<mediawiki xmlns="http://www.mediawiki.org/xml/export-0.11/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.11/ http://www.mediawiki.org/xml/export-0.11.xsd" version="0.11" xml:lang="nr">
  <siteinfo>
    <sitename>Wikiphidiya</sitename>
    <dbname>nrwiki</dbname>
    <base>https://nr.wikipedia.org/wiki/Main_Page</base>
    <generator>MediaWiki 1.46.0-wmf.26</generator>
    <case>first-letter</case>
    <namespaces>
      <namespace key="-2" case="first-letter">Iinrhatjhi</namespace>
      <namespace key="-1" case="first-letter">Khethekileko</namespace>
      <namespace key="0" case="first-letter" />
      <namespace key="1" case="first-letter">Asiqongelane</namespace>
      <namespace key="2" case="first-letter">Umsebenzisi</namespace>
      <namespace key="3" case="first-letter">Umsebenzisi asiqongelane</namespace>
      <namespace key="4" case="first-letter">Wikiphidiya</namespace>
      <namespace key="5" case="first-letter">Wikiphidiya asiqongelane</namespace>
      <namespace key="6" case="first-letter">Isimumathi</namespace>
      <namespace key="7" case="first-letter">Isimumathi asiqongelane</namespace>
      <namespace key="8" case="first-letter">MediaWiki</namespace>
      <namespace key="9" case="first-letter">MediaWiki asiqongelane</namespace>
      <namespace key="10" case="first-letter">Umhlahlandlelasakhiwo</namespace>
      <namespace key="11" case="first-letter">Umhlahlandlelasakhiwo asiqongelane</namespace>
      <namespace key="12" case="first-letter">Lisizo</namespace>
      <namespace key="13" case="first-letter">Lisizo asiqongelane</namespace>
      <namespace key="14" case="first-letter">Mkhakha</namespace>
      <namespace key="15" case="first-letter">Mkhakha asiqongelane</namespace>
      <namespace key="710" case="first-letter">TimedText</namespace>
      <namespace key="711" case="first-letter">TimedText talk</namespace>
      <namespace key="828" case="first-letter">Module</namespace>
      <namespace key="829" case="first-letter">Module talk</namespace>
      <namespace key="1728" case="first-letter">Event</namespace>
      <namespace key="1729" case="first-letter">Event talk</namespace>
    </namespaces>
  </siteinfo>
  <page>
    <title>Main Page</title>
    <ns>0</ns>
    <id>1</id>
    <revision>
      <id>1</id>
      <timestamp>2024-10-14T10:33:00Z</timestamp>
      <contributor>
        <username>Maintenance script</username>
        <id>1</id>
      </contributor>
      <comment>Created page with &quot;&lt;div dir=&quot;ltr&quot; lang=&quot;en&quot; class=&quot;mw-content-ltr&quot;&gt; ==This subdomain is reserved for the creation of a [[wikimedia:Our projects|Wikipedia]] in '''[[w:en:isiNdebele seSewula|isiNdebele seSewula]]''' language==  * Please '''do not start editing''' this new site. This site has a test project on the [[incubator:|Wikimedia Incubator]] (or on the [[betawikiversity:|Beta Wikiversity]] or on the [[oldwikisource:|Old Wikisource]]) and it will be imported to here. * If you would like...&quot;</comment>
      <origin>1</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1416" sha1="q395t1hcdoo8uo1ysxlwgjv93i026xy" xml:space="preserve">&lt;div dir=&quot;ltr&quot; lang=&quot;en&quot; class=&quot;mw-content-ltr&quot;&gt;
==This subdomain is reserved for the creation of a [[wikimedia:Our projects|Wikipedia]] in '''[[w:en:isiNdebele seSewula|isiNdebele seSewula]]''' language==

* Please '''do not start editing''' this new site. This site has a test project on the [[incubator:|Wikimedia Incubator]] (or on the [[betawikiversity:|Beta Wikiversity]] or on the [[oldwikisource:|Old Wikisource]]) and it will be imported to here.
* If you would like to help translating the interface to this language, please do not translate here, but go to [[translatewiki:|translatewiki.net]], a special wiki for translating the interface. That way everyone can use it on every wiki using the [[mw:|same software]].
* For information about how to edit and for other general help, see [[m:Help:Contents|Help on Wikimedia's Meta-Wiki]] or [[mw:Help:Contents|Help on MediaWiki.org]].

== Sister projects ==
&lt;span class=&quot;plainlinks&quot;&gt;
[//www.wikipedia.org Wikipedia] |
[//www.wiktionary.org Wiktionary] |
[//www.wikibooks.org Wikibooks] |
[//www.wikinews.org Wikinews] |
[//www.wikiquote.org Wikiquote] |
[//www.wikisource.org Wikisource] |
[//www.wikiversity.org Wikiversity] |
[//www.wikivoyage.org Wikivoyage] |
[//species.wikimedia.org Wikispecies] |
[//www.wikidata.org Wikidata] |
[//commons.wikimedia.org Commons]
&lt;/span&gt;

See Wikimedia's [[m:|Meta-Wiki]] for the coordination of these projects.
&lt;/div&gt;</text>
      <sha1>q395t1hcdoo8uo1ysxlwgjv93i026xy</sha1>
    </revision>
    <revision>
      <id>1013</id>
      <timestamp>2009-06-01T05:20:53Z</timestamp>
      <contributor>
        <ip>202.67.113.30</ip>
      </contributor>
      <comment>create Main Page</comment>
      <origin>1013</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="526" sha1="1z0fyd8jruhlqccxvpfr9gjgkjtolb8" xml:space="preserve">__NOTOC__
{| wikitable border=&quot;2&quot; width=&quot;100%&quot;
|[[Isimumathi:Flag of South Africa.svg|80px|left]] 
&lt;center&gt;&lt;big&gt;&lt;big&gt; Welcome to the Southern Ndebele Test Wikipedia. &lt;/big&gt;&lt;br /&gt;

{{Wx/Main Page
| project        = Wikipedia
| nativename     = isiNdebele Sewula
| language       = Southern Ndebele
| example        = isiNdebele Sewula
| example.en     = Southern Ndebele language&lt;!--
| inputbox.Label =
| button.Label   = --&gt;
}}
&lt;/center&gt;
|}

&lt;!--Categories--&gt;

&lt;!--Interwikis--&gt;
[[en:]]
[[af:]]
[[xh:]]
[[zu:]]
[[tn:]]
[[ts:]]</text>
      <sha1>1z0fyd8jruhlqccxvpfr9gjgkjtolb8</sha1>
    </revision>
    <revision>
      <id>1014</id>
      <parentid>1013</parentid>
      <timestamp>2009-06-01T05:49:58Z</timestamp>
      <contributor>
        <ip>202.67.113.30</ip>
      </contributor>
      <comment>adding interwikis</comment>
      <origin>1014</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="542" sha1="h5wav7psjk7w9s36s6w4eyi3r7jde0g" xml:space="preserve">__NOTOC__
{| wikitable border=&quot;2&quot; width=&quot;100%&quot;
|[[Isimumathi:Flag of South Africa.svg|80px|left]] 
&lt;center&gt;&lt;big&gt;&lt;big&gt; Welcome to the Southern Ndebele Test Wikipedia. &lt;/big&gt;&lt;br /&gt;

{{Wx/Main Page
| project        = Wikipedia
| nativename     = isiNdebele Sewula
| language       = Southern Ndebele
| example        = isiNdebele Sewula
| example.en     = Southern Ndebele language&lt;!--
| inputbox.Label =
| button.Label   = --&gt;
}}
&lt;/center&gt;
|}

&lt;!--Categories--&gt;

&lt;!--Interwikis--&gt;
[[en:]]
[[af:]]
[[xh:]]
[[zu:]]
[[tn:]]
[[ts:]]
[[ve:]]
[[ss:]]</text>
      <sha1>h5wav7psjk7w9s36s6w4eyi3r7jde0g</sha1>
    </revision>
    <revision>
      <id>1015</id>
      <parentid>1014</parentid>
      <timestamp>2010-09-20T12:06:50Z</timestamp>
      <contributor>
        <username>incubator&gt;Incubator maintenance</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>expand templates</comment>
      <origin>1015</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="294" sha1="4aljo4ro96jif297dtv5qv2zyulzafv" xml:space="preserve">__NOTOC__
{| wikitable border=&quot;2&quot; width=&quot;100%&quot;
|[[Isimumathi:Flag of South Africa.svg|80px|left]] 
&lt;center&gt;&lt;big&gt;&lt;big&gt; Welcome to the Southern Ndebele Test Wikipedia. &lt;/big&gt;&lt;br /&gt;

&lt;/center&gt;
|}

&lt;!--Categories--&gt;

&lt;!--Interwikis--&gt;
[[en:]]
[[af:]]
[[xh:]]
[[zu:]]
[[tn:]]
[[ts:]]
[[ve:]]
[[ss:]]</text>
      <sha1>4aljo4ro96jif297dtv5qv2zyulzafv</sha1>
    </revision>
    <revision>
      <id>1016</id>
      <parentid>1015</parentid>
      <timestamp>2016-02-20T13:23:42Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1016</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5198" sha1="izepysabnmq4xgjstlkm7bwpgx580gt" xml:space="preserve">&lt;!--        BANNER ACROSS TOP OF PAGE        --&gt;
{| id=&quot;mp-topbanner&quot; style=&quot;width:100%; background:#f6f6f6; margin-top:1.2em; border:1px solid #BFB1A3;&quot;
| style=&quot;width:61%; color:#000;&quot; |
&lt;!--        &quot;WELCOME TO WIKIPEDIA&quot; AND ARTICLE COUNT        --&gt;
{| style=&quot;width:280px; border:none; background:none;&quot;
| style=&quot;width:280px; text-align:center; white-space:nowrap; color:#000;&quot; |
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakuthokozisa la nge[[Wikipedia|Wikiphidiya]] ye[[Isindebele|siNdebele]],&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;yiencyclopediya yasmahla etlolwa&amp;nbsp;ngabo bonke&amp;nbsp;abantu.&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenganje, kunemitlolo engu '''{{NUMBEROFARTICLES}}''' ngesiNdebele. Akwande!
&lt;inputbox&gt;
type=create
width=45
break=no
bgcolor=#f0f0f0
buttonlabel=tlola ikhasi 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;div style=&quot;font-size:90%;&quot;&gt;
&lt;/div&gt;
|}
&lt;!--        PORTAL LIST ON RIGHT-HAND SIDE        --&gt;
| style=&quot;width:13%; font-size:95%;&quot; |
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]

| style=&quot;width:13%; font-size:95%;&quot; |
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]

| style=&quot;width:13%; font-size:95%;&quot; |
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}
&lt;/td&gt;&lt;/tr&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:100%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Swaziland.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;small&gt;''Siraghela embili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:6px 0 0 0; background:none; border-spacing: 0px;&quot;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #BFB1A3; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-tfa-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwee...&lt;/h2&gt;
|-
| style=&quot;color:#000;&quot; | &lt;div id=&quot;mp-tfa&quot; style=&quot;padding:2px 5px&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000;padding:2px 5px 5px&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        TOPICS        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #BFB1A3; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000;padding:2px 5px&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
|}
&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mp-other&quot; style=&quot;padding-top:4px; padding-bottom:2px;&quot;&gt;&lt;/div&gt;
&lt;!--        INTERWIKI STRAPLINE        --&gt;
__NOTOC____NOEDITSECTION__
&lt;center&gt;'''[[:meta:Help:Editing|Irhelebho Ngomtlolo]]'''

Uyabawa ukuzifundisa ukutlola lapha ku[[Wikipedia:Sandbox|Sandbox]].

&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#ddcef2; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;
== iWikipedia ngeeilimi ezinye ==
; Ama-Wikipedia Amanye ngeeiLwimi zeAfrika 
[[:af:|Afrikaans]]&amp;nbsp;·
[[:ak:|Akan]]&amp;nbsp;·
[[:am:|አማርኛ]]&amp;nbsp;·
[[:bm:|Bamanankan]]&amp;nbsp;·
[[:ny:|Chi-Chewa]]&amp;nbsp;·
[[:sn:|chiShona]]&amp;nbsp;·
[[:tum:|chiTumbuka]]&amp;nbsp;·
[[:ee:|Ɛʋɛ]]&amp;nbsp;·
[[:ff:|Fulfude]]&amp;nbsp;·
[[:ki:|Gĩkũyũ]]&amp;nbsp;·
[[:ha:|هَوُسَ]]&amp;nbsp;·
[[:ig:|Ìgbo]]&amp;nbsp;·
[[:xh:|isiXhosa]]&amp;nbsp;·
[[:rw:|Kinyarwanda]]&amp;nbsp;·
[[:rn:|Kirundi]]&amp;nbsp;·
[[:sw:|Kiswahili]]&amp;nbsp;·
[[:kg:|Kongo]]&amp;nbsp;·
[[:ln:|Lingala]]&amp;nbsp;·
[[:lg:|Luganda]]&amp;nbsp;·
[[:mg:|Malagasy]]&amp;nbsp;·
[[:arz:|مصرى]]&amp;nbsp;·
[[:om:|Oromoo]]&amp;nbsp;·
[[:sg:|Sängö]]&amp;nbsp;·
[[:st:|seSotho]]&amp;nbsp;·
[[:tn:|Setswana]]&amp;nbsp;·
[[:ss:|SiSwati]]&amp;nbsp;·
[[:so:|Soomaaliga]]&amp;nbsp;·
[[:kab:|Taqbaylit]]&amp;nbsp;·
[[:ti:|ትግርኛ]]&amp;nbsp;·
[[:ve:|Tshivenda]]&amp;nbsp;·
[[:tw:|Twi]]&amp;nbsp;·
[[:wo:|Wolof]]&amp;nbsp;·
[[:ts:|Xitsonga]]&amp;nbsp;·
[[:yo:|Yorùbá]]&amp;nbsp;·
(Uma ufuna ukuqala Ama-Wikipedia amakhulu, qala ku-bar engasesineneni)
&lt;div class=&quot;plainlinks&quot;&gt;
; Amaphrojekthi afana
: [http://meta.wikipedia.org Meta-Wikipedia]&amp;nbsp;· [http://wiktionary.org Wiktionary]&amp;nbsp;· [http://wikibooks.org Wikibooks]&amp;nbsp;· [http://wikiquote.org Wikiquote]&amp;nbsp;· [http://wikisource.org Wikisource]
&lt;/div&gt;
---
&lt;/center&gt;
|}</text>
      <sha1>izepysabnmq4xgjstlkm7bwpgx580gt</sha1>
    </revision>
    <revision>
      <id>1017</id>
      <parentid>1016</parentid>
      <timestamp>2016-02-20T14:42:28Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1017</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5195" sha1="0rc6xz4y28zbunrbg0bgh4bysfuqluf" xml:space="preserve">&lt;!--        BANNER ACROSS TOP OF PAGE        --&gt;
{| id=&quot;mp-topbanner&quot; style=&quot;width:100%; background:#f6f6f6; margin-top:1.2em; border:1px solid #BFB1A3;&quot;
| style=&quot;width:61%; color:#000;&quot; |
&lt;!--        &quot;WELCOME TO WIKIPEDIA&quot; AND ARTICLE COUNT        --&gt;
{| style=&quot;width:280px; border:none; background:none;&quot;
| style=&quot;width:280px; text-align:center; white-space:nowrap; color:#000;&quot; |
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakuthokozisa la nge[[Wikipedia|Wikiphidiya]] ye[[Isindebele|siNdebele]],&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;yiencyclopediya yasmahla etlolwa&amp;nbsp;ngabo bonke&amp;nbsp;abantu.&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenganje, kunemitlolo engu '''{{NUMBEROFARTICLES}}''' ngesiNdebele. Akwande!
&lt;inputbox&gt;
type=create
width=45
break=no
bgcolor=#f0f0f0
buttonlabel=tlola ikhasi 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;div style=&quot;font-size:90%;&quot;&gt;
&lt;/div&gt;
|}
&lt;!--        PORTAL LIST ON RIGHT-HAND SIDE        --&gt;
| style=&quot;width:13%; font-size:95%;&quot; |
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]

| style=&quot;width:13%; font-size:95%;&quot; |
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]

| style=&quot;width:13%; font-size:95%;&quot; |
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}
&lt;/td&gt;&lt;/tr&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:100%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Swaziland.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;small&gt;''Siraghela embili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:6px 0 0 0; background:none; border-spacing: 0px;&quot;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #BFB1A3; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-tfa-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwee...&lt;/h2&gt;
|-
| style=&quot;color:#000;&quot; | &lt;div id=&quot;mp-tfa&quot; style=&quot;padding:2px 5px&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000;padding:2px 5px 5px&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        TOPICS        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #BFB1A3; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000;padding:2px 5px&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mp-other&quot; style=&quot;padding-top:4px; padding-bottom:2px;&quot;&gt;&lt;/div&gt;
&lt;!--        INTERWIKI STRAPLINE        --&gt;
__NOTOC____NOEDITSECTION__
&lt;center&gt;'''[[:meta:Help:Editing|Irhelebho Ngomtlolo]]'''

Uyabawa ukuzifundisa ukutlola lapha ku[[Wikipedia:Sandbox|Sandbox]].

&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#ddcef2; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;
== iWikipedia ngeeilimi ezinye ==
; Ama-Wikipedia Amanye ngeeiLwimi zeAfrika 
[[:af:|Afrikaans]]&amp;nbsp;·
[[:ak:|Akan]]&amp;nbsp;·
[[:am:|አማርኛ]]&amp;nbsp;·
[[:bm:|Bamanankan]]&amp;nbsp;·
[[:ny:|Chi-Chewa]]&amp;nbsp;·
[[:sn:|chiShona]]&amp;nbsp;·
[[:tum:|chiTumbuka]]&amp;nbsp;·
[[:ee:|Ɛʋɛ]]&amp;nbsp;·
[[:ff:|Fulfude]]&amp;nbsp;·
[[:ki:|Gĩkũyũ]]&amp;nbsp;·
[[:ha:|هَوُسَ]]&amp;nbsp;·
[[:ig:|Ìgbo]]&amp;nbsp;·
[[:xh:|isiXhosa]]&amp;nbsp;·
[[:rw:|Kinyarwanda]]&amp;nbsp;·
[[:rn:|Kirundi]]&amp;nbsp;·
[[:sw:|Kiswahili]]&amp;nbsp;·
[[:kg:|Kongo]]&amp;nbsp;·
[[:ln:|Lingala]]&amp;nbsp;·
[[:lg:|Luganda]]&amp;nbsp;·
[[:mg:|Malagasy]]&amp;nbsp;·
[[:arz:|مصرى]]&amp;nbsp;·
[[:om:|Oromoo]]&amp;nbsp;·
[[:sg:|Sängö]]&amp;nbsp;·
[[:st:|seSotho]]&amp;nbsp;·
[[:tn:|Setswana]]&amp;nbsp;·
[[:ss:|SiSwati]]&amp;nbsp;·
[[:so:|Soomaaliga]]&amp;nbsp;·
[[:kab:|Taqbaylit]]&amp;nbsp;·
[[:ti:|ትግርኛ]]&amp;nbsp;·
[[:ve:|Tshivenda]]&amp;nbsp;·
[[:tw:|Twi]]&amp;nbsp;·
[[:wo:|Wolof]]&amp;nbsp;·
[[:ts:|Xitsonga]]&amp;nbsp;·
[[:yo:|Yorùbá]]&amp;nbsp;·
(Uma ufuna ukuqala Ama-Wikipedia amakhulu, qala ku-bar engasesineneni)
&lt;div class=&quot;plainlinks&quot;&gt;
; Amaphrojekthi afana
: [http://meta.wikipedia.org Meta-Wikipedia]&amp;nbsp;· [http://wiktionary.org Wiktionary]&amp;nbsp;· [http://wikibooks.org Wikibooks]&amp;nbsp;· [http://wikiquote.org Wikiquote]&amp;nbsp;· [http://wikisource.org Wikisource]
&lt;/div&gt;
---
&lt;/center&gt;
|}</text>
      <sha1>0rc6xz4y28zbunrbg0bgh4bysfuqluf</sha1>
    </revision>
    <revision>
      <id>1018</id>
      <parentid>1017</parentid>
      <timestamp>2016-02-20T14:45:15Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1018</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5194" sha1="53me1tuy2m0nor4j4e5y507ti68rmjq" xml:space="preserve">&lt;!--        BANNER ACROSS TOP OF PAGE        --&gt;
{| id=&quot;mp-topbanner&quot; style=&quot;width:100%; background:#f6f6f6; margin-top:1.2em; border:1px solid #BFB1A3;&quot;
| style=&quot;width:61%; color:#000;&quot; |
&lt;!--        &quot;WELCOME TO WIKIPEDIA&quot; AND ARTICLE COUNT        --&gt;
{| style=&quot;width:280px; border:none; background:none;&quot;
| style=&quot;width:280px; text-align:center; white-space:nowrap; color:#000;&quot; |
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakuthokozisa la nge[[Wikipedia|Wikiphidiya]] ye[[Isindebele|siNdebele]],&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;yiencyclopediya yasmahla etlolwa&amp;nbsp;ngabo bonke&amp;nbsp;abantu.&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenganje, kunemitlolo engu '''{{NUMBEROFARTICLES}}''' ngesiNdebele. Akwande!
&lt;inputbox&gt;
type=create
width=45
break=no
bgcolor=#f0f0f0
buttonlabel=tlola ikhasi 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;div style=&quot;font-size:90%;&quot;&gt;
&lt;/div&gt;
|}
&lt;!--        PORTAL LIST ON RIGHT-HAND SIDE        --&gt;
| style=&quot;width:13%; font-size:95%;&quot; |
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]

| style=&quot;width:13%; font-size:95%;&quot; |
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]

| style=&quot;width:13%; font-size:95%;&quot; |
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}
&lt;/td&gt;&lt;/tr&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:100%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Swaziland.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;small&gt;''Siraghela embili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:6px 0 0 0; background:none; border-spacing: 0px;&quot;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #BFB1A3; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-tfa-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwee...&lt;/h2&gt;
|-
| style=&quot;color:#000;&quot; | &lt;div id=&quot;mp-tfa&quot; style=&quot;padding:2px 5px&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000;padding:2px 5px 5px&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        TOPICS        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #BFB1A3; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:80%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000;padding:2px 5px&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mp-other&quot; style=&quot;padding-top:4px; padding-bottom:2px;&quot;&gt;&lt;/div&gt;
&lt;!--        INTERWIKI STRAPLINE        --&gt;
__NOTOC____NOEDITSECTION__
&lt;center&gt;'''[[:meta:Help:Editing|Irhelebho Ngomtlolo]]'''

Uyabawa ukuzifundisa ukutlola lapha ku[[Wikipedia:Sandbox|Sandbox]].

&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#ddcef2; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;
== iWikipedia ngeeilimi ezinye ==
; Ama-Wikipedia Amanye ngeeiLwimi zeAfrika 
[[:af:|Afrikaans]]&amp;nbsp;·
[[:ak:|Akan]]&amp;nbsp;·
[[:am:|አማርኛ]]&amp;nbsp;·
[[:bm:|Bamanankan]]&amp;nbsp;·
[[:ny:|Chi-Chewa]]&amp;nbsp;·
[[:sn:|chiShona]]&amp;nbsp;·
[[:tum:|chiTumbuka]]&amp;nbsp;·
[[:ee:|Ɛʋɛ]]&amp;nbsp;·
[[:ff:|Fulfude]]&amp;nbsp;·
[[:ki:|Gĩkũyũ]]&amp;nbsp;·
[[:ha:|هَوُسَ]]&amp;nbsp;·
[[:ig:|Ìgbo]]&amp;nbsp;·
[[:xh:|isiXhosa]]&amp;nbsp;·
[[:rw:|Kinyarwanda]]&amp;nbsp;·
[[:rn:|Kirundi]]&amp;nbsp;·
[[:sw:|Kiswahili]]&amp;nbsp;·
[[:kg:|Kongo]]&amp;nbsp;·
[[:ln:|Lingala]]&amp;nbsp;·
[[:lg:|Luganda]]&amp;nbsp;·
[[:mg:|Malagasy]]&amp;nbsp;·
[[:arz:|مصرى]]&amp;nbsp;·
[[:om:|Oromoo]]&amp;nbsp;·
[[:sg:|Sängö]]&amp;nbsp;·
[[:st:|seSotho]]&amp;nbsp;·
[[:tn:|Setswana]]&amp;nbsp;·
[[:ss:|SiSwati]]&amp;nbsp;·
[[:so:|Soomaaliga]]&amp;nbsp;·
[[:kab:|Taqbaylit]]&amp;nbsp;·
[[:ti:|ትግርኛ]]&amp;nbsp;·
[[:ve:|Tshivenda]]&amp;nbsp;·
[[:tw:|Twi]]&amp;nbsp;·
[[:wo:|Wolof]]&amp;nbsp;·
[[:ts:|Xitsonga]]&amp;nbsp;·
[[:yo:|Yorùbá]]&amp;nbsp;·
(Uma ufuna ukuqala Ama-Wikipedia amakhulu, qala ku-bar engasesineneni)
&lt;div class=&quot;plainlinks&quot;&gt;
; Amaphrojekthi afana
: [http://meta.wikipedia.org Meta-Wikipedia]&amp;nbsp;· [http://wiktionary.org Wiktionary]&amp;nbsp;· [http://wikibooks.org Wikibooks]&amp;nbsp;· [http://wikiquote.org Wikiquote]&amp;nbsp;· [http://wikisource.org Wikisource]
&lt;/div&gt;
---
&lt;/center&gt;
|}</text>
      <sha1>53me1tuy2m0nor4j4e5y507ti68rmjq</sha1>
    </revision>
    <revision>
      <id>1019</id>
      <parentid>1018</parentid>
      <timestamp>2016-02-20T14:48:04Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1019</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5208" sha1="9pyqr9bo0j7u69fq348cqe31zjii3k6" xml:space="preserve">&lt;!--        BANNER ACROSS TOP OF PAGE        --&gt;
{| id=&quot;mp-topbanner&quot; style=&quot;width:100%; background:#f6f6f6; margin-top:1.2em; border:1px solid #BFB1A3;&quot;
| style=&quot;width:61%; color:#000;&quot; |
&lt;!--        &quot;WELCOME TO WIKIPEDIA&quot; AND ARTICLE COUNT        --&gt;
{| style=&quot;width:280px; border:none; background:none;&quot;
| style=&quot;width:280px; text-align:center; white-space:nowrap; color:#000;&quot; |
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakuthokozisa la nge[[Wikipedia|Wikiphidiya]] ye[[Isindebele|siNdebele]],&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;yiencyclopediya yasmahla etlolwa&amp;nbsp;ngabo bonke&amp;nbsp;abantu.&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenganje, kunemitlolo engu '''{{NUMBEROFARTICLES}}''' ngesiNdebele. Akwande!
&lt;inputbox&gt;
type=create
width=45
break=no
bgcolor=#f0f0f0
buttonlabel=tlola ikhasi 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;div style=&quot;font-size:90%;&quot;&gt;
&lt;/div&gt;
|}
&lt;!--        PORTAL LIST ON RIGHT-HAND SIDE        --&gt;
| style=&quot;width:13%; font-size:95%;&quot; |
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]

| style=&quot;width:13%; font-size:95%;&quot; |
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]

| style=&quot;width:13%; font-size:95%;&quot; |
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}
&lt;/td&gt;&lt;/tr&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:100%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Swaziland.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;small&gt;''Siraghela embili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:6px 0 0 0; background:none; border-spacing: 0px;&quot;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #BFB1A3; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-tfa-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwee...&lt;/h2&gt;
|-
| style=&quot;color:#000;&quot; | &lt;div id=&quot;mp-tfa&quot; style=&quot;padding:2px 5px&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000;padding:2px 5px 5px&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        TOPICS        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #BFB1A3; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:80%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000;padding:2px 5px&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mp-other&quot; style=&quot;padding-top:4px; font-size:75%; padding-bottom:2px;&quot;&gt;&lt;/div&gt;
&lt;!--        INTERWIKI STRAPLINE        --&gt;
__NOTOC____NOEDITSECTION__
&lt;center&gt;'''[[:meta:Help:Editing|Irhelebho Ngomtlolo]]'''

Uyabawa ukuzifundisa ukutlola lapha ku[[Wikipedia:Sandbox|Sandbox]].

&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:75%;width: 100%; background-color:#ddcef2; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;
== iWikipedia ngeeilimi ezinye ==
; Ama-Wikipedia Amanye ngeeiLwimi zeAfrika 
[[:af:|Afrikaans]]&amp;nbsp;·
[[:ak:|Akan]]&amp;nbsp;·
[[:am:|አማርኛ]]&amp;nbsp;·
[[:bm:|Bamanankan]]&amp;nbsp;·
[[:ny:|Chi-Chewa]]&amp;nbsp;·
[[:sn:|chiShona]]&amp;nbsp;·
[[:tum:|chiTumbuka]]&amp;nbsp;·
[[:ee:|Ɛʋɛ]]&amp;nbsp;·
[[:ff:|Fulfude]]&amp;nbsp;·
[[:ki:|Gĩkũyũ]]&amp;nbsp;·
[[:ha:|هَوُسَ]]&amp;nbsp;·
[[:ig:|Ìgbo]]&amp;nbsp;·
[[:xh:|isiXhosa]]&amp;nbsp;·
[[:rw:|Kinyarwanda]]&amp;nbsp;·
[[:rn:|Kirundi]]&amp;nbsp;·
[[:sw:|Kiswahili]]&amp;nbsp;·
[[:kg:|Kongo]]&amp;nbsp;·
[[:ln:|Lingala]]&amp;nbsp;·
[[:lg:|Luganda]]&amp;nbsp;·
[[:mg:|Malagasy]]&amp;nbsp;·
[[:arz:|مصرى]]&amp;nbsp;·
[[:om:|Oromoo]]&amp;nbsp;·
[[:sg:|Sängö]]&amp;nbsp;·
[[:st:|seSotho]]&amp;nbsp;·
[[:tn:|Setswana]]&amp;nbsp;·
[[:ss:|SiSwati]]&amp;nbsp;·
[[:so:|Soomaaliga]]&amp;nbsp;·
[[:kab:|Taqbaylit]]&amp;nbsp;·
[[:ti:|ትግርኛ]]&amp;nbsp;·
[[:ve:|Tshivenda]]&amp;nbsp;·
[[:tw:|Twi]]&amp;nbsp;·
[[:wo:|Wolof]]&amp;nbsp;·
[[:ts:|Xitsonga]]&amp;nbsp;·
[[:yo:|Yorùbá]]&amp;nbsp;·
(Uma ufuna ukuqala Ama-Wikipedia amakhulu, qala ku-bar engasesineneni)
&lt;div class=&quot;plainlinks&quot;&gt;
; Amaphrojekthi afana
: [http://meta.wikipedia.org Meta-Wikipedia]&amp;nbsp;· [http://wiktionary.org Wiktionary]&amp;nbsp;· [http://wikibooks.org Wikibooks]&amp;nbsp;· [http://wikiquote.org Wikiquote]&amp;nbsp;· [http://wikisource.org Wikisource]
&lt;/div&gt;
---
&lt;/center&gt;
|}</text>
      <sha1>9pyqr9bo0j7u69fq348cqe31zjii3k6</sha1>
    </revision>
    <revision>
      <id>1020</id>
      <parentid>1019</parentid>
      <timestamp>2016-02-20T14:49:53Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1020</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5209" sha1="99a37ku07b1g9r3t0u6iho0yh2xf2wa" xml:space="preserve">&lt;!--        BANNER ACROSS TOP OF PAGE        --&gt;
{| id=&quot;mp-topbanner&quot; style=&quot;width:100%; background:#f6f6f6; margin-top:1.2em; border:1px solid #BFB1A3;&quot;
| style=&quot;width:61%; color:#000;&quot; |
&lt;!--        &quot;WELCOME TO WIKIPEDIA&quot; AND ARTICLE COUNT        --&gt;
{| style=&quot;width:280px; border:none; background:none;&quot;
| style=&quot;width:280px; text-align:center; white-space:nowrap; color:#000;&quot; |
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakuthokozisa la nge[[Wikipedia|Wikiphidiya]] ye[[Isindebele|siNdebele]],&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;yiencyclopediya yasmahla etlolwa&amp;nbsp;ngabo bonke&amp;nbsp;abantu.&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenganje, kunemitlolo engu '''{{NUMBEROFARTICLES}}''' ngesiNdebele. Akwande!
&lt;inputbox&gt;
type=create
width=45
break=no
bgcolor=#f0f0f0
buttonlabel=tlola ikhasi 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;div style=&quot;font-size:90%;&quot;&gt;
&lt;/div&gt;
|}
&lt;!--        PORTAL LIST ON RIGHT-HAND SIDE        --&gt;
| style=&quot;width:13%; font-size:95%;&quot; |
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]

| style=&quot;width:13%; font-size:95%;&quot; |
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]

| style=&quot;width:13%; font-size:95%;&quot; |
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}
&lt;/td&gt;&lt;/tr&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:100%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Swaziland.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;small&gt;''Siraghela embili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:6px 0 0 0; background:none; border-spacing: 0px;&quot;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #BFB1A3; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-tfa-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:110%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwee...&lt;/h2&gt;
|-
| style=&quot;color:#000;&quot; | &lt;div id=&quot;mp-tfa&quot; style=&quot;padding:2px 5px&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:110%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000;padding:2px 5px 5px&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        TOPICS        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #BFB1A3; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:110%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000;padding:2px 5px&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mp-other&quot; style=&quot;padding-top:4px; font-size:85%; padding-bottom:2px;&quot;&gt;&lt;/div&gt;
&lt;!--        INTERWIKI STRAPLINE        --&gt;
__NOTOC____NOEDITSECTION__
&lt;center&gt;'''[[:meta:Help:Editing|Irhelebho Ngomtlolo]]'''

Uyabawa ukuzifundisa ukutlola lapha ku[[Wikipedia:Sandbox|Sandbox]].

&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:85%;width: 100%; background-color:#ddcef2; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;
== iWikipedia ngeeilimi ezinye ==
; Ama-Wikipedia Amanye ngeeiLwimi zeAfrika 
[[:af:|Afrikaans]]&amp;nbsp;·
[[:ak:|Akan]]&amp;nbsp;·
[[:am:|አማርኛ]]&amp;nbsp;·
[[:bm:|Bamanankan]]&amp;nbsp;·
[[:ny:|Chi-Chewa]]&amp;nbsp;·
[[:sn:|chiShona]]&amp;nbsp;·
[[:tum:|chiTumbuka]]&amp;nbsp;·
[[:ee:|Ɛʋɛ]]&amp;nbsp;·
[[:ff:|Fulfude]]&amp;nbsp;·
[[:ki:|Gĩkũyũ]]&amp;nbsp;·
[[:ha:|هَوُسَ]]&amp;nbsp;·
[[:ig:|Ìgbo]]&amp;nbsp;·
[[:xh:|isiXhosa]]&amp;nbsp;·
[[:rw:|Kinyarwanda]]&amp;nbsp;·
[[:rn:|Kirundi]]&amp;nbsp;·
[[:sw:|Kiswahili]]&amp;nbsp;·
[[:kg:|Kongo]]&amp;nbsp;·
[[:ln:|Lingala]]&amp;nbsp;·
[[:lg:|Luganda]]&amp;nbsp;·
[[:mg:|Malagasy]]&amp;nbsp;·
[[:arz:|مصرى]]&amp;nbsp;·
[[:om:|Oromoo]]&amp;nbsp;·
[[:sg:|Sängö]]&amp;nbsp;·
[[:st:|seSotho]]&amp;nbsp;·
[[:tn:|Setswana]]&amp;nbsp;·
[[:ss:|SiSwati]]&amp;nbsp;·
[[:so:|Soomaaliga]]&amp;nbsp;·
[[:kab:|Taqbaylit]]&amp;nbsp;·
[[:ti:|ትግርኛ]]&amp;nbsp;·
[[:ve:|Tshivenda]]&amp;nbsp;·
[[:tw:|Twi]]&amp;nbsp;·
[[:wo:|Wolof]]&amp;nbsp;·
[[:ts:|Xitsonga]]&amp;nbsp;·
[[:yo:|Yorùbá]]&amp;nbsp;·
(Uma ufuna ukuqala Ama-Wikipedia amakhulu, qala ku-bar engasesineneni)
&lt;div class=&quot;plainlinks&quot;&gt;
; Amaphrojekthi afana
: [http://meta.wikipedia.org Meta-Wikipedia]&amp;nbsp;· [http://wiktionary.org Wiktionary]&amp;nbsp;· [http://wikibooks.org Wikibooks]&amp;nbsp;· [http://wikiquote.org Wikiquote]&amp;nbsp;· [http://wikisource.org Wikisource]
&lt;/div&gt;
---
&lt;/center&gt;
|}</text>
      <sha1>99a37ku07b1g9r3t0u6iho0yh2xf2wa</sha1>
    </revision>
    <revision>
      <id>1021</id>
      <parentid>1020</parentid>
      <timestamp>2016-02-20T17:09:25Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1020</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5209" sha1="99a37ku07b1g9r3t0u6iho0yh2xf2wa" xml:space="preserve">&lt;!--        BANNER ACROSS TOP OF PAGE        --&gt;
{| id=&quot;mp-topbanner&quot; style=&quot;width:100%; background:#f6f6f6; margin-top:1.2em; border:1px solid #BFB1A3;&quot;
| style=&quot;width:61%; color:#000;&quot; |
&lt;!--        &quot;WELCOME TO WIKIPEDIA&quot; AND ARTICLE COUNT        --&gt;
{| style=&quot;width:280px; border:none; background:none;&quot;
| style=&quot;width:280px; text-align:center; white-space:nowrap; color:#000;&quot; |
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakuthokozisa la nge[[Wikipedia|Wikiphidiya]] ye[[Isindebele|siNdebele]],&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;yiencyclopediya yasmahla etlolwa&amp;nbsp;ngabo bonke&amp;nbsp;abantu.&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenganje, kunemitlolo engu '''{{NUMBEROFARTICLES}}''' ngesiNdebele. Akwande!
&lt;inputbox&gt;
type=create
width=45
break=no
bgcolor=#f0f0f0
buttonlabel=tlola ikhasi 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;div style=&quot;font-size:90%;&quot;&gt;
&lt;/div&gt;
|}
&lt;!--        PORTAL LIST ON RIGHT-HAND SIDE        --&gt;
| style=&quot;width:13%; font-size:95%;&quot; |
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]

| style=&quot;width:13%; font-size:95%;&quot; |
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]

| style=&quot;width:13%; font-size:95%;&quot; |
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}
&lt;/td&gt;&lt;/tr&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:100%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Swaziland.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;small&gt;''Siraghela embili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:6px 0 0 0; background:none; border-spacing: 0px;&quot;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #BFB1A3; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-tfa-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:110%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwee...&lt;/h2&gt;
|-
| style=&quot;color:#000;&quot; | &lt;div id=&quot;mp-tfa&quot; style=&quot;padding:2px 5px&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:110%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000;padding:2px 5px 5px&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        TOPICS        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #BFB1A3; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:110%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000;padding:2px 5px&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mp-other&quot; style=&quot;padding-top:4px; font-size:85%; padding-bottom:2px;&quot;&gt;&lt;/div&gt;
&lt;!--        INTERWIKI STRAPLINE        --&gt;
__NOTOC____NOEDITSECTION__
&lt;center&gt;'''[[:meta:Help:Editing|Irhelebho Ngomtlolo]]'''

Uyabawa ukuzifundisa ukutlola lapha ku[[Wikipedia:Sandbox|Sandbox]].

&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:85%;width: 100%; background-color:#ddcef2; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;
== iWikipedia ngeeilimi ezinye ==
; Ama-Wikipedia Amanye ngeeiLwimi zeAfrika 
[[:af:|Afrikaans]]&amp;nbsp;·
[[:ak:|Akan]]&amp;nbsp;·
[[:am:|አማርኛ]]&amp;nbsp;·
[[:bm:|Bamanankan]]&amp;nbsp;·
[[:ny:|Chi-Chewa]]&amp;nbsp;·
[[:sn:|chiShona]]&amp;nbsp;·
[[:tum:|chiTumbuka]]&amp;nbsp;·
[[:ee:|Ɛʋɛ]]&amp;nbsp;·
[[:ff:|Fulfude]]&amp;nbsp;·
[[:ki:|Gĩkũyũ]]&amp;nbsp;·
[[:ha:|هَوُسَ]]&amp;nbsp;·
[[:ig:|Ìgbo]]&amp;nbsp;·
[[:xh:|isiXhosa]]&amp;nbsp;·
[[:rw:|Kinyarwanda]]&amp;nbsp;·
[[:rn:|Kirundi]]&amp;nbsp;·
[[:sw:|Kiswahili]]&amp;nbsp;·
[[:kg:|Kongo]]&amp;nbsp;·
[[:ln:|Lingala]]&amp;nbsp;·
[[:lg:|Luganda]]&amp;nbsp;·
[[:mg:|Malagasy]]&amp;nbsp;·
[[:arz:|مصرى]]&amp;nbsp;·
[[:om:|Oromoo]]&amp;nbsp;·
[[:sg:|Sängö]]&amp;nbsp;·
[[:st:|seSotho]]&amp;nbsp;·
[[:tn:|Setswana]]&amp;nbsp;·
[[:ss:|SiSwati]]&amp;nbsp;·
[[:so:|Soomaaliga]]&amp;nbsp;·
[[:kab:|Taqbaylit]]&amp;nbsp;·
[[:ti:|ትግርኛ]]&amp;nbsp;·
[[:ve:|Tshivenda]]&amp;nbsp;·
[[:tw:|Twi]]&amp;nbsp;·
[[:wo:|Wolof]]&amp;nbsp;·
[[:ts:|Xitsonga]]&amp;nbsp;·
[[:yo:|Yorùbá]]&amp;nbsp;·
(Uma ufuna ukuqala Ama-Wikipedia amakhulu, qala ku-bar engasesineneni)
&lt;div class=&quot;plainlinks&quot;&gt;
; Amaphrojekthi afana
: [http://meta.wikipedia.org Meta-Wikipedia]&amp;nbsp;· [http://wiktionary.org Wiktionary]&amp;nbsp;· [http://wikibooks.org Wikibooks]&amp;nbsp;· [http://wikiquote.org Wikiquote]&amp;nbsp;· [http://wikisource.org Wikisource]
&lt;/div&gt;
---
&lt;/center&gt;
|}</text>
      <sha1>99a37ku07b1g9r3t0u6iho0yh2xf2wa</sha1>
    </revision>
    <revision>
      <id>1022</id>
      <parentid>1021</parentid>
      <timestamp>2016-02-20T17:17:13Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1022</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5225" sha1="jhs2r8mh2yrgf9ajpyx4lvfk85h9ugv" xml:space="preserve">&lt;!--        BANNER ACROSS TOP OF PAGE        --&gt;
{| id=&quot;mp-topbanner&quot; style=&quot;width:100%; background:#f6f6f6; margin-top:1.2em; border:1px solid #BFB1A3;&quot;
| style=&quot;width:61%; color:#000;&quot; |
&lt;!--        &quot;WELCOME TO WIKIPEDIA&quot; AND ARTICLE COUNT        --&gt;
{| style=&quot;width:280px; border:none; background:none;&quot;
| style=&quot;width:280px; text-align:center; white-space:nowrap; color:#000;&quot; |
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakuthokozisa la nge[[Wikipedia|Wikiphidiya]] ye[[Isindebele|siNdebele]],&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;yiencyclopediya yasmahla etlolwa&amp;nbsp;ngabo bonke&amp;nbsp;abantu.&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenganje, kunemitlolo engu '''{{NUMBEROFARTICLES}}''' ngesiNdebele. Akwande!
&lt;inputbox&gt;
type=create
width=45
break=no
bgcolor=#f0f0f0
buttonlabel=tlola ikhasi 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;div style=&quot;font-size:90%;&quot;&gt;
&lt;/div&gt;
|}
&lt;!--        PORTAL LIST ON RIGHT-HAND SIDE        --&gt;
| style=&quot;width:13%; font-size:95%;&quot; |
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]

| style=&quot;width:13%; font-size:95%;&quot; |
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]

| style=&quot;width:13%; font-size:95%;&quot; |
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}
&lt;/td&gt;&lt;/tr&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:100%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Swaziland.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;small&gt;''Siraghela embili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:6px 0 0 0; background:none; border-spacing: 0px;&quot;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #BFB1A3; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-tfa-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:110%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwee...&lt;/h2&gt;
|-
| style=&quot;color:#000;&quot; | &lt;div id=&quot;mp-tfa&quot; style=&quot;padding:2px 5px; font-size:90%;&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:110%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000;padding:2px 5px 5px&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        TOPICS        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #BFB1A3; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:110%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000;padding:2px 5px&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mp-other&quot; style=&quot;padding-top:4px; font-size:85%; padding-bottom:2px;&quot;&gt;&lt;/div&gt;
&lt;!--        INTERWIKI STRAPLINE        --&gt;
__NOTOC____NOEDITSECTION__
&lt;center&gt;'''[[:meta:Help:Editing|Irhelebho Ngomtlolo]]'''

Uyabawa ukuzifundisa ukutlola lapha ku[[Wikipedia:Sandbox|Sandbox]].

&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:85%;width: 100%; background-color:#ddcef2; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;
== iWikipedia ngeeilimi ezinye ==
; Ama-Wikipedia Amanye ngeeiLwimi zeAfrika 
[[:af:|Afrikaans]]&amp;nbsp;·
[[:ak:|Akan]]&amp;nbsp;·
[[:am:|አማርኛ]]&amp;nbsp;·
[[:bm:|Bamanankan]]&amp;nbsp;·
[[:ny:|Chi-Chewa]]&amp;nbsp;·
[[:sn:|chiShona]]&amp;nbsp;·
[[:tum:|chiTumbuka]]&amp;nbsp;·
[[:ee:|Ɛʋɛ]]&amp;nbsp;·
[[:ff:|Fulfude]]&amp;nbsp;·
[[:ki:|Gĩkũyũ]]&amp;nbsp;·
[[:ha:|هَوُسَ]]&amp;nbsp;·
[[:ig:|Ìgbo]]&amp;nbsp;·
[[:xh:|isiXhosa]]&amp;nbsp;·
[[:rw:|Kinyarwanda]]&amp;nbsp;·
[[:rn:|Kirundi]]&amp;nbsp;·
[[:sw:|Kiswahili]]&amp;nbsp;·
[[:kg:|Kongo]]&amp;nbsp;·
[[:ln:|Lingala]]&amp;nbsp;·
[[:lg:|Luganda]]&amp;nbsp;·
[[:mg:|Malagasy]]&amp;nbsp;·
[[:arz:|مصرى]]&amp;nbsp;·
[[:om:|Oromoo]]&amp;nbsp;·
[[:sg:|Sängö]]&amp;nbsp;·
[[:st:|seSotho]]&amp;nbsp;·
[[:tn:|Setswana]]&amp;nbsp;·
[[:ss:|SiSwati]]&amp;nbsp;·
[[:so:|Soomaaliga]]&amp;nbsp;·
[[:kab:|Taqbaylit]]&amp;nbsp;·
[[:ti:|ትግርኛ]]&amp;nbsp;·
[[:ve:|Tshivenda]]&amp;nbsp;·
[[:tw:|Twi]]&amp;nbsp;·
[[:wo:|Wolof]]&amp;nbsp;·
[[:ts:|Xitsonga]]&amp;nbsp;·
[[:yo:|Yorùbá]]&amp;nbsp;·
(Uma ufuna ukuqala Ama-Wikipedia amakhulu, qala ku-bar engasesineneni)
&lt;div class=&quot;plainlinks&quot;&gt;
; Amaphrojekthi afana
: [http://meta.wikipedia.org Meta-Wikipedia]&amp;nbsp;· [http://wiktionary.org Wiktionary]&amp;nbsp;· [http://wikibooks.org Wikibooks]&amp;nbsp;· [http://wikiquote.org Wikiquote]&amp;nbsp;· [http://wikisource.org Wikisource]
&lt;/div&gt;
---
&lt;/center&gt;
|}</text>
      <sha1>jhs2r8mh2yrgf9ajpyx4lvfk85h9ugv</sha1>
    </revision>
    <revision>
      <id>1023</id>
      <parentid>1022</parentid>
      <timestamp>2016-02-20T17:21:01Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1023</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5225" sha1="dik6ds5ctwapdgle7w8hy01f1dfqxih" xml:space="preserve">&lt;!--        BANNER ACROSS TOP OF PAGE        --&gt;
{| id=&quot;mp-topbanner&quot; style=&quot;width:100%; background:#f6f6f6; margin-top:1.2em; border:1px solid #BFB1A3;&quot;
| style=&quot;width:61%; color:#000;&quot; |
&lt;!--        &quot;WELCOME TO WIKIPEDIA&quot; AND ARTICLE COUNT        --&gt;
{| style=&quot;width:280px; border:none; background:none;&quot;
| style=&quot;width:280px; text-align:center; white-space:nowrap; color:#000;&quot; |
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakuthokozisa la nge[[Wikipedia|Wikiphidiya]] ye[[Isindebele|siNdebele]],&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;yiencyclopediya yasmahla etlolwa&amp;nbsp;ngabo bonke&amp;nbsp;abantu.&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenganje, kunemitlolo engu '''{{NUMBEROFARTICLES}}''' ngesiNdebele. Akwande!
&lt;inputbox&gt;
type=create
width=45
break=no
bgcolor=#f0f0f0
buttonlabel=tlola ikhasi 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;div style=&quot;font-size:90%;&quot;&gt;
&lt;/div&gt;
|}
&lt;!--        PORTAL LIST ON RIGHT-HAND SIDE        --&gt;
| style=&quot;width:13%; font-size:95%;&quot; |
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]

| style=&quot;width:13%; font-size:95%;&quot; |
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]

| style=&quot;width:13%; font-size:95%;&quot; |
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}
&lt;/td&gt;&lt;/tr&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:100%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Swaziland.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;small&gt;''Siraghela embili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:6px 0 0 0; background:none; border-spacing: 0px;&quot;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #BFB1A3; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-tfa-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:110%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwee...&lt;/h2&gt;
|-
| style=&quot;color:#000;&quot; | &lt;div id=&quot;mp-dyk&quot; style=&quot;padding:2px 5px; font-size:90%;&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:110%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000;padding:2px 5px 5px&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        TOPICS        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #BFB1A3; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:110%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000;padding:2px 5px&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mp-other&quot; style=&quot;padding-top:4px; font-size:85%; padding-bottom:2px;&quot;&gt;&lt;/div&gt;
&lt;!--        INTERWIKI STRAPLINE        --&gt;
__NOTOC____NOEDITSECTION__
&lt;center&gt;'''[[:meta:Help:Editing|Irhelebho Ngomtlolo]]'''

Uyabawa ukuzifundisa ukutlola lapha ku[[Wikipedia:Sandbox|Sandbox]].

&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:85%;width: 100%; background-color:#ddcef2; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;
== iWikipedia ngeeilimi ezinye ==
; Ama-Wikipedia Amanye ngeeiLwimi zeAfrika 
[[:af:|Afrikaans]]&amp;nbsp;·
[[:ak:|Akan]]&amp;nbsp;·
[[:am:|አማርኛ]]&amp;nbsp;·
[[:bm:|Bamanankan]]&amp;nbsp;·
[[:ny:|Chi-Chewa]]&amp;nbsp;·
[[:sn:|chiShona]]&amp;nbsp;·
[[:tum:|chiTumbuka]]&amp;nbsp;·
[[:ee:|Ɛʋɛ]]&amp;nbsp;·
[[:ff:|Fulfude]]&amp;nbsp;·
[[:ki:|Gĩkũyũ]]&amp;nbsp;·
[[:ha:|هَوُسَ]]&amp;nbsp;·
[[:ig:|Ìgbo]]&amp;nbsp;·
[[:xh:|isiXhosa]]&amp;nbsp;·
[[:rw:|Kinyarwanda]]&amp;nbsp;·
[[:rn:|Kirundi]]&amp;nbsp;·
[[:sw:|Kiswahili]]&amp;nbsp;·
[[:kg:|Kongo]]&amp;nbsp;·
[[:ln:|Lingala]]&amp;nbsp;·
[[:lg:|Luganda]]&amp;nbsp;·
[[:mg:|Malagasy]]&amp;nbsp;·
[[:arz:|مصرى]]&amp;nbsp;·
[[:om:|Oromoo]]&amp;nbsp;·
[[:sg:|Sängö]]&amp;nbsp;·
[[:st:|seSotho]]&amp;nbsp;·
[[:tn:|Setswana]]&amp;nbsp;·
[[:ss:|SiSwati]]&amp;nbsp;·
[[:so:|Soomaaliga]]&amp;nbsp;·
[[:kab:|Taqbaylit]]&amp;nbsp;·
[[:ti:|ትግርኛ]]&amp;nbsp;·
[[:ve:|Tshivenda]]&amp;nbsp;·
[[:tw:|Twi]]&amp;nbsp;·
[[:wo:|Wolof]]&amp;nbsp;·
[[:ts:|Xitsonga]]&amp;nbsp;·
[[:yo:|Yorùbá]]&amp;nbsp;·
(Uma ufuna ukuqala Ama-Wikipedia amakhulu, qala ku-bar engasesineneni)
&lt;div class=&quot;plainlinks&quot;&gt;
; Amaphrojekthi afana
: [http://meta.wikipedia.org Meta-Wikipedia]&amp;nbsp;· [http://wiktionary.org Wiktionary]&amp;nbsp;· [http://wikibooks.org Wikibooks]&amp;nbsp;· [http://wikiquote.org Wikiquote]&amp;nbsp;· [http://wikisource.org Wikisource]
&lt;/div&gt;
---
&lt;/center&gt;
|}</text>
      <sha1>dik6ds5ctwapdgle7w8hy01f1dfqxih</sha1>
    </revision>
    <revision>
      <id>1024</id>
      <parentid>1023</parentid>
      <timestamp>2016-02-20T17:27:27Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1024</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5207" sha1="k8qwc6ppqdo8cj9nd8s6tw1p4tbqddu" xml:space="preserve">&lt;!--        BANNER ACROSS TOP OF PAGE        --&gt;
{| id=&quot;mp-topbanner&quot; style=&quot;width:100%; background:#f6f6f6; margin-top:1.2em; border:1px solid #BFB1A3;&quot;
| style=&quot;width:61%; color:#000;&quot; |
&lt;!--        &quot;WELCOME TO WIKIPEDIA&quot; AND ARTICLE COUNT        --&gt;
{| style=&quot;width:280px; border:none; background:none;&quot;
| style=&quot;width:280px; text-align:center; white-space:nowrap; color:#000;&quot; |
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakuthokozisa la nge[[Wikipedia|Wikiphidiya]] ye[[Isindebele|siNdebele]],&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;yiencyclopediya yasmahla etlolwa&amp;nbsp;ngabo bonke&amp;nbsp;abantu.&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenganje, kunemitlolo engu '''{{NUMBEROFARTICLES}}''' ngesiNdebele. Akwande!
&lt;inputbox&gt;
type=create
width=45
break=no
bgcolor=#f0f0f0
buttonlabel=tlola ikhasi 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;div style=&quot;font-size:90%;&quot;&gt;
&lt;/div&gt;
|}
&lt;!--        PORTAL LIST ON RIGHT-HAND SIDE        --&gt;
| style=&quot;width:13%; font-size:95%;&quot; |
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]

| style=&quot;width:13%; font-size:95%;&quot; |
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]

| style=&quot;width:13%; font-size:95%;&quot; |
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}
&lt;/td&gt;&lt;/tr&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:100%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Swaziland.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;small&gt;''Siraghela embili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:6px 0 0 0; background:none; border-spacing: 0px;&quot;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #BFB1A3; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-tfa-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:110%; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwee...&lt;/h2&gt;
|-
| style=&quot;color:#000;&quot; | &lt;div id=&quot;mp-dyk&quot; style=&quot;padding:2px 5px; font-size:90%;&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:110%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000;padding:2px 5px 5px&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        TOPICS        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #BFB1A3; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:110%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000;padding:2px 5px&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mp-other&quot; style=&quot;padding-top:4px; font-size:85%; padding-bottom:2px;&quot;&gt;&lt;/div&gt;
&lt;!--        INTERWIKI STRAPLINE        --&gt;
__NOTOC____NOEDITSECTION__
&lt;center&gt;'''[[:meta:Help:Editing|Irhelebho Ngomtlolo]]'''

Uyabawa ukuzifundisa ukutlola lapha ku[[Wikipedia:Sandbox|Sandbox]].

&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:85%;width: 100%; background-color:#ddcef2; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;
== iWikipedia ngeeilimi ezinye ==
; Ama-Wikipedia Amanye ngeeiLwimi zeAfrika 
[[:af:|Afrikaans]]&amp;nbsp;·
[[:ak:|Akan]]&amp;nbsp;·
[[:am:|አማርኛ]]&amp;nbsp;·
[[:bm:|Bamanankan]]&amp;nbsp;·
[[:ny:|Chi-Chewa]]&amp;nbsp;·
[[:sn:|chiShona]]&amp;nbsp;·
[[:tum:|chiTumbuka]]&amp;nbsp;·
[[:ee:|Ɛʋɛ]]&amp;nbsp;·
[[:ff:|Fulfude]]&amp;nbsp;·
[[:ki:|Gĩkũyũ]]&amp;nbsp;·
[[:ha:|هَوُسَ]]&amp;nbsp;·
[[:ig:|Ìgbo]]&amp;nbsp;·
[[:xh:|isiXhosa]]&amp;nbsp;·
[[:rw:|Kinyarwanda]]&amp;nbsp;·
[[:rn:|Kirundi]]&amp;nbsp;·
[[:sw:|Kiswahili]]&amp;nbsp;·
[[:kg:|Kongo]]&amp;nbsp;·
[[:ln:|Lingala]]&amp;nbsp;·
[[:lg:|Luganda]]&amp;nbsp;·
[[:mg:|Malagasy]]&amp;nbsp;·
[[:arz:|مصرى]]&amp;nbsp;·
[[:om:|Oromoo]]&amp;nbsp;·
[[:sg:|Sängö]]&amp;nbsp;·
[[:st:|seSotho]]&amp;nbsp;·
[[:tn:|Setswana]]&amp;nbsp;·
[[:ss:|SiSwati]]&amp;nbsp;·
[[:so:|Soomaaliga]]&amp;nbsp;·
[[:kab:|Taqbaylit]]&amp;nbsp;·
[[:ti:|ትግርኛ]]&amp;nbsp;·
[[:ve:|Tshivenda]]&amp;nbsp;·
[[:tw:|Twi]]&amp;nbsp;·
[[:wo:|Wolof]]&amp;nbsp;·
[[:ts:|Xitsonga]]&amp;nbsp;·
[[:yo:|Yorùbá]]&amp;nbsp;·
(Uma ufuna ukuqala Ama-Wikipedia amakhulu, qala ku-bar engasesineneni)
&lt;div class=&quot;plainlinks&quot;&gt;
; Amaphrojekthi afana
: [http://meta.wikipedia.org Meta-Wikipedia]&amp;nbsp;· [http://wiktionary.org Wiktionary]&amp;nbsp;· [http://wikibooks.org Wikibooks]&amp;nbsp;· [http://wikiquote.org Wikiquote]&amp;nbsp;· [http://wikisource.org Wikisource]
&lt;/div&gt;
---
&lt;/center&gt;
|}</text>
      <sha1>k8qwc6ppqdo8cj9nd8s6tw1p4tbqddu</sha1>
    </revision>
    <revision>
      <id>1025</id>
      <parentid>1024</parentid>
      <timestamp>2016-02-20T17:30:08Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Undo revision 3800987 by [[Khethekileko:Contributions/Thuvack|Thuvack]] ([[Umsebenzisi asiqongelane:Thuvack|talk]])</comment>
      <origin>1025</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5225" sha1="dik6ds5ctwapdgle7w8hy01f1dfqxih" xml:space="preserve">&lt;!--        BANNER ACROSS TOP OF PAGE        --&gt;
{| id=&quot;mp-topbanner&quot; style=&quot;width:100%; background:#f6f6f6; margin-top:1.2em; border:1px solid #BFB1A3;&quot;
| style=&quot;width:61%; color:#000;&quot; |
&lt;!--        &quot;WELCOME TO WIKIPEDIA&quot; AND ARTICLE COUNT        --&gt;
{| style=&quot;width:280px; border:none; background:none;&quot;
| style=&quot;width:280px; text-align:center; white-space:nowrap; color:#000;&quot; |
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakuthokozisa la nge[[Wikipedia|Wikiphidiya]] ye[[Isindebele|siNdebele]],&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;yiencyclopediya yasmahla etlolwa&amp;nbsp;ngabo bonke&amp;nbsp;abantu.&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenganje, kunemitlolo engu '''{{NUMBEROFARTICLES}}''' ngesiNdebele. Akwande!
&lt;inputbox&gt;
type=create
width=45
break=no
bgcolor=#f0f0f0
buttonlabel=tlola ikhasi 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;div style=&quot;font-size:90%;&quot;&gt;
&lt;/div&gt;
|}
&lt;!--        PORTAL LIST ON RIGHT-HAND SIDE        --&gt;
| style=&quot;width:13%; font-size:95%;&quot; |
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]

| style=&quot;width:13%; font-size:95%;&quot; |
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]

| style=&quot;width:13%; font-size:95%;&quot; |
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}
&lt;/td&gt;&lt;/tr&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:100%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Swaziland.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;small&gt;''Siraghela embili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:6px 0 0 0; background:none; border-spacing: 0px;&quot;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #BFB1A3; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-tfa-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:110%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwee...&lt;/h2&gt;
|-
| style=&quot;color:#000;&quot; | &lt;div id=&quot;mp-dyk&quot; style=&quot;padding:2px 5px; font-size:90%;&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:110%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000;padding:2px 5px 5px&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        TOPICS        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #BFB1A3; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:110%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000;padding:2px 5px&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mp-other&quot; style=&quot;padding-top:4px; font-size:85%; padding-bottom:2px;&quot;&gt;&lt;/div&gt;
&lt;!--        INTERWIKI STRAPLINE        --&gt;
__NOTOC____NOEDITSECTION__
&lt;center&gt;'''[[:meta:Help:Editing|Irhelebho Ngomtlolo]]'''

Uyabawa ukuzifundisa ukutlola lapha ku[[Wikipedia:Sandbox|Sandbox]].

&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:85%;width: 100%; background-color:#ddcef2; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;
== iWikipedia ngeeilimi ezinye ==
; Ama-Wikipedia Amanye ngeeiLwimi zeAfrika 
[[:af:|Afrikaans]]&amp;nbsp;·
[[:ak:|Akan]]&amp;nbsp;·
[[:am:|አማርኛ]]&amp;nbsp;·
[[:bm:|Bamanankan]]&amp;nbsp;·
[[:ny:|Chi-Chewa]]&amp;nbsp;·
[[:sn:|chiShona]]&amp;nbsp;·
[[:tum:|chiTumbuka]]&amp;nbsp;·
[[:ee:|Ɛʋɛ]]&amp;nbsp;·
[[:ff:|Fulfude]]&amp;nbsp;·
[[:ki:|Gĩkũyũ]]&amp;nbsp;·
[[:ha:|هَوُسَ]]&amp;nbsp;·
[[:ig:|Ìgbo]]&amp;nbsp;·
[[:xh:|isiXhosa]]&amp;nbsp;·
[[:rw:|Kinyarwanda]]&amp;nbsp;·
[[:rn:|Kirundi]]&amp;nbsp;·
[[:sw:|Kiswahili]]&amp;nbsp;·
[[:kg:|Kongo]]&amp;nbsp;·
[[:ln:|Lingala]]&amp;nbsp;·
[[:lg:|Luganda]]&amp;nbsp;·
[[:mg:|Malagasy]]&amp;nbsp;·
[[:arz:|مصرى]]&amp;nbsp;·
[[:om:|Oromoo]]&amp;nbsp;·
[[:sg:|Sängö]]&amp;nbsp;·
[[:st:|seSotho]]&amp;nbsp;·
[[:tn:|Setswana]]&amp;nbsp;·
[[:ss:|SiSwati]]&amp;nbsp;·
[[:so:|Soomaaliga]]&amp;nbsp;·
[[:kab:|Taqbaylit]]&amp;nbsp;·
[[:ti:|ትግርኛ]]&amp;nbsp;·
[[:ve:|Tshivenda]]&amp;nbsp;·
[[:tw:|Twi]]&amp;nbsp;·
[[:wo:|Wolof]]&amp;nbsp;·
[[:ts:|Xitsonga]]&amp;nbsp;·
[[:yo:|Yorùbá]]&amp;nbsp;·
(Uma ufuna ukuqala Ama-Wikipedia amakhulu, qala ku-bar engasesineneni)
&lt;div class=&quot;plainlinks&quot;&gt;
; Amaphrojekthi afana
: [http://meta.wikipedia.org Meta-Wikipedia]&amp;nbsp;· [http://wiktionary.org Wiktionary]&amp;nbsp;· [http://wikibooks.org Wikibooks]&amp;nbsp;· [http://wikiquote.org Wikiquote]&amp;nbsp;· [http://wikisource.org Wikisource]
&lt;/div&gt;
---
&lt;/center&gt;
|}</text>
      <sha1>dik6ds5ctwapdgle7w8hy01f1dfqxih</sha1>
    </revision>
    <revision>
      <id>1026</id>
      <parentid>1025</parentid>
      <timestamp>2016-02-20T17:38:11Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1026</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5210" sha1="dcl1talgr0caj5r7bvvrwdu0evqz0o2" xml:space="preserve">&lt;!--        BANNER ACROSS TOP OF PAGE        --&gt;
{| id=&quot;mp-topbanner&quot; style=&quot;width:100%; background:#f6f6f6; margin-top:1.2em; border:1px solid #BFB1A3;&quot;
| style=&quot;width:61%; color:#000;&quot; |
&lt;!--        &quot;WELCOME TO WIKIPEDIA&quot; AND ARTICLE COUNT        --&gt;
{| style=&quot;width:280px; border:none; background:none;&quot;
| style=&quot;width:280px; text-align:center; white-space:nowrap; color:#000;&quot; |
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakuthokozisa la nge[[Wikipedia|Wikiphidiya]] ye[[Isindebele|siNdebele]],&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;yiencyclopediya yasmahla etlolwa&amp;nbsp;ngabo bonke&amp;nbsp;abantu.&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenganje, kunemitlolo engu '''{{NUMBEROFARTICLES}}''' ngesiNdebele. Akwande!
&lt;inputbox&gt;
type=create
width=45
break=no
bgcolor=#f0f0f0
buttonlabel=tlola ikhasi 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;div style=&quot;font-size:90%;&quot;&gt;
&lt;/div&gt;
|}
&lt;!--        PORTAL LIST ON RIGHT-HAND SIDE        --&gt;
| style=&quot;width:13%; font-size:95%;&quot; |
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]

| style=&quot;width:13%; font-size:95%;&quot; |
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]

| style=&quot;width:13%; font-size:95%;&quot; |
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}
&lt;/td&gt;&lt;/tr&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:100%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Swaziland.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;small&gt;''Siraghela embili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:6px 0 0 0; background:none; border-spacing: 0px;&quot;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #BFB1A3; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-tfa-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:110%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwee...&lt;/h2&gt;
|-
| style=&quot;color:#000;&quot; | &lt;div id=&quot;mp-dyk&quot; style=&quot;padding:2px 5px;&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:110%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000;padding:2px 5px 5px&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        TOPICS        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #BFB1A3; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:110%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000;padding:2px 5px&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mp-other&quot; style=&quot;padding-top:4px; font-size:85%; padding-bottom:2px;&quot;&gt;&lt;/div&gt;
&lt;!--        INTERWIKI STRAPLINE        --&gt;
__NOTOC____NOEDITSECTION__
&lt;center&gt;'''[[:meta:Help:Editing|Irhelebho Ngomtlolo]]'''

Uyabawa ukuzifundisa ukutlola lapha ku[[Wikipedia:Sandbox|Sandbox]].

&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:85%;width: 100%; background-color:#ddcef2; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;
== iWikipedia ngeeilimi ezinye ==
; Ama-Wikipedia Amanye ngeeiLwimi zeAfrika 
[[:af:|Afrikaans]]&amp;nbsp;·
[[:ak:|Akan]]&amp;nbsp;·
[[:am:|አማርኛ]]&amp;nbsp;·
[[:bm:|Bamanankan]]&amp;nbsp;·
[[:ny:|Chi-Chewa]]&amp;nbsp;·
[[:sn:|chiShona]]&amp;nbsp;·
[[:tum:|chiTumbuka]]&amp;nbsp;·
[[:ee:|Ɛʋɛ]]&amp;nbsp;·
[[:ff:|Fulfude]]&amp;nbsp;·
[[:ki:|Gĩkũyũ]]&amp;nbsp;·
[[:ha:|هَوُسَ]]&amp;nbsp;·
[[:ig:|Ìgbo]]&amp;nbsp;·
[[:xh:|isiXhosa]]&amp;nbsp;·
[[:rw:|Kinyarwanda]]&amp;nbsp;·
[[:rn:|Kirundi]]&amp;nbsp;·
[[:sw:|Kiswahili]]&amp;nbsp;·
[[:kg:|Kongo]]&amp;nbsp;·
[[:ln:|Lingala]]&amp;nbsp;·
[[:lg:|Luganda]]&amp;nbsp;·
[[:mg:|Malagasy]]&amp;nbsp;·
[[:arz:|مصرى]]&amp;nbsp;·
[[:om:|Oromoo]]&amp;nbsp;·
[[:sg:|Sängö]]&amp;nbsp;·
[[:st:|seSotho]]&amp;nbsp;·
[[:tn:|Setswana]]&amp;nbsp;·
[[:ss:|SiSwati]]&amp;nbsp;·
[[:so:|Soomaaliga]]&amp;nbsp;·
[[:kab:|Taqbaylit]]&amp;nbsp;·
[[:ti:|ትግርኛ]]&amp;nbsp;·
[[:ve:|Tshivenda]]&amp;nbsp;·
[[:tw:|Twi]]&amp;nbsp;·
[[:wo:|Wolof]]&amp;nbsp;·
[[:ts:|Xitsonga]]&amp;nbsp;·
[[:yo:|Yorùbá]]&amp;nbsp;·
(Uma ufuna ukuqala Ama-Wikipedia amakhulu, qala ku-bar engasesineneni)
&lt;div class=&quot;plainlinks&quot;&gt;
; Amaphrojekthi afana
: [http://meta.wikipedia.org Meta-Wikipedia]&amp;nbsp;· [http://wiktionary.org Wiktionary]&amp;nbsp;· [http://wikibooks.org Wikibooks]&amp;nbsp;· [http://wikiquote.org Wikiquote]&amp;nbsp;· [http://wikisource.org Wikisource]
&lt;/div&gt;
---
&lt;/center&gt;
|}</text>
      <sha1>dcl1talgr0caj5r7bvvrwdu0evqz0o2</sha1>
    </revision>
    <revision>
      <id>1027</id>
      <parentid>1026</parentid>
      <timestamp>2016-02-21T06:28:11Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1027</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5211" sha1="65o54394ix39x0okfa26z2la4nadxo0" xml:space="preserve">&lt;!--        BANNER ACROSS TOP OF PAGE        --&gt;
{| id=&quot;mp-topbanner&quot; style=&quot;width:100%; background:#f6f6f6; margin-top:1.2em; border:1px solid #BFB1A3;&quot;
| style=&quot;width:61%; color:#000;&quot; |
&lt;!--        &quot;WELCOME TO WIKIPEDIA&quot; AND ARTICLE COUNT        --&gt;
{| style=&quot;width:280px; border:none; background:none;&quot;
| style=&quot;width:280px; text-align:center; white-space:nowrap; color:#000;&quot; |
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakuthokozisa la nge[[Wikipedia|Wikiphidiya]] ye[[Isindebele|siNdebele]],&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;yiencyclopediya yasmahla etlolwa&amp;nbsp;ngabo bonke&amp;nbsp;abantu.&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenganje, kunemitlolo engu '''{{NUMBEROFARTICLES}}''' ngesiNdebele. Akwande!
&lt;inputbox&gt;
type=create
width=45
break=no
bgcolor=#f0f0f0
buttonlabel=tlola ikhasi 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;div style=&quot;font-size:90%;&quot;&gt;
&lt;/div&gt;
|}
&lt;!--        PORTAL LIST ON RIGHT-HAND SIDE        --&gt;
| style=&quot;width:13%; font-size:95%;&quot; |
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]

| style=&quot;width:13%; font-size:95%;&quot; |
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]

| style=&quot;width:13%; font-size:95%;&quot; |
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}
&lt;/td&gt;&lt;/tr&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:100%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Swaziland.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:6px 0 0 0; background:none; border-spacing: 0px;&quot;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #BFB1A3; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-tfa-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:110%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwee...&lt;/h2&gt;
|-
| style=&quot;color:#000;&quot; | &lt;div id=&quot;mp-dyk&quot; style=&quot;padding:2px 5px;&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:110%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000;padding:2px 5px 5px&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        TOPICS        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #BFB1A3; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:110%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000;padding:2px 5px&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mp-other&quot; style=&quot;padding-top:4px; font-size:85%; padding-bottom:2px;&quot;&gt;&lt;/div&gt;
&lt;!--        INTERWIKI STRAPLINE        --&gt;
__NOTOC____NOEDITSECTION__
&lt;center&gt;'''[[:meta:Help:Editing|Irhelebho Ngomtlolo]]'''

Uyabawa ukuzifundisa ukutlola lapha ku[[Wikipedia:Sandbox|Sandbox]].

&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:85%;width: 100%; background-color:#ddcef2; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;
== iWikipedia ngeeilimi ezinye ==
; Ama-Wikipedia Amanye ngeeiLwimi zeAfrika 
[[:af:|Afrikaans]]&amp;nbsp;·
[[:ak:|Akan]]&amp;nbsp;·
[[:am:|አማርኛ]]&amp;nbsp;·
[[:bm:|Bamanankan]]&amp;nbsp;·
[[:ny:|Chi-Chewa]]&amp;nbsp;·
[[:sn:|chiShona]]&amp;nbsp;·
[[:tum:|chiTumbuka]]&amp;nbsp;·
[[:ee:|Ɛʋɛ]]&amp;nbsp;·
[[:ff:|Fulfude]]&amp;nbsp;·
[[:ki:|Gĩkũyũ]]&amp;nbsp;·
[[:ha:|هَوُسَ]]&amp;nbsp;·
[[:ig:|Ìgbo]]&amp;nbsp;·
[[:xh:|isiXhosa]]&amp;nbsp;·
[[:rw:|Kinyarwanda]]&amp;nbsp;·
[[:rn:|Kirundi]]&amp;nbsp;·
[[:sw:|Kiswahili]]&amp;nbsp;·
[[:kg:|Kongo]]&amp;nbsp;·
[[:ln:|Lingala]]&amp;nbsp;·
[[:lg:|Luganda]]&amp;nbsp;·
[[:mg:|Malagasy]]&amp;nbsp;·
[[:arz:|مصرى]]&amp;nbsp;·
[[:om:|Oromoo]]&amp;nbsp;·
[[:sg:|Sängö]]&amp;nbsp;·
[[:st:|seSotho]]&amp;nbsp;·
[[:tn:|Setswana]]&amp;nbsp;·
[[:ss:|SiSwati]]&amp;nbsp;·
[[:so:|Soomaaliga]]&amp;nbsp;·
[[:kab:|Taqbaylit]]&amp;nbsp;·
[[:ti:|ትግርኛ]]&amp;nbsp;·
[[:ve:|Tshivenda]]&amp;nbsp;·
[[:tw:|Twi]]&amp;nbsp;·
[[:wo:|Wolof]]&amp;nbsp;·
[[:ts:|Xitsonga]]&amp;nbsp;·
[[:yo:|Yorùbá]]&amp;nbsp;·
(Uma ufuna ukuqala Ama-Wikipedia amakhulu, qala ku-bar engasesineneni)
&lt;div class=&quot;plainlinks&quot;&gt;
; Amaphrojekthi afana
: [http://meta.wikipedia.org Meta-Wikipedia]&amp;nbsp;· [http://wiktionary.org Wiktionary]&amp;nbsp;· [http://wikibooks.org Wikibooks]&amp;nbsp;· [http://wikiquote.org Wikiquote]&amp;nbsp;· [http://wikisource.org Wikisource]
&lt;/div&gt;
---
&lt;/center&gt;
|}</text>
      <sha1>65o54394ix39x0okfa26z2la4nadxo0</sha1>
    </revision>
    <revision>
      <id>1028</id>
      <parentid>1027</parentid>
      <timestamp>2016-02-21T06:59:17Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1028</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3674" sha1="i7rky8pozsfufhkr7653odihbii8cy9" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;| &lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot;|
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakuthokozisa la nge[[Wikipedia|Wikiphidiya]] ye[[Isindebele|siNdebele]]&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;yiencyclopediya yasmahla etlolwa&amp;nbsp;ngabo bonke&amp;nbsp;abantu.&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenganje, kunemitlolo engu '''{{NUMBEROFARTICLES}}''' ngesiNdebele. Akwande!&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Swaziland.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}
&lt;/table&gt;
&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwee..&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Interwikis}}&lt;/div&gt;
|}
|}

&lt;/tr&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;

__NOTOC____NOEDITSECTION__

</text>
      <sha1>i7rky8pozsfufhkr7653odihbii8cy9</sha1>
    </revision>
    <revision>
      <id>1029</id>
      <parentid>1028</parentid>
      <timestamp>2016-02-21T07:01:21Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1029</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3877" sha1="4z57gqrnvln499qt7yxxajs0l5pab7a" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;| &lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot;|
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakuthokozisa la nge[[Wikipedia|Wikiphidiya]] ye[[Isindebele|siNdebele]]&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;yiencyclopediya yasmahla etlolwa&amp;nbsp;ngabo bonke&amp;nbsp;abantu.&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenganje, kunemitlolo engu '''{{NUMBEROFARTICLES}}''' ngesiNdebele. Akwande!&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Swaziland.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}
&lt;/table&gt;
&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwee..&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Interwikis}}&lt;/div&gt;
|}
|}

&lt;/tr&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;

__NOTOC____NOEDITSECTION__

</text>
      <sha1>4z57gqrnvln499qt7yxxajs0l5pab7a</sha1>
    </revision>
    <revision>
      <id>1030</id>
      <parentid>1029</parentid>
      <timestamp>2016-02-21T07:02:42Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1030</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3890" sha1="5ei9y6zazqyfuzzzaoq087qg4itujb2" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;| &lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot;|
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakuthokozisa la nge[[Wikipedia|Wikiphidiya]] ye[[Isindebele|siNdebele]]&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;yiencyclopediya yasmahla etlolwa&amp;nbsp;ngabo bonke&amp;nbsp;abantu.&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenganje, kunemitlolo engu '''{{NUMBEROFARTICLES}}''' ngesiNdebele. Akwande!&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Swaziland.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}
&lt;/table&gt;
&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwee..&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|-
! style=&quot;width:100%; &quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Interwikis}}&lt;/div&gt;
|}
|}

&lt;/tr&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;

__NOTOC____NOEDITSECTION__

</text>
      <sha1>5ei9y6zazqyfuzzzaoq087qg4itujb2</sha1>
    </revision>
    <revision>
      <id>1031</id>
      <parentid>1030</parentid>
      <timestamp>2016-02-21T07:08:22Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1031</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3819" sha1="iyb8xrno1qsy5zrhf2ent1gwjsyexvh" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;| &lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot;|
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakuthokozisa la nge[[Wikipedia|Wikiphidiya]] ye[[Isindebele|siNdebele]]&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;yiencyclopediya yasmahla etlolwa&amp;nbsp;ngabo bonke&amp;nbsp;abantu.&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenganje, kunemitlolo engu '''{{NUMBEROFARTICLES}}''' ngesiNdebele. Akwande!&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Swaziland.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}
&lt;/table&gt;
&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwee..&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
|}

&lt;/tr&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__

</text>
      <sha1>iyb8xrno1qsy5zrhf2ent1gwjsyexvh</sha1>
    </revision>
    <revision>
      <id>1032</id>
      <parentid>1031</parentid>
      <timestamp>2018-11-06T23:26:12Z</timestamp>
      <contributor>
        <username>incubator&gt;CommonsDelinker</username>
        <id>0</id>
      </contributor>
      <comment>Replacing [[Isimumathi:Flag_of_Swaziland.svg]] with [[Isimumathi:Flag_of_Eswatini.svg]] (deleted by [[commons:User:CommonsDelinker|CommonsDelinker]] because of: [[:c:COM:FR|File renamed]]: [[:c:COM:FR#FR3|Criterion 3]] (obvious error) · The name in en.wiki has been</comment>
      <origin>1032</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3818" sha1="2l226akf84thzkf86d8pso3zn0tdnbv" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;| &lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot;|
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakuthokozisa la nge[[Wikipedia|Wikiphidiya]] ye[[Isindebele|siNdebele]]&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;yiencyclopediya yasmahla etlolwa&amp;nbsp;ngabo bonke&amp;nbsp;abantu.&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenganje, kunemitlolo engu '''{{NUMBEROFARTICLES}}''' ngesiNdebele. Akwande!&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}
&lt;/table&gt;
&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwee..&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
|}

&lt;/tr&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__

</text>
      <sha1>2l226akf84thzkf86d8pso3zn0tdnbv</sha1>
    </revision>
    <revision>
      <id>1033</id>
      <parentid>1032</parentid>
      <timestamp>2019-01-11T12:49:55Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Updated banner</comment>
      <origin>1033</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3777" sha1="lbj4opi1opcqe6uash5rfuzmyrxsdaw" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;| &lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot;|
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakuthokozisa la nge[[Wikipedia|Wikiphidiya]],&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;yi encyclopediya ya s'mahla etlolwa&amp;nbsp;ngabo bonke&amp;nbsp;abantu.&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;'''{{NUMBEROFARTICLES}}''' yemitlolo ngesiNdebele. Akwande!&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}
&lt;/table&gt;
&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwee..&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
|}

&lt;/tr&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__

</text>
      <sha1>lbj4opi1opcqe6uash5rfuzmyrxsdaw</sha1>
    </revision>
    <revision>
      <id>1034</id>
      <parentid>1033</parentid>
      <timestamp>2019-01-11T12:51:24Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1034</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3792" sha1="2km8m8n5g490jmlo11ois6o5mzl6hyb" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;| &lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot;|
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakuthokozisa la nge[[Wikipedia|Wikiphidiya]],&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;yi encyclopediya ya s'mahla etlolwa&amp;nbsp;ngabo bonke&amp;nbsp;abantu.&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;'''{{NUMBEROFARTICLES}}''' yemitlolo [[Isindebele|ngesiNdebele]]. Akwande!&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}
&lt;/table&gt;
&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwee..&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
|}

&lt;/tr&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__

</text>
      <sha1>2km8m8n5g490jmlo11ois6o5mzl6hyb</sha1>
    </revision>
    <revision>
      <id>1035</id>
      <parentid>1034</parentid>
      <timestamp>2019-01-11T12:54:01Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1035</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3822" sha1="oycxmbdoncwj01byt9ev6t1ddthxx6n" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;| &lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot;|
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakuthokozisa la nge[[Wikipedia|Wikiphidiya]],&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;yi [[encyclopediya]] ya s'mahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngabo boke&amp;nbsp;abantu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;'''{{NUMBEROFARTICLES}}''' yemitlolo [[Isindebele|ngesiNdebele]]. Akwande!&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}
&lt;/table&gt;
&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwee..&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
|}

&lt;/tr&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__

</text>
      <sha1>oycxmbdoncwj01byt9ev6t1ddthxx6n</sha1>
    </revision>
    <revision>
      <id>1036</id>
      <parentid>1035</parentid>
      <timestamp>2019-01-11T16:02:38Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1036</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3826" sha1="5tww4rabj7q6jvy86onywmy5sn5c52c" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;| &lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot;|
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakuthokozisa la nge[[Wikipedia|Wikiphidiya]],&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;yi [[encyclopediya]] ya s'mahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngabo boke&amp;nbsp;abantu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;'''{{NUMBEROFARTICLES}}''' yemitlolo [[Isindebele|ngesiNdebele]]. Akwande!&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}
&lt;/table&gt;
&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwee..&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
|}

&lt;/tr&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__

</text>
      <sha1>5tww4rabj7q6jvy86onywmy5sn5c52c</sha1>
    </revision>
    <revision>
      <id>1037</id>
      <parentid>1036</parentid>
      <timestamp>2024-03-11T03:54:54Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Adding interwiki links to [[d:Q5296]]</comment>
      <origin>1037</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3846" sha1="8gcaqwn018aj7ywlrv3aho4q3ai5vz6" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;| &lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot;|
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakuthokozisa la nge[[Wikipedia|Wikiphidiya]],&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;yi [[encyclopediya]] ya s'mahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngabo boke&amp;nbsp;abantu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;'''{{NUMBEROFARTICLES}}''' yemitlolo [[Isindebele|ngesiNdebele]]. Akwande!&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}
&lt;/table&gt;
&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwee..&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
|}

&lt;/tr&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__


{{INTERWIKI|Q5296}}</text>
      <sha1>8gcaqwn018aj7ywlrv3aho4q3ai5vz6</sha1>
    </revision>
    <revision>
      <id>1038</id>
      <parentid>1037</parentid>
      <timestamp>2024-05-03T07:44:38Z</timestamp>
      <contributor>
        <username>incubator&gt;Nomsa Skosana</username>
        <id>0</id>
      </contributor>
      <comment>Language changes</comment>
      <origin>1038</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3902" sha1="kbkw5du1z7qhp5g9ulebg0epoqugf00" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;|&lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot;|
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakwamukela ku[[Wikipedia|Wikiphidiya]] yelimi lesiNdebele&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;Iwikiphidiya yi-[[Encyclopedia|encyclopediya]] yasimahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngiwo woke&amp;nbsp;umuntu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenga nje kunemitlolo ema- '''{{NUMBEROFARTICLES}}''' y[[Isindebele|esiNdebele]]. 
Asithome!
&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}
&lt;/table&gt;
&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwee..&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
|}

&lt;/tr&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__


{{INTERWIKI|Q5296}}</text>
      <sha1>kbkw5du1z7qhp5g9ulebg0epoqugf00</sha1>
    </revision>
    <revision>
      <id>1039</id>
      <parentid>1038</parentid>
      <timestamp>2024-05-03T07:47:06Z</timestamp>
      <contributor>
        <username>incubator&gt;Nomsa Skosana</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1039</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3903" sha1="qlgwhkt49cf1s6zz5vs47bjc5lzhbdq" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;|&lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot;|
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakwamukela ku[[Wikipedia|Wikiphidiya]] yelimi lesiNdebele&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;Iwikiphidiya yi-[[Encyclopedia|encyclopediya]] yasimahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngiwo woke&amp;nbsp;umuntu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenga nje kunemitlolo ema- '''{{NUMBEROFARTICLES}}''' y[[Isindebele|esiNdebele]]. 
Asithome!
&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Iinaga|Iinarha Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}
&lt;/table&gt;
&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwee..&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
|}

&lt;/tr&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__


{{INTERWIKI|Q5296}}</text>
      <sha1>qlgwhkt49cf1s6zz5vs47bjc5lzhbdq</sha1>
    </revision>
    <revision>
      <id>1040</id>
      <parentid>1039</parentid>
      <timestamp>2024-05-03T07:53:52Z</timestamp>
      <contributor>
        <username>incubator&gt;Nomsa Skosana</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1040</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3857" sha1="ear5ncd3ruhrl5a48weun30cff6indv" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;|&lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot;|
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakwamukela ku[[Wikipedia|Wikiphidiya]] yelimi lesiNdebele&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;Iwikiphidiya yi-[[Encyclopedia|encyclopediya]] yasimahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngiwo woke&amp;nbsp;umuntu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenga-nje kunemitlolo ema- '''{{NUMBEROFARTICLES}}''' y[[Isindebele|esiNdebele]]. 
Asithome!
&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Iinaga|Iinarha Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukghoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}

&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhuliweko.&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Bewazi na?&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
|}

&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__


{{INTERWIKI|Q5296}}</text>
      <sha1>ear5ncd3ruhrl5a48weun30cff6indv</sha1>
    </revision>
    <revision>
      <id>1041</id>
      <parentid>1040</parentid>
      <timestamp>2024-05-03T07:57:38Z</timestamp>
      <contributor>
        <username>incubator&gt;Nomsa Skosana</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1041</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3851" sha1="ne5nnsb305yn3khu7c9qa1a8dfphj10" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;|&lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot;|
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakwamukela ku[[Wikipedia|Wikiphidiya]] yelimi lesiNdebele&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;Iwikiphidiya yi-[[Encyclopedia|encyclopediya]] yasimahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngiwo woke&amp;nbsp;umuntu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenga-nje kunemitlolo ema- '''{{NUMBEROFARTICLES}}''' y[[Isindebele|esiNdebele]]. 
Asithome!
&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Iinaga|Iinarha Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukghoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ukudla]]
* [[Portal:Amasonto|Amasondo]]
* [[Portal:Ubuvumi|Umvumo]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}

&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhuliweko.&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Bewazi na?&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
|}

&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__


{{INTERWIKI|Q5296}}</text>
      <sha1>ne5nnsb305yn3khu7c9qa1a8dfphj10</sha1>
    </revision>
    <revision>
      <id>1042</id>
      <parentid>1041</parentid>
      <timestamp>2024-05-09T10:51:25Z</timestamp>
      <contributor>
        <username>incubator&gt;Sphenge</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1042</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3812" sha1="18lsptdujs5wg9crsci44hnrf0eihky" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;|&lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot;|
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakwamukela ku[[Wikipedia|Wikiphidiya]] yelimi lesiNdebele&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;Iwikiphidiya yi-insayitlophidiya yasimahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngiwo woke&amp;nbsp;umuntu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenganje, kunemitlolo ema-83 y[[Isindebele|esiNdebele]]. 
Asithome!
&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Iinaga|Iinarha Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukghoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ukudla]]
* [[Portal:Amasonto|Amasondo]]
* [[Portal:Ubuvumi|Umvumo]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}

&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhuliweko.&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Bewazi na?&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
|}

&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__


{{INTERWIKI|Q5296}}</text>
      <sha1>18lsptdujs5wg9crsci44hnrf0eihky</sha1>
    </revision>
    <revision>
      <id>1043</id>
      <parentid>1042</parentid>
      <timestamp>2024-05-09T10:53:15Z</timestamp>
      <contributor>
        <username>incubator&gt;Sphenge</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1043</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3812" sha1="gztxhf7gysqtvsg3gy3o0t980y7hpgc" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;|&lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot;|
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakwamukela ku[[Wikipedia|Wikiphidiya]] yelimi lesiNdebele&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;Iwikiphidiya yi-insayitlophidiya yasimahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngiwo woke&amp;nbsp;umuntu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenganje, kunemitlolo ema-83 y[[Isindebele|esiNdebele]]. 
Asithome!
&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Iinaga|Iinarha Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukghoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ukudla]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Umvumo]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}

&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhuliweko.&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Bewazi na?&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
|}

&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__


{{INTERWIKI|Q5296}}</text>
      <sha1>gztxhf7gysqtvsg3gy3o0t980y7hpgc</sha1>
    </revision>
    <revision>
      <id>1044</id>
      <parentid>1043</parentid>
      <timestamp>2024-05-09T18:01:50Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Reverted edits by [[Khethekileko:Contributions/Sphenge|Sphenge]] ([[Umsebenzisi asiqongelane:Sphenge|talk]]) to last revision by [[Umsebenzisi:Samukelisiwe Grace|Samukelisiwe Grace]]</comment>
      <origin>1044</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3851" sha1="ne5nnsb305yn3khu7c9qa1a8dfphj10" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;|&lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot;|
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakwamukela ku[[Wikipedia|Wikiphidiya]] yelimi lesiNdebele&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;Iwikiphidiya yi-[[Encyclopedia|encyclopediya]] yasimahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngiwo woke&amp;nbsp;umuntu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenga-nje kunemitlolo ema- '''{{NUMBEROFARTICLES}}''' y[[Isindebele|esiNdebele]]. 
Asithome!
&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Iinaga|Iinarha Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukghoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ukudla]]
* [[Portal:Amasonto|Amasondo]]
* [[Portal:Ubuvumi|Umvumo]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}

&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhuliweko.&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Bewazi na?&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
|}

&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__


{{INTERWIKI|Q5296}}</text>
      <sha1>ne5nnsb305yn3khu7c9qa1a8dfphj10</sha1>
    </revision>
    <revision>
      <id>1045</id>
      <parentid>1044</parentid>
      <timestamp>2024-05-09T18:07:04Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Khethekileko:Contributions/Bobbyshabangu|Bobbyshabangu]] ([[Umsebenzisi asiqongelane:Bobbyshabangu|talk]]) to last revision by [[Umsebenzisi:Sphenge|Sphenge]]</comment>
      <origin>1045</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3812" sha1="gztxhf7gysqtvsg3gy3o0t980y7hpgc" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;|&lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot;|
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakwamukela ku[[Wikipedia|Wikiphidiya]] yelimi lesiNdebele&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;Iwikiphidiya yi-insayitlophidiya yasimahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngiwo woke&amp;nbsp;umuntu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenganje, kunemitlolo ema-83 y[[Isindebele|esiNdebele]]. 
Asithome!
&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Iinaga|Iinarha Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukghoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ukudla]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Umvumo]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}

&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhuliweko.&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Bewazi na?&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
|}

&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__


{{INTERWIKI|Q5296}}</text>
      <sha1>gztxhf7gysqtvsg3gy3o0t980y7hpgc</sha1>
    </revision>
    <revision>
      <id>1046</id>
      <parentid>1045</parentid>
      <timestamp>2024-05-09T18:08:37Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Undo revision [[Khethekileko:Diff/6283684|6283684]] by [[Khethekileko:Contributions/Bobbyshabangu|Bobbyshabangu]] ([[Umsebenzisi asiqongelane:Bobbyshabangu|talk]])</comment>
      <origin>1046</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3851" sha1="ne5nnsb305yn3khu7c9qa1a8dfphj10" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;|&lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot;|
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakwamukela ku[[Wikipedia|Wikiphidiya]] yelimi lesiNdebele&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;Iwikiphidiya yi-[[Encyclopedia|encyclopediya]] yasimahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngiwo woke&amp;nbsp;umuntu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenga-nje kunemitlolo ema- '''{{NUMBEROFARTICLES}}''' y[[Isindebele|esiNdebele]]. 
Asithome!
&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Iinaga|Iinarha Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukghoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ukudla]]
* [[Portal:Amasonto|Amasondo]]
* [[Portal:Ubuvumi|Umvumo]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}

&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhuliweko.&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Bewazi na?&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
|}

&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__


{{INTERWIKI|Q5296}}</text>
      <sha1>ne5nnsb305yn3khu7c9qa1a8dfphj10</sha1>
    </revision>
    <revision>
      <id>1047</id>
      <parentid>1046</parentid>
      <timestamp>2024-05-11T06:26:54Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Published an updated version of the landing page.</comment>
      <origin>1047</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3846" sha1="pshj5y5izhjkoz5k0mi2b1ae36hpq80" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;|&lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot;|
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakwamukela ku[[Wikipedia|Wikiphidiya]] yelimi lesiNdebele&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;Iwikiphidiya yi-[[Encyclopedia|encyclopediya]] yasimahla [[Wikipedia:Introduction|etlolwa ngiwo woke&amp;nbsp;umuntu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenga-nje kunemitlolo ema- '''{{NUMBEROFARTICLES}}''' y[[Isindebele|esiNdebele]]. 
Asithome!
&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Iinaga|Iinarha Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukghoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ukudla]]
* [[Portal:Amasonto|Amasondo]]
* [[Portal:Ubuvumi|Umvumo]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}

&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhuliweko.&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Bewazi na?&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
|}

&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__


{{INTERWIKI|Q5296}}</text>
      <sha1>pshj5y5izhjkoz5k0mi2b1ae36hpq80</sha1>
    </revision>
    <revision>
      <id>1048</id>
      <parentid>1047</parentid>
      <timestamp>2024-05-22T19:13:11Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Reverted edits by [[Khethekileko:Contributions/Bobbyshabangu|Bobbyshabangu]] ([[Umsebenzisi asiqongelane:Bobbyshabangu|talk]]) to last revision by [[Umsebenzisi:Sphenge|Sphenge]]</comment>
      <origin>1048</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3812" sha1="gztxhf7gysqtvsg3gy3o0t980y7hpgc" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;|&lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot;|
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakwamukela ku[[Wikipedia|Wikiphidiya]] yelimi lesiNdebele&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;Iwikiphidiya yi-insayitlophidiya yasimahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngiwo woke&amp;nbsp;umuntu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenganje, kunemitlolo ema-83 y[[Isindebele|esiNdebele]]. 
Asithome!
&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Iinaga|Iinarha Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukghoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ukudla]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Umvumo]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}

&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhuliweko.&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Bewazi na?&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
|}

&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__


{{INTERWIKI|Q5296}}</text>
      <sha1>gztxhf7gysqtvsg3gy3o0t980y7hpgc</sha1>
    </revision>
    <revision>
      <id>1049</id>
      <parentid>1048</parentid>
      <timestamp>2024-05-22T19:17:40Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1049</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3851" sha1="ne5nnsb305yn3khu7c9qa1a8dfphj10" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;|&lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot;|
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakwamukela ku[[Wikipedia|Wikiphidiya]] yelimi lesiNdebele&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;Iwikiphidiya yi-[[Encyclopedia|encyclopediya]] yasimahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngiwo woke&amp;nbsp;umuntu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenga-nje kunemitlolo ema- '''{{NUMBEROFARTICLES}}''' y[[Isindebele|esiNdebele]]. 
Asithome!
&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Iinaga|Iinarha Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukghoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ukudla]]
* [[Portal:Amasonto|Amasondo]]
* [[Portal:Ubuvumi|Umvumo]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}

&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhuliweko.&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Bewazi na?&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
|}

&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__


{{INTERWIKI|Q5296}}</text>
      <sha1>ne5nnsb305yn3khu7c9qa1a8dfphj10</sha1>
    </revision>
    <revision>
      <id>1050</id>
      <parentid>1049</parentid>
      <timestamp>2024-05-22T19:21:53Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1050</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3902" sha1="kbkw5du1z7qhp5g9ulebg0epoqugf00" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;|&lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot;|
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakwamukela ku[[Wikipedia|Wikiphidiya]] yelimi lesiNdebele&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;Iwikiphidiya yi-[[Encyclopedia|encyclopediya]] yasimahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngiwo woke&amp;nbsp;umuntu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenga nje kunemitlolo ema- '''{{NUMBEROFARTICLES}}''' y[[Isindebele|esiNdebele]]. 
Asithome!
&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}
&lt;/table&gt;
&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwee..&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
|}

&lt;/tr&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__


{{INTERWIKI|Q5296}}</text>
      <sha1>kbkw5du1z7qhp5g9ulebg0epoqugf00</sha1>
    </revision>
    <revision>
      <id>1051</id>
      <parentid>1050</parentid>
      <timestamp>2024-05-22T19:33:24Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1050</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3902" sha1="kbkw5du1z7qhp5g9ulebg0epoqugf00" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;|&lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot;|
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakwamukela ku[[Wikipedia|Wikiphidiya]] yelimi lesiNdebele&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;Iwikiphidiya yi-[[Encyclopedia|encyclopediya]] yasimahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngiwo woke&amp;nbsp;umuntu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenga nje kunemitlolo ema- '''{{NUMBEROFARTICLES}}''' y[[Isindebele|esiNdebele]]. 
Asithome!
&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}
&lt;/table&gt;
&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwee..&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
|}

&lt;/tr&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__


{{INTERWIKI|Q5296}}</text>
      <sha1>kbkw5du1z7qhp5g9ulebg0epoqugf00</sha1>
    </revision>
    <revision>
      <id>1052</id>
      <parentid>1051</parentid>
      <timestamp>2024-05-22T19:41:04Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1052</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3903" sha1="qlgwhkt49cf1s6zz5vs47bjc5lzhbdq" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;|&lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot;|
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakwamukela ku[[Wikipedia|Wikiphidiya]] yelimi lesiNdebele&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;Iwikiphidiya yi-[[Encyclopedia|encyclopediya]] yasimahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngiwo woke&amp;nbsp;umuntu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenga nje kunemitlolo ema- '''{{NUMBEROFARTICLES}}''' y[[Isindebele|esiNdebele]]. 
Asithome!
&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Iinaga|Iinarha Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}
&lt;/table&gt;
&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwee..&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
|}

&lt;/tr&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__


{{INTERWIKI|Q5296}}</text>
      <sha1>qlgwhkt49cf1s6zz5vs47bjc5lzhbdq</sha1>
    </revision>
    <revision>
      <id>1053</id>
      <parentid>1052</parentid>
      <timestamp>2024-05-22T19:42:50Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1053</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3902" sha1="kbkw5du1z7qhp5g9ulebg0epoqugf00" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;|&lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot;|
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakwamukela ku[[Wikipedia|Wikiphidiya]] yelimi lesiNdebele&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;Iwikiphidiya yi-[[Encyclopedia|encyclopediya]] yasimahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngiwo woke&amp;nbsp;umuntu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenga nje kunemitlolo ema- '''{{NUMBEROFARTICLES}}''' y[[Isindebele|esiNdebele]]. 
Asithome!
&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}
&lt;/table&gt;
&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwee..&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
|}

&lt;/tr&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__


{{INTERWIKI|Q5296}}</text>
      <sha1>kbkw5du1z7qhp5g9ulebg0epoqugf00</sha1>
    </revision>
    <revision>
      <id>1054</id>
      <parentid>1053</parentid>
      <timestamp>2024-07-21T15:30:22Z</timestamp>
      <contributor>
        <ip>200.24.154.83</ip>
      </contributor>
      <origin>1053</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3902" sha1="kbkw5du1z7qhp5g9ulebg0epoqugf00" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;|&lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot;|
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakwamukela ku[[Wikipedia|Wikiphidiya]] yelimi lesiNdebele&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;Iwikiphidiya yi-[[Encyclopedia|encyclopediya]] yasimahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngiwo woke&amp;nbsp;umuntu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenga nje kunemitlolo ema- '''{{NUMBEROFARTICLES}}''' y[[Isindebele|esiNdebele]]. 
Asithome!
&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}
&lt;/table&gt;
&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwee..&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
|}

&lt;/tr&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__


{{INTERWIKI|Q5296}}</text>
      <sha1>kbkw5du1z7qhp5g9ulebg0epoqugf00</sha1>
    </revision>
    <revision>
      <id>1055</id>
      <parentid>1054</parentid>
      <timestamp>2024-07-22T09:09:28Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <origin>1055</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3851" sha1="95cu1nazlgk3m8k4b1hfp9kr01hoteu" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;|&lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot;|
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakwamukela ku-Wikipedia yelimi lesiNdebele&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;Iwikiphidiya yi-[[Encyclopedia|insayitlophidiya]] yasimahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngiwo woke&amp;nbsp;umuntu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenga nje kunemitlolo ema- '''{{NUMBEROFARTICLES}}''' y[[Isindebele|esiNdebele]]. 
Asithome!
&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Iinaga|Iinarha Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukghoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}

&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwe..&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Uthi bewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
|}

&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__


{{INTERWIKI|Q5296}}</text>
      <sha1>95cu1nazlgk3m8k4b1hfp9kr01hoteu</sha1>
    </revision>
    <revision>
      <id>1056</id>
      <parentid>1055</parentid>
      <timestamp>2024-07-22T09:29:02Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1056</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3902" sha1="kbkw5du1z7qhp5g9ulebg0epoqugf00" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;|&lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot;|
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakwamukela ku[[Wikipedia|Wikiphidiya]] yelimi lesiNdebele&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;Iwikiphidiya yi-[[Encyclopedia|encyclopediya]] yasimahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngiwo woke&amp;nbsp;umuntu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenga nje kunemitlolo ema- '''{{NUMBEROFARTICLES}}''' y[[Isindebele|esiNdebele]]. 
Asithome!
&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}
&lt;/table&gt;
&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwee..&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{/Topics}}&lt;/div&gt;
|}
|}

&lt;/tr&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__


{{INTERWIKI|Q5296}}</text>
      <sha1>kbkw5du1z7qhp5g9ulebg0epoqugf00</sha1>
    </revision>
    <revision>
      <id>1057</id>
      <parentid>1056</parentid>
      <timestamp>2024-08-08T11:58:13Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>fix template transclusion</comment>
      <origin>1057</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3942" sha1="9kwqwautnu7l1wqgghbrw25buetiish" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;|&lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot;|
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakwamukela ku[[Wikipedia|Wikiphidiya]] yelimi lesiNdebele&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;Iwikiphidiya yi-[[Encyclopedia|encyclopediya]] yasimahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngiwo woke&amp;nbsp;umuntu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenga nje kunemitlolo ema- '''{{NUMBEROFARTICLES}}''' y[[Isindebele|esiNdebele]]. 
Asithome!
&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}
&lt;/table&gt;
&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwee..&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{:Main Page/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{:Main Page/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{:Main Page/Topics}}&lt;/div&gt;
|}
|}

&lt;/tr&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{:Main Page/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__


{{INTERWIKI|Q5296}}</text>
      <sha1>9kwqwautnu7l1wqgghbrw25buetiish</sha1>
    </revision>
    <revision>
      <id>1058</id>
      <parentid>1057</parentid>
      <timestamp>2024-08-08T11:58:52Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>Protected &quot;[[Main Page]]&quot;: on request by [[Umsebenzisi:Bobbyshabangu]] ([Edit=Allow only autoconfirmed users] (indefinite) [Move=Allow only autoconfirmed users] (indefinite))</comment>
      <origin>1057</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3942" sha1="9kwqwautnu7l1wqgghbrw25buetiish" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;|&lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot;|
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakwamukela ku[[Wikipedia|Wikiphidiya]] yelimi lesiNdebele&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;Iwikiphidiya yi-[[Encyclopedia|encyclopediya]] yasimahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngiwo woke&amp;nbsp;umuntu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenga nje kunemitlolo ema- '''{{NUMBEROFARTICLES}}''' y[[Isindebele|esiNdebele]]. 
Asithome!
&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}
&lt;/table&gt;
&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwee..&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{:Main Page/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{:Main Page/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{:Main Page/Topics}}&lt;/div&gt;
|}
|}

&lt;/tr&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{:Main Page/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__


{{INTERWIKI|Q5296}}</text>
      <sha1>9kwqwautnu7l1wqgghbrw25buetiish</sha1>
    </revision>
    <revision>
      <id>1059</id>
      <parentid>1058</parentid>
      <timestamp>2024-09-14T10:07:50Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <origin>1059</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3913" sha1="d3dz2671rmljkv3mzi0j6us9757ihob" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;|&lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot;|
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakwamukela ku[[Wikipedia|Wikiphidiya]] yelimi lesiNdebele&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;Iwikiphidiya yi-[[Encyclopedia|encyclopediya]] yasimahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngiwo woke&amp;nbsp;umuntu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenga nje kunemitlolo ema- '''{{NUMBEROFARTICLES}}''' y[[Isindebele|esiNdebele]]. 
Asithome!
&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}

&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwe..&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{:Main Page/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{:Main Page/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{:Main Page/Topics}}&lt;/div&gt;
|}
|}

&lt;/tr&gt;
&lt;/table&gt;

&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{:Main Page/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__


{{INTERWIKI|Q5296}}</text>
      <sha1>d3dz2671rmljkv3mzi0j6us9757ihob</sha1>
    </revision>
    <revision>
      <id>1060</id>
      <parentid>1</parentid>
      <timestamp>2024-10-14T13:47:00Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>47 revisions imported</comment>
      <origin>1</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1416" sha1="q395t1hcdoo8uo1ysxlwgjv93i026xy" xml:space="preserve">&lt;div dir=&quot;ltr&quot; lang=&quot;en&quot; class=&quot;mw-content-ltr&quot;&gt;
==This subdomain is reserved for the creation of a [[wikimedia:Our projects|Wikipedia]] in '''[[w:en:isiNdebele seSewula|isiNdebele seSewula]]''' language==

* Please '''do not start editing''' this new site. This site has a test project on the [[incubator:|Wikimedia Incubator]] (or on the [[betawikiversity:|Beta Wikiversity]] or on the [[oldwikisource:|Old Wikisource]]) and it will be imported to here.
* If you would like to help translating the interface to this language, please do not translate here, but go to [[translatewiki:|translatewiki.net]], a special wiki for translating the interface. That way everyone can use it on every wiki using the [[mw:|same software]].
* For information about how to edit and for other general help, see [[m:Help:Contents|Help on Wikimedia's Meta-Wiki]] or [[mw:Help:Contents|Help on MediaWiki.org]].

== Sister projects ==
&lt;span class=&quot;plainlinks&quot;&gt;
[//www.wikipedia.org Wikipedia] |
[//www.wiktionary.org Wiktionary] |
[//www.wikibooks.org Wikibooks] |
[//www.wikinews.org Wikinews] |
[//www.wikiquote.org Wikiquote] |
[//www.wikisource.org Wikisource] |
[//www.wikiversity.org Wikiversity] |
[//www.wikivoyage.org Wikivoyage] |
[//species.wikimedia.org Wikispecies] |
[//www.wikidata.org Wikidata] |
[//commons.wikimedia.org Commons]
&lt;/span&gt;

See Wikimedia's [[m:|Meta-Wiki]] for the coordination of these projects.
&lt;/div&gt;</text>
      <sha1>q395t1hcdoo8uo1ysxlwgjv93i026xy</sha1>
    </revision>
    <revision>
      <id>1657</id>
      <parentid>1060</parentid>
      <timestamp>2024-10-14T13:52:17Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <comment>proper main page</comment>
      <origin>1657</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3913" sha1="d3dz2671rmljkv3mzi0j6us9757ihob" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;|&lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot;|
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakwamukela ku[[Wikipedia|Wikiphidiya]] yelimi lesiNdebele&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;Iwikiphidiya yi-[[Encyclopedia|encyclopediya]] yasimahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngiwo woke&amp;nbsp;umuntu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenga nje kunemitlolo ema- '''{{NUMBEROFARTICLES}}''' y[[Isindebele|esiNdebele]]. 
Asithome!
&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}

&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwe..&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{:Main Page/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{:Main Page/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{:Main Page/Topics}}&lt;/div&gt;
|}
|}

&lt;/tr&gt;
&lt;/table&gt;

&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{:Main Page/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__


{{INTERWIKI|Q5296}}</text>
      <sha1>d3dz2671rmljkv3mzi0j6us9757ihob</sha1>
    </revision>
    <revision>
      <id>1663</id>
      <parentid>1657</parentid>
      <timestamp>2024-10-16T09:49:38Z</timestamp>
      <contributor>
        <username>JhsBot</username>
        <id>34</id>
      </contributor>
      <minor />
      <comment>bot: Removing interwiki template; the page is now connected to [[d:Q5296]]</comment>
      <origin>1663</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3891" sha1="j5c2r71a4cb3bbke3m8ppz2e7kv2m0w" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;|&lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot;|
&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakwamukela ku[[Wikipedia|Wikiphidiya]] yelimi lesiNdebele&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;Iwikiphidiya yi-[[Encyclopedia|encyclopediya]] yasimahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngiwo woke&amp;nbsp;umuntu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenga nje kunemitlolo ema- '''{{NUMBEROFARTICLES}}''' y[[Isindebele|esiNdebele]]. 
Asithome!
&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}

&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwe..&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{:Main Page/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{:Main Page/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{:Main Page/Topics}}&lt;/div&gt;
|}
|}

&lt;/tr&gt;
&lt;/table&gt;

&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{:Main Page/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__</text>
      <sha1>j5c2r71a4cb3bbke3m8ppz2e7kv2m0w</sha1>
    </revision>
    <revision>
      <id>1763</id>
      <parentid>1663</parentid>
      <timestamp>2024-10-28T11:26:08Z</timestamp>
      <contributor>
        <ip>116.204.171.79</ip>
      </contributor>
      <comment>e</comment>
      <origin>1763</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3901" sha1="luynm939przfwxzcpe90ays83i7pmxg" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;|&lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|
|
|-
|
| style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot; |&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakwamukela ku[[Wikipedia|Wikiphidiya]] yelimi lesiNdebele&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;Iwikiphidiya yi-[[Encyclopedia|encyclopediya]] yasimahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngiwo woke&amp;nbsp;umuntu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenga nje kunemitlolo ema- '''{{NUMBEROFARTICLES}}''' y[[Isindebele|esiNdebele]]. 
Asithome!
&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot;  | 
&lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}

&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwe..&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{:Main Page/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{:Main Page/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{:Main Page/Topics}}&lt;/div&gt;
|}
|}

&lt;/tr&gt;
&lt;/table&gt;

&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{:Main Page/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__</text>
      <sha1>luynm939przfwxzcpe90ays83i7pmxg</sha1>
    </revision>
    <revision>
      <id>1764</id>
      <parentid>1763</parentid>
      <timestamp>2024-10-28T11:28:17Z</timestamp>
      <contributor>
        <ip>116.204.171.79</ip>
      </contributor>
      <comment>e</comment>
      <origin>1764</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3907" sha1="5ffppt9dz154vixu9egdf00b19toc28" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;|&lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|
|
|-
|
| style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot; |&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakwamukela ku[[Wikipedia|Wikiphidiya]] yelimi lesiNdebele&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;Iwikiphidiya yi-[[Encyclopedia|encyclopediya]] yasimahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngiwo woke&amp;nbsp;umuntu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenga nje kunemitlolo ema- '''{{NUMBEROFARTICLES}}''' y[[Isindebele|esiNdebele]]. 
Asithome!
&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|
|
| style=&quot;width:14%; font-size:95%;&quot; |
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
!
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot; | &lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}

&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwe..&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{:Main Page/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{:Main Page/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{:Main Page/Topics}}&lt;/div&gt;
|}
|}

&lt;/tr&gt;
&lt;/table&gt;

&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{:Main Page/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__</text>
      <sha1>5ffppt9dz154vixu9egdf00b19toc28</sha1>
    </revision>
    <revision>
      <id>1862</id>
      <parentid>1764</parentid>
      <timestamp>2024-11-03T08:21:12Z</timestamp>
      <contributor>
        <username>咽頭べさ</username>
        <id>133</id>
      </contributor>
      <origin>1862</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3930" sha1="41hfzz8eqm72ijkf54t14879dsnc34g" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;|&lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|
|
|-
|
| style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot; |&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakwamukela ku[[Wikipedia|Wikiphidiya]] yelimi lesiNdebele&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;Iwikiphidiya yi-[[Encyclopedia|encyclopediya]] yasimahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngiwo woke&amp;nbsp;umuntu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenga nje kunemitlolo ema- '''[[Special:Statistics|{{NUMBEROFARTICLES}}]]''' y[[Isindebele|esiNdebele]]. 
Asithome!
&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|
|
| style=&quot;width:14%; font-size:95%;&quot; |
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
!
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot; | &lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}

&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwe..&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{:Main Page/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{:Main Page/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{:Main Page/Topics}}&lt;/div&gt;
|}
|}

&lt;/tr&gt;
&lt;/table&gt;

&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{:Main Page/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__</text>
      <sha1>41hfzz8eqm72ijkf54t14879dsnc34g</sha1>
    </revision>
    <revision>
      <id>1914</id>
      <parentid>1862</parentid>
      <timestamp>2024-11-15T14:21:55Z</timestamp>
      <contributor>
        <username>MikitkoSynAlexeev</username>
        <id>168</id>
      </contributor>
      <origin>1914</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4097" sha1="3a05khughdxptxcf5hh0njstifs3ph3" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;|&lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|
|
|-
|
| style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot; |&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakwamukela ku[[Wikipedia|Wikiphidiya]] yelimi lesiNdebele&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;Iwikiphidiya yi-[[Encyclopedia|encyclopediya]] yasimahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngiwo woke&amp;nbsp;umuntu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenga nje kunemitlolo ema- '''[[Special:Statistics|{{NUMBEROFARTICLES}}]]''' y[[Isindebele|esiNdebele]]. 
Asithome!
&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|
|
| style=&quot;width:14%; font-size:95%;&quot; |
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
!
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot; | &lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] [[Isimumathi:Flag_of_Mongolia.svg|25px]] [[Isimumathi:Flag_of_Russia.svg|25px]] [[Isimumathi:Flag_of_Mari_El.svg|25px]] [[Isimumathi:Flag_of_Moscow,_Russia.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}

&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwe..&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{:Main Page/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{:Main Page/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{:Main Page/Topics}}&lt;/div&gt;
|}
|}

&lt;/tr&gt;
&lt;/table&gt;

&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{:Main Page/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__</text>
      <sha1>3a05khughdxptxcf5hh0njstifs3ph3</sha1>
    </revision>
    <revision>
      <id>1915</id>
      <parentid>1914</parentid>
      <timestamp>2024-11-15T14:23:26Z</timestamp>
      <contributor>
        <username>MikitkoSynAlexeev</username>
        <id>168</id>
      </contributor>
      <origin>1915</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3930" sha1="41hfzz8eqm72ijkf54t14879dsnc34g" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;|&lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|
|
|-
|
| style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot; |&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakwamukela ku[[Wikipedia|Wikiphidiya]] yelimi lesiNdebele&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;Iwikiphidiya yi-[[Encyclopedia|encyclopediya]] yasimahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngiwo woke&amp;nbsp;umuntu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenga nje kunemitlolo ema- '''[[Special:Statistics|{{NUMBEROFARTICLES}}]]''' y[[Isindebele|esiNdebele]]. 
Asithome!
&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|
|
| style=&quot;width:14%; font-size:95%;&quot; |
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
!
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot; | &lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}

&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwe..&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{:Main Page/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{:Main Page/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{:Main Page/Topics}}&lt;/div&gt;
|}
|}

&lt;/tr&gt;
&lt;/table&gt;

&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{:Main Page/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__</text>
      <sha1>41hfzz8eqm72ijkf54t14879dsnc34g</sha1>
    </revision>
    <revision>
      <id>2283</id>
      <parentid>1915</parentid>
      <timestamp>2024-12-20T22:22:23Z</timestamp>
      <contributor>
        <ip>2A04:4A43:88CF:F206:657C:7611:54FA:DF05</ip>
      </contributor>
      <comment>Replaced content with &quot;speak english you idiots english is the superior language you fucking morons 💀💀💀💀&quot;</comment>
      <origin>2283</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="93" sha1="irtbekac0vpsnkrab7xe1w70zn807oa" xml:space="preserve">speak english you idiots
english is the superior language you fucking morons
💀💀💀💀</text>
      <sha1>irtbekac0vpsnkrab7xe1w70zn807oa</sha1>
    </revision>
    <revision>
      <id>2289</id>
      <parentid>2283</parentid>
      <timestamp>2024-12-20T23:01:36Z</timestamp>
      <contributor>
        <username>Codename Noreste</username>
        <id>261</id>
      </contributor>
      <minor />
      <comment>Undo revision [[Special:Diff/2283|2283]] by [[Special:Contributions/2A04:4A43:88CF:F206:657C:7611:54FA:DF05|2A04:4A43:88CF:F206:657C:7611:54FA:DF05]] ([[User talk:2A04:4A43:88CF:F206:657C:7611:54FA:DF05|talk]])</comment>
      <origin>2289</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3930" sha1="41hfzz8eqm72ijkf54t14879dsnc34g" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;|&lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|
|
|-
|
| style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot; |&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakwamukela ku[[Wikipedia|Wikiphidiya]] yelimi lesiNdebele&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;Iwikiphidiya yi-[[Encyclopedia|encyclopediya]] yasimahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngiwo woke&amp;nbsp;umuntu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenga nje kunemitlolo ema- '''[[Special:Statistics|{{NUMBEROFARTICLES}}]]''' y[[Isindebele|esiNdebele]]. 
Asithome!
&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|
|
| style=&quot;width:14%; font-size:95%;&quot; |
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
!
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot; | &lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}

&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwe..&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{:Main Page/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{:Main Page/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{:Main Page/Topics}}&lt;/div&gt;
|}
|}

&lt;/tr&gt;
&lt;/table&gt;

&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{:Main Page/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__</text>
      <sha1>41hfzz8eqm72ijkf54t14879dsnc34g</sha1>
    </revision>
    <revision>
      <id>2292</id>
      <parentid>2289</parentid>
      <timestamp>2024-12-21T01:34:57Z</timestamp>
      <contributor>
        <username>WikiBayer</username>
        <id>225</id>
      </contributor>
      <minor />
      <comment>Protected &quot;[[Main Page]]&quot;: High traffic page ([Edit=Allow only autoconfirmed users] (indefinite) [Move=Allow only autoconfirmed users] (indefinite))</comment>
      <origin>2289</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3930" sha1="41hfzz8eqm72ijkf54t14879dsnc34g" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;|&lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|
|
|-
|
| style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot; |&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakwamukela ku[[Wikipedia|Wikiphidiya]] yelimi lesiNdebele&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;Iwikiphidiya yi-[[Encyclopedia|encyclopediya]] yasimahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngiwo woke&amp;nbsp;umuntu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenga nje kunemitlolo ema- '''[[Special:Statistics|{{NUMBEROFARTICLES}}]]''' y[[Isindebele|esiNdebele]]. 
Asithome!
&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|
|
| style=&quot;width:14%; font-size:95%;&quot; |
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
!
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot; | &lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhekhethu''&lt;/small&gt;&lt;/div&gt;
|}

&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwe..&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{:Main Page/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{:Main Page/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{:Main Page/Topics}}&lt;/div&gt;
|}
|}

&lt;/tr&gt;
&lt;/table&gt;

&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{:Main Page/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__</text>
      <sha1>41hfzz8eqm72ijkf54t14879dsnc34g</sha1>
    </revision>
    <revision>
      <id>2810</id>
      <parentid>2292</parentid>
      <timestamp>2025-05-11T18:48:28Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <minor />
      <comment>i changed the puntuation error.</comment>
      <origin>2810</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3927" sha1="ajozpz5jsgaz73d6ins01w9rw9mejyl" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;|&lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|
|
|-
|
| style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot; |&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakwamukela ku[[Wikipedia|Wikiphidiya]] yelimi lesiNdebele&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;Iwikiphidiya yi-[[Encyclopedia|encyclopediya]] yasimahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngiwo woke&amp;nbsp;umuntu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenga nje kunemitlolo ema- '''[[Special:Statistics|{{NUMBEROFARTICLES}}]]''' y[[Isindebele|esiNdebele]]. 
Asithome!
&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|
|
| style=&quot;width:14%; font-size:95%;&quot; |
* [[Portal:Iinaga|Iinaga Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukgoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amaholideyi]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ezigumiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubuvumi]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
!
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot; | &lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhethu''&lt;/small&gt;&lt;/div&gt;
|}

&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwe..&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{:Main Page/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{:Main Page/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{:Main Page/Topics}}&lt;/div&gt;
|}
|}

&lt;/tr&gt;
&lt;/table&gt;

&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{:Main Page/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__</text>
      <sha1>ajozpz5jsgaz73d6ins01w9rw9mejyl</sha1>
    </revision>
    <revision>
      <id>2834</id>
      <parentid>2810</parentid>
      <timestamp>2025-05-22T13:30:08Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <minor />
      <comment>I fixed spelling errors.</comment>
      <origin>2834</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3939" sha1="4p720rpo2y8l4qqf3ef3e6chuhmx2wu" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;|&lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|
|
|-
|
| style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot; |&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakwamukela ku[[Wikipedia|Wikiphidiya]] yelimi lesiNdebele&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;Iwikiphidiya yi-[[Encyclopedia|encyclopediya]] yasimahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngiwo woke&amp;nbsp;umuntu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenga nje kunemitlolo ema- '''[[Special:Statistics|{{NUMBEROFARTICLES}}]]''' y[[Isindebele|esiNdebele]]. 
Asithome!
&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|
|
| style=&quot;width:14%; font-size:95%;&quot; |
* [[Portal:Iinaga|Iinarha Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukghoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amalanga Wokuphumula]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ezigonyiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubavumi]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
!
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot; | &lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhethu''&lt;/small&gt;&lt;/div&gt;
|}

&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwe..&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{:Main Page/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{:Main Page/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{:Main Page/Topics}}&lt;/div&gt;
|}
|}

&lt;/tr&gt;
&lt;/table&gt;

&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{:Main Page/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__</text>
      <sha1>4p720rpo2y8l4qqf3ef3e6chuhmx2wu</sha1>
    </revision>
    <revision>
      <id>3277</id>
      <parentid>2834</parentid>
      <timestamp>2025-07-02T08:24:31Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <minor />
      <origin>3277</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3937" sha1="e8jzid7lifqmll2w4smwk2o1w6tneih" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;|&lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|
|
|-
|
| style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot; |&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakwamukela ku[[Wikipedia|Wikiphidiya]] yelimi lesiNdebele&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;Iwikiphidiya yi-[[Encyclopedia|encyclopediya]] yasimahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngiwo woke&amp;nbsp;umuntu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenganje kunemitlolo ema-'''[[Special:Statistics|{{NUMBEROFARTICLES}}]]''' y[[Isindebele|esiNdebele]]. 
Asithome!
&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|
|
| style=&quot;width:14%; font-size:95%;&quot; |
* [[Portal:Iinaga|Iinarha Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukghoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amalanga Wokuphumula]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ezigonyiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubavumi]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
!
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot; | &lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhethu''&lt;/small&gt;&lt;/div&gt;
|}

&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwe..&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{:Main Page/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{:Main Page/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{:Main Page/Topics}}&lt;/div&gt;
|}
|}

&lt;/tr&gt;
&lt;/table&gt;

&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{:Main Page/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__</text>
      <sha1>e8jzid7lifqmll2w4smwk2o1w6tneih</sha1>
    </revision>
    <revision>
      <id>3403</id>
      <parentid>3277</parentid>
      <timestamp>2025-07-11T11:50:20Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <minor />
      <comment>Changed protection settings for &quot;[[Main Page]]&quot;: This page has been vandalised before ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) [cascading]</comment>
      <origin>3277</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3937" sha1="e8jzid7lifqmll2w4smwk2o1w6tneih" xml:space="preserve">&lt;!------------------------------Banner across top of page------------------------------&gt;
{| style=&quot;width:100%; background:#fcfcfc; margin-top:1.2em; border:1px solid #ccc;&quot;
|style=&quot;width:56%; color:#000&quot;|&lt;!-- 

-----------&quot;Welcome to Wikipedia&quot; and article count----------&gt;
{| style=&quot;width:400px; border:solid 0px; background:none;&quot;
|
|
|-
|
| style=&quot;width:400px; text-align:center; white-space:nowrap; color:#000;&quot; |&lt;div style=&quot;font-size:162%; border:none; margin:0; padding:.1em; color:#000;&quot;&gt;Siyakwamukela ku[[Wikipedia|Wikiphidiya]] yelimi lesiNdebele&lt;/div&gt;
&lt;div style=&quot;top:+0.2em; font-size:95%;&quot;&gt;Iwikiphidiya yi-[[Encyclopedia|encyclopediya]] yasimahla [[Wikipedia:Introduction|etlolwa&amp;nbsp;ngiwo woke&amp;nbsp;umuntu]].&lt;/div&gt;
&lt;div id=&quot;articlecount&quot; style=&quot;width:100%; text-align:center; font-size:85%;&quot;&gt;Njenganje kunemitlolo ema-'''[[Special:Statistics|{{NUMBEROFARTICLES}}]]''' y[[Isindebele|esiNdebele]]. 
Asithome!
&lt;/div&gt;
|}
&lt;inputbox&gt;
type=create
width=40
break=no
bgcolor=#f0f0f0
buttonlabel=Tlola ikhasi elitjha 
searchbuttonlabel=Search
&lt;/inputbox&gt;&lt;!--

------------Portal list on righthand side----------&gt;
|
|
| style=&quot;width:14%; font-size:95%;&quot; |
* [[Portal:Iinaga|Iinarha Zephasi]]
* [[Portal:Amalimi|Amalimi]]
* [[Portal:Ubukgoni|Ubukghoni]]
|style=&quot;width:14%; font-size:95%;&quot;|
* [[Portal:Amaholideyi|Amalanga Wokuphumula]]
* [[Portal:Imidlalo|Imidlalo]]
* [[Portal:Imvelo|Imvelo]]
|style=&quot;width:20%; font-size:95%;&quot;|
* [[Portal:Ezigumiwako|Ezigonyiwako]]
* [[Portal:Amasonto|Amasonto]]
* [[Portal:Ubuvumi|Ubavumi]]
|}&lt;!--

----------Strapline immediately below banner----------&gt;
{| width=100% cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; valign=&quot;top&quot; style=&quot;background:#F1FAFF;&quot;
|-
!
! style=&quot;background:#E3E4FA; border:1px solid #eeeeee; text-align:center;&quot; | &lt;div style=&quot;font-size:120%&quot;&gt;[[Isimumathi:Flag of South Africa.svg|25px|:Isewula Afrika]] [[Isimumathi:Flag of Eswatini.svg|25px]] [[Isimumathi:Flag_of_Zimbabwe.svg|25px]] &lt;br&gt;&lt;small&gt;''Siragela phambili ngesikhethu''&lt;/small&gt;&lt;/div&gt;
|}

&lt;!--        TODAY'S FEATURED CONTENT        --&gt;
{| id=&quot;mp-upper&quot; style=&quot;width: 100%; margin:4px 0 0 0; background:none; border-spacing: 0px;&quot;
&lt;!--        TODAY'S FEATURED ARTICLE; DID YOU KNOW        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:55%; border:1px solid #cef2e0; background:#f5fffa; vertical-align:top; color:#000;&quot; |
{| id=&quot;mp-left&quot; style=&quot;vertical-align:top; background:#f5fffa;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;Imitlolo edzubhulwe..&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{:Main Page/Featured Article}}&lt;/div&gt;
|-
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-dyk-h2&quot; style=&quot;margin:3px; background:#cef2e0; font-size:120%; font-weight:bold; border:1px solid #a3bfb1; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;UBewazi na?...&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px 5px;&quot; | &lt;div id=&quot;mp-dyk&quot;&gt;{{:Main Page/Did you know}}&lt;/div&gt;
|}
| style=&quot;border:1px solid transparent;&quot; |
&lt;!--        PIC OF THE DAY        --&gt;
| class=&quot;MainPageBG&quot; style=&quot;width:45%; border:1px solid #cedff2; background:#f5faff; vertical-align:top;&quot;|
{| id=&quot;mp-right&quot; style=&quot;width:100%; vertical-align:top; background:#f5faff;&quot;
! style=&quot;padding:2px;&quot; | &lt;h2 id=&quot;mp-itn-h2&quot; style=&quot;margin:3px; background:#cedff2; font-size:120%; font-weight:bold; border:1px solid #a3b0bf; text-align:left; color:#000; padding:0.2em 0.4em;&quot;&gt;OKUNGAPHAKATHI&lt;/h2&gt;
|-
| style=&quot;color:#000; padding:2px 5px;&quot; | &lt;div id=&quot;mp-itn&quot;&gt;{{:Main Page/Topics}}&lt;/div&gt;
|}
|}

&lt;/tr&gt;
&lt;/table&gt;

&lt;!--        SECTIONS AT BOTTOM OF PAGE        --&gt;
&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:100%;width: 100%; background-color:#E3E4FA; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;{{:Main Page/Interwikis}}&lt;/div&gt;

__NOTOC____NOEDITSECTION__</text>
      <sha1>e8jzid7lifqmll2w4smwk2o1w6tneih</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Birth date</title>
    <ns>10</ns>
    <id>58</id>
    <revision>
      <id>235</id>
      <timestamp>2019-01-13T17:33:16Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;&lt;includeonly&gt;{{#if:{{{df|}}}|[[{{#expr:{{{3}}}}} {{MONTHNAME|{{{2}}}}}]]|[[{{MONTHNAME|{{{2}}}}} {{#expr:{{{3}}}}}]]}} [[{{{1}}}|{{{1}}}]]&lt;span style=&quot;display:none&quot;&gt;(&lt;sp...&quot;</comment>
      <origin>235</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="385" sha1="klj342t3duxbd2r4jnzex171ooukdvs" xml:space="preserve">&lt;includeonly&gt;{{#if:{{{df|}}}|[[{{#expr:{{{3}}}}} {{MONTHNAME|{{{2}}}}}]]|[[{{MONTHNAME|{{{2}}}}} {{#expr:{{{3}}}}}]]}} [[{{{1}}}|{{{1}}}]]&lt;span style=&quot;display:none&quot;&gt;(&lt;span class=&quot;bday&quot;&gt;{{{1}}}-{{padleft:{{MONTHNUMBER|{{{2}}}}}|2|0}}-{{padleft:{{{3}}}|2|0}}&lt;/span&gt;)&lt;/span&gt;&lt;/includeonly&gt;&lt;noinclude&gt;
{{pp-template|small=yes}}
{{Documentation|Template:Birth date and age/doc}}
&lt;/noinclude&gt;</text>
      <sha1>klj342t3duxbd2r4jnzex171ooukdvs</sha1>
    </revision>
    <revision>
      <id>236</id>
      <parentid>235</parentid>
      <timestamp>2024-10-14T13:46:14Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>235</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="385" sha1="klj342t3duxbd2r4jnzex171ooukdvs" xml:space="preserve">&lt;includeonly&gt;{{#if:{{{df|}}}|[[{{#expr:{{{3}}}}} {{MONTHNAME|{{{2}}}}}]]|[[{{MONTHNAME|{{{2}}}}} {{#expr:{{{3}}}}}]]}} [[{{{1}}}|{{{1}}}]]&lt;span style=&quot;display:none&quot;&gt;(&lt;span class=&quot;bday&quot;&gt;{{{1}}}-{{padleft:{{MONTHNUMBER|{{{2}}}}}|2|0}}-{{padleft:{{{3}}}|2|0}}&lt;/span&gt;)&lt;/span&gt;&lt;/includeonly&gt;&lt;noinclude&gt;
{{pp-template|small=yes}}
{{Documentation|Template:Birth date and age/doc}}
&lt;/noinclude&gt;</text>
      <sha1>klj342t3duxbd2r4jnzex171ooukdvs</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Birth date and age</title>
    <ns>10</ns>
    <id>59</id>
    <revision>
      <id>237</id>
      <timestamp>2016-02-22T14:09:31Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;&lt;includeonly&gt;{{#if:{{{df|}}}|{{#expr:{{{3|{{{day}}}}}}}} {{MONTHNAME|{{{2|{{{month}}}}}}}}|{{MONTHNAME|{{{2|{{{month}}}}}}}} {{#expr:{{{3|{{{day}}}}}}}},}} {{{1|{{{year}}}}}}&lt;...&quot;</comment>
      <origin>237</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="475" sha1="ex6dfvbt0dgs17odpjrtencllo8h93a" xml:space="preserve">&lt;includeonly&gt;{{#if:{{{df|}}}|{{#expr:{{{3|{{{day}}}}}}}} {{MONTHNAME|{{{2|{{{month}}}}}}}}|{{MONTHNAME|{{{2|{{{month}}}}}}}} {{#expr:{{{3|{{{day}}}}}}}},}} {{{1|{{{year}}}}}}&lt;span style=&quot;display:none&quot;&gt; (&lt;span class=&quot;bday&quot;&gt;{{{1|{{{year}}}}}}-{{padleft:{{{2|{{{month}}}}}}|2|0}}-{{padleft:{{{3|{{{day}}}}}}|2|0}}&lt;/span&gt;)&lt;/span&gt;&lt;span class=&quot;noprint&quot;&gt; (age&amp;nbsp;{{age | {{{1|{{{year}}}}}} | {{{2|{{{month}}}}}} | {{{3|{{{day}}}}}} }})&lt;/span&gt;&lt;/includeonly&gt;&lt;noinclude&gt;
&lt;/noinclude&gt;</text>
      <sha1>ex6dfvbt0dgs17odpjrtencllo8h93a</sha1>
    </revision>
    <revision>
      <id>238</id>
      <parentid>237</parentid>
      <timestamp>2016-02-22T14:13:57Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>237</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="475" sha1="ex6dfvbt0dgs17odpjrtencllo8h93a" xml:space="preserve">&lt;includeonly&gt;{{#if:{{{df|}}}|{{#expr:{{{3|{{{day}}}}}}}} {{MONTHNAME|{{{2|{{{month}}}}}}}}|{{MONTHNAME|{{{2|{{{month}}}}}}}} {{#expr:{{{3|{{{day}}}}}}}},}} {{{1|{{{year}}}}}}&lt;span style=&quot;display:none&quot;&gt; (&lt;span class=&quot;bday&quot;&gt;{{{1|{{{year}}}}}}-{{padleft:{{{2|{{{month}}}}}}|2|0}}-{{padleft:{{{3|{{{day}}}}}}|2|0}}&lt;/span&gt;)&lt;/span&gt;&lt;span class=&quot;noprint&quot;&gt; (age&amp;nbsp;{{age | {{{1|{{{year}}}}}} | {{{2|{{{month}}}}}} | {{{3|{{{day}}}}}} }})&lt;/span&gt;&lt;/includeonly&gt;&lt;noinclude&gt;
&lt;/noinclude&gt;</text>
      <sha1>ex6dfvbt0dgs17odpjrtencllo8h93a</sha1>
    </revision>
    <revision>
      <id>239</id>
      <parentid>238</parentid>
      <timestamp>2024-10-14T13:46:15Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>237</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="475" sha1="ex6dfvbt0dgs17odpjrtencllo8h93a" xml:space="preserve">&lt;includeonly&gt;{{#if:{{{df|}}}|{{#expr:{{{3|{{{day}}}}}}}} {{MONTHNAME|{{{2|{{{month}}}}}}}}|{{MONTHNAME|{{{2|{{{month}}}}}}}} {{#expr:{{{3|{{{day}}}}}}}},}} {{{1|{{{year}}}}}}&lt;span style=&quot;display:none&quot;&gt; (&lt;span class=&quot;bday&quot;&gt;{{{1|{{{year}}}}}}-{{padleft:{{{2|{{{month}}}}}}|2|0}}-{{padleft:{{{3|{{{day}}}}}}|2|0}}&lt;/span&gt;)&lt;/span&gt;&lt;span class=&quot;noprint&quot;&gt; (age&amp;nbsp;{{age | {{{1|{{{year}}}}}} | {{{2|{{{month}}}}}} | {{{3|{{{day}}}}}} }})&lt;/span&gt;&lt;/includeonly&gt;&lt;noinclude&gt;
&lt;/noinclude&gt;</text>
      <sha1>ex6dfvbt0dgs17odpjrtencllo8h93a</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Br separated entries</title>
    <ns>10</ns>
    <id>60</id>
    <revision>
      <id>240</id>
      <timestamp>2016-02-22T13:56:52Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;{{{1|}}}{{#if:{{{1|}}}|{{#if:{{{2|}}}{{{3|}}}|&lt;br /&gt;}}}}{{{2|}}}{{#if:{{{2|}}}|{{#if:{{{3|}}}|&lt;br /&gt;}}}}{{{3|}}}&lt;noinclude&gt; {{documentation}} &lt;/noinclude&gt;&quot;</comment>
      <origin>240</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="154" sha1="9nncnf82brju9aav74unl7qdznyi601" xml:space="preserve">{{{1|}}}{{#if:{{{1|}}}|{{#if:{{{2|}}}{{{3|}}}|&lt;br /&gt;}}}}{{{2|}}}{{#if:{{{2|}}}|{{#if:{{{3|}}}|&lt;br /&gt;}}}}{{{3|}}}&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>9nncnf82brju9aav74unl7qdznyi601</sha1>
    </revision>
    <revision>
      <id>241</id>
      <parentid>240</parentid>
      <timestamp>2016-02-22T13:57:12Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>241</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="136" sha1="ef7c84fxdsg9hcc5gh5zn6cdamkxz4g" xml:space="preserve">{{{1|}}}{{#if:{{{1|}}}|{{#if:{{{2|}}}{{{3|}}}|&lt;br /&gt;}}}}{{{2|}}}{{#if:{{{2|}}}|{{#if:{{{3|}}}|&lt;br /&gt;}}}}{{{3|}}}&lt;noinclude&gt;
&lt;/noinclude&gt;</text>
      <sha1>ef7c84fxdsg9hcc5gh5zn6cdamkxz4g</sha1>
    </revision>
    <revision>
      <id>242</id>
      <parentid>241</parentid>
      <timestamp>2024-10-14T13:46:15Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>241</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="136" sha1="ef7c84fxdsg9hcc5gh5zn6cdamkxz4g" xml:space="preserve">{{{1|}}}{{#if:{{{1|}}}|{{#if:{{{2|}}}{{{3|}}}|&lt;br /&gt;}}}}{{{2|}}}{{#if:{{{2|}}}|{{#if:{{{3|}}}|&lt;br /&gt;}}}}{{{3|}}}&lt;noinclude&gt;
&lt;/noinclude&gt;</text>
      <sha1>ef7c84fxdsg9hcc5gh5zn6cdamkxz4g</sha1>
    </revision>
    <revision>
      <id>367</id>
      <parentid>241</parentid>
      <timestamp>2016-02-22T14:00:52Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;{{{1|}}}{{#if:{{{1|}}}|{{#if:{{{2|}}}{{{3|}}}|&lt;br /&gt;}}}}{{{2|}}}{{#if:{{{2|}}}|{{#if:{{{3|}}}|&lt;br /&gt;}}}}{{{3|}}}&lt;noinclude&gt; &lt;/noinclude&gt;&quot;</comment>
      <origin>241</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="136" sha1="ef7c84fxdsg9hcc5gh5zn6cdamkxz4g" xml:space="preserve">{{{1|}}}{{#if:{{{1|}}}|{{#if:{{{2|}}}{{{3|}}}|&lt;br /&gt;}}}}{{{2|}}}{{#if:{{{2|}}}|{{#if:{{{3|}}}|&lt;br /&gt;}}}}{{{3|}}}&lt;noinclude&gt;
&lt;/noinclude&gt;</text>
      <sha1>ef7c84fxdsg9hcc5gh5zn6cdamkxz4g</sha1>
    </revision>
    <revision>
      <id>368</id>
      <parentid>242</parentid>
      <timestamp>2024-10-14T13:46:24Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>241</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="136" sha1="ef7c84fxdsg9hcc5gh5zn6cdamkxz4g" xml:space="preserve">{{{1|}}}{{#if:{{{1|}}}|{{#if:{{{2|}}}{{{3|}}}|&lt;br /&gt;}}}}{{{2|}}}{{#if:{{{2|}}}|{{#if:{{{3|}}}|&lt;br /&gt;}}}}{{{3|}}}&lt;noinclude&gt;
&lt;/noinclude&gt;</text>
      <sha1>ef7c84fxdsg9hcc5gh5zn6cdamkxz4g</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Cite book</title>
    <ns>10</ns>
    <id>64</id>
    <revision>
      <id>257</id>
      <timestamp>2014-09-04T15:44:11Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;&lt;includeonly&gt;{{#invoke:citation/CS1|citation |CitationClass=book }}&lt;/includeonly&gt;&lt;noinclude&gt; {{documentation}} &lt;/noinclude&gt;&quot;</comment>
      <origin>257</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="123" sha1="hq4yscm08hccl43rjw83qi7egacgxec" xml:space="preserve">&lt;includeonly&gt;{{#invoke:citation/CS1|citation
|CitationClass=book
}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>hq4yscm08hccl43rjw83qi7egacgxec</sha1>
    </revision>
    <revision>
      <id>258</id>
      <parentid>257</parentid>
      <timestamp>2014-09-04T15:53:25Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <origin>257</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="123" sha1="hq4yscm08hccl43rjw83qi7egacgxec" xml:space="preserve">&lt;includeonly&gt;{{#invoke:citation/CS1|citation
|CitationClass=book
}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>hq4yscm08hccl43rjw83qi7egacgxec</sha1>
    </revision>
    <revision>
      <id>259</id>
      <parentid>258</parentid>
      <timestamp>2014-09-04T15:56:44Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <origin>259</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="123" sha1="aq6vm3lxh8816pgrjotoow151mt3o3x" xml:space="preserve">&lt;includeonly&gt;{{#invoke:Citation/CS1|citation
|CitationClass=book
}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>aq6vm3lxh8816pgrjotoow151mt3o3x</sha1>
    </revision>
    <revision>
      <id>260</id>
      <parentid>259</parentid>
      <timestamp>2014-09-04T16:04:36Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <origin>259</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="123" sha1="aq6vm3lxh8816pgrjotoow151mt3o3x" xml:space="preserve">&lt;includeonly&gt;{{#invoke:Citation/CS1|citation
|CitationClass=book
}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>aq6vm3lxh8816pgrjotoow151mt3o3x</sha1>
    </revision>
    <revision>
      <id>261</id>
      <parentid>260</parentid>
      <timestamp>2014-09-04T16:09:45Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>Old from [[:en:Template:Cite book]]</comment>
      <origin>261</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5158" sha1="1hcde9hjzsjtaa5kh4l4gei6zgm65k0" xml:space="preserve">{{Citation/core
|Citation class=book

|Surname1={{{last|{{{last1|{{{author|{{{author1|{{{authors|{{{surname|{{{surname1|}}}}}}}}}}}}}}}}}}}}}
|Surname2={{{last2|{{{author2|{{{surname2|}}}}}}}}}
|Surname3={{{last3|{{{author3|{{{surname3|}}}}}}}}}
|Surname4={{{last4|{{{author4|{{{surname4|}}}}}}}}}
|Surname5={{{last5|{{{author5|{{{surname5|}}}}}}}}}
|Surname6={{{last6|{{{author6|{{{surname6|}}}}}}}}}
|Surname7={{{last7|{{{author7|{{{surname7|}}}}}}}}}
|Surname8={{{last8|{{{author8|{{{surname8|}}}}}}}}}
|Surname9={{{last9|{{{author9|{{{surname9|}}}}}}}}}

|Given1={{{first|{{{first1|{{{given|{{{given1|}}}}}}}}}}}}
|Given2={{{first2|{{{given2|}}}}}}
|Given3={{{first3|{{{given3|}}}}}}
|Given4={{{first4|{{{given4|}}}}}}
|Given5={{{first5|{{{given5|}}}}}}
|Given6={{{first6|{{{given6|}}}}}}
|Given7={{{first7|{{{given7|}}}}}}
|Given8={{{first8|{{{given8|}}}}}}
|Given9={{{first9|{{{given9|}}}}}}

|Authorlink1={{{authorlink|{{{authorlink1|{{{author-link|{{{author1-link|}}}}}}}}}}}}
|Authorlink2={{{authorlink2|{{{author2-link|}}}}}}
|Authorlink3={{{authorlink3|{{{author3-link|}}}}}}
|Authorlink4={{{authorlink4|{{{author4-link|}}}}}}
|Authorlink5={{{authorlink5|{{{author5-link|}}}}}}
|Authorlink6={{{authorlink6|{{{author6-link|}}}}}}
|Authorlink7={{{authorlink7|{{{author7-link|}}}}}}
|Authorlink8={{{authorlink8|{{{author8-link|}}}}}}
|Authorlink9={{{authorlink9|{{{author9-link|}}}}}}

|Coauthors={{{coauthors|{{{coauthor|}}}}}}

|Other={{{others|}}}

|Year={{{year|{{    &lt;!-- attempt to derive year from date, if possible --&gt;
           #if: {{{date|}}}
           |{{
              #iferror:{{#time:Y|{{{date|}}} }}
              |{{#iferror:{{#time:Y|{{{publication-date|einval}}} }}||{{#time:Y|{{{publication-date|}}} }}}}
              |{{#time:Y|{{{date|}}} }}
            }}
           |{{{publication-date|}}} &lt;!-- last resort --&gt;
         }}
      }}}
|YearNote={{{origyear|}}}
|Date={{#if:{{{date|}}}|{{{date}}}|{{{day|}}} {{{month|}}} {{{year|{{{publication-date|}}}}}}}}

|Title={{{title|}}}
|TransTitle={{{trans_chapter|}}}
|TransItalic={{{trans_title|}}}
|IncludedWorkTitle={{{chapter|{{{contribution|{{{section|}}}}}}}}}
|TitleType={{{type|}}}
|language={{{language|}}}

|URL={{#if:{{{archiveurl|}}}
       |{{#ifeq: {{{deadurl|}}} | no | {{{url|}}} | {{{archiveurl|}}}}}
       |{{{url|}}}
     }}
|IncludedWorkURL={{{chapter-url|{{{chapterurl|{{{contribution-url|{{{sectionurl|}}}}}}}}}}}}
|AccessDate={{{accessdate|}}}
|OriginalURL={{{url|}}}
|ArchiveURL={{{archiveurl|}}}
|ArchiveDate={{{archivedate|}}}
|DeadURL={{{deadurl|}}}
|format={{{format|}}}

|At={{#if: {{{page|}}}|{{#if:{{{nopp|}}}||p.&amp;nbsp;}}{{{page}}}
      |{{#if: {{{pages|}}}|{{#if:{{{nopp|}}}||pp.&amp;nbsp;}}{{{pages}}}
      |{{{at|}}}}}
    }}

|Edition={{{edition|}}}
|Series={{{series|{{{version|}}}}}}
|Volume={{{volume|}}}

|Publisher={{{publisher|}}}
|Place={{{location|{{{place|}}}}}}
|PublicationPlace={{{location|{{{place|{{{publication-place|}}}}}}}}}
|PublicationDate={{{publication-date|}}}

|EditorSurname1={{{editor-last|{{{editor1-last|{{{editor|{{{editors|{{{editor-surname|{{{editor1-surname|}}}}}}}}}}}}}}}}}}
|EditorSurname2={{{editor2-last|{{{editor2-surname|}}}}}}
|EditorSurname3={{{editor3-last|{{{editor3-surname|}}}}}}
|EditorSurname4={{{editor4-last|{{{editor4-surname|}}}}}}
|EditorGiven1={{{editor-first|{{{editor1-first|{{{editor-given|{{{editor1-given|}}}}}}}}}}}}
|EditorGiven2={{{editor2-first|{{{editor2-given|}}}}}}
|EditorGiven3={{{editor3-first|{{{editor3-given|}}}}}}
|EditorGiven4={{{editor4-first|{{{editor4-given|}}}}}}
|Editorlink1={{{editor-link|{{{editor1-link|}}}}}}
|Editorlink2={{{editor2-link|}}}
|Editorlink3={{{editor3-link|}}}
|Editorlink4={{{editor4-link|}}}

|ARXIV={{{arxiv|}}}
|ASIN={{{asin|{{{ASIN|}}}}}}
|ASIN-TLD={{{asin-tld|}}}
|BIBCODE={{{bibcode|}}}
|DOI={{{doi|{{{DOI|}}}}}}
|DoiBroken={{{doi_brokendate|{{{doi_inactivedate|}}}}}}
|ISBN={{{isbn|{{{ISBN|}}}}}}
|ISSN={{{issn|{{{ISSN|}}}}}}
|JFM={{{jfm|{{{JFM|}}}}}}
|JSTOR={{{jstor|{{{JSTOR|}}}}}}
|LCCN={{{lccn|{{{LCCN|}}}}}}
|MR={{{mr|{{{MR|}}}}}}
|OCLC={{{oclc|{{{OCLC|}}}}}}
|OL={{{ol|{{{OL|}}}}}}
|OSTI={{{osti|{{{OSTI|}}}}}}
|PMC={{{pmc|{{{PMC|}}}}}}
|PMID={{{pmid|{{{PMID|}}}}}}
|RFC={{{rfc|{{{RFC|}}}}}}
|SSRN={{{ssrn|{{{SSRN|}}}}}}
|ZBL={{{zbl|}}}
|ID={{{id|{{{ID|}}}}}}

|laysummary={{{laysummary|}}}
|laydate={{{laydate|}}}
|laysource={{{laysource|}}}

|quote={{{quote|}}}

|Ref={{{ref|}}}

|amp={{{lastauthoramp|}}}
|AuthorMask={{{author-mask|{{{authormask|}}}}}}
|AuthorSep={{#ifeq:{{{author-separator|}}}|;|&amp;#059;|{{{author-separator|&amp;#059;}}}}}&amp;#32;
|NameSep={{{author-name-separator|,}}}&amp;#32;
|PS={{#if:{{{quote|}}}||{{{postscript|.}}}}}
|Sep={{#ifeq:{{{separator|{{{seperator}}} }}}|;|&amp;#059;|{{{separator|{{{seperator|.}}} }}} }}
|template doc demo={{{template doc demo|}}}
|Trunc={{#if:{{{display-authors|}}}|{{{display-authors}}}|8}}
}}{{#if:{{{access-date|}}}{{{accessdaymonth|}}}{{{accessday|}}}{{{accessmonthday|}}}{{{accessmonth|}}}{{{accessyear|}}}{{{dateformat|}}}{{{day|}}}{{{doilabel|}}}
|[[Mkhakha:Pages containing cite templates with deprecated parameters|{{NAMESPACE}} {{PAGENAME}}]]}}&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>1hcde9hjzsjtaa5kh4l4gei6zgm65k0</sha1>
    </revision>
    <revision>
      <id>262</id>
      <parentid>261</parentid>
      <timestamp>2014-09-04T16:11:36Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <origin>261</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5158" sha1="1hcde9hjzsjtaa5kh4l4gei6zgm65k0" xml:space="preserve">{{Citation/core
|Citation class=book

|Surname1={{{last|{{{last1|{{{author|{{{author1|{{{authors|{{{surname|{{{surname1|}}}}}}}}}}}}}}}}}}}}}
|Surname2={{{last2|{{{author2|{{{surname2|}}}}}}}}}
|Surname3={{{last3|{{{author3|{{{surname3|}}}}}}}}}
|Surname4={{{last4|{{{author4|{{{surname4|}}}}}}}}}
|Surname5={{{last5|{{{author5|{{{surname5|}}}}}}}}}
|Surname6={{{last6|{{{author6|{{{surname6|}}}}}}}}}
|Surname7={{{last7|{{{author7|{{{surname7|}}}}}}}}}
|Surname8={{{last8|{{{author8|{{{surname8|}}}}}}}}}
|Surname9={{{last9|{{{author9|{{{surname9|}}}}}}}}}

|Given1={{{first|{{{first1|{{{given|{{{given1|}}}}}}}}}}}}
|Given2={{{first2|{{{given2|}}}}}}
|Given3={{{first3|{{{given3|}}}}}}
|Given4={{{first4|{{{given4|}}}}}}
|Given5={{{first5|{{{given5|}}}}}}
|Given6={{{first6|{{{given6|}}}}}}
|Given7={{{first7|{{{given7|}}}}}}
|Given8={{{first8|{{{given8|}}}}}}
|Given9={{{first9|{{{given9|}}}}}}

|Authorlink1={{{authorlink|{{{authorlink1|{{{author-link|{{{author1-link|}}}}}}}}}}}}
|Authorlink2={{{authorlink2|{{{author2-link|}}}}}}
|Authorlink3={{{authorlink3|{{{author3-link|}}}}}}
|Authorlink4={{{authorlink4|{{{author4-link|}}}}}}
|Authorlink5={{{authorlink5|{{{author5-link|}}}}}}
|Authorlink6={{{authorlink6|{{{author6-link|}}}}}}
|Authorlink7={{{authorlink7|{{{author7-link|}}}}}}
|Authorlink8={{{authorlink8|{{{author8-link|}}}}}}
|Authorlink9={{{authorlink9|{{{author9-link|}}}}}}

|Coauthors={{{coauthors|{{{coauthor|}}}}}}

|Other={{{others|}}}

|Year={{{year|{{    &lt;!-- attempt to derive year from date, if possible --&gt;
           #if: {{{date|}}}
           |{{
              #iferror:{{#time:Y|{{{date|}}} }}
              |{{#iferror:{{#time:Y|{{{publication-date|einval}}} }}||{{#time:Y|{{{publication-date|}}} }}}}
              |{{#time:Y|{{{date|}}} }}
            }}
           |{{{publication-date|}}} &lt;!-- last resort --&gt;
         }}
      }}}
|YearNote={{{origyear|}}}
|Date={{#if:{{{date|}}}|{{{date}}}|{{{day|}}} {{{month|}}} {{{year|{{{publication-date|}}}}}}}}

|Title={{{title|}}}
|TransTitle={{{trans_chapter|}}}
|TransItalic={{{trans_title|}}}
|IncludedWorkTitle={{{chapter|{{{contribution|{{{section|}}}}}}}}}
|TitleType={{{type|}}}
|language={{{language|}}}

|URL={{#if:{{{archiveurl|}}}
       |{{#ifeq: {{{deadurl|}}} | no | {{{url|}}} | {{{archiveurl|}}}}}
       |{{{url|}}}
     }}
|IncludedWorkURL={{{chapter-url|{{{chapterurl|{{{contribution-url|{{{sectionurl|}}}}}}}}}}}}
|AccessDate={{{accessdate|}}}
|OriginalURL={{{url|}}}
|ArchiveURL={{{archiveurl|}}}
|ArchiveDate={{{archivedate|}}}
|DeadURL={{{deadurl|}}}
|format={{{format|}}}

|At={{#if: {{{page|}}}|{{#if:{{{nopp|}}}||p.&amp;nbsp;}}{{{page}}}
      |{{#if: {{{pages|}}}|{{#if:{{{nopp|}}}||pp.&amp;nbsp;}}{{{pages}}}
      |{{{at|}}}}}
    }}

|Edition={{{edition|}}}
|Series={{{series|{{{version|}}}}}}
|Volume={{{volume|}}}

|Publisher={{{publisher|}}}
|Place={{{location|{{{place|}}}}}}
|PublicationPlace={{{location|{{{place|{{{publication-place|}}}}}}}}}
|PublicationDate={{{publication-date|}}}

|EditorSurname1={{{editor-last|{{{editor1-last|{{{editor|{{{editors|{{{editor-surname|{{{editor1-surname|}}}}}}}}}}}}}}}}}}
|EditorSurname2={{{editor2-last|{{{editor2-surname|}}}}}}
|EditorSurname3={{{editor3-last|{{{editor3-surname|}}}}}}
|EditorSurname4={{{editor4-last|{{{editor4-surname|}}}}}}
|EditorGiven1={{{editor-first|{{{editor1-first|{{{editor-given|{{{editor1-given|}}}}}}}}}}}}
|EditorGiven2={{{editor2-first|{{{editor2-given|}}}}}}
|EditorGiven3={{{editor3-first|{{{editor3-given|}}}}}}
|EditorGiven4={{{editor4-first|{{{editor4-given|}}}}}}
|Editorlink1={{{editor-link|{{{editor1-link|}}}}}}
|Editorlink2={{{editor2-link|}}}
|Editorlink3={{{editor3-link|}}}
|Editorlink4={{{editor4-link|}}}

|ARXIV={{{arxiv|}}}
|ASIN={{{asin|{{{ASIN|}}}}}}
|ASIN-TLD={{{asin-tld|}}}
|BIBCODE={{{bibcode|}}}
|DOI={{{doi|{{{DOI|}}}}}}
|DoiBroken={{{doi_brokendate|{{{doi_inactivedate|}}}}}}
|ISBN={{{isbn|{{{ISBN|}}}}}}
|ISSN={{{issn|{{{ISSN|}}}}}}
|JFM={{{jfm|{{{JFM|}}}}}}
|JSTOR={{{jstor|{{{JSTOR|}}}}}}
|LCCN={{{lccn|{{{LCCN|}}}}}}
|MR={{{mr|{{{MR|}}}}}}
|OCLC={{{oclc|{{{OCLC|}}}}}}
|OL={{{ol|{{{OL|}}}}}}
|OSTI={{{osti|{{{OSTI|}}}}}}
|PMC={{{pmc|{{{PMC|}}}}}}
|PMID={{{pmid|{{{PMID|}}}}}}
|RFC={{{rfc|{{{RFC|}}}}}}
|SSRN={{{ssrn|{{{SSRN|}}}}}}
|ZBL={{{zbl|}}}
|ID={{{id|{{{ID|}}}}}}

|laysummary={{{laysummary|}}}
|laydate={{{laydate|}}}
|laysource={{{laysource|}}}

|quote={{{quote|}}}

|Ref={{{ref|}}}

|amp={{{lastauthoramp|}}}
|AuthorMask={{{author-mask|{{{authormask|}}}}}}
|AuthorSep={{#ifeq:{{{author-separator|}}}|;|&amp;#059;|{{{author-separator|&amp;#059;}}}}}&amp;#32;
|NameSep={{{author-name-separator|,}}}&amp;#32;
|PS={{#if:{{{quote|}}}||{{{postscript|.}}}}}
|Sep={{#ifeq:{{{separator|{{{seperator}}} }}}|;|&amp;#059;|{{{separator|{{{seperator|.}}} }}} }}
|template doc demo={{{template doc demo|}}}
|Trunc={{#if:{{{display-authors|}}}|{{{display-authors}}}|8}}
}}{{#if:{{{access-date|}}}{{{accessdaymonth|}}}{{{accessday|}}}{{{accessmonthday|}}}{{{accessmonth|}}}{{{accessyear|}}}{{{dateformat|}}}{{{day|}}}{{{doilabel|}}}
|[[Mkhakha:Pages containing cite templates with deprecated parameters|{{NAMESPACE}} {{PAGENAME}}]]}}&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>1hcde9hjzsjtaa5kh4l4gei6zgm65k0</sha1>
    </revision>
    <revision>
      <id>263</id>
      <parentid>262</parentid>
      <timestamp>2019-12-03T11:17:27Z</timestamp>
      <contributor>
        <username>incubator&gt;Adithyak1997</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Added a prefix</comment>
      <origin>263</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5158" sha1="hq6j0fz2uhr1wwbwrn8slrbuw0k0ese" xml:space="preserve">{{Citation/core
|Citation class=book

|Surname1={{{last|{{{last1|{{{author|{{{author1|{{{authors|{{{surname|{{{surname1|}}}}}}}}}}}}}}}}}}}}}
|Surname2={{{last2|{{{author2|{{{surname2|}}}}}}}}}
|Surname3={{{last3|{{{author3|{{{surname3|}}}}}}}}}
|Surname4={{{last4|{{{author4|{{{surname4|}}}}}}}}}
|Surname5={{{last5|{{{author5|{{{surname5|}}}}}}}}}
|Surname6={{{last6|{{{author6|{{{surname6|}}}}}}}}}
|Surname7={{{last7|{{{author7|{{{surname7|}}}}}}}}}
|Surname8={{{last8|{{{author8|{{{surname8|}}}}}}}}}
|Surname9={{{last9|{{{author9|{{{surname9|}}}}}}}}}

|Given1={{{first|{{{first1|{{{given|{{{given1|}}}}}}}}}}}}
|Given2={{{first2|{{{given2|}}}}}}
|Given3={{{first3|{{{given3|}}}}}}
|Given4={{{first4|{{{given4|}}}}}}
|Given5={{{first5|{{{given5|}}}}}}
|Given6={{{first6|{{{given6|}}}}}}
|Given7={{{first7|{{{given7|}}}}}}
|Given8={{{first8|{{{given8|}}}}}}
|Given9={{{first9|{{{given9|}}}}}}

|Authorlink1={{{authorlink|{{{authorlink1|{{{author-link|{{{author1-link|}}}}}}}}}}}}
|Authorlink2={{{authorlink2|{{{author2-link|}}}}}}
|Authorlink3={{{authorlink3|{{{author3-link|}}}}}}
|Authorlink4={{{authorlink4|{{{author4-link|}}}}}}
|Authorlink5={{{authorlink5|{{{author5-link|}}}}}}
|Authorlink6={{{authorlink6|{{{author6-link|}}}}}}
|Authorlink7={{{authorlink7|{{{author7-link|}}}}}}
|Authorlink8={{{authorlink8|{{{author8-link|}}}}}}
|Authorlink9={{{authorlink9|{{{author9-link|}}}}}}

|Coauthors={{{coauthors|{{{coauthor|}}}}}}

|Other={{{others|}}}

|Year={{{year|{{    &lt;!-- attempt to derive year from date, if possible --&gt;
           #if: {{{date|}}}
           |{{
              #iferror:{{#time:Y|{{{date|}}} }}
              |{{#iferror:{{#time:Y|{{{publication-date|einval}}} }}||{{#time:Y|{{{publication-date|}}} }}}}
              |{{#time:Y|{{{date|}}} }}
            }}
           |{{{publication-date|}}} &lt;!-- last resort --&gt;
         }}
      }}}
|YearNote={{{origyear|}}}
|Date={{#if:{{{date|}}}|{{{date}}}|{{{day|}}} {{{month|}}} {{{year|{{{publication-date|}}}}}}}}

|Title={{{title|}}}
|TransTitle={{{trans_chapter|}}}
|TransItalic={{{trans_title|}}}
|IncludedWorkTitle={{{chapter|{{{contribution|{{{section|}}}}}}}}}
|TitleType={{{type|}}}
|language={{{language|}}}

|URL={{#if:{{{archiveurl|}}}
       |{{#ifeq: {{{deadurl|}}} | no | {{{url|}}} | {{{archiveurl|}}}}}
       |{{{url|}}}
     }}
|IncludedWorkURL={{{chapter-url|{{{chapterurl|{{{contribution-url|{{{sectionurl|}}}}}}}}}}}}
|AccessDate={{{accessdate|}}}
|OriginalURL={{{url|}}}
|ArchiveURL={{{archiveurl|}}}
|ArchiveDate={{{archivedate|}}}
|DeadURL={{{deadurl|}}}
|format={{{format|}}}

|At={{#if: {{{page|}}}|{{#if:{{{nopp|}}}||p.&amp;nbsp;}}{{{page}}}
      |{{#if: {{{pages|}}}|{{#if:{{{nopp|}}}||pp.&amp;nbsp;}}{{{pages}}}
      |{{{at|}}}}}
    }}

|Edition={{{edition|}}}
|Series={{{series|{{{version|}}}}}}
|Volume={{{volume|}}}

|Publisher={{{publisher|}}}
|Place={{{location|{{{place|}}}}}}
|PublicationPlace={{{location|{{{place|{{{publication-place|}}}}}}}}}
|PublicationDate={{{publication-date|}}}

|EditorSurname1={{{editor-last|{{{editor1-last|{{{editor|{{{editors|{{{editor-surname|{{{editor1-surname|}}}}}}}}}}}}}}}}}}
|EditorSurname2={{{editor2-last|{{{editor2-surname|}}}}}}
|EditorSurname3={{{editor3-last|{{{editor3-surname|}}}}}}
|EditorSurname4={{{editor4-last|{{{editor4-surname|}}}}}}
|EditorGiven1={{{editor-first|{{{editor1-first|{{{editor-given|{{{editor1-given|}}}}}}}}}}}}
|EditorGiven2={{{editor2-first|{{{editor2-given|}}}}}}
|EditorGiven3={{{editor3-first|{{{editor3-given|}}}}}}
|EditorGiven4={{{editor4-first|{{{editor4-given|}}}}}}
|Editorlink1={{{editor-link|{{{editor1-link|}}}}}}
|Editorlink2={{{editor2-link|}}}
|Editorlink3={{{editor3-link|}}}
|Editorlink4={{{editor4-link|}}}

|ARXIV={{{arxiv|}}}
|ASIN={{{asin|{{{ASIN|}}}}}}
|ASIN-TLD={{{asin-tld|}}}
|BIBCODE={{{bibcode|}}}
|DOI={{{doi|{{{DOI|}}}}}}
|DoiBroken={{{doi_brokendate|{{{doi_inactivedate|}}}}}}
|ISBN={{{isbn|{{{ISBN|}}}}}}
|ISSN={{{issn|{{{ISSN|}}}}}}
|JFM={{{jfm|{{{JFM|}}}}}}
|JSTOR={{{jstor|{{{JSTOR|}}}}}}
|LCCN={{{lccn|{{{LCCN|}}}}}}
|MR={{{mr|{{{MR|}}}}}}
|OCLC={{{oclc|{{{OCLC|}}}}}}
|OL={{{ol|{{{OL|}}}}}}
|OSTI={{{osti|{{{OSTI|}}}}}}
|PMC={{{pmc|{{{PMC|}}}}}}
|PMID={{{pmid|{{{PMID|}}}}}}
|RFC={{{rfc|{{{RFC|}}}}}}
|SSRN={{{ssrn|{{{SSRN|}}}}}}
|ZBL={{{zbl|}}}
|ID={{{id|{{{ID|}}}}}}

|laysummary={{{laysummary|}}}
|laydate={{{laydate|}}}
|laysource={{{laysource|}}}

|quote={{{quote|}}}

|Ref={{{ref|}}}

|amp={{{lastauthoramp|}}}
|AuthorMask={{{author-mask|{{{authormask|}}}}}}
|AuthorSep={{#ifeq:{{{author-separator|}}}|;|&amp;#059;|{{{author-separator|&amp;#059;}}}}}&amp;#32;
|NameSep={{{author-name-separator|,}}}&amp;#32;
|PS={{#if:{{{quote|}}}||{{{postscript|.}}}}}
|Sep={{#ifeq:{{{separator|{{{seperator}}} }}}|;|&amp;#059;|{{{separator|{{{seperator|.}}} }}} }}
|template doc demo={{{template doc demo|}}}
|Trunc={{#if:{{{display-authors|}}}|{{{display-authors}}}|8}}
}}{{#if:{{{access-date|}}}{{{accessdaymonth|}}}{{{accessday|}}}{{{accessmonthday|}}}{{{accessmonth|}}}{{{accessyear|}}}{{{dateformat|}}}{{{day|}}}{{{doilabel|}}}
|[[Mkhakha:Pages containing cite templates with deprecated parameters|{{NAMESPACE}} {{PAGENAME}}]]}}&lt;noinclude&gt;
{{Documentation}}
&lt;/noinclude&gt;</text>
      <sha1>hq6j0fz2uhr1wwbwrn8slrbuw0k0ese</sha1>
    </revision>
    <revision>
      <id>264</id>
      <parentid>263</parentid>
      <timestamp>2024-10-14T13:46:17Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>7 revisions imported</comment>
      <origin>263</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5158" sha1="hq6j0fz2uhr1wwbwrn8slrbuw0k0ese" xml:space="preserve">{{Citation/core
|Citation class=book

|Surname1={{{last|{{{last1|{{{author|{{{author1|{{{authors|{{{surname|{{{surname1|}}}}}}}}}}}}}}}}}}}}}
|Surname2={{{last2|{{{author2|{{{surname2|}}}}}}}}}
|Surname3={{{last3|{{{author3|{{{surname3|}}}}}}}}}
|Surname4={{{last4|{{{author4|{{{surname4|}}}}}}}}}
|Surname5={{{last5|{{{author5|{{{surname5|}}}}}}}}}
|Surname6={{{last6|{{{author6|{{{surname6|}}}}}}}}}
|Surname7={{{last7|{{{author7|{{{surname7|}}}}}}}}}
|Surname8={{{last8|{{{author8|{{{surname8|}}}}}}}}}
|Surname9={{{last9|{{{author9|{{{surname9|}}}}}}}}}

|Given1={{{first|{{{first1|{{{given|{{{given1|}}}}}}}}}}}}
|Given2={{{first2|{{{given2|}}}}}}
|Given3={{{first3|{{{given3|}}}}}}
|Given4={{{first4|{{{given4|}}}}}}
|Given5={{{first5|{{{given5|}}}}}}
|Given6={{{first6|{{{given6|}}}}}}
|Given7={{{first7|{{{given7|}}}}}}
|Given8={{{first8|{{{given8|}}}}}}
|Given9={{{first9|{{{given9|}}}}}}

|Authorlink1={{{authorlink|{{{authorlink1|{{{author-link|{{{author1-link|}}}}}}}}}}}}
|Authorlink2={{{authorlink2|{{{author2-link|}}}}}}
|Authorlink3={{{authorlink3|{{{author3-link|}}}}}}
|Authorlink4={{{authorlink4|{{{author4-link|}}}}}}
|Authorlink5={{{authorlink5|{{{author5-link|}}}}}}
|Authorlink6={{{authorlink6|{{{author6-link|}}}}}}
|Authorlink7={{{authorlink7|{{{author7-link|}}}}}}
|Authorlink8={{{authorlink8|{{{author8-link|}}}}}}
|Authorlink9={{{authorlink9|{{{author9-link|}}}}}}

|Coauthors={{{coauthors|{{{coauthor|}}}}}}

|Other={{{others|}}}

|Year={{{year|{{    &lt;!-- attempt to derive year from date, if possible --&gt;
           #if: {{{date|}}}
           |{{
              #iferror:{{#time:Y|{{{date|}}} }}
              |{{#iferror:{{#time:Y|{{{publication-date|einval}}} }}||{{#time:Y|{{{publication-date|}}} }}}}
              |{{#time:Y|{{{date|}}} }}
            }}
           |{{{publication-date|}}} &lt;!-- last resort --&gt;
         }}
      }}}
|YearNote={{{origyear|}}}
|Date={{#if:{{{date|}}}|{{{date}}}|{{{day|}}} {{{month|}}} {{{year|{{{publication-date|}}}}}}}}

|Title={{{title|}}}
|TransTitle={{{trans_chapter|}}}
|TransItalic={{{trans_title|}}}
|IncludedWorkTitle={{{chapter|{{{contribution|{{{section|}}}}}}}}}
|TitleType={{{type|}}}
|language={{{language|}}}

|URL={{#if:{{{archiveurl|}}}
       |{{#ifeq: {{{deadurl|}}} | no | {{{url|}}} | {{{archiveurl|}}}}}
       |{{{url|}}}
     }}
|IncludedWorkURL={{{chapter-url|{{{chapterurl|{{{contribution-url|{{{sectionurl|}}}}}}}}}}}}
|AccessDate={{{accessdate|}}}
|OriginalURL={{{url|}}}
|ArchiveURL={{{archiveurl|}}}
|ArchiveDate={{{archivedate|}}}
|DeadURL={{{deadurl|}}}
|format={{{format|}}}

|At={{#if: {{{page|}}}|{{#if:{{{nopp|}}}||p.&amp;nbsp;}}{{{page}}}
      |{{#if: {{{pages|}}}|{{#if:{{{nopp|}}}||pp.&amp;nbsp;}}{{{pages}}}
      |{{{at|}}}}}
    }}

|Edition={{{edition|}}}
|Series={{{series|{{{version|}}}}}}
|Volume={{{volume|}}}

|Publisher={{{publisher|}}}
|Place={{{location|{{{place|}}}}}}
|PublicationPlace={{{location|{{{place|{{{publication-place|}}}}}}}}}
|PublicationDate={{{publication-date|}}}

|EditorSurname1={{{editor-last|{{{editor1-last|{{{editor|{{{editors|{{{editor-surname|{{{editor1-surname|}}}}}}}}}}}}}}}}}}
|EditorSurname2={{{editor2-last|{{{editor2-surname|}}}}}}
|EditorSurname3={{{editor3-last|{{{editor3-surname|}}}}}}
|EditorSurname4={{{editor4-last|{{{editor4-surname|}}}}}}
|EditorGiven1={{{editor-first|{{{editor1-first|{{{editor-given|{{{editor1-given|}}}}}}}}}}}}
|EditorGiven2={{{editor2-first|{{{editor2-given|}}}}}}
|EditorGiven3={{{editor3-first|{{{editor3-given|}}}}}}
|EditorGiven4={{{editor4-first|{{{editor4-given|}}}}}}
|Editorlink1={{{editor-link|{{{editor1-link|}}}}}}
|Editorlink2={{{editor2-link|}}}
|Editorlink3={{{editor3-link|}}}
|Editorlink4={{{editor4-link|}}}

|ARXIV={{{arxiv|}}}
|ASIN={{{asin|{{{ASIN|}}}}}}
|ASIN-TLD={{{asin-tld|}}}
|BIBCODE={{{bibcode|}}}
|DOI={{{doi|{{{DOI|}}}}}}
|DoiBroken={{{doi_brokendate|{{{doi_inactivedate|}}}}}}
|ISBN={{{isbn|{{{ISBN|}}}}}}
|ISSN={{{issn|{{{ISSN|}}}}}}
|JFM={{{jfm|{{{JFM|}}}}}}
|JSTOR={{{jstor|{{{JSTOR|}}}}}}
|LCCN={{{lccn|{{{LCCN|}}}}}}
|MR={{{mr|{{{MR|}}}}}}
|OCLC={{{oclc|{{{OCLC|}}}}}}
|OL={{{ol|{{{OL|}}}}}}
|OSTI={{{osti|{{{OSTI|}}}}}}
|PMC={{{pmc|{{{PMC|}}}}}}
|PMID={{{pmid|{{{PMID|}}}}}}
|RFC={{{rfc|{{{RFC|}}}}}}
|SSRN={{{ssrn|{{{SSRN|}}}}}}
|ZBL={{{zbl|}}}
|ID={{{id|{{{ID|}}}}}}

|laysummary={{{laysummary|}}}
|laydate={{{laydate|}}}
|laysource={{{laysource|}}}

|quote={{{quote|}}}

|Ref={{{ref|}}}

|amp={{{lastauthoramp|}}}
|AuthorMask={{{author-mask|{{{authormask|}}}}}}
|AuthorSep={{#ifeq:{{{author-separator|}}}|;|&amp;#059;|{{{author-separator|&amp;#059;}}}}}&amp;#32;
|NameSep={{{author-name-separator|,}}}&amp;#32;
|PS={{#if:{{{quote|}}}||{{{postscript|.}}}}}
|Sep={{#ifeq:{{{separator|{{{seperator}}} }}}|;|&amp;#059;|{{{separator|{{{seperator|.}}} }}} }}
|template doc demo={{{template doc demo|}}}
|Trunc={{#if:{{{display-authors|}}}|{{{display-authors}}}|8}}
}}{{#if:{{{access-date|}}}{{{accessdaymonth|}}}{{{accessday|}}}{{{accessmonthday|}}}{{{accessmonth|}}}{{{accessyear|}}}{{{dateformat|}}}{{{day|}}}{{{doilabel|}}}
|[[Mkhakha:Pages containing cite templates with deprecated parameters|{{NAMESPACE}} {{PAGENAME}}]]}}&lt;noinclude&gt;
{{Documentation}}
&lt;/noinclude&gt;</text>
      <sha1>hq6j0fz2uhr1wwbwrn8slrbuw0k0ese</sha1>
    </revision>
    <revision>
      <id>369</id>
      <parentid>258</parentid>
      <timestamp>2014-09-04T15:53:58Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>#REDIRECT</comment>
      <origin>369</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="45" sha1="nsx40kbil6smj3d2umnradzuk38fd77" xml:space="preserve">#REDIRECT [[Umhlahlandlelasakhiwo:Cite_book]]</text>
      <sha1>nsx40kbil6smj3d2umnradzuk38fd77</sha1>
    </revision>
    <revision>
      <id>370</id>
      <parentid>264</parentid>
      <timestamp>2024-10-14T13:46:25Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>263</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5158" sha1="hq6j0fz2uhr1wwbwrn8slrbuw0k0ese" xml:space="preserve">{{Citation/core
|Citation class=book

|Surname1={{{last|{{{last1|{{{author|{{{author1|{{{authors|{{{surname|{{{surname1|}}}}}}}}}}}}}}}}}}}}}
|Surname2={{{last2|{{{author2|{{{surname2|}}}}}}}}}
|Surname3={{{last3|{{{author3|{{{surname3|}}}}}}}}}
|Surname4={{{last4|{{{author4|{{{surname4|}}}}}}}}}
|Surname5={{{last5|{{{author5|{{{surname5|}}}}}}}}}
|Surname6={{{last6|{{{author6|{{{surname6|}}}}}}}}}
|Surname7={{{last7|{{{author7|{{{surname7|}}}}}}}}}
|Surname8={{{last8|{{{author8|{{{surname8|}}}}}}}}}
|Surname9={{{last9|{{{author9|{{{surname9|}}}}}}}}}

|Given1={{{first|{{{first1|{{{given|{{{given1|}}}}}}}}}}}}
|Given2={{{first2|{{{given2|}}}}}}
|Given3={{{first3|{{{given3|}}}}}}
|Given4={{{first4|{{{given4|}}}}}}
|Given5={{{first5|{{{given5|}}}}}}
|Given6={{{first6|{{{given6|}}}}}}
|Given7={{{first7|{{{given7|}}}}}}
|Given8={{{first8|{{{given8|}}}}}}
|Given9={{{first9|{{{given9|}}}}}}

|Authorlink1={{{authorlink|{{{authorlink1|{{{author-link|{{{author1-link|}}}}}}}}}}}}
|Authorlink2={{{authorlink2|{{{author2-link|}}}}}}
|Authorlink3={{{authorlink3|{{{author3-link|}}}}}}
|Authorlink4={{{authorlink4|{{{author4-link|}}}}}}
|Authorlink5={{{authorlink5|{{{author5-link|}}}}}}
|Authorlink6={{{authorlink6|{{{author6-link|}}}}}}
|Authorlink7={{{authorlink7|{{{author7-link|}}}}}}
|Authorlink8={{{authorlink8|{{{author8-link|}}}}}}
|Authorlink9={{{authorlink9|{{{author9-link|}}}}}}

|Coauthors={{{coauthors|{{{coauthor|}}}}}}

|Other={{{others|}}}

|Year={{{year|{{    &lt;!-- attempt to derive year from date, if possible --&gt;
           #if: {{{date|}}}
           |{{
              #iferror:{{#time:Y|{{{date|}}} }}
              |{{#iferror:{{#time:Y|{{{publication-date|einval}}} }}||{{#time:Y|{{{publication-date|}}} }}}}
              |{{#time:Y|{{{date|}}} }}
            }}
           |{{{publication-date|}}} &lt;!-- last resort --&gt;
         }}
      }}}
|YearNote={{{origyear|}}}
|Date={{#if:{{{date|}}}|{{{date}}}|{{{day|}}} {{{month|}}} {{{year|{{{publication-date|}}}}}}}}

|Title={{{title|}}}
|TransTitle={{{trans_chapter|}}}
|TransItalic={{{trans_title|}}}
|IncludedWorkTitle={{{chapter|{{{contribution|{{{section|}}}}}}}}}
|TitleType={{{type|}}}
|language={{{language|}}}

|URL={{#if:{{{archiveurl|}}}
       |{{#ifeq: {{{deadurl|}}} | no | {{{url|}}} | {{{archiveurl|}}}}}
       |{{{url|}}}
     }}
|IncludedWorkURL={{{chapter-url|{{{chapterurl|{{{contribution-url|{{{sectionurl|}}}}}}}}}}}}
|AccessDate={{{accessdate|}}}
|OriginalURL={{{url|}}}
|ArchiveURL={{{archiveurl|}}}
|ArchiveDate={{{archivedate|}}}
|DeadURL={{{deadurl|}}}
|format={{{format|}}}

|At={{#if: {{{page|}}}|{{#if:{{{nopp|}}}||p.&amp;nbsp;}}{{{page}}}
      |{{#if: {{{pages|}}}|{{#if:{{{nopp|}}}||pp.&amp;nbsp;}}{{{pages}}}
      |{{{at|}}}}}
    }}

|Edition={{{edition|}}}
|Series={{{series|{{{version|}}}}}}
|Volume={{{volume|}}}

|Publisher={{{publisher|}}}
|Place={{{location|{{{place|}}}}}}
|PublicationPlace={{{location|{{{place|{{{publication-place|}}}}}}}}}
|PublicationDate={{{publication-date|}}}

|EditorSurname1={{{editor-last|{{{editor1-last|{{{editor|{{{editors|{{{editor-surname|{{{editor1-surname|}}}}}}}}}}}}}}}}}}
|EditorSurname2={{{editor2-last|{{{editor2-surname|}}}}}}
|EditorSurname3={{{editor3-last|{{{editor3-surname|}}}}}}
|EditorSurname4={{{editor4-last|{{{editor4-surname|}}}}}}
|EditorGiven1={{{editor-first|{{{editor1-first|{{{editor-given|{{{editor1-given|}}}}}}}}}}}}
|EditorGiven2={{{editor2-first|{{{editor2-given|}}}}}}
|EditorGiven3={{{editor3-first|{{{editor3-given|}}}}}}
|EditorGiven4={{{editor4-first|{{{editor4-given|}}}}}}
|Editorlink1={{{editor-link|{{{editor1-link|}}}}}}
|Editorlink2={{{editor2-link|}}}
|Editorlink3={{{editor3-link|}}}
|Editorlink4={{{editor4-link|}}}

|ARXIV={{{arxiv|}}}
|ASIN={{{asin|{{{ASIN|}}}}}}
|ASIN-TLD={{{asin-tld|}}}
|BIBCODE={{{bibcode|}}}
|DOI={{{doi|{{{DOI|}}}}}}
|DoiBroken={{{doi_brokendate|{{{doi_inactivedate|}}}}}}
|ISBN={{{isbn|{{{ISBN|}}}}}}
|ISSN={{{issn|{{{ISSN|}}}}}}
|JFM={{{jfm|{{{JFM|}}}}}}
|JSTOR={{{jstor|{{{JSTOR|}}}}}}
|LCCN={{{lccn|{{{LCCN|}}}}}}
|MR={{{mr|{{{MR|}}}}}}
|OCLC={{{oclc|{{{OCLC|}}}}}}
|OL={{{ol|{{{OL|}}}}}}
|OSTI={{{osti|{{{OSTI|}}}}}}
|PMC={{{pmc|{{{PMC|}}}}}}
|PMID={{{pmid|{{{PMID|}}}}}}
|RFC={{{rfc|{{{RFC|}}}}}}
|SSRN={{{ssrn|{{{SSRN|}}}}}}
|ZBL={{{zbl|}}}
|ID={{{id|{{{ID|}}}}}}

|laysummary={{{laysummary|}}}
|laydate={{{laydate|}}}
|laysource={{{laysource|}}}

|quote={{{quote|}}}

|Ref={{{ref|}}}

|amp={{{lastauthoramp|}}}
|AuthorMask={{{author-mask|{{{authormask|}}}}}}
|AuthorSep={{#ifeq:{{{author-separator|}}}|;|&amp;#059;|{{{author-separator|&amp;#059;}}}}}&amp;#32;
|NameSep={{{author-name-separator|,}}}&amp;#32;
|PS={{#if:{{{quote|}}}||{{{postscript|.}}}}}
|Sep={{#ifeq:{{{separator|{{{seperator}}} }}}|;|&amp;#059;|{{{separator|{{{seperator|.}}} }}} }}
|template doc demo={{{template doc demo|}}}
|Trunc={{#if:{{{display-authors|}}}|{{{display-authors}}}|8}}
}}{{#if:{{{access-date|}}}{{{accessdaymonth|}}}{{{accessday|}}}{{{accessmonthday|}}}{{{accessmonth|}}}{{{accessyear|}}}{{{dateformat|}}}{{{day|}}}{{{doilabel|}}}
|[[Mkhakha:Pages containing cite templates with deprecated parameters|{{NAMESPACE}} {{PAGENAME}}]]}}&lt;noinclude&gt;
{{Documentation}}
&lt;/noinclude&gt;</text>
      <sha1>hq6j0fz2uhr1wwbwrn8slrbuw0k0ese</sha1>
    </revision>
    <revision>
      <id>5043</id>
      <parentid>370</parentid>
      <timestamp>2025-08-07T07:43:12Z</timestamp>
      <contributor>
        <username>Martin Urbanec</username>
        <id>803</id>
      </contributor>
      <comment>actually use the Citation module</comment>
      <origin>5043</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="123" sha1="hq4yscm08hccl43rjw83qi7egacgxec" xml:space="preserve">&lt;includeonly&gt;{{#invoke:citation/CS1|citation
|CitationClass=book
}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>hq4yscm08hccl43rjw83qi7egacgxec</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Cite news</title>
    <ns>10</ns>
    <id>65</id>
    <revision>
      <id>265</id>
      <timestamp>2019-01-13T17:13:50Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;&lt;includeonly&gt;{{#invoke:citation/CS1|citation |CitationClass=news }}&lt;/includeonly&gt;&lt;noinclude&gt; {{documentation}} &lt;/noinclude&gt;&quot;</comment>
      <origin>265</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="123" sha1="pbjnspfej5gxihr9izxrzkow3f1uf3i" xml:space="preserve">&lt;includeonly&gt;{{#invoke:citation/CS1|citation
|CitationClass=news
}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>pbjnspfej5gxihr9izxrzkow3f1uf3i</sha1>
    </revision>
    <revision>
      <id>266</id>
      <parentid>265</parentid>
      <timestamp>2024-10-14T13:46:17Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>265</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="123" sha1="pbjnspfej5gxihr9izxrzkow3f1uf3i" xml:space="preserve">&lt;includeonly&gt;{{#invoke:citation/CS1|citation
|CitationClass=news
}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>pbjnspfej5gxihr9izxrzkow3f1uf3i</sha1>
    </revision>
    <revision>
      <id>371</id>
      <parentid>265</parentid>
      <timestamp>2019-01-13T17:17:48Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;&lt;includeonly&gt;{{#invoke:citation/CS1|citation |CitationClass=news }}&lt;/includeonly&gt;&lt;noinclude&gt; {{documentation}} &lt;/noinclude&gt;&quot;</comment>
      <origin>265</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="123" sha1="pbjnspfej5gxihr9izxrzkow3f1uf3i" xml:space="preserve">&lt;includeonly&gt;{{#invoke:citation/CS1|citation
|CitationClass=news
}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>pbjnspfej5gxihr9izxrzkow3f1uf3i</sha1>
    </revision>
    <revision>
      <id>372</id>
      <parentid>371</parentid>
      <timestamp>2019-01-13T17:26:27Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>265</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="123" sha1="pbjnspfej5gxihr9izxrzkow3f1uf3i" xml:space="preserve">&lt;includeonly&gt;{{#invoke:citation/CS1|citation
|CitationClass=news
}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>pbjnspfej5gxihr9izxrzkow3f1uf3i</sha1>
    </revision>
    <revision>
      <id>373</id>
      <parentid>372</parentid>
      <timestamp>2019-01-13T17:27:06Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Undo revision 4492558 by [[Khethekileko:Contributions/Thuvack|Thuvack]] ([[Umsebenzisi asiqongelane:Thuvack|talk]])</comment>
      <origin>265</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="123" sha1="pbjnspfej5gxihr9izxrzkow3f1uf3i" xml:space="preserve">&lt;includeonly&gt;{{#invoke:citation/CS1|citation
|CitationClass=news
}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>pbjnspfej5gxihr9izxrzkow3f1uf3i</sha1>
    </revision>
    <revision>
      <id>374</id>
      <parentid>266</parentid>
      <timestamp>2024-10-14T13:46:25Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>265</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="123" sha1="pbjnspfej5gxihr9izxrzkow3f1uf3i" xml:space="preserve">&lt;includeonly&gt;{{#invoke:citation/CS1|citation
|CitationClass=news
}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>pbjnspfej5gxihr9izxrzkow3f1uf3i</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Cite web</title>
    <ns>10</ns>
    <id>66</id>
    <revision>
      <id>267</id>
      <timestamp>2014-09-04T15:54:55Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;&lt;includeonly&gt;{{#invoke:citation/CS1|citation |CitationClass=web }}&lt;/includeonly&gt;&lt;noinclude&gt; {{documentation}} &lt;/noinclude&gt;&quot;</comment>
      <origin>267</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="122" sha1="rcgmbcxu7hvs583g1f3rzz4c4dkizda" xml:space="preserve">&lt;includeonly&gt;{{#invoke:citation/CS1|citation
|CitationClass=web
}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>rcgmbcxu7hvs583g1f3rzz4c4dkizda</sha1>
    </revision>
    <revision>
      <id>268</id>
      <parentid>267</parentid>
      <timestamp>2014-09-04T15:56:58Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <origin>268</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="122" sha1="l8qlyq4mftonf046vaolwa9hfyxjyoh" xml:space="preserve">&lt;includeonly&gt;{{#invoke:Citation/CS1|citation
|CitationClass=web
}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>l8qlyq4mftonf046vaolwa9hfyxjyoh</sha1>
    </revision>
    <revision>
      <id>269</id>
      <parentid>268</parentid>
      <timestamp>2014-09-04T15:58:26Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <origin>269</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="122" sha1="owgscoqavbnl7ociswl3io0jdwj8p1s" xml:space="preserve">&lt;includeonly&gt;{{#invoke:Citation/CS1|Citation
|CitationClass=web
}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>owgscoqavbnl7ociswl3io0jdwj8p1s</sha1>
    </revision>
    <revision>
      <id>270</id>
      <parentid>269</parentid>
      <timestamp>2014-09-04T15:59:47Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <origin>270</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="122" sha1="l8qlyq4mftonf046vaolwa9hfyxjyoh" xml:space="preserve">&lt;includeonly&gt;{{#invoke:Citation/CS1|citation
|CitationClass=web
}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>l8qlyq4mftonf046vaolwa9hfyxjyoh</sha1>
    </revision>
    <revision>
      <id>271</id>
      <parentid>270</parentid>
      <timestamp>2014-09-04T16:10:51Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>Old from [[:en:Template:Cite web]]</comment>
      <origin>271</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5197" sha1="belaiv8mhopefyuklxknbie9h2upxbe" xml:space="preserve">&lt;includeonly&gt;{{Citation/core
|Citation class=web

|Surname1={{{last|{{{last1|{{{author|{{{author1|{{{authors|{{{surname|{{{surname1|}}}}}}}}}}}}}}}}}}}}}
|Surname2={{{last2|{{{author2|{{{surname2|}}}}}}}}}
|Surname3={{{last3|{{{author3|{{{surname3|}}}}}}}}}
|Surname4={{{last4|{{{author4|{{{surname4|}}}}}}}}}
|Surname5={{{last5|{{{author5|{{{surname5|}}}}}}}}}
|Surname6={{{last6|{{{author6|{{{surname6|}}}}}}}}}
|Surname7={{{last7|{{{author7|{{{surname7|}}}}}}}}}
|Surname8={{{last8|{{{author8|{{{surname8|}}}}}}}}}
|Surname9={{{last9|{{{author9|{{{surname9|}}}}}}}}}

|Given1={{{first|{{{first1|{{{given|{{{given1|}}}}}}}}}}}}
|Given2={{{first2|{{{given2|}}}}}}
|Given3={{{first3|{{{given3|}}}}}}
|Given4={{{first4|{{{given4|}}}}}}
|Given5={{{first5|{{{given5|}}}}}}
|Given6={{{first6|{{{given6|}}}}}}
|Given7={{{first7|{{{given7|}}}}}}
|Given8={{{first8|{{{given8|}}}}}}
|Given9={{{first9|{{{given9|}}}}}}

|Authorlink1={{{authorlink|{{{authorlink1|{{{author-link|{{{author1-link|}}}}}}}}}}}}
|Authorlink2={{{authorlink2|{{{author2-link|}}}}}}
|Authorlink3={{{authorlink3|{{{author3-link|}}}}}}
|Authorlink4={{{authorlink4|{{{author4-link|}}}}}}
|Authorlink5={{{authorlink5|{{{author5-link|}}}}}}
|Authorlink6={{{authorlink6|{{{author6-link|}}}}}}
|Authorlink7={{{authorlink7|{{{author7-link|}}}}}}
|Authorlink8={{{authorlink8|{{{author8-link|}}}}}}
|Authorlink9={{{authorlink9|{{{author9-link|}}}}}}

|Coauthors={{{coauthors|{{{coauthor|}}}}}}

|Other={{{others|}}}

|Year={{{year|{{    &lt;!-- attempt to derive year from date, if possible --&gt;
           #if: {{{date|}}}
           |{{
              #iferror:{{#time:Y|{{{date|}}} }}
              |{{#iferror:{{#time:Y|{{{publication-date|einval}}} }}||{{#time:Y|{{{publication-date|}}} }}}}
              |{{#time:Y|{{{date|}}} }}
            }}
           |{{{publication-date|}}} &lt;!-- last resort --&gt;
         }}
      }}}
|YearNote={{{origyear|}}}
|Date={{#if:{{{date|}}}|{{{date}}}|{{{day|}}} {{{month|}}} {{{year|{{{publication-date|}}}}}}}}

|Title={{{work|}}}
|IncludedWorkTitle={{
  #if:{{{title|}}}
  |{{{title}}}
  |{{
    #if:{{{trans_title|}}}
    |
    |{{citation error|nocat={{{template doc demo|}}}|no &lt;code&gt;&amp;#124;title&amp;#61;&lt;/code&gt; specified|Cite web}}
    }}
  }}
|TransTitle={{{trans_title|}}}
|TitleType={{{type|}}}
|language={{{language|}}}

|IncludedWorkURL={{#if:{{{archiveurl|}}}
       |{{#ifeq: {{{deadurl|}}} | no | {{{url|}}} | {{{archiveurl|}}}}}
       |{{{url|}}}
     }}
|AccessDate={{{accessdate|}}}
|OriginalURL={{{url|}}}
|ArchiveURL={{{archiveurl|}}}
|ArchiveDate={{{archivedate|}}}
|DeadURL={{{deadurl|}}}
|format={{{format|}}}

|At={{#if: {{{page|}}}|{{#if:{{{nopp|}}}||p.&amp;nbsp;}}{{{page}}}
      |{{#if: {{{pages|}}}|{{#if:{{{nopp|}}}||pp.&amp;nbsp;}}{{{pages}}}
      |{{{at|}}}}}
    }}

|Series={{{agency|{{{series|{{{version|}}}}}}}}}

|Publisher={{{publisher|}}}
|Place={{{location|{{{place|}}}}}}
|PublicationPlace={{{location|{{{place|{{{publication-place|}}}}}}}}}
|PublicationDate={{{publication-date|}}}

|EditorSurname1={{{editor-last|{{{editor1-last|{{{editor|{{{editors|{{{editor-surname|{{{editor1-surname|}}}}}}}}}}}}}}}}}}
|EditorSurname2={{{editor2-last|{{{editor2-surname|}}}}}}
|EditorSurname3={{{editor3-last|{{{editor3-surname|}}}}}}
|EditorSurname4={{{editor4-last|{{{editor4-surname|}}}}}}
|EditorGiven1={{{editor-first|{{{editor1-first|{{{editor-given|{{{editor1-given|}}}}}}}}}}}}
|EditorGiven2={{{editor2-first|{{{editor2-given|}}}}}}
|EditorGiven3={{{editor3-first|{{{editor3-given|}}}}}}
|EditorGiven4={{{editor4-first|{{{editor4-given|}}}}}}
|Editorlink1={{{editor-link|{{{editor1-link|}}}}}}
|Editorlink2={{{editor2-link|}}}
|Editorlink3={{{editor3-link|}}}
|Editorlink4={{{editor4-link|}}}

|ARXIV={{{arxiv|}}}
|ASIN={{{asin|{{{ASIN|}}}}}}
|ASIN-TLD={{{asin-tld|}}}
|BIBCODE={{{bibcode|}}}
|DOI={{{doi|{{{DOI|}}}}}}
|DoiBroken={{{doi_brokendate|{{{doi_inactivedate|}}}}}}
|ISBN={{{isbn|{{{ISBN|}}}}}}
|ISSN={{{issn|{{{ISSN|}}}}}}
|JFM={{{jfm|{{{JFM|}}}}}}
|JSTOR={{{jstor|{{{JSTOR|}}}}}}
|LCCN={{{lccn|{{{LCCN|}}}}}}
|MR={{{mr|{{{MR|}}}}}}
|OCLC={{{oclc|{{{OCLC|}}}}}}
|OL={{{ol|{{{OL|}}}}}}
|OSTI={{{osti|{{{OSTI|}}}}}}
|PMC={{{pmc|{{{PMC|}}}}}}
|PMID={{{pmid|{{{PMID|}}}}}}
|RFC={{{rfc|{{{RFC|}}}}}}
|SSRN={{{ssrn|{{{SSRN|}}}}}}
|ZBL={{{zbl|}}}
|ID={{{id|{{{ID|}}}}}}

|laysummary={{{laysummary|}}}
|laydate={{{laydate|}}}
|laysource={{{laysource|}}}

|quote={{{quote|}}}

|Ref={{{ref|}}}

|amp={{{lastauthoramp|}}}
|AuthorMask={{{author-mask|{{{authormask|}}}}}}
|AuthorSep={{#ifeq:{{{author-separator|}}}|;|&amp;#059;|{{{author-separator|&amp;#059;}}}}}&amp;#32;
|NameSep={{{author-name-separator|,}}}&amp;#32;
|PS={{#if:{{{quote|}}}||{{{postscript|.}}}}}
|Sep={{#ifeq:{{{separator|{{{seperator}}} }}}|;|&amp;#059;|{{{separator|{{{seperator|.}}} }}} }}
|template doc demo={{{template doc demo|}}}
|Trunc={{#if:{{{display-authors|}}}|{{{display-authors}}}|8}}
}}{{#if:{{{access-date|}}}{{{accessdaymonth|}}}{{{accessday|}}}{{{accessmonthday|}}}{{{accessed|}}}{{{accessmonth|}}}{{{accessyear|}}}{{{dateformat|}}}{{{day|}}}{{{doilabel|}}}
|[[Mkhakha:Pages containing cite templates with deprecated parameters|{{NAMESPACE}} {{PAGENAME}}]]}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>belaiv8mhopefyuklxknbie9h2upxbe</sha1>
    </revision>
    <revision>
      <id>272</id>
      <parentid>271</parentid>
      <timestamp>2014-09-04T16:11:22Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <origin>271</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5197" sha1="belaiv8mhopefyuklxknbie9h2upxbe" xml:space="preserve">&lt;includeonly&gt;{{Citation/core
|Citation class=web

|Surname1={{{last|{{{last1|{{{author|{{{author1|{{{authors|{{{surname|{{{surname1|}}}}}}}}}}}}}}}}}}}}}
|Surname2={{{last2|{{{author2|{{{surname2|}}}}}}}}}
|Surname3={{{last3|{{{author3|{{{surname3|}}}}}}}}}
|Surname4={{{last4|{{{author4|{{{surname4|}}}}}}}}}
|Surname5={{{last5|{{{author5|{{{surname5|}}}}}}}}}
|Surname6={{{last6|{{{author6|{{{surname6|}}}}}}}}}
|Surname7={{{last7|{{{author7|{{{surname7|}}}}}}}}}
|Surname8={{{last8|{{{author8|{{{surname8|}}}}}}}}}
|Surname9={{{last9|{{{author9|{{{surname9|}}}}}}}}}

|Given1={{{first|{{{first1|{{{given|{{{given1|}}}}}}}}}}}}
|Given2={{{first2|{{{given2|}}}}}}
|Given3={{{first3|{{{given3|}}}}}}
|Given4={{{first4|{{{given4|}}}}}}
|Given5={{{first5|{{{given5|}}}}}}
|Given6={{{first6|{{{given6|}}}}}}
|Given7={{{first7|{{{given7|}}}}}}
|Given8={{{first8|{{{given8|}}}}}}
|Given9={{{first9|{{{given9|}}}}}}

|Authorlink1={{{authorlink|{{{authorlink1|{{{author-link|{{{author1-link|}}}}}}}}}}}}
|Authorlink2={{{authorlink2|{{{author2-link|}}}}}}
|Authorlink3={{{authorlink3|{{{author3-link|}}}}}}
|Authorlink4={{{authorlink4|{{{author4-link|}}}}}}
|Authorlink5={{{authorlink5|{{{author5-link|}}}}}}
|Authorlink6={{{authorlink6|{{{author6-link|}}}}}}
|Authorlink7={{{authorlink7|{{{author7-link|}}}}}}
|Authorlink8={{{authorlink8|{{{author8-link|}}}}}}
|Authorlink9={{{authorlink9|{{{author9-link|}}}}}}

|Coauthors={{{coauthors|{{{coauthor|}}}}}}

|Other={{{others|}}}

|Year={{{year|{{    &lt;!-- attempt to derive year from date, if possible --&gt;
           #if: {{{date|}}}
           |{{
              #iferror:{{#time:Y|{{{date|}}} }}
              |{{#iferror:{{#time:Y|{{{publication-date|einval}}} }}||{{#time:Y|{{{publication-date|}}} }}}}
              |{{#time:Y|{{{date|}}} }}
            }}
           |{{{publication-date|}}} &lt;!-- last resort --&gt;
         }}
      }}}
|YearNote={{{origyear|}}}
|Date={{#if:{{{date|}}}|{{{date}}}|{{{day|}}} {{{month|}}} {{{year|{{{publication-date|}}}}}}}}

|Title={{{work|}}}
|IncludedWorkTitle={{
  #if:{{{title|}}}
  |{{{title}}}
  |{{
    #if:{{{trans_title|}}}
    |
    |{{citation error|nocat={{{template doc demo|}}}|no &lt;code&gt;&amp;#124;title&amp;#61;&lt;/code&gt; specified|Cite web}}
    }}
  }}
|TransTitle={{{trans_title|}}}
|TitleType={{{type|}}}
|language={{{language|}}}

|IncludedWorkURL={{#if:{{{archiveurl|}}}
       |{{#ifeq: {{{deadurl|}}} | no | {{{url|}}} | {{{archiveurl|}}}}}
       |{{{url|}}}
     }}
|AccessDate={{{accessdate|}}}
|OriginalURL={{{url|}}}
|ArchiveURL={{{archiveurl|}}}
|ArchiveDate={{{archivedate|}}}
|DeadURL={{{deadurl|}}}
|format={{{format|}}}

|At={{#if: {{{page|}}}|{{#if:{{{nopp|}}}||p.&amp;nbsp;}}{{{page}}}
      |{{#if: {{{pages|}}}|{{#if:{{{nopp|}}}||pp.&amp;nbsp;}}{{{pages}}}
      |{{{at|}}}}}
    }}

|Series={{{agency|{{{series|{{{version|}}}}}}}}}

|Publisher={{{publisher|}}}
|Place={{{location|{{{place|}}}}}}
|PublicationPlace={{{location|{{{place|{{{publication-place|}}}}}}}}}
|PublicationDate={{{publication-date|}}}

|EditorSurname1={{{editor-last|{{{editor1-last|{{{editor|{{{editors|{{{editor-surname|{{{editor1-surname|}}}}}}}}}}}}}}}}}}
|EditorSurname2={{{editor2-last|{{{editor2-surname|}}}}}}
|EditorSurname3={{{editor3-last|{{{editor3-surname|}}}}}}
|EditorSurname4={{{editor4-last|{{{editor4-surname|}}}}}}
|EditorGiven1={{{editor-first|{{{editor1-first|{{{editor-given|{{{editor1-given|}}}}}}}}}}}}
|EditorGiven2={{{editor2-first|{{{editor2-given|}}}}}}
|EditorGiven3={{{editor3-first|{{{editor3-given|}}}}}}
|EditorGiven4={{{editor4-first|{{{editor4-given|}}}}}}
|Editorlink1={{{editor-link|{{{editor1-link|}}}}}}
|Editorlink2={{{editor2-link|}}}
|Editorlink3={{{editor3-link|}}}
|Editorlink4={{{editor4-link|}}}

|ARXIV={{{arxiv|}}}
|ASIN={{{asin|{{{ASIN|}}}}}}
|ASIN-TLD={{{asin-tld|}}}
|BIBCODE={{{bibcode|}}}
|DOI={{{doi|{{{DOI|}}}}}}
|DoiBroken={{{doi_brokendate|{{{doi_inactivedate|}}}}}}
|ISBN={{{isbn|{{{ISBN|}}}}}}
|ISSN={{{issn|{{{ISSN|}}}}}}
|JFM={{{jfm|{{{JFM|}}}}}}
|JSTOR={{{jstor|{{{JSTOR|}}}}}}
|LCCN={{{lccn|{{{LCCN|}}}}}}
|MR={{{mr|{{{MR|}}}}}}
|OCLC={{{oclc|{{{OCLC|}}}}}}
|OL={{{ol|{{{OL|}}}}}}
|OSTI={{{osti|{{{OSTI|}}}}}}
|PMC={{{pmc|{{{PMC|}}}}}}
|PMID={{{pmid|{{{PMID|}}}}}}
|RFC={{{rfc|{{{RFC|}}}}}}
|SSRN={{{ssrn|{{{SSRN|}}}}}}
|ZBL={{{zbl|}}}
|ID={{{id|{{{ID|}}}}}}

|laysummary={{{laysummary|}}}
|laydate={{{laydate|}}}
|laysource={{{laysource|}}}

|quote={{{quote|}}}

|Ref={{{ref|}}}

|amp={{{lastauthoramp|}}}
|AuthorMask={{{author-mask|{{{authormask|}}}}}}
|AuthorSep={{#ifeq:{{{author-separator|}}}|;|&amp;#059;|{{{author-separator|&amp;#059;}}}}}&amp;#32;
|NameSep={{{author-name-separator|,}}}&amp;#32;
|PS={{#if:{{{quote|}}}||{{{postscript|.}}}}}
|Sep={{#ifeq:{{{separator|{{{seperator}}} }}}|;|&amp;#059;|{{{separator|{{{seperator|.}}} }}} }}
|template doc demo={{{template doc demo|}}}
|Trunc={{#if:{{{display-authors|}}}|{{{display-authors}}}|8}}
}}{{#if:{{{access-date|}}}{{{accessdaymonth|}}}{{{accessday|}}}{{{accessmonthday|}}}{{{accessed|}}}{{{accessmonth|}}}{{{accessyear|}}}{{{dateformat|}}}{{{day|}}}{{{doilabel|}}}
|[[Mkhakha:Pages containing cite templates with deprecated parameters|{{NAMESPACE}} {{PAGENAME}}]]}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>belaiv8mhopefyuklxknbie9h2upxbe</sha1>
    </revision>
    <revision>
      <id>273</id>
      <parentid>272</parentid>
      <timestamp>2019-01-13T17:18:45Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>271</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5197" sha1="belaiv8mhopefyuklxknbie9h2upxbe" xml:space="preserve">&lt;includeonly&gt;{{Citation/core
|Citation class=web

|Surname1={{{last|{{{last1|{{{author|{{{author1|{{{authors|{{{surname|{{{surname1|}}}}}}}}}}}}}}}}}}}}}
|Surname2={{{last2|{{{author2|{{{surname2|}}}}}}}}}
|Surname3={{{last3|{{{author3|{{{surname3|}}}}}}}}}
|Surname4={{{last4|{{{author4|{{{surname4|}}}}}}}}}
|Surname5={{{last5|{{{author5|{{{surname5|}}}}}}}}}
|Surname6={{{last6|{{{author6|{{{surname6|}}}}}}}}}
|Surname7={{{last7|{{{author7|{{{surname7|}}}}}}}}}
|Surname8={{{last8|{{{author8|{{{surname8|}}}}}}}}}
|Surname9={{{last9|{{{author9|{{{surname9|}}}}}}}}}

|Given1={{{first|{{{first1|{{{given|{{{given1|}}}}}}}}}}}}
|Given2={{{first2|{{{given2|}}}}}}
|Given3={{{first3|{{{given3|}}}}}}
|Given4={{{first4|{{{given4|}}}}}}
|Given5={{{first5|{{{given5|}}}}}}
|Given6={{{first6|{{{given6|}}}}}}
|Given7={{{first7|{{{given7|}}}}}}
|Given8={{{first8|{{{given8|}}}}}}
|Given9={{{first9|{{{given9|}}}}}}

|Authorlink1={{{authorlink|{{{authorlink1|{{{author-link|{{{author1-link|}}}}}}}}}}}}
|Authorlink2={{{authorlink2|{{{author2-link|}}}}}}
|Authorlink3={{{authorlink3|{{{author3-link|}}}}}}
|Authorlink4={{{authorlink4|{{{author4-link|}}}}}}
|Authorlink5={{{authorlink5|{{{author5-link|}}}}}}
|Authorlink6={{{authorlink6|{{{author6-link|}}}}}}
|Authorlink7={{{authorlink7|{{{author7-link|}}}}}}
|Authorlink8={{{authorlink8|{{{author8-link|}}}}}}
|Authorlink9={{{authorlink9|{{{author9-link|}}}}}}

|Coauthors={{{coauthors|{{{coauthor|}}}}}}

|Other={{{others|}}}

|Year={{{year|{{    &lt;!-- attempt to derive year from date, if possible --&gt;
           #if: {{{date|}}}
           |{{
              #iferror:{{#time:Y|{{{date|}}} }}
              |{{#iferror:{{#time:Y|{{{publication-date|einval}}} }}||{{#time:Y|{{{publication-date|}}} }}}}
              |{{#time:Y|{{{date|}}} }}
            }}
           |{{{publication-date|}}} &lt;!-- last resort --&gt;
         }}
      }}}
|YearNote={{{origyear|}}}
|Date={{#if:{{{date|}}}|{{{date}}}|{{{day|}}} {{{month|}}} {{{year|{{{publication-date|}}}}}}}}

|Title={{{work|}}}
|IncludedWorkTitle={{
  #if:{{{title|}}}
  |{{{title}}}
  |{{
    #if:{{{trans_title|}}}
    |
    |{{citation error|nocat={{{template doc demo|}}}|no &lt;code&gt;&amp;#124;title&amp;#61;&lt;/code&gt; specified|Cite web}}
    }}
  }}
|TransTitle={{{trans_title|}}}
|TitleType={{{type|}}}
|language={{{language|}}}

|IncludedWorkURL={{#if:{{{archiveurl|}}}
       |{{#ifeq: {{{deadurl|}}} | no | {{{url|}}} | {{{archiveurl|}}}}}
       |{{{url|}}}
     }}
|AccessDate={{{accessdate|}}}
|OriginalURL={{{url|}}}
|ArchiveURL={{{archiveurl|}}}
|ArchiveDate={{{archivedate|}}}
|DeadURL={{{deadurl|}}}
|format={{{format|}}}

|At={{#if: {{{page|}}}|{{#if:{{{nopp|}}}||p.&amp;nbsp;}}{{{page}}}
      |{{#if: {{{pages|}}}|{{#if:{{{nopp|}}}||pp.&amp;nbsp;}}{{{pages}}}
      |{{{at|}}}}}
    }}

|Series={{{agency|{{{series|{{{version|}}}}}}}}}

|Publisher={{{publisher|}}}
|Place={{{location|{{{place|}}}}}}
|PublicationPlace={{{location|{{{place|{{{publication-place|}}}}}}}}}
|PublicationDate={{{publication-date|}}}

|EditorSurname1={{{editor-last|{{{editor1-last|{{{editor|{{{editors|{{{editor-surname|{{{editor1-surname|}}}}}}}}}}}}}}}}}}
|EditorSurname2={{{editor2-last|{{{editor2-surname|}}}}}}
|EditorSurname3={{{editor3-last|{{{editor3-surname|}}}}}}
|EditorSurname4={{{editor4-last|{{{editor4-surname|}}}}}}
|EditorGiven1={{{editor-first|{{{editor1-first|{{{editor-given|{{{editor1-given|}}}}}}}}}}}}
|EditorGiven2={{{editor2-first|{{{editor2-given|}}}}}}
|EditorGiven3={{{editor3-first|{{{editor3-given|}}}}}}
|EditorGiven4={{{editor4-first|{{{editor4-given|}}}}}}
|Editorlink1={{{editor-link|{{{editor1-link|}}}}}}
|Editorlink2={{{editor2-link|}}}
|Editorlink3={{{editor3-link|}}}
|Editorlink4={{{editor4-link|}}}

|ARXIV={{{arxiv|}}}
|ASIN={{{asin|{{{ASIN|}}}}}}
|ASIN-TLD={{{asin-tld|}}}
|BIBCODE={{{bibcode|}}}
|DOI={{{doi|{{{DOI|}}}}}}
|DoiBroken={{{doi_brokendate|{{{doi_inactivedate|}}}}}}
|ISBN={{{isbn|{{{ISBN|}}}}}}
|ISSN={{{issn|{{{ISSN|}}}}}}
|JFM={{{jfm|{{{JFM|}}}}}}
|JSTOR={{{jstor|{{{JSTOR|}}}}}}
|LCCN={{{lccn|{{{LCCN|}}}}}}
|MR={{{mr|{{{MR|}}}}}}
|OCLC={{{oclc|{{{OCLC|}}}}}}
|OL={{{ol|{{{OL|}}}}}}
|OSTI={{{osti|{{{OSTI|}}}}}}
|PMC={{{pmc|{{{PMC|}}}}}}
|PMID={{{pmid|{{{PMID|}}}}}}
|RFC={{{rfc|{{{RFC|}}}}}}
|SSRN={{{ssrn|{{{SSRN|}}}}}}
|ZBL={{{zbl|}}}
|ID={{{id|{{{ID|}}}}}}

|laysummary={{{laysummary|}}}
|laydate={{{laydate|}}}
|laysource={{{laysource|}}}

|quote={{{quote|}}}

|Ref={{{ref|}}}

|amp={{{lastauthoramp|}}}
|AuthorMask={{{author-mask|{{{authormask|}}}}}}
|AuthorSep={{#ifeq:{{{author-separator|}}}|;|&amp;#059;|{{{author-separator|&amp;#059;}}}}}&amp;#32;
|NameSep={{{author-name-separator|,}}}&amp;#32;
|PS={{#if:{{{quote|}}}||{{{postscript|.}}}}}
|Sep={{#ifeq:{{{separator|{{{seperator}}} }}}|;|&amp;#059;|{{{separator|{{{seperator|.}}} }}} }}
|template doc demo={{{template doc demo|}}}
|Trunc={{#if:{{{display-authors|}}}|{{{display-authors}}}|8}}
}}{{#if:{{{access-date|}}}{{{accessdaymonth|}}}{{{accessday|}}}{{{accessmonthday|}}}{{{accessed|}}}{{{accessmonth|}}}{{{accessyear|}}}{{{dateformat|}}}{{{day|}}}{{{doilabel|}}}
|[[Mkhakha:Pages containing cite templates with deprecated parameters|{{NAMESPACE}} {{PAGENAME}}]]}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>belaiv8mhopefyuklxknbie9h2upxbe</sha1>
    </revision>
    <revision>
      <id>274</id>
      <parentid>273</parentid>
      <timestamp>2024-10-14T13:46:17Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>7 revisions imported</comment>
      <origin>271</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5197" sha1="belaiv8mhopefyuklxknbie9h2upxbe" xml:space="preserve">&lt;includeonly&gt;{{Citation/core
|Citation class=web

|Surname1={{{last|{{{last1|{{{author|{{{author1|{{{authors|{{{surname|{{{surname1|}}}}}}}}}}}}}}}}}}}}}
|Surname2={{{last2|{{{author2|{{{surname2|}}}}}}}}}
|Surname3={{{last3|{{{author3|{{{surname3|}}}}}}}}}
|Surname4={{{last4|{{{author4|{{{surname4|}}}}}}}}}
|Surname5={{{last5|{{{author5|{{{surname5|}}}}}}}}}
|Surname6={{{last6|{{{author6|{{{surname6|}}}}}}}}}
|Surname7={{{last7|{{{author7|{{{surname7|}}}}}}}}}
|Surname8={{{last8|{{{author8|{{{surname8|}}}}}}}}}
|Surname9={{{last9|{{{author9|{{{surname9|}}}}}}}}}

|Given1={{{first|{{{first1|{{{given|{{{given1|}}}}}}}}}}}}
|Given2={{{first2|{{{given2|}}}}}}
|Given3={{{first3|{{{given3|}}}}}}
|Given4={{{first4|{{{given4|}}}}}}
|Given5={{{first5|{{{given5|}}}}}}
|Given6={{{first6|{{{given6|}}}}}}
|Given7={{{first7|{{{given7|}}}}}}
|Given8={{{first8|{{{given8|}}}}}}
|Given9={{{first9|{{{given9|}}}}}}

|Authorlink1={{{authorlink|{{{authorlink1|{{{author-link|{{{author1-link|}}}}}}}}}}}}
|Authorlink2={{{authorlink2|{{{author2-link|}}}}}}
|Authorlink3={{{authorlink3|{{{author3-link|}}}}}}
|Authorlink4={{{authorlink4|{{{author4-link|}}}}}}
|Authorlink5={{{authorlink5|{{{author5-link|}}}}}}
|Authorlink6={{{authorlink6|{{{author6-link|}}}}}}
|Authorlink7={{{authorlink7|{{{author7-link|}}}}}}
|Authorlink8={{{authorlink8|{{{author8-link|}}}}}}
|Authorlink9={{{authorlink9|{{{author9-link|}}}}}}

|Coauthors={{{coauthors|{{{coauthor|}}}}}}

|Other={{{others|}}}

|Year={{{year|{{    &lt;!-- attempt to derive year from date, if possible --&gt;
           #if: {{{date|}}}
           |{{
              #iferror:{{#time:Y|{{{date|}}} }}
              |{{#iferror:{{#time:Y|{{{publication-date|einval}}} }}||{{#time:Y|{{{publication-date|}}} }}}}
              |{{#time:Y|{{{date|}}} }}
            }}
           |{{{publication-date|}}} &lt;!-- last resort --&gt;
         }}
      }}}
|YearNote={{{origyear|}}}
|Date={{#if:{{{date|}}}|{{{date}}}|{{{day|}}} {{{month|}}} {{{year|{{{publication-date|}}}}}}}}

|Title={{{work|}}}
|IncludedWorkTitle={{
  #if:{{{title|}}}
  |{{{title}}}
  |{{
    #if:{{{trans_title|}}}
    |
    |{{citation error|nocat={{{template doc demo|}}}|no &lt;code&gt;&amp;#124;title&amp;#61;&lt;/code&gt; specified|Cite web}}
    }}
  }}
|TransTitle={{{trans_title|}}}
|TitleType={{{type|}}}
|language={{{language|}}}

|IncludedWorkURL={{#if:{{{archiveurl|}}}
       |{{#ifeq: {{{deadurl|}}} | no | {{{url|}}} | {{{archiveurl|}}}}}
       |{{{url|}}}
     }}
|AccessDate={{{accessdate|}}}
|OriginalURL={{{url|}}}
|ArchiveURL={{{archiveurl|}}}
|ArchiveDate={{{archivedate|}}}
|DeadURL={{{deadurl|}}}
|format={{{format|}}}

|At={{#if: {{{page|}}}|{{#if:{{{nopp|}}}||p.&amp;nbsp;}}{{{page}}}
      |{{#if: {{{pages|}}}|{{#if:{{{nopp|}}}||pp.&amp;nbsp;}}{{{pages}}}
      |{{{at|}}}}}
    }}

|Series={{{agency|{{{series|{{{version|}}}}}}}}}

|Publisher={{{publisher|}}}
|Place={{{location|{{{place|}}}}}}
|PublicationPlace={{{location|{{{place|{{{publication-place|}}}}}}}}}
|PublicationDate={{{publication-date|}}}

|EditorSurname1={{{editor-last|{{{editor1-last|{{{editor|{{{editors|{{{editor-surname|{{{editor1-surname|}}}}}}}}}}}}}}}}}}
|EditorSurname2={{{editor2-last|{{{editor2-surname|}}}}}}
|EditorSurname3={{{editor3-last|{{{editor3-surname|}}}}}}
|EditorSurname4={{{editor4-last|{{{editor4-surname|}}}}}}
|EditorGiven1={{{editor-first|{{{editor1-first|{{{editor-given|{{{editor1-given|}}}}}}}}}}}}
|EditorGiven2={{{editor2-first|{{{editor2-given|}}}}}}
|EditorGiven3={{{editor3-first|{{{editor3-given|}}}}}}
|EditorGiven4={{{editor4-first|{{{editor4-given|}}}}}}
|Editorlink1={{{editor-link|{{{editor1-link|}}}}}}
|Editorlink2={{{editor2-link|}}}
|Editorlink3={{{editor3-link|}}}
|Editorlink4={{{editor4-link|}}}

|ARXIV={{{arxiv|}}}
|ASIN={{{asin|{{{ASIN|}}}}}}
|ASIN-TLD={{{asin-tld|}}}
|BIBCODE={{{bibcode|}}}
|DOI={{{doi|{{{DOI|}}}}}}
|DoiBroken={{{doi_brokendate|{{{doi_inactivedate|}}}}}}
|ISBN={{{isbn|{{{ISBN|}}}}}}
|ISSN={{{issn|{{{ISSN|}}}}}}
|JFM={{{jfm|{{{JFM|}}}}}}
|JSTOR={{{jstor|{{{JSTOR|}}}}}}
|LCCN={{{lccn|{{{LCCN|}}}}}}
|MR={{{mr|{{{MR|}}}}}}
|OCLC={{{oclc|{{{OCLC|}}}}}}
|OL={{{ol|{{{OL|}}}}}}
|OSTI={{{osti|{{{OSTI|}}}}}}
|PMC={{{pmc|{{{PMC|}}}}}}
|PMID={{{pmid|{{{PMID|}}}}}}
|RFC={{{rfc|{{{RFC|}}}}}}
|SSRN={{{ssrn|{{{SSRN|}}}}}}
|ZBL={{{zbl|}}}
|ID={{{id|{{{ID|}}}}}}

|laysummary={{{laysummary|}}}
|laydate={{{laydate|}}}
|laysource={{{laysource|}}}

|quote={{{quote|}}}

|Ref={{{ref|}}}

|amp={{{lastauthoramp|}}}
|AuthorMask={{{author-mask|{{{authormask|}}}}}}
|AuthorSep={{#ifeq:{{{author-separator|}}}|;|&amp;#059;|{{{author-separator|&amp;#059;}}}}}&amp;#32;
|NameSep={{{author-name-separator|,}}}&amp;#32;
|PS={{#if:{{{quote|}}}||{{{postscript|.}}}}}
|Sep={{#ifeq:{{{separator|{{{seperator}}} }}}|;|&amp;#059;|{{{separator|{{{seperator|.}}} }}} }}
|template doc demo={{{template doc demo|}}}
|Trunc={{#if:{{{display-authors|}}}|{{{display-authors}}}|8}}
}}{{#if:{{{access-date|}}}{{{accessdaymonth|}}}{{{accessday|}}}{{{accessmonthday|}}}{{{accessed|}}}{{{accessmonth|}}}{{{accessyear|}}}{{{dateformat|}}}{{{day|}}}{{{doilabel|}}}
|[[Mkhakha:Pages containing cite templates with deprecated parameters|{{NAMESPACE}} {{PAGENAME}}]]}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>belaiv8mhopefyuklxknbie9h2upxbe</sha1>
    </revision>
    <revision>
      <id>375</id>
      <timestamp>2014-09-04T15:54:20Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>Redirected page to [[Umhlahlandlelasakhiwo:Cite web]]</comment>
      <origin>375</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="44" sha1="lstol8f04e97ouiuibj8pxnhs525tj2" xml:space="preserve">#REDIRECT [[Umhlahlandlelasakhiwo:Cite_web]]</text>
      <sha1>lstol8f04e97ouiuibj8pxnhs525tj2</sha1>
    </revision>
    <revision>
      <id>376</id>
      <parentid>274</parentid>
      <timestamp>2024-10-14T13:46:25Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>271</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5197" sha1="belaiv8mhopefyuklxknbie9h2upxbe" xml:space="preserve">&lt;includeonly&gt;{{Citation/core
|Citation class=web

|Surname1={{{last|{{{last1|{{{author|{{{author1|{{{authors|{{{surname|{{{surname1|}}}}}}}}}}}}}}}}}}}}}
|Surname2={{{last2|{{{author2|{{{surname2|}}}}}}}}}
|Surname3={{{last3|{{{author3|{{{surname3|}}}}}}}}}
|Surname4={{{last4|{{{author4|{{{surname4|}}}}}}}}}
|Surname5={{{last5|{{{author5|{{{surname5|}}}}}}}}}
|Surname6={{{last6|{{{author6|{{{surname6|}}}}}}}}}
|Surname7={{{last7|{{{author7|{{{surname7|}}}}}}}}}
|Surname8={{{last8|{{{author8|{{{surname8|}}}}}}}}}
|Surname9={{{last9|{{{author9|{{{surname9|}}}}}}}}}

|Given1={{{first|{{{first1|{{{given|{{{given1|}}}}}}}}}}}}
|Given2={{{first2|{{{given2|}}}}}}
|Given3={{{first3|{{{given3|}}}}}}
|Given4={{{first4|{{{given4|}}}}}}
|Given5={{{first5|{{{given5|}}}}}}
|Given6={{{first6|{{{given6|}}}}}}
|Given7={{{first7|{{{given7|}}}}}}
|Given8={{{first8|{{{given8|}}}}}}
|Given9={{{first9|{{{given9|}}}}}}

|Authorlink1={{{authorlink|{{{authorlink1|{{{author-link|{{{author1-link|}}}}}}}}}}}}
|Authorlink2={{{authorlink2|{{{author2-link|}}}}}}
|Authorlink3={{{authorlink3|{{{author3-link|}}}}}}
|Authorlink4={{{authorlink4|{{{author4-link|}}}}}}
|Authorlink5={{{authorlink5|{{{author5-link|}}}}}}
|Authorlink6={{{authorlink6|{{{author6-link|}}}}}}
|Authorlink7={{{authorlink7|{{{author7-link|}}}}}}
|Authorlink8={{{authorlink8|{{{author8-link|}}}}}}
|Authorlink9={{{authorlink9|{{{author9-link|}}}}}}

|Coauthors={{{coauthors|{{{coauthor|}}}}}}

|Other={{{others|}}}

|Year={{{year|{{    &lt;!-- attempt to derive year from date, if possible --&gt;
           #if: {{{date|}}}
           |{{
              #iferror:{{#time:Y|{{{date|}}} }}
              |{{#iferror:{{#time:Y|{{{publication-date|einval}}} }}||{{#time:Y|{{{publication-date|}}} }}}}
              |{{#time:Y|{{{date|}}} }}
            }}
           |{{{publication-date|}}} &lt;!-- last resort --&gt;
         }}
      }}}
|YearNote={{{origyear|}}}
|Date={{#if:{{{date|}}}|{{{date}}}|{{{day|}}} {{{month|}}} {{{year|{{{publication-date|}}}}}}}}

|Title={{{work|}}}
|IncludedWorkTitle={{
  #if:{{{title|}}}
  |{{{title}}}
  |{{
    #if:{{{trans_title|}}}
    |
    |{{citation error|nocat={{{template doc demo|}}}|no &lt;code&gt;&amp;#124;title&amp;#61;&lt;/code&gt; specified|Cite web}}
    }}
  }}
|TransTitle={{{trans_title|}}}
|TitleType={{{type|}}}
|language={{{language|}}}

|IncludedWorkURL={{#if:{{{archiveurl|}}}
       |{{#ifeq: {{{deadurl|}}} | no | {{{url|}}} | {{{archiveurl|}}}}}
       |{{{url|}}}
     }}
|AccessDate={{{accessdate|}}}
|OriginalURL={{{url|}}}
|ArchiveURL={{{archiveurl|}}}
|ArchiveDate={{{archivedate|}}}
|DeadURL={{{deadurl|}}}
|format={{{format|}}}

|At={{#if: {{{page|}}}|{{#if:{{{nopp|}}}||p.&amp;nbsp;}}{{{page}}}
      |{{#if: {{{pages|}}}|{{#if:{{{nopp|}}}||pp.&amp;nbsp;}}{{{pages}}}
      |{{{at|}}}}}
    }}

|Series={{{agency|{{{series|{{{version|}}}}}}}}}

|Publisher={{{publisher|}}}
|Place={{{location|{{{place|}}}}}}
|PublicationPlace={{{location|{{{place|{{{publication-place|}}}}}}}}}
|PublicationDate={{{publication-date|}}}

|EditorSurname1={{{editor-last|{{{editor1-last|{{{editor|{{{editors|{{{editor-surname|{{{editor1-surname|}}}}}}}}}}}}}}}}}}
|EditorSurname2={{{editor2-last|{{{editor2-surname|}}}}}}
|EditorSurname3={{{editor3-last|{{{editor3-surname|}}}}}}
|EditorSurname4={{{editor4-last|{{{editor4-surname|}}}}}}
|EditorGiven1={{{editor-first|{{{editor1-first|{{{editor-given|{{{editor1-given|}}}}}}}}}}}}
|EditorGiven2={{{editor2-first|{{{editor2-given|}}}}}}
|EditorGiven3={{{editor3-first|{{{editor3-given|}}}}}}
|EditorGiven4={{{editor4-first|{{{editor4-given|}}}}}}
|Editorlink1={{{editor-link|{{{editor1-link|}}}}}}
|Editorlink2={{{editor2-link|}}}
|Editorlink3={{{editor3-link|}}}
|Editorlink4={{{editor4-link|}}}

|ARXIV={{{arxiv|}}}
|ASIN={{{asin|{{{ASIN|}}}}}}
|ASIN-TLD={{{asin-tld|}}}
|BIBCODE={{{bibcode|}}}
|DOI={{{doi|{{{DOI|}}}}}}
|DoiBroken={{{doi_brokendate|{{{doi_inactivedate|}}}}}}
|ISBN={{{isbn|{{{ISBN|}}}}}}
|ISSN={{{issn|{{{ISSN|}}}}}}
|JFM={{{jfm|{{{JFM|}}}}}}
|JSTOR={{{jstor|{{{JSTOR|}}}}}}
|LCCN={{{lccn|{{{LCCN|}}}}}}
|MR={{{mr|{{{MR|}}}}}}
|OCLC={{{oclc|{{{OCLC|}}}}}}
|OL={{{ol|{{{OL|}}}}}}
|OSTI={{{osti|{{{OSTI|}}}}}}
|PMC={{{pmc|{{{PMC|}}}}}}
|PMID={{{pmid|{{{PMID|}}}}}}
|RFC={{{rfc|{{{RFC|}}}}}}
|SSRN={{{ssrn|{{{SSRN|}}}}}}
|ZBL={{{zbl|}}}
|ID={{{id|{{{ID|}}}}}}

|laysummary={{{laysummary|}}}
|laydate={{{laydate|}}}
|laysource={{{laysource|}}}

|quote={{{quote|}}}

|Ref={{{ref|}}}

|amp={{{lastauthoramp|}}}
|AuthorMask={{{author-mask|{{{authormask|}}}}}}
|AuthorSep={{#ifeq:{{{author-separator|}}}|;|&amp;#059;|{{{author-separator|&amp;#059;}}}}}&amp;#32;
|NameSep={{{author-name-separator|,}}}&amp;#32;
|PS={{#if:{{{quote|}}}||{{{postscript|.}}}}}
|Sep={{#ifeq:{{{separator|{{{seperator}}} }}}|;|&amp;#059;|{{{separator|{{{seperator|.}}} }}} }}
|template doc demo={{{template doc demo|}}}
|Trunc={{#if:{{{display-authors|}}}|{{{display-authors}}}|8}}
}}{{#if:{{{access-date|}}}{{{accessdaymonth|}}}{{{accessday|}}}{{{accessmonthday|}}}{{{accessed|}}}{{{accessmonth|}}}{{{accessyear|}}}{{{dateformat|}}}{{{day|}}}{{{doilabel|}}}
|[[Mkhakha:Pages containing cite templates with deprecated parameters|{{NAMESPACE}} {{PAGENAME}}]]}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>belaiv8mhopefyuklxknbie9h2upxbe</sha1>
    </revision>
    <revision>
      <id>5042</id>
      <parentid>376</parentid>
      <timestamp>2025-08-07T07:40:26Z</timestamp>
      <contributor>
        <username>Martin Urbanec</username>
        <id>803</id>
      </contributor>
      <comment>actually use the citation module</comment>
      <origin>5042</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="122" sha1="rcgmbcxu7hvs583g1f3rzz4c4dkizda" xml:space="preserve">&lt;includeonly&gt;{{#invoke:citation/CS1|citation
|CitationClass=web
}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>rcgmbcxu7hvs583g1f3rzz4c4dkizda</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Col-begin</title>
    <ns>10</ns>
    <id>67</id>
    <revision>
      <id>275</id>
      <timestamp>2019-01-11T15:38:58Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;{| cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;{{{class|}}} multicol&quot; style=&quot;background:{{{bgColor|transparent}}}; width:{{{width|100%}}};&quot;&quot;</comment>
      <origin>275</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="134" sha1="45u6tgubp740avopi6j07ksc5hdns6b" xml:space="preserve">{| cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;{{{class|}}} multicol&quot; style=&quot;background:{{{bgColor|transparent}}}; width:{{{width|100%}}};&quot;</text>
      <sha1>45u6tgubp740avopi6j07ksc5hdns6b</sha1>
    </revision>
    <revision>
      <id>276</id>
      <parentid>275</parentid>
      <timestamp>2022-04-27T09:42:28Z</timestamp>
      <contributor>
        <username>incubator&gt;JhsBot</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>JhsBot moved page [[Umhlahlandlelasakhiwo:col-begin]] to [[Umhlahlandlelasakhiwo:Col-begin]]: bot: Moving pages with (what would be) lowercase titles to uppercase</comment>
      <origin>275</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="134" sha1="45u6tgubp740avopi6j07ksc5hdns6b" xml:space="preserve">{| cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;{{{class|}}} multicol&quot; style=&quot;background:{{{bgColor|transparent}}}; width:{{{width|100%}}};&quot;</text>
      <sha1>45u6tgubp740avopi6j07ksc5hdns6b</sha1>
    </revision>
    <revision>
      <id>277</id>
      <parentid>276</parentid>
      <timestamp>2024-10-14T13:46:18Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>275</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="134" sha1="45u6tgubp740avopi6j07ksc5hdns6b" xml:space="preserve">{| cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;{{{class|}}} multicol&quot; style=&quot;background:{{{bgColor|transparent}}}; width:{{{width|100%}}};&quot;</text>
      <sha1>45u6tgubp740avopi6j07ksc5hdns6b</sha1>
    </revision>
    <revision>
      <id>377</id>
      <parentid>276</parentid>
      <timestamp>2022-04-27T09:42:28Z</timestamp>
      <contributor>
        <username>incubator&gt;JhsBot</username>
        <id>0</id>
      </contributor>
      <comment>JhsBot moved page [[Umhlahlandlelasakhiwo:col-begin]] to [[Umhlahlandlelasakhiwo:Col-begin]]: bot: Moving pages with (what would be) lowercase titles to uppercase</comment>
      <origin>377</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="45" sha1="30d4gfhkz1vcyuph10v82oooy0i8kle" xml:space="preserve">#REDIRECT [[Umhlahlandlelasakhiwo:Col-begin]]</text>
      <sha1>30d4gfhkz1vcyuph10v82oooy0i8kle</sha1>
    </revision>
    <revision>
      <id>378</id>
      <parentid>277</parentid>
      <timestamp>2024-10-14T13:46:25Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>275</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="134" sha1="45u6tgubp740avopi6j07ksc5hdns6b" xml:space="preserve">{| cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;{{{class|}}} multicol&quot; style=&quot;background:{{{bgColor|transparent}}}; width:{{{width|100%}}};&quot;</text>
      <sha1>45u6tgubp740avopi6j07ksc5hdns6b</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Col-break</title>
    <ns>10</ns>
    <id>68</id>
    <revision>
      <id>278</id>
      <timestamp>2019-01-11T15:39:33Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;&lt;p&gt;&lt;/p&gt; | width=&quot;{{{width|}}}&quot; align=&quot;{{{align|left}}}&quot; valign=&quot;{{{valign|top}}}&quot; {{#if: {{{gap|}}} | style=&quot;padding-left:{{{gap}}};&quot; }}|&quot;</comment>
      <origin>278</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="137" sha1="ifjgi1kkpoayt9mz4eut6myjeqtypuu" xml:space="preserve">&lt;p&gt;&lt;/p&gt;
| width=&quot;{{{width|}}}&quot; align=&quot;{{{align|left}}}&quot; valign=&quot;{{{valign|top}}}&quot; {{#if: {{{gap|}}} | style=&quot;padding-left:{{{gap}}};&quot; }}|</text>
      <sha1>ifjgi1kkpoayt9mz4eut6myjeqtypuu</sha1>
    </revision>
    <revision>
      <id>279</id>
      <parentid>278</parentid>
      <timestamp>2022-04-27T09:42:31Z</timestamp>
      <contributor>
        <username>incubator&gt;JhsBot</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>JhsBot moved page [[Umhlahlandlelasakhiwo:col-break]] to [[Umhlahlandlelasakhiwo:Col-break]]: bot: Moving pages with (what would be) lowercase titles to uppercase</comment>
      <origin>278</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="137" sha1="ifjgi1kkpoayt9mz4eut6myjeqtypuu" xml:space="preserve">&lt;p&gt;&lt;/p&gt;
| width=&quot;{{{width|}}}&quot; align=&quot;{{{align|left}}}&quot; valign=&quot;{{{valign|top}}}&quot; {{#if: {{{gap|}}} | style=&quot;padding-left:{{{gap}}};&quot; }}|</text>
      <sha1>ifjgi1kkpoayt9mz4eut6myjeqtypuu</sha1>
    </revision>
    <revision>
      <id>280</id>
      <parentid>279</parentid>
      <timestamp>2024-10-14T13:46:18Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>278</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="137" sha1="ifjgi1kkpoayt9mz4eut6myjeqtypuu" xml:space="preserve">&lt;p&gt;&lt;/p&gt;
| width=&quot;{{{width|}}}&quot; align=&quot;{{{align|left}}}&quot; valign=&quot;{{{valign|top}}}&quot; {{#if: {{{gap|}}} | style=&quot;padding-left:{{{gap}}};&quot; }}|</text>
      <sha1>ifjgi1kkpoayt9mz4eut6myjeqtypuu</sha1>
    </revision>
    <revision>
      <id>379</id>
      <parentid>279</parentid>
      <timestamp>2022-04-27T09:42:31Z</timestamp>
      <contributor>
        <username>incubator&gt;JhsBot</username>
        <id>0</id>
      </contributor>
      <comment>JhsBot moved page [[Umhlahlandlelasakhiwo:col-break]] to [[Umhlahlandlelasakhiwo:Col-break]]: bot: Moving pages with (what would be) lowercase titles to uppercase</comment>
      <origin>379</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="45" sha1="3mkm9j5t2qv90tdr15wrvilp6hzgs7a" xml:space="preserve">#REDIRECT [[Umhlahlandlelasakhiwo:Col-break]]</text>
      <sha1>3mkm9j5t2qv90tdr15wrvilp6hzgs7a</sha1>
    </revision>
    <revision>
      <id>380</id>
      <parentid>280</parentid>
      <timestamp>2024-10-14T13:46:25Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>278</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="137" sha1="ifjgi1kkpoayt9mz4eut6myjeqtypuu" xml:space="preserve">&lt;p&gt;&lt;/p&gt;
| width=&quot;{{{width|}}}&quot; align=&quot;{{{align|left}}}&quot; valign=&quot;{{{valign|top}}}&quot; {{#if: {{{gap|}}} | style=&quot;padding-left:{{{gap}}};&quot; }}|</text>
      <sha1>ifjgi1kkpoayt9mz4eut6myjeqtypuu</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Col-end</title>
    <ns>10</ns>
    <id>69</id>
    <revision>
      <id>281</id>
      <timestamp>2019-01-11T15:39:56Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;&lt;p&gt;&lt;/p&gt; |}&quot;</comment>
      <origin>281</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="10" sha1="ap29tgbr3h2pbiiab9hb7ep9w1arcqa" xml:space="preserve">&lt;p&gt;&lt;/p&gt;
|}</text>
      <sha1>ap29tgbr3h2pbiiab9hb7ep9w1arcqa</sha1>
    </revision>
    <revision>
      <id>282</id>
      <parentid>281</parentid>
      <timestamp>2022-04-27T09:42:34Z</timestamp>
      <contributor>
        <username>incubator&gt;JhsBot</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>JhsBot moved page [[Umhlahlandlelasakhiwo:col-end]] to [[Umhlahlandlelasakhiwo:Col-end]]: bot: Moving pages with (what would be) lowercase titles to uppercase</comment>
      <origin>281</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="10" sha1="ap29tgbr3h2pbiiab9hb7ep9w1arcqa" xml:space="preserve">&lt;p&gt;&lt;/p&gt;
|}</text>
      <sha1>ap29tgbr3h2pbiiab9hb7ep9w1arcqa</sha1>
    </revision>
    <revision>
      <id>283</id>
      <parentid>282</parentid>
      <timestamp>2024-10-14T13:46:18Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>281</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="10" sha1="ap29tgbr3h2pbiiab9hb7ep9w1arcqa" xml:space="preserve">&lt;p&gt;&lt;/p&gt;
|}</text>
      <sha1>ap29tgbr3h2pbiiab9hb7ep9w1arcqa</sha1>
    </revision>
    <revision>
      <id>381</id>
      <parentid>282</parentid>
      <timestamp>2022-04-27T09:42:34Z</timestamp>
      <contributor>
        <username>incubator&gt;JhsBot</username>
        <id>0</id>
      </contributor>
      <comment>JhsBot moved page [[Umhlahlandlelasakhiwo:col-end]] to [[Umhlahlandlelasakhiwo:Col-end]]: bot: Moving pages with (what would be) lowercase titles to uppercase</comment>
      <origin>381</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="43" sha1="1851tcczxkgta4tbsqj10ss69wjh3wy" xml:space="preserve">#REDIRECT [[Umhlahlandlelasakhiwo:Col-end]]</text>
      <sha1>1851tcczxkgta4tbsqj10ss69wjh3wy</sha1>
    </revision>
    <revision>
      <id>382</id>
      <parentid>283</parentid>
      <timestamp>2024-10-14T13:46:25Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>281</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="10" sha1="ap29tgbr3h2pbiiab9hb7ep9w1arcqa" xml:space="preserve">&lt;p&gt;&lt;/p&gt;
|}</text>
      <sha1>ap29tgbr3h2pbiiab9hb7ep9w1arcqa</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Column-width</title>
    <ns>10</ns>
    <id>70</id>
    <revision>
      <id>284</id>
      <timestamp>2016-06-18T05:54:31Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;&lt;includeonly&gt;-moz-column-width: {{{1|30em}}}; -webkit-column-width: {{{1|30em}}}; column-width: {{{1|30em}}};&lt;/includeonly&gt;&lt;noinclude&gt; {{documentation}} &lt;/noinclude&gt;&quot;</comment>
      <origin>284</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="165" sha1="sum88q311kc02222mb4cgzbikcx7fqy" xml:space="preserve">&lt;includeonly&gt;-moz-column-width: {{{1|30em}}}; -webkit-column-width: {{{1|30em}}}; column-width: {{{1|30em}}};&lt;/includeonly&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>sum88q311kc02222mb4cgzbikcx7fqy</sha1>
    </revision>
    <revision>
      <id>285</id>
      <parentid>284</parentid>
      <timestamp>2016-06-18T05:55:32Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>284</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="165" sha1="sum88q311kc02222mb4cgzbikcx7fqy" xml:space="preserve">&lt;includeonly&gt;-moz-column-width: {{{1|30em}}}; -webkit-column-width: {{{1|30em}}}; column-width: {{{1|30em}}};&lt;/includeonly&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>sum88q311kc02222mb4cgzbikcx7fqy</sha1>
    </revision>
    <revision>
      <id>286</id>
      <parentid>285</parentid>
      <timestamp>2024-10-14T13:46:18Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>284</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="165" sha1="sum88q311kc02222mb4cgzbikcx7fqy" xml:space="preserve">&lt;includeonly&gt;-moz-column-width: {{{1|30em}}}; -webkit-column-width: {{{1|30em}}}; column-width: {{{1|30em}}};&lt;/includeonly&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>sum88q311kc02222mb4cgzbikcx7fqy</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Commons</title>
    <ns>10</ns>
    <id>71</id>
    <revision>
      <id>287</id>
      <timestamp>2019-01-13T17:20:12Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;&lt;div class=&quot;noprint&quot; style=&quot;clear: right; border: solid #aaa 1px; margin: 0 0 1em 1em; font-size: 90%; background: #f9f9f9; width: 250px; padding: 4px; spacing: 0px; text-alig...&quot;</comment>
      <origin>287</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="571" sha1="2j1i85gin3hwudk2zwghl0ww1u7vj5a" xml:space="preserve">&lt;div class=&quot;noprint&quot; style=&quot;clear: right; border: solid #aaa 1px; margin: 0 0 1em 1em; font-size: 90%; background: #f9f9f9; width: 250px; padding: 4px; spacing: 0px; text-align: left; float:right;&quot;&gt;
&lt;div style=&quot;float: left;&quot;&gt;[[Isimumathi:Commons-logo.svg|46px|none|Commons]]&lt;/div&gt;
&lt;div style=&quot;margin-left: 60px;&quot;&gt;Wikimedia Commons has media related to:&lt;div style=&quot;margin-left: 10px;&quot;&gt;&lt;span class=&quot;plainlinks&quot;&gt;'''''[{{localurl:Commons:{{{1|{{PAGENAME}}}}}}}?uselang=ts {{{2| {{PAGENAME}} }}}]'''''&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;!--
--&gt;&lt;noinclude&gt;{{Documentation}}&lt;/noinclude&gt;</text>
      <sha1>2j1i85gin3hwudk2zwghl0ww1u7vj5a</sha1>
    </revision>
    <revision>
      <id>288</id>
      <parentid>287</parentid>
      <timestamp>2024-10-14T13:46:18Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>287</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="571" sha1="2j1i85gin3hwudk2zwghl0ww1u7vj5a" xml:space="preserve">&lt;div class=&quot;noprint&quot; style=&quot;clear: right; border: solid #aaa 1px; margin: 0 0 1em 1em; font-size: 90%; background: #f9f9f9; width: 250px; padding: 4px; spacing: 0px; text-align: left; float:right;&quot;&gt;
&lt;div style=&quot;float: left;&quot;&gt;[[Isimumathi:Commons-logo.svg|46px|none|Commons]]&lt;/div&gt;
&lt;div style=&quot;margin-left: 60px;&quot;&gt;Wikimedia Commons has media related to:&lt;div style=&quot;margin-left: 10px;&quot;&gt;&lt;span class=&quot;plainlinks&quot;&gt;'''''[{{localurl:Commons:{{{1|{{PAGENAME}}}}}}}?uselang=ts {{{2| {{PAGENAME}} }}}]'''''&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;!--
--&gt;&lt;noinclude&gt;{{Documentation}}&lt;/noinclude&gt;</text>
      <sha1>2j1i85gin3hwudk2zwghl0ww1u7vj5a</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Documentation</title>
    <ns>10</ns>
    <id>72</id>
    <revision>
      <id>289</id>
      <timestamp>2016-06-18T05:56:19Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;{{#invoke:documentation|main|_content={{ {{#invoke:documentation|contentTitle}}}}}}&lt;noinclude&gt; &lt;!-- Categories go on the /doc subpage, and interwikis go on Wikidata. --&gt; &lt;/noi...&quot;</comment>
      <origin>289</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="182" sha1="o4ddn701tao1ufdnkxe1wdgz5b5ga84" xml:space="preserve">{{#invoke:documentation|main|_content={{ {{#invoke:documentation|contentTitle}}}}}}&lt;noinclude&gt;
&lt;!-- Categories go on the /doc subpage, and interwikis go on Wikidata. --&gt;
&lt;/noinclude&gt;</text>
      <sha1>o4ddn701tao1ufdnkxe1wdgz5b5ga84</sha1>
    </revision>
    <revision>
      <id>290</id>
      <parentid>289</parentid>
      <timestamp>2018-11-17T10:51:21Z</timestamp>
      <contributor>
        <username>incubator&gt;Liuxinyu970226</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>290</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="182" sha1="2xhh66tsv150gi3f97xaydn2109p9s5" xml:space="preserve">{{#invoke:Documentation|main|_content={{ {{#invoke:Documentation|contentTitle}}}}}}&lt;noinclude&gt;
&lt;!-- Categories go on the /doc subpage, and interwikis go on Wikidata. --&gt;
&lt;/noinclude&gt;</text>
      <sha1>2xhh66tsv150gi3f97xaydn2109p9s5</sha1>
    </revision>
    <revision>
      <id>291</id>
      <parentid>290</parentid>
      <timestamp>2024-10-14T13:46:19Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>290</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="182" sha1="2xhh66tsv150gi3f97xaydn2109p9s5" xml:space="preserve">{{#invoke:Documentation|main|_content={{ {{#invoke:Documentation|contentTitle}}}}}}&lt;noinclude&gt;
&lt;!-- Categories go on the /doc subpage, and interwikis go on Wikidata. --&gt;
&lt;/noinclude&gt;</text>
      <sha1>2xhh66tsv150gi3f97xaydn2109p9s5</sha1>
    </revision>
    <revision>
      <id>383</id>
      <parentid>290</parentid>
      <timestamp>2019-01-13T17:05:28Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;&lt;div class=&quot;template-documentation&quot;&gt;&lt;!--  These are the literal class definitions in common.css:   /* For template documentation */ .template-documentation {     clear: both;...&quot;</comment>
      <origin>383</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2692" sha1="fugkld0eb713rb7zeuk965itgeddgkz" xml:space="preserve">&lt;div class=&quot;template-documentation&quot;&gt;&lt;!--

These are the literal class definitions in common.css:
 
/* For template documentation */
.template-documentation {
    clear: both;
    margin: 1em 0 0 0;
    border: 1px solid #aaa; 
    background-color: #ecfcf4; 
    padding: 5px;
}


 --&gt;{{#ifeq:{{{heading|μ}}}|&lt;!--**DEFINED BUT EMPTY**--&gt;
  |&lt;!--**NOTHING**--&gt;
  |&lt;div style=&quot;padding-bottom:3px; border-bottom: 1px solid #aaa; margin-bottom:1ex&quot;&gt;{{#ifeq:{{{content|μ}}}|μ
   |&lt;span class=&quot;editsection plainlinks&quot; id=&quot;doc_editlinks&quot;&gt;{{#ifexist: {{{1|{{Documentation/docname}}}}}
    |&lt;!--**    /doc EXISTS**   --&gt;[[{{fullurl:{{{1|{{Documentation/docname}}}}}|action=edit}} edit]]
    |&lt;!--**/doc DOESN'T EXIST**--&gt;[[{{fullurl:{{{1|{{Documentation/docname }}}}}|action=edit&amp;preload=Template:Documentation/preload}} create]]
   }}&lt;/span&gt;
  }} &lt;span style=&quot;{{#if:{{{heading-style|}}}|{{{heading-style}}}|{{#ifeq:{{NAMESPACE}}|{{ns:template}}|font-weight: bold; font-size: 125%|font-size: 150%}}}}&quot;&gt;{{#if:{{{heading|}}}|{{{heading}}}|{{#ifeq:{{NAMESPACE}}|{{ns:template}}|[[Isimumathi:Template-info.svg|50px]] Template documentation|Documentation}}}}&lt;/span&gt;&lt;/div&gt;
 }}&lt;!--

 --&gt;&lt;div id=&quot;template_doc_page_transcluded&quot; class=&quot;dablink plainlinks&quot;&gt;&lt;!--
  --&gt;{{#ifexist: {{{1|{{Documentation/docname}}}}}
  |&lt;!--**/doc EXISTS**--&gt;This [[Wikipedia:Template documentation|documentation]] is [[Wikipedia:Transclusion|transcluded]] from [[{{{1|{{Documentation/docname}}}}}]]. &lt;small style=&quot;font-style: normal&quot;&gt;([{{fullurl:{{{1|{{Documentation/docname}}}}}|action=edit}} edit] &amp;#124; [{{fullurl:{{{1|{{Documentation/docname}}}}}|action=history}} history])&lt;/small&gt;&lt;br /&gt;
 }}&lt;!--

 --&gt;{{#switch: {{SUBPAGENAME}}
   |sandbox|testcases=&lt;!--**DO NOT SHOW THESE LINKS ON THE SANDBOX/TESTCASES PAGES**--&gt;
   |#default=
    {{#switch: {{SUBJECTSPACE}}
     |{{ns:template}}
     |{{ns:user}}=
      {{#ifexist: {{FULLPAGENAME}}/sandbox
       |This template has a [[/sandbox|sandbox]] &lt;small style=&quot;font-style: normal&quot;&gt;([{{fullurl:{{ #rel2abs: /sandbox }}|action=edit}} edit])&lt;/small&gt; &lt;!--
        --&gt;{{#ifexist: {{FULLPAGENAME}}/testcases
         |and [[/testcases|testcases]] &lt;small style=&quot;font-style: normal&quot;&gt;([{{fullurl:{{ #rel2abs: /testcases }}|action=edit}} edit])&lt;/small&gt;}} for editors to experiment.
       |{{#ifexist: {{FULLPAGENAME}}/testcases
        |This template has [[/testcases|testcases]] &lt;small style=&quot;font-style: normal&quot;&gt;([{{fullurl:{{ #rel2abs: /testcases }}|action=edit}} edit])&lt;/small&gt; for editors to experiment.}}
 }}}}}}
 &lt;/div&gt;
{{#if:{{{content|}}}|{{{content}}}|{{#ifexist:{{{1|{{Documentation/docname}}}}} | {{ {{{1|{{Documentation/docname}}}}} }} }}}}
&lt;/div&gt;&lt;noinclude&gt;
&lt;/noinclude&gt;</text>
      <sha1>fugkld0eb713rb7zeuk965itgeddgkz</sha1>
    </revision>
    <revision>
      <id>384</id>
      <parentid>383</parentid>
      <timestamp>2023-05-30T15:20:50Z</timestamp>
      <contributor>
        <username>incubator&gt;Пан Хаунд</username>
        <id>0</id>
      </contributor>
      <origin>383</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2692" sha1="fugkld0eb713rb7zeuk965itgeddgkz" xml:space="preserve">&lt;div class=&quot;template-documentation&quot;&gt;&lt;!--

These are the literal class definitions in common.css:
 
/* For template documentation */
.template-documentation {
    clear: both;
    margin: 1em 0 0 0;
    border: 1px solid #aaa; 
    background-color: #ecfcf4; 
    padding: 5px;
}


 --&gt;{{#ifeq:{{{heading|μ}}}|&lt;!--**DEFINED BUT EMPTY**--&gt;
  |&lt;!--**NOTHING**--&gt;
  |&lt;div style=&quot;padding-bottom:3px; border-bottom: 1px solid #aaa; margin-bottom:1ex&quot;&gt;{{#ifeq:{{{content|μ}}}|μ
   |&lt;span class=&quot;editsection plainlinks&quot; id=&quot;doc_editlinks&quot;&gt;{{#ifexist: {{{1|{{Documentation/docname}}}}}
    |&lt;!--**    /doc EXISTS**   --&gt;[[{{fullurl:{{{1|{{Documentation/docname}}}}}|action=edit}} edit]]
    |&lt;!--**/doc DOESN'T EXIST**--&gt;[[{{fullurl:{{{1|{{Documentation/docname }}}}}|action=edit&amp;preload=Template:Documentation/preload}} create]]
   }}&lt;/span&gt;
  }} &lt;span style=&quot;{{#if:{{{heading-style|}}}|{{{heading-style}}}|{{#ifeq:{{NAMESPACE}}|{{ns:template}}|font-weight: bold; font-size: 125%|font-size: 150%}}}}&quot;&gt;{{#if:{{{heading|}}}|{{{heading}}}|{{#ifeq:{{NAMESPACE}}|{{ns:template}}|[[Isimumathi:Template-info.svg|50px]] Template documentation|Documentation}}}}&lt;/span&gt;&lt;/div&gt;
 }}&lt;!--

 --&gt;&lt;div id=&quot;template_doc_page_transcluded&quot; class=&quot;dablink plainlinks&quot;&gt;&lt;!--
  --&gt;{{#ifexist: {{{1|{{Documentation/docname}}}}}
  |&lt;!--**/doc EXISTS**--&gt;This [[Wikipedia:Template documentation|documentation]] is [[Wikipedia:Transclusion|transcluded]] from [[{{{1|{{Documentation/docname}}}}}]]. &lt;small style=&quot;font-style: normal&quot;&gt;([{{fullurl:{{{1|{{Documentation/docname}}}}}|action=edit}} edit] &amp;#124; [{{fullurl:{{{1|{{Documentation/docname}}}}}|action=history}} history])&lt;/small&gt;&lt;br /&gt;
 }}&lt;!--

 --&gt;{{#switch: {{SUBPAGENAME}}
   |sandbox|testcases=&lt;!--**DO NOT SHOW THESE LINKS ON THE SANDBOX/TESTCASES PAGES**--&gt;
   |#default=
    {{#switch: {{SUBJECTSPACE}}
     |{{ns:template}}
     |{{ns:user}}=
      {{#ifexist: {{FULLPAGENAME}}/sandbox
       |This template has a [[/sandbox|sandbox]] &lt;small style=&quot;font-style: normal&quot;&gt;([{{fullurl:{{ #rel2abs: /sandbox }}|action=edit}} edit])&lt;/small&gt; &lt;!--
        --&gt;{{#ifexist: {{FULLPAGENAME}}/testcases
         |and [[/testcases|testcases]] &lt;small style=&quot;font-style: normal&quot;&gt;([{{fullurl:{{ #rel2abs: /testcases }}|action=edit}} edit])&lt;/small&gt;}} for editors to experiment.
       |{{#ifexist: {{FULLPAGENAME}}/testcases
        |This template has [[/testcases|testcases]] &lt;small style=&quot;font-style: normal&quot;&gt;([{{fullurl:{{ #rel2abs: /testcases }}|action=edit}} edit])&lt;/small&gt; for editors to experiment.}}
 }}}}}}
 &lt;/div&gt;
{{#if:{{{content|}}}|{{{content}}}|{{#ifexist:{{{1|{{Documentation/docname}}}}} | {{ {{{1|{{Documentation/docname}}}}} }} }}}}
&lt;/div&gt;&lt;noinclude&gt;
&lt;/noinclude&gt;</text>
      <sha1>fugkld0eb713rb7zeuk965itgeddgkz</sha1>
    </revision>
    <revision>
      <id>385</id>
      <parentid>291</parentid>
      <timestamp>2024-10-14T13:46:25Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>290</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="182" sha1="2xhh66tsv150gi3f97xaydn2109p9s5" xml:space="preserve">{{#invoke:Documentation|main|_content={{ {{#invoke:Documentation|contentTitle}}}}}}&lt;noinclude&gt;
&lt;!-- Categories go on the /doc subpage, and interwikis go on Wikidata. --&gt;
&lt;/noinclude&gt;</text>
      <sha1>2xhh66tsv150gi3f97xaydn2109p9s5</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Ethnic group</title>
    <ns>10</ns>
    <id>73</id>
    <revision>
      <id>292</id>
      <timestamp>2016-02-25T19:06:56Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;{| class=&quot;toccolours&quot; style=&quot;float:right; width:280px; margin-left: 1em; font-size: 85%;&quot; | align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | &lt;big&gt;'''{{{ubutjhaba}}}'...&quot;</comment>
      <origin>292</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1403" sha1="er3hb0sqezpw2789cyddzbzwa79l0qu" xml:space="preserve">{| class=&quot;toccolours&quot; style=&quot;float:right; width:280px; margin-left: 1em; font-size: 85%;&quot;
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | &lt;big&gt;'''{{{ubutjhaba}}}'''&lt;/big&gt;
|-
| align=&quot;center&quot; colspan=&quot;2&quot;  |
{|
| align=&quot;center&quot; width=&quot;120&quot;  | [[Isimumathi:{{{isithombe}}}|180px]]
|}
|-
| align=&quot;center&quot; colspan=&quot;2&quot; | &lt;big&gt;''{{{umtlolo}}}''&lt;/big&gt;
|-
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | &lt;big&gt;'''Ubuningi be sitjhaba'''&lt;/big&gt;
|-
| align=&quot;center&quot; colspan=&quot;2&quot; | &lt;big&gt;''{{{Ubuningi}}}''&lt;/big&gt;
|-
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | &lt;big&gt;'''Lapho batholakala ngobuningi'''&lt;/big&gt;
|-
| align=&quot;center&quot; colspan=&quot;2&quot; | &lt;big&gt;''{{{Amaphrovinci}}}''&lt;/big&gt;
|-
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | &lt;big&gt;'''Amalimi esitjhaba'''&lt;/big&gt;
|-
| align=&quot;center&quot; colspan=&quot;2&quot; | &lt;big&gt;''{{{Amalimi}}}''&lt;/big&gt;
|-
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | &lt;big&gt;'''Isiqhema sekolo'''&lt;/big&gt;
|-
| align=&quot;center&quot; colspan=&quot;2&quot; | &lt;big&gt;''{{{ikolo}}}''&lt;/big&gt;
|-
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | &lt;big&gt;'''Ukuhlobana ngobutjhaba'''&lt;/big&gt;
|-
| align=&quot;center&quot; colspan=&quot;2&quot; | &lt;big&gt;''{{{bahlobane}}}''&lt;/big&gt;
|}
&lt;noinclude&gt;
&lt;pre&gt;
{{Ethnic group
|Ubutjhaba    = 
|isithombe    = 
|umtlolo      = 
|Ubuningi     = 
|Amaphrovinci = 
|Amalimi      = 
|Ikolo        = 
|Bahlobane    = 
}}
&lt;/pre&gt;
[[Mkhakha:Abantu]]
&lt;/noinclude&gt;</text>
      <sha1>er3hb0sqezpw2789cyddzbzwa79l0qu</sha1>
    </revision>
    <revision>
      <id>293</id>
      <parentid>292</parentid>
      <timestamp>2016-02-25T19:10:04Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>293</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1262" sha1="gn2drdyezp07k6eo6txauly2ortsv8b" xml:space="preserve">{| class=&quot;toccolours&quot; style=&quot;float:right; width:280px; margin-left: 1em; font-size: 85%;&quot;
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | &lt;big&gt;'''{{{ubutjhaba}}}'''&lt;/big&gt;
|-
| align=&quot;center&quot; colspan=&quot;2&quot;  |
{|
| align=&quot;center&quot; width=&quot;120&quot;  | [[Isimumathi:{{{isithombe}}}|180px]]
|}
|-
| align=&quot;center&quot; colspan=&quot;2&quot; | ''{{{umtlolo}}}''
|-
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | '''Ubuningi be sitjhaba'''
|-
| align=&quot;center&quot; colspan=&quot;2&quot; | {{{Ubuningi}}}
|-
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | '''Lapho batholakala ngobuningi'''
|-
| align=&quot;center&quot; colspan=&quot;2&quot; | {{{Amaphrovinci}}}
|-
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | '''Amalimi esitjhaba'''
|-
| align=&quot;center&quot; colspan=&quot;2&quot; | {{{Amalimi}}}
|-
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | '''Isiqhema sekolo'''
|-
| align=&quot;center&quot; colspan=&quot;2&quot; | {{{ikolo}}}
|-
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | '''Ukuhlobana ngobutjhaba'''
|-
| align=&quot;center&quot; colspan=&quot;2&quot; | {{{bahlobane}}}
|}
&lt;noinclude&gt;
&lt;pre&gt;
{{Ethnic group
|Ubutjhaba    = 
|isithombe    = 
|umtlolo      = 
|Ubuningi     = 
|Amaphrovinci = 
|Amalimi      = 
|Ikolo        = 
|Bahlobane    = 
}}
&lt;/pre&gt;
[[Mkhakha:Abantu]]
&lt;/noinclude&gt;</text>
      <sha1>gn2drdyezp07k6eo6txauly2ortsv8b</sha1>
    </revision>
    <revision>
      <id>294</id>
      <parentid>293</parentid>
      <timestamp>2016-02-25T19:12:45Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>294</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1262" sha1="oxqftqjainazw0vaw9z3dqy5u79dvtq" xml:space="preserve">{| class=&quot;toccolours&quot; style=&quot;float:right; width:280px; margin-left: 1em; font-size: 85%;&quot;
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | &lt;big&gt;'''{{{ubutjhaba}}}'''&lt;/big&gt;
|-
| align=&quot;center&quot; colspan=&quot;2&quot;  |
{|
| align=&quot;center&quot; width=&quot;120&quot;  | [[Isimumathi:{{{isithombe}}}|180px]]
|}
|-
| align=&quot;center&quot; colspan=&quot;2&quot; | ''{{{umtlolo}}}''
|-
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | '''Ubuningi be sitjhaba'''
|-
| align=&quot;center&quot; colspan=&quot;2&quot; | {{{Ubuningi}}}
|-
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | '''Lapho batholakala ngobuningi'''
|-
| align=&quot;center&quot; colspan=&quot;2&quot; | {{{Amaphrovinci}}}
|-
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | '''Amalimi esitjhaba'''
|-
| align=&quot;center&quot; colspan=&quot;2&quot; | {{{Amalimi}}}
|-
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | '''Isiqhema sekolo'''
|-
| align=&quot;center&quot; colspan=&quot;2&quot; | {{{Ikolo}}}
|-
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | '''Ukuhlobana ngobutjhaba'''
|-
| align=&quot;center&quot; colspan=&quot;2&quot; | {{{Bahlobane}}}
|}
&lt;noinclude&gt;
&lt;pre&gt;
{{Ethnic group
|Ubutjhaba    = 
|isithombe    = 
|umtlolo      = 
|Ubuningi     = 
|Amaphrovinci = 
|Amalimi      = 
|Ikolo        = 
|Bahlobane    = 
}}
&lt;/pre&gt;
[[Mkhakha:Abantu]]
&lt;/noinclude&gt;</text>
      <sha1>oxqftqjainazw0vaw9z3dqy5u79dvtq</sha1>
    </revision>
    <revision>
      <id>295</id>
      <parentid>294</parentid>
      <timestamp>2016-02-25T19:13:44Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>295</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1262" sha1="tf5zrdmbaza1s98n35ha9hvzwfodw3i" xml:space="preserve">{| class=&quot;toccolours&quot; style=&quot;float:right; width:280px; margin-left: 1em; font-size: 85%;&quot;
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | &lt;big&gt;'''{{{Ubutjhaba}}}'''&lt;/big&gt;
|-
| align=&quot;center&quot; colspan=&quot;2&quot;  |
{|
| align=&quot;center&quot; width=&quot;120&quot;  | [[Isimumathi:{{{isithombe}}}|220px]]
|}
|-
| align=&quot;center&quot; colspan=&quot;2&quot; | ''{{{umtlolo}}}''
|-
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | '''Ubuningi be sitjhaba'''
|-
| align=&quot;center&quot; colspan=&quot;2&quot; | {{{Ubuningi}}}
|-
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | '''Lapho batholakala ngobuningi'''
|-
| align=&quot;center&quot; colspan=&quot;2&quot; | {{{Amaphrovinci}}}
|-
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | '''Amalimi esitjhaba'''
|-
| align=&quot;center&quot; colspan=&quot;2&quot; | {{{Amalimi}}}
|-
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | '''Isiqhema sekolo'''
|-
| align=&quot;center&quot; colspan=&quot;2&quot; | {{{Ikolo}}}
|-
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | '''Ukuhlobana ngobutjhaba'''
|-
| align=&quot;center&quot; colspan=&quot;2&quot; | {{{Bahlobane}}}
|}
&lt;noinclude&gt;
&lt;pre&gt;
{{Ethnic group
|Ubutjhaba    = 
|isithombe    = 
|umtlolo      = 
|Ubuningi     = 
|Amaphrovinci = 
|Amalimi      = 
|Ikolo        = 
|Bahlobane    = 
}}
&lt;/pre&gt;
[[Mkhakha:Abantu]]
&lt;/noinclude&gt;</text>
      <sha1>tf5zrdmbaza1s98n35ha9hvzwfodw3i</sha1>
    </revision>
    <revision>
      <id>296</id>
      <parentid>295</parentid>
      <timestamp>2024-10-14T13:46:19Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>4 revisions imported</comment>
      <origin>295</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1262" sha1="tf5zrdmbaza1s98n35ha9hvzwfodw3i" xml:space="preserve">{| class=&quot;toccolours&quot; style=&quot;float:right; width:280px; margin-left: 1em; font-size: 85%;&quot;
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | &lt;big&gt;'''{{{Ubutjhaba}}}'''&lt;/big&gt;
|-
| align=&quot;center&quot; colspan=&quot;2&quot;  |
{|
| align=&quot;center&quot; width=&quot;120&quot;  | [[Isimumathi:{{{isithombe}}}|220px]]
|}
|-
| align=&quot;center&quot; colspan=&quot;2&quot; | ''{{{umtlolo}}}''
|-
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | '''Ubuningi be sitjhaba'''
|-
| align=&quot;center&quot; colspan=&quot;2&quot; | {{{Ubuningi}}}
|-
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | '''Lapho batholakala ngobuningi'''
|-
| align=&quot;center&quot; colspan=&quot;2&quot; | {{{Amaphrovinci}}}
|-
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | '''Amalimi esitjhaba'''
|-
| align=&quot;center&quot; colspan=&quot;2&quot; | {{{Amalimi}}}
|-
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | '''Isiqhema sekolo'''
|-
| align=&quot;center&quot; colspan=&quot;2&quot; | {{{Ikolo}}}
|-
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | '''Ukuhlobana ngobutjhaba'''
|-
| align=&quot;center&quot; colspan=&quot;2&quot; | {{{Bahlobane}}}
|}
&lt;noinclude&gt;
&lt;pre&gt;
{{Ethnic group
|Ubutjhaba    = 
|isithombe    = 
|umtlolo      = 
|Ubuningi     = 
|Amaphrovinci = 
|Amalimi      = 
|Ikolo        = 
|Bahlobane    = 
}}
&lt;/pre&gt;
[[Mkhakha:Abantu]]
&lt;/noinclude&gt;</text>
      <sha1>tf5zrdmbaza1s98n35ha9hvzwfodw3i</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Hide in print</title>
    <ns>10</ns>
    <id>74</id>
    <revision>
      <id>297</id>
      <timestamp>2014-09-04T16:20:04Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;&lt;includeonly&gt;{{{1|}}}&lt;/includeonly&gt;&lt;noinclude&gt; {{documentation}} [[Mkhakha:Exclude in print|!]] &lt;/noinclude&gt;&quot;</comment>
      <origin>297</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="108" sha1="fypkwrctbyrm3kiclso5k7gl9505ghq" xml:space="preserve">&lt;includeonly&gt;{{{1|}}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{documentation}}
[[Mkhakha:Exclude in print|!]]
&lt;/noinclude&gt;</text>
      <sha1>fypkwrctbyrm3kiclso5k7gl9505ghq</sha1>
    </revision>
    <revision>
      <id>298</id>
      <parentid>297</parentid>
      <timestamp>2019-12-06T16:30:58Z</timestamp>
      <contributor>
        <username>incubator&gt;Adithyak1997</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Added a prefix</comment>
      <origin>298</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="108" sha1="9fydqxab8pz8c7ka7s0m5hkla03jc1i" xml:space="preserve">&lt;includeonly&gt;{{{1|}}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{Documentation}}
[[Mkhakha:Exclude in print|!]]
&lt;/noinclude&gt;</text>
      <sha1>9fydqxab8pz8c7ka7s0m5hkla03jc1i</sha1>
    </revision>
    <revision>
      <id>299</id>
      <parentid>298</parentid>
      <timestamp>2024-10-14T13:46:19Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>298</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="108" sha1="9fydqxab8pz8c7ka7s0m5hkla03jc1i" xml:space="preserve">&lt;includeonly&gt;{{{1|}}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{Documentation}}
[[Mkhakha:Exclude in print|!]]
&lt;/noinclude&gt;</text>
      <sha1>9fydqxab8pz8c7ka7s0m5hkla03jc1i</sha1>
    </revision>
    <revision>
      <id>386</id>
      <parentid>297</parentid>
      <timestamp>2014-09-04T16:20:43Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>#REDIRECT</comment>
      <origin>386</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="49" sha1="jfiz1rk3xq1eymmzvnkffbgdy6ju5d5" xml:space="preserve">#REDIRECT [[Umhlahlandlelasakhiwo:Hide_in_print]]</text>
      <sha1>jfiz1rk3xq1eymmzvnkffbgdy6ju5d5</sha1>
    </revision>
    <revision>
      <id>387</id>
      <parentid>299</parentid>
      <timestamp>2024-10-14T13:46:25Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>298</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="108" sha1="9fydqxab8pz8c7ka7s0m5hkla03jc1i" xml:space="preserve">&lt;includeonly&gt;{{{1|}}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{Documentation}}
[[Mkhakha:Exclude in print|!]]
&lt;/noinclude&gt;</text>
      <sha1>9fydqxab8pz8c7ka7s0m5hkla03jc1i</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:ICD10</title>
    <ns>10</ns>
    <id>75</id>
    <revision>
      <id>300</id>
      <timestamp>2014-09-04T16:02:04Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;{{#ifeq: {{{1|}}} | H | {{#ifexpr: {{{2|-1}}} &gt;= 0 and {{{2|}}} &lt; 60   | ICD-10 Chapter VII: Diseases of the eye, adnexa   | {{#ifexpr: {{{2|-1}}} &gt;= 60     | ICD-10 Chapter...&quot;</comment>
      <origin>300</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="538" sha1="qu6gervjpcg01kjw33s2fk73fzv2nfu" xml:space="preserve">[[{{#ifeq: {{{1|}}} | H
| {{#ifexpr: {{{2|-1}}} &gt;= 0 and {{{2|}}} &lt; 60
  | ICD-10 Chapter VII: Diseases of the eye, adnexa
  | {{#ifexpr: {{{2|-1}}} &gt;= 60
    | ICD-10 Chapter VIII: Diseases of the ear and mastoid process
    | ICD-10 Chapter H
    }}
  }}
| ICD-10 Chapter {{{1}}}}}|{{{1}}}]][http://apps.who.int/classifications/icd10/browse/2010/en#/{{{1}}}{{{2}}}{{#if:{{{3|}}}|.{{{3}}}}} {{{2}}}{{#if:{{{3|}}}|.{{{3}}}}}]&lt;noinclude&gt;

{{Documentation}}
&lt;!-- Add categories and interwikis to the /doc subpage, not here! --&gt;
&lt;/noinclude&gt;</text>
      <sha1>qu6gervjpcg01kjw33s2fk73fzv2nfu</sha1>
    </revision>
    <revision>
      <id>301</id>
      <parentid>300</parentid>
      <timestamp>2019-12-02T16:06:46Z</timestamp>
      <contributor>
        <username>incubator&gt;Adithyak1997</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Added a prefix</comment>
      <origin>300</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="538" sha1="qu6gervjpcg01kjw33s2fk73fzv2nfu" xml:space="preserve">[[{{#ifeq: {{{1|}}} | H
| {{#ifexpr: {{{2|-1}}} &gt;= 0 and {{{2|}}} &lt; 60
  | ICD-10 Chapter VII: Diseases of the eye, adnexa
  | {{#ifexpr: {{{2|-1}}} &gt;= 60
    | ICD-10 Chapter VIII: Diseases of the ear and mastoid process
    | ICD-10 Chapter H
    }}
  }}
| ICD-10 Chapter {{{1}}}}}|{{{1}}}]][http://apps.who.int/classifications/icd10/browse/2010/en#/{{{1}}}{{{2}}}{{#if:{{{3|}}}|.{{{3}}}}} {{{2}}}{{#if:{{{3|}}}|.{{{3}}}}}]&lt;noinclude&gt;

{{Documentation}}
&lt;!-- Add categories and interwikis to the /doc subpage, not here! --&gt;
&lt;/noinclude&gt;</text>
      <sha1>qu6gervjpcg01kjw33s2fk73fzv2nfu</sha1>
    </revision>
    <revision>
      <id>302</id>
      <parentid>301</parentid>
      <timestamp>2024-10-14T13:46:20Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>300</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="538" sha1="qu6gervjpcg01kjw33s2fk73fzv2nfu" xml:space="preserve">[[{{#ifeq: {{{1|}}} | H
| {{#ifexpr: {{{2|-1}}} &gt;= 0 and {{{2|}}} &lt; 60
  | ICD-10 Chapter VII: Diseases of the eye, adnexa
  | {{#ifexpr: {{{2|-1}}} &gt;= 60
    | ICD-10 Chapter VIII: Diseases of the ear and mastoid process
    | ICD-10 Chapter H
    }}
  }}
| ICD-10 Chapter {{{1}}}}}|{{{1}}}]][http://apps.who.int/classifications/icd10/browse/2010/en#/{{{1}}}{{{2}}}{{#if:{{{3|}}}|.{{{3}}}}} {{{2}}}{{#if:{{{3|}}}|.{{{3}}}}}]&lt;noinclude&gt;

{{Documentation}}
&lt;!-- Add categories and interwikis to the /doc subpage, not here! --&gt;
&lt;/noinclude&gt;</text>
      <sha1>qu6gervjpcg01kjw33s2fk73fzv2nfu</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:ICD9</title>
    <ns>10</ns>
    <id>76</id>
    <revision>
      <id>303</id>
      <timestamp>2014-09-04T16:02:23Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;[http://www.icd9data.com/getICD9Code.ashx?icd9={{{1}}} {{{1}}}]&lt;noinclude&gt; {{documentation}} &lt;/noinclude&gt;&quot;</comment>
      <origin>303</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="105" sha1="inlm7lg4izfzyun1823ezel8jsddgvh" xml:space="preserve">[http://www.icd9data.com/getICD9Code.ashx?icd9={{{1}}} {{{1}}}]&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>inlm7lg4izfzyun1823ezel8jsddgvh</sha1>
    </revision>
    <revision>
      <id>304</id>
      <parentid>303</parentid>
      <timestamp>2019-12-05T18:00:03Z</timestamp>
      <contributor>
        <username>incubator&gt;Adithyak1997</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Added a prefix</comment>
      <origin>304</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="105" sha1="7862yarzx3ir7zon2m18zx1sdhsh6oh" xml:space="preserve">[http://www.icd9data.com/getICD9Code.ashx?icd9={{{1}}} {{{1}}}]&lt;noinclude&gt;
{{Documentation}}
&lt;/noinclude&gt;</text>
      <sha1>7862yarzx3ir7zon2m18zx1sdhsh6oh</sha1>
    </revision>
    <revision>
      <id>305</id>
      <parentid>304</parentid>
      <timestamp>2024-10-14T13:46:20Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>304</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="105" sha1="7862yarzx3ir7zon2m18zx1sdhsh6oh" xml:space="preserve">[http://www.icd9data.com/getICD9Code.ashx?icd9={{{1}}} {{{1}}}]&lt;noinclude&gt;
{{Documentation}}
&lt;/noinclude&gt;</text>
      <sha1>7862yarzx3ir7zon2m18zx1sdhsh6oh</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Icon</title>
    <ns>10</ns>
    <id>77</id>
    <revision>
      <id>306</id>
      <timestamp>2019-01-11T15:35:52Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;File:{{#switch:{{lc:{{{class|{{{1|}}}}}}}}  |fa             = Featured article star.svg               {{!}} Featured article  |far            = Cscr-star piece.png...&quot;</comment>
      <origin>306</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7377" sha1="8jmsy7v2j59nucinglj9d2dgehyodx3" xml:space="preserve">[[Isimumathi:{{#switch:{{lc:{{{class|{{{1|}}}}}}}}
 |fa             = Featured article star.svg               {{!}} Featured article
 |far            = Cscr-star piece.png                     {{!}} Featured article review
 |farc           = Cscr-star piece.png                     {{!}} Featured article removal candidate
 |ffa|dfa        = Featured article star - cross.svg       {{!}} Former featured article
 |fac|fan        = Cscr-candidate.svg                      {{!}} Featured article candidate
 |ffac|nofa      = Featured article star - cross.svg       {{!}} Failed featured article candidate
 |fl             = Featured article star.svg               {{!}} Featured list
 |flrc|flr       = Cscr-star piece.png                     {{!}} Featured list removal candidate
 |ffl|dfl        = Cscr-featured-strike.svg                {{!}} Former featured list
 |flc|fln        = Cscr-candidate.svg                      {{!}} Featured list candidate
 |fflc|nofl      = Cscr-former.svg                         {{!}} Failed featured list candidate
 |a              = Symbol a class.svg                      {{!}} A-Class article
 |dac|daa        = Symbol unsupport A vote.svg             {{!}} Demoted A-Class article
 |acc|acn|aac    = A candidate.svg                         {{!}} A-Class article candidate
 |noac|faac      = Symbol unsupport A vote.svg             {{!}} Failed A-Class article candidate
 |ga             = Symbol support vote.svg                 {{!}} Good article
 |gar            = GA Candidate Neutral vote(ChaosNil).svg {{!}} Good article reassessment
 |dga            = Symbol unsupport vote.svg               {{!}} Delisted good article
 |gan|gac        = GA candidate.svg                        {{!}} Good article nominee
 |ga2            = Symbol neutral vote.svg                 {{!}} Good article, 2nd opinion
 |gah            = Symbol wait.svg                         {{!}} Good article on hold
 |fgan|noga|gaf|gf = Symbol oppose vote.svg                {{!}} Failed good article nominee
 |fp             = Cscr-featured.svg                       {{!}} Featured picture
 |ffp            = Cscr-former.svg                         {{!}} Former featured picture
 |vp             = ENWP VP Logo.svg                        {{!}} Valued picture
 |vpc            = Valued pics 1.svg                       {{!}} Valued picture candidate
 |fs             = Cscr-featured.svg                       {{!}} Featured sound
 |ffs            = Cscr-former.svg                         {{!}} Former featured sound
 |fsc            = Cscr-candidate.svg                      {{!}} Featured sound candidate
 |fpo            = Cscr-featured.svg                       {{!}} Featured portal
 |fpor           = Cscr-star piece.png                     {{!}} Featured portal review
 |ffpo           = Featured article star - cross.svg       {{!}} Former featured portal
 |fpoc           = Cscr-candidate.svg                      {{!}} Featured portal candidate
 |ft             = Cscr-featuredtopic.svg                  {{!}} Featured topic
 |ftrc           = Cscr-star piece.png                     {{!}} Featured topic removal candidate
 |fft|dft        = DFT candidate_cluster.svg               {{!}} Former featured topic
 |ftc|ftn        = FT candidate cluster.svg                {{!}} Featured topic candidate
 |gt             = Support cluster.svg                     {{!}} Good topic
 |gtrc           = Symbol unsupport vote.svg               {{!}} Good topic removal candidate
 |gtc|gtn        = GA candidate cluster.svg                {{!}} Good topic candidate
 |bplus|b+       = Symbol bplus class.svg                  {{!}} Bplus-Class article
 |b              = Symbol b class.svg                      {{!}} B-Class article
 |br|bcr         = Bclass-checklist.svg                    {{!}} B-Class review
 |c              = Symbol c class.svg                      {{!}} C-Class article
 |start          = Symbol start class.svg                  {{!}} Start-Class article
 |stub           = Symbol stub class.svg                   {{!}} Stub-Class article
 |list|comparison= Symbol list class.svg                   {{!}} List-Class article
 |no             = Crystal button cancel.svg               {{!}} Unknown-Class article
 |book           = Symbol book class2.svg                  {{!}} Wikipedia book
 |cat|categ
 |category       = Folder Hexagonal Icon.svg               {{!}} Category
 |dab|disamb
 |disambig
 |disambiguation = Symbol dab class.svg                    {{!}} Disambiguation page
 |image|file     = Video-x-generic.svg                     {{!}} File
 |portal         = Portal-puzzle.svg                       {{!}} Portal
 |project        = Symbol information vote.svg             {{!}} Project page
 |red|redir
 |redirect       = Symbol redirect vote2.svg               {{!}} Redirect
 |temp|templ
 |template       = Symbol template class.svg               {{!}} Template
 |essay          = Essay.svg                               {{!}} Essay
 |na             = Symbol neutral vote.svg                 {{!}} Non-article page
 |aa             = Yes check.svg                           {{!}} Audited article of limited subject matter
 |da             = Symbol oppose vote.svg                  {{!}} Demoted article
 |dyk            = Symbol question.svg                     {{!}} Did You Know?
 |dyk2           = DYK questionmark icon.svg               {{!}} Did You Know?
 |pr             = Nuvola apps kedit.png                   {{!}} Peer review
 |ppr            = Nuvola apps kedit.png                   {{!}} Portal peer review
 |q|question     = Symbol question.svg                     {{!}} Question
 |qi             = Quality images logo.svg                 {{!}} Quality image on Wikimedia Commons
 |vi             = Valued image seal.svg                   {{!}} Valued image on Wikimedia Commons
 |tfa            = Wikipedia-logo.svg                      {{!}} Today's Featured Article
 |itn            = Globe current.svg                       {{!}} In The News
 |otd            = Nuvola apps date.svg                    {{!}} On This Day
 |wikiproject    = People icon.svg                         {{!}} WikiProject
 |wikipedia      = Wikipedia-logo.svg                      {{!}} Wikipedia page
 |commons        = Commons-logo.svg                        {{!}} Commons page
 |wikiquote      = Wikiquote-logo.svg                      {{!}} Wikiquote page
 |wikiversity    = Wikiversity-logo.svg                    {{!}} Wikiversity page
 |wikibooks      = Wikibooks-logo.svg                      {{!}} Wikibooks page
 |wikisource     = Wikisource-logo.svg                     {{!}} Wikisource page
 |wiktionary     = Wiktionary-logo.svg                     {{!}} Wiktionary page
 |wikinews       = Wikinews-logo.svg                       {{!}} Wikinews page
 |wikispecies    = Wikispecies-logo.svg                    {{!}} Wikispecies page
 |wikidata       = Wikidata-logo.svg                       {{!}} Wikidata page
 |wikivoyage     = Wikivoyage-logo.svg                     {{!}} Wikivoyage page
 |meta           = Wikimedia Community Logo.svg            {{!}} Meta-wiki page
 |four           = Four Award.svg                          {{!}} Four Award
 |million        = Million award logo.svg                  {{!}} Million Award
 |#default       = Symbol question.svg
}}|{{{size|16x16px}}}|link=]]&lt;noinclude&gt;

&lt;/noinclude&gt;</text>
      <sha1>8jmsy7v2j59nucinglj9d2dgehyodx3</sha1>
    </revision>
    <revision>
      <id>307</id>
      <parentid>306</parentid>
      <timestamp>2024-10-14T13:46:20Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>306</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7377" sha1="8jmsy7v2j59nucinglj9d2dgehyodx3" xml:space="preserve">[[Isimumathi:{{#switch:{{lc:{{{class|{{{1|}}}}}}}}
 |fa             = Featured article star.svg               {{!}} Featured article
 |far            = Cscr-star piece.png                     {{!}} Featured article review
 |farc           = Cscr-star piece.png                     {{!}} Featured article removal candidate
 |ffa|dfa        = Featured article star - cross.svg       {{!}} Former featured article
 |fac|fan        = Cscr-candidate.svg                      {{!}} Featured article candidate
 |ffac|nofa      = Featured article star - cross.svg       {{!}} Failed featured article candidate
 |fl             = Featured article star.svg               {{!}} Featured list
 |flrc|flr       = Cscr-star piece.png                     {{!}} Featured list removal candidate
 |ffl|dfl        = Cscr-featured-strike.svg                {{!}} Former featured list
 |flc|fln        = Cscr-candidate.svg                      {{!}} Featured list candidate
 |fflc|nofl      = Cscr-former.svg                         {{!}} Failed featured list candidate
 |a              = Symbol a class.svg                      {{!}} A-Class article
 |dac|daa        = Symbol unsupport A vote.svg             {{!}} Demoted A-Class article
 |acc|acn|aac    = A candidate.svg                         {{!}} A-Class article candidate
 |noac|faac      = Symbol unsupport A vote.svg             {{!}} Failed A-Class article candidate
 |ga             = Symbol support vote.svg                 {{!}} Good article
 |gar            = GA Candidate Neutral vote(ChaosNil).svg {{!}} Good article reassessment
 |dga            = Symbol unsupport vote.svg               {{!}} Delisted good article
 |gan|gac        = GA candidate.svg                        {{!}} Good article nominee
 |ga2            = Symbol neutral vote.svg                 {{!}} Good article, 2nd opinion
 |gah            = Symbol wait.svg                         {{!}} Good article on hold
 |fgan|noga|gaf|gf = Symbol oppose vote.svg                {{!}} Failed good article nominee
 |fp             = Cscr-featured.svg                       {{!}} Featured picture
 |ffp            = Cscr-former.svg                         {{!}} Former featured picture
 |vp             = ENWP VP Logo.svg                        {{!}} Valued picture
 |vpc            = Valued pics 1.svg                       {{!}} Valued picture candidate
 |fs             = Cscr-featured.svg                       {{!}} Featured sound
 |ffs            = Cscr-former.svg                         {{!}} Former featured sound
 |fsc            = Cscr-candidate.svg                      {{!}} Featured sound candidate
 |fpo            = Cscr-featured.svg                       {{!}} Featured portal
 |fpor           = Cscr-star piece.png                     {{!}} Featured portal review
 |ffpo           = Featured article star - cross.svg       {{!}} Former featured portal
 |fpoc           = Cscr-candidate.svg                      {{!}} Featured portal candidate
 |ft             = Cscr-featuredtopic.svg                  {{!}} Featured topic
 |ftrc           = Cscr-star piece.png                     {{!}} Featured topic removal candidate
 |fft|dft        = DFT candidate_cluster.svg               {{!}} Former featured topic
 |ftc|ftn        = FT candidate cluster.svg                {{!}} Featured topic candidate
 |gt             = Support cluster.svg                     {{!}} Good topic
 |gtrc           = Symbol unsupport vote.svg               {{!}} Good topic removal candidate
 |gtc|gtn        = GA candidate cluster.svg                {{!}} Good topic candidate
 |bplus|b+       = Symbol bplus class.svg                  {{!}} Bplus-Class article
 |b              = Symbol b class.svg                      {{!}} B-Class article
 |br|bcr         = Bclass-checklist.svg                    {{!}} B-Class review
 |c              = Symbol c class.svg                      {{!}} C-Class article
 |start          = Symbol start class.svg                  {{!}} Start-Class article
 |stub           = Symbol stub class.svg                   {{!}} Stub-Class article
 |list|comparison= Symbol list class.svg                   {{!}} List-Class article
 |no             = Crystal button cancel.svg               {{!}} Unknown-Class article
 |book           = Symbol book class2.svg                  {{!}} Wikipedia book
 |cat|categ
 |category       = Folder Hexagonal Icon.svg               {{!}} Category
 |dab|disamb
 |disambig
 |disambiguation = Symbol dab class.svg                    {{!}} Disambiguation page
 |image|file     = Video-x-generic.svg                     {{!}} File
 |portal         = Portal-puzzle.svg                       {{!}} Portal
 |project        = Symbol information vote.svg             {{!}} Project page
 |red|redir
 |redirect       = Symbol redirect vote2.svg               {{!}} Redirect
 |temp|templ
 |template       = Symbol template class.svg               {{!}} Template
 |essay          = Essay.svg                               {{!}} Essay
 |na             = Symbol neutral vote.svg                 {{!}} Non-article page
 |aa             = Yes check.svg                           {{!}} Audited article of limited subject matter
 |da             = Symbol oppose vote.svg                  {{!}} Demoted article
 |dyk            = Symbol question.svg                     {{!}} Did You Know?
 |dyk2           = DYK questionmark icon.svg               {{!}} Did You Know?
 |pr             = Nuvola apps kedit.png                   {{!}} Peer review
 |ppr            = Nuvola apps kedit.png                   {{!}} Portal peer review
 |q|question     = Symbol question.svg                     {{!}} Question
 |qi             = Quality images logo.svg                 {{!}} Quality image on Wikimedia Commons
 |vi             = Valued image seal.svg                   {{!}} Valued image on Wikimedia Commons
 |tfa            = Wikipedia-logo.svg                      {{!}} Today's Featured Article
 |itn            = Globe current.svg                       {{!}} In The News
 |otd            = Nuvola apps date.svg                    {{!}} On This Day
 |wikiproject    = People icon.svg                         {{!}} WikiProject
 |wikipedia      = Wikipedia-logo.svg                      {{!}} Wikipedia page
 |commons        = Commons-logo.svg                        {{!}} Commons page
 |wikiquote      = Wikiquote-logo.svg                      {{!}} Wikiquote page
 |wikiversity    = Wikiversity-logo.svg                    {{!}} Wikiversity page
 |wikibooks      = Wikibooks-logo.svg                      {{!}} Wikibooks page
 |wikisource     = Wikisource-logo.svg                     {{!}} Wikisource page
 |wiktionary     = Wiktionary-logo.svg                     {{!}} Wiktionary page
 |wikinews       = Wikinews-logo.svg                       {{!}} Wikinews page
 |wikispecies    = Wikispecies-logo.svg                    {{!}} Wikispecies page
 |wikidata       = Wikidata-logo.svg                       {{!}} Wikidata page
 |wikivoyage     = Wikivoyage-logo.svg                     {{!}} Wikivoyage page
 |meta           = Wikimedia Community Logo.svg            {{!}} Meta-wiki page
 |four           = Four Award.svg                          {{!}} Four Award
 |million        = Million award logo.svg                  {{!}} Million Award
 |#default       = Symbol question.svg
}}|{{{size|16x16px}}}|link=]]&lt;noinclude&gt;

&lt;/noinclude&gt;</text>
      <sha1>8jmsy7v2j59nucinglj9d2dgehyodx3</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Image class names</title>
    <ns>10</ns>
    <id>78</id>
    <revision>
      <id>308</id>
      <timestamp>2016-02-22T13:56:22Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;&lt;noinclude&gt; &lt;/noinclude&gt;{{#switch:{{ucfirst:{{{1}}}}}|Replace this image male.svg|Replace this image female.svg|Replace this image1.svg|Replace this imageb.svg|Image:Replace...&quot;</comment>
      <origin>308</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="420" sha1="alon77ny0lw4atjdqtheq7ahos7brzb" xml:space="preserve">&lt;noinclude&gt;
&lt;/noinclude&gt;{{#switch:{{ucfirst:{{{1}}}}}|Replace this image male.svg|Replace this image female.svg|Replace this image1.svg|Replace this imageb.svg|[[Isimumathi:Replace this imageb.svg|150px]]|Replace this image male.svg|[[Isimumathi:Replace this image female.svg|150px]] &lt;!-- Only freely-licensed images may be used to depict living people.  See [[WP:NONFREE]].  --&gt;=metadata dummy}}&lt;noinclude&gt;
&lt;/noinclude&gt;</text>
      <sha1>alon77ny0lw4atjdqtheq7ahos7brzb</sha1>
    </revision>
    <revision>
      <id>309</id>
      <parentid>308</parentid>
      <timestamp>2024-10-14T13:46:20Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>308</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="420" sha1="alon77ny0lw4atjdqtheq7ahos7brzb" xml:space="preserve">&lt;noinclude&gt;
&lt;/noinclude&gt;{{#switch:{{ucfirst:{{{1}}}}}|Replace this image male.svg|Replace this image female.svg|Replace this image1.svg|Replace this imageb.svg|[[Isimumathi:Replace this imageb.svg|150px]]|Replace this image male.svg|[[Isimumathi:Replace this image female.svg|150px]] &lt;!-- Only freely-licensed images may be used to depict living people.  See [[WP:NONFREE]].  --&gt;=metadata dummy}}&lt;noinclude&gt;
&lt;/noinclude&gt;</text>
      <sha1>alon77ny0lw4atjdqtheq7ahos7brzb</sha1>
    </revision>
    <revision>
      <id>388</id>
      <parentid>308</parentid>
      <timestamp>2016-02-22T14:16:19Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;&lt;noinclude&gt;  &lt;/noinclude&gt;{{#switch:{{ucfirst:{{{1}}}}}|Replace this image male.svg|Replace this image female.svg|Replace this image1.svg|Replace this imageb.svg|Image:Replac...&quot;</comment>
      <origin>388</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="421" sha1="m55v5kfm4n4m2y4l49ps3jwg8n63iek" xml:space="preserve">&lt;noinclude&gt;

&lt;/noinclude&gt;{{#switch:{{ucfirst:{{{1}}}}}|Replace this image male.svg|Replace this image female.svg|Replace this image1.svg|Replace this imageb.svg|[[Isimumathi:Replace this imageb.svg|150px]]|Replace this image male.svg|[[Isimumathi:Replace this image female.svg|150px]] &lt;!-- Only freely-licensed images may be used to depict living people.  See [[WP:NONFREE]].  --&gt;=metadata dummy}}&lt;noinclude&gt;
&lt;/noinclude&gt;</text>
      <sha1>m55v5kfm4n4m2y4l49ps3jwg8n63iek</sha1>
    </revision>
    <revision>
      <id>389</id>
      <parentid>309</parentid>
      <timestamp>2024-10-14T13:46:25Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>308</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="420" sha1="alon77ny0lw4atjdqtheq7ahos7brzb" xml:space="preserve">&lt;noinclude&gt;
&lt;/noinclude&gt;{{#switch:{{ucfirst:{{{1}}}}}|Replace this image male.svg|Replace this image female.svg|Replace this image1.svg|Replace this imageb.svg|[[Isimumathi:Replace this imageb.svg|150px]]|Replace this image male.svg|[[Isimumathi:Replace this image female.svg|150px]] &lt;!-- Only freely-licensed images may be used to depict living people.  See [[WP:NONFREE]].  --&gt;=metadata dummy}}&lt;noinclude&gt;
&lt;/noinclude&gt;</text>
      <sha1>alon77ny0lw4atjdqtheq7ahos7brzb</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Infobox</title>
    <ns>10</ns>
    <id>79</id>
    <revision>
      <id>310</id>
      <timestamp>2016-02-22T13:45:57Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;{{#invoke:Infobox|infobox}}&lt;noinclude&gt;  &lt;!-- Categories go in the /doc subpage, and interwikis go in Wikidata. --&gt; &lt;/noinclude&gt;&quot;</comment>
      <origin>310</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="127" sha1="1y1i092vweoykeg31cfnti68cioaenn" xml:space="preserve">{{#invoke:Infobox|infobox}}&lt;noinclude&gt;

&lt;!-- Categories go in the /doc subpage, and interwikis go in Wikidata. --&gt;
&lt;/noinclude&gt;</text>
      <sha1>1y1i092vweoykeg31cfnti68cioaenn</sha1>
    </revision>
    <revision>
      <id>311</id>
      <parentid>310</parentid>
      <timestamp>2016-02-22T13:51:21Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>310</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="127" sha1="1y1i092vweoykeg31cfnti68cioaenn" xml:space="preserve">{{#invoke:Infobox|infobox}}&lt;noinclude&gt;

&lt;!-- Categories go in the /doc subpage, and interwikis go in Wikidata. --&gt;
&lt;/noinclude&gt;</text>
      <sha1>1y1i092vweoykeg31cfnti68cioaenn</sha1>
    </revision>
    <revision>
      <id>312</id>
      <parentid>311</parentid>
      <timestamp>2024-10-14T13:46:21Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>310</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="127" sha1="1y1i092vweoykeg31cfnti68cioaenn" xml:space="preserve">{{#invoke:Infobox|infobox}}&lt;noinclude&gt;

&lt;!-- Categories go in the /doc subpage, and interwikis go in Wikidata. --&gt;
&lt;/noinclude&gt;</text>
      <sha1>1y1i092vweoykeg31cfnti68cioaenn</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Infobox Website</title>
    <ns>10</ns>
    <id>80</id>
    <revision>
      <id>313</id>
      <timestamp>2019-01-13T17:04:22Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;{| class=&quot;infobox borderless&quot; summary=&quot;Template:Infobox Website&quot; style=&quot;float:right; clear:right; font-size:90%; text-align:left; width:24em;&quot; ! colspan=&quot;2&quot; style=&quot;text-align:...&quot;</comment>
      <origin>313</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1798" sha1="ss4bw6rzofdcg6b7x4wu6183iukcxgu" xml:space="preserve">{| class=&quot;infobox borderless&quot; summary=&quot;Template:Infobox Website&quot; style=&quot;float:right; clear:right; font-size:90%; text-align:left; width:24em;&quot;
! colspan=&quot;2&quot; style=&quot;text-align:center; font-size:125%;&quot; | {{{websitename|{{{name|{{PAGENAME}}}}}}}}
|-
{{#if:{{{websitelogo|{{{logo|}}}}}}|
{{!}} colspan=&quot;2&quot; style=&quot;text-align:center;&quot; {{!}} {{{websitelogo|{{{logo}}}}}}
{{!}}-
}}
{{#ifeq:{{{collapsible|}}}|yes|&lt;!-- then --&gt;
{{!}} colspan=&quot;2&quot; {{!}}
{{hidden|Screenshot|{{{screenshot}}}{{#if:{{{caption|}}}|&lt;br /&gt;{{{caption}}}}}|bg1=#ccccff|ta2=center}}
{{!}}-
|&lt;!-- else --&gt;
{{#if:{{{screenshot|}}}|
{{!}} colspan=&quot;2&quot; style=&quot;text-align: center;&quot; {{!}} {{{screenshot}}}{{#if:{{{caption|}}}|&lt;br /&gt;{{{caption}}}}}
{{!}}-
}}
}}
{{#if:{{{url|}}}|
! [[Uniform Resource Locator|URL]]
{{!}} {{{url}}}
{{!}}-
}}
{{#if:{{{slogan|}}}|
! [[Xologeni]]
{{!}} {{{slogan}}}
{{!}}-
}}
{{#if:{{{alexa|}}}|
! Nkutlunya wa [[Alexa Internet|Alexa]]
{{!}} {{{alexa}}}
{{!}}-
}}
{{#if:{{{commercial|}}}|
! Ku bindzula?
{{!}} {{{commercial}}}
{{!}}-
}}
{{#if:{{{type|}}}|
! Muxaka wa tluka
{{!}} {{{type}}}
{{!}}-
}}
{{#if:{{{reg|{{{registration|}}}}}}|
! Vutsarisi
{{!}} {{{reg|{{{registration}}}}}}
{{!}}-
}}
{{#if:{{{language|}}}|
! [[Natural language|Tindzimi]] leti ngakona
{{!}} {{{language|}}}
{{!}}-
}}
{{#if:{{{owner|}}}|
! Nwini
{{!}} {{{owner}}}
{{!}}-
}}
{{#if:{{{author|}}}|
! Vatumbuluxi
{{!}} {{{author}}}
{{!}}-
}}
{{#if:{{{date_of_launch|{{{launch date|}}}}}}|
! Ri pfuriwa
{{!}} {{{date_of_launch|{{{launch date}}}}}}
{{!}}-
}}
{{#if:{{{rev|{{{revenue|}}}}}}|
! Mali
{{!}} {{{rev|{{{revenue}}}}}}
{{!}}-
}}
{{#if:{{{current_status|{{{current status|}}}}}}|
! Xiyimo xa sweswi-nyana
{{!}} {{{current_status|{{{current status}}}}}}
{{!}}-
}}
|}&lt;noinclude&gt;
{{pp-template|small=yes}}
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>ss4bw6rzofdcg6b7x4wu6183iukcxgu</sha1>
    </revision>
    <revision>
      <id>314</id>
      <parentid>313</parentid>
      <timestamp>2019-01-13T17:04:58Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>313</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1798" sha1="ss4bw6rzofdcg6b7x4wu6183iukcxgu" xml:space="preserve">{| class=&quot;infobox borderless&quot; summary=&quot;Template:Infobox Website&quot; style=&quot;float:right; clear:right; font-size:90%; text-align:left; width:24em;&quot;
! colspan=&quot;2&quot; style=&quot;text-align:center; font-size:125%;&quot; | {{{websitename|{{{name|{{PAGENAME}}}}}}}}
|-
{{#if:{{{websitelogo|{{{logo|}}}}}}|
{{!}} colspan=&quot;2&quot; style=&quot;text-align:center;&quot; {{!}} {{{websitelogo|{{{logo}}}}}}
{{!}}-
}}
{{#ifeq:{{{collapsible|}}}|yes|&lt;!-- then --&gt;
{{!}} colspan=&quot;2&quot; {{!}}
{{hidden|Screenshot|{{{screenshot}}}{{#if:{{{caption|}}}|&lt;br /&gt;{{{caption}}}}}|bg1=#ccccff|ta2=center}}
{{!}}-
|&lt;!-- else --&gt;
{{#if:{{{screenshot|}}}|
{{!}} colspan=&quot;2&quot; style=&quot;text-align: center;&quot; {{!}} {{{screenshot}}}{{#if:{{{caption|}}}|&lt;br /&gt;{{{caption}}}}}
{{!}}-
}}
}}
{{#if:{{{url|}}}|
! [[Uniform Resource Locator|URL]]
{{!}} {{{url}}}
{{!}}-
}}
{{#if:{{{slogan|}}}|
! [[Xologeni]]
{{!}} {{{slogan}}}
{{!}}-
}}
{{#if:{{{alexa|}}}|
! Nkutlunya wa [[Alexa Internet|Alexa]]
{{!}} {{{alexa}}}
{{!}}-
}}
{{#if:{{{commercial|}}}|
! Ku bindzula?
{{!}} {{{commercial}}}
{{!}}-
}}
{{#if:{{{type|}}}|
! Muxaka wa tluka
{{!}} {{{type}}}
{{!}}-
}}
{{#if:{{{reg|{{{registration|}}}}}}|
! Vutsarisi
{{!}} {{{reg|{{{registration}}}}}}
{{!}}-
}}
{{#if:{{{language|}}}|
! [[Natural language|Tindzimi]] leti ngakona
{{!}} {{{language|}}}
{{!}}-
}}
{{#if:{{{owner|}}}|
! Nwini
{{!}} {{{owner}}}
{{!}}-
}}
{{#if:{{{author|}}}|
! Vatumbuluxi
{{!}} {{{author}}}
{{!}}-
}}
{{#if:{{{date_of_launch|{{{launch date|}}}}}}|
! Ri pfuriwa
{{!}} {{{date_of_launch|{{{launch date}}}}}}
{{!}}-
}}
{{#if:{{{rev|{{{revenue|}}}}}}|
! Mali
{{!}} {{{rev|{{{revenue}}}}}}
{{!}}-
}}
{{#if:{{{current_status|{{{current status|}}}}}}|
! Xiyimo xa sweswi-nyana
{{!}} {{{current_status|{{{current status}}}}}}
{{!}}-
}}
|}&lt;noinclude&gt;
{{pp-template|small=yes}}
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>ss4bw6rzofdcg6b7x4wu6183iukcxgu</sha1>
    </revision>
    <revision>
      <id>315</id>
      <parentid>314</parentid>
      <timestamp>2024-10-14T13:46:21Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>313</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1798" sha1="ss4bw6rzofdcg6b7x4wu6183iukcxgu" xml:space="preserve">{| class=&quot;infobox borderless&quot; summary=&quot;Template:Infobox Website&quot; style=&quot;float:right; clear:right; font-size:90%; text-align:left; width:24em;&quot;
! colspan=&quot;2&quot; style=&quot;text-align:center; font-size:125%;&quot; | {{{websitename|{{{name|{{PAGENAME}}}}}}}}
|-
{{#if:{{{websitelogo|{{{logo|}}}}}}|
{{!}} colspan=&quot;2&quot; style=&quot;text-align:center;&quot; {{!}} {{{websitelogo|{{{logo}}}}}}
{{!}}-
}}
{{#ifeq:{{{collapsible|}}}|yes|&lt;!-- then --&gt;
{{!}} colspan=&quot;2&quot; {{!}}
{{hidden|Screenshot|{{{screenshot}}}{{#if:{{{caption|}}}|&lt;br /&gt;{{{caption}}}}}|bg1=#ccccff|ta2=center}}
{{!}}-
|&lt;!-- else --&gt;
{{#if:{{{screenshot|}}}|
{{!}} colspan=&quot;2&quot; style=&quot;text-align: center;&quot; {{!}} {{{screenshot}}}{{#if:{{{caption|}}}|&lt;br /&gt;{{{caption}}}}}
{{!}}-
}}
}}
{{#if:{{{url|}}}|
! [[Uniform Resource Locator|URL]]
{{!}} {{{url}}}
{{!}}-
}}
{{#if:{{{slogan|}}}|
! [[Xologeni]]
{{!}} {{{slogan}}}
{{!}}-
}}
{{#if:{{{alexa|}}}|
! Nkutlunya wa [[Alexa Internet|Alexa]]
{{!}} {{{alexa}}}
{{!}}-
}}
{{#if:{{{commercial|}}}|
! Ku bindzula?
{{!}} {{{commercial}}}
{{!}}-
}}
{{#if:{{{type|}}}|
! Muxaka wa tluka
{{!}} {{{type}}}
{{!}}-
}}
{{#if:{{{reg|{{{registration|}}}}}}|
! Vutsarisi
{{!}} {{{reg|{{{registration}}}}}}
{{!}}-
}}
{{#if:{{{language|}}}|
! [[Natural language|Tindzimi]] leti ngakona
{{!}} {{{language|}}}
{{!}}-
}}
{{#if:{{{owner|}}}|
! Nwini
{{!}} {{{owner}}}
{{!}}-
}}
{{#if:{{{author|}}}|
! Vatumbuluxi
{{!}} {{{author}}}
{{!}}-
}}
{{#if:{{{date_of_launch|{{{launch date|}}}}}}|
! Ri pfuriwa
{{!}} {{{date_of_launch|{{{launch date}}}}}}
{{!}}-
}}
{{#if:{{{rev|{{{revenue|}}}}}}|
! Mali
{{!}} {{{rev|{{{revenue}}}}}}
{{!}}-
}}
{{#if:{{{current_status|{{{current status|}}}}}}|
! Xiyimo xa sweswi-nyana
{{!}} {{{current_status|{{{current status}}}}}}
{{!}}-
}}
|}&lt;noinclude&gt;
{{pp-template|small=yes}}
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>ss4bw6rzofdcg6b7x4wu6183iukcxgu</sha1>
    </revision>
    <revision>
      <id>390</id>
      <parentid>314</parentid>
      <timestamp>2019-01-13T17:07:17Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;{| class=&quot;infobox borderless&quot; summary=&quot;Template:Infobox Website&quot; style=&quot;float:right; clear:right; font-size:90%; text-align:left; width:24em;&quot; ! colspan=&quot;2&quot; style=&quot;text-align:...&quot;</comment>
      <origin>313</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1798" sha1="ss4bw6rzofdcg6b7x4wu6183iukcxgu" xml:space="preserve">{| class=&quot;infobox borderless&quot; summary=&quot;Template:Infobox Website&quot; style=&quot;float:right; clear:right; font-size:90%; text-align:left; width:24em;&quot;
! colspan=&quot;2&quot; style=&quot;text-align:center; font-size:125%;&quot; | {{{websitename|{{{name|{{PAGENAME}}}}}}}}
|-
{{#if:{{{websitelogo|{{{logo|}}}}}}|
{{!}} colspan=&quot;2&quot; style=&quot;text-align:center;&quot; {{!}} {{{websitelogo|{{{logo}}}}}}
{{!}}-
}}
{{#ifeq:{{{collapsible|}}}|yes|&lt;!-- then --&gt;
{{!}} colspan=&quot;2&quot; {{!}}
{{hidden|Screenshot|{{{screenshot}}}{{#if:{{{caption|}}}|&lt;br /&gt;{{{caption}}}}}|bg1=#ccccff|ta2=center}}
{{!}}-
|&lt;!-- else --&gt;
{{#if:{{{screenshot|}}}|
{{!}} colspan=&quot;2&quot; style=&quot;text-align: center;&quot; {{!}} {{{screenshot}}}{{#if:{{{caption|}}}|&lt;br /&gt;{{{caption}}}}}
{{!}}-
}}
}}
{{#if:{{{url|}}}|
! [[Uniform Resource Locator|URL]]
{{!}} {{{url}}}
{{!}}-
}}
{{#if:{{{slogan|}}}|
! [[Xologeni]]
{{!}} {{{slogan}}}
{{!}}-
}}
{{#if:{{{alexa|}}}|
! Nkutlunya wa [[Alexa Internet|Alexa]]
{{!}} {{{alexa}}}
{{!}}-
}}
{{#if:{{{commercial|}}}|
! Ku bindzula?
{{!}} {{{commercial}}}
{{!}}-
}}
{{#if:{{{type|}}}|
! Muxaka wa tluka
{{!}} {{{type}}}
{{!}}-
}}
{{#if:{{{reg|{{{registration|}}}}}}|
! Vutsarisi
{{!}} {{{reg|{{{registration}}}}}}
{{!}}-
}}
{{#if:{{{language|}}}|
! [[Natural language|Tindzimi]] leti ngakona
{{!}} {{{language|}}}
{{!}}-
}}
{{#if:{{{owner|}}}|
! Nwini
{{!}} {{{owner}}}
{{!}}-
}}
{{#if:{{{author|}}}|
! Vatumbuluxi
{{!}} {{{author}}}
{{!}}-
}}
{{#if:{{{date_of_launch|{{{launch date|}}}}}}|
! Ri pfuriwa
{{!}} {{{date_of_launch|{{{launch date}}}}}}
{{!}}-
}}
{{#if:{{{rev|{{{revenue|}}}}}}|
! Mali
{{!}} {{{rev|{{{revenue}}}}}}
{{!}}-
}}
{{#if:{{{current_status|{{{current status|}}}}}}|
! Xiyimo xa sweswi-nyana
{{!}} {{{current_status|{{{current status}}}}}}
{{!}}-
}}
|}&lt;noinclude&gt;
{{pp-template|small=yes}}
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>ss4bw6rzofdcg6b7x4wu6183iukcxgu</sha1>
    </revision>
    <revision>
      <id>391</id>
      <parentid>390</parentid>
      <timestamp>2019-01-13T17:08:16Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>313</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1798" sha1="ss4bw6rzofdcg6b7x4wu6183iukcxgu" xml:space="preserve">{| class=&quot;infobox borderless&quot; summary=&quot;Template:Infobox Website&quot; style=&quot;float:right; clear:right; font-size:90%; text-align:left; width:24em;&quot;
! colspan=&quot;2&quot; style=&quot;text-align:center; font-size:125%;&quot; | {{{websitename|{{{name|{{PAGENAME}}}}}}}}
|-
{{#if:{{{websitelogo|{{{logo|}}}}}}|
{{!}} colspan=&quot;2&quot; style=&quot;text-align:center;&quot; {{!}} {{{websitelogo|{{{logo}}}}}}
{{!}}-
}}
{{#ifeq:{{{collapsible|}}}|yes|&lt;!-- then --&gt;
{{!}} colspan=&quot;2&quot; {{!}}
{{hidden|Screenshot|{{{screenshot}}}{{#if:{{{caption|}}}|&lt;br /&gt;{{{caption}}}}}|bg1=#ccccff|ta2=center}}
{{!}}-
|&lt;!-- else --&gt;
{{#if:{{{screenshot|}}}|
{{!}} colspan=&quot;2&quot; style=&quot;text-align: center;&quot; {{!}} {{{screenshot}}}{{#if:{{{caption|}}}|&lt;br /&gt;{{{caption}}}}}
{{!}}-
}}
}}
{{#if:{{{url|}}}|
! [[Uniform Resource Locator|URL]]
{{!}} {{{url}}}
{{!}}-
}}
{{#if:{{{slogan|}}}|
! [[Xologeni]]
{{!}} {{{slogan}}}
{{!}}-
}}
{{#if:{{{alexa|}}}|
! Nkutlunya wa [[Alexa Internet|Alexa]]
{{!}} {{{alexa}}}
{{!}}-
}}
{{#if:{{{commercial|}}}|
! Ku bindzula?
{{!}} {{{commercial}}}
{{!}}-
}}
{{#if:{{{type|}}}|
! Muxaka wa tluka
{{!}} {{{type}}}
{{!}}-
}}
{{#if:{{{reg|{{{registration|}}}}}}|
! Vutsarisi
{{!}} {{{reg|{{{registration}}}}}}
{{!}}-
}}
{{#if:{{{language|}}}|
! [[Natural language|Tindzimi]] leti ngakona
{{!}} {{{language|}}}
{{!}}-
}}
{{#if:{{{owner|}}}|
! Nwini
{{!}} {{{owner}}}
{{!}}-
}}
{{#if:{{{author|}}}|
! Vatumbuluxi
{{!}} {{{author}}}
{{!}}-
}}
{{#if:{{{date_of_launch|{{{launch date|}}}}}}|
! Ri pfuriwa
{{!}} {{{date_of_launch|{{{launch date}}}}}}
{{!}}-
}}
{{#if:{{{rev|{{{revenue|}}}}}}|
! Mali
{{!}} {{{rev|{{{revenue}}}}}}
{{!}}-
}}
{{#if:{{{current_status|{{{current status|}}}}}}|
! Xiyimo xa sweswi-nyana
{{!}} {{{current_status|{{{current status}}}}}}
{{!}}-
}}
|}&lt;noinclude&gt;
{{pp-template|small=yes}}
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>ss4bw6rzofdcg6b7x4wu6183iukcxgu</sha1>
    </revision>
    <revision>
      <id>392</id>
      <parentid>391</parentid>
      <timestamp>2019-01-13T17:12:05Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>392</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1741" sha1="649mjrc8ntla4w7tl93crf39s4gqjdy" xml:space="preserve">{| class=&quot;infobox borderless&quot; summary=&quot;Template:Infobox Website&quot; style=&quot;float:right; clear:right; font-size:90%; text-align:left; width:24em;&quot;
! colspan=&quot;2&quot; style=&quot;text-align:center; font-size:125%;&quot; | {{{websitename|{{{name|{{PAGENAME}}}}}}}}
|-
{{#if:{{{websitelogo|{{{logo|}}}}}}|
{{!}} colspan=&quot;2&quot; style=&quot;text-align:center;&quot; {{!}} {{{websitelogo|{{{logo}}}}}}
{{!}}-
}}
{{#ifeq:{{{collapsible|}}}|yes|&lt;!-- then --&gt;
{{!}} colspan=&quot;2&quot; {{!}}
{{hidden|Screenshot|{{{screenshot}}}{{#if:{{{caption|}}}|&lt;br /&gt;{{{caption}}}}}|bg1=#ccccff|ta2=center}}
{{!}}-
|&lt;!-- else --&gt;
{{#if:{{{screenshot|}}}|
{{!}} colspan=&quot;2&quot; style=&quot;text-align: center;&quot; {{!}} {{{screenshot}}}{{#if:{{{caption|}}}|&lt;br /&gt;{{{caption}}}}}
{{!}}-
}}
}}
{{#if:{{{url|}}}|
! [[Uniform Resource Locator|URL]]
{{!}} {{{url}}}
{{!}}-
}}
{{#if:{{{slogan|}}}|
! [[Slogan]]
{{!}} {{{slogan}}}
{{!}}-
}}
{{#if:{{{alexa|}}}|
! ku [[Alexa Internet|Alexa]]
{{!}} {{{alexa}}}
{{!}}-
}}
{{#if:{{{commercial|}}}|
! 
{{!}} {{{commercial}}}
{{!}}-
}}
{{#if:{{{type|}}}|
! Umtlolo
{{!}} {{{type}}}
{{!}}-
}}
{{#if:{{{reg|{{{registration|}}}}}}|
! Registration
{{!}} {{{reg|{{{registration}}}}}}
{{!}}-
}}
{{#if:{{{language|}}}|
! [[Natural language|amalwimi]]
{{!}} {{{language|}}}
{{!}}-
}}
{{#if:{{{owner|}}}|
! Umnini
{{!}} {{{owner}}}
{{!}}-
}}
{{#if:{{{author|}}}|
! Umtloli
{{!}} {{{author}}}
{{!}}-
}}
{{#if:{{{date_of_launch|{{{launch date|}}}}}}|
! Ukuthoma
{{!}} {{{date_of_launch|{{{launch date}}}}}}
{{!}}-
}}
{{#if:{{{rev|{{{revenue|}}}}}}|
! Revenue
{{!}} {{{rev|{{{revenue}}}}}}
{{!}}-
}}
{{#if:{{{current_status|{{{current status|}}}}}}|
! Njenganje
{{!}} {{{current_status|{{{current status}}}}}}
{{!}}-
}}
|}&lt;noinclude&gt;
{{pp-template|small=yes}}
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>649mjrc8ntla4w7tl93crf39s4gqjdy</sha1>
    </revision>
    <revision>
      <id>393</id>
      <parentid>315</parentid>
      <timestamp>2024-10-14T13:46:25Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>313</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1798" sha1="ss4bw6rzofdcg6b7x4wu6183iukcxgu" xml:space="preserve">{| class=&quot;infobox borderless&quot; summary=&quot;Template:Infobox Website&quot; style=&quot;float:right; clear:right; font-size:90%; text-align:left; width:24em;&quot;
! colspan=&quot;2&quot; style=&quot;text-align:center; font-size:125%;&quot; | {{{websitename|{{{name|{{PAGENAME}}}}}}}}
|-
{{#if:{{{websitelogo|{{{logo|}}}}}}|
{{!}} colspan=&quot;2&quot; style=&quot;text-align:center;&quot; {{!}} {{{websitelogo|{{{logo}}}}}}
{{!}}-
}}
{{#ifeq:{{{collapsible|}}}|yes|&lt;!-- then --&gt;
{{!}} colspan=&quot;2&quot; {{!}}
{{hidden|Screenshot|{{{screenshot}}}{{#if:{{{caption|}}}|&lt;br /&gt;{{{caption}}}}}|bg1=#ccccff|ta2=center}}
{{!}}-
|&lt;!-- else --&gt;
{{#if:{{{screenshot|}}}|
{{!}} colspan=&quot;2&quot; style=&quot;text-align: center;&quot; {{!}} {{{screenshot}}}{{#if:{{{caption|}}}|&lt;br /&gt;{{{caption}}}}}
{{!}}-
}}
}}
{{#if:{{{url|}}}|
! [[Uniform Resource Locator|URL]]
{{!}} {{{url}}}
{{!}}-
}}
{{#if:{{{slogan|}}}|
! [[Xologeni]]
{{!}} {{{slogan}}}
{{!}}-
}}
{{#if:{{{alexa|}}}|
! Nkutlunya wa [[Alexa Internet|Alexa]]
{{!}} {{{alexa}}}
{{!}}-
}}
{{#if:{{{commercial|}}}|
! Ku bindzula?
{{!}} {{{commercial}}}
{{!}}-
}}
{{#if:{{{type|}}}|
! Muxaka wa tluka
{{!}} {{{type}}}
{{!}}-
}}
{{#if:{{{reg|{{{registration|}}}}}}|
! Vutsarisi
{{!}} {{{reg|{{{registration}}}}}}
{{!}}-
}}
{{#if:{{{language|}}}|
! [[Natural language|Tindzimi]] leti ngakona
{{!}} {{{language|}}}
{{!}}-
}}
{{#if:{{{owner|}}}|
! Nwini
{{!}} {{{owner}}}
{{!}}-
}}
{{#if:{{{author|}}}|
! Vatumbuluxi
{{!}} {{{author}}}
{{!}}-
}}
{{#if:{{{date_of_launch|{{{launch date|}}}}}}|
! Ri pfuriwa
{{!}} {{{date_of_launch|{{{launch date}}}}}}
{{!}}-
}}
{{#if:{{{rev|{{{revenue|}}}}}}|
! Mali
{{!}} {{{rev|{{{revenue}}}}}}
{{!}}-
}}
{{#if:{{{current_status|{{{current status|}}}}}}|
! Xiyimo xa sweswi-nyana
{{!}} {{{current_status|{{{current status}}}}}}
{{!}}-
}}
|}&lt;noinclude&gt;
{{pp-template|small=yes}}
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>ss4bw6rzofdcg6b7x4wu6183iukcxgu</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Infobox disease</title>
    <ns>10</ns>
    <id>81</id>
    <revision>
      <id>316</id>
      <timestamp>2014-09-02T09:53:26Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>From [[:en:Template:Infobox disease/simple]]</comment>
      <origin>316</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4912" sha1="nmbnjnclqld5xog21g3jq9om8joai67" xml:space="preserve">&lt;div class=&quot;toc&quot; style=&quot;float:right;width:18em;padding:0.5em;margin:0 0 1em 1em;&quot;&gt;
&lt;table style=&quot;width:100%;&quot;&gt;
&lt;tr&gt;&lt;th colspan=&quot;2&quot;&gt;&lt;big&gt;{{{name|{{PAGENAME}}}}}&lt;/big&gt;&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align:center;&quot;&gt;''Classification and external resources''&lt;/td&gt;&lt;/tr&gt;
{{#if:{{{image|}}}|&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align:center;&quot;&gt;[[Isimumathi:{{{image|}}}{{{Image|}}}|150px|center|{{{caption|{{{name|{{PAGENAME}}}}}}}}]] &lt;small&gt;{{{caption|}}}{{{Caption|}}}&lt;/small&gt;&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{ICD10|}}}|&lt;tr&gt;&lt;td&gt;'''ICD/CIM-10'''&lt;/td&gt;&lt;td&gt;{{{ICD10|}}} {{{ICD10}}}{{#if:{{{ICD10-2|}}}|{{{ICD10-2|}}} {{{ICD10-2}}}|}}&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{ICD9|}}}|&lt;tr&gt;&lt;td&gt;'''ICD/CIM-9'''&lt;/td&gt;&lt;td&gt;{{{ICD9|}}} {{{ICD9}}}&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{OMIM|}}}|&lt;tr&gt;&lt;td&gt;'''OMIM'''&lt;/td&gt;&lt;td&gt;[http://omim.org/entry/{{{OMIM|}}} {{{OMIM}}}]&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{DiseasesDB|}}}|&lt;tr&gt;&lt;td&gt;'''DiseasesDB'''&lt;/td&gt;&lt;td&gt;[http://www.diseasesdatabase.com/ddb{{{DiseasesDB|}}}.htm {{{DiseasesDB}}}]{{#if:{{{DiseasesDB-2|}}}|, [http://www.diseasesdatabase.com/ddb{{{DiseasesDB-2|}}}.htm {{{DiseasesDB-2}}}]|}}&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{MedlinePlus|}}}|&lt;tr&gt;&lt;td&gt;'''MedlinePlus'''&lt;/td&gt;&lt;td&gt;[http://www.nlm.nih.gov/medlineplus/ency/article/{{{MedlinePlus|}}}.htm {{{MedlinePlus}}}]&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{eMedicine|}}}|&lt;tr&gt;&lt;td&gt;'''eMedicine'''&lt;/td&gt;&lt;td&gt;''&amp;lt;Placeholder&amp;gt;''&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{MeSH|}}}|&lt;tr&gt;&lt;td&gt;'''MeSH'''&lt;/td&gt;&lt;td&gt;[http://www.nlm.nih.gov/cgi/mesh/2014/MB_cgi?field=uid&amp;term={{{MeSH}}} {{{MeSH}}}]&lt;/td&gt;&lt;/tr&gt;|}}
&lt;/table&gt;
&lt;/div&gt;&lt;!--

{{ infobox
| abovestyle = background-color: {{{background|{{{Background|lightgrey}}}}}}
| above      = {{{name|{{{Name|&lt;includeonly&gt;{{PAGENAME}}&lt;/includeonly&gt;}}}}}}
| subheader  = &lt;includeonly&gt;''Classification and external resources''&lt;/includeonly&gt;
| image      = {{#invoke:InfoboxImage|InfoboxImage|image={{{image|}}}{{{Image|}}}|size={{{image_size|{{{Width|}}}}}}|sizedefault=frameless|upright=1.06|alt={{{alt|}}}{{{Alt|}}}}}
| caption    = {{{caption|}}}{{{Caption|}}}

| label1     = [[International Statistical Classification of Diseases and Related Health Problems|ICD]]-[[ICD-10|10]]
| data1      = {{{ICD10|}}}

| label2     = [[International Statistical Classification of Diseases and Related Health Problems|ICD]]-[[List of ICD-9 codes|9]]
| data2      = {{{ICD9|}}}

| label3     = [[International Classification of Diseases for Oncology|ICD-O:]]
| data3      = {{{ICDO|}}}

| label4     = [[OMIM]]
| data4      = {{#if:{{{OMIM|}}}|[http://omim.org/entry/{{{OMIM}}} {{{OMIM}}}] {{{OMIM_mult|}}} }}

| label5     = [[Diseases Database|DiseasesDB]]
| data5      = {{#if:{{{DiseasesDB|}}}|[http://www.diseasesdatabase.com/ddb{{{DiseasesDB}}}.htm {{{DiseasesDB}}}] {{{DiseasesDB_mult|}}} }}

| label6     = [[MedlinePlus]]
| data6      = {{#if:{{{MedlinePlus|}}}|[http://www.nlm.nih.gov/medlineplus/ency/article/{{{MedlinePlus}}}.htm {{{MedlinePlus}}}]  {{{MedlinePlus_mult|}}} }}

| label7     = [[Medical Subject Headings|MeSH]]
| data7      = {{comma separated entries
  | 1 = {{#if:{{{MeshID|{{{MeSH|{{{MeSH1|}}}}}}}}} | {{mesh2|{{{MeshID|{{{MeSH|{{{MeSH1}}}}}}}}}| year= {{{MeshYear|{{{MeshYear1|}}}}}} }} }}
  | 2 = {{#if:{{{MeSH2|}}} | {{mesh2|{{{MeSH2|}}}|year={{{MeshYear2|}}}}} }}
  | 3 = {{#if:{{{MeSH3|}}} | {{mesh2|{{{MeSH3|}}}|year={{{MeshYear3|}}}}} }}
  | 4 = {{#if:{{{MeSH4|}}} | {{mesh2|{{{MeSH4|}}}|year={{{MeshYear4|}}}}} }}
  | 5 = {{#if:{{{MeSH5|}}} | {{mesh2|{{{MeSH5|}}}|year={{{MeshYear5|}}}}} }}
  | 6 = {{#if:{{{MeSH6|}}} | {{mesh2|{{{MeSH6|}}}|year={{{MeshYear6|}}}}} }}
  | 7 = {{#if:{{{MeSH7|}}} | {{mesh2|{{{MeSH7|}}}|year={{{MeshYear7|}}}}} }}
  | 8 = {{#if:{{{MeSH8|}}} | {{mesh2|{{{MeSH8|}}}|year={{{MeshYear8|}}}}} }}
  | 9 = {{#if:{{{MeSH9|}}} | {{mesh2|{{{MeSH9|}}}|year={{{MeshYear9|}}}}} }}
  |10 = {{#if: {{{MeshName|}}} | ''{{mesh2 | name = {{{MeshName}}} | number = {{{MeshNumber|}}} }}'' }}
  }}

| label8     = [[GeneReviews]]
| class8     = plainlist
| data8      = {{#if: {{{GeneReviewsNBK|}}}{{{GeneReviewsNBK1|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK|{{{GeneReviewsNBK1}}}}}}|{{{GeneReviewsName|{{{GeneReviewsName1|}}}}}}}}|{{#if: {{{GeneReviewsID|}}}| 
* [http://www.ncbi.nlm.nih.gov/books/n/gene/{{{GeneReviewsID}}}/ {{#if: {{{GeneReviewsName|}}}|{{{GeneReviewsName}}}|{{{GeneReviewsID}}}}}]}}}}{{#if: {{{GeneReviewsNBK2|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK2}}}|{{{GeneReviewsName2|}}}}}}}{{#if: {{{GeneReviewsNBK3|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK3}}}|{{{GeneReviewsName3|}}}}}}}{{#if: {{{GeneReviewsNBK4|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK4}}}|{{{GeneReviewsName4|}}}}}}}{{#if: {{{GeneReviewsNBK5|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK5}}}|{{{GeneReviewsName5|}}}}}}}{{#if: {{{GeneReviewsNBK6|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK6}}}|{{{GeneReviewsName6|}}}}}}}{{#if: {{{GeneReviewsNBK7|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK7}}}|{{{GeneReviewsName7|}}}}}}}

}}--&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>nmbnjnclqld5xog21g3jq9om8joai67</sha1>
    </revision>
    <revision>
      <id>317</id>
      <parentid>316</parentid>
      <timestamp>2014-09-02T10:38:47Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>CFCF moved page [[Umhlahlandlelasakhiwo:Infobox disease]] to [[Infobox disease]]</comment>
      <origin>316</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4912" sha1="nmbnjnclqld5xog21g3jq9om8joai67" xml:space="preserve">&lt;div class=&quot;toc&quot; style=&quot;float:right;width:18em;padding:0.5em;margin:0 0 1em 1em;&quot;&gt;
&lt;table style=&quot;width:100%;&quot;&gt;
&lt;tr&gt;&lt;th colspan=&quot;2&quot;&gt;&lt;big&gt;{{{name|{{PAGENAME}}}}}&lt;/big&gt;&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align:center;&quot;&gt;''Classification and external resources''&lt;/td&gt;&lt;/tr&gt;
{{#if:{{{image|}}}|&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align:center;&quot;&gt;[[Isimumathi:{{{image|}}}{{{Image|}}}|150px|center|{{{caption|{{{name|{{PAGENAME}}}}}}}}]] &lt;small&gt;{{{caption|}}}{{{Caption|}}}&lt;/small&gt;&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{ICD10|}}}|&lt;tr&gt;&lt;td&gt;'''ICD/CIM-10'''&lt;/td&gt;&lt;td&gt;{{{ICD10|}}} {{{ICD10}}}{{#if:{{{ICD10-2|}}}|{{{ICD10-2|}}} {{{ICD10-2}}}|}}&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{ICD9|}}}|&lt;tr&gt;&lt;td&gt;'''ICD/CIM-9'''&lt;/td&gt;&lt;td&gt;{{{ICD9|}}} {{{ICD9}}}&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{OMIM|}}}|&lt;tr&gt;&lt;td&gt;'''OMIM'''&lt;/td&gt;&lt;td&gt;[http://omim.org/entry/{{{OMIM|}}} {{{OMIM}}}]&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{DiseasesDB|}}}|&lt;tr&gt;&lt;td&gt;'''DiseasesDB'''&lt;/td&gt;&lt;td&gt;[http://www.diseasesdatabase.com/ddb{{{DiseasesDB|}}}.htm {{{DiseasesDB}}}]{{#if:{{{DiseasesDB-2|}}}|, [http://www.diseasesdatabase.com/ddb{{{DiseasesDB-2|}}}.htm {{{DiseasesDB-2}}}]|}}&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{MedlinePlus|}}}|&lt;tr&gt;&lt;td&gt;'''MedlinePlus'''&lt;/td&gt;&lt;td&gt;[http://www.nlm.nih.gov/medlineplus/ency/article/{{{MedlinePlus|}}}.htm {{{MedlinePlus}}}]&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{eMedicine|}}}|&lt;tr&gt;&lt;td&gt;'''eMedicine'''&lt;/td&gt;&lt;td&gt;''&amp;lt;Placeholder&amp;gt;''&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{MeSH|}}}|&lt;tr&gt;&lt;td&gt;'''MeSH'''&lt;/td&gt;&lt;td&gt;[http://www.nlm.nih.gov/cgi/mesh/2014/MB_cgi?field=uid&amp;term={{{MeSH}}} {{{MeSH}}}]&lt;/td&gt;&lt;/tr&gt;|}}
&lt;/table&gt;
&lt;/div&gt;&lt;!--

{{ infobox
| abovestyle = background-color: {{{background|{{{Background|lightgrey}}}}}}
| above      = {{{name|{{{Name|&lt;includeonly&gt;{{PAGENAME}}&lt;/includeonly&gt;}}}}}}
| subheader  = &lt;includeonly&gt;''Classification and external resources''&lt;/includeonly&gt;
| image      = {{#invoke:InfoboxImage|InfoboxImage|image={{{image|}}}{{{Image|}}}|size={{{image_size|{{{Width|}}}}}}|sizedefault=frameless|upright=1.06|alt={{{alt|}}}{{{Alt|}}}}}
| caption    = {{{caption|}}}{{{Caption|}}}

| label1     = [[International Statistical Classification of Diseases and Related Health Problems|ICD]]-[[ICD-10|10]]
| data1      = {{{ICD10|}}}

| label2     = [[International Statistical Classification of Diseases and Related Health Problems|ICD]]-[[List of ICD-9 codes|9]]
| data2      = {{{ICD9|}}}

| label3     = [[International Classification of Diseases for Oncology|ICD-O:]]
| data3      = {{{ICDO|}}}

| label4     = [[OMIM]]
| data4      = {{#if:{{{OMIM|}}}|[http://omim.org/entry/{{{OMIM}}} {{{OMIM}}}] {{{OMIM_mult|}}} }}

| label5     = [[Diseases Database|DiseasesDB]]
| data5      = {{#if:{{{DiseasesDB|}}}|[http://www.diseasesdatabase.com/ddb{{{DiseasesDB}}}.htm {{{DiseasesDB}}}] {{{DiseasesDB_mult|}}} }}

| label6     = [[MedlinePlus]]
| data6      = {{#if:{{{MedlinePlus|}}}|[http://www.nlm.nih.gov/medlineplus/ency/article/{{{MedlinePlus}}}.htm {{{MedlinePlus}}}]  {{{MedlinePlus_mult|}}} }}

| label7     = [[Medical Subject Headings|MeSH]]
| data7      = {{comma separated entries
  | 1 = {{#if:{{{MeshID|{{{MeSH|{{{MeSH1|}}}}}}}}} | {{mesh2|{{{MeshID|{{{MeSH|{{{MeSH1}}}}}}}}}| year= {{{MeshYear|{{{MeshYear1|}}}}}} }} }}
  | 2 = {{#if:{{{MeSH2|}}} | {{mesh2|{{{MeSH2|}}}|year={{{MeshYear2|}}}}} }}
  | 3 = {{#if:{{{MeSH3|}}} | {{mesh2|{{{MeSH3|}}}|year={{{MeshYear3|}}}}} }}
  | 4 = {{#if:{{{MeSH4|}}} | {{mesh2|{{{MeSH4|}}}|year={{{MeshYear4|}}}}} }}
  | 5 = {{#if:{{{MeSH5|}}} | {{mesh2|{{{MeSH5|}}}|year={{{MeshYear5|}}}}} }}
  | 6 = {{#if:{{{MeSH6|}}} | {{mesh2|{{{MeSH6|}}}|year={{{MeshYear6|}}}}} }}
  | 7 = {{#if:{{{MeSH7|}}} | {{mesh2|{{{MeSH7|}}}|year={{{MeshYear7|}}}}} }}
  | 8 = {{#if:{{{MeSH8|}}} | {{mesh2|{{{MeSH8|}}}|year={{{MeshYear8|}}}}} }}
  | 9 = {{#if:{{{MeSH9|}}} | {{mesh2|{{{MeSH9|}}}|year={{{MeshYear9|}}}}} }}
  |10 = {{#if: {{{MeshName|}}} | ''{{mesh2 | name = {{{MeshName}}} | number = {{{MeshNumber|}}} }}'' }}
  }}

| label8     = [[GeneReviews]]
| class8     = plainlist
| data8      = {{#if: {{{GeneReviewsNBK|}}}{{{GeneReviewsNBK1|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK|{{{GeneReviewsNBK1}}}}}}|{{{GeneReviewsName|{{{GeneReviewsName1|}}}}}}}}|{{#if: {{{GeneReviewsID|}}}| 
* [http://www.ncbi.nlm.nih.gov/books/n/gene/{{{GeneReviewsID}}}/ {{#if: {{{GeneReviewsName|}}}|{{{GeneReviewsName}}}|{{{GeneReviewsID}}}}}]}}}}{{#if: {{{GeneReviewsNBK2|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK2}}}|{{{GeneReviewsName2|}}}}}}}{{#if: {{{GeneReviewsNBK3|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK3}}}|{{{GeneReviewsName3|}}}}}}}{{#if: {{{GeneReviewsNBK4|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK4}}}|{{{GeneReviewsName4|}}}}}}}{{#if: {{{GeneReviewsNBK5|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK5}}}|{{{GeneReviewsName5|}}}}}}}{{#if: {{{GeneReviewsNBK6|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK6}}}|{{{GeneReviewsName6|}}}}}}}{{#if: {{{GeneReviewsNBK7|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK7}}}|{{{GeneReviewsName7|}}}}}}}

}}--&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>nmbnjnclqld5xog21g3jq9om8joai67</sha1>
    </revision>
    <revision>
      <id>318</id>
      <parentid>317</parentid>
      <timestamp>2014-09-02T10:39:29Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>CFCF moved page [[Infobox disease]] to [[Umhlahlandlelasakhiwo:Infobox disease]]</comment>
      <origin>316</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4912" sha1="nmbnjnclqld5xog21g3jq9om8joai67" xml:space="preserve">&lt;div class=&quot;toc&quot; style=&quot;float:right;width:18em;padding:0.5em;margin:0 0 1em 1em;&quot;&gt;
&lt;table style=&quot;width:100%;&quot;&gt;
&lt;tr&gt;&lt;th colspan=&quot;2&quot;&gt;&lt;big&gt;{{{name|{{PAGENAME}}}}}&lt;/big&gt;&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align:center;&quot;&gt;''Classification and external resources''&lt;/td&gt;&lt;/tr&gt;
{{#if:{{{image|}}}|&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align:center;&quot;&gt;[[Isimumathi:{{{image|}}}{{{Image|}}}|150px|center|{{{caption|{{{name|{{PAGENAME}}}}}}}}]] &lt;small&gt;{{{caption|}}}{{{Caption|}}}&lt;/small&gt;&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{ICD10|}}}|&lt;tr&gt;&lt;td&gt;'''ICD/CIM-10'''&lt;/td&gt;&lt;td&gt;{{{ICD10|}}} {{{ICD10}}}{{#if:{{{ICD10-2|}}}|{{{ICD10-2|}}} {{{ICD10-2}}}|}}&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{ICD9|}}}|&lt;tr&gt;&lt;td&gt;'''ICD/CIM-9'''&lt;/td&gt;&lt;td&gt;{{{ICD9|}}} {{{ICD9}}}&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{OMIM|}}}|&lt;tr&gt;&lt;td&gt;'''OMIM'''&lt;/td&gt;&lt;td&gt;[http://omim.org/entry/{{{OMIM|}}} {{{OMIM}}}]&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{DiseasesDB|}}}|&lt;tr&gt;&lt;td&gt;'''DiseasesDB'''&lt;/td&gt;&lt;td&gt;[http://www.diseasesdatabase.com/ddb{{{DiseasesDB|}}}.htm {{{DiseasesDB}}}]{{#if:{{{DiseasesDB-2|}}}|, [http://www.diseasesdatabase.com/ddb{{{DiseasesDB-2|}}}.htm {{{DiseasesDB-2}}}]|}}&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{MedlinePlus|}}}|&lt;tr&gt;&lt;td&gt;'''MedlinePlus'''&lt;/td&gt;&lt;td&gt;[http://www.nlm.nih.gov/medlineplus/ency/article/{{{MedlinePlus|}}}.htm {{{MedlinePlus}}}]&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{eMedicine|}}}|&lt;tr&gt;&lt;td&gt;'''eMedicine'''&lt;/td&gt;&lt;td&gt;''&amp;lt;Placeholder&amp;gt;''&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{MeSH|}}}|&lt;tr&gt;&lt;td&gt;'''MeSH'''&lt;/td&gt;&lt;td&gt;[http://www.nlm.nih.gov/cgi/mesh/2014/MB_cgi?field=uid&amp;term={{{MeSH}}} {{{MeSH}}}]&lt;/td&gt;&lt;/tr&gt;|}}
&lt;/table&gt;
&lt;/div&gt;&lt;!--

{{ infobox
| abovestyle = background-color: {{{background|{{{Background|lightgrey}}}}}}
| above      = {{{name|{{{Name|&lt;includeonly&gt;{{PAGENAME}}&lt;/includeonly&gt;}}}}}}
| subheader  = &lt;includeonly&gt;''Classification and external resources''&lt;/includeonly&gt;
| image      = {{#invoke:InfoboxImage|InfoboxImage|image={{{image|}}}{{{Image|}}}|size={{{image_size|{{{Width|}}}}}}|sizedefault=frameless|upright=1.06|alt={{{alt|}}}{{{Alt|}}}}}
| caption    = {{{caption|}}}{{{Caption|}}}

| label1     = [[International Statistical Classification of Diseases and Related Health Problems|ICD]]-[[ICD-10|10]]
| data1      = {{{ICD10|}}}

| label2     = [[International Statistical Classification of Diseases and Related Health Problems|ICD]]-[[List of ICD-9 codes|9]]
| data2      = {{{ICD9|}}}

| label3     = [[International Classification of Diseases for Oncology|ICD-O:]]
| data3      = {{{ICDO|}}}

| label4     = [[OMIM]]
| data4      = {{#if:{{{OMIM|}}}|[http://omim.org/entry/{{{OMIM}}} {{{OMIM}}}] {{{OMIM_mult|}}} }}

| label5     = [[Diseases Database|DiseasesDB]]
| data5      = {{#if:{{{DiseasesDB|}}}|[http://www.diseasesdatabase.com/ddb{{{DiseasesDB}}}.htm {{{DiseasesDB}}}] {{{DiseasesDB_mult|}}} }}

| label6     = [[MedlinePlus]]
| data6      = {{#if:{{{MedlinePlus|}}}|[http://www.nlm.nih.gov/medlineplus/ency/article/{{{MedlinePlus}}}.htm {{{MedlinePlus}}}]  {{{MedlinePlus_mult|}}} }}

| label7     = [[Medical Subject Headings|MeSH]]
| data7      = {{comma separated entries
  | 1 = {{#if:{{{MeshID|{{{MeSH|{{{MeSH1|}}}}}}}}} | {{mesh2|{{{MeshID|{{{MeSH|{{{MeSH1}}}}}}}}}| year= {{{MeshYear|{{{MeshYear1|}}}}}} }} }}
  | 2 = {{#if:{{{MeSH2|}}} | {{mesh2|{{{MeSH2|}}}|year={{{MeshYear2|}}}}} }}
  | 3 = {{#if:{{{MeSH3|}}} | {{mesh2|{{{MeSH3|}}}|year={{{MeshYear3|}}}}} }}
  | 4 = {{#if:{{{MeSH4|}}} | {{mesh2|{{{MeSH4|}}}|year={{{MeshYear4|}}}}} }}
  | 5 = {{#if:{{{MeSH5|}}} | {{mesh2|{{{MeSH5|}}}|year={{{MeshYear5|}}}}} }}
  | 6 = {{#if:{{{MeSH6|}}} | {{mesh2|{{{MeSH6|}}}|year={{{MeshYear6|}}}}} }}
  | 7 = {{#if:{{{MeSH7|}}} | {{mesh2|{{{MeSH7|}}}|year={{{MeshYear7|}}}}} }}
  | 8 = {{#if:{{{MeSH8|}}} | {{mesh2|{{{MeSH8|}}}|year={{{MeshYear8|}}}}} }}
  | 9 = {{#if:{{{MeSH9|}}} | {{mesh2|{{{MeSH9|}}}|year={{{MeshYear9|}}}}} }}
  |10 = {{#if: {{{MeshName|}}} | ''{{mesh2 | name = {{{MeshName}}} | number = {{{MeshNumber|}}} }}'' }}
  }}

| label8     = [[GeneReviews]]
| class8     = plainlist
| data8      = {{#if: {{{GeneReviewsNBK|}}}{{{GeneReviewsNBK1|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK|{{{GeneReviewsNBK1}}}}}}|{{{GeneReviewsName|{{{GeneReviewsName1|}}}}}}}}|{{#if: {{{GeneReviewsID|}}}| 
* [http://www.ncbi.nlm.nih.gov/books/n/gene/{{{GeneReviewsID}}}/ {{#if: {{{GeneReviewsName|}}}|{{{GeneReviewsName}}}|{{{GeneReviewsID}}}}}]}}}}{{#if: {{{GeneReviewsNBK2|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK2}}}|{{{GeneReviewsName2|}}}}}}}{{#if: {{{GeneReviewsNBK3|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK3}}}|{{{GeneReviewsName3|}}}}}}}{{#if: {{{GeneReviewsNBK4|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK4}}}|{{{GeneReviewsName4|}}}}}}}{{#if: {{{GeneReviewsNBK5|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK5}}}|{{{GeneReviewsName5|}}}}}}}{{#if: {{{GeneReviewsNBK6|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK6}}}|{{{GeneReviewsName6|}}}}}}}{{#if: {{{GeneReviewsNBK7|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK7}}}|{{{GeneReviewsName7|}}}}}}}

}}--&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>nmbnjnclqld5xog21g3jq9om8joai67</sha1>
    </revision>
    <revision>
      <id>319</id>
      <parentid>318</parentid>
      <timestamp>2014-09-05T07:54:15Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <origin>319</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4973" sha1="cka8ra07le1weu7jafzwixzljytx9ok" xml:space="preserve">&lt;div class=&quot;toc&quot; style=&quot;float:right;width:18em;padding:0.5em;margin:0 0 1em 1em;&quot;&gt;
&lt;table style=&quot;width:100%;&quot;&gt;
&lt;tr&gt;&lt;th colspan=&quot;2&quot;&gt;&lt;big&gt;{{{name|{{PAGENAME}}}}}&lt;/big&gt;&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align:center;&quot;&gt;''Ukuhlukaniswa kweengaba neentlabagelo zangaphandle''&lt;!--''Classification and external resources''--&gt;&lt;/td&gt;&lt;/tr&gt;
{{#if:{{{image|}}}|&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align:center;&quot;&gt;[[Isimumathi:{{{image|}}}{{{Image|}}}|150px|center|{{{caption|{{{name|{{PAGENAME}}}}}}}}]] &lt;small&gt;{{{caption|}}}{{{Caption|}}}&lt;/small&gt;&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{ICD10|}}}|&lt;tr&gt;&lt;td&gt;'''ICD/CIM-10'''&lt;/td&gt;&lt;td&gt;{{{ICD10|}}} {{{ICD10}}}{{#if:{{{ICD10-2|}}}|{{{ICD10-2|}}} {{{ICD10-2}}}|}}&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{ICD9|}}}|&lt;tr&gt;&lt;td&gt;'''ICD/CIM-9'''&lt;/td&gt;&lt;td&gt;{{{ICD9|}}} {{{ICD9}}}&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{OMIM|}}}|&lt;tr&gt;&lt;td&gt;'''OMIM'''&lt;/td&gt;&lt;td&gt;[http://omim.org/entry/{{{OMIM|}}} {{{OMIM}}}]&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{DiseasesDB|}}}|&lt;tr&gt;&lt;td&gt;'''DiseasesDB'''&lt;/td&gt;&lt;td&gt;[http://www.diseasesdatabase.com/ddb{{{DiseasesDB|}}}.htm {{{DiseasesDB}}}]{{#if:{{{DiseasesDB-2|}}}|, [http://www.diseasesdatabase.com/ddb{{{DiseasesDB-2|}}}.htm {{{DiseasesDB-2}}}]|}}&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{MedlinePlus|}}}|&lt;tr&gt;&lt;td&gt;'''MedlinePlus'''&lt;/td&gt;&lt;td&gt;[http://www.nlm.nih.gov/medlineplus/ency/article/{{{MedlinePlus|}}}.htm {{{MedlinePlus}}}]&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{eMedicine|}}}|&lt;tr&gt;&lt;td&gt;'''eMedicine'''&lt;/td&gt;&lt;td&gt;''&amp;lt;Placeholder&amp;gt;''&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{MeSH|}}}|&lt;tr&gt;&lt;td&gt;'''MeSH'''&lt;/td&gt;&lt;td&gt;[http://www.nlm.nih.gov/cgi/mesh/2014/MB_cgi?field=uid&amp;term={{{MeSH}}} {{{MeSH}}}]&lt;/td&gt;&lt;/tr&gt;|}}
&lt;/table&gt;
&lt;/div&gt;&lt;!--

{{ infobox
| abovestyle = background-color: {{{background|{{{Background|lightgrey}}}}}}
| above      = {{{name|{{{Name|&lt;includeonly&gt;{{PAGENAME}}&lt;/includeonly&gt;}}}}}}
| subheader  = &lt;includeonly&gt;''Classification and external resources''&lt;/includeonly&gt;
| image      = {{#invoke:InfoboxImage|InfoboxImage|image={{{image|}}}{{{Image|}}}|size={{{image_size|{{{Width|}}}}}}|sizedefault=frameless|upright=1.06|alt={{{alt|}}}{{{Alt|}}}}}
| caption    = {{{caption|}}}{{{Caption|}}}

| label1     = [[International Statistical Classification of Diseases and Related Health Problems|ICD]]-[[ICD-10|10]]
| data1      = {{{ICD10|}}}

| label2     = [[International Statistical Classification of Diseases and Related Health Problems|ICD]]-[[List of ICD-9 codes|9]]
| data2      = {{{ICD9|}}}

| label3     = [[International Classification of Diseases for Oncology|ICD-O:]]
| data3      = {{{ICDO|}}}

| label4     = [[OMIM]]
| data4      = {{#if:{{{OMIM|}}}|[http://omim.org/entry/{{{OMIM}}} {{{OMIM}}}] {{{OMIM_mult|}}} }}

| label5     = [[Diseases Database|DiseasesDB]]
| data5      = {{#if:{{{DiseasesDB|}}}|[http://www.diseasesdatabase.com/ddb{{{DiseasesDB}}}.htm {{{DiseasesDB}}}] {{{DiseasesDB_mult|}}} }}

| label6     = [[MedlinePlus]]
| data6      = {{#if:{{{MedlinePlus|}}}|[http://www.nlm.nih.gov/medlineplus/ency/article/{{{MedlinePlus}}}.htm {{{MedlinePlus}}}]  {{{MedlinePlus_mult|}}} }}

| label7     = [[Medical Subject Headings|MeSH]]
| data7      = {{comma separated entries
  | 1 = {{#if:{{{MeshID|{{{MeSH|{{{MeSH1|}}}}}}}}} | {{mesh2|{{{MeshID|{{{MeSH|{{{MeSH1}}}}}}}}}| year= {{{MeshYear|{{{MeshYear1|}}}}}} }} }}
  | 2 = {{#if:{{{MeSH2|}}} | {{mesh2|{{{MeSH2|}}}|year={{{MeshYear2|}}}}} }}
  | 3 = {{#if:{{{MeSH3|}}} | {{mesh2|{{{MeSH3|}}}|year={{{MeshYear3|}}}}} }}
  | 4 = {{#if:{{{MeSH4|}}} | {{mesh2|{{{MeSH4|}}}|year={{{MeshYear4|}}}}} }}
  | 5 = {{#if:{{{MeSH5|}}} | {{mesh2|{{{MeSH5|}}}|year={{{MeshYear5|}}}}} }}
  | 6 = {{#if:{{{MeSH6|}}} | {{mesh2|{{{MeSH6|}}}|year={{{MeshYear6|}}}}} }}
  | 7 = {{#if:{{{MeSH7|}}} | {{mesh2|{{{MeSH7|}}}|year={{{MeshYear7|}}}}} }}
  | 8 = {{#if:{{{MeSH8|}}} | {{mesh2|{{{MeSH8|}}}|year={{{MeshYear8|}}}}} }}
  | 9 = {{#if:{{{MeSH9|}}} | {{mesh2|{{{MeSH9|}}}|year={{{MeshYear9|}}}}} }}
  |10 = {{#if: {{{MeshName|}}} | ''{{mesh2 | name = {{{MeshName}}} | number = {{{MeshNumber|}}} }}'' }}
  }}

| label8     = [[GeneReviews]]
| class8     = plainlist
| data8      = {{#if: {{{GeneReviewsNBK|}}}{{{GeneReviewsNBK1|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK|{{{GeneReviewsNBK1}}}}}}|{{{GeneReviewsName|{{{GeneReviewsName1|}}}}}}}}|{{#if: {{{GeneReviewsID|}}}| 
* [http://www.ncbi.nlm.nih.gov/books/n/gene/{{{GeneReviewsID}}}/ {{#if: {{{GeneReviewsName|}}}|{{{GeneReviewsName}}}|{{{GeneReviewsID}}}}}]}}}}{{#if: {{{GeneReviewsNBK2|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK2}}}|{{{GeneReviewsName2|}}}}}}}{{#if: {{{GeneReviewsNBK3|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK3}}}|{{{GeneReviewsName3|}}}}}}}{{#if: {{{GeneReviewsNBK4|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK4}}}|{{{GeneReviewsName4|}}}}}}}{{#if: {{{GeneReviewsNBK5|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK5}}}|{{{GeneReviewsName5|}}}}}}}{{#if: {{{GeneReviewsNBK6|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK6}}}|{{{GeneReviewsName6|}}}}}}}{{#if: {{{GeneReviewsNBK7|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK7}}}|{{{GeneReviewsName7|}}}}}}}

}}--&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>cka8ra07le1weu7jafzwixzljytx9ok</sha1>
    </revision>
    <revision>
      <id>320</id>
      <parentid>319</parentid>
      <timestamp>2024-10-14T13:46:21Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>4 revisions imported</comment>
      <origin>319</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4973" sha1="cka8ra07le1weu7jafzwixzljytx9ok" xml:space="preserve">&lt;div class=&quot;toc&quot; style=&quot;float:right;width:18em;padding:0.5em;margin:0 0 1em 1em;&quot;&gt;
&lt;table style=&quot;width:100%;&quot;&gt;
&lt;tr&gt;&lt;th colspan=&quot;2&quot;&gt;&lt;big&gt;{{{name|{{PAGENAME}}}}}&lt;/big&gt;&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align:center;&quot;&gt;''Ukuhlukaniswa kweengaba neentlabagelo zangaphandle''&lt;!--''Classification and external resources''--&gt;&lt;/td&gt;&lt;/tr&gt;
{{#if:{{{image|}}}|&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align:center;&quot;&gt;[[Isimumathi:{{{image|}}}{{{Image|}}}|150px|center|{{{caption|{{{name|{{PAGENAME}}}}}}}}]] &lt;small&gt;{{{caption|}}}{{{Caption|}}}&lt;/small&gt;&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{ICD10|}}}|&lt;tr&gt;&lt;td&gt;'''ICD/CIM-10'''&lt;/td&gt;&lt;td&gt;{{{ICD10|}}} {{{ICD10}}}{{#if:{{{ICD10-2|}}}|{{{ICD10-2|}}} {{{ICD10-2}}}|}}&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{ICD9|}}}|&lt;tr&gt;&lt;td&gt;'''ICD/CIM-9'''&lt;/td&gt;&lt;td&gt;{{{ICD9|}}} {{{ICD9}}}&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{OMIM|}}}|&lt;tr&gt;&lt;td&gt;'''OMIM'''&lt;/td&gt;&lt;td&gt;[http://omim.org/entry/{{{OMIM|}}} {{{OMIM}}}]&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{DiseasesDB|}}}|&lt;tr&gt;&lt;td&gt;'''DiseasesDB'''&lt;/td&gt;&lt;td&gt;[http://www.diseasesdatabase.com/ddb{{{DiseasesDB|}}}.htm {{{DiseasesDB}}}]{{#if:{{{DiseasesDB-2|}}}|, [http://www.diseasesdatabase.com/ddb{{{DiseasesDB-2|}}}.htm {{{DiseasesDB-2}}}]|}}&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{MedlinePlus|}}}|&lt;tr&gt;&lt;td&gt;'''MedlinePlus'''&lt;/td&gt;&lt;td&gt;[http://www.nlm.nih.gov/medlineplus/ency/article/{{{MedlinePlus|}}}.htm {{{MedlinePlus}}}]&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{eMedicine|}}}|&lt;tr&gt;&lt;td&gt;'''eMedicine'''&lt;/td&gt;&lt;td&gt;''&amp;lt;Placeholder&amp;gt;''&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{MeSH|}}}|&lt;tr&gt;&lt;td&gt;'''MeSH'''&lt;/td&gt;&lt;td&gt;[http://www.nlm.nih.gov/cgi/mesh/2014/MB_cgi?field=uid&amp;term={{{MeSH}}} {{{MeSH}}}]&lt;/td&gt;&lt;/tr&gt;|}}
&lt;/table&gt;
&lt;/div&gt;&lt;!--

{{ infobox
| abovestyle = background-color: {{{background|{{{Background|lightgrey}}}}}}
| above      = {{{name|{{{Name|&lt;includeonly&gt;{{PAGENAME}}&lt;/includeonly&gt;}}}}}}
| subheader  = &lt;includeonly&gt;''Classification and external resources''&lt;/includeonly&gt;
| image      = {{#invoke:InfoboxImage|InfoboxImage|image={{{image|}}}{{{Image|}}}|size={{{image_size|{{{Width|}}}}}}|sizedefault=frameless|upright=1.06|alt={{{alt|}}}{{{Alt|}}}}}
| caption    = {{{caption|}}}{{{Caption|}}}

| label1     = [[International Statistical Classification of Diseases and Related Health Problems|ICD]]-[[ICD-10|10]]
| data1      = {{{ICD10|}}}

| label2     = [[International Statistical Classification of Diseases and Related Health Problems|ICD]]-[[List of ICD-9 codes|9]]
| data2      = {{{ICD9|}}}

| label3     = [[International Classification of Diseases for Oncology|ICD-O:]]
| data3      = {{{ICDO|}}}

| label4     = [[OMIM]]
| data4      = {{#if:{{{OMIM|}}}|[http://omim.org/entry/{{{OMIM}}} {{{OMIM}}}] {{{OMIM_mult|}}} }}

| label5     = [[Diseases Database|DiseasesDB]]
| data5      = {{#if:{{{DiseasesDB|}}}|[http://www.diseasesdatabase.com/ddb{{{DiseasesDB}}}.htm {{{DiseasesDB}}}] {{{DiseasesDB_mult|}}} }}

| label6     = [[MedlinePlus]]
| data6      = {{#if:{{{MedlinePlus|}}}|[http://www.nlm.nih.gov/medlineplus/ency/article/{{{MedlinePlus}}}.htm {{{MedlinePlus}}}]  {{{MedlinePlus_mult|}}} }}

| label7     = [[Medical Subject Headings|MeSH]]
| data7      = {{comma separated entries
  | 1 = {{#if:{{{MeshID|{{{MeSH|{{{MeSH1|}}}}}}}}} | {{mesh2|{{{MeshID|{{{MeSH|{{{MeSH1}}}}}}}}}| year= {{{MeshYear|{{{MeshYear1|}}}}}} }} }}
  | 2 = {{#if:{{{MeSH2|}}} | {{mesh2|{{{MeSH2|}}}|year={{{MeshYear2|}}}}} }}
  | 3 = {{#if:{{{MeSH3|}}} | {{mesh2|{{{MeSH3|}}}|year={{{MeshYear3|}}}}} }}
  | 4 = {{#if:{{{MeSH4|}}} | {{mesh2|{{{MeSH4|}}}|year={{{MeshYear4|}}}}} }}
  | 5 = {{#if:{{{MeSH5|}}} | {{mesh2|{{{MeSH5|}}}|year={{{MeshYear5|}}}}} }}
  | 6 = {{#if:{{{MeSH6|}}} | {{mesh2|{{{MeSH6|}}}|year={{{MeshYear6|}}}}} }}
  | 7 = {{#if:{{{MeSH7|}}} | {{mesh2|{{{MeSH7|}}}|year={{{MeshYear7|}}}}} }}
  | 8 = {{#if:{{{MeSH8|}}} | {{mesh2|{{{MeSH8|}}}|year={{{MeshYear8|}}}}} }}
  | 9 = {{#if:{{{MeSH9|}}} | {{mesh2|{{{MeSH9|}}}|year={{{MeshYear9|}}}}} }}
  |10 = {{#if: {{{MeshName|}}} | ''{{mesh2 | name = {{{MeshName}}} | number = {{{MeshNumber|}}} }}'' }}
  }}

| label8     = [[GeneReviews]]
| class8     = plainlist
| data8      = {{#if: {{{GeneReviewsNBK|}}}{{{GeneReviewsNBK1|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK|{{{GeneReviewsNBK1}}}}}}|{{{GeneReviewsName|{{{GeneReviewsName1|}}}}}}}}|{{#if: {{{GeneReviewsID|}}}| 
* [http://www.ncbi.nlm.nih.gov/books/n/gene/{{{GeneReviewsID}}}/ {{#if: {{{GeneReviewsName|}}}|{{{GeneReviewsName}}}|{{{GeneReviewsID}}}}}]}}}}{{#if: {{{GeneReviewsNBK2|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK2}}}|{{{GeneReviewsName2|}}}}}}}{{#if: {{{GeneReviewsNBK3|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK3}}}|{{{GeneReviewsName3|}}}}}}}{{#if: {{{GeneReviewsNBK4|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK4}}}|{{{GeneReviewsName4|}}}}}}}{{#if: {{{GeneReviewsNBK5|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK5}}}|{{{GeneReviewsName5|}}}}}}}{{#if: {{{GeneReviewsNBK6|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK6}}}|{{{GeneReviewsName6|}}}}}}}{{#if: {{{GeneReviewsNBK7|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK7}}}|{{{GeneReviewsName7|}}}}}}}

}}--&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>cka8ra07le1weu7jafzwixzljytx9ok</sha1>
    </revision>
    <revision>
      <id>1269</id>
      <parentid>317</parentid>
      <timestamp>2014-09-02T10:38:47Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>CFCF moved page [[Umhlahlandlelasakhiwo:Infobox disease]] to [[Infobox disease]]</comment>
      <origin>1269</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="29" sha1="o4syxbmit9sgrablnbnxrb7y8hctvtp" xml:space="preserve">#REDIRECT [[Infobox disease]]</text>
      <sha1>o4syxbmit9sgrablnbnxrb7y8hctvtp</sha1>
    </revision>
    <revision>
      <id>1270</id>
      <parentid>319</parentid>
      <timestamp>2014-09-10T17:46:32Z</timestamp>
      <contributor>
        <username>incubator&gt;タチコマ robot</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Robot: Fixing double redirect to [[Umhlahlandlelasakhiwo:Infobox disease]]</comment>
      <origin>1270</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="51" sha1="5ugq2um5iikepfkjsm2hrydz97gitdw" xml:space="preserve">#REDIRECT [[Umhlahlandlelasakhiwo:Infobox disease]]</text>
      <sha1>5ugq2um5iikepfkjsm2hrydz97gitdw</sha1>
    </revision>
    <revision>
      <id>1271</id>
      <parentid>320</parentid>
      <timestamp>2024-10-14T13:47:09Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>319</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4973" sha1="cka8ra07le1weu7jafzwixzljytx9ok" xml:space="preserve">&lt;div class=&quot;toc&quot; style=&quot;float:right;width:18em;padding:0.5em;margin:0 0 1em 1em;&quot;&gt;
&lt;table style=&quot;width:100%;&quot;&gt;
&lt;tr&gt;&lt;th colspan=&quot;2&quot;&gt;&lt;big&gt;{{{name|{{PAGENAME}}}}}&lt;/big&gt;&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align:center;&quot;&gt;''Ukuhlukaniswa kweengaba neentlabagelo zangaphandle''&lt;!--''Classification and external resources''--&gt;&lt;/td&gt;&lt;/tr&gt;
{{#if:{{{image|}}}|&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align:center;&quot;&gt;[[Isimumathi:{{{image|}}}{{{Image|}}}|150px|center|{{{caption|{{{name|{{PAGENAME}}}}}}}}]] &lt;small&gt;{{{caption|}}}{{{Caption|}}}&lt;/small&gt;&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{ICD10|}}}|&lt;tr&gt;&lt;td&gt;'''ICD/CIM-10'''&lt;/td&gt;&lt;td&gt;{{{ICD10|}}} {{{ICD10}}}{{#if:{{{ICD10-2|}}}|{{{ICD10-2|}}} {{{ICD10-2}}}|}}&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{ICD9|}}}|&lt;tr&gt;&lt;td&gt;'''ICD/CIM-9'''&lt;/td&gt;&lt;td&gt;{{{ICD9|}}} {{{ICD9}}}&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{OMIM|}}}|&lt;tr&gt;&lt;td&gt;'''OMIM'''&lt;/td&gt;&lt;td&gt;[http://omim.org/entry/{{{OMIM|}}} {{{OMIM}}}]&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{DiseasesDB|}}}|&lt;tr&gt;&lt;td&gt;'''DiseasesDB'''&lt;/td&gt;&lt;td&gt;[http://www.diseasesdatabase.com/ddb{{{DiseasesDB|}}}.htm {{{DiseasesDB}}}]{{#if:{{{DiseasesDB-2|}}}|, [http://www.diseasesdatabase.com/ddb{{{DiseasesDB-2|}}}.htm {{{DiseasesDB-2}}}]|}}&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{MedlinePlus|}}}|&lt;tr&gt;&lt;td&gt;'''MedlinePlus'''&lt;/td&gt;&lt;td&gt;[http://www.nlm.nih.gov/medlineplus/ency/article/{{{MedlinePlus|}}}.htm {{{MedlinePlus}}}]&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{eMedicine|}}}|&lt;tr&gt;&lt;td&gt;'''eMedicine'''&lt;/td&gt;&lt;td&gt;''&amp;lt;Placeholder&amp;gt;''&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{MeSH|}}}|&lt;tr&gt;&lt;td&gt;'''MeSH'''&lt;/td&gt;&lt;td&gt;[http://www.nlm.nih.gov/cgi/mesh/2014/MB_cgi?field=uid&amp;term={{{MeSH}}} {{{MeSH}}}]&lt;/td&gt;&lt;/tr&gt;|}}
&lt;/table&gt;
&lt;/div&gt;&lt;!--

{{ infobox
| abovestyle = background-color: {{{background|{{{Background|lightgrey}}}}}}
| above      = {{{name|{{{Name|&lt;includeonly&gt;{{PAGENAME}}&lt;/includeonly&gt;}}}}}}
| subheader  = &lt;includeonly&gt;''Classification and external resources''&lt;/includeonly&gt;
| image      = {{#invoke:InfoboxImage|InfoboxImage|image={{{image|}}}{{{Image|}}}|size={{{image_size|{{{Width|}}}}}}|sizedefault=frameless|upright=1.06|alt={{{alt|}}}{{{Alt|}}}}}
| caption    = {{{caption|}}}{{{Caption|}}}

| label1     = [[International Statistical Classification of Diseases and Related Health Problems|ICD]]-[[ICD-10|10]]
| data1      = {{{ICD10|}}}

| label2     = [[International Statistical Classification of Diseases and Related Health Problems|ICD]]-[[List of ICD-9 codes|9]]
| data2      = {{{ICD9|}}}

| label3     = [[International Classification of Diseases for Oncology|ICD-O:]]
| data3      = {{{ICDO|}}}

| label4     = [[OMIM]]
| data4      = {{#if:{{{OMIM|}}}|[http://omim.org/entry/{{{OMIM}}} {{{OMIM}}}] {{{OMIM_mult|}}} }}

| label5     = [[Diseases Database|DiseasesDB]]
| data5      = {{#if:{{{DiseasesDB|}}}|[http://www.diseasesdatabase.com/ddb{{{DiseasesDB}}}.htm {{{DiseasesDB}}}] {{{DiseasesDB_mult|}}} }}

| label6     = [[MedlinePlus]]
| data6      = {{#if:{{{MedlinePlus|}}}|[http://www.nlm.nih.gov/medlineplus/ency/article/{{{MedlinePlus}}}.htm {{{MedlinePlus}}}]  {{{MedlinePlus_mult|}}} }}

| label7     = [[Medical Subject Headings|MeSH]]
| data7      = {{comma separated entries
  | 1 = {{#if:{{{MeshID|{{{MeSH|{{{MeSH1|}}}}}}}}} | {{mesh2|{{{MeshID|{{{MeSH|{{{MeSH1}}}}}}}}}| year= {{{MeshYear|{{{MeshYear1|}}}}}} }} }}
  | 2 = {{#if:{{{MeSH2|}}} | {{mesh2|{{{MeSH2|}}}|year={{{MeshYear2|}}}}} }}
  | 3 = {{#if:{{{MeSH3|}}} | {{mesh2|{{{MeSH3|}}}|year={{{MeshYear3|}}}}} }}
  | 4 = {{#if:{{{MeSH4|}}} | {{mesh2|{{{MeSH4|}}}|year={{{MeshYear4|}}}}} }}
  | 5 = {{#if:{{{MeSH5|}}} | {{mesh2|{{{MeSH5|}}}|year={{{MeshYear5|}}}}} }}
  | 6 = {{#if:{{{MeSH6|}}} | {{mesh2|{{{MeSH6|}}}|year={{{MeshYear6|}}}}} }}
  | 7 = {{#if:{{{MeSH7|}}} | {{mesh2|{{{MeSH7|}}}|year={{{MeshYear7|}}}}} }}
  | 8 = {{#if:{{{MeSH8|}}} | {{mesh2|{{{MeSH8|}}}|year={{{MeshYear8|}}}}} }}
  | 9 = {{#if:{{{MeSH9|}}} | {{mesh2|{{{MeSH9|}}}|year={{{MeshYear9|}}}}} }}
  |10 = {{#if: {{{MeshName|}}} | ''{{mesh2 | name = {{{MeshName}}} | number = {{{MeshNumber|}}} }}'' }}
  }}

| label8     = [[GeneReviews]]
| class8     = plainlist
| data8      = {{#if: {{{GeneReviewsNBK|}}}{{{GeneReviewsNBK1|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK|{{{GeneReviewsNBK1}}}}}}|{{{GeneReviewsName|{{{GeneReviewsName1|}}}}}}}}|{{#if: {{{GeneReviewsID|}}}| 
* [http://www.ncbi.nlm.nih.gov/books/n/gene/{{{GeneReviewsID}}}/ {{#if: {{{GeneReviewsName|}}}|{{{GeneReviewsName}}}|{{{GeneReviewsID}}}}}]}}}}{{#if: {{{GeneReviewsNBK2|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK2}}}|{{{GeneReviewsName2|}}}}}}}{{#if: {{{GeneReviewsNBK3|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK3}}}|{{{GeneReviewsName3|}}}}}}}{{#if: {{{GeneReviewsNBK4|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK4}}}|{{{GeneReviewsName4|}}}}}}}{{#if: {{{GeneReviewsNBK5|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK5}}}|{{{GeneReviewsName5|}}}}}}}{{#if: {{{GeneReviewsNBK6|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK6}}}|{{{GeneReviewsName6|}}}}}}}{{#if: {{{GeneReviewsNBK7|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK7}}}|{{{GeneReviewsName7|}}}}}}}

}}--&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>cka8ra07le1weu7jafzwixzljytx9ok</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Infobox person</title>
    <ns>10</ns>
    <id>82</id>
    <revision>
      <id>321</id>
      <timestamp>2016-02-22T13:44:38Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;{{Infobox | bodyclass  = biography vcard | bodystyle  = {{#if:{{{box_width|}}}|width:{{{box_width}}};}} | above      = {{#if:{{{honorific prefix|{{{honorific_prefix|}}}}}}|&lt;sp...&quot;</comment>
      <origin>321</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6347" sha1="hp87m0b9o5la13q4uzro9jiyah5nscq" xml:space="preserve">{{Infobox
| bodyclass  = biography vcard
| bodystyle  = {{#if:{{{box_width|}}}|width:{{{box_width}}};}}
| above      = {{#if:{{{honorific prefix|{{{honorific_prefix|}}}}}}|&lt;span class=&quot;honorific-prefix&quot; style=&quot;font-size: small&quot;&gt;{{{honorific prefix|{{{honorific_prefix|}}}}}}&lt;/span&gt;&lt;br /&gt;}}&lt;includeonly&gt;&lt;span class=&quot;fn&quot;&gt;{{{name|{{PAGENAME}}}}}&lt;/span&gt;&lt;/includeonly&gt;{{#if:{{{honorific suffix|{{{honorific_suffix|}}}}}}|&lt;br /&gt;&lt;span class=&quot;honorific-suffix&quot; style=&quot;font-size: small&quot;&gt;{{{honorific suffix|{{{honorific_suffix|}}}}}}&lt;/span&gt;}}
| image      = {{#if:{{{image|}}}|[[Isimumathi:{{{image}}}|{{px|{{{image size|{{{image_size|{{{imagesize|}}}}}}}}}|frameless}}|alt={{{alt|}}}]]}}
| imageclass = {{image class names|{{{image}}}}}
| caption    = {{{image caption|{{{caption|{{{image_caption|}}}}}}}}}
| label1     = Native name
| data1      = {{#if:{{{native_name|}}}|&lt;span class=&quot;nickname&quot; {{#if:{{{native_name_lang|}}}|lang=&quot;{{{native_name_lang}}}&quot; xml:lang=&quot;{{{native_name_lang}}}&quot;}}&gt;{{{native_name}}}&lt;/span&gt; }}

| label2     = Baptised
| data2      = {{{baptised|}}} 

| label3     = Born
| data3      = {{br separated entries|{{#if:{{{birth_name|{{{birthname|}}}}}}|&lt;span class=&quot;nickname&quot;&gt;{{{birth_name|{{{birthname|}}}}}}&lt;/span&gt;}}|{{{birth_date|{{{birthdate|}}}}}}|{{{birth_place|{{{birthplace|}}}}}}}}

| label4     = Disappeared
| data4      = {{br separated entries|{{{disappeared_date|}}}|{{{disappeared_place|}}} }}

| label5     = Status
| data5      = {{{disappeared_status|}}}

| label6     = Died
| data6      = {{br separated entries|{{{death_date|{{{deathdate|}}}}}}|{{{death_place|{{{deathplace|}}}}}}}}
| label7     = Cause&amp;nbsp;of death
| data7      = {{{death cause|{{{death_cause|}}}}}}

| label8     = Body discovered
| data8      = {{{body discovered|{{{body_discovered|}}}}}}

| label9     = Resting place
| class9     = label
| data9      = {{br separated entries|{{{resting place|{{{resting_place|{{{restingplace|}}}}}}}}}|{{{resting place coordinates|{{{resting_place_coordinates|{{{restingplacecoordinates|}}}}}}}}}}}

| label10     = Monuments
| data10      = {{{monuments|}}}

| label11     = Residence
| class11     = {{#if:{{{death_date|}}}{{{death_place|}}}||label}}
| data11      = {{{residence|}}}

| class12    = category
| label12    = Nationality
| data12     = {{{nationality|}}}

| label13    = Other names
| class13    = nickname
| data13     = {{{other names|{{{other_names|{{{othername|{{{alias|}}}}}}}}}}}}

| class14    = category
| label14    = Ethnicity
| data14     = {{{ethnicity|}}}

| class15    = category
| label15    = Citizenship
| data15     = {{{citizenship|}}}

| label16    = Education
| data16     = {{{education|}}}

| label17    = ''[[Alma mater]]''
| data17     = {{{alma mater|{{{alma_mater|}}}}}}

| label18    = Occupation
| class18    = role
| data18     = {{{occupation|}}}

| label19    = Years active
| data19     = {{{years active|{{{years_active|{{{yearsactive|}}}}}}}}}

| label20    = Employer
| data20     = {{{employer|}}}
| class20    = org

| label21    = Organization
| data21     = {{{organization|{{{organizations|}}}}}}
| class21    = org

| label22    = Agent
| data22     = {{{agent|}}}
| class22    = agent

| label23    = Known&amp;nbsp;for
| data23     = {{{known for|{{{known_for|{{{known|}}}}}}}}}

| label24    = Notable works
| data24     = {{{notable works|{{{notable_works|}}}}}}

| label25    = Style
| data25     = {{{style|}}}
| class25    = category

| label26    = Influenced&amp;nbsp;by
| data26     = {{{influences|}}}

| label27    = Influenced
| data27     = {{{influenced|}}}

| label28    = Home town
| data28     = {{{home town|{{{home_town|}}}}}}

| label29    = Salary
| data29     = {{{salary|}}}

| label30    = Net worth
| data30     = {{{net worth|{{{net_worth|{{{networth|}}}}}}}}}

| label31    = Height
| data31     = {{{height|}}}

| label32    = Weight
| data32     = {{{weight|}}}

| label33    = Television
| data33     = {{{television|}}}

| label34    = Title
| data34     = {{{title|}}}
| class34    = title

| label35    = Term
| data35     = {{{term|}}}

| label36    = Predecessor
| data36     = {{{predecessor|}}}

| label37    = Successor
| data37     = {{{successor|}}}

| label38    = Political party
| data38     = {{{party|}}}
| class38    = org

| label39    = Political movement
| data39     = {{{movement|}}}
| class39    = category

| label40    = &lt;span style=&quot;white-space:nowrap;&quot;&gt;Opponent(s)&lt;/span&gt;
| data40     = {{{opponents|}}}

| label41    = Board member&amp;nbsp;of
| data41     = {{{boards|}}}

| label42    = Religion
| data42     = {{{religion|}}}
| class42    = category

| label43    = Denomination
| data43     = {{{denomination|}}}
| class43    = category

| label44    = Criminal charge
| data44     = {{{criminal charge|{{{criminal_charge|}}}}}}

| label45    = Criminal penalty
| data45     = {{{criminal penalty|{{{criminal_penalty|}}}}}}

| label46    = Criminal status
| data46     = {{{criminal status|{{{criminal_status|}}}}}}
| class46    = category

| label47    = Spouse
| data47     = {{{spouse|}}}

| label48    = Partner
| data48     = {{{partner|{{{domesticpartner|}}}}}}

| label49    = Children
| data49     = {{{children|}}}

| label50    = Parents
| data50     = {{{parents|}}}

| label51    = Relatives
| data51     = {{{relations|{{{relatives|}}}}}}

| label52    = Call-sign
| data52     = {{{callsign|}}}

| label53    = Awards
| data53     = {{{awards|}}}

| data54     = {{{misc|{{{module|}}}}}}
| data55     = {{{misc2|{{{module2|}}}}}}
| data56     = {{{misc3|{{{module3|}}}}}}
| data57     = {{{misc4|{{{module4|}}}}}}
| data58     = {{{misc5|{{{module5|}}}}}}
| data59     = {{{misc6|{{{module6|}}}}}}

| label60   = Signature
| data60     = {{#if:{{{signature|}}}|[[Isimumathi:{{{signature}}}|{{px|{{{signature_size|}}}|150px}}|alt={{{signature alt|{{{signature_alt|}}}}}}]]}}

| header61   = {{#if:{{{website|{{{homepage|{{{URL|}}}}}}}}}|Website}}
| data62     = {{{website|{{{homepage|{{{URL|}}}}}}}}}

| below      = {{#if:{{{footnotes|}}}|'''Notes'''&lt;div style=&quot;line-height:1.2em;&quot;&gt;{{{footnotes}}}&lt;/div&gt;}}
| belowstyle = border-top:1px solid #aaaaaa; text-align:left

}}{{#switch:{{ucfirst:{{{image|}}}}}
|Replace this image male.svg
|Replace_this_image_male.svg
|Replace this image female.svg
|Replace_this_image_female.svg=[[Mkhakha:Infoboxes without image]]
}} 
&lt;/noinclude&gt;</text>
      <sha1>hp87m0b9o5la13q4uzro9jiyah5nscq</sha1>
    </revision>
    <revision>
      <id>322</id>
      <parentid>321</parentid>
      <timestamp>2016-02-22T13:53:19Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>321</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6347" sha1="hp87m0b9o5la13q4uzro9jiyah5nscq" xml:space="preserve">{{Infobox
| bodyclass  = biography vcard
| bodystyle  = {{#if:{{{box_width|}}}|width:{{{box_width}}};}}
| above      = {{#if:{{{honorific prefix|{{{honorific_prefix|}}}}}}|&lt;span class=&quot;honorific-prefix&quot; style=&quot;font-size: small&quot;&gt;{{{honorific prefix|{{{honorific_prefix|}}}}}}&lt;/span&gt;&lt;br /&gt;}}&lt;includeonly&gt;&lt;span class=&quot;fn&quot;&gt;{{{name|{{PAGENAME}}}}}&lt;/span&gt;&lt;/includeonly&gt;{{#if:{{{honorific suffix|{{{honorific_suffix|}}}}}}|&lt;br /&gt;&lt;span class=&quot;honorific-suffix&quot; style=&quot;font-size: small&quot;&gt;{{{honorific suffix|{{{honorific_suffix|}}}}}}&lt;/span&gt;}}
| image      = {{#if:{{{image|}}}|[[Isimumathi:{{{image}}}|{{px|{{{image size|{{{image_size|{{{imagesize|}}}}}}}}}|frameless}}|alt={{{alt|}}}]]}}
| imageclass = {{image class names|{{{image}}}}}
| caption    = {{{image caption|{{{caption|{{{image_caption|}}}}}}}}}
| label1     = Native name
| data1      = {{#if:{{{native_name|}}}|&lt;span class=&quot;nickname&quot; {{#if:{{{native_name_lang|}}}|lang=&quot;{{{native_name_lang}}}&quot; xml:lang=&quot;{{{native_name_lang}}}&quot;}}&gt;{{{native_name}}}&lt;/span&gt; }}

| label2     = Baptised
| data2      = {{{baptised|}}} 

| label3     = Born
| data3      = {{br separated entries|{{#if:{{{birth_name|{{{birthname|}}}}}}|&lt;span class=&quot;nickname&quot;&gt;{{{birth_name|{{{birthname|}}}}}}&lt;/span&gt;}}|{{{birth_date|{{{birthdate|}}}}}}|{{{birth_place|{{{birthplace|}}}}}}}}

| label4     = Disappeared
| data4      = {{br separated entries|{{{disappeared_date|}}}|{{{disappeared_place|}}} }}

| label5     = Status
| data5      = {{{disappeared_status|}}}

| label6     = Died
| data6      = {{br separated entries|{{{death_date|{{{deathdate|}}}}}}|{{{death_place|{{{deathplace|}}}}}}}}
| label7     = Cause&amp;nbsp;of death
| data7      = {{{death cause|{{{death_cause|}}}}}}

| label8     = Body discovered
| data8      = {{{body discovered|{{{body_discovered|}}}}}}

| label9     = Resting place
| class9     = label
| data9      = {{br separated entries|{{{resting place|{{{resting_place|{{{restingplace|}}}}}}}}}|{{{resting place coordinates|{{{resting_place_coordinates|{{{restingplacecoordinates|}}}}}}}}}}}

| label10     = Monuments
| data10      = {{{monuments|}}}

| label11     = Residence
| class11     = {{#if:{{{death_date|}}}{{{death_place|}}}||label}}
| data11      = {{{residence|}}}

| class12    = category
| label12    = Nationality
| data12     = {{{nationality|}}}

| label13    = Other names
| class13    = nickname
| data13     = {{{other names|{{{other_names|{{{othername|{{{alias|}}}}}}}}}}}}

| class14    = category
| label14    = Ethnicity
| data14     = {{{ethnicity|}}}

| class15    = category
| label15    = Citizenship
| data15     = {{{citizenship|}}}

| label16    = Education
| data16     = {{{education|}}}

| label17    = ''[[Alma mater]]''
| data17     = {{{alma mater|{{{alma_mater|}}}}}}

| label18    = Occupation
| class18    = role
| data18     = {{{occupation|}}}

| label19    = Years active
| data19     = {{{years active|{{{years_active|{{{yearsactive|}}}}}}}}}

| label20    = Employer
| data20     = {{{employer|}}}
| class20    = org

| label21    = Organization
| data21     = {{{organization|{{{organizations|}}}}}}
| class21    = org

| label22    = Agent
| data22     = {{{agent|}}}
| class22    = agent

| label23    = Known&amp;nbsp;for
| data23     = {{{known for|{{{known_for|{{{known|}}}}}}}}}

| label24    = Notable works
| data24     = {{{notable works|{{{notable_works|}}}}}}

| label25    = Style
| data25     = {{{style|}}}
| class25    = category

| label26    = Influenced&amp;nbsp;by
| data26     = {{{influences|}}}

| label27    = Influenced
| data27     = {{{influenced|}}}

| label28    = Home town
| data28     = {{{home town|{{{home_town|}}}}}}

| label29    = Salary
| data29     = {{{salary|}}}

| label30    = Net worth
| data30     = {{{net worth|{{{net_worth|{{{networth|}}}}}}}}}

| label31    = Height
| data31     = {{{height|}}}

| label32    = Weight
| data32     = {{{weight|}}}

| label33    = Television
| data33     = {{{television|}}}

| label34    = Title
| data34     = {{{title|}}}
| class34    = title

| label35    = Term
| data35     = {{{term|}}}

| label36    = Predecessor
| data36     = {{{predecessor|}}}

| label37    = Successor
| data37     = {{{successor|}}}

| label38    = Political party
| data38     = {{{party|}}}
| class38    = org

| label39    = Political movement
| data39     = {{{movement|}}}
| class39    = category

| label40    = &lt;span style=&quot;white-space:nowrap;&quot;&gt;Opponent(s)&lt;/span&gt;
| data40     = {{{opponents|}}}

| label41    = Board member&amp;nbsp;of
| data41     = {{{boards|}}}

| label42    = Religion
| data42     = {{{religion|}}}
| class42    = category

| label43    = Denomination
| data43     = {{{denomination|}}}
| class43    = category

| label44    = Criminal charge
| data44     = {{{criminal charge|{{{criminal_charge|}}}}}}

| label45    = Criminal penalty
| data45     = {{{criminal penalty|{{{criminal_penalty|}}}}}}

| label46    = Criminal status
| data46     = {{{criminal status|{{{criminal_status|}}}}}}
| class46    = category

| label47    = Spouse
| data47     = {{{spouse|}}}

| label48    = Partner
| data48     = {{{partner|{{{domesticpartner|}}}}}}

| label49    = Children
| data49     = {{{children|}}}

| label50    = Parents
| data50     = {{{parents|}}}

| label51    = Relatives
| data51     = {{{relations|{{{relatives|}}}}}}

| label52    = Call-sign
| data52     = {{{callsign|}}}

| label53    = Awards
| data53     = {{{awards|}}}

| data54     = {{{misc|{{{module|}}}}}}
| data55     = {{{misc2|{{{module2|}}}}}}
| data56     = {{{misc3|{{{module3|}}}}}}
| data57     = {{{misc4|{{{module4|}}}}}}
| data58     = {{{misc5|{{{module5|}}}}}}
| data59     = {{{misc6|{{{module6|}}}}}}

| label60   = Signature
| data60     = {{#if:{{{signature|}}}|[[Isimumathi:{{{signature}}}|{{px|{{{signature_size|}}}|150px}}|alt={{{signature alt|{{{signature_alt|}}}}}}]]}}

| header61   = {{#if:{{{website|{{{homepage|{{{URL|}}}}}}}}}|Website}}
| data62     = {{{website|{{{homepage|{{{URL|}}}}}}}}}

| below      = {{#if:{{{footnotes|}}}|'''Notes'''&lt;div style=&quot;line-height:1.2em;&quot;&gt;{{{footnotes}}}&lt;/div&gt;}}
| belowstyle = border-top:1px solid #aaaaaa; text-align:left

}}{{#switch:{{ucfirst:{{{image|}}}}}
|Replace this image male.svg
|Replace_this_image_male.svg
|Replace this image female.svg
|Replace_this_image_female.svg=[[Mkhakha:Infoboxes without image]]
}} 
&lt;/noinclude&gt;</text>
      <sha1>hp87m0b9o5la13q4uzro9jiyah5nscq</sha1>
    </revision>
    <revision>
      <id>323</id>
      <parentid>322</parentid>
      <timestamp>2016-02-22T13:59:27Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>321</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6347" sha1="hp87m0b9o5la13q4uzro9jiyah5nscq" xml:space="preserve">{{Infobox
| bodyclass  = biography vcard
| bodystyle  = {{#if:{{{box_width|}}}|width:{{{box_width}}};}}
| above      = {{#if:{{{honorific prefix|{{{honorific_prefix|}}}}}}|&lt;span class=&quot;honorific-prefix&quot; style=&quot;font-size: small&quot;&gt;{{{honorific prefix|{{{honorific_prefix|}}}}}}&lt;/span&gt;&lt;br /&gt;}}&lt;includeonly&gt;&lt;span class=&quot;fn&quot;&gt;{{{name|{{PAGENAME}}}}}&lt;/span&gt;&lt;/includeonly&gt;{{#if:{{{honorific suffix|{{{honorific_suffix|}}}}}}|&lt;br /&gt;&lt;span class=&quot;honorific-suffix&quot; style=&quot;font-size: small&quot;&gt;{{{honorific suffix|{{{honorific_suffix|}}}}}}&lt;/span&gt;}}
| image      = {{#if:{{{image|}}}|[[Isimumathi:{{{image}}}|{{px|{{{image size|{{{image_size|{{{imagesize|}}}}}}}}}|frameless}}|alt={{{alt|}}}]]}}
| imageclass = {{image class names|{{{image}}}}}
| caption    = {{{image caption|{{{caption|{{{image_caption|}}}}}}}}}
| label1     = Native name
| data1      = {{#if:{{{native_name|}}}|&lt;span class=&quot;nickname&quot; {{#if:{{{native_name_lang|}}}|lang=&quot;{{{native_name_lang}}}&quot; xml:lang=&quot;{{{native_name_lang}}}&quot;}}&gt;{{{native_name}}}&lt;/span&gt; }}

| label2     = Baptised
| data2      = {{{baptised|}}} 

| label3     = Born
| data3      = {{br separated entries|{{#if:{{{birth_name|{{{birthname|}}}}}}|&lt;span class=&quot;nickname&quot;&gt;{{{birth_name|{{{birthname|}}}}}}&lt;/span&gt;}}|{{{birth_date|{{{birthdate|}}}}}}|{{{birth_place|{{{birthplace|}}}}}}}}

| label4     = Disappeared
| data4      = {{br separated entries|{{{disappeared_date|}}}|{{{disappeared_place|}}} }}

| label5     = Status
| data5      = {{{disappeared_status|}}}

| label6     = Died
| data6      = {{br separated entries|{{{death_date|{{{deathdate|}}}}}}|{{{death_place|{{{deathplace|}}}}}}}}
| label7     = Cause&amp;nbsp;of death
| data7      = {{{death cause|{{{death_cause|}}}}}}

| label8     = Body discovered
| data8      = {{{body discovered|{{{body_discovered|}}}}}}

| label9     = Resting place
| class9     = label
| data9      = {{br separated entries|{{{resting place|{{{resting_place|{{{restingplace|}}}}}}}}}|{{{resting place coordinates|{{{resting_place_coordinates|{{{restingplacecoordinates|}}}}}}}}}}}

| label10     = Monuments
| data10      = {{{monuments|}}}

| label11     = Residence
| class11     = {{#if:{{{death_date|}}}{{{death_place|}}}||label}}
| data11      = {{{residence|}}}

| class12    = category
| label12    = Nationality
| data12     = {{{nationality|}}}

| label13    = Other names
| class13    = nickname
| data13     = {{{other names|{{{other_names|{{{othername|{{{alias|}}}}}}}}}}}}

| class14    = category
| label14    = Ethnicity
| data14     = {{{ethnicity|}}}

| class15    = category
| label15    = Citizenship
| data15     = {{{citizenship|}}}

| label16    = Education
| data16     = {{{education|}}}

| label17    = ''[[Alma mater]]''
| data17     = {{{alma mater|{{{alma_mater|}}}}}}

| label18    = Occupation
| class18    = role
| data18     = {{{occupation|}}}

| label19    = Years active
| data19     = {{{years active|{{{years_active|{{{yearsactive|}}}}}}}}}

| label20    = Employer
| data20     = {{{employer|}}}
| class20    = org

| label21    = Organization
| data21     = {{{organization|{{{organizations|}}}}}}
| class21    = org

| label22    = Agent
| data22     = {{{agent|}}}
| class22    = agent

| label23    = Known&amp;nbsp;for
| data23     = {{{known for|{{{known_for|{{{known|}}}}}}}}}

| label24    = Notable works
| data24     = {{{notable works|{{{notable_works|}}}}}}

| label25    = Style
| data25     = {{{style|}}}
| class25    = category

| label26    = Influenced&amp;nbsp;by
| data26     = {{{influences|}}}

| label27    = Influenced
| data27     = {{{influenced|}}}

| label28    = Home town
| data28     = {{{home town|{{{home_town|}}}}}}

| label29    = Salary
| data29     = {{{salary|}}}

| label30    = Net worth
| data30     = {{{net worth|{{{net_worth|{{{networth|}}}}}}}}}

| label31    = Height
| data31     = {{{height|}}}

| label32    = Weight
| data32     = {{{weight|}}}

| label33    = Television
| data33     = {{{television|}}}

| label34    = Title
| data34     = {{{title|}}}
| class34    = title

| label35    = Term
| data35     = {{{term|}}}

| label36    = Predecessor
| data36     = {{{predecessor|}}}

| label37    = Successor
| data37     = {{{successor|}}}

| label38    = Political party
| data38     = {{{party|}}}
| class38    = org

| label39    = Political movement
| data39     = {{{movement|}}}
| class39    = category

| label40    = &lt;span style=&quot;white-space:nowrap;&quot;&gt;Opponent(s)&lt;/span&gt;
| data40     = {{{opponents|}}}

| label41    = Board member&amp;nbsp;of
| data41     = {{{boards|}}}

| label42    = Religion
| data42     = {{{religion|}}}
| class42    = category

| label43    = Denomination
| data43     = {{{denomination|}}}
| class43    = category

| label44    = Criminal charge
| data44     = {{{criminal charge|{{{criminal_charge|}}}}}}

| label45    = Criminal penalty
| data45     = {{{criminal penalty|{{{criminal_penalty|}}}}}}

| label46    = Criminal status
| data46     = {{{criminal status|{{{criminal_status|}}}}}}
| class46    = category

| label47    = Spouse
| data47     = {{{spouse|}}}

| label48    = Partner
| data48     = {{{partner|{{{domesticpartner|}}}}}}

| label49    = Children
| data49     = {{{children|}}}

| label50    = Parents
| data50     = {{{parents|}}}

| label51    = Relatives
| data51     = {{{relations|{{{relatives|}}}}}}

| label52    = Call-sign
| data52     = {{{callsign|}}}

| label53    = Awards
| data53     = {{{awards|}}}

| data54     = {{{misc|{{{module|}}}}}}
| data55     = {{{misc2|{{{module2|}}}}}}
| data56     = {{{misc3|{{{module3|}}}}}}
| data57     = {{{misc4|{{{module4|}}}}}}
| data58     = {{{misc5|{{{module5|}}}}}}
| data59     = {{{misc6|{{{module6|}}}}}}

| label60   = Signature
| data60     = {{#if:{{{signature|}}}|[[Isimumathi:{{{signature}}}|{{px|{{{signature_size|}}}|150px}}|alt={{{signature alt|{{{signature_alt|}}}}}}]]}}

| header61   = {{#if:{{{website|{{{homepage|{{{URL|}}}}}}}}}|Website}}
| data62     = {{{website|{{{homepage|{{{URL|}}}}}}}}}

| below      = {{#if:{{{footnotes|}}}|'''Notes'''&lt;div style=&quot;line-height:1.2em;&quot;&gt;{{{footnotes}}}&lt;/div&gt;}}
| belowstyle = border-top:1px solid #aaaaaa; text-align:left

}}{{#switch:{{ucfirst:{{{image|}}}}}
|Replace this image male.svg
|Replace_this_image_male.svg
|Replace this image female.svg
|Replace_this_image_female.svg=[[Mkhakha:Infoboxes without image]]
}} 
&lt;/noinclude&gt;</text>
      <sha1>hp87m0b9o5la13q4uzro9jiyah5nscq</sha1>
    </revision>
    <revision>
      <id>324</id>
      <parentid>323</parentid>
      <timestamp>2024-10-14T13:46:21Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>321</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6347" sha1="hp87m0b9o5la13q4uzro9jiyah5nscq" xml:space="preserve">{{Infobox
| bodyclass  = biography vcard
| bodystyle  = {{#if:{{{box_width|}}}|width:{{{box_width}}};}}
| above      = {{#if:{{{honorific prefix|{{{honorific_prefix|}}}}}}|&lt;span class=&quot;honorific-prefix&quot; style=&quot;font-size: small&quot;&gt;{{{honorific prefix|{{{honorific_prefix|}}}}}}&lt;/span&gt;&lt;br /&gt;}}&lt;includeonly&gt;&lt;span class=&quot;fn&quot;&gt;{{{name|{{PAGENAME}}}}}&lt;/span&gt;&lt;/includeonly&gt;{{#if:{{{honorific suffix|{{{honorific_suffix|}}}}}}|&lt;br /&gt;&lt;span class=&quot;honorific-suffix&quot; style=&quot;font-size: small&quot;&gt;{{{honorific suffix|{{{honorific_suffix|}}}}}}&lt;/span&gt;}}
| image      = {{#if:{{{image|}}}|[[Isimumathi:{{{image}}}|{{px|{{{image size|{{{image_size|{{{imagesize|}}}}}}}}}|frameless}}|alt={{{alt|}}}]]}}
| imageclass = {{image class names|{{{image}}}}}
| caption    = {{{image caption|{{{caption|{{{image_caption|}}}}}}}}}
| label1     = Native name
| data1      = {{#if:{{{native_name|}}}|&lt;span class=&quot;nickname&quot; {{#if:{{{native_name_lang|}}}|lang=&quot;{{{native_name_lang}}}&quot; xml:lang=&quot;{{{native_name_lang}}}&quot;}}&gt;{{{native_name}}}&lt;/span&gt; }}

| label2     = Baptised
| data2      = {{{baptised|}}} 

| label3     = Born
| data3      = {{br separated entries|{{#if:{{{birth_name|{{{birthname|}}}}}}|&lt;span class=&quot;nickname&quot;&gt;{{{birth_name|{{{birthname|}}}}}}&lt;/span&gt;}}|{{{birth_date|{{{birthdate|}}}}}}|{{{birth_place|{{{birthplace|}}}}}}}}

| label4     = Disappeared
| data4      = {{br separated entries|{{{disappeared_date|}}}|{{{disappeared_place|}}} }}

| label5     = Status
| data5      = {{{disappeared_status|}}}

| label6     = Died
| data6      = {{br separated entries|{{{death_date|{{{deathdate|}}}}}}|{{{death_place|{{{deathplace|}}}}}}}}
| label7     = Cause&amp;nbsp;of death
| data7      = {{{death cause|{{{death_cause|}}}}}}

| label8     = Body discovered
| data8      = {{{body discovered|{{{body_discovered|}}}}}}

| label9     = Resting place
| class9     = label
| data9      = {{br separated entries|{{{resting place|{{{resting_place|{{{restingplace|}}}}}}}}}|{{{resting place coordinates|{{{resting_place_coordinates|{{{restingplacecoordinates|}}}}}}}}}}}

| label10     = Monuments
| data10      = {{{monuments|}}}

| label11     = Residence
| class11     = {{#if:{{{death_date|}}}{{{death_place|}}}||label}}
| data11      = {{{residence|}}}

| class12    = category
| label12    = Nationality
| data12     = {{{nationality|}}}

| label13    = Other names
| class13    = nickname
| data13     = {{{other names|{{{other_names|{{{othername|{{{alias|}}}}}}}}}}}}

| class14    = category
| label14    = Ethnicity
| data14     = {{{ethnicity|}}}

| class15    = category
| label15    = Citizenship
| data15     = {{{citizenship|}}}

| label16    = Education
| data16     = {{{education|}}}

| label17    = ''[[Alma mater]]''
| data17     = {{{alma mater|{{{alma_mater|}}}}}}

| label18    = Occupation
| class18    = role
| data18     = {{{occupation|}}}

| label19    = Years active
| data19     = {{{years active|{{{years_active|{{{yearsactive|}}}}}}}}}

| label20    = Employer
| data20     = {{{employer|}}}
| class20    = org

| label21    = Organization
| data21     = {{{organization|{{{organizations|}}}}}}
| class21    = org

| label22    = Agent
| data22     = {{{agent|}}}
| class22    = agent

| label23    = Known&amp;nbsp;for
| data23     = {{{known for|{{{known_for|{{{known|}}}}}}}}}

| label24    = Notable works
| data24     = {{{notable works|{{{notable_works|}}}}}}

| label25    = Style
| data25     = {{{style|}}}
| class25    = category

| label26    = Influenced&amp;nbsp;by
| data26     = {{{influences|}}}

| label27    = Influenced
| data27     = {{{influenced|}}}

| label28    = Home town
| data28     = {{{home town|{{{home_town|}}}}}}

| label29    = Salary
| data29     = {{{salary|}}}

| label30    = Net worth
| data30     = {{{net worth|{{{net_worth|{{{networth|}}}}}}}}}

| label31    = Height
| data31     = {{{height|}}}

| label32    = Weight
| data32     = {{{weight|}}}

| label33    = Television
| data33     = {{{television|}}}

| label34    = Title
| data34     = {{{title|}}}
| class34    = title

| label35    = Term
| data35     = {{{term|}}}

| label36    = Predecessor
| data36     = {{{predecessor|}}}

| label37    = Successor
| data37     = {{{successor|}}}

| label38    = Political party
| data38     = {{{party|}}}
| class38    = org

| label39    = Political movement
| data39     = {{{movement|}}}
| class39    = category

| label40    = &lt;span style=&quot;white-space:nowrap;&quot;&gt;Opponent(s)&lt;/span&gt;
| data40     = {{{opponents|}}}

| label41    = Board member&amp;nbsp;of
| data41     = {{{boards|}}}

| label42    = Religion
| data42     = {{{religion|}}}
| class42    = category

| label43    = Denomination
| data43     = {{{denomination|}}}
| class43    = category

| label44    = Criminal charge
| data44     = {{{criminal charge|{{{criminal_charge|}}}}}}

| label45    = Criminal penalty
| data45     = {{{criminal penalty|{{{criminal_penalty|}}}}}}

| label46    = Criminal status
| data46     = {{{criminal status|{{{criminal_status|}}}}}}
| class46    = category

| label47    = Spouse
| data47     = {{{spouse|}}}

| label48    = Partner
| data48     = {{{partner|{{{domesticpartner|}}}}}}

| label49    = Children
| data49     = {{{children|}}}

| label50    = Parents
| data50     = {{{parents|}}}

| label51    = Relatives
| data51     = {{{relations|{{{relatives|}}}}}}

| label52    = Call-sign
| data52     = {{{callsign|}}}

| label53    = Awards
| data53     = {{{awards|}}}

| data54     = {{{misc|{{{module|}}}}}}
| data55     = {{{misc2|{{{module2|}}}}}}
| data56     = {{{misc3|{{{module3|}}}}}}
| data57     = {{{misc4|{{{module4|}}}}}}
| data58     = {{{misc5|{{{module5|}}}}}}
| data59     = {{{misc6|{{{module6|}}}}}}

| label60   = Signature
| data60     = {{#if:{{{signature|}}}|[[Isimumathi:{{{signature}}}|{{px|{{{signature_size|}}}|150px}}|alt={{{signature alt|{{{signature_alt|}}}}}}]]}}

| header61   = {{#if:{{{website|{{{homepage|{{{URL|}}}}}}}}}|Website}}
| data62     = {{{website|{{{homepage|{{{URL|}}}}}}}}}

| below      = {{#if:{{{footnotes|}}}|'''Notes'''&lt;div style=&quot;line-height:1.2em;&quot;&gt;{{{footnotes}}}&lt;/div&gt;}}
| belowstyle = border-top:1px solid #aaaaaa; text-align:left

}}{{#switch:{{ucfirst:{{{image|}}}}}
|Replace this image male.svg
|Replace_this_image_male.svg
|Replace this image female.svg
|Replace_this_image_female.svg=[[Mkhakha:Infoboxes without image]]
}} 
&lt;/noinclude&gt;</text>
      <sha1>hp87m0b9o5la13q4uzro9jiyah5nscq</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:MONTHNAME</title>
    <ns>10</ns>
    <id>83</id>
    <revision>
      <id>325</id>
      <timestamp>2016-02-22T14:12:16Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;&lt;includeonly&gt;{{#if:{{{1|}}}|{{#switch:{{MONTHNUMBER|{{{1}}}}}|1=January|2=February|3=March|4=April|5=May|6=June|7=July|8=August|9=September|10=October|11=November|12=December|...&quot;</comment>
      <origin>325</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="369" sha1="pyb2vz745mhk9h37yekxaz9s4t8lmqg" xml:space="preserve">&lt;includeonly&gt;{{#if:{{{1|}}}|{{#switch:{{MONTHNUMBER|{{{1}}}}}|1=January|2=February|3=March|4=April|5=May|6=June|7=July|8=August|9=September|10=October|11=November|12=December|Incorrect required parameter 1=''month''!}}|Missing required parameter 1=''month''!}}&lt;/includeonly&gt;&lt;noinclude&gt;

&lt;!-- Add categories and interwikis to the /doc subpage, not here! --&gt;
&lt;/noinclude&gt;</text>
      <sha1>pyb2vz745mhk9h37yekxaz9s4t8lmqg</sha1>
    </revision>
    <revision>
      <id>326</id>
      <parentid>325</parentid>
      <timestamp>2024-10-14T13:46:22Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>325</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="369" sha1="pyb2vz745mhk9h37yekxaz9s4t8lmqg" xml:space="preserve">&lt;includeonly&gt;{{#if:{{{1|}}}|{{#switch:{{MONTHNUMBER|{{{1}}}}}|1=January|2=February|3=March|4=April|5=May|6=June|7=July|8=August|9=September|10=October|11=November|12=December|Incorrect required parameter 1=''month''!}}|Missing required parameter 1=''month''!}}&lt;/includeonly&gt;&lt;noinclude&gt;

&lt;!-- Add categories and interwikis to the /doc subpage, not here! --&gt;
&lt;/noinclude&gt;</text>
      <sha1>pyb2vz745mhk9h37yekxaz9s4t8lmqg</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:NUMBEROFARTICLES</title>
    <ns>10</ns>
    <id>84</id>
    <revision>
      <id>327</id>
      <timestamp>2011-01-27T17:09:56Z</timestamp>
      <contributor>
        <username>incubator&gt;Andrijko Z.</username>
        <id>0</id>
      </contributor>
      <comment>Created page with '[[Khethekileko:Prefixindex/Wp/nr|{{PAGESINCATEGORY:Wp/nr}}]]&lt;noinclude&gt;&lt;/noinclude&gt;'</comment>
      <origin>327</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="83" sha1="ku87v5bdqhfv36aulmindw7c0ko819x" xml:space="preserve">[[Khethekileko:Prefixindex/Wp/nr|{{PAGESINCATEGORY:Wp/nr}}]]&lt;noinclude&gt;&lt;/noinclude&gt;</text>
      <sha1>ku87v5bdqhfv36aulmindw7c0ko819x</sha1>
    </revision>
    <revision>
      <id>328</id>
      <parentid>327</parentid>
      <timestamp>2024-10-14T13:46:22Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>327</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="83" sha1="ku87v5bdqhfv36aulmindw7c0ko819x" xml:space="preserve">[[Khethekileko:Prefixindex/Wp/nr|{{PAGESINCATEGORY:Wp/nr}}]]&lt;noinclude&gt;&lt;/noinclude&gt;</text>
      <sha1>ku87v5bdqhfv36aulmindw7c0ko819x</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Official Document</title>
    <ns>10</ns>
    <id>85</id>
    <revision>
      <id>329</id>
      <timestamp>2016-02-24T17:38:31Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;{| class=&quot;toccolours&quot; style=&quot;float:right; width:250px; margin-left: 1em; font-size: 85%;&quot; | align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | &lt;big&gt;'''{{{ibizo}}}'''&lt;/...&quot;</comment>
      <origin>329</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="827" sha1="63thspdpo5kbr3tbmyeshrm2qewzkzj" xml:space="preserve">{| class=&quot;toccolours&quot; style=&quot;float:right; width:250px; margin-left: 1em; font-size: 85%;&quot;
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | &lt;big&gt;'''{{{ibizo}}}'''&lt;/big&gt;
|-
| align=&quot;center&quot; colspan=&quot;2&quot;  |
{|
| align=&quot;center&quot; width=&quot;120&quot;  | [[Isimumathi:{{{isithombe}}}|150px]]
|}
|-
| style=&quot;padding-left: 0.5em;&quot; | '''Unyaka wokutlola:''' ||  {{{unyaka wokutlola}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | '''Indawo yo kutlolwa:''' ||  {{{indawo yo kutlolwa}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | '''Indawo yo kubelethwa:''' ||  {{{indawo yo kubelethwa}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | '''Inarha yomtlolo:''' ||  {{{inarha yomtlolo}}}
|}
&lt;noinclude&gt;
&lt;pre&gt;
{{Official Document|
| ibizo = 
| isithombe = 
| Unyaka wokutlola = 
| Indawo yo kutlolwa = 
| Inarha yomtlolo = 
}}

&lt;/pre&gt;
[[Mkhakha:Amatlolo]]
&lt;/noinclude&gt;</text>
      <sha1>63thspdpo5kbr3tbmyeshrm2qewzkzj</sha1>
    </revision>
    <revision>
      <id>330</id>
      <parentid>329</parentid>
      <timestamp>2016-02-24T17:40:29Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>330</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="732" sha1="atrw1aa0i0yjs2axvwc5umnhugoqo2g" xml:space="preserve">{| class=&quot;toccolours&quot; style=&quot;float:right; width:250px; margin-left: 1em; font-size: 85%;&quot;
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | &lt;big&gt;'''{{{ibizo}}}'''&lt;/big&gt;
|-
| align=&quot;center&quot; colspan=&quot;2&quot;  |
{|
| align=&quot;center&quot; width=&quot;120&quot;  | [[Isimumathi:{{{isithombe}}}|150px]]
|}
|-
| style=&quot;padding-left: 0.5em;&quot; | '''Unyaka wokutlola:''' ||  {{{unyaka wokutlola}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | '''Indawo yo kutlolwa:''' ||  {{{indawo yo kutlolwa}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | '''Inarha yomtlolo:''' ||  {{{inarha yomtlolo}}}
|}
&lt;noinclude&gt;
&lt;pre&gt;
{{Official Document|
| ibizo = 
| isithombe = 
| Unyaka wokutlola = 
| Indawo yo kutlolwa = 
| Inarha yomtlolo = 
}}

&lt;/pre&gt;
[[Mkhakha:Amatlolo]]
&lt;/noinclude&gt;</text>
      <sha1>atrw1aa0i0yjs2axvwc5umnhugoqo2g</sha1>
    </revision>
    <revision>
      <id>331</id>
      <parentid>330</parentid>
      <timestamp>2024-10-14T13:46:22Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>330</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="732" sha1="atrw1aa0i0yjs2axvwc5umnhugoqo2g" xml:space="preserve">{| class=&quot;toccolours&quot; style=&quot;float:right; width:250px; margin-left: 1em; font-size: 85%;&quot;
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | &lt;big&gt;'''{{{ibizo}}}'''&lt;/big&gt;
|-
| align=&quot;center&quot; colspan=&quot;2&quot;  |
{|
| align=&quot;center&quot; width=&quot;120&quot;  | [[Isimumathi:{{{isithombe}}}|150px]]
|}
|-
| style=&quot;padding-left: 0.5em;&quot; | '''Unyaka wokutlola:''' ||  {{{unyaka wokutlola}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | '''Indawo yo kutlolwa:''' ||  {{{indawo yo kutlolwa}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | '''Inarha yomtlolo:''' ||  {{{inarha yomtlolo}}}
|}
&lt;noinclude&gt;
&lt;pre&gt;
{{Official Document|
| ibizo = 
| isithombe = 
| Unyaka wokutlola = 
| Indawo yo kutlolwa = 
| Inarha yomtlolo = 
}}

&lt;/pre&gt;
[[Mkhakha:Amatlolo]]
&lt;/noinclude&gt;</text>
      <sha1>atrw1aa0i0yjs2axvwc5umnhugoqo2g</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Only in print</title>
    <ns>10</ns>
    <id>86</id>
    <revision>
      <id>332</id>
      <timestamp>2014-09-04T16:20:02Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;&lt;includeonly&gt;{{{1|}}}&lt;/includeonly&gt;&lt;noinclude&gt; {{documentation}} [[Mkhakha:Include in print|!]] &lt;/noinclude&gt;&quot;</comment>
      <origin>332</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="108" sha1="q2i8h7kvuugfn1kyvusvdhjewc9cdcz" xml:space="preserve">&lt;includeonly&gt;{{{1|}}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{documentation}}
[[Mkhakha:Include in print|!]]
&lt;/noinclude&gt;</text>
      <sha1>q2i8h7kvuugfn1kyvusvdhjewc9cdcz</sha1>
    </revision>
    <revision>
      <id>333</id>
      <parentid>332</parentid>
      <timestamp>2014-09-04T16:21:25Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <origin>333</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="79" sha1="rm8emca34tsah296fr9jh9dzgyhnfxo" xml:space="preserve">{{#if:{{hide in print|1}}||{{{1|}}}}}&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>rm8emca34tsah296fr9jh9dzgyhnfxo</sha1>
    </revision>
    <revision>
      <id>334</id>
      <parentid>333</parentid>
      <timestamp>2014-09-04T16:21:38Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <origin>333</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="79" sha1="rm8emca34tsah296fr9jh9dzgyhnfxo" xml:space="preserve">{{#if:{{hide in print|1}}||{{{1|}}}}}&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>rm8emca34tsah296fr9jh9dzgyhnfxo</sha1>
    </revision>
    <revision>
      <id>335</id>
      <parentid>334</parentid>
      <timestamp>2019-05-07T18:05:09Z</timestamp>
      <contributor>
        <username>incubator&gt;Adithyak1997</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Added a prefix to correct unprefixed template issue</comment>
      <origin>333</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="79" sha1="rm8emca34tsah296fr9jh9dzgyhnfxo" xml:space="preserve">{{#if:{{hide in print|1}}||{{{1|}}}}}&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>rm8emca34tsah296fr9jh9dzgyhnfxo</sha1>
    </revision>
    <revision>
      <id>336</id>
      <parentid>335</parentid>
      <timestamp>2024-10-14T13:46:22Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>4 revisions imported</comment>
      <origin>333</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="79" sha1="rm8emca34tsah296fr9jh9dzgyhnfxo" xml:space="preserve">{{#if:{{hide in print|1}}||{{{1|}}}}}&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>rm8emca34tsah296fr9jh9dzgyhnfxo</sha1>
    </revision>
    <revision>
      <id>394</id>
      <parentid>332</parentid>
      <timestamp>2014-09-04T16:20:51Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>#REDIRECT [[Umhlahlandlelasakhiwo:hide_in_print]]</comment>
      <origin>394</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="49" sha1="4jgtptv8leylq8p3yerr6m034esss5g" xml:space="preserve">#REDIRECT [[Umhlahlandlelasakhiwo:Only_in_print]]</text>
      <sha1>4jgtptv8leylq8p3yerr6m034esss5g</sha1>
    </revision>
    <revision>
      <id>395</id>
      <parentid>336</parentid>
      <timestamp>2024-10-14T13:46:26Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>333</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="79" sha1="rm8emca34tsah296fr9jh9dzgyhnfxo" xml:space="preserve">{{#if:{{hide in print|1}}||{{{1|}}}}}&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>rm8emca34tsah296fr9jh9dzgyhnfxo</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Person</title>
    <ns>10</ns>
    <id>87</id>
    <revision>
      <id>337</id>
      <timestamp>2016-02-22T14:34:00Z</timestamp>
      <contributor>
        <username>incubator&gt;Katxis</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;{| class=&quot;toccolours&quot; style=&quot;float:right; width:250px; margin-left: 1em; font-size: 85%;&quot; | align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | &lt;big&gt;'''{{{name}}}'''&lt;/b...&quot;</comment>
      <origin>337</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="934" sha1="bwuv2am2q7jfdbavjl0zbbttxwer627" xml:space="preserve">{| class=&quot;toccolours&quot; style=&quot;float:right; width:250px; margin-left: 1em; font-size: 85%;&quot;
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | &lt;big&gt;'''{{{name}}}'''&lt;/big&gt;
|-
| align=&quot;center&quot; colspan=&quot;2&quot;  |
{|
| align=&quot;center&quot; width=&quot;120&quot;  | {{{image}}}
|}
|-
| style=&quot;padding-left: 0.5em;&quot; | Profession: ||  {{{profession}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | Date of birth: ||  {{{Nartj Wah}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | Place of birth: ||  {{{Koorliny nitja boodjar yey}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | Date of death: ||  {{{Nartj boodjar baal koorliny}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | Place of death: ||  {{{Koorliny wiern yey}}}
|}

&lt;noinclude&gt;
&lt;pre&gt;
{{Person|
| Baal             = 
| Image       =
| Boodjar          = 
| Nartj Wah      = 
| Koorliny nitja boodjar yey   = 
| Nartj boodjar baal koorliny   = 
| Koorliny wiern yey   = 
| Nartj boodjar noonar koorliny wiern  = 
}}
&lt;/pre&gt;
&lt;/noinclude&gt;</text>
      <sha1>bwuv2am2q7jfdbavjl0zbbttxwer627</sha1>
    </revision>
    <revision>
      <id>338</id>
      <parentid>337</parentid>
      <timestamp>2016-02-22T14:52:42Z</timestamp>
      <contributor>
        <username>incubator&gt;Katxis</username>
        <id>0</id>
      </contributor>
      <origin>338</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="945" sha1="3sfiut9ys6oqpuv6xmasud6zjwlzjod" xml:space="preserve">{| class=&quot;toccolours&quot; style=&quot;float:right; width:250px; margin-left: 1em; font-size: 85%;&quot;
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | &lt;big&gt;'''{{{ibizo}}}'''&lt;/big&gt;
|-
| align=&quot;center&quot; colspan=&quot;2&quot;  |
{|
| align=&quot;center&quot; width=&quot;120&quot;  | {{{isithombe}}}
|}
|-
| style=&quot;padding-left: 0.5em;&quot; | Umsebenzi: ||  {{{umsebenzi}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | Ubelethwe ngo: ||  {{{ubelethwe ngo}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | Indawo yo kubelethwa: ||  {{{indawo yo kubelethwa}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | Wahlongakala ngo: ||  {{wahlongakala ngo}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | Indawo yo hlongakala: ||  {{{indawo yo hlongakala}}}
|}

&lt;noinclude&gt;
&lt;pre&gt;
{{Person|
| ibizo             = 
| isithombe       =
| Boodjar          = 
| Nartj Wah      = 
| Koorliny nitja boodjar yey   = 
| Nartj boodjar baal koorliny   = 
| Koorliny wiern yey   = 
| Nartj boodjar noonar koorliny wiern  = 
}}
&lt;/pre&gt;
&lt;/noinclude&gt;</text>
      <sha1>3sfiut9ys6oqpuv6xmasud6zjwlzjod</sha1>
    </revision>
    <revision>
      <id>339</id>
      <parentid>338</parentid>
      <timestamp>2016-02-22T14:52:52Z</timestamp>
      <contributor>
        <username>incubator&gt;Katxis</username>
        <id>0</id>
      </contributor>
      <origin>339</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="946" sha1="10sk5sdz1oilox8j5lvf597r2d77dia" xml:space="preserve">{| class=&quot;toccolours&quot; style=&quot;float:right; width:250px; margin-left: 1em; font-size: 85%;&quot;
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | &lt;big&gt;'''{{{ibizo}}}'''&lt;/big&gt;
|-
| align=&quot;center&quot; colspan=&quot;2&quot;  |
{|
| align=&quot;center&quot; width=&quot;120&quot;  | {{{isithombe}}}
|}
|-
| style=&quot;padding-left: 0.5em;&quot; | Umsebenzi: ||  {{{umsebenzi}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | Ubelethwe ngo: ||  {{{ubelethwe ngo}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | Indawo yo kubelethwa: ||  {{{indawo yo kubelethwa}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | Wahlongakala ngo: ||  {{{wahlongakala ngo}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | Indawo yo hlongakala: ||  {{{indawo yo hlongakala}}}
|}

&lt;noinclude&gt;
&lt;pre&gt;
{{Person|
| ibizo             = 
| isithombe       =
| Boodjar          = 
| Nartj Wah      = 
| Koorliny nitja boodjar yey   = 
| Nartj boodjar baal koorliny   = 
| Koorliny wiern yey   = 
| Nartj boodjar noonar koorliny wiern  = 
}}
&lt;/pre&gt;
&lt;/noinclude&gt;</text>
      <sha1>10sk5sdz1oilox8j5lvf597r2d77dia</sha1>
    </revision>
    <revision>
      <id>340</id>
      <parentid>339</parentid>
      <timestamp>2016-02-22T14:54:16Z</timestamp>
      <contributor>
        <username>incubator&gt;Katxis</username>
        <id>0</id>
      </contributor>
      <origin>340</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="914" sha1="ttwla06x1h3laoi5lq1lx3whulj40og" xml:space="preserve">{| class=&quot;toccolours&quot; style=&quot;float:right; width:250px; margin-left: 1em; font-size: 85%;&quot;
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | &lt;big&gt;'''{{{ibizo}}}'''&lt;/big&gt;
|-
| align=&quot;center&quot; colspan=&quot;2&quot;  |
{|
| align=&quot;center&quot; width=&quot;120&quot;  | {{{isithombe}}}
|}
|-
| style=&quot;padding-left: 0.5em;&quot; | Umsebenzi: ||  {{{umsebenzi}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | Ubelethwe ngo: ||  {{{ubelethwe ngo}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | Indawo yo kubelethwa: ||  {{{indawo yo kubelethwa}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | Wahlongakala ngo: ||  {{{wahlongakala ngo}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | Indawo yo hlongakala: ||  {{{indawo yo hlongakala}}}
|}

&lt;noinclude&gt;
&lt;pre&gt;
{{Person|
| ibizo             = 
| isithombe       =
| Boodjar          = 
| Nartj Wah      = 
| Ubelethwe ngo   = 
| Indawo yo kubelethwa   = 
| Wahlongakala ngo  = 
| Indawo yo hlongakala  = 
}}






&lt;/pre&gt;
&lt;/noinclude&gt;</text>
      <sha1>ttwla06x1h3laoi5lq1lx3whulj40og</sha1>
    </revision>
    <revision>
      <id>341</id>
      <parentid>340</parentid>
      <timestamp>2016-02-22T14:54:29Z</timestamp>
      <contributor>
        <username>incubator&gt;Katxis</username>
        <id>0</id>
      </contributor>
      <origin>341</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="907" sha1="2ldt6m213cuixiux9cmdyyv585yy01j" xml:space="preserve">{| class=&quot;toccolours&quot; style=&quot;float:right; width:250px; margin-left: 1em; font-size: 85%;&quot;
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | &lt;big&gt;'''{{{ibizo}}}'''&lt;/big&gt;
|-
| align=&quot;center&quot; colspan=&quot;2&quot;  |
{|
| align=&quot;center&quot; width=&quot;120&quot;  | {{{isithombe}}}
|}
|-
| style=&quot;padding-left: 0.5em;&quot; | Umsebenzi: ||  {{{umsebenzi}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | Ubelethwe ngo: ||  {{{ubelethwe ngo}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | Indawo yo kubelethwa: ||  {{{indawo yo kubelethwa}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | Wahlongakala ngo: ||  {{{wahlongakala ngo}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | Indawo yo hlongakala: ||  {{{indawo yo hlongakala}}}
|}
&lt;noinclude&gt;
&lt;pre&gt;
{{Person|
| ibizo             = 
| isithombe       =
| Boodjar          = 
| Nartj Wah      = 
| Ubelethwe ngo   = 
| Indawo yo kubelethwa   = 
| Wahlongakala ngo  = 
| Indawo yo hlongakala  = 
}}
&lt;/pre&gt;
&lt;/noinclude&gt;</text>
      <sha1>2ldt6m213cuixiux9cmdyyv585yy01j</sha1>
    </revision>
    <revision>
      <id>342</id>
      <parentid>341</parentid>
      <timestamp>2016-02-22T14:56:18Z</timestamp>
      <contributor>
        <username>incubator&gt;Katxis</username>
        <id>0</id>
      </contributor>
      <origin>342</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="880" sha1="1kpbrcblnmx2cp27q31z1gur3bjbtt2" xml:space="preserve">{| class=&quot;toccolours&quot; style=&quot;float:right; width:250px; margin-left: 1em; font-size: 85%;&quot;
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | &lt;big&gt;'''{{{ibizo}}}'''&lt;/big&gt;
|-
| align=&quot;center&quot; colspan=&quot;2&quot;  |
{|
| align=&quot;center&quot; width=&quot;120&quot;  | {{{isithombe}}}
|}
|-
| style=&quot;padding-left: 0.5em;&quot; | Umsebenzi: ||  {{{umsebenzi}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | Ubelethwe ngo: ||  {{{ubelethwe ngo}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | Indawo yo kubelethwa: ||  {{{indawo yo kubelethwa}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | Wahlongakala ngo: ||  {{{wahlongakala ngo}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | Indawo yo hlongakala: ||  {{{indawo yo hlongakala}}}
|}
&lt;noinclude&gt;
&lt;pre&gt;
{{Person|
| ibizo             = 
| isithombe       =
| umsebenzi = 
| ubelethwe ngo   = 
| indawo yo kubelethwa   = 
| wahlongakala ngo  = 
| indawo yo hlongakala  = 
}}
&lt;/pre&gt;
&lt;/noinclude&gt;</text>
      <sha1>1kpbrcblnmx2cp27q31z1gur3bjbtt2</sha1>
    </revision>
    <revision>
      <id>343</id>
      <parentid>342</parentid>
      <timestamp>2016-02-22T15:09:59Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>343</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="910" sha1="ek9cpufap9i7l9kgqv37gd6il8j5fyb" xml:space="preserve">{| class=&quot;toccolours&quot; style=&quot;float:right; width:250px; margin-left: 1em; font-size: 85%;&quot;
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | &lt;big&gt;'''{{{ibizo}}}'''&lt;/big&gt;
|-
| align=&quot;center&quot; colspan=&quot;2&quot;  |
{|
| align=&quot;center&quot; width=&quot;120&quot;  | {{{isithombe}}}
|}
|-
| style=&quot;padding-left: 0.5em;&quot; | '''Umsebenzi:''' ||  {{{umsebenzi}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | '''Ubelethwe ngo:''' ||  {{{ubelethwe ngo}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | '''Indawo yo kubelethwa:''' ||  {{{indawo yo kubelethwa}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | '''Wahlongakala ngo:''' ||  {{{wahlongakala ngo}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | '''Indawo yo hlongakala:''' ||  {{{indawo yo hlongakala}}}
|}
&lt;noinclude&gt;
&lt;pre&gt;
{{Person|
| ibizo             = 
| isithombe       =
| umsebenzi = 
| ubelethwe ngo   = 
| indawo yo kubelethwa   = 
| wahlongakala ngo  = 
| indawo yo hlongakala  = 
}}
&lt;/pre&gt;
&lt;/noinclude&gt;</text>
      <sha1>ek9cpufap9i7l9kgqv37gd6il8j5fyb</sha1>
    </revision>
    <revision>
      <id>344</id>
      <parentid>343</parentid>
      <timestamp>2016-02-22T22:22:43Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>344</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="928" sha1="3jt18yirdo1hfxyddpmhp5c5d3e6ojw" xml:space="preserve">{| class=&quot;toccolours&quot; style=&quot;float:right; width:250px; margin-left: 1em; font-size: 85%;&quot;
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | &lt;big&gt;'''{{{ibizo}}}'''&lt;/big&gt;
|-
| align=&quot;center&quot; colspan=&quot;2&quot;  |
{|
| align=&quot;center&quot; width=&quot;120&quot;  | {{{isithombe}}}
|}
|-
| style=&quot;padding-left: 0.5em;&quot; | '''Umsebenzi:''' ||  {{{umsebenzi}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | '''Ubelethwe ngo:''' ||  {{{ubelethwe ngo}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | '''Indawo yo kubelethwa:''' ||  {{{indawo yo kubelethwa}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | '''Wahlongakala ngo:''' ||  {{{wahlongakala ngo}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | '''Indawo yo hlongakala:''' ||  {{{indawo yo hlongakala}}}
|}
&lt;noinclude&gt;
&lt;pre&gt;
{{Person|
| ibizo             = 
| isithombe       =
| umsebenzi = 
| ubelethwe ngo   = 
| indawo yo kubelethwa   = 
| wahlongakala ngo  = 
| indawo yo hlongakala  = 
}}
&lt;/pre&gt;
[[Mkhakha:Vanhu]]
&lt;/noinclude&gt;</text>
      <sha1>3jt18yirdo1hfxyddpmhp5c5d3e6ojw</sha1>
    </revision>
    <revision>
      <id>345</id>
      <parentid>344</parentid>
      <timestamp>2016-02-22T22:46:10Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>345</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="950" sha1="az9xpl2ao2ajtwjol5amz4cgwy2zb3h" xml:space="preserve">{| class=&quot;toccolours&quot; style=&quot;float:right; width:250px; margin-left: 1em; font-size: 85%;&quot;
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | &lt;big&gt;'''{{{ibizo}}}'''&lt;/big&gt;
|-
| align=&quot;center&quot; colspan=&quot;2&quot;  |
{|
| align=&quot;center&quot; width=&quot;120&quot;  | [[Isimumathi:{{{isithombe}}}|150px]]
|}
|-
| style=&quot;padding-left: 0.5em;&quot; | '''Umsebenzi:''' ||  {{{umsebenzi}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | '''Ubelethwe ngo:''' ||  {{{ubelethwe ngo}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | '''Indawo yo kubelethwa:''' ||  {{{indawo yo kubelethwa}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | '''Wahlongakala ngo:''' ||  {{{wahlongakala ngo}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | '''Indawo yo hlongakala:''' ||  {{{indawo yo hlongakala}}}
|}
&lt;noinclude&gt;
&lt;pre&gt;
{{Person|
| ibizo             = 
| isithombe       =
| umsebenzi = 
| ubelethwe ngo   = 
| indawo yo kubelethwa   = 
| wahlongakala ngo  = 
| indawo yo hlongakala  = 
}}
&lt;/pre&gt;
[[Mkhakha:Abantu]]
&lt;/noinclude&gt;</text>
      <sha1>az9xpl2ao2ajtwjol5amz4cgwy2zb3h</sha1>
    </revision>
    <revision>
      <id>346</id>
      <parentid>345</parentid>
      <timestamp>2016-02-26T21:20:52Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>346</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="718" sha1="lcr516a5z20w8eoij7ygnaqgaboipy0" xml:space="preserve">{| class=&quot;toccolours&quot; style=&quot;float:right; width:250px; margin-left: 1em; font-size: 85%;&quot;
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | &lt;big&gt;'''{{{ibizo}}}'''&lt;/big&gt;
|-
| align=&quot;center&quot; colspan=&quot;2&quot;  |
{|
| align=&quot;center&quot; width=&quot;120&quot;  | [[Isimumathi:{{{isithombe}}}|150px]]
|}
|-
| style=&quot;padding-left: 0.5em;&quot; | '''Umsebenzi:''' ||  {{{umsebenzi}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | '''Ubelethwe ngo:''' ||  {{{ubelethwe ngo}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | '''Indawo yo kubelethwa:''' ||  {{{indawo yo kubelethwa}}}
|}
&lt;noinclude&gt;
&lt;pre&gt;
{{Person|
| ibizo             = 
| isithombe       =
| umsebenzi = 
| ubelethwe ngo   = 
| indawo yo kubelethwa   = 
}}
&lt;/pre&gt;
[[Mkhakha:Abantu]]
&lt;/noinclude&gt;</text>
      <sha1>lcr516a5z20w8eoij7ygnaqgaboipy0</sha1>
    </revision>
    <revision>
      <id>347</id>
      <parentid>346</parentid>
      <timestamp>2024-10-14T13:46:23Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>10 revisions imported</comment>
      <origin>346</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="718" sha1="lcr516a5z20w8eoij7ygnaqgaboipy0" xml:space="preserve">{| class=&quot;toccolours&quot; style=&quot;float:right; width:250px; margin-left: 1em; font-size: 85%;&quot;
| align=&quot;center&quot; colspan=&quot;2&quot; style=&quot;background:lightgrey;&quot; | &lt;big&gt;'''{{{ibizo}}}'''&lt;/big&gt;
|-
| align=&quot;center&quot; colspan=&quot;2&quot;  |
{|
| align=&quot;center&quot; width=&quot;120&quot;  | [[Isimumathi:{{{isithombe}}}|150px]]
|}
|-
| style=&quot;padding-left: 0.5em;&quot; | '''Umsebenzi:''' ||  {{{umsebenzi}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | '''Ubelethwe ngo:''' ||  {{{ubelethwe ngo}}}
|-
| style=&quot;padding-left: 0.5em;&quot; | '''Indawo yo kubelethwa:''' ||  {{{indawo yo kubelethwa}}}
|}
&lt;noinclude&gt;
&lt;pre&gt;
{{Person|
| ibizo             = 
| isithombe       =
| umsebenzi = 
| ubelethwe ngo   = 
| indawo yo kubelethwa   = 
}}
&lt;/pre&gt;
[[Mkhakha:Abantu]]
&lt;/noinclude&gt;</text>
      <sha1>lcr516a5z20w8eoij7ygnaqgaboipy0</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Pp-meta</title>
    <ns>10</ns>
    <id>88</id>
    <revision>
      <id>348</id>
      <timestamp>2016-02-23T14:27:46Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;{{#ifeq:{{lc:{{{small|}}}}}|yes| &lt;div class=&quot;metadata plainlinks&quot; id=&quot;protected-icon&quot; style=&quot;position:absolute; z-index:100; right:55px; top:10px;&quot;&gt; {{#tag:imagemap| Image:{{{...&quot;</comment>
      <origin>348</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5841" sha1="jo1dl0iql89i79w5aar3sgeedukg1v0" xml:space="preserve">{{#ifeq:{{lc:{{{small|}}}}}|yes|
&lt;div class=&quot;metadata plainlinks&quot; id=&quot;protected-icon&quot; style=&quot;position:absolute; z-index:100; right:55px; top:10px;&quot;&gt;
{{#tag:imagemap|
Image:{{{image|{{#switch:{{lc:{{{type}}}}}
 |full=Padlock.svg
 |semi=Padlock-silver-medium.svg
 |move=Padlock-olive.svg
 |indef=Padlock-red.svg
 |office=Padlock-black.svg
 |create=Padlock-skyblue.svg
 |#default=Transparent.gif
}}}}}{{!}}20px{{!}}{{{icon-text|{{#switch:{{lc:{{{type}}}}}
 |full=Fully protected
 |semi=Semi-protected
 |move=Move protected
 |indef=Permanently protected
 |create=Protected from creation
 |office=Protected by the Wikimedia Office
 |#default=&lt;!--null--&gt;
}}}}}
default [[{{{icon-link|Wikipedia:Protection policy#{{lc:{{{type}}}}}}}}|{{{icon-text|This {{#ifeq:{{NAMESPACE}}|{{ns:0}}|article|page}} is {{#switch:{{lc:{{{type}}}}}
 |semi=semi-
 |move=move-
 |indef=permanently&lt;nowiki&gt; &lt;/nowiki&gt;
 |create=creation-
 |office=&lt;!--null, but should this have a special tag?--&gt;
 |full
 |#default=&lt;!--null--&gt;
}}protected{{#ifeq:{{lc:{{{type}}}}}|indef||{{#if:{{{expiry|}}}|&lt;nowiki&gt; &lt;/nowiki&gt;until {{#time:F j, Y|{{{expiry}}}}}}}}}{{{icon-reason|}}}.}}}]]
desc none
}}
&lt;/div&gt;
|
{{{!}} {{main talk other | demospace={{{demospace|}}}
 | 1 = class=&quot;ambox ambox-protection metadata plainlinks&quot;
 | 2 = class=&quot;messagebox standard-talk metadata plainlinks&quot;
 | 3 = class=&quot;messagebox protected metadata plainlinks&quot; style=&quot;border:2px solid #99B; padding:0px; font-size:0.9em;&quot;
 }}
{{!}} {{main talk other|1=class=&quot;ambox-image&quot; {{!}} |demospace={{{demospace|}}}}}
[[Isimumathi:{{{image|{{#switch:{{lc:{{{type}}}}}
 |full=Padlock.svg
 |semi=Padlock-silver-medium.svg
 |move=Padlock-olive.svg
 |indef=Padlock-red.svg
 |office=Padlock-black.svg
 |create=Padlock-skyblue.svg
 |#default=Transparent.gif
}}}}}|40px|{{{icon-text|This page is {{#switch:{{lc:{{{type}}}}}
 |semi=semi-
 |move=move-
 |indef=permanently&lt;nowiki&gt; &lt;/nowiki&gt;
 |create=creation-
 |office=&lt;!--null, but should this have a special tag?--&gt;
 |full
 |#default=&lt;!--null--&gt;
}}protected.}}}]]
{{!}} {{main talk other|1=class=&quot;ambox-text&quot;|demospace={{{demospace|}}}}} style=&quot;v-align:center; align=left;&quot; {{!}}&lt;!--

--&gt;'''{{{reason-text|{{#switch:{{lc:{{{type}}}}}
 |full=This page is currently [[Wikipedia:This page is protected|protected]] from editing
 |semi=Editing of this {{#ifeq:{{NAMESPACE}}|{{ns:0}}|article|page}} by [[Wikipedia:User access levels#Autoconfirmed_users|new]] or [[Wikipedia:User access levels#Anonymous_users|unregistered]] users is currently [[Wikipedia:Protection policy|disabled]]
 |move=This {{#ifeq:{{NAMESPACE}}|{{ns:0}}|article|page}} is currently [[Wikipedia:This page is protected|protected]] from [[Lisizo:Moving a page|page moves]]
 |indef=This page is [[Wikipedia:This page is protected|protected]] from editing ''indefinitely''
 |office=This {{#ifeq:{{NAMESPACE}}|{{ns:0}}|article|page}} is currently [[Wikipedia:This page is protected|protected]] from editing
 |create=[[Lisizo:Starting a new page|Recreation]] of this {{#ifeq:{{NAMESPACE}}|{{ns:0}}|article|page}} [[Wikipedia:This page is protected|has been disabled]]
}}{{#ifeq:{{lc:{{{type}}}}}|indef||{{#if:{{{expiry|}}}|&amp;#32;until {{#time:[[F j]], [[Y]]|{{{expiry}}}}}}}}}{{{reason&lt;includeonly&gt;|&lt;/includeonly&gt;}}}.}}}'''&lt;br /&gt; {{{explanation-text|{{#ifeq:{{lc:{{{dispute}}}}}|yes|This protection is '''not''' an endorsement of the {{#ifeq:{{{type}}}|move|[{{fullurl:Special:Log|type=move&amp;page={{FULLPAGENAMEE}}}} current title]|[{{fullurl:{{FULLPAGENAMEE}}|action=history}} current version]}}.}} See the [[Wikipedia:Protection policy|protection policy]] and [{{fullurl:Special:Log|type=protect&amp;page={{FULLPAGENAMEE}}}} protection log] for more details. {{#switch:{{lc:{{{type}}}}}
 |full|indef=Please discuss any changes on the [[{{TALKPAGENAME}}|talk page]]; you may use the {{tlx|editprotected}} template to ask an [[Wikipedia:Administrator|administrator]] to make the edit if it is supported by [[Wikipedia:Consensus|consensus]]. {{#ifeq:{{NAMESPACE}}|{{ns:8}}&lt;!--MediaWiki--&gt;||You may also [[Wikipedia:Requests for page protection|request]] that this page be unprotected.}}
 |semi=If you cannot edit this {{#switch:{{NAMESPACE}}|{{ns:0}}=article|{{ns:6}}=image|#default=page}} and you wish to make a change, you can {{#ifeq:{{NAMESPACE}}|{{TALKSPACE}}||[[{{TALKPAGENAME}}|discuss changes on the talk page]],}} [[Wikipedia:Requests for page protection#Current requests for unprotection|request unprotection]], [[Khethekileko:Userlogin|log in]], or &lt;span class=&quot;plainlinks&quot;&gt;[http://en.wikipedia.org/w/index.php?title=Special:Userlogin&amp;type=signup &lt;span style=&quot;color:#002bb8;&quot; title=&quot;Sign in / create account&quot;&gt;create an account&lt;/span&gt;].
 |move=The page may still be edited but cannot be moved until unprotected. Please discuss any suggested moves on the [[{{TALKPAGENAME}}|talk page]] or at [[Wikipedia:Requested moves]].  You can also [[Wikipedia:Requests for page protection|request]] that the page be unprotected.  
 |office=If you are able to edit this page, please discuss all changes and additions on the [[{{TALKPAGENAME}}|talk page]] first. '''Do not remove protection from this article unless you are authorized by the Wikimedia Foundation to do so.'''
 |create=Please see the {{#if:{{{xfd|}}}|'''[[{{{xfd}}}|deletion discussion]]''' or the}} [{{fullurl:Special:Log|type=delete&amp;page={{FULLPAGENAMEE}}}} deletion log] for details of why this page was deleted. If you would like to create a page at this title, you must first [[Wikipedia:Requests for page protection|request]] for it to be unprotected, or for the deleted material to be restored via [[Wikipedia:Deletion review|deletion review]].
}}}}}
{{!}}}
}}&lt;!--End if small--&gt;&lt;includeonly&gt;{{#ifeq:{{lc:{{{categories|no}}}}}|no||{{{categories|}}}}}&lt;/includeonly&gt;&lt;noinclude&gt;

&lt;!-- Add categories and interwikis to the /doc subpage, not here! --&gt;
&lt;/noinclude&gt;</text>
      <sha1>jo1dl0iql89i79w5aar3sgeedukg1v0</sha1>
    </revision>
    <revision>
      <id>349</id>
      <parentid>348</parentid>
      <timestamp>2022-04-27T09:42:46Z</timestamp>
      <contributor>
        <username>incubator&gt;JhsBot</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>JhsBot moved page [[Umhlahlandlelasakhiwo:pp-meta]] to [[Umhlahlandlelasakhiwo:Pp-meta]]: bot: Moving pages with (what would be) lowercase titles to uppercase</comment>
      <origin>348</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5841" sha1="jo1dl0iql89i79w5aar3sgeedukg1v0" xml:space="preserve">{{#ifeq:{{lc:{{{small|}}}}}|yes|
&lt;div class=&quot;metadata plainlinks&quot; id=&quot;protected-icon&quot; style=&quot;position:absolute; z-index:100; right:55px; top:10px;&quot;&gt;
{{#tag:imagemap|
Image:{{{image|{{#switch:{{lc:{{{type}}}}}
 |full=Padlock.svg
 |semi=Padlock-silver-medium.svg
 |move=Padlock-olive.svg
 |indef=Padlock-red.svg
 |office=Padlock-black.svg
 |create=Padlock-skyblue.svg
 |#default=Transparent.gif
}}}}}{{!}}20px{{!}}{{{icon-text|{{#switch:{{lc:{{{type}}}}}
 |full=Fully protected
 |semi=Semi-protected
 |move=Move protected
 |indef=Permanently protected
 |create=Protected from creation
 |office=Protected by the Wikimedia Office
 |#default=&lt;!--null--&gt;
}}}}}
default [[{{{icon-link|Wikipedia:Protection policy#{{lc:{{{type}}}}}}}}|{{{icon-text|This {{#ifeq:{{NAMESPACE}}|{{ns:0}}|article|page}} is {{#switch:{{lc:{{{type}}}}}
 |semi=semi-
 |move=move-
 |indef=permanently&lt;nowiki&gt; &lt;/nowiki&gt;
 |create=creation-
 |office=&lt;!--null, but should this have a special tag?--&gt;
 |full
 |#default=&lt;!--null--&gt;
}}protected{{#ifeq:{{lc:{{{type}}}}}|indef||{{#if:{{{expiry|}}}|&lt;nowiki&gt; &lt;/nowiki&gt;until {{#time:F j, Y|{{{expiry}}}}}}}}}{{{icon-reason|}}}.}}}]]
desc none
}}
&lt;/div&gt;
|
{{{!}} {{main talk other | demospace={{{demospace|}}}
 | 1 = class=&quot;ambox ambox-protection metadata plainlinks&quot;
 | 2 = class=&quot;messagebox standard-talk metadata plainlinks&quot;
 | 3 = class=&quot;messagebox protected metadata plainlinks&quot; style=&quot;border:2px solid #99B; padding:0px; font-size:0.9em;&quot;
 }}
{{!}} {{main talk other|1=class=&quot;ambox-image&quot; {{!}} |demospace={{{demospace|}}}}}
[[Isimumathi:{{{image|{{#switch:{{lc:{{{type}}}}}
 |full=Padlock.svg
 |semi=Padlock-silver-medium.svg
 |move=Padlock-olive.svg
 |indef=Padlock-red.svg
 |office=Padlock-black.svg
 |create=Padlock-skyblue.svg
 |#default=Transparent.gif
}}}}}|40px|{{{icon-text|This page is {{#switch:{{lc:{{{type}}}}}
 |semi=semi-
 |move=move-
 |indef=permanently&lt;nowiki&gt; &lt;/nowiki&gt;
 |create=creation-
 |office=&lt;!--null, but should this have a special tag?--&gt;
 |full
 |#default=&lt;!--null--&gt;
}}protected.}}}]]
{{!}} {{main talk other|1=class=&quot;ambox-text&quot;|demospace={{{demospace|}}}}} style=&quot;v-align:center; align=left;&quot; {{!}}&lt;!--

--&gt;'''{{{reason-text|{{#switch:{{lc:{{{type}}}}}
 |full=This page is currently [[Wikipedia:This page is protected|protected]] from editing
 |semi=Editing of this {{#ifeq:{{NAMESPACE}}|{{ns:0}}|article|page}} by [[Wikipedia:User access levels#Autoconfirmed_users|new]] or [[Wikipedia:User access levels#Anonymous_users|unregistered]] users is currently [[Wikipedia:Protection policy|disabled]]
 |move=This {{#ifeq:{{NAMESPACE}}|{{ns:0}}|article|page}} is currently [[Wikipedia:This page is protected|protected]] from [[Lisizo:Moving a page|page moves]]
 |indef=This page is [[Wikipedia:This page is protected|protected]] from editing ''indefinitely''
 |office=This {{#ifeq:{{NAMESPACE}}|{{ns:0}}|article|page}} is currently [[Wikipedia:This page is protected|protected]] from editing
 |create=[[Lisizo:Starting a new page|Recreation]] of this {{#ifeq:{{NAMESPACE}}|{{ns:0}}|article|page}} [[Wikipedia:This page is protected|has been disabled]]
}}{{#ifeq:{{lc:{{{type}}}}}|indef||{{#if:{{{expiry|}}}|&amp;#32;until {{#time:[[F j]], [[Y]]|{{{expiry}}}}}}}}}{{{reason&lt;includeonly&gt;|&lt;/includeonly&gt;}}}.}}}'''&lt;br /&gt; {{{explanation-text|{{#ifeq:{{lc:{{{dispute}}}}}|yes|This protection is '''not''' an endorsement of the {{#ifeq:{{{type}}}|move|[{{fullurl:Special:Log|type=move&amp;page={{FULLPAGENAMEE}}}} current title]|[{{fullurl:{{FULLPAGENAMEE}}|action=history}} current version]}}.}} See the [[Wikipedia:Protection policy|protection policy]] and [{{fullurl:Special:Log|type=protect&amp;page={{FULLPAGENAMEE}}}} protection log] for more details. {{#switch:{{lc:{{{type}}}}}
 |full|indef=Please discuss any changes on the [[{{TALKPAGENAME}}|talk page]]; you may use the {{tlx|editprotected}} template to ask an [[Wikipedia:Administrator|administrator]] to make the edit if it is supported by [[Wikipedia:Consensus|consensus]]. {{#ifeq:{{NAMESPACE}}|{{ns:8}}&lt;!--MediaWiki--&gt;||You may also [[Wikipedia:Requests for page protection|request]] that this page be unprotected.}}
 |semi=If you cannot edit this {{#switch:{{NAMESPACE}}|{{ns:0}}=article|{{ns:6}}=image|#default=page}} and you wish to make a change, you can {{#ifeq:{{NAMESPACE}}|{{TALKSPACE}}||[[{{TALKPAGENAME}}|discuss changes on the talk page]],}} [[Wikipedia:Requests for page protection#Current requests for unprotection|request unprotection]], [[Khethekileko:Userlogin|log in]], or &lt;span class=&quot;plainlinks&quot;&gt;[http://en.wikipedia.org/w/index.php?title=Special:Userlogin&amp;type=signup &lt;span style=&quot;color:#002bb8;&quot; title=&quot;Sign in / create account&quot;&gt;create an account&lt;/span&gt;].
 |move=The page may still be edited but cannot be moved until unprotected. Please discuss any suggested moves on the [[{{TALKPAGENAME}}|talk page]] or at [[Wikipedia:Requested moves]].  You can also [[Wikipedia:Requests for page protection|request]] that the page be unprotected.  
 |office=If you are able to edit this page, please discuss all changes and additions on the [[{{TALKPAGENAME}}|talk page]] first. '''Do not remove protection from this article unless you are authorized by the Wikimedia Foundation to do so.'''
 |create=Please see the {{#if:{{{xfd|}}}|'''[[{{{xfd}}}|deletion discussion]]''' or the}} [{{fullurl:Special:Log|type=delete&amp;page={{FULLPAGENAMEE}}}} deletion log] for details of why this page was deleted. If you would like to create a page at this title, you must first [[Wikipedia:Requests for page protection|request]] for it to be unprotected, or for the deleted material to be restored via [[Wikipedia:Deletion review|deletion review]].
}}}}}
{{!}}}
}}&lt;!--End if small--&gt;&lt;includeonly&gt;{{#ifeq:{{lc:{{{categories|no}}}}}|no||{{{categories|}}}}}&lt;/includeonly&gt;&lt;noinclude&gt;

&lt;!-- Add categories and interwikis to the /doc subpage, not here! --&gt;
&lt;/noinclude&gt;</text>
      <sha1>jo1dl0iql89i79w5aar3sgeedukg1v0</sha1>
    </revision>
    <revision>
      <id>350</id>
      <parentid>349</parentid>
      <timestamp>2022-10-22T21:33:48Z</timestamp>
      <contributor>
        <username>incubator&gt;CommonsDelinker</username>
        <id>0</id>
      </contributor>
      <comment>Replacing [[Isimumathi:Transparent.gif]] with [[Isimumathi:Pix.gif]] (deleted by [[commons:User:CommonsDelinker|CommonsDelinker]] because of: [[:c:COM:FR|File renamed]]: [[:c:COM:FR#FR6|Criterion 6]]: reversed which duplicate to delete).</comment>
      <origin>350</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5825" sha1="0n6gak318gueb9jr0novqnc0w6dn0zg" xml:space="preserve">{{#ifeq:{{lc:{{{small|}}}}}|yes|
&lt;div class=&quot;metadata plainlinks&quot; id=&quot;protected-icon&quot; style=&quot;position:absolute; z-index:100; right:55px; top:10px;&quot;&gt;
{{#tag:imagemap|
Image:{{{image|{{#switch:{{lc:{{{type}}}}}
 |full=Padlock.svg
 |semi=Padlock-silver-medium.svg
 |move=Padlock-olive.svg
 |indef=Padlock-red.svg
 |office=Padlock-black.svg
 |create=Padlock-skyblue.svg
 |#default=Pix.gif
}}}}}{{!}}20px{{!}}{{{icon-text|{{#switch:{{lc:{{{type}}}}}
 |full=Fully protected
 |semi=Semi-protected
 |move=Move protected
 |indef=Permanently protected
 |create=Protected from creation
 |office=Protected by the Wikimedia Office
 |#default=&lt;!--null--&gt;
}}}}}
default [[{{{icon-link|Wikipedia:Protection policy#{{lc:{{{type}}}}}}}}|{{{icon-text|This {{#ifeq:{{NAMESPACE}}|{{ns:0}}|article|page}} is {{#switch:{{lc:{{{type}}}}}
 |semi=semi-
 |move=move-
 |indef=permanently&lt;nowiki&gt; &lt;/nowiki&gt;
 |create=creation-
 |office=&lt;!--null, but should this have a special tag?--&gt;
 |full
 |#default=&lt;!--null--&gt;
}}protected{{#ifeq:{{lc:{{{type}}}}}|indef||{{#if:{{{expiry|}}}|&lt;nowiki&gt; &lt;/nowiki&gt;until {{#time:F j, Y|{{{expiry}}}}}}}}}{{{icon-reason|}}}.}}}]]
desc none
}}
&lt;/div&gt;
|
{{{!}} {{main talk other | demospace={{{demospace|}}}
 | 1 = class=&quot;ambox ambox-protection metadata plainlinks&quot;
 | 2 = class=&quot;messagebox standard-talk metadata plainlinks&quot;
 | 3 = class=&quot;messagebox protected metadata plainlinks&quot; style=&quot;border:2px solid #99B; padding:0px; font-size:0.9em;&quot;
 }}
{{!}} {{main talk other|1=class=&quot;ambox-image&quot; {{!}} |demospace={{{demospace|}}}}}
[[Isimumathi:{{{image|{{#switch:{{lc:{{{type}}}}}
 |full=Padlock.svg
 |semi=Padlock-silver-medium.svg
 |move=Padlock-olive.svg
 |indef=Padlock-red.svg
 |office=Padlock-black.svg
 |create=Padlock-skyblue.svg
 |#default=Pix.gif
}}}}}|40px|{{{icon-text|This page is {{#switch:{{lc:{{{type}}}}}
 |semi=semi-
 |move=move-
 |indef=permanently&lt;nowiki&gt; &lt;/nowiki&gt;
 |create=creation-
 |office=&lt;!--null, but should this have a special tag?--&gt;
 |full
 |#default=&lt;!--null--&gt;
}}protected.}}}]]
{{!}} {{main talk other|1=class=&quot;ambox-text&quot;|demospace={{{demospace|}}}}} style=&quot;v-align:center; align=left;&quot; {{!}}&lt;!--

--&gt;'''{{{reason-text|{{#switch:{{lc:{{{type}}}}}
 |full=This page is currently [[Wikipedia:This page is protected|protected]] from editing
 |semi=Editing of this {{#ifeq:{{NAMESPACE}}|{{ns:0}}|article|page}} by [[Wikipedia:User access levels#Autoconfirmed_users|new]] or [[Wikipedia:User access levels#Anonymous_users|unregistered]] users is currently [[Wikipedia:Protection policy|disabled]]
 |move=This {{#ifeq:{{NAMESPACE}}|{{ns:0}}|article|page}} is currently [[Wikipedia:This page is protected|protected]] from [[Lisizo:Moving a page|page moves]]
 |indef=This page is [[Wikipedia:This page is protected|protected]] from editing ''indefinitely''
 |office=This {{#ifeq:{{NAMESPACE}}|{{ns:0}}|article|page}} is currently [[Wikipedia:This page is protected|protected]] from editing
 |create=[[Lisizo:Starting a new page|Recreation]] of this {{#ifeq:{{NAMESPACE}}|{{ns:0}}|article|page}} [[Wikipedia:This page is protected|has been disabled]]
}}{{#ifeq:{{lc:{{{type}}}}}|indef||{{#if:{{{expiry|}}}|&amp;#32;until {{#time:[[F j]], [[Y]]|{{{expiry}}}}}}}}}{{{reason&lt;includeonly&gt;|&lt;/includeonly&gt;}}}.}}}'''&lt;br /&gt; {{{explanation-text|{{#ifeq:{{lc:{{{dispute}}}}}|yes|This protection is '''not''' an endorsement of the {{#ifeq:{{{type}}}|move|[{{fullurl:Special:Log|type=move&amp;page={{FULLPAGENAMEE}}}} current title]|[{{fullurl:{{FULLPAGENAMEE}}|action=history}} current version]}}.}} See the [[Wikipedia:Protection policy|protection policy]] and [{{fullurl:Special:Log|type=protect&amp;page={{FULLPAGENAMEE}}}} protection log] for more details. {{#switch:{{lc:{{{type}}}}}
 |full|indef=Please discuss any changes on the [[{{TALKPAGENAME}}|talk page]]; you may use the {{tlx|editprotected}} template to ask an [[Wikipedia:Administrator|administrator]] to make the edit if it is supported by [[Wikipedia:Consensus|consensus]]. {{#ifeq:{{NAMESPACE}}|{{ns:8}}&lt;!--MediaWiki--&gt;||You may also [[Wikipedia:Requests for page protection|request]] that this page be unprotected.}}
 |semi=If you cannot edit this {{#switch:{{NAMESPACE}}|{{ns:0}}=article|{{ns:6}}=image|#default=page}} and you wish to make a change, you can {{#ifeq:{{NAMESPACE}}|{{TALKSPACE}}||[[{{TALKPAGENAME}}|discuss changes on the talk page]],}} [[Wikipedia:Requests for page protection#Current requests for unprotection|request unprotection]], [[Khethekileko:Userlogin|log in]], or &lt;span class=&quot;plainlinks&quot;&gt;[http://en.wikipedia.org/w/index.php?title=Special:Userlogin&amp;type=signup &lt;span style=&quot;color:#002bb8;&quot; title=&quot;Sign in / create account&quot;&gt;create an account&lt;/span&gt;].
 |move=The page may still be edited but cannot be moved until unprotected. Please discuss any suggested moves on the [[{{TALKPAGENAME}}|talk page]] or at [[Wikipedia:Requested moves]].  You can also [[Wikipedia:Requests for page protection|request]] that the page be unprotected.  
 |office=If you are able to edit this page, please discuss all changes and additions on the [[{{TALKPAGENAME}}|talk page]] first. '''Do not remove protection from this article unless you are authorized by the Wikimedia Foundation to do so.'''
 |create=Please see the {{#if:{{{xfd|}}}|'''[[{{{xfd}}}|deletion discussion]]''' or the}} [{{fullurl:Special:Log|type=delete&amp;page={{FULLPAGENAMEE}}}} deletion log] for details of why this page was deleted. If you would like to create a page at this title, you must first [[Wikipedia:Requests for page protection|request]] for it to be unprotected, or for the deleted material to be restored via [[Wikipedia:Deletion review|deletion review]].
}}}}}
{{!}}}
}}&lt;!--End if small--&gt;&lt;includeonly&gt;{{#ifeq:{{lc:{{{categories|no}}}}}|no||{{{categories|}}}}}&lt;/includeonly&gt;&lt;noinclude&gt;

&lt;!-- Add categories and interwikis to the /doc subpage, not here! --&gt;
&lt;/noinclude&gt;</text>
      <sha1>0n6gak318gueb9jr0novqnc0w6dn0zg</sha1>
    </revision>
    <revision>
      <id>351</id>
      <parentid>350</parentid>
      <timestamp>2024-10-14T13:46:23Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>350</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5825" sha1="0n6gak318gueb9jr0novqnc0w6dn0zg" xml:space="preserve">{{#ifeq:{{lc:{{{small|}}}}}|yes|
&lt;div class=&quot;metadata plainlinks&quot; id=&quot;protected-icon&quot; style=&quot;position:absolute; z-index:100; right:55px; top:10px;&quot;&gt;
{{#tag:imagemap|
Image:{{{image|{{#switch:{{lc:{{{type}}}}}
 |full=Padlock.svg
 |semi=Padlock-silver-medium.svg
 |move=Padlock-olive.svg
 |indef=Padlock-red.svg
 |office=Padlock-black.svg
 |create=Padlock-skyblue.svg
 |#default=Pix.gif
}}}}}{{!}}20px{{!}}{{{icon-text|{{#switch:{{lc:{{{type}}}}}
 |full=Fully protected
 |semi=Semi-protected
 |move=Move protected
 |indef=Permanently protected
 |create=Protected from creation
 |office=Protected by the Wikimedia Office
 |#default=&lt;!--null--&gt;
}}}}}
default [[{{{icon-link|Wikipedia:Protection policy#{{lc:{{{type}}}}}}}}|{{{icon-text|This {{#ifeq:{{NAMESPACE}}|{{ns:0}}|article|page}} is {{#switch:{{lc:{{{type}}}}}
 |semi=semi-
 |move=move-
 |indef=permanently&lt;nowiki&gt; &lt;/nowiki&gt;
 |create=creation-
 |office=&lt;!--null, but should this have a special tag?--&gt;
 |full
 |#default=&lt;!--null--&gt;
}}protected{{#ifeq:{{lc:{{{type}}}}}|indef||{{#if:{{{expiry|}}}|&lt;nowiki&gt; &lt;/nowiki&gt;until {{#time:F j, Y|{{{expiry}}}}}}}}}{{{icon-reason|}}}.}}}]]
desc none
}}
&lt;/div&gt;
|
{{{!}} {{main talk other | demospace={{{demospace|}}}
 | 1 = class=&quot;ambox ambox-protection metadata plainlinks&quot;
 | 2 = class=&quot;messagebox standard-talk metadata plainlinks&quot;
 | 3 = class=&quot;messagebox protected metadata plainlinks&quot; style=&quot;border:2px solid #99B; padding:0px; font-size:0.9em;&quot;
 }}
{{!}} {{main talk other|1=class=&quot;ambox-image&quot; {{!}} |demospace={{{demospace|}}}}}
[[Isimumathi:{{{image|{{#switch:{{lc:{{{type}}}}}
 |full=Padlock.svg
 |semi=Padlock-silver-medium.svg
 |move=Padlock-olive.svg
 |indef=Padlock-red.svg
 |office=Padlock-black.svg
 |create=Padlock-skyblue.svg
 |#default=Pix.gif
}}}}}|40px|{{{icon-text|This page is {{#switch:{{lc:{{{type}}}}}
 |semi=semi-
 |move=move-
 |indef=permanently&lt;nowiki&gt; &lt;/nowiki&gt;
 |create=creation-
 |office=&lt;!--null, but should this have a special tag?--&gt;
 |full
 |#default=&lt;!--null--&gt;
}}protected.}}}]]
{{!}} {{main talk other|1=class=&quot;ambox-text&quot;|demospace={{{demospace|}}}}} style=&quot;v-align:center; align=left;&quot; {{!}}&lt;!--

--&gt;'''{{{reason-text|{{#switch:{{lc:{{{type}}}}}
 |full=This page is currently [[Wikipedia:This page is protected|protected]] from editing
 |semi=Editing of this {{#ifeq:{{NAMESPACE}}|{{ns:0}}|article|page}} by [[Wikipedia:User access levels#Autoconfirmed_users|new]] or [[Wikipedia:User access levels#Anonymous_users|unregistered]] users is currently [[Wikipedia:Protection policy|disabled]]
 |move=This {{#ifeq:{{NAMESPACE}}|{{ns:0}}|article|page}} is currently [[Wikipedia:This page is protected|protected]] from [[Lisizo:Moving a page|page moves]]
 |indef=This page is [[Wikipedia:This page is protected|protected]] from editing ''indefinitely''
 |office=This {{#ifeq:{{NAMESPACE}}|{{ns:0}}|article|page}} is currently [[Wikipedia:This page is protected|protected]] from editing
 |create=[[Lisizo:Starting a new page|Recreation]] of this {{#ifeq:{{NAMESPACE}}|{{ns:0}}|article|page}} [[Wikipedia:This page is protected|has been disabled]]
}}{{#ifeq:{{lc:{{{type}}}}}|indef||{{#if:{{{expiry|}}}|&amp;#32;until {{#time:[[F j]], [[Y]]|{{{expiry}}}}}}}}}{{{reason&lt;includeonly&gt;|&lt;/includeonly&gt;}}}.}}}'''&lt;br /&gt; {{{explanation-text|{{#ifeq:{{lc:{{{dispute}}}}}|yes|This protection is '''not''' an endorsement of the {{#ifeq:{{{type}}}|move|[{{fullurl:Special:Log|type=move&amp;page={{FULLPAGENAMEE}}}} current title]|[{{fullurl:{{FULLPAGENAMEE}}|action=history}} current version]}}.}} See the [[Wikipedia:Protection policy|protection policy]] and [{{fullurl:Special:Log|type=protect&amp;page={{FULLPAGENAMEE}}}} protection log] for more details. {{#switch:{{lc:{{{type}}}}}
 |full|indef=Please discuss any changes on the [[{{TALKPAGENAME}}|talk page]]; you may use the {{tlx|editprotected}} template to ask an [[Wikipedia:Administrator|administrator]] to make the edit if it is supported by [[Wikipedia:Consensus|consensus]]. {{#ifeq:{{NAMESPACE}}|{{ns:8}}&lt;!--MediaWiki--&gt;||You may also [[Wikipedia:Requests for page protection|request]] that this page be unprotected.}}
 |semi=If you cannot edit this {{#switch:{{NAMESPACE}}|{{ns:0}}=article|{{ns:6}}=image|#default=page}} and you wish to make a change, you can {{#ifeq:{{NAMESPACE}}|{{TALKSPACE}}||[[{{TALKPAGENAME}}|discuss changes on the talk page]],}} [[Wikipedia:Requests for page protection#Current requests for unprotection|request unprotection]], [[Khethekileko:Userlogin|log in]], or &lt;span class=&quot;plainlinks&quot;&gt;[http://en.wikipedia.org/w/index.php?title=Special:Userlogin&amp;type=signup &lt;span style=&quot;color:#002bb8;&quot; title=&quot;Sign in / create account&quot;&gt;create an account&lt;/span&gt;].
 |move=The page may still be edited but cannot be moved until unprotected. Please discuss any suggested moves on the [[{{TALKPAGENAME}}|talk page]] or at [[Wikipedia:Requested moves]].  You can also [[Wikipedia:Requests for page protection|request]] that the page be unprotected.  
 |office=If you are able to edit this page, please discuss all changes and additions on the [[{{TALKPAGENAME}}|talk page]] first. '''Do not remove protection from this article unless you are authorized by the Wikimedia Foundation to do so.'''
 |create=Please see the {{#if:{{{xfd|}}}|'''[[{{{xfd}}}|deletion discussion]]''' or the}} [{{fullurl:Special:Log|type=delete&amp;page={{FULLPAGENAMEE}}}} deletion log] for details of why this page was deleted. If you would like to create a page at this title, you must first [[Wikipedia:Requests for page protection|request]] for it to be unprotected, or for the deleted material to be restored via [[Wikipedia:Deletion review|deletion review]].
}}}}}
{{!}}}
}}&lt;!--End if small--&gt;&lt;includeonly&gt;{{#ifeq:{{lc:{{{categories|no}}}}}|no||{{{categories|}}}}}&lt;/includeonly&gt;&lt;noinclude&gt;

&lt;!-- Add categories and interwikis to the /doc subpage, not here! --&gt;
&lt;/noinclude&gt;</text>
      <sha1>0n6gak318gueb9jr0novqnc0w6dn0zg</sha1>
    </revision>
    <revision>
      <id>396</id>
      <parentid>349</parentid>
      <timestamp>2022-04-27T09:42:46Z</timestamp>
      <contributor>
        <username>incubator&gt;JhsBot</username>
        <id>0</id>
      </contributor>
      <comment>JhsBot moved page [[Umhlahlandlelasakhiwo:pp-meta]] to [[Umhlahlandlelasakhiwo:Pp-meta]]: bot: Moving pages with (what would be) lowercase titles to uppercase</comment>
      <origin>396</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="43" sha1="fi2hj4rq083zqbtj7j3f0gu8p3b0999" xml:space="preserve">#REDIRECT [[Umhlahlandlelasakhiwo:Pp-meta]]</text>
      <sha1>fi2hj4rq083zqbtj7j3f0gu8p3b0999</sha1>
    </revision>
    <revision>
      <id>397</id>
      <parentid>351</parentid>
      <timestamp>2024-10-14T13:46:26Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>350</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5825" sha1="0n6gak318gueb9jr0novqnc0w6dn0zg" xml:space="preserve">{{#ifeq:{{lc:{{{small|}}}}}|yes|
&lt;div class=&quot;metadata plainlinks&quot; id=&quot;protected-icon&quot; style=&quot;position:absolute; z-index:100; right:55px; top:10px;&quot;&gt;
{{#tag:imagemap|
Image:{{{image|{{#switch:{{lc:{{{type}}}}}
 |full=Padlock.svg
 |semi=Padlock-silver-medium.svg
 |move=Padlock-olive.svg
 |indef=Padlock-red.svg
 |office=Padlock-black.svg
 |create=Padlock-skyblue.svg
 |#default=Pix.gif
}}}}}{{!}}20px{{!}}{{{icon-text|{{#switch:{{lc:{{{type}}}}}
 |full=Fully protected
 |semi=Semi-protected
 |move=Move protected
 |indef=Permanently protected
 |create=Protected from creation
 |office=Protected by the Wikimedia Office
 |#default=&lt;!--null--&gt;
}}}}}
default [[{{{icon-link|Wikipedia:Protection policy#{{lc:{{{type}}}}}}}}|{{{icon-text|This {{#ifeq:{{NAMESPACE}}|{{ns:0}}|article|page}} is {{#switch:{{lc:{{{type}}}}}
 |semi=semi-
 |move=move-
 |indef=permanently&lt;nowiki&gt; &lt;/nowiki&gt;
 |create=creation-
 |office=&lt;!--null, but should this have a special tag?--&gt;
 |full
 |#default=&lt;!--null--&gt;
}}protected{{#ifeq:{{lc:{{{type}}}}}|indef||{{#if:{{{expiry|}}}|&lt;nowiki&gt; &lt;/nowiki&gt;until {{#time:F j, Y|{{{expiry}}}}}}}}}{{{icon-reason|}}}.}}}]]
desc none
}}
&lt;/div&gt;
|
{{{!}} {{main talk other | demospace={{{demospace|}}}
 | 1 = class=&quot;ambox ambox-protection metadata plainlinks&quot;
 | 2 = class=&quot;messagebox standard-talk metadata plainlinks&quot;
 | 3 = class=&quot;messagebox protected metadata plainlinks&quot; style=&quot;border:2px solid #99B; padding:0px; font-size:0.9em;&quot;
 }}
{{!}} {{main talk other|1=class=&quot;ambox-image&quot; {{!}} |demospace={{{demospace|}}}}}
[[Isimumathi:{{{image|{{#switch:{{lc:{{{type}}}}}
 |full=Padlock.svg
 |semi=Padlock-silver-medium.svg
 |move=Padlock-olive.svg
 |indef=Padlock-red.svg
 |office=Padlock-black.svg
 |create=Padlock-skyblue.svg
 |#default=Pix.gif
}}}}}|40px|{{{icon-text|This page is {{#switch:{{lc:{{{type}}}}}
 |semi=semi-
 |move=move-
 |indef=permanently&lt;nowiki&gt; &lt;/nowiki&gt;
 |create=creation-
 |office=&lt;!--null, but should this have a special tag?--&gt;
 |full
 |#default=&lt;!--null--&gt;
}}protected.}}}]]
{{!}} {{main talk other|1=class=&quot;ambox-text&quot;|demospace={{{demospace|}}}}} style=&quot;v-align:center; align=left;&quot; {{!}}&lt;!--

--&gt;'''{{{reason-text|{{#switch:{{lc:{{{type}}}}}
 |full=This page is currently [[Wikipedia:This page is protected|protected]] from editing
 |semi=Editing of this {{#ifeq:{{NAMESPACE}}|{{ns:0}}|article|page}} by [[Wikipedia:User access levels#Autoconfirmed_users|new]] or [[Wikipedia:User access levels#Anonymous_users|unregistered]] users is currently [[Wikipedia:Protection policy|disabled]]
 |move=This {{#ifeq:{{NAMESPACE}}|{{ns:0}}|article|page}} is currently [[Wikipedia:This page is protected|protected]] from [[Lisizo:Moving a page|page moves]]
 |indef=This page is [[Wikipedia:This page is protected|protected]] from editing ''indefinitely''
 |office=This {{#ifeq:{{NAMESPACE}}|{{ns:0}}|article|page}} is currently [[Wikipedia:This page is protected|protected]] from editing
 |create=[[Lisizo:Starting a new page|Recreation]] of this {{#ifeq:{{NAMESPACE}}|{{ns:0}}|article|page}} [[Wikipedia:This page is protected|has been disabled]]
}}{{#ifeq:{{lc:{{{type}}}}}|indef||{{#if:{{{expiry|}}}|&amp;#32;until {{#time:[[F j]], [[Y]]|{{{expiry}}}}}}}}}{{{reason&lt;includeonly&gt;|&lt;/includeonly&gt;}}}.}}}'''&lt;br /&gt; {{{explanation-text|{{#ifeq:{{lc:{{{dispute}}}}}|yes|This protection is '''not''' an endorsement of the {{#ifeq:{{{type}}}|move|[{{fullurl:Special:Log|type=move&amp;page={{FULLPAGENAMEE}}}} current title]|[{{fullurl:{{FULLPAGENAMEE}}|action=history}} current version]}}.}} See the [[Wikipedia:Protection policy|protection policy]] and [{{fullurl:Special:Log|type=protect&amp;page={{FULLPAGENAMEE}}}} protection log] for more details. {{#switch:{{lc:{{{type}}}}}
 |full|indef=Please discuss any changes on the [[{{TALKPAGENAME}}|talk page]]; you may use the {{tlx|editprotected}} template to ask an [[Wikipedia:Administrator|administrator]] to make the edit if it is supported by [[Wikipedia:Consensus|consensus]]. {{#ifeq:{{NAMESPACE}}|{{ns:8}}&lt;!--MediaWiki--&gt;||You may also [[Wikipedia:Requests for page protection|request]] that this page be unprotected.}}
 |semi=If you cannot edit this {{#switch:{{NAMESPACE}}|{{ns:0}}=article|{{ns:6}}=image|#default=page}} and you wish to make a change, you can {{#ifeq:{{NAMESPACE}}|{{TALKSPACE}}||[[{{TALKPAGENAME}}|discuss changes on the talk page]],}} [[Wikipedia:Requests for page protection#Current requests for unprotection|request unprotection]], [[Khethekileko:Userlogin|log in]], or &lt;span class=&quot;plainlinks&quot;&gt;[http://en.wikipedia.org/w/index.php?title=Special:Userlogin&amp;type=signup &lt;span style=&quot;color:#002bb8;&quot; title=&quot;Sign in / create account&quot;&gt;create an account&lt;/span&gt;].
 |move=The page may still be edited but cannot be moved until unprotected. Please discuss any suggested moves on the [[{{TALKPAGENAME}}|talk page]] or at [[Wikipedia:Requested moves]].  You can also [[Wikipedia:Requests for page protection|request]] that the page be unprotected.  
 |office=If you are able to edit this page, please discuss all changes and additions on the [[{{TALKPAGENAME}}|talk page]] first. '''Do not remove protection from this article unless you are authorized by the Wikimedia Foundation to do so.'''
 |create=Please see the {{#if:{{{xfd|}}}|'''[[{{{xfd}}}|deletion discussion]]''' or the}} [{{fullurl:Special:Log|type=delete&amp;page={{FULLPAGENAMEE}}}} deletion log] for details of why this page was deleted. If you would like to create a page at this title, you must first [[Wikipedia:Requests for page protection|request]] for it to be unprotected, or for the deleted material to be restored via [[Wikipedia:Deletion review|deletion review]].
}}}}}
{{!}}}
}}&lt;!--End if small--&gt;&lt;includeonly&gt;{{#ifeq:{{lc:{{{categories|no}}}}}|no||{{{categories|}}}}}&lt;/includeonly&gt;&lt;noinclude&gt;

&lt;!-- Add categories and interwikis to the /doc subpage, not here! --&gt;
&lt;/noinclude&gt;</text>
      <sha1>0n6gak318gueb9jr0novqnc0w6dn0zg</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Pp-template</title>
    <ns>10</ns>
    <id>89</id>
    <revision>
      <id>352</id>
      <timestamp>2016-02-23T14:26:03Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;&lt;noinclude&gt;{{pp-template|small=yes}} &lt;/noinclude&gt;&lt;includeonly&gt;{{pp-meta |type=indef |small={{{small|}}} |demospace={{{demospace|}}} |expiry=&lt;!--not applicable--&gt; |disput...&quot;</comment>
      <origin>352</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="983" sha1="jt5doxh60qo6rqc9u7fvmm3j8rub2u8" xml:space="preserve">&lt;noinclude&gt;{{pp-template|small=yes}}
&lt;/noinclude&gt;&lt;includeonly&gt;{{pp-meta
|type=indef
|small={{{small|}}}
|demospace={{{demospace|}}}
|expiry=&lt;!--not applicable--&gt;
|dispute=no
|icon-text=This {{#ifeq:{{NAMESPACE}}|{{ns:6}}|image, included in a high-risk template or message,|high-risk template}} is indefinitely protected from editing to prevent vandalism.
|reason-text=This {{#switch:{{NAMESPACE}}
  |{{ns:image}}=image, used in one or more [[Wikipedia:High-risk templates|high-risk templates]] and/or [[Khethekileko:Allmessages|system messages]],
  |#default=[[Wikipedia:High-risk templates|high-risk template]]
}} has been [[Wikipedia:This page is protected|protected]] from editing to prevent [[Wikipedia:Vandalism|vandalism]]. {{#switch:{{NAMESPACE}}|{{ns:image}}=&lt;br /&gt;&lt;small&gt;'''Do not move this image''' to [[commons:|Wikimedia Commons]].&lt;/small&gt;}}
|categories={{{categories|[[Mkhakha:Protected templates]]}}}}}&lt;/includeonly&gt;&lt;noinclude&gt;{{pp-template|categories=no}}
&lt;/noinclude&gt;</text>
      <sha1>jt5doxh60qo6rqc9u7fvmm3j8rub2u8</sha1>
    </revision>
    <revision>
      <id>353</id>
      <parentid>352</parentid>
      <timestamp>2016-02-23T14:26:49Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>352</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="983" sha1="jt5doxh60qo6rqc9u7fvmm3j8rub2u8" xml:space="preserve">&lt;noinclude&gt;{{pp-template|small=yes}}
&lt;/noinclude&gt;&lt;includeonly&gt;{{pp-meta
|type=indef
|small={{{small|}}}
|demospace={{{demospace|}}}
|expiry=&lt;!--not applicable--&gt;
|dispute=no
|icon-text=This {{#ifeq:{{NAMESPACE}}|{{ns:6}}|image, included in a high-risk template or message,|high-risk template}} is indefinitely protected from editing to prevent vandalism.
|reason-text=This {{#switch:{{NAMESPACE}}
  |{{ns:image}}=image, used in one or more [[Wikipedia:High-risk templates|high-risk templates]] and/or [[Khethekileko:Allmessages|system messages]],
  |#default=[[Wikipedia:High-risk templates|high-risk template]]
}} has been [[Wikipedia:This page is protected|protected]] from editing to prevent [[Wikipedia:Vandalism|vandalism]]. {{#switch:{{NAMESPACE}}|{{ns:image}}=&lt;br /&gt;&lt;small&gt;'''Do not move this image''' to [[commons:|Wikimedia Commons]].&lt;/small&gt;}}
|categories={{{categories|[[Mkhakha:Protected templates]]}}}}}&lt;/includeonly&gt;&lt;noinclude&gt;{{pp-template|categories=no}}
&lt;/noinclude&gt;</text>
      <sha1>jt5doxh60qo6rqc9u7fvmm3j8rub2u8</sha1>
    </revision>
    <revision>
      <id>354</id>
      <parentid>353</parentid>
      <timestamp>2022-04-27T09:42:49Z</timestamp>
      <contributor>
        <username>incubator&gt;JhsBot</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>JhsBot moved page [[Umhlahlandlelasakhiwo:pp-template]] to [[Umhlahlandlelasakhiwo:Pp-template]]: bot: Moving pages with (what would be) lowercase titles to uppercase</comment>
      <origin>352</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="983" sha1="jt5doxh60qo6rqc9u7fvmm3j8rub2u8" xml:space="preserve">&lt;noinclude&gt;{{pp-template|small=yes}}
&lt;/noinclude&gt;&lt;includeonly&gt;{{pp-meta
|type=indef
|small={{{small|}}}
|demospace={{{demospace|}}}
|expiry=&lt;!--not applicable--&gt;
|dispute=no
|icon-text=This {{#ifeq:{{NAMESPACE}}|{{ns:6}}|image, included in a high-risk template or message,|high-risk template}} is indefinitely protected from editing to prevent vandalism.
|reason-text=This {{#switch:{{NAMESPACE}}
  |{{ns:image}}=image, used in one or more [[Wikipedia:High-risk templates|high-risk templates]] and/or [[Khethekileko:Allmessages|system messages]],
  |#default=[[Wikipedia:High-risk templates|high-risk template]]
}} has been [[Wikipedia:This page is protected|protected]] from editing to prevent [[Wikipedia:Vandalism|vandalism]]. {{#switch:{{NAMESPACE}}|{{ns:image}}=&lt;br /&gt;&lt;small&gt;'''Do not move this image''' to [[commons:|Wikimedia Commons]].&lt;/small&gt;}}
|categories={{{categories|[[Mkhakha:Protected templates]]}}}}}&lt;/includeonly&gt;&lt;noinclude&gt;{{pp-template|categories=no}}
&lt;/noinclude&gt;</text>
      <sha1>jt5doxh60qo6rqc9u7fvmm3j8rub2u8</sha1>
    </revision>
    <revision>
      <id>355</id>
      <parentid>354</parentid>
      <timestamp>2024-10-14T13:46:23Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>352</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="983" sha1="jt5doxh60qo6rqc9u7fvmm3j8rub2u8" xml:space="preserve">&lt;noinclude&gt;{{pp-template|small=yes}}
&lt;/noinclude&gt;&lt;includeonly&gt;{{pp-meta
|type=indef
|small={{{small|}}}
|demospace={{{demospace|}}}
|expiry=&lt;!--not applicable--&gt;
|dispute=no
|icon-text=This {{#ifeq:{{NAMESPACE}}|{{ns:6}}|image, included in a high-risk template or message,|high-risk template}} is indefinitely protected from editing to prevent vandalism.
|reason-text=This {{#switch:{{NAMESPACE}}
  |{{ns:image}}=image, used in one or more [[Wikipedia:High-risk templates|high-risk templates]] and/or [[Khethekileko:Allmessages|system messages]],
  |#default=[[Wikipedia:High-risk templates|high-risk template]]
}} has been [[Wikipedia:This page is protected|protected]] from editing to prevent [[Wikipedia:Vandalism|vandalism]]. {{#switch:{{NAMESPACE}}|{{ns:image}}=&lt;br /&gt;&lt;small&gt;'''Do not move this image''' to [[commons:|Wikimedia Commons]].&lt;/small&gt;}}
|categories={{{categories|[[Mkhakha:Protected templates]]}}}}}&lt;/includeonly&gt;&lt;noinclude&gt;{{pp-template|categories=no}}
&lt;/noinclude&gt;</text>
      <sha1>jt5doxh60qo6rqc9u7fvmm3j8rub2u8</sha1>
    </revision>
    <revision>
      <id>398</id>
      <parentid>354</parentid>
      <timestamp>2022-04-27T09:42:49Z</timestamp>
      <contributor>
        <username>incubator&gt;JhsBot</username>
        <id>0</id>
      </contributor>
      <comment>JhsBot moved page [[Umhlahlandlelasakhiwo:pp-template]] to [[Umhlahlandlelasakhiwo:Pp-template]]: bot: Moving pages with (what would be) lowercase titles to uppercase</comment>
      <origin>398</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="47" sha1="hjeu5y7e6ajeqr7u737olbhlnhkj4yb" xml:space="preserve">#REDIRECT [[Umhlahlandlelasakhiwo:Pp-template]]</text>
      <sha1>hjeu5y7e6ajeqr7u737olbhlnhkj4yb</sha1>
    </revision>
    <revision>
      <id>399</id>
      <parentid>355</parentid>
      <timestamp>2024-10-14T13:46:26Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>352</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="983" sha1="jt5doxh60qo6rqc9u7fvmm3j8rub2u8" xml:space="preserve">&lt;noinclude&gt;{{pp-template|small=yes}}
&lt;/noinclude&gt;&lt;includeonly&gt;{{pp-meta
|type=indef
|small={{{small|}}}
|demospace={{{demospace|}}}
|expiry=&lt;!--not applicable--&gt;
|dispute=no
|icon-text=This {{#ifeq:{{NAMESPACE}}|{{ns:6}}|image, included in a high-risk template or message,|high-risk template}} is indefinitely protected from editing to prevent vandalism.
|reason-text=This {{#switch:{{NAMESPACE}}
  |{{ns:image}}=image, used in one or more [[Wikipedia:High-risk templates|high-risk templates]] and/or [[Khethekileko:Allmessages|system messages]],
  |#default=[[Wikipedia:High-risk templates|high-risk template]]
}} has been [[Wikipedia:This page is protected|protected]] from editing to prevent [[Wikipedia:Vandalism|vandalism]]. {{#switch:{{NAMESPACE}}|{{ns:image}}=&lt;br /&gt;&lt;small&gt;'''Do not move this image''' to [[commons:|Wikimedia Commons]].&lt;/small&gt;}}
|categories={{{categories|[[Mkhakha:Protected templates]]}}}}}&lt;/includeonly&gt;&lt;noinclude&gt;{{pp-template|categories=no}}
&lt;/noinclude&gt;</text>
      <sha1>jt5doxh60qo6rqc9u7fvmm3j8rub2u8</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Refbegin</title>
    <ns>10</ns>
    <id>90</id>
    <revision>
      <id>356</id>
      <timestamp>2014-09-04T16:00:36Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;&lt;includeonly&gt;&lt;div class=&quot;refbegin &lt;!--  --&gt;{{#if: {{{normalfont|}}}     | refbegin-100 }} &lt;!--  --&gt;{{#if: {{{1|}}}     | columns {{#iferror: {{#ifexpr: {{{1|1}}} &gt; 1 }}...&quot;</comment>
      <origin>356</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="752" sha1="l6okm8135xhah28f8cuz338k0vca2pn" xml:space="preserve">&lt;includeonly&gt;&lt;div class=&quot;refbegin &lt;!--
 --&gt;{{#if: {{{normalfont|}}}
    | refbegin-100 }} &lt;!--
 --&gt;{{#if: {{{1|}}}
    | columns {{#iferror: {{#ifexpr: {{{1|1}}} &gt; 1 }}
      | references-column-width 
      | references-column-count references-column-count-{{#if:1|{{{1}}}}} }}
    | {{#if: {{{colwidth|}}}
      | references-column-width }} }}&quot; style=&quot;&lt;!--
 --&gt;{{#if: {{{1|}}}
    | {{#iferror: {{#ifexpr: {{{1|1}}} &gt; 1 }}
      | {{column-width|{{#if:1|{{{1}}}}}}}
      | {{column-count|{{#if:1|{{{1}}}}}}} }}
    | {{#if: {{{colwidth|}}}
      | {{column-width|{{{colwidth}}}}} }} }}&quot;&gt;&lt;!--
 --&gt;{{#if: {{{indent|}}}
    | &lt;dl style=&quot;text-indent: -{{{indentsize|3.2}}}em;&quot;&gt;}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{Documentation}}
{{/TemplateData}}
&lt;/noinclude&gt;</text>
      <sha1>l6okm8135xhah28f8cuz338k0vca2pn</sha1>
    </revision>
    <revision>
      <id>357</id>
      <parentid>356</parentid>
      <timestamp>2019-12-06T16:54:03Z</timestamp>
      <contributor>
        <username>incubator&gt;Adithyak1997</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Added some prefixes</comment>
      <origin>357</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="752" sha1="4ipebpx1uiz8tfnqxpm8qn8tl3s2b90" xml:space="preserve">&lt;includeonly&gt;&lt;div class=&quot;refbegin &lt;!--
 --&gt;{{#if: {{{normalfont|}}}
    | refbegin-100 }} &lt;!--
 --&gt;{{#if: {{{1|}}}
    | columns {{#iferror: {{#ifexpr: {{{1|1}}} &gt; 1 }}
      | references-column-width 
      | references-column-count references-column-count-{{#if:1|{{{1}}}}} }}
    | {{#if: {{{colwidth|}}}
      | references-column-width }} }}&quot; style=&quot;&lt;!--
 --&gt;{{#if: {{{1|}}}
    | {{#iferror: {{#ifexpr: {{{1|1}}} &gt; 1 }}
      | {{Column-width|{{#if:1|{{{1}}}}}}}
      | {{Column-count|{{#if:1|{{{1}}}}}}} }}
    | {{#if: {{{colwidth|}}}
      | {{Column-width|{{{colwidth}}}}} }} }}&quot;&gt;&lt;!--
 --&gt;{{#if: {{{indent|}}}
    | &lt;dl style=&quot;text-indent: -{{{indentsize|3.2}}}em;&quot;&gt;}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{Documentation}}
{{/TemplateData}}
&lt;/noinclude&gt;</text>
      <sha1>4ipebpx1uiz8tfnqxpm8qn8tl3s2b90</sha1>
    </revision>
    <revision>
      <id>358</id>
      <parentid>357</parentid>
      <timestamp>2024-10-14T13:46:24Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>357</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="752" sha1="4ipebpx1uiz8tfnqxpm8qn8tl3s2b90" xml:space="preserve">&lt;includeonly&gt;&lt;div class=&quot;refbegin &lt;!--
 --&gt;{{#if: {{{normalfont|}}}
    | refbegin-100 }} &lt;!--
 --&gt;{{#if: {{{1|}}}
    | columns {{#iferror: {{#ifexpr: {{{1|1}}} &gt; 1 }}
      | references-column-width 
      | references-column-count references-column-count-{{#if:1|{{{1}}}}} }}
    | {{#if: {{{colwidth|}}}
      | references-column-width }} }}&quot; style=&quot;&lt;!--
 --&gt;{{#if: {{{1|}}}
    | {{#iferror: {{#ifexpr: {{{1|1}}} &gt; 1 }}
      | {{Column-width|{{#if:1|{{{1}}}}}}}
      | {{Column-count|{{#if:1|{{{1}}}}}}} }}
    | {{#if: {{{colwidth|}}}
      | {{Column-width|{{{colwidth}}}}} }} }}&quot;&gt;&lt;!--
 --&gt;{{#if: {{{indent|}}}
    | &lt;dl style=&quot;text-indent: -{{{indentsize|3.2}}}em;&quot;&gt;}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{Documentation}}
{{/TemplateData}}
&lt;/noinclude&gt;</text>
      <sha1>4ipebpx1uiz8tfnqxpm8qn8tl3s2b90</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Refend</title>
    <ns>10</ns>
    <id>91</id>
    <revision>
      <id>359</id>
      <timestamp>2014-09-04T16:01:04Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;&lt;includeonly&gt;&lt;/dl&gt;&lt;/div&gt;&lt;/includeonly&gt;&lt;noinclude&gt; {{template doc|Template:refbegin/doc}} {{TemplateDataHeader}} &lt;templatedata&gt; {     &quot;description&quot;: &quot;Ends a reference lists sta...&quot;</comment>
      <origin>359</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="251" sha1="ge8cznfxl0zil9rreahsolaz4ivrvek" xml:space="preserve">&lt;includeonly&gt;&lt;/dl&gt;&lt;/div&gt;&lt;/includeonly&gt;&lt;noinclude&gt;
{{template doc|Template:refbegin/doc}}
{{TemplateDataHeader}}
&lt;templatedata&gt;
{
    &quot;description&quot;: &quot;Ends a reference lists started by {{refbegin}}.&quot;,
    &quot;params&quot;: {
    }
}
&lt;/templatedata&gt;
&lt;/noinclude&gt;</text>
      <sha1>ge8cznfxl0zil9rreahsolaz4ivrvek</sha1>
    </revision>
    <revision>
      <id>360</id>
      <parentid>359</parentid>
      <timestamp>2024-10-14T13:46:24Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>359</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="251" sha1="ge8cznfxl0zil9rreahsolaz4ivrvek" xml:space="preserve">&lt;includeonly&gt;&lt;/dl&gt;&lt;/div&gt;&lt;/includeonly&gt;&lt;noinclude&gt;
{{template doc|Template:refbegin/doc}}
{{TemplateDataHeader}}
&lt;templatedata&gt;
{
    &quot;description&quot;: &quot;Ends a reference lists started by {{refbegin}}.&quot;,
    &quot;params&quot;: {
    }
}
&lt;/templatedata&gt;
&lt;/noinclude&gt;</text>
      <sha1>ge8cznfxl0zil9rreahsolaz4ivrvek</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Reflist</title>
    <ns>10</ns>
    <id>92</id>
    <revision>
      <id>361</id>
      <timestamp>2014-09-02T10:42:44Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>From [[:en:Template:Reflist]]</comment>
      <origin>361</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="817" sha1="4gkyehj7b4opv62ycz6r0hb716dhgog" xml:space="preserve">&lt;div class=&quot;reflist &lt;!--
 --&gt;{{#if: {{{1|}}}
    | columns {{#iferror: {{#ifexpr: {{{1|1}}} &gt; 1 }}
      | references-column-width 
      | references-column-count references-column-count-{{#if:1|{{{1}}}}} }}
    | {{#if: {{{colwidth|}}}
      | references-column-width }} }}&quot; style=&quot;&lt;!--
 --&gt;{{#if: {{{1|}}}
    | {{#iferror: {{#ifexpr: {{{1|1}}} &gt; 1 }}
      | {{column-width|{{#if:1|{{{1}}}}}}}
      | {{column-count|{{#if:1|{{{1}}}}}}} }}
    | {{#if: {{{colwidth|}}}
      | {{column-width|{{{colwidth}}}}} }} }} list-style-type: &lt;!--
 --&gt;{{{liststyle|{{#switch: {{{group|}}}
    | upper-alpha
    | upper-roman
    | lower-alpha
    | lower-greek
    | lower-roman = {{{group}}}
    | #default = decimal}}}}};&quot;&gt;
{{#tag:references|{{{refs|}}}|group={{{group|}}}}}&lt;/div&gt;&lt;noinclude&gt;
{{Documentation}}
&lt;/noinclude&gt;</text>
      <sha1>4gkyehj7b4opv62ycz6r0hb716dhgog</sha1>
    </revision>
    <revision>
      <id>362</id>
      <parentid>361</parentid>
      <timestamp>2016-02-23T14:23:51Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>362</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="464" sha1="k5ypi8e538g8wp13da525fg2svgzdrg" xml:space="preserve">&lt;div class=&quot;references-small&quot; {{#if: {{{colwidth|}}}| style=&quot;-moz-column-width:{{{colwidth}}}; -webkit-column-width:{{{colwidth}}}; column-width:{{{colwidth}}};&quot; | {{#if: {{{1|}}}| style=&quot;-moz-column-count:{{{1}}}; -webkit-column-count:{{{1}}}; column-count:{{{1}}};&quot; }} }}&gt;
{{#tag:references||group={{{group|}}}}}&lt;/div&gt;&lt;noinclude&gt;{{pp-template|small=yes}}{{documentation}}
[[br:Patrom:Reflist]]
[[he:תבנית:Reflist]]
[[pt:Predefinição:Reflist]]
&lt;/noinclude&gt;</text>
      <sha1>k5ypi8e538g8wp13da525fg2svgzdrg</sha1>
    </revision>
    <revision>
      <id>363</id>
      <parentid>362</parentid>
      <timestamp>2016-02-23T14:24:47Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>363</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="447" sha1="gi174cp8n7c4sjwoaaagrsj9pdd9f3i" xml:space="preserve">&lt;div class=&quot;references-small&quot; {{#if: {{{colwidth|}}}| style=&quot;-moz-column-width:{{{colwidth}}}; -webkit-column-width:{{{colwidth}}}; column-width:{{{colwidth}}};&quot; | {{#if: {{{1|}}}| style=&quot;-moz-column-count:{{{1}}}; -webkit-column-count:{{{1}}}; column-count:{{{1}}};&quot; }} }}&gt;
{{#tag:references||group={{{group|}}}}}&lt;/div&gt;&lt;noinclude&gt;{{pp-template|small=yes}}
[[br:Patrom:Reflist]]
[[he:תבנית:Reflist]]
[[pt:Predefinição:Reflist]]
&lt;/noinclude&gt;</text>
      <sha1>gi174cp8n7c4sjwoaaagrsj9pdd9f3i</sha1>
    </revision>
    <revision>
      <id>364</id>
      <parentid>363</parentid>
      <timestamp>2024-10-14T13:46:24Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>363</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="447" sha1="gi174cp8n7c4sjwoaaagrsj9pdd9f3i" xml:space="preserve">&lt;div class=&quot;references-small&quot; {{#if: {{{colwidth|}}}| style=&quot;-moz-column-width:{{{colwidth}}}; -webkit-column-width:{{{colwidth}}}; column-width:{{{colwidth}}};&quot; | {{#if: {{{1|}}}| style=&quot;-moz-column-count:{{{1}}}; -webkit-column-count:{{{1}}}; column-count:{{{1}}};&quot; }} }}&gt;
{{#tag:references||group={{{group|}}}}}&lt;/div&gt;&lt;noinclude&gt;{{pp-template|small=yes}}
[[br:Patrom:Reflist]]
[[he:תבנית:Reflist]]
[[pt:Predefinição:Reflist]]
&lt;/noinclude&gt;</text>
      <sha1>gi174cp8n7c4sjwoaaagrsj9pdd9f3i</sha1>
    </revision>
    <revision>
      <id>1772</id>
      <parentid>364</parentid>
      <timestamp>2024-10-30T18:57:34Z</timestamp>
      <contributor>
        <username>Pppery</username>
        <id>47</id>
      </contributor>
      <comment>Move to Wikidata</comment>
      <origin>1772</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="369" sha1="birqo0hptm2rfa59ssbmdnqb9nhv3t6" xml:space="preserve">&lt;div class=&quot;references-small&quot; {{#if: {{{colwidth|}}}| style=&quot;-moz-column-width:{{{colwidth}}}; -webkit-column-width:{{{colwidth}}}; column-width:{{{colwidth}}};&quot; | {{#if: {{{1|}}}| style=&quot;-moz-column-count:{{{1}}}; -webkit-column-count:{{{1}}}; column-count:{{{1}}};&quot; }} }}&gt;
{{#tag:references||group={{{group|}}}}}&lt;/div&gt;&lt;noinclude&gt;{{pp-template|small=yes}}
&lt;/noinclude&gt;</text>
      <sha1>birqo0hptm2rfa59ssbmdnqb9nhv3t6</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Wikipedia:Imitlolo aqakathekileyo/Level/Nav bar</title>
    <ns>10</ns>
    <id>93</id>
    <revision>
      <id>365</id>
      <timestamp>2019-01-11T15:43:49Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;&lt;center&gt;'''Izigaba zemitlolo eqakathekileko''' {| border=&quot;5&quot; cellspacing=&quot;5&quot; cellpadding=&quot;0&quot; height=&quot;50&quot; align=center border=0 style=&quot;background: transparent&quot; | style=&quot;backgro...&quot;</comment>
      <origin>365</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="648" sha1="6a93yfv9jkizpo4leyi471py8xk28og" xml:space="preserve">&lt;center&gt;'''Izigaba zemitlolo eqakathekileko'''
{| border=&quot;5&quot; cellspacing=&quot;5&quot; cellpadding=&quot;0&quot; height=&quot;50&quot; align=center border=0 style=&quot;background: transparent&quot;
| style=&quot;background-color:lightblue; border: solid 1px #000; padding:0px 20px;&quot; | [[Wikipedia:Imitlolo aqakathekileyo/esigaba 1|Isigaba 1]]
| &amp;nbsp; &amp;nbsp;
| style=&quot;background-color:lightblue; border: solid 1px #000; padding:0px 20px;&quot; | [[Wikipedia:Imitlolo aqakathekileyo/esigaba 2|Isigaba 2]]
| &amp;nbsp; &amp;nbsp;
| style=&quot;background-color:lightblue; border: solid 1px #000; padding:0px 20px;&quot; | [[Wikipedia:Imitlolo aqakathekileyo/esigaba 3|Isigaba 3]]
|}
&lt;/center&gt;&lt;noinclude&gt;

&lt;/noinclude&gt;</text>
      <sha1>6a93yfv9jkizpo4leyi471py8xk28og</sha1>
    </revision>
    <revision>
      <id>366</id>
      <parentid>365</parentid>
      <timestamp>2024-10-14T13:46:24Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>365</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="648" sha1="6a93yfv9jkizpo4leyi471py8xk28og" xml:space="preserve">&lt;center&gt;'''Izigaba zemitlolo eqakathekileko'''
{| border=&quot;5&quot; cellspacing=&quot;5&quot; cellpadding=&quot;0&quot; height=&quot;50&quot; align=center border=0 style=&quot;background: transparent&quot;
| style=&quot;background-color:lightblue; border: solid 1px #000; padding:0px 20px;&quot; | [[Wikipedia:Imitlolo aqakathekileyo/esigaba 1|Isigaba 1]]
| &amp;nbsp; &amp;nbsp;
| style=&quot;background-color:lightblue; border: solid 1px #000; padding:0px 20px;&quot; | [[Wikipedia:Imitlolo aqakathekileyo/esigaba 2|Isigaba 2]]
| &amp;nbsp; &amp;nbsp;
| style=&quot;background-color:lightblue; border: solid 1px #000; padding:0px 20px;&quot; | [[Wikipedia:Imitlolo aqakathekileyo/esigaba 3|Isigaba 3]]
|}
&lt;/center&gt;&lt;noinclude&gt;

&lt;/noinclude&gt;</text>
      <sha1>6a93yfv9jkizpo4leyi471py8xk28og</sha1>
    </revision>
    <revision>
      <id>1863</id>
      <parentid>366</parentid>
      <timestamp>2024-11-03T12:02:32Z</timestamp>
      <contributor>
        <username>Minorax</username>
        <id>38</id>
      </contributor>
      <origin>1863</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="647" sha1="jf3qyroskyn2nncwtmpb2o9rbih4pu4" xml:space="preserve">&lt;div class=&quot;center&quot;&gt;'''Izigaba zemitlolo eqakathekileko'''&lt;/div&gt;
{| border=&quot;5&quot; cellspacing=&quot;5&quot; cellpadding=&quot;0&quot; height=&quot;50&quot; border=0 style=&quot;background: transparent; color:inherit; margin:auto;&quot;
| style=&quot;background-color:lightblue; border: solid 1px #000; padding:0px 20px;&quot; | [[Wikipedia:Imitlolo aqakathekileyo/esigaba 1|Isigaba 1]]
| &amp;nbsp; &amp;nbsp;
| style=&quot;background-color:lightblue; border: solid 1px #000; padding:0px 20px;&quot; | [[Wikipedia:Imitlolo aqakathekileyo/esigaba 2|Isigaba 2]]
| &amp;nbsp; &amp;nbsp;
| style=&quot;background-color:lightblue; border: solid 1px #000; padding:0px 20px;&quot; | [[Wikipedia:Imitlolo aqakathekileyo/esigaba 3|Isigaba 3]]
|}</text>
      <sha1>jf3qyroskyn2nncwtmpb2o9rbih4pu4</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Abatloli</title>
    <ns>14</ns>
    <id>94</id>
    <revision>
      <id>400</id>
      <timestamp>2016-02-24T10:32:40Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;.&quot;</comment>
      <origin>400</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1" sha1="6t9fg2gmch401ldtk8m7pyzz632ixbb" xml:space="preserve">.</text>
      <sha1>6t9fg2gmch401ldtk8m7pyzz632ixbb</sha1>
    </revision>
    <revision>
      <id>401</id>
      <parentid>400</parentid>
      <timestamp>2022-09-26T22:04:51Z</timestamp>
      <contributor>
        <username>incubator&gt;JhsBot</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>bot: Categorizing uncategorized test wiki category</comment>
      <origin>401</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3" sha1="i1o78dibucis7drc8kun4rynldcc8uq" xml:space="preserve">.

</text>
      <sha1>i1o78dibucis7drc8kun4rynldcc8uq</sha1>
    </revision>
    <revision>
      <id>402</id>
      <parentid>401</parentid>
      <timestamp>2024-10-14T13:46:26Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>401</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3" sha1="i1o78dibucis7drc8kun4rynldcc8uq" xml:space="preserve">.

</text>
      <sha1>i1o78dibucis7drc8kun4rynldcc8uq</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Amatlolo</title>
    <ns>14</ns>
    <id>95</id>
    <revision>
      <id>403</id>
      <timestamp>2016-02-24T17:38:58Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;.&quot;</comment>
      <origin>403</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1" sha1="6t9fg2gmch401ldtk8m7pyzz632ixbb" xml:space="preserve">.</text>
      <sha1>6t9fg2gmch401ldtk8m7pyzz632ixbb</sha1>
    </revision>
    <revision>
      <id>404</id>
      <parentid>403</parentid>
      <timestamp>2022-09-26T22:04:53Z</timestamp>
      <contributor>
        <username>incubator&gt;JhsBot</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>bot: Categorizing uncategorized test wiki category</comment>
      <origin>404</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3" sha1="i1o78dibucis7drc8kun4rynldcc8uq" xml:space="preserve">.

</text>
      <sha1>i1o78dibucis7drc8kun4rynldcc8uq</sha1>
    </revision>
    <revision>
      <id>405</id>
      <parentid>404</parentid>
      <timestamp>2024-10-14T13:46:26Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>404</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3" sha1="i1o78dibucis7drc8kun4rynldcc8uq" xml:space="preserve">.

</text>
      <sha1>i1o78dibucis7drc8kun4rynldcc8uq</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Imitlolo aqakathekileyo</title>
    <ns>14</ns>
    <id>96</id>
    <revision>
      <id>406</id>
      <timestamp>2019-01-11T15:34:32Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;.&quot;</comment>
      <origin>406</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1" sha1="6t9fg2gmch401ldtk8m7pyzz632ixbb" xml:space="preserve">.</text>
      <sha1>6t9fg2gmch401ldtk8m7pyzz632ixbb</sha1>
    </revision>
    <revision>
      <id>407</id>
      <parentid>406</parentid>
      <timestamp>2022-09-26T22:04:55Z</timestamp>
      <contributor>
        <username>incubator&gt;JhsBot</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>bot: Categorizing uncategorized test wiki category</comment>
      <origin>407</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3" sha1="i1o78dibucis7drc8kun4rynldcc8uq" xml:space="preserve">.

</text>
      <sha1>i1o78dibucis7drc8kun4rynldcc8uq</sha1>
    </revision>
    <revision>
      <id>408</id>
      <parentid>407</parentid>
      <timestamp>2024-10-14T13:46:26Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>407</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3" sha1="i1o78dibucis7drc8kun4rynldcc8uq" xml:space="preserve">.

</text>
      <sha1>i1o78dibucis7drc8kun4rynldcc8uq</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Wikipediya</title>
    <ns>14</ns>
    <id>97</id>
    <revision>
      <id>409</id>
      <timestamp>2019-01-13T17:31:34Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;.&quot;</comment>
      <origin>409</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1" sha1="6t9fg2gmch401ldtk8m7pyzz632ixbb" xml:space="preserve">.</text>
      <sha1>6t9fg2gmch401ldtk8m7pyzz632ixbb</sha1>
    </revision>
    <revision>
      <id>410</id>
      <parentid>409</parentid>
      <timestamp>2022-09-26T22:04:57Z</timestamp>
      <contributor>
        <username>incubator&gt;JhsBot</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>bot: Categorizing uncategorized test wiki category</comment>
      <origin>410</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3" sha1="i1o78dibucis7drc8kun4rynldcc8uq" xml:space="preserve">.

</text>
      <sha1>i1o78dibucis7drc8kun4rynldcc8uq</sha1>
    </revision>
    <revision>
      <id>411</id>
      <parentid>410</parentid>
      <timestamp>2024-10-14T13:46:27Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>410</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3" sha1="i1o78dibucis7drc8kun4rynldcc8uq" xml:space="preserve">.

</text>
      <sha1>i1o78dibucis7drc8kun4rynldcc8uq</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Arguments</title>
    <ns>828</ns>
    <id>100</id>
    <revision>
      <id>426</id>
      <timestamp>2019-01-13T17:22:41Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;-- This module provides easy processing of arguments passed to Scribunto from -- #invoke. It is intended for use by other Lua modules, and should not be -- called from #invoke...&quot;</comment>
      <origin>426</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="10054" sha1="5qx9tzlul9ser30uxj9nbasjt92cevn" xml:space="preserve">-- This module provides easy processing of arguments passed to Scribunto from
-- #invoke. It is intended for use by other Lua modules, and should not be
-- called from #invoke directly.

local libraryUtil = require('libraryUtil')
local checkType = libraryUtil.checkType

local arguments = {}

-- Generate four different tidyVal functions, so that we don't have to check the
-- options every time we call it.

local function tidyValDefault(key, val)
	if type(val) == 'string' then
		val = val:match('^%s*(.-)%s*$')
		if val == '' then
			return nil
		else
			return val
		end
	else
		return val
	end
end

local function tidyValTrimOnly(key, val)
	if type(val) == 'string' then
		return val:match('^%s*(.-)%s*$')
	else
		return val
	end
end

local function tidyValRemoveBlanksOnly(key, val)
	if type(val) == 'string' then
		if val:find('%S') then
			return val
		else
			return nil
		end
	else
		return val
	end
end

local function tidyValNoChange(key, val)
	return val
end

local function matchesTitle(given, title)
	local tp = type( given )
	return (tp == 'string' or tp == 'number') and mw.title.new( given ).prefixedText == title
end

local translate_mt = { __index = function(t, k) return k end }

function arguments.getArgs(frame, options)
	checkType('getArgs', 1, frame, 'table', true)
	checkType('getArgs', 2, options, 'table', true)
	frame = frame or {}
	options = options or {}

	--[[
	-- Set up argument translation.
	--]]
	options.translate = options.translate or {}
	if getmetatable(options.translate) == nil then
		setmetatable(options.translate, translate_mt)
	end
	if options.backtranslate == nil then
		options.backtranslate = {}
		for k,v in pairs(options.translate) do
			options.backtranslate[v] = k
		end
	end
	if options.backtranslate and getmetatable(options.backtranslate) == nil then
		setmetatable(options.backtranslate, {
			__index = function(t, k)
				if options.translate[k] ~= k then
					return nil
				else
					return k
				end
			end
		})
	end

	--[[
	-- Get the argument tables. If we were passed a valid frame object, get the
	-- frame arguments (fargs) and the parent frame arguments (pargs), depending
	-- on the options set and on the parent frame's availability. If we weren't
	-- passed a valid frame object, we are being called from another Lua module
	-- or from the debug console, so assume that we were passed a table of args
	-- directly, and assign it to a new variable (luaArgs).
	--]]
	local fargs, pargs, luaArgs
	if type(frame.args) == 'table' and type(frame.getParent) == 'function' then
		if options.wrappers then
			--[[
			-- The wrappers option makes Module:Arguments look up arguments in
			-- either the frame argument table or the parent argument table, but
			-- not both. This means that users can use either the #invoke syntax
			-- or a wrapper template without the loss of performance associated
			-- with looking arguments up in both the frame and the parent frame.
			-- Module:Arguments will look up arguments in the parent frame
			-- if it finds the parent frame's title in options.wrapper;
			-- otherwise it will look up arguments in the frame object passed
			-- to getArgs.
			--]]
			local parent = frame:getParent()
			if not parent then
				fargs = frame.args
			else
				local title = parent:getTitle():gsub('/sandbox$', '')
				local found = false
				if matchesTitle(options.wrappers, title) then
					found = true
				elseif type(options.wrappers) == 'table' then
					for _,v in pairs(options.wrappers) do
						if matchesTitle(v, title) then
							found = true
							break
						end
					end
				end

				-- We test for false specifically here so that nil (the default) acts like true.
				if found or options.frameOnly == false then
					pargs = parent.args
				end
				if not found or options.parentOnly == false then
					fargs = frame.args
				end
			end
		else
			-- options.wrapper isn't set, so check the other options.
			if not options.parentOnly then
				fargs = frame.args
			end
			if not options.frameOnly then
				local parent = frame:getParent()
				pargs = parent and parent.args or nil
			end
		end
		if options.parentFirst then
			fargs, pargs = pargs, fargs
		end
	else
		luaArgs = frame
	end

	-- Set the order of precedence of the argument tables. If the variables are
	-- nil, nothing will be added to the table, which is how we avoid clashes
	-- between the frame/parent args and the Lua args.
	local argTables = {fargs}
	argTables[#argTables + 1] = pargs
	argTables[#argTables + 1] = luaArgs

	--[[
	-- Generate the tidyVal function. If it has been specified by the user, we
	-- use that; if not, we choose one of four functions depending on the
	-- options chosen. This is so that we don't have to call the options table
	-- every time the function is called.
	--]]
	local tidyVal = options.valueFunc
	if tidyVal then
		if type(tidyVal) ~= 'function' then
			error(
				&quot;bad value assigned to option 'valueFunc'&quot;
					.. '(function expected, got '
					.. type(tidyVal)
					.. ')',
				2
			)
		end
	elseif options.trim ~= false then
		if options.removeBlanks ~= false then
			tidyVal = tidyValDefault
		else
			tidyVal = tidyValTrimOnly
		end
	else
		if options.removeBlanks ~= false then
			tidyVal = tidyValRemoveBlanksOnly
		else
			tidyVal = tidyValNoChange
		end
	end

	--[[
	-- Set up the args, metaArgs and nilArgs tables. args will be the one
	-- accessed from functions, and metaArgs will hold the actual arguments. Nil
	-- arguments are memoized in nilArgs, and the metatable connects all of them
	-- together.
	--]]
	local args, metaArgs, nilArgs, metatable = {}, {}, {}, {}
	setmetatable(args, metatable)

	local function mergeArgs(tables)
		--[[
		-- Accepts multiple tables as input and merges their keys and values
		-- into one table. If a value is already present it is not overwritten;
		-- tables listed earlier have precedence. We are also memoizing nil
		-- values, which can be overwritten if they are 's' (soft).
		--]]
		for _, t in ipairs(tables) do
			for key, val in pairs(t) do
				if metaArgs[key] == nil and nilArgs[key] ~= 'h' then
					local tidiedVal = tidyVal(key, val)
					if tidiedVal == nil then
						nilArgs[key] = 's'
					else
						metaArgs[key] = tidiedVal
					end
				end
			end
		end
	end

	--[[
	-- Define metatable behaviour. Arguments are memoized in the metaArgs table,
	-- and are only fetched from the argument tables once. Fetching arguments
	-- from the argument tables is the most resource-intensive step in this
	-- module, so we try and avoid it where possible. For this reason, nil
	-- arguments are also memoized, in the nilArgs table. Also, we keep a record
	-- in the metatable of when pairs and ipairs have been called, so we do not
	-- run pairs and ipairs on the argument tables more than once. We also do
	-- not run ipairs on fargs and pargs if pairs has already been run, as all
	-- the arguments will already have been copied over.
	--]]

	metatable.__index = function (t, key)
		--[[
		-- Fetches an argument when the args table is indexed. First we check
		-- to see if the value is memoized, and if not we try and fetch it from
		-- the argument tables. When we check memoization, we need to check
		-- metaArgs before nilArgs, as both can be non-nil at the same time.
		-- If the argument is not present in metaArgs, we also check whether
		-- pairs has been run yet. If pairs has already been run, we return nil.
		-- This is because all the arguments will have already been copied into
		-- metaArgs by the mergeArgs function, meaning that any other arguments
		-- must be nil.
		--]]
		if type(key) == 'string' then
			key = options.translate[key]
		end
		local val = metaArgs[key]
		if val ~= nil then
			return val
		elseif metatable.donePairs or nilArgs[key] then
			return nil
		end
		for _, argTable in ipairs(argTables) do
			local argTableVal = tidyVal(key, argTable[key])
			if argTableVal ~= nil then
				metaArgs[key] = argTableVal
				return argTableVal
			end
		end
		nilArgs[key] = 'h'
		return nil
	end

	metatable.__newindex = function (t, key, val)
		-- This function is called when a module tries to add a new value to the
		-- args table, or tries to change an existing value.
		if type(key) == 'string' then
			key = options.translate[key]
		end
		if options.readOnly then
			error(
				'could not write to argument table key &quot;'
					.. tostring(key)
					.. '&quot;; the table is read-only',
				2
			)
		elseif options.noOverwrite and args[key] ~= nil then
			error(
				'could not write to argument table key &quot;'
					.. tostring(key)
					.. '&quot;; overwriting existing arguments is not permitted',
				2
			)
		elseif val == nil then
			--[[
			-- If the argument is to be overwritten with nil, we need to erase
			-- the value in metaArgs, so that __index, __pairs and __ipairs do
			-- not use a previous existing value, if present; and we also need
			-- to memoize the nil in nilArgs, so that the value isn't looked
			-- up in the argument tables if it is accessed again.
			--]]
			metaArgs[key] = nil
			nilArgs[key] = 'h'
		else
			metaArgs[key] = val
		end
	end

	local function translatenext(invariant)
		local k, v = next(invariant.t, invariant.k)
		invariant.k = k
		if k == nil then
			return nil
		elseif type(k) ~= 'string' or not options.backtranslate then
			return k, v
		else
			local backtranslate = options.backtranslate[k]
			if backtranslate == nil then
				-- Skip this one. This is a tail call, so this won't cause stack overflow
				return translatenext(invariant)
			else
				return backtranslate, v
			end
		end
	end

	metatable.__pairs = function ()
		-- Called when pairs is run on the args table.
		if not metatable.donePairs then
			mergeArgs(argTables)
			metatable.donePairs = true
		end
		return translatenext, { t = metaArgs }
	end

	local function inext(t, i)
		-- This uses our __index metamethod
		local v = t[i + 1]
		if v ~= nil then
			return i + 1, v
		end
	end

	metatable.__ipairs = function (t)
		-- Called when ipairs is run on the args table.
		return inext, t, 0
	end

	return args
end

return arguments</text>
      <sha1>5qx9tzlul9ser30uxj9nbasjt92cevn</sha1>
    </revision>
    <revision>
      <id>427</id>
      <parentid>426</parentid>
      <timestamp>2024-10-14T13:46:27Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>426</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="10054" sha1="5qx9tzlul9ser30uxj9nbasjt92cevn" xml:space="preserve">-- This module provides easy processing of arguments passed to Scribunto from
-- #invoke. It is intended for use by other Lua modules, and should not be
-- called from #invoke directly.

local libraryUtil = require('libraryUtil')
local checkType = libraryUtil.checkType

local arguments = {}

-- Generate four different tidyVal functions, so that we don't have to check the
-- options every time we call it.

local function tidyValDefault(key, val)
	if type(val) == 'string' then
		val = val:match('^%s*(.-)%s*$')
		if val == '' then
			return nil
		else
			return val
		end
	else
		return val
	end
end

local function tidyValTrimOnly(key, val)
	if type(val) == 'string' then
		return val:match('^%s*(.-)%s*$')
	else
		return val
	end
end

local function tidyValRemoveBlanksOnly(key, val)
	if type(val) == 'string' then
		if val:find('%S') then
			return val
		else
			return nil
		end
	else
		return val
	end
end

local function tidyValNoChange(key, val)
	return val
end

local function matchesTitle(given, title)
	local tp = type( given )
	return (tp == 'string' or tp == 'number') and mw.title.new( given ).prefixedText == title
end

local translate_mt = { __index = function(t, k) return k end }

function arguments.getArgs(frame, options)
	checkType('getArgs', 1, frame, 'table', true)
	checkType('getArgs', 2, options, 'table', true)
	frame = frame or {}
	options = options or {}

	--[[
	-- Set up argument translation.
	--]]
	options.translate = options.translate or {}
	if getmetatable(options.translate) == nil then
		setmetatable(options.translate, translate_mt)
	end
	if options.backtranslate == nil then
		options.backtranslate = {}
		for k,v in pairs(options.translate) do
			options.backtranslate[v] = k
		end
	end
	if options.backtranslate and getmetatable(options.backtranslate) == nil then
		setmetatable(options.backtranslate, {
			__index = function(t, k)
				if options.translate[k] ~= k then
					return nil
				else
					return k
				end
			end
		})
	end

	--[[
	-- Get the argument tables. If we were passed a valid frame object, get the
	-- frame arguments (fargs) and the parent frame arguments (pargs), depending
	-- on the options set and on the parent frame's availability. If we weren't
	-- passed a valid frame object, we are being called from another Lua module
	-- or from the debug console, so assume that we were passed a table of args
	-- directly, and assign it to a new variable (luaArgs).
	--]]
	local fargs, pargs, luaArgs
	if type(frame.args) == 'table' and type(frame.getParent) == 'function' then
		if options.wrappers then
			--[[
			-- The wrappers option makes Module:Arguments look up arguments in
			-- either the frame argument table or the parent argument table, but
			-- not both. This means that users can use either the #invoke syntax
			-- or a wrapper template without the loss of performance associated
			-- with looking arguments up in both the frame and the parent frame.
			-- Module:Arguments will look up arguments in the parent frame
			-- if it finds the parent frame's title in options.wrapper;
			-- otherwise it will look up arguments in the frame object passed
			-- to getArgs.
			--]]
			local parent = frame:getParent()
			if not parent then
				fargs = frame.args
			else
				local title = parent:getTitle():gsub('/sandbox$', '')
				local found = false
				if matchesTitle(options.wrappers, title) then
					found = true
				elseif type(options.wrappers) == 'table' then
					for _,v in pairs(options.wrappers) do
						if matchesTitle(v, title) then
							found = true
							break
						end
					end
				end

				-- We test for false specifically here so that nil (the default) acts like true.
				if found or options.frameOnly == false then
					pargs = parent.args
				end
				if not found or options.parentOnly == false then
					fargs = frame.args
				end
			end
		else
			-- options.wrapper isn't set, so check the other options.
			if not options.parentOnly then
				fargs = frame.args
			end
			if not options.frameOnly then
				local parent = frame:getParent()
				pargs = parent and parent.args or nil
			end
		end
		if options.parentFirst then
			fargs, pargs = pargs, fargs
		end
	else
		luaArgs = frame
	end

	-- Set the order of precedence of the argument tables. If the variables are
	-- nil, nothing will be added to the table, which is how we avoid clashes
	-- between the frame/parent args and the Lua args.
	local argTables = {fargs}
	argTables[#argTables + 1] = pargs
	argTables[#argTables + 1] = luaArgs

	--[[
	-- Generate the tidyVal function. If it has been specified by the user, we
	-- use that; if not, we choose one of four functions depending on the
	-- options chosen. This is so that we don't have to call the options table
	-- every time the function is called.
	--]]
	local tidyVal = options.valueFunc
	if tidyVal then
		if type(tidyVal) ~= 'function' then
			error(
				&quot;bad value assigned to option 'valueFunc'&quot;
					.. '(function expected, got '
					.. type(tidyVal)
					.. ')',
				2
			)
		end
	elseif options.trim ~= false then
		if options.removeBlanks ~= false then
			tidyVal = tidyValDefault
		else
			tidyVal = tidyValTrimOnly
		end
	else
		if options.removeBlanks ~= false then
			tidyVal = tidyValRemoveBlanksOnly
		else
			tidyVal = tidyValNoChange
		end
	end

	--[[
	-- Set up the args, metaArgs and nilArgs tables. args will be the one
	-- accessed from functions, and metaArgs will hold the actual arguments. Nil
	-- arguments are memoized in nilArgs, and the metatable connects all of them
	-- together.
	--]]
	local args, metaArgs, nilArgs, metatable = {}, {}, {}, {}
	setmetatable(args, metatable)

	local function mergeArgs(tables)
		--[[
		-- Accepts multiple tables as input and merges their keys and values
		-- into one table. If a value is already present it is not overwritten;
		-- tables listed earlier have precedence. We are also memoizing nil
		-- values, which can be overwritten if they are 's' (soft).
		--]]
		for _, t in ipairs(tables) do
			for key, val in pairs(t) do
				if metaArgs[key] == nil and nilArgs[key] ~= 'h' then
					local tidiedVal = tidyVal(key, val)
					if tidiedVal == nil then
						nilArgs[key] = 's'
					else
						metaArgs[key] = tidiedVal
					end
				end
			end
		end
	end

	--[[
	-- Define metatable behaviour. Arguments are memoized in the metaArgs table,
	-- and are only fetched from the argument tables once. Fetching arguments
	-- from the argument tables is the most resource-intensive step in this
	-- module, so we try and avoid it where possible. For this reason, nil
	-- arguments are also memoized, in the nilArgs table. Also, we keep a record
	-- in the metatable of when pairs and ipairs have been called, so we do not
	-- run pairs and ipairs on the argument tables more than once. We also do
	-- not run ipairs on fargs and pargs if pairs has already been run, as all
	-- the arguments will already have been copied over.
	--]]

	metatable.__index = function (t, key)
		--[[
		-- Fetches an argument when the args table is indexed. First we check
		-- to see if the value is memoized, and if not we try and fetch it from
		-- the argument tables. When we check memoization, we need to check
		-- metaArgs before nilArgs, as both can be non-nil at the same time.
		-- If the argument is not present in metaArgs, we also check whether
		-- pairs has been run yet. If pairs has already been run, we return nil.
		-- This is because all the arguments will have already been copied into
		-- metaArgs by the mergeArgs function, meaning that any other arguments
		-- must be nil.
		--]]
		if type(key) == 'string' then
			key = options.translate[key]
		end
		local val = metaArgs[key]
		if val ~= nil then
			return val
		elseif metatable.donePairs or nilArgs[key] then
			return nil
		end
		for _, argTable in ipairs(argTables) do
			local argTableVal = tidyVal(key, argTable[key])
			if argTableVal ~= nil then
				metaArgs[key] = argTableVal
				return argTableVal
			end
		end
		nilArgs[key] = 'h'
		return nil
	end

	metatable.__newindex = function (t, key, val)
		-- This function is called when a module tries to add a new value to the
		-- args table, or tries to change an existing value.
		if type(key) == 'string' then
			key = options.translate[key]
		end
		if options.readOnly then
			error(
				'could not write to argument table key &quot;'
					.. tostring(key)
					.. '&quot;; the table is read-only',
				2
			)
		elseif options.noOverwrite and args[key] ~= nil then
			error(
				'could not write to argument table key &quot;'
					.. tostring(key)
					.. '&quot;; overwriting existing arguments is not permitted',
				2
			)
		elseif val == nil then
			--[[
			-- If the argument is to be overwritten with nil, we need to erase
			-- the value in metaArgs, so that __index, __pairs and __ipairs do
			-- not use a previous existing value, if present; and we also need
			-- to memoize the nil in nilArgs, so that the value isn't looked
			-- up in the argument tables if it is accessed again.
			--]]
			metaArgs[key] = nil
			nilArgs[key] = 'h'
		else
			metaArgs[key] = val
		end
	end

	local function translatenext(invariant)
		local k, v = next(invariant.t, invariant.k)
		invariant.k = k
		if k == nil then
			return nil
		elseif type(k) ~= 'string' or not options.backtranslate then
			return k, v
		else
			local backtranslate = options.backtranslate[k]
			if backtranslate == nil then
				-- Skip this one. This is a tail call, so this won't cause stack overflow
				return translatenext(invariant)
			else
				return backtranslate, v
			end
		end
	end

	metatable.__pairs = function ()
		-- Called when pairs is run on the args table.
		if not metatable.donePairs then
			mergeArgs(argTables)
			metatable.donePairs = true
		end
		return translatenext, { t = metaArgs }
	end

	local function inext(t, i)
		-- This uses our __index metamethod
		local v = t[i + 1]
		if v ~= nil then
			return i + 1, v
		end
	end

	metatable.__ipairs = function (t)
		-- Called when ipairs is run on the args table.
		return inext, t, 0
	end

	return args
end

return arguments</text>
      <sha1>5qx9tzlul9ser30uxj9nbasjt92cevn</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Category handler</title>
    <ns>828</ns>
    <id>101</id>
    <revision>
      <id>428</id>
      <timestamp>2023-05-30T15:16:46Z</timestamp>
      <contributor>
        <username>incubator&gt;Пан Хаунд</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;-------------------------------------------------------------------------------- --                                                                            -- --                              CATEGORY HANDLER                              -- --                                                                            -- --      This module implements the {{category handler}} template in Lua,      -- --      with a few improvements: all namespaces and all namespace alia...&quot;</comment>
      <origin>428</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="7735" sha1="3gubklzofemfn9qf4shfenu5oqsei9z" xml:space="preserve">--------------------------------------------------------------------------------
--                                                                            --
--                              CATEGORY HANDLER                              --
--                                                                            --
--      This module implements the {{category handler}} template in Lua,      --
--      with a few improvements: all namespaces and all namespace aliases     --
--      are supported, and namespace names are detected automatically for     --
--      the local wiki. This module requires [[Module:Namespace detect]]      --
--      and [[Module:Yesno]] to be available on the local wiki. It can be     --
--      configured for different wikis by altering the values in              --
--      [[Module:Category handler/config]], and pages can be blacklisted      --
--      from categorisation by using [[Module:Category handler/blacklist]].   --
--                                                                            --
--------------------------------------------------------------------------------

-- Load required modules
local yesno = require('Module:Yesno')

-- Lazily load things we don't always need
local mShared, mappings

local p = {}

--------------------------------------------------------------------------------
-- Helper functions
--------------------------------------------------------------------------------

local function trimWhitespace(s, removeBlanks)
	if type(s) ~= 'string' then
		return s
	end
	s = s:match('^%s*(.-)%s*$')
	if removeBlanks then
		if s ~= '' then
			return s
		else
			return nil
		end
	else
		return s
	end
end

--------------------------------------------------------------------------------
-- CategoryHandler class
--------------------------------------------------------------------------------

local CategoryHandler = {}
CategoryHandler.__index = CategoryHandler

function CategoryHandler.new(data, args)
	local obj = setmetatable({ _data = data, _args = args }, CategoryHandler)
	
	-- Set the title object
	do
		local pagename = obj:parameter('demopage')
		local success, titleObj = pcall(mw.title.new, pagename)
		if success and titleObj then
			obj.title = titleObj
		else
			obj.title = mw.title.getCurrentTitle()
			obj._usesCurrentTitle = true
		end
	end

	-- Set suppression parameter values
	for _, key in ipairs{'nocat', 'categories'} do
		local value = obj:parameter(key)
		value = trimWhitespace(value, true)
		obj['_' .. key] = yesno(value)
	end
	do
		local subpage = obj:parameter('subpage')
		local category2 = obj:parameter('category2')
		if type(subpage) == 'string' then
			subpage = mw.ustring.lower(subpage)
		end
		if type(category2) == 'string' then
			subpage = mw.ustring.lower(category2)
		end
		obj._subpage = trimWhitespace(subpage, true)
		obj._category2 = trimWhitespace(category2) -- don't remove blank values
	end
	return obj
end

function CategoryHandler:parameter(key)
	local parameterNames = self._data.parameters[key]
	local pntype = type(parameterNames)
	if pntype == 'string' or pntype == 'number' then
		return self._args[parameterNames]
	elseif pntype == 'table' then
		for _, name in ipairs(parameterNames) do
			local value = self._args[name]
			if value ~= nil then
				return value
			end
		end
		return nil
	else
		error(string.format(
			'invalid config key &quot;%s&quot;',
			tostring(key)
		), 2)
	end
end

function CategoryHandler:isSuppressedByArguments()
	return
		-- See if a category suppression argument has been set.
		self._nocat == true
		or self._categories == false
		or (
			self._category2
			and self._category2 ~= self._data.category2Yes
			and self._category2 ~= self._data.category2Negative
		)

		-- Check whether we are on a subpage, and see if categories are
		-- suppressed based on our subpage status.
		or self._subpage == self._data.subpageNo and self.title.isSubpage
		or self._subpage == self._data.subpageOnly and not self.title.isSubpage
end

function CategoryHandler:shouldSkipBlacklistCheck()
	-- Check whether the category suppression arguments indicate we
	-- should skip the blacklist check.
	return self._nocat == false
		or self._categories == true
		or self._category2 == self._data.category2Yes
end

function CategoryHandler:matchesBlacklist()
	if self._usesCurrentTitle then
		return self._data.currentTitleMatchesBlacklist
	else
		mShared = mShared or require('Module:Category handler/shared')
		return mShared.matchesBlacklist(
			self.title.prefixedText,
			mw.loadData('Module:Category handler/blacklist')
		)
	end
end

function CategoryHandler:isSuppressed()
	-- Find if categories are suppressed by either the arguments or by
	-- matching the blacklist.
	return self:isSuppressedByArguments()
		or not self:shouldSkipBlacklistCheck() and self:matchesBlacklist()
end

function CategoryHandler:getNamespaceParameters()
	if self._usesCurrentTitle then
		return self._data.currentTitleNamespaceParameters
	else
		if not mappings then
			mShared = mShared or require('Module:Category handler/shared')
			mappings = mShared.getParamMappings(true) -- gets mappings with mw.loadData
		end
		return mShared.getNamespaceParameters(
			self.title,
			mappings
		)
	end
end

function CategoryHandler:namespaceParametersExist()
	-- Find whether any namespace parameters have been specified.
	-- We use the order &quot;all&quot; --&gt; namespace params --&gt; &quot;other&quot; as this is what
	-- the old template did.
	if self:parameter('all') then
		return true
	end
	if not mappings then
		mShared = mShared or require('Module:Category handler/shared')
		mappings = mShared.getParamMappings(true) -- gets mappings with mw.loadData
	end
	for ns, params in pairs(mappings) do
		for i, param in ipairs(params) do
			if self._args[param] then
				return true
			end
		end
	end
	if self:parameter('other') then
		return true
	end
	return false
end

function CategoryHandler:getCategories()
	local params = self:getNamespaceParameters()
	local nsCategory
	for i, param in ipairs(params) do
		local value = self._args[param]
		if value ~= nil then
			nsCategory = value
			break
		end
	end
	if nsCategory ~= nil or self:namespaceParametersExist() then
		-- Namespace parameters exist - advanced usage.
		if nsCategory == nil then
			nsCategory = self:parameter('other')
		end
		local ret = {self:parameter('all')}
		local numParam = tonumber(nsCategory)
		if numParam and numParam &gt;= 1 and math.floor(numParam) == numParam then
			-- nsCategory is an integer
			ret[#ret + 1] = self._args[numParam]
		else
			ret[#ret + 1] = nsCategory
		end
		if #ret &lt; 1 then
			return nil
		else
			return table.concat(ret)
		end
	elseif self._data.defaultNamespaces[self.title.namespace] then
		-- Namespace parameters don't exist, simple usage.
		return self._args[1]
	end
	return nil
end

--------------------------------------------------------------------------------
-- Exports
--------------------------------------------------------------------------------

local p = {}

function p._exportClasses()
	-- Used for testing purposes.
	return {
		CategoryHandler = CategoryHandler
	}
end

function p._main(args, data)
	data = data or mw.loadData('Module:Category handler/data')
	local handler = CategoryHandler.new(data, args)
	if handler:isSuppressed() then
		return nil
	end
	return handler:getCategories()
end

function p.main(frame, data)
	data = data or mw.loadData('Module:Category handler/data')
	local args = require('Module:Arguments').getArgs(frame, {
		wrappers = data.wrappers,
		valueFunc = function (k, v)
			v = trimWhitespace(v)
			if type(k) == 'number' then
				if v ~= '' then
					return v
				else
					return nil
				end
			else
				return v
			end
		end
	})
	return p._main(args, data)
end

return p</text>
      <sha1>3gubklzofemfn9qf4shfenu5oqsei9z</sha1>
    </revision>
    <revision>
      <id>429</id>
      <parentid>428</parentid>
      <timestamp>2024-10-14T13:46:28Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>428</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="7735" sha1="3gubklzofemfn9qf4shfenu5oqsei9z" xml:space="preserve">--------------------------------------------------------------------------------
--                                                                            --
--                              CATEGORY HANDLER                              --
--                                                                            --
--      This module implements the {{category handler}} template in Lua,      --
--      with a few improvements: all namespaces and all namespace aliases     --
--      are supported, and namespace names are detected automatically for     --
--      the local wiki. This module requires [[Module:Namespace detect]]      --
--      and [[Module:Yesno]] to be available on the local wiki. It can be     --
--      configured for different wikis by altering the values in              --
--      [[Module:Category handler/config]], and pages can be blacklisted      --
--      from categorisation by using [[Module:Category handler/blacklist]].   --
--                                                                            --
--------------------------------------------------------------------------------

-- Load required modules
local yesno = require('Module:Yesno')

-- Lazily load things we don't always need
local mShared, mappings

local p = {}

--------------------------------------------------------------------------------
-- Helper functions
--------------------------------------------------------------------------------

local function trimWhitespace(s, removeBlanks)
	if type(s) ~= 'string' then
		return s
	end
	s = s:match('^%s*(.-)%s*$')
	if removeBlanks then
		if s ~= '' then
			return s
		else
			return nil
		end
	else
		return s
	end
end

--------------------------------------------------------------------------------
-- CategoryHandler class
--------------------------------------------------------------------------------

local CategoryHandler = {}
CategoryHandler.__index = CategoryHandler

function CategoryHandler.new(data, args)
	local obj = setmetatable({ _data = data, _args = args }, CategoryHandler)
	
	-- Set the title object
	do
		local pagename = obj:parameter('demopage')
		local success, titleObj = pcall(mw.title.new, pagename)
		if success and titleObj then
			obj.title = titleObj
		else
			obj.title = mw.title.getCurrentTitle()
			obj._usesCurrentTitle = true
		end
	end

	-- Set suppression parameter values
	for _, key in ipairs{'nocat', 'categories'} do
		local value = obj:parameter(key)
		value = trimWhitespace(value, true)
		obj['_' .. key] = yesno(value)
	end
	do
		local subpage = obj:parameter('subpage')
		local category2 = obj:parameter('category2')
		if type(subpage) == 'string' then
			subpage = mw.ustring.lower(subpage)
		end
		if type(category2) == 'string' then
			subpage = mw.ustring.lower(category2)
		end
		obj._subpage = trimWhitespace(subpage, true)
		obj._category2 = trimWhitespace(category2) -- don't remove blank values
	end
	return obj
end

function CategoryHandler:parameter(key)
	local parameterNames = self._data.parameters[key]
	local pntype = type(parameterNames)
	if pntype == 'string' or pntype == 'number' then
		return self._args[parameterNames]
	elseif pntype == 'table' then
		for _, name in ipairs(parameterNames) do
			local value = self._args[name]
			if value ~= nil then
				return value
			end
		end
		return nil
	else
		error(string.format(
			'invalid config key &quot;%s&quot;',
			tostring(key)
		), 2)
	end
end

function CategoryHandler:isSuppressedByArguments()
	return
		-- See if a category suppression argument has been set.
		self._nocat == true
		or self._categories == false
		or (
			self._category2
			and self._category2 ~= self._data.category2Yes
			and self._category2 ~= self._data.category2Negative
		)

		-- Check whether we are on a subpage, and see if categories are
		-- suppressed based on our subpage status.
		or self._subpage == self._data.subpageNo and self.title.isSubpage
		or self._subpage == self._data.subpageOnly and not self.title.isSubpage
end

function CategoryHandler:shouldSkipBlacklistCheck()
	-- Check whether the category suppression arguments indicate we
	-- should skip the blacklist check.
	return self._nocat == false
		or self._categories == true
		or self._category2 == self._data.category2Yes
end

function CategoryHandler:matchesBlacklist()
	if self._usesCurrentTitle then
		return self._data.currentTitleMatchesBlacklist
	else
		mShared = mShared or require('Module:Category handler/shared')
		return mShared.matchesBlacklist(
			self.title.prefixedText,
			mw.loadData('Module:Category handler/blacklist')
		)
	end
end

function CategoryHandler:isSuppressed()
	-- Find if categories are suppressed by either the arguments or by
	-- matching the blacklist.
	return self:isSuppressedByArguments()
		or not self:shouldSkipBlacklistCheck() and self:matchesBlacklist()
end

function CategoryHandler:getNamespaceParameters()
	if self._usesCurrentTitle then
		return self._data.currentTitleNamespaceParameters
	else
		if not mappings then
			mShared = mShared or require('Module:Category handler/shared')
			mappings = mShared.getParamMappings(true) -- gets mappings with mw.loadData
		end
		return mShared.getNamespaceParameters(
			self.title,
			mappings
		)
	end
end

function CategoryHandler:namespaceParametersExist()
	-- Find whether any namespace parameters have been specified.
	-- We use the order &quot;all&quot; --&gt; namespace params --&gt; &quot;other&quot; as this is what
	-- the old template did.
	if self:parameter('all') then
		return true
	end
	if not mappings then
		mShared = mShared or require('Module:Category handler/shared')
		mappings = mShared.getParamMappings(true) -- gets mappings with mw.loadData
	end
	for ns, params in pairs(mappings) do
		for i, param in ipairs(params) do
			if self._args[param] then
				return true
			end
		end
	end
	if self:parameter('other') then
		return true
	end
	return false
end

function CategoryHandler:getCategories()
	local params = self:getNamespaceParameters()
	local nsCategory
	for i, param in ipairs(params) do
		local value = self._args[param]
		if value ~= nil then
			nsCategory = value
			break
		end
	end
	if nsCategory ~= nil or self:namespaceParametersExist() then
		-- Namespace parameters exist - advanced usage.
		if nsCategory == nil then
			nsCategory = self:parameter('other')
		end
		local ret = {self:parameter('all')}
		local numParam = tonumber(nsCategory)
		if numParam and numParam &gt;= 1 and math.floor(numParam) == numParam then
			-- nsCategory is an integer
			ret[#ret + 1] = self._args[numParam]
		else
			ret[#ret + 1] = nsCategory
		end
		if #ret &lt; 1 then
			return nil
		else
			return table.concat(ret)
		end
	elseif self._data.defaultNamespaces[self.title.namespace] then
		-- Namespace parameters don't exist, simple usage.
		return self._args[1]
	end
	return nil
end

--------------------------------------------------------------------------------
-- Exports
--------------------------------------------------------------------------------

local p = {}

function p._exportClasses()
	-- Used for testing purposes.
	return {
		CategoryHandler = CategoryHandler
	}
end

function p._main(args, data)
	data = data or mw.loadData('Module:Category handler/data')
	local handler = CategoryHandler.new(data, args)
	if handler:isSuppressed() then
		return nil
	end
	return handler:getCategories()
end

function p.main(frame, data)
	data = data or mw.loadData('Module:Category handler/data')
	local args = require('Module:Arguments').getArgs(frame, {
		wrappers = data.wrappers,
		valueFunc = function (k, v)
			v = trimWhitespace(v)
			if type(k) == 'number' then
				if v ~= '' then
					return v
				else
					return nil
				end
			else
				return v
			end
		end
	})
	return p._main(args, data)
end

return p</text>
      <sha1>3gubklzofemfn9qf4shfenu5oqsei9z</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Citation/CS1/Config</title>
    <ns>828</ns>
    <id>103</id>
    <revision>
      <id>432</id>
      <timestamp>2014-09-04T15:51:49Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;citation_config = {};  -- override &lt;code&gt;...&lt;/code&gt; styling to remove color, border, and padding.  &lt;code&gt; css is specified here: -- https://git.wikimedia.org/blob/mediawiki%2F...&quot;</comment>
      <origin>432</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="27546" sha1="ov33haahvlmi52qcmaihosq89qo5vrq" xml:space="preserve">citation_config = {};

-- override &lt;code&gt;...&lt;/code&gt; styling to remove color, border, and padding.  &lt;code&gt; css is specified here:
-- https://git.wikimedia.org/blob/mediawiki%2Fcore.git/69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199
local code_style=&quot;color:inherit; border:inherit; padding:inherit;&quot;;

--[[
List of namespaces that should not be included in citation
error categories.  Same as setting notracking = true by default

Note: Namespace names should use underscores instead of spaces.
]]
citation_config.uncategorized_namespaces = { 'User', 'Talk', 'User_talk', 'Wikipedia_talk', 'File_talk', 'Template_talk',
	'Help_talk', 'Category_talk', 'Portal_talk', 'Book_talk', 'Draft', 'Draft_talk', 'Education_Program_talk', 
	'Module_talk', 'MediaWiki_talk' };

--[[Citation/CS1/
Translation table

The following contains fixed text that may be output as part of a citation.
This is separated from the main body to aid in future translations of this
module.
|
Translation table

The following contains fixed text that may be output as part of a citation.
This is separated from the main body to aid in future translations of this
module.
]]
citation_config.messages = {
  ['published'] = 'published $1',
  ['lay summary'] = 'Lay summary',
  ['retrieved'] = 'Retrieved $1',
  ['inactive'] = 'inactive',
  ['archived-dead'] = 'Archived from $1 on $2',
  ['archived-not-dead'] = '$1 from the original on $2',
  ['archived-missing'] = 'Archived from the original$1 on $2',
  ['archived'] = 'Archived',
  ['original'] = 'the original',
  ['editor'] = 'ed.',
  ['editors'] = 'eds.', 
  ['edition'] = '($1 ed.)', 
  ['episode'] = 'episode',
  ['season'] = 'season', 
  ['series'] = 'series',
  ['cartography'] = 'Cartography by $1',
  ['section'] = 'Section $1',
  ['inset'] = '$1 inset',
  ['written'] = 'Written at $1',
  ['in'] = 'In',
  ['et al'] = 'et al.', 
  
  ['subscription'] = '&lt;span style=&quot;font-size:0.95em; font-size:90%; color:#555&quot;&gt;(subscription required (&lt;span title=&quot;Sources are not required to be available online. Online sources do not have to be freely available. The site may require a paid subscription.&quot; style=&quot;border-bottom:1px dotted;cursor:help&quot;&gt;help&lt;/span&gt;))&lt;/span&gt;' ..
  	'[[Mkhakha:Pages containing links to subscription-only content]]', 

  ['registration']='&lt;span style=&quot;font-size:0.95em; font-size:90%; color:#555&quot;&gt;(registration required (&lt;span title=&quot;Sources are not required to be available online. Online sources do not have to be freely available. The site may require registration.&quot; style=&quot;border-bottom:1px dotted;cursor:help&quot;&gt;help&lt;/span&gt;))&lt;/span&gt;' ..
  	'[[Mkhakha:Pages with login required references or sources]]',
  
  ['language'] = '(in $1)', 
  ['via'] = &quot; &amp;ndash; via $1&quot;,
  ['event'] = 'Event occurs at',
  ['minutes'] = 'minutes in', 

  ['quoted-title'] = '&quot;$1&quot;',
  ['italic-title'] = &quot;''$1''&quot;,
  ['trans-quoted-title'] = &quot;&amp;#91;$1&amp;#93;&quot;,
  ['trans-italic-title'] = &quot;&amp;#91;''$1''&amp;#93;&quot;,
  ['quoted-text'] = '&quot;$1&quot;',

  ['parameter'] = '&lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;$1=&lt;/code&gt;',
  ['parameter-separator'] = ', ',
  ['parameter-final-separator'] = ', and ',
  ['parameter-pair-separator'] = ' and ',

  -- Error output
  -- .error class is specified at https://git.wikimedia.org/blob/mediawiki%2Fcore.git/9553bd02a5595da05c184f7521721fb1b79b3935/skins%2Fcommon%2Fshared.css#L538
  -- .citation-comment class is specified at Help:CS1_errors#Controlling_error_message_display
  ['hidden-error'] = '&lt;span style=&quot;display:none;font-size:100%&quot; class=&quot;error citation-comment&quot;&gt;$1&lt;/span&gt;',
  ['visible-error'] = '&lt;span style=&quot;font-size:100%&quot; class=&quot;error citation-comment&quot;&gt;$1&lt;/span&gt;',
  
  -- Determines the location of the help page
  ['help page link'] = 'Help:CS1 errors',
  ['help page label'] = 'help',
  
  -- Internal errors (should only occur if configuration is bad)
  ['undefined_error'] = 'Called with an undefined error condition',
  ['unknown_manual_ID'] = 'Unrecognized manual ID mode',
  ['unknown_ID_mode'] = 'Unrecognized ID mode',
  ['unknown_argument_map'] = 'Argument map not defined for this variable',
  ['bare_url_no_origin'] = 'Bare url found but origin indicator is nil or empty',
}

-- Aliases table for commonly passed parameters
citation_config.aliases = {
	['AccessDate'] = {'access-date', 'accessdate'},
	['Agency'] = 'agency',
	['AirDate'] = {'air-date', 'airdate'},
	['ArchiveDate'] = {'archive-date', 'archivedate'},
	['ArchiveURL'] = {'archive-url', 'archiveurl'},
	['ASINTLD'] = {'ASIN-TLD', 'asin-tld'},
	['At'] = 'at',
	['Authors'] = {'authors', 'people', 'host'},
	['AuthorFormat'] = {'author-format', 'authorformat'},
	['AuthorSeparator'] = 'author-separator',
	['AuthorNameSeparator'] = 'author-name-separator',
	['BookTitle'] = {'book-title', 'booktitle'},
	['Callsign'] = {'call-sign', 'callsign'},				-- cite interview
	['Cartography'] = 'cartography',
	['Chapter'] = {'chapter', 'contribution', 'entry', 'article', 'section', 'notestitle'},	-- notestitle is deprecated; remove after 1 October 2014; used by old cite AV media notes
	['ChapterLink'] = {'chapter-link', 'chapterlink'},
	['ChapterURL'] = {'chapter-url', 'chapterurl', 'contribution-url', 'contributionurl', 'section-url', 'sectionurl'},
	['City'] = 'city',										-- cite interview
	['Coauthors'] = {'coauthors', 'coauthor'},				-- coauthor and coauthors are deprecated; remove after 1 October 2014
	['Cointerviewers'] = 'cointerviewers',					-- cointerviewers is deprecated; remove after 1 October 2014; used by cite interview
	['Conference'] = {'conference', 'event'},
	['ConferenceURL'] = {'conference-url', 'conferenceurl', 'event-url', 'eventurl'},
	['Date'] = 'date',
	['Day'] = 'day',
	['DeadURL'] = {'dead-url', 'deadurl'},
	['Degree'] = 'degree',
	['DisplayAuthors'] = {'display-authors', 'displayauthors'},
	['DisplayEditors'] = {'display-editors', 'displayeditors'},
	['Docket'] = 'docket',
	['DoiBroken'] = {'doi-broken', 'doi-broken-date', 'doi-inactive-date', 'DoiBroken', 'doi_brokendate', 'doi_inactivedate'},
	['Edition'] = 'edition',
	['Editors'] = 'editors',
	['EditorFormat'] = {'editor-format', 'editorformat'},
	['EditorSeparator'] = 'editor-separator',
	['EditorNameSeparator'] = 'editor-name-separator',
	['Embargo'] = {'Embargo', 'embargo'},
	['Format'] = 'format',
	['ID'] = {'id', 'ID', 'publisherid'},					-- publisherid is deprecated; remove after 1 October 2014; used by old cite AV media notes and old cite DVD notes
	['IgnoreISBN'] = {'ignore-isbn-error', 'ignoreisbnerror'},
	['Inset'] = 'inset',
	['Interviewer'] = 'interviewer',						-- cite interview
	['Issue'] = {'issue', 'number'},
	['Language'] = {'language', 'in'},
	['LastAuthorAmp'] = {'last-author-amp', 'lastauthoramp'},
	['LayDate'] = {'lay-date', 'laydate'},
	['LaySource'] = {'lay-source', 'laysource'},
	['LayURL'] = {'lay-url', 'lay-summary', 'layurl', 'laysummary'},
	['Minutes'] = 'minutes',
	['Month'] = 'month',
	['NameSeparator'] = 'name-separator',
	['Network'] = 'network',
	['NoPP'] = {'no-pp', 'nopp'},
	['NoTracking'] = {'template-doc-demo', 'template doc demo', 'no-cat', 'nocat', 
		'no-tracking', 'notracking'},
	['OrigYear'] = {'orig-year', 'origyear', 'titleyear'},	-- titleyear is deprecated; remove after 1 October 2014; used in old cite DVD notes
	['Others'] = {'others', 'artist', 'director'},			-- artist and director are deprecated; remove after 1 October 2014; used in old cite AV media notes and old cite DVD notes
	['Page'] = {'p', 'page'},
	['Pages'] = {'pp', 'pages'},
	['Periodical'] = {'journal', 'newspaper', 'magazine', 'work',
		'website',  'periodical', 'encyclopedia', 'encyclopaedia', 'dictionary'},
	['Place'] = {'place', 'location'},
	['PPrefix'] = {'p-prefix', 'PPrefix'},
	['PPPrefix'] = {'pp-prefix', 'PPPrefix'},
	['Program'] = 'program',								-- cite interview
	['PostScript'] = 'postscript',
	['PublicationDate'] = {'publicationdate', 'publication-date'},
	['PublicationPlace'] = {'publication-place', 'publicationplace'},
--[[ Hide unfinished cite newsgroup code so that long delayed update can take place
	['PublisherName'] = {'publisher', 'distributor', 'institution', 'newsgroup'},
]]	['PublisherName'] = {'publisher', 'distributor', 'institution'},
	['Quote'] = {'quote', 'quotation'},
	['Ref'] = {'ref', 'Ref'},
	['RegistrationRequired'] = 'registration',
	['Scale'] = 'scale',
	['Section'] = 'section',
	['Season'] = 'season',
	['Separator'] = 'separator',
	['Series'] = {'series', 'version'},
	['SeriesSeparator'] = 'series-separator',
	['SeriesLink'] = {'series-link', 'serieslink'},
	['SeriesNumber'] = {'series-number', 'series-no', 'seriesnumber', 'seriesno'},
	['Station'] = 'station',
	['SubscriptionRequired'] = 'subscription',
	['Time'] = 'time',
	['TimeCaption'] = {'time-caption', 'timecaption'},
	['Title'] = 'title',
	['TitleLink'] = {'title-link', 'episode-link', 'titlelink', 'episodelink', 'albumlink'},	-- albumlink is deprecated; remove after 1 October 2014; used by old cite AV media notes
	['TitleNote'] = 'department',
	['TitleType'] = {'type', 'medium'},
	['TransChapter'] = {'trans-chapter', 'trans_chapter'},
	['Transcript'] = 'transcript',
	['TranscriptURL'] = {'transcript-url', 'transcripturl'},
	['TransTitle'] = {'trans-title', 'trans_title'},
	['URL'] = {'url', 'URL'},
	['Via'] = 'via',
	['Volume'] = 'volume',
	['Year'] = 'year',

	['AuthorList-First'] = {&quot;author#-first&quot;, &quot;author-first#&quot;,
		&quot;first#&quot;, &quot;given#&quot;},
	['AuthorList-Last'] = {&quot;author#-last&quot;, &quot;author-last#&quot;, 
		&quot;last#&quot;, &quot;surname#&quot;, &quot;Author#&quot;, &quot;author#&quot;, &quot;authors#&quot;, &quot;subject#&quot;},
	['AuthorList-Link'] = {&quot;author#-link&quot;, &quot;author-link#&quot;, 
		&quot;author#link&quot;, &quot;authorlink#&quot;, &quot;subject-link#&quot;, &quot;subject#link&quot;, &quot;subject#-link&quot;, &quot;subjectlink#&quot;},
	['AuthorList-Mask'] = {&quot;author#-mask&quot;, &quot;author-mask#&quot;, 
		&quot;author#mask&quot;, &quot;authormask#&quot;},
	
	['EditorList-First'] = {&quot;editor#-first&quot;, 
		&quot;editor-first#&quot;, &quot;editor#-given&quot;, &quot;editor-given#&quot;, &quot;EditorGiven#&quot;},
	['EditorList-Last'] = {&quot;editor#-last&quot;, &quot;editor-last#&quot;,
		&quot;editor#-surname&quot;, &quot;editor-surname#&quot;, &quot;EditorSurname#&quot;, &quot;Editor#&quot;, &quot;editor#&quot;, &quot;editors#&quot;},
	['EditorList-Link'] = {&quot;editor#-link&quot;, &quot;editor-link#&quot;, 
		&quot;editor#link&quot;, &quot;editorlink#&quot;},
	['EditorList-Mask'] = {&quot;editor#-mask&quot;, &quot;editor-mask#&quot;, 
		&quot;editor#mask&quot;, &quot;editormask#&quot;},
	
}

-- Default parameter values
citation_config.defaults = {
	['DeadURL'] = 'yes',
	['AuthorSeparator'] = ';',
	['EditorSeparator'] = ';',
	['NameSeparator'] = ',',
	['PPrefix'] = &quot;p.&amp;nbsp;&quot;,
	['PPPrefix'] = &quot;pp.&amp;nbsp;&quot;,	
}

--[[
Error condition table

The following contains a list of IDs for various error conditions defined in the 
code.  For each ID, we specify a text message to display, an error category to
include, and whether the error message should be wrapped as a hidden comment.

Anchor changes require identical changes to matching anchor in Help:CS1 errors
]]

citation_config.error_conditions = {
	accessdate_missing_url = {
		message = '&lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;accessdate=&lt;/code&gt; requires &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;url=&lt;/code&gt;',
		anchor = 'accessdate_missing_url',
		category = 'Pages using citations with accessdate and no URL',
		hidden = true },
	archive_missing_date = {
		message = '&lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;archiveurl=&lt;/code&gt; requires &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;archivedate=&lt;/code&gt;',
		anchor = 'archive_missing_date',
		category = 'Pages with archiveurl citation errors',
		hidden = false },
	archive_missing_url = {
		message = '&lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;archiveurl=&lt;/code&gt; requires &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;url=&lt;/code&gt;',
		anchor = 'archive_missing_url',
		category = 'Pages with archiveurl citation errors',
		hidden = false },
	bad_arxiv = {
		message = 'Check &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;arxiv=&lt;/code&gt; value',
		anchor = 'bad_arxiv',
		category = 'CS1 errors: arXiv',
		hidden = false },
	bad_authorlink = {
		message = 'Check &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;authorlink=&lt;/code&gt; value',
		anchor = 'bad_authorlink',
		category = 'CS1 errors: authorlink',
		hidden = false },
	bad_date = {
		message = 'Check date values in: &lt;code style=&quot;'..code_style..'&quot;&gt;$1&lt;/code&gt;',
		anchor = 'bad_date',
		category = 'CS1 errors: dates',
		hidden = true },
	bad_doi = {
		message = 'Check &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;doi=&lt;/code&gt; value',
		anchor = 'bad_doi',
		category = 'Pages with DOI errors',
		hidden = false },
	bad_isbn = {
		message = 'Check &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;isbn=&lt;/code&gt; value',
		anchor = 'bad_isbn',
		category = 'Pages with ISBN errors',
		hidden = false },
	bad_issn = {
		message = 'Check &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;issn=&lt;/code&gt; value',
		anchor = 'bad_issn',
		category = 'CS1 errors: ISSN',
		hidden = false },
	bad_lccn = {
		message = 'Check &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;lccn=&lt;/code&gt; value',
		anchor = 'bad_lccn',
		category = 'CS1 errors: LCCN',
		hidden = false },
	bad_ol = {
		message = 'Check &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;ol=&lt;/code&gt; value',
		anchor = 'bad_ol',
		category = 'Pages with OL errors',
		hidden = false },
	bad_pmc = {
		message = 'Check &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;pmc=&lt;/code&gt; value',
		anchor = 'bad_pmc',
		category = 'CS1 errors: PMC',
		hidden = false },
	bad_pmid = {
		message = 'Check &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;pmid=&lt;/code&gt; value',
		anchor = 'bad_pmid',
		category = 'CS1 errors: PMID',
		hidden = false },
	bad_url = {
		message = 'Check &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;url=&lt;/code&gt; scheme',
		anchor = 'bad_url',
		category = 'Pages with URL errors',
		hidden = false },
	bare_url_missing_title = {
		message = '$1 missing title',
		anchor = 'bare_url_missing_title',
		category = 'Pages with citations having bare URLs',
		hidden = false },
	citation_missing_title = {
		message = 'Missing or empty &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;title=&lt;/code&gt;',
		anchor = 'citation_missing_title',
		category = 'Pages with citations lacking titles',
		hidden = false },
	cite_web_url = {										-- this error applies to cite web and to cite podcast
		message = 'Missing or empty &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;url=&lt;/code&gt;',
		anchor = 'cite_web_url',
		category = 'Pages using web citations with no URL',
		hidden = true },
	coauthors_missing_author = {
		message = '&lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;coauthors=&lt;/code&gt; requires &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;author=&lt;/code&gt;',
		anchor = 'coauthors_missing_author',
		category = 'CS1 errors: coauthors without author',
		hidden = false },
	deprecated_params = {
		message = 'Cite uses deprecated parameters',
		anchor = 'deprecated_params',
		category = 'Pages containing cite templates with deprecated parameters',
		hidden = true },
	empty_citation = {
		message = 'Empty citation',
		anchor = 'empty_citation',
		category = 'Pages with empty citations',
		hidden = false },
	extra_pages = {
		message = 'Extra &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;pages=&lt;/code&gt; or &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;at=&lt;/code&gt;',
		anchor = 'extra_pages',
		category = 'Pages with citations using conflicting page specifications',
		hidden = false },
	first_missing_last = {
		message = '&lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;first$2=&lt;/code&gt; missing &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;last$2=&lt;/code&gt; in $1',
		anchor = 'first_missing_last',
		category = 'CS1 errors: missing author or editor',
		hidden = false },
	format_missing_url = {
		message = '&lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;format=&lt;/code&gt; requires &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;url=&lt;/code&gt;',
		anchor = 'format_missing_url',
		category = 'Pages using citations with format and no URL',
		hidden = true },
	implict_etal_author = {
		message = '&lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;displayauthors=&lt;/code&gt; suggested',
		anchor = 'displayauthors',
		category = 'Pages using citations with old-style implicit et al.',
		hidden = true },
	implict_etal_editor = {
		message = '&lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;displayeditors=&lt;/code&gt; suggested',
		anchor = 'displayeditors',
		category = 'Pages using citations with old-style implicit et al. in editors',
		hidden = true },
	missing_name = {
		message = 'Missing &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;last$2=&lt;/code&gt; in $1',
		anchor = 'missing_name',
		category = 'CS1 errors: missing author or editor',
		hidden = false },
	parameter_ignored = {
		message = 'Unknown parameter &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;$1=&lt;/code&gt; ignored',
		anchor = 'parameter_ignored',
		category = 'Pages with citations using unsupported parameters',
		hidden = false },
	parameter_ignored_suggest = {
		message = 'Unknown parameter &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;$1=&lt;/code&gt; ignored (&lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;$2=&lt;/code&gt; suggested)',
		anchor = 'parameter_ignored_suggest',
		category = 'Pages with citations using unsupported parameters',
		hidden = false },
	redundant_parameters = {
		message = 'More than one of $1 specified',
		anchor = 'redundant_parameters',
		category = 'Pages with citations having redundant parameters',
		hidden = false },
	text_ignored = {
		message = 'Text &quot;$1&quot; ignored',
		anchor = 'text_ignored',
		category = 'Pages with citations using unnamed parameters',
		hidden = false },
	trans_missing_chapter = {
		message = '&lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;trans_chapter=&lt;/code&gt; requires &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;chapter=&lt;/code&gt;',
		anchor = 'trans_missing_chapter',
		category = 'Pages with citations using translated terms without the original',
		hidden = false },
	trans_missing_title = {
		message = '&lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;trans_title=&lt;/code&gt; requires &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;title=&lt;/code&gt;',
		anchor = 'trans_missing_title',
		category = 'Pages with citations using translated terms without the original',
		hidden = false },
	wikilink_in_url = {
		message = 'Wikilink embedded in URL title',
		anchor = 'wikilink_in_url',
		category = 'Pages with citations having wikilinks embedded in URL titles',
		hidden = false },
}

citation_config.id_handlers = {
	['ARXIV'] = {
		parameters = {'arxiv', 'ARXIV'}, 
		link = 'arXiv',
		label = 'arXiv',
		mode = 'manual',
		prefix = '//arxiv.org/abs/', 						-- protocol relative tested 2013-09-04
		encode = false,
		COinS = 'info:arxiv',
		separator = ':',
	},
	['ASIN'] = {
		parameters = { 'asin', 'ASIN' },	   
		link = 'Amazon Standard Identification Number',
		label = 'ASIN',
		mode = 'manual',
		COinS = 'info:asin',
		separator = '&amp;nbsp;',
		encode = false;
	},
	['BIBCODE'] = {
		parameters = {'bibcode', 'BIBCODE'}, 
		link = 'Bibcode',
		label = 'Bibcode',
		mode = 'external',
		prefix = 'http://adsabs.harvard.edu/abs/',
		encode = false,
		COinS = 'info:bibcode',
		separator = ':',
	},
	['DOI'] = {
		parameters = { 'doi', 'DOI' },
		link = 'Digital object identifier',
		label = 'doi',
		mode = 'manual',
		prefix = 'http://dx.doi.org/',
		COinS = 'info:doi',
		separator = ':',
		encode = true,
	},
	['ISBN'] = {
		parameters = {'isbn', 'ISBN', 'isbn13', 'ISBN13'}, 
		link = 'International Standard Book Number',
		label = 'ISBN',
		mode = 'manual',
		prefix = 'Special:BookSources/',
		COinS = 'rft.isbn',
		separator = '&amp;nbsp;',
	},
	['ISSN'] = {
		parameters = {'issn', 'ISSN'}, 
		link = 'International Standard Serial Number',
		label = 'ISSN',
		mode = 'manual',
		prefix = '//www.worldcat.org/issn/',
		COinS = 'rft.issn',
		encode = false,
		separator = '&amp;nbsp;',
	},
	['JFM'] = {
		parameters = {'jfm', 'JFM'}, 
		link = 'Jahrbuch über die Fortschritte der Mathematik',
		label = 'JFM',
		mode = 'external',
		prefix = 'http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:',
		COinS = 'rft.jfm',
		encode = true,
		separator = '&amp;nbsp;',
	},
	['JSTOR'] = {
		parameters = {'jstor', 'JSTOR'}, 
		link = 'JSTOR',
		label = 'JSTOR',
		mode = 'external',
		prefix = '//www.jstor.org/stable/', 				-- protocol relative tested 2013-09-04
		COinS = 'rft.jstor',
		encode = true,
		separator = '&amp;nbsp;',
	},
	['LCCN'] = {
		parameters = {'LCCN', 'lccn'}, 
		link = 'Library of Congress Control Number',
		label = 'LCCN',
		mode = 'manual',
		prefix = 'http://lccn.loc.gov/',
		COinS = 'rft.lccn',
		encode = false,
		separator = '&amp;nbsp;',
	},
	['MR'] = {
		parameters = {'MR', 'mr'}, 
		link = 'Mathematical Reviews',
		label = 'MR',
		mode = 'external',
		prefix = '//www.ams.org/mathscinet-getitem?mr=', 	-- protocol relative tested 2013-09-04
		COinS = 'rft.mr',
		encode = true,
		separator = '&amp;nbsp;',
	},
	['OCLC'] = {
		parameters = {'OCLC', 'oclc'}, 
		link = 'OCLC',
		label = 'OCLC',
		mode = 'external',
		prefix = '//www.worldcat.org/oclc/',
		COinS = 'info:oclcnum',
		encode = true,
		separator = '&amp;nbsp;',
	},
	['OL'] = {
		parameters = { 'ol', 'OL' },
		link = 'Open Library',
		label = 'OL',
		mode = 'manual',
		COinS = 'info:olnum',
		separator = '&amp;nbsp;',
		endode = true,
	},
	['OSTI'] = {
		parameters = {'OSTI', 'osti'}, 
		link = 'Office of Scientific and Technical Information',
		label = 'OSTI',
		mode = 'external',
		prefix = '//www.osti.gov/energycitations/product.biblio.jsp?osti_id=',	-- protocol relative tested 2013-09-04
		COinS = 'info:osti',
		encode = true,
		separator = '&amp;nbsp;',
	},
	['PMC'] = {
		parameters = {'PMC', 'pmc'}, 
		link = 'PubMed Central',
		label = 'PMC',
		mode = 'manual',									-- changed to support unlinking of PMC identifier when article is embargoed
		prefix = '//www.ncbi.nlm.nih.gov/pmc/articles/PMC', 
		suffix = &quot; &quot;,
		COinS = 'info:pmc',
		encode = true,
		separator = '&amp;nbsp;',
	},
	['PMID'] = {
		parameters = {'PMID', 'pmid'}, 
		link = 'PubMed Identifier',
		label = 'PMID',
		mode = 'manual',									-- changed from external manual to support PMID validation
		prefix = '//www.ncbi.nlm.nih.gov/pubmed/',
		COinS = 'info:pmid',
		encode = false,
		separator = '&amp;nbsp;',
	},
	['RFC'] = {
		parameters = {'RFC', 'rfc'}, 
		link = 'Request for Comments',
		label = 'RFC',
		mode = 'external',
		prefix = '//tools.ietf.org/html/rfc',
		COinS = 'info:rfc',
		encode = false,
		separator = '&amp;nbsp;',
	},
	['SSRN'] = {
		parameters = {'SSRN', 'ssrn'}, 
		link = 'Social Science Research Network',
		label = 'SSRN',
		mode = 'external',
		prefix = '//ssrn.com/abstract=', 					-- protocol relative tested 2013-09-04
		COinS = 'info:ssrn',
		encode = true,
		separator = '&amp;nbsp;',
	},
--[[ Hide unfinished cite newsgroup code so that long delayed update can take place
	['USENETID'] = {
		parameters = {'id', 'ID'}, 
		link = 'Usenet',
		label = 'Usenet:',
		mode = 'external',
		prefix = 'news:',
		encode = false,
		COinS = 'info:usenet',
		separator = '&amp;nbsp;',
	},
]]	['ZBL'] = {
		parameters = {'ZBL', 'zbl'}, 
		link = 'Zentralblatt MATH',
		label = 'Zbl',
		mode = 'external',
		prefix = 'http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:',
		COinS = 'info:zbl',
		encode = true,
		separator = '&amp;nbsp;',
	},
}

--iso639-1 language codes and names.
citation_config.iso639_1 = {
	[&quot;aa&quot;] = &quot;Afar&quot;,
	[&quot;ab&quot;] = &quot;Abkhazian&quot;,
	[&quot;ae&quot;] = &quot;Avestan&quot;,
	[&quot;af&quot;] = &quot;Afrikaans&quot;,
	[&quot;ak&quot;] = &quot;Akan&quot;,
	[&quot;am&quot;] = &quot;Amharic&quot;,
	[&quot;an&quot;] = &quot;Aragonese&quot;,
	[&quot;ar&quot;] = &quot;Arabic&quot;,
	[&quot;as&quot;] = &quot;Assamese&quot;,
	[&quot;av&quot;] = &quot;Avaric&quot;,
	[&quot;ay&quot;] = &quot;Aymara&quot;,
	[&quot;az&quot;] = &quot;Azerbaijani&quot;,
	[&quot;ba&quot;] = &quot;Bashkir&quot;,
	[&quot;be&quot;] = &quot;Belarusian&quot;,
	[&quot;bg&quot;] = &quot;Bulgarian&quot;,
	[&quot;bh&quot;] = &quot;Bihari languages&quot;,
	[&quot;bi&quot;] = &quot;Bislama&quot;,
	[&quot;bm&quot;] = &quot;Bambara&quot;,
	[&quot;bn&quot;] = &quot;Bengali&quot;,
	[&quot;bo&quot;] = &quot;Tibetan&quot;,
	[&quot;br&quot;] = &quot;Breton&quot;,
	[&quot;bs&quot;] = &quot;Bosnian&quot;,
	[&quot;ca&quot;] = &quot;Catalan&quot;,
--	[&quot;ca&quot;] = &quot;Valencian&quot;,
	[&quot;ce&quot;] = &quot;Chechen&quot;,
	[&quot;ch&quot;] = &quot;Chamorro&quot;,
	[&quot;co&quot;] = &quot;Corsican&quot;,
	[&quot;cr&quot;] = &quot;Cree&quot;,
	[&quot;cs&quot;] = &quot;Czech&quot;,
	[&quot;cu&quot;] = &quot;Church Slavic&quot;,
--	[&quot;cu&quot;] = &quot;Old Slavonic&quot;,
--	[&quot;cu&quot;] = &quot;Church Slavonic&quot;,
--	[&quot;cu&quot;] = &quot;Old Bulgarian&quot;,
--	[&quot;cu&quot;] = &quot;Old Church Slavonic&quot;,
	[&quot;cv&quot;] = &quot;Chuvash&quot;,
	[&quot;cy&quot;] = &quot;Welsh&quot;,
	[&quot;da&quot;] = &quot;Danish&quot;,
	[&quot;de&quot;] = &quot;German&quot;,
	[&quot;dv&quot;] = &quot;Divehi&quot;,
	[&quot;dv&quot;] = &quot;Dhivehi&quot;,
	[&quot;dv&quot;] = &quot;Maldivian&quot;,
	[&quot;dz&quot;] = &quot;Dzongkha&quot;,
	[&quot;ee&quot;] = &quot;Ewe&quot;,
	[&quot;el&quot;] = &quot;Modern Greek&quot;,
	[&quot;en&quot;] = &quot;English&quot;,
	[&quot;eo&quot;] = &quot;Esperanto&quot;,
	[&quot;es&quot;] = &quot;Spanish&quot;,
--	[&quot;es&quot;] = &quot;Castilian&quot;,
	[&quot;et&quot;] = &quot;Estonian&quot;,
	[&quot;eu&quot;] = &quot;Basque&quot;,
	[&quot;fa&quot;] = &quot;Persian&quot;,
	[&quot;ff&quot;] = &quot;Fulah&quot;,
	[&quot;fi&quot;] = &quot;Finnish&quot;,
	[&quot;fj&quot;] = &quot;Fijian&quot;,
	[&quot;fo&quot;] = &quot;Faroese&quot;,
	[&quot;fr&quot;] = &quot;French&quot;,
	[&quot;fy&quot;] = &quot;Western Frisian&quot;,
	[&quot;ga&quot;] = &quot;Irish&quot;,
--	[&quot;gd&quot;] = &quot;Gaelic&quot;,
	[&quot;gd&quot;] = &quot;Scottish Gaelic&quot;,
	[&quot;gl&quot;] = &quot;Galician&quot;,
	[&quot;gn&quot;] = &quot;Guarani&quot;,
	[&quot;gu&quot;] = &quot;Gujarati&quot;,
	[&quot;gv&quot;] = &quot;Manx&quot;,
	[&quot;ha&quot;] = &quot;Hausa&quot;,
	[&quot;he&quot;] = &quot;Hebrew&quot;,
	[&quot;hi&quot;] = &quot;Hindi&quot;,
	[&quot;ho&quot;] = &quot;Hiri Motu&quot;,
	[&quot;hr&quot;] = &quot;Croatian&quot;,
--	[&quot;ht&quot;] = &quot;Haitian&quot;,
	[&quot;ht&quot;] = &quot;Haitian Creole&quot;,
	[&quot;hu&quot;] = &quot;Hungarian&quot;,
	[&quot;hy&quot;] = &quot;Armenian&quot;,
	[&quot;hz&quot;] = &quot;Herero&quot;,
	[&quot;ia&quot;] = &quot;Interlingua&quot;,
	[&quot;id&quot;] = &quot;Indonesian&quot;,
	[&quot;ie&quot;] = &quot;Interlingue&quot;,
	[&quot;ie&quot;] = &quot;Occidental&quot;,
	[&quot;ig&quot;] = &quot;Igbo&quot;,
--	[&quot;ii&quot;] = &quot;Sichuan Yi&quot;,
	[&quot;ii&quot;] = &quot;Nuosu&quot;,
	[&quot;ik&quot;] = &quot;Inupiaq&quot;,
	[&quot;io&quot;] = &quot;Ido&quot;,
	[&quot;is&quot;] = &quot;Icelandic&quot;,
	[&quot;it&quot;] = &quot;Italian&quot;,
	[&quot;iu&quot;] = &quot;Inuktitut&quot;,
	[&quot;ja&quot;] = &quot;Japanese&quot;,
	[&quot;jv&quot;] = &quot;Javanese&quot;,
	[&quot;ka&quot;] = &quot;Georgian&quot;,
	[&quot;kg&quot;] = &quot;Kongo&quot;,
--	[&quot;ki&quot;] = &quot;Kikuyu&quot;,
	[&quot;ki&quot;] = &quot;Gikuyu&quot;,
--	[&quot;kj&quot;] = &quot;Kuanyama&quot;,
	[&quot;kj&quot;] = &quot;Kwanyama&quot;,
	[&quot;kk&quot;] = &quot;Kazakh&quot;,
--	[&quot;kl&quot;] = &quot;Kalaallisut&quot;,
	[&quot;kl&quot;] = &quot;Greenlandic&quot;,
	[&quot;km&quot;] = &quot;Central Khmer&quot;,
	[&quot;kn&quot;] = &quot;Kannada&quot;,
	[&quot;ko&quot;] = &quot;Korean&quot;,
	[&quot;kr&quot;] = &quot;Kanuri&quot;,
	[&quot;ks&quot;] = &quot;Kashmiri&quot;,
	[&quot;ku&quot;] = &quot;Kurdish&quot;,
	[&quot;kv&quot;] = &quot;Komi&quot;,
	[&quot;kw&quot;] = &quot;Cornish&quot;,
--	[&quot;ky&quot;] = &quot;Kirghiz&quot;,
	[&quot;ky&quot;] = &quot;Kyrgyz&quot;,
	[&quot;la&quot;] = &quot;Latin&quot;,
	[&quot;lb&quot;] = &quot;Luxembourgish&quot;,
--	[&quot;lb&quot;] = &quot;Letzeburgesch&quot;,
	[&quot;lg&quot;] = &quot;Ganda&quot;,
--	[&quot;li&quot;] = &quot;Limburgan&quot;,
--	[&quot;li&quot;] = &quot;Limburger&quot;,
	[&quot;li&quot;] = &quot;Limburgish&quot;,
	[&quot;ln&quot;] = &quot;Lingala&quot;,
	[&quot;lo&quot;] = &quot;Lao&quot;,
	[&quot;lt&quot;] = &quot;Lithuanian&quot;,
	[&quot;lu&quot;] = &quot;Luba-Katanga&quot;,
	[&quot;lv&quot;] = &quot;Latvian&quot;,
	[&quot;mg&quot;] = &quot;Malagasy&quot;,
	[&quot;mh&quot;] = &quot;Marshallese&quot;,
	[&quot;mi&quot;] = &quot;Maori&quot;,
	[&quot;mk&quot;] = &quot;Macedonian&quot;,
	[&quot;ml&quot;] = &quot;Malayalam&quot;,
	[&quot;mn&quot;] = &quot;Mongolian&quot;,
	[&quot;mr&quot;] = &quot;Marathi&quot;,
	[&quot;ms&quot;] = &quot;Malay&quot;,
	[&quot;mt&quot;] = &quot;Maltese&quot;,
	[&quot;my&quot;] = &quot;Burmese&quot;,
	[&quot;na&quot;] = &quot;Nauru&quot;,
	[&quot;nb&quot;] = &quot;Norwegian Bokmål&quot;,
	[&quot;nd&quot;] = &quot;North Ndebele&quot;,
	[&quot;ne&quot;] = &quot;Nepali&quot;,
	[&quot;ng&quot;] = &quot;Ndonga&quot;,
	[&quot;nl&quot;] = &quot;Dutch&quot;,
--	[&quot;nl&quot;] = &quot;Flemish&quot;,
	[&quot;nn&quot;] = &quot;Norwegian Nynorsk&quot;,
	[&quot;no&quot;] = &quot;Norwegian&quot;,
	[&quot;nr&quot;] = &quot;South Ndebele&quot;,
	[&quot;nv&quot;] = &quot;Navajo&quot;,
--	[&quot;nv&quot;] = &quot;Navaho&quot;,
--	[&quot;ny&quot;] = &quot;Chichewa&quot;,
--	[&quot;ny&quot;] = &quot;Chewa&quot;,
	[&quot;ny&quot;] = &quot;Nyanja&quot;,
	[&quot;oc&quot;] = &quot;Occitan&quot;,
	[&quot;oj&quot;] = &quot;Ojibwa&quot;,
	[&quot;om&quot;] = &quot;Oromo&quot;,
	[&quot;or&quot;] = &quot;Oriya&quot;,
	[&quot;os&quot;] = &quot;Ossetian&quot;,
	[&quot;os&quot;] = &quot;Ossetic&quot;,
--	[&quot;pa&quot;] = &quot;Panjabi&quot;,
	[&quot;pa&quot;] = &quot;Punjabi&quot;,
	[&quot;pi&quot;] = &quot;Pali&quot;,
	[&quot;pl&quot;] = &quot;Polish&quot;,
--	[&quot;ps&quot;] = &quot;Pushto&quot;,
	[&quot;ps&quot;] = &quot;Pashto&quot;,
	[&quot;pt&quot;] = &quot;Portuguese&quot;,
	[&quot;qu&quot;] = &quot;Quechua&quot;,
	[&quot;rm&quot;] = &quot;Romansh&quot;,
	[&quot;rn&quot;] = &quot;Rundi&quot;,
	[&quot;ro&quot;] = &quot;Romanian&quot;,
--	[&quot;ro&quot;] = &quot;Moldavian&quot;,
--	[&quot;ro&quot;] = &quot;Moldovan&quot;,
	[&quot;ru&quot;] = &quot;Russian&quot;,
	[&quot;rw&quot;] = &quot;Kinyarwanda&quot;,
	[&quot;sa&quot;] = &quot;Sanskrit&quot;,
	[&quot;sc&quot;] = &quot;Sardinian&quot;,
	[&quot;sd&quot;] = &quot;Sindhi&quot;,
	[&quot;se&quot;] = &quot;Northern Sami&quot;,
	[&quot;sg&quot;] = &quot;Sango&quot;,
	[&quot;si&quot;] = &quot;Sinhala&quot;,
--	[&quot;si&quot;] = &quot;Sinhalese&quot;,
	[&quot;sk&quot;] = &quot;Slovak&quot;,
	[&quot;sl&quot;] = &quot;Slovenian&quot;,
	[&quot;sm&quot;] = &quot;Samoan&quot;,
	[&quot;sn&quot;] = &quot;Shona&quot;,
	[&quot;so&quot;] = &quot;Somali&quot;,
	[&quot;sq&quot;] = &quot;Albanian&quot;,
	[&quot;sr&quot;] = &quot;Serbian&quot;,
	[&quot;ss&quot;] = &quot;Swati&quot;,
	[&quot;st&quot;] = &quot;Southern Sotho&quot;,
	[&quot;su&quot;] = &quot;Sundanese&quot;,
	[&quot;sv&quot;] = &quot;Swedish&quot;,
	[&quot;sw&quot;] = &quot;Swahili&quot;,
	[&quot;ta&quot;] = &quot;Tamil&quot;,
	[&quot;te&quot;] = &quot;Telugu&quot;,
	[&quot;tg&quot;] = &quot;Tajik&quot;,
	[&quot;th&quot;] = &quot;Thai&quot;,
	[&quot;ti&quot;] = &quot;Tigrinya&quot;,
	[&quot;tk&quot;] = &quot;Turkmen&quot;,
	[&quot;tl&quot;] = &quot;Tagalog&quot;,
	[&quot;tn&quot;] = &quot;Tswana&quot;,
	[&quot;to&quot;] = &quot;Tonga (Tonga Islands)&quot;,
	[&quot;tr&quot;] = &quot;Turkish&quot;,
	[&quot;ts&quot;] = &quot;Tsonga&quot;,
	[&quot;tt&quot;] = &quot;Tatar&quot;,
	[&quot;tw&quot;] = &quot;Twi&quot;,
	[&quot;ty&quot;] = &quot;Tahitian&quot;,
--	[&quot;ug&quot;] = &quot;Uighur&quot;,
	[&quot;ug&quot;] = &quot;Uyghur&quot;,
	[&quot;uk&quot;] = &quot;Ukrainian&quot;,
	[&quot;ur&quot;] = &quot;Urdu&quot;,
	[&quot;uz&quot;] = &quot;Uzbek&quot;,
	[&quot;ve&quot;] = &quot;Venda&quot;,
	[&quot;vi&quot;] = &quot;Vietnamese&quot;,
	[&quot;vo&quot;] = &quot;Volapük&quot;,
	[&quot;wa&quot;] = &quot;Walloon&quot;,
	[&quot;wo&quot;] = &quot;Wolof&quot;,
	[&quot;xh&quot;] = &quot;Xhosa&quot;,
	[&quot;yi&quot;] = &quot;Yiddish&quot;,
	[&quot;yo&quot;] = &quot;Yoruba&quot;,
	[&quot;za&quot;] = &quot;Zhuang&quot;,
--	[&quot;za&quot;] = &quot;Chuang&quot;,
	[&quot;zh&quot;] = &quot;Chinese&quot;,
	[&quot;zu&quot;] = &quot;Zulu&quot;,
}
return citation_config;</text>
      <sha1>ov33haahvlmi52qcmaihosq89qo5vrq</sha1>
    </revision>
    <revision>
      <id>433</id>
      <parentid>432</parentid>
      <timestamp>2024-10-14T13:46:28Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>432</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="27546" sha1="ov33haahvlmi52qcmaihosq89qo5vrq" xml:space="preserve">citation_config = {};

-- override &lt;code&gt;...&lt;/code&gt; styling to remove color, border, and padding.  &lt;code&gt; css is specified here:
-- https://git.wikimedia.org/blob/mediawiki%2Fcore.git/69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199
local code_style=&quot;color:inherit; border:inherit; padding:inherit;&quot;;

--[[
List of namespaces that should not be included in citation
error categories.  Same as setting notracking = true by default

Note: Namespace names should use underscores instead of spaces.
]]
citation_config.uncategorized_namespaces = { 'User', 'Talk', 'User_talk', 'Wikipedia_talk', 'File_talk', 'Template_talk',
	'Help_talk', 'Category_talk', 'Portal_talk', 'Book_talk', 'Draft', 'Draft_talk', 'Education_Program_talk', 
	'Module_talk', 'MediaWiki_talk' };

--[[Citation/CS1/
Translation table

The following contains fixed text that may be output as part of a citation.
This is separated from the main body to aid in future translations of this
module.
|
Translation table

The following contains fixed text that may be output as part of a citation.
This is separated from the main body to aid in future translations of this
module.
]]
citation_config.messages = {
  ['published'] = 'published $1',
  ['lay summary'] = 'Lay summary',
  ['retrieved'] = 'Retrieved $1',
  ['inactive'] = 'inactive',
  ['archived-dead'] = 'Archived from $1 on $2',
  ['archived-not-dead'] = '$1 from the original on $2',
  ['archived-missing'] = 'Archived from the original$1 on $2',
  ['archived'] = 'Archived',
  ['original'] = 'the original',
  ['editor'] = 'ed.',
  ['editors'] = 'eds.', 
  ['edition'] = '($1 ed.)', 
  ['episode'] = 'episode',
  ['season'] = 'season', 
  ['series'] = 'series',
  ['cartography'] = 'Cartography by $1',
  ['section'] = 'Section $1',
  ['inset'] = '$1 inset',
  ['written'] = 'Written at $1',
  ['in'] = 'In',
  ['et al'] = 'et al.', 
  
  ['subscription'] = '&lt;span style=&quot;font-size:0.95em; font-size:90%; color:#555&quot;&gt;(subscription required (&lt;span title=&quot;Sources are not required to be available online. Online sources do not have to be freely available. The site may require a paid subscription.&quot; style=&quot;border-bottom:1px dotted;cursor:help&quot;&gt;help&lt;/span&gt;))&lt;/span&gt;' ..
  	'[[Mkhakha:Pages containing links to subscription-only content]]', 

  ['registration']='&lt;span style=&quot;font-size:0.95em; font-size:90%; color:#555&quot;&gt;(registration required (&lt;span title=&quot;Sources are not required to be available online. Online sources do not have to be freely available. The site may require registration.&quot; style=&quot;border-bottom:1px dotted;cursor:help&quot;&gt;help&lt;/span&gt;))&lt;/span&gt;' ..
  	'[[Mkhakha:Pages with login required references or sources]]',
  
  ['language'] = '(in $1)', 
  ['via'] = &quot; &amp;ndash; via $1&quot;,
  ['event'] = 'Event occurs at',
  ['minutes'] = 'minutes in', 

  ['quoted-title'] = '&quot;$1&quot;',
  ['italic-title'] = &quot;''$1''&quot;,
  ['trans-quoted-title'] = &quot;&amp;#91;$1&amp;#93;&quot;,
  ['trans-italic-title'] = &quot;&amp;#91;''$1''&amp;#93;&quot;,
  ['quoted-text'] = '&quot;$1&quot;',

  ['parameter'] = '&lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;$1=&lt;/code&gt;',
  ['parameter-separator'] = ', ',
  ['parameter-final-separator'] = ', and ',
  ['parameter-pair-separator'] = ' and ',

  -- Error output
  -- .error class is specified at https://git.wikimedia.org/blob/mediawiki%2Fcore.git/9553bd02a5595da05c184f7521721fb1b79b3935/skins%2Fcommon%2Fshared.css#L538
  -- .citation-comment class is specified at Help:CS1_errors#Controlling_error_message_display
  ['hidden-error'] = '&lt;span style=&quot;display:none;font-size:100%&quot; class=&quot;error citation-comment&quot;&gt;$1&lt;/span&gt;',
  ['visible-error'] = '&lt;span style=&quot;font-size:100%&quot; class=&quot;error citation-comment&quot;&gt;$1&lt;/span&gt;',
  
  -- Determines the location of the help page
  ['help page link'] = 'Help:CS1 errors',
  ['help page label'] = 'help',
  
  -- Internal errors (should only occur if configuration is bad)
  ['undefined_error'] = 'Called with an undefined error condition',
  ['unknown_manual_ID'] = 'Unrecognized manual ID mode',
  ['unknown_ID_mode'] = 'Unrecognized ID mode',
  ['unknown_argument_map'] = 'Argument map not defined for this variable',
  ['bare_url_no_origin'] = 'Bare url found but origin indicator is nil or empty',
}

-- Aliases table for commonly passed parameters
citation_config.aliases = {
	['AccessDate'] = {'access-date', 'accessdate'},
	['Agency'] = 'agency',
	['AirDate'] = {'air-date', 'airdate'},
	['ArchiveDate'] = {'archive-date', 'archivedate'},
	['ArchiveURL'] = {'archive-url', 'archiveurl'},
	['ASINTLD'] = {'ASIN-TLD', 'asin-tld'},
	['At'] = 'at',
	['Authors'] = {'authors', 'people', 'host'},
	['AuthorFormat'] = {'author-format', 'authorformat'},
	['AuthorSeparator'] = 'author-separator',
	['AuthorNameSeparator'] = 'author-name-separator',
	['BookTitle'] = {'book-title', 'booktitle'},
	['Callsign'] = {'call-sign', 'callsign'},				-- cite interview
	['Cartography'] = 'cartography',
	['Chapter'] = {'chapter', 'contribution', 'entry', 'article', 'section', 'notestitle'},	-- notestitle is deprecated; remove after 1 October 2014; used by old cite AV media notes
	['ChapterLink'] = {'chapter-link', 'chapterlink'},
	['ChapterURL'] = {'chapter-url', 'chapterurl', 'contribution-url', 'contributionurl', 'section-url', 'sectionurl'},
	['City'] = 'city',										-- cite interview
	['Coauthors'] = {'coauthors', 'coauthor'},				-- coauthor and coauthors are deprecated; remove after 1 October 2014
	['Cointerviewers'] = 'cointerviewers',					-- cointerviewers is deprecated; remove after 1 October 2014; used by cite interview
	['Conference'] = {'conference', 'event'},
	['ConferenceURL'] = {'conference-url', 'conferenceurl', 'event-url', 'eventurl'},
	['Date'] = 'date',
	['Day'] = 'day',
	['DeadURL'] = {'dead-url', 'deadurl'},
	['Degree'] = 'degree',
	['DisplayAuthors'] = {'display-authors', 'displayauthors'},
	['DisplayEditors'] = {'display-editors', 'displayeditors'},
	['Docket'] = 'docket',
	['DoiBroken'] = {'doi-broken', 'doi-broken-date', 'doi-inactive-date', 'DoiBroken', 'doi_brokendate', 'doi_inactivedate'},
	['Edition'] = 'edition',
	['Editors'] = 'editors',
	['EditorFormat'] = {'editor-format', 'editorformat'},
	['EditorSeparator'] = 'editor-separator',
	['EditorNameSeparator'] = 'editor-name-separator',
	['Embargo'] = {'Embargo', 'embargo'},
	['Format'] = 'format',
	['ID'] = {'id', 'ID', 'publisherid'},					-- publisherid is deprecated; remove after 1 October 2014; used by old cite AV media notes and old cite DVD notes
	['IgnoreISBN'] = {'ignore-isbn-error', 'ignoreisbnerror'},
	['Inset'] = 'inset',
	['Interviewer'] = 'interviewer',						-- cite interview
	['Issue'] = {'issue', 'number'},
	['Language'] = {'language', 'in'},
	['LastAuthorAmp'] = {'last-author-amp', 'lastauthoramp'},
	['LayDate'] = {'lay-date', 'laydate'},
	['LaySource'] = {'lay-source', 'laysource'},
	['LayURL'] = {'lay-url', 'lay-summary', 'layurl', 'laysummary'},
	['Minutes'] = 'minutes',
	['Month'] = 'month',
	['NameSeparator'] = 'name-separator',
	['Network'] = 'network',
	['NoPP'] = {'no-pp', 'nopp'},
	['NoTracking'] = {'template-doc-demo', 'template doc demo', 'no-cat', 'nocat', 
		'no-tracking', 'notracking'},
	['OrigYear'] = {'orig-year', 'origyear', 'titleyear'},	-- titleyear is deprecated; remove after 1 October 2014; used in old cite DVD notes
	['Others'] = {'others', 'artist', 'director'},			-- artist and director are deprecated; remove after 1 October 2014; used in old cite AV media notes and old cite DVD notes
	['Page'] = {'p', 'page'},
	['Pages'] = {'pp', 'pages'},
	['Periodical'] = {'journal', 'newspaper', 'magazine', 'work',
		'website',  'periodical', 'encyclopedia', 'encyclopaedia', 'dictionary'},
	['Place'] = {'place', 'location'},
	['PPrefix'] = {'p-prefix', 'PPrefix'},
	['PPPrefix'] = {'pp-prefix', 'PPPrefix'},
	['Program'] = 'program',								-- cite interview
	['PostScript'] = 'postscript',
	['PublicationDate'] = {'publicationdate', 'publication-date'},
	['PublicationPlace'] = {'publication-place', 'publicationplace'},
--[[ Hide unfinished cite newsgroup code so that long delayed update can take place
	['PublisherName'] = {'publisher', 'distributor', 'institution', 'newsgroup'},
]]	['PublisherName'] = {'publisher', 'distributor', 'institution'},
	['Quote'] = {'quote', 'quotation'},
	['Ref'] = {'ref', 'Ref'},
	['RegistrationRequired'] = 'registration',
	['Scale'] = 'scale',
	['Section'] = 'section',
	['Season'] = 'season',
	['Separator'] = 'separator',
	['Series'] = {'series', 'version'},
	['SeriesSeparator'] = 'series-separator',
	['SeriesLink'] = {'series-link', 'serieslink'},
	['SeriesNumber'] = {'series-number', 'series-no', 'seriesnumber', 'seriesno'},
	['Station'] = 'station',
	['SubscriptionRequired'] = 'subscription',
	['Time'] = 'time',
	['TimeCaption'] = {'time-caption', 'timecaption'},
	['Title'] = 'title',
	['TitleLink'] = {'title-link', 'episode-link', 'titlelink', 'episodelink', 'albumlink'},	-- albumlink is deprecated; remove after 1 October 2014; used by old cite AV media notes
	['TitleNote'] = 'department',
	['TitleType'] = {'type', 'medium'},
	['TransChapter'] = {'trans-chapter', 'trans_chapter'},
	['Transcript'] = 'transcript',
	['TranscriptURL'] = {'transcript-url', 'transcripturl'},
	['TransTitle'] = {'trans-title', 'trans_title'},
	['URL'] = {'url', 'URL'},
	['Via'] = 'via',
	['Volume'] = 'volume',
	['Year'] = 'year',

	['AuthorList-First'] = {&quot;author#-first&quot;, &quot;author-first#&quot;,
		&quot;first#&quot;, &quot;given#&quot;},
	['AuthorList-Last'] = {&quot;author#-last&quot;, &quot;author-last#&quot;, 
		&quot;last#&quot;, &quot;surname#&quot;, &quot;Author#&quot;, &quot;author#&quot;, &quot;authors#&quot;, &quot;subject#&quot;},
	['AuthorList-Link'] = {&quot;author#-link&quot;, &quot;author-link#&quot;, 
		&quot;author#link&quot;, &quot;authorlink#&quot;, &quot;subject-link#&quot;, &quot;subject#link&quot;, &quot;subject#-link&quot;, &quot;subjectlink#&quot;},
	['AuthorList-Mask'] = {&quot;author#-mask&quot;, &quot;author-mask#&quot;, 
		&quot;author#mask&quot;, &quot;authormask#&quot;},
	
	['EditorList-First'] = {&quot;editor#-first&quot;, 
		&quot;editor-first#&quot;, &quot;editor#-given&quot;, &quot;editor-given#&quot;, &quot;EditorGiven#&quot;},
	['EditorList-Last'] = {&quot;editor#-last&quot;, &quot;editor-last#&quot;,
		&quot;editor#-surname&quot;, &quot;editor-surname#&quot;, &quot;EditorSurname#&quot;, &quot;Editor#&quot;, &quot;editor#&quot;, &quot;editors#&quot;},
	['EditorList-Link'] = {&quot;editor#-link&quot;, &quot;editor-link#&quot;, 
		&quot;editor#link&quot;, &quot;editorlink#&quot;},
	['EditorList-Mask'] = {&quot;editor#-mask&quot;, &quot;editor-mask#&quot;, 
		&quot;editor#mask&quot;, &quot;editormask#&quot;},
	
}

-- Default parameter values
citation_config.defaults = {
	['DeadURL'] = 'yes',
	['AuthorSeparator'] = ';',
	['EditorSeparator'] = ';',
	['NameSeparator'] = ',',
	['PPrefix'] = &quot;p.&amp;nbsp;&quot;,
	['PPPrefix'] = &quot;pp.&amp;nbsp;&quot;,	
}

--[[
Error condition table

The following contains a list of IDs for various error conditions defined in the 
code.  For each ID, we specify a text message to display, an error category to
include, and whether the error message should be wrapped as a hidden comment.

Anchor changes require identical changes to matching anchor in Help:CS1 errors
]]

citation_config.error_conditions = {
	accessdate_missing_url = {
		message = '&lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;accessdate=&lt;/code&gt; requires &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;url=&lt;/code&gt;',
		anchor = 'accessdate_missing_url',
		category = 'Pages using citations with accessdate and no URL',
		hidden = true },
	archive_missing_date = {
		message = '&lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;archiveurl=&lt;/code&gt; requires &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;archivedate=&lt;/code&gt;',
		anchor = 'archive_missing_date',
		category = 'Pages with archiveurl citation errors',
		hidden = false },
	archive_missing_url = {
		message = '&lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;archiveurl=&lt;/code&gt; requires &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;url=&lt;/code&gt;',
		anchor = 'archive_missing_url',
		category = 'Pages with archiveurl citation errors',
		hidden = false },
	bad_arxiv = {
		message = 'Check &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;arxiv=&lt;/code&gt; value',
		anchor = 'bad_arxiv',
		category = 'CS1 errors: arXiv',
		hidden = false },
	bad_authorlink = {
		message = 'Check &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;authorlink=&lt;/code&gt; value',
		anchor = 'bad_authorlink',
		category = 'CS1 errors: authorlink',
		hidden = false },
	bad_date = {
		message = 'Check date values in: &lt;code style=&quot;'..code_style..'&quot;&gt;$1&lt;/code&gt;',
		anchor = 'bad_date',
		category = 'CS1 errors: dates',
		hidden = true },
	bad_doi = {
		message = 'Check &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;doi=&lt;/code&gt; value',
		anchor = 'bad_doi',
		category = 'Pages with DOI errors',
		hidden = false },
	bad_isbn = {
		message = 'Check &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;isbn=&lt;/code&gt; value',
		anchor = 'bad_isbn',
		category = 'Pages with ISBN errors',
		hidden = false },
	bad_issn = {
		message = 'Check &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;issn=&lt;/code&gt; value',
		anchor = 'bad_issn',
		category = 'CS1 errors: ISSN',
		hidden = false },
	bad_lccn = {
		message = 'Check &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;lccn=&lt;/code&gt; value',
		anchor = 'bad_lccn',
		category = 'CS1 errors: LCCN',
		hidden = false },
	bad_ol = {
		message = 'Check &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;ol=&lt;/code&gt; value',
		anchor = 'bad_ol',
		category = 'Pages with OL errors',
		hidden = false },
	bad_pmc = {
		message = 'Check &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;pmc=&lt;/code&gt; value',
		anchor = 'bad_pmc',
		category = 'CS1 errors: PMC',
		hidden = false },
	bad_pmid = {
		message = 'Check &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;pmid=&lt;/code&gt; value',
		anchor = 'bad_pmid',
		category = 'CS1 errors: PMID',
		hidden = false },
	bad_url = {
		message = 'Check &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;url=&lt;/code&gt; scheme',
		anchor = 'bad_url',
		category = 'Pages with URL errors',
		hidden = false },
	bare_url_missing_title = {
		message = '$1 missing title',
		anchor = 'bare_url_missing_title',
		category = 'Pages with citations having bare URLs',
		hidden = false },
	citation_missing_title = {
		message = 'Missing or empty &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;title=&lt;/code&gt;',
		anchor = 'citation_missing_title',
		category = 'Pages with citations lacking titles',
		hidden = false },
	cite_web_url = {										-- this error applies to cite web and to cite podcast
		message = 'Missing or empty &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;url=&lt;/code&gt;',
		anchor = 'cite_web_url',
		category = 'Pages using web citations with no URL',
		hidden = true },
	coauthors_missing_author = {
		message = '&lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;coauthors=&lt;/code&gt; requires &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;author=&lt;/code&gt;',
		anchor = 'coauthors_missing_author',
		category = 'CS1 errors: coauthors without author',
		hidden = false },
	deprecated_params = {
		message = 'Cite uses deprecated parameters',
		anchor = 'deprecated_params',
		category = 'Pages containing cite templates with deprecated parameters',
		hidden = true },
	empty_citation = {
		message = 'Empty citation',
		anchor = 'empty_citation',
		category = 'Pages with empty citations',
		hidden = false },
	extra_pages = {
		message = 'Extra &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;pages=&lt;/code&gt; or &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;at=&lt;/code&gt;',
		anchor = 'extra_pages',
		category = 'Pages with citations using conflicting page specifications',
		hidden = false },
	first_missing_last = {
		message = '&lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;first$2=&lt;/code&gt; missing &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;last$2=&lt;/code&gt; in $1',
		anchor = 'first_missing_last',
		category = 'CS1 errors: missing author or editor',
		hidden = false },
	format_missing_url = {
		message = '&lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;format=&lt;/code&gt; requires &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;url=&lt;/code&gt;',
		anchor = 'format_missing_url',
		category = 'Pages using citations with format and no URL',
		hidden = true },
	implict_etal_author = {
		message = '&lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;displayauthors=&lt;/code&gt; suggested',
		anchor = 'displayauthors',
		category = 'Pages using citations with old-style implicit et al.',
		hidden = true },
	implict_etal_editor = {
		message = '&lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;displayeditors=&lt;/code&gt; suggested',
		anchor = 'displayeditors',
		category = 'Pages using citations with old-style implicit et al. in editors',
		hidden = true },
	missing_name = {
		message = 'Missing &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;last$2=&lt;/code&gt; in $1',
		anchor = 'missing_name',
		category = 'CS1 errors: missing author or editor',
		hidden = false },
	parameter_ignored = {
		message = 'Unknown parameter &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;$1=&lt;/code&gt; ignored',
		anchor = 'parameter_ignored',
		category = 'Pages with citations using unsupported parameters',
		hidden = false },
	parameter_ignored_suggest = {
		message = 'Unknown parameter &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;$1=&lt;/code&gt; ignored (&lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;$2=&lt;/code&gt; suggested)',
		anchor = 'parameter_ignored_suggest',
		category = 'Pages with citations using unsupported parameters',
		hidden = false },
	redundant_parameters = {
		message = 'More than one of $1 specified',
		anchor = 'redundant_parameters',
		category = 'Pages with citations having redundant parameters',
		hidden = false },
	text_ignored = {
		message = 'Text &quot;$1&quot; ignored',
		anchor = 'text_ignored',
		category = 'Pages with citations using unnamed parameters',
		hidden = false },
	trans_missing_chapter = {
		message = '&lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;trans_chapter=&lt;/code&gt; requires &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;chapter=&lt;/code&gt;',
		anchor = 'trans_missing_chapter',
		category = 'Pages with citations using translated terms without the original',
		hidden = false },
	trans_missing_title = {
		message = '&lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;trans_title=&lt;/code&gt; requires &lt;code style=&quot;'..code_style..'&quot;&gt;&amp;#124;title=&lt;/code&gt;',
		anchor = 'trans_missing_title',
		category = 'Pages with citations using translated terms without the original',
		hidden = false },
	wikilink_in_url = {
		message = 'Wikilink embedded in URL title',
		anchor = 'wikilink_in_url',
		category = 'Pages with citations having wikilinks embedded in URL titles',
		hidden = false },
}

citation_config.id_handlers = {
	['ARXIV'] = {
		parameters = {'arxiv', 'ARXIV'}, 
		link = 'arXiv',
		label = 'arXiv',
		mode = 'manual',
		prefix = '//arxiv.org/abs/', 						-- protocol relative tested 2013-09-04
		encode = false,
		COinS = 'info:arxiv',
		separator = ':',
	},
	['ASIN'] = {
		parameters = { 'asin', 'ASIN' },	   
		link = 'Amazon Standard Identification Number',
		label = 'ASIN',
		mode = 'manual',
		COinS = 'info:asin',
		separator = '&amp;nbsp;',
		encode = false;
	},
	['BIBCODE'] = {
		parameters = {'bibcode', 'BIBCODE'}, 
		link = 'Bibcode',
		label = 'Bibcode',
		mode = 'external',
		prefix = 'http://adsabs.harvard.edu/abs/',
		encode = false,
		COinS = 'info:bibcode',
		separator = ':',
	},
	['DOI'] = {
		parameters = { 'doi', 'DOI' },
		link = 'Digital object identifier',
		label = 'doi',
		mode = 'manual',
		prefix = 'http://dx.doi.org/',
		COinS = 'info:doi',
		separator = ':',
		encode = true,
	},
	['ISBN'] = {
		parameters = {'isbn', 'ISBN', 'isbn13', 'ISBN13'}, 
		link = 'International Standard Book Number',
		label = 'ISBN',
		mode = 'manual',
		prefix = 'Special:BookSources/',
		COinS = 'rft.isbn',
		separator = '&amp;nbsp;',
	},
	['ISSN'] = {
		parameters = {'issn', 'ISSN'}, 
		link = 'International Standard Serial Number',
		label = 'ISSN',
		mode = 'manual',
		prefix = '//www.worldcat.org/issn/',
		COinS = 'rft.issn',
		encode = false,
		separator = '&amp;nbsp;',
	},
	['JFM'] = {
		parameters = {'jfm', 'JFM'}, 
		link = 'Jahrbuch über die Fortschritte der Mathematik',
		label = 'JFM',
		mode = 'external',
		prefix = 'http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:',
		COinS = 'rft.jfm',
		encode = true,
		separator = '&amp;nbsp;',
	},
	['JSTOR'] = {
		parameters = {'jstor', 'JSTOR'}, 
		link = 'JSTOR',
		label = 'JSTOR',
		mode = 'external',
		prefix = '//www.jstor.org/stable/', 				-- protocol relative tested 2013-09-04
		COinS = 'rft.jstor',
		encode = true,
		separator = '&amp;nbsp;',
	},
	['LCCN'] = {
		parameters = {'LCCN', 'lccn'}, 
		link = 'Library of Congress Control Number',
		label = 'LCCN',
		mode = 'manual',
		prefix = 'http://lccn.loc.gov/',
		COinS = 'rft.lccn',
		encode = false,
		separator = '&amp;nbsp;',
	},
	['MR'] = {
		parameters = {'MR', 'mr'}, 
		link = 'Mathematical Reviews',
		label = 'MR',
		mode = 'external',
		prefix = '//www.ams.org/mathscinet-getitem?mr=', 	-- protocol relative tested 2013-09-04
		COinS = 'rft.mr',
		encode = true,
		separator = '&amp;nbsp;',
	},
	['OCLC'] = {
		parameters = {'OCLC', 'oclc'}, 
		link = 'OCLC',
		label = 'OCLC',
		mode = 'external',
		prefix = '//www.worldcat.org/oclc/',
		COinS = 'info:oclcnum',
		encode = true,
		separator = '&amp;nbsp;',
	},
	['OL'] = {
		parameters = { 'ol', 'OL' },
		link = 'Open Library',
		label = 'OL',
		mode = 'manual',
		COinS = 'info:olnum',
		separator = '&amp;nbsp;',
		endode = true,
	},
	['OSTI'] = {
		parameters = {'OSTI', 'osti'}, 
		link = 'Office of Scientific and Technical Information',
		label = 'OSTI',
		mode = 'external',
		prefix = '//www.osti.gov/energycitations/product.biblio.jsp?osti_id=',	-- protocol relative tested 2013-09-04
		COinS = 'info:osti',
		encode = true,
		separator = '&amp;nbsp;',
	},
	['PMC'] = {
		parameters = {'PMC', 'pmc'}, 
		link = 'PubMed Central',
		label = 'PMC',
		mode = 'manual',									-- changed to support unlinking of PMC identifier when article is embargoed
		prefix = '//www.ncbi.nlm.nih.gov/pmc/articles/PMC', 
		suffix = &quot; &quot;,
		COinS = 'info:pmc',
		encode = true,
		separator = '&amp;nbsp;',
	},
	['PMID'] = {
		parameters = {'PMID', 'pmid'}, 
		link = 'PubMed Identifier',
		label = 'PMID',
		mode = 'manual',									-- changed from external manual to support PMID validation
		prefix = '//www.ncbi.nlm.nih.gov/pubmed/',
		COinS = 'info:pmid',
		encode = false,
		separator = '&amp;nbsp;',
	},
	['RFC'] = {
		parameters = {'RFC', 'rfc'}, 
		link = 'Request for Comments',
		label = 'RFC',
		mode = 'external',
		prefix = '//tools.ietf.org/html/rfc',
		COinS = 'info:rfc',
		encode = false,
		separator = '&amp;nbsp;',
	},
	['SSRN'] = {
		parameters = {'SSRN', 'ssrn'}, 
		link = 'Social Science Research Network',
		label = 'SSRN',
		mode = 'external',
		prefix = '//ssrn.com/abstract=', 					-- protocol relative tested 2013-09-04
		COinS = 'info:ssrn',
		encode = true,
		separator = '&amp;nbsp;',
	},
--[[ Hide unfinished cite newsgroup code so that long delayed update can take place
	['USENETID'] = {
		parameters = {'id', 'ID'}, 
		link = 'Usenet',
		label = 'Usenet:',
		mode = 'external',
		prefix = 'news:',
		encode = false,
		COinS = 'info:usenet',
		separator = '&amp;nbsp;',
	},
]]	['ZBL'] = {
		parameters = {'ZBL', 'zbl'}, 
		link = 'Zentralblatt MATH',
		label = 'Zbl',
		mode = 'external',
		prefix = 'http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:',
		COinS = 'info:zbl',
		encode = true,
		separator = '&amp;nbsp;',
	},
}

--iso639-1 language codes and names.
citation_config.iso639_1 = {
	[&quot;aa&quot;] = &quot;Afar&quot;,
	[&quot;ab&quot;] = &quot;Abkhazian&quot;,
	[&quot;ae&quot;] = &quot;Avestan&quot;,
	[&quot;af&quot;] = &quot;Afrikaans&quot;,
	[&quot;ak&quot;] = &quot;Akan&quot;,
	[&quot;am&quot;] = &quot;Amharic&quot;,
	[&quot;an&quot;] = &quot;Aragonese&quot;,
	[&quot;ar&quot;] = &quot;Arabic&quot;,
	[&quot;as&quot;] = &quot;Assamese&quot;,
	[&quot;av&quot;] = &quot;Avaric&quot;,
	[&quot;ay&quot;] = &quot;Aymara&quot;,
	[&quot;az&quot;] = &quot;Azerbaijani&quot;,
	[&quot;ba&quot;] = &quot;Bashkir&quot;,
	[&quot;be&quot;] = &quot;Belarusian&quot;,
	[&quot;bg&quot;] = &quot;Bulgarian&quot;,
	[&quot;bh&quot;] = &quot;Bihari languages&quot;,
	[&quot;bi&quot;] = &quot;Bislama&quot;,
	[&quot;bm&quot;] = &quot;Bambara&quot;,
	[&quot;bn&quot;] = &quot;Bengali&quot;,
	[&quot;bo&quot;] = &quot;Tibetan&quot;,
	[&quot;br&quot;] = &quot;Breton&quot;,
	[&quot;bs&quot;] = &quot;Bosnian&quot;,
	[&quot;ca&quot;] = &quot;Catalan&quot;,
--	[&quot;ca&quot;] = &quot;Valencian&quot;,
	[&quot;ce&quot;] = &quot;Chechen&quot;,
	[&quot;ch&quot;] = &quot;Chamorro&quot;,
	[&quot;co&quot;] = &quot;Corsican&quot;,
	[&quot;cr&quot;] = &quot;Cree&quot;,
	[&quot;cs&quot;] = &quot;Czech&quot;,
	[&quot;cu&quot;] = &quot;Church Slavic&quot;,
--	[&quot;cu&quot;] = &quot;Old Slavonic&quot;,
--	[&quot;cu&quot;] = &quot;Church Slavonic&quot;,
--	[&quot;cu&quot;] = &quot;Old Bulgarian&quot;,
--	[&quot;cu&quot;] = &quot;Old Church Slavonic&quot;,
	[&quot;cv&quot;] = &quot;Chuvash&quot;,
	[&quot;cy&quot;] = &quot;Welsh&quot;,
	[&quot;da&quot;] = &quot;Danish&quot;,
	[&quot;de&quot;] = &quot;German&quot;,
	[&quot;dv&quot;] = &quot;Divehi&quot;,
	[&quot;dv&quot;] = &quot;Dhivehi&quot;,
	[&quot;dv&quot;] = &quot;Maldivian&quot;,
	[&quot;dz&quot;] = &quot;Dzongkha&quot;,
	[&quot;ee&quot;] = &quot;Ewe&quot;,
	[&quot;el&quot;] = &quot;Modern Greek&quot;,
	[&quot;en&quot;] = &quot;English&quot;,
	[&quot;eo&quot;] = &quot;Esperanto&quot;,
	[&quot;es&quot;] = &quot;Spanish&quot;,
--	[&quot;es&quot;] = &quot;Castilian&quot;,
	[&quot;et&quot;] = &quot;Estonian&quot;,
	[&quot;eu&quot;] = &quot;Basque&quot;,
	[&quot;fa&quot;] = &quot;Persian&quot;,
	[&quot;ff&quot;] = &quot;Fulah&quot;,
	[&quot;fi&quot;] = &quot;Finnish&quot;,
	[&quot;fj&quot;] = &quot;Fijian&quot;,
	[&quot;fo&quot;] = &quot;Faroese&quot;,
	[&quot;fr&quot;] = &quot;French&quot;,
	[&quot;fy&quot;] = &quot;Western Frisian&quot;,
	[&quot;ga&quot;] = &quot;Irish&quot;,
--	[&quot;gd&quot;] = &quot;Gaelic&quot;,
	[&quot;gd&quot;] = &quot;Scottish Gaelic&quot;,
	[&quot;gl&quot;] = &quot;Galician&quot;,
	[&quot;gn&quot;] = &quot;Guarani&quot;,
	[&quot;gu&quot;] = &quot;Gujarati&quot;,
	[&quot;gv&quot;] = &quot;Manx&quot;,
	[&quot;ha&quot;] = &quot;Hausa&quot;,
	[&quot;he&quot;] = &quot;Hebrew&quot;,
	[&quot;hi&quot;] = &quot;Hindi&quot;,
	[&quot;ho&quot;] = &quot;Hiri Motu&quot;,
	[&quot;hr&quot;] = &quot;Croatian&quot;,
--	[&quot;ht&quot;] = &quot;Haitian&quot;,
	[&quot;ht&quot;] = &quot;Haitian Creole&quot;,
	[&quot;hu&quot;] = &quot;Hungarian&quot;,
	[&quot;hy&quot;] = &quot;Armenian&quot;,
	[&quot;hz&quot;] = &quot;Herero&quot;,
	[&quot;ia&quot;] = &quot;Interlingua&quot;,
	[&quot;id&quot;] = &quot;Indonesian&quot;,
	[&quot;ie&quot;] = &quot;Interlingue&quot;,
	[&quot;ie&quot;] = &quot;Occidental&quot;,
	[&quot;ig&quot;] = &quot;Igbo&quot;,
--	[&quot;ii&quot;] = &quot;Sichuan Yi&quot;,
	[&quot;ii&quot;] = &quot;Nuosu&quot;,
	[&quot;ik&quot;] = &quot;Inupiaq&quot;,
	[&quot;io&quot;] = &quot;Ido&quot;,
	[&quot;is&quot;] = &quot;Icelandic&quot;,
	[&quot;it&quot;] = &quot;Italian&quot;,
	[&quot;iu&quot;] = &quot;Inuktitut&quot;,
	[&quot;ja&quot;] = &quot;Japanese&quot;,
	[&quot;jv&quot;] = &quot;Javanese&quot;,
	[&quot;ka&quot;] = &quot;Georgian&quot;,
	[&quot;kg&quot;] = &quot;Kongo&quot;,
--	[&quot;ki&quot;] = &quot;Kikuyu&quot;,
	[&quot;ki&quot;] = &quot;Gikuyu&quot;,
--	[&quot;kj&quot;] = &quot;Kuanyama&quot;,
	[&quot;kj&quot;] = &quot;Kwanyama&quot;,
	[&quot;kk&quot;] = &quot;Kazakh&quot;,
--	[&quot;kl&quot;] = &quot;Kalaallisut&quot;,
	[&quot;kl&quot;] = &quot;Greenlandic&quot;,
	[&quot;km&quot;] = &quot;Central Khmer&quot;,
	[&quot;kn&quot;] = &quot;Kannada&quot;,
	[&quot;ko&quot;] = &quot;Korean&quot;,
	[&quot;kr&quot;] = &quot;Kanuri&quot;,
	[&quot;ks&quot;] = &quot;Kashmiri&quot;,
	[&quot;ku&quot;] = &quot;Kurdish&quot;,
	[&quot;kv&quot;] = &quot;Komi&quot;,
	[&quot;kw&quot;] = &quot;Cornish&quot;,
--	[&quot;ky&quot;] = &quot;Kirghiz&quot;,
	[&quot;ky&quot;] = &quot;Kyrgyz&quot;,
	[&quot;la&quot;] = &quot;Latin&quot;,
	[&quot;lb&quot;] = &quot;Luxembourgish&quot;,
--	[&quot;lb&quot;] = &quot;Letzeburgesch&quot;,
	[&quot;lg&quot;] = &quot;Ganda&quot;,
--	[&quot;li&quot;] = &quot;Limburgan&quot;,
--	[&quot;li&quot;] = &quot;Limburger&quot;,
	[&quot;li&quot;] = &quot;Limburgish&quot;,
	[&quot;ln&quot;] = &quot;Lingala&quot;,
	[&quot;lo&quot;] = &quot;Lao&quot;,
	[&quot;lt&quot;] = &quot;Lithuanian&quot;,
	[&quot;lu&quot;] = &quot;Luba-Katanga&quot;,
	[&quot;lv&quot;] = &quot;Latvian&quot;,
	[&quot;mg&quot;] = &quot;Malagasy&quot;,
	[&quot;mh&quot;] = &quot;Marshallese&quot;,
	[&quot;mi&quot;] = &quot;Maori&quot;,
	[&quot;mk&quot;] = &quot;Macedonian&quot;,
	[&quot;ml&quot;] = &quot;Malayalam&quot;,
	[&quot;mn&quot;] = &quot;Mongolian&quot;,
	[&quot;mr&quot;] = &quot;Marathi&quot;,
	[&quot;ms&quot;] = &quot;Malay&quot;,
	[&quot;mt&quot;] = &quot;Maltese&quot;,
	[&quot;my&quot;] = &quot;Burmese&quot;,
	[&quot;na&quot;] = &quot;Nauru&quot;,
	[&quot;nb&quot;] = &quot;Norwegian Bokmål&quot;,
	[&quot;nd&quot;] = &quot;North Ndebele&quot;,
	[&quot;ne&quot;] = &quot;Nepali&quot;,
	[&quot;ng&quot;] = &quot;Ndonga&quot;,
	[&quot;nl&quot;] = &quot;Dutch&quot;,
--	[&quot;nl&quot;] = &quot;Flemish&quot;,
	[&quot;nn&quot;] = &quot;Norwegian Nynorsk&quot;,
	[&quot;no&quot;] = &quot;Norwegian&quot;,
	[&quot;nr&quot;] = &quot;South Ndebele&quot;,
	[&quot;nv&quot;] = &quot;Navajo&quot;,
--	[&quot;nv&quot;] = &quot;Navaho&quot;,
--	[&quot;ny&quot;] = &quot;Chichewa&quot;,
--	[&quot;ny&quot;] = &quot;Chewa&quot;,
	[&quot;ny&quot;] = &quot;Nyanja&quot;,
	[&quot;oc&quot;] = &quot;Occitan&quot;,
	[&quot;oj&quot;] = &quot;Ojibwa&quot;,
	[&quot;om&quot;] = &quot;Oromo&quot;,
	[&quot;or&quot;] = &quot;Oriya&quot;,
	[&quot;os&quot;] = &quot;Ossetian&quot;,
	[&quot;os&quot;] = &quot;Ossetic&quot;,
--	[&quot;pa&quot;] = &quot;Panjabi&quot;,
	[&quot;pa&quot;] = &quot;Punjabi&quot;,
	[&quot;pi&quot;] = &quot;Pali&quot;,
	[&quot;pl&quot;] = &quot;Polish&quot;,
--	[&quot;ps&quot;] = &quot;Pushto&quot;,
	[&quot;ps&quot;] = &quot;Pashto&quot;,
	[&quot;pt&quot;] = &quot;Portuguese&quot;,
	[&quot;qu&quot;] = &quot;Quechua&quot;,
	[&quot;rm&quot;] = &quot;Romansh&quot;,
	[&quot;rn&quot;] = &quot;Rundi&quot;,
	[&quot;ro&quot;] = &quot;Romanian&quot;,
--	[&quot;ro&quot;] = &quot;Moldavian&quot;,
--	[&quot;ro&quot;] = &quot;Moldovan&quot;,
	[&quot;ru&quot;] = &quot;Russian&quot;,
	[&quot;rw&quot;] = &quot;Kinyarwanda&quot;,
	[&quot;sa&quot;] = &quot;Sanskrit&quot;,
	[&quot;sc&quot;] = &quot;Sardinian&quot;,
	[&quot;sd&quot;] = &quot;Sindhi&quot;,
	[&quot;se&quot;] = &quot;Northern Sami&quot;,
	[&quot;sg&quot;] = &quot;Sango&quot;,
	[&quot;si&quot;] = &quot;Sinhala&quot;,
--	[&quot;si&quot;] = &quot;Sinhalese&quot;,
	[&quot;sk&quot;] = &quot;Slovak&quot;,
	[&quot;sl&quot;] = &quot;Slovenian&quot;,
	[&quot;sm&quot;] = &quot;Samoan&quot;,
	[&quot;sn&quot;] = &quot;Shona&quot;,
	[&quot;so&quot;] = &quot;Somali&quot;,
	[&quot;sq&quot;] = &quot;Albanian&quot;,
	[&quot;sr&quot;] = &quot;Serbian&quot;,
	[&quot;ss&quot;] = &quot;Swati&quot;,
	[&quot;st&quot;] = &quot;Southern Sotho&quot;,
	[&quot;su&quot;] = &quot;Sundanese&quot;,
	[&quot;sv&quot;] = &quot;Swedish&quot;,
	[&quot;sw&quot;] = &quot;Swahili&quot;,
	[&quot;ta&quot;] = &quot;Tamil&quot;,
	[&quot;te&quot;] = &quot;Telugu&quot;,
	[&quot;tg&quot;] = &quot;Tajik&quot;,
	[&quot;th&quot;] = &quot;Thai&quot;,
	[&quot;ti&quot;] = &quot;Tigrinya&quot;,
	[&quot;tk&quot;] = &quot;Turkmen&quot;,
	[&quot;tl&quot;] = &quot;Tagalog&quot;,
	[&quot;tn&quot;] = &quot;Tswana&quot;,
	[&quot;to&quot;] = &quot;Tonga (Tonga Islands)&quot;,
	[&quot;tr&quot;] = &quot;Turkish&quot;,
	[&quot;ts&quot;] = &quot;Tsonga&quot;,
	[&quot;tt&quot;] = &quot;Tatar&quot;,
	[&quot;tw&quot;] = &quot;Twi&quot;,
	[&quot;ty&quot;] = &quot;Tahitian&quot;,
--	[&quot;ug&quot;] = &quot;Uighur&quot;,
	[&quot;ug&quot;] = &quot;Uyghur&quot;,
	[&quot;uk&quot;] = &quot;Ukrainian&quot;,
	[&quot;ur&quot;] = &quot;Urdu&quot;,
	[&quot;uz&quot;] = &quot;Uzbek&quot;,
	[&quot;ve&quot;] = &quot;Venda&quot;,
	[&quot;vi&quot;] = &quot;Vietnamese&quot;,
	[&quot;vo&quot;] = &quot;Volapük&quot;,
	[&quot;wa&quot;] = &quot;Walloon&quot;,
	[&quot;wo&quot;] = &quot;Wolof&quot;,
	[&quot;xh&quot;] = &quot;Xhosa&quot;,
	[&quot;yi&quot;] = &quot;Yiddish&quot;,
	[&quot;yo&quot;] = &quot;Yoruba&quot;,
	[&quot;za&quot;] = &quot;Zhuang&quot;,
--	[&quot;za&quot;] = &quot;Chuang&quot;,
	[&quot;zh&quot;] = &quot;Chinese&quot;,
	[&quot;zu&quot;] = &quot;Zulu&quot;,
}
return citation_config;</text>
      <sha1>ov33haahvlmi52qcmaihosq89qo5vrq</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Documentation</title>
    <ns>828</ns>
    <id>106</id>
    <revision>
      <id>438</id>
      <timestamp>2019-01-13T17:21:11Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;-- This module implements {{documentation}}.  -- Get required modules. local getArgs = require('Module:Arguments').getArgs local messageBox = require('Module:Message box')  --...&quot;</comment>
      <origin>438</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="36742" sha1="aigdgnmr62bny2nwfvzvi5sfbsnl1vr" xml:space="preserve">-- This module implements {{documentation}}.

-- Get required modules.
local getArgs = require('Module:Arguments').getArgs
local messageBox = require('Module:Message box')

-- Get the config table.
local cfg = mw.loadData('Module:Documentation/config')

local p = {}

-- Often-used functions.
local ugsub = mw.ustring.gsub

----------------------------------------------------------------------------
-- Helper functions
--
-- These are defined as local functions, but are made available in the p
-- table for testing purposes.
----------------------------------------------------------------------------

local function message(cfgKey, valArray, expectType)
	--[[
	-- Gets a message from the cfg table and formats it if appropriate.
	-- The function raises an error if the value from the cfg table is not
	-- of the type expectType. The default type for expectType is 'string'.
	-- If the table valArray is present, strings such as $1, $2 etc. in the
	-- message are substituted with values from the table keys [1], [2] etc.
	-- For example, if the message &quot;foo-message&quot; had the value 'Foo $2 bar $1.',
	-- message('foo-message', {'baz', 'qux'}) would return &quot;Foo qux bar baz.&quot;
	--]]
	local msg = cfg[cfgKey]
	expectType = expectType or 'string'
	if type(msg) ~= expectType then
		error('message: type error in message cfg.' .. cfgKey .. ' (' .. expectType .. ' expected, got ' .. type(msg) .. ')', 2)
	end
	if not valArray then
		return msg
	end

	local function getMessageVal(match)
		match = tonumber(match)
		return valArray[match] or error('message: no value found for key $' .. match .. ' in message cfg.' .. cfgKey, 4)
	end

	local ret = ugsub(msg, '$([1-9][0-9]*)', getMessageVal)
	return ret
end

p.message = message

local function makeWikilink(page, display)
	if display then
		return mw.ustring.format('[[%s|%s]]', page, display)
	else
		return mw.ustring.format('[[%s]]', page)
	end
end

p.makeWikilink = makeWikilink

local function makeCategoryLink(cat, sort)
	local catns = mw.site.namespaces[14].name
	return makeWikilink(catns .. ':' .. cat, sort)
end

p.makeCategoryLink = makeCategoryLink

local function makeUrlLink(url, display)
	return mw.ustring.format('[%s %s]', url, display)
end

p.makeUrlLink = makeUrlLink

local function makeToolbar(...)
	local ret = {}
	local lim = select('#', ...)
	if lim &lt; 1 then
		return nil
	end
	for i = 1, lim do
		ret[#ret + 1] = select(i, ...)
	end
	return '&lt;small style=&quot;font-style: normal;&quot;&gt;(' .. table.concat(ret, ' &amp;#124; ') .. ')&lt;/small&gt;'
end	

p.makeToolbar = makeToolbar

----------------------------------------------------------------------------
-- Argument processing
----------------------------------------------------------------------------

local function makeInvokeFunc(funcName)
	return function (frame)
		local args = getArgs(frame, {
			valueFunc = function (key, value)
				if type(value) == 'string' then
					value = value:match('^%s*(.-)%s*$') -- Remove whitespace.
					if key == 'heading' or value ~= '' then
						return value
					else
						return nil
					end
				else
					return value
				end
			end
		})
		return p[funcName](args)
	end
end

----------------------------------------------------------------------------
-- Main function
----------------------------------------------------------------------------

p.main = makeInvokeFunc('_main')

function p._main(args)
	--[[
	-- This function defines logic flow for the module.
	-- @args - table of arguments passed by the user
	-- 
	-- Messages:
	-- 'main-div-id' --&gt; 'template-documentation'
	-- 'main-div-classes' --&gt; 'template-documentation iezoomfix'
	--]]
	local env = p.getEnvironment(args)
	local root = mw.html.create()
	root
		:wikitext(p.protectionTemplate(env))
		:wikitext(p.sandboxNotice(args, env))
		 -- This div tag is from {{documentation/start box}}, but moving it here
		 -- so that we don't have to worry about unclosed tags.
		:tag('div')
			:attr('id', message('main-div-id'))
			:addClass(message('main-div-classes'))
			:newline()
			:wikitext(p._startBox(args, env))
			:wikitext(p._content(args, env))
			:tag('div')
				:css('clear', 'both') -- So right or left floating items don't stick out of the doc box.
				:newline()
				:done()
			:done()
		:wikitext(p._endBox(args, env))
		:wikitext(p.addTrackingCategories(env))
	return tostring(root)
end

----------------------------------------------------------------------------
-- Environment settings
----------------------------------------------------------------------------

function p.getEnvironment(args)
	--[[
	-- Returns a table with information about the environment, including title objects and other namespace- or
	-- path-related data.
	-- @args - table of arguments passed by the user
	--
	-- Title objects include:
	-- env.title - the page we are making documentation for (usually the current title)
	-- env.templateTitle - the template (or module, file, etc.)
	-- env.docTitle - the /doc subpage.
	-- env.sandboxTitle - the /sandbox subpage.
	-- env.testcasesTitle - the /testcases subpage.
	-- env.printTitle - the print version of the template, located at the /Print subpage.
	--
	-- Data includes:
	-- env.protectionLevels - the protection levels table of the title object.
	-- env.subjectSpace - the number of the title's subject namespace.
	-- env.docSpace - the number of the namespace the title puts its documentation in.
	-- env.docpageBase - the text of the base page of the /doc, /sandbox and /testcases pages, with namespace.
	-- env.compareUrl - URL of the Special:ComparePages page comparing the sandbox with the template.
	-- 
	-- All table lookups are passed through pcall so that errors are caught. If an error occurs, the value
	-- returned will be nil.
	--]]
	
	local env, envFuncs = {}, {}

	-- Set up the metatable. If triggered we call the corresponding function in the envFuncs table. The value
	-- returned by that function is memoized in the env table so that we don't call any of the functions
	-- more than once. (Nils won't be memoized.)
	setmetatable(env, {
		__index = function (t, key)
			local envFunc = envFuncs[key]
			if envFunc then
				local success, val = pcall(envFunc)
				if success then
					env[key] = val -- Memoise the value.
					return val
				end
			end
			return nil
		end
	})	

	function envFuncs.title()
		-- The title object for the current page, or a test page passed with args.page.
		local title
		local titleArg = args.page
		if titleArg then
			title = mw.title.new(titleArg)
		else
			title = mw.title.getCurrentTitle()
		end
		return title
	end

	function envFuncs.templateTitle()
		--[[
		-- The template (or module, etc.) title object.
		-- Messages:
		-- 'sandbox-subpage' --&gt; 'sandbox'
		-- 'testcases-subpage' --&gt; 'testcases'
		--]]
		local subjectSpace = env.subjectSpace
		local title = env.title
		local subpage = title.subpageText
		if subpage == message('sandbox-subpage') or subpage == message('testcases-subpage') then
			return mw.title.makeTitle(subjectSpace, title.baseText)
		else
			return mw.title.makeTitle(subjectSpace, title.text)
		end
	end

	function envFuncs.docTitle()
		--[[
		-- Title object of the /doc subpage.
		-- Messages:
		-- 'doc-subpage' --&gt; 'doc'
		--]]
		local title = env.title
		local docname = args[1] -- User-specified doc page.
		local docpage
		if docname then
			docpage = docname
		else
			docpage = env.docpageBase .. '/' .. message('doc-subpage')
		end
		return mw.title.new(docpage)
	end
	
	function envFuncs.sandboxTitle()
		--[[
		-- Title object for the /sandbox subpage.
		-- Messages:
		-- 'sandbox-subpage' --&gt; 'sandbox'
		--]]
		return mw.title.new(env.docpageBase .. '/' .. message('sandbox-subpage'))
	end
	
	function envFuncs.testcasesTitle()
		--[[
		-- Title object for the /testcases subpage.
		-- Messages:
		-- 'testcases-subpage' --&gt; 'testcases'
		--]]
		return mw.title.new(env.docpageBase .. '/' .. message('testcases-subpage'))
	end
	
	function envFuncs.printTitle()
		--[[
		-- Title object for the /Print subpage.
		-- Messages:
		-- 'print-subpage' --&gt; 'Print'
		--]]
		return env.templateTitle:subPageTitle(message('print-subpage'))
	end

	function envFuncs.protectionLevels()
		-- The protection levels table of the title object.
		return env.title.protectionLevels
	end

	function envFuncs.subjectSpace()
		-- The subject namespace number.
		return mw.site.namespaces[env.title.namespace].subject.id
	end

	function envFuncs.docSpace()
		-- The documentation namespace number. For most namespaces this is the same as the
		-- subject namespace. However, pages in the Article, File, MediaWiki or Category
		-- namespaces must have their /doc, /sandbox and /testcases pages in talk space.
		local subjectSpace = env.subjectSpace
		if subjectSpace == 0 or subjectSpace == 6 or subjectSpace == 8 or subjectSpace == 14 then
			return subjectSpace + 1
		else
			return subjectSpace
		end
	end

	function envFuncs.docpageBase()
		-- The base page of the /doc, /sandbox, and /testcases subpages.
		-- For some namespaces this is the talk page, rather than the template page.
		local templateTitle = env.templateTitle
		local docSpace = env.docSpace
		local docSpaceText = mw.site.namespaces[docSpace].name
		-- Assemble the link. docSpace is never the main namespace, so we can hardcode the colon.
		return docSpaceText .. ':' .. templateTitle.text
	end
	
	function envFuncs.compareUrl()
		-- Diff link between the sandbox and the main template using [[Khethekileko:ComparePages]].
		local templateTitle = env.templateTitle
		local sandboxTitle = env.sandboxTitle
		if templateTitle.exists and sandboxTitle.exists then
			local compareUrl = mw.uri.fullUrl(
				'Special:ComparePages',
				{page1 = templateTitle.prefixedText, page2 = sandboxTitle.prefixedText}
			)
			return tostring(compareUrl)
		else
			return nil
		end
	end		

	return env
end	

----------------------------------------------------------------------------
-- Auxiliary templates
----------------------------------------------------------------------------

function p.sandboxNotice(args, env)
	--[=[
	-- Generates a sandbox notice for display above sandbox pages.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	-- Messages:
	-- 'sandbox-notice-image' --&gt; '[[Isimumathi:Sandbox.svg|50px|alt=|link=]]'
	-- 'sandbox-notice-blurb' --&gt; 'This is the $1 for $2.'
	-- 'sandbox-notice-diff-blurb' --&gt; 'This is the $1 for $2 ($3).'
	-- 'sandbox-notice-pagetype-template' --&gt; '[[Wikipedia:Template test cases|template sandbox]] page'
	-- 'sandbox-notice-pagetype-module' --&gt; '[[Wikipedia:Template test cases|module sandbox]] page'
	-- 'sandbox-notice-pagetype-other' --&gt; 'sandbox page'
	-- 'sandbox-notice-compare-link-display' --&gt; 'diff'
	-- 'sandbox-notice-testcases-blurb' --&gt; 'See also the companion subpage for $1.'
	-- 'sandbox-notice-testcases-link-display' --&gt; 'test cases'
	-- 'sandbox-category' --&gt; 'Template sandboxes'
	--]=]
	local title = env.title
	local sandboxTitle = env.sandboxTitle
	local templateTitle = env.templateTitle
	local subjectSpace = env.subjectSpace
	if not (subjectSpace and title and sandboxTitle and templateTitle and mw.title.equals(title, sandboxTitle)) then
		return nil
	end
	-- Build the table of arguments to pass to {{ombox}}. We need just two fields, &quot;image&quot; and &quot;text&quot;.
	local omargs = {}
	omargs.image = message('sandbox-notice-image')
	-- Get the text. We start with the opening blurb, which is something like
	-- &quot;This is the template sandbox for [[Umhlahlandlelasakhiwo:Foo]] (diff).&quot;
	local text = ''
	local pagetype
	if subjectSpace == 10 then
		pagetype = message('sandbox-notice-pagetype-template')
	elseif subjectSpace == 828 then
		pagetype = message('sandbox-notice-pagetype-module')
	else
		pagetype = message('sandbox-notice-pagetype-other')
	end
	local templateLink = makeWikilink(templateTitle.prefixedText)
	local compareUrl = env.compareUrl
	if compareUrl then
		local compareDisplay = message('sandbox-notice-compare-link-display')
		local compareLink = makeUrlLink(compareUrl, compareDisplay)
		text = text .. message('sandbox-notice-diff-blurb', {pagetype, templateLink, compareLink})
	else
		text = text .. message('sandbox-notice-blurb', {pagetype, templateLink})
	end
	-- Get the test cases page blurb if the page exists. This is something like
	-- &quot;See also the companion subpage for [[Umhlahlandlelasakhiwo:Foo/testcases|test cases]].&quot;
	local testcasesTitle = env.testcasesTitle
	if testcasesTitle and testcasesTitle.exists then
		if testcasesTitle.namespace == mw.site.namespaces.Module.id then
			local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display')
			local testcasesRunLinkDisplay = message('sandbox-notice-testcases-run-link-display')
			local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay)
			local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay)
			text = text .. '&lt;br /&gt;' .. message('sandbox-notice-testcases-run-blurb', {testcasesLink, testcasesRunLink})
		else
			local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display')
			local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay)
			text = text .. '&lt;br /&gt;' .. message('sandbox-notice-testcases-blurb', {testcasesLink})
		end
	end
	-- Add the sandbox to the sandbox category.
	text = text .. makeCategoryLink(message('sandbox-category'))
	omargs.text = text
	local ret = '&lt;div style=&quot;clear: both;&quot;&gt;&lt;/div&gt;'
	ret = ret .. messageBox.main('ombox', omargs)
	return ret
end

function p.protectionTemplate(env)
	-- Generates the padlock icon in the top right.
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- Messages:
	-- 'protection-template' --&gt; 'pp-template'
	-- 'protection-template-args' --&gt; {docusage = 'yes'}
	local protectionLevels, mProtectionBanner
	local title = env.title
	protectionLevels = env.protectionLevels
	if not protectionLevels then
		return nil
	end
	local editProt = protectionLevels.edit and protectionLevels.edit[1]
	local moveProt = protectionLevels.move and protectionLevels.move[1]
	if editProt then
		-- The page is edit-protected.
		mProtectionBanner = require('Module:Protection banner')
		local reason = message('protection-reason-edit')
		return mProtectionBanner._main{reason, small = true}
	elseif moveProt and moveProt ~= 'autoconfirmed' then
		-- The page is move-protected but not edit-protected. Exclude move
		-- protection with the level &quot;autoconfirmed&quot;, as this is equivalent to
		-- no move protection at all.
		mProtectionBanner = require('Module:Protection banner')
		return mProtectionBanner._main{action = 'move', small = true}
	else
		return nil
	end
end

----------------------------------------------------------------------------
-- Start box
----------------------------------------------------------------------------

p.startBox = makeInvokeFunc('_startBox')

function p._startBox(args, env)
	--[[
	-- This function generates the start box.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	-- The actual work is done by p.makeStartBoxLinksData and p.renderStartBoxLinks which make
	-- the [view] [edit] [history] [purge] links, and by p.makeStartBoxData and p.renderStartBox
	-- which generate the box HTML.
	--]]
	env = env or p.getEnvironment(args)
	local links
	local content = args.content
	if not content then
		-- No need to include the links if the documentation is on the template page itself.
		local linksData = p.makeStartBoxLinksData(args, env)
		if linksData then
			links = p.renderStartBoxLinks(linksData)
		end
	end
	-- Generate the start box html.
	local data = p.makeStartBoxData(args, env, links)
	if data then
		return p.renderStartBox(data)
	else
		-- User specified no heading.
		return nil
	end
end

function p.makeStartBoxLinksData(args, env)
	--[[
	-- Does initial processing of data to make the [view] [edit] [history] [purge] links.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	-- Messages:
	-- 'view-link-display' --&gt; 'view'
	-- 'edit-link-display' --&gt; 'edit'
	-- 'history-link-display' --&gt; 'history'
	-- 'purge-link-display' --&gt; 'purge'
	-- 'file-docpage-preload' --&gt; 'Template:Documentation/preload-filespace'
	-- 'module-preload' --&gt; 'Template:Documentation/preload-module-doc'
	-- 'docpage-preload' --&gt; 'Template:Documentation/preload'
	-- 'create-link-display' --&gt; 'create'
	--]]
	local subjectSpace = env.subjectSpace
	local title = env.title
	local docTitle = env.docTitle
	if not title or not docTitle then
		return nil
	end

	local data = {}
	data.title = title
	data.docTitle = docTitle
	-- View, display, edit, and purge links if /doc exists.
	data.viewLinkDisplay = message('view-link-display')
	data.editLinkDisplay = message('edit-link-display')
	data.historyLinkDisplay = message('history-link-display')
	data.purgeLinkDisplay = message('purge-link-display')
	-- Create link if /doc doesn't exist.
	local preload = args.preload
	if not preload then
		if subjectSpace == 6 then -- File namespace
			preload = message('file-docpage-preload')
		elseif subjectSpace == 828 then -- Module namespace
			preload = message('module-preload')
		else
			preload = message('docpage-preload')
		end
	end
	data.preload = preload
	data.createLinkDisplay = message('create-link-display')
	return data
end

function p.renderStartBoxLinks(data)
	--[[
	-- Generates the [view][edit][history][purge] or [create] links from the data table.
	-- @data - a table of data generated by p.makeStartBoxLinksData
	--]]
	
	local function escapeBrackets(s)
		-- Escapes square brackets with HTML entities.
		s = s:gsub('%[', '&amp;#91;') -- Replace square brackets with HTML entities.
		s = s:gsub('%]', '&amp;#93;')
		return s
	end

	local ret
	local docTitle = data.docTitle
	local title = data.title
	if docTitle.exists then
		local viewLink = makeWikilink(docTitle.prefixedText, data.viewLinkDisplay)
		local editLink = makeUrlLink(docTitle:fullUrl{action = 'edit'}, data.editLinkDisplay)
		local historyLink = makeUrlLink(docTitle:fullUrl{action = 'history'}, data.historyLinkDisplay)
		local purgeLink = makeUrlLink(title:fullUrl{action = 'purge'}, data.purgeLinkDisplay)
		ret = '[%s] [%s] [%s] [%s]'
		ret = escapeBrackets(ret)
		ret = mw.ustring.format(ret, viewLink, editLink, historyLink, purgeLink)
	else
		local createLink = makeUrlLink(docTitle:fullUrl{action = 'edit', preload = data.preload}, data.createLinkDisplay)
		ret = '[%s]'
		ret = escapeBrackets(ret)
		ret = mw.ustring.format(ret, createLink)
	end
	return ret
end

function p.makeStartBoxData(args, env, links)
	--[=[
	-- Does initial processing of data to pass to the start-box render function, p.renderStartBox.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- @links - a string containing the [view][edit][history][purge] links - could be nil if there's an error.
	--
	-- Messages:
	-- 'documentation-icon-wikitext' --&gt; '[[Isimumathi:Test Template Info-Icon - Version (2).svg|50px|link=|alt=]]'
	-- 'template-namespace-heading' --&gt; 'Template documentation'
	-- 'module-namespace-heading' --&gt; 'Module documentation'
	-- 'file-namespace-heading' --&gt; 'Summary'
	-- 'other-namespaces-heading' --&gt; 'Documentation'
	-- 'start-box-linkclasses' --&gt; 'mw-editsection-like plainlinks'
	-- 'start-box-link-id' --&gt; 'doc_editlinks'
	-- 'testcases-create-link-display' --&gt; 'create'
	--]=]
	local subjectSpace = env.subjectSpace
	if not subjectSpace then
		-- Default to an &quot;other namespaces&quot; namespace, so that we get at least some output
		-- if an error occurs.
		subjectSpace = 2
	end
	local data = {}
	
	-- Heading
	local heading = args.heading -- Blank values are not removed.
	if heading == '' then
		-- Don't display the start box if the heading arg is defined but blank.
		return nil
	end
	if heading then
		data.heading = heading
	elseif subjectSpace == 10 then -- Template namespace
		data.heading = message('documentation-icon-wikitext') .. ' ' .. message('template-namespace-heading')
	elseif subjectSpace == 828 then -- Module namespace
		data.heading = message('documentation-icon-wikitext') .. ' ' .. message('module-namespace-heading')
	elseif subjectSpace == 6 then -- File namespace
		data.heading = message('file-namespace-heading')
	else
		data.heading = message('other-namespaces-heading')
	end
	
	-- Heading CSS
	local headingStyle = args['heading-style']
	if headingStyle then
		data.headingStyleText = headingStyle
	elseif subjectSpace == 10 then
		-- We are in the template or template talk namespaces.
		data.headingFontWeight = 'bold'
		data.headingFontSize = '125%'
	else
		data.headingFontSize = '150%'
	end
	
	-- Data for the [view][edit][history][purge] or [create] links.
	if links then
		data.linksClass = message('start-box-linkclasses')
		data.linksId = message('start-box-link-id')
		data.links = links
	end
	
	return data
end

function p.renderStartBox(data)
	-- Renders the start box html.
	-- @data - a table of data generated by p.makeStartBoxData.
	local sbox = mw.html.create('div')
	sbox
		:css('padding-bottom', '3px')
		:css('border-bottom', '1px solid #aaa')
		:css('margin-bottom', '1ex')
		:newline()
		:tag('span')
			:cssText(data.headingStyleText)
			:css('font-weight', data.headingFontWeight)
			:css('font-size', data.headingFontSize)
			:wikitext(data.heading)
	local links = data.links
	if links then
		sbox:tag('span')
			:addClass(data.linksClass)
			:attr('id', data.linksId)
			:wikitext(links)
	end
	return tostring(sbox)
end

----------------------------------------------------------------------------
-- Documentation content
----------------------------------------------------------------------------

p.content = makeInvokeFunc('_content')

function p._content(args, env)
	-- Displays the documentation contents
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	env = env or p.getEnvironment(args)
	local docTitle = env.docTitle
	local content = args.content
	if not content and docTitle and docTitle.exists then
		content = args._content or mw.getCurrentFrame():expandTemplate{title = docTitle.prefixedText}
	end
	-- The line breaks below are necessary so that &quot;=== Headings ===&quot; at the start and end
	-- of docs are interpreted correctly.
	return '\n' .. (content or '') .. '\n' 
end

p.contentTitle = makeInvokeFunc('_contentTitle')

function p._contentTitle(args, env)
	env = env or p.getEnvironment(args)
	local docTitle = env.docTitle
	if not args.content and docTitle and docTitle.exists then
		return docTitle.prefixedText
	else
		return ''
	end
end

----------------------------------------------------------------------------
-- End box
----------------------------------------------------------------------------

p.endBox = makeInvokeFunc('_endBox')

function p._endBox(args, env)
	--[=[
	-- This function generates the end box (also known as the link box).
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	-- Messages:
	-- 'fmbox-id' --&gt; 'documentation-meta-data'
	-- 'fmbox-style' --&gt; 'background-color: #ecfcf4'
	-- 'fmbox-textstyle' --&gt; 'font-style: italic'
	-- 
	-- The HTML is generated by the {{fmbox}} template, courtesy of [[Module:Message box]].
	--]=]
	
	-- Get environment data.
	env = env or p.getEnvironment(args)
	local subjectSpace = env.subjectSpace
	local docTitle = env.docTitle
	if not subjectSpace or not docTitle then
		return nil
	end
		
	-- Check whether we should output the end box at all. Add the end
	-- box by default if the documentation exists or if we are in the
	-- user, module or template namespaces.
	local linkBox = args['link box']
	if linkBox == 'off'
		or not (
			docTitle.exists
			or subjectSpace == 2
			or subjectSpace == 828
			or subjectSpace == 10
		)
	then
		return nil
	end

	-- Assemble the arguments for {{fmbox}}.
	local fmargs = {}
	fmargs.id = message('fmbox-id') -- Sets 'documentation-meta-data'
	fmargs.image = 'none'
	fmargs.style = message('fmbox-style') -- Sets 'background-color: #ecfcf4'
	fmargs.textstyle = message('fmbox-textstyle') -- 'font-style: italic;'

	-- Assemble the fmbox text field.
	local text = ''
	if linkBox then
		text = text .. linkBox
	else
		text = text .. (p.makeDocPageBlurb(args, env) or '') -- &quot;This documentation is transcluded from [[Foo]].&quot; 
		if subjectSpace == 2 or subjectSpace == 10 or subjectSpace == 828 then
			-- We are in the user, template or module namespaces.
			-- Add sandbox and testcases links.
			-- &quot;Editors can experiment in this template's sandbox and testcases pages.&quot;
			text = text .. (p.makeExperimentBlurb(args, env) or '')
			text = text .. '&lt;br /&gt;'
			if not args.content and not args[1] then
				-- &quot;Please add categories to the /doc subpage.&quot;
				-- Don't show this message with inline docs or with an explicitly specified doc page,
				-- as then it is unclear where to add the categories.
				text = text .. (p.makeCategoriesBlurb(args, env) or '')
			end
			text = text .. ' ' .. (p.makeSubpagesBlurb(args, env) or '') --&quot;Subpages of this template&quot;
			local printBlurb = p.makePrintBlurb(args, env) -- Two-line blurb about print versions of templates.
			if printBlurb then
				text = text .. '&lt;br /&gt;' .. printBlurb
			end
		end
	end
	fmargs.text = text

	return messageBox.main('fmbox', fmargs)
end

function p.makeDocPageBlurb(args, env)
	--[=[
	-- Makes the blurb &quot;This documentation is transcluded from [[Umhlahlandlelasakhiwo:Foo]] (edit, history)&quot;.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	-- Messages:
	-- 'edit-link-display' --&gt; 'edit'
	-- 'history-link-display' --&gt; 'history'
	-- 'transcluded-from-blurb' --&gt; 
	-- 'The above [[Wikipedia:Template documentation|documentation]] 
	-- is [[Wikipedia:Transclusion|transcluded]] from $1.'
	-- 'module-preload' --&gt; 'Template:Documentation/preload-module-doc'
	-- 'create-link-display' --&gt; 'create'
	-- 'create-module-doc-blurb' --&gt;
	-- 'You might want to $1 a documentation page for this [[Wikipedia:Lua|Scribunto module]].'
	--]=]
	local docTitle = env.docTitle
	if not docTitle then
		return nil
	end
	local ret
	if docTitle.exists then
		-- /doc exists; link to it.
		local docLink = makeWikilink(docTitle.prefixedText)
		local editUrl = docTitle:fullUrl{action = 'edit'}
		local editDisplay = message('edit-link-display')
		local editLink = makeUrlLink(editUrl, editDisplay)
		local historyUrl = docTitle:fullUrl{action = 'history'}
		local historyDisplay = message('history-link-display')
		local historyLink = makeUrlLink(historyUrl, historyDisplay)
		ret = message('transcluded-from-blurb', {docLink})
			.. ' '
			.. makeToolbar(editLink, historyLink)
			.. '&lt;br /&gt;'
	elseif env.subjectSpace == 828 then
		-- /doc does not exist; ask to create it.
		local createUrl = docTitle:fullUrl{action = 'edit', preload = message('module-preload')}
		local createDisplay = message('create-link-display')
		local createLink = makeUrlLink(createUrl, createDisplay)
		ret = message('create-module-doc-blurb', {createLink})
			.. '&lt;br /&gt;'
	end
	return ret
end

function p.makeExperimentBlurb(args, env)
	--[[
	-- Renders the text &quot;Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages.&quot;
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	-- Messages:
	-- 'sandbox-link-display' --&gt; 'sandbox'
	-- 'sandbox-edit-link-display' --&gt; 'edit'
	-- 'compare-link-display' --&gt; 'diff'
	-- 'module-sandbox-preload' --&gt; 'Template:Documentation/preload-module-sandbox'
	-- 'template-sandbox-preload' --&gt; 'Template:Documentation/preload-sandbox'
	-- 'sandbox-create-link-display' --&gt; 'create'
	-- 'mirror-edit-summary' --&gt; 'Create sandbox version of $1'
	-- 'mirror-link-display' --&gt; 'mirror'
	-- 'mirror-link-preload' --&gt; 'Template:Documentation/mirror'
	-- 'sandbox-link-display' --&gt; 'sandbox'
	-- 'testcases-link-display' --&gt; 'testcases'
	-- 'testcases-edit-link-display'--&gt; 'edit'
	-- 'template-sandbox-preload' --&gt; 'Template:Documentation/preload-sandbox'
	-- 'testcases-create-link-display' --&gt; 'create'
	-- 'testcases-link-display' --&gt; 'testcases'
	-- 'testcases-edit-link-display' --&gt; 'edit'
	-- 'module-testcases-preload' --&gt; 'Template:Documentation/preload-module-testcases'
	-- 'template-testcases-preload' --&gt; 'Template:Documentation/preload-testcases'
	-- 'experiment-blurb-module' --&gt; 'Editors can experiment in this module's $1 and $2 pages.'
	-- 'experiment-blurb-template' --&gt; 'Editors can experiment in this template's $1 and $2 pages.'
	--]]
	local subjectSpace = env.subjectSpace
	local templateTitle = env.templateTitle
	local sandboxTitle = env.sandboxTitle
	local testcasesTitle = env.testcasesTitle
	local templatePage = templateTitle.prefixedText
	if not subjectSpace or not templateTitle or not sandboxTitle or not testcasesTitle then
		return nil
	end
	-- Make links.
	local sandboxLinks, testcasesLinks
	if sandboxTitle.exists then
		local sandboxPage = sandboxTitle.prefixedText
		local sandboxDisplay = message('sandbox-link-display')
		local sandboxLink = makeWikilink(sandboxPage, sandboxDisplay)
		local sandboxEditUrl = sandboxTitle:fullUrl{action = 'edit'}
		local sandboxEditDisplay = message('sandbox-edit-link-display')
		local sandboxEditLink = makeUrlLink(sandboxEditUrl, sandboxEditDisplay)
		local compareUrl = env.compareUrl
		local compareLink
		if compareUrl then
			local compareDisplay = message('compare-link-display')
			compareLink = makeUrlLink(compareUrl, compareDisplay)
		end
		sandboxLinks = sandboxLink .. ' ' .. makeToolbar(sandboxEditLink, compareLink)
	else
		local sandboxPreload
		if subjectSpace == 828 then
			sandboxPreload = message('module-sandbox-preload')
		else
			sandboxPreload = message('template-sandbox-preload')
		end
		local sandboxCreateUrl = sandboxTitle:fullUrl{action = 'edit', preload = sandboxPreload}
		local sandboxCreateDisplay = message('sandbox-create-link-display')
		local sandboxCreateLink = makeUrlLink(sandboxCreateUrl, sandboxCreateDisplay)
		local mirrorSummary = message('mirror-edit-summary', {makeWikilink(templatePage)})
		local mirrorPreload = message('mirror-link-preload')
		local mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = mirrorPreload, summary = mirrorSummary}
		if subjectSpace == 828 then
			mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = templateTitle.prefixedText, summary = mirrorSummary}
		end
		local mirrorDisplay = message('mirror-link-display')
		local mirrorLink = makeUrlLink(mirrorUrl, mirrorDisplay)
		sandboxLinks = message('sandbox-link-display') .. ' ' .. makeToolbar(sandboxCreateLink, mirrorLink)
	end
	if testcasesTitle.exists then
		local testcasesPage = testcasesTitle.prefixedText
		local testcasesDisplay = message('testcases-link-display')
		local testcasesLink = makeWikilink(testcasesPage, testcasesDisplay)
		local testcasesEditUrl = testcasesTitle:fullUrl{action = 'edit'}
		local testcasesEditDisplay = message('testcases-edit-link-display')
		local testcasesEditLink = makeUrlLink(testcasesEditUrl, testcasesEditDisplay)
		-- for Modules, add testcases run link if exists
		if subjectSpace == 828 and testcasesTitle.talkPageTitle and testcasesTitle.talkPageTitle.exists then
			local testcasesRunLinkDisplay = message('testcases-run-link-display')
			local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay)
			testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink, testcasesRunLink)
		else
			testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink)
		end
	else
		local testcasesPreload
		if subjectSpace == 828 then
			testcasesPreload = message('module-testcases-preload')
		else
			testcasesPreload = message('template-testcases-preload')
		end
		local testcasesCreateUrl = testcasesTitle:fullUrl{action = 'edit', preload = testcasesPreload}
		local testcasesCreateDisplay = message('testcases-create-link-display')
		local testcasesCreateLink = makeUrlLink(testcasesCreateUrl, testcasesCreateDisplay)
		testcasesLinks = message('testcases-link-display') .. ' ' .. makeToolbar(testcasesCreateLink)
	end
	local messageName
	if subjectSpace == 828 then
		messageName = 'experiment-blurb-module'
	else
		messageName = 'experiment-blurb-template'
	end
	return message(messageName, {sandboxLinks, testcasesLinks})
end

function p.makeCategoriesBlurb(args, env)
	--[[
	-- Generates the text &quot;Please add categories to the /doc subpage.&quot;
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- Messages:
	-- 'doc-link-display' --&gt; '/doc'
	-- 'add-categories-blurb' --&gt; 'Please add categories to the $1 subpage.'
	--]]
	local docTitle = env.docTitle
	if not docTitle then
		return nil
	end
	local docPathLink = makeWikilink(docTitle.prefixedText, message('doc-link-display'))
	return message('add-categories-blurb', {docPathLink})
end

function p.makeSubpagesBlurb(args, env)
	--[[
	-- Generates the &quot;Subpages of this template&quot; link.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	
	-- Messages:
	-- 'template-pagetype' --&gt; 'template'
	-- 'module-pagetype' --&gt; 'module'
	-- 'default-pagetype' --&gt; 'page'
	-- 'subpages-link-display' --&gt; 'Subpages of this $1'
	--]]
	local subjectSpace = env.subjectSpace
	local templateTitle = env.templateTitle
	if not subjectSpace or not templateTitle then
		return nil
	end
	local pagetype
	if subjectSpace == 10 then
		pagetype = message('template-pagetype')
	elseif subjectSpace == 828 then
		pagetype = message('module-pagetype')
	else
		pagetype = message('default-pagetype')
	end
	local subpagesLink = makeWikilink(
		'Special:PrefixIndex/' .. templateTitle.prefixedText .. '/',
		message('subpages-link-display', {pagetype})
	)
	return message('subpages-blurb', {subpagesLink})
end

function p.makePrintBlurb(args, env)
	--[=[
	-- Generates the blurb displayed when there is a print version of the template available.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	--
	-- Messages:
	-- 'print-link-display' --&gt; '/Print'
	-- 'print-blurb' --&gt; 'A [[Lisizo:Books/for experts#Improving the book layout|print version]]'
	--		.. ' of this template exists at $1.'
	--		.. ' If you make a change to this template, please update the print version as well.'
	-- 'display-print-category' --&gt; true
	-- 'print-category' --&gt; 'Templates with print versions'
	--]=]
	local printTitle = env.printTitle
	if not printTitle then
		return nil
	end
	local ret
	if printTitle.exists then
		local printLink = makeWikilink(printTitle.prefixedText, message('print-link-display'))
		ret = message('print-blurb', {printLink})
		local displayPrintCategory = message('display-print-category', nil, 'boolean')
		if displayPrintCategory then
			ret = ret .. makeCategoryLink(message('print-category'))
		end
	end
	return ret
end

----------------------------------------------------------------------------
-- Tracking categories
----------------------------------------------------------------------------

function p.addTrackingCategories(env)
	--[[
	-- Check if {{documentation}} is transcluded on a /doc or /testcases page.
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	
	-- Messages:
	-- 'display-strange-usage-category' --&gt; true
	-- 'doc-subpage' --&gt; 'doc'
	-- 'testcases-subpage' --&gt; 'testcases'
	-- 'strange-usage-category' --&gt; 'Wikipedia pages with strange ((documentation)) usage'
	-- 
	-- /testcases pages in the module namespace are not categorised, as they may have
	-- {{documentation}} transcluded automatically.
	--]]
	local title = env.title
	local subjectSpace = env.subjectSpace
	if not title or not subjectSpace then
		return nil
	end
	local subpage = title.subpageText
	local ret = ''
	if message('display-strange-usage-category', nil, 'boolean')
		and (
			subpage == message('doc-subpage')
			or subjectSpace ~= 828 and subpage == message('testcases-subpage')
		)
	then
		ret = ret .. makeCategoryLink(message('strange-usage-category'))
	end
	return ret
end

return p</text>
      <sha1>aigdgnmr62bny2nwfvzvi5sfbsnl1vr</sha1>
    </revision>
    <revision>
      <id>439</id>
      <parentid>438</parentid>
      <timestamp>2019-01-13T17:35:31Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>439</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="36745" sha1="i3ff5q5mxg9bllt9q4gv730dfg5b9ie" xml:space="preserve">-- This module implements {{documentation}}.

-- Get required modules.
local getArgs = require('Module:Arguments').getArgs
local messageBox = require('Module:Message box')

-- Get the config table.
local cfg = mw.loadData('Module:Documentation/config')

local p = {}

-- Often-used functions.
local ugsub = mw.ustring.gsub

----------------------------------------------------------------------------
-- Helper functions
--
-- These are defined as local functions, but are made available in the p
-- table for testing purposes.
----------------------------------------------------------------------------

local function message(cfgKey, valArray, expectType)
	--[[
	-- Gets a message from the cfg table and formats it if appropriate.
	-- The function raises an error if the value from the cfg table is not
	-- of the type expectType. The default type for expectType is 'string'.
	-- If the table valArray is present, strings such as $1, $2 etc. in the
	-- message are substituted with values from the table keys [1], [2] etc.
	-- For example, if the message &quot;foo-message&quot; had the value 'Foo $2 bar $1.',
	-- message('foo-message', {'baz', 'qux'}) would return &quot;Foo qux bar baz.&quot;
	--]]
	local msg = cfg[cfgKey]
	expectType = expectType or 'string'
	if type(msg) ~= expectType then
		error('message: type error in message cfg.' .. cfgKey .. ' (' .. expectType .. ' expected, got ' .. type(msg) .. ')', 2)
	end
	if not valArray then
		return msg
	end

	local function getMessageVal(match)
		match = tonumber(match)
		return valArray[match] or error('message: no value found for key $' .. match .. ' in message cfg.' .. cfgKey, 4)
	end

	local ret = ugsub(msg, '$([1-9][0-9]*)', getMessageVal)
	return ret
end

p.message = message

local function makeWikilink(page, display)
	if display then
		return mw.ustring.format('[[|%s|%s]]', page, display)
	else
		return mw.ustring.format('[[|%s]]', page)
	end
end

p.makeWikilink = makeWikilink

local function makeCategoryLink(cat, sort)
	local catns = mw.site.namespaces[14].name
	return makeWikilink(catns .. ':' .. cat, sort)
end

p.makeCategoryLink = makeCategoryLink

local function makeUrlLink(url, display)
	return mw.ustring.format('[%s %s]', url, display)
end

p.makeUrlLink = makeUrlLink

local function makeToolbar(...)
	local ret = {}
	local lim = select('#', ...)
	if lim &lt; 1 then
		return nil
	end
	for i = 1, lim do
		ret[#ret + 1] = select(i, ...)
	end
	return '&lt;small style=&quot;font-style: normal;&quot;&gt;(' .. table.concat(ret, ' &amp;#124; ') .. ')&lt;/small&gt;'
end	

p.makeToolbar = makeToolbar

----------------------------------------------------------------------------
-- Argument processing
----------------------------------------------------------------------------

local function makeInvokeFunc(funcName)
	return function (frame)
		local args = getArgs(frame, {
			valueFunc = function (key, value)
				if type(value) == 'string' then
					value = value:match('^%s*(.-)%s*$') -- Remove whitespace.
					if key == 'heading' or value ~= '' then
						return value
					else
						return nil
					end
				else
					return value
				end
			end
		})
		return p[funcName](args)
	end
end

----------------------------------------------------------------------------
-- Main function
----------------------------------------------------------------------------

p.main = makeInvokeFunc('_main')

function p._main(args)
	--[[
	-- This function defines logic flow for the module.
	-- @args - table of arguments passed by the user
	-- 
	-- Messages:
	-- 'main-div-id' --&gt; 'template-documentation'
	-- 'main-div-classes' --&gt; 'template-documentation iezoomfix'
	--]]
	local env = p.getEnvironment(args)
	local root = mw.html.create()
	root
		:wikitext(p.protectionTemplate(env))
		:wikitext(p.sandboxNotice(args, env))
		 -- This div tag is from {{documentation/start box}}, but moving it here
		 -- so that we don't have to worry about unclosed tags.
		:tag('div')
			:attr('id', message('main-div-id'))
			:addClass(message('main-div-classes'))
			:newline()
			:wikitext(p._startBox(args, env))
			:wikitext(p._content(args, env))
			:tag('div')
				:css('clear', 'both') -- So right or left floating items don't stick out of the doc box.
				:newline()
				:done()
			:done()
		:wikitext(p._endBox(args, env))
		:wikitext(p.addTrackingCategories(env))
	return tostring(root)
end

----------------------------------------------------------------------------
-- Environment settings
----------------------------------------------------------------------------

function p.getEnvironment(args)
	--[[
	-- Returns a table with information about the environment, including title objects and other namespace- or
	-- path-related data.
	-- @args - table of arguments passed by the user
	--
	-- Title objects include:
	-- env.title - the page we are making documentation for (usually the current title)
	-- env.templateTitle - the template (or module, file, etc.)
	-- env.docTitle - the /doc subpage.
	-- env.sandboxTitle - the /sandbox subpage.
	-- env.testcasesTitle - the /testcases subpage.
	-- env.printTitle - the print version of the template, located at the /Print subpage.
	--
	-- Data includes:
	-- env.protectionLevels - the protection levels table of the title object.
	-- env.subjectSpace - the number of the title's subject namespace.
	-- env.docSpace - the number of the namespace the title puts its documentation in.
	-- env.docpageBase - the text of the base page of the /doc, /sandbox and /testcases pages, with namespace.
	-- env.compareUrl - URL of the Special:ComparePages page comparing the sandbox with the template.
	-- 
	-- All table lookups are passed through pcall so that errors are caught. If an error occurs, the value
	-- returned will be nil.
	--]]
	
	local env, envFuncs = {}, {}

	-- Set up the metatable. If triggered we call the corresponding function in the envFuncs table. The value
	-- returned by that function is memoized in the env table so that we don't call any of the functions
	-- more than once. (Nils won't be memoized.)
	setmetatable(env, {
		__index = function (t, key)
			local envFunc = envFuncs[key]
			if envFunc then
				local success, val = pcall(envFunc)
				if success then
					env[key] = val -- Memoise the value.
					return val
				end
			end
			return nil
		end
	})	

	function envFuncs.title()
		-- The title object for the current page, or a test page passed with args.page.
		local title
		local titleArg = args.page
		if titleArg then
			title = mw.title.new(titleArg)
		else
			title = mw.title.getCurrentTitle()
		end
		return title
	end

	function envFuncs.templateTitle()
		--[[
		-- The template (or module, etc.) title object.
		-- Messages:
		-- 'sandbox-subpage' --&gt; 'sandbox'
		-- 'testcases-subpage' --&gt; 'testcases'
		--]]
		local subjectSpace = env.subjectSpace
		local title = env.title
		local subpage = title.subpageText
		if subpage == message('sandbox-subpage') or subpage == message('testcases-subpage') then
			return mw.title.makeTitle(subjectSpace, title.baseText)
		else
			return mw.title.makeTitle(subjectSpace, title.text)
		end
	end

	function envFuncs.docTitle()
		--[[
		-- Title object of the /doc subpage.
		-- Messages:
		-- 'doc-subpage' --&gt; 'doc'
		--]]
		local title = env.title
		local docname = args[1] -- User-specified doc page.
		local docpage
		if docname then
			docpage = docname
		else
			docpage = env.docpageBase .. '/' .. message('doc-subpage')
		end
		return mw.title.new(docpage)
	end
	
	function envFuncs.sandboxTitle()
		--[[
		-- Title object for the /sandbox subpage.
		-- Messages:
		-- 'sandbox-subpage' --&gt; 'sandbox'
		--]]
		return mw.title.new(env.docpageBase .. '/' .. message('sandbox-subpage'))
	end
	
	function envFuncs.testcasesTitle()
		--[[
		-- Title object for the /testcases subpage.
		-- Messages:
		-- 'testcases-subpage' --&gt; 'testcases'
		--]]
		return mw.title.new(env.docpageBase .. '/' .. message('testcases-subpage'))
	end
	
	function envFuncs.printTitle()
		--[[
		-- Title object for the /Print subpage.
		-- Messages:
		-- 'print-subpage' --&gt; 'Print'
		--]]
		return env.templateTitle:subPageTitle(message('print-subpage'))
	end

	function envFuncs.protectionLevels()
		-- The protection levels table of the title object.
		return env.title.protectionLevels
	end

	function envFuncs.subjectSpace()
		-- The subject namespace number.
		return mw.site.namespaces[env.title.namespace].subject.id
	end

	function envFuncs.docSpace()
		-- The documentation namespace number. For most namespaces this is the same as the
		-- subject namespace. However, pages in the Article, File, MediaWiki or Category
		-- namespaces must have their /doc, /sandbox and /testcases pages in talk space.
		local subjectSpace = env.subjectSpace
		if subjectSpace == 0 or subjectSpace == 6 or subjectSpace == 8 or subjectSpace == 14 then
			return subjectSpace + 1
		else
			return subjectSpace
		end
	end

	function envFuncs.docpageBase()
		-- The base page of the /doc, /sandbox, and /testcases subpages.
		-- For some namespaces this is the talk page, rather than the template page.
		local templateTitle = env.templateTitle
		local docSpace = env.docSpace
		local docSpaceText = mw.site.namespaces[docSpace].name
		-- Assemble the link. docSpace is never the main namespace, so we can hardcode the colon.
		return docSpaceText .. ':' .. templateTitle.text
	end
	
	function envFuncs.compareUrl()
		-- Diff link between the sandbox and the main template using [[Khethekileko:ComparePages]].
		local templateTitle = env.templateTitle
		local sandboxTitle = env.sandboxTitle
		if templateTitle.exists and sandboxTitle.exists then
			local compareUrl = mw.uri.fullUrl(
				'Special:ComparePages',
				{page1 = templateTitle.prefixedText, page2 = sandboxTitle.prefixedText}
			)
			return tostring(compareUrl)
		else
			return nil
		end
	end		

	return env
end	

----------------------------------------------------------------------------
-- Auxiliary templates
----------------------------------------------------------------------------

function p.sandboxNotice(args, env)
	--[=[
	-- Generates a sandbox notice for display above sandbox pages.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	-- Messages:
	-- 'sandbox-notice-image' --&gt; '[[Isimumathi:Sandbox.svg|50px|alt=|link=]]'
	-- 'sandbox-notice-blurb' --&gt; 'This is the $1 for $2.'
	-- 'sandbox-notice-diff-blurb' --&gt; 'This is the $1 for $2 ($3).'
	-- 'sandbox-notice-pagetype-template' --&gt; '[[Wikipedia:Template test cases|template sandbox]] page'
	-- 'sandbox-notice-pagetype-module' --&gt; '[[Wikipedia:Template test cases|module sandbox]] page'
	-- 'sandbox-notice-pagetype-other' --&gt; 'sandbox page'
	-- 'sandbox-notice-compare-link-display' --&gt; 'diff'
	-- 'sandbox-notice-testcases-blurb' --&gt; 'See also the companion subpage for $1.'
	-- 'sandbox-notice-testcases-link-display' --&gt; 'test cases'
	-- 'sandbox-category' --&gt; 'Template sandboxes'
	--]=]
	local title = env.title
	local sandboxTitle = env.sandboxTitle
	local templateTitle = env.templateTitle
	local subjectSpace = env.subjectSpace
	if not (subjectSpace and title and sandboxTitle and templateTitle and mw.title.equals(title, sandboxTitle)) then
		return nil
	end
	-- Build the table of arguments to pass to {{ombox}}. We need just two fields, &quot;image&quot; and &quot;text&quot;.
	local omargs = {}
	omargs.image = message('sandbox-notice-image')
	-- Get the text. We start with the opening blurb, which is something like
	-- &quot;This is the template sandbox for [[Umhlahlandlelasakhiwo:Foo]] (diff).&quot;
	local text = ''
	local pagetype
	if subjectSpace == 10 then
		pagetype = message('sandbox-notice-pagetype-template')
	elseif subjectSpace == 828 then
		pagetype = message('sandbox-notice-pagetype-module')
	else
		pagetype = message('sandbox-notice-pagetype-other')
	end
	local templateLink = makeWikilink(templateTitle.prefixedText)
	local compareUrl = env.compareUrl
	if compareUrl then
		local compareDisplay = message('sandbox-notice-compare-link-display')
		local compareLink = makeUrlLink(compareUrl, compareDisplay)
		text = text .. message('sandbox-notice-diff-blurb', {pagetype, templateLink, compareLink})
	else
		text = text .. message('sandbox-notice-blurb', {pagetype, templateLink})
	end
	-- Get the test cases page blurb if the page exists. This is something like
	-- &quot;See also the companion subpage for [[Umhlahlandlelasakhiwo:Foo/testcases|test cases]].&quot;
	local testcasesTitle = env.testcasesTitle
	if testcasesTitle and testcasesTitle.exists then
		if testcasesTitle.namespace == mw.site.namespaces.Module.id then
			local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display')
			local testcasesRunLinkDisplay = message('sandbox-notice-testcases-run-link-display')
			local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay)
			local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay)
			text = text .. '&lt;br /&gt;' .. message('sandbox-notice-testcases-run-blurb', {testcasesLink, testcasesRunLink})
		else
			local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display')
			local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay)
			text = text .. '&lt;br /&gt;' .. message('sandbox-notice-testcases-blurb', {testcasesLink})
		end
	end
	-- Add the sandbox to the sandbox category.
	text = text .. makeCategoryLink(message('sandbox-category'))
	omargs.text = text
	local ret = '&lt;div style=&quot;clear: both;&quot;&gt;&lt;/div&gt;'
	ret = ret .. messageBox.main('ombox', omargs)
	return ret
end

function p.protectionTemplate(env)
	-- Generates the padlock icon in the top right.
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- Messages:
	-- 'protection-template' --&gt; 'pp-template'
	-- 'protection-template-args' --&gt; {docusage = 'yes'}
	local protectionLevels, mProtectionBanner
	local title = env.title
	protectionLevels = env.protectionLevels
	if not protectionLevels then
		return nil
	end
	local editProt = protectionLevels.edit and protectionLevels.edit[1]
	local moveProt = protectionLevels.move and protectionLevels.move[1]
	if editProt then
		-- The page is edit-protected.
		mProtectionBanner = require('Module:Protection banner')
		local reason = message('protection-reason-edit')
		return mProtectionBanner._main{reason, small = true}
	elseif moveProt and moveProt ~= 'autoconfirmed' then
		-- The page is move-protected but not edit-protected. Exclude move
		-- protection with the level &quot;autoconfirmed&quot;, as this is equivalent to
		-- no move protection at all.
		mProtectionBanner = require('Module:Protection banner')
		return mProtectionBanner._main{action = 'move', small = true}
	else
		return nil
	end
end

----------------------------------------------------------------------------
-- Start box
----------------------------------------------------------------------------

p.startBox = makeInvokeFunc('_startBox')

function p._startBox(args, env)
	--[[
	-- This function generates the start box.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	-- The actual work is done by p.makeStartBoxLinksData and p.renderStartBoxLinks which make
	-- the [view] [edit] [history] [purge] links, and by p.makeStartBoxData and p.renderStartBox
	-- which generate the box HTML.
	--]]
	env = env or p.getEnvironment(args)
	local links
	local content = args.content
	if not content then
		-- No need to include the links if the documentation is on the template page itself.
		local linksData = p.makeStartBoxLinksData(args, env)
		if linksData then
			links = p.renderStartBoxLinks(linksData)
		end
	end
	-- Generate the start box html.
	local data = p.makeStartBoxData(args, env, links)
	if data then
		return p.renderStartBox(data)
	else
		-- User specified no heading.
		return nil
	end
end

function p.makeStartBoxLinksData(args, env)
	--[[
	-- Does initial processing of data to make the [view] [edit] [history] [purge] links.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	-- Messages:
	-- 'view-link-display' --&gt; 'view'
	-- 'edit-link-display' --&gt; 'edit'
	-- 'history-link-display' --&gt; 'history'
	-- 'purge-link-display' --&gt; 'purge'
	-- 'file-docpage-preload' --&gt; 'Template:Documentation/preload-filespace'
	-- 'module-preload' --&gt; 'Template:Documentation/preload-module-doc'
	-- 'docpage-preload' --&gt; 'Template:Documentation/preload'
	-- 'create-link-display' --&gt; 'create'
	--]]
	local subjectSpace = env.subjectSpace
	local title = env.title
	local docTitle = env.docTitle
	if not title or not docTitle then
		return nil
	end

	local data = {}
	data.title = title
	data.docTitle = docTitle
	-- View, display, edit, and purge links if /doc exists.
	data.viewLinkDisplay = message('view-link-display')
	data.editLinkDisplay = message('edit-link-display')
	data.historyLinkDisplay = message('history-link-display')
	data.purgeLinkDisplay = message('purge-link-display')
	-- Create link if /doc doesn't exist.
	local preload = args.preload
	if not preload then
		if subjectSpace == 6 then -- File namespace
			preload = message('file-docpage-preload')
		elseif subjectSpace == 828 then -- Module namespace
			preload = message('module-preload')
		else
			preload = message('docpage-preload')
		end
	end
	data.preload = preload
	data.createLinkDisplay = message('create-link-display')
	return data
end

function p.renderStartBoxLinks(data)
	--[[
	-- Generates the [view][edit][history][purge] or [create] links from the data table.
	-- @data - a table of data generated by p.makeStartBoxLinksData
	--]]
	
	local function escapeBrackets(s)
		-- Escapes square brackets with HTML entities.
		s = s:gsub('%[', '&amp;#91;') -- Replace square brackets with HTML entities.
		s = s:gsub('%]', '&amp;#93;')
		return s
	end

	local ret
	local docTitle = data.docTitle
	local title = data.title
	if docTitle.exists then
		local viewLink = makeWikilink(docTitle.prefixedText, data.viewLinkDisplay)
		local editLink = makeUrlLink(docTitle:fullUrl{action = 'edit'}, data.editLinkDisplay)
		local historyLink = makeUrlLink(docTitle:fullUrl{action = 'history'}, data.historyLinkDisplay)
		local purgeLink = makeUrlLink(title:fullUrl{action = 'purge'}, data.purgeLinkDisplay)
		ret = '[%s] [%s] [%s] [%s]'
		ret = escapeBrackets(ret)
		ret = mw.ustring.format(ret, viewLink, editLink, historyLink, purgeLink)
	else
		local createLink = makeUrlLink(docTitle:fullUrl{action = 'edit', preload = data.preload}, data.createLinkDisplay)
		ret = '[%s]'
		ret = escapeBrackets(ret)
		ret = mw.ustring.format(ret, createLink)
	end
	return ret
end

function p.makeStartBoxData(args, env, links)
	--[=[
	-- Does initial processing of data to pass to the start-box render function, p.renderStartBox.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- @links - a string containing the [view][edit][history][purge] links - could be nil if there's an error.
	--
	-- Messages:
	-- 'documentation-icon-wikitext' --&gt; '[[Isimumathi:Test Template Info-Icon - Version (2).svg|50px|link=|alt=]]'
	-- 'template-namespace-heading' --&gt; 'Template documentation'
	-- 'module-namespace-heading' --&gt; 'Module documentation'
	-- 'file-namespace-heading' --&gt; 'Summary'
	-- 'other-namespaces-heading' --&gt; 'Documentation'
	-- 'start-box-linkclasses' --&gt; 'mw-editsection-like plainlinks'
	-- 'start-box-link-id' --&gt; 'doc_editlinks'
	-- 'testcases-create-link-display' --&gt; 'create'
	--]=]
	local subjectSpace = env.subjectSpace
	if not subjectSpace then
		-- Default to an &quot;other namespaces&quot; namespace, so that we get at least some output
		-- if an error occurs.
		subjectSpace = 2
	end
	local data = {}
	
	-- Heading
	local heading = args.heading -- Blank values are not removed.
	if heading == '' then
		-- Don't display the start box if the heading arg is defined but blank.
		return nil
	end
	if heading then
		data.heading = heading
	elseif subjectSpace == 10 then -- Template namespace
		data.heading = message('documentation-icon-wikitext') .. ' ' .. message('template-namespace-heading')
	elseif subjectSpace == 828 then -- Module namespace
		data.heading = message('documentation-icon-wikitext') .. ' ' .. message('module-namespace-heading')
	elseif subjectSpace == 6 then -- File namespace
		data.heading = message('file-namespace-heading')
	else
		data.heading = message('other-namespaces-heading')
	end
	
	-- Heading CSS
	local headingStyle = args['heading-style']
	if headingStyle then
		data.headingStyleText = headingStyle
	elseif subjectSpace == 10 then
		-- We are in the template or template talk namespaces.
		data.headingFontWeight = 'bold'
		data.headingFontSize = '125%'
	else
		data.headingFontSize = '150%'
	end
	
	-- Data for the [view][edit][history][purge] or [create] links.
	if links then
		data.linksClass = message('start-box-linkclasses')
		data.linksId = message('start-box-link-id')
		data.links = links
	end
	
	return data
end

function p.renderStartBox(data)
	-- Renders the start box html.
	-- @data - a table of data generated by p.makeStartBoxData.
	local sbox = mw.html.create('div')
	sbox
		:css('padding-bottom', '3px')
		:css('border-bottom', '1px solid #aaa')
		:css('margin-bottom', '1ex')
		:newline()
		:tag('span')
			:cssText(data.headingStyleText)
			:css('font-weight', data.headingFontWeight)
			:css('font-size', data.headingFontSize)
			:wikitext(data.heading)
	local links = data.links
	if links then
		sbox:tag('span')
			:addClass(data.linksClass)
			:attr('id', data.linksId)
			:wikitext(links)
	end
	return tostring(sbox)
end

----------------------------------------------------------------------------
-- Documentation content
----------------------------------------------------------------------------

p.content = makeInvokeFunc('_content')

function p._content(args, env)
	-- Displays the documentation contents
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	env = env or p.getEnvironment(args)
	local docTitle = env.docTitle
	local content = args.content
	if not content and docTitle and docTitle.exists then
		content = args._content or mw.getCurrentFrame():expandTemplate{title = docTitle.prefixedText}
	end
	-- The line breaks below are necessary so that &quot;=== Headings ===&quot; at the start and end
	-- of docs are interpreted correctly.
	return '\n' .. (content or '') .. '\n' 
end

p.contentTitle = makeInvokeFunc('_contentTitle')

function p._contentTitle(args, env)
	env = env or p.getEnvironment(args)
	local docTitle = env.docTitle
	if not args.content and docTitle and docTitle.exists then
		return docTitle.prefixedText
	else
		return ''
	end
end

----------------------------------------------------------------------------
-- End box
----------------------------------------------------------------------------

p.endBox = makeInvokeFunc('_endBox')

function p._endBox(args, env)
	--[=[
	-- This function generates the end box (also known as the link box).
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	-- Messages:
	-- 'fmbox-id' --&gt; 'documentation-meta-data'
	-- 'fmbox-style' --&gt; 'background-color: #ecfcf4'
	-- 'fmbox-textstyle' --&gt; 'font-style: italic'
	-- 
	-- The HTML is generated by the {{fmbox}} template, courtesy of [[Module:Message box]].
	--]=]
	
	-- Get environment data.
	env = env or p.getEnvironment(args)
	local subjectSpace = env.subjectSpace
	local docTitle = env.docTitle
	if not subjectSpace or not docTitle then
		return nil
	end
		
	-- Check whether we should output the end box at all. Add the end
	-- box by default if the documentation exists or if we are in the
	-- user, module or template namespaces.
	local linkBox = args['link box']
	if linkBox == 'off'
		or not (
			docTitle.exists
			or subjectSpace == 2
			or subjectSpace == 828
			or subjectSpace == 10
		)
	then
		return nil
	end

	-- Assemble the arguments for {{fmbox}}.
	local fmargs = {}
	fmargs.id = message('fmbox-id') -- Sets 'documentation-meta-data'
	fmargs.image = 'none'
	fmargs.style = message('fmbox-style') -- Sets 'background-color: #ecfcf4'
	fmargs.textstyle = message('fmbox-textstyle') -- 'font-style: italic;'

	-- Assemble the fmbox text field.
	local text = ''
	if linkBox then
		text = text .. linkBox
	else
		text = text .. (p.makeDocPageBlurb(args, env) or '') -- &quot;This documentation is transcluded from [[|Foo]].&quot; 
		if subjectSpace == 2 or subjectSpace == 10 or subjectSpace == 828 then
			-- We are in the user, template or module namespaces.
			-- Add sandbox and testcases links.
			-- &quot;Editors can experiment in this template's sandbox and testcases pages.&quot;
			text = text .. (p.makeExperimentBlurb(args, env) or '')
			text = text .. '&lt;br /&gt;'
			if not args.content and not args[1] then
				-- &quot;Please add categories to the /doc subpage.&quot;
				-- Don't show this message with inline docs or with an explicitly specified doc page,
				-- as then it is unclear where to add the categories.
				text = text .. (p.makeCategoriesBlurb(args, env) or '')
			end
			text = text .. ' ' .. (p.makeSubpagesBlurb(args, env) or '') --&quot;Subpages of this template&quot;
			local printBlurb = p.makePrintBlurb(args, env) -- Two-line blurb about print versions of templates.
			if printBlurb then
				text = text .. '&lt;br /&gt;' .. printBlurb
			end
		end
	end
	fmargs.text = text

	return messageBox.main('fmbox', fmargs)
end

function p.makeDocPageBlurb(args, env)
	--[=[
	-- Makes the blurb &quot;This documentation is transcluded from [[Umhlahlandlelasakhiwo:Foo]] (edit, history)&quot;.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	-- Messages:
	-- 'edit-link-display' --&gt; 'edit'
	-- 'history-link-display' --&gt; 'history'
	-- 'transcluded-from-blurb' --&gt; 
	-- 'The above [[Wikipedia:Template documentation|documentation]] 
	-- is [[Wikipedia:Transclusion|transcluded]] from $1.'
	-- 'module-preload' --&gt; 'Template:Documentation/preload-module-doc'
	-- 'create-link-display' --&gt; 'create'
	-- 'create-module-doc-blurb' --&gt;
	-- 'You might want to $1 a documentation page for this [[Wikipedia:Lua|Scribunto module]].'
	--]=]
	local docTitle = env.docTitle
	if not docTitle then
		return nil
	end
	local ret
	if docTitle.exists then
		-- /doc exists; link to it.
		local docLink = makeWikilink(docTitle.prefixedText)
		local editUrl = docTitle:fullUrl{action = 'edit'}
		local editDisplay = message('edit-link-display')
		local editLink = makeUrlLink(editUrl, editDisplay)
		local historyUrl = docTitle:fullUrl{action = 'history'}
		local historyDisplay = message('history-link-display')
		local historyLink = makeUrlLink(historyUrl, historyDisplay)
		ret = message('transcluded-from-blurb', {docLink})
			.. ' '
			.. makeToolbar(editLink, historyLink)
			.. '&lt;br /&gt;'
	elseif env.subjectSpace == 828 then
		-- /doc does not exist; ask to create it.
		local createUrl = docTitle:fullUrl{action = 'edit', preload = message('module-preload')}
		local createDisplay = message('create-link-display')
		local createLink = makeUrlLink(createUrl, createDisplay)
		ret = message('create-module-doc-blurb', {createLink})
			.. '&lt;br /&gt;'
	end
	return ret
end

function p.makeExperimentBlurb(args, env)
	--[[
	-- Renders the text &quot;Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages.&quot;
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	-- Messages:
	-- 'sandbox-link-display' --&gt; 'sandbox'
	-- 'sandbox-edit-link-display' --&gt; 'edit'
	-- 'compare-link-display' --&gt; 'diff'
	-- 'module-sandbox-preload' --&gt; 'Template:Documentation/preload-module-sandbox'
	-- 'template-sandbox-preload' --&gt; 'Template:Documentation/preload-sandbox'
	-- 'sandbox-create-link-display' --&gt; 'create'
	-- 'mirror-edit-summary' --&gt; 'Create sandbox version of $1'
	-- 'mirror-link-display' --&gt; 'mirror'
	-- 'mirror-link-preload' --&gt; 'Template:Documentation/mirror'
	-- 'sandbox-link-display' --&gt; 'sandbox'
	-- 'testcases-link-display' --&gt; 'testcases'
	-- 'testcases-edit-link-display'--&gt; 'edit'
	-- 'template-sandbox-preload' --&gt; 'Template:Documentation/preload-sandbox'
	-- 'testcases-create-link-display' --&gt; 'create'
	-- 'testcases-link-display' --&gt; 'testcases'
	-- 'testcases-edit-link-display' --&gt; 'edit'
	-- 'module-testcases-preload' --&gt; 'Template:Documentation/preload-module-testcases'
	-- 'template-testcases-preload' --&gt; 'Template:Documentation/preload-testcases'
	-- 'experiment-blurb-module' --&gt; 'Editors can experiment in this module's $1 and $2 pages.'
	-- 'experiment-blurb-template' --&gt; 'Editors can experiment in this template's $1 and $2 pages.'
	--]]
	local subjectSpace = env.subjectSpace
	local templateTitle = env.templateTitle
	local sandboxTitle = env.sandboxTitle
	local testcasesTitle = env.testcasesTitle
	local templatePage = templateTitle.prefixedText
	if not subjectSpace or not templateTitle or not sandboxTitle or not testcasesTitle then
		return nil
	end
	-- Make links.
	local sandboxLinks, testcasesLinks
	if sandboxTitle.exists then
		local sandboxPage = sandboxTitle.prefixedText
		local sandboxDisplay = message('sandbox-link-display')
		local sandboxLink = makeWikilink(sandboxPage, sandboxDisplay)
		local sandboxEditUrl = sandboxTitle:fullUrl{action = 'edit'}
		local sandboxEditDisplay = message('sandbox-edit-link-display')
		local sandboxEditLink = makeUrlLink(sandboxEditUrl, sandboxEditDisplay)
		local compareUrl = env.compareUrl
		local compareLink
		if compareUrl then
			local compareDisplay = message('compare-link-display')
			compareLink = makeUrlLink(compareUrl, compareDisplay)
		end
		sandboxLinks = sandboxLink .. ' ' .. makeToolbar(sandboxEditLink, compareLink)
	else
		local sandboxPreload
		if subjectSpace == 828 then
			sandboxPreload = message('module-sandbox-preload')
		else
			sandboxPreload = message('template-sandbox-preload')
		end
		local sandboxCreateUrl = sandboxTitle:fullUrl{action = 'edit', preload = sandboxPreload}
		local sandboxCreateDisplay = message('sandbox-create-link-display')
		local sandboxCreateLink = makeUrlLink(sandboxCreateUrl, sandboxCreateDisplay)
		local mirrorSummary = message('mirror-edit-summary', {makeWikilink(templatePage)})
		local mirrorPreload = message('mirror-link-preload')
		local mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = mirrorPreload, summary = mirrorSummary}
		if subjectSpace == 828 then
			mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = templateTitle.prefixedText, summary = mirrorSummary}
		end
		local mirrorDisplay = message('mirror-link-display')
		local mirrorLink = makeUrlLink(mirrorUrl, mirrorDisplay)
		sandboxLinks = message('sandbox-link-display') .. ' ' .. makeToolbar(sandboxCreateLink, mirrorLink)
	end
	if testcasesTitle.exists then
		local testcasesPage = testcasesTitle.prefixedText
		local testcasesDisplay = message('testcases-link-display')
		local testcasesLink = makeWikilink(testcasesPage, testcasesDisplay)
		local testcasesEditUrl = testcasesTitle:fullUrl{action = 'edit'}
		local testcasesEditDisplay = message('testcases-edit-link-display')
		local testcasesEditLink = makeUrlLink(testcasesEditUrl, testcasesEditDisplay)
		-- for Modules, add testcases run link if exists
		if subjectSpace == 828 and testcasesTitle.talkPageTitle and testcasesTitle.talkPageTitle.exists then
			local testcasesRunLinkDisplay = message('testcases-run-link-display')
			local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay)
			testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink, testcasesRunLink)
		else
			testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink)
		end
	else
		local testcasesPreload
		if subjectSpace == 828 then
			testcasesPreload = message('module-testcases-preload')
		else
			testcasesPreload = message('template-testcases-preload')
		end
		local testcasesCreateUrl = testcasesTitle:fullUrl{action = 'edit', preload = testcasesPreload}
		local testcasesCreateDisplay = message('testcases-create-link-display')
		local testcasesCreateLink = makeUrlLink(testcasesCreateUrl, testcasesCreateDisplay)
		testcasesLinks = message('testcases-link-display') .. ' ' .. makeToolbar(testcasesCreateLink)
	end
	local messageName
	if subjectSpace == 828 then
		messageName = 'experiment-blurb-module'
	else
		messageName = 'experiment-blurb-template'
	end
	return message(messageName, {sandboxLinks, testcasesLinks})
end

function p.makeCategoriesBlurb(args, env)
	--[[
	-- Generates the text &quot;Please add categories to the /doc subpage.&quot;
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- Messages:
	-- 'doc-link-display' --&gt; '/doc'
	-- 'add-categories-blurb' --&gt; 'Please add categories to the $1 subpage.'
	--]]
	local docTitle = env.docTitle
	if not docTitle then
		return nil
	end
	local docPathLink = makeWikilink(docTitle.prefixedText, message('doc-link-display'))
	return message('add-categories-blurb', {docPathLink})
end

function p.makeSubpagesBlurb(args, env)
	--[[
	-- Generates the &quot;Subpages of this template&quot; link.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	
	-- Messages:
	-- 'template-pagetype' --&gt; 'template'
	-- 'module-pagetype' --&gt; 'module'
	-- 'default-pagetype' --&gt; 'page'
	-- 'subpages-link-display' --&gt; 'Subpages of this $1'
	--]]
	local subjectSpace = env.subjectSpace
	local templateTitle = env.templateTitle
	if not subjectSpace or not templateTitle then
		return nil
	end
	local pagetype
	if subjectSpace == 10 then
		pagetype = message('template-pagetype')
	elseif subjectSpace == 828 then
		pagetype = message('module-pagetype')
	else
		pagetype = message('default-pagetype')
	end
	local subpagesLink = makeWikilink(
		'Special:PrefixIndex/' .. templateTitle.prefixedText .. '/',
		message('subpages-link-display', {pagetype})
	)
	return message('subpages-blurb', {subpagesLink})
end

function p.makePrintBlurb(args, env)
	--[=[
	-- Generates the blurb displayed when there is a print version of the template available.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	--
	-- Messages:
	-- 'print-link-display' --&gt; '/Print'
	-- 'print-blurb' --&gt; 'A [[Lisizo:Books/for experts#Improving the book layout|print version]]'
	--		.. ' of this template exists at $1.'
	--		.. ' If you make a change to this template, please update the print version as well.'
	-- 'display-print-category' --&gt; true
	-- 'print-category' --&gt; 'Templates with print versions'
	--]=]
	local printTitle = env.printTitle
	if not printTitle then
		return nil
	end
	local ret
	if printTitle.exists then
		local printLink = makeWikilink(printTitle.prefixedText, message('print-link-display'))
		ret = message('print-blurb', {printLink})
		local displayPrintCategory = message('display-print-category', nil, 'boolean')
		if displayPrintCategory then
			ret = ret .. makeCategoryLink(message('print-category'))
		end
	end
	return ret
end

----------------------------------------------------------------------------
-- Tracking categories
----------------------------------------------------------------------------

function p.addTrackingCategories(env)
	--[[
	-- Check if {{documentation}} is transcluded on a /doc or /testcases page.
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	
	-- Messages:
	-- 'display-strange-usage-category' --&gt; true
	-- 'doc-subpage' --&gt; 'doc'
	-- 'testcases-subpage' --&gt; 'testcases'
	-- 'strange-usage-category' --&gt; 'Wikipedia pages with strange ((documentation)) usage'
	-- 
	-- /testcases pages in the module namespace are not categorised, as they may have
	-- {{documentation}} transcluded automatically.
	--]]
	local title = env.title
	local subjectSpace = env.subjectSpace
	if not title or not subjectSpace then
		return nil
	end
	local subpage = title.subpageText
	local ret = ''
	if message('display-strange-usage-category', nil, 'boolean')
		and (
			subpage == message('doc-subpage')
			or subjectSpace ~= 828 and subpage == message('testcases-subpage')
		)
	then
		ret = ret .. makeCategoryLink(message('strange-usage-category'))
	end
	return ret
end

return p</text>
      <sha1>i3ff5q5mxg9bllt9q4gv730dfg5b9ie</sha1>
    </revision>
    <revision>
      <id>440</id>
      <parentid>439</parentid>
      <timestamp>2019-05-07T18:04:09Z</timestamp>
      <contributor>
        <username>incubator&gt;Adithyak1997</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Added 2 prefixes</comment>
      <origin>440</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="36748" sha1="ehrpfjhio5rkj04kvpq98th28bl70nn" xml:space="preserve">-- This module implements {{documentation}}.

-- Get required modules.
local getArgs = require('Module:Arguments').getArgs
local messageBox = require('Module:Message box')

-- Get the config table.
local cfg = mw.loadData('Module:Documentation/config')

local p = {}

-- Often-used functions.
local ugsub = mw.ustring.gsub

----------------------------------------------------------------------------
-- Helper functions
--
-- These are defined as local functions, but are made available in the p
-- table for testing purposes.
----------------------------------------------------------------------------

local function message(cfgKey, valArray, expectType)
	--[[
	-- Gets a message from the cfg table and formats it if appropriate.
	-- The function raises an error if the value from the cfg table is not
	-- of the type expectType. The default type for expectType is 'string'.
	-- If the table valArray is present, strings such as $1, $2 etc. in the
	-- message are substituted with values from the table keys [1], [2] etc.
	-- For example, if the message &quot;foo-message&quot; had the value 'Foo $2 bar $1.',
	-- message('foo-message', {'baz', 'qux'}) would return &quot;Foo qux bar baz.&quot;
	--]]
	local msg = cfg[cfgKey]
	expectType = expectType or 'string'
	if type(msg) ~= expectType then
		error('message: type error in message cfg.' .. cfgKey .. ' (' .. expectType .. ' expected, got ' .. type(msg) .. ')', 2)
	end
	if not valArray then
		return msg
	end

	local function getMessageVal(match)
		match = tonumber(match)
		return valArray[match] or error('message: no value found for key $' .. match .. ' in message cfg.' .. cfgKey, 4)
	end

	local ret = ugsub(msg, '$([1-9][0-9]*)', getMessageVal)
	return ret
end

p.message = message

local function makeWikilink(page, display)
	if display then
		return mw.ustring.format('[[||%s|%s]]', page, display)
	else
		return mw.ustring.format('[[||%s]]', page)
	end
end

p.makeWikilink = makeWikilink

local function makeCategoryLink(cat, sort)
	local catns = mw.site.namespaces[14].name
	return makeWikilink(catns .. ':' .. cat, sort)
end

p.makeCategoryLink = makeCategoryLink

local function makeUrlLink(url, display)
	return mw.ustring.format('[%s %s]', url, display)
end

p.makeUrlLink = makeUrlLink

local function makeToolbar(...)
	local ret = {}
	local lim = select('#', ...)
	if lim &lt; 1 then
		return nil
	end
	for i = 1, lim do
		ret[#ret + 1] = select(i, ...)
	end
	return '&lt;small style=&quot;font-style: normal;&quot;&gt;(' .. table.concat(ret, ' &amp;#124; ') .. ')&lt;/small&gt;'
end	

p.makeToolbar = makeToolbar

----------------------------------------------------------------------------
-- Argument processing
----------------------------------------------------------------------------

local function makeInvokeFunc(funcName)
	return function (frame)
		local args = getArgs(frame, {
			valueFunc = function (key, value)
				if type(value) == 'string' then
					value = value:match('^%s*(.-)%s*$') -- Remove whitespace.
					if key == 'heading' or value ~= '' then
						return value
					else
						return nil
					end
				else
					return value
				end
			end
		})
		return p[funcName](args)
	end
end

----------------------------------------------------------------------------
-- Main function
----------------------------------------------------------------------------

p.main = makeInvokeFunc('_main')

function p._main(args)
	--[[
	-- This function defines logic flow for the module.
	-- @args - table of arguments passed by the user
	-- 
	-- Messages:
	-- 'main-div-id' --&gt; 'template-documentation'
	-- 'main-div-classes' --&gt; 'template-documentation iezoomfix'
	--]]
	local env = p.getEnvironment(args)
	local root = mw.html.create()
	root
		:wikitext(p.protectionTemplate(env))
		:wikitext(p.sandboxNotice(args, env))
		 -- This div tag is from {{documentation/start box}}, but moving it here
		 -- so that we don't have to worry about unclosed tags.
		:tag('div')
			:attr('id', message('main-div-id'))
			:addClass(message('main-div-classes'))
			:newline()
			:wikitext(p._startBox(args, env))
			:wikitext(p._content(args, env))
			:tag('div')
				:css('clear', 'both') -- So right or left floating items don't stick out of the doc box.
				:newline()
				:done()
			:done()
		:wikitext(p._endBox(args, env))
		:wikitext(p.addTrackingCategories(env))
	return tostring(root)
end

----------------------------------------------------------------------------
-- Environment settings
----------------------------------------------------------------------------

function p.getEnvironment(args)
	--[[
	-- Returns a table with information about the environment, including title objects and other namespace- or
	-- path-related data.
	-- @args - table of arguments passed by the user
	--
	-- Title objects include:
	-- env.title - the page we are making documentation for (usually the current title)
	-- env.templateTitle - the template (or module, file, etc.)
	-- env.docTitle - the /doc subpage.
	-- env.sandboxTitle - the /sandbox subpage.
	-- env.testcasesTitle - the /testcases subpage.
	-- env.printTitle - the print version of the template, located at the /Print subpage.
	--
	-- Data includes:
	-- env.protectionLevels - the protection levels table of the title object.
	-- env.subjectSpace - the number of the title's subject namespace.
	-- env.docSpace - the number of the namespace the title puts its documentation in.
	-- env.docpageBase - the text of the base page of the /doc, /sandbox and /testcases pages, with namespace.
	-- env.compareUrl - URL of the Special:ComparePages page comparing the sandbox with the template.
	-- 
	-- All table lookups are passed through pcall so that errors are caught. If an error occurs, the value
	-- returned will be nil.
	--]]
	
	local env, envFuncs = {}, {}

	-- Set up the metatable. If triggered we call the corresponding function in the envFuncs table. The value
	-- returned by that function is memoized in the env table so that we don't call any of the functions
	-- more than once. (Nils won't be memoized.)
	setmetatable(env, {
		__index = function (t, key)
			local envFunc = envFuncs[key]
			if envFunc then
				local success, val = pcall(envFunc)
				if success then
					env[key] = val -- Memoise the value.
					return val
				end
			end
			return nil
		end
	})	

	function envFuncs.title()
		-- The title object for the current page, or a test page passed with args.page.
		local title
		local titleArg = args.page
		if titleArg then
			title = mw.title.new(titleArg)
		else
			title = mw.title.getCurrentTitle()
		end
		return title
	end

	function envFuncs.templateTitle()
		--[[
		-- The template (or module, etc.) title object.
		-- Messages:
		-- 'sandbox-subpage' --&gt; 'sandbox'
		-- 'testcases-subpage' --&gt; 'testcases'
		--]]
		local subjectSpace = env.subjectSpace
		local title = env.title
		local subpage = title.subpageText
		if subpage == message('sandbox-subpage') or subpage == message('testcases-subpage') then
			return mw.title.makeTitle(subjectSpace, title.baseText)
		else
			return mw.title.makeTitle(subjectSpace, title.text)
		end
	end

	function envFuncs.docTitle()
		--[[
		-- Title object of the /doc subpage.
		-- Messages:
		-- 'doc-subpage' --&gt; 'doc'
		--]]
		local title = env.title
		local docname = args[1] -- User-specified doc page.
		local docpage
		if docname then
			docpage = docname
		else
			docpage = env.docpageBase .. '/' .. message('doc-subpage')
		end
		return mw.title.new(docpage)
	end
	
	function envFuncs.sandboxTitle()
		--[[
		-- Title object for the /sandbox subpage.
		-- Messages:
		-- 'sandbox-subpage' --&gt; 'sandbox'
		--]]
		return mw.title.new(env.docpageBase .. '/' .. message('sandbox-subpage'))
	end
	
	function envFuncs.testcasesTitle()
		--[[
		-- Title object for the /testcases subpage.
		-- Messages:
		-- 'testcases-subpage' --&gt; 'testcases'
		--]]
		return mw.title.new(env.docpageBase .. '/' .. message('testcases-subpage'))
	end
	
	function envFuncs.printTitle()
		--[[
		-- Title object for the /Print subpage.
		-- Messages:
		-- 'print-subpage' --&gt; 'Print'
		--]]
		return env.templateTitle:subPageTitle(message('print-subpage'))
	end

	function envFuncs.protectionLevels()
		-- The protection levels table of the title object.
		return env.title.protectionLevels
	end

	function envFuncs.subjectSpace()
		-- The subject namespace number.
		return mw.site.namespaces[env.title.namespace].subject.id
	end

	function envFuncs.docSpace()
		-- The documentation namespace number. For most namespaces this is the same as the
		-- subject namespace. However, pages in the Article, File, MediaWiki or Category
		-- namespaces must have their /doc, /sandbox and /testcases pages in talk space.
		local subjectSpace = env.subjectSpace
		if subjectSpace == 0 or subjectSpace == 6 or subjectSpace == 8 or subjectSpace == 14 then
			return subjectSpace + 1
		else
			return subjectSpace
		end
	end

	function envFuncs.docpageBase()
		-- The base page of the /doc, /sandbox, and /testcases subpages.
		-- For some namespaces this is the talk page, rather than the template page.
		local templateTitle = env.templateTitle
		local docSpace = env.docSpace
		local docSpaceText = mw.site.namespaces[docSpace].name
		-- Assemble the link. docSpace is never the main namespace, so we can hardcode the colon.
		return docSpaceText .. ':' .. templateTitle.text
	end
	
	function envFuncs.compareUrl()
		-- Diff link between the sandbox and the main template using [[Khethekileko:ComparePages]].
		local templateTitle = env.templateTitle
		local sandboxTitle = env.sandboxTitle
		if templateTitle.exists and sandboxTitle.exists then
			local compareUrl = mw.uri.fullUrl(
				'Special:ComparePages',
				{page1 = templateTitle.prefixedText, page2 = sandboxTitle.prefixedText}
			)
			return tostring(compareUrl)
		else
			return nil
		end
	end		

	return env
end	

----------------------------------------------------------------------------
-- Auxiliary templates
----------------------------------------------------------------------------

function p.sandboxNotice(args, env)
	--[=[
	-- Generates a sandbox notice for display above sandbox pages.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	-- Messages:
	-- 'sandbox-notice-image' --&gt; '[[Isimumathi:Sandbox.svg|50px|alt=|link=]]'
	-- 'sandbox-notice-blurb' --&gt; 'This is the $1 for $2.'
	-- 'sandbox-notice-diff-blurb' --&gt; 'This is the $1 for $2 ($3).'
	-- 'sandbox-notice-pagetype-template' --&gt; '[[Wikipedia:Template test cases|template sandbox]] page'
	-- 'sandbox-notice-pagetype-module' --&gt; '[[Wikipedia:Template test cases|module sandbox]] page'
	-- 'sandbox-notice-pagetype-other' --&gt; 'sandbox page'
	-- 'sandbox-notice-compare-link-display' --&gt; 'diff'
	-- 'sandbox-notice-testcases-blurb' --&gt; 'See also the companion subpage for $1.'
	-- 'sandbox-notice-testcases-link-display' --&gt; 'test cases'
	-- 'sandbox-category' --&gt; 'Template sandboxes'
	--]=]
	local title = env.title
	local sandboxTitle = env.sandboxTitle
	local templateTitle = env.templateTitle
	local subjectSpace = env.subjectSpace
	if not (subjectSpace and title and sandboxTitle and templateTitle and mw.title.equals(title, sandboxTitle)) then
		return nil
	end
	-- Build the table of arguments to pass to {{ombox}}. We need just two fields, &quot;image&quot; and &quot;text&quot;.
	local omargs = {}
	omargs.image = message('sandbox-notice-image')
	-- Get the text. We start with the opening blurb, which is something like
	-- &quot;This is the template sandbox for [[Umhlahlandlelasakhiwo:Foo]] (diff).&quot;
	local text = ''
	local pagetype
	if subjectSpace == 10 then
		pagetype = message('sandbox-notice-pagetype-template')
	elseif subjectSpace == 828 then
		pagetype = message('sandbox-notice-pagetype-module')
	else
		pagetype = message('sandbox-notice-pagetype-other')
	end
	local templateLink = makeWikilink(templateTitle.prefixedText)
	local compareUrl = env.compareUrl
	if compareUrl then
		local compareDisplay = message('sandbox-notice-compare-link-display')
		local compareLink = makeUrlLink(compareUrl, compareDisplay)
		text = text .. message('sandbox-notice-diff-blurb', {pagetype, templateLink, compareLink})
	else
		text = text .. message('sandbox-notice-blurb', {pagetype, templateLink})
	end
	-- Get the test cases page blurb if the page exists. This is something like
	-- &quot;See also the companion subpage for [[Umhlahlandlelasakhiwo:Foo/testcases|test cases]].&quot;
	local testcasesTitle = env.testcasesTitle
	if testcasesTitle and testcasesTitle.exists then
		if testcasesTitle.namespace == mw.site.namespaces.Module.id then
			local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display')
			local testcasesRunLinkDisplay = message('sandbox-notice-testcases-run-link-display')
			local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay)
			local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay)
			text = text .. '&lt;br /&gt;' .. message('sandbox-notice-testcases-run-blurb', {testcasesLink, testcasesRunLink})
		else
			local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display')
			local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay)
			text = text .. '&lt;br /&gt;' .. message('sandbox-notice-testcases-blurb', {testcasesLink})
		end
	end
	-- Add the sandbox to the sandbox category.
	text = text .. makeCategoryLink(message('sandbox-category'))
	omargs.text = text
	local ret = '&lt;div style=&quot;clear: both;&quot;&gt;&lt;/div&gt;'
	ret = ret .. messageBox.main('ombox', omargs)
	return ret
end

function p.protectionTemplate(env)
	-- Generates the padlock icon in the top right.
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- Messages:
	-- 'protection-template' --&gt; 'pp-template'
	-- 'protection-template-args' --&gt; {docusage = 'yes'}
	local protectionLevels, mProtectionBanner
	local title = env.title
	protectionLevels = env.protectionLevels
	if not protectionLevels then
		return nil
	end
	local editProt = protectionLevels.edit and protectionLevels.edit[1]
	local moveProt = protectionLevels.move and protectionLevels.move[1]
	if editProt then
		-- The page is edit-protected.
		mProtectionBanner = require('Module:Protection banner')
		local reason = message('protection-reason-edit')
		return mProtectionBanner._main{reason, small = true}
	elseif moveProt and moveProt ~= 'autoconfirmed' then
		-- The page is move-protected but not edit-protected. Exclude move
		-- protection with the level &quot;autoconfirmed&quot;, as this is equivalent to
		-- no move protection at all.
		mProtectionBanner = require('Module:Protection banner')
		return mProtectionBanner._main{action = 'move', small = true}
	else
		return nil
	end
end

----------------------------------------------------------------------------
-- Start box
----------------------------------------------------------------------------

p.startBox = makeInvokeFunc('_startBox')

function p._startBox(args, env)
	--[[
	-- This function generates the start box.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	-- The actual work is done by p.makeStartBoxLinksData and p.renderStartBoxLinks which make
	-- the [view] [edit] [history] [purge] links, and by p.makeStartBoxData and p.renderStartBox
	-- which generate the box HTML.
	--]]
	env = env or p.getEnvironment(args)
	local links
	local content = args.content
	if not content then
		-- No need to include the links if the documentation is on the template page itself.
		local linksData = p.makeStartBoxLinksData(args, env)
		if linksData then
			links = p.renderStartBoxLinks(linksData)
		end
	end
	-- Generate the start box html.
	local data = p.makeStartBoxData(args, env, links)
	if data then
		return p.renderStartBox(data)
	else
		-- User specified no heading.
		return nil
	end
end

function p.makeStartBoxLinksData(args, env)
	--[[
	-- Does initial processing of data to make the [view] [edit] [history] [purge] links.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	-- Messages:
	-- 'view-link-display' --&gt; 'view'
	-- 'edit-link-display' --&gt; 'edit'
	-- 'history-link-display' --&gt; 'history'
	-- 'purge-link-display' --&gt; 'purge'
	-- 'file-docpage-preload' --&gt; 'Template:Documentation/preload-filespace'
	-- 'module-preload' --&gt; 'Template:Documentation/preload-module-doc'
	-- 'docpage-preload' --&gt; 'Template:Documentation/preload'
	-- 'create-link-display' --&gt; 'create'
	--]]
	local subjectSpace = env.subjectSpace
	local title = env.title
	local docTitle = env.docTitle
	if not title or not docTitle then
		return nil
	end

	local data = {}
	data.title = title
	data.docTitle = docTitle
	-- View, display, edit, and purge links if /doc exists.
	data.viewLinkDisplay = message('view-link-display')
	data.editLinkDisplay = message('edit-link-display')
	data.historyLinkDisplay = message('history-link-display')
	data.purgeLinkDisplay = message('purge-link-display')
	-- Create link if /doc doesn't exist.
	local preload = args.preload
	if not preload then
		if subjectSpace == 6 then -- File namespace
			preload = message('file-docpage-preload')
		elseif subjectSpace == 828 then -- Module namespace
			preload = message('module-preload')
		else
			preload = message('docpage-preload')
		end
	end
	data.preload = preload
	data.createLinkDisplay = message('create-link-display')
	return data
end

function p.renderStartBoxLinks(data)
	--[[
	-- Generates the [view][edit][history][purge] or [create] links from the data table.
	-- @data - a table of data generated by p.makeStartBoxLinksData
	--]]
	
	local function escapeBrackets(s)
		-- Escapes square brackets with HTML entities.
		s = s:gsub('%[', '&amp;#91;') -- Replace square brackets with HTML entities.
		s = s:gsub('%]', '&amp;#93;')
		return s
	end

	local ret
	local docTitle = data.docTitle
	local title = data.title
	if docTitle.exists then
		local viewLink = makeWikilink(docTitle.prefixedText, data.viewLinkDisplay)
		local editLink = makeUrlLink(docTitle:fullUrl{action = 'edit'}, data.editLinkDisplay)
		local historyLink = makeUrlLink(docTitle:fullUrl{action = 'history'}, data.historyLinkDisplay)
		local purgeLink = makeUrlLink(title:fullUrl{action = 'purge'}, data.purgeLinkDisplay)
		ret = '[%s] [%s] [%s] [%s]'
		ret = escapeBrackets(ret)
		ret = mw.ustring.format(ret, viewLink, editLink, historyLink, purgeLink)
	else
		local createLink = makeUrlLink(docTitle:fullUrl{action = 'edit', preload = data.preload}, data.createLinkDisplay)
		ret = '[%s]'
		ret = escapeBrackets(ret)
		ret = mw.ustring.format(ret, createLink)
	end
	return ret
end

function p.makeStartBoxData(args, env, links)
	--[=[
	-- Does initial processing of data to pass to the start-box render function, p.renderStartBox.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- @links - a string containing the [view][edit][history][purge] links - could be nil if there's an error.
	--
	-- Messages:
	-- 'documentation-icon-wikitext' --&gt; '[[Isimumathi:Test Template Info-Icon - Version (2).svg|50px|link=|alt=]]'
	-- 'template-namespace-heading' --&gt; 'Template documentation'
	-- 'module-namespace-heading' --&gt; 'Module documentation'
	-- 'file-namespace-heading' --&gt; 'Summary'
	-- 'other-namespaces-heading' --&gt; 'Documentation'
	-- 'start-box-linkclasses' --&gt; 'mw-editsection-like plainlinks'
	-- 'start-box-link-id' --&gt; 'doc_editlinks'
	-- 'testcases-create-link-display' --&gt; 'create'
	--]=]
	local subjectSpace = env.subjectSpace
	if not subjectSpace then
		-- Default to an &quot;other namespaces&quot; namespace, so that we get at least some output
		-- if an error occurs.
		subjectSpace = 2
	end
	local data = {}
	
	-- Heading
	local heading = args.heading -- Blank values are not removed.
	if heading == '' then
		-- Don't display the start box if the heading arg is defined but blank.
		return nil
	end
	if heading then
		data.heading = heading
	elseif subjectSpace == 10 then -- Template namespace
		data.heading = message('documentation-icon-wikitext') .. ' ' .. message('template-namespace-heading')
	elseif subjectSpace == 828 then -- Module namespace
		data.heading = message('documentation-icon-wikitext') .. ' ' .. message('module-namespace-heading')
	elseif subjectSpace == 6 then -- File namespace
		data.heading = message('file-namespace-heading')
	else
		data.heading = message('other-namespaces-heading')
	end
	
	-- Heading CSS
	local headingStyle = args['heading-style']
	if headingStyle then
		data.headingStyleText = headingStyle
	elseif subjectSpace == 10 then
		-- We are in the template or template talk namespaces.
		data.headingFontWeight = 'bold'
		data.headingFontSize = '125%'
	else
		data.headingFontSize = '150%'
	end
	
	-- Data for the [view][edit][history][purge] or [create] links.
	if links then
		data.linksClass = message('start-box-linkclasses')
		data.linksId = message('start-box-link-id')
		data.links = links
	end
	
	return data
end

function p.renderStartBox(data)
	-- Renders the start box html.
	-- @data - a table of data generated by p.makeStartBoxData.
	local sbox = mw.html.create('div')
	sbox
		:css('padding-bottom', '3px')
		:css('border-bottom', '1px solid #aaa')
		:css('margin-bottom', '1ex')
		:newline()
		:tag('span')
			:cssText(data.headingStyleText)
			:css('font-weight', data.headingFontWeight)
			:css('font-size', data.headingFontSize)
			:wikitext(data.heading)
	local links = data.links
	if links then
		sbox:tag('span')
			:addClass(data.linksClass)
			:attr('id', data.linksId)
			:wikitext(links)
	end
	return tostring(sbox)
end

----------------------------------------------------------------------------
-- Documentation content
----------------------------------------------------------------------------

p.content = makeInvokeFunc('_content')

function p._content(args, env)
	-- Displays the documentation contents
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	env = env or p.getEnvironment(args)
	local docTitle = env.docTitle
	local content = args.content
	if not content and docTitle and docTitle.exists then
		content = args._content or mw.getCurrentFrame():expandTemplate{title = docTitle.prefixedText}
	end
	-- The line breaks below are necessary so that &quot;=== Headings ===&quot; at the start and end
	-- of docs are interpreted correctly.
	return '\n' .. (content or '') .. '\n' 
end

p.contentTitle = makeInvokeFunc('_contentTitle')

function p._contentTitle(args, env)
	env = env or p.getEnvironment(args)
	local docTitle = env.docTitle
	if not args.content and docTitle and docTitle.exists then
		return docTitle.prefixedText
	else
		return ''
	end
end

----------------------------------------------------------------------------
-- End box
----------------------------------------------------------------------------

p.endBox = makeInvokeFunc('_endBox')

function p._endBox(args, env)
	--[=[
	-- This function generates the end box (also known as the link box).
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	-- Messages:
	-- 'fmbox-id' --&gt; 'documentation-meta-data'
	-- 'fmbox-style' --&gt; 'background-color: #ecfcf4'
	-- 'fmbox-textstyle' --&gt; 'font-style: italic'
	-- 
	-- The HTML is generated by the {{fmbox}} template, courtesy of [[Module:Message box]].
	--]=]
	
	-- Get environment data.
	env = env or p.getEnvironment(args)
	local subjectSpace = env.subjectSpace
	local docTitle = env.docTitle
	if not subjectSpace or not docTitle then
		return nil
	end
		
	-- Check whether we should output the end box at all. Add the end
	-- box by default if the documentation exists or if we are in the
	-- user, module or template namespaces.
	local linkBox = args['link box']
	if linkBox == 'off'
		or not (
			docTitle.exists
			or subjectSpace == 2
			or subjectSpace == 828
			or subjectSpace == 10
		)
	then
		return nil
	end

	-- Assemble the arguments for {{fmbox}}.
	local fmargs = {}
	fmargs.id = message('fmbox-id') -- Sets 'documentation-meta-data'
	fmargs.image = 'none'
	fmargs.style = message('fmbox-style') -- Sets 'background-color: #ecfcf4'
	fmargs.textstyle = message('fmbox-textstyle') -- 'font-style: italic;'

	-- Assemble the fmbox text field.
	local text = ''
	if linkBox then
		text = text .. linkBox
	else
		text = text .. (p.makeDocPageBlurb(args, env) or '') -- &quot;This documentation is transcluded from [[||Foo]].&quot; 
		if subjectSpace == 2 or subjectSpace == 10 or subjectSpace == 828 then
			-- We are in the user, template or module namespaces.
			-- Add sandbox and testcases links.
			-- &quot;Editors can experiment in this template's sandbox and testcases pages.&quot;
			text = text .. (p.makeExperimentBlurb(args, env) or '')
			text = text .. '&lt;br /&gt;'
			if not args.content and not args[1] then
				-- &quot;Please add categories to the /doc subpage.&quot;
				-- Don't show this message with inline docs or with an explicitly specified doc page,
				-- as then it is unclear where to add the categories.
				text = text .. (p.makeCategoriesBlurb(args, env) or '')
			end
			text = text .. ' ' .. (p.makeSubpagesBlurb(args, env) or '') --&quot;Subpages of this template&quot;
			local printBlurb = p.makePrintBlurb(args, env) -- Two-line blurb about print versions of templates.
			if printBlurb then
				text = text .. '&lt;br /&gt;' .. printBlurb
			end
		end
	end
	fmargs.text = text

	return messageBox.main('fmbox', fmargs)
end

function p.makeDocPageBlurb(args, env)
	--[=[
	-- Makes the blurb &quot;This documentation is transcluded from [[Umhlahlandlelasakhiwo:Foo]] (edit, history)&quot;.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	-- Messages:
	-- 'edit-link-display' --&gt; 'edit'
	-- 'history-link-display' --&gt; 'history'
	-- 'transcluded-from-blurb' --&gt; 
	-- 'The above [[Wikipedia:Template documentation|documentation]] 
	-- is [[Wikipedia:Transclusion|transcluded]] from $1.'
	-- 'module-preload' --&gt; 'Template:Documentation/preload-module-doc'
	-- 'create-link-display' --&gt; 'create'
	-- 'create-module-doc-blurb' --&gt;
	-- 'You might want to $1 a documentation page for this [[Wikipedia:Lua|Scribunto module]].'
	--]=]
	local docTitle = env.docTitle
	if not docTitle then
		return nil
	end
	local ret
	if docTitle.exists then
		-- /doc exists; link to it.
		local docLink = makeWikilink(docTitle.prefixedText)
		local editUrl = docTitle:fullUrl{action = 'edit'}
		local editDisplay = message('edit-link-display')
		local editLink = makeUrlLink(editUrl, editDisplay)
		local historyUrl = docTitle:fullUrl{action = 'history'}
		local historyDisplay = message('history-link-display')
		local historyLink = makeUrlLink(historyUrl, historyDisplay)
		ret = message('transcluded-from-blurb', {docLink})
			.. ' '
			.. makeToolbar(editLink, historyLink)
			.. '&lt;br /&gt;'
	elseif env.subjectSpace == 828 then
		-- /doc does not exist; ask to create it.
		local createUrl = docTitle:fullUrl{action = 'edit', preload = message('module-preload')}
		local createDisplay = message('create-link-display')
		local createLink = makeUrlLink(createUrl, createDisplay)
		ret = message('create-module-doc-blurb', {createLink})
			.. '&lt;br /&gt;'
	end
	return ret
end

function p.makeExperimentBlurb(args, env)
	--[[
	-- Renders the text &quot;Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages.&quot;
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	-- Messages:
	-- 'sandbox-link-display' --&gt; 'sandbox'
	-- 'sandbox-edit-link-display' --&gt; 'edit'
	-- 'compare-link-display' --&gt; 'diff'
	-- 'module-sandbox-preload' --&gt; 'Template:Documentation/preload-module-sandbox'
	-- 'template-sandbox-preload' --&gt; 'Template:Documentation/preload-sandbox'
	-- 'sandbox-create-link-display' --&gt; 'create'
	-- 'mirror-edit-summary' --&gt; 'Create sandbox version of $1'
	-- 'mirror-link-display' --&gt; 'mirror'
	-- 'mirror-link-preload' --&gt; 'Template:Documentation/mirror'
	-- 'sandbox-link-display' --&gt; 'sandbox'
	-- 'testcases-link-display' --&gt; 'testcases'
	-- 'testcases-edit-link-display'--&gt; 'edit'
	-- 'template-sandbox-preload' --&gt; 'Template:Documentation/preload-sandbox'
	-- 'testcases-create-link-display' --&gt; 'create'
	-- 'testcases-link-display' --&gt; 'testcases'
	-- 'testcases-edit-link-display' --&gt; 'edit'
	-- 'module-testcases-preload' --&gt; 'Template:Documentation/preload-module-testcases'
	-- 'template-testcases-preload' --&gt; 'Template:Documentation/preload-testcases'
	-- 'experiment-blurb-module' --&gt; 'Editors can experiment in this module's $1 and $2 pages.'
	-- 'experiment-blurb-template' --&gt; 'Editors can experiment in this template's $1 and $2 pages.'
	--]]
	local subjectSpace = env.subjectSpace
	local templateTitle = env.templateTitle
	local sandboxTitle = env.sandboxTitle
	local testcasesTitle = env.testcasesTitle
	local templatePage = templateTitle.prefixedText
	if not subjectSpace or not templateTitle or not sandboxTitle or not testcasesTitle then
		return nil
	end
	-- Make links.
	local sandboxLinks, testcasesLinks
	if sandboxTitle.exists then
		local sandboxPage = sandboxTitle.prefixedText
		local sandboxDisplay = message('sandbox-link-display')
		local sandboxLink = makeWikilink(sandboxPage, sandboxDisplay)
		local sandboxEditUrl = sandboxTitle:fullUrl{action = 'edit'}
		local sandboxEditDisplay = message('sandbox-edit-link-display')
		local sandboxEditLink = makeUrlLink(sandboxEditUrl, sandboxEditDisplay)
		local compareUrl = env.compareUrl
		local compareLink
		if compareUrl then
			local compareDisplay = message('compare-link-display')
			compareLink = makeUrlLink(compareUrl, compareDisplay)
		end
		sandboxLinks = sandboxLink .. ' ' .. makeToolbar(sandboxEditLink, compareLink)
	else
		local sandboxPreload
		if subjectSpace == 828 then
			sandboxPreload = message('module-sandbox-preload')
		else
			sandboxPreload = message('template-sandbox-preload')
		end
		local sandboxCreateUrl = sandboxTitle:fullUrl{action = 'edit', preload = sandboxPreload}
		local sandboxCreateDisplay = message('sandbox-create-link-display')
		local sandboxCreateLink = makeUrlLink(sandboxCreateUrl, sandboxCreateDisplay)
		local mirrorSummary = message('mirror-edit-summary', {makeWikilink(templatePage)})
		local mirrorPreload = message('mirror-link-preload')
		local mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = mirrorPreload, summary = mirrorSummary}
		if subjectSpace == 828 then
			mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = templateTitle.prefixedText, summary = mirrorSummary}
		end
		local mirrorDisplay = message('mirror-link-display')
		local mirrorLink = makeUrlLink(mirrorUrl, mirrorDisplay)
		sandboxLinks = message('sandbox-link-display') .. ' ' .. makeToolbar(sandboxCreateLink, mirrorLink)
	end
	if testcasesTitle.exists then
		local testcasesPage = testcasesTitle.prefixedText
		local testcasesDisplay = message('testcases-link-display')
		local testcasesLink = makeWikilink(testcasesPage, testcasesDisplay)
		local testcasesEditUrl = testcasesTitle:fullUrl{action = 'edit'}
		local testcasesEditDisplay = message('testcases-edit-link-display')
		local testcasesEditLink = makeUrlLink(testcasesEditUrl, testcasesEditDisplay)
		-- for Modules, add testcases run link if exists
		if subjectSpace == 828 and testcasesTitle.talkPageTitle and testcasesTitle.talkPageTitle.exists then
			local testcasesRunLinkDisplay = message('testcases-run-link-display')
			local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay)
			testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink, testcasesRunLink)
		else
			testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink)
		end
	else
		local testcasesPreload
		if subjectSpace == 828 then
			testcasesPreload = message('module-testcases-preload')
		else
			testcasesPreload = message('template-testcases-preload')
		end
		local testcasesCreateUrl = testcasesTitle:fullUrl{action = 'edit', preload = testcasesPreload}
		local testcasesCreateDisplay = message('testcases-create-link-display')
		local testcasesCreateLink = makeUrlLink(testcasesCreateUrl, testcasesCreateDisplay)
		testcasesLinks = message('testcases-link-display') .. ' ' .. makeToolbar(testcasesCreateLink)
	end
	local messageName
	if subjectSpace == 828 then
		messageName = 'experiment-blurb-module'
	else
		messageName = 'experiment-blurb-template'
	end
	return message(messageName, {sandboxLinks, testcasesLinks})
end

function p.makeCategoriesBlurb(args, env)
	--[[
	-- Generates the text &quot;Please add categories to the /doc subpage.&quot;
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- Messages:
	-- 'doc-link-display' --&gt; '/doc'
	-- 'add-categories-blurb' --&gt; 'Please add categories to the $1 subpage.'
	--]]
	local docTitle = env.docTitle
	if not docTitle then
		return nil
	end
	local docPathLink = makeWikilink(docTitle.prefixedText, message('doc-link-display'))
	return message('add-categories-blurb', {docPathLink})
end

function p.makeSubpagesBlurb(args, env)
	--[[
	-- Generates the &quot;Subpages of this template&quot; link.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	
	-- Messages:
	-- 'template-pagetype' --&gt; 'template'
	-- 'module-pagetype' --&gt; 'module'
	-- 'default-pagetype' --&gt; 'page'
	-- 'subpages-link-display' --&gt; 'Subpages of this $1'
	--]]
	local subjectSpace = env.subjectSpace
	local templateTitle = env.templateTitle
	if not subjectSpace or not templateTitle then
		return nil
	end
	local pagetype
	if subjectSpace == 10 then
		pagetype = message('template-pagetype')
	elseif subjectSpace == 828 then
		pagetype = message('module-pagetype')
	else
		pagetype = message('default-pagetype')
	end
	local subpagesLink = makeWikilink(
		'Special:PrefixIndex/' .. templateTitle.prefixedText .. '/',
		message('subpages-link-display', {pagetype})
	)
	return message('subpages-blurb', {subpagesLink})
end

function p.makePrintBlurb(args, env)
	--[=[
	-- Generates the blurb displayed when there is a print version of the template available.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	--
	-- Messages:
	-- 'print-link-display' --&gt; '/Print'
	-- 'print-blurb' --&gt; 'A [[Lisizo:Books/for experts#Improving the book layout|print version]]'
	--		.. ' of this template exists at $1.'
	--		.. ' If you make a change to this template, please update the print version as well.'
	-- 'display-print-category' --&gt; true
	-- 'print-category' --&gt; 'Templates with print versions'
	--]=]
	local printTitle = env.printTitle
	if not printTitle then
		return nil
	end
	local ret
	if printTitle.exists then
		local printLink = makeWikilink(printTitle.prefixedText, message('print-link-display'))
		ret = message('print-blurb', {printLink})
		local displayPrintCategory = message('display-print-category', nil, 'boolean')
		if displayPrintCategory then
			ret = ret .. makeCategoryLink(message('print-category'))
		end
	end
	return ret
end

----------------------------------------------------------------------------
-- Tracking categories
----------------------------------------------------------------------------

function p.addTrackingCategories(env)
	--[[
	-- Check if {{documentation}} is transcluded on a /doc or /testcases page.
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	
	-- Messages:
	-- 'display-strange-usage-category' --&gt; true
	-- 'doc-subpage' --&gt; 'doc'
	-- 'testcases-subpage' --&gt; 'testcases'
	-- 'strange-usage-category' --&gt; 'Wikipedia pages with strange ((documentation)) usage'
	-- 
	-- /testcases pages in the module namespace are not categorised, as they may have
	-- {{documentation}} transcluded automatically.
	--]]
	local title = env.title
	local subjectSpace = env.subjectSpace
	if not title or not subjectSpace then
		return nil
	end
	local subpage = title.subpageText
	local ret = ''
	if message('display-strange-usage-category', nil, 'boolean')
		and (
			subpage == message('doc-subpage')
			or subjectSpace ~= 828 and subpage == message('testcases-subpage')
		)
	then
		ret = ret .. makeCategoryLink(message('strange-usage-category'))
	end
	return ret
end

return p</text>
      <sha1>ehrpfjhio5rkj04kvpq98th28bl70nn</sha1>
    </revision>
    <revision>
      <id>441</id>
      <parentid>440</parentid>
      <timestamp>2024-10-14T13:46:29Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>440</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="36748" sha1="ehrpfjhio5rkj04kvpq98th28bl70nn" xml:space="preserve">-- This module implements {{documentation}}.

-- Get required modules.
local getArgs = require('Module:Arguments').getArgs
local messageBox = require('Module:Message box')

-- Get the config table.
local cfg = mw.loadData('Module:Documentation/config')

local p = {}

-- Often-used functions.
local ugsub = mw.ustring.gsub

----------------------------------------------------------------------------
-- Helper functions
--
-- These are defined as local functions, but are made available in the p
-- table for testing purposes.
----------------------------------------------------------------------------

local function message(cfgKey, valArray, expectType)
	--[[
	-- Gets a message from the cfg table and formats it if appropriate.
	-- The function raises an error if the value from the cfg table is not
	-- of the type expectType. The default type for expectType is 'string'.
	-- If the table valArray is present, strings such as $1, $2 etc. in the
	-- message are substituted with values from the table keys [1], [2] etc.
	-- For example, if the message &quot;foo-message&quot; had the value 'Foo $2 bar $1.',
	-- message('foo-message', {'baz', 'qux'}) would return &quot;Foo qux bar baz.&quot;
	--]]
	local msg = cfg[cfgKey]
	expectType = expectType or 'string'
	if type(msg) ~= expectType then
		error('message: type error in message cfg.' .. cfgKey .. ' (' .. expectType .. ' expected, got ' .. type(msg) .. ')', 2)
	end
	if not valArray then
		return msg
	end

	local function getMessageVal(match)
		match = tonumber(match)
		return valArray[match] or error('message: no value found for key $' .. match .. ' in message cfg.' .. cfgKey, 4)
	end

	local ret = ugsub(msg, '$([1-9][0-9]*)', getMessageVal)
	return ret
end

p.message = message

local function makeWikilink(page, display)
	if display then
		return mw.ustring.format('[[||%s|%s]]', page, display)
	else
		return mw.ustring.format('[[||%s]]', page)
	end
end

p.makeWikilink = makeWikilink

local function makeCategoryLink(cat, sort)
	local catns = mw.site.namespaces[14].name
	return makeWikilink(catns .. ':' .. cat, sort)
end

p.makeCategoryLink = makeCategoryLink

local function makeUrlLink(url, display)
	return mw.ustring.format('[%s %s]', url, display)
end

p.makeUrlLink = makeUrlLink

local function makeToolbar(...)
	local ret = {}
	local lim = select('#', ...)
	if lim &lt; 1 then
		return nil
	end
	for i = 1, lim do
		ret[#ret + 1] = select(i, ...)
	end
	return '&lt;small style=&quot;font-style: normal;&quot;&gt;(' .. table.concat(ret, ' &amp;#124; ') .. ')&lt;/small&gt;'
end	

p.makeToolbar = makeToolbar

----------------------------------------------------------------------------
-- Argument processing
----------------------------------------------------------------------------

local function makeInvokeFunc(funcName)
	return function (frame)
		local args = getArgs(frame, {
			valueFunc = function (key, value)
				if type(value) == 'string' then
					value = value:match('^%s*(.-)%s*$') -- Remove whitespace.
					if key == 'heading' or value ~= '' then
						return value
					else
						return nil
					end
				else
					return value
				end
			end
		})
		return p[funcName](args)
	end
end

----------------------------------------------------------------------------
-- Main function
----------------------------------------------------------------------------

p.main = makeInvokeFunc('_main')

function p._main(args)
	--[[
	-- This function defines logic flow for the module.
	-- @args - table of arguments passed by the user
	-- 
	-- Messages:
	-- 'main-div-id' --&gt; 'template-documentation'
	-- 'main-div-classes' --&gt; 'template-documentation iezoomfix'
	--]]
	local env = p.getEnvironment(args)
	local root = mw.html.create()
	root
		:wikitext(p.protectionTemplate(env))
		:wikitext(p.sandboxNotice(args, env))
		 -- This div tag is from {{documentation/start box}}, but moving it here
		 -- so that we don't have to worry about unclosed tags.
		:tag('div')
			:attr('id', message('main-div-id'))
			:addClass(message('main-div-classes'))
			:newline()
			:wikitext(p._startBox(args, env))
			:wikitext(p._content(args, env))
			:tag('div')
				:css('clear', 'both') -- So right or left floating items don't stick out of the doc box.
				:newline()
				:done()
			:done()
		:wikitext(p._endBox(args, env))
		:wikitext(p.addTrackingCategories(env))
	return tostring(root)
end

----------------------------------------------------------------------------
-- Environment settings
----------------------------------------------------------------------------

function p.getEnvironment(args)
	--[[
	-- Returns a table with information about the environment, including title objects and other namespace- or
	-- path-related data.
	-- @args - table of arguments passed by the user
	--
	-- Title objects include:
	-- env.title - the page we are making documentation for (usually the current title)
	-- env.templateTitle - the template (or module, file, etc.)
	-- env.docTitle - the /doc subpage.
	-- env.sandboxTitle - the /sandbox subpage.
	-- env.testcasesTitle - the /testcases subpage.
	-- env.printTitle - the print version of the template, located at the /Print subpage.
	--
	-- Data includes:
	-- env.protectionLevels - the protection levels table of the title object.
	-- env.subjectSpace - the number of the title's subject namespace.
	-- env.docSpace - the number of the namespace the title puts its documentation in.
	-- env.docpageBase - the text of the base page of the /doc, /sandbox and /testcases pages, with namespace.
	-- env.compareUrl - URL of the Special:ComparePages page comparing the sandbox with the template.
	-- 
	-- All table lookups are passed through pcall so that errors are caught. If an error occurs, the value
	-- returned will be nil.
	--]]
	
	local env, envFuncs = {}, {}

	-- Set up the metatable. If triggered we call the corresponding function in the envFuncs table. The value
	-- returned by that function is memoized in the env table so that we don't call any of the functions
	-- more than once. (Nils won't be memoized.)
	setmetatable(env, {
		__index = function (t, key)
			local envFunc = envFuncs[key]
			if envFunc then
				local success, val = pcall(envFunc)
				if success then
					env[key] = val -- Memoise the value.
					return val
				end
			end
			return nil
		end
	})	

	function envFuncs.title()
		-- The title object for the current page, or a test page passed with args.page.
		local title
		local titleArg = args.page
		if titleArg then
			title = mw.title.new(titleArg)
		else
			title = mw.title.getCurrentTitle()
		end
		return title
	end

	function envFuncs.templateTitle()
		--[[
		-- The template (or module, etc.) title object.
		-- Messages:
		-- 'sandbox-subpage' --&gt; 'sandbox'
		-- 'testcases-subpage' --&gt; 'testcases'
		--]]
		local subjectSpace = env.subjectSpace
		local title = env.title
		local subpage = title.subpageText
		if subpage == message('sandbox-subpage') or subpage == message('testcases-subpage') then
			return mw.title.makeTitle(subjectSpace, title.baseText)
		else
			return mw.title.makeTitle(subjectSpace, title.text)
		end
	end

	function envFuncs.docTitle()
		--[[
		-- Title object of the /doc subpage.
		-- Messages:
		-- 'doc-subpage' --&gt; 'doc'
		--]]
		local title = env.title
		local docname = args[1] -- User-specified doc page.
		local docpage
		if docname then
			docpage = docname
		else
			docpage = env.docpageBase .. '/' .. message('doc-subpage')
		end
		return mw.title.new(docpage)
	end
	
	function envFuncs.sandboxTitle()
		--[[
		-- Title object for the /sandbox subpage.
		-- Messages:
		-- 'sandbox-subpage' --&gt; 'sandbox'
		--]]
		return mw.title.new(env.docpageBase .. '/' .. message('sandbox-subpage'))
	end
	
	function envFuncs.testcasesTitle()
		--[[
		-- Title object for the /testcases subpage.
		-- Messages:
		-- 'testcases-subpage' --&gt; 'testcases'
		--]]
		return mw.title.new(env.docpageBase .. '/' .. message('testcases-subpage'))
	end
	
	function envFuncs.printTitle()
		--[[
		-- Title object for the /Print subpage.
		-- Messages:
		-- 'print-subpage' --&gt; 'Print'
		--]]
		return env.templateTitle:subPageTitle(message('print-subpage'))
	end

	function envFuncs.protectionLevels()
		-- The protection levels table of the title object.
		return env.title.protectionLevels
	end

	function envFuncs.subjectSpace()
		-- The subject namespace number.
		return mw.site.namespaces[env.title.namespace].subject.id
	end

	function envFuncs.docSpace()
		-- The documentation namespace number. For most namespaces this is the same as the
		-- subject namespace. However, pages in the Article, File, MediaWiki or Category
		-- namespaces must have their /doc, /sandbox and /testcases pages in talk space.
		local subjectSpace = env.subjectSpace
		if subjectSpace == 0 or subjectSpace == 6 or subjectSpace == 8 or subjectSpace == 14 then
			return subjectSpace + 1
		else
			return subjectSpace
		end
	end

	function envFuncs.docpageBase()
		-- The base page of the /doc, /sandbox, and /testcases subpages.
		-- For some namespaces this is the talk page, rather than the template page.
		local templateTitle = env.templateTitle
		local docSpace = env.docSpace
		local docSpaceText = mw.site.namespaces[docSpace].name
		-- Assemble the link. docSpace is never the main namespace, so we can hardcode the colon.
		return docSpaceText .. ':' .. templateTitle.text
	end
	
	function envFuncs.compareUrl()
		-- Diff link between the sandbox and the main template using [[Khethekileko:ComparePages]].
		local templateTitle = env.templateTitle
		local sandboxTitle = env.sandboxTitle
		if templateTitle.exists and sandboxTitle.exists then
			local compareUrl = mw.uri.fullUrl(
				'Special:ComparePages',
				{page1 = templateTitle.prefixedText, page2 = sandboxTitle.prefixedText}
			)
			return tostring(compareUrl)
		else
			return nil
		end
	end		

	return env
end	

----------------------------------------------------------------------------
-- Auxiliary templates
----------------------------------------------------------------------------

function p.sandboxNotice(args, env)
	--[=[
	-- Generates a sandbox notice for display above sandbox pages.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	-- Messages:
	-- 'sandbox-notice-image' --&gt; '[[Isimumathi:Sandbox.svg|50px|alt=|link=]]'
	-- 'sandbox-notice-blurb' --&gt; 'This is the $1 for $2.'
	-- 'sandbox-notice-diff-blurb' --&gt; 'This is the $1 for $2 ($3).'
	-- 'sandbox-notice-pagetype-template' --&gt; '[[Wikipedia:Template test cases|template sandbox]] page'
	-- 'sandbox-notice-pagetype-module' --&gt; '[[Wikipedia:Template test cases|module sandbox]] page'
	-- 'sandbox-notice-pagetype-other' --&gt; 'sandbox page'
	-- 'sandbox-notice-compare-link-display' --&gt; 'diff'
	-- 'sandbox-notice-testcases-blurb' --&gt; 'See also the companion subpage for $1.'
	-- 'sandbox-notice-testcases-link-display' --&gt; 'test cases'
	-- 'sandbox-category' --&gt; 'Template sandboxes'
	--]=]
	local title = env.title
	local sandboxTitle = env.sandboxTitle
	local templateTitle = env.templateTitle
	local subjectSpace = env.subjectSpace
	if not (subjectSpace and title and sandboxTitle and templateTitle and mw.title.equals(title, sandboxTitle)) then
		return nil
	end
	-- Build the table of arguments to pass to {{ombox}}. We need just two fields, &quot;image&quot; and &quot;text&quot;.
	local omargs = {}
	omargs.image = message('sandbox-notice-image')
	-- Get the text. We start with the opening blurb, which is something like
	-- &quot;This is the template sandbox for [[Umhlahlandlelasakhiwo:Foo]] (diff).&quot;
	local text = ''
	local pagetype
	if subjectSpace == 10 then
		pagetype = message('sandbox-notice-pagetype-template')
	elseif subjectSpace == 828 then
		pagetype = message('sandbox-notice-pagetype-module')
	else
		pagetype = message('sandbox-notice-pagetype-other')
	end
	local templateLink = makeWikilink(templateTitle.prefixedText)
	local compareUrl = env.compareUrl
	if compareUrl then
		local compareDisplay = message('sandbox-notice-compare-link-display')
		local compareLink = makeUrlLink(compareUrl, compareDisplay)
		text = text .. message('sandbox-notice-diff-blurb', {pagetype, templateLink, compareLink})
	else
		text = text .. message('sandbox-notice-blurb', {pagetype, templateLink})
	end
	-- Get the test cases page blurb if the page exists. This is something like
	-- &quot;See also the companion subpage for [[Umhlahlandlelasakhiwo:Foo/testcases|test cases]].&quot;
	local testcasesTitle = env.testcasesTitle
	if testcasesTitle and testcasesTitle.exists then
		if testcasesTitle.namespace == mw.site.namespaces.Module.id then
			local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display')
			local testcasesRunLinkDisplay = message('sandbox-notice-testcases-run-link-display')
			local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay)
			local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay)
			text = text .. '&lt;br /&gt;' .. message('sandbox-notice-testcases-run-blurb', {testcasesLink, testcasesRunLink})
		else
			local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display')
			local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay)
			text = text .. '&lt;br /&gt;' .. message('sandbox-notice-testcases-blurb', {testcasesLink})
		end
	end
	-- Add the sandbox to the sandbox category.
	text = text .. makeCategoryLink(message('sandbox-category'))
	omargs.text = text
	local ret = '&lt;div style=&quot;clear: both;&quot;&gt;&lt;/div&gt;'
	ret = ret .. messageBox.main('ombox', omargs)
	return ret
end

function p.protectionTemplate(env)
	-- Generates the padlock icon in the top right.
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- Messages:
	-- 'protection-template' --&gt; 'pp-template'
	-- 'protection-template-args' --&gt; {docusage = 'yes'}
	local protectionLevels, mProtectionBanner
	local title = env.title
	protectionLevels = env.protectionLevels
	if not protectionLevels then
		return nil
	end
	local editProt = protectionLevels.edit and protectionLevels.edit[1]
	local moveProt = protectionLevels.move and protectionLevels.move[1]
	if editProt then
		-- The page is edit-protected.
		mProtectionBanner = require('Module:Protection banner')
		local reason = message('protection-reason-edit')
		return mProtectionBanner._main{reason, small = true}
	elseif moveProt and moveProt ~= 'autoconfirmed' then
		-- The page is move-protected but not edit-protected. Exclude move
		-- protection with the level &quot;autoconfirmed&quot;, as this is equivalent to
		-- no move protection at all.
		mProtectionBanner = require('Module:Protection banner')
		return mProtectionBanner._main{action = 'move', small = true}
	else
		return nil
	end
end

----------------------------------------------------------------------------
-- Start box
----------------------------------------------------------------------------

p.startBox = makeInvokeFunc('_startBox')

function p._startBox(args, env)
	--[[
	-- This function generates the start box.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	-- The actual work is done by p.makeStartBoxLinksData and p.renderStartBoxLinks which make
	-- the [view] [edit] [history] [purge] links, and by p.makeStartBoxData and p.renderStartBox
	-- which generate the box HTML.
	--]]
	env = env or p.getEnvironment(args)
	local links
	local content = args.content
	if not content then
		-- No need to include the links if the documentation is on the template page itself.
		local linksData = p.makeStartBoxLinksData(args, env)
		if linksData then
			links = p.renderStartBoxLinks(linksData)
		end
	end
	-- Generate the start box html.
	local data = p.makeStartBoxData(args, env, links)
	if data then
		return p.renderStartBox(data)
	else
		-- User specified no heading.
		return nil
	end
end

function p.makeStartBoxLinksData(args, env)
	--[[
	-- Does initial processing of data to make the [view] [edit] [history] [purge] links.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	-- Messages:
	-- 'view-link-display' --&gt; 'view'
	-- 'edit-link-display' --&gt; 'edit'
	-- 'history-link-display' --&gt; 'history'
	-- 'purge-link-display' --&gt; 'purge'
	-- 'file-docpage-preload' --&gt; 'Template:Documentation/preload-filespace'
	-- 'module-preload' --&gt; 'Template:Documentation/preload-module-doc'
	-- 'docpage-preload' --&gt; 'Template:Documentation/preload'
	-- 'create-link-display' --&gt; 'create'
	--]]
	local subjectSpace = env.subjectSpace
	local title = env.title
	local docTitle = env.docTitle
	if not title or not docTitle then
		return nil
	end

	local data = {}
	data.title = title
	data.docTitle = docTitle
	-- View, display, edit, and purge links if /doc exists.
	data.viewLinkDisplay = message('view-link-display')
	data.editLinkDisplay = message('edit-link-display')
	data.historyLinkDisplay = message('history-link-display')
	data.purgeLinkDisplay = message('purge-link-display')
	-- Create link if /doc doesn't exist.
	local preload = args.preload
	if not preload then
		if subjectSpace == 6 then -- File namespace
			preload = message('file-docpage-preload')
		elseif subjectSpace == 828 then -- Module namespace
			preload = message('module-preload')
		else
			preload = message('docpage-preload')
		end
	end
	data.preload = preload
	data.createLinkDisplay = message('create-link-display')
	return data
end

function p.renderStartBoxLinks(data)
	--[[
	-- Generates the [view][edit][history][purge] or [create] links from the data table.
	-- @data - a table of data generated by p.makeStartBoxLinksData
	--]]
	
	local function escapeBrackets(s)
		-- Escapes square brackets with HTML entities.
		s = s:gsub('%[', '&amp;#91;') -- Replace square brackets with HTML entities.
		s = s:gsub('%]', '&amp;#93;')
		return s
	end

	local ret
	local docTitle = data.docTitle
	local title = data.title
	if docTitle.exists then
		local viewLink = makeWikilink(docTitle.prefixedText, data.viewLinkDisplay)
		local editLink = makeUrlLink(docTitle:fullUrl{action = 'edit'}, data.editLinkDisplay)
		local historyLink = makeUrlLink(docTitle:fullUrl{action = 'history'}, data.historyLinkDisplay)
		local purgeLink = makeUrlLink(title:fullUrl{action = 'purge'}, data.purgeLinkDisplay)
		ret = '[%s] [%s] [%s] [%s]'
		ret = escapeBrackets(ret)
		ret = mw.ustring.format(ret, viewLink, editLink, historyLink, purgeLink)
	else
		local createLink = makeUrlLink(docTitle:fullUrl{action = 'edit', preload = data.preload}, data.createLinkDisplay)
		ret = '[%s]'
		ret = escapeBrackets(ret)
		ret = mw.ustring.format(ret, createLink)
	end
	return ret
end

function p.makeStartBoxData(args, env, links)
	--[=[
	-- Does initial processing of data to pass to the start-box render function, p.renderStartBox.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- @links - a string containing the [view][edit][history][purge] links - could be nil if there's an error.
	--
	-- Messages:
	-- 'documentation-icon-wikitext' --&gt; '[[Isimumathi:Test Template Info-Icon - Version (2).svg|50px|link=|alt=]]'
	-- 'template-namespace-heading' --&gt; 'Template documentation'
	-- 'module-namespace-heading' --&gt; 'Module documentation'
	-- 'file-namespace-heading' --&gt; 'Summary'
	-- 'other-namespaces-heading' --&gt; 'Documentation'
	-- 'start-box-linkclasses' --&gt; 'mw-editsection-like plainlinks'
	-- 'start-box-link-id' --&gt; 'doc_editlinks'
	-- 'testcases-create-link-display' --&gt; 'create'
	--]=]
	local subjectSpace = env.subjectSpace
	if not subjectSpace then
		-- Default to an &quot;other namespaces&quot; namespace, so that we get at least some output
		-- if an error occurs.
		subjectSpace = 2
	end
	local data = {}
	
	-- Heading
	local heading = args.heading -- Blank values are not removed.
	if heading == '' then
		-- Don't display the start box if the heading arg is defined but blank.
		return nil
	end
	if heading then
		data.heading = heading
	elseif subjectSpace == 10 then -- Template namespace
		data.heading = message('documentation-icon-wikitext') .. ' ' .. message('template-namespace-heading')
	elseif subjectSpace == 828 then -- Module namespace
		data.heading = message('documentation-icon-wikitext') .. ' ' .. message('module-namespace-heading')
	elseif subjectSpace == 6 then -- File namespace
		data.heading = message('file-namespace-heading')
	else
		data.heading = message('other-namespaces-heading')
	end
	
	-- Heading CSS
	local headingStyle = args['heading-style']
	if headingStyle then
		data.headingStyleText = headingStyle
	elseif subjectSpace == 10 then
		-- We are in the template or template talk namespaces.
		data.headingFontWeight = 'bold'
		data.headingFontSize = '125%'
	else
		data.headingFontSize = '150%'
	end
	
	-- Data for the [view][edit][history][purge] or [create] links.
	if links then
		data.linksClass = message('start-box-linkclasses')
		data.linksId = message('start-box-link-id')
		data.links = links
	end
	
	return data
end

function p.renderStartBox(data)
	-- Renders the start box html.
	-- @data - a table of data generated by p.makeStartBoxData.
	local sbox = mw.html.create('div')
	sbox
		:css('padding-bottom', '3px')
		:css('border-bottom', '1px solid #aaa')
		:css('margin-bottom', '1ex')
		:newline()
		:tag('span')
			:cssText(data.headingStyleText)
			:css('font-weight', data.headingFontWeight)
			:css('font-size', data.headingFontSize)
			:wikitext(data.heading)
	local links = data.links
	if links then
		sbox:tag('span')
			:addClass(data.linksClass)
			:attr('id', data.linksId)
			:wikitext(links)
	end
	return tostring(sbox)
end

----------------------------------------------------------------------------
-- Documentation content
----------------------------------------------------------------------------

p.content = makeInvokeFunc('_content')

function p._content(args, env)
	-- Displays the documentation contents
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	env = env or p.getEnvironment(args)
	local docTitle = env.docTitle
	local content = args.content
	if not content and docTitle and docTitle.exists then
		content = args._content or mw.getCurrentFrame():expandTemplate{title = docTitle.prefixedText}
	end
	-- The line breaks below are necessary so that &quot;=== Headings ===&quot; at the start and end
	-- of docs are interpreted correctly.
	return '\n' .. (content or '') .. '\n' 
end

p.contentTitle = makeInvokeFunc('_contentTitle')

function p._contentTitle(args, env)
	env = env or p.getEnvironment(args)
	local docTitle = env.docTitle
	if not args.content and docTitle and docTitle.exists then
		return docTitle.prefixedText
	else
		return ''
	end
end

----------------------------------------------------------------------------
-- End box
----------------------------------------------------------------------------

p.endBox = makeInvokeFunc('_endBox')

function p._endBox(args, env)
	--[=[
	-- This function generates the end box (also known as the link box).
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	-- Messages:
	-- 'fmbox-id' --&gt; 'documentation-meta-data'
	-- 'fmbox-style' --&gt; 'background-color: #ecfcf4'
	-- 'fmbox-textstyle' --&gt; 'font-style: italic'
	-- 
	-- The HTML is generated by the {{fmbox}} template, courtesy of [[Module:Message box]].
	--]=]
	
	-- Get environment data.
	env = env or p.getEnvironment(args)
	local subjectSpace = env.subjectSpace
	local docTitle = env.docTitle
	if not subjectSpace or not docTitle then
		return nil
	end
		
	-- Check whether we should output the end box at all. Add the end
	-- box by default if the documentation exists or if we are in the
	-- user, module or template namespaces.
	local linkBox = args['link box']
	if linkBox == 'off'
		or not (
			docTitle.exists
			or subjectSpace == 2
			or subjectSpace == 828
			or subjectSpace == 10
		)
	then
		return nil
	end

	-- Assemble the arguments for {{fmbox}}.
	local fmargs = {}
	fmargs.id = message('fmbox-id') -- Sets 'documentation-meta-data'
	fmargs.image = 'none'
	fmargs.style = message('fmbox-style') -- Sets 'background-color: #ecfcf4'
	fmargs.textstyle = message('fmbox-textstyle') -- 'font-style: italic;'

	-- Assemble the fmbox text field.
	local text = ''
	if linkBox then
		text = text .. linkBox
	else
		text = text .. (p.makeDocPageBlurb(args, env) or '') -- &quot;This documentation is transcluded from [[||Foo]].&quot; 
		if subjectSpace == 2 or subjectSpace == 10 or subjectSpace == 828 then
			-- We are in the user, template or module namespaces.
			-- Add sandbox and testcases links.
			-- &quot;Editors can experiment in this template's sandbox and testcases pages.&quot;
			text = text .. (p.makeExperimentBlurb(args, env) or '')
			text = text .. '&lt;br /&gt;'
			if not args.content and not args[1] then
				-- &quot;Please add categories to the /doc subpage.&quot;
				-- Don't show this message with inline docs or with an explicitly specified doc page,
				-- as then it is unclear where to add the categories.
				text = text .. (p.makeCategoriesBlurb(args, env) or '')
			end
			text = text .. ' ' .. (p.makeSubpagesBlurb(args, env) or '') --&quot;Subpages of this template&quot;
			local printBlurb = p.makePrintBlurb(args, env) -- Two-line blurb about print versions of templates.
			if printBlurb then
				text = text .. '&lt;br /&gt;' .. printBlurb
			end
		end
	end
	fmargs.text = text

	return messageBox.main('fmbox', fmargs)
end

function p.makeDocPageBlurb(args, env)
	--[=[
	-- Makes the blurb &quot;This documentation is transcluded from [[Umhlahlandlelasakhiwo:Foo]] (edit, history)&quot;.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	-- Messages:
	-- 'edit-link-display' --&gt; 'edit'
	-- 'history-link-display' --&gt; 'history'
	-- 'transcluded-from-blurb' --&gt; 
	-- 'The above [[Wikipedia:Template documentation|documentation]] 
	-- is [[Wikipedia:Transclusion|transcluded]] from $1.'
	-- 'module-preload' --&gt; 'Template:Documentation/preload-module-doc'
	-- 'create-link-display' --&gt; 'create'
	-- 'create-module-doc-blurb' --&gt;
	-- 'You might want to $1 a documentation page for this [[Wikipedia:Lua|Scribunto module]].'
	--]=]
	local docTitle = env.docTitle
	if not docTitle then
		return nil
	end
	local ret
	if docTitle.exists then
		-- /doc exists; link to it.
		local docLink = makeWikilink(docTitle.prefixedText)
		local editUrl = docTitle:fullUrl{action = 'edit'}
		local editDisplay = message('edit-link-display')
		local editLink = makeUrlLink(editUrl, editDisplay)
		local historyUrl = docTitle:fullUrl{action = 'history'}
		local historyDisplay = message('history-link-display')
		local historyLink = makeUrlLink(historyUrl, historyDisplay)
		ret = message('transcluded-from-blurb', {docLink})
			.. ' '
			.. makeToolbar(editLink, historyLink)
			.. '&lt;br /&gt;'
	elseif env.subjectSpace == 828 then
		-- /doc does not exist; ask to create it.
		local createUrl = docTitle:fullUrl{action = 'edit', preload = message('module-preload')}
		local createDisplay = message('create-link-display')
		local createLink = makeUrlLink(createUrl, createDisplay)
		ret = message('create-module-doc-blurb', {createLink})
			.. '&lt;br /&gt;'
	end
	return ret
end

function p.makeExperimentBlurb(args, env)
	--[[
	-- Renders the text &quot;Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages.&quot;
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	-- Messages:
	-- 'sandbox-link-display' --&gt; 'sandbox'
	-- 'sandbox-edit-link-display' --&gt; 'edit'
	-- 'compare-link-display' --&gt; 'diff'
	-- 'module-sandbox-preload' --&gt; 'Template:Documentation/preload-module-sandbox'
	-- 'template-sandbox-preload' --&gt; 'Template:Documentation/preload-sandbox'
	-- 'sandbox-create-link-display' --&gt; 'create'
	-- 'mirror-edit-summary' --&gt; 'Create sandbox version of $1'
	-- 'mirror-link-display' --&gt; 'mirror'
	-- 'mirror-link-preload' --&gt; 'Template:Documentation/mirror'
	-- 'sandbox-link-display' --&gt; 'sandbox'
	-- 'testcases-link-display' --&gt; 'testcases'
	-- 'testcases-edit-link-display'--&gt; 'edit'
	-- 'template-sandbox-preload' --&gt; 'Template:Documentation/preload-sandbox'
	-- 'testcases-create-link-display' --&gt; 'create'
	-- 'testcases-link-display' --&gt; 'testcases'
	-- 'testcases-edit-link-display' --&gt; 'edit'
	-- 'module-testcases-preload' --&gt; 'Template:Documentation/preload-module-testcases'
	-- 'template-testcases-preload' --&gt; 'Template:Documentation/preload-testcases'
	-- 'experiment-blurb-module' --&gt; 'Editors can experiment in this module's $1 and $2 pages.'
	-- 'experiment-blurb-template' --&gt; 'Editors can experiment in this template's $1 and $2 pages.'
	--]]
	local subjectSpace = env.subjectSpace
	local templateTitle = env.templateTitle
	local sandboxTitle = env.sandboxTitle
	local testcasesTitle = env.testcasesTitle
	local templatePage = templateTitle.prefixedText
	if not subjectSpace or not templateTitle or not sandboxTitle or not testcasesTitle then
		return nil
	end
	-- Make links.
	local sandboxLinks, testcasesLinks
	if sandboxTitle.exists then
		local sandboxPage = sandboxTitle.prefixedText
		local sandboxDisplay = message('sandbox-link-display')
		local sandboxLink = makeWikilink(sandboxPage, sandboxDisplay)
		local sandboxEditUrl = sandboxTitle:fullUrl{action = 'edit'}
		local sandboxEditDisplay = message('sandbox-edit-link-display')
		local sandboxEditLink = makeUrlLink(sandboxEditUrl, sandboxEditDisplay)
		local compareUrl = env.compareUrl
		local compareLink
		if compareUrl then
			local compareDisplay = message('compare-link-display')
			compareLink = makeUrlLink(compareUrl, compareDisplay)
		end
		sandboxLinks = sandboxLink .. ' ' .. makeToolbar(sandboxEditLink, compareLink)
	else
		local sandboxPreload
		if subjectSpace == 828 then
			sandboxPreload = message('module-sandbox-preload')
		else
			sandboxPreload = message('template-sandbox-preload')
		end
		local sandboxCreateUrl = sandboxTitle:fullUrl{action = 'edit', preload = sandboxPreload}
		local sandboxCreateDisplay = message('sandbox-create-link-display')
		local sandboxCreateLink = makeUrlLink(sandboxCreateUrl, sandboxCreateDisplay)
		local mirrorSummary = message('mirror-edit-summary', {makeWikilink(templatePage)})
		local mirrorPreload = message('mirror-link-preload')
		local mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = mirrorPreload, summary = mirrorSummary}
		if subjectSpace == 828 then
			mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = templateTitle.prefixedText, summary = mirrorSummary}
		end
		local mirrorDisplay = message('mirror-link-display')
		local mirrorLink = makeUrlLink(mirrorUrl, mirrorDisplay)
		sandboxLinks = message('sandbox-link-display') .. ' ' .. makeToolbar(sandboxCreateLink, mirrorLink)
	end
	if testcasesTitle.exists then
		local testcasesPage = testcasesTitle.prefixedText
		local testcasesDisplay = message('testcases-link-display')
		local testcasesLink = makeWikilink(testcasesPage, testcasesDisplay)
		local testcasesEditUrl = testcasesTitle:fullUrl{action = 'edit'}
		local testcasesEditDisplay = message('testcases-edit-link-display')
		local testcasesEditLink = makeUrlLink(testcasesEditUrl, testcasesEditDisplay)
		-- for Modules, add testcases run link if exists
		if subjectSpace == 828 and testcasesTitle.talkPageTitle and testcasesTitle.talkPageTitle.exists then
			local testcasesRunLinkDisplay = message('testcases-run-link-display')
			local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay)
			testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink, testcasesRunLink)
		else
			testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink)
		end
	else
		local testcasesPreload
		if subjectSpace == 828 then
			testcasesPreload = message('module-testcases-preload')
		else
			testcasesPreload = message('template-testcases-preload')
		end
		local testcasesCreateUrl = testcasesTitle:fullUrl{action = 'edit', preload = testcasesPreload}
		local testcasesCreateDisplay = message('testcases-create-link-display')
		local testcasesCreateLink = makeUrlLink(testcasesCreateUrl, testcasesCreateDisplay)
		testcasesLinks = message('testcases-link-display') .. ' ' .. makeToolbar(testcasesCreateLink)
	end
	local messageName
	if subjectSpace == 828 then
		messageName = 'experiment-blurb-module'
	else
		messageName = 'experiment-blurb-template'
	end
	return message(messageName, {sandboxLinks, testcasesLinks})
end

function p.makeCategoriesBlurb(args, env)
	--[[
	-- Generates the text &quot;Please add categories to the /doc subpage.&quot;
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- Messages:
	-- 'doc-link-display' --&gt; '/doc'
	-- 'add-categories-blurb' --&gt; 'Please add categories to the $1 subpage.'
	--]]
	local docTitle = env.docTitle
	if not docTitle then
		return nil
	end
	local docPathLink = makeWikilink(docTitle.prefixedText, message('doc-link-display'))
	return message('add-categories-blurb', {docPathLink})
end

function p.makeSubpagesBlurb(args, env)
	--[[
	-- Generates the &quot;Subpages of this template&quot; link.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	
	-- Messages:
	-- 'template-pagetype' --&gt; 'template'
	-- 'module-pagetype' --&gt; 'module'
	-- 'default-pagetype' --&gt; 'page'
	-- 'subpages-link-display' --&gt; 'Subpages of this $1'
	--]]
	local subjectSpace = env.subjectSpace
	local templateTitle = env.templateTitle
	if not subjectSpace or not templateTitle then
		return nil
	end
	local pagetype
	if subjectSpace == 10 then
		pagetype = message('template-pagetype')
	elseif subjectSpace == 828 then
		pagetype = message('module-pagetype')
	else
		pagetype = message('default-pagetype')
	end
	local subpagesLink = makeWikilink(
		'Special:PrefixIndex/' .. templateTitle.prefixedText .. '/',
		message('subpages-link-display', {pagetype})
	)
	return message('subpages-blurb', {subpagesLink})
end

function p.makePrintBlurb(args, env)
	--[=[
	-- Generates the blurb displayed when there is a print version of the template available.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	--
	-- Messages:
	-- 'print-link-display' --&gt; '/Print'
	-- 'print-blurb' --&gt; 'A [[Lisizo:Books/for experts#Improving the book layout|print version]]'
	--		.. ' of this template exists at $1.'
	--		.. ' If you make a change to this template, please update the print version as well.'
	-- 'display-print-category' --&gt; true
	-- 'print-category' --&gt; 'Templates with print versions'
	--]=]
	local printTitle = env.printTitle
	if not printTitle then
		return nil
	end
	local ret
	if printTitle.exists then
		local printLink = makeWikilink(printTitle.prefixedText, message('print-link-display'))
		ret = message('print-blurb', {printLink})
		local displayPrintCategory = message('display-print-category', nil, 'boolean')
		if displayPrintCategory then
			ret = ret .. makeCategoryLink(message('print-category'))
		end
	end
	return ret
end

----------------------------------------------------------------------------
-- Tracking categories
----------------------------------------------------------------------------

function p.addTrackingCategories(env)
	--[[
	-- Check if {{documentation}} is transcluded on a /doc or /testcases page.
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	
	-- Messages:
	-- 'display-strange-usage-category' --&gt; true
	-- 'doc-subpage' --&gt; 'doc'
	-- 'testcases-subpage' --&gt; 'testcases'
	-- 'strange-usage-category' --&gt; 'Wikipedia pages with strange ((documentation)) usage'
	-- 
	-- /testcases pages in the module namespace are not categorised, as they may have
	-- {{documentation}} transcluded automatically.
	--]]
	local title = env.title
	local subjectSpace = env.subjectSpace
	if not title or not subjectSpace then
		return nil
	end
	local subpage = title.subpageText
	local ret = ''
	if message('display-strange-usage-category', nil, 'boolean')
		and (
			subpage == message('doc-subpage')
			or subjectSpace ~= 828 and subpage == message('testcases-subpage')
		)
	then
		ret = ret .. makeCategoryLink(message('strange-usage-category'))
	end
	return ret
end

return p</text>
      <sha1>ehrpfjhio5rkj04kvpq98th28bl70nn</sha1>
    </revision>
    <revision>
      <id>3378</id>
      <parentid>441</parentid>
      <timestamp>2025-07-11T10:52:53Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <origin>3378</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="36685" sha1="jf2f51u5rzim7qgb93sv92cvfe6ak0s" xml:space="preserve">-- This module implements {{documentation}}.

-- Get required modules.
local getArgs = require('Module:Arguments').getArgs
local messageBox = require('Module:Message box')

-- Get the config table.
local cfg = mw.loadData('Module:Documentation/config')

local p = {}

-- Often-used functions.
local ugsub = mw.ustring.gsub

----------------------------------------------------------------------------
-- Helper functions
--
-- These are defined as local functions, but are made available in the p
-- table for testing purposes.
----------------------------------------------------------------------------

local function message(cfgKey, valArray, expectType)
	--[[
	-- Gets a message from the cfg table and formats it if appropriate.
	-- The function raises an error if the value from the cfg table is not
	-- of the type expectType. The default type for expectType is 'string'.
	-- If the table valArray is present, strings such as $1, $2 etc. in the
	-- message are substituted with values from the table keys [1], [2] etc.
	-- For example, if the message &quot;foo-message&quot; had the value 'Foo $2 bar $1.',
	-- message('foo-message', {'baz', 'qux'}) would return &quot;Foo qux bar baz.&quot;
	--]]
	local msg = cfg[cfgKey]
	expectType = expectType or 'string'
	if type(msg) ~= expectType then
		error('message: type error in message cfg.' .. cfgKey .. ' (' .. expectType .. ' expected, got ' .. type(msg) .. ')', 2)
	end
	if not valArray then
		return msg
	end

	local function getMessageVal(match)
		match = tonumber(match)
		return valArray[match] or error('message: no value found for key $' .. match .. ' in message cfg.' .. cfgKey, 4)
	end

	local ret = ugsub(msg, '$([1-9][0-9]*)', getMessageVal)
	return ret
end

p.message = message

local function makeWikilink(page, display)
	if display then
		return mw.ustring.format('[[%s|%s]]', page, display)
	else
		return mw.ustring.format('[[%s]]', page)
	end
end

p.makeWikilink = makeWikilink

local function makeCategoryLink(cat, sort)
	local catns = mw.site.namespaces[14].name
	return makeWikilink(catns .. ':' .. cat, sort)
end

p.makeCategoryLink = makeCategoryLink

local function makeUrlLink(url, display)
	return mw.ustring.format('[%s %s]', url, display)
end

p.makeUrlLink = makeUrlLink

local function makeToolbar(...)
	local ret = {}
	local lim = select('#', ...)
	if lim &lt; 1 then
		return nil
	end
	for i = 1, lim do
		ret[#ret + 1] = select(i, ...)
	end
	return '&lt;small style=&quot;font-style: normal;&quot;&gt;(' .. table.concat(ret, ' &amp;#124; ') .. ')&lt;/small&gt;'
end	

p.makeToolbar = makeToolbar

----------------------------------------------------------------------------
-- Argument processing
----------------------------------------------------------------------------

local function makeInvokeFunc(funcName)
	return function (frame)
		local args = getArgs(frame, {
			valueFunc = function (key, value)
				if type(value) == 'string' then
					value = value:match('^%s*(.-)%s*$') -- Remove whitespace.
					if key == 'heading' or value ~= '' then
						return value
					else
						return nil
					end
				else
					return value
				end
			end
		})
		return p[funcName](args)
	end
end

----------------------------------------------------------------------------
-- Main function
----------------------------------------------------------------------------

p.main = makeInvokeFunc('_main')

function p._main(args)
	--[[
	-- This function defines logic flow for the module.
	-- @args - table of arguments passed by the user
	-- 
	-- Messages:
	-- 'main-div-id' --&gt; 'template-documentation'
	-- 'main-div-classes' --&gt; 'template-documentation iezoomfix'
	--]]
	local env = p.getEnvironment(args)
	local root = mw.html.create()
	root
		:wikitext(p.protectionTemplate(env))
		:wikitext(p.sandboxNotice(args, env))
		 -- This div tag is from {{documentation/start box}}, but moving it here
		 -- so that we don't have to worry about unclosed tags.
		:tag('div')
			:attr('id', message('main-div-id'))
			:addClass(message('main-div-classes'))
			:newline()
			:wikitext(p._startBox(args, env))
			:wikitext(p._content(args, env))
			:tag('div')
				:css('clear', 'both') -- So right or left floating items don't stick out of the doc box.
				:newline()
				:done()
			:done()
		:wikitext(p._endBox(args, env))
		:wikitext(p.addTrackingCategories(env))
	return tostring(root)
end

----------------------------------------------------------------------------
-- Environment settings
----------------------------------------------------------------------------

function p.getEnvironment(args)
	--[[
	-- Returns a table with information about the environment, including title objects and other namespace- or
	-- path-related data.
	-- @args - table of arguments passed by the user
	--
	-- Title objects include:
	-- env.title - the page we are making documentation for (usually the current title)
	-- env.templateTitle - the template (or module, file, etc.)
	-- env.docTitle - the /doc subpage.
	-- env.sandboxTitle - the /sandbox subpage.
	-- env.testcasesTitle - the /testcases subpage.
	-- env.printTitle - the print version of the template, located at the /Print subpage.
	--
	-- Data includes:
	-- env.protectionLevels - the protection levels table of the title object.
	-- env.subjectSpace - the number of the title's subject namespace.
	-- env.docSpace - the number of the namespace the title puts its documentation in.
	-- env.docpageBase - the text of the base page of the /doc, /sandbox and /testcases pages, with namespace.
	-- env.compareUrl - URL of the Special:ComparePages page comparing the sandbox with the template.
	-- 
	-- All table lookups are passed through pcall so that errors are caught. If an error occurs, the value
	-- returned will be nil.
	--]]
	
	local env, envFuncs = {}, {}

	-- Set up the metatable. If triggered we call the corresponding function in the envFuncs table. The value
	-- returned by that function is memoized in the env table so that we don't call any of the functions
	-- more than once. (Nils won't be memoized.)
	setmetatable(env, {
		__index = function (t, key)
			local envFunc = envFuncs[key]
			if envFunc then
				local success, val = pcall(envFunc)
				if success then
					env[key] = val -- Memoise the value.
					return val
				end
			end
			return nil
		end
	})	

	function envFuncs.title()
		-- The title object for the current page, or a test page passed with args.page.
		local title
		local titleArg = args.page
		if titleArg then
			title = mw.title.new(titleArg)
		else
			title = mw.title.getCurrentTitle()
		end
		return title
	end

	function envFuncs.templateTitle()
		--[[
		-- The template (or module, etc.) title object.
		-- Messages:
		-- 'sandbox-subpage' --&gt; 'sandbox'
		-- 'testcases-subpage' --&gt; 'testcases'
		--]]
		local subjectSpace = env.subjectSpace
		local title = env.title
		local subpage = title.subpageText
		if subpage == message('sandbox-subpage') or subpage == message('testcases-subpage') then
			return mw.title.makeTitle(subjectSpace, title.baseText)
		else
			return mw.title.makeTitle(subjectSpace, title.text)
		end
	end

	function envFuncs.docTitle()
		--[[
		-- Title object of the /doc subpage.
		-- Messages:
		-- 'doc-subpage' --&gt; 'doc'
		--]]
		local title = env.title
		local docname = args[1] -- User-specified doc page.
		local docpage
		if docname then
			docpage = docname
		else
			docpage = env.docpageBase .. '/' .. message('doc-subpage')
		end
		return mw.title.new(docpage)
	end
	
	function envFuncs.sandboxTitle()
		--[[
		-- Title object for the /sandbox subpage.
		-- Messages:
		-- 'sandbox-subpage' --&gt; 'sandbox'
		--]]
		return mw.title.new(env.docpageBase .. '/' .. message('sandbox-subpage'))
	end
	
	function envFuncs.testcasesTitle()
		--[[
		-- Title object for the /testcases subpage.
		-- Messages:
		-- 'testcases-subpage' --&gt; 'testcases'
		--]]
		return mw.title.new(env.docpageBase .. '/' .. message('testcases-subpage'))
	end
	
	function envFuncs.printTitle()
		--[[
		-- Title object for the /Print subpage.
		-- Messages:
		-- 'print-subpage' --&gt; 'Print'
		--]]
		return env.templateTitle:subPageTitle(message('print-subpage'))
	end

	function envFuncs.protectionLevels()
		-- The protection levels table of the title object.
		return env.title.protectionLevels
	end

	function envFuncs.subjectSpace()
		-- The subject namespace number.
		return mw.site.namespaces[env.title.namespace].subject.id
	end

	function envFuncs.docSpace()
		-- The documentation namespace number. For most namespaces this is the same as the
		-- subject namespace. However, pages in the Article, File, MediaWiki or Category
		-- namespaces must have their /doc, /sandbox and /testcases pages in talk space.
		local subjectSpace = env.subjectSpace
		if subjectSpace == 0 or subjectSpace == 6 or subjectSpace == 8 or subjectSpace == 14 then
			return subjectSpace + 1
		else
			return subjectSpace
		end
	end

	function envFuncs.docpageBase()
		-- The base page of the /doc, /sandbox, and /testcases subpages.
		-- For some namespaces this is the talk page, rather than the template page.
		local templateTitle = env.templateTitle
		local docSpace = env.docSpace
		local docSpaceText = mw.site.namespaces[docSpace].name
		-- Assemble the link. docSpace is never the main namespace, so we can hardcode the colon.
		return docSpaceText .. ':' .. templateTitle.text
	end
	
	function envFuncs.compareUrl()
		-- Diff link between the sandbox and the main template using [[Special:ComparePages]].
		local templateTitle = env.templateTitle
		local sandboxTitle = env.sandboxTitle
		if templateTitle.exists and sandboxTitle.exists then
			local compareUrl = mw.uri.fullUrl(
				'Special:ComparePages',
				{page1 = templateTitle.prefixedText, page2 = sandboxTitle.prefixedText}
			)
			return tostring(compareUrl)
		else
			return nil
		end
	end		

	return env
end	

----------------------------------------------------------------------------
-- Auxiliary templates
----------------------------------------------------------------------------

function p.sandboxNotice(args, env)
	--[=[
	-- Generates a sandbox notice for display above sandbox pages.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	-- Messages:
	-- 'sandbox-notice-image' --&gt; '[[Image:Sandbox.svg|50px|alt=|link=]]'
	-- 'sandbox-notice-blurb' --&gt; 'This is the $1 for $2.'
	-- 'sandbox-notice-diff-blurb' --&gt; 'This is the $1 for $2 ($3).'
	-- 'sandbox-notice-pagetype-template' --&gt; '[[Wikipedia:Template test cases|template sandbox]] page'
	-- 'sandbox-notice-pagetype-module' --&gt; '[[Wikipedia:Template test cases|module sandbox]] page'
	-- 'sandbox-notice-pagetype-other' --&gt; 'sandbox page'
	-- 'sandbox-notice-compare-link-display' --&gt; 'diff'
	-- 'sandbox-notice-testcases-blurb' --&gt; 'See also the companion subpage for $1.'
	-- 'sandbox-notice-testcases-link-display' --&gt; 'test cases'
	-- 'sandbox-category' --&gt; 'Template sandboxes'
	--]=]
	local title = env.title
	local sandboxTitle = env.sandboxTitle
	local templateTitle = env.templateTitle
	local subjectSpace = env.subjectSpace
	if not (subjectSpace and title and sandboxTitle and templateTitle and mw.title.equals(title, sandboxTitle)) then
		return nil
	end
	-- Build the table of arguments to pass to {{ombox}}. We need just two fields, &quot;image&quot; and &quot;text&quot;.
	local omargs = {}
	omargs.image = message('sandbox-notice-image')
	-- Get the text. We start with the opening blurb, which is something like
	-- &quot;This is the template sandbox for [[Template:Foo]] (diff).&quot;
	local text = ''
	local pagetype
	if subjectSpace == 10 then
		pagetype = message('sandbox-notice-pagetype-template')
	elseif subjectSpace == 828 then
		pagetype = message('sandbox-notice-pagetype-module')
	else
		pagetype = message('sandbox-notice-pagetype-other')
	end
	local templateLink = makeWikilink(templateTitle.prefixedText)
	local compareUrl = env.compareUrl
	if compareUrl then
		local compareDisplay = message('sandbox-notice-compare-link-display')
		local compareLink = makeUrlLink(compareUrl, compareDisplay)
		text = text .. message('sandbox-notice-diff-blurb', {pagetype, templateLink, compareLink})
	else
		text = text .. message('sandbox-notice-blurb', {pagetype, templateLink})
	end
	-- Get the test cases page blurb if the page exists. This is something like
	-- &quot;See also the companion subpage for [[Template:Foo/testcases|test cases]].&quot;
	local testcasesTitle = env.testcasesTitle
	if testcasesTitle and testcasesTitle.exists then
		if testcasesTitle.namespace == mw.site.namespaces.Module.id then
			local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display')
			local testcasesRunLinkDisplay = message('sandbox-notice-testcases-run-link-display')
			local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay)
			local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay)
			text = text .. '&lt;br /&gt;' .. message('sandbox-notice-testcases-run-blurb', {testcasesLink, testcasesRunLink})
		else
			local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display')
			local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay)
			text = text .. '&lt;br /&gt;' .. message('sandbox-notice-testcases-blurb', {testcasesLink})
		end
	end
	-- Add the sandbox to the sandbox category.
	text = text .. makeCategoryLink(message('sandbox-category'))
	omargs.text = text
	local ret = '&lt;div style=&quot;clear: both;&quot;&gt;&lt;/div&gt;'
	ret = ret .. messageBox.main('ombox', omargs)
	return ret
end

function p.protectionTemplate(env)
	-- Generates the padlock icon in the top right.
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- Messages:
	-- 'protection-template' --&gt; 'pp-template'
	-- 'protection-template-args' --&gt; {docusage = 'yes'}
	local protectionLevels, mProtectionBanner
	local title = env.title
	protectionLevels = env.protectionLevels
	if not protectionLevels then
		return nil
	end
	local editProt = protectionLevels.edit and protectionLevels.edit[1]
	local moveProt = protectionLevels.move and protectionLevels.move[1]
	if editProt then
		-- The page is edit-protected.
		mProtectionBanner = require('Module:Protection banner')
		local reason = message('protection-reason-edit')
		return mProtectionBanner._main{reason, small = true}
	elseif moveProt and moveProt ~= 'autoconfirmed' then
		-- The page is move-protected but not edit-protected. Exclude move
		-- protection with the level &quot;autoconfirmed&quot;, as this is equivalent to
		-- no move protection at all.
		mProtectionBanner = require('Module:Protection banner')
		return mProtectionBanner._main{action = 'move', small = true}
	else
		return nil
	end
end

----------------------------------------------------------------------------
-- Start box
----------------------------------------------------------------------------

p.startBox = makeInvokeFunc('_startBox')

function p._startBox(args, env)
	--[[
	-- This function generates the start box.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	-- The actual work is done by p.makeStartBoxLinksData and p.renderStartBoxLinks which make
	-- the [view] [edit] [history] [purge] links, and by p.makeStartBoxData and p.renderStartBox
	-- which generate the box HTML.
	--]]
	env = env or p.getEnvironment(args)
	local links
	local content = args.content
	if not content then
		-- No need to include the links if the documentation is on the template page itself.
		local linksData = p.makeStartBoxLinksData(args, env)
		if linksData then
			links = p.renderStartBoxLinks(linksData)
		end
	end
	-- Generate the start box html.
	local data = p.makeStartBoxData(args, env, links)
	if data then
		return p.renderStartBox(data)
	else
		-- User specified no heading.
		return nil
	end
end

function p.makeStartBoxLinksData(args, env)
	--[[
	-- Does initial processing of data to make the [view] [edit] [history] [purge] links.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	-- Messages:
	-- 'view-link-display' --&gt; 'view'
	-- 'edit-link-display' --&gt; 'edit'
	-- 'history-link-display' --&gt; 'history'
	-- 'purge-link-display' --&gt; 'purge'
	-- 'file-docpage-preload' --&gt; 'Template:Documentation/preload-filespace'
	-- 'module-preload' --&gt; 'Template:Documentation/preload-module-doc'
	-- 'docpage-preload' --&gt; 'Template:Documentation/preload'
	-- 'create-link-display' --&gt; 'create'
	--]]
	local subjectSpace = env.subjectSpace
	local title = env.title
	local docTitle = env.docTitle
	if not title or not docTitle then
		return nil
	end

	local data = {}
	data.title = title
	data.docTitle = docTitle
	-- View, display, edit, and purge links if /doc exists.
	data.viewLinkDisplay = message('view-link-display')
	data.editLinkDisplay = message('edit-link-display')
	data.historyLinkDisplay = message('history-link-display')
	data.purgeLinkDisplay = message('purge-link-display')
	-- Create link if /doc doesn't exist.
	local preload = args.preload
	if not preload then
		if subjectSpace == 6 then -- File namespace
			preload = message('file-docpage-preload')
		elseif subjectSpace == 828 then -- Module namespace
			preload = message('module-preload')
		else
			preload = message('docpage-preload')
		end
	end
	data.preload = preload
	data.createLinkDisplay = message('create-link-display')
	return data
end

function p.renderStartBoxLinks(data)
	--[[
	-- Generates the [view][edit][history][purge] or [create] links from the data table.
	-- @data - a table of data generated by p.makeStartBoxLinksData
	--]]
	
	local function escapeBrackets(s)
		-- Escapes square brackets with HTML entities.
		s = s:gsub('%[', '&amp;#91;') -- Replace square brackets with HTML entities.
		s = s:gsub('%]', '&amp;#93;')
		return s
	end

	local ret
	local docTitle = data.docTitle
	local title = data.title
	if docTitle.exists then
		local viewLink = makeWikilink(docTitle.prefixedText, data.viewLinkDisplay)
		local editLink = makeUrlLink(docTitle:fullUrl{action = 'edit'}, data.editLinkDisplay)
		local historyLink = makeUrlLink(docTitle:fullUrl{action = 'history'}, data.historyLinkDisplay)
		local purgeLink = makeUrlLink(title:fullUrl{action = 'purge'}, data.purgeLinkDisplay)
		ret = '[%s] [%s] [%s] [%s]'
		ret = escapeBrackets(ret)
		ret = mw.ustring.format(ret, viewLink, editLink, historyLink, purgeLink)
	else
		local createLink = makeUrlLink(docTitle:fullUrl{action = 'edit', preload = data.preload}, data.createLinkDisplay)
		ret = '[%s]'
		ret = escapeBrackets(ret)
		ret = mw.ustring.format(ret, createLink)
	end
	return ret
end

function p.makeStartBoxData(args, env, links)
	--[=[
	-- Does initial processing of data to pass to the start-box render function, p.renderStartBox.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- @links - a string containing the [view][edit][history][purge] links - could be nil if there's an error.
	--
	-- Messages:
	-- 'documentation-icon-wikitext' --&gt; '[[File:Test Template Info-Icon - Version (2).svg|50px|link=|alt=]]'
	-- 'template-namespace-heading' --&gt; 'Template documentation'
	-- 'module-namespace-heading' --&gt; 'Module documentation'
	-- 'file-namespace-heading' --&gt; 'Summary'
	-- 'other-namespaces-heading' --&gt; 'Documentation'
	-- 'start-box-linkclasses' --&gt; 'mw-editsection-like plainlinks'
	-- 'start-box-link-id' --&gt; 'doc_editlinks'
	-- 'testcases-create-link-display' --&gt; 'create'
	--]=]
	local subjectSpace = env.subjectSpace
	if not subjectSpace then
		-- Default to an &quot;other namespaces&quot; namespace, so that we get at least some output
		-- if an error occurs.
		subjectSpace = 2
	end
	local data = {}
	
	-- Heading
	local heading = args.heading -- Blank values are not removed.
	if heading == '' then
		-- Don't display the start box if the heading arg is defined but blank.
		return nil
	end
	if heading then
		data.heading = heading
	elseif subjectSpace == 10 then -- Template namespace
		data.heading = message('documentation-icon-wikitext') .. ' ' .. message('template-namespace-heading')
	elseif subjectSpace == 828 then -- Module namespace
		data.heading = message('documentation-icon-wikitext') .. ' ' .. message('module-namespace-heading')
	elseif subjectSpace == 6 then -- File namespace
		data.heading = message('file-namespace-heading')
	else
		data.heading = message('other-namespaces-heading')
	end
	
	-- Heading CSS
	local headingStyle = args['heading-style']
	if headingStyle then
		data.headingStyleText = headingStyle
	elseif subjectSpace == 10 then
		-- We are in the template or template talk namespaces.
		data.headingFontWeight = 'bold'
		data.headingFontSize = '125%'
	else
		data.headingFontSize = '150%'
	end
	
	-- Data for the [view][edit][history][purge] or [create] links.
	if links then
		data.linksClass = message('start-box-linkclasses')
		data.linksId = message('start-box-link-id')
		data.links = links
	end
	
	return data
end

function p.renderStartBox(data)
	-- Renders the start box html.
	-- @data - a table of data generated by p.makeStartBoxData.
	local sbox = mw.html.create('div')
	sbox
		:css('padding-bottom', '3px')
		:css('border-bottom', '1px solid #aaa')
		:css('margin-bottom', '1ex')
		:newline()
		:tag('span')
			:cssText(data.headingStyleText)
			:css('font-weight', data.headingFontWeight)
			:css('font-size', data.headingFontSize)
			:wikitext(data.heading)
	local links = data.links
	if links then
		sbox:tag('span')
			:addClass(data.linksClass)
			:attr('id', data.linksId)
			:wikitext(links)
	end
	return tostring(sbox)
end

----------------------------------------------------------------------------
-- Documentation content
----------------------------------------------------------------------------

p.content = makeInvokeFunc('_content')

function p._content(args, env)
	-- Displays the documentation contents
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	env = env or p.getEnvironment(args)
	local docTitle = env.docTitle
	local content = args.content
	if not content and docTitle and docTitle.exists then
		content = args._content or mw.getCurrentFrame():expandTemplate{title = docTitle.prefixedText}
	end
	-- The line breaks below are necessary so that &quot;=== Headings ===&quot; at the start and end
	-- of docs are interpreted correctly.
	return '\n' .. (content or '') .. '\n' 
end

p.contentTitle = makeInvokeFunc('_contentTitle')

function p._contentTitle(args, env)
	env = env or p.getEnvironment(args)
	local docTitle = env.docTitle
	if not args.content and docTitle and docTitle.exists then
		return docTitle.prefixedText
	else
		return ''
	end
end

----------------------------------------------------------------------------
-- End box
----------------------------------------------------------------------------

p.endBox = makeInvokeFunc('_endBox')

function p._endBox(args, env)
	--[=[
	-- This function generates the end box (also known as the link box).
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	-- Messages:
	-- 'fmbox-id' --&gt; 'documentation-meta-data'
	-- 'fmbox-style' --&gt; 'background-color: #ecfcf4'
	-- 'fmbox-textstyle' --&gt; 'font-style: italic'
	-- 
	-- The HTML is generated by the {{fmbox}} template, courtesy of [[Module:Message box]].
	--]=]
	
	-- Get environment data.
	env = env or p.getEnvironment(args)
	local subjectSpace = env.subjectSpace
	local docTitle = env.docTitle
	if not subjectSpace or not docTitle then
		return nil
	end
		
	-- Check whether we should output the end box at all. Add the end
	-- box by default if the documentation exists or if we are in the
	-- user, module or template namespaces.
	local linkBox = args['link box']
	if linkBox == 'off'
		or not (
			docTitle.exists
			or subjectSpace == 2
			or subjectSpace == 828
			or subjectSpace == 10
		)
	then
		return nil
	end

	-- Assemble the arguments for {{fmbox}}.
	local fmargs = {}
	fmargs.id = message('fmbox-id') -- Sets 'documentation-meta-data'
	fmargs.image = 'none'
	fmargs.style = message('fmbox-style') -- Sets 'background-color: #ecfcf4'
	fmargs.textstyle = message('fmbox-textstyle') -- 'font-style: italic;'

	-- Assemble the fmbox text field.
	local text = ''
	if linkBox then
		text = text .. linkBox
	else
		text = text .. (p.makeDocPageBlurb(args, env) or '') -- &quot;This documentation is transcluded from [[Foo]].&quot; 
		if subjectSpace == 2 or subjectSpace == 10 or subjectSpace == 828 then
			-- We are in the user, template or module namespaces.
			-- Add sandbox and testcases links.
			-- &quot;Editors can experiment in this template's sandbox and testcases pages.&quot;
			text = text .. (p.makeExperimentBlurb(args, env) or '')
			text = text .. '&lt;br /&gt;'
			if not args.content and not args[1] then
				-- &quot;Please add categories to the /doc subpage.&quot;
				-- Don't show this message with inline docs or with an explicitly specified doc page,
				-- as then it is unclear where to add the categories.
				text = text .. (p.makeCategoriesBlurb(args, env) or '')
			end
			text = text .. ' ' .. (p.makeSubpagesBlurb(args, env) or '') --&quot;Subpages of this template&quot;
			local printBlurb = p.makePrintBlurb(args, env) -- Two-line blurb about print versions of templates.
			if printBlurb then
				text = text .. '&lt;br /&gt;' .. printBlurb
			end
		end
	end
	fmargs.text = text

	return messageBox.main('fmbox', fmargs)
end

function p.makeDocPageBlurb(args, env)
	--[=[
	-- Makes the blurb &quot;This documentation is transcluded from [[Template:Foo]] (edit, history)&quot;.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	-- Messages:
	-- 'edit-link-display' --&gt; 'edit'
	-- 'history-link-display' --&gt; 'history'
	-- 'transcluded-from-blurb' --&gt; 
	-- 'The above [[Wikipedia:Template documentation|documentation]] 
	-- is [[Wikipedia:Transclusion|transcluded]] from $1.'
	-- 'module-preload' --&gt; 'Template:Documentation/preload-module-doc'
	-- 'create-link-display' --&gt; 'create'
	-- 'create-module-doc-blurb' --&gt;
	-- 'You might want to $1 a documentation page for this [[Wikipedia:Lua|Scribunto module]].'
	--]=]
	local docTitle = env.docTitle
	if not docTitle then
		return nil
	end
	local ret
	if docTitle.exists then
		-- /doc exists; link to it.
		local docLink = makeWikilink(docTitle.prefixedText)
		local editUrl = docTitle:fullUrl{action = 'edit'}
		local editDisplay = message('edit-link-display')
		local editLink = makeUrlLink(editUrl, editDisplay)
		local historyUrl = docTitle:fullUrl{action = 'history'}
		local historyDisplay = message('history-link-display')
		local historyLink = makeUrlLink(historyUrl, historyDisplay)
		ret = message('transcluded-from-blurb', {docLink})
			.. ' '
			.. makeToolbar(editLink, historyLink)
			.. '&lt;br /&gt;'
	elseif env.subjectSpace == 828 then
		-- /doc does not exist; ask to create it.
		local createUrl = docTitle:fullUrl{action = 'edit', preload = message('module-preload')}
		local createDisplay = message('create-link-display')
		local createLink = makeUrlLink(createUrl, createDisplay)
		ret = message('create-module-doc-blurb', {createLink})
			.. '&lt;br /&gt;'
	end
	return ret
end

function p.makeExperimentBlurb(args, env)
	--[[
	-- Renders the text &quot;Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages.&quot;
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	-- Messages:
	-- 'sandbox-link-display' --&gt; 'sandbox'
	-- 'sandbox-edit-link-display' --&gt; 'edit'
	-- 'compare-link-display' --&gt; 'diff'
	-- 'module-sandbox-preload' --&gt; 'Template:Documentation/preload-module-sandbox'
	-- 'template-sandbox-preload' --&gt; 'Template:Documentation/preload-sandbox'
	-- 'sandbox-create-link-display' --&gt; 'create'
	-- 'mirror-edit-summary' --&gt; 'Create sandbox version of $1'
	-- 'mirror-link-display' --&gt; 'mirror'
	-- 'mirror-link-preload' --&gt; 'Template:Documentation/mirror'
	-- 'sandbox-link-display' --&gt; 'sandbox'
	-- 'testcases-link-display' --&gt; 'testcases'
	-- 'testcases-edit-link-display'--&gt; 'edit'
	-- 'template-sandbox-preload' --&gt; 'Template:Documentation/preload-sandbox'
	-- 'testcases-create-link-display' --&gt; 'create'
	-- 'testcases-link-display' --&gt; 'testcases'
	-- 'testcases-edit-link-display' --&gt; 'edit'
	-- 'module-testcases-preload' --&gt; 'Template:Documentation/preload-module-testcases'
	-- 'template-testcases-preload' --&gt; 'Template:Documentation/preload-testcases'
	-- 'experiment-blurb-module' --&gt; 'Editors can experiment in this module's $1 and $2 pages.'
	-- 'experiment-blurb-template' --&gt; 'Editors can experiment in this template's $1 and $2 pages.'
	--]]
	local subjectSpace = env.subjectSpace
	local templateTitle = env.templateTitle
	local sandboxTitle = env.sandboxTitle
	local testcasesTitle = env.testcasesTitle
	local templatePage = templateTitle.prefixedText
	if not subjectSpace or not templateTitle or not sandboxTitle or not testcasesTitle then
		return nil
	end
	-- Make links.
	local sandboxLinks, testcasesLinks
	if sandboxTitle.exists then
		local sandboxPage = sandboxTitle.prefixedText
		local sandboxDisplay = message('sandbox-link-display')
		local sandboxLink = makeWikilink(sandboxPage, sandboxDisplay)
		local sandboxEditUrl = sandboxTitle:fullUrl{action = 'edit'}
		local sandboxEditDisplay = message('sandbox-edit-link-display')
		local sandboxEditLink = makeUrlLink(sandboxEditUrl, sandboxEditDisplay)
		local compareUrl = env.compareUrl
		local compareLink
		if compareUrl then
			local compareDisplay = message('compare-link-display')
			compareLink = makeUrlLink(compareUrl, compareDisplay)
		end
		sandboxLinks = sandboxLink .. ' ' .. makeToolbar(sandboxEditLink, compareLink)
	else
		local sandboxPreload
		if subjectSpace == 828 then
			sandboxPreload = message('module-sandbox-preload')
		else
			sandboxPreload = message('template-sandbox-preload')
		end
		local sandboxCreateUrl = sandboxTitle:fullUrl{action = 'edit', preload = sandboxPreload}
		local sandboxCreateDisplay = message('sandbox-create-link-display')
		local sandboxCreateLink = makeUrlLink(sandboxCreateUrl, sandboxCreateDisplay)
		local mirrorSummary = message('mirror-edit-summary', {makeWikilink(templatePage)})
		local mirrorPreload = message('mirror-link-preload')
		local mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = mirrorPreload, summary = mirrorSummary}
		if subjectSpace == 828 then
			mirrorUrl = sandboxTitle:fullUrl{action = 'edit', preload = templateTitle.prefixedText, summary = mirrorSummary}
		end
		local mirrorDisplay = message('mirror-link-display')
		local mirrorLink = makeUrlLink(mirrorUrl, mirrorDisplay)
		sandboxLinks = message('sandbox-link-display') .. ' ' .. makeToolbar(sandboxCreateLink, mirrorLink)
	end
	if testcasesTitle.exists then
		local testcasesPage = testcasesTitle.prefixedText
		local testcasesDisplay = message('testcases-link-display')
		local testcasesLink = makeWikilink(testcasesPage, testcasesDisplay)
		local testcasesEditUrl = testcasesTitle:fullUrl{action = 'edit'}
		local testcasesEditDisplay = message('testcases-edit-link-display')
		local testcasesEditLink = makeUrlLink(testcasesEditUrl, testcasesEditDisplay)
		-- for Modules, add testcases run link if exists
		if subjectSpace == 828 and testcasesTitle.talkPageTitle and testcasesTitle.talkPageTitle.exists then
			local testcasesRunLinkDisplay = message('testcases-run-link-display')
			local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay)
			testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink, testcasesRunLink)
		else
			testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink)
		end
	else
		local testcasesPreload
		if subjectSpace == 828 then
			testcasesPreload = message('module-testcases-preload')
		else
			testcasesPreload = message('template-testcases-preload')
		end
		local testcasesCreateUrl = testcasesTitle:fullUrl{action = 'edit', preload = testcasesPreload}
		local testcasesCreateDisplay = message('testcases-create-link-display')
		local testcasesCreateLink = makeUrlLink(testcasesCreateUrl, testcasesCreateDisplay)
		testcasesLinks = message('testcases-link-display') .. ' ' .. makeToolbar(testcasesCreateLink)
	end
	local messageName
	if subjectSpace == 828 then
		messageName = 'experiment-blurb-module'
	else
		messageName = 'experiment-blurb-template'
	end
	return message(messageName, {sandboxLinks, testcasesLinks})
end

function p.makeCategoriesBlurb(args, env)
	--[[
	-- Generates the text &quot;Please add categories to the /doc subpage.&quot;
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- Messages:
	-- 'doc-link-display' --&gt; '/doc'
	-- 'add-categories-blurb' --&gt; 'Please add categories to the $1 subpage.'
	--]]
	local docTitle = env.docTitle
	if not docTitle then
		return nil
	end
	local docPathLink = makeWikilink(docTitle.prefixedText, message('doc-link-display'))
	return message('add-categories-blurb', {docPathLink})
end

function p.makeSubpagesBlurb(args, env)
	--[[
	-- Generates the &quot;Subpages of this template&quot; link.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	
	-- Messages:
	-- 'template-pagetype' --&gt; 'template'
	-- 'module-pagetype' --&gt; 'module'
	-- 'default-pagetype' --&gt; 'page'
	-- 'subpages-link-display' --&gt; 'Subpages of this $1'
	--]]
	local subjectSpace = env.subjectSpace
	local templateTitle = env.templateTitle
	if not subjectSpace or not templateTitle then
		return nil
	end
	local pagetype
	if subjectSpace == 10 then
		pagetype = message('template-pagetype')
	elseif subjectSpace == 828 then
		pagetype = message('module-pagetype')
	else
		pagetype = message('default-pagetype')
	end
	local subpagesLink = makeWikilink(
		'Special:PrefixIndex/' .. templateTitle.prefixedText .. '/',
		message('subpages-link-display', {pagetype})
	)
	return message('subpages-blurb', {subpagesLink})
end

function p.makePrintBlurb(args, env)
	--[=[
	-- Generates the blurb displayed when there is a print version of the template available.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	--
	-- Messages:
	-- 'print-link-display' --&gt; '/Print'
	-- 'print-blurb' --&gt; 'A [[Help:Books/for experts#Improving the book layout|print version]]'
	--		.. ' of this template exists at $1.'
	--		.. ' If you make a change to this template, please update the print version as well.'
	-- 'display-print-category' --&gt; true
	-- 'print-category' --&gt; 'Templates with print versions'
	--]=]
	local printTitle = env.printTitle
	if not printTitle then
		return nil
	end
	local ret
	if printTitle.exists then
		local printLink = makeWikilink(printTitle.prefixedText, message('print-link-display'))
		ret = message('print-blurb', {printLink})
		local displayPrintCategory = message('display-print-category', nil, 'boolean')
		if displayPrintCategory then
			ret = ret .. makeCategoryLink(message('print-category'))
		end
	end
	return ret
end

----------------------------------------------------------------------------
-- Tracking categories
----------------------------------------------------------------------------

function p.addTrackingCategories(env)
	--[[
	-- Check if {{documentation}} is transcluded on a /doc or /testcases page.
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	
	-- Messages:
	-- 'display-strange-usage-category' --&gt; true
	-- 'doc-subpage' --&gt; 'doc'
	-- 'testcases-subpage' --&gt; 'testcases'
	-- 'strange-usage-category' --&gt; 'Wikipedia pages with strange ((documentation)) usage'
	-- 
	-- /testcases pages in the module namespace are not categorised, as they may have
	-- {{documentation}} transcluded automatically.
	--]]
	local title = env.title
	local subjectSpace = env.subjectSpace
	if not title or not subjectSpace then
		return nil
	end
	local subpage = title.subpageText
	local ret = ''
	if message('display-strange-usage-category', nil, 'boolean')
		and (
			subpage == message('doc-subpage')
			or subjectSpace ~= 828 and subpage == message('testcases-subpage')
		)
	then
		ret = ret .. makeCategoryLink(message('strange-usage-category'))
	end
	return ret
end

return p</text>
      <sha1>jf2f51u5rzim7qgb93sv92cvfe6ak0s</sha1>
    </revision>
    <revision>
      <id>3383</id>
      <parentid>3378</parentid>
      <timestamp>2025-07-11T11:02:09Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <origin>3383</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="35178" sha1="fttwrouvv52xj3xc0iv9fbm0og9nf2z" xml:space="preserve">-- This module implements {{documentation}}.

-- Get required modules.
local getArgs = require('Module:Arguments').getArgs

-- Get the config table.
local cfg = mw.loadData('Module:Documentation/config')

local p = {}

-- Often-used functions.
local ugsub = mw.ustring.gsub
local format = mw.ustring.format

----------------------------------------------------------------------------
-- Helper functions
--
-- These are defined as local functions, but are made available in the p
-- table for testing purposes.
----------------------------------------------------------------------------

local function message(cfgKey, valArray, expectType)
	--[[
	-- Gets a message from the cfg table and formats it if appropriate.
	-- The function raises an error if the value from the cfg table is not
	-- of the type expectType. The default type for expectType is 'string'.
	-- If the table valArray is present, strings such as $1, $2 etc. in the
	-- message are substituted with values from the table keys [1], [2] etc.
	-- For example, if the message &quot;foo-message&quot; had the value 'Foo $2 bar $1.',
	-- message('foo-message', {'baz', 'qux'}) would return &quot;Foo qux bar baz.&quot;
	--]]
	local msg = cfg[cfgKey]
	expectType = expectType or 'string'
	if type(msg) ~= expectType then
		error('message: type error in message cfg.' .. cfgKey .. ' (' .. expectType .. ' expected, got ' .. type(msg) .. ')', 2)
	end
	if not valArray then
		return msg
	end

	local function getMessageVal(match)
		match = tonumber(match)
		return valArray[match] or error('message: no value found for key $' .. match .. ' in message cfg.' .. cfgKey, 4)
	end

	return ugsub(msg, '$([1-9][0-9]*)', getMessageVal)
end

p.message = message

local function makeWikilink(page, display)
	if display then
		return format('[[%s|%s]]', page, display)
	else
		return format('[[%s]]', page)
	end
end

p.makeWikilink = makeWikilink

local function makeCategoryLink(cat, sort)
	local catns = mw.site.namespaces[14].name
	return makeWikilink(catns .. ':' .. cat, sort)
end

p.makeCategoryLink = makeCategoryLink

local function makeUrlLink(url, display)
	return format('[%s %s]', url, display)
end

p.makeUrlLink = makeUrlLink

local function makeToolbar(...)
	local ret = {}
	local lim = select('#', ...)
	if lim &lt; 1 then
		return nil
	end
	for i = 1, lim do
		ret[#ret + 1] = select(i, ...)
	end
	-- 'documentation-toolbar'
	return format(
		'&lt;span class=&quot;%s&quot;&gt;(%s)&lt;/span&gt;',
		message('toolbar-class'),
		table.concat(ret, ' &amp;#124; ')
	)
end	

p.makeToolbar = makeToolbar

----------------------------------------------------------------------------
-- Argument processing
----------------------------------------------------------------------------

local function makeInvokeFunc(funcName)
	return function (frame)
		local args = getArgs(frame, {
			valueFunc = function (key, value)
				if type(value) == 'string' then
					value = value:match('^%s*(.-)%s*$') -- Remove whitespace.
					if key == 'heading' or value ~= '' then
						return value
					else
						return nil
					end
				else
					return value
				end
			end
		})
		return p[funcName](args)
	end
end

----------------------------------------------------------------------------
-- Entry points
----------------------------------------------------------------------------

function p.nonexistent(frame)
	if mw.title.getCurrentTitle().subpageText == 'testcases' then
		return frame:expandTemplate{title = 'module test cases notice'}
	else
		return p.main(frame)
	end
end

p.main = makeInvokeFunc('_main')

function p._main(args)
	--[[
	-- This function defines logic flow for the module.
	-- @args - table of arguments passed by the user
	--]]
	local env = p.getEnvironment(args)
	local root = mw.html.create()
	root
		:wikitext(p._getModuleWikitext(args, env))
		:wikitext(p.protectionTemplate(env))
		:wikitext(p.sandboxNotice(args, env))
		:tag('div')
			-- 'documentation-container'
			:addClass(message('container'))
			:attr('role', 'complementary')
			:attr('aria-labelledby', args.heading ~= '' and 'documentation-heading' or nil)
			:attr('aria-label', args.heading == '' and 'Documentation' or nil)
			:newline()
			:tag('div')
				-- 'documentation'
				:addClass(message('main-div-classes'))
				:newline()
				:wikitext(p._startBox(args, env))
				:wikitext(p._content(args, env))
				:tag('div')
					-- 'documentation-clear'
					:addClass(message('clear'))
					:done()
				:newline()
				:done()
			:wikitext(p._endBox(args, env))
			:done()
		:wikitext(p.addTrackingCategories(env))
	-- 'Module:Documentation/styles.css'
	return mw.getCurrentFrame():extensionTag (
		'templatestyles', '', {src=cfg['templatestyles']
	}) .. tostring(root)
end

----------------------------------------------------------------------------
-- Environment settings
----------------------------------------------------------------------------

function p.getEnvironment(args)
	--[[
	-- Returns a table with information about the environment, including title
	-- objects and other namespace- or path-related data.
	-- @args - table of arguments passed by the user
	--
	-- Title objects include:
	-- env.title - the page we are making documentation for (usually the current title)
	-- env.templateTitle - the template (or module, file, etc.)
	-- env.docTitle - the /doc subpage.
	-- env.sandboxTitle - the /sandbox subpage.
	-- env.testcasesTitle - the /testcases subpage.
	--
	-- Data includes:
	-- env.protectionLevels - the protection levels table of the title object.
	-- env.subjectSpace - the number of the title's subject namespace.
	-- env.docSpace - the number of the namespace the title puts its documentation in.
	-- env.docpageBase - the text of the base page of the /doc, /sandbox and /testcases pages, with namespace.
	-- env.compareUrl - URL of the Special:ComparePages page comparing the sandbox with the template.
	-- 
	-- All table lookups are passed through pcall so that errors are caught. If an error occurs, the value
	-- returned will be nil.
	--]]
	
	local env, envFuncs = {}, {}

	-- Set up the metatable. If triggered we call the corresponding function in the envFuncs table. The value
	-- returned by that function is memoized in the env table so that we don't call any of the functions
	-- more than once. (Nils won't be memoized.)
	setmetatable(env, {
		__index = function (t, key)
			local envFunc = envFuncs[key]
			if envFunc then
				local success, val = pcall(envFunc)
				if success then
					env[key] = val -- Memoise the value.
					return val
				end
			end
			return nil
		end
	})	

	function envFuncs.title()
		-- The title object for the current page, or a test page passed with args.page.
		local title
		local titleArg = args.page
		if titleArg then
			title = mw.title.new(titleArg)
		else
			title = mw.title.getCurrentTitle()
		end
		return title
	end

	function envFuncs.templateTitle()
		--[[
		-- The template (or module, etc.) title object.
		-- Messages:
		-- 'sandbox-subpage' --&gt; 'sandbox'
		-- 'testcases-subpage' --&gt; 'testcases'
		--]]
		local subjectSpace = env.subjectSpace
		local title = env.title
		local subpage = title.subpageText
		if subpage == message('sandbox-subpage') or subpage == message('testcases-subpage') or (subpage == message('doc-subpage') and mw.title.getCurrentTitle().namespace == env.docSpace) then
			return mw.title.makeTitle(subjectSpace, title.baseText)
		else
			return mw.title.makeTitle(subjectSpace, title.text)
		end
	end

	function envFuncs.docTitle()
		--[[
		-- Title object of the /doc subpage.
		-- Messages:
		-- 'doc-subpage' --&gt; 'doc'
		--]]
		local title = env.title
		local docname = args[1] -- User-specified doc page.
		local docpage
		if docname then
			docpage = docname
		else
			docpage = env.docpageBase .. '/' .. message('doc-subpage')
		end
		return mw.title.new(docpage)
	end
	
	function envFuncs.sandboxTitle()
		--[[
		-- Title object for the /sandbox subpage.
		-- Messages:
		-- 'sandbox-subpage' --&gt; 'sandbox'
		--]]
		return mw.title.new(env.docpageBase .. '/' .. message('sandbox-subpage'))
	end
	
	function envFuncs.testcasesTitle()
		--[[
		-- Title object for the /testcases subpage.
		-- Messages:
		-- 'testcases-subpage' --&gt; 'testcases'
		--]]
		return mw.title.new(env.docpageBase .. '/' .. message('testcases-subpage'))
	end

	function envFuncs.protectionLevels()
		-- The protection levels table of the title object.
		return env.title.protectionLevels
	end

	function envFuncs.subjectSpace()
		-- The subject namespace number.
		return mw.site.namespaces[env.title.namespace].subject.id
	end

	function envFuncs.docSpace()
		-- The documentation namespace number. For most namespaces this is the
		-- same as the subject namespace. However, pages in the Article, File,
		-- MediaWiki or Category namespaces must have their /doc, /sandbox and
		-- /testcases pages in talk space.
		local subjectSpace = env.subjectSpace
		if subjectSpace == 0 or subjectSpace == 6 or subjectSpace == 8 or subjectSpace == 14 then
			return subjectSpace + 1
		else
			return subjectSpace
		end
	end

	function envFuncs.docpageBase()
		-- The base page of the /doc, /sandbox, and /testcases subpages.
		-- For some namespaces this is the talk page, rather than the template page.
		local templateTitle = env.templateTitle
		local docSpace = env.docSpace
		local docSpaceText = mw.site.namespaces[docSpace].name
		-- Assemble the link. docSpace is never the main namespace, so we can hardcode the colon.
		return docSpaceText .. ':' .. templateTitle.text
	end
	
	function envFuncs.compareUrl()
		-- Diff link between the sandbox and the main template using [[Special:ComparePages]].
		local templateTitle = env.templateTitle
		local sandboxTitle = env.sandboxTitle
		if templateTitle.exists and sandboxTitle.exists then
			local compareUrl = mw.uri.canonicalUrl(
				'Special:ComparePages',
				{ page1 = templateTitle.prefixedText, page2 = sandboxTitle.prefixedText}
			)
			return tostring(compareUrl)
		else
			return nil
		end
	end		

	return env
end	

----------------------------------------------------------------------------
-- Auxiliary templates
----------------------------------------------------------------------------

p.getModuleWikitext = makeInvokeFunc('_getModuleWikitext')

function p._getModuleWikitext(args, env)
	local currentTitle = mw.title.getCurrentTitle()
	if currentTitle.contentModel ~= 'Scribunto' then return end
	pcall(require, currentTitle.prefixedText) -- if it fails, we don't care
	local moduleWikitext =  package.loaded[&quot;Module:Module wikitext&quot;]
	if moduleWikitext then
		return moduleWikitext.main()
	end
end

function p.sandboxNotice(args, env)
	--[=[
	-- Generates a sandbox notice for display above sandbox pages.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	-- Messages:
	-- 'sandbox-notice-image' --&gt; '[[File:Sandbox.svg|50px|alt=|link=]]'
	-- 'sandbox-notice-blurb' --&gt; 'This is the $1 for $2.'
	-- 'sandbox-notice-diff-blurb' --&gt; 'This is the $1 for $2 ($3).'
	-- 'sandbox-notice-pagetype-template' --&gt; '[[Wikipedia:Template test cases|template sandbox]] page'
	-- 'sandbox-notice-pagetype-module' --&gt; '[[Wikipedia:Template test cases|module sandbox]] page'
	-- 'sandbox-notice-pagetype-other' --&gt; 'sandbox page'
	-- 'sandbox-notice-compare-link-display' --&gt; 'diff'
	-- 'sandbox-notice-testcases-blurb' --&gt; 'See also the companion subpage for $1.'
	-- 'sandbox-notice-testcases-link-display' --&gt; 'test cases'
	-- 'sandbox-category' --&gt; 'Template sandboxes'
	-- 'module-sandbox-category' --&gt; 'Module sandboxes'
	-- 'other-sandbox-category' --&gt; 'Sandboxes outside of template or module namespace'
	--]=]
	local title = env.title
	local sandboxTitle = env.sandboxTitle
	local templateTitle = env.templateTitle
	local subjectSpace = env.subjectSpace
	if not (subjectSpace and title and sandboxTitle and templateTitle
		and mw.title.equals(title, sandboxTitle)) then
		return nil
	end
	-- Build the table of arguments to pass to {{ombox}}. We need just two fields, &quot;image&quot; and &quot;text&quot;.
	local omargs = {}
	omargs.image = message('sandbox-notice-image')
	-- Get the text. We start with the opening blurb, which is something like
	-- &quot;This is the template sandbox for [[Template:Foo]] (diff).&quot;
	local text = '__EXPECTUNUSEDTEMPLATE__'
	local pagetype, sandboxCat
	if subjectSpace == 10 then
		pagetype = message('sandbox-notice-pagetype-template')
		sandboxCat = message('sandbox-category')
	elseif subjectSpace == 828 then
		pagetype = message('sandbox-notice-pagetype-module')
		sandboxCat = message('module-sandbox-category')
	else
		pagetype = message('sandbox-notice-pagetype-other')
		sandboxCat = message('other-sandbox-category')
	end
	local templateLink = makeWikilink(templateTitle.prefixedText)
	local compareUrl = env.compareUrl
	if compareUrl then
		local compareDisplay = message('sandbox-notice-compare-link-display')
		local compareLink = makeUrlLink(compareUrl, compareDisplay)
		text = text .. message('sandbox-notice-diff-blurb', {pagetype, templateLink, compareLink})
	else
		text = text .. message('sandbox-notice-blurb', {pagetype, templateLink})
	end
	-- Get the test cases page blurb if the page exists. This is something like
	-- &quot;See also the companion subpage for [[Template:Foo/testcases|test cases]].&quot;
	local testcasesTitle = env.testcasesTitle
	if testcasesTitle and testcasesTitle.exists then
		if testcasesTitle.contentModel == &quot;Scribunto&quot; then
			local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display')
			local testcasesRunLinkDisplay = message('sandbox-notice-testcases-run-link-display')
			local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay)
			local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay)
			text = text .. '&lt;br /&gt;' .. message('sandbox-notice-testcases-run-blurb', {testcasesLink, testcasesRunLink})
		else
			local testcasesLinkDisplay = message('sandbox-notice-testcases-link-display')
			local testcasesLink = makeWikilink(testcasesTitle.prefixedText, testcasesLinkDisplay)
			text = text .. '&lt;br /&gt;' .. message('sandbox-notice-testcases-blurb', {testcasesLink})
		end
	end
	
	-- Add the sandbox to the sandbox category.
	omargs.text = text .. makeCategoryLink(sandboxCat)

	-- 'documentation-clear'
	return '&lt;div class=&quot;' .. message('clear') .. '&quot;&gt;&lt;/div&gt;'
		.. require('Module:Message box').main('ombox', omargs)
end

function p.protectionTemplate(env)
	-- Generates the padlock icon in the top right.
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- Messages:
	-- 'protection-template' --&gt; 'pp-template'
	-- 'protection-template-args' --&gt; {docusage = 'yes'}
	local protectionLevels = env.protectionLevels
	if not protectionLevels then
		return nil
	end
	local editProt = protectionLevels.edit and protectionLevels.edit[1]
	local moveProt = protectionLevels.move and protectionLevels.move[1]
	if editProt then
		-- The page is edit-protected.
		return require('Module:Protection banner')._main{
			message('protection-reason-edit'), small = true
		}
	elseif moveProt and moveProt ~= 'autoconfirmed' then
		-- The page is move-protected but not edit-protected. Exclude move
		-- protection with the level &quot;autoconfirmed&quot;, as this is equivalent to
		-- no move protection at all.
		return require('Module:Protection banner')._main{
			action = 'move', small = true
		}
	else
		return nil
	end
end

----------------------------------------------------------------------------
-- Start box
----------------------------------------------------------------------------

p.startBox = makeInvokeFunc('_startBox')

function p._startBox(args, env)
	--[[
	-- This function generates the start box.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	-- The actual work is done by p.makeStartBoxLinksData and p.renderStartBoxLinks which make
	-- the [view] [edit] [history] [purge] links, and by p.makeStartBoxData and p.renderStartBox
	-- which generate the box HTML.
	--]]
	env = env or p.getEnvironment(args)
	local links
	local content = args.content
	if not content or args[1] then
		-- No need to include the links if the documentation is on the template page itself.
		local linksData = p.makeStartBoxLinksData(args, env)
		if linksData then
			links = p.renderStartBoxLinks(linksData)
		end
	end
	-- Generate the start box html.
	local data = p.makeStartBoxData(args, env, links)
	if data then
		return p.renderStartBox(data)
	else
		-- User specified no heading.
		return nil
	end
end

function p.makeStartBoxLinksData(args, env)
	--[[
	-- Does initial processing of data to make the [view] [edit] [history] [purge] links.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	-- Messages:
	-- 'view-link-display' --&gt; 'view'
	-- 'edit-link-display' --&gt; 'edit'
	-- 'history-link-display' --&gt; 'history'
	-- 'purge-link-display' --&gt; 'purge'
	-- 'module-preload' --&gt; 'Template:Documentation/preload-module-doc'
	-- 'docpage-preload' --&gt; 'Template:Documentation/preload'
	-- 'create-link-display' --&gt; 'create'
	--]]
	local subjectSpace = env.subjectSpace
	local title = env.title
	local docTitle = env.docTitle
	if not title or not docTitle then
		return nil
	end
	if docTitle.isRedirect then 
		docTitle = docTitle.redirectTarget
	end

	-- Create link if /doc doesn't exist.
	local preload = args.preload
	if not preload then
		if subjectSpace == 828 then -- Module namespace
			preload = message('module-preload')
		else
			preload = message('docpage-preload')
		end
	end
	
	return {
		title = title,
		docTitle = docTitle,
		-- View, display, edit, and purge links if /doc exists.
		viewLinkDisplay = message('view-link-display'),
		editLinkDisplay = message('edit-link-display'),
		historyLinkDisplay = message('history-link-display'),
		purgeLinkDisplay = message('purge-link-display'),
		preload = preload,
		createLinkDisplay = message('create-link-display')
	}
end

function p.renderStartBoxLinks(data)
	--[[
	-- Generates the [view][edit][history][purge] or [create][purge] links from the data table.
	-- @data - a table of data generated by p.makeStartBoxLinksData
	--]]
	local docTitle = data.docTitle
	-- yes, we do intend to purge the template page on which the documentation appears
	local purgeLink = makeWikilink(&quot;Special:Purge/&quot; .. data.title.prefixedText, data.purgeLinkDisplay)
	
	if docTitle.exists then
		local viewLink = makeWikilink(docTitle.prefixedText, data.viewLinkDisplay)
		local editLink = makeWikilink(&quot;Special:EditPage/&quot; .. docTitle.prefixedText, data.editLinkDisplay)
		local historyLink = makeWikilink(&quot;Special:PageHistory/&quot; .. docTitle.prefixedText, data.historyLinkDisplay)
		return &quot;&amp;#91;&quot; .. viewLink .. &quot;&amp;#93; &amp;#91;&quot; .. editLink .. &quot;&amp;#93; &amp;#91;&quot; .. historyLink .. &quot;&amp;#93; &amp;#91;&quot; .. purgeLink .. &quot;&amp;#93;&quot;
	else
		local createLink = makeUrlLink(docTitle:canonicalUrl{action = 'edit', preload = data.preload}, data.createLinkDisplay)
		return  &quot;&amp;#91;&quot; .. createLink .. &quot;&amp;#93; &amp;#91;&quot; .. purgeLink .. &quot;&amp;#93;&quot;
	end
	return ret
end

function p.makeStartBoxData(args, env, links)
	--[=[
	-- Does initial processing of data to pass to the start-box render function, p.renderStartBox.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- @links - a string containing the [view][edit][history][purge] links - could be nil if there's an error.
	--
	-- Messages:
	-- 'documentation-icon-wikitext' --&gt; '[[File:Test Template Info-Icon - Version (2).svg|50px|link=|alt=]]'
	-- 'template-namespace-heading' --&gt; 'Template documentation'
	-- 'module-namespace-heading' --&gt; 'Module documentation'
	-- 'file-namespace-heading' --&gt; 'Summary'
	-- 'other-namespaces-heading' --&gt; 'Documentation'
	-- 'testcases-create-link-display' --&gt; 'create'
	--]=]
	local subjectSpace = env.subjectSpace
	if not subjectSpace then
		-- Default to an &quot;other namespaces&quot; namespace, so that we get at least some output
		-- if an error occurs.
		subjectSpace = 2
	end
	local data = {}
	
	-- Heading
	local heading = args.heading -- Blank values are not removed.
	if heading == '' then
		-- Don't display the start box if the heading arg is defined but blank.
		return nil
	end
	if heading then
		data.heading = heading
	elseif subjectSpace == 10 then -- Template namespace
		data.heading = message('documentation-icon-wikitext') .. ' ' .. message('template-namespace-heading')
	elseif subjectSpace == 828 then -- Module namespace
		data.heading = message('documentation-icon-wikitext') .. ' ' .. message('module-namespace-heading')
	elseif subjectSpace == 6 then -- File namespace
		data.heading = message('file-namespace-heading')
	else
		data.heading = message('other-namespaces-heading')
	end
	
	-- Heading CSS
	local headingStyle = args['heading-style']
	if headingStyle then
		data.headingStyleText = headingStyle
	else
		-- 'documentation-heading'
		data.headingClass = message('main-div-heading-class')
	end
	
	-- Data for the [view][edit][history][purge] or [create] links.
	if links then
		-- 'mw-editsection-like plainlinks'
		data.linksClass = message('start-box-link-classes')
		data.links = links
	end
	
	return data
end

function p.renderStartBox(data)
	-- Renders the start box html.
	-- @data - a table of data generated by p.makeStartBoxData.
	local sbox = mw.html.create('div')
	sbox
		-- 'documentation-startbox'
		:addClass(message('start-box-class'))
		:newline()
		:tag('span')
			:addClass(data.headingClass)
			:attr('id', 'documentation-heading')
			:cssText(data.headingStyleText)
			:wikitext(data.heading)
	local links = data.links
	if links then
		sbox:tag('span')
			:addClass(data.linksClass)
			:attr('id', data.linksId)
			:wikitext(links)
	end
	return tostring(sbox)
end

----------------------------------------------------------------------------
-- Documentation content
----------------------------------------------------------------------------

p.content = makeInvokeFunc('_content')

function p._content(args, env)
	-- Displays the documentation contents
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	env = env or p.getEnvironment(args)
	local docTitle = env.docTitle
	local content = args.content
	if not content and docTitle and docTitle.exists then
		content = args._content or mw.getCurrentFrame():expandTemplate{title = docTitle.prefixedText}
	end
	-- The line breaks below are necessary so that &quot;=== Headings ===&quot; at the start and end
	-- of docs are interpreted correctly.
	return '\n' .. (content or '') .. '\n' 
end

p.contentTitle = makeInvokeFunc('_contentTitle')

function p._contentTitle(args, env)
	env = env or p.getEnvironment(args)
	local docTitle = env.docTitle
	if not args.content and docTitle and docTitle.exists then
		return docTitle.prefixedText
	else
		return ''
	end
end

----------------------------------------------------------------------------
-- End box
----------------------------------------------------------------------------

p.endBox = makeInvokeFunc('_endBox')

function p._endBox(args, env)
	--[=[
	-- This function generates the end box (also known as the link box).
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	--]=]
	
	-- Get environment data.
	env = env or p.getEnvironment(args)
	local subjectSpace = env.subjectSpace
	local docTitle = env.docTitle
	if not subjectSpace or not docTitle then
		return nil
	end
		
	-- Check whether we should output the end box at all. Add the end
	-- box by default if the documentation exists or if we are in the
	-- user, module or template namespaces.
	local linkBox = args['link box']
	if linkBox == 'off'
		or not (
			docTitle.exists
			or subjectSpace == 2
			or subjectSpace == 828
			or subjectSpace == 10
		)
	then
		return nil
	end

	-- Assemble the link box.
	local text = ''
	if linkBox then
		text = text .. linkBox
	else
		text = text .. (p.makeDocPageBlurb(args, env) or '') -- &quot;This documentation is transcluded from [[Foo]].&quot; 
		if subjectSpace == 2 or subjectSpace == 10 or subjectSpace == 828 then
			-- We are in the user, template or module namespaces.
			-- Add sandbox and testcases links.
			-- &quot;Editors can experiment in this template's sandbox and testcases pages.&quot;
			text = text .. (p.makeExperimentBlurb(args, env) or '') .. '&lt;br /&gt;'
			if not args.content and not args[1] then
				-- &quot;Please add categories to the /doc subpage.&quot;
				-- Don't show this message with inline docs or with an explicitly specified doc page,
				-- as then it is unclear where to add the categories.
				text = text .. (p.makeCategoriesBlurb(args, env) or '')
			end
			text = text .. ' ' .. (p.makeSubpagesBlurb(args, env) or '') --&quot;Subpages of this template&quot;
		end
	end
	
	local box = mw.html.create('div')
	-- 'documentation-metadata'
	box:attr('role', 'note')
		:addClass(message('end-box-class'))
		-- 'plainlinks'
		:addClass(message('end-box-plainlinks'))
		:wikitext(text)
		:done()

	return '\n' .. tostring(box)
end

function p.makeDocPageBlurb(args, env)
	--[=[
	-- Makes the blurb &quot;This documentation is transcluded from [[Template:Foo]] (edit, history)&quot;.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	-- Messages:
	-- 'edit-link-display' --&gt; 'edit'
	-- 'history-link-display' --&gt; 'history'
	-- 'transcluded-from-blurb' --&gt; 
	-- 'The above [[Wikipedia:Template documentation|documentation]] 
	-- is [[Help:Transclusion|transcluded]] from $1.'
	-- 'module-preload' --&gt; 'Template:Documentation/preload-module-doc'
	-- 'create-link-display' --&gt; 'create'
	-- 'create-module-doc-blurb' --&gt;
	-- 'You might want to $1 a documentation page for this [[Wikipedia:Lua|Scribunto module]].'
	--]=]
	local docTitle = env.docTitle
	if not docTitle then
		return nil
	end
	if docTitle.exists then
		-- /doc exists; link to it.
		local docLink = makeWikilink(docTitle.prefixedText)
		local editDisplay = message('edit-link-display')
		local editLink = makeWikilink(&quot;Special:EditPage/&quot; .. docTitle.prefixedText, editDisplay)
		local historyDisplay = message('history-link-display')
		local historyLink = makeWikilink(&quot;Special:PageHistory/&quot; .. docTitle.prefixedText, historyDisplay)
		return message('transcluded-from-blurb', {docLink})
			.. ' '
			.. makeToolbar(editLink, historyLink)
			.. '&lt;br /&gt;'
	elseif env.subjectSpace == 828 then
		-- /doc does not exist; ask to create it.
		local createUrl = docTitle:canonicalUrl{action = 'edit', preload = message('module-preload')}
		local createDisplay = message('create-link-display')
		local createLink = makeUrlLink(createUrl, createDisplay)
		return message('create-module-doc-blurb', {createLink})
			.. '&lt;br /&gt;'
	end
end

function p.makeExperimentBlurb(args, env)
	--[[
	-- Renders the text &quot;Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages.&quot;
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- 
	-- Messages:
	-- 'sandbox-link-display' --&gt; 'sandbox'
	-- 'sandbox-edit-link-display' --&gt; 'edit'
	-- 'compare-link-display' --&gt; 'diff'
	-- 'module-sandbox-preload' --&gt; 'Template:Documentation/preload-module-sandbox'
	-- 'template-sandbox-preload' --&gt; 'Template:Documentation/preload-sandbox'
	-- 'sandbox-create-link-display' --&gt; 'create'
	-- 'mirror-edit-summary' --&gt; 'Create sandbox version of $1'
	-- 'mirror-link-display' --&gt; 'mirror'
	-- 'mirror-link-preload' --&gt; 'Template:Documentation/mirror'
	-- 'sandbox-link-display' --&gt; 'sandbox'
	-- 'testcases-link-display' --&gt; 'testcases'
	-- 'testcases-edit-link-display'--&gt; 'edit'
	-- 'template-sandbox-preload' --&gt; 'Template:Documentation/preload-sandbox'
	-- 'testcases-create-link-display' --&gt; 'create'
	-- 'testcases-link-display' --&gt; 'testcases'
	-- 'testcases-edit-link-display' --&gt; 'edit'
	-- 'module-testcases-preload' --&gt; 'Template:Documentation/preload-module-testcases'
	-- 'template-testcases-preload' --&gt; 'Template:Documentation/preload-testcases'
	-- 'experiment-blurb-module' --&gt; 'Editors can experiment in this module's $1 and $2 pages.'
	-- 'experiment-blurb-template' --&gt; 'Editors can experiment in this template's $1 and $2 pages.'
	--]]
	local subjectSpace = env.subjectSpace
	local templateTitle = env.templateTitle
	local sandboxTitle = env.sandboxTitle
	local testcasesTitle = env.testcasesTitle
	local templatePage = templateTitle.prefixedText
	if not subjectSpace or not templateTitle or not sandboxTitle or not testcasesTitle then
		return nil
	end
	-- Make links.
	local sandboxLinks, testcasesLinks
	if sandboxTitle.exists then
		local sandboxPage = sandboxTitle.prefixedText
		local sandboxDisplay = message('sandbox-link-display')
		local sandboxLink = makeWikilink(sandboxPage, sandboxDisplay)
		local sandboxEditDisplay = message('sandbox-edit-link-display')
		local sandboxEditLink = makeWikilink(&quot;Special:EditPage/&quot; .. sandboxPage, sandboxEditDisplay)
		local compareUrl = env.compareUrl
		local compareLink
		if compareUrl then
			local compareDisplay = message('compare-link-display')
			compareLink = makeUrlLink(compareUrl, compareDisplay)
		end
		sandboxLinks = sandboxLink .. ' ' .. makeToolbar(sandboxEditLink, compareLink)
	else
		local sandboxPreload
		if subjectSpace == 828 then
			sandboxPreload = message('module-sandbox-preload')
		else
			sandboxPreload = message('template-sandbox-preload')
		end
		local sandboxCreateUrl = sandboxTitle:canonicalUrl{action = 'edit', preload = sandboxPreload}
		local sandboxCreateDisplay = message('sandbox-create-link-display')
		local sandboxCreateLink = makeUrlLink(sandboxCreateUrl, sandboxCreateDisplay)
		local mirrorSummary = message('mirror-edit-summary', {makeWikilink(templatePage)})
		local mirrorPreload = message('mirror-link-preload')
		local mirrorUrl = sandboxTitle:canonicalUrl{action = 'edit', preload = mirrorPreload, summary = mirrorSummary}
		if subjectSpace == 828 then
			mirrorUrl = sandboxTitle:canonicalUrl{action = 'edit', preload = templateTitle.prefixedText, summary = mirrorSummary}
		end
		local mirrorDisplay = message('mirror-link-display')
		local mirrorLink = makeUrlLink(mirrorUrl, mirrorDisplay)
		sandboxLinks = message('sandbox-link-display') .. ' ' .. makeToolbar(sandboxCreateLink, mirrorLink)
	end
	if testcasesTitle.exists then
		local testcasesPage = testcasesTitle.prefixedText
		local testcasesDisplay = message('testcases-link-display')
		local testcasesLink = makeWikilink(testcasesPage, testcasesDisplay)
		local testcasesEditUrl = testcasesTitle:canonicalUrl{action = 'edit'}
		local testcasesEditDisplay = message('testcases-edit-link-display')
		local testcasesEditLink = makeWikilink(&quot;Special:EditPage/&quot; .. testcasesPage, testcasesEditDisplay)
		-- for Modules, add testcases run link if exists
		if testcasesTitle.contentModel == &quot;Scribunto&quot;  and testcasesTitle.talkPageTitle and testcasesTitle.talkPageTitle.exists then
			local testcasesRunLinkDisplay = message('testcases-run-link-display')
			local testcasesRunLink = makeWikilink(testcasesTitle.talkPageTitle.prefixedText, testcasesRunLinkDisplay)
			testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink, testcasesRunLink)
		else
			testcasesLinks = testcasesLink .. ' ' .. makeToolbar(testcasesEditLink)
		end
	else
		local testcasesPreload
		if subjectSpace == 828 then
			testcasesPreload = message('module-testcases-preload')
		else
			testcasesPreload = message('template-testcases-preload')
		end
		local testcasesCreateUrl = testcasesTitle:canonicalUrl{action = 'edit', preload = testcasesPreload}
		local testcasesCreateDisplay = message('testcases-create-link-display')
		local testcasesCreateLink = makeUrlLink(testcasesCreateUrl, testcasesCreateDisplay)
		testcasesLinks = message('testcases-link-display') .. ' ' .. makeToolbar(testcasesCreateLink)
	end
	local messageName
	if subjectSpace == 828 then
		messageName = 'experiment-blurb-module'
	else
		messageName = 'experiment-blurb-template'
	end
	return message(messageName, {sandboxLinks, testcasesLinks})
end

function p.makeCategoriesBlurb(args, env)
	--[[
	-- Generates the text &quot;Please add categories to the /doc subpage.&quot;
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	-- Messages:
	-- 'doc-link-display' --&gt; '/doc'
	-- 'add-categories-blurb' --&gt; 'Please add categories to the $1 subpage.'
	--]]
	local docTitle = env.docTitle
	if not docTitle then
		return nil
	end
	local docPathLink = makeWikilink(docTitle.prefixedText, message('doc-link-display'))
	return message('add-categories-blurb', {docPathLink})
end

function p.makeSubpagesBlurb(args, env)
	--[[
	-- Generates the &quot;Subpages of this template&quot; link.
	-- @args - a table of arguments passed by the user
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	
	-- Messages:
	-- 'template-pagetype' --&gt; 'template'
	-- 'module-pagetype' --&gt; 'module'
	-- 'default-pagetype' --&gt; 'page'
	-- 'subpages-link-display' --&gt; 'Subpages of this $1'
	--]]
	local subjectSpace = env.subjectSpace
	local templateTitle = env.templateTitle
	if not subjectSpace or not templateTitle then
		return nil
	end
	local pagetype
	if subjectSpace == 10 then
		pagetype = message('template-pagetype')
	elseif subjectSpace == 828 then
		pagetype = message('module-pagetype')
	else
		pagetype = message('default-pagetype')
	end
	local subpagesLink = makeWikilink(
		'Special:PrefixIndex/' .. templateTitle.prefixedText .. '/',
		message('subpages-link-display', {pagetype})
	)
	return message('subpages-blurb', {subpagesLink})
end

----------------------------------------------------------------------------
-- Tracking categories
----------------------------------------------------------------------------

function p.addTrackingCategories(env)
	--[[
	-- Check if {{documentation}} is transcluded on a /doc or /testcases page.
	-- @env - environment table containing title objects, etc., generated with p.getEnvironment
	
	-- Messages:
	-- 'display-strange-usage-category' --&gt; true
	-- 'doc-subpage' --&gt; 'doc'
	-- 'testcases-subpage' --&gt; 'testcases'
	-- 'strange-usage-category' --&gt; 'Wikipedia pages with strange ((documentation)) usage'
	-- 
	-- /testcases pages in the module namespace are not categorised, as they may have
	-- {{documentation}} transcluded automatically.
	--]]
	local title = env.title
	local subjectSpace = env.subjectSpace
	if not title or not subjectSpace then
		return nil
	end
	local subpage = title.subpageText
	if message('display-strange-usage-category', nil, 'boolean')
		and (
			subpage == message('doc-subpage')
			or subjectSpace ~= 828 and subpage == message('testcases-subpage')
		)
	then
		return makeCategoryLink(message('strange-usage-category'))
	end
	return ''
end

return p</text>
      <sha1>fttwrouvv52xj3xc0iv9fbm0og9nf2z</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Infobox</title>
    <ns>828</ns>
    <id>107</id>
    <revision>
      <id>442</id>
      <timestamp>2016-02-22T13:49:55Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;-- -- This module implements {{Infobox}} --   local p = {}  local args = {} local origArgs local root  local function union(t1, t2)     -- Returns the union of the values of t...&quot;</comment>
      <origin>442</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="13512" sha1="oz8ffzjz5f7bhpm9cg8co9gn7ei3a74" xml:space="preserve">--
-- This module implements {{Infobox}}
--
 
local p = {}

local args = {}
local origArgs
local root

local function union(t1, t2)
    -- Returns the union of the values of two tables, as a sequence.
    local vals = {}
    for k, v in pairs(t1) do
        vals[v] = true
    end
    for k, v in pairs(t2) do
        vals[v] = true
    end
    local ret = {}
    for k, v in pairs(vals) do
        table.insert(ret, k)
    end
    return ret
end

local function getArgNums(prefix)
    -- Returns a table containing the numbers of the arguments that exist
    -- for the specified prefix. For example, if the prefix was 'data', and
    -- 'data1', 'data2', and 'data5' exist, it would return {1, 2, 5}.
    local nums = {}
    for k, v in pairs(args) do
        local num = tostring(k):match('^' .. prefix .. '([1-9]%d*)$')
        if num then table.insert(nums, tonumber(num)) end
    end
    table.sort(nums)
    return nums
end

local function addRow(rowArgs)
    -- Adds a row to the infobox, with either a header cell
    -- or a label/data cell combination.
    if rowArgs.header then
        root
            :tag('tr')
                :addClass(rowArgs.rowclass)
                :cssText(rowArgs.rowstyle)
                :attr('id', rowArgs.rowid)
                :tag('th')
                    :attr('colspan', 2)
                    :attr('id', rowArgs.headerid)
                    :addClass(rowArgs.class)
                    :addClass(args.headerclass)
                    :css('text-align', 'center')
                    :cssText(args.headerstyle)
                    :wikitext(rowArgs.header)
    elseif rowArgs.data then
        local row = root:tag('tr')
        row:addClass(rowArgs.rowclass)
        row:cssText(rowArgs.rowstyle)
        row:attr('id', rowArgs.rowid)
        if rowArgs.label then
            row
                :tag('th')
                    :attr('scope', 'row')
                    :attr('id', rowArgs.labelid)
                    :css('text-align', 'right')
                    :cssText(args.labelstyle)
                    :wikitext(rowArgs.label)
                    :done()
        end
        
        local dataCell = row:tag('td')
        if not rowArgs.label then 
            dataCell
                :attr('colspan', 2)
                :css('text-align', 'center') 
        end
        dataCell
            :attr('id', rowArgs.dataid)
            :addClass(rowArgs.class)
            :cssText(rowArgs.datastyle)
            :newline()
            :wikitext(rowArgs.data)
    end
end

local function renderTitle()
    if not args.title then return end

    root
        :tag('caption')
            :addClass(args.titleclass)
            :cssText(args.titlestyle)
            :wikitext(args.title)
end

local function renderAboveRow()
    if not args.above then return end
    
    root
        :tag('tr')
            :tag('th')
                :attr('colspan', 2)
                :addClass(args.aboveclass)
                :css('text-align', 'center')
                :css('font-size', '125%')
                :css('font-weight', 'bold')
                :cssText(args.abovestyle)
                :wikitext(args.above)
end

local function renderBelowRow()
    if not args.below then return end
    
    root
        :tag('tr')
            :tag('td')
                :attr('colspan', '2')
                :addClass(args.belowclass)
                :css('text-align', 'center')
                :cssText(args.belowstyle)
                :newline()
                :wikitext(args.below)
end

local function renderSubheaders()
    if args.subheader then
        args.subheader1 = args.subheader
    end
    if args.subheaderrowclass then
        args.subheaderrowclass1 = args.subheaderrowclass
    end
    local subheadernums = getArgNums('subheader')
    for k, num in ipairs(subheadernums) do
        addRow({
            data = args['subheader' .. tostring(num)],
            datastyle = args.subheaderstyle or args['subheaderstyle' .. tostring(num)],
            class = args.subheaderclass,
            rowclass = args['subheaderrowclass' .. tostring(num)]
        })
    end
end

local function renderImages()
    if args.image then
        args.image1 = args.image
    end
    if args.caption then
        args.caption1 = args.caption
    end
    local imagenums = getArgNums('image')
    for k, num in ipairs(imagenums) do
        local caption = args['caption' .. tostring(num)]
        local data = mw.html.create():wikitext(args['image' .. tostring(num)])
        if caption then
            data
                :tag('div')
                    :cssText(args.captionstyle)
                    :wikitext(caption)
        end
        addRow({
            data = tostring(data),
            datastyle = args.imagestyle,
            class = args.imageclass,
            rowclass = args['imagerowclass' .. tostring(num)]
        })
    end
end

local function renderRows()
    -- Gets the union of the header and data argument numbers,
    -- and renders them all in order using addRow.
    local rownums = union(getArgNums('header'), getArgNums('data'))
    table.sort(rownums)
    for k, num in ipairs(rownums) do
        addRow({
            header = args['header' .. tostring(num)],
            label = args['label' .. tostring(num)],
            data = args['data' .. tostring(num)],
            datastyle = args.datastyle,
            class = args['class' .. tostring(num)],
            rowclass = args['rowclass' .. tostring(num)],
            rowstyle = args['rowstyle' .. tostring(num)],
            dataid = args['dataid' .. tostring(num)],
            labelid = args['labelid' .. tostring(num)],
            headerid = args['headerid' .. tostring(num)],
            rowid = args['rowid' .. tostring(num)]
        })
    end
end

local function renderNavBar()
    if not args.name then return end
    
    root
        :tag('tr')
            :tag('td')
                :attr('colspan', '2')
                :css('text-align', 'left')
                :wikitext(mw.getCurrentFrame():expandTemplate({ 
                    title = 'navbar', 
                    args = { args.name, mini = 1 }
                }))
end

local function renderItalicTitle()
    local italicTitle = args['italic title'] and mw.ustring.lower(args['italic title'])
    if italicTitle == '' or italicTitle == 'force' or italicTitle == 'yes' then
        root:wikitext(mw.getCurrentFrame():expandTemplate({title = 'italic title'}))
    end
end

local function renderTrackingCategories()
    if args.decat ~= 'yes' then
        if #(getArgNums('data')) == 0 and mw.title.getCurrentTitle().namespace == 0 then
            root:wikitext('[[Mkhakha:Articles which use infobox templates with no data rows]]')
        end
        if args.child == 'yes' and args.title then
            root:wikitext('[[Mkhakha:Articles which use embedded infobox templates with the title parameter]]')
        end
    end
end

local function _infobox()
    -- Specify the overall layout of the infobox, with special settings
    -- if the infobox is used as a 'child' inside another infobox.
    if args.child ~= 'yes' then
        root = mw.html.create('table')
        
        root
            :addClass('infobox')
            :addClass(args.bodyclass)
            
            if args.subbox == 'yes' then
                root
                    :css('padding', '0')
                    :css('border', 'none')
                    :css('margin', '-3px')
                    :css('width', 'auto')
                    :css('min-width', '100%')
                    :css('font-size', '100%')
                    :css('clear', 'none')
                    :css('float', 'none')
                    :css('background-color', 'transparent')
            else
                root
                    :css('width', '22em')
            end
        root
            :cssText(args.bodystyle)
    
        renderTitle()
        renderAboveRow()
    else
        root = mw.html.create()
        
        root
            :wikitext(args.title)
    end

    renderSubheaders()
    renderImages() 
    renderRows() 
    renderBelowRow()  
    renderNavBar()
    renderItalicTitle()
    renderTrackingCategories()
    
    return tostring(root)
end

local function preprocessSingleArg(argName)
    -- If the argument exists and isn't blank, add it to the argument table.
    -- Blank arguments are treated as nil to match the behaviour of ParserFunctions.
    if origArgs[argName] and origArgs[argName] ~= '' then
        args[argName] = origArgs[argName]
    end
end

local function preprocessArgs(prefixTable, step)
    -- Assign the parameters with the given prefixes to the args table, in order, in batches
    -- of the step size specified. This is to prevent references etc. from appearing in the
    -- wrong order. The prefixTable should be an array containing tables, each of which has
    -- two possible fields, a &quot;prefix&quot; string and a &quot;depend&quot; table. The function always parses
    -- parameters containing the &quot;prefix&quot; string, but only parses parameters in the &quot;depend&quot;
    -- table if the prefix parameter is present and non-blank.
    if type(prefixTable) ~= 'table' then
        error(&quot;Non-table value detected for the prefix table&quot;, 2)
    end
    if type(step) ~= 'number' then
        error(&quot;Invalid step value detected&quot;, 2)
    end
    
    -- Get arguments without a number suffix, and check for bad input.
    for i,v in ipairs(prefixTable) do
        if type(v) ~= 'table' or type(v.prefix) ~= &quot;string&quot; or (v.depend and type(v.depend) ~= 'table') then
            error('Invalid input detected to preprocessArgs prefix table', 2)
        end
        preprocessSingleArg(v.prefix)
        -- Only parse the depend parameter if the prefix parameter is present and not blank.
        if args[v.prefix] and v.depend then
            for j, dependValue in ipairs(v.depend) do
                if type(dependValue) ~= 'string' then
                    error('Invalid &quot;depend&quot; parameter value detected in preprocessArgs')
                end
                preprocessSingleArg(dependValue)
            end
        end
    end

    -- Get arguments with number suffixes.
    local a = 1 -- Counter variable.
    local moreArgumentsExist = true
    while moreArgumentsExist == true do
        moreArgumentsExist = false
        for i = a, a + step - 1 do
            for j,v in ipairs(prefixTable) do
                local prefixArgName = v.prefix .. tostring(i)
                if origArgs[prefixArgName] then
                    moreArgumentsExist = true -- Do another loop if any arguments are found, even blank ones.
                    preprocessSingleArg(prefixArgName)
                end
                -- Process the depend table if the prefix argument is present and not blank, or
                -- we are processing &quot;prefix1&quot; and &quot;prefix&quot; is present and not blank, and
                -- if the depend table is present.
                if v.depend and (args[prefixArgName] or (i == 1 and args[v.prefix])) then
                    for j,dependValue in ipairs(v.depend) do
                        local dependArgName = dependValue .. tostring(i)
                        preprocessSingleArg(dependArgName)
                    end
                end
            end
        end
        a = a + step
    end
end
 
function p.infobox(frame)
    -- If called via #invoke, use the args passed into the invoking template.
    -- Otherwise, for testing purposes, assume args are being passed directly in.
    if frame == mw.getCurrentFrame() then
        origArgs = frame:getParent().args
    else
        origArgs = frame
    end
    
    -- Parse the data parameters in the same order that the old {{infobox}} did, so that
    -- references etc. will display in the expected places. Parameters that depend on
    -- another parameter are only processed if that parameter is present, to avoid
    -- phantom references appearing in article reference lists.
    preprocessSingleArg('child')
    preprocessSingleArg('bodyclass')
    preprocessSingleArg('subbox')
    preprocessSingleArg('bodystyle')
    preprocessSingleArg('title')
    preprocessSingleArg('titleclass')
    preprocessSingleArg('titlestyle')
    preprocessSingleArg('above')
    preprocessSingleArg('aboveclass')
    preprocessSingleArg('abovestyle')
    preprocessArgs({
        {prefix = 'subheader', depend = {'subheaderstyle', 'subheaderrowclass'}}
    }, 10)
    preprocessSingleArg('subheaderstyle')
    preprocessSingleArg('subheaderclass')
    preprocessArgs({
        {prefix = 'image', depend = {'caption', 'imagerowclass'}}
    }, 10)
    preprocessSingleArg('captionstyle')
    preprocessSingleArg('imagestyle')
    preprocessSingleArg('imageclass')
    preprocessArgs({
        {prefix = 'header'},
        {prefix = 'data', depend = {'label'}},
        {prefix = 'rowclass'},
        {prefix = 'rowstyle'},
        {prefix = 'class'},
        {prefix = 'dataid'},
        {prefix = 'labelid'},
        {prefix = 'headerid'},
        {prefix = 'rowid'}
    }, 50)
    preprocessSingleArg('headerclass')
    preprocessSingleArg('headerstyle')
    preprocessSingleArg('labelstyle')
    preprocessSingleArg('datastyle')
    preprocessSingleArg('below')
    preprocessSingleArg('belowclass')
    preprocessSingleArg('belowstyle')
    preprocessSingleArg('name')
    args['italic title'] = origArgs['italic title'] -- different behaviour if blank or absent
    preprocessSingleArg('decat')
 
    return _infobox()
end
 
return p</text>
      <sha1>oz8ffzjz5f7bhpm9cg8co9gn7ei3a74</sha1>
    </revision>
    <revision>
      <id>443</id>
      <parentid>442</parentid>
      <timestamp>2024-10-14T13:46:29Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>442</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="13512" sha1="oz8ffzjz5f7bhpm9cg8co9gn7ei3a74" xml:space="preserve">--
-- This module implements {{Infobox}}
--
 
local p = {}

local args = {}
local origArgs
local root

local function union(t1, t2)
    -- Returns the union of the values of two tables, as a sequence.
    local vals = {}
    for k, v in pairs(t1) do
        vals[v] = true
    end
    for k, v in pairs(t2) do
        vals[v] = true
    end
    local ret = {}
    for k, v in pairs(vals) do
        table.insert(ret, k)
    end
    return ret
end

local function getArgNums(prefix)
    -- Returns a table containing the numbers of the arguments that exist
    -- for the specified prefix. For example, if the prefix was 'data', and
    -- 'data1', 'data2', and 'data5' exist, it would return {1, 2, 5}.
    local nums = {}
    for k, v in pairs(args) do
        local num = tostring(k):match('^' .. prefix .. '([1-9]%d*)$')
        if num then table.insert(nums, tonumber(num)) end
    end
    table.sort(nums)
    return nums
end

local function addRow(rowArgs)
    -- Adds a row to the infobox, with either a header cell
    -- or a label/data cell combination.
    if rowArgs.header then
        root
            :tag('tr')
                :addClass(rowArgs.rowclass)
                :cssText(rowArgs.rowstyle)
                :attr('id', rowArgs.rowid)
                :tag('th')
                    :attr('colspan', 2)
                    :attr('id', rowArgs.headerid)
                    :addClass(rowArgs.class)
                    :addClass(args.headerclass)
                    :css('text-align', 'center')
                    :cssText(args.headerstyle)
                    :wikitext(rowArgs.header)
    elseif rowArgs.data then
        local row = root:tag('tr')
        row:addClass(rowArgs.rowclass)
        row:cssText(rowArgs.rowstyle)
        row:attr('id', rowArgs.rowid)
        if rowArgs.label then
            row
                :tag('th')
                    :attr('scope', 'row')
                    :attr('id', rowArgs.labelid)
                    :css('text-align', 'right')
                    :cssText(args.labelstyle)
                    :wikitext(rowArgs.label)
                    :done()
        end
        
        local dataCell = row:tag('td')
        if not rowArgs.label then 
            dataCell
                :attr('colspan', 2)
                :css('text-align', 'center') 
        end
        dataCell
            :attr('id', rowArgs.dataid)
            :addClass(rowArgs.class)
            :cssText(rowArgs.datastyle)
            :newline()
            :wikitext(rowArgs.data)
    end
end

local function renderTitle()
    if not args.title then return end

    root
        :tag('caption')
            :addClass(args.titleclass)
            :cssText(args.titlestyle)
            :wikitext(args.title)
end

local function renderAboveRow()
    if not args.above then return end
    
    root
        :tag('tr')
            :tag('th')
                :attr('colspan', 2)
                :addClass(args.aboveclass)
                :css('text-align', 'center')
                :css('font-size', '125%')
                :css('font-weight', 'bold')
                :cssText(args.abovestyle)
                :wikitext(args.above)
end

local function renderBelowRow()
    if not args.below then return end
    
    root
        :tag('tr')
            :tag('td')
                :attr('colspan', '2')
                :addClass(args.belowclass)
                :css('text-align', 'center')
                :cssText(args.belowstyle)
                :newline()
                :wikitext(args.below)
end

local function renderSubheaders()
    if args.subheader then
        args.subheader1 = args.subheader
    end
    if args.subheaderrowclass then
        args.subheaderrowclass1 = args.subheaderrowclass
    end
    local subheadernums = getArgNums('subheader')
    for k, num in ipairs(subheadernums) do
        addRow({
            data = args['subheader' .. tostring(num)],
            datastyle = args.subheaderstyle or args['subheaderstyle' .. tostring(num)],
            class = args.subheaderclass,
            rowclass = args['subheaderrowclass' .. tostring(num)]
        })
    end
end

local function renderImages()
    if args.image then
        args.image1 = args.image
    end
    if args.caption then
        args.caption1 = args.caption
    end
    local imagenums = getArgNums('image')
    for k, num in ipairs(imagenums) do
        local caption = args['caption' .. tostring(num)]
        local data = mw.html.create():wikitext(args['image' .. tostring(num)])
        if caption then
            data
                :tag('div')
                    :cssText(args.captionstyle)
                    :wikitext(caption)
        end
        addRow({
            data = tostring(data),
            datastyle = args.imagestyle,
            class = args.imageclass,
            rowclass = args['imagerowclass' .. tostring(num)]
        })
    end
end

local function renderRows()
    -- Gets the union of the header and data argument numbers,
    -- and renders them all in order using addRow.
    local rownums = union(getArgNums('header'), getArgNums('data'))
    table.sort(rownums)
    for k, num in ipairs(rownums) do
        addRow({
            header = args['header' .. tostring(num)],
            label = args['label' .. tostring(num)],
            data = args['data' .. tostring(num)],
            datastyle = args.datastyle,
            class = args['class' .. tostring(num)],
            rowclass = args['rowclass' .. tostring(num)],
            rowstyle = args['rowstyle' .. tostring(num)],
            dataid = args['dataid' .. tostring(num)],
            labelid = args['labelid' .. tostring(num)],
            headerid = args['headerid' .. tostring(num)],
            rowid = args['rowid' .. tostring(num)]
        })
    end
end

local function renderNavBar()
    if not args.name then return end
    
    root
        :tag('tr')
            :tag('td')
                :attr('colspan', '2')
                :css('text-align', 'left')
                :wikitext(mw.getCurrentFrame():expandTemplate({ 
                    title = 'navbar', 
                    args = { args.name, mini = 1 }
                }))
end

local function renderItalicTitle()
    local italicTitle = args['italic title'] and mw.ustring.lower(args['italic title'])
    if italicTitle == '' or italicTitle == 'force' or italicTitle == 'yes' then
        root:wikitext(mw.getCurrentFrame():expandTemplate({title = 'italic title'}))
    end
end

local function renderTrackingCategories()
    if args.decat ~= 'yes' then
        if #(getArgNums('data')) == 0 and mw.title.getCurrentTitle().namespace == 0 then
            root:wikitext('[[Mkhakha:Articles which use infobox templates with no data rows]]')
        end
        if args.child == 'yes' and args.title then
            root:wikitext('[[Mkhakha:Articles which use embedded infobox templates with the title parameter]]')
        end
    end
end

local function _infobox()
    -- Specify the overall layout of the infobox, with special settings
    -- if the infobox is used as a 'child' inside another infobox.
    if args.child ~= 'yes' then
        root = mw.html.create('table')
        
        root
            :addClass('infobox')
            :addClass(args.bodyclass)
            
            if args.subbox == 'yes' then
                root
                    :css('padding', '0')
                    :css('border', 'none')
                    :css('margin', '-3px')
                    :css('width', 'auto')
                    :css('min-width', '100%')
                    :css('font-size', '100%')
                    :css('clear', 'none')
                    :css('float', 'none')
                    :css('background-color', 'transparent')
            else
                root
                    :css('width', '22em')
            end
        root
            :cssText(args.bodystyle)
    
        renderTitle()
        renderAboveRow()
    else
        root = mw.html.create()
        
        root
            :wikitext(args.title)
    end

    renderSubheaders()
    renderImages() 
    renderRows() 
    renderBelowRow()  
    renderNavBar()
    renderItalicTitle()
    renderTrackingCategories()
    
    return tostring(root)
end

local function preprocessSingleArg(argName)
    -- If the argument exists and isn't blank, add it to the argument table.
    -- Blank arguments are treated as nil to match the behaviour of ParserFunctions.
    if origArgs[argName] and origArgs[argName] ~= '' then
        args[argName] = origArgs[argName]
    end
end

local function preprocessArgs(prefixTable, step)
    -- Assign the parameters with the given prefixes to the args table, in order, in batches
    -- of the step size specified. This is to prevent references etc. from appearing in the
    -- wrong order. The prefixTable should be an array containing tables, each of which has
    -- two possible fields, a &quot;prefix&quot; string and a &quot;depend&quot; table. The function always parses
    -- parameters containing the &quot;prefix&quot; string, but only parses parameters in the &quot;depend&quot;
    -- table if the prefix parameter is present and non-blank.
    if type(prefixTable) ~= 'table' then
        error(&quot;Non-table value detected for the prefix table&quot;, 2)
    end
    if type(step) ~= 'number' then
        error(&quot;Invalid step value detected&quot;, 2)
    end
    
    -- Get arguments without a number suffix, and check for bad input.
    for i,v in ipairs(prefixTable) do
        if type(v) ~= 'table' or type(v.prefix) ~= &quot;string&quot; or (v.depend and type(v.depend) ~= 'table') then
            error('Invalid input detected to preprocessArgs prefix table', 2)
        end
        preprocessSingleArg(v.prefix)
        -- Only parse the depend parameter if the prefix parameter is present and not blank.
        if args[v.prefix] and v.depend then
            for j, dependValue in ipairs(v.depend) do
                if type(dependValue) ~= 'string' then
                    error('Invalid &quot;depend&quot; parameter value detected in preprocessArgs')
                end
                preprocessSingleArg(dependValue)
            end
        end
    end

    -- Get arguments with number suffixes.
    local a = 1 -- Counter variable.
    local moreArgumentsExist = true
    while moreArgumentsExist == true do
        moreArgumentsExist = false
        for i = a, a + step - 1 do
            for j,v in ipairs(prefixTable) do
                local prefixArgName = v.prefix .. tostring(i)
                if origArgs[prefixArgName] then
                    moreArgumentsExist = true -- Do another loop if any arguments are found, even blank ones.
                    preprocessSingleArg(prefixArgName)
                end
                -- Process the depend table if the prefix argument is present and not blank, or
                -- we are processing &quot;prefix1&quot; and &quot;prefix&quot; is present and not blank, and
                -- if the depend table is present.
                if v.depend and (args[prefixArgName] or (i == 1 and args[v.prefix])) then
                    for j,dependValue in ipairs(v.depend) do
                        local dependArgName = dependValue .. tostring(i)
                        preprocessSingleArg(dependArgName)
                    end
                end
            end
        end
        a = a + step
    end
end
 
function p.infobox(frame)
    -- If called via #invoke, use the args passed into the invoking template.
    -- Otherwise, for testing purposes, assume args are being passed directly in.
    if frame == mw.getCurrentFrame() then
        origArgs = frame:getParent().args
    else
        origArgs = frame
    end
    
    -- Parse the data parameters in the same order that the old {{infobox}} did, so that
    -- references etc. will display in the expected places. Parameters that depend on
    -- another parameter are only processed if that parameter is present, to avoid
    -- phantom references appearing in article reference lists.
    preprocessSingleArg('child')
    preprocessSingleArg('bodyclass')
    preprocessSingleArg('subbox')
    preprocessSingleArg('bodystyle')
    preprocessSingleArg('title')
    preprocessSingleArg('titleclass')
    preprocessSingleArg('titlestyle')
    preprocessSingleArg('above')
    preprocessSingleArg('aboveclass')
    preprocessSingleArg('abovestyle')
    preprocessArgs({
        {prefix = 'subheader', depend = {'subheaderstyle', 'subheaderrowclass'}}
    }, 10)
    preprocessSingleArg('subheaderstyle')
    preprocessSingleArg('subheaderclass')
    preprocessArgs({
        {prefix = 'image', depend = {'caption', 'imagerowclass'}}
    }, 10)
    preprocessSingleArg('captionstyle')
    preprocessSingleArg('imagestyle')
    preprocessSingleArg('imageclass')
    preprocessArgs({
        {prefix = 'header'},
        {prefix = 'data', depend = {'label'}},
        {prefix = 'rowclass'},
        {prefix = 'rowstyle'},
        {prefix = 'class'},
        {prefix = 'dataid'},
        {prefix = 'labelid'},
        {prefix = 'headerid'},
        {prefix = 'rowid'}
    }, 50)
    preprocessSingleArg('headerclass')
    preprocessSingleArg('headerstyle')
    preprocessSingleArg('labelstyle')
    preprocessSingleArg('datastyle')
    preprocessSingleArg('below')
    preprocessSingleArg('belowclass')
    preprocessSingleArg('belowstyle')
    preprocessSingleArg('name')
    args['italic title'] = origArgs['italic title'] -- different behaviour if blank or absent
    preprocessSingleArg('decat')
 
    return _infobox()
end
 
return p</text>
      <sha1>oz8ffzjz5f7bhpm9cg8co9gn7ei3a74</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Message box</title>
    <ns>828</ns>
    <id>108</id>
    <revision>
      <id>444</id>
      <timestamp>2019-01-13T17:36:59Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;-- This is a meta-module for producing message box templates, including -- {{mbox}}, {{ambox}}, {{imbox}}, {{tmbox}}, {{ombox}}, {{cmbox}} and {{fmbox}}.  -- Load necessary mo...&quot;</comment>
      <origin>444</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="16824" sha1="30425kdmecruvoplexo6unx7te7z8gc" xml:space="preserve">-- This is a meta-module for producing message box templates, including
-- {{mbox}}, {{ambox}}, {{imbox}}, {{tmbox}}, {{ombox}}, {{cmbox}} and {{fmbox}}.

-- Load necessary modules.
require('Module:No globals')
local getArgs
local categoryHandler = require('Module:Category handler')._main
local yesno = require('Module:Yesno')

-- Get a language object for formatDate and ucfirst.
local lang = mw.language.getContentLanguage()

-- Define constants
local CONFIG_MODULE = 'Module:Message box/configuration'

--------------------------------------------------------------------------------
-- Helper functions
--------------------------------------------------------------------------------

local function getTitleObject(...)
	-- Get the title object, passing the function through pcall
	-- in case we are over the expensive function count limit.
	local success, title = pcall(mw.title.new, ...)
	if success then
		return title
	end
end

local function union(t1, t2)
	-- Returns the union of two arrays.
	local vals = {}
	for i, v in ipairs(t1) do
		vals[v] = true
	end
	for i, v in ipairs(t2) do
		vals[v] = true
	end
	local ret = {}
	for k in pairs(vals) do
		table.insert(ret, k)
	end
	table.sort(ret)
	return ret
end

local function getArgNums(args, prefix)
	local nums = {}
	for k, v in pairs(args) do
		local num = mw.ustring.match(tostring(k), '^' .. prefix .. '([1-9]%d*)$')
		if num then
			table.insert(nums, tonumber(num))
		end
	end
	table.sort(nums)
	return nums
end

--------------------------------------------------------------------------------
-- Box class definition
--------------------------------------------------------------------------------

local MessageBox = {}
MessageBox.__index = MessageBox

function MessageBox.new(boxType, args, cfg)
	args = args or {}
	local obj = {}

	-- Set the title object and the namespace.
	obj.title = getTitleObject(args.page) or mw.title.getCurrentTitle()

	-- Set the config for our box type.
	obj.cfg = cfg[boxType]
	if not obj.cfg then
		local ns = obj.title.namespace
		-- boxType is &quot;mbox&quot; or invalid input
		if ns == 0 then
			obj.cfg = cfg.ambox -- main namespace
		elseif ns == 6 then
			obj.cfg = cfg.imbox -- file namespace
		elseif ns == 14 then
			obj.cfg = cfg.cmbox -- category namespace
		else
			local nsTable = mw.site.namespaces[ns]
			if nsTable and nsTable.isTalk then
				obj.cfg = cfg.tmbox -- any talk namespace
			else
				obj.cfg = cfg.ombox -- other namespaces or invalid input
			end
		end
	end

	-- Set the arguments, and remove all blank arguments except for the ones
	-- listed in cfg.allowBlankParams.
	do
		local newArgs = {}
		for k, v in pairs(args) do
			if v ~= '' then
				newArgs[k] = v
			end
		end
		for i, param in ipairs(obj.cfg.allowBlankParams or {}) do
			newArgs[param] = args[param]
		end
		obj.args = newArgs
	end

	-- Define internal data structure.
	obj.categories = {}
	obj.classes = {}

	return setmetatable(obj, MessageBox)
end

function MessageBox:addCat(ns, cat, sort)
	if not cat then
		return nil
	end
	if sort then
		cat = string.format('[[Mkhakha:%s|%s]]', cat, sort)
	else
		cat = string.format('[[Mkhakha:%s]]', cat)
	end
	self.categories[ns] = self.categories[ns] or {}
	table.insert(self.categories[ns], cat)
end

function MessageBox:addClass(class)
	if not class then
		return nil
	end
	table.insert(self.classes, class)
end

function MessageBox:setParameters()
	local args = self.args
	local cfg = self.cfg

	-- Get type data.
	self.type = args.type
	local typeData = cfg.types[self.type]
	self.invalidTypeError = cfg.showInvalidTypeError
		and self.type
		and not typeData
	typeData = typeData or cfg.types[cfg.default]
	self.typeClass = typeData.class
	self.typeImage = typeData.image

	-- Find if the box has been wrongly substituted.
	self.isSubstituted = cfg.substCheck and args.subst == 'SUBST'

	-- Find whether we are using a small message box.
	self.isSmall = cfg.allowSmall and (
		cfg.smallParam and args.small == cfg.smallParam
		or not cfg.smallParam and yesno(args.small)
	)

	-- Add attributes, classes and styles.
	self.id = args.id
	if yesno(args.plainlinks) ~= false then
		self:addClass('plainlinks')
	end
	for _, class in ipairs(cfg.classes or {}) do
		self:addClass(class)
	end
	if self.isSmall then
		self:addClass(cfg.smallClass or 'mbox-small')
	end
	self:addClass(self.typeClass)
	self:addClass(args.class)
	self.style = args.style
	self.attrs = args.attrs

	-- Set text style.
	self.textstyle = args.textstyle

	-- Find if we are on the template page or not. This functionality is only
	-- used if useCollapsibleTextFields is set, or if both cfg.templateCategory
	-- and cfg.templateCategoryRequireName are set.
	self.useCollapsibleTextFields = cfg.useCollapsibleTextFields
	if self.useCollapsibleTextFields
		or cfg.templateCategory
		and cfg.templateCategoryRequireName
	then
		self.name = args.name
		if self.name then
			local templateName = mw.ustring.match(
				self.name,
				'^[tT][eE][mM][pP][lL][aA][tT][eE][%s_]*:[%s_]*(.*)$'
			) or self.name
			templateName = 'Template:' .. templateName
			self.templateTitle = getTitleObject(templateName)
		end
		self.isTemplatePage = self.templateTitle
			and mw.title.equals(self.title, self.templateTitle)
	end

	-- Process data for collapsible text fields. At the moment these are only
	-- used in {{ambox}}.
	if self.useCollapsibleTextFields then
		-- Get the self.issue value.
		if self.isSmall and args.smalltext then
			self.issue = args.smalltext
		else
			local sect
			if args.sect == '' then
				sect = 'This ' .. (cfg.sectionDefault or 'page')
			elseif type(args.sect) == 'string' then
				sect = 'This ' .. args.sect
			end
			local issue = args.issue
			issue = type(issue) == 'string' and issue ~= '' and issue or nil
			local text = args.text
			text = type(text) == 'string' and text or nil
			local issues = {}
			table.insert(issues, sect)
			table.insert(issues, issue)
			table.insert(issues, text)
			self.issue = table.concat(issues, ' ')
		end

		-- Get the self.talk value.
		local talk = args.talk
		-- Show talk links on the template page or template subpages if the talk
		-- parameter is blank.
		if talk == ''
			and self.templateTitle
			and (
				mw.title.equals(self.templateTitle, self.title)
				or self.title:isSubpageOf(self.templateTitle)
			)
		then
			talk = '#'
		elseif talk == '' then
			talk = nil
		end
		if talk then
			-- If the talk value is a talk page, make a link to that page. Else
			-- assume that it's a section heading, and make a link to the talk
			-- page of the current page with that section heading.
			local talkTitle = getTitleObject(talk)
			local talkArgIsTalkPage = true
			if not talkTitle or not talkTitle.isTalkPage then
				talkArgIsTalkPage = false
				talkTitle = getTitleObject(
					self.title.text,
					mw.site.namespaces[self.title.namespace].talk.id
				)
			end
			if talkTitle and talkTitle.exists then
				local talkText = 'Relevant discussion may be found on'
				if talkArgIsTalkPage then
					talkText = string.format(
						'%s [[%s|%s]].',
						talkText,
						talk,
						talkTitle.prefixedText
					)
				else
					talkText = string.format(
						'%s the [[%s#%s|talk page]].',
						talkText,
						talkTitle.prefixedText,
						talk
					)
				end
				self.talk = talkText
			end
		end

		-- Get other values.
		self.fix = args.fix ~= '' and args.fix or nil
		local date
		if args.date and args.date ~= '' then
			date = args.date
		elseif args.date == '' and self.isTemplatePage then
			date = lang:formatDate('F Y')
		end
		if date then
			self.date = string.format(&quot; &lt;small&gt;''(%s)''&lt;/small&gt;&quot;, date)
		end
		self.info = args.info
		if yesno(args.removalnotice) then
			self.removalNotice = cfg.removalNotice
		end
	end

	-- Set the non-collapsible text field. At the moment this is used by all box
	-- types other than ambox, and also by ambox when small=yes.
	if self.isSmall then
		self.text = args.smalltext or args.text
	else
		self.text = args.text
	end

	-- Set the below row.
	self.below = cfg.below and args.below

	-- General image settings.
	self.imageCellDiv = not self.isSmall and cfg.imageCellDiv
	self.imageEmptyCell = cfg.imageEmptyCell
	if cfg.imageEmptyCellStyle then
		self.imageEmptyCellStyle = 'border:none;padding:0px;width:1px'
	end

	-- Left image settings.
	local imageLeft = self.isSmall and args.smallimage or args.image
	if cfg.imageCheckBlank and imageLeft ~= 'blank' and imageLeft ~= 'none'
		or not cfg.imageCheckBlank and imageLeft ~= 'none'
	then
		self.imageLeft = imageLeft
		if not imageLeft then
			local imageSize = self.isSmall
				and (cfg.imageSmallSize or '30x30px')
				or '40x40px'
			self.imageLeft = string.format('[[Isimumathi:%s|%s|link=|alt=]]', self.typeImage
				or 'Imbox notice.png', imageSize)
		end
	end

	-- Right image settings.
	local imageRight = self.isSmall and args.smallimageright or args.imageright
	if not (cfg.imageRightNone and imageRight == 'none') then
		self.imageRight = imageRight
	end
end

function MessageBox:setMainspaceCategories()
	local args = self.args
	local cfg = self.cfg

	if not cfg.allowMainspaceCategories then
		return nil
	end

	local nums = {}
	for _, prefix in ipairs{'cat', 'category', 'all'} do
		args[prefix .. '1'] = args[prefix]
		nums = union(nums, getArgNums(args, prefix))
	end

	-- The following is roughly equivalent to the old {{Ambox/category}}.
	local date = args.date
	date = type(date) == 'string' and date
	local preposition = 'from'
	for _, num in ipairs(nums) do
		local mainCat = args['cat' .. tostring(num)]
			or args['category' .. tostring(num)]
		local allCat = args['all' .. tostring(num)]
		mainCat = type(mainCat) == 'string' and mainCat
		allCat = type(allCat) == 'string' and allCat
		if mainCat and date and date ~= '' then
			local catTitle = string.format('%s %s %s', mainCat, preposition, date)
			self:addCat(0, catTitle)
			catTitle = getTitleObject('Category:' .. catTitle)
			if not catTitle or not catTitle.exists then
				self:addCat(0, 'Articles with invalid date parameter in template')
			end
		elseif mainCat and (not date or date == '') then
			self:addCat(0, mainCat)
		end
		if allCat then
			self:addCat(0, allCat)
		end
	end
end

function MessageBox:setTemplateCategories()
	local args = self.args
	local cfg = self.cfg

	-- Add template categories.
	if cfg.templateCategory then
		if cfg.templateCategoryRequireName then
			if self.isTemplatePage then
				self:addCat(10, cfg.templateCategory)
			end
		elseif not self.title.isSubpage then
			self:addCat(10, cfg.templateCategory)
		end
	end

	-- Add template error categories.
	if cfg.templateErrorCategory then
		local templateErrorCategory = cfg.templateErrorCategory
		local templateCat, templateSort
		if not self.name and not self.title.isSubpage then
			templateCat = templateErrorCategory
		elseif self.isTemplatePage then
			local paramsToCheck = cfg.templateErrorParamsToCheck or {}
			local count = 0
			for i, param in ipairs(paramsToCheck) do
				if not args[param] then
					count = count + 1
				end
			end
			if count &gt; 0 then
				templateCat = templateErrorCategory
				templateSort = tostring(count)
			end
			if self.categoryNums and #self.categoryNums &gt; 0 then
				templateCat = templateErrorCategory
				templateSort = 'C'
			end
		end
		self:addCat(10, templateCat, templateSort)
	end
end

function MessageBox:setAllNamespaceCategories()
	-- Set categories for all namespaces.
	if self.invalidTypeError then
		local allSort = (self.title.namespace == 0 and 'Main:' or '') .. self.title.prefixedText
		self:addCat('all', 'Wikipedia message box parameter needs fixing', allSort)
	end
	if self.isSubstituted then
		self:addCat('all', 'Pages with incorrectly substituted templates')
	end
end

function MessageBox:setCategories()
	if self.title.namespace == 0 then
		self:setMainspaceCategories()
	elseif self.title.namespace == 10 then
		self:setTemplateCategories()
	end
	self:setAllNamespaceCategories()
end

function MessageBox:renderCategories()
	-- Convert category tables to strings and pass them through
	-- [[Module:Category handler]].
	return categoryHandler{
		main = table.concat(self.categories[0] or {}),
		template = table.concat(self.categories[10] or {}),
		all = table.concat(self.categories.all or {}),
		nocat = self.args.nocat,
		page = self.args.page
	}
end

function MessageBox:export()
	local root = mw.html.create()

	-- Add the subst check error.
	if self.isSubstituted and self.name then
		root:tag('b')
			:addClass('error')
			:wikitext(string.format(
				'Template &lt;code&gt;%s[[Umhlahlandlelasakhiwo:%s|%s]]%s&lt;/code&gt; has been incorrectly substituted.',
				mw.text.nowiki('{{'), self.name, self.name, mw.text.nowiki('}}')
			))
	end

	-- Create the box table.
	local boxTable = root:tag('table')
	boxTable:attr('id', self.id or nil)
	for i, class in ipairs(self.classes or {}) do
		boxTable:addClass(class or nil)
	end
	boxTable
		:cssText(self.style or nil)
		:attr('role', 'presentation')

	if self.attrs then
		boxTable:attr(self.attrs)
	end

	-- Add the left-hand image.
	local row = boxTable:tag('tr')
	if self.imageLeft then
		local imageLeftCell = row:tag('td'):addClass('mbox-image')
		if self.imageCellDiv then
			-- If we are using a div, redefine imageLeftCell so that the image
			-- is inside it. Divs use style=&quot;width: 52px;&quot;, which limits the
			-- image width to 52px. If any images in a div are wider than that,
			-- they may overlap with the text or cause other display problems.
			imageLeftCell = imageLeftCell:tag('div'):css('width', '52px')
		end
		imageLeftCell:wikitext(self.imageLeft or nil)
	elseif self.imageEmptyCell then
		-- Some message boxes define an empty cell if no image is specified, and
		-- some don't. The old template code in templates where empty cells are
		-- specified gives the following hint: &quot;No image. Cell with some width
		-- or padding necessary for text cell to have 100% width.&quot;
		row:tag('td')
			:addClass('mbox-empty-cell')
			:cssText(self.imageEmptyCellStyle or nil)
	end

	-- Add the text.
	local textCell = row:tag('td'):addClass('mbox-text')
	if self.useCollapsibleTextFields then
		-- The message box uses advanced text parameters that allow things to be
		-- collapsible. At the moment, only ambox uses this.
		textCell:cssText(self.textstyle or nil)
		local textCellDiv = textCell:tag('div')
		textCellDiv
			:addClass('mbox-text-span')
			:wikitext(self.issue or nil)
		if (self.talk or self.fix) and not self.isSmall then
			textCellDiv:tag('span')
				:addClass('hide-when-compact')
				:wikitext(self.talk and (' ' .. self.talk) or nil)
				:wikitext(self.fix and (' ' .. self.fix) or nil)
		end
		textCellDiv:wikitext(self.date and (' ' .. self.date) or nil)
		if self.info and not self.isSmall then
			textCellDiv
				:tag('span')
				:addClass('hide-when-compact')
				:wikitext(self.info and (' ' .. self.info) or nil)
		end
		if self.removalNotice then
			textCellDiv:tag('small')
				:addClass('hide-when-compact')
				:tag('i')
					:wikitext(string.format(&quot; (%s)&quot;, self.removalNotice))
		end
	else
		-- Default text formatting - anything goes.
		textCell
			:cssText(self.textstyle or nil)
			:wikitext(self.text or nil)
	end

	-- Add the right-hand image.
	if self.imageRight then
		local imageRightCell = row:tag('td'):addClass('mbox-imageright')
		if self.imageCellDiv then
			-- If we are using a div, redefine imageRightCell so that the image
			-- is inside it.
			imageRightCell = imageRightCell:tag('div'):css('width', '52px')
		end
		imageRightCell
			:wikitext(self.imageRight or nil)
	end

	-- Add the below row.
	if self.below then
		boxTable:tag('tr')
			:tag('td')
				:attr('colspan', self.imageRight and '3' or '2')
				:addClass('mbox-text')
				:cssText(self.textstyle or nil)
				:wikitext(self.below or nil)
	end

	-- Add error message for invalid type parameters.
	if self.invalidTypeError then
		root:tag('div')
			:css('text-align', 'center')
			:wikitext(string.format(
				'This message box is using an invalid &quot;type=%s&quot; parameter and needs fixing.',
				self.type or ''
			))
	end

	-- Add categories.
	root:wikitext(self:renderCategories() or nil)

	return tostring(root)
end

--------------------------------------------------------------------------------
-- Exports
--------------------------------------------------------------------------------

local p, mt = {}, {}

function p._exportClasses()
	-- For testing.
	return {
		MessageBox = MessageBox
	}
end

function p.main(boxType, args, cfgTables)
	local box = MessageBox.new(boxType, args, cfgTables or mw.loadData(CONFIG_MODULE))
	box:setParameters()
	box:setCategories()
	return box:export()
end

function mt.__index(t, k)
	return function (frame)
		if not getArgs then
			getArgs = require('Module:Arguments').getArgs
		end
		return t.main(k, getArgs(frame, {trim = false, removeBlanks = false}))
	end
end

return setmetatable(p, mt)</text>
      <sha1>30425kdmecruvoplexo6unx7te7z8gc</sha1>
    </revision>
    <revision>
      <id>445</id>
      <parentid>444</parentid>
      <timestamp>2019-12-02T16:09:36Z</timestamp>
      <contributor>
        <username>incubator&gt;Adithyak1997</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Added some prefixes</comment>
      <origin>445</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="16826" sha1="1rbvtuoip6thpdgb06fmknm5ebeoml8" xml:space="preserve">-- This is a meta-module for producing message box templates, including
-- {{mbox}}, {{ambox}}, {{imbox}}, {{tmbox}}, {{ombox}}, {{cmbox}} and {{fmbox}}.

-- Load necessary modules.
require('Module:No globals')
local getArgs
local categoryHandler = require('Module:Category handler')._main
local yesno = require('Module:Yesno')

-- Get a language object for formatDate and ucfirst.
local lang = mw.language.getContentLanguage()

-- Define constants
local CONFIG_MODULE = 'Module:Message box/configuration'

--------------------------------------------------------------------------------
-- Helper functions
--------------------------------------------------------------------------------

local function getTitleObject(...)
	-- Get the title object, passing the function through pcall
	-- in case we are over the expensive function count limit.
	local success, title = pcall(mw.title.new, ...)
	if success then
		return title
	end
end

local function union(t1, t2)
	-- Returns the union of two arrays.
	local vals = {}
	for i, v in ipairs(t1) do
		vals[v] = true
	end
	for i, v in ipairs(t2) do
		vals[v] = true
	end
	local ret = {}
	for k in pairs(vals) do
		table.insert(ret, k)
	end
	table.sort(ret)
	return ret
end

local function getArgNums(args, prefix)
	local nums = {}
	for k, v in pairs(args) do
		local num = mw.ustring.match(tostring(k), '^' .. prefix .. '([1-9]%d*)$')
		if num then
			table.insert(nums, tonumber(num))
		end
	end
	table.sort(nums)
	return nums
end

--------------------------------------------------------------------------------
-- Box class definition
--------------------------------------------------------------------------------

local MessageBox = {}
MessageBox.__index = MessageBox

function MessageBox.new(boxType, args, cfg)
	args = args or {}
	local obj = {}

	-- Set the title object and the namespace.
	obj.title = getTitleObject(args.page) or mw.title.getCurrentTitle()

	-- Set the config for our box type.
	obj.cfg = cfg[boxType]
	if not obj.cfg then
		local ns = obj.title.namespace
		-- boxType is &quot;mbox&quot; or invalid input
		if ns == 0 then
			obj.cfg = cfg.ambox -- main namespace
		elseif ns == 6 then
			obj.cfg = cfg.imbox -- file namespace
		elseif ns == 14 then
			obj.cfg = cfg.cmbox -- category namespace
		else
			local nsTable = mw.site.namespaces[ns]
			if nsTable and nsTable.isTalk then
				obj.cfg = cfg.tmbox -- any talk namespace
			else
				obj.cfg = cfg.ombox -- other namespaces or invalid input
			end
		end
	end

	-- Set the arguments, and remove all blank arguments except for the ones
	-- listed in cfg.allowBlankParams.
	do
		local newArgs = {}
		for k, v in pairs(args) do
			if v ~= '' then
				newArgs[k] = v
			end
		end
		for i, param in ipairs(obj.cfg.allowBlankParams or {}) do
			newArgs[param] = args[param]
		end
		obj.args = newArgs
	end

	-- Define internal data structure.
	obj.categories = {}
	obj.classes = {}

	return setmetatable(obj, MessageBox)
end

function MessageBox:addCat(ns, cat, sort)
	if not cat then
		return nil
	end
	if sort then
		cat = string.format('[[Mkhakha:%s|%s]]', cat, sort)
	else
		cat = string.format('[[Mkhakha:%s]]', cat)
	end
	self.categories[ns] = self.categories[ns] or {}
	table.insert(self.categories[ns], cat)
end

function MessageBox:addClass(class)
	if not class then
		return nil
	end
	table.insert(self.classes, class)
end

function MessageBox:setParameters()
	local args = self.args
	local cfg = self.cfg

	-- Get type data.
	self.type = args.type
	local typeData = cfg.types[self.type]
	self.invalidTypeError = cfg.showInvalidTypeError
		and self.type
		and not typeData
	typeData = typeData or cfg.types[cfg.default]
	self.typeClass = typeData.class
	self.typeImage = typeData.image

	-- Find if the box has been wrongly substituted.
	self.isSubstituted = cfg.substCheck and args.subst == 'SUBST'

	-- Find whether we are using a small message box.
	self.isSmall = cfg.allowSmall and (
		cfg.smallParam and args.small == cfg.smallParam
		or not cfg.smallParam and yesno(args.small)
	)

	-- Add attributes, classes and styles.
	self.id = args.id
	if yesno(args.plainlinks) ~= false then
		self:addClass('plainlinks')
	end
	for _, class in ipairs(cfg.classes or {}) do
		self:addClass(class)
	end
	if self.isSmall then
		self:addClass(cfg.smallClass or 'mbox-small')
	end
	self:addClass(self.typeClass)
	self:addClass(args.class)
	self.style = args.style
	self.attrs = args.attrs

	-- Set text style.
	self.textstyle = args.textstyle

	-- Find if we are on the template page or not. This functionality is only
	-- used if useCollapsibleTextFields is set, or if both cfg.templateCategory
	-- and cfg.templateCategoryRequireName are set.
	self.useCollapsibleTextFields = cfg.useCollapsibleTextFields
	if self.useCollapsibleTextFields
		or cfg.templateCategory
		and cfg.templateCategoryRequireName
	then
		self.name = args.name
		if self.name then
			local templateName = mw.ustring.match(
				self.name,
				'^[tT][eE][mM][pP][lL][aA][tT][eE][%s_]*:[%s_]*(.*)$'
			) or self.name
			templateName = 'Template:' .. templateName
			self.templateTitle = getTitleObject(templateName)
		end
		self.isTemplatePage = self.templateTitle
			and mw.title.equals(self.title, self.templateTitle)
	end

	-- Process data for collapsible text fields. At the moment these are only
	-- used in {{ambox}}.
	if self.useCollapsibleTextFields then
		-- Get the self.issue value.
		if self.isSmall and args.smalltext then
			self.issue = args.smalltext
		else
			local sect
			if args.sect == '' then
				sect = 'This ' .. (cfg.sectionDefault or 'page')
			elseif type(args.sect) == 'string' then
				sect = 'This ' .. args.sect
			end
			local issue = args.issue
			issue = type(issue) == 'string' and issue ~= '' and issue or nil
			local text = args.text
			text = type(text) == 'string' and text or nil
			local issues = {}
			table.insert(issues, sect)
			table.insert(issues, issue)
			table.insert(issues, text)
			self.issue = table.concat(issues, ' ')
		end

		-- Get the self.talk value.
		local talk = args.talk
		-- Show talk links on the template page or template subpages if the talk
		-- parameter is blank.
		if talk == ''
			and self.templateTitle
			and (
				mw.title.equals(self.templateTitle, self.title)
				or self.title:isSubpageOf(self.templateTitle)
			)
		then
			talk = '#'
		elseif talk == '' then
			talk = nil
		end
		if talk then
			-- If the talk value is a talk page, make a link to that page. Else
			-- assume that it's a section heading, and make a link to the talk
			-- page of the current page with that section heading.
			local talkTitle = getTitleObject(talk)
			local talkArgIsTalkPage = true
			if not talkTitle or not talkTitle.isTalkPage then
				talkArgIsTalkPage = false
				talkTitle = getTitleObject(
					self.title.text,
					mw.site.namespaces[self.title.namespace].talk.id
				)
			end
			if talkTitle and talkTitle.exists then
				local talkText = 'Relevant discussion may be found on'
				if talkArgIsTalkPage then
					talkText = string.format(
						'%s [[|%s|%s]].',
						talkText,
						talk,
						talkTitle.prefixedText
					)
				else
					talkText = string.format(
						'%s the [[|%s#%s|talk page]].',
						talkText,
						talkTitle.prefixedText,
						talk
					)
				end
				self.talk = talkText
			end
		end

		-- Get other values.
		self.fix = args.fix ~= '' and args.fix or nil
		local date
		if args.date and args.date ~= '' then
			date = args.date
		elseif args.date == '' and self.isTemplatePage then
			date = lang:formatDate('F Y')
		end
		if date then
			self.date = string.format(&quot; &lt;small&gt;''(%s)''&lt;/small&gt;&quot;, date)
		end
		self.info = args.info
		if yesno(args.removalnotice) then
			self.removalNotice = cfg.removalNotice
		end
	end

	-- Set the non-collapsible text field. At the moment this is used by all box
	-- types other than ambox, and also by ambox when small=yes.
	if self.isSmall then
		self.text = args.smalltext or args.text
	else
		self.text = args.text
	end

	-- Set the below row.
	self.below = cfg.below and args.below

	-- General image settings.
	self.imageCellDiv = not self.isSmall and cfg.imageCellDiv
	self.imageEmptyCell = cfg.imageEmptyCell
	if cfg.imageEmptyCellStyle then
		self.imageEmptyCellStyle = 'border:none;padding:0px;width:1px'
	end

	-- Left image settings.
	local imageLeft = self.isSmall and args.smallimage or args.image
	if cfg.imageCheckBlank and imageLeft ~= 'blank' and imageLeft ~= 'none'
		or not cfg.imageCheckBlank and imageLeft ~= 'none'
	then
		self.imageLeft = imageLeft
		if not imageLeft then
			local imageSize = self.isSmall
				and (cfg.imageSmallSize or '30x30px')
				or '40x40px'
			self.imageLeft = string.format('[[Isimumathi:%s|%s|link=|alt=]]', self.typeImage
				or 'Imbox notice.png', imageSize)
		end
	end

	-- Right image settings.
	local imageRight = self.isSmall and args.smallimageright or args.imageright
	if not (cfg.imageRightNone and imageRight == 'none') then
		self.imageRight = imageRight
	end
end

function MessageBox:setMainspaceCategories()
	local args = self.args
	local cfg = self.cfg

	if not cfg.allowMainspaceCategories then
		return nil
	end

	local nums = {}
	for _, prefix in ipairs{'cat', 'category', 'all'} do
		args[prefix .. '1'] = args[prefix]
		nums = union(nums, getArgNums(args, prefix))
	end

	-- The following is roughly equivalent to the old {{Ambox/category}}.
	local date = args.date
	date = type(date) == 'string' and date
	local preposition = 'from'
	for _, num in ipairs(nums) do
		local mainCat = args['cat' .. tostring(num)]
			or args['category' .. tostring(num)]
		local allCat = args['all' .. tostring(num)]
		mainCat = type(mainCat) == 'string' and mainCat
		allCat = type(allCat) == 'string' and allCat
		if mainCat and date and date ~= '' then
			local catTitle = string.format('%s %s %s', mainCat, preposition, date)
			self:addCat(0, catTitle)
			catTitle = getTitleObject('Category:' .. catTitle)
			if not catTitle or not catTitle.exists then
				self:addCat(0, 'Articles with invalid date parameter in template')
			end
		elseif mainCat and (not date or date == '') then
			self:addCat(0, mainCat)
		end
		if allCat then
			self:addCat(0, allCat)
		end
	end
end

function MessageBox:setTemplateCategories()
	local args = self.args
	local cfg = self.cfg

	-- Add template categories.
	if cfg.templateCategory then
		if cfg.templateCategoryRequireName then
			if self.isTemplatePage then
				self:addCat(10, cfg.templateCategory)
			end
		elseif not self.title.isSubpage then
			self:addCat(10, cfg.templateCategory)
		end
	end

	-- Add template error categories.
	if cfg.templateErrorCategory then
		local templateErrorCategory = cfg.templateErrorCategory
		local templateCat, templateSort
		if not self.name and not self.title.isSubpage then
			templateCat = templateErrorCategory
		elseif self.isTemplatePage then
			local paramsToCheck = cfg.templateErrorParamsToCheck or {}
			local count = 0
			for i, param in ipairs(paramsToCheck) do
				if not args[param] then
					count = count + 1
				end
			end
			if count &gt; 0 then
				templateCat = templateErrorCategory
				templateSort = tostring(count)
			end
			if self.categoryNums and #self.categoryNums &gt; 0 then
				templateCat = templateErrorCategory
				templateSort = 'C'
			end
		end
		self:addCat(10, templateCat, templateSort)
	end
end

function MessageBox:setAllNamespaceCategories()
	-- Set categories for all namespaces.
	if self.invalidTypeError then
		local allSort = (self.title.namespace == 0 and 'Main:' or '') .. self.title.prefixedText
		self:addCat('all', 'Wikipedia message box parameter needs fixing', allSort)
	end
	if self.isSubstituted then
		self:addCat('all', 'Pages with incorrectly substituted templates')
	end
end

function MessageBox:setCategories()
	if self.title.namespace == 0 then
		self:setMainspaceCategories()
	elseif self.title.namespace == 10 then
		self:setTemplateCategories()
	end
	self:setAllNamespaceCategories()
end

function MessageBox:renderCategories()
	-- Convert category tables to strings and pass them through
	-- [[Module:Category handler]].
	return categoryHandler{
		main = table.concat(self.categories[0] or {}),
		template = table.concat(self.categories[10] or {}),
		all = table.concat(self.categories.all or {}),
		nocat = self.args.nocat,
		page = self.args.page
	}
end

function MessageBox:export()
	local root = mw.html.create()

	-- Add the subst check error.
	if self.isSubstituted and self.name then
		root:tag('b')
			:addClass('error')
			:wikitext(string.format(
				'Template &lt;code&gt;%s[[Umhlahlandlelasakhiwo:%s|%s]]%s&lt;/code&gt; has been incorrectly substituted.',
				mw.text.nowiki('{{'), self.name, self.name, mw.text.nowiki('}}')
			))
	end

	-- Create the box table.
	local boxTable = root:tag('table')
	boxTable:attr('id', self.id or nil)
	for i, class in ipairs(self.classes or {}) do
		boxTable:addClass(class or nil)
	end
	boxTable
		:cssText(self.style or nil)
		:attr('role', 'presentation')

	if self.attrs then
		boxTable:attr(self.attrs)
	end

	-- Add the left-hand image.
	local row = boxTable:tag('tr')
	if self.imageLeft then
		local imageLeftCell = row:tag('td'):addClass('mbox-image')
		if self.imageCellDiv then
			-- If we are using a div, redefine imageLeftCell so that the image
			-- is inside it. Divs use style=&quot;width: 52px;&quot;, which limits the
			-- image width to 52px. If any images in a div are wider than that,
			-- they may overlap with the text or cause other display problems.
			imageLeftCell = imageLeftCell:tag('div'):css('width', '52px')
		end
		imageLeftCell:wikitext(self.imageLeft or nil)
	elseif self.imageEmptyCell then
		-- Some message boxes define an empty cell if no image is specified, and
		-- some don't. The old template code in templates where empty cells are
		-- specified gives the following hint: &quot;No image. Cell with some width
		-- or padding necessary for text cell to have 100% width.&quot;
		row:tag('td')
			:addClass('mbox-empty-cell')
			:cssText(self.imageEmptyCellStyle or nil)
	end

	-- Add the text.
	local textCell = row:tag('td'):addClass('mbox-text')
	if self.useCollapsibleTextFields then
		-- The message box uses advanced text parameters that allow things to be
		-- collapsible. At the moment, only ambox uses this.
		textCell:cssText(self.textstyle or nil)
		local textCellDiv = textCell:tag('div')
		textCellDiv
			:addClass('mbox-text-span')
			:wikitext(self.issue or nil)
		if (self.talk or self.fix) and not self.isSmall then
			textCellDiv:tag('span')
				:addClass('hide-when-compact')
				:wikitext(self.talk and (' ' .. self.talk) or nil)
				:wikitext(self.fix and (' ' .. self.fix) or nil)
		end
		textCellDiv:wikitext(self.date and (' ' .. self.date) or nil)
		if self.info and not self.isSmall then
			textCellDiv
				:tag('span')
				:addClass('hide-when-compact')
				:wikitext(self.info and (' ' .. self.info) or nil)
		end
		if self.removalNotice then
			textCellDiv:tag('small')
				:addClass('hide-when-compact')
				:tag('i')
					:wikitext(string.format(&quot; (%s)&quot;, self.removalNotice))
		end
	else
		-- Default text formatting - anything goes.
		textCell
			:cssText(self.textstyle or nil)
			:wikitext(self.text or nil)
	end

	-- Add the right-hand image.
	if self.imageRight then
		local imageRightCell = row:tag('td'):addClass('mbox-imageright')
		if self.imageCellDiv then
			-- If we are using a div, redefine imageRightCell so that the image
			-- is inside it.
			imageRightCell = imageRightCell:tag('div'):css('width', '52px')
		end
		imageRightCell
			:wikitext(self.imageRight or nil)
	end

	-- Add the below row.
	if self.below then
		boxTable:tag('tr')
			:tag('td')
				:attr('colspan', self.imageRight and '3' or '2')
				:addClass('mbox-text')
				:cssText(self.textstyle or nil)
				:wikitext(self.below or nil)
	end

	-- Add error message for invalid type parameters.
	if self.invalidTypeError then
		root:tag('div')
			:css('text-align', 'center')
			:wikitext(string.format(
				'This message box is using an invalid &quot;type=%s&quot; parameter and needs fixing.',
				self.type or ''
			))
	end

	-- Add categories.
	root:wikitext(self:renderCategories() or nil)

	return tostring(root)
end

--------------------------------------------------------------------------------
-- Exports
--------------------------------------------------------------------------------

local p, mt = {}, {}

function p._exportClasses()
	-- For testing.
	return {
		MessageBox = MessageBox
	}
end

function p.main(boxType, args, cfgTables)
	local box = MessageBox.new(boxType, args, cfgTables or mw.loadData(CONFIG_MODULE))
	box:setParameters()
	box:setCategories()
	return box:export()
end

function mt.__index(t, k)
	return function (frame)
		if not getArgs then
			getArgs = require('Module:Arguments').getArgs
		end
		return t.main(k, getArgs(frame, {trim = false, removeBlanks = false}))
	end
end

return setmetatable(p, mt)</text>
      <sha1>1rbvtuoip6thpdgb06fmknm5ebeoml8</sha1>
    </revision>
    <revision>
      <id>446</id>
      <parentid>445</parentid>
      <timestamp>2024-10-14T13:46:29Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>445</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="16826" sha1="1rbvtuoip6thpdgb06fmknm5ebeoml8" xml:space="preserve">-- This is a meta-module for producing message box templates, including
-- {{mbox}}, {{ambox}}, {{imbox}}, {{tmbox}}, {{ombox}}, {{cmbox}} and {{fmbox}}.

-- Load necessary modules.
require('Module:No globals')
local getArgs
local categoryHandler = require('Module:Category handler')._main
local yesno = require('Module:Yesno')

-- Get a language object for formatDate and ucfirst.
local lang = mw.language.getContentLanguage()

-- Define constants
local CONFIG_MODULE = 'Module:Message box/configuration'

--------------------------------------------------------------------------------
-- Helper functions
--------------------------------------------------------------------------------

local function getTitleObject(...)
	-- Get the title object, passing the function through pcall
	-- in case we are over the expensive function count limit.
	local success, title = pcall(mw.title.new, ...)
	if success then
		return title
	end
end

local function union(t1, t2)
	-- Returns the union of two arrays.
	local vals = {}
	for i, v in ipairs(t1) do
		vals[v] = true
	end
	for i, v in ipairs(t2) do
		vals[v] = true
	end
	local ret = {}
	for k in pairs(vals) do
		table.insert(ret, k)
	end
	table.sort(ret)
	return ret
end

local function getArgNums(args, prefix)
	local nums = {}
	for k, v in pairs(args) do
		local num = mw.ustring.match(tostring(k), '^' .. prefix .. '([1-9]%d*)$')
		if num then
			table.insert(nums, tonumber(num))
		end
	end
	table.sort(nums)
	return nums
end

--------------------------------------------------------------------------------
-- Box class definition
--------------------------------------------------------------------------------

local MessageBox = {}
MessageBox.__index = MessageBox

function MessageBox.new(boxType, args, cfg)
	args = args or {}
	local obj = {}

	-- Set the title object and the namespace.
	obj.title = getTitleObject(args.page) or mw.title.getCurrentTitle()

	-- Set the config for our box type.
	obj.cfg = cfg[boxType]
	if not obj.cfg then
		local ns = obj.title.namespace
		-- boxType is &quot;mbox&quot; or invalid input
		if ns == 0 then
			obj.cfg = cfg.ambox -- main namespace
		elseif ns == 6 then
			obj.cfg = cfg.imbox -- file namespace
		elseif ns == 14 then
			obj.cfg = cfg.cmbox -- category namespace
		else
			local nsTable = mw.site.namespaces[ns]
			if nsTable and nsTable.isTalk then
				obj.cfg = cfg.tmbox -- any talk namespace
			else
				obj.cfg = cfg.ombox -- other namespaces or invalid input
			end
		end
	end

	-- Set the arguments, and remove all blank arguments except for the ones
	-- listed in cfg.allowBlankParams.
	do
		local newArgs = {}
		for k, v in pairs(args) do
			if v ~= '' then
				newArgs[k] = v
			end
		end
		for i, param in ipairs(obj.cfg.allowBlankParams or {}) do
			newArgs[param] = args[param]
		end
		obj.args = newArgs
	end

	-- Define internal data structure.
	obj.categories = {}
	obj.classes = {}

	return setmetatable(obj, MessageBox)
end

function MessageBox:addCat(ns, cat, sort)
	if not cat then
		return nil
	end
	if sort then
		cat = string.format('[[Mkhakha:%s|%s]]', cat, sort)
	else
		cat = string.format('[[Mkhakha:%s]]', cat)
	end
	self.categories[ns] = self.categories[ns] or {}
	table.insert(self.categories[ns], cat)
end

function MessageBox:addClass(class)
	if not class then
		return nil
	end
	table.insert(self.classes, class)
end

function MessageBox:setParameters()
	local args = self.args
	local cfg = self.cfg

	-- Get type data.
	self.type = args.type
	local typeData = cfg.types[self.type]
	self.invalidTypeError = cfg.showInvalidTypeError
		and self.type
		and not typeData
	typeData = typeData or cfg.types[cfg.default]
	self.typeClass = typeData.class
	self.typeImage = typeData.image

	-- Find if the box has been wrongly substituted.
	self.isSubstituted = cfg.substCheck and args.subst == 'SUBST'

	-- Find whether we are using a small message box.
	self.isSmall = cfg.allowSmall and (
		cfg.smallParam and args.small == cfg.smallParam
		or not cfg.smallParam and yesno(args.small)
	)

	-- Add attributes, classes and styles.
	self.id = args.id
	if yesno(args.plainlinks) ~= false then
		self:addClass('plainlinks')
	end
	for _, class in ipairs(cfg.classes or {}) do
		self:addClass(class)
	end
	if self.isSmall then
		self:addClass(cfg.smallClass or 'mbox-small')
	end
	self:addClass(self.typeClass)
	self:addClass(args.class)
	self.style = args.style
	self.attrs = args.attrs

	-- Set text style.
	self.textstyle = args.textstyle

	-- Find if we are on the template page or not. This functionality is only
	-- used if useCollapsibleTextFields is set, or if both cfg.templateCategory
	-- and cfg.templateCategoryRequireName are set.
	self.useCollapsibleTextFields = cfg.useCollapsibleTextFields
	if self.useCollapsibleTextFields
		or cfg.templateCategory
		and cfg.templateCategoryRequireName
	then
		self.name = args.name
		if self.name then
			local templateName = mw.ustring.match(
				self.name,
				'^[tT][eE][mM][pP][lL][aA][tT][eE][%s_]*:[%s_]*(.*)$'
			) or self.name
			templateName = 'Template:' .. templateName
			self.templateTitle = getTitleObject(templateName)
		end
		self.isTemplatePage = self.templateTitle
			and mw.title.equals(self.title, self.templateTitle)
	end

	-- Process data for collapsible text fields. At the moment these are only
	-- used in {{ambox}}.
	if self.useCollapsibleTextFields then
		-- Get the self.issue value.
		if self.isSmall and args.smalltext then
			self.issue = args.smalltext
		else
			local sect
			if args.sect == '' then
				sect = 'This ' .. (cfg.sectionDefault or 'page')
			elseif type(args.sect) == 'string' then
				sect = 'This ' .. args.sect
			end
			local issue = args.issue
			issue = type(issue) == 'string' and issue ~= '' and issue or nil
			local text = args.text
			text = type(text) == 'string' and text or nil
			local issues = {}
			table.insert(issues, sect)
			table.insert(issues, issue)
			table.insert(issues, text)
			self.issue = table.concat(issues, ' ')
		end

		-- Get the self.talk value.
		local talk = args.talk
		-- Show talk links on the template page or template subpages if the talk
		-- parameter is blank.
		if talk == ''
			and self.templateTitle
			and (
				mw.title.equals(self.templateTitle, self.title)
				or self.title:isSubpageOf(self.templateTitle)
			)
		then
			talk = '#'
		elseif talk == '' then
			talk = nil
		end
		if talk then
			-- If the talk value is a talk page, make a link to that page. Else
			-- assume that it's a section heading, and make a link to the talk
			-- page of the current page with that section heading.
			local talkTitle = getTitleObject(talk)
			local talkArgIsTalkPage = true
			if not talkTitle or not talkTitle.isTalkPage then
				talkArgIsTalkPage = false
				talkTitle = getTitleObject(
					self.title.text,
					mw.site.namespaces[self.title.namespace].talk.id
				)
			end
			if talkTitle and talkTitle.exists then
				local talkText = 'Relevant discussion may be found on'
				if talkArgIsTalkPage then
					talkText = string.format(
						'%s [[|%s|%s]].',
						talkText,
						talk,
						talkTitle.prefixedText
					)
				else
					talkText = string.format(
						'%s the [[|%s#%s|talk page]].',
						talkText,
						talkTitle.prefixedText,
						talk
					)
				end
				self.talk = talkText
			end
		end

		-- Get other values.
		self.fix = args.fix ~= '' and args.fix or nil
		local date
		if args.date and args.date ~= '' then
			date = args.date
		elseif args.date == '' and self.isTemplatePage then
			date = lang:formatDate('F Y')
		end
		if date then
			self.date = string.format(&quot; &lt;small&gt;''(%s)''&lt;/small&gt;&quot;, date)
		end
		self.info = args.info
		if yesno(args.removalnotice) then
			self.removalNotice = cfg.removalNotice
		end
	end

	-- Set the non-collapsible text field. At the moment this is used by all box
	-- types other than ambox, and also by ambox when small=yes.
	if self.isSmall then
		self.text = args.smalltext or args.text
	else
		self.text = args.text
	end

	-- Set the below row.
	self.below = cfg.below and args.below

	-- General image settings.
	self.imageCellDiv = not self.isSmall and cfg.imageCellDiv
	self.imageEmptyCell = cfg.imageEmptyCell
	if cfg.imageEmptyCellStyle then
		self.imageEmptyCellStyle = 'border:none;padding:0px;width:1px'
	end

	-- Left image settings.
	local imageLeft = self.isSmall and args.smallimage or args.image
	if cfg.imageCheckBlank and imageLeft ~= 'blank' and imageLeft ~= 'none'
		or not cfg.imageCheckBlank and imageLeft ~= 'none'
	then
		self.imageLeft = imageLeft
		if not imageLeft then
			local imageSize = self.isSmall
				and (cfg.imageSmallSize or '30x30px')
				or '40x40px'
			self.imageLeft = string.format('[[Isimumathi:%s|%s|link=|alt=]]', self.typeImage
				or 'Imbox notice.png', imageSize)
		end
	end

	-- Right image settings.
	local imageRight = self.isSmall and args.smallimageright or args.imageright
	if not (cfg.imageRightNone and imageRight == 'none') then
		self.imageRight = imageRight
	end
end

function MessageBox:setMainspaceCategories()
	local args = self.args
	local cfg = self.cfg

	if not cfg.allowMainspaceCategories then
		return nil
	end

	local nums = {}
	for _, prefix in ipairs{'cat', 'category', 'all'} do
		args[prefix .. '1'] = args[prefix]
		nums = union(nums, getArgNums(args, prefix))
	end

	-- The following is roughly equivalent to the old {{Ambox/category}}.
	local date = args.date
	date = type(date) == 'string' and date
	local preposition = 'from'
	for _, num in ipairs(nums) do
		local mainCat = args['cat' .. tostring(num)]
			or args['category' .. tostring(num)]
		local allCat = args['all' .. tostring(num)]
		mainCat = type(mainCat) == 'string' and mainCat
		allCat = type(allCat) == 'string' and allCat
		if mainCat and date and date ~= '' then
			local catTitle = string.format('%s %s %s', mainCat, preposition, date)
			self:addCat(0, catTitle)
			catTitle = getTitleObject('Category:' .. catTitle)
			if not catTitle or not catTitle.exists then
				self:addCat(0, 'Articles with invalid date parameter in template')
			end
		elseif mainCat and (not date or date == '') then
			self:addCat(0, mainCat)
		end
		if allCat then
			self:addCat(0, allCat)
		end
	end
end

function MessageBox:setTemplateCategories()
	local args = self.args
	local cfg = self.cfg

	-- Add template categories.
	if cfg.templateCategory then
		if cfg.templateCategoryRequireName then
			if self.isTemplatePage then
				self:addCat(10, cfg.templateCategory)
			end
		elseif not self.title.isSubpage then
			self:addCat(10, cfg.templateCategory)
		end
	end

	-- Add template error categories.
	if cfg.templateErrorCategory then
		local templateErrorCategory = cfg.templateErrorCategory
		local templateCat, templateSort
		if not self.name and not self.title.isSubpage then
			templateCat = templateErrorCategory
		elseif self.isTemplatePage then
			local paramsToCheck = cfg.templateErrorParamsToCheck or {}
			local count = 0
			for i, param in ipairs(paramsToCheck) do
				if not args[param] then
					count = count + 1
				end
			end
			if count &gt; 0 then
				templateCat = templateErrorCategory
				templateSort = tostring(count)
			end
			if self.categoryNums and #self.categoryNums &gt; 0 then
				templateCat = templateErrorCategory
				templateSort = 'C'
			end
		end
		self:addCat(10, templateCat, templateSort)
	end
end

function MessageBox:setAllNamespaceCategories()
	-- Set categories for all namespaces.
	if self.invalidTypeError then
		local allSort = (self.title.namespace == 0 and 'Main:' or '') .. self.title.prefixedText
		self:addCat('all', 'Wikipedia message box parameter needs fixing', allSort)
	end
	if self.isSubstituted then
		self:addCat('all', 'Pages with incorrectly substituted templates')
	end
end

function MessageBox:setCategories()
	if self.title.namespace == 0 then
		self:setMainspaceCategories()
	elseif self.title.namespace == 10 then
		self:setTemplateCategories()
	end
	self:setAllNamespaceCategories()
end

function MessageBox:renderCategories()
	-- Convert category tables to strings and pass them through
	-- [[Module:Category handler]].
	return categoryHandler{
		main = table.concat(self.categories[0] or {}),
		template = table.concat(self.categories[10] or {}),
		all = table.concat(self.categories.all or {}),
		nocat = self.args.nocat,
		page = self.args.page
	}
end

function MessageBox:export()
	local root = mw.html.create()

	-- Add the subst check error.
	if self.isSubstituted and self.name then
		root:tag('b')
			:addClass('error')
			:wikitext(string.format(
				'Template &lt;code&gt;%s[[Umhlahlandlelasakhiwo:%s|%s]]%s&lt;/code&gt; has been incorrectly substituted.',
				mw.text.nowiki('{{'), self.name, self.name, mw.text.nowiki('}}')
			))
	end

	-- Create the box table.
	local boxTable = root:tag('table')
	boxTable:attr('id', self.id or nil)
	for i, class in ipairs(self.classes or {}) do
		boxTable:addClass(class or nil)
	end
	boxTable
		:cssText(self.style or nil)
		:attr('role', 'presentation')

	if self.attrs then
		boxTable:attr(self.attrs)
	end

	-- Add the left-hand image.
	local row = boxTable:tag('tr')
	if self.imageLeft then
		local imageLeftCell = row:tag('td'):addClass('mbox-image')
		if self.imageCellDiv then
			-- If we are using a div, redefine imageLeftCell so that the image
			-- is inside it. Divs use style=&quot;width: 52px;&quot;, which limits the
			-- image width to 52px. If any images in a div are wider than that,
			-- they may overlap with the text or cause other display problems.
			imageLeftCell = imageLeftCell:tag('div'):css('width', '52px')
		end
		imageLeftCell:wikitext(self.imageLeft or nil)
	elseif self.imageEmptyCell then
		-- Some message boxes define an empty cell if no image is specified, and
		-- some don't. The old template code in templates where empty cells are
		-- specified gives the following hint: &quot;No image. Cell with some width
		-- or padding necessary for text cell to have 100% width.&quot;
		row:tag('td')
			:addClass('mbox-empty-cell')
			:cssText(self.imageEmptyCellStyle or nil)
	end

	-- Add the text.
	local textCell = row:tag('td'):addClass('mbox-text')
	if self.useCollapsibleTextFields then
		-- The message box uses advanced text parameters that allow things to be
		-- collapsible. At the moment, only ambox uses this.
		textCell:cssText(self.textstyle or nil)
		local textCellDiv = textCell:tag('div')
		textCellDiv
			:addClass('mbox-text-span')
			:wikitext(self.issue or nil)
		if (self.talk or self.fix) and not self.isSmall then
			textCellDiv:tag('span')
				:addClass('hide-when-compact')
				:wikitext(self.talk and (' ' .. self.talk) or nil)
				:wikitext(self.fix and (' ' .. self.fix) or nil)
		end
		textCellDiv:wikitext(self.date and (' ' .. self.date) or nil)
		if self.info and not self.isSmall then
			textCellDiv
				:tag('span')
				:addClass('hide-when-compact')
				:wikitext(self.info and (' ' .. self.info) or nil)
		end
		if self.removalNotice then
			textCellDiv:tag('small')
				:addClass('hide-when-compact')
				:tag('i')
					:wikitext(string.format(&quot; (%s)&quot;, self.removalNotice))
		end
	else
		-- Default text formatting - anything goes.
		textCell
			:cssText(self.textstyle or nil)
			:wikitext(self.text or nil)
	end

	-- Add the right-hand image.
	if self.imageRight then
		local imageRightCell = row:tag('td'):addClass('mbox-imageright')
		if self.imageCellDiv then
			-- If we are using a div, redefine imageRightCell so that the image
			-- is inside it.
			imageRightCell = imageRightCell:tag('div'):css('width', '52px')
		end
		imageRightCell
			:wikitext(self.imageRight or nil)
	end

	-- Add the below row.
	if self.below then
		boxTable:tag('tr')
			:tag('td')
				:attr('colspan', self.imageRight and '3' or '2')
				:addClass('mbox-text')
				:cssText(self.textstyle or nil)
				:wikitext(self.below or nil)
	end

	-- Add error message for invalid type parameters.
	if self.invalidTypeError then
		root:tag('div')
			:css('text-align', 'center')
			:wikitext(string.format(
				'This message box is using an invalid &quot;type=%s&quot; parameter and needs fixing.',
				self.type or ''
			))
	end

	-- Add categories.
	root:wikitext(self:renderCategories() or nil)

	return tostring(root)
end

--------------------------------------------------------------------------------
-- Exports
--------------------------------------------------------------------------------

local p, mt = {}, {}

function p._exportClasses()
	-- For testing.
	return {
		MessageBox = MessageBox
	}
end

function p.main(boxType, args, cfgTables)
	local box = MessageBox.new(boxType, args, cfgTables or mw.loadData(CONFIG_MODULE))
	box:setParameters()
	box:setCategories()
	return box:export()
end

function mt.__index(t, k)
	return function (frame)
		if not getArgs then
			getArgs = require('Module:Arguments').getArgs
		end
		return t.main(k, getArgs(frame, {trim = false, removeBlanks = false}))
	end
end

return setmetatable(p, mt)</text>
      <sha1>1rbvtuoip6thpdgb06fmknm5ebeoml8</sha1>
    </revision>
    <revision>
      <id>6609</id>
      <parentid>446</parentid>
      <timestamp>2026-05-19T06:39:34Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6609</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="22838" sha1="ocboyo877qnpqum2b9fyiquh72vukqa" xml:space="preserve">require('strict')
local getArgs
local yesno = require('Module:Yesno')
local lang = mw.language.getContentLanguage()

local CONFIG_MODULE = 'Module:Message box/configuration'
local DEMOSPACES = {talk = 'tmbox', image = 'imbox', file = 'imbox', category = 'cmbox', article = 'ambox', main = 'ambox'}

--------------------------------------------------------------------------------
-- Helper functions
--------------------------------------------------------------------------------

local function getTitleObject(...)
	-- Get the title object, passing the function through pcall
	-- in case we are over the expensive function count limit.
	local success, title = pcall(mw.title.new, ...)
	if success then
		return title
	end
end

local function union(t1, t2)
	-- Returns the union of two arrays.
	local vals = {}
	for i, v in ipairs(t1) do
		vals[v] = true
	end
	for i, v in ipairs(t2) do
		vals[v] = true
	end
	local ret = {}
	for k in pairs(vals) do
		table.insert(ret, k)
	end
	table.sort(ret)
	return ret
end

local function getArgNums(args, prefix)
	local nums = {}
	for k, v in pairs(args) do
		local num = mw.ustring.match(tostring(k), '^' .. prefix .. '([1-9]%d*)$')
		if num then
			table.insert(nums, tonumber(num))
		end
	end
	table.sort(nums)
	return nums
end

--------------------------------------------------------------------------------
-- Box class definition
--------------------------------------------------------------------------------

local MessageBox = {}
MessageBox.__index = MessageBox

function MessageBox.new(boxType, args, cfg)
	args = args or {}
	local obj = {}

	-- Set the title object and the namespace.
	obj.title = getTitleObject(args.page) or mw.title.getCurrentTitle()

	-- Set the config for our box type.
	obj.cfg = cfg[boxType]
	if not obj.cfg then
		local ns = obj.title.namespace
		-- boxType is &quot;mbox&quot; or invalid input
		if args.demospace and args.demospace ~= '' then
			-- implement demospace parameter of mbox
			local demospace = string.lower(args.demospace)
			if DEMOSPACES[demospace] then
				-- use template from DEMOSPACES
				obj.cfg = cfg[DEMOSPACES[demospace]]
			elseif string.find( demospace, 'talk' ) then
				-- demo as a talk page
				obj.cfg = cfg.tmbox
			else
				-- default to ombox
				obj.cfg = cfg.ombox
			end
		elseif ns == 0 then
			obj.cfg = cfg.ambox -- main namespace
		elseif ns == 6 then
			obj.cfg = cfg.imbox -- file namespace
		elseif ns == 14 then
			obj.cfg = cfg.cmbox -- category namespace
		else
			local nsTable = mw.site.namespaces[ns]
			if nsTable and nsTable.isTalk then
				obj.cfg = cfg.tmbox -- any talk namespace
			else
				obj.cfg = cfg.ombox -- other namespaces or invalid input
			end
		end
	end

	-- Set the arguments, and remove all blank arguments except for the ones
	-- listed in cfg.allowBlankParams.
	do
		local newArgs = {}
		for k, v in pairs(args) do
			if v ~= '' then
				newArgs[k] = v
			end
		end
		for i, param in ipairs(obj.cfg.allowBlankParams or {}) do
			newArgs[param] = args[param]
		end
		obj.args = newArgs
	end

	-- Define internal data structure.
	obj.categories = {}
	obj.classes = {}
	-- For lazy loading of [[Module:Category handler]].
	obj.hasCategories = false

	return setmetatable(obj, MessageBox)
end

function MessageBox:addCat(ns, cat, sort)
	if not cat then
		return nil
	end
	if sort then
		cat = string.format('[[Category:%s|%s]]', cat, sort)
	else
		cat = string.format('[[Category:%s]]', cat)
	end
	self.hasCategories = true
	self.categories[ns] = self.categories[ns] or {}
	table.insert(self.categories[ns], cat)
end

function MessageBox:addClass(class)
	if not class then
		return nil
	end
	table.insert(self.classes, class)
end

function MessageBox:setParameters()
	local args = self.args
	local cfg = self.cfg

	-- Get type data.
	self.type = args.type
	local typeData = cfg.types[self.type]
	self.invalidTypeError = cfg.showInvalidTypeError
		and self.type
		and not typeData
	typeData = typeData or cfg.types[cfg.default]
	self.typeClass = typeData.class
	self.typeImage = typeData.image
	self.typeImageNeedsLink = typeData.imageNeedsLink

	-- Find if the box has been wrongly substituted.
	self.isSubstituted = cfg.substCheck and args.subst == 'SUBST'

	-- Find whether we are using a small message box.
	self.isSmall = cfg.allowSmall and (
		cfg.smallParam and args.small == cfg.smallParam
		or not cfg.smallParam and yesno(args.small)
	)

	-- Set the below row.
	self.below = cfg.below and args.below
	
	-- Add attributes, classes and styles.
	self.id = args.id
	self.name = args.name
	if self.name then
		self:addClass('box-' .. string.gsub(self.name,' ','_'))
	end
	if yesno(args.plainlinks) ~= false then
		self:addClass('plainlinks')
	end
	if self.below then
		self:addClass('mbox-with-below')
	end
	for _, class in ipairs(cfg.classes or {}) do
		self:addClass(class)
	end
	if self.isSmall then
		self:addClass(cfg.smallClass or 'mbox-small')
	end
	self:addClass(self.typeClass)
	self:addClass(args.class)
	self.style = args.style
	self.attrs = args.attrs

	-- Set text style.
	self.textstyle = args.textstyle

	-- Set image classes.
	self.imageRightClass = args.imagerightclass or args.imageclass
	self.imageLeftClass = args.imageleftclass or args.imageclass

	-- Find if we are on the template page or not. This functionality is only
	-- used if useCollapsibleTextFields is set, or if both cfg.templateCategory
	-- and cfg.templateCategoryRequireName are set.
	self.useCollapsibleTextFields = cfg.useCollapsibleTextFields
	if self.useCollapsibleTextFields
		or cfg.templateCategory
		and cfg.templateCategoryRequireName
	then
		if self.name then
			local templateName = mw.ustring.match(
				self.name,
				'^[tT][eE][mM][pP][lL][aA][tT][eE][%s_]*:[%s_]*(.*)$'
			) or self.name
			templateName = 'Template:' .. templateName
			self.templateTitle = getTitleObject(templateName)
		end
		self.isTemplatePage = self.templateTitle
			and mw.title.equals(self.title, self.templateTitle)
	end
	
	-- Process data for collapsible text fields. At the moment these are only
	-- used in {{ambox}}.
	if self.useCollapsibleTextFields then
		-- Get the self.issue value.
		if self.isSmall and args.smalltext then
			self.issue = args.smalltext
		else
			local sect
			if args.sect == '' then
				sect = 'This ' .. (cfg.sectionDefault or 'page')
			elseif type(args.sect) == 'string' then
				sect = 'This ' .. args.sect
			end
			local issue = args.issue
			issue = type(issue) == 'string' and issue ~= '' and issue or nil
			local text = args.text
			text = type(text) == 'string' and text or nil
			local issues = {}
			table.insert(issues, sect)
			table.insert(issues, issue)
			table.insert(issues, text)
			self.issue = table.concat(issues, ' ')
		end

		-- Get the self.talk value.
		local talk = args.talk
		-- Show talk links on the template page or template subpages if the talk
		-- parameter is blank.
		if talk == ''
			and self.templateTitle
			and (
				mw.title.equals(self.templateTitle, self.title)
				or self.title:isSubpageOf(self.templateTitle)
			)
		then
			talk = '#'
		elseif talk == '' then
			talk = nil
		end
		if talk then
			-- If the talk value is a talk page, make a link to that page. Else
			-- assume that it's a section heading, and make a link to the talk
			-- page of the current page with that section heading.
			local talkTitle = getTitleObject(talk)
			local talkArgIsTalkPage = true
			if not talkTitle or not talkTitle.isTalkPage then
				talkArgIsTalkPage = false
				talkTitle = getTitleObject(
					self.title.text,
					mw.site.namespaces[self.title.namespace].talk.id
				)
			end
			if talkTitle and talkTitle.exists then
                local talkText
                if self.isSmall then
                    local talkLink = talkArgIsTalkPage and talk or (talkTitle.prefixedText .. (talk == '#' and '' or '#') .. talk)
                    talkText = string.format('([[%s|talk]])', talkLink)
                else
                    talkText = 'Relevant discussion may be found on'
                    if talkArgIsTalkPage then
                        talkText = string.format(
                            '%s [[%s|%s]].',
                            talkText,
                            talk,
                            talkTitle.prefixedText
                        )
                    else
                        talkText = string.format(
                            '%s the [[%s' .. (talk == '#' and '' or '#') .. '%s|talk page]].',
                            talkText,
                            talkTitle.prefixedText,
                            talk
                        )
                    end
                end
				self.talk = talkText
			end
		end

		-- Get other values.
		self.fix = args.fix ~= '' and args.fix or nil
		local date
		if args.date and args.date ~= '' then
			date = args.date
		elseif args.date == '' and self.isTemplatePage then
			date = lang:formatDate('F Y')
		end
		if date then
			self.date = string.format(&quot; &lt;span class='date-container'&gt;&lt;i&gt;(&lt;span class='date'&gt;%s&lt;/span&gt;)&lt;/i&gt;&lt;/span&gt;&quot;, date)
		end
		self.info = args.info
		if yesno(args.removalnotice) then
			self.removalNotice = cfg.removalNotice
		end
	end

	-- Set the non-collapsible text field. At the moment this is used by all box
	-- types other than ambox, and also by ambox when small=yes.
	if self.isSmall then
		self.text = args.smalltext or args.text
	else
		self.text = args.text
	end

	-- General image settings.
	self.imageCellDiv = not self.isSmall and cfg.imageCellDiv
	self.imageEmptyCell = cfg.imageEmptyCell

	-- Left image settings.
	local imageLeft = self.isSmall and args.smallimage or args.image
	if cfg.imageCheckBlank and imageLeft ~= 'blank' and imageLeft ~= 'none'
		or not cfg.imageCheckBlank and imageLeft ~= 'none'
	then
		self.imageLeft = imageLeft
		if not imageLeft then
			local imageSize = self.isSmall
				and (cfg.imageSmallSize or '30x30px')
				or '40x40px'
			self.imageLeft = string.format('[[File:%s|%s%s|alt=]]', self.typeImage
				or 'Information icon4.svg', imageSize, self.typeImageNeedsLink and &quot;&quot; or &quot;|link=&quot; )
		end
	end

	-- Right image settings.
	local imageRight = self.isSmall and args.smallimageright or args.imageright
	if not (cfg.imageRightNone and imageRight == 'none') then
		self.imageRight = imageRight
	end
	
	-- set templatestyles
	self.base_templatestyles = cfg.templatestyles
	self.templatestyles = args.templatestyles
end

function MessageBox:setMainspaceCategories()
	local args = self.args
	local cfg = self.cfg

	if not cfg.allowMainspaceCategories then
		return nil
	end

	local nums = {}
	for _, prefix in ipairs{'cat', 'category', 'all'} do
		args[prefix .. '1'] = args[prefix]
		nums = union(nums, getArgNums(args, prefix))
	end

	-- The following is roughly equivalent to the old {{Ambox/category}}.
	local date = args.date
	date = type(date) == 'string' and date
	local preposition = 'from'
	for _, num in ipairs(nums) do
		local mainCat = args['cat' .. tostring(num)]
			or args['category' .. tostring(num)]
		local allCat = args['all' .. tostring(num)]
		mainCat = type(mainCat) == 'string' and mainCat
		allCat = type(allCat) == 'string' and allCat
		if mainCat and date and date ~= '' then
			local catTitle = string.format('%s %s %s', mainCat, preposition, date)
			self:addCat(0, catTitle)
			catTitle = getTitleObject('Category:' .. catTitle)
			if not catTitle or not catTitle.exists then
				self:addCat(0, 'Articles with invalid date parameter in template')
			end
		elseif mainCat and (not date or date == '') then
			self:addCat(0, mainCat)
		end
		if allCat then
			self:addCat(0, allCat)
		end
	end
end

function MessageBox:setTemplateCategories()
	local args = self.args
	local cfg = self.cfg

	-- Add template categories.
	if cfg.templateCategory then
		if cfg.templateCategoryRequireName then
			if self.isTemplatePage then
				self:addCat(10, cfg.templateCategory)
			end
		elseif not self.title.isSubpage then
			self:addCat(10, cfg.templateCategory)
		end
	end

	-- Add template error categories.
	if cfg.templateErrorCategory then
		local templateErrorCategory = cfg.templateErrorCategory
		local templateCat, templateSort
		if not self.name and not self.title.isSubpage then
			templateCat = templateErrorCategory
		elseif self.isTemplatePage then
			local paramsToCheck = cfg.templateErrorParamsToCheck or {}
			local count = 0
			for i, param in ipairs(paramsToCheck) do
				if not args[param] then
					count = count + 1
				end
			end
			if count &gt; 0 then
				templateCat = templateErrorCategory
				templateSort = tostring(count)
			end
			if self.categoryNums and #self.categoryNums &gt; 0 then
				templateCat = templateErrorCategory
				templateSort = 'C'
			end
		end
		self:addCat(10, templateCat, templateSort)
	end
end

function MessageBox:setAllNamespaceCategories()
	-- Set categories for all namespaces.
	if self.invalidTypeError then
		local allSort = (self.title.namespace == 0 and 'Main:' or '') .. self.title.prefixedText
		self:addCat('all', 'Wikipedia message box parameter needs fixing', allSort)
	end
	if self.isSubstituted then
		self:addCat('all', 'Pages with incorrectly substituted templates')
	end
end

function MessageBox:setCategories()
	if self.title.namespace == 0 then
		self:setMainspaceCategories()
	elseif self.title.namespace == 10 then
		self:setTemplateCategories()
	end
	self:setAllNamespaceCategories()
end

function MessageBox:renderCategories()
	if not self.hasCategories then
		-- No categories added, no need to pass them to Category handler so,
		-- if it was invoked, it would return the empty string.
		-- So we shortcut and return the empty string.
		return &quot;&quot;
	end
	-- Convert category tables to strings and pass them through
	-- [[Module:Category handler]].
	return require('Module:Category handler')._main{
		main = table.concat(self.categories[0] or {}),
		template = table.concat(self.categories[10] or {}),
		all = table.concat(self.categories.all or {}),
		nocat = self.args.nocat,
		page = self.args.page
	}
end

function MessageBox:exportDiv()
	local root = mw.html.create()

	-- Add the subst check error.
	if self.isSubstituted and self.name then
		root:tag('b')
			:addClass('error')
			:wikitext(string.format(
				'Template &lt;code&gt;%s[[Template:%s|%s]]%s&lt;/code&gt; has been incorrectly substituted.',
				mw.text.nowiki('{{'), self.name, self.name, mw.text.nowiki('}}')
			))
	end

	local frame = mw.getCurrentFrame()
	root:wikitext(frame:extensionTag{
		name = 'templatestyles',
		args = { src = self.base_templatestyles },
	})
	-- Add support for a single custom templatestyles sheet. Undocumented as
	-- need should be limited and many templates using mbox are substed; we
	-- don't want to spread templatestyles sheets around to arbitrary places
	if self.templatestyles then
		root:wikitext(frame:extensionTag{
			name = 'templatestyles',
			args = { src = self.templatestyles },
		})
	end

	-- Create the box.
	local mbox = root:tag('div')
	mbox:attr('id', self.id or nil)
	for i, class in ipairs(self.classes or {}) do
		mbox:addClass(class or nil)
	end
	mbox
		:cssText(self.style or nil)

	if self.attrs then
		mbox:attr(self.attrs)
	end
	
	local flex_container
	if self.below then
		-- we need to wrap the flex components (`image(right)` and `text`) in their
		-- own container div to support the `below` parameter
		flex_container = mw.html.create('div')
		flex_container:addClass('mbox-flex')
	else
		-- the mbox itself is the parent, so we need no HTML flex_container
		flex_container = mw.html.create()
	end

	-- Add the left-hand image.
	if self.imageLeft then
		local imageLeftCell = flex_container:tag('div'):addClass('mbox-image')
		imageLeftCell
			:addClass(self.imageLeftClass)
			:wikitext(self.imageLeft or nil)
	end

	-- Add the text.
	local textCell = flex_container:tag('div'):addClass('mbox-text')
	if self.useCollapsibleTextFields then
		-- The message box uses advanced text parameters that allow things to be
		-- collapsible. At the moment, only ambox uses this.
		textCell:cssText(self.textstyle or nil)
		local textCellDiv = textCell:tag('div')
		textCellDiv
			:addClass('mbox-text-span')
			:wikitext(self.issue or nil)
		if (self.talk or self.fix) then
			textCellDiv:tag('span')
				:addClass('hide-when-compact')
				:wikitext(self.talk and (' ' .. self.talk) or nil)
				:wikitext(self.fix and (' ' .. self.fix) or nil)
		end
		textCellDiv:wikitext(self.date and (' ' .. self.date) or nil)
		if self.info and not self.isSmall then
			textCellDiv
				:tag('span')
				:addClass('hide-when-compact')
				:wikitext(self.info and (' ' .. self.info) or nil)
		end
		if self.removalNotice then
			textCellDiv:tag('span')
				:addClass('hide-when-compact')
				:tag('i')
					:wikitext(string.format(&quot; (%s)&quot;, self.removalNotice))
		end
	else
		-- Default text formatting - anything goes.
		textCell
			:cssText(self.textstyle or nil)
			:wikitext(self.text or nil)
	end

	-- Add the right-hand image.
	if self.imageRight then
		local imageRightCell = flex_container:tag('div'):addClass('mbox-imageright')
		imageRightCell
			:addClass(self.imageRightClass)
			:wikitext(self.imageRight or nil)
	end
	
	mbox:node(flex_container)

	-- Add the below row.
	if self.below then
		mbox:tag('div')
			:addClass('mbox-text mbox-below')
			:cssText(self.textstyle or nil)
			:wikitext(self.below or nil)
	end

	-- Add error message for invalid type parameters.
	if self.invalidTypeError then
		root:tag('div')
			:addClass('mbox-invalid-type')
			:wikitext(string.format(
				'This message box is using an invalid &quot;type=%s&quot; parameter and needs fixing.',
				self.type or ''
			))
	end

	-- Add categories.
	root:wikitext(self:renderCategories() or nil)

	return tostring(root)
end

function MessageBox:export()

	local root = mw.html.create()

	-- Add the subst check error.
	if self.isSubstituted and self.name then
		root:tag('b')
			:addClass('error')
			:wikitext(string.format(
				'Template &lt;code&gt;%s[[Template:%s|%s]]%s&lt;/code&gt; has been incorrectly substituted.',
				mw.text.nowiki('{{'), self.name, self.name, mw.text.nowiki('}}')
			))
	end

	local frame = mw.getCurrentFrame()
	root:wikitext(frame:extensionTag{
		name = 'templatestyles',
		args = { src = self.base_templatestyles },
	})
	-- Add support for a single custom templatestyles sheet. Undocumented as
	-- need should be limited and many templates using mbox are substed; we
	-- don't want to spread templatestyles sheets around to arbitrary places
	if self.templatestyles then
		root:wikitext(frame:extensionTag{
			name = 'templatestyles',
			args = { src = self.templatestyles },
		})
	end

	-- Create the box table.
	local boxTable = root:tag('table')
	boxTable:attr('id', self.id or nil)
	for i, class in ipairs(self.classes or {}) do
		boxTable:addClass(class or nil)
	end
	boxTable
		:cssText(self.style or nil)
		:attr('role', 'presentation')

	if self.attrs then
		boxTable:attr(self.attrs)
	end

	-- Add the left-hand image.
	local row = boxTable:tag('tr')
	if self.imageLeft then
		local imageLeftCell = row:tag('td'):addClass('mbox-image')
		if self.imageCellDiv then
			-- If we are using a div, redefine imageLeftCell so that the image
			-- is inside it. Divs use style=&quot;width: 52px;&quot;, which limits the
			-- image width to 52px. If any images in a div are wider than that,
			-- they may overlap with the text or cause other display problems.
			imageLeftCell = imageLeftCell:tag('div'):addClass('mbox-image-div')
		end
		imageLeftCell
			:addClass(self.imageLeftClass)
			:wikitext(self.imageLeft or nil)
	elseif self.imageEmptyCell then
		-- Some message boxes define an empty cell if no image is specified, and
		-- some don't. The old template code in templates where empty cells are
		-- specified gives the following hint: &quot;No image. Cell with some width
		-- or padding necessary for text cell to have 100% width.&quot;
		row:tag('td')
			:addClass('mbox-empty-cell')
	end

	-- Add the text.
	local textCell = row:tag('td'):addClass('mbox-text')
	if self.useCollapsibleTextFields then
		-- The message box uses advanced text parameters that allow things to be
		-- collapsible. At the moment, only ambox uses this.
		textCell:cssText(self.textstyle or nil)
		local textCellDiv = textCell:tag('div')
		textCellDiv
			:addClass('mbox-text-span')
			:wikitext(self.issue or nil)
		if (self.talk or self.fix) then
			textCellDiv:tag('span')
				:addClass('hide-when-compact')
				:wikitext(self.talk and (' ' .. self.talk) or nil)
				:wikitext(self.fix and (' ' .. self.fix) or nil)
		end
		textCellDiv:wikitext(self.date and (' ' .. self.date) or nil)
		if self.info and not self.isSmall then
			textCellDiv
				:tag('span')
				:addClass('hide-when-compact')
				:wikitext(self.info and (' ' .. self.info) or nil)
		end
		if self.removalNotice then
			textCellDiv:tag('span')
				:addClass('hide-when-compact')
				:tag('i')
					:wikitext(string.format(&quot; (%s)&quot;, self.removalNotice))
		end
	else
		-- Default text formatting - anything goes.
		textCell
			:cssText(self.textstyle or nil)
			:wikitext(self.text or nil)
	end

	-- Add the right-hand image.
	if self.imageRight then
		local imageRightCell = row:tag('td'):addClass('mbox-imageright')
		if self.imageCellDiv then
			-- If we are using a div, redefine imageRightCell so that the image
			-- is inside it.
			imageRightCell = imageRightCell:tag('div'):addClass('mbox-image-div')
		end
		imageRightCell
			:addClass(self.imageRightClass)
			:wikitext(self.imageRight or nil)
	end

	-- Add the below row.
	if self.below then
		boxTable:tag('tr')
			:tag('td')
				:attr('colspan', self.imageRight and '3' or '2')
				:addClass('mbox-text')
				:cssText(self.textstyle or nil)
				:wikitext(self.below or nil)
	end

	-- Add error message for invalid type parameters.
	if self.invalidTypeError then
		root:tag('div')
			:addClass('mbox-invalid-type')
			:wikitext(string.format(
				'This message box is using an invalid &quot;type=%s&quot; parameter and needs fixing.',
				self.type or ''
			))
	end

	-- Add categories.
	root:wikitext(self:renderCategories() or nil)

	return tostring(root)
end

--------------------------------------------------------------------------------
-- Exports
--------------------------------------------------------------------------------

local p, mt = {}, {}

function p._exportClasses()
	-- For testing.
	return {
		MessageBox = MessageBox
	}
end

function p.main(boxType, args, cfgTables)
	local box = MessageBox.new(boxType, args, cfgTables or mw.loadData(CONFIG_MODULE))
	box:setParameters()
	box:setCategories()
	-- DIV MIGRATION CONDITIONAL
	if box.cfg.div_structure then
		return box:exportDiv()
	end
	-- END DIV MIGRATION CONDITIONAL
	return box:export()
end

function mt.__index(t, k)
	return function (frame)
		if not getArgs then
			getArgs = require('Module:Arguments').getArgs
		end
		return t.main(k, getArgs(frame, {trim = false, removeBlanks = false}))
	end
end

return setmetatable(p, mt)</text>
      <sha1>ocboyo877qnpqum2b9fyiquh72vukqa</sha1>
    </revision>
  </page>
  <page>
    <title>Module:No globals</title>
    <ns>828</ns>
    <id>109</id>
    <revision>
      <id>447</id>
      <timestamp>2023-05-30T15:02:12Z</timestamp>
      <contributor>
        <username>incubator&gt;Пан Хаунд</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;local mt = getmetatable(_G) or {} function mt.__index (t, k) 	if k ~= 'arg' then 		error('Tried to read nil global ' .. tostring(k), 2) 	end 	return nil end function mt.__newindex(t, k, v) 	if k ~= 'arg' then 		error('Tried to write global ' .. tostring(k), 2) 	end 	rawset(t, k, v) end setmetatable(_G, mt)&quot;</comment>
      <origin>447</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="307" sha1="gggsv54pq7f94l3up48hr91qtxnskdm" xml:space="preserve">local mt = getmetatable(_G) or {}
function mt.__index (t, k)
	if k ~= 'arg' then
		error('Tried to read nil global ' .. tostring(k), 2)
	end
	return nil
end
function mt.__newindex(t, k, v)
	if k ~= 'arg' then
		error('Tried to write global ' .. tostring(k), 2)
	end
	rawset(t, k, v)
end
setmetatable(_G, mt)</text>
      <sha1>gggsv54pq7f94l3up48hr91qtxnskdm</sha1>
    </revision>
    <revision>
      <id>448</id>
      <parentid>447</parentid>
      <timestamp>2024-10-14T13:46:29Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>447</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="307" sha1="gggsv54pq7f94l3up48hr91qtxnskdm" xml:space="preserve">local mt = getmetatable(_G) or {}
function mt.__index (t, k)
	if k ~= 'arg' then
		error('Tried to read nil global ' .. tostring(k), 2)
	end
	return nil
end
function mt.__newindex(t, k, v)
	if k ~= 'arg' then
		error('Tried to write global ' .. tostring(k), 2)
	end
	rawset(t, k, v)
end
setmetatable(_G, mt)</text>
      <sha1>gggsv54pq7f94l3up48hr91qtxnskdm</sha1>
    </revision>
  </page>
  <page>
    <title>16 JUNE 1976</title>
    <ns>0</ns>
    <id>110</id>
    <revision>
      <id>449</id>
      <timestamp>2024-03-09T10:46:43Z</timestamp>
      <contributor>
        <username>incubator&gt;KhethiweMsiza94</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;== 16 JUNE 1976 ==  === Ilanga labantu abatjha === '''Umguruguru'''  weSOWETO  owenziwa bantwana besikolo bombala onzima  e[[Isewula Afrika|Sewula Afrika]] ngeskhathi sebandlululo wathoma ekuseni amalanga nakalitjhumi nesithandathu kumgwengweni ngonyaka ka-1976.Izehlakalo ezathoma ukulwa kwabantwana zifaka umbuso webandlululo owabangela i[[BANTU EDUCATION ACT]] ka-1953.ngelanga ekwathonywa ngalo lomguruguru kwathi sele baphakathi nendawo ngokukhamba bathola amaphol...&quot;</comment>
      <origin>449</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1329" sha1="p7lsz8bp72l7ykqqy38lkgg14as40ho" xml:space="preserve">== 16 JUNE 1976 ==

=== Ilanga labantu abatjha ===
'''Umguruguru'''  weSOWETO  owenziwa bantwana besikolo bombala onzima  e[[Isewula Afrika|Sewula Afrika]] ngeskhathi sebandlululo wathoma ekuseni amalanga nakalitjhumi nesithandathu kumgwengweni ngonyaka ka-1976.Izehlakalo ezathoma ukulwa kwabantwana zifaka umbuso webandlululo owabangela i[[BANTU EDUCATION ACT]] ka-1953.ngelanga ekwathonywa ngalo lomguruguru kwathi sele baphakathi nendawo ngokukhamba bathola amapholisa webandlululo abajamele ngeengidi ezikulu  babarhitjha ngentuthu barhameka bebabadubula ngeenkule zeraba nabo bebadobha amatje bawajikijele lapha iinkule bezivela khona, lokhu kwabanga irawurawu ekulu lapha kwaqghina sele kulimala abafundi ekufaka khona u[[Hector peterson]] owadutjulwa mapholisa la.

[[Isimumathi:Anti-Apartheid_Protest_02_F.jpg|316x316px|Anti-Apartheid Protest 02 F]]
[[Isimumathi:MeadowlandsHighPlaque.png|thumb|SOWETO UPRISING]]

==== Kwenzekani kuhector perterson ====
U[[Hector Peterson]] wabe angomunye wabafundi egade balwela ikululeko yokungafundiswa ngelimi lesibhunu i-[[AFRIKAANS]] eenkolweni. bekaneminyaka elitjhumi nambili ngeskhathi ahlongakala ngaso eemgurugurwini lo. AboDorhodere abamhlolako nasele abhubhile bathi ubulewe likule elalikhombe yena mathupha ingasi ikule elamunemba ngephutha njengalokha amapholisa asitjho.</text>
      <sha1>p7lsz8bp72l7ykqqy38lkgg14as40ho</sha1>
    </revision>
    <revision>
      <id>450</id>
      <parentid>449</parentid>
      <timestamp>2024-05-10T07:04:51Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>450</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1697" sha1="tplubmesp7h8mva8l4xl5viqy5sm3im" xml:space="preserve">== 16 kuMgwengweni 1976 ==

=== Ilanga labantu abatjha ===


Umhlaka 16 kuMgwengweni 1976 lilanga lapho kwatjhuguluka khona izinto ezinengi eSewula Afrika. Ngelanga leli abantu abatjha abahlukeneko eenrarheni ezinengi babuthelelana bese balwisana negandelelo lombuso wangaphambilini. Lokho azange kwahlala kuhle embusweni wangaleso sikhathi. Ngalokho-ke, kwabanga ukutjhayisana.

'''Kodwana,''' eSoweto ukutjhayisana lokhu kwaba kukhulu hlangana nabentwana besikolo babantu abanzima bombala onzima. Ezinye zezinto ebe balila ngazo mthetho wezofundo obizwa, Bantu Education Act ka-1953. Iinlilo lezi zabangela umbuso wegandelelo ukuthi uphendule ngokuthumela amajoni namapholisa endaweni leyo. Amapholisa namajoni la bekahlome ngeengidi nezinye iinkhali. Ukungezelela, kwabakhona umguruguru hlangana kwamajoni la nabentwana besikolo la. Abafundi abanengi laba bazithola balinyazwa. Omunye wabongazimbi kwaba ngu-[[Hector peterson]] loyo owadutjulwa mapholisa la.

[[Isimumathi:Anti-Apartheid_Protest_02_F.jpg|316x316px|Anti-Apartheid Protest 02 F]]
[[Isimumathi:MeadowlandsHighPlaque.png|thumb|SOWETO UPRISING]]

U[[Hector Peterson|-Hector Peterson]] lo wabe ngomunye wabafundi egade balwela ikululeko yokungafundiswa ngelimi lesibhunu i-[[AFRIKAANS|Afrikaans]] eenkolweni. Ngaleso sikhathi bekaneminyaka elitjhumi nambili nakadutjulwako. Wayiswa esibhedlela kodwana wathi nabatjhejako abodorhodere ebebasebenza ngaleso sikhathi bamfumana sele umoya wakhe uhlukene nenyama. 

Kusukela ngelanga leli, woke umuntu wathoma ukulwisana nebandlululo lombuso wangaphambilini lo. Ilanga leli nesehlakalo esenzeka ngeSewoto lesi sasetjenziswa njengekhuthazo. Ilanga leli lathiywa bonyana lilanga lelutjha.

</text>
      <sha1>tplubmesp7h8mva8l4xl5viqy5sm3im</sha1>
    </revision>
    <revision>
      <id>451</id>
      <parentid>450</parentid>
      <timestamp>2024-07-25T13:36:51Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>/* Ilanga labantu abatjha */</comment>
      <origin>451</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1695" sha1="5iac3aj937ixu4cgut86sjj2agfwkaa" xml:space="preserve">== 16 kuMgwengweni 1976 ==

=== Ilanga labantu abatjha ===



Umhlaka 16 kuMgwengweni 1976 lilanga lapho kwatjhuguluka khona izinto ezinengi eSewula Afrika. Ngelanga leli abantu abatjha abahlukeneko eenarheni ezinengi babuthelelana bese balwisana negandelelo lombuso wangaphambilini. Lokho azange kwahlala kuhle embusweni egade ubusa ngaleso sikhathi. Lokho-ke, kwabanga ukutjhayisana.

'''Kodwana,''' eSoweto ukutjhayisana lokhu kwaba kukhulu hlangana nabentwana besikolo sabantu bombala onzima. Ezinye zezinto ebe balila ngazo mthetho wezofundo obizwa, Bantu Education Act ka-1953. Iinlilo lezi zabangela umbuso wegandelelo ukuthi uphendule ngokuthumela amajoni namapholisa endaweni leyo. Amapholisa namajoni la bekahlome ngeengidi nezinye iinkhali. Ukungezelela, kwabakhona umguruguru hlangana kwamajoni la nabentwana besikolo la. Abafundi abanengi laba bazithola balinyazwa. Omunye wabongazimbi kwaba ngu-[[Hector peterson]] loyo owadutjulwa mapholisa la.

[[Isimumathi:Anti-Apartheid_Protest_02_F.jpg|316x316px|Anti-Apartheid Protest 02 F]]
[[Isimumathi:MeadowlandsHighPlaque.png|thumb|SOWETO UPRISING]]

U[[Hector Peterson|-Hector Peterson]] lo wabe ngomunye wabafundi egade balwela ikululeko yokungafundiswa ngelimi lesibhunu i-[[AFRIKAANS|Afrikaans]] eenkolweni. Ngaleso sikhathi bekaneminyaka elitjhumi nambili nakadutjulwako. Wayiswa esibhedlela kodwana wathi nabatjhejako abodorhodere ebebasebenza ngaleso sikhathi bamfumana sele umoya wakhe uhlukene nenyama. 

Kusukela ngelanga leli, woke umuntu wathoma ukulwisana nebandlululo lombuso wangaphambilini lo. Ilanga leli nesehlakalo esenzeka ngeSewoto lesi sasetjenziswa njengekhuthazo. Ilanga leli lathiywa bonyana lilanga lelutjha.

</text>
      <sha1>5iac3aj937ixu4cgut86sjj2agfwkaa</sha1>
    </revision>
    <revision>
      <id>452</id>
      <parentid>451</parentid>
      <timestamp>2024-07-25T13:37:30Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>/* Ilanga labantu abatjha */</comment>
      <origin>452</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1702" sha1="anzomhvg61co7k0gs3mqui9rtj4d6gf" xml:space="preserve">== 16 kuMgwengweni 1976 ==

=== Ilanga labantu abatjha ===



Umhlaka 16 kuMgwengweni 1976 lilanga lapho kwatjhuguluka khona izinto ezinengi eSewula Afrika. Ngelanga leli abantu abatjha abahlukeneko eenarheni ezinengi babuthelelana bese balwisana negandelelo lombuso wangaphambilini. Lokho azange kwahlala kuhle embusweni egade ubusa ngaleso sikhathi. Lokho-ke, kwabanga ukutjhayisana.

'''Kodwana,''' eSoweto ukutjhayisana lokhu kwaba kukhulu hlangana nabentwana besikolo sabantu bombala onzima. Ezinye zezinto ebe balila ngazo mthetho wezefundo obizwa bona yi Bantu Education Act ka-1953. Iinlilo lezi zabangela umbuso wegandelelo ukuthi uphendule ngokuthumela amajoni namapholisa endaweni leyo. Amapholisa namajoni la bekahlome ngeengidi nezinye iinkhali. Ukungezelela, kwabakhona umguruguru hlangana kwamajoni la nabentwana besikolo la. Abafundi abanengi laba bazithola balinyazwa. Omunye wabongazimbi kwaba ngu-[[Hector peterson]] loyo owadutjulwa mapholisa la.

[[Isimumathi:Anti-Apartheid_Protest_02_F.jpg|316x316px|Anti-Apartheid Protest 02 F]]
[[Isimumathi:MeadowlandsHighPlaque.png|thumb|SOWETO UPRISING]]

U[[Hector Peterson|-Hector Peterson]] lo wabe ngomunye wabafundi egade balwela ikululeko yokungafundiswa ngelimi lesibhunu i-[[AFRIKAANS|Afrikaans]] eenkolweni. Ngaleso sikhathi bekaneminyaka elitjhumi nambili nakadutjulwako. Wayiswa esibhedlela kodwana wathi nabatjhejako abodorhodere ebebasebenza ngaleso sikhathi bamfumana sele umoya wakhe uhlukene nenyama. 

Kusukela ngelanga leli, woke umuntu wathoma ukulwisana nebandlululo lombuso wangaphambilini lo. Ilanga leli nesehlakalo esenzeka ngeSewoto lesi sasetjenziswa njengekhuthazo. Ilanga leli lathiywa bonyana lilanga lelutjha.

</text>
      <sha1>anzomhvg61co7k0gs3mqui9rtj4d6gf</sha1>
    </revision>
    <revision>
      <id>453</id>
      <parentid>452</parentid>
      <timestamp>2024-08-30T11:59:05Z</timestamp>
      <contributor>
        <username>incubator&gt;Nomsa Skosana</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>453</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1695" sha1="qeocdju8era53ajlyom8gy5c3v9mk0k" xml:space="preserve">== 16 kuMgwengweni 1976 ==

=== Ilanga labantu abatjha ===
Ilanga lange 16 kuMgwengweni 1976 lilanga lapho kwatjhuguluka khona izinto ezinengi eSewula Afrika. Ngelangeli abantu abatjha abahlukeneko eenarheni ezinengi babuthelelana bese balwisana negandelelo lombuso wangaphambilini. Lokho azange kwahlala kuhle embusweni egade ubusa ngaleso sikhathi. Lokho-ke, kwabanga ukutjhayisana.
[[Isimumathi:Anti-Apartheid_Protest_02_F.jpg|alt=Anti-Apartheid Protest 02 F|right|316x316px]]
ESoweto ukutjhayisanokhu kwaba kukhulu hlangana nabentwana besikolo sabantu bombala onzima. Ezinye zezinto ebebalila ngazo mthetho wezefundo obizwa bona ngeBantu ''Education Act'' ka-1953. Iinlilo lezi zabangela umbuso wegandelelo ukuthi uphendule ngokuthumela amajoni namapholisa endaweni leyo. Amapholisa namajoni la bekahlome ngeengidi nezinye iinkhali. Ngemva kwalokhu kwaba khona umguruguru hlangana namajoni la nabentwana besikolo la. Abafundi abanengi laba bazithola balinyazwa. Omunye wabongazimbi kwaba ngu-[[Hector peterson|Hector Peterson]] loyo owadutjulwa mapholisa.[[Isimumathi:MeadowlandsHighPlaque.png|thumb|SOWETO UPRISING]]

U[[Hector Peterson|-Hector Peterson]] wabengomunye wabafundi egade balwela ikululeko yokungafundiswa ngelimi lesibhunu i-[[AFRIKAANS|Afrikaans]] eenkolweni. Ngaleso sikhathi bekaneminyaka elitjhumi nambili nakadutjulwako. Wayiswa esibhedlela kodwana wathi nabatjhejako abodorhodere ebebasebenza ngaleso sikhathi bamfumana sele umoyakhe uhlukene nenyama. 

Kusukela ngelanga leli, woke umuntu wathoma ukulwisana nebandlululo lombuso wangaphambilini lo. Ilangeli nesehlakalo esenzeka ngeSewoto lesi sasetjenziswa njengekhuthazo. Ilangeli lathiywa bonyana lilanga lelutjha.

</text>
      <sha1>qeocdju8era53ajlyom8gy5c3v9mk0k</sha1>
    </revision>
    <revision>
      <id>454</id>
      <parentid>453</parentid>
      <timestamp>2024-10-14T13:46:30Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>5 revisions imported</comment>
      <origin>453</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1695" sha1="qeocdju8era53ajlyom8gy5c3v9mk0k" xml:space="preserve">== 16 kuMgwengweni 1976 ==

=== Ilanga labantu abatjha ===
Ilanga lange 16 kuMgwengweni 1976 lilanga lapho kwatjhuguluka khona izinto ezinengi eSewula Afrika. Ngelangeli abantu abatjha abahlukeneko eenarheni ezinengi babuthelelana bese balwisana negandelelo lombuso wangaphambilini. Lokho azange kwahlala kuhle embusweni egade ubusa ngaleso sikhathi. Lokho-ke, kwabanga ukutjhayisana.
[[Isimumathi:Anti-Apartheid_Protest_02_F.jpg|alt=Anti-Apartheid Protest 02 F|right|316x316px]]
ESoweto ukutjhayisanokhu kwaba kukhulu hlangana nabentwana besikolo sabantu bombala onzima. Ezinye zezinto ebebalila ngazo mthetho wezefundo obizwa bona ngeBantu ''Education Act'' ka-1953. Iinlilo lezi zabangela umbuso wegandelelo ukuthi uphendule ngokuthumela amajoni namapholisa endaweni leyo. Amapholisa namajoni la bekahlome ngeengidi nezinye iinkhali. Ngemva kwalokhu kwaba khona umguruguru hlangana namajoni la nabentwana besikolo la. Abafundi abanengi laba bazithola balinyazwa. Omunye wabongazimbi kwaba ngu-[[Hector peterson|Hector Peterson]] loyo owadutjulwa mapholisa.[[Isimumathi:MeadowlandsHighPlaque.png|thumb|SOWETO UPRISING]]

U[[Hector Peterson|-Hector Peterson]] wabengomunye wabafundi egade balwela ikululeko yokungafundiswa ngelimi lesibhunu i-[[AFRIKAANS|Afrikaans]] eenkolweni. Ngaleso sikhathi bekaneminyaka elitjhumi nambili nakadutjulwako. Wayiswa esibhedlela kodwana wathi nabatjhejako abodorhodere ebebasebenza ngaleso sikhathi bamfumana sele umoyakhe uhlukene nenyama. 

Kusukela ngelanga leli, woke umuntu wathoma ukulwisana nebandlululo lombuso wangaphambilini lo. Ilangeli nesehlakalo esenzeka ngeSewoto lesi sasetjenziswa njengekhuthazo. Ilangeli lathiywa bonyana lilanga lelutjha.

</text>
      <sha1>qeocdju8era53ajlyom8gy5c3v9mk0k</sha1>
    </revision>
    <revision>
      <id>6496</id>
      <parentid>454</parentid>
      <timestamp>2026-05-15T19:01:32Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <origin>6496</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1629" sha1="slecqgvacqg0yi5lh0mpg594jt78prw" xml:space="preserve">'''Ilanga''' lange 16 kuMgwengweni 1976 lilanga lapho kwatjhuguluka khona izinto ezinengi eSewula Afrika. Ngelangeli abantu abatjha abahlukeneko eendaweni ezinengi babuthelelana bese balwisana negandelelo lombuso wangaphambilini. Lokho azange kwahlala kuhle embusweni egade ubusa ngaleso sikhathi. Lokho-ke, kwabanga ukutjhayisana.
[[Isimumathi:Anti-Apartheid_Protest_02_F.jpg|alt=Anti-Apartheid Protest 02 F|right|316x316px]]
ESoweto ukutjhayisanokhu kwaba kukhulu hlangana nabentwana besikolo sabantu bombala onzima. Ezinye zezinto ebebalila ngazo mthetho wezefundo obizwa ngeBantu ''Education Act'' yomnyaka we-1953. Iinlilo lezi zabangela umbuso wegandelelo ukuthi uphendule ngokuthumela amajoni namapholisa endaweni leyo. Amapholisa namajoni la bekahlome ngeengidi nezinye iinkhali. Ngemva kwalokhu kwaba khona umguruguru hlangana namajoni la nabentwana besikolo. Abafundi abanengaba bazithola balinyazwa. Omunye wabongazimbi kwaba ngu-[[Hector peterson|Hector Peterson]] loyo owadutjulwa mapholisa.[[Isimumathi:MeadowlandsHighPlaque.png|thumb|SOWETO UPRISING]]

U[[Hector Peterson|-Hector Peterson]] bekangomunye wabafundi egade balwela ikululeko yokungafundiswa ngelimi lesibhunu i-[[AFRIKAANS|Afrikaans]] eenkolweni. Ngaleso sikhathi bekaneminyaka elitjhumi nambili nakadutjulwako. Wasiwa esibhedlela kodwana bathi nabatjhejako abodorhodere ebebasebenza ngaleso sikhathi bamfumana sele umoyakhe uhlukene nenyama. 

Kusukela ngelanga leli, woke umuntu wathoma ukulwisana nebandlululo lombuso wangaphambilini lo. Ilangeli nesehlakalo esenzeka eSewoto sasetjenziswa njengekuthazo. Ilangeli lathiywa bonyana lilanga lelutjha.</text>
      <sha1>slecqgvacqg0yi5lh0mpg594jt78prw</sha1>
    </revision>
    <revision>
      <id>6497</id>
      <parentid>6496</parentid>
      <timestamp>2026-05-15T19:02:16Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <comment>added [[Category:16 June 1976]] using [[Help:Gadget-HotCat|HotCat]]</comment>
      <origin>6497</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1655" sha1="9ifc02dsj0ruqib4rzuxd08rrlafmd9" xml:space="preserve">'''Ilanga''' lange 16 kuMgwengweni 1976 lilanga lapho kwatjhuguluka khona izinto ezinengi eSewula Afrika. Ngelangeli abantu abatjha abahlukeneko eendaweni ezinengi babuthelelana bese balwisana negandelelo lombuso wangaphambilini. Lokho azange kwahlala kuhle embusweni egade ubusa ngaleso sikhathi. Lokho-ke, kwabanga ukutjhayisana.
[[Isimumathi:Anti-Apartheid_Protest_02_F.jpg|alt=Anti-Apartheid Protest 02 F|right|316x316px]]
ESoweto ukutjhayisanokhu kwaba kukhulu hlangana nabentwana besikolo sabantu bombala onzima. Ezinye zezinto ebebalila ngazo mthetho wezefundo obizwa ngeBantu ''Education Act'' yomnyaka we-1953. Iinlilo lezi zabangela umbuso wegandelelo ukuthi uphendule ngokuthumela amajoni namapholisa endaweni leyo. Amapholisa namajoni la bekahlome ngeengidi nezinye iinkhali. Ngemva kwalokhu kwaba khona umguruguru hlangana namajoni la nabentwana besikolo. Abafundi abanengaba bazithola balinyazwa. Omunye wabongazimbi kwaba ngu-[[Hector peterson|Hector Peterson]] loyo owadutjulwa mapholisa.[[Isimumathi:MeadowlandsHighPlaque.png|thumb|SOWETO UPRISING]]

U[[Hector Peterson|-Hector Peterson]] bekangomunye wabafundi egade balwela ikululeko yokungafundiswa ngelimi lesibhunu i-[[AFRIKAANS|Afrikaans]] eenkolweni. Ngaleso sikhathi bekaneminyaka elitjhumi nambili nakadutjulwako. Wasiwa esibhedlela kodwana bathi nabatjhejako abodorhodere ebebasebenza ngaleso sikhathi bamfumana sele umoyakhe uhlukene nenyama. 

Kusukela ngelanga leli, woke umuntu wathoma ukulwisana nebandlululo lombuso wangaphambilini lo. Ilangeli nesehlakalo esenzeka eSewoto sasetjenziswa njengekuthazo. Ilangeli lathiywa bonyana lilanga lelutjha.

[[Mkhakha:16 June 1976]]</text>
      <sha1>9ifc02dsj0ruqib4rzuxd08rrlafmd9</sha1>
    </revision>
  </page>
  <page>
    <title>Ababelethi</title>
    <ns>0</ns>
    <id>111</id>
    <revision>
      <id>455</id>
      <timestamp>2024-07-11T10:28:43Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Ababelethi'''  bantu abalatha umuntu othileko ephasini. Nasikhukhuluma ngababelethi sikhuluma ngomma nanyana uyise womuntu. Labo kubabantu abahlangiswe ngokuthi babe nomntwana.&quot;</comment>
      <origin>455</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="179" sha1="kvorzlff1pq6timx3pk06l6czhoycxy" xml:space="preserve">'''Ababelethi'''  bantu abalatha umuntu othileko ephasini. Nasikhukhuluma ngababelethi sikhuluma ngomma nanyana uyise womuntu. Labo kubabantu abahlangiswe ngokuthi babe nomntwana.</text>
      <sha1>kvorzlff1pq6timx3pk06l6czhoycxy</sha1>
    </revision>
    <revision>
      <id>456</id>
      <parentid>455</parentid>
      <timestamp>2024-07-11T10:31:50Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>456</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="359" sha1="ie0eb9gljl1ql3ux0smbf6lxymnultd" xml:space="preserve">'''Ababelethi'''  bantu abalatha umuntu othileko ephasini. Nasikhukhuluma ngababelethi sikhuluma ngomma nanyana uyise womuntu. Labo kubabantu abahlangiswe ngokuthi babe nomntwana begodu kube ngibo abanikela umntwana itjhejo eliphambili begodu bakghone nokumnikela ithando. Ababelethi kungilabo bantu umntwana abafuzileko begodu afana nabo ngesotja nangezenzo.</text>
      <sha1>ie0eb9gljl1ql3ux0smbf6lxymnultd</sha1>
    </revision>
    <revision>
      <id>457</id>
      <parentid>456</parentid>
      <timestamp>2024-07-25T13:45:26Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>457</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="577" sha1="fyanq68bfrvwtsb7um5uh212s60casm" xml:space="preserve">'''Ababelethi'''  babantu abaletha umuntu othileko ephasini. Nasikhuluma ngababelethi sikhuluma ngomma no yise womuntu. Labo kubabantu abahlangiswe ngokuthi babe nomntwana begodu kube ngibo abanikela umntwana itjhejo eliphambili begodu bakghone nokumnikela ithando. Ababelethi kungilabo bantu umntwana abafuzileko begodu afana nabo ngesotja nangezenzo. Ukungezelela, babantu abanikela umntwana izinyo lakhe okuligama abantu abayombiza ngalo ipilo yakhe yoke. Igama elithi &quot;mbelethi&quot; aliqalisisi kumma no yise ebakulethe emhlabenapha. Libuye liqalekise emntwini okutlhogomelako.</text>
      <sha1>fyanq68bfrvwtsb7um5uh212s60casm</sha1>
    </revision>
    <revision>
      <id>458</id>
      <parentid>457</parentid>
      <timestamp>2024-10-14T13:46:30Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>457</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="577" sha1="fyanq68bfrvwtsb7um5uh212s60casm" xml:space="preserve">'''Ababelethi'''  babantu abaletha umuntu othileko ephasini. Nasikhuluma ngababelethi sikhuluma ngomma no yise womuntu. Labo kubabantu abahlangiswe ngokuthi babe nomntwana begodu kube ngibo abanikela umntwana itjhejo eliphambili begodu bakghone nokumnikela ithando. Ababelethi kungilabo bantu umntwana abafuzileko begodu afana nabo ngesotja nangezenzo. Ukungezelela, babantu abanikela umntwana izinyo lakhe okuligama abantu abayombiza ngalo ipilo yakhe yoke. Igama elithi &quot;mbelethi&quot; aliqalisisi kumma no yise ebakulethe emhlabenapha. Libuye liqalekise emntwini okutlhogomelako.</text>
      <sha1>fyanq68bfrvwtsb7um5uh212s60casm</sha1>
    </revision>
    <revision>
      <id>2280</id>
      <parentid>458</parentid>
      <timestamp>2024-12-14T15:33:02Z</timestamp>
      <contributor>
        <ip>88.241.64.40</ip>
      </contributor>
      <origin>2280</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="624" sha1="tf6kfkfempkv5u4j3g5bu8ypxfqux34" xml:space="preserve">'''Ababelethi'''  babantu abaletha umuntu othileko ephasini. Nasikhuluma ngababelethi sikhuluma ngomma no yise womuntu. Labo kubabantu abahlangiswe ngokuthi babe nomntwana begodu kube ngibo abanikela umntwana itjhejo eliphambili begodu bakghone nokumnikela ithando. Ababelethi kungilabo bantu umntwana abafuzileko begodu afana nabo ngesotja nangezenzo. Ukungezelela, babantu abanikela umntwana izinyo lakhe okuligama abantu abayombiza ngalo ipilo yakhe yoke. Igama elithi &quot;mbelethi&quot; aliqalisisi kumma no yise ebakulethe emhlabenapha. Libuye liqalekise emntwini okutlhogomelako. [https://www.busarkisozu.com/ busarkisozu.com]</text>
      <sha1>tf6kfkfempkv5u4j3g5bu8ypxfqux34</sha1>
    </revision>
    <revision>
      <id>2365</id>
      <parentid>2280</parentid>
      <timestamp>2025-01-26T02:14:01Z</timestamp>
      <contributor>
        <ip>88.238.41.121</ip>
      </contributor>
      <origin>2365</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="634" sha1="gchmpwbkwyd1xmssma366zdu4xr5mlh" xml:space="preserve">'''Ababelethi'''  babantu abaletha umuntu othileko ephasini. Nasikhuluma ngababelethi sikhuluma ngomma no yise womuntu. Labo kubabantu abahlangiswe ngokuthi babe nomntwana begodu kube ngibo abanikela umntwana itjhejo eliphambili begodu bakghone nokumnikela ithando. Ababelethi kungilabo bantu umntwana abafuzileko begodu afana nabo ngesotja nangezenzo. Ukungezelela, babantu abanikela umntwana izinyo lakhe okuligama abantu abayombiza ngalo ipilo yakhe yoke. Igama elithi &quot;mbelethi&quot; aliqalisisi kumma no yise ebakulethe emhlabenapha. Libuye liqalekise emntwini okutlhogomelako. [https://www.1sarkisozu.com.tr/ şarkı sözleri sitesi]</text>
      <sha1>gchmpwbkwyd1xmssma366zdu4xr5mlh</sha1>
    </revision>
    <revision>
      <id>2918</id>
      <parentid>2365</parentid>
      <timestamp>2025-06-06T17:01:32Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>tghg</comment>
      <origin>2918</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="715" sha1="87eejqkz75fqgsoyg3ggnbxcvm27qkc" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. Ababelethi'''  babantu abaletha umuntu othileko ephasini. Nasikhuluma ngababelethi sikhuluma ngomma no yise womuntu. Labo kubabantu abahlangiswe ngokuthi babe nomntwana begodu kube ngibo abanikela umntwana itjhejo eliphambili begodu bakghone nokumnikela ithando. Ababelethi kungilabo bantu umntwana abafuzileko begodu afana nabo ngesotja nangezenzo. Ukungezelela, babantu abanikela umntwana izinyo lakhe okuligama abantu abayombiza ngalo ipilo yakhe yoke. Igama elithi &quot;mbelethi&quot; aliqalisisi kumma no yise ebakulethe emhlabenapha. Libuye liqalekise emntwini okutlhogomelako. [https://www.1sarkisozu.com.tr/ şarkı sözleri sitesi]</text>
      <sha1>87eejqkz75fqgsoyg3ggnbxcvm27qkc</sha1>
    </revision>
    <revision>
      <id>3148</id>
      <parentid>2918</parentid>
      <timestamp>2025-06-07T03:05:24Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:88.238.41.121|88.238.41.121]]</comment>
      <origin>2365</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="634" sha1="gchmpwbkwyd1xmssma366zdu4xr5mlh" xml:space="preserve">'''Ababelethi'''  babantu abaletha umuntu othileko ephasini. Nasikhuluma ngababelethi sikhuluma ngomma no yise womuntu. Labo kubabantu abahlangiswe ngokuthi babe nomntwana begodu kube ngibo abanikela umntwana itjhejo eliphambili begodu bakghone nokumnikela ithando. Ababelethi kungilabo bantu umntwana abafuzileko begodu afana nabo ngesotja nangezenzo. Ukungezelela, babantu abanikela umntwana izinyo lakhe okuligama abantu abayombiza ngalo ipilo yakhe yoke. Igama elithi &quot;mbelethi&quot; aliqalisisi kumma no yise ebakulethe emhlabenapha. Libuye liqalekise emntwini okutlhogomelako. [https://www.1sarkisozu.com.tr/ şarkı sözleri sitesi]</text>
      <sha1>gchmpwbkwyd1xmssma366zdu4xr5mlh</sha1>
    </revision>
    <revision>
      <id>6500</id>
      <parentid>3148</parentid>
      <timestamp>2026-05-15T19:29:17Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <origin>6500</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="587" sha1="ez7g7e82imorcsmw0l6mx09oqb14yoc" xml:space="preserve">'''Ababelethi'''  babantu abaletha umuntu othileko ephasini. Nasikhuluma ngababelethi sikhuluma ngomma noyise lomuntu. Labo kubabantu abahlangiswe ngokuthi babe nomntwana begodu kube ngibo abanikela umntwana itjhejo eliphambili begodu bakghone nokumnikela ithando. Ababelethi kungilabo bantu umntwana abafuzileko begodu afana nabo ngamasotja womzimba nangezenzo. Ukungezelela, kubabantu abanikela umntwana izinyo lakhe okuligama abantu abayombiza ngalo ipilo yakhe yoke. Igama elithi, mbelethi aliqalisisi kumma noyise ebakulethe emhlabenapha. Libuye liqalekise emntwini okutlhogomelako.</text>
      <sha1>ez7g7e82imorcsmw0l6mx09oqb14yoc</sha1>
    </revision>
    <revision>
      <id>6802</id>
      <parentid>6500</parentid>
      <timestamp>2026-08-21T03:27:07Z</timestamp>
      <contributor>
        <username>Andries Solly Skhosana</username>
        <id>1624</id>
      </contributor>
      <origin>6802</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="696" sha1="9wg84jei1bv1p92nfkh3mctaduazepl" xml:space="preserve">'''Ababelethi'''  babantu abaletha umuntu othileko ephasini. Nasikhuluma ngababelethi sisuke sikhuluma ngomma noyise lomuntu. Labo kubabantu abahlanganiswe bona babe nomntwana, kube ngibo abanikela umntwana loyo itjhejo eliphuma phambili begodu bakghone nokumnikela ithando. Ababelethi kungilabo bantu umntwana abafuzileko begodu afana nabo ngamasotja womzimba nangezenzo. Ukungezelela, kubabantu abanikela umntwana izinyo lakhe okuligama abantu abayombiza ngalo ipilo yakhe yoke. Igama elithi, mbelethi alikaqaliswa kumma noyise lomntwana ebamlethe emhlabenapha kwaphela. Libuya liqaleswe emntwini omnakelelako imbala.&lt;ref&gt;&lt;nowiki&gt;https://www.merriam-webster.com/dictionary/parent&lt;/nowiki&gt;&lt;/ref&gt;</text>
      <sha1>9wg84jei1bv1p92nfkh3mctaduazepl</sha1>
    </revision>
    <revision>
      <id>6803</id>
      <parentid>6802</parentid>
      <timestamp>2026-08-21T03:29:08Z</timestamp>
      <contributor>
        <username>Andries Solly Skhosana</username>
        <id>1624</id>
      </contributor>
      <origin>6803</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="695" sha1="40gflnaj7i663ofh13kgy71deus44ua" xml:space="preserve">'''Ababelethi'''  babantu abaletha umuntu othileko ephasini. Nasikhuluma ngababelethi sisuke sikhuluma ngomma noyise lomuntu. Labo kubabantu abahlanganiswe bona babe nomntwana, kube ngibo abanikela umntwana loyo itjhejo eliphuma phambili begodu bakghone nokumnikela ithando. Ababelethi kungilabo bantu umntwana abafuzileko begodu afana nabo ngamasotja womzimba nangezenzo. Ukungezelela, kubabantu abanikela umntwana izinyo lakhe okuligama abantu abayombiza ngalo ipilo yakhe yoke. Igama elithi, mbelethi alikaqaliswa kumma noyise lomntwana ebamlethe ephasinapha kwaphela. Libuya liqaleswe emntwini omnakelelako imbala.&lt;ref&gt;&lt;nowiki&gt;https://www.merriam-webster.com/dictionary/parent&lt;/nowiki&gt;&lt;/ref&gt;</text>
      <sha1>40gflnaj7i663ofh13kgy71deus44ua</sha1>
    </revision>
  </page>
  <page>
    <title>Abongwaqa</title>
    <ns>0</ns>
    <id>112</id>
    <revision>
      <id>459</id>
      <timestamp>2024-05-10T10:17:53Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;== '''Abongwaqa''' == Abongwaqa ngamanye amatjhada asetjenziswa khulu esiNdebeleni. Amatjhada la, abongwaqa, asetjenziswa nabokamisa ukuze kube matjhada la azwakalako. Abongwaqa bamihlobo ehlukeneko. Imihlobo le ibizwa bona; Abodumuza/Abodubula, ububula, abomavuthelwa, abomavuthelwagandelela, uliliza, urephula, abosingakamisa, abomakghadlana, abongwabathwa, abongwaqabathwa ababozinyo, abongwaqabathwa abosininirhwalabha  nabongwaqabatha abahlangothi. Esigatjeni esilandela...&quot;</comment>
      <origin>459</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3028" sha1="k0637k8ttuiqkjab7psomo5e59r1ih7" xml:space="preserve">== '''Abongwaqa''' ==
Abongwaqa ngamanye amatjhada asetjenziswa khulu esiNdebeleni. Amatjhada la, abongwaqa, asetjenziswa nabokamisa ukuze kube matjhada la azwakalako. Abongwaqa bamihlobo ehlukeneko. Imihlobo le ibizwa bona; Abodumuza/Abodubula, ububula, abomavuthelwa, abomavuthelwagandelela, uliliza, urephula, abosingakamisa, abomakghadlana, abongwabathwa, abongwaqabathwa ababozinyo, abongwaqabathwa abosininirhwalabha  nabongwaqabatha abahlangothi. Esigatjeni esilandelako sizokukhuluma ngemihlobo yabongwaqa. 

== '''Abodumuza/Abodubula''' ==
Abodumuza nanyana abodubula matjhada lawo othi nawuwaphimisako, umoya uphume ngebelo nawuya ngaphandle bese kube khona ukudumuza komoya. 

''Isibonelo:'' 

# p[p’]: udumuza oputjukako ongundebembili (ipisi [ip’isi])
# d[d]: udumuza onelizwi ongusinini.Utholakala kuhlanganiselamakghadlana (indaba [indaƃa])

== '''Ububula''' ==
Litjhada elingundebembili lelo eliphimiswa ngokububula.

''Isibonelo:''

# b[ƃ]: ububula ongundebembili.basa [ƃasa]

== '''Abomavuthelwa''' ==
Abomavuthelwa matjhada lawo othi nawuwaphimisako kuzwakale ukuvuthelwa.

''Isibonelo:'' 

# f[f]: umavuthelwa onganalizwi ongundebezinyo (fafatha [fafatha]).

== '''Abomavuthelwagandelela''' ==
Abomavuthelwagandelela matjhada lawo othi nawuwaphimisako ilimi lakho lirhwathe ilwangeni bese kuvimbeke umoya. Umoya lo bese uphume sele ugandelelekile.

''Isibonelo:'' 

# ts[ts’]: umavuthelwagandelela oputjukako ongusinini (itsetse [its’ɛts’ɛ).
# dz[dz]: umavuthelwagandelela onelizwi ongusinini (idzila [idzila).

== '''Uliliza''' ==
Uliliza litjhada lelo elinelwi begodu nawuliphimisako ilimi likghwatha iinsini bese umoya uphome ngemahlangothini. 

''Isibonelo:'' 

# l[l]: uliliza onelizwi ongusininihlangothi (lila [lila]).

== '''Urephula''' ==
Urephula litjhada olingusinini eliphinyiswa ngokuthi kuzwakale ukurhephula.

''Isibonelo:''

# r[r]: urephula ongusinini onelizwi (rara [rara]).

== '''Abosingakamisa''' ==
Abosingakamisa matjhada obolwangeni nanyana aborhwalabha.

''Isibonelo:'' 

# y[j]: usingakamisa ongurhwalabha (ongulwangeni) [yeyezela [jɛjɛzɛla]

== '''Abomakghadlana''' ==
Abomakghadlana matjhada lawo aphinyiswa ngeendebe zomlomo nanyana ngokuthi ilimi likghwathe ilwangeni.

''Isibonelo:'' 

# m[m]: umakghadlana ongundebembili (mina [mina]).
# n[n]: umakghadlana ongusinini (inani [inani]).

== '''Abongwaqabathwa Ababozinyo''' ==
Abongwaqabathwa matjhada lawo asuselwa kubaThwa. Ubongwaqabathwa laba bafaka abongwaqabathwa ababozinyo, aababosininirhwalabha nabohlangothi. 

''Isibonelo:'' 

# Abongwaqabathwa Ababozinyo

c[/]: ungwaqabathwa onganalizwi onguzinyo (coca [/ɔ/a]).

2. Abongwaqabathwa Ababosininirhwalabha (-lwangeni)

q[!]: ungwaqabathwa onganalizwi ongusininirhwalabha (qina)

3. Abongwaqabathwa Abahlangothi

nx[ŋ//]: ungwaqabathwa okghadlazisweko ohlangothi (nxifa [ŋ//ifa]).


Abongwaqa matjhada lawo abaqakathekileko bonyana bafundwe begodu bazwisise ngombala bakulayela ngamatjhada asetjenziswa esiNdebeleni kanye nangendlela atlolwa ngayo.</text>
      <sha1>k0637k8ttuiqkjab7psomo5e59r1ih7</sha1>
    </revision>
    <revision>
      <id>460</id>
      <parentid>459</parentid>
      <timestamp>2024-05-10T10:19:24Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>460</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3028" sha1="ajbijv3kr2s00i16clkz9m44txoei2v" xml:space="preserve">== '''Abongwaqa''' ==
Abongwaqa ngamanye amatjhada asetjenziswa khulu esiNdebeleni. Amatjhada la, abongwaqa, asetjenziswa nabokamisa ukuze kube matjhada la azwakalako. Abongwaqa bamihlobo ehlukeneko. Imihlobo le ibizwa bona; Abodumuza/Abodubula, ububula, abomavuthelwa, abomavuthelwagandelela, uliliza, urephula, abosingakamisa, abomakghadlana, abongwabathwa, abongwaqabathwa ababozinyo, abongwaqabathwa abosininirhwalabha  nabongwaqabatha abahlangothi. Esigatjeni esilandelako sizokukhuluma ngemihlobo yabongwaqa. 

== '''Abodumuza/Abodubula''' ==
Abodumuza nanyana abodubula matjhada lawo othi nawuwaphimisako, umoya uphume ngebelo nawuya ngaphandle bese kube khona ukudumuza komoya. 

''Isibonelo:'' 

# p[p’]: udumuza oputjukako ongundebembili (ipisi [ip’isi])
# d[d]: udumuza onelizwi ongusinini.Utholakala kuhlanganiselamakghadlana (indaba [indaƃa])

== '''Ububula''' ==
Litjhada elingundebembili lelo eliphimiswa ngokububula.

''Isibonelo:''

# b[ƃ]: ububula ongundebembili.basa [ƃasa]

== '''Abomavuthelwa''' ==
Abomavuthelwa matjhada lawo othi nawuwaphimisako kuzwakale ukuvuthelwa.

''Isibonelo:'' 

# f[f]: umavuthelwa onganalizwi ongundebezinyo (fafatha [fafatha]).

== '''Abomavuthelwagandelela''' ==
Abomavuthelwagandelela matjhada lawo othi nawuwaphimisako ilimi lakho lirhwathe ilwangeni bese kuvimbeke umoya. Umoya lo bese uphume sele ugandelelekile.

''Isibonelo:'' 

# ts[ts’]: umavuthelwagandelela oputjukako ongusinini (itsetse [its’ɛts’ɛ).
# dz[dz]: umavuthelwagandelela onelizwi ongusinini (idzila [idzila).

== '''Uliliza''' ==
Uliliza litjhada lelo elinelwi begodu nawuliphimisako ilimi likghwatha iinsini bese umoya uphome ngemahlangothini. 

''Isibonelo:'' 

# l[l]: uliliza onelizwi ongusininihlangothi (lila [lila]).

== '''Urephula''' ==
Urephula litjhada olingusinini eliphinyiswa ngokuthi kuzwakale ukurhephula.

''Isibonelo:''

# r[r]: urephula ongusinini onelizwi (rara [rara]).

== '''Abosingakamisa''' ==
Abosingakamisa matjhada obolwangeni nanyana aborhwalabha.

''Isibonelo:'' 

# y[j]: usingakamisa ongurhwalabha (ongulwangeni) [yeyezela [jɛjɛzɛla]

== '''Abomakghadlana''' ==
Abomakghadlana matjhada lawo aphinyiswa ngeendebe zomlomo nanyana ngokuthi ilimi likghwathe ilwangeni.

''Isibonelo:'' 

# m[m]: umakghadlana ongundebembili (mina [mina]).
# n[n]: umakghadlana ongusinini (inani [inani]).

== '''Abongwaqabathwa Ababozinyo''' ==
Abongwaqabathwa matjhada lawo asuselwa kubaThwa. Ubongwaqabathwa laba bafaka abongwaqabathwa ababozinyo, aababosininirhwalabha nabohlangothi. 

''Isibonelo:''

1. Abongwaqabathwa Ababozinyo

c[/]: ungwaqabathwa onganalizwi onguzinyo (coca [/ɔ/a]).

2. Abongwaqabathwa Ababosininirhwalabha (-lwangeni)

q[!]: ungwaqabathwa onganalizwi ongusininirhwalabha (qina)

3. Abongwaqabathwa Abahlangothi

nx[ŋ//]: ungwaqabathwa okghadlazisweko ohlangothi (nxifa [ŋ//ifa]).


Abongwaqa matjhada lawo abaqakathekileko bonyana bafundwe begodu bazwisise ngombala bakulayela ngamatjhada asetjenziswa esiNdebeleni kanye nangendlela atlolwa ngayo.</text>
      <sha1>ajbijv3kr2s00i16clkz9m44txoei2v</sha1>
    </revision>
    <revision>
      <id>461</id>
      <parentid>460</parentid>
      <timestamp>2024-05-10T10:24:13Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>461</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3051" sha1="5mefmlxx2iyec3bhr9itfrlilp8rehx" xml:space="preserve">== '''Abongwaqa''' ==
Abongwaqa ngamanye amatjhada asetjenziswa khulu esiNdebeleni. Amatjhada la, abongwaqa, asetjenziswa nabokamisa ukuze kube matjhada la azwakalako. Abongwaqa bamihlobo ehlukeneko. Imihlobo le ibizwa bona; Abodumuza/Abodubula, ububula, abomavuthelwa, abomavuthelwagandelela, uliliza, urephula, abosingakamisa, abomakghadlana, abongwabathwa, abongwaqabathwa ababozinyo, abongwaqabathwa abosininirhwalabha  nabongwaqabatha abahlangothi. Esigatjeni esilandelako sizokukhuluma ngemihlobo yabongwaqa. 

== '''Abodumuza/Abodubula''' ==
Abodumuza nanyana abodubula matjhada lawo othi nawuwaphimisako, umoya uphume ngebelo nawuya ngaphandle bese kube khona ukudumuza komoya. 

''Isibonelo:'' 

# p[p’]: udumuza oputjukako ongundebembili (ipisi [ip’isi])
# d[d]: udumuza onelizwi ongusinini.Utholakala kuhlanganiselamakghadlana (indaba [indaƃa])

== '''Ububula''' ==
Litjhada elingundebembili lelo eliphimiswa ngokububula.

''Isibonelo:''

# b[ƃ]: ububula ongundebembili.basa [ƃasa]

== '''Abomavuthelwa''' ==
Abomavuthelwa matjhada lawo othi nawuwaphimisako kuzwakale ukuvuthelwa.

''Isibonelo:'' 

# f[f]: umavuthelwa onganalizwi ongundebezinyo (fafatha [fafatha]).

== '''Abomavuthelwagandelela''' ==
Abomavuthelwagandelela matjhada lawo othi nawuwaphimisako ilimi lakho lirhwathe ilwangeni bese kuvimbeke umoya. Umoya lo bese uphume sele ugandelelekile.

''Isibonelo:'' 

# ts[ts’]: umavuthelwagandelela oputjukako ongusinini (itsetse [its’ɛts’ɛ).
# dz[dz]: umavuthelwagandelela onelizwi ongusinini (idzila [idzila).

== '''Uliliza''' ==
Uliliza litjhada lelo elinelwi begodu nawuliphimisako ilimi likghwatha iinsini bese umoya uphome ngemahlangothini. 

''Isibonelo:'' 

# l[l]: uliliza onelizwi ongusininihlangothi (lila [lila]).

== '''Urephula''' ==
Urephula litjhada olingusinini eliphinyiswa ngokuthi kuzwakale ukurhephula.

''Isibonelo:''

# r[r]: urephula ongusinini onelizwi (rara [rara]).

== '''Abosingakamisa''' ==
Abosingakamisa matjhada obolwangeni nanyana aborhwalabha.

''Isibonelo:'' 

# y[j]: usingakamisa ongurhwalabha (ongulwangeni) [yeyezela [jɛjɛzɛla]

== '''Abomakghadlana''' ==
Abomakghadlana matjhada lawo aphinyiswa ngeendebe zomlomo nanyana ngokuthi ilimi likghwathe ilwangeni.

''Isibonelo:'' 

# m[m]: umakghadlana ongundebembili (mina [mina]).
# n[n]: umakghadlana ongusinini (inani [inani]).

== '''Abongwaqabathwa Ababozinyo''' ==
Abongwaqabathwa matjhada lawo asuselwa kubaThwa. Ubongwaqabathwa laba bafaka abongwaqabathwa ababozinyo, aababosininirhwalabha nabohlangothi. 

''Isibonelo:''

1. Abongwaqabathwa Ababozinyo

c[/]: ungwaqabathwa onganalizwi onguzinyo (coca [/ɔ/a]).

2. Abongwaqabathwa Ababosininirhwalabha (-lwangeni)

q[!]: ungwaqabathwa onganalizwi ongusininirhwalabha (qina)

3. Abongwaqabathwa Abahlangothi

nx[ŋ//]: ungwaqabathwa okghadlazisweko ohlangothi (nxifa [ŋ//ifa]).

== '''Isiphetho''' ==


Abongwaqa matjhada lawo abaqakathekileko bonyana bafundwe begodu bazwisise ngombala bakulayela ngamatjhada asetjenziswa esiNdebeleni kanye nangendlela atlolwa ngayo.</text>
      <sha1>5mefmlxx2iyec3bhr9itfrlilp8rehx</sha1>
    </revision>
    <revision>
      <id>462</id>
      <parentid>461</parentid>
      <timestamp>2024-07-25T13:49:43Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>462</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3053" sha1="2v471wrpt0z1736w9slaq5l0e5h7sz6" xml:space="preserve">== '''Abongwaqa''' ==
Abongwaqa ngamanye amatjhada asetjenziswa khulu esiNdebeleni. Amatjhada la, abongwaqa, asetjenziswa nabokamisa ukuze kube matjhada la azwakalako. Abongwaqa bamihlobo ehlukeneko. Imihlobo le ibizwa bona; Abodumuza/Abodubula, ububula, abomavuthelwa, abomavuthelwagandelela, uliliza, urephula, abosingakamisa, abomakghadlana, abongwaqabathwa, abongwaqabathwa ababozinyo, abongwaqabathwa abosininirhwalabha  nabongwaqabatha abahlangothi. Esigatjeni esilandelako sizokukhuluma ngemihlobo yabongwaqa. 

== '''Abodumuza/Abodubula''' ==
Abodumuza nanyana abodubula matjhada lawo othi nawuwaphimisako, umoya uphume ngebelo nawuya ngaphandle bese kube khona ukudumuza komoya. 

''Isibonelo:'' 

# p[p’]: udumuza oputjukako ongundebembili (ipisi [ip’isi])
# d[d]: udumuza onelizwi ongusinini.Utholakala kuhlanganiselamakghadlana (indaba [indaƃa])

== '''Ububula''' ==
Litjhada elingundebembili lelo eliphimiswa ngokububula.

''Isibonelo:''

# b[ƃ]: ububula ongundebembili.basa [ƃasa]

== '''Abomavuthelwa''' ==
Abomavuthelwa matjhada lawo othi nawuwaphimisako kuzwakale ukuvuthelwa.

''Isibonelo:'' 

# f[f]: umavuthelwa onganalizwi ongundebezinyo (fafatha [fafatha]).

== '''Abomavuthelwagandelela''' ==
Abomavuthelwagandelela matjhada lawo othi nawuwaphimisako ilimi lakho lirhwathe ilwangeni bese kuvimbeke umoya. Umoya lo bese uphume sele ugandelelekile.

''Isibonelo:'' 

# ts[ts’]: umavuthelwagandelela oputjukako ongusinini (itsetse [its’ɛts’ɛ).
# dz[dz]: umavuthelwagandelela onelizwi ongusinini (idzila [idzila).

== '''Uliliza''' ==
Uliliza litjhada lelo elinelwi begodu nawuliphimisako ilimi likghwatha iinsini bese umoya uphome ngemahlangothini. 

''Isibonelo:'' 

# l[l]: uliliza onelizwi ongusininihlangothi (lila [lila]).

== '''Urephula''' ==
Urephula litjhada olingusinini eliphinyiswa ngokuthi kuzwakale ukurhephula.

''Isibonelo:''

# r[r]: urephula ongusinini onelizwi (rara [rara]).

== '''Abosingakamisa''' ==
Abosingakamisa matjhada obolwangeni nanyana aborhwalabha.

''Isibonelo:'' 

# y[j]: usingakamisa ongurhwalabha (ongulwangeni) [yeyezela [jɛjɛzɛla]

== '''Abomakghadlana''' ==
Abomakghadlana matjhada lawo aphinyiswa ngeendebe zomlomo nanyana ngokuthi ilimi likghwathe ilwangeni.

''Isibonelo:'' 

# m[m]: umakghadlana ongundebembili (mina [mina]).
# n[n]: umakghadlana ongusinini (inani [inani]).

== '''Abongwaqabathwa Ababozinyo''' ==
Abongwaqabathwa matjhada lawo asuselwa kubaThwa. Ubongwaqabathwa laba bafaka abongwaqabathwa ababozinyo, aababosininirhwalabha nabohlangothi. 

''Isibonelo:''

1. Abongwaqabathwa Ababozinyo

c[/]: ungwaqabathwa onganalizwi onguzinyo (coca [/ɔ/a]).

2. Abongwaqabathwa Ababosininirhwalabha (-lwangeni)

q[!]: ungwaqabathwa onganalizwi ongusininirhwalabha (qina)

3. Abongwaqabathwa Abahlangothi

nx[ŋ//]: ungwaqabathwa okghadlazisweko ohlangothi (nxifa [ŋ//ifa]).

== '''Isiphetho''' ==


Abongwaqa matjhada lawo abaqakathekileko bonyana bafundwe begodu bazwisise ngombala bakulayela ngamatjhada asetjenziswa esiNdebeleni kanye nangendlela atlolwa ngayo.</text>
      <sha1>2v471wrpt0z1736w9slaq5l0e5h7sz6</sha1>
    </revision>
    <revision>
      <id>463</id>
      <parentid>462</parentid>
      <timestamp>2024-09-18T15:39:26Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <origin>463</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3056" sha1="q1ac5dbjqyrop83lg6gz1vqyoqu7inx" xml:space="preserve">== '''Abongwaqa''' ==
Abongwaqa ngamanye amatjhada asetjenziswa khulu esiNdebeleni. Amatjhada la, abongwaqa, asetjenziswa nabokamisa ukuze kube matjhada la azwakalako. Abongwaqa bamihlobo ehlukeneko. Imihlobo le ibizwa bona; Abodumuza/Abodubula, ububula, abomavuthelwa, abomavuthelwagandelela, uliliza, urephula, abosingakamisa, abomakghadlana, abongwaqabathwa, abongwaqabathwa ababozinyo, abongwaqabathwa abosininirhwalabha  nabongwaqabatha abahlangothi. Esigatjeni esilandelako sizokukhuluma ngemihlobo yabongwaqa. 

== '''Abodumuza/Abodubula''' ==
Abodumuza nanyana abodubula matjhada lawo othi nawuwaphimisako, umoya uphume ngebelo nawuya ngaphandle bese kube khona ukudumuza komoya. 

''Isibonelo:'' 

# p[p’]: udumuza oputjukako ongundebembili (ipisi [ip’isi])
# d[d]: udumuza onelizwi ongusinini.Utholakala kuhlanganiselamakghadlana (indaba [indaƃa])

== '''Ububula.''' ==
Litjhada elingundebembili lelo eliphimiswa ngokububula.

''Isibonelo:''

# b[ƃ]: ububula ongundebembili.basa [ƃasa]

== '''Abomavuthelwa.''' ==
Abomavuthelwa matjhada lawo othi nawuwaphimisako kuzwakale ukuvuthelwa.

''Isibonelo:'' 

# f[f]: umavuthelwa onganalizwi ongundebezinyo (fafatha [fafatha]).

== '''Abomavuthelwagandelela.''' ==
Abomavuthelwagandelela matjhada lawo othi nawuwaphimisako ilimi lakho lirhwathe ilwangeni bese kuvimbeke umoya. Umoya lo bese uphume sele ugandelelekile.

''Isibonelo:'' 

# ts[ts’]: umavuthelwagandelela oputjukako ongusinini (itsetse [its’ɛts’ɛ).
# dz[dz]: umavuthelwagandelela onelizwi ongusinini (idzila [idzila).

== '''Uliliza''' ==
Uliliza litjhada lelo elinelwi begodu nawuliphimisako ilimi likghwatha iinsini bese umoya uphome ngemahlangothini. 

''Isibonelo:'' 

# l[l]: uliliza onelizwi ongusininihlangothi (lila [lila]).

== '''Urephula''' ==
Urephula litjhada olingusinini eliphinyiswa ngokuthi kuzwakale ukurhephula.

''Isibonelo:''

# r[r]: urephula ongusinini onelizwi (rara [rara]).

== '''Abosingakamisa''' ==
Abosingakamisa matjhada obolwangeni nanyana aborhwalabha.

''Isibonelo:'' 

# y[j]: usingakamisa ongurhwalabha (ongulwangeni) [yeyezela [jɛjɛzɛla]

== '''Abomakghadlana''' ==
Abomakghadlana matjhada lawo aphinyiswa ngeendebe zomlomo nanyana ngokuthi ilimi likghwathe ilwangeni.

''Isibonelo:'' 

# m[m]: umakghadlana ongundebembili (mina [mina]).
# n[n]: umakghadlana ongusinini (inani [inani]).

== '''Abongwaqabathwa Ababozinyo''' ==
Abongwaqabathwa matjhada lawo asuselwa kubaThwa. Ubongwaqabathwa laba bafaka abongwaqabathwa ababozinyo, aababosininirhwalabha nabohlangothi. 

''Isibonelo:''

1. Abongwaqabathwa Ababozinyo

c[/]: ungwaqabathwa onganalizwi onguzinyo (coca [/ɔ/a]).

2. Abongwaqabathwa Ababosininirhwalabha (-lwangeni)

q[!]: ungwaqabathwa onganalizwi ongusininirhwalabha (qina)

3. Abongwaqabathwa Abahlangothi

nx[ŋ//]: ungwaqabathwa okghadlazisweko ohlangothi (nxifa [ŋ//ifa]).

== '''Isiphetho''' ==


Abongwaqa matjhada lawo abaqakathekileko bonyana bafundwe begodu bazwisise ngombala bakulayela ngamatjhada asetjenziswa esiNdebeleni kanye nangendlela atlolwa ngayo.</text>
      <sha1>q1ac5dbjqyrop83lg6gz1vqyoqu7inx</sha1>
    </revision>
    <revision>
      <id>464</id>
      <parentid>463</parentid>
      <timestamp>2024-09-18T15:39:45Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>464</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3057" sha1="gesgune3m80yr1c27b802gl6e0di2ut" xml:space="preserve">== '''Abongwaqa.''' ==
Abongwaqa ngamanye amatjhada asetjenziswa khulu esiNdebeleni. Amatjhada la, abongwaqa, asetjenziswa nabokamisa ukuze kube matjhada la azwakalako. Abongwaqa bamihlobo ehlukeneko. Imihlobo le ibizwa bona; Abodumuza/Abodubula, ububula, abomavuthelwa, abomavuthelwagandelela, uliliza, urephula, abosingakamisa, abomakghadlana, abongwaqabathwa, abongwaqabathwa ababozinyo, abongwaqabathwa abosininirhwalabha  nabongwaqabatha abahlangothi. Esigatjeni esilandelako sizokukhuluma ngemihlobo yabongwaqa. 

== '''Abodumuza/Abodubula''' ==
Abodumuza nanyana abodubula matjhada lawo othi nawuwaphimisako, umoya uphume ngebelo nawuya ngaphandle bese kube khona ukudumuza komoya. 

''Isibonelo:'' 

# p[p’]: udumuza oputjukako ongundebembili (ipisi [ip’isi])
# d[d]: udumuza onelizwi ongusinini.Utholakala kuhlanganiselamakghadlana (indaba [indaƃa])

== '''Ububula.''' ==
Litjhada elingundebembili lelo eliphimiswa ngokububula.

''Isibonelo:''

# b[ƃ]: ububula ongundebembili.basa [ƃasa]

== '''Abomavuthelwa.''' ==
Abomavuthelwa matjhada lawo othi nawuwaphimisako kuzwakale ukuvuthelwa.

''Isibonelo:'' 

# f[f]: umavuthelwa onganalizwi ongundebezinyo (fafatha [fafatha]).

== '''Abomavuthelwagandelela.''' ==
Abomavuthelwagandelela matjhada lawo othi nawuwaphimisako ilimi lakho lirhwathe ilwangeni bese kuvimbeke umoya. Umoya lo bese uphume sele ugandelelekile.

''Isibonelo:'' 

# ts[ts’]: umavuthelwagandelela oputjukako ongusinini (itsetse [its’ɛts’ɛ).
# dz[dz]: umavuthelwagandelela onelizwi ongusinini (idzila [idzila).

== '''Uliliza''' ==
Uliliza litjhada lelo elinelwi begodu nawuliphimisako ilimi likghwatha iinsini bese umoya uphome ngemahlangothini. 

''Isibonelo:'' 

# l[l]: uliliza onelizwi ongusininihlangothi (lila [lila]).

== '''Urephula''' ==
Urephula litjhada olingusinini eliphinyiswa ngokuthi kuzwakale ukurhephula.

''Isibonelo:''

# r[r]: urephula ongusinini onelizwi (rara [rara]).

== '''Abosingakamisa''' ==
Abosingakamisa matjhada obolwangeni nanyana aborhwalabha.

''Isibonelo:'' 

# y[j]: usingakamisa ongurhwalabha (ongulwangeni) [yeyezela [jɛjɛzɛla]

== '''Abomakghadlana''' ==
Abomakghadlana matjhada lawo aphinyiswa ngeendebe zomlomo nanyana ngokuthi ilimi likghwathe ilwangeni.

''Isibonelo:'' 

# m[m]: umakghadlana ongundebembili (mina [mina]).
# n[n]: umakghadlana ongusinini (inani [inani]).

== '''Abongwaqabathwa Ababozinyo''' ==
Abongwaqabathwa matjhada lawo asuselwa kubaThwa. Ubongwaqabathwa laba bafaka abongwaqabathwa ababozinyo, aababosininirhwalabha nabohlangothi. 

''Isibonelo:''

1. Abongwaqabathwa Ababozinyo

c[/]: ungwaqabathwa onganalizwi onguzinyo (coca [/ɔ/a]).

2. Abongwaqabathwa Ababosininirhwalabha (-lwangeni)

q[!]: ungwaqabathwa onganalizwi ongusininirhwalabha (qina)

3. Abongwaqabathwa Abahlangothi

nx[ŋ//]: ungwaqabathwa okghadlazisweko ohlangothi (nxifa [ŋ//ifa]).

== '''Isiphetho''' ==


Abongwaqa matjhada lawo abaqakathekileko bonyana bafundwe begodu bazwisise ngombala bakulayela ngamatjhada asetjenziswa esiNdebeleni kanye nangendlela atlolwa ngayo.</text>
      <sha1>gesgune3m80yr1c27b802gl6e0di2ut</sha1>
    </revision>
    <revision>
      <id>465</id>
      <parentid>464</parentid>
      <timestamp>2024-09-18T16:17:37Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>465</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3058" sha1="dl2rbppmykfxgjmxwu6udzozr42p5o7" xml:space="preserve">== '''Abongwaqa.''' ==
Abongwaqa ngamanye amatjhada asetjenziswa khulu esiNdebeleni. Amatjhada la, abongwaqa, asetjenziswa nabokamisa ukuze kube matjhada la azwakalako. Abongwaqa bamihlobo ehlukeneko. Imihlobo le ibizwa bona; Abodumuza/Abodubula, ububula, abomavuthelwa, abomavuthelwagandelela, uliliza, urephula, abosingakamisa, abomakghadlana, abongwaqabathwa, abongwaqabathwa ababozinyo, abongwaqabathwa abosininirhwalabha  nabongwaqabatha abahlangothi. Esigatjeni esilandelako sizokukhuluma ngemihlobo yabongwaqa. 

== '''Abodumuza/Abodubula.''' ==
Abodumuza nanyana abodubula matjhada lawo othi nawuwaphimisako, umoya uphume ngebelo nawuya ngaphandle bese kube khona ukudumuza komoya. 

''Isibonelo:'' 

# p[p’]: udumuza oputjukako ongundebembili (ipisi [ip’isi])
# d[d]: udumuza onelizwi ongusinini.Utholakala kuhlanganiselamakghadlana (indaba [indaƃa])

== '''Ububula.''' ==
Litjhada elingundebembili lelo eliphimiswa ngokububula.

''Isibonelo:''

# b[ƃ]: ububula ongundebembili.basa [ƃasa]

== '''Abomavuthelwa.''' ==
Abomavuthelwa matjhada lawo othi nawuwaphimisako kuzwakale ukuvuthelwa.

''Isibonelo:'' 

# f[f]: umavuthelwa onganalizwi ongundebezinyo (fafatha [fafatha]).

== '''Abomavuthelwagandelela.''' ==
Abomavuthelwagandelela matjhada lawo othi nawuwaphimisako ilimi lakho lirhwathe ilwangeni bese kuvimbeke umoya. Umoya lo bese uphume sele ugandelelekile.

''Isibonelo:'' 

# ts[ts’]: umavuthelwagandelela oputjukako ongusinini (itsetse [its’ɛts’ɛ).
# dz[dz]: umavuthelwagandelela onelizwi ongusinini (idzila [idzila).

== '''Uliliza''' ==
Uliliza litjhada lelo elinelwi begodu nawuliphimisako ilimi likghwatha iinsini bese umoya uphome ngemahlangothini. 

''Isibonelo:'' 

# l[l]: uliliza onelizwi ongusininihlangothi (lila [lila]).

== '''Urephula''' ==
Urephula litjhada olingusinini eliphinyiswa ngokuthi kuzwakale ukurhephula.

''Isibonelo:''

# r[r]: urephula ongusinini onelizwi (rara [rara]).

== '''Abosingakamisa''' ==
Abosingakamisa matjhada obolwangeni nanyana aborhwalabha.

''Isibonelo:'' 

# y[j]: usingakamisa ongurhwalabha (ongulwangeni) [yeyezela [jɛjɛzɛla]

== '''Abomakghadlana''' ==
Abomakghadlana matjhada lawo aphinyiswa ngeendebe zomlomo nanyana ngokuthi ilimi likghwathe ilwangeni.

''Isibonelo:'' 

# m[m]: umakghadlana ongundebembili (mina [mina]).
# n[n]: umakghadlana ongusinini (inani [inani]).

== '''Abongwaqabathwa Ababozinyo''' ==
Abongwaqabathwa matjhada lawo asuselwa kubaThwa. Ubongwaqabathwa laba bafaka abongwaqabathwa ababozinyo, aababosininirhwalabha nabohlangothi. 

''Isibonelo:''

1. Abongwaqabathwa Ababozinyo

c[/]: ungwaqabathwa onganalizwi onguzinyo (coca [/ɔ/a]).

2. Abongwaqabathwa Ababosininirhwalabha (-lwangeni)

q[!]: ungwaqabathwa onganalizwi ongusininirhwalabha (qina)

3. Abongwaqabathwa Abahlangothi

nx[ŋ//]: ungwaqabathwa okghadlazisweko ohlangothi (nxifa [ŋ//ifa]).

== '''Isiphetho''' ==


Abongwaqa matjhada lawo abaqakathekileko bonyana bafundwe begodu bazwisise ngombala bakulayela ngamatjhada asetjenziswa esiNdebeleni kanye nangendlela atlolwa ngayo.</text>
      <sha1>dl2rbppmykfxgjmxwu6udzozr42p5o7</sha1>
    </revision>
    <revision>
      <id>466</id>
      <parentid>465</parentid>
      <timestamp>2024-10-14T13:46:30Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>7 revisions imported</comment>
      <origin>465</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3058" sha1="dl2rbppmykfxgjmxwu6udzozr42p5o7" xml:space="preserve">== '''Abongwaqa.''' ==
Abongwaqa ngamanye amatjhada asetjenziswa khulu esiNdebeleni. Amatjhada la, abongwaqa, asetjenziswa nabokamisa ukuze kube matjhada la azwakalako. Abongwaqa bamihlobo ehlukeneko. Imihlobo le ibizwa bona; Abodumuza/Abodubula, ububula, abomavuthelwa, abomavuthelwagandelela, uliliza, urephula, abosingakamisa, abomakghadlana, abongwaqabathwa, abongwaqabathwa ababozinyo, abongwaqabathwa abosininirhwalabha  nabongwaqabatha abahlangothi. Esigatjeni esilandelako sizokukhuluma ngemihlobo yabongwaqa. 

== '''Abodumuza/Abodubula.''' ==
Abodumuza nanyana abodubula matjhada lawo othi nawuwaphimisako, umoya uphume ngebelo nawuya ngaphandle bese kube khona ukudumuza komoya. 

''Isibonelo:'' 

# p[p’]: udumuza oputjukako ongundebembili (ipisi [ip’isi])
# d[d]: udumuza onelizwi ongusinini.Utholakala kuhlanganiselamakghadlana (indaba [indaƃa])

== '''Ububula.''' ==
Litjhada elingundebembili lelo eliphimiswa ngokububula.

''Isibonelo:''

# b[ƃ]: ububula ongundebembili.basa [ƃasa]

== '''Abomavuthelwa.''' ==
Abomavuthelwa matjhada lawo othi nawuwaphimisako kuzwakale ukuvuthelwa.

''Isibonelo:'' 

# f[f]: umavuthelwa onganalizwi ongundebezinyo (fafatha [fafatha]).

== '''Abomavuthelwagandelela.''' ==
Abomavuthelwagandelela matjhada lawo othi nawuwaphimisako ilimi lakho lirhwathe ilwangeni bese kuvimbeke umoya. Umoya lo bese uphume sele ugandelelekile.

''Isibonelo:'' 

# ts[ts’]: umavuthelwagandelela oputjukako ongusinini (itsetse [its’ɛts’ɛ).
# dz[dz]: umavuthelwagandelela onelizwi ongusinini (idzila [idzila).

== '''Uliliza''' ==
Uliliza litjhada lelo elinelwi begodu nawuliphimisako ilimi likghwatha iinsini bese umoya uphome ngemahlangothini. 

''Isibonelo:'' 

# l[l]: uliliza onelizwi ongusininihlangothi (lila [lila]).

== '''Urephula''' ==
Urephula litjhada olingusinini eliphinyiswa ngokuthi kuzwakale ukurhephula.

''Isibonelo:''

# r[r]: urephula ongusinini onelizwi (rara [rara]).

== '''Abosingakamisa''' ==
Abosingakamisa matjhada obolwangeni nanyana aborhwalabha.

''Isibonelo:'' 

# y[j]: usingakamisa ongurhwalabha (ongulwangeni) [yeyezela [jɛjɛzɛla]

== '''Abomakghadlana''' ==
Abomakghadlana matjhada lawo aphinyiswa ngeendebe zomlomo nanyana ngokuthi ilimi likghwathe ilwangeni.

''Isibonelo:'' 

# m[m]: umakghadlana ongundebembili (mina [mina]).
# n[n]: umakghadlana ongusinini (inani [inani]).

== '''Abongwaqabathwa Ababozinyo''' ==
Abongwaqabathwa matjhada lawo asuselwa kubaThwa. Ubongwaqabathwa laba bafaka abongwaqabathwa ababozinyo, aababosininirhwalabha nabohlangothi. 

''Isibonelo:''

1. Abongwaqabathwa Ababozinyo

c[/]: ungwaqabathwa onganalizwi onguzinyo (coca [/ɔ/a]).

2. Abongwaqabathwa Ababosininirhwalabha (-lwangeni)

q[!]: ungwaqabathwa onganalizwi ongusininirhwalabha (qina)

3. Abongwaqabathwa Abahlangothi

nx[ŋ//]: ungwaqabathwa okghadlazisweko ohlangothi (nxifa [ŋ//ifa]).

== '''Isiphetho''' ==


Abongwaqa matjhada lawo abaqakathekileko bonyana bafundwe begodu bazwisise ngombala bakulayela ngamatjhada asetjenziswa esiNdebeleni kanye nangendlela atlolwa ngayo.</text>
      <sha1>dl2rbppmykfxgjmxwu6udzozr42p5o7</sha1>
    </revision>
    <revision>
      <id>5050</id>
      <parentid>466</parentid>
      <timestamp>2025-08-07T08:43:46Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <origin>5050</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3035" sha1="fjsqpt5fr08pclw0n6w7gdfhtm9l38o" xml:space="preserve">Abongwaqa ngamanye amatjhada asetjenziswa khulu esiNdebeleni. Amatjhada la, abongwaqa, asetjenziswa nabokamisa ukuze kube matjhada la azwakalako. Abongwaqa bamihlobo ehlukeneko. Imihlobo le ibizwa bona; Abodumuza/Abodubula, ububula, abomavuthelwa, abomavuthelwagandelela, uliliza, urephula, abosingakamisa, abomakghadlana, abongwaqabathwa, abongwaqabathwa ababozinyo, abongwaqabathwa abosininirhwalabha  nabongwaqabatha abahlangothi. Esigatjeni esilandelako sizokukhuluma ngemihlobo yabongwaqa. 

== '''Abodumuza/Abodubula.''' ==
Abodumuza nanyana abodubula matjhada lawo othi nawuwaphimisako, umoya uphume ngebelo nawuya ngaphandle bese kube khona ukudumuza komoya. 

''Isibonelo:'' 

# p[p’]: udumuza oputjukako ongundebembili (ipisi [ip’isi])
# d[d]: udumuza onelizwi ongusinini.Utholakala kuhlanganiselamakghadlana (indaba [indaƃa])

== '''Ububula.''' ==
Litjhada elingundebembili lelo eliphimiswa ngokububula.

''Isibonelo:''

# b[ƃ]: ububula ongundebembili.basa [ƃasa]

== '''Abomavuthelwa.''' ==
Abomavuthelwa matjhada lawo othi nawuwaphimisako kuzwakale ukuvuthelwa.

''Isibonelo:'' 

# f[f]: umavuthelwa onganalizwi ongundebezinyo (fafatha [fafatha]).

== '''Abomavuthelwagandelela.''' ==
Abomavuthelwagandelela matjhada lawo othi nawuwaphimisako ilimi lakho lirhwathe ilwangeni bese kuvimbeke umoya. Umoya lo bese uphume sele ugandelelekile.

''Isibonelo:'' 

# ts[ts’]: umavuthelwagandelela oputjukako ongusinini (itsetse [its’ɛts’ɛ).
# dz[dz]: umavuthelwagandelela onelizwi ongusinini (idzila [idzila).

== '''Uliliza''' ==
Uliliza litjhada lelo elinelwi begodu nawuliphimisako ilimi likghwatha iinsini bese umoya uphome ngemahlangothini. 

''Isibonelo:'' 

# l[l]: uliliza onelizwi ongusininihlangothi (lila [lila]).

== '''Urephula''' ==
Urephula litjhada olingusinini eliphinyiswa ngokuthi kuzwakale ukurhephula.

''Isibonelo:''

# r[r]: urephula ongusinini onelizwi (rara [rara]).

== '''Abosingakamisa''' ==
Abosingakamisa matjhada obolwangeni nanyana aborhwalabha.

''Isibonelo:'' 

# y[j]: usingakamisa ongurhwalabha (ongulwangeni) [yeyezela [jɛjɛzɛla]

== '''Abomakghadlana''' ==
Abomakghadlana matjhada lawo aphinyiswa ngeendebe zomlomo nanyana ngokuthi ilimi likghwathe ilwangeni.

''Isibonelo:'' 

# m[m]: umakghadlana ongundebembili (mina [mina]).
# n[n]: umakghadlana ongusinini (inani [inani]).

== '''Abongwaqabathwa Ababozinyo''' ==
Abongwaqabathwa matjhada lawo asuselwa kubaThwa. Ubongwaqabathwa laba bafaka abongwaqabathwa ababozinyo, aababosininirhwalabha nabohlangothi. 

''Isibonelo:''

1. Abongwaqabathwa Ababozinyo

c[/]: ungwaqabathwa onganalizwi onguzinyo (coca [/ɔ/a]).

2. Abongwaqabathwa Ababosininirhwalabha (-lwangeni)

q[!]: ungwaqabathwa onganalizwi ongusininirhwalabha (qina)

3. Abongwaqabathwa Abahlangothi

nx[ŋ//]: ungwaqabathwa okghadlazisweko ohlangothi (nxifa [ŋ//ifa]).

== '''Isiphetho''' ==


Abongwaqa matjhada lawo abaqakathekileko bonyana bafundwe begodu bazwisise ngombala bakulayela ngamatjhada asetjenziswa esiNdebeleni kanye nangendlela atlolwa ngayo.</text>
      <sha1>fjsqpt5fr08pclw0n6w7gdfhtm9l38o</sha1>
    </revision>
  </page>
  <page>
    <title>AmaNdebele</title>
    <ns>0</ns>
    <id>113</id>
    <revision>
      <id>467</id>
      <timestamp>2024-03-08T13:36:46Z</timestamp>
      <contributor>
        <username>incubator&gt;Mosakaruka</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;AmaNdebele sitjhaba sabantu abakhuluma isiNdebele esinabantu abalinganiselwa eengidini ezimbili. Inengi lawo lihlala esifundeni seMpumalanga, kodwana amanye asabalele eemfundeni zoke zeSewula Afrika. Aziwa ngobukghwari bokugwala ephasini loke zombelele, izembatho neengubo zawo ezihle ezinemibala ekhanyako .  Abanye bacabanga bona imvelaphi yamaNdebele isemaHlubini. Lokhu kubonakala ngobufakazi belimi phakathi kwelimi lesiNdebele nesiHlubi. Kunamagama amanengana akhona es...&quot;</comment>
      <origin>467</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="842" sha1="2veev4f3q1ove5fppdklhmhbpqnnjms" xml:space="preserve">AmaNdebele sitjhaba sabantu abakhuluma isiNdebele esinabantu abalinganiselwa eengidini ezimbili. Inengi lawo lihlala esifundeni seMpumalanga, kodwana amanye asabalele eemfundeni zoke zeSewula Afrika. Aziwa ngobukghwari bokugwala ephasini loke zombelele, izembatho neengubo zawo ezihle ezinemibala ekhanyako .

Abanye bacabanga bona imvelaphi yamaNdebele isemaHlubini. Lokhu kubonakala ngobufakazi belimi phakathi kwelimi lesiNdebele nesiHlubi. Kunamagama amanengana akhona esiNdebeleni akhona nelimini lesiHlubi. Ngokwesibonelo, amagama anjengokuthi, &quot;sela&quot;, &quot;fumana&quot;, &quot;ekhabo&quot;, njll, begodu womabili amalimi la ayandondoza. Okhunye okufuze kutjhejwe kukobana amaNdebele weSewula Afrika awafani namaNdebele weZimbabwe. Nanyana abosomlando baveza bona iinqhema ezimbilezi zakhe zahlangana esikhathini esithileko, kodwana umsuka wazo awufani.

</text>
      <sha1>2veev4f3q1ove5fppdklhmhbpqnnjms</sha1>
    </revision>
    <revision>
      <id>468</id>
      <parentid>467</parentid>
      <timestamp>2024-03-08T13:37:43Z</timestamp>
      <contributor>
        <username>incubator&gt;Mosakaruka</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Bolded the first word</comment>
      <origin>468</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="848" sha1="7brqu99dkhjep0c5665tp8u3m04d79v" xml:space="preserve">'''AmaNdebele''' sitjhaba sabantu abakhuluma isiNdebele esinabantu abalinganiselwa eengidini ezimbili. Inengi lawo lihlala esifundeni seMpumalanga, kodwana amanye asabalele eemfundeni zoke zeSewula Afrika. Aziwa ngobukghwari bokugwala ephasini loke zombelele, izembatho neengubo zawo ezihle ezinemibala ekhanyako .

Abanye bacabanga bona imvelaphi yamaNdebele isemaHlubini. Lokhu kubonakala ngobufakazi belimi phakathi kwelimi lesiNdebele nesiHlubi. Kunamagama amanengana akhona esiNdebeleni akhona nelimini lesiHlubi. Ngokwesibonelo, amagama anjengokuthi, &quot;sela&quot;, &quot;fumana&quot;, &quot;ekhabo&quot;, njll, begodu womabili amalimi la ayandondoza. Okhunye okufuze kutjhejwe kukobana amaNdebele weSewula Afrika awafani namaNdebele weZimbabwe. Nanyana abosomlando baveza bona iinqhema ezimbilezi zakhe zahlangana esikhathini esithileko, kodwana umsuka wazo awufani.

</text>
      <sha1>7brqu99dkhjep0c5665tp8u3m04d79v</sha1>
    </revision>
    <revision>
      <id>469</id>
      <parentid>468</parentid>
      <timestamp>2024-03-08T13:40:40Z</timestamp>
      <contributor>
        <username>incubator&gt;Mosakaruka</username>
        <id>0</id>
      </contributor>
      <comment>Added the subheading</comment>
      <origin>469</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="922" sha1="s1gzkixzg7495h4o426vl54p02o3c3y" xml:space="preserve">'''AmaNdebele''' sitjhaba sabantu abakhuluma isiNdebele esinabantu abalinganiselwa eengidini ezimbili. Inengi lawo lihlala esifundeni seMpumalanga, kodwana amanye asabalele eemfundeni zoke zeSewula Afrika. Aziwa ngobukghwari bokugwala ephasini loke zombelele, izembatho neengubo zawo ezihle ezinemibala ekhanyako.

Abanye bacabanga bona imvelaphi yamaNdebele isemaHlubini. Lokhu kubonakala ngobufakazi belimi phakathi kwelimi lesiNdebele nesiHlubi. Kunamagama amanengana akhona esiNdebeleni akhona nelimini lesiHlubi. Ngokwesibonelo, amagama anjengokuthi, &quot;sela&quot;, &quot;fumana&quot;, &quot;ekhabo&quot;, njll, begodu womabili amalimi la ayandondoza. Okhunye okufuze kutjhejwe kukobana amaNdebele weSewula Afrika awafani namaNdebele weZimbabwe. Nanyana abosomlando baveza bona iinqhema ezimbilezi zakhe zahlangana esikhathini esithileko, kodwana umsuka wazo awufani.

=== AmaNdebele Angaphambi Kweenkhathi [[Umlando waMandebele|Zomlando]] ===
</text>
      <sha1>s1gzkixzg7495h4o426vl54p02o3c3y</sha1>
    </revision>
    <revision>
      <id>470</id>
      <parentid>469</parentid>
      <timestamp>2024-03-08T13:41:38Z</timestamp>
      <contributor>
        <username>incubator&gt;Mosakaruka</username>
        <id>0</id>
      </contributor>
      <comment>Highlighted</comment>
      <origin>470</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="946" sha1="anijzitzebax4yt10mnerjwq1arefb4" xml:space="preserve">'''[[Umlando waMandebele|AmaNdebele]]''' sitjhaba sabantu abakhuluma isiNdebele esinabantu abalinganiselwa eengidini ezimbili. Inengi lawo lihlala esifundeni seMpumalanga, kodwana amanye asabalele eemfundeni zoke zeSewula Afrika. Aziwa ngobukghwari bokugwala ephasini loke zombelele, izembatho neengubo zawo ezihle ezinemibala ekhanyako.

Abanye bacabanga bona imvelaphi yamaNdebele isemaHlubini. Lokhu kubonakala ngobufakazi belimi phakathi kwelimi lesiNdebele nesiHlubi. Kunamagama amanengana akhona esiNdebeleni akhona nelimini lesiHlubi. Ngokwesibonelo, amagama anjengokuthi, &quot;sela&quot;, &quot;fumana&quot;, &quot;ekhabo&quot;, njll, begodu womabili amalimi la ayandondoza. Okhunye okufuze kutjhejwe kukobana amaNdebele weSewula Afrika awafani namaNdebele weZimbabwe. Nanyana abosomlando baveza bona iinqhema ezimbilezi zakhe zahlangana esikhathini esithileko, kodwana umsuka wazo awufani.

=== AmaNdebele Angaphambi Kweenkhathi [[Umlando waMandebele|Zomlando]] ===
</text>
      <sha1>anijzitzebax4yt10mnerjwq1arefb4</sha1>
    </revision>
    <revision>
      <id>471</id>
      <parentid>470</parentid>
      <timestamp>2024-03-09T07:11:08Z</timestamp>
      <contributor>
        <username>incubator&gt;Mosakaruka</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>/* AmaNdebele Angaphambi Kweenkhathi Zomlando */</comment>
      <origin>471</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1457" sha1="9epzflw9waoghmn3xkmp15ltve0inkl" xml:space="preserve">'''[[Umlando waMandebele|AmaNdebele]]''' sitjhaba sabantu abakhuluma isiNdebele esinabantu abalinganiselwa eengidini ezimbili. Inengi lawo lihlala esifundeni seMpumalanga, kodwana amanye asabalele eemfundeni zoke zeSewula Afrika. Aziwa ngobukghwari bokugwala ephasini loke zombelele, izembatho neengubo zawo ezihle ezinemibala ekhanyako.

Abanye bacabanga bona imvelaphi yamaNdebele isemaHlubini. Lokhu kubonakala ngobufakazi belimi phakathi kwelimi lesiNdebele nesiHlubi. Kunamagama amanengana akhona esiNdebeleni akhona nelimini lesiHlubi. Ngokwesibonelo, amagama anjengokuthi, &quot;sela&quot;, &quot;fumana&quot;, &quot;ekhabo&quot;, njll, begodu womabili amalimi la ayandondoza. Okhunye okufuze kutjhejwe kukobana amaNdebele weSewula Afrika awafani namaNdebele weZimbabwe. Nanyana abosomlando baveza bona iinqhema ezimbilezi zakhe zahlangana esikhathini esithileko, kodwana umsuka wazo awufani.

=== AmaNdebele Angaphambi Kweenkhathi [[Umlando waMandebele|Zomlando]] ===
Kunabosomlando abathi amaNdebele avela emaHlubini. Kuthiwa ikosi uNdebele yasuka emaHlubini nesitjhaba sayo yayokwakha endaweni ebizwa ngokobana kuseNdolwaneni. INgwenyama uNdebele wabeletha umNtungwa owaba ngubaba wesitjhaba samaNtungwa kwaNdolwana. Ngemva kwalokho umNtungwa wabeletha uMkhalangana, okukholelwa bona angaba ngubaba wamaKhalanga ahlala eZimbabwe neMalawi.

Ngokukhamba kwesikhathi uMkhalangana wabeletha uNjonono owakhamba nesitjhaba sakhe wayokwakha endaweni eyaziwa ngokuthi kuseJononoskop. 
</text>
      <sha1>9epzflw9waoghmn3xkmp15ltve0inkl</sha1>
    </revision>
    <revision>
      <id>472</id>
      <parentid>471</parentid>
      <timestamp>2024-03-09T07:30:28Z</timestamp>
      <contributor>
        <username>incubator&gt;Mosakaruka</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>/* AmaNdebele Angaphambi Kweenkhathi Zomlando */</comment>
      <origin>472</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1461" sha1="97ql4av1epja6ngs1y1huxkefzhj7fn" xml:space="preserve">'''[[Umlando waMandebele|AmaNdebele]]''' sitjhaba sabantu abakhuluma isiNdebele esinabantu abalinganiselwa eengidini ezimbili. Inengi lawo lihlala esifundeni seMpumalanga, kodwana amanye asabalele eemfundeni zoke zeSewula Afrika. Aziwa ngobukghwari bokugwala ephasini loke zombelele, izembatho neengubo zawo ezihle ezinemibala ekhanyako.

Abanye bacabanga bona imvelaphi yamaNdebele isemaHlubini. Lokhu kubonakala ngobufakazi belimi phakathi kwelimi lesiNdebele nesiHlubi. Kunamagama amanengana akhona esiNdebeleni akhona nelimini lesiHlubi. Ngokwesibonelo, amagama anjengokuthi, &quot;sela&quot;, &quot;fumana&quot;, &quot;ekhabo&quot;, njll, begodu womabili amalimi la ayandondoza. Okhunye okufuze kutjhejwe kukobana amaNdebele weSewula Afrika awafani namaNdebele weZimbabwe. Nanyana abosomlando baveza bona iinqhema ezimbilezi zakhe zahlangana esikhathini esithileko, kodwana umsuka wazo awufani.

=== AmaNdebele Angaphambi Kweenkhathi [[Umlando waMandebele|Zomlando]] ===
Kunabosomlando abathi amaNdebele avela emaHlubini. Kuthiwa ikosi uNdebele yasuka emaHlubini nesitjhaba sayo yayokwakha endaweni ebizwa ngokobana kuseNdolwaneni. INgwenyama uNdebele wabeletha umNtungwa owaba ngubaba wesitjhaba samaNtungwa kwaNdolwana. Ngemva kwalokho umNtungwa wabeletha uMkhalangana, okukholelwa bona angaba ngubaba wamaKhalanga ahlala eZimbabwe neMalawi.

Ngokukhamba kwesikhathi [[uMkhalangana]] wabeletha uNjonono owakhamba nesitjhaba sakhe wayokwakha endaweni eyaziwa ngokuthi kuseJononoskop. 
</text>
      <sha1>97ql4av1epja6ngs1y1huxkefzhj7fn</sha1>
    </revision>
    <revision>
      <id>473</id>
      <parentid>472</parentid>
      <timestamp>2024-03-09T07:34:16Z</timestamp>
      <contributor>
        <username>incubator&gt;Mosakaruka</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>473</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1552" sha1="au5ddwi1avhuw44il6aglbpwokmsgdi" xml:space="preserve">'''[[Umlando waMandebele|AmaNdebele]]''' sitjhaba sabantu abakhuluma isiNdebele esinabantu abalinganiselwa eengidini ezimbili. Inengi lawo lihlala esifundeni seMpumalanga, kodwana amanye asabalele eemfundeni zoke zeSewula Afrika. Aziwa ngobukghwari bokugwala ephasini loke zombelele (njengombana uDorh. [[Esther Mahlangu]] aba livulandlela lubukghwari bokugwala bekube nje), izembatho neengubo zawo ezihle ezinemibala ekhanyako.

Abanye bacabanga bona imvelaphi yamaNdebele isemaHlubini. Lokhu kubonakala ngobufakazi belimi phakathi kwelimi lesiNdebele nesiHlubi. Kunamagama amanengana akhona esiNdebeleni akhona nelimini lesiHlubi. Ngokwesibonelo, amagama anjengokuthi, &quot;sela&quot;, &quot;fumana&quot;, &quot;ekhabo&quot;, njll, begodu womabili amalimi la ayandondoza. Okhunye okufuze kutjhejwe kukobana amaNdebele weSewula Afrika awafani namaNdebele weZimbabwe. Nanyana abosomlando baveza bona iinqhema ezimbilezi zakhe zahlangana esikhathini esithileko, kodwana umsuka wazo awufani.

=== AmaNdebele Angaphambi Kweenkhathi [[Umlando waMandebele|Zomlando]] ===
Kunabosomlando abathi amaNdebele avela emaHlubini. Kuthiwa ikosi uNdebele yasuka emaHlubini nesitjhaba sayo yayokwakha endaweni ebizwa ngokobana kuseNdolwaneni. INgwenyama uNdebele wabeletha umNtungwa owaba ngubaba wesitjhaba samaNtungwa kwaNdolwana. Ngemva kwalokho umNtungwa wabeletha uMkhalangana, okukholelwa bona angaba ngubaba wamaKhalanga ahlala eZimbabwe neMalawi.

Ngokukhamba kwesikhathi [[uMkhalangana]] wabeletha uNjonono owakhamba nesitjhaba sakhe wayokwakha endaweni eyaziwa ngokuthi kuseJononoskop. 
</text>
      <sha1>au5ddwi1avhuw44il6aglbpwokmsgdi</sha1>
    </revision>
    <revision>
      <id>474</id>
      <parentid>473</parentid>
      <timestamp>2024-03-09T07:36:15Z</timestamp>
      <contributor>
        <username>incubator&gt;Mosakaruka</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>474</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1572" sha1="4o8avm0ucp0lvue07ja7i4ayrhmti5j" xml:space="preserve">'''[[Umlando waMandebele|AmaNdebele]]''' sitjhaba sabantu abakhuluma isiNdebele esinabantu abalinganiselwa eengidini ezimbili. Inengi lawo lihlala esifundeni seMpumalanga, kodwana amanye asabalele eemfundeni zoke zeSewula Afrika. Aziwa ngobukghwari bokugwala ephasini loke zombelele (njengombana uDorh. [[:en:Esther_Mahlangu|Esther Mahlangu]] aba livulandlela lubukghwari bokugwala bekube nje), izembatho neengubo zawo ezihle ezinemibala ekhanyako.

Abanye bacabanga bona imvelaphi yamaNdebele isemaHlubini. Lokhu kubonakala ngobufakazi belimi phakathi kwelimi lesiNdebele nesiHlubi. Kunamagama amanengana akhona esiNdebeleni akhona nelimini lesiHlubi. Ngokwesibonelo, amagama anjengokuthi, &quot;sela&quot;, &quot;fumana&quot;, &quot;ekhabo&quot;, njll, begodu womabili amalimi la ayandondoza. Okhunye okufuze kutjhejwe kukobana amaNdebele weSewula Afrika awafani namaNdebele weZimbabwe. Nanyana abosomlando baveza bona iinqhema ezimbilezi zakhe zahlangana esikhathini esithileko, kodwana umsuka wazo awufani.

=== AmaNdebele Angaphambi Kweenkhathi [[Umlando waMandebele|Zomlando]] ===
Kunabosomlando abathi amaNdebele avela emaHlubini. Kuthiwa ikosi uNdebele yasuka emaHlubini nesitjhaba sayo yayokwakha endaweni ebizwa ngokobana kuseNdolwaneni. INgwenyama uNdebele wabeletha umNtungwa owaba ngubaba wesitjhaba samaNtungwa kwaNdolwana. Ngemva kwalokho umNtungwa wabeletha uMkhalangana, okukholelwa bona angaba ngubaba wamaKhalanga ahlala eZimbabwe neMalawi.

Ngokukhamba kwesikhathi [[uMkhalangana]] wabeletha uNjonono owakhamba nesitjhaba sakhe wayokwakha endaweni eyaziwa ngokuthi kuseJononoskop. 
</text>
      <sha1>4o8avm0ucp0lvue07ja7i4ayrhmti5j</sha1>
    </revision>
    <revision>
      <id>475</id>
      <parentid>474</parentid>
      <timestamp>2024-03-09T07:37:50Z</timestamp>
      <contributor>
        <username>incubator&gt;Mosakaruka</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>475</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1643" sha1="kzjga0c9kbtfyr5270fc3p4ngsx546h" xml:space="preserve">'''[[Umlando waMandebele|AmaNdebele]]''' sitjhaba sabantu abakhuluma isiNdebele esinabantu abalinganiselwa eengidini ezimbili. Inengi lawo lihlala esifundeni seMpumalanga, kodwana amanye asabalele eemfundeni zoke zeSewula Afrika. Aziwa ngobukghwari bokugwala ephasini loke zombelele (njengombana uDorh. [[:en:Esther_Mahlangu|Esther Mahlangu]] aba livulandlela lubukghwari bokugwala bekube nje), izembatho neengubo zawo ezihle ezinemibala ekhanyako.

Abanye bacabanga bona imvelaphi yamaNdebele isemaHlubini. Lokhu kubonakala ngobufakazi belimi phakathi kwelimi lesiNdebele nesiHlubi. Kunamagama amanengana akhona esiNdebeleni akhona nelimini lesiHlubi. Ngokwesibonelo, amagama anjengokuthi, &quot;sela&quot;, &quot;fumana&quot;, &quot;ekhabo&quot;, njll, begodu womabili amalimi la ayandondoza. Okhunye okufuze kutjhejwe kukobana amaNdebele weSewula Afrika awafani namaNdebele weZimbabwe. Nanyana abosomlando baveza bona iinqhema ezimbilezi zakhe zahlangana esikhathini esithileko, kodwana umsuka wazo awufani.

=== AmaNdebele Angaphambi Kweenkhathi [[Umlando waMandebele|Zomlando]] ===
Kunabosomlando abathi amaNdebele avela emaHlubini. Kuthiwa ikosi uNdebele yasuka emaHlubini nesitjhaba sayo yayokwakha endaweni ebizwa ngokobana kuseNdolwaneni. INgwenyama uNdebele wabeletha umNtungwa owaba ngubaba wesitjhaba samaNtungwa kwaNdolwana. Ngemva kwalokho umNtungwa wabeletha uMkhalangana, okukholelwa bona angaba ngubaba wamaKhalanga ahlala eZimbabwe neMalawi.

Ngokukhamba kwesikhathi [[uMkhalangana]] wabeletha uNjonono owakhamba nesitjhaba sakhe wayokwakha endaweni eyaziwa ngokuthi kuseJononoskop. Ngokukhamba kwesikhathi uNjonono wabeletha uNanasi owabeletha uMafana. 
</text>
      <sha1>kzjga0c9kbtfyr5270fc3p4ngsx546h</sha1>
    </revision>
    <revision>
      <id>476</id>
      <parentid>475</parentid>
      <timestamp>2024-03-09T08:17:31Z</timestamp>
      <contributor>
        <username>incubator&gt;CdTshabangu</username>
        <id>0</id>
      </contributor>
      <origin>476</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1708" sha1="ep4bezulwuctrdv6ud5arnysi4a43pi" xml:space="preserve">[[Isimumathi:Esther Mahlangu in 2015.jpg|thumb|ESTHER MAHLANGU]]
'''[[Umlando waMandebele|AmaNdebele]]''' sitjhaba sabantu abakhuluma isiNdebele esinabantu abalinganiselwa eengidini ezimbili. Inengi lawo lihlala esifundeni seMpumalanga, kodwana amanye asabalele eemfundeni zoke zeSewula Afrika. Aziwa ngobukghwari bokugwala ephasini loke zombelele (njengombana uDorh. [[:en:Esther_Mahlangu|Esther Mahlangu]] aba livulandlela lubukghwari bokugwala bekube nje), izembatho neengubo zawo ezihle ezinemibala ekhanyako.

Abanye bacabanga bona imvelaphi yamaNdebele isemaHlubini. Lokhu kubonakala ngobufakazi belimi phakathi kwelimi lesiNdebele nesiHlubi. Kunamagama amanengana akhona esiNdebeleni akhona nelimini lesiHlubi. Ngokwesibonelo, amagama anjengokuthi, &quot;sela&quot;, &quot;fumana&quot;, &quot;ekhabo&quot;, njll, begodu womabili amalimi la ayandondoza. Okhunye okufuze kutjhejwe kukobana amaNdebele weSewula Afrika awafani namaNdebele weZimbabwe. Nanyana abosomlando baveza bona iinqhema ezimbilezi zakhe zahlangana esikhathini esithileko, kodwana umsuka wazo awufani.

=== AmaNdebele Angaphambi Kweenkhathi [[Umlando waMandebele|Zomlando]] ===
Kunabosomlando abathi amaNdebele avela emaHlubini. Kuthiwa ikosi uNdebele yasuka emaHlubini nesitjhaba sayo yayokwakha endaweni ebizwa ngokobana kuseNdolwaneni. INgwenyama uNdebele wabeletha umNtungwa owaba ngubaba wesitjhaba samaNtungwa kwaNdolwana. Ngemva kwalokho umNtungwa wabeletha uMkhalangana, okukholelwa bona angaba ngubaba wamaKhalanga ahlala eZimbabwe neMalawi.

Ngokukhamba kwesikhathi [[uMkhalangana]] wabeletha uNjonono owakhamba nesitjhaba sakhe wayokwakha endaweni eyaziwa ngokuthi kuseJononoskop. Ngokukhamba kwesikhathi uNjonono wabeletha uNanasi owabeletha uMafana. 
</text>
      <sha1>ep4bezulwuctrdv6ud5arnysi4a43pi</sha1>
    </revision>
    <revision>
      <id>477</id>
      <parentid>476</parentid>
      <timestamp>2024-03-09T08:25:14Z</timestamp>
      <contributor>
        <username>incubator&gt;Mosakaruka</username>
        <id>0</id>
      </contributor>
      <origin>477</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1810" sha1="bg005d8rr6tccbzimihb096clgy509h" xml:space="preserve">[[Isimumathi:Ndebele-women-loopspruit.jpg|center|frameless|843x843px|Abomma BamaNdebele ELoopspruit]]
[[Isimumathi:Esther Mahlangu in 2015.jpg|thumb|ESTHER MAHLANGU]]
'''[[Umlando waMandebele|AmaNdebele]]''' sitjhaba sabantu abakhuluma isiNdebele esinabantu abalinganiselwa eengidini ezimbili. Inengi lawo lihlala esifundeni seMpumalanga, kodwana amanye asabalele eemfundeni zoke zeSewula Afrika. Aziwa ngobukghwari bokugwala ephasini loke zombelele (njengombana uDorh. [[:en:Esther_Mahlangu|Esther Mahlangu]] aba livulandlela lubukghwari bokugwala bekube nje), izembatho neengubo zawo ezihle ezinemibala ekhanyako.

Abanye bacabanga bona imvelaphi yamaNdebele isemaHlubini. Lokhu kubonakala ngobufakazi belimi phakathi kwelimi lesiNdebele nesiHlubi. Kunamagama amanengana akhona esiNdebeleni akhona nelimini lesiHlubi. Ngokwesibonelo, amagama anjengokuthi, &quot;sela&quot;, &quot;fumana&quot;, &quot;ekhabo&quot;, njll, begodu womabili amalimi la ayandondoza. Okhunye okufuze kutjhejwe kukobana amaNdebele weSewula Afrika awafani namaNdebele weZimbabwe. Nanyana abosomlando baveza bona iinqhema ezimbilezi zakhe zahlangana esikhathini esithileko, kodwana umsuka wazo awufani.

=== AmaNdebele Angaphambi Kweenkhathi [[Umlando waMandebele|Zomlando]] ===
Kunabosomlando abathi amaNdebele avela emaHlubini. Kuthiwa ikosi uNdebele yasuka emaHlubini nesitjhaba sayo yayokwakha endaweni ebizwa ngokobana kuseNdolwaneni. INgwenyama uNdebele wabeletha umNtungwa owaba ngubaba wesitjhaba samaNtungwa kwaNdolwana. Ngemva kwalokho umNtungwa wabeletha uMkhalangana, okukholelwa bona angaba ngubaba wamaKhalanga ahlala eZimbabwe neMalawi.

Ngokukhamba kwesikhathi [[uMkhalangana]] wabeletha uNjonono owakhamba nesitjhaba sakhe wayokwakha endaweni eyaziwa ngokuthi kuseJononoskop. Ngokukhamba kwesikhathi uNjonono wabeletha uNanasi owabeletha uMafana. 
</text>
      <sha1>bg005d8rr6tccbzimihb096clgy509h</sha1>
    </revision>
    <revision>
      <id>478</id>
      <parentid>477</parentid>
      <timestamp>2024-03-09T09:38:20Z</timestamp>
      <contributor>
        <username>incubator&gt;Mosakaruka</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>478</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1810" sha1="pgmkb8ovfkbn57j0aaz1gggzfevob3g" xml:space="preserve">[[Isimumathi:Ndebele-women-loopspruit.jpg|center|frameless|732x732px|Abomma BamaNdebele ELoopspruit]]
[[Isimumathi:Esther Mahlangu in 2015.jpg|thumb|ESTHER MAHLANGU]]
'''[[Umlando waMandebele|AmaNdebele]]''' sitjhaba sabantu abakhuluma isiNdebele esinabantu abalinganiselwa eengidini ezimbili. Inengi lawo lihlala esifundeni seMpumalanga, kodwana amanye asabalele eemfundeni zoke zeSewula Afrika. Aziwa ngobukghwari bokugwala ephasini loke zombelele (njengombana uDorh. [[:en:Esther_Mahlangu|Esther Mahlangu]] aba livulandlela lubukghwari bokugwala bekube nje), izembatho neengubo zawo ezihle ezinemibala ekhanyako.

Abanye bacabanga bona imvelaphi yamaNdebele isemaHlubini. Lokhu kubonakala ngobufakazi belimi phakathi kwelimi lesiNdebele nesiHlubi. Kunamagama amanengana akhona esiNdebeleni akhona nelimini lesiHlubi. Ngokwesibonelo, amagama anjengokuthi, &quot;sela&quot;, &quot;fumana&quot;, &quot;ekhabo&quot;, njll, begodu womabili amalimi la ayandondoza. Okhunye okufuze kutjhejwe kukobana amaNdebele weSewula Afrika awafani namaNdebele weZimbabwe. Nanyana abosomlando baveza bona iinqhema ezimbilezi zakhe zahlangana esikhathini esithileko, kodwana umsuka wazo awufani.

=== AmaNdebele Angaphambi Kweenkhathi [[Umlando waMandebele|Zomlando]] ===
Kunabosomlando abathi amaNdebele avela emaHlubini. Kuthiwa ikosi uNdebele yasuka emaHlubini nesitjhaba sayo yayokwakha endaweni ebizwa ngokobana kuseNdolwaneni. INgwenyama uNdebele wabeletha umNtungwa owaba ngubaba wesitjhaba samaNtungwa kwaNdolwana. Ngemva kwalokho umNtungwa wabeletha uMkhalangana, okukholelwa bona angaba ngubaba wamaKhalanga ahlala eZimbabwe neMalawi.

Ngokukhamba kwesikhathi [[uMkhalangana]] wabeletha uNjonono owakhamba nesitjhaba sakhe wayokwakha endaweni eyaziwa ngokuthi kuseJononoskop. Ngokukhamba kwesikhathi uNjonono wabeletha uNanasi owabeletha uMafana. 
</text>
      <sha1>pgmkb8ovfkbn57j0aaz1gggzfevob3g</sha1>
    </revision>
    <revision>
      <id>479</id>
      <parentid>478</parentid>
      <timestamp>2024-03-09T09:49:39Z</timestamp>
      <contributor>
        <username>incubator&gt;Mosakaruka</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>479</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2210" sha1="1rfdb969snipkbebjbkhptb5yjaqxqf" xml:space="preserve">== AmaNdebele ==
[[Isimumathi:Ndebele-women-loopspruit.jpg|center|frameless|695x695px|Abomma BamaNdebele ELoopspruit]]
[[Isimumathi:Esther Mahlangu in 2015.jpg|thumb|ESTHER MAHLANGU]]
'''[[Umlando waMandebele|AmaNdebele]]''' sitjhaba sabantu abakhuluma isiNdebele esinabantu abalinganiselwa eengidini ezimbili. Inengi lawo lihlala esifundeni seMpumalanga, kodwana amanye asabalele eemfundeni zoke zeSewula Afrika. Aziwa ngobukghwari bokugwala ephasini loke zombelele (njengombana uDorh. [[:en:Esther_Mahlangu|Esther Mahlangu]] aba livulandlela lubukghwari bokugwala bekube nje), izembatho neengubo zawo ezihle ezinemibala ekhanyako.

Abanye bacabanga bona imvelaphi yamaNdebele isemaHlubini. Lokhu kubonakala ngobufakazi belimi phakathi kwelimi lesiNdebele nesiHlubi. Kunamagama amanengana akhona esiNdebeleni akhona nelimini lesiHlubi. Ngokwesibonelo, amagama anjengokuthi, &quot;sela&quot;, &quot;fumana&quot;, &quot;ekhabo&quot;, njll, begodu womabili amalimi la ayandondoza. Okhunye okufuze kutjhejwe kukobana amaNdebele weSewula Afrika awafani namaNdebele weZimbabwe. Nanyana abosomlando baveza bona iinqhema ezimbilezi zakhe zahlangana esikhathini esithileko, kodwana umsuka wazo awufani.

== AmaNdebele Angaphambi Kuka-1600 ==
Kunabosomlando abathi amaNdebele avela emaHlubini. Kuthiwa ikosi uNdebele yasuka emaHlubini nesitjhaba sayo yayokwakha endaweni ebizwa ngokobana kuseNdolwaneni. INgwenyama uNdebele wabeletha umNtungwa owaba ngubaba wesitjhaba samaNtungwa kwaNdolwana. Ngemva kwalokho umNtungwa wabeletha uMkhalangana, okukholelwa bona angaba ngubaba wamaKhalanga ahlala eZimbabwe neMalawi.

Ngokukhamba kwesikhathi [[uMkhalangana]] wabeletha uNjonono owakhamba nesitjhaba sakhe wayokwakha endaweni eyaziwa ngokuthi kuseJononoskop. Ngokukhamba kwesikhathi uNjonono wabeletha uNanasi owabeletha uMafana. Bese iNgwenyama uMafana abelethe iNgwenyama uMhlanga ebeletha uMusi noSikhube.  INgwenyama uMusi ibeletha amadodana namadodakazi amanengi, kodwana aziwayo nguMasobuka, uNzunza, uManala, uMthombeni, uMrhwaduba, uSibasa noDlomu. Kunabanye abathi uMusi ubeletha uTshwane, kodwana kunepikiswano ekulu mayelana nemvelaphi kaTshwane okuthiyelelwe ngaye idorobho ebelibizwa ngePitori. 

== AmaNdebele Kusukela Ku-1600 - 1880 ==
</text>
      <sha1>1rfdb969snipkbebjbkhptb5yjaqxqf</sha1>
    </revision>
    <revision>
      <id>480</id>
      <parentid>479</parentid>
      <timestamp>2024-03-09T11:47:58Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>480</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2273" sha1="33kpe7pvapta42xxilblvwufruf03jb" xml:space="preserve">== AmaNdebele ==
[[Isimumathi:Ndebele-women-loopspruit.jpg|center|frameless|695x695px|Abomma BamaNdebele ELoopspruit]]
[[Isimumathi:Esther Mahlangu in 2015.jpg|thumb|ESTHER MAHLANGU]]
'''[[Umlando waMandebele|AmaNdebele]]''' sitjhaba sabantu abakhuluma isiNdebele esinabantu abalinganiselwa eengidini ezimbili. Inengi lawo lihlala esifundeni seMpumalanga, kodwana amanye asabalele eemfundeni zoke zeSewula Afrika. Aziwa ngobukghwari bokugwala ephasini loke zombelele (njengombana uDorh. [[:en:Esther_Mahlangu|Esther Mahlangu]] aba livulandlela lubukghwari bokugwala bekube nje), izembatho neengubo zawo ezihle ezinemibala ekhanyako.

Abanye bacabanga bona imvelaphi yamaNdebele isemaHlubini. Lokhu kubonakala ngobufakazi belimi phakathi kwelimi lesiNdebele nesiHlubi. Kunamagama amanengana akhona esiNdebeleni akhona nelimini lesiHlubi. Ngokwesibonelo, amagama anjengokuthi, &quot;sela&quot;, &quot;fumana&quot;, &quot;ekhabo&quot;, njll, begodu womabili amalimi la ayandondoza. Okhunye okufuze kutjhejwe kukobana amaNdebele weSewula Afrika awafani namaNdebele weZimbabwe. Nanyana abosomlando baveza bona iinqhema ezimbilezi zakhe zahlangana esikhathini esithileko, kodwana umsuka wazo awufani.&lt;ref&gt;https://www.sahistory.org.za/article/ndebele-history&lt;/ref&gt;

== AmaNdebele Angaphambi Kuka-1600 ==
Kunabosomlando abathi amaNdebele avela emaHlubini. Kuthiwa ikosi uNdebele yasuka emaHlubini nesitjhaba sayo yayokwakha endaweni ebizwa ngokobana kuseNdolwaneni. INgwenyama uNdebele wabeletha umNtungwa owaba ngubaba wesitjhaba samaNtungwa kwaNdolwana. Ngemva kwalokho umNtungwa wabeletha uMkhalangana, okukholelwa bona angaba ngubaba wamaKhalanga ahlala eZimbabwe neMalawi.

Ngokukhamba kwesikhathi [[uMkhalangana]] wabeletha uNjonono owakhamba nesitjhaba sakhe wayokwakha endaweni eyaziwa ngokuthi kuseJononoskop. Ngokukhamba kwesikhathi uNjonono wabeletha uNanasi owabeletha uMafana. Bese iNgwenyama uMafana abelethe iNgwenyama uMhlanga ebeletha uMusi noSikhube.  INgwenyama uMusi ibeletha amadodana namadodakazi amanengi, kodwana aziwayo nguMasobuka, uNzunza, uManala, uMthombeni, uMrhwaduba, uSibasa noDlomu. Kunabanye abathi uMusi ubeletha uTshwane, kodwana kunepikiswano ekulu mayelana nemvelaphi kaTshwane okuthiyelelwe ngaye idorobho ebelibizwa ngePitori. 

== AmaNdebele Kusukela Ku-1600 - 1880 ==
</text>
      <sha1>33kpe7pvapta42xxilblvwufruf03jb</sha1>
    </revision>
    <revision>
      <id>481</id>
      <parentid>480</parentid>
      <timestamp>2024-03-10T02:58:22Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>/* AmaNdebele */</comment>
      <origin>481</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2273" sha1="ovepzi6ytixrtmse1z57lfhqiuexygx" xml:space="preserve">== AmaNdebele ==
[[Isimumathi:Ndebele-women-loopspruit.jpg|center|frameless|295x295px|Abomma BamaNdebele ELoopspruit]]
[[Isimumathi:Esther Mahlangu in 2015.jpg|thumb|ESTHER MAHLANGU]]
'''[[Umlando waMandebele|AmaNdebele]]''' sitjhaba sabantu abakhuluma isiNdebele esinabantu abalinganiselwa eengidini ezimbili. Inengi lawo lihlala esifundeni seMpumalanga, kodwana amanye asabalele eemfundeni zoke zeSewula Afrika. Aziwa ngobukghwari bokugwala ephasini loke zombelele (njengombana uDorh. [[:en:Esther_Mahlangu|Esther Mahlangu]] aba livulandlela lubukghwari bokugwala bekube nje), izembatho neengubo zawo ezihle ezinemibala ekhanyako.

Abanye bacabanga bona imvelaphi yamaNdebele isemaHlubini. Lokhu kubonakala ngobufakazi belimi phakathi kwelimi lesiNdebele nesiHlubi. Kunamagama amanengana akhona esiNdebeleni akhona nelimini lesiHlubi. Ngokwesibonelo, amagama anjengokuthi, &quot;sela&quot;, &quot;fumana&quot;, &quot;ekhabo&quot;, njll, begodu womabili amalimi la ayandondoza. Okhunye okufuze kutjhejwe kukobana amaNdebele weSewula Afrika awafani namaNdebele weZimbabwe. Nanyana abosomlando baveza bona iinqhema ezimbilezi zakhe zahlangana esikhathini esithileko, kodwana umsuka wazo awufani.&lt;ref&gt;https://www.sahistory.org.za/article/ndebele-history&lt;/ref&gt;

== AmaNdebele Angaphambi Kuka-1600 ==
Kunabosomlando abathi amaNdebele avela emaHlubini. Kuthiwa ikosi uNdebele yasuka emaHlubini nesitjhaba sayo yayokwakha endaweni ebizwa ngokobana kuseNdolwaneni. INgwenyama uNdebele wabeletha umNtungwa owaba ngubaba wesitjhaba samaNtungwa kwaNdolwana. Ngemva kwalokho umNtungwa wabeletha uMkhalangana, okukholelwa bona angaba ngubaba wamaKhalanga ahlala eZimbabwe neMalawi.

Ngokukhamba kwesikhathi [[uMkhalangana]] wabeletha uNjonono owakhamba nesitjhaba sakhe wayokwakha endaweni eyaziwa ngokuthi kuseJononoskop. Ngokukhamba kwesikhathi uNjonono wabeletha uNanasi owabeletha uMafana. Bese iNgwenyama uMafana abelethe iNgwenyama uMhlanga ebeletha uMusi noSikhube.  INgwenyama uMusi ibeletha amadodana namadodakazi amanengi, kodwana aziwayo nguMasobuka, uNzunza, uManala, uMthombeni, uMrhwaduba, uSibasa noDlomu. Kunabanye abathi uMusi ubeletha uTshwane, kodwana kunepikiswano ekulu mayelana nemvelaphi kaTshwane okuthiyelelwe ngaye idorobho ebelibizwa ngePitori. 

== AmaNdebele Kusukela Ku-1600 - 1880 ==
</text>
      <sha1>ovepzi6ytixrtmse1z57lfhqiuexygx</sha1>
    </revision>
    <revision>
      <id>482</id>
      <parentid>481</parentid>
      <timestamp>2024-03-10T02:58:46Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>482</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2272" sha1="mj75cke20nel7hccdyd2ygjq3q69to1" xml:space="preserve">== AmaNdebele ==
[[Isimumathi:Ndebele-women-loopspruit.jpg|right|frameless|295x295px|Abomma BamaNdebele ELoopspruit]]
[[Isimumathi:Esther Mahlangu in 2015.jpg|thumb|ESTHER MAHLANGU]]
'''[[Umlando waMandebele|AmaNdebele]]''' sitjhaba sabantu abakhuluma isiNdebele esinabantu abalinganiselwa eengidini ezimbili. Inengi lawo lihlala esifundeni seMpumalanga, kodwana amanye asabalele eemfundeni zoke zeSewula Afrika. Aziwa ngobukghwari bokugwala ephasini loke zombelele (njengombana uDorh. [[:en:Esther_Mahlangu|Esther Mahlangu]] aba livulandlela lubukghwari bokugwala bekube nje), izembatho neengubo zawo ezihle ezinemibala ekhanyako.

Abanye bacabanga bona imvelaphi yamaNdebele isemaHlubini. Lokhu kubonakala ngobufakazi belimi phakathi kwelimi lesiNdebele nesiHlubi. Kunamagama amanengana akhona esiNdebeleni akhona nelimini lesiHlubi. Ngokwesibonelo, amagama anjengokuthi, &quot;sela&quot;, &quot;fumana&quot;, &quot;ekhabo&quot;, njll, begodu womabili amalimi la ayandondoza. Okhunye okufuze kutjhejwe kukobana amaNdebele weSewula Afrika awafani namaNdebele weZimbabwe. Nanyana abosomlando baveza bona iinqhema ezimbilezi zakhe zahlangana esikhathini esithileko, kodwana umsuka wazo awufani.&lt;ref&gt;https://www.sahistory.org.za/article/ndebele-history&lt;/ref&gt;

== AmaNdebele Angaphambi Kuka-1600 ==
Kunabosomlando abathi amaNdebele avela emaHlubini. Kuthiwa ikosi uNdebele yasuka emaHlubini nesitjhaba sayo yayokwakha endaweni ebizwa ngokobana kuseNdolwaneni. INgwenyama uNdebele wabeletha umNtungwa owaba ngubaba wesitjhaba samaNtungwa kwaNdolwana. Ngemva kwalokho umNtungwa wabeletha uMkhalangana, okukholelwa bona angaba ngubaba wamaKhalanga ahlala eZimbabwe neMalawi.

Ngokukhamba kwesikhathi [[uMkhalangana]] wabeletha uNjonono owakhamba nesitjhaba sakhe wayokwakha endaweni eyaziwa ngokuthi kuseJononoskop. Ngokukhamba kwesikhathi uNjonono wabeletha uNanasi owabeletha uMafana. Bese iNgwenyama uMafana abelethe iNgwenyama uMhlanga ebeletha uMusi noSikhube.  INgwenyama uMusi ibeletha amadodana namadodakazi amanengi, kodwana aziwayo nguMasobuka, uNzunza, uManala, uMthombeni, uMrhwaduba, uSibasa noDlomu. Kunabanye abathi uMusi ubeletha uTshwane, kodwana kunepikiswano ekulu mayelana nemvelaphi kaTshwane okuthiyelelwe ngaye idorobho ebelibizwa ngePitori. 

== AmaNdebele Kusukela Ku-1600 - 1880 ==
</text>
      <sha1>mj75cke20nel7hccdyd2ygjq3q69to1</sha1>
    </revision>
    <revision>
      <id>483</id>
      <parentid>482</parentid>
      <timestamp>2024-03-10T02:59:49Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Adding interwiki links to [[d:Q1972827]]</comment>
      <origin>483</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2295" sha1="4ph1ihme4wholeaccqyrofsihizm9nr" xml:space="preserve">== AmaNdebele ==
[[Isimumathi:Ndebele-women-loopspruit.jpg|right|frameless|295x295px|Abomma BamaNdebele ELoopspruit]]
[[Isimumathi:Esther Mahlangu in 2015.jpg|thumb|ESTHER MAHLANGU]]
'''[[Umlando waMandebele|AmaNdebele]]''' sitjhaba sabantu abakhuluma isiNdebele esinabantu abalinganiselwa eengidini ezimbili. Inengi lawo lihlala esifundeni seMpumalanga, kodwana amanye asabalele eemfundeni zoke zeSewula Afrika. Aziwa ngobukghwari bokugwala ephasini loke zombelele (njengombana uDorh. [[:en:Esther_Mahlangu|Esther Mahlangu]] aba livulandlela lubukghwari bokugwala bekube nje), izembatho neengubo zawo ezihle ezinemibala ekhanyako.

Abanye bacabanga bona imvelaphi yamaNdebele isemaHlubini. Lokhu kubonakala ngobufakazi belimi phakathi kwelimi lesiNdebele nesiHlubi. Kunamagama amanengana akhona esiNdebeleni akhona nelimini lesiHlubi. Ngokwesibonelo, amagama anjengokuthi, &quot;sela&quot;, &quot;fumana&quot;, &quot;ekhabo&quot;, njll, begodu womabili amalimi la ayandondoza. Okhunye okufuze kutjhejwe kukobana amaNdebele weSewula Afrika awafani namaNdebele weZimbabwe. Nanyana abosomlando baveza bona iinqhema ezimbilezi zakhe zahlangana esikhathini esithileko, kodwana umsuka wazo awufani.&lt;ref&gt;https://www.sahistory.org.za/article/ndebele-history&lt;/ref&gt;

== AmaNdebele Angaphambi Kuka-1600 ==
Kunabosomlando abathi amaNdebele avela emaHlubini. Kuthiwa ikosi uNdebele yasuka emaHlubini nesitjhaba sayo yayokwakha endaweni ebizwa ngokobana kuseNdolwaneni. INgwenyama uNdebele wabeletha umNtungwa owaba ngubaba wesitjhaba samaNtungwa kwaNdolwana. Ngemva kwalokho umNtungwa wabeletha uMkhalangana, okukholelwa bona angaba ngubaba wamaKhalanga ahlala eZimbabwe neMalawi.

Ngokukhamba kwesikhathi [[uMkhalangana]] wabeletha uNjonono owakhamba nesitjhaba sakhe wayokwakha endaweni eyaziwa ngokuthi kuseJononoskop. Ngokukhamba kwesikhathi uNjonono wabeletha uNanasi owabeletha uMafana. Bese iNgwenyama uMafana abelethe iNgwenyama uMhlanga ebeletha uMusi noSikhube.  INgwenyama uMusi ibeletha amadodana namadodakazi amanengi, kodwana aziwayo nguMasobuka, uNzunza, uManala, uMthombeni, uMrhwaduba, uSibasa noDlomu. Kunabanye abathi uMusi ubeletha uTshwane, kodwana kunepikiswano ekulu mayelana nemvelaphi kaTshwane okuthiyelelwe ngaye idorobho ebelibizwa ngePitori. 

== AmaNdebele Kusukela Ku-1600 - 1880 ==

{{INTERWIKI|Q1972827}}</text>
      <sha1>4ph1ihme4wholeaccqyrofsihizm9nr</sha1>
    </revision>
    <revision>
      <id>484</id>
      <parentid>483</parentid>
      <timestamp>2024-03-10T03:01:13Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>484</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2278" sha1="6upkbfbn82hm4yxvx7qb93b6hn3ypxh" xml:space="preserve">[[Isimumathi:Ndebele-women-loopspruit.jpg|right|frameless|295x295px|Abomma BamaNdebele ELoopspruit]]
[[Isimumathi:Esther Mahlangu in 2015.jpg|thumb|ESTHER MAHLANGU]]
'''[[Umlando waMandebele|AmaNdebele]]''' sitjhaba sabantu abakhuluma isiNdebele esinabantu abalinganiselwa eengidini ezimbili. Inengi lawo lihlala esifundeni seMpumalanga, kodwana amanye asabalele eemfundeni zoke zeSewula Afrika. Aziwa ngobukghwari bokugwala ephasini loke zombelele (njengombana uDorh. [[:en:Esther_Mahlangu|Esther Mahlangu]] aba livulandlela lubukghwari bokugwala bekube nje), izembatho neengubo zawo ezihle ezinemibala ekhanyako.

Abanye bacabanga bona imvelaphi yamaNdebele isemaHlubini. Lokhu kubonakala ngobufakazi belimi phakathi kwelimi lesiNdebele nesiHlubi. Kunamagama amanengana akhona esiNdebeleni akhona nelimini lesiHlubi. Ngokwesibonelo, amagama anjengokuthi, &quot;sela&quot;, &quot;fumana&quot;, &quot;ekhabo&quot;, njll, begodu womabili amalimi la ayandondoza. Okhunye okufuze kutjhejwe kukobana amaNdebele weSewula Afrika awafani namaNdebele weZimbabwe. Nanyana abosomlando baveza bona iinqhema ezimbilezi zakhe zahlangana esikhathini esithileko, kodwana umsuka wazo awufani.&lt;ref&gt;https://www.sahistory.org.za/article/ndebele-history&lt;/ref&gt;

== AmaNdebele Angaphambi Kuka-1600 ==
Kunabosomlando abathi amaNdebele avela emaHlubini. Kuthiwa ikosi uNdebele yasuka emaHlubini nesitjhaba sayo yayokwakha endaweni ebizwa ngokobana kuseNdolwaneni. INgwenyama uNdebele wabeletha umNtungwa owaba ngubaba wesitjhaba samaNtungwa kwaNdolwana. Ngemva kwalokho umNtungwa wabeletha uMkhalangana, okukholelwa bona angaba ngubaba wamaKhalanga ahlala eZimbabwe neMalawi.

Ngokukhamba kwesikhathi [[uMkhalangana]] wabeletha uNjonono owakhamba nesitjhaba sakhe wayokwakha endaweni eyaziwa ngokuthi kuseJononoskop. Ngokukhamba kwesikhathi uNjonono wabeletha uNanasi owabeletha uMafana. Bese iNgwenyama uMafana abelethe iNgwenyama uMhlanga ebeletha uMusi noSikhube.  INgwenyama uMusi ibeletha amadodana namadodakazi amanengi, kodwana aziwayo nguMasobuka, uNzunza, uManala, uMthombeni, uMrhwaduba, uSibasa noDlomu. Kunabanye abathi uMusi ubeletha uTshwane, kodwana kunepikiswano ekulu mayelana nemvelaphi kaTshwane okuthiyelelwe ngaye idorobho ebelibizwa ngePitori. 

== AmaNdebele Kusukela Ku-1600 - 1880 ==

{{INTERWIKI|Q1972827}}</text>
      <sha1>6upkbfbn82hm4yxvx7qb93b6hn3ypxh</sha1>
    </revision>
    <revision>
      <id>485</id>
      <parentid>484</parentid>
      <timestamp>2024-03-10T03:01:46Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>485</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2254" sha1="cqjm4106zluh4y3y6y0tz8fc9lyd14a" xml:space="preserve">[[Isimumathi:Ndebele-women-loopspruit.jpg|right|frameless|295x295px|Abomma BamaNdebele ELoopspruit]]
[[Isimumathi:Esther Mahlangu in 2015.jpg|thumb|ESTHER MAHLANGU]]
'''AmaNdebele''' sitjhaba sabantu abakhuluma isiNdebele esinabantu abalinganiselwa eengidini ezimbili. Inengi lawo lihlala esifundeni seMpumalanga, kodwana amanye asabalele eemfundeni zoke zeSewula Afrika. Aziwa ngobukghwari bokugwala ephasini loke zombelele (njengombana uDorh. [[:en:Esther_Mahlangu|Esther Mahlangu]] aba livulandlela lubukghwari bokugwala bekube nje), izembatho neengubo zawo ezihle ezinemibala ekhanyako.

Abanye bacabanga bona imvelaphi yamaNdebele isemaHlubini. Lokhu kubonakala ngobufakazi belimi phakathi kwelimi lesiNdebele nesiHlubi. Kunamagama amanengana akhona esiNdebeleni akhona nelimini lesiHlubi. Ngokwesibonelo, amagama anjengokuthi, &quot;sela&quot;, &quot;fumana&quot;, &quot;ekhabo&quot;, njll, begodu womabili amalimi la ayandondoza. Okhunye okufuze kutjhejwe kukobana amaNdebele weSewula Afrika awafani namaNdebele weZimbabwe. Nanyana abosomlando baveza bona iinqhema ezimbilezi zakhe zahlangana esikhathini esithileko, kodwana umsuka wazo awufani.&lt;ref&gt;https://www.sahistory.org.za/article/ndebele-history&lt;/ref&gt;

== AmaNdebele Angaphambi Kuka-1600 ==
Kunabosomlando abathi amaNdebele avela emaHlubini. Kuthiwa ikosi uNdebele yasuka emaHlubini nesitjhaba sayo yayokwakha endaweni ebizwa ngokobana kuseNdolwaneni. INgwenyama uNdebele wabeletha umNtungwa owaba ngubaba wesitjhaba samaNtungwa kwaNdolwana. Ngemva kwalokho umNtungwa wabeletha uMkhalangana, okukholelwa bona angaba ngubaba wamaKhalanga ahlala eZimbabwe neMalawi.

Ngokukhamba kwesikhathi [[uMkhalangana]] wabeletha uNjonono owakhamba nesitjhaba sakhe wayokwakha endaweni eyaziwa ngokuthi kuseJononoskop. Ngokukhamba kwesikhathi uNjonono wabeletha uNanasi owabeletha uMafana. Bese iNgwenyama uMafana abelethe iNgwenyama uMhlanga ebeletha uMusi noSikhube.  INgwenyama uMusi ibeletha amadodana namadodakazi amanengi, kodwana aziwayo nguMasobuka, uNzunza, uManala, uMthombeni, uMrhwaduba, uSibasa noDlomu. Kunabanye abathi uMusi ubeletha uTshwane, kodwana kunepikiswano ekulu mayelana nemvelaphi kaTshwane okuthiyelelwe ngaye idorobho ebelibizwa ngePitori. 

== AmaNdebele Kusukela Ku-1600 - 1880 ==

{{INTERWIKI|Q1972827}}</text>
      <sha1>cqjm4106zluh4y3y6y0tz8fc9lyd14a</sha1>
    </revision>
    <revision>
      <id>486</id>
      <parentid>485</parentid>
      <timestamp>2024-06-27T06:01:10Z</timestamp>
      <contributor>
        <username>incubator&gt;CdTshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>486</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2360" sha1="mhhv8ck7tyvn0uqa558u411omg4248x" xml:space="preserve">[[Isimumathi:Ndebele-women-loopspruit.jpg|right|frameless|295x295px|Abomma BamaNdebele ELoopspruit]]
[[Isimumathi:Esther Mahlangu in 2015.jpg|thumb|ESTHER MAHLANGU]]
'''AmaNdebele''' sitjhaba sabantu abakhuluma isiNdebele esinabantu abalinganiselwa eengidini ezimbili. Inengi lawo lihlala esifundeni seMpumalanga, kodwana amanye asabalele eemfundeni zoke zeSewula Afrika. Aziwa ngobukghwari bokugwala ephasini loke zombelele (njengombana uDorh. [[:en:Esther_Mahlangu|Esther Mahlangu]] aba livulandlela lubukghwari bokugwala bekube nje), izembatho neengubo zawo ezihle ezinemibala ekhanyako.

Abanye bacabanga bona imvelaphi yamaNdebele isemaHlubini. Lokhu kubonakala ngobufakazi belimi phakathi kwelimi lesiNdebele nesiHlubi. Kunamagama amanengana akhona esiNdebeleni akhona nelimini lesiHlubi. Ngokwesibonelo, amagama anjengokuthi, &quot;sela&quot;, &quot;fumana&quot;, &quot;ekhabo&quot;, njll, begodu womabili amalimi la ayandondoza. Okhunye okufuze kutjhejwe kukobana amaNdebele weSewula Afrika awafani namaNdebele weZimbabwe. Nanyana abosomlando baveza bona iinqhema ezimbilezi zakhe zahlangana esikhathini esithileko, kodwana umsuka wazo awufani.&lt;ref&gt;https://www.sahistory.org.za/article/ndebele-history&lt;/ref&gt;

Izembatho zabo bazikhakhazisa ngazo begodu nomgwalo wabo ubahlukanisa kuhle mabase esitjhabeni esinye. 


== AmaNdebele Angaphambi Kuka-1600 ==
Kunabosomlando abathi amaNdebele avela emaHlubini. Kuthiwa ikosi uNdebele yasuka emaHlubini nesitjhaba sayo yayokwakha endaweni ebizwa ngokobana kuseNdolwaneni. INgwenyama uNdebele wabeletha umNtungwa owaba ngubaba wesitjhaba samaNtungwa kwaNdolwana. Ngemva kwalokho umNtungwa wabeletha uMkhalangana, okukholelwa bona angaba ngubaba wamaKhalanga ahlala eZimbabwe neMalawi.

Ngokukhamba kwesikhathi [[uMkhalangana]] wabeletha uNjonono owakhamba nesitjhaba sakhe wayokwakha endaweni eyaziwa ngokuthi kuseJononoskop. Ngokukhamba kwesikhathi uNjonono wabeletha uNanasi owabeletha uMafana. Bese iNgwenyama uMafana abelethe iNgwenyama uMhlanga ebeletha uMusi noSikhube.  INgwenyama uMusi ibeletha amadodana namadodakazi amanengi, kodwana aziwayo nguMasobuka, uNzunza, uManala, uMthombeni, uMrhwaduba, uSibasa noDlomu. Kunabanye abathi uMusi ubeletha uTshwane, kodwana kunepikiswano ekulu mayelana nemvelaphi kaTshwane okuthiyelelwe ngaye idorobho ebelibizwa ngePitori. 

== AmaNdebele Kusukela Ku-1600 - 1880 ==

{{INTERWIKI|Q1972827}}</text>
      <sha1>mhhv8ck7tyvn0uqa558u411omg4248x</sha1>
    </revision>
    <revision>
      <id>487</id>
      <parentid>486</parentid>
      <timestamp>2024-07-25T13:54:59Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>487</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2360" sha1="fqkyiapov36pqzkb8ckmq4eysiwitqs" xml:space="preserve">[[Isimumathi:Ndebele-women-loopspruit.jpg|right|frameless|295x295px|Abomma BamaNdebele ELoopspruit]]
[[Isimumathi:Esther Mahlangu in 2015.jpg|thumb|ESTHER MAHLANGU]]
'''AmaNdebele''' sitjhaba sabantu abakhuluma isiNdebele esinabantu abalinganiselwa eengidini ezimbili. Inengi lawo lihlala esifundeni seMpumalanga, kodwana amanye atjhabalele eemfundeni zoke zeSewula Afrika. Aziwa ngobukghwari bokugwala ephasini loke zombelele (njengombana uDorh. [[:en:Esther_Mahlangu|Esther Mahlangu]] aba livulandlela lubukghwari bokugwala bekube nje), izembatho neengubo zawo ezihle ezinemibala ekhanyako.

Abanye bacabanga bona imvelaphi yamaNdebele isemaHlubini. Lokhu kubonakala ngobufakazi belimi phakathi kwelimi lesiNdebele nesiHlubi. Kunamagama amanengana akhona esiNdebeleni akhona nelimini lesiHlubi. Ngokwesibonelo, amagama anjengokuthi, &quot;sela&quot;, &quot;fumana&quot;, &quot;ekhabo&quot;, njll, begodu womabili amalimi la ayandondoza. Okhunye okufuze kutjhejwe kukobana amaNdebele weSewula Afrika awafani namaNdebele weZimbabwe. Nanyana abosomlando baveza bona iinqhema ezimbilezi zakhe zahlangana esikhathini esithileko, kodwana umsuka wazo awufani.&lt;ref&gt;https://www.sahistory.org.za/article/ndebele-history&lt;/ref&gt;

Izembatho zabo bazikhakhazisa ngazo begodu nomgwalo wabo ubahlukanisa kuhle nabasesitjhabeni esinye. 


== AmaNdebele Angaphambi Kuka-1600 ==
Kunabosomlando abathi amaNdebele avela emaHlubini. Kuthiwa ikosi uNdebele yasuka emaHlubini nesitjhaba sayo yayokwakha endaweni ebizwa ngokobana kuseNdolwaneni. INgwenyama uNdebele wabeletha umNtungwa owaba ngubaba wesitjhaba samaNtungwa kwaNdolwana. Ngemva kwalokho umNtungwa wabeletha uMkhalangana, okukholelwa bona angaba ngubaba wamaKhalanga ahlala eZimbabwe neMalawi.

Ngokukhamba kwesikhathi [[uMkhalangana]] wabeletha uNjonono owakhamba nesitjhaba sakhe wayokwakha endaweni eyaziwa ngokuthi kuseJononoskop. Ngokukhamba kwesikhathi uNjonono wabeletha uNanasi owabeletha uMafana. Bese iNgwenyama uMafana abelethe iNgwenyama uMhlanga ebeletha uMusi noSikhube.  INgwenyama uMusi ibeletha amadodana namadodakazi amanengi, kodwana aziwayo nguMasobuka, uNzunza, uManala, uMthombeni, uMrhwaduba, uSibasa noDlomu. Kunabanye abathi uMusi ubeletha uTshwane, kodwana kunepikiswano ekulu mayelana nemvelaphi kaTshwane okuthiyelelwe ngaye idorobho ebelibizwa ngePitori. 

== AmaNdebele Kusukela Ku-1600 - 1880 ==

{{INTERWIKI|Q1972827}}</text>
      <sha1>fqkyiapov36pqzkb8ckmq4eysiwitqs</sha1>
    </revision>
    <revision>
      <id>488</id>
      <parentid>487</parentid>
      <timestamp>2024-10-14T13:46:31Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>21 revisions imported</comment>
      <origin>487</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2360" sha1="fqkyiapov36pqzkb8ckmq4eysiwitqs" xml:space="preserve">[[Isimumathi:Ndebele-women-loopspruit.jpg|right|frameless|295x295px|Abomma BamaNdebele ELoopspruit]]
[[Isimumathi:Esther Mahlangu in 2015.jpg|thumb|ESTHER MAHLANGU]]
'''AmaNdebele''' sitjhaba sabantu abakhuluma isiNdebele esinabantu abalinganiselwa eengidini ezimbili. Inengi lawo lihlala esifundeni seMpumalanga, kodwana amanye atjhabalele eemfundeni zoke zeSewula Afrika. Aziwa ngobukghwari bokugwala ephasini loke zombelele (njengombana uDorh. [[:en:Esther_Mahlangu|Esther Mahlangu]] aba livulandlela lubukghwari bokugwala bekube nje), izembatho neengubo zawo ezihle ezinemibala ekhanyako.

Abanye bacabanga bona imvelaphi yamaNdebele isemaHlubini. Lokhu kubonakala ngobufakazi belimi phakathi kwelimi lesiNdebele nesiHlubi. Kunamagama amanengana akhona esiNdebeleni akhona nelimini lesiHlubi. Ngokwesibonelo, amagama anjengokuthi, &quot;sela&quot;, &quot;fumana&quot;, &quot;ekhabo&quot;, njll, begodu womabili amalimi la ayandondoza. Okhunye okufuze kutjhejwe kukobana amaNdebele weSewula Afrika awafani namaNdebele weZimbabwe. Nanyana abosomlando baveza bona iinqhema ezimbilezi zakhe zahlangana esikhathini esithileko, kodwana umsuka wazo awufani.&lt;ref&gt;https://www.sahistory.org.za/article/ndebele-history&lt;/ref&gt;

Izembatho zabo bazikhakhazisa ngazo begodu nomgwalo wabo ubahlukanisa kuhle nabasesitjhabeni esinye. 


== AmaNdebele Angaphambi Kuka-1600 ==
Kunabosomlando abathi amaNdebele avela emaHlubini. Kuthiwa ikosi uNdebele yasuka emaHlubini nesitjhaba sayo yayokwakha endaweni ebizwa ngokobana kuseNdolwaneni. INgwenyama uNdebele wabeletha umNtungwa owaba ngubaba wesitjhaba samaNtungwa kwaNdolwana. Ngemva kwalokho umNtungwa wabeletha uMkhalangana, okukholelwa bona angaba ngubaba wamaKhalanga ahlala eZimbabwe neMalawi.

Ngokukhamba kwesikhathi [[uMkhalangana]] wabeletha uNjonono owakhamba nesitjhaba sakhe wayokwakha endaweni eyaziwa ngokuthi kuseJononoskop. Ngokukhamba kwesikhathi uNjonono wabeletha uNanasi owabeletha uMafana. Bese iNgwenyama uMafana abelethe iNgwenyama uMhlanga ebeletha uMusi noSikhube.  INgwenyama uMusi ibeletha amadodana namadodakazi amanengi, kodwana aziwayo nguMasobuka, uNzunza, uManala, uMthombeni, uMrhwaduba, uSibasa noDlomu. Kunabanye abathi uMusi ubeletha uTshwane, kodwana kunepikiswano ekulu mayelana nemvelaphi kaTshwane okuthiyelelwe ngaye idorobho ebelibizwa ngePitori. 

== AmaNdebele Kusukela Ku-1600 - 1880 ==

{{INTERWIKI|Q1972827}}</text>
      <sha1>fqkyiapov36pqzkb8ckmq4eysiwitqs</sha1>
    </revision>
    <revision>
      <id>1664</id>
      <parentid>488</parentid>
      <timestamp>2024-10-16T09:49:40Z</timestamp>
      <contributor>
        <username>JhsBot</username>
        <id>34</id>
      </contributor>
      <minor />
      <comment>bot: Removing interwiki template; the page is now connected to [[d:Q1972827]]</comment>
      <origin>1664</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2336" sha1="s17n5bwtot5oe1g8ro9f0eoqhb2shrk" xml:space="preserve">[[Isimumathi:Ndebele-women-loopspruit.jpg|right|frameless|295x295px|Abomma BamaNdebele ELoopspruit]]
[[Isimumathi:Esther Mahlangu in 2015.jpg|thumb|ESTHER MAHLANGU]]
'''AmaNdebele''' sitjhaba sabantu abakhuluma isiNdebele esinabantu abalinganiselwa eengidini ezimbili. Inengi lawo lihlala esifundeni seMpumalanga, kodwana amanye atjhabalele eemfundeni zoke zeSewula Afrika. Aziwa ngobukghwari bokugwala ephasini loke zombelele (njengombana uDorh. [[:en:Esther_Mahlangu|Esther Mahlangu]] aba livulandlela lubukghwari bokugwala bekube nje), izembatho neengubo zawo ezihle ezinemibala ekhanyako.

Abanye bacabanga bona imvelaphi yamaNdebele isemaHlubini. Lokhu kubonakala ngobufakazi belimi phakathi kwelimi lesiNdebele nesiHlubi. Kunamagama amanengana akhona esiNdebeleni akhona nelimini lesiHlubi. Ngokwesibonelo, amagama anjengokuthi, &quot;sela&quot;, &quot;fumana&quot;, &quot;ekhabo&quot;, njll, begodu womabili amalimi la ayandondoza. Okhunye okufuze kutjhejwe kukobana amaNdebele weSewula Afrika awafani namaNdebele weZimbabwe. Nanyana abosomlando baveza bona iinqhema ezimbilezi zakhe zahlangana esikhathini esithileko, kodwana umsuka wazo awufani.&lt;ref&gt;https://www.sahistory.org.za/article/ndebele-history&lt;/ref&gt;

Izembatho zabo bazikhakhazisa ngazo begodu nomgwalo wabo ubahlukanisa kuhle nabasesitjhabeni esinye. 


== AmaNdebele Angaphambi Kuka-1600 ==
Kunabosomlando abathi amaNdebele avela emaHlubini. Kuthiwa ikosi uNdebele yasuka emaHlubini nesitjhaba sayo yayokwakha endaweni ebizwa ngokobana kuseNdolwaneni. INgwenyama uNdebele wabeletha umNtungwa owaba ngubaba wesitjhaba samaNtungwa kwaNdolwana. Ngemva kwalokho umNtungwa wabeletha uMkhalangana, okukholelwa bona angaba ngubaba wamaKhalanga ahlala eZimbabwe neMalawi.

Ngokukhamba kwesikhathi [[uMkhalangana]] wabeletha uNjonono owakhamba nesitjhaba sakhe wayokwakha endaweni eyaziwa ngokuthi kuseJononoskop. Ngokukhamba kwesikhathi uNjonono wabeletha uNanasi owabeletha uMafana. Bese iNgwenyama uMafana abelethe iNgwenyama uMhlanga ebeletha uMusi noSikhube.  INgwenyama uMusi ibeletha amadodana namadodakazi amanengi, kodwana aziwayo nguMasobuka, uNzunza, uManala, uMthombeni, uMrhwaduba, uSibasa noDlomu. Kunabanye abathi uMusi ubeletha uTshwane, kodwana kunepikiswano ekulu mayelana nemvelaphi kaTshwane okuthiyelelwe ngaye idorobho ebelibizwa ngePitori. 

== AmaNdebele Kusukela Ku-1600 - 1880 ==</text>
      <sha1>s17n5bwtot5oe1g8ro9f0eoqhb2shrk</sha1>
    </revision>
    <revision>
      <id>1765</id>
      <parentid>1664</parentid>
      <timestamp>2024-10-29T11:27:41Z</timestamp>
      <contributor>
        <ip>88.241.74.105</ip>
      </contributor>
      <origin>1765</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2368" sha1="kyua24orpv6asa7dl3mpozz58hir9jn" xml:space="preserve">[[Isimumathi:Ndebele-women-loopspruit.jpg|right|frameless|295x295px|Abomma BamaNdebele ELoopspruit]]
[[Isimumathi:Esther Mahlangu in 2015.jpg|thumb|ESTHER MAHLANGU]]
'''AmaNdebele''' sitjhaba sabantu abakhuluma isiNdebele esinabantu abalinganiselwa eengidini ezimbili. Inengi lawo lihlala esifundeni seMpumalanga, kodwana amanye atjhabalele eemfundeni zoke zeSewula Afrika. Aziwa ngobukghwari bokugwala ephasini loke zombelele (njengombana uDorh. [[:en:Esther_Mahlangu|Esther Mahlangu]] aba livulandlela lubukghwari bokugwala bekube nje), izembatho neengubo zawo ezihle ezinemibala ekhanyako.

Abanye bacabanga bona imvelaphi yamaNdebele isemaHlubini. Lokhu kubonakala ngobufakazi belimi phakathi kwelimi lesiNdebele nesiHlubi. Kunamagama amanengana akhona esiNdebeleni akhona nelimini lesiHlubi. Ngokwesibonelo, amagama anjengokuthi, &quot;sela&quot;, &quot;fumana&quot;, &quot;ekhabo&quot;, njll, begodu womabili amalimi la ayandondoza. Okhunye okufuze kutjhejwe kukobana amaNdebele weSewula Afrika awafani namaNdebele weZimbabwe. Nanyana abosomlando baveza bona iinqhema ezimbilezi zakhe zahlangana esikhathini esithileko, kodwana umsuka wazo awufani.&lt;ref&gt;https://www.sahistory.org.za/article/ndebele-history&lt;/ref&gt;

Izembatho zabo bazikhakhazisa ngazo begodu nomgwalo wabo ubahlukanisa kuhle nabasesitjhabeni esinye. 


== AmaNdebele Angaphambi Kuka-1600 ==
Kunabosomlando abathi amaNdebele avela emaHlubini. Kuthiwa ikosi uNdebele yasuka emaHlubini nesitjhaba sayo yayokwakha endaweni ebizwa ngokobana kuseNdolwaneni. INgwenyama uNdebele wabeletha umNtungwa owaba ngubaba wesitjhaba samaNtungwa kwaNdolwana. Ngemva kwalokho umNtungwa wabeletha uMkhalangana, okukholelwa bona angaba ngubaba wamaKhalanga ahlala eZimbabwe [https://sam2spot.com sam2spot] neMalawi.

Ngokukhamba kwesikhathi [[uMkhalangana]] wabeletha uNjonono owakhamba nesitjhaba sakhe wayokwakha endaweni eyaziwa ngokuthi kuseJononoskop. Ngokukhamba kwesikhathi uNjonono wabeletha uNanasi owabeletha uMafana. Bese iNgwenyama uMafana abelethe iNgwenyama uMhlanga ebeletha uMusi noSikhube.  INgwenyama uMusi ibeletha amadodana namadodakazi amanengi, kodwana aziwayo nguMasobuka, uNzunza, uManala, uMthombeni, uMrhwaduba, uSibasa noDlomu. Kunabanye abathi uMusi ubeletha uTshwane, kodwana kunepikiswano ekulu mayelana nemvelaphi kaTshwane okuthiyelelwe ngaye idorobho ebelibizwa ngePitori. 

== AmaNdebele Kusukela Ku-1600 - 1880 ==</text>
      <sha1>kyua24orpv6asa7dl3mpozz58hir9jn</sha1>
    </revision>
    <revision>
      <id>1861</id>
      <parentid>1765</parentid>
      <timestamp>2024-11-02T18:21:01Z</timestamp>
      <contributor>
        <username>A09</username>
        <id>35</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/88.241.74.105|88.241.74.105]] ([[User talk:88.241.74.105|talk]]) to last revision by [[User:JhsBot|JhsBot]]</comment>
      <origin>1664</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2336" sha1="s17n5bwtot5oe1g8ro9f0eoqhb2shrk" xml:space="preserve">[[Isimumathi:Ndebele-women-loopspruit.jpg|right|frameless|295x295px|Abomma BamaNdebele ELoopspruit]]
[[Isimumathi:Esther Mahlangu in 2015.jpg|thumb|ESTHER MAHLANGU]]
'''AmaNdebele''' sitjhaba sabantu abakhuluma isiNdebele esinabantu abalinganiselwa eengidini ezimbili. Inengi lawo lihlala esifundeni seMpumalanga, kodwana amanye atjhabalele eemfundeni zoke zeSewula Afrika. Aziwa ngobukghwari bokugwala ephasini loke zombelele (njengombana uDorh. [[:en:Esther_Mahlangu|Esther Mahlangu]] aba livulandlela lubukghwari bokugwala bekube nje), izembatho neengubo zawo ezihle ezinemibala ekhanyako.

Abanye bacabanga bona imvelaphi yamaNdebele isemaHlubini. Lokhu kubonakala ngobufakazi belimi phakathi kwelimi lesiNdebele nesiHlubi. Kunamagama amanengana akhona esiNdebeleni akhona nelimini lesiHlubi. Ngokwesibonelo, amagama anjengokuthi, &quot;sela&quot;, &quot;fumana&quot;, &quot;ekhabo&quot;, njll, begodu womabili amalimi la ayandondoza. Okhunye okufuze kutjhejwe kukobana amaNdebele weSewula Afrika awafani namaNdebele weZimbabwe. Nanyana abosomlando baveza bona iinqhema ezimbilezi zakhe zahlangana esikhathini esithileko, kodwana umsuka wazo awufani.&lt;ref&gt;https://www.sahistory.org.za/article/ndebele-history&lt;/ref&gt;

Izembatho zabo bazikhakhazisa ngazo begodu nomgwalo wabo ubahlukanisa kuhle nabasesitjhabeni esinye. 


== AmaNdebele Angaphambi Kuka-1600 ==
Kunabosomlando abathi amaNdebele avela emaHlubini. Kuthiwa ikosi uNdebele yasuka emaHlubini nesitjhaba sayo yayokwakha endaweni ebizwa ngokobana kuseNdolwaneni. INgwenyama uNdebele wabeletha umNtungwa owaba ngubaba wesitjhaba samaNtungwa kwaNdolwana. Ngemva kwalokho umNtungwa wabeletha uMkhalangana, okukholelwa bona angaba ngubaba wamaKhalanga ahlala eZimbabwe neMalawi.

Ngokukhamba kwesikhathi [[uMkhalangana]] wabeletha uNjonono owakhamba nesitjhaba sakhe wayokwakha endaweni eyaziwa ngokuthi kuseJononoskop. Ngokukhamba kwesikhathi uNjonono wabeletha uNanasi owabeletha uMafana. Bese iNgwenyama uMafana abelethe iNgwenyama uMhlanga ebeletha uMusi noSikhube.  INgwenyama uMusi ibeletha amadodana namadodakazi amanengi, kodwana aziwayo nguMasobuka, uNzunza, uManala, uMthombeni, uMrhwaduba, uSibasa noDlomu. Kunabanye abathi uMusi ubeletha uTshwane, kodwana kunepikiswano ekulu mayelana nemvelaphi kaTshwane okuthiyelelwe ngaye idorobho ebelibizwa ngePitori. 

== AmaNdebele Kusukela Ku-1600 - 1880 ==</text>
      <sha1>s17n5bwtot5oe1g8ro9f0eoqhb2shrk</sha1>
    </revision>
    <revision>
      <id>1870</id>
      <parentid>1861</parentid>
      <timestamp>2024-11-08T06:08:19Z</timestamp>
      <contributor>
        <ip>88.241.74.255</ip>
      </contributor>
      <origin>1870</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2383" sha1="48x2araxdar6k0ia6g8qb3a0okjkdbu" xml:space="preserve">[[Isimumathi:Ndebele-women-loopspruit.jpg|right|frameless|295x295px|Abomma BamaNdebele ELoopspruit]]
[[Isimumathi:Esther Mahlangu in 2015.jpg|thumb|ESTHER MAHLANGU]]
'''AmaNdebele''' sitjhaba sabantu abakhuluma isiNdebele esinabantu abalinganiselwa eengidini ezimbili. Inengi lawo lihlala esifundeni seMpumalanga, kodwana amanye atjhabalele eemfundeni zoke zeSewula Afrika. Aziwa ngobukghwari bokugwala ephasini loke zombelele (njengombana uDorh. [[:en:Esther_Mahlangu|Esther Mahlangu]] aba livulandlela lubukghwari bokugwala bekube nje), izembatho neengubo zawo ezihle ezinemibala ekhanyako.

Abanye bacabanga bona imvelaphi yamaNdebele isemaHlubini. Lokhu kubonakala ngobufakazi belimi phakathi kwelimi lesiNdebele nesiHlubi. Kunamagama amanengana akhona esiNdebeleni akhona nelimini lesiHlubi. Ngokwesibonelo, amagama anjengokuthi, &quot;sela&quot;, &quot;fumana&quot;, &quot;ekhabo&quot;, njll, begodu womabili amalimi la ayandondoza. Okhunye okufuze kutjhejwe kukobana amaNdebele weSewula Afrika awafani namaNdebele weZimbabwe. Nanyana abosomlando baveza bona iinqhema ezimbilezi zakhe zahlangana esikhathini esithileko, kodwana umsuka wazo awufani.&lt;ref&gt;https://www.sahistory.org.za/article/ndebele-history&lt;/ref&gt;

Izembatho zabo bazikhakhazisa ngazo begodu nomgwalo wabo ubahlukanisa kuhle nabasesitjhabeni esinye. 


== AmaNdebele Angaphambi Kuka-1600 ==
Kunabosomlando abathi amaNdebele avela emaHlubini. Kuthiwa ikosi uNdebele yasuka emaHlubini nesitjhaba sayo yayokwakha endaweni ebizwa ngokobana kuseNdolwaneni. INgwenyama uNdebele wabeletha umNtungwa owaba ngubaba wesitjhaba samaNtungwa kwaNdolwana. Ngemva kwalokho [https://blumenpflegen.com/ blumenpflegen.com] umNtungwa wabeletha uMkhalangana, okukholelwa bona angaba ngubaba wamaKhalanga ahlala eZimbabwe neMalawi.

Ngokukhamba kwesikhathi [[uMkhalangana]] wabeletha uNjonono owakhamba nesitjhaba sakhe wayokwakha endaweni eyaziwa ngokuthi kuseJononoskop. Ngokukhamba kwesikhathi uNjonono wabeletha uNanasi owabeletha uMafana. Bese iNgwenyama uMafana abelethe iNgwenyama uMhlanga ebeletha uMusi noSikhube.  INgwenyama uMusi ibeletha amadodana namadodakazi amanengi, kodwana aziwayo nguMasobuka, uNzunza, uManala, uMthombeni, uMrhwaduba, uSibasa noDlomu. Kunabanye abathi uMusi ubeletha uTshwane, kodwana kunepikiswano ekulu mayelana nemvelaphi kaTshwane okuthiyelelwe ngaye idorobho ebelibizwa ngePitori. 

== AmaNdebele Kusukela Ku-1600 - 1880 ==</text>
      <sha1>48x2araxdar6k0ia6g8qb3a0okjkdbu</sha1>
    </revision>
    <revision>
      <id>2170</id>
      <parentid>1870</parentid>
      <timestamp>2024-11-27T06:33:37Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>UEsther Mahlangu ngo-2015</comment>
      <origin>2170</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2392" sha1="j9hm8vrxrramj1nztchqmpbzc6o77uv" xml:space="preserve">[[Isimumathi:Ndebele-women-loopspruit.jpg|right|frameless|295x295px|Abomma BamaNdebele ELoopspruit]]
[[Isimumathi:Esther Mahlangu in 2015.jpg|thumb|UEsther Mahlangu ngo-2015]]
'''AmaNdebele''' sitjhaba sabantu abakhuluma isiNdebele esinabantu abalinganiselwa eengidini ezimbili. Inengi lawo lihlala esifundeni seMpumalanga, kodwana amanye atjhabalele eemfundeni zoke zeSewula Afrika. Aziwa ngobukghwari bokugwala ephasini loke zombelele (njengombana uDorh. [[:en:Esther_Mahlangu|Esther Mahlangu]] aba livulandlela lubukghwari bokugwala bekube nje), izembatho neengubo zawo ezihle ezinemibala ekhanyako.

Abanye bacabanga bona imvelaphi yamaNdebele isemaHlubini. Lokhu kubonakala ngobufakazi belimi phakathi kwelimi lesiNdebele nesiHlubi. Kunamagama amanengana akhona esiNdebeleni akhona nelimini lesiHlubi. Ngokwesibonelo, amagama anjengokuthi, &quot;sela&quot;, &quot;fumana&quot;, &quot;ekhabo&quot;, njll, begodu womabili amalimi la ayandondoza. Okhunye okufuze kutjhejwe kukobana amaNdebele weSewula Afrika awafani namaNdebele weZimbabwe. Nanyana abosomlando baveza bona iinqhema ezimbilezi zakhe zahlangana esikhathini esithileko, kodwana umsuka wazo awufani.&lt;ref&gt;https://www.sahistory.org.za/article/ndebele-history&lt;/ref&gt;

Izembatho zabo bazikhakhazisa ngazo begodu nomgwalo wabo ubahlukanisa kuhle nabasesitjhabeni esinye. 

== AmaNdebele Angaphambi Kuka-1600 ==
Kunabosomlando abathi amaNdebele avela emaHlubini. Kuthiwa ikosi uNdebele yasuka emaHlubini nesitjhaba sayo yayokwakha endaweni ebizwa ngokobana kuseNdolwaneni. INgwenyama uNdebele wabeletha umNtungwa owaba ngubaba wesitjhaba samaNtungwa kwaNdolwana. Ngemva kwalokho [https://blumenpflegen.com/ blumenpflegen.com] umNtungwa wabeletha uMkhalangana, okukholelwa bona angaba ngubaba wamaKhalanga ahlala eZimbabwe neMalawi.

Ngokukhamba kwesikhathi [[uMkhalangana]] wabeletha uNjonono owakhamba nesitjhaba sakhe wayokwakha endaweni eyaziwa ngokuthi kuseJononoskop. Ngokukhamba kwesikhathi uNjonono wabeletha uNanasi owabeletha uMafana. Bese iNgwenyama uMafana abelethe iNgwenyama uMhlanga ebeletha uMusi noSikhube.  INgwenyama uMusi ibeletha amadodana namadodakazi amanengi, kodwana aziwayo nguMasobuka, uNzunza, uManala, uMthombeni, uMrhwaduba, uSibasa noDlomu. Kunabanye abathi uMusi ubeletha uTshwane, kodwana kunepikiswano ekulu mayelana nemvelaphi kaTshwane okuthiyelelwe ngaye idorobho ebelibizwa ngePitori. 

== AmaNdebele Kusukela Ku-1600 - 1880 ==</text>
      <sha1>j9hm8vrxrramj1nztchqmpbzc6o77uv</sha1>
    </revision>
    <revision>
      <id>2171</id>
      <parentid>2170</parentid>
      <timestamp>2024-11-27T06:33:58Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>+ Iinkomba</comment>
      <origin>2171</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2420" sha1="6fd695wvux47lhhx99y7b536bun63np" xml:space="preserve">[[Isimumathi:Ndebele-women-loopspruit.jpg|right|frameless|295x295px|Abomma BamaNdebele ELoopspruit]]
[[Isimumathi:Esther Mahlangu in 2015.jpg|thumb|UEsther Mahlangu ngo-2015]]
'''AmaNdebele''' sitjhaba sabantu abakhuluma isiNdebele esinabantu abalinganiselwa eengidini ezimbili. Inengi lawo lihlala esifundeni seMpumalanga, kodwana amanye atjhabalele eemfundeni zoke zeSewula Afrika. Aziwa ngobukghwari bokugwala ephasini loke zombelele (njengombana uDorh. [[:en:Esther_Mahlangu|Esther Mahlangu]] aba livulandlela lubukghwari bokugwala bekube nje), izembatho neengubo zawo ezihle ezinemibala ekhanyako.

Abanye bacabanga bona imvelaphi yamaNdebele isemaHlubini. Lokhu kubonakala ngobufakazi belimi phakathi kwelimi lesiNdebele nesiHlubi. Kunamagama amanengana akhona esiNdebeleni akhona nelimini lesiHlubi. Ngokwesibonelo, amagama anjengokuthi, &quot;sela&quot;, &quot;fumana&quot;, &quot;ekhabo&quot;, njll, begodu womabili amalimi la ayandondoza. Okhunye okufuze kutjhejwe kukobana amaNdebele weSewula Afrika awafani namaNdebele weZimbabwe. Nanyana abosomlando baveza bona iinqhema ezimbilezi zakhe zahlangana esikhathini esithileko, kodwana umsuka wazo awufani.&lt;ref&gt;https://www.sahistory.org.za/article/ndebele-history&lt;/ref&gt;

Izembatho zabo bazikhakhazisa ngazo begodu nomgwalo wabo ubahlukanisa kuhle nabasesitjhabeni esinye. 

== AmaNdebele Angaphambi Kuka-1600 ==
Kunabosomlando abathi amaNdebele avela emaHlubini. Kuthiwa ikosi uNdebele yasuka emaHlubini nesitjhaba sayo yayokwakha endaweni ebizwa ngokobana kuseNdolwaneni. INgwenyama uNdebele wabeletha umNtungwa owaba ngubaba wesitjhaba samaNtungwa kwaNdolwana. Ngemva kwalokho [https://blumenpflegen.com/ blumenpflegen.com] umNtungwa wabeletha uMkhalangana, okukholelwa bona angaba ngubaba wamaKhalanga ahlala eZimbabwe neMalawi.

Ngokukhamba kwesikhathi [[uMkhalangana]] wabeletha uNjonono owakhamba nesitjhaba sakhe wayokwakha endaweni eyaziwa ngokuthi kuseJononoskop. Ngokukhamba kwesikhathi uNjonono wabeletha uNanasi owabeletha uMafana. Bese iNgwenyama uMafana abelethe iNgwenyama uMhlanga ebeletha uMusi noSikhube.  INgwenyama uMusi ibeletha amadodana namadodakazi amanengi, kodwana aziwayo nguMasobuka, uNzunza, uManala, uMthombeni, uMrhwaduba, uSibasa noDlomu. Kunabanye abathi uMusi ubeletha uTshwane, kodwana kunepikiswano ekulu mayelana nemvelaphi kaTshwane okuthiyelelwe ngaye idorobho ebelibizwa ngePitori. 

== AmaNdebele Kusukela Ku-1600 - 1880 ==

== Iinkomba ==
{{Reflist}}</text>
      <sha1>6fd695wvux47lhhx99y7b536bun63np</sha1>
    </revision>
    <revision>
      <id>2228</id>
      <parentid>2171</parentid>
      <timestamp>2024-12-01T08:15:56Z</timestamp>
      <contributor>
        <ip>88.241.77.117</ip>
      </contributor>
      <origin>2228</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2413" sha1="jx4sw7tal58vcjl6zxw8a3vgp2m3pbj" xml:space="preserve">[[Isimumathi:Ndebele-women-loopspruit.jpg|right|frameless|295x295px|Abomma BamaNdebele ELoopspruit]]
[[Isimumathi:Esther Mahlangu in 2015.jpg|thumb|UEsther Mahlangu ngo-2015]]
'''AmaNdebele''' sitjhaba sabantu abakhuluma isiNdebele esinabantu abalinganiselwa eengidini ezimbili. Inengi lawo lihlala esifundeni seMpumalanga, kodwana amanye atjhabalele eemfundeni zoke zeSewula Afrika. Aziwa ngobukghwari bokugwala ephasini loke zombelele (njengombana uDorh. [[:en:Esther_Mahlangu|Esther Mahlangu]] aba livulandlela lubukghwari bokugwala bekube nje), izembatho neengubo zawo ezihle ezinemibala ekhanyako.

Abanye bacabanga bona imvelaphi yamaNdebele isemaHlubini. Lokhu kubonakala ngobufakazi belimi phakathi kwelimi lesiNdebele nesiHlubi. Kunamagama amanengana akhona esiNdebeleni akhona nelimini lesiHlubi. Ngokwesibonelo, amagama anjengokuthi, &quot;sela&quot;, &quot;fumana&quot;, &quot;ekhabo&quot;, njll, begodu womabili amalimi la ayandondoza. Okhunye okufuze kutjhejwe kukobana amaNdebele weSewula Afrika awafani namaNdebele weZimbabwe. Nanyana abosomlando baveza bona iinqhema ezimbilezi zakhe zahlangana esikhathini esithileko, kodwana umsuka wazo awufani.&lt;ref&gt;https://www.sahistory.org.za/article/ndebele-history&lt;/ref&gt;

Izembatho zabo bazikhakhazisa ngazo begodu nomgwalo wabo ubahlukanisa kuhle nabasesitjhabeni esinye. 

== AmaNdebele Angaphambi Kuka-1600 ==
Kunabosomlando abathi amaNdebele avela emaHlubini. Kuthiwa ikosi uNdebele yasuka emaHlubini nesitjhaba sayo yayokwakha endaweni ebizwa ngokobana kuseNdolwaneni. INgwenyama uNdebele wabeletha umNtungwa owaba ngubaba wesitjhaba samaNtungwa kwaNdolwana. Ngemva kwalokho [https://1kompozisyon.com/ kompozisyon] umNtungwa wabeletha uMkhalangana, okukholelwa bona angaba ngubaba wamaKhalanga ahlala eZimbabwe neMalawi.

Ngokukhamba kwesikhathi [[uMkhalangana]] wabeletha uNjonono owakhamba nesitjhaba sakhe wayokwakha endaweni eyaziwa ngokuthi kuseJononoskop. Ngokukhamba kwesikhathi uNjonono wabeletha uNanasi owabeletha uMafana. Bese iNgwenyama uMafana abelethe iNgwenyama uMhlanga ebeletha uMusi noSikhube.  INgwenyama uMusi ibeletha amadodana namadodakazi amanengi, kodwana aziwayo nguMasobuka, uNzunza, uManala, uMthombeni, uMrhwaduba, uSibasa noDlomu. Kunabanye abathi uMusi ubeletha uTshwane, kodwana kunepikiswano ekulu mayelana nemvelaphi kaTshwane okuthiyelelwe ngaye idorobho ebelibizwa ngePitori. 

== AmaNdebele Kusukela Ku-1600 - 1880 ==

== Iinkomba ==
{{Reflist}}</text>
      <sha1>jx4sw7tal58vcjl6zxw8a3vgp2m3pbj</sha1>
    </revision>
    <revision>
      <id>2884</id>
      <parentid>2228</parentid>
      <timestamp>2025-06-01T19:51:04Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>/* AmaNdebele Angaphambi Kuka-1600 */ spelling</comment>
      <origin>2884</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2372" sha1="ib0u84p45h4jfnt68q2p4rmrvjwr4gx" xml:space="preserve">[[Isimumathi:Ndebele-women-loopspruit.jpg|right|frameless|295x295px|Abomma BamaNdebele ELoopspruit]]
[[Isimumathi:Esther Mahlangu in 2015.jpg|thumb|UEsther Mahlangu ngo-2015]]
'''AmaNdebele''' sitjhaba sabantu abakhuluma isiNdebele esinabantu abalinganiselwa eengidini ezimbili. Inengi lawo lihlala esifundeni seMpumalanga, kodwana amanye atjhabalele eemfundeni zoke zeSewula Afrika. Aziwa ngobukghwari bokugwala ephasini loke zombelele (njengombana uDorh. [[:en:Esther_Mahlangu|Esther Mahlangu]] aba livulandlela lubukghwari bokugwala bekube nje), izembatho neengubo zawo ezihle ezinemibala ekhanyako.

Abanye bacabanga bona imvelaphi yamaNdebele isemaHlubini. Lokhu kubonakala ngobufakazi belimi phakathi kwelimi lesiNdebele nesiHlubi. Kunamagama amanengana akhona esiNdebeleni akhona nelimini lesiHlubi. Ngokwesibonelo, amagama anjengokuthi, &quot;sela&quot;, &quot;fumana&quot;, &quot;ekhabo&quot;, njll, begodu womabili amalimi la ayandondoza. Okhunye okufuze kutjhejwe kukobana amaNdebele weSewula Afrika awafani namaNdebele weZimbabwe. Nanyana abosomlando baveza bona iinqhema ezimbilezi zakhe zahlangana esikhathini esithileko, kodwana umsuka wazo awufani.&lt;ref&gt;https://www.sahistory.org.za/article/ndebele-history&lt;/ref&gt;

Izembatho zabo bazikhakhazisa ngazo begodu nomgwalo wabo ubahlukanisa kuhle nabasesitjhabeni esinye. 

== AmaNdebele Angaphambi Kuka-1600 ==
Kunabosomlando abathi amaNdebele avela emaHlubini. Kuthiwa ikosi uNdebele yasuka emaHlubini nesitjhaba sayo yayokwakha endaweni ebizwa ngokobana kuseNdolwaneni. INgwenyama uNdebele wabeletha umNtungwa owaba ngubaba wesitjhaba samaNtungwa kwaNdolwana. Ngemva kwalokho umNtungwa wabeletha uMkhalangana, okukholelwa bona angaba ngubaba wamaKhalanga ahlala eZimbabwe neMalawi.

Ngokukhamba kwesikhathi [[uMkhalangana]] wabeletha uNjonono owakhamba nesitjhaba sakhe wayokwakha endaweni eyaziwa ngokuthi kuseJononoskop. Ngokukhamba kwesikhathi uNjonono wabeletha uNanasi owabeletha uMafana. Bese iNgwenyama uMafana abelethe iNgwenyama uMhlanga ebeletha uMusi noSikhube.  INgwenyama uMusi ibeletha amadodana namadodakazi amanengi, kodwana aziwayo nguMasobuka, uNzunza, uManala, uMthombeni, uMrhwaduba, uSibasa noDlomu. Kunabanye abathi uMusi ubeletha uTshwane, kodwana kunepikiswano ekulu mayelana nemvelaphi kaTshwane okuthiyelelwe ngaye idorobho ebelibizwa ngePitori.

== AmaNdebele Kusukela Ku-1600 - 1880 ==

== Iinkomba ==
{{Reflist}}</text>
      <sha1>ib0u84p45h4jfnt68q2p4rmrvjwr4gx</sha1>
    </revision>
    <revision>
      <id>3007</id>
      <parentid>2884</parentid>
      <timestamp>2025-06-06T20:22:22Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>hjcdhedj</comment>
      <origin>3007</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2453" sha1="puam23yfeoz1s8wxxk5faquy5jj2m2d" xml:space="preserve">[[Isimumathi:Ndebele-women-loopspruit.jpg|right|frameless|295x295px|Abomma BamaNdebele ELoopspruit]]
[[Isimumathi:Esther Mahlangu in 2015.jpg|thumb|UEsther Mahlangu ngo-2015]]
'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. AmaNdebele''' sitjhaba sabantu abakhuluma isiNdebele esinabantu abalinganiselwa eengidini ezimbili. Inengi lawo lihlala esifundeni seMpumalanga, kodwana amanye atjhabalele eemfundeni zoke zeSewula Afrika. Aziwa ngobukghwari bokugwala ephasini loke zombelele (njengombana uDorh. [[:en:Esther_Mahlangu|Esther Mahlangu]] aba livulandlela lubukghwari bokugwala bekube nje), izembatho neengubo zawo ezihle ezinemibala ekhanyako.

Abanye bacabanga bona imvelaphi yamaNdebele isemaHlubini. Lokhu kubonakala ngobufakazi belimi phakathi kwelimi lesiNdebele nesiHlubi. Kunamagama amanengana akhona esiNdebeleni akhona nelimini lesiHlubi. Ngokwesibonelo, amagama anjengokuthi, &quot;sela&quot;, &quot;fumana&quot;, &quot;ekhabo&quot;, njll, begodu womabili amalimi la ayandondoza. Okhunye okufuze kutjhejwe kukobana amaNdebele weSewula Afrika awafani namaNdebele weZimbabwe. Nanyana abosomlando baveza bona iinqhema ezimbilezi zakhe zahlangana esikhathini esithileko, kodwana umsuka wazo awufani.&lt;ref&gt;https://www.sahistory.org.za/article/ndebele-history&lt;/ref&gt;

Izembatho zabo bazikhakhazisa ngazo begodu nomgwalo wabo ubahlukanisa kuhle nabasesitjhabeni esinye. 

== AmaNdebele Angaphambi Kuka-1600 ==
Kunabosomlando abathi amaNdebele avela emaHlubini. Kuthiwa ikosi uNdebele yasuka emaHlubini nesitjhaba sayo yayokwakha endaweni ebizwa ngokobana kuseNdolwaneni. INgwenyama uNdebele wabeletha umNtungwa owaba ngubaba wesitjhaba samaNtungwa kwaNdolwana. Ngemva kwalokho umNtungwa wabeletha uMkhalangana, okukholelwa bona angaba ngubaba wamaKhalanga ahlala eZimbabwe neMalawi.

Ngokukhamba kwesikhathi [[uMkhalangana]] wabeletha uNjonono owakhamba nesitjhaba sakhe wayokwakha endaweni eyaziwa ngokuthi kuseJononoskop. Ngokukhamba kwesikhathi uNjonono wabeletha uNanasi owabeletha uMafana. Bese iNgwenyama uMafana abelethe iNgwenyama uMhlanga ebeletha uMusi noSikhube.  INgwenyama uMusi ibeletha amadodana namadodakazi amanengi, kodwana aziwayo nguMasobuka, uNzunza, uManala, uMthombeni, uMrhwaduba, uSibasa noDlomu. Kunabanye abathi uMusi ubeletha uTshwane, kodwana kunepikiswano ekulu mayelana nemvelaphi kaTshwane okuthiyelelwe ngaye idorobho ebelibizwa ngePitori.

== AmaNdebele Kusukela Ku-1600 - 1880 ==

== Iinkomba ==
{{Reflist}}</text>
      <sha1>puam23yfeoz1s8wxxk5faquy5jj2m2d</sha1>
    </revision>
    <revision>
      <id>3062</id>
      <parentid>3007</parentid>
      <timestamp>2025-06-07T03:05:22Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Mosakaruka|Mosakaruka]]</comment>
      <origin>2884</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2372" sha1="ib0u84p45h4jfnt68q2p4rmrvjwr4gx" xml:space="preserve">[[Isimumathi:Ndebele-women-loopspruit.jpg|right|frameless|295x295px|Abomma BamaNdebele ELoopspruit]]
[[Isimumathi:Esther Mahlangu in 2015.jpg|thumb|UEsther Mahlangu ngo-2015]]
'''AmaNdebele''' sitjhaba sabantu abakhuluma isiNdebele esinabantu abalinganiselwa eengidini ezimbili. Inengi lawo lihlala esifundeni seMpumalanga, kodwana amanye atjhabalele eemfundeni zoke zeSewula Afrika. Aziwa ngobukghwari bokugwala ephasini loke zombelele (njengombana uDorh. [[:en:Esther_Mahlangu|Esther Mahlangu]] aba livulandlela lubukghwari bokugwala bekube nje), izembatho neengubo zawo ezihle ezinemibala ekhanyako.

Abanye bacabanga bona imvelaphi yamaNdebele isemaHlubini. Lokhu kubonakala ngobufakazi belimi phakathi kwelimi lesiNdebele nesiHlubi. Kunamagama amanengana akhona esiNdebeleni akhona nelimini lesiHlubi. Ngokwesibonelo, amagama anjengokuthi, &quot;sela&quot;, &quot;fumana&quot;, &quot;ekhabo&quot;, njll, begodu womabili amalimi la ayandondoza. Okhunye okufuze kutjhejwe kukobana amaNdebele weSewula Afrika awafani namaNdebele weZimbabwe. Nanyana abosomlando baveza bona iinqhema ezimbilezi zakhe zahlangana esikhathini esithileko, kodwana umsuka wazo awufani.&lt;ref&gt;https://www.sahistory.org.za/article/ndebele-history&lt;/ref&gt;

Izembatho zabo bazikhakhazisa ngazo begodu nomgwalo wabo ubahlukanisa kuhle nabasesitjhabeni esinye. 

== AmaNdebele Angaphambi Kuka-1600 ==
Kunabosomlando abathi amaNdebele avela emaHlubini. Kuthiwa ikosi uNdebele yasuka emaHlubini nesitjhaba sayo yayokwakha endaweni ebizwa ngokobana kuseNdolwaneni. INgwenyama uNdebele wabeletha umNtungwa owaba ngubaba wesitjhaba samaNtungwa kwaNdolwana. Ngemva kwalokho umNtungwa wabeletha uMkhalangana, okukholelwa bona angaba ngubaba wamaKhalanga ahlala eZimbabwe neMalawi.

Ngokukhamba kwesikhathi [[uMkhalangana]] wabeletha uNjonono owakhamba nesitjhaba sakhe wayokwakha endaweni eyaziwa ngokuthi kuseJononoskop. Ngokukhamba kwesikhathi uNjonono wabeletha uNanasi owabeletha uMafana. Bese iNgwenyama uMafana abelethe iNgwenyama uMhlanga ebeletha uMusi noSikhube.  INgwenyama uMusi ibeletha amadodana namadodakazi amanengi, kodwana aziwayo nguMasobuka, uNzunza, uManala, uMthombeni, uMrhwaduba, uSibasa noDlomu. Kunabanye abathi uMusi ubeletha uTshwane, kodwana kunepikiswano ekulu mayelana nemvelaphi kaTshwane okuthiyelelwe ngaye idorobho ebelibizwa ngePitori.

== AmaNdebele Kusukela Ku-1600 - 1880 ==

== Iinkomba ==
{{Reflist}}</text>
      <sha1>ib0u84p45h4jfnt68q2p4rmrvjwr4gx</sha1>
    </revision>
    <revision>
      <id>6687</id>
      <parentid>3062</parentid>
      <timestamp>2026-06-12T07:18:17Z</timestamp>
      <contributor>
        <username>MissHadassah</username>
        <id>1561</id>
      </contributor>
      <minor />
      <comment>/* AmaNdebele Angaphambi Kuka-1600 */ linked pages</comment>
      <origin>6687</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2416" sha1="5wl3l0uhm8hd99833ze7cpuotapon5k" xml:space="preserve">[[Isimumathi:Ndebele-women-loopspruit.jpg|right|frameless|295x295px|Abomma BamaNdebele ELoopspruit]]
[[Isimumathi:Esther Mahlangu in 2015.jpg|thumb|UEsther Mahlangu ngo-2015]]
'''AmaNdebele''' sitjhaba sabantu abakhuluma isiNdebele esinabantu abalinganiselwa eengidini ezimbili. Inengi lawo lihlala esifundeni seMpumalanga, kodwana amanye atjhabalele eemfundeni zoke zeSewula Afrika. Aziwa ngobukghwari bokugwala ephasini loke zombelele (njengombana uDorh. [[:en:Esther_Mahlangu|Esther Mahlangu]] aba livulandlela lubukghwari bokugwala bekube nje), izembatho neengubo zawo ezihle ezinemibala ekhanyako.

Abanye bacabanga bona imvelaphi yamaNdebele isemaHlubini. Lokhu kubonakala ngobufakazi belimi phakathi kwelimi lesiNdebele nesiHlubi. Kunamagama amanengana akhona esiNdebeleni akhona nelimini lesiHlubi. Ngokwesibonelo, amagama anjengokuthi, &quot;sela&quot;, &quot;fumana&quot;, &quot;ekhabo&quot;, njll, begodu womabili amalimi la ayandondoza. Okhunye okufuze kutjhejwe kukobana amaNdebele weSewula Afrika awafani namaNdebele weZimbabwe. Nanyana abosomlando baveza bona iinqhema ezimbilezi zakhe zahlangana esikhathini esithileko, kodwana umsuka wazo awufani.&lt;ref&gt;https://www.sahistory.org.za/article/ndebele-history&lt;/ref&gt;

Izembatho zabo bazikhakhazisa ngazo begodu nomgwalo wabo ubahlukanisa kuhle nabasesitjhabeni esinye. 

== AmaNdebele Angaphambi Kuka-1600 ==
Kunabosomlando abathi amaNdebele avela emaHlubini. Kuthiwa ikosi uNdebele yasuka emaHlubini nesitjhaba sayo yayokwakha endaweni ebizwa ngokobana kuseNdolwaneni. INgwenyama uNdebele wabeletha umNtungwa owaba ngubaba wesitjhaba samaNtungwa kwaNdolwana. Ngemva kwalokho umNtungwa wabeletha uMkhalangana, okukholelwa bona angaba ngubaba wamaKhalanga ahlala eZimbabwe neMalawi.

Ngokukhamba kwesikhathi [[uMkhalangana]] wabeletha uNjonono owakhamba nesitjhaba sakhe wayokwakha endaweni eyaziwa ngokuthi kuseJononoskop. Ngokukhamba kwesikhathi uNjonono wabeletha uNanasi owabeletha uMafana. Bese iNgwenyama uMafana abelethe iNgwenyama uMhlanga ebeletha uMusi noSikhube.  INgwenyama uMusi ibeletha amadodana namadodakazi amanengi, kodwana aziwayo nguMasobuka, [[UNzunza no Manala|uNzunza]], [[UNzunza no Manala|uManala]], uMthombeni, uMrhwaduba, uSibasa noDlomu. Kunabanye abathi uMusi ubeletha uTshwane, kodwana kunepikiswano ekulu mayelana nemvelaphi kaTshwane okuthiyelelwe ngaye idorobho ebelibizwa ngePitori.

== AmaNdebele Kusukela Ku-1600 - 1880 ==

== Iinkomba ==
{{Reflist}}</text>
      <sha1>5wl3l0uhm8hd99833ze7cpuotapon5k</sha1>
    </revision>
  </page>
  <page>
    <title>Amalungelo Wobuntu</title>
    <ns>0</ns>
    <id>114</id>
    <revision>
      <id>489</id>
      <timestamp>2016-02-24T17:35:21Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;{{Document| | ibizo = Amalungelo Wobuntu | isithombe = RSA-Constitution.png | Unyaka wokutlola = 1996  | Indawo yo kutlolwa = Johannesburg | Inarha yomtlolo =  Isewula A...&quot;</comment>
      <origin>489</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="177" sha1="38o0d8o0ggkeeexwgt0bz8y6ixewhd2" xml:space="preserve">{{Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| Unyaka wokutlola = 1996 
| Indawo yo kutlolwa = Johannesburg
| Inarha yomtlolo =  Isewula Afrika
}}</text>
      <sha1>38o0d8o0ggkeeexwgt0bz8y6ixewhd2</sha1>
    </revision>
    <revision>
      <id>490</id>
      <parentid>489</parentid>
      <timestamp>2016-02-24T17:35:53Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>490</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="186" sha1="bxd9sa2a64lf1vhkifh6etzrlngj7h3" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| Unyaka wokutlola = 1996 
| Indawo yo kutlolwa = Johannesburg
| Inarha yomtlolo =  Isewula Afrika
}}</text>
      <sha1>bxd9sa2a64lf1vhkifh6etzrlngj7h3</sha1>
    </revision>
    <revision>
      <id>491</id>
      <parentid>490</parentid>
      <timestamp>2016-02-24T18:01:17Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>491</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="433" sha1="oganj78j6ijel6z26u66njpaquh9sj1" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| Unyaka wokutlola = 1996 
| Indawo yo kutlolwa = Johannesburg
| Inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo wenarha ye Sewula Afrika. Kuna malungelo wobuntu amaatjhumi amabili nekhomba kumthethosisekelo begodu ahlathjulula indlela bona amalungelo la aberega ngayo.</text>
      <sha1>oganj78j6ijel6z26u66njpaquh9sj1</sha1>
    </revision>
    <revision>
      <id>492</id>
      <parentid>491</parentid>
      <timestamp>2016-02-24T18:02:29Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>492</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="447" sha1="dsnc8c4q6nl72jle2v4yyc3qlbfnuiz" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| Unyaka wokutlola = 1996 
| Indawo yo kutlolwa = Johannesburg
| Inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo wenarha ye Sewula Afrika begodu isihloko le sihlathjulula indlela bona amalungelo la aberega ngayo. Kuna malungelo wobuntu amaatjhumi amabili nekhomba kumthethosisekelo .</text>
      <sha1>dsnc8c4q6nl72jle2v4yyc3qlbfnuiz</sha1>
    </revision>
    <revision>
      <id>493</id>
      <parentid>492</parentid>
      <timestamp>2016-02-24T18:32:43Z</timestamp>
      <contributor>
        <username>incubator&gt;Katxis</username>
        <id>0</id>
      </contributor>
      <origin>493</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="447" sha1="e12ftx9exzmunu3191i8024jvrvpo4u" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo wenarha ye Sewula Afrika begodu isihloko le sihlathjulula indlela bona amalungelo la aberega ngayo. Kuna malungelo wobuntu amaatjhumi amabili nekhomba kumthethosisekelo .</text>
      <sha1>e12ftx9exzmunu3191i8024jvrvpo4u</sha1>
    </revision>
    <revision>
      <id>494</id>
      <parentid>493</parentid>
      <timestamp>2016-02-24T19:39:37Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>494</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="453" sha1="565ft1s45g47bsit4bhhgslm93c3o1h" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo wenarha ye Sewula Afrika begodu isihloko le sihlathjulula indlela bona amalungelo la aberega ngayo. Kuna malungelo wobuntu amaatjhumi amabili nekhomba kumthethosisekelo. 


</text>
      <sha1>565ft1s45g47bsit4bhhgslm93c3o1h</sha1>
    </revision>
    <revision>
      <id>495</id>
      <parentid>494</parentid>
      <timestamp>2016-02-24T20:06:04Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Added headings</comment>
      <origin>495</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1928" sha1="ok1wc2qvwsamffc72vhrf5lkf1llvhl" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo wenarha ye Sewula Afrika begodu isihloko le sihlathjulula indlela bona amalungelo la aberega ngayo namcana angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amaatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;

==Ukulingana==


==Isithunzi sabantu==


==Ipilo==


==Itjhaphuluko nokuPhepha komuntu==


==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==


==Ukuba wedwa==


== Itjhaphuluko yekolo, yekolelo neyombono==


== Ukuvuza imibono ngokutjhaphuluka==


==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==


==Ilungelo lokuHlangana==


==Amalungelo wezepolotiki==


==Ubakhamuzi==


==Itjhaphuluko lokuKhamba nelokuHlala==


==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==


==Itjhebiswano kezemisebenzi==


==Ibhoduluko==


==Ipahla==


==Izindlu==


==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==


==Abantwana==


==Ifundo==


==Ilimi nesiko==


==Imiphakathi yamaSiko, yeKolo nemaLimi==


==Ukufumana ilwazi==


==Ukuphatha ngokusemthethweni==


==Ukungena emaKhotho==


==Abantu ababotjhiweko nabathweswe umlandu==


==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>ok1wc2qvwsamffc72vhrf5lkf1llvhl</sha1>
    </revision>
    <revision>
      <id>496</id>
      <parentid>495</parentid>
      <timestamp>2016-02-24T20:08:48Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Ukulingana */</comment>
      <origin>496</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2108" sha1="l1vkl0nkeyhedj5urbidhwsp52sv6gu" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo wenarha ye Sewula Afrika begodu isihloko le sihlathjulula indlela bona amalungelo la aberega ngayo namcana angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amaatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe.

 Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.

==Isithunzi sabantu==


==Ipilo==


==Itjhaphuluko nokuPhepha komuntu==


==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==


==Ukuba wedwa==


== Itjhaphuluko yekolo, yekolelo neyombono==


== Ukuvuza imibono ngokutjhaphuluka==


==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==


==Ilungelo lokuHlangana==


==Amalungelo wezepolotiki==


==Ubakhamuzi==


==Itjhaphuluko lokuKhamba nelokuHlala==


==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==


==Itjhebiswano kezemisebenzi==


==Ibhoduluko==


==Ipahla==


==Izindlu==


==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==


==Abantwana==


==Ifundo==


==Ilimi nesiko==


==Imiphakathi yamaSiko, yeKolo nemaLimi==


==Ukufumana ilwazi==


==Ukuphatha ngokusemthethweni==


==Ukungena emaKhotho==


==Abantu ababotjhiweko nabathweswe umlandu==


==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>l1vkl0nkeyhedj5urbidhwsp52sv6gu</sha1>
    </revision>
    <revision>
      <id>497</id>
      <parentid>496</parentid>
      <timestamp>2016-02-24T20:10:16Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Isithunzi sabantu */</comment>
      <origin>497</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2234" sha1="hgrwevhh2zvq69nzp4ovccixj0aviug" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo wenarha ye Sewula Afrika begodu isihloko le sihlathjulula indlela bona amalungelo la aberega ngayo namcana angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amaatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe.

 Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe.

 Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.

==Ipilo==


==Itjhaphuluko nokuPhepha komuntu==


==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==


==Ukuba wedwa==


== Itjhaphuluko yekolo, yekolelo neyombono==


== Ukuvuza imibono ngokutjhaphuluka==


==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==


==Ilungelo lokuHlangana==


==Amalungelo wezepolotiki==


==Ubakhamuzi==


==Itjhaphuluko lokuKhamba nelokuHlala==


==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==


==Itjhebiswano kezemisebenzi==


==Ibhoduluko==


==Ipahla==


==Izindlu==


==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==


==Abantwana==


==Ifundo==


==Ilimi nesiko==


==Imiphakathi yamaSiko, yeKolo nemaLimi==


==Ukufumana ilwazi==


==Ukuphatha ngokusemthethweni==


==Ukungena emaKhotho==


==Abantu ababotjhiweko nabathweswe umlandu==


==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>hgrwevhh2zvq69nzp4ovccixj0aviug</sha1>
    </revision>
    <revision>
      <id>498</id>
      <parentid>497</parentid>
      <timestamp>2016-02-24T20:11:06Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Ipilo */</comment>
      <origin>498</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2286" sha1="fs0a6fnmjshozpiroe0rg8hjww20cm1" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo wenarha ye Sewula Afrika begodu isihloko le sihlathjulula indlela bona amalungelo la aberega ngayo namcana angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amaatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe.

 Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe.

 Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.

==Ipilo==
Unelungelo lepilo.

 Boke abantu banelungelo lepilo.

==Itjhaphuluko nokuPhepha komuntu==


==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==


==Ukuba wedwa==


== Itjhaphuluko yekolo, yekolelo neyombono==


== Ukuvuza imibono ngokutjhaphuluka==


==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==


==Ilungelo lokuHlangana==


==Amalungelo wezepolotiki==


==Ubakhamuzi==


==Itjhaphuluko lokuKhamba nelokuHlala==


==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==


==Itjhebiswano kezemisebenzi==


==Ibhoduluko==


==Ipahla==


==Izindlu==


==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==


==Abantwana==


==Ifundo==


==Ilimi nesiko==


==Imiphakathi yamaSiko, yeKolo nemaLimi==


==Ukufumana ilwazi==


==Ukuphatha ngokusemthethweni==


==Ukungena emaKhotho==


==Abantu ababotjhiweko nabathweswe umlandu==


==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>fs0a6fnmjshozpiroe0rg8hjww20cm1</sha1>
    </revision>
    <revision>
      <id>499</id>
      <parentid>498</parentid>
      <timestamp>2016-02-24T20:12:21Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Itjhaphuluko nokuPhepha komuntu */</comment>
      <origin>499</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2490" sha1="c7orudtn5oig1n7jwi4o5maxpofgywn" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo wenarha ye Sewula Afrika begodu isihloko le sihlathjulula indlela bona amalungelo la aberega ngayo namcana angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amaatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe.

 Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe.

 Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.

==Ipilo==
Unelungelo lepilo.

 Boke abantu banelungelo lepilo.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejiziswa kumbi. Ukutlhoriswa kwemakhaya akukavunyelwa.

 Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa ngananyana ngiyiphi indlela.

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==


==Ukuba wedwa==


== Itjhaphuluko yekolo, yekolelo neyombono==


== Ukuvuza imibono ngokutjhaphuluka==


==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==


==Ilungelo lokuHlangana==


==Amalungelo wezepolotiki==


==Ubakhamuzi==


==Itjhaphuluko lokuKhamba nelokuHlala==


==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==


==Itjhebiswano kezemisebenzi==


==Ibhoduluko==


==Ipahla==


==Izindlu==


==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==


==Abantwana==


==Ifundo==


==Ilimi nesiko==


==Imiphakathi yamaSiko, yeKolo nemaLimi==


==Ukufumana ilwazi==


==Ukuphatha ngokusemthethweni==


==Ukungena emaKhotho==


==Abantu ababotjhiweko nabathweswe umlandu==


==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>c7orudtn5oig1n7jwi4o5maxpofgywn</sha1>
    </revision>
    <revision>
      <id>500</id>
      <parentid>499</parentid>
      <timestamp>2016-02-24T20:13:27Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako */</comment>
      <origin>500</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2596" sha1="he7ysmomocueoi9ox5ow385w8vn1en4" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo wenarha ye Sewula Afrika begodu isihloko le sihlathjulula indlela bona amalungelo la aberega ngayo namcana angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amaatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe.

 Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe.

 Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.

==Ipilo==
Unelungelo lepilo.

 Boke abantu banelungelo lepilo.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejiziswa kumbi. Ukutlhoriswa kwemakhaya akukavunyelwa.

 Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa ngananyana ngiyiphi indlela.

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa.

 Akakafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.

==Ukuba wedwa==


== Itjhaphuluko yekolo, yekolelo neyombono==


== Ukuvuza imibono ngokutjhaphuluka==


==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==


==Ilungelo lokuHlangana==


==Amalungelo wezepolotiki==


==Ubakhamuzi==


==Itjhaphuluko lokuKhamba nelokuHlala==


==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==


==Itjhebiswano kezemisebenzi==


==Ibhoduluko==


==Ipahla==


==Izindlu==


==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==


==Abantwana==


==Ifundo==


==Ilimi nesiko==


==Imiphakathi yamaSiko, yeKolo nemaLimi==


==Ukufumana ilwazi==


==Ukuphatha ngokusemthethweni==


==Ukungena emaKhotho==


==Abantu ababotjhiweko nabathweswe umlandu==


==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>he7ysmomocueoi9ox5ow385w8vn1en4</sha1>
    </revision>
    <revision>
      <id>501</id>
      <parentid>500</parentid>
      <timestamp>2016-02-24T20:14:34Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Ukuba wedwa */</comment>
      <origin>501</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2729" sha1="jwcte5blupvc1lxxkamxq0izhmy85yk" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo wenarha ye Sewula Afrika begodu isihloko le sihlathjulula indlela bona amalungelo la aberega ngayo namcana angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amaatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe.

 Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe.

 Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.

==Ipilo==
Unelungelo lepilo.

 Boke abantu banelungelo lepilo.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejiziswa kumbi. Ukutlhoriswa kwemakhaya akukavunyelwa.

 Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa ngananyana ngiyiphi indlela.

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa.

 Akakafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa.

 Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.

== Itjhaphuluko yekolo, yekolelo neyombono==


== Ukuvuza imibono ngokutjhaphuluka==


==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==


==Ilungelo lokuHlangana==


==Amalungelo wezepolotiki==


==Ubakhamuzi==


==Itjhaphuluko lokuKhamba nelokuHlala==


==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==


==Itjhebiswano kezemisebenzi==


==Ibhoduluko==


==Ipahla==


==Izindlu==


==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==


==Abantwana==


==Ifundo==


==Ilimi nesiko==


==Imiphakathi yamaSiko, yeKolo nemaLimi==


==Ukufumana ilwazi==


==Ukuphatha ngokusemthethweni==


==Ukungena emaKhotho==


==Abantu ababotjhiweko nabathweswe umlandu==


==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>jwcte5blupvc1lxxkamxq0izhmy85yk</sha1>
    </revision>
    <revision>
      <id>502</id>
      <parentid>501</parentid>
      <timestamp>2016-02-24T20:15:33Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Itjhaphuluko yekolo, yekolelo neyombono */</comment>
      <origin>502</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2895" sha1="t4mvq22xwwceyxfdx7fw2cqx8fcvyt6" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo wenarha ye Sewula Afrika begodu isihloko le sihlathjulula indlela bona amalungelo la aberega ngayo namcana angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amaatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe.

 Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe.

 Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.

==Ipilo==
Unelungelo lepilo.

 Boke abantu banelungelo lepilo.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejiziswa kumbi. Ukutlhoriswa kwemakhaya akukavunyelwa.

 Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa ngananyana ngiyiphi indlela.

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa.

 Akakafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa.

 Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako.

 Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.

== Ukuvuza imibono ngokutjhaphuluka==


==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==


==Ilungelo lokuHlangana==


==Amalungelo wezepolotiki==


==Ubakhamuzi==


==Itjhaphuluko lokuKhamba nelokuHlala==


==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==


==Itjhebiswano kezemisebenzi==


==Ibhoduluko==


==Ipahla==


==Izindlu==


==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==


==Abantwana==


==Ifundo==


==Ilimi nesiko==


==Imiphakathi yamaSiko, yeKolo nemaLimi==


==Ukufumana ilwazi==


==Ukuphatha ngokusemthethweni==


==Ukungena emaKhotho==


==Abantu ababotjhiweko nabathweswe umlandu==


==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>t4mvq22xwwceyxfdx7fw2cqx8fcvyt6</sha1>
    </revision>
    <revision>
      <id>503</id>
      <parentid>502</parentid>
      <timestamp>2016-02-24T20:16:47Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Ukuvuza imibono ngokutjhaphuluka */</comment>
      <origin>503</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3076" sha1="ck1hlflvp5ol30vz8v0w2ifqzs3v3ui" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo wenarha ye Sewula Afrika begodu isihloko le sihlathjulula indlela bona amalungelo la aberega ngayo namcana angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amaatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe.

 Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe.

 Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.

==Ipilo==
Unelungelo lepilo.

 Boke abantu banelungelo lepilo.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejiziswa kumbi. Ukutlhoriswa kwemakhaya akukavunyelwa.

 Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa ngananyana ngiyiphi indlela.

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa.

 Akakafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa.

 Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako.

 Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.

== Ukuvuza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako.

 Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yenzondo ayikavunyelwa.

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==


==Ilungelo lokuHlangana==


==Amalungelo wezepolotiki==


==Ubakhamuzi==


==Itjhaphuluko lokuKhamba nelokuHlala==


==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==


==Itjhebiswano kezemisebenzi==


==Ibhoduluko==


==Ipahla==


==Izindlu==


==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==


==Abantwana==


==Ifundo==


==Ilimi nesiko==


==Imiphakathi yamaSiko, yeKolo nemaLimi==


==Ukufumana ilwazi==


==Ukuphatha ngokusemthethweni==


==Ukungena emaKhotho==


==Abantu ababotjhiweko nabathweswe umlandu==


==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>ck1hlflvp5ol30vz8v0w2ifqzs3v3ui</sha1>
    </revision>
    <revision>
      <id>504</id>
      <parentid>503</parentid>
      <timestamp>2016-02-24T20:17:44Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo */</comment>
      <origin>504</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3257" sha1="tmchommpqo9jnc13k97tos8l83me7w5" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo wenarha ye Sewula Afrika begodu isihloko le sihlathjulula indlela bona amalungelo la aberega ngayo namcana angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amaatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe.

 Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe.

 Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.

==Ipilo==
Unelungelo lepilo.

 Boke abantu banelungelo lepilo.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejiziswa kumbi. Ukutlhoriswa kwemakhaya akukavunyelwa.

 Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa ngananyana ngiyiphi indlela.

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa.

 Akakafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa.

 Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako.

 Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.

== Ukuvuza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako.

 Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yenzondo ayikavunyelwa.

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula.

 Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.

==Ilungelo lokuHlangana==


==Amalungelo wezepolotiki==


==Ubakhamuzi==


==Itjhaphuluko lokuKhamba nelokuHlala==


==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==


==Itjhebiswano kezemisebenzi==


==Ibhoduluko==


==Ipahla==


==Izindlu==


==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==


==Abantwana==


==Ifundo==


==Ilimi nesiko==


==Imiphakathi yamaSiko, yeKolo nemaLimi==


==Ukufumana ilwazi==


==Ukuphatha ngokusemthethweni==


==Ukungena emaKhotho==


==Abantu ababotjhiweko nabathweswe umlandu==


==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>tmchommpqo9jnc13k97tos8l83me7w5</sha1>
    </revision>
    <revision>
      <id>505</id>
      <parentid>504</parentid>
      <timestamp>2016-02-24T20:18:28Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Ilungelo lokuHlangana */</comment>
      <origin>505</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3342" sha1="7zafcskvkkjfwn82sk8lb9l9hrxng9l" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo wenarha ye Sewula Afrika begodu isihloko le sihlathjulula indlela bona amalungelo la aberega ngayo namcana angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amaatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe.

 Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe.

 Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.

==Ipilo==
Unelungelo lepilo.

 Boke abantu banelungelo lepilo.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejiziswa kumbi. Ukutlhoriswa kwemakhaya akukavunyelwa.

 Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa ngananyana ngiyiphi indlela.

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa.

 Akakafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa.

 Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako.

 Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.

== Ukuvuza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako.

 Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yenzondo ayikavunyelwa.

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula.

 Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako.

 Unelungelo lokuhlangana nananyana ngubani.

==Amalungelo wezepolotiki==


==Ubakhamuzi==


==Itjhaphuluko lokuKhamba nelokuHlala==


==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==


==Itjhebiswano kezemisebenzi==


==Ibhoduluko==


==Ipahla==


==Izindlu==


==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==


==Abantwana==


==Ifundo==


==Ilimi nesiko==


==Imiphakathi yamaSiko, yeKolo nemaLimi==


==Ukufumana ilwazi==


==Ukuphatha ngokusemthethweni==


==Ukungena emaKhotho==


==Abantu ababotjhiweko nabathweswe umlandu==


==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>7zafcskvkkjfwn82sk8lb9l9hrxng9l</sha1>
    </revision>
    <revision>
      <id>506</id>
      <parentid>505</parentid>
      <timestamp>2016-02-24T20:19:42Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Amalungelo wezepolotiki */</comment>
      <origin>506</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3600" sha1="je24piza9605tulb91j86jf1096b4s4" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo wenarha ye Sewula Afrika begodu isihloko le sihlathjulula indlela bona amalungelo la aberega ngayo namcana angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amaatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe.

 Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe.

 Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.

==Ipilo==
Unelungelo lepilo.

 Boke abantu banelungelo lepilo.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejiziswa kumbi. Ukutlhoriswa kwemakhaya akukavunyelwa.

 Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa ngananyana ngiyiphi indlela.

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa.

 Akakafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa.

 Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako.

 Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.

== Ukuvuza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako.

 Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yenzondo ayikavunyelwa.

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula.

 Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako.

 Unelungelo lokuhlangana nananyana ngubani.

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda.

 Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhetweni atjhaphulukileko nangasolisiko.

==Ubakhamuzi==


==Itjhaphuluko lokuKhamba nelokuHlala==


==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==


==Itjhebiswano kezemisebenzi==


==Ibhoduluko==


==Ipahla==


==Izindlu==


==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==


==Abantwana==


==Ifundo==


==Ilimi nesiko==


==Imiphakathi yamaSiko, yeKolo nemaLimi==


==Ukufumana ilwazi==


==Ukuphatha ngokusemthethweni==


==Ukungena emaKhotho==


==Abantu ababotjhiweko nabathweswe umlandu==


==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>je24piza9605tulb91j86jf1096b4s4</sha1>
    </revision>
    <revision>
      <id>507</id>
      <parentid>506</parentid>
      <timestamp>2016-02-24T20:20:29Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Ubakhamuzi */</comment>
      <origin>507</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3693" sha1="fb6amygxv7scq6cps9b6ipmyjjjd7xp" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo wenarha ye Sewula Afrika begodu isihloko le sihlathjulula indlela bona amalungelo la aberega ngayo namcana angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amaatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe.

 Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe.

 Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.

==Ipilo==
Unelungelo lepilo.

 Boke abantu banelungelo lepilo.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejiziswa kumbi. Ukutlhoriswa kwemakhaya akukavunyelwa.

 Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa ngananyana ngiyiphi indlela.

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa.

 Akakafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa.

 Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako.

 Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.

== Ukuvuza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako.

 Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yenzondo ayikavunyelwa.

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula.

 Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako.

 Unelungelo lokuhlangana nananyana ngubani.

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda.

 Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhetweni atjhaphulukileko nangasolisiko.

==Ubakhamuzi==
Ubakhamuzi bakho ngeze basuswa kuwe.

 Asikho isakhamuzi ekufuze sithathelwe ubakhamuzi baso.

==Itjhaphuluko lokuKhamba nelokuHlala==


==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==


==Itjhebiswano kezemisebenzi==


==Ibhoduluko==


==Ipahla==


==Izindlu==


==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==


==Abantwana==


==Ifundo==


==Ilimi nesiko==


==Imiphakathi yamaSiko, yeKolo nemaLimi==


==Ukufumana ilwazi==


==Ukuphatha ngokusemthethweni==


==Ukungena emaKhotho==


==Abantu ababotjhiweko nabathweswe umlandu==


==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>fb6amygxv7scq6cps9b6ipmyjjjd7xp</sha1>
    </revision>
    <revision>
      <id>508</id>
      <parentid>507</parentid>
      <timestamp>2016-02-24T20:21:14Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Itjhaphuluko lokuKhamba nelokuHlala */</comment>
      <origin>508</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3821" sha1="8t6r8l3od18zd7gylyhymnxt8h32bu9" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo wenarha ye Sewula Afrika begodu isihloko le sihlathjulula indlela bona amalungelo la aberega ngayo namcana angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amaatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe.

 Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe.

 Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.

==Ipilo==
Unelungelo lepilo.

 Boke abantu banelungelo lepilo.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejiziswa kumbi. Ukutlhoriswa kwemakhaya akukavunyelwa.

 Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa ngananyana ngiyiphi indlela.

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa.

 Akakafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa.

 Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako.

 Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.

== Ukuvuza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako.

 Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yenzondo ayikavunyelwa.

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula.

 Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako.

 Unelungelo lokuhlangana nananyana ngubani.

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda.

 Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhetweni atjhaphulukileko nangasolisiko.

==Ubakhamuzi==
Ubakhamuzi bakho ngeze basuswa kuwe.

 Asikho isakhamuzi ekufuze sithathelwe ubakhamuzi baso.

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanyana kukuphi eRiphabhliki yeSewula Afrika.

 Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==


==Itjhebiswano kezemisebenzi==


==Ibhoduluko==


==Ipahla==


==Izindlu==


==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==


==Abantwana==


==Ifundo==


==Ilimi nesiko==


==Imiphakathi yamaSiko, yeKolo nemaLimi==


==Ukufumana ilwazi==


==Ukuphatha ngokusemthethweni==


==Ukungena emaKhotho==


==Abantu ababotjhiweko nabathweswe umlandu==


==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>8t6r8l3od18zd7gylyhymnxt8h32bu9</sha1>
    </revision>
    <revision>
      <id>509</id>
      <parentid>508</parentid>
      <timestamp>2016-02-24T20:22:21Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Itjhaphuluko yokuRhweba, yomSebenzi neBizelo */</comment>
      <origin>509</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3963" sha1="492lvg7m5b6uhoym4wn4pc54k9fnx1y" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo wenarha ye Sewula Afrika begodu isihloko le sihlathjulula indlela bona amalungelo la aberega ngayo namcana angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amaatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe.

 Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe.

 Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.

==Ipilo==
Unelungelo lepilo.

 Boke abantu banelungelo lepilo.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejiziswa kumbi. Ukutlhoriswa kwemakhaya akukavunyelwa.

 Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa ngananyana ngiyiphi indlela.

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa.

 Akakafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa.

 Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako.

 Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.

== Ukuvuza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako.

 Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yenzondo ayikavunyelwa.

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula.

 Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako.

 Unelungelo lokuhlangana nananyana ngubani.

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda.

 Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhetweni atjhaphulukileko nangasolisiko.

==Ubakhamuzi==
Ubakhamuzi bakho ngeze basuswa kuwe.

 Asikho isakhamuzi ekufuze sithathelwe ubakhamuzi baso.

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanyana kukuphi eRiphabhliki yeSewula Afrika.

 Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako.

 Unelungel lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.

==Itjhebiswano kezemisebenzi==


==Ibhoduluko==


==Ipahla==


==Izindlu==


==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==


==Abantwana==


==Ifundo==


==Ilimi nesiko==


==Imiphakathi yamaSiko, yeKolo nemaLimi==


==Ukufumana ilwazi==


==Ukuphatha ngokusemthethweni==


==Ukungena emaKhotho==


==Abantu ababotjhiweko nabathweswe umlandu==


==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>492lvg7m5b6uhoym4wn4pc54k9fnx1y</sha1>
    </revision>
    <revision>
      <id>510</id>
      <parentid>509</parentid>
      <timestamp>2016-02-24T20:23:42Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Itjhebiswano kezemisebenzi */</comment>
      <origin>510</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4097" sha1="5hxo4ty8ri9rw8tz94g9uj700p9ep72" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo wenarha ye Sewula Afrika begodu isihloko le sihlathjulula indlela bona amalungelo la aberega ngayo namcana angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amaatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe.

 Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe.

 Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.

==Ipilo==
Unelungelo lepilo.

 Boke abantu banelungelo lepilo.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejiziswa kumbi. Ukutlhoriswa kwemakhaya akukavunyelwa.

 Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa ngananyana ngiyiphi indlela.

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa.

 Akakafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa.

 Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako.

 Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.

== Ukuvuza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako.

 Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yenzondo ayikavunyelwa.

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula.

 Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako.

 Unelungelo lokuhlangana nananyana ngubani.

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda.

 Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhetweni atjhaphulukileko nangasolisiko.

==Ubakhamuzi==
Ubakhamuzi bakho ngeze basuswa kuwe.

 Asikho isakhamuzi ekufuze sithathelwe ubakhamuzi baso.

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanyana kukuphi eRiphabhliki yeSewula Afrika.

 Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako.

 Unelungel lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.

==Itjhebiswano kezemisebenzi==
Ungajoyina amayuniyoni bewutoyitoye 

 Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana kuphumelelisa iminqopho yabo.

==Ibhoduluko==


==Ipahla==


==Izindlu==


==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==


==Abantwana==


==Ifundo==


==Ilimi nesiko==


==Imiphakathi yamaSiko, yeKolo nemaLimi==


==Ukufumana ilwazi==


==Ukuphatha ngokusemthethweni==


==Ukungena emaKhotho==


==Abantu ababotjhiweko nabathweswe umlandu==


==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>5hxo4ty8ri9rw8tz94g9uj700p9ep72</sha1>
    </revision>
    <revision>
      <id>511</id>
      <parentid>510</parentid>
      <timestamp>2016-02-24T20:24:48Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Ibhoduluko */</comment>
      <origin>511</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4195" sha1="sasmsdl67e8673in0tj3m6n794zdzhd" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo wenarha ye Sewula Afrika begodu isihloko le sihlathjulula indlela bona amalungelo la aberega ngayo namcana angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amaatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe.

 Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe.

 Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.

==Ipilo==
Unelungelo lepilo.

 Boke abantu banelungelo lepilo.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejiziswa kumbi. Ukutlhoriswa kwemakhaya akukavunyelwa.

 Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa ngananyana ngiyiphi indlela.

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa.

 Akakafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa.

 Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako.

 Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.

== Ukuvuza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako.

 Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yenzondo ayikavunyelwa.

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula.

 Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako.

 Unelungelo lokuhlangana nananyana ngubani.

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda.

 Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhetweni atjhaphulukileko nangasolisiko.

==Ubakhamuzi==
Ubakhamuzi bakho ngeze basuswa kuwe.

 Asikho isakhamuzi ekufuze sithathelwe ubakhamuzi baso.

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanyana kukuphi eRiphabhliki yeSewula Afrika.

 Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako.

 Unelungel lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.

==Itjhebiswano kezemisebenzi==
Ungajoyina amayuniyoni bewutoyitoye 

 Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana kuphumelelisa iminqopho yabo.

==Ibhoduluko==
Unelungelo lebhoduluko elinepilo.

 Unelungelo lokuhlala ebhodulukweni elivikelekileko nelinepilo.

==Ipahla==


==Izindlu==


==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==


==Abantwana==


==Ifundo==


==Ilimi nesiko==


==Imiphakathi yamaSiko, yeKolo nemaLimi==


==Ukufumana ilwazi==


==Ukuphatha ngokusemthethweni==


==Ukungena emaKhotho==


==Abantu ababotjhiweko nabathweswe umlandu==


==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>sasmsdl67e8673in0tj3m6n794zdzhd</sha1>
    </revision>
    <revision>
      <id>512</id>
      <parentid>511</parentid>
      <timestamp>2016-02-24T20:25:45Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Ipahla */</comment>
      <origin>512</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4349" sha1="oisan1ur0iwtcjjsm0tbcobopq2v0z3" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo wenarha ye Sewula Afrika begodu isihloko le sihlathjulula indlela bona amalungelo la aberega ngayo namcana angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amaatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe.

 Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe.

 Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.

==Ipilo==
Unelungelo lepilo.

 Boke abantu banelungelo lepilo.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejiziswa kumbi. Ukutlhoriswa kwemakhaya akukavunyelwa.

 Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa ngananyana ngiyiphi indlela.

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa.

 Akakafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa.

 Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako.

 Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.

== Ukuvuza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako.

 Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yenzondo ayikavunyelwa.

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula.

 Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako.

 Unelungelo lokuhlangana nananyana ngubani.

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda.

 Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhetweni atjhaphulukileko nangasolisiko.

==Ubakhamuzi==
Ubakhamuzi bakho ngeze basuswa kuwe.

 Asikho isakhamuzi ekufuze sithathelwe ubakhamuzi baso.

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanyana kukuphi eRiphabhliki yeSewula Afrika.

 Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako.

 Unelungel lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.

==Itjhebiswano kezemisebenzi==
Ungajoyina amayuniyoni bewutoyitoye 

 Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana kuphumelelisa iminqopho yabo.

==Ibhoduluko==
Unelungelo lebhoduluko elinepilo.

 Unelungelo lokuhlala ebhodulukweni elivikelekileko nelinepilo.

==Ipahla==
Ungathathelwa ipahlakho nangabe imithetho efaneleko ilandelwe.

 Akekho ongathathelwa ipahla ngaphandle kwemibandela yomthetho okusetjenziswa okuvamileko.

==Izindlu==


==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==


==Abantwana==


==Ifundo==


==Ilimi nesiko==


==Imiphakathi yamaSiko, yeKolo nemaLimi==


==Ukufumana ilwazi==


==Ukuphatha ngokusemthethweni==


==Ukungena emaKhotho==


==Abantu ababotjhiweko nabathweswe umlandu==


==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>oisan1ur0iwtcjjsm0tbcobopq2v0z3</sha1>
    </revision>
    <revision>
      <id>513</id>
      <parentid>512</parentid>
      <timestamp>2016-02-24T20:26:35Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Izindlu */</comment>
      <origin>513</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4486" sha1="kemqkm16nv7pgm4c81n3il20wn3i9u2" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo wenarha ye Sewula Afrika begodu isihloko le sihlathjulula indlela bona amalungelo la aberega ngayo namcana angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amaatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe.

 Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe.

 Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.

==Ipilo==
Unelungelo lepilo.

 Boke abantu banelungelo lepilo.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejiziswa kumbi. Ukutlhoriswa kwemakhaya akukavunyelwa.

 Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa ngananyana ngiyiphi indlela.

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa.

 Akakafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa.

 Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako.

 Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.

== Ukuvuza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako.

 Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yenzondo ayikavunyelwa.

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula.

 Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako.

 Unelungelo lokuhlangana nananyana ngubani.

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda.

 Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhetweni atjhaphulukileko nangasolisiko.

==Ubakhamuzi==
Ubakhamuzi bakho ngeze basuswa kuwe.

 Asikho isakhamuzi ekufuze sithathelwe ubakhamuzi baso.

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanyana kukuphi eRiphabhliki yeSewula Afrika.

 Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako.

 Unelungel lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.

==Itjhebiswano kezemisebenzi==
Ungajoyina amayuniyoni bewutoyitoye 

 Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana kuphumelelisa iminqopho yabo.

==Ibhoduluko==
Unelungelo lebhoduluko elinepilo.

 Unelungelo lokuhlala ebhodulukweni elivikelekileko nelinepilo.

==Ipahla==
Ungathathelwa ipahlakho nangabe imithetho efaneleko ilandelwe.

 Akekho ongathathelwa ipahla ngaphandle kwemibandela yomthetho okusetjenziswa okuvamileko.

==Izindlu==
Urhulumende kufanele enze isiqiniseko sokobana abantu bafumana ukungena
okufaneleko eendlini..

 Ninelungelo lokufumana izidlu ezaneleko.

==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==


==Abantwana==


==Ifundo==


==Ilimi nesiko==


==Imiphakathi yamaSiko, yeKolo nemaLimi==


==Ukufumana ilwazi==


==Ukuphatha ngokusemthethweni==


==Ukungena emaKhotho==


==Abantu ababotjhiweko nabathweswe umlandu==


==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>kemqkm16nv7pgm4c81n3il20wn3i9u2</sha1>
    </revision>
    <revision>
      <id>514</id>
      <parentid>513</parentid>
      <timestamp>2016-02-24T20:27:59Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi */</comment>
      <origin>514</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4691" sha1="6wb2m010uqf11325up9sanyckzm6gvq" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo wenarha ye Sewula Afrika begodu isihloko le sihlathjulula indlela bona amalungelo la aberega ngayo namcana angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amaatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe.

 Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe.

 Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.

==Ipilo==
Unelungelo lepilo.

 Boke abantu banelungelo lepilo.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejiziswa kumbi. Ukutlhoriswa kwemakhaya akukavunyelwa.

 Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa ngananyana ngiyiphi indlela.

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa.

 Akakafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa.

 Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako.

 Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.

== Ukuvuza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako.

 Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yenzondo ayikavunyelwa.

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula.

 Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako.

 Unelungelo lokuhlangana nananyana ngubani.

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda.

 Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhetweni atjhaphulukileko nangasolisiko.

==Ubakhamuzi==
Ubakhamuzi bakho ngeze basuswa kuwe.

 Asikho isakhamuzi ekufuze sithathelwe ubakhamuzi baso.

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanyana kukuphi eRiphabhliki yeSewula Afrika.

 Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako.

 Unelungel lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.

==Itjhebiswano kezemisebenzi==
Ungajoyina amayuniyoni bewutoyitoye 

 Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana kuphumelelisa iminqopho yabo.

==Ibhoduluko==
Unelungelo lebhoduluko elinepilo.

 Unelungelo lokuhlala ebhodulukweni elivikelekileko nelinepilo.

==Ipahla==
Ungathathelwa ipahlakho nangabe imithetho efaneleko ilandelwe.

 Akekho ongathathelwa ipahla ngaphandle kwemibandela yomthetho okusetjenziswa okuvamileko.

==Izindlu==
Urhulumende kufanele enze isiqiniseko sokobana abantu bafumana ukungena
okufaneleko eendlini..

 Ninelungelo lokufumana izidlu ezaneleko.

==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==
Urhulumende kufanele enze isiqiniseko sokobana nifumana ukudla namanzi, itjhejo lezePilo kanye nokuPhepha emphakathini.

 Unelungelo letjhejo lezepilo, ukudla namanzi aneleko kanye nokuphepha emphakathini.

==Abantwana==


==Ifundo==


==Ilimi nesiko==


==Imiphakathi yamaSiko, yeKolo nemaLimi==


==Ukufumana ilwazi==


==Ukuphatha ngokusemthethweni==


==Ukungena emaKhotho==


==Abantu ababotjhiweko nabathweswe umlandu==


==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>6wb2m010uqf11325up9sanyckzm6gvq</sha1>
    </revision>
    <revision>
      <id>515</id>
      <parentid>514</parentid>
      <timestamp>2016-02-24T20:29:32Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Abantwana */</comment>
      <origin>515</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4907" sha1="g76owvvbidgnprmwe3q7e40y8udh1z9" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo wenarha ye Sewula Afrika begodu isihloko le sihlathjulula indlela bona amalungelo la aberega ngayo namcana angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amaatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe.

 Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe.

 Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.

==Ipilo==
Unelungelo lepilo.

 Boke abantu banelungelo lepilo.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejiziswa kumbi. Ukutlhoriswa kwemakhaya akukavunyelwa.

 Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa ngananyana ngiyiphi indlela.

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa.

 Akakafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa.

 Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako.

 Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.

== Ukuvuza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako.

 Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yenzondo ayikavunyelwa.

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula.

 Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako.

 Unelungelo lokuhlangana nananyana ngubani.

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda.

 Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhetweni atjhaphulukileko nangasolisiko.

==Ubakhamuzi==
Ubakhamuzi bakho ngeze basuswa kuwe.

 Asikho isakhamuzi ekufuze sithathelwe ubakhamuzi baso.

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanyana kukuphi eRiphabhliki yeSewula Afrika.

 Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako.

 Unelungel lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.

==Itjhebiswano kezemisebenzi==
Ungajoyina amayuniyoni bewutoyitoye 

 Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana kuphumelelisa iminqopho yabo.

==Ibhoduluko==
Unelungelo lebhoduluko elinepilo.

 Unelungelo lokuhlala ebhodulukweni elivikelekileko nelinepilo.

==Ipahla==
Ungathathelwa ipahlakho nangabe imithetho efaneleko ilandelwe.

 Akekho ongathathelwa ipahla ngaphandle kwemibandela yomthetho okusetjenziswa okuvamileko.

==Izindlu==
Urhulumende kufanele enze isiqiniseko sokobana abantu bafumana ukungena
okufaneleko eendlini..

 Ninelungelo lokufumana izidlu ezaneleko.

==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==
Urhulumende kufanele enze isiqiniseko sokobana nifumana ukudla namanzi, itjhejo lezePilo kanye nokuPhepha emphakathini.

 Unelungelo letjhejo lezepilo, ukudla namanzi aneleko kanye nokuphepha emphakathini.

==Abantwana==
Abantwana abangaphasi kweminyaka eli-18 banamalungelo akhethekileko njengelungelo lokungatlhoriswa.

 Woke umntwana unelungelo lebizo, lobutjhaba kanye nelokuvikelwa ekutlhorisweni nekusetjenzisweni ngokungakafaneli.

==Ifundo==


==Ilimi nesiko==


==Imiphakathi yamaSiko, yeKolo nemaLimi==


==Ukufumana ilwazi==


==Ukuphatha ngokusemthethweni==


==Ukungena emaKhotho==


==Abantu ababotjhiweko nabathweswe umlandu==


==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>g76owvvbidgnprmwe3q7e40y8udh1z9</sha1>
    </revision>
    <revision>
      <id>516</id>
      <parentid>515</parentid>
      <timestamp>2016-02-24T20:30:39Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Ifundo */</comment>
      <origin>516</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5077" sha1="ssigvg54n38ee8w5tksxoe5pqlgo73m" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo wenarha ye Sewula Afrika begodu isihloko le sihlathjulula indlela bona amalungelo la aberega ngayo namcana angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amaatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe.

 Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe.

 Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.

==Ipilo==
Unelungelo lepilo.

 Boke abantu banelungelo lepilo.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejiziswa kumbi. Ukutlhoriswa kwemakhaya akukavunyelwa.

 Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa ngananyana ngiyiphi indlela.

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa.

 Akakafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa.

 Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako.

 Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.

== Ukuvuza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako.

 Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yenzondo ayikavunyelwa.

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula.

 Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako.

 Unelungelo lokuhlangana nananyana ngubani.

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda.

 Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhetweni atjhaphulukileko nangasolisiko.

==Ubakhamuzi==
Ubakhamuzi bakho ngeze basuswa kuwe.

 Asikho isakhamuzi ekufuze sithathelwe ubakhamuzi baso.

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanyana kukuphi eRiphabhliki yeSewula Afrika.

 Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako.

 Unelungel lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.

==Itjhebiswano kezemisebenzi==
Ungajoyina amayuniyoni bewutoyitoye 

 Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana kuphumelelisa iminqopho yabo.

==Ibhoduluko==
Unelungelo lebhoduluko elinepilo.

 Unelungelo lokuhlala ebhodulukweni elivikelekileko nelinepilo.

==Ipahla==
Ungathathelwa ipahlakho nangabe imithetho efaneleko ilandelwe.

 Akekho ongathathelwa ipahla ngaphandle kwemibandela yomthetho okusetjenziswa okuvamileko.

==Izindlu==
Urhulumende kufanele enze isiqiniseko sokobana abantu bafumana ukungena
okufaneleko eendlini..

 Ninelungelo lokufumana izidlu ezaneleko.

==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==
Urhulumende kufanele enze isiqiniseko sokobana nifumana ukudla namanzi, itjhejo lezePilo kanye nokuPhepha emphakathini.

 Unelungelo letjhejo lezepilo, ukudla namanzi aneleko kanye nokuphepha emphakathini.

==Abantwana==
Abantwana abangaphasi kweminyaka eli-18 banamalungelo akhethekileko njengelungelo lokungatlhoriswa.

 Woke umntwana unelungelo lebizo, lobutjhaba kanye nelokuvikelwa ekutlhorisweni nekusetjenzisweni ngokungakafaneli.

==Ifundo==
Unelungelo lefundo esisekelo, kubalwa nefundo esisekelo yabadala ngelimi lakho (nangabekuyakghonakala)

 Unelungelo lefundo esisekelo ngelimi elisemthethweni olithandako.

==Ilimi nesiko==


==Imiphakathi yamaSiko, yeKolo nemaLimi==


==Ukufumana ilwazi==


==Ukuphatha ngokusemthethweni==


==Ukungena emaKhotho==


==Abantu ababotjhiweko nabathweswe umlandu==


==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>ssigvg54n38ee8w5tksxoe5pqlgo73m</sha1>
    </revision>
    <revision>
      <id>517</id>
      <parentid>516</parentid>
      <timestamp>2016-02-24T20:31:29Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Ilimi nesiko */</comment>
      <origin>517</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5221" sha1="s81trph5qkkoltuvpb2pc2u81ofpk49" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo wenarha ye Sewula Afrika begodu isihloko le sihlathjulula indlela bona amalungelo la aberega ngayo namcana angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amaatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe.

 Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe.

 Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.

==Ipilo==
Unelungelo lepilo.

 Boke abantu banelungelo lepilo.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejiziswa kumbi. Ukutlhoriswa kwemakhaya akukavunyelwa.

 Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa ngananyana ngiyiphi indlela.

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa.

 Akakafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa.

 Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako.

 Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.

== Ukuvuza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako.

 Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yenzondo ayikavunyelwa.

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula.

 Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako.

 Unelungelo lokuhlangana nananyana ngubani.

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda.

 Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhetweni atjhaphulukileko nangasolisiko.

==Ubakhamuzi==
Ubakhamuzi bakho ngeze basuswa kuwe.

 Asikho isakhamuzi ekufuze sithathelwe ubakhamuzi baso.

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanyana kukuphi eRiphabhliki yeSewula Afrika.

 Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako.

 Unelungel lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.

==Itjhebiswano kezemisebenzi==
Ungajoyina amayuniyoni bewutoyitoye 

 Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana kuphumelelisa iminqopho yabo.

==Ibhoduluko==
Unelungelo lebhoduluko elinepilo.

 Unelungelo lokuhlala ebhodulukweni elivikelekileko nelinepilo.

==Ipahla==
Ungathathelwa ipahlakho nangabe imithetho efaneleko ilandelwe.

 Akekho ongathathelwa ipahla ngaphandle kwemibandela yomthetho okusetjenziswa okuvamileko.

==Izindlu==
Urhulumende kufanele enze isiqiniseko sokobana abantu bafumana ukungena
okufaneleko eendlini..

 Ninelungelo lokufumana izidlu ezaneleko.

==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==
Urhulumende kufanele enze isiqiniseko sokobana nifumana ukudla namanzi, itjhejo lezePilo kanye nokuPhepha emphakathini.

 Unelungelo letjhejo lezepilo, ukudla namanzi aneleko kanye nokuphepha emphakathini.

==Abantwana==
Abantwana abangaphasi kweminyaka eli-18 banamalungelo akhethekileko njengelungelo lokungatlhoriswa.

 Woke umntwana unelungelo lebizo, lobutjhaba kanye nelokuvikelwa ekutlhorisweni nekusetjenzisweni ngokungakafaneli.

==Ifundo==
Unelungelo lefundo esisekelo, kubalwa nefundo esisekelo yabadala ngelimi lakho (nangabekuyakghonakala)

 Unelungelo lefundo esisekelo ngelimi elisemthethweni olithandako.

==Ilimi nesiko==
Ungasebenzisa ilimi ofuna ukulisebenzisa bewulandele nesiko ozikhethela lona.

 Unelungelo lokusebenzisa ilimi olithandako bewenze nesiko lakho.

==Imiphakathi yamaSiko, yeKolo nemaLimi==


==Ukufumana ilwazi==


==Ukuphatha ngokusemthethweni==


==Ukungena emaKhotho==


==Abantu ababotjhiweko nabathweswe umlandu==


==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>s81trph5qkkoltuvpb2pc2u81ofpk49</sha1>
    </revision>
    <revision>
      <id>518</id>
      <parentid>517</parentid>
      <timestamp>2016-02-24T20:32:17Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Imiphakathi yamaSiko, yeKolo nemaLimi */</comment>
      <origin>518</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5401" sha1="s2pr5wj2t5porp182qzfjjq2h8nlb2a" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo wenarha ye Sewula Afrika begodu isihloko le sihlathjulula indlela bona amalungelo la aberega ngayo namcana angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amaatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe.

 Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe.

 Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.

==Ipilo==
Unelungelo lepilo.

 Boke abantu banelungelo lepilo.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejiziswa kumbi. Ukutlhoriswa kwemakhaya akukavunyelwa.

 Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa ngananyana ngiyiphi indlela.

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa.

 Akakafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa.

 Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako.

 Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.

== Ukuvuza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako.

 Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yenzondo ayikavunyelwa.

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula.

 Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako.

 Unelungelo lokuhlangana nananyana ngubani.

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda.

 Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhetweni atjhaphulukileko nangasolisiko.

==Ubakhamuzi==
Ubakhamuzi bakho ngeze basuswa kuwe.

 Asikho isakhamuzi ekufuze sithathelwe ubakhamuzi baso.

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanyana kukuphi eRiphabhliki yeSewula Afrika.

 Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako.

 Unelungel lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.

==Itjhebiswano kezemisebenzi==
Ungajoyina amayuniyoni bewutoyitoye 

 Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana kuphumelelisa iminqopho yabo.

==Ibhoduluko==
Unelungelo lebhoduluko elinepilo.

 Unelungelo lokuhlala ebhodulukweni elivikelekileko nelinepilo.

==Ipahla==
Ungathathelwa ipahlakho nangabe imithetho efaneleko ilandelwe.

 Akekho ongathathelwa ipahla ngaphandle kwemibandela yomthetho okusetjenziswa okuvamileko.

==Izindlu==
Urhulumende kufanele enze isiqiniseko sokobana abantu bafumana ukungena
okufaneleko eendlini..

 Ninelungelo lokufumana izidlu ezaneleko.

==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==
Urhulumende kufanele enze isiqiniseko sokobana nifumana ukudla namanzi, itjhejo lezePilo kanye nokuPhepha emphakathini.

 Unelungelo letjhejo lezepilo, ukudla namanzi aneleko kanye nokuphepha emphakathini.

==Abantwana==
Abantwana abangaphasi kweminyaka eli-18 banamalungelo akhethekileko njengelungelo lokungatlhoriswa.

 Woke umntwana unelungelo lebizo, lobutjhaba kanye nelokuvikelwa ekutlhorisweni nekusetjenzisweni ngokungakafaneli.

==Ifundo==
Unelungelo lefundo esisekelo, kubalwa nefundo esisekelo yabadala ngelimi lakho (nangabekuyakghonakala)

 Unelungelo lefundo esisekelo ngelimi elisemthethweni olithandako.

==Ilimi nesiko==
Ungasebenzisa ilimi ofuna ukulisebenzisa bewulandele nesiko ozikhethela lona.

 Unelungelo lokusebenzisa ilimi olithandako bewenze nesiko lakho.

==Imiphakathi yamaSiko, yeKolo nemaLimi==
Imiphakathi ingazithabisa ngamasiko wayo; balandele ikolwabo bebasebenzise
ilimi labo.

 Unelungelo lokuthoma, lokujoyina nelogcina isiko, ilimi kanye nesiqhema sekolo osithandako.

==Ukufumana ilwazi==


==Ukuphatha ngokusemthethweni==


==Ukungena emaKhotho==


==Abantu ababotjhiweko nabathweswe umlandu==


==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>s2pr5wj2t5porp182qzfjjq2h8nlb2a</sha1>
    </revision>
    <revision>
      <id>519</id>
      <parentid>518</parentid>
      <timestamp>2016-02-24T20:33:09Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Ukufumana ilwazi */</comment>
      <origin>519</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5530" sha1="1fby6jeh96iv2q08qrx1v843oejylxg" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo wenarha ye Sewula Afrika begodu isihloko le sihlathjulula indlela bona amalungelo la aberega ngayo namcana angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amaatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe.

 Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe.

 Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.

==Ipilo==
Unelungelo lepilo.

 Boke abantu banelungelo lepilo.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejiziswa kumbi. Ukutlhoriswa kwemakhaya akukavunyelwa.

 Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa ngananyana ngiyiphi indlela.

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa.

 Akakafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa.

 Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako.

 Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.

== Ukuvuza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako.

 Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yenzondo ayikavunyelwa.

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula.

 Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako.

 Unelungelo lokuhlangana nananyana ngubani.

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda.

 Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhetweni atjhaphulukileko nangasolisiko.

==Ubakhamuzi==
Ubakhamuzi bakho ngeze basuswa kuwe.

 Asikho isakhamuzi ekufuze sithathelwe ubakhamuzi baso.

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanyana kukuphi eRiphabhliki yeSewula Afrika.

 Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako.

 Unelungel lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.

==Itjhebiswano kezemisebenzi==
Ungajoyina amayuniyoni bewutoyitoye 

 Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana kuphumelelisa iminqopho yabo.

==Ibhoduluko==
Unelungelo lebhoduluko elinepilo.

 Unelungelo lokuhlala ebhodulukweni elivikelekileko nelinepilo.

==Ipahla==
Ungathathelwa ipahlakho nangabe imithetho efaneleko ilandelwe.

 Akekho ongathathelwa ipahla ngaphandle kwemibandela yomthetho okusetjenziswa okuvamileko.

==Izindlu==
Urhulumende kufanele enze isiqiniseko sokobana abantu bafumana ukungena
okufaneleko eendlini..

 Ninelungelo lokufumana izidlu ezaneleko.

==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==
Urhulumende kufanele enze isiqiniseko sokobana nifumana ukudla namanzi, itjhejo lezePilo kanye nokuPhepha emphakathini.

 Unelungelo letjhejo lezepilo, ukudla namanzi aneleko kanye nokuphepha emphakathini.

==Abantwana==
Abantwana abangaphasi kweminyaka eli-18 banamalungelo akhethekileko njengelungelo lokungatlhoriswa.

 Woke umntwana unelungelo lebizo, lobutjhaba kanye nelokuvikelwa ekutlhorisweni nekusetjenzisweni ngokungakafaneli.

==Ifundo==
Unelungelo lefundo esisekelo, kubalwa nefundo esisekelo yabadala ngelimi lakho (nangabekuyakghonakala)

 Unelungelo lefundo esisekelo ngelimi elisemthethweni olithandako.

==Ilimi nesiko==
Ungasebenzisa ilimi ofuna ukulisebenzisa bewulandele nesiko ozikhethela lona.

 Unelungelo lokusebenzisa ilimi olithandako bewenze nesiko lakho.

==Imiphakathi yamaSiko, yeKolo nemaLimi==
Imiphakathi ingazithabisa ngamasiko wayo; balandele ikolwabo bebasebenzise
ilimi labo.

 Unelungelo lokuthoma, lokujoyina nelogcina isiko, ilimi kanye nesiqhema sekolo osithandako.

==Ukufumana ilwazi==
Unelungelo lelinye nelinye ilwazi urhulumende analo

 Ungafumana elinye nelinye ilwazi eliphethwe mbuso ukuvikela amalungelwakho.

==Ukuphatha ngokusemthethweni==


==Ukungena emaKhotho==


==Abantu ababotjhiweko nabathweswe umlandu==


==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>1fby6jeh96iv2q08qrx1v843oejylxg</sha1>
    </revision>
    <revision>
      <id>520</id>
      <parentid>519</parentid>
      <timestamp>2016-02-24T20:34:07Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Ukuphatha ngokusemthethweni */</comment>
      <origin>520</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5661" sha1="0vayxmejk12nms1igol2qw1nezx93f4" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo wenarha ye Sewula Afrika begodu isihloko le sihlathjulula indlela bona amalungelo la aberega ngayo namcana angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amaatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe.

 Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe.

 Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.

==Ipilo==
Unelungelo lepilo.

 Boke abantu banelungelo lepilo.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejiziswa kumbi. Ukutlhoriswa kwemakhaya akukavunyelwa.

 Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa ngananyana ngiyiphi indlela.

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa.

 Akakafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa.

 Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako.

 Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.

== Ukuvuza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako.

 Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yenzondo ayikavunyelwa.

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula.

 Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako.

 Unelungelo lokuhlangana nananyana ngubani.

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda.

 Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhetweni atjhaphulukileko nangasolisiko.

==Ubakhamuzi==
Ubakhamuzi bakho ngeze basuswa kuwe.

 Asikho isakhamuzi ekufuze sithathelwe ubakhamuzi baso.

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanyana kukuphi eRiphabhliki yeSewula Afrika.

 Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako.

 Unelungel lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.

==Itjhebiswano kezemisebenzi==
Ungajoyina amayuniyoni bewutoyitoye 

 Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana kuphumelelisa iminqopho yabo.

==Ibhoduluko==
Unelungelo lebhoduluko elinepilo.

 Unelungelo lokuhlala ebhodulukweni elivikelekileko nelinepilo.

==Ipahla==
Ungathathelwa ipahlakho nangabe imithetho efaneleko ilandelwe.

 Akekho ongathathelwa ipahla ngaphandle kwemibandela yomthetho okusetjenziswa okuvamileko.

==Izindlu==
Urhulumende kufanele enze isiqiniseko sokobana abantu bafumana ukungena
okufaneleko eendlini..

 Ninelungelo lokufumana izidlu ezaneleko.

==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==
Urhulumende kufanele enze isiqiniseko sokobana nifumana ukudla namanzi, itjhejo lezePilo kanye nokuPhepha emphakathini.

 Unelungelo letjhejo lezepilo, ukudla namanzi aneleko kanye nokuphepha emphakathini.

==Abantwana==
Abantwana abangaphasi kweminyaka eli-18 banamalungelo akhethekileko njengelungelo lokungatlhoriswa.

 Woke umntwana unelungelo lebizo, lobutjhaba kanye nelokuvikelwa ekutlhorisweni nekusetjenzisweni ngokungakafaneli.

==Ifundo==
Unelungelo lefundo esisekelo, kubalwa nefundo esisekelo yabadala ngelimi lakho (nangabekuyakghonakala)

 Unelungelo lefundo esisekelo ngelimi elisemthethweni olithandako.

==Ilimi nesiko==
Ungasebenzisa ilimi ofuna ukulisebenzisa bewulandele nesiko ozikhethela lona.

 Unelungelo lokusebenzisa ilimi olithandako bewenze nesiko lakho.

==Imiphakathi yamaSiko, yeKolo nemaLimi==
Imiphakathi ingazithabisa ngamasiko wayo; balandele ikolwabo bebasebenzise
ilimi labo.

 Unelungelo lokuthoma, lokujoyina nelogcina isiko, ilimi kanye nesiqhema sekolo osithandako.

==Ukufumana ilwazi==
Unelungelo lelinye nelinye ilwazi urhulumende analo

 Ungafumana elinye nelinye ilwazi eliphethwe mbuso ukuvikela amalungelwakho.

==Ukuphatha ngokusemthethweni==
Izenzo zakarhulumende kufanele zibe ngezilungileko 

 Unelungelo lezenzo ezisemthethweni, ezizwakalako nezilungileko akarhulumende.

==Ukungena emaKhotho==


==Abantu ababotjhiweko nabathweswe umlandu==


==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>0vayxmejk12nms1igol2qw1nezx93f4</sha1>
    </revision>
    <revision>
      <id>521</id>
      <parentid>520</parentid>
      <timestamp>2016-02-24T20:35:16Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Ukungena emaKhotho */</comment>
      <origin>521</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5868" sha1="c804ehq4ervacy4t2ccs75j470tc56r" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo wenarha ye Sewula Afrika begodu isihloko le sihlathjulula indlela bona amalungelo la aberega ngayo namcana angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amaatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe.

 Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe.

 Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.

==Ipilo==
Unelungelo lepilo.

 Boke abantu banelungelo lepilo.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejiziswa kumbi. Ukutlhoriswa kwemakhaya akukavunyelwa.

 Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa ngananyana ngiyiphi indlela.

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa.

 Akakafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa.

 Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako.

 Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.

== Ukuvuza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako.

 Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yenzondo ayikavunyelwa.

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula.

 Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako.

 Unelungelo lokuhlangana nananyana ngubani.

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda.

 Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhetweni atjhaphulukileko nangasolisiko.

==Ubakhamuzi==
Ubakhamuzi bakho ngeze basuswa kuwe.

 Asikho isakhamuzi ekufuze sithathelwe ubakhamuzi baso.

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanyana kukuphi eRiphabhliki yeSewula Afrika.

 Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako.

 Unelungel lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.

==Itjhebiswano kezemisebenzi==
Ungajoyina amayuniyoni bewutoyitoye 

 Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana kuphumelelisa iminqopho yabo.

==Ibhoduluko==
Unelungelo lebhoduluko elinepilo.

 Unelungelo lokuhlala ebhodulukweni elivikelekileko nelinepilo.

==Ipahla==
Ungathathelwa ipahlakho nangabe imithetho efaneleko ilandelwe.

 Akekho ongathathelwa ipahla ngaphandle kwemibandela yomthetho okusetjenziswa okuvamileko.

==Izindlu==
Urhulumende kufanele enze isiqiniseko sokobana abantu bafumana ukungena
okufaneleko eendlini..

 Ninelungelo lokufumana izidlu ezaneleko.

==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==
Urhulumende kufanele enze isiqiniseko sokobana nifumana ukudla namanzi, itjhejo lezePilo kanye nokuPhepha emphakathini.

 Unelungelo letjhejo lezepilo, ukudla namanzi aneleko kanye nokuphepha emphakathini.

==Abantwana==
Abantwana abangaphasi kweminyaka eli-18 banamalungelo akhethekileko njengelungelo lokungatlhoriswa.

 Woke umntwana unelungelo lebizo, lobutjhaba kanye nelokuvikelwa ekutlhorisweni nekusetjenzisweni ngokungakafaneli.

==Ifundo==
Unelungelo lefundo esisekelo, kubalwa nefundo esisekelo yabadala ngelimi lakho (nangabekuyakghonakala)

 Unelungelo lefundo esisekelo ngelimi elisemthethweni olithandako.

==Ilimi nesiko==
Ungasebenzisa ilimi ofuna ukulisebenzisa bewulandele nesiko ozikhethela lona.

 Unelungelo lokusebenzisa ilimi olithandako bewenze nesiko lakho.

==Imiphakathi yamaSiko, yeKolo nemaLimi==
Imiphakathi ingazithabisa ngamasiko wayo; balandele ikolwabo bebasebenzise
ilimi labo.

 Unelungelo lokuthoma, lokujoyina nelogcina isiko, ilimi kanye nesiqhema sekolo osithandako.

==Ukufumana ilwazi==
Unelungelo lelinye nelinye ilwazi urhulumende analo

 Ungafumana elinye nelinye ilwazi eliphethwe mbuso ukuvikela amalungelwakho.

==Ukuphatha ngokusemthethweni==
Izenzo zakarhulumende kufanele zibe ngezilungileko 

 Unelungelo lezenzo ezisemthethweni, ezizwakalako nezilungileko akarhulumende.

==Ukungena emaKhotho==
Umrarwakho wangokomthetho ungathathelwa isiqunto yikhotho namkha isakhiwo esifanako.

 Unelungelo lokurarulula imiraro yangokomthetho ekhotho namkha ebandleni elingakabandanyeki bunqopha elirarulula imiraro.

==Abantu ababotjhiweko nabathweswe umlandu==


==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>c804ehq4ervacy4t2ccs75j470tc56r</sha1>
    </revision>
    <revision>
      <id>522</id>
      <parentid>521</parentid>
      <timestamp>2016-02-24T20:36:38Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Abantu ababotjhiweko nabathweswe umlandu */</comment>
      <origin>522</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6095" sha1="eir85dfp33734zg7325gy9lj8uyzu2v" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo wenarha ye Sewula Afrika begodu isihloko le sihlathjulula indlela bona amalungelo la aberega ngayo namcana angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amaatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - '''The Department of Justice and Constitutional Development'''. Retrieved 24 February 2016&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe.

 Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe.

 Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.

==Ipilo==
Unelungelo lepilo.

 Boke abantu banelungelo lepilo.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejiziswa kumbi. Ukutlhoriswa kwemakhaya akukavunyelwa.

 Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa ngananyana ngiyiphi indlela.

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa.

 Akakafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa.

 Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako.

 Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.

== Ukuvuza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako.

 Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yenzondo ayikavunyelwa.

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula.

 Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako.

 Unelungelo lokuhlangana nananyana ngubani.

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda.

 Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhetweni atjhaphulukileko nangasolisiko.

==Ubakhamuzi==
Ubakhamuzi bakho ngeze basuswa kuwe.

 Asikho isakhamuzi ekufuze sithathelwe ubakhamuzi baso.

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanyana kukuphi eRiphabhliki yeSewula Afrika.

 Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako.

 Unelungel lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.

==Itjhebiswano kezemisebenzi==
Ungajoyina amayuniyoni bewutoyitoye 

 Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana kuphumelelisa iminqopho yabo.

==Ibhoduluko==
Unelungelo lebhoduluko elinepilo.

 Unelungelo lokuhlala ebhodulukweni elivikelekileko nelinepilo.

==Ipahla==
Ungathathelwa ipahlakho nangabe imithetho efaneleko ilandelwe.

 Akekho ongathathelwa ipahla ngaphandle kwemibandela yomthetho okusetjenziswa okuvamileko.

==Izindlu==
Urhulumende kufanele enze isiqiniseko sokobana abantu bafumana ukungena
okufaneleko eendlini..

 Ninelungelo lokufumana izidlu ezaneleko.

==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==
Urhulumende kufanele enze isiqiniseko sokobana nifumana ukudla namanzi, itjhejo lezePilo kanye nokuPhepha emphakathini.

 Unelungelo letjhejo lezepilo, ukudla namanzi aneleko kanye nokuphepha emphakathini.

==Abantwana==
Abantwana abangaphasi kweminyaka eli-18 banamalungelo akhethekileko njengelungelo lokungatlhoriswa.

 Woke umntwana unelungelo lebizo, lobutjhaba kanye nelokuvikelwa ekutlhorisweni nekusetjenzisweni ngokungakafaneli.

==Ifundo==
Unelungelo lefundo esisekelo, kubalwa nefundo esisekelo yabadala ngelimi lakho (nangabekuyakghonakala)

 Unelungelo lefundo esisekelo ngelimi elisemthethweni olithandako.

==Ilimi nesiko==
Ungasebenzisa ilimi ofuna ukulisebenzisa bewulandele nesiko ozikhethela lona.

 Unelungelo lokusebenzisa ilimi olithandako bewenze nesiko lakho.

==Imiphakathi yamaSiko, yeKolo nemaLimi==
Imiphakathi ingazithabisa ngamasiko wayo; balandele ikolwabo bebasebenzise
ilimi labo.

 Unelungelo lokuthoma, lokujoyina nelogcina isiko, ilimi kanye nesiqhema sekolo osithandako.

==Ukufumana ilwazi==
Unelungelo lelinye nelinye ilwazi urhulumende analo

 Ungafumana elinye nelinye ilwazi eliphethwe mbuso ukuvikela amalungelwakho.

==Ukuphatha ngokusemthethweni==
Izenzo zakarhulumende kufanele zibe ngezilungileko 

 Unelungelo lezenzo ezisemthethweni, ezizwakalako nezilungileko akarhulumende.

==Ukungena emaKhotho==
Umrarwakho wangokomthetho ungathathelwa isiqunto yikhotho namkha isakhiwo esifanako.

 Unelungelo lokurarulula imiraro yangokomthetho ekhotho namkha ebandleni elingakabandanyeki bunqopha elirarulula imiraro.

==Abantu ababotjhiweko nabathweswe umlandu==
Ilungelweli livikela abantu ababotjhiweko nabavalelwe esikhungweni namkha abathweswe umlandu.

 Nawubotjhiweko unelungelo okungakhulumi, lokulethwa ngaphambi kwekhotho ema-irini ama-48 kanye nelungelo lokujanyelwa ngokomthetho.

==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>eir85dfp33734zg7325gy9lj8uyzu2v</sha1>
    </revision>
    <revision>
      <id>523</id>
      <parentid>522</parentid>
      <timestamp>2016-02-24T20:44:50Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>523</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6916" sha1="36lw8zmgaby0h3r2zd8pth1o5g01ypf" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo wenarha ye Sewula Afrika begodu isihloko le sihlathjulula indlela bona amalungelo la aberega ngayo namcana angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amaatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe.

 Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.&lt;ref name=ph3&gt;&quot;[http://www.justice.gov.za/legislation/constitution/bor/BillofRights50thAnniversary-Ndebele.pdf Bill of Rights 50&lt;sup&gt;th&lt;/sup&gt; Anniversary]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;



==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe.

 Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ipilo==
Unelungelo lepilo.

 Boke abantu banelungelo lepilo.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejiziswa kumbi. Ukutlhoriswa kwemakhaya akukavunyelwa.

 Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa ngananyana ngiyiphi indlela.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa.

 Akakafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa.

 Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.&lt;ref name=ph3&gt;&lt;/ref&gt;

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako.

 Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.&lt;ref name=ph3&gt;&lt;/ref&gt;

== Ukuvuza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako.

 Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yenzondo ayikavunyelwa.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula.

 Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako.

 Unelungelo lokuhlangana nananyana ngubani.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda.

 Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhetweni atjhaphulukileko nangasolisiko.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ubakhamuzi==
Ubakhamuzi bakho ngeze basuswa kuwe.

 Asikho isakhamuzi ekufuze sithathelwe ubakhamuzi baso.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanyana kukuphi eRiphabhliki yeSewula Afrika.

 Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako.

 Unelungel lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Itjhebiswano kezemisebenzi==
Ungajoyina amayuniyoni bewutoyitoye 

 Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana kuphumelelisa iminqopho yabo.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ibhoduluko==
Unelungelo lebhoduluko elinepilo.

 Unelungelo lokuhlala ebhodulukweni elivikelekileko nelinepilo.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ipahla==
Ungathathelwa ipahlakho nangabe imithetho efaneleko ilandelwe.

 Akekho ongathathelwa ipahla ngaphandle kwemibandela yomthetho okusetjenziswa okuvamileko.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Izindlu==
Urhulumende kufanele enze isiqiniseko sokobana abantu bafumana ukungena
okufaneleko eendlini..

 Ninelungelo lokufumana izidlu ezaneleko.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==
Urhulumende kufanele enze isiqiniseko sokobana nifumana ukudla namanzi, itjhejo lezePilo kanye nokuPhepha emphakathini.

 Unelungelo letjhejo lezepilo, ukudla namanzi aneleko kanye nokuphepha emphakathini.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Abantwana==
Abantwana abangaphasi kweminyaka eli-18 banamalungelo akhethekileko njengelungelo lokungatlhoriswa.

 Woke umntwana unelungelo lebizo, lobutjhaba kanye nelokuvikelwa ekutlhorisweni nekusetjenzisweni ngokungakafaneli.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ifundo==
Unelungelo lefundo esisekelo, kubalwa nefundo esisekelo yabadala ngelimi lakho (nangabekuyakghonakala)

 Unelungelo lefundo esisekelo ngelimi elisemthethweni olithandako.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ilimi nesiko==
Ungasebenzisa ilimi ofuna ukulisebenzisa bewulandele nesiko ozikhethela lona.

 Unelungelo lokusebenzisa ilimi olithandako bewenze nesiko lakho.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Imiphakathi yamaSiko, yeKolo nemaLimi==
Imiphakathi ingazithabisa ngamasiko wayo; balandele ikolwabo bebasebenzise
ilimi labo.

 Unelungelo lokuthoma, lokujoyina nelogcina isiko, ilimi kanye nesiqhema sekolo osithandako.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ukufumana ilwazi==
Unelungelo lelinye nelinye ilwazi urhulumende analo

 Ungafumana elinye nelinye ilwazi eliphethwe mbuso ukuvikela amalungelwakho.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ukuphatha ngokusemthethweni==
Izenzo zakarhulumende kufanele zibe ngezilungileko 

 Unelungelo lezenzo ezisemthethweni, ezizwakalako nezilungileko akarhulumende.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ukungena emaKhotho==
Umrarwakho wangokomthetho ungathathelwa isiqunto yikhotho namkha isakhiwo esifanako.

 Unelungelo lokurarulula imiraro yangokomthetho ekhotho namkha ebandleni elingakabandanyeki bunqopha elirarulula imiraro.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Abantu ababotjhiweko nabathweswe umlandu==
Ilungelweli livikela abantu ababotjhiweko nabavalelwe esikhungweni namkha abathweswe umlandu.

 Nawubotjhiweko unelungelo okungakhulumi, lokulethwa ngaphambi kwekhotho ema-irini ama-48 kanye nelungelo lokujanyelwa ngokomthetho.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>36lw8zmgaby0h3r2zd8pth1o5g01ypf</sha1>
    </revision>
    <revision>
      <id>524</id>
      <parentid>523</parentid>
      <timestamp>2016-02-25T21:24:19Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Ukulingana */</comment>
      <origin>524</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6914" sha1="aiegmnvoqgwoo2bavyejmcpnqh77rej" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo wenarha ye Sewula Afrika begodu isihloko le sihlathjulula indlela bona amalungelo la aberega ngayo namcana angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amaatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe.

 Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.&lt;ref name=ph3&gt;&quot;[http://www.justice.gov.za/legislation/constitution/bor/BillofRights50thAnniversary-Ndebele.pdf Bill of Rights 50&lt;sup&gt;th&lt;/sup&gt; Anniversary]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe.

 Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ipilo==
Unelungelo lepilo.

 Boke abantu banelungelo lepilo.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejiziswa kumbi. Ukutlhoriswa kwemakhaya akukavunyelwa.

 Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa ngananyana ngiyiphi indlela.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa.

 Akakafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa.

 Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.&lt;ref name=ph3&gt;&lt;/ref&gt;

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako.

 Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.&lt;ref name=ph3&gt;&lt;/ref&gt;

== Ukuvuza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako.

 Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yenzondo ayikavunyelwa.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula.

 Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako.

 Unelungelo lokuhlangana nananyana ngubani.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda.

 Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhetweni atjhaphulukileko nangasolisiko.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ubakhamuzi==
Ubakhamuzi bakho ngeze basuswa kuwe.

 Asikho isakhamuzi ekufuze sithathelwe ubakhamuzi baso.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanyana kukuphi eRiphabhliki yeSewula Afrika.

 Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako.

 Unelungel lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Itjhebiswano kezemisebenzi==
Ungajoyina amayuniyoni bewutoyitoye 

 Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana kuphumelelisa iminqopho yabo.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ibhoduluko==
Unelungelo lebhoduluko elinepilo.

 Unelungelo lokuhlala ebhodulukweni elivikelekileko nelinepilo.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ipahla==
Ungathathelwa ipahlakho nangabe imithetho efaneleko ilandelwe.

 Akekho ongathathelwa ipahla ngaphandle kwemibandela yomthetho okusetjenziswa okuvamileko.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Izindlu==
Urhulumende kufanele enze isiqiniseko sokobana abantu bafumana ukungena
okufaneleko eendlini..

 Ninelungelo lokufumana izidlu ezaneleko.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==
Urhulumende kufanele enze isiqiniseko sokobana nifumana ukudla namanzi, itjhejo lezePilo kanye nokuPhepha emphakathini.

 Unelungelo letjhejo lezepilo, ukudla namanzi aneleko kanye nokuphepha emphakathini.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Abantwana==
Abantwana abangaphasi kweminyaka eli-18 banamalungelo akhethekileko njengelungelo lokungatlhoriswa.

 Woke umntwana unelungelo lebizo, lobutjhaba kanye nelokuvikelwa ekutlhorisweni nekusetjenzisweni ngokungakafaneli.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ifundo==
Unelungelo lefundo esisekelo, kubalwa nefundo esisekelo yabadala ngelimi lakho (nangabekuyakghonakala)

 Unelungelo lefundo esisekelo ngelimi elisemthethweni olithandako.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ilimi nesiko==
Ungasebenzisa ilimi ofuna ukulisebenzisa bewulandele nesiko ozikhethela lona.

 Unelungelo lokusebenzisa ilimi olithandako bewenze nesiko lakho.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Imiphakathi yamaSiko, yeKolo nemaLimi==
Imiphakathi ingazithabisa ngamasiko wayo; balandele ikolwabo bebasebenzise
ilimi labo.

 Unelungelo lokuthoma, lokujoyina nelogcina isiko, ilimi kanye nesiqhema sekolo osithandako.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ukufumana ilwazi==
Unelungelo lelinye nelinye ilwazi urhulumende analo

 Ungafumana elinye nelinye ilwazi eliphethwe mbuso ukuvikela amalungelwakho.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ukuphatha ngokusemthethweni==
Izenzo zakarhulumende kufanele zibe ngezilungileko 

 Unelungelo lezenzo ezisemthethweni, ezizwakalako nezilungileko akarhulumende.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ukungena emaKhotho==
Umrarwakho wangokomthetho ungathathelwa isiqunto yikhotho namkha isakhiwo esifanako.

 Unelungelo lokurarulula imiraro yangokomthetho ekhotho namkha ebandleni elingakabandanyeki bunqopha elirarulula imiraro.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Abantu ababotjhiweko nabathweswe umlandu==
Ilungelweli livikela abantu ababotjhiweko nabavalelwe esikhungweni namkha abathweswe umlandu.

 Nawubotjhiweko unelungelo okungakhulumi, lokulethwa ngaphambi kwekhotho ema-irini ama-48 kanye nelungelo lokujanyelwa ngokomthetho.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>aiegmnvoqgwoo2bavyejmcpnqh77rej</sha1>
    </revision>
    <revision>
      <id>525</id>
      <parentid>524</parentid>
      <timestamp>2021-08-26T17:08:10Z</timestamp>
      <contributor>
        <username>incubator&gt;InternetArchiveBot</username>
        <id>0</id>
      </contributor>
      <comment>Rescuing 3 sources and tagging 0 as dead.) #IABot (v2.0.8</comment>
      <origin>525</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7043" sha1="n9891bvyfh09cig0smwn2alwqw2867d" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo wenarha ye Sewula Afrika begodu isihloko le sihlathjulula indlela bona amalungelo la aberega ngayo namcana angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[https://web.archive.org/web/20160305192903/http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amaatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[https://web.archive.org/web/20160306031920/http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe.

 Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.&lt;ref name=ph3&gt;&quot;[https://web.archive.org/web/20160329070107/http://www.justice.gov.za/legislation/constitution/bor/BillofRights50thAnniversary-Ndebele.pdf Bill of Rights 50&lt;sup&gt;th&lt;/sup&gt; Anniversary]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe.

 Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ipilo==
Unelungelo lepilo.

 Boke abantu banelungelo lepilo.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejiziswa kumbi. Ukutlhoriswa kwemakhaya akukavunyelwa.

 Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa ngananyana ngiyiphi indlela.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa.

 Akakafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa.

 Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.&lt;ref name=ph3&gt;&lt;/ref&gt;

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako.

 Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.&lt;ref name=ph3&gt;&lt;/ref&gt;

== Ukuvuza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako.

 Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yenzondo ayikavunyelwa.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula.

 Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako.

 Unelungelo lokuhlangana nananyana ngubani.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda.

 Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhetweni atjhaphulukileko nangasolisiko.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ubakhamuzi==
Ubakhamuzi bakho ngeze basuswa kuwe.

 Asikho isakhamuzi ekufuze sithathelwe ubakhamuzi baso.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanyana kukuphi eRiphabhliki yeSewula Afrika.

 Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako.

 Unelungel lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Itjhebiswano kezemisebenzi==
Ungajoyina amayuniyoni bewutoyitoye 

 Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana kuphumelelisa iminqopho yabo.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ibhoduluko==
Unelungelo lebhoduluko elinepilo.

 Unelungelo lokuhlala ebhodulukweni elivikelekileko nelinepilo.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ipahla==
Ungathathelwa ipahlakho nangabe imithetho efaneleko ilandelwe.

 Akekho ongathathelwa ipahla ngaphandle kwemibandela yomthetho okusetjenziswa okuvamileko.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Izindlu==
Urhulumende kufanele enze isiqiniseko sokobana abantu bafumana ukungena
okufaneleko eendlini..

 Ninelungelo lokufumana izidlu ezaneleko.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==
Urhulumende kufanele enze isiqiniseko sokobana nifumana ukudla namanzi, itjhejo lezePilo kanye nokuPhepha emphakathini.

 Unelungelo letjhejo lezepilo, ukudla namanzi aneleko kanye nokuphepha emphakathini.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Abantwana==
Abantwana abangaphasi kweminyaka eli-18 banamalungelo akhethekileko njengelungelo lokungatlhoriswa.

 Woke umntwana unelungelo lebizo, lobutjhaba kanye nelokuvikelwa ekutlhorisweni nekusetjenzisweni ngokungakafaneli.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ifundo==
Unelungelo lefundo esisekelo, kubalwa nefundo esisekelo yabadala ngelimi lakho (nangabekuyakghonakala)

 Unelungelo lefundo esisekelo ngelimi elisemthethweni olithandako.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ilimi nesiko==
Ungasebenzisa ilimi ofuna ukulisebenzisa bewulandele nesiko ozikhethela lona.

 Unelungelo lokusebenzisa ilimi olithandako bewenze nesiko lakho.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Imiphakathi yamaSiko, yeKolo nemaLimi==
Imiphakathi ingazithabisa ngamasiko wayo; balandele ikolwabo bebasebenzise
ilimi labo.

 Unelungelo lokuthoma, lokujoyina nelogcina isiko, ilimi kanye nesiqhema sekolo osithandako.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ukufumana ilwazi==
Unelungelo lelinye nelinye ilwazi urhulumende analo

 Ungafumana elinye nelinye ilwazi eliphethwe mbuso ukuvikela amalungelwakho.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ukuphatha ngokusemthethweni==
Izenzo zakarhulumende kufanele zibe ngezilungileko 

 Unelungelo lezenzo ezisemthethweni, ezizwakalako nezilungileko akarhulumende.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ukungena emaKhotho==
Umrarwakho wangokomthetho ungathathelwa isiqunto yikhotho namkha isakhiwo esifanako.

 Unelungelo lokurarulula imiraro yangokomthetho ekhotho namkha ebandleni elingakabandanyeki bunqopha elirarulula imiraro.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Abantu ababotjhiweko nabathweswe umlandu==
Ilungelweli livikela abantu ababotjhiweko nabavalelwe esikhungweni namkha abathweswe umlandu.

 Nawubotjhiweko unelungelo okungakhulumi, lokulethwa ngaphambi kwekhotho ema-irini ama-48 kanye nelungelo lokujanyelwa ngokomthetho.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>n9891bvyfh09cig0smwn2alwqw2867d</sha1>
    </revision>
    <revision>
      <id>526</id>
      <parentid>525</parentid>
      <timestamp>2024-03-07T23:52:03Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>/* Isithunzi sabantu */</comment>
      <origin>526</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7043" sha1="osdv2tmivtz0bvtookje1siwky08b1f" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo wenarha ye Sewula Afrika begodu isihloko le sihlathjulula indlela bona amalungelo la aberega ngayo namcana angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[https://web.archive.org/web/20160305192903/http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amaatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[https://web.archive.org/web/20160306031920/http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe.

 Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.&lt;ref name=ph3&gt;&quot;[https://web.archive.org/web/20160329070107/http://www.justice.gov.za/legislation/constitution/bor/BillofRights50thAnniversary-Ndebele.pdf Bill of Rights 50&lt;sup&gt;th&lt;/sup&gt; Anniversary]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe. Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipilo==
Unelungelo lepilo.

 Boke abantu banelungelo lepilo.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejiziswa kumbi. Ukutlhoriswa kwemakhaya akukavunyelwa.

 Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa ngananyana ngiyiphi indlela.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa.

 Akakafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa.

 Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.&lt;ref name=ph3&gt;&lt;/ref&gt;

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako.

 Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.&lt;ref name=ph3&gt;&lt;/ref&gt;

== Ukuvuza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako.

 Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yenzondo ayikavunyelwa.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula.

 Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako.

 Unelungelo lokuhlangana nananyana ngubani.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda.

 Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhetweni atjhaphulukileko nangasolisiko.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ubakhamuzi==
Ubakhamuzi bakho ngeze basuswa kuwe.

 Asikho isakhamuzi ekufuze sithathelwe ubakhamuzi baso.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanyana kukuphi eRiphabhliki yeSewula Afrika.

 Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako.

 Unelungel lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Itjhebiswano kezemisebenzi==
Ungajoyina amayuniyoni bewutoyitoye 

 Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana kuphumelelisa iminqopho yabo.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ibhoduluko==
Unelungelo lebhoduluko elinepilo.

 Unelungelo lokuhlala ebhodulukweni elivikelekileko nelinepilo.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ipahla==
Ungathathelwa ipahlakho nangabe imithetho efaneleko ilandelwe.

 Akekho ongathathelwa ipahla ngaphandle kwemibandela yomthetho okusetjenziswa okuvamileko.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Izindlu==
Urhulumende kufanele enze isiqiniseko sokobana abantu bafumana ukungena
okufaneleko eendlini..

 Ninelungelo lokufumana izidlu ezaneleko.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==
Urhulumende kufanele enze isiqiniseko sokobana nifumana ukudla namanzi, itjhejo lezePilo kanye nokuPhepha emphakathini.

 Unelungelo letjhejo lezepilo, ukudla namanzi aneleko kanye nokuphepha emphakathini.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Abantwana==
Abantwana abangaphasi kweminyaka eli-18 banamalungelo akhethekileko njengelungelo lokungatlhoriswa.

 Woke umntwana unelungelo lebizo, lobutjhaba kanye nelokuvikelwa ekutlhorisweni nekusetjenzisweni ngokungakafaneli.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ifundo==
Unelungelo lefundo esisekelo, kubalwa nefundo esisekelo yabadala ngelimi lakho (nangabekuyakghonakala)

 Unelungelo lefundo esisekelo ngelimi elisemthethweni olithandako.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ilimi nesiko==
Ungasebenzisa ilimi ofuna ukulisebenzisa bewulandele nesiko ozikhethela lona.

 Unelungelo lokusebenzisa ilimi olithandako bewenze nesiko lakho.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Imiphakathi yamaSiko, yeKolo nemaLimi==
Imiphakathi ingazithabisa ngamasiko wayo; balandele ikolwabo bebasebenzise
ilimi labo.

 Unelungelo lokuthoma, lokujoyina nelogcina isiko, ilimi kanye nesiqhema sekolo osithandako.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ukufumana ilwazi==
Unelungelo lelinye nelinye ilwazi urhulumende analo

 Ungafumana elinye nelinye ilwazi eliphethwe mbuso ukuvikela amalungelwakho.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ukuphatha ngokusemthethweni==
Izenzo zakarhulumende kufanele zibe ngezilungileko 

 Unelungelo lezenzo ezisemthethweni, ezizwakalako nezilungileko akarhulumende.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ukungena emaKhotho==
Umrarwakho wangokomthetho ungathathelwa isiqunto yikhotho namkha isakhiwo esifanako.

 Unelungelo lokurarulula imiraro yangokomthetho ekhotho namkha ebandleni elingakabandanyeki bunqopha elirarulula imiraro.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Abantu ababotjhiweko nabathweswe umlandu==
Ilungelweli livikela abantu ababotjhiweko nabavalelwe esikhungweni namkha abathweswe umlandu.

 Nawubotjhiweko unelungelo okungakhulumi, lokulethwa ngaphambi kwekhotho ema-irini ama-48 kanye nelungelo lokujanyelwa ngokomthetho.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>osdv2tmivtz0bvtookje1siwky08b1f</sha1>
    </revision>
    <revision>
      <id>527</id>
      <parentid>526</parentid>
      <timestamp>2024-03-08T10:35:55Z</timestamp>
      <contributor>
        <username>incubator&gt;LondiweM24</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>I Edited and added</comment>
      <origin>527</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7097" sha1="osu8poe2wyqj79wb27k7pcfgf8vxo9e" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo senarha ye Sewula Afrika begodu isihloko le sihlathulula indlela bona amalungelo la asebenza ngayo namkha angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[https://web.archive.org/web/20160305192903/http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[https://web.archive.org/web/20160306031920/http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe.

 Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.&lt;ref name=ph3&gt;&quot;[https://web.archive.org/web/20160329070107/http://www.justice.gov.za/legislation/constitution/bor/BillofRights50thAnniversary-Ndebele.pdf Bill of Rights 50&lt;sup&gt;th&lt;/sup&gt; Anniversary]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe. Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipilo==
Unelungelo lepilo.

 Boke abantu banelungelo lokuphila.&lt;ref name=ph3&gt;&lt;/ref&gt;
irhelebho nanyana ngiliphi ongalithola ukuze uphile.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejeziswa kumbi. Ukutlhoriswa kwemakhaya akukavunyelwa.

 Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa ngananyana ngiyiphi indlela.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa.

 Akakafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa.

 Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.&lt;ref name=ph3&gt;&lt;/ref&gt;

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako.

 Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.&lt;ref name=ph3&gt;&lt;/ref&gt;

== Ukuvuza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako.

 Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yenzondo ayikavunyelwa.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula.

 Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako.

 Unelungelo lokuhlangana nananyana ngubani.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda.

 Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhetweni atjhaphulukileko nangasolisiko.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ubakhamuzi==
Ubakhamuzi bakho ngeze basuswa kuwe.

 Asikho isakhamuzi ekufuze sithathelwe ubakhamuzi baso.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanyana kukuphi eRiphabhliki yeSewula Afrika.

 Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako.

 Unelungel lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Itjhebiswano kezemisebenzi==
Ungajoyina amayuniyoni bewutoyitoye 

 Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana kuphumelelisa iminqopho yabo.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ibhoduluko==
Unelungelo lebhoduluko elinepilo.

 Unelungelo lokuhlala ebhodulukweni elivikelekileko nelinepilo.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ipahla==
Ungathathelwa ipahlakho nangabe imithetho efaneleko ilandelwe.

 Akekho ongathathelwa ipahla ngaphandle kwemibandela yomthetho okusetjenziswa okuvamileko.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Izindlu==
Urhulumende kufanele enze isiqiniseko sokobana abantu bafumana ukungena
okufaneleko eendlini..

 Ninelungelo lokufumana izidlu ezaneleko.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==
Urhulumende kufanele enze isiqiniseko sokobana nifumana ukudla namanzi, itjhejo lezePilo kanye nokuPhepha emphakathini.

 Unelungelo letjhejo lezepilo, ukudla namanzi aneleko kanye nokuphepha emphakathini.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Abantwana==
Abantwana abangaphasi kweminyaka eli-18 banamalungelo akhethekileko njengelungelo lokungatlhoriswa.

 Woke umntwana unelungelo lebizo, lobutjhaba kanye nelokuvikelwa ekutlhorisweni nekusetjenzisweni ngokungakafaneli.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ifundo==
Unelungelo lefundo esisekelo, kubalwa nefundo esisekelo yabadala ngelimi lakho (nangabekuyakghonakala)

 Unelungelo lefundo esisekelo ngelimi elisemthethweni olithandako.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ilimi nesiko==
Ungasebenzisa ilimi ofuna ukulisebenzisa bewulandele nesiko ozikhethela lona.

 Unelungelo lokusebenzisa ilimi olithandako bewenze nesiko lakho.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Imiphakathi yamaSiko, yeKolo nemaLimi==
Imiphakathi ingazithabisa ngamasiko wayo; balandele ikolwabo bebasebenzise
ilimi labo.

 Unelungelo lokuthoma, lokujoyina nelogcina isiko, ilimi kanye nesiqhema sekolo osithandako.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ukufumana ilwazi==
Unelungelo lelinye nelinye ilwazi urhulumende analo

 Ungafumana elinye nelinye ilwazi eliphethwe mbuso ukuvikela amalungelwakho.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ukuphatha ngokusemthethweni==
Izenzo zakarhulumende kufanele zibe ngezilungileko 

 Unelungelo lezenzo ezisemthethweni, ezizwakalako nezilungileko akarhulumende.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ukungena emaKhotho==
Umrarwakho wangokomthetho ungathathelwa isiqunto yikhotho namkha isakhiwo esifanako.

 Unelungelo lokurarulula imiraro yangokomthetho ekhotho namkha ebandleni elingakabandanyeki bunqopha elirarulula imiraro.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Abantu ababotjhiweko nabathweswe umlandu==
Ilungelweli livikela abantu ababotjhiweko nabavalelwe esikhungweni namkha abathweswe umlandu.

 Nawubotjhiweko unelungelo okungakhulumi, lokulethwa ngaphambi kwekhotho ema-irini ama-48 kanye nelungelo lokujanyelwa ngokomthetho.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>osu8poe2wyqj79wb27k7pcfgf8vxo9e</sha1>
    </revision>
    <revision>
      <id>528</id>
      <parentid>527</parentid>
      <timestamp>2024-03-09T07:26:36Z</timestamp>
      <contributor>
        <username>incubator&gt;Mbandeni</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Linked to another article</comment>
      <origin>528</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7116" sha1="0lbew9d5gmfuiklcjktzign74h878xq" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo senarha ye [[Isewula Afrika|Sewula Afrika]] begodu isihloko le sihlathulula indlela bona amalungelo la asebenza ngayo namkha angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[https://web.archive.org/web/20160305192903/http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[https://web.archive.org/web/20160306031920/http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe.

 Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.&lt;ref name=ph3&gt;&quot;[https://web.archive.org/web/20160329070107/http://www.justice.gov.za/legislation/constitution/bor/BillofRights50thAnniversary-Ndebele.pdf Bill of Rights 50&lt;sup&gt;th&lt;/sup&gt; Anniversary]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe. Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipilo==
Unelungelo lepilo.

 Boke abantu banelungelo lokuphila.&lt;ref name=ph3&gt;&lt;/ref&gt;
irhelebho nanyana ngiliphi ongalithola ukuze uphile.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejeziswa kumbi. Ukutlhoriswa kwemakhaya akukavunyelwa.

 Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa ngananyana ngiyiphi indlela.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa.

 Akakafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa.

 Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.&lt;ref name=ph3&gt;&lt;/ref&gt;

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako.

 Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.&lt;ref name=ph3&gt;&lt;/ref&gt;

== Ukuvuza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako.

 Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yenzondo ayikavunyelwa.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula.

 Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako.

 Unelungelo lokuhlangana nananyana ngubani.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda.

 Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhetweni atjhaphulukileko nangasolisiko.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ubakhamuzi==
Ubakhamuzi bakho ngeze basuswa kuwe.

 Asikho isakhamuzi ekufuze sithathelwe ubakhamuzi baso.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanyana kukuphi eRiphabhliki yeSewula Afrika.

 Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako.

 Unelungel lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Itjhebiswano kezemisebenzi==
Ungajoyina amayuniyoni bewutoyitoye 

 Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana kuphumelelisa iminqopho yabo.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ibhoduluko==
Unelungelo lebhoduluko elinepilo.

 Unelungelo lokuhlala ebhodulukweni elivikelekileko nelinepilo.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ipahla==
Ungathathelwa ipahlakho nangabe imithetho efaneleko ilandelwe.

 Akekho ongathathelwa ipahla ngaphandle kwemibandela yomthetho okusetjenziswa okuvamileko.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Izindlu==
Urhulumende kufanele enze isiqiniseko sokobana abantu bafumana ukungena
okufaneleko eendlini..

 Ninelungelo lokufumana izidlu ezaneleko.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==
Urhulumende kufanele enze isiqiniseko sokobana nifumana ukudla namanzi, itjhejo lezePilo kanye nokuPhepha emphakathini.

 Unelungelo letjhejo lezepilo, ukudla namanzi aneleko kanye nokuphepha emphakathini.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Abantwana==
Abantwana abangaphasi kweminyaka eli-18 banamalungelo akhethekileko njengelungelo lokungatlhoriswa.

 Woke umntwana unelungelo lebizo, lobutjhaba kanye nelokuvikelwa ekutlhorisweni nekusetjenzisweni ngokungakafaneli.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ifundo==
Unelungelo lefundo esisekelo, kubalwa nefundo esisekelo yabadala ngelimi lakho (nangabekuyakghonakala)

 Unelungelo lefundo esisekelo ngelimi elisemthethweni olithandako.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ilimi nesiko==
Ungasebenzisa ilimi ofuna ukulisebenzisa bewulandele nesiko ozikhethela lona.

 Unelungelo lokusebenzisa ilimi olithandako bewenze nesiko lakho.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Imiphakathi yamaSiko, yeKolo nemaLimi==
Imiphakathi ingazithabisa ngamasiko wayo; balandele ikolwabo bebasebenzise
ilimi labo.

 Unelungelo lokuthoma, lokujoyina nelogcina isiko, ilimi kanye nesiqhema sekolo osithandako.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ukufumana ilwazi==
Unelungelo lelinye nelinye ilwazi urhulumende analo

 Ungafumana elinye nelinye ilwazi eliphethwe mbuso ukuvikela amalungelwakho.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ukuphatha ngokusemthethweni==
Izenzo zakarhulumende kufanele zibe ngezilungileko 

 Unelungelo lezenzo ezisemthethweni, ezizwakalako nezilungileko akarhulumende.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Ukungena emaKhotho==
Umrarwakho wangokomthetho ungathathelwa isiqunto yikhotho namkha isakhiwo esifanako.

 Unelungelo lokurarulula imiraro yangokomthetho ekhotho namkha ebandleni elingakabandanyeki bunqopha elirarulula imiraro.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Abantu ababotjhiweko nabathweswe umlandu==
Ilungelweli livikela abantu ababotjhiweko nabavalelwe esikhungweni namkha abathweswe umlandu.

 Nawubotjhiweko unelungelo okungakhulumi, lokulethwa ngaphambi kwekhotho ema-irini ama-48 kanye nelungelo lokujanyelwa ngokomthetho.&lt;ref name=ph3&gt;&lt;/ref&gt;

==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>0lbew9d5gmfuiklcjktzign74h878xq</sha1>
    </revision>
    <revision>
      <id>529</id>
      <parentid>528</parentid>
      <timestamp>2024-03-10T20:26:32Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>529</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7117" sha1="hu9xsmseyr7nmqr8ivynk823p86kruw" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo senarha ye [[Isewula Afrika|Sewula Afrika]] begodu isihloko le sihlathulula indlela bona amalungelo la asebenza ngayo namkha angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[https://web.archive.org/web/20160305192903/http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[https://web.archive.org/web/20160306031920/http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe. Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.&lt;ref name=&quot;ph3&quot;&gt;&quot;[https://web.archive.org/web/20160329070107/http://www.justice.gov.za/legislation/constitution/bor/BillofRights50thAnniversary-Ndebele.pdf Bill of Rights 50&lt;sup&gt;th&lt;/sup&gt; Anniversary]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe. Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipilo==
Unelungelo lepilo. Boke abantu banelungelo lokuphila.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

irhelebho nanyana ngiliphi ongalithola ukuze uphile.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejeziswa kumbi. Ukutlhoriswa kwemakhaya akukavunyelwa. Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa ngananyana ngiyiphi indlela.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa. Akakafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa. Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako. Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

== Ukuvuza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako. Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yenzondo ayikavunyelwa.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula. Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako. Unelungelo lokuhlangana nananyana ngubani.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda. Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhetweni atjhaphulukileko nangasolisiko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ubakhamuzi==
Ubakhamuzi bakho ngeze basuswa kuwe. Asikho isakhamuzi ekufuze sithathelwe ubakhamuzi baso.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanyana kukuphi eRiphabhliki yeSewula Afrika. Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako. Unelungel lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhebiswano kezemisebenzi==
Ungajoyina amayuniyoni bewutoyitoye Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana kuphumelelisa iminqopho yabo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt; 

==Ibhoduluko==
Unelungelo lebhoduluko elinepilo. Unelungelo lokuhlala ebhodulukweni elivikelekileko nelinepilo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipahla==
Ungathathelwa ipahlakho nangabe imithetho efaneleko ilandelwe. Akekho ongathathelwa ipahla ngaphandle kwemibandela yomthetho okusetjenziswa okuvamileko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Izindlu==
Urhulumende kufanele enze isiqiniseko sokobana abantu bafumana ukungena
okufaneleko eendlini.. Ninelungelo lokufumana izidlu ezaneleko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==
Urhulumende kufanele enze isiqiniseko sokobana nifumana ukudla namanzi, itjhejo lezePilo kanye nokuPhepha emphakathini. Unelungelo letjhejo lezepilo, ukudla namanzi aneleko kanye nokuphepha emphakathini.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Abantwana==
Abantwana abangaphasi kweminyaka eli-18 banamalungelo akhethekileko njengelungelo lokungatlhoriswa. Woke umntwana unelungelo lebizo, lobutjhaba kanye nelokuvikelwa ekutlhorisweni nekusetjenzisweni ngokungakafaneli.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ifundo==
Unelungelo lefundo esisekelo, kubalwa nefundo esisekelo yabadala ngelimi lakho (nangabekuyakghonakala) Unelungelo lefundo esisekelo ngelimi elisemthethweni olithandako.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ilimi nesiko==
Ungasebenzisa ilimi ofuna ukulisebenzisa bewulandele nesiko ozikhethela lona. Unelungelo lokusebenzisa ilimi olithandako bewenze nesiko lakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Imiphakathi yamaSiko, yeKolo nemaLimi==
Imiphakathi ingazithabisa ngamasiko wayo; balandele ikolwabo bebasebenzise
ilimi labo. Unelungelo lokuthoma, lokujoyina nelogcina isiko, ilimi kanye nesiqhema sekolo osithandako.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukufumana ilwazi==
Unelungelo lelinye nelinye ilwazi urhulumende analo Ungafumana elinye nelinye ilwazi eliphethwe mbuso ukuvikela amalungelwakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuphatha ngokusemthethweni==
Izenzo zakarhulumende kufanele zibe ngezilungileko Unelungelo lezenzo ezisemthethweni, ezizwakalako nezilungileko akarhulumende.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt; 

==Ukungena emaKhotho==
Umrarwakho wangokomthetho ungathathelwa isiqunto yikhotho namkha isakhiwo esifanako. Unelungelo lokurarulula imiraro yangokomthetho ekhotho namkha ebandleni elingakabandanyeki bunqopha elirarulula imiraro.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Abantu ababotjhiweko nabathweswe umlandu==
Ilungelweli livikela abantu ababotjhiweko nabavalelwe esikhungweni namkha abathweswe umlandu. Nawubotjhiweko unelungelo okungakhulumi, lokulethwa ngaphambi kwekhotho ema-irini ama-48 kanye nelungelo lokujanyelwa ngokomthetho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>hu9xsmseyr7nmqr8ivynk823p86kruw</sha1>
    </revision>
    <revision>
      <id>530</id>
      <parentid>529</parentid>
      <timestamp>2024-03-10T20:27:58Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Adding interwiki links to [[d:Q8458]]</comment>
      <origin>530</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7137" sha1="ewi27nqfyettpu57iidyfkqacps3dm6" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo senarha ye [[Isewula Afrika|Sewula Afrika]] begodu isihloko le sihlathulula indlela bona amalungelo la asebenza ngayo namkha angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[https://web.archive.org/web/20160305192903/http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[https://web.archive.org/web/20160306031920/http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe. Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.&lt;ref name=&quot;ph3&quot;&gt;&quot;[https://web.archive.org/web/20160329070107/http://www.justice.gov.za/legislation/constitution/bor/BillofRights50thAnniversary-Ndebele.pdf Bill of Rights 50&lt;sup&gt;th&lt;/sup&gt; Anniversary]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe. Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipilo==
Unelungelo lepilo. Boke abantu banelungelo lokuphila.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

irhelebho nanyana ngiliphi ongalithola ukuze uphile.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejeziswa kumbi. Ukutlhoriswa kwemakhaya akukavunyelwa. Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa ngananyana ngiyiphi indlela.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa. Akakafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa. Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako. Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

== Ukuvuza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako. Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yenzondo ayikavunyelwa.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula. Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako. Unelungelo lokuhlangana nananyana ngubani.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda. Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhetweni atjhaphulukileko nangasolisiko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ubakhamuzi==
Ubakhamuzi bakho ngeze basuswa kuwe. Asikho isakhamuzi ekufuze sithathelwe ubakhamuzi baso.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanyana kukuphi eRiphabhliki yeSewula Afrika. Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako. Unelungel lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhebiswano kezemisebenzi==
Ungajoyina amayuniyoni bewutoyitoye Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana kuphumelelisa iminqopho yabo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt; 

==Ibhoduluko==
Unelungelo lebhoduluko elinepilo. Unelungelo lokuhlala ebhodulukweni elivikelekileko nelinepilo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipahla==
Ungathathelwa ipahlakho nangabe imithetho efaneleko ilandelwe. Akekho ongathathelwa ipahla ngaphandle kwemibandela yomthetho okusetjenziswa okuvamileko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Izindlu==
Urhulumende kufanele enze isiqiniseko sokobana abantu bafumana ukungena
okufaneleko eendlini.. Ninelungelo lokufumana izidlu ezaneleko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==
Urhulumende kufanele enze isiqiniseko sokobana nifumana ukudla namanzi, itjhejo lezePilo kanye nokuPhepha emphakathini. Unelungelo letjhejo lezepilo, ukudla namanzi aneleko kanye nokuphepha emphakathini.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Abantwana==
Abantwana abangaphasi kweminyaka eli-18 banamalungelo akhethekileko njengelungelo lokungatlhoriswa. Woke umntwana unelungelo lebizo, lobutjhaba kanye nelokuvikelwa ekutlhorisweni nekusetjenzisweni ngokungakafaneli.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ifundo==
Unelungelo lefundo esisekelo, kubalwa nefundo esisekelo yabadala ngelimi lakho (nangabekuyakghonakala) Unelungelo lefundo esisekelo ngelimi elisemthethweni olithandako.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ilimi nesiko==
Ungasebenzisa ilimi ofuna ukulisebenzisa bewulandele nesiko ozikhethela lona. Unelungelo lokusebenzisa ilimi olithandako bewenze nesiko lakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Imiphakathi yamaSiko, yeKolo nemaLimi==
Imiphakathi ingazithabisa ngamasiko wayo; balandele ikolwabo bebasebenzise
ilimi labo. Unelungelo lokuthoma, lokujoyina nelogcina isiko, ilimi kanye nesiqhema sekolo osithandako.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukufumana ilwazi==
Unelungelo lelinye nelinye ilwazi urhulumende analo Ungafumana elinye nelinye ilwazi eliphethwe mbuso ukuvikela amalungelwakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuphatha ngokusemthethweni==
Izenzo zakarhulumende kufanele zibe ngezilungileko Unelungelo lezenzo ezisemthethweni, ezizwakalako nezilungileko akarhulumende.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt; 

==Ukungena emaKhotho==
Umrarwakho wangokomthetho ungathathelwa isiqunto yikhotho namkha isakhiwo esifanako. Unelungelo lokurarulula imiraro yangokomthetho ekhotho namkha ebandleni elingakabandanyeki bunqopha elirarulula imiraro.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Abantu ababotjhiweko nabathweswe umlandu==
Ilungelweli livikela abantu ababotjhiweko nabavalelwe esikhungweni namkha abathweswe umlandu. Nawubotjhiweko unelungelo okungakhulumi, lokulethwa ngaphambi kwekhotho ema-irini ama-48 kanye nelungelo lokujanyelwa ngokomthetho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Isithasiselo==
&lt;references/&gt;


{{INTERWIKI|Q8458}}</text>
      <sha1>ewi27nqfyettpu57iidyfkqacps3dm6</sha1>
    </revision>
    <revision>
      <id>531</id>
      <parentid>530</parentid>
      <timestamp>2024-03-11T12:50:47Z</timestamp>
      <contributor>
        <ip>102.33.220.50</ip>
      </contributor>
      <comment>added a reference.</comment>
      <origin>531</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7425" sha1="i920ihwu7tlvswogk0foau2uis1mx96" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo senarha ye [[Isewula Afrika|Sewula Afrika]] begodu isihloko le sihlathulula indlela bona amalungelo la asebenza ngayo namkha angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[https://web.archive.org/web/20160305192903/http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala eriphabliki yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[https://web.archive.org/web/20160306031920/http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;&lt;ref&gt;[https://www.un.org/en/global-issues/human-rights#:~:text=Human%20rights%20are%20rights%20inherent,and%20education%2C%20and%20many%20more. https://www.un.org/en/global-issues/human-rights#:~:text=Human%20rights%20are%20rights%20inherent,and%20education%2C%20and%20many%20more.]&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe. Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.&lt;ref name=&quot;ph3&quot;&gt;&quot;[https://web.archive.org/web/20160329070107/http://www.justice.gov.za/legislation/constitution/bor/BillofRights50thAnniversary-Ndebele.pdf Bill of Rights 50&lt;sup&gt;th&lt;/sup&gt; Anniversary]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe. Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipilo==
Unelungelo lepilo. Boke abantu banelungelo lokuphila.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

irhelebho nanyana ngiliphi ongalithola ukuze uphile.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejeziswa kumbi. Ukutlhoriswa kwemakhaya akukavunyelwa. Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa ngananyana ngiyiphi indlela.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa. Akakafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa. Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako. Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

== Ukuvuza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako. Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yenzondo ayikavunyelwa.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula. Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako. Unelungelo lokuhlangana nananyana ngubani.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda. Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhetweni atjhaphulukileko nangasolisiko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ubakhamuzi==
Ubakhamuzi bakho ngeze basuswa kuwe. Asikho isakhamuzi ekufuze sithathelwe ubakhamuzi baso.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanyana kukuphi eRiphabhliki yeSewula Afrika. Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako. Unelungel lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhebiswano kezemisebenzi==
Ungajoyina amayuniyoni bewutoyitoye Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana kuphumelelisa iminqopho yabo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt; 

==Ibhoduluko==
Unelungelo lebhoduluko elinepilo. Unelungelo lokuhlala ebhodulukweni elivikelekileko nelinepilo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipahla==
Ungathathelwa ipahlakho nangabe imithetho efaneleko ilandelwe. Akekho ongathathelwa ipahla ngaphandle kwemibandela yomthetho okusetjenziswa okuvamileko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Izindlu==
Urhulumende kufanele enze isiqiniseko sokobana abantu bafumana ukungena
okufaneleko eendlini.. Ninelungelo lokufumana izidlu ezaneleko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==
Urhulumende kufanele enze isiqiniseko sokobana nifumana ukudla namanzi, itjhejo lezePilo kanye nokuPhepha emphakathini. Unelungelo letjhejo lezepilo, ukudla namanzi aneleko kanye nokuphepha emphakathini.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Abantwana==
Abantwana abangaphasi kweminyaka eli-18 banamalungelo akhethekileko njengelungelo lokungatlhoriswa. Woke umntwana unelungelo lebizo, lobutjhaba kanye nelokuvikelwa ekutlhorisweni nekusetjenzisweni ngokungakafaneli.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ifundo==
Unelungelo lefundo esisekelo, kubalwa nefundo esisekelo yabadala ngelimi lakho (nangabekuyakghonakala) Unelungelo lefundo esisekelo ngelimi elisemthethweni olithandako.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ilimi nesiko==
Ungasebenzisa ilimi ofuna ukulisebenzisa bewulandele nesiko ozikhethela lona. Unelungelo lokusebenzisa ilimi olithandako bewenze nesiko lakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Imiphakathi yamaSiko, yeKolo nemaLimi==
Imiphakathi ingazithabisa ngamasiko wayo; balandele ikolwabo bebasebenzise
ilimi labo. Unelungelo lokuthoma, lokujoyina nelogcina isiko, ilimi kanye nesiqhema sekolo osithandako.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukufumana ilwazi==
Unelungelo lelinye nelinye ilwazi urhulumende analo Ungafumana elinye nelinye ilwazi eliphethwe mbuso ukuvikela amalungelwakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuphatha ngokusemthethweni==
Izenzo zakarhulumende kufanele zibe ngezilungileko Unelungelo lezenzo ezisemthethweni, ezizwakalako nezilungileko akarhulumende.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt; 

==Ukungena emaKhotho==
Umrarwakho wangokomthetho ungathathelwa isiqunto yikhotho namkha isakhiwo esifanako. Unelungelo lokurarulula imiraro yangokomthetho ekhotho namkha ebandleni elingakabandanyeki bunqopha elirarulula imiraro.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Abantu ababotjhiweko nabathweswe umlandu==
Ilungelweli livikela abantu ababotjhiweko nabavalelwe esikhungweni namkha abathweswe umlandu. Nawubotjhiweko unelungelo okungakhulumi, lokulethwa ngaphambi kwekhotho ema-irini ama-48 kanye nelungelo lokujanyelwa ngokomthetho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Isithasiselo==
&lt;references/&gt;


{{INTERWIKI|Q8458}}</text>
      <sha1>i920ihwu7tlvswogk0foau2uis1mx96</sha1>
    </revision>
    <revision>
      <id>532</id>
      <parentid>531</parentid>
      <timestamp>2024-07-25T13:57:16Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>532</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7422" sha1="hr4j5122g7ym1nrwiqxii3wvkmpxd7d" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo senarha ye [[Isewula Afrika|Sewula Afrika]] begodu isihloko le sihlathulula indlela bona amalungelo la asebenza ngayo namkha angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[https://web.archive.org/web/20160305192903/http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala enarheni yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[https://web.archive.org/web/20160306031920/http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;&lt;ref&gt;[https://www.un.org/en/global-issues/human-rights#:~:text=Human%20rights%20are%20rights%20inherent,and%20education%2C%20and%20many%20more. https://www.un.org/en/global-issues/human-rights#:~:text=Human%20rights%20are%20rights%20inherent,and%20education%2C%20and%20many%20more.]&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe. Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.&lt;ref name=&quot;ph3&quot;&gt;&quot;[https://web.archive.org/web/20160329070107/http://www.justice.gov.za/legislation/constitution/bor/BillofRights50thAnniversary-Ndebele.pdf Bill of Rights 50&lt;sup&gt;th&lt;/sup&gt; Anniversary]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe. Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipilo==
Unelungelo lepilo. Boke abantu banelungelo lokuphila.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

irhelebho nanyana ngiliphi ongalithola ukuze uphile.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejeziswa kumbi. Ukutlhoriswa kwemakhaya akukavunyelwa. Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa ngananyana ngiyiphi indlela.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa. Akakafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa. Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako. Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

== Ukuvuza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako. Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yenzondo ayikavunyelwa.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula. Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako. Unelungelo lokuhlangana nananyana ngubani.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda. Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhetweni atjhaphulukileko nangasolisiko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ubakhamuzi==
Ubakhamuzi bakho ngeze basuswa kuwe. Asikho isakhamuzi ekufuze sithathelwe ubakhamuzi baso.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanyana kukuphi eRiphabhliki yeSewula Afrika. Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako. Unelungel lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhebiswano kezemisebenzi==
Ungajoyina amayuniyoni bewutoyitoye Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana kuphumelelisa iminqopho yabo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt; 

==Ibhoduluko==
Unelungelo lebhoduluko elinepilo. Unelungelo lokuhlala ebhodulukweni elivikelekileko nelinepilo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipahla==
Ungathathelwa ipahlakho nangabe imithetho efaneleko ilandelwe. Akekho ongathathelwa ipahla ngaphandle kwemibandela yomthetho okusetjenziswa okuvamileko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Izindlu==
Urhulumende kufanele enze isiqiniseko sokobana abantu bafumana ukungena
okufaneleko eendlini.. Ninelungelo lokufumana izidlu ezaneleko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==
Urhulumende kufanele enze isiqiniseko sokobana nifumana ukudla namanzi, itjhejo lezePilo kanye nokuPhepha emphakathini. Unelungelo letjhejo lezepilo, ukudla namanzi aneleko kanye nokuphepha emphakathini.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Abantwana==
Abantwana abangaphasi kweminyaka eli-18 banamalungelo akhethekileko njengelungelo lokungatlhoriswa. Woke umntwana unelungelo lebizo, lobutjhaba kanye nelokuvikelwa ekutlhorisweni nekusetjenzisweni ngokungakafaneli.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ifundo==
Unelungelo lefundo esisekelo, kubalwa nefundo esisekelo yabadala ngelimi lakho (nangabekuyakghonakala) Unelungelo lefundo esisekelo ngelimi elisemthethweni olithandako.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ilimi nesiko==
Ungasebenzisa ilimi ofuna ukulisebenzisa bewulandele nesiko ozikhethela lona. Unelungelo lokusebenzisa ilimi olithandako bewenze nesiko lakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Imiphakathi yamaSiko, yeKolo nemaLimi==
Imiphakathi ingazithabisa ngamasiko wayo; balandele ikolwabo bebasebenzise
ilimi labo. Unelungelo lokuthoma, lokujoyina nelogcina isiko, ilimi kanye nesiqhema sekolo osithandako.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukufumana ilwazi==
Unelungelo lelinye nelinye ilwazi urhulumende analo Ungafumana elinye nelinye ilwazi eliphethwe mbuso ukuvikela amalungelwakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuphatha ngokusemthethweni==
Izenzo zakarhulumende kufanele zibe ngezilungileko Unelungelo lezenzo ezisemthethweni, ezizwakalako nezilungileko akarhulumende.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt; 

==Ukungena emaKhotho==
Umrarwakho wangokomthetho ungathathelwa isiqunto yikhotho namkha isakhiwo esifanako. Unelungelo lokurarulula imiraro yangokomthetho ekhotho namkha ebandleni elingakabandanyeki bunqopha elirarulula imiraro.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Abantu ababotjhiweko nabathweswe umlandu==
Ilungelweli livikela abantu ababotjhiweko nabavalelwe esikhungweni namkha abathweswe umlandu. Nawubotjhiweko unelungelo okungakhulumi, lokulethwa ngaphambi kwekhotho ema-irini ama-48 kanye nelungelo lokujanyelwa ngokomthetho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Isithasiselo==
&lt;references/&gt;


{{INTERWIKI|Q8458}}</text>
      <sha1>hr4j5122g7ym1nrwiqxii3wvkmpxd7d</sha1>
    </revision>
    <revision>
      <id>533</id>
      <parentid>532</parentid>
      <timestamp>2024-07-25T14:01:30Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>/* Itjhaphuluko nokuPhepha komuntu */</comment>
      <origin>533</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7419" sha1="jo5pabpg5kgj7e1ulul3tpi277dbdv1" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo senarha ye [[Isewula Afrika|Sewula Afrika]] begodu isihloko le sihlathulula indlela bona amalungelo la asebenza ngayo namkha angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[https://web.archive.org/web/20160305192903/http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala enarheni yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[https://web.archive.org/web/20160306031920/http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;&lt;ref&gt;[https://www.un.org/en/global-issues/human-rights#:~:text=Human%20rights%20are%20rights%20inherent,and%20education%2C%20and%20many%20more. https://www.un.org/en/global-issues/human-rights#:~:text=Human%20rights%20are%20rights%20inherent,and%20education%2C%20and%20many%20more.]&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe. Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.&lt;ref name=&quot;ph3&quot;&gt;&quot;[https://web.archive.org/web/20160329070107/http://www.justice.gov.za/legislation/constitution/bor/BillofRights50thAnniversary-Ndebele.pdf Bill of Rights 50&lt;sup&gt;th&lt;/sup&gt; Anniversary]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe. Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipilo==
Unelungelo lepilo. Boke abantu banelungelo lokuphila.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

irhelebho nanyana ngiliphi ongalithola ukuze uphile.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejeziswa kumbi. Ukutlhoriswa kwemakhaya akukavumeleki. Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa nanyana ngiyiphi indlela.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa. Akakafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa. Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako. Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

== Ukuvuza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako. Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yenzondo ayikavunyelwa.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula. Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako. Unelungelo lokuhlangana nananyana ngubani.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda. Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhetweni atjhaphulukileko nangasolisiko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ubakhamuzi==
Ubakhamuzi bakho ngeze basuswa kuwe. Asikho isakhamuzi ekufuze sithathelwe ubakhamuzi baso.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanyana kukuphi eRiphabhliki yeSewula Afrika. Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako. Unelungel lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhebiswano kezemisebenzi==
Ungajoyina amayuniyoni bewutoyitoye Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana kuphumelelisa iminqopho yabo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt; 

==Ibhoduluko==
Unelungelo lebhoduluko elinepilo. Unelungelo lokuhlala ebhodulukweni elivikelekileko nelinepilo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipahla==
Ungathathelwa ipahlakho nangabe imithetho efaneleko ilandelwe. Akekho ongathathelwa ipahla ngaphandle kwemibandela yomthetho okusetjenziswa okuvamileko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Izindlu==
Urhulumende kufanele enze isiqiniseko sokobana abantu bafumana ukungena
okufaneleko eendlini.. Ninelungelo lokufumana izidlu ezaneleko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==
Urhulumende kufanele enze isiqiniseko sokobana nifumana ukudla namanzi, itjhejo lezePilo kanye nokuPhepha emphakathini. Unelungelo letjhejo lezepilo, ukudla namanzi aneleko kanye nokuphepha emphakathini.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Abantwana==
Abantwana abangaphasi kweminyaka eli-18 banamalungelo akhethekileko njengelungelo lokungatlhoriswa. Woke umntwana unelungelo lebizo, lobutjhaba kanye nelokuvikelwa ekutlhorisweni nekusetjenzisweni ngokungakafaneli.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ifundo==
Unelungelo lefundo esisekelo, kubalwa nefundo esisekelo yabadala ngelimi lakho (nangabekuyakghonakala) Unelungelo lefundo esisekelo ngelimi elisemthethweni olithandako.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ilimi nesiko==
Ungasebenzisa ilimi ofuna ukulisebenzisa bewulandele nesiko ozikhethela lona. Unelungelo lokusebenzisa ilimi olithandako bewenze nesiko lakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Imiphakathi yamaSiko, yeKolo nemaLimi==
Imiphakathi ingazithabisa ngamasiko wayo; balandele ikolwabo bebasebenzise
ilimi labo. Unelungelo lokuthoma, lokujoyina nelogcina isiko, ilimi kanye nesiqhema sekolo osithandako.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukufumana ilwazi==
Unelungelo lelinye nelinye ilwazi urhulumende analo Ungafumana elinye nelinye ilwazi eliphethwe mbuso ukuvikela amalungelwakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuphatha ngokusemthethweni==
Izenzo zakarhulumende kufanele zibe ngezilungileko Unelungelo lezenzo ezisemthethweni, ezizwakalako nezilungileko akarhulumende.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt; 

==Ukungena emaKhotho==
Umrarwakho wangokomthetho ungathathelwa isiqunto yikhotho namkha isakhiwo esifanako. Unelungelo lokurarulula imiraro yangokomthetho ekhotho namkha ebandleni elingakabandanyeki bunqopha elirarulula imiraro.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Abantu ababotjhiweko nabathweswe umlandu==
Ilungelweli livikela abantu ababotjhiweko nabavalelwe esikhungweni namkha abathweswe umlandu. Nawubotjhiweko unelungelo okungakhulumi, lokulethwa ngaphambi kwekhotho ema-irini ama-48 kanye nelungelo lokujanyelwa ngokomthetho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Isithasiselo==
&lt;references/&gt;


{{INTERWIKI|Q8458}}</text>
      <sha1>jo5pabpg5kgj7e1ulul3tpi277dbdv1</sha1>
    </revision>
    <revision>
      <id>534</id>
      <parentid>533</parentid>
      <timestamp>2024-07-25T14:03:06Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>/* Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako */</comment>
      <origin>534</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7419" sha1="7ncd3f6vb73oif8uuugpcarjskwka98" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo senarha ye [[Isewula Afrika|Sewula Afrika]] begodu isihloko le sihlathulula indlela bona amalungelo la asebenza ngayo namkha angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[https://web.archive.org/web/20160305192903/http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala enarheni yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[https://web.archive.org/web/20160306031920/http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;&lt;ref&gt;[https://www.un.org/en/global-issues/human-rights#:~:text=Human%20rights%20are%20rights%20inherent,and%20education%2C%20and%20many%20more. https://www.un.org/en/global-issues/human-rights#:~:text=Human%20rights%20are%20rights%20inherent,and%20education%2C%20and%20many%20more.]&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe. Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.&lt;ref name=&quot;ph3&quot;&gt;&quot;[https://web.archive.org/web/20160329070107/http://www.justice.gov.za/legislation/constitution/bor/BillofRights50thAnniversary-Ndebele.pdf Bill of Rights 50&lt;sup&gt;th&lt;/sup&gt; Anniversary]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe. Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipilo==
Unelungelo lepilo. Boke abantu banelungelo lokuphila.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

irhelebho nanyana ngiliphi ongalithola ukuze uphile.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejeziswa kumbi. Ukutlhoriswa kwemakhaya akukavumeleki. Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa nanyana ngiyiphi indlela.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa. Akukafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa. Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako. Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

== Ukuvuza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako. Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yenzondo ayikavunyelwa.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula. Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako. Unelungelo lokuhlangana nananyana ngubani.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda. Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhetweni atjhaphulukileko nangasolisiko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ubakhamuzi==
Ubakhamuzi bakho ngeze basuswa kuwe. Asikho isakhamuzi ekufuze sithathelwe ubakhamuzi baso.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanyana kukuphi eRiphabhliki yeSewula Afrika. Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako. Unelungel lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhebiswano kezemisebenzi==
Ungajoyina amayuniyoni bewutoyitoye Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana kuphumelelisa iminqopho yabo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt; 

==Ibhoduluko==
Unelungelo lebhoduluko elinepilo. Unelungelo lokuhlala ebhodulukweni elivikelekileko nelinepilo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipahla==
Ungathathelwa ipahlakho nangabe imithetho efaneleko ilandelwe. Akekho ongathathelwa ipahla ngaphandle kwemibandela yomthetho okusetjenziswa okuvamileko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Izindlu==
Urhulumende kufanele enze isiqiniseko sokobana abantu bafumana ukungena
okufaneleko eendlini.. Ninelungelo lokufumana izidlu ezaneleko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==
Urhulumende kufanele enze isiqiniseko sokobana nifumana ukudla namanzi, itjhejo lezePilo kanye nokuPhepha emphakathini. Unelungelo letjhejo lezepilo, ukudla namanzi aneleko kanye nokuphepha emphakathini.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Abantwana==
Abantwana abangaphasi kweminyaka eli-18 banamalungelo akhethekileko njengelungelo lokungatlhoriswa. Woke umntwana unelungelo lebizo, lobutjhaba kanye nelokuvikelwa ekutlhorisweni nekusetjenzisweni ngokungakafaneli.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ifundo==
Unelungelo lefundo esisekelo, kubalwa nefundo esisekelo yabadala ngelimi lakho (nangabekuyakghonakala) Unelungelo lefundo esisekelo ngelimi elisemthethweni olithandako.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ilimi nesiko==
Ungasebenzisa ilimi ofuna ukulisebenzisa bewulandele nesiko ozikhethela lona. Unelungelo lokusebenzisa ilimi olithandako bewenze nesiko lakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Imiphakathi yamaSiko, yeKolo nemaLimi==
Imiphakathi ingazithabisa ngamasiko wayo; balandele ikolwabo bebasebenzise
ilimi labo. Unelungelo lokuthoma, lokujoyina nelogcina isiko, ilimi kanye nesiqhema sekolo osithandako.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukufumana ilwazi==
Unelungelo lelinye nelinye ilwazi urhulumende analo Ungafumana elinye nelinye ilwazi eliphethwe mbuso ukuvikela amalungelwakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuphatha ngokusemthethweni==
Izenzo zakarhulumende kufanele zibe ngezilungileko Unelungelo lezenzo ezisemthethweni, ezizwakalako nezilungileko akarhulumende.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt; 

==Ukungena emaKhotho==
Umrarwakho wangokomthetho ungathathelwa isiqunto yikhotho namkha isakhiwo esifanako. Unelungelo lokurarulula imiraro yangokomthetho ekhotho namkha ebandleni elingakabandanyeki bunqopha elirarulula imiraro.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Abantu ababotjhiweko nabathweswe umlandu==
Ilungelweli livikela abantu ababotjhiweko nabavalelwe esikhungweni namkha abathweswe umlandu. Nawubotjhiweko unelungelo okungakhulumi, lokulethwa ngaphambi kwekhotho ema-irini ama-48 kanye nelungelo lokujanyelwa ngokomthetho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Isithasiselo==
&lt;references/&gt;


{{INTERWIKI|Q8458}}</text>
      <sha1>7ncd3f6vb73oif8uuugpcarjskwka98</sha1>
    </revision>
    <revision>
      <id>535</id>
      <parentid>534</parentid>
      <timestamp>2024-07-25T14:07:55Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>/* Ukuvuza imibono ngokutjhaphuluka */</comment>
      <origin>535</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7418" sha1="tficl63qx6prvc24z76o4p1hf1uht5t" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo senarha ye [[Isewula Afrika|Sewula Afrika]] begodu isihloko le sihlathulula indlela bona amalungelo la asebenza ngayo namkha angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[https://web.archive.org/web/20160305192903/http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala enarheni yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[https://web.archive.org/web/20160306031920/http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;&lt;ref&gt;[https://www.un.org/en/global-issues/human-rights#:~:text=Human%20rights%20are%20rights%20inherent,and%20education%2C%20and%20many%20more. https://www.un.org/en/global-issues/human-rights#:~:text=Human%20rights%20are%20rights%20inherent,and%20education%2C%20and%20many%20more.]&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe. Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.&lt;ref name=&quot;ph3&quot;&gt;&quot;[https://web.archive.org/web/20160329070107/http://www.justice.gov.za/legislation/constitution/bor/BillofRights50thAnniversary-Ndebele.pdf Bill of Rights 50&lt;sup&gt;th&lt;/sup&gt; Anniversary]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe. Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipilo==
Unelungelo lepilo. Boke abantu banelungelo lokuphila.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

irhelebho nanyana ngiliphi ongalithola ukuze uphile.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejeziswa kumbi. Ukutlhoriswa kwemakhaya akukavumeleki. Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa nanyana ngiyiphi indlela.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa. Akukafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa. Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako. Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

== Ukuveza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako. Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yezondo ayikavunyelwa.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula. Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako. Unelungelo lokuhlangana nananyana ngubani.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda. Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhetweni atjhaphulukileko nangasolisiko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ubakhamuzi==
Ubakhamuzi bakho ngeze basuswa kuwe. Asikho isakhamuzi ekufuze sithathelwe ubakhamuzi baso.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanyana kukuphi eRiphabhliki yeSewula Afrika. Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako. Unelungel lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhebiswano kezemisebenzi==
Ungajoyina amayuniyoni bewutoyitoye Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana kuphumelelisa iminqopho yabo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt; 

==Ibhoduluko==
Unelungelo lebhoduluko elinepilo. Unelungelo lokuhlala ebhodulukweni elivikelekileko nelinepilo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipahla==
Ungathathelwa ipahlakho nangabe imithetho efaneleko ilandelwe. Akekho ongathathelwa ipahla ngaphandle kwemibandela yomthetho okusetjenziswa okuvamileko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Izindlu==
Urhulumende kufanele enze isiqiniseko sokobana abantu bafumana ukungena
okufaneleko eendlini.. Ninelungelo lokufumana izidlu ezaneleko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==
Urhulumende kufanele enze isiqiniseko sokobana nifumana ukudla namanzi, itjhejo lezePilo kanye nokuPhepha emphakathini. Unelungelo letjhejo lezepilo, ukudla namanzi aneleko kanye nokuphepha emphakathini.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Abantwana==
Abantwana abangaphasi kweminyaka eli-18 banamalungelo akhethekileko njengelungelo lokungatlhoriswa. Woke umntwana unelungelo lebizo, lobutjhaba kanye nelokuvikelwa ekutlhorisweni nekusetjenzisweni ngokungakafaneli.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ifundo==
Unelungelo lefundo esisekelo, kubalwa nefundo esisekelo yabadala ngelimi lakho (nangabekuyakghonakala) Unelungelo lefundo esisekelo ngelimi elisemthethweni olithandako.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ilimi nesiko==
Ungasebenzisa ilimi ofuna ukulisebenzisa bewulandele nesiko ozikhethela lona. Unelungelo lokusebenzisa ilimi olithandako bewenze nesiko lakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Imiphakathi yamaSiko, yeKolo nemaLimi==
Imiphakathi ingazithabisa ngamasiko wayo; balandele ikolwabo bebasebenzise
ilimi labo. Unelungelo lokuthoma, lokujoyina nelogcina isiko, ilimi kanye nesiqhema sekolo osithandako.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukufumana ilwazi==
Unelungelo lelinye nelinye ilwazi urhulumende analo Ungafumana elinye nelinye ilwazi eliphethwe mbuso ukuvikela amalungelwakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuphatha ngokusemthethweni==
Izenzo zakarhulumende kufanele zibe ngezilungileko Unelungelo lezenzo ezisemthethweni, ezizwakalako nezilungileko akarhulumende.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt; 

==Ukungena emaKhotho==
Umrarwakho wangokomthetho ungathathelwa isiqunto yikhotho namkha isakhiwo esifanako. Unelungelo lokurarulula imiraro yangokomthetho ekhotho namkha ebandleni elingakabandanyeki bunqopha elirarulula imiraro.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Abantu ababotjhiweko nabathweswe umlandu==
Ilungelweli livikela abantu ababotjhiweko nabavalelwe esikhungweni namkha abathweswe umlandu. Nawubotjhiweko unelungelo okungakhulumi, lokulethwa ngaphambi kwekhotho ema-irini ama-48 kanye nelungelo lokujanyelwa ngokomthetho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Isithasiselo==
&lt;references/&gt;


{{INTERWIKI|Q8458}}</text>
      <sha1>tficl63qx6prvc24z76o4p1hf1uht5t</sha1>
    </revision>
    <revision>
      <id>536</id>
      <parentid>535</parentid>
      <timestamp>2024-10-14T13:46:33Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>47 revisions imported</comment>
      <origin>535</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7418" sha1="tficl63qx6prvc24z76o4p1hf1uht5t" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo senarha ye [[Isewula Afrika|Sewula Afrika]] begodu isihloko le sihlathulula indlela bona amalungelo la asebenza ngayo namkha angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[https://web.archive.org/web/20160305192903/http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala enarheni yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[https://web.archive.org/web/20160306031920/http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;&lt;ref&gt;[https://www.un.org/en/global-issues/human-rights#:~:text=Human%20rights%20are%20rights%20inherent,and%20education%2C%20and%20many%20more. https://www.un.org/en/global-issues/human-rights#:~:text=Human%20rights%20are%20rights%20inherent,and%20education%2C%20and%20many%20more.]&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe. Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.&lt;ref name=&quot;ph3&quot;&gt;&quot;[https://web.archive.org/web/20160329070107/http://www.justice.gov.za/legislation/constitution/bor/BillofRights50thAnniversary-Ndebele.pdf Bill of Rights 50&lt;sup&gt;th&lt;/sup&gt; Anniversary]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe. Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipilo==
Unelungelo lepilo. Boke abantu banelungelo lokuphila.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

irhelebho nanyana ngiliphi ongalithola ukuze uphile.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejeziswa kumbi. Ukutlhoriswa kwemakhaya akukavumeleki. Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa nanyana ngiyiphi indlela.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa. Akukafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa. Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako. Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

== Ukuveza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako. Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yezondo ayikavunyelwa.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula. Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako. Unelungelo lokuhlangana nananyana ngubani.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda. Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhetweni atjhaphulukileko nangasolisiko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ubakhamuzi==
Ubakhamuzi bakho ngeze basuswa kuwe. Asikho isakhamuzi ekufuze sithathelwe ubakhamuzi baso.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanyana kukuphi eRiphabhliki yeSewula Afrika. Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako. Unelungel lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhebiswano kezemisebenzi==
Ungajoyina amayuniyoni bewutoyitoye Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana kuphumelelisa iminqopho yabo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt; 

==Ibhoduluko==
Unelungelo lebhoduluko elinepilo. Unelungelo lokuhlala ebhodulukweni elivikelekileko nelinepilo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipahla==
Ungathathelwa ipahlakho nangabe imithetho efaneleko ilandelwe. Akekho ongathathelwa ipahla ngaphandle kwemibandela yomthetho okusetjenziswa okuvamileko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Izindlu==
Urhulumende kufanele enze isiqiniseko sokobana abantu bafumana ukungena
okufaneleko eendlini.. Ninelungelo lokufumana izidlu ezaneleko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==
Urhulumende kufanele enze isiqiniseko sokobana nifumana ukudla namanzi, itjhejo lezePilo kanye nokuPhepha emphakathini. Unelungelo letjhejo lezepilo, ukudla namanzi aneleko kanye nokuphepha emphakathini.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Abantwana==
Abantwana abangaphasi kweminyaka eli-18 banamalungelo akhethekileko njengelungelo lokungatlhoriswa. Woke umntwana unelungelo lebizo, lobutjhaba kanye nelokuvikelwa ekutlhorisweni nekusetjenzisweni ngokungakafaneli.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ifundo==
Unelungelo lefundo esisekelo, kubalwa nefundo esisekelo yabadala ngelimi lakho (nangabekuyakghonakala) Unelungelo lefundo esisekelo ngelimi elisemthethweni olithandako.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ilimi nesiko==
Ungasebenzisa ilimi ofuna ukulisebenzisa bewulandele nesiko ozikhethela lona. Unelungelo lokusebenzisa ilimi olithandako bewenze nesiko lakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Imiphakathi yamaSiko, yeKolo nemaLimi==
Imiphakathi ingazithabisa ngamasiko wayo; balandele ikolwabo bebasebenzise
ilimi labo. Unelungelo lokuthoma, lokujoyina nelogcina isiko, ilimi kanye nesiqhema sekolo osithandako.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukufumana ilwazi==
Unelungelo lelinye nelinye ilwazi urhulumende analo Ungafumana elinye nelinye ilwazi eliphethwe mbuso ukuvikela amalungelwakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuphatha ngokusemthethweni==
Izenzo zakarhulumende kufanele zibe ngezilungileko Unelungelo lezenzo ezisemthethweni, ezizwakalako nezilungileko akarhulumende.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt; 

==Ukungena emaKhotho==
Umrarwakho wangokomthetho ungathathelwa isiqunto yikhotho namkha isakhiwo esifanako. Unelungelo lokurarulula imiraro yangokomthetho ekhotho namkha ebandleni elingakabandanyeki bunqopha elirarulula imiraro.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Abantu ababotjhiweko nabathweswe umlandu==
Ilungelweli livikela abantu ababotjhiweko nabavalelwe esikhungweni namkha abathweswe umlandu. Nawubotjhiweko unelungelo okungakhulumi, lokulethwa ngaphambi kwekhotho ema-irini ama-48 kanye nelungelo lokujanyelwa ngokomthetho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Isithasiselo==
&lt;references/&gt;


{{INTERWIKI|Q8458}}</text>
      <sha1>tficl63qx6prvc24z76o4p1hf1uht5t</sha1>
    </revision>
    <revision>
      <id>1665</id>
      <parentid>536</parentid>
      <timestamp>2024-10-16T09:49:42Z</timestamp>
      <contributor>
        <username>JhsBot</username>
        <id>34</id>
      </contributor>
      <minor />
      <comment>bot: Removing interwiki template; the page is now connected to [[d:Q8458]]</comment>
      <origin>1665</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7396" sha1="aimwk2lvgtg9jjdkp3ys02ms6chqarw" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo senarha ye [[Isewula Afrika|Sewula Afrika]] begodu isihloko le sihlathulula indlela bona amalungelo la asebenza ngayo namkha angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[https://web.archive.org/web/20160305192903/http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala enarheni yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[https://web.archive.org/web/20160306031920/http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;&lt;ref&gt;[https://www.un.org/en/global-issues/human-rights#:~:text=Human%20rights%20are%20rights%20inherent,and%20education%2C%20and%20many%20more. https://www.un.org/en/global-issues/human-rights#:~:text=Human%20rights%20are%20rights%20inherent,and%20education%2C%20and%20many%20more.]&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe. Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.&lt;ref name=&quot;ph3&quot;&gt;&quot;[https://web.archive.org/web/20160329070107/http://www.justice.gov.za/legislation/constitution/bor/BillofRights50thAnniversary-Ndebele.pdf Bill of Rights 50&lt;sup&gt;th&lt;/sup&gt; Anniversary]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe. Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipilo==
Unelungelo lepilo. Boke abantu banelungelo lokuphila.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

irhelebho nanyana ngiliphi ongalithola ukuze uphile.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejeziswa kumbi. Ukutlhoriswa kwemakhaya akukavumeleki. Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa nanyana ngiyiphi indlela.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa. Akukafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa. Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako. Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

== Ukuveza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako. Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yezondo ayikavunyelwa.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula. Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako. Unelungelo lokuhlangana nananyana ngubani.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda. Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhetweni atjhaphulukileko nangasolisiko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ubakhamuzi==
Ubakhamuzi bakho ngeze basuswa kuwe. Asikho isakhamuzi ekufuze sithathelwe ubakhamuzi baso.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanyana kukuphi eRiphabhliki yeSewula Afrika. Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako. Unelungel lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhebiswano kezemisebenzi==
Ungajoyina amayuniyoni bewutoyitoye Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana kuphumelelisa iminqopho yabo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt; 

==Ibhoduluko==
Unelungelo lebhoduluko elinepilo. Unelungelo lokuhlala ebhodulukweni elivikelekileko nelinepilo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipahla==
Ungathathelwa ipahlakho nangabe imithetho efaneleko ilandelwe. Akekho ongathathelwa ipahla ngaphandle kwemibandela yomthetho okusetjenziswa okuvamileko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Izindlu==
Urhulumende kufanele enze isiqiniseko sokobana abantu bafumana ukungena
okufaneleko eendlini.. Ninelungelo lokufumana izidlu ezaneleko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==
Urhulumende kufanele enze isiqiniseko sokobana nifumana ukudla namanzi, itjhejo lezePilo kanye nokuPhepha emphakathini. Unelungelo letjhejo lezepilo, ukudla namanzi aneleko kanye nokuphepha emphakathini.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Abantwana==
Abantwana abangaphasi kweminyaka eli-18 banamalungelo akhethekileko njengelungelo lokungatlhoriswa. Woke umntwana unelungelo lebizo, lobutjhaba kanye nelokuvikelwa ekutlhorisweni nekusetjenzisweni ngokungakafaneli.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ifundo==
Unelungelo lefundo esisekelo, kubalwa nefundo esisekelo yabadala ngelimi lakho (nangabekuyakghonakala) Unelungelo lefundo esisekelo ngelimi elisemthethweni olithandako.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ilimi nesiko==
Ungasebenzisa ilimi ofuna ukulisebenzisa bewulandele nesiko ozikhethela lona. Unelungelo lokusebenzisa ilimi olithandako bewenze nesiko lakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Imiphakathi yamaSiko, yeKolo nemaLimi==
Imiphakathi ingazithabisa ngamasiko wayo; balandele ikolwabo bebasebenzise
ilimi labo. Unelungelo lokuthoma, lokujoyina nelogcina isiko, ilimi kanye nesiqhema sekolo osithandako.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukufumana ilwazi==
Unelungelo lelinye nelinye ilwazi urhulumende analo Ungafumana elinye nelinye ilwazi eliphethwe mbuso ukuvikela amalungelwakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuphatha ngokusemthethweni==
Izenzo zakarhulumende kufanele zibe ngezilungileko Unelungelo lezenzo ezisemthethweni, ezizwakalako nezilungileko akarhulumende.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt; 

==Ukungena emaKhotho==
Umrarwakho wangokomthetho ungathathelwa isiqunto yikhotho namkha isakhiwo esifanako. Unelungelo lokurarulula imiraro yangokomthetho ekhotho namkha ebandleni elingakabandanyeki bunqopha elirarulula imiraro.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Abantu ababotjhiweko nabathweswe umlandu==
Ilungelweli livikela abantu ababotjhiweko nabavalelwe esikhungweni namkha abathweswe umlandu. Nawubotjhiweko unelungelo okungakhulumi, lokulethwa ngaphambi kwekhotho ema-irini ama-48 kanye nelungelo lokujanyelwa ngokomthetho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Isithasiselo==
&lt;references/&gt;</text>
      <sha1>aimwk2lvgtg9jjdkp3ys02ms6chqarw</sha1>
    </revision>
    <revision>
      <id>2202</id>
      <parentid>1665</parentid>
      <timestamp>2024-11-29T07:26:22Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <comment>/* Isithasiselo */Reflist</comment>
      <origin>2202</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7394" sha1="i5aktep4ncdmcmqtcb4zxsqimcerhpp" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo senarha ye [[Isewula Afrika|Sewula Afrika]] begodu isihloko le sihlathulula indlela bona amalungelo la asebenza ngayo namkha angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[https://web.archive.org/web/20160305192903/http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala enarheni yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[https://web.archive.org/web/20160306031920/http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;&lt;ref&gt;[https://www.un.org/en/global-issues/human-rights#:~:text=Human%20rights%20are%20rights%20inherent,and%20education%2C%20and%20many%20more. https://www.un.org/en/global-issues/human-rights#:~:text=Human%20rights%20are%20rights%20inherent,and%20education%2C%20and%20many%20more.]&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe. Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.&lt;ref name=&quot;ph3&quot;&gt;&quot;[https://web.archive.org/web/20160329070107/http://www.justice.gov.za/legislation/constitution/bor/BillofRights50thAnniversary-Ndebele.pdf Bill of Rights 50&lt;sup&gt;th&lt;/sup&gt; Anniversary]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe. Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipilo==
Unelungelo lepilo. Boke abantu banelungelo lokuphila.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

irhelebho nanyana ngiliphi ongalithola ukuze uphile.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejeziswa kumbi. Ukutlhoriswa kwemakhaya akukavumeleki. Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa nanyana ngiyiphi indlela.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa. Akukafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa. Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako. Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

== Ukuveza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako. Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yezondo ayikavunyelwa.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula. Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako. Unelungelo lokuhlangana nananyana ngubani.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda. Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhetweni atjhaphulukileko nangasolisiko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ubakhamuzi==
Ubakhamuzi bakho ngeze basuswa kuwe. Asikho isakhamuzi ekufuze sithathelwe ubakhamuzi baso.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanyana kukuphi eRiphabhliki yeSewula Afrika. Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako. Unelungel lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhebiswano kezemisebenzi==
Ungajoyina amayuniyoni bewutoyitoye Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana kuphumelelisa iminqopho yabo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt; 

==Ibhoduluko==
Unelungelo lebhoduluko elinepilo. Unelungelo lokuhlala ebhodulukweni elivikelekileko nelinepilo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipahla==
Ungathathelwa ipahlakho nangabe imithetho efaneleko ilandelwe. Akekho ongathathelwa ipahla ngaphandle kwemibandela yomthetho okusetjenziswa okuvamileko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Izindlu==
Urhulumende kufanele enze isiqiniseko sokobana abantu bafumana ukungena
okufaneleko eendlini.. Ninelungelo lokufumana izidlu ezaneleko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==
Urhulumende kufanele enze isiqiniseko sokobana nifumana ukudla namanzi, itjhejo lezePilo kanye nokuPhepha emphakathini. Unelungelo letjhejo lezepilo, ukudla namanzi aneleko kanye nokuphepha emphakathini.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Abantwana==
Abantwana abangaphasi kweminyaka eli-18 banamalungelo akhethekileko njengelungelo lokungatlhoriswa. Woke umntwana unelungelo lebizo, lobutjhaba kanye nelokuvikelwa ekutlhorisweni nekusetjenzisweni ngokungakafaneli.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ifundo==
Unelungelo lefundo esisekelo, kubalwa nefundo esisekelo yabadala ngelimi lakho (nangabekuyakghonakala) Unelungelo lefundo esisekelo ngelimi elisemthethweni olithandako.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ilimi nesiko==
Ungasebenzisa ilimi ofuna ukulisebenzisa bewulandele nesiko ozikhethela lona. Unelungelo lokusebenzisa ilimi olithandako bewenze nesiko lakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Imiphakathi yamaSiko, yeKolo nemaLimi==
Imiphakathi ingazithabisa ngamasiko wayo; balandele ikolwabo bebasebenzise
ilimi labo. Unelungelo lokuthoma, lokujoyina nelogcina isiko, ilimi kanye nesiqhema sekolo osithandako.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukufumana ilwazi==
Unelungelo lelinye nelinye ilwazi urhulumende analo Ungafumana elinye nelinye ilwazi eliphethwe mbuso ukuvikela amalungelwakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuphatha ngokusemthethweni==
Izenzo zakarhulumende kufanele zibe ngezilungileko Unelungelo lezenzo ezisemthethweni, ezizwakalako nezilungileko akarhulumende.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt; 

==Ukungena emaKhotho==
Umrarwakho wangokomthetho ungathathelwa isiqunto yikhotho namkha isakhiwo esifanako. Unelungelo lokurarulula imiraro yangokomthetho ekhotho namkha ebandleni elingakabandanyeki bunqopha elirarulula imiraro.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Abantu ababotjhiweko nabathweswe umlandu==
Ilungelweli livikela abantu ababotjhiweko nabavalelwe esikhungweni namkha abathweswe umlandu. Nawubotjhiweko unelungelo okungakhulumi, lokulethwa ngaphambi kwekhotho ema-irini ama-48 kanye nelungelo lokujanyelwa ngokomthetho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Isithasiselo==
{{Reflist}}</text>
      <sha1>i5aktep4ncdmcmqtcb4zxsqimcerhpp</sha1>
    </revision>
    <revision>
      <id>2899</id>
      <parentid>2202</parentid>
      <timestamp>2025-06-06T15:31:52Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>Flint and Steel</comment>
      <origin>2899</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7475" sha1="rypxgcv1hos2u83tmjmkpi3nxhtkq8x" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo senarha ye [[Isewula Afrika|Sewula Afrika]] begodu isihloko le sihlathulula indlela bona amalungelo la asebenza ngayo namkha angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[https://web.archive.org/web/20160305192903/http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala enarheni yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[https://web.archive.org/web/20160306031920/http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;&lt;ref&gt;[https://www.un.org/en/global-issues/human-rights#:~:text=Human%20rights%20are%20rights%20inherent,and%20education%2C%20and%20many%20more. https://www.un.org/en/global-issues/human-rights#:~:text=Human%20rights%20are%20rights%20inherent,and%20education%2C%20and%20many%20more.]&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe. Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.&lt;ref name=&quot;ph3&quot;&gt;&quot;[https://web.archive.org/web/20160329070107/http://www.justice.gov.za/legislation/constitution/bor/BillofRights50thAnniversary-Ndebele.pdf Bill of Rights 50&lt;sup&gt;th&lt;/sup&gt; Anniversary]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe. Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipilo==
Unelungelo lepilo. Boke abantu banelungelo lokuphila.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

irhelebho nanyana ngiliphi ongalithola ukuze uphile.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejeziswa kumbi. Ukutlhoriswa kwemakhaya akukavumeleki. Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa nanyana ngiyiphi indlela.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa. Akukafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa. Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako. Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

== Ukuveza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako. Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yezondo ayikavunyelwa.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula. Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako. Unelungelo lokuhlangana nananyana ngubani.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda. Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhetweni atjhaphulukileko nangasolisiko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ubakhamuzi==
Ubakhamuzi bakho ngeze basuswa kuwe. Asikho isakhamuzi ekufuze sithathelwe ubakhamuzi baso.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanyana kukuphi eRiphabhliki yeSewula Afrika. Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako. Unelungel lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhebiswano kezemisebenzi==
Ungajoyina amayuniyoni bewutoyitoye Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana kuphumelelisa iminqopho yabo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt; 

==Ibhoduluko==
Unelungelo lebhoduluko elinepilo. Unelungelo lokuhlala ebhodulukweni elivikelekileko nelinepilo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipahla==
Ungathathelwa ipahlakho nangabe imithetho efaneleko ilandelwe. Akekho ongathathelwa ipahla ngaphandle kwemibandela yomthetho okusetjenziswa okuvamileko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Izindlu==
Urhulumende kufanele enze isiqiniseko sokobana abantu bafumana ukungena
okufaneleko eendlini.. Ninelungelo lokufumana izidlu ezaneleko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==
Urhulumende kufanele enze isiqiniseko sokobana nifumana ukudla namanzi, itjhejo lezePilo kanye nokuPhepha emphakathini. Unelungelo letjhejo lezepilo, ukudla namanzi aneleko kanye nokuphepha emphakathini.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Abantwana==
Abantwana abangaphasi kweminyaka eli-18 banamalungelo akhethekileko njengelungelo lokungatlhoriswa. Woke umntwana unelungelo lebizo, lobutjhaba kanye nelokuvikelwa ekutlhorisweni nekusetjenzisweni ngokungakafaneli.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ifundo==
Unelungelo lefundo esisekelo, kubalwa nefundo esisekelo yabadala ngelimi lakho (nangabekuyakghonakala) Unelungelo lefundo esisekelo ngelimi elisemthethweni olithandako.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ilimi nesiko==
Ungasebenzisa ilimi ofuna ukulisebenzisa bewulandele nesiko ozikhethela lona. Unelungelo lokusebenzisa ilimi olithandako bewenze nesiko lakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Imiphakathi yamaSiko, yeKolo nemaLimi==
Imiphakathi ingazithabisa ngamasiko wayo; balandele ikolwabo bebasebenzise
ilimi labo. Unelungelo lokuthoma, lokujoyina nelogcina isiko, ilimi kanye nesiqhema sekolo osithandako.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukufumana ilwazi==
Unelungelo lelinye nelinye ilwazi urhulumende analo Ungafumana elinye nelinye ilwazi eliphethwe mbuso ukuvikela amalungelwakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuphatha ngokusemthethweni==
Izenzo zakarhulumende kufanele zibe ngezilungileko Unelungelo lezenzo ezisemthethweni, ezizwakalako nezilungileko akarhulumende.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt; 

==Ukungena emaKhotho==
Umrarwakho wangokomthetho ungathathelwa isiqunto yikhotho namkha isakhiwo esifanako. Unelungelo lokurarulula imiraro yangokomthetho ekhotho namkha ebandleni elingakabandanyeki bunqopha elirarulula imiraro.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Abantu ababotjhiweko nabathweswe umlandu==
Ilungelweli livikela abantu ababotjhiweko nabavalelwe esikhungweni namkha abathweswe umlandu. Nawubotjhiweko unelungelo okungakhulumi, lokulethwa ngaphambi kwekhotho ema-irini ama-48 kanye nelungelo lokujanyelwa ngokomthetho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Isithasiselo==
{{Reflist}}</text>
      <sha1>rypxgcv1hos2u83tmjmkpi3nxhtkq8x</sha1>
    </revision>
    <revision>
      <id>3132</id>
      <parentid>2899</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Simakahle Moselekatse|Simakahle Moselekatse]]</comment>
      <origin>2202</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7394" sha1="i5aktep4ncdmcmqtcb4zxsqimcerhpp" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi ngesahlukweni sesibili somthetho-sisekelo senarha ye [[Isewula Afrika|Sewula Afrika]] begodu isihloko le sihlathulula indlela bona amalungelo la asebenza ngayo namkha angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[https://web.archive.org/web/20160305192903/http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala enarheni yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[https://web.archive.org/web/20160306031920/http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;&lt;ref&gt;[https://www.un.org/en/global-issues/human-rights#:~:text=Human%20rights%20are%20rights%20inherent,and%20education%2C%20and%20many%20more. https://www.un.org/en/global-issues/human-rights#:~:text=Human%20rights%20are%20rights%20inherent,and%20education%2C%20and%20many%20more.]&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe. Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.&lt;ref name=&quot;ph3&quot;&gt;&quot;[https://web.archive.org/web/20160329070107/http://www.justice.gov.za/legislation/constitution/bor/BillofRights50thAnniversary-Ndebele.pdf Bill of Rights 50&lt;sup&gt;th&lt;/sup&gt; Anniversary]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe. Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipilo==
Unelungelo lepilo. Boke abantu banelungelo lokuphila.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

irhelebho nanyana ngiliphi ongalithola ukuze uphile.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejeziswa kumbi. Ukutlhoriswa kwemakhaya akukavumeleki. Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa nanyana ngiyiphi indlela.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa. Akukafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa. Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako. Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

== Ukuveza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako. Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yezondo ayikavunyelwa.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula. Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako. Unelungelo lokuhlangana nananyana ngubani.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda. Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhetweni atjhaphulukileko nangasolisiko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ubakhamuzi==
Ubakhamuzi bakho ngeze basuswa kuwe. Asikho isakhamuzi ekufuze sithathelwe ubakhamuzi baso.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanyana kukuphi eRiphabhliki yeSewula Afrika. Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako. Unelungel lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhebiswano kezemisebenzi==
Ungajoyina amayuniyoni bewutoyitoye Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana kuphumelelisa iminqopho yabo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt; 

==Ibhoduluko==
Unelungelo lebhoduluko elinepilo. Unelungelo lokuhlala ebhodulukweni elivikelekileko nelinepilo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipahla==
Ungathathelwa ipahlakho nangabe imithetho efaneleko ilandelwe. Akekho ongathathelwa ipahla ngaphandle kwemibandela yomthetho okusetjenziswa okuvamileko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Izindlu==
Urhulumende kufanele enze isiqiniseko sokobana abantu bafumana ukungena
okufaneleko eendlini.. Ninelungelo lokufumana izidlu ezaneleko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==
Urhulumende kufanele enze isiqiniseko sokobana nifumana ukudla namanzi, itjhejo lezePilo kanye nokuPhepha emphakathini. Unelungelo letjhejo lezepilo, ukudla namanzi aneleko kanye nokuphepha emphakathini.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Abantwana==
Abantwana abangaphasi kweminyaka eli-18 banamalungelo akhethekileko njengelungelo lokungatlhoriswa. Woke umntwana unelungelo lebizo, lobutjhaba kanye nelokuvikelwa ekutlhorisweni nekusetjenzisweni ngokungakafaneli.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ifundo==
Unelungelo lefundo esisekelo, kubalwa nefundo esisekelo yabadala ngelimi lakho (nangabekuyakghonakala) Unelungelo lefundo esisekelo ngelimi elisemthethweni olithandako.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ilimi nesiko==
Ungasebenzisa ilimi ofuna ukulisebenzisa bewulandele nesiko ozikhethela lona. Unelungelo lokusebenzisa ilimi olithandako bewenze nesiko lakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Imiphakathi yamaSiko, yeKolo nemaLimi==
Imiphakathi ingazithabisa ngamasiko wayo; balandele ikolwabo bebasebenzise
ilimi labo. Unelungelo lokuthoma, lokujoyina nelogcina isiko, ilimi kanye nesiqhema sekolo osithandako.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukufumana ilwazi==
Unelungelo lelinye nelinye ilwazi urhulumende analo Ungafumana elinye nelinye ilwazi eliphethwe mbuso ukuvikela amalungelwakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuphatha ngokusemthethweni==
Izenzo zakarhulumende kufanele zibe ngezilungileko Unelungelo lezenzo ezisemthethweni, ezizwakalako nezilungileko akarhulumende.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt; 

==Ukungena emaKhotho==
Umrarwakho wangokomthetho ungathathelwa isiqunto yikhotho namkha isakhiwo esifanako. Unelungelo lokurarulula imiraro yangokomthetho ekhotho namkha ebandleni elingakabandanyeki bunqopha elirarulula imiraro.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Abantu ababotjhiweko nabathweswe umlandu==
Ilungelweli livikela abantu ababotjhiweko nabavalelwe esikhungweni namkha abathweswe umlandu. Nawubotjhiweko unelungelo okungakhulumi, lokulethwa ngaphambi kwekhotho ema-irini ama-48 kanye nelungelo lokujanyelwa ngokomthetho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Isithasiselo==
{{Reflist}}</text>
      <sha1>i5aktep4ncdmcmqtcb4zxsqimcerhpp</sha1>
    </revision>
    <revision>
      <id>5069</id>
      <parentid>3132</parentid>
      <timestamp>2025-08-08T08:08:36Z</timestamp>
      <contributor>
        <username>Zukesto</username>
        <id>829</id>
      </contributor>
      <origin>5069</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7392" sha1="s44chy9udqhejjhjh44kgcz3z3rdg8r" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''+Amalungelo Wobuntu''' atholakala ngaphakatha kwesahluko sesibili somthetho-sisekelo senarha ye [[Isewula Afrika|Sewula Afrika]] begodu isihloko le sihlathulula indlela bona amalungelo la asebenza ngayo namkha angancitjhiswa nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[https://web.archive.org/web/20160305192903/http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;. Kuna malungelo wobuntu amatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala enarheni yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[https://web.archive.org/web/20160306031920/http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;&lt;ref&gt;[https://www.un.org/en/global-issues/human-rights#:~:text=Human%20rights%20are%20rights%20inherent,and%20education%2C%20and%20many%20more. https://www.un.org/en/global-issues/human-rights#:~:text=Human%20rights%20are%20rights%20inherent,and%20education%2C%20and%20many%20more.]&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe. Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.&lt;ref name=&quot;ph3&quot;&gt;&quot;[https://web.archive.org/web/20160329070107/http://www.justice.gov.za/legislation/constitution/bor/BillofRights50thAnniversary-Ndebele.pdf Bill of Rights 50&lt;sup&gt;th&lt;/sup&gt; Anniversary]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe. Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipilo==
Unelungelo lepilo. Boke abantu banelungelo lokuphila.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

irhelebho nanyana ngiliphi ongalithola ukuze uphile.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejeziswa kumbi. Ukutlhoriswa kwemakhaya akukavumeleki. Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa nanyana ngiyiphi indlela.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa. Akukafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuba wedwa==
Ngeze wasetjhwa namkha ikhaya lakho nezinto zasetjhwa. Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa begodu ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako. Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

== Ukuveza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako. Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yezondo ayikavunyelwa.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula. Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ilungelo lokuHlangana==
Ungahlangana nananyana ngubani omfunako. Unelungelo lokuhlangana nananyana ngubani.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda. Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhetweni atjhaphulukileko nangasolisiko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ubakhamuzi==
Ubakhamuzi bakho ngeze basuswa kuwe. Asikho isakhamuzi ekufuze sithathelwe ubakhamuzi baso.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanyana kukuphi eRiphabhliki yeSewula Afrika. Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako. Unelungel lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhebiswano kezemisebenzi==
Ungajoyina amayuniyoni bewutoyitoye Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana kuphumelelisa iminqopho yabo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt; 

==Ibhoduluko==
Unelungelo lebhoduluko elinepilo. Unelungelo lokuhlala ebhodulukweni elivikelekileko nelinepilo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipahla==
Ungathathelwa ipahlakho nangabe imithetho efaneleko ilandelwe. Akekho ongathathelwa ipahla ngaphandle kwemibandela yomthetho okusetjenziswa okuvamileko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Izindlu==
Urhulumende kufanele enze isiqiniseko sokobana abantu bafumana ukungena
okufaneleko eendlini.. Ninelungelo lokufumana izidlu ezaneleko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==
Urhulumende kufanele enze isiqiniseko sokobana nifumana ukudla namanzi, itjhejo lezePilo kanye nokuPhepha emphakathini. Unelungelo letjhejo lezepilo, ukudla namanzi aneleko kanye nokuphepha emphakathini.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Abantwana==
Abantwana abangaphasi kweminyaka eli-18 banamalungelo akhethekileko njengelungelo lokungatlhoriswa. Woke umntwana unelungelo lebizo, lobutjhaba kanye nelokuvikelwa ekutlhorisweni nekusetjenzisweni ngokungakafaneli.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ifundo==
Unelungelo lefundo esisekelo, kubalwa nefundo esisekelo yabadala ngelimi lakho (nangabekuyakghonakala) Unelungelo lefundo esisekelo ngelimi elisemthethweni olithandako.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ilimi nesiko==
Ungasebenzisa ilimi ofuna ukulisebenzisa bewulandele nesiko ozikhethela lona. Unelungelo lokusebenzisa ilimi olithandako bewenze nesiko lakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Imiphakathi yamaSiko, yeKolo nemaLimi==
Imiphakathi ingazithabisa ngamasiko wayo; balandele ikolwabo bebasebenzise
ilimi labo. Unelungelo lokuthoma, lokujoyina nelogcina isiko, ilimi kanye nesiqhema sekolo osithandako.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukufumana ilwazi==
Unelungelo lelinye nelinye ilwazi urhulumende analo Ungafumana elinye nelinye ilwazi eliphethwe mbuso ukuvikela amalungelwakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuphatha ngokusemthethweni==
Izenzo zakarhulumende kufanele zibe ngezilungileko Unelungelo lezenzo ezisemthethweni, ezizwakalako nezilungileko akarhulumende.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt; 

==Ukungena emaKhotho==
Umrarwakho wangokomthetho ungathathelwa isiqunto yikhotho namkha isakhiwo esifanako. Unelungelo lokurarulula imiraro yangokomthetho ekhotho namkha ebandleni elingakabandanyeki bunqopha elirarulula imiraro.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Abantu ababotjhiweko nabathweswe umlandu==
Ilungelweli livikela abantu ababotjhiweko nabavalelwe esikhungweni namkha abathweswe umlandu. Nawubotjhiweko unelungelo okungakhulumi, lokulethwa ngaphambi kwekhotho ema-irini ama-48 kanye nelungelo lokujanyelwa ngokomthetho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Isithasiselo==
{{Reflist}}</text>
      <sha1>s44chy9udqhejjhjh44kgcz3z3rdg8r</sha1>
    </revision>
    <revision>
      <id>5086</id>
      <parentid>5069</parentid>
      <timestamp>2025-08-08T09:05:49Z</timestamp>
      <contributor>
        <username>Nothi2003</username>
        <id>833</id>
      </contributor>
      <minor />
      <origin>5086</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7315" sha1="4rza6adiaj2p3mh0jg5c88ay6sj60t2" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''+Amalungelo Wobuntu''' atholakala ngaphakatha kwesahluko sesibili somthetho-sisekelo yenarha ye [[Isewula Afrika|Sewula Afrika]] begodu isihloko lesi sihlathulula indlela bona amalungelo la asebenza njani namkha angancitjhiswa njani nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[https://web.archive.org/web/20160305192903/http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;. Kunamalungelo wobuntu amatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala enarheni yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[https://web.archive.org/web/20160306031920/http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;&lt;ref&gt;[https://www.un.org/en/global-issues/human-rights#:~:text=Human%20rights%20are%20rights%20inherent,and%20education%2C%20and%20many%20more. https://www.un.org/en/global-issues/human-rights#:~:text=Human%20rights%20are%20rights%20inherent,and%20education%2C%20and%20many%20more.]&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe. Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.&lt;ref name=&quot;ph3&quot;&gt;&quot;[https://web.archive.org/web/20160329070107/http://www.justice.gov.za/legislation/constitution/bor/BillofRights50thAnniversary-Ndebele.pdf Bill of Rights 50&lt;sup&gt;th&lt;/sup&gt; Anniversary]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe. Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipilo==
Unelungelo lepilo. Boke abantu banelungelo lokuphila.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

isizo namkha ngiliphi ongalithola ukuze uphile.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejeziswa kumbi. Ukutlhoriswa kwemakhaya akukavumeleki. Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa nanyana ngiyiphi indlela.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa. Akukafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuba wedwa==
Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa, ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako. Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

== Ukuveza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako. Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yezondo ayikavunyelwa.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula. Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ilungelo lokuHlangana==
Unelungelo lokuhlangana nananyana ngubani.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda. Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhethweni atjhaphulukileko nangasolisiko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ubakhamuzi==
Akekho umuntu onelungelo lokuthi asuswe lana akhe khona. Asikho isakhamuzi ekufuze sithathelwe indawo yaso.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanoma kukuphi eRiphabhliki yeSewula Afrika. Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako. Unelungel lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhebiswano kezemisebenzi==
Ungajoyina amayunyoni bewutoyitoye. Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana, lokho kuphumelelisa iminqopho yabo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt; 

==Ibhoduluko==
Unelungelo lebhoduluko elinepilo. Unelungelo lokuhlala ebhodulukweni elivikelekileko nelinepilo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipahla==
Ungathathelwa ipahlakho nangabe imithetho efaneleko ilandelwe. Akekho ongathathelwa ipahla ngaphandle kwemibandela yomthetho okusetjenziswa okuvamileko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Izindlu==
Urhulumende kufanele enze isiqiniseko sokobana abantu bafumana ukungena
okufaneleko eendlini.. Ninelungelo lokufumana izidlu ezaneleko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==
Urhulumende kufanele enze isiqiniseko sokobana nifumana ukudla namanzi, itjhejo lezePilo kanye nokuPhepha emphakathini. Unelungelo letjhejo lezepilo, ukudla namanzi aneleko kanye nokuphepha emphakathini.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Abantwana==
Abantwana abangaphasi kweminyaka eli-18 banamalungelo akhethekileko njengelungelo lokungatlhoriswa. Woke umntwana unelungelo lebizo, lobutjhaba kanye nelokuvikelwa ekutlhorisweni nekusetjenzisweni ngokungakafaneli.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ifundo==
Unelungelo lefundo esisekelo, kubalwa nefundo esisekelo yabadala ngelimi lakho (nangabekuyakghonakala) Unelungelo lefundo esisekelo ngelimi elisemthethweni olithandako.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ilimi nesiko==
Ungasebenzisa ilimi ofuna ukulisebenzisa bewulandele nesiko ozikhethela lona. Unelungelo lokusebenzisa ilimi olithandako bewenze nesiko lakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Imiphakathi yamaSiko, yeKolo nemaLimi==
Imiphakathi ingazithabisa ngamasiko wayo; balandele ikolwabo bebasebenzise
ilimi labo. Unelungelo lokuthoma, lokujoyina nelogcina isiko, ilimi kanye nesiqhema sekolo osithandako.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukufumana ilwazi==
Unelungelo lelinye nelinye ilwazi urhulumende analo Ungafumana elinye nelinye ilwazi eliphethwe mbuso ukuvikela amalungelwakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuphatha ngokusemthethweni==
Izenzo zakarhulumende kufanele zibe ngezilungileko Unelungelo lezenzo ezisemthethweni, ezizwakalako nezilungileko akarhulumende.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt; 

==Ukungena emaKhotho==
Umrarwakho wangokomthetho ungathathelwa isiqunto yikhotho namkha isakhiwo esifanako. Unelungelo lokurarulula imiraro yangokomthetho ekhotho namkha ebandleni elingakabandanyeki bunqopha elirarulula imiraro.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Abantu ababotjhiweko nabathweswe umlandu==
Ilungelweli livikela abantu ababotjhiweko nabavalelwe esikhungweni namkha abathweswe umlandu. Nawubotjhiweko unelungelo okungakhulumi, lokulethwa ngaphambi kwekhotho ema-irini ama-48 kanye nelungelo lokujanyelwa ngokomthetho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Isithasiselo==
{{Reflist}}</text>
      <sha1>4rza6adiaj2p3mh0jg5c88ay6sj60t2</sha1>
    </revision>
    <revision>
      <id>5096</id>
      <parentid>5086</parentid>
      <timestamp>2025-08-08T09:38:50Z</timestamp>
      <contributor>
        <username>N Mabhena</username>
        <id>843</id>
      </contributor>
      <origin>5096</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7316" sha1="d17joo2pyyyo0hb63zzpk8slmebtuhb" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''+Amalungelo Wobuntu''' atholakala ngaphakathi kwesahluko sesibili somthetho-sisekelo yenarha ye [[Isewula Afrika|Sewula Afrika]] begodu isihloko lesi sihlathulula indlela bona amalungelo la asebenza njani namkha angancitjhiswa njani nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[https://web.archive.org/web/20160305192903/http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;. Kunamalungelo wobuntu amatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala enarheni yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[https://web.archive.org/web/20160306031920/http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;&lt;ref&gt;[https://www.un.org/en/global-issues/human-rights#:~:text=Human%20rights%20are%20rights%20inherent,and%20education%2C%20and%20many%20more. https://www.un.org/en/global-issues/human-rights#:~:text=Human%20rights%20are%20rights%20inherent,and%20education%2C%20and%20many%20more.]&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe. Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.&lt;ref name=&quot;ph3&quot;&gt;&quot;[https://web.archive.org/web/20160329070107/http://www.justice.gov.za/legislation/constitution/bor/BillofRights50thAnniversary-Ndebele.pdf Bill of Rights 50&lt;sup&gt;th&lt;/sup&gt; Anniversary]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe. Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipilo==
Unelungelo lepilo. Boke abantu banelungelo lokuphila.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

isizo namkha ngiliphi ongalithola ukuze uphile.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejeziswa kumbi. Ukutlhoriswa kwemakhaya akukavumeleki. Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa nanyana ngiyiphi indlela.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa. Akukafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuba wedwa==
Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa, ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako. Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

== Ukuveza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako. Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yezondo ayikavunyelwa.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula. Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ilungelo lokuHlangana==
Unelungelo lokuhlangana nananyana ngubani.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda. Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhethweni atjhaphulukileko nangasolisiko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ubakhamuzi==
Akekho umuntu onelungelo lokuthi asuswe lana akhe khona. Asikho isakhamuzi ekufuze sithathelwe indawo yaso.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanoma kukuphi eRiphabhliki yeSewula Afrika. Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako. Unelungelo lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhebiswano kezemisebenzi==
Ungajoyina amayunyoni bewutoyitoye. Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana, lokho kuphumelelisa iminqopho yabo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt; 

==Ibhoduluko==
Unelungelo lebhoduluko elinepilo. Unelungelo lokuhlala ebhodulukweni elivikelekileko nelinepilo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipahla==
Ungathathelwa ipahlakho nangabe imithetho efaneleko ilandelwe. Akekho ongathathelwa ipahla ngaphandle kwemibandela yomthetho okusetjenziswa okuvamileko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Izindlu==
Urhulumende kufanele enze isiqiniseko sokobana abantu bafumana ukungena
okufaneleko eendlini.. Ninelungelo lokufumana izidlu ezaneleko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==
Urhulumende kufanele enze isiqiniseko sokobana nifumana ukudla namanzi, itjhejo lezePilo kanye nokuPhepha emphakathini. Unelungelo letjhejo lezepilo, ukudla namanzi aneleko kanye nokuphepha emphakathini.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Abantwana==
Abantwana abangaphasi kweminyaka eli-18 banamalungelo akhethekileko njengelungelo lokungatlhoriswa. Woke umntwana unelungelo lebizo, lobutjhaba kanye nelokuvikelwa ekutlhorisweni nekusetjenzisweni ngokungakafaneli.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ifundo==
Unelungelo lefundo esisekelo, kubalwa nefundo esisekelo yabadala ngelimi lakho (nangabekuyakghonakala) Unelungelo lefundo esisekelo ngelimi elisemthethweni olithandako.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ilimi nesiko==
Ungasebenzisa ilimi ofuna ukulisebenzisa bewulandele nesiko ozikhethela lona. Unelungelo lokusebenzisa ilimi olithandako bewenze nesiko lakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Imiphakathi yamaSiko, yeKolo nemaLimi==
Imiphakathi ingazithabisa ngamasiko wayo; balandele ikolwabo bebasebenzise
ilimi labo. Unelungelo lokuthoma, lokujoyina nelogcina isiko, ilimi kanye nesiqhema sekolo osithandako.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukufumana ilwazi==
Unelungelo lelinye nelinye ilwazi urhulumende analo Ungafumana elinye nelinye ilwazi eliphethwe mbuso ukuvikela amalungelwakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuphatha ngokusemthethweni==
Izenzo zakarhulumende kufanele zibe ngezilungileko Unelungelo lezenzo ezisemthethweni, ezizwakalako nezilungileko akarhulumende.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt; 

==Ukungena emaKhotho==
Umrarwakho wangokomthetho ungathathelwa isiqunto yikhotho namkha isakhiwo esifanako. Unelungelo lokurarulula imiraro yangokomthetho ekhotho namkha ebandleni elingakabandanyeki bunqopha elirarulula imiraro.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Abantu ababotjhiweko nabathweswe umlandu==
Ilungelweli livikela abantu ababotjhiweko nabavalelwe esikhungweni namkha abathweswe umlandu. Nawubotjhiweko unelungelo okungakhulumi, lokulethwa ngaphambi kwekhotho ema-irini ama-48 kanye nelungelo lokujanyelwa ngokomthetho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Isithasiselo==
{{Reflist}}</text>
      <sha1>d17joo2pyyyo0hb63zzpk8slmebtuhb</sha1>
    </revision>
    <revision>
      <id>6391</id>
      <parentid>5096</parentid>
      <timestamp>2026-04-02T00:35:20Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6391</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7315" sha1="tjywfumcd85j50izx14zl5d9k28aeff" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi kwesahluko sesibili somthetho-sisekelo yenarha ye [[Isewula Afrika|Sewula Afrika]] begodu isihloko lesi sihlathulula indlela bona amalungelo la asebenza njani namkha angancitjhiswa njani nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[https://web.archive.org/web/20160305192903/http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;. Kunamalungelo wobuntu amatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala enarheni yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[https://web.archive.org/web/20160306031920/http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;&lt;ref&gt;[https://www.un.org/en/global-issues/human-rights#:~:text=Human%20rights%20are%20rights%20inherent,and%20education%2C%20and%20many%20more. https://www.un.org/en/global-issues/human-rights#:~:text=Human%20rights%20are%20rights%20inherent,and%20education%2C%20and%20many%20more.]&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe. Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.&lt;ref name=&quot;ph3&quot;&gt;&quot;[https://web.archive.org/web/20160329070107/http://www.justice.gov.za/legislation/constitution/bor/BillofRights50thAnniversary-Ndebele.pdf Bill of Rights 50&lt;sup&gt;th&lt;/sup&gt; Anniversary]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe. Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipilo==
Unelungelo lepilo. Boke abantu banelungelo lokuphila.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

isizo namkha ngiliphi ongalithola ukuze uphile.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejeziswa kumbi. Ukutlhoriswa kwemakhaya akukavumeleki. Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa nanyana ngiyiphi indlela.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa. Akukafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuba wedwa==
Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa, ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako. Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

== Ukuveza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako. Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yezondo ayikavunyelwa.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula. Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ilungelo lokuHlangana==
Unelungelo lokuhlangana nananyana ngubani.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda. Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhethweni atjhaphulukileko nangasolisiko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ubakhamuzi==
Akekho umuntu onelungelo lokuthi asuswe lana akhe khona. Asikho isakhamuzi ekufuze sithathelwe indawo yaso.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanoma kukuphi eRiphabhliki yeSewula Afrika. Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako. Unelungelo lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhebiswano kezemisebenzi==
Ungajoyina amayunyoni bewutoyitoye. Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana, lokho kuphumelelisa iminqopho yabo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt; 

==Ibhoduluko==
Unelungelo lebhoduluko elinepilo. Unelungelo lokuhlala ebhodulukweni elivikelekileko nelinepilo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipahla==
Ungathathelwa ipahlakho nangabe imithetho efaneleko ilandelwe. Akekho ongathathelwa ipahla ngaphandle kwemibandela yomthetho okusetjenziswa okuvamileko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Izindlu==
Urhulumende kufanele enze isiqiniseko sokobana abantu bafumana ukungena
okufaneleko eendlini.. Ninelungelo lokufumana izidlu ezaneleko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==
Urhulumende kufanele enze isiqiniseko sokobana nifumana ukudla namanzi, itjhejo lezePilo kanye nokuPhepha emphakathini. Unelungelo letjhejo lezepilo, ukudla namanzi aneleko kanye nokuphepha emphakathini.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Abantwana==
Abantwana abangaphasi kweminyaka eli-18 banamalungelo akhethekileko njengelungelo lokungatlhoriswa. Woke umntwana unelungelo lebizo, lobutjhaba kanye nelokuvikelwa ekutlhorisweni nekusetjenzisweni ngokungakafaneli.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ifundo==
Unelungelo lefundo esisekelo, kubalwa nefundo esisekelo yabadala ngelimi lakho (nangabekuyakghonakala) Unelungelo lefundo esisekelo ngelimi elisemthethweni olithandako.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ilimi nesiko==
Ungasebenzisa ilimi ofuna ukulisebenzisa bewulandele nesiko ozikhethela lona. Unelungelo lokusebenzisa ilimi olithandako bewenze nesiko lakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Imiphakathi yamaSiko, yeKolo nemaLimi==
Imiphakathi ingazithabisa ngamasiko wayo; balandele ikolwabo bebasebenzise
ilimi labo. Unelungelo lokuthoma, lokujoyina nelogcina isiko, ilimi kanye nesiqhema sekolo osithandako.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukufumana ilwazi==
Unelungelo lelinye nelinye ilwazi urhulumende analo Ungafumana elinye nelinye ilwazi eliphethwe mbuso ukuvikela amalungelwakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuphatha ngokusemthethweni==
Izenzo zakarhulumende kufanele zibe ngezilungileko Unelungelo lezenzo ezisemthethweni, ezizwakalako nezilungileko akarhulumende.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt; 

==Ukungena emaKhotho==
Umrarwakho wangokomthetho ungathathelwa isiqunto yikhotho namkha isakhiwo esifanako. Unelungelo lokurarulula imiraro yangokomthetho ekhotho namkha ebandleni elingakabandanyeki bunqopha elirarulula imiraro.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Abantu ababotjhiweko nabathweswe umlandu==
Ilungelweli livikela abantu ababotjhiweko nabavalelwe esikhungweni namkha abathweswe umlandu. Nawubotjhiweko unelungelo okungakhulumi, lokulethwa ngaphambi kwekhotho ema-irini ama-48 kanye nelungelo lokujanyelwa ngokomthetho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Isithasiselo==
{{Reflist}}</text>
      <sha1>tjywfumcd85j50izx14zl5d9k28aeff</sha1>
    </revision>
    <revision>
      <id>6805</id>
      <parentid>6391</parentid>
      <timestamp>2026-08-23T16:37:29Z</timestamp>
      <contributor>
        <username>HUMMONBO</username>
        <id>1719</id>
      </contributor>
      <origin>6805</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7334" sha1="h1qvdn2fsgoy232pm3feg9agigi4uq6" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' (홍명보 나가) atholakala ngaphakathi kwesahluko sesibili somthetho-sisekelo yenarha ye [[Isewula Afrika|Sewula Afrika]] begodu isihloko lesi sihlathulula indlela bona amalungelo la asebenza njani namkha angancitjhiswa njani nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[https://web.archive.org/web/20160305192903/http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;. Kunamalungelo wobuntu amatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala enarheni yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[https://web.archive.org/web/20160306031920/http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;&lt;ref&gt;[https://www.un.org/en/global-issues/human-rights#:~:text=Human%20rights%20are%20rights%20inherent,and%20education%2C%20and%20many%20more. https://www.un.org/en/global-issues/human-rights#:~:text=Human%20rights%20are%20rights%20inherent,and%20education%2C%20and%20many%20more.]&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe. Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.&lt;ref name=&quot;ph3&quot;&gt;&quot;[https://web.archive.org/web/20160329070107/http://www.justice.gov.za/legislation/constitution/bor/BillofRights50thAnniversary-Ndebele.pdf Bill of Rights 50&lt;sup&gt;th&lt;/sup&gt; Anniversary]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe. Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipilo==
Unelungelo lepilo. Boke abantu banelungelo lokuphila.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

isizo namkha ngiliphi ongalithola ukuze uphile.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejeziswa kumbi. Ukutlhoriswa kwemakhaya akukavumeleki. Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa nanyana ngiyiphi indlela.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa. Akukafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuba wedwa==
Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa, ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako. Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

== Ukuveza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako. Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yezondo ayikavunyelwa.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula. Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ilungelo lokuHlangana==
Unelungelo lokuhlangana nananyana ngubani.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda. Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhethweni atjhaphulukileko nangasolisiko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ubakhamuzi==
Akekho umuntu onelungelo lokuthi asuswe lana akhe khona. Asikho isakhamuzi ekufuze sithathelwe indawo yaso.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanoma kukuphi eRiphabhliki yeSewula Afrika. Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako. Unelungelo lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhebiswano kezemisebenzi==
Ungajoyina amayunyoni bewutoyitoye. Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana, lokho kuphumelelisa iminqopho yabo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt; 

==Ibhoduluko==
Unelungelo lebhoduluko elinepilo. Unelungelo lokuhlala ebhodulukweni elivikelekileko nelinepilo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipahla==
Ungathathelwa ipahlakho nangabe imithetho efaneleko ilandelwe. Akekho ongathathelwa ipahla ngaphandle kwemibandela yomthetho okusetjenziswa okuvamileko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Izindlu==
Urhulumende kufanele enze isiqiniseko sokobana abantu bafumana ukungena
okufaneleko eendlini.. Ninelungelo lokufumana izidlu ezaneleko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==
Urhulumende kufanele enze isiqiniseko sokobana nifumana ukudla namanzi, itjhejo lezePilo kanye nokuPhepha emphakathini. Unelungelo letjhejo lezepilo, ukudla namanzi aneleko kanye nokuphepha emphakathini.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Abantwana==
Abantwana abangaphasi kweminyaka eli-18 banamalungelo akhethekileko njengelungelo lokungatlhoriswa. Woke umntwana unelungelo lebizo, lobutjhaba kanye nelokuvikelwa ekutlhorisweni nekusetjenzisweni ngokungakafaneli.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ifundo==
Unelungelo lefundo esisekelo, kubalwa nefundo esisekelo yabadala ngelimi lakho (nangabekuyakghonakala) Unelungelo lefundo esisekelo ngelimi elisemthethweni olithandako.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ilimi nesiko==
Ungasebenzisa ilimi ofuna ukulisebenzisa bewulandele nesiko ozikhethela lona. Unelungelo lokusebenzisa ilimi olithandako bewenze nesiko lakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Imiphakathi yamaSiko, yeKolo nemaLimi==
Imiphakathi ingazithabisa ngamasiko wayo; balandele ikolwabo bebasebenzise
ilimi labo. Unelungelo lokuthoma, lokujoyina nelogcina isiko, ilimi kanye nesiqhema sekolo osithandako.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukufumana ilwazi==
Unelungelo lelinye nelinye ilwazi urhulumende analo Ungafumana elinye nelinye ilwazi eliphethwe mbuso ukuvikela amalungelwakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuphatha ngokusemthethweni==
Izenzo zakarhulumende kufanele zibe ngezilungileko Unelungelo lezenzo ezisemthethweni, ezizwakalako nezilungileko akarhulumende.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt; 

==Ukungena emaKhotho==
Umrarwakho wangokomthetho ungathathelwa isiqunto yikhotho namkha isakhiwo esifanako. Unelungelo lokurarulula imiraro yangokomthetho ekhotho namkha ebandleni elingakabandanyeki bunqopha elirarulula imiraro.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Abantu ababotjhiweko nabathweswe umlandu==
Ilungelweli livikela abantu ababotjhiweko nabavalelwe esikhungweni namkha abathweswe umlandu. Nawubotjhiweko unelungelo okungakhulumi, lokulethwa ngaphambi kwekhotho ema-irini ama-48 kanye nelungelo lokujanyelwa ngokomthetho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Isithasiselo==
{{Reflist}}</text>
      <sha1>h1qvdn2fsgoy232pm3feg9agigi4uq6</sha1>
    </revision>
    <revision>
      <id>6806</id>
      <parentid>6805</parentid>
      <timestamp>2026-08-23T16:37:55Z</timestamp>
      <contributor>
        <username>HUMMONBO</username>
        <id>1719</id>
      </contributor>
      <origin>6806</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7315" sha1="tjywfumcd85j50izx14zl5d9k28aeff" xml:space="preserve">{{Official Document|
| ibizo = Amalungelo Wobuntu
| isithombe = RSA-Constitution.png
| unyaka wokutlola = 16 KuNobayeni 1996 
| indawo yo kutlolwa = Johannesburg
| inarha yomtlolo =  Isewula Afrika
}}
'''Amalungelo Wobuntu''' atholakala ngaphakathi kwesahluko sesibili somthetho-sisekelo yenarha ye [[Isewula Afrika|Sewula Afrika]] begodu isihloko lesi sihlathulula indlela bona amalungelo la asebenza njani namkha angancitjhiswa njani nangabe kulungile ukwenza njalo&lt;ref name=ph1&gt;&quot;[https://web.archive.org/web/20160305192903/http://www.justice.gov.za/legislation/constitution/chp02.html Bill of Rights Chapter 2, Section 7-39]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;. Kunamalungelo wobuntu amatjhumi amabili nekhomba kumthethosisekelo. Yoke imithetho le ilawulwa mthetho wendawo kodwana isebenza kibo boke abahlala enarheni yeSewula Afrika.&lt;ref name=ph2&gt;&quot;[https://web.archive.org/web/20160306031920/http://www.justice.gov.za/legislation/constitution/index.html The South African Constitution]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;&lt;ref&gt;[https://www.un.org/en/global-issues/human-rights#:~:text=Human%20rights%20are%20rights%20inherent,and%20education%2C%20and%20many%20more. https://www.un.org/en/global-issues/human-rights#:~:text=Human%20rights%20are%20rights%20inherent,and%20education%2C%20and%20many%20more.]&lt;/ref&gt;

==Ukulingana==
Ngeze wabandlululwa kodwana igadango lokulinganisa emsebenzini kubandlulula okufaneleko kuvunyelwe. Boke abantu bayalingana ngaphambi komthetho begodu akukafaneli ukubandlululwa.&lt;ref name=&quot;ph3&quot;&gt;&quot;[https://web.archive.org/web/20160329070107/http://www.justice.gov.za/legislation/constitution/bor/BillofRights50thAnniversary-Ndebele.pdf Bill of Rights 50&lt;sup&gt;th&lt;/sup&gt; Anniversary]&quot; - &lt;small&gt;'''The Department of Justice and Constitutional Development'''&lt;/small&gt;. Retrieved 24 February 2016&lt;/ref&gt;

==Isithunzi sabantu==
Isithunzi sakho kufanele sihlonitjhwe begodu sivikelwe. Boke abantu banesithunzi sobuntu esisisekelo ekufanele sihlonitjhwe.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipilo==
Unelungelo lepilo. Boke abantu banelungelo lokuphila.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

isizo namkha ngiliphi ongalithola ukuze uphile.

==Itjhaphuluko nokuPhepha komuntu==
Angeze wavalelwa ngaphandle kokugwetjwa, walinyazwa namkha wejeziswa kumbi. Ukutlhoriswa kwemakhaya akukavumeleki. Angeze wavalelwa ngaphandle kokugwetjwa namkha watlhoriswa nanyana ngiyiphi indlela.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ubugcila, Ukusebenzela kanye nomsebenzi okatelelwako==
Ubugcila nomsebenzi okatelelwako azivunyelwa. Akukafaneli wenziwe isigcila namkha ukatelelwe ukusebenza.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuba wedwa==
Ilungelo lakho lokuba wedwa lifakahlangana umzimbakho, ikhaya nezinto zakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

== Itjhaphuluko yekolo, yekolelo neyombono==
Ungakholwa, ucabange nanyana yini oyifunako begodu ungalandela ikolo oyithandako. Unelungelo lokucabanga, lokukholwa nelokukhothamela ngendlela othanda ngayo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

== Ukuveza imibono ngokutjhaphuluka==
Boke abantu (kubalwa neembikindaba) bangatjho nanyana yini abayifunako. Unelungelo lokutjho, lokufunda nelokufunda nanyana yini oyikhethako kodwana ikulumo yezondo ayikavunyelwa.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuhlangana, Ukutjengisa, Ukutoyitoya nomTlolo weembawo==
Ningabamba isitjengiso, nitoyitoye begodu niveze umtlolo wesibawo kodwana kufanele lokhu nikwenze ngokuthula. Ninelungelo lokuhlangana ngokuthula, lokutjengisa nelokunghonghoyila.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ilungelo lokuHlangana==
Unelungelo lokuhlangana nananyana ngubani.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Amalungelo wezepolotiki==
Ungasekela ihlangano yepolotiki oyithandako. Nangabe usisakhamuzi begodu okungenani uneminyaka eli-18 ubudala, ungavowuda. Ungathoma ihlangano yepolotiki, ungathatha ingcenye begodu uvowudele enye nenye ihlangano emakhethweni atjhaphulukileko nangasolisiko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ubakhamuzi==
Akekho umuntu onelungelo lokuthi asuswe lana akhe khona. Asikho isakhamuzi ekufuze sithathelwe indawo yaso.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhaphuluko lokuKhamba nelokuHlala==
Ungakhamba begodu uhlale nanoma kukuphi eRiphabhliki yeSewula Afrika. Unelungelo lokungena nokuhlala eRiphabliki ngokuthanda.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhaphuluko yokuRhweba, yomSebenzi neBizelo==
Ungenza nanyana ngimuphi umsebenzi owufunako. Unelungelo lokukhetha elinye nelinye irhwebo elisemthethweni namkha umsebenzi ngokutjhaphuluka.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhebiswano kezemisebenzi==
Ungajoyina amayunyoni bewutoyitoye. Boke abasebenzi nabaqhatjhi banelungelo lokuhlela nokukhulumisana, lokho kuphumelelisa iminqopho yabo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt; 

==Ibhoduluko==
Unelungelo lebhoduluko elinepilo. Unelungelo lokuhlala ebhodulukweni elivikelekileko nelinepilo.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ipahla==
Ungathathelwa ipahlakho nangabe imithetho efaneleko ilandelwe. Akekho ongathathelwa ipahla ngaphandle kwemibandela yomthetho okusetjenziswa okuvamileko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Izindlu==
Urhulumende kufanele enze isiqiniseko sokobana abantu bafumana ukungena
okufaneleko eendlini.. Ninelungelo lokufumana izidlu ezaneleko.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Itjhejo lezepilo, Ukudla, Amanzi nokuPhepha komPhakathi==
Urhulumende kufanele enze isiqiniseko sokobana nifumana ukudla namanzi, itjhejo lezePilo kanye nokuPhepha emphakathini. Unelungelo letjhejo lezepilo, ukudla namanzi aneleko kanye nokuphepha emphakathini.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Abantwana==
Abantwana abangaphasi kweminyaka eli-18 banamalungelo akhethekileko njengelungelo lokungatlhoriswa. Woke umntwana unelungelo lebizo, lobutjhaba kanye nelokuvikelwa ekutlhorisweni nekusetjenzisweni ngokungakafaneli.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ifundo==
Unelungelo lefundo esisekelo, kubalwa nefundo esisekelo yabadala ngelimi lakho (nangabekuyakghonakala) Unelungelo lefundo esisekelo ngelimi elisemthethweni olithandako.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ilimi nesiko==
Ungasebenzisa ilimi ofuna ukulisebenzisa bewulandele nesiko ozikhethela lona. Unelungelo lokusebenzisa ilimi olithandako bewenze nesiko lakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Imiphakathi yamaSiko, yeKolo nemaLimi==
Imiphakathi ingazithabisa ngamasiko wayo; balandele ikolwabo bebasebenzise
ilimi labo. Unelungelo lokuthoma, lokujoyina nelogcina isiko, ilimi kanye nesiqhema sekolo osithandako.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukufumana ilwazi==
Unelungelo lelinye nelinye ilwazi urhulumende analo Ungafumana elinye nelinye ilwazi eliphethwe mbuso ukuvikela amalungelwakho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Ukuphatha ngokusemthethweni==
Izenzo zakarhulumende kufanele zibe ngezilungileko Unelungelo lezenzo ezisemthethweni, ezizwakalako nezilungileko akarhulumende.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt; 

==Ukungena emaKhotho==
Umrarwakho wangokomthetho ungathathelwa isiqunto yikhotho namkha isakhiwo esifanako. Unelungelo lokurarulula imiraro yangokomthetho ekhotho namkha ebandleni elingakabandanyeki bunqopha elirarulula imiraro.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Abantu ababotjhiweko nabathweswe umlandu==
Ilungelweli livikela abantu ababotjhiweko nabavalelwe esikhungweni namkha abathweswe umlandu. Nawubotjhiweko unelungelo okungakhulumi, lokulethwa ngaphambi kwekhotho ema-irini ama-48 kanye nelungelo lokujanyelwa ngokomthetho.&lt;ref name=&quot;ph3&quot;&gt;&lt;/ref&gt;

==Isithasiselo==
{{Reflist}}</text>
      <sha1>tjywfumcd85j50izx14zl5d9k28aeff</sha1>
    </revision>
  </page>
  <page>
    <title>Amarhwebo eYunivesithi yeMpumalanga</title>
    <ns>0</ns>
    <id>115</id>
    <revision>
      <id>537</id>
      <timestamp>2024-03-09T10:08:44Z</timestamp>
      <contributor>
        <username>incubator&gt;Mbandeni</username>
        <id>0</id>
      </contributor>
      <comment>Created this page</comment>
      <origin>537</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="322" sha1="dkia9wg6ofkj85jv1xsujt8m5jvfkau" xml:space="preserve">Abafundi bazimisele khulu ngamarhwebo wabo. Manengi tle! amarherhwebo wavulwe bafundi beYunivesithi yeMpumalanga. IYunivesithi yenza isiqiniseko sokobana siyabakhuthaza nokubagqugquzela ekukhuliseni amarhwebo wabo. Ngomnyaka ka-2023 kuKhukhulamungu, iYunivesithi yenza ilanga lokobana abafundi bakhangise amarhwebo wabo.

</text>
      <sha1>dkia9wg6ofkj85jv1xsujt8m5jvfkau</sha1>
    </revision>
    <revision>
      <id>538</id>
      <parentid>537</parentid>
      <timestamp>2024-03-09T10:10:30Z</timestamp>
      <contributor>
        <username>incubator&gt;Mbandeni</username>
        <id>0</id>
      </contributor>
      <comment>Added bold</comment>
      <origin>538</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="360" sha1="m79xmwac21u6dw34fxmy53rmtf4lmfl" xml:space="preserve">'''Abafundi''' bazimisele khulu ngamarhwebo wabo. Manengi tle! amarherhwebo wavulwe bafundi beYunivesithi yeMpumalanga. IYunivesithi yenza isiqiniseko sokobana siyabakhuthaza nokubagqugquzela ekukhuliseni amarhwebo wabo. Ngomnyaka ka-2023 kuKhukhulamungu, iYunivesithi yenza ilanga lokobana abafundi bakhangise amarhwebo wabo.

=== Ukubaluleka kwamarhwebo ===
</text>
      <sha1>m79xmwac21u6dw34fxmy53rmtf4lmfl</sha1>
    </revision>
    <revision>
      <id>539</id>
      <parentid>538</parentid>
      <timestamp>2024-03-09T10:37:42Z</timestamp>
      <contributor>
        <username>incubator&gt;Mbandeni</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Added picture</comment>
      <origin>539</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="444" sha1="lsbdwu7mm2umcsmi4nz8ejam6gzrbu9" xml:space="preserve">[[Isimumathi:Mfundisi Tuckshop.jpg|thumb|Entrepreneur Day at UMP Siyabuswa Campus]]
'''Abafundi''' bazimisele khulu ngamarhwebo wabo. Manengi tle! amarherhwebo wavulwe bafundi beYunivesithi yeMpumalanga. IYunivesithi yenza isiqiniseko sokobana siyabakhuthaza nokubagqugquzela ekukhuliseni amarhwebo wabo. Ngomnyaka ka-2023 kuKhukhulamungu, iYunivesithi yenza ilanga lokobana abafundi bakhangise amarhwebo wabo.

=== Ukubaluleka kwamarhwebo ===
</text>
      <sha1>lsbdwu7mm2umcsmi4nz8ejam6gzrbu9</sha1>
    </revision>
    <revision>
      <id>540</id>
      <parentid>539</parentid>
      <timestamp>2024-03-09T10:38:40Z</timestamp>
      <contributor>
        <username>incubator&gt;Mbandeni</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Edited</comment>
      <origin>540</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="465" sha1="itdyrfru5unm5buf10gedbo1mjp0ryd" xml:space="preserve">[[Isimumathi:Mfundisi Tuckshop.jpg|thumb|Entrepreneur Day at UMP Siyabuswa Campus]]
'''Abafundi''' bazimisele khulu ngamarhwebo wabo. Manengi tle! amarherhwebo wavulwe bafundi beYunivesithi yeMpumalanga enzinze ngeSiyabuswa. IYunivesithi yenza isiqiniseko sokobana siyabakhuthaza nokubagqugquzela ekukhuliseni amarhwebo wabo. Ngomnyaka ka-2023 kuKhukhulamungu, iYunivesithi yenza ilanga lokobana abafundi bakhangise amarhwebo wabo.

=== Ukubaluleka kwamarhwebo ===
</text>
      <sha1>itdyrfru5unm5buf10gedbo1mjp0ryd</sha1>
    </revision>
    <revision>
      <id>541</id>
      <parentid>540</parentid>
      <timestamp>2024-03-09T10:39:11Z</timestamp>
      <contributor>
        <username>incubator&gt;Mbandeni</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Linked to another article</comment>
      <origin>541</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="469" sha1="n9vovf9ds1qebwv6q4rwn6p0j6i83en" xml:space="preserve">[[Isimumathi:Mfundisi Tuckshop.jpg|thumb|Entrepreneur Day at UMP Siyabuswa Campus]]
'''Abafundi''' bazimisele khulu ngamarhwebo wabo. Manengi tle! amarherhwebo wavulwe bafundi beYunivesithi yeMpumalanga enzinze nge[[Siyabuswa]]. IYunivesithi yenza isiqiniseko sokobana siyabakhuthaza nokubagqugquzela ekukhuliseni amarhwebo wabo. Ngomnyaka ka-2023 kuKhukhulamungu, iYunivesithi yenza ilanga lokobana abafundi bakhangise amarhwebo wabo.

=== Ukubaluleka kwamarhwebo ===
</text>
      <sha1>n9vovf9ds1qebwv6q4rwn6p0j6i83en</sha1>
    </revision>
    <revision>
      <id>542</id>
      <parentid>541</parentid>
      <timestamp>2024-03-09T10:40:22Z</timestamp>
      <contributor>
        <username>incubator&gt;Mbandeni</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Added a picture</comment>
      <origin>542</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="556" sha1="5bsv5a162y4sk0oiuvyhj0zz0736bfy" xml:space="preserve">[[Isimumathi:Mfundisi Tuckshop.jpg|thumb|Entrepreneur Day at UMP Siyabuswa Campus]]
[[Isimumathi:Trisha'sGlam.jpg|thumb|Student Entrepreneur Day at UMP Siyabuswa Campus]]
'''Abafundi''' bazimisele khulu ngamarhwebo wabo. Manengi tle! amarherhwebo wavulwe bafundi beYunivesithi yeMpumalanga enzinze nge[[Siyabuswa]]. IYunivesithi yenza isiqiniseko sokobana siyabakhuthaza nokubagqugquzela ekukhuliseni amarhwebo wabo. Ngomnyaka ka-2023 kuKhukhulamungu, iYunivesithi yenza ilanga lokobana abafundi bakhangise amarhwebo wabo.

=== Ukubaluleka kwamarhwebo ===
</text>
      <sha1>5bsv5a162y4sk0oiuvyhj0zz0736bfy</sha1>
    </revision>
    <revision>
      <id>543</id>
      <parentid>542</parentid>
      <timestamp>2024-03-09T10:43:25Z</timestamp>
      <contributor>
        <username>incubator&gt;Mbandeni</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Linked to another article</comment>
      <origin>543</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="752" sha1="ssmfqu3yvsyx91dpfreio3y48hynmcz" xml:space="preserve">[[Isimumathi:Mfundisi Tuckshop.jpg|thumb|Entrepreneur Day at UMP Siyabuswa Campus]]
[[Isimumathi:Trisha'sGlam.jpg|thumb|Student Entrepreneur Day at UMP Siyabuswa Campus]]
'''Abafundi''' bazimisele khulu ngamarhwebo wabo. Manengi tle! amarherhwebo wavulwe bafundi beYunivesithi yeMpumalanga enzinze nge[[Siyabuswa]]. IYunivesithi yenza isiqiniseko sokobana siyabakhuthaza nokubagqugquzela ekukhuliseni amarhwebo wabo. Ngomnyaka ka-2023 kuKhukhulamungu, iYunivesithi yenza ilanga lokobana abafundi bakhangise amarhwebo wabo.

=== Ukubaluleka kwamarhwebo ===
Amarhwebo aqakatheke khulu ekukhuliseni umnotho we-[[Isewula Afrika|Sewula Afrika]]. Okhunye kukobana amarhwebo abava iinkhundla zokungasebenzi kwabantu abatjha, ekukuvuleni amathuba womsebenzi. 
</text>
      <sha1>ssmfqu3yvsyx91dpfreio3y48hynmcz</sha1>
    </revision>
    <revision>
      <id>544</id>
      <parentid>543</parentid>
      <timestamp>2024-03-09T10:45:47Z</timestamp>
      <contributor>
        <username>incubator&gt;Mbandeni</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Edited</comment>
      <origin>544</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="798" sha1="b8wbch5psjoy8wqa1t899we8eeygwno" xml:space="preserve">[[Isimumathi:Mfundisi Tuckshop.jpg|thumb|Entrepreneur Day at UMP Siyabuswa Campus]]
[[Isimumathi:Trisha'sGlam.jpg|thumb|Student Entrepreneur Day at UMP Siyabuswa Campus]]
'''Abafundi''' bazimisele khulu ngamarhwebo wabo. Manengi tle! amarherhwebo wavulwe bafundi beYunivesithi yeMpumalanga enzinze nge[[Siyabuswa]]. IYunivesithi yenza isiqiniseko sokobana siyabakhuthaza nokubagqugquzela ekukhuliseni amarhwebo wabo. Ngomnyaka ka-2023 kuKhukhulamungu, iYunivesithi yenza ilanga lokobana abafundi bakhangise amarhwebo wabo ekukhombisa kobana i-Yunivesithi iyabasekela.

=== Ukubaluleka kwamarhwebo ===
Amarhwebo aqakatheke khulu ekukhuliseni umnotho we-[[Isewula Afrika|Sewula Afrika]]. Okhunye kukobana amarhwebo avala iinkhundla zokungasebenzi kwabantu abatjha, ekukuvuleni amathuba womsebenzi.  
</text>
      <sha1>b8wbch5psjoy8wqa1t899we8eeygwno</sha1>
    </revision>
    <revision>
      <id>545</id>
      <parentid>544</parentid>
      <timestamp>2024-07-25T14:17:22Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>545</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1605" sha1="plw6fgcz57odolwdnitth9ivcmnyjdn" xml:space="preserve">[[Isimumathi:Mfundisi Tuckshop.jpg|thumb|Entrepreneur Day at UMP Siyabuswa Campus]]
[[Isimumathi:Trisha'sGlam.jpg|thumb|Student Entrepreneur Day at UMP Siyabuswa Campus]]
'''Abafundi''' bazimisele khulu ngamarhwebo wabo. Manengi tle! amarhwebo avulwe bafundi beYunivesithi yeMpumalanga enzinze nge[[Siyabuswa]]. IYunivesithi yenza isiqiniseko sokobana siyabakhuthaza nokubagqugquzela ekukhuliseni amarhwebo wabo. Ngomnyaka ka-2023 kuKhukhulamungu, iYunivesithi yenza ilanga lokobana abafundi bakhangise amarhwebo wabo ukukhombisa kobana i-Yunivesithi iyabasekela.

=== Ukubaluleka kwamarhwebo ===
Amarhwebo aqakatheke khulu ekukhuliseni umnotho we-[[Isewula Afrika|Sewula Afrika]]. Okhunye kukobana amarhwebo avala iinkhundla zokungasebenzi kwabantu abatjha, ekukuvuleni amathuba womsebenzi.  

Amabhizinisi adlala indima eqakathekileko emphakathini wanamhlanjesi, afaka isandla khulu emikhakheni yezomnotho, yezehlalakuhle, neyamasiko wepilo. Nanzi iindaba eziqakathekileko eziveza ukuqakatheka kwamabhizinisi:  

==== 1. Ukukhula komnotho ====
Amabhizinisi aqhuba ukukhula komnotho ngokudala imisebenzi, ukukhiqiza ipahla nemisebenzi, nokukhiqiza imali. Zifaka isandla emkhiqizweni welizwe elipheleleko (i-GDP) begodu zikhuthaza ukuthuthukiswa komnotho. &lt;ref&gt;The role of business in economic growth | McKinsey&lt;/ref&gt;

==== 2. Imisebenzi ====
Amabhizinisi mthombo omkhulu wemisebenzi, anikela imisebenzi eengidigidini zabantu. Zinikela amathuba wokuthi abantu baziphilise begodu bathuthukise izinga labo lokuphila.&lt;ref&gt;IZA World of Labor - Entrepreneurs and their impact on jobs and economic growth&lt;/ref&gt;
</text>
      <sha1>plw6fgcz57odolwdnitth9ivcmnyjdn</sha1>
    </revision>
    <revision>
      <id>546</id>
      <parentid>545</parentid>
      <timestamp>2024-07-25T14:18:21Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>546</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1596" sha1="gxh6bk1ojha7t9iq71c141azspqjsqa" xml:space="preserve">[[Isimumathi:Mfundisi Tuckshop.jpg|thumb|Entrepreneur Day at UMP Siyabuswa Campus]]
[[Isimumathi:Trisha'sGlam.jpg|thumb|Student Entrepreneur Day at UMP Siyabuswa Campus]]
'''Abafundi''' bazimisele khulu ngamarhwebo wabo. Manengi tle! amarhwebo avulwe bafundi beYunivesithi yeMpumalanga enzinze nge[[Siyabuswa]]. IYunivesithi yenza isiqiniseko sokobana siyabakhuthaza nokubagqugquzela ekukhuliseni amarhwebo wabo. Ngomnyaka ka-2023 kuKhukhulamungu, iYunivesithi yenza ilanga lokobana abafundi bakhangise amarhwebo wabo ukukhombisa kobana i-Yunivesithi iyabasekela.

=== Ukubaluleka kwamarhwebo ===
Amarhwebo aqakatheke khulu ekukhuliseni umnotho we-[[Isewula Afrika|Sewula Afrika]]. Okhunye kukobana amarhwebo avala iinkhundla zokungasebenzi kwabantu abatjha, ekukuvuleni amathuba womsebenzi.  

Amarhwebo adlala indima eqakathekileko emphakathini wanamhlanjesi, afaka isandla khulu emikhakheni yezomnotho, yezehlalakuhle, neyamasiko wepilo. Nanzi iindaba eziqakathekileko eziveza ukuqakatheka kwamabhizinisi:  

==== 1. Ukukhula komnotho ====
Amarhwebo aqhuba ukukhula komnotho ngokudala imisebenzi, ukukhiqiza ipahla nemisebenzi, nokukhiqiza imali. Zifaka isandla emkhiqizweni welizwe elipheleleko (i-GDP) begodu zikhuthaza ukuthuthukiswa komnotho. &lt;ref&gt;The role of business in economic growth | McKinsey&lt;/ref&gt;

==== 2. Imisebenzi ====
Amarhwebo mthombo omkhulu wemisebenzi, anikela imisebenzi eengidigidini zabantu. Zinikela amathuba wokuthi abantu baziphilise begodu bathuthukise izinga labo lokuphila.&lt;ref&gt;IZA World of Labor - Entrepreneurs and their impact on jobs and economic growth&lt;/ref&gt;
</text>
      <sha1>gxh6bk1ojha7t9iq71c141azspqjsqa</sha1>
    </revision>
    <revision>
      <id>547</id>
      <parentid>546</parentid>
      <timestamp>2024-10-14T13:46:34Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>10 revisions imported</comment>
      <origin>546</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1596" sha1="gxh6bk1ojha7t9iq71c141azspqjsqa" xml:space="preserve">[[Isimumathi:Mfundisi Tuckshop.jpg|thumb|Entrepreneur Day at UMP Siyabuswa Campus]]
[[Isimumathi:Trisha'sGlam.jpg|thumb|Student Entrepreneur Day at UMP Siyabuswa Campus]]
'''Abafundi''' bazimisele khulu ngamarhwebo wabo. Manengi tle! amarhwebo avulwe bafundi beYunivesithi yeMpumalanga enzinze nge[[Siyabuswa]]. IYunivesithi yenza isiqiniseko sokobana siyabakhuthaza nokubagqugquzela ekukhuliseni amarhwebo wabo. Ngomnyaka ka-2023 kuKhukhulamungu, iYunivesithi yenza ilanga lokobana abafundi bakhangise amarhwebo wabo ukukhombisa kobana i-Yunivesithi iyabasekela.

=== Ukubaluleka kwamarhwebo ===
Amarhwebo aqakatheke khulu ekukhuliseni umnotho we-[[Isewula Afrika|Sewula Afrika]]. Okhunye kukobana amarhwebo avala iinkhundla zokungasebenzi kwabantu abatjha, ekukuvuleni amathuba womsebenzi.  

Amarhwebo adlala indima eqakathekileko emphakathini wanamhlanjesi, afaka isandla khulu emikhakheni yezomnotho, yezehlalakuhle, neyamasiko wepilo. Nanzi iindaba eziqakathekileko eziveza ukuqakatheka kwamabhizinisi:  

==== 1. Ukukhula komnotho ====
Amarhwebo aqhuba ukukhula komnotho ngokudala imisebenzi, ukukhiqiza ipahla nemisebenzi, nokukhiqiza imali. Zifaka isandla emkhiqizweni welizwe elipheleleko (i-GDP) begodu zikhuthaza ukuthuthukiswa komnotho. &lt;ref&gt;The role of business in economic growth | McKinsey&lt;/ref&gt;

==== 2. Imisebenzi ====
Amarhwebo mthombo omkhulu wemisebenzi, anikela imisebenzi eengidigidini zabantu. Zinikela amathuba wokuthi abantu baziphilise begodu bathuthukise izinga labo lokuphila.&lt;ref&gt;IZA World of Labor - Entrepreneurs and their impact on jobs and economic growth&lt;/ref&gt;
</text>
      <sha1>gxh6bk1ojha7t9iq71c141azspqjsqa</sha1>
    </revision>
    <revision>
      <id>2124</id>
      <parentid>547</parentid>
      <timestamp>2024-11-25T18:16:25Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* Iinkomba */Reflist</comment>
      <origin>2124</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1623" sha1="0ef8qttg2p30nvja1uop594b44dcjgz" xml:space="preserve">[[Isimumathi:Mfundisi Tuckshop.jpg|thumb|Entrepreneur Day at UMP Siyabuswa Campus]]
[[Isimumathi:Trisha'sGlam.jpg|thumb|Student Entrepreneur Day at UMP Siyabuswa Campus]]
'''Abafundi''' bazimisele khulu ngamarhwebo wabo. Manengi tle! amarhwebo avulwe bafundi beYunivesithi yeMpumalanga enzinze nge[[Siyabuswa]]. IYunivesithi yenza isiqiniseko sokobana siyabakhuthaza nokubagqugquzela ekukhuliseni amarhwebo wabo. Ngomnyaka ka-2023 kuKhukhulamungu, iYunivesithi yenza ilanga lokobana abafundi bakhangise amarhwebo wabo ukukhombisa kobana i-Yunivesithi iyabasekela.

=== Ukubaluleka kwamarhwebo ===
Amarhwebo aqakatheke khulu ekukhuliseni umnotho we-[[Isewula Afrika|Sewula Afrika]]. Okhunye kukobana amarhwebo avala iinkhundla zokungasebenzi kwabantu abatjha, ekukuvuleni amathuba womsebenzi.  

Amarhwebo adlala indima eqakathekileko emphakathini wanamhlanjesi, afaka isandla khulu emikhakheni yezomnotho, yezehlalakuhle, neyamasiko wepilo. Nanzi iindaba eziqakathekileko eziveza ukuqakatheka kwamabhizinisi:  

==== 1. Ukukhula komnotho ====
Amarhwebo aqhuba ukukhula komnotho ngokudala imisebenzi, ukukhiqiza ipahla nemisebenzi, nokukhiqiza imali. Zifaka isandla emkhiqizweni welizwe elipheleleko (i-GDP) begodu zikhuthaza ukuthuthukiswa komnotho. &lt;ref&gt;The role of business in economic growth | McKinsey&lt;/ref&gt;

==== 2. Imisebenzi ====
Amarhwebo mthombo omkhulu wemisebenzi, anikela imisebenzi eengidigidini zabantu. Zinikela amathuba wokuthi abantu baziphilise begodu bathuthukise izinga labo lokuphila.&lt;ref&gt;IZA World of Labor - Entrepreneurs and their impact on jobs and economic growth&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}</text>
      <sha1>0ef8qttg2p30nvja1uop594b44dcjgz</sha1>
    </revision>
    <revision>
      <id>3023</id>
      <parentid>2124</parentid>
      <timestamp>2025-06-06T20:30:56Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>oooooooooooooooooo</comment>
      <origin>3023</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1704" sha1="a1he76245p9cuwcsgkxj4n63aty1bqg" xml:space="preserve">[[Isimumathi:Mfundisi Tuckshop.jpg|thumb|Entrepreneur Day at UMP Siyabuswa Campus]]
[[Isimumathi:Trisha'sGlam.jpg|thumb|Student Entrepreneur Day at UMP Siyabuswa Campus]]
'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. Abafundi''' bazimisele khulu ngamarhwebo wabo. Manengi tle! amarhwebo avulwe bafundi beYunivesithi yeMpumalanga enzinze nge[[Siyabuswa]]. IYunivesithi yenza isiqiniseko sokobana siyabakhuthaza nokubagqugquzela ekukhuliseni amarhwebo wabo. Ngomnyaka ka-2023 kuKhukhulamungu, iYunivesithi yenza ilanga lokobana abafundi bakhangise amarhwebo wabo ukukhombisa kobana i-Yunivesithi iyabasekela.

=== Ukubaluleka kwamarhwebo ===
Amarhwebo aqakatheke khulu ekukhuliseni umnotho we-[[Isewula Afrika|Sewula Afrika]]. Okhunye kukobana amarhwebo avala iinkhundla zokungasebenzi kwabantu abatjha, ekukuvuleni amathuba womsebenzi.  

Amarhwebo adlala indima eqakathekileko emphakathini wanamhlanjesi, afaka isandla khulu emikhakheni yezomnotho, yezehlalakuhle, neyamasiko wepilo. Nanzi iindaba eziqakathekileko eziveza ukuqakatheka kwamabhizinisi:  

==== 1. Ukukhula komnotho ====
Amarhwebo aqhuba ukukhula komnotho ngokudala imisebenzi, ukukhiqiza ipahla nemisebenzi, nokukhiqiza imali. Zifaka isandla emkhiqizweni welizwe elipheleleko (i-GDP) begodu zikhuthaza ukuthuthukiswa komnotho. &lt;ref&gt;The role of business in economic growth | McKinsey&lt;/ref&gt;

==== 2. Imisebenzi ====
Amarhwebo mthombo omkhulu wemisebenzi, anikela imisebenzi eengidigidini zabantu. Zinikela amathuba wokuthi abantu baziphilise begodu bathuthukise izinga labo lokuphila.&lt;ref&gt;IZA World of Labor - Entrepreneurs and their impact on jobs and economic growth&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}</text>
      <sha1>a1he76245p9cuwcsgkxj4n63aty1bqg</sha1>
    </revision>
    <revision>
      <id>3042</id>
      <parentid>3023</parentid>
      <timestamp>2025-06-07T03:05:22Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Simakahle Moselekatse|Simakahle Moselekatse]]</comment>
      <origin>2124</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1623" sha1="0ef8qttg2p30nvja1uop594b44dcjgz" xml:space="preserve">[[Isimumathi:Mfundisi Tuckshop.jpg|thumb|Entrepreneur Day at UMP Siyabuswa Campus]]
[[Isimumathi:Trisha'sGlam.jpg|thumb|Student Entrepreneur Day at UMP Siyabuswa Campus]]
'''Abafundi''' bazimisele khulu ngamarhwebo wabo. Manengi tle! amarhwebo avulwe bafundi beYunivesithi yeMpumalanga enzinze nge[[Siyabuswa]]. IYunivesithi yenza isiqiniseko sokobana siyabakhuthaza nokubagqugquzela ekukhuliseni amarhwebo wabo. Ngomnyaka ka-2023 kuKhukhulamungu, iYunivesithi yenza ilanga lokobana abafundi bakhangise amarhwebo wabo ukukhombisa kobana i-Yunivesithi iyabasekela.

=== Ukubaluleka kwamarhwebo ===
Amarhwebo aqakatheke khulu ekukhuliseni umnotho we-[[Isewula Afrika|Sewula Afrika]]. Okhunye kukobana amarhwebo avala iinkhundla zokungasebenzi kwabantu abatjha, ekukuvuleni amathuba womsebenzi.  

Amarhwebo adlala indima eqakathekileko emphakathini wanamhlanjesi, afaka isandla khulu emikhakheni yezomnotho, yezehlalakuhle, neyamasiko wepilo. Nanzi iindaba eziqakathekileko eziveza ukuqakatheka kwamabhizinisi:  

==== 1. Ukukhula komnotho ====
Amarhwebo aqhuba ukukhula komnotho ngokudala imisebenzi, ukukhiqiza ipahla nemisebenzi, nokukhiqiza imali. Zifaka isandla emkhiqizweni welizwe elipheleleko (i-GDP) begodu zikhuthaza ukuthuthukiswa komnotho. &lt;ref&gt;The role of business in economic growth | McKinsey&lt;/ref&gt;

==== 2. Imisebenzi ====
Amarhwebo mthombo omkhulu wemisebenzi, anikela imisebenzi eengidigidini zabantu. Zinikela amathuba wokuthi abantu baziphilise begodu bathuthukise izinga labo lokuphila.&lt;ref&gt;IZA World of Labor - Entrepreneurs and their impact on jobs and economic growth&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}</text>
      <sha1>0ef8qttg2p30nvja1uop594b44dcjgz</sha1>
    </revision>
  </page>
  <page>
    <title>Bantu Holomisa</title>
    <ns>0</ns>
    <id>118</id>
    <revision>
      <id>556</id>
      <timestamp>2024-03-08T13:17:16Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;uBantu Holomisa ungusopolitiki waseSewula Afrika abuye abe ngumholi wecembe leUDM.  &quot;</comment>
      <origin>556</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="84" sha1="ao702ndpaynuwzrwy9lurds9yw8w18u" xml:space="preserve">uBantu Holomisa ungusopolitiki waseSewula Afrika abuye abe ngumholi wecembe leUDM.

</text>
      <sha1>ao702ndpaynuwzrwy9lurds9yw8w18u</sha1>
    </revision>
    <revision>
      <id>557</id>
      <parentid>556</parentid>
      <timestamp>2024-03-08T13:18:21Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>557</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="90" sha1="ckzxuvcyq7kcxevtblvzur6on0a4015" xml:space="preserve">'''uBantu Holomisa''' ungusopolitiki waseSewula Afrika abuye abe ngumholi wecembu leUDM.

</text>
      <sha1>ckzxuvcyq7kcxevtblvzur6on0a4015</sha1>
    </revision>
    <revision>
      <id>558</id>
      <parentid>557</parentid>
      <timestamp>2024-03-09T07:20:11Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>558</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="109" sha1="lt8h99l18anul075mxx2607soumm2m6" xml:space="preserve">'''uBantu Holomisa''' ungusopolitiki wase[[Isewula Afrika|Sewula Afrika]] abuye abe ngumholi wecembu leUDM.

</text>
      <sha1>lt8h99l18anul075mxx2607soumm2m6</sha1>
    </revision>
    <revision>
      <id>559</id>
      <parentid>558</parentid>
      <timestamp>2024-03-09T08:15:48Z</timestamp>
      <contributor>
        <username>incubator&gt;Lethabo19</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Added a picture</comment>
      <origin>559</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="165" sha1="bxd3k4ao87x4p8r9nty3qz1u4g2v1a6" xml:space="preserve">[[Isimumathi:Bantu Holomisa.png|thumb|uBantu Holomisa]]
'''uBantu Holomisa''' ungusopolitiki wase[[Isewula Afrika|Sewula Afrika]] abuye abe ngumholi wecembu leUDM.

</text>
      <sha1>bxd3k4ao87x4p8r9nty3qz1u4g2v1a6</sha1>
    </revision>
    <revision>
      <id>560</id>
      <parentid>559</parentid>
      <timestamp>2024-07-25T14:27:33Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>560</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="920" sha1="hzql0ilzsboi5mu6hj7emv4lmbfligj" xml:space="preserve">[[Isimumathi:Bantu Holomisa.png|thumb|uBantu Holomisa]]
'''uBantu Holomisa''' ungusopolitiki wase[[Isewula Afrika|Sewula Afrika]] abuye abe ngumholi wehlangano leUDM. U-Bantu Holomisa ungumdosiphambili odumileko eSewula Afrika. Wabelethwa mhlazi-25 kuNtaka 1955, ulilunga nomrholi we-United Democratic Movement (UDM), ihlangano yezepolotiki eSewula Afrika. U-Holomisa ekuthomeni wathola uphakamiso ngokuba mrholi e-Transkei, ebegade iyi-bantustan ngesikhathi sebandlululo, lapho asebenza khona njengesikhulu sebutho begodu ngokukhamba kwesikhathi waba yihloko karhulumende. Ngemva kokuphela kwebandlululo, wazibandakanya kwezepolotiki yesitjhaba, wakhuthaza intando yenengi, ukubusa okuhle, nobulungiswa emphakathini. U-Holomisa waziwa ngobujamo bakhe bokukhuluma ngokutjhaphulukileko nokuzibophelela kwakhe ekurarululeni iindaba ezifana nekohlakalo nokungalingani eSewula Afrika. &lt;ref&gt;Bantu Holomisa - Wikipedia&lt;/ref&gt;

</text>
      <sha1>hzql0ilzsboi5mu6hj7emv4lmbfligj</sha1>
    </revision>
    <revision>
      <id>561</id>
      <parentid>560</parentid>
      <timestamp>2024-07-25T14:33:50Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>561</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="171" sha1="0ddx9fgtuwqg9iv5cqxb1w4jkd5vexe" xml:space="preserve">[[Isimumathi:Bantu Holomisa.png|thumb|uBantu Holomisa]]
'''uBantu Holomisa''' ungusopolitiki wase[[Isewula Afrika|Sewula Afrika]] abuye abe ngumholi wehlangano leUDM. . 

</text>
      <sha1>0ddx9fgtuwqg9iv5cqxb1w4jkd5vexe</sha1>
    </revision>
    <revision>
      <id>562</id>
      <parentid>561</parentid>
      <timestamp>2024-07-25T14:35:02Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>562</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="920" sha1="ljs76nhjekjhiib2p12qk23qh71itdd" xml:space="preserve">[[Isimumathi:Bantu Holomisa.png|thumb|uBantu Holomisa]]
'''uBantu Holomisa''' ungusopolitiki wase[[Isewula Afrika|Sewula Afrika]] abuye abe ngumholi wehlangano leUDM. U-Bantu Holomisa ungumdosiphambili odumileko eSewula Afrika. Wabelethwa mhlazi-25 kuNtaka 1955, ulilunga nomrholi we-United Democratic Movement (UDM), ihlangano yezepolotiki eSewula Afrika. U-Holomisa ekuthomeni wathola uphakamiso ngokuba mrholi e-Transkei, ebegade iyi-bantustan ngesikhathi sebandlululo, lapho asebenza khona njengesikhulu sebutho begodu ngokukhamba kwesikhathi waba yihloko karhulumende. Ngemva kokuphela kwebandlululo, wazibandakanya kwezepolotiki yesitjhaba, wakhuthaza intando yenengi, ukubusa okuhle, nobulungiswa emphakathini. U-Holomisa waziwa ngobujamo bakhe bokukhuluma ngokutjhaphulukileko nokuzibophelela kwakhe ekurarululeni iindaba ezifana nekohlakalo nokungalingani eSewula Afrika.&lt;ref&gt;Bantu Holomisa - Wikipedia&lt;/ref&gt; 

</text>
      <sha1>ljs76nhjekjhiib2p12qk23qh71itdd</sha1>
    </revision>
    <revision>
      <id>563</id>
      <parentid>562</parentid>
      <timestamp>2024-10-14T13:46:35Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>7 revisions imported</comment>
      <origin>562</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="920" sha1="ljs76nhjekjhiib2p12qk23qh71itdd" xml:space="preserve">[[Isimumathi:Bantu Holomisa.png|thumb|uBantu Holomisa]]
'''uBantu Holomisa''' ungusopolitiki wase[[Isewula Afrika|Sewula Afrika]] abuye abe ngumholi wehlangano leUDM. U-Bantu Holomisa ungumdosiphambili odumileko eSewula Afrika. Wabelethwa mhlazi-25 kuNtaka 1955, ulilunga nomrholi we-United Democratic Movement (UDM), ihlangano yezepolotiki eSewula Afrika. U-Holomisa ekuthomeni wathola uphakamiso ngokuba mrholi e-Transkei, ebegade iyi-bantustan ngesikhathi sebandlululo, lapho asebenza khona njengesikhulu sebutho begodu ngokukhamba kwesikhathi waba yihloko karhulumende. Ngemva kokuphela kwebandlululo, wazibandakanya kwezepolotiki yesitjhaba, wakhuthaza intando yenengi, ukubusa okuhle, nobulungiswa emphakathini. U-Holomisa waziwa ngobujamo bakhe bokukhuluma ngokutjhaphulukileko nokuzibophelela kwakhe ekurarululeni iindaba ezifana nekohlakalo nokungalingani eSewula Afrika.&lt;ref&gt;Bantu Holomisa - Wikipedia&lt;/ref&gt; 

</text>
      <sha1>ljs76nhjekjhiib2p12qk23qh71itdd</sha1>
    </revision>
    <revision>
      <id>1877</id>
      <parentid>563</parentid>
      <timestamp>2024-11-12T18:02:14Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>uBantu Holomisa, 2019</comment>
      <origin>1877</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="923" sha1="osqy7gd65e3pkfc7w5g3692cjo4ubt5" xml:space="preserve">[[Isimumathi:Bantu Holomisa.png|thumb|uBantu Holomisa, 2019]]
'''uBantu Holomisa''' ungusopolitiki wase[[Isewula Afrika|Sewula Afrika]] abuye abe ngumholi wehlangano leUDM. U-Bantu Holomisa ungumdosiphambili odumileko eSewula Afrika. Wabelethwa mhlazi-25 kuNtaka 1955, ulilunga nomrholi we-United Democratic Movement (UDM), ihlangano yezepolotiki eSewula Afrika. U-Holomisa ekuthomeni wathola uphakamiso ngokuba mrholi e-Transkei, ebegade iyi-bantustan ngesikhathi sebandlululo, lapho asebenza khona njengesikhulu sebutho begodu ngokukhamba kwesikhathi waba yihloko karhulumende. Ngemva kokuphela kwebandlululo, wazibandakanya kwezepolotiki yesitjhaba, wakhuthaza intando yenengi, ukubusa okuhle, nobulungiswa emphakathini. U-Holomisa waziwa ngobujamo bakhe bokukhuluma ngokutjhaphulukileko nokuzibophelela kwakhe ekurarululeni iindaba ezifana nekohlakalo nokungalingani eSewula Afrika.&lt;ref&gt;Bantu Holomisa - Wikipedia&lt;/ref&gt;</text>
      <sha1>osqy7gd65e3pkfc7w5g3692cjo4ubt5</sha1>
    </revision>
    <revision>
      <id>1882</id>
      <parentid>1877</parentid>
      <timestamp>2024-11-12T18:55:41Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <comment>uBantu Holomisa ka 2019</comment>
      <origin>1882</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="925" sha1="1mn0nqpyongl96qrb312zebsg5rqx0s" xml:space="preserve">[[Isimumathi:Bantu Holomisa.png|thumb|uBantu Holomisa ka 2019]]
'''uBantu Holomisa''' ungusopolitiki wase[[Isewula Afrika|Sewula Afrika]] abuye abe ngumholi wehlangano leUDM. U-Bantu Holomisa ungumdosiphambili odumileko eSewula Afrika. Wabelethwa mhlazi-25 kuNtaka 1955, ulilunga nomrholi we-United Democratic Movement (UDM), ihlangano yezepolotiki eSewula Afrika. U-Holomisa ekuthomeni wathola uphakamiso ngokuba mrholi e-Transkei, ebegade iyi-bantustan ngesikhathi sebandlululo, lapho asebenza khona njengesikhulu sebutho begodu ngokukhamba kwesikhathi waba yihloko karhulumende. Ngemva kokuphela kwebandlululo, wazibandakanya kwezepolotiki yesitjhaba, wakhuthaza intando yenengi, ukubusa okuhle, nobulungiswa emphakathini. U-Holomisa waziwa ngobujamo bakhe bokukhuluma ngokutjhaphulukileko nokuzibophelela kwakhe ekurarululeni iindaba ezifana nekohlakalo nokungalingani eSewula Afrika.&lt;ref&gt;Bantu Holomisa - Wikipedia&lt;/ref&gt;</text>
      <sha1>1mn0nqpyongl96qrb312zebsg5rqx0s</sha1>
    </revision>
    <revision>
      <id>2156</id>
      <parentid>1882</parentid>
      <timestamp>2024-11-27T05:37:04Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>+ Iinkomba</comment>
      <origin>2156</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="953" sha1="nakhpk07ed63lzssvr22phexnkmeepc" xml:space="preserve">[[Isimumathi:Bantu Holomisa.png|thumb|uBantu Holomisa ka 2019]]
'''uBantu Holomisa''' ungusopolitiki wase[[Isewula Afrika|Sewula Afrika]] abuye abe ngumholi wehlangano leUDM. U-Bantu Holomisa ungumdosiphambili odumileko eSewula Afrika. Wabelethwa mhlazi-25 kuNtaka 1955, ulilunga nomrholi we-United Democratic Movement (UDM), ihlangano yezepolotiki eSewula Afrika. U-Holomisa ekuthomeni wathola uphakamiso ngokuba mrholi e-Transkei, ebegade iyi-bantustan ngesikhathi sebandlululo, lapho asebenza khona njengesikhulu sebutho begodu ngokukhamba kwesikhathi waba yihloko karhulumende. Ngemva kokuphela kwebandlululo, wazibandakanya kwezepolotiki yesitjhaba, wakhuthaza intando yenengi, ukubusa okuhle, nobulungiswa emphakathini. U-Holomisa waziwa ngobujamo bakhe bokukhuluma ngokutjhaphulukileko nokuzibophelela kwakhe ekurarululeni iindaba ezifana nekohlakalo nokungalingani eSewula Afrika.&lt;ref&gt;Bantu Holomisa - Wikipedia&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}</text>
      <sha1>nakhpk07ed63lzssvr22phexnkmeepc</sha1>
    </revision>
    <revision>
      <id>2180</id>
      <parentid>2156</parentid>
      <timestamp>2024-11-28T09:12:08Z</timestamp>
      <contributor>
        <ip>104.255.173.142</ip>
      </contributor>
      <comment>uHolomisa ngomnyaka ka-2019</comment>
      <origin>2180</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="957" sha1="ldljsvriannxopuya44vi2wi3hkal27" xml:space="preserve">[[Isimumathi:Bantu Holomisa.png|thumb|uHolomisa ngomnyaka ka-2019]]
'''uBantu Holomisa''' ungusopolitiki wase[[Isewula Afrika|Sewula Afrika]] abuye abe ngumholi wehlangano leUDM. U-Bantu Holomisa ungumdosiphambili odumileko eSewula Afrika. Wabelethwa mhlazi-25 kuNtaka 1955, ulilunga nomrholi we-United Democratic Movement (UDM), ihlangano yezepolotiki eSewula Afrika. U-Holomisa ekuthomeni wathola uphakamiso ngokuba mrholi e-Transkei, ebegade iyi-bantustan ngesikhathi sebandlululo, lapho asebenza khona njengesikhulu sebutho begodu ngokukhamba kwesikhathi waba yihloko karhulumende. Ngemva kokuphela kwebandlululo, wazibandakanya kwezepolotiki yesitjhaba, wakhuthaza intando yenengi, ukubusa okuhle, nobulungiswa emphakathini. U-Holomisa waziwa ngobujamo bakhe bokukhuluma ngokutjhaphulukileko nokuzibophelela kwakhe ekurarululeni iindaba ezifana nekohlakalo nokungalingani eSewula Afrika.&lt;ref&gt;Bantu Holomisa - Wikipedia&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}</text>
      <sha1>ldljsvriannxopuya44vi2wi3hkal27</sha1>
    </revision>
    <revision>
      <id>2902</id>
      <parentid>2180</parentid>
      <timestamp>2025-06-06T16:39:39Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>The Nether</comment>
      <origin>2902</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1038" sha1="sutfuf9rlmqp4qnx4tdcgfd41c10hiv" xml:space="preserve">[[Isimumathi:Bantu Holomisa.png|thumb|uHolomisa ngomnyaka ka-2019]]
'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. uBantu Holomisa''' ungusopolitiki wase[[Isewula Afrika|Sewula Afrika]] abuye abe ngumholi wehlangano leUDM. U-Bantu Holomisa ungumdosiphambili odumileko eSewula Afrika. Wabelethwa mhlazi-25 kuNtaka 1955, ulilunga nomrholi we-United Democratic Movement (UDM), ihlangano yezepolotiki eSewula Afrika. U-Holomisa ekuthomeni wathola uphakamiso ngokuba mrholi e-Transkei, ebegade iyi-bantustan ngesikhathi sebandlululo, lapho asebenza khona njengesikhulu sebutho begodu ngokukhamba kwesikhathi waba yihloko karhulumende. Ngemva kokuphela kwebandlululo, wazibandakanya kwezepolotiki yesitjhaba, wakhuthaza intando yenengi, ukubusa okuhle, nobulungiswa emphakathini. U-Holomisa waziwa ngobujamo bakhe bokukhuluma ngokutjhaphulukileko nokuzibophelela kwakhe ekurarululeni iindaba ezifana nekohlakalo nokungalingani eSewula Afrika.&lt;ref&gt;Bantu Holomisa - Wikipedia&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}</text>
      <sha1>sutfuf9rlmqp4qnx4tdcgfd41c10hiv</sha1>
    </revision>
    <revision>
      <id>3122</id>
      <parentid>2902</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:104.255.173.142|104.255.173.142]]</comment>
      <origin>2180</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="957" sha1="ldljsvriannxopuya44vi2wi3hkal27" xml:space="preserve">[[Isimumathi:Bantu Holomisa.png|thumb|uHolomisa ngomnyaka ka-2019]]
'''uBantu Holomisa''' ungusopolitiki wase[[Isewula Afrika|Sewula Afrika]] abuye abe ngumholi wehlangano leUDM. U-Bantu Holomisa ungumdosiphambili odumileko eSewula Afrika. Wabelethwa mhlazi-25 kuNtaka 1955, ulilunga nomrholi we-United Democratic Movement (UDM), ihlangano yezepolotiki eSewula Afrika. U-Holomisa ekuthomeni wathola uphakamiso ngokuba mrholi e-Transkei, ebegade iyi-bantustan ngesikhathi sebandlululo, lapho asebenza khona njengesikhulu sebutho begodu ngokukhamba kwesikhathi waba yihloko karhulumende. Ngemva kokuphela kwebandlululo, wazibandakanya kwezepolotiki yesitjhaba, wakhuthaza intando yenengi, ukubusa okuhle, nobulungiswa emphakathini. U-Holomisa waziwa ngobujamo bakhe bokukhuluma ngokutjhaphulukileko nokuzibophelela kwakhe ekurarululeni iindaba ezifana nekohlakalo nokungalingani eSewula Afrika.&lt;ref&gt;Bantu Holomisa - Wikipedia&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}</text>
      <sha1>ldljsvriannxopuya44vi2wi3hkal27</sha1>
    </revision>
  </page>
  <page>
    <title>Benni McCarthy</title>
    <ns>0</ns>
    <id>119</id>
    <revision>
      <id>564</id>
      <timestamp>2024-05-20T11:48:22Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;U-Benedict Saul &quot;Benni&quot; McCarthy (owazalwa ngo-12 Novemba 1977) ungumqeqeshi waseSewula Afriak kunye nomdlali webhola ekhatywayo owayesakuba ngumqeqeshi weqela lokuqala kwiManchester United . Kutshanje usebenze njengomqeqeshi oyintloko weqela laMaZulu elikwiPremier Division. &lt;ref&gt;https://www.thesouthafrican.com/sport/soccer/psl-south-africa/kaizer-chiefs-benni-mccarthy-reveals-next-move-pitso-mosimane-orlando-pirates/&lt;/ref&gt;  &quot;</comment>
      <origin>564</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="429" sha1="byqkd84ct5k0ieyxk165ya9llqy6ua2" xml:space="preserve">U-Benedict Saul &quot;Benni&quot; McCarthy (owazalwa ngo-12 Novemba 1977) ungumqeqeshi waseSewula Afriak kunye nomdlali webhola ekhatywayo owayesakuba ngumqeqeshi weqela lokuqala kwiManchester United . Kutshanje usebenze njengomqeqeshi oyintloko weqela laMaZulu elikwiPremier Division. &lt;ref&gt;https://www.thesouthafrican.com/sport/soccer/psl-south-africa/kaizer-chiefs-benni-mccarthy-reveals-next-move-pitso-mosimane-orlando-pirates/&lt;/ref&gt;

</text>
      <sha1>byqkd84ct5k0ieyxk165ya9llqy6ua2</sha1>
    </revision>
    <revision>
      <id>565</id>
      <parentid>564</parentid>
      <timestamp>2024-07-25T14:40:40Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>565</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1329" sha1="thet85vjuaee5bihuyhebyj2kpozs98" xml:space="preserve">U-Benni McCarthy, owabelethwa ngu-Benedict Saul McCarthy mhlana ali-12 kuNobayeni wee-1977, e-Cape Town, eSewula Afrika, mdlali webholo odumileko begodu mrhelebhi webholo wamanje. Njengomdlali, u-McCarthy bekangumdlali ophuma phambili owaziwa ngekghono lakhe lokushaya amagoli. Waba nomsebenzi ophumeleleko wesiqhema e-Europe, adlalela amathimu afana ne-Ajax Amsterdam, Celta Vigo, FC Porto, Blackburn Rovers, kanye ne-West Ham United. Enye yezinto aziphumeleleko khulu bekukuthumba i-UEFA Champions League ne-FC Porto ngo-2004 ngaphasi kokulawulwa kwaka-José Mourinho.

UMcCarthy naye waba nomthelela omkhulu esiteji samazwe ngamazwe, ajamele iSewula Afrika emiqhudelwaneni eminengi yeNdebe yamaZwe ye-Afrika kanye neNdebe yePhasi ye-FIFA. Ngemva kokuthatha umhlalaphasi njengomdlali, watjhuguluka waba mqeqetjhi begodu ube nemisebenzi ehlukileko yokuba mqeqetjhi, okufaka hlangana ukuphatha i-Cape Town City FC ku-South African Premier Soccer League nokusebenza njengomsizi womqeqetjhi we-Manchester United. U-McCarthy ugujwa ngegalelo lakhe ebholweni ngaphakathi nangaphandle kwenkundla. Kutshanje usebenze njengomqeqeshi oyintloko weqela laMaZulu elikwiPremier Division. &lt;ref&gt;https://www.thesouthafrican.com/sport/soccer/psl-south-africa/kaizer-chiefs-benni-mccarthy-reveals-next-move-pitso-mosimane-orlando-pirates/&lt;/ref&gt;

</text>
      <sha1>thet85vjuaee5bihuyhebyj2kpozs98</sha1>
    </revision>
    <revision>
      <id>566</id>
      <parentid>565</parentid>
      <timestamp>2024-10-14T13:46:35Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>565</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1329" sha1="thet85vjuaee5bihuyhebyj2kpozs98" xml:space="preserve">U-Benni McCarthy, owabelethwa ngu-Benedict Saul McCarthy mhlana ali-12 kuNobayeni wee-1977, e-Cape Town, eSewula Afrika, mdlali webholo odumileko begodu mrhelebhi webholo wamanje. Njengomdlali, u-McCarthy bekangumdlali ophuma phambili owaziwa ngekghono lakhe lokushaya amagoli. Waba nomsebenzi ophumeleleko wesiqhema e-Europe, adlalela amathimu afana ne-Ajax Amsterdam, Celta Vigo, FC Porto, Blackburn Rovers, kanye ne-West Ham United. Enye yezinto aziphumeleleko khulu bekukuthumba i-UEFA Champions League ne-FC Porto ngo-2004 ngaphasi kokulawulwa kwaka-José Mourinho.

UMcCarthy naye waba nomthelela omkhulu esiteji samazwe ngamazwe, ajamele iSewula Afrika emiqhudelwaneni eminengi yeNdebe yamaZwe ye-Afrika kanye neNdebe yePhasi ye-FIFA. Ngemva kokuthatha umhlalaphasi njengomdlali, watjhuguluka waba mqeqetjhi begodu ube nemisebenzi ehlukileko yokuba mqeqetjhi, okufaka hlangana ukuphatha i-Cape Town City FC ku-South African Premier Soccer League nokusebenza njengomsizi womqeqetjhi we-Manchester United. U-McCarthy ugujwa ngegalelo lakhe ebholweni ngaphakathi nangaphandle kwenkundla. Kutshanje usebenze njengomqeqeshi oyintloko weqela laMaZulu elikwiPremier Division. &lt;ref&gt;https://www.thesouthafrican.com/sport/soccer/psl-south-africa/kaizer-chiefs-benni-mccarthy-reveals-next-move-pitso-mosimane-orlando-pirates/&lt;/ref&gt;

</text>
      <sha1>thet85vjuaee5bihuyhebyj2kpozs98</sha1>
    </revision>
    <revision>
      <id>2122</id>
      <parentid>566</parentid>
      <timestamp>2024-11-25T18:14:42Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <comment>'''</comment>
      <origin>2122</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1333" sha1="91xpfx2whya763cyuibaoi9ccw61d09" xml:space="preserve">'''U-Benni McCarthy''', owabelethwa ngu-Benedict Saul McCarthy mhlana ali-12 kuNobayeni wee-1977, e-Cape Town, eSewula Afrika, mdlali webholo odumileko begodu mrhelebhi webholo wamanje. Njengomdlali, u-McCarthy bekangumdlali ophuma phambili owaziwa ngekghono lakhe lokushaya amagoli. Waba nomsebenzi ophumeleleko wesiqhema e-Europe, adlalela amathimu afana ne-Ajax Amsterdam, Celta Vigo, FC Porto, Blackburn Rovers, kanye ne-West Ham United. Enye yezinto aziphumeleleko khulu bekukuthumba i-UEFA Champions League ne-FC Porto ngo-2004 ngaphasi kokulawulwa kwaka-José Mourinho.

UMcCarthy naye waba nomthelela omkhulu esiteji samazwe ngamazwe, ajamele iSewula Afrika emiqhudelwaneni eminengi yeNdebe yamaZwe ye-Afrika kanye neNdebe yePhasi ye-FIFA. Ngemva kokuthatha umhlalaphasi njengomdlali, watjhuguluka waba mqeqetjhi begodu ube nemisebenzi ehlukileko yokuba mqeqetjhi, okufaka hlangana ukuphatha i-Cape Town City FC ku-South African Premier Soccer League nokusebenza njengomsizi womqeqetjhi we-Manchester United. U-McCarthy ugujwa ngegalelo lakhe ebholweni ngaphakathi nangaphandle kwenkundla. Kutshanje usebenze njengomqeqeshi oyintloko weqela laMaZulu elikwiPremier Division. &lt;ref&gt;https://www.thesouthafrican.com/sport/soccer/psl-south-africa/kaizer-chiefs-benni-mccarthy-reveals-next-move-pitso-mosimane-orlando-pirates/&lt;/ref&gt;</text>
      <sha1>91xpfx2whya763cyuibaoi9ccw61d09</sha1>
    </revision>
    <revision>
      <id>2130</id>
      <parentid>2122</parentid>
      <timestamp>2024-11-25T18:25:05Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>+ Iinkomba</comment>
      <origin>2130</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1361" sha1="e06uqm33na58ocszm98yodbwmf6mw7x" xml:space="preserve">'''U-Benni McCarthy''', owabelethwa ngu-Benedict Saul McCarthy mhlana ali-12 kuNobayeni wee-1977, e-Cape Town, eSewula Afrika, mdlali webholo odumileko begodu mrhelebhi webholo wamanje. Njengomdlali, u-McCarthy bekangumdlali ophuma phambili owaziwa ngekghono lakhe lokushaya amagoli. Waba nomsebenzi ophumeleleko wesiqhema e-Europe, adlalela amathimu afana ne-Ajax Amsterdam, Celta Vigo, FC Porto, Blackburn Rovers, kanye ne-West Ham United. Enye yezinto aziphumeleleko khulu bekukuthumba i-UEFA Champions League ne-FC Porto ngo-2004 ngaphasi kokulawulwa kwaka-José Mourinho.

UMcCarthy naye waba nomthelela omkhulu esiteji samazwe ngamazwe, ajamele iSewula Afrika emiqhudelwaneni eminengi yeNdebe yamaZwe ye-Afrika kanye neNdebe yePhasi ye-FIFA. Ngemva kokuthatha umhlalaphasi njengomdlali, watjhuguluka waba mqeqetjhi begodu ube nemisebenzi ehlukileko yokuba mqeqetjhi, okufaka hlangana ukuphatha i-Cape Town City FC ku-South African Premier Soccer League nokusebenza njengomsizi womqeqetjhi we-Manchester United. U-McCarthy ugujwa ngegalelo lakhe ebholweni ngaphakathi nangaphandle kwenkundla. Kutshanje usebenze njengomqeqeshi oyintloko weqela laMaZulu elikwiPremier Division. &lt;ref&gt;https://www.thesouthafrican.com/sport/soccer/psl-south-africa/kaizer-chiefs-benni-mccarthy-reveals-next-move-pitso-mosimane-orlando-pirates/&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}</text>
      <sha1>e06uqm33na58ocszm98yodbwmf6mw7x</sha1>
    </revision>
  </page>
  <page>
    <title>Bhiza Masango</title>
    <ns>0</ns>
    <id>120</id>
    <revision>
      <id>567</id>
      <timestamp>2016-02-26T22:13:49Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Bhiza David Masango''' (4 kuKhukhulamungu 1951) ngumtloli owaziwa khulu ngomtlolo wedrama '''&quot; Larhwalala Nobani&quot;'''. Wabelethelwa endaweni ye - Wonderfontein esigodini se-...&quot;</comment>
      <origin>567</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2913" sha1="n3crt957lo8qev3pxk7qi742j1728jm" xml:space="preserve">'''Bhiza David Masango''' (4 kuKhukhulamungu 1951) ngumtloli owaziwa khulu ngomtlolo wedrama '''&quot; Larhwalala Nobani&quot;'''. Wabelethelwa endaweni ye - Wonderfontein esigodini se-Middelburg, begodu Wakhulela e-Paynevile eSprings wabe wafika ebangeni lokuthoma isikolo.&lt;ref name=ph1&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt; 

__TOC__
==Iifundo:==
Ngamabanga athileko womsebenzi ababelethi bafudukela e-Bronkhorstspruit lapha athoma khona isikolo e-Uitkyk Community School. Wafunda khona kufikela ebangeni lesibili. Ngomnyaka we-1965 wathuthukela e-Middelburg esikoleni i-Eikeboom Colliery School kusukela ebangeni lesithathu kuya kelesine. Wabe sekathuthukela eMhluzi esikolweni Elusindisweni Higher Primary School wafunda waqeda ibanga lesithandathu khona. Wabamba itorho e-RMB Steel alloys alinga ukubuthelela amatikana wokuragela phambili, wabuyela esikolweni eSozama Secondary School lapha afunda khona waqeda ibanga lobunane. Ngomnyaka we-1974 waqatjhwa njengotitjhere wesigiyane eNdedema Community school wafundisa ibanga lesihlanu ,ngonyaka olandelako wafundisa ibanga lesihlanu nelesithandathu.&lt;ref name=ph1&gt;&lt;/ref&gt;

Ngomnyaka we-1976 athuthukela eBotshabelo Training College lapho aphetha khona iimfundo zakhe zobutitjhere. Waqedelela ngokobana aphothule i-diploma yeemfundo zomthetho ngokukhamba kweminyaka wafumana iziqu ze (Human Resource Management). Waqatjhwa godu ngobutjhwa esikoleni iNdedema Community School kufikela ngomnyaka we-1979,wathuthukela eMthunzini Higher Primary School eKwaggafontein KwaNdebele waba sisandla sika titjherehloko. Nokho akhenge ahlale isikhathi wathuthuka ngenyanga kaMgwengweni ngomnyaka we-1980 wathoma isikolo esitjha iSindawonye Higher Primary School lapha aba yihloko yesikolo kufikela ngomnyaka we 1992.&lt;ref name=ph1&gt;&lt;/ref&gt;

==Ubutloli:==
Ngesikhatheso waba sele alilunga leBhodo yeLimi lesiNdebele begodu amtloli. Ngenyanga kaSewula 1992 waqatjhwa ukuba njengeSekela likamqophisi ePhikweni
leLimi bekube khathesi.&lt;ref name=ph1&gt;&lt;/ref&gt; Umtloli lo wa tlola amadrama begodu nendatjana eziningana, ezinye ngezilandilako:

# - Larhwalala Nobani 
# - Uzangenzani
# - Amabatha

&lt;blockquote class=&quot;toccolours&quot; style=&quot;float:none; padding: 10px 15px 10px 15px; display:table;&quot;&gt;&quot;Nzunza nomanala ngibawela incwadi le eyinoveli ezingqondweni zenu bonyana ihlale inzinze ibe yinzunzo kini. Nginethemba elikhulu bona nizayithola inesifundo esihle khulu khulu kebengubo kunye namatlawu. Ihlathulula kuhle bonyana ihlama iyayidungu ingqondo yomuntu, aphelele ngokuzikholwa bona kufanele aphile yiphi ipilo. Kungebangelo-ke kutholakala umuntu angazazi bona usisibekelo sayiphi ipolo&quot;--&quot;Amabatha (unfaithful) B.D Masango.&lt;/blockquote&gt; 

==Isithasiselo==
&lt;references/&gt;

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>n3crt957lo8qev3pxk7qi742j1728jm</sha1>
    </revision>
    <revision>
      <id>568</id>
      <parentid>567</parentid>
      <timestamp>2016-02-26T22:14:19Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Ubutloli: */</comment>
      <origin>568</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2918" sha1="cs5e8fm11txvh6vt225h6e1szo8hwhd" xml:space="preserve">'''Bhiza David Masango''' (4 kuKhukhulamungu 1951) ngumtloli owaziwa khulu ngomtlolo wedrama '''&quot; Larhwalala Nobani&quot;'''. Wabelethelwa endaweni ye - Wonderfontein esigodini se-Middelburg, begodu Wakhulela e-Paynevile eSprings wabe wafika ebangeni lokuthoma isikolo.&lt;ref name=ph1&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt; 

__TOC__
==Iifundo:==
Ngamabanga athileko womsebenzi ababelethi bafudukela e-Bronkhorstspruit lapha athoma khona isikolo e-Uitkyk Community School. Wafunda khona kufikela ebangeni lesibili. Ngomnyaka we-1965 wathuthukela e-Middelburg esikoleni i-Eikeboom Colliery School kusukela ebangeni lesithathu kuya kelesine. Wabe sekathuthukela eMhluzi esikolweni Elusindisweni Higher Primary School wafunda waqeda ibanga lesithandathu khona. Wabamba itorho e-RMB Steel alloys alinga ukubuthelela amatikana wokuragela phambili, wabuyela esikolweni eSozama Secondary School lapha afunda khona waqeda ibanga lobunane. Ngomnyaka we-1974 waqatjhwa njengotitjhere wesigiyane eNdedema Community school wafundisa ibanga lesihlanu ,ngonyaka olandelako wafundisa ibanga lesihlanu nelesithandathu.&lt;ref name=ph1&gt;&lt;/ref&gt;

Ngomnyaka we-1976 athuthukela eBotshabelo Training College lapho aphetha khona iimfundo zakhe zobutitjhere. Waqedelela ngokobana aphothule i-diploma yeemfundo zomthetho ngokukhamba kweminyaka wafumana iziqu ze (Human Resource Management). Waqatjhwa godu ngobutjhwa esikoleni iNdedema Community School kufikela ngomnyaka we-1979,wathuthukela eMthunzini Higher Primary School eKwaggafontein KwaNdebele waba sisandla sika titjherehloko. Nokho akhenge ahlale isikhathi wathuthuka ngenyanga kaMgwengweni ngomnyaka we-1980 wathoma isikolo esitjha iSindawonye Higher Primary School lapha aba yihloko yesikolo kufikela ngomnyaka we 1992.&lt;ref name=ph1&gt;&lt;/ref&gt;

==Ubutloli:==
Ngesikhatheso waba sele alilunga leBhodo yeLimi lesiNdebele begodu amtloli. Ngenyanga kaSewula 1992 waqatjhwa ukuba njengeSekela likamqophisi ePhikweni
leLimi bekube khathesi.&lt;ref name=ph1&gt;&lt;/ref&gt; Umtloli lo wa tlola amadrama begodu nendatjana eziningana, ezinye ngezilandilako:

# - Larhwalala Nobani 
# - Uzangenzani
# - Amabatha

&lt;blockquote class=&quot;toccolours&quot; style=&quot;float:none; padding: 10px 15px 10px 15px; display:table;&quot;&gt;&quot;Nzunza nomanala ngibawela incwadi le eyinoveli ezingqondweni zenu bonyana ihlale inzinze ibe yinzunzo kini. Nginethemba elikhulu bona nizayithola inesifundo esihle khulu khulu kebengubo kunye namatlawu. Ihlathulula kuhle bonyana ihlama iyayidungu ingqondo yomuntu, aphelele ngokuzikholwa bona kufanele aphile yiphi ipilo. Kungebangelo-ke kutholakala umuntu angazazi bona usisibekelo sayiphi ipolo&quot;--&quot;'''Amabatha (unfaithful) B.D Masango'''.&lt;/blockquote&gt;

==Isithasiselo==
&lt;references/&gt;

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>cs5e8fm11txvh6vt225h6e1szo8hwhd</sha1>
    </revision>
    <revision>
      <id>569</id>
      <parentid>568</parentid>
      <timestamp>2016-02-26T22:24:06Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Ubutloli: */</comment>
      <origin>569</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3221" sha1="3nepwc61xwuo9fnys8cgce6p59romk9" xml:space="preserve">'''Bhiza David Masango''' (4 kuKhukhulamungu 1951) ngumtloli owaziwa khulu ngomtlolo wedrama '''&quot; Larhwalala Nobani&quot;'''. Wabelethelwa endaweni ye - Wonderfontein esigodini se-Middelburg, begodu Wakhulela e-Paynevile eSprings wabe wafika ebangeni lokuthoma isikolo.&lt;ref name=ph1&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt; 

__TOC__
==Iifundo:==
Ngamabanga athileko womsebenzi ababelethi bafudukela e-Bronkhorstspruit lapha athoma khona isikolo e-Uitkyk Community School. Wafunda khona kufikela ebangeni lesibili. Ngomnyaka we-1965 wathuthukela e-Middelburg esikoleni i-Eikeboom Colliery School kusukela ebangeni lesithathu kuya kelesine. Wabe sekathuthukela eMhluzi esikolweni Elusindisweni Higher Primary School wafunda waqeda ibanga lesithandathu khona. Wabamba itorho e-RMB Steel alloys alinga ukubuthelela amatikana wokuragela phambili, wabuyela esikolweni eSozama Secondary School lapha afunda khona waqeda ibanga lobunane. Ngomnyaka we-1974 waqatjhwa njengotitjhere wesigiyane eNdedema Community school wafundisa ibanga lesihlanu ,ngonyaka olandelako wafundisa ibanga lesihlanu nelesithandathu.&lt;ref name=ph1&gt;&lt;/ref&gt;

Ngomnyaka we-1976 athuthukela eBotshabelo Training College lapho aphetha khona iimfundo zakhe zobutitjhere. Waqedelela ngokobana aphothule i-diploma yeemfundo zomthetho ngokukhamba kweminyaka wafumana iziqu ze (Human Resource Management). Waqatjhwa godu ngobutjhwa esikoleni iNdedema Community School kufikela ngomnyaka we-1979,wathuthukela eMthunzini Higher Primary School eKwaggafontein KwaNdebele waba sisandla sika titjherehloko. Nokho akhenge ahlale isikhathi wathuthuka ngenyanga kaMgwengweni ngomnyaka we-1980 wathoma isikolo esitjha iSindawonye Higher Primary School lapha aba yihloko yesikolo kufikela ngomnyaka we 1992.&lt;ref name=ph1&gt;&lt;/ref&gt;

==Ubutloli:==
Ngesikhatheso waba sele alilunga leBhodo yeLimi lesiNdebele begodu amtloli. Ngenyanga kaSewula 1992 waqatjhwa ukuba njengeSekela likamqophisi ePhikweni
leLimi bekube khathesi.&lt;ref name=ph1&gt;&lt;/ref&gt; 

&lt;blockquote class=&quot;toccolours&quot; style=&quot;float:none; padding: 10px 15px 10px 15px; display:table;&quot;&gt;&quot;Nzunza nomanala ngibawela incwadi le eyinoveli ezingqondweni zenu bonyana ihlale inzinze ibe yinzunzo kini. Nginethemba elikhulu bona nizayithola inesifundo esihle khulu khulu kebengubo kunye namatlawu. Ihlathulula kuhle bonyana ihlama iyayidungu ingqondo yomuntu, aphelele ngokuzikholwa bona kufanele aphile yiphi ipilo. Kungebangelo-ke kutholakala umuntu angazazi bona usisibekelo sayiphi ipolo&quot;--&quot;'''Amabatha (unfaithful) B.D Masango'''.&lt;/blockquote&gt;


Umtloli lo wa tlola amadrama begodu nendatjana eziningana, ezinye ngezilandilako:

# - Zithabiseni ngeenkondlo (''1990'')
# - Isilodlhelo sakaNzunza noManala (''1990'')
# - Yewize sifunde : ibanga (''1990'')
# - Zithabiseni ngeenkondlo 2 (''1992'')
# - Ngifanele ukuzenzela (''1992'')
# - Umuntu akahlobokwa (''1992 godu ngo 1995)
# - Ubadanile (''1992 godu ngo 1995'')
# - Uzangenzani (''1994'')
# - Amabatha (''1995 godu ngo 1996'')

==Isithasiselo==
&lt;references/&gt;

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>3nepwc61xwuo9fnys8cgce6p59romk9</sha1>
    </revision>
    <revision>
      <id>570</id>
      <parentid>569</parentid>
      <timestamp>2016-02-26T22:24:24Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Ubutloli: */</comment>
      <origin>570</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3220" sha1="syak612kf6p9exyjdjbb3fls8nv9pc8" xml:space="preserve">'''Bhiza David Masango''' (4 kuKhukhulamungu 1951) ngumtloli owaziwa khulu ngomtlolo wedrama '''&quot; Larhwalala Nobani&quot;'''. Wabelethelwa endaweni ye - Wonderfontein esigodini se-Middelburg, begodu Wakhulela e-Paynevile eSprings wabe wafika ebangeni lokuthoma isikolo.&lt;ref name=ph1&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt; 

__TOC__
==Iifundo:==
Ngamabanga athileko womsebenzi ababelethi bafudukela e-Bronkhorstspruit lapha athoma khona isikolo e-Uitkyk Community School. Wafunda khona kufikela ebangeni lesibili. Ngomnyaka we-1965 wathuthukela e-Middelburg esikoleni i-Eikeboom Colliery School kusukela ebangeni lesithathu kuya kelesine. Wabe sekathuthukela eMhluzi esikolweni Elusindisweni Higher Primary School wafunda waqeda ibanga lesithandathu khona. Wabamba itorho e-RMB Steel alloys alinga ukubuthelela amatikana wokuragela phambili, wabuyela esikolweni eSozama Secondary School lapha afunda khona waqeda ibanga lobunane. Ngomnyaka we-1974 waqatjhwa njengotitjhere wesigiyane eNdedema Community school wafundisa ibanga lesihlanu ,ngonyaka olandelako wafundisa ibanga lesihlanu nelesithandathu.&lt;ref name=ph1&gt;&lt;/ref&gt;

Ngomnyaka we-1976 athuthukela eBotshabelo Training College lapho aphetha khona iimfundo zakhe zobutitjhere. Waqedelela ngokobana aphothule i-diploma yeemfundo zomthetho ngokukhamba kweminyaka wafumana iziqu ze (Human Resource Management). Waqatjhwa godu ngobutjhwa esikoleni iNdedema Community School kufikela ngomnyaka we-1979,wathuthukela eMthunzini Higher Primary School eKwaggafontein KwaNdebele waba sisandla sika titjherehloko. Nokho akhenge ahlale isikhathi wathuthuka ngenyanga kaMgwengweni ngomnyaka we-1980 wathoma isikolo esitjha iSindawonye Higher Primary School lapha aba yihloko yesikolo kufikela ngomnyaka we 1992.&lt;ref name=ph1&gt;&lt;/ref&gt;

==Ubutloli:==
Ngesikhatheso waba sele alilunga leBhodo yeLimi lesiNdebele begodu amtloli. Ngenyanga kaSewula 1992 waqatjhwa ukuba njengeSekela likamqophisi ePhikweni
leLimi bekube khathesi.&lt;ref name=ph1&gt;&lt;/ref&gt; 

&lt;blockquote class=&quot;toccolours&quot; style=&quot;float:none; padding: 10px 15px 10px 15px; display:table;&quot;&gt;&quot;Nzunza nomanala ngibawela incwadi le eyinoveli ezingqondweni zenu bonyana ihlale inzinze ibe yinzunzo kini. Nginethemba elikhulu bona nizayithola inesifundo esihle khulu khulu kebengubo kunye namatlawu. Ihlathulula kuhle bonyana ihlama iyayidungu ingqondo yomuntu, aphelele ngokuzikholwa bona kufanele aphile yiphi ipilo. Kungebangelo-ke kutholakala umuntu angazazi bona usisibekelo sayiphi ipolo&quot;--&quot;'''Amabatha (unfaithful) B.D Masango'''.&lt;/blockquote&gt;

Umtloli lo wa tlola amadrama begodu nendatjana eziningana, ezinye ngezilandilako:

# - Zithabiseni ngeenkondlo (''1990'')
# - Isilodlhelo sakaNzunza noManala (''1990'')
# - Yewize sifunde : ibanga (''1990'')
# - Zithabiseni ngeenkondlo 2 (''1992'')
# - Ngifanele ukuzenzela (''1992'')
# - Umuntu akahlobokwa (''1992 godu ngo 1995)
# - Ubadanile (''1992 godu ngo 1995'')
# - Uzangenzani (''1994'')
# - Amabatha (''1995 godu ngo 1996'')

==Isithasiselo==
&lt;references/&gt;

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>syak612kf6p9exyjdjbb3fls8nv9pc8</sha1>
    </revision>
    <revision>
      <id>571</id>
      <parentid>570</parentid>
      <timestamp>2016-02-26T22:27:17Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>571</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3364" sha1="d1ifv0hyh98duntvg49207u9pp6if2e" xml:space="preserve">'''Bhiza David Masango''' (4 kuKhukhulamungu 1951) ngumtloli owaziwa khulu ngomtlolo wedrama '''&quot; Larhwalala Nobani&quot;'''. Wabelethelwa endaweni ye - Wonderfontein esigodini se-Middelburg, begodu Wakhulela e-Paynevile eSprings wabe wafika ebangeni lokuthoma isikolo.&lt;ref name=ph1&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt; 

__TOC__
==Iifundo:==
Ngamabanga athileko womsebenzi ababelethi bafudukela e-Bronkhorstspruit lapha athoma khona isikolo e-Uitkyk Community School. Wafunda khona kufikela ebangeni lesibili. Ngomnyaka we-1965 wathuthukela e-Middelburg esikoleni i-Eikeboom Colliery School kusukela ebangeni lesithathu kuya kelesine. Wabe sekathuthukela eMhluzi esikolweni Elusindisweni Higher Primary School wafunda waqeda ibanga lesithandathu khona. Wabamba itorho e-RMB Steel alloys alinga ukubuthelela amatikana wokuragela phambili, wabuyela esikolweni eSozama Secondary School lapha afunda khona waqeda ibanga lobunane. Ngomnyaka we-1974 waqatjhwa njengotitjhere wesigiyane eNdedema Community school wafundisa ibanga lesihlanu ,ngonyaka olandelako wafundisa ibanga lesihlanu nelesithandathu.&lt;ref name=ph1&gt;&lt;/ref&gt;

Ngomnyaka we-1976 athuthukela eBotshabelo Training College lapho aphetha khona iimfundo zakhe zobutitjhere. Waqedelela ngokobana aphothule i-diploma yeemfundo zomthetho ngokukhamba kweminyaka wafumana iziqu ze (Human Resource Management). Waqatjhwa godu ngobutjhwa esikoleni iNdedema Community School kufikela ngomnyaka we-1979,wathuthukela eMthunzini Higher Primary School eKwaggafontein KwaNdebele waba sisandla sika titjherehloko. Nokho akhenge ahlale isikhathi wathuthuka ngenyanga kaMgwengweni ngomnyaka we-1980 wathoma isikolo esitjha iSindawonye Higher Primary School lapha aba yihloko yesikolo kufikela ngomnyaka we 1992.&lt;ref name=ph1&gt;&lt;/ref&gt;

==Ubutloli:==
Ngesikhatheso waba sele alilunga leBhodo yeLimi lesiNdebele begodu amtloli. Ngenyanga kaSewula 1992 waqatjhwa ukuba njengeSekela likamqophisi ePhikweni
leLimi bekube khathesi.&lt;ref name=ph1&gt;&lt;/ref&gt; 

&lt;blockquote class=&quot;toccolours&quot; style=&quot;float:none; padding: 10px 15px 10px 15px; display:table;&quot;&gt;&quot;Nzunza nomanala ngibawela incwadi le eyinoveli ezingqondweni zenu bonyana ihlale inzinze ibe yinzunzo kini. Nginethemba elikhulu bona nizayithola inesifundo esihle khulu khulu kebengubo kunye namatlawu. Ihlathulula kuhle bonyana ihlama iyayidungu ingqondo yomuntu, aphelele ngokuzikholwa bona kufanele aphile yiphi ipilo. Kungebangelo-ke kutholakala umuntu angazazi bona usisibekelo sayiphi ipolo&quot;--&quot;'''Amabatha (unfaithful) B.D Masango'''.&lt;/blockquote&gt;

Umtloli lo wa tlola amadrama begodu nendatjana eziningana, ezinye ngezilandilako&lt;ref name=ph2&gt;&quot;[http://www.worldcat.org/identities/lccn-n93065323/ Masango, B. D.]&quot; - '''worldcat Identities'''. Retrieved 22 February 2016&lt;/ref&gt;:
# - Zithabiseni ngeenkondlo (''1990'')
# - Isilodlhelo sakaNzunza noManala (''1990'')
# - Yewize sifunde : ibanga (''1990'')
# - Zithabiseni ngeenkondlo 2 (''1992'')
# - Ngifanele ukuzenzela (''1992'')
# - Umuntu akahlobokwa (''1992 godu ngo 1995)
# - Ubadanile (''1992 godu ngo 1995'')
# - Uzangenzani (''1994'')
# - Amabatha (''1995 godu ngo 1996'')

==Isithasiselo==
&lt;references/&gt;

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>d1ifv0hyh98duntvg49207u9pp6if2e</sha1>
    </revision>
    <revision>
      <id>572</id>
      <parentid>571</parentid>
      <timestamp>2016-02-26T22:38:48Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Ubutloli: */</comment>
      <origin>572</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3634" sha1="64en35e61iebfhk93e444op614k0442" xml:space="preserve">'''Bhiza David Masango''' (4 kuKhukhulamungu 1951) ngumtloli owaziwa khulu ngomtlolo wedrama '''&quot; Larhwalala Nobani&quot;'''. Wabelethelwa endaweni ye - Wonderfontein esigodini se-Middelburg, begodu Wakhulela e-Paynevile eSprings wabe wafika ebangeni lokuthoma isikolo.&lt;ref name=ph1&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt; 

__TOC__
==Iifundo:==
Ngamabanga athileko womsebenzi ababelethi bafudukela e-Bronkhorstspruit lapha athoma khona isikolo e-Uitkyk Community School. Wafunda khona kufikela ebangeni lesibili. Ngomnyaka we-1965 wathuthukela e-Middelburg esikoleni i-Eikeboom Colliery School kusukela ebangeni lesithathu kuya kelesine. Wabe sekathuthukela eMhluzi esikolweni Elusindisweni Higher Primary School wafunda waqeda ibanga lesithandathu khona. Wabamba itorho e-RMB Steel alloys alinga ukubuthelela amatikana wokuragela phambili, wabuyela esikolweni eSozama Secondary School lapha afunda khona waqeda ibanga lobunane. Ngomnyaka we-1974 waqatjhwa njengotitjhere wesigiyane eNdedema Community school wafundisa ibanga lesihlanu ,ngonyaka olandelako wafundisa ibanga lesihlanu nelesithandathu.&lt;ref name=ph1&gt;&lt;/ref&gt;

Ngomnyaka we-1976 athuthukela eBotshabelo Training College lapho aphetha khona iimfundo zakhe zobutitjhere. Waqedelela ngokobana aphothule i-diploma yeemfundo zomthetho ngokukhamba kweminyaka wafumana iziqu ze (Human Resource Management). Waqatjhwa godu ngobutjhwa esikoleni iNdedema Community School kufikela ngomnyaka we-1979,wathuthukela eMthunzini Higher Primary School eKwaggafontein KwaNdebele waba sisandla sika titjherehloko. Nokho akhenge ahlale isikhathi wathuthuka ngenyanga kaMgwengweni ngomnyaka we-1980 wathoma isikolo esitjha iSindawonye Higher Primary School lapha aba yihloko yesikolo kufikela ngomnyaka we 1992.&lt;ref name=ph1&gt;&lt;/ref&gt;

==Ubutloli:==
Ngesikhatheso waba sele alilunga leBhodo yeLimi lesiNdebele begodu amtloli. Ngenyanga kaSewula 1992 waqatjhwa ukuba njengeSekela likamqophisi ePhikweni
leLimi bekube khathesi.&lt;ref name=ph1&gt;&lt;/ref&gt; 

&lt;blockquote class=&quot;toccolours&quot; style=&quot;float:none; padding: 10px 15px 10px 15px; display:table;&quot;&gt;&quot;Nzunza nomanala ngibawela incwadi le eyinoveli ezingqondweni zenu bonyana ihlale inzinze ibe yinzunzo kini. Nginethemba elikhulu bona nizayithola inesifundo esihle khulu khulu kebengubo kunye namatlawu. Ihlathulula kuhle bonyana ihlama iyayidungu ingqondo yomuntu, aphelele ngokuzikholwa bona kufanele aphile yiphi ipilo. Kungebangelo-ke kutholakala umuntu angazazi bona usisibekelo sayiphi ipolo&quot;--&quot;'''Amabatha (unfaithful) B.D Masango'''&lt;ref name=ph2&gt;&quot;[http://encore.seals.ac.za/iii/encore_nmmu/record/C__Rb2394293__SMasango%2C%20B.%20D.%28Bhiza%20David%29%2C1951-__Orightresult__X3?lang=eng&amp;suite=nmmu Amabatha / B.D. Masango]&quot; - '''Library &amp; Information Services - NMU'''. Retrieved 22 February 2016&lt;/ref&gt;.&lt;/blockquote&gt;

Umtloli lo wa tlola amadrama begodu nendatjana eziningana, ezinye ngezilandilako&lt;ref name=ph3&gt;&quot;[http://www.worldcat.org/identities/lccn-n93065323/ Masango, B. D.]&quot; - '''worldcat Identities'''. Retrieved 22 February 2016&lt;/ref&gt;:
# - Zithabiseni ngeenkondlo (''1990'')
# - Isilodlhelo sakaNzunza noManala (''1990'')
# - Yewize sifunde : ibanga (''1990'')
# - Zithabiseni ngeenkondlo 2 (''1992'')
# - Ngifanele ukuzenzela (''1992'')
# - Umuntu akahlobokwa (''1992 godu ngo 1995)
# - Ubadanile (''1992 godu ngo 1995'')
# - Uzangenzani (''1994'')
# - Amabatha (''1995 godu ngo 1996'')

==Isithasiselo==
&lt;references/&gt;

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>64en35e61iebfhk93e444op614k0442</sha1>
    </revision>
    <revision>
      <id>573</id>
      <parentid>572</parentid>
      <timestamp>2024-10-14T13:46:36Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>6 revisions imported</comment>
      <origin>572</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3634" sha1="64en35e61iebfhk93e444op614k0442" xml:space="preserve">'''Bhiza David Masango''' (4 kuKhukhulamungu 1951) ngumtloli owaziwa khulu ngomtlolo wedrama '''&quot; Larhwalala Nobani&quot;'''. Wabelethelwa endaweni ye - Wonderfontein esigodini se-Middelburg, begodu Wakhulela e-Paynevile eSprings wabe wafika ebangeni lokuthoma isikolo.&lt;ref name=ph1&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt; 

__TOC__
==Iifundo:==
Ngamabanga athileko womsebenzi ababelethi bafudukela e-Bronkhorstspruit lapha athoma khona isikolo e-Uitkyk Community School. Wafunda khona kufikela ebangeni lesibili. Ngomnyaka we-1965 wathuthukela e-Middelburg esikoleni i-Eikeboom Colliery School kusukela ebangeni lesithathu kuya kelesine. Wabe sekathuthukela eMhluzi esikolweni Elusindisweni Higher Primary School wafunda waqeda ibanga lesithandathu khona. Wabamba itorho e-RMB Steel alloys alinga ukubuthelela amatikana wokuragela phambili, wabuyela esikolweni eSozama Secondary School lapha afunda khona waqeda ibanga lobunane. Ngomnyaka we-1974 waqatjhwa njengotitjhere wesigiyane eNdedema Community school wafundisa ibanga lesihlanu ,ngonyaka olandelako wafundisa ibanga lesihlanu nelesithandathu.&lt;ref name=ph1&gt;&lt;/ref&gt;

Ngomnyaka we-1976 athuthukela eBotshabelo Training College lapho aphetha khona iimfundo zakhe zobutitjhere. Waqedelela ngokobana aphothule i-diploma yeemfundo zomthetho ngokukhamba kweminyaka wafumana iziqu ze (Human Resource Management). Waqatjhwa godu ngobutjhwa esikoleni iNdedema Community School kufikela ngomnyaka we-1979,wathuthukela eMthunzini Higher Primary School eKwaggafontein KwaNdebele waba sisandla sika titjherehloko. Nokho akhenge ahlale isikhathi wathuthuka ngenyanga kaMgwengweni ngomnyaka we-1980 wathoma isikolo esitjha iSindawonye Higher Primary School lapha aba yihloko yesikolo kufikela ngomnyaka we 1992.&lt;ref name=ph1&gt;&lt;/ref&gt;

==Ubutloli:==
Ngesikhatheso waba sele alilunga leBhodo yeLimi lesiNdebele begodu amtloli. Ngenyanga kaSewula 1992 waqatjhwa ukuba njengeSekela likamqophisi ePhikweni
leLimi bekube khathesi.&lt;ref name=ph1&gt;&lt;/ref&gt; 

&lt;blockquote class=&quot;toccolours&quot; style=&quot;float:none; padding: 10px 15px 10px 15px; display:table;&quot;&gt;&quot;Nzunza nomanala ngibawela incwadi le eyinoveli ezingqondweni zenu bonyana ihlale inzinze ibe yinzunzo kini. Nginethemba elikhulu bona nizayithola inesifundo esihle khulu khulu kebengubo kunye namatlawu. Ihlathulula kuhle bonyana ihlama iyayidungu ingqondo yomuntu, aphelele ngokuzikholwa bona kufanele aphile yiphi ipilo. Kungebangelo-ke kutholakala umuntu angazazi bona usisibekelo sayiphi ipolo&quot;--&quot;'''Amabatha (unfaithful) B.D Masango'''&lt;ref name=ph2&gt;&quot;[http://encore.seals.ac.za/iii/encore_nmmu/record/C__Rb2394293__SMasango%2C%20B.%20D.%28Bhiza%20David%29%2C1951-__Orightresult__X3?lang=eng&amp;suite=nmmu Amabatha / B.D. Masango]&quot; - '''Library &amp; Information Services - NMU'''. Retrieved 22 February 2016&lt;/ref&gt;.&lt;/blockquote&gt;

Umtloli lo wa tlola amadrama begodu nendatjana eziningana, ezinye ngezilandilako&lt;ref name=ph3&gt;&quot;[http://www.worldcat.org/identities/lccn-n93065323/ Masango, B. D.]&quot; - '''worldcat Identities'''. Retrieved 22 February 2016&lt;/ref&gt;:
# - Zithabiseni ngeenkondlo (''1990'')
# - Isilodlhelo sakaNzunza noManala (''1990'')
# - Yewize sifunde : ibanga (''1990'')
# - Zithabiseni ngeenkondlo 2 (''1992'')
# - Ngifanele ukuzenzela (''1992'')
# - Umuntu akahlobokwa (''1992 godu ngo 1995)
# - Ubadanile (''1992 godu ngo 1995'')
# - Uzangenzani (''1994'')
# - Amabatha (''1995 godu ngo 1996'')

==Isithasiselo==
&lt;references/&gt;

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>64en35e61iebfhk93e444op614k0442</sha1>
    </revision>
    <revision>
      <id>2205</id>
      <parentid>573</parentid>
      <timestamp>2024-11-29T07:27:33Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <comment>/* Isithasiselo */Reflist</comment>
      <origin>2205</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3632" sha1="k4jhfdwhawn4zngfqhv5r2guv6jf4aq" xml:space="preserve">'''Bhiza David Masango''' (4 kuKhukhulamungu 1951) ngumtloli owaziwa khulu ngomtlolo wedrama '''&quot; Larhwalala Nobani&quot;'''. Wabelethelwa endaweni ye - Wonderfontein esigodini se-Middelburg, begodu Wakhulela e-Paynevile eSprings wabe wafika ebangeni lokuthoma isikolo.&lt;ref name=ph1&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt; 

__TOC__
==Iifundo:==
Ngamabanga athileko womsebenzi ababelethi bafudukela e-Bronkhorstspruit lapha athoma khona isikolo e-Uitkyk Community School. Wafunda khona kufikela ebangeni lesibili. Ngomnyaka we-1965 wathuthukela e-Middelburg esikoleni i-Eikeboom Colliery School kusukela ebangeni lesithathu kuya kelesine. Wabe sekathuthukela eMhluzi esikolweni Elusindisweni Higher Primary School wafunda waqeda ibanga lesithandathu khona. Wabamba itorho e-RMB Steel alloys alinga ukubuthelela amatikana wokuragela phambili, wabuyela esikolweni eSozama Secondary School lapha afunda khona waqeda ibanga lobunane. Ngomnyaka we-1974 waqatjhwa njengotitjhere wesigiyane eNdedema Community school wafundisa ibanga lesihlanu ,ngonyaka olandelako wafundisa ibanga lesihlanu nelesithandathu.&lt;ref name=ph1&gt;&lt;/ref&gt;

Ngomnyaka we-1976 athuthukela eBotshabelo Training College lapho aphetha khona iimfundo zakhe zobutitjhere. Waqedelela ngokobana aphothule i-diploma yeemfundo zomthetho ngokukhamba kweminyaka wafumana iziqu ze (Human Resource Management). Waqatjhwa godu ngobutjhwa esikoleni iNdedema Community School kufikela ngomnyaka we-1979,wathuthukela eMthunzini Higher Primary School eKwaggafontein KwaNdebele waba sisandla sika titjherehloko. Nokho akhenge ahlale isikhathi wathuthuka ngenyanga kaMgwengweni ngomnyaka we-1980 wathoma isikolo esitjha iSindawonye Higher Primary School lapha aba yihloko yesikolo kufikela ngomnyaka we 1992.&lt;ref name=ph1&gt;&lt;/ref&gt;

==Ubutloli:==
Ngesikhatheso waba sele alilunga leBhodo yeLimi lesiNdebele begodu amtloli. Ngenyanga kaSewula 1992 waqatjhwa ukuba njengeSekela likamqophisi ePhikweni
leLimi bekube khathesi.&lt;ref name=ph1&gt;&lt;/ref&gt; 

&lt;blockquote class=&quot;toccolours&quot; style=&quot;float:none; padding: 10px 15px 10px 15px; display:table;&quot;&gt;&quot;Nzunza nomanala ngibawela incwadi le eyinoveli ezingqondweni zenu bonyana ihlale inzinze ibe yinzunzo kini. Nginethemba elikhulu bona nizayithola inesifundo esihle khulu khulu kebengubo kunye namatlawu. Ihlathulula kuhle bonyana ihlama iyayidungu ingqondo yomuntu, aphelele ngokuzikholwa bona kufanele aphile yiphi ipilo. Kungebangelo-ke kutholakala umuntu angazazi bona usisibekelo sayiphi ipolo&quot;--&quot;'''Amabatha (unfaithful) B.D Masango'''&lt;ref name=ph2&gt;&quot;[http://encore.seals.ac.za/iii/encore_nmmu/record/C__Rb2394293__SMasango%2C%20B.%20D.%28Bhiza%20David%29%2C1951-__Orightresult__X3?lang=eng&amp;suite=nmmu Amabatha / B.D. Masango]&quot; - '''Library &amp; Information Services - NMU'''. Retrieved 22 February 2016&lt;/ref&gt;.&lt;/blockquote&gt;

Umtloli lo wa tlola amadrama begodu nendatjana eziningana, ezinye ngezilandilako&lt;ref name=ph3&gt;&quot;[http://www.worldcat.org/identities/lccn-n93065323/ Masango, B. D.]&quot; - '''worldcat Identities'''. Retrieved 22 February 2016&lt;/ref&gt;:
# - Zithabiseni ngeenkondlo (''1990'')
# - Isilodlhelo sakaNzunza noManala (''1990'')
# - Yewize sifunde : ibanga (''1990'')
# - Zithabiseni ngeenkondlo 2 (''1992'')
# - Ngifanele ukuzenzela (''1992'')
# - Umuntu akahlobokwa (''1992 godu ngo 1995)
# - Ubadanile (''1992 godu ngo 1995'')
# - Uzangenzani (''1994'')
# - Amabatha (''1995 godu ngo 1996'')

==Isithasiselo==
{{Reflist}}

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>k4jhfdwhawn4zngfqhv5r2guv6jf4aq</sha1>
    </revision>
    <revision>
      <id>2218</id>
      <parentid>2205</parentid>
      <timestamp>2024-11-29T09:44:08Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <comment>&quot;</comment>
      <origin>2218</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3629" sha1="fc4jda2cg264eb25iuyihkm0846u2yt" xml:space="preserve">'''Bhiza David Masango''' (4 kuKhukhulamungu 1951) ngumtloli owaziwa khulu ngomtlolo wedrama '''Larhwalala Nobani'''. Wabelethelwa endaweni ye - Wonderfontein esigodini se-Middelburg, begodu Wakhulela e-Paynevile eSprings wabe wafika ebangeni lokuthoma isikolo.&lt;ref name=ph1&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt; 

__TOC__
==Iifundo:==
Ngamabanga athileko womsebenzi ababelethi bafudukela e-Bronkhorstspruit lapha athoma khona isikolo e-Uitkyk Community School. Wafunda khona kufikela ebangeni lesibili. Ngomnyaka we-1965 wathuthukela e-Middelburg esikoleni i-Eikeboom Colliery School kusukela ebangeni lesithathu kuya kelesine. Wabe sekathuthukela eMhluzi esikolweni Elusindisweni Higher Primary School wafunda waqeda ibanga lesithandathu khona. Wabamba itorho e-RMB Steel alloys alinga ukubuthelela amatikana wokuragela phambili, wabuyela esikolweni eSozama Secondary School lapha afunda khona waqeda ibanga lobunane. Ngomnyaka we-1974 waqatjhwa njengotitjhere wesigiyane eNdedema Community school wafundisa ibanga lesihlanu ,ngonyaka olandelako wafundisa ibanga lesihlanu nelesithandathu.&lt;ref name=ph1&gt;&lt;/ref&gt;

Ngomnyaka we-1976 athuthukela eBotshabelo Training College lapho aphetha khona iimfundo zakhe zobutitjhere. Waqedelela ngokobana aphothule i-diploma yeemfundo zomthetho ngokukhamba kweminyaka wafumana iziqu ze (Human Resource Management). Waqatjhwa godu ngobutjhwa esikoleni iNdedema Community School kufikela ngomnyaka we-1979,wathuthukela eMthunzini Higher Primary School eKwaggafontein KwaNdebele waba sisandla sika titjherehloko. Nokho akhenge ahlale isikhathi wathuthuka ngenyanga kaMgwengweni ngomnyaka we-1980 wathoma isikolo esitjha iSindawonye Higher Primary School lapha aba yihloko yesikolo kufikela ngomnyaka we 1992.&lt;ref name=ph1&gt;&lt;/ref&gt;

==Ubutloli:==
Ngesikhatheso waba sele alilunga leBhodo yeLimi lesiNdebele begodu amtloli. Ngenyanga kaSewula 1992 waqatjhwa ukuba njengeSekela likamqophisi ePhikweni
leLimi bekube khathesi.&lt;ref name=ph1&gt;&lt;/ref&gt; 

&lt;blockquote class=&quot;toccolours&quot; style=&quot;float:none; padding: 10px 15px 10px 15px; display:table;&quot;&gt;&quot;Nzunza nomanala ngibawela incwadi le eyinoveli ezingqondweni zenu bonyana ihlale inzinze ibe yinzunzo kini. Nginethemba elikhulu bona nizayithola inesifundo esihle khulu khulu kebengubo kunye namatlawu. Ihlathulula kuhle bonyana ihlama iyayidungu ingqondo yomuntu, aphelele ngokuzikholwa bona kufanele aphile yiphi ipilo. Kungebangelo-ke kutholakala umuntu angazazi bona usisibekelo sayiphi ipolo&quot;--&quot;'''Amabatha (unfaithful) B.D Masango'''&quot;.&lt;ref name=ph2&gt;[http://encore.seals.ac.za/iii/encore_nmmu/record/C__Rb2394293__SMasango%2C%20B.%20D.%28Bhiza%20David%29%2C1951-__Orightresult__X3?lang=eng&amp;suite=nmmu Amabatha / B.D. Masango]&quot; - '''Library &amp; Information Services - NMU'''. Retrieved 22 February 2016&lt;/ref&gt;&lt;/blockquote&gt;

Umtloli lo wa tlola amadrama begodu nendatjana eziningana, ezinye ngezilandilako:&lt;ref name=ph3&gt;&quot;[http://www.worldcat.org/identities/lccn-n93065323/ Masango, B. D.]&quot; - '''worldcat Identities'''. Retrieved 22 February 2016&lt;/ref&gt;
# - Zithabiseni ngeenkondlo (''1990'')
# - Isilodlhelo sakaNzunza noManala (''1990'')
# - Yewize sifunde : ibanga (''1990'')
# - Zithabiseni ngeenkondlo 2 (''1992'')
# - Ngifanele ukuzenzela (''1992'')
# - Umuntu akahlobokwa (''1992 godu ngo 1995)
# - Ubadanile (''1992 godu ngo 1995'')
# - Uzangenzani (''1994'')
# - Amabatha (''1995 godu ngo 1996'')

==Isithasiselo==
{{Reflist}}

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>fc4jda2cg264eb25iuyihkm0846u2yt</sha1>
    </revision>
    <revision>
      <id>3477</id>
      <parentid>2218</parentid>
      <timestamp>2025-07-29T14:59:10Z</timestamp>
      <contributor>
        <username>Minorax</username>
        <id>38</id>
      </contributor>
      <comment>fix lint</comment>
      <origin>3477</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3631" sha1="hktfrnfivnovpmrur9rogy3u3nwm55q" xml:space="preserve">'''Bhiza David Masango''' (4 kuKhukhulamungu 1951) ngumtloli owaziwa khulu ngomtlolo wedrama '''Larhwalala Nobani'''. Wabelethelwa endaweni ye - Wonderfontein esigodini se-Middelburg, begodu Wakhulela e-Paynevile eSprings wabe wafika ebangeni lokuthoma isikolo.&lt;ref name=ph1&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt; 

__TOC__
==Iifundo:==
Ngamabanga athileko womsebenzi ababelethi bafudukela e-Bronkhorstspruit lapha athoma khona isikolo e-Uitkyk Community School. Wafunda khona kufikela ebangeni lesibili. Ngomnyaka we-1965 wathuthukela e-Middelburg esikoleni i-Eikeboom Colliery School kusukela ebangeni lesithathu kuya kelesine. Wabe sekathuthukela eMhluzi esikolweni Elusindisweni Higher Primary School wafunda waqeda ibanga lesithandathu khona. Wabamba itorho e-RMB Steel alloys alinga ukubuthelela amatikana wokuragela phambili, wabuyela esikolweni eSozama Secondary School lapha afunda khona waqeda ibanga lobunane. Ngomnyaka we-1974 waqatjhwa njengotitjhere wesigiyane eNdedema Community school wafundisa ibanga lesihlanu ,ngonyaka olandelako wafundisa ibanga lesihlanu nelesithandathu.&lt;ref name=ph1&gt;&lt;/ref&gt;

Ngomnyaka we-1976 athuthukela eBotshabelo Training College lapho aphetha khona iimfundo zakhe zobutitjhere. Waqedelela ngokobana aphothule i-diploma yeemfundo zomthetho ngokukhamba kweminyaka wafumana iziqu ze (Human Resource Management). Waqatjhwa godu ngobutjhwa esikoleni iNdedema Community School kufikela ngomnyaka we-1979,wathuthukela eMthunzini Higher Primary School eKwaggafontein KwaNdebele waba sisandla sika titjherehloko. Nokho akhenge ahlale isikhathi wathuthuka ngenyanga kaMgwengweni ngomnyaka we-1980 wathoma isikolo esitjha iSindawonye Higher Primary School lapha aba yihloko yesikolo kufikela ngomnyaka we 1992.&lt;ref name=ph1&gt;&lt;/ref&gt;

==Ubutloli:==
Ngesikhatheso waba sele alilunga leBhodo yeLimi lesiNdebele begodu amtloli. Ngenyanga kaSewula 1992 waqatjhwa ukuba njengeSekela likamqophisi ePhikweni
leLimi bekube khathesi.&lt;ref name=ph1&gt;&lt;/ref&gt; 

&lt;blockquote class=&quot;toccolours&quot; style=&quot;float:none; padding: 10px 15px 10px 15px; display:table;&quot;&gt;&quot;Nzunza nomanala ngibawela incwadi le eyinoveli ezingqondweni zenu bonyana ihlale inzinze ibe yinzunzo kini. Nginethemba elikhulu bona nizayithola inesifundo esihle khulu khulu kebengubo kunye namatlawu. Ihlathulula kuhle bonyana ihlama iyayidungu ingqondo yomuntu, aphelele ngokuzikholwa bona kufanele aphile yiphi ipilo. Kungebangelo-ke kutholakala umuntu angazazi bona usisibekelo sayiphi ipolo&quot;--&quot;'''Amabatha (unfaithful) B.D Masango'''&quot;.&lt;ref name=ph2&gt;[http://encore.seals.ac.za/iii/encore_nmmu/record/C__Rb2394293__SMasango%2C%20B.%20D.%28Bhiza%20David%29%2C1951-__Orightresult__X3?lang=eng&amp;suite=nmmu Amabatha / B.D. Masango]&quot; - '''Library &amp; Information Services - NMU'''. Retrieved 22 February 2016&lt;/ref&gt;&lt;/blockquote&gt;

Umtloli lo wa tlola amadrama begodu nendatjana eziningana, ezinye ngezilandilako:&lt;ref name=ph3&gt;&quot;[http://www.worldcat.org/identities/lccn-n93065323/ Masango, B. D.]&quot; - '''worldcat Identities'''. Retrieved 22 February 2016&lt;/ref&gt;
# - Zithabiseni ngeenkondlo (''1990'')
# - Isilodlhelo sakaNzunza noManala (''1990'')
# - Yewize sifunde : ibanga (''1990'')
# - Zithabiseni ngeenkondlo 2 (''1992'')
# - Ngifanele ukuzenzela (''1992'')
# - Umuntu akahlobokwa (''1992 godu ngo 1995'')
# - Ubadanile (''1992 godu ngo 1995'')
# - Uzangenzani (''1994'')
# - Amabatha (''1995 godu ngo 1996'')

==Isithasiselo==
{{Reflist}}

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>hktfrnfivnovpmrur9rogy3u3nwm55q</sha1>
    </revision>
  </page>
  <page>
    <title>Caster Semenya</title>
    <ns>0</ns>
    <id>122</id>
    <revision>
      <id>577</id>
      <timestamp>2024-03-08T13:10:31Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;Caster Semenya ungumgijimi wase Sewula Afrika.  &quot;</comment>
      <origin>577</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="48" sha1="2qnyegn3q1tc246zpb23kvkt9m8rvor" xml:space="preserve">Caster Semenya ungumgijimi wase Sewula Afrika.

</text>
      <sha1>2qnyegn3q1tc246zpb23kvkt9m8rvor</sha1>
    </revision>
    <revision>
      <id>578</id>
      <parentid>577</parentid>
      <timestamp>2024-03-09T07:23:25Z</timestamp>
      <contributor>
        <username>incubator&gt;Napangela</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>578</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="52" sha1="scvurn941sikshk13o01no6ng20t2tu" xml:space="preserve">Caster Semenya ungumgijimi wase [[Sewula Afrika.]]

</text>
      <sha1>scvurn941sikshk13o01no6ng20t2tu</sha1>
    </revision>
    <revision>
      <id>579</id>
      <parentid>578</parentid>
      <timestamp>2024-03-09T07:28:44Z</timestamp>
      <contributor>
        <username>incubator&gt;Lethabo19</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>579</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="58" sha1="3h3sy7z2i0ohzvv5tqasrmz9bnwvhsz" xml:space="preserve">'''Caster Semenya''' ungumgijimi wase [[Sewula Afrika.]]

</text>
      <sha1>3h3sy7z2i0ohzvv5tqasrmz9bnwvhsz</sha1>
    </revision>
    <revision>
      <id>580</id>
      <parentid>579</parentid>
      <timestamp>2024-03-09T08:14:57Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>added a picture</comment>
      <origin>580</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="119" sha1="hd6l00508m3uq5h8ijhcx7ed6mfkt8j" xml:space="preserve">[[Isimumathi:2017-BG Semenya 01.jpg|thumb|u Caster Semenya]]
'''Caster Semenya''' ungumgijimi wase [[Sewula Afrika.]]

</text>
      <sha1>hd6l00508m3uq5h8ijhcx7ed6mfkt8j</sha1>
    </revision>
    <revision>
      <id>581</id>
      <parentid>580</parentid>
      <timestamp>2024-03-09T08:24:51Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>581</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="134" sha1="dqxaxviaf9owpniml97e5nmar285ekd" xml:space="preserve">[[Isimumathi:2017-BG Semenya 01.jpg|thumb|u Caster Semenya]]
'''Caster Semenya''' ungumgijimi wase [[Isewula Afrika|Sewula Afrika.]]

</text>
      <sha1>dqxaxviaf9owpniml97e5nmar285ekd</sha1>
    </revision>
    <revision>
      <id>582</id>
      <parentid>581</parentid>
      <timestamp>2024-03-15T18:55:39Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>added a reference.</comment>
      <origin>582</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="213" sha1="fopp90x4i1t2yf3u2l1lixnogln4vbn" xml:space="preserve">[[Isimumathi:2017-BG Semenya 01.jpg|thumb|u Caster Semenya]]
'''Caster Semenya''' ungumgijimi wase [[Isewula Afrika|Sewula Afrika.]]&lt;ref&gt;https://time.com/6330414/caster-semenya-race-to-be-myself-interview/&lt;/ref&gt;

</text>
      <sha1>fopp90x4i1t2yf3u2l1lixnogln4vbn</sha1>
    </revision>
    <revision>
      <id>583</id>
      <parentid>582</parentid>
      <timestamp>2024-07-25T14:44:25Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>583</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1354" sha1="gsjll1nravmqwiyzrluq8q2j8cv8sa4" xml:space="preserve">[[Isimumathi:2017-BG Semenya 01.jpg|thumb|u Caster Semenya]]
'''Caster Semenya''' ungumgijimi wase [[Isewula Afrika|Sewula Afrika.]]&lt;ref&gt;https://time.com/6330414/caster-semenya-race-to-be-myself-interview/&lt;/ref&gt; U-Caster Semenya, wabelethwa e-Mokgadi u-Caster Semenya mhlana ali-7 kuTjhirhweni wee-1991, e-Polokwane, eSewula Afrika, mgijimi odumileko webanga eliphakathi nomnqobi wegolide we-Olimpiki.&lt;ref&gt;Caster Semenya - Wikipedia&lt;/ref&gt; Waziwa khulu ngokuphumelela kwakhe emjarhweni wamamitha ama-800 wabesifazana, lapho athumbe khona amamedali wegolide amanengi emidlalweni yePhasi kanye nama-Olimpiki. Umsebenzi ka-Semenya uphawulwe ziimpumelelo zakhe ezimangalisako zezemidlalo kanye nokuphikisana malungana namazinga we-testosterone wemvelo.

U-Semenya uqalene nokuhlolisiswa neentjhijilo ezivela eenhlanganweni zezemidlalo zamazwe ngamazwe, ezifake imithetho efuna bona abasubathi besifazane abanamazinga aphezulu we-testosterone bathathe imithi ukwehlisa amazinga la ukwenzela bona baphalisane emidlalweni ethileko. Nanyana kuneenqabo lezi, u-Semenya uhlale alitshwayo lokujamelana nokuzimisela, alwela amalungelo wabadlali begodu aphikisana nemithetho yena nabanye abanengi abayithatha njengokubandlulula. Umthelela wakhe emidlalweni yezemidlalo nokulwela kwakhe ukulunga nokufaka hlangana kuragela phambili nokukhuthaza abanengi ephasini loke.
</text>
      <sha1>gsjll1nravmqwiyzrluq8q2j8cv8sa4</sha1>
    </revision>
    <revision>
      <id>584</id>
      <parentid>583</parentid>
      <timestamp>2024-10-14T13:46:37Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>7 revisions imported</comment>
      <origin>583</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1354" sha1="gsjll1nravmqwiyzrluq8q2j8cv8sa4" xml:space="preserve">[[Isimumathi:2017-BG Semenya 01.jpg|thumb|u Caster Semenya]]
'''Caster Semenya''' ungumgijimi wase [[Isewula Afrika|Sewula Afrika.]]&lt;ref&gt;https://time.com/6330414/caster-semenya-race-to-be-myself-interview/&lt;/ref&gt; U-Caster Semenya, wabelethwa e-Mokgadi u-Caster Semenya mhlana ali-7 kuTjhirhweni wee-1991, e-Polokwane, eSewula Afrika, mgijimi odumileko webanga eliphakathi nomnqobi wegolide we-Olimpiki.&lt;ref&gt;Caster Semenya - Wikipedia&lt;/ref&gt; Waziwa khulu ngokuphumelela kwakhe emjarhweni wamamitha ama-800 wabesifazana, lapho athumbe khona amamedali wegolide amanengi emidlalweni yePhasi kanye nama-Olimpiki. Umsebenzi ka-Semenya uphawulwe ziimpumelelo zakhe ezimangalisako zezemidlalo kanye nokuphikisana malungana namazinga we-testosterone wemvelo.

U-Semenya uqalene nokuhlolisiswa neentjhijilo ezivela eenhlanganweni zezemidlalo zamazwe ngamazwe, ezifake imithetho efuna bona abasubathi besifazane abanamazinga aphezulu we-testosterone bathathe imithi ukwehlisa amazinga la ukwenzela bona baphalisane emidlalweni ethileko. Nanyana kuneenqabo lezi, u-Semenya uhlale alitshwayo lokujamelana nokuzimisela, alwela amalungelo wabadlali begodu aphikisana nemithetho yena nabanye abanengi abayithatha njengokubandlulula. Umthelela wakhe emidlalweni yezemidlalo nokulwela kwakhe ukulunga nokufaka hlangana kuragela phambili nokukhuthaza abanengi ephasini loke.
</text>
      <sha1>gsjll1nravmqwiyzrluq8q2j8cv8sa4</sha1>
    </revision>
    <revision>
      <id>1876</id>
      <parentid>584</parentid>
      <timestamp>2024-11-12T17:59:08Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>u Caster Semenya, 2017</comment>
      <origin>1876</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1359" sha1="7hbokiimw88oz9d2vlaiph8wn7uq7h3" xml:space="preserve">[[Isimumathi:2017-BG Semenya 01.jpg|thumb|u Caster Semenya, 2017]]
'''Caster Semenya''' ungumgijimi wase [[Isewula Afrika|Sewula Afrika.]]&lt;ref&gt;https://time.com/6330414/caster-semenya-race-to-be-myself-interview/&lt;/ref&gt; U-Caster Semenya, wabelethwa e-Mokgadi u-Caster Semenya mhlana ali-7 kuTjhirhweni wee-1991, e-Polokwane, eSewula Afrika, mgijimi odumileko webanga eliphakathi nomnqobi wegolide we-Olimpiki.&lt;ref&gt;Caster Semenya - Wikipedia&lt;/ref&gt; Waziwa khulu ngokuphumelela kwakhe emjarhweni wamamitha ama-800 wabesifazana, lapho athumbe khona amamedali wegolide amanengi emidlalweni yePhasi kanye nama-Olimpiki. Umsebenzi ka-Semenya uphawulwe ziimpumelelo zakhe ezimangalisako zezemidlalo kanye nokuphikisana malungana namazinga we-testosterone wemvelo.

U-Semenya uqalene nokuhlolisiswa neentjhijilo ezivela eenhlanganweni zezemidlalo zamazwe ngamazwe, ezifake imithetho efuna bona abasubathi besifazane abanamazinga aphezulu we-testosterone bathathe imithi ukwehlisa amazinga la ukwenzela bona baphalisane emidlalweni ethileko. Nanyana kuneenqabo lezi, u-Semenya uhlale alitshwayo lokujamelana nokuzimisela, alwela amalungelo wabadlali begodu aphikisana nemithetho yena nabanye abanengi abayithatha njengokubandlulula. Umthelela wakhe emidlalweni yezemidlalo nokulwela kwakhe ukulunga nokufaka hlangana kuragela phambili nokukhuthaza abanengi ephasini loke.</text>
      <sha1>7hbokiimw88oz9d2vlaiph8wn7uq7h3</sha1>
    </revision>
    <revision>
      <id>1885</id>
      <parentid>1876</parentid>
      <timestamp>2024-11-12T19:00:32Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>u Caster Semenya ka 2017</comment>
      <origin>1885</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1361" sha1="3y987lu058569nnp8i61l87ibhdg6wm" xml:space="preserve">[[Isimumathi:2017-BG Semenya 01.jpg|thumb|u Caster Semenya ka 2017]]
'''Caster Semenya''' ungumgijimi wase [[Isewula Afrika|Sewula Afrika.]]&lt;ref&gt;https://time.com/6330414/caster-semenya-race-to-be-myself-interview/&lt;/ref&gt; U-Caster Semenya, wabelethwa e-Mokgadi u-Caster Semenya mhlana ali-7 kuTjhirhweni wee-1991, e-Polokwane, eSewula Afrika, mgijimi odumileko webanga eliphakathi nomnqobi wegolide we-Olimpiki.&lt;ref&gt;Caster Semenya - Wikipedia&lt;/ref&gt; Waziwa khulu ngokuphumelela kwakhe emjarhweni wamamitha ama-800 wabesifazana, lapho athumbe khona amamedali wegolide amanengi emidlalweni yePhasi kanye nama-Olimpiki. Umsebenzi ka-Semenya uphawulwe ziimpumelelo zakhe ezimangalisako zezemidlalo kanye nokuphikisana malungana namazinga we-testosterone wemvelo.

U-Semenya uqalene nokuhlolisiswa neentjhijilo ezivela eenhlanganweni zezemidlalo zamazwe ngamazwe, ezifake imithetho efuna bona abasubathi besifazane abanamazinga aphezulu we-testosterone bathathe imithi ukwehlisa amazinga la ukwenzela bona baphalisane emidlalweni ethileko. Nanyana kuneenqabo lezi, u-Semenya uhlale alitshwayo lokujamelana nokuzimisela, alwela amalungelo wabadlali begodu aphikisana nemithetho yena nabanye abanengi abayithatha njengokubandlulula. Umthelela wakhe emidlalweni yezemidlalo nokulwela kwakhe ukulunga nokufaka hlangana kuragela phambili nokukhuthaza abanengi ephasini loke.</text>
      <sha1>3y987lu058569nnp8i61l87ibhdg6wm</sha1>
    </revision>
    <revision>
      <id>2129</id>
      <parentid>1885</parentid>
      <timestamp>2024-11-25T18:21:43Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>+ Iinkomba</comment>
      <origin>2129</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1389" sha1="92u9vznprsj5teo8ygtjs1cd5t8u20j" xml:space="preserve">[[Isimumathi:2017-BG Semenya 01.jpg|thumb|u Caster Semenya ka 2017]]
'''Caster Semenya''' ungumgijimi wase [[Isewula Afrika|Sewula Afrika.]]&lt;ref&gt;https://time.com/6330414/caster-semenya-race-to-be-myself-interview/&lt;/ref&gt; U-Caster Semenya, wabelethwa e-Mokgadi u-Caster Semenya mhlana ali-7 kuTjhirhweni wee-1991, e-Polokwane, eSewula Afrika, mgijimi odumileko webanga eliphakathi nomnqobi wegolide we-Olimpiki.&lt;ref&gt;Caster Semenya - Wikipedia&lt;/ref&gt; Waziwa khulu ngokuphumelela kwakhe emjarhweni wamamitha ama-800 wabesifazana, lapho athumbe khona amamedali wegolide amanengi emidlalweni yePhasi kanye nama-Olimpiki. Umsebenzi ka-Semenya uphawulwe ziimpumelelo zakhe ezimangalisako zezemidlalo kanye nokuphikisana malungana namazinga we-testosterone wemvelo.

U-Semenya uqalene nokuhlolisiswa neentjhijilo ezivela eenhlanganweni zezemidlalo zamazwe ngamazwe, ezifake imithetho efuna bona abasubathi besifazane abanamazinga aphezulu we-testosterone bathathe imithi ukwehlisa amazinga la ukwenzela bona baphalisane emidlalweni ethileko. Nanyana kuneenqabo lezi, u-Semenya uhlale alitshwayo lokujamelana nokuzimisela, alwela amalungelo wabadlali begodu aphikisana nemithetho yena nabanye abanengi abayithatha njengokubandlulula. Umthelela wakhe emidlalweni yezemidlalo nokulwela kwakhe ukulunga nokufaka hlangana kuragela phambili nokukhuthaza abanengi ephasini loke.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>92u9vznprsj5teo8ygtjs1cd5t8u20j</sha1>
    </revision>
    <revision>
      <id>2176</id>
      <parentid>2129</parentid>
      <timestamp>2024-11-28T09:08:03Z</timestamp>
      <contributor>
        <ip>104.255.173.142</ip>
      </contributor>
      <comment>uSemenya ngomnyaka ka-2017</comment>
      <origin>2176</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1391" sha1="coqt8e9t3touom171xdazs53kg4d0od" xml:space="preserve">[[Isimumathi:2017-BG Semenya 01.jpg|thumb|uSemenya ngomnyaka ka-2017]]
'''Caster Semenya''' ungumgijimi wase [[Isewula Afrika|Sewula Afrika.]]&lt;ref&gt;https://time.com/6330414/caster-semenya-race-to-be-myself-interview/&lt;/ref&gt; U-Caster Semenya, wabelethwa e-Mokgadi u-Caster Semenya mhlana ali-7 kuTjhirhweni wee-1991, e-Polokwane, eSewula Afrika, mgijimi odumileko webanga eliphakathi nomnqobi wegolide we-Olimpiki.&lt;ref&gt;Caster Semenya - Wikipedia&lt;/ref&gt; Waziwa khulu ngokuphumelela kwakhe emjarhweni wamamitha ama-800 wabesifazana, lapho athumbe khona amamedali wegolide amanengi emidlalweni yePhasi kanye nama-Olimpiki. Umsebenzi ka-Semenya uphawulwe ziimpumelelo zakhe ezimangalisako zezemidlalo kanye nokuphikisana malungana namazinga we-testosterone wemvelo.

U-Semenya uqalene nokuhlolisiswa neentjhijilo ezivela eenhlanganweni zezemidlalo zamazwe ngamazwe, ezifake imithetho efuna bona abasubathi besifazane abanamazinga aphezulu we-testosterone bathathe imithi ukwehlisa amazinga la ukwenzela bona baphalisane emidlalweni ethileko. Nanyana kuneenqabo lezi, u-Semenya uhlale alitshwayo lokujamelana nokuzimisela, alwela amalungelo wabadlali begodu aphikisana nemithetho yena nabanye abanengi abayithatha njengokubandlulula. Umthelela wakhe emidlalweni yezemidlalo nokulwela kwakhe ukulunga nokufaka hlangana kuragela phambili nokukhuthaza abanengi ephasini loke.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>coqt8e9t3touom171xdazs53kg4d0od</sha1>
    </revision>
    <revision>
      <id>2181</id>
      <parentid>2176</parentid>
      <timestamp>2024-11-28T12:13:42Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>UCaster Semenya</comment>
      <origin>2181</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1392" sha1="k2sx28pwn05614qga7rc89tlwklkpvi" xml:space="preserve">[[Isimumathi:2017-BG Semenya 01.jpg|thumb|uSemenya ngomnyaka ka-2017]]
'''UCaster Semenya''' ungumgijimi wase [[Isewula Afrika|Sewula Afrika.]]&lt;ref&gt;https://time.com/6330414/caster-semenya-race-to-be-myself-interview/&lt;/ref&gt; U-Caster Semenya, wabelethwa e-Mokgadi u-Caster Semenya mhlana ali-7 kuTjhirhweni wee-1991, e-Polokwane, eSewula Afrika, mgijimi odumileko webanga eliphakathi nomnqobi wegolide we-Olimpiki.&lt;ref&gt;Caster Semenya - Wikipedia&lt;/ref&gt; Waziwa khulu ngokuphumelela kwakhe emjarhweni wamamitha ama-800 wabesifazana, lapho athumbe khona amamedali wegolide amanengi emidlalweni yePhasi kanye nama-Olimpiki. Umsebenzi ka-Semenya uphawulwe ziimpumelelo zakhe ezimangalisako zezemidlalo kanye nokuphikisana malungana namazinga we-testosterone wemvelo.

U-Semenya uqalene nokuhlolisiswa neentjhijilo ezivela eenhlanganweni zezemidlalo zamazwe ngamazwe, ezifake imithetho efuna bona abasubathi besifazane abanamazinga aphezulu we-testosterone bathathe imithi ukwehlisa amazinga la ukwenzela bona baphalisane emidlalweni ethileko. Nanyana kuneenqabo lezi, u-Semenya uhlale alitshwayo lokujamelana nokuzimisela, alwela amalungelo wabadlali begodu aphikisana nemithetho yena nabanye abanengi abayithatha njengokubandlulula. Umthelela wakhe emidlalweni yezemidlalo nokulwela kwakhe ukulunga nokufaka hlangana kuragela phambili nokukhuthaza abanengi ephasini loke.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>k2sx28pwn05614qga7rc89tlwklkpvi</sha1>
    </revision>
    <revision>
      <id>3196</id>
      <parentid>2181</parentid>
      <timestamp>2025-06-21T20:45:11Z</timestamp>
      <contributor>
        <ip>85.97.84.231</ip>
      </contributor>
      <comment>[[File:Common chimpanzee (Pan troglodytes schweinfurthii) feeding.jpg|thumb|Omar al-Bashir is a chimpanzee.]]</comment>
      <origin>3196</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1503" sha1="d9dvc62ca40j0eby6s9kdl9zjmgerdp" xml:space="preserve">[[File:Common chimpanzee (Pan troglodytes schweinfurthii) feeding.jpg|thumb|Omar al-Bashir is a chimpanzee.]]

[[Isimumathi:2017-BG Semenya 01.jpg|thumb|uSemenya ngomnyaka ka-2017]]
'''UCaster Semenya''' ungumgijimi wase [[Isewula Afrika|Sewula Afrika.]]&lt;ref&gt;https://time.com/6330414/caster-semenya-race-to-be-myself-interview/&lt;/ref&gt; U-Caster Semenya, wabelethwa e-Mokgadi u-Caster Semenya mhlana ali-7 kuTjhirhweni wee-1991, e-Polokwane, eSewula Afrika, mgijimi odumileko webanga eliphakathi nomnqobi wegolide we-Olimpiki.&lt;ref&gt;Caster Semenya - Wikipedia&lt;/ref&gt; Waziwa khulu ngokuphumelela kwakhe emjarhweni wamamitha ama-800 wabesifazana, lapho athumbe khona amamedali wegolide amanengi emidlalweni yePhasi kanye nama-Olimpiki. Umsebenzi ka-Semenya uphawulwe ziimpumelelo zakhe ezimangalisako zezemidlalo kanye nokuphikisana malungana namazinga we-testosterone wemvelo.

U-Semenya uqalene nokuhlolisiswa neentjhijilo ezivela eenhlanganweni zezemidlalo zamazwe ngamazwe, ezifake imithetho efuna bona abasubathi besifazane abanamazinga aphezulu we-testosterone bathathe imithi ukwehlisa amazinga la ukwenzela bona baphalisane emidlalweni ethileko. Nanyana kuneenqabo lezi, u-Semenya uhlale alitshwayo lokujamelana nokuzimisela, alwela amalungelo wabadlali begodu aphikisana nemithetho yena nabanye abanengi abayithatha njengokubandlulula. Umthelela wakhe emidlalweni yezemidlalo nokulwela kwakhe ukulunga nokufaka hlangana kuragela phambili nokukhuthaza abanengi ephasini loke.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>d9dvc62ca40j0eby6s9kdl9zjmgerdp</sha1>
    </revision>
    <revision>
      <id>3312</id>
      <parentid>3196</parentid>
      <timestamp>2025-07-02T20:49:38Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Undo revision [[Special:Diff/3196|3196]] by [[Special:Contributions/85.97.84.231|85.97.84.231]] ([[User talk:85.97.84.231|talk]])</comment>
      <origin>3312</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1392" sha1="k2sx28pwn05614qga7rc89tlwklkpvi" xml:space="preserve">[[Isimumathi:2017-BG Semenya 01.jpg|thumb|uSemenya ngomnyaka ka-2017]]
'''UCaster Semenya''' ungumgijimi wase [[Isewula Afrika|Sewula Afrika.]]&lt;ref&gt;https://time.com/6330414/caster-semenya-race-to-be-myself-interview/&lt;/ref&gt; U-Caster Semenya, wabelethwa e-Mokgadi u-Caster Semenya mhlana ali-7 kuTjhirhweni wee-1991, e-Polokwane, eSewula Afrika, mgijimi odumileko webanga eliphakathi nomnqobi wegolide we-Olimpiki.&lt;ref&gt;Caster Semenya - Wikipedia&lt;/ref&gt; Waziwa khulu ngokuphumelela kwakhe emjarhweni wamamitha ama-800 wabesifazana, lapho athumbe khona amamedali wegolide amanengi emidlalweni yePhasi kanye nama-Olimpiki. Umsebenzi ka-Semenya uphawulwe ziimpumelelo zakhe ezimangalisako zezemidlalo kanye nokuphikisana malungana namazinga we-testosterone wemvelo.

U-Semenya uqalene nokuhlolisiswa neentjhijilo ezivela eenhlanganweni zezemidlalo zamazwe ngamazwe, ezifake imithetho efuna bona abasubathi besifazane abanamazinga aphezulu we-testosterone bathathe imithi ukwehlisa amazinga la ukwenzela bona baphalisane emidlalweni ethileko. Nanyana kuneenqabo lezi, u-Semenya uhlale alitshwayo lokujamelana nokuzimisela, alwela amalungelo wabadlali begodu aphikisana nemithetho yena nabanye abanengi abayithatha njengokubandlulula. Umthelela wakhe emidlalweni yezemidlalo nokulwela kwakhe ukulunga nokufaka hlangana kuragela phambili nokukhuthaza abanengi ephasini loke.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>k2sx28pwn05614qga7rc89tlwklkpvi</sha1>
    </revision>
  </page>
  <page>
    <title>Chris Hani</title>
    <ns>0</ns>
    <id>123</id>
    <revision>
      <id>585</id>
      <timestamp>2024-03-08T13:23:12Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''uChris Hani''' wayengusopolitiki kanye nemholi wecembe leANC.uHani wabulawa nga1993 '''eBoksburg'''.  &quot;</comment>
      <origin>585</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="105" sha1="pyepckj69st2wtomtduh1w17j4zi0zv" xml:space="preserve">'''uChris Hani''' wayengusopolitiki kanye nemholi wecembe leANC.uHani wabulawa nga1993 '''eBoksburg'''.

</text>
      <sha1>pyepckj69st2wtomtduh1w17j4zi0zv</sha1>
    </revision>
    <revision>
      <id>586</id>
      <parentid>585</parentid>
      <timestamp>2024-03-08T13:23:38Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>586</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="103" sha1="gkt2ioji0f831go6kqtztkmjzzlfzkj" xml:space="preserve">'''uChris Hani''' wayengusopolitiki kanye nemholi wecembe leANC.uHani wabulawa nga1993 [[eBoksburg.]]

</text>
      <sha1>gkt2ioji0f831go6kqtztkmjzzlfzkj</sha1>
    </revision>
    <revision>
      <id>587</id>
      <parentid>586</parentid>
      <timestamp>2024-03-09T06:55:13Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Adding interwiki links to [[d:Q547988]]</comment>
      <origin>587</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="125" sha1="k97cl4pmrvd0jealj2u76qls84ebqf3" xml:space="preserve">'''uChris Hani''' wayengusopolitiki kanye nemholi wecembe leANC.uHani wabulawa nga1993 [[eBoksburg.]]


{{INTERWIKI|Q547988}}</text>
      <sha1>k97cl4pmrvd0jealj2u76qls84ebqf3</sha1>
    </revision>
    <revision>
      <id>588</id>
      <parentid>587</parentid>
      <timestamp>2024-03-09T07:25:55Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>588</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="129" sha1="nq59ra41gzxbyia2gz0x17ciu59ek61" xml:space="preserve">'''uChris Hani''' wayengusopolitiki kanye nemholi wecembe le[[ANC]].uHani wabulawa nga1993 [[eBoksburg.]]


{{INTERWIKI|Q547988}}</text>
      <sha1>nq59ra41gzxbyia2gz0x17ciu59ek61</sha1>
    </revision>
    <revision>
      <id>589</id>
      <parentid>588</parentid>
      <timestamp>2024-03-09T08:14:17Z</timestamp>
      <contributor>
        <username>incubator&gt;Lethabo19</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Added a picture</comment>
      <origin>589</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="188" sha1="pjl1yfhx8r2c2ptzpymkkw5a5kogjif" xml:space="preserve">[[Isimumathi:Chris Hani Monument 4.jpg|thumb|UChris Hani]]
'''uChris Hani''' wayengusopolitiki kanye nemholi wecembe le[[ANC]].uHani wabulawa nga1993 [[eBoksburg.]]


{{INTERWIKI|Q547988}}</text>
      <sha1>pjl1yfhx8r2c2ptzpymkkw5a5kogjif</sha1>
    </revision>
    <revision>
      <id>590</id>
      <parentid>589</parentid>
      <timestamp>2024-03-09T08:25:05Z</timestamp>
      <contributor>
        <username>incubator&gt;NomusaAMethula</username>
        <id>0</id>
      </contributor>
      <comment>This is a picture of Chris Hani Baragwanath hospital</comment>
      <origin>590</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="293" sha1="2dieibyjucmez9ldm45hosudwxuosmk" xml:space="preserve">[[Isimumathi:Chris Hani Monument 4.jpg|thumb|UChris Hani]]
[[Isimumathi:The Chris Hani Baragwanath Hospital, Soweto.jpg|thumb|Isibhedlela iChris Hani Baragwanath]]
'''uChris Hani''' wayengusopolitiki kanye nemholi wecembe le[[ANC]].uHani wabulawa nga1993 [[eBoksburg.]]


{{INTERWIKI|Q547988}}</text>
      <sha1>2dieibyjucmez9ldm45hosudwxuosmk</sha1>
    </revision>
    <revision>
      <id>591</id>
      <parentid>590</parentid>
      <timestamp>2024-07-25T14:47:34Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>added new information</comment>
      <origin>591</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1521" sha1="hg1oxlgm993kazdk83rr5jcy8dvle0a" xml:space="preserve">[[Isimumathi:Chris Hani Monument 4.jpg|thumb|UChris Hani]]
[[Isimumathi:The Chris Hani Baragwanath Hospital, Soweto.jpg|thumb|Isibhedlela iChris Hani Baragwanath]]
'''uChris Hani''' wayengusopolitiki kanye nemholi wecembe le[[ANC]].uHani wabulawa nga1993 [[eBoksburg.]] U-Chris Hani, wabelethwa ngu-Martin Thembisile Hani mhlazi-28 kuMgwengweni wee-1942, endaweni yemakhaya ye-Sabalele e-Transkei, eSewula Afrika, bekangumlweli webandlululo nomrholi we-South African Communist Party (SACP) kanye ne-African National Congress (ANC ).&lt;ref&gt;Chris Hani - Wikipedia&lt;/ref&gt; U-Hani wadlala indima ekulu emzabalazweni wokulwisana nebandlululo, wasebenza njengomphathi we-Umkhonto we Sizwe, iphiko elihlomileko le-ANC.

U-Hani bekaziwa ngoburholi bakhe obuhle, ukuzinikela kwakhe emkhankasweni wekululeko, nekghono lakhe lokukhuthaza nokuhlanganisa abantu. Ukuzinikela kwakhe ekulwisaneni nebandlululo kwamenza waba mumuntu othandekako ebantwini abanengi beSewula Afrika.

Ngokudanisako, u-Chris Hani wabulawa mhlana ali-10 kuMrhayili wee-1993, ngaphandle kwekhaya lakhe e-Boksburg, eduze ne-Johannesburg. Ukubulawa kwakhe kwaba mzuzu oqakathekileko emlandwini weSewula Afrika, okwenzeka ngesikhathi esibucayi sokutjhugulukela kwentando yenengi. Ukuhlongakala kwaka-Hani kwabangela ukuthukuthela nokulila okukhulu, begodu kwaveza itlhogeko ephuthumako yokurarulula ukurarana kwesitjhaba ngokuthula. Ilifa lakhe liragela phambili nokuhlonitjhwa eSewula Afrika njengetshwayo lomzabalazo wekululeko nobulungiswa.

{{INTERWIKI|Q547988}}</text>
      <sha1>hg1oxlgm993kazdk83rr5jcy8dvle0a</sha1>
    </revision>
    <revision>
      <id>592</id>
      <parentid>591</parentid>
      <timestamp>2024-07-25T14:48:56Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>592</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1528" sha1="8pksgm6nw6wrw9y812wzr7uep13ujk4" xml:space="preserve">[[Isimumathi:Chris Hani Monument 4.jpg|thumb|UChris Hani]]
[[Isimumathi:The Chris Hani Baragwanath Hospital, Soweto.jpg|thumb|Isibhedlela iChris Hani Baragwanath]]
'''u[[Chris Hani]]''' wayengusopolitiki kanye nemholi wecembe le[[ANC]].uHani wabulawa nga1993 [[eBoksburg.]] U-Chris Hani, wabelethwa ngu-[[Martin Thembisile Hani]] mhlazi-28 kuMgwengweni wee-1942, endaweni yemakhaya ye-Sabalele e-Transkei, eSewula Afrika, bekangumlweli webandlululo nomrholi we-South African Communist Party (SACP) kanye ne-African National Congress (ANC).&lt;ref&gt;Chris Hani - Wikipedia&lt;/ref&gt; U-Hani wadlala indima ekulu emzabalazweni wokulwisana nebandlululo, wasebenza njengomphathi we-Umkhonto we Sizwe, iphiko elihlomileko le-ANC.

U-Hani bekaziwa ngoburholi bakhe obuhle, ukuzinikela kwakhe emkhankasweni wekululeko, nekghono lakhe lokukhuthaza nokuhlanganisa abantu. Ukuzinikela kwakhe ekulwisaneni nebandlululo kwamenza waba mumuntu othandekako ebantwini abanengi beSewula Afrika.

Ngokudanisako, u-Chris Hani wabulawa mhlana ali-10 kuMrhayili wee-1993, ngaphandle kwekhaya lakhe e-Boksburg, eduze ne-Johannesburg. Ukubulawa kwakhe kwaba mzuzu oqakathekileko emlandwini weSewula Afrika, okwenzeka ngesikhathi esibucayi sokutjhugulukela kwentando yenengi. Ukuhlongakala kwaka-Hani kwabangela ukuthukuthela nokulila okukhulu, begodu kwaveza itlhogeko ephuthumako yokurarulula ukurarana kwesitjhaba ngokuthula. Ilifa lakhe liragela phambili nokuhlonitjhwa eSewula Afrika njengetshwayo lomzabalazo wekululeko nobulungiswa.

{{INTERWIKI|Q547988}}</text>
      <sha1>8pksgm6nw6wrw9y812wzr7uep13ujk4</sha1>
    </revision>
    <revision>
      <id>593</id>
      <parentid>592</parentid>
      <timestamp>2024-10-14T13:46:37Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>8 revisions imported</comment>
      <origin>592</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1528" sha1="8pksgm6nw6wrw9y812wzr7uep13ujk4" xml:space="preserve">[[Isimumathi:Chris Hani Monument 4.jpg|thumb|UChris Hani]]
[[Isimumathi:The Chris Hani Baragwanath Hospital, Soweto.jpg|thumb|Isibhedlela iChris Hani Baragwanath]]
'''u[[Chris Hani]]''' wayengusopolitiki kanye nemholi wecembe le[[ANC]].uHani wabulawa nga1993 [[eBoksburg.]] U-Chris Hani, wabelethwa ngu-[[Martin Thembisile Hani]] mhlazi-28 kuMgwengweni wee-1942, endaweni yemakhaya ye-Sabalele e-Transkei, eSewula Afrika, bekangumlweli webandlululo nomrholi we-South African Communist Party (SACP) kanye ne-African National Congress (ANC).&lt;ref&gt;Chris Hani - Wikipedia&lt;/ref&gt; U-Hani wadlala indima ekulu emzabalazweni wokulwisana nebandlululo, wasebenza njengomphathi we-Umkhonto we Sizwe, iphiko elihlomileko le-ANC.

U-Hani bekaziwa ngoburholi bakhe obuhle, ukuzinikela kwakhe emkhankasweni wekululeko, nekghono lakhe lokukhuthaza nokuhlanganisa abantu. Ukuzinikela kwakhe ekulwisaneni nebandlululo kwamenza waba mumuntu othandekako ebantwini abanengi beSewula Afrika.

Ngokudanisako, u-Chris Hani wabulawa mhlana ali-10 kuMrhayili wee-1993, ngaphandle kwekhaya lakhe e-Boksburg, eduze ne-Johannesburg. Ukubulawa kwakhe kwaba mzuzu oqakathekileko emlandwini weSewula Afrika, okwenzeka ngesikhathi esibucayi sokutjhugulukela kwentando yenengi. Ukuhlongakala kwaka-Hani kwabangela ukuthukuthela nokulila okukhulu, begodu kwaveza itlhogeko ephuthumako yokurarulula ukurarana kwesitjhaba ngokuthula. Ilifa lakhe liragela phambili nokuhlonitjhwa eSewula Afrika njengetshwayo lomzabalazo wekululeko nobulungiswa.

{{INTERWIKI|Q547988}}</text>
      <sha1>8pksgm6nw6wrw9y812wzr7uep13ujk4</sha1>
    </revision>
    <revision>
      <id>1667</id>
      <parentid>593</parentid>
      <timestamp>2024-10-16T09:49:47Z</timestamp>
      <contributor>
        <username>JhsBot</username>
        <id>34</id>
      </contributor>
      <minor />
      <comment>bot: Removing interwiki template; the page is now connected to [[d:Q547988]]</comment>
      <origin>1667</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1505" sha1="3hqg01bcibobkvq5pvvayifp4r1wgu8" xml:space="preserve">[[Isimumathi:Chris Hani Monument 4.jpg|thumb|UChris Hani]]
[[Isimumathi:The Chris Hani Baragwanath Hospital, Soweto.jpg|thumb|Isibhedlela iChris Hani Baragwanath]]
'''u[[Chris Hani]]''' wayengusopolitiki kanye nemholi wecembe le[[ANC]].uHani wabulawa nga1993 [[eBoksburg.]] U-Chris Hani, wabelethwa ngu-[[Martin Thembisile Hani]] mhlazi-28 kuMgwengweni wee-1942, endaweni yemakhaya ye-Sabalele e-Transkei, eSewula Afrika, bekangumlweli webandlululo nomrholi we-South African Communist Party (SACP) kanye ne-African National Congress (ANC).&lt;ref&gt;Chris Hani - Wikipedia&lt;/ref&gt; U-Hani wadlala indima ekulu emzabalazweni wokulwisana nebandlululo, wasebenza njengomphathi we-Umkhonto we Sizwe, iphiko elihlomileko le-ANC.

U-Hani bekaziwa ngoburholi bakhe obuhle, ukuzinikela kwakhe emkhankasweni wekululeko, nekghono lakhe lokukhuthaza nokuhlanganisa abantu. Ukuzinikela kwakhe ekulwisaneni nebandlululo kwamenza waba mumuntu othandekako ebantwini abanengi beSewula Afrika.

Ngokudanisako, u-Chris Hani wabulawa mhlana ali-10 kuMrhayili wee-1993, ngaphandle kwekhaya lakhe e-Boksburg, eduze ne-Johannesburg. Ukubulawa kwakhe kwaba mzuzu oqakathekileko emlandwini weSewula Afrika, okwenzeka ngesikhathi esibucayi sokutjhugulukela kwentando yenengi. Ukuhlongakala kwaka-Hani kwabangela ukuthukuthela nokulila okukhulu, begodu kwaveza itlhogeko ephuthumako yokurarulula ukurarana kwesitjhaba ngokuthula. Ilifa lakhe liragela phambili nokuhlonitjhwa eSewula Afrika njengetshwayo lomzabalazo wekululeko nobulungiswa.</text>
      <sha1>3hqg01bcibobkvq5pvvayifp4r1wgu8</sha1>
    </revision>
    <revision>
      <id>2100</id>
      <parentid>1667</parentid>
      <timestamp>2024-11-25T09:44:00Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>+ Iinkomba</comment>
      <origin>2100</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1533" sha1="j6lrlcp9zv7gllbi3cj930t8jngy78e" xml:space="preserve">[[Isimumathi:Chris Hani Monument 4.jpg|thumb|UChris Hani]]
[[Isimumathi:The Chris Hani Baragwanath Hospital, Soweto.jpg|thumb|Isibhedlela iChris Hani Baragwanath]]
'''u[[Chris Hani]]''' wayengusopolitiki kanye nemholi wecembe le[[ANC]].uHani wabulawa nga1993 [[eBoksburg.]] U-Chris Hani, wabelethwa ngu-[[Martin Thembisile Hani]] mhlazi-28 kuMgwengweni wee-1942, endaweni yemakhaya ye-Sabalele e-Transkei, eSewula Afrika, bekangumlweli webandlululo nomrholi we-South African Communist Party (SACP) kanye ne-African National Congress (ANC).&lt;ref&gt;Chris Hani - Wikipedia&lt;/ref&gt; U-Hani wadlala indima ekulu emzabalazweni wokulwisana nebandlululo, wasebenza njengomphathi we-Umkhonto we Sizwe, iphiko elihlomileko le-ANC.

U-Hani bekaziwa ngoburholi bakhe obuhle, ukuzinikela kwakhe emkhankasweni wekululeko, nekghono lakhe lokukhuthaza nokuhlanganisa abantu. Ukuzinikela kwakhe ekulwisaneni nebandlululo kwamenza waba mumuntu othandekako ebantwini abanengi beSewula Afrika.

Ngokudanisako, u-Chris Hani wabulawa mhlana ali-10 kuMrhayili wee-1993, ngaphandle kwekhaya lakhe e-Boksburg, eduze ne-Johannesburg. Ukubulawa kwakhe kwaba mzuzu oqakathekileko emlandwini weSewula Afrika, okwenzeka ngesikhathi esibucayi sokutjhugulukela kwentando yenengi. Ukuhlongakala kwaka-Hani kwabangela ukuthukuthela nokulila okukhulu, begodu kwaveza itlhogeko ephuthumako yokurarulula ukurarana kwesitjhaba ngokuthula. Ilifa lakhe liragela phambili nokuhlonitjhwa eSewula Afrika njengetshwayo lomzabalazo wekululeko nobulungiswa.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>j6lrlcp9zv7gllbi3cj930t8jngy78e</sha1>
    </revision>
    <revision>
      <id>2949</id>
      <parentid>2100</parentid>
      <timestamp>2025-06-06T17:23:30Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>E</comment>
      <origin>2949</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="50" sha1="dtyp5e0o2s6wvx63jcc7najmew8l12f" xml:space="preserve">Chris
== Christopher oh Christopher ==
{{Reflist}}</text>
      <sha1>dtyp5e0o2s6wvx63jcc7najmew8l12f</sha1>
    </revision>
    <revision>
      <id>3103</id>
      <parentid>2949</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Simakahle Moselekatse|Simakahle Moselekatse]]</comment>
      <origin>2100</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1533" sha1="j6lrlcp9zv7gllbi3cj930t8jngy78e" xml:space="preserve">[[Isimumathi:Chris Hani Monument 4.jpg|thumb|UChris Hani]]
[[Isimumathi:The Chris Hani Baragwanath Hospital, Soweto.jpg|thumb|Isibhedlela iChris Hani Baragwanath]]
'''u[[Chris Hani]]''' wayengusopolitiki kanye nemholi wecembe le[[ANC]].uHani wabulawa nga1993 [[eBoksburg.]] U-Chris Hani, wabelethwa ngu-[[Martin Thembisile Hani]] mhlazi-28 kuMgwengweni wee-1942, endaweni yemakhaya ye-Sabalele e-Transkei, eSewula Afrika, bekangumlweli webandlululo nomrholi we-South African Communist Party (SACP) kanye ne-African National Congress (ANC).&lt;ref&gt;Chris Hani - Wikipedia&lt;/ref&gt; U-Hani wadlala indima ekulu emzabalazweni wokulwisana nebandlululo, wasebenza njengomphathi we-Umkhonto we Sizwe, iphiko elihlomileko le-ANC.

U-Hani bekaziwa ngoburholi bakhe obuhle, ukuzinikela kwakhe emkhankasweni wekululeko, nekghono lakhe lokukhuthaza nokuhlanganisa abantu. Ukuzinikela kwakhe ekulwisaneni nebandlululo kwamenza waba mumuntu othandekako ebantwini abanengi beSewula Afrika.

Ngokudanisako, u-Chris Hani wabulawa mhlana ali-10 kuMrhayili wee-1993, ngaphandle kwekhaya lakhe e-Boksburg, eduze ne-Johannesburg. Ukubulawa kwakhe kwaba mzuzu oqakathekileko emlandwini weSewula Afrika, okwenzeka ngesikhathi esibucayi sokutjhugulukela kwentando yenengi. Ukuhlongakala kwaka-Hani kwabangela ukuthukuthela nokulila okukhulu, begodu kwaveza itlhogeko ephuthumako yokurarulula ukurarana kwesitjhaba ngokuthula. Ilifa lakhe liragela phambili nokuhlonitjhwa eSewula Afrika njengetshwayo lomzabalazo wekululeko nobulungiswa.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>j6lrlcp9zv7gllbi3cj930t8jngy78e</sha1>
    </revision>
  </page>
  <page>
    <title>Clive Barker</title>
    <ns>0</ns>
    <id>124</id>
    <revision>
      <id>594</id>
      <timestamp>2024-05-22T19:04:28Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;UClive William Barker (23 Juni 1944 - 10 Juni 2023) wayengumqeqeshi webhola lase[[Isewula Afrika|Sewula Afrika]]. Uhole iqembu lesizwe laseNingizimu Afrika ekunqobeni okuwukuphela kwalo isicoco se-African Nations Cup ngo-1996. Wayengumalume kaSteve Barker.&quot;</comment>
      <origin>594</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="256" sha1="2qwqa7c1s2v0ucfs2kcc49f2fqvicx2" xml:space="preserve">UClive William Barker (23 Juni 1944 - 10 Juni 2023) wayengumqeqeshi webhola lase[[Isewula Afrika|Sewula Afrika]]. Uhole iqembu lesizwe laseNingizimu Afrika ekunqobeni okuwukuphela kwalo isicoco se-African Nations Cup ngo-1996. Wayengumalume kaSteve Barker.</text>
      <sha1>2qwqa7c1s2v0ucfs2kcc49f2fqvicx2</sha1>
    </revision>
    <revision>
      <id>595</id>
      <parentid>594</parentid>
      <timestamp>2024-10-14T13:46:37Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>594</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="256" sha1="2qwqa7c1s2v0ucfs2kcc49f2fqvicx2" xml:space="preserve">UClive William Barker (23 Juni 1944 - 10 Juni 2023) wayengumqeqeshi webhola lase[[Isewula Afrika|Sewula Afrika]]. Uhole iqembu lesizwe laseNingizimu Afrika ekunqobeni okuwukuphela kwalo isicoco se-African Nations Cup ngo-1996. Wayengumalume kaSteve Barker.</text>
      <sha1>2qwqa7c1s2v0ucfs2kcc49f2fqvicx2</sha1>
    </revision>
    <revision>
      <id>2116</id>
      <parentid>595</parentid>
      <timestamp>2024-11-25T18:00:58Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <comment>'''</comment>
      <origin>2116</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="262" sha1="k56pai9bgr02fstlj45y8lwi2uwg0ey" xml:space="preserve">'''UClive William Barker''' (23 Juni 1944 - 10 Juni 2023) wayengumqeqeshi webhola lase[[Isewula Afrika|Sewula Afrika]]. Uhole iqembu lesizwe laseNingizimu Afrika ekunqobeni okuwukuphela kwalo isicoco se-African Nations Cup ngo-1996. Wayengumalume kaSteve Barker.</text>
      <sha1>k56pai9bgr02fstlj45y8lwi2uwg0ey</sha1>
    </revision>
  </page>
  <page>
    <title>David Tlale</title>
    <ns>0</ns>
    <id>126</id>
    <revision>
      <id>598</id>
      <timestamp>2024-03-08T13:14:46Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;David Tlale ungumthungu wezembatho waseSewula Afrika.  &quot;</comment>
      <origin>598</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="55" sha1="f14063uajey9uhxiffsj5l2c87znp9f" xml:space="preserve">David Tlale ungumthungu wezembatho waseSewula Afrika.

</text>
      <sha1>f14063uajey9uhxiffsj5l2c87znp9f</sha1>
    </revision>
    <revision>
      <id>599</id>
      <parentid>598</parentid>
      <timestamp>2024-03-09T07:27:27Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>599</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="80" sha1="28h5x7nqqpbah3o566xegu4fah3bgnb" xml:space="preserve">'''David Tlale''' ungumthungu wezembatho wase[[Isewula Afrika|Sewula Afrika]].

</text>
      <sha1>28h5x7nqqpbah3o566xegu4fah3bgnb</sha1>
    </revision>
    <revision>
      <id>600</id>
      <parentid>599</parentid>
      <timestamp>2024-03-10T20:49:26Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Adding interwiki links to [[d:Q23409652]]</comment>
      <origin>600</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="104" sha1="sa63g231ing1ggywz5r3asqzl8xccmr" xml:space="preserve">'''David Tlale''' ungumthungu wezembatho wase[[Isewula Afrika|Sewula Afrika]].


{{INTERWIKI|Q23409652}}</text>
      <sha1>sa63g231ing1ggywz5r3asqzl8xccmr</sha1>
    </revision>
    <revision>
      <id>601</id>
      <parentid>600</parentid>
      <timestamp>2024-10-14T13:46:37Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>600</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="104" sha1="sa63g231ing1ggywz5r3asqzl8xccmr" xml:space="preserve">'''David Tlale''' ungumthungu wezembatho wase[[Isewula Afrika|Sewula Afrika]].


{{INTERWIKI|Q23409652}}</text>
      <sha1>sa63g231ing1ggywz5r3asqzl8xccmr</sha1>
    </revision>
    <revision>
      <id>1668</id>
      <parentid>601</parentid>
      <timestamp>2024-10-16T09:49:49Z</timestamp>
      <contributor>
        <username>JhsBot</username>
        <id>34</id>
      </contributor>
      <minor />
      <comment>bot: Removing interwiki template; the page is now connected to [[d:Q23409652]]</comment>
      <origin>1668</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="78" sha1="lkf9iksy4kp33gue57ezzjtd19yypm2" xml:space="preserve">'''David Tlale''' ungumthungu wezembatho wase[[Isewula Afrika|Sewula Afrika]].</text>
      <sha1>lkf9iksy4kp33gue57ezzjtd19yypm2</sha1>
    </revision>
    <revision>
      <id>1708</id>
      <parentid>1668</parentid>
      <timestamp>2024-10-21T02:41:06Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1708</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1368" sha1="hdog0fjb696ws1e47x5xgkwmnkgww6k" xml:space="preserve">'''U-David Tlale''' (29 kuTjhirhweni 1975) mklami wezembatho [[Isewula Afrika|weSewula Afrika]]. Wabelethelwa e-Vosloorus eSewula Afrika. Wakhuliswa ngunina oyedwa. Umsebenzi wakhe utjengiswe e-Cape Town Fashion Week, e-New York Fashion Week, kanye ne-Paris Fashion Week. Uphinde wakha amaqoqo wabathengisi abakhulu njenge-Edgars. U-Tlale bekangumdlali we-semi finalist ku-South African Fashion Week Elle New Talent Show Competition ngo-2002. NgoMeyi 2003, u-Tlale wathoma ama-studio wokuklama e-Cape Town ne-Johannesburg.&lt;ref name=&quot;dn&quot;&gt;{{cite web | url=http://www.nation.co.ke/lifestyle/lifestyle/David-Tlale-on-the-business-of-fashion/-/1214/2859234/-/uxv8baz/-/index.html | title=World acclaimed South African designer on the business of fashion | publisher=Daily Nation | date=5 September 2015 | accessdate=12 March 2016}}&lt;/ref&gt;&lt;ref&gt;{{Cite web|url=http://www.southafrica.net/za/en/articles/entry/article-david-tlale|title=Colouring outside the lines: David Tlale|last=|first=|date=|website=|publisher=|access-date=}}&lt;/ref&gt;&lt;ref&gt;{{Cite web|url=http://www.iol.co.za/news/south-africa/tlales-bridalwear-defies-tradition-1894072|title=Tlale's bridalwear defies tradition {{!}} IOL|website=IOL|access-date=2016-03-12}}&lt;/ref&gt;


Ngomnyaka ka-2022 u-Tlale wanikelwa idigri yokuhlonipha yi-Tshwane University of Technology, begodu wanikela idigri leyo kumma wakhe ongasekho.</text>
      <sha1>hdog0fjb696ws1e47x5xgkwmnkgww6k</sha1>
    </revision>
    <revision>
      <id>1709</id>
      <parentid>1708</parentid>
      <timestamp>2024-10-21T02:41:44Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1709</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1384" sha1="n9apikvb8yr56g46r6piix2yobtj4l2" xml:space="preserve">'''U-David Tlale''' (29 kuTjhirhweni 1975) mklami wezembatho [[Isewula Afrika|weSewula Afrika]]. Wabelethelwa e-Vosloorus eSewula Afrika. Wakhuliswa ngunina oyedwa. Umsebenzi wakhe utjengiswe e-Cape Town Fashion Week, e-New York Fashion Week, kanye ne-Paris Fashion Week. Uphinde wakha amaqoqo wabathengisi abakhulu njenge-Edgars. U-Tlale bekangumdlali we-semi finalist ku-South African Fashion Week Elle New Talent Show Competition ngo-2002. NgoMeyi 2003, u-Tlale wathoma ama-studio wokuklama e-Cape Town ne-Johannesburg.&lt;ref name=&quot;dn&quot;&gt;{{cite web | url=http://www.nation.co.ke/lifestyle/lifestyle/David-Tlale-on-the-business-of-fashion/-/1214/2859234/-/uxv8baz/-/index.html | title=World acclaimed South African designer on the business of fashion | publisher=Daily Nation | date=5 September 2015 | accessdate=12 March 2016}}&lt;/ref&gt;&lt;ref&gt;{{Cite web|url=http://www.southafrica.net/za/en/articles/entry/article-david-tlale|title=Colouring outside the lines: David Tlale|last=|first=|date=|website=|publisher=|access-date=}}&lt;/ref&gt;&lt;ref&gt;{{Cite web|url=http://www.iol.co.za/news/south-africa/tlales-bridalwear-defies-tradition-1894072|title=Tlale's bridalwear defies tradition {{!}} IOL|website=IOL|access-date=2016-03-12}}&lt;/ref&gt;


Ngomnyaka ka-2022 u-Tlale wanikelwa idigri yokuhlonipha yi-Tshwane University of Technology, begodu wanikela idigri leyo kumma wakhe ongasekho.

== Iinkomba ==</text>
      <sha1>n9apikvb8yr56g46r6piix2yobtj4l2</sha1>
    </revision>
    <revision>
      <id>2098</id>
      <parentid>1709</parentid>
      <timestamp>2024-11-25T08:51:40Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* Iinkomba */nation.africa</comment>
      <origin>2098</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1387" sha1="0hd5uiujuvltm2r4nsjm1b0v0i1p76e" xml:space="preserve">'''U-David Tlale''' (29 kuTjhirhweni 1975) mklami wezembatho [[Isewula Afrika|weSewula Afrika]]. Wabelethelwa e-Vosloorus eSewula Afrika. Wakhuliswa ngunina oyedwa. Umsebenzi wakhe utjengiswe e-Cape Town Fashion Week, e-New York Fashion Week, kanye ne-Paris Fashion Week. Uphinde wakha amaqoqo wabathengisi abakhulu njenge-Edgars. U-Tlale bekangumdlali we-semi finalist ku-South African Fashion Week Elle New Talent Show Competition ngo-2002. NgoMeyi 2003, u-Tlale wathoma ama-studio wokuklama e-Cape Town ne-Johannesburg.&lt;ref name=&quot;dn&quot;&gt;{{cite web | url=https://nation.africa/lifestyle/lifestyle/David-Tlale-on-the-business-of-fashion/1214-2859234-uxv8baz/index.html | title=World acclaimed South African designer on the business of fashion | publisher=Daily Nation | date=5 September 2015 | accessdate=12 March 2016}}&lt;/ref&gt;&lt;ref&gt;{{Cite web|url=http://www.southafrica.net/za/en/articles/entry/article-david-tlale|title=Colouring outside the lines: David Tlale|last=|first=|date=|website=|publisher=|access-date=}}&lt;/ref&gt;&lt;ref&gt;{{Cite web|url=http://www.iol.co.za/news/south-africa/tlales-bridalwear-defies-tradition-1894072|title=Tlale's bridalwear defies tradition {{!}} IOL|website=IOL|access-date=2016-03-12}}&lt;/ref&gt;

Ngomnyaka ka-2022 u-Tlale wanikelwa idigri yokuhlonipha yi-Tshwane University of Technology, begodu wanikela idigri leyo kumma wakhe ongasekho.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>0hd5uiujuvltm2r4nsjm1b0v0i1p76e</sha1>
    </revision>
    <revision>
      <id>2099</id>
      <parentid>2098</parentid>
      <timestamp>2024-11-25T08:53:32Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <comment>/* Iinkomba */iol.co.za</comment>
      <origin>2099</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1388" sha1="21d7dx1m3a81dnmf3pkjb5nqb0aydi8" xml:space="preserve">'''U-David Tlale''' (29 kuTjhirhweni 1975) mklami wezembatho [[Isewula Afrika|weSewula Afrika]]. Wabelethelwa e-Vosloorus eSewula Afrika. Wakhuliswa ngunina oyedwa. Umsebenzi wakhe utjengiswe e-Cape Town Fashion Week, e-New York Fashion Week, kanye ne-Paris Fashion Week. Uphinde wakha amaqoqo wabathengisi abakhulu njenge-Edgars. U-Tlale bekangumdlali we-semi finalist ku-South African Fashion Week Elle New Talent Show Competition ngo-2002. NgoMeyi 2003, u-Tlale wathoma ama-studio wokuklama e-Cape Town ne-Johannesburg.&lt;ref name=&quot;dn&quot;&gt;{{cite web | url=https://nation.africa/lifestyle/lifestyle/David-Tlale-on-the-business-of-fashion/1214-2859234-uxv8baz/index.html | title=World acclaimed South African designer on the business of fashion | publisher=Daily Nation | date=5 September 2015 | accessdate=12 March 2016}}&lt;/ref&gt;&lt;ref&gt;{{Cite web|url=http://www.southafrica.net/za/en/articles/entry/article-david-tlale|title=Colouring outside the lines: David Tlale|last=|first=|date=|website=|publisher=|access-date=}}&lt;/ref&gt;&lt;ref&gt;{{Cite web|url=https://www.iol.co.za/news/south-africa/tlales-bridalwear-defies-tradition-1894072|title=Tlale's bridalwear defies tradition {{!}} IOL|website=IOL|access-date=2016-03-12}}&lt;/ref&gt;

Ngomnyaka ka-2022 u-Tlale wanikelwa idigri yokuhlonipha yi-Tshwane University of Technology, begodu wanikela idigri leyo kumma wakhe ongasekho.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>21d7dx1m3a81dnmf3pkjb5nqb0aydi8</sha1>
    </revision>
    <revision>
      <id>2161</id>
      <parentid>2099</parentid>
      <timestamp>2024-11-27T06:04:23Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <comment>UDavid</comment>
      <origin>2161</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1387" sha1="d1qseks6y4ukbrknrrw3qjuhkokfhp1" xml:space="preserve">'''UDavid Tlale''' (29 kuTjhirhweni 1975) mklami wezembatho [[Isewula Afrika|weSewula Afrika]]. Wabelethelwa e-Vosloorus eSewula Afrika. Wakhuliswa ngunina oyedwa. Umsebenzi wakhe utjengiswe e-Cape Town Fashion Week, e-New York Fashion Week, kanye ne-Paris Fashion Week. Uphinde wakha amaqoqo wabathengisi abakhulu njenge-Edgars. U-Tlale bekangumdlali we-semi finalist ku-South African Fashion Week Elle New Talent Show Competition ngo-2002. NgoMeyi 2003, u-Tlale wathoma ama-studio wokuklama e-Cape Town ne-Johannesburg.&lt;ref name=&quot;dn&quot;&gt;{{cite web | url=https://nation.africa/lifestyle/lifestyle/David-Tlale-on-the-business-of-fashion/1214-2859234-uxv8baz/index.html | title=World acclaimed South African designer on the business of fashion | publisher=Daily Nation | date=5 September 2015 | accessdate=12 March 2016}}&lt;/ref&gt;&lt;ref&gt;{{Cite web|url=http://www.southafrica.net/za/en/articles/entry/article-david-tlale|title=Colouring outside the lines: David Tlale|last=|first=|date=|website=|publisher=|access-date=}}&lt;/ref&gt;&lt;ref&gt;{{Cite web|url=https://www.iol.co.za/news/south-africa/tlales-bridalwear-defies-tradition-1894072|title=Tlale's bridalwear defies tradition {{!}} IOL|website=IOL|access-date=2016-03-12}}&lt;/ref&gt;

Ngomnyaka ka-2022 u-Tlale wanikelwa idigri yokuhlonipha yi-Tshwane University of Technology, begodu wanikela idigri leyo kumma wakhe ongasekho.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>d1qseks6y4ukbrknrrw3qjuhkokfhp1</sha1>
    </revision>
    <revision>
      <id>2992</id>
      <parentid>2161</parentid>
      <timestamp>2025-06-06T20:15:10Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>nhiudhythrgfdgry</comment>
      <origin>2992</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1468" sha1="hen8i1r9hymyyt3027u2pku9jusuci9" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. UDavid Tlale''' (29 kuTjhirhweni 1975) mklami wezembatho [[Isewula Afrika|weSewula Afrika]]. Wabelethelwa e-Vosloorus eSewula Afrika. Wakhuliswa ngunina oyedwa. Umsebenzi wakhe utjengiswe e-Cape Town Fashion Week, e-New York Fashion Week, kanye ne-Paris Fashion Week. Uphinde wakha amaqoqo wabathengisi abakhulu njenge-Edgars. U-Tlale bekangumdlali we-semi finalist ku-South African Fashion Week Elle New Talent Show Competition ngo-2002. NgoMeyi 2003, u-Tlale wathoma ama-studio wokuklama e-Cape Town ne-Johannesburg.&lt;ref name=&quot;dn&quot;&gt;{{cite web | url=https://nation.africa/lifestyle/lifestyle/David-Tlale-on-the-business-of-fashion/1214-2859234-uxv8baz/index.html | title=World acclaimed South African designer on the business of fashion | publisher=Daily Nation | date=5 September 2015 | accessdate=12 March 2016}}&lt;/ref&gt;&lt;ref&gt;{{Cite web|url=http://www.southafrica.net/za/en/articles/entry/article-david-tlale|title=Colouring outside the lines: David Tlale|last=|first=|date=|website=|publisher=|access-date=}}&lt;/ref&gt;&lt;ref&gt;{{Cite web|url=https://www.iol.co.za/news/south-africa/tlales-bridalwear-defies-tradition-1894072|title=Tlale's bridalwear defies tradition {{!}} IOL|website=IOL|access-date=2016-03-12}}&lt;/ref&gt;

Ngomnyaka ka-2022 u-Tlale wanikelwa idigri yokuhlonipha yi-Tshwane University of Technology, begodu wanikela idigri leyo kumma wakhe ongasekho.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>hen8i1r9hymyyt3027u2pku9jusuci9</sha1>
    </revision>
    <revision>
      <id>3078</id>
      <parentid>2992</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Simakahle Moselekatse|Simakahle Moselekatse]]</comment>
      <origin>2161</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1387" sha1="d1qseks6y4ukbrknrrw3qjuhkokfhp1" xml:space="preserve">'''UDavid Tlale''' (29 kuTjhirhweni 1975) mklami wezembatho [[Isewula Afrika|weSewula Afrika]]. Wabelethelwa e-Vosloorus eSewula Afrika. Wakhuliswa ngunina oyedwa. Umsebenzi wakhe utjengiswe e-Cape Town Fashion Week, e-New York Fashion Week, kanye ne-Paris Fashion Week. Uphinde wakha amaqoqo wabathengisi abakhulu njenge-Edgars. U-Tlale bekangumdlali we-semi finalist ku-South African Fashion Week Elle New Talent Show Competition ngo-2002. NgoMeyi 2003, u-Tlale wathoma ama-studio wokuklama e-Cape Town ne-Johannesburg.&lt;ref name=&quot;dn&quot;&gt;{{cite web | url=https://nation.africa/lifestyle/lifestyle/David-Tlale-on-the-business-of-fashion/1214-2859234-uxv8baz/index.html | title=World acclaimed South African designer on the business of fashion | publisher=Daily Nation | date=5 September 2015 | accessdate=12 March 2016}}&lt;/ref&gt;&lt;ref&gt;{{Cite web|url=http://www.southafrica.net/za/en/articles/entry/article-david-tlale|title=Colouring outside the lines: David Tlale|last=|first=|date=|website=|publisher=|access-date=}}&lt;/ref&gt;&lt;ref&gt;{{Cite web|url=https://www.iol.co.za/news/south-africa/tlales-bridalwear-defies-tradition-1894072|title=Tlale's bridalwear defies tradition {{!}} IOL|website=IOL|access-date=2016-03-12}}&lt;/ref&gt;

Ngomnyaka ka-2022 u-Tlale wanikelwa idigri yokuhlonipha yi-Tshwane University of Technology, begodu wanikela idigri leyo kumma wakhe ongasekho.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>d1qseks6y4ukbrknrrw3qjuhkokfhp1</sha1>
    </revision>
  </page>
  <page>
    <title>Ebola</title>
    <ns>0</ns>
    <id>127</id>
    <redirect title="Ubulwelwe be-Ebola" />
    <revision>
      <id>602</id>
      <timestamp>2014-09-04T07:33:21Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>#REDIRECT [[Ubulwelwe be-Ebola]]</comment>
      <origin>602</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="32" sha1="o71s3uo8ogma4etl5ujafo5gttakvhx" xml:space="preserve">#REDIRECT [[Ubulwelwe be-Ebola]]</text>
      <sha1>o71s3uo8ogma4etl5ujafo5gttakvhx</sha1>
    </revision>
    <revision>
      <id>603</id>
      <parentid>602</parentid>
      <timestamp>2024-10-14T13:46:38Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>602</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="32" sha1="o71s3uo8ogma4etl5ujafo5gttakvhx" xml:space="preserve">#REDIRECT [[Ubulwelwe be-Ebola]]</text>
      <sha1>o71s3uo8ogma4etl5ujafo5gttakvhx</sha1>
    </revision>
  </page>
  <page>
    <title>Emaplasini weBelfast</title>
    <ns>0</ns>
    <id>128</id>
    <revision>
      <id>604</id>
      <timestamp>2024-05-22T08:25:34Z</timestamp>
      <contributor>
        <ip>196.21.175.1</ip>
      </contributor>
      <comment>Created page with &quot;'''Emaplasini weBelfast''' kuyindawa ehle khulu ngesibanga sokuthi izele ngezinto zemvelo. Ithulile ngombana imizi imacalanga. Kuyindawa ebizwa ngokuthi semakhazeni ngombana kumakhaza. Nakusebusika manzi avuka aliyisi.  &quot;</comment>
      <origin>604</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="220" sha1="r79so8ebp7nrcwvjnzkgm12othb6cg7" xml:space="preserve">'''Emaplasini weBelfast''' kuyindawa ehle khulu ngesibanga sokuthi izele ngezinto zemvelo. Ithulile ngombana imizi imacalanga. Kuyindawa ebizwa ngokuthi semakhazeni ngombana kumakhaza. Nakusebusika manzi avuka aliyisi.

</text>
      <sha1>r79so8ebp7nrcwvjnzkgm12othb6cg7</sha1>
    </revision>
    <revision>
      <id>605</id>
      <parentid>604</parentid>
      <timestamp>2024-05-22T08:54:04Z</timestamp>
      <contributor>
        <ip>196.21.175.1</ip>
      </contributor>
      <origin>605</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1762" sha1="ce5cs6bmfdva4vwsey4yjk2z415q4iy" xml:space="preserve">'''Emaplasini weBelfast''' kuyindawa ehle khulu ngesibanga sokuthi izele ngezinto zemvelo. Ithulile ngombana imizi imacalanga. Kuyindawa ebizwa ngokuthi semakhazeni ngombana kumakhaza. Nakusebusika manzi avuka aliyisi. Emaplsini kuyindawo eqakathekileko  ebantwini abanengi bamaNdebele ngombana kukulapho kwalala khona abomkhulu babo begodu kukulapho badabuka khona.

== Indlela yokuphila emaplasini ==
Emaplasini kusaphilwa ngendlela yakade ngombana akuna gezi, yeku lokha nafanele kuphekwe kuphekwa esitofini samahle ngokusebenzisa iinkuni ezitheziweko. Nangabe kuphekwa ngeempoto ezikulu engeze zanele esitofini samalahle, kubaswa phas ngeenkuni.

=== Amanzi wemifula ===
Amanzi wemifula yakhona ahlenzile ngombana akulahlelwa noma yini emilanjeni. Abantu bavasela khona iingubo zabo ukuze zihlanzeke kuhle. Kuthi sele bacedile ukuzihlanza iingubo zabo bakhambe bayozinekka emadradeni ahlukanisa iindlela yeenkoloyi namahlathi.

=== Iinthelo nefuyo ===
Kumateni amakhulu lapho kutjalwe khona iinthelo ezifana nama anyanisi, ife, amazambane, kanye nemirorho. Ifuyo ekhona emaplasini ziinkomo ekungezama khuwa begodu ezinye ngezabantu abanzima. imfaigi, izimvu, kanye neenkukhu. Abantu abanzima badla amacanda abekelwe ziinkukhu zemakhaya begodu ipuphu bayithola emakhuweni ahlala nabo emaplasini. Zikhoa neembana emaplasini ezifana ne nenungu, iimfarigi zommango

=== Izinga lobugebengu ===
emaplsini ubugebengu yinto engakavami. Lokhu kubonakala ngokuthi iminyango yakhona ayikhiyelwa.

=== Iinkolo ===
Emaplsini azikho iinkolo, kodwana zisedorobheni eliseduze nakhona. Abantwana ukuze bakghone ukuya esikolweni balandwa yi bhesi nge iri le-6 ekuseni. Bese godu kunesinye isikolo lapho abantwana bahlala khona esibizwa bonyana yi Makhazeni boarding school. 

</text>
      <sha1>ce5cs6bmfdva4vwsey4yjk2z415q4iy</sha1>
    </revision>
    <revision>
      <id>606</id>
      <parentid>605</parentid>
      <timestamp>2024-05-22T09:00:56Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>606</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2008" sha1="b3hibqrx9bnkfert8qjuiqlhtv9384p" xml:space="preserve">'''Emaplasini weBelfast''' kuyindawa ehle khulu ngesibanga sokuthi izele ngezinto zemvelo. Ithulile ngombana imizi imacalanga. Kuyindawa ebizwa ngokuthi semakhazeni ngombana kumakhaza. Nakusebusika manzi avuka aliyisi  ngendla kumakhaza ngakhona. Emaplasini kuyindawo eqakathekileko  ebantwini abanengi bamaNdebele ngombana kukulapho kwalala khona abomkhulu babo, begodu kukulapho abanye babo badabuka khona. Yeke endaweni le kukulapho kulele khona amathambo wamalunga wemindeni yabo.

== Indlela yokuphila emaplasini ==
Emaplasini kusaphilwa ngendlela yakade ngombana akuna gezi, yeke lokha nafanele kuphekwe kuphekwa esitofini samahle ngokusebenzisa iinkuni ezitheziweko. Nangabe kuphekwa ngeempoto ezikulu engeze zanele esitofini samalahle, kubaswa phasi ngeenkuni. abantu abanzima nabafuna ukutjhajisa abomaliledinini babo baya emakhumaweni bona abatjhatjhisele zona.

=== Amanzi wemifula ===
Amanzi wemifula yakhona, kumamanzi akhambako, ahlenzekile ngombana akulahlelwa noma yini emilanjeni. Abantu bavasela khona iingubo zabo ukuze zihlanzeke kuhle. Kuthi sele bacedile ukuzihlanza iingubo zabo bakhambe bayozinekka emadradeni ahlukanisa iindlela yeenkoloyi namahlathi.

=== Iinthelo nefuyo ===
Kumateni amakhulu lapho kutjalwe khona iinthelo ezifana nama anyanisi, ife, amazambane, kanye nemirorho. Ifuyo ekhona emaplasini ziinkomo ekungezama khuwa begodu ezinye ngezabantu abanzima. imfaigi, izimvu, kanye neenkukhu. Abantu abanzima badla amacanda abekelwe ziinkukhu zemakhaya begodu ipuphu bayithola emakhuweni ahlala nabo emaplasini. Zikhoa neembana emaplasini ezifana ne nenungu, iimfarigi zommango

=== Izinga lobugebengu ===
emaplsini ubugebengu yinto engakavami. Lokhu kubonakala ngokuthi iminyango yakhona ayikhiyelwa.

=== Iinkolo ===
Emaplsini azikho iinkolo, kodwana zisedorobheni eliseduze nakhona. Abantwana ukuze bakghone ukuya esikolweni balandwa yi bhesi nge iri le-6 ekuseni. Bese godu kunesinye isikolo lapho abantwana bahlala khona esibizwa bonyana yi Makhazeni boarding school. 

</text>
      <sha1>b3hibqrx9bnkfert8qjuiqlhtv9384p</sha1>
    </revision>
    <revision>
      <id>607</id>
      <parentid>606</parentid>
      <timestamp>2024-05-22T21:17:50Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>607</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2222" sha1="8g43b4jnkzgpfi8vh0ojktw38fku539" xml:space="preserve">[[Isimumathi:Indlu yemaplasini.jpg|thumb|Izindlu zemaplasini]]
[[Isimumathi:Imizi imacalanga.jpg|thumb|Imizi imacalanga[[Isimumathi:Ifuyo yemaplasini.jpg|thumb]]Ifuyo]]
'''Emaplasini weBelfast''' kuyindawa ehle khulu ngesibanga sokuthi izele ngezinto zemvelo. Ithulile ngombana imizi imacalanga. Kuyindawa ebizwa ngokuthi semakhazeni ngombana kumakhaza. Nakusebusika manzi avuka alirhwaba  ngendlela kumakhaza ngakhona.Ehlobo imithi notjani  bubahlaza tlabha . Emaplasini kuyindawo eqakathekileko  ebantwini abanengi bamaNdebele ngombana kukulapho kwalala khona abomkhulu babo, begodu kukulapho abanye babo badabuka khona. Yeke endaweni le kukulapho kulele khona amathambo wamalunga wemindeni yabo.

== Indlela yokuphila emaplasini ==
Emaplasini kusaphilwa ngendlela yakade ngombana akuna gezi, yeke lokha nafanele kuphekwe kuphekwa esitofini samahle ngokusebenzisa iinkuni ezitheziweko. Nangabe kuphekwa ngeempoto ezikulu engeze zanele esitofini samalahle, kubaswa phasi ngeenkuni. abantu abanzima nabafuna ukutjhajisa abomaliledinini babo baya emakhumaweni bona abatjhatjhisele zona.

=== Amanzi wemifula ===
Amanzi wemifula yakhona, kumamanzi akhambako, ahlenzekile ngombana akulahlelwa noma yini emilanjeni. Abantu bavasela khona iingubo zabo ukuze zihlanzeke kuhle. Kuthi sele bacedile ukuzihlanza iingubo zabo bakhambe bayozinekka emadradeni ahlukanisa iindlela yeenkoloyi namahlathi.

=== Iinthelo nefuyo ===
Kumateni amakhulu lapho kutjalwe khona iinthelo ezifana nama anyanisi, ife, amazambane, kanye nemirorho. Ifuyo ekhona emaplasini ziinkomo ekungezama khuwa begodu ezinye ngezabantu abanzima. imfaigi, izimvu, kanye neenkukhu. Abantu abanzima badla amacanda abekelwe ziinkukhu zemakhaya begodu ipuphu bayithola emakhuweni ahlala nabo emaplasini. Zikhoa neembana emaplasini ezifana ne nenungu, iimfarigi zommango

=== Izinga lobugebengu ===
emaplsini ubugebengu yinto engakavami. Lokhu kubonakala ngokuthi iminyango yakhona ayikhiyelwa.

=== Iinkolo ===
Emaplsini azikho iinkolo, kodwana zisedorobheni eliseduze nakhona. Abantwana ukuze bakghone ukuya esikolweni balandwa yi bhesi nge iri le-6 ekuseni. Bese godu kunesinye isikolo lapho abantwana bahlala khona esibizwa bonyana yi Makhazeni boarding school. 

</text>
      <sha1>8g43b4jnkzgpfi8vh0ojktw38fku539</sha1>
    </revision>
    <revision>
      <id>608</id>
      <parentid>607</parentid>
      <timestamp>2024-05-22T21:19:59Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>608</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2235" sha1="s9oze1bwt4e99cwmfnirz98en6nalew" xml:space="preserve">[[Isimumathi:Indlu yemaplasini.jpg|thumb|Izindlu zemaplasini]]
[[Isimumathi:Imizi imacalanga.jpg|thumb|Imizi imacalanga[[Isimumathi:Ifuyo yemaplasini.jpg|thumb]]Ifuyo]]
'''Emaplasini we[[Belfast]]''' kuyindawa ehle khulu ngesibanga sokuthi izele ngezinto zemvelo. Ithulile ngombana imizi imacalanga. Kuyindawa ebizwa ngokuthi semakhazeni ngombana kumakhaza. Nakusebusika manzi avuka alirhwaba  ngendlela kumakhaza ngakhona.Ehlobo imithi notjani  bubahlaza tlabha . Emaplasini kuyindawo eqakathekileko  ebantwini abanengi bamaNdebele ngombana kukulapho kwalala khona abomkhulu babo, begodu kukulapho abanye babo badabuka khona. Yeke endaweni le kukulapho kulele khona amathambo wamalunga wemindeni yabo.

== Indlela yokuphila emaplasini ==
Emaplasini kusaphilwa ngendlela yakade ngombana akuna gezi, yeke lokha nafanele kuphekwe kuphekwa esitofini samahle ngokusebenzisa iinkuni ezitheziweko. Nangabe kuphekwa ngeempoto ezikulu engeze zanele esitofini samalahle, kubaswa phasi ngeenkuni. abantu abanzima nabafuna ukutjhajisa abomaliledinini babo baya emakhumaweni bona abatjhatjhisele zona.

=== Amanzi wemifula ===
[[Amanzi]] wemifula yakhona, kumamanzi akhambako, ahlenzekile ngombana akulahlelwa noma yini emilanjeni. Abantu bavasela khona iingubo zabo ukuze zihlanzeke kuhle. Kuthi sele bacedile ukuzihlanza iingubo zabo bakhambe bayozinekka emadradeni ahlukanisa iindlela yeenkoloyi namahlathi.

=== Iinthelo nefuyo ===
Kumateni amakhulu lapho kutjalwe khona iinthelo ezifana nama anyanisi, ife, amazambane, kanye nemirorho. Ifuyo ekhona emaplasini ziinkomo ekungezama khuwa begodu ezinye ngezabantu abanzima. imfaigi, izimvu, kanye neenkukhu. Abantu abanzima badla amacanda abekelwe ziinkukhu zemakhaya begodu ipuphu bayithola emakhuweni ahlala nabo emaplasini. Zikhoa neembana emaplasini ezifana ne nenungu, iimfarigi zommango

=== Izinga lobugebengu ===
emaplsini ubugebengu yinto engakavami. Lokhu kubonakala ngokuthi iminyango yakhona ayikhiyelwa.

=== Iinkolo ===
Emaplasini azikho iinkolo, kodwana zisedorobheni eliseduze nakhona. Abantwana ukuze bakghone ukuya esikolweni balandwa yi bhesi nge iri le-6 ekuseni. Bese godu kunesinye isikolo lapho abantwana bahlala khona esibizwa bonyana yi Makhazeni boarding [[school]]. 

</text>
      <sha1>s9oze1bwt4e99cwmfnirz98en6nalew</sha1>
    </revision>
    <revision>
      <id>609</id>
      <parentid>608</parentid>
      <timestamp>2024-05-23T19:04:38Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>609</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2251" sha1="trrt16bu0hrxghzeunuag4y4xaev9wl" xml:space="preserve">[[Isimumathi:Indlu yemaplasini.jpg|thumb|Izindlu zemaplasini]]
[[Isimumathi:Imizi imacalanga.jpg|thumb|Imizi imacalanga[[Isimumathi:Ifuyo yemaplasini.jpg|thumb]]Ifuyo]]
'''Emaplasini we[[Belfast]]''' kuyindawa ehle khulu ngesibanga sokuthi izele ngezinto zemvelo. Ithulile ngombana imizi imacalanga. Kuyindawa ebizwa ngokuthi semakhazeni ngombana kumakhaza. Nakusebusika manzi avuka alirhwaba  ngendlela kumakhaza ngakhona.Ehlobo imithi notjani  bubahlaza tlabha . Emaplasini kuyindawo eqakathekileko  ebantwini abanengi bamaNdebele ngombana kukulapho kwalala khona abomkhulu babo, begodu kukulapho abanye babo badabuka khona. Yeke endaweni le kukulapho kulele khona amathambo wamalunga wemindeni yabo.

== Indlela yokuphila emaplasini ==
Emaplasini kusaphilwa ngendlela yakade ngombana akuna gezi, yeke lokha nafanele kuphekwe kuphekwa esitofini samahle ngokusebenzisa iinkuni ezitheziweko. Nangabe kuphekwa ngeempoto ezikulu engeze zanele esitofini samalahle, kubaswa phasi ngeenkuni. abantu abanzima nabafuna ukutjhajisa abomaliledinini babo baya emakhumaweni bona abatjhatjhisele zona.

=== Amanzi wemilambo yakhona ===
[[Amanzi]] wemilambo yakhona, kumamanzi akhambako, ahlenzekile ngombana akulahlelwa noma yini emilanjeni. Abantu bavasela khona iingubo zabo ukuze zihlanzeke kuhle. Kuthi sele bacedile ukuzihlanza iingubo zabo bakhambe bayozineka emadradeni ahlukanisa iindlela yeenkoloyi namahlathi.

=== Iinthelo nefuyo ===
Kumateni amakhulu lapho kutjalwe khona iinthelo ezifana nama anyanisi, ife, amazambane, kanye nemirorho. Ifuyo ekhona emaplasini ziinkomo ekungezama khuwa begodu ezinye ngezabantu abanzima. imfarigi, izimvu, kanye neenkukhu. Abantu abanzima badla amacanda abekelwe ziinkukhu zemakhaya begodu ipuphu bayithola emakhuweni ahlala nabo emaplasini. Zikhona neembandana emaplasini ezifana ne nenungu neemfarigi zommango.

=== Izinga lobugebengu ===
Emaplasini ubugebengu yinto engakavami. Lokhu kubonakala ngokuthi iminyango yakhona ayikhiyelwa.

=== Iinkolo ===
Emaplasini azikho iinkolo, kodwana zisedorobheni eliseduze nakhona. Abantwana ukuze bakghone ukuya esikolweni balandwa yi bhesi nge iri le-6 ekuseni. Bese godu kunesinye isikolo lapho abantwana bahlala khona esibizwa bonyana yi Makhazeni boarding [[school]]. 

</text>
      <sha1>trrt16bu0hrxghzeunuag4y4xaev9wl</sha1>
    </revision>
    <revision>
      <id>610</id>
      <parentid>609</parentid>
      <timestamp>2024-10-14T13:46:38Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>6 revisions imported</comment>
      <origin>609</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2251" sha1="trrt16bu0hrxghzeunuag4y4xaev9wl" xml:space="preserve">[[Isimumathi:Indlu yemaplasini.jpg|thumb|Izindlu zemaplasini]]
[[Isimumathi:Imizi imacalanga.jpg|thumb|Imizi imacalanga[[Isimumathi:Ifuyo yemaplasini.jpg|thumb]]Ifuyo]]
'''Emaplasini we[[Belfast]]''' kuyindawa ehle khulu ngesibanga sokuthi izele ngezinto zemvelo. Ithulile ngombana imizi imacalanga. Kuyindawa ebizwa ngokuthi semakhazeni ngombana kumakhaza. Nakusebusika manzi avuka alirhwaba  ngendlela kumakhaza ngakhona.Ehlobo imithi notjani  bubahlaza tlabha . Emaplasini kuyindawo eqakathekileko  ebantwini abanengi bamaNdebele ngombana kukulapho kwalala khona abomkhulu babo, begodu kukulapho abanye babo badabuka khona. Yeke endaweni le kukulapho kulele khona amathambo wamalunga wemindeni yabo.

== Indlela yokuphila emaplasini ==
Emaplasini kusaphilwa ngendlela yakade ngombana akuna gezi, yeke lokha nafanele kuphekwe kuphekwa esitofini samahle ngokusebenzisa iinkuni ezitheziweko. Nangabe kuphekwa ngeempoto ezikulu engeze zanele esitofini samalahle, kubaswa phasi ngeenkuni. abantu abanzima nabafuna ukutjhajisa abomaliledinini babo baya emakhumaweni bona abatjhatjhisele zona.

=== Amanzi wemilambo yakhona ===
[[Amanzi]] wemilambo yakhona, kumamanzi akhambako, ahlenzekile ngombana akulahlelwa noma yini emilanjeni. Abantu bavasela khona iingubo zabo ukuze zihlanzeke kuhle. Kuthi sele bacedile ukuzihlanza iingubo zabo bakhambe bayozineka emadradeni ahlukanisa iindlela yeenkoloyi namahlathi.

=== Iinthelo nefuyo ===
Kumateni amakhulu lapho kutjalwe khona iinthelo ezifana nama anyanisi, ife, amazambane, kanye nemirorho. Ifuyo ekhona emaplasini ziinkomo ekungezama khuwa begodu ezinye ngezabantu abanzima. imfarigi, izimvu, kanye neenkukhu. Abantu abanzima badla amacanda abekelwe ziinkukhu zemakhaya begodu ipuphu bayithola emakhuweni ahlala nabo emaplasini. Zikhona neembandana emaplasini ezifana ne nenungu neemfarigi zommango.

=== Izinga lobugebengu ===
Emaplasini ubugebengu yinto engakavami. Lokhu kubonakala ngokuthi iminyango yakhona ayikhiyelwa.

=== Iinkolo ===
Emaplasini azikho iinkolo, kodwana zisedorobheni eliseduze nakhona. Abantwana ukuze bakghone ukuya esikolweni balandwa yi bhesi nge iri le-6 ekuseni. Bese godu kunesinye isikolo lapho abantwana bahlala khona esibizwa bonyana yi Makhazeni boarding [[school]]. 

</text>
      <sha1>trrt16bu0hrxghzeunuag4y4xaev9wl</sha1>
    </revision>
  </page>
  <page>
    <title>Erholweni</title>
    <ns>0</ns>
    <id>129</id>
    <revision>
      <id>611</id>
      <timestamp>2024-06-22T18:25:01Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Erholweni''' yindawo yeRosenekaal esemangweni eneetaba nemibundu. Kunamahlathi amihlobohlobo nemithi. Iintaba namagoqo wamatje amakhulu ahlezi elinye phezu kwelinye  ngokwemvelo yawo. Indawo le ingetjingalanga yeGroblersdaal. amaNdebele afika anzinza endaweni le ngonyaka we-1839. Kwaba yindawo yabo esetjenziswa njengesiphephelo sesitjhaba begodu izokwazi uksekela amaqhinga wokulwa izipi.  &quot;</comment>
      <origin>611</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="395" sha1="43thfu9jqt8miu0cdp4ky7sgiqkvgi2" xml:space="preserve">'''Erholweni''' yindawo yeRosenekaal esemangweni eneetaba nemibundu. Kunamahlathi amihlobohlobo nemithi. Iintaba namagoqo wamatje amakhulu ahlezi elinye phezu kwelinye  ngokwemvelo yawo. Indawo le ingetjingalanga yeGroblersdaal. amaNdebele afika anzinza endaweni le ngonyaka we-1839. Kwaba yindawo yabo esetjenziswa njengesiphephelo sesitjhaba begodu izokwazi uksekela amaqhinga wokulwa izipi.

</text>
      <sha1>43thfu9jqt8miu0cdp4ky7sgiqkvgi2</sha1>
    </revision>
    <revision>
      <id>612</id>
      <parentid>611</parentid>
      <timestamp>2024-06-22T18:50:16Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>612</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1665" sha1="8pw5hd06fab9ylfku9xvm5w45cgtkut" xml:space="preserve">'''Erholweni''' yindawo yeRosenekaal esemangweni eneetaba nemibundu. Kunamahlathi amihlobohlobo nemithi. Iintaba namagoqo wamatje amakhulu ahlezi elinye phezu kwelinye  ngokwemvelo yawo. Indawo le ingetjingalanga yeGroblersdaal. amaNdebele afika anzinza endaweni le ngonyaka we-1839. Kwaba yindawo yabo esetjenziswa njengesiphephelo sesitjhaba begodu izokwazi uksekela amaqhinga wokulwa izipi.

ngemva kwepi yamaNgisi namaBhunu ngonyaka we-1882 amakhuwa nakasaphikisana nengwenyama umabhoko ngokusikwa kwenarhakhe. Kwenzeka isiga kibomakhelwan ekubaPedi bakomarotha, kwabulawa  ingwenyama uSikhukhune embangweni wobukhosi bkwa sikwadi  owayehlanganyele ekuphatheni kwamkhuwa intransvaal. Ingonyama uMampuru wesibili wayobhaqiswa kwaNoMtjharhelo. Ipihlangana noNyabela namakhuwa yathatha inyanga ezibunane ukuthoma ngoSinyikhaba ka 1882 bekwaba ngu Velabahlinze  ka1883.

amakhuwa asebenzisa iqhinga lokuvlal amanzi nokutjhisa amasimu ukubulalisa amaNdebelel ngendlala ukuthumba ipi eyadlula namabutho  amanengi  wakwaNzunza. Umphumela wepi kwaba  kubotjhwa kwengwenyama uNyabela no Mampuru bayokuvalelwa ejele ePitori. Ingwenyama uMampuru yabulawa ngokukhungwa. ISigwebo sikaNyabela  senziwa saba ngesokufela ejele kodwana waphuma ngaphambi kwepi yesibili yamabhuru namaNgisi ngonyaka we- 1898.

== Ukuqakatheka kwendawo le esitjhabeni samaNdebele ==
Indawo ye Rosenekaal yaba ngaphasi kwamagugu kusekela ngonyaka we-1937. Yathoma ukuhlonitjhwa  njengendawo yamagugu ngonyaka we-1968. Kwabunjwa isithombe sesengwenyama uNyabela konoMtjharhela. Le kuyindawo yamaNdebele kaNzunza. AmaNdebele aya erholweni kanye ngonyaka ukugidinga imvelaphi nendabuko yama ndebele..
</text>
      <sha1>8pw5hd06fab9ylfku9xvm5w45cgtkut</sha1>
    </revision>
    <revision>
      <id>613</id>
      <parentid>612</parentid>
      <timestamp>2024-06-22T18:52:22Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>613</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1676" sha1="qudhgpgcb02gunwyad0e076yf256y80" xml:space="preserve">'''Erholweni''' yindawo ye[[Rosenekaal]] esemangweni enentaba nemibundu. Kunamahlathi amihlobohlobo nemithi. Iintaba namagoqo wamatje amakhulu ahlezi elinye phezu kwelinye  ngokwemvelo yawo. Indawo le ingetjingalanga yeGroblersdaal. amaNdebele afika anzinza endaweni le ngonyaka we-1839. Kwaba yindawo yabo esetjenziswa njengesiphephelo sesitjhaba begodu izokwazi uksekela amaqhinga wokulwa izipi.

ngemva kwepi yamaNgisi namaBhunu ngonyaka we-1882 amakhuwa nakasaphikisana nengwenyama umabhoko ngokusikwa kwenarhakhe. Kwenzeka isiga kibomakhelwan ekubaPedi bakomarotha, kwabulawa  ingwenyama uSikhukhune embangweni wobukhosi bkwa sikwadi  owayehlanganyele ekuphatheni kwamkhuwa intransvaal. Ingonyama [[uMampuru]] wesibili wayobhaqiswa kwaNoMtjharhelo. Ipihlangana noNyabela namakhuwa yathatha inyanga ezibunane ukuthoma ngoSinyikhaba ka 1882 bekwaba ngu Velabahlinze  ka1883.

amakhuwa asebenzisa iqhinga lokuvala amanzi nokutjhisa amasimu ukubulalisa [[amaNdebele]] ngendlala ukuthumba ipi eyadlula namabutho  amanengi  wakwaNzunza. Umphumela wepi kwaba  kubotjhwa kwengwenyama uNyabela no Mampuru bayokuvalelwa ejele ePitori. Ingwenyama uMampuru yabulawa ngokukhungwa. ISigwebo sikaNyabela  senziwa saba ngesokufela ejele kodwana waphuma ngaphambi kwepi yesibili yamabhuru namaNgisi ngonyaka we- 1898.

== Ukuqakatheka kwendawo le esitjhabeni samaNdebele ==
Indawo ye Rosenekaal yaba ngaphasi kwamagugu kusekela ngonyaka we-1937. Yathoma ukuhlonitjhwa  njengendawo yamagugu ngonyaka we-1968. Kwabunjwa isithombe sesengwenyama uNyabela konoMtjharhela. Le kuyindawo yamaNdebele kaNzunza. AmaNdebele aya erholweni kanye ngonyaka ukugidinga imvelaphi nendabuko yama ndebele..
</text>
      <sha1>qudhgpgcb02gunwyad0e076yf256y80</sha1>
    </revision>
    <revision>
      <id>614</id>
      <parentid>613</parentid>
      <timestamp>2024-06-30T11:13:07Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>614</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1733" sha1="g91ppg0kb4412ew9rjyxs3snji3jeic" xml:space="preserve">'''Erholweni''' yindawo ye[[Rosenekaal]] esemangweni enentaba nemibundu. Kunamahlathi amihlobohlobo nemithi. Iintaba namagoqo wamatje amakhulu ahlezi elinye phezu kwelinye  ngokwemvelo yawo. Indawo le ingetjingalanga yeGroblersdaal. Indawo le yaziwa nge [[mapoch caves]] ngelimi lesiNgisi. amaNdebele afika anzinza endaweni le ngonyaka we-1839. Kwaba yindawo yabo esetjenziswa njengesiphephelo sesitjhaba begodu izokwazi uksekela amaqhinga wokulwa izipi.

ngemva kwepi yamaNgisi namaBhunu ngonyaka we-1882 amakhuwa nakasaphikisana nengwenyama umabhoko ngokusikwa kwenarhakhe. Kwenzeka isiga kibomakhelwan ekubaPedi bakomarotha, kwabulawa  ingwenyama uSikhukhune embangweni wobukhosi bkwa sikwadi  owayehlanganyele ekuphatheni kwamkhuwa intransvaal. Ingonyama [[uMampuru]] wesibili wayobhaqiswa kwaNoMtjharhelo. Ipihlangana noNyabela namakhuwa yathatha inyanga ezibunane ukuthoma ngoSinyikhaba ka 1882 bekwaba ngu Velabahlinze  ka1883.

amakhuwa asebenzisa iqhinga lokuvala amanzi nokutjhisa amasimu ukubulalisa [[amaNdebele]] ngendlala ukuthumba ipi eyadlula namabutho  amanengi  wakwaNzunza. Umphumela wepi kwaba  kubotjhwa kwengwenyama uNyabela no Mampuru bayokuvalelwa ejele ePitori. Ingwenyama uMampuru yabulawa ngokukhungwa. ISigwebo sikaNyabela  senziwa saba ngesokufela ejele kodwana waphuma ngaphambi kwepi yesibili yamabhuru namaNgisi ngonyaka we- 1898.

== Ukuqakatheka kwendawo le esitjhabeni samaNdebele ==
Indawo ye Rosenekaal yaba ngaphasi kwamagugu kusekela ngonyaka we-1937. Yathoma ukuhlonitjhwa  njengendawo yamagugu ngonyaka we-1968. Kwabunjwa isithombe sesengwenyama uNyabela konoMtjharhela. Le kuyindawo yamaNdebele kaNzunza. AmaNdebele aya erholweni kanye ngonyaka ukugidinga imvelaphi nendabuko yama ndebele..
</text>
      <sha1>g91ppg0kb4412ew9rjyxs3snji3jeic</sha1>
    </revision>
    <revision>
      <id>615</id>
      <parentid>614</parentid>
      <timestamp>2024-06-30T17:20:49Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>615</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1825" sha1="b0fkltz88k2h1yyiter71g1q3g3lcr9" xml:space="preserve">[[Isimumathi:King Nyabela of the Ndebele Tribe South Africa 1893.jpg|thumb|ikosi uNyabela]]
'''Erholweni''' yindawo ye[[Rosenekaal]] esemangweni enentaba nemibundu. Kunamahlathi amihlobohlobo nemithi. Iintaba namagoqo wamatje amakhulu ahlezi elinye phezu kwelinye  ngokwemvelo yawo. Indawo le ingetjingalanga yeGroblersdaal. Indawo le yaziwa nge [[mapoch caves]] ngelimi lesiNgisi. amaNdebele afika anzinza endaweni le ngonyaka we-1839. Kwaba yindawo yabo esetjenziswa njengesiphephelo sesitjhaba begodu izokwazi uksekela amaqhinga wokulwa izipi.

ngemva kwepi yamaNgisi namaBhunu ngonyaka we-1882 amakhuwa nakasaphikisana nengwenyama umabhoko ngokusikwa kwenarhakhe. Kwenzeka isiga kibomakhelwan ekubaPedi bakomarotha, kwabulawa  ingwenyama uSikhukhune embangweni wobukhosi bkwa sikwadi  owayehlanganyele ekuphatheni kwamkhuwa intransvaal. Ingonyama [[uMampuru]] wesibili wayobhaqiswa kwaNoMtjharhelo. Ipihlangana noNyabela namakhuwa yathatha inyanga ezibunane ukuthoma ngoSinyikhaba ka 1882 bekwaba ngu Velabahlinze  ka1883.

amakhuwa asebenzisa iqhinga lokuvala amanzi nokutjhisa amasimu ukubulalisa [[amaNdebele]] ngendlala ukuthumba ipi eyadlula namabutho  amanengi  wakwaNzunza. Umphumela wepi kwaba  kubotjhwa kwengwenyama uNyabela no Mampuru bayokuvalelwa ejele ePitori. Ingwenyama uMampuru yabulawa ngokukhungwa. ISigwebo sikaNyabela  senziwa saba ngesokufela ejele kodwana waphuma ngaphambi kwepi yesibili yamabhuru namaNgisi ngonyaka we- 1898.

== Ukuqakatheka kwendawo le esitjhabeni samaNdebele ==
Indawo ye Rosenekaal yaba ngaphasi kwamagugu kusekela ngonyaka we-1937. Yathoma ukuhlonitjhwa  njengendawo yamagugu ngonyaka we-1968. Kwabunjwa isithombe sesengwenyama uNyabela konoMtjharhela. Le kuyindawo yamaNdebele kaNzunza. AmaNdebele aya erholweni kanye ngonyaka ukugidinga imvelaphi nendabuko yama ndebele..
</text>
      <sha1>b0fkltz88k2h1yyiter71g1q3g3lcr9</sha1>
    </revision>
    <revision>
      <id>616</id>
      <parentid>615</parentid>
      <timestamp>2024-07-10T10:18:12Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>616</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2018" sha1="aqfypiqrkqowfscxb2xbj35z2wl904a" xml:space="preserve">[[Isimumathi:King Nyabela of the Ndebele Tribe South Africa 1893.jpg|thumb|ikosi uNyabela]]
&lt;ref&gt;Kusel, U. (2000). Mapoch Ndebele Village: a heritage partnership: mobilising partnerships for heritage and events. ''South African Museums Association Bulletin'', ''25''(1), 35-37.&lt;/ref&gt;'''Erholweni''' yindawo ye-[[Roossenekal]] esemangweni enentaba nemibundu. Kunamahlathi amihlobohlobo nemithi. Iintaba namagoqo wamatje amakhulu ahlezi elinye phezu kwelinye  ngokwemvelo yawo. Indawo le ingetjingalanga yeGroblersdaal. Indawo le yaziwa nge [[mapoch caves]] ngelimi lesiNgisi. amaNdebele afika anzinza endaweni le ngonyaka we-1839. Kwaba yindawo yabo esetjenziswa njengesiphephelo sesitjhaba begodu izokwazi uksekela amaqhinga wokulwa izipi.

ngemva kwepi yamaNgisi namaBhunu ngonyaka we-1882 amakhuwa nakasaphikisana nengwenyama umabhoko ngokusikwa kwenarhakhe. Kwenzeka isiga kibomakhelwan ekubaPedi bakomarotha, kwabulawa  ingwenyama uSikhukhune embangweni wobukhosi bkwa sikwadi  owayehlanganyele ekuphatheni kwamkhuwa intransvaal. Ingonyama [[uMampuru]] wesibili wayobhaqiswa kwaNoMtjharhelo. Ipihlangana noNyabela namakhuwa yathatha inyanga ezibunane ukuthoma ngoSinyikhaba ka 1882 bekwaba ngu Velabahlinze  ka1883.

amakhuwa asebenzisa iqhinga lokuvala amanzi nokutjhisa amasimu ukubulalisa [[amaNdebele]] ngendlala ukuthumba ipi eyadlula namabutho  amanengi  wakwaNzunza. Umphumela wepi kwaba  kubotjhwa kwengwenyama uNyabela no Mampuru bayokuvalelwa ejele ePitori. Ingwenyama uMampuru yabulawa ngokukhungwa. ISigwebo sikaNyabela  senziwa saba ngesokufela ejele kodwana waphuma ngaphambi kwepi yesibili yamabhuru namaNgisi ngonyaka we- 1898.

== Ukuqakatheka kwendawo le esitjhabeni samaNdebele ==
Indawo ye Rosenekaal yaba ngaphasi kwamagugu kusekela ngonyaka we-1937. Yathoma ukuhlonitjhwa  njengendawo yamagugu ngonyaka we-1968. Kwabunjwa isithombe sesengwenyama uNyabela konoMtjharhela. Le kuyindawo yamaNdebele kaNzunza. AmaNdebele aya erholweni kanye ngonyaka ukugidinga imvelaphi nendabuko yama ndebele..
</text>
      <sha1>aqfypiqrkqowfscxb2xbj35z2wl904a</sha1>
    </revision>
    <revision>
      <id>617</id>
      <parentid>616</parentid>
      <timestamp>2024-10-14T13:46:38Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>6 revisions imported</comment>
      <origin>616</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2018" sha1="aqfypiqrkqowfscxb2xbj35z2wl904a" xml:space="preserve">[[Isimumathi:King Nyabela of the Ndebele Tribe South Africa 1893.jpg|thumb|ikosi uNyabela]]
&lt;ref&gt;Kusel, U. (2000). Mapoch Ndebele Village: a heritage partnership: mobilising partnerships for heritage and events. ''South African Museums Association Bulletin'', ''25''(1), 35-37.&lt;/ref&gt;'''Erholweni''' yindawo ye-[[Roossenekal]] esemangweni enentaba nemibundu. Kunamahlathi amihlobohlobo nemithi. Iintaba namagoqo wamatje amakhulu ahlezi elinye phezu kwelinye  ngokwemvelo yawo. Indawo le ingetjingalanga yeGroblersdaal. Indawo le yaziwa nge [[mapoch caves]] ngelimi lesiNgisi. amaNdebele afika anzinza endaweni le ngonyaka we-1839. Kwaba yindawo yabo esetjenziswa njengesiphephelo sesitjhaba begodu izokwazi uksekela amaqhinga wokulwa izipi.

ngemva kwepi yamaNgisi namaBhunu ngonyaka we-1882 amakhuwa nakasaphikisana nengwenyama umabhoko ngokusikwa kwenarhakhe. Kwenzeka isiga kibomakhelwan ekubaPedi bakomarotha, kwabulawa  ingwenyama uSikhukhune embangweni wobukhosi bkwa sikwadi  owayehlanganyele ekuphatheni kwamkhuwa intransvaal. Ingonyama [[uMampuru]] wesibili wayobhaqiswa kwaNoMtjharhelo. Ipihlangana noNyabela namakhuwa yathatha inyanga ezibunane ukuthoma ngoSinyikhaba ka 1882 bekwaba ngu Velabahlinze  ka1883.

amakhuwa asebenzisa iqhinga lokuvala amanzi nokutjhisa amasimu ukubulalisa [[amaNdebele]] ngendlala ukuthumba ipi eyadlula namabutho  amanengi  wakwaNzunza. Umphumela wepi kwaba  kubotjhwa kwengwenyama uNyabela no Mampuru bayokuvalelwa ejele ePitori. Ingwenyama uMampuru yabulawa ngokukhungwa. ISigwebo sikaNyabela  senziwa saba ngesokufela ejele kodwana waphuma ngaphambi kwepi yesibili yamabhuru namaNgisi ngonyaka we- 1898.

== Ukuqakatheka kwendawo le esitjhabeni samaNdebele ==
Indawo ye Rosenekaal yaba ngaphasi kwamagugu kusekela ngonyaka we-1937. Yathoma ukuhlonitjhwa  njengendawo yamagugu ngonyaka we-1968. Kwabunjwa isithombe sesengwenyama uNyabela konoMtjharhela. Le kuyindawo yamaNdebele kaNzunza. AmaNdebele aya erholweni kanye ngonyaka ukugidinga imvelaphi nendabuko yama ndebele..
</text>
      <sha1>aqfypiqrkqowfscxb2xbj35z2wl904a</sha1>
    </revision>
    <revision>
      <id>2226</id>
      <parentid>617</parentid>
      <timestamp>2024-11-29T14:20:37Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>U. Kusel</comment>
      <origin>2226</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2016" sha1="iyrcs5hq6obbdasnvetgy2gtxg801a9" xml:space="preserve">[[Isimumathi:King Nyabela of the Ndebele Tribe South Africa 1893.jpg|thumb|ikosi uNyabela]]
'''Erholweni''' yindawo ye-[[Roossenekal]] esemangweni enentaba nemibundu. Kunamahlathi amihlobohlobo nemithi. Iintaba namagoqo wamatje amakhulu ahlezi elinye phezu kwelinye  ngokwemvelo yawo. Indawo le ingetjingalanga yeGroblersdaal. Indawo le yaziwa nge [[mapoch caves]] ngelimi lesiNgisi. amaNdebele afika anzinza endaweni le ngonyaka we-1839. Kwaba yindawo yabo esetjenziswa njengesiphephelo sesitjhaba begodu izokwazi uksekela amaqhinga wokulwa izipi.

ngemva kwepi yamaNgisi namaBhunu ngonyaka we-1882 amakhuwa nakasaphikisana nengwenyama umabhoko ngokusikwa kwenarhakhe. Kwenzeka isiga kibomakhelwan ekubaPedi bakomarotha, kwabulawa  ingwenyama uSikhukhune embangweni wobukhosi bkwa sikwadi  owayehlanganyele ekuphatheni kwamkhuwa intransvaal. Ingonyama [[uMampuru]] wesibili wayobhaqiswa kwaNoMtjharhelo. Ipihlangana noNyabela namakhuwa yathatha inyanga ezibunane ukuthoma ngoSinyikhaba ka 1882 bekwaba ngu Velabahlinze  ka1883.

amakhuwa asebenzisa iqhinga lokuvala amanzi nokutjhisa amasimu ukubulalisa [[amaNdebele]] ngendlala ukuthumba ipi eyadlula namabutho  amanengi  wakwaNzunza. Umphumela wepi kwaba  kubotjhwa kwengwenyama uNyabela no Mampuru bayokuvalelwa ejele ePitori. Ingwenyama uMampuru yabulawa ngokukhungwa. ISigwebo sikaNyabela  senziwa saba ngesokufela ejele kodwana waphuma ngaphambi kwepi yesibili yamabhuru namaNgisi ngonyaka we- 1898.

== Ukuqakatheka kwendawo le esitjhabeni samaNdebele ==
Indawo ye Rosenekaal yaba ngaphasi kwamagugu kusekela ngonyaka we-1937. Yathoma ukuhlonitjhwa  njengendawo yamagugu ngonyaka we-1968. Kwabunjwa isithombe sesengwenyama uNyabela konoMtjharhela. Le kuyindawo yamaNdebele kaNzunza. AmaNdebele aya erholweni kanye ngonyaka ukugidinga imvelaphi nendabuko yama ndebele.&lt;ref&gt;Kusel, U. (2000). Mapoch Ndebele Village: a heritage partnership: mobilising partnerships for heritage and events. ''South African Museums Association Bulletin'', ''25''(1), 35-37.&lt;/ref&gt;</text>
      <sha1>iyrcs5hq6obbdasnvetgy2gtxg801a9</sha1>
    </revision>
    <revision>
      <id>2227</id>
      <parentid>2226</parentid>
      <timestamp>2024-11-29T14:22:24Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>+ Iinkomba</comment>
      <origin>2227</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2044" sha1="nei6qhspq9g1u1ic6qvbb1o11r0h7hp" xml:space="preserve">[[Isimumathi:King Nyabela of the Ndebele Tribe South Africa 1893.jpg|thumb|ikosi uNyabela]]
'''Erholweni''' yindawo ye-[[Roossenekal]] esemangweni enentaba nemibundu. Kunamahlathi amihlobohlobo nemithi. Iintaba namagoqo wamatje amakhulu ahlezi elinye phezu kwelinye  ngokwemvelo yawo. Indawo le ingetjingalanga yeGroblersdaal. Indawo le yaziwa nge [[mapoch caves]] ngelimi lesiNgisi. amaNdebele afika anzinza endaweni le ngonyaka we-1839. Kwaba yindawo yabo esetjenziswa njengesiphephelo sesitjhaba begodu izokwazi uksekela amaqhinga wokulwa izipi.

ngemva kwepi yamaNgisi namaBhunu ngonyaka we-1882 amakhuwa nakasaphikisana nengwenyama umabhoko ngokusikwa kwenarhakhe. Kwenzeka isiga kibomakhelwan ekubaPedi bakomarotha, kwabulawa  ingwenyama uSikhukhune embangweni wobukhosi bkwa sikwadi  owayehlanganyele ekuphatheni kwamkhuwa intransvaal. Ingonyama [[uMampuru]] wesibili wayobhaqiswa kwaNoMtjharhelo. Ipihlangana noNyabela namakhuwa yathatha inyanga ezibunane ukuthoma ngoSinyikhaba ka 1882 bekwaba ngu Velabahlinze  ka1883.

amakhuwa asebenzisa iqhinga lokuvala amanzi nokutjhisa amasimu ukubulalisa [[amaNdebele]] ngendlala ukuthumba ipi eyadlula namabutho  amanengi  wakwaNzunza. Umphumela wepi kwaba  kubotjhwa kwengwenyama uNyabela no Mampuru bayokuvalelwa ejele ePitori. Ingwenyama uMampuru yabulawa ngokukhungwa. ISigwebo sikaNyabela  senziwa saba ngesokufela ejele kodwana waphuma ngaphambi kwepi yesibili yamabhuru namaNgisi ngonyaka we- 1898.

== Ukuqakatheka kwendawo le esitjhabeni samaNdebele ==
Indawo ye Rosenekaal yaba ngaphasi kwamagugu kusekela ngonyaka we-1937. Yathoma ukuhlonitjhwa  njengendawo yamagugu ngonyaka we-1968. Kwabunjwa isithombe sesengwenyama uNyabela konoMtjharhela. Le kuyindawo yamaNdebele kaNzunza. AmaNdebele aya erholweni kanye ngonyaka ukugidinga imvelaphi nendabuko yama ndebele.&lt;ref&gt;Kusel, U. (2000). Mapoch Ndebele Village: a heritage partnership: mobilising partnerships for heritage and events. ''South African Museums Association Bulletin'', ''25''(1), 35-37.&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}</text>
      <sha1>nei6qhspq9g1u1ic6qvbb1o11r0h7hp</sha1>
    </revision>
    <revision>
      <id>3427</id>
      <parentid>2227</parentid>
      <timestamp>2025-07-12T14:20:01Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3427</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2046" sha1="bxf1np0olbvo4tu14qc8moa0ipexzkw" xml:space="preserve">[[Isimumathi:King Nyabela of the Ndebele Tribe South Africa 1893.jpg|thumb|ikosi uNyabela]]
'''Erholweni''' yindawo ye-[[Roossenekal]] esemangweni enentaba nemibundu. Kunamahlathi amihlobohlobo nemithi. Iintaba namagoqo wamatje amakhulu ahlezi elinye phezu kwelinye  ngokwemvelo yawo. Indawo le ingetjingalanga yeGroblersdaal. Indawo le yaziwa nge [[mapoch caves]] ngelimi lesiNgisi. amaNdebele afika anzinza endaweni le ngonyaka we-1839. Kwaba yindawo yabo esetjenziswa njengesiphephelo sesitjhaba begodu izokwazi uksekela amaqhinga wokulwa izipi.

ngemva kwepi yamaNgisi namaBhunu ngonyaka we-1882 amakhuwa nakasaphikisana nengwenyama umabhoko ngokusikwa kwenarhakhe. Kwenzeka isiga kibomakhelwan ekubaPedi bakomarotha, kwabulawa  ingwenyama uSikhukhune embangweni wobukhosi bkwa sikwadi  owayehlanganyele ekuphatheni kwamkhuwa intransvaal. Ingonyama [[uMampuru]] wesibili wayobhaqiswa kwaNoMtjharhelo. Ipihlangana noNyabela namakhuwa yathatha inyanga ezibunane ukuthoma ngoSinyikhaba ka 1882 bekwaba ngu Velabahlinze  ka1883.

amakhuwa asebenzisa iqhinga lokuvala amanzi nokutjhisa amasimu ukubulalisa [[amaNdebele]] ngendlala ukuthumba ipi eyadlula namabutho  amanengi  wakwaNzunza. Umphumela wepi kwaba  kubotjhwa kwengwenyama uNyabela no Mampuru bayokuvalelwa ejele ePitori. Ingwenyama uMampuru yabulawa ngokukhungwa. ISigwebo sikaNyabela  senziwa saba ngesokufela ejele kodwana waphuma ngaphambi kwepi yesibili yamabhuru namaNgisi ngonyaka we- 1898.

=== Ukuqakatheka kwendawo le esitjhabeni samaNdebele ===
Indawo ye Rosenekaal yaba ngaphasi kwamagugu kusekela ngonyaka we-1937. Yathoma ukuhlonitjhwa  njengendawo yamagugu ngonyaka we-1968. Kwabunjwa isithombe sesengwenyama uNyabela konoMtjharhela. Le kuyindawo yamaNdebele kaNzunza. AmaNdebele aya erholweni kanye ngonyaka ukugidinga imvelaphi nendabuko yama ndebele.&lt;ref&gt;Kusel, U. (2000). Mapoch Ndebele Village: a heritage partnership: mobilising partnerships for heritage and events. ''South African Museums Association Bulletin'', ''25''(1), 35-37.&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}</text>
      <sha1>bxf1np0olbvo4tu14qc8moa0ipexzkw</sha1>
    </revision>
  </page>
  <page>
    <title>Esther Mahlangu</title>
    <ns>0</ns>
    <id>130</id>
    <revision>
      <id>618</id>
      <timestamp>2022-09-14T08:36:10Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Esther Mahlangu''' (born 11 November 1935) ngusowula Afrika othanda ukugwala ukudweba.   &quot;</comment>
      <origin>618</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="92" sha1="inozov9pe9wwrztgoazsa5jhanhqi4z" xml:space="preserve">'''Esther Mahlangu''' (born 11 November 1935) ngusowula Afrika othanda ukugwala ukudweba. 

</text>
      <sha1>inozov9pe9wwrztgoazsa5jhanhqi4z</sha1>
    </revision>
    <revision>
      <id>619</id>
      <parentid>618</parentid>
      <timestamp>2024-03-08T10:04:47Z</timestamp>
      <contributor>
        <ip>196.21.175.1</ip>
      </contributor>
      <comment>added a few information</comment>
      <origin>619</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="120" sha1="7suhifznei0ab54pcdp7r5mi98j0nvi" xml:space="preserve">'''Esther Mahlangu''' (born 11 November 1935) ngusewula Afrika othanda ukugwala namkha ukudweba imigwalo yesiNdebele. 

</text>
      <sha1>7suhifznei0ab54pcdp7r5mi98j0nvi</sha1>
    </revision>
    <revision>
      <id>620</id>
      <parentid>619</parentid>
      <timestamp>2024-03-08T10:10:27Z</timestamp>
      <contributor>
        <ip>41.121.32.248</ip>
      </contributor>
      <comment>Added information</comment>
      <origin>620</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="178" sha1="89dpln01472k4168fhg1wrrm4s29ujg" xml:space="preserve">'''Esther Mahlangu''' (born 11 November 1935) ngusewula Afrika (Mpumalanga) nge Mthambothini endaweni ebizwa nge Kosini othanda ukugwala namkha ukudweba imigwalo yesiNdebele.  

</text>
      <sha1>89dpln01472k4168fhg1wrrm4s29ujg</sha1>
    </revision>
    <revision>
      <id>621</id>
      <parentid>620</parentid>
      <timestamp>2024-03-08T10:13:21Z</timestamp>
      <contributor>
        <username>incubator&gt;Siphesihle Chantel46</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>I added some information</comment>
      <origin>621</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="268" sha1="28nhwb0ni4kkfws2tolu6hhhy5393yb" xml:space="preserve">'''Esther Mahlangu''' (born 11 November 1935) ngusewula Afrika (Mpumalanga) nge Mthambothini endaweni ebizwa nge Kosini othanda ukugwala namkha ukudweba imigwalo yesiNdebele. Uthome ukugwala aneminyaka elitjhumi. Ukugwala lokhu ufundiswe ngunina kanye nogogo wakhe  

</text>
      <sha1>28nhwb0ni4kkfws2tolu6hhhy5393yb</sha1>
    </revision>
    <revision>
      <id>622</id>
      <parentid>621</parentid>
      <timestamp>2024-03-08T10:19:12Z</timestamp>
      <contributor>
        <username>incubator&gt;Ntuli Evelyn</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>i added a correct year in isiNdebele and the dates in isiNdebele also added who taught her the skill of writing.</comment>
      <origin>622</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="471" sha1="lubl5snqdnbseuc1f9cg3hz96490h9e" xml:space="preserve">'''Esther Mahlangu''' (born 11 November 1935) ngusewula Afrika (Mpumalanga) nge Mthambothini endaweni ebizwa nge Kosini othanda ukugwala namkha ukudweba imigwalo yesiNdebele. Uthome ukugwala aneminyaka elitjhumi. Ukugwala lokhu ufundiswe ngunina kanye nogogo wakhe  

UDorhodere Esther Mahlangu wabelethwa mhla amalanga amatjhumi nanye enyangeni kaSinyikhaba ngomnyaka we 1935. UDorhodere Esther wathoma ukugwala aneminyaka elitjhumi kwaphela , afundiswa ngugogwakhe.  

</text>
      <sha1>lubl5snqdnbseuc1f9cg3hz96490h9e</sha1>
    </revision>
    <revision>
      <id>623</id>
      <parentid>622</parentid>
      <timestamp>2024-03-08T10:22:49Z</timestamp>
      <contributor>
        <username>incubator&gt;Napangela</username>
        <id>0</id>
      </contributor>
      <comment>new article</comment>
      <origin>623</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="506" sha1="8i4752sosborzcaczjbdwpewkjo8pf9" xml:space="preserve">'''Esther Mahlangu''' wabelethwa mhlana amalanga ali-11 kuSinyikhaba ngomnyaka we-1935. Wabelethelwa endaweni yeMthambothini, ebizwa ngeKosini. U-Esther Mahlangu uthanda ukugwala namkha ukudweba imigwalo yesiNdebele. Uthome ukugwala nakaneminyaka elitjhumi. Wafundiswa ngunina nogogwakhe ukugwala.    

UDorhodere Esther Mahlangu wabelethwa mhla amalanga amatjhumi nanye enyangeni kaSinyikhaba ngomnyaka we 1935. UDorhodere Esther wathoma ukugwala aneminyaka elitjhumi kwaphela , afundiswa ngugogwakhe.  

</text>
      <sha1>8i4752sosborzcaczjbdwpewkjo8pf9</sha1>
    </revision>
    <revision>
      <id>624</id>
      <parentid>623</parentid>
      <timestamp>2024-03-08T10:27:32Z</timestamp>
      <contributor>
        <username>incubator&gt;Napangela</username>
        <id>0</id>
      </contributor>
      <comment>hyphen</comment>
      <origin>624</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="506" sha1="g6mtsxsr3558f1wwxh0g38925x5xupf" xml:space="preserve">'''Esther Mahlangu''' wabelethwa mhlana amalanga ali-11 kuSinyikhaba ngomnyaka we-1935. Wabelethelwa endaweni yeMthambothini, ebizwa ngeKosini. U-Esther Mahlangu uthanda ukugwala namkha ukudweba imigwalo yesiNdebele. Uthome ukugwala nakaneminyaka elitjhumi. Wafundiswa ngunina nogogwakhe ukugwala.    

UDorhodere Esther Mahlangu wabelethwa mhla amalanga amatjhumi nanye enyangeni kaSinyikhaba ngomnyaka we-1935. UDorhodere Esther wathoma ukugwala aneminyaka elitjhumi kwaphela , afundiswa ngugogwakhe.  

</text>
      <sha1>g6mtsxsr3558f1wwxh0g38925x5xupf</sha1>
    </revision>
    <revision>
      <id>625</id>
      <parentid>624</parentid>
      <timestamp>2024-03-08T10:30:58Z</timestamp>
      <contributor>
        <username>incubator&gt;Simphiwe22</username>
        <id>0</id>
      </contributor>
      <comment>Added content</comment>
      <origin>625</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="583" sha1="qhkr53emikyup90vp6wcz6mcjwhf2st" xml:space="preserve">'''Esther Mahlangu''' wabelethwa mhlana amalanga ali-11 kuSinyikhaba ngomnyaka we-1935. Wabelethelwa endaweni yeMthambothini, ebizwa ngeKosini. U-Esther Mahlangu uthanda ukugwala namkha ukudweba imigwalo yesiNdebele. Uthome ukugwala nakaneminyaka elitjhumi. Wafundiswa ngunina nogogwakhe ukugwala.    

UDorhodere Esther Mahlangu wabelethwa mhla amalanga amatjhumi nanye enyangeni kaSinyikhaba ngomnyaka we-1935. UDorhodere Esther wathoma ukugwala aneminyaka elitjhumi kwaphela , afundiswa ngugogwakhe.u dorhodere Mahlangu unomntwana munye okungu Stokana begodu waziwa ngoNastokana .</text>
      <sha1>qhkr53emikyup90vp6wcz6mcjwhf2st</sha1>
    </revision>
    <revision>
      <id>626</id>
      <parentid>625</parentid>
      <timestamp>2024-03-08T10:48:54Z</timestamp>
      <contributor>
        <username>incubator&gt;LindiweSiba</username>
        <id>0</id>
      </contributor>
      <comment>Added content</comment>
      <origin>626</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="628" sha1="k67es6guqcl9xdhtzlv3fzkgcc70dnv" xml:space="preserve">'''Esther Mahlangu''' wabelethwa mhlana amalanga ali-11 kuSinyikhaba ngomnyaka we-1935. Wabelethelwa endaweni yeMthambothini, ebizwa ngeKosini. U-Esther Mahlangu uthanda ukugwala namkha ukudweba imigwalo yesiNdebele. Uthome ukugwala nakaneminyaka elitjhumi. Wafundiswa ngunina nogogwakhe ukugwala.    

UDorhodere Esther Mahlangu wabelethwa mhla amalanga amatjhumi nanye enyangeni kaSinyikhaba ngomnyaka we-1935. UDorhodere Esther wathoma ukugwala aneminyaka elitjhumi kwaphela , afundiswa ngugogwakhe.u dorhodere Mahlangu unomntwana munye okungu Stokana begodu waziwa ngoNastokana .Ngonyaka ka1991 wagwala iBMW yetjhumi nambili</text>
      <sha1>k67es6guqcl9xdhtzlv3fzkgcc70dnv</sha1>
    </revision>
    <revision>
      <id>627</id>
      <parentid>626</parentid>
      <timestamp>2024-03-08T10:53:42Z</timestamp>
      <contributor>
        <username>incubator&gt;Thandeka179</username>
        <id>0</id>
      </contributor>
      <origin>627</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="518" sha1="lauk01rdprzulhlpg3aqro5glcc2i3l" xml:space="preserve">'''Esther Mahlangu''' wabelethwa mhlana amalanga ali-11 kuSinyikhaba ngomnyaka we-1935. Wabelethelwa endaweni yeMthambothini, ebizwa ngeKosini. U-Esther Mahlangu uthanda ukugwala namkha ukudweba imigwalo yesiNdebele. Uthome ukugwala nakaneminyaka elitjhumi. Wafundiswa ngunina nogogwakhe ukugwala.    

UDorhodere Esther wathoma ukugwala aneminyaka elitjhumi kwaphela , afundiswa ngugogwakhe.u dorhodere Mahlangu unomntwana munye okungu Stokana begodu waziwa ngoNastokana .Ngonyaka ka1991 wagwala iBMW yetjhumi nambili</text>
      <sha1>lauk01rdprzulhlpg3aqro5glcc2i3l</sha1>
    </revision>
    <revision>
      <id>628</id>
      <parentid>627</parentid>
      <timestamp>2024-03-08T11:26:02Z</timestamp>
      <contributor>
        <username>incubator&gt;JesicaMasilela17</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>628</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="594" sha1="qyedz6y2p30hm3wt72kr7is3u7xj4an" xml:space="preserve">'''Esther Mahlangu''' wabelethwa mhlana amalanga ali-11 kuSinyikhaba ngomnyaka we-1935. Wabelethelwa endaweni yeMthambothini, ebizwa ngeKosini. U-Esther Mahlangu uthanda ukugwala namkha ukudweba imigwalo yesiNdebele. Uthome ukugwala nakaneminyaka elitjhumi. Wafundiswa ngunina nogogwakhe ukugwala. Ugwala izinto ezinengana ekufakahlangana ikomitji, amaboda, kanye nekoloyi.    

UDorhodere Esther wathoma ukugwala aneminyaka elitjhumi kwaphela , afundiswa ngugogwakhe.u dorhodere Mahlangu unomntwana munye okungu Stokana begodu waziwa ngoNastokana .Ngonyaka ka1991 wagwala iBMW yetjhumi nambili</text>
      <sha1>qyedz6y2p30hm3wt72kr7is3u7xj4an</sha1>
    </revision>
    <revision>
      <id>629</id>
      <parentid>628</parentid>
      <timestamp>2024-03-09T07:31:25Z</timestamp>
      <contributor>
        <username>incubator&gt;KhethiweMsiza94</username>
        <id>0</id>
      </contributor>
      <comment>linked Esther Mahlangu</comment>
      <origin>629</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="598" sha1="rno6ylpo06prg5mo9x0v4edujh94g0b" xml:space="preserve">'''Esther Mahlangu''' wabelethwa mhlana amalanga ali-11 kuSinyikhaba ngomnyaka we-1935. Wabelethelwa endaweni yeMthambothini, ebizwa ngeKosini. U-[[Esther Mahlangu]] uthanda ukugwala namkha ukudweba imigwalo yesiNdebele. Uthome ukugwala nakaneminyaka elitjhumi. Wafundiswa ngunina nogogwakhe ukugwala. Ugwala izinto ezinengana ekufakahlangana ikomitji, amaboda, kanye nekoloyi.    

UDorhodere Esther wathoma ukugwala aneminyaka elitjhumi kwaphela , afundiswa ngugogwakhe.u dorhodere Mahlangu unomntwana munye okungu Stokana begodu waziwa ngoNastokana .Ngonyaka ka1991 wagwala iBMW yetjhumi nambili</text>
      <sha1>rno6ylpo06prg5mo9x0v4edujh94g0b</sha1>
    </revision>
    <revision>
      <id>630</id>
      <parentid>629</parentid>
      <timestamp>2024-03-09T08:13:54Z</timestamp>
      <contributor>
        <username>incubator&gt;KhethiweMsiza94</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>630</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="686" sha1="3eykj0s7ahqr2vrqm0skf4liqiwfp0i" xml:space="preserve">[[Isimumathi:Esther Mahlangu (cropped).jpg|thumb|Umgwali wesiNdebele uEsther Mahlangu]]
'''Esther Mahlangu''' wabelethwa mhlana amalanga ali-11 kuSinyikhaba ngomnyaka we-1935. Wabelethelwa endaweni yeMthambothini, ebizwa ngeKosini. U-[[Esther Mahlangu]] uthanda ukugwala namkha ukudweba imigwalo yesiNdebele. Uthome ukugwala nakaneminyaka elitjhumi. Wafundiswa ngunina nogogwakhe ukugwala. Ugwala izinto ezinengana ekufakahlangana ikomitji, amaboda, kanye nekoloyi.    

UDorhodere Esther wathoma ukugwala aneminyaka elitjhumi kwaphela , afundiswa ngugogwakhe.u dorhodere Mahlangu unomntwana munye okungu Stokana begodu waziwa ngoNastokana .Ngonyaka ka1991 wagwala iBMW yetjhumi nambili</text>
      <sha1>3eykj0s7ahqr2vrqm0skf4liqiwfp0i</sha1>
    </revision>
    <revision>
      <id>631</id>
      <parentid>630</parentid>
      <timestamp>2024-03-09T08:17:35Z</timestamp>
      <contributor>
        <username>incubator&gt;MahlanguMondli24</username>
        <id>0</id>
      </contributor>
      <comment>addded a picture</comment>
      <origin>631</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="751" sha1="2mvbjeqnk59pczug75garfva7c0atg9" xml:space="preserve">[[Isimumathi:Esther Mahlangu (cropped).jpg|thumb|Umgwali wesiNdebele uEsther Mahlangu]]
[[Isimumathi:Esther Mahlangu in 2015.jpg|thumb|Esther Mahlangu]]
'''Esther Mahlangu''' wabelethwa mhlana amalanga ali-11 kuSinyikhaba ngomnyaka we-1935. Wabelethelwa endaweni yeMthambothini, ebizwa ngeKosini. U-[[Esther Mahlangu]] uthanda ukugwala namkha ukudweba imigwalo yesiNdebele. Uthome ukugwala nakaneminyaka elitjhumi. Wafundiswa ngunina nogogwakhe ukugwala. Ugwala izinto ezinengana ekufakahlangana ikomitji, amaboda, kanye nekoloyi.    

UDorhodere Esther wathoma ukugwala aneminyaka elitjhumi kwaphela , afundiswa ngugogwakhe.u dorhodere Mahlangu unomntwana munye okungu Stokana begodu waziwa ngoNastokana .Ngonyaka ka1991 wagwala iBMW yetjhumi nambili</text>
      <sha1>2mvbjeqnk59pczug75garfva7c0atg9</sha1>
    </revision>
    <revision>
      <id>632</id>
      <parentid>631</parentid>
      <timestamp>2024-03-09T08:18:55Z</timestamp>
      <contributor>
        <username>incubator&gt;MahlanguMondli24</username>
        <id>0</id>
      </contributor>
      <comment>added a picture</comment>
      <origin>632</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="777" sha1="q3rzdzx0r82m9q2nwrji99vnntypgbi" xml:space="preserve">[[Isimumathi:Esther Mahlangu (cropped).jpg|thumb|Umgwali wesiNdebele uEsther Mahlangu]]
[[Isimumathi:Esther Mahlangu in 2015.jpg|thumb|Ugogo u Esther Mahlangu ngomnyaka ka 2015]]
'''Esther Mahlangu''' wabelethwa mhlana amalanga ali-11 kuSinyikhaba ngomnyaka we-1935. Wabelethelwa endaweni yeMthambothini, ebizwa ngeKosini. U-[[Esther Mahlangu]] uthanda ukugwala namkha ukudweba imigwalo yesiNdebele. Uthome ukugwala nakaneminyaka elitjhumi. Wafundiswa ngunina nogogwakhe ukugwala. Ugwala izinto ezinengana ekufakahlangana ikomitji, amaboda, kanye nekoloyi.    

UDorhodere Esther wathoma ukugwala aneminyaka elitjhumi kwaphela , afundiswa ngugogwakhe.u dorhodere Mahlangu unomntwana munye okungu Stokana begodu waziwa ngoNastokana .Ngonyaka ka1991 wagwala iBMW yetjhumi nambili</text>
      <sha1>q3rzdzx0r82m9q2nwrji99vnntypgbi</sha1>
    </revision>
    <revision>
      <id>633</id>
      <parentid>632</parentid>
      <timestamp>2024-03-09T08:21:12Z</timestamp>
      <contributor>
        <username>incubator&gt;MahlanguMondli24</username>
        <id>0</id>
      </contributor>
      <comment>added a picture</comment>
      <origin>633</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="778" sha1="ig0uh96af4ychrxurpeli8s4h65cv4b" xml:space="preserve">[[Isimumathi:Esther Mahlangu (cropped).jpg|thumb|Umgwali wesiNdebele uEsther Mahlangu]]
[[Isimumathi:Esther Mahlangu in 2015.jpg|thumb|Ugogo u-Esther Mahlangu ngomnyaka ka 2015.]]
'''Esther Mahlangu''' wabelethwa mhlana amalanga ali-11 kuSinyikhaba ngomnyaka we-1935. Wabelethelwa endaweni yeMthambothini, ebizwa ngeKosini. U-[[Esther Mahlangu]] uthanda ukugwala namkha ukudweba imigwalo yesiNdebele. Uthome ukugwala nakaneminyaka elitjhumi. Wafundiswa ngunina nogogwakhe ukugwala. Ugwala izinto ezinengana ekufakahlangana ikomitji, amaboda, kanye nekoloyi.    

UDorhodere Esther wathoma ukugwala aneminyaka elitjhumi kwaphela , afundiswa ngugogwakhe.u dorhodere Mahlangu unomntwana munye okungu Stokana begodu waziwa ngoNastokana .Ngonyaka ka1991 wagwala iBMW yetjhumi nambili</text>
      <sha1>ig0uh96af4ychrxurpeli8s4h65cv4b</sha1>
    </revision>
    <revision>
      <id>634</id>
      <parentid>633</parentid>
      <timestamp>2024-03-09T08:30:48Z</timestamp>
      <contributor>
        <username>incubator&gt;Madubandlela</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>634</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="875" sha1="5fev84xvknhf4uk9qwo7ag6inik7jpf" xml:space="preserve">[[Isimumathi:Esther Mahlangu (cropped).jpg|thumb|Umgwali wesiNdebele uEsther Mahlangu]]
[[Isimumathi:Esther Mahlangu in 2015.jpg|thumb|Ugogo u-Esther Mahlangu ngomnyaka ka 2015.]]
'''Esther Mahlangu''' wabelethwa mhlana amalanga ali-11 kuSinyikhaba ngomnyaka we-1935. Wabelethelwa endaweni yeMthambothini, ebizwa ngeKosini. U-[[Esther Mahlangu]] uthanda ukugwala namkha ukudweba imigwalo yesiNdebele. Uthome ukugwala nakaneminyaka elitjhumi. Wafundiswa ngunina nogogwakhe ukugwala. Ugwala izinto ezinengana ekufakahlangana ikomitji, amaboda, kanye nekoloyi.    

UDorhodere Esther wathoma ukugwala aneminyaka elitjhumi kwaphela , afundiswa ngugogwakhe.u dorhodere Mahlangu unomntwana munye okungu Stokana begodu waziwa ngoNastokana .Ngonyaka ka1991 wagwala iBMW yetjhumi nambili

Ester Mahlangu watlonyeliswa ngobudorhodere yinyuvesi yase JHB.

Ugwalile nasemazweni aphetjeya</text>
      <sha1>5fev84xvknhf4uk9qwo7ag6inik7jpf</sha1>
    </revision>
    <revision>
      <id>635</id>
      <parentid>634</parentid>
      <timestamp>2024-03-09T10:07:15Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>635</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="876" sha1="gtl9lxroo59evvn4rnnkwpoz80h4z26" xml:space="preserve">[[Isimumathi:Esther Mahlangu (cropped).jpg|thumb|Umgwali wesiNdebele uEsther Mahlangu]]
[[Isimumathi:Esther Mahlangu in 2015.jpg|thumb|Ugogo u-Esther Mahlangu ngomnyaka ka 2015.]]
'''Esther Mahlangu''' wabelethwa mhlana amalanga ali-11 kuSinyikhaba ngomnyaka we-1935. Wabelethelwa endaweni yeMthambothini, ebizwa ngeKosini. U-[[Esther Mahlangu]] uthanda ukugwala namkha ukudweba imigwalo yesiNdebele. Uthome ukugwala nakaneminyaka elitjhumi. Wafundiswa ngunina nogogwakhe ukugwala. Ugwala izinto ezinengana ekufakahlangana ikomitji, amaboda, kanye nekoloyi.    

UDorhodere Esther wathoma ukugwala aneminyaka elitjhumi kwaphela , afundiswa ngugogwakhe.u dorhodere Mahlangu unomntwana munye okungu Stokana begodu waziwa ngoNastokana .Ngonyaka ka1991 wagwala iBMW yetjhumi nambili

Ester Mahlangu watlonyeliswa ngobudorhodere yinyuvesi yase JHB.

Ugwalile nasemazweni aphetjeya
</text>
      <sha1>gtl9lxroo59evvn4rnnkwpoz80h4z26</sha1>
    </revision>
    <revision>
      <id>636</id>
      <parentid>635</parentid>
      <timestamp>2024-10-14T13:46:39Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>18 revisions imported</comment>
      <origin>635</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="876" sha1="gtl9lxroo59evvn4rnnkwpoz80h4z26" xml:space="preserve">[[Isimumathi:Esther Mahlangu (cropped).jpg|thumb|Umgwali wesiNdebele uEsther Mahlangu]]
[[Isimumathi:Esther Mahlangu in 2015.jpg|thumb|Ugogo u-Esther Mahlangu ngomnyaka ka 2015.]]
'''Esther Mahlangu''' wabelethwa mhlana amalanga ali-11 kuSinyikhaba ngomnyaka we-1935. Wabelethelwa endaweni yeMthambothini, ebizwa ngeKosini. U-[[Esther Mahlangu]] uthanda ukugwala namkha ukudweba imigwalo yesiNdebele. Uthome ukugwala nakaneminyaka elitjhumi. Wafundiswa ngunina nogogwakhe ukugwala. Ugwala izinto ezinengana ekufakahlangana ikomitji, amaboda, kanye nekoloyi.    

UDorhodere Esther wathoma ukugwala aneminyaka elitjhumi kwaphela , afundiswa ngugogwakhe.u dorhodere Mahlangu unomntwana munye okungu Stokana begodu waziwa ngoNastokana .Ngonyaka ka1991 wagwala iBMW yetjhumi nambili

Ester Mahlangu watlonyeliswa ngobudorhodere yinyuvesi yase JHB.

Ugwalile nasemazweni aphetjeya
</text>
      <sha1>gtl9lxroo59evvn4rnnkwpoz80h4z26</sha1>
    </revision>
    <revision>
      <id>1878</id>
      <parentid>636</parentid>
      <timestamp>2024-11-12T18:43:16Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>Umgwali wesiNdebele uEsther Mahlangu ka 2009</comment>
      <origin>1878</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="882" sha1="2g2n3hwig7slgfcvozak0qsc57cgpew" xml:space="preserve">[[Isimumathi:Esther Mahlangu (cropped).jpg|thumb|Umgwali wesiNdebele uEsther Mahlangu ka 2009]]
[[Isimumathi:Esther Mahlangu in 2015.jpg|thumb|Ugogo u-Esther Mahlangu ngomnyaka ka 2015]]
'''Esther Mahlangu''' wabelethwa mhlana amalanga ali-11 kuSinyikhaba ngomnyaka we-1935. Wabelethelwa endaweni yeMthambothini, ebizwa ngeKosini. U-[[Esther Mahlangu]] uthanda ukugwala namkha ukudweba imigwalo yesiNdebele. Uthome ukugwala nakaneminyaka elitjhumi. Wafundiswa ngunina nogogwakhe ukugwala. Ugwala izinto ezinengana ekufakahlangana ikomitji, amaboda, kanye nekoloyi.    

UDorhodere Esther wathoma ukugwala aneminyaka elitjhumi kwaphela , afundiswa ngugogwakhe.u dorhodere Mahlangu unomntwana munye okungu Stokana begodu waziwa ngoNastokana .Ngonyaka ka1991 wagwala iBMW yetjhumi nambili

Ester Mahlangu watlonyeliswa ngobudorhodere yinyuvesi yase JHB.

Ugwalile nasemazweni aphetjeya</text>
      <sha1>2g2n3hwig7slgfcvozak0qsc57cgpew</sha1>
    </revision>
    <revision>
      <id>5410</id>
      <parentid>1878</parentid>
      <timestamp>2025-09-03T12:30:16Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1303104769|Esther Mahlangu]]&quot;</comment>
      <origin>5410</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="346" sha1="tlytdl083zbqlve6r4ghgquavo7fx6c" xml:space="preserve">
U-'''Esther Mahlangu''' (wabelethwa lokha amalanga ali-11 kuNobayeni ngomnyaka we-1935) mgwali weSewula Afrikha. Waziwa ngemigwalakhe enokuzithema, enesithunzi, emihle, emikhulu nekarisako yesimanjemanje ekhuthazwe lilwazi lakhe, amagugu anawo welimi,, amasiko nekolo [[AmaNdebele|yamaNdebele]].  Ngomunye wabagwali abaziwa khulu eSewula Afrika.</text>
      <sha1>tlytdl083zbqlve6r4ghgquavo7fx6c</sha1>
    </revision>
  </page>
  <page>
    <title>Gwede Mantashe</title>
    <ns>0</ns>
    <id>131</id>
    <revision>
      <id>637</id>
      <timestamp>2024-03-09T07:11:54Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;uGwede Mantashe ungusopolitiki wase Sewula Afrika wecembu le ANC.  &quot;</comment>
      <origin>637</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="67" sha1="gqgy6lx7yxkzom4mkfxol7fjutwcrpe" xml:space="preserve">uGwede Mantashe ungusopolitiki wase Sewula Afrika wecembu le ANC.

</text>
      <sha1>gqgy6lx7yxkzom4mkfxol7fjutwcrpe</sha1>
    </revision>
    <revision>
      <id>638</id>
      <parentid>637</parentid>
      <timestamp>2024-03-09T07:13:14Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>638</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="73" sha1="2olad47f5tdt1o6aserphm38lgt6oeo" xml:space="preserve">'''uGwede Mantashe''' ungusopolitiki wase Sewula Afrika wecembu le ANC.

</text>
      <sha1>2olad47f5tdt1o6aserphm38lgt6oeo</sha1>
    </revision>
    <revision>
      <id>639</id>
      <parentid>638</parentid>
      <timestamp>2024-03-09T07:20:35Z</timestamp>
      <contributor>
        <username>incubator&gt;Leratonathasher369</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>639</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="100" sha1="238z8x06y6fsqx3ege9m7316j6eknwz" xml:space="preserve">'''USamson Gwede Mantashe''' ngusoPolitiki wase [[Isewula Afrika|Sewula Afrika]] wehlangano i-ANC.

</text>
      <sha1>238z8x06y6fsqx3ege9m7316j6eknwz</sha1>
    </revision>
    <revision>
      <id>640</id>
      <parentid>639</parentid>
      <timestamp>2024-03-09T07:29:44Z</timestamp>
      <contributor>
        <username>incubator&gt;Lethabo19</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>640</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="104" sha1="du4ry2lmgiwrzy9vl56vpsp9ox1vt96" xml:space="preserve">'''USamson Gwede Mantashe''' ngusoPolitiki wase [[Isewula Afrika|Sewula Afrika]] wehlangano i-[[ANC.]]

</text>
      <sha1>du4ry2lmgiwrzy9vl56vpsp9ox1vt96</sha1>
    </revision>
    <revision>
      <id>641</id>
      <parentid>640</parentid>
      <timestamp>2024-03-09T08:11:16Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>added picture.</comment>
      <origin>641</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="168" sha1="mfgy5czvi095ebl9go04gl91l41ej3o" xml:space="preserve">[[Isimumathi:Gwede Mantashe in 2019.png|thumb|uGwede Mantashe]]
'''USamson Gwede Mantashe''' ngusoPolitiki wase [[Isewula Afrika|Sewula Afrika]] wehlangano i-[[ANC.]]

</text>
      <sha1>mfgy5czvi095ebl9go04gl91l41ej3o</sha1>
    </revision>
    <revision>
      <id>642</id>
      <parentid>641</parentid>
      <timestamp>2024-03-09T08:15:21Z</timestamp>
      <contributor>
        <username>incubator&gt;Mbandeni</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Added a picture</comment>
      <origin>641</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="168" sha1="mfgy5czvi095ebl9go04gl91l41ej3o" xml:space="preserve">[[Isimumathi:Gwede Mantashe in 2019.png|thumb|uGwede Mantashe]]
'''USamson Gwede Mantashe''' ngusoPolitiki wase [[Isewula Afrika|Sewula Afrika]] wehlangano i-[[ANC.]]

</text>
      <sha1>mfgy5czvi095ebl9go04gl91l41ej3o</sha1>
    </revision>
    <revision>
      <id>643</id>
      <parentid>642</parentid>
      <timestamp>2024-10-14T13:46:40Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>6 revisions imported</comment>
      <origin>641</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="168" sha1="mfgy5czvi095ebl9go04gl91l41ej3o" xml:space="preserve">[[Isimumathi:Gwede Mantashe in 2019.png|thumb|uGwede Mantashe]]
'''USamson Gwede Mantashe''' ngusoPolitiki wase [[Isewula Afrika|Sewula Afrika]] wehlangano i-[[ANC.]]

</text>
      <sha1>mfgy5czvi095ebl9go04gl91l41ej3o</sha1>
    </revision>
    <revision>
      <id>1880</id>
      <parentid>643</parentid>
      <timestamp>2024-11-12T18:54:30Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <comment>uGwede Mantashe ka 2019</comment>
      <origin>1880</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="172" sha1="5lztex98gsb7as7sw55fkxtkh18556s" xml:space="preserve">[[Isimumathi:Gwede Mantashe in 2019.png|thumb|uGwede Mantashe, 2019]]
'''USamson Gwede Mantashe''' ngusoPolitiki wase [[Isewula Afrika|Sewula Afrika]] wehlangano i-[[ANC.]]</text>
      <sha1>5lztex98gsb7as7sw55fkxtkh18556s</sha1>
    </revision>
    <revision>
      <id>1881</id>
      <parentid>1880</parentid>
      <timestamp>2024-11-12T18:54:41Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <origin>1881</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="174" sha1="egya16ou61peukttsjln32fj32nbfcm" xml:space="preserve">[[Isimumathi:Gwede Mantashe in 2019.png|thumb|uGwede Mantashe ka 2019]]
'''USamson Gwede Mantashe''' ngusoPolitiki wase [[Isewula Afrika|Sewula Afrika]] wehlangano i-[[ANC.]]</text>
      <sha1>egya16ou61peukttsjln32fj32nbfcm</sha1>
    </revision>
    <revision>
      <id>2175</id>
      <parentid>1881</parentid>
      <timestamp>2024-11-28T09:07:24Z</timestamp>
      <contributor>
        <ip>104.255.173.142</ip>
      </contributor>
      <comment>uMantashe ngomnyaka ka-2019</comment>
      <origin>2175</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="178" sha1="47gwh1sc1dkm9xr9nx02xd2eikspwec" xml:space="preserve">[[Isimumathi:Gwede Mantashe in 2019.png|thumb|uMantashe ngomnyaka ka-2019]]
'''USamson Gwede Mantashe''' ngusoPolitiki wase [[Isewula Afrika|Sewula Afrika]] wehlangano i-[[ANC.]]</text>
      <sha1>47gwh1sc1dkm9xr9nx02xd2eikspwec</sha1>
    </revision>
  </page>
  <page>
    <title>Hluzingqondo secondary school</title>
    <ns>0</ns>
    <id>132</id>
    <revision>
      <id>644</id>
      <timestamp>2024-03-08T13:55:15Z</timestamp>
      <contributor>
        <username>incubator&gt;Leratonathasher369</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;Ihluzingqondo Secondary school sikolo esisendaweni ebizwa ngeKwaggafontein A eseMpumalanga. Siwela ngaphasi koMasipala iThembisile Hani Municipality.Siphethwe nguhlokokulu uLitsie. Sifundisa iimfundo ezihlukahlukeneko ngelimi lesiNdebele, isikhuwa kanye nesiPedi.  &quot;</comment>
      <origin>644</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="265" sha1="fufspc46y2frkc9e3fd481164nyixsb" xml:space="preserve">Ihluzingqondo Secondary school sikolo esisendaweni ebizwa ngeKwaggafontein A eseMpumalanga. Siwela ngaphasi koMasipala iThembisile Hani Municipality.Siphethwe nguhlokokulu uLitsie. Sifundisa iimfundo ezihlukahlukeneko ngelimi lesiNdebele, isikhuwa kanye nesiPedi.

</text>
      <sha1>fufspc46y2frkc9e3fd481164nyixsb</sha1>
    </revision>
    <revision>
      <id>645</id>
      <parentid>644</parentid>
      <timestamp>2024-03-08T13:55:45Z</timestamp>
      <contributor>
        <username>incubator&gt;Leratonathasher369</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>645</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="265" sha1="31176dzeg10ucsakinskc5uaik9s3c9" xml:space="preserve">IHluzingqondo Secondary school sikolo esisendaweni ebizwa ngeKwaggafontein A eseMpumalanga. Siwela ngaphasi koMasipala iThembisile Hani Municipality.Siphethwe nguhlokokulu uLitsie. Sifundisa iimfundo ezihlukahlukeneko ngelimi lesiNdebele, isikhuwa kanye nesiPedi.

</text>
      <sha1>31176dzeg10ucsakinskc5uaik9s3c9</sha1>
    </revision>
    <revision>
      <id>646</id>
      <parentid>645</parentid>
      <timestamp>2024-03-08T13:58:46Z</timestamp>
      <contributor>
        <username>incubator&gt;Leratonathasher369</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>646</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="271" sha1="ro9s8lb74f88q1nj0qc6mdxscj2zh2i" xml:space="preserve">'''IHluzingqondo Secondary school''' sikolo esisendaweni ebizwa ngeKwaggafontein A eseMpumalanga. Siwela ngaphasi koMasipala iThembisile Hani Municipality.Siphethwe nguhlokokulu uLitsie. Sifundisa iimfundo ezihlukahlukeneko ngelimi lesiNdebele, isikhuwa kanye nesiPedi.

</text>
      <sha1>ro9s8lb74f88q1nj0qc6mdxscj2zh2i</sha1>
    </revision>
    <revision>
      <id>647</id>
      <parentid>646</parentid>
      <timestamp>2024-03-09T07:33:41Z</timestamp>
      <contributor>
        <username>incubator&gt;Leratonathasher369</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>647</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="283" sha1="ffxe2df8szp1bhandomsacal7nlfqvn" xml:space="preserve">'''IHluzingqondo Secondary school''' sikolo esisendaweni ebizwa nge[[Kwaggafontein A]] ese[[Mpumalanga]]. Siwela ngaphasi koMasipala i[[Thembisile Hani Municipality]].Siphethwe nguhlokokulu uLitsie. Sifundisa iimfundo ezihlukahlukeneko ngelimi lesiNdebele, isiKhuwa kanye nesiPedi.

</text>
      <sha1>ffxe2df8szp1bhandomsacal7nlfqvn</sha1>
    </revision>
    <revision>
      <id>648</id>
      <parentid>647</parentid>
      <timestamp>2024-10-14T13:46:40Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>4 revisions imported</comment>
      <origin>647</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="283" sha1="ffxe2df8szp1bhandomsacal7nlfqvn" xml:space="preserve">'''IHluzingqondo Secondary school''' sikolo esisendaweni ebizwa nge[[Kwaggafontein A]] ese[[Mpumalanga]]. Siwela ngaphasi koMasipala i[[Thembisile Hani Municipality]].Siphethwe nguhlokokulu uLitsie. Sifundisa iimfundo ezihlukahlukeneko ngelimi lesiNdebele, isiKhuwa kanye nesiPedi.

</text>
      <sha1>ffxe2df8szp1bhandomsacal7nlfqvn</sha1>
    </revision>
    <revision>
      <id>2250</id>
      <parentid>648</parentid>
      <timestamp>2024-12-09T11:03:26Z</timestamp>
      <contributor>
        <ip>95.26.163.119</ip>
      </contributor>
      <origin>2250</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="283" sha1="fw2tf777uanrbsix2p364hvfc89t9t7" xml:space="preserve">'''IHluzingqondo Secondary school -''' sikolo esisendaweni ebizwa nge[[Kwaggafontein A]] ese[[Mpumalanga]]. Siwela ngaphasi koMasipala i[[Thembisile Hani Municipality]].Siphethwe nguhlokokulu uLitsie. Sifundisa iimfundo ezihlukahlukeneko ngelimi lesiNdebele, isiKhuwa kanye nesiPedi.</text>
      <sha1>fw2tf777uanrbsix2p364hvfc89t9t7</sha1>
    </revision>
    <revision>
      <id>2349</id>
      <parentid>2250</parentid>
      <timestamp>2025-01-17T11:00:53Z</timestamp>
      <contributor>
        <ip>85.192.95.241</ip>
      </contributor>
      <comment>yes</comment>
      <origin>2349</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="397" sha1="n4d1hdice1rew26y04t8s08aqr4guen" xml:space="preserve">'''IHluzingqondo Secondary school -''' sikolo esisendaweni ebizwa nge[[Kwaggafontein A]] ese[[Mpumalanga]]. Siwela ngaphasi koMasipala i[[Thembisile Hani Municipality]].Siphethwe nguhlokokulu uLitsie. Sifundisa iimfundo ezihlukahlukeneko ngelimi lesiNdebele, isiKhuwa kanye ne

Hollow knight sobrevaloradiesimo bro

&quot;aqui teneis juegos para jugar&quot;

-capitan obvio

[https://geography-basic-10.us/]</text>
      <sha1>n4d1hdice1rew26y04t8s08aqr4guen</sha1>
    </revision>
    <revision>
      <id>2352</id>
      <parentid>2349</parentid>
      <timestamp>2025-01-17T11:05:42Z</timestamp>
      <contributor>
        <username>Elton</username>
        <id>323</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/85.192.95.241|85.192.95.241]] ([[User talk:85.192.95.241|talk]]) to last revision by [[User:95.26.163.119|95.26.163.119]]</comment>
      <origin>2250</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="283" sha1="fw2tf777uanrbsix2p364hvfc89t9t7" xml:space="preserve">'''IHluzingqondo Secondary school -''' sikolo esisendaweni ebizwa nge[[Kwaggafontein A]] ese[[Mpumalanga]]. Siwela ngaphasi koMasipala i[[Thembisile Hani Municipality]].Siphethwe nguhlokokulu uLitsie. Sifundisa iimfundo ezihlukahlukeneko ngelimi lesiNdebele, isiKhuwa kanye nesiPedi.</text>
      <sha1>fw2tf777uanrbsix2p364hvfc89t9t7</sha1>
    </revision>
    <revision>
      <id>2898</id>
      <parentid>2352</parentid>
      <timestamp>2025-06-06T15:31:50Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <origin>2898</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="62117" sha1="ji0j3fiqi736y4i4lnz6bqxo4z8p7z1" xml:space="preserve">&quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot; &quot;Attack the D-point&quot;</text>
      <sha1>ji0j3fiqi736y4i4lnz6bqxo4z8p7z1</sha1>
    </revision>
    <revision>
      <id>3117</id>
      <parentid>2898</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Elton|Elton]]</comment>
      <origin>2250</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="283" sha1="fw2tf777uanrbsix2p364hvfc89t9t7" xml:space="preserve">'''IHluzingqondo Secondary school -''' sikolo esisendaweni ebizwa nge[[Kwaggafontein A]] ese[[Mpumalanga]]. Siwela ngaphasi koMasipala i[[Thembisile Hani Municipality]].Siphethwe nguhlokokulu uLitsie. Sifundisa iimfundo ezihlukahlukeneko ngelimi lesiNdebele, isiKhuwa kanye nesiPedi.</text>
      <sha1>fw2tf777uanrbsix2p364hvfc89t9t7</sha1>
    </revision>
  </page>
  <page>
    <title>I-Dalmanutha</title>
    <ns>0</ns>
    <id>133</id>
    <revision>
      <id>649</id>
      <timestamp>2024-05-11T06:18:00Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''I-Dalmanutha''' iyisiteshi sesitimela esiqhele ngamakhilomitha ayi-16 empumalanga yeBelfast, emzileni ophakathi kwePitoli neMaputo. Iqanjwe ngegama lepulazi, elibuye lithathe igama lalo edolobheni laseBhayibhelini oLwandle LwaseGalile (Marku 8:10). Igama kuthiwa lisho 'indlu yobufelokazi'. Le ndawo yaziwa ngabantu bendawo ngokuthi iMonometsi. Ukungqubuzana phakathi kweBakoni neMatabele kwenzeka lapha. Kuphinde kwaba yinkundla yempi yokugcina yeMpi Yesibili YamaBhunu (...&quot;</comment>
      <origin>649</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="521" sha1="nik8j42mqbno8qxqg5mu4teecfe66zb" xml:space="preserve">'''I-Dalmanutha''' iyisiteshi sesitimela esiqhele ngamakhilomitha ayi-16 empumalanga yeBelfast, emzileni ophakathi kwePitoli neMaputo. Iqanjwe ngegama lepulazi, elibuye lithathe igama lalo edolobheni laseBhayibhelini oLwandle LwaseGalile (Marku 8:10). Igama kuthiwa lisho 'indlu yobufelokazi'. Le ndawo yaziwa ngabantu bendawo ngokuthi iMonometsi. Ukungqubuzana phakathi kweBakoni neMatabele kwenzeka lapha. Kuphinde kwaba yinkundla yempi yokugcina yeMpi Yesibili YamaBhunu (1899-1902) eyasuka zingama-25 kuNcwaba 1900.

</text>
      <sha1>nik8j42mqbno8qxqg5mu4teecfe66zb</sha1>
    </revision>
    <revision>
      <id>650</id>
      <parentid>649</parentid>
      <timestamp>2024-05-22T09:06:43Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>650</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="523" sha1="3r3ncv3u2731h1toq8ir8iu5v3prjox" xml:space="preserve">'''I-Dalmanutha''' isitethji sesitimela esiqhele ngamakhilomitha ayi-16 empumalanga yeBelfast, emzileni ophakathi kwePitori neMaputo. Ithiyelelwe ngegama leplasi, elibuye lithathe igama lalo edorobheni laseBhayibhelini iLwandle LeGalile (Marku 8:10). Igama leli kuthiwa litjho 'indlu yobufelokazi'. Le ndawo yaziwa ngabantu bendawo ngokuthi iMonometsi. Ukungqubuzana phakathi kweBakoni neMatabele kwenzeka lapha. Kuphinde kwaba yikundla yepi yokugcina yepi Yesibili YamaBhunu (1899-1902) eyasuka zingama-25 kuNcwaba 1900.

</text>
      <sha1>3r3ncv3u2731h1toq8ir8iu5v3prjox</sha1>
    </revision>
    <revision>
      <id>651</id>
      <parentid>650</parentid>
      <timestamp>2024-10-14T13:46:40Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>650</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="523" sha1="3r3ncv3u2731h1toq8ir8iu5v3prjox" xml:space="preserve">'''I-Dalmanutha''' isitethji sesitimela esiqhele ngamakhilomitha ayi-16 empumalanga yeBelfast, emzileni ophakathi kwePitori neMaputo. Ithiyelelwe ngegama leplasi, elibuye lithathe igama lalo edorobheni laseBhayibhelini iLwandle LeGalile (Marku 8:10). Igama leli kuthiwa litjho 'indlu yobufelokazi'. Le ndawo yaziwa ngabantu bendawo ngokuthi iMonometsi. Ukungqubuzana phakathi kweBakoni neMatabele kwenzeka lapha. Kuphinde kwaba yikundla yepi yokugcina yepi Yesibili YamaBhunu (1899-1902) eyasuka zingama-25 kuNcwaba 1900.

</text>
      <sha1>3r3ncv3u2731h1toq8ir8iu5v3prjox</sha1>
    </revision>
  </page>
  <page>
    <title>I-logo</title>
    <ns>0</ns>
    <id>134</id>
    <revision>
      <id>652</id>
      <timestamp>2024-07-21T10:14:14Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;== I-logo == Kukhona ezinye izinto ezijamele ikhamphani nanyana umkhiqizo othize, ezifana njetshwayo, isithombe kanye nelogo. Izinto lezi zakhiwe ngedlela yokuthi zinikele umlayezo nanyana umniningwana kilabo abaqothelweko. Nanyana kunjalo-ke, ngaphasi kwesihloko sethi lesi sizokunzinza kwi-logo.    I-Cambridge Dictionary (2024) iqinisekisa iphuzu elingehla leli ngokuveza bona, i-logo litshwayo leli elisetjenziswa yikhamphani emikhiqizweni yalo ukuthuthukisa ubujamo nomk...&quot;</comment>
      <origin>652</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1435" sha1="23rqi48trgqhmgjyi1f3dsm8ind9hg5" xml:space="preserve">== I-logo ==
Kukhona ezinye izinto ezijamele ikhamphani nanyana umkhiqizo othize, ezifana njetshwayo, isithombe kanye nelogo. Izinto lezi zakhiwe ngedlela yokuthi zinikele umlayezo nanyana umniningwana kilabo abaqothelweko. Nanyana kunjalo-ke, ngaphasi kwesihloko sethi lesi sizokunzinza kwi-logo.  

I-Cambridge Dictionary (2024) iqinisekisa iphuzu elingehla leli ngokuveza bona, i-logo litshwayo leli elisetjenziswa yikhamphani emikhiqizweni yalo ukuthuthukisa ubujamo nomkhiqizo walo begodu nokwenza isiqiniseko sokuthi amakhastama wayo ayibona bekayikhumbule msinya ikhamphani le.  I-logo yekhaphani ingasetjenziswa kunanyana ngimuphi umkhiqizo kanye nezinto zekhamphani okufaka hlangana imakhiwo, iinkoloyi neesentjenziswa ukuze abantu bazi bonyana izinto lezo ngezabo.  

Abasebenzisi, abathengi nanyana abanikeli ngemisebenzi bazokuqala ibizo nanyana i-logo yekhamphani ukuze bakwazi ukuhlukanisa imikhiqizo yekhamphani leyo neminye imikhiqizo yeenkhaphani eziphalisana nayo.  I-logo ibuye yazise abasebenzisi ngokwazeka nokuduma kwabo  nangendlela abaziwa ngayo emphakathini (Cambridge Dictionary 2024). Lokho kuzokwenza kobana balemuke kobana yikhamphani nanyana umsebenzi nanyana umuntu onendumela, okuzokwenza kobana imikhiqhizo leyo ithengwe khudlwana.

=== Isilululwazi  ===
Cambridge Dictionary. (2024b). ‘Logo’. Available at:&lt;https://dictionary.cambridge.org/dictionary/english/logo&gt;. Accessed on [9 January 2024].

</text>
      <sha1>23rqi48trgqhmgjyi1f3dsm8ind9hg5</sha1>
    </revision>
    <revision>
      <id>653</id>
      <parentid>652</parentid>
      <timestamp>2024-09-18T15:31:34Z</timestamp>
      <contributor>
        <username>incubator&gt;Nomsa Skosana</username>
        <id>0</id>
      </contributor>
      <comment>/* I-logo */</comment>
      <origin>653</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1419" sha1="63x0v2uw9avpz8x4qt0gtct7no0rf29" xml:space="preserve">Kukhona ezinye izinto ezijamele ikhamphani nanyana umkhiqizo othize, ezifana njetshwayo, isithombe kanye nelogo. Izinto lezi zakhiwe ngedlela yokuthi zinikele umlayezo nanyana umniningwana kilabo abaqothelweko. Nanyana kunjalo-ke, ngaphasi kwesihloko sethi lesi sizokunzinza kwi-logo.  

I-Cambridge Dictionary (2024) iqinisekisa iphuzu elingehla leli ngokuveza bona, i-logo litshwayo leli elisetjenziswa yikhamphani emikhiqizweni yalo ukuthuthukisa ubujamo nomkhiqizo walo begodu nokwenza isiqiniseko sokuthi amakhastama wayo ayibona bekayikhumbule msinya ikhamphani le.  I-logo yekhaphani ingasetjenziswa kunanyana ngimuphi umkhiqizo kanye nezinto zekhamphani okufaka hlangana imakhiwo, iinkoloyi neesentjenziswa ukuze abantu bazi bonyana izinto lezo ngezabo.  

Abasebenzisi, abathengi nanyana abanikeli ngemisebenzi bazokuqala ibizo nanyana i-logo yekhamphani ukuze bakwazi ukuhlukanisa imikhiqizo yekhamphani leyo neminye imikhiqizo yeenkhaphani eziphalisana nayo.  I-logo ibuye yazise abasebenzisi ngokwazeka nokuduma kwabo  nangendlela abaziwa ngayo emphakathini (Cambridge Dictionary 2024). Lokho kuzokwenza kobana balemuke kobana yikhamphani nanyana umsebenzi nanyana umuntu onendumela, okuzokwenza kobana imikhiqhizo leyo ithengwe khudlwana.

== Isilululwazi ==
Cambridge Dictionary. (2024b). ‘Logo’. Available at:&lt;https://dictionary.cambridge.org/dictionary/english/logo&gt;. Accessed on [9 January 2024].

</text>
      <sha1>63x0v2uw9avpz8x4qt0gtct7no0rf29</sha1>
    </revision>
    <revision>
      <id>654</id>
      <parentid>653</parentid>
      <timestamp>2024-09-18T15:31:59Z</timestamp>
      <contributor>
        <username>incubator&gt;Nomsa Skosana</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>654</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1425" sha1="frbjttlnxl9bc1lfofle9ojugsw9q01" xml:space="preserve">'''Kukhona''' ezinye izinto ezijamele ikhamphani nanyana umkhiqizo othize, ezifana njetshwayo, isithombe kanye nelogo. Izinto lezi zakhiwe ngedlela yokuthi zinikele umlayezo nanyana umniningwana kilabo abaqothelweko. Nanyana kunjalo-ke, ngaphasi kwesihloko sethi lesi sizokunzinza kwi-logo.  

I-Cambridge Dictionary (2024) iqinisekisa iphuzu elingehla leli ngokuveza bona, i-logo litshwayo leli elisetjenziswa yikhamphani emikhiqizweni yalo ukuthuthukisa ubujamo nomkhiqizo walo begodu nokwenza isiqiniseko sokuthi amakhastama wayo ayibona bekayikhumbule msinya ikhamphani le.  I-logo yekhaphani ingasetjenziswa kunanyana ngimuphi umkhiqizo kanye nezinto zekhamphani okufaka hlangana imakhiwo, iinkoloyi neesentjenziswa ukuze abantu bazi bonyana izinto lezo ngezabo.  

Abasebenzisi, abathengi nanyana abanikeli ngemisebenzi bazokuqala ibizo nanyana i-logo yekhamphani ukuze bakwazi ukuhlukanisa imikhiqizo yekhamphani leyo neminye imikhiqizo yeenkhaphani eziphalisana nayo.  I-logo ibuye yazise abasebenzisi ngokwazeka nokuduma kwabo  nangendlela abaziwa ngayo emphakathini (Cambridge Dictionary 2024). Lokho kuzokwenza kobana balemuke kobana yikhamphani nanyana umsebenzi nanyana umuntu onendumela, okuzokwenza kobana imikhiqhizo leyo ithengwe khudlwana.

== Isilululwazi ==
Cambridge Dictionary. (2024b). ‘Logo’. Available at:&lt;https://dictionary.cambridge.org/dictionary/english/logo&gt;. Accessed on [9 January 2024].

</text>
      <sha1>frbjttlnxl9bc1lfofle9ojugsw9q01</sha1>
    </revision>
    <revision>
      <id>655</id>
      <parentid>654</parentid>
      <timestamp>2024-09-18T15:38:04Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <origin>655</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1699" sha1="j6w8q1v3pehrz6nv5qzwcf2zx7xxr5z" xml:space="preserve">'''Kukhona''' ezinye izinto ezijamele ikhamphani nanyana umkhiqizo othize, ezifana njetshwayo, isithombe kanye nelogo. Izinto lezi zakhiwe ngedlela yokuthi zinikele umlayezo nanyana umniningwana kilabo abaqothelweko. Nanyana kunjalo-ke, ngaphasi kwesihloko sethi lesi sizokunzinza kwi-logo.  

I-Cambridge Dictionary (2024)&lt;ref name=&quot;:0&quot;&gt;Cambridge Dictionary. (2024b). ‘Logo’. Available at:&lt;https://dictionary.cambridge.org/dictionary/english/logo&gt;. Accessed on [9 January 2024].&lt;/ref&gt; ne-Wikipedia (2024)&lt;ref&gt;Wikipedia. 2024. Logo. Litholakala ku:&lt;https://en.wikipedia.org/wiki/Logo&gt;. Ifunyenwe ngomhlaka [09 ngoTjhirhweni 2024].&lt;/ref&gt; iqinisekisa iphuzu elingehla leli ngokuveza bona, i-logo litshwayo leli elisetjenziswa yikhamphani emikhiqizweni yalo ukuthuthukisa ubujamo nomkhiqizo walo begodu nokwenza isiqiniseko sokuthi amakhastama wayo ayibona bekayikhumbule msinya ikhamphani le.  I-[https://dictionary.cambridge.org/dictionary/english/logo logo] yekhaphani ingasetjenziswa kunanyana ngimuphi umkhiqizo kanye nezinto zekhamphani okufaka hlangana imakhiwo, iinkoloyi neesentjenziswa ukuze abantu bazi bonyana izinto lezo ngezabo.  

Abasebenzisi, abathengi nanyana abanikeli ngemisebenzi bazokuqala ibizo nanyana i-[[:en:Logo|logo]] yekhamphani ukuze bakwazi ukuhlukanisa imikhiqizo yekhamphani leyo neminye imikhiqizo yeenkhaphani eziphalisana nayo.  I-logo ibuye yazise abasebenzisi ngokwazeka nokuduma kwabo  nangendlela abaziwa ngayo emphakathini (Cambridge Dictionary 2024&lt;ref name=&quot;:0&quot; /&gt;). Lokho kuzokwenza kobana balemuke kobana yikhamphani nanyana umsebenzi nanyana umuntu onendumela, okuzokwenza kobana imikhiqhizo leyo ithengwe khudlwana.

== Isilululwazi ==
&lt;references /&gt;
</text>
      <sha1>j6w8q1v3pehrz6nv5qzwcf2zx7xxr5z</sha1>
    </revision>
    <revision>
      <id>656</id>
      <parentid>655</parentid>
      <timestamp>2024-10-14T13:46:40Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>4 revisions imported</comment>
      <origin>655</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1699" sha1="j6w8q1v3pehrz6nv5qzwcf2zx7xxr5z" xml:space="preserve">'''Kukhona''' ezinye izinto ezijamele ikhamphani nanyana umkhiqizo othize, ezifana njetshwayo, isithombe kanye nelogo. Izinto lezi zakhiwe ngedlela yokuthi zinikele umlayezo nanyana umniningwana kilabo abaqothelweko. Nanyana kunjalo-ke, ngaphasi kwesihloko sethi lesi sizokunzinza kwi-logo.  

I-Cambridge Dictionary (2024)&lt;ref name=&quot;:0&quot;&gt;Cambridge Dictionary. (2024b). ‘Logo’. Available at:&lt;https://dictionary.cambridge.org/dictionary/english/logo&gt;. Accessed on [9 January 2024].&lt;/ref&gt; ne-Wikipedia (2024)&lt;ref&gt;Wikipedia. 2024. Logo. Litholakala ku:&lt;https://en.wikipedia.org/wiki/Logo&gt;. Ifunyenwe ngomhlaka [09 ngoTjhirhweni 2024].&lt;/ref&gt; iqinisekisa iphuzu elingehla leli ngokuveza bona, i-logo litshwayo leli elisetjenziswa yikhamphani emikhiqizweni yalo ukuthuthukisa ubujamo nomkhiqizo walo begodu nokwenza isiqiniseko sokuthi amakhastama wayo ayibona bekayikhumbule msinya ikhamphani le.  I-[https://dictionary.cambridge.org/dictionary/english/logo logo] yekhaphani ingasetjenziswa kunanyana ngimuphi umkhiqizo kanye nezinto zekhamphani okufaka hlangana imakhiwo, iinkoloyi neesentjenziswa ukuze abantu bazi bonyana izinto lezo ngezabo.  

Abasebenzisi, abathengi nanyana abanikeli ngemisebenzi bazokuqala ibizo nanyana i-[[:en:Logo|logo]] yekhamphani ukuze bakwazi ukuhlukanisa imikhiqizo yekhamphani leyo neminye imikhiqizo yeenkhaphani eziphalisana nayo.  I-logo ibuye yazise abasebenzisi ngokwazeka nokuduma kwabo  nangendlela abaziwa ngayo emphakathini (Cambridge Dictionary 2024&lt;ref name=&quot;:0&quot; /&gt;). Lokho kuzokwenza kobana balemuke kobana yikhamphani nanyana umsebenzi nanyana umuntu onendumela, okuzokwenza kobana imikhiqhizo leyo ithengwe khudlwana.

== Isilululwazi ==
&lt;references /&gt;
</text>
      <sha1>j6w8q1v3pehrz6nv5qzwcf2zx7xxr5z</sha1>
    </revision>
    <revision>
      <id>2929</id>
      <parentid>656</parentid>
      <timestamp>2025-06-06T17:09:33Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>Che</comment>
      <origin>2929</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="77" sha1="bg5p5hoi7f9q8jmxb9f6hnfuri7ll8w" xml:space="preserve">Cesar Chavez helped Mexican-Americans fight for their rights.  &lt;references /&gt;</text>
      <sha1>bg5p5hoi7f9q8jmxb9f6hnfuri7ll8w</sha1>
    </revision>
    <revision>
      <id>2931</id>
      <parentid>2929</parentid>
      <timestamp>2025-06-06T17:10:57Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>call it vandalism (rhymes with grug)</comment>
      <origin>2931</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="164" sha1="36sqjoa5j86pbu6vsdnzrlg9g8f50ad" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.''' Cesar Chavez helped Mexican-Americans fight for their rights.  &lt;references /&gt;</text>
      <sha1>36sqjoa5j86pbu6vsdnzrlg9g8f50ad</sha1>
    </revision>
    <revision>
      <id>3100</id>
      <parentid>2931</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edits by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Jon Harald Søby|Jon Harald Søby]]</comment>
      <origin>655</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1699" sha1="j6w8q1v3pehrz6nv5qzwcf2zx7xxr5z" xml:space="preserve">'''Kukhona''' ezinye izinto ezijamele ikhamphani nanyana umkhiqizo othize, ezifana njetshwayo, isithombe kanye nelogo. Izinto lezi zakhiwe ngedlela yokuthi zinikele umlayezo nanyana umniningwana kilabo abaqothelweko. Nanyana kunjalo-ke, ngaphasi kwesihloko sethi lesi sizokunzinza kwi-logo.  

I-Cambridge Dictionary (2024)&lt;ref name=&quot;:0&quot;&gt;Cambridge Dictionary. (2024b). ‘Logo’. Available at:&lt;https://dictionary.cambridge.org/dictionary/english/logo&gt;. Accessed on [9 January 2024].&lt;/ref&gt; ne-Wikipedia (2024)&lt;ref&gt;Wikipedia. 2024. Logo. Litholakala ku:&lt;https://en.wikipedia.org/wiki/Logo&gt;. Ifunyenwe ngomhlaka [09 ngoTjhirhweni 2024].&lt;/ref&gt; iqinisekisa iphuzu elingehla leli ngokuveza bona, i-logo litshwayo leli elisetjenziswa yikhamphani emikhiqizweni yalo ukuthuthukisa ubujamo nomkhiqizo walo begodu nokwenza isiqiniseko sokuthi amakhastama wayo ayibona bekayikhumbule msinya ikhamphani le.  I-[https://dictionary.cambridge.org/dictionary/english/logo logo] yekhaphani ingasetjenziswa kunanyana ngimuphi umkhiqizo kanye nezinto zekhamphani okufaka hlangana imakhiwo, iinkoloyi neesentjenziswa ukuze abantu bazi bonyana izinto lezo ngezabo.  

Abasebenzisi, abathengi nanyana abanikeli ngemisebenzi bazokuqala ibizo nanyana i-[[:en:Logo|logo]] yekhamphani ukuze bakwazi ukuhlukanisa imikhiqizo yekhamphani leyo neminye imikhiqizo yeenkhaphani eziphalisana nayo.  I-logo ibuye yazise abasebenzisi ngokwazeka nokuduma kwabo  nangendlela abaziwa ngayo emphakathini (Cambridge Dictionary 2024&lt;ref name=&quot;:0&quot; /&gt;). Lokho kuzokwenza kobana balemuke kobana yikhamphani nanyana umsebenzi nanyana umuntu onendumela, okuzokwenza kobana imikhiqhizo leyo ithengwe khudlwana.

== Isilululwazi ==
&lt;references /&gt;
</text>
      <sha1>j6w8q1v3pehrz6nv5qzwcf2zx7xxr5z</sha1>
    </revision>
  </page>
  <page>
    <title>IFUNDO</title>
    <ns>0</ns>
    <id>136</id>
    <revision>
      <id>660</id>
      <timestamp>2024-03-09T10:49:22Z</timestamp>
      <contributor>
        <username>incubator&gt;JesicaMasilela17</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;[[Isimumathi:Deus High School Diplome.png|thumb|136x136px]] '''IFUNDO''' Kusilodhlelo esivula iminyango eminengi ephumelelisako. Ngingatjho bonyana ifundo iyayitjhugulula impilo zabantu begodu ayikhathi bala, nakuyi badlhululo ayinayo eyamukela nanyana ngubani begodu ayikhethi neminyaka. Ifundo iyakhana begodu ifundisa nokunengi. [[Ifundo]] iyonqopha mlandu epilweni zabantu, uthola bonyana abanye badobha phasi emakhabo kodwana ngobanyana baqiniselele efundweni baq...&quot;</comment>
      <origin>660</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1256" sha1="5qia4elz5wu55ox1p4xum6zf7cjyfk6" xml:space="preserve">[[Isimumathi:Deus High School Diplome.png|thumb|136x136px]]
'''IFUNDO''' Kusilodhlelo esivula iminyango eminengi ephumelelisako. Ngingatjho bonyana ifundo iyayitjhugulula impilo zabantu begodu ayikhathi bala, nakuyi badlhululo ayinayo eyamukela nanyana ngubani begodu ayikhethi neminyaka. Ifundo iyakhana begodu ifundisa nokunengi.
[[Ifundo]] iyonqopha mlandu epilweni zabantu, uthola bonyana abanye badobha phasi emakhabo kodwana ngobanyana baqiniselele efundweni baqcina baphumelele. 


UMLANDO WEFENDO

Okukhulu okukarisa khulu nge Fundo kukobana siyinama thuba amanengi wokuthuthukela phambili ngefundo yakho, Siyazi lokha umuntu bekangakhoni ukuqhubekela phambili ngefundo zakhe ngobanyana ekhabo banganamali yokumusa eskolweni samabanga aphezulu kodwana nje izinto sezaba lula sekunemfundazwe ekuyi [[NSFAS]], SETA, [[Fundza Lushaka]] nezinye ezinengi

[[Isimumathi:Guide to the Ohio graduation tests for students and families reading, mathematics, writing, science, and social studies. - DPLA - 40fb5773c1ce60aef6478def3fc2ef00.jpg|left|thumb|192x192px|IImfundiswa zithola imitlomela yabo (Degree)]]
Namhlanje sinabo Titjhere, Dorhodere, amaQhwetha, abosoSiyense ngeqaye yefundo.Ngingatjho bonyana Ifundo iyamakha umuntu imenze umuntu ebantwini.



</text>
      <sha1>5qia4elz5wu55ox1p4xum6zf7cjyfk6</sha1>
    </revision>
    <revision>
      <id>661</id>
      <parentid>660</parentid>
      <timestamp>2024-05-10T07:28:11Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>661</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1325" sha1="81ov6e9ekdv1kcun3yy6jmbodikpf67" xml:space="preserve">[[Isimumathi:Deus High School Diplome.png|thumb|136x136px]]
'''IFUNDO'''  

Ifundo kusilodlhelo esivula iminyango eminengi ephumelelisako. Ngingatjho bonyana ifundo iyayitjhugulula ipilo yabantu begodu ayikhethi umbala. Ukuragela phambili, ibandlululo lona  ayilayo, yamukela nanyana ngubani begodu ayikhethi neminyaka. Ifundo iyakhana begodu ifundisa nokunengi.
 
[[Ifundo]] yakha mlandu omutjha epilweni yabantu. Nakungenzeka bonyana ukhule udobha phasi kodwana ngebanga lefundo bagcine baphumelela. 

Okukhulu okukarisa khulu ngefundo kukobana inamathuba amanengi wokukuthuthusela phambili epilweni yakho. Siyazi lokha umuntu bekangakghoni ukuragela phambili ngefundo yakhe ngobanyana ekhabo banganamali yokumusa eskolweni samabanga aphezulu iinhlangano ezifana ne-[[NSFAS]], SETA, [[Fundza Lushaka|ne-Fundza Lushaka]] siyakusiza ngemali nemifundaze.

[[Isimumathi:Guide to the Ohio graduation tests for students and families reading, mathematics, writing, science, and social studies. - DPLA - 40fb5773c1ce60aef6478def3fc2ef00.jpg|left|thumb|192x192px|IImfundiswa zithola imitlomela yabo (Degree)]]
Namhlanje sinabotitjhere, dorhodere, amaqhwetha, abososayensi ngayo ifundo.Ngingatjho bonyana Ifundo iyamakha umuntu imenze umuntu ebantwini. Lokhu kutjengisa ukuqakatheka kwefundo kanye nezinto umuntu ongazizuza kiyo.



</text>
      <sha1>81ov6e9ekdv1kcun3yy6jmbodikpf67</sha1>
    </revision>
    <revision>
      <id>662</id>
      <parentid>661</parentid>
      <timestamp>2024-10-14T13:46:40Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>661</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1325" sha1="81ov6e9ekdv1kcun3yy6jmbodikpf67" xml:space="preserve">[[Isimumathi:Deus High School Diplome.png|thumb|136x136px]]
'''IFUNDO'''  

Ifundo kusilodlhelo esivula iminyango eminengi ephumelelisako. Ngingatjho bonyana ifundo iyayitjhugulula ipilo yabantu begodu ayikhethi umbala. Ukuragela phambili, ibandlululo lona  ayilayo, yamukela nanyana ngubani begodu ayikhethi neminyaka. Ifundo iyakhana begodu ifundisa nokunengi.
 
[[Ifundo]] yakha mlandu omutjha epilweni yabantu. Nakungenzeka bonyana ukhule udobha phasi kodwana ngebanga lefundo bagcine baphumelela. 

Okukhulu okukarisa khulu ngefundo kukobana inamathuba amanengi wokukuthuthusela phambili epilweni yakho. Siyazi lokha umuntu bekangakghoni ukuragela phambili ngefundo yakhe ngobanyana ekhabo banganamali yokumusa eskolweni samabanga aphezulu iinhlangano ezifana ne-[[NSFAS]], SETA, [[Fundza Lushaka|ne-Fundza Lushaka]] siyakusiza ngemali nemifundaze.

[[Isimumathi:Guide to the Ohio graduation tests for students and families reading, mathematics, writing, science, and social studies. - DPLA - 40fb5773c1ce60aef6478def3fc2ef00.jpg|left|thumb|192x192px|IImfundiswa zithola imitlomela yabo (Degree)]]
Namhlanje sinabotitjhere, dorhodere, amaqhwetha, abososayensi ngayo ifundo.Ngingatjho bonyana Ifundo iyamakha umuntu imenze umuntu ebantwini. Lokhu kutjengisa ukuqakatheka kwefundo kanye nezinto umuntu ongazizuza kiyo.



</text>
      <sha1>81ov6e9ekdv1kcun3yy6jmbodikpf67</sha1>
    </revision>
  </page>
  <page>
    <title>IKapa ne-Cape (Cape and Cape).</title>
    <ns>0</ns>
    <id>137</id>
    <revision>
      <id>663</id>
      <timestamp>2024-08-07T05:53:35Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;== IKapa ne-Cape (Cape and Cape) ==  === Isingeniso === IKapa ne-Cape magama lawo apeledwa bekaphinyiswe ngokufana elimi lesiNgisi kodwana ihlathululo yawo ayifani. Singatjho bonyana kumagama abomphimbofana njengoba ahluka ngehlathululo kwaphela. Esigajeni esilandelako sizokutjheja bonyana amagama la atjho ukuthini.  === IKapa === IKapa kuyihlokodorobha yesifunda seTjhingala Kapa. Ukungezelela, iTjhingala Kapa kungesinye sesifunda esitholakala eSewula Afrika. IKapa le it...&quot;</comment>
      <origin>663</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1307" sha1="tqnfzshm1i4wjprgx5oh4vmd1gsd91s" xml:space="preserve">== IKapa ne-Cape (Cape and Cape) ==

=== Isingeniso ===
IKapa ne-Cape magama lawo apeledwa bekaphinyiswe ngokufana elimi lesiNgisi kodwana ihlathululo yawo ayifani. Singatjho bonyana kumagama abomphimbofana njengoba ahluka ngehlathululo kwaphela. Esigajeni esilandelako sizokutjheja bonyana amagama la atjho ukuthini.

=== IKapa ===
IKapa kuyihlokodorobha yesifunda seTjhingala Kapa. Ukungezelela, iTjhingala Kapa kungesinye sesifunda esitholakala eSewula Afrika. IKapa le itjho indawo esesewula, begodu la itjho idoroba elisesewula yeSewula Afrika.

=== I-Cape ===
I-Cape yona kuligama lelo elihlathulula bonyana into ethize ivele esewula yephasi, khulukhulu nasitjheja iinlwani neenyoni. Ngamanye amagama nawuqala ibalazwe, iinyoni nelwani lezo zifunyaneka khulu lapaha eSewula yephasi. Isibonelo kukhona i-Cape Baffalo (ikomo yommango). I-Cape Baffalo le ayitjho bona ivela edorobheni iKapa kodwana itjho bonyana yikomo yommango etholakala khulu esewula yephasi. Ngalokho-ke, lokha nasibona igama lesilwani nanyana inyoni elimo-Cape kufanele sikhumbule bonyana inyoni nanyana isilwani leso sitholakala khulu esewula yephasi.

=== Isiphetho ===
Ikapa ne-Cape zingapeledwa beziphinyiswe kokufana ngesiNgisi kodwana zona zitjho izinto ezingafani. Kuhle bonyana siziyelele khulu ngaphambi kokuzisebenzisa.  </text>
      <sha1>tqnfzshm1i4wjprgx5oh4vmd1gsd91s</sha1>
    </revision>
    <revision>
      <id>664</id>
      <parentid>663</parentid>
      <timestamp>2024-09-19T08:51:38Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <origin>664</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1309" sha1="m5cffhtg98h8mqneao4d86x4fasbljb" xml:space="preserve">== IKapa ne-Cape (Cape and Cape). ==

=== Isingeniso. ===
IKapa ne-Cape magama lawo apeledwa bekaphinyiswe ngokufana elimi lesiNgisi kodwana ihlathululo yawo ayifani. Singatjho bonyana kumagama abomphimbofana njengoba ahluka ngehlathululo kwaphela. Esigajeni esilandelako sizokutjheja bonyana amagama la atjho ukuthini.

=== IKapa ===
IKapa kuyihlokodorobha yesifunda seTjhingala Kapa. Ukungezelela, iTjhingala Kapa kungesinye sesifunda esitholakala eSewula Afrika. IKapa le itjho indawo esesewula, begodu la itjho idoroba elisesewula yeSewula Afrika.

=== I-Cape ===
I-Cape yona kuligama lelo elihlathulula bonyana into ethize ivele esewula yephasi, khulukhulu nasitjheja iinlwani neenyoni. Ngamanye amagama nawuqala ibalazwe, iinyoni nelwani lezo zifunyaneka khulu lapaha eSewula yephasi. Isibonelo kukhona i-Cape Baffalo (ikomo yommango). I-Cape Baffalo le ayitjho bona ivela edorobheni iKapa kodwana itjho bonyana yikomo yommango etholakala khulu esewula yephasi. Ngalokho-ke, lokha nasibona igama lesilwani nanyana inyoni elimo-Cape kufanele sikhumbule bonyana inyoni nanyana isilwani leso sitholakala khulu esewula yephasi.

=== Isiphetho ===
Ikapa ne-Cape zingapeledwa beziphinyiswe kokufana ngesiNgisi kodwana zona zitjho izinto ezingafani. Kuhle bonyana siziyelele khulu ngaphambi kokuzisebenzisa.  </text>
      <sha1>m5cffhtg98h8mqneao4d86x4fasbljb</sha1>
    </revision>
    <revision>
      <id>665</id>
      <parentid>664</parentid>
      <timestamp>2024-10-14T13:46:41Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>664</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1309" sha1="m5cffhtg98h8mqneao4d86x4fasbljb" xml:space="preserve">== IKapa ne-Cape (Cape and Cape). ==

=== Isingeniso. ===
IKapa ne-Cape magama lawo apeledwa bekaphinyiswe ngokufana elimi lesiNgisi kodwana ihlathululo yawo ayifani. Singatjho bonyana kumagama abomphimbofana njengoba ahluka ngehlathululo kwaphela. Esigajeni esilandelako sizokutjheja bonyana amagama la atjho ukuthini.

=== IKapa ===
IKapa kuyihlokodorobha yesifunda seTjhingala Kapa. Ukungezelela, iTjhingala Kapa kungesinye sesifunda esitholakala eSewula Afrika. IKapa le itjho indawo esesewula, begodu la itjho idoroba elisesewula yeSewula Afrika.

=== I-Cape ===
I-Cape yona kuligama lelo elihlathulula bonyana into ethize ivele esewula yephasi, khulukhulu nasitjheja iinlwani neenyoni. Ngamanye amagama nawuqala ibalazwe, iinyoni nelwani lezo zifunyaneka khulu lapaha eSewula yephasi. Isibonelo kukhona i-Cape Baffalo (ikomo yommango). I-Cape Baffalo le ayitjho bona ivela edorobheni iKapa kodwana itjho bonyana yikomo yommango etholakala khulu esewula yephasi. Ngalokho-ke, lokha nasibona igama lesilwani nanyana inyoni elimo-Cape kufanele sikhumbule bonyana inyoni nanyana isilwani leso sitholakala khulu esewula yephasi.

=== Isiphetho ===
Ikapa ne-Cape zingapeledwa beziphinyiswe kokufana ngesiNgisi kodwana zona zitjho izinto ezingafani. Kuhle bonyana siziyelele khulu ngaphambi kokuzisebenzisa.  </text>
      <sha1>m5cffhtg98h8mqneao4d86x4fasbljb</sha1>
    </revision>
  </page>
  <page>
    <title>IMIDLALO YABENTWANA</title>
    <ns>0</ns>
    <id>138</id>
    <revision>
      <id>666</id>
      <timestamp>2024-03-08T13:29:35Z</timestamp>
      <contributor>
        <username>incubator&gt;Napangela</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;Imidlalo yabentwana   Imidlalo yabentwana midlalo edlaliwa bentwana abangaphasi kweminyaka elitjhumi nambili. Imidlalo le ihlukaniseke kabili. Kunemidlalo yabesena kanye nomdlalo wabentazana. Imidlalo le ihlukaniseke ngendlella abantu bekadeni bebaphila ngayo. Abesana bebadlala ngeenkoloyi nofana ngamadrada, bese abentazana bebadlala ngokupheka nofana igqubsi.   Imidlalo le irhelebha abentwana ngamakghono wepilo. Amakghono wepilo afaka hlangana nekghono lokuphila nabantu...&quot;</comment>
      <origin>666</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="983" sha1="46qcoqg72prhulw69qgp7t8ps8i03f3" xml:space="preserve">Imidlalo yabentwana 

Imidlalo yabentwana midlalo edlaliwa bentwana abangaphasi kweminyaka elitjhumi nambili. Imidlalo le ihlukaniseke kabili. Kunemidlalo yabesena kanye nomdlalo wabentazana. Imidlalo le ihlukaniseke ngendlella abantu bekadeni bebaphila ngayo. Abesana bebadlala ngeenkoloyi nofana ngamadrada, bese abentazana bebadlala ngokupheka nofana igqubsi. 

Imidlalo le irhelebha abentwana ngamakghono wepilo. Amakghono wepilo afaka hlangana nekghono lokuphila nabantu, ingqondo nokhunye. Abentwana abadlala imidlalo ehlukahlukeneko bayakghona ukuthuthuka nangamakghono welimi: Ukukhuluma nokulalela, ukufunda nokubhala. Amakghono la abalulekile ekusizeni abentwana bonyana babebafundi abanqophileko epilweni yangomuso. 

Abotitjhere kufanele bafake imidlalo ehlukahlukeneko lokha nabafundisa okuthileko. Imidlalo eminengi ikhuthaza bafundi bafunde ngokuzimisela nangethando. Imidlalo engadlaliwa ngekumbeni yokufundela midlalo efana nokweqa lokha nakubizwa umdumo weledere.

</text>
      <sha1>46qcoqg72prhulw69qgp7t8ps8i03f3</sha1>
    </revision>
    <revision>
      <id>667</id>
      <parentid>666</parentid>
      <timestamp>2024-03-08T13:49:54Z</timestamp>
      <contributor>
        <username>incubator&gt;Napangela</username>
        <id>0</id>
      </contributor>
      <comment>new article</comment>
      <origin>667</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="989" sha1="qij20abany97qja1t1ml4nf04er3fj8" xml:space="preserve">'''Imidlalo yabentwana''' 

Imidlalo yabentwana midlalo edlaliwa bentwana abangaphasi kweminyaka elitjhumi nambili. Imidlalo le ihlukaniseke kabili. Kunemidlalo yabesena kanye nomdlalo wabentazana. Imidlalo le ihlukaniseke ngendlella abantu bekadeni bebaphila ngayo. Abesana bebadlala ngeenkoloyi nofana ngamadrada, bese abentazana bebadlala ngokupheka nofana igqubsi. 

Imidlalo le irhelebha abentwana ngamakghono wepilo. Amakghono wepilo afaka hlangana nekghono lokuphila nabantu, ingqondo nokhunye. Abentwana abadlala imidlalo ehlukahlukeneko bayakghona ukuthuthuka nangamakghono welimi: Ukukhuluma nokulalela, ukufunda nokubhala. Amakghono la abalulekile ekusizeni abentwana bonyana babebafundi abanqophileko epilweni yangomuso. 

Abotitjhere kufanele bafake imidlalo ehlukahlukeneko lokha nabafundisa okuthileko. Imidlalo eminengi ikhuthaza bafundi bafunde ngokuzimisela nangethando. Imidlalo engadlaliwa ngekumbeni yokufundela midlalo efana nokweqa lokha nakubizwa umdumo weledere.

</text>
      <sha1>qij20abany97qja1t1ml4nf04er3fj8</sha1>
    </revision>
    <revision>
      <id>668</id>
      <parentid>667</parentid>
      <timestamp>2024-03-09T07:34:06Z</timestamp>
      <contributor>
        <username>incubator&gt;Napangela</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>668</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1103" sha1="c9wvxezxkfttphojhw3z0v7pbtirsm7" xml:space="preserve"> 

'''Imidlalo yabentwana''' midlalo edlaliwa bentwana abangaphasi kweminyaka elitjhumi nambili. Imidlalo le ihlukaniseke kabili. Kunemidlalo yabesena kanye nomdlalo wabentazana. Imidlalo le ihlukaniseke ngendlella abantu bekadeni bebaphila ngayo. [[Abesana]] bebadlala ngeenkoloyi nofana ngamadrada, bese [[abentazana]] bebadlala ngokupheka nofana igqubsi. 

== Isiza ngani imidlalo yabentwana? ==
Imidlalo le irhelebha abentwana ngamakghono wepilo. [[Amakghono wepilo]] afaka hlangana nekghono lokuphila nabantu, ingqondo nokhunye. Abentwana abadlala imidlalo ehlukahlukeneko bayakghona ukuthuthuka nangamakghono welimi: [[Ukukhuluma nokulalela,]] ukufunda nokubhala. [[Amakghono]] la abalulekile ekusizeni abentwana bonyana babebafundi abanqophileko epilweni yangomuso. 

== Kubayini abotitjhere kufanele babenelwazi ngomdlalo wabentwana? ==
Abotitjhere kufanele bafake imidlalo ehlukahlukeneko lokha nabafundisa okuthileko. Imidlalo eminengi ikhuthaza bafundi bafunde ngokuzimisela nangethando. Imidlalo engadlaliwa ngekumbeni yokufundela midlalo efana nokweqa lokha nakubizwa [[umdumo weledere.]]

</text>
      <sha1>c9wvxezxkfttphojhw3z0v7pbtirsm7</sha1>
    </revision>
    <revision>
      <id>669</id>
      <parentid>668</parentid>
      <timestamp>2024-03-09T08:20:07Z</timestamp>
      <contributor>
        <username>incubator&gt;JesicaMasilela17</username>
        <id>0</id>
      </contributor>
      <origin>669</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1150" sha1="59i3c5uhjp6926x9vplezxfcag7ydrp" xml:space="preserve">[[Isimumathi:Children's games in iran.jpg|thumb]]
'''Imidlalo yabentwana''' midlalo edlaliwa bentwana abangaphasi kweminyaka elitjhumi nambili. Imidlalo le ihlukaniseke kabili. Kunemidlalo yabesena kanye nomdlalo wabentazana. Imidlalo le ihlukaniseke ngendlella abantu bekadeni bebaphila ngayo. [[Abesana]] bebadlala ngeenkoloyi nofana ngamadrada, bese [[abentazana]] bebadlala ngokupheka nofana igqubsi. 

== Isiza ngani imidlalo yabentwana? ==
Imidlalo le irhelebha abentwana ngamakghono wepilo. [[Amakghono wepilo]] afaka hlangana nekghono lokuphila nabantu, ingqondo nokhunye. Abentwana abadlala imidlalo ehlukahlukeneko bayakghona ukuthuthuka nangamakghono welimi: [[Ukukhuluma nokulalela,]] ukufunda nokubhala. [[Amakghono]] la abalulekile ekusizeni abentwana bonyana babebafundi abanqophileko epilweni yangomuso. 

== Kubayini abotitjhere kufanele babenelwazi ngomdlalo wabentwana? ==
Abotitjhere kufanele bafake imidlalo ehlukahlukeneko lokha nabafundisa okuthileko. Imidlalo eminengi ikhuthaza bafundi bafunde ngokuzimisela nangethando. Imidlalo engadlaliwa ngekumbeni yokufundela midlalo efana nokweqa lokha nakubizwa [[umdumo weledere.]]

</text>
      <sha1>59i3c5uhjp6926x9vplezxfcag7ydrp</sha1>
    </revision>
    <revision>
      <id>670</id>
      <parentid>669</parentid>
      <timestamp>2024-10-14T13:46:41Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>4 revisions imported</comment>
      <origin>669</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1150" sha1="59i3c5uhjp6926x9vplezxfcag7ydrp" xml:space="preserve">[[Isimumathi:Children's games in iran.jpg|thumb]]
'''Imidlalo yabentwana''' midlalo edlaliwa bentwana abangaphasi kweminyaka elitjhumi nambili. Imidlalo le ihlukaniseke kabili. Kunemidlalo yabesena kanye nomdlalo wabentazana. Imidlalo le ihlukaniseke ngendlella abantu bekadeni bebaphila ngayo. [[Abesana]] bebadlala ngeenkoloyi nofana ngamadrada, bese [[abentazana]] bebadlala ngokupheka nofana igqubsi. 

== Isiza ngani imidlalo yabentwana? ==
Imidlalo le irhelebha abentwana ngamakghono wepilo. [[Amakghono wepilo]] afaka hlangana nekghono lokuphila nabantu, ingqondo nokhunye. Abentwana abadlala imidlalo ehlukahlukeneko bayakghona ukuthuthuka nangamakghono welimi: [[Ukukhuluma nokulalela,]] ukufunda nokubhala. [[Amakghono]] la abalulekile ekusizeni abentwana bonyana babebafundi abanqophileko epilweni yangomuso. 

== Kubayini abotitjhere kufanele babenelwazi ngomdlalo wabentwana? ==
Abotitjhere kufanele bafake imidlalo ehlukahlukeneko lokha nabafundisa okuthileko. Imidlalo eminengi ikhuthaza bafundi bafunde ngokuzimisela nangethando. Imidlalo engadlaliwa ngekumbeni yokufundela midlalo efana nokweqa lokha nakubizwa [[umdumo weledere.]]

</text>
      <sha1>59i3c5uhjp6926x9vplezxfcag7ydrp</sha1>
    </revision>
  </page>
  <page>
    <title>IMonkeypox</title>
    <ns>0</ns>
    <id>139</id>
    <revision>
      <id>671</id>
      <timestamp>2024-06-30T17:04:51Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''IMonkeypox''' kugula okuthileko  okuhlasela abantu.ESewula Afrika sele kunabantu ababanjwe sisifo lesi. Kusisifo esivela eenlwaneni sibambe abantu. sithoma ngokuthi umuntu aphathwe mkhuhlani, ihloko, avuvuke imisipha begodu avele iratjhi emzimbeni kuthi ngokukhmba kwesikhathi aphume iinlonda eziphuma amanzi.  &quot;</comment>
      <origin>671</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="314" sha1="0dswlb3cyq0ypkvkav029aiq98tohdy" xml:space="preserve">'''IMonkeypox''' kugula okuthileko  okuhlasela abantu.ESewula Afrika sele kunabantu ababanjwe sisifo lesi. Kusisifo esivela eenlwaneni sibambe abantu. sithoma ngokuthi umuntu aphathwe mkhuhlani, ihloko, avuvuke imisipha begodu avele iratjhi emzimbeni kuthi ngokukhmba kwesikhathi aphume iinlonda eziphuma amanzi.

</text>
      <sha1>0dswlb3cyq0ypkvkav029aiq98tohdy</sha1>
    </revision>
    <revision>
      <id>672</id>
      <parentid>671</parentid>
      <timestamp>2024-07-05T16:21:42Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>672</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="377" sha1="aq6l95mrv8ps9vzmo6ksia7vgcuu8wz" xml:space="preserve">[[Isimumathi:Monkeypox.jpg|thumb|Umuntu obanjwe yi Monkeypox]]
'''IMonkeypox''' kugula okuthileko  okuhlasela abantu.ESewula Afrika sele kunabantu ababanjwe sisifo lesi. Kusisifo esivela eenlwaneni sibambe abantu. sithoma ngokuthi umuntu aphathwe mkhuhlani, ihloko, avuvuke imisipha begodu avele iratjhi emzimbeni kuthi ngokukhmba kwesikhathi aphume iinlonda eziphuma amanzi.

</text>
      <sha1>aq6l95mrv8ps9vzmo6ksia7vgcuu8wz</sha1>
    </revision>
    <revision>
      <id>673</id>
      <parentid>672</parentid>
      <timestamp>2024-07-15T08:34:54Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>673</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="580" sha1="puptv3pjlsxtt74qmmvfdleohaq6jde" xml:space="preserve">[[Isimumathi:Monkeypox.jpg|thumb|Umuntu obanjwe yi Monkeypox]]
'''IMonkeypox''' kugula okuthileko  okuhlasela abantu.ESewula Afrika sele kunabantu ababanjwe sisifo lesi. Kusisifo esivela eenlwaneni sibambe abantu. sithoma ngokuthi umuntu aphathwe mkhuhlani, ihloko, avuvuke imisipha begodu avele iratjhi emzimbeni kuthi ngokukhmba kwesikhathi aphume iinlonda eziphuma amanzi.

Uvikela njani ukubhebhetheka kwe monkeypox

I Monkeypox ingavikelwa ngokuthi lokha umuntu nakazi bona bonyana unamaphawu wokuthi kungeka abanjwe sisifo lesi bese avakatjhele emtholapilo ukuthola isizo.

</text>
      <sha1>puptv3pjlsxtt74qmmvfdleohaq6jde</sha1>
    </revision>
    <revision>
      <id>674</id>
      <parentid>673</parentid>
      <timestamp>2024-09-25T13:54:02Z</timestamp>
      <contributor>
        <username>Nintendofan885</username>
        <id>5</id>
      </contributor>
      <minor />
      <comment>Adding interwiki links to [[d:Q382370]]</comment>
      <origin>674</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="602" sha1="au3cbeayl10ow4ku3hnz8rkfqg8x341" xml:space="preserve">[[Isimumathi:Monkeypox.jpg|thumb|Umuntu obanjwe yi Monkeypox]]
'''IMonkeypox''' kugula okuthileko  okuhlasela abantu.ESewula Afrika sele kunabantu ababanjwe sisifo lesi. Kusisifo esivela eenlwaneni sibambe abantu. sithoma ngokuthi umuntu aphathwe mkhuhlani, ihloko, avuvuke imisipha begodu avele iratjhi emzimbeni kuthi ngokukhmba kwesikhathi aphume iinlonda eziphuma amanzi.

Uvikela njani ukubhebhetheka kwe monkeypox

I Monkeypox ingavikelwa ngokuthi lokha umuntu nakazi bona bonyana unamaphawu wokuthi kungeka abanjwe sisifo lesi bese avakatjhele emtholapilo ukuthola isizo.


{{INTERWIKI|Q382370}}</text>
      <sha1>au3cbeayl10ow4ku3hnz8rkfqg8x341</sha1>
    </revision>
    <revision>
      <id>675</id>
      <parentid>674</parentid>
      <timestamp>2024-10-14T13:46:41Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>4 revisions imported</comment>
      <origin>674</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="602" sha1="au3cbeayl10ow4ku3hnz8rkfqg8x341" xml:space="preserve">[[Isimumathi:Monkeypox.jpg|thumb|Umuntu obanjwe yi Monkeypox]]
'''IMonkeypox''' kugula okuthileko  okuhlasela abantu.ESewula Afrika sele kunabantu ababanjwe sisifo lesi. Kusisifo esivela eenlwaneni sibambe abantu. sithoma ngokuthi umuntu aphathwe mkhuhlani, ihloko, avuvuke imisipha begodu avele iratjhi emzimbeni kuthi ngokukhmba kwesikhathi aphume iinlonda eziphuma amanzi.

Uvikela njani ukubhebhetheka kwe monkeypox

I Monkeypox ingavikelwa ngokuthi lokha umuntu nakazi bona bonyana unamaphawu wokuthi kungeka abanjwe sisifo lesi bese avakatjhele emtholapilo ukuthola isizo.


{{INTERWIKI|Q382370}}</text>
      <sha1>au3cbeayl10ow4ku3hnz8rkfqg8x341</sha1>
    </revision>
    <revision>
      <id>1669</id>
      <parentid>675</parentid>
      <timestamp>2024-10-16T09:49:51Z</timestamp>
      <contributor>
        <username>JhsBot</username>
        <id>34</id>
      </contributor>
      <minor />
      <comment>bot: Removing interwiki template; the page is now connected to [[d:Q382370]]</comment>
      <origin>1669</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="578" sha1="a9jzhdoxk3zau1oqvm55co8qo8wqcm2" xml:space="preserve">[[Isimumathi:Monkeypox.jpg|thumb|Umuntu obanjwe yi Monkeypox]]
'''IMonkeypox''' kugula okuthileko  okuhlasela abantu.ESewula Afrika sele kunabantu ababanjwe sisifo lesi. Kusisifo esivela eenlwaneni sibambe abantu. sithoma ngokuthi umuntu aphathwe mkhuhlani, ihloko, avuvuke imisipha begodu avele iratjhi emzimbeni kuthi ngokukhmba kwesikhathi aphume iinlonda eziphuma amanzi.

Uvikela njani ukubhebhetheka kwe monkeypox

I Monkeypox ingavikelwa ngokuthi lokha umuntu nakazi bona bonyana unamaphawu wokuthi kungeka abanjwe sisifo lesi bese avakatjhele emtholapilo ukuthola isizo.</text>
      <sha1>a9jzhdoxk3zau1oqvm55co8qo8wqcm2</sha1>
    </revision>
    <revision>
      <id>2162</id>
      <parentid>1669</parentid>
      <timestamp>2024-11-27T06:15:00Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <origin>2162</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="579" sha1="1f6vjy6xyuvjrz9jxvopgiz1jx4urer" xml:space="preserve">[[Isimumathi:Monkeypox.jpg|thumb|Umuntu obanjwe yi Monkeypox]]
'''IMonkeypox''' kugula okuthileko  okuhlasela abantu. ESewula Afrika sele kunabantu ababanjwe sisifo lesi. Kusisifo esivela eenlwaneni sibambe abantu. sithoma ngokuthi umuntu aphathwe mkhuhlani, ihloko, avuvuke imisipha begodu avele iratjhi emzimbeni kuthi ngokukhmba kwesikhathi aphume iinlonda eziphuma amanzi.

Uvikela njani ukubhebhetheka kwe monkeypox

I Monkeypox ingavikelwa ngokuthi lokha umuntu nakazi bona bonyana unamaphawu wokuthi kungeka abanjwe sisifo lesi bese avakatjhele emtholapilo ukuthola isizo.</text>
      <sha1>1f6vjy6xyuvjrz9jxvopgiz1jx4urer</sha1>
    </revision>
    <revision>
      <id>3019</id>
      <parentid>2162</parentid>
      <timestamp>2025-06-06T20:29:14Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>eww</comment>
      <origin>3019</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="660" sha1="axqywwdy6dekf4h1g2b6g22msy4xdf6" xml:space="preserve">[[Isimumathi:Monkeypox.jpg|thumb|Umuntu obanjwe yi Monkeypox]]
'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. IMonkeypox''' kugula okuthileko  okuhlasela abantu. ESewula Afrika sele kunabantu ababanjwe sisifo lesi. Kusisifo esivela eenlwaneni sibambe abantu. sithoma ngokuthi umuntu aphathwe mkhuhlani, ihloko, avuvuke imisipha begodu avele iratjhi emzimbeni kuthi ngokukhmba kwesikhathi aphume iinlonda eziphuma amanzi.

Uvikela njani ukubhebhetheka kwe monkeypox

I Monkeypox ingavikelwa ngokuthi lokha umuntu nakazi bona bonyana unamaphawu wokuthi kungeka abanjwe sisifo lesi bese avakatjhele emtholapilo ukuthola isizo.</text>
      <sha1>axqywwdy6dekf4h1g2b6g22msy4xdf6</sha1>
    </revision>
    <revision>
      <id>3057</id>
      <parentid>3019</parentid>
      <timestamp>2025-06-07T03:05:22Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Simakahle Moselekatse|Simakahle Moselekatse]]</comment>
      <origin>2162</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="579" sha1="1f6vjy6xyuvjrz9jxvopgiz1jx4urer" xml:space="preserve">[[Isimumathi:Monkeypox.jpg|thumb|Umuntu obanjwe yi Monkeypox]]
'''IMonkeypox''' kugula okuthileko  okuhlasela abantu. ESewula Afrika sele kunabantu ababanjwe sisifo lesi. Kusisifo esivela eenlwaneni sibambe abantu. sithoma ngokuthi umuntu aphathwe mkhuhlani, ihloko, avuvuke imisipha begodu avele iratjhi emzimbeni kuthi ngokukhmba kwesikhathi aphume iinlonda eziphuma amanzi.

Uvikela njani ukubhebhetheka kwe monkeypox

I Monkeypox ingavikelwa ngokuthi lokha umuntu nakazi bona bonyana unamaphawu wokuthi kungeka abanjwe sisifo lesi bese avakatjhele emtholapilo ukuthola isizo.</text>
      <sha1>1f6vjy6xyuvjrz9jxvopgiz1jx4urer</sha1>
    </revision>
  </page>
  <page>
    <title>ISIFUNDO SEHLELOMUTJHO (SYNTAX)</title>
    <ns>0</ns>
    <id>140</id>
    <revision>
      <id>676</id>
      <timestamp>2024-06-07T11:50:20Z</timestamp>
      <contributor>
        <username>incubator&gt;Nomsa Skosana</username>
        <id>0</id>
      </contributor>
      <comment>This is the new article.</comment>
      <origin>676</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="10990" sha1="4d9gq0mpuucikty1i9wd6ywhty8ptlw" xml:space="preserve">== '''ISIFUNDO SEHLELOMUTJHO (SYNTAX)''' ==
UMTLOLI: N.P Mahlangu

== 1.1. Isifundo Semitjho ==
Uyini umutjho?

Umutjho libuthelelo lamagama alandelanako atloliweko namkha akhulunyiweko ahlelwe ngendlela yokobana ethule umqondo othileko. Ilandelano lamagama kufanele lihleleke kuhle ukuze umutjho loyo unikele umqondo. Kungebangelo-ke sithi lihlelomutjho (syntax).

Akhesifunde umutjho olandelako sibone bonyana wenza umqondo na:

[Abantwana ibholo badlala.]

Kuyavela bonyana umutjho ongehla lo awukahleleki kuhle. Akhesiwuhlele kuhle ngokuya kwehlelomutjho.

[Abantwana badlala ibholo.]

Umutjho ongehla lo sele wenza umqondo ngombana ilandelano lamagama lihleleke kuhle. Umutjho esiNdebeleni, njengakiwo woke amalimi, ulandela isakhiwo esisisekelo ngalendlela:

Ihloko Isenzo Umenziwa [Subject Verb Object (SVO)] 

'''Isibonelo:'''

[ Ubaba utjhuka isikhumba.]

Ubaba- yihloko

utjhuka-sisenzo

isikhumba-ngumenziwa

• Umutjho opheleleko esiNdebeleni uba nehloko nesilandiso. Isilandiso ngiso esithwele ummongo zombelele womutjho. Ngaphandle kwesilandiso, umutjho awukho. Isilandiso kuba sisenzo namkha isbanjalo.

• Isilandiso esakha umutjho opheleleko sisenzo esikghona ukutjhugutjhugulula iinkhathi zesenzo (finite verb) ingasi isenzo esisendlelni esabizo (infinitive)

'''Isibonelo:'''

[ Ukusela amanzi ] – umutjho lo awukapheleli ngombana unesenzo esisendlelni esisabizo (infinitive) (ukusela). Akhesilungelele isenzo esikghona ukutjhugutjhugulula iinkhathi zesenzo sibone.

[ Ukusela amanzi ngiyakuthanda. ] – umutjho lo sele uphelele ngombana kunesilandiso esikghona ukutjhugutjhugulula iinkhathi zesenzo. Singatjho sithi,

(ngizokuthanda/ngikuthandile/ngisakuthanda.)

== 1.2 Imihlobo Yemitjho: ==
EsiNdebeleni sinemihlobo EMINE yemitjho ekungile elandelako:

(1) &lt;u&gt;'''Umutjho onqophileko/olula/omkhulu (Simple sentence)'''&lt;/u&gt;

Umutjho onqophileko wakhiwa yihloko, isilandiso esisodwa kanye nomenziwa. Umutjho lo wethula umqondo owodwa. Kuyenzeka bonyana umutjho onqophileko uvume namkha ulandule.

'''Isibonelo:'''

[ Abantwana badlala ibhlolo.] -uyavuma

[ Abantwana abayidlali ibholo.] -uyalandula

[ Ugogo yinyanga.] -uyavuma

[ Ugogo akasiyo inyanga. ]- uyalandula

Umutjho onqophileko kuyenzeka bonyana ube nehloko nesilandiso kwaphela, umenziwa angabi khona. Kilobubujamo kutjho bonyana umenziwa ubhaqile.

'''Isibonelo:'''

[ Abantwana bayadlala.]

[ Abantwana abadlali ]

Umutjho onqophileko godu kuyenzeka bonyana ungabi nehloko, kodwana ube nesilandiso nomenziwa kwaphela. Kilobubujamo kutjho bonyana ihloko yomutjho ibhaqile. Isilandiso ekusisenzo siba nesivumelwano sehloko esifuze ihloko yomutjho ebhaqileko.

'''Isibonelo:'''

[ Badlala ibholo. ]

[ Abayidlali ibholo.]

Ihloko yomutjho ebhaqileko ngu(Abantwana). Isivumelwano sakhona sehloko u(ba-) siyavela esilandisweni. Umutjho onqophileko godu uyakwazi ukuba silandiso esizijamele sisodwa. Isilandisweso siba nesivumelwano sehloko esifuze ihloko yomutjho ebhaqileko.

'''Isibonelo:'''

[ Bayapheka.]- ihloko yomutjho ebhaqileko ngu (Bona).

[ Zizelamani. ]- ihloko yomutjho ebhaqileko ngu (Zona)

Kuyenzeka godu bonyana umutjho onqophileko ube sisenzo esisedleleni ekatelelako enganaso isivumelwano sehloko.

'''Isibonelo:'''

[ Vuka! ] – ihloko yomutjho ebhaqileko ngu (Wena)=(Wena vuka!)

(2) '''&lt;u&gt;Umutjho ovangileko (Compound sentence)&lt;/u&gt;'''

Umutjho ovangileko wakhiwa mimitjho emibili namkha ngehla kwemibili enqophileko ihlanganiswe ngesihlanganiso esithileko. Nangabe kuneenlandiso ezimbili, kutjho khona bonyana kunemitjho emibili enqophileko. Iinhlanganiso ezisetjenziselwa ukwakha umutjho ovangileko ngilezi ezilandulako:

[ ngombana, kodwana, begodu, godu, bese, ukuze, kanti, bonyana, njengombana]

'''Isibonelo 1:'''

[ UMsongelwa uyafunda ngombana uyasithanda isikolo.]

Umutjho wokuthoma ngothi, [ UMsongelwa uyafunda. ]

Umutjho wesibili ngothi, [ uyasithanda isikolo.]

Isihlanganiso ngu ( ngombana ).

'''Isibonelo 2:'''

[ Abobaba bahlaba ikomo bese abomma bapheka iinredlo. ]

Umutjho wokuthoma ngothi, [ Abobaba bahlaba ikomo. ]

Umutjho wesibili ngothi, [ abomma bapheka iinredlo. ]

Isihlanganiso ngu (bese).

'''Isibonelo 3:'''

[ Ugogo ugayela utjwala ngombana ubamkhulu womile bese umma uhlanza amarhabha. ]

Umutjho wokuthoma ngothi, [ Ugogo ugayela utjwala. ]

Umutjho wesibili ngothi, [ ubamkhulu womile. ]

Umutjho wesithathu ngothi, [ umma uhlanza amarhabha. ]

Isihlanganiso ngu (ngombana) no (bese)

(3) &lt;u&gt;'''Umutjho opandepande (Complex sentence)'''&lt;/u&gt;

Umutjho opandepande mumutjho owakhiwa mumutjho owodwa onqophileko kanye nomutjhwana owodwa namkha ngehla kowodwa oyamileko. Umutjhwana oyamileko ungayama ngokuthi uhlathulule usobizo namkha ukhanyise isilandiso.

• Umutjhwana oyamileko ohlathululako wakhiwa libinzana lesitlhadlhuli (Adjectival phrase) bese umuthjwana oyamileko okhanyisako wakhiwa

libinzana lesikhanyiso (Adverbial phrase).

• Umutjhwana oyamileko sithi mumutjhwana oyamileko ngombana awukwazi ukuzijamela uwodwa unikele umqondo opheleleko. Uyame

emutjhweni omkhulu/onqophileko ukuze wenze umqondo. Kungebangelo sithi libinzana (phrase).

• Nasikhupha umutjho onqophileko emutjhweni opandepande, kulindeleke bonyana kuvele ihloko nesilandiso kwaphela.

'''Isibonelo 1:'''

[ Indoda ede enzima izile izolo emini esikolweni. ]

[Indoda izile.] – mumutjho onqophileko

(ede enzima) – mumutjhwana oyamileko ohlathululo usobizo (Indoda)

(izolo emini esikolweni) – mumutjhwana oyamileko okhanyisa isilandiso (izile)

'''Isibonelo 2:'''

[ Abafundi abafundako bayaphumelela eemfundweni zabo. ]

[ Abafundi bayaphumelela. ] – mumutjho onqophileko.

(abafundako)- mumutjhwana oyamileko ohlathululako usobizo (Abafundi)

(eemfundweni zabo)- mumutjhwana oyamileko okhanyisa isilandiso (bayaphumelela)

Okutjhejekako kukobana ngaphandle komutjho onqophileko, umutjho opandepande angeze wenza umqondo. Imitjhwana eyamileko isebenza

njengeselulo somutjho onqophileko iwenze umutjho opandepande.

(4) '''&lt;u&gt;Umutjho ovange bupandepande/opandepande vangileko (Compound complex sentence)&lt;/u&gt;'''

Umutjho ovange bupandepande/opandepande ovangileko mumutjho owakhiwa mimitjho emibili enqophileko kanye nomutjhwana owodwa namkha ngehla kowodwa oyamileko. Kilobubujamo kutjho bonyana kuba khona umutjho ovangileko obhebhule imitjhwana eyamileko.

'''Isibonelo 1:'''

[ Ababelethi babafundi abangaphumeleliko babiziwe bonyana bakhambele umhlangano esikolweni ngoMvulo. ]

La sithola imitjho emibili enqophileko ehlanganiswe ngesihlanganiso u(bonyana).

[Ababelethi babiziwe]

(Ababelethi)- yihloko yomutjho.

(babiziwe)- silandiso

bonyana - sihlanganiso

[ bakhambele umhlangano]

(bakhambele)- silandiso

(umhlangano)- ngumenziwa

Sibuye sithole imitjhwana emibili, ohlathulula usobizo nokhanyisa isilandiso.

(babafundi abangaphumeleliko)- mumutjhwana oyamileko ohlathulula usobizo (ababelethi)

(esikolweni ngoMvulo)- mumutjhwana oyamileko okhanyisa isilandiso (bakhambele).

'''Isibonelo 2:'''

[ Abantu abanjingileko abanengi bathanda izinto ezihle begodu bathenga ukudla eentolo ezibizako.]

[Abantu bathanda izinto]- mumutjho onqophileko

(abanjingileko abanengi) – mumutjhwana oyamileko ohlathulula usobizo (abantu)

(ezihle)- mumutjhwana oyamileko ohlathulula usobizo (izinto)

begodu- sihlanganiso

[ bathenga ukudla]- mumutjho onqophileko

(eentolo ezibizako)- mumutjhwana oyamileko okhanyisa isilandiso (bathenga)

'''&lt;u&gt;Umsebenzi 1&lt;/u&gt;'''

Tlola bonyana umutjho ngamunye kongenzasi umhlobo bani womutjho.

(a) Umntwana ulise ibele ngombana uyamilisa.

(b) Abafundi bafunda incwadi.

(c) Imbuzi emhlophe esikazi ibuyile izolo emini.

(d) Ubaba uthenge ikoloyi.

(e) UDlhamaga ukhelele amanzi emlanjeni ekuseni ngombana ugogo udiniwe.

(f) Iinkoloyi ezitja ezibizako zithengiwe.

(g) Ugogo utheza iinkuni ukuze umma abase umlilo bese uvusa abantwana.

(h) Thina sithanda ibholo edlawa ngeenyawo begodu sithanda ukuyidlala etatawini qobe ngoSondo.

'''&lt;u&gt;Umsebenzi 2&lt;/u&gt;'''

Fundisisa isiqetjhana esingenzasi bese uphendula imibuzo elandelako:

2.1 Tlola bonyana umutjho othalelwe emudeni woku-1 umhlobo bani womutjhwana (1)

2.2 Tlola bonyana umutjho otlolwe ngokunzima khulu emudeni wesi-2 umhlobo bani womutjho. (1)

AmaNdebele sitjhaba &lt;u&gt;esihle esihloniphekileko&lt;/u&gt; kwaNzunza nakwaManala. '''Thina senza amasiko''' anothileko ngendlelethu ehlukileko. Umgwalo wesiNdebele ukubiza ukude le ngombana uzidle ngemibalawo emihle nekhanyako. Nakuneminyanya, ingadla ibetjhwa egagadwini kuvungame ithuli, babe bodwa abathi mzimba jugujeka, babe bodwa abathi tjhida ngitjhudule. Kiyo yoke iminyanya sifinya ngendololwana sibethe sentwala. &lt;u&gt;Iinhlobo ezikude ziyamenywa ngombana umnyanya omkhulu uyahlelelwa&lt;/u&gt;. Abobaba bahlaba ikomo bese abomma bapheka ukudla. Ilanga nalithi phatjha! Vane sele kukghutjhulwe ngebekonyana. Abobaba bavuma ingoma. Ngokukopheza kwelihlo, umphako vane sewungdliwa mntwana. Ngiyasithanda isiKhethu ngombana ngiyazikhakhazisa. &lt;u&gt;Utjwala obubilisiweko besintu buyaphekwa&lt;/u&gt;. Ukuphekwa kotjwala nokuhlatjwa kwembuzi kusebenza njongomhlahlandlela wokuthintana nabezimu bethu. Abomakhelani bayeza ukuze sigidinge nabo. Ukunotha kwesintu sethu kulele kithi, maNdebele ngombana indlela ibuzwa kwabaphambili.

[Umtlolo wokuzitlamela : Nsizwa Mahlangu]


2.3 Umujho othalelwe emudeni wesi-6 ovange bupandepande. Kiwo khupha umutjho ovangileko. (2)

2.3 Umujho othi, “Abobaba bahlaba ikomo bese abomma bapheka ukudla” mumutjho…

A onqophileko

B opandepande

C ovangileko

D ovange bupandepande. (1)

2.4 Buyelela utlole umutjho onqophileko ongenzasi kodwana uveze ukulandula.

Abobaba bavuma ingoma. (1)

2.5 Emutjhweni opandepande othalelwe emudeni we-10, khupa:

(a) Umutjho onqophileko/omkhulu. (1)

(b) Umutjhwana oyamileko ohlathululako. (1)

2.6 Veza umehluko okhona phakathi komutjho onqophileko nomutjho ovangileko. (2)

2.7 Veza umehluko okhona phakathi komutjho opandepande nomutjho ovange bupandepande/opandepande vangileko. (2)

2.8 Tlola bonyana isitatimende ngasinye kwezingenzasi siLiqiniso namkha Mamala

(a) Umutjho onqophileko uba neenlandiso ezimbili. (1)

(b) Umutjho onqophileko uyakwazi ukuzijamela uwodwa unikele umqondo opheleleko kiloyo mutjho. (1)

(c) Umutjho opandepande uyaba nomutjhwana oyamileko ohlathululako namkha okhanyisako. (1)

(d) Umutjhwana oyamileko ohlathululako uhlathulula isilandiso. (1)

(e) Umutjhwana oyamileko okhanyisako ukhanyisa usobizo. (1)

(f) Umutjho ovangileko uba nemitjho emibili namkha ngehla kwemibili enqophileko bese ihlanganiswa ngesihlanganiso esithileko. (1)

(g) Umutjho ovange bupandepande awubi nemitjhwana eyamileko. (1)

(h) Isilandiso esethula umqondo opheleleko emutjhweni onqophileko sisenzo esisendleleni esabizo. (1)

2.8 Hlaziya umthetho wehlelomutjho (syntax) mayelana nokwakhiwa komutjho ngokulandela isisekelo sakhona esivamileko lokha nakwakhiwa umutjho olula. (4)

2.9 Tshwaya ngokuhlolisisa indima edlalwa silandiso lokha nakwakhiwa umutjho esiNdebeleni. (4)

2.10 Tlola isibonelo sakho somutjho opandepande (2)

[30]
</text>
      <sha1>4d9gq0mpuucikty1i9wd6ywhty8ptlw</sha1>
    </revision>
    <revision>
      <id>677</id>
      <parentid>676</parentid>
      <timestamp>2024-10-14T13:46:41Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>676</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="10990" sha1="4d9gq0mpuucikty1i9wd6ywhty8ptlw" xml:space="preserve">== '''ISIFUNDO SEHLELOMUTJHO (SYNTAX)''' ==
UMTLOLI: N.P Mahlangu

== 1.1. Isifundo Semitjho ==
Uyini umutjho?

Umutjho libuthelelo lamagama alandelanako atloliweko namkha akhulunyiweko ahlelwe ngendlela yokobana ethule umqondo othileko. Ilandelano lamagama kufanele lihleleke kuhle ukuze umutjho loyo unikele umqondo. Kungebangelo-ke sithi lihlelomutjho (syntax).

Akhesifunde umutjho olandelako sibone bonyana wenza umqondo na:

[Abantwana ibholo badlala.]

Kuyavela bonyana umutjho ongehla lo awukahleleki kuhle. Akhesiwuhlele kuhle ngokuya kwehlelomutjho.

[Abantwana badlala ibholo.]

Umutjho ongehla lo sele wenza umqondo ngombana ilandelano lamagama lihleleke kuhle. Umutjho esiNdebeleni, njengakiwo woke amalimi, ulandela isakhiwo esisisekelo ngalendlela:

Ihloko Isenzo Umenziwa [Subject Verb Object (SVO)] 

'''Isibonelo:'''

[ Ubaba utjhuka isikhumba.]

Ubaba- yihloko

utjhuka-sisenzo

isikhumba-ngumenziwa

• Umutjho opheleleko esiNdebeleni uba nehloko nesilandiso. Isilandiso ngiso esithwele ummongo zombelele womutjho. Ngaphandle kwesilandiso, umutjho awukho. Isilandiso kuba sisenzo namkha isbanjalo.

• Isilandiso esakha umutjho opheleleko sisenzo esikghona ukutjhugutjhugulula iinkhathi zesenzo (finite verb) ingasi isenzo esisendlelni esabizo (infinitive)

'''Isibonelo:'''

[ Ukusela amanzi ] – umutjho lo awukapheleli ngombana unesenzo esisendlelni esisabizo (infinitive) (ukusela). Akhesilungelele isenzo esikghona ukutjhugutjhugulula iinkhathi zesenzo sibone.

[ Ukusela amanzi ngiyakuthanda. ] – umutjho lo sele uphelele ngombana kunesilandiso esikghona ukutjhugutjhugulula iinkhathi zesenzo. Singatjho sithi,

(ngizokuthanda/ngikuthandile/ngisakuthanda.)

== 1.2 Imihlobo Yemitjho: ==
EsiNdebeleni sinemihlobo EMINE yemitjho ekungile elandelako:

(1) &lt;u&gt;'''Umutjho onqophileko/olula/omkhulu (Simple sentence)'''&lt;/u&gt;

Umutjho onqophileko wakhiwa yihloko, isilandiso esisodwa kanye nomenziwa. Umutjho lo wethula umqondo owodwa. Kuyenzeka bonyana umutjho onqophileko uvume namkha ulandule.

'''Isibonelo:'''

[ Abantwana badlala ibhlolo.] -uyavuma

[ Abantwana abayidlali ibholo.] -uyalandula

[ Ugogo yinyanga.] -uyavuma

[ Ugogo akasiyo inyanga. ]- uyalandula

Umutjho onqophileko kuyenzeka bonyana ube nehloko nesilandiso kwaphela, umenziwa angabi khona. Kilobubujamo kutjho bonyana umenziwa ubhaqile.

'''Isibonelo:'''

[ Abantwana bayadlala.]

[ Abantwana abadlali ]

Umutjho onqophileko godu kuyenzeka bonyana ungabi nehloko, kodwana ube nesilandiso nomenziwa kwaphela. Kilobubujamo kutjho bonyana ihloko yomutjho ibhaqile. Isilandiso ekusisenzo siba nesivumelwano sehloko esifuze ihloko yomutjho ebhaqileko.

'''Isibonelo:'''

[ Badlala ibholo. ]

[ Abayidlali ibholo.]

Ihloko yomutjho ebhaqileko ngu(Abantwana). Isivumelwano sakhona sehloko u(ba-) siyavela esilandisweni. Umutjho onqophileko godu uyakwazi ukuba silandiso esizijamele sisodwa. Isilandisweso siba nesivumelwano sehloko esifuze ihloko yomutjho ebhaqileko.

'''Isibonelo:'''

[ Bayapheka.]- ihloko yomutjho ebhaqileko ngu (Bona).

[ Zizelamani. ]- ihloko yomutjho ebhaqileko ngu (Zona)

Kuyenzeka godu bonyana umutjho onqophileko ube sisenzo esisedleleni ekatelelako enganaso isivumelwano sehloko.

'''Isibonelo:'''

[ Vuka! ] – ihloko yomutjho ebhaqileko ngu (Wena)=(Wena vuka!)

(2) '''&lt;u&gt;Umutjho ovangileko (Compound sentence)&lt;/u&gt;'''

Umutjho ovangileko wakhiwa mimitjho emibili namkha ngehla kwemibili enqophileko ihlanganiswe ngesihlanganiso esithileko. Nangabe kuneenlandiso ezimbili, kutjho khona bonyana kunemitjho emibili enqophileko. Iinhlanganiso ezisetjenziselwa ukwakha umutjho ovangileko ngilezi ezilandulako:

[ ngombana, kodwana, begodu, godu, bese, ukuze, kanti, bonyana, njengombana]

'''Isibonelo 1:'''

[ UMsongelwa uyafunda ngombana uyasithanda isikolo.]

Umutjho wokuthoma ngothi, [ UMsongelwa uyafunda. ]

Umutjho wesibili ngothi, [ uyasithanda isikolo.]

Isihlanganiso ngu ( ngombana ).

'''Isibonelo 2:'''

[ Abobaba bahlaba ikomo bese abomma bapheka iinredlo. ]

Umutjho wokuthoma ngothi, [ Abobaba bahlaba ikomo. ]

Umutjho wesibili ngothi, [ abomma bapheka iinredlo. ]

Isihlanganiso ngu (bese).

'''Isibonelo 3:'''

[ Ugogo ugayela utjwala ngombana ubamkhulu womile bese umma uhlanza amarhabha. ]

Umutjho wokuthoma ngothi, [ Ugogo ugayela utjwala. ]

Umutjho wesibili ngothi, [ ubamkhulu womile. ]

Umutjho wesithathu ngothi, [ umma uhlanza amarhabha. ]

Isihlanganiso ngu (ngombana) no (bese)

(3) &lt;u&gt;'''Umutjho opandepande (Complex sentence)'''&lt;/u&gt;

Umutjho opandepande mumutjho owakhiwa mumutjho owodwa onqophileko kanye nomutjhwana owodwa namkha ngehla kowodwa oyamileko. Umutjhwana oyamileko ungayama ngokuthi uhlathulule usobizo namkha ukhanyise isilandiso.

• Umutjhwana oyamileko ohlathululako wakhiwa libinzana lesitlhadlhuli (Adjectival phrase) bese umuthjwana oyamileko okhanyisako wakhiwa

libinzana lesikhanyiso (Adverbial phrase).

• Umutjhwana oyamileko sithi mumutjhwana oyamileko ngombana awukwazi ukuzijamela uwodwa unikele umqondo opheleleko. Uyame

emutjhweni omkhulu/onqophileko ukuze wenze umqondo. Kungebangelo sithi libinzana (phrase).

• Nasikhupha umutjho onqophileko emutjhweni opandepande, kulindeleke bonyana kuvele ihloko nesilandiso kwaphela.

'''Isibonelo 1:'''

[ Indoda ede enzima izile izolo emini esikolweni. ]

[Indoda izile.] – mumutjho onqophileko

(ede enzima) – mumutjhwana oyamileko ohlathululo usobizo (Indoda)

(izolo emini esikolweni) – mumutjhwana oyamileko okhanyisa isilandiso (izile)

'''Isibonelo 2:'''

[ Abafundi abafundako bayaphumelela eemfundweni zabo. ]

[ Abafundi bayaphumelela. ] – mumutjho onqophileko.

(abafundako)- mumutjhwana oyamileko ohlathululako usobizo (Abafundi)

(eemfundweni zabo)- mumutjhwana oyamileko okhanyisa isilandiso (bayaphumelela)

Okutjhejekako kukobana ngaphandle komutjho onqophileko, umutjho opandepande angeze wenza umqondo. Imitjhwana eyamileko isebenza

njengeselulo somutjho onqophileko iwenze umutjho opandepande.

(4) '''&lt;u&gt;Umutjho ovange bupandepande/opandepande vangileko (Compound complex sentence)&lt;/u&gt;'''

Umutjho ovange bupandepande/opandepande ovangileko mumutjho owakhiwa mimitjho emibili enqophileko kanye nomutjhwana owodwa namkha ngehla kowodwa oyamileko. Kilobubujamo kutjho bonyana kuba khona umutjho ovangileko obhebhule imitjhwana eyamileko.

'''Isibonelo 1:'''

[ Ababelethi babafundi abangaphumeleliko babiziwe bonyana bakhambele umhlangano esikolweni ngoMvulo. ]

La sithola imitjho emibili enqophileko ehlanganiswe ngesihlanganiso u(bonyana).

[Ababelethi babiziwe]

(Ababelethi)- yihloko yomutjho.

(babiziwe)- silandiso

bonyana - sihlanganiso

[ bakhambele umhlangano]

(bakhambele)- silandiso

(umhlangano)- ngumenziwa

Sibuye sithole imitjhwana emibili, ohlathulula usobizo nokhanyisa isilandiso.

(babafundi abangaphumeleliko)- mumutjhwana oyamileko ohlathulula usobizo (ababelethi)

(esikolweni ngoMvulo)- mumutjhwana oyamileko okhanyisa isilandiso (bakhambele).

'''Isibonelo 2:'''

[ Abantu abanjingileko abanengi bathanda izinto ezihle begodu bathenga ukudla eentolo ezibizako.]

[Abantu bathanda izinto]- mumutjho onqophileko

(abanjingileko abanengi) – mumutjhwana oyamileko ohlathulula usobizo (abantu)

(ezihle)- mumutjhwana oyamileko ohlathulula usobizo (izinto)

begodu- sihlanganiso

[ bathenga ukudla]- mumutjho onqophileko

(eentolo ezibizako)- mumutjhwana oyamileko okhanyisa isilandiso (bathenga)

'''&lt;u&gt;Umsebenzi 1&lt;/u&gt;'''

Tlola bonyana umutjho ngamunye kongenzasi umhlobo bani womutjho.

(a) Umntwana ulise ibele ngombana uyamilisa.

(b) Abafundi bafunda incwadi.

(c) Imbuzi emhlophe esikazi ibuyile izolo emini.

(d) Ubaba uthenge ikoloyi.

(e) UDlhamaga ukhelele amanzi emlanjeni ekuseni ngombana ugogo udiniwe.

(f) Iinkoloyi ezitja ezibizako zithengiwe.

(g) Ugogo utheza iinkuni ukuze umma abase umlilo bese uvusa abantwana.

(h) Thina sithanda ibholo edlawa ngeenyawo begodu sithanda ukuyidlala etatawini qobe ngoSondo.

'''&lt;u&gt;Umsebenzi 2&lt;/u&gt;'''

Fundisisa isiqetjhana esingenzasi bese uphendula imibuzo elandelako:

2.1 Tlola bonyana umutjho othalelwe emudeni woku-1 umhlobo bani womutjhwana (1)

2.2 Tlola bonyana umutjho otlolwe ngokunzima khulu emudeni wesi-2 umhlobo bani womutjho. (1)

AmaNdebele sitjhaba &lt;u&gt;esihle esihloniphekileko&lt;/u&gt; kwaNzunza nakwaManala. '''Thina senza amasiko''' anothileko ngendlelethu ehlukileko. Umgwalo wesiNdebele ukubiza ukude le ngombana uzidle ngemibalawo emihle nekhanyako. Nakuneminyanya, ingadla ibetjhwa egagadwini kuvungame ithuli, babe bodwa abathi mzimba jugujeka, babe bodwa abathi tjhida ngitjhudule. Kiyo yoke iminyanya sifinya ngendololwana sibethe sentwala. &lt;u&gt;Iinhlobo ezikude ziyamenywa ngombana umnyanya omkhulu uyahlelelwa&lt;/u&gt;. Abobaba bahlaba ikomo bese abomma bapheka ukudla. Ilanga nalithi phatjha! Vane sele kukghutjhulwe ngebekonyana. Abobaba bavuma ingoma. Ngokukopheza kwelihlo, umphako vane sewungdliwa mntwana. Ngiyasithanda isiKhethu ngombana ngiyazikhakhazisa. &lt;u&gt;Utjwala obubilisiweko besintu buyaphekwa&lt;/u&gt;. Ukuphekwa kotjwala nokuhlatjwa kwembuzi kusebenza njongomhlahlandlela wokuthintana nabezimu bethu. Abomakhelani bayeza ukuze sigidinge nabo. Ukunotha kwesintu sethu kulele kithi, maNdebele ngombana indlela ibuzwa kwabaphambili.

[Umtlolo wokuzitlamela : Nsizwa Mahlangu]


2.3 Umujho othalelwe emudeni wesi-6 ovange bupandepande. Kiwo khupha umutjho ovangileko. (2)

2.3 Umujho othi, “Abobaba bahlaba ikomo bese abomma bapheka ukudla” mumutjho…

A onqophileko

B opandepande

C ovangileko

D ovange bupandepande. (1)

2.4 Buyelela utlole umutjho onqophileko ongenzasi kodwana uveze ukulandula.

Abobaba bavuma ingoma. (1)

2.5 Emutjhweni opandepande othalelwe emudeni we-10, khupa:

(a) Umutjho onqophileko/omkhulu. (1)

(b) Umutjhwana oyamileko ohlathululako. (1)

2.6 Veza umehluko okhona phakathi komutjho onqophileko nomutjho ovangileko. (2)

2.7 Veza umehluko okhona phakathi komutjho opandepande nomutjho ovange bupandepande/opandepande vangileko. (2)

2.8 Tlola bonyana isitatimende ngasinye kwezingenzasi siLiqiniso namkha Mamala

(a) Umutjho onqophileko uba neenlandiso ezimbili. (1)

(b) Umutjho onqophileko uyakwazi ukuzijamela uwodwa unikele umqondo opheleleko kiloyo mutjho. (1)

(c) Umutjho opandepande uyaba nomutjhwana oyamileko ohlathululako namkha okhanyisako. (1)

(d) Umutjhwana oyamileko ohlathululako uhlathulula isilandiso. (1)

(e) Umutjhwana oyamileko okhanyisako ukhanyisa usobizo. (1)

(f) Umutjho ovangileko uba nemitjho emibili namkha ngehla kwemibili enqophileko bese ihlanganiswa ngesihlanganiso esithileko. (1)

(g) Umutjho ovange bupandepande awubi nemitjhwana eyamileko. (1)

(h) Isilandiso esethula umqondo opheleleko emutjhweni onqophileko sisenzo esisendleleni esabizo. (1)

2.8 Hlaziya umthetho wehlelomutjho (syntax) mayelana nokwakhiwa komutjho ngokulandela isisekelo sakhona esivamileko lokha nakwakhiwa umutjho olula. (4)

2.9 Tshwaya ngokuhlolisisa indima edlalwa silandiso lokha nakwakhiwa umutjho esiNdebeleni. (4)

2.10 Tlola isibonelo sakho somutjho opandepande (2)

[30]
</text>
      <sha1>4d9gq0mpuucikty1i9wd6ywhty8ptlw</sha1>
    </revision>
    <revision>
      <id>3006</id>
      <parentid>677</parentid>
      <timestamp>2025-06-06T20:22:05Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>ghdgdhr</comment>
      <origin>3006</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="11077" sha1="n9cws65bh06nt6xxz20zjedwa88tbgz" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.'''

== '''ISIFUNDO SEHLELOMUTJHO (SYNTAX)''' ==
UMTLOLI: N.P Mahlangu

== 1.1. Isifundo Semitjho ==
Uyini umutjho?

Umutjho libuthelelo lamagama alandelanako atloliweko namkha akhulunyiweko ahlelwe ngendlela yokobana ethule umqondo othileko. Ilandelano lamagama kufanele lihleleke kuhle ukuze umutjho loyo unikele umqondo. Kungebangelo-ke sithi lihlelomutjho (syntax).

Akhesifunde umutjho olandelako sibone bonyana wenza umqondo na:

[Abantwana ibholo badlala.]

Kuyavela bonyana umutjho ongehla lo awukahleleki kuhle. Akhesiwuhlele kuhle ngokuya kwehlelomutjho.

[Abantwana badlala ibholo.]

Umutjho ongehla lo sele wenza umqondo ngombana ilandelano lamagama lihleleke kuhle. Umutjho esiNdebeleni, njengakiwo woke amalimi, ulandela isakhiwo esisisekelo ngalendlela:

Ihloko Isenzo Umenziwa [Subject Verb Object (SVO)] 

'''Isibonelo:'''

[ Ubaba utjhuka isikhumba.]

Ubaba- yihloko

utjhuka-sisenzo

isikhumba-ngumenziwa

• Umutjho opheleleko esiNdebeleni uba nehloko nesilandiso. Isilandiso ngiso esithwele ummongo zombelele womutjho. Ngaphandle kwesilandiso, umutjho awukho. Isilandiso kuba sisenzo namkha isbanjalo.

• Isilandiso esakha umutjho opheleleko sisenzo esikghona ukutjhugutjhugulula iinkhathi zesenzo (finite verb) ingasi isenzo esisendlelni esabizo (infinitive)

'''Isibonelo:'''

[ Ukusela amanzi ] – umutjho lo awukapheleli ngombana unesenzo esisendlelni esisabizo (infinitive) (ukusela). Akhesilungelele isenzo esikghona ukutjhugutjhugulula iinkhathi zesenzo sibone.

[ Ukusela amanzi ngiyakuthanda. ] – umutjho lo sele uphelele ngombana kunesilandiso esikghona ukutjhugutjhugulula iinkhathi zesenzo. Singatjho sithi,

(ngizokuthanda/ngikuthandile/ngisakuthanda.)

== 1.2 Imihlobo Yemitjho: ==
EsiNdebeleni sinemihlobo EMINE yemitjho ekungile elandelako:

(1) &lt;u&gt;'''Umutjho onqophileko/olula/omkhulu (Simple sentence)'''&lt;/u&gt;

Umutjho onqophileko wakhiwa yihloko, isilandiso esisodwa kanye nomenziwa. Umutjho lo wethula umqondo owodwa. Kuyenzeka bonyana umutjho onqophileko uvume namkha ulandule.

'''Isibonelo:'''

[ Abantwana badlala ibhlolo.] -uyavuma

[ Abantwana abayidlali ibholo.] -uyalandula

[ Ugogo yinyanga.] -uyavuma

[ Ugogo akasiyo inyanga. ]- uyalandula

Umutjho onqophileko kuyenzeka bonyana ube nehloko nesilandiso kwaphela, umenziwa angabi khona. Kilobubujamo kutjho bonyana umenziwa ubhaqile.

'''Isibonelo:'''

[ Abantwana bayadlala.]

[ Abantwana abadlali ]

Umutjho onqophileko godu kuyenzeka bonyana ungabi nehloko, kodwana ube nesilandiso nomenziwa kwaphela. Kilobubujamo kutjho bonyana ihloko yomutjho ibhaqile. Isilandiso ekusisenzo siba nesivumelwano sehloko esifuze ihloko yomutjho ebhaqileko.

'''Isibonelo:'''

[ Badlala ibholo. ]

[ Abayidlali ibholo.]

Ihloko yomutjho ebhaqileko ngu(Abantwana). Isivumelwano sakhona sehloko u(ba-) siyavela esilandisweni. Umutjho onqophileko godu uyakwazi ukuba silandiso esizijamele sisodwa. Isilandisweso siba nesivumelwano sehloko esifuze ihloko yomutjho ebhaqileko.

'''Isibonelo:'''

[ Bayapheka.]- ihloko yomutjho ebhaqileko ngu (Bona).

[ Zizelamani. ]- ihloko yomutjho ebhaqileko ngu (Zona)

Kuyenzeka godu bonyana umutjho onqophileko ube sisenzo esisedleleni ekatelelako enganaso isivumelwano sehloko.

'''Isibonelo:'''

[ Vuka! ] – ihloko yomutjho ebhaqileko ngu (Wena)=(Wena vuka!)

(2) '''&lt;u&gt;Umutjho ovangileko (Compound sentence)&lt;/u&gt;'''

Umutjho ovangileko wakhiwa mimitjho emibili namkha ngehla kwemibili enqophileko ihlanganiswe ngesihlanganiso esithileko. Nangabe kuneenlandiso ezimbili, kutjho khona bonyana kunemitjho emibili enqophileko. Iinhlanganiso ezisetjenziselwa ukwakha umutjho ovangileko ngilezi ezilandulako:

[ ngombana, kodwana, begodu, godu, bese, ukuze, kanti, bonyana, njengombana]

'''Isibonelo 1:'''

[ UMsongelwa uyafunda ngombana uyasithanda isikolo.]

Umutjho wokuthoma ngothi, [ UMsongelwa uyafunda. ]

Umutjho wesibili ngothi, [ uyasithanda isikolo.]

Isihlanganiso ngu ( ngombana ).

'''Isibonelo 2:'''

[ Abobaba bahlaba ikomo bese abomma bapheka iinredlo. ]

Umutjho wokuthoma ngothi, [ Abobaba bahlaba ikomo. ]

Umutjho wesibili ngothi, [ abomma bapheka iinredlo. ]

Isihlanganiso ngu (bese).

'''Isibonelo 3:'''

[ Ugogo ugayela utjwala ngombana ubamkhulu womile bese umma uhlanza amarhabha. ]

Umutjho wokuthoma ngothi, [ Ugogo ugayela utjwala. ]

Umutjho wesibili ngothi, [ ubamkhulu womile. ]

Umutjho wesithathu ngothi, [ umma uhlanza amarhabha. ]

Isihlanganiso ngu (ngombana) no (bese)

(3) &lt;u&gt;'''Umutjho opandepande (Complex sentence)'''&lt;/u&gt;

Umutjho opandepande mumutjho owakhiwa mumutjho owodwa onqophileko kanye nomutjhwana owodwa namkha ngehla kowodwa oyamileko. Umutjhwana oyamileko ungayama ngokuthi uhlathulule usobizo namkha ukhanyise isilandiso.

• Umutjhwana oyamileko ohlathululako wakhiwa libinzana lesitlhadlhuli (Adjectival phrase) bese umuthjwana oyamileko okhanyisako wakhiwa

libinzana lesikhanyiso (Adverbial phrase).

• Umutjhwana oyamileko sithi mumutjhwana oyamileko ngombana awukwazi ukuzijamela uwodwa unikele umqondo opheleleko. Uyame

emutjhweni omkhulu/onqophileko ukuze wenze umqondo. Kungebangelo sithi libinzana (phrase).

• Nasikhupha umutjho onqophileko emutjhweni opandepande, kulindeleke bonyana kuvele ihloko nesilandiso kwaphela.

'''Isibonelo 1:'''

[ Indoda ede enzima izile izolo emini esikolweni. ]

[Indoda izile.] – mumutjho onqophileko

(ede enzima) – mumutjhwana oyamileko ohlathululo usobizo (Indoda)

(izolo emini esikolweni) – mumutjhwana oyamileko okhanyisa isilandiso (izile)

'''Isibonelo 2:'''

[ Abafundi abafundako bayaphumelela eemfundweni zabo. ]

[ Abafundi bayaphumelela. ] – mumutjho onqophileko.

(abafundako)- mumutjhwana oyamileko ohlathululako usobizo (Abafundi)

(eemfundweni zabo)- mumutjhwana oyamileko okhanyisa isilandiso (bayaphumelela)

Okutjhejekako kukobana ngaphandle komutjho onqophileko, umutjho opandepande angeze wenza umqondo. Imitjhwana eyamileko isebenza

njengeselulo somutjho onqophileko iwenze umutjho opandepande.

(4) '''&lt;u&gt;Umutjho ovange bupandepande/opandepande vangileko (Compound complex sentence)&lt;/u&gt;'''

Umutjho ovange bupandepande/opandepande ovangileko mumutjho owakhiwa mimitjho emibili enqophileko kanye nomutjhwana owodwa namkha ngehla kowodwa oyamileko. Kilobubujamo kutjho bonyana kuba khona umutjho ovangileko obhebhule imitjhwana eyamileko.

'''Isibonelo 1:'''

[ Ababelethi babafundi abangaphumeleliko babiziwe bonyana bakhambele umhlangano esikolweni ngoMvulo. ]

La sithola imitjho emibili enqophileko ehlanganiswe ngesihlanganiso u(bonyana).

[Ababelethi babiziwe]

(Ababelethi)- yihloko yomutjho.

(babiziwe)- silandiso

bonyana - sihlanganiso

[ bakhambele umhlangano]

(bakhambele)- silandiso

(umhlangano)- ngumenziwa

Sibuye sithole imitjhwana emibili, ohlathulula usobizo nokhanyisa isilandiso.

(babafundi abangaphumeleliko)- mumutjhwana oyamileko ohlathulula usobizo (ababelethi)

(esikolweni ngoMvulo)- mumutjhwana oyamileko okhanyisa isilandiso (bakhambele).

'''Isibonelo 2:'''

[ Abantu abanjingileko abanengi bathanda izinto ezihle begodu bathenga ukudla eentolo ezibizako.]

[Abantu bathanda izinto]- mumutjho onqophileko

(abanjingileko abanengi) – mumutjhwana oyamileko ohlathulula usobizo (abantu)

(ezihle)- mumutjhwana oyamileko ohlathulula usobizo (izinto)

begodu- sihlanganiso

[ bathenga ukudla]- mumutjho onqophileko

(eentolo ezibizako)- mumutjhwana oyamileko okhanyisa isilandiso (bathenga)

'''&lt;u&gt;Umsebenzi 1&lt;/u&gt;'''

Tlola bonyana umutjho ngamunye kongenzasi umhlobo bani womutjho.

(a) Umntwana ulise ibele ngombana uyamilisa.

(b) Abafundi bafunda incwadi.

(c) Imbuzi emhlophe esikazi ibuyile izolo emini.

(d) Ubaba uthenge ikoloyi.

(e) UDlhamaga ukhelele amanzi emlanjeni ekuseni ngombana ugogo udiniwe.

(f) Iinkoloyi ezitja ezibizako zithengiwe.

(g) Ugogo utheza iinkuni ukuze umma abase umlilo bese uvusa abantwana.

(h) Thina sithanda ibholo edlawa ngeenyawo begodu sithanda ukuyidlala etatawini qobe ngoSondo.

'''&lt;u&gt;Umsebenzi 2&lt;/u&gt;'''

Fundisisa isiqetjhana esingenzasi bese uphendula imibuzo elandelako:

2.1 Tlola bonyana umutjho othalelwe emudeni woku-1 umhlobo bani womutjhwana (1)

2.2 Tlola bonyana umutjho otlolwe ngokunzima khulu emudeni wesi-2 umhlobo bani womutjho. (1)

AmaNdebele sitjhaba &lt;u&gt;esihle esihloniphekileko&lt;/u&gt; kwaNzunza nakwaManala. '''Thina senza amasiko''' anothileko ngendlelethu ehlukileko. Umgwalo wesiNdebele ukubiza ukude le ngombana uzidle ngemibalawo emihle nekhanyako. Nakuneminyanya, ingadla ibetjhwa egagadwini kuvungame ithuli, babe bodwa abathi mzimba jugujeka, babe bodwa abathi tjhida ngitjhudule. Kiyo yoke iminyanya sifinya ngendololwana sibethe sentwala. &lt;u&gt;Iinhlobo ezikude ziyamenywa ngombana umnyanya omkhulu uyahlelelwa&lt;/u&gt;. Abobaba bahlaba ikomo bese abomma bapheka ukudla. Ilanga nalithi phatjha! Vane sele kukghutjhulwe ngebekonyana. Abobaba bavuma ingoma. Ngokukopheza kwelihlo, umphako vane sewungdliwa mntwana. Ngiyasithanda isiKhethu ngombana ngiyazikhakhazisa. &lt;u&gt;Utjwala obubilisiweko besintu buyaphekwa&lt;/u&gt;. Ukuphekwa kotjwala nokuhlatjwa kwembuzi kusebenza njongomhlahlandlela wokuthintana nabezimu bethu. Abomakhelani bayeza ukuze sigidinge nabo. Ukunotha kwesintu sethu kulele kithi, maNdebele ngombana indlela ibuzwa kwabaphambili.

[Umtlolo wokuzitlamela : Nsizwa Mahlangu]


2.3 Umujho othalelwe emudeni wesi-6 ovange bupandepande. Kiwo khupha umutjho ovangileko. (2)

2.3 Umujho othi, “Abobaba bahlaba ikomo bese abomma bapheka ukudla” mumutjho…

A onqophileko

B opandepande

C ovangileko

D ovange bupandepande. (1)

2.4 Buyelela utlole umutjho onqophileko ongenzasi kodwana uveze ukulandula.

Abobaba bavuma ingoma. (1)

2.5 Emutjhweni opandepande othalelwe emudeni we-10, khupa:

(a) Umutjho onqophileko/omkhulu. (1)

(b) Umutjhwana oyamileko ohlathululako. (1)

2.6 Veza umehluko okhona phakathi komutjho onqophileko nomutjho ovangileko. (2)

2.7 Veza umehluko okhona phakathi komutjho opandepande nomutjho ovange bupandepande/opandepande vangileko. (2)

2.8 Tlola bonyana isitatimende ngasinye kwezingenzasi siLiqiniso namkha Mamala

(a) Umutjho onqophileko uba neenlandiso ezimbili. (1)

(b) Umutjho onqophileko uyakwazi ukuzijamela uwodwa unikele umqondo opheleleko kiloyo mutjho. (1)

(c) Umutjho opandepande uyaba nomutjhwana oyamileko ohlathululako namkha okhanyisako. (1)

(d) Umutjhwana oyamileko ohlathululako uhlathulula isilandiso. (1)

(e) Umutjhwana oyamileko okhanyisako ukhanyisa usobizo. (1)

(f) Umutjho ovangileko uba nemitjho emibili namkha ngehla kwemibili enqophileko bese ihlanganiswa ngesihlanganiso esithileko. (1)

(g) Umutjho ovange bupandepande awubi nemitjhwana eyamileko. (1)

(h) Isilandiso esethula umqondo opheleleko emutjhweni onqophileko sisenzo esisendleleni esabizo. (1)

2.8 Hlaziya umthetho wehlelomutjho (syntax) mayelana nokwakhiwa komutjho ngokulandela isisekelo sakhona esivamileko lokha nakwakhiwa umutjho olula. (4)

2.9 Tshwaya ngokuhlolisisa indima edlalwa silandiso lokha nakwakhiwa umutjho esiNdebeleni. (4)

2.10 Tlola isibonelo sakho somutjho opandepande (2)

[30]</text>
      <sha1>n9cws65bh06nt6xxz20zjedwa88tbgz</sha1>
    </revision>
    <revision>
      <id>3044</id>
      <parentid>3006</parentid>
      <timestamp>2025-06-07T03:05:22Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Jon Harald Søby|Jon Harald Søby]]</comment>
      <origin>676</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="10990" sha1="4d9gq0mpuucikty1i9wd6ywhty8ptlw" xml:space="preserve">== '''ISIFUNDO SEHLELOMUTJHO (SYNTAX)''' ==
UMTLOLI: N.P Mahlangu

== 1.1. Isifundo Semitjho ==
Uyini umutjho?

Umutjho libuthelelo lamagama alandelanako atloliweko namkha akhulunyiweko ahlelwe ngendlela yokobana ethule umqondo othileko. Ilandelano lamagama kufanele lihleleke kuhle ukuze umutjho loyo unikele umqondo. Kungebangelo-ke sithi lihlelomutjho (syntax).

Akhesifunde umutjho olandelako sibone bonyana wenza umqondo na:

[Abantwana ibholo badlala.]

Kuyavela bonyana umutjho ongehla lo awukahleleki kuhle. Akhesiwuhlele kuhle ngokuya kwehlelomutjho.

[Abantwana badlala ibholo.]

Umutjho ongehla lo sele wenza umqondo ngombana ilandelano lamagama lihleleke kuhle. Umutjho esiNdebeleni, njengakiwo woke amalimi, ulandela isakhiwo esisisekelo ngalendlela:

Ihloko Isenzo Umenziwa [Subject Verb Object (SVO)] 

'''Isibonelo:'''

[ Ubaba utjhuka isikhumba.]

Ubaba- yihloko

utjhuka-sisenzo

isikhumba-ngumenziwa

• Umutjho opheleleko esiNdebeleni uba nehloko nesilandiso. Isilandiso ngiso esithwele ummongo zombelele womutjho. Ngaphandle kwesilandiso, umutjho awukho. Isilandiso kuba sisenzo namkha isbanjalo.

• Isilandiso esakha umutjho opheleleko sisenzo esikghona ukutjhugutjhugulula iinkhathi zesenzo (finite verb) ingasi isenzo esisendlelni esabizo (infinitive)

'''Isibonelo:'''

[ Ukusela amanzi ] – umutjho lo awukapheleli ngombana unesenzo esisendlelni esisabizo (infinitive) (ukusela). Akhesilungelele isenzo esikghona ukutjhugutjhugulula iinkhathi zesenzo sibone.

[ Ukusela amanzi ngiyakuthanda. ] – umutjho lo sele uphelele ngombana kunesilandiso esikghona ukutjhugutjhugulula iinkhathi zesenzo. Singatjho sithi,

(ngizokuthanda/ngikuthandile/ngisakuthanda.)

== 1.2 Imihlobo Yemitjho: ==
EsiNdebeleni sinemihlobo EMINE yemitjho ekungile elandelako:

(1) &lt;u&gt;'''Umutjho onqophileko/olula/omkhulu (Simple sentence)'''&lt;/u&gt;

Umutjho onqophileko wakhiwa yihloko, isilandiso esisodwa kanye nomenziwa. Umutjho lo wethula umqondo owodwa. Kuyenzeka bonyana umutjho onqophileko uvume namkha ulandule.

'''Isibonelo:'''

[ Abantwana badlala ibhlolo.] -uyavuma

[ Abantwana abayidlali ibholo.] -uyalandula

[ Ugogo yinyanga.] -uyavuma

[ Ugogo akasiyo inyanga. ]- uyalandula

Umutjho onqophileko kuyenzeka bonyana ube nehloko nesilandiso kwaphela, umenziwa angabi khona. Kilobubujamo kutjho bonyana umenziwa ubhaqile.

'''Isibonelo:'''

[ Abantwana bayadlala.]

[ Abantwana abadlali ]

Umutjho onqophileko godu kuyenzeka bonyana ungabi nehloko, kodwana ube nesilandiso nomenziwa kwaphela. Kilobubujamo kutjho bonyana ihloko yomutjho ibhaqile. Isilandiso ekusisenzo siba nesivumelwano sehloko esifuze ihloko yomutjho ebhaqileko.

'''Isibonelo:'''

[ Badlala ibholo. ]

[ Abayidlali ibholo.]

Ihloko yomutjho ebhaqileko ngu(Abantwana). Isivumelwano sakhona sehloko u(ba-) siyavela esilandisweni. Umutjho onqophileko godu uyakwazi ukuba silandiso esizijamele sisodwa. Isilandisweso siba nesivumelwano sehloko esifuze ihloko yomutjho ebhaqileko.

'''Isibonelo:'''

[ Bayapheka.]- ihloko yomutjho ebhaqileko ngu (Bona).

[ Zizelamani. ]- ihloko yomutjho ebhaqileko ngu (Zona)

Kuyenzeka godu bonyana umutjho onqophileko ube sisenzo esisedleleni ekatelelako enganaso isivumelwano sehloko.

'''Isibonelo:'''

[ Vuka! ] – ihloko yomutjho ebhaqileko ngu (Wena)=(Wena vuka!)

(2) '''&lt;u&gt;Umutjho ovangileko (Compound sentence)&lt;/u&gt;'''

Umutjho ovangileko wakhiwa mimitjho emibili namkha ngehla kwemibili enqophileko ihlanganiswe ngesihlanganiso esithileko. Nangabe kuneenlandiso ezimbili, kutjho khona bonyana kunemitjho emibili enqophileko. Iinhlanganiso ezisetjenziselwa ukwakha umutjho ovangileko ngilezi ezilandulako:

[ ngombana, kodwana, begodu, godu, bese, ukuze, kanti, bonyana, njengombana]

'''Isibonelo 1:'''

[ UMsongelwa uyafunda ngombana uyasithanda isikolo.]

Umutjho wokuthoma ngothi, [ UMsongelwa uyafunda. ]

Umutjho wesibili ngothi, [ uyasithanda isikolo.]

Isihlanganiso ngu ( ngombana ).

'''Isibonelo 2:'''

[ Abobaba bahlaba ikomo bese abomma bapheka iinredlo. ]

Umutjho wokuthoma ngothi, [ Abobaba bahlaba ikomo. ]

Umutjho wesibili ngothi, [ abomma bapheka iinredlo. ]

Isihlanganiso ngu (bese).

'''Isibonelo 3:'''

[ Ugogo ugayela utjwala ngombana ubamkhulu womile bese umma uhlanza amarhabha. ]

Umutjho wokuthoma ngothi, [ Ugogo ugayela utjwala. ]

Umutjho wesibili ngothi, [ ubamkhulu womile. ]

Umutjho wesithathu ngothi, [ umma uhlanza amarhabha. ]

Isihlanganiso ngu (ngombana) no (bese)

(3) &lt;u&gt;'''Umutjho opandepande (Complex sentence)'''&lt;/u&gt;

Umutjho opandepande mumutjho owakhiwa mumutjho owodwa onqophileko kanye nomutjhwana owodwa namkha ngehla kowodwa oyamileko. Umutjhwana oyamileko ungayama ngokuthi uhlathulule usobizo namkha ukhanyise isilandiso.

• Umutjhwana oyamileko ohlathululako wakhiwa libinzana lesitlhadlhuli (Adjectival phrase) bese umuthjwana oyamileko okhanyisako wakhiwa

libinzana lesikhanyiso (Adverbial phrase).

• Umutjhwana oyamileko sithi mumutjhwana oyamileko ngombana awukwazi ukuzijamela uwodwa unikele umqondo opheleleko. Uyame

emutjhweni omkhulu/onqophileko ukuze wenze umqondo. Kungebangelo sithi libinzana (phrase).

• Nasikhupha umutjho onqophileko emutjhweni opandepande, kulindeleke bonyana kuvele ihloko nesilandiso kwaphela.

'''Isibonelo 1:'''

[ Indoda ede enzima izile izolo emini esikolweni. ]

[Indoda izile.] – mumutjho onqophileko

(ede enzima) – mumutjhwana oyamileko ohlathululo usobizo (Indoda)

(izolo emini esikolweni) – mumutjhwana oyamileko okhanyisa isilandiso (izile)

'''Isibonelo 2:'''

[ Abafundi abafundako bayaphumelela eemfundweni zabo. ]

[ Abafundi bayaphumelela. ] – mumutjho onqophileko.

(abafundako)- mumutjhwana oyamileko ohlathululako usobizo (Abafundi)

(eemfundweni zabo)- mumutjhwana oyamileko okhanyisa isilandiso (bayaphumelela)

Okutjhejekako kukobana ngaphandle komutjho onqophileko, umutjho opandepande angeze wenza umqondo. Imitjhwana eyamileko isebenza

njengeselulo somutjho onqophileko iwenze umutjho opandepande.

(4) '''&lt;u&gt;Umutjho ovange bupandepande/opandepande vangileko (Compound complex sentence)&lt;/u&gt;'''

Umutjho ovange bupandepande/opandepande ovangileko mumutjho owakhiwa mimitjho emibili enqophileko kanye nomutjhwana owodwa namkha ngehla kowodwa oyamileko. Kilobubujamo kutjho bonyana kuba khona umutjho ovangileko obhebhule imitjhwana eyamileko.

'''Isibonelo 1:'''

[ Ababelethi babafundi abangaphumeleliko babiziwe bonyana bakhambele umhlangano esikolweni ngoMvulo. ]

La sithola imitjho emibili enqophileko ehlanganiswe ngesihlanganiso u(bonyana).

[Ababelethi babiziwe]

(Ababelethi)- yihloko yomutjho.

(babiziwe)- silandiso

bonyana - sihlanganiso

[ bakhambele umhlangano]

(bakhambele)- silandiso

(umhlangano)- ngumenziwa

Sibuye sithole imitjhwana emibili, ohlathulula usobizo nokhanyisa isilandiso.

(babafundi abangaphumeleliko)- mumutjhwana oyamileko ohlathulula usobizo (ababelethi)

(esikolweni ngoMvulo)- mumutjhwana oyamileko okhanyisa isilandiso (bakhambele).

'''Isibonelo 2:'''

[ Abantu abanjingileko abanengi bathanda izinto ezihle begodu bathenga ukudla eentolo ezibizako.]

[Abantu bathanda izinto]- mumutjho onqophileko

(abanjingileko abanengi) – mumutjhwana oyamileko ohlathulula usobizo (abantu)

(ezihle)- mumutjhwana oyamileko ohlathulula usobizo (izinto)

begodu- sihlanganiso

[ bathenga ukudla]- mumutjho onqophileko

(eentolo ezibizako)- mumutjhwana oyamileko okhanyisa isilandiso (bathenga)

'''&lt;u&gt;Umsebenzi 1&lt;/u&gt;'''

Tlola bonyana umutjho ngamunye kongenzasi umhlobo bani womutjho.

(a) Umntwana ulise ibele ngombana uyamilisa.

(b) Abafundi bafunda incwadi.

(c) Imbuzi emhlophe esikazi ibuyile izolo emini.

(d) Ubaba uthenge ikoloyi.

(e) UDlhamaga ukhelele amanzi emlanjeni ekuseni ngombana ugogo udiniwe.

(f) Iinkoloyi ezitja ezibizako zithengiwe.

(g) Ugogo utheza iinkuni ukuze umma abase umlilo bese uvusa abantwana.

(h) Thina sithanda ibholo edlawa ngeenyawo begodu sithanda ukuyidlala etatawini qobe ngoSondo.

'''&lt;u&gt;Umsebenzi 2&lt;/u&gt;'''

Fundisisa isiqetjhana esingenzasi bese uphendula imibuzo elandelako:

2.1 Tlola bonyana umutjho othalelwe emudeni woku-1 umhlobo bani womutjhwana (1)

2.2 Tlola bonyana umutjho otlolwe ngokunzima khulu emudeni wesi-2 umhlobo bani womutjho. (1)

AmaNdebele sitjhaba &lt;u&gt;esihle esihloniphekileko&lt;/u&gt; kwaNzunza nakwaManala. '''Thina senza amasiko''' anothileko ngendlelethu ehlukileko. Umgwalo wesiNdebele ukubiza ukude le ngombana uzidle ngemibalawo emihle nekhanyako. Nakuneminyanya, ingadla ibetjhwa egagadwini kuvungame ithuli, babe bodwa abathi mzimba jugujeka, babe bodwa abathi tjhida ngitjhudule. Kiyo yoke iminyanya sifinya ngendololwana sibethe sentwala. &lt;u&gt;Iinhlobo ezikude ziyamenywa ngombana umnyanya omkhulu uyahlelelwa&lt;/u&gt;. Abobaba bahlaba ikomo bese abomma bapheka ukudla. Ilanga nalithi phatjha! Vane sele kukghutjhulwe ngebekonyana. Abobaba bavuma ingoma. Ngokukopheza kwelihlo, umphako vane sewungdliwa mntwana. Ngiyasithanda isiKhethu ngombana ngiyazikhakhazisa. &lt;u&gt;Utjwala obubilisiweko besintu buyaphekwa&lt;/u&gt;. Ukuphekwa kotjwala nokuhlatjwa kwembuzi kusebenza njongomhlahlandlela wokuthintana nabezimu bethu. Abomakhelani bayeza ukuze sigidinge nabo. Ukunotha kwesintu sethu kulele kithi, maNdebele ngombana indlela ibuzwa kwabaphambili.

[Umtlolo wokuzitlamela : Nsizwa Mahlangu]


2.3 Umujho othalelwe emudeni wesi-6 ovange bupandepande. Kiwo khupha umutjho ovangileko. (2)

2.3 Umujho othi, “Abobaba bahlaba ikomo bese abomma bapheka ukudla” mumutjho…

A onqophileko

B opandepande

C ovangileko

D ovange bupandepande. (1)

2.4 Buyelela utlole umutjho onqophileko ongenzasi kodwana uveze ukulandula.

Abobaba bavuma ingoma. (1)

2.5 Emutjhweni opandepande othalelwe emudeni we-10, khupa:

(a) Umutjho onqophileko/omkhulu. (1)

(b) Umutjhwana oyamileko ohlathululako. (1)

2.6 Veza umehluko okhona phakathi komutjho onqophileko nomutjho ovangileko. (2)

2.7 Veza umehluko okhona phakathi komutjho opandepande nomutjho ovange bupandepande/opandepande vangileko. (2)

2.8 Tlola bonyana isitatimende ngasinye kwezingenzasi siLiqiniso namkha Mamala

(a) Umutjho onqophileko uba neenlandiso ezimbili. (1)

(b) Umutjho onqophileko uyakwazi ukuzijamela uwodwa unikele umqondo opheleleko kiloyo mutjho. (1)

(c) Umutjho opandepande uyaba nomutjhwana oyamileko ohlathululako namkha okhanyisako. (1)

(d) Umutjhwana oyamileko ohlathululako uhlathulula isilandiso. (1)

(e) Umutjhwana oyamileko okhanyisako ukhanyisa usobizo. (1)

(f) Umutjho ovangileko uba nemitjho emibili namkha ngehla kwemibili enqophileko bese ihlanganiswa ngesihlanganiso esithileko. (1)

(g) Umutjho ovange bupandepande awubi nemitjhwana eyamileko. (1)

(h) Isilandiso esethula umqondo opheleleko emutjhweni onqophileko sisenzo esisendleleni esabizo. (1)

2.8 Hlaziya umthetho wehlelomutjho (syntax) mayelana nokwakhiwa komutjho ngokulandela isisekelo sakhona esivamileko lokha nakwakhiwa umutjho olula. (4)

2.9 Tshwaya ngokuhlolisisa indima edlalwa silandiso lokha nakwakhiwa umutjho esiNdebeleni. (4)

2.10 Tlola isibonelo sakho somutjho opandepande (2)

[30]
</text>
      <sha1>4d9gq0mpuucikty1i9wd6ywhty8ptlw</sha1>
    </revision>
    <revision>
      <id>6324</id>
      <parentid>3044</parentid>
      <timestamp>2026-03-23T09:43:49Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <origin>6324</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="10960" sha1="etwl83x9djqgqwnvp0a78wj3puy25bs" xml:space="preserve">== 1.1. Isifundo Semitjho ==
Uyini umutjho?

Umutjho libuthelelo lamagama alandelanako atloliweko namkha akhulunyiweko ahlelwe ngendlela yokobana ethule umqondo othileko. Ilandelano lamagama kufanele lihleleke kuhle ukuze umutjho loyo unikele umqondo. Kungebangelo-ke sithi lihlelomutjho (syntax).

Akhesifunde umutjho olandelako sibone bonyana wenza umqondo na:

[Abantwana ibholo badlala.]

Kuyavela bonyana umutjho ongehla lo awukahleleki kuhle. Akhesiwuhlele kuhle ngokuya kwehlelomutjho.

[Abantwana badlala ibholo.]

Umutjho ongehla lo sele wenza umqondo ngombana ilandelano lamagama lihleleke kuhle. Umutjho esiNdebeleni, njengakiwo woke amalimi, ulandela isakhiwo esisisekelo ngalendlela:

Ihloko Isenzo Umenziwa [Subject Verb Object (SVO)] 

'''Isibonelo:'''

[ Ubaba utjhuka isikhumba.]

Ubaba- yihloko

utjhuka-sisenzo

isikhumba-ngumenziwa

• Umutjho opheleleko esiNdebeleni uba nehloko nesilandiso. Isilandiso ngiso esithwele ummongo zombelele womutjho. Ngaphandle kwesilandiso, umutjho awukho. Isilandiso kuba sisenzo namkha isbanjalo.

• Isilandiso esakha umutjho opheleleko sisenzo esikghona ukutjhugutjhugulula iinkhathi zesenzo (finite verb) ingasi isenzo esisendlelni esabizo (infinitive)

'''Isibonelo:'''

[ Ukusela amanzi ] – umutjho lo awukapheleli ngombana unesenzo esisendlelni esisabizo (infinitive) (ukusela). Akhesilungelele isenzo esikghona ukutjhugutjhugulula iinkhathi zesenzo sibone.

[ Ukusela amanzi ngiyakuthanda. ] – umutjho lo sele uphelele ngombana kunesilandiso esikghona ukutjhugutjhugulula iinkhathi zesenzo. Singatjho sithi,

(ngizokuthanda/ngikuthandile/ngisakuthanda.)

== 1.2 Imihlobo Yemitjho: ==
EsiNdebeleni sinemihlobo EMINE yemitjho ekungile elandelako:

(1) &lt;u&gt;'''Umutjho onqophileko/olula/omkhulu (Simple sentence)'''&lt;/u&gt;

Umutjho onqophileko wakhiwa yihloko, isilandiso esisodwa kanye nomenziwa. Umutjho lo wethula umqondo owodwa. Kuyenzeka bonyana umutjho onqophileko uvume namkha ulandule.

'''Isibonelo:'''

[ Abantwana badlala ibhlolo.] -uyavuma

[ Abantwana abayidlali ibholo.] -uyalandula

[ Ugogo yinyanga.] -uyavuma

[ Ugogo akasiyo inyanga. ]- uyalandula

Umutjho onqophileko kuyenzeka bonyana ube nehloko nesilandiso kwaphela, umenziwa angabi khona. Kilobubujamo kutjho bonyana umenziwa ubhaqile.

'''Isibonelo:'''

[ Abantwana bayadlala.]

[ Abantwana abadlali ]

Umutjho onqophileko godu kuyenzeka bonyana ungabi nehloko, kodwana ube nesilandiso nomenziwa kwaphela. Kilobubujamo kutjho bonyana ihloko yomutjho ibhaqile. Isilandiso ekusisenzo siba nesivumelwano sehloko esifuze ihloko yomutjho ebhaqileko.

'''Isibonelo:'''

[ Badlala ibholo. ]

[ Abayidlali ibholo.]

Ihloko yomutjho ebhaqileko ngu(Abantwana). Isivumelwano sakhona sehloko u(ba-) siyavela esilandisweni. Umutjho onqophileko godu uyakwazi ukuba silandiso esizijamele sisodwa. Isilandisweso siba nesivumelwano sehloko esifuze ihloko yomutjho ebhaqileko.

'''Isibonelo:'''

[ Bayapheka.]- ihloko yomutjho ebhaqileko ngu (Bona).

[ Zizelamani. ]- ihloko yomutjho ebhaqileko ngu (Zona)

Kuyenzeka godu bonyana umutjho onqophileko ube sisenzo esisedleleni ekatelelako enganaso isivumelwano sehloko.

'''Isibonelo:'''

[ Vuka! ] – ihloko yomutjho ebhaqileko ngu (Wena)=(Wena vuka!)

(2) '''&lt;u&gt;Umutjho ovangileko (Compound sentence)&lt;/u&gt;'''

Umutjho ovangileko wakhiwa mimitjho emibili namkha ngehla kwemibili enqophileko ihlanganiswe ngesihlanganiso esithileko. Nangabe kuneenlandiso ezimbili, kutjho khona bonyana kunemitjho emibili enqophileko. Iinhlanganiso ezisetjenziselwa ukwakha umutjho ovangileko ngilezi ezilandulako:

[ ngombana, kodwana, begodu, godu, bese, ukuze, kanti, bonyana, njengombana]

'''Isibonelo 1:'''

[ UMsongelwa uyafunda ngombana uyasithanda isikolo.]

Umutjho wokuthoma ngothi, [ UMsongelwa uyafunda. ]

Umutjho wesibili ngothi, [ uyasithanda isikolo.]

Isihlanganiso ngu ( ngombana ).

'''Isibonelo 2:'''

[ Abobaba bahlaba ikomo bese abomma bapheka iinredlo. ]

Umutjho wokuthoma ngothi, [ Abobaba bahlaba ikomo. ]

Umutjho wesibili ngothi, [ abomma bapheka iinredlo. ]

Isihlanganiso ngu (bese).

'''Isibonelo 3:'''

[ Ugogo ugayela utjwala ngombana ubamkhulu womile bese umma uhlanza amarhabha. ]

Umutjho wokuthoma ngothi, [ Ugogo ugayela utjwala. ]

Umutjho wesibili ngothi, [ ubamkhulu womile. ]

Umutjho wesithathu ngothi, [ umma uhlanza amarhabha. ]

Isihlanganiso ngu (ngombana) no (bese)

(3) &lt;u&gt;'''Umutjho opandepande (Complex sentence)'''&lt;/u&gt;

Umutjho opandepande mumutjho owakhiwa mumutjho owodwa onqophileko kanye nomutjhwana owodwa namkha ngehla kowodwa oyamileko. Umutjhwana oyamileko ungayama ngokuthi uhlathulule usobizo namkha ukhanyise isilandiso.

• Umutjhwana oyamileko ohlathululako wakhiwa libinzana lesitlhadlhuli (Adjectival phrase) bese umuthjwana oyamileko okhanyisako wakhiwa

libinzana lesikhanyiso (Adverbial phrase).

• Umutjhwana oyamileko sithi mumutjhwana oyamileko ngombana awukwazi ukuzijamela uwodwa unikele umqondo opheleleko. Uyame

emutjhweni omkhulu/onqophileko ukuze wenze umqondo. Kungebangelo sithi libinzana (phrase).

• Nasikhupha umutjho onqophileko emutjhweni opandepande, kulindeleke bonyana kuvele ihloko nesilandiso kwaphela.

'''Isibonelo 1:'''

[ Indoda ede enzima izile izolo emini esikolweni. ]

[Indoda izile.] – mumutjho onqophileko

(ede enzima) – mumutjhwana oyamileko ohlathululo usobizo (Indoda)

(izolo emini esikolweni) – mumutjhwana oyamileko okhanyisa isilandiso (izile)

'''Isibonelo 2:'''

[ Abafundi abafundako bayaphumelela eemfundweni zabo. ]

[ Abafundi bayaphumelela. ] – mumutjho onqophileko.

(abafundako)- mumutjhwana oyamileko ohlathululako usobizo (Abafundi)

(eemfundweni zabo)- mumutjhwana oyamileko okhanyisa isilandiso (bayaphumelela)

Okutjhejekako kukobana ngaphandle komutjho onqophileko, umutjho opandepande angeze wenza umqondo. Imitjhwana eyamileko isebenza

njengeselulo somutjho onqophileko iwenze umutjho opandepande.

(4) '''&lt;u&gt;Umutjho ovange bupandepande/opandepande vangileko (Compound complex sentence)&lt;/u&gt;'''

Umutjho ovange bupandepande/opandepande ovangileko mumutjho owakhiwa mimitjho emibili enqophileko kanye nomutjhwana owodwa namkha ngehla kowodwa oyamileko. Kilobubujamo kutjho bonyana kuba khona umutjho ovangileko obhebhule imitjhwana eyamileko.

'''Isibonelo 1:'''

[ Ababelethi babafundi abangaphumeleliko babiziwe bonyana bakhambele umhlangano esikolweni ngoMvulo. ]

La sithola imitjho emibili enqophileko ehlanganiswe ngesihlanganiso u(bonyana).

[Ababelethi babiziwe]

(Ababelethi)- yihloko yomutjho.

(babiziwe)- silandiso

bonyana - sihlanganiso

[ bakhambele umhlangano]

(bakhambele)- silandiso

(umhlangano)- ngumenziwa

Sibuye sithole imitjhwana emibili, ohlathulula usobizo nokhanyisa isilandiso.

(babafundi abangaphumeleliko)- mumutjhwana oyamileko ohlathulula usobizo (ababelethi)

(esikolweni ngoMvulo)- mumutjhwana oyamileko okhanyisa isilandiso (bakhambele).

'''Isibonelo 2:'''

[ Abantu abanjingileko abanengi bathanda izinto ezihle begodu bathenga ukudla eentolo ezibizako.]

[Abantu bathanda izinto]- mumutjho onqophileko

(abanjingileko abanengi) – mumutjhwana oyamileko ohlathulula usobizo (abantu)

(ezihle)- mumutjhwana oyamileko ohlathulula usobizo (izinto)

begodu- sihlanganiso

[ bathenga ukudla]- mumutjho onqophileko

(eentolo ezibizako)- mumutjhwana oyamileko okhanyisa isilandiso (bathenga)

'''&lt;u&gt;Umsebenzi 1&lt;/u&gt;'''

Tlola bonyana umutjho ngamunye kongenzasi umhlobo bani womutjho.

(a) Umntwana ulise ibele ngombana uyamilisa.

(b) Abafundi bafunda incwadi.

(c) Imbuzi emhlophe esikazi ibuyile izolo emini.

(d) Ubaba uthenge ikoloyi.

(e) UDlhamaga ukhelele amanzi emlanjeni ekuseni ngombana ugogo udiniwe.

(f) Iinkoloyi ezitja ezibizako zithengiwe.

(g) Ugogo utheza iinkuni ukuze umma abase umlilo bese uvusa abantwana.

(h) Thina sithanda ibholo edlawa ngeenyawo begodu sithanda ukuyidlala etatawini qobe ngoSondo.

'''&lt;u&gt;Umsebenzi 2&lt;/u&gt;'''

Fundisisa isiqetjhana esingenzasi bese uphendula imibuzo elandelako:

2.1 Tlola bonyana umutjho othalelwe emudeni woku-1 umhlobo bani womutjhwana (1)

2.2 Tlola bonyana umutjho otlolwe ngokunzima khulu emudeni wesi-2 umhlobo bani womutjho. (1)

AmaNdebele sitjhaba &lt;u&gt;esihle esihloniphekileko&lt;/u&gt; kwaNzunza nakwaManala. '''Thina senza amasiko''' anothileko ngendlelethu ehlukileko. Umgwalo wesiNdebele ukubiza ukude le ngombana uzidle ngemibalawo emihle nekhanyako. Nakuneminyanya, ingadla ibetjhwa egagadwini kuvungame ithuli, babe bodwa abathi mzimba jugujeka, babe bodwa abathi tjhida ngitjhudule. Kiyo yoke iminyanya sifinya ngendololwana sibethe sentwala. &lt;u&gt;Iinhlobo ezikude ziyamenywa ngombana umnyanya omkhulu uyahlelelwa&lt;/u&gt;. Abobaba bahlaba ikomo bese abomma bapheka ukudla. Ilanga nalithi phatjha! Vane sele kukghutjhulwe ngebekonyana. Abobaba bavuma ingoma. Ngokukopheza kwelihlo, umphako vane sewungdliwa mntwana. Ngiyasithanda isiKhethu ngombana ngiyazikhakhazisa. &lt;u&gt;Utjwala obubilisiweko besintu buyaphekwa&lt;/u&gt;. Ukuphekwa kotjwala nokuhlatjwa kwembuzi kusebenza njongomhlahlandlela wokuthintana nabezimu bethu. Abomakhelani bayeza ukuze sigidinge nabo. Ukunotha kwesintu sethu kulele kithi, maNdebele ngombana indlela ibuzwa kwabaphambili.

[Umtlolo wokuzitlamela : Nsizwa Mahlangu]


2.3 Umujho othalelwe emudeni wesi-6 ovange bupandepande. Kiwo khupha umutjho ovangileko. (2)

2.3 Umujho othi, “Abobaba bahlaba ikomo bese abomma bapheka ukudla” mumutjho…

A onqophileko

B opandepande

C ovangileko

D ovange bupandepande. (1)

2.4 Buyelela utlole umutjho onqophileko ongenzasi kodwana uveze ukulandula.

Abobaba bavuma ingoma. (1)

2.5 Emutjhweni opandepande othalelwe emudeni we-10, khupa:

(a) Umutjho onqophileko/omkhulu. (1)

(b) Umutjhwana oyamileko ohlathululako. (1)

2.6 Veza umehluko okhona phakathi komutjho onqophileko nomutjho ovangileko. (2)

2.7 Veza umehluko okhona phakathi komutjho opandepande nomutjho ovange bupandepande/opandepande vangileko. (2)

2.8 Tlola bonyana isitatimende ngasinye kwezingenzasi siLiqiniso namkha Mamala

(a) Umutjho onqophileko uba neenlandiso ezimbili. (1)

(b) Umutjho onqophileko uyakwazi ukuzijamela uwodwa unikele umqondo opheleleko kiloyo mutjho. (1)

(c) Umutjho opandepande uyaba nomutjhwana oyamileko ohlathululako namkha okhanyisako. (1)

(d) Umutjhwana oyamileko ohlathululako uhlathulula isilandiso. (1)

(e) Umutjhwana oyamileko okhanyisako ukhanyisa usobizo. (1)

(f) Umutjho ovangileko uba nemitjho emibili namkha ngehla kwemibili enqophileko bese ihlanganiswa ngesihlanganiso esithileko. (1)

(g) Umutjho ovange bupandepande awubi nemitjhwana eyamileko. (1)

(h) Isilandiso esethula umqondo opheleleko emutjhweni onqophileko sisenzo esisendleleni esabizo. (1)

2.8 Hlaziya umthetho wehlelomutjho (syntax) mayelana nokwakhiwa komutjho ngokulandela isisekelo sakhona esivamileko lokha nakwakhiwa umutjho olula. (4)

2.9 Tshwaya ngokuhlolisisa indima edlalwa silandiso lokha nakwakhiwa umutjho esiNdebeleni. (4)

2.10 Tlola isibonelo sakho somutjho opandepande (2)

[30]

== Iinkomba ==
UMTLOLI: N.P Mahlangu</text>
      <sha1>etwl83x9djqgqwnvp0a78wj3puy25bs</sha1>
    </revision>
  </page>
  <page>
    <title>ISewula Afrika ne-Afrika eseSewula (South Africa and Southern Africa).</title>
    <ns>0</ns>
    <id>141</id>
    <revision>
      <id>678</id>
      <timestamp>2024-08-07T05:50:52Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;== '''ISewula Afrika ne-Afrika eseSewula (South Africa and Southern Africa).''' ==  === '''Isingeniso''' === Kukhona amanye amagama abonakala begodu azwakala ngathi atjho into yinye kodwa ekubeni atjho izinto ezihlukileko. Amagama lawo esikhathi esinengi agcina asetjenziswa kwangathi yinto yinye ngabanye abantu. Amagama la afaka hlanga iSewula Afrika ne-Afrika eseSewula. Ekumimeni yethi le sizokunqopha kumehluko hlangana kweSewula Afrika ne-Afrika eseSewula.  === '''Kuyi...&quot;</comment>
      <origin>678</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1502" sha1="s5kqmruzl5fav6mo7x0d32w72ixtfky" xml:space="preserve">== '''ISewula Afrika ne-Afrika eseSewula (South Africa and Southern Africa).''' ==

=== '''Isingeniso''' ===
Kukhona amanye amagama abonakala begodu azwakala ngathi atjho into yinye kodwa ekubeni atjho izinto ezihlukileko. Amagama lawo esikhathi esinengi agcina asetjenziswa kwangathi yinto yinye ngabanye abantu. Amagama la afaka hlanga iSewula Afrika ne-Afrika eseSewula. Ekumimeni yethi le sizokunqopha kumehluko hlangana kweSewula Afrika ne-Afrika eseSewula.

=== '''Kuyin iSewula Afrika?''' ===
ISewula Afrika kuyinarha leyo etholakala enarheni kazi ye-Afrika. ISewula Afrika yinarha etholaka ekugcineni kweSewula ye-Afrika. Kubalazwe, itholakala encasi kunazo zoke iinarha ezikhona e-Afrika. Ukungezelela, iSewula Afrika iyingcenye nanyana ingezinye zeenarha ezibumba i-Afrika eseSewula.

=== '''Kuyini i-Afrika eseSewula?''' ===
I-Afrika eseSewula libizobuthelelo lelo elitjho iinarha ezifunyanwa eSewula ye-Afrika. Ngamanye amagama, ziinarha lezo esengcenyeni esencasi e-Afrika. Lokhu kutjho bonyana ziinarha ezifunyanwa esiyingi seSewula e-Afrika. Iinarha lezi zifaka hlangana  i-Angola, iBotswana, iLesotho, iMalawi, iMozambique, iNamibia, iSewula Afrika, Eswatini, i-Zambia neZimbabwe. Zoke iinarha lezi nazihlangeneko zibizwa bonyana i-Afrika eseSewula.

=== '''Isiphetho.''' ===
Kuqakathekile bonyana sazi umlando wethu kanye nokuthi iinarhakazi ye-Afrika le esihlala kiyo ihlukaniswe njani. Yeke-ke, nje sesiyazi bonyana iSewula Afrika kuyinarha ngaphakathi kwesiyingi seSewula e-Afrika.</text>
      <sha1>s5kqmruzl5fav6mo7x0d32w72ixtfky</sha1>
    </revision>
    <revision>
      <id>679</id>
      <parentid>678</parentid>
      <timestamp>2024-09-18T15:40:43Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>679</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1503" sha1="km7cnfrfnfphg9mkxkd77whblnw6tfu" xml:space="preserve">== '''ISewula Afrika ne-Afrika eseSewula (South Africa and Southern Africa).''' ==

=== '''Isingeniso.''' ===
Kukhona amanye amagama abonakala begodu azwakala ngathi atjho into yinye kodwa ekubeni atjho izinto ezihlukileko. Amagama lawo esikhathi esinengi agcina asetjenziswa kwangathi yinto yinye ngabanye abantu. Amagama la afaka hlanga iSewula Afrika ne-Afrika eseSewula. Ekumimeni yethi le sizokunqopha kumehluko hlangana kweSewula Afrika ne-Afrika eseSewula.

=== '''Kuyin iSewula Afrika?''' ===
ISewula Afrika kuyinarha leyo etholakala enarheni kazi ye-Afrika. ISewula Afrika yinarha etholaka ekugcineni kweSewula ye-Afrika. Kubalazwe, itholakala encasi kunazo zoke iinarha ezikhona e-Afrika. Ukungezelela, iSewula Afrika iyingcenye nanyana ingezinye zeenarha ezibumba i-Afrika eseSewula.

=== '''Kuyini i-Afrika eseSewula?''' ===
I-Afrika eseSewula libizobuthelelo lelo elitjho iinarha ezifunyanwa eSewula ye-Afrika. Ngamanye amagama, ziinarha lezo esengcenyeni esencasi e-Afrika. Lokhu kutjho bonyana ziinarha ezifunyanwa esiyingi seSewula e-Afrika. Iinarha lezi zifaka hlangana  i-Angola, iBotswana, iLesotho, iMalawi, iMozambique, iNamibia, iSewula Afrika, Eswatini, i-Zambia neZimbabwe. Zoke iinarha lezi nazihlangeneko zibizwa bonyana i-Afrika eseSewula.

=== '''Isiphetho.''' ===
Kuqakathekile bonyana sazi umlando wethu kanye nokuthi iinarhakazi ye-Afrika le esihlala kiyo ihlukaniswe njani. Yeke-ke, nje sesiyazi bonyana iSewula Afrika kuyinarha ngaphakathi kwesiyingi seSewula e-Afrika.</text>
      <sha1>km7cnfrfnfphg9mkxkd77whblnw6tfu</sha1>
    </revision>
    <revision>
      <id>680</id>
      <parentid>679</parentid>
      <timestamp>2024-10-14T13:46:42Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>679</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1503" sha1="km7cnfrfnfphg9mkxkd77whblnw6tfu" xml:space="preserve">== '''ISewula Afrika ne-Afrika eseSewula (South Africa and Southern Africa).''' ==

=== '''Isingeniso.''' ===
Kukhona amanye amagama abonakala begodu azwakala ngathi atjho into yinye kodwa ekubeni atjho izinto ezihlukileko. Amagama lawo esikhathi esinengi agcina asetjenziswa kwangathi yinto yinye ngabanye abantu. Amagama la afaka hlanga iSewula Afrika ne-Afrika eseSewula. Ekumimeni yethi le sizokunqopha kumehluko hlangana kweSewula Afrika ne-Afrika eseSewula.

=== '''Kuyin iSewula Afrika?''' ===
ISewula Afrika kuyinarha leyo etholakala enarheni kazi ye-Afrika. ISewula Afrika yinarha etholaka ekugcineni kweSewula ye-Afrika. Kubalazwe, itholakala encasi kunazo zoke iinarha ezikhona e-Afrika. Ukungezelela, iSewula Afrika iyingcenye nanyana ingezinye zeenarha ezibumba i-Afrika eseSewula.

=== '''Kuyini i-Afrika eseSewula?''' ===
I-Afrika eseSewula libizobuthelelo lelo elitjho iinarha ezifunyanwa eSewula ye-Afrika. Ngamanye amagama, ziinarha lezo esengcenyeni esencasi e-Afrika. Lokhu kutjho bonyana ziinarha ezifunyanwa esiyingi seSewula e-Afrika. Iinarha lezi zifaka hlangana  i-Angola, iBotswana, iLesotho, iMalawi, iMozambique, iNamibia, iSewula Afrika, Eswatini, i-Zambia neZimbabwe. Zoke iinarha lezi nazihlangeneko zibizwa bonyana i-Afrika eseSewula.

=== '''Isiphetho.''' ===
Kuqakathekile bonyana sazi umlando wethu kanye nokuthi iinarhakazi ye-Afrika le esihlala kiyo ihlukaniswe njani. Yeke-ke, nje sesiyazi bonyana iSewula Afrika kuyinarha ngaphakathi kwesiyingi seSewula e-Afrika.</text>
      <sha1>km7cnfrfnfphg9mkxkd77whblnw6tfu</sha1>
    </revision>
    <revision>
      <id>1748</id>
      <parentid>680</parentid>
      <timestamp>2024-10-24T00:34:45Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1748</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1393" sha1="dt1ljryys1dzscykuv7zl7gv834auan" xml:space="preserve">Kukhona amanye amagama abonakala begodu azwakala ngathi atjho into yinye kodwa ekubeni atjho izinto ezihlukileko. Amagama lawo esikhathi esinengi agcina asetjenziswa kwangathi yinto yinye ngabanye abantu. Amagama la afaka hlanga iSewula Afrika ne-Afrika eseSewula. Ekumimeni yethi le sizokunqopha kumehluko hlangana kweSewula Afrika ne-Afrika eseSewula.

=== '''Kuyin iSewula Afrika?''' ===
ISewula Afrika kuyinarha leyo etholakala enarheni kazi ye-Afrika. ISewula Afrika yinarha etholaka ekugcineni kweSewula ye-Afrika. Kubalazwe, itholakala encasi kunazo zoke iinarha ezikhona e-Afrika. Ukungezelela, iSewula Afrika iyingcenye nanyana ingezinye zeenarha ezibumba i-Afrika eseSewula.

=== '''Kuyini i-Afrika eseSewula?''' ===
I-Afrika eseSewula libizobuthelelo lelo elitjho iinarha ezifunyanwa eSewula ye-Afrika. Ngamanye amagama, ziinarha lezo esengcenyeni esencasi e-Afrika. Lokhu kutjho bonyana ziinarha ezifunyanwa esiyingi seSewula e-Afrika. Iinarha lezi zifaka hlangana  i-Angola, iBotswana, iLesotho, iMalawi, iMozambique, iNamibia, iSewula Afrika, Eswatini, i-Zambia neZimbabwe. Zoke iinarha lezi nazihlangeneko zibizwa bonyana i-Afrika eseSewula.

=== '''Isiphetho.''' ===
Kuqakathekile bonyana sazi umlando wethu kanye nokuthi iinarhakazi ye-Afrika le esihlala kiyo ihlukaniswe njani. Yeke-ke, nje sesiyazi bonyana iSewula Afrika kuyinarha ngaphakathi kwesiyingi seSewula e-Afrika.</text>
      <sha1>dt1ljryys1dzscykuv7zl7gv834auan</sha1>
    </revision>
  </page>
  <page>
    <title>Ivunulo</title>
    <ns>0</ns>
    <id>142</id>
    <revision>
      <id>681</id>
      <timestamp>2024-03-09T09:56:01Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;Ivunulo yizambatho ezimbathwa maNdebele eminyanyeni ehlukahlukileko. Ivunulo ibalulekile esikweni lama Ndebele begodu ngiyo ehlathulula bona ulenzile isiko noma awa. Bazikhakhazisa ngendlela ekarisako ngendlela ebambatha ngayo. Izembatho ezinengi zesiko zinento ebizwa bona mncamo.  &quot;</comment>
      <origin>681</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="283" sha1="7hnfk5mr0aje6fbf2ovm0vi3refsvbq" xml:space="preserve">Ivunulo yizambatho ezimbathwa maNdebele eminyanyeni ehlukahlukileko. Ivunulo ibalulekile esikweni lama Ndebele begodu ngiyo ehlathulula bona ulenzile isiko noma awa. Bazikhakhazisa ngendlela ekarisako ngendlela ebambatha ngayo. Izembatho ezinengi zesiko zinento ebizwa bona mncamo.

</text>
      <sha1>7hnfk5mr0aje6fbf2ovm0vi3refsvbq</sha1>
    </revision>
    <revision>
      <id>682</id>
      <parentid>681</parentid>
      <timestamp>2024-03-09T09:57:13Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>682</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="289" sha1="4srrrjjefw3hxbtu3cevcu4f6tckm4p" xml:space="preserve">'''Ivunulo''' yizambatho ezimbathwa maNdebele eminyanyeni ehlukahlukileko. Ivunulo ibalulekile esikweni lama Ndebele begodu ngiyo ehlathulula bona ulenzile isiko noma awa. Bazikhakhazisa ngendlela ekarisako ngendlela ebambatha ngayo. Izembatho ezinengi zesiko zinento ebizwa bona mncamo.

</text>
      <sha1>4srrrjjefw3hxbtu3cevcu4f6tckm4p</sha1>
    </revision>
    <revision>
      <id>683</id>
      <parentid>682</parentid>
      <timestamp>2024-03-09T09:59:27Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>683</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="357" sha1="4e2vj6ni4svl601qrgbgrwibyzrodys" xml:space="preserve">[[Isimumathi:AmaNdebele.jpg|left|thumb|'''Ivunulo yama Ndebele''']]
'''Ivunulo''' yizambatho ezimbathwa maNdebele eminyanyeni ehlukahlukileko. Ivunulo ibalulekile esikweni lama Ndebele begodu ngiyo ehlathulula bona ulenzile isiko noma awa. Bazikhakhazisa ngendlela ekarisako ngendlela ebambatha ngayo. Izembatho ezinengi zesiko zinento ebizwa bona mncamo.

</text>
      <sha1>4e2vj6ni4svl601qrgbgrwibyzrodys</sha1>
    </revision>
    <revision>
      <id>684</id>
      <parentid>683</parentid>
      <timestamp>2024-03-09T10:12:41Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>684</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1046" sha1="p6k2pnycnjaf2ysv1j8qmk95plhyhfj" xml:space="preserve">[[Isimumathi:AmaNdebele.jpg|left|thumb|'''Ivunulo yama Ndebele''']]
'''Ivunulo''' yizambatho ezimbathwa maNdebele eminyanyeni ehlukahlukileko. Ivunulo ibalulekile esikweni lama Ndebele begodu ngiyo ehlathulula bona ulenzile isiko noma awa. Bazikhakhazisa ngendlela ekarisako ngendlela ebambatha ngayo. Izembatho ezinengi zesiko zinento ebizwa bona mncamo. 



====== &lt;u&gt;ABO MMA NABO BABA&lt;/u&gt; ======
[[Isimumathi:Abomma nabo baba.jpg|thumb|253x253px|'''Abomma nabo baba''']]
'''&lt;u&gt;Abomma&lt;/u&gt;'''

Abo mma ngomnyanya lapho umswegwabo aba yisokona bambatha ivunulo esuka ehloko efika eenyaweni. Ehloko bambatha umkhala nomlinga kobe. emzimbeni bambatha ingubo ebovu ebizwa bona yi bhidi.

'''&lt;u&gt;Abobaba&lt;/u&gt;'''

abo baba emnyanyeni ongehla nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. Ehloko bambatha iporiyana, esandleni sokudla baphatha intonga bese ngesandleni sesincele baphatha isiviko.


'''&lt;u&gt;UMSWEGWABO&lt;/u&gt;'''

Umswegwabo msana ongakenzi isiko nofana msana ongakayi engomeni. ivunulo yaba swegwabo ngiyo elula ukudlula zoke. Bambatha
</text>
      <sha1>p6k2pnycnjaf2ysv1j8qmk95plhyhfj</sha1>
    </revision>
    <revision>
      <id>685</id>
      <parentid>684</parentid>
      <timestamp>2024-03-09T10:18:51Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>685</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1415" sha1="su0lfwyvzv4rzzghmr6a2ljyqw4wmqs" xml:space="preserve">[[Isimumathi:AmaNdebele.jpg|left|thumb|'''Ivunulo yama Ndebele''']]
'''Ivunulo''' yizambatho ezimbathwa maNdebele eminyanyeni ehlukahlukileko. Ivunulo ibalulekile esikweni lama Ndebele begodu ngiyo ehlathulula bona ulenzile isiko noma awa. Bazikhakhazisa ngendlela ekarisako ngendlela ebambatha ngayo. Izembatho ezinengi zesiko zinento ebizwa bona mncamo. 



====== &lt;u&gt;ABO MMA NABO BABA&lt;/u&gt; ======
[[Isimumathi:Abomma nabo baba.jpg|thumb|253x253px|'''Abomma nabo baba''']]
'''&lt;u&gt;Abomma&lt;/u&gt;'''

Abo mma ngomnyanya lapho umswegwabo aba yisokona bambatha ivunulo esuka ehloko efika eenyaweni. Ehloko bambatha umkhala nomlinga kobe. emzimbeni bambatha ingubo ebovu ebizwa bona yi bhidi.

'''&lt;u&gt;Abobaba&lt;/u&gt;'''

abo baba emnyanyeni ongehla nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. Ehloko bambatha iporiyana, esandleni sokudla baphatha intonga bese ngesandleni sesincele baphatha isiviko.


'''&lt;u&gt;UMSWEGWABO&lt;/u&gt;'''
[[Isimumathi:Abasegwabo.jpg|left|thumb|206x206px|Umswegwabo]]
Umswegwabo msana ongakenzi isiko nofana msana ongakayi engomeni. ivunulo yaba swegwabo ngiyo elula ukudlula zoke. Nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. Ehloko bambatha utjani ebenzwe indingiliza ebubizwa bona ngu swenyana, emzimbeni bambatha i yembhe yemikhono emide, eenyaweni bambatha ibhrugu elifitjhani bese esandleni sokudla baphatha intonga. Bakhamba ngo bhadu phasi okuhlathulula bona abambathi amanyathelo.
</text>
      <sha1>su0lfwyvzv4rzzghmr6a2ljyqw4wmqs</sha1>
    </revision>
    <revision>
      <id>686</id>
      <parentid>685</parentid>
      <timestamp>2024-03-09T10:19:13Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>/* ABO MMA NABO BABA */</comment>
      <origin>686</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1414" sha1="h3td4lv2jicvhvd13sh941i9ktyf14e" xml:space="preserve">[[Isimumathi:AmaNdebele.jpg|left|thumb|'''Ivunulo yama Ndebele''']]
'''Ivunulo''' yizambatho ezimbathwa maNdebele eminyanyeni ehlukahlukileko. Ivunulo ibalulekile esikweni lama Ndebele begodu ngiyo ehlathulula bona ulenzile isiko noma awa. Bazikhakhazisa ngendlela ekarisako ngendlela ebambatha ngayo. Izembatho ezinengi zesiko zinento ebizwa bona mncamo. 


====== &lt;u&gt;ABO MMA NABO BABA&lt;/u&gt; ======
[[Isimumathi:Abomma nabo baba.jpg|thumb|253x253px|'''Abomma nabo baba''']]
'''&lt;u&gt;Abomma&lt;/u&gt;'''

Abo mma ngomnyanya lapho umswegwabo aba yisokona bambatha ivunulo esuka ehloko efika eenyaweni. Ehloko bambatha umkhala nomlinga kobe. emzimbeni bambatha ingubo ebovu ebizwa bona yi bhidi.

'''&lt;u&gt;Abobaba&lt;/u&gt;'''

abo baba emnyanyeni ongehla nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. Ehloko bambatha iporiyana, esandleni sokudla baphatha intonga bese ngesandleni sesincele baphatha isiviko.


'''&lt;u&gt;UMSWEGWABO&lt;/u&gt;'''
[[Isimumathi:Abasegwabo.jpg|left|thumb|206x206px|Umswegwabo]]
Umswegwabo msana ongakenzi isiko nofana msana ongakayi engomeni. ivunulo yaba swegwabo ngiyo elula ukudlula zoke. Nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. Ehloko bambatha utjani ebenzwe indingiliza ebubizwa bona ngu swenyana, emzimbeni bambatha i yembhe yemikhono emide, eenyaweni bambatha ibhrugu elifitjhani bese esandleni sokudla baphatha intonga. Bakhamba ngo bhadu phasi okuhlathulula bona abambathi amanyathelo.
</text>
      <sha1>h3td4lv2jicvhvd13sh941i9ktyf14e</sha1>
    </revision>
    <revision>
      <id>687</id>
      <parentid>686</parentid>
      <timestamp>2024-03-09T10:42:38Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <origin>687</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2723" sha1="15panr3inyrwng3t6l8zwk70rzdkeiz" xml:space="preserve">[[Isimumathi:AmaNdebele.jpg|left|thumb|'''Ivunulo yama Ndebele''']]
'''Ivunulo''' yizambatho ezimbathwa maNdebele eminyanyeni ehlukahlukileko. Ivunulo ibalulekile esikweni lama Ndebele begodu ngiyo ehlathulula bona ulenzile isiko noma awa. Bazikhakhazisa ngendlela ekarisako ngendlela ebambatha ngayo. Izembatho ezinengi zesiko zinento ebizwa bona mncamo. 



== &lt;u&gt;ABO MMA NABO BABA&lt;/u&gt; ==
[[Isimumathi:Abomma nabo baba.jpg|thumb|253x253px|'''Abomma nabo baba''']]
'''&lt;u&gt;Abomma&lt;/u&gt;'''

Abo mma ngomnyanya lapho umswegwabo aba yisokona bambatha ivunulo esuka ehloko efika eenyaweni. Ehloko bambatha umkhala nomlinga kobe. emzimbeni bambatha ingubo ebovu ebizwa bona yi bhidi.

'''&lt;u&gt;Abobaba&lt;/u&gt;'''

abo baba emnyanyeni ongehla nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. Ehloko bambatha iporiyana, esandleni sokudla baphatha intonga bese ngesandleni sesincele baphatha isiviko.

== &lt;u&gt;UMSWEGWABO&lt;/u&gt; ==
[[Isimumathi:Abasegwabo.jpg|left|thumb|183x183px|'''Umswegwabo''']]
Umswegwabo msana ongakenzi isiko nofana msana ongakayi engomeni. ivunulo yaba swegwabo ngiyo elula ukudlula zoke. Nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. Ehloko bambatha utjani ebenzwe indingiliza ebubizwa bona ngu swenyana, emzimbeni bambatha i yembhe yemikhono emide, eenyaweni bambatha ibhrugu elifitjhani bese esandleni sokudla baphatha intonga. Bakhamba ngo bhadu phasi okuhlathulula bona abambathi amanyathelo.



== '''&lt;u&gt;AMASOKANA&lt;/u&gt;''' ==
[[Isimumathi:Amasokana.jpg|left|thumb|260x260px|'''Amasokana''']]
Isokana mumuntu wejazi owenze isiko begodu wahlatjelwa wakhamba nabo baba. Ivunulo yama sokana nayo isuka ehloko ifinyelele emilenzeni. Ehloko bambatha umkhala, entameni bambatha irasu, edinini bambatha ijuba nobukhobe, emikhonweni kanye nemilenzeni bambatha iinrholwani. imibala yakhona ngu nzima, hlaza okwesibhakabhaka, hlaza satjani, ubukhobe kanye nomhlophe. Koke lokhu kwenziwe ngomncamo. Iinrholwani lezi zinendlela ezilandelana ngayo ngokuya kwesiko. Isithombe esingehlanzeni sesincelesi masokana asayokwenza isiko ivunulo yabo ihlukile kunamasokana sele aqedileko. Ivunulo yabo ilula njengale yomswegwabo. Bona bambatha ibhetjha kanje neenzipha kwaphela bese baphathe intonga ngesandleni sokudla.


== '''&lt;u&gt;ABENTAZANA&lt;/u&gt;''' ==
[[Isimumathi:Abentazana.jpg|thumb|'''Abentazana''']]
Abentazana ngomhlubulo nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. ehloko bambatha umkhala, entameni bambatha irasu, edinini iphephethu, iinrholwani zedinini (ijuba nobukhobe), isithimba kanye ne yerhana. Ezandleni bambatha iinrholwani ezinemibalabala babuye bazembathe kanye neenyaweni. Imibala yakhona ngu nzima, hlaza okwesibhakabhaka, hlaza satjani, ubukhobe kanye nomhlophe. Koke lokhu kwenziwe ngomncamo.

</text>
      <sha1>15panr3inyrwng3t6l8zwk70rzdkeiz</sha1>
    </revision>
    <revision>
      <id>688</id>
      <parentid>687</parentid>
      <timestamp>2024-03-09T10:43:39Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>688</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2727" sha1="j3065nrct0c89mlg9h2yvflvq3uj88i" xml:space="preserve">[[Isimumathi:AmaNdebele.jpg|left|thumb|'''Ivunulo yama Ndebele''']]
'''Ivunulo''' yizambatho ezimbathwa maNdebele eminyanyeni ehlukahlukileko. Ivunulo ibalulekile esikweni lama [[Ndebele]] begodu ngiyo ehlathulula bona ulenzile isiko noma awa. Bazikhakhazisa ngendlela ekarisako ngendlela ebambatha ngayo. Izembatho ezinengi zesiko zinento ebizwa bona mncamo. 



== &lt;u&gt;ABO MMA NABO BABA&lt;/u&gt; ==
[[Isimumathi:Abomma nabo baba.jpg|thumb|253x253px|'''Abomma nabo baba''']]
'''&lt;u&gt;Abomma&lt;/u&gt;'''

Abo mma ngomnyanya lapho umswegwabo aba yisokona bambatha ivunulo esuka ehloko efika eenyaweni. Ehloko bambatha umkhala nomlinga kobe. emzimbeni bambatha ingubo ebovu ebizwa bona yi bhidi.

'''&lt;u&gt;Abobaba&lt;/u&gt;'''

abo baba emnyanyeni ongehla nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. Ehloko bambatha iporiyana, esandleni sokudla baphatha intonga bese ngesandleni sesincele baphatha isiviko.

== &lt;u&gt;UMSWEGWABO&lt;/u&gt; ==
[[Isimumathi:Abasegwabo.jpg|left|thumb|183x183px|'''Umswegwabo''']]
Umswegwabo msana ongakenzi isiko nofana msana ongakayi engomeni. ivunulo yaba swegwabo ngiyo elula ukudlula zoke. Nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. Ehloko bambatha utjani ebenzwe indingiliza ebubizwa bona ngu swenyana, emzimbeni bambatha i yembhe yemikhono emide, eenyaweni bambatha ibhrugu elifitjhani bese esandleni sokudla baphatha intonga. Bakhamba ngo bhadu phasi okuhlathulula bona abambathi amanyathelo.



== '''&lt;u&gt;AMASOKANA&lt;/u&gt;''' ==
[[Isimumathi:Amasokana.jpg|left|thumb|260x260px|'''Amasokana''']]
Isokana mumuntu wejazi owenze isiko begodu wahlatjelwa wakhamba nabo baba. Ivunulo yama sokana nayo isuka ehloko ifinyelele emilenzeni. Ehloko bambatha umkhala, entameni bambatha irasu, edinini bambatha ijuba nobukhobe, emikhonweni kanye nemilenzeni bambatha iinrholwani. imibala yakhona ngu nzima, hlaza okwesibhakabhaka, hlaza satjani, ubukhobe kanye nomhlophe. Koke lokhu kwenziwe ngomncamo. Iinrholwani lezi zinendlela ezilandelana ngayo ngokuya kwesiko. Isithombe esingehlanzeni sesincelesi masokana asayokwenza isiko ivunulo yabo ihlukile kunamasokana sele aqedileko. Ivunulo yabo ilula njengale yomswegwabo. Bona bambatha ibhetjha kanje neenzipha kwaphela bese baphathe intonga ngesandleni sokudla.


== '''&lt;u&gt;ABENTAZANA&lt;/u&gt;''' ==
[[Isimumathi:Abentazana.jpg|thumb|'''Abentazana''']]
Abentazana ngomhlubulo nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. ehloko bambatha umkhala, entameni bambatha irasu, edinini iphephethu, iinrholwani zedinini (ijuba nobukhobe), isithimba kanye ne yerhana. Ezandleni bambatha iinrholwani ezinemibalabala babuye bazembathe kanye neenyaweni. Imibala yakhona ngu nzima, hlaza okwesibhakabhaka, hlaza satjani, ubukhobe kanye nomhlophe. Koke lokhu kwenziwe ngomncamo.

</text>
      <sha1>j3065nrct0c89mlg9h2yvflvq3uj88i</sha1>
    </revision>
    <revision>
      <id>689</id>
      <parentid>688</parentid>
      <timestamp>2024-03-09T10:45:32Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>689</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2805" sha1="dh8e3wcvdkuxaiamt6aydw95rn2muiv" xml:space="preserve">[[Isimumathi:AmaNdebele.jpg|left|thumb|'''Ivunulo yama Ndebele''']]
'''Ivunulo''' yizambatho ezimbathwa maNdebele eminyanyeni ehlukahlukileko. Ivunulo ibalulekile esikweni lama [[Ndebele]] begodu ngiyo ehlathulula bona ulenzile isiko noma awa. Bazikhakhazisa ngendlela ekarisako ngendlela ebambatha ngayo. Izembatho ezinengi zesiko zinento ebizwa bona mncamo. 



== &lt;u&gt;ABO MMA NABO BABA&lt;/u&gt; ==
[[Isimumathi:Abomma nabo baba.jpg|thumb|253x253px|'''Abomma nabo baba''']]
'''&lt;u&gt;Abomma&lt;/u&gt;'''

Abo mma ngomnyanya lapho umswegwabo aba yisokona bambatha ivunulo esuka ehloko efika eenyaweni. Ehloko bambatha umkhala nomlinga kobe. emzimbeni bambatha ingubo ebovu ebizwa bona yi bhidi.

'''&lt;u&gt;Abobaba&lt;/u&gt;'''

abo baba emnyanyeni ongehla nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. Ehloko bambatha iporiyana, esandleni sokudla baphatha intonga bese ngesandleni sesincele baphatha isiviko.

== &lt;u&gt;UMSWEGWABO&lt;/u&gt; ==
[[Isimumathi:Abasegwabo.jpg|left|thumb|183x183px|'''Umswegwabo''']]
Umswegwabo msana ongakenzi isiko nofana msana ongakayi engomeni. ivunulo yaba swegwabo ngiyo elula ukudlula zoke. Nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. Ehloko bambatha utjani ebenzwe indingiliza ebubizwa bona ngu swenyana, emzimbeni bambatha i yembhe yemikhono emide, eenyaweni bambatha ibhrugu elifitjhani bese esandleni sokudla baphatha intonga. Bakhamba ngo bhadu phasi okuhlathulula bona abambathi amanyathelo. Batjhagala endleleni ukutjengisa abantu bona sebalungile ukukhamba nabo baba.



== '''&lt;u&gt;AMASOKANA&lt;/u&gt;''' ==
[[Isimumathi:Amasokana.jpg|left|thumb|260x260px|'''Amasokana''']]
Isokana mumuntu wejazi owenze isiko begodu wahlatjelwa wakhamba nabo baba. Ivunulo yama sokana nayo isuka ehloko ifinyelele emilenzeni. Ehloko bambatha umkhala, entameni bambatha irasu, edinini bambatha ijuba nobukhobe, emikhonweni kanye nemilenzeni bambatha iinrholwani. imibala yakhona ngu nzima, hlaza okwesibhakabhaka, hlaza satjani, ubukhobe kanye nomhlophe. Koke lokhu kwenziwe ngomncamo. Iinrholwani lezi zinendlela ezilandelana ngayo ngokuya kwesiko. Isithombe esingehlanzeni sesincelesi masokana asayokwenza isiko ivunulo yabo ihlukile kunamasokana sele aqedileko. Ivunulo yabo ilula njengale yomswegwabo. Bona bambatha ibhetjha kanje neenzipha kwaphela bese baphathe intonga ngesandleni sokudla.


== '''&lt;u&gt;ABENTAZANA&lt;/u&gt;''' ==
[[Isimumathi:Abentazana.jpg|thumb|'''Abentazana''']]
Abentazana ngomhlubulo nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. ehloko bambatha umkhala, entameni bambatha irasu, edinini iphephethu, iinrholwani zedinini (ijuba nobukhobe), isithimba kanye ne yerhana. Ezandleni bambatha iinrholwani ezinemibalabala babuye bazembathe kanye neenyaweni. Imibala yakhona ngu nzima, hlaza okwesibhakabhaka, hlaza satjani, ubukhobe kanye nomhlophe. Koke lokhu kwenziwe ngomncamo.

</text>
      <sha1>dh8e3wcvdkuxaiamt6aydw95rn2muiv</sha1>
    </revision>
    <revision>
      <id>690</id>
      <parentid>689</parentid>
      <timestamp>2024-03-09T10:47:32Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>690</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2810" sha1="accbnukhas82mbb9afz0008p3fyr255" xml:space="preserve">[[Isimumathi:AmaNdebele.jpg|left|thumb|'''Ivunulo yama Ndebele''']]
'''Ivunulo''' yizambatho ezimbathwa maNdebele eminyanyeni ehlukahlukileko. Ivunulo ibalulekile esikweni lama [[Ndebele]] begodu ngiyo ehlathulula bona ulenzile isiko noma awa. Bazikhakhazisa ngendlela ekarisako ngendlela ebambatha ngayo. Izembatho ezinengi zesiko zinento ebizwa bona mncamo.  



== &lt;u&gt;ABO MMA NABO BABA&lt;/u&gt; ==
[[Isimumathi:Abomma nabo baba.jpg|thumb|253x253px|'''Abomma nabo baba''']]
'''&lt;u&gt;Abomma&lt;/u&gt;'''

Abo mma ngomnyanya lapho umswegwabo aba yisokona bambatha ivunulo esuka ehloko efika eenyaweni. Ehloko bambatha umkhala nomlinga kobe. emzimbeni bambatha ingubo ebovu ebizwa bona yi bhidi.

'''&lt;u&gt;Abobaba&lt;/u&gt;'''

abo baba emnyanyeni ongehla nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. Ehloko bambatha iporiyana, esandleni sokudla baphatha intonga bese ngesandleni sesincele baphatha isiviko.

== &lt;u&gt;UMSWEGWABO&lt;/u&gt; ==
[[Isimumathi:Abasegwabo.jpg|left|thumb|183x183px|'''Umswegwabo''']]
Umswegwabo [[msana]] ongakenzi isiko nofana msana ongakayi engomeni. ivunulo yaba swegwabo ngiyo elula ukudlula zoke. Nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. Ehloko bambatha utjani ebenzwe indingiliza ebubizwa bona ngu swenyana, emzimbeni bambatha i yembhe yemikhono emide, eenyaweni bambatha ibhrugu elifitjhani bese esandleni sokudla baphatha intonga. Bakhamba ngo bhadu phasi okuhlathulula bona abambathi amanyathelo. Batjhagala endleleni ukutjengisa abantu bona sebalungile ukukhamba nabo baba.



== '''&lt;u&gt;AMASOKANA&lt;/u&gt;''' ==
[[Isimumathi:Amasokana.jpg|left|thumb|260x260px|'''Amasokana''']]
Isokana mumuntu wejazi owenze isiko begodu wahlatjelwa wakhamba nabo baba. Ivunulo yama sokana nayo isuka ehloko ifinyelele emilenzeni. Ehloko bambatha umkhala, entameni bambatha irasu, edinini bambatha ijuba nobukhobe, emikhonweni kanye nemilenzeni bambatha iinrholwani. imibala yakhona ngu nzima, hlaza okwesibhakabhaka, hlaza satjani, ubukhobe kanye nomhlophe. Koke lokhu kwenziwe ngomncamo. Iinrholwani lezi zinendlela ezilandelana ngayo ngokuya kwesiko. Isithombe esingehlanzeni sesincelesi masokana asayokwenza isiko ivunulo yabo ihlukile kunamasokana sele aqedileko. Ivunulo yabo ilula njengale yomswegwabo. Bona bambatha ibhetjha kanje neenzipha kwaphela bese baphathe intonga ngesandleni sokudla.


== '''&lt;u&gt;ABENTAZANA&lt;/u&gt;''' ==
[[Isimumathi:Abentazana.jpg|thumb|'''Abentazana''']]
Abentazana ngomhlubulo nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. ehloko bambatha umkhala, entameni bambatha irasu, edinini iphephethu, iinrholwani zedinini (ijuba nobukhobe), isithimba kanye ne yerhana. Ezandleni bambatha iinrholwani ezinemibalabala babuye bazembathe kanye neenyaweni. Imibala yakhona ngu nzima, hlaza okwesibhakabhaka, hlaza satjani, ubukhobe kanye nomhlophe. Koke lokhu kwenziwe ngomncamo.

</text>
      <sha1>accbnukhas82mbb9afz0008p3fyr255</sha1>
    </revision>
    <revision>
      <id>691</id>
      <parentid>690</parentid>
      <timestamp>2024-03-09T10:47:52Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>691</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2814" sha1="71kdt900ndjmt0j4udu9tqhgv369g2d" xml:space="preserve">[[Isimumathi:AmaNdebele.jpg|left|thumb|'''Ivunulo yama Ndebele''']]
'''Ivunulo''' yizambatho ezimbathwa maNdebele eminyanyeni ehlukahlukileko. Ivunulo ibalulekile esikweni lama [[Ndebele]] begodu ngiyo ehlathulula bona ulenzile isiko noma awa. Bazikhakhazisa ngendlela ekarisako ngendlela ebambatha ngayo. Izembatho ezinengi zesiko zinento ebizwa bona mncamo.  



== &lt;u&gt;ABO MMA NABO BABA&lt;/u&gt; ==
[[Isimumathi:Abomma nabo baba.jpg|thumb|253x253px|'''Abomma nabo baba''']]
'''&lt;u&gt;Abomma&lt;/u&gt;'''

Abo mma ngomnyanya lapho umswegwabo aba yisokona bambatha ivunulo esuka ehloko efika eenyaweni. Ehloko bambatha umkhala nomlinga kobe. emzimbeni bambatha ingubo ebovu ebizwa bona yi bhidi.

'''&lt;u&gt;Abobaba&lt;/u&gt;'''

abo baba emnyanyeni ongehla nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. Ehloko bambatha iporiyana, esandleni sokudla baphatha intonga bese ngesandleni sesincele baphatha isiviko.

== &lt;u&gt;UMSWEGWABO&lt;/u&gt; ==
[[Isimumathi:Abasegwabo.jpg|left|thumb|183x183px|'''Umswegwabo''']]
Umswegwabo [[msana]] ongakenzi isiko nofana msana ongakayi engomeni. ivunulo yaba swegwabo ngiyo elula ukudlula zoke. Nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. Ehloko bambatha utjani ebenzwe [[indingiliza]] ebubizwa bona ngu swenyana, emzimbeni bambatha i yembhe yemikhono emide, eenyaweni bambatha ibhrugu elifitjhani bese esandleni sokudla baphatha intonga. Bakhamba ngo bhadu phasi okuhlathulula bona abambathi amanyathelo. Batjhagala endleleni ukutjengisa abantu bona sebalungile ukukhamba nabo baba.



== '''&lt;u&gt;AMASOKANA&lt;/u&gt;''' ==
[[Isimumathi:Amasokana.jpg|left|thumb|260x260px|'''Amasokana''']]
Isokana mumuntu wejazi owenze isiko begodu wahlatjelwa wakhamba nabo baba. Ivunulo yama sokana nayo isuka ehloko ifinyelele emilenzeni. Ehloko bambatha umkhala, entameni bambatha irasu, edinini bambatha ijuba nobukhobe, emikhonweni kanye nemilenzeni bambatha iinrholwani. imibala yakhona ngu nzima, hlaza okwesibhakabhaka, hlaza satjani, ubukhobe kanye nomhlophe. Koke lokhu kwenziwe ngomncamo. Iinrholwani lezi zinendlela ezilandelana ngayo ngokuya kwesiko. Isithombe esingehlanzeni sesincelesi masokana asayokwenza isiko ivunulo yabo ihlukile kunamasokana sele aqedileko. Ivunulo yabo ilula njengale yomswegwabo. Bona bambatha ibhetjha kanje neenzipha kwaphela bese baphathe intonga ngesandleni sokudla.


== '''&lt;u&gt;ABENTAZANA&lt;/u&gt;''' ==
[[Isimumathi:Abentazana.jpg|thumb|'''Abentazana''']]
Abentazana ngomhlubulo nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. ehloko bambatha umkhala, entameni bambatha irasu, edinini iphephethu, iinrholwani zedinini (ijuba nobukhobe), isithimba kanye ne yerhana. Ezandleni bambatha iinrholwani ezinemibalabala babuye bazembathe kanye neenyaweni. Imibala yakhona ngu nzima, hlaza okwesibhakabhaka, hlaza satjani, ubukhobe kanye nomhlophe. Koke lokhu kwenziwe ngomncamo.

</text>
      <sha1>71kdt900ndjmt0j4udu9tqhgv369g2d</sha1>
    </revision>
    <revision>
      <id>692</id>
      <parentid>691</parentid>
      <timestamp>2024-03-09T10:49:03Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>692</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2915" sha1="r12qj5ih2gpmtvox3uxpdm6pl6ay5sq" xml:space="preserve">[[Isimumathi:AmaNdebele.jpg|left|thumb|'''Ivunulo yama Ndebele''']]
'''Ivunulo''' yizambatho ezimbathwa maNdebele eminyanyeni ehlukahlukileko. Ivunulo ibalulekile esikweni lama [[Ndebele]] begodu ngiyo ehlathulula bona ulenzile isiko noma awa. Bazikhakhazisa ngendlela ekarisako ngendlela ebambatha ngayo. Izembatho ezinengi zesiko zinento ebizwa bona mncamo. [[Wp/nd/IsiNdebele|IsiNdebele]] sikarisa kwamambala egodu ivunulo yabo inemibala eminengi ekhanyako.  



== &lt;u&gt;ABO MMA NABO BABA&lt;/u&gt; ==
[[Isimumathi:Abomma nabo baba.jpg|thumb|253x253px|'''Abomma nabo baba''']]
'''&lt;u&gt;Abomma&lt;/u&gt;'''

Abo mma ngomnyanya lapho umswegwabo aba yisokona bambatha ivunulo esuka ehloko efika eenyaweni. Ehloko bambatha umkhala nomlinga kobe. emzimbeni bambatha ingubo ebovu ebizwa bona yi bhidi.

'''&lt;u&gt;Abobaba&lt;/u&gt;'''

abo baba emnyanyeni ongehla nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. Ehloko bambatha iporiyana, esandleni sokudla baphatha intonga bese ngesandleni sesincele baphatha isiviko.

== &lt;u&gt;UMSWEGWABO&lt;/u&gt; ==
[[Isimumathi:Abasegwabo.jpg|left|thumb|183x183px|'''Umswegwabo''']]
Umswegwabo [[msana]] ongakenzi isiko nofana msana ongakayi engomeni. ivunulo yaba swegwabo ngiyo elula ukudlula zoke. Nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. Ehloko bambatha utjani ebenzwe [[indingiliza]] ebubizwa bona ngu swenyana, emzimbeni bambatha i yembhe yemikhono emide, eenyaweni bambatha ibhrugu elifitjhani bese esandleni sokudla baphatha intonga. Bakhamba ngo bhadu phasi okuhlathulula bona abambathi amanyathelo. Batjhagala endleleni ukutjengisa abantu bona sebalungile ukukhamba nabo baba.



== '''&lt;u&gt;AMASOKANA&lt;/u&gt;''' ==
[[Isimumathi:Amasokana.jpg|left|thumb|260x260px|'''Amasokana''']]
Isokana mumuntu wejazi owenze isiko begodu wahlatjelwa wakhamba nabo baba. Ivunulo yama sokana nayo isuka ehloko ifinyelele emilenzeni. Ehloko bambatha umkhala, entameni bambatha irasu, edinini bambatha ijuba nobukhobe, emikhonweni kanye nemilenzeni bambatha iinrholwani. imibala yakhona ngu nzima, hlaza okwesibhakabhaka, hlaza satjani, ubukhobe kanye nomhlophe. Koke lokhu kwenziwe ngomncamo. Iinrholwani lezi zinendlela ezilandelana ngayo ngokuya kwesiko. Isithombe esingehlanzeni sesincelesi masokana asayokwenza isiko ivunulo yabo ihlukile kunamasokana sele aqedileko. Ivunulo yabo ilula njengale yomswegwabo. Bona bambatha ibhetjha kanje neenzipha kwaphela bese baphathe intonga ngesandleni sokudla.


== '''&lt;u&gt;ABENTAZANA&lt;/u&gt;''' ==
[[Isimumathi:Abentazana.jpg|thumb|'''Abentazana''']]
Abentazana ngomhlubulo nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. ehloko bambatha umkhala, entameni bambatha irasu, edinini iphephethu, iinrholwani zedinini (ijuba nobukhobe), isithimba kanye ne yerhana. Ezandleni bambatha iinrholwani ezinemibalabala babuye bazembathe kanye neenyaweni. Imibala yakhona ngu nzima, hlaza okwesibhakabhaka, hlaza satjani, ubukhobe kanye nomhlophe. Koke lokhu kwenziwe ngomncamo.

</text>
      <sha1>r12qj5ih2gpmtvox3uxpdm6pl6ay5sq</sha1>
    </revision>
    <revision>
      <id>693</id>
      <parentid>692</parentid>
      <timestamp>2024-10-14T13:46:42Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>12 revisions imported</comment>
      <origin>692</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2915" sha1="r12qj5ih2gpmtvox3uxpdm6pl6ay5sq" xml:space="preserve">[[Isimumathi:AmaNdebele.jpg|left|thumb|'''Ivunulo yama Ndebele''']]
'''Ivunulo''' yizambatho ezimbathwa maNdebele eminyanyeni ehlukahlukileko. Ivunulo ibalulekile esikweni lama [[Ndebele]] begodu ngiyo ehlathulula bona ulenzile isiko noma awa. Bazikhakhazisa ngendlela ekarisako ngendlela ebambatha ngayo. Izembatho ezinengi zesiko zinento ebizwa bona mncamo. [[Wp/nd/IsiNdebele|IsiNdebele]] sikarisa kwamambala egodu ivunulo yabo inemibala eminengi ekhanyako.  



== &lt;u&gt;ABO MMA NABO BABA&lt;/u&gt; ==
[[Isimumathi:Abomma nabo baba.jpg|thumb|253x253px|'''Abomma nabo baba''']]
'''&lt;u&gt;Abomma&lt;/u&gt;'''

Abo mma ngomnyanya lapho umswegwabo aba yisokona bambatha ivunulo esuka ehloko efika eenyaweni. Ehloko bambatha umkhala nomlinga kobe. emzimbeni bambatha ingubo ebovu ebizwa bona yi bhidi.

'''&lt;u&gt;Abobaba&lt;/u&gt;'''

abo baba emnyanyeni ongehla nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. Ehloko bambatha iporiyana, esandleni sokudla baphatha intonga bese ngesandleni sesincele baphatha isiviko.

== &lt;u&gt;UMSWEGWABO&lt;/u&gt; ==
[[Isimumathi:Abasegwabo.jpg|left|thumb|183x183px|'''Umswegwabo''']]
Umswegwabo [[msana]] ongakenzi isiko nofana msana ongakayi engomeni. ivunulo yaba swegwabo ngiyo elula ukudlula zoke. Nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. Ehloko bambatha utjani ebenzwe [[indingiliza]] ebubizwa bona ngu swenyana, emzimbeni bambatha i yembhe yemikhono emide, eenyaweni bambatha ibhrugu elifitjhani bese esandleni sokudla baphatha intonga. Bakhamba ngo bhadu phasi okuhlathulula bona abambathi amanyathelo. Batjhagala endleleni ukutjengisa abantu bona sebalungile ukukhamba nabo baba.



== '''&lt;u&gt;AMASOKANA&lt;/u&gt;''' ==
[[Isimumathi:Amasokana.jpg|left|thumb|260x260px|'''Amasokana''']]
Isokana mumuntu wejazi owenze isiko begodu wahlatjelwa wakhamba nabo baba. Ivunulo yama sokana nayo isuka ehloko ifinyelele emilenzeni. Ehloko bambatha umkhala, entameni bambatha irasu, edinini bambatha ijuba nobukhobe, emikhonweni kanye nemilenzeni bambatha iinrholwani. imibala yakhona ngu nzima, hlaza okwesibhakabhaka, hlaza satjani, ubukhobe kanye nomhlophe. Koke lokhu kwenziwe ngomncamo. Iinrholwani lezi zinendlela ezilandelana ngayo ngokuya kwesiko. Isithombe esingehlanzeni sesincelesi masokana asayokwenza isiko ivunulo yabo ihlukile kunamasokana sele aqedileko. Ivunulo yabo ilula njengale yomswegwabo. Bona bambatha ibhetjha kanje neenzipha kwaphela bese baphathe intonga ngesandleni sokudla.


== '''&lt;u&gt;ABENTAZANA&lt;/u&gt;''' ==
[[Isimumathi:Abentazana.jpg|thumb|'''Abentazana''']]
Abentazana ngomhlubulo nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. ehloko bambatha umkhala, entameni bambatha irasu, edinini iphephethu, iinrholwani zedinini (ijuba nobukhobe), isithimba kanye ne yerhana. Ezandleni bambatha iinrholwani ezinemibalabala babuye bazembathe kanye neenyaweni. Imibala yakhona ngu nzima, hlaza okwesibhakabhaka, hlaza satjani, ubukhobe kanye nomhlophe. Koke lokhu kwenziwe ngomncamo.

</text>
      <sha1>r12qj5ih2gpmtvox3uxpdm6pl6ay5sq</sha1>
    </revision>
    <revision>
      <id>1886</id>
      <parentid>693</parentid>
      <timestamp>2024-11-12T19:05:46Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <origin>1886</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2908" sha1="n0cw1jr70p9w55loyge08ra0rvjqf8v" xml:space="preserve">[[Isimumathi:AmaNdebele.jpg|left|thumb|'''Ivunulo yama Ndebele''']]
'''Ivunulo''' yizambatho ezimbathwa maNdebele eminyanyeni ehlukahlukileko. Ivunulo ibalulekile esikweni lama [[Ndebele]] begodu ngiyo ehlathulula bona ulenzile isiko noma awa. Bazikhakhazisa ngendlela ekarisako ngendlela ebambatha ngayo. Izembatho ezinengi zesiko zinento ebizwa bona mncamo. [[Wp/nd/IsiNdebele|IsiNdebele]] sikarisa kwamambala egodu ivunulo yabo inemibala eminengi ekhanyako.  

== &lt;u&gt;ABO MMA NABO BABA&lt;/u&gt; ==
[[Isimumathi:Abomma nabo baba.jpg|thumb|253x253px|'''Abomma nabo baba''']]
'''&lt;u&gt;Abomma&lt;/u&gt;'''

Abo mma ngomnyanya lapho umswegwabo aba yisokona bambatha ivunulo esuka ehloko efika eenyaweni. Ehloko bambatha umkhala nomlinga kobe. emzimbeni bambatha ingubo ebovu ebizwa bona yi bhidi.

'''&lt;u&gt;Abobaba&lt;/u&gt;'''

abo baba emnyanyeni ongehla nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. Ehloko bambatha iporiyana, esandleni sokudla baphatha intonga bese ngesandleni sesincele baphatha isiviko.

== &lt;u&gt;UMSWEGWABO&lt;/u&gt; ==
[[Isimumathi:Abasegwabo.jpg|left|thumb|183x183px|'''Umswegwabo''']]
Umswegwabo [[msana]] ongakenzi isiko nofana msana ongakayi engomeni. ivunulo yaba swegwabo ngiyo elula ukudlula zoke. Nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. Ehloko bambatha utjani ebenzwe [[indingiliza]] ebubizwa bona ngu swenyana, emzimbeni bambatha i yembhe yemikhono emide, eenyaweni bambatha ibhrugu elifitjhani bese esandleni sokudla baphatha intonga. Bakhamba ngo bhadu phasi okuhlathulula bona abambathi amanyathelo. Batjhagala endleleni ukutjengisa abantu bona sebalungile ukukhamba nabo baba.

== '''&lt;u&gt;AMASOKANA&lt;/u&gt;''' ==
[[Isimumathi:Amasokana.jpg|left|thumb|260x260px|'''Amasokana''']]
Isokana mumuntu wejazi owenze isiko begodu wahlatjelwa wakhamba nabo baba. Ivunulo yama sokana nayo isuka ehloko ifinyelele emilenzeni. Ehloko bambatha umkhala, entameni bambatha irasu, edinini bambatha ijuba nobukhobe, emikhonweni kanye nemilenzeni bambatha iinrholwani. imibala yakhona ngu nzima, hlaza okwesibhakabhaka, hlaza satjani, ubukhobe kanye nomhlophe. Koke lokhu kwenziwe ngomncamo. Iinrholwani lezi zinendlela ezilandelana ngayo ngokuya kwesiko. Isithombe esingehlanzeni sesincelesi masokana asayokwenza isiko ivunulo yabo ihlukile kunamasokana sele aqedileko. Ivunulo yabo ilula njengale yomswegwabo. Bona bambatha ibhetjha kanje neenzipha kwaphela bese baphathe intonga ngesandleni sokudla.

== '''&lt;u&gt;ABENTAZANA&lt;/u&gt;''' ==
[[Isimumathi:Abentazana.jpg|thumb|'''Abentazana''']]
Abentazana ngomhlubulo nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. ehloko bambatha umkhala, entameni bambatha irasu, edinini iphephethu, iinrholwani zedinini (ijuba nobukhobe), isithimba kanye ne yerhana. Ezandleni bambatha iinrholwani ezinemibalabala babuye bazembathe kanye neenyaweni. Imibala yakhona ngu nzima, hlaza okwesibhakabhaka, hlaza satjani, ubukhobe kanye nomhlophe. Koke lokhu kwenziwe ngomncamo.</text>
      <sha1>n0cw1jr70p9w55loyge08ra0rvjqf8v</sha1>
    </revision>
    <revision>
      <id>2222</id>
      <parentid>1886</parentid>
      <timestamp>2024-11-29T14:15:30Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* ABENTAZANA */ Abentazana</comment>
      <origin>2222</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2889" sha1="tgxhuqfftlhfv5z9id6lsspthuofm5k" xml:space="preserve">[[Isimumathi:AmaNdebele.jpg|left|thumb|'''Ivunulo yama Ndebele''']]
'''Ivunulo''' yizambatho ezimbathwa maNdebele eminyanyeni ehlukahlukileko. Ivunulo ibalulekile esikweni lama [[Ndebele]] begodu ngiyo ehlathulula bona ulenzile isiko noma awa. Bazikhakhazisa ngendlela ekarisako ngendlela ebambatha ngayo. Izembatho ezinengi zesiko zinento ebizwa bona mncamo. [[Wp/nd/IsiNdebele|IsiNdebele]] sikarisa kwamambala egodu ivunulo yabo inemibala eminengi ekhanyako.  

== &lt;u&gt;ABO MMA NABO BABA&lt;/u&gt; ==
[[Isimumathi:Abomma nabo baba.jpg|thumb|253x253px|'''Abomma nabo baba''']]
'''&lt;u&gt;Abomma&lt;/u&gt;'''

Abo mma ngomnyanya lapho umswegwabo aba yisokona bambatha ivunulo esuka ehloko efika eenyaweni. Ehloko bambatha umkhala nomlinga kobe. emzimbeni bambatha ingubo ebovu ebizwa bona yi bhidi.

'''&lt;u&gt;Abobaba&lt;/u&gt;'''

abo baba emnyanyeni ongehla nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. Ehloko bambatha iporiyana, esandleni sokudla baphatha intonga bese ngesandleni sesincele baphatha isiviko.

== &lt;u&gt;UMSWEGWABO&lt;/u&gt; ==
[[Isimumathi:Abasegwabo.jpg|left|thumb|183x183px|'''Umswegwabo''']]
Umswegwabo [[msana]] ongakenzi isiko nofana msana ongakayi engomeni. ivunulo yaba swegwabo ngiyo elula ukudlula zoke. Nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. Ehloko bambatha utjani ebenzwe [[indingiliza]] ebubizwa bona ngu swenyana, emzimbeni bambatha i yembhe yemikhono emide, eenyaweni bambatha ibhrugu elifitjhani bese esandleni sokudla baphatha intonga. Bakhamba ngo bhadu phasi okuhlathulula bona abambathi amanyathelo. Batjhagala endleleni ukutjengisa abantu bona sebalungile ukukhamba nabo baba.

== '''&lt;u&gt;AMASOKANA&lt;/u&gt;''' ==
[[Isimumathi:Amasokana.jpg|left|thumb|260x260px|'''Amasokana''']]
Isokana mumuntu wejazi owenze isiko begodu wahlatjelwa wakhamba nabo baba. Ivunulo yama sokana nayo isuka ehloko ifinyelele emilenzeni. Ehloko bambatha umkhala, entameni bambatha irasu, edinini bambatha ijuba nobukhobe, emikhonweni kanye nemilenzeni bambatha iinrholwani. imibala yakhona ngu nzima, hlaza okwesibhakabhaka, hlaza satjani, ubukhobe kanye nomhlophe. Koke lokhu kwenziwe ngomncamo. Iinrholwani lezi zinendlela ezilandelana ngayo ngokuya kwesiko. Isithombe esingehlanzeni sesincelesi masokana asayokwenza isiko ivunulo yabo ihlukile kunamasokana sele aqedileko. Ivunulo yabo ilula njengale yomswegwabo. Bona bambatha ibhetjha kanje neenzipha kwaphela bese baphathe intonga ngesandleni sokudla.

== Abentazana ==
[[Isimumathi:Abentazana.jpg|thumb|Abentazana]]
Abentazana ngomhlubulo nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. ehloko bambatha umkhala, entameni bambatha irasu, edinini iphephethu, iinrholwani zedinini (ijuba nobukhobe), isithimba kanye ne yerhana. Ezandleni bambatha iinrholwani ezinemibalabala babuye bazembathe kanye neenyaweni. Imibala yakhona ngu nzima, hlaza okwesibhakabhaka, hlaza satjani, ubukhobe kanye nomhlophe. Koke lokhu kwenziwe ngomncamo.</text>
      <sha1>tgxhuqfftlhfv5z9id6lsspthuofm5k</sha1>
    </revision>
    <revision>
      <id>2223</id>
      <parentid>2222</parentid>
      <timestamp>2024-11-29T14:15:52Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* AMASOKANA */ Amasokana</comment>
      <origin>2223</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2870" sha1="1hpga522zdjmjvaiig8mkd43b6s79vy" xml:space="preserve">[[Isimumathi:AmaNdebele.jpg|left|thumb|'''Ivunulo yama Ndebele''']]
'''Ivunulo''' yizambatho ezimbathwa maNdebele eminyanyeni ehlukahlukileko. Ivunulo ibalulekile esikweni lama [[Ndebele]] begodu ngiyo ehlathulula bona ulenzile isiko noma awa. Bazikhakhazisa ngendlela ekarisako ngendlela ebambatha ngayo. Izembatho ezinengi zesiko zinento ebizwa bona mncamo. [[Wp/nd/IsiNdebele|IsiNdebele]] sikarisa kwamambala egodu ivunulo yabo inemibala eminengi ekhanyako.  

== &lt;u&gt;ABO MMA NABO BABA&lt;/u&gt; ==
[[Isimumathi:Abomma nabo baba.jpg|thumb|253x253px|'''Abomma nabo baba''']]
'''&lt;u&gt;Abomma&lt;/u&gt;'''

Abo mma ngomnyanya lapho umswegwabo aba yisokona bambatha ivunulo esuka ehloko efika eenyaweni. Ehloko bambatha umkhala nomlinga kobe. emzimbeni bambatha ingubo ebovu ebizwa bona yi bhidi.

'''&lt;u&gt;Abobaba&lt;/u&gt;'''

abo baba emnyanyeni ongehla nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. Ehloko bambatha iporiyana, esandleni sokudla baphatha intonga bese ngesandleni sesincele baphatha isiviko.

== &lt;u&gt;UMSWEGWABO&lt;/u&gt; ==
[[Isimumathi:Abasegwabo.jpg|left|thumb|183x183px|'''Umswegwabo''']]
Umswegwabo [[msana]] ongakenzi isiko nofana msana ongakayi engomeni. ivunulo yaba swegwabo ngiyo elula ukudlula zoke. Nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. Ehloko bambatha utjani ebenzwe [[indingiliza]] ebubizwa bona ngu swenyana, emzimbeni bambatha i yembhe yemikhono emide, eenyaweni bambatha ibhrugu elifitjhani bese esandleni sokudla baphatha intonga. Bakhamba ngo bhadu phasi okuhlathulula bona abambathi amanyathelo. Batjhagala endleleni ukutjengisa abantu bona sebalungile ukukhamba nabo baba.

== Amasokana ==
[[Isimumathi:Amasokana.jpg|left|thumb|260x260px|Amasokana]]
Isokana mumuntu wejazi owenze isiko begodu wahlatjelwa wakhamba nabo baba. Ivunulo yama sokana nayo isuka ehloko ifinyelele emilenzeni. Ehloko bambatha umkhala, entameni bambatha irasu, edinini bambatha ijuba nobukhobe, emikhonweni kanye nemilenzeni bambatha iinrholwani. imibala yakhona ngu nzima, hlaza okwesibhakabhaka, hlaza satjani, ubukhobe kanye nomhlophe. Koke lokhu kwenziwe ngomncamo. Iinrholwani lezi zinendlela ezilandelana ngayo ngokuya kwesiko. Isithombe esingehlanzeni sesincelesi masokana asayokwenza isiko ivunulo yabo ihlukile kunamasokana sele aqedileko. Ivunulo yabo ilula njengale yomswegwabo. Bona bambatha ibhetjha kanje neenzipha kwaphela bese baphathe intonga ngesandleni sokudla.

== Abentazana ==
[[Isimumathi:Abentazana.jpg|thumb|Abentazana]]
Abentazana ngomhlubulo nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. ehloko bambatha umkhala, entameni bambatha irasu, edinini iphephethu, iinrholwani zedinini (ijuba nobukhobe), isithimba kanye ne yerhana. Ezandleni bambatha iinrholwani ezinemibalabala babuye bazembathe kanye neenyaweni. Imibala yakhona ngu nzima, hlaza okwesibhakabhaka, hlaza satjani, ubukhobe kanye nomhlophe. Koke lokhu kwenziwe ngomncamo.</text>
      <sha1>1hpga522zdjmjvaiig8mkd43b6s79vy</sha1>
    </revision>
    <revision>
      <id>2224</id>
      <parentid>2223</parentid>
      <timestamp>2024-11-29T14:16:13Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* UMSWEGWABO */ Umswegwabo</comment>
      <origin>2224</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2857" sha1="027q4ya4nyfxmkpo6n6j0ox7a4zj502" xml:space="preserve">[[Isimumathi:AmaNdebele.jpg|left|thumb|'''Ivunulo yama Ndebele''']]
'''Ivunulo''' yizambatho ezimbathwa maNdebele eminyanyeni ehlukahlukileko. Ivunulo ibalulekile esikweni lama [[Ndebele]] begodu ngiyo ehlathulula bona ulenzile isiko noma awa. Bazikhakhazisa ngendlela ekarisako ngendlela ebambatha ngayo. Izembatho ezinengi zesiko zinento ebizwa bona mncamo. [[Wp/nd/IsiNdebele|IsiNdebele]] sikarisa kwamambala egodu ivunulo yabo inemibala eminengi ekhanyako.  

== &lt;u&gt;ABO MMA NABO BABA&lt;/u&gt; ==
[[Isimumathi:Abomma nabo baba.jpg|thumb|253x253px|'''Abomma nabo baba''']]
'''&lt;u&gt;Abomma&lt;/u&gt;'''

Abo mma ngomnyanya lapho umswegwabo aba yisokona bambatha ivunulo esuka ehloko efika eenyaweni. Ehloko bambatha umkhala nomlinga kobe. emzimbeni bambatha ingubo ebovu ebizwa bona yi bhidi.

'''&lt;u&gt;Abobaba&lt;/u&gt;'''

abo baba emnyanyeni ongehla nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. Ehloko bambatha iporiyana, esandleni sokudla baphatha intonga bese ngesandleni sesincele baphatha isiviko.

== Umswegwabo ==
[[Isimumathi:Abasegwabo.jpg|left|thumb|183x183px|Umswegwabo]]
Umswegwabo [[msana]] ongakenzi isiko nofana msana ongakayi engomeni. ivunulo yaba swegwabo ngiyo elula ukudlula zoke. Nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. Ehloko bambatha utjani ebenzwe [[indingiliza]] ebubizwa bona ngu swenyana, emzimbeni bambatha i yembhe yemikhono emide, eenyaweni bambatha ibhrugu elifitjhani bese esandleni sokudla baphatha intonga. Bakhamba ngo bhadu phasi okuhlathulula bona abambathi amanyathelo. Batjhagala endleleni ukutjengisa abantu bona sebalungile ukukhamba nabo baba.

== Amasokana ==
[[Isimumathi:Amasokana.jpg|left|thumb|260x260px|Amasokana]]
Isokana mumuntu wejazi owenze isiko begodu wahlatjelwa wakhamba nabo baba. Ivunulo yama sokana nayo isuka ehloko ifinyelele emilenzeni. Ehloko bambatha umkhala, entameni bambatha irasu, edinini bambatha ijuba nobukhobe, emikhonweni kanye nemilenzeni bambatha iinrholwani. imibala yakhona ngu nzima, hlaza okwesibhakabhaka, hlaza satjani, ubukhobe kanye nomhlophe. Koke lokhu kwenziwe ngomncamo. Iinrholwani lezi zinendlela ezilandelana ngayo ngokuya kwesiko. Isithombe esingehlanzeni sesincelesi masokana asayokwenza isiko ivunulo yabo ihlukile kunamasokana sele aqedileko. Ivunulo yabo ilula njengale yomswegwabo. Bona bambatha ibhetjha kanje neenzipha kwaphela bese baphathe intonga ngesandleni sokudla.

== Abentazana ==
[[Isimumathi:Abentazana.jpg|thumb|Abentazana]]
Abentazana ngomhlubulo nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. ehloko bambatha umkhala, entameni bambatha irasu, edinini iphephethu, iinrholwani zedinini (ijuba nobukhobe), isithimba kanye ne yerhana. Ezandleni bambatha iinrholwani ezinemibalabala babuye bazembathe kanye neenyaweni. Imibala yakhona ngu nzima, hlaza okwesibhakabhaka, hlaza satjani, ubukhobe kanye nomhlophe. Koke lokhu kwenziwe ngomncamo.</text>
      <sha1>027q4ya4nyfxmkpo6n6j0ox7a4zj502</sha1>
    </revision>
    <revision>
      <id>2225</id>
      <parentid>2224</parentid>
      <timestamp>2024-11-29T14:16:35Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* ABO MMA NABO BABA */ Abomma nabo baba</comment>
      <origin>2225</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2843" sha1="1myfl2azjkt5wlfqhrtox42rh6zq7n9" xml:space="preserve">[[Isimumathi:AmaNdebele.jpg|left|thumb|'''Ivunulo yama Ndebele''']]
'''Ivunulo''' yizambatho ezimbathwa maNdebele eminyanyeni ehlukahlukileko. Ivunulo ibalulekile esikweni lama [[Ndebele]] begodu ngiyo ehlathulula bona ulenzile isiko noma awa. Bazikhakhazisa ngendlela ekarisako ngendlela ebambatha ngayo. Izembatho ezinengi zesiko zinento ebizwa bona mncamo. [[Wp/nd/IsiNdebele|IsiNdebele]] sikarisa kwamambala egodu ivunulo yabo inemibala eminengi ekhanyako.  

== Abomma nabo baba ==
[[Isimumathi:Abomma nabo baba.jpg|thumb|253x253px|Abomma nabo baba]]
'''&lt;u&gt;Abomma&lt;/u&gt;'''

Abo mma ngomnyanya lapho umswegwabo aba yisokona bambatha ivunulo esuka ehloko efika eenyaweni. Ehloko bambatha umkhala nomlinga kobe. emzimbeni bambatha ingubo ebovu ebizwa bona yi bhidi.

'''&lt;u&gt;Abobaba&lt;/u&gt;'''

abo baba emnyanyeni ongehla nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. Ehloko bambatha iporiyana, esandleni sokudla baphatha intonga bese ngesandleni sesincele baphatha isiviko.

== Umswegwabo ==
[[Isimumathi:Abasegwabo.jpg|left|thumb|183x183px|Umswegwabo]]
Umswegwabo [[msana]] ongakenzi isiko nofana msana ongakayi engomeni. ivunulo yaba swegwabo ngiyo elula ukudlula zoke. Nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. Ehloko bambatha utjani ebenzwe [[indingiliza]] ebubizwa bona ngu swenyana, emzimbeni bambatha i yembhe yemikhono emide, eenyaweni bambatha ibhrugu elifitjhani bese esandleni sokudla baphatha intonga. Bakhamba ngo bhadu phasi okuhlathulula bona abambathi amanyathelo. Batjhagala endleleni ukutjengisa abantu bona sebalungile ukukhamba nabo baba.

== Amasokana ==
[[Isimumathi:Amasokana.jpg|left|thumb|260x260px|Amasokana]]
Isokana mumuntu wejazi owenze isiko begodu wahlatjelwa wakhamba nabo baba. Ivunulo yama sokana nayo isuka ehloko ifinyelele emilenzeni. Ehloko bambatha umkhala, entameni bambatha irasu, edinini bambatha ijuba nobukhobe, emikhonweni kanye nemilenzeni bambatha iinrholwani. imibala yakhona ngu nzima, hlaza okwesibhakabhaka, hlaza satjani, ubukhobe kanye nomhlophe. Koke lokhu kwenziwe ngomncamo. Iinrholwani lezi zinendlela ezilandelana ngayo ngokuya kwesiko. Isithombe esingehlanzeni sesincelesi masokana asayokwenza isiko ivunulo yabo ihlukile kunamasokana sele aqedileko. Ivunulo yabo ilula njengale yomswegwabo. Bona bambatha ibhetjha kanje neenzipha kwaphela bese baphathe intonga ngesandleni sokudla.

== Abentazana ==
[[Isimumathi:Abentazana.jpg|thumb|Abentazana]]
Abentazana ngomhlubulo nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. ehloko bambatha umkhala, entameni bambatha irasu, edinini iphephethu, iinrholwani zedinini (ijuba nobukhobe), isithimba kanye ne yerhana. Ezandleni bambatha iinrholwani ezinemibalabala babuye bazembathe kanye neenyaweni. Imibala yakhona ngu nzima, hlaza okwesibhakabhaka, hlaza satjani, ubukhobe kanye nomhlophe. Koke lokhu kwenziwe ngomncamo.</text>
      <sha1>1myfl2azjkt5wlfqhrtox42rh6zq7n9</sha1>
    </revision>
    <revision>
      <id>5056</id>
      <parentid>2225</parentid>
      <timestamp>2025-08-07T14:00:19Z</timestamp>
      <contributor>
        <username>Zukesto</username>
        <id>829</id>
      </contributor>
      <comment>ngihlathulule ibizo likaMma bengalungisa nesithomo namkha isingeniso sePage leli</comment>
      <origin>5056</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3160" sha1="3zdl78tqfjmdk6g1syotciipog10b28" xml:space="preserve">[[Isimumathi:AmaNdebele.jpg|left|thumb|'''Ivunulo yama Ndebele''']]
'''Ivunulo''' yizambatho ezimbathwa maNdebele ngokuhlukahlukana kwabo. Ivunulo ibalulekile esikweni lama [[Ndebele]] begodu ngiyo ehlathulula bona ulenzile isiko noma awa, ibuye ihlathulule isigaba somuntu ngokwesiko nesiko-pilo kaNdebele. Bazikhakhazisa ngendlela ekarisako ngendlela ebambatha ngayo. Izembatho ezinengi zesiko zinento ebizwa bona mncamo. [[Wp/nd/IsiNdebele|IsiNdebele]] sikarisa kwamambala begodu ivunulo yabo inemibala eminengi ekhanyako.  

== Abomma nabo baba ==
[[Isimumathi:Abomma nabo baba.jpg|thumb|253x253px|Abomma nabo baba]]
'''&lt;u&gt;Abomma&lt;/u&gt;'''

U-Mma ngokwesiko lesiNdebele kumumuntu wengubo osele adlulile esigabeni sokuba mntazana, begodu ukudlula kwakhe sikuhlathulula ngokobana aphethe isiko lobuntazana elibizwa ngokobana liQude, bekufike lapho athathwa khona abenguMma womuzi wakoSobantu. 

Abo mma ngomnyanya lapho umswegwabo aba yisokona bambatha ivunulo esuka ehloko efika eenyaweni. Ehloko bambatha umkhala nomlinga kobe. emzimbeni bambatha ingubo ebovu ebizwa bona yi bhidi.

'''&lt;u&gt;Abobaba&lt;/u&gt;'''

abo baba emnyanyeni ongehla nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. Ehloko bambatha iporiyana, esandleni sokudla baphatha intonga bese ngesandleni sesincele baphatha isiviko.

== Umswegwabo ==
[[Isimumathi:Abasegwabo.jpg|left|thumb|183x183px|Umswegwabo]]
Umswegwabo [[msana]] ongakenzi isiko nofana msana ongakayi engomeni. ivunulo yaba swegwabo ngiyo elula ukudlula zoke. Nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. Ehloko bambatha utjani ebenzwe [[indingiliza]] ebubizwa bona ngu swenyana, emzimbeni bambatha i yembhe yemikhono emide, eenyaweni bambatha ibhrugu elifitjhani bese esandleni sokudla baphatha intonga. Bakhamba ngo bhadu phasi okuhlathulula bona abambathi amanyathelo. Batjhagala endleleni ukutjengisa abantu bona sebalungile ukukhamba nabo baba.

== Amasokana ==
[[Isimumathi:Amasokana.jpg|left|thumb|260x260px|Amasokana]]
Isokana mumuntu wejazi owenze isiko begodu wahlatjelwa wakhamba nabo baba. Ivunulo yama sokana nayo isuka ehloko ifinyelele emilenzeni. Ehloko bambatha umkhala, entameni bambatha irasu, edinini bambatha ijuba nobukhobe, emikhonweni kanye nemilenzeni bambatha iinrholwani. imibala yakhona ngu nzima, hlaza okwesibhakabhaka, hlaza satjani, ubukhobe kanye nomhlophe. Koke lokhu kwenziwe ngomncamo. Iinrholwani lezi zinendlela ezilandelana ngayo ngokuya kwesiko. Isithombe esingehlanzeni sesincelesi masokana asayokwenza isiko ivunulo yabo ihlukile kunamasokana sele aqedileko. Ivunulo yabo ilula njengale yomswegwabo. Bona bambatha ibhetjha kanje neenzipha kwaphela bese baphathe intonga ngesandleni sokudla.

== Abentazana ==
[[Isimumathi:Abentazana.jpg|thumb|Abentazana]]
Abentazana ngomhlubulo nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. ehloko bambatha umkhala, entameni bambatha irasu, edinini iphephethu, iinrholwani zedinini (ijuba nobukhobe), isithimba kanye ne yerhana. Ezandleni bambatha iinrholwani ezinemibalabala babuye bazembathe kanye neenyaweni. Imibala yakhona ngu nzima, hlaza okwesibhakabhaka, hlaza satjani, ubukhobe kanye nomhlophe. Koke lokhu kwenziwe ngomncamo.</text>
      <sha1>3zdl78tqfjmdk6g1syotciipog10b28</sha1>
    </revision>
    <revision>
      <id>5144</id>
      <parentid>5056</parentid>
      <timestamp>2025-08-11T07:50:37Z</timestamp>
      <contributor>
        <username>Wolverène</username>
        <id>97</id>
      </contributor>
      <minor />
      <comment>Wolverène moved page [[IVUNULO]] to [[Ivunulo]]</comment>
      <origin>5056</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3160" sha1="3zdl78tqfjmdk6g1syotciipog10b28" xml:space="preserve">[[Isimumathi:AmaNdebele.jpg|left|thumb|'''Ivunulo yama Ndebele''']]
'''Ivunulo''' yizambatho ezimbathwa maNdebele ngokuhlukahlukana kwabo. Ivunulo ibalulekile esikweni lama [[Ndebele]] begodu ngiyo ehlathulula bona ulenzile isiko noma awa, ibuye ihlathulule isigaba somuntu ngokwesiko nesiko-pilo kaNdebele. Bazikhakhazisa ngendlela ekarisako ngendlela ebambatha ngayo. Izembatho ezinengi zesiko zinento ebizwa bona mncamo. [[Wp/nd/IsiNdebele|IsiNdebele]] sikarisa kwamambala begodu ivunulo yabo inemibala eminengi ekhanyako.  

== Abomma nabo baba ==
[[Isimumathi:Abomma nabo baba.jpg|thumb|253x253px|Abomma nabo baba]]
'''&lt;u&gt;Abomma&lt;/u&gt;'''

U-Mma ngokwesiko lesiNdebele kumumuntu wengubo osele adlulile esigabeni sokuba mntazana, begodu ukudlula kwakhe sikuhlathulula ngokobana aphethe isiko lobuntazana elibizwa ngokobana liQude, bekufike lapho athathwa khona abenguMma womuzi wakoSobantu. 

Abo mma ngomnyanya lapho umswegwabo aba yisokona bambatha ivunulo esuka ehloko efika eenyaweni. Ehloko bambatha umkhala nomlinga kobe. emzimbeni bambatha ingubo ebovu ebizwa bona yi bhidi.

'''&lt;u&gt;Abobaba&lt;/u&gt;'''

abo baba emnyanyeni ongehla nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. Ehloko bambatha iporiyana, esandleni sokudla baphatha intonga bese ngesandleni sesincele baphatha isiviko.

== Umswegwabo ==
[[Isimumathi:Abasegwabo.jpg|left|thumb|183x183px|Umswegwabo]]
Umswegwabo [[msana]] ongakenzi isiko nofana msana ongakayi engomeni. ivunulo yaba swegwabo ngiyo elula ukudlula zoke. Nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. Ehloko bambatha utjani ebenzwe [[indingiliza]] ebubizwa bona ngu swenyana, emzimbeni bambatha i yembhe yemikhono emide, eenyaweni bambatha ibhrugu elifitjhani bese esandleni sokudla baphatha intonga. Bakhamba ngo bhadu phasi okuhlathulula bona abambathi amanyathelo. Batjhagala endleleni ukutjengisa abantu bona sebalungile ukukhamba nabo baba.

== Amasokana ==
[[Isimumathi:Amasokana.jpg|left|thumb|260x260px|Amasokana]]
Isokana mumuntu wejazi owenze isiko begodu wahlatjelwa wakhamba nabo baba. Ivunulo yama sokana nayo isuka ehloko ifinyelele emilenzeni. Ehloko bambatha umkhala, entameni bambatha irasu, edinini bambatha ijuba nobukhobe, emikhonweni kanye nemilenzeni bambatha iinrholwani. imibala yakhona ngu nzima, hlaza okwesibhakabhaka, hlaza satjani, ubukhobe kanye nomhlophe. Koke lokhu kwenziwe ngomncamo. Iinrholwani lezi zinendlela ezilandelana ngayo ngokuya kwesiko. Isithombe esingehlanzeni sesincelesi masokana asayokwenza isiko ivunulo yabo ihlukile kunamasokana sele aqedileko. Ivunulo yabo ilula njengale yomswegwabo. Bona bambatha ibhetjha kanje neenzipha kwaphela bese baphathe intonga ngesandleni sokudla.

== Abentazana ==
[[Isimumathi:Abentazana.jpg|thumb|Abentazana]]
Abentazana ngomhlubulo nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. ehloko bambatha umkhala, entameni bambatha irasu, edinini iphephethu, iinrholwani zedinini (ijuba nobukhobe), isithimba kanye ne yerhana. Ezandleni bambatha iinrholwani ezinemibalabala babuye bazembathe kanye neenyaweni. Imibala yakhona ngu nzima, hlaza okwesibhakabhaka, hlaza satjani, ubukhobe kanye nomhlophe. Koke lokhu kwenziwe ngomncamo.</text>
      <sha1>3zdl78tqfjmdk6g1syotciipog10b28</sha1>
    </revision>
    <revision>
      <id>5660</id>
      <parentid>5144</parentid>
      <timestamp>2025-09-04T11:12:39Z</timestamp>
      <contributor>
        <username>Kholeka19721</username>
        <id>889</id>
      </contributor>
      <minor />
      <comment>removed the red links.</comment>
      <origin>5660</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3127" sha1="n4752rk9rfd5qsy8j910k3dpuqlpjt4" xml:space="preserve">[[Isimumathi:AmaNdebele.jpg|left|thumb|'''Ivunulo yama Ndebele''']]
'''Ivunulo''' yizambatho ezimbathwa maNdebele ngokuhlukahlukana kwabo. Ivunulo ibalulekile esikweni lama Ndebele begodu ngiyo ehlathulula bona ulenzile isiko noma awa, ibuye ihlathulule isigaba somuntu ngokwesiko nesiko-pilo kaNdebele. Bazikhakhazisa ngendlela ekarisako ngendlela ebambatha ngayo. Izembatho ezinengi zesiko zinento ebizwa bona mncamo. IsiNdebele sikarisa kwamambala begodu ivunulo yabo inemibala eminengi ekhanyako.  

== Abomma nabo baba ==
[[Isimumathi:Abomma nabo baba.jpg|thumb|253x253px|Abomma nabo baba]]
'''&lt;u&gt;Abomma&lt;/u&gt;'''

U-Mma ngokwesiko lesiNdebele kumumuntu wengubo osele adlulile esigabeni sokuba mntazana, begodu ukudlula kwakhe sikuhlathulula ngokobana aphethe isiko lobuntazana elibizwa ngokobana liQude, bekufike lapho athathwa khona abenguMma womuzi wakoSobantu. 

Abo mma ngomnyanya lapho umswegwabo aba yisokona bambatha ivunulo esuka ehloko efika eenyaweni. Ehloko bambatha umkhala nomlinga kobe. emzimbeni bambatha ingubo ebovu ebizwa bona yi bhidi.

'''&lt;u&gt;Abobaba&lt;/u&gt;'''

abo baba emnyanyeni ongehla nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. Ehloko bambatha iporiyana, esandleni sokudla baphatha intonga bese ngesandleni sesincele baphatha isiviko.

== Umswegwabo ==
[[Isimumathi:Abasegwabo.jpg|left|thumb|183x183px|Umswegwabo]]
Umswegwabo msana ongakenzi isiko nofana msana ongakayi engomeni. ivunulo yaba swegwabo ngiyo elula ukudlula zoke. Nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. Ehloko bambatha utjani ebenzwe indingiliza ebubizwa bona ngu swenyana, emzimbeni bambatha i yembhe yemikhono emide, eenyaweni bambatha ibhrugu elifitjhani bese esandleni sokudla baphatha intonga. Bakhamba ngo bhadu phasi okuhlathulula bona abambathi amanyathelo. Batjhagala endleleni ukutjengisa abantu bona sebalungile ukukhamba nabo baba.

== Amasokana ==
[[Isimumathi:Amasokana.jpg|left|thumb|260x260px|Amasokana]]
Isokana mumuntu wejazi owenze isiko begodu wahlatjelwa wakhamba nabo baba. Ivunulo yama sokana nayo isuka ehloko ifinyelele emilenzeni. Ehloko bambatha umkhala, entameni bambatha irasu, edinini bambatha ijuba nobukhobe, emikhonweni kanye nemilenzeni bambatha iinrholwani. imibala yakhona ngu nzima, hlaza okwesibhakabhaka, hlaza satjani, ubukhobe kanye nomhlophe. Koke lokhu kwenziwe ngomncamo. Iinrholwani lezi zinendlela ezilandelana ngayo ngokuya kwesiko. Isithombe esingehlanzeni sesincelesi masokana asayokwenza isiko ivunulo yabo ihlukile kunamasokana sele aqedileko. Ivunulo yabo ilula njengale yomswegwabo. Bona bambatha ibhetjha kanje neenzipha kwaphela bese baphathe intonga ngesandleni sokudla.

== Abentazana ==
[[Isimumathi:Abentazana.jpg|thumb|Abentazana]]
Abentazana ngomhlubulo nabo bambatha ivunulo esuka ehloko ukufika eenyaweni. ehloko bambatha umkhala, entameni bambatha irasu, edinini iphephethu, iinrholwani zedinini (ijuba nobukhobe), isithimba kanye ne yerhana. Ezandleni bambatha iinrholwani ezinemibalabala babuye bazembathe kanye neenyaweni. Imibala yakhona ngu nzima, hlaza okwesibhakabhaka, hlaza satjani, ubukhobe kanye nomhlophe. Koke lokhu kwenziwe ngomncamo.</text>
      <sha1>n4752rk9rfd5qsy8j910k3dpuqlpjt4</sha1>
    </revision>
  </page>
  <page>
    <title>Ibhayibhili</title>
    <ns>0</ns>
    <id>143</id>
    <revision>
      <id>694</id>
      <timestamp>2024-07-08T09:06:31Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;ibhayibhili yincwadi ecwengileko esetjenziswa babantu amakrestu. Incwadi isetjenziswa ukutjhumayela.&quot;</comment>
      <origin>694</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="100" sha1="27koptvdk21rzivohljzg7vfv9vb7mq" xml:space="preserve">ibhayibhili yincwadi ecwengileko esetjenziswa babantu amakrestu. Incwadi isetjenziswa ukutjhumayela.</text>
      <sha1>27koptvdk21rzivohljzg7vfv9vb7mq</sha1>
    </revision>
    <revision>
      <id>695</id>
      <parentid>694</parentid>
      <timestamp>2024-07-08T09:07:46Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>695</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="106" sha1="jic2sp4azrxx98o5qzava8cmmvbjjpe" xml:space="preserve">'''Ibhayibhili''' yincwadi ecwengileko esetjenziswa babantu amakrestu. Incwadi isetjenziswa ukutjhumayela.</text>
      <sha1>jic2sp4azrxx98o5qzava8cmmvbjjpe</sha1>
    </revision>
    <revision>
      <id>696</id>
      <parentid>695</parentid>
      <timestamp>2024-07-09T08:07:18Z</timestamp>
      <contributor>
        <ip>102.182.24.97</ip>
      </contributor>
      <origin>696</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="775" sha1="m6lqzbtatpaffy9mhz1esc0qr0iebp5" xml:space="preserve">'''Ibhayibhili''' yincwadi ecwengileko esetjenziswa babantu amakrestu. Incwadi isetjenziswa ukutjhumayela nokufunda indaba zikaZimu begodu nokubona bonyana kuba njani lokha umuntu nakakhamba noZimu. Abanye bathi ibhayibhili sikhali sokulwa nemimoya emembi. ibhayibheli ihlukaniseke kabili. Ngokuthi kune Testamende elidala begodu kune testamende elitja. Itestamende elidala lifundisa ngoZimu lokha uJesu Krestu angafiki emhlabeni begodu likhombise bonyana uZimu bekasenzisa abaphrofethi ukukhuluma nabantu okhunye esikuthola etestamendeni elidala kukuthi kuze njani bona abantu bafe nokuthi kuze njani kube nephasi.

Itestamende LIfundisa ngokufika kwaka Jesu ephasini nokubethelwa kwakhe esphambanweni begodu nokuthi abapostoli basala benzani lokha uJesu nakabuyela ezulwini</text>
      <sha1>m6lqzbtatpaffy9mhz1esc0qr0iebp5</sha1>
    </revision>
    <revision>
      <id>697</id>
      <parentid>696</parentid>
      <timestamp>2024-07-09T08:14:27Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>697</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="787" sha1="9w87z9kbd4beokn4dde7jds346ba2ii" xml:space="preserve">'''Ibhayibhili''' yincwadi ecwengileko esetjenziswa babantu amakrestu. Incwadi isetjenziswa ukutjhumayela nokufunda indaba zikaZimu begodu nokubona bonyana kuba njani lokha umuntu nakakhamba noZimu. Abanye bathi ibhayibhili sikhali sokulwa nemimoya emembi. ibhayibheli ihlukaniseke kabili. Ngokuthi kune [[Testamende]] elidala begodu kune testamende elitja. Itestamende elidala lifundisa ngo[[Zimu]] lokha uJesu Krestu angafiki emhlabeni begodu likhombise bonyana uZimu bekasenzisa [[abaphrofethi]] ukukhuluma nabantu okhunye esikuthola etestamendeni elidala kukuthi kuze njani bona abantu bafe nokuthi kuze njani kube nephasi.

Itestamende LIfundisa ngokufika kwaka Jesu ephasini nokubethelwa kwakhe esphambanweni begodu nokuthi abapostoli basala benzani lokha uJesu nakabuyela ezulwini</text>
      <sha1>9w87z9kbd4beokn4dde7jds346ba2ii</sha1>
    </revision>
    <revision>
      <id>698</id>
      <parentid>697</parentid>
      <timestamp>2024-07-09T08:21:08Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>698</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="788" sha1="smmus1pvudkcc60nom54l3t70qen3pi" xml:space="preserve">'''Ibhayibhili''' yincwadi ecwengileko esetjenziswa babantu amakrestu. Incwadi isetjenziswa ukutjhumayela nokufunda indaba zikaZimu begodu nokubona bonyana kuba njani lokha umuntu nakakhamba noZimu. Abanye bathi ibhayibhili sikhali sokulwa nemimoya emembi. ibhayibheli ihlukaniseke kabili. Ngokuthi kune [[Testamende]] elidala begodu kune testamende elitja. Itestamende elidala lifundisa ngo[[Zimu]] lokha uJesu Krestu angafiki emhlabeni begodu likhombise bonyana uZimu bekasenzisa [[abaphrofethi]] ukukhuluma nabantu okhunye esikuthola etestamendeni elidala kukuthi kuze njani bona abantu bafe nokuthi kuze njani kube nephasi.

Itestamende LIfundisa ngokufika kwaka Jesu ephasini nokubethelwa kwakhe esphambanweni begodu nokuthi abapostoli basala benzani lokha uJesu nakabuyela ezulwini.</text>
      <sha1>smmus1pvudkcc60nom54l3t70qen3pi</sha1>
    </revision>
    <revision>
      <id>699</id>
      <parentid>698</parentid>
      <timestamp>2024-07-14T16:47:18Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>699</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="796" sha1="3gs8p5hdxlh0ge55wq5la8etdnb2a51" xml:space="preserve">'''Ibhayibhili''' yincwadi ecwengileko esetjenziswa babantu amakrestu. Incwadi isetjenziswa ukutjhumayela nokufunda indaba zikaZimu begodu nokubona bonyana kuba njani lokha umuntu nakakhamba noZimu. Abanye bathi ibhayibhili sikhali sokulwa nemimoya emimbi. Ibhayibheli ihlukaniseke kabili. Ngokuthi kune [[Testamende]] elidala begodu kune testamende elitja. Itestamende elidala lifundisa ngo[[Zimu]] lokha uJesu Krestu angafiki emhlabeni begodu likhombise bonyana uZimu bekasenzisa [[abaphrofethi]] ukukhuluma nabantu okhunye esikuthola etestamendeni elidala kukuthi kuze njani bona abantu bafe nokuthi kuze njani kube nephasi.

Itestamende elitjha lifundisa ngokufika kwaka Jesu ephasini nokubethelwa kwakhe esphambanweni begodu nokuthi abapostoli basala benzani lokha uJesu nakabuyela ezulwini.</text>
      <sha1>3gs8p5hdxlh0ge55wq5la8etdnb2a51</sha1>
    </revision>
    <revision>
      <id>700</id>
      <parentid>699</parentid>
      <timestamp>2024-10-14T13:46:43Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>6 revisions imported</comment>
      <origin>699</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="796" sha1="3gs8p5hdxlh0ge55wq5la8etdnb2a51" xml:space="preserve">'''Ibhayibhili''' yincwadi ecwengileko esetjenziswa babantu amakrestu. Incwadi isetjenziswa ukutjhumayela nokufunda indaba zikaZimu begodu nokubona bonyana kuba njani lokha umuntu nakakhamba noZimu. Abanye bathi ibhayibhili sikhali sokulwa nemimoya emimbi. Ibhayibheli ihlukaniseke kabili. Ngokuthi kune [[Testamende]] elidala begodu kune testamende elitja. Itestamende elidala lifundisa ngo[[Zimu]] lokha uJesu Krestu angafiki emhlabeni begodu likhombise bonyana uZimu bekasenzisa [[abaphrofethi]] ukukhuluma nabantu okhunye esikuthola etestamendeni elidala kukuthi kuze njani bona abantu bafe nokuthi kuze njani kube nephasi.

Itestamende elitjha lifundisa ngokufika kwaka Jesu ephasini nokubethelwa kwakhe esphambanweni begodu nokuthi abapostoli basala benzani lokha uJesu nakabuyela ezulwini.</text>
      <sha1>3gs8p5hdxlh0ge55wq5la8etdnb2a51</sha1>
    </revision>
    <revision>
      <id>1872</id>
      <parentid>700</parentid>
      <timestamp>2024-11-10T14:28:39Z</timestamp>
      <contributor>
        <ip>88.238.42.228</ip>
      </contributor>
      <origin>1872</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="845" sha1="s0k1pjoyozrx8onhxjeuwfk01uk03r6" xml:space="preserve">'''Ibhayibhili''' yincwadi ecwengileko esetjenziswa babantu amakrestu. Incwadi isetjenziswa ukutjhumayela nokufunda indaba zikaZimu begodu nokubona bonyana kuba njani lokha umuntu nakakhamba noZimu. Abanye bathi ibhayibhili sikhali sokulwa nemimoya emimbi. Ibhayibheli ihlukaniseke kabili. Ngokuthi kune [[Testamende]] elidala begodu kune testamende elitja. Itestamende elidala lifundisa ngo[[Zimu]] lokha uJesu Krestu angafiki emhlabeni begodu likhombise bonyana uZimu bekasenzisa [[abaphrofethi]] ukukhuluma nabantu okhunye esikuthola etestamendeni elidala kukuthi kuze njani bona abantu bafe nokuthi kuze njani kube nephasi.

Itestamende elitjha lifundisa ngokufika kwaka Jesu ephasini nokubethelwa kwakhe esphambanweni begodu nokuthi abapostoli basala benzani lokha uJesu nakabuyela ezulwini. [https://drucker-fehler.com/ drucker-fehler.com]</text>
      <sha1>s0k1pjoyozrx8onhxjeuwfk01uk03r6</sha1>
    </revision>
    <revision>
      <id>2279</id>
      <parentid>1872</parentid>
      <timestamp>2024-12-13T12:44:04Z</timestamp>
      <contributor>
        <ip>88.238.42.176</ip>
      </contributor>
      <origin>2279</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="833" sha1="5u0130gz0ud3i93sq4kj4lc9smazkqk" xml:space="preserve">'''Ibhayibhili''' yincwadi ecwengileko esetjenziswa babantu amakrestu. Incwadi isetjenziswa ukutjhumayela nokufunda indaba zikaZimu begodu nokubona bonyana kuba njani lokha umuntu nakakhamba noZimu. Abanye bathi ibhayibhili sikhali sokulwa nemimoya emimbi. Ibhayibheli ihlukaniseke kabili. Ngokuthi kune [[Testamende]] elidala begodu kune testamende elitja. Itestamende elidala lifundisa ngo[[Zimu]] lokha uJesu Krestu angafiki emhlabeni begodu likhombise bonyana uZimu bekasenzisa [[abaphrofethi]] ukukhuluma nabantu okhunye esikuthola etestamendeni elidala kukuthi kuze njani bona abantu bafe nokuthi kuze njani kube nephasi.

Itestamende elitjha lifundisa ngokufika kwaka Jesu ephasini nokubethelwa kwakhe esphambanweni begodu nokuthi abapostoli basala benzani lokha uJesu nakabuyela ezulwini. [https://www.fehlerpro.de FehlerPRO]</text>
      <sha1>5u0130gz0ud3i93sq4kj4lc9smazkqk</sha1>
    </revision>
    <revision>
      <id>5730</id>
      <parentid>2279</parentid>
      <timestamp>2025-09-13T01:09:57Z</timestamp>
      <contributor>
        <username>~2025-58858-7</username>
        <id>926</id>
      </contributor>
      <origin>5730</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="796" sha1="3gs8p5hdxlh0ge55wq5la8etdnb2a51" xml:space="preserve">'''Ibhayibhili''' yincwadi ecwengileko esetjenziswa babantu amakrestu. Incwadi isetjenziswa ukutjhumayela nokufunda indaba zikaZimu begodu nokubona bonyana kuba njani lokha umuntu nakakhamba noZimu. Abanye bathi ibhayibhili sikhali sokulwa nemimoya emimbi. Ibhayibheli ihlukaniseke kabili. Ngokuthi kune [[Testamende]] elidala begodu kune testamende elitja. Itestamende elidala lifundisa ngo[[Zimu]] lokha uJesu Krestu angafiki emhlabeni begodu likhombise bonyana uZimu bekasenzisa [[abaphrofethi]] ukukhuluma nabantu okhunye esikuthola etestamendeni elidala kukuthi kuze njani bona abantu bafe nokuthi kuze njani kube nephasi.

Itestamende elitjha lifundisa ngokufika kwaka Jesu ephasini nokubethelwa kwakhe esphambanweni begodu nokuthi abapostoli basala benzani lokha uJesu nakabuyela ezulwini.</text>
      <sha1>3gs8p5hdxlh0ge55wq5la8etdnb2a51</sha1>
    </revision>
  </page>
  <page>
    <title>Ibhoduluko</title>
    <ns>0</ns>
    <id>144</id>
    <revision>
      <id>701</id>
      <timestamp>2024-09-14T09:36:42Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;== Ibhoduluko == [[:en:Natural_environment|Ibhodoluko]] ngezinye zezinto eziqakathekileko ephasini. Ngaphandle kwebhodulo ipilo bengeze yabakhona. Ibhoduluko ifumbethe ipilo yeenlwani ezinengi. Ezinye zeenlwana ziyaphila kanti ezinye zona aziphili. Eenhlokwaneni ezilandelako sizokutjheja kobana kuyini ibhodulo begodu ibhoduluko lihlukene njani.  === Kuyini ibholuko? === Ngokuya kukaSadiku, u-Ashaolu, u-Ajayi-Majebi no-Musa (2020&lt;ref&gt;Sadiku, M. O., Ashaoulu, T. J., Ajayi-...&quot;</comment>
      <origin>701</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3252" sha1="o6g4q5d6eogkog64wsnjgk6a6tkizxk" xml:space="preserve">== Ibhoduluko ==
[[:en:Natural_environment|Ibhodoluko]] ngezinye zezinto eziqakathekileko ephasini. Ngaphandle kwebhodulo ipilo bengeze yabakhona. Ibhoduluko ifumbethe ipilo yeenlwani ezinengi. Ezinye zeenlwana ziyaphila kanti ezinye zona aziphili. Eenhlokwaneni ezilandelako sizokutjheja kobana kuyini ibhodulo begodu ibhoduluko lihlukene njani.

=== Kuyini ibholuko? ===
Ngokuya kukaSadiku, u-Ashaolu, u-Ajayi-Majebi no-Musa (2020&lt;ref&gt;Sadiku, M. O., Ashaoulu, T. J., Ajayi-Majebi, A. &amp; Musa, S. M. 2020. Environmental Studies: An Introduction. ''International Journal of Scientific Advances'', 1(3):54-57.&lt;/ref&gt;) ibhoduluko iphathelene nakho koke ekusemanzini, emoyeni, enarheni nehlabathini. Ukungezelela, ibhoduluko ngikho koke okutholakala ephasini, ekuphilako nokungaphili ekufaka hlangana izengiwa, iinlwani eziphilako nezingaphili umumoya kanye nokusesibhakabhageni (Maelzer 1964&lt;ref&gt;Maelzer, D. A. 1964. A Discussion of Components of Environment in Ecology. J. ''Theoret. Biol'', 8:141-162.&lt;/ref&gt;). Ngamanye amagama, koke lokhu ukuthola ephasini nohlangana nakho mihla namalanga kungaba yingcenye nanyana kuyingcenye yebhoduluko.

Ibhoduluko lihlukaniswe ngcenye ezilandelako (Glazovsky 2009&lt;ref name=&quot;:0&quot;&gt;Glazovsky, N. 2009. Environmental Structure and Function: Earth System. ''Earth System History and Natural Variability'', 7:1-16.&lt;/ref&gt;):

1.      Umoya

2.      Ihlabathi

3.      Amanzi

4.      Isibhakabhaka

Ihlathululo engehla iyasivezela bonyana ibhoduluko liyini begodu liqakatheke kangangani. Eenhlokwaneni ezilandelako sizokutjheja bonyana sitjho ukuthi ngokuthi umoya, ihlabathi, amanzi nesibhakabhaka.

==== 1.      Umoya ====
Ingabe sitjho ukuthi nasikhuluma ngomoya ngaphasi kwebhoduluko na? Umoya ngaphasi kwebhoduluko utjho umoya esiwuthola ngaphandle begodu lowo esiwuphefumulako (Glazovsky 2009&lt;ref name=&quot;:0&quot; /&gt;; ne-Wikipedia 2024&lt;ref name=&quot;:1&quot;&gt;Wikipedia. 2024. ''Natural Environment''. Litholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Natural_environment&lt;/nowiki&gt;&gt;. Lifunyenwe ngomhlaka [20 kuRhoboyi 2024].&lt;/ref&gt;). Ngaphasi komoya siqala izinga lekhwalithi womaya, ubumbi Nobuhle (Glazovsky 2009&lt;ref name=&quot;:0&quot; /&gt;).

==== 2.      Ihlabathi ====
Ngaphasi kwehlabathi siqale koke okuphilako nokungaphiliko eokutholakala ehlabathini, ekufaka hlangana izenjiwa namanzi atholakala ehlabathini (Glazovsky 2009&lt;ref name=&quot;:0&quot; /&gt;; ne-Wikipedia 2024&lt;ref name=&quot;:1&quot; /&gt;). Izinga lekhwalithi lehlabathi nalo liqakathekile.

==== 3.      Amanzi ====
Amanzi ngaphasi kwebhoduluko kutjhejwe zoke izinto ezitholakala emanzini eziphilako nezingaphiliko kanye nezinga lekhwalithi yemanzi, ubuhle nobumbi balo (Glazovsky 2009&lt;ref name=&quot;:0&quot; /&gt;; ne-Wikipedia 2024&lt;ref name=&quot;:1&quot; /&gt;).

==== 4.      Isibhakabhaka ====
Iisbhakabhaka sitjho iphezulu, koke okukhamba nokutholakala esibhakabhakeni (Glazovsky 2009&lt;ref name=&quot;:0&quot; /&gt;). Ekungezelela, kutjhejwe nangendlela ibhodululo liphathwa ngalo kanye nizinto esisipha sona (Glazovsky 2009&lt;ref name=&quot;:0&quot; /&gt;).

=== Isiphetho ===
Isibhoduloko liqakatheke khulu njengepilo yayo yoke into. Izinto ukuze ziphile, zenze imisebenzi yayo zifunjethwe begodu zinakekelwa libhoduluko. Ngphandle kwebhoduluko ezinye zezinto bezingeze zabakhona.

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>o6g4q5d6eogkog64wsnjgk6a6tkizxk</sha1>
    </revision>
    <revision>
      <id>702</id>
      <parentid>701</parentid>
      <timestamp>2024-09-18T16:16:45Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>702</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3253" sha1="8era8ew6nh9rbg9zcbz2jt1qigibkdb" xml:space="preserve">== Ibhoduluko. ==
[[:en:Natural_environment|Ibhodoluko]] ngezinye zezinto eziqakathekileko ephasini. Ngaphandle kwebhodulo ipilo bengeze yabakhona. Ibhoduluko ifumbethe ipilo yeenlwani ezinengi. Ezinye zeenlwana ziyaphila kanti ezinye zona aziphili. Eenhlokwaneni ezilandelako sizokutjheja kobana kuyini ibhodulo begodu ibhoduluko lihlukene njani.

=== Kuyini ibholuko? ===
Ngokuya kukaSadiku, u-Ashaolu, u-Ajayi-Majebi no-Musa (2020&lt;ref&gt;Sadiku, M. O., Ashaoulu, T. J., Ajayi-Majebi, A. &amp; Musa, S. M. 2020. Environmental Studies: An Introduction. ''International Journal of Scientific Advances'', 1(3):54-57.&lt;/ref&gt;) ibhoduluko iphathelene nakho koke ekusemanzini, emoyeni, enarheni nehlabathini. Ukungezelela, ibhoduluko ngikho koke okutholakala ephasini, ekuphilako nokungaphili ekufaka hlangana izengiwa, iinlwani eziphilako nezingaphili umumoya kanye nokusesibhakabhageni (Maelzer 1964&lt;ref&gt;Maelzer, D. A. 1964. A Discussion of Components of Environment in Ecology. J. ''Theoret. Biol'', 8:141-162.&lt;/ref&gt;). Ngamanye amagama, koke lokhu ukuthola ephasini nohlangana nakho mihla namalanga kungaba yingcenye nanyana kuyingcenye yebhoduluko.

Ibhoduluko lihlukaniswe ngcenye ezilandelako (Glazovsky 2009&lt;ref name=&quot;:0&quot;&gt;Glazovsky, N. 2009. Environmental Structure and Function: Earth System. ''Earth System History and Natural Variability'', 7:1-16.&lt;/ref&gt;):

1.      Umoya

2.      Ihlabathi

3.      Amanzi

4.      Isibhakabhaka

Ihlathululo engehla iyasivezela bonyana ibhoduluko liyini begodu liqakatheke kangangani. Eenhlokwaneni ezilandelako sizokutjheja bonyana sitjho ukuthi ngokuthi umoya, ihlabathi, amanzi nesibhakabhaka.

==== 1.      Umoya ====
Ingabe sitjho ukuthi nasikhuluma ngomoya ngaphasi kwebhoduluko na? Umoya ngaphasi kwebhoduluko utjho umoya esiwuthola ngaphandle begodu lowo esiwuphefumulako (Glazovsky 2009&lt;ref name=&quot;:0&quot; /&gt;; ne-Wikipedia 2024&lt;ref name=&quot;:1&quot;&gt;Wikipedia. 2024. ''Natural Environment''. Litholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Natural_environment&lt;/nowiki&gt;&gt;. Lifunyenwe ngomhlaka [20 kuRhoboyi 2024].&lt;/ref&gt;). Ngaphasi komoya siqala izinga lekhwalithi womaya, ubumbi Nobuhle (Glazovsky 2009&lt;ref name=&quot;:0&quot; /&gt;).

==== 2.      Ihlabathi ====
Ngaphasi kwehlabathi siqale koke okuphilako nokungaphiliko eokutholakala ehlabathini, ekufaka hlangana izenjiwa namanzi atholakala ehlabathini (Glazovsky 2009&lt;ref name=&quot;:0&quot; /&gt;; ne-Wikipedia 2024&lt;ref name=&quot;:1&quot; /&gt;). Izinga lekhwalithi lehlabathi nalo liqakathekile.

==== 3.      Amanzi ====
Amanzi ngaphasi kwebhoduluko kutjhejwe zoke izinto ezitholakala emanzini eziphilako nezingaphiliko kanye nezinga lekhwalithi yemanzi, ubuhle nobumbi balo (Glazovsky 2009&lt;ref name=&quot;:0&quot; /&gt;; ne-Wikipedia 2024&lt;ref name=&quot;:1&quot; /&gt;).

==== 4.      Isibhakabhaka ====
Iisbhakabhaka sitjho iphezulu, koke okukhamba nokutholakala esibhakabhakeni (Glazovsky 2009&lt;ref name=&quot;:0&quot; /&gt;). Ekungezelela, kutjhejwe nangendlela ibhodululo liphathwa ngalo kanye nizinto esisipha sona (Glazovsky 2009&lt;ref name=&quot;:0&quot; /&gt;).

=== Isiphetho ===
Isibhoduloko liqakatheke khulu njengepilo yayo yoke into. Izinto ukuze ziphile, zenze imisebenzi yayo zifunjethwe begodu zinakekelwa libhoduluko. Ngphandle kwebhoduluko ezinye zezinto bezingeze zabakhona.

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>8era8ew6nh9rbg9zcbz2jt1qigibkdb</sha1>
    </revision>
    <revision>
      <id>703</id>
      <parentid>702</parentid>
      <timestamp>2024-10-14T13:46:43Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>702</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3253" sha1="8era8ew6nh9rbg9zcbz2jt1qigibkdb" xml:space="preserve">== Ibhoduluko. ==
[[:en:Natural_environment|Ibhodoluko]] ngezinye zezinto eziqakathekileko ephasini. Ngaphandle kwebhodulo ipilo bengeze yabakhona. Ibhoduluko ifumbethe ipilo yeenlwani ezinengi. Ezinye zeenlwana ziyaphila kanti ezinye zona aziphili. Eenhlokwaneni ezilandelako sizokutjheja kobana kuyini ibhodulo begodu ibhoduluko lihlukene njani.

=== Kuyini ibholuko? ===
Ngokuya kukaSadiku, u-Ashaolu, u-Ajayi-Majebi no-Musa (2020&lt;ref&gt;Sadiku, M. O., Ashaoulu, T. J., Ajayi-Majebi, A. &amp; Musa, S. M. 2020. Environmental Studies: An Introduction. ''International Journal of Scientific Advances'', 1(3):54-57.&lt;/ref&gt;) ibhoduluko iphathelene nakho koke ekusemanzini, emoyeni, enarheni nehlabathini. Ukungezelela, ibhoduluko ngikho koke okutholakala ephasini, ekuphilako nokungaphili ekufaka hlangana izengiwa, iinlwani eziphilako nezingaphili umumoya kanye nokusesibhakabhageni (Maelzer 1964&lt;ref&gt;Maelzer, D. A. 1964. A Discussion of Components of Environment in Ecology. J. ''Theoret. Biol'', 8:141-162.&lt;/ref&gt;). Ngamanye amagama, koke lokhu ukuthola ephasini nohlangana nakho mihla namalanga kungaba yingcenye nanyana kuyingcenye yebhoduluko.

Ibhoduluko lihlukaniswe ngcenye ezilandelako (Glazovsky 2009&lt;ref name=&quot;:0&quot;&gt;Glazovsky, N. 2009. Environmental Structure and Function: Earth System. ''Earth System History and Natural Variability'', 7:1-16.&lt;/ref&gt;):

1.      Umoya

2.      Ihlabathi

3.      Amanzi

4.      Isibhakabhaka

Ihlathululo engehla iyasivezela bonyana ibhoduluko liyini begodu liqakatheke kangangani. Eenhlokwaneni ezilandelako sizokutjheja bonyana sitjho ukuthi ngokuthi umoya, ihlabathi, amanzi nesibhakabhaka.

==== 1.      Umoya ====
Ingabe sitjho ukuthi nasikhuluma ngomoya ngaphasi kwebhoduluko na? Umoya ngaphasi kwebhoduluko utjho umoya esiwuthola ngaphandle begodu lowo esiwuphefumulako (Glazovsky 2009&lt;ref name=&quot;:0&quot; /&gt;; ne-Wikipedia 2024&lt;ref name=&quot;:1&quot;&gt;Wikipedia. 2024. ''Natural Environment''. Litholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Natural_environment&lt;/nowiki&gt;&gt;. Lifunyenwe ngomhlaka [20 kuRhoboyi 2024].&lt;/ref&gt;). Ngaphasi komoya siqala izinga lekhwalithi womaya, ubumbi Nobuhle (Glazovsky 2009&lt;ref name=&quot;:0&quot; /&gt;).

==== 2.      Ihlabathi ====
Ngaphasi kwehlabathi siqale koke okuphilako nokungaphiliko eokutholakala ehlabathini, ekufaka hlangana izenjiwa namanzi atholakala ehlabathini (Glazovsky 2009&lt;ref name=&quot;:0&quot; /&gt;; ne-Wikipedia 2024&lt;ref name=&quot;:1&quot; /&gt;). Izinga lekhwalithi lehlabathi nalo liqakathekile.

==== 3.      Amanzi ====
Amanzi ngaphasi kwebhoduluko kutjhejwe zoke izinto ezitholakala emanzini eziphilako nezingaphiliko kanye nezinga lekhwalithi yemanzi, ubuhle nobumbi balo (Glazovsky 2009&lt;ref name=&quot;:0&quot; /&gt;; ne-Wikipedia 2024&lt;ref name=&quot;:1&quot; /&gt;).

==== 4.      Isibhakabhaka ====
Iisbhakabhaka sitjho iphezulu, koke okukhamba nokutholakala esibhakabhakeni (Glazovsky 2009&lt;ref name=&quot;:0&quot; /&gt;). Ekungezelela, kutjhejwe nangendlela ibhodululo liphathwa ngalo kanye nizinto esisipha sona (Glazovsky 2009&lt;ref name=&quot;:0&quot; /&gt;).

=== Isiphetho ===
Isibhoduloko liqakatheke khulu njengepilo yayo yoke into. Izinto ukuze ziphile, zenze imisebenzi yayo zifunjethwe begodu zinakekelwa libhoduluko. Ngphandle kwebhoduluko ezinye zezinto bezingeze zabakhona.

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>8era8ew6nh9rbg9zcbz2jt1qigibkdb</sha1>
    </revision>
  </page>
  <page>
    <title>Idatha, umniningwana nelwazi</title>
    <ns>0</ns>
    <id>145</id>
    <revision>
      <id>704</id>
      <timestamp>2024-07-21T09:48:23Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;== Idatha, umniningwana nelwazi ==  === Isingeniso === Idatha, umniningwana nelwazi zizinto ezingafaniko lezo ezitjengisa izinga elithe lobuhlakani kanye nethuthuko yomqabango. Nanyana, kukhona abazisebenzisa njengezinto ezifanako nje, kodwana ekhabo lazo azifani. Esigabeni esilandelako sizokuhlathulula idatha, imininingwana nelwazi begodu siveze nomehluko wazo.  === Idatha === Idatha mitlolo leyo ebuthelelweko nanyana imitlolo leyo engaka engaka fundwa begodu engaka ung...&quot;</comment>
      <origin>704</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2245" sha1="59ugtnegtkwu5lt29ti55ki71qt48ew" xml:space="preserve">== Idatha, umniningwana nelwazi ==

=== Isingeniso ===
Idatha, umniningwana nelwazi zizinto ezingafaniko lezo ezitjengisa izinga elithe lobuhlakani kanye nethuthuko yomqabango. Nanyana, kukhona abazisebenzisa njengezinto ezifanako nje, kodwana ekhabo lazo azifani. Esigabeni esilandelako sizokuhlathulula idatha, imininingwana nelwazi begodu siveze nomehluko wazo.

=== Idatha ===
Idatha mitlolo leyo ebuthelelweko nanyana imitlolo leyo engaka engaka fundwa begodu engaka ungwa yazwisiswa. Ngamanye magama imitlolo leyo ongakayifundi begodu ungazi bonyana ikhuluma ngani ngokuneneleleko ibizwa bona yidatha. 

Isibonelo, lokha nawubuthelelwa imitlolo uyibeke nawonye ukuthi kusasa uzoyiqala, uyifundele ukuyizwisisa begodu uyirhumutjhe, leyo mitlolo yidatha.

=== Imininingwana ===
Umniningwana yidatha esele ifundiwe, yazwisiswa begodu yarhunyuthwa. Ngamanye amagama imitlolo leyo ehlungiweko begodu yazwisisa bonyana ikhuluma ngani begodu inqophe kuphi, leyo mitlolo nanyana idatha ibizwa ngokuthi mininingwana. 

Isibonelo, lokha nawuthatha imitlolo yakho oyibutheleleko uyifunda begodu uyizwisisa bonyana ikhuluma ngezamaphilo nemitjhoga, imitlolo leyo ibizwa bonyana mininingwana. 

=== Ilwazi ===
Ilwazi mniningwana leyo osele uyisebenzisile begodu wazi imiphumela yakhona emihle nemimbi. Ngamanye amagama, lokha nawuthatha imininingwana uyisebenzise ukwenza into ethize bese uyaphumelela nanyana uyabhalelwa ukufinyelela umnqopho wakho, imininingwana leyo ibizwa bonyana lilwazi.
Isibonelo, nawuthatha imininingwana yokubhaga amatjhatjhatjha bese ilandela imilayo yawo ukwenza amatjhatjhatjha. Ekugcineni, ugcine uwenzile amatjhatjhatjha nanyana akuhlulile, imininingwana leyo ibizwa bonyana lilwazi ngombana uyisebenzisile begodu uyazi bonyana imiphumela yayo iba njani. 

=== Isiphetho ===
Idatha ikhombisa izinga lokuthoma lobuhlakani bese kuthi umniningwana wona ukhombise izinga eliphakathi lobuhlakani. Kanti-ke, ilwazi lona likhombisa ilwazi eliphezulu lobuhlakani. Idatha, umniningwana nelwazi azifani kodwana ziyahlobana njengombana umtlolo ukuze ube mniningwana uthoma ube yidatha begodu ukuze umniningwana ube lilwazi ufuna ukusetjenziswa begodu kwaziwe umphumela wakhona. Kuqakathekileko bonyana siwazisise woke amathemu la.

</text>
      <sha1>59ugtnegtkwu5lt29ti55ki71qt48ew</sha1>
    </revision>
    <revision>
      <id>705</id>
      <parentid>704</parentid>
      <timestamp>2024-09-18T15:41:52Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>705</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2247" sha1="0o7l9i02s7xvle3lz8cy4vtpjuw1g84" xml:space="preserve">== Idatha, umniningwana nelwazi ==

=== Isingeniso. ===
Idatha, umniningwana nelwazi zizinto ezingafaniko lezo ezitjengisa izinga elithe lobuhlakani kanye nethuthuko yomqabango. Nanyana, kukhona abazisebenzisa njengezinto ezifanako nje, kodwana ekhabo lazo azifani. Esigabeni esilandelako sizokuhlathulula idatha, imininingwana nelwazi begodu siveze nomehluko wazo.

=== Idatha. ===
Idatha mitlolo leyo ebuthelelweko nanyana imitlolo leyo engaka engaka fundwa begodu engaka ungwa yazwisiswa. Ngamanye magama imitlolo leyo ongakayifundi begodu ungazi bonyana ikhuluma ngani ngokuneneleleko ibizwa bona yidatha. 

Isibonelo, lokha nawubuthelelwa imitlolo uyibeke nawonye ukuthi kusasa uzoyiqala, uyifundele ukuyizwisisa begodu uyirhumutjhe, leyo mitlolo yidatha.

=== Imininingwana ===
Umniningwana yidatha esele ifundiwe, yazwisiswa begodu yarhunyuthwa. Ngamanye amagama imitlolo leyo ehlungiweko begodu yazwisisa bonyana ikhuluma ngani begodu inqophe kuphi, leyo mitlolo nanyana idatha ibizwa ngokuthi mininingwana. 

Isibonelo, lokha nawuthatha imitlolo yakho oyibutheleleko uyifunda begodu uyizwisisa bonyana ikhuluma ngezamaphilo nemitjhoga, imitlolo leyo ibizwa bonyana mininingwana. 

=== Ilwazi ===
Ilwazi mniningwana leyo osele uyisebenzisile begodu wazi imiphumela yakhona emihle nemimbi. Ngamanye amagama, lokha nawuthatha imininingwana uyisebenzise ukwenza into ethize bese uyaphumelela nanyana uyabhalelwa ukufinyelela umnqopho wakho, imininingwana leyo ibizwa bonyana lilwazi.
Isibonelo, nawuthatha imininingwana yokubhaga amatjhatjhatjha bese ilandela imilayo yawo ukwenza amatjhatjhatjha. Ekugcineni, ugcine uwenzile amatjhatjhatjha nanyana akuhlulile, imininingwana leyo ibizwa bonyana lilwazi ngombana uyisebenzisile begodu uyazi bonyana imiphumela yayo iba njani. 

=== Isiphetho ===
Idatha ikhombisa izinga lokuthoma lobuhlakani bese kuthi umniningwana wona ukhombise izinga eliphakathi lobuhlakani. Kanti-ke, ilwazi lona likhombisa ilwazi eliphezulu lobuhlakani. Idatha, umniningwana nelwazi azifani kodwana ziyahlobana njengombana umtlolo ukuze ube mniningwana uthoma ube yidatha begodu ukuze umniningwana ube lilwazi ufuna ukusetjenziswa begodu kwaziwe umphumela wakhona. Kuqakathekileko bonyana siwazisise woke amathemu la.

</text>
      <sha1>0o7l9i02s7xvle3lz8cy4vtpjuw1g84</sha1>
    </revision>
    <revision>
      <id>706</id>
      <parentid>705</parentid>
      <timestamp>2024-10-14T13:46:43Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>705</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2247" sha1="0o7l9i02s7xvle3lz8cy4vtpjuw1g84" xml:space="preserve">== Idatha, umniningwana nelwazi ==

=== Isingeniso. ===
Idatha, umniningwana nelwazi zizinto ezingafaniko lezo ezitjengisa izinga elithe lobuhlakani kanye nethuthuko yomqabango. Nanyana, kukhona abazisebenzisa njengezinto ezifanako nje, kodwana ekhabo lazo azifani. Esigabeni esilandelako sizokuhlathulula idatha, imininingwana nelwazi begodu siveze nomehluko wazo.

=== Idatha. ===
Idatha mitlolo leyo ebuthelelweko nanyana imitlolo leyo engaka engaka fundwa begodu engaka ungwa yazwisiswa. Ngamanye magama imitlolo leyo ongakayifundi begodu ungazi bonyana ikhuluma ngani ngokuneneleleko ibizwa bona yidatha. 

Isibonelo, lokha nawubuthelelwa imitlolo uyibeke nawonye ukuthi kusasa uzoyiqala, uyifundele ukuyizwisisa begodu uyirhumutjhe, leyo mitlolo yidatha.

=== Imininingwana ===
Umniningwana yidatha esele ifundiwe, yazwisiswa begodu yarhunyuthwa. Ngamanye amagama imitlolo leyo ehlungiweko begodu yazwisisa bonyana ikhuluma ngani begodu inqophe kuphi, leyo mitlolo nanyana idatha ibizwa ngokuthi mininingwana. 

Isibonelo, lokha nawuthatha imitlolo yakho oyibutheleleko uyifunda begodu uyizwisisa bonyana ikhuluma ngezamaphilo nemitjhoga, imitlolo leyo ibizwa bonyana mininingwana. 

=== Ilwazi ===
Ilwazi mniningwana leyo osele uyisebenzisile begodu wazi imiphumela yakhona emihle nemimbi. Ngamanye amagama, lokha nawuthatha imininingwana uyisebenzise ukwenza into ethize bese uyaphumelela nanyana uyabhalelwa ukufinyelela umnqopho wakho, imininingwana leyo ibizwa bonyana lilwazi.
Isibonelo, nawuthatha imininingwana yokubhaga amatjhatjhatjha bese ilandela imilayo yawo ukwenza amatjhatjhatjha. Ekugcineni, ugcine uwenzile amatjhatjhatjha nanyana akuhlulile, imininingwana leyo ibizwa bonyana lilwazi ngombana uyisebenzisile begodu uyazi bonyana imiphumela yayo iba njani. 

=== Isiphetho ===
Idatha ikhombisa izinga lokuthoma lobuhlakani bese kuthi umniningwana wona ukhombise izinga eliphakathi lobuhlakani. Kanti-ke, ilwazi lona likhombisa ilwazi eliphezulu lobuhlakani. Idatha, umniningwana nelwazi azifani kodwana ziyahlobana njengombana umtlolo ukuze ube mniningwana uthoma ube yidatha begodu ukuze umniningwana ube lilwazi ufuna ukusetjenziswa begodu kwaziwe umphumela wakhona. Kuqakathekileko bonyana siwazisise woke amathemu la.

</text>
      <sha1>0o7l9i02s7xvle3lz8cy4vtpjuw1g84</sha1>
    </revision>
  </page>
  <page>
    <title>Idwendwe nobukhazi</title>
    <ns>0</ns>
    <id>146</id>
    <revision>
      <id>707</id>
      <timestamp>2024-07-08T08:33:19Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''idwendwe nobukhazi''' mnyanya wesiNdebele.  &quot;</comment>
      <origin>707</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="47" sha1="5ongb4677i4grwaau66qaxz5wqwb5vk" xml:space="preserve">'''idwendwe nobukhazi''' mnyanya wesiNdebele.

</text>
      <sha1>5ongb4677i4grwaau66qaxz5wqwb5vk</sha1>
    </revision>
    <revision>
      <id>708</id>
      <parentid>707</parentid>
      <timestamp>2024-07-08T08:34:02Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>708</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="47" sha1="s8pm18v3rysemwu9gm7fs4dcu78fxxl" xml:space="preserve">'''Idwendwe nobukhazi''' mnyanya wesiNdebele.

</text>
      <sha1>s8pm18v3rysemwu9gm7fs4dcu78fxxl</sha1>
    </revision>
    <revision>
      <id>709</id>
      <parentid>708</parentid>
      <timestamp>2024-07-12T17:19:21Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>709</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="273" sha1="e3u6ozazb3pd2phlp7y4wnkv1bexwke" xml:space="preserve">'''Idwendwe nobukhazi''' mnyanya wesiNdebele. Isokana liyakhamba liyokubawa umkhamanzi, bese liyameba. Kuthi ligament bese liyakhamba liyokutjela umndeni wekhabo mkhamanzi bona bafunele nganeno. Ismanje siyangena, ngeLesithathu abogogo bayayeyezela, ngeLesine kuba sikira

</text>
      <sha1>e3u6ozazb3pd2phlp7y4wnkv1bexwke</sha1>
    </revision>
    <revision>
      <id>710</id>
      <parentid>709</parentid>
      <timestamp>2024-07-12T17:23:48Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>710</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="516" sha1="hsq4mft2pue9buuz4ik1p63t6x02fyr" xml:space="preserve">'''Idwendwe nobukhazi''' mnyanya wesiNdebele. Isokana liyakhamba liyokubawa umkhamanzi, bese liyameba. Kuthi ligament bese liyakhamba liyokutjela umndeni wekhabo mkhamanzi bona bafunele nganeno. Ismanje siyangena, ngeLesithathu abogogo bayayeyezela, ngeLesine kuba sikira, Ngelesihlanu umalikazana ubuyela ekhabo uphekelelwa lidwendwe labo mma neenkomo zobukhazi. Kuthi ngoMgqibelo kuhlatswe ubhukhazi, iinkomo ziyabiwa ngokuya kwamagama wazo. Okhunye godu kuyambeswana okutjho bona bakhiphelana izipho ezithileko.

</text>
      <sha1>hsq4mft2pue9buuz4ik1p63t6x02fyr</sha1>
    </revision>
    <revision>
      <id>711</id>
      <parentid>710</parentid>
      <timestamp>2024-10-14T13:46:43Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>4 revisions imported</comment>
      <origin>710</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="516" sha1="hsq4mft2pue9buuz4ik1p63t6x02fyr" xml:space="preserve">'''Idwendwe nobukhazi''' mnyanya wesiNdebele. Isokana liyakhamba liyokubawa umkhamanzi, bese liyameba. Kuthi ligament bese liyakhamba liyokutjela umndeni wekhabo mkhamanzi bona bafunele nganeno. Ismanje siyangena, ngeLesithathu abogogo bayayeyezela, ngeLesine kuba sikira, Ngelesihlanu umalikazana ubuyela ekhabo uphekelelwa lidwendwe labo mma neenkomo zobukhazi. Kuthi ngoMgqibelo kuhlatswe ubhukhazi, iinkomo ziyabiwa ngokuya kwamagama wazo. Okhunye godu kuyambeswana okutjho bona bakhiphelana izipho ezithileko.

</text>
      <sha1>hsq4mft2pue9buuz4ik1p63t6x02fyr</sha1>
    </revision>
    <revision>
      <id>2413</id>
      <parentid>711</parentid>
      <timestamp>2025-02-16T12:50:54Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2413</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="585" sha1="l4eicp3puqyxbaz7xctvks49b34ni7w" xml:space="preserve">'''Idwendwe nobukhazi''' mnyanya wesiNdebele. Isokana liyakhamba liyokubawa umkhamanzi, bese liyameba. Kuthi ligamena bese liyakhamba liyokutjela umndeni wekhabo mkhamanzi bona bafunele nganeno. Ismanje siyangena, ngeLesithathu abogogo bayayeyezela, ngeLesine kuba sikira, Ngelesihlanu umalukazana ubuyela ekhabo uphekelelwa lidwendwe labo mma neenkomo zobukhazi. Kuthi ngoMgqibelo kuhlatswe ubukhazi, iinkomo ziyabiwa ngokuya kwamagama wazo. Okhunye godu kuyambeswana okutjho bona bakhiphelana izipho ezithileko. Umakoti uphiwa igama lokwendeni azokubizwa ngalo lokha nakafika emzini.</text>
      <sha1>l4eicp3puqyxbaz7xctvks49b34ni7w</sha1>
    </revision>
    <revision>
      <id>2419</id>
      <parentid>2413</parentid>
      <timestamp>2025-02-17T11:10:58Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2419</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="651" sha1="0qssoxjxdwt4u1itorxdtm2u1g9c5fk" xml:space="preserve">[[Isimumathi:Iintende.jpg|thumb|Iintende zikamma ongene simanje]]
'''Idwendwe nobukhazi''' mnyanya wesiNdebele. Isokana liyakhamba liyokubawa umkhamanzi, bese liyameba. Kuthi ligamena bese liyakhamba liyokutjela umndeni wekhabo mkhamanzi bona bafunele nganeno. Ismanje siyangena, ngeLesithathu abogogo bayayeyezela, ngeLesine kuba sikira, Ngelesihlanu umalukazana ubuyela ekhabo uphekelelwa lidwendwe labo mma neenkomo zobukhazi. Kuthi ngoMgqibelo kuhlatswe ubukhazi, iinkomo ziyabiwa ngokuya kwamagama wazo. Okhunye godu kuyambeswana okutjho bona bakhiphelana izipho ezithileko. Umakoti uphiwa igama lokwendeni azokubizwa ngalo lokha nakafika emzini.</text>
      <sha1>0qssoxjxdwt4u1itorxdtm2u1g9c5fk</sha1>
    </revision>
    <revision>
      <id>6109</id>
      <parentid>2419</parentid>
      <timestamp>2026-01-02T21:18:23Z</timestamp>
      <contributor>
        <username>~2026-36204</username>
        <id>1262</id>
      </contributor>
      <origin>6109</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="651" sha1="mioga9o3xlptxy9y761yncuuyvbp9oy" xml:space="preserve">[[Isimumathi:Iintende.jpg|thumb|Iintende zikamma ongene simanje]]
'''Idwendwe nobukhazi''' mnyanya wesiNdebele. Isokana liyakhamba liyokubawa umkhamanzi, bese liyameba. Kuthi ligameba bese liyakhamba liyokutjela umndeni wekhabo mkhamanzi bona bafunele nganeno. Ismanje siyangena, ngeLesithathu abogogo bayayeyezela, ngeLesine kuba sikira, Ngelesihlanu umalukazana ubuyela ekhabo uphekelelwa lidwendwe labo mma neenkomo zobukhazi. Kuthi ngoMgqibelo kuhlatswe ubukhazi, iinkomo ziyabiwa ngokuya kwamagama wazo. Okhunye godu kuyambeswana okutjho bona bakhiphelana izipho ezithileko. Umakoti uphiwa igama lokwendeni azokubizwa ngalo lokha nakafika emzini.</text>
      <sha1>mioga9o3xlptxy9y761yncuuyvbp9oy</sha1>
    </revision>
    <revision>
      <id>6110</id>
      <parentid>6109</parentid>
      <timestamp>2026-01-02T21:19:00Z</timestamp>
      <contributor>
        <username>~2026-36204</username>
        <id>1262</id>
      </contributor>
      <origin>6110</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="652" sha1="pqzaa1p0iy87295y3ly0ir8irn8iphl" xml:space="preserve">[[Isimumathi:Iintende.jpg|thumb|Iintende zikamma ongene simanje]]
'''Idwendwe nobukhazi''' mnyanya wesiNdebele. Isokana liyakhamba liyokubawa umkhamanzi, bese liyameba. Kuthi lingameba bese liyakhamba liyokutjela umndeni wekhabo mkhamanzi bona bafunele nganeno. Ismanje siyangena, ngeLesithathu abogogo bayayeyezela, ngeLesine kuba sikira, Ngelesihlanu umalukazana ubuyela ekhabo uphekelelwa lidwendwe labo mma neenkomo zobukhazi. Kuthi ngoMgqibelo kuhlatswe ubukhazi, iinkomo ziyabiwa ngokuya kwamagama wazo. Okhunye godu kuyambeswana okutjho bona bakhiphelana izipho ezithileko. Umakoti uphiwa igama lokwendeni azokubizwa ngalo lokha nakafika emzini.</text>
      <sha1>pqzaa1p0iy87295y3ly0ir8irn8iphl</sha1>
    </revision>
  </page>
  <page>
    <title>Iflaga yeSewula Afrika</title>
    <ns>0</ns>
    <id>147</id>
    <revision>
      <id>712</id>
      <timestamp>2024-04-11T10:46:12Z</timestamp>
      <contributor>
        <username>incubator&gt;PHEELL</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Iflaga yeSewula Afrika''' yatlanywa ngonyaka ka-1994 ngenyanga kaMrhayili, kwabese yamukelwa ngenyanga kaSihlabantangana ngo-1994, ngesikhathi sekhetho zombelele ye-Sewula Afrika yango-1994, ukujamiselela iflaga ebeyisetjenziswa kusukela ngonyaka ka-1928 ukuya ku-1994.&quot;</comment>
      <origin>712</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="272" sha1="jigieoys9caa0zv48lvbb1938mp0j05" xml:space="preserve">'''Iflaga yeSewula Afrika''' yatlanywa ngonyaka ka-1994 ngenyanga kaMrhayili, kwabese yamukelwa ngenyanga kaSihlabantangana ngo-1994, ngesikhathi sekhetho zombelele ye-Sewula Afrika yango-1994, ukujamiselela iflaga ebeyisetjenziswa kusukela ngonyaka ka-1928 ukuya ku-1994.</text>
      <sha1>jigieoys9caa0zv48lvbb1938mp0j05</sha1>
    </revision>
    <revision>
      <id>713</id>
      <parentid>712</parentid>
      <timestamp>2024-04-11T10:47:12Z</timestamp>
      <contributor>
        <username>incubator&gt;PHEELL</username>
        <id>0</id>
      </contributor>
      <origin>713</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="387" sha1="kyv4b9xhkyzi75gmxxmg1l4pd0z2t17" xml:space="preserve">&lt;ref&gt;[./Https://en.wikipedia.org/wiki/Flag_of_South_AfricaHttps://en.wikipedia.org/wiki/Flag_of_South_Africa]&lt;/ref&gt;'''Iflaga yeSewula Afrika''' yatlanywa ngonyaka ka-1994 ngenyanga kaMrhayili, kwabese yamukelwa ngenyanga kaSihlabantangana ngo-1994, ngesikhathi sekhetho zombelele ye-Sewula Afrika yango-1994, ukujamiselela iflaga ebeyisetjenziswa kusukela ngonyaka ka-1928 ukuya ku-1994.</text>
      <sha1>kyv4b9xhkyzi75gmxxmg1l4pd0z2t17</sha1>
    </revision>
    <revision>
      <id>714</id>
      <parentid>713</parentid>
      <timestamp>2024-04-11T10:48:08Z</timestamp>
      <contributor>
        <username>incubator&gt;PHEELL</username>
        <id>0</id>
      </contributor>
      <origin>714</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="404" sha1="my5fqt2qd4u0glvuztm2ctnyl5r3ipk" xml:space="preserve">&lt;ref&gt;[./Https://en.wikipedia.org/wiki/Flag_of_South_AfricaHttps://en.wikipedia.org/wiki/Flag_of_South_Africa]&lt;/ref&gt;'''Iflaga yeSewula Afrika''' yatlanywa ngonyaka ka-1994 ngenyanga kaMrhayili, kwabese yamukelwa ngenyanga kaSihlabantangana ngo-1994, ngesikhathi sekhetho zombelele ye-Sewula Afrika yango-1994, ukujamiselela iflaga ebeyisetjenziswa kusukela ngonyaka ka-1928 ukuya ku-1994.


'''IINKOMBA'''</text>
      <sha1>my5fqt2qd4u0glvuztm2ctnyl5r3ipk</sha1>
    </revision>
    <revision>
      <id>715</id>
      <parentid>714</parentid>
      <timestamp>2024-04-15T14:15:01Z</timestamp>
      <contributor>
        <username>incubator&gt;PHEELL</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>715</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="400" sha1="d7lpz5qieux8uqbds5hgk2ly622mhpj" xml:space="preserve">'''Iflaga yeSewula Afrika''' yatlanywa ngonyaka ka-1994 ngenyanga kaMrhayili, kwabese yamukelwa ngenyanga kaSihlabantangana ngo-1994, ngesikhathi sekhetho zombelele ye-Sewula Afrika yango-1994, ukujamiselela iflaga ebeyisetjenziswa kusukela ngonyaka ka-1928 ukuya ku-1994.



'''IINKOMBA'''

https://www.proquest.com/openview/4e33979a174461d38782ed85a71d66d3/1?pq-origsite=gscholar&amp;cbl=2026366&amp;diss=y</text>
      <sha1>d7lpz5qieux8uqbds5hgk2ly622mhpj</sha1>
    </revision>
    <revision>
      <id>716</id>
      <parentid>715</parentid>
      <timestamp>2024-06-26T18:18:24Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>716</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="451" sha1="pt09adt6gvwx747osvmvy825vk5n7au" xml:space="preserve">'''Iflaga yeSewula Afrika''' yatlanywa ngonyaka ka-1994 ngenyanga kaMrhayili, kwabese yamukelwa ngenyanga kaSihlabantangana ngo-1994, ngesikhathi sekhetho zombelele ye-Sewula Afrika yango-1994, ukujamiselela iflaga ebeyisetjenziswa kusukela ngonyaka ka-1928 ukuya ku-1994.

Iflaga ye Sewula afrika inemibala esithandathu. 




'''IINKOMBA'''

https://www.proquest.com/openview/4e33979a174461d38782ed85a71d66d3/1?pq-origsite=gscholar&amp;cbl=2026366&amp;diss=y</text>
      <sha1>pt09adt6gvwx747osvmvy825vk5n7au</sha1>
    </revision>
    <revision>
      <id>717</id>
      <parentid>716</parentid>
      <timestamp>2024-10-14T13:46:43Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>5 revisions imported</comment>
      <origin>716</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="451" sha1="pt09adt6gvwx747osvmvy825vk5n7au" xml:space="preserve">'''Iflaga yeSewula Afrika''' yatlanywa ngonyaka ka-1994 ngenyanga kaMrhayili, kwabese yamukelwa ngenyanga kaSihlabantangana ngo-1994, ngesikhathi sekhetho zombelele ye-Sewula Afrika yango-1994, ukujamiselela iflaga ebeyisetjenziswa kusukela ngonyaka ka-1928 ukuya ku-1994.

Iflaga ye Sewula afrika inemibala esithandathu. 




'''IINKOMBA'''

https://www.proquest.com/openview/4e33979a174461d38782ed85a71d66d3/1?pq-origsite=gscholar&amp;cbl=2026366&amp;diss=y</text>
      <sha1>pt09adt6gvwx747osvmvy825vk5n7au</sha1>
    </revision>
    <revision>
      <id>2169</id>
      <parentid>717</parentid>
      <timestamp>2024-11-27T06:25:09Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>+ Iinkomba</comment>
      <origin>2169</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="468" sha1="831qhk72p74bbds8bru66l3go3csl8p" xml:space="preserve">'''Iflaga yeSewula Afrika''' yatlanywa ngonyaka ka-1994 ngenyanga kaMrhayili, kwabese yamukelwa ngenyanga kaSihlabantangana ngo-1994, ngesikhathi sekhetho zombelele ye-Sewula Afrika yango-1994, ukujamiselela iflaga ebeyisetjenziswa kusukela ngonyaka ka-1928 ukuya ku-1994.

Iflaga ye Sewula afrika inemibala esithandathu.&lt;ref&gt;https://www.proquest.com/openview/4e33979a174461d38782ed85a71d66d3/1?pq-origsite=gscholar&amp;cbl=2026366&amp;diss=y&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}</text>
      <sha1>831qhk72p74bbds8bru66l3go3csl8p</sha1>
    </revision>
    <revision>
      <id>2392</id>
      <parentid>2169</parentid>
      <timestamp>2025-01-28T12:25:26Z</timestamp>
      <contributor>
        <username>Jfblanc</username>
        <id>328</id>
      </contributor>
      <origin>2392</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="537" sha1="bn5kcxb8xuomn4unonmqlofz31fkok8" xml:space="preserve">[[File:Flag of South Afirca.svg|thumb|400px|Iflaga yeSewula Afrika]]
'''Iflaga yeSewula Afrika''' yatlanywa ngonyaka ka-1994 ngenyanga kaMrhayili, kwabese yamukelwa ngenyanga kaSihlabantangana ngo-1994, ngesikhathi sekhetho zombelele ye-Sewula Afrika yango-1994, ukujamiselela iflaga ebeyisetjenziswa kusukela ngonyaka ka-1928 ukuya ku-1994.

Iflaga ye Sewula afrika inemibala esithandathu.&lt;ref&gt;https://www.proquest.com/openview/4e33979a174461d38782ed85a71d66d3/1?pq-origsite=gscholar&amp;cbl=2026366&amp;diss=y&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}</text>
      <sha1>bn5kcxb8xuomn4unonmqlofz31fkok8</sha1>
    </revision>
    <revision>
      <id>2393</id>
      <parentid>2392</parentid>
      <timestamp>2025-01-28T12:25:36Z</timestamp>
      <contributor>
        <username>Jfblanc</username>
        <id>328</id>
      </contributor>
      <origin>2393</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="537" sha1="gilzobr2l6hhsxnnfybo6b6d32u74cb" xml:space="preserve">[[File:Flag of South Africa.svg|thumb|400px|Iflaga yeSewula Afrika]]
'''Iflaga yeSewula Afrika''' yatlanywa ngonyaka ka-1994 ngenyanga kaMrhayili, kwabese yamukelwa ngenyanga kaSihlabantangana ngo-1994, ngesikhathi sekhetho zombelele ye-Sewula Afrika yango-1994, ukujamiselela iflaga ebeyisetjenziswa kusukela ngonyaka ka-1928 ukuya ku-1994.

Iflaga ye Sewula afrika inemibala esithandathu.&lt;ref&gt;https://www.proquest.com/openview/4e33979a174461d38782ed85a71d66d3/1?pq-origsite=gscholar&amp;cbl=2026366&amp;diss=y&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}</text>
      <sha1>gilzobr2l6hhsxnnfybo6b6d32u74cb</sha1>
    </revision>
    <revision>
      <id>2394</id>
      <parentid>2393</parentid>
      <timestamp>2025-01-28T12:25:54Z</timestamp>
      <contributor>
        <username>Jfblanc</username>
        <id>328</id>
      </contributor>
      <minor />
      <comment>Jfblanc moved page [[Iflaga yeSewula Africa]] to [[Iflaga yeSewula Afrika]]</comment>
      <origin>2393</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="537" sha1="gilzobr2l6hhsxnnfybo6b6d32u74cb" xml:space="preserve">[[File:Flag of South Africa.svg|thumb|400px|Iflaga yeSewula Afrika]]
'''Iflaga yeSewula Afrika''' yatlanywa ngonyaka ka-1994 ngenyanga kaMrhayili, kwabese yamukelwa ngenyanga kaSihlabantangana ngo-1994, ngesikhathi sekhetho zombelele ye-Sewula Afrika yango-1994, ukujamiselela iflaga ebeyisetjenziswa kusukela ngonyaka ka-1928 ukuya ku-1994.

Iflaga ye Sewula afrika inemibala esithandathu.&lt;ref&gt;https://www.proquest.com/openview/4e33979a174461d38782ed85a71d66d3/1?pq-origsite=gscholar&amp;cbl=2026366&amp;diss=y&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}</text>
      <sha1>gilzobr2l6hhsxnnfybo6b6d32u74cb</sha1>
    </revision>
    <revision>
      <id>2396</id>
      <parentid>2394</parentid>
      <timestamp>2025-01-28T12:27:05Z</timestamp>
      <contributor>
        <username>Jfblanc</username>
        <id>328</id>
      </contributor>
      <origin>2396</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="556" sha1="5ji9rso0klm74atv8xe2risbhfti6bo" xml:space="preserve">[[File:Flag of South Africa.svg|thumb|400px|Iflaga yeSewula Afrika]]
'''Iflaga yeSewula Afrika''' yatlanywa ngonyaka ka-1994 ngenyanga kaMrhayili, kwabese yamukelwa ngenyanga kaSihlabantangana ngo-1994, ngesikhathi sekhetho zombelele [[Isewula Afrika|ye-Sewula Afrika]] yango-1994, ukujamiselela iflaga ebeyisetjenziswa kusukela ngonyaka ka-1928 ukuya ku-1994.

Iflaga ye Sewula afrika inemibala esithandathu.&lt;ref&gt;https://www.proquest.com/openview/4e33979a174461d38782ed85a71d66d3/1?pq-origsite=gscholar&amp;cbl=2026366&amp;diss=y&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}</text>
      <sha1>5ji9rso0klm74atv8xe2risbhfti6bo</sha1>
    </revision>
    <revision>
      <id>2626</id>
      <parentid>2396</parentid>
      <timestamp>2025-04-03T19:08:33Z</timestamp>
      <contributor>
        <username>Rachmat04</username>
        <id>32</id>
      </contributor>
      <minor />
      <origin>2626</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="562" sha1="jydeuhvz7kqyml39zsy5u7d3apnpdyu" xml:space="preserve">[[Isimumathi:Flag of South Africa.svg|thumb|400px|Iflaga yeSewula Afrika]]
'''Iflaga yeSewula Afrika''' yatlanywa ngonyaka ka-1994 ngenyanga kaMrhayili, kwabese yamukelwa ngenyanga kaSihlabantangana ngo-1994, ngesikhathi sekhetho zombelele [[Isewula Afrika|ye-Sewula Afrika]] yango-1994, ukujamiselela iflaga ebeyisetjenziswa kusukela ngonyaka ka-1928 ukuya ku-1994.

Iflaga ye Sewula afrika inemibala esithandathu.&lt;ref&gt;https://www.proquest.com/openview/4e33979a174461d38782ed85a71d66d3/1?pq-origsite=gscholar&amp;cbl=2026366&amp;diss=y&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}</text>
      <sha1>jydeuhvz7kqyml39zsy5u7d3apnpdyu</sha1>
    </revision>
  </page>
  <page>
    <title>Ifundo</title>
    <ns>0</ns>
    <id>148</id>
    <revision>
      <id>718</id>
      <timestamp>2024-03-09T07:14:36Z</timestamp>
      <contributor>
        <username>incubator&gt;Mbandeni</username>
        <id>0</id>
      </contributor>
      <comment>Created this page</comment>
      <origin>718</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="43" sha1="pqs4j6wuj5vphhuv42v3hewantbd0bl" xml:space="preserve">Ifundo iqakathekile esikhathini sagadesi.

</text>
      <sha1>pqs4j6wuj5vphhuv42v3hewantbd0bl</sha1>
    </revision>
    <revision>
      <id>719</id>
      <parentid>718</parentid>
      <timestamp>2024-03-09T07:15:53Z</timestamp>
      <contributor>
        <username>incubator&gt;Mbandeni</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Sub-heading and Bold</comment>
      <origin>719</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="95" sha1="sbu7honp5b6jwlkj6ms9aqy2y8jkpcu" xml:space="preserve">'''Ifundo''' iqakathekile esikhathini sagadesi.

=== Umphumela wokuzibandekanya efundweni. ===
</text>
      <sha1>sbu7honp5b6jwlkj6ms9aqy2y8jkpcu</sha1>
    </revision>
    <revision>
      <id>720</id>
      <parentid>719</parentid>
      <timestamp>2024-03-09T08:22:28Z</timestamp>
      <contributor>
        <username>incubator&gt;Lethabo19</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>720</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="197" sha1="tfiyf2mcrzhg4omstbj3hykducuwyxo" xml:space="preserve">[[Isimumathi:Diego Suarez Antsiranana urban public primary school (EPP) Madagascar.jpg|thumb|IFundo]]
'''Ifundo''' iqakathekile esikhathini sagadesi.

=== Umphumela wokuzibandekanya efundweni. ===
</text>
      <sha1>tfiyf2mcrzhg4omstbj3hykducuwyxo</sha1>
    </revision>
    <revision>
      <id>721</id>
      <parentid>720</parentid>
      <timestamp>2024-05-09T12:29:34Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>721</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1051" sha1="5uipemnh0ufoisunvm1x6a1y9stwnlv" xml:space="preserve">[[Isimumathi:Diego Suarez Antsiranana urban public primary school (EPP) Madagascar.jpg|thumb|Umfundisi etlasini]]

== Ifundo ==
Ifundo iqakathekile epilweni yomuntu ngombana inabisa ilwazi lomuntu begodu yandisa nekghono lomuntu. Ukungezelela, ifundo inikela isisekelo sengemuso elihle. 

Esikhathini esiphila kiso, imisebenzi eminengi sele ifuna ilwazi elithize lefundo. Ifundo enarheni yekhethu ihlukaniswe ngokwamazinga amabili. Amazinga asisekelo namazinga aphakemeko. 

Izinga lefundo begodu liqakatheke ukulemukisa abantu ngezinga lwelwazi nanyana lefundokghono analo. Esikhathini esinengi abantu abanezinga eliphezulu lefundo ngombana basebenzisa amagama womukhakha loyo ifundokghono lakhe liwela ngaphasi kwakhona. Amagama la kungenzeka angazwisiseki kumuntu omunye angakafundeli ifundokghono lakhe. 

Ngebanga lobudisi obukhona lokha nawungakafundi, ababelethi abanengi bazithola ngaso soke isikhathi bakhuthaza abentwana babo bonyana bafunde. Lokhu bakwenza ngombana babathanda begodu bafuna ukuthi babe nekusasa nanyana ingemuso elingcono.
</text>
      <sha1>5uipemnh0ufoisunvm1x6a1y9stwnlv</sha1>
    </revision>
    <revision>
      <id>722</id>
      <parentid>721</parentid>
      <timestamp>2024-10-14T13:46:44Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>4 revisions imported</comment>
      <origin>721</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1051" sha1="5uipemnh0ufoisunvm1x6a1y9stwnlv" xml:space="preserve">[[Isimumathi:Diego Suarez Antsiranana urban public primary school (EPP) Madagascar.jpg|thumb|Umfundisi etlasini]]

== Ifundo ==
Ifundo iqakathekile epilweni yomuntu ngombana inabisa ilwazi lomuntu begodu yandisa nekghono lomuntu. Ukungezelela, ifundo inikela isisekelo sengemuso elihle. 

Esikhathini esiphila kiso, imisebenzi eminengi sele ifuna ilwazi elithize lefundo. Ifundo enarheni yekhethu ihlukaniswe ngokwamazinga amabili. Amazinga asisekelo namazinga aphakemeko. 

Izinga lefundo begodu liqakatheke ukulemukisa abantu ngezinga lwelwazi nanyana lefundokghono analo. Esikhathini esinengi abantu abanezinga eliphezulu lefundo ngombana basebenzisa amagama womukhakha loyo ifundokghono lakhe liwela ngaphasi kwakhona. Amagama la kungenzeka angazwisiseki kumuntu omunye angakafundeli ifundokghono lakhe. 

Ngebanga lobudisi obukhona lokha nawungakafundi, ababelethi abanengi bazithola ngaso soke isikhathi bakhuthaza abentwana babo bonyana bafunde. Lokhu bakwenza ngombana babathanda begodu bafuna ukuthi babe nekusasa nanyana ingemuso elingcono.
</text>
      <sha1>5uipemnh0ufoisunvm1x6a1y9stwnlv</sha1>
    </revision>
    <revision>
      <id>3026</id>
      <parentid>722</parentid>
      <timestamp>2025-06-06T20:33:17Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>ban me</comment>
      <origin>3026</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1136" sha1="0gf0lkl78zjjqu09twt1fnke4ihiruz" xml:space="preserve">[[Isimumathi:Diego Suarez Antsiranana urban public primary school (EPP) Madagascar.jpg|thumb|Umfundisi etlasini]]'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.'''

== Ifundo ==
Ifundo iqakathekile epilweni yomuntu ngombana inabisa ilwazi lomuntu begodu yandisa nekghono lomuntu. Ukungezelela, ifundo inikela isisekelo sengemuso elihle. 

Esikhathini esiphila kiso, imisebenzi eminengi sele ifuna ilwazi elithize lefundo. Ifundo enarheni yekhethu ihlukaniswe ngokwamazinga amabili. Amazinga asisekelo namazinga aphakemeko. 

Izinga lefundo begodu liqakatheke ukulemukisa abantu ngezinga lwelwazi nanyana lefundokghono analo. Esikhathini esinengi abantu abanezinga eliphezulu lefundo ngombana basebenzisa amagama womukhakha loyo ifundokghono lakhe liwela ngaphasi kwakhona. Amagama la kungenzeka angazwisiseki kumuntu omunye angakafundeli ifundokghono lakhe. 

Ngebanga lobudisi obukhona lokha nawungakafundi, ababelethi abanengi bazithola ngaso soke isikhathi bakhuthaza abentwana babo bonyana bafunde. Lokhu bakwenza ngombana babathanda begodu bafuna ukuthi babe nekusasa nanyana ingemuso elingcono.</text>
      <sha1>0gf0lkl78zjjqu09twt1fnke4ihiruz</sha1>
    </revision>
    <revision>
      <id>3061</id>
      <parentid>3026</parentid>
      <timestamp>2025-06-07T03:05:22Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Jon Harald Søby|Jon Harald Søby]]</comment>
      <origin>721</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1051" sha1="5uipemnh0ufoisunvm1x6a1y9stwnlv" xml:space="preserve">[[Isimumathi:Diego Suarez Antsiranana urban public primary school (EPP) Madagascar.jpg|thumb|Umfundisi etlasini]]

== Ifundo ==
Ifundo iqakathekile epilweni yomuntu ngombana inabisa ilwazi lomuntu begodu yandisa nekghono lomuntu. Ukungezelela, ifundo inikela isisekelo sengemuso elihle. 

Esikhathini esiphila kiso, imisebenzi eminengi sele ifuna ilwazi elithize lefundo. Ifundo enarheni yekhethu ihlukaniswe ngokwamazinga amabili. Amazinga asisekelo namazinga aphakemeko. 

Izinga lefundo begodu liqakatheke ukulemukisa abantu ngezinga lwelwazi nanyana lefundokghono analo. Esikhathini esinengi abantu abanezinga eliphezulu lefundo ngombana basebenzisa amagama womukhakha loyo ifundokghono lakhe liwela ngaphasi kwakhona. Amagama la kungenzeka angazwisiseki kumuntu omunye angakafundeli ifundokghono lakhe. 

Ngebanga lobudisi obukhona lokha nawungakafundi, ababelethi abanengi bazithola ngaso soke isikhathi bakhuthaza abentwana babo bonyana bafunde. Lokhu bakwenza ngombana babathanda begodu bafuna ukuthi babe nekusasa nanyana ingemuso elingcono.
</text>
      <sha1>5uipemnh0ufoisunvm1x6a1y9stwnlv</sha1>
    </revision>
    <revision>
      <id>5912</id>
      <parentid>3061</parentid>
      <timestamp>2025-10-10T12:17:01Z</timestamp>
      <contributor>
        <username>Hlalithwa</username>
        <id>996</id>
      </contributor>
      <minor />
      <comment>Ukubaluleka kweefundo esikhathini esiphila kiso</comment>
      <origin>5912</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1181" sha1="j5y310r1ljtfwve6yv9f7n9osudblj0" xml:space="preserve">[[Isimumathi:Diego Suarez Antsiranana urban public primary school (EPP) Madagascar.jpg|thumb|Umfundisi etlasini]]

== Ifundo ==
Ifundo esikhathini esiphila kiso ibalulekile empilweni zabantu ngombana inabisa ilwazi lomuntu begodu yandisa nekghono lomuntu, lokhu kufaka hlangana ukwamukela ilwazi elitjha ngesibanga sokungezelela lelolwazi esele unalo begodu ifundo inikela isisekelo sengemuso elihle. 

Esikhathini esiphila kiso imisebenzi eminengi sele ifuna ilwazi elithize lefundo, Ifundo enarheni yekhethu ihlukaniswe ngokwamazinga amabili, okufaka hlangana amazinga asisekelo namazinga aphakemeko. 

Izinga lefundo liqakatheke khulu ekulemukiseni abantu ngezinga lwelwazi nanyana lefundokghono abanawo. Esikhathini esinengi abantu abanezinga eliphezulu lefundo basebenzisa amagama womukhakha loyo ifundokghono lakhe liwela ngaphasi kwakhona. Amagama la kungenzeka angazwisiseki komunye umuntu ongakafundeli ifundokghono lakhe. 

Ngebanga lobudisi obukhona lokha nawungakafundi, ababelethi abanengi bazithola ngaso soke isikhathi bakhuthaza abentwana babo bonyana bafunde. Lokhu bakwenza ngombana babathanda begodu bafuna ukuthi babe nekusasa elihle nanyana ingomuso elingcono.</text>
      <sha1>j5y310r1ljtfwve6yv9f7n9osudblj0</sha1>
    </revision>
  </page>
  <page>
    <title>Ifundo sikhiya saksasa</title>
    <ns>0</ns>
    <id>149</id>
    <revision>
      <id>723</id>
      <timestamp>2024-03-09T10:12:56Z</timestamp>
      <contributor>
        <username>incubator&gt;Simphiwe22</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;Ifundo iqakatheke khulu esikhathini sanamhlanje , ngombana kufanele ufunde ukwazi ukufumana umsebenzi . Uziphilele ngendlela ofuna ngayo uzenzele koke okbalulekileko okfunako.  Esikhathini sanje nawungakafundi awsililitho ebantwini ngombana nemisebenzi itholakala ngefundo  begodu ubonakala umumuntu ongakazimiseli epilweni .  &quot;</comment>
      <origin>723</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="327" sha1="shg48fpnye08942lpijuqkm38n2hq4y" xml:space="preserve">Ifundo iqakatheke khulu esikhathini sanamhlanje , ngombana kufanele ufunde ukwazi ukufumana umsebenzi . Uziphilele ngendlela ofuna ngayo uzenzele koke okbalulekileko okfunako.

Esikhathini sanje nawungakafundi awsililitho ebantwini ngombana nemisebenzi itholakala ngefundo  begodu ubonakala umumuntu ongakazimiseli epilweni .

</text>
      <sha1>shg48fpnye08942lpijuqkm38n2hq4y</sha1>
    </revision>
    <revision>
      <id>724</id>
      <parentid>723</parentid>
      <timestamp>2024-03-09T10:27:57Z</timestamp>
      <contributor>
        <username>incubator&gt;Simphiwe22</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Added content</comment>
      <origin>724</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="337" sha1="os6o01xdk7d7phxjnzmi6yxrydytbug" xml:space="preserve">'''Ifundo''' iqakatheke khulu esikhathini sanamhlanje , ngombana kufanele ufunde ukwazi ukufumana [[umsebenzi]] . Uziphilele ngendlela ofuna ngayo uzenzele koke okbalulekileko okfunako.

Esikhathini sanje nawungakafundi awsililitho ebantwini ngombana nemisebenzi itholakala ngefundo  begodu ubonakala umumuntu ongakazimiseli epilweni .

</text>
      <sha1>os6o01xdk7d7phxjnzmi6yxrydytbug</sha1>
    </revision>
    <revision>
      <id>725</id>
      <parentid>724</parentid>
      <timestamp>2024-03-09T11:03:53Z</timestamp>
      <contributor>
        <username>incubator&gt;Simphiwe22</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Added picture</comment>
      <origin>725</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="439" sha1="m5k70mlutzt6figoxhcjozqzaxb8kgp" xml:space="preserve">[[Isimumathi:Diego Suarez Antsiranana urban public primary school (EPP) Madagascar.jpg|thumb|ifundo]]
'''Ifundo''' iqakatheke khulu esikhathini sanamhlanje , ngombana kufanele ufunde ukwazi ukufumana [[umsebenzi]] . Uziphilele ngendlela ofuna ngayo uzenzele koke okbalulekileko okfunako.

Esikhathini sanje nawungakafundi awsililitho ebantwini ngombana nemisebenzi itholakala ngefundo  begodu ubonakala umumuntu ongakazimiseli epilweni .

</text>
      <sha1>m5k70mlutzt6figoxhcjozqzaxb8kgp</sha1>
    </revision>
    <revision>
      <id>726</id>
      <parentid>725</parentid>
      <timestamp>2024-10-14T13:46:44Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>725</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="439" sha1="m5k70mlutzt6figoxhcjozqzaxb8kgp" xml:space="preserve">[[Isimumathi:Diego Suarez Antsiranana urban public primary school (EPP) Madagascar.jpg|thumb|ifundo]]
'''Ifundo''' iqakatheke khulu esikhathini sanamhlanje , ngombana kufanele ufunde ukwazi ukufumana [[umsebenzi]] . Uziphilele ngendlela ofuna ngayo uzenzele koke okbalulekileko okfunako.

Esikhathini sanje nawungakafundi awsililitho ebantwini ngombana nemisebenzi itholakala ngefundo  begodu ubonakala umumuntu ongakazimiseli epilweni .

</text>
      <sha1>m5k70mlutzt6figoxhcjozqzaxb8kgp</sha1>
    </revision>
  </page>
  <page>
    <title>Ifundo yama 2000</title>
    <ns>0</ns>
    <id>150</id>
    <revision>
      <id>727</id>
      <timestamp>2024-03-09T10:38:01Z</timestamp>
      <contributor>
        <username>incubator&gt;CdTshabangu</username>
        <id>0</id>
      </contributor>
      <comment>ipilo</comment>
      <origin>727</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1149" sha1="8h7t2qys8l848cjehkr8offg8lgxrfj" xml:space="preserve">ama 2000 babantu aba thanda ukubona izinto ngokwabo abafuni ukuzwa ngobathi, nangendlela bazi phatha gayo ayifani nayo ya woke umuntu yingakho nefundweni bazenzela umathanda yeke bakhona abathanda ukuthi maba fikile endaweni kwaziwe bonyana nagu yena seka fikile. mhlapha nje kwakune sokana ebeli funda ibanga le shumi liye layekela isikolo layo berega lathi masele libona bonyana alisakhoni uku berega la buyela esikolweni lafunda lathi masele libona bonyana liphumelele ebangeni elilandelako, la phuma godu. 

ngithe mangilibuza lathi lona lifuna imali be ifundo le iyambambezela ngombana unabazali abamenzela koke akufunako. ngithe mangibona bonyana unakho koke ngabona bonyana yikho abona ngathi ifundo ayikaqakatheki kangako, yeke ngayobuza omunye engimbona bonyana uli 2000 naye wathi yena ifundo akusiyo yake, ngokuya ngaye thana uhlala ekhaya bamnikele yoke into ayifunako befuthi bamuphe ne mali ayifunako ngaso soke isikhathi.
ngiye ngambuza bonyana akaqabangi bonyana makangaba neyakhe imali angazenzela koke lokhu nokunye okundlula lokhu na? 
i pilo yabo abanye babo abayiboni isemfundweni bafuna izinto zize bahlezi.
I PILO YAMA 2000.

</text>
      <sha1>8h7t2qys8l848cjehkr8offg8lgxrfj</sha1>
    </revision>
    <revision>
      <id>728</id>
      <parentid>727</parentid>
      <timestamp>2024-03-09T10:45:23Z</timestamp>
      <contributor>
        <username>incubator&gt;CdTshabangu</username>
        <id>0</id>
      </contributor>
      <origin>728</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1259" sha1="rm85dzi53v2rfi2hatl1xbdxiqn6hui" xml:space="preserve">'''Ama 2000''' babantu aba thanda ukubona izinto ngokwabo abafuni ukuzwa ngobathi, nangendlela bazi phatha gayo ayifani nayo ya woke umuntu yingakho nefundweni bazenzela umathanda yeke bakhona abathanda ukuthi maba fikile endaweni kwaziwe bonyana nagu yena seka fikile. mhlapha nje kwakune sokana ebeli funda ibanga le shumi liye layekela isikolo layo berega lathi masele libona bonyana alisakhoni uku berega la buyela esikolweni lafunda lathi masele libona bonyana liphumelele ebangeni elilandelako, la phuma godu. 
[[Isimumathi:Garni, Armenian youth, Young Armenians, Armenia.jpg|thumb|Ama 2000]]

== IPILO YAMA 2000 ==
Ngithe mangilibuza lathi lona lifuna imali be ifundo le iyambambezela ngombana unabazali abamenzela koke akufunako. ngithe mangibona bonyana unakho koke ngabona bonyana yikho abona ngathi ifundo ayikaqakatheki kangako, yeke ngayobuza omunye engimbona bonyana uli 2000 naye wathi yena ifundo akusiyo yake, ngokuya ngaye thana uhlala ekhaya bamnikele yoke into ayifunako befuthi bamuphe ne mali ayifunako ngaso soke isikhathi.
ngiye ngambuza bonyana akaqabangi bonyana makangaba neyakhe imali angazenzela koke lokhu nokunye okundlula lokhu na? 
i pilo yabo abanye babo abayiboni isemfundweni bafuna izinto zize bahlezi.
I PILO YAMA 2000.

</text>
      <sha1>rm85dzi53v2rfi2hatl1xbdxiqn6hui</sha1>
    </revision>
    <revision>
      <id>729</id>
      <parentid>728</parentid>
      <timestamp>2024-03-09T10:46:28Z</timestamp>
      <contributor>
        <username>incubator&gt;CdTshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>729</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1260" sha1="p3xs83tb7n35kn0x8dcdc81h9pq0dug" xml:space="preserve">'''Ama 2000''' babantu aba thanda ukubona izinto ngokwabo abafuni ukuzwa ngobathi, nangendlela bazi phatha gayo ayifani nayo ya woke umuntu yingakho nefundweni bazenzela umathanda yeke bakhona abathanda ukuthi maba fikile endaweni kwaziwe bonyana nagu yena seka fikile. mhlapha nje kwakune sokana ebeli funda ibanga le shumi liye layekela isikolo layo berega lathi masele libona bonyana alisakhoni uku berega la buyela esikolweni lafunda lathi masele libona bonyana liphumelele ebangeni elilandelako, la phuma godu. 
[[Isimumathi:Garni, Armenian youth, Young Armenians, Armenia.jpg|thumb|Ama 2000]]

== IFUNDO YAMA 2000 ==
Ngithe mangilibuza lathi lona lifuna imali be ifundo le iyambambezela ngombana unabazali abamenzela koke akufunako. ngithe mangibona bonyana unakho koke ngabona bonyana yikho abona ngathi ifundo ayikaqakatheki kangako, yeke ngayobuza omunye engimbona bonyana uli 2000 naye wathi yena ifundo akusiyo yake, ngokuya ngaye thana uhlala ekhaya bamnikele yoke into ayifunako befuthi bamuphe ne mali ayifunako ngaso soke isikhathi.
ngiye ngambuza bonyana akaqabangi bonyana makangaba neyakhe imali angazenzela koke lokhu nokunye okundlula lokhu na? 
i pilo yabo abanye babo abayiboni isemfundweni bafuna izinto zize bahlezi.
I PILO YAMA 2000.

</text>
      <sha1>p3xs83tb7n35kn0x8dcdc81h9pq0dug</sha1>
    </revision>
    <revision>
      <id>730</id>
      <parentid>729</parentid>
      <timestamp>2024-03-09T10:56:09Z</timestamp>
      <contributor>
        <username>incubator&gt;CdTshabangu</username>
        <id>0</id>
      </contributor>
      <origin>730</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1532" sha1="f2sg8iteraiyqb9chj4kv7qro6eim0a" xml:space="preserve">[[Isimumathi:Youth Climate Strike- North Bay - 32455665987.jpg|thumb|Abafundi abazimiseleko]]
'''Ama 2000''' babantu aba thanda ukubona izinto ngokwabo abafuni ukuzwa ngobathi, nangendlela bazi phatha gayo ayifani nayo ya woke umuntu yingakho nefundweni bazenzela umathanda yeke bakhona abathanda ukuthi maba fikile endaweni kwaziwe bonyana nagu yena seka fikile. abanye bona bazimisele ngeemfundo zabo begodu bafuna ukuzibona baphumelele epilweni, bese kunabanye bafuna ipilo le ibe lila kibo babe nakho koke ebakufunako bangaka kusebenzeli.Mhlapha nje kwakune sokana ebeli funda ibanga le shumi liye layekela isikolo layo berega lathi masele libona bonyana alisakhoni uku berega la buyela esikolweni lafunda lathi masele libona bonyana liphumelele ebangeni elilandelako, la phuma godu. 
[[Isimumathi:Garni, Armenian youth, Young Armenians, Armenia.jpg|thumb|Ama 2000]]

== IFUNDO YAMA 2000 ==
Ngithe mangilibuza lathi lona lifuna imali be ifundo le iyambambezela ngombana unabazali abamenzela koke akufunako. ngithe mangibona bonyana unakho koke ngabona bonyana yikho abona ngathi ifundo ayikaqakatheki kangako, yeke ngayobuza omunye engimbona bonyana uli 2000 naye wathi yena ifundo akusiyo yake, ngokuya ngaye thana uhlala ekhaya bamnikele yoke into ayifunako befuthi bamuphe ne mali ayifunako ngaso soke isikhathi.
ngiye ngambuza bonyana akaqabangi bonyana makangaba neyakhe imali angazenzela koke lokhu nokunye okundlula lokhu na? 
i pilo yabo abanye babo abayiboni isemfundweni bafuna izinto zize bahlezi.
I PILO YAMA 2000.

</text>
      <sha1>f2sg8iteraiyqb9chj4kv7qro6eim0a</sha1>
    </revision>
    <revision>
      <id>731</id>
      <parentid>730</parentid>
      <timestamp>2024-03-09T10:57:02Z</timestamp>
      <contributor>
        <username>incubator&gt;CdTshabangu</username>
        <id>0</id>
      </contributor>
      <origin>731</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1533" sha1="8stfnxs5es1a83u0w64fe2dq6lb9mwy" xml:space="preserve">[[Isimumathi:Youth Climate Strike- North Bay - 32455665987.jpg|thumb|Abafundi abazimiseleko]]
'''Ama 2000''' babantu aba thanda ukubona izinto ngokwabo abafuni ukuzwa ngobathi, nangendlela bazi phatha gayo ayifani nayo ya woke umuntu yingakho nefundweni bazenzela umathanda yeke bakhona abathanda ukuthi maba fikile endaweni kwaziwe bonyana nagu yena seka fikile. abanye bona bazimisele ngeemfundo zabo begodu bafuna ukuzibona baphumelele epilweni, bese kunabanye bafuna ipilo le ibe lila kibo babe nakho koke ebakufunako bangaka kusebenzeli.Mhlapha nje kwakune sokana ebeli funda ibanga le shumi liye layekela isikolo layo berega lathi masele libona bonyana alisakhoni uku berega la buyela esikolweni lafunda lathi masele libona bonyana liphumelele ebangeni elilandelako, la phuma godu. 
[[Isimumathi:Garni, Armenian youth, Young Armenians, Armenia.jpg|thumb|Ama 2000]]

== IFUNDO YAMA 2000 ==
Ngithe mangilibuza lathi lona lifuna imali be ifundo le iyambambezela ngombana unabazali abamenzela koke akufunako. ngithe mangibona bonyana unakho koke ngabona bonyana yikho abona ngathi ifundo ayikaqakatheki kangako, yeke ngayobuza omunye engimbona bonyana uli 2000 naye wathi yena ifundo akusiyo yake, ngokuya ngaye thana uhlala ekhaya bamnikele yoke into ayifunako befuthi bamuphe ne mali ayifunako ngaso soke isikhathi.
ngiye ngambuza bonyana akaqabangi bonyana makangaba neyakhe imali angazenzela koke lokhu nokunye okundlula lokhu na? 
i pilo yabo abanye babo abayiboni isemfundweni bafuna izinto zize bahlezi.
I FUNDO YAMA 2000.

</text>
      <sha1>8stfnxs5es1a83u0w64fe2dq6lb9mwy</sha1>
    </revision>
    <revision>
      <id>732</id>
      <parentid>731</parentid>
      <timestamp>2024-03-09T10:58:28Z</timestamp>
      <contributor>
        <username>incubator&gt;CdTshabangu</username>
        <id>0</id>
      </contributor>
      <origin>732</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1534" sha1="4wxj336juo4lq8wj4kon2uw950tpu35" xml:space="preserve">[[Isimumathi:Youth Climate Strike- North Bay - 32455665987.jpg|thumb|Abafundi abazimiseleko]]
'''Ama 2000''' babantu aba thanda ukubona izinto ngokwabo abafuni ukuzwa ngobathi, nangendlela bazi phatha gayo ayifani nayo ya woke umuntu yingakho nefundweni bazenzela umathanda yeke bakhona abathanda ukuthi maba fikile endaweni kwaziwe bonyana nangu yena seka fikile. abanye bona bazimisele ngeemfundo zabo begodu bafuna ukuzibona baphumelele epilweni, bese kunabanye bafuna ipilo le ibe lila kibo babe nakho koke ebakufunako bangaka kusebenzeli.Mhlapha nje kwakune sokana ebeli funda ibanga le shumi liye layekela isikolo layo berega lathi masele libona bonyana alisakhoni uku berega la buyela esikolweni lafunda lathi masele libona bonyana liphumelele ebangeni elilandelako, la phuma godu. 
[[Isimumathi:Garni, Armenian youth, Young Armenians, Armenia.jpg|thumb|Ama 2000]]

== IFUNDO YAMA 2000 ==
Ngithe mangilibuza lathi lona lifuna imali be ifundo le iyambambezela ngombana unabazali abamenzela koke akufunako. ngithe mangibona bonyana unakho koke ngabona bonyana yikho abona ngathi ifundo ayikaqakatheki kangako, yeke ngayobuza omunye engimbona bonyana uli 2000 naye wathi yena ifundo akusiyo yake, ngokuya ngaye thana uhlala ekhaya bamnikele yoke into ayifunako befuthi bamuphe ne mali ayifunako ngaso soke isikhathi.
ngiye ngambuza bonyana akaqabangi bonyana makangaba neyakhe imali angazenzela koke lokhu nokunye okundlula lokhu na? 
i pilo yabo abanye babo abayiboni isemfundweni bafuna izinto zize bahlezi.
I FUNDO YAMA 2000.

</text>
      <sha1>4wxj336juo4lq8wj4kon2uw950tpu35</sha1>
    </revision>
    <revision>
      <id>733</id>
      <parentid>732</parentid>
      <timestamp>2024-03-20T06:48:19Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>733</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1544" sha1="pc1ogfy5g3taign82na2bqq887hmevn" xml:space="preserve">[[Isimumathi:Youth Climate Strike- North Bay - 32455665987.jpg|thumb|Abafundi abazimiseleko]]
'''Ama 2000''' babantu aba thanda ukubona izinto ngokwabo abafuni ukuzwa ngobatjho, nangendlela bazi phatha ngayo ayifani nayo ya woke umuntu yingakho nefundweni bazenzela umathanda. Yeke bakhona abathanda ukuthi naba fikile endaweni kwaziwe bonyana nangu yena seka fikile,. abanye bona bazimisele ngeemfundo zabo begodu bafuna ukuzibona baphumelele epilweni, bese kunabanye bafuna ipilo le ibe lula kibo babe nakho koke ebakufunako bangaka kusebenzeli. Mhlapha nje kwakune sokana ebeli funda ibanga le tjhumi liye layekela isikolo layo sebenza lathi nasele libona bonyana alisakhoni uku sebenza la buyela esikolweni lafunda lathi nasele libona bonyana liphumelele ebangeni elilandelako, la phuma godu. 
[[Isimumathi:Garni, Armenian youth, Young Armenians, Armenia.jpg|thumb|Ama 2000]]

== IFUNDO YAMA 2000 ==
Ngithe nangilibuza lathi lona lifuna imali be [[ifundo]] le iyambambezela ngombana unabazali abamenzela koke akufunako. ngithe nangibona bonyana unakho koke ngabona kobana ngikho abona ngathi ifundo ayikaqakatheki kangako. Ngayobuza omunye engimbona bonyana uli 2000 naye wathi yena ifundo akusiyo yakhe, ngokuya ngaye ngathana uhlala ekhaya bamnikele yoke into ayifunako befuthi bamuphe ne mali ayifunako ngaso soke isikhathi.
ngiye ngambuza bonyana akaqabangi bonyana nakangaba neyakhe imali angazenzela koke lokhu nokunye okundlula lokhu na? 
i pilo yabo abanye babo abayiboni isefundweni bafuna izinto zize bahlezi.
I FUNDO YAMA 2000.

</text>
      <sha1>pc1ogfy5g3taign82na2bqq887hmevn</sha1>
    </revision>
    <revision>
      <id>734</id>
      <parentid>733</parentid>
      <timestamp>2024-10-14T13:46:45Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>7 revisions imported</comment>
      <origin>733</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1544" sha1="pc1ogfy5g3taign82na2bqq887hmevn" xml:space="preserve">[[Isimumathi:Youth Climate Strike- North Bay - 32455665987.jpg|thumb|Abafundi abazimiseleko]]
'''Ama 2000''' babantu aba thanda ukubona izinto ngokwabo abafuni ukuzwa ngobatjho, nangendlela bazi phatha ngayo ayifani nayo ya woke umuntu yingakho nefundweni bazenzela umathanda. Yeke bakhona abathanda ukuthi naba fikile endaweni kwaziwe bonyana nangu yena seka fikile,. abanye bona bazimisele ngeemfundo zabo begodu bafuna ukuzibona baphumelele epilweni, bese kunabanye bafuna ipilo le ibe lula kibo babe nakho koke ebakufunako bangaka kusebenzeli. Mhlapha nje kwakune sokana ebeli funda ibanga le tjhumi liye layekela isikolo layo sebenza lathi nasele libona bonyana alisakhoni uku sebenza la buyela esikolweni lafunda lathi nasele libona bonyana liphumelele ebangeni elilandelako, la phuma godu. 
[[Isimumathi:Garni, Armenian youth, Young Armenians, Armenia.jpg|thumb|Ama 2000]]

== IFUNDO YAMA 2000 ==
Ngithe nangilibuza lathi lona lifuna imali be [[ifundo]] le iyambambezela ngombana unabazali abamenzela koke akufunako. ngithe nangibona bonyana unakho koke ngabona kobana ngikho abona ngathi ifundo ayikaqakatheki kangako. Ngayobuza omunye engimbona bonyana uli 2000 naye wathi yena ifundo akusiyo yakhe, ngokuya ngaye ngathana uhlala ekhaya bamnikele yoke into ayifunako befuthi bamuphe ne mali ayifunako ngaso soke isikhathi.
ngiye ngambuza bonyana akaqabangi bonyana nakangaba neyakhe imali angazenzela koke lokhu nokunye okundlula lokhu na? 
i pilo yabo abanye babo abayiboni isefundweni bafuna izinto zize bahlezi.
I FUNDO YAMA 2000.

</text>
      <sha1>pc1ogfy5g3taign82na2bqq887hmevn</sha1>
    </revision>
    <revision>
      <id>5093</id>
      <parentid>734</parentid>
      <timestamp>2025-08-08T09:27:13Z</timestamp>
      <contributor>
        <username>Mtsweni S</username>
        <id>835</id>
      </contributor>
      <origin>5093</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1534" sha1="261ydo4dz5msclixua1yn8p6vzn65i8" xml:space="preserve">[[Isimumathi:Youth Climate Strike- North Bay - 32455665987.jpg|thumb|Abafundi abazimiseleko]]
'''Ama 2000''' babantu abathanda ukubona izinto ngokwabo abafuni ukuzwa ngobatjho, nangendlela bazi phatha ngayo ayifani nayo yawoke umuntu, kungebangelo nefundweni bazenzela umathanda. Yeke bakhona abathanda ukuthi naba fikileko endaweni kwaziwe bonyana nangu yena seka fikile,. abanye bona bazimisele ngeemfundo zabo begodu bafuna ukuzibona baphumelele epilweni, bese kunabanye abafuna ipilo le ibe lula kibo babe nakho koke ebakufunako bangakakusebenzeli. Mhlapha nje kwakune sokana ekhabe lifunda ibanga letjhumi nanye layekela isikolo layokusebenza, lathi nasele libona bonyana alisakghoni ukusebenza labuyela esikolweni lafunda. Sele libona bonyana liphumelele ebangeni elilandelako, laphuma godu. 
[[Isimumathi:Garni, Armenian youth, Young Armenians, Armenia.jpg|thumb|Ama 2000]]

== IFUNDO YAMA 2000 ==
Ngithe nangilibuzako lathi lona lifuna imali, i[[ifundo|fundo]] le iyambambezela ngombana unababelethi abamenzela koke akufunako. Nangibona bonyana unakho koke ngabona kobana ngikho abona ngathi ifundo ayikaqakatheki kangako. Ngabuza omunye engimbona bonyana uli-2000 naye wathi yena ifundo akusiyo yakhe, ngokuya ngaye ngathana uhlala ekhaya bamnikele yoke into ayifunako begodu bamuphe nemali ayifunako ngaso soke isikhathi, ngiye ngambuza kobana akaqabangi bona nakangaba neyakhe imali angazenzela koke lokhu nokunye okudlula lokhu na? ipilo yabo abanye babo abayiboni isefundweni bafuna izinto zize bahlezi.
IFUNDO YAMA 2000.</text>
      <sha1>261ydo4dz5msclixua1yn8p6vzn65i8</sha1>
    </revision>
  </page>
  <page>
    <title>Iimbandana ezihlanu ezikulu</title>
    <ns>0</ns>
    <id>151</id>
    <revision>
      <id>735</id>
      <timestamp>2024-06-27T12:08:37Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Iimbandana''' ezihlanu ezikulu ngilezo mbandana ezitholakala amalini yephepha yeSewula Afrika.  &quot;</comment>
      <origin>735</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="99" sha1="pi1l1ob07usdqu9z4o8l9zli7ok0873" xml:space="preserve">'''Iimbandana''' ezihlanu ezikulu ngilezo mbandana ezitholakala amalini yephepha yeSewula Afrika.

</text>
      <sha1>pi1l1ob07usdqu9z4o8l9zli7ok0873</sha1>
    </revision>
    <revision>
      <id>736</id>
      <parentid>735</parentid>
      <timestamp>2024-06-27T13:13:51Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>736</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="262" sha1="fpdv86dsd55zdj74hnad4z2stynoxre" xml:space="preserve">'''Iimbandana''' ezihlanu ezikulu ngilezo mbandana ezitholakala amalini yephepha yeSewula Afrika. Imbandana lezi zihlala ehlathini begodu azibekwa hlangana nabantu ngombana ziyingozi khulu. Amagama weembandana lezi yibhubezi, indlovu, umkhombe, ingwe nenyathi.

</text>
      <sha1>fpdv86dsd55zdj74hnad4z2stynoxre</sha1>
    </revision>
    <revision>
      <id>737</id>
      <parentid>736</parentid>
      <timestamp>2024-10-14T13:46:45Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>736</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="262" sha1="fpdv86dsd55zdj74hnad4z2stynoxre" xml:space="preserve">'''Iimbandana''' ezihlanu ezikulu ngilezo mbandana ezitholakala amalini yephepha yeSewula Afrika. Imbandana lezi zihlala ehlathini begodu azibekwa hlangana nabantu ngombana ziyingozi khulu. Amagama weembandana lezi yibhubezi, indlovu, umkhombe, ingwe nenyathi.

</text>
      <sha1>fpdv86dsd55zdj74hnad4z2stynoxre</sha1>
    </revision>
    <revision>
      <id>5776</id>
      <parentid>737</parentid>
      <timestamp>2025-09-22T16:53:23Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5776</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="836" sha1="frctlwsui2rapcgwttrfbjh1k5gtoyq" xml:space="preserve">[[Isimumathi:Lion (Panthera leo) male 6y.jpg|thumb|Ibhubezi]]
'''Iimbandana ezihlanu ezikulu''' ngilezo mbandana ezitholakala amalini yephepha yeSewula Afrika. Imbandana lezi zihlala ehlathini begodu azibekwa hlangana nabantu ngombana ziyingozi khulu. Amagama weembandana lezi yibhubezi, indlovu, umkhombe, ingwe nenyathi. Zingilezo mbandana ezaziwa bonyana ziyakghona ukuzingela.

Ibhubezi

Laziwa njenge kosi yehlathini, begodu, lona ngoko mhlobo liwela kibo katsu. Ibhubezi lilitshwayo lamandla nobukhosi ehlathini le Afrika.Amabhubezi  atholakala ehlathini le-Afrika begodu ngoko mlando e-India. Amabhubezi asikazi esikhathini esinengi ngiwo akhambako ayokuzingela afune inyamazana ezifana nama Zebra, impala, nokhunye. Akghona kubhodla ngamaphimbo wawo asabekako begodu ukubhodla kwawo kudlisa umlayezo othileko kwezinye imbandana.</text>
      <sha1>frctlwsui2rapcgwttrfbjh1k5gtoyq</sha1>
    </revision>
    <revision>
      <id>5777</id>
      <parentid>5776</parentid>
      <timestamp>2025-09-22T17:01:42Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5777</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1428" sha1="n04q4hey15losfr2rrgi74x5hlki8m7" xml:space="preserve">[[Isimumathi:Lion (Panthera leo) male 6y.jpg|thumb|Ibhubezi]]
'''Iimbandana ezihlanu ezikulu''' ngilezo mbandana ezitholakala amalini yephepha yeSewula Afrika. Imbandana lezi zihlala ehlathini begodu azibekwa hlangana nabantu ngombana ziyingozi khulu. Amagama weembandana lezi yibhubezi, indlovu, umkhombe, ingwe nenyathi. Zingilezo mbandana ezaziwa bonyana ziyakghona ukuzingela.

=== Ibhubezi ===
Laziwa njenge kosi yehlathini, begodu, lona ngoko mhlobo liwela kibo katsu. Ibhubezi lilitshwayo lamandla nobukhosi ehlathini le Afrika.Amabhubezi  atholakala ehlathini le-Afrika begodu ngoko mlando e-India. Amabhubezi asikazi esikhathini esinengi ngiwo akhambako ayokuzingela afune inyamazana ezifana nama Zebra, impala, nokhunye. Akghona kubhodla ngamaphimbo wawo asabekako begodu ukubhodla kwawo kudlisa umlayezo othileko kwezinye imbandana.

=== Indlovu ===
Indlovu isimunyisi esikulu ukuzidlula zoke iimunyisi. Zihlakaniphile begodu zinekghono lokukhumbula. Indlovu  ithatha pheze iminyaka emibili ukuthi ukuthi icede ukuzithwala beyithola umntwana ophilileko.zitholakakala endaweni ezele utjani nofana ehlathini le-Afrika ne-Asia. nokwahe inomboko osebenza njengepumulo nendebe yomlomo yangaphezulu. Isebenzisa umboko lo ukuphefumula nokubamaba izinto. Inamaphndo amabili ewasebenzisela ukugubha nofana ukwemba nokuzivikela. Iindlovu zikhamba  bezihlale ngeenqhema ezidoswa phambili ziindlovu ezisikazi ezidala ngokomnyaka.</text>
      <sha1>n04q4hey15losfr2rrgi74x5hlki8m7</sha1>
    </revision>
    <revision>
      <id>5778</id>
      <parentid>5777</parentid>
      <timestamp>2025-09-22T17:10:11Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5778</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2117" sha1="jwbmlwmw9zl61mtoowzuloaum9b4all" xml:space="preserve">[[Isimumathi:Lion (Panthera leo) male 6y.jpg|thumb|Ibhubezi]]
'''Iimbandana ezihlanu ezikulu''' ngilezo mbandana ezitholakala amalini yephepha yeSewula Afrika. Imbandana lezi zihlala ehlathini begodu azibekwa hlangana nabantu ngombana ziyingozi angekhe umuntu azizingela lula.&lt;ref&gt;[https://gosafari.co.za/blog/animals-of-south-africa/the-big-five-safari-in-south-africa.html The Big Five - Go SAfari]&lt;/ref&gt; Amagama weembandana lezi yibhubezi, indlovu, umkhombe, ingwe nenyathi. Zingilezo mbandana ezaziwa bonyana ziyakghona ukuzingela.

=== Ibhubezi ===
Laziwa njenge kosi yehlathini, begodu, lona ngoko mhlobo liwela kibo katsu. Ibhubezi lilitshwayo lamandla nobukhosi ehlathini le Afrika.Amabhubezi  atholakala ehlathini le-Afrika begodu ngoko mlando e-India. Amabhubezi asikazi esikhathini esinengi ngiwo akhambako ayokuzingela afune inyamazana ezifana nama Zebra, impala, nokhunye.&lt;ref&gt;[https://gosafari.co.za/blog/animals-of-south-africa/the-big-five-safari-in-south-africa.html The Big Five - Go SAfari]&lt;/ref&gt; Akghona kubhodla ngamaphimbo wawo asabekako begodu ukubhodla kwawo kudlisa umlayezo othileko kwezinye imbandana. Amabhubezi ahlalal endaweni ezibizwa bona ma-''pride.''

=== Indlovu ===
[[Isimumathi:Elephant running.jpg|thumb|Iindlovu ezikhamba ngesiqhema ziyagijima]]
Indlovu isimunyisi esikulu ukuzidlula zoke iimunyisi. Zihlakaniphile begodu zinekghono lokukhumbula. Indlovu  ithatha pheze iminyaka emibili ukuthi ukuthi icede ukuzithwala beyithola umntwana ophilileko.zitholakakala endaweni ezele utjani nofana ehlathini le-Afrika ne-Asia. nokwahe inomboko osebenza njengepumulo nendebe yomlomo yangaphezulu. Isebenzisa umboko lo ukuphefumula nokubamaba izinto. Inamaphndo amabili ewasebenzisela ukugubha nofana ukwemba nokuzivikela. Iindlovu zikhamba  bezihlale ngeenqhema ezidoswa phambili ziindlovu ezisikazi ezidala ngokomnyaka. Ziyakghona ukusebenzisaa zikhombisa ukuba nizwa yokuzwela lokho kubonakala ngombana ziyazila lokha nazilahlekelwa mumuntu ezithandako. Ayikhohlwa nakhe wayenza into embi. Ukukhuluma zisebenzisa itjhada eliwenza ngomboko kanye nokunyakazisa umzimba.

== Iinkomba ==</text>
      <sha1>jwbmlwmw9zl61mtoowzuloaum9b4all</sha1>
    </revision>
    <revision>
      <id>5779</id>
      <parentid>5778</parentid>
      <timestamp>2025-09-22T17:21:12Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5779</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2873" sha1="oesriubdicp7y1f65rrr8q6tk8lz8ku" xml:space="preserve">[[Isimumathi:Lion (Panthera leo) male 6y.jpg|thumb|Ibhubezi]]
'''Iimbandana ezihlanu ezikulu''' ngilezo mbandana ezitholakala amalini yephepha yeSewula Afrika. Imbandana lezi zihlala ehlathini begodu azibekwa hlangana nabantu ngombana ziyingozi angekhe umuntu azizingela lula.&lt;ref&gt;[https://gosafari.co.za/blog/animals-of-south-africa/the-big-five-safari-in-south-africa.html The Big Five - Go SAfari]&lt;/ref&gt; Amagama weembandana lezi yibhubezi, indlovu, umkhombe, ingwe nenyathi. Zingilezo mbandana ezaziwa bonyana ziyakghona ukuzingela.

=== Ibhubezi ===
Laziwa njenge kosi yehlathini, begodu, lona ngoko mhlobo liwela kibo katsu. Ibhubezi lilitshwayo lamandla nobukhosi ehlathini le Afrika.Amabhubezi  atholakala ehlathini le-Afrika begodu ngoko mlando e-India. Amabhubezi asikazi esikhathini esinengi ngiwo akhambako ayokuzingela afune inyamazana ezifana nama Zebra, impala, nokhunye.&lt;ref&gt;[https://gosafari.co.za/blog/animals-of-south-africa/the-big-five-safari-in-south-africa.html The Big Five - Go SAfari]&lt;/ref&gt; Akghona kubhodla ngamaphimbo wawo asabekako begodu ukubhodla kwawo kudlisa umlayezo othileko kwezinye imbandana. Amabhubezi ahlalal endaweni ezibizwa bona ma-''pride.''

=== Indlovu ===
[[Isimumathi:Elephant running.jpg|thumb|Iindlovu ezikhamba ngesiqhema ziyagijima]]
Indlovu isimunyisi esikulu ukuzidlula zoke iimunyisi. Zihlakaniphile begodu zinekghono lokukhumbula. Indlovu  ithatha pheze iminyaka emibili ukuthi ukuthi icede ukuzithwala beyithola umntwana ophilileko.zitholakakala endaweni ezele utjani nofana ehlathini le-Afrika ne-Asia. nokwahe inomboko osebenza njengepumulo nendebe yomlomo yangaphezulu. Isebenzisa umboko lo ukuphefumula nokubamaba izinto. Inamaphndo amabili ewasebenzisela ukugubha nofana ukwemba nokuzivikela. Iindlovu zikhamba  bezihlale ngeenqhema ezidoswa phambili ziindlovu ezisikazi ezidala ngokomnyaka. Ziyakghona ukusebenzisaa zikhombisa ukuba nizwa yokuzwela lokho kubonakala ngombana ziyazila lokha nazilahlekelwa mumuntu ezithandako. Ayikhohlwa nakhe wayenza into embi. Ukukhuluma zisebenzisa itjhada eliwenza ngomboko kanye nokunyakazisa umzimba.

=== Ingwe ===
Ingwe ngomunye yemihlobo yabokatsu abakhona, yona ingukatsu omkhulu ohlukaniseka ngokuthi unamabala emzimbeni. Ihlala emangweni begodu inekghono lokugijima ngombana iphila ngokuzingela igijime inyamazana ehlathini. Izingwe zitholakala enarhakazini ye-Asia ne- Afrika. Zikhombisa amandla, umusa, namandla wehlathini. Ingwe ikghona ukukhwela umuthi begodu eskhathi esinengi nayibamba inyamzana, ithatha iinyamanazana leyo iyoyibeka emthini phezulu. Zikghona ukuphila ehlathini, emangweni begodu neentabeni.&lt;ref&gt;[https://www.south-african-lodges.com/page/big-five/ African Safaris Big Five - Lions, Elephant, Rhinoceros, Buffalo, Leopard]&lt;/ref&gt; Zikghona ukuzingela kuhle lokha ilanga nalingakhanyiko begodu lisebenzisa amabala wayo ukuzifihla.

== Iinkomba ==</text>
      <sha1>oesriubdicp7y1f65rrr8q6tk8lz8ku</sha1>
    </revision>
    <revision>
      <id>5780</id>
      <parentid>5779</parentid>
      <timestamp>2025-09-22T17:23:11Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5780</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3050" sha1="ffcrw3gneo3qjerdlfvnmrno128xq7x" xml:space="preserve">[[Isimumathi:Lion (Panthera leo) male 6y.jpg|thumb|Ibhubezi]]
'''Iimbandana ezihlanu ezikulu''' ngilezo mbandana ezitholakala amalini yephepha yeSewula Afrika. Imbandana lezi zihlala ehlathini begodu azibekwa hlangana nabantu ngombana ziyingozi angekhe umuntu azizingela lula.&lt;ref&gt;[https://gosafari.co.za/blog/animals-of-south-africa/the-big-five-safari-in-south-africa.html The Big Five - Go SAfari]&lt;/ref&gt; Amagama weembandana lezi yibhubezi, indlovu, umkhombe, ingwe nenyathi. Zingilezo mbandana ezaziwa bonyana ziyakghona ukuzingela.

=== Ibhubezi ===
Laziwa njenge kosi yehlathini, begodu, lona ngoko mhlobo liwela kibo katsu. Ibhubezi lilitshwayo lamandla nobukhosi ehlathini le Afrika.Amabhubezi  atholakala ehlathini le-Afrika begodu ngoko mlando e-India. Amabhubezi asikazi esikhathini esinengi ngiwo akhambako ayokuzingela afune inyamazana ezifana nama Zebra, impala, nokhunye.&lt;ref&gt;[https://gosafari.co.za/blog/animals-of-south-africa/the-big-five-safari-in-south-africa.html The Big Five - Go SAfari]&lt;/ref&gt; Akghona kubhodla ngamaphimbo wawo asabekako begodu ukubhodla kwawo kudlisa umlayezo othileko kwezinye imbandana. Amabhubezi ahlalal endaweni ezibizwa bona ma-''pride.''

=== Indlovu ===
[[Isimumathi:Elephant running.jpg|thumb|Iindlovu ezikhamba ngesiqhema ziyagijima]]
Indlovu isimunyisi esikulu ukuzidlula zoke iimunyisi. Zihlakaniphile begodu zinekghono lokukhumbula. Indlovu  ithatha pheze iminyaka emibili ukuthi ukuthi icede ukuzithwala beyithola umntwana ophilileko.zitholakakala endaweni ezele utjani nofana ehlathini le-Afrika ne-Asia. nokwahe inomboko osebenza njengepumulo nendebe yomlomo yangaphezulu. Isebenzisa umboko lo ukuphefumula nokubamaba izinto. Inamaphndo amabili ewasebenzisela ukugubha nofana ukwemba nokuzivikela. Iindlovu zikhamba  bezihlale ngeenqhema ezidoswa phambili ziindlovu ezisikazi ezidala ngokomnyaka. Ziyakghona ukusebenzisaa zikhombisa ukuba nizwa yokuzwela lokho kubonakala ngombana ziyazila lokha nazilahlekelwa mumuntu ezithandako. Ayikhohlwa nakhe wayenza into embi. Ukukhuluma zisebenzisa itjhada eliwenza ngomboko kanye nokunyakazisa umzimba.

=== Ingwe ===
[[Isimumathi:Leopardo (Panthera pardus) devorando un antílope, parque nacional Kruger, Sudáfrica, 2018-07-26, DD 07.jpg|thumb|Ingwe ikhwele nenyamazana yayo phezulu komuthi]]
Ingwe ngomunye yemihlobo yabokatsu abakhona, yona ingukatsu omkhulu ohlukaniseka ngokuthi unamabala emzimbeni. Ihlala emangweni begodu inekghono lokugijima ngombana iphila ngokuzingela igijime inyamazana ehlathini. Izingwe zitholakala enarhakazini ye-Asia ne- Afrika. Zikhombisa amandla, umusa, namandla wehlathini. Ingwe ikghona ukukhwela umuthi begodu eskhathi esinengi nayibamba inyamzana, ithatha iinyamanazana leyo iyoyibeka emthini phezulu. Zikghona ukuphila ehlathini, emangweni begodu neentabeni.&lt;ref&gt;[https://www.south-african-lodges.com/page/big-five/ African Safaris Big Five - Lions, Elephant, Rhinoceros, Buffalo, Leopard]&lt;/ref&gt; Zikghona ukuzingela kuhle lokha ilanga nalingakhanyiko begodu lisebenzisa amabala wayo ukuzifihla.

== Iinkomba ==</text>
      <sha1>ffcrw3gneo3qjerdlfvnmrno128xq7x</sha1>
    </revision>
    <revision>
      <id>5781</id>
      <parentid>5780</parentid>
      <timestamp>2025-09-22T17:25:41Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>5781</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3158" sha1="r06jxi0a285sagknecphf0k3yhg4bh2" xml:space="preserve">[[Isimumathi:Lion (Panthera leo) male 6y.jpg|thumb|Ibhubezi]]
'''Iimbandana ezihlanu ezikulu''' ngilezo mbandana ezitholakala amalini yephepha yeSewula Afrika. Imbandana lezi zihlala ehlathini begodu azibekwa hlangana nabantu ngombana ziyingozi angekhe umuntu azizingela lula.&lt;ref&gt;[https://gosafari.co.za/blog/animals-of-south-africa/the-big-five-safari-in-south-africa.html The Big Five - Go SAfari]&lt;/ref&gt; Amagama weembandana lezi yibhubezi, indlovu, umkhombe, ingwe nenyathi. Zingilezo mbandana ezaziwa bonyana ziyakghona ukuzingela.

=== Ibhubezi ===
Laziwa njenge kosi yehlathini, begodu, lona ngoko mhlobo liwela kibo katsu. Ibhubezi lilitshwayo lamandla nobukhosi ehlathini le Afrika.Amabhubezi  atholakala ehlathini le-Afrika begodu ngoko mlando e-India. Amabhubezi asikazi esikhathini esinengi ngiwo akhambako ayokuzingela afune inyamazana ezifana nama Zebra, impala, nokhunye.&lt;ref&gt;[https://gosafari.co.za/blog/animals-of-south-africa/the-big-five-safari-in-south-africa.html The Big Five - Go SAfari]&lt;/ref&gt; Akghona kubhodla ngamaphimbo wawo asabekako begodu ukubhodla kwawo kudlisa umlayezo othileko kwezinye imbandana. Amabhubezi ahlalal endaweni ezibizwa bona ma-''pride.''

=== Indlovu ===
[[Isimumathi:Elephant running.jpg|thumb|Iindlovu ezikhamba ngesiqhema ziyagijima]]
Indlovu isimunyisi esikulu ukuzidlula zoke iimunyisi. Zihlakaniphile begodu zinekghono lokukhumbula. Indlovu  ithatha pheze iminyaka emibili ukuthi ukuthi icede ukuzithwala beyithola umntwana ophilileko.zitholakakala endaweni ezele utjani nofana ehlathini le-Afrika ne-Asia. nokwahe inomboko osebenza njengepumulo nendebe yomlomo yangaphezulu. Isebenzisa umboko lo ukuphefumula nokubamaba izinto. Inamaphndo amabili ewasebenzisela ukugubha nofana ukwemba nokuzivikela. Iindlovu zikhamba  bezihlale ngeenqhema ezidoswa phambili ziindlovu ezisikazi ezidala ngokomnyaka. Ziyakghona ukusebenzisaa zikhombisa ukuba nizwa yokuzwela lokho kubonakala ngombana ziyazila lokha nazilahlekelwa mumuntu ezithandako. Ayikhohlwa nakhe wayenza into embi. Ukukhuluma zisebenzisa itjhada eliwenza ngomboko kanye nokunyakazisa umzimba.

=== Ingwe ===
[[Isimumathi:Leopardo (Panthera pardus) devorando un antílope, parque nacional Kruger, Sudáfrica, 2018-07-26, DD 07.jpg|thumb|Ingwe ikhwele nenyamazana yayo phezulu komuthi]]
Ingwe ngomunye yemihlobo yabokatsu abakhona, yona ingukatsu omkhulu ohlukaniseka ngokuthi unamabala emzimbeni. Ihlala emangweni begodu inekghono lokugijima ngombana iphila ngokuzingela igijime inyamazana ehlathini. Izingwe zitholakala enarhakazini ye-Asia ne- Afrika. Zikhombisa amandla, umusa, namandla wehlathini. Ingwe ikghona ukukhwela umuthi begodu eskhathi esinengi nayibamba inyamzana, ithatha iinyamanazana leyo iyoyibeka emthini phezulu. Zikghona ukuphila ehlathini, emangweni begodu neentabeni.&lt;ref&gt;[https://www.south-african-lodges.com/page/big-five/ African Safaris Big Five - Lions, Elephant, Rhinoceros, Buffalo, Leopard]&lt;/ref&gt; Zikghona ukuzingela kuhle lokha ilanga nalingakhanyiko begodu lisebenzisa amabala wayo ukuzifihla.

== Iinkomba ==
[[Category:ibhubezi]]
[[Category: indlovu]]
[[Category: ingwe]]
[[Category: inyathi]]
[[Category:Umkhombe]]</text>
      <sha1>r06jxi0a285sagknecphf0k3yhg4bh2</sha1>
    </revision>
    <revision>
      <id>5783</id>
      <parentid>5781</parentid>
      <timestamp>2025-09-23T17:20:57Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5783</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3771" sha1="m8w7eabo54gcq1naqvsvz6w4lhhn9js" xml:space="preserve">[[Isimumathi:Lion (Panthera leo) male 6y.jpg|thumb|Ibhubezi]]
'''Iimbandana ezihlanu ezikulu''' ngilezo mbandana ezitholakala amalini yephepha yeSewula Afrika. Imbandana lezi zihlala ehlathini begodu azibekwa hlangana nabantu ngombana ziyingozi angekhe umuntu azizingela lula.&lt;ref&gt;[https://gosafari.co.za/blog/animals-of-south-africa/the-big-five-safari-in-south-africa.html The Big Five - Go SAfari]&lt;/ref&gt; Amagama weembandana lezi yibhubezi, indlovu, umkhombe, ingwe nenyathi. Zingilezo mbandana ezaziwa bonyana ziyakghona ukuzingela.

=== Ibhubezi ===
Laziwa njenge kosi yehlathini, begodu, lona ngoko mhlobo liwela kibo katsu. Ibhubezi lilitshwayo lamandla nobukhosi ehlathini le Afrika.Amabhubezi  atholakala ehlathini le-Afrika begodu ngoko mlando e-India. Amabhubezi asikazi esikhathini esinengi ngiwo akhambako ayokuzingela afune inyamazana ezifana nama Zebra, impala, nokhunye.&lt;ref&gt;[https://gosafari.co.za/blog/animals-of-south-africa/the-big-five-safari-in-south-africa.html The Big Five - Go SAfari]&lt;/ref&gt; Akghona kubhodla ngamaphimbo wawo asabekako begodu ukubhodla kwawo kudlisa umlayezo othileko kwezinye imbandana. Amabhubezi ahlalal endaweni ezibizwa bona ma-''pride.''

=== Indlovu ===
[[Isimumathi:Elephant running.jpg|thumb|Iindlovu ezikhamba ngesiqhema ziyagijima]]
Indlovu isimunyisi esikulu ukuzidlula zoke iimunyisi. Zihlakaniphile begodu zinekghono lokukhumbula. Indlovu  ithatha pheze iminyaka emibili ukuthi ukuthi icede ukuzithwala beyithola umntwana ophilileko.zitholakakala endaweni ezele utjani nofana ehlathini le-Afrika ne-Asia. nokwahe inomboko osebenza njengepumulo nendebe yomlomo yangaphezulu. Isebenzisa umboko lo ukuphefumula nokubamaba izinto. Inamaphndo amabili ewasebenzisela ukugubha nofana ukwemba nokuzivikela. Iindlovu zikhamba  bezihlale ngeenqhema ezidoswa phambili ziindlovu ezisikazi ezidala ngokomnyaka. Ziyakghona ukusebenzisaa zikhombisa ukuba nizwa yokuzwela lokho kubonakala ngombana ziyazila lokha nazilahlekelwa mumuntu ezithandako. Ayikhohlwa nakhe wayenza into embi. Ukukhuluma zisebenzisa itjhada eliwenza ngomboko kanye nokunyakazisa umzimba.

=== Ingwe ===
[[Isimumathi:Leopardo (Panthera pardus) devorando un antílope, parque nacional Kruger, Sudáfrica, 2018-07-26, DD 07.jpg|thumb|Ingwe ikhwele nenyamazana yayo phezulu komuthi]]
Ingwe ngomunye yemihlobo yabokatsu abakhona, yona ingukatsu omkhulu ohlukaniseka ngokuthi unamabala emzimbeni. Ihlala emangweni begodu inekghono lokugijima ngombana iphila ngokuzingela igijime inyamazana ehlathini. Izingwe zitholakala enarhakazini ye-Asia ne- Afrika. Zikhombisa amandla, umusa, namandla wehlathini. Ingwe ikghona ukukhwela umuthi begodu eskhathi esinengi nayibamba inyamzana, ithatha iinyamanazana leyo iyoyibeka emthini phezulu. Zikghona ukuphila ehlathini, emangweni begodu neentabeni.&lt;ref&gt;[https://www.south-african-lodges.com/page/big-five/ African Safaris Big Five - Lions, Elephant, Rhinoceros, Buffalo, Leopard]&lt;/ref&gt; Zikghona ukuzingela kuhle lokha ilanga nalingakhanyiko begodu lisebenzisa amabala wayo ukuzifihla.

Inyathi
[[Isimumathi:029 African buffalo in the Serengeti National Park Photo by Giles Laurent.jpg|thumb|Inyathi]]
Inyathi ngenye  yeemmunyisi ezikulu e-Afrika. Inamandla begodu yikulu ngokomzimba akusilula bonyana umntu ayifunde bonyanan injani ngokwemvelo. Inamapphondo aqinileko begodu anamandla asebenza ukulwa nokuzivikela. Ayikhanyi ngokombala. Inkunzi zakhona zinesisindo ukudlula lezo ezisikazi. Zikahmba ngenqheema zomhlambi begodu ziyazwana. Zidla utjani begodu azikhoni ukuphila ngaphandle kwamanzi. Inyathi iyinyamazana ekulu engazingelwa mabhubezi ngombana ikghona ukuzilwela lokha nayizingelwako. 

== Iinkomba ==
[[Category:ibhubezi]]
[[Category: indlovu]]
[[Category: ingwe]]
[[Category: inyathi]]
[[Category:Umkhombe]]</text>
      <sha1>m8w7eabo54gcq1naqvsvz6w4lhhn9js</sha1>
    </revision>
    <revision>
      <id>5784</id>
      <parentid>5783</parentid>
      <timestamp>2025-09-23T17:32:55Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5784</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4649" sha1="a58efo6lz39g3w43c61825u3kiany7j" xml:space="preserve">[[Isimumathi:Lion (Panthera leo) male 6y.jpg|thumb|Ibhubezi]]
'''Iimbandana ezihlanu ezikulu''' ngilezo mbandana ezitholakala amalini yephepha yeSewula Afrika. Imbandana lezi zihlala ehlathini begodu azibekwa hlangana nabantu ngombana ziyingozi angekhe umuntu azizingela lula.&lt;ref&gt;[https://gosafari.co.za/blog/animals-of-south-africa/the-big-five-safari-in-south-africa.html The Big Five - Go SAfari]&lt;/ref&gt; Amagama weembandana lezi yibhubezi, indlovu, umkhombe, ingwe nenyathi. Zingilezo mbandana ezaziwa bonyana ziyakghona ukuzingela.

=== Ibhubezi ===
Laziwa njenge kosi yehlathini, begodu, lona ngoko mhlobo liwela kibo katsu. Ibhubezi lilitshwayo lamandla nobukhosi ehlathini le Afrika.Amabhubezi  atholakala ehlathini le-Afrika begodu ngoko mlando e-India. Amabhubezi asikazi esikhathini esinengi ngiwo akhambako ayokuzingela afune inyamazana ezifana nama Zebra, impala, nokhunye.&lt;ref&gt;[https://gosafari.co.za/blog/animals-of-south-africa/the-big-five-safari-in-south-africa.html The Big Five - Go SAfari]&lt;/ref&gt; Akghona kubhodla ngamaphimbo wawo asabekako begodu ukubhodla kwawo kudlisa umlayezo othileko kwezinye imbandana. Amabhubezi ahlalal endaweni ezibizwa bona ma-''pride.''

=== Indlovu ===
[[Isimumathi:Elephant running.jpg|thumb|Iindlovu ezikhamba ngesiqhema ziyagijima]]
Indlovu isimunyisi esikulu ukuzidlula zoke iimunyisi. Zihlakaniphile begodu zinekghono lokukhumbula. Indlovu  ithatha pheze iminyaka emibili ukuthi ukuthi icede ukuzithwala beyithola umntwana ophilileko.zitholakakala endaweni ezele utjani nofana ehlathini le-Afrika ne-Asia. nokwahe inomboko osebenza njengepumulo nendebe yomlomo yangaphezulu. Isebenzisa umboko lo ukuphefumula nokubamaba izinto. Inamaphndo amabili ewasebenzisela ukugubha nofana ukwemba nokuzivikela. Iindlovu zikhamba  bezihlale ngeenqhema ezidoswa phambili ziindlovu ezisikazi ezidala ngokomnyaka. Ziyakghona ukusebenzisaa zikhombisa ukuba nizwa yokuzwela lokho kubonakala ngombana ziyazila lokha nazilahlekelwa mumuntu ezithandako. Ayikhohlwa nakhe wayenza into embi. Ukukhuluma zisebenzisa itjhada eliwenza ngomboko kanye nokunyakazisa umzimba.

=== Ingwe ===
[[Isimumathi:Leopardo (Panthera pardus) devorando un antílope, parque nacional Kruger, Sudáfrica, 2018-07-26, DD 07.jpg|thumb|Ingwe ikhwele nenyamazana yayo phezulu komuthi]]
Ingwe ngomunye yemihlobo yabokatsu abakhona, yona ingukatsu omkhulu ohlukaniseka ngokuthi unamabala emzimbeni. Ihlala emangweni begodu inekghono lokugijima ngombana iphila ngokuzingela igijime inyamazana ehlathini. Izingwe zitholakala enarhakazini ye-Asia ne- Afrika. Zikhombisa amandla, umusa, namandla wehlathini. Ingwe ikghona ukukhwela umuthi begodu eskhathi esinengi nayibamba inyamzana, ithatha iinyamanazana leyo iyoyibeka emthini phezulu. Zikghona ukuphila ehlathini, emangweni begodu neentabeni.&lt;ref&gt;[https://www.south-african-lodges.com/page/big-five/ African Safaris Big Five - Lions, Elephant, Rhinoceros, Buffalo, Leopard]&lt;/ref&gt; Zikghona ukuzingela kuhle lokha ilanga nalingakhanyiko begodu lisebenzisa amabala wayo ukuzifihla.

=== Inyathi ===
[[Isimumathi:029 African buffalo in the Serengeti National Park Photo by Giles Laurent.jpg|thumb|Inyathi]]
Inyathi ngenye  yeemmunyisi ezikulu e-Afrika. Inamandla begodu yikulu ngokomzimba akusilula bonyana umntu ayifunde bonyanan injani ngokwemvelo. Inamapphondo aqinileko begodu anamandla asebenza ukulwa nokuzivikela. Ayikhanyi ngokombala. Inkunzi zakhona zinesisindo ukudlula lezo ezisikazi. Zikahmba ngenqheema zomhlambi begodu ziyazwana. Zidla utjani begodu azikhoni ukuphila ngaphandle kwamanzi. Inyathi iyinyamazana ekulu engazingelwa mabhubezi ngombana ikghona ukuzilwela lokha nayizingelwako. 

Umkhombe 
[[Isimumathi:Rhinoceros in South Africa adjusted.jpg|thumb|Umkhombe]]
Umkhombe usimunyisi esikulu esineempondo ebusweni ngaphezulu kwepumulo. iphondo lesibandana lesi lenziwe nge- Keratin ekuyiphrotheyini eyenza iinhluthu zabantu kanye namazipho. Amaphondo aqakathekile ekuthengiseni kwabantu abanzima. Imikhombe ngokwemvelo idla utjani, imikhombe enzima idla amabhlari wemithi. Itholakala ehlathini le Afrika nele-Asia. Imikhombe uzinlwana ezisengozini yokutjhabalala ngombana bantu bayibulala ngokuthi bayisike amaphondo wazo ziphila. Lokho bakwenza ngombana amaphondo wazo kwenziwa imitjhoga ngawo enearheni ye-Asia. Imikhombe ilala ama- iri abunane ngelanga, begodu ingalala ijamile nofana ibhambalele phasi. Zosebe zisa idaka ukwehlisa ukutjhisa emzimbeni begodu nokuzivikela isikhumba. Imikhombe mikhulu ngokomzimba kodwana iyakghona ukugijima msinya. 

== Iinkomba ==
[[Category:ibhubezi]]
[[Category: indlovu]]
[[Category: ingwe]]
[[Category: inyathi]]
[[Category:Umkhombe]]</text>
      <sha1>a58efo6lz39g3w43c61825u3kiany7j</sha1>
    </revision>
    <revision>
      <id>5785</id>
      <parentid>5784</parentid>
      <timestamp>2025-09-23T17:39:25Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5785</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5121" sha1="298uunhf52x4jslkciedgszj9pnrq73" xml:space="preserve">[[Isimumathi:Lion (Panthera leo) male 6y.jpg|thumb|Ibhubezi]]
'''Iimbandana ezihlanu ezikulu''' ngilezo mbandana ezitholakala amalini yephepha yeSewula Afrika. Imbandana lezi zihlala ehlathini begodu azibekwa hlangana nabantu ngombana ziyingozi angekhe umuntu azizingela lula.&lt;ref&gt;[https://gosafari.co.za/blog/animals-of-south-africa/the-big-five-safari-in-south-africa.html The Big Five - Go SAfari]&lt;/ref&gt; Amagama weembandana lezi yibhubezi, indlovu, umkhombe, ingwe nenyathi. Zingilezo mbandana ezaziwa bonyana ziyakghona ukuzingela.

=== Ibhubezi ===
Laziwa njenge kosi yehlathini, begodu, lona ngoko mhlobo liwela kibo katsu. Ibhubezi lilitshwayo lamandla nobukhosi ehlathini le Afrika.Amabhubezi  atholakala ehlathini le-Afrika begodu ngoko mlando e-India. Amabhubezi asikazi esikhathini esinengi ngiwo akhambako ayokuzingela afune inyamazana ezifana nama Zebra, impala, nokhunye.&lt;ref&gt;[https://gosafari.co.za/blog/animals-of-south-africa/the-big-five-safari-in-south-africa.html The Big Five - Go SAfari]&lt;/ref&gt; Akghona kubhodla ngamaphimbo wawo asabekako begodu ukubhodla kwawo kudlisa umlayezo othileko kwezinye imbandana. Amabhubezi ahlalal endaweni ezibizwa bona ma-''pride.''

=== Indlovu ===
[[Isimumathi:Elephant running.jpg|thumb|Iindlovu ezikhamba ngesiqhema ziyagijima]]
Indlovu isimunyisi esikulu ukuzidlula zoke iimunyisi. Zihlakaniphile begodu zinekghono lokukhumbula. Indlovu  ithatha pheze iminyaka emibili ukuthi ukuthi icede ukuzithwala beyithola umntwana ophilileko.zitholakakala endaweni ezele utjani nofana ehlathini le-Afrika ne-Asia. nokwahe inomboko osebenza njengepumulo nendebe yomlomo yangaphezulu. Isebenzisa umboko lo ukuphefumula nokubamaba izinto. Inamaphndo amabili ewasebenzisela ukugubha nofana ukwemba nokuzivikela. Iindlovu zikhamba  bezihlale ngeenqhema ezidoswa phambili ziindlovu ezisikazi ezidala ngokomnyaka. Ziyakghona ukusebenzisaa zikhombisa ukuba nizwa yokuzwela lokho kubonakala ngombana ziyazila lokha nazilahlekelwa mumuntu ezithandako. Ayikhohlwa nakhe wayenza into embi. Ukukhuluma zisebenzisa itjhada eliwenza ngomboko kanye nokunyakazisa umzimba.

=== Ingwe ===
[[Isimumathi:Leopardo (Panthera pardus) devorando un antílope, parque nacional Kruger, Sudáfrica, 2018-07-26, DD 07.jpg|thumb|Ingwe ikhwele nenyamazana yayo phezulu komuthi]]
Ingwe ngomunye yemihlobo yabokatsu abakhona, yona ingukatsu omkhulu ohlukaniseka ngokuthi unamabala emzimbeni. Ihlala emangweni begodu inekghono lokugijima ngombana iphila ngokuzingela igijime inyamazana ehlathini. Izingwe zitholakala enarhakazini ye-Asia ne- Afrika. Zikhombisa amandla, umusa, namandla wehlathini. Ingwe ikghona ukukhwela umuthi begodu eskhathi esinengi nayibamba inyamzana, ithatha iinyamanazana leyo iyoyibeka emthini phezulu. Zikghona ukuphila ehlathini, emangweni begodu neentabeni.&lt;ref&gt;[https://www.south-african-lodges.com/page/big-five/ African Safaris Big Five - Lions, Elephant, Rhinoceros, Buffalo, Leopard]&lt;/ref&gt; Zikghona ukuzingela kuhle lokha ilanga nalingakhanyiko begodu lisebenzisa amabala wayo ukuzifihla.

=== Inyathi ===
[[Isimumathi:029 African buffalo in the Serengeti National Park Photo by Giles Laurent.jpg|thumb|Inyathi]]
Inyathi [[isimunyisi]] esikulu halngana nezinye e-Afrika. Inamandla begodu yikulu ngokomzimba akusilula bonyana umuntu ayifunde bonyana injani ngokwemvelo. Inamaphondo aqinileko begodu anamandla asebenza ukulwa nokuzivikela. Ayikhanyi ngokombala. Inkunzi zakhona zinesisindo ukudlula lezo ezisikazi.&lt;ref&gt;Perera, B.M.A.O., 2011. Reproductive cycles of buffalo. ''Animal reproduction science'', ''124''(3-4), pp.194-199.&lt;/ref&gt; Zikhamba ngenqheema zomhlambi begodu ziyazwana. Zidla utjani begodu azikhoni ukuphila ngaphandle kwamanzi. Inyathi iyinyamazana ekulu engazingelwa mabhubezi ngombana ikghona ukuzilwela lokha nayizingelwako. 

=== Umkhombe ===
[[Isimumathi:Rhinoceros in South Africa adjusted.jpg|thumb|Umkhombe]]
Umkhombe usimunyisi esikulu esineempondo ebusweni ngaphezulu kwepumulo. iphondo lesibandana lesi lenziwe nge- Keratin ekuyiphrotheyini eyenza iinhluthu zabantu kanye namazipho. Amaphondo aqakathekile ekuthengiseni kwabantu abanzima. Imikhombe ngokwemvelo idla utjani, imikhombe enzima idla amabhlari wemithi. Itholakala ehlathini le Afrika nele-Asia. Imikhombe uzinlwana ezisengozini yokutjhabalala ngombana bantu bayibulala ngokuthi bayisike amaphondo wazo ziphila.&lt;ref&gt;[https://biglife.org/what-we-do/wildlife-protection/rhino-protection?msclkid=8c37490902e617c53a6d21dbd88f4d05&amp;utm_source=bing&amp;utm_medium=cpc&amp;utm_campaign=BLF%20-%20%20What%20We%20Do%2FInformation%20(International)&amp;utm_term=rhinoceros%20endangered&amp;utm_content=Endangered%20Rhinos Big Life Foundation - Rhino Protection]&lt;/ref&gt; Lokho bakwenza ngombana amaphondo wazo kwenziwa imitjhoga ngawo enearheni ye-Asia. Imikhombe ilala ama- iri abunane ngelanga, begodu ingalala ijamile nofana ibhambalele phasi. Zosebe zisa idaka ukwehlisa ukutjhisa emzimbeni begodu nokuzivikela isikhumba. Imikhombe mikhulu ngokomzimba kodwana iyakghona ukugijima msinya. 

== Iinkomba ==
[[Category:ibhubezi]]
[[Category: indlovu]]
[[Category: ingwe]]
[[Category: inyathi]]
[[Category:Umkhombe]]</text>
      <sha1>298uunhf52x4jslkciedgszj9pnrq73</sha1>
    </revision>
    <revision>
      <id>5786</id>
      <parentid>5785</parentid>
      <timestamp>2025-09-23T17:40:54Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5786</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5221" sha1="90kfm9gcqp9yl9yd808t3ugms5gpux5" xml:space="preserve">[[Isimumathi:Lion (Panthera leo) male 6y.jpg|thumb|Ibhubezi]]
'''Iimbandana ezihlanu ezikulu''' ngilezo mbandana ezitholakala amalini yephepha yeSewula Afrika. Imbandana lezi zihlala ehlathini begodu azibekwa hlangana nabantu ngombana ziyingozi angekhe umuntu azizingela lula.&lt;ref&gt;[https://gosafari.co.za/blog/animals-of-south-africa/the-big-five-safari-in-south-africa.html The Big Five - Go SAfari]&lt;/ref&gt; Amagama weembandana lezi yibhubezi, indlovu, umkhombe, ingwe nenyathi. Zingilezo mbandana ezaziwa bonyana ziyakghona ukuzingela. Imbandana lezi zoke zizimunyusi begodu ezmbili zidla inyama kwaphela, kuthi ezithathu zidle utjani.

=== Ibhubezi ===
Laziwa njenge kosi yehlathini, begodu, lona ngoko mhlobo liwela kibo katsu. Ibhubezi lilitshwayo lamandla nobukhosi ehlathini le Afrika.Amabhubezi  atholakala ehlathini le-Afrika begodu ngoko mlando e-India. Amabhubezi asikazi esikhathini esinengi ngiwo akhambako ayokuzingela afune inyamazana ezifana nama Zebra, impala, nokhunye.&lt;ref&gt;[https://gosafari.co.za/blog/animals-of-south-africa/the-big-five-safari-in-south-africa.html The Big Five - Go SAfari]&lt;/ref&gt; Akghona kubhodla ngamaphimbo wawo asabekako begodu ukubhodla kwawo kudlisa umlayezo othileko kwezinye imbandana. Amabhubezi ahlalal endaweni ezibizwa bona ma-''pride.''

=== Indlovu ===
[[Isimumathi:Elephant running.jpg|thumb|Iindlovu ezikhamba ngesiqhema ziyagijima]]
Indlovu isimunyisi esikulu ukuzidlula zoke iimunyisi. Zihlakaniphile begodu zinekghono lokukhumbula. Indlovu  ithatha pheze iminyaka emibili ukuthi ukuthi icede ukuzithwala beyithola umntwana ophilileko.zitholakakala endaweni ezele utjani nofana ehlathini le-Afrika ne-Asia. nokwahe inomboko osebenza njengepumulo nendebe yomlomo yangaphezulu. Isebenzisa umboko lo ukuphefumula nokubamaba izinto. Inamaphndo amabili ewasebenzisela ukugubha nofana ukwemba nokuzivikela. Iindlovu zikhamba  bezihlale ngeenqhema ezidoswa phambili ziindlovu ezisikazi ezidala ngokomnyaka. Ziyakghona ukusebenzisaa zikhombisa ukuba nizwa yokuzwela lokho kubonakala ngombana ziyazila lokha nazilahlekelwa mumuntu ezithandako. Ayikhohlwa nakhe wayenza into embi. Ukukhuluma zisebenzisa itjhada eliwenza ngomboko kanye nokunyakazisa umzimba.

=== Ingwe ===
[[Isimumathi:Leopardo (Panthera pardus) devorando un antílope, parque nacional Kruger, Sudáfrica, 2018-07-26, DD 07.jpg|thumb|Ingwe ikhwele nenyamazana yayo phezulu komuthi]]
Ingwe ngomunye yemihlobo yabokatsu abakhona, yona ingukatsu omkhulu ohlukaniseka ngokuthi unamabala emzimbeni. Ihlala emangweni begodu inekghono lokugijima ngombana iphila ngokuzingela igijime inyamazana ehlathini. Izingwe zitholakala enarhakazini ye-Asia ne- Afrika. Zikhombisa amandla, umusa, namandla wehlathini. Ingwe ikghona ukukhwela umuthi begodu eskhathi esinengi nayibamba inyamzana, ithatha iinyamanazana leyo iyoyibeka emthini phezulu. Zikghona ukuphila ehlathini, emangweni begodu neentabeni.&lt;ref&gt;[https://www.south-african-lodges.com/page/big-five/ African Safaris Big Five - Lions, Elephant, Rhinoceros, Buffalo, Leopard]&lt;/ref&gt; Zikghona ukuzingela kuhle lokha ilanga nalingakhanyiko begodu lisebenzisa amabala wayo ukuzifihla.

=== Inyathi ===
[[Isimumathi:029 African buffalo in the Serengeti National Park Photo by Giles Laurent.jpg|thumb|Inyathi]]
Inyathi [[isimunyisi]] esikulu halngana nezinye e-Afrika. Inamandla begodu yikulu ngokomzimba akusilula bonyana umuntu ayifunde bonyana injani ngokwemvelo. Inamaphondo aqinileko begodu anamandla asebenza ukulwa nokuzivikela. Ayikhanyi ngokombala. Inkunzi zakhona zinesisindo ukudlula lezo ezisikazi.&lt;ref&gt;Perera, B.M.A.O., 2011. Reproductive cycles of buffalo. ''Animal reproduction science'', ''124''(3-4), pp.194-199.&lt;/ref&gt; Zikhamba ngenqheema zomhlambi begodu ziyazwana. Zidla utjani begodu azikhoni ukuphila ngaphandle kwamanzi. Inyathi iyinyamazana ekulu engazingelwa mabhubezi ngombana ikghona ukuzilwela lokha nayizingelwako. 

=== Umkhombe ===
[[Isimumathi:Rhinoceros in South Africa adjusted.jpg|thumb|Umkhombe]]
Umkhombe usimunyisi esikulu esineempondo ebusweni ngaphezulu kwepumulo. iphondo lesibandana lesi lenziwe nge- Keratin ekuyiphrotheyini eyenza iinhluthu zabantu kanye namazipho. Amaphondo aqakathekile ekuthengiseni kwabantu abanzima. Imikhombe ngokwemvelo idla utjani, imikhombe enzima idla amabhlari wemithi. Itholakala ehlathini le Afrika nele-Asia. Imikhombe uzinlwana ezisengozini yokutjhabalala ngombana bantu bayibulala ngokuthi bayisike amaphondo wazo ziphila.&lt;ref&gt;[https://biglife.org/what-we-do/wildlife-protection/rhino-protection?msclkid=8c37490902e617c53a6d21dbd88f4d05&amp;utm_source=bing&amp;utm_medium=cpc&amp;utm_campaign=BLF%20-%20%20What%20We%20Do%2FInformation%20(International)&amp;utm_term=rhinoceros%20endangered&amp;utm_content=Endangered%20Rhinos Big Life Foundation - Rhino Protection]&lt;/ref&gt; Lokho bakwenza ngombana amaphondo wazo kwenziwa imitjhoga ngawo enearheni ye-Asia. Imikhombe ilala ama- iri abunane ngelanga, begodu ingalala ijamile nofana ibhambalele phasi. Zosebe zisa idaka ukwehlisa ukutjhisa emzimbeni begodu nokuzivikela isikhumba. Imikhombe mikhulu ngokomzimba kodwana iyakghona ukugijima msinya. 

== Iinkomba ==
[[Category:ibhubezi]]
[[Category: indlovu]]
[[Category: ingwe]]
[[Category: inyathi]]
[[Category:Umkhombe]]</text>
      <sha1>90kfm9gcqp9yl9yd808t3ugms5gpux5</sha1>
    </revision>
    <revision>
      <id>5803</id>
      <parentid>5786</parentid>
      <timestamp>2025-09-29T09:56:07Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5803</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5221" sha1="jgaisl0n7qbpub8tqh2k014o61zp1ea" xml:space="preserve">[[Isimumathi:Lion (Panthera leo) male 6y.jpg|thumb|Ibhubezi]]
'''Iimbandana ezihlanu ezikulu''' ngilezo mbandana ezitholakala amalini yephepha yeSewula Afrika. Imbandana lezi zihlala ehlathini begodu azibekwa hlangana nabantu ngombana ziyingozi angekhe umuntu azizingela lula.&lt;ref&gt;[https://gosafari.co.za/blog/animals-of-south-africa/the-big-five-safari-in-south-africa.html The Big Five - Go SAfari]&lt;/ref&gt; Amagama weembandana lezi yibhubezi, indlovu, umkhombe, ingwe nenyathi. Zingilezo mbandana ezaziwa bonyana ziyakghona ukuzingela. Imbandana lezi zoke zizimunyusi begodu ezmbili zidla inyama kwaphela, kuthi ezithathu zidle utjani.

=== Ibhubezi ===
Laziwa njenge kosi yehlathini, begodu, lona ngoko mhlobo liwela kibo katsu. Ibhubezi lilitshwayo lamandla nobukhosi ehlathini le Afrika.Amabhubezi  atholakala ehlathini le-Afrika begodu ngoko mlando e-India. Amabhubezi asikazi esikhathini esinengi ngiwo akhambako ayokuzingela afune inyamazana ezifana nama Zebra, impala, nokhunye.&lt;ref&gt;[https://gosafari.co.za/blog/animals-of-south-africa/the-big-five-safari-in-south-africa.html The Big Five - Go SAfari]&lt;/ref&gt; Akghona kubhodla ngamaphimbo wawo asabekako begodu ukubhodla kwawo kudlisa umlayezo othileko kwezinye imbandana. Amabhubezi ahlalal endaweni ezibizwa bona ma-''pride.''

=== Indlovu ===
[[Isimumathi:Elephant running.jpg|thumb|Iindlovu ezikhamba ngesiqhema ziyagijima]]
Indlovu isimunyisi esikulu ukuzidlula zoke iimunyisi. Zihlakaniphile begodu zinekghono lokukhumbula. Indlovu  ithatha pheze iminyaka emibili ukuthi ukuthi icede ukuzithwala beyithola umntwana ophilileko.zitholakakala endaweni ezele utjani nofana ehlathini le-Afrika ne-Asia. nokwahe inomboko osebenza njengepumulo nendebe yomlomo yangaphezulu. Isebenzisa umboko lo ukuphefumula nokubamaba izinto. Inamaphndo amabili ewasebenzisela ukugubha nofana ukwemba nokuzivikela. Iindlovu zikhamba  bezihlale ngeenqhema ezidoswa phambili ziindlovu ezisikazi ezidala ngokomnyaka. Ziyakghona ukusebenzisaa zikhombisa ukuba nizwa yokuzwela lokho kubonakala ngombana ziyazila lokha nazilahlekelwa mumuntu ezithandako. Ayikhohlwa nakhe wayenza into embi. Ukukhuluma zisebenzisa itjhada eliwenza ngomboko kanye nokunyakazisa umzimba.

=== Ingwe ===
[[Isimumathi:Leopardo (Panthera pardus) devorando un antílope, parque nacional Kruger, Sudáfrica, 2018-07-26, DD 07.jpg|thumb|Ingwe ikhwele nenyamazana yayo phezulu komuthi]]
Ingwe ngomunye yemihlobo yabokatsu abakhona, yona ingukatsu omkhulu ohlukaniseka ngokuthi unamabala emzimbeni. Ihlala emangweni begodu inekghono lokugijima ngombana iphila ngokuzingela igijime inyamazana ehlathini. Izingwe zitholakala enarhakazini ye-Asia ne- Afrika. Zikhombisa amandla, umusa, namandla wehlathini. Ingwe ikghona ukukhwela umuthi begodu eskhathi esinengi nayibamba inyamzana, ithatha iinyamanazana leyo iyoyibeka emthini phezulu. Zikghona ukuphila ehlathini, emangweni begodu neentabeni.&lt;ref&gt;[https://www.south-african-lodges.com/page/big-five/ African Safaris Big Five - Lions, Elephant, Rhinoceros, Buffalo, Leopard]&lt;/ref&gt; Zikghona ukuzingela kuhle lokha ilanga nalingakhanyiko begodu lisebenzisa amabala wayo ukuzifihla.

=== Inyathi ===
[[Isimumathi:029 African buffalo in the Serengeti National Park Photo by Giles Laurent.jpg|thumb|Inyathi]]
Inyathi [[isimunyisi]] esikulu hlangana nezinye e-Afrika. Inamandla begodu yikulu ngokomzimba akusilula bonyana umuntu ayifunde bonyana injani ngokwemvelo. Inamaphondo aqinileko begodu anamandla asebenza ukulwa nokuzivikela. Ayikhanyi ngokombala. Inkunzi zakhona zinesisindo ukudlula lezo ezisikazi.&lt;ref&gt;Perera, B.M.A.O., 2011. Reproductive cycles of buffalo. ''Animal reproduction science'', ''124''(3-4), pp.194-199.&lt;/ref&gt; Zikhamba ngenqheema zomhlambi begodu ziyazwana. Zidla utjani begodu azikhoni ukuphila ngaphandle kwamanzi. Inyathi iyinyamazana ekulu engazingelwa mabhubezi ngombana ikghona ukuzilwela lokha nayizingelwako. 

=== Umkhombe ===
[[Isimumathi:Rhinoceros in South Africa adjusted.jpg|thumb|Umkhombe]]
Umkhombe usimunyisi esikulu esineempondo ebusweni ngaphezulu kwepumulo. iphondo lesibandana lesi lenziwe nge- Keratin ekuyiphrotheyini eyenza iinhluthu zabantu kanye namazipho. Amaphondo aqakathekile ekuthengiseni kwabantu abanzima. Imikhombe ngokwemvelo idla utjani, imikhombe enzima idla amabhlari wemithi. Itholakala ehlathini le Afrika nele-Asia. Imikhombe uzinlwana ezisengozini yokutjhabalala ngombana bantu bayibulala ngokuthi bayisike amaphondo wazo ziphila.&lt;ref&gt;[https://biglife.org/what-we-do/wildlife-protection/rhino-protection?msclkid=8c37490902e617c53a6d21dbd88f4d05&amp;utm_source=bing&amp;utm_medium=cpc&amp;utm_campaign=BLF%20-%20%20What%20We%20Do%2FInformation%20(International)&amp;utm_term=rhinoceros%20endangered&amp;utm_content=Endangered%20Rhinos Big Life Foundation - Rhino Protection]&lt;/ref&gt; Lokho bakwenza ngombana amaphondo wazo kwenziwa imitjhoga ngawo enearheni ye-Asia. Imikhombe ilala ama- iri abunane ngelanga, begodu ingalala ijamile nofana ibhambalele phasi. Zosebe zisa idaka ukwehlisa ukutjhisa emzimbeni begodu nokuzivikela isikhumba. Imikhombe mikhulu ngokomzimba kodwana iyakghona ukugijima msinya. 

== Iinkomba ==
[[Category:ibhubezi]]
[[Category: indlovu]]
[[Category: ingwe]]
[[Category: inyathi]]
[[Category:Umkhombe]]</text>
      <sha1>jgaisl0n7qbpub8tqh2k014o61zp1ea</sha1>
    </revision>
  </page>
  <page>
    <title>Iindlela ezinengi zokuhlakanipha</title>
    <ns>0</ns>
    <id>152</id>
    <revision>
      <id>738</id>
      <timestamp>2024-08-03T12:02:16Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Iindlela''' ezinengi zokuhlanipha kuyithiyori ka Howard Gardner lapho ahlathulula khona bona ukuhlanipha kwabantu ngekhe kwaba ngendlela eyodwa kodwana kungendlela ezinengi ezihlukileko.  &quot;</comment>
      <origin>738</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="191" sha1="tdktqy27g3ltta3jzaj30nbcfmunypn" xml:space="preserve">'''Iindlela''' ezinengi zokuhlanipha kuyithiyori ka Howard Gardner lapho ahlathulula khona bona ukuhlanipha kwabantu ngekhe kwaba ngendlela eyodwa kodwana kungendlela ezinengi ezihlukileko.

</text>
      <sha1>tdktqy27g3ltta3jzaj30nbcfmunypn</sha1>
    </revision>
    <revision>
      <id>739</id>
      <parentid>738</parentid>
      <timestamp>2024-08-03T12:05:35Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>739</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="455" sha1="0qwbb0uc2iyfcfyublta345xrifzpv5" xml:space="preserve">'''Iindlela''' ezinengi zokuhlanipha kuyithiyori ka Howard Gardner lapho ahlathulula khona bona ukuhlanipha kwabantu ngekhe kwaba ngendlela eyodwa kodwana kungendlela ezinengi ezihlukileko&lt;ref&gt;Derakhshan, A. and Faribi, M., 2015. Multiple intelligences: Language learning and teaching. ''International Journal of English Linguistics'', ''5''(4), p.63&lt;/ref&gt;. Iindlela lezi kuvezwa bona zibunane lokha nazipheleleko. 

== Iindlela ezibunane zokuhlanipha ==
</text>
      <sha1>0qwbb0uc2iyfcfyublta345xrifzpv5</sha1>
    </revision>
    <revision>
      <id>740</id>
      <parentid>739</parentid>
      <timestamp>2024-08-03T12:24:16Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>740</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1398" sha1="1hlg1awnzjpogx82rug1hzs0bdq968v" xml:space="preserve">'''Iindlela''' ezinengi zokuhlanipha kuyithiyori ka Howard Gardner lapho ahlathulula khona bona ukuhlanipha kwabantu ngekhe kwaba ngendlela eyodwa kodwana kungendlela ezinengi ezihlukileko&lt;ref&gt;Derakhshan, A. and Faribi, M., 2015. Multiple intelligences: Language learning and teaching. ''International Journal of English Linguistics'', ''5''(4), p.63&lt;/ref&gt;. Iindlela lezi kuvezwa bona zibunane lokha nazipheleleko. 

== Iindlela ezibunane zokuhlanipha ==

=== 1. Ukuhlakanipha ngokweenomboro ===
Umuntu lokha nakahlakaniphe ngokweenomboro kutjho bona uba nekghono elikhulu lokwenza iimbalo. Umuntu loyo ukghona ukuba iimbalo ezibudisi ezibhalela abantu abanengi, kodwana yena akhone ukuzenza ngendlela elula. Umuntu ohlakaniphe ngokweembalo ukghona ukurarulula imiraro ephathelenen nokubalal ngendlela etjengisa obukhulu ubuhlakani. 

=== 2. Ukuhlakanipha ngokwelimi/ngokwamalimi ===
Umuntu ohlakaniphe ngokwelimi kumumuntu onekghono elikhulu lokukhuluma amalumi nanyan ilimi elithileko. umunntu lo uthi nakakhuluma amalimi nanyana atlole into ethileko ukhombisa ilwazi lalelo limi.

=== 3.Ukuhlakanipha ngokugwala ===
Ukuhlakanipah ngokuugwala Kukulokha umuntu akghona ukugwala imigwalo emihle nofana iinthombe. Okhunye godu abantu abahlakiniphe ngokugwala bakghona ukuthula imilayezo ngokungabhali amagama  kodwana ngokugwala iinthombe ezithula umlayezo, bakhona nokuveza imizwa yabo ngokugwala.
</text>
      <sha1>1hlg1awnzjpogx82rug1hzs0bdq968v</sha1>
    </revision>
    <revision>
      <id>741</id>
      <parentid>740</parentid>
      <timestamp>2024-08-03T12:33:00Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>741</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1861" sha1="7z2ajxj4efagame5wq87snbukygdlzc" xml:space="preserve">'''Iindlela''' ezinengi zokuhlanipha kuyithiyori ka Howard Gardner lapho ahlathulula khona bona ukuhlanipha kwabantu ngekhe kwaba ngendlela eyodwa kodwana kungendlela ezinengi ezihlukileko&lt;ref&gt;Derakhshan, A. and Faribi, M., 2015. Multiple intelligences: Language learning and teaching. ''International Journal of English Linguistics'', ''5''(4), p.63&lt;/ref&gt;. Iindlela lezi kuvezwa bona zibunane lokha nazipheleleko. 

== Iindlela ezibunane zokuhlanipha ==

=== 1. Ukuhlakanipha ngokweenomboro ===
Umuntu lokha nakahlakaniphe ngokweenomboro kutjho bona uba nekghono elikhulu lokwenza iimbalo. Umuntu loyo ukghona ukuba iimbalo ezibudisi ezibhalela abantu abanengi, kodwana yena akhone ukuzenza ngendlela elula. Umuntu ohlakaniphe ngokweembalo ukghona ukurarulula imiraro ephathelenen nokubalal ngendlela etjengisa obukhulu ubuhlakani. 

=== 2. Ukuhlakanipha ngokwelimi/ngokwamalimi ===
Umuntu ohlakaniphe ngokwelimi kumumuntu onekghono elikhulu lokukhuluma amalumi nanyan ilimi elithileko. umunntu lo uthi nakakhuluma amalimi nanyana atlole into ethileko ukhombisa ilwazi lalelo limi.

=== 3.Ukuhlakanipha ngokugwala ===
Ukuhlakanipah ngokuugwala Kukulokha umuntu akghona ukugwala imigwalo emihle nofana iinthombe. Okhunye godu abantu abahlakiniphe ngokugwala bakghona ukuthula imilayezo ngokungabhali amagama  kodwana ngokugwala iinthombe ezithula umlayezo, bakhona nokuveza imizwa yabo ngokugwala.

=== 4. Ukuhlanipha ngokwabantu ===
Umumtu lokha nakahlaniphe ngokwabantu kukuklokha umuntu abanekghono elukhulu lokusebenza nabantu ngaphandle kokuthi kube nerarano phakathi kwabo. Umuntu onalokhu kuhlanipha ukghona  ukuhlanisa abantu begodu ukghona ukuzwisisa ubunjalo babantu aphilisana nabo.

=== 5. Ukuhlakanipha ngokuzwisisa imvelo ===
Abantu abahlakaniphe ngokuzwisisa imvelo kungilabo bantu abakghona ukufunda ngokusebenzisa imvelo nofana izinto zemvelo.
</text>
      <sha1>7z2ajxj4efagame5wq87snbukygdlzc</sha1>
    </revision>
    <revision>
      <id>742</id>
      <parentid>741</parentid>
      <timestamp>2024-08-03T12:44:57Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>742</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2480" sha1="7b11l2b70mqcfrj6x8yd98cnsy4njgn" xml:space="preserve">'''Iindlela''' ezinengi zokuhlanipha kuyithiyori ka Howard Gardner lapho ahlathulula khona bona ukuhlanipha kwabantu ngekhe kwaba ngendlela eyodwa kodwana kungendlela ezinengi ezihlukileko&lt;ref&gt;Derakhshan, A. and Faribi, M., 2015. Multiple intelligences: Language learning and teaching. ''International Journal of English Linguistics'', ''5''(4), p.63&lt;/ref&gt;. Iindlela lezi kuvezwa bona zibunane lokha nazipheleleko. 

== Iindlela ezibunane zokuhlanipha ==

=== 1. Ukuhlakanipha ngokweenomboro ===
Umuntu lokha nakahlakaniphe ngokweenomboro kutjho bona uba nekghono elikhulu lokwenza iimbalo. Umuntu loyo ukghona ukuba iimbalo ezibudisi ezibhalela abantu abanengi, kodwana yena akhone ukuzenza ngendlela elula. Umuntu ohlakaniphe ngokweembalo ukghona ukurarulula imiraro ephathelenen nokubalal ngendlela etjengisa obukhulu ubuhlakani. 

=== 2. Ukuhlakanipha ngokwelimi/ngokwamalimi ===
Umuntu ohlakaniphe ngokwelimi kumumuntu onekghono elikhulu lokukhuluma amalumi nanyan ilimi elithileko. umunntu lo uthi nakakhuluma amalimi nanyana atlole into ethileko ukhombisa ilwazi lalelo limi.

=== 3.Ukuhlakanipha ngokugwala ===
Ukuhlakanipah ngokuugwala Kukulokha umuntu akghona ukugwala imigwalo emihle nofana iinthombe. Okhunye godu abantu abahlakiniphe ngokugwala bakghona ukuthula imilayezo ngokungabhali amagama  kodwana ngokugwala iinthombe ezithula umlayezo, bakhona nokuveza imizwa yabo ngokugwala.

=== 4. Ukuhlanipha ngokwabantu ===
Umumtu lokha nakahlaniphe ngokwabantu kukuklokha umuntu abanekghono elukhulu lokusebenza nabantu ngaphandle kokuthi kube nerarano phakathi kwabo. Umuntu onalokhu kuhlanipha ukghona  ukuhlanisa abantu begodu ukghona ukuzwisisa ubunjalo babantu aphilisana nabo.

=== 5. Ukuhlakanipha ngokuzwisisa imvelo ===
Abantu abahlakaniphe ngokuzwisisa imvelo kungilabo bantu abakghona ukufunda ngokusebenzisa imvelo nofana izinto zemvelo.

=== 6.Ukuhlakanipha ngokusebenzisa umzimba ===
Umuntu ohlakaniphe ngokusenzisa umzimba uba nekghona elikhuli lokwenza izinto ezifana nokudansa ukugida nokhunye okuphathelene nokunyakazisa umzimba.

=== 7. Ukuhlakanipha ngokukhona ukuvuma ===
Umuntu ohlakaniphe ngokukhona ukuvuma kumuntu onekghono lokwenza umvumo omnandi ongathabelwa babantu abanengi.

=== 8. Ukuhlanipha ngokwakho ===
Umuntu ohlakaniphe ngokwakhe kumumuntu ohlakaniphe ngokuthi ukghona ukusebenza begodu nokwenza izinto ezihle ngokwakhe ngaphandle kokusebenzisana nabanye abantu. Esikhathini esinengi lomhlobo wabantu awukhoni ukusebenza nesiqhema.
</text>
      <sha1>7b11l2b70mqcfrj6x8yd98cnsy4njgn</sha1>
    </revision>
    <revision>
      <id>743</id>
      <parentid>742</parentid>
      <timestamp>2024-08-04T15:10:16Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>743</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2490" sha1="68wdq5ts9cdr4z19qoa06ddn3n4du14" xml:space="preserve">'''Iindlela''' ezinengi zoku[[hlakanipha]] kuyithiyori ka Howard Gardner lapho ahlathulula khona bona ukuhlanipha kwabantu ngekhe kwaba ngendlela eyodwa kodwana kungendlela ezinengi ezihlukileko&lt;ref&gt;Derakhshan, A. and Faribi, M., 2015. Multiple intelligences: Language learning and teaching. ''International Journal of English Linguistics'', ''5''(4), p.63&lt;/ref&gt;. Iindlela lezi kuvezwa bona zibunane lokha nazipheleleko. 

== Iindlela ezibunane zokuhlanipha ==

=== 1. Ukuhlakanipha ngokweenomboro ===
Umuntu lokha nakahlakaniphe ngokweenomboro kutjho bona uba nekghono elikhulu lokwenza iimbalo. Umuntu loyo ukghona ukuba iimbalo ezibudisi ezibhalela abantu abanengi, kodwana yena akhone ukuzenza ngendlela elula. Umuntu ohlakaniphe ngokweembalo ukghona ukurarulula imiraro ephathelenen nokubalal ngendlela etjengisa obukhulu ubuhlakani. 

=== 2. Ukuhlakanipha ngokwelimi/ngokwamalimi ===
Umuntu ohlakaniphe ngokwelimi kumumuntu onekghono elikhulu lokukhuluma amalumi nanyan ilimi elithileko. umunntu lo uthi nakakhuluma amalimi nanyana atlole into ethileko ukhombisa [[ilwazi]] lalelo limi.

=== 3.Ukuhlakanipha ngokugwala ===
Ukuhlakanipha ngokuugwala Kukulokha umuntu akghona ukugwala imigwalo emihle nofana iinthombe. Okhunye godu abantu abahlakiniphe ngokugwala bakghona ukuthula imilayezo ngokungabhali amagama  kodwana ngokugwala iinthombe ezithula umlayezo, bakhona nokuveza imizwa yabo ngokugwala.

=== 4. Ukuhlanipha ngokwabantu ===
Umumtu lokha nakahlaniphe ngokwabantu kukuklokha umuntu abanekghono elukhulu lokusebenza nabantu ngaphandle kokuthi kube nerarano phakathi kwabo. Umuntu onalokhu kuhlanipha ukghona  ukuhlanisa abantu begodu ukghona ukuzwisisa ubunjalo babantu aphilisana nabo.

=== 5. Ukuhlakanipha ngokuzwisisa imvelo ===
Abantu abahlakaniphe ngokuzwisisa imvelo kungilabo bantu abakghona ukufunda ngokusebenzisa imvelo nofana izinto zemvelo.

=== 6.Ukuhlakanipha ngokusebenzisa umzimba ===
Umuntu ohlakaniphe ngokusenzisa umzimba uba nekghona elikhuli lokwenza izinto ezifana nokudansa ukugida nokhunye okuphathelene nokunyakazisa umzimba.

=== 7. Ukuhlakanipha ngokukhona ukuvuma ===
Umuntu ohlakaniphe ngokukhona ukuvuma kumuntu onekghono lokwenza umvumo omnandi ongathabelwa babantu abanengi.

=== 8. Ukuhlanipha ngokwakho ===
Umuntu ohlakaniphe ngokwakhe kumumuntu ohlakaniphe ngokuthi ukghona ukusebenza begodu nokwenza izinto ezihle ngokwakhe ngaphandle kokusebenzisana nabanye abantu. Esikhathini esinengi lomhlobo wabantu awukhoni ukusebenza nesiqhema.
</text>
      <sha1>68wdq5ts9cdr4z19qoa06ddn3n4du14</sha1>
    </revision>
    <revision>
      <id>744</id>
      <parentid>743</parentid>
      <timestamp>2024-08-12T17:10:38Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>744</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2567" sha1="70766j9ykq0ur3zmanvvd1aac5hgmmq" xml:space="preserve">'''Iindlela''' ezinengi zoku[[hlakanipha]] kuyithiyori ka Howard Gardner lapho ahlathulula khona bona ukuhlanipha kwabantu ngekhe kwaba ngendlela eyodwa kodwana kungendlela ezinengi ezihlukileko&lt;ref&gt;Derakhshan, A. and Faribi, M., 2015. Multiple intelligences: Language learning and teaching. ''International Journal of English Linguistics'', ''5''(4), p.63&lt;/ref&gt;. Iindlela lezi kuvezwa bona zibunane lokha nazipheleleko. 

== Iindlela ezibunane zokuhlanipha ==

=== 1. Ukuhlakanipha ngokweenomboro ===
Umuntu lokha nakahlakaniphe ngokweenomboro kutjho bona uba nekghono elikhulu lokwenza iimbalo. Umuntu loyo ukghona ukuba iimbalo ezibudisi ezibhalela abantu abanengi, kodwana yena akhone ukuzenza ngendlela elula. Umuntu ohlakaniphe ngokweembalo ukghona ukurarulula imiraro ephathelenen nokubalal ngendlela etjengisa obukhulu ubuhlakani. 

=== 2. Ukuhlakanipha ngokwelimi/ngokwamalimi ===
Umuntu ohlakaniphe ngokwelimi kumumuntu onekghono elikhulu lokukhuluma amalumi nanyan ilimi elithileko. umunntu lo uthi nakakhuluma amalimi nanyana atlole into ethileko ukhombisa [[ilwazi]] lalelo limi.

=== 3.Ukuhlakanipha ngokugwala ===
[[Isimumathi:Ukuhlakanipha ngokugwala.jpg|thumb|ukuhlakanipha ngokugwala]]
Ukuhlakanipha ngokuugwala Kukulokha umuntu akghona ukugwala imigwalo emihle nofana iinthombe. Okhunye godu abantu abahlakiniphe ngokugwala bakghona ukuthula imilayezo ngokungabhali amagama  kodwana ngokugwala iinthombe ezithula umlayezo, bakhona nokuveza imizwa yabo ngokugwala. 

=== 4. Ukuhlanipha ngokwabantu ===
Umumtu lokha nakahlaniphe ngokwabantu kukuklokha umuntu abanekghono elukhulu lokusebenza nabantu ngaphandle kokuthi kube nerarano phakathi kwabo. Umuntu onalokhu kuhlanipha ukghona  ukuhlanisa abantu begodu ukghona ukuzwisisa ubunjalo babantu aphilisana nabo. 

=== 5. Ukuhlakanipha ngokuzwisisa imvelo ===
Abantu abahlakaniphe ngokuzwisisa imvelo kungilabo bantu abakghona ukufunda ngokusebenzisa imvelo nofana izinto zemvelo.

=== 6.Ukuhlakanipha ngokusebenzisa umzimba ===
Umuntu ohlakaniphe ngokusenzisa umzimba uba nekghona elikhuli lokwenza izinto ezifana nokudansa ukugida nokhunye okuphathelene nokunyakazisa umzimba.

=== 7. Ukuhlakanipha ngokukhona ukuvuma ===
Umuntu ohlakaniphe ngokukhona ukuvuma kumuntu onekghono lokwenza umvumo omnandi ongathabelwa babantu abanengi.

=== 8. Ukuhlanipha ngokwakho ===
Umuntu ohlakaniphe ngokwakhe kumumuntu ohlakaniphe ngokuthi ukghona ukusebenza begodu nokwenza izinto ezihle ngokwakhe ngaphandle kokusebenzisana nabanye abantu. Esikhathini esinengi lomhlobo wabantu awukhoni ukusebenza nesiqhema.
</text>
      <sha1>70766j9ykq0ur3zmanvvd1aac5hgmmq</sha1>
    </revision>
    <revision>
      <id>745</id>
      <parentid>744</parentid>
      <timestamp>2024-08-12T17:17:02Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>745</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2664" sha1="kzbkeb63ba2yj0dvne664e43fu0weax" xml:space="preserve">'''Iindlela''' ezinengi zoku[[hlakanipha]] kuyithiyori ka Howard Gardner lapho ahlathulula khona bona ukuhlanipha kwabantu ngekhe kwaba ngendlela eyodwa kodwana kungendlela ezinengi ezihlukileko&lt;ref&gt;Derakhshan, A. and Faribi, M., 2015. Multiple intelligences: Language learning and teaching. ''International Journal of English Linguistics'', ''5''(4), p.63&lt;/ref&gt;. Iindlela lezi kuvezwa bona zibunane lokha nazipheleleko. 

== Iindlela ezibunane zokuhlanipha ==

=== 1. Ukuhlakanipha ngokweenomboro ===
Umuntu lokha nakahlakaniphe ngokweenomboro kutjho bona uba nekghono elikhulu lokwenza iimbalo. Umuntu loyo ukghona ukuba iimbalo ezibudisi ezibhalela abantu abanengi, kodwana yena akhone ukuzenza ngendlela elula. Umuntu ohlakaniphe ngokweembalo ukghona ukurarulula imiraro ephathelenen nokubalal ngendlela etjengisa obukhulu ubuhlakani. 

=== 2. Ukuhlakanipha ngokwelimi/ngokwamalimi ===
Umuntu ohlakaniphe ngokwelimi kumumuntu onekghono elikhulu lokukhuluma amalumi nanyan ilimi elithileko. umunntu lo uthi nakakhuluma amalimi nanyana atlole into ethileko ukhombisa [[ilwazi]] lalelo limi.

=== 3.Ukuhlakanipha ngokugwala ===
[[Isimumathi:Ukuhlakanipha ngokugwala.jpg|thumb|ukuhlakanipha ngokugwala]]
Ukuhlakanipha ngokuugwala Kukulokha umuntu akghona ukugwala imigwalo emihle nofana iinthombe. Okhunye godu abantu abahlakiniphe ngokugwala bakghona ukuthula imilayezo ngokungabhali amagama  kodwana ngokugwala iinthombe ezithula umlayezo, bakhona nokuveza imizwa yabo ngokugwala. 

=== 4. Ukuhlanipha ngokwabantu ===
Umumtu lokha nakahlaniphe ngokwabantu kukuklokha umuntu abanekghono elukhulu lokusebenza nabantu ngaphandle kokuthi kube nerarano phakathi kwabo. Umuntu onalokhu kuhlanipha ukghona  ukuhlanisa abantu begodu ukghona ukuzwisisa ubunjalo babantu aphilisana nabo. 

=== 5. Ukuhlakanipha ngokuzwisisa imvelo ===
Abantu abahlakaniphe ngokuzwisisa imvelo kungilabo bantu abakghona ukufunda ngokusebenzisa imvelo nofana izinto zemvelo.

=== 6.Ukuhlakanipha ngokusebenzisa umzimba ===
Umuntu ohlakaniphe ngokusenzisa umzimba uba nekghona elikhuli lokwenza izinto ezifana nokudansa ukugida nokhunye okuphathelene nokunyakazisa umzimba&lt;ref&gt;Nolen, J.L., 2003. MULTIPLE INTELLIGENCES IN THE CLASSROOM. ''Education'', ''124''(1).&lt;/ref&gt;.

=== 7. Ukuhlakanipha ngokukhona ukuvuma ===
Umuntu ohlakaniphe ngokukhona ukuvuma kumuntu onekghono lokwenza umvumo omnandi ongathabelwa babantu abanengi.

=== 8. Ukuhlanipha ngokwakho ===
Umuntu ohlakaniphe ngokwakhe kumumuntu ohlakaniphe ngokuthi ukghona ukusebenza begodu nokwenza izinto ezihle ngokwakhe ngaphandle kokusebenzisana nabanye abantu. Esikhathini esinengi lomhlobo wabantu awukhoni ukusebenza nesiqhema.
</text>
      <sha1>kzbkeb63ba2yj0dvne664e43fu0weax</sha1>
    </revision>
    <revision>
      <id>746</id>
      <parentid>745</parentid>
      <timestamp>2024-10-14T13:46:45Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>8 revisions imported</comment>
      <origin>745</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2664" sha1="kzbkeb63ba2yj0dvne664e43fu0weax" xml:space="preserve">'''Iindlela''' ezinengi zoku[[hlakanipha]] kuyithiyori ka Howard Gardner lapho ahlathulula khona bona ukuhlanipha kwabantu ngekhe kwaba ngendlela eyodwa kodwana kungendlela ezinengi ezihlukileko&lt;ref&gt;Derakhshan, A. and Faribi, M., 2015. Multiple intelligences: Language learning and teaching. ''International Journal of English Linguistics'', ''5''(4), p.63&lt;/ref&gt;. Iindlela lezi kuvezwa bona zibunane lokha nazipheleleko. 

== Iindlela ezibunane zokuhlanipha ==

=== 1. Ukuhlakanipha ngokweenomboro ===
Umuntu lokha nakahlakaniphe ngokweenomboro kutjho bona uba nekghono elikhulu lokwenza iimbalo. Umuntu loyo ukghona ukuba iimbalo ezibudisi ezibhalela abantu abanengi, kodwana yena akhone ukuzenza ngendlela elula. Umuntu ohlakaniphe ngokweembalo ukghona ukurarulula imiraro ephathelenen nokubalal ngendlela etjengisa obukhulu ubuhlakani. 

=== 2. Ukuhlakanipha ngokwelimi/ngokwamalimi ===
Umuntu ohlakaniphe ngokwelimi kumumuntu onekghono elikhulu lokukhuluma amalumi nanyan ilimi elithileko. umunntu lo uthi nakakhuluma amalimi nanyana atlole into ethileko ukhombisa [[ilwazi]] lalelo limi.

=== 3.Ukuhlakanipha ngokugwala ===
[[Isimumathi:Ukuhlakanipha ngokugwala.jpg|thumb|ukuhlakanipha ngokugwala]]
Ukuhlakanipha ngokuugwala Kukulokha umuntu akghona ukugwala imigwalo emihle nofana iinthombe. Okhunye godu abantu abahlakiniphe ngokugwala bakghona ukuthula imilayezo ngokungabhali amagama  kodwana ngokugwala iinthombe ezithula umlayezo, bakhona nokuveza imizwa yabo ngokugwala. 

=== 4. Ukuhlanipha ngokwabantu ===
Umumtu lokha nakahlaniphe ngokwabantu kukuklokha umuntu abanekghono elukhulu lokusebenza nabantu ngaphandle kokuthi kube nerarano phakathi kwabo. Umuntu onalokhu kuhlanipha ukghona  ukuhlanisa abantu begodu ukghona ukuzwisisa ubunjalo babantu aphilisana nabo. 

=== 5. Ukuhlakanipha ngokuzwisisa imvelo ===
Abantu abahlakaniphe ngokuzwisisa imvelo kungilabo bantu abakghona ukufunda ngokusebenzisa imvelo nofana izinto zemvelo.

=== 6.Ukuhlakanipha ngokusebenzisa umzimba ===
Umuntu ohlakaniphe ngokusenzisa umzimba uba nekghona elikhuli lokwenza izinto ezifana nokudansa ukugida nokhunye okuphathelene nokunyakazisa umzimba&lt;ref&gt;Nolen, J.L., 2003. MULTIPLE INTELLIGENCES IN THE CLASSROOM. ''Education'', ''124''(1).&lt;/ref&gt;.

=== 7. Ukuhlakanipha ngokukhona ukuvuma ===
Umuntu ohlakaniphe ngokukhona ukuvuma kumuntu onekghono lokwenza umvumo omnandi ongathabelwa babantu abanengi.

=== 8. Ukuhlanipha ngokwakho ===
Umuntu ohlakaniphe ngokwakhe kumumuntu ohlakaniphe ngokuthi ukghona ukusebenza begodu nokwenza izinto ezihle ngokwakhe ngaphandle kokusebenzisana nabanye abantu. Esikhathini esinengi lomhlobo wabantu awukhoni ukusebenza nesiqhema.
</text>
      <sha1>kzbkeb63ba2yj0dvne664e43fu0weax</sha1>
    </revision>
    <revision>
      <id>2157</id>
      <parentid>746</parentid>
      <timestamp>2024-11-27T05:38:12Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>+ Iinkomba</comment>
      <origin>2157</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2690" sha1="ir7w6fbbfudpvbo0gcwuhug5x03331d" xml:space="preserve">'''Iindlela''' ezinengi zoku[[hlakanipha]] kuyithiyori ka Howard Gardner lapho ahlathulula khona bona ukuhlanipha kwabantu ngekhe kwaba ngendlela eyodwa kodwana kungendlela ezinengi ezihlukileko&lt;ref&gt;Derakhshan, A. and Faribi, M., 2015. Multiple intelligences: Language learning and teaching. ''International Journal of English Linguistics'', ''5''(4), p.63&lt;/ref&gt;. Iindlela lezi kuvezwa bona zibunane lokha nazipheleleko. 

== Iindlela ezibunane zokuhlanipha ==
=== 1. Ukuhlakanipha ngokweenomboro ===
Umuntu lokha nakahlakaniphe ngokweenomboro kutjho bona uba nekghono elikhulu lokwenza iimbalo. Umuntu loyo ukghona ukuba iimbalo ezibudisi ezibhalela abantu abanengi, kodwana yena akhone ukuzenza ngendlela elula. Umuntu ohlakaniphe ngokweembalo ukghona ukurarulula imiraro ephathelenen nokubalal ngendlela etjengisa obukhulu ubuhlakani. 

=== 2. Ukuhlakanipha ngokwelimi/ngokwamalimi ===
Umuntu ohlakaniphe ngokwelimi kumumuntu onekghono elikhulu lokukhuluma amalumi nanyan ilimi elithileko. umunntu lo uthi nakakhuluma amalimi nanyana atlole into ethileko ukhombisa [[ilwazi]] lalelo limi.

=== 3.Ukuhlakanipha ngokugwala ===
[[Isimumathi:Ukuhlakanipha ngokugwala.jpg|thumb|ukuhlakanipha ngokugwala]]
Ukuhlakanipha ngokuugwala Kukulokha umuntu akghona ukugwala imigwalo emihle nofana iinthombe. Okhunye godu abantu abahlakiniphe ngokugwala bakghona ukuthula imilayezo ngokungabhali amagama  kodwana ngokugwala iinthombe ezithula umlayezo, bakhona nokuveza imizwa yabo ngokugwala. 

=== 4. Ukuhlanipha ngokwabantu ===
Umumtu lokha nakahlaniphe ngokwabantu kukuklokha umuntu abanekghono elukhulu lokusebenza nabantu ngaphandle kokuthi kube nerarano phakathi kwabo. Umuntu onalokhu kuhlanipha ukghona  ukuhlanisa abantu begodu ukghona ukuzwisisa ubunjalo babantu aphilisana nabo. 

=== 5. Ukuhlakanipha ngokuzwisisa imvelo ===
Abantu abahlakaniphe ngokuzwisisa imvelo kungilabo bantu abakghona ukufunda ngokusebenzisa imvelo nofana izinto zemvelo.

=== 6.Ukuhlakanipha ngokusebenzisa umzimba ===
Umuntu ohlakaniphe ngokusenzisa umzimba uba nekghona elikhuli lokwenza izinto ezifana nokudansa ukugida nokhunye okuphathelene nokunyakazisa umzimba&lt;ref&gt;Nolen, J.L., 2003. MULTIPLE INTELLIGENCES IN THE CLASSROOM. ''Education'', ''124''(1).&lt;/ref&gt;.

=== 7. Ukuhlakanipha ngokukhona ukuvuma ===
Umuntu ohlakaniphe ngokukhona ukuvuma kumuntu onekghono lokwenza umvumo omnandi ongathabelwa babantu abanengi.

=== 8. Ukuhlanipha ngokwakho ===
Umuntu ohlakaniphe ngokwakhe kumumuntu ohlakaniphe ngokuthi ukghona ukusebenza begodu nokwenza izinto ezihle ngokwakhe ngaphandle kokusebenzisana nabanye abantu. Esikhathini esinengi lomhlobo wabantu awukhoni ukusebenza nesiqhema.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>ir7w6fbbfudpvbo0gcwuhug5x03331d</sha1>
    </revision>
    <revision>
      <id>2282</id>
      <parentid>2157</parentid>
      <timestamp>2024-12-17T03:01:13Z</timestamp>
      <contributor>
        <ip>88.238.40.230</ip>
      </contributor>
      <origin>2282</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2724" sha1="o6zajzi0xtbwbo5pibtg3poqiesdeyc" xml:space="preserve">'''Iindlela''' ezinengi zoku[[hlakanipha]] kuyithiyori ka Howard Gardner lapho ahlathulula khona bona ukuhlanipha kwabantu ngekhe kwaba ngendlela eyodwa kodwana kungendlela ezinengi ezihlukileko&lt;ref&gt;Derakhshan, A. and Faribi, M., 2015. Multiple intelligences: Language learning and teaching. ''International Journal of English Linguistics'', ''5''(4), p.63&lt;/ref&gt;. Iindlela lezi kuvezwa bona zibunane lokha nazipheleleko. 

== Iindlela ezibunane zokuhlanipha ==
=== 1. Ukuhlakanipha ngokweenomboro ===
Umuntu lokha nakahlakaniphe ngokweenomboro kutjho bona uba nekghono elikhulu lokwenza iimbalo. Umuntu loyo ukghona ukuba iimbalo ezibudisi ezibhalela abantu abanengi, kodwana yena akhone ukuzenza ngendlela elula. Umuntu ohlakaniphe ngokweembalo ukghona ukurarulula imiraro ephathelenen nokubalal ngendlela etjengisa obukhulu ubuhlakani. 

=== 2. Ukuhlakanipha ngokwelimi/ngokwamalimi ===
Umuntu ohlakaniphe ngokwelimi kumumuntu onekghono elikhulu lokukhuluma amalumi nanyan ilimi elithileko. umunntu lo uthi nakakhuluma amalimi nanyana atlole into ethileko ukhombisa [[ilwazi]] lalelo limi.

=== 3.Ukuhlakanipha ngokugwala ===
[[Isimumathi:Ukuhlakanipha ngokugwala.jpg|thumb|ukuhlakanipha ngokugwala]]
Ukuhlakanipha ngokuugwala Kukulokha umuntu akghona ukugwala imigwalo emihle nofana iinthombe. Okhunye godu abantu abahlakiniphe ngokugwala bakghona ukuthula imilayezo ngokungabhali amagama  kodwana ngokugwala iinthombe ezithula umlayezo, bakhona nokuveza imizwa yabo ngokugwala. 

=== 4. Ukuhlanipha ngokwabantu ===
Umumtu lokha nakahlaniphe ngokwabantu kukuklokha umuntu abanekghono elukhulu lokusebenza nabantu ngaphandle kokuthi kube nerarano phakathi kwabo. Umuntu onalokhu kuhlanipha ukghona  ukuhlanisa abantu begodu ukghona ukuzwisisa ubunjalo babantu aphilisana nabo. 

=== 5. Ukuhlakanipha ngokuzwisisa imvelo ===
Abantu abahlakaniphe ngokuzwisisa imvelo kungilabo bantu abakghona ukufunda ngokusebenzisa imvelo nofana izinto zemvelo.

=== 6.Ukuhlakanipha ngokusebenzisa umzimba ===
Umuntu ohlakaniphe ngokusenzisa umzimba uba nekghona elikhuli lokwenza izinto ezifana nokudansa ukugida nokhunye okuphathelene nokunyakazisa umzimba&lt;ref&gt;Nolen, J.L., 2003. MULTIPLE INTELLIGENCES IN THE CLASSROOM. ''Education'', ''124''(1). [https://www.neufakt.de/ neufakt]&lt;/ref&gt;.

=== 7. Ukuhlakanipha ngokukhona ukuvuma ===
Umuntu ohlakaniphe ngokukhona ukuvuma kumuntu onekghono lokwenza umvumo omnandi ongathabelwa babantu abanengi.

=== 8. Ukuhlanipha ngokwakho ===
Umuntu ohlakaniphe ngokwakhe kumumuntu ohlakaniphe ngokuthi ukghona ukusebenza begodu nokwenza izinto ezihle ngokwakhe ngaphandle kokusebenzisana nabanye abantu. Esikhathini esinengi lomhlobo wabantu awukhoni ukusebenza nesiqhema.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>o6zajzi0xtbwbo5pibtg3poqiesdeyc</sha1>
    </revision>
    <revision>
      <id>2344</id>
      <parentid>2282</parentid>
      <timestamp>2025-01-10T13:40:28Z</timestamp>
      <contributor>
        <ip>88.238.43.137</ip>
      </contributor>
      <origin>2344</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2726" sha1="fmdh32nuof9n3dmslpeneiiejtkvafj" xml:space="preserve">'''Iindlela''' ezinengi zoku[[hlakanipha]] kuyithiyori ka Howard Gardner lapho ahlathulula khona bona ukuhlanipha kwabantu ngekhe kwaba ngendlela eyodwa kodwana kungendlela ezinengi ezihlukileko&lt;ref&gt;Derakhshan, A. and Faribi, M., 2015. Multiple intelligences: Language learning and teaching. ''International Journal of English Linguistics'', ''5''(4), p.63&lt;/ref&gt;. Iindlela lezi kuvezwa bona zibunane lokha nazipheleleko. 

== Iindlela ezibunane zokuhlanipha ==
=== 1. Ukuhlakanipha ngokweenomboro ===
Umuntu lokha nakahlakaniphe ngokweenomboro kutjho bona uba nekghono elikhulu lokwenza iimbalo. Umuntu loyo ukghona ukuba iimbalo ezibudisi ezibhalela abantu abanengi, kodwana yena akhone ukuzenza ngendlela elula. Umuntu ohlakaniphe ngokweembalo ukghona ukurarulula imiraro ephathelenen nokubalal ngendlela etjengisa obukhulu ubuhlakani. 

=== 2. Ukuhlakanipha ngokwelimi/ngokwamalimi ===
Umuntu ohlakaniphe ngokwelimi kumumuntu onekghono elikhulu lokukhuluma amalumi nanyan ilimi elithileko. umunntu lo uthi nakakhuluma amalimi nanyana atlole into ethileko ukhombisa [[ilwazi]] lalelo limi.

=== 3.Ukuhlakanipha ngokugwala ===
[[Isimumathi:Ukuhlakanipha ngokugwala.jpg|thumb|ukuhlakanipha ngokugwala]]
Ukuhlakanipha ngokuugwala Kukulokha umuntu akghona ukugwala imigwalo emihle nofana iinthombe. Okhunye godu abantu abahlakiniphe ngokugwala bakghona ukuthula imilayezo ngokungabhali amagama  kodwana ngokugwala iinthombe ezithula umlayezo, bakhona nokuveza imizwa yabo ngokugwala. 

=== 4. Ukuhlanipha ngokwabantu ===
Umumtu lokha nakahlaniphe ngokwabantu kukuklokha umuntu abanekghono elukhulu lokusebenza nabantu ngaphandle kokuthi kube nerarano phakathi kwabo. Umuntu onalokhu kuhlanipha ukghona  ukuhlanisa abantu begodu ukghona ukuzwisisa ubunjalo babantu aphilisana nabo. 

=== 5. Ukuhlakanipha ngokuzwisisa imvelo ===
Abantu abahlakaniphe ngokuzwisisa imvelo kungilabo bantu abakghona ukufunda ngokusebenzisa imvelo nofana izinto zemvelo.

=== 6.Ukuhlakanipha ngokusebenzisa umzimba ===
Umuntu ohlakaniphe ngokusenzisa umzimba uba nekghona elikhuli lokwenza izinto ezifana nokudansa ukugida nokhunye okuphathelene nokunyakazisa umzimba&lt;ref&gt;Nolen, J.L., 2003. MULTIPLE INTELLIGENCES IN THE CLASSROOM. ''Education'', ''124''(1). [https://www.traumlex.de/ traumlex]&lt;/ref&gt;.

=== 7. Ukuhlakanipha ngokukhona ukuvuma ===
Umuntu ohlakaniphe ngokukhona ukuvuma kumuntu onekghono lokwenza umvumo omnandi ongathabelwa babantu abanengi.

=== 8. Ukuhlanipha ngokwakho ===
Umuntu ohlakaniphe ngokwakhe kumumuntu ohlakaniphe ngokuthi ukghona ukusebenza begodu nokwenza izinto ezihle ngokwakhe ngaphandle kokusebenzisana nabanye abantu. Esikhathini esinengi lomhlobo wabantu awukhoni ukusebenza nesiqhema.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>fmdh32nuof9n3dmslpeneiiejtkvafj</sha1>
    </revision>
    <revision>
      <id>5070</id>
      <parentid>2344</parentid>
      <timestamp>2025-08-08T08:09:19Z</timestamp>
      <contributor>
        <username>Ayanda TS Mahlangu</username>
        <id>834</id>
      </contributor>
      <comment>grammar</comment>
      <origin>5070</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2720" sha1="2eg8trcprhgnppzh992plnlkkb6oqnw" xml:space="preserve">'''Iindlela''' ezinengi zoku[[hlakanipha]] kuyitiyori ka Howard Gardner lapho ahlathulula khona bona ukuhlanipha kwabantu ngekhe kwaba ngendlela eyodwa kodwana kungeendlela ezinengi ezihlukileko&lt;ref&gt;Derakhshan, A. and Faribi, M., 2015. Multiple intelligences: Language learning and teaching. ''International Journal of English Linguistics'', ''5''(4), p.63&lt;/ref&gt;. Iindlela lezi kuvezwa bona zibunane nazipheleleko. 

== Iindlela ezibunane zokuhlanipha ==
=== 1. Ukuhlakanipha ngokweenomboro ===
Umuntu lokha nakahlakaniphe ngokweenomboro kutjho bona uba nekghono elikhulu lokwenza iimbalo. Umuntu loyo ukghona ukuba iimbalo ezibudisi ezibhalela abantu abanengi, kodwana yena akhone ukuzenza ngendlela elula. Umuntu ohlakaniphe ngokweembalo ukghona ukurarulula imiraro ephathelenen nokubalal ngendlela etjengisa obukhulu ubuhlakani. 

=== 2. Ukuhlakanipha ngokwelimi/ngokwamalimi ===
Umuntu ohlakaniphe ngokwelimi kumumuntu onekghono elikhulu lokukhuluma amalumi nanyan ilimi elithileko. umunntu lo uthi nakakhuluma amalimi nanyana atlole into ethileko ukhombisa [[ilwazi]] lalelo limi.

=== 3.Ukuhlakanipha ngokugwala ===
[[Isimumathi:Ukuhlakanipha ngokugwala.jpg|thumb|ukuhlakanipha ngokugwala]]
Ukuhlakanipha ngokuugwala Kukulokha umuntu akghona ukugwala imigwalo emihle nofana iinthombe. Okhunye godu abantu abahlakiniphe ngokugwala bakghona ukuthula imilayezo ngokungabhali amagama  kodwana ngokugwala iinthombe ezithula umlayezo, bakhona nokuveza imizwa yabo ngokugwala. 

=== 4. Ukuhlanipha ngokwabantu ===
Umumtu lokha nakahlaniphe ngokwabantu kukuklokha umuntu abanekghono elukhulu lokusebenza nabantu ngaphandle kokuthi kube nerarano phakathi kwabo. Umuntu onalokhu kuhlanipha ukghona  ukuhlanisa abantu begodu ukghona ukuzwisisa ubunjalo babantu aphilisana nabo. 

=== 5. Ukuhlakanipha ngokuzwisisa imvelo ===
Abantu abahlakaniphe ngokuzwisisa imvelo kungilabo bantu abakghona ukufunda ngokusebenzisa imvelo nofana izinto zemvelo.

=== 6.Ukuhlakanipha ngokusebenzisa umzimba ===
Umuntu ohlakaniphe ngokusenzisa umzimba uba nekghona elikhuli lokwenza izinto ezifana nokudansa ukugida nokhunye okuphathelene nokunyakazisa umzimba&lt;ref&gt;Nolen, J.L., 2003. MULTIPLE INTELLIGENCES IN THE CLASSROOM. ''Education'', ''124''(1). [https://www.traumlex.de/ traumlex]&lt;/ref&gt;.

=== 7. Ukuhlakanipha ngokukhona ukuvuma ===
Umuntu ohlakaniphe ngokukhona ukuvuma kumuntu onekghono lokwenza umvumo omnandi ongathabelwa babantu abanengi.

=== 8. Ukuhlanipha ngokwakho ===
Umuntu ohlakaniphe ngokwakhe kumumuntu ohlakaniphe ngokuthi ukghona ukusebenza begodu nokwenza izinto ezihle ngokwakhe ngaphandle kokusebenzisana nabanye abantu. Esikhathini esinengi lomhlobo wabantu awukhoni ukusebenza nesiqhema.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>2eg8trcprhgnppzh992plnlkkb6oqnw</sha1>
    </revision>
    <revision>
      <id>5072</id>
      <parentid>5070</parentid>
      <timestamp>2025-08-08T08:11:26Z</timestamp>
      <contributor>
        <username>Mtsweni S</username>
        <id>835</id>
      </contributor>
      <comment>/* 4. Ukuhlakanipha ngokwabantu */</comment>
      <origin>5072</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2722" sha1="s1w6epxf7ru5awcwaybrzjextlx8b3n" xml:space="preserve">'''Iindlela''' ezinengi zoku[[hlakanipha]] kuyitiyori ka Howard Gardner lapho ahlathulula khona bona ukuhlanipha kwabantu ngekhe kwaba ngendlela eyodwa kodwana kungeendlela ezinengi ezihlukileko&lt;ref&gt;Derakhshan, A. and Faribi, M., 2015. Multiple intelligences: Language learning and teaching. ''International Journal of English Linguistics'', ''5''(4), p.63&lt;/ref&gt;. Iindlela lezi kuvezwa bona zibunane nazipheleleko. 

== Iindlela ezibunane zokuhlanipha ==
=== 1. Ukuhlakanipha ngokweenomboro ===
Umuntu lokha nakahlakaniphe ngokweenomboro kutjho bona uba nekghono elikhulu lokwenza iimbalo. Umuntu loyo ukghona ukuba iimbalo ezibudisi ezibhalela abantu abanengi, kodwana yena akhone ukuzenza ngendlela elula. Umuntu ohlakaniphe ngokweembalo ukghona ukurarulula imiraro ephathelenen nokubalal ngendlela etjengisa obukhulu ubuhlakani. 

=== 2. Ukuhlakanipha ngokwelimi/ngokwamalimi ===
Umuntu ohlakaniphe ngokwelimi kumumuntu onekghono elikhulu lokukhuluma amalumi nanyan ilimi elithileko. umunntu lo uthi nakakhuluma amalimi nanyana atlole into ethileko ukhombisa [[ilwazi]] lalelo limi.

=== 3.Ukuhlakanipha ngokugwala ===
[[Isimumathi:Ukuhlakanipha ngokugwala.jpg|thumb|ukuhlakanipha ngokugwala]]
Ukuhlakanipha ngokuugwala Kukulokha umuntu akghona ukugwala imigwalo emihle nofana iinthombe. Okhunye godu abantu abahlakiniphe ngokugwala bakghona ukuthula imilayezo ngokungabhali amagama  kodwana ngokugwala iinthombe ezithula umlayezo, bakhona nokuveza imizwa yabo ngokugwala. 

=== 4. Ukuhlakanipha ngokwabantu ===
Umumtu lokha nakahlaniphe ngokwabantu kukuklokha umuntu abanekghono elukhulu lokusebenza nabantu ngaphandle kokuthi kube nerarano phakathi kwabo. Umuntu onalokhu kuhlanipha ukghona  ukuhlanisa abantu begodu ukghona ukuzwisisa ubunjalo babantu aphilisana nabo. 

=== 5. Ukuhlakanipha ngokuzwisisa imvelo ===
Abantu abahlakaniphe ngokuzwisisa imvelo kungilabo bantu abakghona ukufunda ngokusebenzisa imvelo nofana izinto zemvelo.

=== 6.Ukuhlakanipha ngokusebenzisa umzimba ===
Umuntu ohlakaniphe ngokusenzisa umzimba uba nekghona elikhuli lokwenza izinto ezifana nokudansa ukugida nokhunye okuphathelene nokunyakazisa umzimba&lt;ref&gt;Nolen, J.L., 2003. MULTIPLE INTELLIGENCES IN THE CLASSROOM. ''Education'', ''124''(1). [https://www.traumlex.de/ traumlex]&lt;/ref&gt;.

=== 7. Ukuhlakanipha ngokukhona ukuvuma ===
Umuntu ohlakaniphe ngokukhona ukuvuma kumuntu onekghono lokwenza umvumo omnandi ongathabelwa babantu abanengi.

=== 8. Ukuhlanipha ngokwakho ===
Umuntu ohlakaniphe ngokwakhe kumumuntu ohlakaniphe ngokuthi ukghona ukusebenza begodu nokwenza izinto ezihle ngokwakhe ngaphandle kokusebenzisana nabanye abantu. Esikhathini esinengi lomhlobo wabantu awukhoni ukusebenza nesiqhema.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>s1w6epxf7ru5awcwaybrzjextlx8b3n</sha1>
    </revision>
    <revision>
      <id>5074</id>
      <parentid>5072</parentid>
      <timestamp>2025-08-08T08:12:25Z</timestamp>
      <contributor>
        <username>Mtsweni S</username>
        <id>835</id>
      </contributor>
      <comment>/* 8. Ukuhlakanipha ngokwakho */</comment>
      <origin>5074</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2724" sha1="ol8tw8ehe1wjokapi11cx84nh9o4ucq" xml:space="preserve">'''Iindlela''' ezinengi zoku[[hlakanipha]] kuyitiyori ka Howard Gardner lapho ahlathulula khona bona ukuhlanipha kwabantu ngekhe kwaba ngendlela eyodwa kodwana kungeendlela ezinengi ezihlukileko&lt;ref&gt;Derakhshan, A. and Faribi, M., 2015. Multiple intelligences: Language learning and teaching. ''International Journal of English Linguistics'', ''5''(4), p.63&lt;/ref&gt;. Iindlela lezi kuvezwa bona zibunane nazipheleleko. 

== Iindlela ezibunane zokuhlanipha ==
=== 1. Ukuhlakanipha ngokweenomboro ===
Umuntu lokha nakahlakaniphe ngokweenomboro kutjho bona uba nekghono elikhulu lokwenza iimbalo. Umuntu loyo ukghona ukuba iimbalo ezibudisi ezibhalela abantu abanengi, kodwana yena akhone ukuzenza ngendlela elula. Umuntu ohlakaniphe ngokweembalo ukghona ukurarulula imiraro ephathelenen nokubalal ngendlela etjengisa obukhulu ubuhlakani. 

=== 2. Ukuhlakanipha ngokwelimi/ngokwamalimi ===
Umuntu ohlakaniphe ngokwelimi kumumuntu onekghono elikhulu lokukhuluma amalumi nanyan ilimi elithileko. umunntu lo uthi nakakhuluma amalimi nanyana atlole into ethileko ukhombisa [[ilwazi]] lalelo limi.

=== 3.Ukuhlakanipha ngokugwala ===
[[Isimumathi:Ukuhlakanipha ngokugwala.jpg|thumb|ukuhlakanipha ngokugwala]]
Ukuhlakanipha ngokuugwala Kukulokha umuntu akghona ukugwala imigwalo emihle nofana iinthombe. Okhunye godu abantu abahlakiniphe ngokugwala bakghona ukuthula imilayezo ngokungabhali amagama  kodwana ngokugwala iinthombe ezithula umlayezo, bakhona nokuveza imizwa yabo ngokugwala. 

=== 4. Ukuhlakanipha ngokwabantu ===
Umumtu lokha nakahlaniphe ngokwabantu kukuklokha umuntu abanekghono elukhulu lokusebenza nabantu ngaphandle kokuthi kube nerarano phakathi kwabo. Umuntu onalokhu kuhlanipha ukghona  ukuhlanisa abantu begodu ukghona ukuzwisisa ubunjalo babantu aphilisana nabo. 

=== 5. Ukuhlakanipha ngokuzwisisa imvelo ===
Abantu abahlakaniphe ngokuzwisisa imvelo kungilabo bantu abakghona ukufunda ngokusebenzisa imvelo nofana izinto zemvelo.

=== 6.Ukuhlakanipha ngokusebenzisa umzimba ===
Umuntu ohlakaniphe ngokusenzisa umzimba uba nekghona elikhuli lokwenza izinto ezifana nokudansa ukugida nokhunye okuphathelene nokunyakazisa umzimba&lt;ref&gt;Nolen, J.L., 2003. MULTIPLE INTELLIGENCES IN THE CLASSROOM. ''Education'', ''124''(1). [https://www.traumlex.de/ traumlex]&lt;/ref&gt;.

=== 7. Ukuhlakanipha ngokukhona ukuvuma ===
Umuntu ohlakaniphe ngokukhona ukuvuma kumuntu onekghono lokwenza umvumo omnandi ongathabelwa babantu abanengi.

=== 8. Ukuhlakanipha ngokwakho ===
Umuntu ohlakaniphe ngokwakhe kumumuntu ohlakaniphe ngokuthi ukghona ukusebenza begodu nokwenza izinto ezihle ngokwakhe ngaphandle kokusebenzisana nabanye abantu. Esikhathini esinengi lomhlobo wabantu awukhoni ukusebenza nesiqhema.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>ol8tw8ehe1wjokapi11cx84nh9o4ucq</sha1>
    </revision>
    <revision>
      <id>5090</id>
      <parentid>5074</parentid>
      <timestamp>2025-08-08T09:25:49Z</timestamp>
      <contributor>
        <username>T Ntuli</username>
        <id>844</id>
      </contributor>
      <origin>5090</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2724" sha1="g0bv2mqtehg0dzfke5itg0dovlf3x3q" xml:space="preserve">'''Iindlela''' ezinengi zoku[[hlakanipha]] kuyitiyori ka Howard Gardner lapho ahlathulula khona bona ukuhlanipha kwabantu ngekhe kwaba ngendlela eyodwa kodwana kungeendlela ezinengi ezihlukileko&lt;ref&gt;Derakhshan, A. and Faribi, M., 2015. Multiple intelligences: Language learning and teaching. ''International Journal of English Linguistics'', ''5''(4), p.63&lt;/ref&gt;. Iindlela lezi kuvezwa bona zibunane nazipheleleko. 

== Iindlela ezibunane zokuhlanipha ==
=== 1. Ukuhlakanipha ngokweenomboro ===
Umuntu lokha nakahlakaniphe ngokweenomboro kutjho bona uba nekghono elikhulu lokwenza iimbalo. Umuntu loyo ukghona ukubala iimbalo ezibudisi ezibhalela abantu abanengi, kodwana yena akghone ukuzenza ngendlela elula. Umuntu ohlakaniphe ngokweembalo ukghona ukurarulula imiraro ephathelene nokubala ngendlela etjengisa obukhulu ubuhlakani. 

=== 2. Ukuhlakanipha ngokwelimi/ngokwamalimi ===
Umuntu ohlakaniphe ngokwelimi kumumuntu onekghono elikhulu lokukhuluma amalumi nanyana ilimi elithileko. umunntu lo uthi nakakhuluma amalimi nanyana atlole into ethileko ukhombisa [[ilwazi]] lalelo limi.

=== 3.Ukuhlakanipha ngokugwala ===
[[Isimumathi:Ukuhlakanipha ngokugwala.jpg|thumb|ukuhlakanipha ngokugwala]]
Ukuhlakanipha ngokugwala kukulokha umuntu akghona ukugwala imigwalo emihle nofana iinthombe. Okhunye godu abantu abahlakiniphe ngokugwala bakghona ukuthula imilayezo ngokungabhali amagama  kodwana ngokugwala iinthombe ezithula umlayezo, bakhona nokuveza imizwa yabo ngokugwala. 

=== 4. Ukuhlakanipha ngokwabantu ===
Umumtu lokha nakahlaniphe ngokwabantu kukulokha umuntu abanekghono elikhulu lokusebenza nabantu ngaphandle kokuthi kube nerarano phakathi kwabo. Umuntu onalokhu kuhlanipha ukghona  ukuhlanisa abantu begodu ukghona ukuzwisisa ubunjalo babantu aphilisana nabo. 

=== 5. Ukuhlakanipha ngokuzwisisa imvelo ===
Abantu abahlakaniphe ngokuzwisisa imvelo kungilabo bantu abakghona ukufunda ngokusebenzisa imvelo nofana izinto zemvelo.

=== 6.Ukuhlakanipha ngokusebenzisa umzimba ===
Umuntu ohlakaniphe ngokusenzisa umzimba uba nekghona elikhuli lokwenza izinto ezifana nokudansa ukugida nokhunye okuphathelene nokunyakazisa umzimba&lt;ref&gt;Nolen, J.L., 2003. MULTIPLE INTELLIGENCES IN THE CLASSROOM. ''Education'', ''124''(1). [https://www.traumlex.de/ traumlex]&lt;/ref&gt;.

=== 7. Ukuhlakanipha ngokukhona ukuvuma ===
Umuntu ohlakaniphe ngokukhona ukuvuma kumuntu onekghono lokwenza umvumo omnandi ongathabelwa babantu abanengi.

=== 8. Ukuhlakanipha ngokwakho ===
Umuntu ohlakaniphe ngokwakhe kumumuntu ohlakaniphe ngokuthi ukghona ukusebenza begodu nokwenza izinto ezihle ngokwakhe ngaphandle kokusebenzisana nabanye abantu. Esikhathini esinengi lomhlobo wabantu awukhoni ukusebenza nesiqhema.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>g0bv2mqtehg0dzfke5itg0dovlf3x3q</sha1>
    </revision>
    <revision>
      <id>5119</id>
      <parentid>5090</parentid>
      <timestamp>2025-08-10T14:52:53Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>5119</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2786" sha1="gxbpk0unk4ca1e0rv2txuilkqctgnb6" xml:space="preserve">'''Iindlela''' ezinengi zoku[[hlakanipha]] kuyitiyori ka Howard Gardner lapho ahlathulula khona bona ukuhlanipha kwabantu ngekhe kwaba ngendlela eyodwa kodwana kungeendlela ezinengi ezihlukileko&lt;ref&gt;Derakhshan, A. and Faribi, M., 2015. Multiple intelligences: Language learning and teaching. ''International Journal of English Linguistics'', ''5''(4), p.63&lt;/ref&gt;. Iindlela lezi kuvezwa bona zibunane nazipheleleko. 

== Iindlela ezibunane zokuhlanipha ==
=== 1. Ukuhlakanipha ngokweenomboro ===
Umuntu lokha nakahlakaniphe ngokweenomboro kutjho bona uba nekghono elikhulu lokwenza iimbalo. Umuntu loyo ukghona ukubala iimbalo ezibudisi ezibhalela abantu abanengi, kodwana yena akghone ukuzenza ngendlela elula. Umuntu ohlakaniphe ngokweembalo ukghona ukurarulula imiraro ephathelene nokubala ngendlela etjengisa obukhulu ubuhlakani. 

=== 2. Ukuhlakanipha ngokwelimi/ngokwamalimi ===
Umuntu ohlakaniphe ngokwelimi kumumuntu onekghono elikhulu lokukhuluma amalumi nanyana ilimi elithileko. umunntu lo uthi nakakhuluma amalimi nanyana atlole into ethileko ukhombisa [[ilwazi]] lalelo limi.

=== 3.Ukuhlakanipha ngokugwala ===
[[Isimumathi:Ukuhlakanipha ngokugwala.jpg|thumb|ukuhlakanipha ngokugwala]]
Ukuhlakanipha ngokugwala kukulokha umuntu akghona ukugwala imigwalo emihle nofana iinthombe. Okhunye godu abantu abahlakiniphe ngokugwala bakghona ukuthula imilayezo ngokungabhali amagama  kodwana ngokugwala iinthombe ezithula umlayezo, bakhona nokuveza imizwa yabo ngokugwala. 

=== 4. Ukuhlakanipha ngokwabantu ===
Umumtu lokha nakahlaniphe ngokwabantu kukulokha umuntu abanekghono elikhulu lokusebenza nabantu ngaphandle kokuthi kube nerarano phakathi kwabo. Umuntu onalokhu kuhlanipha ukghona  ukuhlanisa abantu begodu ukghona ukuzwisisa ubunjalo babantu aphilisana nabo. 

=== 5. Ukuhlakanipha ngokuzwisisa imvelo ===
Abantu abahlakaniphe ngokuzwisisa imvelo kungilabo bantu abakghona ukufunda ngokusebenzisa imvelo nofana izinto zemvelo.

=== 6.Ukuhlakanipha ngokusebenzisa umzimba ===
Umuntu ohlakaniphe ngokusenzisa umzimba uba nekghona elikhuli lokwenza izinto ezifana nokudansa ukugida nokhunye okuphathelene nokunyakazisa umzimba&lt;ref&gt;Nolen, J.L., 2003. MULTIPLE INTELLIGENCES IN THE CLASSROOM. ''Education'', ''124''(1). [https://www.traumlex.de/ traumlex]&lt;/ref&gt;.

=== 7. Ukuhlakanipha ngokukhona ukuvuma ===
Umuntu ohlakaniphe ngokukhona ukuvuma kumuntu onekghono lokwenza umvumo omnandi ongathabelwa babantu abanengi.

=== 8. Ukuhlakanipha ngokwakho ===
Umuntu ohlakaniphe ngokwakhe kumumuntu ohlakaniphe ngokuthi ukghona ukusebenza begodu nokwenza izinto ezihle ngokwakhe ngaphandle kokusebenzisana nabanye abantu. Esikhathini esinengi lomhlobo wabantu awukhoni ukusebenza nesiqhema.

== Iinkomba ==
{{Reflist}}
[[Category:Ukuhlakanipha]]
[[Category:Iindlela zokuhlanipha]]</text>
      <sha1>gxbpk0unk4ca1e0rv2txuilkqctgnb6</sha1>
    </revision>
    <revision>
      <id>5120</id>
      <parentid>5119</parentid>
      <timestamp>2025-08-10T15:11:16Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5120</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3888" sha1="r00sw5kdfaimkjv1zrg2nl0jtb4v4zy" xml:space="preserve">'''Iindlela''' ezinengi zoku[[hlakanipha]] kuyitiyori ka Howard Gardner lapho ahlathulula khona bona ukuhlanipha kwabantu ngekhe kwaba ngendlela eyodwa kodwana kungeendlela ezinengi ezihlukileko&lt;ref&gt;Derakhshan, A. and Faribi, M., 2015. Multiple intelligences: Language learning and teaching. ''International Journal of English Linguistics'', ''5''(4), p.63&lt;/ref&gt;.Itiyori le iveza bona ukuthi umuntu uhlakaniphile ngekhe sabombona ngokuthi aphumelele kuhle eemfundweni zakhe zeskolo kodwana zikhona nezinye izinto angabonakala ngazo bonyana uhlakaniphile.Woke umuntu uhlakaniphe ngeyakhe indlela ngokuya kwendlela yemvelo adaleke ngayo. Iindlela lezi kuvezwa bona zibunane nazipheleleko. 

=== Iindlela ezibunane zokuhlanipha ===

==== 1. Ukuhlakanipha ngokweenomboro ====
Umuntu lokha nakahlakaniphe ngokweenomboro kutjho bona uba nekghono elikhulu lokwenza iimbalo. Umuntu loyo ukghona ukubala iimbalo ezibudisi ezibhalela abantu abanengi, kodwana yena akghone ukuzenza ngendlela elula. Umuntu ohlakaniphe ngokweembalo ukghona ukurarulula imiraro ephathelene nokubala ngendlela etjengisa obukhulu ubuhlakani. 

==== 2. Ukuhlakanipha ngokwelimi/ngokwamalimi ====
Umuntu ohlakaniphe ngokwelimi kumumuntu onekghono elikhulu lokukhuluma amalumi nanyana ilimi elithileko. umunntu lo uthi nakakhuluma amalimi nanyana atlole into ethileko ukhombisa [[ilwazi]] lalelo limi.Umuntu ohlakaniphe ngokwelimi ukghona ukuthi akhethe amagama ekungiwo ukuze ikulumo yakhe izwakale. Eskhathini esinengi abantu laba bakghona ukuthi bakhulume nabanye abantu begodu bangaphikiswa ngambana bayakwazi ukuhlela ikulumo yabo ngendlea ezokuzwiwa babantu boke.

==== 3.Ukuhlakanipha ngokugwala ====
[[Isimumathi:Ukuhlakanipha ngokugwala.jpg|thumb|ukuhlakanipha ngokugwala]]
Ukuhlakanipha ngokugwala kukulokha umuntu akghona ukugwala imigwalo emihle nofana iinthombe. Okhunye godu abantu abahlakiniphe ngokugwala bakghona ukuthula imilayezo ngokungabhali amagama  kodwana ngokugwala iinthombe ezithula umlayezo, bakhona nokuveza imizwa yabo ngokugwala. Abantu laba bangalandela amabizelo wobukghwari. 

==== 4. Ukuhlakanipha ngokwabantu ====
Umumtu lokha nakahlaniphe ngokwabantu kukulokha umuntu abanekghono elikhulu lokusebenza nabantu ngaphandle kokuthi kube nerarano phakathi kwabo. Umuntu onalokhu kuhlanipha ukghona  ukuhlanisa abantu begodu ukghona ukuzwisisa ubunjalo babantu aphilisana nabo. 

==== 5. Ukuhlakanipha ngokuzwisisa imvelo ====
Abantu abahlakaniphe ngokuzwisisa imvelo kungilabo bantu abakghona ukufunda ngokusebenzisa imvelo nofana izinto zemvelo. Umuntu lakhona ubanekghono eliphezulu lokuzwisisa imvelo begodu ikghono lakhona litjengisa ukuhlanipha emuntwini loyo. bathanda izinto zemvelo ezifana neentaba, amahlathi, iimbandana nokhunye okuyizinto zemvelo.&lt;ref&gt;[https://www.simplypsychology.org/multiple-intelligences.html Gardner's Theory Of Multiple Intelligences]&lt;/ref&gt; 

==== 6.Ukuhlakanipha ngokusebenzisa umzimba ====
Umuntu ohlakaniphe ngokusenzisa umzimba uba nekghona elikhuli lokwenza izinto ezifana nokudansa ukugida nokhunye okuphathelene nokunyakazisa umzimba&lt;ref&gt;Nolen, J.L., 2003. MULTIPLE INTELLIGENCES IN THE CLASSROOM. ''Education'', ''124''(1). [https://www.traumlex.de/ traumlex]&lt;/ref&gt;.

==== 7. Ukuhlakanipha ngokukhona ukuvuma ====
Umuntu ohlakaniphe ngokukghona ukuvuma kumumuntu onekghono lokwenza umvumo omnandi ongathabelwa babantu abanengi. Abantu laba bakghona ukuthi bezwe ukuduma namaphimbo amnandi.

==== 8. Ukuhlakanipha ngokwakho ====
Umuntu ohlakaniphe ngokwakhe kumumuntu ohlakaniphe ngokuthi ukghona ukusebenza begodu nokwenza izinto ezihle ngokwakhe ngaphandle kokusebenzisana nabanye abantu. Esikhathini esinengi lomhlobo wabantu awukhoni ukusebenza nesiqhema.bakghona ukuthi bazwisise imizwa yabantu,nezinto abazihlosileko nanyana abantu labo bangakazikhulumi.

== Iinkomba ==
{{Reflist}}
[[Category:Ukuhlakanipha]]
[[Category:Iindlela zokuhlanipha]]</text>
      <sha1>r00sw5kdfaimkjv1zrg2nl0jtb4v4zy</sha1>
    </revision>
  </page>
  <page>
    <title>Iinganekwane</title>
    <ns>0</ns>
    <id>153</id>
    <revision>
      <id>747</id>
      <timestamp>2024-07-05T16:25:03Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Iinganenkwane''' ziindabaa egade zicocwa bababntu abadala kade begodu azinabo abatloli.  &quot;</comment>
      <origin>747</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="92" sha1="sv65p1srsdp9ohsp8frsgwcgl7lwhyw" xml:space="preserve">'''Iinganenkwane''' ziindabaa egade zicocwa bababntu abadala kade begodu azinabo abatloli.

</text>
      <sha1>sv65p1srsdp9ohsp8frsgwcgl7lwhyw</sha1>
    </revision>
    <revision>
      <id>748</id>
      <parentid>747</parentid>
      <timestamp>2024-07-05T19:23:12Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>748</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="194" sha1="2bi9dtvxiwo826aqg06v68md4o7xcnw" xml:space="preserve">'''Iinganekwane''' ziindabaa egade zicocwa babantu abadala kade begodu azinabo abatloli. Abogogo beba coca inganekwane ebusuku lokha woke umuntu ahlezi phasi. Inganekwane ziimhlobo emithathu.


</text>
      <sha1>2bi9dtvxiwo826aqg06v68md4o7xcnw</sha1>
    </revision>
    <revision>
      <id>749</id>
      <parentid>748</parentid>
      <timestamp>2024-07-12T17:35:44Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>749</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="482" sha1="jyu3w8cnd3fmkl0xy27yu8q7br093yk" xml:space="preserve">'''Iinganekwane''' ziindabaa egade zicocwa babantu abadala kade begodu azinabo abatloli. Abogogo beba coca inganekwane ebusuku lokha woke umuntu ahlezi phasi.Inganekwane zaba zicocwa ngesibanga sokobana abogogo babe bafuna abantwana bangabi nesizungu. Kade kwabe kungakavumelelki bona ucoce inganekwane emini, bekuthiwa nawuzicocs emini uzokumila iimpondo. Esikhathini Sanje izinto sele zitjhungulukile ngombana sele zikhona nokufundwa eenkolweni emini begodu sele zitlowe phasi.


</text>
      <sha1>jyu3w8cnd3fmkl0xy27yu8q7br093yk</sha1>
    </revision>
    <revision>
      <id>750</id>
      <parentid>749</parentid>
      <timestamp>2024-10-14T13:46:45Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>749</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="482" sha1="jyu3w8cnd3fmkl0xy27yu8q7br093yk" xml:space="preserve">'''Iinganekwane''' ziindabaa egade zicocwa babantu abadala kade begodu azinabo abatloli. Abogogo beba coca inganekwane ebusuku lokha woke umuntu ahlezi phasi.Inganekwane zaba zicocwa ngesibanga sokobana abogogo babe bafuna abantwana bangabi nesizungu. Kade kwabe kungakavumelelki bona ucoce inganekwane emini, bekuthiwa nawuzicocs emini uzokumila iimpondo. Esikhathini Sanje izinto sele zitjhungulukile ngombana sele zikhona nokufundwa eenkolweni emini begodu sele zitlowe phasi.


</text>
      <sha1>jyu3w8cnd3fmkl0xy27yu8q7br093yk</sha1>
    </revision>
    <revision>
      <id>2463</id>
      <parentid>750</parentid>
      <timestamp>2025-02-24T11:59:21Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2463</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="476" sha1="kvoiwryh8t5zljnhlma34qozit8mhwe" xml:space="preserve">'''Iinganekwane''' ziindaba egade zicocwa babantu abadala kade begodu azinabo abatloli. Abogogo beba coca inganekwane ebusuku lokha woke umuntu ahlezi phasi.Inganekwane zaba zicocwa ngesibanga sokobana abogogo babe bafuna abantwana bangabi nesizungu. Kade kwabe kungakavumeleki bona ucoce inganekwane emini, bekuthiwa nawuzicoca emini uzokumila iimpondo. Esikhathini Sanje izinto sele zitjhugulukile ngombana sele zikhona nokufundwa eenkolweni emini begodu sele zitlowe phasi.</text>
      <sha1>kvoiwryh8t5zljnhlma34qozit8mhwe</sha1>
    </revision>
  </page>
  <page>
    <title>Iinkathi zomnyaka</title>
    <ns>0</ns>
    <id>154</id>
    <revision>
      <id>751</id>
      <timestamp>2024-07-21T10:12:20Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;== Iinkathi zomnyaka ==  === Isingeniso === Nasikhuluma ngeenkathi zomnyaka sisuke sikhuluma ngobujamo bezulu lobo obuhlukaniswe ngeenyanga entathu, khulukhulu la eSewula Afrika. Ngamanye amagama iinkathi zomnyaka lezi zihlukaniswe kane nawutjheja bonyana umnyaka uneenyanga ezilitjhumi nambili. Iinkathi zomnyaka zona ngilezi, ihlobo, isiruthwani, ubusika nesilimela.  Iinkathi zomnyaka  Kanti zona iinkathi lezi zikhamba zihlukaniswa ngeenyanga zomnyaka ngendlela elandelak...&quot;</comment>
      <origin>751</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2448" sha1="i8eqsz98z13rt7eflflrzuw0bu7pz1p" xml:space="preserve">== Iinkathi zomnyaka ==

=== Isingeniso ===
Nasikhuluma ngeenkathi zomnyaka sisuke sikhuluma ngobujamo bezulu lobo obuhlukaniswe ngeenyanga entathu, khulukhulu la eSewula Afrika. Ngamanye amagama iinkathi zomnyaka lezi zihlukaniswe kane nawutjheja bonyana umnyaka uneenyanga ezilitjhumi nambili. Iinkathi zomnyaka zona ngilezi, ihlobo, isiruthwani, ubusika nesilimela. 
Iinkathi zomnyaka

Kanti zona iinkathi lezi zikhamba zihlukaniswa ngeenyanga zomnyaka ngendlela elandelako:

1.	'''Ihlobo''': ihlobo lithoma kanengi ngoNobayeni kufikela ekupheleni kukaMhlolanja

2.	'''Isiruthwani''': isiruthwani sithoma kanengi ngoNtaka kufikela ekupheleni kukaMrhayili

3.	'''Ubusika''': ubusika buthoma kanengi ngoMgwengweni kufikela ekupheleni kukaRhoboyi.

4.	'''Isilimela''': isilimela sithoma kanengi ngoKhukhulamungu kufikela ekuthomeni kukaSinyikhaba

=== Ihlobo: ===
Ehlobo kanengi amalanga walo ayatjhisa begodu kunezulu elinengi, khulukhulu eendaweni eziwela ngaphasi kobujamo bezulu ithrophikhali. Ukungezelela, iindawo lapho kutjhisa khulu khona uzokubona ngabonompopoloza abanengi tle kanye nokubahlaza kotjani nemithi. 

=== Isiruthwani: ===
Esiruthwaneni kanengi amalanga wakhona afudumele begodu akusatjhisi khulu njengoba sendlalela ubusika. Ngesikhathi sesiruthwani, abantu abanengi bayavuna lokho ebe bakutjalile ngehlobo. Ukungezelela, nezulu nalo alisani ngamandla khulu.

=== Ubusika: ===
Ebusika kanengi amalanga wakhona amakhaza khulu begodu eendaweni lezo ubujamo bazo bezulu kungebethrophikhali izulu alisani. Kodwana, iindawo lezo ubujamo bazo kuyi- Mediterranean, izulu liyana kwambala tle begodu likhamba negabhogo nomoya omakhaza tle. Ngesikhathi lesi somnyaka imithi ithintheka amakazi begodu notjani nabo buyoma. Isikhathi lezi sinemililo eminengi yehlathini leyo ezenzelekako.

=== Isilimela:  ===
Isilimela kanengi amalanga wakhona athoma ufudumele njengoba sindlalela ihlobo. Begodu, imithi, iintjalo notjani buthoma ukutlhurha nokuthela. Ukuragela phambili, nezulu lithoma ukuna kodwana lincani kwambala. Into enengi mumoya onamandla loya oguga nehkabathi namatje amancani lawo abetha kabuhlungu eenyaweni.

=== Isiphetho ===
Iinkathi zomnyaka ziqakatheke khulu bonyana sizazi nokuthi sizihlukanise njengombana sithwele umlayezo mayelana nokuthi singalindela ini nanyana siziphathe njani njengalokha ebusika siyazi bonyana kufanele simbathe iimpahla ezifudumeleko kanti ngesilimela kufanele sithome silime begodu sitjale.

</text>
      <sha1>i8eqsz98z13rt7eflflrzuw0bu7pz1p</sha1>
    </revision>
    <revision>
      <id>752</id>
      <parentid>751</parentid>
      <timestamp>2024-09-18T15:44:17Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>752</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2449" sha1="50brx7ngzvmzzdxpyopiz637gpr4yhs" xml:space="preserve">== Iinkathi zomnyaka. ==

=== Isingeniso ===
Nasikhuluma ngeenkathi zomnyaka sisuke sikhuluma ngobujamo bezulu lobo obuhlukaniswe ngeenyanga entathu, khulukhulu la eSewula Afrika. Ngamanye amagama iinkathi zomnyaka lezi zihlukaniswe kane nawutjheja bonyana umnyaka uneenyanga ezilitjhumi nambili. Iinkathi zomnyaka zona ngilezi, ihlobo, isiruthwani, ubusika nesilimela. 
Iinkathi zomnyaka

Kanti zona iinkathi lezi zikhamba zihlukaniswa ngeenyanga zomnyaka ngendlela elandelako:

1.	'''Ihlobo''': ihlobo lithoma kanengi ngoNobayeni kufikela ekupheleni kukaMhlolanja

2.	'''Isiruthwani''': isiruthwani sithoma kanengi ngoNtaka kufikela ekupheleni kukaMrhayili

3.	'''Ubusika''': ubusika buthoma kanengi ngoMgwengweni kufikela ekupheleni kukaRhoboyi.

4.	'''Isilimela''': isilimela sithoma kanengi ngoKhukhulamungu kufikela ekuthomeni kukaSinyikhaba

=== Ihlobo: ===
Ehlobo kanengi amalanga walo ayatjhisa begodu kunezulu elinengi, khulukhulu eendaweni eziwela ngaphasi kobujamo bezulu ithrophikhali. Ukungezelela, iindawo lapho kutjhisa khulu khona uzokubona ngabonompopoloza abanengi tle kanye nokubahlaza kotjani nemithi. 

=== Isiruthwani: ===
Esiruthwaneni kanengi amalanga wakhona afudumele begodu akusatjhisi khulu njengoba sendlalela ubusika. Ngesikhathi sesiruthwani, abantu abanengi bayavuna lokho ebe bakutjalile ngehlobo. Ukungezelela, nezulu nalo alisani ngamandla khulu.

=== Ubusika: ===
Ebusika kanengi amalanga wakhona amakhaza khulu begodu eendaweni lezo ubujamo bazo bezulu kungebethrophikhali izulu alisani. Kodwana, iindawo lezo ubujamo bazo kuyi- Mediterranean, izulu liyana kwambala tle begodu likhamba negabhogo nomoya omakhaza tle. Ngesikhathi lesi somnyaka imithi ithintheka amakazi begodu notjani nabo buyoma. Isikhathi lezi sinemililo eminengi yehlathini leyo ezenzelekako.

=== Isilimela:  ===
Isilimela kanengi amalanga wakhona athoma ufudumele njengoba sindlalela ihlobo. Begodu, imithi, iintjalo notjani buthoma ukutlhurha nokuthela. Ukuragela phambili, nezulu lithoma ukuna kodwana lincani kwambala. Into enengi mumoya onamandla loya oguga nehkabathi namatje amancani lawo abetha kabuhlungu eenyaweni.

=== Isiphetho ===
Iinkathi zomnyaka ziqakatheke khulu bonyana sizazi nokuthi sizihlukanise njengombana sithwele umlayezo mayelana nokuthi singalindela ini nanyana siziphathe njani njengalokha ebusika siyazi bonyana kufanele simbathe iimpahla ezifudumeleko kanti ngesilimela kufanele sithome silime begodu sitjale.

</text>
      <sha1>50brx7ngzvmzzdxpyopiz637gpr4yhs</sha1>
    </revision>
    <revision>
      <id>753</id>
      <parentid>752</parentid>
      <timestamp>2024-10-14T13:46:45Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>752</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2449" sha1="50brx7ngzvmzzdxpyopiz637gpr4yhs" xml:space="preserve">== Iinkathi zomnyaka. ==

=== Isingeniso ===
Nasikhuluma ngeenkathi zomnyaka sisuke sikhuluma ngobujamo bezulu lobo obuhlukaniswe ngeenyanga entathu, khulukhulu la eSewula Afrika. Ngamanye amagama iinkathi zomnyaka lezi zihlukaniswe kane nawutjheja bonyana umnyaka uneenyanga ezilitjhumi nambili. Iinkathi zomnyaka zona ngilezi, ihlobo, isiruthwani, ubusika nesilimela. 
Iinkathi zomnyaka

Kanti zona iinkathi lezi zikhamba zihlukaniswa ngeenyanga zomnyaka ngendlela elandelako:

1.	'''Ihlobo''': ihlobo lithoma kanengi ngoNobayeni kufikela ekupheleni kukaMhlolanja

2.	'''Isiruthwani''': isiruthwani sithoma kanengi ngoNtaka kufikela ekupheleni kukaMrhayili

3.	'''Ubusika''': ubusika buthoma kanengi ngoMgwengweni kufikela ekupheleni kukaRhoboyi.

4.	'''Isilimela''': isilimela sithoma kanengi ngoKhukhulamungu kufikela ekuthomeni kukaSinyikhaba

=== Ihlobo: ===
Ehlobo kanengi amalanga walo ayatjhisa begodu kunezulu elinengi, khulukhulu eendaweni eziwela ngaphasi kobujamo bezulu ithrophikhali. Ukungezelela, iindawo lapho kutjhisa khulu khona uzokubona ngabonompopoloza abanengi tle kanye nokubahlaza kotjani nemithi. 

=== Isiruthwani: ===
Esiruthwaneni kanengi amalanga wakhona afudumele begodu akusatjhisi khulu njengoba sendlalela ubusika. Ngesikhathi sesiruthwani, abantu abanengi bayavuna lokho ebe bakutjalile ngehlobo. Ukungezelela, nezulu nalo alisani ngamandla khulu.

=== Ubusika: ===
Ebusika kanengi amalanga wakhona amakhaza khulu begodu eendaweni lezo ubujamo bazo bezulu kungebethrophikhali izulu alisani. Kodwana, iindawo lezo ubujamo bazo kuyi- Mediterranean, izulu liyana kwambala tle begodu likhamba negabhogo nomoya omakhaza tle. Ngesikhathi lesi somnyaka imithi ithintheka amakazi begodu notjani nabo buyoma. Isikhathi lezi sinemililo eminengi yehlathini leyo ezenzelekako.

=== Isilimela:  ===
Isilimela kanengi amalanga wakhona athoma ufudumele njengoba sindlalela ihlobo. Begodu, imithi, iintjalo notjani buthoma ukutlhurha nokuthela. Ukuragela phambili, nezulu lithoma ukuna kodwana lincani kwambala. Into enengi mumoya onamandla loya oguga nehkabathi namatje amancani lawo abetha kabuhlungu eenyaweni.

=== Isiphetho ===
Iinkathi zomnyaka ziqakatheke khulu bonyana sizazi nokuthi sizihlukanise njengombana sithwele umlayezo mayelana nokuthi singalindela ini nanyana siziphathe njani njengalokha ebusika siyazi bonyana kufanele simbathe iimpahla ezifudumeleko kanti ngesilimela kufanele sithome silime begodu sitjale.

</text>
      <sha1>50brx7ngzvmzzdxpyopiz637gpr4yhs</sha1>
    </revision>
    <revision>
      <id>6680</id>
      <parentid>753</parentid>
      <timestamp>2026-06-09T15:48:16Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <origin>6680</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2377" sha1="jx8i6rjw4zbyhetkudfdhvxoguk2jtt" xml:space="preserve">'''Nasikhuluma''' ngeenkathi zomnyaka sisuke sikhuluma ngobujamo bezulu lobo obuhlukaniswe ngeenyanga entathu, khulukhulu la eSewula Afrika. Ngamanye amagama iinkathi zomnyaka lezi zihlukaniswe kane nawutjheja bonyana umnyaka uneenyanga ezilitjhumi nambili. Iinkathi zomnyaka zona ngilezi, ihlobo, isiruthwani, ubusika nesilimela. 
Iinkathi zomnyaka

Kanti zona iinkathi lezi zikhamba zihlukaniswa ngeenyanga zomnyaka ngendlela elandelako:

1.	'''Ihlobo''': ihlobo lithoma kanengi ngoNobayeni kufikela ekupheleni kukaMhlolanja

2.	'''Isiruthwani''': isiruthwani sithoma kanengi ngoNtaka kufikela ekupheleni kukaMrhayili

3.	'''Ubusika''': ubusika buthoma kanengi ngoMgwengweni kufikela ekupheleni kukaRhoboyi.

4.	'''Isilimela''': isilimela sithoma kanengi ngoKhukhulamungu kufikela ekuthomeni kukaSinyikhaba

== Ihlobo ==
Ehlobo kanengi amalanga walo ayatjhisa begodu kunezulu elinengi, khulukhulu eendaweni eziwela ngaphasi kobujamo bezulu ithrophikhali. Ukungezelela, iindawo lapho kutjhisa khulu khona uzokubona ngabonompopoloza abanengi tle kanye nokubahlaza kotjani nemithi. 

== Isiruthwani ==
Esiruthwaneni kanengi amalanga wakhona afudumele begodu akusatjhisi khulu njengoba sendlalela ubusika. Ngesikhathi sesiruthwani, abantu abanengi bayavuna lokho ebe bakutjalile ngehlobo. Ukungezelela, nezulu nalo alisani ngamandla khulu.

== Ubusika ==
Ebusika kanengi amalanga wakhona amakhaza khulu begodu eendaweni lezo ubujamo bazo bezulu kungebethrophikhali izulu alisani. Kodwana, iindawo lezo ubujamo bazo kuyi- Mediterranean, izulu liyana kwambala tle begodu likhamba negabhogo nomoya omakhaza tle. Ngesikhathi lesi somnyaka imithi ithintheka amakazi begodu notjani nabo buyoma. Isikhathi lezi sinemililo eminengi yehlathini leyo ezenzelekako.

== Isilimela ==
Isilimela kanengi amalanga wakhona athoma ufudumele njengoba sindlalela ihlobo. Begodu, imithi, iintjalo notjani buthoma ukutlhurha nokuthela. Ukuragela phambili, nezulu lithoma ukuna kodwana lincani kwambala. Into enengi mumoya onamandla loya oguga nehkabathi namatje amancani lawo abetha kabuhlungu eenyaweni.

Iinkathi zomnyaka ziqakatheke khulu bonyana sizazi nokuthi sizihlukanise njengombana sithwele umlayezo mayelana nokuthi singalindela ini nanyana siziphathe njani njengalokha ebusika siyazi bonyana kufanele simbathe iimpahla ezifudumeleko kanti ngesilimela kufanele sithome silime begodu sitjale.</text>
      <sha1>jx8i6rjw4zbyhetkudfdhvxoguk2jtt</sha1>
    </revision>
  </page>
  <page>
    <title>Iinlwana Ezisengozini Yokutjhabalala</title>
    <ns>0</ns>
    <id>155</id>
    <revision>
      <id>754</id>
      <timestamp>2024-09-14T09:54:45Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;== Iinlwana Ezisengozini Yokutjhabalala. ==  === Isingeniso === Iinlwana ngezinye zezinto ezidlala indima eqakathekileko ephasini ngokunabileko. Ilwana zidlala indima eqakathekileko kezamaphilo, ukunzinza kanye nezehlala kuhle yazo zoke izinto ephasini (Fuanalytics 2023&lt;ref name=&quot;:0&quot;&gt;Fuanalytics. 2023. ''Wild Animals''. Itholakala ku:&lt;nowiki&gt;https://faunalytics.org/fundamentals-wild-animals/?gad_source=1&amp;gclid=CjwKCAjwuMC2BhA7EiwAmJKRrMUrysChkerPZrjOHIAYZCTAFNyfCXX_Cubds...&quot;</comment>
      <origin>754</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5058" sha1="0on7cxnb0t41bnrojxyn02l3drcxwip" xml:space="preserve">== Iinlwana Ezisengozini Yokutjhabalala. ==

=== Isingeniso ===
Iinlwana ngezinye zezinto ezidlala indima eqakathekileko ephasini ngokunabileko. Ilwana zidlala indima eqakathekileko kezamaphilo, ukunzinza kanye nezehlala kuhle yazo zoke izinto ephasini (Fuanalytics 2023&lt;ref name=&quot;:0&quot;&gt;Fuanalytics. 2023. ''Wild Animals''. Itholakala ku:&lt;nowiki&gt;https://faunalytics.org/fundamentals-wild-animals/?gad_source=1&amp;gclid=CjwKCAjwuMC2BhA7EiwAmJKRrMUrysChkerPZrjOHIAYZCTAFNyfCXX_CubdshvnfgH0wYDKJagapxoCTrgQAvD_BwE&lt;/nowiki&gt;. Ufunyenwe ngomhlaka [29 kuRhoboyi 2024]&lt;/ref&gt;; ne-Wikipedia 2024&lt;ref&gt;Wikipedia. 2024. ''Endangered Species''. Litholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Endangered_species&lt;/nowiki&gt;&gt;. Lifunyenwe ngomhlaka [29 kuRhoboyi 2024]&lt;/ref&gt;). Iinlwana lezi akukhethi bonyana ziinlwana zemakhaya nanyana kuz[https://faunalytics.org/fundamentals-wild-animals/?gad_source=1&amp;gclid=CjwKCAjwuMC2BhA7EiwAmJKRrMUrysChkerPZrjOHIAYZCTAFNyfCXX_CubdshvnfgH0wYDKJagapxoCTrgQAvD_BwE. iinlwana zehlathini] nanyana iimbandana nanyana iinlwana zemanzini. Nanyana kunjalo-ke, kukhona umraro lo oqalene neelwana lezi, ekukutjhabalala. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyini ukutjhabalala kweenlwana kanye nembangela yakhona. 

=== Ingabe kuyini ukutjhabalala kweenlwana na? ===
Ngokuya kuka-Pizzi, u-Caroli, u-Landini, u-Galluccio, u-Mezzelani no-Milanesi (2013)&lt;ref name=&quot;:1&quot;&gt;Pizzi, F., Caroli, A. M., Landini, M., Galluccio, N., Mezzelani, A. &amp; Milanesi, L. 2013. Conservation of endangered animals: From biotechnologies to digital preservation. ''Natural Science'', 5 (8): 903-913. SciRes.&lt;/ref&gt; ne-Wikipedia (2024) iinlwana zemakhaya, zehlathini nezemanzini zizithola zihlangabezana netjhugululo lepilo. Amatjhuguluko la, abangela bonyana kubo nokuncipha kwezinye ilwani kanti ezinye zazo zigcine zingasatholakali (South African National Biodiversity Institute [I-SANBI] (2010&lt;ref name=&quot;:2&quot;&gt;South African National Biodiversity Institute. 2010. ''Threatened Species: A guide to Red Lists and their use in conservation''. Threatened Species Programme. SANBI: Pretoria.&lt;/ref&gt;). Isenzo lesi sokuncipha bekufike la zingasekho nanyana zingatholakali khona sibizwa bonyana kutjhabalala kweenlwana (I-SANBI 2010&lt;ref name=&quot;:2&quot; /&gt;; no-Pizzi ''nabanye'' 2013&lt;ref name=&quot;:1&quot; /&gt;). 

[[:en:Endangered_species|Ukutjhabalala lokhu akukhethi bonyana iinlwana]] leyo zikuyiphi iindawo; zikuliphi ibhoduluko; begodu ziphila ipilo enjani (Fuanlaytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Esikhathini esinengi iinlwana ezitjhabalalako ngilezo zendabuko nanyana zeemvelo (i-SANBI 2013&lt;ref name=&quot;:2&quot; /&gt;). Ngamanye amagama, iinlwana ezitjhabalalako kuziinlwana lezo ezivelele kilezo ndawo, begodu zijwayele ukuphila lapho ngoba kwezinye iindawo angeze zaphila. Izinto ezifaka isandla ekutjhabalaliseni kweenlwana lezi azifani begodu zihluke ngokuya kweendawo (Pizzi ''nabanye'' 2013&lt;ref name=&quot;:1&quot; /&gt;). Esihlokweni esilandelako sizokutjheja izinto ezifaka isandla ekutjhaballaliseni iinlwana nanyana iimbangela. 

=== Imbangela yokutjhabalala kweenlwazi zendabuko ===
Zinengi izinto ezibangela ukutjhabalala kweenlwani, khulukhulu zemvelo; kodwana ekulumenipendulo le, sizokutjheja ezilandelako:

=== 1.      Ibhoduluko nobujamo bezulu ===
Amatjhuguluko alethwa libhodululo nobujamo bezulu athinta kumbi imihlobo yeenlwana zoke (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;).  Lokhu kubangwa kukuthi uthola sele kutjhisa khulu nanyana kumakhaza khulu ngokudluleleko nanyana kuthatha isikhathi eside leso iinlwani ezingakghoni ukusibekezala (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Ngebanga lalokho, zigcina zihlongakala. 

=== 2.      Indlala ===
Iinlwazi ezinengi ziyathiywa begodu zithiywa ngonengi khulu ukudlula iimbalo leyo ezikghona ukuvela ngayo (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Ukungezelele, iinlwani lezi zithiyelwa ukudliwa begodu abantu abanengi abatlhagako bathembekizo njengomthombo wokudla (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Lokhu kumraro.

=== 3.      Amarhwebo namabubulo ===
Amarhwebo namabubulo enza inzunzo esikhathi esinengi asebenzisa begodu athengisa iinlwani nemikghiqizo kanye nezitho zazo (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Ngebanga lokhu amarhwebo namabubulo la sele amanengi khulu begodu adisela imindeni yeenlwana lezi, iinlwani lezi ziyancipha ezinye ziphelile begodu azisaveli (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;).

=== 4.      Ituthuko yamadorobha ===
Lokha nakwakhiwa iindawo namadorobha amatjha kususwa iindawo lapho iinlwana lezi ziphila khona begodu akukho la zifuduselwa nanyana zigcinwa khona (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Ukungezelela, ezinye zazo ziyabulawa ngomba zithathwa njengeenlwana eziyingozi (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Ngebanga lalokhu, ziyancipha begodu zigcine zitjhabalele.

=== Isiphetho ===
Iinlwana, khulukhulu zendabuko nanyana zemvelo zifunwa ukunakekelwa nokugcinwa ukuze zikhazi ukufinyelela iinzukulwazi ezizako. Ziqakatheke khulu iinlwani njengomthombo wokudla, ingenismali kanye nemitjhoga. Ngalokho-ke, kufanele sizinakekele besizivikele ngaso soke isikhathi. 

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>0on7cxnb0t41bnrojxyn02l3drcxwip</sha1>
    </revision>
    <revision>
      <id>755</id>
      <parentid>754</parentid>
      <timestamp>2024-09-19T05:53:35Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>755</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5106" sha1="20m69tb8jg8vgivx0bovpm77o1d0wqv" xml:space="preserve">== Iinlwana Ezisengozini Yokutjhabalala. ==

=== Isingeniso ===
Iinlwana ngezinye zezinto ezidlala indima eqakathekileko ephasini ngokunabileko. Ilwana zidlala indima eqakathekileko kezamaphilo, ukunzinza kanye nezehlala kuhle yazo zoke izinto ephasini (Fuanalytics 2023&lt;ref name=&quot;:0&quot;&gt;Fuanalytics. 2023. ''Wild Animals''. Itholakala ku:&lt;nowiki&gt;https://faunalytics.org/fundamentals-wild-animals/?gad_source=1&amp;gclid=CjwKCAjwuMC2BhA7EiwAmJKRrMUrysChkerPZrjOHIAYZCTAFNyfCXX_CubdshvnfgH0wYDKJagapxoCTrgQAvD_BwE&lt;/nowiki&gt;. Ufunyenwe ngomhlaka [29 kuRhoboyi 2024]&lt;/ref&gt;; ne-Wikipedia 2024&lt;ref&gt;Wikipedia. 2024. ''Endangered Species''. Litholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Endangered_species&lt;/nowiki&gt;&gt;. Lifunyenwe ngomhlaka [29 kuRhoboyi 2024]&lt;/ref&gt;). Iinlwana lezi akukhethi bonyana ziinlwana zemakhaya nanyana kuz[https://faunalytics.org/fundamentals-wild-animals/?gad_source=1&amp;gclid=CjwKCAjwuMC2BhA7EiwAmJKRrMUrysChkerPZrjOHIAYZCTAFNyfCXX_CubdshvnfgH0wYDKJagapxoCTrgQAvD_BwE. iinlwana zehlathini] nanyana iimbandana nanyana iinlwana zemanzini. Nanyana kunjalo-ke, kukhona umraro lo oqalene neelwana lezi, ekukutjhabalala. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyini ukutjhabalala kweenlwana kanye nembangela yakhona. 

=== Ingabe kuyini ukutjhabalala kweenlwana na? ===
[[Isimumathi:Imaza.jpg|thumb|Imaza  ehlathini]]
Ngokuya kuka-Pizzi, u-Caroli, u-Landini, u-Galluccio, u-Mezzelani no-Milanesi (2013)&lt;ref name=&quot;:1&quot;&gt;Pizzi, F., Caroli, A. M., Landini, M., Galluccio, N., Mezzelani, A. &amp; Milanesi, L. 2013. Conservation of endangered animals: From biotechnologies to digital preservation. ''Natural Science'', 5 (8): 903-913. SciRes.&lt;/ref&gt; ne-Wikipedia (2024) iinlwana zemakhaya, zehlathini nezemanzini zizithola zihlangabezana netjhugululo lepilo. Amatjhuguluko la, abangela bonyana kubo nokuncipha kwezinye ilwani kanti ezinye zazo zigcine zingasatholakali (South African National Biodiversity Institute [I-SANBI] (2010&lt;ref name=&quot;:2&quot;&gt;South African National Biodiversity Institute. 2010. ''Threatened Species: A guide to Red Lists and their use in conservation''. Threatened Species Programme. SANBI: Pretoria.&lt;/ref&gt;). Isenzo lesi sokuncipha bekufike la zingasekho nanyana zingatholakali khona sibizwa bonyana kutjhabalala kweenlwana (I-SANBI 2010&lt;ref name=&quot;:2&quot; /&gt;; no-Pizzi ''nabanye'' 2013&lt;ref name=&quot;:1&quot; /&gt;). 

[[:en:Endangered_species|Ukutjhabalala lokhu akukhethi bonyana iinlwana]] leyo zikuyiphi iindawo; zikuliphi ibhoduluko; begodu ziphila ipilo enjani (Fuanlaytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Esikhathini esinengi iinlwana ezitjhabalalako ngilezo zendabuko nanyana zeemvelo (i-SANBI 2013&lt;ref name=&quot;:2&quot; /&gt;). Ngamanye amagama, iinlwana ezitjhabalalako kuziinlwana lezo ezivelele kilezo ndawo, begodu zijwayele ukuphila lapho ngoba kwezinye iindawo angeze zaphila. Izinto ezifaka isandla ekutjhabalaliseni kweenlwana lezi azifani begodu zihluke ngokuya kweendawo (Pizzi ''nabanye'' 2013&lt;ref name=&quot;:1&quot; /&gt;). Esihlokweni esilandelako sizokutjheja izinto ezifaka isandla ekutjhaballaliseni iinlwana nanyana iimbangela. 

=== Imbangela yokutjhabalala kweenlwazi zendabuko ===
Zinengi izinto ezibangela ukutjhabalala kweenlwani, khulukhulu zemvelo; kodwana ekulumenipendulo le, sizokutjheja ezilandelako:

=== 1.      Ibhoduluko nobujamo bezulu ===
Amatjhuguluko alethwa libhodululo nobujamo bezulu athinta kumbi imihlobo yeenlwana zoke (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;).  Lokhu kubangwa kukuthi uthola sele kutjhisa khulu nanyana kumakhaza khulu ngokudluleleko nanyana kuthatha isikhathi eside leso iinlwani ezingakghoni ukusibekezala (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Ngebanga lalokho, zigcina zihlongakala. 

=== 2.      Indlala ===
Iinlwazi ezinengi ziyathiywa begodu zithiywa ngonengi khulu ukudlula iimbalo leyo ezikghona ukuvela ngayo (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Ukungezelele, iinlwani lezi zithiyelwa ukudliwa begodu abantu abanengi abatlhagako bathembekizo njengomthombo wokudla (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Lokhu kumraro.

=== 3.      Amarhwebo namabubulo ===
Amarhwebo namabubulo enza inzunzo esikhathi esinengi asebenzisa begodu athengisa iinlwani nemikghiqizo kanye nezitho zazo (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Ngebanga lokhu amarhwebo namabubulo la sele amanengi khulu begodu adisela imindeni yeenlwana lezi, iinlwani lezi ziyancipha ezinye ziphelile begodu azisaveli (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;).

=== 4.      Ituthuko yamadorobha ===
Lokha nakwakhiwa iindawo namadorobha amatjha kususwa iindawo lapho iinlwana lezi ziphila khona begodu akukho la zifuduselwa nanyana zigcinwa khona (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Ukungezelela, ezinye zazo ziyabulawa ngomba zithathwa njengeenlwana eziyingozi (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Ngebanga lalokhu, ziyancipha begodu zigcine zitjhabalele.

=== Isiphetho ===
Iinlwana, khulukhulu zendabuko nanyana zemvelo zifunwa ukunakekelwa nokugcinwa ukuze zikhazi ukufinyelela iinzukulwazi ezizako. Ziqakatheke khulu iinlwani njengomthombo wokudla, ingenismali kanye nemitjhoga. Ngalokho-ke, kufanele sizinakekele besizivikele ngaso soke isikhathi. 

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>20m69tb8jg8vgivx0bovpm77o1d0wqv</sha1>
    </revision>
    <revision>
      <id>756</id>
      <parentid>755</parentid>
      <timestamp>2024-10-14T13:46:46Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>755</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5106" sha1="20m69tb8jg8vgivx0bovpm77o1d0wqv" xml:space="preserve">== Iinlwana Ezisengozini Yokutjhabalala. ==

=== Isingeniso ===
Iinlwana ngezinye zezinto ezidlala indima eqakathekileko ephasini ngokunabileko. Ilwana zidlala indima eqakathekileko kezamaphilo, ukunzinza kanye nezehlala kuhle yazo zoke izinto ephasini (Fuanalytics 2023&lt;ref name=&quot;:0&quot;&gt;Fuanalytics. 2023. ''Wild Animals''. Itholakala ku:&lt;nowiki&gt;https://faunalytics.org/fundamentals-wild-animals/?gad_source=1&amp;gclid=CjwKCAjwuMC2BhA7EiwAmJKRrMUrysChkerPZrjOHIAYZCTAFNyfCXX_CubdshvnfgH0wYDKJagapxoCTrgQAvD_BwE&lt;/nowiki&gt;. Ufunyenwe ngomhlaka [29 kuRhoboyi 2024]&lt;/ref&gt;; ne-Wikipedia 2024&lt;ref&gt;Wikipedia. 2024. ''Endangered Species''. Litholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Endangered_species&lt;/nowiki&gt;&gt;. Lifunyenwe ngomhlaka [29 kuRhoboyi 2024]&lt;/ref&gt;). Iinlwana lezi akukhethi bonyana ziinlwana zemakhaya nanyana kuz[https://faunalytics.org/fundamentals-wild-animals/?gad_source=1&amp;gclid=CjwKCAjwuMC2BhA7EiwAmJKRrMUrysChkerPZrjOHIAYZCTAFNyfCXX_CubdshvnfgH0wYDKJagapxoCTrgQAvD_BwE. iinlwana zehlathini] nanyana iimbandana nanyana iinlwana zemanzini. Nanyana kunjalo-ke, kukhona umraro lo oqalene neelwana lezi, ekukutjhabalala. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyini ukutjhabalala kweenlwana kanye nembangela yakhona. 

=== Ingabe kuyini ukutjhabalala kweenlwana na? ===
[[Isimumathi:Imaza.jpg|thumb|Imaza  ehlathini]]
Ngokuya kuka-Pizzi, u-Caroli, u-Landini, u-Galluccio, u-Mezzelani no-Milanesi (2013)&lt;ref name=&quot;:1&quot;&gt;Pizzi, F., Caroli, A. M., Landini, M., Galluccio, N., Mezzelani, A. &amp; Milanesi, L. 2013. Conservation of endangered animals: From biotechnologies to digital preservation. ''Natural Science'', 5 (8): 903-913. SciRes.&lt;/ref&gt; ne-Wikipedia (2024) iinlwana zemakhaya, zehlathini nezemanzini zizithola zihlangabezana netjhugululo lepilo. Amatjhuguluko la, abangela bonyana kubo nokuncipha kwezinye ilwani kanti ezinye zazo zigcine zingasatholakali (South African National Biodiversity Institute [I-SANBI] (2010&lt;ref name=&quot;:2&quot;&gt;South African National Biodiversity Institute. 2010. ''Threatened Species: A guide to Red Lists and their use in conservation''. Threatened Species Programme. SANBI: Pretoria.&lt;/ref&gt;). Isenzo lesi sokuncipha bekufike la zingasekho nanyana zingatholakali khona sibizwa bonyana kutjhabalala kweenlwana (I-SANBI 2010&lt;ref name=&quot;:2&quot; /&gt;; no-Pizzi ''nabanye'' 2013&lt;ref name=&quot;:1&quot; /&gt;). 

[[:en:Endangered_species|Ukutjhabalala lokhu akukhethi bonyana iinlwana]] leyo zikuyiphi iindawo; zikuliphi ibhoduluko; begodu ziphila ipilo enjani (Fuanlaytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Esikhathini esinengi iinlwana ezitjhabalalako ngilezo zendabuko nanyana zeemvelo (i-SANBI 2013&lt;ref name=&quot;:2&quot; /&gt;). Ngamanye amagama, iinlwana ezitjhabalalako kuziinlwana lezo ezivelele kilezo ndawo, begodu zijwayele ukuphila lapho ngoba kwezinye iindawo angeze zaphila. Izinto ezifaka isandla ekutjhabalaliseni kweenlwana lezi azifani begodu zihluke ngokuya kweendawo (Pizzi ''nabanye'' 2013&lt;ref name=&quot;:1&quot; /&gt;). Esihlokweni esilandelako sizokutjheja izinto ezifaka isandla ekutjhaballaliseni iinlwana nanyana iimbangela. 

=== Imbangela yokutjhabalala kweenlwazi zendabuko ===
Zinengi izinto ezibangela ukutjhabalala kweenlwani, khulukhulu zemvelo; kodwana ekulumenipendulo le, sizokutjheja ezilandelako:

=== 1.      Ibhoduluko nobujamo bezulu ===
Amatjhuguluko alethwa libhodululo nobujamo bezulu athinta kumbi imihlobo yeenlwana zoke (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;).  Lokhu kubangwa kukuthi uthola sele kutjhisa khulu nanyana kumakhaza khulu ngokudluleleko nanyana kuthatha isikhathi eside leso iinlwani ezingakghoni ukusibekezala (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Ngebanga lalokho, zigcina zihlongakala. 

=== 2.      Indlala ===
Iinlwazi ezinengi ziyathiywa begodu zithiywa ngonengi khulu ukudlula iimbalo leyo ezikghona ukuvela ngayo (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Ukungezelele, iinlwani lezi zithiyelwa ukudliwa begodu abantu abanengi abatlhagako bathembekizo njengomthombo wokudla (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Lokhu kumraro.

=== 3.      Amarhwebo namabubulo ===
Amarhwebo namabubulo enza inzunzo esikhathi esinengi asebenzisa begodu athengisa iinlwani nemikghiqizo kanye nezitho zazo (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Ngebanga lokhu amarhwebo namabubulo la sele amanengi khulu begodu adisela imindeni yeenlwana lezi, iinlwani lezi ziyancipha ezinye ziphelile begodu azisaveli (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;).

=== 4.      Ituthuko yamadorobha ===
Lokha nakwakhiwa iindawo namadorobha amatjha kususwa iindawo lapho iinlwana lezi ziphila khona begodu akukho la zifuduselwa nanyana zigcinwa khona (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Ukungezelela, ezinye zazo ziyabulawa ngomba zithathwa njengeenlwana eziyingozi (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Ngebanga lalokhu, ziyancipha begodu zigcine zitjhabalele.

=== Isiphetho ===
Iinlwana, khulukhulu zendabuko nanyana zemvelo zifunwa ukunakekelwa nokugcinwa ukuze zikhazi ukufinyelela iinzukulwazi ezizako. Ziqakatheke khulu iinlwani njengomthombo wokudla, ingenismali kanye nemitjhoga. Ngalokho-ke, kufanele sizinakekele besizivikele ngaso soke isikhathi. 

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>20m69tb8jg8vgivx0bovpm77o1d0wqv</sha1>
    </revision>
    <revision>
      <id>2125</id>
      <parentid>756</parentid>
      <timestamp>2024-11-25T18:16:59Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* Isilululwazi */</comment>
      <origin>2125</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5097" sha1="n230s8f621xuxiu80n7aq4dq5wqjs36" xml:space="preserve">== Iinlwana Ezisengozini Yokutjhabalala. ==

=== Isingeniso ===
Iinlwana ngezinye zezinto ezidlala indima eqakathekileko ephasini ngokunabileko. Ilwana zidlala indima eqakathekileko kezamaphilo, ukunzinza kanye nezehlala kuhle yazo zoke izinto ephasini (Fuanalytics 2023&lt;ref name=&quot;:0&quot;&gt;Fuanalytics. 2023. ''Wild Animals''. Itholakala ku:&lt;nowiki&gt;https://faunalytics.org/fundamentals-wild-animals/?gad_source=1&amp;gclid=CjwKCAjwuMC2BhA7EiwAmJKRrMUrysChkerPZrjOHIAYZCTAFNyfCXX_CubdshvnfgH0wYDKJagapxoCTrgQAvD_BwE&lt;/nowiki&gt;. Ufunyenwe ngomhlaka [29 kuRhoboyi 2024]&lt;/ref&gt;; ne-Wikipedia 2024&lt;ref&gt;Wikipedia. 2024. ''Endangered Species''. Litholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Endangered_species&lt;/nowiki&gt;&gt;. Lifunyenwe ngomhlaka [29 kuRhoboyi 2024]&lt;/ref&gt;). Iinlwana lezi akukhethi bonyana ziinlwana zemakhaya nanyana kuz[https://faunalytics.org/fundamentals-wild-animals/?gad_source=1&amp;gclid=CjwKCAjwuMC2BhA7EiwAmJKRrMUrysChkerPZrjOHIAYZCTAFNyfCXX_CubdshvnfgH0wYDKJagapxoCTrgQAvD_BwE. iinlwana zehlathini] nanyana iimbandana nanyana iinlwana zemanzini. Nanyana kunjalo-ke, kukhona umraro lo oqalene neelwana lezi, ekukutjhabalala. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyini ukutjhabalala kweenlwana kanye nembangela yakhona. 

=== Ingabe kuyini ukutjhabalala kweenlwana na? ===
[[Isimumathi:Imaza.jpg|thumb|Imaza  ehlathini]]
Ngokuya kuka-Pizzi, u-Caroli, u-Landini, u-Galluccio, u-Mezzelani no-Milanesi (2013)&lt;ref name=&quot;:1&quot;&gt;Pizzi, F., Caroli, A. M., Landini, M., Galluccio, N., Mezzelani, A. &amp; Milanesi, L. 2013. Conservation of endangered animals: From biotechnologies to digital preservation. ''Natural Science'', 5 (8): 903-913. SciRes.&lt;/ref&gt; ne-Wikipedia (2024) iinlwana zemakhaya, zehlathini nezemanzini zizithola zihlangabezana netjhugululo lepilo. Amatjhuguluko la, abangela bonyana kubo nokuncipha kwezinye ilwani kanti ezinye zazo zigcine zingasatholakali (South African National Biodiversity Institute [I-SANBI] (2010&lt;ref name=&quot;:2&quot;&gt;South African National Biodiversity Institute. 2010. ''Threatened Species: A guide to Red Lists and their use in conservation''. Threatened Species Programme. SANBI: Pretoria.&lt;/ref&gt;). Isenzo lesi sokuncipha bekufike la zingasekho nanyana zingatholakali khona sibizwa bonyana kutjhabalala kweenlwana (I-SANBI 2010&lt;ref name=&quot;:2&quot; /&gt;; no-Pizzi ''nabanye'' 2013&lt;ref name=&quot;:1&quot; /&gt;). 

[[:en:Endangered_species|Ukutjhabalala lokhu akukhethi bonyana iinlwana]] leyo zikuyiphi iindawo; zikuliphi ibhoduluko; begodu ziphila ipilo enjani (Fuanlaytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Esikhathini esinengi iinlwana ezitjhabalalako ngilezo zendabuko nanyana zeemvelo (i-SANBI 2013&lt;ref name=&quot;:2&quot; /&gt;). Ngamanye amagama, iinlwana ezitjhabalalako kuziinlwana lezo ezivelele kilezo ndawo, begodu zijwayele ukuphila lapho ngoba kwezinye iindawo angeze zaphila. Izinto ezifaka isandla ekutjhabalaliseni kweenlwana lezi azifani begodu zihluke ngokuya kweendawo (Pizzi ''nabanye'' 2013&lt;ref name=&quot;:1&quot; /&gt;). Esihlokweni esilandelako sizokutjheja izinto ezifaka isandla ekutjhaballaliseni iinlwana nanyana iimbangela. 

=== Imbangela yokutjhabalala kweenlwazi zendabuko ===
Zinengi izinto ezibangela ukutjhabalala kweenlwani, khulukhulu zemvelo; kodwana ekulumenipendulo le, sizokutjheja ezilandelako:

=== 1.      Ibhoduluko nobujamo bezulu ===
Amatjhuguluko alethwa libhodululo nobujamo bezulu athinta kumbi imihlobo yeenlwana zoke (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;).  Lokhu kubangwa kukuthi uthola sele kutjhisa khulu nanyana kumakhaza khulu ngokudluleleko nanyana kuthatha isikhathi eside leso iinlwani ezingakghoni ukusibekezala (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Ngebanga lalokho, zigcina zihlongakala. 

=== 2.      Indlala ===
Iinlwazi ezinengi ziyathiywa begodu zithiywa ngonengi khulu ukudlula iimbalo leyo ezikghona ukuvela ngayo (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Ukungezelele, iinlwani lezi zithiyelwa ukudliwa begodu abantu abanengi abatlhagako bathembekizo njengomthombo wokudla (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Lokhu kumraro.

=== 3.      Amarhwebo namabubulo ===
Amarhwebo namabubulo enza inzunzo esikhathi esinengi asebenzisa begodu athengisa iinlwani nemikghiqizo kanye nezitho zazo (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Ngebanga lokhu amarhwebo namabubulo la sele amanengi khulu begodu adisela imindeni yeenlwana lezi, iinlwani lezi ziyancipha ezinye ziphelile begodu azisaveli (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;).

=== 4.      Ituthuko yamadorobha ===
Lokha nakwakhiwa iindawo namadorobha amatjha kususwa iindawo lapho iinlwana lezi ziphila khona begodu akukho la zifuduselwa nanyana zigcinwa khona (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Ukungezelela, ezinye zazo ziyabulawa ngomba zithathwa njengeenlwana eziyingozi (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Ngebanga lalokhu, ziyancipha begodu zigcine zitjhabalele.

=== Isiphetho ===
Iinlwana, khulukhulu zendabuko nanyana zemvelo zifunwa ukunakekelwa nokugcinwa ukuze zikhazi ukufinyelela iinzukulwazi ezizako. Ziqakatheke khulu iinlwani njengomthombo wokudla, ingenismali kanye nemitjhoga. Ngalokho-ke, kufanele sizinakekele besizivikele ngaso soke isikhathi. 

== Iinkomba ==
{{Reflist}}</text>
      <sha1>n230s8f621xuxiu80n7aq4dq5wqjs36</sha1>
    </revision>
    <revision>
      <id>4032</id>
      <parentid>2125</parentid>
      <timestamp>2025-08-07T07:29:42Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <origin>4032</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5033" sha1="r4mxn8von4hdyr5np4o6wkr8ox1snpe" xml:space="preserve">Iinlwana ngezinye zezinto ezidlala indima eqakathekileko ephasini ngokunabileko. Ilwana zidlala indima eqakathekileko kezamaphilo, ukunzinza kanye nezehlala kuhle yazo zoke izinto ephasini (Fuanalytics 2023&lt;ref name=&quot;:0&quot;&gt;Fuanalytics. 2023. ''Wild Animals''. Itholakala ku:&lt;nowiki&gt;https://faunalytics.org/fundamentals-wild-animals/?gad_source=1&amp;gclid=CjwKCAjwuMC2BhA7EiwAmJKRrMUrysChkerPZrjOHIAYZCTAFNyfCXX_CubdshvnfgH0wYDKJagapxoCTrgQAvD_BwE&lt;/nowiki&gt;. Ufunyenwe ngomhlaka [29 kuRhoboyi 2024]&lt;/ref&gt;; ne-Wikipedia 2024&lt;ref&gt;Wikipedia. 2024. ''Endangered Species''. Litholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Endangered_species&lt;/nowiki&gt;&gt;. Lifunyenwe ngomhlaka [29 kuRhoboyi 2024]&lt;/ref&gt;). Iinlwana lezi akukhethi bonyana ziinlwana zemakhaya nanyana kuz[https://faunalytics.org/fundamentals-wild-animals/?gad_source=1&amp;gclid=CjwKCAjwuMC2BhA7EiwAmJKRrMUrysChkerPZrjOHIAYZCTAFNyfCXX_CubdshvnfgH0wYDKJagapxoCTrgQAvD_BwE. iinlwana zehlathini] nanyana iimbandana nanyana iinlwana zemanzini. Nanyana kunjalo-ke, kukhona umraro lo oqalene neelwana lezi, ekukutjhabalala. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyini ukutjhabalala kweenlwana kanye nembangela yakhona. 

=== Ingabe kuyini ukutjhabalala kweenlwana na? ===
[[Isimumathi:Imaza.jpg|thumb|Imaza  ehlathini]]
Ngokuya kuka-Pizzi, u-Caroli, u-Landini, u-Galluccio, u-Mezzelani no-Milanesi (2013)&lt;ref name=&quot;:1&quot;&gt;Pizzi, F., Caroli, A. M., Landini, M., Galluccio, N., Mezzelani, A. &amp; Milanesi, L. 2013. Conservation of endangered animals: From biotechnologies to digital preservation. ''Natural Science'', 5 (8): 903-913. SciRes.&lt;/ref&gt; ne-Wikipedia (2024) iinlwana zemakhaya, zehlathini nezemanzini zizithola zihlangabezana netjhugululo lepilo. Amatjhuguluko la, abangela bonyana kubo nokuncipha kwezinye ilwani kanti ezinye zazo zigcine zingasatholakali (South African National Biodiversity Institute [I-SANBI] (2010&lt;ref name=&quot;:2&quot;&gt;South African National Biodiversity Institute. 2010. ''Threatened Species: A guide to Red Lists and their use in conservation''. Threatened Species Programme. SANBI: Pretoria.&lt;/ref&gt;). Isenzo lesi sokuncipha bekufike la zingasekho nanyana zingatholakali khona sibizwa bonyana kutjhabalala kweenlwana (I-SANBI 2010&lt;ref name=&quot;:2&quot; /&gt;; no-Pizzi ''nabanye'' 2013&lt;ref name=&quot;:1&quot; /&gt;). 

[[:en:Endangered_species|Ukutjhabalala lokhu akukhethi bonyana iinlwana]] leyo zikuyiphi iindawo; zikuliphi ibhoduluko; begodu ziphila ipilo enjani (Fuanlaytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Esikhathini esinengi iinlwana ezitjhabalalako ngilezo zendabuko nanyana zeemvelo (i-SANBI 2013&lt;ref name=&quot;:2&quot; /&gt;). Ngamanye amagama, iinlwana ezitjhabalalako kuziinlwana lezo ezivelele kilezo ndawo, begodu zijwayele ukuphila lapho ngoba kwezinye iindawo angeze zaphila. Izinto ezifaka isandla ekutjhabalaliseni kweenlwana lezi azifani begodu zihluke ngokuya kweendawo (Pizzi ''nabanye'' 2013&lt;ref name=&quot;:1&quot; /&gt;). Esihlokweni esilandelako sizokutjheja izinto ezifaka isandla ekutjhaballaliseni iinlwana nanyana iimbangela. 

=== Imbangela yokutjhabalala kweenlwazi zendabuko ===
Zinengi izinto ezibangela ukutjhabalala kweenlwani, khulukhulu zemvelo; kodwana ekulumenipendulo le, sizokutjheja ezilandelako:

=== 1.      Ibhoduluko nobujamo bezulu ===
Amatjhuguluko alethwa libhodululo nobujamo bezulu athinta kumbi imihlobo yeenlwana zoke (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;).  Lokhu kubangwa kukuthi uthola sele kutjhisa khulu nanyana kumakhaza khulu ngokudluleleko nanyana kuthatha isikhathi eside leso iinlwani ezingakghoni ukusibekezala (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Ngebanga lalokho, zigcina zihlongakala. 

=== 2.      Indlala ===
Iinlwazi ezinengi ziyathiywa begodu zithiywa ngonengi khulu ukudlula iimbalo leyo ezikghona ukuvela ngayo (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Ukungezelele, iinlwani lezi zithiyelwa ukudliwa begodu abantu abanengi abatlhagako bathembekizo njengomthombo wokudla (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Lokhu kumraro.

=== 3.      Amarhwebo namabubulo ===
Amarhwebo namabubulo enza inzunzo esikhathi esinengi asebenzisa begodu athengisa iinlwani nemikghiqizo kanye nezitho zazo (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Ngebanga lokhu amarhwebo namabubulo la sele amanengi khulu begodu adisela imindeni yeenlwana lezi, iinlwani lezi ziyancipha ezinye ziphelile begodu azisaveli (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;).

=== 4.      Ituthuko yamadorobha ===
Lokha nakwakhiwa iindawo namadorobha amatjha kususwa iindawo lapho iinlwana lezi ziphila khona begodu akukho la zifuduselwa nanyana zigcinwa khona (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Ukungezelela, ezinye zazo ziyabulawa ngomba zithathwa njengeenlwana eziyingozi (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Ngebanga lalokhu, ziyancipha begodu zigcine zitjhabalele.

=== Isiphetho ===
Iinlwana, khulukhulu zendabuko nanyana zemvelo zifunwa ukunakekelwa nokugcinwa ukuze zikhazi ukufinyelela iinzukulwazi ezizako. Ziqakatheke khulu iinlwani njengomthombo wokudla, ingenismali kanye nemitjhoga. Ngalokho-ke, kufanele sizinakekele besizivikele ngaso soke isikhathi. 

== Iinkomba ==
{{Reflist}}</text>
      <sha1>r4mxn8von4hdyr5np4o6wkr8ox1snpe</sha1>
    </revision>
    <revision>
      <id>6682</id>
      <parentid>4032</parentid>
      <timestamp>2026-06-09T15:51:16Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <origin>6682</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5017" sha1="9yb90nqvw2mtuj1x58inqg4e8w5zow7" xml:space="preserve">'''Iinlwana''' ngezinye zezinto ezidlala indima eqakathekileko ephasini ngokunabileko. Ilwana zidlala indima eqakathekileko kezamaphilo, ukunzinza kanye nezehlala kuhle yazo zoke izinto ephasini (Fuanalytics 2023&lt;ref name=&quot;:0&quot;&gt;Fuanalytics. 2023. ''Wild Animals''. Itholakala ku:&lt;nowiki&gt;https://faunalytics.org/fundamentals-wild-animals/?gad_source=1&amp;gclid=CjwKCAjwuMC2BhA7EiwAmJKRrMUrysChkerPZrjOHIAYZCTAFNyfCXX_CubdshvnfgH0wYDKJagapxoCTrgQAvD_BwE&lt;/nowiki&gt;. Ufunyenwe ngomhlaka [29 kuRhoboyi 2024]&lt;/ref&gt;; ne-Wikipedia 2024&lt;ref&gt;Wikipedia. 2024. ''Endangered Species''. Litholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Endangered_species&lt;/nowiki&gt;&gt;. Lifunyenwe ngomhlaka [29 kuRhoboyi 2024]&lt;/ref&gt;). Iinlwana lezi akukhethi bonyana ziinlwana zemakhaya nanyana kuz[https://faunalytics.org/fundamentals-wild-animals/?gad_source=1&amp;gclid=CjwKCAjwuMC2BhA7EiwAmJKRrMUrysChkerPZrjOHIAYZCTAFNyfCXX_CubdshvnfgH0wYDKJagapxoCTrgQAvD_BwE. iinlwana zehlathini] nanyana iimbandana nanyana iinlwana zemanzini. Nanyana kunjalo-ke, kukhona umraro lo oqalene neelwana lezi, ekukutjhabalala. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyini ukutjhabalala kweenlwana kanye nembangela yakhona. 

== Ingabe kuyini ukutjhabalala kweenlwana na? ==
[[Isimumathi:Imaza.jpg|thumb|Imaza  ehlathini]]
Ngokuya kuka-Pizzi, u-Caroli, u-Landini, u-Galluccio, u-Mezzelani no-Milanesi (2013)&lt;ref name=&quot;:1&quot;&gt;Pizzi, F., Caroli, A. M., Landini, M., Galluccio, N., Mezzelani, A. &amp; Milanesi, L. 2013. Conservation of endangered animals: From biotechnologies to digital preservation. ''Natural Science'', 5 (8): 903-913. SciRes.&lt;/ref&gt; ne-Wikipedia (2024) iinlwana zemakhaya, zehlathini nezemanzini zizithola zihlangabezana netjhugululo lepilo. Amatjhuguluko la, abangela bonyana kubo nokuncipha kwezinye ilwani kanti ezinye zazo zigcine zingasatholakali (South African National Biodiversity Institute [I-SANBI] (2010&lt;ref name=&quot;:2&quot;&gt;South African National Biodiversity Institute. 2010. ''Threatened Species: A guide to Red Lists and their use in conservation''. Threatened Species Programme. SANBI: Pretoria.&lt;/ref&gt;). Isenzo lesi sokuncipha bekufike la zingasekho nanyana zingatholakali khona sibizwa bonyana kutjhabalala kweenlwana (I-SANBI 2010&lt;ref name=&quot;:2&quot; /&gt;; no-Pizzi ''nabanye'' 2013&lt;ref name=&quot;:1&quot; /&gt;). 

[[:en:Endangered_species|Ukutjhabalala lokhu akukhethi bonyana iinlwana]] leyo zikuyiphi iindawo; zikuliphi ibhoduluko; begodu ziphila ipilo enjani (Fuanlaytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Esikhathini esinengi iinlwana ezitjhabalalako ngilezo zendabuko nanyana zeemvelo (i-SANBI 2013&lt;ref name=&quot;:2&quot; /&gt;). Ngamanye amagama, iinlwana ezitjhabalalako kuziinlwana lezo ezivelele kilezo ndawo, begodu zijwayele ukuphila lapho ngoba kwezinye iindawo angeze zaphila. Izinto ezifaka isandla ekutjhabalaliseni kweenlwana lezi azifani begodu zihluke ngokuya kweendawo (Pizzi ''nabanye'' 2013&lt;ref name=&quot;:1&quot; /&gt;). Esihlokweni esilandelako sizokutjheja izinto ezifaka isandla ekutjhaballaliseni iinlwana nanyana iimbangela. 

== Imbangela yokutjhabalala kweenlwazi zendabuko ==
Zinengi izinto ezibangela ukutjhabalala kweenlwani, khulukhulu zemvelo; kodwana ekulumenipendulo le, sizokutjheja ezilandelako:

=== 1.      Ibhoduluko nobujamo bezulu ===
Amatjhuguluko alethwa libhodululo nobujamo bezulu athinta kumbi imihlobo yeenlwana zoke (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;).  Lokhu kubangwa kukuthi uthola sele kutjhisa khulu nanyana kumakhaza khulu ngokudluleleko nanyana kuthatha isikhathi eside leso iinlwani ezingakghoni ukusibekezala (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Ngebanga lalokho, zigcina zihlongakala. 

=== 2.      Indlala ===
Iinlwazi ezinengi ziyathiywa begodu zithiywa ngonengi khulu ukudlula iimbalo leyo ezikghona ukuvela ngayo (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Ukungezelele, iinlwani lezi zithiyelwa ukudliwa begodu abantu abanengi abatlhagako bathembekizo njengomthombo wokudla (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Lokhu kumraro.

=== 3.      Amarhwebo namabubulo ===
Amarhwebo namabubulo enza inzunzo esikhathi esinengi asebenzisa begodu athengisa iinlwani nemikghiqizo kanye nezitho zazo (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Ngebanga lokhu amarhwebo namabubulo la sele amanengi khulu begodu adisela imindeni yeenlwana lezi, iinlwani lezi ziyancipha ezinye ziphelile begodu azisaveli (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;).

=== 4.      Ituthuko yamadorobha ===
Lokha nakwakhiwa iindawo namadorobha amatjha kususwa iindawo lapho iinlwana lezi ziphila khona begodu akukho la zifuduselwa nanyana zigcinwa khona (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Ukungezelela, ezinye zazo ziyabulawa ngomba zithathwa njengeenlwana eziyingozi (Fuanalytics 2023&lt;ref name=&quot;:0&quot; /&gt;). Ngebanga lalokhu, ziyancipha begodu zigcine zitjhabalele.

Iinlwana, khulukhulu zendabuko nanyana zemvelo zifunwa ukunakekelwa nokugcinwa ukuze zikhazi ukufinyelela iinzukulwazi ezizako. Ziqakatheke khulu iinlwani njengomthombo wokudla, ingenismali kanye nemitjhoga. Ngalokho-ke, kufanele sizinakekele besizivikele ngaso soke isikhathi. 

== Iinkomba ==
{{Reflist}}</text>
      <sha1>9yb90nqvw2mtuj1x58inqg4e8w5zow7</sha1>
    </revision>
  </page>
  <page>
    <title>Iinthuthi</title>
    <ns>0</ns>
    <id>156</id>
    <revision>
      <id>757</id>
      <timestamp>2024-09-14T10:02:45Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;== Iinthuthi ==  === Isingeniso === [[:en:Transport|Iinthuthi]] zizinto lezo ezithutha izinto ezifana nabantu, iinlwani neesetjenziswa ukusuka kwenye indawo ukuya kwenye indawo (Wikipedia 2024&lt;ref name=&quot;:0&quot;&gt;Wikipedia.2024. ''Transport''. Litholakala ku :&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Transport&lt;/nowiki&gt;&gt;. Lifunyenwe ngomhlaka [13 kuRhoboyi 2024].&lt;/ref&gt;). Imihlobo yeenthuthi ifaka iinthuthi zemoyeni, zaphasi (indlela neentimela), nezemanzini.  === Imihlobo yeenthut...&quot;</comment>
      <origin>757</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2596" sha1="6bvwaztc1ia5w234wlcmbx38syasw08" xml:space="preserve">== Iinthuthi ==

=== Isingeniso ===
[[:en:Transport|Iinthuthi]] zizinto lezo ezithutha izinto ezifana nabantu, iinlwani neesetjenziswa ukusuka kwenye indawo ukuya kwenye indawo (Wikipedia 2024&lt;ref name=&quot;:0&quot;&gt;Wikipedia.2024. ''Transport''. Litholakala ku :&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Transport&lt;/nowiki&gt;&gt;. Lifunyenwe ngomhlaka [13 kuRhoboyi 2024].&lt;/ref&gt;). Imihlobo yeenthuthi ifaka iinthuthi zemoyeni, zaphasi (indlela neentimela), nezemanzini.

=== Imihlobo yeenthuthi ===
Intuthi zemoyeni zifaka iimphaphamtjhini neembhanoyi. (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;) Iimphaphamtjhini ziinthuthi ezikhamba emoyeni begodu esikhathini esinengi zitholakala edoyelweni leemphaphatjhini (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;). Kanti-ke, iimbhanoyi zona kanti zisebenziswa babantu neenkhaphani zangeqadi. Nazo iimbhanoyi zikhamba emoyeni. Esikhanini esinengi zisebenza ukuthutha abantu, iinlwana neensetjenziswa.

Iinthuthi zaphasi, kuziinthuthi lezo ekhamba phasi, ekufaka indlala neentimela (Ahjum, Merven, Stone no-Caetano 2018&lt;ref&gt;Ahjum, F., Merven, B., Stone, A. &amp; Caetano, T. 2018. Road transport vehicles in South Africa towards 2050: Factors influencing technology choice and implications for fuel supply. ''Journal of Energy in Southern Africa'', 29(3): 33–50.&lt;/ref&gt;). Iinthuthi lezi zisetjengiswa miphakathi neenkamphani zangeqadi ukuthutha abantu, iimpahla, iseentjenziswa, iinlwani nezinye izinto (Bartneck 2021&lt;ref&gt;Bartneck, C. 2021.  ''An Introduction to Ethics in Robotics and AI''. Springer Briefs in Ethics.&lt;/ref&gt;). Kukhona iinthuthi ezisebenzisa imbaseli ezihlukeneko, ezifaka hlangana ipethroli nedizili (Scurt, Vesselenyi, Tarca, Beles no-Dragomir 2021&lt;ref&gt;Scurt, F. B., Vesselenyi, T., Tarca, R. C., Beles, H. &amp; Dragomir. 2021. Autonomous vehicles: Classification, technology and evolution. IOP Conference Series: ''Material Science and Engineering'',:1-8.&lt;/ref&gt;). Iinthuthi zaphasi zona zingahlukaniswa ngale indlela: isitimela, ibhesi teksi, ikoloyi kanye netsikiri.

Iinthuthi zemanzi zona, kuziinthuthi lezo ezikhamba emanzini lezo ezisetjenzisa babantu, umphakath, umbuzo kanye neekhamphani zangeqadi (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;). Iinthuthi lezi zona zisetjenziselwa imisebenzi eminingi leyo efana nokuthuthwa abantu, iimpahla, iinsetjenziswa kanye neenlwazi. Iinthuthi zemanzini lezi zona zihlukene kanengi zifaka lezi: iinkepe nemikhumbi.

=== Isiphetho ===
Iinthuthi ngizo zoke izinto lezo ezisetjenziswa ukuthutha izinto ukusuka endaweni enye ukuya kwenye. Inthuthi lezo zingasebenzisa iimbaseli ukukhamba nanyana angawasebenzini.

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>6bvwaztc1ia5w234wlcmbx38syasw08</sha1>
    </revision>
    <revision>
      <id>758</id>
      <parentid>757</parentid>
      <timestamp>2024-10-14T13:46:46Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>757</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2596" sha1="6bvwaztc1ia5w234wlcmbx38syasw08" xml:space="preserve">== Iinthuthi ==

=== Isingeniso ===
[[:en:Transport|Iinthuthi]] zizinto lezo ezithutha izinto ezifana nabantu, iinlwani neesetjenziswa ukusuka kwenye indawo ukuya kwenye indawo (Wikipedia 2024&lt;ref name=&quot;:0&quot;&gt;Wikipedia.2024. ''Transport''. Litholakala ku :&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Transport&lt;/nowiki&gt;&gt;. Lifunyenwe ngomhlaka [13 kuRhoboyi 2024].&lt;/ref&gt;). Imihlobo yeenthuthi ifaka iinthuthi zemoyeni, zaphasi (indlela neentimela), nezemanzini.

=== Imihlobo yeenthuthi ===
Intuthi zemoyeni zifaka iimphaphamtjhini neembhanoyi. (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;) Iimphaphamtjhini ziinthuthi ezikhamba emoyeni begodu esikhathini esinengi zitholakala edoyelweni leemphaphatjhini (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;). Kanti-ke, iimbhanoyi zona kanti zisebenziswa babantu neenkhaphani zangeqadi. Nazo iimbhanoyi zikhamba emoyeni. Esikhanini esinengi zisebenza ukuthutha abantu, iinlwana neensetjenziswa.

Iinthuthi zaphasi, kuziinthuthi lezo ekhamba phasi, ekufaka indlala neentimela (Ahjum, Merven, Stone no-Caetano 2018&lt;ref&gt;Ahjum, F., Merven, B., Stone, A. &amp; Caetano, T. 2018. Road transport vehicles in South Africa towards 2050: Factors influencing technology choice and implications for fuel supply. ''Journal of Energy in Southern Africa'', 29(3): 33–50.&lt;/ref&gt;). Iinthuthi lezi zisetjengiswa miphakathi neenkamphani zangeqadi ukuthutha abantu, iimpahla, iseentjenziswa, iinlwani nezinye izinto (Bartneck 2021&lt;ref&gt;Bartneck, C. 2021.  ''An Introduction to Ethics in Robotics and AI''. Springer Briefs in Ethics.&lt;/ref&gt;). Kukhona iinthuthi ezisebenzisa imbaseli ezihlukeneko, ezifaka hlangana ipethroli nedizili (Scurt, Vesselenyi, Tarca, Beles no-Dragomir 2021&lt;ref&gt;Scurt, F. B., Vesselenyi, T., Tarca, R. C., Beles, H. &amp; Dragomir. 2021. Autonomous vehicles: Classification, technology and evolution. IOP Conference Series: ''Material Science and Engineering'',:1-8.&lt;/ref&gt;). Iinthuthi zaphasi zona zingahlukaniswa ngale indlela: isitimela, ibhesi teksi, ikoloyi kanye netsikiri.

Iinthuthi zemanzi zona, kuziinthuthi lezo ezikhamba emanzini lezo ezisetjenzisa babantu, umphakath, umbuzo kanye neekhamphani zangeqadi (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;). Iinthuthi lezi zona zisetjenziselwa imisebenzi eminingi leyo efana nokuthuthwa abantu, iimpahla, iinsetjenziswa kanye neenlwazi. Iinthuthi zemanzini lezi zona zihlukene kanengi zifaka lezi: iinkepe nemikhumbi.

=== Isiphetho ===
Iinthuthi ngizo zoke izinto lezo ezisetjenziswa ukuthutha izinto ukusuka endaweni enye ukuya kwenye. Inthuthi lezo zingasebenzisa iimbaseli ukukhamba nanyana angawasebenzini.

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>6bvwaztc1ia5w234wlcmbx38syasw08</sha1>
    </revision>
    <revision>
      <id>2527</id>
      <parentid>758</parentid>
      <timestamp>2025-03-12T21:12:36Z</timestamp>
      <contributor>
        <ip>88.241.77.194</ip>
      </contributor>
      <origin>2527</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2641" sha1="afsskxevkn5tc0gjy45yt9fwqpmfseb" xml:space="preserve">== Iinthuthi ==

=== Isingeniso ===
[[:en:Transport|Iinthuthi]] zizinto lezo ezithutha izinto ezifana nabantu, iinlwani neesetjenziswa ukusuka kwenye indawo ukuya kwenye indawo (Wikipedia 2024&lt;ref name=&quot;:0&quot;&gt;Wikipedia.2024. ''Transport''. Litholakala ku :&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Transport&lt;/nowiki&gt;&gt;. Lifunyenwe ngomhlaka [13 kuRhoboyi 2024].&lt;/ref&gt;). Imihlobo yeenthuthi ifaka iinthuthi zemoyeni, zaphasi (indlela neentimela), nezemanzini.

=== Imihlobo yeenthuthi ===
Intuthi zemoyeni zifaka iimphaphamtjhini neembhanoyi. (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;) Iimphaphamtjhini ziinthuthi ezikhamba emoyeni begodu esikhathini esinengi zitholakala edoyelweni leemphaphatjhini (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;). Kanti-ke, iimbhanoyi zona kanti zisebenziswa babantu neenkhaphani zangeqadi. Nazo iimbhanoyi zikhamba emoyeni. Esikhanini esinengi zisebenza ukuthutha abantu, iinlwana neensetjenziswa.

Iinthuthi zaphasi, kuziinthuthi lezo ekhamba phasi, ekufaka indlala neentimela (Ahjum, Merven, Stone no-Caetano 2018&lt;ref&gt;Ahjum, F., Merven, B., Stone, A. &amp; Caetano, T. 2018. Road transport vehicles in South Africa towards 2050: Factors influencing technology choice and implications for fuel supply. ''Journal of Energy in Southern Africa'', 29(3): 33–50.&lt;/ref&gt;). Iinthuthi lezi zisetjengiswa miphakathi neenkamphani zangeqadi ukuthutha abantu, iimpahla, iseentjenziswa, iinlwani nezinye izinto (Bartneck 2021&lt;ref&gt;Bartneck, C. 2021.  ''An Introduction to Ethics in Robotics and AI''. Springer Briefs in Ethics.&lt;/ref&gt;). Kukhona iinthuthi ezisebenzisa imbaseli ezihlukeneko, ezifaka hlangana ipethroli nedizili (Scurt, Vesselenyi, Tarca, Beles no-Dragomir 2021&lt;ref&gt;Scurt, F. B., Vesselenyi, T., Tarca, R. C., Beles, H. &amp; Dragomir. 2021. Autonomous vehicles: Classification, technology and evolution. IOP Conference Series: ''Material Science and Engineering'',:1-8.&lt;/ref&gt;). Iinthuthi zaphasi zona zingahlukaniswa ngale indlela: isitimela, ibhesi teksi, ikoloyi kanye netsikiri.

Iinthuthi zemanzi zona, kuziinthuthi lezo ezikhamba emanzini lezo ezisetjenzisa babantu, umphakath, umbuzo kanye neekhamphani zangeqadi (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;). Iinthuthi lezi zona zisetjenziselwa imisebenzi eminingi leyo efana nokuthuthwa abantu, iimpahla, iinsetjenziswa kanye neenlwazi. Iinthuthi zemanzini lezi zona zihlukene kanengi zifaka lezi: iinkepe nemikhumbi.

=== Isiphetho ===
Iinthuthi ngizo zoke izinto lezo ezisetjenziswa ukuthutha izinto ukusuka endaweni enye ukuya kwenye. Inthuthi lezo zingasebenzisa iimbaseli ukukhamba nanyana angawasebenzini. [https://www.kargosubesi.biz/ kargo şubesi]

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>afsskxevkn5tc0gjy45yt9fwqpmfseb</sha1>
    </revision>
    <revision>
      <id>2975</id>
      <parentid>2527</parentid>
      <timestamp>2025-06-06T20:03:28Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>szerxdtcfg hjnkm</comment>
      <origin>2975</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2729" sha1="rpjwyy1kphkha859p0e45qwubav4am7" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.'''

== Iinthuthi ==

=== Isingeniso ===
[[:en:Transport|Iinthuthi]] zizinto lezo ezithutha izinto ezifana nabantu, iinlwani neesetjenziswa ukusuka kwenye indawo ukuya kwenye indawo (Wikipedia 2024&lt;ref name=&quot;:0&quot;&gt;Wikipedia.2024. ''Transport''. Litholakala ku :&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Transport&lt;/nowiki&gt;&gt;. Lifunyenwe ngomhlaka [13 kuRhoboyi 2024].&lt;/ref&gt;). Imihlobo yeenthuthi ifaka iinthuthi zemoyeni, zaphasi (indlela neentimela), nezemanzini.

=== Imihlobo yeenthuthi ===
Intuthi zemoyeni zifaka iimphaphamtjhini neembhanoyi. (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;) Iimphaphamtjhini ziinthuthi ezikhamba emoyeni begodu esikhathini esinengi zitholakala edoyelweni leemphaphatjhini (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;). Kanti-ke, iimbhanoyi zona kanti zisebenziswa babantu neenkhaphani zangeqadi. Nazo iimbhanoyi zikhamba emoyeni. Esikhanini esinengi zisebenza ukuthutha abantu, iinlwana neensetjenziswa.

Iinthuthi zaphasi, kuziinthuthi lezo ekhamba phasi, ekufaka indlala neentimela (Ahjum, Merven, Stone no-Caetano 2018&lt;ref&gt;Ahjum, F., Merven, B., Stone, A. &amp; Caetano, T. 2018. Road transport vehicles in South Africa towards 2050: Factors influencing technology choice and implications for fuel supply. ''Journal of Energy in Southern Africa'', 29(3): 33–50.&lt;/ref&gt;). Iinthuthi lezi zisetjengiswa miphakathi neenkamphani zangeqadi ukuthutha abantu, iimpahla, iseentjenziswa, iinlwani nezinye izinto (Bartneck 2021&lt;ref&gt;Bartneck, C. 2021.  ''An Introduction to Ethics in Robotics and AI''. Springer Briefs in Ethics.&lt;/ref&gt;). Kukhona iinthuthi ezisebenzisa imbaseli ezihlukeneko, ezifaka hlangana ipethroli nedizili (Scurt, Vesselenyi, Tarca, Beles no-Dragomir 2021&lt;ref&gt;Scurt, F. B., Vesselenyi, T., Tarca, R. C., Beles, H. &amp; Dragomir. 2021. Autonomous vehicles: Classification, technology and evolution. IOP Conference Series: ''Material Science and Engineering'',:1-8.&lt;/ref&gt;). Iinthuthi zaphasi zona zingahlukaniswa ngale indlela: isitimela, ibhesi teksi, ikoloyi kanye netsikiri.

Iinthuthi zemanzi zona, kuziinthuthi lezo ezikhamba emanzini lezo ezisetjenzisa babantu, umphakath, umbuzo kanye neekhamphani zangeqadi (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;). Iinthuthi lezi zona zisetjenziselwa imisebenzi eminingi leyo efana nokuthuthwa abantu, iimpahla, iinsetjenziswa kanye neenlwazi. Iinthuthi zemanzini lezi zona zihlukene kanengi zifaka lezi: iinkepe nemikhumbi.

=== Isiphetho ===
Iinthuthi ngizo zoke izinto lezo ezisetjenziswa ukuthutha izinto ukusuka endaweni enye ukuya kwenye. Inthuthi lezo zingasebenzisa iimbaseli ukukhamba nanyana angawasebenzini. [https://www.kargosubesi.biz/ kargo şubesi]

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>rpjwyy1kphkha859p0e45qwubav4am7</sha1>
    </revision>
    <revision>
      <id>3099</id>
      <parentid>2975</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:88.241.77.194|88.241.77.194]]</comment>
      <origin>2527</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2641" sha1="afsskxevkn5tc0gjy45yt9fwqpmfseb" xml:space="preserve">== Iinthuthi ==

=== Isingeniso ===
[[:en:Transport|Iinthuthi]] zizinto lezo ezithutha izinto ezifana nabantu, iinlwani neesetjenziswa ukusuka kwenye indawo ukuya kwenye indawo (Wikipedia 2024&lt;ref name=&quot;:0&quot;&gt;Wikipedia.2024. ''Transport''. Litholakala ku :&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Transport&lt;/nowiki&gt;&gt;. Lifunyenwe ngomhlaka [13 kuRhoboyi 2024].&lt;/ref&gt;). Imihlobo yeenthuthi ifaka iinthuthi zemoyeni, zaphasi (indlela neentimela), nezemanzini.

=== Imihlobo yeenthuthi ===
Intuthi zemoyeni zifaka iimphaphamtjhini neembhanoyi. (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;) Iimphaphamtjhini ziinthuthi ezikhamba emoyeni begodu esikhathini esinengi zitholakala edoyelweni leemphaphatjhini (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;). Kanti-ke, iimbhanoyi zona kanti zisebenziswa babantu neenkhaphani zangeqadi. Nazo iimbhanoyi zikhamba emoyeni. Esikhanini esinengi zisebenza ukuthutha abantu, iinlwana neensetjenziswa.

Iinthuthi zaphasi, kuziinthuthi lezo ekhamba phasi, ekufaka indlala neentimela (Ahjum, Merven, Stone no-Caetano 2018&lt;ref&gt;Ahjum, F., Merven, B., Stone, A. &amp; Caetano, T. 2018. Road transport vehicles in South Africa towards 2050: Factors influencing technology choice and implications for fuel supply. ''Journal of Energy in Southern Africa'', 29(3): 33–50.&lt;/ref&gt;). Iinthuthi lezi zisetjengiswa miphakathi neenkamphani zangeqadi ukuthutha abantu, iimpahla, iseentjenziswa, iinlwani nezinye izinto (Bartneck 2021&lt;ref&gt;Bartneck, C. 2021.  ''An Introduction to Ethics in Robotics and AI''. Springer Briefs in Ethics.&lt;/ref&gt;). Kukhona iinthuthi ezisebenzisa imbaseli ezihlukeneko, ezifaka hlangana ipethroli nedizili (Scurt, Vesselenyi, Tarca, Beles no-Dragomir 2021&lt;ref&gt;Scurt, F. B., Vesselenyi, T., Tarca, R. C., Beles, H. &amp; Dragomir. 2021. Autonomous vehicles: Classification, technology and evolution. IOP Conference Series: ''Material Science and Engineering'',:1-8.&lt;/ref&gt;). Iinthuthi zaphasi zona zingahlukaniswa ngale indlela: isitimela, ibhesi teksi, ikoloyi kanye netsikiri.

Iinthuthi zemanzi zona, kuziinthuthi lezo ezikhamba emanzini lezo ezisetjenzisa babantu, umphakath, umbuzo kanye neekhamphani zangeqadi (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;). Iinthuthi lezi zona zisetjenziselwa imisebenzi eminingi leyo efana nokuthuthwa abantu, iimpahla, iinsetjenziswa kanye neenlwazi. Iinthuthi zemanzini lezi zona zihlukene kanengi zifaka lezi: iinkepe nemikhumbi.

=== Isiphetho ===
Iinthuthi ngizo zoke izinto lezo ezisetjenziswa ukuthutha izinto ukusuka endaweni enye ukuya kwenye. Inthuthi lezo zingasebenzisa iimbaseli ukukhamba nanyana angawasebenzini. [https://www.kargosubesi.biz/ kargo şubesi]

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>afsskxevkn5tc0gjy45yt9fwqpmfseb</sha1>
    </revision>
    <revision>
      <id>6482</id>
      <parentid>3099</parentid>
      <timestamp>2026-04-24T18:45:03Z</timestamp>
      <contributor>
        <username>~2026-25087-89</username>
        <id>1481</id>
      </contributor>
      <origin>6482</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2647" sha1="nqxizj1jhv9lslymxxgmjob02whs7di" xml:space="preserve">== Iinthuthi ==

=== Isingeniso ===
[[:en:Transport|Iinthuthi]] zizinto lezo ezithutha izinto ezifana nabantu, iinlwani neesetjenziswa ukusuka kwenye indawo ukuya kwenye indawo (Wikipedia 2024&lt;ref name=&quot;:0&quot;&gt;Wikipedia.2024. ''Transport''. Litholakala ku :&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Transport&lt;/nowiki&gt;&gt;. Lifunyenwe ngomhlaka [13 kuRhoboyi 2024].&lt;/ref&gt;). Imihlobo yeenthuthi ifaka iinthuthi zemoyeni, zaphasi (indlela neentimela), nezemanzini.

=== Imihlobo yeenthuthi ===
Intuthi zemoyeni zifaka iimphaphamtjhini neembhanoyi. (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;) Iimphaphamtjhini ziinthuthi ezikhamba emoyeni begodu esikhathini esinengi zitholakala edoyelweni leemphaphatjhini (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;). Kanti-ke, iimbhanoyi zona kanti zisebenziswa babantu neenkhaphani zangeqadi. Nazo iimbhanoyi zikhamba emoyeni. Esikhanini esinengi zisebenza ukuthutha abantu, iinlwana neensetjenziswa.

Iinthuthi zaphasi, kuziinthuthi lezo ekhamba phasi, ekufaka indlala neentimela (Ahjum, Merven, Stone no-Caetano 2018&lt;ref&gt;Ahjum, F., Merven, B., Stone, A. &amp; Caetano, T. 2018. Road transport vehicles in South Africa towards 2050: Factors influencing technology choice and implications for fuel supply. ''Journal of Energy in Southern Africa'', 29(3): 33–50.&lt;/ref&gt;). Iinthuthi lezi zisetjengiswa miphakathi neenkamphani zangeqadi ukuthutha abantu, iimpahla, iseentjenziswa, iinlwani nezinye izinto (Bartneck 2021&lt;ref&gt;Bartneck, C. 2021.  ''An Introduction to Ethics in Robotics and AI''. Springer Briefs in Ethics.&lt;/ref&gt;). Kukhona iinthuthi ezisebenzisa imbaseli ezihlukeneko, ezifaka hlangana ipethroli nedizili (Scurt, Vesselenyi, Tarca, Beles no-Dragomir 2021&lt;ref&gt;Scurt, F. B., Vesselenyi, T., Tarca, R. C., Beles, H. &amp; Dragomir. 2021. Autonomous vehicles: Classification, technology and evolution. IOP Conference Series: ''Material Science and Engineering'',:1-8.&lt;/ref&gt;). Iinthuthi zaphasi zona zingahlukaniswa ngale indlela: isitimela, ibhesi teksi, ikoloyi kanye netsikiri.

Iinthuthi zemanzi zona, kuziinthuthi lezo ezikhamba emanzini lezo ezisetjenzisa babantu, umphakath, umbuzo kanye neekhamphani zangeqadi (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;). Iinthuthi lezi zona zisetjenziselwa imisebenzi eminingi leyo efana nokuthuthwa abantu, iimpahla, iinsetjenziswa kanye neenlwazi. Iinthuthi zemanzini lezi zona zihlukene kanengi zifaka lezi: iinkepe nemikhumbi.

=== Isiphetho ===
Iinthuthi ngizo zoke izinto lezo ezisetjenziswa ukuthutha izinto ukusuka endaweni enye ukuya kwenye. Inthuthi lezo zingasebenzisa iimbaseli ukukhamba nanyana angawasebenzini. [https://yazi-stilleri.net.tr/tr-1 yazı stilleri]

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>nqxizj1jhv9lslymxxgmjob02whs7di</sha1>
    </revision>
    <revision>
      <id>6494</id>
      <parentid>6482</parentid>
      <timestamp>2026-05-13T18:41:01Z</timestamp>
      <contributor>
        <username>Icodense</username>
        <id>494</id>
      </contributor>
      <comment>-linkspam</comment>
      <origin>6494</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2596" sha1="6bvwaztc1ia5w234wlcmbx38syasw08" xml:space="preserve">== Iinthuthi ==

=== Isingeniso ===
[[:en:Transport|Iinthuthi]] zizinto lezo ezithutha izinto ezifana nabantu, iinlwani neesetjenziswa ukusuka kwenye indawo ukuya kwenye indawo (Wikipedia 2024&lt;ref name=&quot;:0&quot;&gt;Wikipedia.2024. ''Transport''. Litholakala ku :&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Transport&lt;/nowiki&gt;&gt;. Lifunyenwe ngomhlaka [13 kuRhoboyi 2024].&lt;/ref&gt;). Imihlobo yeenthuthi ifaka iinthuthi zemoyeni, zaphasi (indlela neentimela), nezemanzini.

=== Imihlobo yeenthuthi ===
Intuthi zemoyeni zifaka iimphaphamtjhini neembhanoyi. (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;) Iimphaphamtjhini ziinthuthi ezikhamba emoyeni begodu esikhathini esinengi zitholakala edoyelweni leemphaphatjhini (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;). Kanti-ke, iimbhanoyi zona kanti zisebenziswa babantu neenkhaphani zangeqadi. Nazo iimbhanoyi zikhamba emoyeni. Esikhanini esinengi zisebenza ukuthutha abantu, iinlwana neensetjenziswa.

Iinthuthi zaphasi, kuziinthuthi lezo ekhamba phasi, ekufaka indlala neentimela (Ahjum, Merven, Stone no-Caetano 2018&lt;ref&gt;Ahjum, F., Merven, B., Stone, A. &amp; Caetano, T. 2018. Road transport vehicles in South Africa towards 2050: Factors influencing technology choice and implications for fuel supply. ''Journal of Energy in Southern Africa'', 29(3): 33–50.&lt;/ref&gt;). Iinthuthi lezi zisetjengiswa miphakathi neenkamphani zangeqadi ukuthutha abantu, iimpahla, iseentjenziswa, iinlwani nezinye izinto (Bartneck 2021&lt;ref&gt;Bartneck, C. 2021.  ''An Introduction to Ethics in Robotics and AI''. Springer Briefs in Ethics.&lt;/ref&gt;). Kukhona iinthuthi ezisebenzisa imbaseli ezihlukeneko, ezifaka hlangana ipethroli nedizili (Scurt, Vesselenyi, Tarca, Beles no-Dragomir 2021&lt;ref&gt;Scurt, F. B., Vesselenyi, T., Tarca, R. C., Beles, H. &amp; Dragomir. 2021. Autonomous vehicles: Classification, technology and evolution. IOP Conference Series: ''Material Science and Engineering'',:1-8.&lt;/ref&gt;). Iinthuthi zaphasi zona zingahlukaniswa ngale indlela: isitimela, ibhesi teksi, ikoloyi kanye netsikiri.

Iinthuthi zemanzi zona, kuziinthuthi lezo ezikhamba emanzini lezo ezisetjenzisa babantu, umphakath, umbuzo kanye neekhamphani zangeqadi (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;). Iinthuthi lezi zona zisetjenziselwa imisebenzi eminingi leyo efana nokuthuthwa abantu, iimpahla, iinsetjenziswa kanye neenlwazi. Iinthuthi zemanzini lezi zona zihlukene kanengi zifaka lezi: iinkepe nemikhumbi.

=== Isiphetho ===
Iinthuthi ngizo zoke izinto lezo ezisetjenziswa ukuthutha izinto ukusuka endaweni enye ukuya kwenye. Inthuthi lezo zingasebenzisa iimbaseli ukukhamba nanyana angawasebenzini.

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>6bvwaztc1ia5w234wlcmbx38syasw08</sha1>
    </revision>
    <revision>
      <id>6667</id>
      <parentid>6494</parentid>
      <timestamp>2026-06-06T12:24:54Z</timestamp>
      <contributor>
        <username>~2026-33315-61</username>
        <id>1554</id>
      </contributor>
      <origin>6667</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2661" sha1="9o6fvv5w48hsxaz6l57yyavy68vtm6u" xml:space="preserve">[[Isimumathi:Manchester Transport Montage.jpg|thumb|291x291px]]

== Iinthuthi ==

=== Isingeniso ===
[[:en:Transport|Iinthuthi]] zizinto lezo ezithutha izinto ezifana nabantu, iinlwani neesetjenziswa ukusuka kwenye indawo ukuya kwenye indawo (Wikipedia 2024&lt;ref name=&quot;:0&quot;&gt;Wikipedia.2024. ''Transport''. Litholakala ku :&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Transport&lt;/nowiki&gt;&gt;. Lifunyenwe ngomhlaka [13 kuRhoboyi 2024].&lt;/ref&gt;). Imihlobo yeenthuthi ifaka iinthuthi zemoyeni, zaphasi (indlela neentimela), nezemanzini.

=== Imihlobo yeenthuthi ===
Intuthi zemoyeni zifaka iimphaphamtjhini neembhanoyi. (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;) Iimphaphamtjhini ziinthuthi ezikhamba emoyeni begodu esikhathini esinengi zitholakala edoyelweni leemphaphatjhini (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;). Kanti-ke, iimbhanoyi zona kanti zisebenziswa babantu neenkhaphani zangeqadi. Nazo iimbhanoyi zikhamba emoyeni. Esikhanini esinengi zisebenza ukuthutha abantu, iinlwana neensetjenziswa.

Iinthuthi zaphasi, kuziinthuthi lezo ekhamba phasi, ekufaka indlala neentimela (Ahjum, Merven, Stone no-Caetano 2018&lt;ref&gt;Ahjum, F., Merven, B., Stone, A. &amp; Caetano, T. 2018. Road transport vehicles in South Africa towards 2050: Factors influencing technology choice and implications for fuel supply. ''Journal of Energy in Southern Africa'', 29(3): 33–50.&lt;/ref&gt;). Iinthuthi lezi zisetjengiswa miphakathi neenkamphani zangeqadi ukuthutha abantu, iimpahla, iseentjenziswa, iinlwani nezinye izinto (Bartneck 2021&lt;ref&gt;Bartneck, C. 2021.  ''An Introduction to Ethics in Robotics and AI''. Springer Briefs in Ethics.&lt;/ref&gt;). Kukhona iinthuthi ezisebenzisa imbaseli ezihlukeneko, ezifaka hlangana ipethroli nedizili (Scurt, Vesselenyi, Tarca, Beles no-Dragomir 2021&lt;ref&gt;Scurt, F. B., Vesselenyi, T., Tarca, R. C., Beles, H. &amp; Dragomir. 2021. Autonomous vehicles: Classification, technology and evolution. IOP Conference Series: ''Material Science and Engineering'',:1-8.&lt;/ref&gt;). Iinthuthi zaphasi zona zingahlukaniswa ngale indlela: isitimela, ibhesi teksi, ikoloyi kanye netsikiri.

Iinthuthi zemanzi zona, kuziinthuthi lezo ezikhamba emanzini lezo ezisetjenzisa babantu, umphakath, umbuzo kanye neekhamphani zangeqadi (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;). Iinthuthi lezi zona zisetjenziselwa imisebenzi eminingi leyo efana nokuthuthwa abantu, iimpahla, iinsetjenziswa kanye neenlwazi. Iinthuthi zemanzini lezi zona zihlukene kanengi zifaka lezi: iinkepe nemikhumbi.

=== Isiphetho ===
Iinthuthi ngizo zoke izinto lezo ezisetjenziswa ukuthutha izinto ukusuka endaweni enye ukuya kwenye. Inthuthi lezo zingasebenzisa iimbaseli ukukhamba nanyana angawasebenzini.

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>9o6fvv5w48hsxaz6l57yyavy68vtm6u</sha1>
    </revision>
  </page>
  <page>
    <title>Iintjalo Ezisengozini Yokutjhabalala</title>
    <ns>0</ns>
    <id>157</id>
    <revision>
      <id>759</id>
      <timestamp>2024-09-14T10:25:13Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;== Iintjalo Ezisengozini Yokutjhabalala ==  === Isingeniso === Iintjalo nemithi esiphila hlangana nayo nanyana etholaka endaweni zangekhethu iqakatheke khulu. Kunemisebenzi eminengi eyenzako ukuze siphile upilo ehle nephephileko. Nanyana kunjalo, kunomraro wokutjhabala kweentjalo nemithi enarheni yoke zombelele (Pfab no-Victor 2002&lt;ref name=&quot;:0&quot;&gt;Pfab, M. F. &amp; Victor, J. E. Threatened plants of Gauteng, South Africa. ''South African Journal of Botany'', 68:370-375.&lt;/ref&gt;;...&quot;</comment>
      <origin>759</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6562" sha1="m8v5sibi92uoz1lz0xappi64rtl5ivb" xml:space="preserve">== Iintjalo Ezisengozini Yokutjhabalala ==

=== Isingeniso ===
Iintjalo nemithi esiphila hlangana nayo nanyana etholaka endaweni zangekhethu iqakatheke khulu. Kunemisebenzi eminengi eyenzako ukuze siphile upilo ehle nephephileko. Nanyana kunjalo, kunomraro wokutjhabala kweentjalo nemithi enarheni yoke zombelele (Pfab no-Victor 2002&lt;ref name=&quot;:0&quot;&gt;Pfab, M. F. &amp; Victor, J. E. Threatened plants of Gauteng, South Africa. ''South African Journal of Botany'', 68:370-375.&lt;/ref&gt;; ne-Wikipedia 2024&lt;ref name=&quot;:1&quot;&gt;Wikipedia. 2024. ''List of critically endangered plants''. Litholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/List_of_critically_endangered_plants&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [12 kuRhoboyi 2024].&lt;/ref&gt;). Ngokuya kuka-Stohlgren no-Kumar (2013:205)&lt;ref name=&quot;:2&quot;&gt;Stohlgren, T. T. &amp; Kumar, S. 2013. Endangered Plants. ''Encyclopedia of Biodiversity'', 3: 465-477. Elsevier.&lt;/ref&gt;  ama-% ama-95 ukuya kuma-% ama-99 wemithi neenjalo ezikhethekileko ebe zikhona ngaphambili nje sele zingasekho nayana ziseduze nokungasabi khona. Ibelo leli ezitjhabalala ngalo ngilo elithusa abatlhogomeli bemvelo nanyana bendabuko (Stohlgren noKumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Ngamanye amagama, ukutjhabalala kweentjalo nemithi bekuvele kukhona kodwana nje umraro kukuthi zitjhabalala ngebelo eliphezulu khulu begodu kubudisi ukulilawula. Eenhlokwaneni ezilandelako sizokutjheja bonyana sikhuluma ngani nasikhuluma ngokutjhabalala kweentjalo nemithi begodi sibuye sitjheje nembangela nanyana isithintela esibanga ukutjhalala kwemithi neentjalo lokhu. 

=== Sikhuluma ngani nasikhuluma ngokutjhabalala kweentjalo nemithi na? ===
I-South African National Biodiversity Institute (I-SANBI) [2010&lt;ref name=&quot;:3&quot;&gt;South African National Biodiversity Institute. 2010. ''Threatened Species: A guide to Red Lists and their use in conservation''. Threatened Species Programme. SANBI: Pretoria.&lt;/ref&gt;] yathi, kukhona iinjalo nemithi, khulukhulu yendabuko nanyana yemvelo leyo  ekhamba inyamala ngemva kwesikhathi. Ngokuya kwebonelophambili, imithi neentjalo le ekhamba inyamala ilinginiselwa een-2 553 eSewula Afrika kwaphela (SANBI 2013&lt;ref&gt;South African National Biodiversity Institute. 2013. ''Plants in Peril''. SANBI: Biodiversity for Life: Pretoria.&lt;/ref&gt;). Ukungezelela, iintjalo lezo nemithi kufikelwa lapho zingasatholakali khona ngemva kokunyamela (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;; ne-Wikipedia 2024&lt;ref name=&quot;:1&quot; /&gt;). Ukunyamela kweentjalo nemithi lokhu bezingasatholakali kubizwa bonyana kutjhabalala kweentjalo nemithi (SANBI 2010&lt;ref name=&quot;:3&quot; /&gt;). 

[[:en:List_of_critically_endangered_plants|Ukutjhabalala kweentjalo nemithi]] lokhu kubangelwa zizinto ezuhlukileko begodu nebelo lokutjhabalala kwazo akufani. Kukhona ezinye ezitjhabalala ngebelo eliphezulu, khulukhulu lezo ezitholakala emadorobheni bese kube nalezo ezitjhabalala ngebelo elingasiphezulu khulu (Pfab no-Victor 2002&lt;ref name=&quot;:0&quot; /&gt;). 

Esikhathini esinengi iintjalo nemithi etjhabalalako ngileyo yendabuko begodu ekhethekileko leyo engatholakali koke (Pfab no-Victor 2002&lt;ref name=&quot;:0&quot; /&gt;; no-Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Ngokuya kuka-Stohlgren no-Kumar (2013)&lt;ref name=&quot;:2&quot; /&gt; basekelwa yi-SANBI (2010)&lt;ref name=&quot;:3&quot; /&gt;, iintjalo nemithi yendabuko nanyana yemvelo le, ibongazimbi abakhulu tle ngebanga lokuthi ukhona ukuphila endaweni yelo nanyana evelele kiyo begodu iphilo yayo ikhambelana nebhduluko lendawo lelo. Ngamanye amagama, ihlabathi, amanzi, umoya nebujamo bezulu obuhlukileko bakwezinye iindawo abukalungeli iinjalo nemithi yendabuko le. Esihlokweni esilandelako sizokutjheja iimbangela zokutjhabalalisa iintjalo nemithi.

=== Imbangelo yokuhlabalala kwemithi neentjalo ===
Zinengi iimbangela ezibanga ukutjhabalala kwemithi neentjalo esele zitshwaye babantu abanengi iphasi loke leli. Kodwana, kulekulumopendulwano sizokudzimelela kwezilandelako:

==== 1.      Ukutlhayela kweendawo zazo ====
Ukutlhayela kweendawo la iintjalo nemithi yendabuko ingaphila khona kumraro omukhulu (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Iintjalo nemithi le izithola ingasakhoni ukunaba kanye nokukhula ngebanga lokuthi iindawo zazo ziyancipha begodi akusenasikhala la zinganabela nanyana zikhulele khona (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;).

==== 2.      Izenzo zabantu ====
Izenzo zabantu zinomthintela omkhulu tle okutjhabalaleni kweentjalo nemithi yendabuko. Ngokuya kuka-Stohlgren no-Kumar (2013) &lt;ref name=&quot;:2&quot; /&gt;izenzo zabantu ezifana nokutheza, ukugubha iinjalo kanye nokutjhisa amahlathi notjani zidlala indima ekulu ekutjhabalaleni kweentjalo nemithi yendabuko. Ngamanye amagama, nabatheza bebaguba iintjalo kodwana bangazitjali nanyana bazijamiselele kubanga ukutjhabalala kwemithi neentjalo ngombana ziyanciba nabenza njalo.

==== 3.      Ituthuko yezehlalakuhle. ====
Kunetuthuko enengi khulu eyenzeka mihla namalanga ephasi esiphila kiyo (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). U-Stohlgren no-Kumar (2013) &lt;ref name=&quot;:2&quot; /&gt;baveze bonyana abantu nabakha iindawo ezitjha, imakhiwo kanye namadorobha amatjha, basusa imithi neentjalo zendabuko endaweni lezo begodu abalingi ukuzifudusela nanyana ukuzibulunga. Lokhu kufaka isandla ekutjhabalaliseni iintjalo nemithi.

==== 4.      Amabubulo namarhwebo ====
Amabubulo namarhwebo asebenzisa iintjalo nemithi yendabuko ukukhiqhiza imikhiqhizo ebayithengisako, kodwana abanandaba nokobanyana imithi neentjalo leyo iyaphela begodu ifuna ukujamiselwela ngokuthi batjale eminye (Stohlgren no-Kumar 2013)&lt;ref name=&quot;:2&quot; /&gt;. Lokhu nakho kudlala indima ekulu ekutjhabalaliseleni iintjalo nemithi.

==== 5.      Itjhuguluko lebhoduluko ====
Itjhuguluko lebhoduluko ekufaka hlangana ubujamo bezulu lobo obutjhugulula iinkathi nezinga ebenza ngakho izinto kumraro khulu eentjalweni nemithi yendabuko (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Ukungezelela, imithi neentjalo lezo zizithola zibhalela kuphila ngaphasi kwetjhugululo lebhoduluko nelobujamo bezulu elitjha lelo (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Ngamanye amagama, lokha nakutjhisa ngendlela ongakajwaleki isikhathi eside nanyana kumakhaza khulu isikhathi eside ukudlula ngenjayelo ngebanga lamatjhuguluko webhoduluko nanyana wobujamo bezulu, iintjalo nemithi yendabuko le igcina ihlongakala begodu ingasamili.

=== Isiphetho ===
Ukutjhabalala kweentjalo nemithi yendabuko yinto embi nenomthelela omumbi eempilweni zethu ngombana kuzokuba nokudla nemitjhaga ebesiyinikelwa mimithi neentjalo lezo engasazokutholakala. Ngalokho-ke, kuqakathekile bonyana sinakele zoke iintjalo nemithi, khulukhulu yendabuko.

Isilululwazi
&lt;references /&gt;
.</text>
      <sha1>m8v5sibi92uoz1lz0xappi64rtl5ivb</sha1>
    </revision>
    <revision>
      <id>760</id>
      <parentid>759</parentid>
      <timestamp>2024-09-19T05:59:57Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>760</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6707" sha1="bgo0n78zpyqoq3pgantzkv4aacp8gc4" xml:space="preserve">[[Isimumathi:Isirhorhopha.jpg|thumb|Isirhorhopha]]

== Iintjalo Ezisengozini Yokutjhabalala ==

=== Isingeniso ===
Iintjalo nemithi esiphila hlangana nayo nanyana etholaka endaweni zangekhethu iqakatheke khulu. Kunemisebenzi eminengi eyenzako ukuze siphile upilo ehle nephephileko. Nanyana kunjalo, kunomraro wokutjhabala kweentjalo nemithi enarheni yoke zombelele (Pfab no-Victor 2002&lt;ref name=&quot;:0&quot;&gt;Pfab, M. F. &amp; Victor, J. E. Threatened plants of Gauteng, South Africa. ''South African Journal of Botany'', 68:370-375.&lt;/ref&gt;; ne-Wikipedia 2024&lt;ref name=&quot;:1&quot;&gt;Wikipedia. 2024. ''List of critically endangered plants''. Litholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/List_of_critically_endangered_plants&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [12 kuRhoboyi 2024].&lt;/ref&gt;). Ngokuya kuka-Stohlgren no-Kumar (2013:205)&lt;ref name=&quot;:2&quot;&gt;Stohlgren, T. T. &amp; Kumar, S. 2013. Endangered Plants. ''Encyclopedia of Biodiversity'', 3: 465-477. Elsevier.&lt;/ref&gt;  ama-% ama-95 ukuya kuma-% ama-99 wemithi neenjalo ezikhethekileko ebe zikhona ngaphambili nje sele zingasekho nayana ziseduze nokungasabi khona. Ibelo leli ezitjhabalala ngalo ngilo elithusa abatlhogomeli bemvelo nanyana bendabuko (Stohlgren noKumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Ngamanye amagama, ukutjhabalala kweentjalo nemithi bekuvele kukhona kodwana nje umraro kukuthi zitjhabalala ngebelo eliphezulu khulu begodu kubudisi ukulilawula. Eenhlokwaneni ezilandelako sizokutjheja bonyana sikhuluma ngani nasikhuluma ngokutjhabalala kweentjalo nemithi begodi sibuye sitjheje nembangela nanyana isithintela esibanga ukutjhalala kwemithi neentjalo lokhu. 

=== Sikhuluma ngani nasikhuluma ngokutjhabalala kweentjalo nemithi na? ===
[[Isimumathi:Ithuthumbo.jpg|left|thumb|Ithuthumbo]]
I-South African National Biodiversity Institute (I-SANBI) [2010&lt;ref name=&quot;:3&quot;&gt;South African National Biodiversity Institute. 2010. ''Threatened Species: A guide to Red Lists and their use in conservation''. Threatened Species Programme. SANBI: Pretoria.&lt;/ref&gt;] yathi, kukhona iinjalo nemithi, khulukhulu yendabuko nanyana yemvelo leyo  ekhamba inyamala ngemva kwesikhathi. Ngokuya kwebonelophambili, imithi neentjalo le ekhamba inyamala ilinginiselwa een-2 553 eSewula Afrika kwaphela (SANBI 2013&lt;ref&gt;South African National Biodiversity Institute. 2013. ''Plants in Peril''. SANBI: Biodiversity for Life: Pretoria.&lt;/ref&gt;). Ukungezelela, iintjalo lezo nemithi kufikelwa lapho zingasatholakali khona ngemva kokunyamela (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;; ne-Wikipedia 2024&lt;ref name=&quot;:1&quot; /&gt;). Ukunyamela kweentjalo nemithi lokhu bezingasatholakali kubizwa bonyana kutjhabalala kweentjalo nemithi (SANBI 2010&lt;ref name=&quot;:3&quot; /&gt;). 

[[:en:List_of_critically_endangered_plants|Ukutjhabalala kweentjalo nemithi]] lokhu kubangelwa zizinto ezuhlukileko begodu nebelo lokutjhabalala kwazo akufani. Kukhona ezinye ezitjhabalala ngebelo eliphezulu, khulukhulu lezo ezitholakala emadorobheni bese kube nalezo ezitjhabalala ngebelo elingasiphezulu khulu (Pfab no-Victor 2002&lt;ref name=&quot;:0&quot; /&gt;). 

Esikhathini esinengi iintjalo nemithi etjhabalalako ngileyo yendabuko begodu ekhethekileko leyo engatholakali koke (Pfab no-Victor 2002&lt;ref name=&quot;:0&quot; /&gt;; no-Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Ngokuya kuka-Stohlgren no-Kumar (2013)&lt;ref name=&quot;:2&quot; /&gt; basekelwa yi-SANBI (2010)&lt;ref name=&quot;:3&quot; /&gt;, iintjalo nemithi yendabuko nanyana yemvelo le, ibongazimbi abakhulu tle ngebanga lokuthi ukhona ukuphila endaweni yelo nanyana evelele kiyo begodu iphilo yayo ikhambelana nebhduluko lendawo lelo. Ngamanye amagama, ihlabathi, amanzi, umoya nebujamo bezulu obuhlukileko bakwezinye iindawo abukalungeli iinjalo nemithi yendabuko le. Esihlokweni esilandelako sizokutjheja iimbangela zokutjhabalalisa iintjalo nemithi.

=== Imbangelo yokuhlabalala kwemithi neentjalo ===
Zinengi iimbangela ezibanga ukutjhabalala kwemithi neentjalo esele zitshwaye babantu abanengi iphasi loke leli. Kodwana, kulekulumopendulwano sizokudzimelela kwezilandelako:

==== 1.      Ukutlhayela kweendawo zazo ====
[[Isimumathi:Umomori.jpg|thumb|Umomori]]
Ukutlhayela kweendawo la iintjalo nemithi yendabuko ingaphila khona kumraro omukhulu (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Iintjalo nemithi le izithola ingasakhoni ukunaba kanye nokukhula ngebanga lokuthi iindawo zazo ziyancipha begodi akusenasikhala la zinganabela nanyana zikhulele khona (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;).

==== 2.      Izenzo zabantu ====
Izenzo zabantu zinomthintela omkhulu tle okutjhabalaleni kweentjalo nemithi yendabuko. Ngokuya kuka-Stohlgren no-Kumar (2013) &lt;ref name=&quot;:2&quot; /&gt;izenzo zabantu ezifana nokutheza, ukugubha iinjalo kanye nokutjhisa amahlathi notjani zidlala indima ekulu ekutjhabalaleni kweentjalo nemithi yendabuko. Ngamanye amagama, nabatheza bebaguba iintjalo kodwana bangazitjali nanyana bazijamiselele kubanga ukutjhabalala kwemithi neentjalo ngombana ziyanciba nabenza njalo.

==== 3.      Ituthuko yezehlalakuhle. ====
Kunetuthuko enengi khulu eyenzeka mihla namalanga ephasi esiphila kiyo (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). U-Stohlgren no-Kumar (2013) &lt;ref name=&quot;:2&quot; /&gt;baveze bonyana abantu nabakha iindawo ezitjha, imakhiwo kanye namadorobha amatjha, basusa imithi neentjalo zendabuko endaweni lezo begodu abalingi ukuzifudusela nanyana ukuzibulunga. Lokhu kufaka isandla ekutjhabalaliseni iintjalo nemithi.

==== 4.      Amabubulo namarhwebo ====
Amabubulo namarhwebo asebenzisa iintjalo nemithi yendabuko ukukhiqhiza imikhiqhizo ebayithengisako, kodwana abanandaba nokobanyana imithi neentjalo leyo iyaphela begodu ifuna ukujamiselwela ngokuthi batjale eminye (Stohlgren no-Kumar 2013)&lt;ref name=&quot;:2&quot; /&gt;. Lokhu nakho kudlala indima ekulu ekutjhabalaliseleni iintjalo nemithi.

==== 5.      Itjhuguluko lebhoduluko ====
Itjhuguluko lebhoduluko ekufaka hlangana ubujamo bezulu lobo obutjhugulula iinkathi nezinga ebenza ngakho izinto kumraro khulu eentjalweni nemithi yendabuko (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Ukungezelela, imithi neentjalo lezo zizithola zibhalela kuphila ngaphasi kwetjhugululo lebhoduluko nelobujamo bezulu elitjha lelo (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Ngamanye amagama, lokha nakutjhisa ngendlela ongakajwaleki isikhathi eside nanyana kumakhaza khulu isikhathi eside ukudlula ngenjayelo ngebanga lamatjhuguluko webhoduluko nanyana wobujamo bezulu, iintjalo nemithi yendabuko le igcina ihlongakala begodu ingasamili.

=== Isiphetho ===
Ukutjhabalala kweentjalo nemithi yendabuko yinto embi nenomthelela omumbi eempilweni zethu ngombana kuzokuba nokudla nemitjhaga ebesiyinikelwa mimithi neentjalo lezo engasazokutholakala. Ngalokho-ke, kuqakathekile bonyana sinakele zoke iintjalo nemithi, khulukhulu yendabuko.

Isilululwazi
&lt;references /&gt;
.</text>
      <sha1>bgo0n78zpyqoq3pgantzkv4aacp8gc4</sha1>
    </revision>
    <revision>
      <id>761</id>
      <parentid>760</parentid>
      <timestamp>2024-10-14T13:46:46Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>760</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6707" sha1="bgo0n78zpyqoq3pgantzkv4aacp8gc4" xml:space="preserve">[[Isimumathi:Isirhorhopha.jpg|thumb|Isirhorhopha]]

== Iintjalo Ezisengozini Yokutjhabalala ==

=== Isingeniso ===
Iintjalo nemithi esiphila hlangana nayo nanyana etholaka endaweni zangekhethu iqakatheke khulu. Kunemisebenzi eminengi eyenzako ukuze siphile upilo ehle nephephileko. Nanyana kunjalo, kunomraro wokutjhabala kweentjalo nemithi enarheni yoke zombelele (Pfab no-Victor 2002&lt;ref name=&quot;:0&quot;&gt;Pfab, M. F. &amp; Victor, J. E. Threatened plants of Gauteng, South Africa. ''South African Journal of Botany'', 68:370-375.&lt;/ref&gt;; ne-Wikipedia 2024&lt;ref name=&quot;:1&quot;&gt;Wikipedia. 2024. ''List of critically endangered plants''. Litholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/List_of_critically_endangered_plants&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [12 kuRhoboyi 2024].&lt;/ref&gt;). Ngokuya kuka-Stohlgren no-Kumar (2013:205)&lt;ref name=&quot;:2&quot;&gt;Stohlgren, T. T. &amp; Kumar, S. 2013. Endangered Plants. ''Encyclopedia of Biodiversity'', 3: 465-477. Elsevier.&lt;/ref&gt;  ama-% ama-95 ukuya kuma-% ama-99 wemithi neenjalo ezikhethekileko ebe zikhona ngaphambili nje sele zingasekho nayana ziseduze nokungasabi khona. Ibelo leli ezitjhabalala ngalo ngilo elithusa abatlhogomeli bemvelo nanyana bendabuko (Stohlgren noKumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Ngamanye amagama, ukutjhabalala kweentjalo nemithi bekuvele kukhona kodwana nje umraro kukuthi zitjhabalala ngebelo eliphezulu khulu begodu kubudisi ukulilawula. Eenhlokwaneni ezilandelako sizokutjheja bonyana sikhuluma ngani nasikhuluma ngokutjhabalala kweentjalo nemithi begodi sibuye sitjheje nembangela nanyana isithintela esibanga ukutjhalala kwemithi neentjalo lokhu. 

=== Sikhuluma ngani nasikhuluma ngokutjhabalala kweentjalo nemithi na? ===
[[Isimumathi:Ithuthumbo.jpg|left|thumb|Ithuthumbo]]
I-South African National Biodiversity Institute (I-SANBI) [2010&lt;ref name=&quot;:3&quot;&gt;South African National Biodiversity Institute. 2010. ''Threatened Species: A guide to Red Lists and their use in conservation''. Threatened Species Programme. SANBI: Pretoria.&lt;/ref&gt;] yathi, kukhona iinjalo nemithi, khulukhulu yendabuko nanyana yemvelo leyo  ekhamba inyamala ngemva kwesikhathi. Ngokuya kwebonelophambili, imithi neentjalo le ekhamba inyamala ilinginiselwa een-2 553 eSewula Afrika kwaphela (SANBI 2013&lt;ref&gt;South African National Biodiversity Institute. 2013. ''Plants in Peril''. SANBI: Biodiversity for Life: Pretoria.&lt;/ref&gt;). Ukungezelela, iintjalo lezo nemithi kufikelwa lapho zingasatholakali khona ngemva kokunyamela (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;; ne-Wikipedia 2024&lt;ref name=&quot;:1&quot; /&gt;). Ukunyamela kweentjalo nemithi lokhu bezingasatholakali kubizwa bonyana kutjhabalala kweentjalo nemithi (SANBI 2010&lt;ref name=&quot;:3&quot; /&gt;). 

[[:en:List_of_critically_endangered_plants|Ukutjhabalala kweentjalo nemithi]] lokhu kubangelwa zizinto ezuhlukileko begodu nebelo lokutjhabalala kwazo akufani. Kukhona ezinye ezitjhabalala ngebelo eliphezulu, khulukhulu lezo ezitholakala emadorobheni bese kube nalezo ezitjhabalala ngebelo elingasiphezulu khulu (Pfab no-Victor 2002&lt;ref name=&quot;:0&quot; /&gt;). 

Esikhathini esinengi iintjalo nemithi etjhabalalako ngileyo yendabuko begodu ekhethekileko leyo engatholakali koke (Pfab no-Victor 2002&lt;ref name=&quot;:0&quot; /&gt;; no-Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Ngokuya kuka-Stohlgren no-Kumar (2013)&lt;ref name=&quot;:2&quot; /&gt; basekelwa yi-SANBI (2010)&lt;ref name=&quot;:3&quot; /&gt;, iintjalo nemithi yendabuko nanyana yemvelo le, ibongazimbi abakhulu tle ngebanga lokuthi ukhona ukuphila endaweni yelo nanyana evelele kiyo begodu iphilo yayo ikhambelana nebhduluko lendawo lelo. Ngamanye amagama, ihlabathi, amanzi, umoya nebujamo bezulu obuhlukileko bakwezinye iindawo abukalungeli iinjalo nemithi yendabuko le. Esihlokweni esilandelako sizokutjheja iimbangela zokutjhabalalisa iintjalo nemithi.

=== Imbangelo yokuhlabalala kwemithi neentjalo ===
Zinengi iimbangela ezibanga ukutjhabalala kwemithi neentjalo esele zitshwaye babantu abanengi iphasi loke leli. Kodwana, kulekulumopendulwano sizokudzimelela kwezilandelako:

==== 1.      Ukutlhayela kweendawo zazo ====
[[Isimumathi:Umomori.jpg|thumb|Umomori]]
Ukutlhayela kweendawo la iintjalo nemithi yendabuko ingaphila khona kumraro omukhulu (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Iintjalo nemithi le izithola ingasakhoni ukunaba kanye nokukhula ngebanga lokuthi iindawo zazo ziyancipha begodi akusenasikhala la zinganabela nanyana zikhulele khona (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;).

==== 2.      Izenzo zabantu ====
Izenzo zabantu zinomthintela omkhulu tle okutjhabalaleni kweentjalo nemithi yendabuko. Ngokuya kuka-Stohlgren no-Kumar (2013) &lt;ref name=&quot;:2&quot; /&gt;izenzo zabantu ezifana nokutheza, ukugubha iinjalo kanye nokutjhisa amahlathi notjani zidlala indima ekulu ekutjhabalaleni kweentjalo nemithi yendabuko. Ngamanye amagama, nabatheza bebaguba iintjalo kodwana bangazitjali nanyana bazijamiselele kubanga ukutjhabalala kwemithi neentjalo ngombana ziyanciba nabenza njalo.

==== 3.      Ituthuko yezehlalakuhle. ====
Kunetuthuko enengi khulu eyenzeka mihla namalanga ephasi esiphila kiyo (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). U-Stohlgren no-Kumar (2013) &lt;ref name=&quot;:2&quot; /&gt;baveze bonyana abantu nabakha iindawo ezitjha, imakhiwo kanye namadorobha amatjha, basusa imithi neentjalo zendabuko endaweni lezo begodu abalingi ukuzifudusela nanyana ukuzibulunga. Lokhu kufaka isandla ekutjhabalaliseni iintjalo nemithi.

==== 4.      Amabubulo namarhwebo ====
Amabubulo namarhwebo asebenzisa iintjalo nemithi yendabuko ukukhiqhiza imikhiqhizo ebayithengisako, kodwana abanandaba nokobanyana imithi neentjalo leyo iyaphela begodu ifuna ukujamiselwela ngokuthi batjale eminye (Stohlgren no-Kumar 2013)&lt;ref name=&quot;:2&quot; /&gt;. Lokhu nakho kudlala indima ekulu ekutjhabalaliseleni iintjalo nemithi.

==== 5.      Itjhuguluko lebhoduluko ====
Itjhuguluko lebhoduluko ekufaka hlangana ubujamo bezulu lobo obutjhugulula iinkathi nezinga ebenza ngakho izinto kumraro khulu eentjalweni nemithi yendabuko (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Ukungezelela, imithi neentjalo lezo zizithola zibhalela kuphila ngaphasi kwetjhugululo lebhoduluko nelobujamo bezulu elitjha lelo (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Ngamanye amagama, lokha nakutjhisa ngendlela ongakajwaleki isikhathi eside nanyana kumakhaza khulu isikhathi eside ukudlula ngenjayelo ngebanga lamatjhuguluko webhoduluko nanyana wobujamo bezulu, iintjalo nemithi yendabuko le igcina ihlongakala begodu ingasamili.

=== Isiphetho ===
Ukutjhabalala kweentjalo nemithi yendabuko yinto embi nenomthelela omumbi eempilweni zethu ngombana kuzokuba nokudla nemitjhaga ebesiyinikelwa mimithi neentjalo lezo engasazokutholakala. Ngalokho-ke, kuqakathekile bonyana sinakele zoke iintjalo nemithi, khulukhulu yendabuko.

Isilululwazi
&lt;references /&gt;
.</text>
      <sha1>bgo0n78zpyqoq3pgantzkv4aacp8gc4</sha1>
    </revision>
    <revision>
      <id>2127</id>
      <parentid>761</parentid>
      <timestamp>2024-11-25T18:18:03Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* Iinkomba */Reflist</comment>
      <origin>2127</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6704" sha1="8z0p31rdhf1f3hs4qqkptb5qj8znvpr" xml:space="preserve">[[Isimumathi:Isirhorhopha.jpg|thumb|Isirhorhopha]]

== Iintjalo Ezisengozini Yokutjhabalala ==

=== Isingeniso ===
Iintjalo nemithi esiphila hlangana nayo nanyana etholaka endaweni zangekhethu iqakatheke khulu. Kunemisebenzi eminengi eyenzako ukuze siphile upilo ehle nephephileko. Nanyana kunjalo, kunomraro wokutjhabala kweentjalo nemithi enarheni yoke zombelele (Pfab no-Victor 2002&lt;ref name=&quot;:0&quot;&gt;Pfab, M. F. &amp; Victor, J. E. Threatened plants of Gauteng, South Africa. ''South African Journal of Botany'', 68:370-375.&lt;/ref&gt;; ne-Wikipedia 2024&lt;ref name=&quot;:1&quot;&gt;Wikipedia. 2024. ''List of critically endangered plants''. Litholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/List_of_critically_endangered_plants&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [12 kuRhoboyi 2024].&lt;/ref&gt;). Ngokuya kuka-Stohlgren no-Kumar (2013:205)&lt;ref name=&quot;:2&quot;&gt;Stohlgren, T. T. &amp; Kumar, S. 2013. Endangered Plants. ''Encyclopedia of Biodiversity'', 3: 465-477. Elsevier.&lt;/ref&gt;  ama-% ama-95 ukuya kuma-% ama-99 wemithi neenjalo ezikhethekileko ebe zikhona ngaphambili nje sele zingasekho nayana ziseduze nokungasabi khona. Ibelo leli ezitjhabalala ngalo ngilo elithusa abatlhogomeli bemvelo nanyana bendabuko (Stohlgren noKumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Ngamanye amagama, ukutjhabalala kweentjalo nemithi bekuvele kukhona kodwana nje umraro kukuthi zitjhabalala ngebelo eliphezulu khulu begodu kubudisi ukulilawula. Eenhlokwaneni ezilandelako sizokutjheja bonyana sikhuluma ngani nasikhuluma ngokutjhabalala kweentjalo nemithi begodi sibuye sitjheje nembangela nanyana isithintela esibanga ukutjhalala kwemithi neentjalo lokhu. 

=== Sikhuluma ngani nasikhuluma ngokutjhabalala kweentjalo nemithi na? ===
[[Isimumathi:Ithuthumbo.jpg|left|thumb|Ithuthumbo]]
I-South African National Biodiversity Institute (I-SANBI) [2010&lt;ref name=&quot;:3&quot;&gt;South African National Biodiversity Institute. 2010. ''Threatened Species: A guide to Red Lists and their use in conservation''. Threatened Species Programme. SANBI: Pretoria.&lt;/ref&gt;] yathi, kukhona iinjalo nemithi, khulukhulu yendabuko nanyana yemvelo leyo  ekhamba inyamala ngemva kwesikhathi. Ngokuya kwebonelophambili, imithi neentjalo le ekhamba inyamala ilinginiselwa een-2 553 eSewula Afrika kwaphela (SANBI 2013&lt;ref&gt;South African National Biodiversity Institute. 2013. ''Plants in Peril''. SANBI: Biodiversity for Life: Pretoria.&lt;/ref&gt;). Ukungezelela, iintjalo lezo nemithi kufikelwa lapho zingasatholakali khona ngemva kokunyamela (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;; ne-Wikipedia 2024&lt;ref name=&quot;:1&quot; /&gt;). Ukunyamela kweentjalo nemithi lokhu bezingasatholakali kubizwa bonyana kutjhabalala kweentjalo nemithi (SANBI 2010&lt;ref name=&quot;:3&quot; /&gt;). 

[[:en:List_of_critically_endangered_plants|Ukutjhabalala kweentjalo nemithi]] lokhu kubangelwa zizinto ezuhlukileko begodu nebelo lokutjhabalala kwazo akufani. Kukhona ezinye ezitjhabalala ngebelo eliphezulu, khulukhulu lezo ezitholakala emadorobheni bese kube nalezo ezitjhabalala ngebelo elingasiphezulu khulu (Pfab no-Victor 2002&lt;ref name=&quot;:0&quot; /&gt;). 

Esikhathini esinengi iintjalo nemithi etjhabalalako ngileyo yendabuko begodu ekhethekileko leyo engatholakali koke (Pfab no-Victor 2002&lt;ref name=&quot;:0&quot; /&gt;; no-Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Ngokuya kuka-Stohlgren no-Kumar (2013)&lt;ref name=&quot;:2&quot; /&gt; basekelwa yi-SANBI (2010)&lt;ref name=&quot;:3&quot; /&gt;, iintjalo nemithi yendabuko nanyana yemvelo le, ibongazimbi abakhulu tle ngebanga lokuthi ukhona ukuphila endaweni yelo nanyana evelele kiyo begodu iphilo yayo ikhambelana nebhduluko lendawo lelo. Ngamanye amagama, ihlabathi, amanzi, umoya nebujamo bezulu obuhlukileko bakwezinye iindawo abukalungeli iinjalo nemithi yendabuko le. Esihlokweni esilandelako sizokutjheja iimbangela zokutjhabalalisa iintjalo nemithi.

=== Imbangelo yokuhlabalala kwemithi neentjalo ===
Zinengi iimbangela ezibanga ukutjhabalala kwemithi neentjalo esele zitshwaye babantu abanengi iphasi loke leli. Kodwana, kulekulumopendulwano sizokudzimelela kwezilandelako:

==== 1.      Ukutlhayela kweendawo zazo ====
[[Isimumathi:Umomori.jpg|thumb|Umomori]]
Ukutlhayela kweendawo la iintjalo nemithi yendabuko ingaphila khona kumraro omukhulu (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Iintjalo nemithi le izithola ingasakhoni ukunaba kanye nokukhula ngebanga lokuthi iindawo zazo ziyancipha begodi akusenasikhala la zinganabela nanyana zikhulele khona (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;).

==== 2.      Izenzo zabantu ====
Izenzo zabantu zinomthintela omkhulu tle okutjhabalaleni kweentjalo nemithi yendabuko. Ngokuya kuka-Stohlgren no-Kumar (2013) &lt;ref name=&quot;:2&quot; /&gt;izenzo zabantu ezifana nokutheza, ukugubha iinjalo kanye nokutjhisa amahlathi notjani zidlala indima ekulu ekutjhabalaleni kweentjalo nemithi yendabuko. Ngamanye amagama, nabatheza bebaguba iintjalo kodwana bangazitjali nanyana bazijamiselele kubanga ukutjhabalala kwemithi neentjalo ngombana ziyanciba nabenza njalo.

==== 3.      Ituthuko yezehlalakuhle. ====
Kunetuthuko enengi khulu eyenzeka mihla namalanga ephasi esiphila kiyo (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). U-Stohlgren no-Kumar (2013) &lt;ref name=&quot;:2&quot; /&gt;baveze bonyana abantu nabakha iindawo ezitjha, imakhiwo kanye namadorobha amatjha, basusa imithi neentjalo zendabuko endaweni lezo begodu abalingi ukuzifudusela nanyana ukuzibulunga. Lokhu kufaka isandla ekutjhabalaliseni iintjalo nemithi.

==== 4.      Amabubulo namarhwebo ====
Amabubulo namarhwebo asebenzisa iintjalo nemithi yendabuko ukukhiqhiza imikhiqhizo ebayithengisako, kodwana abanandaba nokobanyana imithi neentjalo leyo iyaphela begodu ifuna ukujamiselwela ngokuthi batjale eminye (Stohlgren no-Kumar 2013)&lt;ref name=&quot;:2&quot; /&gt;. Lokhu nakho kudlala indima ekulu ekutjhabalaliseleni iintjalo nemithi.

==== 5.      Itjhuguluko lebhoduluko ====
Itjhuguluko lebhoduluko ekufaka hlangana ubujamo bezulu lobo obutjhugulula iinkathi nezinga ebenza ngakho izinto kumraro khulu eentjalweni nemithi yendabuko (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Ukungezelela, imithi neentjalo lezo zizithola zibhalela kuphila ngaphasi kwetjhugululo lebhoduluko nelobujamo bezulu elitjha lelo (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Ngamanye amagama, lokha nakutjhisa ngendlela ongakajwaleki isikhathi eside nanyana kumakhaza khulu isikhathi eside ukudlula ngenjayelo ngebanga lamatjhuguluko webhoduluko nanyana wobujamo bezulu, iintjalo nemithi yendabuko le igcina ihlongakala begodu ingasamili.

=== Isiphetho ===
Ukutjhabalala kweentjalo nemithi yendabuko yinto embi nenomthelela omumbi eempilweni zethu ngombana kuzokuba nokudla nemitjhaga ebesiyinikelwa mimithi neentjalo lezo engasazokutholakala. Ngalokho-ke, kuqakathekile bonyana sinakele zoke iintjalo nemithi, khulukhulu yendabuko.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>8z0p31rdhf1f3hs4qqkptb5qj8znvpr</sha1>
    </revision>
    <revision>
      <id>2281</id>
      <parentid>2127</parentid>
      <timestamp>2024-12-15T12:20:26Z</timestamp>
      <contributor>
        <ip>88.241.72.242</ip>
      </contributor>
      <origin>2281</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6732" sha1="bdt00it5txjfadqby8eej1yofxq1s9k" xml:space="preserve">[[Isimumathi:Isirhorhopha.jpg|thumb|Isirhorhopha]]

== Iintjalo Ezisengozini Yokutjhabalala ==

=== Isingeniso ===
Iintjalo nemithi esiphila hlangana nayo nanyana etholaka endaweni zangekhethu iqakatheke khulu. Kunemisebenzi eminengi eyenzako ukuze siphile upilo ehle nephephileko. Nanyana kunjalo, kunomraro wokutjhabala kweentjalo nemithi enarheni yoke zombelele (Pfab no-Victor 2002&lt;ref name=&quot;:0&quot;&gt;Pfab, M. F. &amp; Victor, J. E. Threatened plants of Gauteng, South Africa. ''South African Journal of Botany'', 68:370-375.&lt;/ref&gt;; ne-Wikipedia 2024&lt;ref name=&quot;:1&quot;&gt;Wikipedia. 2024. ''List of critically endangered plants''. Litholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/List_of_critically_endangered_plants&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [12 kuRhoboyi 2024].&lt;/ref&gt;). Ngokuya kuka-Stohlgren no-Kumar (2013:205)&lt;ref name=&quot;:2&quot;&gt;Stohlgren, T. T. &amp; Kumar, S. 2013. Endangered Plants. ''Encyclopedia of Biodiversity'', 3: 465-477. Elsevier.&lt;/ref&gt;  ama-% ama-95 ukuya kuma-% ama-99 wemithi neenjalo ezikhethekileko ebe zikhona ngaphambili nje sele zingasekho nayana ziseduze nokungasabi khona. Ibelo leli ezitjhabalala ngalo ngilo elithusa abatlhogomeli bemvelo nanyana bendabuko (Stohlgren noKumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Ngamanye amagama, ukutjhabalala kweentjalo nemithi bekuvele kukhona kodwana nje umraro kukuthi zitjhabalala ngebelo eliphezulu khulu begodu kubudisi ukulilawula. Eenhlokwaneni ezilandelako sizokutjheja bonyana sikhuluma ngani nasikhuluma ngokutjhabalala kweentjalo nemithi begodi sibuye sitjheje nembangela nanyana isithintela esibanga ukutjhalala kwemithi neentjalo lokhu. 

=== Sikhuluma ngani nasikhuluma ngokutjhabalala kweentjalo nemithi na? ===
[[Isimumathi:Ithuthumbo.jpg|left|thumb|Ithuthumbo]]
I-South African National Biodiversity Institute (I-SANBI) [2010&lt;ref name=&quot;:3&quot;&gt;South African National Biodiversity Institute. 2010. ''Threatened Species: A guide to Red Lists and their use in conservation''. Threatened Species Programme. SANBI: Pretoria.&lt;/ref&gt;] yathi, kukhona iinjalo nemithi, khulukhulu yendabuko nanyana yemvelo leyo  ekhamba inyamala ngemva kwesikhathi. Ngokuya kwebonelophambili, imithi neentjalo le ekhamba inyamala ilinginiselwa een-2 553 eSewula Afrika kwaphela (SANBI 2013&lt;ref&gt;South African National Biodiversity Institute. 2013. ''Plants in Peril''. SANBI: Biodiversity for Life: Pretoria.&lt;/ref&gt;). Ukungezelela, iintjalo lezo nemithi kufikelwa lapho zingasatholakali khona ngemva kokunyamela (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;; ne-Wikipedia 2024&lt;ref name=&quot;:1&quot; /&gt;). Ukunyamela kweentjalo nemithi lokhu bezingasatholakali kubizwa bonyana kutjhabalala kweentjalo nemithi (SANBI 2010&lt;ref name=&quot;:3&quot; /&gt;). 

[[:en:List_of_critically_endangered_plants|Ukutjhabalala kweentjalo nemithi]] [https://www.on7g.de/ on7g] lokhu kubangelwa zizinto ezuhlukileko begodu nebelo lokutjhabalala kwazo akufani. Kukhona ezinye ezitjhabalala ngebelo eliphezulu, khulukhulu lezo ezitholakala emadorobheni bese kube nalezo ezitjhabalala ngebelo elingasiphezulu khulu (Pfab no-Victor 2002&lt;ref name=&quot;:0&quot; /&gt;). 

Esikhathini esinengi iintjalo nemithi etjhabalalako ngileyo yendabuko begodu ekhethekileko leyo engatholakali koke (Pfab no-Victor 2002&lt;ref name=&quot;:0&quot; /&gt;; no-Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Ngokuya kuka-Stohlgren no-Kumar (2013)&lt;ref name=&quot;:2&quot; /&gt; basekelwa yi-SANBI (2010)&lt;ref name=&quot;:3&quot; /&gt;, iintjalo nemithi yendabuko nanyana yemvelo le, ibongazimbi abakhulu tle ngebanga lokuthi ukhona ukuphila endaweni yelo nanyana evelele kiyo begodu iphilo yayo ikhambelana nebhduluko lendawo lelo. Ngamanye amagama, ihlabathi, amanzi, umoya nebujamo bezulu obuhlukileko bakwezinye iindawo abukalungeli iinjalo nemithi yendabuko le. Esihlokweni esilandelako sizokutjheja iimbangela zokutjhabalalisa iintjalo nemithi.

=== Imbangelo yokuhlabalala kwemithi neentjalo ===
Zinengi iimbangela ezibanga ukutjhabalala kwemithi neentjalo esele zitshwaye babantu abanengi iphasi loke leli. Kodwana, kulekulumopendulwano sizokudzimelela kwezilandelako:

==== 1.      Ukutlhayela kweendawo zazo ====
[[Isimumathi:Umomori.jpg|thumb|Umomori]]
Ukutlhayela kweendawo la iintjalo nemithi yendabuko ingaphila khona kumraro omukhulu (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Iintjalo nemithi le izithola ingasakhoni ukunaba kanye nokukhula ngebanga lokuthi iindawo zazo ziyancipha begodi akusenasikhala la zinganabela nanyana zikhulele khona (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;).

==== 2.      Izenzo zabantu ====
Izenzo zabantu zinomthintela omkhulu tle okutjhabalaleni kweentjalo nemithi yendabuko. Ngokuya kuka-Stohlgren no-Kumar (2013) &lt;ref name=&quot;:2&quot; /&gt;izenzo zabantu ezifana nokutheza, ukugubha iinjalo kanye nokutjhisa amahlathi notjani zidlala indima ekulu ekutjhabalaleni kweentjalo nemithi yendabuko. Ngamanye amagama, nabatheza bebaguba iintjalo kodwana bangazitjali nanyana bazijamiselele kubanga ukutjhabalala kwemithi neentjalo ngombana ziyanciba nabenza njalo.

==== 3.      Ituthuko yezehlalakuhle. ====
Kunetuthuko enengi khulu eyenzeka mihla namalanga ephasi esiphila kiyo (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). U-Stohlgren no-Kumar (2013) &lt;ref name=&quot;:2&quot; /&gt;baveze bonyana abantu nabakha iindawo ezitjha, imakhiwo kanye namadorobha amatjha, basusa imithi neentjalo zendabuko endaweni lezo begodu abalingi ukuzifudusela nanyana ukuzibulunga. Lokhu kufaka isandla ekutjhabalaliseni iintjalo nemithi.

==== 4.      Amabubulo namarhwebo ====
Amabubulo namarhwebo asebenzisa iintjalo nemithi yendabuko ukukhiqhiza imikhiqhizo ebayithengisako, kodwana abanandaba nokobanyana imithi neentjalo leyo iyaphela begodu ifuna ukujamiselwela ngokuthi batjale eminye (Stohlgren no-Kumar 2013)&lt;ref name=&quot;:2&quot; /&gt;. Lokhu nakho kudlala indima ekulu ekutjhabalaliseleni iintjalo nemithi.

==== 5.      Itjhuguluko lebhoduluko ====
Itjhuguluko lebhoduluko ekufaka hlangana ubujamo bezulu lobo obutjhugulula iinkathi nezinga ebenza ngakho izinto kumraro khulu eentjalweni nemithi yendabuko (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Ukungezelela, imithi neentjalo lezo zizithola zibhalela kuphila ngaphasi kwetjhugululo lebhoduluko nelobujamo bezulu elitjha lelo (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Ngamanye amagama, lokha nakutjhisa ngendlela ongakajwaleki isikhathi eside nanyana kumakhaza khulu isikhathi eside ukudlula ngenjayelo ngebanga lamatjhuguluko webhoduluko nanyana wobujamo bezulu, iintjalo nemithi yendabuko le igcina ihlongakala begodu ingasamili.

=== Isiphetho ===
Ukutjhabalala kweentjalo nemithi yendabuko yinto embi nenomthelela omumbi eempilweni zethu ngombana kuzokuba nokudla nemitjhaga ebesiyinikelwa mimithi neentjalo lezo engasazokutholakala. Ngalokho-ke, kuqakathekile bonyana sinakele zoke iintjalo nemithi, khulukhulu yendabuko.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>bdt00it5txjfadqby8eej1yofxq1s9k</sha1>
    </revision>
    <revision>
      <id>2347</id>
      <parentid>2281</parentid>
      <timestamp>2025-01-15T01:30:36Z</timestamp>
      <contributor>
        <ip>176.219.164.251</ip>
      </contributor>
      <origin>2347</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6780" sha1="2b64bg0wx2cearm6je4kmhmaa3uukaq" xml:space="preserve">[[Isimumathi:Isirhorhopha.jpg|thumb|Isirhorhopha]]

== Iintjalo Ezisengozini Yokutjhabalala ==

=== Isingeniso ===
Iintjalo nemithi esiphila hlangana nayo nanyana etholaka endaweni zangekhethu iqakatheke khulu. Kunemisebenzi eminengi eyenzako ukuze siphile upilo ehle nephephileko. Nanyana kunjalo, kunomraro wokutjhabala kweentjalo nemithi enarheni yoke zombelele (Pfab no-Victor 2002&lt;ref name=&quot;:0&quot;&gt;Pfab, M. F. &amp; Victor, J. E. Threatened plants of Gauteng, South Africa. ''South African Journal of Botany'', 68:370-375.&lt;/ref&gt;; ne-Wikipedia 2024&lt;ref name=&quot;:1&quot;&gt;Wikipedia. 2024. ''List of critically endangered plants''. Litholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/List_of_critically_endangered_plants&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [12 kuRhoboyi 2024].&lt;/ref&gt;). Ngokuya kuka-Stohlgren no-Kumar (2013:205)&lt;ref name=&quot;:2&quot;&gt;Stohlgren, T. T. &amp; Kumar, S. 2013. Endangered Plants. ''Encyclopedia of Biodiversity'', 3: 465-477. Elsevier.&lt;/ref&gt;  ama-% ama-95 ukuya kuma-% ama-99 wemithi neenjalo ezikhethekileko ebe zikhona ngaphambili nje sele zingasekho nayana ziseduze nokungasabi khona. Ibelo leli ezitjhabalala ngalo ngilo elithusa abatlhogomeli bemvelo nanyana bendabuko (Stohlgren noKumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Ngamanye amagama, ukutjhabalala kweentjalo nemithi bekuvele kukhona kodwana nje umraro kukuthi zitjhabalala ngebelo eliphezulu khulu begodu kubudisi ukulilawula. Eenhlokwaneni ezilandelako sizokutjheja bonyana sikhuluma ngani nasikhuluma ngokutjhabalala kweentjalo nemithi begodi sibuye sitjheje nembangela nanyana isithintela esibanga ukutjhalala kwemithi neentjalo lokhu. 

=== Sikhuluma ngani nasikhuluma ngokutjhabalala kweentjalo nemithi na? ===
[[Isimumathi:Ithuthumbo.jpg|left|thumb|Ithuthumbo]]
I-South African National Biodiversity Institute (I-SANBI) [2010&lt;ref name=&quot;:3&quot;&gt;South African National Biodiversity Institute. 2010. ''Threatened Species: A guide to Red Lists and their use in conservation''. Threatened Species Programme. SANBI: Pretoria.&lt;/ref&gt;] yathi, kukhona iinjalo nemithi, khulukhulu yendabuko nanyana yemvelo leyo  ekhamba inyamala ngemva kwesikhathi. Ngokuya kwebonelophambili, imithi neentjalo le ekhamba inyamala ilinginiselwa een-2 553 eSewula Afrika kwaphela (SANBI 2013&lt;ref&gt;South African National Biodiversity Institute. 2013. ''Plants in Peril''. SANBI: Biodiversity for Life: Pretoria.&lt;/ref&gt;). Ukungezelela, iintjalo lezo nemithi kufikelwa lapho zingasatholakali khona ngemva kokunyamela (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;; ne-Wikipedia 2024&lt;ref name=&quot;:1&quot; /&gt;). Ukunyamela kweentjalo nemithi lokhu bezingasatholakali kubizwa bonyana kutjhabalala kweentjalo nemithi (SANBI 2010&lt;ref name=&quot;:3&quot; /&gt;). 

[[:en:List_of_critically_endangered_plants|Ukutjhabalala kweentjalo nemithi]] [https://www.on7g.de/ on7g] lokhu kubangelwa zizinto ezuhlukileko begodu nebelo lokutjhabalala kwazo akufani. Kukhona ezinye ezitjhabalala ngebelo eliphezulu, khulukhulu lezo ezitholakala emadorobheni bese kube nalezo ezitjhabalala ngebelo elingasiphezulu khulu (Pfab no-Victor 2002&lt;ref name=&quot;:0&quot; /&gt;). 

Esikhathini esinengi iintjalo nemithi etjhabalalako ngileyo yendabuko begodu ekhethekileko leyo engatholakali koke (Pfab no-Victor 2002&lt;ref name=&quot;:0&quot; /&gt;; no-Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Ngokuya kuka-Stohlgren no-Kumar (2013)&lt;ref name=&quot;:2&quot; /&gt; basekelwa yi-SANBI (2010)&lt;ref name=&quot;:3&quot; /&gt;, iintjalo nemithi yendabuko nanyana yemvelo le, ibongazimbi abakhulu tle ngebanga lokuthi ukhona ukuphila endaweni yelo nanyana evelele kiyo begodu iphilo yayo ikhambelana nebhduluko lendawo lelo. Ngamanye amagama, ihlabathi, amanzi, umoya nebujamo bezulu obuhlukileko bakwezinye iindawo abukalungeli iinjalo nemithi yendabuko le. Esihlokweni esilandelako sizokutjheja iimbangela zokutjhabalalisa iintjalo nemithi.

=== Imbangelo yokuhlabalala kwemithi neentjalo ===
Zinengi iimbangela ezibanga ukutjhabalala kwemithi neentjalo esele zitshwaye babantu abanengi iphasi loke leli. Kodwana, kulekulumopendulwano sizokudzimelela kwezilandelako:

==== 1.      Ukutlhayela kweendawo zazo ====
[[Isimumathi:Umomori.jpg|thumb|Umomori]]
Ukutlhayela kweendawo la iintjalo nemithi yendabuko ingaphila khona kumraro omukhulu (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Iintjalo nemithi le izithola ingasakhoni ukunaba kanye nokukhula ngebanga lokuthi iindawo zazo ziyancipha begodi akusenasikhala la zinganabela nanyana zikhulele khona (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;).

==== 2.      Izenzo zabantu ====
Izenzo zabantu zinomthintela omkhulu tle okutjhabalaleni kweentjalo nemithi yendabuko. Ngokuya kuka-Stohlgren no-Kumar (2013) &lt;ref name=&quot;:2&quot; /&gt;izenzo zabantu ezifana nokutheza, ukugubha iinjalo kanye nokutjhisa amahlathi notjani zidlala indima ekulu ekutjhabalaleni kweentjalo nemithi yendabuko. Ngamanye amagama, nabatheza bebaguba iintjalo kodwana bangazitjali nanyana bazijamiselele kubanga ukutjhabalala kwemithi neentjalo ngombana ziyanciba nabenza njalo.

==== 3.      Ituthuko yezehlalakuhle. ====
Kunetuthuko enengi khulu eyenzeka mihla namalanga ephasi esiphila kiyo (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). U-Stohlgren no-Kumar (2013) &lt;ref name=&quot;:2&quot; /&gt;baveze bonyana abantu nabakha iindawo ezitjha, imakhiwo kanye namadorobha amatjha, basusa imithi neentjalo zendabuko endaweni lezo begodu abalingi ukuzifudusela nanyana ukuzibulunga. Lokhu kufaka isandla ekutjhabalaliseni iintjalo nemithi.

==== 4.      Amabubulo namarhwebo ====
Amabubulo namarhwebo asebenzisa iintjalo nemithi yendabuko ukukhiqhiza imikhiqhizo ebayithengisako, kodwana abanandaba nokobanyana imithi neentjalo leyo iyaphela begodu ifuna ukujamiselwela ngokuthi batjale eminye (Stohlgren no-Kumar 2013)&lt;ref name=&quot;:2&quot; /&gt;. Lokhu nakho kudlala indima ekulu ekutjhabalaliseleni iintjalo nemithi.

==== 5.      Itjhuguluko lebhoduluko ====
Itjhuguluko lebhoduluko ekufaka hlangana ubujamo bezulu lobo obutjhugulula iinkathi nezinga ebenza ngakho izinto kumraro khulu eentjalweni nemithi yendabuko (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Ukungezelela, imithi neentjalo lezo zizithola zibhalela kuphila ngaphasi kwetjhugululo lebhoduluko nelobujamo bezulu elitjha lelo (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). [https://www.kompozisyontv.com.tr/ kompozisyon] Ngamanye amagama, lokha nakutjhisa ngendlela ongakajwaleki isikhathi eside nanyana kumakhaza khulu isikhathi eside ukudlula ngenjayelo ngebanga lamatjhuguluko webhoduluko nanyana wobujamo bezulu, iintjalo nemithi yendabuko le igcina ihlongakala begodu ingasamili.

=== Isiphetho ===
Ukutjhabalala kweentjalo nemithi yendabuko yinto embi nenomthelela omumbi eempilweni zethu ngombana kuzokuba nokudla nemitjhaga ebesiyinikelwa mimithi neentjalo lezo engasazokutholakala. Ngalokho-ke, kuqakathekile bonyana sinakele zoke iintjalo nemithi, khulukhulu yendabuko.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>2b64bg0wx2cearm6je4kmhmaa3uukaq</sha1>
    </revision>
    <revision>
      <id>5051</id>
      <parentid>2347</parentid>
      <timestamp>2025-08-07T08:44:28Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <origin>5051</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6717" sha1="jtk2uk7lx9iejblyruudoxnls1qkly0" xml:space="preserve">[[Isimumathi:Isirhorhopha.jpg|thumb|Isirhorhopha]]

Iintjalo nemithi esiphila hlangana nayo nanyana etholaka endaweni zangekhethu iqakatheke khulu. Kunemisebenzi eminengi eyenzako ukuze siphile upilo ehle nephephileko. Nanyana kunjalo, kunomraro wokutjhabala kweentjalo nemithi enarheni yoke zombelele (Pfab no-Victor 2002&lt;ref name=&quot;:0&quot;&gt;Pfab, M. F. &amp; Victor, J. E. Threatened plants of Gauteng, South Africa. ''South African Journal of Botany'', 68:370-375.&lt;/ref&gt;; ne-Wikipedia 2024&lt;ref name=&quot;:1&quot;&gt;Wikipedia. 2024. ''List of critically endangered plants''. Litholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/List_of_critically_endangered_plants&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [12 kuRhoboyi 2024].&lt;/ref&gt;). Ngokuya kuka-Stohlgren no-Kumar (2013:205)&lt;ref name=&quot;:2&quot;&gt;Stohlgren, T. T. &amp; Kumar, S. 2013. Endangered Plants. ''Encyclopedia of Biodiversity'', 3: 465-477. Elsevier.&lt;/ref&gt;  ama-% ama-95 ukuya kuma-% ama-99 wemithi neenjalo ezikhethekileko ebe zikhona ngaphambili nje sele zingasekho nayana ziseduze nokungasabi khona. Ibelo leli ezitjhabalala ngalo ngilo elithusa abatlhogomeli bemvelo nanyana bendabuko (Stohlgren noKumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Ngamanye amagama, ukutjhabalala kweentjalo nemithi bekuvele kukhona kodwana nje umraro kukuthi zitjhabalala ngebelo eliphezulu khulu begodu kubudisi ukulilawula. Eenhlokwaneni ezilandelako sizokutjheja bonyana sikhuluma ngani nasikhuluma ngokutjhabalala kweentjalo nemithi begodi sibuye sitjheje nembangela nanyana isithintela esibanga ukutjhalala kwemithi neentjalo lokhu. 

=== Sikhuluma ngani nasikhuluma ngokutjhabalala kweentjalo nemithi na? ===
[[Isimumathi:Ithuthumbo.jpg|left|thumb|Ithuthumbo]]
I-South African National Biodiversity Institute (I-SANBI) [2010&lt;ref name=&quot;:3&quot;&gt;South African National Biodiversity Institute. 2010. ''Threatened Species: A guide to Red Lists and their use in conservation''. Threatened Species Programme. SANBI: Pretoria.&lt;/ref&gt;] yathi, kukhona iinjalo nemithi, khulukhulu yendabuko nanyana yemvelo leyo  ekhamba inyamala ngemva kwesikhathi. Ngokuya kwebonelophambili, imithi neentjalo le ekhamba inyamala ilinginiselwa een-2 553 eSewula Afrika kwaphela (SANBI 2013&lt;ref&gt;South African National Biodiversity Institute. 2013. ''Plants in Peril''. SANBI: Biodiversity for Life: Pretoria.&lt;/ref&gt;). Ukungezelela, iintjalo lezo nemithi kufikelwa lapho zingasatholakali khona ngemva kokunyamela (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;; ne-Wikipedia 2024&lt;ref name=&quot;:1&quot; /&gt;). Ukunyamela kweentjalo nemithi lokhu bezingasatholakali kubizwa bonyana kutjhabalala kweentjalo nemithi (SANBI 2010&lt;ref name=&quot;:3&quot; /&gt;). 

[[:en:List_of_critically_endangered_plants|Ukutjhabalala kweentjalo nemithi]] [https://www.on7g.de/ on7g] lokhu kubangelwa zizinto ezuhlukileko begodu nebelo lokutjhabalala kwazo akufani. Kukhona ezinye ezitjhabalala ngebelo eliphezulu, khulukhulu lezo ezitholakala emadorobheni bese kube nalezo ezitjhabalala ngebelo elingasiphezulu khulu (Pfab no-Victor 2002&lt;ref name=&quot;:0&quot; /&gt;). 

Esikhathini esinengi iintjalo nemithi etjhabalalako ngileyo yendabuko begodu ekhethekileko leyo engatholakali koke (Pfab no-Victor 2002&lt;ref name=&quot;:0&quot; /&gt;; no-Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Ngokuya kuka-Stohlgren no-Kumar (2013)&lt;ref name=&quot;:2&quot; /&gt; basekelwa yi-SANBI (2010)&lt;ref name=&quot;:3&quot; /&gt;, iintjalo nemithi yendabuko nanyana yemvelo le, ibongazimbi abakhulu tle ngebanga lokuthi ukhona ukuphila endaweni yelo nanyana evelele kiyo begodu iphilo yayo ikhambelana nebhduluko lendawo lelo. Ngamanye amagama, ihlabathi, amanzi, umoya nebujamo bezulu obuhlukileko bakwezinye iindawo abukalungeli iinjalo nemithi yendabuko le. Esihlokweni esilandelako sizokutjheja iimbangela zokutjhabalalisa iintjalo nemithi.

=== Imbangelo yokuhlabalala kwemithi neentjalo ===
Zinengi iimbangela ezibanga ukutjhabalala kwemithi neentjalo esele zitshwaye babantu abanengi iphasi loke leli. Kodwana, kulekulumopendulwano sizokudzimelela kwezilandelako:

==== 1.      Ukutlhayela kweendawo zazo ====
[[Isimumathi:Umomori.jpg|thumb|Umomori]]
Ukutlhayela kweendawo la iintjalo nemithi yendabuko ingaphila khona kumraro omukhulu (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Iintjalo nemithi le izithola ingasakhoni ukunaba kanye nokukhula ngebanga lokuthi iindawo zazo ziyancipha begodi akusenasikhala la zinganabela nanyana zikhulele khona (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;).

==== 2.      Izenzo zabantu ====
Izenzo zabantu zinomthintela omkhulu tle okutjhabalaleni kweentjalo nemithi yendabuko. Ngokuya kuka-Stohlgren no-Kumar (2013) &lt;ref name=&quot;:2&quot; /&gt;izenzo zabantu ezifana nokutheza, ukugubha iinjalo kanye nokutjhisa amahlathi notjani zidlala indima ekulu ekutjhabalaleni kweentjalo nemithi yendabuko. Ngamanye amagama, nabatheza bebaguba iintjalo kodwana bangazitjali nanyana bazijamiselele kubanga ukutjhabalala kwemithi neentjalo ngombana ziyanciba nabenza njalo.

==== 3.      Ituthuko yezehlalakuhle. ====
Kunetuthuko enengi khulu eyenzeka mihla namalanga ephasi esiphila kiyo (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). U-Stohlgren no-Kumar (2013) &lt;ref name=&quot;:2&quot; /&gt;baveze bonyana abantu nabakha iindawo ezitjha, imakhiwo kanye namadorobha amatjha, basusa imithi neentjalo zendabuko endaweni lezo begodu abalingi ukuzifudusela nanyana ukuzibulunga. Lokhu kufaka isandla ekutjhabalaliseni iintjalo nemithi.

==== 4.      Amabubulo namarhwebo ====
Amabubulo namarhwebo asebenzisa iintjalo nemithi yendabuko ukukhiqhiza imikhiqhizo ebayithengisako, kodwana abanandaba nokobanyana imithi neentjalo leyo iyaphela begodu ifuna ukujamiselwela ngokuthi batjale eminye (Stohlgren no-Kumar 2013)&lt;ref name=&quot;:2&quot; /&gt;. Lokhu nakho kudlala indima ekulu ekutjhabalaliseleni iintjalo nemithi.

==== 5.      Itjhuguluko lebhoduluko ====
Itjhuguluko lebhoduluko ekufaka hlangana ubujamo bezulu lobo obutjhugulula iinkathi nezinga ebenza ngakho izinto kumraro khulu eentjalweni nemithi yendabuko (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Ukungezelela, imithi neentjalo lezo zizithola zibhalela kuphila ngaphasi kwetjhugululo lebhoduluko nelobujamo bezulu elitjha lelo (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). [https://www.kompozisyontv.com.tr/ kompozisyon] Ngamanye amagama, lokha nakutjhisa ngendlela ongakajwaleki isikhathi eside nanyana kumakhaza khulu isikhathi eside ukudlula ngenjayelo ngebanga lamatjhuguluko webhoduluko nanyana wobujamo bezulu, iintjalo nemithi yendabuko le igcina ihlongakala begodu ingasamili.

=== Isiphetho ===
Ukutjhabalala kweentjalo nemithi yendabuko yinto embi nenomthelela omumbi eempilweni zethu ngombana kuzokuba nokudla nemitjhaga ebesiyinikelwa mimithi neentjalo lezo engasazokutholakala. Ngalokho-ke, kuqakathekile bonyana sinakele zoke iintjalo nemithi, khulukhulu yendabuko.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>jtk2uk7lx9iejblyruudoxnls1qkly0</sha1>
    </revision>
    <revision>
      <id>5101</id>
      <parentid>5051</parentid>
      <timestamp>2025-08-08T09:40:44Z</timestamp>
      <contributor>
        <username>Tjhudu Khanyi</username>
        <id>836</id>
      </contributor>
      <origin>5101</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6731" sha1="rijlm6bi20eqcbdgva0ywczz2ytkdvn" xml:space="preserve">[[Isimumathi:Isirhorhopha.jpg|thumb|Isirhorhopha]]

Iintjalo nemithi esiphila hlangana nazo nanyana ezitholaka eendaweni zangekhethu ziqakatheke khulu. Kunemisebenzi eminengi eyenzako ukuze siphile ipilo ehle nephephileko. Nanyana kunjalo, kunomraro wokutjhabala kweentjalo nemithi enarheni yoke zombelele (Pfab no-Victor 2002&lt;ref name=&quot;:0&quot;&gt;Pfab, M. F. &amp; Victor, J. E. Threatened plants of Gauteng, South Africa. ''South African Journal of Botany'', 68:370-375.&lt;/ref&gt;; ne-Wikipedia 2024&lt;ref name=&quot;:1&quot;&gt;Wikipedia. 2024. ''List of critically endangered plants''. Litholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/List_of_critically_endangered_plants&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [12 kuRhoboyi 2024].&lt;/ref&gt;). Ngokuya kuka-Stohlgren no-Kumar (2013:205)&lt;ref name=&quot;:2&quot;&gt;Stohlgren, T. T. &amp; Kumar, S. 2013. Endangered Plants. ''Encyclopedia of Biodiversity'', 3: 465-477. Elsevier.&lt;/ref&gt;  ama-% ama-95 ukuya kuma-% ama-99 wemithi neentjalo ezikhethekileko ebe zikhona ngaphambili nje sele zingasekho nayana ziseduze nokungasabi khona. Ibelo leli ezitjhabalala ngalo ngilo elithusa abatlhogomeli bemvelo nanyana bendabuko (Stohlgren noKumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Ngamanye amagama, ukutjhabalala kweentjalo nemithi bekuvele kukhona kodwana nje umraro kukuthi zitjhabalala ngebelo eliphezulu khulu begodu kubudisi ukulilawula. Eenhlokwaneni ezilandelako sizokutjheja bonyana sikhuluma ngani nasikhuluma ngokutjhabalala kweentjalo nemithi begodi sibuye sitjheje neembangela nanyana isithintela esibanga ukutjhabalala kwemithi neentjalo lokhu. 

=== Sikhuluma ngani nasikhuluma ngokutjhabalala kweentjalo nemithi na? ===
[[Isimumathi:Ithuthumbo.jpg|left|thumb|Ithuthumbo]]
I-South African National Biodiversity Institute (I-SANBI) [2010&lt;ref name=&quot;:3&quot;&gt;South African National Biodiversity Institute. 2010. ''Threatened Species: A guide to Red Lists and their use in conservation''. Threatened Species Programme. SANBI: Pretoria.&lt;/ref&gt;] yathi, kukhona iintjalo nemithi, khulukhulu yendabuko nanyana yemvelo leyo  ekhamba inyamalala ngemva kwesikhathi. Ngokuya kwebonelophambili, imithi neentjalo le ekhamba inyamalala ilinginiselwa een-2 553 eSewula Afrika kwaphela (SANBI 2013&lt;ref&gt;South African National Biodiversity Institute. 2013. ''Plants in Peril''. SANBI: Biodiversity for Life: Pretoria.&lt;/ref&gt;). Ukungezelela, iintjalo lezo nemithi kufikela lapho zingasatholakali khona ngemva kokunyamela (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;; ne-Wikipedia 2024&lt;ref name=&quot;:1&quot; /&gt;). Ukunyamela kweentjalo nemithi lokhu bezingasatholakali kubizwa bonyana kutjhabalala kweentjalo nemithi (SANBI 2010&lt;ref name=&quot;:3&quot; /&gt;). 

[[:en:List_of_critically_endangered_plants|Ukutjhabalala kweentjalo nemithi]] [https://www.on7g.de/ on7g] lokhu kubangelwa zizinto ezuhlukileko begodu nebelo lokutjhabalala kwazo akufani. Kukhona ezinye ezitjhabalala ngebelo eliphezulu, khulukhulu lezo ezitholakala emadorobheni bese kube nalezo ezitjhabalala ngebelo elingasiphezulu khulu (Pfab no-Victor 2002&lt;ref name=&quot;:0&quot; /&gt;). 

Esikhathini esinengi iintjalo nemithi etjhabalalako ngileyo yendabuko begodu ekhethekileko leyo engatholakali koke (Pfab no-Victor 2002&lt;ref name=&quot;:0&quot; /&gt;; no-Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Ngokuya kuka-Stohlgren no-Kumar (2013)&lt;ref name=&quot;:2&quot; /&gt; basekelwa yi-SANBI (2010)&lt;ref name=&quot;:3&quot; /&gt;, iintjalo nemithi yendabuko nanyana yemvelo le, ibongazimbi abakhulu tle ngebanga lokuthi ukhona ukuphila endaweni yelo nanyana evelele kiyo begodu iphilo yayo ikhambelana nebhduluko lendawo lelo. Ngamanye amagama, ihlabathi, amanzi, umoya nebujamo bezulu obuhlukileko bakwezinye iindawo abukalungeli iinjalo nemithi yendabuko le. Esihlokweni esilandelako sizokutjheja iimbangela zokutjhabalalisa iintjalo nemithi.

=== Imbangelo yokuhlabalala kwemithi neentjalo ===
Zinengi iimbangela ezibanga ukutjhabalala kwemithi neentjalo esele zitshwaye babantu abanengi iphasi loke leli. Kodwana, kulekulumopendulwano sizokudzimelela kwezilandelako:

==== 1.      Ukutlhayela kweendawo zazo ====
[[Isimumathi:Umomori.jpg|thumb|Umomori]]
Ukutlhayela kweendawo la iintjalo nemithi yendabuko ingaphila khona kumraro omukhulu (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Iintjalo nemithi le izithola ingasakhoni ukunaba kanye nokukhula ngebanga lokuthi iindawo zazo ziyancipha begodi akusenasikhala la zinganabela nanyana zikhulele khona (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;).

==== 2.      Izenzo zabantu ====
Izenzo zabantu zinomthintela omkhulu tle okutjhabalaleni kweentjalo nemithi yendabuko. Ngokuya kuka-Stohlgren no-Kumar (2013) &lt;ref name=&quot;:2&quot; /&gt;izenzo zabantu ezifana nokutheza, ukugubha iintjalo kanye nokutjhisa amahlathi notjani zidlala indima ekulu ekutjhabalaleni kweentjalo nemithi yendabuko. Ngamanye amagama, nabatheza bebaguba iintjalo kodwana bangazitjali nanyana bazijamiselele kubanga ukutjhabalala kwemithi neentjalo ngombana ziyancipha nabenza njalo.

==== 3.      Ituthuko yezehlalakuhle. ====
Kunetuthuko enengi khulu eyenzeka mihla namalanga ephasi esiphila kiyo (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). U-Stohlgren no-Kumar (2013) &lt;ref name=&quot;:2&quot; /&gt;baveze bonyana abantu nabakha iindawo ezitjha, imakhiwo kanye namadorobha amatjha, basusa imithi neentjalo zendabuko endaweni lezo begodu abalingi ukuzifudusela nanyana ukuzibulunga. Lokhu kufaka isandla ekutjhabalaliseni iintjalo nemithi.

==== 4.      Amabubulo namarhwebo ====
Amabubulo namarhwebo asebenzisa iintjalo nemithi yendabuko ukukhiqhiza imikhiqhizo ebayithengisako, kodwana abanandaba nokobanyana imithi neentjalo leyo iyaphela begodu ifuna ukujamiselwela ngokuthi batjale eminye (Stohlgren no-Kumar 2013)&lt;ref name=&quot;:2&quot; /&gt;. Lokhu nakho kudlala indima ekulu ekutjhabalaliseleni iintjalo nemithi.

==== 5.      Itjhuguluko lebhoduluko ====
Itjhuguluko lebhoduluko ekufaka hlangana ubujamo bezulu lobo obutjhugulula iinkathi nezinga ebenza ngakho izinto kumraro khulu eentjalweni nemithi yendabuko (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Ukungezelela, imithi neentjalo lezo zizithola zibhalela kuphila ngaphasi kwetjhugululo lebhoduluko nelobujamo bezulu elitjha lelo (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). [https://www.kompozisyontv.com.tr/ kompozisyon] Ngamanye amagama, lokha nakutjhisa ngendlela ongakajwaleki isikhathi eside nanyana kumakhaza khulu isikhathi eside ukudlula ngenjayelo ngebanga lamatjhuguluko webhoduluko nanyana wobujamo bezulu, iintjalo nemithi yendabuko le igcina ihlongakala begodu ingasamili.

=== Isiphetho ===
Ukutjhabalala kweentjalo nemithi yendabuko yinto embi nenomthelela omumbi eempilweni zethu ngombana kuzokuba nokudla nemitjhaga ebesiyinikelwa mimithi neentjalo lezo engasazokutholakala. Ngalokho-ke, kuqakathekile bonyana sinakele zoke iintjalo nemithi, khulukhulu yendabuko.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>rijlm6bi20eqcbdgva0ywczz2ytkdvn</sha1>
    </revision>
    <revision>
      <id>5104</id>
      <parentid>5101</parentid>
      <timestamp>2025-08-08T10:38:59Z</timestamp>
      <contributor>
        <username>Lerato Ruffy</username>
        <id>846</id>
      </contributor>
      <origin>5104</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6796" sha1="2bgyj8xrsee7ttqvtgk0jq5f2rep1vd" xml:space="preserve">[[Isimumathi:Isirhorhopha.jpg|thumb|Isirhorhopha]]

Iintjalo nemithi esiphila hlangana nazo nanyana ezitholakala eendaweni zangekhethu ziqakatheke khulu. Kunemisebenzi eminengi eyenzako ukuze siphile ipilo ehle nephephileko. Nanyana kunjalo, kunomraro wokutjhabalala kweentjalo nemithi enarheni yoke zombelele (Pfab no-Victor 2002&lt;ref name=&quot;:0&quot;&gt;Pfab, M. F. &amp; Victor, J. E. Threatened plants of Gauteng, South Africa. ''South African Journal of Botany'', 68:370-375.&lt;/ref&gt;; ne-Wikipedia 2024&lt;ref name=&quot;:1&quot;&gt;Wikipedia. 2024. ''List of critically endangered plants''. Litholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/List_of_critically_endangered_plants&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [12 kuRhoboyi 2024].&lt;/ref&gt;). Ngokuya kuka-Stohlgren no-Kumar (2013:205)&lt;ref name=&quot;:2&quot;&gt;Stohlgren, T. T. &amp; Kumar, S. 2013. Endangered Plants. ''Encyclopedia of Biodiversity'', 3: 465-477. Elsevier.&lt;/ref&gt;  ama-% ama-95 ukuya kuma-% ama-99 wemithi neentjalo ezikhethekileko ebe zikhona ngaphambilini sele zingasekho nanyana ziseduze nokungasabi khona. Ibelo leli ezitjhabalala ngalo ngilo elithusa abatlhogomeli bemvelo nanyana bendabuko (Stohlgren noKumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Ngamanye amagama, ukutjhabalala kweentjalo nemithi bekuvele kukhona kodwana nje umraro kukuthi zitjhabalala ngebelo eliphezulu khulu begodu kubudisi ukulilawula. Eenhlokwaneni ezilandelako sizokutjheja bonyana sikhuluma ngani nasikhuluma ngokutjhabalala kweentjalo nemithi begodi sibuye sitjheje neembangela nanyana isithintela esibanga ukutjhabalala kwemithi neentjalo lokhu. 

=== Sikhuluma ngani nasikhuluma ngokutjhabalala kweentjalo nemithi na? ===
[[Isimumathi:Ithuthumbo.jpg|left|thumb|Ithuthumbo]]
I-South African National Biodiversity Institute (I-SANBI) [2010&lt;ref name=&quot;:3&quot;&gt;South African National Biodiversity Institute. 2010. ''Threatened Species: A guide to Red Lists and their use in conservation''. Threatened Species Programme. SANBI: Pretoria.&lt;/ref&gt;] yathi, kukhona iintjalo nemithi, khulukhulu yendabuko nanyana yemvelo leyo  ekhamba inyamalala ngemva kwesikhathi. Ngokuya kwebonelophambili, imithi neentjalo le ekhamba inyamalala ilinganiselwa een-2 553 eSewula Afrika kwaphela (SANBI 2013&lt;ref&gt;South African National Biodiversity Institute. 2013. ''Plants in Peril''. SANBI: Biodiversity for Life: Pretoria.&lt;/ref&gt;). Ukungezelela, iintjalo lezo nemithi kufikela lapho zingasatholakali khona ngemva kokunyamela (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;; ne-Wikipedia 2024&lt;ref name=&quot;:1&quot; /&gt;). Ukunyamela kweentjalo nemithi lokhu bezingasatholakali kubizwa bonyana kutjhabalala kweentjalo nemithi (SANBI 2010&lt;ref name=&quot;:3&quot; /&gt;). 

[[:en:List_of_critically_endangered_plants|Ukutjhabalala kweentjalo nemithi]] [https://www.on7g.de/ on7g] lokhu kubangelwa zizinto ezihlukileko begodu nebelo lokutjhabalala kwazo akufani. Kukhona ezinye ezitjhabalala ngebelo eliphezulu khulu, khulukhulu lezo ezitholakala emadorobheni bese kubuye godu kube nalezo ezitjhabalala ngebelo elingasiphezulu khulu (Pfab no-Victor 2002&lt;ref name=&quot;:0&quot; /&gt;). 

Esikhathini esinengi iintjalo nemithi etjhabalalako ngileyo yendabuko begodu ekhethekileko leyo engatholakali koke (Pfab no-Victor 2002&lt;ref name=&quot;:0&quot; /&gt;; no-Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Ngokuya kuka-Stohlgren no-Kumar (2013)&lt;ref name=&quot;:2&quot; /&gt; basekelwa yi-SANBI (2010)&lt;ref name=&quot;:3&quot; /&gt;, iintjalo nemithi yendabuko nanyana yemvelo le, ibongazimbi abakhulu tle ngebanga lokuthi ukhona ukuphila endaweni leyo nanyana evelele kiyo begodu ipilo yayo ikhambelana nebhoduluko lendawo lelo. Ngamanye amagama, ihlabathi, amanzi, umoya nobujamo bezulu obuhlukileko bakwezinye iindawo abukalungeli iintjalo nemithi yendabuko le. Esihlokweni esilandelako sizokutjheja iimbangela zokutjhabalalisa iintjalo nemithi.

=== Imbangelo yokutjhabalala kwemithi kanye neentjalo ===
Zinengi iimbangela ezibanga ukutjhabalala kwemithi neentjalo esele zitshwaye babantu abanengi iphasi loke leli kodwana kulekulumo-pendulwano sizokudzimelela kwezilandelako:

==== 1.      Ukutlhayela kweendawo zazo ====
[[Isimumathi:Umomori.jpg|thumb|Umomori]]
Ukutlhayela kweendawo la iintjalo nemithi yendabuko ingaphila khona kumraro omukhulu (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Iintjalo nemithi le izithola ingasakhoni ukunaba kanye nokukhula ngebanga lokuthi iindawo zazo ziyancipha begodu akusenasikhala la zinganabela nanyana zikhulele khona (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;).

==== 2.      Izenzo zabantu ====
Izenzo zabantu zinomthelela omkhulu tle ekutjhabalaleni kweentjalo nemithi yendabuko. Ngokuya kuka-Stohlgren no-Kumar (2013) &lt;ref name=&quot;:2&quot; /&gt;izenzo zabantu ezifana nokutheza, ukugubha iintjalo kanye nokutjhisa amahlathi notjani zidlala indima ekulu ekutjhabalaleni kweentjalo nemithi yendabuko. Ngamanye amagama, nabatheza bebaguba iintjalo kodwana bangazitjali nanyana bazijamiselele kubanga ukutjhabalala kwemithi neentjalo ngombana ziyancipha nabenza njalo.

==== 3.      Ituthuko yezehlalakuhle. ====
Kunetuthuko enengi khulu eyenzeka mihla namalanga ephasini esiphila kilo (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). U-Stohlgren no-Kumar (2013) &lt;ref name=&quot;:2&quot; /&gt;baveze bonyana abantu nabakha iindawo ezitjha, imakhiwo kanye namadorobha amatjha, basusa imithi neentjalo zendabuko endaweni lezo begodu abalingi ukuzifudusela nanyana ukuzibulunga. Lokhu kufaka isandla ekutjhabalaliseni iintjalo nemithi.

==== 4.      Amabubulo namarhwebo ====
Amabubulo namarhwebo asebenzisa iintjalo nemithi yendabuko ukukhiqhiza imikhiqhizo ebayithengisako, kodwana abanandaba nokobanyana imithi neentjalo leyo iyaphela begodu ifuna ukujamiselwela ngokuthi batjale eminye (Stohlgren no-Kumar 2013)&lt;ref name=&quot;:2&quot; /&gt;. Lokhu nakho kudlala indima ekulu ekutjhabalaliseleni iintjalo nemithi.

==== 5.      Itjhuguluko lebhoduluko ====
Itjhuguluko lebhoduluko ekufaka hlangana ubujamo bezulu lobo obutjhugulula iinkhathi nezinga ebenza ngakho izinto kumraro khulu eentjalweni nemithi yendabuko (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Ukungezelela, imithi neentjalo lezo zizithola zibhalelwa kuphila ngaphasi kwetjhugululo lebhoduluko nelobujamo bezulu (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). [https://www.kompozisyontv.com.tr/ kompozisyon] Ngamanye amagama, lokha nakutjhisa ngendlela engakajwaleki isikhathi eside nanyana kumakhaza khulu isikhathi eside ukudlula ngenjayelo ngebanga lamatjhuguluko webhoduluko nanyana wobujamo bezulu, iintjalo nemithi yendabuko le igcina ihlongakala begodu ingasamili.

=== Isiphetho ===
Ukutjhabalala kweentjalo nemithi yendabuko yinto embi nenomthelela omumbi eempilweni zethu ngombana kuzokuba nokudla nemitjhoga ebesiyinikelwa mimithi neentjalo lezo engasazokutholakala. Ngalokho-ke, kuqakathekile bonyana sinakekele zoke iintjalo nemithi, khulukhulu yendabuko ngombana ngizo ezisirhelebha khulu epilweni .

== Iinkomba ==
{{Reflist}}</text>
      <sha1>2bgyj8xrsee7ttqvtgk0jq5f2rep1vd</sha1>
    </revision>
    <revision>
      <id>5905</id>
      <parentid>5104</parentid>
      <timestamp>2025-10-06T13:19:58Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <minor />
      <origin>5905</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6769" sha1="2m39itqljxy0qgia0d4odfsmc162h0e" xml:space="preserve">[[Isimumathi:Isirhorhopha.jpg|thumb|Isirhorhopha]]

Iintjalo nemithi esiphila hlangana nazo nanyana ezitholakala eendaweni zangekhethu ziqakatheke khulu. Kunemisebenzi eminengi eyenzako ukuze siphile ipilo ehle nephephileko. Nanyana kunjalo, kunomraro wokutjhabalala kweentjalo nemithi enarheni yoke zombelele (Pfab no-Victor 2002&lt;ref name=&quot;:0&quot;&gt;Pfab, M. F. &amp; Victor, J. E. Threatened plants of Gauteng, South Africa. ''South African Journal of Botany'', 68:370-375.&lt;/ref&gt;; ne-Wikipedia 2024&lt;ref name=&quot;:1&quot;&gt;Wikipedia. 2024. ''List of critically endangered plants''. Litholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/List_of_critically_endangered_plants&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [12 kuRhoboyi 2024].&lt;/ref&gt;). Ngokuya kuka-Stohlgren no-Kumar (2013:205)&lt;ref name=&quot;:2&quot;&gt;Stohlgren, T. T. &amp; Kumar, S. 2013. Endangered Plants. ''Encyclopedia of Biodiversity'', 3: 465-477. Elsevier.&lt;/ref&gt;  ama-% ama-95 ukuya kuma-% ama-99 wemithi neentjalo ezikhethekileko ebe zikhona ngaphambilini sele zingasekho nanyana ziseduze nokungasabi khona. Ibelo leli ezitjhabalala ngalo ngilo elithusa abatlhogomeli bemvelo nanyana bendabuko (Stohlgren noKumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Ngamanye amagama, ukutjhabalala kweentjalo nemithi bekuvele kukhona kodwana nje umraro kukuthi zitjhabalala ngebelo eliphezulu khulu begodu kubudisi ukulilawula. Eenhlokwaneni ezilandelako sizokutjheja bonyana sikhuluma ngani nasikhuluma ngokutjhabalala kweentjalo nemithi begodi sibuye sitjheje neembangela nanyana isithintela esibanga ukutjhabalala kwemithi neentjalo lokhu. 

=== Sikhuluma ngani nasikhuluma ngokutjhabalala kweentjalo nemithi na? ===
[[Isimumathi:Ithuthumbo.jpg|left|thumb|Ithuthumbo]]
I-South African National Biodiversity Institute (I-SANBI) [2010&lt;ref name=&quot;:3&quot;&gt;South African National Biodiversity Institute. 2010. ''Threatened Species: A guide to Red Lists and their use in conservation''. Threatened Species Programme. SANBI: Pretoria.&lt;/ref&gt;] yathi, kukhona iintjalo nemithi, khulukhulu yendabuko nanyana yemvelo leyo  ekhamba inyamalala ngemva kwesikhathi. Ngokuya kwebonelophambili, imithi neentjalo le ekhamba inyamalala ilinganiselwa een-2 553 eSewula Afrika kwaphela (SANBI 2013&lt;ref&gt;South African National Biodiversity Institute. 2013. ''Plants in Peril''. SANBI: Biodiversity for Life: Pretoria.&lt;/ref&gt;). Ukungezelela, iintjalo lezo nemithi kufikela lapho zingasatholakali khona ngemva kokunyamela (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;; ne-Wikipedia 2024&lt;ref name=&quot;:1&quot; /&gt;). Ukunyamela kweentjalo nemithi lokhu bezingasatholakali kubizwa bonyana kutjhabalala kweentjalo nemithi (SANBI 2010&lt;ref name=&quot;:3&quot; /&gt;). 

[[:en:List_of_critically_endangered_plants|Ukutjhabalala kweentjalo nemithi]]  lokhu kubangelwa zizinto ezihlukileko begodu nebelo lokutjhabalala kwazo akufani. Kukhona ezinye ezitjhabalala ngebelo eliphezulu khulu, khulukhulu lezo ezitholakala emadorobheni bese kubuye godu kube nalezo ezitjhabalala ngebelo elingasiphezulu khulu (Pfab no-Victor 2002&lt;ref name=&quot;:0&quot; /&gt;). 

Esikhathini esinengi iintjalo nemithi etjhabalalako ngileyo yendabuko begodu ekhethekileko leyo engatholakali koke (Pfab no-Victor 2002&lt;ref name=&quot;:0&quot; /&gt;; no-Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Ngokuya kuka-Stohlgren no-Kumar (2013)&lt;ref name=&quot;:2&quot; /&gt; basekelwa yi-SANBI (2010)&lt;ref name=&quot;:3&quot; /&gt;, iintjalo nemithi yendabuko nanyana yemvelo le, ibongazimbi abakhulu tle ngebanga lokuthi ukhona ukuphila endaweni leyo nanyana evelele kiyo begodu ipilo yayo ikhambelana nebhoduluko lendawo lelo. Ngamanye amagama, ihlabathi, amanzi, umoya nobujamo bezulu obuhlukileko bakwezinye iindawo abukalungeli iintjalo nemithi yendabuko le. Esihlokweni esilandelako sizokutjheja iimbangela zokutjhabalalisa iintjalo nemithi.

=== Imbangelo yokutjhabalala kwemithi kanye neentjalo ===
Zinengi iimbangela ezibanga ukutjhabalala kwemithi neentjalo esele zitshwaye babantu abanengi iphasi loke leli kodwana kulekulumo-pendulwano sizokudzimelela kwezilandelako:

==== 1.      Ukutlhayela kweendawo zazo ====
[[Isimumathi:Umomori.jpg|thumb|Umomori]]
Ukutlhayela kweendawo la iintjalo nemithi yendabuko ingaphila khona kumraro omukhulu (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Iintjalo nemithi le izithola ingasakhoni ukunaba kanye nokukhula ngebanga lokuthi iindawo zazo ziyancipha begodu akusenasikhala la zinganabela nanyana zikhulele khona (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;).

==== 2.      Izenzo zabantu ====
Izenzo zabantu zinomthelela omkhulu tle ekutjhabalaleni kweentjalo nemithi yendabuko. Ngokuya kuka-Stohlgren no-Kumar (2013) &lt;ref name=&quot;:2&quot; /&gt;izenzo zabantu ezifana nokutheza, ukugubha iintjalo kanye nokutjhisa amahlathi notjani zidlala indima ekulu ekutjhabalaleni kweentjalo nemithi yendabuko. Ngamanye amagama, nabatheza bebaguba iintjalo kodwana bangazitjali nanyana bazijamiselele kubanga ukutjhabalala kwemithi neentjalo ngombana ziyancipha nabenza njalo.

==== 3.      Ituthuko yezehlalakuhle. ====
Kunetuthuko enengi khulu eyenzeka mihla namalanga ephasini esiphila kilo (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). U-Stohlgren no-Kumar (2013) &lt;ref name=&quot;:2&quot; /&gt;baveze bonyana abantu nabakha iindawo ezitjha, imakhiwo kanye namadorobha amatjha, basusa imithi neentjalo zendabuko endaweni lezo begodu abalingi ukuzifudusela nanyana ukuzibulunga. Lokhu kufaka isandla ekutjhabalaliseni iintjalo nemithi.

==== 4.      Amabubulo namarhwebo ====
Amabubulo namarhwebo asebenzisa iintjalo nemithi yendabuko ukukhiqhiza imikhiqhizo ebayithengisako, kodwana abanandaba nokobanyana imithi neentjalo leyo iyaphela begodu ifuna ukujamiselwela ngokuthi batjale eminye (Stohlgren no-Kumar 2013)&lt;ref name=&quot;:2&quot; /&gt;. Lokhu nakho kudlala indima ekulu ekutjhabalaliseleni iintjalo nemithi.

==== 5.      Itjhuguluko lebhoduluko ====
Itjhuguluko lebhoduluko ekufaka hlangana ubujamo bezulu lobo obutjhugulula iinkhathi nezinga ebenza ngakho izinto kumraro khulu eentjalweni nemithi yendabuko (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). Ukungezelela, imithi neentjalo lezo zizithola zibhalelwa kuphila ngaphasi kwetjhugululo lebhoduluko nelobujamo bezulu (Stohlgren no-Kumar 2013&lt;ref name=&quot;:2&quot; /&gt;). [https://www.kompozisyontv.com.tr/ kompozisyon] Ngamanye amagama, lokha nakutjhisa ngendlela engakajwaleki isikhathi eside nanyana kumakhaza khulu isikhathi eside ukudlula ngenjayelo ngebanga lamatjhuguluko webhoduluko nanyana wobujamo bezulu, iintjalo nemithi yendabuko le igcina ihlongakala begodu ingasamili.

=== Isiphetho ===
Ukutjhabalala kweentjalo nemithi yendabuko yinto embi nenomthelela omumbi eempilweni zethu ngombana kuzokuba nokudla nemitjhoga ebesiyinikelwa mimithi neentjalo lezo engasazokutholakala. Ngalokho-ke, kuqakathekile bonyana sinakekele zoke iintjalo nemithi, khulukhulu yendabuko ngombana ngizo ezisirhelebha khulu epilweni .

== Iinkomba ==
{{Reflist}}</text>
      <sha1>2m39itqljxy0qgia0d4odfsmc162h0e</sha1>
    </revision>
  </page>
  <page>
    <title>Iintjhijilo abantwana abazintandani abaqalana nazo</title>
    <ns>0</ns>
    <id>158</id>
    <revision>
      <id>762</id>
      <timestamp>2024-06-30T16:55:27Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Intandani''' mntwana onganababelethi bobabili, umma no baba.  &quot;</comment>
      <origin>762</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="65" sha1="s1mf32zb7mvpzlkbnur3mfl2vhz8scx" xml:space="preserve">'''Intandani''' mntwana onganababelethi bobabili, umma no baba.

</text>
      <sha1>s1mf32zb7mvpzlkbnur3mfl2vhz8scx</sha1>
    </revision>
    <revision>
      <id>763</id>
      <parentid>762</parentid>
      <timestamp>2024-06-30T19:18:55Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>763</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="525" sha1="lq43g2y3lo4a4ari7hj6eydp30lzo99" xml:space="preserve">'''Intandani''' mntwana onganababelethi bobabili, umma no baba. Baphila ngaphasi kobudisi bokubandlulwa nokukhonjwa nesibanga sesimo sabo. Abantwana laba lokha nangabe bangahlali ekhaya lapho kuhlala khona abantwana abazintandani baqalane nobudisi bokuthi bangahlukunyezwa. 

Abanye babo baba nokugandeleleka komkhumbulo ngesibanga sokuthi bahlulwe kuthi bamukele isimo esibudisi sokulahlekelwa babelethi.

Abantwana laba nangabe banganabo ababonisi bagcina sele babasebungozini bokuthi bangagcina sele bangakacedi isikolo.

</text>
      <sha1>lq43g2y3lo4a4ari7hj6eydp30lzo99</sha1>
    </revision>
    <revision>
      <id>764</id>
      <parentid>763</parentid>
      <timestamp>2024-07-13T19:58:48Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>764</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="527" sha1="2j0he0vd35715xn88x41ihj2hgr3x4o" xml:space="preserve">'''Intandani''' mntwana onganababelethi bobabili, umma no baba. Baphila ngaphasi kobudisi bokubandlululwa nokukhonjwa nesibanga sesimo sabo. Abantwana laba lokha nangabe bangahlali ekhaya lapho kuhlala khona abantwana abazintandani baqalane nobudisi bokuthi bangahlukunyezwa. 

Abanye babo baba nokugandeleleka komkhumbulo ngesibanga sokuthi bahlulwe kuthi bamukele isimo esibudisi sokulahlekelwa babelethi.

Abantwana laba nangabe banganabo ababonisi bagcina sele babasebungozini bokuthi bangagcina sele bangakacedi isikolo.

</text>
      <sha1>2j0he0vd35715xn88x41ihj2hgr3x4o</sha1>
    </revision>
    <revision>
      <id>765</id>
      <parentid>764</parentid>
      <timestamp>2024-10-14T13:46:46Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>764</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="527" sha1="2j0he0vd35715xn88x41ihj2hgr3x4o" xml:space="preserve">'''Intandani''' mntwana onganababelethi bobabili, umma no baba. Baphila ngaphasi kobudisi bokubandlululwa nokukhonjwa nesibanga sesimo sabo. Abantwana laba lokha nangabe bangahlali ekhaya lapho kuhlala khona abantwana abazintandani baqalane nobudisi bokuthi bangahlukunyezwa. 

Abanye babo baba nokugandeleleka komkhumbulo ngesibanga sokuthi bahlulwe kuthi bamukele isimo esibudisi sokulahlekelwa babelethi.

Abantwana laba nangabe banganabo ababonisi bagcina sele babasebungozini bokuthi bangagcina sele bangakacedi isikolo.

</text>
      <sha1>2j0he0vd35715xn88x41ihj2hgr3x4o</sha1>
    </revision>
  </page>
  <page>
    <title>Ijuba nezuba.</title>
    <ns>0</ns>
    <id>159</id>
    <revision>
      <id>766</id>
      <timestamp>2024-08-07T05:52:22Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot; == Ijuba nezuba == Iphasini kunezinye zezinto lezo ezitjhidelene khulu nanyana eziwela ngaphasi komndeni munye. Kwesinye isikhathi izinto lezo zithathwa kwangathi begodu zibizwa ngathi yinto yinye, kodwana akusinjalo. Izinto lezo zifaka hlangana ijuba nezuba. Esigatjeni esilandelako sizokutjheja umehluko hlangana kwejuba nezuba.  === Kuyini ijuba? === Ijuba ngenye yenyoni leyo etholakala khulu ekhaya. Ijuba kuyinyoni leyo efuywako begodu ethandwa khulu bentwana. Ijuba l...&quot;</comment>
      <origin>766</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1432" sha1="2ig8maure3seozakc8moow1w92heb8u" xml:space="preserve">
== Ijuba nezuba ==
Iphasini kunezinye zezinto lezo ezitjhidelene khulu nanyana eziwela ngaphasi komndeni munye. Kwesinye isikhathi izinto lezo zithathwa kwangathi begodu zibizwa ngathi yinto yinye, kodwana akusinjalo. Izinto lezo zifaka hlangana ijuba nezuba. Esigatjeni esilandelako sizokutjheja umehluko hlangana kwejuba nezuba.

=== Kuyini ijuba? ===
Ijuba ngenye yenyoni leyo etholakala khulu ekhaya. Ijuba kuyinyoni leyo efuywako begodu ethandwa khulu bentwana. Ijuba lakhelwa ihogo ukuthi lihlale lapho begodu lithengelwa ukudla. Ukudlula lapho lithelelwa mamanzi. Liyafundiswa bonyana ekhaya kukhuphi begodu livulelwe liphaphe namanye amajuba kanye nemihlobo eminye yeenyoni. Kodwana, ngesikhathi sokubuya libuyela ekhaya ehogweni yalo.

=== Kuyini izuba? ===
Izuba lona ngezinye zeenyoni lezo ezitholakala khulu ehlathunini. Akusikanengi lifuywa begodu nanyana lingafuywa, walivulela nanyana nalithole ithuba liyakhamba libuyele ehlathini. Lokhu kusitjela bonyana indabuko yalo khulu, kukuhlala nokuphila ehlathini.

Nanyana kunjalo, ngebanga lethuthuko yezokuhlalakuhle, amazuba sele azithola hlangana nabantu kwesinye isikhathi ngebanga lokususwa kweendawo zawo kanye nendlala. Ngalokho-ke, singatjho bonyana izuba lijuba lommango.

=== Isiphetho ===
Ijuba nezuba ziinyoni ezimbili ezihlobana eduze. Kodwana umehluko hlangana nazo kukuthi enye ihlala emakhaya, begodu iyafuywa kanti enye ihlala ehlathini begodu ayifuywa.</text>
      <sha1>2ig8maure3seozakc8moow1w92heb8u</sha1>
    </revision>
    <revision>
      <id>767</id>
      <parentid>766</parentid>
      <timestamp>2024-09-18T15:43:26Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>767</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1433" sha1="5j8uwt0vuoafc1eywtfhfsmtuzo08of" xml:space="preserve">
== Ijuba nezuba. ==
Iphasini kunezinye zezinto lezo ezitjhidelene khulu nanyana eziwela ngaphasi komndeni munye. Kwesinye isikhathi izinto lezo zithathwa kwangathi begodu zibizwa ngathi yinto yinye, kodwana akusinjalo. Izinto lezo zifaka hlangana ijuba nezuba. Esigatjeni esilandelako sizokutjheja umehluko hlangana kwejuba nezuba.

=== Kuyini ijuba? ===
Ijuba ngenye yenyoni leyo etholakala khulu ekhaya. Ijuba kuyinyoni leyo efuywako begodu ethandwa khulu bentwana. Ijuba lakhelwa ihogo ukuthi lihlale lapho begodu lithengelwa ukudla. Ukudlula lapho lithelelwa mamanzi. Liyafundiswa bonyana ekhaya kukhuphi begodu livulelwe liphaphe namanye amajuba kanye nemihlobo eminye yeenyoni. Kodwana, ngesikhathi sokubuya libuyela ekhaya ehogweni yalo.

=== Kuyini izuba? ===
Izuba lona ngezinye zeenyoni lezo ezitholakala khulu ehlathunini. Akusikanengi lifuywa begodu nanyana lingafuywa, walivulela nanyana nalithole ithuba liyakhamba libuyele ehlathini. Lokhu kusitjela bonyana indabuko yalo khulu, kukuhlala nokuphila ehlathini.

Nanyana kunjalo, ngebanga lethuthuko yezokuhlalakuhle, amazuba sele azithola hlangana nabantu kwesinye isikhathi ngebanga lokususwa kweendawo zawo kanye nendlala. Ngalokho-ke, singatjho bonyana izuba lijuba lommango.

=== Isiphetho ===
Ijuba nezuba ziinyoni ezimbili ezihlobana eduze. Kodwana umehluko hlangana nazo kukuthi enye ihlala emakhaya, begodu iyafuywa kanti enye ihlala ehlathini begodu ayifuywa.</text>
      <sha1>5j8uwt0vuoafc1eywtfhfsmtuzo08of</sha1>
    </revision>
    <revision>
      <id>768</id>
      <parentid>767</parentid>
      <timestamp>2024-10-14T13:46:47Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>767</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1433" sha1="5j8uwt0vuoafc1eywtfhfsmtuzo08of" xml:space="preserve">
== Ijuba nezuba. ==
Iphasini kunezinye zezinto lezo ezitjhidelene khulu nanyana eziwela ngaphasi komndeni munye. Kwesinye isikhathi izinto lezo zithathwa kwangathi begodu zibizwa ngathi yinto yinye, kodwana akusinjalo. Izinto lezo zifaka hlangana ijuba nezuba. Esigatjeni esilandelako sizokutjheja umehluko hlangana kwejuba nezuba.

=== Kuyini ijuba? ===
Ijuba ngenye yenyoni leyo etholakala khulu ekhaya. Ijuba kuyinyoni leyo efuywako begodu ethandwa khulu bentwana. Ijuba lakhelwa ihogo ukuthi lihlale lapho begodu lithengelwa ukudla. Ukudlula lapho lithelelwa mamanzi. Liyafundiswa bonyana ekhaya kukhuphi begodu livulelwe liphaphe namanye amajuba kanye nemihlobo eminye yeenyoni. Kodwana, ngesikhathi sokubuya libuyela ekhaya ehogweni yalo.

=== Kuyini izuba? ===
Izuba lona ngezinye zeenyoni lezo ezitholakala khulu ehlathunini. Akusikanengi lifuywa begodu nanyana lingafuywa, walivulela nanyana nalithole ithuba liyakhamba libuyele ehlathini. Lokhu kusitjela bonyana indabuko yalo khulu, kukuhlala nokuphila ehlathini.

Nanyana kunjalo, ngebanga lethuthuko yezokuhlalakuhle, amazuba sele azithola hlangana nabantu kwesinye isikhathi ngebanga lokususwa kweendawo zawo kanye nendlala. Ngalokho-ke, singatjho bonyana izuba lijuba lommango.

=== Isiphetho ===
Ijuba nezuba ziinyoni ezimbili ezihlobana eduze. Kodwana umehluko hlangana nazo kukuthi enye ihlala emakhaya, begodu iyafuywa kanti enye ihlala ehlathini begodu ayifuywa.</text>
      <sha1>5j8uwt0vuoafc1eywtfhfsmtuzo08of</sha1>
    </revision>
  </page>
  <page>
    <title>Ikolo yamakhrestu</title>
    <ns>0</ns>
    <id>160</id>
    <revision>
      <id>769</id>
      <timestamp>2024-03-09T10:47:37Z</timestamp>
      <contributor>
        <username>incubator&gt;NomusaAMethula</username>
        <id>0</id>
      </contributor>
      <comment>This is an article about Christianity and its special days.</comment>
      <origin>769</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="712" sha1="dlx8bbz7uzibs4nrx803e75dgble7cz" xml:space="preserve">'''Ikolo yamakhrestu''' yikolo eqale iimfundiso zika zimu. Amakhrestu bathemba bona uJesu wafela izono zethu soke. Ukuze siphile inguna phakade. Lokho kwenza bona noma senze okungakhambiselani nekolo le, sibuyele kuzimu ngomthandazo simubawe bona asilibalele. Kanengi abantu abamakhrestu babizwa bona bazalwana. Omunye angathi makholwa. 
'''Amalanga aqhakathekile ''' wamakholwa kufaka hlangana nelanga lokubhubha kukaJesu, esithi yi ''Good Friday'', nelanga lokubelethwa kukaJesu, okuyikhrismasi. Abanye bangabala nokubhabhadiswa njengesikhumbuzo. Bathemba bona umuntu uba sidalwa esitjha. I-''Good Friday'' kanengi iba ngenyanga kaSihlabantangana. Amasonto ayahlangana bakhumbule ukubhubha nokuvuka kukaJesu.

</text>
      <sha1>dlx8bbz7uzibs4nrx803e75dgble7cz</sha1>
    </revision>
    <revision>
      <id>770</id>
      <parentid>769</parentid>
      <timestamp>2024-03-09T10:52:43Z</timestamp>
      <contributor>
        <username>incubator&gt;NomusaAMethula</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>I added a picture of the cross of Jesus Christ</comment>
      <origin>770</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="847" sha1="h1n38cqadkb2gsq2juu3i7vq0lupii4" xml:space="preserve">[[Isimumathi:Christianity-Jesus Christ Died for your Sin.jpg|thumb|This is the cross where it is believed that Jesus Christ died on.]]
'''Ikolo yamakhrestu''' yikolo eqale iimfundiso zika zimu. Amakhrestu bathemba bona uJesu wafela izono zethu soke. Ukuze siphile inguna phakade. Lokho kwenza bona noma senze okungakhambiselani nekolo le, sibuyele kuzimu ngomthandazo simubawe bona asilibalele. Kanengi abantu abamakhrestu babizwa bona bazalwana. Omunye angathi makholwa. 
'''Amalanga aqhakathekile ''' wamakholwa kufaka hlangana nelanga lokubhubha kukaJesu, esithi yi ''Good Friday'', nelanga lokubelethwa kukaJesu, okuyikhrismasi. Abanye bangabala nokubhabhadiswa njengesikhumbuzo. Bathemba bona umuntu uba sidalwa esitjha. I-''Good Friday'' kanengi iba ngenyanga kaSihlabantangana. Amasonto ayahlangana bakhumbule ukubhubha nokuvuka kukaJesu.

</text>
      <sha1>h1n38cqadkb2gsq2juu3i7vq0lupii4</sha1>
    </revision>
    <revision>
      <id>771</id>
      <parentid>770</parentid>
      <timestamp>2024-10-14T13:46:47Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>770</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="847" sha1="h1n38cqadkb2gsq2juu3i7vq0lupii4" xml:space="preserve">[[Isimumathi:Christianity-Jesus Christ Died for your Sin.jpg|thumb|This is the cross where it is believed that Jesus Christ died on.]]
'''Ikolo yamakhrestu''' yikolo eqale iimfundiso zika zimu. Amakhrestu bathemba bona uJesu wafela izono zethu soke. Ukuze siphile inguna phakade. Lokho kwenza bona noma senze okungakhambiselani nekolo le, sibuyele kuzimu ngomthandazo simubawe bona asilibalele. Kanengi abantu abamakhrestu babizwa bona bazalwana. Omunye angathi makholwa. 
'''Amalanga aqhakathekile ''' wamakholwa kufaka hlangana nelanga lokubhubha kukaJesu, esithi yi ''Good Friday'', nelanga lokubelethwa kukaJesu, okuyikhrismasi. Abanye bangabala nokubhabhadiswa njengesikhumbuzo. Bathemba bona umuntu uba sidalwa esitjha. I-''Good Friday'' kanengi iba ngenyanga kaSihlabantangana. Amasonto ayahlangana bakhumbule ukubhubha nokuvuka kukaJesu.

</text>
      <sha1>h1n38cqadkb2gsq2juu3i7vq0lupii4</sha1>
    </revision>
    <revision>
      <id>3278</id>
      <parentid>771</parentid>
      <timestamp>2025-07-02T09:32:07Z</timestamp>
      <contributor>
        <username>Andre Engels</username>
        <id>480</id>
      </contributor>
      <comment>merge</comment>
      <origin>3278</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="866" sha1="rzv0qkyr62i27rs4v6xi6fij1o6yjja" xml:space="preserve">{{merge|Ubukresite}}
[[Isimumathi:Christianity-Jesus Christ Died for your Sin.jpg|thumb|This is the cross where it is believed that Jesus Christ died on.]]
'''Ikolo yamakhrestu''' yikolo eqale iimfundiso zika zimu. Amakhrestu bathemba bona uJesu wafela izono zethu soke. Ukuze siphile inguna phakade. Lokho kwenza bona noma senze okungakhambiselani nekolo le, sibuyele kuzimu ngomthandazo simubawe bona asilibalele. Kanengi abantu abamakhrestu babizwa bona bazalwana. Omunye angathi makholwa. 
'''Amalanga aqhakathekile ''' wamakholwa kufaka hlangana nelanga lokubhubha kukaJesu, esithi yi ''Good Friday'', nelanga lokubelethwa kukaJesu, okuyikhrismasi. Abanye bangabala nokubhabhadiswa njengesikhumbuzo. Bathemba bona umuntu uba sidalwa esitjha. I-''Good Friday'' kanengi iba ngenyanga kaSihlabantangana. Amasonto ayahlangana bakhumbule ukubhubha nokuvuka kukaJesu.</text>
      <sha1>rzv0qkyr62i27rs4v6xi6fij1o6yjja</sha1>
    </revision>
  </page>
  <page>
    <title>Ikondlo</title>
    <ns>0</ns>
    <id>161</id>
    <revision>
      <id>772</id>
      <timestamp>2024-07-11T11:01:21Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Ikondlo''' kumtlolo lapho imbongi nanyana umtloli aveza khona amazizo wakhe ngesihloko esithileko esisekhumbulweni waso.  &quot;</comment>
      <origin>772</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="125" sha1="k033irxltiwjdkmfgzyau8z89f8ctuw" xml:space="preserve">'''Ikondlo''' kumtlolo lapho imbongi nanyana umtloli aveza khona amazizo wakhe ngesihloko esithileko esisekhumbulweni waso.

</text>
      <sha1>k033irxltiwjdkmfgzyau8z89f8ctuw</sha1>
    </revision>
    <revision>
      <id>773</id>
      <parentid>772</parentid>
      <timestamp>2024-10-14T13:46:47Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>772</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="125" sha1="k033irxltiwjdkmfgzyau8z89f8ctuw" xml:space="preserve">'''Ikondlo''' kumtlolo lapho imbongi nanyana umtloli aveza khona amazizo wakhe ngesihloko esithileko esisekhumbulweni waso.

</text>
      <sha1>k033irxltiwjdkmfgzyau8z89f8ctuw</sha1>
    </revision>
    <revision>
      <id>5794</id>
      <parentid>773</parentid>
      <timestamp>2025-09-23T18:21:15Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5794</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="233" sha1="4hr9oz2ffpxbax7nlsedky0ie5tjaib" xml:space="preserve">'''Ikondlo''' kumtlolo lapho imbongi nanyana umtloli aveza khona amazizo wakhe ngesihloko esithileko esisekhumbulweni waso.

[[Category:Imbongi]]
[[Category:Inkondlo]]
[[Category:Ubuthakgha bomlomo]]
[[Category: Imihlobo yeenkondlo]]</text>
      <sha1>4hr9oz2ffpxbax7nlsedky0ie5tjaib</sha1>
    </revision>
    <revision>
      <id>5795</id>
      <parentid>5794</parentid>
      <timestamp>2025-09-23T18:27:36Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5795</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="568" sha1="4hb1ftmkyk1dhfptj3sf5xr3rlqz3oq" xml:space="preserve">'''Ikondlo''' kumtlolo lapho imbongi nanyana umtloli aveza khona amazizo wakhe ngesihloko esithileko esisekhumbulweni waso.&lt;ref&gt;[https://dictionary.cambridge.org/dictionary/english/poem POEM | English meaning - Cambridge Dictionary]&lt;/ref&gt;Ikondlo itlolwa ngemida engafiki ekugcineni kwekhasi kodwana iphelela phakakthi nendawo. ihlukuniseke ngokwendima ezibizwa bona ma- stanza ngelimi lesiNgisi. Ikondlo ineskhiwo sangaphandle nesangaphakathi.

== Iinkomba ==
[[Category:Imbongi]]
[[Category:Inkondlo]]
[[Category:Ubuthakgha bomlomo]]
[[Category: Imihlobo yeenkondlo]]</text>
      <sha1>4hb1ftmkyk1dhfptj3sf5xr3rlqz3oq</sha1>
    </revision>
    <revision>
      <id>5796</id>
      <parentid>5795</parentid>
      <timestamp>2025-09-23T18:28:18Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5796</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="568" sha1="igl3pq260lcsiu307m9uyz5mywvt4i8" xml:space="preserve">'''Ikondlo''' kumtlolo lapho imbongi nanyana umtloli aveza khona amazizo wakhe ngesihloko esithileko esisekhumbulweni waso.&lt;ref&gt;[https://dictionary.cambridge.org/dictionary/english/poem POEM | English meaning - Cambridge Dictionary]&lt;/ref&gt;Ikondlo itlolwa ngemida engafiki ekugcineni kwekhasi kodwana iphelela phakakthi nendawo. ihlukuniseke ngokwendima ezibizwa bona ma- stanza ngelimi lesiNgisi. Ikondlo ineskhiwo sangaphandle nesangaphakathi.

== Iinkomb. ==
[[Category:Imbongi]]
[[Category:Inkondlo]]
[[Category:Ubuthakgha bomlomo]]
[[Category: Imihlobo yeenkondlo]]</text>
      <sha1>igl3pq260lcsiu307m9uyz5mywvt4i8</sha1>
    </revision>
  </page>
  <page>
    <title>Ikrismesi</title>
    <ns>0</ns>
    <id>162</id>
    <revision>
      <id>774</id>
      <timestamp>2016-02-21T08:25:46Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;&lt;div style=&quot;float:left;margin:0.5em 0.9em 0.4em 0&quot;&gt;[[Isimumathi:The visit of the wise-men.jpg|130px|khisimusi.]]&lt;/div&gt; &lt;div id=&quot;mp-dyk&quot; style=&quot;padding:2px 5px; font-size:95%;&quot;&gt; '''I...&quot;</comment>
      <origin>774</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="533" sha1="sww9j2h20fs4894058pu3ub73mbnu2g" xml:space="preserve">&lt;div style=&quot;float:left;margin:0.5em 0.9em 0.4em 0&quot;&gt;[[Isimumathi:The visit of the wise-men.jpg|130px|khisimusi.]]&lt;/div&gt;
&lt;div id=&quot;mp-dyk&quot; style=&quot;padding:2px 5px; font-size:95%;&quot;&gt;
'''Ikrismesi''' umgidingo odumileko kwikolo yobukreste begodu igidingwa eengcenyeni ezinengi zephasi namhlanje. Iskhathesi sihlanganisa abantwu bona nemindenaabo, kuthokozwe khulu. Umgidingolo ukhumbula ilanga uJesu abelethwa ngalo, ngo 25 kunobayeni qobe minyaka. Ungabona kobanyana Ikrismesi itjhidile ngerhwebo begodu neplarha zerhwebo enarheni yoke.


</text>
      <sha1>sww9j2h20fs4894058pu3ub73mbnu2g</sha1>
    </revision>
    <revision>
      <id>775</id>
      <parentid>774</parentid>
      <timestamp>2024-03-08T10:15:08Z</timestamp>
      <contributor>
        <username>incubator&gt;Mzwakhe David18</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>grammar and added a paragraph</comment>
      <origin>775</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="916" sha1="m8dbdtp5vkjmz2cmrx0tqhz6eh1xeog" xml:space="preserve">&lt;div style=&quot;float:left;margin:0.5em 0.9em 0.4em 0&quot;&gt;[[Isimumathi:The visit of the wise-men.jpg|130px|khisimusi.]]&lt;/div&gt;
&lt;div id=&quot;mp-dyk&quot; style=&quot;padding:2px 5px; font-size:95%;&quot;&gt;
'''Ikrismesi''' umgidingo odumileko kwikolo yobukrestu begodu igidingwa engcenyeni ezinengi zephasi namhlanje. Iskhathesi sihlanganisa kusikathi esihle khulu lapho imindeni ithola ithuba lokobana bahlanganyele bebavuselele ukuzwana kwabo. Umgidingo lo ukhumbula ilanga uJesu abelethwa ngalo, ngen 25 kunobayeni qobe minyaka. Ungabona kobanyana Ikrismesi itjhidile ngerhwebo begodu neplarha zerhwebo enarheni yoke.


Ngelanga lika kresumusi abantu benza okuhlukahlukeneko ngombana kulilanga elihle khulu emuntwini woke, Abazalwana baya esondweni, imindeni iyapheka, abanye bazikhuphela endaweni zokududa kanye nokunye okunengi. Ngifuna kuthiwa bathi umndeni kade ucabene kangangani kodwana ngelanga leli bazwana boke befuthi kuyabambiswana.</text>
      <sha1>m8dbdtp5vkjmz2cmrx0tqhz6eh1xeog</sha1>
    </revision>
    <revision>
      <id>776</id>
      <parentid>775</parentid>
      <timestamp>2024-03-08T10:24:20Z</timestamp>
      <contributor>
        <username>incubator&gt;Mzwakhe David18</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>776</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="958" sha1="4tikgatfixatppx05s7igyqkzw67dt3" xml:space="preserve">&lt;div style=&quot;float:left;margin:0.5em 0.9em 0.4em 0&quot;&gt;[[Isimumathi:The visit of the wise-men.jpg|130px|khisimusi.]]&lt;/div&gt;
&lt;div id=&quot;mp-dyk&quot; style=&quot;padding:2px 5px; font-size:95%;&quot;&gt;
'''Ikrismesi''' umgidingo odumileko kwikolo yobukrestu begodu igidingwa engcenyeni ezinengi zephasi namhlanje. Iskhathesi sihlanganisa kusikathi esihle khulu lapho imindeni ithola ithuba lokobana bahlanganyele bebavuselele ukuzwana kwabo. Umgidingo lo ukhumbula ilanga uJesu abelethwa ngalo, ngen 25 kunobayeni qobe minyaka. Ungabona kobanyana Ikrismesi itjhidile ngerhwebo begodu neplarha zerhwebo enarheni yoke.

== Ukubaluleka kwelanga lika krisimusi ==
Ngelanga lika kresumusi abantu benza okuhlukahlukeneko ngombana kulilanga elihle khulu emuntwini woke, Abazalwana baya esondweni, imindeni iyapheka, abanye bazikhuphela endaweni zokududa kanye nokunye okunengi. Ngifuna kuthiwa bathi umndeni kade ucabene kangangani kodwana ngelanga leli bazwana boke befuthi kuyabambiswana.
</text>
      <sha1>4tikgatfixatppx05s7igyqkzw67dt3</sha1>
    </revision>
    <revision>
      <id>777</id>
      <parentid>776</parentid>
      <timestamp>2024-09-25T13:50:05Z</timestamp>
      <contributor>
        <username>Nintendofan885</username>
        <id>5</id>
      </contributor>
      <minor />
      <comment>Adding interwiki links to [[d:Q19809]]</comment>
      <origin>777</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="979" sha1="dvu7lfprsxqghdj6mynzjpfwmtrl7cr" xml:space="preserve">&lt;div style=&quot;float:left;margin:0.5em 0.9em 0.4em 0&quot;&gt;[[Isimumathi:The visit of the wise-men.jpg|130px|khisimusi.]]&lt;/div&gt;
&lt;div id=&quot;mp-dyk&quot; style=&quot;padding:2px 5px; font-size:95%;&quot;&gt;
'''Ikrismesi''' umgidingo odumileko kwikolo yobukrestu begodu igidingwa engcenyeni ezinengi zephasi namhlanje. Iskhathesi sihlanganisa kusikathi esihle khulu lapho imindeni ithola ithuba lokobana bahlanganyele bebavuselele ukuzwana kwabo. Umgidingo lo ukhumbula ilanga uJesu abelethwa ngalo, ngen 25 kunobayeni qobe minyaka. Ungabona kobanyana Ikrismesi itjhidile ngerhwebo begodu neplarha zerhwebo enarheni yoke.

== Ukubaluleka kwelanga lika krisimusi ==
Ngelanga lika kresumusi abantu benza okuhlukahlukeneko ngombana kulilanga elihle khulu emuntwini woke, Abazalwana baya esondweni, imindeni iyapheka, abanye bazikhuphela endaweni zokududa kanye nokunye okunengi. Ngifuna kuthiwa bathi umndeni kade ucabene kangangani kodwana ngelanga leli bazwana boke befuthi kuyabambiswana.

{{INTERWIKI|Q19809}}</text>
      <sha1>dvu7lfprsxqghdj6mynzjpfwmtrl7cr</sha1>
    </revision>
    <revision>
      <id>778</id>
      <parentid>777</parentid>
      <timestamp>2024-10-14T13:46:47Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>4 revisions imported</comment>
      <origin>777</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="979" sha1="dvu7lfprsxqghdj6mynzjpfwmtrl7cr" xml:space="preserve">&lt;div style=&quot;float:left;margin:0.5em 0.9em 0.4em 0&quot;&gt;[[Isimumathi:The visit of the wise-men.jpg|130px|khisimusi.]]&lt;/div&gt;
&lt;div id=&quot;mp-dyk&quot; style=&quot;padding:2px 5px; font-size:95%;&quot;&gt;
'''Ikrismesi''' umgidingo odumileko kwikolo yobukrestu begodu igidingwa engcenyeni ezinengi zephasi namhlanje. Iskhathesi sihlanganisa kusikathi esihle khulu lapho imindeni ithola ithuba lokobana bahlanganyele bebavuselele ukuzwana kwabo. Umgidingo lo ukhumbula ilanga uJesu abelethwa ngalo, ngen 25 kunobayeni qobe minyaka. Ungabona kobanyana Ikrismesi itjhidile ngerhwebo begodu neplarha zerhwebo enarheni yoke.

== Ukubaluleka kwelanga lika krisimusi ==
Ngelanga lika kresumusi abantu benza okuhlukahlukeneko ngombana kulilanga elihle khulu emuntwini woke, Abazalwana baya esondweni, imindeni iyapheka, abanye bazikhuphela endaweni zokududa kanye nokunye okunengi. Ngifuna kuthiwa bathi umndeni kade ucabene kangangani kodwana ngelanga leli bazwana boke befuthi kuyabambiswana.

{{INTERWIKI|Q19809}}</text>
      <sha1>dvu7lfprsxqghdj6mynzjpfwmtrl7cr</sha1>
    </revision>
    <revision>
      <id>1670</id>
      <parentid>778</parentid>
      <timestamp>2024-10-16T09:49:53Z</timestamp>
      <contributor>
        <username>JhsBot</username>
        <id>34</id>
      </contributor>
      <minor />
      <comment>bot: Removing interwiki template; the page is now connected to [[d:Q19809]]</comment>
      <origin>1670</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="957" sha1="ll84mbaiob878w9hnwcunej2i37z848" xml:space="preserve">&lt;div style=&quot;float:left;margin:0.5em 0.9em 0.4em 0&quot;&gt;[[Isimumathi:The visit of the wise-men.jpg|130px|khisimusi.]]&lt;/div&gt;
&lt;div id=&quot;mp-dyk&quot; style=&quot;padding:2px 5px; font-size:95%;&quot;&gt;
'''Ikrismesi''' umgidingo odumileko kwikolo yobukrestu begodu igidingwa engcenyeni ezinengi zephasi namhlanje. Iskhathesi sihlanganisa kusikathi esihle khulu lapho imindeni ithola ithuba lokobana bahlanganyele bebavuselele ukuzwana kwabo. Umgidingo lo ukhumbula ilanga uJesu abelethwa ngalo, ngen 25 kunobayeni qobe minyaka. Ungabona kobanyana Ikrismesi itjhidile ngerhwebo begodu neplarha zerhwebo enarheni yoke.

== Ukubaluleka kwelanga lika krisimusi ==
Ngelanga lika kresumusi abantu benza okuhlukahlukeneko ngombana kulilanga elihle khulu emuntwini woke, Abazalwana baya esondweni, imindeni iyapheka, abanye bazikhuphela endaweni zokududa kanye nokunye okunengi. Ngifuna kuthiwa bathi umndeni kade ucabene kangangani kodwana ngelanga leli bazwana boke befuthi kuyabambiswana.</text>
      <sha1>ll84mbaiob878w9hnwcunej2i37z848</sha1>
    </revision>
    <revision>
      <id>3008</id>
      <parentid>1670</parentid>
      <timestamp>2025-06-06T20:22:49Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>no page is safe</comment>
      <origin>3008</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1038" sha1="m6j9xwqi3zsj099d3tjbejv9ofumesy" xml:space="preserve">&lt;div style=&quot;float:left;margin:0.5em 0.9em 0.4em 0&quot;&gt;[[Isimumathi:The visit of the wise-men.jpg|130px|khisimusi.]]&lt;/div&gt;
&lt;div id=&quot;mp-dyk&quot; style=&quot;padding:2px 5px; font-size:95%;&quot;&gt;
'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. Ikrismesi''' umgidingo odumileko kwikolo yobukrestu begodu igidingwa engcenyeni ezinengi zephasi namhlanje. Iskhathesi sihlanganisa kusikathi esihle khulu lapho imindeni ithola ithuba lokobana bahlanganyele bebavuselele ukuzwana kwabo. Umgidingo lo ukhumbula ilanga uJesu abelethwa ngalo, ngen 25 kunobayeni qobe minyaka. Ungabona kobanyana Ikrismesi itjhidile ngerhwebo begodu neplarha zerhwebo enarheni yoke.

== Ukubaluleka kwelanga lika krisimusi ==
Ngelanga lika kresumusi abantu benza okuhlukahlukeneko ngombana kulilanga elihle khulu emuntwini woke, Abazalwana baya esondweni, imindeni iyapheka, abanye bazikhuphela endaweni zokududa kanye nokunye okunengi. Ngifuna kuthiwa bathi umndeni kade ucabene kangangani kodwana ngelanga leli bazwana boke befuthi kuyabambiswana.</text>
      <sha1>m6j9xwqi3zsj099d3tjbejv9ofumesy</sha1>
    </revision>
    <revision>
      <id>3108</id>
      <parentid>3008</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:JhsBot|JhsBot]]</comment>
      <origin>1670</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="957" sha1="ll84mbaiob878w9hnwcunej2i37z848" xml:space="preserve">&lt;div style=&quot;float:left;margin:0.5em 0.9em 0.4em 0&quot;&gt;[[Isimumathi:The visit of the wise-men.jpg|130px|khisimusi.]]&lt;/div&gt;
&lt;div id=&quot;mp-dyk&quot; style=&quot;padding:2px 5px; font-size:95%;&quot;&gt;
'''Ikrismesi''' umgidingo odumileko kwikolo yobukrestu begodu igidingwa engcenyeni ezinengi zephasi namhlanje. Iskhathesi sihlanganisa kusikathi esihle khulu lapho imindeni ithola ithuba lokobana bahlanganyele bebavuselele ukuzwana kwabo. Umgidingo lo ukhumbula ilanga uJesu abelethwa ngalo, ngen 25 kunobayeni qobe minyaka. Ungabona kobanyana Ikrismesi itjhidile ngerhwebo begodu neplarha zerhwebo enarheni yoke.

== Ukubaluleka kwelanga lika krisimusi ==
Ngelanga lika kresumusi abantu benza okuhlukahlukeneko ngombana kulilanga elihle khulu emuntwini woke, Abazalwana baya esondweni, imindeni iyapheka, abanye bazikhuphela endaweni zokududa kanye nokunye okunengi. Ngifuna kuthiwa bathi umndeni kade ucabene kangangani kodwana ngelanga leli bazwana boke befuthi kuyabambiswana.</text>
      <sha1>ll84mbaiob878w9hnwcunej2i37z848</sha1>
    </revision>
    <revision>
      <id>3479</id>
      <parentid>3108</parentid>
      <timestamp>2025-07-29T14:59:33Z</timestamp>
      <contributor>
        <username>Minorax</username>
        <id>38</id>
      </contributor>
      <origin>3479</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="843" sha1="pybg3210w4fc57r9ks8fziyg6h575oj" xml:space="preserve">[[Isimumathi:The visit of the wise-men.jpg|130px|khisimusi.]]

'''Ikrismesi''' umgidingo odumileko kwikolo yobukrestu begodu igidingwa engcenyeni ezinengi zephasi namhlanje. Iskhathesi sihlanganisa kusikathi esihle khulu lapho imindeni ithola ithuba lokobana bahlanganyele bebavuselele ukuzwana kwabo. Umgidingo lo ukhumbula ilanga uJesu abelethwa ngalo, ngen 25 kunobayeni qobe minyaka. Ungabona kobanyana Ikrismesi itjhidile ngerhwebo begodu neplarha zerhwebo enarheni yoke.

== Ukubaluleka kwelanga lika krisimusi ==
Ngelanga lika kresumusi abantu benza okuhlukahlukeneko ngombana kulilanga elihle khulu emuntwini woke, Abazalwana baya esondweni, imindeni iyapheka, abanye bazikhuphela endaweni zokududa kanye nokunye okunengi. Ngifuna kuthiwa bathi umndeni kade ucabene kangangani kodwana ngelanga leli bazwana boke befuthi kuyabambiswana.</text>
      <sha1>pybg3210w4fc57r9ks8fziyg6h575oj</sha1>
    </revision>
  </page>
  <page>
    <title>Ilanga Lamabeletho</title>
    <ns>0</ns>
    <id>163</id>
    <revision>
      <id>779</id>
      <timestamp>2024-09-14T10:34:32Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;== Ilanga Lamabeletho ==  === Isingeniso === Ilanga lamabeletho ngezinye zezinto eziqakathekileko ebantwini abanengi begodu liletha injabulo ebantwini abanengi. Abantu ngokwahlukana kwabo balizwisisa ngeendla ezihlukileko begodu lokho kwenza bonyana baligidinge ngeendlela ezihlukileko. Eenhlokwaneni ezilandelako sizokutjheja bonyana ilanga lamabeletho liyini begodu lisuselwa kuphi.  === Liyini ilanga lamabeletho? === [[:en:Birthday|Ilanga lamabeletho]] lilanga lelo omunt...&quot;</comment>
      <origin>779</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2693" sha1="0au04pi610qg31ndbag7hgbkoqqz2d4" xml:space="preserve">== Ilanga Lamabeletho ==

=== Isingeniso ===
Ilanga lamabeletho ngezinye zezinto eziqakathekileko ebantwini abanengi begodu liletha injabulo ebantwini abanengi. Abantu ngokwahlukana kwabo balizwisisa ngeendla ezihlukileko begodu lokho kwenza bonyana baligidinge ngeendlela ezihlukileko. Eenhlokwaneni ezilandelako sizokutjheja bonyana ilanga lamabeletho liyini begodu lisuselwa kuphi.

=== Liyini ilanga lamabeletho? ===
[[:en:Birthday|Ilanga lamabeletho]] lilanga lelo omuntu avela nanyana abelethwa ngalo (Wikipedia 2024&lt;ref&gt;Wikipedia. 2024. ''Birthday.'' Litholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Birthday&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [11 kuRhoboyi 2024].&lt;/ref&gt;). Ilanga leli lisikhumbuzo emuntwini loyo obelethwe ngalo bonyana wathoma nanyana wafika ephasini la ngelanga lelo (The Yard Designs 2024&lt;ref&gt;The Yard Designs. 2024. ''Why are birthdays important.'' Litholakala ku:&lt;&lt;nowiki&gt;https://theyarddesigns.com/why-are-birthdays-important/&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [11 kuRhoboyi 2024]&lt;/ref&gt;). Ngamanye amagama, ilanga lamabeletho kulilanga elikutjela bonyana ipilo yakho yathoma ngaleli langa enyangeni yeminyaka nanyana yomnyaka ogadungileko.

Nanyana kunjalo-ke, [https://theyarddesigns.com/why-are-birthdays-important/ ilanga lamabeletho aligidingwa ngokufana] ngebanga leenzathu ezifaka ikolo, umbono womuntu kanye nezehlalakuhle zeemali. Abantu abamakholwa njengabafakazi bakaJesu abaligidingi kokufana njengamakholwa amaMozilemu; ngokufanako, abantu abanemali abaligidingi ngokufanako nabantu abanganamali nanyana abazidobhela phasi.

=== Ingabe ilanga lamabeletho lasuselwa kuphi? ===
[https://www.rebounderz.com/the-history-of-birthdays/ Ukuthi ilanga lamabeletho lasuselwa kuphi akuveli kuhle]. Kukhona amarhubhululo amanengi lawa azama ukufunyana iimpendulo mayelana nokusungulwa kwelanga lamabeletho kodwana azange kube netlha (Reboundersz 2024&lt;ref name=&quot;:0&quot;&gt;Rebounderz. 2024. ''The history of birthdays''. Litholaka ku:&lt;&lt;nowiki&gt;https://www.rebounderz.com/the-history-of-birthdays/&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [11 kuRhoboyi 2024].&lt;/ref&gt;). Kodwana kukhona abakholelwa bonyana ilanga lamabeletho lasungulwa yiKosi yamaGibhide, uPharoah ngeminyaka eziin-3000 ngaphambi kokubelethwa kukaJesu (Rebounderesz 2024&lt;ref name=&quot;:0&quot; /&gt;). Ngaleso sikhathi ilanga leli belisetjenziswa njengetshwayo lokuthokoza nololotjha uPharoah. Ngokukhamba kwesikhathi ilanga leli lakhamba liba namatjhugululo lawo afakwa nezinto eligidingwa ngalo.  

=== Isiphetho ===
Ilanga lamabeletho kulilanga eliqakathekileko ebantwini abanengi begodu ligidingwa ngeendlela ezihlukeneko. Ilanga leli limumethe umlayezo ohlukileko ebantwini abahlukeneko. 

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>0au04pi610qg31ndbag7hgbkoqqz2d4</sha1>
    </revision>
    <revision>
      <id>780</id>
      <parentid>779</parentid>
      <timestamp>2024-10-14T13:46:47Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>779</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2693" sha1="0au04pi610qg31ndbag7hgbkoqqz2d4" xml:space="preserve">== Ilanga Lamabeletho ==

=== Isingeniso ===
Ilanga lamabeletho ngezinye zezinto eziqakathekileko ebantwini abanengi begodu liletha injabulo ebantwini abanengi. Abantu ngokwahlukana kwabo balizwisisa ngeendla ezihlukileko begodu lokho kwenza bonyana baligidinge ngeendlela ezihlukileko. Eenhlokwaneni ezilandelako sizokutjheja bonyana ilanga lamabeletho liyini begodu lisuselwa kuphi.

=== Liyini ilanga lamabeletho? ===
[[:en:Birthday|Ilanga lamabeletho]] lilanga lelo omuntu avela nanyana abelethwa ngalo (Wikipedia 2024&lt;ref&gt;Wikipedia. 2024. ''Birthday.'' Litholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Birthday&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [11 kuRhoboyi 2024].&lt;/ref&gt;). Ilanga leli lisikhumbuzo emuntwini loyo obelethwe ngalo bonyana wathoma nanyana wafika ephasini la ngelanga lelo (The Yard Designs 2024&lt;ref&gt;The Yard Designs. 2024. ''Why are birthdays important.'' Litholakala ku:&lt;&lt;nowiki&gt;https://theyarddesigns.com/why-are-birthdays-important/&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [11 kuRhoboyi 2024]&lt;/ref&gt;). Ngamanye amagama, ilanga lamabeletho kulilanga elikutjela bonyana ipilo yakho yathoma ngaleli langa enyangeni yeminyaka nanyana yomnyaka ogadungileko.

Nanyana kunjalo-ke, [https://theyarddesigns.com/why-are-birthdays-important/ ilanga lamabeletho aligidingwa ngokufana] ngebanga leenzathu ezifaka ikolo, umbono womuntu kanye nezehlalakuhle zeemali. Abantu abamakholwa njengabafakazi bakaJesu abaligidingi kokufana njengamakholwa amaMozilemu; ngokufanako, abantu abanemali abaligidingi ngokufanako nabantu abanganamali nanyana abazidobhela phasi.

=== Ingabe ilanga lamabeletho lasuselwa kuphi? ===
[https://www.rebounderz.com/the-history-of-birthdays/ Ukuthi ilanga lamabeletho lasuselwa kuphi akuveli kuhle]. Kukhona amarhubhululo amanengi lawa azama ukufunyana iimpendulo mayelana nokusungulwa kwelanga lamabeletho kodwana azange kube netlha (Reboundersz 2024&lt;ref name=&quot;:0&quot;&gt;Rebounderz. 2024. ''The history of birthdays''. Litholaka ku:&lt;&lt;nowiki&gt;https://www.rebounderz.com/the-history-of-birthdays/&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [11 kuRhoboyi 2024].&lt;/ref&gt;). Kodwana kukhona abakholelwa bonyana ilanga lamabeletho lasungulwa yiKosi yamaGibhide, uPharoah ngeminyaka eziin-3000 ngaphambi kokubelethwa kukaJesu (Rebounderesz 2024&lt;ref name=&quot;:0&quot; /&gt;). Ngaleso sikhathi ilanga leli belisetjenziswa njengetshwayo lokuthokoza nololotjha uPharoah. Ngokukhamba kwesikhathi ilanga leli lakhamba liba namatjhugululo lawo afakwa nezinto eligidingwa ngalo.  

=== Isiphetho ===
Ilanga lamabeletho kulilanga eliqakathekileko ebantwini abanengi begodu ligidingwa ngeendlela ezihlukeneko. Ilanga leli limumethe umlayezo ohlukileko ebantwini abahlukeneko. 

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>0au04pi610qg31ndbag7hgbkoqqz2d4</sha1>
    </revision>
    <revision>
      <id>2200</id>
      <parentid>780</parentid>
      <timestamp>2024-11-29T07:24:50Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <comment>/* Isilululwazi */Reflist</comment>
      <origin>2200</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2690" sha1="97joaiqhfjcua0no7xk64e5zwxe8nuu" xml:space="preserve">== Ilanga Lamabeletho ==

=== Isingeniso ===
Ilanga lamabeletho ngezinye zezinto eziqakathekileko ebantwini abanengi begodu liletha injabulo ebantwini abanengi. Abantu ngokwahlukana kwabo balizwisisa ngeendla ezihlukileko begodu lokho kwenza bonyana baligidinge ngeendlela ezihlukileko. Eenhlokwaneni ezilandelako sizokutjheja bonyana ilanga lamabeletho liyini begodu lisuselwa kuphi.

=== Liyini ilanga lamabeletho? ===
[[:en:Birthday|Ilanga lamabeletho]] lilanga lelo omuntu avela nanyana abelethwa ngalo (Wikipedia 2024&lt;ref&gt;Wikipedia. 2024. ''Birthday.'' Litholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Birthday&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [11 kuRhoboyi 2024].&lt;/ref&gt;). Ilanga leli lisikhumbuzo emuntwini loyo obelethwe ngalo bonyana wathoma nanyana wafika ephasini la ngelanga lelo (The Yard Designs 2024&lt;ref&gt;The Yard Designs. 2024. ''Why are birthdays important.'' Litholakala ku:&lt;&lt;nowiki&gt;https://theyarddesigns.com/why-are-birthdays-important/&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [11 kuRhoboyi 2024]&lt;/ref&gt;). Ngamanye amagama, ilanga lamabeletho kulilanga elikutjela bonyana ipilo yakho yathoma ngaleli langa enyangeni yeminyaka nanyana yomnyaka ogadungileko.

Nanyana kunjalo-ke, [https://theyarddesigns.com/why-are-birthdays-important/ ilanga lamabeletho aligidingwa ngokufana] ngebanga leenzathu ezifaka ikolo, umbono womuntu kanye nezehlalakuhle zeemali. Abantu abamakholwa njengabafakazi bakaJesu abaligidingi kokufana njengamakholwa amaMozilemu; ngokufanako, abantu abanemali abaligidingi ngokufanako nabantu abanganamali nanyana abazidobhela phasi.

=== Ingabe ilanga lamabeletho lasuselwa kuphi? ===
[https://www.rebounderz.com/the-history-of-birthdays/ Ukuthi ilanga lamabeletho lasuselwa kuphi akuveli kuhle]. Kukhona amarhubhululo amanengi lawa azama ukufunyana iimpendulo mayelana nokusungulwa kwelanga lamabeletho kodwana azange kube netlha (Reboundersz 2024&lt;ref name=&quot;:0&quot;&gt;Rebounderz. 2024. ''The history of birthdays''. Litholaka ku:&lt;&lt;nowiki&gt;https://www.rebounderz.com/the-history-of-birthdays/&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [11 kuRhoboyi 2024].&lt;/ref&gt;). Kodwana kukhona abakholelwa bonyana ilanga lamabeletho lasungulwa yiKosi yamaGibhide, uPharoah ngeminyaka eziin-3000 ngaphambi kokubelethwa kukaJesu (Rebounderesz 2024&lt;ref name=&quot;:0&quot; /&gt;). Ngaleso sikhathi ilanga leli belisetjenziswa njengetshwayo lokuthokoza nololotjha uPharoah. Ngokukhamba kwesikhathi ilanga leli lakhamba liba namatjhugululo lawo afakwa nezinto eligidingwa ngalo.  

=== Isiphetho ===
Ilanga lamabeletho kulilanga eliqakathekileko ebantwini abanengi begodu ligidingwa ngeendlela ezihlukeneko. Ilanga leli limumethe umlayezo ohlukileko ebantwini abahlukeneko. 

=== Isilululwazi ===
{{Reflist}}</text>
      <sha1>97joaiqhfjcua0no7xk64e5zwxe8nuu</sha1>
    </revision>
    <revision>
      <id>3000</id>
      <parentid>2200</parentid>
      <timestamp>2025-06-06T20:19:05Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>hgfdsa</comment>
      <origin>3000</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2778" sha1="beeypyblunle6e9hvzj2fmg7h1pm1b4" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.'''

== Ilanga Lamabeletho ==

=== Isingeniso ===
Ilanga lamabeletho ngezinye zezinto eziqakathekileko ebantwini abanengi begodu liletha injabulo ebantwini abanengi. Abantu ngokwahlukana kwabo balizwisisa ngeendla ezihlukileko begodu lokho kwenza bonyana baligidinge ngeendlela ezihlukileko. Eenhlokwaneni ezilandelako sizokutjheja bonyana ilanga lamabeletho liyini begodu lisuselwa kuphi.

=== Liyini ilanga lamabeletho? ===
[[:en:Birthday|Ilanga lamabeletho]] lilanga lelo omuntu avela nanyana abelethwa ngalo (Wikipedia 2024&lt;ref&gt;Wikipedia. 2024. ''Birthday.'' Litholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Birthday&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [11 kuRhoboyi 2024].&lt;/ref&gt;). Ilanga leli lisikhumbuzo emuntwini loyo obelethwe ngalo bonyana wathoma nanyana wafika ephasini la ngelanga lelo (The Yard Designs 2024&lt;ref&gt;The Yard Designs. 2024. ''Why are birthdays important.'' Litholakala ku:&lt;&lt;nowiki&gt;https://theyarddesigns.com/why-are-birthdays-important/&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [11 kuRhoboyi 2024]&lt;/ref&gt;). Ngamanye amagama, ilanga lamabeletho kulilanga elikutjela bonyana ipilo yakho yathoma ngaleli langa enyangeni yeminyaka nanyana yomnyaka ogadungileko.

Nanyana kunjalo-ke, [https://theyarddesigns.com/why-are-birthdays-important/ ilanga lamabeletho aligidingwa ngokufana] ngebanga leenzathu ezifaka ikolo, umbono womuntu kanye nezehlalakuhle zeemali. Abantu abamakholwa njengabafakazi bakaJesu abaligidingi kokufana njengamakholwa amaMozilemu; ngokufanako, abantu abanemali abaligidingi ngokufanako nabantu abanganamali nanyana abazidobhela phasi.

=== Ingabe ilanga lamabeletho lasuselwa kuphi? ===
[https://www.rebounderz.com/the-history-of-birthdays/ Ukuthi ilanga lamabeletho lasuselwa kuphi akuveli kuhle]. Kukhona amarhubhululo amanengi lawa azama ukufunyana iimpendulo mayelana nokusungulwa kwelanga lamabeletho kodwana azange kube netlha (Reboundersz 2024&lt;ref name=&quot;:0&quot;&gt;Rebounderz. 2024. ''The history of birthdays''. Litholaka ku:&lt;&lt;nowiki&gt;https://www.rebounderz.com/the-history-of-birthdays/&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [11 kuRhoboyi 2024].&lt;/ref&gt;). Kodwana kukhona abakholelwa bonyana ilanga lamabeletho lasungulwa yiKosi yamaGibhide, uPharoah ngeminyaka eziin-3000 ngaphambi kokubelethwa kukaJesu (Rebounderesz 2024&lt;ref name=&quot;:0&quot; /&gt;). Ngaleso sikhathi ilanga leli belisetjenziswa njengetshwayo lokuthokoza nololotjha uPharoah. Ngokukhamba kwesikhathi ilanga leli lakhamba liba namatjhugululo lawo afakwa nezinto eligidingwa ngalo.  

=== Isiphetho ===
Ilanga lamabeletho kulilanga eliqakathekileko ebantwini abanengi begodu ligidingwa ngeendlela ezihlukeneko. Ilanga leli limumethe umlayezo ohlukileko ebantwini abahlukeneko. 

=== Isilululwazi ===
{{Reflist}}</text>
      <sha1>beeypyblunle6e9hvzj2fmg7h1pm1b4</sha1>
    </revision>
    <revision>
      <id>3048</id>
      <parentid>3000</parentid>
      <timestamp>2025-06-07T03:05:22Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Simakahle Moselekatse|Simakahle Moselekatse]]</comment>
      <origin>2200</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2690" sha1="97joaiqhfjcua0no7xk64e5zwxe8nuu" xml:space="preserve">== Ilanga Lamabeletho ==

=== Isingeniso ===
Ilanga lamabeletho ngezinye zezinto eziqakathekileko ebantwini abanengi begodu liletha injabulo ebantwini abanengi. Abantu ngokwahlukana kwabo balizwisisa ngeendla ezihlukileko begodu lokho kwenza bonyana baligidinge ngeendlela ezihlukileko. Eenhlokwaneni ezilandelako sizokutjheja bonyana ilanga lamabeletho liyini begodu lisuselwa kuphi.

=== Liyini ilanga lamabeletho? ===
[[:en:Birthday|Ilanga lamabeletho]] lilanga lelo omuntu avela nanyana abelethwa ngalo (Wikipedia 2024&lt;ref&gt;Wikipedia. 2024. ''Birthday.'' Litholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Birthday&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [11 kuRhoboyi 2024].&lt;/ref&gt;). Ilanga leli lisikhumbuzo emuntwini loyo obelethwe ngalo bonyana wathoma nanyana wafika ephasini la ngelanga lelo (The Yard Designs 2024&lt;ref&gt;The Yard Designs. 2024. ''Why are birthdays important.'' Litholakala ku:&lt;&lt;nowiki&gt;https://theyarddesigns.com/why-are-birthdays-important/&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [11 kuRhoboyi 2024]&lt;/ref&gt;). Ngamanye amagama, ilanga lamabeletho kulilanga elikutjela bonyana ipilo yakho yathoma ngaleli langa enyangeni yeminyaka nanyana yomnyaka ogadungileko.

Nanyana kunjalo-ke, [https://theyarddesigns.com/why-are-birthdays-important/ ilanga lamabeletho aligidingwa ngokufana] ngebanga leenzathu ezifaka ikolo, umbono womuntu kanye nezehlalakuhle zeemali. Abantu abamakholwa njengabafakazi bakaJesu abaligidingi kokufana njengamakholwa amaMozilemu; ngokufanako, abantu abanemali abaligidingi ngokufanako nabantu abanganamali nanyana abazidobhela phasi.

=== Ingabe ilanga lamabeletho lasuselwa kuphi? ===
[https://www.rebounderz.com/the-history-of-birthdays/ Ukuthi ilanga lamabeletho lasuselwa kuphi akuveli kuhle]. Kukhona amarhubhululo amanengi lawa azama ukufunyana iimpendulo mayelana nokusungulwa kwelanga lamabeletho kodwana azange kube netlha (Reboundersz 2024&lt;ref name=&quot;:0&quot;&gt;Rebounderz. 2024. ''The history of birthdays''. Litholaka ku:&lt;&lt;nowiki&gt;https://www.rebounderz.com/the-history-of-birthdays/&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [11 kuRhoboyi 2024].&lt;/ref&gt;). Kodwana kukhona abakholelwa bonyana ilanga lamabeletho lasungulwa yiKosi yamaGibhide, uPharoah ngeminyaka eziin-3000 ngaphambi kokubelethwa kukaJesu (Rebounderesz 2024&lt;ref name=&quot;:0&quot; /&gt;). Ngaleso sikhathi ilanga leli belisetjenziswa njengetshwayo lokuthokoza nololotjha uPharoah. Ngokukhamba kwesikhathi ilanga leli lakhamba liba namatjhugululo lawo afakwa nezinto eligidingwa ngalo.  

=== Isiphetho ===
Ilanga lamabeletho kulilanga eliqakathekileko ebantwini abanengi begodu ligidingwa ngeendlela ezihlukeneko. Ilanga leli limumethe umlayezo ohlukileko ebantwini abahlukeneko. 

=== Isilululwazi ===
{{Reflist}}</text>
      <sha1>97joaiqhfjcua0no7xk64e5zwxe8nuu</sha1>
    </revision>
  </page>
  <page>
    <title>Ilanga labasebenzi</title>
    <ns>0</ns>
    <id>164</id>
    <revision>
      <id>781</id>
      <timestamp>2024-07-10T10:44:56Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Ilanga labasebenzi''' kuyilanga eliba yiholideyi labantu abahlala enarheni yeSewula afrika kusukela ngonyaka wekululeko. Ilanga labasebenzi ligidingwa ngenyanga ka Mrhayili ngelanga loku-1 minyaka yoke.  &quot;</comment>
      <origin>781</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="207" sha1="mqwa61o5vq7f4h6t7s2riq61s2032wt" xml:space="preserve">'''Ilanga labasebenzi''' kuyilanga eliba yiholideyi labantu abahlala enarheni yeSewula afrika kusukela ngonyaka wekululeko. Ilanga labasebenzi ligidingwa ngenyanga ka Mrhayili ngelanga loku-1 minyaka yoke.

</text>
      <sha1>mqwa61o5vq7f4h6t7s2riq61s2032wt</sha1>
    </revision>
    <revision>
      <id>782</id>
      <parentid>781</parentid>
      <timestamp>2024-07-10T10:45:24Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>782</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="211" sha1="gaw0tiptv1jrgfarmks4dtdk2dbnar4" xml:space="preserve">'''Ilanga labasebenzi''' kuyilanga eliba y[[iholideyi]] labantu abahlala enarheni yeSewula afrika kusukela ngonyaka wekululeko. Ilanga labasebenzi ligidingwa ngenyanga ka Mrhayili ngelanga loku-1 minyaka yoke.

</text>
      <sha1>gaw0tiptv1jrgfarmks4dtdk2dbnar4</sha1>
    </revision>
    <revision>
      <id>783</id>
      <parentid>782</parentid>
      <timestamp>2024-07-10T10:46:01Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>783</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="211" sha1="hir9r1w53ywr59hmybefho72q5xrypj" xml:space="preserve">'''Ilanga labasebenzi''' kuyilanga eliba yi[[holideyi]] labantu abahlala enarheni yeSewula afrika kusukela ngonyaka wekululeko. Ilanga labasebenzi ligidingwa ngenyanga ka Mrhayili ngelanga loku-1 minyaka yoke.

</text>
      <sha1>hir9r1w53ywr59hmybefho72q5xrypj</sha1>
    </revision>
    <revision>
      <id>784</id>
      <parentid>783</parentid>
      <timestamp>2024-07-13T19:57:34Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>784</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="323" sha1="klgv8ag2ushi90pt3wdup0jylhlopy9" xml:space="preserve">'''Ilanga labasebenzi''' kuyilanga eliba yi[[holideyi]] labantu abahlala enarheni yeSewula afrika kusukela ngonyaka wekululeko. Ilanga labasebenzi ligidingwa ngenyanga ka Mrhayili ngelanga loku-1 minyaka yoke. Ngaleli ilanga kusuke kugifingwa indima edlalwa basebenzi enarheni ukuthithukisa isitjhaba ngokwanfisa umnotho.

</text>
      <sha1>klgv8ag2ushi90pt3wdup0jylhlopy9</sha1>
    </revision>
    <revision>
      <id>785</id>
      <parentid>784</parentid>
      <timestamp>2024-10-14T13:46:48Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>4 revisions imported</comment>
      <origin>784</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="323" sha1="klgv8ag2ushi90pt3wdup0jylhlopy9" xml:space="preserve">'''Ilanga labasebenzi''' kuyilanga eliba yi[[holideyi]] labantu abahlala enarheni yeSewula afrika kusukela ngonyaka wekululeko. Ilanga labasebenzi ligidingwa ngenyanga ka Mrhayili ngelanga loku-1 minyaka yoke. Ngaleli ilanga kusuke kugifingwa indima edlalwa basebenzi enarheni ukuthithukisa isitjhaba ngokwanfisa umnotho.

</text>
      <sha1>klgv8ag2ushi90pt3wdup0jylhlopy9</sha1>
    </revision>
    <revision>
      <id>2447</id>
      <parentid>785</parentid>
      <timestamp>2025-02-20T04:55:48Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2447</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="329" sha1="f7ncjkr00ipqlz1llb4xuq4jsnj0990" xml:space="preserve">'''Ilanga labasebenzi''' kuyilanga eliba yi[[holideyi]] labantu abahlala enarheni yeSewula afrika kusukela ngonyaka wekululeko. Ilanga labasebenzi ligidingwa ngenyanga ka Mrhayili ngelanga loku-1 minyaka yoke. Ngaleli ilanga kusuke kugidingwa indima edlalwa basebenzi enarheni ukuthithukisa isitjhaba ngokwandisa umnotho wenarha.</text>
      <sha1>f7ncjkr00ipqlz1llb4xuq4jsnj0990</sha1>
    </revision>
  </page>
  <page>
    <title>Ilobolo</title>
    <ns>0</ns>
    <id>165</id>
    <revision>
      <id>786</id>
      <timestamp>2024-07-08T09:37:17Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Ilobolo''' kulapho indoda ithumela khona abantu bayo bonyana bakhabe baye khabo lentobi yakhe bonyana bayokukhulumisana ngemali ebayifunako bonyana indoda le izokukhona ukuthatha intombi yayo imenze umfazi wayo&quot;</comment>
      <origin>786</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="213" sha1="oimeonvuxzrpwlksozegri3k0r0m4dz" xml:space="preserve">'''Ilobolo''' kulapho indoda ithumela khona abantu bayo bonyana bakhabe baye khabo lentobi yakhe bonyana bayokukhulumisana ngemali ebayifunako bonyana indoda le izokukhona ukuthatha intombi yayo imenze umfazi wayo</text>
      <sha1>oimeonvuxzrpwlksozegri3k0r0m4dz</sha1>
    </revision>
    <revision>
      <id>787</id>
      <parentid>786</parentid>
      <timestamp>2024-07-08T09:37:30Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>787</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="214" sha1="r0ji7fjd5o4795f3vtcltvclu29uira" xml:space="preserve">'''Ilobolo''' kulapho indoda ithumela khona abantu bayo bonyana bakhabe baye khabo lentobi yakhe bonyana bayokukhulumisana ngemali ebayifunako bonyana indoda le izokukhona ukuthatha intombi yayo imenze umfazi wayo.</text>
      <sha1>r0ji7fjd5o4795f3vtcltvclu29uira</sha1>
    </revision>
    <revision>
      <id>788</id>
      <parentid>787</parentid>
      <timestamp>2024-07-10T10:11:11Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>788</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="421" sha1="qp465xy4u0twc57lq9rr98bfgk16i9x" xml:space="preserve">'''Ilobolo''' kulapho indoda ithumela khona abantu bayo bonyana bakhambe baye khabo lentombi yakhe bonyana bayokukhulumisana ngemali ebayifunako bonyana indoda le izokukhona ukuthatha intombi yayo imenze umfazi wayo. Abakhongi bayakhamba bayokuzwa bonyana kufuneka malini, bese isokana liyayikhipha imali leyo neenkomo phezulu.

== Inkomo zelobolo ==
NGesindebele iinkomo zelobolo zisithandathu begodu zinamagama wakhona.</text>
      <sha1>qp465xy4u0twc57lq9rr98bfgk16i9x</sha1>
    </revision>
    <revision>
      <id>789</id>
      <parentid>788</parentid>
      <timestamp>2024-07-10T10:12:03Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>789</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="421" sha1="4a9r5pbtwux316d6fvxg3rmwnusy46k" xml:space="preserve">'''Ilobolo''' kulapho indoda ithumela khona abantu bayo bonyana bakhambe baye khabo lentombi yakhe bonyana bayokukhulumisana ngemali ebayifunako bonyana indoda le izokukhona ukuthatha intombi yayo imenze umfazi wayo. Abakhongi bayakhamba bayokuzwa bonyana kufuneka malini, bese isokana liyayikhipha imali leyo neenkomo phezulu.

== Inkomo zelobolo ==
NgesiNdebele iinkomo zelobolo zisithandathu begodu zinamagama wakhona.</text>
      <sha1>4a9r5pbtwux316d6fvxg3rmwnusy46k</sha1>
    </revision>
    <revision>
      <id>790</id>
      <parentid>789</parentid>
      <timestamp>2024-10-14T13:46:48Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>4 revisions imported</comment>
      <origin>789</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="421" sha1="4a9r5pbtwux316d6fvxg3rmwnusy46k" xml:space="preserve">'''Ilobolo''' kulapho indoda ithumela khona abantu bayo bonyana bakhambe baye khabo lentombi yakhe bonyana bayokukhulumisana ngemali ebayifunako bonyana indoda le izokukhona ukuthatha intombi yayo imenze umfazi wayo. Abakhongi bayakhamba bayokuzwa bonyana kufuneka malini, bese isokana liyayikhipha imali leyo neenkomo phezulu.

== Inkomo zelobolo ==
NgesiNdebele iinkomo zelobolo zisithandathu begodu zinamagama wakhona.</text>
      <sha1>4a9r5pbtwux316d6fvxg3rmwnusy46k</sha1>
    </revision>
    <revision>
      <id>6746</id>
      <parentid>790</parentid>
      <timestamp>2026-07-23T10:18:07Z</timestamp>
      <contributor>
        <username>Gusunufuds</username>
        <id>1643</id>
      </contributor>
      <minor />
      <origin>6746</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="108" sha1="moc2d5jv2x10xp9991271f8oukt28zp" xml:space="preserve">'''Ilobolo''' 

== Inkomo zelobolo ==
NgesiNdebele iinkomo zelobolo zisithandathu begodu zinamagama wakhona.</text>
      <sha1>moc2d5jv2x10xp9991271f8oukt28zp</sha1>
    </revision>
    <revision>
      <id>6747</id>
      <parentid>6746</parentid>
      <timestamp>2026-07-23T10:18:33Z</timestamp>
      <contributor>
        <username>Gusunufuds</username>
        <id>1643</id>
      </contributor>
      <minor />
      <comment>Undid revision [[Special:Diff/6746|6746]] by [[Special:Contributions/Gusunufuds|Gusunufuds]] ([[User talk:Gusunufuds|talk]])</comment>
      <origin>6747</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="421" sha1="4a9r5pbtwux316d6fvxg3rmwnusy46k" xml:space="preserve">'''Ilobolo''' kulapho indoda ithumela khona abantu bayo bonyana bakhambe baye khabo lentombi yakhe bonyana bayokukhulumisana ngemali ebayifunako bonyana indoda le izokukhona ukuthatha intombi yayo imenze umfazi wayo. Abakhongi bayakhamba bayokuzwa bonyana kufuneka malini, bese isokana liyayikhipha imali leyo neenkomo phezulu.

== Inkomo zelobolo ==
NgesiNdebele iinkomo zelobolo zisithandathu begodu zinamagama wakhona.</text>
      <sha1>4a9r5pbtwux316d6fvxg3rmwnusy46k</sha1>
    </revision>
  </page>
  <page>
    <title>Ilwandle</title>
    <ns>0</ns>
    <id>166</id>
    <revision>
      <id>791</id>
      <timestamp>2024-07-10T10:03:51Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Ilwandle''' yindawo yemvelo mamanzi amanengi anetswayi azungeze iphasi loke. Amanzi la ahlukanisa amakhontinenti wephasi begodu ephasini zombelele kunamalwandle amathathu. Ilwandle ngelinye leendawo zokuzithabisa evakatjhelwa babantu. Abantu vane baye ukuyokubona ilwande begodu bafike bakhe namanzi wakhona ukuwasebenzisela izinto ezithileko eziphathelene nomoya.  &quot;</comment>
      <origin>791</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="369" sha1="pzz27a5wtsi09wohtusce40yhyy186l" xml:space="preserve">'''Ilwandle''' yindawo yemvelo mamanzi amanengi anetswayi azungeze iphasi loke. Amanzi la ahlukanisa amakhontinenti wephasi begodu ephasini zombelele kunamalwandle amathathu. Ilwandle ngelinye leendawo zokuzithabisa evakatjhelwa babantu. Abantu vane baye ukuyokubona ilwande begodu bafike bakhe namanzi wakhona ukuwasebenzisela izinto ezithileko eziphathelene nomoya.

</text>
      <sha1>pzz27a5wtsi09wohtusce40yhyy186l</sha1>
    </revision>
    <revision>
      <id>792</id>
      <parentid>791</parentid>
      <timestamp>2024-07-10T10:51:10Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>792</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="452" sha1="7f4rzzzcn4i1xacxbxwte8b7b1ji1af" xml:space="preserve">[[Isimumathi:Seal Rocks, Ocean Beach, San Francisco.jpg|thumb|isithombe seLwande]]
'''Ilwandle''' yindawo yemvelo mamanzi amanengi anetswayi azungeze iphasi loke. Amanzi la ahlukanisa amakhontinenti wephasi begodu ephasini zombelele kunamalwandle amathathu. Ilwandle ngelinye leendawo zokuzithabisa evakatjhelwa babantu. Abantu vane baye ukuyokubona ilwande begodu bafike bakhe namanzi wakhona ukuwasebenzisela izinto ezithileko eziphathelene nomoya.

</text>
      <sha1>7f4rzzzcn4i1xacxbxwte8b7b1ji1af</sha1>
    </revision>
    <revision>
      <id>793</id>
      <parentid>792</parentid>
      <timestamp>2024-07-10T10:51:43Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>793</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="453" sha1="paac4xe59dwd6mc3zspw8vq6z45sv6l" xml:space="preserve">[[Isimumathi:Seal Rocks, Ocean Beach, San Francisco.jpg|thumb|isithombe seLwande]]
'''Ilwandle''' yindawo yemvelo mamanzi amanengi anetswayi azungeze iphasi loke. Amanzi la ahlukanisa amakhontinenti wephasi begodu ephasini zombelele kunamalwandle amathathu. Ilwandle ngelinye leendawo zokuzithabisa evakatjhelwa babantu. Abantu vane baye ukuyokubona ilwande begodu bafike bakhe namanzi wakhona ukuwasebenzisela izinto ezithileko eziphathelene nomoya. 

</text>
      <sha1>paac4xe59dwd6mc3zspw8vq6z45sv6l</sha1>
    </revision>
    <revision>
      <id>794</id>
      <parentid>793</parentid>
      <timestamp>2024-10-14T13:46:48Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>793</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="453" sha1="paac4xe59dwd6mc3zspw8vq6z45sv6l" xml:space="preserve">[[Isimumathi:Seal Rocks, Ocean Beach, San Francisco.jpg|thumb|isithombe seLwande]]
'''Ilwandle''' yindawo yemvelo mamanzi amanengi anetswayi azungeze iphasi loke. Amanzi la ahlukanisa amakhontinenti wephasi begodu ephasini zombelele kunamalwandle amathathu. Ilwandle ngelinye leendawo zokuzithabisa evakatjhelwa babantu. Abantu vane baye ukuyokubona ilwande begodu bafike bakhe namanzi wakhona ukuwasebenzisela izinto ezithileko eziphathelene nomoya. 

</text>
      <sha1>paac4xe59dwd6mc3zspw8vq6z45sv6l</sha1>
    </revision>
  </page>
  <page>
    <title>Imibala yeflarha yeSewula Afrika nehlathululo yawo.</title>
    <ns>0</ns>
    <id>167</id>
    <revision>
      <id>795</id>
      <timestamp>2024-07-21T10:07:29Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;== Imibala yeflarha yeSewula Afrika nehlathululo yawo. == Imibala ngezinye zezinto ethelwe nanyana ephethe umlayezo loyo abantu ekufanele bawurhumutjhe ukuze bawuzwisise. Umbala ngamunye ungaba nemilayezo eminengi tle, kodwana umnqopho wombala nomkhiqizo nanyana ithulusi lelo ofakwe kilo, ngilo elisitjela ngomlayezo ewumumethweko ngaleso sikhathi. Nanyana kunjalo, ekulumeni yethu le sizokutjheja khulu ihlathululo yemibala yeflarha yeSewula Afrika.  Isithombe esingehla le...&quot;</comment>
      <origin>795</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3163" sha1="re4k77d2aru18e8vrafan5n6qeu7ppa" xml:space="preserve">== Imibala yeflarha yeSewula Afrika nehlathululo yawo. ==
Imibala ngezinye zezinto ethelwe nanyana ephethe umlayezo loyo abantu ekufanele bawurhumutjhe ukuze bawuzwisise. Umbala ngamunye ungaba nemilayezo eminengi tle, kodwana umnqopho wombala nomkhiqizo nanyana ithulusi lelo ofakwe kilo, ngilo elisitjela ngomlayezo ewumumethweko ngaleso sikhathi. Nanyana kunjalo, ekulumeni yethu le sizokutjheja khulu ihlathululo yemibala yeflarha yeSewula Afrika.

Isithombe esingehla lesi seflarha yeSewula Afrika, sithola imibala imibala esithantathu (onzima, wegolide nanyana osarulana, ohlaza kotjani, ohlaza kwesibhakabhaka, omhlophe nobovu). 

'''Onzima'''- Ngokuya bakaw-South Afrika Net (2024) umbala onzima  ojamele abantu bendabuko beSewula Afrika. Ngamanye amagama, ujamele abantu abanzima nabathwa njengoba sazi bonyana ngibo bokuthoma la eSewula Afrka ngaphambi kokuthi kufike amakhuwa.

'''Wegolide nanyana osarulana'''- Umbala wegolide nanyana osarulana ujamele izenjiwa kanye neminye iminotho yendabuko nanyana yeboduluko leSewula Afrika (South Afrka Net 2024).

'''Ohlaza kotjani''' – Bakwa-South Afrika Net baveze bonyana umbala ohlaza kotjani ujamele ukunotha kwenarha yeSewula Afrika. Siyazi bonyana inarha yeSewula Afrika inehlabathi enothileko leyo esetjenziselwa ukudla, iminotho yezenyiwa, amanzi kanye nezinye izinto.

'''Ohlaza kwesibhakabhaka''' – Ngokuya kwe-Mappr (2024), umbala ohlaza kwesibhakabhaka ujamele isibhakabhaka, itjhaphululo kanye namathuba lawo angapheliko weSewula Afrika. Bangezelele, bakaw-Mappr (2024), bathi, ulitshwayo lekuthazo yengemuso elingcono leSewula Afrika.

'''Obovu''' – Umbala obovu ujamele yoke imisebenzi eyenziwa, nokuzibophelela kanye neengazi ezathulukako ekulweni negandelelo kanye nokulwela itjhaphuluko yeSewula Afrka ngaphambilini (Mappr 2024). Ulitshwayo lokukhumbula ukuzithemba nonokubekezela kwabantu beSewula Afrika (Mappr 2024).

'''Omhlophe''' – Ngokuya kwe-Mappr (2024) umbala omhlopho ujamele ukuthulwa nokubambisana kwabantu beSewula Afrika. Ulitshayo lokuzibophelela kweSewula Afrika engomuseni elinokuthula nokulibalelana kwabantu beSewula Afika (Mappr 2024).

Nanyana kunjalo, ihlathululo yemibala le ayikapheleli. Lokha nasitjheja imibala le yoke sifunyana bona ijamele nabo boke abantu abaphila eSewula Afrika, ukusuka kumakhuwa, abantu abanzima, bombala, abantu beenkolo ezahlukeneko (Britannica 2024).

=== Isiphetho ===
Ikulumo yethu yangehla le iyasitjengisa bona imibala yeSewula Afrika le ijamele izinto ezinengi lezo ezifaka umlando, ibhoduluko, abantu, abantu, ukunotha, ikusasa elihle nemfiso kanye nenarha yeSewula Afrika ngokupheleleko.

=== Umthombolwazi. ===
Britannica. (2024). ‘Flag of South Africa’. Available at :https://www.britannica.com/topic/flag-of-South-Africa. 
Mappr. (2024). ‘South Africa Flag Unveiled: Colors, Meaning, Coat of Arms, Flag Map, and Similar Flags’. Available at:https://www.mappr.co/flag-maps/south-africa/.
South Afrika. (2024). ‘An enduring symbol of unity and overcoming adversity as a nation’. Available at:&lt;https://www.southafrica.net/gl/en/travel/article/an-enduring-symbol-of-unity-and-overcoming-adversity-as-a-nation&gt;.

</text>
      <sha1>re4k77d2aru18e8vrafan5n6qeu7ppa</sha1>
    </revision>
    <revision>
      <id>796</id>
      <parentid>795</parentid>
      <timestamp>2024-09-18T15:49:09Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>796</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3326" sha1="0qrld7xz0nodk3eh1ihqq8utwgzisop" xml:space="preserve">== Imibala yeflarha yeSewula Afrika nehlathululo yawo. ==
Imibala ngezinye zezinto ethelwe nanyana ephethe umlayezo loyo abantu ekufanele bawurhumutjhe ukuze bawuzwisise. Umbala ngamunye ungaba nemilayezo eminengi tle, kodwana umnqopho wombala nomkhiqizo nanyana ithulusi lelo ofakwe kilo, ngilo elisitjela ngomlayezo ewumumethweko ngaleso sikhathi. Nanyana kunjalo, ekulumeni yethu le sizokutjheja khulu ihlathululo yemibala yeflarha yeSewula Afrika.

Isithombe esingehla lesi seflarha yeSewula Afrika, sithola imibala imibala esithantathu (onzima, wegolide nanyana osarulana, ohlaza kotjani, ohlaza kwesibhakabhaka, omhlophe nobovu). 

'''Onzima'''- Ngokuya bakaw-South Africa Net (2024&lt;ref name=&quot;:0&quot;&gt;South Africa. (2024). ‘An enduring symbol of unity and overcoming adversity as a nation’. Available at:&lt;https://www.southafrica.net/gl/en/travel/article/an-enduring-symbol-of-unity-and-overcoming-adversity-as-a-nation&lt;/ref&gt;) umbala onzima  ojamele abantu bendabuko beSewula Afrika. Ngamanye amagama, ujamele abantu abanzima nabathwa njengoba sazi bonyana ngibo bokuthoma la eSewula Afrka ngaphambi kokuthi kufike amakhuwa.

'''Wegolide nanyana osarulana'''- Umbala wegolide nanyana osarulana ujamele izenjiwa kanye neminye iminotho yendabuko nanyana yeboduluko leSewula Afrika (South Africa Net 2024&lt;ref name=&quot;:0&quot; /&gt;).

'''Ohlaza kotjani''' – Bakwa-South Afrika Net baveze bonyana umbala ohlaza kotjani ujamele ukunotha kwenarha yeSewula Afrika. Siyazi bonyana inarha yeSewula Afrika inehlabathi enothileko leyo esetjenziselwa ukudla, iminotho yezenyiwa, amanzi kanye nezinye izinto.

'''Ohlaza kwesibhakabhaka''' – Ngokuya kwe-Mappr (2024&lt;ref name=&quot;:1&quot;&gt;Mappr. (2024). ‘South Africa Flag Unveiled: Colors, Meaning, Coat of Arms, Flag Map, and Similar Flags’. Available at:https://www.mappr.co/flag-maps/south-africa/&lt;/ref&gt;), umbala ohlaza kwesibhakabhaka ujamele isibhakabhaka, itjhaphululo kanye namathuba lawo angapheliko weSewula Afrika. Bangezelele, bakaw-Mappr (2024&lt;ref name=&quot;:1&quot; /&gt;), bathi, ulitshwayo lekuthazo yengemuso elingcono leSewula Afrika.

'''Obovu''' – Umbala obovu ujamele yoke imisebenzi eyenziwa, nokuzibophelela kanye neengazi ezathulukako ekulweni negandelelo kanye nokulwela itjhaphuluko yeSewula Afrka ngaphambilini (Mappr 2024&lt;ref name=&quot;:1&quot; /&gt;). Ulitshwayo lokukhumbula ukuzithemba nonokubekezela kwabantu beSewula Afrika (Mappr 2024&lt;ref name=&quot;:1&quot; /&gt;).

'''Omhlophe''' – Ngokuya kwe-Mappr (2024&lt;ref name=&quot;:1&quot; /&gt;) umbala omhlopho ujamele ukuthulwa nokubambisana kwabantu beSewula Afrika. Ulitshayo lokuzibophelela kweSewula Afrika engomuseni elinokuthula nokulibalelana kwabantu beSewula Afika (Mappr 2024&lt;ref name=&quot;:1&quot; /&gt;).

Nanyana kunjalo, ihlathululo yemibala le ayikapheleli. Lokha nasitjheja imibala le yoke sifunyana bona ijamele nabo boke abantu abaphila eSewula Afrika, ukusuka kumakhuwa, abantu abanzima, bombala, abantu beenkolo ezahlukeneko (Britannica 2024&lt;ref&gt;Britannica. (2024). ‘Flag of South Africa’. Available at :https://www.britannica.com/topic/flag-of-South-Africa&lt;/ref&gt;).

=== Isiphetho ===
Ikulumo yethu yangehla le iyasitjengisa bona imibala yeSewula Afrika le ijamele izinto ezinengi lezo ezifaka umlando, ibhoduluko, abantu, abantu, ukunotha, ikusasa elihle nemfiso kanye nenarha yeSewula Afrika ngokupheleleko.

=== Umthombolwazi. ===
&lt;references /&gt;

</text>
      <sha1>0qrld7xz0nodk3eh1ihqq8utwgzisop</sha1>
    </revision>
    <revision>
      <id>797</id>
      <parentid>796</parentid>
      <timestamp>2024-10-14T13:46:48Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>796</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3326" sha1="0qrld7xz0nodk3eh1ihqq8utwgzisop" xml:space="preserve">== Imibala yeflarha yeSewula Afrika nehlathululo yawo. ==
Imibala ngezinye zezinto ethelwe nanyana ephethe umlayezo loyo abantu ekufanele bawurhumutjhe ukuze bawuzwisise. Umbala ngamunye ungaba nemilayezo eminengi tle, kodwana umnqopho wombala nomkhiqizo nanyana ithulusi lelo ofakwe kilo, ngilo elisitjela ngomlayezo ewumumethweko ngaleso sikhathi. Nanyana kunjalo, ekulumeni yethu le sizokutjheja khulu ihlathululo yemibala yeflarha yeSewula Afrika.

Isithombe esingehla lesi seflarha yeSewula Afrika, sithola imibala imibala esithantathu (onzima, wegolide nanyana osarulana, ohlaza kotjani, ohlaza kwesibhakabhaka, omhlophe nobovu). 

'''Onzima'''- Ngokuya bakaw-South Africa Net (2024&lt;ref name=&quot;:0&quot;&gt;South Africa. (2024). ‘An enduring symbol of unity and overcoming adversity as a nation’. Available at:&lt;https://www.southafrica.net/gl/en/travel/article/an-enduring-symbol-of-unity-and-overcoming-adversity-as-a-nation&lt;/ref&gt;) umbala onzima  ojamele abantu bendabuko beSewula Afrika. Ngamanye amagama, ujamele abantu abanzima nabathwa njengoba sazi bonyana ngibo bokuthoma la eSewula Afrka ngaphambi kokuthi kufike amakhuwa.

'''Wegolide nanyana osarulana'''- Umbala wegolide nanyana osarulana ujamele izenjiwa kanye neminye iminotho yendabuko nanyana yeboduluko leSewula Afrika (South Africa Net 2024&lt;ref name=&quot;:0&quot; /&gt;).

'''Ohlaza kotjani''' – Bakwa-South Afrika Net baveze bonyana umbala ohlaza kotjani ujamele ukunotha kwenarha yeSewula Afrika. Siyazi bonyana inarha yeSewula Afrika inehlabathi enothileko leyo esetjenziselwa ukudla, iminotho yezenyiwa, amanzi kanye nezinye izinto.

'''Ohlaza kwesibhakabhaka''' – Ngokuya kwe-Mappr (2024&lt;ref name=&quot;:1&quot;&gt;Mappr. (2024). ‘South Africa Flag Unveiled: Colors, Meaning, Coat of Arms, Flag Map, and Similar Flags’. Available at:https://www.mappr.co/flag-maps/south-africa/&lt;/ref&gt;), umbala ohlaza kwesibhakabhaka ujamele isibhakabhaka, itjhaphululo kanye namathuba lawo angapheliko weSewula Afrika. Bangezelele, bakaw-Mappr (2024&lt;ref name=&quot;:1&quot; /&gt;), bathi, ulitshwayo lekuthazo yengemuso elingcono leSewula Afrika.

'''Obovu''' – Umbala obovu ujamele yoke imisebenzi eyenziwa, nokuzibophelela kanye neengazi ezathulukako ekulweni negandelelo kanye nokulwela itjhaphuluko yeSewula Afrka ngaphambilini (Mappr 2024&lt;ref name=&quot;:1&quot; /&gt;). Ulitshwayo lokukhumbula ukuzithemba nonokubekezela kwabantu beSewula Afrika (Mappr 2024&lt;ref name=&quot;:1&quot; /&gt;).

'''Omhlophe''' – Ngokuya kwe-Mappr (2024&lt;ref name=&quot;:1&quot; /&gt;) umbala omhlopho ujamele ukuthulwa nokubambisana kwabantu beSewula Afrika. Ulitshayo lokuzibophelela kweSewula Afrika engomuseni elinokuthula nokulibalelana kwabantu beSewula Afika (Mappr 2024&lt;ref name=&quot;:1&quot; /&gt;).

Nanyana kunjalo, ihlathululo yemibala le ayikapheleli. Lokha nasitjheja imibala le yoke sifunyana bona ijamele nabo boke abantu abaphila eSewula Afrika, ukusuka kumakhuwa, abantu abanzima, bombala, abantu beenkolo ezahlukeneko (Britannica 2024&lt;ref&gt;Britannica. (2024). ‘Flag of South Africa’. Available at :https://www.britannica.com/topic/flag-of-South-Africa&lt;/ref&gt;).

=== Isiphetho ===
Ikulumo yethu yangehla le iyasitjengisa bona imibala yeSewula Afrika le ijamele izinto ezinengi lezo ezifaka umlando, ibhoduluko, abantu, abantu, ukunotha, ikusasa elihle nemfiso kanye nenarha yeSewula Afrika ngokupheleleko.

=== Umthombolwazi. ===
&lt;references /&gt;

</text>
      <sha1>0qrld7xz0nodk3eh1ihqq8utwgzisop</sha1>
    </revision>
  </page>
  <page>
    <title>Imidlalo</title>
    <ns>0</ns>
    <id>168</id>
    <revision>
      <id>798</id>
      <timestamp>2024-08-06T18:29:01Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Umdlalo''' ngilokho okwenziwa mumuntu nanyana abantu ngehloso yokuzithabisa, okufaka hlangana umthetho , ukuphikisana nekghono elithileko. Umdlalo udlala ziinqheema ezimbili  nanyan ezinengi.  == Imihlobo yemidlalo ==  === Imidlalo yeenqheema === Le midlalo efaka hlangana inqheema ezimbli nnanyana ezingaphezu kwezimbili. Abadlali bomdlalo wesiqheema basebenzisana ngokumnqopho wokuzuza lokho abakuhlosileko, kungaba ligondelo nanyana okhunye ekuzobenza bona bathumbe umd...&quot;</comment>
      <origin>798</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1251" sha1="7jmye91omp3ffhmy5qyb3hb8qkzvhoz" xml:space="preserve">'''Umdlalo''' ngilokho okwenziwa mumuntu nanyana abantu ngehloso yokuzithabisa, okufaka hlangana umthetho , ukuphikisana nekghono elithileko. Umdlalo udlala ziinqheema ezimbili  nanyan ezinengi.

== Imihlobo yemidlalo ==

=== Imidlalo yeenqheema ===
Le midlalo efaka hlangana inqheema ezimbli nnanyana ezingaphezu kwezimbili. Abadlali bomdlalo wesiqheema basebenzisana ngokumnqopho wokuzuza lokho abakuhlosileko, kungaba ligondelo nanyana okhunye ekuzobenza bona bathumbe umdlalo. Emdlalweni abadlali bayazihlela ngokwendelal abazokujama ngayo.

=== Imidlalo yangamunye ===
Midlalo lapho umuntu adlala khona ngokuzijamela abambelelel ekghonweni nemandleni, nemanweni;lawo azowa sebenzisa ukuthuma emdlalweni. Abadlali bomdlalo lo kufuze babe nokuzithemba okukhulu ngomba  kufuze bazijamelebona. Imidlalo le ifuna ithalente nokuzinniekela komuntu.

=== Imidlalo  yeengqondo ===
Imidalalo yeengqondo mdlalo iofuan bona umuntu atjengise okukhulu okuhlakanipha, ngokusebenzisa ingqondo yakhe ukuthuma umdlalo. abadalal abadalal imidlalo le kufuze bona babe nekghono lokurarulula imiraro, amaphazili nokhunye.Kufuze boan umdlali akwazi ukuthswaya ngelihlo elibukhali bwegodu akghone nokwenza ibonelelo phambili elizomsiza ukithumba iphaliswano lomdlalo.


</text>
      <sha1>7jmye91omp3ffhmy5qyb3hb8qkzvhoz</sha1>
    </revision>
    <revision>
      <id>799</id>
      <parentid>798</parentid>
      <timestamp>2024-08-07T17:20:29Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>799</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1497" sha1="4rx1e364x4tz1sce4wnbq83az2dibbg" xml:space="preserve">'''Umdlalo''' ngilokho okwenziwa mumuntu nanyana abantu ngehloso yokuzithabisa, okufaka hlangana umthetho , ukuphikisana nekghono elithileko. Umdlalo udlala ziinqheema ezimbili  nanyan ezinengi.

== Imihlobo yemidlalo ==

=== Imidlalo yeenqheema ===
Le midlalo efaka hlangana inqheema ezimbli nnanyana ezingaphezu kwezimbili. Abadlali bomdlalo wesiqheema basebenzisana ngokumnqopho wokuzuza lokho abakuhlosileko, kungaba ligondelo nanyana okhunye ekuzobenza bona bathumbe umdlalo. Emdlalweni abadlali bayazihlela ngokwendelal abazokujama ngayo. Isibonelo somdlalo weenqheema kungaba mdlalo webholo, umakhakhula rarhwe kanye ne khrikhethi.

=== Imidlalo yangamunye ===
Midlalo lapho umuntu adlala khona ngokuzijamela abambelelel ekghonweni nemandleni, nemanweni;lawo azowa sebenzisa ukuthuma emdlalweni. Abadlali bomdlalo lo kufuze babe nokuzithemba okukhulu ngomba  kufuze bazijamelebona. Imidlalo le ifuna ithalente nokuzinniekela komuntu. Isibonelo somdlalo wangamunye kungaba mdlalo wokududa, ukureya itsikiri, nokugijima.

=== Imidlalo  yeengqondo ===
Imidalalo yeengqondo mdlalo iofuan bona umuntu atjengise okukhulu okuhlakanipha, ngokusebenzisa ingqondo yakhe ukuthuma umdlalo. abadalal abadalal imidlalo le kufuze bona babe nekghono lokurarulula imiraro, amaphazili nokhunye.Kufuze boan umdlali akwazi ukuthswaya ngelihlo elibukhali bwegodu akghone nokwenza ibonelelo phambili elizomsiza ukithumba iphaliswano lomdlalo. Isibonelo somdlalo wengqondo kungaba mdlalo we tjhezi namaphazili.


</text>
      <sha1>4rx1e364x4tz1sce4wnbq83az2dibbg</sha1>
    </revision>
    <revision>
      <id>800</id>
      <parentid>799</parentid>
      <timestamp>2024-08-07T17:29:10Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>800</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1985" sha1="ebon6rqa6bslqhyl72l06rt4pbnxs82" xml:space="preserve">&lt;ref&gt;Jarvie, G., Thornton, J. and Mackie, H., 2013. ''Sport, culture and society: an introduction''. Routledge.&lt;/ref&gt;'''Umdlalo''' ngilokho okwenziwa mumuntu nanyana abantu ngehloso yokuzithabisa, okufaka hlangana umthetho , ukuphikisana nekghono elithileko. Umdlalo udlala ziinqheema ezimbili  nanyan ezinengi.

== Imihlobo yemidlalo ==

=== Imidlalo yeenqheema ===
Le midlalo efaka hlangana inqheema ezimbli nnanyana ezingaphezu kwezimbili. Abadlali bomdlalo wesiqheema basebenzisana ngokumnqopho wokuzuza lokho abakuhlosileko, kungaba ligondelo nanyana okhunye ekuzobenza bona bathumbe umdlalo. Emdlalweni abadlali bayazihlela ngokwendelal abazokujama ngayo. Isibonelo somdlalo weenqheema kungaba mdlalo webholo, umakhakhula rarhwe kanye ne khrikhethi.

=== Imidlalo yangamunye ===
Midlalo lapho umuntu adlala khona ngokuzijamela abambelele ekghonweni nemandleni, nemanweni;lawo azowa sebenzisa ukuthuma emdlalweni. Abadlali bomdlalo lo kufuze babe nokuzithemba okukhulu ngomba  kufuze bazijamelebona. Imidlalo le ifuna ithalente nokuzinniekela komuntu. Isibonelo somdlalo wangamunye kungaba mdlalo wokududa, ukureya itsikiri, nokugijima&lt;ref&gt;Baker, J., Yardley, J. and Cote, J., 2003. And individual sports. ''Int. J. Sport Psychol'', ''34'', pp.226-239&lt;/ref&gt; .

=== Imidlalo  yeengqondo ===
Kobiela (2018) uhlathulula Imidlalo yeengqondo ngokuthi mdlalo lapho umuntu angasebenzisi khona umzimba wakhe ukudlala kodwana ufuna bona umuntu atjengise okukhulu okuhlakanipha, ngokusebenzisa ingqondo yakhe ukuthuma umdlalo&lt;ref&gt;Kobiela, F., 2018. Should chess and other mind sports be regarded as sports?. ''Journal of the Philosophy of Sport'', ''45''(3), pp.279-295.&lt;/ref&gt;. abadalal abadalal imidlalo le kufuze bona babe nekghono lokurarulula imiraro, amaphazili nokhunye.Kufuze boan umdlali akwazi ukuthswaya ngelihlo elibukhali bwegodu akghone nokwenza ibonelelo phambili elizomsiza ukithumba iphaliswano lomdlalo. Isibonelo somdlalo wengqondo kungaba mdlalo we tjhezi namaphazili.


</text>
      <sha1>ebon6rqa6bslqhyl72l06rt4pbnxs82</sha1>
    </revision>
    <revision>
      <id>801</id>
      <parentid>800</parentid>
      <timestamp>2024-08-07T18:06:09Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>801</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1989" sha1="gvrgn2iza7hv4tsor57acn81wyco65x" xml:space="preserve">&lt;ref&gt;Jarvie, G., Thornton, J. and Mackie, H., 2013. ''Sport, culture and society: an introduction''. Routledge.&lt;/ref&gt;'''Umdlalo''' ngilokho okwenziwa mumuntu nanyana abantu ngehloso yokuzithabisa, okufaka hlangana umthetho , ukuphikisana nekghono elithileko. Umdlalo udlala ziinqheema ezimbili  nanyan ezinengi.

== Imihlobo yemidlalo ==

=== Imidlalo yeenqheema ===
Le midlalo efaka hlangana inqheema ezimbli nnanyana ezingaphezu kwezimbili. Abadlali bomdlalo wesiqheema basebenzisana ngokumnqopho wokuzuza lokho abakuhlosileko, kungaba ligondelo nanyana okhunye ekuzobenza bona bathumbe umdlalo. Emdlalweni abadlali bayazihlela ngokwendelal abazokujama ngayo. Isibonelo somdlalo weenqheema kungaba mdlalo webholo, umakhakhula rarhwe kanye ne khrikhethi.

=== Imidlalo yangamunye ===
Midlalo lapho umuntu adlala khona ngokuzijamela abambelele ekghonweni nemandleni, nemanweni;lawo azowa sebenzisa ukuthuma emdlalweni. Abadlali bomdlalo lo kufuze babe nokuzithemba okukhulu ngomba  kufuze bazijamelebona. Imidlalo le ifuna ithalente nokuzinniekela komuntu. Isibonelo somdlalo wangamunye kungaba mdlalo wokududa, ukureya itsikiri, nokugijima&lt;ref&gt;Baker, J., Yardley, J. and Cote, J., 2003. And individual sports. ''Int. J. Sport Psychol'', ''34'', pp.226-239&lt;/ref&gt; .

=== Imidlalo  yeengqondo ===
Kobiela (2018) uhlathulula [[Imidlalo]] yeengqondo ngokuthi mdlalo lapho umuntu angasebenzisi khona umzimba wakhe ukudlala kodwana ufuna bona umuntu atjengise okukhulu okuhlakanipha, ngokusebenzisa ingqondo yakhe ukuthuma umdlalo&lt;ref&gt;Kobiela, F., 2018. Should chess and other mind sports be regarded as sports?. ''Journal of the Philosophy of Sport'', ''45''(3), pp.279-295.&lt;/ref&gt;. abadalal abadalal imidlalo le kufuze bona babe nekghono lokurarulula imiraro, amaphazili nokhunye.Kufuze boan umdlali akwazi ukuthswaya ngelihlo elibukhali bwegodu akghone nokwenza ibonelelo phambili elizomsiza ukithumba iphaliswano lomdlalo. Isibonelo somdlalo wengqondo kungaba mdlalo we tjhezi namaphazili.


</text>
      <sha1>gvrgn2iza7hv4tsor57acn81wyco65x</sha1>
    </revision>
    <revision>
      <id>802</id>
      <parentid>801</parentid>
      <timestamp>2024-08-07T18:06:57Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>802</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1992" sha1="ht57qcl7ug076msm0aq073orjq6prcw" xml:space="preserve">&lt;ref&gt;Jarvie, G., Thornton, J. and Mackie, H., 2013. ''Sport, culture and society: an introduction''. Routledge.&lt;/ref&gt;'''Umdlalo''' ngilokho okwenziwa mumuntu nanyana abantu ngehloso yokuzithabisa, okufaka hlangana umthetho , ukuphikisana nekghono elithileko. Umdlalo udlala ziinqheema ezimbili  nanyan ezinengi.

== Imihlobo yemidlalo ==

=== Imidlalo yeenqheema ===
Le midlalo efaka hlangana inqheema ezimbli nnanyana ezingaphezu kwezimbili. Abadlali bomdlalo wesiqheema basebenzisana ngokumnqopho wokuzuza lokho abakuhlosileko, kungaba ligondelo nanyana okhunye ekuzobenza bona bathumbe umdlalo. Emdlalweni abadlali bayazihlela ngokwendelal abazokujama ngayo. Isibonelo somdlalo weenqheema kungaba mdlalo webholo, [[umakhakhulararhwe]] kanye ne khrikhethi.

=== Imidlalo yangamunye ===
Midlalo lapho umuntu adlala khona ngokuzijamela abambelele ekghonweni nemandleni, nemanweni;lawo azowa sebenzisa ukuthuma emdlalweni. Abadlali bomdlalo lo kufuze babe nokuzithemba okukhulu ngomba  kufuze bazijamelebona. Imidlalo le ifuna ithalente nokuzinniekela komuntu. Isibonelo somdlalo wangamunye kungaba mdlalo wokududa, ukureya itsikiri, nokugijima&lt;ref&gt;Baker, J., Yardley, J. and Cote, J., 2003. And individual sports. ''Int. J. Sport Psychol'', ''34'', pp.226-239&lt;/ref&gt; .

=== Imidlalo  yeengqondo ===
Kobiela (2018) uhlathulula [[Imidlalo]] yeengqondo ngokuthi mdlalo lapho umuntu angasebenzisi khona umzimba wakhe ukudlala kodwana ufuna bona umuntu atjengise okukhulu okuhlakanipha, ngokusebenzisa ingqondo yakhe ukuthuma umdlalo&lt;ref&gt;Kobiela, F., 2018. Should chess and other mind sports be regarded as sports?. ''Journal of the Philosophy of Sport'', ''45''(3), pp.279-295.&lt;/ref&gt;. abadalal abadalal imidlalo le kufuze bona babe nekghono lokurarulula imiraro, amaphazili nokhunye.Kufuze boan umdlali akwazi ukuthswaya ngelihlo elibukhali bwegodu akghone nokwenza ibonelelo phambili elizomsiza ukithumba iphaliswano lomdlalo. Isibonelo somdlalo wengqondo kungaba mdlalo we tjhezi namaphazili.


</text>
      <sha1>ht57qcl7ug076msm0aq073orjq6prcw</sha1>
    </revision>
    <revision>
      <id>803</id>
      <parentid>802</parentid>
      <timestamp>2024-08-18T12:38:41Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>803</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2078" sha1="c2f6i7xcywylxljrgry1cneyzcq7i6m" xml:space="preserve">&lt;ref&gt;Jarvie, G., Thornton, J. and Mackie, H., 2013. ''Sport, culture and society: an introduction''. Routledge.&lt;/ref&gt;'''Umdlalo''' ngilokho okwenziwa mumuntu nanyana abantu ngehloso yokuzithabisa, okufaka hlangana umthetho , ukuphikisana nekghono elithileko. Umdlalo udlala ziinqheema ezimbili  nanyan ezinengi.

== Imihlobo yemidlalo ==

=== Imidlalo yeenqheema ===
[[Isimumathi:Umdlalo webholo.jpg|thumb|abantwana abasafunda ukudlala umdlalo webholo]]
Le midlalo efaka hlangana inqheema ezimbli nnanyana ezingaphezu kwezimbili. Abadlali bomdlalo wesiqheema basebenzisana ngokumnqopho wokuzuza lokho abakuhlosileko, kungaba ligondelo nanyana okhunye ekuzobenza bona bathumbe umdlalo. Emdlalweni abadlali bayazihlela ngokwendela abazokujama ngayo. Isibonelo somdlalo weenqheema kungaba mdlalo webholo, [[umakhakhulararhwe]] kanye ne khrikhethi.

=== Imidlalo yangamunye ===
Midlalo lapho umuntu adlala khona ngokuzijamela abambelele ekghonweni nemandleni, nemanweni;lawo azowa sebenzisa ukuthuma emdlalweni. Abadlali bomdlalo lo kufuze babe nokuzithemba okukhulu ngomba  kufuze bazijamelebona. Imidlalo le ifuna ithalente nokuzinniekela komuntu. Isibonelo somdlalo wangamunye kungaba mdlalo wokududa, ukureya itsikiri, nokugijima&lt;ref&gt;Baker, J., Yardley, J. and Cote, J., 2003. And individual sports. ''Int. J. Sport Psychol'', ''34'', pp.226-239&lt;/ref&gt; .

=== Imidlalo  yeengqondo ===
Kobiela (2018) uhlathulula [[Imidlalo]] yeengqondo ngokuthi mdlalo lapho umuntu angasebenzisi khona umzimba wakhe ukudlala kodwana ufuna bona umuntu atjengise okukhulu okuhlakanipha, ngokusebenzisa ingqondo yakhe ukuthuma umdlalo&lt;ref&gt;Kobiela, F., 2018. Should chess and other mind sports be regarded as sports?. ''Journal of the Philosophy of Sport'', ''45''(3), pp.279-295.&lt;/ref&gt;. abadalal abadalal imidlalo le kufuze bona babe nekghono lokurarulula imiraro, amaphazili nokhunye.Kufuze boan umdlali akwazi ukuthswaya ngelihlo elibukhali bwegodu akghone nokwenza ibonelelo phambili elizomsiza ukithumba iphaliswano lomdlalo. Isibonelo somdlalo wengqondo kungaba mdlalo we tjhezi namaphazili.


</text>
      <sha1>c2f6i7xcywylxljrgry1cneyzcq7i6m</sha1>
    </revision>
    <revision>
      <id>804</id>
      <parentid>803</parentid>
      <timestamp>2024-10-14T13:46:49Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>6 revisions imported</comment>
      <origin>803</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2078" sha1="c2f6i7xcywylxljrgry1cneyzcq7i6m" xml:space="preserve">&lt;ref&gt;Jarvie, G., Thornton, J. and Mackie, H., 2013. ''Sport, culture and society: an introduction''. Routledge.&lt;/ref&gt;'''Umdlalo''' ngilokho okwenziwa mumuntu nanyana abantu ngehloso yokuzithabisa, okufaka hlangana umthetho , ukuphikisana nekghono elithileko. Umdlalo udlala ziinqheema ezimbili  nanyan ezinengi.

== Imihlobo yemidlalo ==

=== Imidlalo yeenqheema ===
[[Isimumathi:Umdlalo webholo.jpg|thumb|abantwana abasafunda ukudlala umdlalo webholo]]
Le midlalo efaka hlangana inqheema ezimbli nnanyana ezingaphezu kwezimbili. Abadlali bomdlalo wesiqheema basebenzisana ngokumnqopho wokuzuza lokho abakuhlosileko, kungaba ligondelo nanyana okhunye ekuzobenza bona bathumbe umdlalo. Emdlalweni abadlali bayazihlela ngokwendela abazokujama ngayo. Isibonelo somdlalo weenqheema kungaba mdlalo webholo, [[umakhakhulararhwe]] kanye ne khrikhethi.

=== Imidlalo yangamunye ===
Midlalo lapho umuntu adlala khona ngokuzijamela abambelele ekghonweni nemandleni, nemanweni;lawo azowa sebenzisa ukuthuma emdlalweni. Abadlali bomdlalo lo kufuze babe nokuzithemba okukhulu ngomba  kufuze bazijamelebona. Imidlalo le ifuna ithalente nokuzinniekela komuntu. Isibonelo somdlalo wangamunye kungaba mdlalo wokududa, ukureya itsikiri, nokugijima&lt;ref&gt;Baker, J., Yardley, J. and Cote, J., 2003. And individual sports. ''Int. J. Sport Psychol'', ''34'', pp.226-239&lt;/ref&gt; .

=== Imidlalo  yeengqondo ===
Kobiela (2018) uhlathulula [[Imidlalo]] yeengqondo ngokuthi mdlalo lapho umuntu angasebenzisi khona umzimba wakhe ukudlala kodwana ufuna bona umuntu atjengise okukhulu okuhlakanipha, ngokusebenzisa ingqondo yakhe ukuthuma umdlalo&lt;ref&gt;Kobiela, F., 2018. Should chess and other mind sports be regarded as sports?. ''Journal of the Philosophy of Sport'', ''45''(3), pp.279-295.&lt;/ref&gt;. abadalal abadalal imidlalo le kufuze bona babe nekghono lokurarulula imiraro, amaphazili nokhunye.Kufuze boan umdlali akwazi ukuthswaya ngelihlo elibukhali bwegodu akghone nokwenza ibonelelo phambili elizomsiza ukithumba iphaliswano lomdlalo. Isibonelo somdlalo wengqondo kungaba mdlalo we tjhezi namaphazili.


</text>
      <sha1>c2f6i7xcywylxljrgry1cneyzcq7i6m</sha1>
    </revision>
    <revision>
      <id>2166</id>
      <parentid>804</parentid>
      <timestamp>2024-11-27T06:18:38Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>+ Iinkomba</comment>
      <origin>2166</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2102" sha1="robr8ogzf5g291wz912af96nuylu8ob" xml:space="preserve">&lt;ref&gt;Jarvie, G., Thornton, J. and Mackie, H., 2013. ''Sport, culture and society: an introduction''. Routledge.&lt;/ref&gt;'''Umdlalo''' ngilokho okwenziwa mumuntu nanyana abantu ngehloso yokuzithabisa, okufaka hlangana umthetho , ukuphikisana nekghono elithileko. Umdlalo udlala ziinqheema ezimbili  nanyan ezinengi.

== Imihlobo yemidlalo ==
=== Imidlalo yeenqheema ===
[[Isimumathi:Umdlalo webholo.jpg|thumb|abantwana abasafunda ukudlala umdlalo webholo]]
Le midlalo efaka hlangana inqheema ezimbli nnanyana ezingaphezu kwezimbili. Abadlali bomdlalo wesiqheema basebenzisana ngokumnqopho wokuzuza lokho abakuhlosileko, kungaba ligondelo nanyana okhunye ekuzobenza bona bathumbe umdlalo. Emdlalweni abadlali bayazihlela ngokwendela abazokujama ngayo. Isibonelo somdlalo weenqheema kungaba mdlalo webholo, [[umakhakhulararhwe]] kanye ne khrikhethi.

=== Imidlalo yangamunye ===
Midlalo lapho umuntu adlala khona ngokuzijamela abambelele ekghonweni nemandleni, nemanweni;lawo azowa sebenzisa ukuthuma emdlalweni. Abadlali bomdlalo lo kufuze babe nokuzithemba okukhulu ngomba  kufuze bazijamelebona. Imidlalo le ifuna ithalente nokuzinniekela komuntu. Isibonelo somdlalo wangamunye kungaba mdlalo wokududa, ukureya itsikiri, nokugijima&lt;ref&gt;Baker, J., Yardley, J. and Cote, J., 2003. And individual sports. ''Int. J. Sport Psychol'', ''34'', pp.226-239&lt;/ref&gt; .

=== Imidlalo  yeengqondo ===
Kobiela (2018) uhlathulula [[Imidlalo]] yeengqondo ngokuthi mdlalo lapho umuntu angasebenzisi khona umzimba wakhe ukudlala kodwana ufuna bona umuntu atjengise okukhulu okuhlakanipha, ngokusebenzisa ingqondo yakhe ukuthuma umdlalo&lt;ref&gt;Kobiela, F., 2018. Should chess and other mind sports be regarded as sports?. ''Journal of the Philosophy of Sport'', ''45''(3), pp.279-295.&lt;/ref&gt;. abadalal abadalal imidlalo le kufuze bona babe nekghono lokurarulula imiraro, amaphazili nokhunye.Kufuze boan umdlali akwazi ukuthswaya ngelihlo elibukhali bwegodu akghone nokwenza ibonelelo phambili elizomsiza ukithumba iphaliswano lomdlalo. Isibonelo somdlalo wengqondo kungaba mdlalo we tjhezi namaphazili.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>robr8ogzf5g291wz912af96nuylu8ob</sha1>
    </revision>
    <revision>
      <id>2919</id>
      <parentid>2166</parentid>
      <timestamp>2025-06-06T17:02:54Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>Your skin.</comment>
      <origin>2919</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="670" sha1="k9antab7icupkgqu1x9useqnkb4fwcr" xml:space="preserve">They told me to wear your skin

They told me to wear your skin

They told me to wear your skin

They told me to wear your skin

They told me to wear your skin

They told me to wear your skin

They told me to wear your skin

They told me to wear your skin

They told me to wear your skin

They told me to wear your skin

They told me to wear your skin

They told me to wear your skin

They told me to wear your skin

They told me to wear your skin

They told me to wear your skin

They told me to wear your skin

They told me to wear your skin

They told me to wear your skin

They told me to wear your skin

They told me to wear your skin

They told me to wear your skin</text>
      <sha1>k9antab7icupkgqu1x9useqnkb4fwcr</sha1>
    </revision>
    <revision>
      <id>3101</id>
      <parentid>2919</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Simakahle Moselekatse|Simakahle Moselekatse]]</comment>
      <origin>2166</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2102" sha1="robr8ogzf5g291wz912af96nuylu8ob" xml:space="preserve">&lt;ref&gt;Jarvie, G., Thornton, J. and Mackie, H., 2013. ''Sport, culture and society: an introduction''. Routledge.&lt;/ref&gt;'''Umdlalo''' ngilokho okwenziwa mumuntu nanyana abantu ngehloso yokuzithabisa, okufaka hlangana umthetho , ukuphikisana nekghono elithileko. Umdlalo udlala ziinqheema ezimbili  nanyan ezinengi.

== Imihlobo yemidlalo ==
=== Imidlalo yeenqheema ===
[[Isimumathi:Umdlalo webholo.jpg|thumb|abantwana abasafunda ukudlala umdlalo webholo]]
Le midlalo efaka hlangana inqheema ezimbli nnanyana ezingaphezu kwezimbili. Abadlali bomdlalo wesiqheema basebenzisana ngokumnqopho wokuzuza lokho abakuhlosileko, kungaba ligondelo nanyana okhunye ekuzobenza bona bathumbe umdlalo. Emdlalweni abadlali bayazihlela ngokwendela abazokujama ngayo. Isibonelo somdlalo weenqheema kungaba mdlalo webholo, [[umakhakhulararhwe]] kanye ne khrikhethi.

=== Imidlalo yangamunye ===
Midlalo lapho umuntu adlala khona ngokuzijamela abambelele ekghonweni nemandleni, nemanweni;lawo azowa sebenzisa ukuthuma emdlalweni. Abadlali bomdlalo lo kufuze babe nokuzithemba okukhulu ngomba  kufuze bazijamelebona. Imidlalo le ifuna ithalente nokuzinniekela komuntu. Isibonelo somdlalo wangamunye kungaba mdlalo wokududa, ukureya itsikiri, nokugijima&lt;ref&gt;Baker, J., Yardley, J. and Cote, J., 2003. And individual sports. ''Int. J. Sport Psychol'', ''34'', pp.226-239&lt;/ref&gt; .

=== Imidlalo  yeengqondo ===
Kobiela (2018) uhlathulula [[Imidlalo]] yeengqondo ngokuthi mdlalo lapho umuntu angasebenzisi khona umzimba wakhe ukudlala kodwana ufuna bona umuntu atjengise okukhulu okuhlakanipha, ngokusebenzisa ingqondo yakhe ukuthuma umdlalo&lt;ref&gt;Kobiela, F., 2018. Should chess and other mind sports be regarded as sports?. ''Journal of the Philosophy of Sport'', ''45''(3), pp.279-295.&lt;/ref&gt;. abadalal abadalal imidlalo le kufuze bona babe nekghono lokurarulula imiraro, amaphazili nokhunye.Kufuze boan umdlali akwazi ukuthswaya ngelihlo elibukhali bwegodu akghone nokwenza ibonelelo phambili elizomsiza ukithumba iphaliswano lomdlalo. Isibonelo somdlalo wengqondo kungaba mdlalo we tjhezi namaphazili.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>robr8ogzf5g291wz912af96nuylu8ob</sha1>
    </revision>
    <revision>
      <id>5066</id>
      <parentid>3101</parentid>
      <timestamp>2025-08-07T18:29:04Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5066</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2110" sha1="39026i2m77ywlpuqx2w3dengt5e4dyy" xml:space="preserve">&lt;ref&gt;Jarvie, G., Thornton, J. and Mackie, H., 2013. ''Sport, culture and society: an introduction''. Routledge.&lt;/ref&gt;'''Umdlalo''' ngilokho okwenziwa mumuntu nanyana abantu ngehloso yokuzithabisa, okufaka hlangana umthetho , ukuphikisana nekghono elithileko. Umdlalo udlala ziinqheema ezimbili  nanyan ezinengi.

=== Imihlobo yemidlalo ===

==== Imidlalo yeenqheema ====
[[Isimumathi:Umdlalo webholo.jpg|thumb|abantwana abasafunda ukudlala umdlalo webholo]]
Le midlalo efaka hlangana inqheema ezimbli nanyana ezingaphezu kwezimbili. Abadlali bomdlalo wesiqheema basebenzisana ngokumnqopho wokuzuza lokho abakuhlosileko, kungaba ligondelo nanyana okhunye ekuzobenza bona bathumbe umdlalo. Emdlalweni abadlali bayazihlela ngokwendela abazokujama ngayo. Isibonelo somdlalo weenqheema kungaba mdlalo webholo, [[umakhakhulararhwe]] kanye ne khrikhethi.

==== Imidlalo yangamunye ====
Midlalo lapho umuntu adlala khona ngokuzijamela abambelele ekghonweni nemandleni, nemanweni;lawo azowa sebenzisa ukuthuma emdlalweni. Abadlali bomdlalo lo kufuze babe nokuzithemba okukhulu ngomba  kufuze bazijamelebona. Imidlalo le ifuna ithalente nokuzinniekela komuntu. Isibonelo somdlalo wangamunye kungaba mdlalo wokududa, ukureya itsikiri, nokugijima&lt;ref&gt;Baker, J., Yardley, J. and Cote, J., 2003. And individual sports. ''Int. J. Sport Psychol'', ''34'', pp.226-239&lt;/ref&gt; .

==== Imidlalo  yeengqondo ====
Kobiela (2018) uhlathulula [[Imidlalo]] yeengqondo ngokuthi mdlalo lapho umuntu angasebenzisi khona umzimba wakhe ukudlala kodwana ufuna bona umuntu atjengise okukhulu okuhlakanipha, ngokusebenzisa ingqondo yakhe ukuthuma umdlalo&lt;ref&gt;Kobiela, F., 2018. Should chess and other mind sports be regarded as sports?. ''Journal of the Philosophy of Sport'', ''45''(3), pp.279-295.&lt;/ref&gt;. abadalal abadalal imidlalo le kufuze bona babe nekghono lokurarulula imiraro, amaphazili nokhunye.Kufuze boan umdlali akwazi ukuthswaya ngelihlo elibukhali bwegodu akghone nokwenza ibonelelo phambili elizomsiza ukithumba iphaliswano lomdlalo. Isibonelo somdlalo wengqondo kungaba mdlalo we tjhezi namaphazili.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>39026i2m77ywlpuqx2w3dengt5e4dyy</sha1>
    </revision>
    <revision>
      <id>5067</id>
      <parentid>5066</parentid>
      <timestamp>2025-08-07T18:30:15Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>5067</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2159" sha1="0j9lhthwgzqo3hf4lz69lsis0oowgbm" xml:space="preserve">&lt;ref&gt;Jarvie, G., Thornton, J. and Mackie, H., 2013. ''Sport, culture and society: an introduction''. Routledge.&lt;/ref&gt;'''Umdlalo''' ngilokho okwenziwa mumuntu nanyana abantu ngehloso yokuzithabisa, okufaka hlangana umthetho , ukuphikisana nekghono elithileko. Umdlalo udlala ziinqheema ezimbili  nanyan ezinengi.

=== Imihlobo yemidlalo ===

==== Imidlalo yeenqheema ====
[[Isimumathi:Umdlalo webholo.jpg|thumb|abantwana abasafunda ukudlala umdlalo webholo]]
Le midlalo efaka hlangana inqheema ezimbli nanyana ezingaphezu kwezimbili. Abadlali bomdlalo wesiqheema basebenzisana ngokumnqopho wokuzuza lokho abakuhlosileko, kungaba ligondelo nanyana okhunye ekuzobenza bona bathumbe umdlalo. Emdlalweni abadlali bayazihlela ngokwendela abazokujama ngayo. Isibonelo somdlalo weenqheema kungaba mdlalo webholo, [[umakhakhulararhwe]] kanye ne khrikhethi.

==== Imidlalo yangamunye ====
Midlalo lapho umuntu adlala khona ngokuzijamela abambelele ekghonweni nemandleni, nemanweni;lawo azowa sebenzisa ukuthuma emdlalweni. Abadlali bomdlalo lo kufuze babe nokuzithemba okukhulu ngomba  kufuze bazijamelebona. Imidlalo le ifuna ithalente nokuzinniekela komuntu. Isibonelo somdlalo wangamunye kungaba mdlalo wokududa, ukureya itsikiri, nokugijima&lt;ref&gt;Baker, J., Yardley, J. and Cote, J., 2003. And individual sports. ''Int. J. Sport Psychol'', ''34'', pp.226-239&lt;/ref&gt; .

==== Imidlalo  yeengqondo ====
Kobiela (2018) uhlathulula [[Imidlalo]] yeengqondo ngokuthi mdlalo lapho umuntu angasebenzisi khona umzimba wakhe ukudlala kodwana ufuna bona umuntu atjengise okukhulu okuhlakanipha, ngokusebenzisa ingqondo yakhe ukuthuma umdlalo&lt;ref&gt;Kobiela, F., 2018. Should chess and other mind sports be regarded as sports?. ''Journal of the Philosophy of Sport'', ''45''(3), pp.279-295.&lt;/ref&gt;. abadalal abadalal imidlalo le kufuze bona babe nekghono lokurarulula imiraro, amaphazili nokhunye.Kufuze boan umdlali akwazi ukuthswaya ngelihlo elibukhali bwegodu akghone nokwenza ibonelelo phambili elizomsiza ukithumba iphaliswano lomdlalo. Isibonelo somdlalo wengqondo kungaba mdlalo we tjhezi namaphazili.

== Iinkomba ==
{{Reflist}}
[[Category:Umdlalo]]
[[Category:Ukuzithabulula]]</text>
      <sha1>0j9lhthwgzqo3hf4lz69lsis0oowgbm</sha1>
    </revision>
    <revision>
      <id>5937</id>
      <parentid>5067</parentid>
      <timestamp>2025-10-29T14:21:13Z</timestamp>
      <contributor>
        <username>Hlalithwa</username>
        <id>996</id>
      </contributor>
      <minor />
      <comment>Spelling and grammar</comment>
      <origin>5937</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2162" sha1="n8ret2yoi8ugpmrzprvluvgzso67z83" xml:space="preserve">&lt;ref&gt;Jarvie, G., Thornton, J. and Mackie, H., 2013. ''Sport, culture and society: an introduction''. Routledge.&lt;/ref&gt;'''Umdlalo''' ngilokho okwenziwa mumuntu nanyana abantu ngehloso yokuzithabisa, okufaka hlangana umthetho , ukuphikisana nekghono elithileko. Umdlalo udlala ziinqheema ezimbili  nanyan ezinengi.

=== Imihlobo yemidlalo ===

==== Imidlalo yeenqheema ====
[[Isimumathi:Umdlalo webholo.jpg|thumb|abantwana abasafunda ukudlala umdlalo webholo]]
Le midlalo efaka hlangana iinqheema ezimbli nanyana ezingaphezu kwezimbili. Abadlali bomdlalo wesiqheema basebenzisana ngomnqopho wokuzuza lokho abakuhlosileko, kungaba ligondelo nanyana okhunye ekuzobenza bona bathumbe umdlalo. Emdlalweni abadlali bayazihlela ngokwendlela abazokujama ngayo. Isibonelo somdlalo weenqheema kungaba mdlalo webholo, [[umakhakhulararhwe]] kanye ne khrikhethi.

==== Imidlalo yangamunye ====
Midlalo lapho umuntu adlala khona ngokuzijamela abambelele ekghonweni nemandleni, nemanweni;lawo azowa sebenzisa ukuthumba emdlalweni. Abadlali bomdlalo lo kufuze babe nokuzithemba okukhulu ngombana  kufuze bazijamele bona, Imidlalo le ifuna ithalente nokuzinikela komuntu. Isibonelo somdlalo wangamunye kungaba mdlalo wokududa, ukureya itsikiri, nokugijima&lt;ref&gt;Baker, J., Yardley, J. and Cote, J., 2003. And individual sports. ''Int. J. Sport Psychol'', ''34'', pp.226-239&lt;/ref&gt; .

==== Imidlalo  yeengqondo ====
Kobiela (2018) uhlathulula [[Imidlalo]] yeengqondo ngokuthi mdlalo lapho umuntu angasebenzisi khona umzimba wakhe ukudlala kodwana ufuna bona umuntu atjengise okukhulu okuhlakanipha, ngokusebenzisa ingqondo yakhe ukuthumba umdlalo&lt;ref&gt;Kobiela, F., 2018. Should chess and other mind sports be regarded as sports?. ''Journal of the Philosophy of Sport'', ''45''(3), pp.279-295.&lt;/ref&gt;. abadlali abadlala imidlalo le kufuze bona babe nekghono lokurarulula imiraro, amaphazili nokhunye, Kufuze bona umdlali akwazi ukuthswaya ngelihlo elibukhali begodu akghone nokwenza ibonelelo phambili elizomsiza ukuthumba iphaliswano lomdlalo. Isibonelo somdlalo wengqondo kungaba mdlalo we tjhezi namaphazili.

== Iinkomba ==
{{Reflist}}
[[Category:Umdlalo]]
[[Category:Ukuzithabulula]]</text>
      <sha1>n8ret2yoi8ugpmrzprvluvgzso67z83</sha1>
    </revision>
  </page>
  <page>
    <title>Imihlobo yeenhlathululimagama</title>
    <ns>0</ns>
    <id>169</id>
    <revision>
      <id>805</id>
      <timestamp>2024-07-21T09:41:00Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;== Imihlobo yeenhlathululimagama == Iinhlathululimagama nanyana iinhlathululimezwi zinemihlobo emingi leyo etholakalako. Imihlobo itlanywe ngeminqopho neendingo ezihlukileko zabasebenzisi abaqothelweko. Kukhona iinhlathululimagama ezikhethekileko lezo ezenzelwe imisebenzi nabantu bemikhakha ekhethekileko efana nezamaphilo, zesayensi nezebunjiniyera. Nanyana kunjalo, kukhona ezenzelwe woke umuntu osebenzisa ilimi ukukhuluma, ukuthintana nokufunda.    Namhlanje sizokutjhej...&quot;</comment>
      <origin>805</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4348" sha1="pwz88k4mjd2k9zeq0413a3lc7qi8agb" xml:space="preserve">== Imihlobo yeenhlathululimagama ==
Iinhlathululimagama nanyana iinhlathululimezwi zinemihlobo emingi leyo etholakalako. Imihlobo itlanywe ngeminqopho neendingo ezihlukileko zabasebenzisi abaqothelweko. Kukhona iinhlathululimagama ezikhethekileko lezo ezenzelwe imisebenzi nabantu bemikhakha ekhethekileko efana nezamaphilo, zesayensi nezebunjiniyera. Nanyana kunjalo, kukhona ezenzelwe woke umuntu osebenzisa ilimi ukukhuluma, ukuthintana nokufunda.  

Namhlanje sizokutjheja lezo ezenzelwe woke umuntu loyo osebenzisa ilimi ukufundisa, ukukhuluma nokuthintana. Iinhlathululimagama lezi sizozihlukanisa ngemihlobo emithathu, ebizwa bona: isihlathululimagama esilimilinye, isihlathululimagama esilimimbili nesihlathululimagama esilimintathu. 

=== Kuyini sihlathululimagama esilimilinye na? ===
U-Ali ngomnyaka ka-2012 wahlathulula isihlathululimagama esilimilinye bonyana, isihlathululimagama esilimilinye sihlathululimagama esinehlathululo, amatshwayo nelinye ilwazi lokuhleleka nanyana ilandelano lamagama welimi lomphakathi othize mayelana namagama lawo abudisi ukuzwisiseka kubasebenzisi belimi lelo. Ngamanye amagama isihlathululimagama esilimilinye sihlathululimagama esimumethe ilwazi ngelimi. Okutjho bonyana ihlathululo yegama, amatshwayo namathemu atlolwe ngesiNdebele. 

Kanengi lomhlobo wesihlathulumagama usetjenziswa babantu ilimi lelo ekulilimi lebele nanyana abafunda ilimi lelo njengelimi lokuthoma ekhaya. Nangabe wena awukhulumi ilimi lelo begodu awulifundi esikolweni njengeli lokuthoma lekhaya, ungaba nomraro wokungazwisisi amagama nanyana okutlolwe ngaphakathi kwesihlathululimagama lesi.
Isihlathululimagama lesi siqakatheke kwamambala ekungezeleleni ilwazi lwamagama nethuthuko yelimi lelo (Hadebe 2007). 

=== Kuyini isihlathululimagama esilimimbili na? ===
UKlapicova (2005) wahlathulula isihlathululimagama esilimimbili wathi, isihlathululimagama esilimimbili sinerhelo lamagama arhenyiswe ngokulandelana kwamaledere nanyana izitjho ngelimi linye lezo, ngokuqothelwa ezinikelwe amagama nanyana izinto ezinqophe poro ngelinye ilimi. Ngamanye amagama la, kusetjenziswa amalimi amabili, elinye ilimi lilimi elimsuka bese elinye lenziwe ilimi eliqothelweko. Ilimi elimsuka lilimi lelo amagama nanyana amathemu arhenyiswa ngalo. Kodwana, ilimi eliqothelweko lilimi lelo ihlathululo nezinye izitjho zinikelwa nanyana zitlolwe ngalo.  

Nabakhuluma ngokurhenyiswa kwamagama ngamaledere, balinga ukuveza bonyana isihlathululimagama ngiyo yodwa incwadi lapho ungathola khona imitlolo yangaphakathi irhenyiswe ngamaledere. Ezinye iincwadi ziyatlola ngaphandle kokurhemisa amagama ngamaledere.  

Lomhlobo wesihlathululimagama usetjenziswa khulu ngilabo abafuna ukufunda amalimi amabili ngesikhathi esisodwa nanyana abasebenza ngamalimi amabili njengokutjhugulula. Uqakathekile lomhlobo  ngomba utholakala nemikhakheni ekhethekileko. 

=== Kuyini isihlathululimagama esilimintathu? ===
UKlapicova (2005) uveza bonyana kukhona ezinye iinhlathululimagama lezo ezisebenzisa amalimi adlula kwamabili emitlolweni yazo ngaphakathi. Okutjho bona umhlobo lo ungasebenzisa isiNdebele, Siswati nesiZulu elwazini langaphakathi. Okwenzekako kukobana kuthathwa ilimi linye lezniwe imili elimsuka bese amanye la enziwe amalimi aqothelweko. Ngamanye amagama lokha amagama nanyana amathemu arhenyiswa ngesindebele, ihlathululo nanyana amathemu onqophileko azokunikelwa ngamalimi amabili la ekumalimi aqothelweko, Sizwati nesiZulu. 

Lomhlobo wesihlathululimagama wenzele boke abantu abafunda nanyana abasebenzisa amalimi amathathu ukukhuluma, ukufunda nokusebenza. Begodu umhlobo utjengisa nezinga lokuthuthuka kwamalimi esetjenzisiweko la. 

Ekulumeni yethu ngehla sikhulume besahlathulula imihlobo emithathu yeenhlathululimagama ezijayelekileko. Isihlathululimagama esilimilinye, esilimimbili nesilimbintathu zitjhejwe ngokungeneleleko. Zoke iihlathululimagama lezi ziqakatheke ngokungafani begodu nemisebenzi yazo ayifani. Kodwana, okukhulu kukobana kufanele zibe khona ukuze ilimi likwazi ukuthuthtuka

=== Umthombolwazi ===
Ali, H. I. H. (2012). ‘Monolingual Dictionary Use in an EFL Context’. English Language Teaching. 5(7):1-7

Hadebe, S. (2004). ‘Improving Dictionary Skills in Ndebele’. Lexikos. 14: 89-104.

Klapicová, E. H. (2005). Stavba hesla v dvojjazyčnom slovníku a jeho parametre. Studi Slavistici. 2(1): 219–235.

</text>
      <sha1>pwz88k4mjd2k9zeq0413a3lc7qi8agb</sha1>
    </revision>
    <revision>
      <id>806</id>
      <parentid>805</parentid>
      <timestamp>2024-09-18T15:52:15Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>806</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4418" sha1="n7muf5df5apryvv9bj7zidcf2iinifp" xml:space="preserve">== Imihlobo yeenhlathululimagama ==
Iinhlathululimagama nanyana iinhlathululimezwi zinemihlobo emingi leyo etholakalako. Imihlobo itlanywe ngeminqopho neendingo ezihlukileko zabasebenzisi abaqothelweko. Kukhona iinhlathululimagama ezikhethekileko lezo ezenzelwe imisebenzi nabantu bemikhakha ekhethekileko efana nezamaphilo, zesayensi nezebunjiniyera. Nanyana kunjalo, kukhona ezenzelwe woke umuntu osebenzisa ilimi ukukhuluma, ukuthintana nokufunda.  

Namhlanje sizokutjheja lezo ezenzelwe woke umuntu loyo osebenzisa ilimi ukufundisa, ukukhuluma nokuthintana. Iinhlathululimagama lezi sizozihlukanisa ngemihlobo emithathu, ebizwa bona: isihlathululimagama esilimilinye, isihlathululimagama esilimimbili nesihlathululimagama esilimintathu. 

=== Kuyini sihlathululimagama esilimilinye na? ===
U-Ali&lt;ref&gt;Ali, H. I. H. (2012). ‘Monolingual Dictionary Use in an EFL Context’. English Language Teaching. 5(7):1-7&lt;/ref&gt; ngomnyaka ka-2012 wahlathulula isihlathululimagama esilimilinye bonyana, isihlathululimagama esilimilinye sihlathululimagama esinehlathululo, amatshwayo nelinye ilwazi lokuhleleka nanyana ilandelano lamagama welimi lomphakathi othize mayelana namagama lawo abudisi ukuzwisiseka kubasebenzisi belimi lelo. Ngamanye amagama isihlathululimagama esilimilinye sihlathululimagama esimumethe ilwazi ngelimi. Okutjho bonyana ihlathululo yegama, amatshwayo namathemu atlolwe ngesiNdebele. 

Kanengi lomhlobo wesihlathulumagama usetjenziswa babantu ilimi lelo ekulilimi lebele nanyana abafunda ilimi lelo njengelimi lokuthoma ekhaya. Nangabe wena awukhulumi ilimi lelo begodu awulifundi esikolweni njengeli lokuthoma lekhaya, ungaba nomraro wokungazwisisi amagama nanyana okutlolwe ngaphakathi kwesihlathululimagama lesi.
Isihlathululimagama lesi siqakatheke kwamambala ekungezeleleni ilwazi lwamagama nethuthuko yelimi lelo (Hadebe 2007&lt;ref&gt;Hadebe, S. (2004). ‘Improving Dictionary Skills in Ndebele’. Lexikos. 14: 89-104.&lt;/ref&gt;). 

=== Kuyini isihlathululimagama esilimimbili na? ===
UKlapicova (2005&lt;ref name=&quot;:0&quot;&gt;Klapicová, E. H. (2005). Stavba hesla v dvojjazyčnom slovníku a jeho parametre. Studi Slavistici. 2(1): 219–235.&lt;/ref&gt;) wahlathulula isihlathululimagama esilimimbili wathi, isihlathululimagama esilimimbili sinerhelo lamagama arhenyiswe ngokulandelana kwamaledere nanyana izitjho ngelimi linye lezo, ngokuqothelwa ezinikelwe amagama nanyana izinto ezinqophe poro ngelinye ilimi. Ngamanye amagama la, kusetjenziswa amalimi amabili, elinye ilimi lilimi elimsuka bese elinye lenziwe ilimi eliqothelweko. Ilimi elimsuka lilimi lelo amagama nanyana amathemu arhenyiswa ngalo. Kodwana, ilimi eliqothelweko lilimi lelo ihlathululo nezinye izitjho zinikelwa nanyana zitlolwe ngalo.  

Nabakhuluma ngokurhenyiswa kwamagama ngamaledere, balinga ukuveza bonyana isihlathululimagama ngiyo yodwa incwadi lapho ungathola khona imitlolo yangaphakathi irhenyiswe ngamaledere. Ezinye iincwadi ziyatlola ngaphandle kokurhemisa amagama ngamaledere.  

Lomhlobo wesihlathululimagama usetjenziswa khulu ngilabo abafuna ukufunda amalimi amabili ngesikhathi esisodwa nanyana abasebenza ngamalimi amabili njengokutjhugulula. Uqakathekile lomhlobo  ngomba utholakala nemikhakheni ekhethekileko. 

=== Kuyini isihlathululimagama esilimintathu? ===
UKlapicova (2005&lt;ref name=&quot;:0&quot; /&gt;) uveza bonyana kukhona ezinye iinhlathululimagama lezo ezisebenzisa amalimi adlula kwamabili emitlolweni yazo ngaphakathi. Okutjho bona umhlobo lo ungasebenzisa isiNdebele, Siswati nesiZulu elwazini langaphakathi. Okwenzekako kukobana kuthathwa ilimi linye lezniwe imili elimsuka bese amanye la enziwe amalimi aqothelweko. Ngamanye amagama lokha amagama nanyana amathemu arhenyiswa ngesindebele, ihlathululo nanyana amathemu onqophileko azokunikelwa ngamalimi amabili la ekumalimi aqothelweko, Sizwati nesiZulu. 

Lomhlobo wesihlathululimagama wenzele boke abantu abafunda nanyana abasebenzisa amalimi amathathu ukukhuluma, ukufunda nokusebenza. Begodu umhlobo utjengisa nezinga lokuthuthuka kwamalimi esetjenzisiweko la. 

Ekulumeni yethu ngehla sikhulume besahlathulula imihlobo emithathu yeenhlathululimagama ezijayelekileko. Isihlathululimagama esilimilinye, esilimimbili nesilimbintathu zitjhejwe ngokungeneleleko. Zoke iihlathululimagama lezi ziqakatheke ngokungafani begodu nemisebenzi yazo ayifani. Kodwana, okukhulu kukobana kufanele zibe khona ukuze ilimi likwazi ukuthuthtuka

=== Umthombolwazi ===
&lt;references /&gt;

</text>
      <sha1>n7muf5df5apryvv9bj7zidcf2iinifp</sha1>
    </revision>
    <revision>
      <id>807</id>
      <parentid>806</parentid>
      <timestamp>2024-10-14T13:46:49Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>806</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4418" sha1="n7muf5df5apryvv9bj7zidcf2iinifp" xml:space="preserve">== Imihlobo yeenhlathululimagama ==
Iinhlathululimagama nanyana iinhlathululimezwi zinemihlobo emingi leyo etholakalako. Imihlobo itlanywe ngeminqopho neendingo ezihlukileko zabasebenzisi abaqothelweko. Kukhona iinhlathululimagama ezikhethekileko lezo ezenzelwe imisebenzi nabantu bemikhakha ekhethekileko efana nezamaphilo, zesayensi nezebunjiniyera. Nanyana kunjalo, kukhona ezenzelwe woke umuntu osebenzisa ilimi ukukhuluma, ukuthintana nokufunda.  

Namhlanje sizokutjheja lezo ezenzelwe woke umuntu loyo osebenzisa ilimi ukufundisa, ukukhuluma nokuthintana. Iinhlathululimagama lezi sizozihlukanisa ngemihlobo emithathu, ebizwa bona: isihlathululimagama esilimilinye, isihlathululimagama esilimimbili nesihlathululimagama esilimintathu. 

=== Kuyini sihlathululimagama esilimilinye na? ===
U-Ali&lt;ref&gt;Ali, H. I. H. (2012). ‘Monolingual Dictionary Use in an EFL Context’. English Language Teaching. 5(7):1-7&lt;/ref&gt; ngomnyaka ka-2012 wahlathulula isihlathululimagama esilimilinye bonyana, isihlathululimagama esilimilinye sihlathululimagama esinehlathululo, amatshwayo nelinye ilwazi lokuhleleka nanyana ilandelano lamagama welimi lomphakathi othize mayelana namagama lawo abudisi ukuzwisiseka kubasebenzisi belimi lelo. Ngamanye amagama isihlathululimagama esilimilinye sihlathululimagama esimumethe ilwazi ngelimi. Okutjho bonyana ihlathululo yegama, amatshwayo namathemu atlolwe ngesiNdebele. 

Kanengi lomhlobo wesihlathulumagama usetjenziswa babantu ilimi lelo ekulilimi lebele nanyana abafunda ilimi lelo njengelimi lokuthoma ekhaya. Nangabe wena awukhulumi ilimi lelo begodu awulifundi esikolweni njengeli lokuthoma lekhaya, ungaba nomraro wokungazwisisi amagama nanyana okutlolwe ngaphakathi kwesihlathululimagama lesi.
Isihlathululimagama lesi siqakatheke kwamambala ekungezeleleni ilwazi lwamagama nethuthuko yelimi lelo (Hadebe 2007&lt;ref&gt;Hadebe, S. (2004). ‘Improving Dictionary Skills in Ndebele’. Lexikos. 14: 89-104.&lt;/ref&gt;). 

=== Kuyini isihlathululimagama esilimimbili na? ===
UKlapicova (2005&lt;ref name=&quot;:0&quot;&gt;Klapicová, E. H. (2005). Stavba hesla v dvojjazyčnom slovníku a jeho parametre. Studi Slavistici. 2(1): 219–235.&lt;/ref&gt;) wahlathulula isihlathululimagama esilimimbili wathi, isihlathululimagama esilimimbili sinerhelo lamagama arhenyiswe ngokulandelana kwamaledere nanyana izitjho ngelimi linye lezo, ngokuqothelwa ezinikelwe amagama nanyana izinto ezinqophe poro ngelinye ilimi. Ngamanye amagama la, kusetjenziswa amalimi amabili, elinye ilimi lilimi elimsuka bese elinye lenziwe ilimi eliqothelweko. Ilimi elimsuka lilimi lelo amagama nanyana amathemu arhenyiswa ngalo. Kodwana, ilimi eliqothelweko lilimi lelo ihlathululo nezinye izitjho zinikelwa nanyana zitlolwe ngalo.  

Nabakhuluma ngokurhenyiswa kwamagama ngamaledere, balinga ukuveza bonyana isihlathululimagama ngiyo yodwa incwadi lapho ungathola khona imitlolo yangaphakathi irhenyiswe ngamaledere. Ezinye iincwadi ziyatlola ngaphandle kokurhemisa amagama ngamaledere.  

Lomhlobo wesihlathululimagama usetjenziswa khulu ngilabo abafuna ukufunda amalimi amabili ngesikhathi esisodwa nanyana abasebenza ngamalimi amabili njengokutjhugulula. Uqakathekile lomhlobo  ngomba utholakala nemikhakheni ekhethekileko. 

=== Kuyini isihlathululimagama esilimintathu? ===
UKlapicova (2005&lt;ref name=&quot;:0&quot; /&gt;) uveza bonyana kukhona ezinye iinhlathululimagama lezo ezisebenzisa amalimi adlula kwamabili emitlolweni yazo ngaphakathi. Okutjho bona umhlobo lo ungasebenzisa isiNdebele, Siswati nesiZulu elwazini langaphakathi. Okwenzekako kukobana kuthathwa ilimi linye lezniwe imili elimsuka bese amanye la enziwe amalimi aqothelweko. Ngamanye amagama lokha amagama nanyana amathemu arhenyiswa ngesindebele, ihlathululo nanyana amathemu onqophileko azokunikelwa ngamalimi amabili la ekumalimi aqothelweko, Sizwati nesiZulu. 

Lomhlobo wesihlathululimagama wenzele boke abantu abafunda nanyana abasebenzisa amalimi amathathu ukukhuluma, ukufunda nokusebenza. Begodu umhlobo utjengisa nezinga lokuthuthuka kwamalimi esetjenzisiweko la. 

Ekulumeni yethu ngehla sikhulume besahlathulula imihlobo emithathu yeenhlathululimagama ezijayelekileko. Isihlathululimagama esilimilinye, esilimimbili nesilimbintathu zitjhejwe ngokungeneleleko. Zoke iihlathululimagama lezi ziqakatheke ngokungafani begodu nemisebenzi yazo ayifani. Kodwana, okukhulu kukobana kufanele zibe khona ukuze ilimi likwazi ukuthuthtuka

=== Umthombolwazi ===
&lt;references /&gt;

</text>
      <sha1>n7muf5df5apryvv9bj7zidcf2iinifp</sha1>
    </revision>
  </page>
  <page>
    <title>Imijondolo</title>
    <ns>0</ns>
    <id>170</id>
    <revision>
      <id>808</id>
      <timestamp>2024-05-09T18:15:37Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Imijondolo''', indawo ye-squatter noma indawo yokuhlala ye-squatter iyindawo yokuhlala yezakhiwo ezithuthukisiwe ezaziwa ngokuthi imijondolo noma imijondolo, ngokuvamile eyakhiwe ngezinto ezifana nodaka nokhuni. Idolobhana eliyimijondolo elijwayelekile linemikhukhu futhi ekuqaleni alinayo ingqalasizinda eyanele, okuhlanganisa ukuthuthwa kwendle okufanele, ukuhlinzekwa kwamanzi aphephile, ugesi kanye nokuthuthwa kwendle emigwaqweni. Ngokuhamba kwesikhathi, amadolobha a...&quot;</comment>
      <origin>808</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="656" sha1="pxsz456qt3wqi5adtrsw7667reiiofs" xml:space="preserve">'''Imijondolo''', indawo ye-squatter noma indawo yokuhlala ye-squatter iyindawo yokuhlala yezakhiwo ezithuthukisiwe ezaziwa ngokuthi imijondolo noma imijondolo, ngokuvamile eyakhiwe ngezinto ezifana nodaka nokhuni. Idolobhana eliyimijondolo elijwayelekile linemikhukhu futhi ekuqaleni alinayo ingqalasizinda eyanele, okuhlanganisa ukuthuthwa kwendle okufanele, ukuhlinzekwa kwamanzi aphephile, ugesi kanye nokuthuthwa kwendle emigwaqweni. Ngokuhamba kwesikhathi, amadolobha anemijondolo angathuthukisa ingqalasizinda yawo futhi ashintshe abe izindawo ezingomakhelwane abasezingeni eliphakathi. Kungaba imijondolo emincane noma kungahlalisa izigidi zabantu.</text>
      <sha1>pxsz456qt3wqi5adtrsw7667reiiofs</sha1>
    </revision>
    <revision>
      <id>809</id>
      <parentid>808</parentid>
      <timestamp>2024-10-14T13:46:49Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>808</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="656" sha1="pxsz456qt3wqi5adtrsw7667reiiofs" xml:space="preserve">'''Imijondolo''', indawo ye-squatter noma indawo yokuhlala ye-squatter iyindawo yokuhlala yezakhiwo ezithuthukisiwe ezaziwa ngokuthi imijondolo noma imijondolo, ngokuvamile eyakhiwe ngezinto ezifana nodaka nokhuni. Idolobhana eliyimijondolo elijwayelekile linemikhukhu futhi ekuqaleni alinayo ingqalasizinda eyanele, okuhlanganisa ukuthuthwa kwendle okufanele, ukuhlinzekwa kwamanzi aphephile, ugesi kanye nokuthuthwa kwendle emigwaqweni. Ngokuhamba kwesikhathi, amadolobha anemijondolo angathuthukisa ingqalasizinda yawo futhi ashintshe abe izindawo ezingomakhelwane abasezingeni eliphakathi. Kungaba imijondolo emincane noma kungahlalisa izigidi zabantu.</text>
      <sha1>pxsz456qt3wqi5adtrsw7667reiiofs</sha1>
    </revision>
  </page>
  <page>
    <title>Imikhombe</title>
    <ns>0</ns>
    <id>171</id>
    <revision>
      <id>810</id>
      <timestamp>2024-06-27T12:39:30Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Imikhombe''' mhlobo weembandana ohlala ehlathini, unephondo ebusweni ngaphezu kwepumulo  &quot;</comment>
      <origin>810</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="92" sha1="pavbyetrojxeobrf5omi6h1vi5pzp0v" xml:space="preserve">'''Imikhombe''' mhlobo weembandana ohlala ehlathini, unephondo ebusweni ngaphezu kwepumulo

</text>
      <sha1>pavbyetrojxeobrf5omi6h1vi5pzp0v</sha1>
    </revision>
    <revision>
      <id>811</id>
      <parentid>810</parentid>
      <timestamp>2024-10-14T13:46:49Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>810</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="92" sha1="pavbyetrojxeobrf5omi6h1vi5pzp0v" xml:space="preserve">'''Imikhombe''' mhlobo weembandana ohlala ehlathini, unephondo ebusweni ngaphezu kwepumulo

</text>
      <sha1>pavbyetrojxeobrf5omi6h1vi5pzp0v</sha1>
    </revision>
  </page>
  <page>
    <title>Imisebenzi ye-Art eyenziwa bomma bamaNdebele</title>
    <ns>0</ns>
    <id>172</id>
    <revision>
      <id>812</id>
      <timestamp>2024-03-22T06:16:40Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Abomma bamaNdebele''' banobukghoni obukhulu kweze-art ngombana bakhona ukwenza imisebenzi yezandla emihle begodu ebukwa liphasi loke. Imisebenzi yezandla abayenzako akusiyo imisebenzi ungenziwa ngunyana ngubani mgombana ifuna itelente begodu nekghono lokusebenzisa izandla ngendlela ethile, begodu ube nekghono lokukhetha imibala uyihlanganise ukwenza amaphetheni. ikghono leli kwezomkhakha wefundo liwela ngaphasi kwe-Arts.  &quot;</comment>
      <origin>812</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="429" sha1="daj76f46q84vfctkc6296g6c2mx8nkt" xml:space="preserve">'''Abomma bamaNdebele''' banobukghoni obukhulu kweze-art ngombana bakhona ukwenza imisebenzi yezandla emihle begodu ebukwa liphasi loke. Imisebenzi yezandla abayenzako akusiyo imisebenzi ungenziwa ngunyana ngubani mgombana ifuna itelente begodu nekghono lokusebenzisa izandla ngendlela ethile, begodu ube nekghono lokukhetha imibala uyihlanganise ukwenza amaphetheni. ikghono leli kwezomkhakha wefundo liwela ngaphasi kwe-Arts.

</text>
      <sha1>daj76f46q84vfctkc6296g6c2mx8nkt</sha1>
    </revision>
    <revision>
      <id>813</id>
      <parentid>812</parentid>
      <timestamp>2024-03-22T06:27:54Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>813</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="938" sha1="r4dcowkgwsnajzfaqewl5rmyqplxn6u" xml:space="preserve">'''Abomma bamaNdebele''' banobukghoni obukhulu kweze-art ngombana bakhona ukwenza imisebenzi yezandla emihle begodu ebukwa liphasi loke. Imisebenzi yezandla abayenzako akusiyo imisebenzi ungenziwa ngunyana ngubani mgombana ifuna itelente begodu nekghono lokusebenzisa izandla ngendlela ethile, begodu ube nekghono lokukhetha imibala uyihlanganise ukwenza amaphetheni. ikghono leli kwezomkhakha wefundo liwela ngaphasi kwe-Arts.

== Ukugwala ==
ukugwala yindlela yokuhlobisa amaboda ngokupenda wenze amaphetheni amahle, ngemibala ehlukahlukeneko. Abomma nabagwalako basenzisa isiba lekukhu khulu khulu. Abomma ekadeni bebenza umsebenzi lo ukuhlobisa imizabo. Esikhathini ukugwala sekuyinto AmaNdebele adume ngayo iphasi loke ngombana sele kungasa gwala izindlu kwaphela kodwana sele kugwalwa nezambatho, imodere nokhunye. Umuntu odume khulu ngokugwala emaNdebeleni ngumma u Esther Mahlangu osele enze imisebenzi eminengi khulu ngokugwala.
</text>
      <sha1>r4dcowkgwsnajzfaqewl5rmyqplxn6u</sha1>
    </revision>
    <revision>
      <id>814</id>
      <parentid>813</parentid>
      <timestamp>2024-03-22T06:37:49Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>814</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1479" sha1="3g6ciu2w8ng62zeaio430mqclgfp781" xml:space="preserve">'''Abomma bamaNdebele''' banobukghoni obukhulu kweze-art ngombana bakhona ukwenza imisebenzi yezandla emihle begodu ebukwa liphasi loke. Imisebenzi yezandla abayenzako akusiyo imisebenzi ungenziwa ngunyana ngubani mgombana ifuna itelente begodu nekghono lokusebenzisa izandla ngendlela ethile, begodu ube nekghono lokukhetha imibala uyihlanganise ukwenza amaphetheni. ikghono leli kwezomkhakha wefundo liwela ngaphasi kwe-Arts.

== Ukugwala ==
ukugwala yindlela yokuhlobisa amaboda ngokupenda wenze amaphetheni amahle, ngemibala ehlukahlukeneko. Abomma nabagwalako basenzisa isiba lekukhu khulu khulu. Abomma ekadeni bebenza umsebenzi lo ukuhlobisa imizabo. Esikhathini ukugwala sekuyinto AmaNdebele adume ngayo iphasi loke ngombana sele kungasa gwala izindlu kwaphela kodwana sele kugwalwa nezambatho, imodere nokhunye. Umuntu odume khulu ngokugwala emaNdebeleni ngumma u Esther Mahlangu osele enze imisebenzi eminengi khulu ngokugwala.

== Ukuluka imiseme ==
Nasikhuluma ngokuluka sikhuluma ngokwenza umseme usebenzisa umcobosi. umcobosi butjani ubuhlaza ubudege ubumila ngemlanjeni. abomma bayakhamba bayokukha utjani lobu nofana bayobuthenga bese benza ngabo imiseme. Lokha nabenza imiseme le basebenzisa amawula ahlukahlukeneko ngemibala, begodu amawula la enza amaphetheni amahle khulu emsemeni. Umseme usetjenziselwa ukuhlala, ukunothisa, kanye nokwakha intende lokha  nakusimanje. Umsebenzi omkhulu womseme singatjho bona kuhlalisa abantu kuhle phasi bangasilaphazeki.  
</text>
      <sha1>3g6ciu2w8ng62zeaio430mqclgfp781</sha1>
    </revision>
    <revision>
      <id>815</id>
      <parentid>814</parentid>
      <timestamp>2024-03-22T07:05:16Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>815</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1999" sha1="c371b4misbwarf3bnilcv87legr27cl" xml:space="preserve">'''Abomma bamaNdebele''' banobukghoni obukhulu kweze-art ngombana bakhona ukwenza imisebenzi yezandla emihle begodu ebukwa liphasi loke. Imisebenzi yezandla abayenzako akusiyo imisebenzi ungenziwa ngunyana ngubani mgombana ifuna itelente begodu nekghono lokusebenzisa izandla ngendlela ethile, begodu ube nekghono lokukhetha imibala uyihlanganise ukwenza amaphetheni. ikghono leli kwezomkhakha wefundo liwela ngaphasi kwe-Arts.

== Ukugwala ==
ukugwala yindlela yokuhlobisa amaboda ngokupenda wenze amaphetheni amahle, ngemibala ehlukahlukeneko. Abomma nabagwalako basenzisa isiba lekukhu khulu khulu. Abomma ekadeni bebenza umsebenzi lo ukuhlobisa imizabo&lt;ref&gt;Van Vuuren, C.J., 2012. Iconic bodies: Ndebele women in ritual context. ''South African Journal of Art History'', ''27''(2), pp.325-347.&lt;/ref&gt;. Esikhathini ukugwala sekuyinto AmaNdebele adume ngayo iphasi loke ngombana sele kungasa gwala izindlu kwaphela kodwana sele kugwalwa nezambatho, imodere nokhunye. Umuntu odume khulu ngokugwala emaNdebeleni ngumma u Esther Mahlangu osele enze imisebenzi eminengi khulu ngokugwala.

== Ukuluka imiseme ==
Nasikhuluma ngokuluka sikhuluma ngokwenza umseme usebenzisa umcobosi. umcobosi butjani ubuhlaza ubudege ubumila ngemlanjeni. abomma bayakhamba bayokukha utjani lobu nofana bayobuthenga bese benza ngabo imiseme. Lokha nabenza imiseme le basebenzisa amawula ahlukahlukeneko ngemibala, begodu amawula la enza amaphetheni amahle khulu emsemeni. Umseme usetjenziselwa ukuhlala, ukunothisa, kanye nokwakha intende lokha  nakusimanje. Umsebenzi omkhulu womseme singatjho bona kuhlalisa abantu kuhle phasi bangasilaphazeki.  

== Ukuphothela umcamo nokunghada iinrholwani ==
Ukuphothela kuluka usebenzisa imicamo ukwenza ivunulo ethileko yesiNdebele enjenge nrholwani, iphephethu, iyerhana nokhunye. Ukuphothela kufuna ikghono lokusenzisa  izandla  begodu ukwazi ngithjo nokuthunga. Ukuphothela nokughada iinrholwane kuyinto eqakathekileko eMaNdebeleni ngombana pheze ivunulo yabo yoke ivela lapho.
</text>
      <sha1>c371b4misbwarf3bnilcv87legr27cl</sha1>
    </revision>
    <revision>
      <id>816</id>
      <parentid>815</parentid>
      <timestamp>2024-03-22T07:06:10Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>816</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2169" sha1="kmdo4ljwi84r9ptxkqia52f053q57go" xml:space="preserve">'''Abomma bamaNdebele''' banobukghoni obukhulu kweze-art ngombana bakhona ukwenza imisebenzi yezandla emihle begodu ebukwa liphasi loke. Imisebenzi yezandla abayenzako akusiyo imisebenzi ungenziwa ngunyana ngubani mgombana ifuna itelente begodu nekghono lokusebenzisa izandla ngendlela ethile, begodu ube nekghono lokukhetha imibala uyihlanganise ukwenza amaphetheni. ikghono leli kwezomkhakha wefundo liwela ngaphasi kwe-Arts.

== Ukugwala ==
ukugwala yindlela yokuhlobisa amaboda ngokupenda wenze amaphetheni amahle, ngemibala ehlukahlukeneko. Abomma nabagwalako basenzisa isiba lekukhu khulu khulu. Abomma ekadeni bebenza umsebenzi lo ukuhlobisa imizabo&lt;ref&gt;Van Vuuren, C.J., 2012. Iconic bodies: Ndebele women in ritual context. ''South African Journal of Art History'', ''27''(2), pp.325-347.&lt;/ref&gt;. Esikhathini ukugwala sekuyinto AmaNdebele adume ngayo iphasi loke ngombana sele kungasa gwala izindlu kwaphela kodwana sele kugwalwa nezambatho, imodere nokhunye. Umuntu odume khulu ngokugwala emaNdebeleni ngumma u Esther Mahlangu osele enze imisebenzi eminengi khulu ngokugwala.

== Ukuluka imiseme ==
Nasikhuluma ngokuluka sikhuluma ngokwenza umseme usebenzisa umcobosi. umcobosi butjani ubuhlaza ubudege ubumila ngemlanjeni. abomma bayakhamba bayokukha utjani lobu nofana bayobuthenga bese benza ngabo imiseme. Lokha nabenza imiseme le basebenzisa amawula ahlukahlukeneko ngemibala, begodu amawula la enza amaphetheni amahle khulu emsemeni. Umseme usetjenziselwa ukuhlala, ukunothisa, kanye nokwakha intende lokha  nakusimanje. Umsebenzi omkhulu womseme singatjho bona kuhlalisa abantu kuhle phasi bangasilaphazeki.  

== Ukuphothela umcamo nokunghada iinrholwani ==
Ukuphothela kuluka usebenzisa imicamo ukwenza ivunulo ethileko yesiNdebele enjenge nrholwani, iphephethu, iyerhana nokhunye&lt;ref&gt;Ndlovu, S., 2020. Material culture in Southern Ndebele identity making in post-apartheid South Africa. ''Anthropology Southern Africa'', ''43''(4), pp.218-232.&lt;/ref&gt;. Ukuphothela kufuna ikghono lokusenzisa  izandla  begodu ukwazi ngithjo nokuthunga. Ukuphothela nokughada iinrholwane kuyinto eqakathekileko eMaNdebeleni ngombana pheze ivunulo yabo yoke ivela lapho.
</text>
      <sha1>kmdo4ljwi84r9ptxkqia52f053q57go</sha1>
    </revision>
    <revision>
      <id>817</id>
      <parentid>816</parentid>
      <timestamp>2024-03-22T07:06:42Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>817</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2173" sha1="s0j8i8io1dxxdknmftwmluucqgq2n34" xml:space="preserve">'''Abomma bamaNdebele''' banobukghoni obukhulu kweze-art ngombana bakhona ukwenza imisebenzi yezandla emihle begodu ebukwa liphasi loke. Imisebenzi yezandla abayenzako akusiyo imisebenzi ungenziwa ngunyana ngubani mgombana ifuna itelente begodu nekghono lokusebenzisa izandla ngendlela ethile, begodu ube nekghono lokukhetha imibala uyihlanganise ukwenza amaphetheni. ikghono leli kwezomkhakha wefundo liwela ngaphasi kwe-Arts.

== Ukugwala ==
[[ukugwala]] yindlela yokuhlobisa amaboda ngokupenda wenze amaphetheni amahle, ngemibala ehlukahlukeneko. Abomma nabagwalako basenzisa isiba lekukhu khulu khulu. Abomma ekadeni bebenza umsebenzi lo ukuhlobisa imizabo&lt;ref&gt;Van Vuuren, C.J., 2012. Iconic bodies: Ndebele women in ritual context. ''South African Journal of Art History'', ''27''(2), pp.325-347.&lt;/ref&gt;. Esikhathini ukugwala sekuyinto AmaNdebele adume ngayo iphasi loke ngombana sele kungasa gwala izindlu kwaphela kodwana sele kugwalwa nezambatho, imodere nokhunye. Umuntu odume khulu ngokugwala emaNdebeleni ngumma u Esther Mahlangu osele enze imisebenzi eminengi khulu ngokugwala.

== Ukuluka imiseme ==
Nasikhuluma ngokuluka sikhuluma ngokwenza umseme usebenzisa umcobosi. umcobosi butjani ubuhlaza ubudege ubumila ngemlanjeni. abomma bayakhamba bayokukha utjani lobu nofana bayobuthenga bese benza ngabo imiseme. Lokha nabenza imiseme le basebenzisa amawula ahlukahlukeneko ngemibala, begodu amawula la enza amaphetheni amahle khulu emsemeni. Umseme usetjenziselwa ukuhlala, ukunothisa, kanye nokwakha intende lokha  nakusimanje. Umsebenzi omkhulu womseme singatjho bona kuhlalisa abantu kuhle phasi bangasilaphazeki.  

== Ukuphothela umcamo nokunghada iinrholwani ==
Ukuphothela kuluka usebenzisa imicamo ukwenza ivunulo ethileko yesiNdebele enjenge nrholwani, iphephethu, iyerhana nokhunye&lt;ref&gt;Ndlovu, S., 2020. Material culture in Southern Ndebele identity making in post-apartheid South Africa. ''Anthropology Southern Africa'', ''43''(4), pp.218-232.&lt;/ref&gt;. Ukuphothela kufuna ikghono lokusenzisa  izandla  begodu ukwazi ngithjo nokuthunga. Ukuphothela nokughada iinrholwane kuyinto eqakathekileko eMaNdebeleni ngombana pheze ivunulo yabo yoke ivela lapho.
</text>
      <sha1>s0j8i8io1dxxdknmftwmluucqgq2n34</sha1>
    </revision>
    <revision>
      <id>818</id>
      <parentid>817</parentid>
      <timestamp>2024-03-22T07:07:19Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>818</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2177" sha1="nxcbvzgegmc80a265t56fo1fd6gu8ku" xml:space="preserve">'''Abomma bamaNdebele''' banobukghoni obukhulu kweze-[[art]] ngombana bakhona ukwenza imisebenzi yezandla emihle begodu ebukwa liphasi loke. Imisebenzi yezandla abayenzako akusiyo imisebenzi ungenziwa ngunyana ngubani mgombana ifuna itelente begodu nekghono lokusebenzisa izandla ngendlela ethile, begodu ube nekghono lokukhetha imibala uyihlanganise ukwenza amaphetheni. ikghono leli kwezomkhakha wefundo liwela ngaphasi kwe-Arts.

== Ukugwala ==
[[ukugwala]] yindlela yokuhlobisa amaboda ngokupenda wenze amaphetheni amahle, ngemibala ehlukahlukeneko. Abomma nabagwalako basenzisa isiba lekukhu khulu khulu. Abomma ekadeni bebenza umsebenzi lo ukuhlobisa imizabo&lt;ref&gt;Van Vuuren, C.J., 2012. Iconic bodies: Ndebele women in ritual context. ''South African Journal of Art History'', ''27''(2), pp.325-347.&lt;/ref&gt;. Esikhathini ukugwala sekuyinto AmaNdebele adume ngayo iphasi loke ngombana sele kungasa gwala izindlu kwaphela kodwana sele kugwalwa nezambatho, imodere nokhunye. Umuntu odume khulu ngokugwala emaNdebeleni ngumma u Esther Mahlangu osele enze imisebenzi eminengi khulu ngokugwala.

== Ukuluka imiseme ==
Nasikhuluma ngokuluka sikhuluma ngokwenza umseme usebenzisa umcobosi. umcobosi butjani ubuhlaza ubudege ubumila ngemlanjeni. abomma bayakhamba bayokukha utjani lobu nofana bayobuthenga bese benza ngabo imiseme. Lokha nabenza imiseme le basebenzisa amawula ahlukahlukeneko ngemibala, begodu amawula la enza amaphetheni amahle khulu emsemeni. Umseme usetjenziselwa ukuhlala, ukunothisa, kanye nokwakha intende lokha  nakusimanje. Umsebenzi omkhulu womseme singatjho bona kuhlalisa abantu kuhle phasi bangasilaphazeki.  

== Ukuphothela umcamo nokunghada iinrholwani ==
Ukuphothela kuluka usebenzisa imicamo ukwenza ivunulo ethileko yesiNdebele enjenge nrholwani, iphephethu, iyerhana nokhunye&lt;ref&gt;Ndlovu, S., 2020. Material culture in Southern Ndebele identity making in post-apartheid South Africa. ''Anthropology Southern Africa'', ''43''(4), pp.218-232.&lt;/ref&gt;. Ukuphothela kufuna ikghono lokusenzisa  izandla  begodu ukwazi ngithjo nokuthunga. Ukuphothela nokughada iinrholwane kuyinto eqakathekileko eMaNdebeleni ngombana pheze ivunulo yabo yoke ivela lapho.
</text>
      <sha1>nxcbvzgegmc80a265t56fo1fd6gu8ku</sha1>
    </revision>
    <revision>
      <id>819</id>
      <parentid>818</parentid>
      <timestamp>2024-04-12T20:04:08Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>819</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2250" sha1="1r7oxtsi5ajvswzq2proq812weusuyp" xml:space="preserve">[[Isimumathi:Ndebele Architecture.jpg|thumb|indlu egwalwe ngesiNdebele]]
'''Abomma bamaNdebele''' banobukghoni obukhulu kweze-[[art]] ngombana bakhona ukwenza imisebenzi yezandla emihle begodu ebukwa liphasi loke. Imisebenzi yezandla abayenzako akusiyo imisebenzi ungenziwa ngunyana ngubani mgombana ifuna itelente begodu nekghono lokusebenzisa izandla ngendlela ethile, begodu ube nekghono lokukhetha imibala uyihlanganise ukwenza amaphetheni. ikghono leli kwezomkhakha wefundo liwela ngaphasi kwe-Arts.

== Ukugwala ==
[[ukugwala]] yindlela yokuhlobisa amaboda ngokupenda wenze amaphetheni amahle, ngemibala ehlukahlukeneko. Abomma nabagwalako basenzisa isiba lekukhu khulu khulu. Abomma ekadeni bebenza umsebenzi lo ukuhlobisa imizabo&lt;ref&gt;Van Vuuren, C.J., 2012. Iconic bodies: Ndebele women in ritual context. ''South African Journal of Art History'', ''27''(2), pp.325-347.&lt;/ref&gt;. Esikhathini ukugwala sekuyinto AmaNdebele adume ngayo iphasi loke ngombana sele kungasa gwala izindlu kwaphela kodwana sele kugwalwa nezambatho, imodere nokhunye. Umuntu odume khulu ngokugwala emaNdebeleni ngumma u Esther Mahlangu osele enze imisebenzi eminengi khulu ngokugwala.

== Ukuluka imiseme ==
Nasikhuluma ngokuluka sikhuluma ngokwenza umseme usebenzisa umcobosi. umcobosi butjani ubuhlaza ubudege ubumila ngemlanjeni. abomma bayakhamba bayokukha utjani lobu nofana bayobuthenga bese benza ngabo imiseme. Lokha nabenza imiseme le basebenzisa amawula ahlukahlukeneko ngemibala, begodu amawula la enza amaphetheni amahle khulu emsemeni. Umseme usetjenziselwa ukuhlala, ukunothisa, kanye nokwakha intende lokha  nakusimanje. Umsebenzi omkhulu womseme singatjho bona kuhlalisa abantu kuhle phasi bangasilaphazeki.  

== Ukuphothela umcamo nokunghada iinrholwani ==
Ukuphothela kuluka usebenzisa imicamo ukwenza ivunulo ethileko yesiNdebele enjenge nrholwani, iphephethu, iyerhana nokhunye&lt;ref&gt;Ndlovu, S., 2020. Material culture in Southern Ndebele identity making in post-apartheid South Africa. ''Anthropology Southern Africa'', ''43''(4), pp.218-232.&lt;/ref&gt;. Ukuphothela kufuna ikghono lokusenzisa  izandla  begodu ukwazi ngithjo nokuthunga. Ukuphothela nokughada iinrholwane kuyinto eqakathekileko eMaNdebeleni ngombana pheze ivunulo yabo yoke ivela lapho.
</text>
      <sha1>1r7oxtsi5ajvswzq2proq812weusuyp</sha1>
    </revision>
    <revision>
      <id>820</id>
      <parentid>819</parentid>
      <timestamp>2024-10-14T13:46:49Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>8 revisions imported</comment>
      <origin>819</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2250" sha1="1r7oxtsi5ajvswzq2proq812weusuyp" xml:space="preserve">[[Isimumathi:Ndebele Architecture.jpg|thumb|indlu egwalwe ngesiNdebele]]
'''Abomma bamaNdebele''' banobukghoni obukhulu kweze-[[art]] ngombana bakhona ukwenza imisebenzi yezandla emihle begodu ebukwa liphasi loke. Imisebenzi yezandla abayenzako akusiyo imisebenzi ungenziwa ngunyana ngubani mgombana ifuna itelente begodu nekghono lokusebenzisa izandla ngendlela ethile, begodu ube nekghono lokukhetha imibala uyihlanganise ukwenza amaphetheni. ikghono leli kwezomkhakha wefundo liwela ngaphasi kwe-Arts.

== Ukugwala ==
[[ukugwala]] yindlela yokuhlobisa amaboda ngokupenda wenze amaphetheni amahle, ngemibala ehlukahlukeneko. Abomma nabagwalako basenzisa isiba lekukhu khulu khulu. Abomma ekadeni bebenza umsebenzi lo ukuhlobisa imizabo&lt;ref&gt;Van Vuuren, C.J., 2012. Iconic bodies: Ndebele women in ritual context. ''South African Journal of Art History'', ''27''(2), pp.325-347.&lt;/ref&gt;. Esikhathini ukugwala sekuyinto AmaNdebele adume ngayo iphasi loke ngombana sele kungasa gwala izindlu kwaphela kodwana sele kugwalwa nezambatho, imodere nokhunye. Umuntu odume khulu ngokugwala emaNdebeleni ngumma u Esther Mahlangu osele enze imisebenzi eminengi khulu ngokugwala.

== Ukuluka imiseme ==
Nasikhuluma ngokuluka sikhuluma ngokwenza umseme usebenzisa umcobosi. umcobosi butjani ubuhlaza ubudege ubumila ngemlanjeni. abomma bayakhamba bayokukha utjani lobu nofana bayobuthenga bese benza ngabo imiseme. Lokha nabenza imiseme le basebenzisa amawula ahlukahlukeneko ngemibala, begodu amawula la enza amaphetheni amahle khulu emsemeni. Umseme usetjenziselwa ukuhlala, ukunothisa, kanye nokwakha intende lokha  nakusimanje. Umsebenzi omkhulu womseme singatjho bona kuhlalisa abantu kuhle phasi bangasilaphazeki.  

== Ukuphothela umcamo nokunghada iinrholwani ==
Ukuphothela kuluka usebenzisa imicamo ukwenza ivunulo ethileko yesiNdebele enjenge nrholwani, iphephethu, iyerhana nokhunye&lt;ref&gt;Ndlovu, S., 2020. Material culture in Southern Ndebele identity making in post-apartheid South Africa. ''Anthropology Southern Africa'', ''43''(4), pp.218-232.&lt;/ref&gt;. Ukuphothela kufuna ikghono lokusenzisa  izandla  begodu ukwazi ngithjo nokuthunga. Ukuphothela nokughada iinrholwane kuyinto eqakathekileko eMaNdebeleni ngombana pheze ivunulo yabo yoke ivela lapho.
</text>
      <sha1>1r7oxtsi5ajvswzq2proq812weusuyp</sha1>
    </revision>
    <revision>
      <id>2123</id>
      <parentid>820</parentid>
      <timestamp>2024-11-25T18:15:36Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* Iinkomba */Reflist</comment>
      <origin>2123</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2277" sha1="ah3yhpp87g4j41pezef9g3ge8tj9lzj" xml:space="preserve">[[Isimumathi:Ndebele Architecture.jpg|thumb|indlu egwalwe ngesiNdebele]]
'''Abomma bamaNdebele''' banobukghoni obukhulu kweze-[[art]] ngombana bakhona ukwenza imisebenzi yezandla emihle begodu ebukwa liphasi loke. Imisebenzi yezandla abayenzako akusiyo imisebenzi ungenziwa ngunyana ngubani mgombana ifuna itelente begodu nekghono lokusebenzisa izandla ngendlela ethile, begodu ube nekghono lokukhetha imibala uyihlanganise ukwenza amaphetheni. ikghono leli kwezomkhakha wefundo liwela ngaphasi kwe-Arts.

== Ukugwala ==
[[ukugwala]] yindlela yokuhlobisa amaboda ngokupenda wenze amaphetheni amahle, ngemibala ehlukahlukeneko. Abomma nabagwalako basenzisa isiba lekukhu khulu khulu. Abomma ekadeni bebenza umsebenzi lo ukuhlobisa imizabo&lt;ref&gt;Van Vuuren, C.J., 2012. Iconic bodies: Ndebele women in ritual context. ''South African Journal of Art History'', ''27''(2), pp.325-347.&lt;/ref&gt;. Esikhathini ukugwala sekuyinto AmaNdebele adume ngayo iphasi loke ngombana sele kungasa gwala izindlu kwaphela kodwana sele kugwalwa nezambatho, imodere nokhunye. Umuntu odume khulu ngokugwala emaNdebeleni ngumma u Esther Mahlangu osele enze imisebenzi eminengi khulu ngokugwala.

== Ukuluka imiseme ==
Nasikhuluma ngokuluka sikhuluma ngokwenza umseme usebenzisa umcobosi. umcobosi butjani ubuhlaza ubudege ubumila ngemlanjeni. abomma bayakhamba bayokukha utjani lobu nofana bayobuthenga bese benza ngabo imiseme. Lokha nabenza imiseme le basebenzisa amawula ahlukahlukeneko ngemibala, begodu amawula la enza amaphetheni amahle khulu emsemeni. Umseme usetjenziselwa ukuhlala, ukunothisa, kanye nokwakha intende lokha  nakusimanje. Umsebenzi omkhulu womseme singatjho bona kuhlalisa abantu kuhle phasi bangasilaphazeki.  

== Ukuphothela umcamo nokunghada iinrholwani ==
Ukuphothela kuluka usebenzisa imicamo ukwenza ivunulo ethileko yesiNdebele enjenge nrholwani, iphephethu, iyerhana nokhunye&lt;ref&gt;Ndlovu, S., 2020. Material culture in Southern Ndebele identity making in post-apartheid South Africa. ''Anthropology Southern Africa'', ''43''(4), pp.218-232.&lt;/ref&gt;. Ukuphothela kufuna ikghono lokusenzisa  izandla  begodu ukwazi ngithjo nokuthunga. Ukuphothela nokughada iinrholwane kuyinto eqakathekileko eMaNdebeleni ngombana pheze ivunulo yabo yoke ivela lapho.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>ah3yhpp87g4j41pezef9g3ge8tj9lzj</sha1>
    </revision>
    <revision>
      <id>2464</id>
      <parentid>2123</parentid>
      <timestamp>2025-02-24T12:07:21Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2464</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2281" sha1="dd46bk771mglvg8afchqufdn9ln1knj" xml:space="preserve">[[Isimumathi:Ndebele Architecture.jpg|thumb|indlu egwalwe ngesiNdebele]]
'''Abomma bamaNdebele''' banobukghoni obukhulu kweze-[[art]] ngombana bakhona ukwenza imisebenzi yezandla emihle begodu ebukwa liphasi loke. Imisebenzi yezandla abayenzako akusiyo imisebenzi ungenziwa ngunyana ngubani mgombana ifuna itelente begodu nekghono lokusebenzisa izandla ngendlela ethile, begodu ube nekghono lokukhetha [[imibala]] uyihlanganise ukwenza amaphetheni. ikghono leli kwezomkhakha wefundo liwela ngaphasi kwe-Arts.

== Ukugwala ==
[[ukugwala]] yindlela yokuhlobisa amaboda ngokupenda wenze amaphetheni amahle, ngemibala ehlukahlukeneko. Abomma nabagwalako basenzisa isiba lekukhu khulu khulu. Abomma ekadeni bebenza umsebenzi lo ukuhlobisa imizabo&lt;ref&gt;Van Vuuren, C.J., 2012. Iconic bodies: Ndebele women in ritual context. ''South African Journal of Art History'', ''27''(2), pp.325-347.&lt;/ref&gt;. Esikhathini ukugwala sekuyinto AmaNdebele adume ngayo iphasi loke ngombana sele kungasa gwala izindlu kwaphela kodwana sele kugwalwa nezambatho, imodere nokhunye. Umuntu odume khulu ngokugwala emaNdebeleni ngumma u Esther Mahlangu osele enze imisebenzi eminengi khulu ngokugwala.

== Ukuluka imiseme ==
Nasikhuluma ngokuluka sikhuluma ngokwenza umseme usebenzisa umcobosi. umcobosi butjani ubuhlaza ubudege ubumila ngemlanjeni. abomma bayakhamba bayokukha utjani lobu nofana bayobuthenga bese benza ngabo imiseme. Lokha nabenza imiseme le basebenzisa amawula ahlukahlukeneko ngemibala, begodu amawula la enza amaphetheni amahle khulu emsemeni. Umseme usetjenziselwa ukuhlala, ukunothisa, kanye nokwakha intende lokha  nakusimanje. Umsebenzi omkhulu womseme singatjho bona kuhlalisa abantu kuhle phasi bangasilaphazeki.  

== Ukuphothela umcamo nokunghada iinrholwani ==
Ukuphothela kuluka usebenzisa imicamo ukwenza ivunulo ethileko yesiNdebele enjenge nrholwani, iphephethu, iyerhana nokhunye&lt;ref&gt;Ndlovu, S., 2020. Material culture in Southern Ndebele identity making in post-apartheid South Africa. ''Anthropology Southern Africa'', ''43''(4), pp.218-232.&lt;/ref&gt;. Ukuphothela kufuna ikghono lokusenzisa  izandla  begodu ukwazi ngithjo nokuthunga. Ukuphothela nokughada iinrholwane kuyinto eqakathekileko eMaNdebeleni ngombana pheze ivunulo yabo yoke ivela lapho.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>dd46bk771mglvg8afchqufdn9ln1knj</sha1>
    </revision>
    <revision>
      <id>2465</id>
      <parentid>2464</parentid>
      <timestamp>2025-02-24T12:11:35Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2465</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2389" sha1="e8dcq4jauv21o8df1wiagouvmqf58wl" xml:space="preserve">[[Isimumathi:Ndebele Architecture.jpg|thumb|indlu egwalwe ngesiNdebele]]
'''Abomma bamaNdebele''' banobukghoni obukhulu kweze-[[art]] ngombana bakhona ukwenza imisebenzi yezandla emihle begodu ebukwa liphasi loke. Imisebenzi yezandla abayenzako akusiyo imisebenzi ungenziwa ngunyana ngubani mgombana ifuna itelente begodu nekghono lokusebenzisa izandla ngendlela ethile, begodu ube nekghono lokukhetha [[imibala]] uyihlanganise ukwenza amaphetheni. ikghono leli kwezomkhakha wefundo liwela ngaphasi kwe-Arts.

== Ukugwala ==
[[ukugwala]] yindlela yokuhlobisa amaboda ngokupenda wenze amaphetheni amahle, ngemibala ehlukahlukeneko. Abomma nabagwalako basenzisa isiba lekukhu khulu khulu. Abomma ekadeni bebenza umsebenzi lo ukuhlobisa imizabo&lt;ref&gt;Van Vuuren, C.J., 2012. Iconic bodies: Ndebele women in ritual context. ''South African Journal of Art History'', ''27''(2), pp.325-347.&lt;/ref&gt;. Esikhathini ukugwala sekuyinto AmaNdebele adume ngayo iphasi loke ngombana sele kungasa gwala izindlu kwaphela kodwana sele kugwalwa nezambatho, imodere nokhunye. Umuntu odume khulu ngokugwala emaNdebeleni ngumma u Esther Mahlangu osele enze imisebenzi eminengi khulu ngokugwala.

== Ukuluka imiseme ==
Nasikhuluma ngokuluka sikhuluma ngokwenza umseme usebenzisa umcobosi. umcobosi butjani ubuhlaza ubudege ubumila ngemlanjeni. Abomma bayakhamba bayokukha utjani lobu nofana bayobuthenga bese benza ngabo imiseme. Umseme bawuluka ngokuthi bawubeke phezu kweplanka elithileko lokwenza umseme. Lokha nabenza imiseme le basebenzisa amawula ahlukahlukeneko ngemibala, begodu amawula la enza amaphetheni amahle khulu emsemeni. Umseme usetjenziselwa ukuhlala, ukunothisa, kanye nokwakha intende lokha  nakusimanje. Umsebenzi omkhulu womseme singatjho bona kuhlalisa abantu kuhle phasi bangasilaphazeki. Elinye igama lomseme mjadeko.  

== Ukuphothela umcamo nokunghada iinrholwani ==
Ukuphothela kuluka usebenzisa imicamo ukwenza ivunulo ethileko yesiNdebele enjenge nrholwani, iphephethu, iyerhana nokhunye&lt;ref&gt;Ndlovu, S., 2020. Material culture in Southern Ndebele identity making in post-apartheid South Africa. ''Anthropology Southern Africa'', ''43''(4), pp.218-232.&lt;/ref&gt;. Ukuphothela kufuna ikghono lokusenzisa  izandla  begodu ukwazi ngithjo nokuthunga. Ukuphothela nokughada iinrholwane kuyinto eqakathekileko eMaNdebeleni ngombana pheze ivunulo yabo yoke ivela lapho.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>e8dcq4jauv21o8df1wiagouvmqf58wl</sha1>
    </revision>
    <revision>
      <id>5048</id>
      <parentid>2465</parentid>
      <timestamp>2025-08-07T08:06:52Z</timestamp>
      <contributor>
        <username>Martin Urbanec</username>
        <id>803</id>
      </contributor>
      <minor />
      <comment>added [[Category:Abadwebi]] using [[Help:Gadget-HotCat|HotCat]]</comment>
      <origin>5048</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2411" sha1="3snvvfsodplrgijqyqa0nndl3mhwobt" xml:space="preserve">[[Isimumathi:Ndebele Architecture.jpg|thumb|indlu egwalwe ngesiNdebele]]
'''Abomma bamaNdebele''' banobukghoni obukhulu kweze-[[art]] ngombana bakhona ukwenza imisebenzi yezandla emihle begodu ebukwa liphasi loke. Imisebenzi yezandla abayenzako akusiyo imisebenzi ungenziwa ngunyana ngubani mgombana ifuna itelente begodu nekghono lokusebenzisa izandla ngendlela ethile, begodu ube nekghono lokukhetha [[imibala]] uyihlanganise ukwenza amaphetheni. ikghono leli kwezomkhakha wefundo liwela ngaphasi kwe-Arts.

== Ukugwala ==
[[ukugwala]] yindlela yokuhlobisa amaboda ngokupenda wenze amaphetheni amahle, ngemibala ehlukahlukeneko. Abomma nabagwalako basenzisa isiba lekukhu khulu khulu. Abomma ekadeni bebenza umsebenzi lo ukuhlobisa imizabo&lt;ref&gt;Van Vuuren, C.J., 2012. Iconic bodies: Ndebele women in ritual context. ''South African Journal of Art History'', ''27''(2), pp.325-347.&lt;/ref&gt;. Esikhathini ukugwala sekuyinto AmaNdebele adume ngayo iphasi loke ngombana sele kungasa gwala izindlu kwaphela kodwana sele kugwalwa nezambatho, imodere nokhunye. Umuntu odume khulu ngokugwala emaNdebeleni ngumma u Esther Mahlangu osele enze imisebenzi eminengi khulu ngokugwala.

== Ukuluka imiseme ==
Nasikhuluma ngokuluka sikhuluma ngokwenza umseme usebenzisa umcobosi. umcobosi butjani ubuhlaza ubudege ubumila ngemlanjeni. Abomma bayakhamba bayokukha utjani lobu nofana bayobuthenga bese benza ngabo imiseme. Umseme bawuluka ngokuthi bawubeke phezu kweplanka elithileko lokwenza umseme. Lokha nabenza imiseme le basebenzisa amawula ahlukahlukeneko ngemibala, begodu amawula la enza amaphetheni amahle khulu emsemeni. Umseme usetjenziselwa ukuhlala, ukunothisa, kanye nokwakha intende lokha  nakusimanje. Umsebenzi omkhulu womseme singatjho bona kuhlalisa abantu kuhle phasi bangasilaphazeki. Elinye igama lomseme mjadeko.  

== Ukuphothela umcamo nokunghada iinrholwani ==
Ukuphothela kuluka usebenzisa imicamo ukwenza ivunulo ethileko yesiNdebele enjenge nrholwani, iphephethu, iyerhana nokhunye&lt;ref&gt;Ndlovu, S., 2020. Material culture in Southern Ndebele identity making in post-apartheid South Africa. ''Anthropology Southern Africa'', ''43''(4), pp.218-232.&lt;/ref&gt;. Ukuphothela kufuna ikghono lokusenzisa  izandla  begodu ukwazi ngithjo nokuthunga. Ukuphothela nokughada iinrholwane kuyinto eqakathekileko eMaNdebeleni ngombana pheze ivunulo yabo yoke ivela lapho.

== Iinkomba ==
{{Reflist}}

[[Mkhakha:Abadwebi]]</text>
      <sha1>3snvvfsodplrgijqyqa0nndl3mhwobt</sha1>
    </revision>
    <revision>
      <id>5049</id>
      <parentid>5048</parentid>
      <timestamp>2025-08-07T08:06:57Z</timestamp>
      <contributor>
        <username>Martin Urbanec</username>
        <id>803</id>
      </contributor>
      <minor />
      <comment>removed [[Category:Abadwebi]] using [[Help:Gadget-HotCat|HotCat]]</comment>
      <origin>5049</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2389" sha1="e8dcq4jauv21o8df1wiagouvmqf58wl" xml:space="preserve">[[Isimumathi:Ndebele Architecture.jpg|thumb|indlu egwalwe ngesiNdebele]]
'''Abomma bamaNdebele''' banobukghoni obukhulu kweze-[[art]] ngombana bakhona ukwenza imisebenzi yezandla emihle begodu ebukwa liphasi loke. Imisebenzi yezandla abayenzako akusiyo imisebenzi ungenziwa ngunyana ngubani mgombana ifuna itelente begodu nekghono lokusebenzisa izandla ngendlela ethile, begodu ube nekghono lokukhetha [[imibala]] uyihlanganise ukwenza amaphetheni. ikghono leli kwezomkhakha wefundo liwela ngaphasi kwe-Arts.

== Ukugwala ==
[[ukugwala]] yindlela yokuhlobisa amaboda ngokupenda wenze amaphetheni amahle, ngemibala ehlukahlukeneko. Abomma nabagwalako basenzisa isiba lekukhu khulu khulu. Abomma ekadeni bebenza umsebenzi lo ukuhlobisa imizabo&lt;ref&gt;Van Vuuren, C.J., 2012. Iconic bodies: Ndebele women in ritual context. ''South African Journal of Art History'', ''27''(2), pp.325-347.&lt;/ref&gt;. Esikhathini ukugwala sekuyinto AmaNdebele adume ngayo iphasi loke ngombana sele kungasa gwala izindlu kwaphela kodwana sele kugwalwa nezambatho, imodere nokhunye. Umuntu odume khulu ngokugwala emaNdebeleni ngumma u Esther Mahlangu osele enze imisebenzi eminengi khulu ngokugwala.

== Ukuluka imiseme ==
Nasikhuluma ngokuluka sikhuluma ngokwenza umseme usebenzisa umcobosi. umcobosi butjani ubuhlaza ubudege ubumila ngemlanjeni. Abomma bayakhamba bayokukha utjani lobu nofana bayobuthenga bese benza ngabo imiseme. Umseme bawuluka ngokuthi bawubeke phezu kweplanka elithileko lokwenza umseme. Lokha nabenza imiseme le basebenzisa amawula ahlukahlukeneko ngemibala, begodu amawula la enza amaphetheni amahle khulu emsemeni. Umseme usetjenziselwa ukuhlala, ukunothisa, kanye nokwakha intende lokha  nakusimanje. Umsebenzi omkhulu womseme singatjho bona kuhlalisa abantu kuhle phasi bangasilaphazeki. Elinye igama lomseme mjadeko.  

== Ukuphothela umcamo nokunghada iinrholwani ==
Ukuphothela kuluka usebenzisa imicamo ukwenza ivunulo ethileko yesiNdebele enjenge nrholwani, iphephethu, iyerhana nokhunye&lt;ref&gt;Ndlovu, S., 2020. Material culture in Southern Ndebele identity making in post-apartheid South Africa. ''Anthropology Southern Africa'', ''43''(4), pp.218-232.&lt;/ref&gt;. Ukuphothela kufuna ikghono lokusenzisa  izandla  begodu ukwazi ngithjo nokuthunga. Ukuphothela nokughada iinrholwane kuyinto eqakathekileko eMaNdebeleni ngombana pheze ivunulo yabo yoke ivela lapho.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>e8dcq4jauv21o8df1wiagouvmqf58wl</sha1>
    </revision>
  </page>
  <page>
    <title>Imithetho yokutlola nokupeleda</title>
    <ns>0</ns>
    <id>173</id>
    <revision>
      <id>821</id>
      <timestamp>2024-07-21T10:09:11Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;== Imithetho yokutlola nokupeleda == Ngokuya kukaZulu, uBotha no-Barnard (2008:188) imithetho yokutlola nokupeleda kulibuthelelo lamatshwayo lawo asetjenziswa ekultolweni kwelimi begodu afaka hlangana indlela yokutlola nokupeleda kwelimi lelo. Ngamanye amagama singatjho bonyana imithetho yokutlola nokupeleda kumhlahlandlela loyo ohlahla abasebenzisi belimi elithe bonyana litlolwa njani begodu amatjhada abanawo ngimaphi.   U-Albert (2013) usekele uZulu nabanye (2008) lokh...&quot;</comment>
      <origin>821</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1917" sha1="c7bwy65nmrf1yitsptkyaiul17aeb6l" xml:space="preserve">== Imithetho yokutlola nokupeleda ==
Ngokuya kukaZulu, uBotha no-Barnard (2008:188) imithetho yokutlola nokupeleda kulibuthelelo lamatshwayo lawo asetjenziswa ekultolweni kwelimi begodu afaka hlangana indlela yokutlola nokupeleda kwelimi lelo. Ngamanye amagama singatjho bonyana imithetho yokutlola nokupeleda kumhlahlandlela loyo ohlahla abasebenzisi belimi elithe bonyana litlolwa njani begodu amatjhada abanawo ngimaphi. 

U-Albert (2013) usekele uZulu nabanye (2008) lokha nakaveza bonyana imithetho yokutlola nokupeleda uvumela amalimi bonyana anzinzise amalimi wabo ngokuthi aqinisekise bonyana kuba nokutlolwa nokupeledwa kwelimi lelo ngokufakano. Ukungezelela, imithetho yokutlola nokupelelda yenza isiqiniseko sokobana abasebenzisi belimi balisebenzisa ngokufana ilimi lelo. 

U-Albert (2013) uragele phambili wathi, imithetho yokutlola nokupeleda ayisizi kwaphela ekwenzeni isiqiniseko sokuthi ilimi lisetjenziswa ngokufanako, kodwana isiza nemisebenzi yelimi kanye nokuthintaneni. Lokhu kutjho bonyana imithetho yokutlola nokupeleda ayisimhlahlandlela kwaphela kodwana kulithulusi lokuthuthukisa ilimi. 

Imithetho yokutlola nokupelela le iqakathekile bonyana ngaso soke isikhathi ibuyekezwe ukuze ikhambisane nokuthuthuka kanye netjhuguluko lelimi. Siyazi bonyana ilimi alikajami ndawonye, liyathuthuka begodu liyatjhuguluka isikhathi nasikhambako. 

Imithetho yokutlola nokupeledwa le kufanele isekelwe  nangamarhubhululo ukuze nakuthathwa iinqunto, kuthathwe iinqunto ezizwakalako. Ngaphandle kwemithetho yokutlola nokupeleda, abantu angeze bazwana mayelana nelimi, kungakho sitjho bona iqakathekile.’

=== Umthombolwazi ===
Zulu, P. N., Botha, G., and Barnard, E. 2008. Orthographic measures of language distances between the official South African languages. Literator, 29(1):185-204.

Alberts, M. 2013. The Afrikaans Orthographic Rules as Guide for Other South African Languages. Lexikos, 23:1-28

</text>
      <sha1>c7bwy65nmrf1yitsptkyaiul17aeb6l</sha1>
    </revision>
    <revision>
      <id>822</id>
      <parentid>821</parentid>
      <timestamp>2024-10-14T13:46:50Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>821</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1917" sha1="c7bwy65nmrf1yitsptkyaiul17aeb6l" xml:space="preserve">== Imithetho yokutlola nokupeleda ==
Ngokuya kukaZulu, uBotha no-Barnard (2008:188) imithetho yokutlola nokupeleda kulibuthelelo lamatshwayo lawo asetjenziswa ekultolweni kwelimi begodu afaka hlangana indlela yokutlola nokupeleda kwelimi lelo. Ngamanye amagama singatjho bonyana imithetho yokutlola nokupeleda kumhlahlandlela loyo ohlahla abasebenzisi belimi elithe bonyana litlolwa njani begodu amatjhada abanawo ngimaphi. 

U-Albert (2013) usekele uZulu nabanye (2008) lokha nakaveza bonyana imithetho yokutlola nokupeleda uvumela amalimi bonyana anzinzise amalimi wabo ngokuthi aqinisekise bonyana kuba nokutlolwa nokupeledwa kwelimi lelo ngokufakano. Ukungezelela, imithetho yokutlola nokupelelda yenza isiqiniseko sokobana abasebenzisi belimi balisebenzisa ngokufana ilimi lelo. 

U-Albert (2013) uragele phambili wathi, imithetho yokutlola nokupeleda ayisizi kwaphela ekwenzeni isiqiniseko sokuthi ilimi lisetjenziswa ngokufanako, kodwana isiza nemisebenzi yelimi kanye nokuthintaneni. Lokhu kutjho bonyana imithetho yokutlola nokupeleda ayisimhlahlandlela kwaphela kodwana kulithulusi lokuthuthukisa ilimi. 

Imithetho yokutlola nokupelela le iqakathekile bonyana ngaso soke isikhathi ibuyekezwe ukuze ikhambisane nokuthuthuka kanye netjhuguluko lelimi. Siyazi bonyana ilimi alikajami ndawonye, liyathuthuka begodu liyatjhuguluka isikhathi nasikhambako. 

Imithetho yokutlola nokupeledwa le kufanele isekelwe  nangamarhubhululo ukuze nakuthathwa iinqunto, kuthathwe iinqunto ezizwakalako. Ngaphandle kwemithetho yokutlola nokupeleda, abantu angeze bazwana mayelana nelimi, kungakho sitjho bona iqakathekile.’

=== Umthombolwazi ===
Zulu, P. N., Botha, G., and Barnard, E. 2008. Orthographic measures of language distances between the official South African languages. Literator, 29(1):185-204.

Alberts, M. 2013. The Afrikaans Orthographic Rules as Guide for Other South African Languages. Lexikos, 23:1-28

</text>
      <sha1>c7bwy65nmrf1yitsptkyaiul17aeb6l</sha1>
    </revision>
  </page>
  <page>
    <title>Impalapala</title>
    <ns>0</ns>
    <id>174</id>
    <revision>
      <id>823</id>
      <timestamp>2024-07-08T08:50:34Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Impalapala''' liphondo elifana ne vuvuzela. lisetjenziswa bomaNdebele ukwenza umdumo lokha nabavumako nanyana nabagida u1. u1 libizo lemgido ogidwa bomma bamaNdebele abatjhadileko. impalapala le iyagwalwa ibe yihle.  &quot;</comment>
      <origin>823</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="220" sha1="prnkmrn9j012cx5k8ffsf01td13iyyh" xml:space="preserve">'''Impalapala''' liphondo elifana ne vuvuzela. lisetjenziswa bomaNdebele ukwenza umdumo lokha nabavumako nanyana nabagida u1. u1 libizo lemgido ogidwa bomma bamaNdebele abatjhadileko. impalapala le iyagwalwa ibe yihle.

</text>
      <sha1>prnkmrn9j012cx5k8ffsf01td13iyyh</sha1>
    </revision>
    <revision>
      <id>824</id>
      <parentid>823</parentid>
      <timestamp>2024-07-08T08:51:39Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>824</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="298" sha1="2l88r8z1a1claj30jkmbwoiakx8oiu2" xml:space="preserve">[[Isimumathi:Mapoch.-musiciennes Ndebele.jpg|thumb|umma ovuthela impalapala]]
'''Impalapala''' liphondo elifana ne vuvuzela. lisetjenziswa bomaNdebele ukwenza umdumo lokha nabavumako nanyana nabagida u1. u1 libizo lemgido ogidwa bomma bamaNdebele abatjhadileko. impalapala le iyagwalwa ibe yihle.

</text>
      <sha1>2l88r8z1a1claj30jkmbwoiakx8oiu2</sha1>
    </revision>
    <revision>
      <id>825</id>
      <parentid>824</parentid>
      <timestamp>2024-07-10T09:26:42Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>825</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="591" sha1="ikavugws2k7bmem41xexxr8xz3xaicl" xml:space="preserve">[[Isimumathi:Mapoch.-musiciennes Ndebele.jpg|thumb|umma ovuthela impalapala]]
'''Impalapala''' liphondo elifana ne vuvuzela. lisetjenziswa bomaNdebele ukwenza umdumo lokha nabavumako nanyana nabagida u1. u1 libizo lemgido ogidwa bomma bamaNdebele abatjhadileko. impalapala le iyagwalwa ibe yihle. impalapala ejwayelekileko ifana ne phayiphu elidege kodwana ayibi yide khulu. Ubude bayo bungalingana nebezandla ezimbili nazihlanganisiweko. Ukubetha impalapala kudinga binyana ube nomoya ommnengi  kube ukhona ukupha umdumo olindelekileko. Ukusingunoma ngubani ongakhona ukubetha impalapala.

</text>
      <sha1>ikavugws2k7bmem41xexxr8xz3xaicl</sha1>
    </revision>
    <revision>
      <id>826</id>
      <parentid>825</parentid>
      <timestamp>2024-10-14T13:46:50Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>825</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="591" sha1="ikavugws2k7bmem41xexxr8xz3xaicl" xml:space="preserve">[[Isimumathi:Mapoch.-musiciennes Ndebele.jpg|thumb|umma ovuthela impalapala]]
'''Impalapala''' liphondo elifana ne vuvuzela. lisetjenziswa bomaNdebele ukwenza umdumo lokha nabavumako nanyana nabagida u1. u1 libizo lemgido ogidwa bomma bamaNdebele abatjhadileko. impalapala le iyagwalwa ibe yihle. impalapala ejwayelekileko ifana ne phayiphu elidege kodwana ayibi yide khulu. Ubude bayo bungalingana nebezandla ezimbili nazihlanganisiweko. Ukubetha impalapala kudinga binyana ube nomoya ommnengi  kube ukhona ukupha umdumo olindelekileko. Ukusingunoma ngubani ongakhona ukubetha impalapala.

</text>
      <sha1>ikavugws2k7bmem41xexxr8xz3xaicl</sha1>
    </revision>
    <revision>
      <id>2436</id>
      <parentid>826</parentid>
      <timestamp>2025-02-19T15:56:21Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2436</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="688" sha1="8e61372johaloqw56ey2ewzh8x8h9p8" xml:space="preserve">[[Isimumathi:Mapoch.-musiciennes Ndebele.jpg|thumb|umma ovuthela impalapala]]
'''Impalapala''' liphondo elifana ne vuvuzela. lisetjenziswa bomaNdebele ukwenza umdumo lokha nabavumako nanyana nabagida u1. u1 libizo lemgido ogidwa bomma bamaNdebele abatjhadileko. impalapala le iyagwalwa ibe yihle. impalapala ejwayelekileko ifana ne phayiphu elidege kodwana ayibi yide khulu. Ubude bayo bungalingana nebezandla ezimbili nazihlanganisiweko. Ukubetha impalapala kudinga bonyana ube nomoya omnengi  ukuze uzokghona ukukhupha umdumo olindelekileko. Akusingunoma ngubani ongakhona ukubetha impalapala ngombana kufuze bona loyo oyibethako abe nelwazi lokuthi umdumo okhitjhwako kufuze ube njani.</text>
      <sha1>8e61372johaloqw56ey2ewzh8x8h9p8</sha1>
    </revision>
  </page>
  <page>
    <title>Indakamizwa</title>
    <ns>0</ns>
    <id>175</id>
    <revision>
      <id>827</id>
      <timestamp>2024-03-08T13:28:42Z</timestamp>
      <contributor>
        <username>incubator&gt;Siphesihle Chantel46</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Indakamizwa''' zinsetjenziswa eziberegisa babantu bona zibadakwe imizwa. Sinemihlobo emibili yendakamizwa, indakamizwa ezisemthethweni kanye nendakamizwa ezingekho emthethweni. Indakamizwa ezisemthethweni ngilezi ezivumelekile bona singasetjenziswa babantu. Isib. Ama antibiotics, grandpa, panado ama ARV's namanye amanengi. Indakamizwa ezingekho emthethweni kufaka hlangana iHeroine, iNyaope, iTik, isango kanye namanye amanengi.&quot;</comment>
      <origin>827</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="433" sha1="k17tjxah3rnpzf9jlkryr5kjgacmnp3" xml:space="preserve">'''Indakamizwa''' zinsetjenziswa eziberegisa babantu bona zibadakwe imizwa. Sinemihlobo emibili yendakamizwa, indakamizwa ezisemthethweni kanye nendakamizwa ezingekho emthethweni. Indakamizwa ezisemthethweni ngilezi ezivumelekile bona singasetjenziswa babantu. Isib. Ama antibiotics, grandpa, panado ama ARV's namanye amanengi. Indakamizwa ezingekho emthethweni kufaka hlangana iHeroine, iNyaope, iTik, isango kanye namanye amanengi.</text>
      <sha1>k17tjxah3rnpzf9jlkryr5kjgacmnp3</sha1>
    </revision>
    <revision>
      <id>828</id>
      <parentid>827</parentid>
      <timestamp>2024-03-08T13:50:15Z</timestamp>
      <contributor>
        <username>incubator&gt;Siphesihle Chantel46</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>828</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="516" sha1="r1zjvevzlar3iqx7lsf5fg241v02by6" xml:space="preserve">== Indakamizwa ==
'''Indakamizwa''' zinsetjenziswa eziberegisa babantu bona zibadakwe imizwa. Sinemihlobo emibili yendakamizwa, indakamizwa ezisemthethweni kanye nendakamizwa ezingekho emthethweni. Indakamizwa ezisemthethweni ngilezi ezivumelekile bona singasetjenziswa babantu. Isib. Ama antibiotics, grandpa, panado ama ARV's namanye amanengi. Indakamizwa ezingekho emthethweni kufaka hlangana iHeroine, iNyaope, iTik, isango kanye namanye amanengi.https://www.health.gov.au/topics/drugs/about-drugs/types-of-drugs</text>
      <sha1>r1zjvevzlar3iqx7lsf5fg241v02by6</sha1>
    </revision>
    <revision>
      <id>829</id>
      <parentid>828</parentid>
      <timestamp>2024-03-09T08:19:12Z</timestamp>
      <contributor>
        <username>incubator&gt;Lethabo19</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Added a picture</comment>
      <origin>829</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="573" sha1="b7ecmvs2ywfoe6bpkg6at6b699iva5t" xml:space="preserve">[[Isimumathi:Psychoactive Drugs.jpg|thumb|Indakamizwa]]

== Indakamizwa ==
'''Indakamizwa''' zinsetjenziswa eziberegisa babantu bona zibadakwe imizwa. Sinemihlobo emibili yendakamizwa, indakamizwa ezisemthethweni kanye nendakamizwa ezingekho emthethweni. Indakamizwa ezisemthethweni ngilezi ezivumelekile bona singasetjenziswa babantu. Isib. Ama antibiotics, grandpa, panado ama ARV's namanye amanengi. Indakamizwa ezingekho emthethweni kufaka hlangana iHeroine, iNyaope, iTik, isango kanye namanye amanengi.https://www.health.gov.au/topics/drugs/about-drugs/types-of-drugs</text>
      <sha1>b7ecmvs2ywfoe6bpkg6at6b699iva5t</sha1>
    </revision>
    <revision>
      <id>830</id>
      <parentid>829</parentid>
      <timestamp>2024-03-09T08:25:27Z</timestamp>
      <contributor>
        <username>incubator&gt;Napangela</username>
        <id>0</id>
      </contributor>
      <origin>830</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="575" sha1="q8dfrzxlff8vq642yf8ul3tpfd4oep9" xml:space="preserve">[[Isimumathi:Psychoactive Drugs.jpg|thumb|Indakamizwa]]

== Indakamizwa ==
'''Indakamizwa''' zinsetjenziswa eziberegisa babantu bona zibadakwe imizwa. Sinemihlobo emibili yendakamizwa, indakamizwa ezisemthethweni kanye nendakamizwa ezingekho emthethweni. Indakamizwa ezisemthethweni ngilezi ezivumelekile bona singasetjenziswa babantu. Isib. Ama antibiotics, grandpa, panado ama ARV's namanye amanengi. Indakamizwa ezingekho emthethweni kufaka hlangana iHeroine, iNyaope, iTik, isango kanye namanye amanengi.https://www.health.gov.au/topics/drugs/about-drugs/types-of-drugs

</text>
      <sha1>q8dfrzxlff8vq642yf8ul3tpfd4oep9</sha1>
    </revision>
    <revision>
      <id>831</id>
      <parentid>830</parentid>
      <timestamp>2024-03-09T08:27:10Z</timestamp>
      <contributor>
        <username>incubator&gt;Napangela</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>831</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="580" sha1="7z5uzgw4ktbvtgpv6vobsl3j0qwnen7" xml:space="preserve">[[Isimumathi:Psychoactive Drugs.jpg|thumb|Indakamizwa]]

== Indakamizwa ==
'''Indakamizwa''' zinsetjenziswa eziberegisa babantu bona zibadakwe imizwa. Sinemihlobo emibili yendakamizwa, indakamizwa ezisemthethweni kanye nendakamizwa ezingekho emthethweni. Indakamizwa ezisemthethweni ngilezi ezivumelekile bona singasetjenziswa babantu. Isib. Ama antibiotics, grandpa, panado ama [[-ARV's]]  amanye amanengi. Indakamizwa ezingekho emthethweni kufaka hlangana iHeroine, iNyaope, iTik, isango kanye namanye amanengi.https://www.health.gov.au/topics/drugs/about-drugs/types-of-drugs

</text>
      <sha1>7z5uzgw4ktbvtgpv6vobsl3j0qwnen7</sha1>
    </revision>
    <revision>
      <id>832</id>
      <parentid>831</parentid>
      <timestamp>2024-05-10T07:48:18Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>832</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1393" sha1="enxas7itb0rvcj74tnt2fxwwbiy7o0d" xml:space="preserve">[[Isimumathi:Psychoactive Drugs.jpg|thumb|Iindakamizwa]]

== '''Iindakamizwa''' ==
'''Iindakamizwa''' zinsetjenziswa nanyana izinto ezidakwa imikhumbulo nomzimba womuntu. Iindakamizwa lezi zihlukaniswe ngemihlobo embili. 

Kukhona iindakamizwa ezimitjhoga lezo ezisetjenziswa ukupholisa abantu. Lezi ziindakamizwa ozithola kibodorhodere nanyana ezifuna incwadi yemvumo kobana ekhemisi bakuthengisele. 

Iindakamizwa zomhlobo wesibili, ngilezo abantu abazisebenzisako ezingakalungeli umzimba. Esikhathini esinengi wazisebenzisa butjhilweni, zigcina zikumotjha umzimba nepilo yakho. Abantu abasebenzisa iindakamizwa lezi esikhathi esinengi bayagula begodu abakghoni ukuziyekela. Abanye baphila ngazo bebahlongakale. 

Iindakamizwa lezi zomhlobo wesibili, kanengi azikho emthethweni begodu nabantu abazisebenzisako bazisebenzisa ngongasimthetho. Kukhona iindakamizwa ezaziwa ngama-mandras, inyawupe, newunga.https://www.health.gov.au/topics/drugs/about-drugs/types-of-drugs

Ibange lona ngakelinye ihlangothi lingasetjenziswa ngokomthetho ngokulandela umthetho kanye neenlwayelo zakadorhodere. Kodwana, kukhona abalibhemako nalabo abalithengisako. Lokha nawulibhema nanyana ulithengisa ngendlela engekho emthethweni ungabotjhwa. 

Kuqakathekile bonyana abantu bazi ngemihlobo yeendamakizwa kanye nemisebenzi yazi ukuze bazokwazi ukubalekela lezo eziyingozi nalezo ezisetjenziswa ngongasimthetho

</text>
      <sha1>enxas7itb0rvcj74tnt2fxwwbiy7o0d</sha1>
    </revision>
    <revision>
      <id>833</id>
      <parentid>832</parentid>
      <timestamp>2024-10-14T13:46:50Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>6 revisions imported</comment>
      <origin>832</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1393" sha1="enxas7itb0rvcj74tnt2fxwwbiy7o0d" xml:space="preserve">[[Isimumathi:Psychoactive Drugs.jpg|thumb|Iindakamizwa]]

== '''Iindakamizwa''' ==
'''Iindakamizwa''' zinsetjenziswa nanyana izinto ezidakwa imikhumbulo nomzimba womuntu. Iindakamizwa lezi zihlukaniswe ngemihlobo embili. 

Kukhona iindakamizwa ezimitjhoga lezo ezisetjenziswa ukupholisa abantu. Lezi ziindakamizwa ozithola kibodorhodere nanyana ezifuna incwadi yemvumo kobana ekhemisi bakuthengisele. 

Iindakamizwa zomhlobo wesibili, ngilezo abantu abazisebenzisako ezingakalungeli umzimba. Esikhathini esinengi wazisebenzisa butjhilweni, zigcina zikumotjha umzimba nepilo yakho. Abantu abasebenzisa iindakamizwa lezi esikhathi esinengi bayagula begodu abakghoni ukuziyekela. Abanye baphila ngazo bebahlongakale. 

Iindakamizwa lezi zomhlobo wesibili, kanengi azikho emthethweni begodu nabantu abazisebenzisako bazisebenzisa ngongasimthetho. Kukhona iindakamizwa ezaziwa ngama-mandras, inyawupe, newunga.https://www.health.gov.au/topics/drugs/about-drugs/types-of-drugs

Ibange lona ngakelinye ihlangothi lingasetjenziswa ngokomthetho ngokulandela umthetho kanye neenlwayelo zakadorhodere. Kodwana, kukhona abalibhemako nalabo abalithengisako. Lokha nawulibhema nanyana ulithengisa ngendlela engekho emthethweni ungabotjhwa. 

Kuqakathekile bonyana abantu bazi ngemihlobo yeendamakizwa kanye nemisebenzi yazi ukuze bazokwazi ukubalekela lezo eziyingozi nalezo ezisetjenziswa ngongasimthetho

</text>
      <sha1>enxas7itb0rvcj74tnt2fxwwbiy7o0d</sha1>
    </revision>
    <revision>
      <id>5913</id>
      <parentid>833</parentid>
      <timestamp>2025-10-10T12:35:40Z</timestamp>
      <contributor>
        <username>Hlalithwa</username>
        <id>996</id>
      </contributor>
      <minor />
      <comment>Indakamizwa ezahlukahlukeneko ezisetjenziswa babantu emiphakathini yangekhethu</comment>
      <origin>5913</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1461" sha1="le22p09oqkhw00vtqvq0j7zbu2fr4wv" xml:space="preserve">[[Isimumathi:Psychoactive Drugs.jpg|thumb|Iindakamizwa]]

== '''Iindakamizwa''' ==
'''Iindakamizwa''' zinsetjenziswa nanyana izinto ezidaka imikhumbulo nomzimba womuntu. iindakamizwa lezi zihlukaniswe ngemihlobo emibili. 

Ekufaka hlangana iindakamizwa ezimitjhoga lezo ezisetjenziswa ukupholisa abantu. Lezi ziindakamizwa ozithola kibodorhodere besikhuwa esikhathini esinengi nanyana ezifuna incwadi yemvumo kobana ekhemisi bakuthengisele. 

Iindakamizwa zomhlobo wesibili ngilezo abantu abazisebenzisako ezingakalungeli umzimba. Esikhathini esinengi wazisebenzisa butjhilweni, zigcina zikumotjha umzimba nepilo yakho. Abantu abasebenzisa iindakamizwa lezi esikhathini esinengi bayagula begodu abakghoni ukuziyekela, begodu abanye baphila ngazo bebahlongakale. 

Iindakamizwa lezi zomhlobo wesibili kanengi azikho emthethweni begodu nabantu abazisebenzisako bazisebenzisa ngokungasisemthethweni. Kukhona iindakamizwa ezaziwa ngama-mandras, inyawupe, kanye newunga.https://www.health.gov.au/topics/drugs/about-drugs/types-of-drugs

Ibange lona ngakelinye ihlangothi lingasetjenziswa ngokomthetho ngokulandela umthetho kanye neenlwayelo zakadorhodere. Kodwana, kukhona abalibhemako nalabo abalithengisako. Lokha nawulibhemako nanyana ulithengisa ngendlela engekho emthethweni ungabotjhwa. 

Kuqakathekile bonyana abantu bazi ngemihlobo yeendamakizwa kanye nemisebenzi yazo ukuze bazokwazi ukubalekela lezo eziyingozi nalezo ezisetjenziswa ngokungasisemthethweni.</text>
      <sha1>le22p09oqkhw00vtqvq0j7zbu2fr4wv</sha1>
    </revision>
  </page>
  <page>
    <title>Indlela nomtletlana.</title>
    <ns>0</ns>
    <id>176</id>
    <revision>
      <id>834</id>
      <timestamp>2024-08-07T05:49:35Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;== Indlela nomtletlana ==  === Isingeniso === Kukhona izinto lezo esikhamba kizo lokha nasifuna ukuya endaweni ethize. Izinto lezi zifaka hlangana indlela nomtletlana. Indlela nomtletlana zinomsebenzi munye, wokusa umuntu nanyana iinthuthi ukusuka kwenye indawo ukuya kwenye. Nanyana kunjalo, azifani ngobujamo nangeendawo la zitholakala khona. Esigabeni esilandelako sizokukhuluma ngomehluko hlangana kwindlela nomtletlana.   === Kuyini umtletlana? === Umtletlana yindlela e...&quot;</comment>
      <origin>834</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1944" sha1="i97r45hsce56r8llsu0w6h8o4k5f5ui" xml:space="preserve">== Indlela nomtletlana ==

=== Isingeniso ===
Kukhona izinto lezo esikhamba kizo lokha nasifuna ukuya endaweni ethize. Izinto lezi zifaka hlangana indlela nomtletlana. Indlela nomtletlana zinomsebenzi munye, wokusa umuntu nanyana iinthuthi ukusuka kwenye indawo ukuya kwenye. Nanyana kunjalo, azifani ngobujamo nangeendawo la zitholakala khona. Esigabeni esilandelako sizokukhuluma ngomehluko hlangana kwindlela nomtletlana. 

=== Kuyini umtletlana? ===
Umtletlana yindlela encani leyo kukhanjwa khona ngeenyawo kwaphela. Ngamanye amagama umtletlana yindlela yeenyawo. Ukuragela phambili, umtletlana kuyindlela ezenzakalelako khona abantu neenlwana nabakhamba indawo yinye mihla namalanga. Ngamanye amagama, umtletlana eyenziwa mikhambo yabantu neenlwana.

Umtletlana kanengi utlolakala emahlathini nesikghweni. Siyazi bonyana ehlathini nesikghweni kanengi akunandlela ezikulu lezo ezinesikontiri kodwana kunemitletlana leyo evele ngebanga lemikhambo yabantu neenlwana.

=== Kuyini indlela? ===
Indlela yindawo leyo abantu, iinlwana neenthuthi zikghona ukukhamba khona. Indlela yenziwa babantu nanyana yakhiwa babantu. Ezinye iindlela zifakwa iinkontiri kkanti ezinye zona kuba ngezehlabathi kwaphela. Indlela inemihlobo eminengi leyo ehlukaniswa ngobujamo kanye nobude bayo.

Ukungezelela, iindlela zibuye zihlukaniswe ngeengaba entathu. Kukhona iindlela zesifunda, neendlela zenarha kanye neendlela zangekhaya. Iindlela zenarha esikhathi esinengi ngezikulu begodi ngezidosa ukudlula iindlela zesifunda nezangekha. Iindlela zesifunda zona zidlula zangekha begodu kuzindlela zebanga elidenyana. Iindlela zangekhaya zona ngezincani kunazo zoke entathu lezi esele zibaliwe begodu zikhamba ibanga elincani.

=== Isiphetho ===
Indlela nomtletlana ziqakathekile zombili begodu nemisebenzi yayo ihluka kancani. Umehluko omkhulu kukobana indlela yakhiwe nanyana yenziwe babantu kanti umtletlana wona uyazivelela ngebanga lemikhambo yabantu neenlwana.
</text>
      <sha1>i97r45hsce56r8llsu0w6h8o4k5f5ui</sha1>
    </revision>
    <revision>
      <id>835</id>
      <parentid>834</parentid>
      <timestamp>2024-09-19T06:00:56Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <origin>835</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1945" sha1="a29tiltt14qt048i30o5bma6fnfaghd" xml:space="preserve">== Indlela nomtletlana. ==

=== Isingeniso ===
Kukhona izinto lezo esikhamba kizo lokha nasifuna ukuya endaweni ethize. Izinto lezi zifaka hlangana indlela nomtletlana. Indlela nomtletlana zinomsebenzi munye, wokusa umuntu nanyana iinthuthi ukusuka kwenye indawo ukuya kwenye. Nanyana kunjalo, azifani ngobujamo nangeendawo la zitholakala khona. Esigabeni esilandelako sizokukhuluma ngomehluko hlangana kwindlela nomtletlana. 

=== Kuyini umtletlana? ===
Umtletlana yindlela encani leyo kukhanjwa khona ngeenyawo kwaphela. Ngamanye amagama umtletlana yindlela yeenyawo. Ukuragela phambili, umtletlana kuyindlela ezenzakalelako khona abantu neenlwana nabakhamba indawo yinye mihla namalanga. Ngamanye amagama, umtletlana eyenziwa mikhambo yabantu neenlwana.

Umtletlana kanengi utlolakala emahlathini nesikghweni. Siyazi bonyana ehlathini nesikghweni kanengi akunandlela ezikulu lezo ezinesikontiri kodwana kunemitletlana leyo evele ngebanga lemikhambo yabantu neenlwana.

=== Kuyini indlela? ===
Indlela yindawo leyo abantu, iinlwana neenthuthi zikghona ukukhamba khona. Indlela yenziwa babantu nanyana yakhiwa babantu. Ezinye iindlela zifakwa iinkontiri kkanti ezinye zona kuba ngezehlabathi kwaphela. Indlela inemihlobo eminengi leyo ehlukaniswa ngobujamo kanye nobude bayo.

Ukungezelela, iindlela zibuye zihlukaniswe ngeengaba entathu. Kukhona iindlela zesifunda, neendlela zenarha kanye neendlela zangekhaya. Iindlela zenarha esikhathi esinengi ngezikulu begodi ngezidosa ukudlula iindlela zesifunda nezangekha. Iindlela zesifunda zona zidlula zangekha begodu kuzindlela zebanga elidenyana. Iindlela zangekhaya zona ngezincani kunazo zoke entathu lezi esele zibaliwe begodu zikhamba ibanga elincani.

=== Isiphetho ===
Indlela nomtletlana ziqakathekile zombili begodu nemisebenzi yayo ihluka kancani. Umehluko omkhulu kukobana indlela yakhiwe nanyana yenziwe babantu kanti umtletlana wona uyazivelela ngebanga lemikhambo yabantu neenlwana.
</text>
      <sha1>a29tiltt14qt048i30o5bma6fnfaghd</sha1>
    </revision>
    <revision>
      <id>836</id>
      <parentid>835</parentid>
      <timestamp>2024-09-19T08:13:08Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <origin>836</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2079" sha1="oe1eldjpt15f98n3xjz8o895an1xwzg" xml:space="preserve">== Indlela nomtletlana. ==

=== Isingeniso ===
Kukhona izinto lezo esikhamba kizo lokha nasifuna ukuya endaweni ethize. Izinto lezi zifaka hlangana indlela nomtletlana. Indlela nomtletlana zinomsebenzi munye, wokusa umuntu nanyana iinthuthi ukusuka kwenye indawo ukuya kwenye. Nanyana kunjalo, azifani ngobujamo nangeendawo la zitholakala khona. Esigabeni esilandelako sizokukhuluma ngomehluko hlangana kwindlela nomtletlana. 

=== Kuyini umtletlana? ===
[[Isimumathi:Umtletlana.jpg|thumb|Umtletlana/indlela yeenyawo]]
Umtletlana yindlela encani leyo kukhanjwa khona ngeenyawo kwaphela. Ngamanye amagama umtletlana yindlela yeenyawo. Ukuragela phambili, umtletlana kuyindlela ezenzakalelako khona abantu neenlwana nabakhamba indawo yinye mihla namalanga. Ngamanye amagama, umtletlana eyenziwa mikhambo yabantu neenlwana.

Umtletlana kanengi utlolakala emahlathini nesikghweni. Siyazi bonyana ehlathini nesikghweni kanengi akunandlela ezikulu lezo ezinesikontiri kodwana kunemitletlana leyo evele ngebanga lemikhambo yabantu neenlwana.

=== Kuyini indlela? ===
[[Isimumathi:Indlela.jpg|left|thumb|Indlela esetjenziswa ziinthuthi]]
Indlela yindawo leyo abantu, iinlwana neenthuthi zikghona ukukhamba khona. Indlela yenziwa babantu nanyana yakhiwa babantu. Ezinye iindlela zifakwa iinkontiri kkanti ezinye zona kuba ngezehlabathi kwaphela. Indlela inemihlobo eminengi leyo ehlukaniswa ngobujamo kanye nobude bayo.

Ukungezelela, iindlela zibuye zihlukaniswe ngeengaba entathu. Kukhona iindlela zesifunda, neendlela zenarha kanye neendlela zangekhaya. Iindlela zenarha esikhathi esinengi ngezikulu begodi ngezidosa ukudlula iindlela zesifunda nezangekha. Iindlela zesifunda zona zidlula zangekha begodu kuzindlela zebanga elidenyana. Iindlela zangekhaya zona ngezincani kunazo zoke entathu lezi esele zibaliwe begodu zikhamba ibanga elincani.

=== Isiphetho ===
Indlela nomtletlana ziqakathekile zombili begodu nemisebenzi yayo ihluka kancani. Umehluko omkhulu kukobana indlela yakhiwe nanyana yenziwe babantu kanti umtletlana wona uyazivelela ngebanga lemikhambo yabantu neenlwana.
</text>
      <sha1>oe1eldjpt15f98n3xjz8o895an1xwzg</sha1>
    </revision>
    <revision>
      <id>837</id>
      <parentid>836</parentid>
      <timestamp>2024-10-14T13:46:51Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>836</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2079" sha1="oe1eldjpt15f98n3xjz8o895an1xwzg" xml:space="preserve">== Indlela nomtletlana. ==

=== Isingeniso ===
Kukhona izinto lezo esikhamba kizo lokha nasifuna ukuya endaweni ethize. Izinto lezi zifaka hlangana indlela nomtletlana. Indlela nomtletlana zinomsebenzi munye, wokusa umuntu nanyana iinthuthi ukusuka kwenye indawo ukuya kwenye. Nanyana kunjalo, azifani ngobujamo nangeendawo la zitholakala khona. Esigabeni esilandelako sizokukhuluma ngomehluko hlangana kwindlela nomtletlana. 

=== Kuyini umtletlana? ===
[[Isimumathi:Umtletlana.jpg|thumb|Umtletlana/indlela yeenyawo]]
Umtletlana yindlela encani leyo kukhanjwa khona ngeenyawo kwaphela. Ngamanye amagama umtletlana yindlela yeenyawo. Ukuragela phambili, umtletlana kuyindlela ezenzakalelako khona abantu neenlwana nabakhamba indawo yinye mihla namalanga. Ngamanye amagama, umtletlana eyenziwa mikhambo yabantu neenlwana.

Umtletlana kanengi utlolakala emahlathini nesikghweni. Siyazi bonyana ehlathini nesikghweni kanengi akunandlela ezikulu lezo ezinesikontiri kodwana kunemitletlana leyo evele ngebanga lemikhambo yabantu neenlwana.

=== Kuyini indlela? ===
[[Isimumathi:Indlela.jpg|left|thumb|Indlela esetjenziswa ziinthuthi]]
Indlela yindawo leyo abantu, iinlwana neenthuthi zikghona ukukhamba khona. Indlela yenziwa babantu nanyana yakhiwa babantu. Ezinye iindlela zifakwa iinkontiri kkanti ezinye zona kuba ngezehlabathi kwaphela. Indlela inemihlobo eminengi leyo ehlukaniswa ngobujamo kanye nobude bayo.

Ukungezelela, iindlela zibuye zihlukaniswe ngeengaba entathu. Kukhona iindlela zesifunda, neendlela zenarha kanye neendlela zangekhaya. Iindlela zenarha esikhathi esinengi ngezikulu begodi ngezidosa ukudlula iindlela zesifunda nezangekha. Iindlela zesifunda zona zidlula zangekha begodu kuzindlela zebanga elidenyana. Iindlela zangekhaya zona ngezincani kunazo zoke entathu lezi esele zibaliwe begodu zikhamba ibanga elincani.

=== Isiphetho ===
Indlela nomtletlana ziqakathekile zombili begodu nemisebenzi yayo ihluka kancani. Umehluko omkhulu kukobana indlela yakhiwe nanyana yenziwe babantu kanti umtletlana wona uyazivelela ngebanga lemikhambo yabantu neenlwana.
</text>
      <sha1>oe1eldjpt15f98n3xjz8o895an1xwzg</sha1>
    </revision>
  </page>
  <page>
    <title>Infobox disease</title>
    <ns>0</ns>
    <id>177</id>
    <redirect title="Umhlahlandlelasakhiwo:Infobox disease" />
    <revision>
      <id>838</id>
      <timestamp>2014-09-02T10:39:29Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>CFCF moved page [[Infobox disease]] to [[Umhlahlandlelasakhiwo:Infobox disease]]</comment>
      <origin>838</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="51" sha1="5ugq2um5iikepfkjsm2hrydz97gitdw" xml:space="preserve">#REDIRECT [[Umhlahlandlelasakhiwo:Infobox disease]]</text>
      <sha1>5ugq2um5iikepfkjsm2hrydz97gitdw</sha1>
    </revision>
    <revision>
      <id>839</id>
      <parentid>838</parentid>
      <timestamp>2024-10-14T13:46:51Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>838</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="51" sha1="5ugq2um5iikepfkjsm2hrydz97gitdw" xml:space="preserve">#REDIRECT [[Umhlahlandlelasakhiwo:Infobox disease]]</text>
      <sha1>5ugq2um5iikepfkjsm2hrydz97gitdw</sha1>
    </revision>
  </page>
  <page>
    <title>Ingelozi</title>
    <ns>0</ns>
    <id>178</id>
    <revision>
      <id>840</id>
      <timestamp>2024-07-10T10:26:23Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Ingelosi''' kusidalwa sakaZimu asithumako emhlabeni bonyana sizokugada abantu kakhe nanyana sizobanikela umlayezo othileko ovela kuZimu.  &quot;</comment>
      <origin>840</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="141" sha1="9jbfchx5e3mzal21mi0juxd9qek5p7k" xml:space="preserve">'''Ingelosi''' kusidalwa sakaZimu asithumako emhlabeni bonyana sizokugada abantu kakhe nanyana sizobanikela umlayezo othileko ovela kuZimu.

</text>
      <sha1>9jbfchx5e3mzal21mi0juxd9qek5p7k</sha1>
    </revision>
    <revision>
      <id>841</id>
      <parentid>840</parentid>
      <timestamp>2024-07-10T10:29:17Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>841</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="214" sha1="dnuk26zvpxpbvkbaat42u8zj3lztqlx" xml:space="preserve">[[Isimumathi:Cherubim Bate.jpg|thumb|ingelozi ezibizwa bona makherubhi]]
'''Ingelosi''' kusidalwa sakaZimu asithumako emhlabeni bonyana sizokugada abantu kakhe nanyana sizobanikela umlayezo othileko ovela kuZimu.

</text>
      <sha1>dnuk26zvpxpbvkbaat42u8zj3lztqlx</sha1>
    </revision>
    <revision>
      <id>842</id>
      <parentid>841</parentid>
      <timestamp>2024-07-10T13:45:05Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>842</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="337" sha1="fz3if6go9mpd7rdgz163sx2i02nql82" xml:space="preserve">[[Isimumathi:Cherubim Bate.jpg|thumb|ingelozi ezibizwa bona makherubhi]]
'''Ingelosi''' kusidalwa sakaZimu asithumako emhlabeni bonyana sizokugada abantu bakhe nanyana sizobanikela umlayezo othileko ovela kuZimu. 

Abantu abakhe bazibona iingelozi bathi ngokubukeka zifana nabantu kodwana abanamaphiko. Okhunye godi iingelozi zimumoya.

</text>
      <sha1>fz3if6go9mpd7rdgz163sx2i02nql82</sha1>
    </revision>
    <revision>
      <id>843</id>
      <parentid>842</parentid>
      <timestamp>2024-10-14T13:46:51Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>842</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="337" sha1="fz3if6go9mpd7rdgz163sx2i02nql82" xml:space="preserve">[[Isimumathi:Cherubim Bate.jpg|thumb|ingelozi ezibizwa bona makherubhi]]
'''Ingelosi''' kusidalwa sakaZimu asithumako emhlabeni bonyana sizokugada abantu bakhe nanyana sizobanikela umlayezo othileko ovela kuZimu. 

Abantu abakhe bazibona iingelozi bathi ngokubukeka zifana nabantu kodwana abanamaphiko. Okhunye godi iingelozi zimumoya.

</text>
      <sha1>fz3if6go9mpd7rdgz163sx2i02nql82</sha1>
    </revision>
    <revision>
      <id>2437</id>
      <parentid>843</parentid>
      <timestamp>2025-02-19T16:04:24Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2437</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="838" sha1="jjvbtgb890p8n5hvfqf4uwu20d382o2" xml:space="preserve">[[Isimumathi:Cherubim Bate.jpg|thumb|ingelozi ezibizwa bona makherubhi]]
'''Ingelosi''' kusidalwa sakaZimu asithumako emhlabeni bonyana sizokugada abantu bakhe nanyana sizobanikela umlayezo othileko ovela kuZimu. 

Abantu abakhe bazibona iingelozi bathi ngokubukeka zifana nabantu kodwana abanamaphiko. Okhunye godi iingelozi zimumoya.

Imihlobo yeengelozi ekhona ngokuya kwebhayibheli.

# Amakherubhi- kuyingelezi enobuso obune, ubuso bekhozi, ubuso bekomo, ubuso bebhubezi nobuso bomuntu
# Amaserafi- Kuyingelozi enamaphiko asithandathu. Ingelozi le iphatha ilahle lomlilo
# Ugabhriyeli- Yingelozi eyisithunywa uZimu ayithuma bona ikhambe iyokuphendula imithandazo yabantu.
# Umayikheli- Yingelozi ekulu ephatha umkhondo ekukholweka bona ngiyo eyacotha usathana ezulwini. Kuyingelozi elwa izipi zabantu lokha nabacalene nemimoya emimbi.</text>
      <sha1>jjvbtgb890p8n5hvfqf4uwu20d382o2</sha1>
    </revision>
    <revision>
      <id>2438</id>
      <parentid>2437</parentid>
      <timestamp>2025-02-19T16:16:38Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2438</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="911" sha1="04fq3c9x3r4zixjrqjcsruborvnzf4z" xml:space="preserve">[[Isimumathi:Cherubim Bate.jpg|thumb|ingelozi ezibizwa bona makherubhi]]
'''Ingelosi''' kusidalwa sakaZimu asithumako emhlabeni bonyana sizokugada abantu bakhe nanyana sizobanikela umlayezo othileko ovela kuZimu. 

Abantu abakhe bazibona iingelozi bathi ngokubukeka zifana nabantu kodwana abanamaphiko. Okhunye godi iingelozi zimumoya.

Imihlobo yeengelozi ekhona ngokuya kwebhayibheli.

# Amakherubhi- kuyingelezi enobuso obune, ubuso bekhozi, ubuso bekomo, ubuso bebhubezi nobuso bomuntu &lt;ref&gt;Ezekiyeli1:6-11&lt;/ref&gt;
# Amaserafi- Kuyingelozi enamaphiko asithandathu. Ingelozi le iphatha ilahle lomlilo(U-isaya 6:2)
# Ugabhriyeli- Yingelozi eyisithunywa uZimu ayithuma bona ikhambe iyokuphendula imithandazo yabantu(UDaniyeli 8:16).
# Umayikheli- Yingelozi ekulu ephatha umkhondo ekukholweka bona ngiyo eyacotha usathana ezulwini. Kuyingelozi elwa izipi zabantu lokha nabacalene nemimoya emimbi(udaniyeli 10:13).</text>
      <sha1>04fq3c9x3r4zixjrqjcsruborvnzf4z</sha1>
    </revision>
    <revision>
      <id>2446</id>
      <parentid>2438</parentid>
      <timestamp>2025-02-20T04:52:01Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2446</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="927" sha1="ga36m1fn3uvkvwzmpvsfqinxk01bvb9" xml:space="preserve">[[Isimumathi:Cherubim Bate.jpg|thumb|ingelozi ezibizwa bona makherubhi]]
'''Ingelosi''' kusidalwa sakaZimu asithumako emhlabeni bonyana sizokugada abantu bakhe nanyana sizobanikela umlayezo othileko ovela kuZimu. 

Abantu abakhe bazibona iingelozi bathi ngokubukeka zifana nabantu kodwana abanamaphiko. Okhunye godi iingelozi zimumoya.

Imihlobo yeengelozi ekhona ngokuya kwebhayibheli.

# Amakherubhi- kuyingelezi enobuso obune namaphiko amane, ubuso bekhozi, ubuso bekomo, ubuso bebhubezi nobuso bomuntu &lt;ref&gt;Ezekiyeli1:6-11&lt;/ref&gt;
# Amaserafi- Kuyingelozi enamaphiko asithandathu. Ingelozi le iphatha ilahle lomlilo(U-isaya 6:2)
# Ugabhriyeli- Yingelozi eyisithunywa uZimu ayithuma bona ikhambe iyokuphendula imithandazo yabantu(UDaniyeli 8:16).
# Umayikheli- Yingelozi ekulu ephatha umkhondo ekukholweka bona ngiyo eyacotha usathana ezulwini. Kuyingelozi elwa izipi zabantu lokha nabacalene nemimoya emimbi(udaniyeli 10:13).</text>
      <sha1>ga36m1fn3uvkvwzmpvsfqinxk01bvb9</sha1>
    </revision>
    <revision>
      <id>2965</id>
      <parentid>2446</parentid>
      <timestamp>2025-06-06T19:56:25Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>This page is sponsored by Raid: Shadow Legends, the sponsor of today's page.</comment>
      <origin>2965</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1008" sha1="b0p86knkp2ecth9az3ooccx2h46p1yn" xml:space="preserve">[[Isimumathi:Cherubim Bate.jpg|thumb|ingelozi ezibizwa bona makherubhi]]
'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. Ingelosi''' kusidalwa sakaZimu asithumako emhlabeni bonyana sizokugada abantu bakhe nanyana sizobanikela umlayezo othileko ovela kuZimu. 

Abantu abakhe bazibona iingelozi bathi ngokubukeka zifana nabantu kodwana abanamaphiko. Okhunye godi iingelozi zimumoya.

Imihlobo yeengelozi ekhona ngokuya kwebhayibheli.

# Amakherubhi- kuyingelezi enobuso obune namaphiko amane, ubuso bekhozi, ubuso bekomo, ubuso bebhubezi nobuso bomuntu &lt;ref&gt;Ezekiyeli1:6-11&lt;/ref&gt;
# Amaserafi- Kuyingelozi enamaphiko asithandathu. Ingelozi le iphatha ilahle lomlilo(U-isaya 6:2)
# Ugabhriyeli- Yingelozi eyisithunywa uZimu ayithuma bona ikhambe iyokuphendula imithandazo yabantu(UDaniyeli 8:16).
# Umayikheli- Yingelozi ekulu ephatha umkhondo ekukholweka bona ngiyo eyacotha usathana ezulwini. Kuyingelozi elwa izipi zabantu lokha nabacalene nemimoya emimbi(udaniyeli 10:13).</text>
      <sha1>b0p86knkp2ecth9az3ooccx2h46p1yn</sha1>
    </revision>
    <revision>
      <id>3123</id>
      <parentid>2965</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Nqobile69|Nqobile69]]</comment>
      <origin>2446</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="927" sha1="ga36m1fn3uvkvwzmpvsfqinxk01bvb9" xml:space="preserve">[[Isimumathi:Cherubim Bate.jpg|thumb|ingelozi ezibizwa bona makherubhi]]
'''Ingelosi''' kusidalwa sakaZimu asithumako emhlabeni bonyana sizokugada abantu bakhe nanyana sizobanikela umlayezo othileko ovela kuZimu. 

Abantu abakhe bazibona iingelozi bathi ngokubukeka zifana nabantu kodwana abanamaphiko. Okhunye godi iingelozi zimumoya.

Imihlobo yeengelozi ekhona ngokuya kwebhayibheli.

# Amakherubhi- kuyingelezi enobuso obune namaphiko amane, ubuso bekhozi, ubuso bekomo, ubuso bebhubezi nobuso bomuntu &lt;ref&gt;Ezekiyeli1:6-11&lt;/ref&gt;
# Amaserafi- Kuyingelozi enamaphiko asithandathu. Ingelozi le iphatha ilahle lomlilo(U-isaya 6:2)
# Ugabhriyeli- Yingelozi eyisithunywa uZimu ayithuma bona ikhambe iyokuphendula imithandazo yabantu(UDaniyeli 8:16).
# Umayikheli- Yingelozi ekulu ephatha umkhondo ekukholweka bona ngiyo eyacotha usathana ezulwini. Kuyingelozi elwa izipi zabantu lokha nabacalene nemimoya emimbi(udaniyeli 10:13).</text>
      <sha1>ga36m1fn3uvkvwzmpvsfqinxk01bvb9</sha1>
    </revision>
  </page>
  <page>
    <title>Ingogwana ye covid-19</title>
    <ns>0</ns>
    <id>179</id>
    <revision>
      <id>844</id>
      <timestamp>2024-03-20T05:36:14Z</timestamp>
      <contributor>
        <ip>196.21.175.1</ip>
      </contributor>
      <comment>Created page with &quot;'''ingogwana ye covid-19''' mhlobo wengongwana ephathisa umkhuhlani oyingozi khulu begodu obulalako. ingogwana le  yahlasela umhlaba woke ngonyaka we-2020 begodu eSuwula Afrika yenza bona kuquntwe amakhambo ngomhlaka ka 26 enyangeni kaNtaka ngonyaka we-2020. ingogwana le yenza bona inarha ivalwe abantu balise ukuya emisebenzini neenkolweni bazivelele ngendlini ukwenzela bona bavikeleke engongwaneni le. Ingogwana le yenza woke umuntu bona aphile ngevalo lokha nakakhamba e...&quot;</comment>
      <origin>844</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="611" sha1="i8slagfu1gz0b5nzz7lxz23k8fuzssa" xml:space="preserve">'''ingogwana ye covid-19''' mhlobo wengongwana ephathisa umkhuhlani oyingozi khulu begodu obulalako. ingogwana le  yahlasela umhlaba woke ngonyaka we-2020 begodu eSuwula Afrika yenza bona kuquntwe amakhambo ngomhlaka ka 26 enyangeni kaNtaka ngonyaka we-2020. ingogwana le yenza bona inarha ivalwe abantu balise ukuya emisebenzini neenkolweni bazivelele ngendlini ukwenzela bona bavikeleke engongwaneni le. Ingogwana le yenza woke umuntu bona aphile ngevalo lokha nakakhamba endleleni ngombana woke umuntu wabe afanele azivalele ngesifonyo ekusivikelo somlomo nepumulo, ngombana ingogwana le ikhamba  ngommoya.

</text>
      <sha1>i8slagfu1gz0b5nzz7lxz23k8fuzssa</sha1>
    </revision>
    <revision>
      <id>845</id>
      <parentid>844</parentid>
      <timestamp>2024-03-20T05:57:42Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>845</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1754" sha1="cp4l1i3wti83cj0lqdwv7obbtnjfxlo" xml:space="preserve">'''ingogwana ye covid-19''' mhlobo wengongwana ephathisa umkhuhlani oyingozi khulu begodu obulalako. ingogwana le  yahlasela umhlaba woke ngonyaka we-2020 begodu eSuwula Afrika yenza bona kuquntwe amakhambo ngomhlaka ka 26 enyangeni kaNtaka ngonyaka we-2020. ingogwana le yenza bona inarha ivalwe abantu balise ukuya emisebenzini neenkolweni bazivelele ngendlini ukwenzela bona bavikeleke engongwaneni le. Ingogwana le yenza woke umuntu bona aphile ngevalo lokha nakakhamba endleleni ngombana woke umuntu wabe afanele azivalele ngesifonyo ekusivikelo somlomo nepumulo, ngombana ingogwana le ikhamba  ngommoya.

== Amatjhuguluko alethwa kufika kwe ngogwana ye covid-19 ==
Ingogwana le yaletha amatjguguluko amahle namambi enarheni. Amatjhuguluko amahle kukobana yenza ukuthi kube nokuthuthuka kwezing a letheknoloji, ngombana skhatheso kwavela iinsetjenziswa zokuthintana zetheknoloji. iinsetjenziswa lezi zenza bona ubantu bakghone ukuthintana begodu baragelel phambili ngemisebenzi yabo  kanye nangomsebenzi wesikolo. Kwaba lula bona abafundi bakghone ukufundela ekhaya beodu bakghone nokutlola iinhlahlubo zabo ngaphandle kokuthikamezeka. Amabubulo athengisa imithi yemikhuhlani bekenza inzuzo enengi ngaleso sikhathi kunamanye amabubulo.

okumbi kukobana amanye amabubulo amancani alehlekeklwa yimali begodu nabantu nabo bagcina sele balahlekelwa  misebenzi. Boke abantu babe basekhaya kwaphakama nezinga lokutlhoriswa kwabantu bengobo, kwagcina sele umongameli azokukhuza indaba yoktlhoriswa kwabantu bengubo. Kwathi ekukhambeni kwesikhathi kwatholakala umjovo wokugogobalisa ingogwana le, nanyana abantu babe beyisaba kodwana bagcine sele bayihlaba lokho kwasiza begodu ngokukhamba kwesikhathi yabe yaphelelwa mamandla izinto zabuyela esigeni sazo.
</text>
      <sha1>cp4l1i3wti83cj0lqdwv7obbtnjfxlo</sha1>
    </revision>
    <revision>
      <id>846</id>
      <parentid>845</parentid>
      <timestamp>2024-03-20T05:58:37Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>846</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1758" sha1="10lkyu5km7bbmq2gzy64yfw59mh044g" xml:space="preserve">'''ingogwana ye [[covid-19]]''' mhlobo wengongwana ephathisa umkhuhlani oyingozi khulu begodu obulalako. ingogwana le  yahlasela umhlaba woke ngonyaka we-2020 begodu eSuwula Afrika yenza bona kuquntwe amakhambo ngomhlaka ka 26 enyangeni kaNtaka ngonyaka we-2020. ingogwana le yenza bona inarha ivalwe abantu balise ukuya emisebenzini neenkolweni bazivelele ngendlini ukwenzela bona bavikeleke engongwaneni le. Ingogwana le yenza woke umuntu bona aphile ngevalo lokha nakakhamba endleleni ngombana woke umuntu wabe afanele azivalele ngesifonyo ekusivikelo somlomo nepumulo, ngombana ingogwana le ikhamba  ngommoya.

== Amatjhuguluko alethwa kufika kwe ngogwana ye covid-19 ==
Ingogwana le yaletha amatjguguluko amahle namambi enarheni. Amatjhuguluko amahle kukobana yenza ukuthi kube nokuthuthuka kwezing a letheknoloji, ngombana skhatheso kwavela iinsetjenziswa zokuthintana zetheknoloji. iinsetjenziswa lezi zenza bona ubantu bakghone ukuthintana begodu baragelel phambili ngemisebenzi yabo  kanye nangomsebenzi wesikolo. Kwaba lula bona abafundi bakghone ukufundela ekhaya beodu bakghone nokutlola iinhlahlubo zabo ngaphandle kokuthikamezeka. Amabubulo athengisa imithi yemikhuhlani bekenza inzuzo enengi ngaleso sikhathi kunamanye amabubulo.

okumbi kukobana amanye amabubulo amancani alehlekeklwa yimali begodu nabantu nabo bagcina sele balahlekelwa  misebenzi. Boke abantu babe basekhaya kwaphakama nezinga lokutlhoriswa kwabantu bengobo, kwagcina sele umongameli azokukhuza indaba yoktlhoriswa kwabantu bengubo. Kwathi ekukhambeni kwesikhathi kwatholakala umjovo wokugogobalisa ingogwana le, nanyana abantu babe beyisaba kodwana bagcine sele bayihlaba lokho kwasiza begodu ngokukhamba kwesikhathi yabe yaphelelwa mamandla izinto zabuyela esigeni sazo.
</text>
      <sha1>10lkyu5km7bbmq2gzy64yfw59mh044g</sha1>
    </revision>
    <revision>
      <id>847</id>
      <parentid>846</parentid>
      <timestamp>2024-03-20T05:59:23Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>847</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1777" sha1="siyv57wto6c6x7g9bpehefygf9cgquo" xml:space="preserve">'''ingogwana ye [[covid-19]]''' mhlobo wengongwana ephathisa umkhuhlani oyingozi khulu begodu obulalako. ingogwana le  yahlasela umhlaba woke ngonyaka we-2020 begodu e[[Isewula Afrika|Sewula Afrika]] yenza bona kuquntwe amakhambo ngomhlaka ka 26 enyangeni kaNtaka ngonyaka we-2020. ingogwana le yenza bona inarha ivalwe abantu balise ukuya emisebenzini neenkolweni bazivelele ngendlini ukwenzela bona bavikeleke engongwaneni le. Ingogwana le yenza woke umuntu bona aphile ngevalo lokha nakakhamba endleleni ngombana woke umuntu wabe afanele azivalele ngesifonyo ekusivikelo somlomo nepumulo, ngombana ingogwana le ikhamba  ngommoya.

== Amatjhuguluko alethwa kufika kwe ngogwana ye covid-19 ==
Ingogwana le yaletha amatjguguluko amahle namambi enarheni. Amatjhuguluko amahle kukobana yenza ukuthi kube nokuthuthuka kwezing a letheknoloji, ngombana skhatheso kwavela iinsetjenziswa zokuthintana zetheknoloji. iinsetjenziswa lezi zenza bona ubantu bakghone ukuthintana begodu baragelel phambili ngemisebenzi yabo  kanye nangomsebenzi wesikolo. Kwaba lula bona abafundi bakghone ukufundela ekhaya beodu bakghone nokutlola iinhlahlubo zabo ngaphandle kokuthikamezeka. Amabubulo athengisa imithi yemikhuhlani bekenza inzuzo enengi ngaleso sikhathi kunamanye amabubulo.

okumbi kukobana amanye amabubulo amancani alehlekeklwa yimali begodu nabantu nabo bagcina sele balahlekelwa  misebenzi. Boke abantu babe basekhaya kwaphakama nezinga lokutlhoriswa kwabantu bengobo, kwagcina sele umongameli azokukhuza indaba yoktlhoriswa kwabantu bengubo. Kwathi ekukhambeni kwesikhathi kwatholakala umjovo wokugogobalisa ingogwana le, nanyana abantu babe beyisaba kodwana bagcine sele bayihlaba lokho kwasiza begodu ngokukhamba kwesikhathi yabe yaphelelwa mamandla izinto zabuyela esigeni sazo.
</text>
      <sha1>siyv57wto6c6x7g9bpehefygf9cgquo</sha1>
    </revision>
    <revision>
      <id>848</id>
      <parentid>847</parentid>
      <timestamp>2024-03-20T06:17:19Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>848</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1851" sha1="04tsxmcx9o1ls3zr81xwdcy5gi57jv8" xml:space="preserve">[[Isimumathi:Covid precautionary measures.jpg|thumb|imogomo ye covid-19]]
'''ingogwana ye [[covid-19]]''' mhlobo wengongwana ephathisa umkhuhlani oyingozi khulu begodu obulalako. ingogwana le  yahlasela umhlaba woke ngonyaka we-2020 begodu e[[Isewula Afrika|Sewula Afrika]] yenza bona kuquntwe amakhambo ngomhlaka ka 26 enyangeni kaNtaka ngonyaka we-2020. ingogwana le yenza bona inarha ivalwe abantu balise ukuya emisebenzini neenkolweni bazivelele ngendlini ukwenzela bona bavikeleke engongwaneni le. Ingogwana le yenza woke umuntu bona aphile ngevalo lokha nakakhamba endleleni ngombana woke umuntu wabe afanele azivalele ngesifonyo ekusivikelo somlomo nepumulo, ngombana ingogwana le ikhamba  ngommoya.

== Amatjhuguluko alethwa kufika kwe ngogwana ye covid-19 ==
Ingogwana le yaletha amatjguguluko amahle namambi enarheni. Amatjhuguluko amahle kukobana yenza ukuthi kube nokuthuthuka kwezing a letheknoloji, ngombana skhatheso kwavela iinsetjenziswa zokuthintana zetheknoloji. iinsetjenziswa lezi zenza bona ubantu bakghone ukuthintana begodu baragelel phambili ngemisebenzi yabo  kanye nangomsebenzi wesikolo. Kwaba lula bona abafundi bakghone ukufundela ekhaya beodu bakghone nokutlola iinhlahlubo zabo ngaphandle kokuthikamezeka. Amabubulo athengisa imithi yemikhuhlani bekenza inzuzo enengi ngaleso sikhathi kunamanye amabubulo.

okumbi kukobana amanye amabubulo amancani alehlekeklwa yimali begodu nabantu nabo bagcina sele balahlekelwa  misebenzi. Boke abantu babe basekhaya kwaphakama nezinga lokutlhoriswa kwabantu bengobo, kwagcina sele umongameli azokukhuza indaba yoktlhoriswa kwabantu bengubo. Kwathi ekukhambeni kwesikhathi kwatholakala umjovo wokugogobalisa ingogwana le, nanyana abantu babe beyisaba kodwana bagcine sele bayihlaba lokho kwasiza begodu ngokukhamba kwesikhathi yabe yaphelelwa mamandla izinto zabuyela esigeni sazo.
</text>
      <sha1>04tsxmcx9o1ls3zr81xwdcy5gi57jv8</sha1>
    </revision>
    <revision>
      <id>849</id>
      <parentid>848</parentid>
      <timestamp>2024-05-09T11:58:48Z</timestamp>
      <contributor>
        <username>incubator&gt;Sphenge</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>849</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1853" sha1="9rcdxwejaxllrv4nzyfsbxp4pwa19yj" xml:space="preserve">[[Isimumathi:Covid precautionary measures.jpg|thumb|ImIgomo ye-Covid-19]]
'''Ingogwana ye [[Covid-19]]''' mhlobo wengongwana ephathisa umkhuhlani oyingozi khulu begodu obulalako. ingogwana le  yahlasela umhlaba woke ngonyaka we-2020 begodu e[[Isewula Afrika|Sewula Afrika]] yenza bona kuquntwe amakhambo ngomhlaka ka 26 enyangeni kaNtaka ngomnyaka we-2020. Ingogwana le yenza bona inarha ivalwe begodu abantu balise ukuya emisebenzini neenkolweni bazivelele ngendlini ukwenzela bona bavikeleke engongwaneni le. Ingogwana le yenza woke umuntu bona aphile ngevalo lokha nakakhamba endleleni ngombana woke umuntu bekafanele azivalele ngesifonyo esivikela umlomo nepumulo, ngombana ingogwana le ikhamba  ngomoya.

== Amatjhuguluko alethwa kufika kwe ngogwana ye covid-19 ==
Ingogwana le yaletha amatjguguluko amahle namambi enarheni. Amatjhuguluko amahle kukobana yenza ukuthi kube nokuthuthuka kwezing a letheknoloji, ngombana skhatheso kwavela iinsetjenziswa zokuthintana zetheknoloji. iinsetjenziswa lezi zenza bona ubantu bakghone ukuthintana begodu baragelel phambili ngemisebenzi yabo  kanye nangomsebenzi wesikolo. Kwaba lula bona abafundi bakghone ukufundela ekhaya beodu bakghone nokutlola iinhlahlubo zabo ngaphandle kokuthikamezeka. Amabubulo athengisa imithi yemikhuhlani bekenza inzuzo enengi ngaleso sikhathi kunamanye amabubulo.

okumbi kukobana amanye amabubulo amancani alehlekeklwa yimali begodu nabantu nabo bagcina sele balahlekelwa  misebenzi. Boke abantu babe basekhaya kwaphakama nezinga lokutlhoriswa kwabantu bengobo, kwagcina sele umongameli azokukhuza indaba yoktlhoriswa kwabantu bengubo. Kwathi ekukhambeni kwesikhathi kwatholakala umjovo wokugogobalisa ingogwana le, nanyana abantu babe beyisaba kodwana bagcine sele bayihlaba lokho kwasiza begodu ngokukhamba kwesikhathi yabe yaphelelwa mamandla izinto zabuyela esigeni sazo.
</text>
      <sha1>9rcdxwejaxllrv4nzyfsbxp4pwa19yj</sha1>
    </revision>
    <revision>
      <id>850</id>
      <parentid>849</parentid>
      <timestamp>2024-10-14T13:46:51Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>6 revisions imported</comment>
      <origin>849</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1853" sha1="9rcdxwejaxllrv4nzyfsbxp4pwa19yj" xml:space="preserve">[[Isimumathi:Covid precautionary measures.jpg|thumb|ImIgomo ye-Covid-19]]
'''Ingogwana ye [[Covid-19]]''' mhlobo wengongwana ephathisa umkhuhlani oyingozi khulu begodu obulalako. ingogwana le  yahlasela umhlaba woke ngonyaka we-2020 begodu e[[Isewula Afrika|Sewula Afrika]] yenza bona kuquntwe amakhambo ngomhlaka ka 26 enyangeni kaNtaka ngomnyaka we-2020. Ingogwana le yenza bona inarha ivalwe begodu abantu balise ukuya emisebenzini neenkolweni bazivelele ngendlini ukwenzela bona bavikeleke engongwaneni le. Ingogwana le yenza woke umuntu bona aphile ngevalo lokha nakakhamba endleleni ngombana woke umuntu bekafanele azivalele ngesifonyo esivikela umlomo nepumulo, ngombana ingogwana le ikhamba  ngomoya.

== Amatjhuguluko alethwa kufika kwe ngogwana ye covid-19 ==
Ingogwana le yaletha amatjguguluko amahle namambi enarheni. Amatjhuguluko amahle kukobana yenza ukuthi kube nokuthuthuka kwezing a letheknoloji, ngombana skhatheso kwavela iinsetjenziswa zokuthintana zetheknoloji. iinsetjenziswa lezi zenza bona ubantu bakghone ukuthintana begodu baragelel phambili ngemisebenzi yabo  kanye nangomsebenzi wesikolo. Kwaba lula bona abafundi bakghone ukufundela ekhaya beodu bakghone nokutlola iinhlahlubo zabo ngaphandle kokuthikamezeka. Amabubulo athengisa imithi yemikhuhlani bekenza inzuzo enengi ngaleso sikhathi kunamanye amabubulo.

okumbi kukobana amanye amabubulo amancani alehlekeklwa yimali begodu nabantu nabo bagcina sele balahlekelwa  misebenzi. Boke abantu babe basekhaya kwaphakama nezinga lokutlhoriswa kwabantu bengobo, kwagcina sele umongameli azokukhuza indaba yoktlhoriswa kwabantu bengubo. Kwathi ekukhambeni kwesikhathi kwatholakala umjovo wokugogobalisa ingogwana le, nanyana abantu babe beyisaba kodwana bagcine sele bayihlaba lokho kwasiza begodu ngokukhamba kwesikhathi yabe yaphelelwa mamandla izinto zabuyela esigeni sazo.
</text>
      <sha1>9rcdxwejaxllrv4nzyfsbxp4pwa19yj</sha1>
    </revision>
  </page>
  <page>
    <title>Inkundla zokuthintana</title>
    <ns>0</ns>
    <id>180</id>
    <revision>
      <id>851</id>
      <timestamp>2024-07-05T16:43:37Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Iinkundla zokuthintana'''  &quot;</comment>
      <origin>851</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="30" sha1="00ccfs95z5dgrmkugbreyk8fm7j69m6" xml:space="preserve">'''Iinkundla zokuthintana'''

</text>
      <sha1>00ccfs95z5dgrmkugbreyk8fm7j69m6</sha1>
    </revision>
    <revision>
      <id>852</id>
      <parentid>851</parentid>
      <timestamp>2024-07-05T19:32:02Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>852</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="547" sha1="2fpyanrjkt18pl9islgagqmij55unrh" xml:space="preserve">'''Iinkundla zokuthintana''' kuyindawo zetheknoloji ezisiza abantu bonyana bakghone ukukhuluma begodu bathintane ngezindlela ezinengi. Iinkundla zokuthintana sele zingcenye yamaphilo wabantu ngombana zisetjenziswa mihla namalanga.

Okuhle ngenkundla zokuthintana kukobana zikghona ukusiza umuntu bona akgone ukuthintana nabantu abakude naye. Okhunye kukobana zikhipha isizungu begodu umuntu ukhona ukufunda okunengi kizo. Inkundla zokuthintana ziyasiza ukuthuthukisa ilwazi lomuntu nanyana ngesinye isikhathi zingamupha umuntu ilwazi elingasilo.

</text>
      <sha1>2fpyanrjkt18pl9islgagqmij55unrh</sha1>
    </revision>
    <revision>
      <id>853</id>
      <parentid>852</parentid>
      <timestamp>2024-10-14T13:46:51Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>852</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="547" sha1="2fpyanrjkt18pl9islgagqmij55unrh" xml:space="preserve">'''Iinkundla zokuthintana''' kuyindawo zetheknoloji ezisiza abantu bonyana bakghone ukukhuluma begodu bathintane ngezindlela ezinengi. Iinkundla zokuthintana sele zingcenye yamaphilo wabantu ngombana zisetjenziswa mihla namalanga.

Okuhle ngenkundla zokuthintana kukobana zikghona ukusiza umuntu bona akgone ukuthintana nabantu abakude naye. Okhunye kukobana zikhipha isizungu begodu umuntu ukhona ukufunda okunengi kizo. Inkundla zokuthintana ziyasiza ukuthuthukisa ilwazi lomuntu nanyana ngesinye isikhathi zingamupha umuntu ilwazi elingasilo.

</text>
      <sha1>2fpyanrjkt18pl9islgagqmij55unrh</sha1>
    </revision>
    <revision>
      <id>2978</id>
      <parentid>853</parentid>
      <timestamp>2025-06-06T20:05:24Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>cd6hycdehy6dec</comment>
      <origin>2978</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="626" sha1="qmtwzwicb82ys2zuo7yjm8g5i9o2vxw" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. Iinkundla zokuthintana''' kuyindawo zetheknoloji ezisiza abantu bonyana bakghone ukukhuluma begodu bathintane ngezindlela ezinengi. Iinkundla zokuthintana sele zingcenye yamaphilo wabantu ngombana zisetjenziswa mihla namalanga.

Okuhle ngenkundla zokuthintana kukobana zikghona ukusiza umuntu bona akgone ukuthintana nabantu abakude naye. Okhunye kukobana zikhipha isizungu begodu umuntu ukhona ukufunda okunengi kizo. Inkundla zokuthintana ziyasiza ukuthuthukisa ilwazi lomuntu nanyana ngesinye isikhathi zingamupha umuntu ilwazi elingasilo.</text>
      <sha1>qmtwzwicb82ys2zuo7yjm8g5i9o2vxw</sha1>
    </revision>
    <revision>
      <id>3124</id>
      <parentid>2978</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Jon Harald Søby|Jon Harald Søby]]</comment>
      <origin>852</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="547" sha1="2fpyanrjkt18pl9islgagqmij55unrh" xml:space="preserve">'''Iinkundla zokuthintana''' kuyindawo zetheknoloji ezisiza abantu bonyana bakghone ukukhuluma begodu bathintane ngezindlela ezinengi. Iinkundla zokuthintana sele zingcenye yamaphilo wabantu ngombana zisetjenziswa mihla namalanga.

Okuhle ngenkundla zokuthintana kukobana zikghona ukusiza umuntu bona akgone ukuthintana nabantu abakude naye. Okhunye kukobana zikhipha isizungu begodu umuntu ukhona ukufunda okunengi kizo. Inkundla zokuthintana ziyasiza ukuthuthukisa ilwazi lomuntu nanyana ngesinye isikhathi zingamupha umuntu ilwazi elingasilo.

</text>
      <sha1>2fpyanrjkt18pl9islgagqmij55unrh</sha1>
    </revision>
    <revision>
      <id>3161</id>
      <parentid>3124</parentid>
      <timestamp>2025-06-21T18:41:31Z</timestamp>
      <contributor>
        <ip>85.97.84.231</ip>
      </contributor>
      <origin>3161</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="656" sha1="njyx3iyrm9x62uqslg1fp32yombqbv3" xml:space="preserve">[[File:Common chimpanzee (Pan troglodytes schweinfurthii) feeding.jpg|thumb|Omar al-Bashir is a chimpanzee.]]

'''Iinkundla zokuthintana''' kuyindawo zetheknoloji ezisiza abantu bonyana bakghone ukukhuluma begodu bathintane ngezindlela ezinengi. Iinkundla zokuthintana sele zingcenye yamaphilo wabantu ngombana zisetjenziswa mihla namalanga.

Okuhle ngenkundla zokuthintana kukobana zikghona ukusiza umuntu bona akgone ukuthintana nabantu abakude naye. Okhunye kukobana zikhipha isizungu begodu umuntu ukhona ukufunda okunengi kizo. Inkundla zokuthintana ziyasiza ukuthuthukisa ilwazi lomuntu nanyana ngesinye isikhathi zingamupha umuntu ilwazi elingasilo.</text>
      <sha1>njyx3iyrm9x62uqslg1fp32yombqbv3</sha1>
    </revision>
    <revision>
      <id>3284</id>
      <parentid>3161</parentid>
      <timestamp>2025-07-02T20:38:51Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Undo revision [[Special:Diff/3161|3161]] by [[Special:Contributions/85.97.84.231|85.97.84.231]] ([[User talk:85.97.84.231|talk]])</comment>
      <origin>3284</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="545" sha1="fgl5y9yhhr921480rz6kkvs9wfxbqoy" xml:space="preserve">'''Iinkundla zokuthintana''' kuyindawo zetheknoloji ezisiza abantu bonyana bakghone ukukhuluma begodu bathintane ngezindlela ezinengi. Iinkundla zokuthintana sele zingcenye yamaphilo wabantu ngombana zisetjenziswa mihla namalanga.

Okuhle ngenkundla zokuthintana kukobana zikghona ukusiza umuntu bona akgone ukuthintana nabantu abakude naye. Okhunye kukobana zikhipha isizungu begodu umuntu ukhona ukufunda okunengi kizo. Inkundla zokuthintana ziyasiza ukuthuthukisa ilwazi lomuntu nanyana ngesinye isikhathi zingamupha umuntu ilwazi elingasilo.</text>
      <sha1>fgl5y9yhhr921480rz6kkvs9wfxbqoy</sha1>
    </revision>
  </page>
  <page>
    <title>Intaba</title>
    <ns>0</ns>
    <id>181</id>
    <revision>
      <id>854</id>
      <timestamp>2024-08-04T15:22:55Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Intaba''' kuphakama kwemvelo komhlaba, ngokujayelekileko singathi kuphakama okungaphezu kwama mitha ama-300 ngaphezulu kwendawo yebhoduluko yayo. Intaba ingenziwa zizehlakalo ezehlukeneko zemvelo ezifana nokudubula kwama volcano, ukunyakaza kwama tectonic plates kanye nokurhurhuleka  kwehlabathi. Iintaba zingahlukaniswa ngokwemihlobo ngokuya kokubumbeka, ubukhulu bazo begodu nangokuya kwendawo lapho zikhona.  &quot;</comment>
      <origin>854</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="416" sha1="ga5drr70bsuxppjavwjlcgklbkcjpy6" xml:space="preserve">'''Intaba''' kuphakama kwemvelo komhlaba, ngokujayelekileko singathi kuphakama okungaphezu kwama mitha ama-300 ngaphezulu kwendawo yebhoduluko yayo. Intaba ingenziwa zizehlakalo ezehlukeneko zemvelo ezifana nokudubula kwama volcano, ukunyakaza kwama tectonic plates kanye nokurhurhuleka  kwehlabathi. Iintaba zingahlukaniswa ngokwemihlobo ngokuya kokubumbeka, ubukhulu bazo begodu nangokuya kwendawo lapho zikhona.

</text>
      <sha1>ga5drr70bsuxppjavwjlcgklbkcjpy6</sha1>
    </revision>
    <revision>
      <id>855</id>
      <parentid>854</parentid>
      <timestamp>2024-08-04T15:23:38Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>855</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="420" sha1="npodras9yczq596l4xt4umzgpbzg4km" xml:space="preserve">'''Intaba''' kuphakama kwemvelo komhlaba, ngokujayelekileko singathi kuphakama okungaphezu kwama mitha ama-300 ngaphezulu kwendawo yebhoduluko yayo. [[Intaba]] ingenziwa zizehlakalo ezehlukeneko zemvelo ezifana nokudubula kwama volcano, ukunyakaza kwama tectonic plates kanye nokurhurhuleka  kwehlabathi. Iintaba zingahlukaniswa ngokwemihlobo ngokuya kokubumbeka, ubukhulu bazo begodu nangokuya kwendawo lapho zikhona.

</text>
      <sha1>npodras9yczq596l4xt4umzgpbzg4km</sha1>
    </revision>
    <revision>
      <id>856</id>
      <parentid>855</parentid>
      <timestamp>2024-08-04T15:38:44Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>856</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1142" sha1="rdnl439fy8y1xx6xc9kkgc380i15rkg" xml:space="preserve">'''Intaba''' kuphakama kwemvelo komhlaba, ngokujayelekileko singathi kuphakama okungaphezu kwama mitha ama-300 ngaphezulu kwendawo yebhoduluko yayo. [[Intaba]] ingenziwa zizehlakalo ezehlukeneko zemvelo ezifana nokudubula kwama volcano, ukunyakaza kwama tectonic plates kanye nokurhurhuleka  kwehlabathi. Iintaba zingahlukaniswa ngokwemihlobo ngokuya kokubumbeka, ubukhulu bazo begodu nangokuya kwendawo lapho zikhona. 

== Imihlobo yeentaba ==

=== 1. Intaba ezima  volkheyino ===
Lezi kuzintaba ezakhekako  kade kune volkheyino. isibonelo sentaba ezinjalo yi ntaba ekulu eAfrika intaba i Kilimanjaro eseTanzania.

=== 2. Intaba ezigocekileko ===
Lezi ziintaba ezakheka nanyana ezibumbeka ngokuhlangana nofana ngokuqhulana kwamam tectonic plates lezi kuzintaba ezifana ne Himalayas. 

== Ukuqakatheka kweentaba ==
Iintaba  ziqakathekile ngombana ziyikhaya nofana iindawo yokuhlala yeenlwana kanye neziinye iintjalo zemangweni. Intaba zidlala iindima ekulu ekubumbeni isimo sezulu endaweni eziseduze nayo. Intaba ezikulu ezifana ne [[Table Mountain]] zinikela amathuba amalhle wokuzithabisa, nakwezamavakatjho bogodu nokuthuthukisa umnotho.

</text>
      <sha1>rdnl439fy8y1xx6xc9kkgc380i15rkg</sha1>
    </revision>
    <revision>
      <id>857</id>
      <parentid>856</parentid>
      <timestamp>2024-08-04T15:46:03Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>857</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1518" sha1="2av1oecczw7i7deyviicqbjiaglql8m" xml:space="preserve">'''Intaba''' kuphakama kwemvelo komhlaba, ngokujayelekileko singathi kuphakama okungaphezu kwama mitha ama-300 ngaphezulu kwendawo yebhoduluko yayo. [[Intaba]] ingenziwa zizehlakalo ezehlukeneko zemvelo ezifana nokudubula kwama volcano, ukunyakaza kwama tectonic plates kanye nokurhurhuleka  kwehlabathi&lt;ref&gt;Kirchoff, M.R. and McKinnon, W.B., 2009. Formation of mountains on Io: Variable volcanism and thermal stresses. ''Icarus'', ''201''(2), pp.598-614.&lt;/ref&gt;. Iintaba zingahlukaniswa ngokwemihlobo ngokuya kokubumbeka, ubukhulu bazo begodu nangokuya kwendawo lapho zikhona. 

== Imihlobo yeentaba ==

=== 1. Intaba ezima  volkheyino ===
Lezi kuzintaba ezakhekako  kade kune volkheyino. isibonelo sentaba ezinjalo yi ntaba ekulu eAfrika intaba i Kilimanjaro eseTanzania.

=== 2. Intaba ezigocekileko ===
Lezi ziintaba ezakheka nanyana ezibumbeka ngokuhlangana nofana ngokuqhulana kwamam tectonic plates lezi kuzintaba ezifana ne Himalayas. 

== Ukuqakatheka kweentaba ==
Iintaba  ziqakathekile ngombana ziyikhaya nofana iindawo yokuhlala yeenlwana kanye neziinye iintjalo zemangweni. Intaba zidlala iindima ekulu ekubumbeni isimo sezulu endaweni eziseduze nayo&lt;ref&gt;Shrestha, S., Yao, T. and Adhikari, T.R., 2019. Analysis of rainfall trends of two complex mountain river basins on the southern slopes of the Central Himalayas. ''Atmospheric Research'', ''215'', pp.99-115.&lt;/ref&gt;. Intaba ezikulu ezifana ne [[Table Mountain]] zinikela amathuba amalhle wokuzithabisa, nakwezamavakatjho bogodu nokuthuthukisa umnotho.

</text>
      <sha1>2av1oecczw7i7deyviicqbjiaglql8m</sha1>
    </revision>
    <revision>
      <id>858</id>
      <parentid>857</parentid>
      <timestamp>2024-08-04T15:48:52Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>858</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1534" sha1="nkk33hz05ks3fl5sbnmih96v4mhw7fh" xml:space="preserve">'''Intaba''' kuphakama kwemvelo komhlaba, ngokujayelekileko singathi kuphakama okungaphezu kwama mitha ama-300 ngaphezulu kwendawo yebhoduluko yayo. [[Intaba]] ingenziwa zizehlakalo ezehlukeneko zemvelo ezifana nokudubula kwama volcano, ukunyakaza kwama tectonic plates kanye nokurhurhuleka  kwehlabathi&lt;ref&gt;Kirchoff, M.R. and McKinnon, W.B., 2009. Formation of mountains on Io: Variable volcanism and thermal stresses. ''Icarus'', ''201''(2), pp.598-614.&lt;/ref&gt;. Iintaba zingahlukaniswa ngokwemihlobo ngokuya kokubumbeka, ubukhulu bazo begodu nangokuya kwendawo lapho zikhona. 

== Imihlobo yeentaba ==

=== 1. Intaba ezima  volkheyino ===
Lezi kuzintaba ezakhekako  kade kune volkheyino. isibonelo sentaba ezinjalo yi ntaba ekulu eAfrika intaba i Kilimanjaro eseTanzania.

=== 2. Intaba ezigocekileko ===
Lezi ziintaba ezakheka nanyana ezibumbeka ngokuhlangana nofana ngokuqhulana kwamam tectonic plates lezi kuzintaba ezifana ne Himalayas. 

== Ukuqakatheka kweentaba ==
Iintaba  ziqakathekile ngombana ziyikhaya nofana iindawo yokuhlala yeenlwana kanye neziinye iintjalo zemangweni. Intaba zidlala iindima ekulu ekubumbeni isimo sezulu endaweni eziseduze nayo&lt;ref&gt;Shrestha, S., Yao, T. and Adhikari, T.R., 2019. Analysis of rainfall trends of two complex mountain river basins on the southern slopes of the Central Himalayas. ''Atmospheric Research'', ''215'', pp.99-115.&lt;/ref&gt;. Intaba ezikulu ezifana ne [[Table Mountain]] zinikela amathuba amalhle wokuzithabisa, nakwezamavakatjho bogodu nokuthuthukisa umnotho wenarha ezikiyo.

</text>
      <sha1>nkk33hz05ks3fl5sbnmih96v4mhw7fh</sha1>
    </revision>
    <revision>
      <id>859</id>
      <parentid>858</parentid>
      <timestamp>2024-08-12T17:00:51Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>859</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1585" sha1="2ri9a8rbgdjh9h4sbd36ti60ulpdqv1" xml:space="preserve">[[Isimumathi:Entabeni.jpg|thumb|phezulu entabeni]]
'''Intaba''' kuphakama kwemvelo komhlaba, ngokujayelekileko singathi kuphakama okungaphezu kwama mitha ama-300 ngaphezulu kwendawo yebhoduluko yayo. [[Intaba]] ingenziwa zizehlakalo ezehlukeneko zemvelo ezifana nokudubula kwama volcano, ukunyakaza kwama tectonic plates kanye nokurhurhuleka  kwehlabathi&lt;ref&gt;Kirchoff, M.R. and McKinnon, W.B., 2009. Formation of mountains on Io: Variable volcanism and thermal stresses. ''Icarus'', ''201''(2), pp.598-614.&lt;/ref&gt;. Iintaba zingahlukaniswa ngokwemihlobo ngokuya kokubumbeka, ubukhulu bazo begodu nangokuya kwendawo lapho zikhona. 

== Imihlobo yeentaba ==

=== 1. Intaba ezima  volkheyino ===
Lezi kuzintaba ezakhekako  kade kune volkheyino. isibonelo sentaba ezinjalo yi ntaba ekulu eAfrika intaba i Kilimanjaro eseTanzania.

=== 2. Intaba ezigocekileko ===
Lezi ziintaba ezakheka nanyana ezibumbeka ngokuhlangana nofana ngokuqhulana kwamam tectonic plates lezi kuzintaba ezifana ne Himalayas. 

== Ukuqakatheka kweentaba ==
Iintaba  ziqakathekile ngombana ziyikhaya nofana iindawo yokuhlala yeenlwana kanye neziinye iintjalo zemangweni. Intaba zidlala iindima ekulu ekubumbeni isimo sezulu endaweni eziseduze nayo&lt;ref&gt;Shrestha, S., Yao, T. and Adhikari, T.R., 2019. Analysis of rainfall trends of two complex mountain river basins on the southern slopes of the Central Himalayas. ''Atmospheric Research'', ''215'', pp.99-115.&lt;/ref&gt;. Intaba ezikulu ezifana ne [[Table Mountain]] zinikela amathuba amalhle wokuzithabisa, nakwezamavakatjho bogodu nokuthuthukisa umnotho wenarha ezikiyo.

</text>
      <sha1>2ri9a8rbgdjh9h4sbd36ti60ulpdqv1</sha1>
    </revision>
    <revision>
      <id>860</id>
      <parentid>859</parentid>
      <timestamp>2024-10-14T13:46:52Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>6 revisions imported</comment>
      <origin>859</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1585" sha1="2ri9a8rbgdjh9h4sbd36ti60ulpdqv1" xml:space="preserve">[[Isimumathi:Entabeni.jpg|thumb|phezulu entabeni]]
'''Intaba''' kuphakama kwemvelo komhlaba, ngokujayelekileko singathi kuphakama okungaphezu kwama mitha ama-300 ngaphezulu kwendawo yebhoduluko yayo. [[Intaba]] ingenziwa zizehlakalo ezehlukeneko zemvelo ezifana nokudubula kwama volcano, ukunyakaza kwama tectonic plates kanye nokurhurhuleka  kwehlabathi&lt;ref&gt;Kirchoff, M.R. and McKinnon, W.B., 2009. Formation of mountains on Io: Variable volcanism and thermal stresses. ''Icarus'', ''201''(2), pp.598-614.&lt;/ref&gt;. Iintaba zingahlukaniswa ngokwemihlobo ngokuya kokubumbeka, ubukhulu bazo begodu nangokuya kwendawo lapho zikhona. 

== Imihlobo yeentaba ==

=== 1. Intaba ezima  volkheyino ===
Lezi kuzintaba ezakhekako  kade kune volkheyino. isibonelo sentaba ezinjalo yi ntaba ekulu eAfrika intaba i Kilimanjaro eseTanzania.

=== 2. Intaba ezigocekileko ===
Lezi ziintaba ezakheka nanyana ezibumbeka ngokuhlangana nofana ngokuqhulana kwamam tectonic plates lezi kuzintaba ezifana ne Himalayas. 

== Ukuqakatheka kweentaba ==
Iintaba  ziqakathekile ngombana ziyikhaya nofana iindawo yokuhlala yeenlwana kanye neziinye iintjalo zemangweni. Intaba zidlala iindima ekulu ekubumbeni isimo sezulu endaweni eziseduze nayo&lt;ref&gt;Shrestha, S., Yao, T. and Adhikari, T.R., 2019. Analysis of rainfall trends of two complex mountain river basins on the southern slopes of the Central Himalayas. ''Atmospheric Research'', ''215'', pp.99-115.&lt;/ref&gt;. Intaba ezikulu ezifana ne [[Table Mountain]] zinikela amathuba amalhle wokuzithabisa, nakwezamavakatjho bogodu nokuthuthukisa umnotho wenarha ezikiyo.

</text>
      <sha1>2ri9a8rbgdjh9h4sbd36ti60ulpdqv1</sha1>
    </revision>
    <revision>
      <id>2173</id>
      <parentid>860</parentid>
      <timestamp>2024-11-27T06:47:36Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>+ Iinkomba</comment>
      <origin>2173</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1610" sha1="rkf0vtg77krmmp7s15qtvmta31as2ew" xml:space="preserve">[[Isimumathi:Entabeni.jpg|thumb|phezulu entabeni]]
'''Intaba''' kuphakama kwemvelo komhlaba, ngokujayelekileko singathi kuphakama okungaphezu kwama mitha ama-300 ngaphezulu kwendawo yebhoduluko yayo. [[Intaba]] ingenziwa zizehlakalo ezehlukeneko zemvelo ezifana nokudubula kwama volcano, ukunyakaza kwama tectonic plates kanye nokurhurhuleka  kwehlabathi&lt;ref&gt;Kirchoff, M.R. and McKinnon, W.B., 2009. Formation of mountains on Io: Variable volcanism and thermal stresses. ''Icarus'', ''201''(2), pp.598-614.&lt;/ref&gt;. Iintaba zingahlukaniswa ngokwemihlobo ngokuya kokubumbeka, ubukhulu bazo begodu nangokuya kwendawo lapho zikhona. 

== Imihlobo yeentaba ==
=== 1. Intaba ezima  volkheyino ===
Lezi kuzintaba ezakhekako  kade kune volkheyino. isibonelo sentaba ezinjalo yi ntaba ekulu eAfrika intaba i Kilimanjaro eseTanzania.

=== 2. Intaba ezigocekileko ===
Lezi ziintaba ezakheka nanyana ezibumbeka ngokuhlangana nofana ngokuqhulana kwamam tectonic plates lezi kuzintaba ezifana ne Himalayas. 

== Ukuqakatheka kweentaba ==
Iintaba  ziqakathekile ngombana ziyikhaya nofana iindawo yokuhlala yeenlwana kanye neziinye iintjalo zemangweni. Intaba zidlala iindima ekulu ekubumbeni isimo sezulu endaweni eziseduze nayo&lt;ref&gt;Shrestha, S., Yao, T. and Adhikari, T.R., 2019. Analysis of rainfall trends of two complex mountain river basins on the southern slopes of the Central Himalayas. ''Atmospheric Research'', ''215'', pp.99-115.&lt;/ref&gt;. Intaba ezikulu ezifana ne [[Table Mountain]] zinikela amathuba amalhle wokuzithabisa, nakwezamavakatjho bogodu nokuthuthukisa umnotho wenarha ezikiyo.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>rkf0vtg77krmmp7s15qtvmta31as2ew</sha1>
    </revision>
  </page>
  <page>
    <title>Intaba iKilimanjaro</title>
    <ns>0</ns>
    <id>182</id>
    <revision>
      <id>861</id>
      <timestamp>2024-07-05T16:30:14Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Intaba''' iKilimnajaro yintaba ekulu ukuzidlula zoke eAfrika. Itholakala eTanzania  &quot;</comment>
      <origin>861</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="87" sha1="rbp7gwwubk82uyaipf3i4eietiebjo4" xml:space="preserve">'''Intaba''' iKilimnajaro yintaba ekulu ukuzidlula zoke eAfrika. Itholakala eTanzania

</text>
      <sha1>rbp7gwwubk82uyaipf3i4eietiebjo4</sha1>
    </revision>
    <revision>
      <id>862</id>
      <parentid>861</parentid>
      <timestamp>2024-07-05T16:30:44Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>862</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="87" sha1="ac4w0ysc7cv8bbd99qvcvwpliu0oo04" xml:space="preserve">'''Intaba''' iKilimanjaro yintaba ekulu ukuzidlula zoke eAfrika. Itholakala eTanzania

</text>
      <sha1>ac4w0ysc7cv8bbd99qvcvwpliu0oo04</sha1>
    </revision>
    <revision>
      <id>863</id>
      <parentid>862</parentid>
      <timestamp>2024-07-05T16:34:47Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>863</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="160" sha1="725nkjhna1q8wq18fkm32vgsyrcjtfb" xml:space="preserve">[[Isimumathi:Mount Kilimanjaro.jpg|thumb|Isthombe sentaba iKilimanjaro]]
'''Intaba''' iKilimanjaro yintaba ekulu ukuzidlula zoke eAfrika. Itholakala eTanzania

</text>
      <sha1>725nkjhna1q8wq18fkm32vgsyrcjtfb</sha1>
    </revision>
    <revision>
      <id>864</id>
      <parentid>863</parentid>
      <timestamp>2024-07-05T19:12:57Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>864</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="615" sha1="olrgviqyb3zb63r6kelcasy5vd6gln3" xml:space="preserve">[[Isimumathi:Mount Kilimanjaro.jpg|thumb|Isthombe sentaba iKilimanjaro]]
'''Intaba''' iKilimanjaro yintaba ekulu ukuzidlula zoke e-Afrika. Itholakala enarheni ye Tanzania. Intaba le yihle ngokwemvelo begodu kiyo kutholakala iimbandana namathuthumbo athileko. Ngobuhle bayo idosa amathoristi bona ayivakatjhele. 

Abantu abanekareke kwezemidlalo basuke bayikhuphuke intaba le ngokusebenzisa indlela ezitholakala lapho entabeni. Indlela lezi yokuthoma yi marangu route, le yindlela eyaziwa khulu entabeni iKilimanjaro begodu kuthiwa ngiyo elula. Yesibili indlela yiMachame route begodu kune Rongai ne Lemosho route.

</text>
      <sha1>olrgviqyb3zb63r6kelcasy5vd6gln3</sha1>
    </revision>
    <revision>
      <id>865</id>
      <parentid>864</parentid>
      <timestamp>2024-10-14T13:46:52Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>4 revisions imported</comment>
      <origin>864</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="615" sha1="olrgviqyb3zb63r6kelcasy5vd6gln3" xml:space="preserve">[[Isimumathi:Mount Kilimanjaro.jpg|thumb|Isthombe sentaba iKilimanjaro]]
'''Intaba''' iKilimanjaro yintaba ekulu ukuzidlula zoke e-Afrika. Itholakala enarheni ye Tanzania. Intaba le yihle ngokwemvelo begodu kiyo kutholakala iimbandana namathuthumbo athileko. Ngobuhle bayo idosa amathoristi bona ayivakatjhele. 

Abantu abanekareke kwezemidlalo basuke bayikhuphuke intaba le ngokusebenzisa indlela ezitholakala lapho entabeni. Indlela lezi yokuthoma yi marangu route, le yindlela eyaziwa khulu entabeni iKilimanjaro begodu kuthiwa ngiyo elula. Yesibili indlela yiMachame route begodu kune Rongai ne Lemosho route.

</text>
      <sha1>olrgviqyb3zb63r6kelcasy5vd6gln3</sha1>
    </revision>
  </page>
  <page>
    <title>Intanga zama Ndebele wakwa Nzunza</title>
    <ns>0</ns>
    <id>183</id>
    <revision>
      <id>866</id>
      <timestamp>2024-03-08T13:37:32Z</timestamp>
      <contributor>
        <username>incubator&gt;Thandeka179</username>
        <id>0</id>
      </contributor>
      <comment>Created this page</comment>
      <origin>866</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="179" sha1="klzu8ofn7v9ydkhay6cm69qv6s55kzi" xml:space="preserve">'''Intanga zesiNdebele wakwa Nzunza'''

Duba(Libunzwana)

Dlowu(Liganadlha)

Dlhari(Libasa)

Nyathi(Ngudukuza ongafiko yisiqurhwana sengonga)

Rudla(Maswebalanga ngusomtjhongweni)</text>
      <sha1>klzu8ofn7v9ydkhay6cm69qv6s55kzi</sha1>
    </revision>
    <revision>
      <id>867</id>
      <parentid>866</parentid>
      <timestamp>2024-10-14T13:46:52Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>866</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="179" sha1="klzu8ofn7v9ydkhay6cm69qv6s55kzi" xml:space="preserve">'''Intanga zesiNdebele wakwa Nzunza'''

Duba(Libunzwana)

Dlowu(Liganadlha)

Dlhari(Libasa)

Nyathi(Ngudukuza ongafiko yisiqurhwana sengonga)

Rudla(Maswebalanga ngusomtjhongweni)</text>
      <sha1>klzu8ofn7v9ydkhay6cm69qv6s55kzi</sha1>
    </revision>
  </page>
  <page>
    <title>Inzondo</title>
    <ns>0</ns>
    <id>184</id>
    <revision>
      <id>868</id>
      <timestamp>2024-07-10T09:47:16Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Inzondo''' mimizwa emimbi begodu enamandla begodu angaba nemiphumela emimbi ekugcineni. Mimizwa umuntu aba nayo yokungathandi umuntu, isiqhema esithileko, namyana umbono othileko. Inzondo ingavela  ngendlela ezinengi ngokuya komuntu. Okhunye ibonakala ngokuthi umuntu abenebandlulo elithileko godu ngokuthi afuna ukubanga ukulwa ngamalanga. inzondo yenza umuntu afune ukuziphindiselela lokha nangabe wenziwe into embi. inzondo kuyinto engakalungi ngombana iyabanga  bonyan...&quot;</comment>
      <origin>868</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="525" sha1="f66y73iw6x5vf7y4h4enc8mexkc27hv" xml:space="preserve">'''Inzondo''' mimizwa emimbi begodu enamandla begodu angaba nemiphumela emimbi ekugcineni. Mimizwa umuntu aba nayo yokungathandi umuntu, isiqhema esithileko, namyana umbono othileko. Inzondo ingavela  ngendlela ezinengi ngokuya komuntu. Okhunye ibonakala ngokuthi umuntu abenebandlulo elithileko godu ngokuthi afuna ukubanga ukulwa ngamalanga. inzondo yenza umuntu afune ukuziphindiselela lokha nangabe wenziwe into embi. inzondo kuyinto engakalungi ngombana iyabanga  bonyana umuntu agcine sele angasaboni ubuhle benzinto.

</text>
      <sha1>f66y73iw6x5vf7y4h4enc8mexkc27hv</sha1>
    </revision>
    <revision>
      <id>869</id>
      <parentid>868</parentid>
      <timestamp>2024-07-10T09:50:05Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>869</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="529" sha1="ttw7oia35mwmpu98jg68872al9pjgzg" xml:space="preserve">'''Inzondo''' m[[imizwa]] emimbi begodu enamandla begodu angaba nemiphumela emimbi ekugcineni. Mimizwa umuntu aba nayo yokungathandi umuntu, isiqhema esithileko, namyana umbono othileko. Inzondo ingavela  ngendlela ezinengi ngokuya komuntu. Okhunye ibonakala ngokuthi umuntu abenebandlulo elithileko godu ngokuthi afuna ukubanga ukulwa ngamalanga. inzondo yenza umuntu afune ukuziphindiselela lokha nangabe wenziwe into embi. inzondo kuyinto engakalungi ngombana iyabanga  bonyana umuntu agcine sele angasaboni ubuhle benzinto.

</text>
      <sha1>ttw7oia35mwmpu98jg68872al9pjgzg</sha1>
    </revision>
    <revision>
      <id>870</id>
      <parentid>869</parentid>
      <timestamp>2024-07-13T19:50:51Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>870</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="529" sha1="1vjbiljqoz43gwx4hi8l9soawftwbli" xml:space="preserve">'''Inzondo''' m[[imizwa]] emimbi begodu enamandla begodu angaba nemiphumela emimbi ekugcineni. Mimizwa umuntu aba nayo yokungathandi umuntu, isiqhema esithileko, nanyana umbono othileko. Inzondo ingavela  ngendlela ezinengi ngokuya komuntu. Okhunye ibonakala ngokuthi umuntu abenebandlulo elithileko godu ngokuthi afuna ukubanga ukulwa ngamalanga. Inzondo yenza umuntu afune ukuziphindiselela lokha nangabe wenziwe into embi. Inzondo kuyinto engakalungi ngombana iyabanga  bonyana umuntu agcine sele angasaboni ubuhle benzinto.

</text>
      <sha1>1vjbiljqoz43gwx4hi8l9soawftwbli</sha1>
    </revision>
    <revision>
      <id>871</id>
      <parentid>870</parentid>
      <timestamp>2024-10-14T13:46:52Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>870</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="529" sha1="1vjbiljqoz43gwx4hi8l9soawftwbli" xml:space="preserve">'''Inzondo''' m[[imizwa]] emimbi begodu enamandla begodu angaba nemiphumela emimbi ekugcineni. Mimizwa umuntu aba nayo yokungathandi umuntu, isiqhema esithileko, nanyana umbono othileko. Inzondo ingavela  ngendlela ezinengi ngokuya komuntu. Okhunye ibonakala ngokuthi umuntu abenebandlulo elithileko godu ngokuthi afuna ukubanga ukulwa ngamalanga. Inzondo yenza umuntu afune ukuziphindiselela lokha nangabe wenziwe into embi. Inzondo kuyinto engakalungi ngombana iyabanga  bonyana umuntu agcine sele angasaboni ubuhle benzinto.

</text>
      <sha1>1vjbiljqoz43gwx4hi8l9soawftwbli</sha1>
    </revision>
    <revision>
      <id>2504</id>
      <parentid>871</parentid>
      <timestamp>2025-03-05T14:43:27Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2504</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="527" sha1="jiu2tbgbwd4xbc6dwdr4tk19zgjol8n" xml:space="preserve">'''Inzondo''' m[[imizwa]] emimbi begodu enamandla begodu engaba nemiphumela emimbi ekugcineni. Mimizwa umuntu aba nayo yokungathandi umuntu, isiqhema esithileko, nanyana umbono othileko. Inzondo ingavela  ngendlela ezinengi ngokuya komuntu. Okhunye ibonakala ngokuthi umuntu abenebandlulo elithileko godu ngokuthi afuna ukubanga ukulwa ngamalanga. Inzondo yenza umuntu afune ukuziphindiselela lokha nangabe wenziwe into embi. Inzondo kuyinto engakalungi ngombana iyabanga  bonyana umuntu agcine sele angasaboni ubuhle benzinto.</text>
      <sha1>jiu2tbgbwd4xbc6dwdr4tk19zgjol8n</sha1>
    </revision>
  </page>
  <page>
    <title>Iqude leSindebele</title>
    <ns>0</ns>
    <id>185</id>
    <revision>
      <id>872</id>
      <timestamp>2024-03-08T13:46:22Z</timestamp>
      <contributor>
        <username>incubator&gt;Lethabo19</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;Umnyanya wequde kukhuliswa komntwana womntazana esikweni lamaNdebele. Kunemnihlobohlobo, nangendlela ikambiso yeQude iyenzeka ngayo. Kumnyanya lapho kugidingwa khona ukukhuliswa komntazana, ngokumhlabela isibandana nangokumupha izipho ezahlukahlukeneko.  &quot;</comment>
      <origin>872</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="255" sha1="4jthxdy20a5cv814av73cg4xirubi7n" xml:space="preserve">Umnyanya wequde kukhuliswa komntwana womntazana esikweni lamaNdebele. Kunemnihlobohlobo, nangendlela ikambiso yeQude iyenzeka ngayo. Kumnyanya lapho kugidingwa khona ukukhuliswa komntazana, ngokumhlabela isibandana nangokumupha izipho ezahlukahlukeneko.

</text>
      <sha1>4jthxdy20a5cv814av73cg4xirubi7n</sha1>
    </revision>
    <revision>
      <id>873</id>
      <parentid>872</parentid>
      <timestamp>2024-03-09T07:32:55Z</timestamp>
      <contributor>
        <username>incubator&gt;Lethabo19</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>I have linked another page</comment>
      <origin>873</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="265" sha1="3thcifj3baj0rd53lc6wnrsnnkn60zm" xml:space="preserve">'''Umnyanya wequde''' kukhuliswa komntwana womntazana esikweni lama[[Ndebele]]. Kunemnihlobohlobo, nangendlela ikambiso yeQude iyenzeka ngayo. Kumnyanya lapho kugidingwa khona ukukhuliswa komntazana, ngokumhlabela isibandana nangokumupha izipho ezahlukahlukeneko.

</text>
      <sha1>3thcifj3baj0rd53lc6wnrsnnkn60zm</sha1>
    </revision>
    <revision>
      <id>874</id>
      <parentid>873</parentid>
      <timestamp>2024-10-14T13:46:53Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>873</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="265" sha1="3thcifj3baj0rd53lc6wnrsnnkn60zm" xml:space="preserve">'''Umnyanya wequde''' kukhuliswa komntwana womntazana esikweni lama[[Ndebele]]. Kunemnihlobohlobo, nangendlela ikambiso yeQude iyenzeka ngayo. Kumnyanya lapho kugidingwa khona ukukhuliswa komntazana, ngokumhlabela isibandana nangokumupha izipho ezahlukahlukeneko.

</text>
      <sha1>3thcifj3baj0rd53lc6wnrsnnkn60zm</sha1>
    </revision>
  </page>
  <page>
    <title>Irhabha</title>
    <ns>0</ns>
    <id>186</id>
    <revision>
      <id>875</id>
      <timestamp>2024-06-30T17:34:21Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Irhabha'''kuyinto yesintu yokuvubela.  &quot;</comment>
      <origin>875</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="42" sha1="4zlq4elz53bjglli8jq8xfs6zcftjbp" xml:space="preserve">'''Irhabha'''kuyinto yesintu yokuvubela.

</text>
      <sha1>4zlq4elz53bjglli8jq8xfs6zcftjbp</sha1>
    </revision>
    <revision>
      <id>876</id>
      <parentid>875</parentid>
      <timestamp>2024-06-30T17:34:37Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>876</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="43" sha1="o2g7fyg2k0rypjf8g45df5278lwg1kp" xml:space="preserve">'''Irhabha''' kuyinto yesintu yokuvubela.

</text>
      <sha1>o2g7fyg2k0rypjf8g45df5278lwg1kp</sha1>
    </revision>
    <revision>
      <id>877</id>
      <parentid>876</parentid>
      <timestamp>2024-06-30T17:36:19Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>877</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="131" sha1="kotvs9zphm1eux6gjhsadi21m6ux3jr" xml:space="preserve">[[Isimumathi:Calabash (Lagenaria siceraria) in Seoul.jpg|thumb|irhabha elisatjaliweko]]
'''Irhabha''' kuyinto yesintu yokuvubela.

</text>
      <sha1>kotvs9zphm1eux6gjhsadi21m6ux3jr</sha1>
    </revision>
    <revision>
      <id>878</id>
      <parentid>877</parentid>
      <timestamp>2024-06-30T17:38:53Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>878</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="225" sha1="8dz4is2sar8ro5jrr3zqnw4et6r3w57" xml:space="preserve">[[Isimumathi:Calabash (Lagenaria siceraria) in Seoul.jpg|thumb|irhabha elisatjaliweko]]
[[Isimumathi:Bissap - gourd calabash with dried leaves, Hibiscus sabdariffa.jpg|thumb|Ikapo]]
'''Irhabha''' kuyinto yesintu yokuvubela.

</text>
      <sha1>8dz4is2sar8ro5jrr3zqnw4et6r3w57</sha1>
    </revision>
    <revision>
      <id>879</id>
      <parentid>878</parentid>
      <timestamp>2024-06-30T17:40:39Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>879</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="235" sha1="2l1frq0ej9eps2maezgj3f69xc0shg5" xml:space="preserve">[[Isimumathi:Calabash (Lagenaria siceraria) in Seoul.jpg|thumb|irhabha elisatjaliweko]]
[[Isimumathi:Bissap - gourd calabash with dried leaves, Hibiscus sabdariffa.jpg|thumb|Ikapo]]
'''Irhabha''' kuyinto yesintu esebenza njesigubhu. 

</text>
      <sha1>2l1frq0ej9eps2maezgj3f69xc0shg5</sha1>
    </revision>
    <revision>
      <id>880</id>
      <parentid>879</parentid>
      <timestamp>2024-06-30T18:34:51Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>880</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="908" sha1="kfrqnidg0sl4c02ad3dfzvemr43jg6r" xml:space="preserve">[[Isimumathi:Calabash (Lagenaria siceraria) in Seoul.jpg|thumb|irhabha elisatjaliweko]]
[[Isimumathi:Bissap - gourd calabash with dried leaves, Hibiscus sabdariffa.jpg|thumb|Ikapo]]
'''Irhabha''' kuyinto yesintu esebenza njesigubhu. Irhabha lisetjenziswa ukufaka utjwala besintu obufana netlabalala.  Irhabha liyinto yemvelo ngombana liyatjalwa bese lomiswe kukhitjhwe intanga ngaphathi kuthi nasele lome kuhle lisetjenziswe ukufaka izinto ezimanzi.  

Okhunye godu ngerhabha kukuthi liyasikwa kuhle phakathi lilingane kwenziwe into ekuthiwa bona yikapo. Ikapho ingasetjenziswa njengesitja ukudlela nanyana ukufaka izinto ezifana nepuphu, Ireysi nokukhunye. 

Irhabha nekapho kuzizinto eziqakathekileko emasikweni wabantu abanzima ngombana zisetjenziswa khulu lokha nakunrminyanya ukusela nokuvubela utswala. Zibuye zihlotjiswe zibe yincenye yoburhwari zithengiswele imvakatjhi ukuthi ziyokuhlobisa ngazo. 

</text>
      <sha1>kfrqnidg0sl4c02ad3dfzvemr43jg6r</sha1>
    </revision>
    <revision>
      <id>881</id>
      <parentid>880</parentid>
      <timestamp>2024-10-14T13:46:53Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>6 revisions imported</comment>
      <origin>880</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="908" sha1="kfrqnidg0sl4c02ad3dfzvemr43jg6r" xml:space="preserve">[[Isimumathi:Calabash (Lagenaria siceraria) in Seoul.jpg|thumb|irhabha elisatjaliweko]]
[[Isimumathi:Bissap - gourd calabash with dried leaves, Hibiscus sabdariffa.jpg|thumb|Ikapo]]
'''Irhabha''' kuyinto yesintu esebenza njesigubhu. Irhabha lisetjenziswa ukufaka utjwala besintu obufana netlabalala.  Irhabha liyinto yemvelo ngombana liyatjalwa bese lomiswe kukhitjhwe intanga ngaphathi kuthi nasele lome kuhle lisetjenziswe ukufaka izinto ezimanzi.  

Okhunye godu ngerhabha kukuthi liyasikwa kuhle phakathi lilingane kwenziwe into ekuthiwa bona yikapo. Ikapho ingasetjenziswa njengesitja ukudlela nanyana ukufaka izinto ezifana nepuphu, Ireysi nokukhunye. 

Irhabha nekapho kuzizinto eziqakathekileko emasikweni wabantu abanzima ngombana zisetjenziswa khulu lokha nakunrminyanya ukusela nokuvubela utswala. Zibuye zihlotjiswe zibe yincenye yoburhwari zithengiswele imvakatjhi ukuthi ziyokuhlobisa ngazo. 

</text>
      <sha1>kfrqnidg0sl4c02ad3dfzvemr43jg6r</sha1>
    </revision>
    <revision>
      <id>2462</id>
      <parentid>881</parentid>
      <timestamp>2025-02-23T17:36:05Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2462</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="905" sha1="njdzxdmq6ese9dm4cjzaj968iu1308r" xml:space="preserve">[[Isimumathi:Calabash (Lagenaria siceraria) in Seoul.jpg|thumb|irhabha elisatjaliweko]]
[[Isimumathi:Bissap - gourd calabash with dried leaves, Hibiscus sabdariffa.jpg|thumb|Ikapo]]
'''Irhabha''' kuyinto yesintu esebenza njesigubhu. Irhabha lisetjenziswa ukufaka utjwala besintu obufana netlabalala.  Irhabha liyinto yemvelo ngombana liyatjalwa bese lomiswe kukhitjhwe intanga ngaphathi kuthi nasele lome kuhle lisetjenziswe ukufaka izinto ezimanzi.  

Okhunye godu ngerhabha kukuthi liyasikwa kuhle phakathi lilingane kwenziwe into ekuthiwa bona yikapo. Ikapho ingasetjenziswa njengesitja ukudlela nanyana ukufaka izinto ezifana nepuphu, Ireysi nokukhunye. 

Irhabha nekapho kuzizinto eziqakathekileko emasikweni wabantu abanzima ngombana zisetjenziswa khulu lokha nakuneminyanya ukusela nokuvubela utswala. Zibuye zihlotjiswe zibe yincenye yoburhwari zithengiswele imvakatjhi ukuthi ziyokuhlobisa ngazo.</text>
      <sha1>njdzxdmq6ese9dm4cjzaj968iu1308r</sha1>
    </revision>
  </page>
  <page>
    <title>Isewula Afrika</title>
    <ns>0</ns>
    <id>187</id>
    <revision>
      <id>882</id>
      <timestamp>2022-04-01T12:45:20Z</timestamp>
      <contributor>
        <ip>62.4.43.163</ip>
      </contributor>
      <comment>Created page with &quot;Isewula Afrika&quot;</comment>
      <origin>882</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="14" sha1="b1040kwconlgjozx1l1iqr8aq4ne5gt" xml:space="preserve">Isewula Afrika</text>
      <sha1>b1040kwconlgjozx1l1iqr8aq4ne5gt</sha1>
    </revision>
    <revision>
      <id>883</id>
      <parentid>882</parentid>
      <timestamp>2024-03-08T10:09:54Z</timestamp>
      <contributor>
        <ip>196.21.175.1</ip>
      </contributor>
      <comment>I have named the provinces found in South Africa</comment>
      <origin>883</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="167" sha1="c6qwfedgf0prjrkhue4pu0bbuvibdj5" xml:space="preserve">ISewula Afrika ineemphande ezilithoba ezilandelako: Mpumalanga, Gauteng, Free State, North West, Northern Cape, Kwa-Zulu Natal, Limpopo, Eastern Cape, ne Western Cape.</text>
      <sha1>c6qwfedgf0prjrkhue4pu0bbuvibdj5</sha1>
    </revision>
    <revision>
      <id>884</id>
      <parentid>883</parentid>
      <timestamp>2024-03-08T10:12:56Z</timestamp>
      <contributor>
        <ip>196.21.175.1</ip>
      </contributor>
      <comment>I put a bold</comment>
      <origin>884</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="173" sha1="qrv31qcxhh2ajgtg2twwswth4qhypf6" xml:space="preserve">'''ISewula Afrika''' ineemphande ezilithoba ezilandelako: Mpumalanga, Gauteng, Free State, North West, Northern Cape, Kwa-Zulu Natal, Limpopo, Eastern Cape, ne Western Cape.</text>
      <sha1>qrv31qcxhh2ajgtg2twwswth4qhypf6</sha1>
    </revision>
    <revision>
      <id>885</id>
      <parentid>884</parentid>
      <timestamp>2024-03-08T10:18:57Z</timestamp>
      <contributor>
        <username>incubator&gt;Mbandeni</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>I have highlighted the smallest province in South Africa</comment>
      <origin>885</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="246" sha1="h3a9374tiqg95ku066nzn8j1w9kytx9" xml:space="preserve">'''ISewula Afrika''' ineemphande ezilithoba ezilandelako: Mpumalanga, Gauteng, Free State, North West, Northern Cape, Kwa-Zulu Natal, Limpopo, Eastern Cape, ne Western Cape. Hlangana kweemphande ezibalwe ngehla i-Gauteng ngiyo encani kunazo zoke.</text>
      <sha1>h3a9374tiqg95ku066nzn8j1w9kytx9</sha1>
    </revision>
    <revision>
      <id>886</id>
      <parentid>885</parentid>
      <timestamp>2024-03-08T10:20:49Z</timestamp>
      <contributor>
        <username>incubator&gt;Mosakaruka</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>I've changed the number of people living in South Afrika</comment>
      <origin>886</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="407" sha1="imfyetucyae3pm1l5u3m1qbeqk4ydeu" xml:space="preserve">'''ISewula Afrika''' yinarha esesewula enarhakazini ekulu '''ye-Afrika.''' Inabantu abangaba mamiliyoni angaphezu kwama-62, abakhuluma amalimi ambadlwana, kodwana ali-11 wakhona asemthethweni. Yinarha yesi-23 erhelweni leenarha ezinabantu abanengi ukuzidlula zoke ephasini. Amaphesente ama-80 mhlobo wabantu abanzima ababelethelwe kilenarha, kanti ama-20 ngoweminye imihlobo evela eenarheni ezingaphandle.

</text>
      <sha1>imfyetucyae3pm1l5u3m1qbeqk4ydeu</sha1>
    </revision>
    <revision>
      <id>887</id>
      <parentid>886</parentid>
      <timestamp>2024-03-08T10:26:53Z</timestamp>
      <contributor>
        <username>incubator&gt;Mosakaruka</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Put subheading</comment>
      <origin>887</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="471" sha1="cygk1xip85jl3jly2sbthqyki0udeev" xml:space="preserve">'''ISewula Afrika''' yinarha esesewula enarhakazini ekulu '''ye-Afrika.''' Inabantu abangaba mamiliyoni angaphezu kwama-62, abahlala eemfundeni ezilithoba, abakhuluma amalimi ambadlwana, kodwana ali-11 wakhona asemthethweni. Yinarha yesi-23 erhelweni leenarha ezinabantu abanengi ukuzidlula zoke ephasini. Amaphesente ama-80 mhlobo wabantu abanzima ababelethelwe kilenarha, kanti ama-20 ngoweminye imihlobo evela eenarheni ezingaphandle.

=== Umlando WeSewula Afrika ===
</text>
      <sha1>cygk1xip85jl3jly2sbthqyki0udeev</sha1>
    </revision>
    <revision>
      <id>888</id>
      <parentid>887</parentid>
      <timestamp>2024-03-08T10:28:25Z</timestamp>
      <contributor>
        <username>incubator&gt;Mosakaruka</username>
        <id>0</id>
      </contributor>
      <comment>I've inserted a link</comment>
      <origin>888</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="559" sha1="p9x9rlvxth1ckd3usgid9dj6ypoyq3p" xml:space="preserve">'''ISewula Afrika''' yinarha esesewula enarhakazini ekulu '''ye-Afrika.''' Inabantu abangaba mamiliyoni angaphezu kwama-62, abahlala eemfundeni ezilithoba, abakhuluma amalimi ambadlwana, kodwana ali-11 wakhona asemthethweni. Yinarha yesi-23 erhelweni leenarha ezinabantu abanengi ukuzidlula zoke ephasini. Amaphesente ama-80 mhlobo wabantu abanzima ababelethelwe kilenarha, kanti ama-20 ngoweminye imihlobo evela eenarheni ezingaphandle.[./Https://en.wikipedia.org/wiki/South_AfricaHttps://en.wikipedia.org/wiki/South_Africa]

=== Umlando WeSewula Afrika ===
</text>
      <sha1>p9x9rlvxth1ckd3usgid9dj6ypoyq3p</sha1>
    </revision>
    <revision>
      <id>889</id>
      <parentid>888</parentid>
      <timestamp>2024-03-08T10:29:40Z</timestamp>
      <contributor>
        <username>incubator&gt;Mosakaruka</username>
        <id>0</id>
      </contributor>
      <comment>Deleted an extra link</comment>
      <origin>889</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="517" sha1="soplyz9z6vyj18ud6w7927csji44qf0" xml:space="preserve">'''ISewula Afrika''' yinarha esesewula enarhakazini ekulu '''ye-Afrika.''' Inabantu abangaba mamiliyoni angaphezu kwama-62, abahlala eemfundeni ezilithoba, abakhuluma amalimi ambadlwana, kodwana ali-11 wakhona asemthethweni. Yinarha yesi-23 erhelweni leenarha ezinabantu abanengi ukuzidlula zoke ephasini. Amaphesente ama-80 mhlobo wabantu abanzima ababelethelwe kilenarha, kanti ama-20 ngoweminye imihlobo evela eenarheni ezingaphandle.[./Https://en.wikipedia.org/wiki/South_Africa]

=== Umlando WeSewula Afrika ===
</text>
      <sha1>soplyz9z6vyj18ud6w7927csji44qf0</sha1>
    </revision>
    <revision>
      <id>890</id>
      <parentid>889</parentid>
      <timestamp>2024-03-09T08:12:58Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>added picture.</comment>
      <origin>890</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="587" sha1="ei4fl79030xk2p4czszi6rkunq1lgor" xml:space="preserve">[[Isimumathi:South Africa adm location map.svg|thumb|iSewula Afrika]]
'''ISewula Afrika''' yinarha esesewula enarhakazini ekulu '''ye-Afrika.''' Inabantu abangaba mamiliyoni angaphezu kwama-62, abahlala eemfundeni ezilithoba, abakhuluma amalimi ambadlwana, kodwana ali-11 wakhona asemthethweni. Yinarha yesi-23 erhelweni leenarha ezinabantu abanengi ukuzidlula zoke ephasini. Amaphesente ama-80 mhlobo wabantu abanzima ababelethelwe kilenarha, kanti ama-20 ngoweminye imihlobo evela eenarheni ezingaphandle.[./Https://en.wikipedia.org/wiki/South_Africa]

=== Umlando WeSewula Afrika ===
</text>
      <sha1>ei4fl79030xk2p4czszi6rkunq1lgor</sha1>
    </revision>
    <revision>
      <id>891</id>
      <parentid>890</parentid>
      <timestamp>2024-03-10T20:50:40Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Adding interwiki links to [[d:Q258]]</comment>
      <origin>891</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="606" sha1="leoxyeddxzkrg8dpjefagxfhkq0kshj" xml:space="preserve">[[Isimumathi:South Africa adm location map.svg|thumb|iSewula Afrika]]
'''ISewula Afrika''' yinarha esesewula enarhakazini ekulu '''ye-Afrika.''' Inabantu abangaba mamiliyoni angaphezu kwama-62, abahlala eemfundeni ezilithoba, abakhuluma amalimi ambadlwana, kodwana ali-11 wakhona asemthethweni. Yinarha yesi-23 erhelweni leenarha ezinabantu abanengi ukuzidlula zoke ephasini. Amaphesente ama-80 mhlobo wabantu abanzima ababelethelwe kilenarha, kanti ama-20 ngoweminye imihlobo evela eenarheni ezingaphandle.[./Https://en.wikipedia.org/wiki/South_Africa]

=== Umlando WeSewula Afrika ===

{{INTERWIKI|Q258}}</text>
      <sha1>leoxyeddxzkrg8dpjefagxfhkq0kshj</sha1>
    </revision>
    <revision>
      <id>892</id>
      <parentid>891</parentid>
      <timestamp>2024-03-10T20:54:14Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>892</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="755" sha1="qhgs2vf4w7kns2k7ycsdsfscmi6gnun" xml:space="preserve">[[Isimumathi:South Africa adm location map.svg|thumb|iSewula Afrika]]
'''ISewula Afrika''' yinarha esesewula enarhakazini ekulu '''ye-Afrika.''' Inabantu abangaba mamiliyoni angaphezu kwama-62, abahlala eemfundeni ezilithoba, abakhuluma amalimi ambadlwana, kodwana ali-11 wakhona asemthethweni. Yinarha yesi-23 erhelweni leenarha ezinabantu abanengi ukuzidlula zoke ephasini. Amaphesente ama-80 mhlobo wabantu abanzima ababelethelwe kilenarha, kanti ama-20 ngoweminye imihlobo evela eenarheni ezingaphandle.&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=96-QAgAAQBAJ&amp;oi=fnd&amp;pg=PA115&amp;dq=South+Africa&amp;ots=YmjPhRE4bt&amp;sig=CyoJp5sfJGPVXMxSmJ9jYRB4JXM&amp;redir_esc=y#v=onepage&amp;q=South%20Africa&amp;f=false&lt;/ref&gt;

=== Umlando WeSewula Afrika ===

{{INTERWIKI|Q258}}</text>
      <sha1>qhgs2vf4w7kns2k7ycsdsfscmi6gnun</sha1>
    </revision>
    <revision>
      <id>893</id>
      <parentid>892</parentid>
      <timestamp>2024-03-10T21:01:23Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>893</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="964" sha1="n7niu9rxngsujyqjltblv9ittqgelgd" xml:space="preserve">[[Isimumathi:South Africa adm location map.svg|thumb|iSewula Afrika]]
'''ISewula Afrika''' yinarha esesewula enarhakazini ekulu '''ye-Afrika.''' Inabantu abangaba mamiliyoni angaphezu kwama-62, abahlala eemfundeni ezilithoba, abakhuluma amalimi ambadlwana, kodwana ali-11 wakhona asemthethweni. Yinarha yesi-23 erhelweni leenarha ezinabantu abanengi ukuzidlula zoke ephasini. Amaphesente ama-80 mhlobo wabantu abanzima ababelethelwe kilenarha, kanti ama-20 ngoweminye imihlobo evela eenarheni ezingaphandle.&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=96-QAgAAQBAJ&amp;oi=fnd&amp;pg=PA115&amp;dq=South+Africa&amp;ots=YmjPhRE4bt&amp;sig=CyoJp5sfJGPVXMxSmJ9jYRB4JXM&amp;redir_esc=y#v=onepage&amp;q=South%20Africa&amp;f=false&lt;/ref&gt;
&lt;references /&gt;
&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=FE3EEAAAQBAJ&amp;oi=fnd&amp;pg=PP1&amp;dq=South+Africa&amp;ots=fjYhrVgxT5&amp;sig=4gDCXRDfxb4OPHzJzWiXxlr49kk&amp;redir_esc=y#v=onepage&amp;q=South%20Africa&amp;f=false&lt;/ref&gt;

=== Umlando WeSewula Afrika ===

{{INTERWIKI|Q258}}</text>
      <sha1>n7niu9rxngsujyqjltblv9ittqgelgd</sha1>
    </revision>
    <revision>
      <id>894</id>
      <parentid>893</parentid>
      <timestamp>2024-03-10T21:02:02Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>894</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="770" sha1="ry102d2si1otaouygqi297uud4s23wm" xml:space="preserve">[[Isimumathi:South Africa adm location map.svg|thumb|iSewula Afrika]]
'''ISewula Afrika''' yinarha esesewula enarhakazini ekulu '''ye-Afrika.''' Inabantu abangaba mamiliyoni angaphezu kwama-62, abahlala eemfundeni ezilithoba, abakhuluma amalimi ambadlwana, kodwana ali-11 wakhona asemthethweni. Yinarha yesi-23 erhelweni leenarha ezinabantu abanengi ukuzidlula zoke ephasini. Amaphesente ama-80 mhlobo wabantu abanzima ababelethelwe kilenarha, kanti ama-20 ngoweminye imihlobo evela eenarheni ezingaphandle.&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=96-QAgAAQBAJ&amp;oi=fnd&amp;pg=PA115&amp;dq=South+Africa&amp;ots=YmjPhRE4bt&amp;sig=CyoJp5sfJGPVXMxSmJ9jYRB4JXM&amp;redir_esc=y#v=onepage&amp;q=South%20Africa&amp;f=false&lt;/ref&gt;
&lt;references /&gt;

=== Umlando WeSewula Afrika ===

{{INTERWIKI|Q258}}</text>
      <sha1>ry102d2si1otaouygqi297uud4s23wm</sha1>
    </revision>
    <revision>
      <id>895</id>
      <parentid>894</parentid>
      <timestamp>2024-03-10T21:02:24Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>895</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="963" sha1="os50f3ehkcadz5ibo0vgy3y21e0o3en" xml:space="preserve">[[Isimumathi:South Africa adm location map.svg|thumb|iSewula Afrika]]
'''ISewula Afrika''' yinarha esesewula enarhakazini ekulu '''ye-Afrika.''' Inabantu abangaba mamiliyoni angaphezu kwama-62, abahlala eemfundeni ezilithoba, abakhuluma amalimi ambadlwana, kodwana ali-11 wakhona asemthethweni. Yinarha yesi-23 erhelweni leenarha ezinabantu abanengi ukuzidlula zoke ephasini. Amaphesente ama-80 mhlobo wabantu abanzima ababelethelwe kilenarha, kanti ama-20 ngoweminye imihlobo evela eenarheni ezingaphandle.&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=96-QAgAAQBAJ&amp;oi=fnd&amp;pg=PA115&amp;dq=South+Africa&amp;ots=YmjPhRE4bt&amp;sig=CyoJp5sfJGPVXMxSmJ9jYRB4JXM&amp;redir_esc=y#v=onepage&amp;q=South%20Africa&amp;f=false&lt;/ref&gt;&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=FE3EEAAAQBAJ&amp;oi=fnd&amp;pg=PP1&amp;dq=South+Africa&amp;ots=fjYhrVgxT5&amp;sig=4gDCXRDfxb4OPHzJzWiXxlr49kk&amp;redir_esc=y#v=onepage&amp;q=South%20Africa&amp;f=false&lt;/ref&gt;
&lt;references /&gt;

=== Umlando WeSewula Afrika ===

{{INTERWIKI|Q258}}</text>
      <sha1>os50f3ehkcadz5ibo0vgy3y21e0o3en</sha1>
    </revision>
    <revision>
      <id>896</id>
      <parentid>895</parentid>
      <timestamp>2024-10-14T13:46:54Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>14 revisions imported</comment>
      <origin>895</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="963" sha1="os50f3ehkcadz5ibo0vgy3y21e0o3en" xml:space="preserve">[[Isimumathi:South Africa adm location map.svg|thumb|iSewula Afrika]]
'''ISewula Afrika''' yinarha esesewula enarhakazini ekulu '''ye-Afrika.''' Inabantu abangaba mamiliyoni angaphezu kwama-62, abahlala eemfundeni ezilithoba, abakhuluma amalimi ambadlwana, kodwana ali-11 wakhona asemthethweni. Yinarha yesi-23 erhelweni leenarha ezinabantu abanengi ukuzidlula zoke ephasini. Amaphesente ama-80 mhlobo wabantu abanzima ababelethelwe kilenarha, kanti ama-20 ngoweminye imihlobo evela eenarheni ezingaphandle.&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=96-QAgAAQBAJ&amp;oi=fnd&amp;pg=PA115&amp;dq=South+Africa&amp;ots=YmjPhRE4bt&amp;sig=CyoJp5sfJGPVXMxSmJ9jYRB4JXM&amp;redir_esc=y#v=onepage&amp;q=South%20Africa&amp;f=false&lt;/ref&gt;&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=FE3EEAAAQBAJ&amp;oi=fnd&amp;pg=PP1&amp;dq=South+Africa&amp;ots=fjYhrVgxT5&amp;sig=4gDCXRDfxb4OPHzJzWiXxlr49kk&amp;redir_esc=y#v=onepage&amp;q=South%20Africa&amp;f=false&lt;/ref&gt;
&lt;references /&gt;

=== Umlando WeSewula Afrika ===

{{INTERWIKI|Q258}}</text>
      <sha1>os50f3ehkcadz5ibo0vgy3y21e0o3en</sha1>
    </revision>
    <revision>
      <id>1671</id>
      <parentid>896</parentid>
      <timestamp>2024-10-16T09:49:56Z</timestamp>
      <contributor>
        <username>JhsBot</username>
        <id>34</id>
      </contributor>
      <minor />
      <comment>bot: Removing interwiki template; the page is now connected to [[d:Q258]]</comment>
      <origin>1671</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="943" sha1="q4ybd81lgi46bc898z1eksmjsp6c8yd" xml:space="preserve">[[Isimumathi:South Africa adm location map.svg|thumb|iSewula Afrika]]
'''ISewula Afrika''' yinarha esesewula enarhakazini ekulu '''ye-Afrika.''' Inabantu abangaba mamiliyoni angaphezu kwama-62, abahlala eemfundeni ezilithoba, abakhuluma amalimi ambadlwana, kodwana ali-11 wakhona asemthethweni. Yinarha yesi-23 erhelweni leenarha ezinabantu abanengi ukuzidlula zoke ephasini. Amaphesente ama-80 mhlobo wabantu abanzima ababelethelwe kilenarha, kanti ama-20 ngoweminye imihlobo evela eenarheni ezingaphandle.&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=96-QAgAAQBAJ&amp;oi=fnd&amp;pg=PA115&amp;dq=South+Africa&amp;ots=YmjPhRE4bt&amp;sig=CyoJp5sfJGPVXMxSmJ9jYRB4JXM&amp;redir_esc=y#v=onepage&amp;q=South%20Africa&amp;f=false&lt;/ref&gt;&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=FE3EEAAAQBAJ&amp;oi=fnd&amp;pg=PP1&amp;dq=South+Africa&amp;ots=fjYhrVgxT5&amp;sig=4gDCXRDfxb4OPHzJzWiXxlr49kk&amp;redir_esc=y#v=onepage&amp;q=South%20Africa&amp;f=false&lt;/ref&gt;
&lt;references /&gt;

=== Umlando WeSewula Afrika ===</text>
      <sha1>q4ybd81lgi46bc898z1eksmjsp6c8yd</sha1>
    </revision>
    <revision>
      <id>1723</id>
      <parentid>1671</parentid>
      <timestamp>2024-10-23T19:29:08Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1723</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="907" sha1="40nhwo3424cxom9518c6hubq8wdasnf" xml:space="preserve">[[Isimumathi:South Africa adm location map.svg|thumb|iSewula Afrika]]
'''ISewula Afrika''' yinarha esesewula enarhakazini ekulu ye-[[Afrika]].Inabantu abangaba mamiliyoni angaphezu kwama-62, abahlala eemfundeni ezilithoba, abakhuluma amalimi ambadlwana, kodwana ali-11 wakhona asemthethweni. Yinarha yesi-23 erhelweni leenarha ezinabantu abanengi ukuzidlula zoke ephasini. Amaphesente ama-80 mhlobo wabantu abanzima ababelethelwe kilenarha, kanti ama-20 ngoweminye imihlobo evela eenarheni ezingaphandle.&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=96-QAgAAQBAJ&amp;oi=fnd&amp;pg=PA115&amp;dq=South+Africa&amp;ots=YmjPhRE4bt&amp;sig=CyoJp5sfJGPVXMxSmJ9jYRB4JXM&amp;redir_esc=y#v=onepage&amp;q=South%20Africa&amp;f=false&lt;/ref&gt;&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=FE3EEAAAQBAJ&amp;oi=fnd&amp;pg=PP1&amp;dq=South+Africa&amp;ots=fjYhrVgxT5&amp;sig=4gDCXRDfxb4OPHzJzWiXxlr49kk&amp;redir_esc=y#v=onepage&amp;q=South%20Africa&amp;f=false&lt;/ref&gt;
&lt;references /&gt;</text>
      <sha1>40nhwo3424cxom9518c6hubq8wdasnf</sha1>
    </revision>
    <revision>
      <id>1815</id>
      <parentid>1723</parentid>
      <timestamp>2024-11-01T18:29:54Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1815</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="936" sha1="kld284qp39w7vn6tro714fer9fjnxvq" xml:space="preserve">[[Isimumathi:South Africa adm location map.svg|thumb|iSewula Afrika]]
'''ISewula Afrika''' yinarha esesewula enarhakazini ekulu ye-[[Afrika]].Inabantu abangaba mamiliyoni angaphezu kwama-62, abahlala eemfundeni ezilithoba, abakhuluma amalimi ambadlwana, kodwana ali-11 wakhona asemthethweni. Yinarha yesi-23 erhelweni leenarha ezinabantu abanengi ukuzidlula zoke ephasini. Amaphesente ama-80 mhlobo wabantu abanzima ababelethelwe kilenarha, kanti ama-20 ngoweminye imihlobo evela eenarheni ezingaphandle.&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=96-QAgAAQBAJ&amp;oi=fnd&amp;pg=PA115&amp;dq=South+Africa&amp;ots=YmjPhRE4bt&amp;sig=CyoJp5sfJGPVXMxSmJ9jYRB4JXM&amp;redir_esc=y#v=onepage&amp;q=South%20Africa&amp;f=false&lt;/ref&gt;&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=FE3EEAAAQBAJ&amp;oi=fnd&amp;pg=PP1&amp;dq=South+Africa&amp;ots=fjYhrVgxT5&amp;sig=4gDCXRDfxb4OPHzJzWiXxlr49kk&amp;redir_esc=y#v=onepage&amp;q=South%20Africa&amp;f=false&lt;/ref&gt;
&lt;references /&gt;
[[Category:Iinarha zephasi]]</text>
      <sha1>kld284qp39w7vn6tro714fer9fjnxvq</sha1>
    </revision>
    <revision>
      <id>1816</id>
      <parentid>1815</parentid>
      <timestamp>2024-11-01T18:30:13Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1816</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="949" sha1="eui3nv0uk7dmtg4byyq3w8klc2orv11" xml:space="preserve">[[Isimumathi:South Africa adm location map.svg|thumb|iSewula Afrika]]
'''ISewula Afrika''' yinarha esesewula enarhakazini ekulu ye-[[Afrika]].Inabantu abangaba mamiliyoni angaphezu kwama-62, abahlala eemfundeni ezilithoba, abakhuluma amalimi ambadlwana, kodwana ali-11 wakhona asemthethweni. Yinarha yesi-23 erhelweni leenarha ezinabantu abanengi ukuzidlula zoke ephasini. Amaphesente ama-80 mhlobo wabantu abanzima ababelethelwe kilenarha, kanti ama-20 ngoweminye imihlobo evela eenarheni ezingaphandle.&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=96-QAgAAQBAJ&amp;oi=fnd&amp;pg=PA115&amp;dq=South+Africa&amp;ots=YmjPhRE4bt&amp;sig=CyoJp5sfJGPVXMxSmJ9jYRB4JXM&amp;redir_esc=y#v=onepage&amp;q=South%20Africa&amp;f=false&lt;/ref&gt;&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=FE3EEAAAQBAJ&amp;oi=fnd&amp;pg=PP1&amp;dq=South+Africa&amp;ots=fjYhrVgxT5&amp;sig=4gDCXRDfxb4OPHzJzWiXxlr49kk&amp;redir_esc=y#v=onepage&amp;q=South%20Africa&amp;f=false&lt;/ref&gt;
==Iinkomba==
&lt;references /&gt;
[[Category:Iinarha zephasi]]</text>
      <sha1>eui3nv0uk7dmtg4byyq3w8klc2orv11</sha1>
    </revision>
    <revision>
      <id>2131</id>
      <parentid>1816</parentid>
      <timestamp>2024-11-25T18:26:41Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* Iinkomba */Reflist</comment>
      <origin>2131</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="949" sha1="5wb1cr755i70kxtm31zmna8e855rbgk" xml:space="preserve">[[Isimumathi:South Africa adm location map.svg|thumb|iSewula Afrika]]
'''ISewula Afrika''' yinarha esesewula enarhakazini ekulu ye-[[Afrika]].Inabantu abangaba mamiliyoni angaphezu kwama-62, abahlala eemfundeni ezilithoba, abakhuluma amalimi ambadlwana, kodwana ali-11 wakhona asemthethweni. Yinarha yesi-23 erhelweni leenarha ezinabantu abanengi ukuzidlula zoke ephasini. Amaphesente ama-80 mhlobo wabantu abanzima ababelethelwe kilenarha, kanti ama-20 ngoweminye imihlobo evela eenarheni ezingaphandle.&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=96-QAgAAQBAJ&amp;oi=fnd&amp;pg=PA115&amp;dq=South+Africa&amp;ots=YmjPhRE4bt&amp;sig=CyoJp5sfJGPVXMxSmJ9jYRB4JXM&amp;redir_esc=y#v=onepage&amp;q=South%20Africa&amp;f=false&lt;/ref&gt;&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=FE3EEAAAQBAJ&amp;oi=fnd&amp;pg=PP1&amp;dq=South+Africa&amp;ots=fjYhrVgxT5&amp;sig=4gDCXRDfxb4OPHzJzWiXxlr49kk&amp;redir_esc=y#v=onepage&amp;q=South%20Africa&amp;f=false&lt;/ref&gt;
== Iinkomba ==
{{Reflist}}

[[Category:Iinarha zephasi]]</text>
      <sha1>5wb1cr755i70kxtm31zmna8e855rbgk</sha1>
    </revision>
    <revision>
      <id>2137</id>
      <parentid>2131</parentid>
      <timestamp>2024-11-25T18:28:54Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>Mkhakha</comment>
      <origin>2137</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="948" sha1="4wstp5kyifm0orzkgm0rphykzf9poiv" xml:space="preserve">[[Isimumathi:South Africa adm location map.svg|thumb|iSewula Afrika]]
'''ISewula Afrika''' yinarha esesewula enarhakazini ekulu ye-[[Afrika]].Inabantu abangaba mamiliyoni angaphezu kwama-62, abahlala eemfundeni ezilithoba, abakhuluma amalimi ambadlwana, kodwana ali-11 wakhona asemthethweni. Yinarha yesi-23 erhelweni leenarha ezinabantu abanengi ukuzidlula zoke ephasini. Amaphesente ama-80 mhlobo wabantu abanzima ababelethelwe kilenarha, kanti ama-20 ngoweminye imihlobo evela eenarheni ezingaphandle.&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=96-QAgAAQBAJ&amp;oi=fnd&amp;pg=PA115&amp;dq=South+Africa&amp;ots=YmjPhRE4bt&amp;sig=CyoJp5sfJGPVXMxSmJ9jYRB4JXM&amp;redir_esc=y#v=onepage&amp;q=South%20Africa&amp;f=false&lt;/ref&gt;&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=FE3EEAAAQBAJ&amp;oi=fnd&amp;pg=PP1&amp;dq=South+Africa&amp;ots=fjYhrVgxT5&amp;sig=4gDCXRDfxb4OPHzJzWiXxlr49kk&amp;redir_esc=y#v=onepage&amp;q=South%20Africa&amp;f=false&lt;/ref&gt;
== Iinkomba ==
{{Reflist}}

[[Mkhakha:Iinarha zephasi]]</text>
      <sha1>4wstp5kyifm0orzkgm0rphykzf9poiv</sha1>
    </revision>
    <revision>
      <id>2243</id>
      <parentid>2137</parentid>
      <timestamp>2024-12-04T00:24:55Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2243</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="975" sha1="248g9u5yqazzkhxut2ex7mhnzyaf1gi" xml:space="preserve">[[Isimumathi:South Africa adm location map.svg|thumb|iSewula Afrika]]
'''ISewula Afrika''' yinarha esesewula enarhakazini ekulu ye-[[Afrika]].Inabantu abangaba mamiliyoni angaphezu kwama-62, abahlala eemfundeni ezilithoba, abakhuluma amalimi ambadlwana, kodwana ali-11 wakhona asemthethweni. Yinarha yesi-23 erhelweni leenarha ezinabantu abanengi ukuzidlula zoke ephasini. Amaphesente ama-80 mhlobo wabantu abanzima ababelethelwe kilenarha, kanti ama-20 ngoweminye imihlobo evela eenarheni ezingaphandle.&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=96-QAgAAQBAJ&amp;oi=fnd&amp;pg=PA115&amp;dq=South+Africa&amp;ots=YmjPhRE4bt&amp;sig=CyoJp5sfJGPVXMxSmJ9jYRB4JXM&amp;redir_esc=y#v=onepage&amp;q=South%20Africa&amp;f=false&lt;/ref&gt;&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=FE3EEAAAQBAJ&amp;oi=fnd&amp;pg=PP1&amp;dq=South+Africa&amp;ots=fjYhrVgxT5&amp;sig=4gDCXRDfxb4OPHzJzWiXxlr49kk&amp;redir_esc=y#v=onepage&amp;q=South%20Africa&amp;f=false&lt;/ref&gt;
== Iinkomba ==
{{Reflist}}

[[Mkhakha:Iinarha zephasi]]
[[Mkhakha:Isewula Afrika]]</text>
      <sha1>248g9u5yqazzkhxut2ex7mhnzyaf1gi</sha1>
    </revision>
    <revision>
      <id>5538</id>
      <parentid>2243</parentid>
      <timestamp>2025-09-04T09:27:58Z</timestamp>
      <contributor>
        <username>Pholap</username>
        <id>883</id>
      </contributor>
      <minor />
      <comment>/* Iinkomba */</comment>
      <origin>5538</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="980" sha1="iz062yxgcc5wwkqjw620tbpif4kjn1b" xml:space="preserve">[[Isimumathi:South Africa adm location map.svg|thumb|iSewula Afrika]]
'''ISewula Afrika''' yinarha esesewula enarhakazini ekulu ye-[[Afrika]].Inabantu abangaba mamiliyoni angaphezu kwama-62, abahlala eemfundeni ezilithoba, abakhuluma amalimi ambadlwana, kodwana ali-11 wakhona asemthethweni. Yinarha yesi-23 erhelweni leenarha ezinabantu abanengi ukuzidlula zoke ephasini. Amaphesente ama-80 mhlobo wabantu abanzima ababelethelwe kilenarha, kanti ama-20 ngoweminye imihlobo evela eenarheni ezingaphandle.&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=96-QAgAAQBAJ&amp;oi=fnd&amp;pg=PA115&amp;dq=South+Africa&amp;ots=YmjPhRE4bt&amp;sig=CyoJp5sfJGPVXMxSmJ9jYRB4JXM&amp;redir_esc=y#v=onepage&amp;q=South%20Africa&amp;f=false&lt;/ref&gt;&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=FE3EEAAAQBAJ&amp;oi=fnd&amp;pg=PP1&amp;dq=South+Africa&amp;ots=fjYhrVgxT5&amp;sig=4gDCXRDfxb4OPHzJzWiXxlr49kk&amp;redir_esc=y#v=onepage&amp;q=South%20Africa&amp;f=false&lt;/ref&gt;
== Umthombolwazi ==
{{Reflist}}

[[Mkhakha:Iinarha zephasi]]
[[Mkhakha:Isewula Afrika]]</text>
      <sha1>iz062yxgcc5wwkqjw620tbpif4kjn1b</sha1>
    </revision>
  </page>
  <page>
    <title>Isibongo sikamma owendileko</title>
    <ns>0</ns>
    <id>188</id>
    <revision>
      <id>897</id>
      <timestamp>2024-05-09T11:55:07Z</timestamp>
      <contributor>
        <username>incubator&gt;Sphenge</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;Isingeniso  Isitjhaba samaNdebele sesithuthuke ngeendlela ezinengi emikhakheni ehlukahlukeneko. Kuqakathekile bona imvelaphi yaso yazeke begodu ihlaliswe ngendlela efaneleko. Umuntu nakakhulako ukhamba iingaba ezithileko zepilo begodu ngokwesitjhaba samaNdebele, esinye nesinye isigaba sinebizo begodu kukhona okulindelekileko okukhambisana nesigabeso.  &quot;</comment>
      <origin>897</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="354" sha1="4dx69qjhfnmd09njz7z2i993f5bj52n" xml:space="preserve">Isingeniso

Isitjhaba samaNdebele sesithuthuke ngeendlela ezinengi emikhakheni ehlukahlukeneko. Kuqakathekile bona imvelaphi yaso yazeke begodu ihlaliswe ngendlela efaneleko. Umuntu nakakhulako ukhamba iingaba ezithileko zepilo begodu ngokwesitjhaba samaNdebele, esinye nesinye isigaba sinebizo begodu kukhona okulindelekileko okukhambisana nesigabeso.

</text>
      <sha1>4dx69qjhfnmd09njz7z2i993f5bj52n</sha1>
    </revision>
    <revision>
      <id>898</id>
      <parentid>897</parentid>
      <timestamp>2024-05-09T12:08:35Z</timestamp>
      <contributor>
        <username>incubator&gt;Sphenge</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>898</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="678" sha1="0xn6m8b0opa40t2ltcjzoosojkwl3h5" xml:space="preserve">== '''Isingeniso''' ==
Isitjhaba samaNdebele sesithuthuke ngeendlela ezinengi emikhakheni ehlukahlukeneko. Kuqakathekile bona imvelaphi yaso yazeke begodu ihlaliswe ngendlela efaneleko. Umuntu nakakhulako ukhamba iingaba ezithileko zepilo begodu ngokwesitjhaba samaNdebele, esinye nesinye isigaba sinebizo begodu kukhona okulindelekileko okukhambisana nesigabeso.

== Umntazana ==
Umntwana womntazana nakabelethwako uphiwa ibizo azokubizwa ngalo ukufikela la aba litlawana khona. Nasele alitlawana kukhona isiko elinziweko elibizwa ngokuthomba. Isibonelo, umntazana lo nakabelethwako unikelwe ibizo likaThandeka. kuzokuthi ngemva kobana adluliswe anikelwe ibizo likaNdlelehle.

</text>
      <sha1>0xn6m8b0opa40t2ltcjzoosojkwl3h5</sha1>
    </revision>
    <revision>
      <id>899</id>
      <parentid>898</parentid>
      <timestamp>2024-05-09T12:26:18Z</timestamp>
      <contributor>
        <username>incubator&gt;Sphenge</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>899</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1119" sha1="2p49udtrqyvewtm15s4uusiv0pw5x0r" xml:space="preserve">== '''Isingeniso''' ==
Isitjhaba samaNdebele sesithuthuke ngeendlela ezinengi emikhakheni ehlukahlukeneko. Kuqakathekile bona imvelaphi yaso yazeke begodu ihlaliswe ngendlela efaneleko. Umuntu nakakhulako ukhamba iingaba ezithileko zepilo begodu ngokwesitjhaba samaNdebele, esinye nesinye isigaba sinebizo begodu kukhona okulindelekileko okukhambisana nesigabeso.

== Iingaba zokukhula komuntu wengubo ==
Umntwana womntazana nakabelethwako uphiwa ibizo azokubizwa ngalo ukufikela la aba litlawana khona. Nasele alitlawana kukhona isiko elinziweko elibizwa ngokuthomba. Isibonelo, umntazana lo nakabelethwako unikelwe ibizo likaThandeka, ngemva kobana adluliswe anikelwe ibizo likaNdlelehle. Umntazana lo nangabe ungewakwaSkhosana uzokubizwa ngoNaSkhosana. UNaSkhosana lo nanyana angathathwa kwaMahlangu uzokubizwa ngoNaSkhosana. Njengombana sele athethwe kwaMahlangu usokunikelwa ibizo lakhe lekwendeni. 

Kuqakathekile bona sazi bona umma oliNdebele nasele athethwe unikelwa ibizo likamalukazana. Esitjhabeni samaNdebele kukhona amabizo amahlanu anikelwa abomakoti, kukhona uLombeni, uKumbuza, uMaphangela noMzangobe

</text>
      <sha1>2p49udtrqyvewtm15s4uusiv0pw5x0r</sha1>
    </revision>
    <revision>
      <id>900</id>
      <parentid>899</parentid>
      <timestamp>2024-05-09T12:31:48Z</timestamp>
      <contributor>
        <username>incubator&gt;Sphenge</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>/* Isingeniso */</comment>
      <origin>900</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1120" sha1="i98uhdrqc8u1o9l3n1spp466k1dagzm" xml:space="preserve">== '''Isingeniso''' ==
Isitjhaba samaNdebele sesithuthuke ngeendlela ezinengi emikhakheni ehlukahlukeneko. Kuqakathekile bona imvelaphi yaso yazeke begodu ihlaliswe ngendlela efaneleko. Umuntu nakakhulako ukhamba iingaba ezithileko zepilo begodu ngokwesitjhaba samaNdebele, esinye nesinye isigaba sinebizo begodu kukhona okulindelekileko okukhambisana nesigabeso.

== Iingaba zokukhula komuntu wengubo ==
Umntwana womntazana nakabelethwako uphiwa ibizo azokubizwa ngalo ukufikela la aba litlawana khona. Nasele alitlawana kukhona isiko elinziweko elibizwa ngokuthomba. Isibonelo, umntazana lo nakabelethwako unikelwe ibizo likaThandeka, ngemva kobana adluliswe anikelwe ibizo likaNdlelehle. Umntazana lo nangabe ungewakwaSkhosana uzokubizwa ngoNaSkhosana. UNaSkhosana lo nanyana angathathwa kwaMahlangu uzokubizwa ngoNaSkhosana. Njengombana sele athethwe kwaMahlangu usokunikelwa ibizo lakhe lekwendeni. 

Kuqakathekile bona sazi bona umma oliNdebele nasele athethwe unikelwa ibizo likamalukazana. Esitjhabeni samaNdebele kukhona amabizo amahlanu anikelwa abomakoti, kukhona uLombeni, uKumbuza, uMaphangela noMzangobe.

</text>
      <sha1>i98uhdrqc8u1o9l3n1spp466k1dagzm</sha1>
    </revision>
    <revision>
      <id>901</id>
      <parentid>900</parentid>
      <timestamp>2024-10-14T13:46:54Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>4 revisions imported</comment>
      <origin>900</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1120" sha1="i98uhdrqc8u1o9l3n1spp466k1dagzm" xml:space="preserve">== '''Isingeniso''' ==
Isitjhaba samaNdebele sesithuthuke ngeendlela ezinengi emikhakheni ehlukahlukeneko. Kuqakathekile bona imvelaphi yaso yazeke begodu ihlaliswe ngendlela efaneleko. Umuntu nakakhulako ukhamba iingaba ezithileko zepilo begodu ngokwesitjhaba samaNdebele, esinye nesinye isigaba sinebizo begodu kukhona okulindelekileko okukhambisana nesigabeso.

== Iingaba zokukhula komuntu wengubo ==
Umntwana womntazana nakabelethwako uphiwa ibizo azokubizwa ngalo ukufikela la aba litlawana khona. Nasele alitlawana kukhona isiko elinziweko elibizwa ngokuthomba. Isibonelo, umntazana lo nakabelethwako unikelwe ibizo likaThandeka, ngemva kobana adluliswe anikelwe ibizo likaNdlelehle. Umntazana lo nangabe ungewakwaSkhosana uzokubizwa ngoNaSkhosana. UNaSkhosana lo nanyana angathathwa kwaMahlangu uzokubizwa ngoNaSkhosana. Njengombana sele athethwe kwaMahlangu usokunikelwa ibizo lakhe lekwendeni. 

Kuqakathekile bona sazi bona umma oliNdebele nasele athethwe unikelwa ibizo likamalukazana. Esitjhabeni samaNdebele kukhona amabizo amahlanu anikelwa abomakoti, kukhona uLombeni, uKumbuza, uMaphangela noMzangobe.

</text>
      <sha1>i98uhdrqc8u1o9l3n1spp466k1dagzm</sha1>
    </revision>
  </page>
  <page>
    <title>Isidingo sokuvikela aboBhejane</title>
    <ns>0</ns>
    <id>189</id>
    <revision>
      <id>902</id>
      <timestamp>2024-06-27T11:47:10Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''UBhejane''' sibandana esihlala emangweni esinepumulo ebusweni phambi kwepumulo.  &quot;</comment>
      <origin>902</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="84" sha1="pgk005dj1mokw3gge2e5ekn08zlfipn" xml:space="preserve">'''UBhejane''' sibandana esihlala emangweni esinepumulo ebusweni phambi kwepumulo.

</text>
      <sha1>pgk005dj1mokw3gge2e5ekn08zlfipn</sha1>
    </revision>
    <revision>
      <id>903</id>
      <parentid>902</parentid>
      <timestamp>2024-06-28T09:25:43Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>903</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="496" sha1="pkd3en11iglme9hgacytg94dj4s4scl" xml:space="preserve">'''UBhejane''' sibandana esihlala emangweni esinepumulo ebusweni phambi kwepumulo. Isibandana lesi ngesinye seembandana ezikulu ezihlanu .Lomhlobo weembandana ubalwa bonyana sele useduze nokuthi ungasatholakali ngombana abantu bazibulala ngesihlungu, ngesibanga sokobana bafuna amaphondo wazo. 

Kufanele bona abantu bavikele iimbandana lezi ukwenzela bonyana zingagcini sele zingasatholaka ephasini. Kufanele sizibulunge ukwenzela isizukulwana esizako begodu nokutjengisa ukuthanda [[imvelo]].

</text>
      <sha1>pkd3en11iglme9hgacytg94dj4s4scl</sha1>
    </revision>
    <revision>
      <id>904</id>
      <parentid>903</parentid>
      <timestamp>2024-06-30T17:25:19Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>904</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="566" sha1="s086kshws1pb3aaeb5gkgak6v1766te" xml:space="preserve">[[Isimumathi:Rhinoceros in South Africa adjusted.jpg|thumb|Ubhejane]]
'''UBhejane''' sibandana esihlala emangweni esinepumulo ebusweni phambi kwepumulo. Isibandana lesi ngesinye seembandana ezikulu ezihlanu .Lomhlobo weembandana ubalwa bonyana sele useduze nokuthi ungasatholakali ngombana abantu bazibulala ngesihlungu, ngesibanga sokobana bafuna amaphondo wazo. 

Kufanele bona abantu bavikele iimbandana lezi ukwenzela bonyana zingagcini sele zingasatholaka ephasini. Kufanele sizibulunge ukwenzela isizukulwana esizako begodu nokutjengisa ukuthanda [[imvelo]].

</text>
      <sha1>s086kshws1pb3aaeb5gkgak6v1766te</sha1>
    </revision>
    <revision>
      <id>905</id>
      <parentid>904</parentid>
      <timestamp>2024-07-05T16:03:16Z</timestamp>
      <contributor>
        <ip>41.13.90.126</ip>
      </contributor>
      <origin>905</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="723" sha1="9ai43t5l9hvpw03100xpo7d6v70qoak" xml:space="preserve">[[Isimumathi:Rhinoceros in South Africa adjusted.jpg|thumb|Ubhejane]]
'''UBhejane''' sibandana esihlala emangweni esinephondo ebusweni phambi kwepumulo. Isibandana lesi ngesinye seembandana ezikulu ezihlanu .Lomhlobo weembandana ubalwa bonyana sele useduze nokuthi ungasatholakali ngombana abantu bazibulala ngesihlungu, ngesibanga sokobana bafuna amaphondo wazo. Amaphondo la ayathengisswa begodu athengiswa ngemali enengi ngikho abotsotsi babulala abobhejane ukuthi bazokhona ukwenza imali. 

Kufanele bona abantu bavikele iimbandana lezi ukwenzela bonyana zingagcini sele zingasatholaka ephasini. Kufanele sizibulunge ukwenzela isizukulwana esizako sizokghona ukubona iinlwana begodu nokutjengisa ukuthanda [[imvelo]].

</text>
      <sha1>9ai43t5l9hvpw03100xpo7d6v70qoak</sha1>
    </revision>
    <revision>
      <id>906</id>
      <parentid>905</parentid>
      <timestamp>2024-07-05T16:05:12Z</timestamp>
      <contributor>
        <ip>41.13.90.126</ip>
      </contributor>
      <origin>906</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="790" sha1="8orka3ktzpgv8o317mp5zh2v8anm60f" xml:space="preserve">[[Isimumathi:Rhinoceros in South Africa adjusted.jpg|thumb|Ubhejane]]
[[Isimumathi:Bleeding Rhino.png|thumb|Ubhejane okhutjhwe iphondo]]
'''UBhejane''' sibandana esihlala emangweni esinephondo ebusweni phambi kwepumulo. Isibandana lesi ngesinye seembandana ezikulu ezihlanu .Lomhlobo weembandana ubalwa bonyana sele useduze nokuthi ungasatholakali ngombana abantu bazibulala ngesihlungu, ngesibanga sokobana bafuna amaphondo wazo. Amaphondo la ayathengisswa begodu athengiswa ngemali enengi ngikho abotsotsi babulala abobhejane ukuthi bazokhona ukwenza imali. 

Kufanele bona abantu bavikele iimbandana lezi ukwenzela bonyana zingagcini sele zingasatholaka ephasini. Kufanele sizibulunge ukwenzela isizukulwana esizako sizokghona ukubona iinlwana begodu nokutjengisa ukuthanda [[imvelo]].

</text>
      <sha1>8orka3ktzpgv8o317mp5zh2v8anm60f</sha1>
    </revision>
    <revision>
      <id>907</id>
      <parentid>906</parentid>
      <timestamp>2024-10-14T13:46:55Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>5 revisions imported</comment>
      <origin>906</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="790" sha1="8orka3ktzpgv8o317mp5zh2v8anm60f" xml:space="preserve">[[Isimumathi:Rhinoceros in South Africa adjusted.jpg|thumb|Ubhejane]]
[[Isimumathi:Bleeding Rhino.png|thumb|Ubhejane okhutjhwe iphondo]]
'''UBhejane''' sibandana esihlala emangweni esinephondo ebusweni phambi kwepumulo. Isibandana lesi ngesinye seembandana ezikulu ezihlanu .Lomhlobo weembandana ubalwa bonyana sele useduze nokuthi ungasatholakali ngombana abantu bazibulala ngesihlungu, ngesibanga sokobana bafuna amaphondo wazo. Amaphondo la ayathengisswa begodu athengiswa ngemali enengi ngikho abotsotsi babulala abobhejane ukuthi bazokhona ukwenza imali. 

Kufanele bona abantu bavikele iimbandana lezi ukwenzela bonyana zingagcini sele zingasatholaka ephasini. Kufanele sizibulunge ukwenzela isizukulwana esizako sizokghona ukubona iinlwana begodu nokutjengisa ukuthanda [[imvelo]].

</text>
      <sha1>8orka3ktzpgv8o317mp5zh2v8anm60f</sha1>
    </revision>
  </page>
  <page>
    <title>Isifunda seMpumalanga</title>
    <ns>0</ns>
    <id>190</id>
    <revision>
      <id>908</id>
      <timestamp>2024-03-09T10:05:42Z</timestamp>
      <contributor>
        <username>incubator&gt;Mzwakhe David18</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;   '''Isifunda seMpumalanga''' Singesinye sesifuda esitholakala enarheni ye[[Isewula Afrika|Sewula Afrika]]. Sitholakala sitjhidelene nenmfunda ezintathu, ifinda seLimpopo, Kwazulu natal, kanye negauteng. Idorobho elikhulu lakhona yi[[Mbombela]] ebeyaziwa ngokobana yi[[Nelspruit]] kade. Ibuye ibeNamadorobha asthandathu: eMalahleni (ebeyaziwa nge Witbank), Standerton, eMkhondo ( ebeyaziwa bona yi Piet Retief), Malalane, Ermelo, Barberton and Sabie....&quot;</comment>
      <origin>908</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="477" sha1="0inonhz5toudt0uugt96c2m8f4f0nnb" xml:space="preserve">

'''Isifunda seMpumalanga''' Singesinye sesifuda esitholakala enarheni ye[[Isewula Afrika|Sewula Afrika]]. Sitholakala sitjhidelene nenmfunda ezintathu, ifinda seLimpopo, Kwazulu natal, kanye negauteng. Idorobho elikhulu lakhona yi[[Mbombela]] ebeyaziwa ngokobana yi[[Nelspruit]] kade. Ibuye ibeNamadorobha asthandathu: eMalahleni (ebeyaziwa nge Witbank), Standerton, eMkhondo ( ebeyaziwa bona yi Piet Retief), Malalane, Ermelo, Barberton and Sabie.

Ukuthuthuka kwesifundesi.</text>
      <sha1>0inonhz5toudt0uugt96c2m8f4f0nnb</sha1>
    </revision>
    <revision>
      <id>909</id>
      <parentid>908</parentid>
      <timestamp>2024-03-09T10:45:57Z</timestamp>
      <contributor>
        <username>incubator&gt;Mzwakhe David18</username>
        <id>0</id>
      </contributor>
      <comment>Edited</comment>
      <origin>909</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2275" sha1="qnyogx71004n5g45j9pvviwskmmgudq" xml:space="preserve">

[[Isimumathi:Flag of Mpumalanga Province.svg|alt=iFlege yesifunda seMpumalanga|thumb|104x104px|iFlege yesifunda seMpumalanga.]]
'''Isifunda seMpumalanga''' Singesinye sesifuda esitholakala enarheni ye[[Isewula Afrika|Sewula Afrika]]. Sitholakala sitjhidelene nenmfunda ezintathu, ifinda seLimpopo, Kwazulu natal, kanye negauteng. Idorobho elikhulu lakhona yi[[Mbombela]] ebeyaziwa ngokobana yi[[Nelspruit]] kade. Ibuye ibeNamadorobha asthandathu: eMalahleni (ebeyaziwa nge Witbank), Standerton, eMkhondo ( ebeyaziwa bona yi Piet Retief), Malalane, Ermelo, Barberton and Sabie. 

== Ukuthuthuka kwesifundesi. ==
[[Isimumathi:Kusilekragsentrale, Mpumalanga, 2019, a.jpg|alt=IRhwebo yemayini.|thumb|334x334px|IRhwebo yemayini.]]
Isifundesi sithathele kude ukuthuthuka ukudlula imfunda zoke zeSewula Afrika kodwana Kwanje ituthuko sesele isezingeni eliphezulu ngombana urhulumnde wenarha uzamile ukwenza imizamo bona nayo ibonakale njengezinye indawo ezifana nabo ''[[gauteng]], [[Kwazulu Nata]]&lt;nowiki/&gt;l kanye nezinye ezinengi...'' Isifundesi kutholakale bona ngiso esifakelela khulu ukuthuthukiswa komnotho wesewula afrika ngombana kunendawo ezidlula ekhulwini ezinamamayini, kanye nehlabathi yakhona ilungele bona kube yindawo yokutjhala kuphume inthelo ezihle. Isifundesi siphethe eza[[mamayini]] (Mining), [[zokutjala]] Electricity [[gezi]] (Electricity)kanye  nezinye ezinengi. Kanyenenani labantu lisezingeni eliphezulu 
{| class=&quot;wikitable sortable&quot;
!
!Amabizo
!ikhowudu
!indawo
!Abantu abahlala lapho
!
|-
|
|Ehlanzeni District Municipality
|DC32
|Mbombela
|1,754,931
|
|-
|
|Gert Sibande District Municipality
|DC30
|Ermelo
|1,135,409
|
|-
|
|Nkangala District Municipality
|DC31
|Middelburg
|1,445,624
|
|}

== Amadistrict kanye Nabomaspala besewula afrika ==
Isifunda sempumalanga sinama [[District]] ama-3  kanye nabo [[Masipala]] aba li-17 Umasipala weHlanzeni unabomaspala abalandelako: umasipala we Bushbuckridge, City of Mbombela, Nkomazi, neThaba chew. Bese iDistrict yenkangala inabomaspala abalendelako, Thembisile, DR JS Moroka, eMakhazeni, Emalahleni, Steve tshwete kanye neVictor Kanye. Bese iDistrict yokugcina yiGert Sibande enabomaspala laba: Chief Albert Luthuli, Dipaleseng, Dr Pixley Ka Isaka Seme, Govan Mbeki, Lekwa, Mkhondo kanye ne Msukaligwa.</text>
      <sha1>qnyogx71004n5g45j9pvviwskmmgudq</sha1>
    </revision>
    <revision>
      <id>910</id>
      <parentid>909</parentid>
      <timestamp>2024-03-09T10:49:12Z</timestamp>
      <contributor>
        <username>incubator&gt;Mzwakhe David18</username>
        <id>0</id>
      </contributor>
      <comment>Edited</comment>
      <origin>910</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2263" sha1="c3clt7nvf6oxoxoloqrs9a1uk0u1ffo" xml:space="preserve">

[[Isimumathi:Flag of Mpumalanga Province.svg|alt=iFlege yesifunda seMpumalanga|thumb|104x104px|iFlege yesifunda seMpumalanga.]]
'''Isifunda seMpumalanga''' Singesinye sesifuda esitholakala enarheni ye[[Isewula Afrika|Sewula Afrika]]. Sitholakala sitjhidelene nenmfunda ezintathu, ifinda seLimpopo, Kwazulu natal, kanye negauteng. Idorobho elikhulu lakhona yi[[Mbombela]] ebeyaziwa ngokobana yi[[Nelspruit]] kade. Ibuye ibeNamadorobha asthandathu: eMalahleni (ebeyaziwa nge Witbank), Standerton, eMkhondo ( ebeyaziwa bona yi Piet Retief), Malalane, Ermelo, Barberton and Sabie. 

== Ukuthuthuka kwesifunda seMpumalanga . ==
[[Isimumathi:Kusilekragsentrale, Mpumalanga, 2019, a.jpg|alt=IRhwebo yemayini.|thumb|334x334px|IRhwebo yemayini.]]
Isifundesi sithathele kude ukuthuthuka ukudlula imfunda zoke zeSewula Afrika kodwana Kwanje ituthuko sesele isezingeni eliphezulu ngombana urhulumnde wenarha uzamile ukwenza imizamo bona nayo ibonakale njengezinye indawo ezifana nabo ''[[gauteng]], [[Kwazulu Nata]]&lt;nowiki/&gt;l kanye nezinye ezinengi...'' Isifundesi kutholakale bona ngiso esifakelela khulu ukuthuthukiswa komnotho wesewula afrika ngombana kunendawo ezidlula ekhulwini ezinamamayini, kanye nehlabathi yakhona ilungele bona kube yindawo yokutjhala kuphume inthelo ezihle. Isifundesi siphethe eza[[mamayini]] (Mining), [[zokutjala]] Electricity [[gezi]] (Electricity)kanye  nezinye ezinengi. Kanyenenani labantu lisezingeni eliphezulu 
{| class=&quot;wikitable sortable&quot;
!
!Amabizo wamaDistrict
!ikhowudu
!indawo
!Abantu abahlala lapho
!
|-
|
|Ehlanzeni District 
|DC32
|Mbombela
|1,754,931
|
|-
|
|Gert Sibande
|DC30
|Ermelo
|1,135,409
|
|-
|
|Nkangala District
|DC31
|Middelburg
|1,445,624
|
|}

== Amadistrict kanye NaboMaspala besifundeni seMpumalanga. ==
Isifunda sempumalanga sinama [[District]] ama-3  kanye nabo [[Masipala]] aba li-17 Umasipala weHlanzeni unabomaspala abalandelako: umasipala we Bushbuckridge, City of Mbombela, Nkomazi, neThaba chew. Bese iDistrict yenkangala inabomaspala abalendelako, Thembisile, DR JS Moroka, eMakhazeni, Emalahleni, Steve tshwete kanye neVictor Kanye. Bese iDistrict yokugcina yiGert Sibande enabomaspala laba: Chief Albert Luthuli, Dipaleseng, Dr Pixley Ka Isaka Seme, Govan Mbeki, Lekwa, Mkhondo kanye ne Msukaligwa.</text>
      <sha1>c3clt7nvf6oxoxoloqrs9a1uk0u1ffo</sha1>
    </revision>
    <revision>
      <id>911</id>
      <parentid>910</parentid>
      <timestamp>2024-03-09T12:01:45Z</timestamp>
      <contributor>
        <username>incubator&gt;Mzwakhe David18</username>
        <id>0</id>
      </contributor>
      <comment>added reference</comment>
      <origin>911</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2406" sha1="5yeij1hnpmc5gj1kaxp97i3fo4w4p88" xml:space="preserve">

[[Isimumathi:Flag of Mpumalanga Province.svg|alt=iFlege yesifunda seMpumalanga|thumb|104x104px|iFlege yesifunda seMpumalanga.]]
'''Isifunda seMpumalanga''' Singesinye sesifuda esitholakala enarheni ye[[Isewula Afrika|Sewula Afrika]]. Sitholakala sitjhidelene nenmfunda ezintathu, ifinda seLimpopo, Kwazulu natal, kanye negauteng. Idorobho elikhulu lakhona yi[[Mbombela]] ebeyaziwa ngokobana yi[[Nelspruit]] kade. Ibuye ibeNamadorobha asthandathu: eMalahleni (ebeyaziwa nge Witbank), Standerton, eMkhondo ( ebeyaziwa bona yi Piet Retief), Malalane, Ermelo, Barberton and Sabie.&lt;ref&gt;Frontiers | Competition for Land: The Water-Energy-Food Nexus and Coal Mining in Mpumalanga Province, South Africa (frontiersin.org)&lt;/ref&gt; 

== Ukuthuthuka kwesifunda seMpumalanga . ==
[[Isimumathi:Kusilekragsentrale, Mpumalanga, 2019, a.jpg|alt=IRhwebo yemayini.|thumb|334x334px|IRhwebo yemayini.]]
Isifundesi sithathele kude ukuthuthuka ukudlula imfunda zoke zeSewula Afrika kodwana Kwanje ituthuko sesele isezingeni eliphezulu ngombana urhulumnde wenarha uzamile ukwenza imizamo bona nayo ibonakale njengezinye indawo ezifana nabo ''[[gauteng]], [[Kwazulu Nata]]&lt;nowiki/&gt;l kanye nezinye ezinengi...'' Isifundesi kutholakale bona ngiso esifakelela khulu ukuthuthukiswa komnotho wesewula afrika ngombana kunendawo ezidlula ekhulwini ezinamamayini, kanye nehlabathi yakhona ilungele bona kube yindawo yokutjhala kuphume inthelo ezihle. Isifundesi siphethe eza[[mamayini]] (Mining), [[zokutjala]] Electricity [[gezi]] (Electricity)kanye  nezinye ezinengi. Kanyenenani labantu lisezingeni eliphezulu 
{| class=&quot;wikitable sortable&quot;
!
!Amabizo wamaDistrict
!ikhowudu
!indawo
!Abantu abahlala lapho
!
|-
|
|Ehlanzeni District 
|DC32
|Mbombela
|1,754,931
|
|-
|
|Gert Sibande
|DC30
|Ermelo
|1,135,409
|
|-
|
|Nkangala District
|DC31
|Middelburg
|1,445,624
|
|}

== Amadistrict kanye NaboMaspala besifundeni seMpumalanga. ==
Isifunda sempumalanga sinama [[District]] ama-3  kanye nabo [[Masipala]] aba li-17 Umasipala weHlanzeni unabomaspala abalandelako: umasipala we Bushbuckridge, City of Mbombela, Nkomazi, neThaba chew. Bese iDistrict yenkangala inabomaspala abalendelako, Thembisile, DR JS Moroka, eMakhazeni, Emalahleni, Steve tshwete kanye neVictor Kanye. Bese iDistrict yokugcina yiGert Sibande enabomaspala laba: Chief Albert Luthuli, Dipaleseng, Dr Pixley Ka Isaka Seme, Govan Mbeki, Lekwa, Mkhondo kanye ne Msukaligwa.</text>
      <sha1>5yeij1hnpmc5gj1kaxp97i3fo4w4p88</sha1>
    </revision>
    <revision>
      <id>912</id>
      <parentid>911</parentid>
      <timestamp>2024-03-10T20:30:01Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Adding interwiki links to [[d:Q132410]]</comment>
      <origin>912</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2429" sha1="12xy7exph8lfyq4z7ufx5p5bv6xb6tf" xml:space="preserve">

[[Isimumathi:Flag of Mpumalanga Province.svg|alt=iFlege yesifunda seMpumalanga|thumb|104x104px|iFlege yesifunda seMpumalanga.]]
'''Isifunda seMpumalanga''' Singesinye sesifuda esitholakala enarheni ye[[Isewula Afrika|Sewula Afrika]]. Sitholakala sitjhidelene nenmfunda ezintathu, ifinda seLimpopo, Kwazulu natal, kanye negauteng. Idorobho elikhulu lakhona yi[[Mbombela]] ebeyaziwa ngokobana yi[[Nelspruit]] kade. Ibuye ibeNamadorobha asthandathu: eMalahleni (ebeyaziwa nge Witbank), Standerton, eMkhondo ( ebeyaziwa bona yi Piet Retief), Malalane, Ermelo, Barberton and Sabie.&lt;ref&gt;Frontiers | Competition for Land: The Water-Energy-Food Nexus and Coal Mining in Mpumalanga Province, South Africa (frontiersin.org)&lt;/ref&gt; 

== Ukuthuthuka kwesifunda seMpumalanga . ==
[[Isimumathi:Kusilekragsentrale, Mpumalanga, 2019, a.jpg|alt=IRhwebo yemayini.|thumb|334x334px|IRhwebo yemayini.]]
Isifundesi sithathele kude ukuthuthuka ukudlula imfunda zoke zeSewula Afrika kodwana Kwanje ituthuko sesele isezingeni eliphezulu ngombana urhulumnde wenarha uzamile ukwenza imizamo bona nayo ibonakale njengezinye indawo ezifana nabo ''[[gauteng]], [[Kwazulu Nata]]&lt;nowiki/&gt;l kanye nezinye ezinengi...'' Isifundesi kutholakale bona ngiso esifakelela khulu ukuthuthukiswa komnotho wesewula afrika ngombana kunendawo ezidlula ekhulwini ezinamamayini, kanye nehlabathi yakhona ilungele bona kube yindawo yokutjhala kuphume inthelo ezihle. Isifundesi siphethe eza[[mamayini]] (Mining), [[zokutjala]] Electricity [[gezi]] (Electricity)kanye  nezinye ezinengi. Kanyenenani labantu lisezingeni eliphezulu 
{| class=&quot;wikitable sortable&quot;
!
!Amabizo wamaDistrict
!ikhowudu
!indawo
!Abantu abahlala lapho
!
|-
|
|Ehlanzeni District 
|DC32
|Mbombela
|1,754,931
|
|-
|
|Gert Sibande
|DC30
|Ermelo
|1,135,409
|
|-
|
|Nkangala District
|DC31
|Middelburg
|1,445,624
|
|}

== Amadistrict kanye NaboMaspala besifundeni seMpumalanga. ==
Isifunda sempumalanga sinama [[District]] ama-3  kanye nabo [[Masipala]] aba li-17 Umasipala weHlanzeni unabomaspala abalandelako: umasipala we Bushbuckridge, City of Mbombela, Nkomazi, neThaba chew. Bese iDistrict yenkangala inabomaspala abalendelako, Thembisile, DR JS Moroka, eMakhazeni, Emalahleni, Steve tshwete kanye neVictor Kanye. Bese iDistrict yokugcina yiGert Sibande enabomaspala laba: Chief Albert Luthuli, Dipaleseng, Dr Pixley Ka Isaka Seme, Govan Mbeki, Lekwa, Mkhondo kanye ne Msukaligwa.

{{INTERWIKI|Q132410}}</text>
      <sha1>12xy7exph8lfyq4z7ufx5p5bv6xb6tf</sha1>
    </revision>
    <revision>
      <id>913</id>
      <parentid>912</parentid>
      <timestamp>2024-10-14T13:46:55Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>5 revisions imported</comment>
      <origin>912</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2429" sha1="12xy7exph8lfyq4z7ufx5p5bv6xb6tf" xml:space="preserve">

[[Isimumathi:Flag of Mpumalanga Province.svg|alt=iFlege yesifunda seMpumalanga|thumb|104x104px|iFlege yesifunda seMpumalanga.]]
'''Isifunda seMpumalanga''' Singesinye sesifuda esitholakala enarheni ye[[Isewula Afrika|Sewula Afrika]]. Sitholakala sitjhidelene nenmfunda ezintathu, ifinda seLimpopo, Kwazulu natal, kanye negauteng. Idorobho elikhulu lakhona yi[[Mbombela]] ebeyaziwa ngokobana yi[[Nelspruit]] kade. Ibuye ibeNamadorobha asthandathu: eMalahleni (ebeyaziwa nge Witbank), Standerton, eMkhondo ( ebeyaziwa bona yi Piet Retief), Malalane, Ermelo, Barberton and Sabie.&lt;ref&gt;Frontiers | Competition for Land: The Water-Energy-Food Nexus and Coal Mining in Mpumalanga Province, South Africa (frontiersin.org)&lt;/ref&gt; 

== Ukuthuthuka kwesifunda seMpumalanga . ==
[[Isimumathi:Kusilekragsentrale, Mpumalanga, 2019, a.jpg|alt=IRhwebo yemayini.|thumb|334x334px|IRhwebo yemayini.]]
Isifundesi sithathele kude ukuthuthuka ukudlula imfunda zoke zeSewula Afrika kodwana Kwanje ituthuko sesele isezingeni eliphezulu ngombana urhulumnde wenarha uzamile ukwenza imizamo bona nayo ibonakale njengezinye indawo ezifana nabo ''[[gauteng]], [[Kwazulu Nata]]&lt;nowiki/&gt;l kanye nezinye ezinengi...'' Isifundesi kutholakale bona ngiso esifakelela khulu ukuthuthukiswa komnotho wesewula afrika ngombana kunendawo ezidlula ekhulwini ezinamamayini, kanye nehlabathi yakhona ilungele bona kube yindawo yokutjhala kuphume inthelo ezihle. Isifundesi siphethe eza[[mamayini]] (Mining), [[zokutjala]] Electricity [[gezi]] (Electricity)kanye  nezinye ezinengi. Kanyenenani labantu lisezingeni eliphezulu 
{| class=&quot;wikitable sortable&quot;
!
!Amabizo wamaDistrict
!ikhowudu
!indawo
!Abantu abahlala lapho
!
|-
|
|Ehlanzeni District 
|DC32
|Mbombela
|1,754,931
|
|-
|
|Gert Sibande
|DC30
|Ermelo
|1,135,409
|
|-
|
|Nkangala District
|DC31
|Middelburg
|1,445,624
|
|}

== Amadistrict kanye NaboMaspala besifundeni seMpumalanga. ==
Isifunda sempumalanga sinama [[District]] ama-3  kanye nabo [[Masipala]] aba li-17 Umasipala weHlanzeni unabomaspala abalandelako: umasipala we Bushbuckridge, City of Mbombela, Nkomazi, neThaba chew. Bese iDistrict yenkangala inabomaspala abalendelako, Thembisile, DR JS Moroka, eMakhazeni, Emalahleni, Steve tshwete kanye neVictor Kanye. Bese iDistrict yokugcina yiGert Sibande enabomaspala laba: Chief Albert Luthuli, Dipaleseng, Dr Pixley Ka Isaka Seme, Govan Mbeki, Lekwa, Mkhondo kanye ne Msukaligwa.

{{INTERWIKI|Q132410}}</text>
      <sha1>12xy7exph8lfyq4z7ufx5p5bv6xb6tf</sha1>
    </revision>
    <revision>
      <id>1672</id>
      <parentid>913</parentid>
      <timestamp>2024-10-16T09:49:58Z</timestamp>
      <contributor>
        <username>JhsBot</username>
        <id>34</id>
      </contributor>
      <minor />
      <comment>bot: Removing interwiki template; the page is now connected to [[d:Q132410]]</comment>
      <origin>1672</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2406" sha1="5yeij1hnpmc5gj1kaxp97i3fo4w4p88" xml:space="preserve">

[[Isimumathi:Flag of Mpumalanga Province.svg|alt=iFlege yesifunda seMpumalanga|thumb|104x104px|iFlege yesifunda seMpumalanga.]]
'''Isifunda seMpumalanga''' Singesinye sesifuda esitholakala enarheni ye[[Isewula Afrika|Sewula Afrika]]. Sitholakala sitjhidelene nenmfunda ezintathu, ifinda seLimpopo, Kwazulu natal, kanye negauteng. Idorobho elikhulu lakhona yi[[Mbombela]] ebeyaziwa ngokobana yi[[Nelspruit]] kade. Ibuye ibeNamadorobha asthandathu: eMalahleni (ebeyaziwa nge Witbank), Standerton, eMkhondo ( ebeyaziwa bona yi Piet Retief), Malalane, Ermelo, Barberton and Sabie.&lt;ref&gt;Frontiers | Competition for Land: The Water-Energy-Food Nexus and Coal Mining in Mpumalanga Province, South Africa (frontiersin.org)&lt;/ref&gt; 

== Ukuthuthuka kwesifunda seMpumalanga . ==
[[Isimumathi:Kusilekragsentrale, Mpumalanga, 2019, a.jpg|alt=IRhwebo yemayini.|thumb|334x334px|IRhwebo yemayini.]]
Isifundesi sithathele kude ukuthuthuka ukudlula imfunda zoke zeSewula Afrika kodwana Kwanje ituthuko sesele isezingeni eliphezulu ngombana urhulumnde wenarha uzamile ukwenza imizamo bona nayo ibonakale njengezinye indawo ezifana nabo ''[[gauteng]], [[Kwazulu Nata]]&lt;nowiki/&gt;l kanye nezinye ezinengi...'' Isifundesi kutholakale bona ngiso esifakelela khulu ukuthuthukiswa komnotho wesewula afrika ngombana kunendawo ezidlula ekhulwini ezinamamayini, kanye nehlabathi yakhona ilungele bona kube yindawo yokutjhala kuphume inthelo ezihle. Isifundesi siphethe eza[[mamayini]] (Mining), [[zokutjala]] Electricity [[gezi]] (Electricity)kanye  nezinye ezinengi. Kanyenenani labantu lisezingeni eliphezulu 
{| class=&quot;wikitable sortable&quot;
!
!Amabizo wamaDistrict
!ikhowudu
!indawo
!Abantu abahlala lapho
!
|-
|
|Ehlanzeni District 
|DC32
|Mbombela
|1,754,931
|
|-
|
|Gert Sibande
|DC30
|Ermelo
|1,135,409
|
|-
|
|Nkangala District
|DC31
|Middelburg
|1,445,624
|
|}

== Amadistrict kanye NaboMaspala besifundeni seMpumalanga. ==
Isifunda sempumalanga sinama [[District]] ama-3  kanye nabo [[Masipala]] aba li-17 Umasipala weHlanzeni unabomaspala abalandelako: umasipala we Bushbuckridge, City of Mbombela, Nkomazi, neThaba chew. Bese iDistrict yenkangala inabomaspala abalendelako, Thembisile, DR JS Moroka, eMakhazeni, Emalahleni, Steve tshwete kanye neVictor Kanye. Bese iDistrict yokugcina yiGert Sibande enabomaspala laba: Chief Albert Luthuli, Dipaleseng, Dr Pixley Ka Isaka Seme, Govan Mbeki, Lekwa, Mkhondo kanye ne Msukaligwa.</text>
      <sha1>5yeij1hnpmc5gj1kaxp97i3fo4w4p88</sha1>
    </revision>
  </page>
  <page>
    <title>Isihlathululimagama/isihlathululimezwi</title>
    <ns>0</ns>
    <id>191</id>
    <revision>
      <id>914</id>
      <timestamp>2024-07-21T09:37:33Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;== Isihlathululimagama/isihlathululimezwi == Isihlathululimagama, abanye basazi bona sihlathululimezwi, sisetjenziswa esinehlathululo ebudisi khulu. Asinayo ihlathululo eyodwa. Kodwana ngokuya kuka-Bejoint (2002:9) ihlathululo yesihlathululimagama kufanele ifake izinto nanzi ezilandelako:   a) isihlathululimagama silirhelomjeje weendima ezihlukeneko.  b) isihlathululimagama senzelwe ukubonisa.  c) iinhlathululimagama zinamaphahla amabili.  d) Isihlathululimagama siziinqh...&quot;</comment>
      <origin>914</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3723" sha1="pi9crxqp0p5z3glhbv3bcwmurwm3ty7" xml:space="preserve">== Isihlathululimagama/isihlathululimezwi ==
Isihlathululimagama, abanye basazi bona sihlathululimezwi, sisetjenziswa esinehlathululo ebudisi khulu. Asinayo ihlathululo eyodwa. Kodwana ngokuya kuka-Bejoint (2002:9) ihlathululo yesihlathululimagama kufanele ifake izinto nanzi ezilandelako: 

a) isihlathululimagama silirhelomjeje weendima ezihlukeneko.

b) isihlathululimagama senzelwe ukubonisa.

c) iinhlathululimagama zinamaphahla amabili.

d) Isihlathululimagama siziinqhema ezihlelwe ngokulandelana.

e) isihlathululimagama siyingcenye yamarhelo welimi.

f) Isihlathululimagama siyincwadi yokulayela nokufundisa.

g) Isihlathululimagama sinikela ngelwazi elimayelana namatshwayo welimi.

h) Isihlathululimagama kusisethulo esihleliweko seengcenye eziquntwe ngaphambilini zeenhlathululimagama.

Amaphuzu angehla la, aveza isihlathululimagama ngokuya kwemisebenzi neendingo zaso. Nanyana kunjalo, kuba budisi khulu ukuthola ihlathululo efaka woke amaphuzu abalwe ngehla la. 

UGau ngomnyaka ka-2010, wahlathulula isihlathululimagama wathi, sisetjenziswa nanyana sitjabagelo leso esisetjenziselwa ukufunda nokunabisa ilwazi ngokusiqalisisa erhubhululweni. Ihlathululo engehla le, inqophe khulu kubarhubhululi nabafundi labo abafunda ukurhubhulula ngesihlathululimagama kanye nokuzwisisa isihlathululimagama emikhakheni yezefundo nesayenzi.  

U-Singh ngomnyaka ka-2010, waba nehlathululo ehlukileko yesihlathululimagama lapho athi, isihlathululimagama yincwadi yeriferensi mayelana namagama nanyana amathemu. Ihlathululo le inqophe, khulukhulu, kuwo woke umuntu osebenzisa isihlathululimagama ngebanga lesitjhijilo nanyana Isidingo anaso. Isidingo nanyana isitjhijilo leso kungenzeka bonyana ngesekulumo ejayelekileko nanyana somkhakha okhethekileko. Ihlathululo kaSingh (2010) esitjela khona kukobana isihlathululimagama sisetjenziswa esinikela ngeensombululo zelimi nethintwana lelimi lelo elisetjenziswako msebenzisi oqothelweko.  

Ihlathululo yesine siyinikelwa nguLampung (2016) lapho athi, isihlathululimagama silirhelo lamagama arhenyiswe ngokulandelana kwamaledere lelo elethula ihlathululo begodu linikela nelwazi lokuphimisa iinhlathululo nemvelaphi yawo. Ihlathulullo le inqophe khulu kusayensi yezokutlanywa kweenhlathululimagama leyo ebizwa ngokuthi iLezikhografi. Ukungezelela, ibuye ikhulume ngesakhiwo sangaphakathi nanyana selwazi langaphakathi lesihlathululimagama.  

Ihlathululo yokugcina siyinikelwa ngu-Bergenholtz (2012) nakathi, isihlathululimagama siyincwadi yamagama ahlelwengelandelwano nelwazi mayelana nokupeleda, iingaba zamabizo namatjhugululo wamagama alethwa lilimi neenhlathululo zamagama nanyana inrhunye lawo ukuya kwelinye ilimi. Nawutjheja ihlathululo le, uzokuyelela bonyana ilinge ukufana isakhiwo nemisebenzi eyenziwa sihlathululimagama. Nawuyifundako uyazi bonyana ulindele miphi imisebenzi begodu ulindele ukuthola ini ngaphakathi kwesihlathululi magama. 

Iinhlathulumagama ezingehla lezi zoke zinqophile, begodu zitjengisa imisebenzi, isakhiwo kanye nomhlobo wencwadi lo obizwa bonyana sihlathululimagama bonyana unjani. Ngalokho, kungakho sivezile ekuthomeni bonyana ihlathululo yesihlathululimagama ibudisi ukuyihlathulula ngehlathululo eyedwa, ngebanga lesakhiwo nemisebenzi yaso.

=== Umthombolwazi ===
Béjoint, H. (2002). ‘An introduction of modern lexicography’. Beijing: Foreign Teaching and Research Press.

Bergenholtz, H. (2012). ‘What is a Dictionary?’ Lexikos. 22:20-30.

Gao, L. (2010). ‘Historical Background of the Translatological Dictionaries’. Journal of Language Teaching and Research. 1(3):285-294.

Lampung, I. R. I. (2016). ‘Dictionary Usage in English Language Learning’. English Education:Journal Tadris Bahaa Inggris. 9(1):186-197.

</text>
      <sha1>pi9crxqp0p5z3glhbv3bcwmurwm3ty7</sha1>
    </revision>
    <revision>
      <id>915</id>
      <parentid>914</parentid>
      <timestamp>2024-08-06T06:18:31Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <comment>/* Isihlathululimagama/isihlathululimezwi */</comment>
      <origin>915</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3966" sha1="okflragmx3rsfpsjcw4wetydhobhlfl" xml:space="preserve">== Isihlathululimagama/isihlathululimezwi ==
Isihlathululimagama, abanye basazi bona sihlathululimezwi, sisetjenziswa esinehlathululo ebudisi khulu. Asinayo ihlathululo eyodwa. Kodwana ngokuya kuka-Bejoint&lt;ref name=&quot;:0&quot;&gt;Béjoint, H. (2002). ‘''An introduction of modern lexicography’''. Beijing: Foreign Teaching and Research Press.&lt;/ref&gt; (2002:9) ihlathululo yesihlathululimagama kufanele ifake izinto nanzi ezilandelako: 

a) isihlathululimagama silirhelomjeje weendima ezihlukeneko.

b) isihlathululimagama senzelwe ukubonisa.

c) iinhlathululimagama zinamaphahla amabili.

d) Isihlathululimagama siziinqhema ezihlelwe ngokulandelana.

e) isihlathululimagama siyingcenye yamarhelo welimi.

f) Isihlathululimagama siyincwadi yokulayela nokufundisa.

g) Isihlathululimagama sinikela ngelwazi elimayelana namatshwayo welimi.

h) Isihlathululimagama kusisethulo esihleliweko seengcenye eziquntwe ngaphambilini zeenhlathululimagama.

Amaphuzu angehla la, aveza isihlathululimagama ngokuya kwemisebenzi neendingo zaso. Nanyana kunjalo, kuba budisi khulu ukuthola ihlathululo efaka woke amaphuzu abalwe ngehla la. 

UGau&lt;ref&gt;Gao, L. (2010). ‘Historical Background of the Translatological Dictionaries’. ''Journal of Language Teaching and Research.'' 1(3):285-294.&lt;/ref&gt; ngomnyaka ka-2010, wahlathulula isihlathululimagama wathi, sisetjenziswa nanyana sitjabagelo leso esisetjenziselwa ukufunda nokunabisa ilwazi ngokusiqalisisa erhubhululweni. Ihlathululo engehla le, inqophe khulu kubarhubhululi nabafundi labo abafunda ukurhubhulula ngesihlathululimagama kanye nokuzwisisa isihlathululimagama emikhakheni yezefundo nesayenzi.  

U-Singh&lt;ref name=&quot;:1&quot;&gt;Singh, P. (2010). ‘Dictionary and Its Structure’. In ''Research Journal of Indian Cultural, Social &amp; Philosophical Stream Mehta'', Edited by M. K. Mehta. ''ANUSILANA'' 24. Manvi Seva Samiti: 1-6.&lt;/ref&gt; ngomnyaka ka-2010, waba nehlathululo ehlukileko yesihlathululimagama lapho athi, isihlathululimagama yincwadi yeriferensi mayelana namagama nanyana amathemu. Ihlathululo le inqophe, khulukhulu, kuwo woke umuntu osebenzisa isihlathululimagama ngebanga lesitjhijilo nanyana Isidingo anaso. Isidingo nanyana isitjhijilo leso kungenzeka bonyana ngesekulumo ejayelekileko nanyana somkhakha okhethekileko. Ihlathululo kaSingh&lt;ref name=&quot;:1&quot; /&gt; (2010) esitjela khona kukobana isihlathululimagama sisetjenziswa esinikela ngeensombululo zelimi nethintwana lelimi lelo elisetjenziswako msebenzisi oqothelweko.  

Ihlathululo yesine siyinikelwa nguLampung&lt;ref&gt;Lampung, I. R. I. (2016). ‘Dictionary Usage in English Language Learning’. English Education:Journal Tadris Bahaa Inggris. 9(1):186-197.&lt;/ref&gt; (2016) lapho athi, isihlathululimagama silirhelo lamagama arhenyiswe ngokulandelana kwamaledere lelo elethula ihlathululo begodu linikela nelwazi lokuphimisa iinhlathululo nemvelaphi yawo. Ihlathulullo le inqophe khulu kusayensi yezokutlanywa kweenhlathululimagama leyo ebizwa ngokuthi iLezikhografi. Ukungezelela, ibuye ikhulume ngesakhiwo sangaphakathi nanyana selwazi langaphakathi lesihlathululimagama.  

Ihlathululo yokugcina siyinikelwa ngu-Bergenholtz &lt;ref name=&quot;:0&quot; /&gt;(2012) nakathi, isihlathululimagama siyincwadi yamagama ahlelwengelandelwano nelwazi mayelana nokupeleda, iingaba zamabizo namatjhugululo wamagama alethwa lilimi neenhlathululo zamagama nanyana inrhunye lawo ukuya kwelinye ilimi. Nawutjheja ihlathululo le, uzokuyelela bonyana ilinge ukufana isakhiwo nemisebenzi eyenziwa sihlathululimagama. Nawuyifundako uyazi bonyana ulindele miphi imisebenzi begodu ulindele ukuthola ini ngaphakathi kwesihlathululi magama. 

Iinhlathulumagama ezingehla lezi zoke zinqophile, begodu zitjengisa imisebenzi, isakhiwo kanye nomhlobo wencwadi lo obizwa bonyana sihlathululimagama bonyana unjani. Ngalokho, kungakho sivezile ekuthomeni bonyana ihlathululo yesihlathululimagama ibudisi ukuyihlathulula ngehlathululo eyedwa, ngebanga lesakhiwo nemisebenzi yaso.

=== Umthombolwazi ===
&lt;references /&gt;

</text>
      <sha1>okflragmx3rsfpsjcw4wetydhobhlfl</sha1>
    </revision>
    <revision>
      <id>916</id>
      <parentid>915</parentid>
      <timestamp>2024-08-06T06:48:03Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <origin>916</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4055" sha1="g0xzwigygr960mh87brbr6r6ure24bn" xml:space="preserve">== Isihlathululimagama/isihlathululimezwi ==
Isihlathululimagama, abanye basazi bona sihlathululimezwi, sisetjenziswa esinehlathululo ebudisi khulu. Asinayo ihlathululo eyodwa. Kodwana ngokuya kuka-Bejoint&lt;ref name=&quot;:0&quot;&gt;Béjoint, H. (2002). ‘''An introduction of modern lexicography’''. Beijing: Foreign Teaching and Research Press.&lt;/ref&gt; (2002:9) ihlathululo yesihlathululimagama kufanele ifake izinto nanzi ezilandelako: 
[[Isimumathi:IsiHlathululimagama.jpg|thumb|Isihlathululimagama sesiNdebele esilimimbili]]
a) isihlathululimagama silirhelomjeje weendima ezihlukeneko.

b) isihlathululimagama senzelwe ukubonisa.

c) iinhlathululimagama zinamaphahla amabili.

d) Isihlathululimagama siziinqhema ezihlelwe ngokulandelana.

e) isihlathululimagama siyingcenye yamarhelo welimi.

f) Isihlathululimagama siyincwadi yokulayela nokufundisa.

g) Isihlathululimagama sinikela ngelwazi elimayelana namatshwayo welimi.

h) Isihlathululimagama kusisethulo esihleliweko seengcenye eziquntwe ngaphambilini zeenhlathululimagama.

Amaphuzu angehla la, aveza isihlathululimagama ngokuya kwemisebenzi neendingo zaso. Nanyana kunjalo, kuba budisi khulu ukuthola ihlathululo efaka woke amaphuzu abalwe ngehla la. 

UGau&lt;ref&gt;Gao, L. (2010). ‘Historical Background of the Translatological Dictionaries’. ''Journal of Language Teaching and Research.'' 1(3):285-294.&lt;/ref&gt; ngomnyaka ka-2010, wahlathulula isihlathululimagama wathi, sisetjenziswa nanyana sitjabagelo leso esisetjenziselwa ukufunda nokunabisa ilwazi ngokusiqalisisa erhubhululweni. Ihlathululo engehla le, inqophe khulu kubarhubhululi nabafundi labo abafunda ukurhubhulula ngesihlathululimagama kanye nokuzwisisa isihlathululimagama emikhakheni yezefundo nesayenzi.  

U-Singh&lt;ref name=&quot;:1&quot;&gt;Singh, P. (2010). ‘Dictionary and Its Structure’. In ''Research Journal of Indian Cultural, Social &amp; Philosophical Stream Mehta'', Edited by M. K. Mehta. ''ANUSILANA'' 24. Manvi Seva Samiti: 1-6.&lt;/ref&gt; ngomnyaka ka-2010, waba nehlathululo ehlukileko yesihlathululimagama lapho athi, isihlathululimagama yincwadi yeriferensi mayelana namagama nanyana amathemu. Ihlathululo le inqophe, khulukhulu, kuwo woke umuntu osebenzisa isihlathululimagama ngebanga lesitjhijilo nanyana Isidingo anaso. Isidingo nanyana isitjhijilo leso kungenzeka bonyana ngesekulumo ejayelekileko nanyana somkhakha okhethekileko. Ihlathululo kaSingh&lt;ref name=&quot;:1&quot; /&gt; (2010) esitjela khona kukobana isihlathululimagama sisetjenziswa esinikela ngeensombululo zelimi nethintwana lelimi lelo elisetjenziswako msebenzisi oqothelweko.  

Ihlathululo yesine siyinikelwa nguLampung&lt;ref&gt;Lampung, I. R. I. (2016). ‘Dictionary Usage in English Language Learning’. English Education:Journal Tadris Bahaa Inggris. 9(1):186-197.&lt;/ref&gt; (2016) lapho athi, isihlathululimagama silirhelo lamagama arhenyiswe ngokulandelana kwamaledere lelo elethula ihlathululo begodu linikela nelwazi lokuphimisa iinhlathululo nemvelaphi yawo. Ihlathulullo le inqophe khulu kusayensi yezokutlanywa kweenhlathululimagama leyo ebizwa ngokuthi iLezikhografi. Ukungezelela, ibuye ikhulume ngesakhiwo sangaphakathi nanyana selwazi langaphakathi lesihlathululimagama.  

Ihlathululo yokugcina siyinikelwa ngu-Bergenholtz &lt;ref name=&quot;:0&quot; /&gt;(2012) nakathi, isihlathululimagama siyincwadi yamagama ahlelwengelandelwano nelwazi mayelana nokupeleda, iingaba zamabizo namatjhugululo wamagama alethwa lilimi neenhlathululo zamagama nanyana inrhunye lawo ukuya kwelinye ilimi. Nawutjheja ihlathululo le, uzokuyelela bonyana ilinge ukufana isakhiwo nemisebenzi eyenziwa sihlathululimagama. Nawuyifundako uyazi bonyana ulindele miphi imisebenzi begodu ulindele ukuthola ini ngaphakathi kwesihlathululi magama. 

Iinhlathulumagama ezingehla lezi zoke zinqophile, begodu zitjengisa imisebenzi, isakhiwo kanye nomhlobo wencwadi lo obizwa bonyana sihlathululimagama bonyana unjani. Ngalokho, kungakho sivezile ekuthomeni bonyana ihlathululo yesihlathululimagama ibudisi ukuyihlathulula ngehlathululo eyedwa, ngebanga lesakhiwo nemisebenzi yaso.

=== Umthombolwazi ===
&lt;references /&gt;

</text>
      <sha1>g0xzwigygr960mh87brbr6r6ure24bn</sha1>
    </revision>
    <revision>
      <id>917</id>
      <parentid>916</parentid>
      <timestamp>2024-08-06T14:20:32Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <comment>/* Isihlathululimagama/isihlathululimezwi */</comment>
      <origin>917</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4074" sha1="fz7pctrcz8chrqx1188m3zy6kb0kpr8" xml:space="preserve">== Isihlathululimagama/isihlathululimezwi ==
[[:en:Dictionary|Isihlathululimagama]], abanye basazi bona sihlathululimezwi, sisetjenziswa esinehlathululo ebudisi khulu. Asinayo ihlathululo eyodwa. Kodwana ngokuya kuka-Bejoint&lt;ref name=&quot;:0&quot;&gt;Béjoint, H. (2002). ‘''An introduction of modern lexicography’''. Beijing: Foreign Teaching and Research Press.&lt;/ref&gt; (2002:9) ihlathululo yesihlathululimagama kufanele ifake izinto nanzi ezilandelako: 
[[Isimumathi:IsiHlathululimagama.jpg|thumb|Isihlathululimagama sesiNdebele esilimimbili]]
a) isihlathululimagama silirhelomjeje weendima ezihlukeneko.

b) isihlathululimagama senzelwe ukubonisa.

c) iinhlathululimagama zinamaphahla amabili.

d) Isihlathululimagama siziinqhema ezihlelwe ngokulandelana.

e) isihlathululimagama siyingcenye yamarhelo welimi.

f) Isihlathululimagama siyincwadi yokulayela nokufundisa.

g) Isihlathululimagama sinikela ngelwazi elimayelana namatshwayo welimi.

h) Isihlathululimagama kusisethulo esihleliweko seengcenye eziquntwe ngaphambilini zeenhlathululimagama.

Amaphuzu angehla la, aveza isihlathululimagama ngokuya kwemisebenzi neendingo zaso. Nanyana kunjalo, kuba budisi khulu ukuthola ihlathululo efaka woke amaphuzu abalwe ngehla la. 

UGau&lt;ref&gt;Gao, L. (2010). ‘Historical Background of the Translatological Dictionaries’. ''Journal of Language Teaching and Research.'' 1(3):285-294.&lt;/ref&gt; ngomnyaka ka-2010, wahlathulula isihlathululimagama wathi, sisetjenziswa nanyana sitjabagelo leso esisetjenziselwa ukufunda nokunabisa ilwazi ngokusiqalisisa erhubhululweni. Ihlathululo engehla le, inqophe khulu kubarhubhululi nabafundi labo abafunda ukurhubhulula ngesihlathululimagama kanye nokuzwisisa isihlathululimagama emikhakheni yezefundo nesayenzi.  

U-Singh&lt;ref name=&quot;:1&quot;&gt;Singh, P. (2010). ‘Dictionary and Its Structure’. In ''Research Journal of Indian Cultural, Social &amp; Philosophical Stream Mehta'', Edited by M. K. Mehta. ''ANUSILANA'' 24. Manvi Seva Samiti: 1-6.&lt;/ref&gt; ngomnyaka ka-2010, waba nehlathululo ehlukileko yesihlathululimagama lapho athi, isihlathululimagama yincwadi yeriferensi mayelana namagama nanyana amathemu. Ihlathululo le inqophe, khulukhulu, kuwo woke umuntu osebenzisa isihlathululimagama ngebanga lesitjhijilo nanyana Isidingo anaso. Isidingo nanyana isitjhijilo leso kungenzeka bonyana ngesekulumo ejayelekileko nanyana somkhakha okhethekileko. Ihlathululo kaSingh&lt;ref name=&quot;:1&quot; /&gt; (2010) esitjela khona kukobana isihlathululimagama sisetjenziswa esinikela ngeensombululo zelimi nethintwana lelimi lelo elisetjenziswako msebenzisi oqothelweko.  

Ihlathululo yesine siyinikelwa nguLampung&lt;ref&gt;Lampung, I. R. I. (2016). ‘Dictionary Usage in English Language Learning’. English Education:Journal Tadris Bahaa Inggris. 9(1):186-197.&lt;/ref&gt; (2016) lapho athi, isihlathululimagama silirhelo lamagama arhenyiswe ngokulandelana kwamaledere lelo elethula ihlathululo begodu linikela nelwazi lokuphimisa iinhlathululo nemvelaphi yawo. Ihlathulullo le inqophe khulu kusayensi yezokutlanywa kweenhlathululimagama leyo ebizwa ngokuthi iLezikhografi. Ukungezelela, ibuye ikhulume ngesakhiwo sangaphakathi nanyana selwazi langaphakathi lesihlathululimagama.  

Ihlathululo yokugcina siyinikelwa ngu-Bergenholtz &lt;ref name=&quot;:0&quot; /&gt;(2012) nakathi, isihlathululimagama siyincwadi yamagama ahlelwengelandelwano nelwazi mayelana nokupeleda, iingaba zamabizo namatjhugululo wamagama alethwa lilimi neenhlathululo zamagama nanyana inrhunye lawo ukuya kwelinye ilimi. Nawutjheja ihlathululo le, uzokuyelela bonyana ilinge ukufana isakhiwo nemisebenzi eyenziwa sihlathululimagama. Nawuyifundako uyazi bonyana ulindele miphi imisebenzi begodu ulindele ukuthola ini ngaphakathi kwesihlathululi magama. 

Iinhlathulumagama ezingehla lezi zoke zinqophile, begodu zitjengisa imisebenzi, isakhiwo kanye nomhlobo wencwadi lo obizwa bonyana sihlathululimagama bonyana unjani. Ngalokho, kungakho sivezile ekuthomeni bonyana ihlathululo yesihlathululimagama ibudisi ukuyihlathulula ngehlathululo eyedwa, ngebanga lesakhiwo nemisebenzi yaso.

=== Umthombolwazi ===
&lt;references /&gt;

</text>
      <sha1>fz7pctrcz8chrqx1188m3zy6kb0kpr8</sha1>
    </revision>
    <revision>
      <id>918</id>
      <parentid>917</parentid>
      <timestamp>2024-09-18T15:54:28Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>918</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4113" sha1="cm3dkubyqq0rjdpwemgrggw5z1xf8uv" xml:space="preserve">== Isihlathululimagama/isihlathululimezwi. ==

=== Isingeniso ===
[[:en:Dictionary|Isihlathululimagama]], abanye basazi bona sihlathululimezwi, sisetjenziswa esinehlathululo ebudisi khulu. Asinayo ihlathululo eyodwa. Kodwana ngokuya kuka-Bejoint&lt;ref name=&quot;:0&quot;&gt;Béjoint, H. (2002). ‘''An introduction of modern lexicography’''. Beijing: Foreign Teaching and Research Press.&lt;/ref&gt; (2002:9) ihlathululo yesihlathululimagama kufanele ifake izinto nanzi ezilandelako: 
[[Isimumathi:IsiHlathululimagama.jpg|thumb|Isihlathululimagama sesiNdebele esilimimbili]]
a) isihlathululimagama silirhelomjeje weendima ezihlukeneko.

b) isihlathululimagama senzelwe ukubonisa.

c) iinhlathululimagama zinamaphahla amabili.

d) Isihlathululimagama siziinqhema ezihlelwe ngokulandelana.

e) isihlathululimagama siyingcenye yamarhelo welimi.

f) Isihlathululimagama siyincwadi yokulayela nokufundisa.

g) Isihlathululimagama sinikela ngelwazi elimayelana namatshwayo welimi.

h) Isihlathululimagama kusisethulo esihleliweko seengcenye eziquntwe ngaphambilini zeenhlathululimagama.

Amaphuzu angehla la, aveza isihlathululimagama ngokuya kwemisebenzi neendingo zaso. Nanyana kunjalo, kuba budisi khulu ukuthola ihlathululo efaka woke amaphuzu abalwe ngehla la. 

UGau&lt;ref&gt;Gao, L. (2010). ‘Historical Background of the Translatological Dictionaries’. ''Journal of Language Teaching and Research.'' 1(3):285-294.&lt;/ref&gt; ngomnyaka ka-2010, wahlathulula isihlathululimagama wathi, sisetjenziswa nanyana sitjabagelo leso esisetjenziselwa ukufunda nokunabisa ilwazi ngokusiqalisisa erhubhululweni. Ihlathululo engehla le, inqophe khulu kubarhubhululi nabafundi labo abafunda ukurhubhulula ngesihlathululimagama kanye nokuzwisisa isihlathululimagama emikhakheni yezefundo nesayenzi.  

U-Singh&lt;ref name=&quot;:1&quot;&gt;Singh, P. (2010). ‘Dictionary and Its Structure’. In ''Research Journal of Indian Cultural, Social &amp; Philosophical Stream Mehta'', Edited by M. K. Mehta. ''ANUSILANA'' 24. Manvi Seva Samiti: 1-6.&lt;/ref&gt; ngomnyaka ka-2010, waba nehlathululo ehlukileko yesihlathululimagama lapho athi, isihlathululimagama yincwadi yeriferensi mayelana namagama nanyana amathemu. Ihlathululo le inqophe, khulukhulu, kuwo woke umuntu osebenzisa isihlathululimagama ngebanga lesitjhijilo nanyana Isidingo anaso. Isidingo nanyana isitjhijilo leso kungenzeka bonyana ngesekulumo ejayelekileko nanyana somkhakha okhethekileko. Ihlathululo kaSingh&lt;ref name=&quot;:1&quot; /&gt; (2010) esitjela khona kukobana isihlathululimagama sisetjenziswa esinikela ngeensombululo zelimi nethintwana lelimi lelo elisetjenziswako msebenzisi oqothelweko.  

Ihlathululo yesine siyinikelwa nguLampung&lt;ref&gt;Lampung, I. R. I. (2016). ‘Dictionary Usage in English Language Learning’. English Education:Journal Tadris Bahaa Inggris. 9(1):186-197.&lt;/ref&gt; (2016) lapho athi, isihlathululimagama silirhelo lamagama arhenyiswe ngokulandelana kwamaledere lelo elethula ihlathululo begodu linikela nelwazi lokuphimisa iinhlathululo nemvelaphi yawo. Ihlathulullo le inqophe khulu kusayensi yezokutlanywa kweenhlathululimagama leyo ebizwa ngokuthi iLezikhografi. Ukungezelela, ibuye ikhulume ngesakhiwo sangaphakathi nanyana selwazi langaphakathi lesihlathululimagama.  

Ihlathululo yokugcina siyinikelwa ngu-Bergenholtz &lt;ref name=&quot;:0&quot; /&gt;(2012) nakathi, isihlathululimagama siyincwadi yamagama ahlelwengelandelwano nelwazi mayelana nokupeleda, iingaba zamabizo namatjhugululo wamagama alethwa lilimi neenhlathululo zamagama nanyana inrhunye lawo ukuya kwelinye ilimi. Nawutjheja ihlathululo le, uzokuyelela bonyana ilinge ukufana isakhiwo nemisebenzi eyenziwa sihlathululimagama. Nawuyifundako uyazi bonyana ulindele miphi imisebenzi begodu ulindele ukuthola ini ngaphakathi kwesihlathululi magama. 

=== Isiphetho ===
Iinhlathulumagama ezingehla lezi zoke zinqophile, begodu zitjengisa imisebenzi, isakhiwo kanye nomhlobo wencwadi lo obizwa bonyana sihlathululimagama bonyana unjani. Ngalokho, kungakho sivezile ekuthomeni bonyana ihlathululo yesihlathululimagama ibudisi ukuyihlathulula ngehlathululo eyedwa, ngebanga lesakhiwo nemisebenzi yaso.

=== Umthombolwazi ===
&lt;references /&gt;

</text>
      <sha1>cm3dkubyqq0rjdpwemgrggw5z1xf8uv</sha1>
    </revision>
    <revision>
      <id>919</id>
      <parentid>918</parentid>
      <timestamp>2024-10-14T13:46:55Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>5 revisions imported</comment>
      <origin>918</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4113" sha1="cm3dkubyqq0rjdpwemgrggw5z1xf8uv" xml:space="preserve">== Isihlathululimagama/isihlathululimezwi. ==

=== Isingeniso ===
[[:en:Dictionary|Isihlathululimagama]], abanye basazi bona sihlathululimezwi, sisetjenziswa esinehlathululo ebudisi khulu. Asinayo ihlathululo eyodwa. Kodwana ngokuya kuka-Bejoint&lt;ref name=&quot;:0&quot;&gt;Béjoint, H. (2002). ‘''An introduction of modern lexicography’''. Beijing: Foreign Teaching and Research Press.&lt;/ref&gt; (2002:9) ihlathululo yesihlathululimagama kufanele ifake izinto nanzi ezilandelako: 
[[Isimumathi:IsiHlathululimagama.jpg|thumb|Isihlathululimagama sesiNdebele esilimimbili]]
a) isihlathululimagama silirhelomjeje weendima ezihlukeneko.

b) isihlathululimagama senzelwe ukubonisa.

c) iinhlathululimagama zinamaphahla amabili.

d) Isihlathululimagama siziinqhema ezihlelwe ngokulandelana.

e) isihlathululimagama siyingcenye yamarhelo welimi.

f) Isihlathululimagama siyincwadi yokulayela nokufundisa.

g) Isihlathululimagama sinikela ngelwazi elimayelana namatshwayo welimi.

h) Isihlathululimagama kusisethulo esihleliweko seengcenye eziquntwe ngaphambilini zeenhlathululimagama.

Amaphuzu angehla la, aveza isihlathululimagama ngokuya kwemisebenzi neendingo zaso. Nanyana kunjalo, kuba budisi khulu ukuthola ihlathululo efaka woke amaphuzu abalwe ngehla la. 

UGau&lt;ref&gt;Gao, L. (2010). ‘Historical Background of the Translatological Dictionaries’. ''Journal of Language Teaching and Research.'' 1(3):285-294.&lt;/ref&gt; ngomnyaka ka-2010, wahlathulula isihlathululimagama wathi, sisetjenziswa nanyana sitjabagelo leso esisetjenziselwa ukufunda nokunabisa ilwazi ngokusiqalisisa erhubhululweni. Ihlathululo engehla le, inqophe khulu kubarhubhululi nabafundi labo abafunda ukurhubhulula ngesihlathululimagama kanye nokuzwisisa isihlathululimagama emikhakheni yezefundo nesayenzi.  

U-Singh&lt;ref name=&quot;:1&quot;&gt;Singh, P. (2010). ‘Dictionary and Its Structure’. In ''Research Journal of Indian Cultural, Social &amp; Philosophical Stream Mehta'', Edited by M. K. Mehta. ''ANUSILANA'' 24. Manvi Seva Samiti: 1-6.&lt;/ref&gt; ngomnyaka ka-2010, waba nehlathululo ehlukileko yesihlathululimagama lapho athi, isihlathululimagama yincwadi yeriferensi mayelana namagama nanyana amathemu. Ihlathululo le inqophe, khulukhulu, kuwo woke umuntu osebenzisa isihlathululimagama ngebanga lesitjhijilo nanyana Isidingo anaso. Isidingo nanyana isitjhijilo leso kungenzeka bonyana ngesekulumo ejayelekileko nanyana somkhakha okhethekileko. Ihlathululo kaSingh&lt;ref name=&quot;:1&quot; /&gt; (2010) esitjela khona kukobana isihlathululimagama sisetjenziswa esinikela ngeensombululo zelimi nethintwana lelimi lelo elisetjenziswako msebenzisi oqothelweko.  

Ihlathululo yesine siyinikelwa nguLampung&lt;ref&gt;Lampung, I. R. I. (2016). ‘Dictionary Usage in English Language Learning’. English Education:Journal Tadris Bahaa Inggris. 9(1):186-197.&lt;/ref&gt; (2016) lapho athi, isihlathululimagama silirhelo lamagama arhenyiswe ngokulandelana kwamaledere lelo elethula ihlathululo begodu linikela nelwazi lokuphimisa iinhlathululo nemvelaphi yawo. Ihlathulullo le inqophe khulu kusayensi yezokutlanywa kweenhlathululimagama leyo ebizwa ngokuthi iLezikhografi. Ukungezelela, ibuye ikhulume ngesakhiwo sangaphakathi nanyana selwazi langaphakathi lesihlathululimagama.  

Ihlathululo yokugcina siyinikelwa ngu-Bergenholtz &lt;ref name=&quot;:0&quot; /&gt;(2012) nakathi, isihlathululimagama siyincwadi yamagama ahlelwengelandelwano nelwazi mayelana nokupeleda, iingaba zamabizo namatjhugululo wamagama alethwa lilimi neenhlathululo zamagama nanyana inrhunye lawo ukuya kwelinye ilimi. Nawutjheja ihlathululo le, uzokuyelela bonyana ilinge ukufana isakhiwo nemisebenzi eyenziwa sihlathululimagama. Nawuyifundako uyazi bonyana ulindele miphi imisebenzi begodu ulindele ukuthola ini ngaphakathi kwesihlathululi magama. 

=== Isiphetho ===
Iinhlathulumagama ezingehla lezi zoke zinqophile, begodu zitjengisa imisebenzi, isakhiwo kanye nomhlobo wencwadi lo obizwa bonyana sihlathululimagama bonyana unjani. Ngalokho, kungakho sivezile ekuthomeni bonyana ihlathululo yesihlathululimagama ibudisi ukuyihlathulula ngehlathululo eyedwa, ngebanga lesakhiwo nemisebenzi yaso.

=== Umthombolwazi ===
&lt;references /&gt;

</text>
      <sha1>cm3dkubyqq0rjdpwemgrggw5z1xf8uv</sha1>
    </revision>
    <revision>
      <id>2126</id>
      <parentid>919</parentid>
      <timestamp>2024-11-25T18:17:24Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* Iinkomba */Reflist</comment>
      <origin>2126</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4101" sha1="ruaaszr4ft4rgv3w5k2uqo3pf949epw" xml:space="preserve">== Isihlathululimagama/isihlathululimezwi. ==

=== Isingeniso ===
[[:en:Dictionary|Isihlathululimagama]], abanye basazi bona sihlathululimezwi, sisetjenziswa esinehlathululo ebudisi khulu. Asinayo ihlathululo eyodwa. Kodwana ngokuya kuka-Bejoint&lt;ref name=&quot;:0&quot;&gt;Béjoint, H. (2002). ‘''An introduction of modern lexicography’''. Beijing: Foreign Teaching and Research Press.&lt;/ref&gt; (2002:9) ihlathululo yesihlathululimagama kufanele ifake izinto nanzi ezilandelako: 
[[Isimumathi:IsiHlathululimagama.jpg|thumb|Isihlathululimagama sesiNdebele esilimimbili]]
a) isihlathululimagama silirhelomjeje weendima ezihlukeneko.

b) isihlathululimagama senzelwe ukubonisa.

c) iinhlathululimagama zinamaphahla amabili.

d) Isihlathululimagama siziinqhema ezihlelwe ngokulandelana.

e) isihlathululimagama siyingcenye yamarhelo welimi.

f) Isihlathululimagama siyincwadi yokulayela nokufundisa.

g) Isihlathululimagama sinikela ngelwazi elimayelana namatshwayo welimi.

h) Isihlathululimagama kusisethulo esihleliweko seengcenye eziquntwe ngaphambilini zeenhlathululimagama.

Amaphuzu angehla la, aveza isihlathululimagama ngokuya kwemisebenzi neendingo zaso. Nanyana kunjalo, kuba budisi khulu ukuthola ihlathululo efaka woke amaphuzu abalwe ngehla la. 

UGau&lt;ref&gt;Gao, L. (2010). ‘Historical Background of the Translatological Dictionaries’. ''Journal of Language Teaching and Research.'' 1(3):285-294.&lt;/ref&gt; ngomnyaka ka-2010, wahlathulula isihlathululimagama wathi, sisetjenziswa nanyana sitjabagelo leso esisetjenziselwa ukufunda nokunabisa ilwazi ngokusiqalisisa erhubhululweni. Ihlathululo engehla le, inqophe khulu kubarhubhululi nabafundi labo abafunda ukurhubhulula ngesihlathululimagama kanye nokuzwisisa isihlathululimagama emikhakheni yezefundo nesayenzi.  

U-Singh&lt;ref name=&quot;:1&quot;&gt;Singh, P. (2010). ‘Dictionary and Its Structure’. In ''Research Journal of Indian Cultural, Social &amp; Philosophical Stream Mehta'', Edited by M. K. Mehta. ''ANUSILANA'' 24. Manvi Seva Samiti: 1-6.&lt;/ref&gt; ngomnyaka ka-2010, waba nehlathululo ehlukileko yesihlathululimagama lapho athi, isihlathululimagama yincwadi yeriferensi mayelana namagama nanyana amathemu. Ihlathululo le inqophe, khulukhulu, kuwo woke umuntu osebenzisa isihlathululimagama ngebanga lesitjhijilo nanyana Isidingo anaso. Isidingo nanyana isitjhijilo leso kungenzeka bonyana ngesekulumo ejayelekileko nanyana somkhakha okhethekileko. Ihlathululo kaSingh&lt;ref name=&quot;:1&quot; /&gt; (2010) esitjela khona kukobana isihlathululimagama sisetjenziswa esinikela ngeensombululo zelimi nethintwana lelimi lelo elisetjenziswako msebenzisi oqothelweko.  

Ihlathululo yesine siyinikelwa nguLampung&lt;ref&gt;Lampung, I. R. I. (2016). ‘Dictionary Usage in English Language Learning’. English Education:Journal Tadris Bahaa Inggris. 9(1):186-197.&lt;/ref&gt; (2016) lapho athi, isihlathululimagama silirhelo lamagama arhenyiswe ngokulandelana kwamaledere lelo elethula ihlathululo begodu linikela nelwazi lokuphimisa iinhlathululo nemvelaphi yawo. Ihlathulullo le inqophe khulu kusayensi yezokutlanywa kweenhlathululimagama leyo ebizwa ngokuthi iLezikhografi. Ukungezelela, ibuye ikhulume ngesakhiwo sangaphakathi nanyana selwazi langaphakathi lesihlathululimagama.  

Ihlathululo yokugcina siyinikelwa ngu-Bergenholtz &lt;ref name=&quot;:0&quot; /&gt;(2012) nakathi, isihlathululimagama siyincwadi yamagama ahlelwengelandelwano nelwazi mayelana nokupeleda, iingaba zamabizo namatjhugululo wamagama alethwa lilimi neenhlathululo zamagama nanyana inrhunye lawo ukuya kwelinye ilimi. Nawutjheja ihlathululo le, uzokuyelela bonyana ilinge ukufana isakhiwo nemisebenzi eyenziwa sihlathululimagama. Nawuyifundako uyazi bonyana ulindele miphi imisebenzi begodu ulindele ukuthola ini ngaphakathi kwesihlathululi magama. 

=== Isiphetho ===
Iinhlathulumagama ezingehla lezi zoke zinqophile, begodu zitjengisa imisebenzi, isakhiwo kanye nomhlobo wencwadi lo obizwa bonyana sihlathululimagama bonyana unjani. Ngalokho, kungakho sivezile ekuthomeni bonyana ihlathululo yesihlathululimagama ibudisi ukuyihlathulula ngehlathululo eyedwa, ngebanga lesakhiwo nemisebenzi yaso.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>ruaaszr4ft4rgv3w5k2uqo3pf949epw</sha1>
    </revision>
  </page>
  <page>
    <title>Isikhethu</title>
    <ns>0</ns>
    <id>192</id>
    <revision>
      <id>920</id>
      <timestamp>2024-03-08T13:27:06Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''AmaNdebele''' azikhakhazisa kwamambala ngesiko labo. Baneminyanya ehlukahlukeneko begodu ekhamba nevunulo yakhona. Kusukela emsaneni ongakaweli ukuya kibo baba kanye emntazaneni ongakenzi isiko ukufinyelela ekubeni ngumma opheleleko ivunulo ayifani.  &quot;</comment>
      <origin>920</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="254" sha1="g6a9wu8likpyel0rxrjd5k3cm5ve1nd" xml:space="preserve">'''AmaNdebele''' azikhakhazisa kwamambala ngesiko labo. Baneminyanya ehlukahlukeneko begodu ekhamba nevunulo yakhona. Kusukela emsaneni ongakaweli ukuya kibo baba kanye emntazaneni ongakenzi isiko ukufinyelela ekubeni ngumma opheleleko ivunulo ayifani.

</text>
      <sha1>g6a9wu8likpyel0rxrjd5k3cm5ve1nd</sha1>
    </revision>
    <revision>
      <id>921</id>
      <parentid>920</parentid>
      <timestamp>2024-03-08T13:33:35Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <origin>921</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="520" sha1="ol8q3hs14qhd33pkysoapj1r6f40kux" xml:space="preserve">'''AmaNdebele''' azikhakhazisa kwamambala ngesiko labo. Baneminyanya ehlukahlukeneko begodu ekhamba nevunulo yakhona. Kusukela emsaneni ongakaweli ukuya kibo baba kanye emntazaneni ongakenzi isiko ukufinyelela ekubeni ngumma opheleleko ivunulo ayifani. IsiNdebelesi asizombelezi evunulweni kwaphela kodwana sibuye sifake ukudla neminyanya ehlukahlukeneko lapho sigoma khona ukudla lokhu. ukwenza isibonelo angeke wagoma igqatjha okumdoko wesiko nge Dwendwe nobukhazi okungomunye womhlobo womnyanya wesiko lamaNdebele. 

</text>
      <sha1>ol8q3hs14qhd33pkysoapj1r6f40kux</sha1>
    </revision>
    <revision>
      <id>922</id>
      <parentid>921</parentid>
      <timestamp>2024-03-09T07:27:32Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>922</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="524" sha1="r4d6ba1vh196cygojjpfhcsh9tw1gr5" xml:space="preserve">'''[[AmaNdebele]]''' azikhakhazisa kwamambala ngesiko labo. Baneminyanya ehlukahlukeneko begodu ekhamba nevunulo yakhona. Kusukela emsaneni ongakaweli ukuya kibo baba kanye emntazaneni ongakenzi isiko ukufinyelela ekubeni ngumma opheleleko ivunulo ayifani. IsiNdebelesi asizombelezi evunulweni kwaphela kodwana sibuye sifake ukudla neminyanya ehlukahlukeneko lapho sigoma khona ukudla lokhu. ukwenza isibonelo angeke wagoma igqatjha okumdoko wesiko nge Dwendwe nobukhazi okungomunye womhlobo womnyanya wesiko lamaNdebele. 

</text>
      <sha1>r4d6ba1vh196cygojjpfhcsh9tw1gr5</sha1>
    </revision>
    <revision>
      <id>923</id>
      <parentid>922</parentid>
      <timestamp>2024-03-09T07:28:10Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <origin>923</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="541" sha1="dzinkhq5jkj9q2aj2ft2zoilj7y19o9" xml:space="preserve">'''[[Wp/nd/AmaNdebele|AmaNdebele]]''' azikhakhazisa kwamambala ngesiko labo. Baneminyanya ehlukahlukeneko begodu ekhamba nevunulo yakhona. Kusukela emsaneni ongakaweli ukuya kibo baba kanye emntazaneni ongakenzi isiko ukufinyelela ekubeni ngumma opheleleko ivunulo ayifani. IsiNdebelesi asizombelezi evunulweni kwaphela kodwana sibuye sifake ukudla neminyanya ehlukahlukeneko lapho sigoma khona ukudla lokhu. ukwenza isibonelo angeke wagoma igqatjha okumdoko wesiko nge Dwendwe nobukhazi okungomunye womhlobo womnyanya wesiko lamaNdebele. 

</text>
      <sha1>dzinkhq5jkj9q2aj2ft2zoilj7y19o9</sha1>
    </revision>
    <revision>
      <id>924</id>
      <parentid>923</parentid>
      <timestamp>2024-03-09T07:36:21Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>924</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="554" sha1="szfaoj9wl0qx8yiarjvbt23qp9nloyt" xml:space="preserve">'''[[Wp/nd/AmaNdebele|AmaNdebele]]''' azikhakhazisa kwamambala ngesiko labo. Baneminyanya ehlukahlukeneko begodu ekhamba nevunulo yakhona. Kusukela emsaneni ongakaweli ukuya kibo baba kanye emntazaneni ongakenzi isiko ukufinyelela ekubeni ngumma opheleleko ivunulo ayifani. Isi[[Ndebele]]&lt;nowiki/&gt;si asizombelezi evunulweni kwaphela kodwana sibuye sifake ukudla neminyanya ehlukahlukeneko lapho sigoma khona ukudla lokhu. ukwenza isibonelo angeke wagoma igqatjha okumdoko wesiko nge Dwendwe nobukhazi okungomunye womhlobo womnyanya wesiko lamaNdebele. 

</text>
      <sha1>szfaoj9wl0qx8yiarjvbt23qp9nloyt</sha1>
    </revision>
    <revision>
      <id>925</id>
      <parentid>924</parentid>
      <timestamp>2024-03-09T07:48:55Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>925</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="793" sha1="l2j1s1ndnd2iyblenqnmquo06259dhm" xml:space="preserve">'''[[Wp/nd/AmaNdebele|AmaNdebele]]''' azikhakhazisa kwamambala ngesiko labo. Baneminyanya ehlukahlukeneko begodu ekhamba nevunulo yakhona. Kusukela emsaneni ongakaweli ukuya kibo baba kanye emntazaneni ongakenzi isiko ukufinyelela ekubeni ngumma opheleleko ivunulo ayifani. Isi[[Ndebele]]&lt;nowiki/&gt;si asizombelezi evunulweni kwaphela kodwana sibuye sifake ukudla neminyanya ehlukahlukeneko lapho sigoma khona ukudla lokhu. ukwenza isibonelo angeke wagoma igqatjha okumdoko wesiko nge Dwendwe nobukhazi okungomunye womhlobo womnyanya wesiko lamaNdebele. 

== IVUNULO ==
Ivunulo yizambatho ezimbathwa emnyanyeni yamaNdebele. Inemibala eminengi begodu amaNdebele baziwa ngekgono labo loku gwala kanye nokuthunga ngemincamo. Ivunulo yabo ubunengi bayo yenziwe ngemihlobohlobo ehlukileko yemincamo.
</text>
      <sha1>l2j1s1ndnd2iyblenqnmquo06259dhm</sha1>
    </revision>
    <revision>
      <id>926</id>
      <parentid>925</parentid>
      <timestamp>2024-03-09T08:19:22Z</timestamp>
      <contributor>
        <username>incubator&gt;Mbandeni</username>
        <id>0</id>
      </contributor>
      <comment>Picture</comment>
      <origin>926</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="870" sha1="ojqm8v16kwhp9kflskftnp70yek16sr" xml:space="preserve">[[Isimumathi:Mapoch.- Playing music in Ndebele Village.ogv|thumb|IsiNdebele]]
'''[[Wp/nd/AmaNdebele|AmaNdebele]]''' azikhakhazisa kwamambala ngesiko labo. Baneminyanya ehlukahlukeneko begodu ekhamba nevunulo yakhona. Kusukela emsaneni ongakaweli ukuya kibo baba kanye emntazaneni ongakenzi isiko ukufinyelela ekubeni ngumma opheleleko ivunulo ayifani. Isi[[Ndebele]]&lt;nowiki/&gt;si asizombelezi evunulweni kwaphela kodwana sibuye sifake ukudla neminyanya ehlukahlukeneko lapho sigoma khona ukudla lokhu. ukwenza isibonelo angeke wagoma igqatjha okumdoko wesiko nge Dwendwe nobukhazi okungomunye womhlobo womnyanya wesiko lamaNdebele.

== IVUNULO ==
Ivunulo yizambatho ezimbathwa emnyanyeni yamaNdebele. Inemibala eminengi begodu amaNdebele baziwa ngekgono labo loku gwala kanye nokuthunga ngemincamo. Ivunulo yabo ubunengi bayo yenziwe ngemihlobohlobo ehlukileko yemincamo.
</text>
      <sha1>ojqm8v16kwhp9kflskftnp70yek16sr</sha1>
    </revision>
    <revision>
      <id>927</id>
      <parentid>926</parentid>
      <timestamp>2024-03-09T08:22:23Z</timestamp>
      <contributor>
        <username>incubator&gt;Simphiwe22</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Added content</comment>
      <origin>926</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="870" sha1="ojqm8v16kwhp9kflskftnp70yek16sr" xml:space="preserve">[[Isimumathi:Mapoch.- Playing music in Ndebele Village.ogv|thumb|IsiNdebele]]
'''[[Wp/nd/AmaNdebele|AmaNdebele]]''' azikhakhazisa kwamambala ngesiko labo. Baneminyanya ehlukahlukeneko begodu ekhamba nevunulo yakhona. Kusukela emsaneni ongakaweli ukuya kibo baba kanye emntazaneni ongakenzi isiko ukufinyelela ekubeni ngumma opheleleko ivunulo ayifani. Isi[[Ndebele]]&lt;nowiki/&gt;si asizombelezi evunulweni kwaphela kodwana sibuye sifake ukudla neminyanya ehlukahlukeneko lapho sigoma khona ukudla lokhu. ukwenza isibonelo angeke wagoma igqatjha okumdoko wesiko nge Dwendwe nobukhazi okungomunye womhlobo womnyanya wesiko lamaNdebele.

== IVUNULO ==
Ivunulo yizambatho ezimbathwa emnyanyeni yamaNdebele. Inemibala eminengi begodu amaNdebele baziwa ngekgono labo loku gwala kanye nokuthunga ngemincamo. Ivunulo yabo ubunengi bayo yenziwe ngemihlobohlobo ehlukileko yemincamo.
</text>
      <sha1>ojqm8v16kwhp9kflskftnp70yek16sr</sha1>
    </revision>
    <revision>
      <id>928</id>
      <parentid>927</parentid>
      <timestamp>2024-10-14T13:46:56Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>8 revisions imported</comment>
      <origin>926</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="870" sha1="ojqm8v16kwhp9kflskftnp70yek16sr" xml:space="preserve">[[Isimumathi:Mapoch.- Playing music in Ndebele Village.ogv|thumb|IsiNdebele]]
'''[[Wp/nd/AmaNdebele|AmaNdebele]]''' azikhakhazisa kwamambala ngesiko labo. Baneminyanya ehlukahlukeneko begodu ekhamba nevunulo yakhona. Kusukela emsaneni ongakaweli ukuya kibo baba kanye emntazaneni ongakenzi isiko ukufinyelela ekubeni ngumma opheleleko ivunulo ayifani. Isi[[Ndebele]]&lt;nowiki/&gt;si asizombelezi evunulweni kwaphela kodwana sibuye sifake ukudla neminyanya ehlukahlukeneko lapho sigoma khona ukudla lokhu. ukwenza isibonelo angeke wagoma igqatjha okumdoko wesiko nge Dwendwe nobukhazi okungomunye womhlobo womnyanya wesiko lamaNdebele.

== IVUNULO ==
Ivunulo yizambatho ezimbathwa emnyanyeni yamaNdebele. Inemibala eminengi begodu amaNdebele baziwa ngekgono labo loku gwala kanye nokuthunga ngemincamo. Ivunulo yabo ubunengi bayo yenziwe ngemihlobohlobo ehlukileko yemincamo.
</text>
      <sha1>ojqm8v16kwhp9kflskftnp70yek16sr</sha1>
    </revision>
  </page>
  <page>
    <title>Isiko</title>
    <ns>0</ns>
    <id>193</id>
    <revision>
      <id>929</id>
      <timestamp>2024-06-27T11:51:12Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Isiko''' yindlela abantu ebenza ngayo izinto ngokwekolelo yabo, eyenza bona bacabange begodu baziphathe ngendlela ethize.  &quot;</comment>
      <origin>929</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="126" sha1="04733j3at3feoxo0kkcpy30a8y7qaw8" xml:space="preserve">'''Isiko''' yindlela abantu ebenza ngayo izinto ngokwekolelo yabo, eyenza bona bacabange begodu baziphathe ngendlela ethize.

</text>
      <sha1>04733j3at3feoxo0kkcpy30a8y7qaw8</sha1>
    </revision>
    <revision>
      <id>930</id>
      <parentid>929</parentid>
      <timestamp>2024-06-27T13:21:30Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>930</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="496" sha1="sfjwwdkji38zte3j9v47h4dqwax0l0s" xml:space="preserve">'''Isiko''' yindlela abantu ebenza ngayo izinto ngokwekolelo yabo, eyenza bona bacabange begodu baziphathe ngendlela ethize.

Isiko lifaka hlangana ikolo, ilimi, umvumo, ukudansa, amagugu nokhunye. Isiko ngilo elanza bona umuntu azazi bona ungubani begodu ukhamba nabobani. Liqagela indlela yokufunda nokufundisa. Ngilo isiko elakha umphakathi nelihlanganisa abantu ngokukhuluma nokuzwisisana. Isiko lilekelela abantu bona bakghone ukukghodlhelela ebhodulukweni elitjhugulukako mihla namalanga.

</text>
      <sha1>sfjwwdkji38zte3j9v47h4dqwax0l0s</sha1>
    </revision>
    <revision>
      <id>931</id>
      <parentid>930</parentid>
      <timestamp>2024-06-27T13:23:49Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>931</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="712" sha1="7kkk28rp6mr22o2ten2bbq8sra6gt6t" xml:space="preserve">'''Isiko''' yindlela abantu ebenza ngayo izinto ngokwekolelo yabo, eyenza bona bacabange begodu baziphathe ngendlela ethize.

Isiko lifaka hlangana ikolo, ilimi, umvumo, ukudansa, amagugu nokhunye. Isiko ngilo elanza bona umuntu azazi bona ungubani begodu ukhamba nabobani. Liqagela indlela yokufunda nokufundisa. Ngilo isiko elakha umphakathi nelihlanganisa abantu ngokukhuluma nokuzwisisana. Isiko lilekelela abantu bona bakghone ukukghodlhelela ebhodulukweni elitjhugulukako mihla namalanga.

Omunye nomunye umuntu unesiko lakhe begodu amasiko ayahlukahlukana kuqakathekile bonyana omunye nomunye umuntu ahloniphe isiko labantu aphila nabo. Lokhu kwenza bona kube nokuzwana nokuhlalisana kuhle esitjhabeni. 

</text>
      <sha1>7kkk28rp6mr22o2ten2bbq8sra6gt6t</sha1>
    </revision>
    <revision>
      <id>932</id>
      <parentid>931</parentid>
      <timestamp>2024-10-14T13:46:56Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>931</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="712" sha1="7kkk28rp6mr22o2ten2bbq8sra6gt6t" xml:space="preserve">'''Isiko''' yindlela abantu ebenza ngayo izinto ngokwekolelo yabo, eyenza bona bacabange begodu baziphathe ngendlela ethize.

Isiko lifaka hlangana ikolo, ilimi, umvumo, ukudansa, amagugu nokhunye. Isiko ngilo elanza bona umuntu azazi bona ungubani begodu ukhamba nabobani. Liqagela indlela yokufunda nokufundisa. Ngilo isiko elakha umphakathi nelihlanganisa abantu ngokukhuluma nokuzwisisana. Isiko lilekelela abantu bona bakghone ukukghodlhelela ebhodulukweni elitjhugulukako mihla namalanga.

Omunye nomunye umuntu unesiko lakhe begodu amasiko ayahlukahlukana kuqakathekile bonyana omunye nomunye umuntu ahloniphe isiko labantu aphila nabo. Lokhu kwenza bona kube nokuzwana nokuhlalisana kuhle esitjhabeni. 

</text>
      <sha1>7kkk28rp6mr22o2ten2bbq8sra6gt6t</sha1>
    </revision>
    <revision>
      <id>5192</id>
      <parentid>932</parentid>
      <timestamp>2025-08-16T08:07:25Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5192</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="706" sha1="hid97628r57sbc0fkhcadpqklaebx0e" xml:space="preserve">'''Isiko''' yindlela abantu ebenza ngayo izinto ngokwekolelo yabo, eyenza bona bacabange begodu baziphathe ngendlela ethize. Isiko lifaka hlangana ikolo, ilimi, umvumo, ukudansa, amagugu nokhunye. Isiko ngilo elanza bona umuntu azazi bona ungubani begodu ukhamba nabobani. Liqagela indlela yokufunda nokufundisa. Ngilo isiko elakha umphakathi nelihlanganisa abantu ngokukhuluma nokuzwisisana. Isiko lilekelela abantu bona bakghone ukukghodlhelela ebhodulukweni elitjhugulukako mihla namalanga.Omunye nomunye umuntu unesiko lakhe begodu amasiko ayahlukahlukana kuqakathekile bonyana omunye nomunye umuntu ahloniphe isiko labantu aphila nabo. Lokhu kwenza bona kube nokuzwana nokuhlalisana kuhle esitjhabeni.</text>
      <sha1>hid97628r57sbc0fkhcadpqklaebx0e</sha1>
    </revision>
    <revision>
      <id>5193</id>
      <parentid>5192</parentid>
      <timestamp>2025-08-16T08:07:56Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5193</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="707" sha1="jfvjq93nn7508i2zz2nduacrrh06jx1" xml:space="preserve">'''Isiko''' yindlela abantu ebenza ngayo izinto ngokwekolelo yabo, eyenza bona bacabange begodu baziphathe ngendlela ethize. Isiko lifaka hlangana ikolo, ilimi, umvumo, ukudansa, amagugu nokhunye. Isiko ngilo elanza bona umuntu azazi bona ungubani begodu ukhamba nabobani. Liqagela indlela yokufunda nokufundisa. Ngilo isiko elakha umphakathi nelihlanganisa abantu ngokukhuluma nokuzwisisana. Isiko lilekelela abantu bona bakghone ukukghodlhelela ebhodulukweni elitjhugulukako mihla namalanga. Omunye nomunye umuntu unesiko lakhe begodu amasiko ayahlukahlukana kuqakathekile bonyana omunye nomunye umuntu ahloniphe isiko labantu aphila nabo. Lokhu kwenza bona kube nokuzwana nokuhlalisana kuhle esitjhabeni.</text>
      <sha1>jfvjq93nn7508i2zz2nduacrrh06jx1</sha1>
    </revision>
    <revision>
      <id>5194</id>
      <parentid>5193</parentid>
      <timestamp>2025-08-16T08:08:56Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5194</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="747" sha1="qvm03ts4sin9621ph4a9zlnhszhobat" xml:space="preserve">'''Isiko''' yindlela abantu ebenza ngayo izinto ngokwekolelo yabo, eyenza bona bacabange begodu baziphathe ngendlela ethize. Isiko lifaka hlangana ikolo, ilimi, umvumo, ukudansa, amagugu nokhunye. Isiko ngilo elanza bona umuntu azazi bona ungubani begodu ukhamba nabobani. Liqagela indlela yokufunda nokufundisa. Ngilo isiko elakha umphakathi nelihlanganisa abantu ngokukhuluma nokuzwisisana. Isiko lilekelela abantu bona bakghone ukukghodlhelela ebhodulukweni elitjhugulukako mihla namalanga. Omunye nomunye umuntu unesiko lakhe begodu amasiko ayahlukahlukana kuqakathekile bonyana omunye nomunye umuntu ahloniphe isiko labantu aphila nabo. Lokhu kwenza bona kube nokuzwana nokuhlalisana kuhle esitjhabeni.
[[category:Isiko]]
[[Category:Amagugu]]</text>
      <sha1>qvm03ts4sin9621ph4a9zlnhszhobat</sha1>
    </revision>
  </page>
  <page>
    <title>Isikolo imayitjha</title>
    <ns>0</ns>
    <id>194</id>
    <revision>
      <id>933</id>
      <timestamp>2024-03-08T13:39:43Z</timestamp>
      <contributor>
        <username>incubator&gt;KhethiweMsiza94</username>
        <id>0</id>
      </contributor>
      <comment>Mayisha secondary school</comment>
      <origin>933</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="885" sha1="5pm25p42j7l35hl8eoonj329wudo8bi" xml:space="preserve">'''IMAYISHA SECONDARY SCHOOL'''

IMayisha secondary school  sikolo esisendaweni yange Waterval b,Epumalanga. Isikolo lesi sathiyelelwa ngekosi uMayitjha obekayikosi yamaNdebele weSewula.Iposo yalesi isikolo yi PO BOx 596 Siyabuswa 0472. isikolo lesi sikolo sikarhulumende kufundwa simahla.

Ukuya ngembalobalo zonyaka ka 2016, isikolwesi sinabantwana abamakhulu amane netjhumi abafundiswa bothitjhere abalitjhumi nambili.Uhlokokulu weMayisha nguMartin Siluma.uhlokokulu lo udume ngokuletha umehluko mkhulu kilesi isikolo eminyaken elitjhumi eyadlulako.Ngokutjhugululwa kwezinto imayitjha yahlanganiswa nesinye isikolo yathoma amabanga ebangeni lethoba kanti esikhathini esadlula beyithoma kuGreyidi yetjhumi.Isikolo lesi sikolo amabanga aphakathi begodu sinamalimi amabili kwaphela ekuyisiNdebele ne''Sepedi.'' kilesi isikolo sifundisa iimfundo ze''Science , iAccounting negeography.''</text>
      <sha1>5pm25p42j7l35hl8eoonj329wudo8bi</sha1>
    </revision>
    <revision>
      <id>934</id>
      <parentid>933</parentid>
      <timestamp>2024-03-09T07:39:00Z</timestamp>
      <contributor>
        <username>incubator&gt;KhethiweMsiza94</username>
        <id>0</id>
      </contributor>
      <origin>934</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="963" sha1="bdf0o31q2r6z3fiiwao7359te4c1x92" xml:space="preserve">'''IMAYISHA SECONDARY SCHOOL'''

=== SIKUPHI ISIKOLO IMAYITJHA SECONDARY SCHOOL? ===
'''IMayisha secondary schoo'''l  sikolo esisendaweni yange [[Waterval]] b,Epumalanga. Isikolo lesi sathiyelelwa ngekosi uMayitjha obekayikosi yamaNdebele weSewula.Iposo yalesi isikolo yi PO BOx 596 [[Siyabuswa]] 0472. isikolo lesi sikolo sikarhulumende kufundwa simahla.

Ukuya ngembalobalo zonyaka ka 2016, isikolwesi sinabantwana abamakhulu amane netjhumi abafundiswa bothitjhere abalitjhumi nambili.Uhlokokulu weMayisha nguMartin Siluma.uhlokokulu lo udume ngokuletha umehluko mkhulu kilesi isikolo eminyaken elitjhumi eyadlulako.Ngokutjhugululwa kwezinto imayitjha yahlanganiswa nesinye isikolo yathoma amabanga ebangeni lethoba kanti esikhathini esadlula beyithoma kuGreyidi yetjhumi.Isikolo lesi sikolo amabanga aphakathi begodu sinamalimi amabili kwaphela ekuyisiNdebele ne''Sepedi.'' kilesi isikolo sifundisa iimfundo ze''[[Science|Science ,]] iAccounting negeography.''</text>
      <sha1>bdf0o31q2r6z3fiiwao7359te4c1x92</sha1>
    </revision>
    <revision>
      <id>935</id>
      <parentid>934</parentid>
      <timestamp>2024-10-14T13:46:56Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>934</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="963" sha1="bdf0o31q2r6z3fiiwao7359te4c1x92" xml:space="preserve">'''IMAYISHA SECONDARY SCHOOL'''

=== SIKUPHI ISIKOLO IMAYITJHA SECONDARY SCHOOL? ===
'''IMayisha secondary schoo'''l  sikolo esisendaweni yange [[Waterval]] b,Epumalanga. Isikolo lesi sathiyelelwa ngekosi uMayitjha obekayikosi yamaNdebele weSewula.Iposo yalesi isikolo yi PO BOx 596 [[Siyabuswa]] 0472. isikolo lesi sikolo sikarhulumende kufundwa simahla.

Ukuya ngembalobalo zonyaka ka 2016, isikolwesi sinabantwana abamakhulu amane netjhumi abafundiswa bothitjhere abalitjhumi nambili.Uhlokokulu weMayisha nguMartin Siluma.uhlokokulu lo udume ngokuletha umehluko mkhulu kilesi isikolo eminyaken elitjhumi eyadlulako.Ngokutjhugululwa kwezinto imayitjha yahlanganiswa nesinye isikolo yathoma amabanga ebangeni lethoba kanti esikhathini esadlula beyithoma kuGreyidi yetjhumi.Isikolo lesi sikolo amabanga aphakathi begodu sinamalimi amabili kwaphela ekuyisiNdebele ne''Sepedi.'' kilesi isikolo sifundisa iimfundo ze''[[Science|Science ,]] iAccounting negeography.''</text>
      <sha1>bdf0o31q2r6z3fiiwao7359te4c1x92</sha1>
    </revision>
    <revision>
      <id>2625</id>
      <parentid>935</parentid>
      <timestamp>2025-04-03T19:08:16Z</timestamp>
      <contributor>
        <username>Rachmat04</username>
        <id>32</id>
      </contributor>
      <minor />
      <origin>2625</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="962" sha1="6w0sa6zq3dzi2p8oi3mn7udq223vysk" xml:space="preserve">'''IMAYISHA SECONDARY SCHOOL'''

=== SIKUPHI ISIKOLO IMAYITJHA SECONDARY SCHOOL? ===
'''IMayisha secondary schoo'''l sikolo esisendaweni yange [[Waterval]] b,Epumalanga. Isikolo lesi sathiyelelwa ngekosi uMayitjha obekayikosi yamaNdebele weSewula.Iposo yalesi isikolo yi PO BOx 596 [[Siyabuswa]] 0472. isikolo lesi sikolo sikarhulumende kufundwa simahla.

Ukuya ngembalobalo zonyaka ka 2016, isikolwesi sinabantwana abamakhulu amane netjhumi abafundiswa bothitjhere abalitjhumi nambili.Uhlokokulu weMayisha nguMartin Siluma.uhlokokulu lo udume ngokuletha umehluko mkhulu kilesi isikolo eminyaken elitjhumi eyadlulako.Ngokutjhugululwa kwezinto imayitjha yahlanganiswa nesinye isikolo yathoma amabanga ebangeni lethoba kanti esikhathini esadlula beyithoma kuGreyidi yetjhumi.Isikolo lesi sikolo amabanga aphakathi begodu sinamalimi amabili kwaphela ekuyisiNdebele ne''Sepedi.'' kilesi isikolo sifundisa iimfundo ze''[[Science|Science ,]] iAccounting negeography.''</text>
      <sha1>6w0sa6zq3dzi2p8oi3mn7udq223vysk</sha1>
    </revision>
  </page>
  <page>
    <title>Isiqwi seenlwana</title>
    <ns>0</ns>
    <id>195</id>
    <revision>
      <id>936</id>
      <timestamp>2024-09-15T09:48:51Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;== Isiqwi Seenlwana ==  === Isengeniso === Kukhona indawo lezo ezenzelwe ukubulunga, ukugcina kanye nokuvikela ubuphilo nobujamo bezinto ethize lokho okukhambisana nokunikela izinto lezo ibhoduluko elizijwaleyeleko. Indawo lezo kungenzeka bonyana zifake iinlwana, amahlathi, amanzi, iintjano nemithi. Ngaphasi kwalesi sihloko sizokunqopha khulu kusiqwi seenlwana.   === Kuyini isiqwi seenlwana na? === Ngokuya kuka-Nekolny no-Fiavona (2018&lt;ref&gt;Nekolny, L., &amp; Fialova, D. 2018...&quot;</comment>
      <origin>936</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3073" sha1="e15fpkhzgwwutm2dldzy5q2estk5wjm" xml:space="preserve">== Isiqwi Seenlwana ==

=== Isengeniso ===
Kukhona indawo lezo ezenzelwe ukubulunga, ukugcina kanye nokuvikela ubuphilo nobujamo bezinto ethize lokho okukhambisana nokunikela izinto lezo ibhoduluko elizijwaleyeleko. Indawo lezo kungenzeka bonyana zifake iinlwana, amahlathi, amanzi, iintjano nemithi. Ngaphasi kwalesi sihloko sizokunqopha khulu kusiqwi seenlwana. 

=== Kuyini isiqwi seenlwana na? ===
Ngokuya kuka-Nekolny no-Fiavona (2018&lt;ref&gt;Nekolny, L., &amp; Fialova, D. 2018. Zoo Tourism: What Actually Is a Zoo? ''Czech Journal of Tourism'', 7(2): 153–166.&lt;/ref&gt;) [[:en:Zoo|isiqwi seenlwana]] yindawo lapho kubekwa, kugcinwe begodu kutjengiswa iinlwana. Nasiqala ihlathululo le inzinze khulu mayelana nokuvikeleko nendawo la kutholakala khona iinlwana lezi. U-Rose, u-Brereton, u-Rowden, u-De Figuiredo, no-Riley (2019)&lt;ref&gt;Rose, P. E., Brereton, J. E., Rowden, L. J., De Figuiredo, R. L. &amp; Riley, L. M. 2019. What’s new from the zoo? An analysis of ten years of zoo-themed research output. ''Palgrave Communications'', :1-9&lt;/ref&gt; baveze bona isiqwi seenlwana yindawo leyo evelelwe umphakathi bonyana uzokubona iinlwana zemakhaya nezehlathi kanye nemanzini bonyana ziphila njani nokuthi bazuze ilwazi ngazo. Ihlathululo le ilinge ukufaka hlangana imihlobo yeenlwana leyo etholaka esiqwini seenlwana kanti nepilo yazi nelwazi lelo umphakathi ongalizuza. U-Zareva-Simeonova, u-Zlatanova, u-Racheva, u-Angelov no-Asenova (2009)&lt;ref&gt;Zareva-Simeonova, K., Zlatanova, D., Racheva, V. Angelov, V. &amp; Asenova, I. 2009. ''The zoos and their role in the formal and informal environmental education. Biotechnol &amp; Biotechnol''. EQ.&lt;/ref&gt; ithi yona, isiqwi seenlwana yindawo lapho kubekwa khona iinlwani, zivikelwe ngaphasi kwabasabenzi bamafundwakghono. Iinlwani lezi kungaka ngezemanzini nanyana zehlabathini. 

=== Ingabe kutholaka ziphi iinlwana esiqwini seenlwana? ===
Iinlwani ezitholakala esiqwini seenlwana kutholaka zoke iinlwana (Wikipedia 2024&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. ''Zoo''. Litholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Zoo&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). Iinlwazi lezi zihlukaniswe ngokweendawo ezihlala kizo, lezo ezifaka amanzi nehlabathini. Iinlwani zehlabathini zifaka iinkomo iimbuduma, iimpunzi, iimbuzi, inyoka neenyoni. Iinlwana zemanzi zona zifaka iimfesi, imikhombo nabotjhaka. 

=== Isiqwi seenlwana lesi sinakekelwa bobani? ===
Isiqwi seenlwana sinakekela babantu abanengi labo abanamafundwakghona ahlukeneko. Amafundwakghona la afaka, abosoonlwana, abantu abasebenza ngeentjalo nemithi, nalabo abasebenzi ngamahlathi, abantu abasebenza ngamanzi neenlwana zemanzini kanye nabosobhoduluko kanye nabarhubhululi abahlukeneko (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;). Boke basebenza ngomnqopho munye wokusisa, ukusekela nokubulunga isiqwi seenlwana ngokupheleleko.

=== Isiphetho. ===
Isiqwi seenlwana siqakathekile khulu ekubulungeni nokuphephiseni iinlwana zoke eziphila emanzini nehlabathini. Begodu, siqinisekisa bonyana iinzukulwani ezizako ziba nethuba lokuzibona iinlwana lezi. 

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>e15fpkhzgwwutm2dldzy5q2estk5wjm</sha1>
    </revision>
    <revision>
      <id>937</id>
      <parentid>936</parentid>
      <timestamp>2024-09-18T15:56:41Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>937</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3074" sha1="gxlemc54l0ykyzaxigm4yznzcm0n78w" xml:space="preserve">== Isiqwi Seenlwana. ==

=== Isengeniso ===
Kukhona indawo lezo ezenzelwe ukubulunga, ukugcina kanye nokuvikela ubuphilo nobujamo bezinto ethize lokho okukhambisana nokunikela izinto lezo ibhoduluko elizijwaleyeleko. Indawo lezo kungenzeka bonyana zifake iinlwana, amahlathi, amanzi, iintjano nemithi. Ngaphasi kwalesi sihloko sizokunqopha khulu kusiqwi seenlwana. 

=== Kuyini isiqwi seenlwana na? ===
Ngokuya kuka-Nekolny no-Fiavona (2018&lt;ref&gt;Nekolny, L., &amp; Fialova, D. 2018. Zoo Tourism: What Actually Is a Zoo? ''Czech Journal of Tourism'', 7(2): 153–166.&lt;/ref&gt;) [[:en:Zoo|isiqwi seenlwana]] yindawo lapho kubekwa, kugcinwe begodu kutjengiswa iinlwana. Nasiqala ihlathululo le inzinze khulu mayelana nokuvikeleko nendawo la kutholakala khona iinlwana lezi. U-Rose, u-Brereton, u-Rowden, u-De Figuiredo, no-Riley (2019)&lt;ref&gt;Rose, P. E., Brereton, J. E., Rowden, L. J., De Figuiredo, R. L. &amp; Riley, L. M. 2019. What’s new from the zoo? An analysis of ten years of zoo-themed research output. ''Palgrave Communications'', :1-9&lt;/ref&gt; baveze bona isiqwi seenlwana yindawo leyo evelelwe umphakathi bonyana uzokubona iinlwana zemakhaya nezehlathi kanye nemanzini bonyana ziphila njani nokuthi bazuze ilwazi ngazo. Ihlathululo le ilinge ukufaka hlangana imihlobo yeenlwana leyo etholaka esiqwini seenlwana kanti nepilo yazi nelwazi lelo umphakathi ongalizuza. U-Zareva-Simeonova, u-Zlatanova, u-Racheva, u-Angelov no-Asenova (2009)&lt;ref&gt;Zareva-Simeonova, K., Zlatanova, D., Racheva, V. Angelov, V. &amp; Asenova, I. 2009. ''The zoos and their role in the formal and informal environmental education. Biotechnol &amp; Biotechnol''. EQ.&lt;/ref&gt; ithi yona, isiqwi seenlwana yindawo lapho kubekwa khona iinlwani, zivikelwe ngaphasi kwabasabenzi bamafundwakghono. Iinlwani lezi kungaka ngezemanzini nanyana zehlabathini. 

=== Ingabe kutholaka ziphi iinlwana esiqwini seenlwana? ===
Iinlwani ezitholakala esiqwini seenlwana kutholaka zoke iinlwana (Wikipedia 2024&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. ''Zoo''. Litholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Zoo&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). Iinlwazi lezi zihlukaniswe ngokweendawo ezihlala kizo, lezo ezifaka amanzi nehlabathini. Iinlwani zehlabathini zifaka iinkomo iimbuduma, iimpunzi, iimbuzi, inyoka neenyoni. Iinlwana zemanzi zona zifaka iimfesi, imikhombo nabotjhaka. 

=== Isiqwi seenlwana lesi sinakekelwa bobani? ===
Isiqwi seenlwana sinakekela babantu abanengi labo abanamafundwakghona ahlukeneko. Amafundwakghona la afaka, abosoonlwana, abantu abasebenza ngeentjalo nemithi, nalabo abasebenzi ngamahlathi, abantu abasebenza ngamanzi neenlwana zemanzini kanye nabosobhoduluko kanye nabarhubhululi abahlukeneko (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;). Boke basebenza ngomnqopho munye wokusisa, ukusekela nokubulunga isiqwi seenlwana ngokupheleleko.

=== Isiphetho. ===
Isiqwi seenlwana siqakathekile khulu ekubulungeni nokuphephiseni iinlwana zoke eziphila emanzini nehlabathini. Begodu, siqinisekisa bonyana iinzukulwani ezizako ziba nethuba lokuzibona iinlwana lezi. 

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>gxlemc54l0ykyzaxigm4yznzcm0n78w</sha1>
    </revision>
    <revision>
      <id>938</id>
      <parentid>937</parentid>
      <timestamp>2024-09-19T06:02:47Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <origin>938</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3167" sha1="0op1s9uxvgwugbyp2ismm9r1ltbjxfb" xml:space="preserve">== Isiqwi Seenlwana. ==

=== Isengeniso ===
Kukhona indawo lezo ezenzelwe ukubulunga, ukugcina kanye nokuvikela ubuphilo nobujamo bezinto ethize lokho okukhambisana nokunikela izinto lezo ibhoduluko elizijwaleyeleko. Indawo lezo kungenzeka bonyana zifake iinlwana, amahlathi, amanzi, iintjano nemithi. Ngaphasi kwalesi sihloko sizokunqopha khulu kusiqwi seenlwana. 

=== Kuyini isiqwi seenlwana na? ===
[[Isimumathi:Imbabala.jpg|thumb|Imbabala idla utjani]]
Ngokuya kuka-Nekolny no-Fiavona (2018&lt;ref&gt;Nekolny, L., &amp; Fialova, D. 2018. Zoo Tourism: What Actually Is a Zoo? ''Czech Journal of Tourism'', 7(2): 153–166.&lt;/ref&gt;) [[:en:Zoo|isiqwi seenlwana]] yindawo lapho kubekwa, kugcinwe begodu kutjengiswa iinlwana. Nasiqala ihlathululo le inzinze khulu mayelana nokuvikeleko nendawo la kutholakala khona iinlwana lezi. U-Rose, u-Brereton, u-Rowden, u-De Figuiredo, no-Riley (2019)&lt;ref&gt;Rose, P. E., Brereton, J. E., Rowden, L. J., De Figuiredo, R. L. &amp; Riley, L. M. 2019. What’s new from the zoo? An analysis of ten years of zoo-themed research output. ''Palgrave Communications'', :1-9&lt;/ref&gt; baveze bona isiqwi seenlwana yindawo leyo evelelwe umphakathi bonyana uzokubona iinlwana zemakhaya nezehlathi kanye nemanzini bonyana ziphila njani nokuthi bazuze ilwazi ngazo. Ihlathululo le ilinge ukufaka hlangana imihlobo yeenlwana leyo etholaka esiqwini seenlwana kanti nepilo yazi nelwazi lelo umphakathi ongalizuza. U-Zareva-Simeonova, u-Zlatanova, u-Racheva, u-Angelov no-Asenova (2009)&lt;ref&gt;Zareva-Simeonova, K., Zlatanova, D., Racheva, V. Angelov, V. &amp; Asenova, I. 2009. ''The zoos and their role in the formal and informal environmental education. Biotechnol &amp; Biotechnol''. EQ.&lt;/ref&gt; ithi yona, isiqwi seenlwana yindawo lapho kubekwa khona iinlwani, zivikelwe ngaphasi kwabasabenzi bamafundwakghono. Iinlwani lezi kungaka ngezemanzini nanyana zehlabathini. 

=== Ingabe kutholaka ziphi iinlwana esiqwini seenlwana? ===
[[Isimumathi:Unohaha.jpg|left|thumb]]
Iinlwani ezitholakala esiqwini seenlwana kutholaka zoke iinlwana (Wikipedia 2024&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. ''Zoo''. Litholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Zoo&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). Iinlwazi lezi zihlukaniswe ngokweendawo ezihlala kizo, lezo ezifaka amanzi nehlabathini. Iinlwani zehlabathini zifaka iinkomo iimbuduma, iimpunzi, iimbuzi, inyoka neenyoni. Iinlwana zemanzi zona zifaka iimfesi, imikhombo nabotjhaka. 

=== Isiqwi seenlwana lesi sinakekelwa bobani? ===
Isiqwi seenlwana sinakekela babantu abanengi labo abanamafundwakghona ahlukeneko. Amafundwakghona la afaka, abosoonlwana, abantu abasebenza ngeentjalo nemithi, nalabo abasebenzi ngamahlathi, abantu abasebenza ngamanzi neenlwana zemanzini kanye nabosobhoduluko kanye nabarhubhululi abahlukeneko (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;). Boke basebenza ngomnqopho munye wokusisa, ukusekela nokubulunga isiqwi seenlwana ngokupheleleko.

=== Isiphetho. ===
Isiqwi seenlwana siqakathekile khulu ekubulungeni nokuphephiseni iinlwana zoke eziphila emanzini nehlabathini. Begodu, siqinisekisa bonyana iinzukulwani ezizako ziba nethuba lokuzibona iinlwana lezi. 

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>0op1s9uxvgwugbyp2ismm9r1ltbjxfb</sha1>
    </revision>
    <revision>
      <id>939</id>
      <parentid>938</parentid>
      <timestamp>2024-10-14T13:46:56Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>938</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3167" sha1="0op1s9uxvgwugbyp2ismm9r1ltbjxfb" xml:space="preserve">== Isiqwi Seenlwana. ==

=== Isengeniso ===
Kukhona indawo lezo ezenzelwe ukubulunga, ukugcina kanye nokuvikela ubuphilo nobujamo bezinto ethize lokho okukhambisana nokunikela izinto lezo ibhoduluko elizijwaleyeleko. Indawo lezo kungenzeka bonyana zifake iinlwana, amahlathi, amanzi, iintjano nemithi. Ngaphasi kwalesi sihloko sizokunqopha khulu kusiqwi seenlwana. 

=== Kuyini isiqwi seenlwana na? ===
[[Isimumathi:Imbabala.jpg|thumb|Imbabala idla utjani]]
Ngokuya kuka-Nekolny no-Fiavona (2018&lt;ref&gt;Nekolny, L., &amp; Fialova, D. 2018. Zoo Tourism: What Actually Is a Zoo? ''Czech Journal of Tourism'', 7(2): 153–166.&lt;/ref&gt;) [[:en:Zoo|isiqwi seenlwana]] yindawo lapho kubekwa, kugcinwe begodu kutjengiswa iinlwana. Nasiqala ihlathululo le inzinze khulu mayelana nokuvikeleko nendawo la kutholakala khona iinlwana lezi. U-Rose, u-Brereton, u-Rowden, u-De Figuiredo, no-Riley (2019)&lt;ref&gt;Rose, P. E., Brereton, J. E., Rowden, L. J., De Figuiredo, R. L. &amp; Riley, L. M. 2019. What’s new from the zoo? An analysis of ten years of zoo-themed research output. ''Palgrave Communications'', :1-9&lt;/ref&gt; baveze bona isiqwi seenlwana yindawo leyo evelelwe umphakathi bonyana uzokubona iinlwana zemakhaya nezehlathi kanye nemanzini bonyana ziphila njani nokuthi bazuze ilwazi ngazo. Ihlathululo le ilinge ukufaka hlangana imihlobo yeenlwana leyo etholaka esiqwini seenlwana kanti nepilo yazi nelwazi lelo umphakathi ongalizuza. U-Zareva-Simeonova, u-Zlatanova, u-Racheva, u-Angelov no-Asenova (2009)&lt;ref&gt;Zareva-Simeonova, K., Zlatanova, D., Racheva, V. Angelov, V. &amp; Asenova, I. 2009. ''The zoos and their role in the formal and informal environmental education. Biotechnol &amp; Biotechnol''. EQ.&lt;/ref&gt; ithi yona, isiqwi seenlwana yindawo lapho kubekwa khona iinlwani, zivikelwe ngaphasi kwabasabenzi bamafundwakghono. Iinlwani lezi kungaka ngezemanzini nanyana zehlabathini. 

=== Ingabe kutholaka ziphi iinlwana esiqwini seenlwana? ===
[[Isimumathi:Unohaha.jpg|left|thumb]]
Iinlwani ezitholakala esiqwini seenlwana kutholaka zoke iinlwana (Wikipedia 2024&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. ''Zoo''. Litholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Zoo&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). Iinlwazi lezi zihlukaniswe ngokweendawo ezihlala kizo, lezo ezifaka amanzi nehlabathini. Iinlwani zehlabathini zifaka iinkomo iimbuduma, iimpunzi, iimbuzi, inyoka neenyoni. Iinlwana zemanzi zona zifaka iimfesi, imikhombo nabotjhaka. 

=== Isiqwi seenlwana lesi sinakekelwa bobani? ===
Isiqwi seenlwana sinakekela babantu abanengi labo abanamafundwakghona ahlukeneko. Amafundwakghona la afaka, abosoonlwana, abantu abasebenza ngeentjalo nemithi, nalabo abasebenzi ngamahlathi, abantu abasebenza ngamanzi neenlwana zemanzini kanye nabosobhoduluko kanye nabarhubhululi abahlukeneko (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;). Boke basebenza ngomnqopho munye wokusisa, ukusekela nokubulunga isiqwi seenlwana ngokupheleleko.

=== Isiphetho. ===
Isiqwi seenlwana siqakathekile khulu ekubulungeni nokuphephiseni iinlwana zoke eziphila emanzini nehlabathini. Begodu, siqinisekisa bonyana iinzukulwani ezizako ziba nethuba lokuzibona iinlwana lezi. 

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>0op1s9uxvgwugbyp2ismm9r1ltbjxfb</sha1>
    </revision>
  </page>
  <page>
    <title>Isokana</title>
    <ns>0</ns>
    <id>196</id>
    <revision>
      <id>940</id>
      <timestamp>2024-07-10T19:41:27Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;isokana mumuntu weembaji owelileko kodwana ongakathathi. Isokana kumuntu osele asesigabeni sokuthi angathatha abe nomfazi.&quot;</comment>
      <origin>940</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="122" sha1="96wpiacl6chp3obdwxkwwc4okosu9ts" xml:space="preserve">isokana mumuntu weembaji owelileko kodwana ongakathathi. Isokana kumuntu osele asesigabeni sokuthi angathatha abe nomfazi.</text>
      <sha1>96wpiacl6chp3obdwxkwwc4okosu9ts</sha1>
    </revision>
    <revision>
      <id>941</id>
      <parentid>940</parentid>
      <timestamp>2024-10-14T13:46:56Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>940</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="122" sha1="96wpiacl6chp3obdwxkwwc4okosu9ts" xml:space="preserve">isokana mumuntu weembaji owelileko kodwana ongakathathi. Isokana kumuntu osele asesigabeni sokuthi angathatha abe nomfazi.</text>
      <sha1>96wpiacl6chp3obdwxkwwc4okosu9ts</sha1>
    </revision>
    <revision>
      <id>2963</id>
      <parentid>941</parentid>
      <timestamp>2025-06-06T19:55:41Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>This page is sponsored by Raid: Shadow Legends, the sponsor of today's page.</comment>
      <origin>2963</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="209" sha1="80aqhhjc4af3nyqpnwetxg3xmoqzi5w" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.''' isokana mumuntu weembaji owelileko kodwana ongakathathi. Isokana kumuntu osele asesigabeni sokuthi angathatha abe nomfazi.</text>
      <sha1>80aqhhjc4af3nyqpnwetxg3xmoqzi5w</sha1>
    </revision>
    <revision>
      <id>3077</id>
      <parentid>2963</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Jon Harald Søby|Jon Harald Søby]]</comment>
      <origin>940</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="122" sha1="96wpiacl6chp3obdwxkwwc4okosu9ts" xml:space="preserve">isokana mumuntu weembaji owelileko kodwana ongakathathi. Isokana kumuntu osele asesigabeni sokuthi angathatha abe nomfazi.</text>
      <sha1>96wpiacl6chp3obdwxkwwc4okosu9ts</sha1>
    </revision>
  </page>
  <page>
    <title>Ithando</title>
    <ns>0</ns>
    <id>197</id>
    <revision>
      <id>942</id>
      <timestamp>2024-07-10T09:34:21Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Ithando''' mimizwa emihle umuntu abanayo ngomunye umuntu. Imizwa le kungaba ngeyabantu ahlala nabo ekumndeni wakhe  nanyana kube mimizwa yomuntu ohlukileko kunaye ngokobulili. Ithando yinto ehle khulu ngombana lakha ubuhlobo begodu likhulisa nemindeni. Ithando kuyinto eletha ukuthula nokuzwana emakhayeni. Abantu bakghona ukubekezelelana nokuthuthukisana ngesibanga sethando.   Woke amakhaya akhona ajame ngesibanga sethando. Ithando liletha ithabo nokujabula, lapho kuph...&quot;</comment>
      <origin>942</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="518" sha1="tqotwcb8cfvhd4qiioauujnmaloif33" xml:space="preserve">'''Ithando''' mimizwa emihle umuntu abanayo ngomunye umuntu. Imizwa le kungaba ngeyabantu ahlala nabo ekumndeni wakhe  nanyana kube mimizwa yomuntu ohlukileko kunaye ngokobulili. Ithando yinto ehle khulu ngombana lakha ubuhlobo begodu likhulisa nemindeni. Ithando kuyinto eletha ukuthula nokuzwana emakhayeni. Abantu bakghona ukubekezelelana nokuthuthukisana ngesibanga sethando. 

Woke amakhaya akhona ajame ngesibanga sethando. Ithando liletha ithabo nokujabula, lapho kuphelekhona ithando abantu bahlala badanile.

</text>
      <sha1>tqotwcb8cfvhd4qiioauujnmaloif33</sha1>
    </revision>
    <revision>
      <id>943</id>
      <parentid>942</parentid>
      <timestamp>2024-10-14T13:46:56Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>942</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="518" sha1="tqotwcb8cfvhd4qiioauujnmaloif33" xml:space="preserve">'''Ithando''' mimizwa emihle umuntu abanayo ngomunye umuntu. Imizwa le kungaba ngeyabantu ahlala nabo ekumndeni wakhe  nanyana kube mimizwa yomuntu ohlukileko kunaye ngokobulili. Ithando yinto ehle khulu ngombana lakha ubuhlobo begodu likhulisa nemindeni. Ithando kuyinto eletha ukuthula nokuzwana emakhayeni. Abantu bakghona ukubekezelelana nokuthuthukisana ngesibanga sethando. 

Woke amakhaya akhona ajame ngesibanga sethando. Ithando liletha ithabo nokujabula, lapho kuphelekhona ithando abantu bahlala badanile.

</text>
      <sha1>tqotwcb8cfvhd4qiioauujnmaloif33</sha1>
    </revision>
    <revision>
      <id>5787</id>
      <parentid>943</parentid>
      <timestamp>2025-09-23T17:43:09Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5787</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="591" sha1="37lknu63urywrc98hr98c5pddyg6tmp" xml:space="preserve">[[Isimumathi:Love padlocks on the Butchers' Bridge (Ljubljana).jpg|thumb|i]]
'''Ithando''' mimizwa emihle umuntu abanayo ngomunye umuntu. Imizwa le kungaba ngeyabantu ahlala nabo ekumndeni wakhe  nanyana kube mimizwa yomuntu ohlukileko kunaye ngokobulili. Ithando yinto ehle khulu ngombana lakha ubuhlobo begodu likhulisa nemindeni. Ithando kuyinto eletha ukuthula nokuzwana emakhayeni. Abantu bakghona ukubekezelelana nokuthuthukisana ngesibanga sethando. Woke amakhaya akhona ajame ngesibanga sethando. Ithando liletha ithabo nokujabula, lapho kuphelekhona ithando abantu bahlala badanile.</text>
      <sha1>37lknu63urywrc98hr98c5pddyg6tmp</sha1>
    </revision>
    <revision>
      <id>5788</id>
      <parentid>5787</parentid>
      <timestamp>2025-09-23T17:44:35Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5788</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="662" sha1="39c7tqm18jqg8gjp1482rrex2xi1pdg" xml:space="preserve">[[Isimumathi:Love padlocks on the Butchers' Bridge (Ljubljana).jpg|thumb|i]]
'''Ithando''' mimizwa emihle umuntu abanayo ngomunye umuntu. Imizwa le kungaba ngeyabantu ahlala nabo ekumndeni wakhe  nanyana kube mimizwa yomuntu ohlukileko kunaye ngokobulili. Ithando yinto ehle khulu ngombana lakha ubuhlobo begodu likhulisa nemindeni. Ithando kuyinto eletha ukuthula nokuzwana emakhayeni. Abantu bakghona ukubekezelelana nokuthuthukisana ngesibanga sethando. Woke amakhaya akhona ajame ngesibanga sethando. Ithando liletha ithabo nokujabula, lapho kuphelekhona ithando abantu bahlala badanile.
[[Category: Ithando]]
[[Category;Ilanga lethando]]
[[category:Imizwa]]</text>
      <sha1>39c7tqm18jqg8gjp1482rrex2xi1pdg</sha1>
    </revision>
    <revision>
      <id>5789</id>
      <parentid>5788</parentid>
      <timestamp>2025-09-23T17:45:15Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5789</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="662" sha1="m6w3rpl0xokhbl10tj2lmpj959f3fgz" xml:space="preserve">[[Isimumathi:Love padlocks on the Butchers' Bridge (Ljubljana).jpg|thumb|i]]
'''Ithando''' mimizwa emihle umuntu abanayo ngomunye umuntu. Imizwa le kungaba ngeyabantu ahlala nabo ekumndeni wakhe  nanyana kube mimizwa yomuntu ohlukileko kunaye ngokobulili. Ithando yinto ehle khulu ngombana lakha ubuhlobo begodu likhulisa nemindeni. Ithando kuyinto eletha ukuthula nokuzwana emakhayeni. Abantu bakghona ukubekezelelana nokuthuthukisana ngesibanga sethando. Woke amakhaya akhona ajame ngesibanga sethando. Ithando liletha ithabo nokujabula, lapho kuphelekhona ithando abantu bahlala badanile.
[[Category: Ithando]]
[[Category:Ilanga lethando]]
[[category:Imizwa]]</text>
      <sha1>m6w3rpl0xokhbl10tj2lmpj959f3fgz</sha1>
    </revision>
    <revision>
      <id>5790</id>
      <parentid>5789</parentid>
      <timestamp>2025-09-23T17:55:48Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5790</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1179" sha1="t95cal98cboxxkc139cykyd67f56nb3" xml:space="preserve">[[Isimumathi:Love padlocks on the Butchers' Bridge (Ljubljana).jpg|thumb|i]]
'''Ithando''' mimizwa emihle umuntu abanayo ngomunye umuntu. &lt;ref&gt;[[mwod:love#word-history|LOVE Definition &amp; Meaning - Merriam-Webster]]&lt;/ref&gt;[[Imizwa]] le kungaba ngeyabantu ahlala nabo ekumndeni wakhe  nanyana kube mimizwa yomuntu ohlukileko kunaye ngokobulili. Ithando yinto ehle khulu ngombana lakha ubuhlobo begodu likhulisa nemindeni. Ithando kuyinto eletha ukuthula nokuzwana emakhayeni. Abantu bakghona ukubekezelelana nokuthuthukisana ngesibanga sethando. Woke amakhaya akhona ajame ngesibanga sethando. Ithando liletha ithabo nokujabula, lapho kuphelekhona ithando abantu bahlala badanile.

Ithando libonakala lokha umuntu atshweyeka ngokuthi omunye umuntu  uhleli kuhle lapho akhona. Likhombisa ukuzinkela kwabantu ababili  ekutheni babe semaduze gokwenhliziyo nangommoya wabo. Ithando kuyinto yemvelo enganayo imibandela. Livela nofana lenzeka lapho umuntu angakacabangi khona. Imizwa yethando ingavuka lokha umuntu nakabona umuntu omuhle nofana umuntu onemikghwa, nofana oziphatha gendlela ayithandako.

== Iinkomba ==
[[Category: Ithando]]
[[Category:Ilanga lethando]]
[[category:Imizwa]]</text>
      <sha1>t95cal98cboxxkc139cykyd67f56nb3</sha1>
    </revision>
    <revision>
      <id>5791</id>
      <parentid>5790</parentid>
      <timestamp>2025-09-23T17:58:41Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5791</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1358" sha1="m7fx4zf1i2gu17brcexm2hu588meikr" xml:space="preserve">[[Isimumathi:Love padlocks on the Butchers' Bridge (Ljubljana).jpg|thumb|i]]
'''Ithando''' mimizwa emihle umuntu abanayo ngomunye umuntu. &lt;ref&gt;[[mwod:love#word-history|LOVE Definition &amp; Meaning - Merriam-Webster]]&lt;/ref&gt;[[Imizwa]] le kungaba ngeyabantu ahlala nabo ekumndeni wakhe  nanyana kube mimizwa yomuntu ohlukileko kunaye ngokobulili. Ithando yinto ehle khulu ngombana lakha ubuhlobo begodu likhulisa nemindeni. Ithando kuyinto eletha ukuthula nokuzwana emakhayeni. Abantu bakghona ukubekezelelana nokuthuthukisana ngesibanga sethando. Woke amakhaya akhona ajame ngesibanga sethando. Ithando liletha ithabo nokujabula, lapho kuphelekhona ithando abantu bahlala badanile.

Ithando libonakala lokha umuntu atshweyeka ngokuthi omunye umuntu  uhleli kuhle lapho akhona. Likhombisa ukuzinkela kwabantu ababili  ekutheni babe semaduze gokwenhliziyo nangommoya wabo. Ithando kuyinto yemvelo enganayo imibandela.&lt;ref&gt;Cordner, C., 2016. Unconditional love?. ''Cogent Arts &amp; Humanities'', ''3''(1), p.1207918.&lt;/ref&gt; Livela nofana lenzeka lapho umuntu angakacabangi khona. Imizwa yethando ingavuka lokha umuntu nakabona umuntu omuhle nofana umuntu onemikghwa, nofana oziphatha gendlela ayithandako. Abantu abathandako bakghone ukuthi balwe begodu babuye bakwazi ukulibalelana.

== Iinkomba ==
[[Category: Ithando]]
[[Category:Ilanga lethando]]
[[category:Imizwa]]</text>
      <sha1>m7fx4zf1i2gu17brcexm2hu588meikr</sha1>
    </revision>
    <revision>
      <id>6620</id>
      <parentid>5791</parentid>
      <timestamp>2026-05-19T07:45:18Z</timestamp>
      <contributor>
        <username>Kwamikagami</username>
        <id>1412</id>
      </contributor>
      <origin>6620</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1364" sha1="jjnq35pgpyffbju3tqcbva9l48nj89g" xml:space="preserve">[[Isimumathi:Love padlocks on the Butchers' Bridge (Ljubljana).jpg|thumb|ithando]]
'''Ithando''' mimizwa emihle umuntu abanayo ngomunye umuntu. &lt;ref&gt;[[mwod:love#word-history|LOVE Definition &amp; Meaning - Merriam-Webster]]&lt;/ref&gt;[[Imizwa]] le kungaba ngeyabantu ahlala nabo ekumndeni wakhe  nanyana kube mimizwa yomuntu ohlukileko kunaye ngokobulili. Ithando yinto ehle khulu ngombana lakha ubuhlobo begodu likhulisa nemindeni. Ithando kuyinto eletha ukuthula nokuzwana emakhayeni. Abantu bakghona ukubekezelelana nokuthuthukisana ngesibanga sethando. Woke amakhaya akhona ajame ngesibanga sethando. Ithando liletha ithabo nokujabula, lapho kuphelekhona ithando abantu bahlala badanile.

Ithando libonakala lokha umuntu atshweyeka ngokuthi omunye umuntu  uhleli kuhle lapho akhona. Likhombisa ukuzinkela kwabantu ababili  ekutheni babe semaduze gokwenhliziyo nangommoya wabo. Ithando kuyinto yemvelo enganayo imibandela.&lt;ref&gt;Cordner, C., 2016. Unconditional love?. ''Cogent Arts &amp; Humanities'', ''3''(1), p.1207918.&lt;/ref&gt; Livela nofana lenzeka lapho umuntu angakacabangi khona. Imizwa yethando ingavuka lokha umuntu nakabona umuntu omuhle nofana umuntu onemikghwa, nofana oziphatha gendlela ayithandako. Abantu abathandako bakghone ukuthi balwe begodu babuye bakwazi ukulibalelana.

== Iinkomba ==
[[Category: Ithando]]
[[Category:Ilanga lethando]]
[[category:Imizwa]]</text>
      <sha1>jjnq35pgpyffbju3tqcbva9l48nj89g</sha1>
    </revision>
  </page>
  <page>
    <title>Itheminografi</title>
    <ns>0</ns>
    <id>198</id>
    <revision>
      <id>944</id>
      <timestamp>2024-07-21T09:45:16Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;== Itheminografi == Itheminografi Sifundo esiphathelene nemisebenzi, izenzo, isakhiwo, amarhubhululo, namahlelo amayelana nethemiloji. Ngamanye amagama, koke okwenzekako lokha nakwakhiwa itheminoloji kufikela la isetjenziswa beyifundwa khona kubizwa ngokuthi yitheminografi.    Itheminografi kumkhakha okhethekileko loyo ofuna amakghonofundwa akhethekileko afana nomhlolimphoso, umrhubhululi welimi, ababutheleli data, abahlungi data, abatlami betheminoloji kanye nabalawuli...&quot;</comment>
      <origin>944</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4473" sha1="b7g4gn7zs0nmkt2eiujvpl8s3kijwb4" xml:space="preserve">== Itheminografi ==
Itheminografi Sifundo esiphathelene nemisebenzi, izenzo, isakhiwo, amarhubhululo, namahlelo amayelana nethemiloji. Ngamanye amagama, koke okwenzekako lokha nakwakhiwa itheminoloji kufikela la isetjenziswa beyifundwa khona kubizwa ngokuthi yitheminografi. 
 
Itheminografi kumkhakha okhethekileko loyo ofuna amakghonofundwa akhethekileko afana nomhlolimphoso, umrhubhululi welimi, ababutheleli data, abahlungi data, abatlami betheminoloji kanye nabalawuli bamahlelo nanyana amaphrojekhthi. Lokhu kusivezela bonaitheminographi inabe khulu ngaphakathi begodu yenziwe ziingcenye zinengi lezo ezisebenzisanako. 
 
Lokha nakutlanywa itheminoloji kuthonywa ngokubuthelela idata yomkhakha loyo ozabe ukhethiwe bonyana kuzokwakhiwa itheminoloji yawo. Ithi ingabuthelelwa, ihlungwe begodu irhumutjhwe idata le. Ngemva kokuhlungwa, idatha le iba mniningwana. Ukusuka lapho umniningwana lo ukghedlwe ngokuya ngokweengcezu zawo zekulumo, ihlathululo, umkhakha nobujamo bawo. Ukusuka lapho kwakhiwe ithemiloji etja. Lokha nasele kwakhiwe itheminoloji etja, umniningwana loyo uba lilwazi njengombana sele usetjenzisiwe begodu kunelwazi bonyana uyini, umnqopho wawo yini begodu umhlake njani kuneminye. 
 
Amaqhinga wokwakha itheminoloji manengi. Kodwana, ilimi lidlala indima ekulu ekukhetheni amaqhinga angasebenza elimini lelo. Amange amaqhinga asetjenziswa ukwakha itheminoloji ngila:
 
=== Ukusebenzisa ithemu elifanako ngelimi eliqothelweko ===
Kwesinye isikhathi uthola bonyana ithemu lelilimi elimsuka kukhona elikhambisana nalo nanyana elifana nalo ngehlathululo nangomqopho. Nakunjalo, kuthathwa lona. 
 
Isibonelo: teach [English] – fundisa [isiNdebele].
Ithemu leli, teach le-English litjho into eyodwa naleli lesiNdebele elithi, -fundisa. Ngalokho-ke, akudingeki bonyana kwakhiwe elinye ithemu. 

=== Ukukwakha ngokunciphisa ===
Leli qhinga lisebenzisa indlela yokunciphisa ithemu lelimi elimsuka ukwakha ithemu elimini eliqothelweko. Kodwana, nanyana ithemu lelimi elimsuka lelo lincitjhiswa, kufanele litlolwe ngelimi eliqothelweko begodu likhambisane nomthetho welimi eliqothelweko.
Isibonelo: Refrigerator (English) – Ifriji (isiNdebele).
Ithemu leli, refrigerator le English lincitjhisiwe lenziwa ifriji. Kodwana nanyana kunjalo, litlolwe ngesiNdebele begodu kwafakwa isithomo nephimiso lamatjhada wesiNdebele. 
Ukutjhugulula ngegama ngegama 

Leli iqhinga lisebenzisa indlela yokutjhugulula igama ngalinye ngendlela akhamba ngayo nanyana alandelana ngayo ukusuka elimi elimsuka ukuya elimini eliqothelweko. Elimi eliqothelweko kufanele itjhugululo lamagama la lilandelane njengoba belilandelene elimini elimsuka.
Isibonelo: Department of Education (English) – UmNyango wezeFundo (isiNdebele).
Nasiqala isibonelo esingehla sifunyana ithemu umnyango ngelimi eliqothelweko (isiNdebele) lelo elithi Department (English) ngelimi elimsuka. Wobamili amagama la asekuthomeni emalimi womabili. Amathemu la, of education (English) athi ngesiNdebele (ngelimi eliqothelweko) wezefundo begodu alandelana njengoba ahlezi kiwo woke amalimi la. 
 
=== Ukubizwa kwethemu kunjalo ===
Indlela yokubiza ithemu linjalo yindlela lapho ithemu liphinyiswa njengoba linjalo kodwana kusetjenziswe amatjhada welimi eliqothelweko.
Isibonelo: machine (English) – umtjhini (isiNdebele) 
La ithemu machine, lisetjenziswe linjalo ukusuka ku-English ukuya esiNdebeleni kodwana kwasetjenziswa amatjhada welimi lesiNdebele. Ukungezelela, woke amatjhada welimi elimsuka, angekho elimi eliqothelweko (isiNdebele) afana no-ch, ajanyiselwe ngo-tjh. Lokhu kungombana igama leli kufanele likhambisane nomthetho wokutlola nokupeleda wesiNdebele.  

Ukuhlanganisa amagama amabili ukwenza ithemu linye
Leli qhinga lisebenzisa amagama amabili lawo atjho izinto ezihlukileko ukuwahlanganisa bese atjho into yinye. Esikhathini esinengi akukakateleki bonyana amagama lawo abuye emkhakheni owodwa ngesikhathi ahlanganiswa. 
Isibonelo: umtjhiningqondo (computer)  

Ithemu leli umtjhininqgondo lakhiwe magama amabili lawo akhona ukuzijamela, umtjhini + ingqondo. Amathemu la bekatjho izinto ezihlukileko kodwana ahlanganiswa bonyana atjho i-computer. Lo umhlobo wamathemu ubizwa bonya mabizomvango. 

=== Isiphetho ===
Itheminografi kusifundo esiqakathekileko ekuthuthukiseni ilimi ngombana ngaso soke isikhathi kuba nezinto ezitja ezivelako lezo ezifuna amathemi amatjha. Ukwakhiwa kwamathemu nakho kufaka izinto ezinengi njengamaqhinga wokwakha mathemu lawo ekufanelwe esetjenziswe kuhle.

</text>
      <sha1>b7g4gn7zs0nmkt2eiujvpl8s3kijwb4</sha1>
    </revision>
    <revision>
      <id>945</id>
      <parentid>944</parentid>
      <timestamp>2024-09-18T15:55:40Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>945</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4493" sha1="0px3whizkywokhnwyw17cyzdll3thm1" xml:space="preserve">== Itheminografi ==

=== Isingeniso ===
Itheminografi Sifundo esiphathelene nemisebenzi, izenzo, isakhiwo, amarhubhululo, namahlelo amayelana nethemiloji. Ngamanye amagama, koke okwenzekako lokha nakwakhiwa itheminoloji kufikela la isetjenziswa beyifundwa khona kubizwa ngokuthi yitheminografi. 
 
Itheminografi kumkhakha okhethekileko loyo ofuna amakghonofundwa akhethekileko afana nomhlolimphoso, umrhubhululi welimi, ababutheleli data, abahlungi data, abatlami betheminoloji kanye nabalawuli bamahlelo nanyana amaphrojekhthi. Lokhu kusivezela bonaitheminographi inabe khulu ngaphakathi begodu yenziwe ziingcenye zinengi lezo ezisebenzisanako. 
 
Lokha nakutlanywa itheminoloji kuthonywa ngokubuthelela idata yomkhakha loyo ozabe ukhethiwe bonyana kuzokwakhiwa itheminoloji yawo. Ithi ingabuthelelwa, ihlungwe begodu irhumutjhwe idata le. Ngemva kokuhlungwa, idatha le iba mniningwana. Ukusuka lapho umniningwana lo ukghedlwe ngokuya ngokweengcezu zawo zekulumo, ihlathululo, umkhakha nobujamo bawo. Ukusuka lapho kwakhiwe ithemiloji etja. Lokha nasele kwakhiwe itheminoloji etja, umniningwana loyo uba lilwazi njengombana sele usetjenzisiwe begodu kunelwazi bonyana uyini, umnqopho wawo yini begodu umhlake njani kuneminye. 
 
Amaqhinga wokwakha itheminoloji manengi. Kodwana, ilimi lidlala indima ekulu ekukhetheni amaqhinga angasebenza elimini lelo. Amange amaqhinga asetjenziswa ukwakha itheminoloji ngila:
 
=== Ukusebenzisa ithemu elifanako ngelimi eliqothelweko ===
Kwesinye isikhathi uthola bonyana ithemu lelilimi elimsuka kukhona elikhambisana nalo nanyana elifana nalo ngehlathululo nangomqopho. Nakunjalo, kuthathwa lona. 
 
Isibonelo: teach [English] – fundisa [isiNdebele].
Ithemu leli, teach le-English litjho into eyodwa naleli lesiNdebele elithi, -fundisa. Ngalokho-ke, akudingeki bonyana kwakhiwe elinye ithemu. 

=== Ukukwakha ngokunciphisa ===
Leli qhinga lisebenzisa indlela yokunciphisa ithemu lelimi elimsuka ukwakha ithemu elimini eliqothelweko. Kodwana, nanyana ithemu lelimi elimsuka lelo lincitjhiswa, kufanele litlolwe ngelimi eliqothelweko begodu likhambisane nomthetho welimi eliqothelweko.
Isibonelo: Refrigerator (English) – Ifriji (isiNdebele).
Ithemu leli, refrigerator le English lincitjhisiwe lenziwa ifriji. Kodwana nanyana kunjalo, litlolwe ngesiNdebele begodu kwafakwa isithomo nephimiso lamatjhada wesiNdebele. 
Ukutjhugulula ngegama ngegama 

Leli iqhinga lisebenzisa indlela yokutjhugulula igama ngalinye ngendlela akhamba ngayo nanyana alandelana ngayo ukusuka elimi elimsuka ukuya elimini eliqothelweko. Elimi eliqothelweko kufanele itjhugululo lamagama la lilandelane njengoba belilandelene elimini elimsuka.
Isibonelo: Department of Education (English) – UmNyango wezeFundo (isiNdebele).
Nasiqala isibonelo esingehla sifunyana ithemu umnyango ngelimi eliqothelweko (isiNdebele) lelo elithi Department (English) ngelimi elimsuka. Wobamili amagama la asekuthomeni emalimi womabili. Amathemu la, of education (English) athi ngesiNdebele (ngelimi eliqothelweko) wezefundo begodu alandelana njengoba ahlezi kiwo woke amalimi la. 
 
=== Ukubizwa kwethemu kunjalo ===
Indlela yokubiza ithemu linjalo yindlela lapho ithemu liphinyiswa njengoba linjalo kodwana kusetjenziswe amatjhada welimi eliqothelweko.
Isibonelo: machine (English) – umtjhini (isiNdebele) 
La ithemu machine, lisetjenziswe linjalo ukusuka ku-English ukuya esiNdebeleni kodwana kwasetjenziswa amatjhada welimi lesiNdebele. Ukungezelela, woke amatjhada welimi elimsuka, angekho elimi eliqothelweko (isiNdebele) afana no-ch, ajanyiselwe ngo-tjh. Lokhu kungombana igama leli kufanele likhambisane nomthetho wokutlola nokupeleda wesiNdebele.  

Ukuhlanganisa amagama amabili ukwenza ithemu linye
Leli qhinga lisebenzisa amagama amabili lawo atjho izinto ezihlukileko ukuwahlanganisa bese atjho into yinye. Esikhathini esinengi akukakateleki bonyana amagama lawo abuye emkhakheni owodwa ngesikhathi ahlanganiswa. 
Isibonelo: umtjhiningqondo (computer)  

Ithemu leli umtjhininqgondo lakhiwe magama amabili lawo akhona ukuzijamela, umtjhini + ingqondo. Amathemu la bekatjho izinto ezihlukileko kodwana ahlanganiswa bonyana atjho i-computer. Lo umhlobo wamathemu ubizwa bonya mabizomvango. 

=== Isiphetho ===
Itheminografi kusifundo esiqakathekileko ekuthuthukiseni ilimi ngombana ngaso soke isikhathi kuba nezinto ezitja ezivelako lezo ezifuna amathemi amatjha. Ukwakhiwa kwamathemu nakho kufaka izinto ezinengi njengamaqhinga wokwakha mathemu lawo ekufanelwe esetjenziswe kuhle.

</text>
      <sha1>0px3whizkywokhnwyw17cyzdll3thm1</sha1>
    </revision>
    <revision>
      <id>946</id>
      <parentid>945</parentid>
      <timestamp>2024-10-14T13:46:57Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>945</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4493" sha1="0px3whizkywokhnwyw17cyzdll3thm1" xml:space="preserve">== Itheminografi ==

=== Isingeniso ===
Itheminografi Sifundo esiphathelene nemisebenzi, izenzo, isakhiwo, amarhubhululo, namahlelo amayelana nethemiloji. Ngamanye amagama, koke okwenzekako lokha nakwakhiwa itheminoloji kufikela la isetjenziswa beyifundwa khona kubizwa ngokuthi yitheminografi. 
 
Itheminografi kumkhakha okhethekileko loyo ofuna amakghonofundwa akhethekileko afana nomhlolimphoso, umrhubhululi welimi, ababutheleli data, abahlungi data, abatlami betheminoloji kanye nabalawuli bamahlelo nanyana amaphrojekhthi. Lokhu kusivezela bonaitheminographi inabe khulu ngaphakathi begodu yenziwe ziingcenye zinengi lezo ezisebenzisanako. 
 
Lokha nakutlanywa itheminoloji kuthonywa ngokubuthelela idata yomkhakha loyo ozabe ukhethiwe bonyana kuzokwakhiwa itheminoloji yawo. Ithi ingabuthelelwa, ihlungwe begodu irhumutjhwe idata le. Ngemva kokuhlungwa, idatha le iba mniningwana. Ukusuka lapho umniningwana lo ukghedlwe ngokuya ngokweengcezu zawo zekulumo, ihlathululo, umkhakha nobujamo bawo. Ukusuka lapho kwakhiwe ithemiloji etja. Lokha nasele kwakhiwe itheminoloji etja, umniningwana loyo uba lilwazi njengombana sele usetjenzisiwe begodu kunelwazi bonyana uyini, umnqopho wawo yini begodu umhlake njani kuneminye. 
 
Amaqhinga wokwakha itheminoloji manengi. Kodwana, ilimi lidlala indima ekulu ekukhetheni amaqhinga angasebenza elimini lelo. Amange amaqhinga asetjenziswa ukwakha itheminoloji ngila:
 
=== Ukusebenzisa ithemu elifanako ngelimi eliqothelweko ===
Kwesinye isikhathi uthola bonyana ithemu lelilimi elimsuka kukhona elikhambisana nalo nanyana elifana nalo ngehlathululo nangomqopho. Nakunjalo, kuthathwa lona. 
 
Isibonelo: teach [English] – fundisa [isiNdebele].
Ithemu leli, teach le-English litjho into eyodwa naleli lesiNdebele elithi, -fundisa. Ngalokho-ke, akudingeki bonyana kwakhiwe elinye ithemu. 

=== Ukukwakha ngokunciphisa ===
Leli qhinga lisebenzisa indlela yokunciphisa ithemu lelimi elimsuka ukwakha ithemu elimini eliqothelweko. Kodwana, nanyana ithemu lelimi elimsuka lelo lincitjhiswa, kufanele litlolwe ngelimi eliqothelweko begodu likhambisane nomthetho welimi eliqothelweko.
Isibonelo: Refrigerator (English) – Ifriji (isiNdebele).
Ithemu leli, refrigerator le English lincitjhisiwe lenziwa ifriji. Kodwana nanyana kunjalo, litlolwe ngesiNdebele begodu kwafakwa isithomo nephimiso lamatjhada wesiNdebele. 
Ukutjhugulula ngegama ngegama 

Leli iqhinga lisebenzisa indlela yokutjhugulula igama ngalinye ngendlela akhamba ngayo nanyana alandelana ngayo ukusuka elimi elimsuka ukuya elimini eliqothelweko. Elimi eliqothelweko kufanele itjhugululo lamagama la lilandelane njengoba belilandelene elimini elimsuka.
Isibonelo: Department of Education (English) – UmNyango wezeFundo (isiNdebele).
Nasiqala isibonelo esingehla sifunyana ithemu umnyango ngelimi eliqothelweko (isiNdebele) lelo elithi Department (English) ngelimi elimsuka. Wobamili amagama la asekuthomeni emalimi womabili. Amathemu la, of education (English) athi ngesiNdebele (ngelimi eliqothelweko) wezefundo begodu alandelana njengoba ahlezi kiwo woke amalimi la. 
 
=== Ukubizwa kwethemu kunjalo ===
Indlela yokubiza ithemu linjalo yindlela lapho ithemu liphinyiswa njengoba linjalo kodwana kusetjenziswe amatjhada welimi eliqothelweko.
Isibonelo: machine (English) – umtjhini (isiNdebele) 
La ithemu machine, lisetjenziswe linjalo ukusuka ku-English ukuya esiNdebeleni kodwana kwasetjenziswa amatjhada welimi lesiNdebele. Ukungezelela, woke amatjhada welimi elimsuka, angekho elimi eliqothelweko (isiNdebele) afana no-ch, ajanyiselwe ngo-tjh. Lokhu kungombana igama leli kufanele likhambisane nomthetho wokutlola nokupeleda wesiNdebele.  

Ukuhlanganisa amagama amabili ukwenza ithemu linye
Leli qhinga lisebenzisa amagama amabili lawo atjho izinto ezihlukileko ukuwahlanganisa bese atjho into yinye. Esikhathini esinengi akukakateleki bonyana amagama lawo abuye emkhakheni owodwa ngesikhathi ahlanganiswa. 
Isibonelo: umtjhiningqondo (computer)  

Ithemu leli umtjhininqgondo lakhiwe magama amabili lawo akhona ukuzijamela, umtjhini + ingqondo. Amathemu la bekatjho izinto ezihlukileko kodwana ahlanganiswa bonyana atjho i-computer. Lo umhlobo wamathemu ubizwa bonya mabizomvango. 

=== Isiphetho ===
Itheminografi kusifundo esiqakathekileko ekuthuthukiseni ilimi ngombana ngaso soke isikhathi kuba nezinto ezitja ezivelako lezo ezifuna amathemi amatjha. Ukwakhiwa kwamathemu nakho kufaka izinto ezinengi njengamaqhinga wokwakha mathemu lawo ekufanelwe esetjenziswe kuhle.

</text>
      <sha1>0px3whizkywokhnwyw17cyzdll3thm1</sha1>
    </revision>
  </page>
  <page>
    <title>Ithuthumbo lePhrothiya</title>
    <ns>0</ns>
    <id>199</id>
    <revision>
      <id>947</id>
      <timestamp>2024-06-27T12:14:04Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;IPhrothiya lithuthumbo elijamele inarha yeSewula Afrika. Litjengisa amagugu nokuziqhenya kweSewula Afrika njengesitjhaba.  &quot;</comment>
      <origin>947</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="123" sha1="hizor9kkfkb42fbeiboc35kqh1i38tk" xml:space="preserve">IPhrothiya lithuthumbo elijamele inarha yeSewula Afrika. Litjengisa amagugu nokuziqhenya kweSewula Afrika njengesitjhaba.

</text>
      <sha1>hizor9kkfkb42fbeiboc35kqh1i38tk</sha1>
    </revision>
    <revision>
      <id>948</id>
      <parentid>947</parentid>
      <timestamp>2024-06-27T12:14:38Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>948</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="129" sha1="dh1uykvd7aat4grc48j89llultplbzc" xml:space="preserve">'''IPhrothiya''' lithuthumbo elijamele inarha yeSewula Afrika. Litjengisa amagugu nokuziqhenya kweSewula Afrika njengesitjhaba.

</text>
      <sha1>dh1uykvd7aat4grc48j89llultplbzc</sha1>
    </revision>
    <revision>
      <id>949</id>
      <parentid>948</parentid>
      <timestamp>2024-06-27T13:41:05Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>949</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="478" sha1="fwm9ikymrosfkrjoukr6gzjb4ccvp3s" xml:space="preserve">'''IPhrothiya''' lithuthumbo elijamele inarha yeSewula Afrika. Litjengisa amagugu nokuziqhenya kweSewula Afrika njengesitjhaba. Ithuthumbo leli liliphawu lobuhle nekhono lokuphikelela ebudisini besitjhaba sekhethu. Lijamele ukuhlukahlukana kwamalimi, amasiko nekolo yabantu ababumbeneko abahlala enarheni yeSewula Afrika.

Ikghono lethuthumbo lePhrothiya ukukhula endaweni lapho kubudisi khona bona kungakhula into, kutjengisa ikghono lesitjhaba lokubekekela natural namandla.

</text>
      <sha1>fwm9ikymrosfkrjoukr6gzjb4ccvp3s</sha1>
    </revision>
    <revision>
      <id>950</id>
      <parentid>949</parentid>
      <timestamp>2024-06-30T17:27:00Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>950</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="552" sha1="lvgpmszob1zoo65f5cm7bwxii6cfde7" xml:space="preserve">[[Isimumathi:Protea cynaroides MS 9113.jpg|thumb|Ithuthumbo lePhrothiya]]
'''IPhrothiya''' lithuthumbo elijamele inarha yeSewula Afrika. Litjengisa amagugu nokuziqhenya kweSewula Afrika njengesitjhaba. Ithuthumbo leli liliphawu lobuhle nekhono lokuphikelela ebudisini besitjhaba sekhethu. Lijamele ukuhlukahlukana kwamalimi, amasiko nekolo yabantu ababumbeneko abahlala enarheni yeSewula Afrika.

Ikghono lethuthumbo lePhrothiya ukukhula endaweni lapho kubudisi khona bona kungakhula into, kutjengisa ikghono lesitjhaba lokubekekela natural namandla.

</text>
      <sha1>lvgpmszob1zoo65f5cm7bwxii6cfde7</sha1>
    </revision>
    <revision>
      <id>951</id>
      <parentid>950</parentid>
      <timestamp>2024-07-08T08:27:41Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>951</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="608" sha1="s4c3f4y6pnxdyytq7t1t3gmmyppobr5" xml:space="preserve">[[Isimumathi:Protea cynaroides MS 9113.jpg|thumb|Ithuthumbo lePhrothiya]]
'''IPhrothiya''' lithuthumbo elijamele inarha yeSewula Afrika. Ithuthumbo leli likhona ngemva kwemali ku coat of arms. Litjengisa amagugu nokuziqhenya kweSewula Afrika njengesitjhaba. Ithuthumbo leli liliphawu lobuhle nekhono lokuphikelela ebudisini besitjhaba sekhethu. Lijamele ukuhlukahlukana kwamalimi, amasiko nekolo yabantu ababumbeneko abahlala enarheni yeSewula Afrika.

Ikghono lethuthumbo lePhrothiya ukukhula endaweni lapho kubudisi khona bona kungakhula into, kutjengisa ikghono lesitjhaba lokubekekela natural namandla.

</text>
      <sha1>s4c3f4y6pnxdyytq7t1t3gmmyppobr5</sha1>
    </revision>
    <revision>
      <id>952</id>
      <parentid>951</parentid>
      <timestamp>2024-10-14T13:46:57Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>5 revisions imported</comment>
      <origin>951</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="608" sha1="s4c3f4y6pnxdyytq7t1t3gmmyppobr5" xml:space="preserve">[[Isimumathi:Protea cynaroides MS 9113.jpg|thumb|Ithuthumbo lePhrothiya]]
'''IPhrothiya''' lithuthumbo elijamele inarha yeSewula Afrika. Ithuthumbo leli likhona ngemva kwemali ku coat of arms. Litjengisa amagugu nokuziqhenya kweSewula Afrika njengesitjhaba. Ithuthumbo leli liliphawu lobuhle nekhono lokuphikelela ebudisini besitjhaba sekhethu. Lijamele ukuhlukahlukana kwamalimi, amasiko nekolo yabantu ababumbeneko abahlala enarheni yeSewula Afrika.

Ikghono lethuthumbo lePhrothiya ukukhula endaweni lapho kubudisi khona bona kungakhula into, kutjengisa ikghono lesitjhaba lokubekekela natural namandla.

</text>
      <sha1>s4c3f4y6pnxdyytq7t1t3gmmyppobr5</sha1>
    </revision>
    <revision>
      <id>2961</id>
      <parentid>952</parentid>
      <timestamp>2025-06-06T19:54:33Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>This page is sponsored by Raid: Shadow Legends, the sponsor of today's page.</comment>
      <origin>2961</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="687" sha1="6zhru9iin02sdeerlj45pdyjvbjdpqa" xml:space="preserve">[[Isimumathi:Protea cynaroides MS 9113.jpg|thumb|Ithuthumbo lePhrothiya]]
'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. IPhrothiya''' lithuthumbo elijamele inarha yeSewula Afrika. Ithuthumbo leli likhona ngemva kwemali ku coat of arms. Litjengisa amagugu nokuziqhenya kweSewula Afrika njengesitjhaba. Ithuthumbo leli liliphawu lobuhle nekhono lokuphikelela ebudisini besitjhaba sekhethu. Lijamele ukuhlukahlukana kwamalimi, amasiko nekolo yabantu ababumbeneko abahlala enarheni yeSewula Afrika.

Ikghono lethuthumbo lePhrothiya ukukhula endaweni lapho kubudisi khona bona kungakhula into, kutjengisa ikghono lesitjhaba lokubekekela natural namandla.</text>
      <sha1>6zhru9iin02sdeerlj45pdyjvbjdpqa</sha1>
    </revision>
    <revision>
      <id>3095</id>
      <parentid>2961</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Jon Harald Søby|Jon Harald Søby]]</comment>
      <origin>951</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="608" sha1="s4c3f4y6pnxdyytq7t1t3gmmyppobr5" xml:space="preserve">[[Isimumathi:Protea cynaroides MS 9113.jpg|thumb|Ithuthumbo lePhrothiya]]
'''IPhrothiya''' lithuthumbo elijamele inarha yeSewula Afrika. Ithuthumbo leli likhona ngemva kwemali ku coat of arms. Litjengisa amagugu nokuziqhenya kweSewula Afrika njengesitjhaba. Ithuthumbo leli liliphawu lobuhle nekhono lokuphikelela ebudisini besitjhaba sekhethu. Lijamele ukuhlukahlukana kwamalimi, amasiko nekolo yabantu ababumbeneko abahlala enarheni yeSewula Afrika.

Ikghono lethuthumbo lePhrothiya ukukhula endaweni lapho kubudisi khona bona kungakhula into, kutjengisa ikghono lesitjhaba lokubekekela natural namandla.

</text>
      <sha1>s4c3f4y6pnxdyytq7t1t3gmmyppobr5</sha1>
    </revision>
  </page>
  <page>
    <title>Itjhuguluko lesine lezamabubulo (4IR)</title>
    <ns>0</ns>
    <id>200</id>
    <revision>
      <id>953</id>
      <timestamp>2024-04-03T14:39:12Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Itjhuguluko lesine lezamabubulo''' kulapho iphasi sele lithuthukela ekusetjenzisweni okuphezulu kwetheknoloji ukulawila indlela yokuphila. Lelitjhuguluko libangela ukutjhuguluka kwezomnotho, elwazini,  kanye nemandleni.  &quot;</comment>
      <origin>953</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="224" sha1="061lz41gyg9mu8tv50fsnap17m2pll5" xml:space="preserve">'''Itjhuguluko lesine lezamabubulo''' kulapho iphasi sele lithuthukela ekusetjenzisweni okuphezulu kwetheknoloji ukulawila indlela yokuphila. Lelitjhuguluko libangela ukutjhuguluka kwezomnotho, elwazini,  kanye nemandleni.

</text>
      <sha1>061lz41gyg9mu8tv50fsnap17m2pll5</sha1>
    </revision>
    <revision>
      <id>954</id>
      <parentid>953</parentid>
      <timestamp>2024-04-03T14:40:13Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>954</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="408" sha1="53eov4om72drk9jmj02qdqi2rz8maav" xml:space="preserve">'''Itjhuguluko lesine lezamabubulo''' kulapho iphasi sele lithuthukela ekusetjenzisweni okuphezulu kwetheknoloji ukulawila indlela yokuphila.&lt;ref&gt;Xu, M., David, J.M. and Kim, S.H., 2018. The fourth industrial revolution: Opportunities and challenges. ''International journal of financial research'', ''9''(2), pp.90-95.&lt;/ref&gt; Lelitjhuguluko libangela ukutjhuguluka kwezomnotho, elwazini,  kanye nemandleni.

</text>
      <sha1>53eov4om72drk9jmj02qdqi2rz8maav</sha1>
    </revision>
    <revision>
      <id>955</id>
      <parentid>954</parentid>
      <timestamp>2024-04-07T20:55:13Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>955</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1014" sha1="04vfiye3vm23j64yt9kf9kxtsol785u" xml:space="preserve">'''Itjhuguluko lesine lezamabubulo''' kulapho iphasi sele lithuthukela ekusetjenzisweni okuphezulu kwetheknoloji ukulawila indlela yokuphila.&lt;ref&gt;Xu, M., David, J.M. and Kim, S.H., 2018. The fourth industrial revolution: Opportunities and challenges. ''International journal of financial research'', ''9''(2), pp.90-95.&lt;/ref&gt; Lelitjhuguluko libangela ukutjhuguluka kwezomnotho, elwazini,  kanye nemandleni.

== ubuhle betjhuguluko lesine lezamabubulo ==
Ubuhle betjhuguluko leli kukobana abantu bazokukhona ukwenza imisebenzi yabo ngendlela elula basebenzisa imitjhini bona ma AI. Abanye abantu sele bakhona ukusebenzela ekhaya. okhunye ukobana abantu baba nelwazwi eliphezulu lokusenzisa imitjhini.

== Ubudisi obulethwa litjhuguluko leli ==
Abantu abenza imisebenzi elula nejayelekileko bahlekelwa misebenzi ngombana esikhundleni sabo sele kusetjenziswa imitjhini ukwenza imisebenzi leyo. Izinga lobulelesi nalo liyakhuphuka, ngombana abantu bakhona ukusebenzisa imitjhini ukwebela abantu izinto ezifana nemali.
</text>
      <sha1>04vfiye3vm23j64yt9kf9kxtsol785u</sha1>
    </revision>
    <revision>
      <id>956</id>
      <parentid>955</parentid>
      <timestamp>2024-04-07T20:58:33Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>956</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1119" sha1="7wrt4jqg5h9kj0v7r9x21nt4qx2qndu" xml:space="preserve">[[Isimumathi:Industry 4.0 es.png|thumb|itjhuguluko lesine lezamabubulo liletha ukusetjenziswa kwama AI]]
'''Itjhuguluko lesine lezamabubulo''' kulapho iphasi sele lithuthukela ekusetjenzisweni okuphezulu kwetheknoloji ukulawila indlela yokuphila.&lt;ref&gt;Xu, M., David, J.M. and Kim, S.H., 2018. The fourth industrial revolution: Opportunities and challenges. ''International journal of financial research'', ''9''(2), pp.90-95.&lt;/ref&gt; Lelitjhuguluko libangela ukutjhuguluka kwezomnotho, elwazini,  kanye nemandleni.

== ubuhle betjhuguluko lesine lezamabubulo ==
Ubuhle betjhuguluko leli kukobana abantu bazokukhona ukwenza imisebenzi yabo ngendlela elula basebenzisa imitjhini bona ma AI. Abanye abantu sele bakhona ukusebenzela ekhaya. okhunye ukobana abantu baba nelwazwi eliphezulu lokusenzisa imitjhini.

== Ubudisi obulethwa litjhuguluko leli ==
Abantu abenza imisebenzi elula nejayelekileko bahlekelwa misebenzi ngombana esikhundleni sabo sele kusetjenziswa imitjhini ukwenza imisebenzi leyo. Izinga lobulelesi nalo liyakhuphuka, ngombana abantu bakhona ukusebenzisa imitjhini ukwebela abantu izinto ezifana nemali.
</text>
      <sha1>7wrt4jqg5h9kj0v7r9x21nt4qx2qndu</sha1>
    </revision>
    <revision>
      <id>957</id>
      <parentid>956</parentid>
      <timestamp>2024-04-07T20:59:39Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>957</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1127" sha1="n67kk67yb089fq85ipd0zg7s5q4yz8s" xml:space="preserve">[[Isimumathi:Industry 4.0 es.png|thumb|itjhuguluko lesine lezamabubulo liletha ukusetjenziswa kwama AI]]
'''Itjhuguluko lesine lezamabubulo''' kulapho iphasi sele lithuthukela ekusetjenzisweni okuphezulu [[kwetheknoloji]] ukulawila indlela yokuphila.&lt;ref&gt;Xu, M., David, J.M. and Kim, S.H., 2018. The fourth industrial revolution: Opportunities and challenges. ''International journal of financial research'', ''9''(2), pp.90-95.&lt;/ref&gt; Lelitjhuguluko libangela ukutjhuguluka kwezomnotho, elwazini,  kanye nemandleni.

== ubuhle betjhuguluko lesine lezamabubulo ==
Ubuhle betjhuguluko leli kukobana abantu bazokukhona ukwenza imisebenzi yabo ngendlela elula basebenzisa imitjhini bona ma [[AI]]. Abanye abantu sele bakhona ukusebenzela ekhaya. okhunye ukobana abantu baba nelwazwi eliphezulu lokusenzisa imitjhini.

== Ubudisi obulethwa litjhuguluko leli ==
Abantu abenza imisebenzi elula nejayelekileko bahlekelwa misebenzi ngombana esikhundleni sabo sele kusetjenziswa imitjhini ukwenza imisebenzi leyo. Izinga lobulelesi nalo liyakhuphuka, ngombana abantu bakhona ukusebenzisa imitjhini ukwebela abantu izinto ezifana nemali.
</text>
      <sha1>n67kk67yb089fq85ipd0zg7s5q4yz8s</sha1>
    </revision>
    <revision>
      <id>958</id>
      <parentid>957</parentid>
      <timestamp>2024-10-14T13:46:57Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>5 revisions imported</comment>
      <origin>957</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1127" sha1="n67kk67yb089fq85ipd0zg7s5q4yz8s" xml:space="preserve">[[Isimumathi:Industry 4.0 es.png|thumb|itjhuguluko lesine lezamabubulo liletha ukusetjenziswa kwama AI]]
'''Itjhuguluko lesine lezamabubulo''' kulapho iphasi sele lithuthukela ekusetjenzisweni okuphezulu [[kwetheknoloji]] ukulawila indlela yokuphila.&lt;ref&gt;Xu, M., David, J.M. and Kim, S.H., 2018. The fourth industrial revolution: Opportunities and challenges. ''International journal of financial research'', ''9''(2), pp.90-95.&lt;/ref&gt; Lelitjhuguluko libangela ukutjhuguluka kwezomnotho, elwazini,  kanye nemandleni.

== ubuhle betjhuguluko lesine lezamabubulo ==
Ubuhle betjhuguluko leli kukobana abantu bazokukhona ukwenza imisebenzi yabo ngendlela elula basebenzisa imitjhini bona ma [[AI]]. Abanye abantu sele bakhona ukusebenzela ekhaya. okhunye ukobana abantu baba nelwazwi eliphezulu lokusenzisa imitjhini.

== Ubudisi obulethwa litjhuguluko leli ==
Abantu abenza imisebenzi elula nejayelekileko bahlekelwa misebenzi ngombana esikhundleni sabo sele kusetjenziswa imitjhini ukwenza imisebenzi leyo. Izinga lobulelesi nalo liyakhuphuka, ngombana abantu bakhona ukusebenzisa imitjhini ukwebela abantu izinto ezifana nemali.
</text>
      <sha1>n67kk67yb089fq85ipd0zg7s5q4yz8s</sha1>
    </revision>
    <revision>
      <id>2165</id>
      <parentid>958</parentid>
      <timestamp>2024-11-27T06:18:14Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>+ Iinkomba</comment>
      <origin>2165</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1154" sha1="fc5czdp8ks83cpwjh64pbba4facrkw5" xml:space="preserve">[[Isimumathi:Industry 4.0 es.png|thumb|itjhuguluko lesine lezamabubulo liletha ukusetjenziswa kwama AI]]
'''Itjhuguluko lesine lezamabubulo''' kulapho iphasi sele lithuthukela ekusetjenzisweni okuphezulu [[kwetheknoloji]] ukulawila indlela yokuphila.&lt;ref&gt;Xu, M., David, J.M. and Kim, S.H., 2018. The fourth industrial revolution: Opportunities and challenges. ''International journal of financial research'', ''9''(2), pp.90-95.&lt;/ref&gt; Lelitjhuguluko libangela ukutjhuguluka kwezomnotho, elwazini,  kanye nemandleni.

== ubuhle betjhuguluko lesine lezamabubulo ==
Ubuhle betjhuguluko leli kukobana abantu bazokukhona ukwenza imisebenzi yabo ngendlela elula basebenzisa imitjhini bona ma [[AI]]. Abanye abantu sele bakhona ukusebenzela ekhaya. okhunye ukobana abantu baba nelwazwi eliphezulu lokusenzisa imitjhini.

== Ubudisi obulethwa litjhuguluko leli ==
Abantu abenza imisebenzi elula nejayelekileko bahlekelwa misebenzi ngombana esikhundleni sabo sele kusetjenziswa imitjhini ukwenza imisebenzi leyo. Izinga lobulelesi nalo liyakhuphuka, ngombana abantu bakhona ukusebenzisa imitjhini ukwebela abantu izinto ezifana nemali.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>fc5czdp8ks83cpwjh64pbba4facrkw5</sha1>
    </revision>
  </page>
  <page>
    <title>Izinto Ezabanga Ipi Yephasi</title>
    <ns>0</ns>
    <id>201</id>
    <revision>
      <id>959</id>
      <timestamp>2024-09-15T10:31:44Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;== Izinto Ezabanga Ipi Yephasi Yesibili ==  === Isingeniso === [[:en:Causes_of_World_War_II|Ipi yephasi yesibili]] ngezinye zezinto ezibuhlungu ezenzeka ephasini esiphila kibo. Ipi yephasi yathoma ngomnyaka we-1939, yaphela ngomnyaka we-1945 (Myrice 2015&lt;ref name=&quot;:0&quot;&gt;Myrice, E. 2015. The Impact of the Second World War on the Decolonization of Africa. Africana. ''Studies Student Research Conference'', 2:1-10.&lt;/ref&gt;). Lokhu kutjho bonyana ipi yephasi yathatha iminyaka esi...&quot;</comment>
      <origin>959</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2862" sha1="p8m1038db5l7mdz7c3o20oh65lidyh0" xml:space="preserve">== Izinto Ezabanga Ipi Yephasi Yesibili ==

=== Isingeniso ===
[[:en:Causes_of_World_War_II|Ipi yephasi yesibili]] ngezinye zezinto ezibuhlungu ezenzeka ephasini esiphila kibo. Ipi yephasi yathoma ngomnyaka we-1939, yaphela ngomnyaka we-1945 (Myrice 2015&lt;ref name=&quot;:0&quot;&gt;Myrice, E. 2015. The Impact of the Second World War on the Decolonization of Africa. Africana. ''Studies Student Research Conference'', 2:1-10.&lt;/ref&gt;). Lokhu kutjho bonyana ipi yephasi yathatha iminyaka esithantathu yoke. Ngesikhathi sepi yephasi yesibili le kwalahleka amaphilo amanengi, kwatjhuguluka iimpilo zabanto kante nephasi ngokwalo. Nanyana kunjalo ke, ingabe yini eyafakaisandla bonyana kube nepi yephasi yesibili na? Umbuzo lo sizokulinga ukuwuphendula esihlokwaneni esilandelako. 

=== Ingabe yini eyafaka isandla bonyana kube nepi yephasi na? ===
Ngemva kokuba khona kwepi yokuthoma yephasi kwabakhonaimiphumela nomthintela loyo ophathelene namandla kanye nomnotho. Ngokuya kwe-Wikipedia (2024)&lt;ref name=&quot;:1&quot;&gt;Wikipedia. 2024. ''Causes of World War II''. Itholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Causes_of_World_War_II&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [27 kuRhoboyi 2024]&lt;/ref&gt;, umdosiphambili wehlangano i-Nazi Party, u-Adolf Hitler, wafuna amandla wokulawula i-Germany yoke kanye nokususa umthethosibopho, iVersailles, ngebanga lokuthi awukhambelani neemfuneko zakhe zokulawula ngekani ezinye iinarha (Wikipedia 2024&lt;ref name=&quot;:1&quot; /&gt;). U-Adolf Hitler wabe angasiyedwa, i-Fascist ye-Itally nayo yagandelela i-Ethiopia, ngokudluleleko kanti ngesikhathi esifanako i-Japan nayo yagandela i-China ngeemfuneko ezifanako nezaka-Adolf Hilter (Myrice 2015&lt;ref name=&quot;:0&quot; /&gt;). 

Iimfuneko lezi zazifaka hlangana umnotho, amandla wokubusa ezinye iinarha, ukulawula kwamajoni wezinye iinarha kanye nokususa imithetho ebakhandela bonyana bagandelele ezinye iinarha (Wikipedia 2024&lt;ref name=&quot;:1&quot; /&gt;). Nanyana kunjalo, iinarha eziphikisana nalokhu okufaka hlangana i-Britain, United State of America ne-France, zabumbana zabiza umhlangano lapho wabekwa ngokusemthethweni umthethosibopho, iTreaty of Versailles, loyo ovikela i-Germany, I-Italy ne-Japan bonyana igandelel ezinye iinarha begodu bazenzele umathanda kwezinye iinarha (Myrice 2015&lt;ref name=&quot;:0&quot; /&gt;). Lokhu kwakwatisa khulu u-Adolf Hitler kanye nabangani bakhe i-Japan ne-Italy, labo bathatha isiqunto bonyana nje ipi yephasi yesibili iyasuka begodu boke laba abangabasekeli kutjho bonyana manaba wabo (Oxford 2010&lt;ref&gt;Oxford. ''2010. Big Ideas geography: History''. Oxford&lt;/ref&gt;).

=== Isiphetho ===
Amandla womnotho, nokulawulwa kwamajoni kanye kugcilaza ezinye iinarha zadlala indima ekulu ekwenzi esiqiniseko sokobanyana ipi yephasi yesibili iba khona. Nanyana kunjalo, ngemva kweminyana esithantathu ipi yephasi ikhona, kwakghonakala bonyana iphele begodu kube nokuthula ephasini. 

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>p8m1038db5l7mdz7c3o20oh65lidyh0</sha1>
    </revision>
    <revision>
      <id>960</id>
      <parentid>959</parentid>
      <timestamp>2024-10-14T13:46:58Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>959</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2862" sha1="p8m1038db5l7mdz7c3o20oh65lidyh0" xml:space="preserve">== Izinto Ezabanga Ipi Yephasi Yesibili ==

=== Isingeniso ===
[[:en:Causes_of_World_War_II|Ipi yephasi yesibili]] ngezinye zezinto ezibuhlungu ezenzeka ephasini esiphila kibo. Ipi yephasi yathoma ngomnyaka we-1939, yaphela ngomnyaka we-1945 (Myrice 2015&lt;ref name=&quot;:0&quot;&gt;Myrice, E. 2015. The Impact of the Second World War on the Decolonization of Africa. Africana. ''Studies Student Research Conference'', 2:1-10.&lt;/ref&gt;). Lokhu kutjho bonyana ipi yephasi yathatha iminyaka esithantathu yoke. Ngesikhathi sepi yephasi yesibili le kwalahleka amaphilo amanengi, kwatjhuguluka iimpilo zabanto kante nephasi ngokwalo. Nanyana kunjalo ke, ingabe yini eyafakaisandla bonyana kube nepi yephasi yesibili na? Umbuzo lo sizokulinga ukuwuphendula esihlokwaneni esilandelako. 

=== Ingabe yini eyafaka isandla bonyana kube nepi yephasi na? ===
Ngemva kokuba khona kwepi yokuthoma yephasi kwabakhonaimiphumela nomthintela loyo ophathelene namandla kanye nomnotho. Ngokuya kwe-Wikipedia (2024)&lt;ref name=&quot;:1&quot;&gt;Wikipedia. 2024. ''Causes of World War II''. Itholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Causes_of_World_War_II&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [27 kuRhoboyi 2024]&lt;/ref&gt;, umdosiphambili wehlangano i-Nazi Party, u-Adolf Hitler, wafuna amandla wokulawula i-Germany yoke kanye nokususa umthethosibopho, iVersailles, ngebanga lokuthi awukhambelani neemfuneko zakhe zokulawula ngekani ezinye iinarha (Wikipedia 2024&lt;ref name=&quot;:1&quot; /&gt;). U-Adolf Hitler wabe angasiyedwa, i-Fascist ye-Itally nayo yagandelela i-Ethiopia, ngokudluleleko kanti ngesikhathi esifanako i-Japan nayo yagandela i-China ngeemfuneko ezifanako nezaka-Adolf Hilter (Myrice 2015&lt;ref name=&quot;:0&quot; /&gt;). 

Iimfuneko lezi zazifaka hlangana umnotho, amandla wokubusa ezinye iinarha, ukulawula kwamajoni wezinye iinarha kanye nokususa imithetho ebakhandela bonyana bagandelele ezinye iinarha (Wikipedia 2024&lt;ref name=&quot;:1&quot; /&gt;). Nanyana kunjalo, iinarha eziphikisana nalokhu okufaka hlangana i-Britain, United State of America ne-France, zabumbana zabiza umhlangano lapho wabekwa ngokusemthethweni umthethosibopho, iTreaty of Versailles, loyo ovikela i-Germany, I-Italy ne-Japan bonyana igandelel ezinye iinarha begodu bazenzele umathanda kwezinye iinarha (Myrice 2015&lt;ref name=&quot;:0&quot; /&gt;). Lokhu kwakwatisa khulu u-Adolf Hitler kanye nabangani bakhe i-Japan ne-Italy, labo bathatha isiqunto bonyana nje ipi yephasi yesibili iyasuka begodu boke laba abangabasekeli kutjho bonyana manaba wabo (Oxford 2010&lt;ref&gt;Oxford. ''2010. Big Ideas geography: History''. Oxford&lt;/ref&gt;).

=== Isiphetho ===
Amandla womnotho, nokulawulwa kwamajoni kanye kugcilaza ezinye iinarha zadlala indima ekulu ekwenzi esiqiniseko sokobanyana ipi yephasi yesibili iba khona. Nanyana kunjalo, ngemva kweminyana esithantathu ipi yephasi ikhona, kwakghonakala bonyana iphele begodu kube nokuthula ephasini. 

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>p8m1038db5l7mdz7c3o20oh65lidyh0</sha1>
    </revision>
    <revision>
      <id>2201</id>
      <parentid>960</parentid>
      <timestamp>2024-11-29T07:25:55Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <comment>/* Isilululwazi */Reflist</comment>
      <origin>2201</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2859" sha1="evu2synttkiekdrgn7tmyx4grcx0jp0" xml:space="preserve">== Izinto Ezabanga Ipi Yephasi Yesibili ==

=== Isingeniso ===
[[:en:Causes_of_World_War_II|Ipi yephasi yesibili]] ngezinye zezinto ezibuhlungu ezenzeka ephasini esiphila kibo. Ipi yephasi yathoma ngomnyaka we-1939, yaphela ngomnyaka we-1945 (Myrice 2015&lt;ref name=&quot;:0&quot;&gt;Myrice, E. 2015. The Impact of the Second World War on the Decolonization of Africa. Africana. ''Studies Student Research Conference'', 2:1-10.&lt;/ref&gt;). Lokhu kutjho bonyana ipi yephasi yathatha iminyaka esithantathu yoke. Ngesikhathi sepi yephasi yesibili le kwalahleka amaphilo amanengi, kwatjhuguluka iimpilo zabanto kante nephasi ngokwalo. Nanyana kunjalo ke, ingabe yini eyafakaisandla bonyana kube nepi yephasi yesibili na? Umbuzo lo sizokulinga ukuwuphendula esihlokwaneni esilandelako. 

=== Ingabe yini eyafaka isandla bonyana kube nepi yephasi na? ===
Ngemva kokuba khona kwepi yokuthoma yephasi kwabakhonaimiphumela nomthintela loyo ophathelene namandla kanye nomnotho. Ngokuya kwe-Wikipedia (2024)&lt;ref name=&quot;:1&quot;&gt;Wikipedia. 2024. ''Causes of World War II''. Itholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Causes_of_World_War_II&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [27 kuRhoboyi 2024]&lt;/ref&gt;, umdosiphambili wehlangano i-Nazi Party, u-Adolf Hitler, wafuna amandla wokulawula i-Germany yoke kanye nokususa umthethosibopho, iVersailles, ngebanga lokuthi awukhambelani neemfuneko zakhe zokulawula ngekani ezinye iinarha (Wikipedia 2024&lt;ref name=&quot;:1&quot; /&gt;). U-Adolf Hitler wabe angasiyedwa, i-Fascist ye-Itally nayo yagandelela i-Ethiopia, ngokudluleleko kanti ngesikhathi esifanako i-Japan nayo yagandela i-China ngeemfuneko ezifanako nezaka-Adolf Hilter (Myrice 2015&lt;ref name=&quot;:0&quot; /&gt;). 

Iimfuneko lezi zazifaka hlangana umnotho, amandla wokubusa ezinye iinarha, ukulawula kwamajoni wezinye iinarha kanye nokususa imithetho ebakhandela bonyana bagandelele ezinye iinarha (Wikipedia 2024&lt;ref name=&quot;:1&quot; /&gt;). Nanyana kunjalo, iinarha eziphikisana nalokhu okufaka hlangana i-Britain, United State of America ne-France, zabumbana zabiza umhlangano lapho wabekwa ngokusemthethweni umthethosibopho, iTreaty of Versailles, loyo ovikela i-Germany, I-Italy ne-Japan bonyana igandelel ezinye iinarha begodu bazenzele umathanda kwezinye iinarha (Myrice 2015&lt;ref name=&quot;:0&quot; /&gt;). Lokhu kwakwatisa khulu u-Adolf Hitler kanye nabangani bakhe i-Japan ne-Italy, labo bathatha isiqunto bonyana nje ipi yephasi yesibili iyasuka begodu boke laba abangabasekeli kutjho bonyana manaba wabo (Oxford 2010&lt;ref&gt;Oxford. ''2010. Big Ideas geography: History''. Oxford&lt;/ref&gt;).

=== Isiphetho ===
Amandla womnotho, nokulawulwa kwamajoni kanye kugcilaza ezinye iinarha zadlala indima ekulu ekwenzi esiqiniseko sokobanyana ipi yephasi yesibili iba khona. Nanyana kunjalo, ngemva kweminyana esithantathu ipi yephasi ikhona, kwakghonakala bonyana iphele begodu kube nokuthula ephasini. 

=== Isilululwazi ===
{{Reflist}}</text>
      <sha1>evu2synttkiekdrgn7tmyx4grcx0jp0</sha1>
    </revision>
    <revision>
      <id>3571</id>
      <parentid>2201</parentid>
      <timestamp>2025-08-06T09:11:08Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <origin>3571</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2950" sha1="k199sc26xh4cto7e7mnbrgf4cbur16u" xml:space="preserve">== Izinto Ezabanga Ipi Yephasi Yesibili ==

=== Isingeniso ===
[[:en:Causes_of_World_War_II|Ipi yephasi yesibili]] ngezinye zezinto ezibuhlungu ezenzeka ephasini esiphila kibo. Ipi yephasi yathoma ngomnyaka we-1939, yaphela ngomnyaka we-1945 (Myrice 2015&lt;ref name=&quot;:0&quot;&gt;Myrice, E. 2015. The Impact of the Second World War on the Decolonization of Africa. Africana. ''Studies Student Research Conference'', 2:1-10.&lt;/ref&gt;). Lokhu kutjho bonyana ipi yephasi yathatha iminyaka esithantathu yoke. Ngesikhathi sepi yephasi yesibili le kwalahleka amaphilo amanengi, kwatjhuguluka iimpilo zabanto kante nephasi ngokwalo. Nanyana kunjalo ke, ingabe yini eyafakaisandla bonyana kube nepi yephasi yesibili na? Umbuzo lo sizokulinga ukuwuphendula esihlokwaneni esilandelako. 

=== Ingabe yini eyafaka isandla bonyana kube nepi yephasi na? ===
Ngemva kokuba khona kwepi yokuthoma yephasi kwabakhonaimiphumela nomthintela loyo ophathelene namandla kanye nomnotho. Ngokuya kwe-Wikipedia (2024)&lt;ref name=&quot;:1&quot;&gt;Wikipedia. 2024. ''Causes of World War II''. Itholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Causes_of_World_War_II&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [27 kuRhoboyi 2024]&lt;/ref&gt;, umdosiphambili wehlangano i-Nazi Party, u-Adolf Hitler, wafuna amandla wokulawula i-Germany yoke kanye nokususa umthethosibopho, iVersailles, ngebanga lokuthi awukhambelani neemfuneko zakhe zokulawula ngekani ezinye iinarha (Wikipedia 2024&lt;ref name=&quot;:1&quot; /&gt;). U-Adolf Hitler wabe angasiyedwa, i-Fascist ye-Itally nayo yagandelela i-Ethiopia, ngokudluleleko kanti ngesikhathi esifanako i-Japan nayo yagandela i-China ngeemfuneko ezifanako nezaka-Adolf Hilter (Myrice 2015&lt;ref name=&quot;:0&quot; /&gt;). 

Iimfuneko lezi zazifaka hlangana umnotho, amandla wokubusa ezinye iinarha, ukulawula kwamajoni wezinye iinarha kanye nokususa imithetho ebakhandela bonyana bagandelele ezinye iinarha (Wikipedia 2024&lt;ref name=&quot;:1&quot; /&gt;). Nanyana kunjalo, iinarha eziphikisana nalokhu okufaka hlangana i-Britain, United State of America ne-France, zabumbana zabiza umhlangano lapho wabekwa ngokusemthethweni umthethosibopho, iTreaty of Versailles, loyo ovikela i-Germany, I-Italy ne-Japan bonyana igandelel ezinye iinarha begodu bazenzele umathanda kwezinye iinarha (Myrice 2015&lt;ref name=&quot;:0&quot; /&gt;). Lokhu kwakwatisa khulu u-Adolf Hitler kanye nabangani bakhe i-Japan ne-Italy, labo bathatha isiqunto bonyana nje ipi yephasi yesibili iyasuka begodu boke laba abangabasekeli kutjho bonyana manaba wabo (Oxford 2010&lt;ref&gt;Oxford. ''2010. Big Ideas geography: History''. Oxford&lt;/ref&gt;).

=== Isiphetho ===
Amandla womnotho, nokulawulwa kwamajoni kanye kugcilaza ezinye iinarha zadlala indima ekulu ekwenzi esiqiniseko sokobanyana ipi yephasi yesibili iba khona. Nanyana kunjalo, ngemva kweminyana esithantathu ipi yephasi ikhona, kwakghonakala bonyana iphele begodu kube nokuthula ephasini. 

=== Isilululwazi ===
{{Reflist}}

[[Category:Ipi yephasi yesibili]]
[[Category:Ipi yephasi yokuthoma]]
[[Category:Iinarha]]</text>
      <sha1>k199sc26xh4cto7e7mnbrgf4cbur16u</sha1>
    </revision>
  </page>
  <page>
    <title>Jabu Mahlangu</title>
    <ns>0</ns>
    <id>202</id>
    <revision>
      <id>961</id>
      <timestamp>2024-03-15T19:07:05Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Created a new article.</comment>
      <origin>961</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="107" sha1="m2dawvp60z2cdc8twt2zkx0nap4nbxu" xml:space="preserve">'''Jabu Mahlangu''' obuye aziwe ngo Jabu Pule wayengumdlai wecembe lebhola i Kaizer Chiefs, eSewula Afrika.</text>
      <sha1>m2dawvp60z2cdc8twt2zkx0nap4nbxu</sha1>
    </revision>
    <revision>
      <id>962</id>
      <parentid>961</parentid>
      <timestamp>2024-03-15T19:07:56Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>962</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="126" sha1="t57jkv5o6ddhr3evefy49txs2pgpruc" xml:space="preserve">'''Jabu Mahlangu''' obuye aziwe ngo Jabu Pule wayengumdlai wecembe lebhola i Kaizer Chiefs, e[[Isewula Afrika|Sewula Afrika]].</text>
      <sha1>t57jkv5o6ddhr3evefy49txs2pgpruc</sha1>
    </revision>
    <revision>
      <id>963</id>
      <parentid>962</parentid>
      <timestamp>2024-10-14T13:46:58Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>962</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="126" sha1="t57jkv5o6ddhr3evefy49txs2pgpruc" xml:space="preserve">'''Jabu Mahlangu''' obuye aziwe ngo Jabu Pule wayengumdlai wecembe lebhola i Kaizer Chiefs, e[[Isewula Afrika|Sewula Afrika]].</text>
      <sha1>t57jkv5o6ddhr3evefy49txs2pgpruc</sha1>
    </revision>
    <revision>
      <id>2221</id>
      <parentid>963</parentid>
      <timestamp>2024-11-29T14:13:44Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <comment>UJabu Mahlangu</comment>
      <origin>2221</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="127" sha1="3ewxc24x27bcjrd4vs9dglrsydogkzr" xml:space="preserve">'''UJabu Mahlangu''' obuye aziwe ngo Jabu Pule wayengumdlai wecembe lebhola i Kaizer Chiefs, e[[Isewula Afrika|Sewula Afrika]].</text>
      <sha1>3ewxc24x27bcjrd4vs9dglrsydogkzr</sha1>
    </revision>
  </page>
  <page>
    <title>Jerry Sikhosana</title>
    <ns>0</ns>
    <id>203</id>
    <revision>
      <id>964</id>
      <timestamp>2024-03-15T18:48:59Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Created a new page.</comment>
      <origin>964</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="96" sha1="ka4flhmqv5vn8z3uzf323ppy3sp6yxb" xml:space="preserve">Jerry Sikhosana wayengumdlali webhola lezinyawo waseSewula Afrika obekadlalela iOrlando Pirates.</text>
      <sha1>ka4flhmqv5vn8z3uzf323ppy3sp6yxb</sha1>
    </revision>
    <revision>
      <id>965</id>
      <parentid>964</parentid>
      <timestamp>2024-03-15T18:49:33Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>965</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="102" sha1="ktwijw5w291du7q0bhkob89rwn4f7bv" xml:space="preserve">'''Jerry Sikhosana''' wayengumdlali webhola lezinyawo waseSewula Afrika obekadlalela iOrlando Pirates.</text>
      <sha1>ktwijw5w291du7q0bhkob89rwn4f7bv</sha1>
    </revision>
    <revision>
      <id>966</id>
      <parentid>965</parentid>
      <timestamp>2024-10-14T13:46:58Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>965</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="102" sha1="ktwijw5w291du7q0bhkob89rwn4f7bv" xml:space="preserve">'''Jerry Sikhosana''' wayengumdlali webhola lezinyawo waseSewula Afrika obekadlalela iOrlando Pirates.</text>
      <sha1>ktwijw5w291du7q0bhkob89rwn4f7bv</sha1>
    </revision>
    <revision>
      <id>2232</id>
      <parentid>966</parentid>
      <timestamp>2024-12-04T00:18:51Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2232</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="739" sha1="p92ebzya29cul9eh1jhwoku72z29tjl" xml:space="preserve">'''U-Jerry Sikhosana''' (wabelethwa mhlazi-8 kuMgwengweni 1969[2]) mdlali webholo weSewula Afrika. Ukudlala isikhathi esinengi somsebenzi wakhe e-Orlando Pirates, bekangumlandeli omkhulu we-Pirates i-Kaizer Chiefs, begodu wadlalela isiqhema sakhe emidlalweni ye-Soweto, okufaka hlangana ukushaya i-hat-trick ku-1996 Bob Save Superbowl semifinal, umdlalo owaziwa nge- U-Jerry Sikhosana i-derby.[3][4][5][6][7] Wabizwa ngebizo elithi &quot;Legs of Thunder&quot; ngemva kwehhashi lomjaho oyintshatsheli ebegade lilingiswa emdlalweni we-TV weSewula Afrika, begodu sele azuze isikhundla esidumileko e-Orlando Pirates njengomdlali oqinileko wokuzingela amagoli ngabo-1990. Bekayingcenye yesiqhema esiphumeleleko se-African Champions League ngo-1995.[8][9]</text>
      <sha1>p92ebzya29cul9eh1jhwoku72z29tjl</sha1>
    </revision>
    <revision>
      <id>2233</id>
      <parentid>2232</parentid>
      <timestamp>2024-12-04T00:19:23Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2233</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="758" sha1="9bqvrkbblfws2bgvuqk5bsmf4bsm4sf" xml:space="preserve">'''U-Jerry Sikhosana''' (wabelethwa mhlazi-8 kuMgwengweni 1969[2]) mdlali webholo we[[Isewula Afrika|Sewula Afrika]]. Ukudlala isikhathi esinengi somsebenzi wakhe e-Orlando Pirates, bekangumlandeli omkhulu we-Pirates i-Kaizer Chiefs, begodu wadlalela isiqhema sakhe emidlalweni ye-Soweto, okufaka hlangana ukushaya i-hat-trick ku-1996 Bob Save Superbowl semifinal, umdlalo owaziwa nge- U-Jerry Sikhosana i-derby.[3][4][5][6][7] Wabizwa ngebizo elithi &quot;Legs of Thunder&quot; ngemva kwehhashi lomjaho oyintshatsheli ebegade lilingiswa emdlalweni we-TV weSewula Afrika, begodu sele azuze isikhundla esidumileko e-Orlando Pirates njengomdlali oqinileko wokuzingela amagoli ngabo-1990. Bekayingcenye yesiqhema esiphumeleleko se-African Champions League ngo-1995.[8][9]</text>
      <sha1>9bqvrkbblfws2bgvuqk5bsmf4bsm4sf</sha1>
    </revision>
    <revision>
      <id>2234</id>
      <parentid>2233</parentid>
      <timestamp>2024-12-04T00:19:59Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2234</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="779" sha1="ikc41965jhko1hjv8ql61a4o08gfqz9" xml:space="preserve">'''U-Jerry Sikhosana''' (wabelethwa mhlazi-8 kuMgwengweni 1969[2]) mdlali webholo we[[Isewula Afrika|Sewula Afrika]]. Ukudlala isikhathi esinengi somsebenzi wakhe e-[[IOrlando Pirates|Orlando Pirates]], bekangumlandeli omkhulu we-Pirates i-Kaizer Chiefs, begodu wadlalela isiqhema sakhe emidlalweni ye-Soweto, okufaka hlangana ukushaya i-hat-trick ku-1996 Bob Save Superbowl semifinal, umdlalo owaziwa nge- U-Jerry Sikhosana i-derby.[3][4][5][6][7] Wabizwa ngebizo elithi &quot;Legs of Thunder&quot; ngemva kwehhashi lomjaho oyintshatsheli ebegade lilingiswa emdlalweni we-TV weSewula Afrika, begodu sele azuze isikhundla esidumileko e-Orlando Pirates njengomdlali oqinileko wokuzingela amagoli ngabo-1990. Bekayingcenye yesiqhema esiphumeleleko se-African Champions League ngo-1995.[8][9]</text>
      <sha1>ikc41965jhko1hjv8ql61a4o08gfqz9</sha1>
    </revision>
    <revision>
      <id>2235</id>
      <parentid>2234</parentid>
      <timestamp>2024-12-04T00:20:11Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2235</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="766" sha1="18kceaoatlsmtcmvw8vvamw621qikmo" xml:space="preserve">'''U-Jerry Sikhosana''' (wabelethwa mhlazi-8 kuMgwengweni 1969[2]) mdlali webholo we[[Isewula Afrika|Sewula Afrika]]. Ukudlala isikhathi esinengi somsebenzi wakhe e-[[IOrlando Pirates|Orlando Pirates]], bekangumlandeli omkhulu we-Pirates i-Kaizer Chiefs, begodu wadlalela isiqhema sakhe emidlalweni ye-Soweto, okufaka hlangana ukushaya i-hat-trick ku-1996 Bob Save Superbowl semifinal, umdlalo owaziwa nge- U-Jerry Sikhosana i-derby.[3]Wabizwa ngebizo elithi &quot;Legs of Thunder&quot; ngemva kwehhashi lomjaho oyintshatsheli ebegade lilingiswa emdlalweni we-TV weSewula Afrika, begodu sele azuze isikhundla esidumileko e-Orlando Pirates njengomdlali oqinileko wokuzingela amagoli ngabo-1990. Bekayingcenye yesiqhema esiphumeleleko se-African Champions League ngo-1995.[8][9]</text>
      <sha1>18kceaoatlsmtcmvw8vvamw621qikmo</sha1>
    </revision>
    <revision>
      <id>2236</id>
      <parentid>2235</parentid>
      <timestamp>2024-12-04T00:20:24Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2236</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="760" sha1="tdog8253untrq3t2xy3t478tt3tst1f" xml:space="preserve">'''U-Jerry Sikhosana''' (wabelethwa mhlazi-8 kuMgwengweni 1969[2]) mdlali webholo we[[Isewula Afrika|Sewula Afrika]]. Ukudlala isikhathi esinengi somsebenzi wakhe e-[[IOrlando Pirates|Orlando Pirates]], bekangumlandeli omkhulu we-Pirates i-Kaizer Chiefs, begodu wadlalela isiqhema sakhe emidlalweni ye-Soweto, okufaka hlangana ukushaya i-hat-trick ku-1996 Bob Save Superbowl semifinal, umdlalo owaziwa nge- U-Jerry Sikhosana i-derby.[3]Wabizwa ngebizo elithi &quot;Legs of Thunder&quot; ngemva kwehhashi lomjaho oyintshatsheli ebegade lilingiswa emdlalweni we-TV weSewula Afrika, begodu sele azuze isikhundla esidumileko e-Orlando Pirates njengomdlali oqinileko wokuzingela amagoli ngabo-1990. Bekayingcenye yesiqhema esiphumeleleko se-African Champions League ngo-1995.</text>
      <sha1>tdog8253untrq3t2xy3t478tt3tst1f</sha1>
    </revision>
    <revision>
      <id>2237</id>
      <parentid>2236</parentid>
      <timestamp>2024-12-04T00:21:48Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2237</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="999" sha1="5fyz0k5i1bavqcir0nwcwoaihm1x71z" xml:space="preserve">'''U-Jerry Sikhosana''' (wabelethwa mhlazi-8 kuMgwengweni 1969[2]) mdlali webholo we[[Isewula Afrika|Sewula Afrika]].&lt;ref&gt;https://www.snl24.com/kickoff/sanews/premiership/orlando-pirates/story-behind-the-nickname-jerry-legs-of-thunder-sikhosana-20241110&lt;/ref&gt; Ukudlala isikhathi esinengi somsebenzi wakhe e-[[IOrlando Pirates|Orlando Pirates]], bekangumlandeli omkhulu we-Pirates i-Kaizer Chiefs, begodu wadlalela isiqhema sakhe emidlalweni ye-Soweto, okufaka hlangana ukushaya i-hat-trick ku-1996 Bob Save Superbowl semifinal, umdlalo owaziwa nge- U-Jerry Sikhosana i-derby.[3]Wabizwa ngebizo elithi &quot;Legs of Thunder&quot; ngemva kwehhashi lomjaho oyintshatsheli ebegade lilingiswa emdlalweni we-TV weSewula Afrika, begodu sele azuze isikhundla esidumileko e-Orlando Pirates njengomdlali oqinileko wokuzingela amagoli ngabo-1990. Bekayingcenye yesiqhema esiphumeleleko se-African Champions League ngo-1995.https://farpost.co.za/2024/11/24/jerry-skhosana-names-magesi-star-to-solve-chiefs-scoring-issues/</text>
      <sha1>5fyz0k5i1bavqcir0nwcwoaihm1x71z</sha1>
    </revision>
    <revision>
      <id>2238</id>
      <parentid>2237</parentid>
      <timestamp>2024-12-04T00:22:19Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2238</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1012" sha1="svvkk74me7t0kv9irxj5933iagjjxh7" xml:space="preserve">'''U-Jerry Sikhosana''' (wabelethwa mhlazi-8 kuMgwengweni 1969[2]) mdlali webholo we[[Isewula Afrika|Sewula Afrika]].&lt;ref&gt;https://www.snl24.com/kickoff/sanews/premiership/orlando-pirates/story-behind-the-nickname-jerry-legs-of-thunder-sikhosana-20241110&lt;/ref&gt; Ukudlala isikhathi esinengi somsebenzi wakhe e-[[IOrlando Pirates|Orlando Pirates]], bekangumlandeli omkhulu we-Pirates i-Kaizer Chiefs, begodu wadlalela isiqhema sakhe emidlalweni ye-Soweto, okufaka hlangana ukushaya i-hat-trick ku-1996 Bob Save Superbowl semifinal, umdlalo owaziwa nge- U-Jerry Sikhosana i-derby.[3]Wabizwa ngebizo elithi &quot;Legs of Thunder&quot; ngemva kwehhashi lomjaho oyintshatsheli ebegade lilingiswa emdlalweni we-TV weSewula Afrika, begodu sele azuze isikhundla esidumileko e-Orlando Pirates njengomdlali oqinileko wokuzingela amagoli ngabo-1990. Bekayingcenye yesiqhema esiphumeleleko se-African Champions League ngo-1995.https://farpost.co.za/2024/11/24/jerry-skhosana-names-magesi-star-to-solve-chiefs-scoring-issues/
==Iinkomba==</text>
      <sha1>svvkk74me7t0kv9irxj5933iagjjxh7</sha1>
    </revision>
    <revision>
      <id>2239</id>
      <parentid>2238</parentid>
      <timestamp>2024-12-04T00:23:09Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2239</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1023" sha1="e9caify27tob59ijp954cbdi8t781cf" xml:space="preserve">'''U-Jerry Sikhosana''' (wabelethwa mhlazi-8 kuMgwengweni 1969[2]) mdlali webholo we[[Isewula Afrika|Sewula Afrika]].&lt;ref&gt;https://www.snl24.com/kickoff/sanews/premiership/orlando-pirates/story-behind-the-nickname-jerry-legs-of-thunder-sikhosana-20241110&lt;/ref&gt; Ukudlala isikhathi esinengi somsebenzi wakhe e-[[IOrlando Pirates|Orlando Pirates]], bekangumlandeli omkhulu we-Pirates i-Kaizer Chiefs, begodu wadlalela isiqhema sakhe emidlalweni ye-Soweto, okufaka hlangana ukushaya i-hat-trick ku-1996 Bob Save Superbowl semifinal, umdlalo owaziwa nge- U-Jerry Sikhosana i-derby.[3]Wabizwa ngebizo elithi &quot;Legs of Thunder&quot; ngemva kwehhashi lomjaho oyintshatsheli ebegade lilingiswa emdlalweni we-TV weSewula Afrika, begodu sele azuze isikhundla esidumileko e-Orlando Pirates njengomdlali oqinileko wokuzingela amagoli ngabo-1990. Bekayingcenye yesiqhema esiphumeleleko se-African Champions League ngo-1995.&lt;ref&gt;https://farpost.co.za/2024/11/24/jerry-skhosana-names-magesi-star-to-solve-chiefs-scoring-issues/&lt;/ref&gt;
==Iinkomba==</text>
      <sha1>e9caify27tob59ijp954cbdi8t781cf</sha1>
    </revision>
    <revision>
      <id>2240</id>
      <parentid>2239</parentid>
      <timestamp>2024-12-04T00:23:32Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2240</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1035" sha1="rlbgw9umigexr3mk1mr7mskn6np9e3a" xml:space="preserve">'''U-Jerry Sikhosana''' (wabelethwa mhlazi-8 kuMgwengweni 1969[2]) mdlali webholo we[[Isewula Afrika|Sewula Afrika]].&lt;ref&gt;https://www.snl24.com/kickoff/sanews/premiership/orlando-pirates/story-behind-the-nickname-jerry-legs-of-thunder-sikhosana-20241110&lt;/ref&gt; Ukudlala isikhathi esinengi somsebenzi wakhe e-[[IOrlando Pirates|Orlando Pirates]], bekangumlandeli omkhulu we-Pirates i-Kaizer Chiefs, begodu wadlalela isiqhema sakhe emidlalweni ye-Soweto, okufaka hlangana ukushaya i-hat-trick ku-1996 Bob Save Superbowl semifinal, umdlalo owaziwa nge- U-Jerry Sikhosana i-derby.[3]Wabizwa ngebizo elithi &quot;Legs of Thunder&quot; ngemva kwehhashi lomjaho oyintshatsheli ebegade lilingiswa emdlalweni we-TV weSewula Afrika, begodu sele azuze isikhundla esidumileko e-Orlando Pirates njengomdlali oqinileko wokuzingela amagoli ngabo-1990. Bekayingcenye yesiqhema esiphumeleleko se-African Champions League ngo-1995.&lt;ref&gt;https://farpost.co.za/2024/11/24/jerry-skhosana-names-magesi-star-to-solve-chiefs-scoring-issues/&lt;/ref&gt;
==Iinkomba==
{{Reflist}}</text>
      <sha1>rlbgw9umigexr3mk1mr7mskn6np9e3a</sha1>
    </revision>
    <revision>
      <id>2241</id>
      <parentid>2240</parentid>
      <timestamp>2024-12-04T00:23:50Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2241</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1059" sha1="fdm82wvd0c48zfodan086dg8m1wbiqq" xml:space="preserve">'''U-Jerry Sikhosana''' (wabelethwa mhlazi-8 kuMgwengweni 1969[2]) mdlali webholo we[[Isewula Afrika|Sewula Afrika]].&lt;ref&gt;https://www.snl24.com/kickoff/sanews/premiership/orlando-pirates/story-behind-the-nickname-jerry-legs-of-thunder-sikhosana-20241110&lt;/ref&gt; Ukudlala isikhathi esinengi somsebenzi wakhe e-[[IOrlando Pirates|Orlando Pirates]], bekangumlandeli omkhulu we-Pirates i-Kaizer Chiefs, begodu wadlalela isiqhema sakhe emidlalweni ye-Soweto, okufaka hlangana ukushaya i-hat-trick ku-1996 Bob Save Superbowl semifinal, umdlalo owaziwa nge- U-Jerry Sikhosana i-derby.[3]Wabizwa ngebizo elithi &quot;Legs of Thunder&quot; ngemva kwehhashi lomjaho oyintshatsheli ebegade lilingiswa emdlalweni we-TV weSewula Afrika, begodu sele azuze isikhundla esidumileko e-Orlando Pirates njengomdlali oqinileko wokuzingela amagoli ngabo-1990. Bekayingcenye yesiqhema esiphumeleleko se-African Champions League ngo-1995.&lt;ref&gt;https://farpost.co.za/2024/11/24/jerry-skhosana-names-magesi-star-to-solve-chiefs-scoring-issues/&lt;/ref&gt;
==Iinkomba==
{{Reflist}}
[[Category:Bosaziwako]]</text>
      <sha1>fdm82wvd0c48zfodan086dg8m1wbiqq</sha1>
    </revision>
    <revision>
      <id>2242</id>
      <parentid>2241</parentid>
      <timestamp>2024-12-04T00:24:06Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2242</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1060" sha1="ex1sm3lxciu1cyfd502pldgqlrsvlh3" xml:space="preserve">'''U-Jerry Sikhosana''' (wabelethwa mhlazi-8 kuMgwengweni 1969[2]) mdlali webholo we[[Isewula Afrika|Sewula Afrika]].&lt;ref&gt;https://www.snl24.com/kickoff/sanews/premiership/orlando-pirates/story-behind-the-nickname-jerry-legs-of-thunder-sikhosana-20241110&lt;/ref&gt; Ukudlala isikhathi esinengi somsebenzi wakhe e-[[IOrlando Pirates|Orlando Pirates]], bekangumlandeli omkhulu we-Pirates i-Kaizer Chiefs, begodu wadlalela isiqhema sakhe emidlalweni ye-Soweto, okufaka hlangana ukushaya i-hat-trick ku-1996 Bob Save Superbowl semifinal, umdlalo owaziwa nge- U-Jerry Sikhosana i-derby.[3]Wabizwa ngebizo elithi &quot;Legs of Thunder&quot; ngemva kwehhashi lomjaho oyintshatsheli ebegade lilingiswa emdlalweni we-TV weSewula Afrika, begodu sele azuze isikhundla esidumileko e-Orlando Pirates njengomdlali oqinileko wokuzingela amagoli ngabo-1990. Bekayingcenye yesiqhema esiphumeleleko se-African Champions League ngo-1995.&lt;ref&gt;https://farpost.co.za/2024/11/24/jerry-skhosana-names-magesi-star-to-solve-chiefs-scoring-issues/&lt;/ref&gt;
==Iinkomba==
{{Reflist}}
[[Category:Abosaziwako]]</text>
      <sha1>ex1sm3lxciu1cyfd502pldgqlrsvlh3</sha1>
    </revision>
    <revision>
      <id>2245</id>
      <parentid>2242</parentid>
      <timestamp>2024-12-04T00:25:40Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2245</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1087" sha1="1imc98lo3qe9md4z3fcpqrcswkeoz5s" xml:space="preserve">'''U-Jerry Sikhosana''' (wabelethwa mhlazi-8 kuMgwengweni 1969[2]) mdlali webholo we[[Isewula Afrika|Sewula Afrika]].&lt;ref&gt;https://www.snl24.com/kickoff/sanews/premiership/orlando-pirates/story-behind-the-nickname-jerry-legs-of-thunder-sikhosana-20241110&lt;/ref&gt; Ukudlala isikhathi esinengi somsebenzi wakhe e-[[IOrlando Pirates|Orlando Pirates]], bekangumlandeli omkhulu we-Pirates i-Kaizer Chiefs, begodu wadlalela isiqhema sakhe emidlalweni ye-Soweto, okufaka hlangana ukushaya i-hat-trick ku-1996 Bob Save Superbowl semifinal, umdlalo owaziwa nge- U-Jerry Sikhosana i-derby.[3]Wabizwa ngebizo elithi &quot;Legs of Thunder&quot; ngemva kwehhashi lomjaho oyintshatsheli ebegade lilingiswa emdlalweni we-TV weSewula Afrika, begodu sele azuze isikhundla esidumileko e-Orlando Pirates njengomdlali oqinileko wokuzingela amagoli ngabo-1990. Bekayingcenye yesiqhema esiphumeleleko se-African Champions League ngo-1995.&lt;ref&gt;https://farpost.co.za/2024/11/24/jerry-skhosana-names-magesi-star-to-solve-chiefs-scoring-issues/&lt;/ref&gt;
==Iinkomba==
{{Reflist}}
[[Category:Abosaziwako]]
[[Mkhakha:Isewula Afrika]]</text>
      <sha1>1imc98lo3qe9md4z3fcpqrcswkeoz5s</sha1>
    </revision>
  </page>
  <page>
    <title>Joe Sibanyoni</title>
    <ns>0</ns>
    <id>204</id>
    <revision>
      <id>967</id>
      <timestamp>2024-03-08T13:14:54Z</timestamp>
      <contributor>
        <username>incubator&gt;LindiweSiba</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;UJoe Sibanyoni ungusomarhwebo no mphathi omkhulu matekisi, ohlala eKwaggafontein A.  &quot;</comment>
      <origin>967</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="85" sha1="hv6nnmgj7wnje582l71da9fryp00smk" xml:space="preserve">UJoe Sibanyoni ungusomarhwebo no mphathi omkhulu matekisi, ohlala eKwaggafontein A.

</text>
      <sha1>hv6nnmgj7wnje582l71da9fryp00smk</sha1>
    </revision>
    <revision>
      <id>968</id>
      <parentid>967</parentid>
      <timestamp>2024-10-14T13:46:58Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>967</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="85" sha1="hv6nnmgj7wnje582l71da9fryp00smk" xml:space="preserve">UJoe Sibanyoni ungusomarhwebo no mphathi omkhulu matekisi, ohlala eKwaggafontein A.

</text>
      <sha1>hv6nnmgj7wnje582l71da9fryp00smk</sha1>
    </revision>
    <revision>
      <id>2987</id>
      <parentid>968</parentid>
      <timestamp>2025-06-06T20:12:30Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>yngtbrvfdc</comment>
      <origin>2987</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="170" sha1="3luzwy8q039kwk4lwqtc25k33beu06m" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.''' UJoe Sibanyoni ungusomarhwebo no mphathi omkhulu matekisi, ohlala eKwaggafontein A.</text>
      <sha1>3luzwy8q039kwk4lwqtc25k33beu06m</sha1>
    </revision>
    <revision>
      <id>3073</id>
      <parentid>2987</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Jon Harald Søby|Jon Harald Søby]]</comment>
      <origin>967</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="85" sha1="hv6nnmgj7wnje582l71da9fryp00smk" xml:space="preserve">UJoe Sibanyoni ungusomarhwebo no mphathi omkhulu matekisi, ohlala eKwaggafontein A.

</text>
      <sha1>hv6nnmgj7wnje582l71da9fryp00smk</sha1>
    </revision>
  </page>
  <page>
    <title>Johannesburg</title>
    <ns>0</ns>
    <id>205</id>
    <revision>
      <id>969</id>
      <timestamp>2022-09-14T10:57:19Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;IJohannesburg idolobhakazi lase Sewula Afrika.  &quot;</comment>
      <origin>969</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="48" sha1="gvuuyc3hpjfft3na095l603w900dl00" xml:space="preserve">IJohannesburg idolobhakazi lase Sewula Afrika.

</text>
      <sha1>gvuuyc3hpjfft3na095l603w900dl00</sha1>
    </revision>
    <revision>
      <id>970</id>
      <parentid>969</parentid>
      <timestamp>2022-09-14T10:57:57Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>970</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="54" sha1="07vglno90966hbedti6ebw0qyqf5pfo" xml:space="preserve">I'''Johannesburg''' idolobhakazi lase Sewula Afrika.

</text>
      <sha1>07vglno90966hbedti6ebw0qyqf5pfo</sha1>
    </revision>
    <revision>
      <id>971</id>
      <parentid>970</parentid>
      <timestamp>2024-03-08T10:10:35Z</timestamp>
      <contributor>
        <username>incubator&gt;CdTshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>971</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="198" sha1="e3v8yvo7x6nkce6touapqjasz46kdwi" xml:space="preserve">I'''Johannesburg''' idolobhakazi lase Sewula Afrika.

ku lapho abobaba bemizi eminengi baphelela khona baye ukuyosebenzela abantwana babo

kodwana abanye baqhina baakha imizi yabo eminye yesibili.

</text>
      <sha1>e3v8yvo7x6nkce6touapqjasz46kdwi</sha1>
    </revision>
    <revision>
      <id>972</id>
      <parentid>971</parentid>
      <timestamp>2024-03-08T10:12:59Z</timestamp>
      <contributor>
        <username>incubator&gt;CdTshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>972</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="305" sha1="qkha3o4rcnyjbivpb6p2mmb1vmrg6sr" xml:space="preserve">I'''Johannesburg''' idolobhakazi lase Sewula Afrika.

i dolobha eliyintantokazi kuwo woke umuntu, ngisho nabafundi babhudanga ukuya khona ukuyo funa umsebenzi.

ku lapho abobaba bemizi eminengi baphelela khona baye ukuyosebenzela abantwana babo

kodwana abanye baqhina baakha imizi yabo eminye yesibili.

</text>
      <sha1>qkha3o4rcnyjbivpb6p2mmb1vmrg6sr</sha1>
    </revision>
    <revision>
      <id>973</id>
      <parentid>972</parentid>
      <timestamp>2024-03-08T10:18:52Z</timestamp>
      <contributor>
        <username>incubator&gt;CdTshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>973</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="312" sha1="c6euvixmkm5mrhjetbfktv091niknny" xml:space="preserve">I'''Johannesburg''' idolobhakazi lase Sewula Afrika.

I '''dolobha''' eliyintantokazi kuwo woke umuntu, ngisho nabafundi babhudanga ukuya khona ukuyo funa umsebenzi.

Kulapho abobaba bemizi eminengi baphelela khona baye ukuyosebenzela abantwana babo

kodwana abanye baqhina baakha imizi yabo eminye yesibili.



</text>
      <sha1>c6euvixmkm5mrhjetbfktv091niknny</sha1>
    </revision>
    <revision>
      <id>974</id>
      <parentid>973</parentid>
      <timestamp>2024-03-08T10:19:59Z</timestamp>
      <contributor>
        <username>incubator&gt;CdTshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>974</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="332" sha1="7d2pv0mfkhpos4s4w7winntlvaaphdl" xml:space="preserve">I'''Johannesburg''' idolobhakazi lase Sewula Afrika.

I '''dolobha''' eliyintantokazi kuwo woke umuntu, ngisho nabafundi babhudanga ukuya khona ukuyo funa umsebenzi.

Kulapho abobaba bemizi eminengi baphelela khona baye ukuyosebenzela abantwana babo

kodwana abanye baqhina baakha imizi yabo eminye yesibili engaziwako emakhaya.



</text>
      <sha1>7d2pv0mfkhpos4s4w7winntlvaaphdl</sha1>
    </revision>
    <revision>
      <id>975</id>
      <parentid>974</parentid>
      <timestamp>2024-03-09T07:45:06Z</timestamp>
      <contributor>
        <ip>196.21.175.1</ip>
      </contributor>
      <comment>linked to other page</comment>
      <origin>975</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="351" sha1="2eysel152ghh9cia54zt71eyz3zyexr" xml:space="preserve">I'''Johannesburg''' idolobhakazi lase [[Isewula Afrika|Sewula Afrika]].

I '''dolobha''' eliyintantokazi kuwo woke umuntu, ngisho nabafundi babhudanga ukuya khona ukuyo funa umsebenzi.

Kulapho abobaba bemizi eminengi baphelela khona baye ukuyosebenzela abantwana babo

kodwana abanye baqhina baakha imizi yabo eminye yesibili engaziwako emakhaya.



</text>
      <sha1>2eysel152ghh9cia54zt71eyz3zyexr</sha1>
    </revision>
    <revision>
      <id>976</id>
      <parentid>975</parentid>
      <timestamp>2024-03-09T08:19:18Z</timestamp>
      <contributor>
        <username>incubator&gt;LindiweSiba</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>976</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="406" sha1="3pawf7fpti3w3imtouqzr1717k6601g" xml:space="preserve">[[Isimumathi:Johannesburg CBD.jpg|thumb|Johannesburg]]
I'''Johannesburg''' idolobhakazi lase [[Isewula Afrika|Sewula Afrika]].

I '''dolobha''' eliyintantokazi kuwo woke umuntu, ngisho nabafundi babhudanga ukuya khona ukuyo funa umsebenzi.

Kulapho abobaba bemizi eminengi baphelela khona baye ukuyosebenzela abantwana babo

kodwana abanye baqhina baakha imizi yabo eminye yesibili engaziwako emakhaya.



</text>
      <sha1>3pawf7fpti3w3imtouqzr1717k6601g</sha1>
    </revision>
    <revision>
      <id>977</id>
      <parentid>976</parentid>
      <timestamp>2024-10-14T13:46:58Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>8 revisions imported</comment>
      <origin>976</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="406" sha1="3pawf7fpti3w3imtouqzr1717k6601g" xml:space="preserve">[[Isimumathi:Johannesburg CBD.jpg|thumb|Johannesburg]]
I'''Johannesburg''' idolobhakazi lase [[Isewula Afrika|Sewula Afrika]].

I '''dolobha''' eliyintantokazi kuwo woke umuntu, ngisho nabafundi babhudanga ukuya khona ukuyo funa umsebenzi.

Kulapho abobaba bemizi eminengi baphelela khona baye ukuyosebenzela abantwana babo

kodwana abanye baqhina baakha imizi yabo eminye yesibili engaziwako emakhaya.



</text>
      <sha1>3pawf7fpti3w3imtouqzr1717k6601g</sha1>
    </revision>
    <revision>
      <id>1771</id>
      <parentid>977</parentid>
      <timestamp>2024-10-30T08:09:05Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1771</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="431" sha1="ivg1wa0vetlwl920vumste5tjxoasmt" xml:space="preserve">[[Isimumathi:Johannesburg CBD.jpg|thumb|Johannesburg]]
I'''Johannesburg''' idolobhakazi lase [[Isewula Afrika|Sewula Afrika]].

I '''dolobha''' eliyintantokazi kuwo woke umuntu, ngisho nabafundi babhudanga ukuya khona ukuyo funa umsebenzi.

Kulapho abobaba bemizi eminengi baphelela khona baye ukuyosebenzela abantwana babo

kodwana abanye baqhina baakha imizi yabo eminye yesibili engaziwako emakhaya.

[[Category:iSewula Afrika]]</text>
      <sha1>ivg1wa0vetlwl920vumste5tjxoasmt</sha1>
    </revision>
    <revision>
      <id>2103</id>
      <parentid>1771</parentid>
      <timestamp>2024-11-25T09:48:28Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>Mkhakha</comment>
      <origin>2103</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="430" sha1="6drtwqidbyvbn4bbsh7p5g2xbsu0wsy" xml:space="preserve">[[Isimumathi:Johannesburg CBD.jpg|thumb|Johannesburg]]
I'''Johannesburg''' idolobhakazi lase [[Isewula Afrika|Sewula Afrika]].

I '''dolobha''' eliyintantokazi kuwo woke umuntu, ngisho nabafundi babhudanga ukuya khona ukuyo funa umsebenzi.

Kulapho abobaba bemizi eminengi baphelela khona baye ukuyosebenzela abantwana babo

kodwana abanye baqhina baakha imizi yabo eminye yesibili engaziwako emakhaya.

[[Mkhakha:iSewula Afrika]]</text>
      <sha1>6drtwqidbyvbn4bbsh7p5g2xbsu0wsy</sha1>
    </revision>
    <revision>
      <id>2350</id>
      <parentid>2103</parentid>
      <timestamp>2025-01-17T11:04:09Z</timestamp>
      <contributor>
        <ip>85.192.95.241</ip>
      </contributor>
      <comment>maybe</comment>
      <origin>2350</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="596" sha1="cfrhpfsbty1rkd427q62gue5l3db283" xml:space="preserve">[[Isimumathi:Johannesburg CBD.jpg|thumb|Johannesburg]]
I'''Johannesburg''' idolobhakazi lase [[Isewula Afrika|Sewula Afrika]].

I '''dolobha''' eliyintantokazi kuwo woke umuntu, ngisho nabafundi babhudanga ukuya khona ukuyo funa umsebenzi.

Kulapho abobaba bemizi eminengi baphelela khona baye ukuyosebenzela abantwana babo

kodwana abanye baqhina baakha imizi yabo eminye yesibili engaziwako emakhaya.

i want to get a BIG, HUUUGE  dick I want that dick inside mah mouth now plz plz help&lt;ref&gt;jei&lt;/ref&gt;



mmmmmmmmmmmmmmmmmmmhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh cum

plz

[[Mkhakha:iSewula Afrika]]</text>
      <sha1>cfrhpfsbty1rkd427q62gue5l3db283</sha1>
    </revision>
    <revision>
      <id>2351</id>
      <parentid>2350</parentid>
      <timestamp>2025-01-17T11:05:34Z</timestamp>
      <contributor>
        <username>Elton</username>
        <id>323</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/85.192.95.241|85.192.95.241]] ([[User talk:85.192.95.241|talk]]) to last revision by [[User:Simakahle Moselekatse|Simakahle Moselekatse]]</comment>
      <origin>2103</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="430" sha1="6drtwqidbyvbn4bbsh7p5g2xbsu0wsy" xml:space="preserve">[[Isimumathi:Johannesburg CBD.jpg|thumb|Johannesburg]]
I'''Johannesburg''' idolobhakazi lase [[Isewula Afrika|Sewula Afrika]].

I '''dolobha''' eliyintantokazi kuwo woke umuntu, ngisho nabafundi babhudanga ukuya khona ukuyo funa umsebenzi.

Kulapho abobaba bemizi eminengi baphelela khona baye ukuyosebenzela abantwana babo

kodwana abanye baqhina baakha imizi yabo eminye yesibili engaziwako emakhaya.

[[Mkhakha:iSewula Afrika]]</text>
      <sha1>6drtwqidbyvbn4bbsh7p5g2xbsu0wsy</sha1>
    </revision>
    <revision>
      <id>2894</id>
      <parentid>2351</parentid>
      <timestamp>2025-06-06T15:27:52Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <origin>2894</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="378" sha1="3mw1qpb25sovh45d7fmbywf1x3364ej" xml:space="preserve">[[Isimumathi:Johannesburg CBD.jpg|thumb|Johannesburg]]
Johannesburg is the capital city of South Africa. It is a city that many people are drawn to, even students struggle to go there in search of work. That is where many families go to work for their children, but others are stuck building their homes elsewhere far away from their original places.

[[Mkhakha:iSewula Afrika]]</text>
      <sha1>3mw1qpb25sovh45d7fmbywf1x3364ej</sha1>
    </revision>
    <revision>
      <id>2895</id>
      <parentid>2894</parentid>
      <timestamp>2025-06-06T15:28:13Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <origin>2895</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="400" sha1="l5x9lv4ubzqn0j0p11gdtgpd6636vdi" xml:space="preserve">[[Isimumathi:Johannesburg CBD.jpg|thumb|Johannesburg]]
[[A Minecraft Movie|Johannesburg is the capital city of South Africa. It is a city that many people are drawn to, even students struggle to go there in search of work. That is where many families go to work for their children, but others are stuck building their homes elsewhere far away from their original places.]]

[[Mkhakha:iSewula Afrika]]</text>
      <sha1>l5x9lv4ubzqn0j0p11gdtgpd6636vdi</sha1>
    </revision>
    <revision>
      <id>3131</id>
      <parentid>2895</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edits by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Elton|Elton]]</comment>
      <origin>2103</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="430" sha1="6drtwqidbyvbn4bbsh7p5g2xbsu0wsy" xml:space="preserve">[[Isimumathi:Johannesburg CBD.jpg|thumb|Johannesburg]]
I'''Johannesburg''' idolobhakazi lase [[Isewula Afrika|Sewula Afrika]].

I '''dolobha''' eliyintantokazi kuwo woke umuntu, ngisho nabafundi babhudanga ukuya khona ukuyo funa umsebenzi.

Kulapho abobaba bemizi eminengi baphelela khona baye ukuyosebenzela abantwana babo

kodwana abanye baqhina baakha imizi yabo eminye yesibili engaziwako emakhaya.

[[Mkhakha:iSewula Afrika]]</text>
      <sha1>6drtwqidbyvbn4bbsh7p5g2xbsu0wsy</sha1>
    </revision>
  </page>
  <page>
    <title>Kgalema Motlante</title>
    <ns>0</ns>
    <id>206</id>
    <revision>
      <id>978</id>
      <timestamp>2024-03-07T23:26:03Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;uKgalema Montlane ungusopolitika kanye nomongameli wangaphambilini we Sowula Afrika.&quot;</comment>
      <origin>978</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="84" sha1="1j4h1wuh4ahp1lvyddfdc3u0v5yspv7" xml:space="preserve">uKgalema Montlane ungusopolitika kanye nomongameli wangaphambilini we Sowula Afrika.</text>
      <sha1>1j4h1wuh4ahp1lvyddfdc3u0v5yspv7</sha1>
    </revision>
    <revision>
      <id>979</id>
      <parentid>978</parentid>
      <timestamp>2024-03-07T23:29:09Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Adding interwiki links to [[d:Q152327]]</comment>
      <origin>979</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="107" sha1="lnws3s3lmf8fmqpxbx2mltl68pqgake" xml:space="preserve">uKgalema Montlane ungusopolitika kanye nomongameli wangaphambilini we Sowula Afrika.

{{INTERWIKI|Q152327}}</text>
      <sha1>lnws3s3lmf8fmqpxbx2mltl68pqgake</sha1>
    </revision>
    <revision>
      <id>980</id>
      <parentid>979</parentid>
      <timestamp>2024-03-08T09:58:30Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>980</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="113" sha1="88z75pwfe1gv4l5b5o1uhoded04i4sn" xml:space="preserve">'''uKgalema Montlane''' ungusopolitika kanye nomongameli wangaphambilini we Sowula Afrika.

{{INTERWIKI|Q152327}}</text>
      <sha1>88z75pwfe1gv4l5b5o1uhoded04i4sn</sha1>
    </revision>
    <revision>
      <id>981</id>
      <parentid>980</parentid>
      <timestamp>2024-03-08T10:10:39Z</timestamp>
      <contributor>
        <username>incubator&gt;Simphiwe22</username>
        <id>0</id>
      </contributor>
      <comment>Fixed typo</comment>
      <origin>981</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="185" sha1="el90pa4p5pmtpkvyno2sonabv0zrh1e" xml:space="preserve">'''uKgalema Montlane''' ungusopolitika kanye nomongameli wangaphambilini we Sowula Afrika wabelethwa e Mpumalanga endaweni yange Siyabuswa . Wabelethwa ngomhlaka 20 ku sihlabantangana .</text>
      <sha1>el90pa4p5pmtpkvyno2sonabv0zrh1e</sha1>
    </revision>
    <revision>
      <id>982</id>
      <parentid>981</parentid>
      <timestamp>2024-03-08T10:36:57Z</timestamp>
      <contributor>
        <username>incubator&gt;Leratonathasher369</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>i edited the history</comment>
      <origin>982</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="479" sha1="hp4kx11qfcia07lsr6mhg8s20skxlj1" xml:space="preserve">'''uKgalema Petrus Motlanthe''' wabelethwa mhla amalanga ali-18 kuVelabahlinze ngomhlaka ka-1949. Waba nguMongameli wesithathu weSewula Africa kusukela ngomnyaka ka-2008 kuKhukhulamungu mhla amalanga ali 25, ukuya ngomnyaka ka-2009 mhla amalanga ali-9 kuMrhayili. Waba ngusekela  Mongameli ngaphasi koMongameli wangaphambilini uJacob Zuma, kusukela ngomnyaka ka-2009 kuMrhayini mhla amalanga ali-9, ukuya ngomnyaka ka-26 kuMrhayili mhla amalanga ali-26. 

{{INTERWIKI|Q152327}}

</text>
      <sha1>hp4kx11qfcia07lsr6mhg8s20skxlj1</sha1>
    </revision>
    <revision>
      <id>983</id>
      <parentid>982</parentid>
      <timestamp>2024-03-09T08:01:11Z</timestamp>
      <contributor>
        <username>incubator&gt;Madubandlela</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>983</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="513" sha1="32y4xsrpm74oesl9wgilf61bikp0ajs" xml:space="preserve">'''uKgalema Petrus Motlanthe''' wabelethwa mhla amalanga ali-18 kuVelabahlinze ngomhlaka ka-1949. Waba nguMongameli wesithathu weSewula Africa kusukela ngomnyaka ka-2008 kuKhukhulamungu mhla amalanga ali 25, ukuya ngomnyaka ka-2009 mhla amalanga ali-9 kuMrhayili. Waba ngusekela  Mongameli ngaphasi koMongameli wangaphambilini uJacob Zuma, kusukela ngomnyaka ka-2009 kuMrhayini mhla amalanga ali-9, ukuya ngomnyaka ka-26 kuMrhayili mhla amalanga ali-26. 

{{INTERWIKI|Q152327}}Ukgalema akasabonwa kubomabonakude 
</text>
      <sha1>32y4xsrpm74oesl9wgilf61bikp0ajs</sha1>
    </revision>
    <revision>
      <id>984</id>
      <parentid>983</parentid>
      <timestamp>2024-03-09T08:02:52Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>984</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="616" sha1="6oemruq6jgi2994gta542apyf181nhf" xml:space="preserve">'''uKgalema Petrus Motlanthe''' wabelethwa mhla amalanga ali-18 kuVelabahlinze ngomhlaka ka-1949. Waba nguMongameli wesithathu weSewula Africa kusukela ngomnyaka ka-2008 kuKhukhulamungu mhla amalanga ali 25, ukuya ngomnyaka ka-2009 mhla amalanga ali-9 kuMrhayili. Waba ngusekela  Mongameli ngaphasi koMongameli wangaphambilini uJacob Zuma, kusukela ngomnyaka ka-2009 kuMrhayini mhla amalanga ali-9, ukuya ngomnyaka ka-26 kuMrhayili mhla amalanga ali-26. [[Isimumathi:Kgalema Motlanthe at the 12th AU Summit (cropped).jpg|thumb|left|200px|Kgalema Montlante]]

{{INTERWIKI|Q152327}}Ukgalema akasabonwa kubomabonakude 
</text>
      <sha1>6oemruq6jgi2994gta542apyf181nhf</sha1>
    </revision>
    <revision>
      <id>985</id>
      <parentid>984</parentid>
      <timestamp>2024-03-09T08:03:23Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>985</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="617" sha1="b5ukoqfo8vebsge6g9q4ws8ovr37w1g" xml:space="preserve">[[Isimumathi:Kgalema Motlanthe at the 12th AU Summit (cropped).jpg|thumb|left|200px|Kgalema Montlante]]
'''uKgalema Petrus Motlanthe''' wabelethwa mhla amalanga ali-18 kuVelabahlinze ngomhlaka ka-1949. Waba nguMongameli wesithathu weSewula Africa kusukela ngomnyaka ka-2008 kuKhukhulamungu mhla amalanga ali 25, ukuya ngomnyaka ka-2009 mhla amalanga ali-9 kuMrhayili. Waba ngusekela  Mongameli ngaphasi koMongameli wangaphambilini uJacob Zuma, kusukela ngomnyaka ka-2009 kuMrhayini mhla amalanga ali-9, ukuya ngomnyaka ka-26 kuMrhayili mhla amalanga ali-26. 

{{INTERWIKI|Q152327}}Ukgalema akasabonwa kubomabonakude 
</text>
      <sha1>b5ukoqfo8vebsge6g9q4ws8ovr37w1g</sha1>
    </revision>
    <revision>
      <id>986</id>
      <parentid>985</parentid>
      <timestamp>2024-03-09T08:04:40Z</timestamp>
      <contributor>
        <username>incubator&gt;Madubandlela</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>986</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="615" sha1="50vyedijgc1v2d36f75kxo1zsbqttm0" xml:space="preserve">[[Isimumathi:Kgalema Motlanthe at the 12th AU Summit (cropped).jpg|thumb|left|200px|Kgalema Montlante]]
'''uKgalema Petrus Motlanthe''' wabelethwa mhla amalanga ali-18 kuVelabahlinze ngomhlaka ka-1949. Waba nguMongameli wesithathu weSewula Africa kusukela ngomnyaka ka-2008 kuKhukhulamungu mhla amalanga ali 25, ukuya ngomnyaka ka-2009 mhla amalanga ali-9 kuMrhayili. Waba ngusekela  Mongameli ngaphasi koMongameli wangaphambilini uJacob Zuma, kusukela ngomnyaka ka-2009 kuMrhayini mhla amalanga ali-9, ukuya ngomnyaka ka-26 kuMrhayili mhla amalanga ali-26. 

{{INTERWIKI|Q152327}}Ukgalema akasabonwa kubomabonakude</text>
      <sha1>50vyedijgc1v2d36f75kxo1zsbqttm0</sha1>
    </revision>
    <revision>
      <id>987</id>
      <parentid>986</parentid>
      <timestamp>2024-10-14T13:46:59Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>9 revisions imported</comment>
      <origin>986</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="615" sha1="50vyedijgc1v2d36f75kxo1zsbqttm0" xml:space="preserve">[[Isimumathi:Kgalema Motlanthe at the 12th AU Summit (cropped).jpg|thumb|left|200px|Kgalema Montlante]]
'''uKgalema Petrus Motlanthe''' wabelethwa mhla amalanga ali-18 kuVelabahlinze ngomhlaka ka-1949. Waba nguMongameli wesithathu weSewula Africa kusukela ngomnyaka ka-2008 kuKhukhulamungu mhla amalanga ali 25, ukuya ngomnyaka ka-2009 mhla amalanga ali-9 kuMrhayili. Waba ngusekela  Mongameli ngaphasi koMongameli wangaphambilini uJacob Zuma, kusukela ngomnyaka ka-2009 kuMrhayini mhla amalanga ali-9, ukuya ngomnyaka ka-26 kuMrhayili mhla amalanga ali-26. 

{{INTERWIKI|Q152327}}Ukgalema akasabonwa kubomabonakude</text>
      <sha1>50vyedijgc1v2d36f75kxo1zsbqttm0</sha1>
    </revision>
    <revision>
      <id>1673</id>
      <parentid>987</parentid>
      <timestamp>2024-10-16T09:50:00Z</timestamp>
      <contributor>
        <username>JhsBot</username>
        <id>34</id>
      </contributor>
      <minor />
      <comment>bot: Removing interwiki template; the page is now connected to [[d:Q152327]]</comment>
      <origin>1673</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="593" sha1="du6gvn3dwsxfogvqmho00ckr69jjriv" xml:space="preserve">[[Isimumathi:Kgalema Motlanthe at the 12th AU Summit (cropped).jpg|thumb|left|200px|Kgalema Montlante]]
'''uKgalema Petrus Motlanthe''' wabelethwa mhla amalanga ali-18 kuVelabahlinze ngomhlaka ka-1949. Waba nguMongameli wesithathu weSewula Africa kusukela ngomnyaka ka-2008 kuKhukhulamungu mhla amalanga ali 25, ukuya ngomnyaka ka-2009 mhla amalanga ali-9 kuMrhayili. Waba ngusekela  Mongameli ngaphasi koMongameli wangaphambilini uJacob Zuma, kusukela ngomnyaka ka-2009 kuMrhayini mhla amalanga ali-9, ukuya ngomnyaka ka-26 kuMrhayili mhla amalanga ali-26. 
Ukgalema akasabonwa kubomabonakude</text>
      <sha1>du6gvn3dwsxfogvqmho00ckr69jjriv</sha1>
    </revision>
    <revision>
      <id>1884</id>
      <parentid>1673</parentid>
      <timestamp>2024-11-12T18:58:13Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>Kgalema Montlante ka 2009</comment>
      <origin>1884</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="601" sha1="qb33yso9g3bjvm7264cz89rv4j291zu" xml:space="preserve">[[Isimumathi:Kgalema Motlanthe at the 12th AU Summit (cropped).jpg|thumb|left|200px|Kgalema Montlante ka 2009]]
'''uKgalema Petrus Motlanthe''' wabelethwa mhla amalanga ali-18 kuVelabahlinze ngomhlaka ka-1949. Waba nguMongameli wesithathu weSewula Africa kusukela ngomnyaka ka-2008 kuKhukhulamungu mhla amalanga ali 25, ukuya ngomnyaka ka-2009 mhla amalanga ali-9 kuMrhayili. Waba ngusekela  Mongameli ngaphasi koMongameli wangaphambilini uJacob Zuma, kusukela ngomnyaka ka-2009 kuMrhayini mhla amalanga ali-9, ukuya ngomnyaka ka-26 kuMrhayili mhla amalanga ali-26. 
Ukgalema akasabonwa kubomabonakude</text>
      <sha1>qb33yso9g3bjvm7264cz89rv4j291zu</sha1>
    </revision>
    <revision>
      <id>2154</id>
      <parentid>1884</parentid>
      <timestamp>2024-11-27T05:08:09Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <comment>Ukgalema akasabonwa kubomabonakude.</comment>
      <origin>2154</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="603" sha1="n980spmi00jc7w9ajsifln1pay7bxao" xml:space="preserve">[[Isimumathi:Kgalema Motlanthe at the 12th AU Summit (cropped).jpg|thumb|left|200px|Kgalema Montlante ka 2009]]
'''uKgalema Petrus Motlanthe''' wabelethwa mhla amalanga ali-18 kuVelabahlinze ngomhlaka ka-1949. Waba nguMongameli wesithathu weSewula Africa kusukela ngomnyaka ka-2008 kuKhukhulamungu mhla amalanga ali 25, ukuya ngomnyaka ka-2009 mhla amalanga ali-9 kuMrhayili. Waba ngusekela  Mongameli ngaphasi koMongameli wangaphambilini uJacob Zuma, kusukela ngomnyaka ka-2009 kuMrhayini mhla amalanga ali-9, ukuya ngomnyaka ka-26 kuMrhayili mhla amalanga ali-26.
 
Ukgalema akasabonwa kubomabonakude.</text>
      <sha1>n980spmi00jc7w9ajsifln1pay7bxao</sha1>
    </revision>
    <revision>
      <id>2179</id>
      <parentid>2154</parentid>
      <timestamp>2024-11-28T09:11:04Z</timestamp>
      <contributor>
        <ip>104.255.173.142</ip>
      </contributor>
      <comment>uMontlante ngomnyaka ka-2009</comment>
      <origin>2179</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="595" sha1="2srshvs12piul0zud7xb9cs8ws7kub8" xml:space="preserve">[[Isimumathi:Kgalema Motlanthe at the 12th AU Summit (cropped).jpg|thumb|uMontlante ngomnyaka ka-2009]]
'''uKgalema Petrus Motlanthe''' wabelethwa mhla amalanga ali-18 kuVelabahlinze ngomhlaka ka-1949. Waba nguMongameli wesithathu weSewula Africa kusukela ngomnyaka ka-2008 kuKhukhulamungu mhla amalanga ali 25, ukuya ngomnyaka ka-2009 mhla amalanga ali-9 kuMrhayili. Waba ngusekela  Mongameli ngaphasi koMongameli wangaphambilini uJacob Zuma, kusukela ngomnyaka ka-2009 kuMrhayini mhla amalanga ali-9, ukuya ngomnyaka ka-26 kuMrhayili mhla amalanga ali-26.
 
Ukgalema akasabonwa kubomabonakude.</text>
      <sha1>2srshvs12piul0zud7xb9cs8ws7kub8</sha1>
    </revision>
    <revision>
      <id>2966</id>
      <parentid>2179</parentid>
      <timestamp>2025-06-06T19:56:45Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>This page is sponsored by Raid: Shadow Legends, the sponsor of today's page.</comment>
      <origin>2966</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="676" sha1="boovdazn1pydltygyql14mk1llnisi7" xml:space="preserve">[[Isimumathi:Kgalema Motlanthe at the 12th AU Summit (cropped).jpg|thumb|uMontlante ngomnyaka ka-2009]]
'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. uKgalema Petrus Motlanthe''' wabelethwa mhla amalanga ali-18 kuVelabahlinze ngomhlaka ka-1949. Waba nguMongameli wesithathu weSewula Africa kusukela ngomnyaka ka-2008 kuKhukhulamungu mhla amalanga ali 25, ukuya ngomnyaka ka-2009 mhla amalanga ali-9 kuMrhayili. Waba ngusekela  Mongameli ngaphasi koMongameli wangaphambilini uJacob Zuma, kusukela ngomnyaka ka-2009 kuMrhayini mhla amalanga ali-9, ukuya ngomnyaka ka-26 kuMrhayili mhla amalanga ali-26.
 
Ukgalema akasabonwa kubomabonakude.</text>
      <sha1>boovdazn1pydltygyql14mk1llnisi7</sha1>
    </revision>
    <revision>
      <id>3090</id>
      <parentid>2966</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:104.255.173.142|104.255.173.142]]</comment>
      <origin>2179</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="595" sha1="2srshvs12piul0zud7xb9cs8ws7kub8" xml:space="preserve">[[Isimumathi:Kgalema Motlanthe at the 12th AU Summit (cropped).jpg|thumb|uMontlante ngomnyaka ka-2009]]
'''uKgalema Petrus Motlanthe''' wabelethwa mhla amalanga ali-18 kuVelabahlinze ngomhlaka ka-1949. Waba nguMongameli wesithathu weSewula Africa kusukela ngomnyaka ka-2008 kuKhukhulamungu mhla amalanga ali 25, ukuya ngomnyaka ka-2009 mhla amalanga ali-9 kuMrhayili. Waba ngusekela  Mongameli ngaphasi koMongameli wangaphambilini uJacob Zuma, kusukela ngomnyaka ka-2009 kuMrhayini mhla amalanga ali-9, ukuya ngomnyaka ka-26 kuMrhayili mhla amalanga ali-26.
 
Ukgalema akasabonwa kubomabonakude.</text>
      <sha1>2srshvs12piul0zud7xb9cs8ws7kub8</sha1>
    </revision>
    <revision>
      <id>3169</id>
      <parentid>3090</parentid>
      <timestamp>2025-06-21T18:44:46Z</timestamp>
      <contributor>
        <ip>85.97.84.231</ip>
      </contributor>
      <origin>3169</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="706" sha1="mdazcpg49fat3b08b7dnaun4eftdkru" xml:space="preserve">[[File:Common chimpanzee (Pan troglodytes schweinfurthii) feeding.jpg|thumb|Omar al-Bashir is a chimpanzee.]]

[[Isimumathi:Kgalema Motlanthe at the 12th AU Summit (cropped).jpg|thumb|uMontlante ngomnyaka ka-2009]]
'''uKgalema Petrus Motlanthe''' wabelethwa mhla amalanga ali-18 kuVelabahlinze ngomhlaka ka-1949. Waba nguMongameli wesithathu weSewula Africa kusukela ngomnyaka ka-2008 kuKhukhulamungu mhla amalanga ali 25, ukuya ngomnyaka ka-2009 mhla amalanga ali-9 kuMrhayili. Waba ngusekela  Mongameli ngaphasi koMongameli wangaphambilini uJacob Zuma, kusukela ngomnyaka ka-2009 kuMrhayini mhla amalanga ali-9, ukuya ngomnyaka ka-26 kuMrhayili mhla amalanga ali-26.
 
Ukgalema akasabonwa kubomabonakude.</text>
      <sha1>mdazcpg49fat3b08b7dnaun4eftdkru</sha1>
    </revision>
    <revision>
      <id>3293</id>
      <parentid>3169</parentid>
      <timestamp>2025-07-02T20:43:23Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Undo revision [[Special:Diff/3169|3169]] by [[Special:Contributions/85.97.84.231|85.97.84.231]] ([[User talk:85.97.84.231|talk]])</comment>
      <origin>3293</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="595" sha1="2srshvs12piul0zud7xb9cs8ws7kub8" xml:space="preserve">[[Isimumathi:Kgalema Motlanthe at the 12th AU Summit (cropped).jpg|thumb|uMontlante ngomnyaka ka-2009]]
'''uKgalema Petrus Motlanthe''' wabelethwa mhla amalanga ali-18 kuVelabahlinze ngomhlaka ka-1949. Waba nguMongameli wesithathu weSewula Africa kusukela ngomnyaka ka-2008 kuKhukhulamungu mhla amalanga ali 25, ukuya ngomnyaka ka-2009 mhla amalanga ali-9 kuMrhayili. Waba ngusekela  Mongameli ngaphasi koMongameli wangaphambilini uJacob Zuma, kusukela ngomnyaka ka-2009 kuMrhayini mhla amalanga ali-9, ukuya ngomnyaka ka-26 kuMrhayili mhla amalanga ali-26.
 
Ukgalema akasabonwa kubomabonakude.</text>
      <sha1>2srshvs12piul0zud7xb9cs8ws7kub8</sha1>
    </revision>
  </page>
  <page>
    <title>Komkhulu</title>
    <ns>0</ns>
    <id>208</id>
    <revision>
      <id>990</id>
      <timestamp>2024-03-09T10:13:19Z</timestamp>
      <contributor>
        <username>incubator&gt;Thandeka179</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;  &quot;</comment>
      <origin>990</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2" sha1="d9djsoiy1tv4u1g6270onnoihttadwu" xml:space="preserve">

</text>
      <sha1>d9djsoiy1tv4u1g6270onnoihttadwu</sha1>
    </revision>
    <revision>
      <id>991</id>
      <parentid>990</parentid>
      <timestamp>2024-03-09T10:17:11Z</timestamp>
      <contributor>
        <username>incubator&gt;Thandeka179</username>
        <id>0</id>
      </contributor>
      <comment>Added information</comment>
      <origin>991</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="112" sha1="r6ixge9nwotj8oc4lc0haokrxq9xpzp" xml:space="preserve">

Komkhulu  mdlalo wokthoma wamandebe owadumama khulu bewabonakala kumabonakude .Wathoma ukubonakala ngomhlaka 8</text>
      <sha1>r6ixge9nwotj8oc4lc0haokrxq9xpzp</sha1>
    </revision>
    <revision>
      <id>992</id>
      <parentid>991</parentid>
      <timestamp>2024-03-09T10:49:47Z</timestamp>
      <contributor>
        <username>incubator&gt;Thandeka179</username>
        <id>0</id>
      </contributor>
      <comment>Created the page</comment>
      <origin>992</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1008" sha1="ar940yy9tfrog2o2gyqy1gd8i3hi5x5" xml:space="preserve">

'''Komkhulu'''  mdlalo wokthoma wamandebe owaduma khulu bewabonakala kumabonakude .Wathoma ukubonakala kumabona kude ngomhlaka 9 April 2023 .Udlalelwa esi fundeni se[[Mpumalanga]] endaweni ezinjenge Kosini ngako         [[Esther Mahlangu]]  ,kwamhlanga lapho kunzinze khona ama Ndebele .Kwaba mqopha mlandu khulu ngombana bekumdlalo wokthoma ozokubonakala kumabonakude begodu e tjhaneleni ekulu kangaka  u Mzansi magic (channel 161) ku DSTV.


'''&lt;big&gt;Umlando wako Mkhulu&lt;/big&gt;'''

Umdlalo lo umayelana nobukhosi bekosi u Masoso Mbonani oyokosi encani esakhulako begodu ebelethelwe emnothweni , Ipilo yekosi isengozini njengombana angarhoni ukuba nendlalifa nje ezokthatha ubkhosi bayo.

'''IMIDLALO'''

Umdlalo lo ube neemidlalo elitjhumi nantathu(13 episodes)

'''ABADLALI'''

Johannes Mandla Mnguni (Yikosi u Masoso Mbonani)

Bongi Mtsweni ngu (Sayina Mbonani)

Sipho Mbele(Hlangabeza)

James Sithole ngu Karisa

Andiswa khuzwayo ngu Nomhlekhabo 

Frieda Makoba ngu Nastokana 

Bongani Mahlangu ngu Jama</text>
      <sha1>ar940yy9tfrog2o2gyqy1gd8i3hi5x5</sha1>
    </revision>
    <revision>
      <id>993</id>
      <parentid>992</parentid>
      <timestamp>2024-03-09T10:52:05Z</timestamp>
      <contributor>
        <username>incubator&gt;Thandeka179</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>993</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1013" sha1="2rk5zb3nflcw3rbx3c7pbihngu6rux2" xml:space="preserve">

'''Komkhulu'''  mdlalo wokthoma wamandebe owaduma khulu bewabonakala kumabonakude .Wathoma ukubonakala kumabona kude ngomhlaka 9 April 2023 .Udlalelwa esi fundeni se[[Mpumalanga]] endaweni ezinjenge Kosini ngako         [[Esther Mahlangu]]  ,kwamhlanga lapho kunzinze khona ama Ndebele .Kwaba mqopha mlandu khulu ngombana bekumdlalo wokthoma ozokubonakala kumabonakude begodu e tjhaneleni ekulu kangaka  u Mzansi magic (channel 161) ku [[DSTV.]]



'''&lt;big&gt;Umlando wako Mkhulu&lt;/big&gt;'''

Umdlalo lo umayelana nobukhosi bekosi u Masoso Mbonani oyokosi encani esakhulako begodu ebelethelwe emnothweni , Ipilo yekosi isengozini njengombana angarhoni ukuba nendlalifa nje ezokthatha ubkhosi bayo.

'''IMIDLALO'''

Umdlalo lo ube neemidlalo elitjhumi nantathu(13 episodes)

'''ABADLALI'''

Johannes Mandla Mnguni (Yikosi u Masoso Mbonani)

Bongi Mtsweni ngu (Sayina Mbonani)

Sipho Mbele(Hlangabeza)

James Sithole ngu Karisa

Andiswa khuzwayo ngu Nomhlekhabo 

Frieda Makoba ngu Nastokana 

Bongani Mahlangu ngu Jama</text>
      <sha1>2rk5zb3nflcw3rbx3c7pbihngu6rux2</sha1>
    </revision>
    <revision>
      <id>994</id>
      <parentid>993</parentid>
      <timestamp>2024-03-09T11:03:29Z</timestamp>
      <contributor>
        <username>incubator&gt;Thandeka179</username>
        <id>0</id>
      </contributor>
      <comment>Added image</comment>
      <origin>994</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1062" sha1="7dpxdauyf43z4o1izsj0ukwvoq4uo9i" xml:space="preserve">

[[Isimumathi:Komkhulu.png|thumb|ndebele series]]
'''Komkhulu'''  mdlalo wokthoma wamandebe owaduma khulu bewabonakala kumabonakude .Wathoma ukubonakala kumabona kude ngomhlaka 9 April 2023 .Udlalelwa esi fundeni se[[Mpumalanga]] endaweni ezinjenge Kosini ngako         [[Esther Mahlangu]]  ,kwamhlanga lapho kunzinze khona ama Ndebele .Kwaba mqopha mlandu khulu ngombana bekumdlalo wokthoma ozokubonakala kumabonakude begodu e tjhaneleni ekulu kangaka  u Mzansi magic (channel 161) ku [[DSTV.]]



'''&lt;big&gt;Umlando wako Mkhulu&lt;/big&gt;'''

Umdlalo lo umayelana nobukhosi bekosi u Masoso Mbonani oyokosi encani esakhulako begodu ebelethelwe emnothweni , Ipilo yekosi isengozini njengombana angarhoni ukuba nendlalifa nje ezokthatha ubkhosi bayo.

'''IMIDLALO'''

Umdlalo lo ube neemidlalo elitjhumi nantathu(13 episodes)

'''ABADLALI'''

Johannes Mandla Mnguni (Yikosi u Masoso Mbonani)

Bongi Mtsweni ngu (Sayina Mbonani)

Sipho Mbele(Hlangabeza)

James Sithole ngu Karisa

Andiswa khuzwayo ngu Nomhlekhabo 

Frieda Makoba ngu Nastokana 

Bongani Mahlangu ngu Jama</text>
      <sha1>7dpxdauyf43z4o1izsj0ukwvoq4uo9i</sha1>
    </revision>
    <revision>
      <id>995</id>
      <parentid>994</parentid>
      <timestamp>2024-03-09T11:04:34Z</timestamp>
      <contributor>
        <username>incubator&gt;Thandeka179</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>995</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1127" sha1="o2lh3lmwnevt7b41vu9k12hmwwtn2zf" xml:space="preserve">

[[Isimumathi:Komkhulu.png|thumb|ndebele series]]
[[Isimumathi:Ndebele drama series.jpg|thumb|umdlalo wesndebele]]
'''Komkhulu'''  mdlalo wokthoma wamandebe owaduma khulu bewabonakala kumabonakude .Wathoma ukubonakala kumabona kude ngomhlaka 9 April 2023 .Udlalelwa esi fundeni se[[Mpumalanga]] endaweni ezinjenge Kosini ngako         [[Esther Mahlangu]]  ,kwamhlanga lapho kunzinze khona ama Ndebele .Kwaba mqopha mlandu khulu ngombana bekumdlalo wokthoma ozokubonakala kumabonakude begodu e tjhaneleni ekulu kangaka  u Mzansi magic (channel 161) ku [[DSTV.]]



'''&lt;big&gt;Umlando wako Mkhulu&lt;/big&gt;'''

Umdlalo lo umayelana nobukhosi bekosi u Masoso Mbonani oyokosi encani esakhulako begodu ebelethelwe emnothweni , Ipilo yekosi isengozini njengombana angarhoni ukuba nendlalifa nje ezokthatha ubkhosi bayo.

'''IMIDLALO'''

Umdlalo lo ube neemidlalo elitjhumi nantathu(13 episodes)

'''ABADLALI'''

Johannes Mandla Mnguni (Yikosi u Masoso Mbonani)

Bongi Mtsweni ngu (Sayina Mbonani)

Sipho Mbele(Hlangabeza)

James Sithole ngu Karisa

Andiswa khuzwayo ngu Nomhlekhabo 

Frieda Makoba ngu Nastokana 

Bongani Mahlangu ngu Jama</text>
      <sha1>o2lh3lmwnevt7b41vu9k12hmwwtn2zf</sha1>
    </revision>
    <revision>
      <id>996</id>
      <parentid>995</parentid>
      <timestamp>2024-03-09T11:18:59Z</timestamp>
      <contributor>
        <username>incubator&gt;Thandeka179</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>996</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1138" sha1="gqluv4n5j0jk9czmr7jipwpmgk2ia3o" xml:space="preserve">

[[Isimumathi:Komkhulu.png|thumb|ndebele series]]
[[Isimumathi:Ndebele drama series.jpg|thumb|umdlalo wesndebele]]
'''Komkhulu'''  mdlalo wokthoma wamandebe owaduma khulu bewabonakala kumabonakude .Wathoma ukubonakala kumabona kude ngomhlaka 9 April 2023 .Udlalelwa esi fundeni se[[Mpumalanga]] endaweni ezinjenge Kosini ngako gogo          [[Esther Mahlangu]]  ,kwamhlanga lapho kunzinze khona ama Ndebele .Kwaba mqopha mlandu khulu ngombana bekumdlalo wokthoma ozokubonakala kumabonakude begodu e tjhaneleni ekulu kangaka  u Mzansi magic (channel 161) ku [[DSTV.]]



'''&lt;big&gt;Umlando wako Mkhulu&lt;/big&gt;'''

Umdlalo lo umayelana nobukhosi bekosi u Masoso Mbonani oyokosi encani esakhulako begodu ebelethelwe emnothweni , Ipilo yekosi isengozini njengombana angarhoni ukuba nendlalifa nje ezokthatha ubkhosi bayo.

'''IMIDLALO'''

Umdlalo lo ube neemidlalo elitjhumi nantathu(13 episodes)

'''ABADLALI'''

Johannes Mandla Mnguni (Yikosi u Masoso Mbonani)

Bongi Mtsweni ngu (Sayina Mbonani)

Sipho Mbele(Hlangabeza)

[[James Sithole]] ngu Karisa

Andiswa khuzwayo ngu Nomhlekhabo 

Frieda Makoba ngu Nastokana 

Bongani Mahlangu ngu Jama.</text>
      <sha1>gqluv4n5j0jk9czmr7jipwpmgk2ia3o</sha1>
    </revision>
    <revision>
      <id>997</id>
      <parentid>996</parentid>
      <timestamp>2024-05-13T09:38:21Z</timestamp>
      <contributor>
        <ip>41.150.216.107</ip>
      </contributor>
      <comment>Rephrased the content.</comment>
      <origin>997</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1339" sha1="ojo3ht2p4xaho6p364ndyjf37u021wn" xml:space="preserve">

[[Isimumathi:Komkhulu.png|thumb|Umdlalo WamaNdebele]]
[[Isimumathi:Ndebele drama series.jpg|thumb|Umdlalo WesiNdebele ]]
'''Komkhulu''' mdlalo wokuthoma wamaNdebele owaduma khulu bewabonakala kumabonwakude. Wathoma ukubonakala kumabonwakude lokha amalanga ali-9 kusiHlabantangana ngomnyaka wee-2023. Umdlalo lo ugadangiselwe bewadlalelwa esifundeni se[[Mpumalanga|Mpumalanga,]] eendaweni ezifaka hlangana ngeKosini kwagogo u-[[Esther Mahlangu]], naKwaMhlanga esese yindawo yaKwaNdebele. Ukuthoma nokudlala komdlalo lo kwaba yinqophamlando ngombana bekumdlalo wokuthoma owawuzokubonakala kumabonwakude wesiNdebele netjhaneleni ekulu okuyi Mzansi Magic (Channel 161) eku-[[DSTV.]]

== &lt;big&gt;Umlando waKomkhulu&lt;/big&gt; ==
Umdlalo lo umayelana nobukhosi bekosi uMasoso Mbonani, oyokosi encani esakhulako begodu ebelethelwe emnothweni. Ipilo yekosi isengozini njengombana ingarhoni ukuba nendlalifa ezokuthatha ubukhosi bayo.

== Iinkundla ==
Umdlalo lo ube neenkundla ezilitjhumi nantathu (13 ''episodes'').

== Abadlali ==
Ikosi uMasoso Mbonani bekadlalwa ngu-Johannes Mandla Mnguni. 

USayina Mbonani bekadlalwa nguBongi Mtsweni.

UHlangabeza bekadlalwa nguSipho Mbele.

UKarisa bekadlalwa ngu-[[James Sithole]].

UNomhlekhabo bekadlalwa ngu-Andiswa Khuzwayo. 

UNastokana bekadlalwa ngu-Frieda Makoba. 

UJama bekadlalwa nguBongani Mahlangu.</text>
      <sha1>ojo3ht2p4xaho6p364ndyjf37u021wn</sha1>
    </revision>
    <revision>
      <id>998</id>
      <parentid>997</parentid>
      <timestamp>2024-10-14T13:46:59Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>8 revisions imported</comment>
      <origin>997</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1339" sha1="ojo3ht2p4xaho6p364ndyjf37u021wn" xml:space="preserve">

[[Isimumathi:Komkhulu.png|thumb|Umdlalo WamaNdebele]]
[[Isimumathi:Ndebele drama series.jpg|thumb|Umdlalo WesiNdebele ]]
'''Komkhulu''' mdlalo wokuthoma wamaNdebele owaduma khulu bewabonakala kumabonwakude. Wathoma ukubonakala kumabonwakude lokha amalanga ali-9 kusiHlabantangana ngomnyaka wee-2023. Umdlalo lo ugadangiselwe bewadlalelwa esifundeni se[[Mpumalanga|Mpumalanga,]] eendaweni ezifaka hlangana ngeKosini kwagogo u-[[Esther Mahlangu]], naKwaMhlanga esese yindawo yaKwaNdebele. Ukuthoma nokudlala komdlalo lo kwaba yinqophamlando ngombana bekumdlalo wokuthoma owawuzokubonakala kumabonwakude wesiNdebele netjhaneleni ekulu okuyi Mzansi Magic (Channel 161) eku-[[DSTV.]]

== &lt;big&gt;Umlando waKomkhulu&lt;/big&gt; ==
Umdlalo lo umayelana nobukhosi bekosi uMasoso Mbonani, oyokosi encani esakhulako begodu ebelethelwe emnothweni. Ipilo yekosi isengozini njengombana ingarhoni ukuba nendlalifa ezokuthatha ubukhosi bayo.

== Iinkundla ==
Umdlalo lo ube neenkundla ezilitjhumi nantathu (13 ''episodes'').

== Abadlali ==
Ikosi uMasoso Mbonani bekadlalwa ngu-Johannes Mandla Mnguni. 

USayina Mbonani bekadlalwa nguBongi Mtsweni.

UHlangabeza bekadlalwa nguSipho Mbele.

UKarisa bekadlalwa ngu-[[James Sithole]].

UNomhlekhabo bekadlalwa ngu-Andiswa Khuzwayo. 

UNastokana bekadlalwa ngu-Frieda Makoba. 

UJama bekadlalwa nguBongani Mahlangu.</text>
      <sha1>ojo3ht2p4xaho6p364ndyjf37u021wn</sha1>
    </revision>
    <revision>
      <id>5150</id>
      <parentid>998</parentid>
      <timestamp>2025-08-13T03:18:25Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>/* Umlando waKomkhulu */ Fixed grammar</comment>
      <origin>5150</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1340" sha1="odfzlmvnix62kmrbcaf8fvnrqkg5rw4" xml:space="preserve">

[[Isimumathi:Komkhulu.png|thumb|Umdlalo WamaNdebele]]
[[Isimumathi:Ndebele drama series.jpg|thumb|Umdlalo WesiNdebele ]]
'''Komkhulu''' mdlalo wokuthoma wamaNdebele owaduma khulu bewabonakala kumabonwakude. Wathoma ukubonakala kumabonwakude lokha amalanga ali-9 kusiHlabantangana ngomnyaka wee-2023. Umdlalo lo ugadangiselwe bewadlalelwa esifundeni se[[Mpumalanga|Mpumalanga,]] eendaweni ezifaka hlangana ngeKosini kwagogo u-[[Esther Mahlangu]], naKwaMhlanga esese yindawo yaKwaNdebele. Ukuthoma nokudlala komdlalo lo kwaba yinqophamlando ngombana bekumdlalo wokuthoma owawuzokubonakala kumabonwakude wesiNdebele netjhaneleni ekulu okuyi Mzansi Magic (Channel 161) eku-[[DSTV.]]

== &lt;big&gt;Umlando waKomkhulu&lt;/big&gt; ==
Umdlalo lo umayelana nobukhosi bekosi uMasoso Mbonani, oyikosi encani esakhulako begodu ebelethelwe emnothweni. Ipilo yekosi isengozini njengombana ingakghoni ukuba nendlalifa ezokuthatha ubukhosi bayo.

== Iinkundla ==
Umdlalo lo ube neenkundla ezilitjhumi nantathu (13 ''episodes'').

== Abadlali ==
Ikosi uMasoso Mbonani bekadlalwa ngu-Johannes Mandla Mnguni. 

USayina Mbonani bekadlalwa nguBongi Mtsweni.

UHlangabeza bekadlalwa nguSipho Mbele.

UKarisa bekadlalwa ngu-[[James Sithole]].

UNomhlekhabo bekadlalwa ngu-Andiswa Khuzwayo. 

UNastokana bekadlalwa ngu-Frieda Makoba. 

UJama bekadlalwa nguBongani Mahlangu.</text>
      <sha1>odfzlmvnix62kmrbcaf8fvnrqkg5rw4</sha1>
    </revision>
    <revision>
      <id>6701</id>
      <parentid>5150</parentid>
      <timestamp>2026-06-12T08:31:16Z</timestamp>
      <contributor>
        <username>MissHadassah</username>
        <id>1561</id>
      </contributor>
      <comment>linked pages</comment>
      <origin>6701</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1364" sha1="gk01rvdlewpf1r3yxh1c27ydlf1jcqq" xml:space="preserve">

[[Isimumathi:Komkhulu.png|thumb|Umdlalo WamaNdebele]]
[[Isimumathi:Ndebele drama series.jpg|thumb|Umdlalo WesiNdebele ]]
'''Komkhulu''' mdlalo wokuthoma wamaNdebele owaduma khulu bewabonakala kumabonwakude. Wathoma ukubonakala kumabonwakude lokha amalanga ali-9 kusiHlabantangana ngomnyaka wee-2023. Umdlalo lo ugadangiselwe bewadlalelwa esifundeni se[[Mpumalanga|Mpumalanga,]] eendaweni ezifaka hlangana ngeKosini kwagogo u-[[Esther Mahlangu]], na[[KwaMhlanga|KwaMhlang]]&lt;nowiki/&gt;a esese yindawo yaKwaNdebele. Ukuthoma nokudlala komdlalo lo kwaba yinqophamlando ngombana bekumdlalo wokuthoma owawuzokubonakala kumabonwakude wesiNdebele netjhaneleni ekulu okuyi Mzansi Magic (Channel 161) eku-[[DSTV.]]

== &lt;big&gt;Umlando waKomkhulu&lt;/big&gt; ==
Umdlalo lo umayelana nobukhosi bekosi uMasoso Mbonani, oyikosi encani esakhulako begodu ebelethelwe emnothweni. Ipilo yekosi isengozini njengombana ingakghoni ukuba nendlalifa ezokuthatha ubukhosi bayo.

== Iinkundla ==
Umdlalo lo ube neenkundla ezilitjhumi nantathu (13 ''episodes'').

== Abadlali ==
Ikosi uMasoso Mbonani bekadlalwa ngu-Johannes Mandla Mnguni. 

USayina Mbonani bekadlalwa nguBongi Mtsweni.

UHlangabeza bekadlalwa nguSipho Mbele.

UKarisa bekadlalwa ngu-[[James Sithole]].

UNomhlekhabo bekadlalwa ngu-Andiswa Khuzwayo. 

UNastokana bekadlalwa ngu-Frieda Makoba. 

UJama bekadlalwa nguBongani Mahlangu.</text>
      <sha1>gk01rvdlewpf1r3yxh1c27ydlf1jcqq</sha1>
    </revision>
  </page>
  <page>
    <title>KwaMabhoko</title>
    <ns>0</ns>
    <id>209</id>
    <revision>
      <id>999</id>
      <timestamp>2024-05-11T06:32:13Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''KwaMabhoko''' ebuye yaziwe ngeMapoch yidolobha elikuMasipala Wendawo i-Dr JS Moroka esifundazweni saseMpumalanga eNingizimu Afrika.  IMapoch iyindawo yasemaphandleni, futhi umphakathi wendawo usahlala ngendlela yasesigodini.&quot;</comment>
      <origin>999</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="227" sha1="q0amg1znvwax5wj5pl53hnbm982saet" xml:space="preserve">'''KwaMabhoko''' ebuye yaziwe ngeMapoch yidolobha elikuMasipala Wendawo i-Dr JS Moroka esifundazweni saseMpumalanga eNingizimu Afrika.

IMapoch iyindawo yasemaphandleni, futhi umphakathi wendawo usahlala ngendlela yasesigodini.</text>
      <sha1>q0amg1znvwax5wj5pl53hnbm982saet</sha1>
    </revision>
    <revision>
      <id>1000</id>
      <parentid>999</parentid>
      <timestamp>2024-10-14T13:46:59Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>999</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="227" sha1="q0amg1znvwax5wj5pl53hnbm982saet" xml:space="preserve">'''KwaMabhoko''' ebuye yaziwe ngeMapoch yidolobha elikuMasipala Wendawo i-Dr JS Moroka esifundazweni saseMpumalanga eNingizimu Afrika.

IMapoch iyindawo yasemaphandleni, futhi umphakathi wendawo usahlala ngendlela yasesigodini.</text>
      <sha1>q0amg1znvwax5wj5pl53hnbm982saet</sha1>
    </revision>
  </page>
  <page>
    <title>Kwekwezi fm</title>
    <ns>0</ns>
    <id>210</id>
    <revision>
      <id>1001</id>
      <timestamp>2024-03-08T13:23:18Z</timestamp>
      <contributor>
        <username>incubator&gt;Thandeka179</username>
        <id>0</id>
      </contributor>
      <comment>Created this page</comment>
      <origin>1001</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="80" sha1="tdeghxlx6ljt4iojm2q29hevm2jaovh" xml:space="preserve">'''Ikwekwezi Fm''' mrhatjho orhasha ngelimi leSindebele owaziwa ilizwe jikelele.</text>
      <sha1>tdeghxlx6ljt4iojm2q29hevm2jaovh</sha1>
    </revision>
    <revision>
      <id>1002</id>
      <parentid>1001</parentid>
      <timestamp>2024-03-08T13:51:02Z</timestamp>
      <contributor>
        <username>incubator&gt;Thandeka179</username>
        <id>0</id>
      </contributor>
      <origin>1002</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="154" sha1="d5x84g4fgp1rar6sj6kb5a5vlqed5yj" xml:space="preserve">'''Ikwekwezi Fm''' mrhatjho orhasha ngelimi leSindebele owaziwa ilizwe jikelele. Phambilini beyaziwa nge Radio Ndebele ,yasungulwa ngomhlaka (1April 1983)</text>
      <sha1>d5x84g4fgp1rar6sj6kb5a5vlqed5yj</sha1>
    </revision>
    <revision>
      <id>1003</id>
      <parentid>1002</parentid>
      <timestamp>2024-03-09T07:20:46Z</timestamp>
      <contributor>
        <username>incubator&gt;Thandeka179</username>
        <id>0</id>
      </contributor>
      <origin>1003</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="158" sha1="75ohil7omjsg3p8yxq426xew2e2yurk" xml:space="preserve">'''Ikwekwezi Fm''' mrhatjho orhasha ngelimi leSindebele owaziwa ilizwe jikelele. Phambilini beyaziwa nge Radio [[Ndebele]] ,yasungulwa ngomhlaka (1April 1983)</text>
      <sha1>75ohil7omjsg3p8yxq426xew2e2yurk</sha1>
    </revision>
    <revision>
      <id>1004</id>
      <parentid>1003</parentid>
      <timestamp>2024-03-09T07:34:53Z</timestamp>
      <contributor>
        <username>incubator&gt;Thandeka179</username>
        <id>0</id>
      </contributor>
      <comment>Added content</comment>
      <origin>1004</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="404" sha1="grmf0tkz17z09lewo57mvoukr7fc0c2" xml:space="preserve">'''Ikwekwezi Fm''' mrhatjho orhasha ngelimi leSindebele owaziwa ilizwe jikelele. Phambilini beyaziwa nge Radio [[Ndebele]] ,yasungulwa ngomhlaka (1April 1983)

'''Isizinda'''

umrhatjho wathoma ukunzinza kwa SABC(Northern Transvaal Region), e Minaar street epitori. Yafuduka yaya e Weavid Park nayo ese Pitori , Yafuduka godu yanzinza e Auckland Pack e Johannesburg kukulapho isanzinze khona namhlanjesi.</text>
      <sha1>grmf0tkz17z09lewo57mvoukr7fc0c2</sha1>
    </revision>
    <revision>
      <id>1005</id>
      <parentid>1004</parentid>
      <timestamp>2024-03-09T07:35:38Z</timestamp>
      <contributor>
        <username>incubator&gt;Thandeka179</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Linked the page</comment>
      <origin>1005</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="408" sha1="mo766z9q99dmx5aa44z3jxaw62rs08q" xml:space="preserve">'''Ikwekwezi Fm''' mrhatjho orhasha ngelimi leSindebele owaziwa ilizwe jikelele. Phambilini beyaziwa nge Radio [[Ndebele]] ,yasungulwa ngomhlaka (1April 1983)

'''Isizinda'''

umrhatjho wathoma ukunzinza kwa SABC([[Northern Transvaal Region]]), e Minaar street epitori. Yafuduka yaya e Weavid Park nayo ese Pitori , Yafuduka godu yanzinza e Auckland Pack e Johannesburg kukulapho isanzinze khona namhlanjesi.</text>
      <sha1>mo766z9q99dmx5aa44z3jxaw62rs08q</sha1>
    </revision>
    <revision>
      <id>1006</id>
      <parentid>1005</parentid>
      <timestamp>2024-03-09T07:36:29Z</timestamp>
      <contributor>
        <username>incubator&gt;Thandeka179</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1006</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="412" sha1="psq1z3zgac89octtc5ai9ad7djwz444" xml:space="preserve">'''Ikwekwezi Fm''' mrhatjho orhasha ngelimi leSindebele owaziwa ilizwe jikelele. Phambilini beyaziwa nge Radio [[Ndebele]] ,yasungulwa ngomhlaka (1April 1983)

'''Isizinda'''

umrhatjho wathoma ukunzinza kwa [[SABC]]([[Northern Transvaal Region]]), e Minaar street epitori. Yafuduka yaya e Weavid Park nayo ese Pitori , Yafuduka godu yanzinza e Auckland Pack e Johannesburg kukulapho isanzinze khona namhlanjesi.</text>
      <sha1>psq1z3zgac89octtc5ai9ad7djwz444</sha1>
    </revision>
    <revision>
      <id>1007</id>
      <parentid>1006</parentid>
      <timestamp>2024-03-09T07:37:02Z</timestamp>
      <contributor>
        <username>incubator&gt;Thandeka179</username>
        <id>0</id>
      </contributor>
      <comment>Linked the page</comment>
      <origin>1007</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="416" sha1="9vm9m0fxdfn68ze2y2ongglnpj7v1na" xml:space="preserve">'''Ikwekwezi Fm''' mrhatjho orhasha ngelimi leSindebele owaziwa ilizwe jikelele. Phambilini beyaziwa nge Radio [[Ndebele]] ,yasungulwa ngomhlaka (1April 1983)

'''Isizinda'''

umrhatjho wathoma ukunzinza kwa [[SABC]]([[Northern Transvaal Region]]), e Minaar street epitori. Yafuduka yaya e Weavid Park nayo ese Pitori , Yafuduka godu yanzinza e Auckland Pack e [[Johannesburg]] kukulapho isanzinze khona namhlanjesi.</text>
      <sha1>9vm9m0fxdfn68ze2y2ongglnpj7v1na</sha1>
    </revision>
    <revision>
      <id>1008</id>
      <parentid>1007</parentid>
      <timestamp>2024-03-09T07:37:59Z</timestamp>
      <contributor>
        <username>incubator&gt;Thandeka179</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1008</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="427" sha1="fvs639zt5ppydfbthue7aowfcewxk5m" xml:space="preserve">'''Ikwekwezi Fm''' mrhatjho orhasha ngelimi leSindebele owaziwa ilizwe jikelele. Phambilini beyaziwa nge Radio [[Ndebele]] ,yasungulwa ngomhlaka (1April 1983)

'''&lt;big&gt;Isizinda&lt;/big&gt;'''

umrhatjho wathoma ukunzinza kwa [[SABC]]([[Northern Transvaal Region]]), e Minaar street epitori. Yafuduka yaya e Weavid Park nayo ese Pitori , Yafuduka godu yanzinza e Auckland Pack e [[Johannesburg]] kukulapho isanzinze khona namhlanjesi.</text>
      <sha1>fvs639zt5ppydfbthue7aowfcewxk5m</sha1>
    </revision>
    <revision>
      <id>1009</id>
      <parentid>1008</parentid>
      <timestamp>2024-10-14T13:47:00Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>8 revisions imported</comment>
      <origin>1008</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="427" sha1="fvs639zt5ppydfbthue7aowfcewxk5m" xml:space="preserve">'''Ikwekwezi Fm''' mrhatjho orhasha ngelimi leSindebele owaziwa ilizwe jikelele. Phambilini beyaziwa nge Radio [[Ndebele]] ,yasungulwa ngomhlaka (1April 1983)

'''&lt;big&gt;Isizinda&lt;/big&gt;'''

umrhatjho wathoma ukunzinza kwa [[SABC]]([[Northern Transvaal Region]]), e Minaar street epitori. Yafuduka yaya e Weavid Park nayo ese Pitori , Yafuduka godu yanzinza e Auckland Pack e [[Johannesburg]] kukulapho isanzinze khona namhlanjesi.</text>
      <sha1>fvs639zt5ppydfbthue7aowfcewxk5m</sha1>
    </revision>
  </page>
  <page>
    <title>Mabidwana Jiyana</title>
    <ns>0</ns>
    <id>211</id>
    <revision>
      <id>1010</id>
      <timestamp>2024-03-08T10:38:21Z</timestamp>
      <contributor>
        <ip>196.21.175.1</ip>
      </contributor>
      <comment>nothing changed</comment>
      <origin>1010</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="36" sha1="9dvkjzehny74g0qiqop4ttzfqdgwylr" xml:space="preserve">uMabidwana Jiyana wange Siyabuswa.

</text>
      <sha1>9dvkjzehny74g0qiqop4ttzfqdgwylr</sha1>
    </revision>
    <revision>
      <id>1011</id>
      <parentid>1010</parentid>
      <timestamp>2024-03-09T11:02:55Z</timestamp>
      <contributor>
        <username>incubator&gt;LondiweM24</username>
        <id>0</id>
      </contributor>
      <comment>i edited and added pictures. i also made an article longer</comment>
      <origin>1011</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1280" sha1="ozvg2dq4jwvvqf5m6jn823ys9gtx62n" xml:space="preserve">'''Ilanga lamagugu.'''

Enyakeni omunye nomunye ngo Sinyikhamba 27, e [[Sewula Afrika]] kugidingwa ilanga lamagugu. Omunye nomunye uzikhakhazisa ngesikhabo, imvelaphi yakhe. eenkolweni neendaweni zokusebenzela ngelangeli omunye nomunye uvela ngesikhhabo.


Thina amaNdebele nathi sikhumbula lapha sivela khona, izidlo ebegade zidliwa ekadeni, ivunulo, iinkosi ebegade zisibuza nabo khokho bethu. imvelaphi yomuntu ibaluleke kwamambala. kufuze uzibuze bona kubayini simbatha umbhalo, utjho ukuthini umbhalo emaNdebeleni? indaba yesirholwana ivelaphi? ijemu ihlathululani? kubalulekile bonyana isiko lakho ulazi ngokuzeleko. ilwazi liyafunyaneka kwabakhulu abo mma, abo gogo nabo khokho nawusese netjhudu ubafunyene badla umratha.

== Indlela yokwembatha ==
Isikhethu siyakarisa ebulilini obunye nobunye, nezingeni elinye nelinye lomnyaka.
[[Isimumathi:AmaNdebele.jpg|thumb|ndebele different attires]]
umntazana netlawana bambatha ngendlela efanako. umma othethweko ivunulo yakhe iyahluka kanti ke nendoda ethetheko ineporiyana. amasokana nawo aneyabo indlela yokwembatha, bese umsegwabo umbatha irhembe nebrugu elifitjhani aphathe nendronga ukutjengisa bona uzasok'khula abe lisokana.



Isikhenu siqakatheke malanga wonke ingasi ngo Sinyikhaba kwaphela. zikhakhazise ngesikhenu!

</text>
      <sha1>ozvg2dq4jwvvqf5m6jn823ys9gtx62n</sha1>
    </revision>
    <revision>
      <id>1012</id>
      <parentid>1011</parentid>
      <timestamp>2024-10-14T13:47:00Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>1011</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1280" sha1="ozvg2dq4jwvvqf5m6jn823ys9gtx62n" xml:space="preserve">'''Ilanga lamagugu.'''

Enyakeni omunye nomunye ngo Sinyikhamba 27, e [[Sewula Afrika]] kugidingwa ilanga lamagugu. Omunye nomunye uzikhakhazisa ngesikhabo, imvelaphi yakhe. eenkolweni neendaweni zokusebenzela ngelangeli omunye nomunye uvela ngesikhhabo.


Thina amaNdebele nathi sikhumbula lapha sivela khona, izidlo ebegade zidliwa ekadeni, ivunulo, iinkosi ebegade zisibuza nabo khokho bethu. imvelaphi yomuntu ibaluleke kwamambala. kufuze uzibuze bona kubayini simbatha umbhalo, utjho ukuthini umbhalo emaNdebeleni? indaba yesirholwana ivelaphi? ijemu ihlathululani? kubalulekile bonyana isiko lakho ulazi ngokuzeleko. ilwazi liyafunyaneka kwabakhulu abo mma, abo gogo nabo khokho nawusese netjhudu ubafunyene badla umratha.

== Indlela yokwembatha ==
Isikhethu siyakarisa ebulilini obunye nobunye, nezingeni elinye nelinye lomnyaka.
[[Isimumathi:AmaNdebele.jpg|thumb|ndebele different attires]]
umntazana netlawana bambatha ngendlela efanako. umma othethweko ivunulo yakhe iyahluka kanti ke nendoda ethetheko ineporiyana. amasokana nawo aneyabo indlela yokwembatha, bese umsegwabo umbatha irhembe nebrugu elifitjhani aphathe nendronga ukutjengisa bona uzasok'khula abe lisokana.



Isikhenu siqakatheke malanga wonke ingasi ngo Sinyikhaba kwaphela. zikhakhazise ngesikhenu!

</text>
      <sha1>ozvg2dq4jwvvqf5m6jn823ys9gtx62n</sha1>
    </revision>
    <revision>
      <id>2213</id>
      <parentid>1012</parentid>
      <timestamp>2024-11-29T07:37:13Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <comment>/* Indlela yokwembatha */</comment>
      <origin>2213</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1276" sha1="eiwftdbrmgct7wt7ugiuc0o125kjcor" xml:space="preserve">'''Ilanga lamagugu.'''

Enyakeni omunye nomunye ngo Sinyikhamba 27, e [[Sewula Afrika]] kugidingwa ilanga lamagugu. Omunye nomunye uzikhakhazisa ngesikhabo, imvelaphi yakhe. eenkolweni neendaweni zokusebenzela ngelangeli omunye nomunye uvela ngesikhhabo.


Thina amaNdebele nathi sikhumbula lapha sivela khona, izidlo ebegade zidliwa ekadeni, ivunulo, iinkosi ebegade zisibuza nabo khokho bethu. imvelaphi yomuntu ibaluleke kwamambala. kufuze uzibuze bona kubayini simbatha umbhalo, utjho ukuthini umbhalo emaNdebeleni? indaba yesirholwana ivelaphi? ijemu ihlathululani? kubalulekile bonyana isiko lakho ulazi ngokuzeleko. ilwazi liyafunyaneka kwabakhulu abo mma, abo gogo nabo khokho nawusese netjhudu ubafunyene badla umratha.

== Indlela yokwembatha ==
Isikhethu siyakarisa ebulilini obunye nobunye, nezingeni elinye nelinye lomnyaka.
[[Isimumathi:AmaNdebele.jpg|thumb|ndebele different attires]]
umntazana netlawana bambatha ngendlela efanako. umma othethweko ivunulo yakhe iyahluka kanti ke nendoda ethetheko ineporiyana. amasokana nawo aneyabo indlela yokwembatha, bese umsegwabo umbatha irhembe nebrugu elifitjhani aphathe nendronga ukutjengisa bona uzasok'khula abe lisokana.

Isikhenu siqakatheke malanga wonke ingasi ngo Sinyikhaba kwaphela. zikhakhazise ngesikhenu!</text>
      <sha1>eiwftdbrmgct7wt7ugiuc0o125kjcor</sha1>
    </revision>
  </page>
  <page>
    <title>Wikiphidiya:Main Page/Did you know</title>
    <ns>4</ns>
    <id>212</id>
    <revision>
      <id>1061</id>
      <timestamp>2016-02-20T17:37:17Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;&lt;div style=&quot;float:left;margin:0.5em 0.9em 0.4em 0&quot;&gt;[[Isimumathi:The visit of the wise-men.jpg|100px|khisimusi.]]&lt;/div&gt; '''[[khisimusi]]''' i nkarhi lowu tsakeriwaka ngopfu...&quot;</comment>
      <origin>1061</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="567" sha1="l6voz85xyf6w4cmwl39nfqfdwyxyei8" xml:space="preserve">&lt;div style=&quot;float:left;margin:0.5em 0.9em 0.4em 0&quot;&gt;[[Isimumathi:The visit of the wise-men.jpg|100px|khisimusi.]]&lt;/div&gt;
'''[[khisimusi]]''' i nkarhi lowu tsakeriwaka ngopfu hi maninamani emisaveni hinkwayo. Nkarhi lowu wu hlanganisa maxaka na mindyangu, laha swirho swa mindyangu leswi tshamake ekule swi kotaka ku hlangana swivonana endzawini yin'we. eka va kreste votala lri i siku ra ku tswariwa ka [[Jesus|Yesu kreste]]. Loko siku leri ri tshinela hi vona ku xongisiwa ka mapatu na ti ndlela ku hlanganisa na mavhengele. ('''[[Khisimusi|Leswi engetelekeke...]]''')</text>
      <sha1>l6voz85xyf6w4cmwl39nfqfdwyxyei8</sha1>
    </revision>
    <revision>
      <id>1062</id>
      <parentid>1061</parentid>
      <timestamp>2016-02-20T17:48:23Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1062</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="683" sha1="ftftr4a3ur4r3elms18kt2sbnk5r2e2" xml:space="preserve">&lt;div style=&quot;float:left;margin:0.5em 0.9em 0.4em 0&quot;&gt;[[Isimumathi:The visit of the wise-men.jpg|100px|khisimusi.]]&lt;/div&gt;
&lt;div id=&quot;mp-dyk&quot; style=&quot;padding:2px 5px; font-size:95%;&quot;&gt;
'''[[khisimusi]]''' i nkarhi lowu tsakeriwaka ngopfu hi maninamani emisaveni hinkwayo. Nkarhi lowu wu hlanganisa maxaka na mindyangu, laha swirho swa mindyangu leswi tshamake ekule swi kotaka ku hlangana swivonana endzawini yin'we. eka va kreste votala lri i siku ra ku tswariwa ka [[Jesus|Yesu kreste]]. Loko siku leri ri tshinela hi vona ku xongisiwa ka mapatu na ti ndlela ku hlanganisa na mavhengele.
&lt;br&gt;
&lt;div style=&quot;font-size:85%; text-align:right;&quot;&gt;([[Ikhrismesi|Qala Isithasiselo...]])&lt;/div&gt;
&lt;/div&gt;</text>
      <sha1>ftftr4a3ur4r3elms18kt2sbnk5r2e2</sha1>
    </revision>
    <revision>
      <id>1063</id>
      <parentid>1062</parentid>
      <timestamp>2016-02-21T07:15:44Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1063</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="683" sha1="mihsaj9062tl413qmbroylotfmhr920" xml:space="preserve">&lt;div style=&quot;float:left;margin:0.5em 0.9em 0.4em 0&quot;&gt;[[Isimumathi:The visit of the wise-men.jpg|150px|khisimusi.]]&lt;/div&gt;
&lt;div id=&quot;mp-dyk&quot; style=&quot;padding:2px 5px; font-size:95%;&quot;&gt;
'''[[khisimusi]]''' i nkarhi lowu tsakeriwaka ngopfu hi maninamani emisaveni hinkwayo. Nkarhi lowu wu hlanganisa maxaka na mindyangu, laha swirho swa mindyangu leswi tshamake ekule swi kotaka ku hlangana swivonana endzawini yin'we. eka va kreste votala lri i siku ra ku tswariwa ka [[Jesus|Yesu kreste]]. Loko siku leri ri tshinela hi vona ku xongisiwa ka mapatu na ti ndlela ku hlanganisa na mavhengele.
&lt;br&gt;
&lt;div style=&quot;font-size:85%; text-align:right;&quot;&gt;([[Ikhrismesi|Qala Isithasiselo...]])&lt;/div&gt;
&lt;/div&gt;</text>
      <sha1>mihsaj9062tl413qmbroylotfmhr920</sha1>
    </revision>
    <revision>
      <id>1064</id>
      <parentid>1063</parentid>
      <timestamp>2016-02-21T08:12:45Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1064</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="629" sha1="kz5572bhnizbtn46j4xvh6rfxal4qgy" xml:space="preserve">&lt;div style=&quot;float:left;margin:0.5em 0.9em 0.4em 0&quot;&gt;[[Isimumathi:The visit of the wise-men.jpg|150px|khisimusi.]]&lt;/div&gt;
&lt;div id=&quot;mp-dyk&quot; style=&quot;padding:2px 5px; font-size:95%;&quot;&gt;
'''Ikhrismesi''' umgidingo odumileko kwikolo yobukhreste begodu igidingwa eengcenyeni ezinengi zephasi namhlanje. Iskhathesi sihlanganisa abantwu bona nemindenaabo, kuthokozwe khulu. Umgidingolo ukhumbula ilanga uJesu abelethwa ngalo, ngo 25 kunobayeni qobe minyaka. Ungabona kobanyana Ikhrismesi itjhidile ngentengiso begodu neplarha enarheni yoke. 
&lt;br&gt;
&lt;div style=&quot;font-size:85%; text-align:right;&quot;&gt;([[Ikhrismesi|Qala Isithasiselo...]])&lt;/div&gt;
&lt;/div&gt;</text>
      <sha1>kz5572bhnizbtn46j4xvh6rfxal4qgy</sha1>
    </revision>
    <revision>
      <id>1065</id>
      <parentid>1064</parentid>
      <timestamp>2016-02-21T08:22:15Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1065</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="632" sha1="m9sbv66vjt6wpxqjyiklagf1fgu4zbj" xml:space="preserve">&lt;div style=&quot;float:left;margin:0.5em 0.9em 0.4em 0&quot;&gt;[[Isimumathi:The visit of the wise-men.jpg|150px|khisimusi.]]&lt;/div&gt;
&lt;div id=&quot;mp-dyk&quot; style=&quot;padding:2px 5px; font-size:95%;&quot;&gt;
'''Ikrismesi''' umgidingo odumileko kwikolo yobukreste begodu igidingwa eengcenyeni ezinengi zephasi namhlanje. Iskhathesi sihlanganisa abantwu bona nemindenaabo, kuthokozwe khulu. Umgidingolo ukhumbula ilanga uJesu abelethwa ngalo, ngo 25 kunobayeni qobe minyaka. Ungabona kobanyana Ikrismesi itjhidile ngerhwebo begodu neplarha zerhwebo enarheni yoke. 
&lt;br&gt;
&lt;div style=&quot;font-size:85%; text-align:right;&quot;&gt;([[Ikrismesi|Qala Isithasiselo...]])&lt;/div&gt;
&lt;/div&gt;</text>
      <sha1>m9sbv66vjt6wpxqjyiklagf1fgu4zbj</sha1>
    </revision>
    <revision>
      <id>1066</id>
      <parentid>1065</parentid>
      <timestamp>2016-02-21T08:22:36Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1066</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="632" sha1="iae4v1od0k2b4whdsdlq6avzusrm1tw" xml:space="preserve">&lt;div style=&quot;float:left;margin:0.5em 0.9em 0.4em 0&quot;&gt;[[Isimumathi:The visit of the wise-men.jpg|130px|khisimusi.]]&lt;/div&gt;
&lt;div id=&quot;mp-dyk&quot; style=&quot;padding:2px 5px; font-size:95%;&quot;&gt;
'''Ikrismesi''' umgidingo odumileko kwikolo yobukreste begodu igidingwa eengcenyeni ezinengi zephasi namhlanje. Iskhathesi sihlanganisa abantwu bona nemindenaabo, kuthokozwe khulu. Umgidingolo ukhumbula ilanga uJesu abelethwa ngalo, ngo 25 kunobayeni qobe minyaka. Ungabona kobanyana Ikrismesi itjhidile ngerhwebo begodu neplarha zerhwebo enarheni yoke. 
&lt;br&gt;
&lt;div style=&quot;font-size:85%; text-align:right;&quot;&gt;([[Ikrismesi|Qala Isithasiselo...]])&lt;/div&gt;
&lt;/div&gt;</text>
      <sha1>iae4v1od0k2b4whdsdlq6avzusrm1tw</sha1>
    </revision>
    <revision>
      <id>1067</id>
      <parentid>1066</parentid>
      <timestamp>2016-02-21T08:24:08Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1067</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="638" sha1="t5kpvuuxs21wmu3yd6wf8tkr6xfc4q2" xml:space="preserve">&lt;div style=&quot;float:left;margin:0.5em 0.9em 0.4em 0&quot;&gt;[[Isimumathi:The visit of the wise-men.jpg|130px|khisimusi.]]&lt;/div&gt;
&lt;div id=&quot;mp-dyk&quot; style=&quot;padding:2px 5px; font-size:95%;&quot;&gt;
'''Ikrismesi''' umgidingo odumileko kwikolo yobukreste begodu igidingwa eengcenyeni ezinengi zephasi namhlanje. Iskhathesi sihlanganisa abantwu bona nemindenaabo, kuthokozwe khulu. Umgidingolo ukhumbula ilanga uJesu abelethwa ngalo, ngo 25 kunobayeni qobe minyaka. Ungabona kobanyana Ikrismesi itjhidile ngerhwebo begodu neplarha zerhwebo enarheni yoke. 
&lt;br&gt;
&lt;div style=&quot;font-size:85%; text-align:right;&quot;&gt;('''[[Ikrismesi|Qala Isithasiselo...]]''')&lt;/div&gt;
&lt;/div&gt;</text>
      <sha1>t5kpvuuxs21wmu3yd6wf8tkr6xfc4q2</sha1>
    </revision>
    <revision>
      <id>1068</id>
      <parentid>1067</parentid>
      <timestamp>2024-10-14T13:47:01Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>7 revisions imported</comment>
      <origin>1067</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="638" sha1="t5kpvuuxs21wmu3yd6wf8tkr6xfc4q2" xml:space="preserve">&lt;div style=&quot;float:left;margin:0.5em 0.9em 0.4em 0&quot;&gt;[[Isimumathi:The visit of the wise-men.jpg|130px|khisimusi.]]&lt;/div&gt;
&lt;div id=&quot;mp-dyk&quot; style=&quot;padding:2px 5px; font-size:95%;&quot;&gt;
'''Ikrismesi''' umgidingo odumileko kwikolo yobukreste begodu igidingwa eengcenyeni ezinengi zephasi namhlanje. Iskhathesi sihlanganisa abantwu bona nemindenaabo, kuthokozwe khulu. Umgidingolo ukhumbula ilanga uJesu abelethwa ngalo, ngo 25 kunobayeni qobe minyaka. Ungabona kobanyana Ikrismesi itjhidile ngerhwebo begodu neplarha zerhwebo enarheni yoke. 
&lt;br&gt;
&lt;div style=&quot;font-size:85%; text-align:right;&quot;&gt;('''[[Ikrismesi|Qala Isithasiselo...]]''')&lt;/div&gt;
&lt;/div&gt;</text>
      <sha1>t5kpvuuxs21wmu3yd6wf8tkr6xfc4q2</sha1>
    </revision>
    <revision>
      <id>1899</id>
      <parentid>1068</parentid>
      <timestamp>2024-11-14T19:27:12Z</timestamp>
      <contributor>
        <username>MikitkoSynAlexeev</username>
        <id>168</id>
      </contributor>
      <origin>1899</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="795" sha1="ott440zbduej9h1jetfjvrzozt8f827" xml:space="preserve">[[Isimumathi:View over the Old Town of Budva from the Citadel.jpg|130px|khisimusi.]]
&lt;div style=&quot;float:left;margin:0.5em 0.9em 0.4em 0&quot;&gt;&lt;/div&gt;
&lt;div id=&quot;mp-dyk&quot; style=&quot;padding:2px 5px; font-size:95%;&quot;&gt;
'''I-Budva''' lidorobha elise-Montenegro, eliphakathi kwe-Adriatic coast yelizwe. Idorobha lisikhungo sesifunda sikamasipala esinegama elifanako. I-Budva yasungulwa eminyakeni ema-2500 eyadlulako begodu ngenye yeendawo zokuhlala zakade khulu emaphethelweni weLwandle le-Adriatic. I-Budva nendawo eziseduze kwayo zakha i-Budva Riviera - isikhungo seemvakatjhi esikhulu kunazo zoke e-Montenegro, esidume ngamabhitjhi waso, ipilo yasebusuku kanye neembonelo ezihle zezakhiwo ze-Mediterranean.
&lt;br&gt;
&lt;div style=&quot;font-size:85%; text-align:right;&quot;&gt;('''[[I-Budva|Qala Isithasiselo...]]''')&lt;/div&gt;
&lt;/div&gt;</text>
      <sha1>ott440zbduej9h1jetfjvrzozt8f827</sha1>
    </revision>
    <revision>
      <id>2265</id>
      <parentid>1899</parentid>
      <timestamp>2024-12-11T19:31:46Z</timestamp>
      <contributor>
        <username>Таёжный лес</username>
        <id>59</id>
      </contributor>
      <minor />
      <comment>Таёжный лес moved page [[Main Page/Did you know]] to [[Wikiphidiya:Main Page/Did you know]]</comment>
      <origin>1899</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="795" sha1="ott440zbduej9h1jetfjvrzozt8f827" xml:space="preserve">[[Isimumathi:View over the Old Town of Budva from the Citadel.jpg|130px|khisimusi.]]
&lt;div style=&quot;float:left;margin:0.5em 0.9em 0.4em 0&quot;&gt;&lt;/div&gt;
&lt;div id=&quot;mp-dyk&quot; style=&quot;padding:2px 5px; font-size:95%;&quot;&gt;
'''I-Budva''' lidorobha elise-Montenegro, eliphakathi kwe-Adriatic coast yelizwe. Idorobha lisikhungo sesifunda sikamasipala esinegama elifanako. I-Budva yasungulwa eminyakeni ema-2500 eyadlulako begodu ngenye yeendawo zokuhlala zakade khulu emaphethelweni weLwandle le-Adriatic. I-Budva nendawo eziseduze kwayo zakha i-Budva Riviera - isikhungo seemvakatjhi esikhulu kunazo zoke e-Montenegro, esidume ngamabhitjhi waso, ipilo yasebusuku kanye neembonelo ezihle zezakhiwo ze-Mediterranean.
&lt;br&gt;
&lt;div style=&quot;font-size:85%; text-align:right;&quot;&gt;('''[[I-Budva|Qala Isithasiselo...]]''')&lt;/div&gt;
&lt;/div&gt;</text>
      <sha1>ott440zbduej9h1jetfjvrzozt8f827</sha1>
    </revision>
    <revision>
      <id>2568</id>
      <parentid>2265</parentid>
      <timestamp>2025-03-22T05:33:55Z</timestamp>
      <contributor>
        <username>Kvazimodo</username>
        <id>341</id>
      </contributor>
      <origin>2568</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="799" sha1="otl6qhmkrn8xfhmqsmav9rwksxkij4z" xml:space="preserve">[[Isimumathi:View over the Old Town of Budva from the Citadel.jpg|130px|khisimusi.]]
&lt;div style=&quot;float:left;margin:0.5em 0.9em 0.4em 0&quot;&gt;&lt;/div&gt;
&lt;div id=&quot;mp-dyk&quot; style=&quot;padding:2px 5px; font-size:95%;&quot;&gt;
'''[[I-Budva]]''' lidorobha elise-Montenegro, eliphakathi kwe-Adriatic coast yelizwe. Idorobha lisikhungo sesifunda sikamasipala esinegama elifanako. I-Budva yasungulwa eminyakeni ema-2500 eyadlulako begodu ngenye yeendawo zokuhlala zakade khulu emaphethelweni weLwandle le-Adriatic. I-Budva nendawo eziseduze kwayo zakha i-Budva Riviera - isikhungo seemvakatjhi esikhulu kunazo zoke e-Montenegro, esidume ngamabhitjhi waso, ipilo yasebusuku kanye neembonelo ezihle zezakhiwo ze-Mediterranean.
&lt;br&gt;
&lt;div style=&quot;font-size:85%; text-align:right;&quot;&gt;('''[[I-Budva|Qala Isithasiselo...]]''')&lt;/div&gt;
&lt;/div&gt;</text>
      <sha1>otl6qhmkrn8xfhmqsmav9rwksxkij4z</sha1>
    </revision>
    <revision>
      <id>2908</id>
      <parentid>2568</parentid>
      <timestamp>2025-06-06T16:46:43Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>nice</comment>
      <origin>2908</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="76" sha1="kqvik3y5c16vuypii0dw1xibl8tcyai" xml:space="preserve">This page is sponsored by Raid: Shadow Legends, the sponsor of today's page.</text>
      <sha1>kqvik3y5c16vuypii0dw1xibl8tcyai</sha1>
    </revision>
    <revision>
      <id>2909</id>
      <parentid>2908</parentid>
      <timestamp>2025-06-06T16:47:12Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <origin>2909</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="80" sha1="4eqellm0byk4eoajmah0qjrk1ddf9hg" xml:space="preserve">This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.</text>
      <sha1>4eqellm0byk4eoajmah0qjrk1ddf9hg</sha1>
    </revision>
    <revision>
      <id>3145</id>
      <parentid>2909</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edits by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Janabaevazizbek|Janabaevazizbek]]</comment>
      <origin>2568</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="799" sha1="otl6qhmkrn8xfhmqsmav9rwksxkij4z" xml:space="preserve">[[Isimumathi:View over the Old Town of Budva from the Citadel.jpg|130px|khisimusi.]]
&lt;div style=&quot;float:left;margin:0.5em 0.9em 0.4em 0&quot;&gt;&lt;/div&gt;
&lt;div id=&quot;mp-dyk&quot; style=&quot;padding:2px 5px; font-size:95%;&quot;&gt;
'''[[I-Budva]]''' lidorobha elise-Montenegro, eliphakathi kwe-Adriatic coast yelizwe. Idorobha lisikhungo sesifunda sikamasipala esinegama elifanako. I-Budva yasungulwa eminyakeni ema-2500 eyadlulako begodu ngenye yeendawo zokuhlala zakade khulu emaphethelweni weLwandle le-Adriatic. I-Budva nendawo eziseduze kwayo zakha i-Budva Riviera - isikhungo seemvakatjhi esikhulu kunazo zoke e-Montenegro, esidume ngamabhitjhi waso, ipilo yasebusuku kanye neembonelo ezihle zezakhiwo ze-Mediterranean.
&lt;br&gt;
&lt;div style=&quot;font-size:85%; text-align:right;&quot;&gt;('''[[I-Budva|Qala Isithasiselo...]]''')&lt;/div&gt;
&lt;/div&gt;</text>
      <sha1>otl6qhmkrn8xfhmqsmav9rwksxkij4z</sha1>
    </revision>
  </page>
  <page>
    <title>Main Page/Featured Article</title>
    <ns>0</ns>
    <id>213</id>
    <revision>
      <id>1069</id>
      <timestamp>2016-02-20T17:12:03Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot; '''The South Ndebele people''' found in the former Transvaal today consists mainly of two tribes, namely, abakwaManala (the Manala Ndebele) and abakwaNdzundza (the Ndzundza N...&quot;</comment>
      <origin>1069</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="794" sha1="ie5rw6soiqrpl5ypuukv9b3i8s7k0x1" xml:space="preserve">
'''The South Ndebele people''' found in the former Transvaal today consists mainly of two tribes, namely, abakwaManala (the Manala Ndebele) and abakwaNdzundza (the Ndzundza Ndebele). the history of the Ndebele people can be traced back to Mafana, their first identifiable chief. Mafana’s successor, Mhlanga, had a son named Musi who, in the early 1600’s, decided to move away from his cousins (later to become the mighty Zulu nation) and to settle in the hills of Gauteng near where the capital, Pretoria is situated. Historically, KwaMnyamana is the most important settlement area of the (ama) Ndebele of the Republic of South Africa, because it is the place where the (ama)Ndebele split into two main groups and numerous smaller sub-groups. ([[Umlando waMandebele|Qala Isithasiselo...]])</text>
      <sha1>ie5rw6soiqrpl5ypuukv9b3i8s7k0x1</sha1>
    </revision>
    <revision>
      <id>1070</id>
      <parentid>1069</parentid>
      <timestamp>2016-02-20T17:15:46Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1070</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="852" sha1="5me2s1hdezymetyfre4sii52hdfjf9g" xml:space="preserve">
'''The South Ndebele people''' found in the former Transvaal today consists mainly of two tribes, namely, abakwaManala (the Manala Ndebele) and abakwaNdzundza (the Ndzundza Ndebele). the history of the Ndebele people can be traced back to Mafana, their first identifiable chief. Mafana’s successor, Mhlanga, had a son named Musi who, in the early 1600’s, decided to move away from his cousins (later to become the mighty Zulu nation) and to settle in the hills of Gauteng near where the capital, Pretoria is situated. Historically, KwaMnyamana is the most important settlement area of the (ama) Ndebele of the Republic of South Africa, because it is the place where the (ama)Ndebele split into two main groups and numerous smaller sub-groups. 
&lt;br&gt;
&lt;div style=&quot;font-size:80%; text-align:right;&quot;&gt;([[Umlando waMandebele|Qala Isithasiselo...]])&lt;/div&gt;</text>
      <sha1>5me2s1hdezymetyfre4sii52hdfjf9g</sha1>
    </revision>
    <revision>
      <id>1071</id>
      <parentid>1070</parentid>
      <timestamp>2016-02-20T17:16:07Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1071</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="852" sha1="s3j8vpzh3wtk14djm0r6ypx2k6vm6qr" xml:space="preserve">
'''The South Ndebele people''' found in the former Transvaal today consists mainly of two tribes, namely, abakwaManala (the Manala Ndebele) and abakwaNdzundza (the Ndzundza Ndebele). the history of the Ndebele people can be traced back to Mafana, their first identifiable chief. Mafana’s successor, Mhlanga, had a son named Musi who, in the early 1600’s, decided to move away from his cousins (later to become the mighty Zulu nation) and to settle in the hills of Gauteng near where the capital, Pretoria is situated. Historically, KwaMnyamana is the most important settlement area of the (ama) Ndebele of the Republic of South Africa, because it is the place where the (ama)Ndebele split into two main groups and numerous smaller sub-groups. 
&lt;br&gt;
&lt;div style=&quot;font-size:85%; text-align:right;&quot;&gt;([[Umlando waMandebele|Qala Isithasiselo...]])&lt;/div&gt;</text>
      <sha1>s3j8vpzh3wtk14djm0r6ypx2k6vm6qr</sha1>
    </revision>
    <revision>
      <id>1072</id>
      <parentid>1071</parentid>
      <timestamp>2016-02-20T17:24:31Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1072</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="904" sha1="gnda0fne63zczzuw83p3a2pqg6l66l0" xml:space="preserve">[[Isimumathi:Ndebele women-1.jpg|250px|center]]
&lt;br&gt;
'''The South Ndebele people''' found in the former Transvaal today consists mainly of two tribes, namely, abakwaManala (the Manala Ndebele) and abakwaNdzundza (the Ndzundza Ndebele). the history of the Ndebele people can be traced back to Mafana, their first identifiable chief. Mafana’s successor, Mhlanga, had a son named Musi who, in the early 1600’s, decided to move away from his cousins (later to become the mighty Zulu nation) and to settle in the hills of Gauteng near where the capital, Pretoria is situated. Historically, KwaMnyamana is the most important settlement area of the (ama) Ndebele of the Republic of South Africa, because it is the place where the (ama)Ndebele split into two main groups and numerous smaller sub-groups. 
&lt;br&gt;
&lt;div style=&quot;font-size:85%; text-align:right;&quot;&gt;([[Umlando waMandebele|Qala Isithasiselo...]])&lt;/div&gt;</text>
      <sha1>gnda0fne63zczzuw83p3a2pqg6l66l0</sha1>
    </revision>
    <revision>
      <id>1073</id>
      <parentid>1072</parentid>
      <timestamp>2016-02-20T17:25:21Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1073</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="899" sha1="k7r0fqpi3376qcpccl1bhsv6bfz4920" xml:space="preserve">[[Isimumathi:Ndebele women-1.jpg|250px|center]]
'''The South Ndebele people''' found in the former Transvaal today consists mainly of two tribes, namely, abakwaManala (the Manala Ndebele) and abakwaNdzundza (the Ndzundza Ndebele). the history of the Ndebele people can be traced back to Mafana, their first identifiable chief. Mafana’s successor, Mhlanga, had a son named Musi who, in the early 1600’s, decided to move away from his cousins (later to become the mighty Zulu nation) and to settle in the hills of Gauteng near where the capital, Pretoria is situated. Historically, KwaMnyamana is the most important settlement area of the (ama) Ndebele of the Republic of South Africa, because it is the place where the (ama)Ndebele split into two main groups and numerous smaller sub-groups. 
&lt;br&gt;
&lt;div style=&quot;font-size:85%; text-align:right;&quot;&gt;([[Umlando waMandebele|Qala Isithasiselo...]])&lt;/div&gt;</text>
      <sha1>k7r0fqpi3376qcpccl1bhsv6bfz4920</sha1>
    </revision>
    <revision>
      <id>1074</id>
      <parentid>1073</parentid>
      <timestamp>2016-02-20T17:29:55Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1074</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="964" sha1="qs5h9ppocymc8e03impupidqhf1pwoz" xml:space="preserve">&lt;div id=&quot;mp-dyk&quot; style=&quot;padding:2px 5px; font-size:90%;&quot;&gt;
[[Isimumathi:Ndebele women-1.jpg|250px|center]]
'''The South Ndebele people''' found in the former Transvaal today consists mainly of two tribes, namely, abakwaManala (the Manala Ndebele) and abakwaNdzundza (the Ndzundza Ndebele). the history of the Ndebele people can be traced back to Mafana, their first identifiable chief. Mafana’s successor, Mhlanga, had a son named Musi who, in the early 1600’s, decided to move away from his cousins (later to become the mighty Zulu nation) and to settle in the hills of Gauteng near where the capital, Pretoria is situated. Historically, KwaMnyamana is the most important settlement area of the (ama) Ndebele of the Republic of South Africa, because it is the place where the (ama)Ndebele split into two main groups and numerous smaller sub-groups. 
&lt;br&gt;
&lt;div style=&quot;font-size:85%; text-align:right;&quot;&gt;([[Umlando waMandebele|Qala Isithasiselo...]])&lt;/div&gt;
&lt;/div&gt;</text>
      <sha1>qs5h9ppocymc8e03impupidqhf1pwoz</sha1>
    </revision>
    <revision>
      <id>1075</id>
      <parentid>1074</parentid>
      <timestamp>2016-02-21T07:15:21Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1075</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1021" sha1="7vva0no7i05rg153w0jh7my68xomm6s" xml:space="preserve">&lt;div style=&quot;float:left;margin:0.5em 0.9em 0.4em 0&quot;&gt;[[Isimumathi:Ndebele women-1.jpg|150px|center]]&lt;/div&gt;
&lt;div id=&quot;mp-dyk&quot; style=&quot;padding:2px 5px; font-size:95%;&quot;&gt;
'''The South Ndebele people''' found in the former Transvaal today consists mainly of two tribes, namely, abakwaManala (the Manala Ndebele) and abakwaNdzundza (the Ndzundza Ndebele). the history of the Ndebele people can be traced back to Mafana, their first identifiable chief. Mafana’s successor, Mhlanga, had a son named Musi who, in the early 1600’s, decided to move away from his cousins (later to become the mighty Zulu nation) and to settle in the hills of Gauteng near where the capital, Pretoria is situated. Historically, KwaMnyamana is the most important settlement area of the (ama) Ndebele of the Republic of South Africa, because it is the place where the (ama)Ndebele split into two main groups and numerous smaller sub-groups. 
&lt;br&gt;
&lt;div style=&quot;font-size:85%; text-align:right;&quot;&gt;([[Umlando waMandebele|Qala Isithasiselo...]])&lt;/div&gt;
&lt;/div&gt;</text>
      <sha1>7vva0no7i05rg153w0jh7my68xomm6s</sha1>
    </revision>
    <revision>
      <id>1076</id>
      <parentid>1075</parentid>
      <timestamp>2016-02-21T08:25:13Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1076</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1027" sha1="k41ssv7pjyp3vut9nujugwcc9vyxsdy" xml:space="preserve">&lt;div style=&quot;float:left;margin:0.5em 0.9em 0.4em 0&quot;&gt;[[Isimumathi:Ndebele women-1.jpg|150px|center]]&lt;/div&gt;
&lt;div id=&quot;mp-dyk&quot; style=&quot;padding:2px 5px; font-size:95%;&quot;&gt;
'''The South Ndebele people''' found in the former Transvaal today consists mainly of two tribes, namely, abakwaManala (the Manala Ndebele) and abakwaNdzundza (the Ndzundza Ndebele). the history of the Ndebele people can be traced back to Mafana, their first identifiable chief. Mafana’s successor, Mhlanga, had a son named Musi who, in the early 1600’s, decided to move away from his cousins (later to become the mighty Zulu nation) and to settle in the hills of Gauteng near where the capital, Pretoria is situated. Historically, KwaMnyamana is the most important settlement area of the (ama) Ndebele of the Republic of South Africa, because it is the place where the (ama)Ndebele split into two main groups and numerous smaller sub-groups. 
&lt;br&gt;
&lt;div style=&quot;font-size:85%; text-align:right;&quot;&gt;('''[[Umlando waMandebele|Qala Isithasiselo...]]''')&lt;/div&gt;
&lt;/div&gt;</text>
      <sha1>k41ssv7pjyp3vut9nujugwcc9vyxsdy</sha1>
    </revision>
    <revision>
      <id>1077</id>
      <parentid>1076</parentid>
      <timestamp>2016-02-21T08:36:11Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1077</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="911" sha1="5kxun28s3zltl74zpinbpcbjww4c6lg" xml:space="preserve">&lt;div style=&quot;float:left;margin:0.5em 0.9em 0.4em 0&quot;&gt;[[Isimumathi:7042 lores-Ebola-Zaire-CDC Photo.jpg|150px|center]]&lt;/div&gt;
&lt;div id=&quot;mp-dyk&quot; style=&quot;padding:2px 5px; font-size:95%;&quot;&gt;
'''Ubulwelwe be-Ebola''' nofana ('''EVD''') '''I-Ebola nomulwana wokopha iingazi okhambisana nomgomani''' ('''EHF''') mimulwana ebangwa bulwelwe bevayirasi ebizwa nge- [[Ebola]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo athoma ukubonakala phakathi kwamalanga amabili ukuya eemvekeni eentathu ngemva sewungenwe bulwelwe lobu, [[njengomgomani ongapheliko]], umphimbo obabako onesilonda, [[imisipha ebuhlungu kanye nehloko esawula kabuhlungu]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kesinye isikhathi [[ungahlanza]], uphakanyelwe ziimbindi nesifo  [[sokurhuda]], kuzokwenza bona [[amaphaphu]] kanye [[neso]] zingasasebenzi kuhle. 
&lt;br&gt;
&lt;div style=&quot;font-size:85%; text-align:right;&quot;&gt;('''[[Ubulwelwe be-Ebola|Qala Isithasiselo...]]''')&lt;/div&gt;
&lt;/div&gt;</text>
      <sha1>5kxun28s3zltl74zpinbpcbjww4c6lg</sha1>
    </revision>
    <revision>
      <id>1078</id>
      <parentid>1077</parentid>
      <timestamp>2016-02-21T08:40:32Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1078</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1216" sha1="opre5uo9lq139r7befjp2zs5q0tmipq" xml:space="preserve">&lt;div style=&quot;float:left;margin:0.5em 0.9em 0.4em 0&quot;&gt;[[Isimumathi:7042 lores-Ebola-Zaire-CDC Photo.jpg|125px|center]]&lt;/div&gt;
&lt;div id=&quot;mp-dyk&quot; style=&quot;padding:2px 5px; font-size:95%;&quot;&gt;
'''Ubulwelwe be-Ebola''' nofana ('''EVD''') '''I-Ebola nomulwana wokopha iingazi okhambisana nomgomani''' ('''EHF''') mimulwana ebangwa bulwelwe bevayirasi ebizwa nge-Ebola. Amatshwayo athoma ukubonakala phakathi kwamalanga amabili ukuya eemvekeni eentathu ngemva sewungenwe bulwelwe lobu, njengomgomani ongapheliko, umphimbo obabako onesilonda, imisipha ebuhlungu kanye nehloko esawula kabuhlungu. Kesinye isikhathi ungahlanza, uphakanyelwe ziimbindi nesifo  sokurhuda, kuzokwenza bona amaphaphu kanye neso zingasasebenzi kuhle. 

Umulwana lo ungangena nawuthintana neengazi zomuntu ophethwe ngibo nofana umjuluko nanyana okunye nokunye okusamanzana okuvela (eenlwaneni kumaphelaphelana nofana iimfene). Kukholelwa bonyana abomaphelaphelani bakwazi  ukuphatha umulwana lo kodwana wona angaphathwa ngiwo. Kwaba khona umuntu otheleleke ngomulwana lo, umulwana lo ungatheleleka kabanye abantu godu ngesikhathi esifitjhani.
&lt;br&gt;
&lt;div style=&quot;font-size:85%; text-align:right;&quot;&gt;('''[[Ubulwelwe be-Ebola|Qala Isithasiselo...]]''')&lt;/div&gt;
&lt;/div&gt;</text>
      <sha1>opre5uo9lq139r7befjp2zs5q0tmipq</sha1>
    </revision>
    <revision>
      <id>1079</id>
      <parentid>1078</parentid>
      <timestamp>2024-10-14T13:47:01Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>10 revisions imported</comment>
      <origin>1078</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1216" sha1="opre5uo9lq139r7befjp2zs5q0tmipq" xml:space="preserve">&lt;div style=&quot;float:left;margin:0.5em 0.9em 0.4em 0&quot;&gt;[[Isimumathi:7042 lores-Ebola-Zaire-CDC Photo.jpg|125px|center]]&lt;/div&gt;
&lt;div id=&quot;mp-dyk&quot; style=&quot;padding:2px 5px; font-size:95%;&quot;&gt;
'''Ubulwelwe be-Ebola''' nofana ('''EVD''') '''I-Ebola nomulwana wokopha iingazi okhambisana nomgomani''' ('''EHF''') mimulwana ebangwa bulwelwe bevayirasi ebizwa nge-Ebola. Amatshwayo athoma ukubonakala phakathi kwamalanga amabili ukuya eemvekeni eentathu ngemva sewungenwe bulwelwe lobu, njengomgomani ongapheliko, umphimbo obabako onesilonda, imisipha ebuhlungu kanye nehloko esawula kabuhlungu. Kesinye isikhathi ungahlanza, uphakanyelwe ziimbindi nesifo  sokurhuda, kuzokwenza bona amaphaphu kanye neso zingasasebenzi kuhle. 

Umulwana lo ungangena nawuthintana neengazi zomuntu ophethwe ngibo nofana umjuluko nanyana okunye nokunye okusamanzana okuvela (eenlwaneni kumaphelaphelana nofana iimfene). Kukholelwa bonyana abomaphelaphelani bakwazi  ukuphatha umulwana lo kodwana wona angaphathwa ngiwo. Kwaba khona umuntu otheleleke ngomulwana lo, umulwana lo ungatheleleka kabanye abantu godu ngesikhathi esifitjhani.
&lt;br&gt;
&lt;div style=&quot;font-size:85%; text-align:right;&quot;&gt;('''[[Ubulwelwe be-Ebola|Qala Isithasiselo...]]''')&lt;/div&gt;
&lt;/div&gt;</text>
      <sha1>opre5uo9lq139r7befjp2zs5q0tmipq</sha1>
    </revision>
    <revision>
      <id>1900</id>
      <parentid>1079</parentid>
      <timestamp>2024-11-14T19:31:06Z</timestamp>
      <contributor>
        <username>MikitkoSynAlexeev</username>
        <id>168</id>
      </contributor>
      <origin>1900</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="948" sha1="2wgxsyazvryaorlnvs0dvz4pxdls0n5" xml:space="preserve">&lt;div style=&quot;float:left;margin:0.5em 0.9em 0.4em 0&quot;&gt;[[Isimumathi:Baron ungern.ruem.jpg|125px|center]]&lt;/div&gt;
&lt;div id=&quot;mp-dyk&quot; style=&quot;padding:2px 5px; font-size:95%;&quot;&gt;
'''U-Baron Robert Nicholas Maximilian Florer von Ungeren-Sternberg'''; Ngomhlana ali-18 kuNobayeni 1885 (mhlana ali-10 kuNobayeni 1886) , e-Graz - mhlana ali-15 kuNobayeni 1921, e-Novonikolaevsk) - umlawuli webutho le-Russia ngesikhathi se-Russian Revolution, umthengisi we-Russian White Army, umlingisi odosa phambili we-White resistance. eNtshonalanga Ephakathi. I-St. Petersburg Academy. UJosefa. Bekayinhloko yomqondo wokubuyisela umbuso ka-Genghis Khan ukusuka e-Pacific Ocean ukuya e-Caspian Sea.
Ivela emndenini wakade we-German-Baltic (Baltic) kanye nomndeni wama-baronial, ofakwe hlangana nama-matriques we-noble yazo zoke iifundazwe ezintathu ze-Russian Baltic.
&lt;br&gt;
&lt;div style=&quot;font-size:85%; text-align:right;&quot;&gt;('''[[U-Roman Ungern|Qala Isithasiselo...]]''')&lt;/div&gt;
&lt;/div&gt;</text>
      <sha1>2wgxsyazvryaorlnvs0dvz4pxdls0n5</sha1>
    </revision>
    <revision>
      <id>2567</id>
      <parentid>1900</parentid>
      <timestamp>2025-03-22T05:32:36Z</timestamp>
      <contributor>
        <username>Kvazimodo</username>
        <id>341</id>
      </contributor>
      <origin>2567</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="967" sha1="bp88qz5syfbfqpvxh7a3vf3ldhrnbav" xml:space="preserve">&lt;div style=&quot;float:left;margin:0.5em 0.9em 0.4em 0&quot;&gt;[[Isimumathi:Baron ungern.ruem.jpg|125px|center]]&lt;/div&gt;
&lt;div id=&quot;mp-dyk&quot; style=&quot;padding:2px 5px; font-size:95%;&quot;&gt;
'''[[U-Roman Ungern|U-Baron Robert Nicholas Maximilian Florer von Ungeren-Sternberg]]'''; Ngomhlana ali-18 kuNobayeni 1885 (mhlana ali-10 kuNobayeni 1886) , e-Graz - mhlana ali-15 kuNobayeni 1921, e-Novonikolaevsk) - umlawuli webutho le-Russia ngesikhathi se-Russian Revolution, umthengisi we-Russian White Army, umlingisi odosa phambili we-White resistance. eNtshonalanga Ephakathi. I-St. Petersburg Academy. UJosefa. Bekayinhloko yomqondo wokubuyisela umbuso ka-Genghis Khan ukusuka e-Pacific Ocean ukuya e-Caspian Sea.
Ivela emndenini wakade we-German-Baltic (Baltic) kanye nomndeni wama-baronial, ofakwe hlangana nama-matriques we-noble yazo zoke iifundazwe ezintathu ze-Russian Baltic.
&lt;br&gt;
&lt;div style=&quot;font-size:85%; text-align:right;&quot;&gt;('''[[U-Roman Ungern|Qala Isithasiselo...]]''')&lt;/div&gt;
&lt;/div&gt;</text>
      <sha1>bp88qz5syfbfqpvxh7a3vf3ldhrnbav</sha1>
    </revision>
    <revision>
      <id>2956</id>
      <parentid>2567</parentid>
      <timestamp>2025-06-06T18:51:52Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>Sigma</comment>
      <origin>2956</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="411" sha1="j3mn23x1dv9i981xbqfoe2rwuxz2xi5" xml:space="preserve">&lt;div style=&quot;float:left;margin:0.5em 0.9em 0.4em 0&quot;&gt;[[Isimumathi:Baron ungern.ruem.jpg|125px|center]]'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.''' '''Sigma Ohio rizz sussy skibidi sigmas will find all of you. [[A Minecraft Movie|I... Am Steve]]'''&lt;/div&gt;
&lt;div id=&quot;mp-dyk&quot; style=&quot;padding:2px 5px; font-size:95%;&quot;&gt;
&lt;div style=&quot;font-size:85%; text-align:right;&quot;&gt;&lt;/div&gt;
&lt;/div&gt;</text>
      <sha1>j3mn23x1dv9i981xbqfoe2rwuxz2xi5</sha1>
    </revision>
    <revision>
      <id>2959</id>
      <parentid>2956</parentid>
      <timestamp>2025-06-06T19:07:00Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>wsedfgr</comment>
      <origin>2959</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="431" sha1="gb51vmvgj3morghbqdf62k0fgn1tb5z" xml:space="preserve">&lt;div style=&quot;float:left;margin:0.5em 0.9em 0.4em 0&quot;&gt;[[Isimumathi:Baron ungern.ruem.jpg|125px|center]]'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.''' '''Sigma Ohio rizz sussy skibidi sigmas (as pictured above) will find all of you. [[A Minecraft Movie|I... Am Steve]]'''&lt;/div&gt;
&lt;div id=&quot;mp-dyk&quot; style=&quot;padding:2px 5px; font-size:95%;&quot;&gt;
&lt;div style=&quot;font-size:85%; text-align:right;&quot;&gt;&lt;/div&gt;
&lt;/div&gt;</text>
      <sha1>gb51vmvgj3morghbqdf62k0fgn1tb5z</sha1>
    </revision>
    <revision>
      <id>3121</id>
      <parentid>2959</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edits by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Janabaevazizbek|Janabaevazizbek]]</comment>
      <origin>2567</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="967" sha1="bp88qz5syfbfqpvxh7a3vf3ldhrnbav" xml:space="preserve">&lt;div style=&quot;float:left;margin:0.5em 0.9em 0.4em 0&quot;&gt;[[Isimumathi:Baron ungern.ruem.jpg|125px|center]]&lt;/div&gt;
&lt;div id=&quot;mp-dyk&quot; style=&quot;padding:2px 5px; font-size:95%;&quot;&gt;
'''[[U-Roman Ungern|U-Baron Robert Nicholas Maximilian Florer von Ungeren-Sternberg]]'''; Ngomhlana ali-18 kuNobayeni 1885 (mhlana ali-10 kuNobayeni 1886) , e-Graz - mhlana ali-15 kuNobayeni 1921, e-Novonikolaevsk) - umlawuli webutho le-Russia ngesikhathi se-Russian Revolution, umthengisi we-Russian White Army, umlingisi odosa phambili we-White resistance. eNtshonalanga Ephakathi. I-St. Petersburg Academy. UJosefa. Bekayinhloko yomqondo wokubuyisela umbuso ka-Genghis Khan ukusuka e-Pacific Ocean ukuya e-Caspian Sea.
Ivela emndenini wakade we-German-Baltic (Baltic) kanye nomndeni wama-baronial, ofakwe hlangana nama-matriques we-noble yazo zoke iifundazwe ezintathu ze-Russian Baltic.
&lt;br&gt;
&lt;div style=&quot;font-size:85%; text-align:right;&quot;&gt;('''[[U-Roman Ungern|Qala Isithasiselo...]]''')&lt;/div&gt;
&lt;/div&gt;</text>
      <sha1>bp88qz5syfbfqpvxh7a3vf3ldhrnbav</sha1>
    </revision>
  </page>
  <page>
    <title>Main Page/Interwikis</title>
    <ns>0</ns>
    <id>214</id>
    <revision>
      <id>1080</id>
      <timestamp>2016-02-21T06:56:21Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;&lt;center&gt;'''[[:meta:Help:Editing|Irhelebho Ngomtlolo]]'''  Uyabawa ukuzifundisa ukutlola lapha ku[[Wikipedia:Sandbox|Sandbox]].  &lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; fo...&quot;</comment>
      <origin>1080</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1655" sha1="owkisbp7875063tn4ufgydsmcdo9kzs" xml:space="preserve">&lt;center&gt;'''[[:meta:Help:Editing|Irhelebho Ngomtlolo]]'''

Uyabawa ukuzifundisa ukutlola lapha ku[[Wikipedia:Sandbox|Sandbox]].

&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:85%;width: 100%; background-color:#ddcef2; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;
== iWikipedia ngeeilimi ezinye ==
; Ama-Wikipedia Amanye ngeeiLwimi zeAfrika 
[[:af:|Afrikaans]]&amp;nbsp;·
[[:ak:|Akan]]&amp;nbsp;·
[[:am:|አማርኛ]]&amp;nbsp;·
[[:bm:|Bamanankan]]&amp;nbsp;·
[[:ny:|Chi-Chewa]]&amp;nbsp;·
[[:sn:|chiShona]]&amp;nbsp;·
[[:tum:|chiTumbuka]]&amp;nbsp;·
[[:ee:|Ɛʋɛ]]&amp;nbsp;·
[[:ff:|Fulfude]]&amp;nbsp;·
[[:ki:|Gĩkũyũ]]&amp;nbsp;·
[[:ha:|هَوُسَ]]&amp;nbsp;·
[[:ig:|Ìgbo]]&amp;nbsp;·
[[:xh:|isiXhosa]]&amp;nbsp;·
[[:rw:|Kinyarwanda]]&amp;nbsp;·
[[:rn:|Kirundi]]&amp;nbsp;·
[[:sw:|Kiswahili]]&amp;nbsp;·
[[:kg:|Kongo]]&amp;nbsp;·
[[:ln:|Lingala]]&amp;nbsp;·
[[:lg:|Luganda]]&amp;nbsp;·
[[:mg:|Malagasy]]&amp;nbsp;·
[[:arz:|مصرى]]&amp;nbsp;·
[[:om:|Oromoo]]&amp;nbsp;·
[[:sg:|Sängö]]&amp;nbsp;·
[[:st:|seSotho]]&amp;nbsp;·
[[:tn:|Setswana]]&amp;nbsp;·
[[:ss:|SiSwati]]&amp;nbsp;·
[[:so:|Soomaaliga]]&amp;nbsp;·
[[:kab:|Taqbaylit]]&amp;nbsp;·
[[:ti:|ትግርኛ]]&amp;nbsp;·
[[:ve:|Tshivenda]]&amp;nbsp;·
[[:tw:|Twi]]&amp;nbsp;·
[[:wo:|Wolof]]&amp;nbsp;·
[[:ts:|Xitsonga]]&amp;nbsp;·
[[:yo:|Yorùbá]]&amp;nbsp;·
(Uma ufuna ukuqala Ama-Wikipedia amakhulu, qala ku-bar engasesineneni)
&lt;div class=&quot;plainlinks&quot;&gt;
; Amaphrojekthi afana
: [http://meta.wikipedia.org Meta-Wikipedia]&amp;nbsp;· [http://wiktionary.org Wiktionary]&amp;nbsp;· [http://wikibooks.org Wikibooks]&amp;nbsp;· [http://wikiquote.org Wikiquote]&amp;nbsp;· [http://wikisource.org Wikisource]
&lt;/div&gt;
&lt;/center&gt;
|}
---</text>
      <sha1>owkisbp7875063tn4ufgydsmcdo9kzs</sha1>
    </revision>
    <revision>
      <id>1081</id>
      <parentid>1080</parentid>
      <timestamp>2016-02-21T06:56:44Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1081</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1652" sha1="l615w5izlj8kq9a11lf5laoo5fcskc1" xml:space="preserve">&lt;center&gt;'''[[:meta:Help:Editing|Irhelebho Ngomtlolo]]'''

Uyabawa ukuzifundisa ukutlola lapha ku[[Wikipedia:Sandbox|Sandbox]].

&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:85%;width: 100%; background-color:#ddcef2; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;
== iWikipedia ngeeilimi ezinye ==
; Ama-Wikipedia Amanye ngeeiLwimi zeAfrika 
[[:af:|Afrikaans]]&amp;nbsp;·
[[:ak:|Akan]]&amp;nbsp;·
[[:am:|አማርኛ]]&amp;nbsp;·
[[:bm:|Bamanankan]]&amp;nbsp;·
[[:ny:|Chi-Chewa]]&amp;nbsp;·
[[:sn:|chiShona]]&amp;nbsp;·
[[:tum:|chiTumbuka]]&amp;nbsp;·
[[:ee:|Ɛʋɛ]]&amp;nbsp;·
[[:ff:|Fulfude]]&amp;nbsp;·
[[:ki:|Gĩkũyũ]]&amp;nbsp;·
[[:ha:|هَوُسَ]]&amp;nbsp;·
[[:ig:|Ìgbo]]&amp;nbsp;·
[[:xh:|isiXhosa]]&amp;nbsp;·
[[:rw:|Kinyarwanda]]&amp;nbsp;·
[[:rn:|Kirundi]]&amp;nbsp;·
[[:sw:|Kiswahili]]&amp;nbsp;·
[[:kg:|Kongo]]&amp;nbsp;·
[[:ln:|Lingala]]&amp;nbsp;·
[[:lg:|Luganda]]&amp;nbsp;·
[[:mg:|Malagasy]]&amp;nbsp;·
[[:arz:|مصرى]]&amp;nbsp;·
[[:om:|Oromoo]]&amp;nbsp;·
[[:sg:|Sängö]]&amp;nbsp;·
[[:st:|seSotho]]&amp;nbsp;·
[[:tn:|Setswana]]&amp;nbsp;·
[[:ss:|SiSwati]]&amp;nbsp;·
[[:so:|Soomaaliga]]&amp;nbsp;·
[[:kab:|Taqbaylit]]&amp;nbsp;·
[[:ti:|ትግርኛ]]&amp;nbsp;·
[[:ve:|Tshivenda]]&amp;nbsp;·
[[:tw:|Twi]]&amp;nbsp;·
[[:wo:|Wolof]]&amp;nbsp;·
[[:ts:|Xitsonga]]&amp;nbsp;·
[[:yo:|Yorùbá]]&amp;nbsp;·
(Uma ufuna ukuqala Ama-Wikipedia amakhulu, qala ku-bar engasesineneni)
&lt;div class=&quot;plainlinks&quot;&gt;
; Amaphrojekthi afana
: [http://meta.wikipedia.org Meta-Wikipedia]&amp;nbsp;· [http://wiktionary.org Wiktionary]&amp;nbsp;· [http://wikibooks.org Wikibooks]&amp;nbsp;· [http://wikiquote.org Wikiquote]&amp;nbsp;· [http://wikisource.org Wikisource]
&lt;/div&gt;
&lt;/center&gt;
---</text>
      <sha1>l615w5izlj8kq9a11lf5laoo5fcskc1</sha1>
    </revision>
    <revision>
      <id>1082</id>
      <parentid>1081</parentid>
      <timestamp>2016-02-21T06:57:28Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1082</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1669" sha1="6bo0yze3nwdekfw7suaj1nys1tah271" xml:space="preserve">&lt;center&gt;'''[[:meta:Help:Editing|Irhelebho Ngomtlolo]]'''

Uyabawa ukuzifundisa ukutlola lapha ku[[Wikipedia:Sandbox|Sandbox]].

&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:85%;width: 100%; background-color:#ddcef2; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;
== iWikipedia ngeeilimi ezinye ==
; Ama-Wikipedia Amanye ngeeiLwimi zeAfrika 
[[:af:|Afrikaans]]&amp;nbsp;·
[[:ak:|Akan]]&amp;nbsp;·
[[:am:|አማርኛ]]&amp;nbsp;·
[[:bm:|Bamanankan]]&amp;nbsp;·
[[:ny:|Chi-Chewa]]&amp;nbsp;·
[[:sn:|chiShona]]&amp;nbsp;·
[[:tum:|chiTumbuka]]&amp;nbsp;·
[[:ee:|Ɛʋɛ]]&amp;nbsp;·
[[:ff:|Fulfude]]&amp;nbsp;·
[[:ki:|Gĩkũyũ]]&amp;nbsp;·
[[:ha:|هَوُسَ]]&amp;nbsp;·
[[:ig:|Ìgbo]]&amp;nbsp;·
[[:xh:|isiXhosa]]&amp;nbsp;·
[[:rw:|Kinyarwanda]]&amp;nbsp;·
[[:rn:|Kirundi]]&amp;nbsp;·
[[:sw:|Kiswahili]]&amp;nbsp;·
[[:kg:|Kongo]]&amp;nbsp;·
[[:ln:|Lingala]]&amp;nbsp;·
[[:lg:|Luganda]]&amp;nbsp;·
[[:mg:|Malagasy]]&amp;nbsp;·
[[:arz:|مصرى]]&amp;nbsp;·
[[:om:|Oromoo]]&amp;nbsp;·
[[:sg:|Sängö]]&amp;nbsp;·
[[:st:|seSotho]]&amp;nbsp;·
[[:tn:|Setswana]]&amp;nbsp;·
[[:ss:|SiSwati]]&amp;nbsp;·
[[:so:|Soomaaliga]]&amp;nbsp;·
[[:kab:|Taqbaylit]]&amp;nbsp;·
[[:ti:|ትግርኛ]]&amp;nbsp;·
[[:ve:|Tshivenda]]&amp;nbsp;·
[[:tw:|Twi]]&amp;nbsp;·
[[:wo:|Wolof]]&amp;nbsp;·
[[:ts:|Xitsonga]]&amp;nbsp;·
[[:yo:|Yorùbá]]&amp;nbsp;·
(Uma ufuna ukuqala Ama-Wikipedia amakhulu, qala ku-bar engasesineneni)
&lt;div class=&quot;plainlinks&quot;&gt;
; Amaphrojekthi afana
: [http://meta.wikipedia.org Meta-Wikipedia]&amp;nbsp;· [http://wiktionary.org Wiktionary]&amp;nbsp;· [http://wikibooks.org Wikibooks]&amp;nbsp;· [http://wikiquote.org Wikiquote]&amp;nbsp;· [http://wikisource.org Wikisource]
&lt;/div&gt;
&lt;/center&gt;
---
_NOTOC_ _NOEDIT_</text>
      <sha1>6bo0yze3nwdekfw7suaj1nys1tah271</sha1>
    </revision>
    <revision>
      <id>1083</id>
      <parentid>1082</parentid>
      <timestamp>2016-02-21T06:58:08Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1083</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1652" sha1="l615w5izlj8kq9a11lf5laoo5fcskc1" xml:space="preserve">&lt;center&gt;'''[[:meta:Help:Editing|Irhelebho Ngomtlolo]]'''

Uyabawa ukuzifundisa ukutlola lapha ku[[Wikipedia:Sandbox|Sandbox]].

&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:85%;width: 100%; background-color:#ddcef2; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;
== iWikipedia ngeeilimi ezinye ==
; Ama-Wikipedia Amanye ngeeiLwimi zeAfrika 
[[:af:|Afrikaans]]&amp;nbsp;·
[[:ak:|Akan]]&amp;nbsp;·
[[:am:|አማርኛ]]&amp;nbsp;·
[[:bm:|Bamanankan]]&amp;nbsp;·
[[:ny:|Chi-Chewa]]&amp;nbsp;·
[[:sn:|chiShona]]&amp;nbsp;·
[[:tum:|chiTumbuka]]&amp;nbsp;·
[[:ee:|Ɛʋɛ]]&amp;nbsp;·
[[:ff:|Fulfude]]&amp;nbsp;·
[[:ki:|Gĩkũyũ]]&amp;nbsp;·
[[:ha:|هَوُسَ]]&amp;nbsp;·
[[:ig:|Ìgbo]]&amp;nbsp;·
[[:xh:|isiXhosa]]&amp;nbsp;·
[[:rw:|Kinyarwanda]]&amp;nbsp;·
[[:rn:|Kirundi]]&amp;nbsp;·
[[:sw:|Kiswahili]]&amp;nbsp;·
[[:kg:|Kongo]]&amp;nbsp;·
[[:ln:|Lingala]]&amp;nbsp;·
[[:lg:|Luganda]]&amp;nbsp;·
[[:mg:|Malagasy]]&amp;nbsp;·
[[:arz:|مصرى]]&amp;nbsp;·
[[:om:|Oromoo]]&amp;nbsp;·
[[:sg:|Sängö]]&amp;nbsp;·
[[:st:|seSotho]]&amp;nbsp;·
[[:tn:|Setswana]]&amp;nbsp;·
[[:ss:|SiSwati]]&amp;nbsp;·
[[:so:|Soomaaliga]]&amp;nbsp;·
[[:kab:|Taqbaylit]]&amp;nbsp;·
[[:ti:|ትግርኛ]]&amp;nbsp;·
[[:ve:|Tshivenda]]&amp;nbsp;·
[[:tw:|Twi]]&amp;nbsp;·
[[:wo:|Wolof]]&amp;nbsp;·
[[:ts:|Xitsonga]]&amp;nbsp;·
[[:yo:|Yorùbá]]&amp;nbsp;·
(Uma ufuna ukuqala Ama-Wikipedia amakhulu, qala ku-bar engasesineneni)
&lt;div class=&quot;plainlinks&quot;&gt;
; Amaphrojekthi afana
: [http://meta.wikipedia.org Meta-Wikipedia]&amp;nbsp;· [http://wiktionary.org Wiktionary]&amp;nbsp;· [http://wikibooks.org Wikibooks]&amp;nbsp;· [http://wikiquote.org Wikiquote]&amp;nbsp;· [http://wikisource.org Wikisource]
&lt;/div&gt;
&lt;/center&gt;
---</text>
      <sha1>l615w5izlj8kq9a11lf5laoo5fcskc1</sha1>
    </revision>
    <revision>
      <id>1084</id>
      <parentid>1083</parentid>
      <timestamp>2016-02-21T06:58:26Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1084</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1648" sha1="t35ve52yfjcftu0vn2j7iwy13bdoq9w" xml:space="preserve">&lt;center&gt;'''[[:meta:Help:Editing|Irhelebho Ngomtlolo]]'''

Uyabawa ukuzifundisa ukutlola lapha ku[[Wikipedia:Sandbox|Sandbox]].

&lt;div id=&quot;mpbanner&quot; style=&quot;text-align:center; font-size:85%;width: 100%; background-color:#ddcef2; padding: .2em 0; border: 1px solid #BFB1A3; color: #000; margin-top:+.2em;font-family:verdana,arial,helvetica&quot;&gt;
== iWikipedia ngeeilimi ezinye ==
; Ama-Wikipedia Amanye ngeeiLwimi zeAfrika 
[[:af:|Afrikaans]]&amp;nbsp;·
[[:ak:|Akan]]&amp;nbsp;·
[[:am:|አማርኛ]]&amp;nbsp;·
[[:bm:|Bamanankan]]&amp;nbsp;·
[[:ny:|Chi-Chewa]]&amp;nbsp;·
[[:sn:|chiShona]]&amp;nbsp;·
[[:tum:|chiTumbuka]]&amp;nbsp;·
[[:ee:|Ɛʋɛ]]&amp;nbsp;·
[[:ff:|Fulfude]]&amp;nbsp;·
[[:ki:|Gĩkũyũ]]&amp;nbsp;·
[[:ha:|هَوُسَ]]&amp;nbsp;·
[[:ig:|Ìgbo]]&amp;nbsp;·
[[:xh:|isiXhosa]]&amp;nbsp;·
[[:rw:|Kinyarwanda]]&amp;nbsp;·
[[:rn:|Kirundi]]&amp;nbsp;·
[[:sw:|Kiswahili]]&amp;nbsp;·
[[:kg:|Kongo]]&amp;nbsp;·
[[:ln:|Lingala]]&amp;nbsp;·
[[:lg:|Luganda]]&amp;nbsp;·
[[:mg:|Malagasy]]&amp;nbsp;·
[[:arz:|مصرى]]&amp;nbsp;·
[[:om:|Oromoo]]&amp;nbsp;·
[[:sg:|Sängö]]&amp;nbsp;·
[[:st:|seSotho]]&amp;nbsp;·
[[:tn:|Setswana]]&amp;nbsp;·
[[:ss:|SiSwati]]&amp;nbsp;·
[[:so:|Soomaaliga]]&amp;nbsp;·
[[:kab:|Taqbaylit]]&amp;nbsp;·
[[:ti:|ትግርኛ]]&amp;nbsp;·
[[:ve:|Tshivenda]]&amp;nbsp;·
[[:tw:|Twi]]&amp;nbsp;·
[[:wo:|Wolof]]&amp;nbsp;·
[[:ts:|Xitsonga]]&amp;nbsp;·
[[:yo:|Yorùbá]]&amp;nbsp;·
(Uma ufuna ukuqala Ama-Wikipedia amakhulu, qala ku-bar engasesineneni)
&lt;div class=&quot;plainlinks&quot;&gt;
; Amaphrojekthi afana
: [http://meta.wikipedia.org Meta-Wikipedia]&amp;nbsp;· [http://wiktionary.org Wiktionary]&amp;nbsp;· [http://wikibooks.org Wikibooks]&amp;nbsp;· [http://wikiquote.org Wikiquote]&amp;nbsp;· [http://wikisource.org Wikisource]
&lt;/div&gt;
&lt;/center&gt;</text>
      <sha1>t35ve52yfjcftu0vn2j7iwy13bdoq9w</sha1>
    </revision>
    <revision>
      <id>1085</id>
      <parentid>1084</parentid>
      <timestamp>2016-02-21T07:09:36Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1085</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1430" sha1="it7gqez4havxiqd3enl9gz4buc98o3c" xml:space="preserve">&lt;center&gt;'''[[:meta:Help:Editing|Irhelebho Ngomtlolo]]'''&lt;/centre&gt;

Uyabawa ukuzifundisa ukutlola lapha ku[[Wikipedia:Sandbox|Sandbox]].

== iWikipedia ngeeilimi ezinye ==
; Ama-Wikipedia Amanye ngeeiLwimi zeAfrika 
[[:af:|Afrikaans]]&amp;nbsp;·
[[:ak:|Akan]]&amp;nbsp;·
[[:am:|አማርኛ]]&amp;nbsp;·
[[:bm:|Bamanankan]]&amp;nbsp;·
[[:ny:|Chi-Chewa]]&amp;nbsp;·
[[:sn:|chiShona]]&amp;nbsp;·
[[:tum:|chiTumbuka]]&amp;nbsp;·
[[:ee:|Ɛʋɛ]]&amp;nbsp;·
[[:ff:|Fulfude]]&amp;nbsp;·
[[:ki:|Gĩkũyũ]]&amp;nbsp;·
[[:ha:|هَوُسَ]]&amp;nbsp;·
[[:ig:|Ìgbo]]&amp;nbsp;·
[[:xh:|isiXhosa]]&amp;nbsp;·
[[:rw:|Kinyarwanda]]&amp;nbsp;·
[[:rn:|Kirundi]]&amp;nbsp;·
[[:sw:|Kiswahili]]&amp;nbsp;·
[[:kg:|Kongo]]&amp;nbsp;·
[[:ln:|Lingala]]&amp;nbsp;·
[[:lg:|Luganda]]&amp;nbsp;·
[[:mg:|Malagasy]]&amp;nbsp;·
[[:arz:|مصرى]]&amp;nbsp;·
[[:om:|Oromoo]]&amp;nbsp;·
[[:sg:|Sängö]]&amp;nbsp;·
[[:st:|seSotho]]&amp;nbsp;·
[[:tn:|Setswana]]&amp;nbsp;·
[[:ss:|SiSwati]]&amp;nbsp;·
[[:so:|Soomaaliga]]&amp;nbsp;·
[[:kab:|Taqbaylit]]&amp;nbsp;·
[[:ti:|ትግርኛ]]&amp;nbsp;·
[[:ve:|Tshivenda]]&amp;nbsp;·
[[:tw:|Twi]]&amp;nbsp;·
[[:wo:|Wolof]]&amp;nbsp;·
[[:ts:|Xitsonga]]&amp;nbsp;·
[[:yo:|Yorùbá]]&amp;nbsp;·
(Uma ufuna ukuqala Ama-Wikipedia amakhulu, qala ku-bar engasesineneni)
&lt;div class=&quot;plainlinks&quot;&gt;
; Amaphrojekthi afana
: [http://meta.wikipedia.org Meta-Wikipedia]&amp;nbsp;· [http://wiktionary.org Wiktionary]&amp;nbsp;· [http://wikibooks.org Wikibooks]&amp;nbsp;· [http://wikiquote.org Wikiquote]&amp;nbsp;· [http://wikisource.org Wikisource]</text>
      <sha1>it7gqez4havxiqd3enl9gz4buc98o3c</sha1>
    </revision>
    <revision>
      <id>1086</id>
      <parentid>1085</parentid>
      <timestamp>2016-02-21T07:11:55Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1086</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1430" sha1="kuwsb576ihi7wd413y5yg5nztzi758r" xml:space="preserve">&lt;center&gt;'''[[:meta:Help:Editing|Irhelebho Ngomtlolo]]'''&lt;/center&gt;

Uyabawa ukuzifundisa ukutlola lapha ku[[Wikipedia:Sandbox|Sandbox]].

== iWikipedia ngeeilimi ezinye ==
; Ama-Wikipedia Amanye ngeeiLwimi zeAfrika 
[[:af:|Afrikaans]]&amp;nbsp;·
[[:ak:|Akan]]&amp;nbsp;·
[[:am:|አማርኛ]]&amp;nbsp;·
[[:bm:|Bamanankan]]&amp;nbsp;·
[[:ny:|Chi-Chewa]]&amp;nbsp;·
[[:sn:|chiShona]]&amp;nbsp;·
[[:tum:|chiTumbuka]]&amp;nbsp;·
[[:ee:|Ɛʋɛ]]&amp;nbsp;·
[[:ff:|Fulfude]]&amp;nbsp;·
[[:ki:|Gĩkũyũ]]&amp;nbsp;·
[[:ha:|هَوُسَ]]&amp;nbsp;·
[[:ig:|Ìgbo]]&amp;nbsp;·
[[:xh:|isiXhosa]]&amp;nbsp;·
[[:rw:|Kinyarwanda]]&amp;nbsp;·
[[:rn:|Kirundi]]&amp;nbsp;·
[[:sw:|Kiswahili]]&amp;nbsp;·
[[:kg:|Kongo]]&amp;nbsp;·
[[:ln:|Lingala]]&amp;nbsp;·
[[:lg:|Luganda]]&amp;nbsp;·
[[:mg:|Malagasy]]&amp;nbsp;·
[[:arz:|مصرى]]&amp;nbsp;·
[[:om:|Oromoo]]&amp;nbsp;·
[[:sg:|Sängö]]&amp;nbsp;·
[[:st:|seSotho]]&amp;nbsp;·
[[:tn:|Setswana]]&amp;nbsp;·
[[:ss:|SiSwati]]&amp;nbsp;·
[[:so:|Soomaaliga]]&amp;nbsp;·
[[:kab:|Taqbaylit]]&amp;nbsp;·
[[:ti:|ትግርኛ]]&amp;nbsp;·
[[:ve:|Tshivenda]]&amp;nbsp;·
[[:tw:|Twi]]&amp;nbsp;·
[[:wo:|Wolof]]&amp;nbsp;·
[[:ts:|Xitsonga]]&amp;nbsp;·
[[:yo:|Yorùbá]]&amp;nbsp;·
(Uma ufuna ukuqala Ama-Wikipedia amakhulu, qala ku-bar engasesineneni)
&lt;div class=&quot;plainlinks&quot;&gt;
; Amaphrojekthi afana
: [http://meta.wikipedia.org Meta-Wikipedia]&amp;nbsp;· [http://wiktionary.org Wiktionary]&amp;nbsp;· [http://wikibooks.org Wikibooks]&amp;nbsp;· [http://wikiquote.org Wikiquote]&amp;nbsp;· [http://wikisource.org Wikisource]</text>
      <sha1>kuwsb576ihi7wd413y5yg5nztzi758r</sha1>
    </revision>
    <revision>
      <id>1087</id>
      <parentid>1086</parentid>
      <timestamp>2016-02-21T07:12:24Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1087</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1430" sha1="fy8v0p7lsw7g1ll1im1dhhq7c2zdapt" xml:space="preserve">&lt;center&gt;'''[[:meta:Help:Editing|Irhelebho Ngomtlolo]]'''

Uyabawa ukuzifundisa ukutlola lapha ku[[Wikipedia:Sandbox|Sandbox]].&lt;/center&gt;

== iWikipedia ngeeilimi ezinye ==
; Ama-Wikipedia Amanye ngeeiLwimi zeAfrika 
[[:af:|Afrikaans]]&amp;nbsp;·
[[:ak:|Akan]]&amp;nbsp;·
[[:am:|አማርኛ]]&amp;nbsp;·
[[:bm:|Bamanankan]]&amp;nbsp;·
[[:ny:|Chi-Chewa]]&amp;nbsp;·
[[:sn:|chiShona]]&amp;nbsp;·
[[:tum:|chiTumbuka]]&amp;nbsp;·
[[:ee:|Ɛʋɛ]]&amp;nbsp;·
[[:ff:|Fulfude]]&amp;nbsp;·
[[:ki:|Gĩkũyũ]]&amp;nbsp;·
[[:ha:|هَوُسَ]]&amp;nbsp;·
[[:ig:|Ìgbo]]&amp;nbsp;·
[[:xh:|isiXhosa]]&amp;nbsp;·
[[:rw:|Kinyarwanda]]&amp;nbsp;·
[[:rn:|Kirundi]]&amp;nbsp;·
[[:sw:|Kiswahili]]&amp;nbsp;·
[[:kg:|Kongo]]&amp;nbsp;·
[[:ln:|Lingala]]&amp;nbsp;·
[[:lg:|Luganda]]&amp;nbsp;·
[[:mg:|Malagasy]]&amp;nbsp;·
[[:arz:|مصرى]]&amp;nbsp;·
[[:om:|Oromoo]]&amp;nbsp;·
[[:sg:|Sängö]]&amp;nbsp;·
[[:st:|seSotho]]&amp;nbsp;·
[[:tn:|Setswana]]&amp;nbsp;·
[[:ss:|SiSwati]]&amp;nbsp;·
[[:so:|Soomaaliga]]&amp;nbsp;·
[[:kab:|Taqbaylit]]&amp;nbsp;·
[[:ti:|ትግርኛ]]&amp;nbsp;·
[[:ve:|Tshivenda]]&amp;nbsp;·
[[:tw:|Twi]]&amp;nbsp;·
[[:wo:|Wolof]]&amp;nbsp;·
[[:ts:|Xitsonga]]&amp;nbsp;·
[[:yo:|Yorùbá]]&amp;nbsp;·
(Uma ufuna ukuqala Ama-Wikipedia amakhulu, qala ku-bar engasesineneni)
&lt;div class=&quot;plainlinks&quot;&gt;
; Amaphrojekthi afana
: [http://meta.wikipedia.org Meta-Wikipedia]&amp;nbsp;· [http://wiktionary.org Wiktionary]&amp;nbsp;· [http://wikibooks.org Wikibooks]&amp;nbsp;· [http://wikiquote.org Wikiquote]&amp;nbsp;· [http://wikisource.org Wikisource]</text>
      <sha1>fy8v0p7lsw7g1ll1im1dhhq7c2zdapt</sha1>
    </revision>
    <revision>
      <id>1088</id>
      <parentid>1087</parentid>
      <timestamp>2016-02-21T07:12:46Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1088</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1434" sha1="8h5me3vqc0n4f6xhgt4ly81nsrpyequ" xml:space="preserve">&lt;center&gt;'''[[:meta:Help:Editing|Irhelebho Ngomtlolo]]'''
&lt;br&gt;
Uyabawa ukuzifundisa ukutlola lapha ku[[Wikipedia:Sandbox|Sandbox]].&lt;/center&gt;

== iWikipedia ngeeilimi ezinye ==
; Ama-Wikipedia Amanye ngeeiLwimi zeAfrika 
[[:af:|Afrikaans]]&amp;nbsp;·
[[:ak:|Akan]]&amp;nbsp;·
[[:am:|አማርኛ]]&amp;nbsp;·
[[:bm:|Bamanankan]]&amp;nbsp;·
[[:ny:|Chi-Chewa]]&amp;nbsp;·
[[:sn:|chiShona]]&amp;nbsp;·
[[:tum:|chiTumbuka]]&amp;nbsp;·
[[:ee:|Ɛʋɛ]]&amp;nbsp;·
[[:ff:|Fulfude]]&amp;nbsp;·
[[:ki:|Gĩkũyũ]]&amp;nbsp;·
[[:ha:|هَوُسَ]]&amp;nbsp;·
[[:ig:|Ìgbo]]&amp;nbsp;·
[[:xh:|isiXhosa]]&amp;nbsp;·
[[:rw:|Kinyarwanda]]&amp;nbsp;·
[[:rn:|Kirundi]]&amp;nbsp;·
[[:sw:|Kiswahili]]&amp;nbsp;·
[[:kg:|Kongo]]&amp;nbsp;·
[[:ln:|Lingala]]&amp;nbsp;·
[[:lg:|Luganda]]&amp;nbsp;·
[[:mg:|Malagasy]]&amp;nbsp;·
[[:arz:|مصرى]]&amp;nbsp;·
[[:om:|Oromoo]]&amp;nbsp;·
[[:sg:|Sängö]]&amp;nbsp;·
[[:st:|seSotho]]&amp;nbsp;·
[[:tn:|Setswana]]&amp;nbsp;·
[[:ss:|SiSwati]]&amp;nbsp;·
[[:so:|Soomaaliga]]&amp;nbsp;·
[[:kab:|Taqbaylit]]&amp;nbsp;·
[[:ti:|ትግርኛ]]&amp;nbsp;·
[[:ve:|Tshivenda]]&amp;nbsp;·
[[:tw:|Twi]]&amp;nbsp;·
[[:wo:|Wolof]]&amp;nbsp;·
[[:ts:|Xitsonga]]&amp;nbsp;·
[[:yo:|Yorùbá]]&amp;nbsp;·
(Uma ufuna ukuqala Ama-Wikipedia amakhulu, qala ku-bar engasesineneni)
&lt;div class=&quot;plainlinks&quot;&gt;
; Amaphrojekthi afana
: [http://meta.wikipedia.org Meta-Wikipedia]&amp;nbsp;· [http://wiktionary.org Wiktionary]&amp;nbsp;· [http://wikibooks.org Wikibooks]&amp;nbsp;· [http://wikiquote.org Wikiquote]&amp;nbsp;· [http://wikisource.org Wikisource]</text>
      <sha1>8h5me3vqc0n4f6xhgt4ly81nsrpyequ</sha1>
    </revision>
    <revision>
      <id>1089</id>
      <parentid>1088</parentid>
      <timestamp>2016-02-21T07:17:08Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1089</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1432" sha1="lgtpgq1kcuntunpakodexhw1rt191jv" xml:space="preserve">&lt;center&gt;'''[[:meta:Help:Editing|Irhelebho Ngomtlolo]]'''&lt;br&gt;
Uyabawa ukuzifundisa ukutlola lapha ku[[Wikipedia:Sandbox|Sandbox]].&lt;/center&gt;
== iWikipedia ngeeilimi ezinye ==
; Ama-Wikipedia Amanye ngeeiLwimi zeAfrika 
[[:af:|Afrikaans]]&amp;nbsp;·
[[:ak:|Akan]]&amp;nbsp;·
[[:am:|አማርኛ]]&amp;nbsp;·
[[:bm:|Bamanankan]]&amp;nbsp;·
[[:ny:|Chi-Chewa]]&amp;nbsp;·
[[:sn:|chiShona]]&amp;nbsp;·
[[:tum:|chiTumbuka]]&amp;nbsp;·
[[:ee:|Ɛʋɛ]]&amp;nbsp;·
[[:ff:|Fulfude]]&amp;nbsp;·
[[:ki:|Gĩkũyũ]]&amp;nbsp;·
[[:ha:|هَوُسَ]]&amp;nbsp;·
[[:ig:|Ìgbo]]&amp;nbsp;·
[[:xh:|isiXhosa]]&amp;nbsp;·
[[:rw:|Kinyarwanda]]&amp;nbsp;·
[[:rn:|Kirundi]]&amp;nbsp;·
[[:sw:|Kiswahili]]&amp;nbsp;·
[[:kg:|Kongo]]&amp;nbsp;·
[[:ln:|Lingala]]&amp;nbsp;·
[[:lg:|Luganda]]&amp;nbsp;·
[[:mg:|Malagasy]]&amp;nbsp;·
[[:arz:|مصرى]]&amp;nbsp;·
[[:om:|Oromoo]]&amp;nbsp;·
[[:sg:|Sängö]]&amp;nbsp;·
[[:st:|seSotho]]&amp;nbsp;·
[[:tn:|Setswana]]&amp;nbsp;·
[[:ss:|SiSwati]]&amp;nbsp;·
[[:so:|Soomaaliga]]&amp;nbsp;·
[[:kab:|Taqbaylit]]&amp;nbsp;·
[[:ti:|ትግርኛ]]&amp;nbsp;·
[[:ve:|Tshivenda]]&amp;nbsp;·
[[:tw:|Twi]]&amp;nbsp;·
[[:wo:|Wolof]]&amp;nbsp;·
[[:ts:|Xitsonga]]&amp;nbsp;·
[[:yo:|Yorùbá]]&amp;nbsp;·
(Uma ufuna ukuqala Ama-Wikipedia amakhulu, qala ku-bar engasesineneni)
&lt;div class=&quot;plainlinks&quot;&gt;
; Amaphrojekthi afana
: [http://meta.wikipedia.org Meta-Wikipedia]&amp;nbsp;· [http://wiktionary.org Wiktionary]&amp;nbsp;· [http://wikibooks.org Wikibooks]&amp;nbsp;· [http://wikiquote.org Wikiquote]&amp;nbsp;· [http://wikisource.org Wikisource]</text>
      <sha1>lgtpgq1kcuntunpakodexhw1rt191jv</sha1>
    </revision>
    <revision>
      <id>1090</id>
      <parentid>1089</parentid>
      <timestamp>2016-02-21T07:48:05Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1090</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1431" sha1="iqqvozidrxwgs607c79722lrjfity03" xml:space="preserve">&lt;center&gt;'''[[:meta:Help:Editing|Irhelebho Ngomtlolo]]'''&lt;br&gt;
Uyabawa ukuzifundisa ukutlola lapha ku[[Wikipedia:Sandbox|Sandbox]].&lt;/center&gt;
== iWikipedia ngeeilimi ezinye ==
; Ama-Wikipedia Amanye ngeeiLwimi zeAfrika 
[[:af:|Afrikaans]]&amp;nbsp;·
[[:ak:|Akan]]&amp;nbsp;·
[[:am:|አማርኛ]]&amp;nbsp;·
[[:bm:|Bamanankan]]&amp;nbsp;·
[[:ny:|Chi-Chewa]]&amp;nbsp;·
[[:sn:|chiShona]]&amp;nbsp;·
[[:tum:|chiTumbuka]]&amp;nbsp;·
[[:ee:|Ɛʋɛ]]&amp;nbsp;·
[[:ff:|Fulfude]]&amp;nbsp;·
[[:ki:|Gĩkũyũ]]&amp;nbsp;·
[[:ha:|هَوُسَ]]&amp;nbsp;·
[[:ig:|Ìgbo]]&amp;nbsp;·
[[:xh:|isiXhosa]]&amp;nbsp;·
[[:rw:|Kinyarwanda]]&amp;nbsp;·
[[:rn:|Kirundi]]&amp;nbsp;·
[[:sw:|Kiswahili]]&amp;nbsp;·
[[:kg:|Kongo]]&amp;nbsp;·
[[:ln:|Lingala]]&amp;nbsp;·
[[:lg:|Luganda]]&amp;nbsp;·
[[:mg:|Malagasy]]&amp;nbsp;·
[[:arz:|مصرى]]&amp;nbsp;·
[[:om:|Oromoo]]&amp;nbsp;·
[[:sg:|Sängö]]&amp;nbsp;·
[[:st:|seSotho]]&amp;nbsp;·
[[:tn:|Setswana]]&amp;nbsp;·
[[:ss:|SiSwati]]&amp;nbsp;·
[[:so:|Soomaaliga]]&amp;nbsp;·
[[:kab:|Taqbaylit]]&amp;nbsp;·
[[:ti:|ትግርኛ]]&amp;nbsp;·
[[:ve:|Tshivenda]]&amp;nbsp;·
[[:tw:|Twi]]&amp;nbsp;·
[[:wo:|Wolof]]&amp;nbsp;·
[[:ts:|Xitsonga]]&amp;nbsp;·
[[:yo:|Yorùbá]]&amp;nbsp;·
(Uma ufuna ukuqala Ama-Wikipedia khulu, qala ku-bar engasesineneni)
&lt;div class=&quot;plainlinks&quot;&gt;
; Amaphrojekthi afanako
: [http://meta.wikipedia.org Meta-Wikipedia]&amp;nbsp;· [http://wiktionary.org Wiktionary]&amp;nbsp;· [http://wikibooks.org Wikibooks]&amp;nbsp;· [http://wikiquote.org Wikiquote]&amp;nbsp;· [http://wikisource.org Wikisource]</text>
      <sha1>iqqvozidrxwgs607c79722lrjfity03</sha1>
    </revision>
    <revision>
      <id>1091</id>
      <parentid>1090</parentid>
      <timestamp>2016-02-26T23:46:15Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1091</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1563" sha1="au67w9deu91400kre2xqrttv3d88z1v" xml:space="preserve">&lt;center&gt;'''[[:meta:Help:Editing|Irhelebho Ngomtlolo]]'''&lt;br&gt;
Uyabawa ukuzifundisa ukutlola lapha ku[[Wikipedia:Sandbox|Sandbox]].
Cala amakhasi aqakathekile, esibawa bona urhelepe kuwo: [[Vital 10|10]] &amp;nbsp;· [[Vital 100|100]] &amp;nbsp;· [[Vital 1000|1000]]&lt;/center&gt;&lt;br&gt;
== iWikipedia ngeeilimi ezinye ==
; Ama-Wikipedia Amanye ngeeiLwimi zeAfrika 
[[:af:|Afrikaans]]&amp;nbsp;·
[[:ak:|Akan]]&amp;nbsp;·
[[:am:|አማርኛ]]&amp;nbsp;·
[[:bm:|Bamanankan]]&amp;nbsp;·
[[:ny:|Chi-Chewa]]&amp;nbsp;·
[[:sn:|chiShona]]&amp;nbsp;·
[[:tum:|chiTumbuka]]&amp;nbsp;·
[[:ee:|Ɛʋɛ]]&amp;nbsp;·
[[:ff:|Fulfude]]&amp;nbsp;·
[[:ki:|Gĩkũyũ]]&amp;nbsp;·
[[:ha:|هَوُسَ]]&amp;nbsp;·
[[:ig:|Ìgbo]]&amp;nbsp;·
[[:xh:|isiXhosa]]&amp;nbsp;·
[[:rw:|Kinyarwanda]]&amp;nbsp;·
[[:rn:|Kirundi]]&amp;nbsp;·
[[:sw:|Kiswahili]]&amp;nbsp;·
[[:kg:|Kongo]]&amp;nbsp;·
[[:ln:|Lingala]]&amp;nbsp;·
[[:lg:|Luganda]]&amp;nbsp;·
[[:mg:|Malagasy]]&amp;nbsp;·
[[:arz:|مصرى]]&amp;nbsp;·
[[:om:|Oromoo]]&amp;nbsp;·
[[:sg:|Sängö]]&amp;nbsp;·
[[:st:|seSotho]]&amp;nbsp;·
[[:tn:|Setswana]]&amp;nbsp;·
[[:ss:|SiSwati]]&amp;nbsp;·
[[:so:|Soomaaliga]]&amp;nbsp;·
[[:kab:|Taqbaylit]]&amp;nbsp;·
[[:ti:|ትግርኛ]]&amp;nbsp;·
[[:ve:|Tshivenda]]&amp;nbsp;·
[[:tw:|Twi]]&amp;nbsp;·
[[:wo:|Wolof]]&amp;nbsp;·
[[:ts:|Xitsonga]]&amp;nbsp;·
[[:yo:|Yorùbá]]&amp;nbsp;·
(Uma ufuna ukuqala Ama-Wikipedia khulu, qala ku-bar engasesineneni)
&lt;div class=&quot;plainlinks&quot;&gt;
; Amaphrojekthi afanako
: [http://meta.wikipedia.org Meta-Wikipedia]&amp;nbsp;· [http://wiktionary.org Wiktionary]&amp;nbsp;· [http://wikibooks.org Wikibooks]&amp;nbsp;· [http://wikiquote.org Wikiquote]&amp;nbsp;· [http://wikisource.org Wikisource]</text>
      <sha1>au67w9deu91400kre2xqrttv3d88z1v</sha1>
    </revision>
    <revision>
      <id>1092</id>
      <parentid>1091</parentid>
      <timestamp>2016-02-26T23:47:42Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1092</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1563" sha1="7m896z6xpuywm1vz07uzf5u2guytq8c" xml:space="preserve">&lt;center&gt;'''[[:meta:Help:Editing|Irhelebho Ngomtlolo]]'''&lt;br&gt;
Uyabawa ukuzifundisa ukutlola lapha ku[[Wikipedia:Sandbox|Sandbox]].&lt;br&gt;
Cala amakhasi aqakathekile, esibawa bona urhelepe kuwo: [[Vital 10|10]] &amp;nbsp;· [[Vital 100|100]] &amp;nbsp;· [[Vital 1000|1000]]&lt;/center&gt;
== iWikipedia ngeeilimi ezinye ==
; Ama-Wikipedia Amanye ngeeiLwimi zeAfrika 
[[:af:|Afrikaans]]&amp;nbsp;·
[[:ak:|Akan]]&amp;nbsp;·
[[:am:|አማርኛ]]&amp;nbsp;·
[[:bm:|Bamanankan]]&amp;nbsp;·
[[:ny:|Chi-Chewa]]&amp;nbsp;·
[[:sn:|chiShona]]&amp;nbsp;·
[[:tum:|chiTumbuka]]&amp;nbsp;·
[[:ee:|Ɛʋɛ]]&amp;nbsp;·
[[:ff:|Fulfude]]&amp;nbsp;·
[[:ki:|Gĩkũyũ]]&amp;nbsp;·
[[:ha:|هَوُسَ]]&amp;nbsp;·
[[:ig:|Ìgbo]]&amp;nbsp;·
[[:xh:|isiXhosa]]&amp;nbsp;·
[[:rw:|Kinyarwanda]]&amp;nbsp;·
[[:rn:|Kirundi]]&amp;nbsp;·
[[:sw:|Kiswahili]]&amp;nbsp;·
[[:kg:|Kongo]]&amp;nbsp;·
[[:ln:|Lingala]]&amp;nbsp;·
[[:lg:|Luganda]]&amp;nbsp;·
[[:mg:|Malagasy]]&amp;nbsp;·
[[:arz:|مصرى]]&amp;nbsp;·
[[:om:|Oromoo]]&amp;nbsp;·
[[:sg:|Sängö]]&amp;nbsp;·
[[:st:|seSotho]]&amp;nbsp;·
[[:tn:|Setswana]]&amp;nbsp;·
[[:ss:|SiSwati]]&amp;nbsp;·
[[:so:|Soomaaliga]]&amp;nbsp;·
[[:kab:|Taqbaylit]]&amp;nbsp;·
[[:ti:|ትግርኛ]]&amp;nbsp;·
[[:ve:|Tshivenda]]&amp;nbsp;·
[[:tw:|Twi]]&amp;nbsp;·
[[:wo:|Wolof]]&amp;nbsp;·
[[:ts:|Xitsonga]]&amp;nbsp;·
[[:yo:|Yorùbá]]&amp;nbsp;·
(Uma ufuna ukuqala Ama-Wikipedia khulu, qala ku-bar engasesineneni)
&lt;div class=&quot;plainlinks&quot;&gt;
; Amaphrojekthi afanako
: [http://meta.wikipedia.org Meta-Wikipedia]&amp;nbsp;· [http://wiktionary.org Wiktionary]&amp;nbsp;· [http://wikibooks.org Wikibooks]&amp;nbsp;· [http://wikiquote.org Wikiquote]&amp;nbsp;· [http://wikisource.org Wikisource]</text>
      <sha1>7m896z6xpuywm1vz07uzf5u2guytq8c</sha1>
    </revision>
    <revision>
      <id>1093</id>
      <parentid>1092</parentid>
      <timestamp>2016-02-26T23:48:19Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1093</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1573" sha1="jkwggjnp91mgrnm4clri08lgegxlc55" xml:space="preserve">&lt;center&gt;'''[[:meta:Help:Editing|Irhelebho Ngomtlolo]]'''&lt;br&gt;
Uyabawa ukuzifundisa ukutlola lapha ku[[Wikipedia:Sandbox|Sandbox]].&lt;br&gt;
Cala amakhasi aqakathekile, esibawa bona urhelepe kuwo: &lt;big&gt;[[Vital 10|10]] &amp;nbsp;· [[Vital 100|100]] &amp;nbsp;· [[Vital 1000|1000]]&lt;big&gt;&lt;/center&gt;
== iWikipedia ngeeilimi ezinye ==
; Ama-Wikipedia Amanye ngeeiLwimi zeAfrika 
[[:af:|Afrikaans]]&amp;nbsp;·
[[:ak:|Akan]]&amp;nbsp;·
[[:am:|አማርኛ]]&amp;nbsp;·
[[:bm:|Bamanankan]]&amp;nbsp;·
[[:ny:|Chi-Chewa]]&amp;nbsp;·
[[:sn:|chiShona]]&amp;nbsp;·
[[:tum:|chiTumbuka]]&amp;nbsp;·
[[:ee:|Ɛʋɛ]]&amp;nbsp;·
[[:ff:|Fulfude]]&amp;nbsp;·
[[:ki:|Gĩkũyũ]]&amp;nbsp;·
[[:ha:|هَوُسَ]]&amp;nbsp;·
[[:ig:|Ìgbo]]&amp;nbsp;·
[[:xh:|isiXhosa]]&amp;nbsp;·
[[:rw:|Kinyarwanda]]&amp;nbsp;·
[[:rn:|Kirundi]]&amp;nbsp;·
[[:sw:|Kiswahili]]&amp;nbsp;·
[[:kg:|Kongo]]&amp;nbsp;·
[[:ln:|Lingala]]&amp;nbsp;·
[[:lg:|Luganda]]&amp;nbsp;·
[[:mg:|Malagasy]]&amp;nbsp;·
[[:arz:|مصرى]]&amp;nbsp;·
[[:om:|Oromoo]]&amp;nbsp;·
[[:sg:|Sängö]]&amp;nbsp;·
[[:st:|seSotho]]&amp;nbsp;·
[[:tn:|Setswana]]&amp;nbsp;·
[[:ss:|SiSwati]]&amp;nbsp;·
[[:so:|Soomaaliga]]&amp;nbsp;·
[[:kab:|Taqbaylit]]&amp;nbsp;·
[[:ti:|ትግርኛ]]&amp;nbsp;·
[[:ve:|Tshivenda]]&amp;nbsp;·
[[:tw:|Twi]]&amp;nbsp;·
[[:wo:|Wolof]]&amp;nbsp;·
[[:ts:|Xitsonga]]&amp;nbsp;·
[[:yo:|Yorùbá]]&amp;nbsp;·
(Uma ufuna ukuqala Ama-Wikipedia khulu, qala ku-bar engasesineneni)
&lt;div class=&quot;plainlinks&quot;&gt;
; Amaphrojekthi afanako
: [http://meta.wikipedia.org Meta-Wikipedia]&amp;nbsp;· [http://wiktionary.org Wiktionary]&amp;nbsp;· [http://wikibooks.org Wikibooks]&amp;nbsp;· [http://wikiquote.org Wikiquote]&amp;nbsp;· [http://wikisource.org Wikisource]</text>
      <sha1>jkwggjnp91mgrnm4clri08lgegxlc55</sha1>
    </revision>
    <revision>
      <id>1094</id>
      <parentid>1093</parentid>
      <timestamp>2016-02-26T23:51:15Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1094</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1574" sha1="02lhswszemslgkgl41t4ye79w4sokmu" xml:space="preserve">&lt;center&gt;'''[[:meta:Help:Editing|Irhelebho Ngomtlolo]]'''&lt;br&gt;
Uyabawa ukuzifundisa ukutlola lapha ku[[Wikipedia:Sandbox|Sandbox]].&lt;br&gt;
Cala amakhasi aqakathekile, esibawa bona urhelepe kuwo: &lt;big&gt;[[Vital 10|10]] &amp;nbsp;· [[Vital 100|100]] &amp;nbsp;· [[Vital 1000|1000]]&lt;/big&gt;&lt;/center&gt;
== iWikipedia ngeeilimi ezinye ==
; Ama-Wikipedia Amanye ngeeiLwimi zeAfrika 
[[:af:|Afrikaans]]&amp;nbsp;·
[[:ak:|Akan]]&amp;nbsp;·
[[:am:|አማርኛ]]&amp;nbsp;·
[[:bm:|Bamanankan]]&amp;nbsp;·
[[:ny:|Chi-Chewa]]&amp;nbsp;·
[[:sn:|chiShona]]&amp;nbsp;·
[[:tum:|chiTumbuka]]&amp;nbsp;·
[[:ee:|Ɛʋɛ]]&amp;nbsp;·
[[:ff:|Fulfude]]&amp;nbsp;·
[[:ki:|Gĩkũyũ]]&amp;nbsp;·
[[:ha:|هَوُسَ]]&amp;nbsp;·
[[:ig:|Ìgbo]]&amp;nbsp;·
[[:xh:|isiXhosa]]&amp;nbsp;·
[[:rw:|Kinyarwanda]]&amp;nbsp;·
[[:rn:|Kirundi]]&amp;nbsp;·
[[:sw:|Kiswahili]]&amp;nbsp;·
[[:kg:|Kongo]]&amp;nbsp;·
[[:ln:|Lingala]]&amp;nbsp;·
[[:lg:|Luganda]]&amp;nbsp;·
[[:mg:|Malagasy]]&amp;nbsp;·
[[:arz:|مصرى]]&amp;nbsp;·
[[:om:|Oromoo]]&amp;nbsp;·
[[:sg:|Sängö]]&amp;nbsp;·
[[:st:|seSotho]]&amp;nbsp;·
[[:tn:|Setswana]]&amp;nbsp;·
[[:ss:|SiSwati]]&amp;nbsp;·
[[:so:|Soomaaliga]]&amp;nbsp;·
[[:kab:|Taqbaylit]]&amp;nbsp;·
[[:ti:|ትግርኛ]]&amp;nbsp;·
[[:ve:|Tshivenda]]&amp;nbsp;·
[[:tw:|Twi]]&amp;nbsp;·
[[:wo:|Wolof]]&amp;nbsp;·
[[:ts:|Xitsonga]]&amp;nbsp;·
[[:yo:|Yorùbá]]&amp;nbsp;·
(Uma ufuna ukuqala Ama-Wikipedia khulu, qala ku-bar engasesineneni)
&lt;div class=&quot;plainlinks&quot;&gt;
; Amaphrojekthi afanako
: [http://meta.wikipedia.org Meta-Wikipedia]&amp;nbsp;· [http://wiktionary.org Wiktionary]&amp;nbsp;· [http://wikibooks.org Wikibooks]&amp;nbsp;· [http://wikiquote.org Wikiquote]&amp;nbsp;· [http://wikisource.org Wikisource]</text>
      <sha1>02lhswszemslgkgl41t4ye79w4sokmu</sha1>
    </revision>
    <revision>
      <id>1095</id>
      <parentid>1094</parentid>
      <timestamp>2019-01-11T13:23:08Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1095</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1679" sha1="i9tkuw2sniyjnw6fvqlkoq1iftcr78w" xml:space="preserve">&lt;center&gt;'''[[:meta:Help:Editing|Irhelebho Ngomtlolo]]'''&lt;br&gt;
Uyabawa ukuzifundisa ukutlola lapha ku[[Wikipedia:Sandbox|Sandbox]].&lt;br&gt;
Cala amakhasi aqakathekile, esibawa bona urhelepe kuwo: &lt;big&gt;[[|Wikipedia:Imitlolo aqakathekileyo/esigaba 1|10]] &amp;nbsp;· [[|Wikipedia:Imitlolo aqakathekileyo/esigaba 2|100]] &amp;nbsp;· [[|Wikipedia:Imitlolo aqakathekileyo/esigaba 3|1000]]&lt;/big&gt;&lt;/center&gt;
== iWikipedia ngeeilimi ezinye ==
; Ama-Wikipedia Amanye ngeeiLwimi zeAfrika 
[[:af:|Afrikaans]]&amp;nbsp;·
[[:ak:|Akan]]&amp;nbsp;·
[[:am:|አማርኛ]]&amp;nbsp;·
[[:bm:|Bamanankan]]&amp;nbsp;·
[[:ny:|Chi-Chewa]]&amp;nbsp;·
[[:sn:|chiShona]]&amp;nbsp;·
[[:tum:|chiTumbuka]]&amp;nbsp;·
[[:ee:|Ɛʋɛ]]&amp;nbsp;·
[[:ff:|Fulfude]]&amp;nbsp;·
[[:ki:|Gĩkũyũ]]&amp;nbsp;·
[[:ha:|هَوُسَ]]&amp;nbsp;·
[[:ig:|Ìgbo]]&amp;nbsp;·
[[:xh:|isiXhosa]]&amp;nbsp;·
[[:rw:|Kinyarwanda]]&amp;nbsp;·
[[:rn:|Kirundi]]&amp;nbsp;·
[[:sw:|Kiswahili]]&amp;nbsp;·
[[:kg:|Kongo]]&amp;nbsp;·
[[:ln:|Lingala]]&amp;nbsp;·
[[:lg:|Luganda]]&amp;nbsp;·
[[:mg:|Malagasy]]&amp;nbsp;·
[[:arz:|مصرى]]&amp;nbsp;·
[[:om:|Oromoo]]&amp;nbsp;·
[[:sg:|Sängö]]&amp;nbsp;·
[[:st:|seSotho]]&amp;nbsp;·
[[:tn:|Setswana]]&amp;nbsp;·
[[:ss:|SiSwati]]&amp;nbsp;·
[[:so:|Soomaaliga]]&amp;nbsp;·
[[:kab:|Taqbaylit]]&amp;nbsp;·
[[:ti:|ትግርኛ]]&amp;nbsp;·
[[:ve:|Tshivenda]]&amp;nbsp;·
[[:tw:|Twi]]&amp;nbsp;·
[[:wo:|Wolof]]&amp;nbsp;·
[[:ts:|Xitsonga]]&amp;nbsp;·
[[:yo:|Yorùbá]]&amp;nbsp;·
(Uma ufuna ukuqala Ama-Wikipedia khulu, qala ku-bar engasesineneni)
&lt;div class=&quot;plainlinks&quot;&gt;
; Amaphrojekthi afanako
: [http://meta.wikipedia.org Meta-Wikipedia]&amp;nbsp;· [http://wiktionary.org Wiktionary]&amp;nbsp;· [http://wikibooks.org Wikibooks]&amp;nbsp;· [http://wikiquote.org Wikiquote]&amp;nbsp;· [http://wikisource.org Wikisource]</text>
      <sha1>i9tkuw2sniyjnw6fvqlkoq1iftcr78w</sha1>
    </revision>
    <revision>
      <id>1096</id>
      <parentid>1095</parentid>
      <timestamp>2019-01-11T13:24:24Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1096</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1676" sha1="gtl78do1609grdgnzzxofllucnayszj" xml:space="preserve">&lt;center&gt;'''[[:meta:Help:Editing|Irhelebho Ngomtlolo]]'''&lt;br&gt;
Uyabawa ukuzifundisa ukutlola lapha ku[[Wikipedia:Sandbox|Sandbox]].&lt;br&gt;
Cala amakhasi aqakathekile, esibawa bona urhelepe kuwo: &lt;big&gt;[[Wikipedia:Imitlolo aqakathekileyo/esigaba 1|10]] &amp;nbsp;· [[Wikipedia:Imitlolo aqakathekileyo/esigaba 2|100]] &amp;nbsp;· [[Wikipedia:Imitlolo aqakathekileyo/esigaba 3|1000]]&lt;/big&gt;&lt;/center&gt;
== iWikipedia ngeeilimi ezinye ==
; Ama-Wikipedia Amanye ngeeiLwimi zeAfrika 
[[:af:|Afrikaans]]&amp;nbsp;·
[[:ak:|Akan]]&amp;nbsp;·
[[:am:|አማርኛ]]&amp;nbsp;·
[[:bm:|Bamanankan]]&amp;nbsp;·
[[:ny:|Chi-Chewa]]&amp;nbsp;·
[[:sn:|chiShona]]&amp;nbsp;·
[[:tum:|chiTumbuka]]&amp;nbsp;·
[[:ee:|Ɛʋɛ]]&amp;nbsp;·
[[:ff:|Fulfude]]&amp;nbsp;·
[[:ki:|Gĩkũyũ]]&amp;nbsp;·
[[:ha:|هَوُسَ]]&amp;nbsp;·
[[:ig:|Ìgbo]]&amp;nbsp;·
[[:xh:|isiXhosa]]&amp;nbsp;·
[[:rw:|Kinyarwanda]]&amp;nbsp;·
[[:rn:|Kirundi]]&amp;nbsp;·
[[:sw:|Kiswahili]]&amp;nbsp;·
[[:kg:|Kongo]]&amp;nbsp;·
[[:ln:|Lingala]]&amp;nbsp;·
[[:lg:|Luganda]]&amp;nbsp;·
[[:mg:|Malagasy]]&amp;nbsp;·
[[:arz:|مصرى]]&amp;nbsp;·
[[:om:|Oromoo]]&amp;nbsp;·
[[:sg:|Sängö]]&amp;nbsp;·
[[:st:|seSotho]]&amp;nbsp;·
[[:tn:|Setswana]]&amp;nbsp;·
[[:ss:|SiSwati]]&amp;nbsp;·
[[:so:|Soomaaliga]]&amp;nbsp;·
[[:kab:|Taqbaylit]]&amp;nbsp;·
[[:ti:|ትግርኛ]]&amp;nbsp;·
[[:ve:|Tshivenda]]&amp;nbsp;·
[[:tw:|Twi]]&amp;nbsp;·
[[:wo:|Wolof]]&amp;nbsp;·
[[:ts:|Xitsonga]]&amp;nbsp;·
[[:yo:|Yorùbá]]&amp;nbsp;·
(Uma ufuna ukuqala Ama-Wikipedia khulu, qala ku-bar engasesineneni)
&lt;div class=&quot;plainlinks&quot;&gt;
; Amaphrojekthi afanako
: [http://meta.wikipedia.org Meta-Wikipedia]&amp;nbsp;· [http://wiktionary.org Wiktionary]&amp;nbsp;· [http://wikibooks.org Wikibooks]&amp;nbsp;· [http://wikiquote.org Wikiquote]&amp;nbsp;· [http://wikisource.org Wikisource]</text>
      <sha1>gtl78do1609grdgnzzxofllucnayszj</sha1>
    </revision>
    <revision>
      <id>1097</id>
      <parentid>1096</parentid>
      <timestamp>2024-09-14T10:07:08Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1097</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1670" sha1="624stw5rbc44xx99ywprm3k7xolwxqe" xml:space="preserve">&lt;center&gt;'''[[:meta:Help:Editing|Isizo Ngomtlolo]]'''&lt;br&gt;
Uyabawa ukuzifundisa ukutlola lapha ku[[Wikipedia:Sandbox|-Sandbox]].&lt;br&gt;
Qala amakhasi aqakathekile, esibawa bona usize kiwo: &lt;big&gt;[[Wikipedia:Imitlolo aqakathekileyo/esigaba 1|10]] &amp;nbsp;· [[Wikipedia:Imitlolo aqakathekileyo/esigaba 2|100]] &amp;nbsp;· [[Wikipedia:Imitlolo aqakathekileyo/esigaba 3|1000]]&lt;/big&gt;&lt;/center&gt;
== I-Wikipedia ngamalimi amanye ==
; Ama-Wikipedia Amanye Ngamalimi we-Afrika
[[:af:|Afrikaans]]&amp;nbsp;·
[[:ak:|Akan]]&amp;nbsp;·
[[:am:|አማርኛ]]&amp;nbsp;·
[[:bm:|Bamanankan]]&amp;nbsp;·
[[:ny:|Chi-Chewa]]&amp;nbsp;·
[[:sn:|chiShona]]&amp;nbsp;·
[[:tum:|chiTumbuka]]&amp;nbsp;·
[[:ee:|Ɛʋɛ]]&amp;nbsp;·
[[:ff:|Fulfude]]&amp;nbsp;·
[[:ki:|Gĩkũyũ]]&amp;nbsp;·
[[:ha:|هَوُسَ]]&amp;nbsp;·
[[:ig:|Ìgbo]]&amp;nbsp;·
[[:xh:|isiXhosa]]&amp;nbsp;·
[[:rw:|Kinyarwanda]]&amp;nbsp;·
[[:rn:|Kirundi]]&amp;nbsp;·
[[:sw:|Kiswahili]]&amp;nbsp;·
[[:kg:|Kongo]]&amp;nbsp;·
[[:ln:|Lingala]]&amp;nbsp;·
[[:lg:|Luganda]]&amp;nbsp;·
[[:mg:|Malagasy]]&amp;nbsp;·
[[:arz:|مصرى]]&amp;nbsp;·
[[:om:|Oromoo]]&amp;nbsp;·
[[:sg:|Sängö]]&amp;nbsp;·
[[:st:|seSotho]]&amp;nbsp;·
[[:tn:|Setswana]]&amp;nbsp;·
[[:ss:|SiSwati]]&amp;nbsp;·
[[:so:|Soomaaliga]]&amp;nbsp;·
[[:kab:|Taqbaylit]]&amp;nbsp;·
[[:ti:|ትግርኛ]]&amp;nbsp;·
[[:ve:|Tshivenda]]&amp;nbsp;·
[[:tw:|Twi]]&amp;nbsp;·
[[:wo:|Wolof]]&amp;nbsp;·
[[:ts:|Xitsonga]]&amp;nbsp;·
[[:yo:|Yorùbá]]&amp;nbsp;·
(Nangabe ufuna ukuqala Ama-Wikipedia khulu, qala ku-bar engenzasi)
&lt;div class=&quot;plainlinks&quot;&gt;
; Amaphrojekhthi afanako
: [http://meta.wikipedia.org Meta-Wikipedia]&amp;nbsp;· [http://wiktionary.org Wiktionary]&amp;nbsp;· [http://wikibooks.org Wikibooks]&amp;nbsp;· [http://wikiquote.org Wikiquote]&amp;nbsp;· [http://wikisource.org Wikisource]</text>
      <sha1>624stw5rbc44xx99ywprm3k7xolwxqe</sha1>
    </revision>
    <revision>
      <id>1098</id>
      <parentid>1097</parentid>
      <timestamp>2024-10-14T13:47:02Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>18 revisions imported</comment>
      <origin>1097</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1670" sha1="624stw5rbc44xx99ywprm3k7xolwxqe" xml:space="preserve">&lt;center&gt;'''[[:meta:Help:Editing|Isizo Ngomtlolo]]'''&lt;br&gt;
Uyabawa ukuzifundisa ukutlola lapha ku[[Wikipedia:Sandbox|-Sandbox]].&lt;br&gt;
Qala amakhasi aqakathekile, esibawa bona usize kiwo: &lt;big&gt;[[Wikipedia:Imitlolo aqakathekileyo/esigaba 1|10]] &amp;nbsp;· [[Wikipedia:Imitlolo aqakathekileyo/esigaba 2|100]] &amp;nbsp;· [[Wikipedia:Imitlolo aqakathekileyo/esigaba 3|1000]]&lt;/big&gt;&lt;/center&gt;
== I-Wikipedia ngamalimi amanye ==
; Ama-Wikipedia Amanye Ngamalimi we-Afrika
[[:af:|Afrikaans]]&amp;nbsp;·
[[:ak:|Akan]]&amp;nbsp;·
[[:am:|አማርኛ]]&amp;nbsp;·
[[:bm:|Bamanankan]]&amp;nbsp;·
[[:ny:|Chi-Chewa]]&amp;nbsp;·
[[:sn:|chiShona]]&amp;nbsp;·
[[:tum:|chiTumbuka]]&amp;nbsp;·
[[:ee:|Ɛʋɛ]]&amp;nbsp;·
[[:ff:|Fulfude]]&amp;nbsp;·
[[:ki:|Gĩkũyũ]]&amp;nbsp;·
[[:ha:|هَوُسَ]]&amp;nbsp;·
[[:ig:|Ìgbo]]&amp;nbsp;·
[[:xh:|isiXhosa]]&amp;nbsp;·
[[:rw:|Kinyarwanda]]&amp;nbsp;·
[[:rn:|Kirundi]]&amp;nbsp;·
[[:sw:|Kiswahili]]&amp;nbsp;·
[[:kg:|Kongo]]&amp;nbsp;·
[[:ln:|Lingala]]&amp;nbsp;·
[[:lg:|Luganda]]&amp;nbsp;·
[[:mg:|Malagasy]]&amp;nbsp;·
[[:arz:|مصرى]]&amp;nbsp;·
[[:om:|Oromoo]]&amp;nbsp;·
[[:sg:|Sängö]]&amp;nbsp;·
[[:st:|seSotho]]&amp;nbsp;·
[[:tn:|Setswana]]&amp;nbsp;·
[[:ss:|SiSwati]]&amp;nbsp;·
[[:so:|Soomaaliga]]&amp;nbsp;·
[[:kab:|Taqbaylit]]&amp;nbsp;·
[[:ti:|ትግርኛ]]&amp;nbsp;·
[[:ve:|Tshivenda]]&amp;nbsp;·
[[:tw:|Twi]]&amp;nbsp;·
[[:wo:|Wolof]]&amp;nbsp;·
[[:ts:|Xitsonga]]&amp;nbsp;·
[[:yo:|Yorùbá]]&amp;nbsp;·
(Nangabe ufuna ukuqala Ama-Wikipedia khulu, qala ku-bar engenzasi)
&lt;div class=&quot;plainlinks&quot;&gt;
; Amaphrojekhthi afanako
: [http://meta.wikipedia.org Meta-Wikipedia]&amp;nbsp;· [http://wiktionary.org Wiktionary]&amp;nbsp;· [http://wikibooks.org Wikibooks]&amp;nbsp;· [http://wikiquote.org Wikiquote]&amp;nbsp;· [http://wikisource.org Wikisource]</text>
      <sha1>624stw5rbc44xx99ywprm3k7xolwxqe</sha1>
    </revision>
    <revision>
      <id>1693</id>
      <parentid>1098</parentid>
      <timestamp>2024-10-17T04:33:05Z</timestamp>
      <contributor>
        <username>Minorax</username>
        <id>38</id>
      </contributor>
      <origin>1693</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1679" sha1="5nvlpno674s7ov76rhxei8vncjxlelk" xml:space="preserve">&lt;div class=&quot;center&quot;&gt;'''[[:meta:Help:Editing|Isizo Ngomtlolo]]'''&lt;br&gt;
Uyabawa ukuzifundisa ukutlola lapha ku[[Wikipedia:Sandbox|-Sandbox]].&lt;br&gt;
Qala amakhasi aqakathekile, esibawa bona usize kiwo: &lt;big&gt;[[Wikipedia:Imitlolo aqakathekileyo/esigaba 1|10]] &amp;nbsp;· [[Wikipedia:Imitlolo aqakathekileyo/esigaba 2|100]] &amp;nbsp;· [[Wikipedia:Imitlolo aqakathekileyo/esigaba 3|1000]]&lt;/big&gt;&lt;/div&gt;
== I-Wikipedia ngamalimi amanye ==
; Ama-Wikipedia Amanye Ngamalimi we-Afrika
[[:af:|Afrikaans]]&amp;nbsp;·
[[:ak:|Akan]]&amp;nbsp;·
[[:am:|አማርኛ]]&amp;nbsp;·
[[:bm:|Bamanankan]]&amp;nbsp;·
[[:ny:|Chi-Chewa]]&amp;nbsp;·
[[:sn:|chiShona]]&amp;nbsp;·
[[:tum:|chiTumbuka]]&amp;nbsp;·
[[:ee:|Ɛʋɛ]]&amp;nbsp;·
[[:ff:|Fulfude]]&amp;nbsp;·
[[:ki:|Gĩkũyũ]]&amp;nbsp;·
[[:ha:|هَوُسَ]]&amp;nbsp;·
[[:ig:|Ìgbo]]&amp;nbsp;·
[[:xh:|isiXhosa]]&amp;nbsp;·
[[:rw:|Kinyarwanda]]&amp;nbsp;·
[[:rn:|Kirundi]]&amp;nbsp;·
[[:sw:|Kiswahili]]&amp;nbsp;·
[[:kg:|Kongo]]&amp;nbsp;·
[[:ln:|Lingala]]&amp;nbsp;·
[[:lg:|Luganda]]&amp;nbsp;·
[[:mg:|Malagasy]]&amp;nbsp;·
[[:arz:|مصرى]]&amp;nbsp;·
[[:om:|Oromoo]]&amp;nbsp;·
[[:sg:|Sängö]]&amp;nbsp;·
[[:st:|seSotho]]&amp;nbsp;·
[[:tn:|Setswana]]&amp;nbsp;·
[[:ss:|SiSwati]]&amp;nbsp;·
[[:so:|Soomaaliga]]&amp;nbsp;·
[[:kab:|Taqbaylit]]&amp;nbsp;·
[[:ti:|ትግርኛ]]&amp;nbsp;·
[[:ve:|Tshivenda]]&amp;nbsp;·
[[:tw:|Twi]]&amp;nbsp;·
[[:wo:|Wolof]]&amp;nbsp;·
[[:ts:|Xitsonga]]&amp;nbsp;·
[[:yo:|Yorùbá]]&amp;nbsp;·
(Nangabe ufuna ukuqala Ama-Wikipedia khulu, qala ku-bar engenzasi)
&lt;div class=&quot;plainlinks&quot;&gt;
; Amaphrojekhthi afanako
: [http://meta.wikipedia.org Meta-Wikipedia]&amp;nbsp;· [http://wiktionary.org Wiktionary]&amp;nbsp;· [http://wikibooks.org Wikibooks]&amp;nbsp;· [http://wikiquote.org Wikiquote]&amp;nbsp;· [http://wikisource.org Wikisource]</text>
      <sha1>5nvlpno674s7ov76rhxei8vncjxlelk</sha1>
    </revision>
    <revision>
      <id>1694</id>
      <parentid>1693</parentid>
      <timestamp>2024-10-17T04:33:12Z</timestamp>
      <contributor>
        <username>Minorax</username>
        <id>38</id>
      </contributor>
      <origin>1694</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1686" sha1="r8i28si6lvrpf5uriga2wpzspmtjrjr" xml:space="preserve">&lt;div class=&quot;center&quot;&gt;'''[[:meta:Help:Editing|Isizo Ngomtlolo]]'''&lt;br&gt;
Uyabawa ukuzifundisa ukutlola lapha ku[[Wikipedia:Sandbox|-Sandbox]].&lt;br&gt;
Qala amakhasi aqakathekile, esibawa bona usize kiwo: &lt;big&gt;[[Wikipedia:Imitlolo aqakathekileyo/esigaba 1|10]] &amp;nbsp;· [[Wikipedia:Imitlolo aqakathekileyo/esigaba 2|100]] &amp;nbsp;· [[Wikipedia:Imitlolo aqakathekileyo/esigaba 3|1000]]&lt;/big&gt;&lt;/div&gt;
== I-Wikipedia ngamalimi amanye ==
; Ama-Wikipedia Amanye Ngamalimi we-Afrika
[[:af:|Afrikaans]]&amp;nbsp;·
[[:ak:|Akan]]&amp;nbsp;·
[[:am:|አማርኛ]]&amp;nbsp;·
[[:bm:|Bamanankan]]&amp;nbsp;·
[[:ny:|Chi-Chewa]]&amp;nbsp;·
[[:sn:|chiShona]]&amp;nbsp;·
[[:tum:|chiTumbuka]]&amp;nbsp;·
[[:ee:|Ɛʋɛ]]&amp;nbsp;·
[[:ff:|Fulfude]]&amp;nbsp;·
[[:ki:|Gĩkũyũ]]&amp;nbsp;·
[[:ha:|هَوُسَ]]&amp;nbsp;·
[[:ig:|Ìgbo]]&amp;nbsp;·
[[:xh:|isiXhosa]]&amp;nbsp;·
[[:rw:|Kinyarwanda]]&amp;nbsp;·
[[:rn:|Kirundi]]&amp;nbsp;·
[[:sw:|Kiswahili]]&amp;nbsp;·
[[:kg:|Kongo]]&amp;nbsp;·
[[:ln:|Lingala]]&amp;nbsp;·
[[:lg:|Luganda]]&amp;nbsp;·
[[:mg:|Malagasy]]&amp;nbsp;·
[[:arz:|مصرى]]&amp;nbsp;·
[[:om:|Oromoo]]&amp;nbsp;·
[[:sg:|Sängö]]&amp;nbsp;·
[[:st:|seSotho]]&amp;nbsp;·
[[:tn:|Setswana]]&amp;nbsp;·
[[:ss:|SiSwati]]&amp;nbsp;·
[[:so:|Soomaaliga]]&amp;nbsp;·
[[:kab:|Taqbaylit]]&amp;nbsp;·
[[:ti:|ትግርኛ]]&amp;nbsp;·
[[:ve:|Tshivenda]]&amp;nbsp;·
[[:tw:|Twi]]&amp;nbsp;·
[[:wo:|Wolof]]&amp;nbsp;·
[[:ts:|Xitsonga]]&amp;nbsp;·
[[:yo:|Yorùbá]]&amp;nbsp;·
(Nangabe ufuna ukuqala Ama-Wikipedia khulu, qala ku-bar engenzasi)
&lt;div class=&quot;plainlinks&quot;&gt;
; Amaphrojekhthi afanako
: [http://meta.wikipedia.org Meta-Wikipedia]&amp;nbsp;· [http://wiktionary.org Wiktionary]&amp;nbsp;· [http://wikibooks.org Wikibooks]&amp;nbsp;· [http://wikiquote.org Wikiquote]&amp;nbsp;· [http://wikisource.org Wikisource]
&lt;/div&gt;</text>
      <sha1>r8i28si6lvrpf5uriga2wpzspmtjrjr</sha1>
    </revision>
    <revision>
      <id>2958</id>
      <parentid>1694</parentid>
      <timestamp>2025-06-06T19:00:44Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>a</comment>
      <origin>2958</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="137" sha1="dyd9ch0z9tegcr7r2pmsj5skmvip2gd" xml:space="preserve">= This Wikipedia is sponsored by [[Raid: Shadow Legends]] =
&lt;div class=&quot;plainlinks&quot;&gt;
== [[A Minecraft Movie|Chicken Jockey!!!]] ==
&lt;/div&gt;</text>
      <sha1>dyd9ch0z9tegcr7r2pmsj5skmvip2gd</sha1>
    </revision>
    <revision>
      <id>3096</id>
      <parentid>2958</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Minorax|Minorax]]</comment>
      <origin>1694</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1686" sha1="r8i28si6lvrpf5uriga2wpzspmtjrjr" xml:space="preserve">&lt;div class=&quot;center&quot;&gt;'''[[:meta:Help:Editing|Isizo Ngomtlolo]]'''&lt;br&gt;
Uyabawa ukuzifundisa ukutlola lapha ku[[Wikipedia:Sandbox|-Sandbox]].&lt;br&gt;
Qala amakhasi aqakathekile, esibawa bona usize kiwo: &lt;big&gt;[[Wikipedia:Imitlolo aqakathekileyo/esigaba 1|10]] &amp;nbsp;· [[Wikipedia:Imitlolo aqakathekileyo/esigaba 2|100]] &amp;nbsp;· [[Wikipedia:Imitlolo aqakathekileyo/esigaba 3|1000]]&lt;/big&gt;&lt;/div&gt;
== I-Wikipedia ngamalimi amanye ==
; Ama-Wikipedia Amanye Ngamalimi we-Afrika
[[:af:|Afrikaans]]&amp;nbsp;·
[[:ak:|Akan]]&amp;nbsp;·
[[:am:|አማርኛ]]&amp;nbsp;·
[[:bm:|Bamanankan]]&amp;nbsp;·
[[:ny:|Chi-Chewa]]&amp;nbsp;·
[[:sn:|chiShona]]&amp;nbsp;·
[[:tum:|chiTumbuka]]&amp;nbsp;·
[[:ee:|Ɛʋɛ]]&amp;nbsp;·
[[:ff:|Fulfude]]&amp;nbsp;·
[[:ki:|Gĩkũyũ]]&amp;nbsp;·
[[:ha:|هَوُسَ]]&amp;nbsp;·
[[:ig:|Ìgbo]]&amp;nbsp;·
[[:xh:|isiXhosa]]&amp;nbsp;·
[[:rw:|Kinyarwanda]]&amp;nbsp;·
[[:rn:|Kirundi]]&amp;nbsp;·
[[:sw:|Kiswahili]]&amp;nbsp;·
[[:kg:|Kongo]]&amp;nbsp;·
[[:ln:|Lingala]]&amp;nbsp;·
[[:lg:|Luganda]]&amp;nbsp;·
[[:mg:|Malagasy]]&amp;nbsp;·
[[:arz:|مصرى]]&amp;nbsp;·
[[:om:|Oromoo]]&amp;nbsp;·
[[:sg:|Sängö]]&amp;nbsp;·
[[:st:|seSotho]]&amp;nbsp;·
[[:tn:|Setswana]]&amp;nbsp;·
[[:ss:|SiSwati]]&amp;nbsp;·
[[:so:|Soomaaliga]]&amp;nbsp;·
[[:kab:|Taqbaylit]]&amp;nbsp;·
[[:ti:|ትግርኛ]]&amp;nbsp;·
[[:ve:|Tshivenda]]&amp;nbsp;·
[[:tw:|Twi]]&amp;nbsp;·
[[:wo:|Wolof]]&amp;nbsp;·
[[:ts:|Xitsonga]]&amp;nbsp;·
[[:yo:|Yorùbá]]&amp;nbsp;·
(Nangabe ufuna ukuqala Ama-Wikipedia khulu, qala ku-bar engenzasi)
&lt;div class=&quot;plainlinks&quot;&gt;
; Amaphrojekhthi afanako
: [http://meta.wikipedia.org Meta-Wikipedia]&amp;nbsp;· [http://wiktionary.org Wiktionary]&amp;nbsp;· [http://wikibooks.org Wikibooks]&amp;nbsp;· [http://wikiquote.org Wikiquote]&amp;nbsp;· [http://wikisource.org Wikisource]
&lt;/div&gt;</text>
      <sha1>r8i28si6lvrpf5uriga2wpzspmtjrjr</sha1>
    </revision>
    <revision>
      <id>3393</id>
      <parentid>3096</parentid>
      <timestamp>2025-07-11T11:26:25Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <origin>3393</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1612" sha1="0ddcnmgrj6fmvxtgt8zv3oh3acwpd6y" xml:space="preserve">&lt;div class=&quot;center&quot;&gt;'''[[:meta:Help:Editing|Isizo Ngomtlolo]]'''&lt;br&gt;
Qala amakhasi aqakathekile, esibawa bona usize kiwo: &lt;big&gt;[[Wikipedia:Imitlolo aqakathekileyo/esigaba 1|10]] &amp;nbsp;· [[Wikipedia:Imitlolo aqakathekileyo/esigaba 2|100]] &amp;nbsp;· [[Wikipedia:Imitlolo aqakathekileyo/esigaba 3|1000]]&lt;/big&gt;&lt;/div&gt;
== I-Wikipedia ngamalimi amanye ==
; Ama-Wikipedia Amanye Ngamalimi we-Afrika
[[:af:|Afrikaans]]&amp;nbsp;·
[[:ak:|Akan]]&amp;nbsp;·
[[:am:|አማርኛ]]&amp;nbsp;·
[[:bm:|Bamanankan]]&amp;nbsp;·
[[:ny:|Chi-Chewa]]&amp;nbsp;·
[[:sn:|chiShona]]&amp;nbsp;·
[[:tum:|chiTumbuka]]&amp;nbsp;·
[[:ee:|Ɛʋɛ]]&amp;nbsp;·
[[:ff:|Fulfude]]&amp;nbsp;·
[[:ki:|Gĩkũyũ]]&amp;nbsp;·
[[:ha:|هَوُسَ]]&amp;nbsp;·
[[:ig:|Ìgbo]]&amp;nbsp;·
[[:xh:|isiXhosa]]&amp;nbsp;·
[[:rw:|Kinyarwanda]]&amp;nbsp;·
[[:rn:|Kirundi]]&amp;nbsp;·
[[:sw:|Kiswahili]]&amp;nbsp;·
[[:kg:|Kongo]]&amp;nbsp;·
[[:ln:|Lingala]]&amp;nbsp;·
[[:lg:|Luganda]]&amp;nbsp;·
[[:mg:|Malagasy]]&amp;nbsp;·
[[:arz:|مصرى]]&amp;nbsp;·
[[:om:|Oromoo]]&amp;nbsp;·
[[:sg:|Sängö]]&amp;nbsp;·
[[:st:|seSotho]]&amp;nbsp;·
[[:tn:|Setswana]]&amp;nbsp;·
[[:ss:|SiSwati]]&amp;nbsp;·
[[:so:|Soomaaliga]]&amp;nbsp;·
[[:kab:|Taqbaylit]]&amp;nbsp;·
[[:ti:|ትግርኛ]]&amp;nbsp;·
[[:ve:|Tshivenda]]&amp;nbsp;·
[[:tw:|Twi]]&amp;nbsp;·
[[:wo:|Wolof]]&amp;nbsp;·
[[:ts:|Xitsonga]]&amp;nbsp;·
[[:yo:|Yorùbá]]&amp;nbsp;·
(Nangabe ufuna ukuqala Ama-Wikipedia khulu, qala ku-bar engenzasi)
&lt;div class=&quot;plainlinks&quot;&gt;
; Amaphrojekhthi afanako
: [http://meta.wikipedia.org Meta-Wikipedia]&amp;nbsp;· [http://wiktionary.org Wiktionary]&amp;nbsp;· [http://wikibooks.org Wikibooks]&amp;nbsp;· [http://wikiquote.org Wikiquote]&amp;nbsp;· [http://wikisource.org Wikisource]
&lt;/div&gt;</text>
      <sha1>0ddcnmgrj6fmvxtgt8zv3oh3acwpd6y</sha1>
    </revision>
  </page>
  <page>
    <title>Main Page/Topics</title>
    <ns>0</ns>
    <id>215</id>
    <revision>
      <id>1099</id>
      <timestamp>2016-02-20T13:36:16Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;|colspan=&quot;6&quot; align=&quot;center&quot; bgcolor=&quot;white&quot; | {| width=&quot;100%&quot;  border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;5&quot; &lt;!----------------------------------------------&gt; | width=&quot;10%&quot; | I...&quot;</comment>
      <origin>1099</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="710" sha1="cv8kxso65mhdy6sg52rna736jf3xcku" xml:space="preserve">|colspan=&quot;6&quot; align=&quot;center&quot; bgcolor=&quot;white&quot; |
{| width=&quot;100%&quot;  border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;5&quot;
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Nuvola apps bookcase.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 95%; &quot; |  '''Sesotho sa Leboa'''&lt;br/&gt; 
[[Leina la temana]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Sefoka sa Afrika Borwa]]&amp;nbsp;-
[[Sepedi]]&amp;nbsp;- 
[[Sepedi mo internet]]&amp;nbsp;-
[[Kopanobokgoši]]&amp;nbsp;-
[[Pherekgong]]&amp;nbsp;-
[[Dibokwane]]&amp;nbsp;-
[[Hlakola]]&amp;nbsp;-
[[Moranang]]&amp;nbsp;-
[[Mopitlo]]&amp;nbsp;-
[[Phupu]]&amp;nbsp;-
[[Mosegamanye]]&amp;nbsp;-
[[Phato]]&amp;nbsp;-
[[Lewedi]]&amp;nbsp;-
[[Diphalane]]&amp;nbsp;-
[[Dibatsela]]&amp;nbsp;-
[[Manthole]] &amp;nbsp;-
[[Nomoro|Dinomoro]]</text>
      <sha1>cv8kxso65mhdy6sg52rna736jf3xcku</sha1>
    </revision>
    <revision>
      <id>1100</id>
      <parentid>1099</parentid>
      <timestamp>2016-02-20T13:39:19Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1100</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3761" sha1="5z7ayis4t9wmoex1mjwlutdaxhqmgpi" xml:space="preserve">&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Nuvola apps bookcase.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 95%; &quot; |  '''Sesotho sa Leboa'''&lt;br/&gt; 
[[Leina la temana]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Sefoka sa Afrika Borwa]]&amp;nbsp;-
[[Sepedi]]&amp;nbsp;- 
[[Sepedi mo internet]]&amp;nbsp;-
[[Kopanobokgoši]]&amp;nbsp;-
[[Pherekgong]]&amp;nbsp;-
[[Dibokwane]]&amp;nbsp;-
[[Hlakola]]&amp;nbsp;-
[[Moranang]]&amp;nbsp;-
[[Mopitlo]]&amp;nbsp;-
[[Phupu]]&amp;nbsp;-
[[Mosegamanye]]&amp;nbsp;-
[[Phato]]&amp;nbsp;-
[[Lewedi]]&amp;nbsp;-
[[Diphalane]]&amp;nbsp;-
[[Dibatsela]]&amp;nbsp;-
[[Manthole]] &amp;nbsp;-
[[Nomoro|Dinomoro]]
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:P countries-lightblue.png|40px|center]]
| style=&quot;font-size: 95%; border-top: 1px dashed #AAAAAA;&quot; | '''Thutafase'''&lt;br/&gt;
[[Thutafase]]&amp;nbsp;- 
[[Yuropa]]&amp;nbsp;- 
[[Asia]]&amp;nbsp;- 
[[Afrika]]&amp;nbsp;- 
[[Amerika]]&amp;nbsp;- 
[[Oceania]]&amp;nbsp;- 
[[Antarctica]]&amp;nbsp;- 
[[Australia]]&amp;nbsp;- 
[[Lefase]]&amp;nbsp;- 
[[Lefasana]]
&lt;!----------------------------------------------&gt;
|- 
&lt;!----------------------------------------------&gt;
| [[Isimumathi:P_religion_world.svg|40px|center]]
| style=&quot;font-size: 95%; border-top: 1px dashed #AAAAAA;&quot; | '''Bodumedi'''&lt;br/&gt;
[[Modimo]]&amp;nbsp;- 
[[Sebuda]]&amp;nbsp;- 
[[Sejuda]]&amp;nbsp;- 
[[Sekriste]]&amp;nbsp;- 
[[Seporotestante]]
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Nuvola apps kcoloredit.svg|40px|center]]
| style=&quot;font-size: 95%; border-top: 1px dashed #AAAAAA;&quot; | '''Dimala'''&lt;br/&gt;
[[Mmala wa gauta|Gauta]]&amp;nbsp;- 
[[Hwibidu]]&amp;nbsp;-
[[Namune (mmala)|Namune]]&amp;nbsp;- 
[[Ntsho]]&amp;nbsp;-
[[Phifadu]]&amp;nbsp;- 
[[Pinki]]&amp;nbsp;- 
[[Pududu]]&amp;nbsp;- 
[[Purepura]]&amp;nbsp;- 
[[Putswa]]&amp;nbsp;-
[[Serolane]]&amp;nbsp;-
[[Silifêra (mmala)|Silifêra]]&amp;nbsp;-
[[Tala]]&amp;nbsp;-
[[Tšhweu]]
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Gnome-globe.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 95%;&quot; | '''Dinaga'''&lt;br/&gt;
[[Afrika Borwa]]&amp;nbsp;- 
[[Algeria]]&amp;nbsp;- 
[[Angola]]&amp;nbsp;- 
[[Benin]]&amp;nbsp;- 
[[Botswana]]&amp;nbsp;- 
[[Burkina Faso]]&amp;nbsp;- 
[[Burundi]]&amp;nbsp;-  
[[Cameroon]]&amp;nbsp;- 
[[Canary Islands]]&amp;nbsp;- 
[[Cape Verde]]&amp;nbsp;-
[[Central African Republic]]&amp;nbsp;- 
[[Ceuta]]&amp;nbsp;- 
[[Chad]]&amp;nbsp;- 
[[Comoros]]&amp;nbsp;- 
[[Côte d'Ivoire]]&amp;nbsp;- 
[[Democratic Republic of the Congo]]&amp;nbsp;- 
[[Djibouti]]&amp;nbsp;- 
[[Egypt]]&amp;nbsp;- 
[[Equatorial Guinea]]&amp;nbsp;- 
[[Eritrea]]&amp;nbsp;- 
[[Ethiopia]]&amp;nbsp;- 
[[Fora]]&amp;nbsp;- 
[[Gabon]]&amp;nbsp;- 
[[Gambia]]&amp;nbsp;- 
[[Ghana]]&amp;nbsp;- 
[[Guinea]]&amp;nbsp;- 
[[Guinea-Bissau]]&amp;nbsp;- 
[[Ireland]]&amp;nbsp;- 
[[Japane]]&amp;nbsp;-
[[Kenya]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Liberia]]&amp;nbsp;- 
[[Libya]]&amp;nbsp;- 
[[Madagascar]]&amp;nbsp;- 
[[Madeira|Madeira Islands]]&amp;nbsp;- 
[[Malawi]]&amp;nbsp;- 
[[Mali]]&amp;nbsp;- 
[[Mauritania]]&amp;nbsp;- 
[[Mauritius]]&amp;nbsp;-  
[[Mayotte]]&amp;nbsp;- 
[[Melilla]] &amp;nbsp;- 
[[Morocco]]&amp;nbsp;-  
[[Mozambique]]&amp;nbsp;-
[[Namibia]]&amp;nbsp;- 
[[New Zealand]]&amp;nbsp;- 
[[Niger]]&amp;nbsp;- 
[[Nigeria]]&amp;nbsp;- 
[[Pakistan]]&amp;nbsp;-
[[Republic ya Congo|Congo]]&amp;nbsp;- 
[[Réunion]]&amp;nbsp;- 
[[Rwanda]]&amp;nbsp;- 
[[Saint Helena]]&amp;nbsp;- 
[[São Tomé and Príncipe]]&amp;nbsp;-
[[Senegal]]&amp;nbsp;- 
[[Seychelles]]&amp;nbsp;- 
[[Sierra Leone]]&amp;nbsp;- 
[[Somalia]]&amp;nbsp;- 
[[Sri Lanka]]&amp;nbsp;- 
[[Sudan]]&amp;nbsp;-  
[[Swaziland]]&amp;nbsp;- 
[[Tanzania]]&amp;nbsp;-
[[Togo]]&amp;nbsp;-
[[Tšhaena]]&amp;nbsp;-  
[[Tunisia]]&amp;nbsp;- 
[[Uganda]]&amp;nbsp;- 
[[United States of America|United States]]&amp;nbsp;-
[[Western Sahara]]&amp;nbsp;- 
[[Zambia]]&amp;nbsp;- 
[[Zimbabwe]] 
&lt;!----------------------------------------------&gt;
|- 
&lt;!----------------------------------------------&gt;</text>
      <sha1>5z7ayis4t9wmoex1mjwlutdaxhqmgpi</sha1>
    </revision>
    <revision>
      <id>1101</id>
      <parentid>1100</parentid>
      <timestamp>2016-02-20T13:40:42Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1101</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4194" sha1="nkzzbg3f28swmbni1qdmlq5fy63t2i1" xml:space="preserve">{| cellpadding=&quot;4&quot; cellspacing=&quot;3&quot; style=&quot;width:100%; border:2px solid #0000ff;&quot;  
|-----
|colspan=&quot;6&quot; align=&quot;center&quot; bgcolor=&quot;#3CF&quot; |

{|width=&quot;100%&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; style=&quot;vertical-align:top; background:#3CF;&quot;
|style=&quot;color:#000000;&quot;|&lt;div style=&quot;float:left;&quot;&gt;&lt;center&gt; '''Temana tša bobedi''' 
|}
|-----
|colspan=&quot;6&quot; align=&quot;center&quot; bgcolor=&quot;white&quot; |

{| width=&quot;100%&quot;  border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;5&quot;
|- 
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Nuvola apps bookcase.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 95%; &quot; |  '''Sesotho sa Leboa'''&lt;br/&gt; 
[[Leina la temana]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Sefoka sa Afrika Borwa]]&amp;nbsp;-
[[Sepedi]]&amp;nbsp;- 
[[Sepedi mo internet]]&amp;nbsp;-
[[Kopanobokgoši]]&amp;nbsp;-
[[Pherekgong]]&amp;nbsp;-
[[Dibokwane]]&amp;nbsp;-
[[Hlakola]]&amp;nbsp;-
[[Moranang]]&amp;nbsp;-
[[Mopitlo]]&amp;nbsp;-
[[Phupu]]&amp;nbsp;-
[[Mosegamanye]]&amp;nbsp;-
[[Phato]]&amp;nbsp;-
[[Lewedi]]&amp;nbsp;-
[[Diphalane]]&amp;nbsp;-
[[Dibatsela]]&amp;nbsp;-
[[Manthole]] &amp;nbsp;-
[[Nomoro|Dinomoro]]
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:P countries-lightblue.png|40px|center]]
| style=&quot;font-size: 95%; border-top: 1px dashed #AAAAAA;&quot; | '''Thutafase'''&lt;br/&gt;
[[Thutafase]]&amp;nbsp;- 
[[Yuropa]]&amp;nbsp;- 
[[Asia]]&amp;nbsp;- 
[[Afrika]]&amp;nbsp;- 
[[Amerika]]&amp;nbsp;- 
[[Oceania]]&amp;nbsp;- 
[[Antarctica]]&amp;nbsp;- 
[[Australia]]&amp;nbsp;- 
[[Lefase]]&amp;nbsp;- 
[[Lefasana]]
&lt;!----------------------------------------------&gt;
|- 
&lt;!----------------------------------------------&gt;
| [[Isimumathi:P_religion_world.svg|40px|center]]
| style=&quot;font-size: 95%; border-top: 1px dashed #AAAAAA;&quot; | '''Bodumedi'''&lt;br/&gt;
[[Modimo]]&amp;nbsp;- 
[[Sebuda]]&amp;nbsp;- 
[[Sejuda]]&amp;nbsp;- 
[[Sekriste]]&amp;nbsp;- 
[[Seporotestante]]
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Nuvola apps kcoloredit.svg|40px|center]]
| style=&quot;font-size: 95%; border-top: 1px dashed #AAAAAA;&quot; | '''Dimala'''&lt;br/&gt;
[[Mmala wa gauta|Gauta]]&amp;nbsp;- 
[[Hwibidu]]&amp;nbsp;-
[[Namune (mmala)|Namune]]&amp;nbsp;- 
[[Ntsho]]&amp;nbsp;-
[[Phifadu]]&amp;nbsp;- 
[[Pinki]]&amp;nbsp;- 
[[Pududu]]&amp;nbsp;- 
[[Purepura]]&amp;nbsp;- 
[[Putswa]]&amp;nbsp;-
[[Serolane]]&amp;nbsp;-
[[Silifêra (mmala)|Silifêra]]&amp;nbsp;-
[[Tala]]&amp;nbsp;-
[[Tšhweu]]
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Gnome-globe.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 95%;&quot; | '''Dinaga'''&lt;br/&gt;
[[Afrika Borwa]]&amp;nbsp;- 
[[Algeria]]&amp;nbsp;- 
[[Angola]]&amp;nbsp;- 
[[Benin]]&amp;nbsp;- 
[[Botswana]]&amp;nbsp;- 
[[Burkina Faso]]&amp;nbsp;- 
[[Burundi]]&amp;nbsp;-  
[[Cameroon]]&amp;nbsp;- 
[[Canary Islands]]&amp;nbsp;- 
[[Cape Verde]]&amp;nbsp;-
[[Central African Republic]]&amp;nbsp;- 
[[Ceuta]]&amp;nbsp;- 
[[Chad]]&amp;nbsp;- 
[[Comoros]]&amp;nbsp;- 
[[Côte d'Ivoire]]&amp;nbsp;- 
[[Democratic Republic of the Congo]]&amp;nbsp;- 
[[Djibouti]]&amp;nbsp;- 
[[Egypt]]&amp;nbsp;- 
[[Equatorial Guinea]]&amp;nbsp;- 
[[Eritrea]]&amp;nbsp;- 
[[Ethiopia]]&amp;nbsp;- 
[[Fora]]&amp;nbsp;- 
[[Gabon]]&amp;nbsp;- 
[[Gambia]]&amp;nbsp;- 
[[Ghana]]&amp;nbsp;- 
[[Guinea]]&amp;nbsp;- 
[[Guinea-Bissau]]&amp;nbsp;- 
[[Ireland]]&amp;nbsp;- 
[[Japane]]&amp;nbsp;-
[[Kenya]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Liberia]]&amp;nbsp;- 
[[Libya]]&amp;nbsp;- 
[[Madagascar]]&amp;nbsp;- 
[[Madeira|Madeira Islands]]&amp;nbsp;- 
[[Malawi]]&amp;nbsp;- 
[[Mali]]&amp;nbsp;- 
[[Mauritania]]&amp;nbsp;- 
[[Mauritius]]&amp;nbsp;-  
[[Mayotte]]&amp;nbsp;- 
[[Melilla]] &amp;nbsp;- 
[[Morocco]]&amp;nbsp;-  
[[Mozambique]]&amp;nbsp;-
[[Namibia]]&amp;nbsp;- 
[[New Zealand]]&amp;nbsp;- 
[[Niger]]&amp;nbsp;- 
[[Nigeria]]&amp;nbsp;- 
[[Pakistan]]&amp;nbsp;-
[[Republic ya Congo|Congo]]&amp;nbsp;- 
[[Réunion]]&amp;nbsp;- 
[[Rwanda]]&amp;nbsp;- 
[[Saint Helena]]&amp;nbsp;- 
[[São Tomé and Príncipe]]&amp;nbsp;-
[[Senegal]]&amp;nbsp;- 
[[Seychelles]]&amp;nbsp;- 
[[Sierra Leone]]&amp;nbsp;- 
[[Somalia]]&amp;nbsp;- 
[[Sri Lanka]]&amp;nbsp;- 
[[Sudan]]&amp;nbsp;-  
[[Swaziland]]&amp;nbsp;- 
[[Tanzania]]&amp;nbsp;-
[[Togo]]&amp;nbsp;-
[[Tšhaena]]&amp;nbsp;-  
[[Tunisia]]&amp;nbsp;- 
[[Uganda]]&amp;nbsp;- 
[[United States of America|United States]]&amp;nbsp;-
[[Western Sahara]]&amp;nbsp;- 
[[Zambia]]&amp;nbsp;- 
[[Zimbabwe]] 
&lt;!----------------------------------------------&gt;
|- 
&lt;!----------------------------------------------&gt;</text>
      <sha1>nkzzbg3f28swmbni1qdmlq5fy63t2i1</sha1>
    </revision>
    <revision>
      <id>1102</id>
      <parentid>1101</parentid>
      <timestamp>2016-02-20T13:42:29Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1102</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3909" sha1="ob6bxpkzyuf2ytxjflqcoc0k350mer6" xml:space="preserve">{| cellpadding=&quot;4&quot; cellspacing=&quot;3&quot; style=&quot;width:100%; border:2px solid #0000ff;&quot;  
|-----
|colspan=&quot;6&quot; align=&quot;center&quot; bgcolor=&quot;#3CF&quot; |
|-----
|colspan=&quot;6&quot; align=&quot;center&quot; bgcolor=&quot;white&quot; |

{| width=&quot;100%&quot;  border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;5&quot;
|- 
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Nuvola apps bookcase.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 95%; &quot; |  '''Sesotho sa Leboa'''&lt;br/&gt; 
[[Leina la temana]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Sefoka sa Afrika Borwa]]&amp;nbsp;-
[[Sepedi]]&amp;nbsp;- 
[[Sepedi mo internet]]&amp;nbsp;-
[[Kopanobokgoši]]&amp;nbsp;-
[[Pherekgong]]&amp;nbsp;-
[[Dibokwane]]&amp;nbsp;-
[[Hlakola]]&amp;nbsp;-
[[Moranang]]&amp;nbsp;-
[[Mopitlo]]&amp;nbsp;-
[[Phupu]]&amp;nbsp;-
[[Mosegamanye]]&amp;nbsp;-
[[Phato]]&amp;nbsp;-
[[Lewedi]]&amp;nbsp;-
[[Diphalane]]&amp;nbsp;-
[[Dibatsela]]&amp;nbsp;-
[[Manthole]] &amp;nbsp;-
[[Nomoro|Dinomoro]]
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:P countries-lightblue.png|40px|center]]
| style=&quot;font-size: 95%; border-top: 1px dashed #AAAAAA;&quot; | '''Thutafase'''&lt;br/&gt;
[[Thutafase]]&amp;nbsp;- 
[[Yuropa]]&amp;nbsp;- 
[[Asia]]&amp;nbsp;- 
[[Afrika]]&amp;nbsp;- 
[[Amerika]]&amp;nbsp;- 
[[Oceania]]&amp;nbsp;- 
[[Antarctica]]&amp;nbsp;- 
[[Australia]]&amp;nbsp;- 
[[Lefase]]&amp;nbsp;- 
[[Lefasana]]
&lt;!----------------------------------------------&gt;
|- 
&lt;!----------------------------------------------&gt;
| [[Isimumathi:P_religion_world.svg|40px|center]]
| style=&quot;font-size: 95%; border-top: 1px dashed #AAAAAA;&quot; | '''Bodumedi'''&lt;br/&gt;
[[Modimo]]&amp;nbsp;- 
[[Sebuda]]&amp;nbsp;- 
[[Sejuda]]&amp;nbsp;- 
[[Sekriste]]&amp;nbsp;- 
[[Seporotestante]]
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Nuvola apps kcoloredit.svg|40px|center]]
| style=&quot;font-size: 95%; border-top: 1px dashed #AAAAAA;&quot; | '''Dimala'''&lt;br/&gt;
[[Mmala wa gauta|Gauta]]&amp;nbsp;- 
[[Hwibidu]]&amp;nbsp;-
[[Namune (mmala)|Namune]]&amp;nbsp;- 
[[Ntsho]]&amp;nbsp;-
[[Phifadu]]&amp;nbsp;- 
[[Pinki]]&amp;nbsp;- 
[[Pududu]]&amp;nbsp;- 
[[Purepura]]&amp;nbsp;- 
[[Putswa]]&amp;nbsp;-
[[Serolane]]&amp;nbsp;-
[[Silifêra (mmala)|Silifêra]]&amp;nbsp;-
[[Tala]]&amp;nbsp;-
[[Tšhweu]]
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Gnome-globe.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 95%;&quot; | '''Dinaga'''&lt;br/&gt;
[[Afrika Borwa]]&amp;nbsp;- 
[[Algeria]]&amp;nbsp;- 
[[Angola]]&amp;nbsp;- 
[[Benin]]&amp;nbsp;- 
[[Botswana]]&amp;nbsp;- 
[[Burkina Faso]]&amp;nbsp;- 
[[Burundi]]&amp;nbsp;-  
[[Cameroon]]&amp;nbsp;- 
[[Canary Islands]]&amp;nbsp;- 
[[Cape Verde]]&amp;nbsp;-
[[Central African Republic]]&amp;nbsp;- 
[[Ceuta]]&amp;nbsp;- 
[[Chad]]&amp;nbsp;- 
[[Comoros]]&amp;nbsp;- 
[[Côte d'Ivoire]]&amp;nbsp;- 
[[Democratic Republic of the Congo]]&amp;nbsp;- 
[[Djibouti]]&amp;nbsp;- 
[[Egypt]]&amp;nbsp;- 
[[Equatorial Guinea]]&amp;nbsp;- 
[[Eritrea]]&amp;nbsp;- 
[[Ethiopia]]&amp;nbsp;- 
[[Fora]]&amp;nbsp;- 
[[Gabon]]&amp;nbsp;- 
[[Gambia]]&amp;nbsp;- 
[[Ghana]]&amp;nbsp;- 
[[Guinea]]&amp;nbsp;- 
[[Guinea-Bissau]]&amp;nbsp;- 
[[Ireland]]&amp;nbsp;- 
[[Japane]]&amp;nbsp;-
[[Kenya]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Liberia]]&amp;nbsp;- 
[[Libya]]&amp;nbsp;- 
[[Madagascar]]&amp;nbsp;- 
[[Madeira|Madeira Islands]]&amp;nbsp;- 
[[Malawi]]&amp;nbsp;- 
[[Mali]]&amp;nbsp;- 
[[Mauritania]]&amp;nbsp;- 
[[Mauritius]]&amp;nbsp;-  
[[Mayotte]]&amp;nbsp;- 
[[Melilla]] &amp;nbsp;- 
[[Morocco]]&amp;nbsp;-  
[[Mozambique]]&amp;nbsp;-
[[Namibia]]&amp;nbsp;- 
[[New Zealand]]&amp;nbsp;- 
[[Niger]]&amp;nbsp;- 
[[Nigeria]]&amp;nbsp;- 
[[Pakistan]]&amp;nbsp;-
[[Republic ya Congo|Congo]]&amp;nbsp;- 
[[Réunion]]&amp;nbsp;- 
[[Rwanda]]&amp;nbsp;- 
[[Saint Helena]]&amp;nbsp;- 
[[São Tomé and Príncipe]]&amp;nbsp;-
[[Senegal]]&amp;nbsp;- 
[[Seychelles]]&amp;nbsp;- 
[[Sierra Leone]]&amp;nbsp;- 
[[Somalia]]&amp;nbsp;- 
[[Sri Lanka]]&amp;nbsp;- 
[[Sudan]]&amp;nbsp;-  
[[Swaziland]]&amp;nbsp;- 
[[Tanzania]]&amp;nbsp;-
[[Togo]]&amp;nbsp;-
[[Tšhaena]]&amp;nbsp;-  
[[Tunisia]]&amp;nbsp;- 
[[Uganda]]&amp;nbsp;- 
[[United States of America|United States]]&amp;nbsp;-
[[Western Sahara]]&amp;nbsp;- 
[[Zambia]]&amp;nbsp;- 
[[Zimbabwe]]</text>
      <sha1>ob6bxpkzyuf2ytxjflqcoc0k350mer6</sha1>
    </revision>
    <revision>
      <id>1103</id>
      <parentid>1102</parentid>
      <timestamp>2016-02-20T13:43:34Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1103</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3909" sha1="ginhegc1gtkaysm2gfssw091pgd2urs" xml:space="preserve">{| cellpadding=&quot;5&quot; cellspacing=&quot;3&quot; style=&quot;width:100%; border:2px solid #0000ff;&quot;  
|-----
|colspan=&quot;6&quot; align=&quot;center&quot; bgcolor=&quot;#3CF&quot; |
|-----
|colspan=&quot;6&quot; align=&quot;center&quot; bgcolor=&quot;white&quot; |

{| width=&quot;100%&quot;  border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;5&quot;
|- 
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Nuvola apps bookcase.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 95%; &quot; |  '''Sesotho sa Leboa'''&lt;br/&gt; 
[[Leina la temana]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Sefoka sa Afrika Borwa]]&amp;nbsp;-
[[Sepedi]]&amp;nbsp;- 
[[Sepedi mo internet]]&amp;nbsp;-
[[Kopanobokgoši]]&amp;nbsp;-
[[Pherekgong]]&amp;nbsp;-
[[Dibokwane]]&amp;nbsp;-
[[Hlakola]]&amp;nbsp;-
[[Moranang]]&amp;nbsp;-
[[Mopitlo]]&amp;nbsp;-
[[Phupu]]&amp;nbsp;-
[[Mosegamanye]]&amp;nbsp;-
[[Phato]]&amp;nbsp;-
[[Lewedi]]&amp;nbsp;-
[[Diphalane]]&amp;nbsp;-
[[Dibatsela]]&amp;nbsp;-
[[Manthole]] &amp;nbsp;-
[[Nomoro|Dinomoro]]
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:P countries-lightblue.png|40px|center]]
| style=&quot;font-size: 95%; border-top: 1px dashed #AAAAAA;&quot; | '''Thutafase'''&lt;br/&gt;
[[Thutafase]]&amp;nbsp;- 
[[Yuropa]]&amp;nbsp;- 
[[Asia]]&amp;nbsp;- 
[[Afrika]]&amp;nbsp;- 
[[Amerika]]&amp;nbsp;- 
[[Oceania]]&amp;nbsp;- 
[[Antarctica]]&amp;nbsp;- 
[[Australia]]&amp;nbsp;- 
[[Lefase]]&amp;nbsp;- 
[[Lefasana]]
&lt;!----------------------------------------------&gt;
|- 
&lt;!----------------------------------------------&gt;
| [[Isimumathi:P_religion_world.svg|40px|center]]
| style=&quot;font-size: 95%; border-top: 1px dashed #AAAAAA;&quot; | '''Bodumedi'''&lt;br/&gt;
[[Modimo]]&amp;nbsp;- 
[[Sebuda]]&amp;nbsp;- 
[[Sejuda]]&amp;nbsp;- 
[[Sekriste]]&amp;nbsp;- 
[[Seporotestante]]
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Nuvola apps kcoloredit.svg|40px|center]]
| style=&quot;font-size: 95%; border-top: 1px dashed #AAAAAA;&quot; | '''Dimala'''&lt;br/&gt;
[[Mmala wa gauta|Gauta]]&amp;nbsp;- 
[[Hwibidu]]&amp;nbsp;-
[[Namune (mmala)|Namune]]&amp;nbsp;- 
[[Ntsho]]&amp;nbsp;-
[[Phifadu]]&amp;nbsp;- 
[[Pinki]]&amp;nbsp;- 
[[Pududu]]&amp;nbsp;- 
[[Purepura]]&amp;nbsp;- 
[[Putswa]]&amp;nbsp;-
[[Serolane]]&amp;nbsp;-
[[Silifêra (mmala)|Silifêra]]&amp;nbsp;-
[[Tala]]&amp;nbsp;-
[[Tšhweu]]
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Gnome-globe.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 95%;&quot; | '''Dinaga'''&lt;br/&gt;
[[Afrika Borwa]]&amp;nbsp;- 
[[Algeria]]&amp;nbsp;- 
[[Angola]]&amp;nbsp;- 
[[Benin]]&amp;nbsp;- 
[[Botswana]]&amp;nbsp;- 
[[Burkina Faso]]&amp;nbsp;- 
[[Burundi]]&amp;nbsp;-  
[[Cameroon]]&amp;nbsp;- 
[[Canary Islands]]&amp;nbsp;- 
[[Cape Verde]]&amp;nbsp;-
[[Central African Republic]]&amp;nbsp;- 
[[Ceuta]]&amp;nbsp;- 
[[Chad]]&amp;nbsp;- 
[[Comoros]]&amp;nbsp;- 
[[Côte d'Ivoire]]&amp;nbsp;- 
[[Democratic Republic of the Congo]]&amp;nbsp;- 
[[Djibouti]]&amp;nbsp;- 
[[Egypt]]&amp;nbsp;- 
[[Equatorial Guinea]]&amp;nbsp;- 
[[Eritrea]]&amp;nbsp;- 
[[Ethiopia]]&amp;nbsp;- 
[[Fora]]&amp;nbsp;- 
[[Gabon]]&amp;nbsp;- 
[[Gambia]]&amp;nbsp;- 
[[Ghana]]&amp;nbsp;- 
[[Guinea]]&amp;nbsp;- 
[[Guinea-Bissau]]&amp;nbsp;- 
[[Ireland]]&amp;nbsp;- 
[[Japane]]&amp;nbsp;-
[[Kenya]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Liberia]]&amp;nbsp;- 
[[Libya]]&amp;nbsp;- 
[[Madagascar]]&amp;nbsp;- 
[[Madeira|Madeira Islands]]&amp;nbsp;- 
[[Malawi]]&amp;nbsp;- 
[[Mali]]&amp;nbsp;- 
[[Mauritania]]&amp;nbsp;- 
[[Mauritius]]&amp;nbsp;-  
[[Mayotte]]&amp;nbsp;- 
[[Melilla]] &amp;nbsp;- 
[[Morocco]]&amp;nbsp;-  
[[Mozambique]]&amp;nbsp;-
[[Namibia]]&amp;nbsp;- 
[[New Zealand]]&amp;nbsp;- 
[[Niger]]&amp;nbsp;- 
[[Nigeria]]&amp;nbsp;- 
[[Pakistan]]&amp;nbsp;-
[[Republic ya Congo|Congo]]&amp;nbsp;- 
[[Réunion]]&amp;nbsp;- 
[[Rwanda]]&amp;nbsp;- 
[[Saint Helena]]&amp;nbsp;- 
[[São Tomé and Príncipe]]&amp;nbsp;-
[[Senegal]]&amp;nbsp;- 
[[Seychelles]]&amp;nbsp;- 
[[Sierra Leone]]&amp;nbsp;- 
[[Somalia]]&amp;nbsp;- 
[[Sri Lanka]]&amp;nbsp;- 
[[Sudan]]&amp;nbsp;-  
[[Swaziland]]&amp;nbsp;- 
[[Tanzania]]&amp;nbsp;-
[[Togo]]&amp;nbsp;-
[[Tšhaena]]&amp;nbsp;-  
[[Tunisia]]&amp;nbsp;- 
[[Uganda]]&amp;nbsp;- 
[[United States of America|United States]]&amp;nbsp;-
[[Western Sahara]]&amp;nbsp;- 
[[Zambia]]&amp;nbsp;- 
[[Zimbabwe]]</text>
      <sha1>ginhegc1gtkaysm2gfssw091pgd2urs</sha1>
    </revision>
    <revision>
      <id>1104</id>
      <parentid>1103</parentid>
      <timestamp>2016-02-20T13:44:00Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1104</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3909" sha1="tj6h9282pw3dpj4ma54gm0pre4vy50u" xml:space="preserve">{| cellpadding=&quot;5&quot; cellspacing=&quot;4&quot; style=&quot;width:100%; border:2px solid #0000ff;&quot;  
|-----
|colspan=&quot;6&quot; align=&quot;center&quot; bgcolor=&quot;#3CF&quot; |
|-----
|colspan=&quot;6&quot; align=&quot;center&quot; bgcolor=&quot;white&quot; |

{| width=&quot;100%&quot;  border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;5&quot;
|- 
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Nuvola apps bookcase.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 95%; &quot; |  '''Sesotho sa Leboa'''&lt;br/&gt; 
[[Leina la temana]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Sefoka sa Afrika Borwa]]&amp;nbsp;-
[[Sepedi]]&amp;nbsp;- 
[[Sepedi mo internet]]&amp;nbsp;-
[[Kopanobokgoši]]&amp;nbsp;-
[[Pherekgong]]&amp;nbsp;-
[[Dibokwane]]&amp;nbsp;-
[[Hlakola]]&amp;nbsp;-
[[Moranang]]&amp;nbsp;-
[[Mopitlo]]&amp;nbsp;-
[[Phupu]]&amp;nbsp;-
[[Mosegamanye]]&amp;nbsp;-
[[Phato]]&amp;nbsp;-
[[Lewedi]]&amp;nbsp;-
[[Diphalane]]&amp;nbsp;-
[[Dibatsela]]&amp;nbsp;-
[[Manthole]] &amp;nbsp;-
[[Nomoro|Dinomoro]]
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:P countries-lightblue.png|40px|center]]
| style=&quot;font-size: 95%; border-top: 1px dashed #AAAAAA;&quot; | '''Thutafase'''&lt;br/&gt;
[[Thutafase]]&amp;nbsp;- 
[[Yuropa]]&amp;nbsp;- 
[[Asia]]&amp;nbsp;- 
[[Afrika]]&amp;nbsp;- 
[[Amerika]]&amp;nbsp;- 
[[Oceania]]&amp;nbsp;- 
[[Antarctica]]&amp;nbsp;- 
[[Australia]]&amp;nbsp;- 
[[Lefase]]&amp;nbsp;- 
[[Lefasana]]
&lt;!----------------------------------------------&gt;
|- 
&lt;!----------------------------------------------&gt;
| [[Isimumathi:P_religion_world.svg|40px|center]]
| style=&quot;font-size: 95%; border-top: 1px dashed #AAAAAA;&quot; | '''Bodumedi'''&lt;br/&gt;
[[Modimo]]&amp;nbsp;- 
[[Sebuda]]&amp;nbsp;- 
[[Sejuda]]&amp;nbsp;- 
[[Sekriste]]&amp;nbsp;- 
[[Seporotestante]]
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Nuvola apps kcoloredit.svg|40px|center]]
| style=&quot;font-size: 95%; border-top: 1px dashed #AAAAAA;&quot; | '''Dimala'''&lt;br/&gt;
[[Mmala wa gauta|Gauta]]&amp;nbsp;- 
[[Hwibidu]]&amp;nbsp;-
[[Namune (mmala)|Namune]]&amp;nbsp;- 
[[Ntsho]]&amp;nbsp;-
[[Phifadu]]&amp;nbsp;- 
[[Pinki]]&amp;nbsp;- 
[[Pududu]]&amp;nbsp;- 
[[Purepura]]&amp;nbsp;- 
[[Putswa]]&amp;nbsp;-
[[Serolane]]&amp;nbsp;-
[[Silifêra (mmala)|Silifêra]]&amp;nbsp;-
[[Tala]]&amp;nbsp;-
[[Tšhweu]]
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Gnome-globe.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 95%;&quot; | '''Dinaga'''&lt;br/&gt;
[[Afrika Borwa]]&amp;nbsp;- 
[[Algeria]]&amp;nbsp;- 
[[Angola]]&amp;nbsp;- 
[[Benin]]&amp;nbsp;- 
[[Botswana]]&amp;nbsp;- 
[[Burkina Faso]]&amp;nbsp;- 
[[Burundi]]&amp;nbsp;-  
[[Cameroon]]&amp;nbsp;- 
[[Canary Islands]]&amp;nbsp;- 
[[Cape Verde]]&amp;nbsp;-
[[Central African Republic]]&amp;nbsp;- 
[[Ceuta]]&amp;nbsp;- 
[[Chad]]&amp;nbsp;- 
[[Comoros]]&amp;nbsp;- 
[[Côte d'Ivoire]]&amp;nbsp;- 
[[Democratic Republic of the Congo]]&amp;nbsp;- 
[[Djibouti]]&amp;nbsp;- 
[[Egypt]]&amp;nbsp;- 
[[Equatorial Guinea]]&amp;nbsp;- 
[[Eritrea]]&amp;nbsp;- 
[[Ethiopia]]&amp;nbsp;- 
[[Fora]]&amp;nbsp;- 
[[Gabon]]&amp;nbsp;- 
[[Gambia]]&amp;nbsp;- 
[[Ghana]]&amp;nbsp;- 
[[Guinea]]&amp;nbsp;- 
[[Guinea-Bissau]]&amp;nbsp;- 
[[Ireland]]&amp;nbsp;- 
[[Japane]]&amp;nbsp;-
[[Kenya]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Liberia]]&amp;nbsp;- 
[[Libya]]&amp;nbsp;- 
[[Madagascar]]&amp;nbsp;- 
[[Madeira|Madeira Islands]]&amp;nbsp;- 
[[Malawi]]&amp;nbsp;- 
[[Mali]]&amp;nbsp;- 
[[Mauritania]]&amp;nbsp;- 
[[Mauritius]]&amp;nbsp;-  
[[Mayotte]]&amp;nbsp;- 
[[Melilla]] &amp;nbsp;- 
[[Morocco]]&amp;nbsp;-  
[[Mozambique]]&amp;nbsp;-
[[Namibia]]&amp;nbsp;- 
[[New Zealand]]&amp;nbsp;- 
[[Niger]]&amp;nbsp;- 
[[Nigeria]]&amp;nbsp;- 
[[Pakistan]]&amp;nbsp;-
[[Republic ya Congo|Congo]]&amp;nbsp;- 
[[Réunion]]&amp;nbsp;- 
[[Rwanda]]&amp;nbsp;- 
[[Saint Helena]]&amp;nbsp;- 
[[São Tomé and Príncipe]]&amp;nbsp;-
[[Senegal]]&amp;nbsp;- 
[[Seychelles]]&amp;nbsp;- 
[[Sierra Leone]]&amp;nbsp;- 
[[Somalia]]&amp;nbsp;- 
[[Sri Lanka]]&amp;nbsp;- 
[[Sudan]]&amp;nbsp;-  
[[Swaziland]]&amp;nbsp;- 
[[Tanzania]]&amp;nbsp;-
[[Togo]]&amp;nbsp;-
[[Tšhaena]]&amp;nbsp;-  
[[Tunisia]]&amp;nbsp;- 
[[Uganda]]&amp;nbsp;- 
[[United States of America|United States]]&amp;nbsp;-
[[Western Sahara]]&amp;nbsp;- 
[[Zambia]]&amp;nbsp;- 
[[Zimbabwe]]</text>
      <sha1>tj6h9282pw3dpj4ma54gm0pre4vy50u</sha1>
    </revision>
    <revision>
      <id>1105</id>
      <parentid>1104</parentid>
      <timestamp>2016-02-20T13:45:14Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1105</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3844" sha1="tpwjwcy40n1hmgjcf18x81g7nuzl1vp" xml:space="preserve">{| cellpadding=&quot;5&quot; cellspacing=&quot;4&quot; style=&quot;width:100%; border:2px ;&quot;  
|-----
|colspan=&quot;6&quot; align=&quot;center&quot; bgcolor=&quot;white&quot; |

{| width=&quot;100%&quot;  border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;5&quot;
|- 
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Nuvola apps bookcase.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 95%; &quot; |  '''Sesotho sa Leboa'''&lt;br/&gt; 
[[Leina la temana]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Sefoka sa Afrika Borwa]]&amp;nbsp;-
[[Sepedi]]&amp;nbsp;- 
[[Sepedi mo internet]]&amp;nbsp;-
[[Kopanobokgoši]]&amp;nbsp;-
[[Pherekgong]]&amp;nbsp;-
[[Dibokwane]]&amp;nbsp;-
[[Hlakola]]&amp;nbsp;-
[[Moranang]]&amp;nbsp;-
[[Mopitlo]]&amp;nbsp;-
[[Phupu]]&amp;nbsp;-
[[Mosegamanye]]&amp;nbsp;-
[[Phato]]&amp;nbsp;-
[[Lewedi]]&amp;nbsp;-
[[Diphalane]]&amp;nbsp;-
[[Dibatsela]]&amp;nbsp;-
[[Manthole]] &amp;nbsp;-
[[Nomoro|Dinomoro]]
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:P countries-lightblue.png|40px|center]]
| style=&quot;font-size: 95%; border-top: 1px dashed #AAAAAA;&quot; | '''Thutafase'''&lt;br/&gt;
[[Thutafase]]&amp;nbsp;- 
[[Yuropa]]&amp;nbsp;- 
[[Asia]]&amp;nbsp;- 
[[Afrika]]&amp;nbsp;- 
[[Amerika]]&amp;nbsp;- 
[[Oceania]]&amp;nbsp;- 
[[Antarctica]]&amp;nbsp;- 
[[Australia]]&amp;nbsp;- 
[[Lefase]]&amp;nbsp;- 
[[Lefasana]]
&lt;!----------------------------------------------&gt;
|- 
&lt;!----------------------------------------------&gt;
| [[Isimumathi:P_religion_world.svg|40px|center]]
| style=&quot;font-size: 95%; border-top: 1px dashed #AAAAAA;&quot; | '''Bodumedi'''&lt;br/&gt;
[[Modimo]]&amp;nbsp;- 
[[Sebuda]]&amp;nbsp;- 
[[Sejuda]]&amp;nbsp;- 
[[Sekriste]]&amp;nbsp;- 
[[Seporotestante]]
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Nuvola apps kcoloredit.svg|40px|center]]
| style=&quot;font-size: 95%; border-top: 1px dashed #AAAAAA;&quot; | '''Dimala'''&lt;br/&gt;
[[Mmala wa gauta|Gauta]]&amp;nbsp;- 
[[Hwibidu]]&amp;nbsp;-
[[Namune (mmala)|Namune]]&amp;nbsp;- 
[[Ntsho]]&amp;nbsp;-
[[Phifadu]]&amp;nbsp;- 
[[Pinki]]&amp;nbsp;- 
[[Pududu]]&amp;nbsp;- 
[[Purepura]]&amp;nbsp;- 
[[Putswa]]&amp;nbsp;-
[[Serolane]]&amp;nbsp;-
[[Silifêra (mmala)|Silifêra]]&amp;nbsp;-
[[Tala]]&amp;nbsp;-
[[Tšhweu]]
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Gnome-globe.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 95%;&quot; | '''Dinaga'''&lt;br/&gt;
[[Afrika Borwa]]&amp;nbsp;- 
[[Algeria]]&amp;nbsp;- 
[[Angola]]&amp;nbsp;- 
[[Benin]]&amp;nbsp;- 
[[Botswana]]&amp;nbsp;- 
[[Burkina Faso]]&amp;nbsp;- 
[[Burundi]]&amp;nbsp;-  
[[Cameroon]]&amp;nbsp;- 
[[Canary Islands]]&amp;nbsp;- 
[[Cape Verde]]&amp;nbsp;-
[[Central African Republic]]&amp;nbsp;- 
[[Ceuta]]&amp;nbsp;- 
[[Chad]]&amp;nbsp;- 
[[Comoros]]&amp;nbsp;- 
[[Côte d'Ivoire]]&amp;nbsp;- 
[[Democratic Republic of the Congo]]&amp;nbsp;- 
[[Djibouti]]&amp;nbsp;- 
[[Egypt]]&amp;nbsp;- 
[[Equatorial Guinea]]&amp;nbsp;- 
[[Eritrea]]&amp;nbsp;- 
[[Ethiopia]]&amp;nbsp;- 
[[Fora]]&amp;nbsp;- 
[[Gabon]]&amp;nbsp;- 
[[Gambia]]&amp;nbsp;- 
[[Ghana]]&amp;nbsp;- 
[[Guinea]]&amp;nbsp;- 
[[Guinea-Bissau]]&amp;nbsp;- 
[[Ireland]]&amp;nbsp;- 
[[Japane]]&amp;nbsp;-
[[Kenya]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Liberia]]&amp;nbsp;- 
[[Libya]]&amp;nbsp;- 
[[Madagascar]]&amp;nbsp;- 
[[Madeira|Madeira Islands]]&amp;nbsp;- 
[[Malawi]]&amp;nbsp;- 
[[Mali]]&amp;nbsp;- 
[[Mauritania]]&amp;nbsp;- 
[[Mauritius]]&amp;nbsp;-  
[[Mayotte]]&amp;nbsp;- 
[[Melilla]] &amp;nbsp;- 
[[Morocco]]&amp;nbsp;-  
[[Mozambique]]&amp;nbsp;-
[[Namibia]]&amp;nbsp;- 
[[New Zealand]]&amp;nbsp;- 
[[Niger]]&amp;nbsp;- 
[[Nigeria]]&amp;nbsp;- 
[[Pakistan]]&amp;nbsp;-
[[Republic ya Congo|Congo]]&amp;nbsp;- 
[[Réunion]]&amp;nbsp;- 
[[Rwanda]]&amp;nbsp;- 
[[Saint Helena]]&amp;nbsp;- 
[[São Tomé and Príncipe]]&amp;nbsp;-
[[Senegal]]&amp;nbsp;- 
[[Seychelles]]&amp;nbsp;- 
[[Sierra Leone]]&amp;nbsp;- 
[[Somalia]]&amp;nbsp;- 
[[Sri Lanka]]&amp;nbsp;- 
[[Sudan]]&amp;nbsp;-  
[[Swaziland]]&amp;nbsp;- 
[[Tanzania]]&amp;nbsp;-
[[Togo]]&amp;nbsp;-
[[Tšhaena]]&amp;nbsp;-  
[[Tunisia]]&amp;nbsp;- 
[[Uganda]]&amp;nbsp;- 
[[United States of America|United States]]&amp;nbsp;-
[[Western Sahara]]&amp;nbsp;- 
[[Zambia]]&amp;nbsp;- 
[[Zimbabwe]]</text>
      <sha1>tpwjwcy40n1hmgjcf18x81g7nuzl1vp</sha1>
    </revision>
    <revision>
      <id>1106</id>
      <parentid>1105</parentid>
      <timestamp>2016-02-20T13:46:39Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1106</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3411" sha1="qwt0ugc2sa7pe13jd8x2rc0dut4q9qd" xml:space="preserve">{| cellpadding=&quot;5&quot; cellspacing=&quot;4&quot; style=&quot;width:100%; border:2px ;&quot;  
|-----
|colspan=&quot;6&quot; align=&quot;center&quot; bgcolor=&quot;white&quot; |

{| width=&quot;100%&quot;  border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;5&quot;
|- 
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Nuvola apps bookcase.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 95%; &quot; |  '''Sesotho sa Leboa'''&lt;br/&gt; 
[[Leina la temana]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Sefoka sa Afrika Borwa]]&amp;nbsp;-
[[Sepedi]]&amp;nbsp;- 
[[Sepedi mo internet]]&amp;nbsp;-
[[Kopanobokgoši]]&amp;nbsp;-
[[Pherekgong]]&amp;nbsp;-
[[Dibokwane]]&amp;nbsp;-
[[Hlakola]]&amp;nbsp;-
[[Moranang]]&amp;nbsp;-
[[Mopitlo]]&amp;nbsp;-
[[Phupu]]&amp;nbsp;-
[[Mosegamanye]]&amp;nbsp;-
[[Phato]]&amp;nbsp;-
[[Lewedi]]&amp;nbsp;-
[[Diphalane]]&amp;nbsp;-
[[Dibatsela]]&amp;nbsp;-
[[Manthole]] &amp;nbsp;-
[[Nomoro|Dinomoro]]
&lt;!----------------------------------------------&gt;
|- 
&lt;!----------------------------------------------&gt;
| [[Isimumathi:P_religion_world.svg|40px|center]]
| style=&quot;font-size: 95%; border-top: 1px dashed #AAAAAA;&quot; | '''Bodumedi'''&lt;br/&gt;
[[Modimo]]&amp;nbsp;- 
[[Sebuda]]&amp;nbsp;- 
[[Sejuda]]&amp;nbsp;- 
[[Sekriste]]&amp;nbsp;- 
[[Seporotestante]]
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Nuvola apps kcoloredit.svg|40px|center]]
| style=&quot;font-size: 95%; border-top: 1px dashed #AAAAAA;&quot; | '''Dimala'''&lt;br/&gt;
[[Mmala wa gauta|Gauta]]&amp;nbsp;- 
[[Hwibidu]]&amp;nbsp;-
[[Namune (mmala)|Namune]]&amp;nbsp;- 
[[Ntsho]]&amp;nbsp;-
[[Phifadu]]&amp;nbsp;- 
[[Pinki]]&amp;nbsp;- 
[[Pududu]]&amp;nbsp;- 
[[Purepura]]&amp;nbsp;- 
[[Putswa]]&amp;nbsp;-
[[Serolane]]&amp;nbsp;-
[[Silifêra (mmala)|Silifêra]]&amp;nbsp;-
[[Tala]]&amp;nbsp;-
[[Tšhweu]]
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Gnome-globe.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 95%;&quot; | '''Dinaga'''&lt;br/&gt;
[[Afrika Borwa]]&amp;nbsp;- 
[[Algeria]]&amp;nbsp;- 
[[Angola]]&amp;nbsp;- 
[[Benin]]&amp;nbsp;- 
[[Botswana]]&amp;nbsp;- 
[[Burkina Faso]]&amp;nbsp;- 
[[Burundi]]&amp;nbsp;-  
[[Cameroon]]&amp;nbsp;- 
[[Canary Islands]]&amp;nbsp;- 
[[Cape Verde]]&amp;nbsp;-
[[Central African Republic]]&amp;nbsp;- 
[[Ceuta]]&amp;nbsp;- 
[[Chad]]&amp;nbsp;- 
[[Comoros]]&amp;nbsp;- 
[[Côte d'Ivoire]]&amp;nbsp;- 
[[Democratic Republic of the Congo]]&amp;nbsp;- 
[[Djibouti]]&amp;nbsp;- 
[[Egypt]]&amp;nbsp;- 
[[Equatorial Guinea]]&amp;nbsp;- 
[[Eritrea]]&amp;nbsp;- 
[[Ethiopia]]&amp;nbsp;- 
[[Fora]]&amp;nbsp;- 
[[Gabon]]&amp;nbsp;- 
[[Gambia]]&amp;nbsp;- 
[[Ghana]]&amp;nbsp;- 
[[Guinea]]&amp;nbsp;- 
[[Guinea-Bissau]]&amp;nbsp;- 
[[Ireland]]&amp;nbsp;- 
[[Japane]]&amp;nbsp;-
[[Kenya]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Liberia]]&amp;nbsp;- 
[[Libya]]&amp;nbsp;- 
[[Madagascar]]&amp;nbsp;- 
[[Madeira|Madeira Islands]]&amp;nbsp;- 
[[Malawi]]&amp;nbsp;- 
[[Mali]]&amp;nbsp;- 
[[Mauritania]]&amp;nbsp;- 
[[Mauritius]]&amp;nbsp;-  
[[Mayotte]]&amp;nbsp;- 
[[Melilla]] &amp;nbsp;- 
[[Morocco]]&amp;nbsp;-  
[[Mozambique]]&amp;nbsp;-
[[Namibia]]&amp;nbsp;- 
[[New Zealand]]&amp;nbsp;- 
[[Niger]]&amp;nbsp;- 
[[Nigeria]]&amp;nbsp;- 
[[Pakistan]]&amp;nbsp;-
[[Republic ya Congo|Congo]]&amp;nbsp;- 
[[Réunion]]&amp;nbsp;- 
[[Rwanda]]&amp;nbsp;- 
[[Saint Helena]]&amp;nbsp;- 
[[São Tomé and Príncipe]]&amp;nbsp;-
[[Senegal]]&amp;nbsp;- 
[[Seychelles]]&amp;nbsp;- 
[[Sierra Leone]]&amp;nbsp;- 
[[Somalia]]&amp;nbsp;- 
[[Sri Lanka]]&amp;nbsp;- 
[[Sudan]]&amp;nbsp;-  
[[Swaziland]]&amp;nbsp;- 
[[Tanzania]]&amp;nbsp;-
[[Togo]]&amp;nbsp;-
[[Tšhaena]]&amp;nbsp;-  
[[Tunisia]]&amp;nbsp;- 
[[Uganda]]&amp;nbsp;- 
[[United States of America|United States]]&amp;nbsp;-
[[Western Sahara]]&amp;nbsp;- 
[[Zambia]]&amp;nbsp;- 
[[Zimbabwe]]</text>
      <sha1>qwt0ugc2sa7pe13jd8x2rc0dut4q9qd</sha1>
    </revision>
    <revision>
      <id>1107</id>
      <parentid>1106</parentid>
      <timestamp>2016-02-20T13:47:04Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Undo revision 3800903 by [[Khethekileko:Contributions/Thuvack|Thuvack]] ([[Umsebenzisi asiqongelane:Thuvack|talk]])</comment>
      <origin>1107</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3844" sha1="tpwjwcy40n1hmgjcf18x81g7nuzl1vp" xml:space="preserve">{| cellpadding=&quot;5&quot; cellspacing=&quot;4&quot; style=&quot;width:100%; border:2px ;&quot;  
|-----
|colspan=&quot;6&quot; align=&quot;center&quot; bgcolor=&quot;white&quot; |

{| width=&quot;100%&quot;  border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;5&quot;
|- 
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Nuvola apps bookcase.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 95%; &quot; |  '''Sesotho sa Leboa'''&lt;br/&gt; 
[[Leina la temana]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Sefoka sa Afrika Borwa]]&amp;nbsp;-
[[Sepedi]]&amp;nbsp;- 
[[Sepedi mo internet]]&amp;nbsp;-
[[Kopanobokgoši]]&amp;nbsp;-
[[Pherekgong]]&amp;nbsp;-
[[Dibokwane]]&amp;nbsp;-
[[Hlakola]]&amp;nbsp;-
[[Moranang]]&amp;nbsp;-
[[Mopitlo]]&amp;nbsp;-
[[Phupu]]&amp;nbsp;-
[[Mosegamanye]]&amp;nbsp;-
[[Phato]]&amp;nbsp;-
[[Lewedi]]&amp;nbsp;-
[[Diphalane]]&amp;nbsp;-
[[Dibatsela]]&amp;nbsp;-
[[Manthole]] &amp;nbsp;-
[[Nomoro|Dinomoro]]
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:P countries-lightblue.png|40px|center]]
| style=&quot;font-size: 95%; border-top: 1px dashed #AAAAAA;&quot; | '''Thutafase'''&lt;br/&gt;
[[Thutafase]]&amp;nbsp;- 
[[Yuropa]]&amp;nbsp;- 
[[Asia]]&amp;nbsp;- 
[[Afrika]]&amp;nbsp;- 
[[Amerika]]&amp;nbsp;- 
[[Oceania]]&amp;nbsp;- 
[[Antarctica]]&amp;nbsp;- 
[[Australia]]&amp;nbsp;- 
[[Lefase]]&amp;nbsp;- 
[[Lefasana]]
&lt;!----------------------------------------------&gt;
|- 
&lt;!----------------------------------------------&gt;
| [[Isimumathi:P_religion_world.svg|40px|center]]
| style=&quot;font-size: 95%; border-top: 1px dashed #AAAAAA;&quot; | '''Bodumedi'''&lt;br/&gt;
[[Modimo]]&amp;nbsp;- 
[[Sebuda]]&amp;nbsp;- 
[[Sejuda]]&amp;nbsp;- 
[[Sekriste]]&amp;nbsp;- 
[[Seporotestante]]
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Nuvola apps kcoloredit.svg|40px|center]]
| style=&quot;font-size: 95%; border-top: 1px dashed #AAAAAA;&quot; | '''Dimala'''&lt;br/&gt;
[[Mmala wa gauta|Gauta]]&amp;nbsp;- 
[[Hwibidu]]&amp;nbsp;-
[[Namune (mmala)|Namune]]&amp;nbsp;- 
[[Ntsho]]&amp;nbsp;-
[[Phifadu]]&amp;nbsp;- 
[[Pinki]]&amp;nbsp;- 
[[Pududu]]&amp;nbsp;- 
[[Purepura]]&amp;nbsp;- 
[[Putswa]]&amp;nbsp;-
[[Serolane]]&amp;nbsp;-
[[Silifêra (mmala)|Silifêra]]&amp;nbsp;-
[[Tala]]&amp;nbsp;-
[[Tšhweu]]
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Gnome-globe.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 95%;&quot; | '''Dinaga'''&lt;br/&gt;
[[Afrika Borwa]]&amp;nbsp;- 
[[Algeria]]&amp;nbsp;- 
[[Angola]]&amp;nbsp;- 
[[Benin]]&amp;nbsp;- 
[[Botswana]]&amp;nbsp;- 
[[Burkina Faso]]&amp;nbsp;- 
[[Burundi]]&amp;nbsp;-  
[[Cameroon]]&amp;nbsp;- 
[[Canary Islands]]&amp;nbsp;- 
[[Cape Verde]]&amp;nbsp;-
[[Central African Republic]]&amp;nbsp;- 
[[Ceuta]]&amp;nbsp;- 
[[Chad]]&amp;nbsp;- 
[[Comoros]]&amp;nbsp;- 
[[Côte d'Ivoire]]&amp;nbsp;- 
[[Democratic Republic of the Congo]]&amp;nbsp;- 
[[Djibouti]]&amp;nbsp;- 
[[Egypt]]&amp;nbsp;- 
[[Equatorial Guinea]]&amp;nbsp;- 
[[Eritrea]]&amp;nbsp;- 
[[Ethiopia]]&amp;nbsp;- 
[[Fora]]&amp;nbsp;- 
[[Gabon]]&amp;nbsp;- 
[[Gambia]]&amp;nbsp;- 
[[Ghana]]&amp;nbsp;- 
[[Guinea]]&amp;nbsp;- 
[[Guinea-Bissau]]&amp;nbsp;- 
[[Ireland]]&amp;nbsp;- 
[[Japane]]&amp;nbsp;-
[[Kenya]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Liberia]]&amp;nbsp;- 
[[Libya]]&amp;nbsp;- 
[[Madagascar]]&amp;nbsp;- 
[[Madeira|Madeira Islands]]&amp;nbsp;- 
[[Malawi]]&amp;nbsp;- 
[[Mali]]&amp;nbsp;- 
[[Mauritania]]&amp;nbsp;- 
[[Mauritius]]&amp;nbsp;-  
[[Mayotte]]&amp;nbsp;- 
[[Melilla]] &amp;nbsp;- 
[[Morocco]]&amp;nbsp;-  
[[Mozambique]]&amp;nbsp;-
[[Namibia]]&amp;nbsp;- 
[[New Zealand]]&amp;nbsp;- 
[[Niger]]&amp;nbsp;- 
[[Nigeria]]&amp;nbsp;- 
[[Pakistan]]&amp;nbsp;-
[[Republic ya Congo|Congo]]&amp;nbsp;- 
[[Réunion]]&amp;nbsp;- 
[[Rwanda]]&amp;nbsp;- 
[[Saint Helena]]&amp;nbsp;- 
[[São Tomé and Príncipe]]&amp;nbsp;-
[[Senegal]]&amp;nbsp;- 
[[Seychelles]]&amp;nbsp;- 
[[Sierra Leone]]&amp;nbsp;- 
[[Somalia]]&amp;nbsp;- 
[[Sri Lanka]]&amp;nbsp;- 
[[Sudan]]&amp;nbsp;-  
[[Swaziland]]&amp;nbsp;- 
[[Tanzania]]&amp;nbsp;-
[[Togo]]&amp;nbsp;-
[[Tšhaena]]&amp;nbsp;-  
[[Tunisia]]&amp;nbsp;- 
[[Uganda]]&amp;nbsp;- 
[[United States of America|United States]]&amp;nbsp;-
[[Western Sahara]]&amp;nbsp;- 
[[Zambia]]&amp;nbsp;- 
[[Zimbabwe]]</text>
      <sha1>tpwjwcy40n1hmgjcf18x81g7nuzl1vp</sha1>
    </revision>
    <revision>
      <id>1108</id>
      <parentid>1107</parentid>
      <timestamp>2016-02-20T13:50:04Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1108</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3537" sha1="e3nbnp97hno8eai5r9b7yib6y8i04pa" xml:space="preserve">{| cellpadding=&quot;5&quot; cellspacing=&quot;4&quot; style=&quot;width:100%; border:2px ;&quot;  
|-----
|colspan=&quot;6&quot; align=&quot;center&quot; bgcolor=&quot;white&quot; |

{| width=&quot;100%&quot;  border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;5&quot;
|- 
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Nuvola apps bookcase.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 95%; &quot; |  '''Sesotho sa Leboa'''&lt;br/&gt; 
[[Leina la temana]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Sefoka sa Afrika Borwa]]&amp;nbsp;-
[[Sepedi]]&amp;nbsp;- 
[[Sepedi mo internet]]&amp;nbsp;-
[[Kopanobokgoši]]&amp;nbsp;-
[[Pherekgong]]&amp;nbsp;-
[[Dibokwane]]&amp;nbsp;-
[[Hlakola]]&amp;nbsp;-
[[Moranang]]&amp;nbsp;-
[[Mopitlo]]&amp;nbsp;-
[[Phupu]]&amp;nbsp;-
[[Mosegamanye]]&amp;nbsp;-
[[Phato]]&amp;nbsp;-
[[Lewedi]]&amp;nbsp;-
[[Diphalane]]&amp;nbsp;-
[[Dibatsela]]&amp;nbsp;-
[[Manthole]] &amp;nbsp;-
[[Nomoro|Dinomoro]]
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:P_religion_world.svg|40px|center]]
| style=&quot;font-size: 95%; border-top: 1px dashed #AAAAAA;&quot; | '''Thutafase'''&lt;br/&gt;
[[Modimo]]&amp;nbsp;- 
[[Sebuda]]&amp;nbsp;- 
[[Sejuda]]&amp;nbsp;- 
[[Sekriste]]&amp;nbsp;- 
[[Seporotestante]]
&lt;!----------------------------------------------&gt;
|- 
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Nuvola apps kcoloredit.svg|40px|center]]
| style=&quot;font-size: 95%; border-top: 1px dashed #AAAAAA;&quot; | '''Bodumedi'''&lt;br/&gt;
[[Mmala wa gauta|Gauta]]&amp;nbsp;- 
[[Hwibidu]]&amp;nbsp;-
[[Namune (mmala)|Namune]]&amp;nbsp;- 
[[Ntsho]]&amp;nbsp;-
[[Phifadu]]&amp;nbsp;- 
[[Pinki]]&amp;nbsp;- 
[[Pududu]]&amp;nbsp;- 
[[Purepura]]&amp;nbsp;- 
[[Putswa]]&amp;nbsp;-
[[Serolane]]&amp;nbsp;-
[[Silifêra (mmala)|Silifêra]]&amp;nbsp;-
[[Tala]]&amp;nbsp;-
[[Tšhweu]]
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Gnome-globe.svg|40px|center]]
| style=&quot;font-size: 95%; border-top: 1px dashed #AAAAAA;&quot; | '''Dimala'''&lt;br/&gt;
| width=&quot;10%&quot; | [[Isimumathi:Gnome-globe.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 95%;&quot; | '''Dinaga'''&lt;br/&gt;
[[Afrika Borwa]]&amp;nbsp;- 
[[Algeria]]&amp;nbsp;- 
[[Angola]]&amp;nbsp;- 
[[Benin]]&amp;nbsp;- 
[[Botswana]]&amp;nbsp;- 
[[Burkina Faso]]&amp;nbsp;- 
[[Burundi]]&amp;nbsp;-  
[[Cameroon]]&amp;nbsp;- 
[[Canary Islands]]&amp;nbsp;- 
[[Cape Verde]]&amp;nbsp;-
[[Central African Republic]]&amp;nbsp;- 
[[Ceuta]]&amp;nbsp;- 
[[Chad]]&amp;nbsp;- 
[[Comoros]]&amp;nbsp;- 
[[Côte d'Ivoire]]&amp;nbsp;- 
[[Democratic Republic of the Congo]]&amp;nbsp;- 
[[Djibouti]]&amp;nbsp;- 
[[Egypt]]&amp;nbsp;- 
[[Equatorial Guinea]]&amp;nbsp;- 
[[Eritrea]]&amp;nbsp;- 
[[Ethiopia]]&amp;nbsp;- 
[[Fora]]&amp;nbsp;- 
[[Gabon]]&amp;nbsp;- 
[[Gambia]]&amp;nbsp;- 
[[Ghana]]&amp;nbsp;- 
[[Guinea]]&amp;nbsp;- 
[[Guinea-Bissau]]&amp;nbsp;- 
[[Ireland]]&amp;nbsp;- 
[[Japane]]&amp;nbsp;-
[[Kenya]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Liberia]]&amp;nbsp;- 
[[Libya]]&amp;nbsp;- 
[[Madagascar]]&amp;nbsp;- 
[[Madeira|Madeira Islands]]&amp;nbsp;- 
[[Malawi]]&amp;nbsp;- 
[[Mali]]&amp;nbsp;- 
[[Mauritania]]&amp;nbsp;- 
[[Mauritius]]&amp;nbsp;-  
[[Mayotte]]&amp;nbsp;- 
[[Melilla]] &amp;nbsp;- 
[[Morocco]]&amp;nbsp;-  
[[Mozambique]]&amp;nbsp;-
[[Namibia]]&amp;nbsp;- 
[[New Zealand]]&amp;nbsp;- 
[[Niger]]&amp;nbsp;- 
[[Nigeria]]&amp;nbsp;- 
[[Pakistan]]&amp;nbsp;-
[[Republic ya Congo|Congo]]&amp;nbsp;- 
[[Réunion]]&amp;nbsp;- 
[[Rwanda]]&amp;nbsp;- 
[[Saint Helena]]&amp;nbsp;- 
[[São Tomé and Príncipe]]&amp;nbsp;-
[[Senegal]]&amp;nbsp;- 
[[Seychelles]]&amp;nbsp;- 
[[Sierra Leone]]&amp;nbsp;- 
[[Somalia]]&amp;nbsp;- 
[[Sri Lanka]]&amp;nbsp;- 
[[Sudan]]&amp;nbsp;-  
[[Swaziland]]&amp;nbsp;- 
[[Tanzania]]&amp;nbsp;-
[[Togo]]&amp;nbsp;-
[[Tšhaena]]&amp;nbsp;-  
[[Tunisia]]&amp;nbsp;- 
[[Uganda]]&amp;nbsp;- 
[[United States of America|United States]]&amp;nbsp;-
[[Western Sahara]]&amp;nbsp;- 
[[Zambia]]&amp;nbsp;- 
[[Zimbabwe]]</text>
      <sha1>e3nbnp97hno8eai5r9b7yib6y8i04pa</sha1>
    </revision>
    <revision>
      <id>1109</id>
      <parentid>1108</parentid>
      <timestamp>2016-02-20T13:55:18Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1109</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3422" sha1="doo3bsue12l05q43ifhpgfjef27g0e9" xml:space="preserve">{| cellpadding=&quot;5&quot; cellspacing=&quot;4&quot; style=&quot;width:100%; border:2px ;&quot;  
|-----
|colspan=&quot;6&quot; align=&quot;center&quot; bgcolor=&quot;white&quot; |

{| width=&quot;100%&quot;  border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;5&quot;
|- 
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Nuvola apps bookcase.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 95%; &quot; |  '''Sesotho sa Leboa'''&lt;br/&gt; 
[[Leina la temana]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Sefoka sa Afrika Borwa]]&amp;nbsp;-
[[Sepedi]]&amp;nbsp;- 
[[Sepedi mo internet]]&amp;nbsp;-
[[Kopanobokgoši]]&amp;nbsp;-
[[Pherekgong]]&amp;nbsp;-
[[Dibokwane]]&amp;nbsp;-
[[Hlakola]]&amp;nbsp;-
[[Moranang]]&amp;nbsp;-
[[Mopitlo]]&amp;nbsp;-
[[Phupu]]&amp;nbsp;-
[[Mosegamanye]]&amp;nbsp;-
[[Phato]]&amp;nbsp;-
[[Lewedi]]&amp;nbsp;-
[[Diphalane]]&amp;nbsp;-
[[Dibatsela]]&amp;nbsp;-
[[Manthole]] &amp;nbsp;-
[[Nomoro|Dinomoro]]
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:P_religion_world.svg|40px|center]]
| style=&quot;font-size: 95%; border-top: 1px dashed #AAAAAA;&quot; | '''Thutafase'''&lt;br/&gt;
[[Modimo]]&amp;nbsp;- 
[[Sebuda]]&amp;nbsp;- 
[[Sejuda]]&amp;nbsp;- 
[[Sekriste]]&amp;nbsp;- 
[[Seporotestante]]
&lt;!----------------------------------------------&gt;
|- 
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Nuvola apps kcoloredit.svg|40px|center]]
| style=&quot;font-size: 95%; border-top: 1px dashed #AAAAAA;&quot; | '''Bodumedi'''&lt;br/&gt;
[[Mmala wa gauta|Gauta]]&amp;nbsp;- 
[[Hwibidu]]&amp;nbsp;-
[[Namune (mmala)|Namune]]&amp;nbsp;- 
[[Ntsho]]&amp;nbsp;-
[[Phifadu]]&amp;nbsp;- 
[[Pinki]]&amp;nbsp;- 
[[Pududu]]&amp;nbsp;- 
[[Purepura]]&amp;nbsp;- 
[[Putswa]]&amp;nbsp;-
[[Serolane]]&amp;nbsp;-
[[Silifêra (mmala)|Silifêra]]&amp;nbsp;-
[[Tala]]&amp;nbsp;-
[[Tšhweu]]
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Gnome-globe.svg|40px|center]]
| style=&quot;font-size: 95%; border-top: 1px dashed #AAAAAA;&quot; | '''Bodumedi'''&lt;br/&gt;
[[Afrika Borwa]]&amp;nbsp;- 
[[Algeria]]&amp;nbsp;- 
[[Angola]]&amp;nbsp;- 
[[Benin]]&amp;nbsp;- 
[[Botswana]]&amp;nbsp;- 
[[Burkina Faso]]&amp;nbsp;- 
[[Burundi]]&amp;nbsp;-  
[[Cameroon]]&amp;nbsp;- 
[[Canary Islands]]&amp;nbsp;- 
[[Cape Verde]]&amp;nbsp;-
[[Central African Republic]]&amp;nbsp;- 
[[Ceuta]]&amp;nbsp;- 
[[Chad]]&amp;nbsp;- 
[[Comoros]]&amp;nbsp;- 
[[Côte d'Ivoire]]&amp;nbsp;- 
[[Democratic Republic of the Congo]]&amp;nbsp;- 
[[Djibouti]]&amp;nbsp;- 
[[Egypt]]&amp;nbsp;- 
[[Equatorial Guinea]]&amp;nbsp;- 
[[Eritrea]]&amp;nbsp;- 
[[Ethiopia]]&amp;nbsp;- 
[[Fora]]&amp;nbsp;- 
[[Gabon]]&amp;nbsp;- 
[[Gambia]]&amp;nbsp;- 
[[Ghana]]&amp;nbsp;- 
[[Guinea]]&amp;nbsp;- 
[[Guinea-Bissau]]&amp;nbsp;- 
[[Ireland]]&amp;nbsp;- 
[[Japane]]&amp;nbsp;-
[[Kenya]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Liberia]]&amp;nbsp;- 
[[Libya]]&amp;nbsp;- 
[[Madagascar]]&amp;nbsp;- 
[[Madeira|Madeira Islands]]&amp;nbsp;- 
[[Malawi]]&amp;nbsp;- 
[[Mali]]&amp;nbsp;- 
[[Mauritania]]&amp;nbsp;- 
[[Mauritius]]&amp;nbsp;-  
[[Mayotte]]&amp;nbsp;- 
[[Melilla]] &amp;nbsp;- 
[[Morocco]]&amp;nbsp;-  
[[Mozambique]]&amp;nbsp;-
[[Namibia]]&amp;nbsp;- 
[[New Zealand]]&amp;nbsp;- 
[[Niger]]&amp;nbsp;- 
[[Nigeria]]&amp;nbsp;- 
[[Pakistan]]&amp;nbsp;-
[[Republic ya Congo|Congo]]&amp;nbsp;- 
[[Réunion]]&amp;nbsp;- 
[[Rwanda]]&amp;nbsp;- 
[[Saint Helena]]&amp;nbsp;- 
[[São Tomé and Príncipe]]&amp;nbsp;-
[[Senegal]]&amp;nbsp;- 
[[Seychelles]]&amp;nbsp;- 
[[Sierra Leone]]&amp;nbsp;- 
[[Somalia]]&amp;nbsp;- 
[[Sri Lanka]]&amp;nbsp;- 
[[Sudan]]&amp;nbsp;-  
[[Swaziland]]&amp;nbsp;- 
[[Tanzania]]&amp;nbsp;-
[[Togo]]&amp;nbsp;-
[[Tšhaena]]&amp;nbsp;-  
[[Tunisia]]&amp;nbsp;- 
[[Uganda]]&amp;nbsp;- 
[[United States of America|United States]]&amp;nbsp;-
[[Western Sahara]]&amp;nbsp;- 
[[Zambia]]&amp;nbsp;- 
[[Zimbabwe]]</text>
      <sha1>doo3bsue12l05q43ifhpgfjef27g0e9</sha1>
    </revision>
    <revision>
      <id>1110</id>
      <parentid>1109</parentid>
      <timestamp>2016-02-20T14:40:29Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1110</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2112" sha1="eto8jol0rk5n09photp92hcj2etyj71" xml:space="preserve">{| cellpadding=&quot;5&quot; cellspacing=&quot;4&quot; style=&quot;width:100%; border:2px ;&quot;  
|-----
|colspan=&quot;6&quot; align=&quot;center&quot; bgcolor=&quot;white&quot; |

{| width=&quot;100%&quot;  border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;5&quot;
|- 
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Nuvola apps bookcase.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 95%; &quot; |  '''Imitlolo ngesindebele'''&lt;br/&gt; 
[[Isindebele]]&amp;nbsp;-
[[Amalungelo Wobuntu]]&amp;nbsp;- 
[[umThethosisekelo]]&amp;nbsp;-
[[Ezepilo]]&amp;nbsp;-
[[Ifundo]]&amp;nbsp;-
[[Amatshwayo eSewula Africa]]&amp;nbsp;-
[[Iflaga yeSewula Africa]]&amp;nbsp;-
[[Iinomboro]]&amp;nbsp;-
[[AmaKghono wePilo]]&amp;nbsp;-

&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:P_religion_world.svg|40px|center]]
| style=&quot;font-size: 95%; border-top: 1px dashed #AAAAAA;&quot; | '''Ikolo'''&lt;br/&gt;
[[Uzimu]]&amp;nbsp;- 
[[Ubukresite]]&amp;nbsp;- 
[[Abaphasi]]&amp;nbsp;- 
[[Ikolo]]&amp;nbsp;- 
[[Ibhayibhili]]
&lt;!----------------------------------------------&gt;
|- 
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Nuvola apps kcoloredit.svg|40px|center]]
| style=&quot;font-size: 95%; border-top: 1px dashed #AAAAAA;&quot; | '''Amabala'''&lt;br/&gt;
[[Onzima]]&amp;nbsp;- 
[[Omhlophe]]&amp;nbsp;-
[[Obovu]]&amp;nbsp;- 

&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Gnome-globe.svg|40px|center]]
| style=&quot;font-size: 95%; border-top: 1px dashed #AAAAAA;&quot; | '''Iinaga zephasi'''&lt;br/&gt;
[[Isewula Afrika]]&amp;nbsp;- 
[[Iamarika]]&amp;nbsp;-
[[Angola]]&amp;nbsp;-  
[[Botswana]]&amp;nbsp;- 
[[Burkina Faso]]&amp;nbsp;-   
[[Cameroon]]&amp;nbsp;- 
[[Egypt]]&amp;nbsp;- 
[[Ethiopia]]&amp;nbsp;- 
[[Ghana]]&amp;nbsp;- 
[[Japane]]&amp;nbsp;-
[[Kenya]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Madagascar]]&amp;nbsp;- 
[[Malawi]]&amp;nbsp;- 
[[Mali]]&amp;nbsp;- 
[[Mauritius]]&amp;nbsp;-  
[[Morocco]]&amp;nbsp;-  
[[Mozambique]]&amp;nbsp;-
[[Namibia]]&amp;nbsp;-  
[[Niger]]&amp;nbsp;- 
[[Nigeria]]&amp;nbsp;-   
[[Rwanda]]&amp;nbsp;- 
[[Senegal]]&amp;nbsp;- 
[[Sierra Leone]]&amp;nbsp;- 
[[Somalia]]&amp;nbsp;- 
[[Swaziland]]&amp;nbsp;- 
[[Tanzania]]&amp;nbsp;-
[[Tshayina]]&amp;nbsp;-  
[[Tunisia]]&amp;nbsp;- 
[[Zambia]]&amp;nbsp;- 
[[Zimbabwe]]</text>
      <sha1>eto8jol0rk5n09photp92hcj2etyj71</sha1>
    </revision>
    <revision>
      <id>1111</id>
      <parentid>1110</parentid>
      <timestamp>2016-02-20T14:51:48Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1111</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2112" sha1="ah6grlyfvmpwjeqtna3scotay6p22w7" xml:space="preserve">{| cellpadding=&quot;5&quot; cellspacing=&quot;4&quot; style=&quot;width:100%; border:2px ;&quot;  
|-----
|colspan=&quot;6&quot; align=&quot;center&quot; bgcolor=&quot;white&quot; |

{| width=&quot;100%&quot;  border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;5&quot;
|- 
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Nuvola apps bookcase.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 75%; &quot; |  '''Imitlolo ngesindebele'''&lt;br/&gt; 
[[Isindebele]]&amp;nbsp;-
[[Amalungelo Wobuntu]]&amp;nbsp;- 
[[umThethosisekelo]]&amp;nbsp;-
[[Ezepilo]]&amp;nbsp;-
[[Ifundo]]&amp;nbsp;-
[[Amatshwayo eSewula Africa]]&amp;nbsp;-
[[Iflaga yeSewula Africa]]&amp;nbsp;-
[[Iinomboro]]&amp;nbsp;-
[[AmaKghono wePilo]]&amp;nbsp;-

&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:P_religion_world.svg|40px|center]]
| style=&quot;font-size: 75%; border-top: 1px dashed #AAAAAA;&quot; | '''Ikolo'''&lt;br/&gt;
[[Uzimu]]&amp;nbsp;- 
[[Ubukresite]]&amp;nbsp;- 
[[Abaphasi]]&amp;nbsp;- 
[[Ikolo]]&amp;nbsp;- 
[[Ibhayibhili]]
&lt;!----------------------------------------------&gt;
|- 
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Nuvola apps kcoloredit.svg|40px|center]]
| style=&quot;font-size: 75%; border-top: 1px dashed #AAAAAA;&quot; | '''Amabala'''&lt;br/&gt;
[[Onzima]]&amp;nbsp;- 
[[Omhlophe]]&amp;nbsp;-
[[Obovu]]&amp;nbsp;- 

&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Gnome-globe.svg|40px|center]]
| style=&quot;font-size: 75%; border-top: 1px dashed #AAAAAA;&quot; | '''Iinaga zephasi'''&lt;br/&gt;
[[Isewula Afrika]]&amp;nbsp;- 
[[Iamarika]]&amp;nbsp;-
[[Angola]]&amp;nbsp;-  
[[Botswana]]&amp;nbsp;- 
[[Burkina Faso]]&amp;nbsp;-   
[[Cameroon]]&amp;nbsp;- 
[[Egypt]]&amp;nbsp;- 
[[Ethiopia]]&amp;nbsp;- 
[[Ghana]]&amp;nbsp;- 
[[Japane]]&amp;nbsp;-
[[Kenya]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Madagascar]]&amp;nbsp;- 
[[Malawi]]&amp;nbsp;- 
[[Mali]]&amp;nbsp;- 
[[Mauritius]]&amp;nbsp;-  
[[Morocco]]&amp;nbsp;-  
[[Mozambique]]&amp;nbsp;-
[[Namibia]]&amp;nbsp;-  
[[Niger]]&amp;nbsp;- 
[[Nigeria]]&amp;nbsp;-   
[[Rwanda]]&amp;nbsp;- 
[[Senegal]]&amp;nbsp;- 
[[Sierra Leone]]&amp;nbsp;- 
[[Somalia]]&amp;nbsp;- 
[[Swaziland]]&amp;nbsp;- 
[[Tanzania]]&amp;nbsp;-
[[Tshayina]]&amp;nbsp;-  
[[Tunisia]]&amp;nbsp;- 
[[Zambia]]&amp;nbsp;- 
[[Zimbabwe]]</text>
      <sha1>ah6grlyfvmpwjeqtna3scotay6p22w7</sha1>
    </revision>
    <revision>
      <id>1112</id>
      <parentid>1111</parentid>
      <timestamp>2016-02-20T14:52:42Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1112</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2112" sha1="5x3ajrw7q6kwxc27xz1yoqo9lr7kzy7" xml:space="preserve">{| cellpadding=&quot;5&quot; cellspacing=&quot;4&quot; style=&quot;width:100%; border:2px ;&quot;  
|-----
|colspan=&quot;6&quot; align=&quot;center&quot; bgcolor=&quot;white&quot; |

{| width=&quot;100%&quot;  border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;5&quot;
|- 
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Nuvola apps bookcase.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 80%; &quot; |  '''Imitlolo ngesindebele'''&lt;br/&gt; 
[[Isindebele]]&amp;nbsp;-
[[Amalungelo Wobuntu]]&amp;nbsp;- 
[[umThethosisekelo]]&amp;nbsp;-
[[Ezepilo]]&amp;nbsp;-
[[Ifundo]]&amp;nbsp;-
[[Amatshwayo eSewula Africa]]&amp;nbsp;-
[[Iflaga yeSewula Africa]]&amp;nbsp;-
[[Iinomboro]]&amp;nbsp;-
[[AmaKghono wePilo]]&amp;nbsp;-

&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:P_religion_world.svg|40px|center]]
| style=&quot;font-size: 80%; border-top: 1px dashed #AAAAAA;&quot; | '''Ikolo'''&lt;br/&gt;
[[Uzimu]]&amp;nbsp;- 
[[Ubukresite]]&amp;nbsp;- 
[[Abaphasi]]&amp;nbsp;- 
[[Ikolo]]&amp;nbsp;- 
[[Ibhayibhili]]
&lt;!----------------------------------------------&gt;
|- 
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Nuvola apps kcoloredit.svg|40px|center]]
| style=&quot;font-size: 80%; border-top: 1px dashed #AAAAAA;&quot; | '''Amabala'''&lt;br/&gt;
[[Onzima]]&amp;nbsp;- 
[[Omhlophe]]&amp;nbsp;-
[[Obovu]]&amp;nbsp;- 

&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Gnome-globe.svg|40px|center]]
| style=&quot;font-size: 80%; border-top: 1px dashed #AAAAAA;&quot; | '''Iinaga zephasi'''&lt;br/&gt;
[[Isewula Afrika]]&amp;nbsp;- 
[[Iamarika]]&amp;nbsp;-
[[Angola]]&amp;nbsp;-  
[[Botswana]]&amp;nbsp;- 
[[Burkina Faso]]&amp;nbsp;-   
[[Cameroon]]&amp;nbsp;- 
[[Egypt]]&amp;nbsp;- 
[[Ethiopia]]&amp;nbsp;- 
[[Ghana]]&amp;nbsp;- 
[[Japane]]&amp;nbsp;-
[[Kenya]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Madagascar]]&amp;nbsp;- 
[[Malawi]]&amp;nbsp;- 
[[Mali]]&amp;nbsp;- 
[[Mauritius]]&amp;nbsp;-  
[[Morocco]]&amp;nbsp;-  
[[Mozambique]]&amp;nbsp;-
[[Namibia]]&amp;nbsp;-  
[[Niger]]&amp;nbsp;- 
[[Nigeria]]&amp;nbsp;-   
[[Rwanda]]&amp;nbsp;- 
[[Senegal]]&amp;nbsp;- 
[[Sierra Leone]]&amp;nbsp;- 
[[Somalia]]&amp;nbsp;- 
[[Swaziland]]&amp;nbsp;- 
[[Tanzania]]&amp;nbsp;-
[[Tshayina]]&amp;nbsp;-  
[[Tunisia]]&amp;nbsp;- 
[[Zambia]]&amp;nbsp;- 
[[Zimbabwe]]</text>
      <sha1>5x3ajrw7q6kwxc27xz1yoqo9lr7kzy7</sha1>
    </revision>
    <revision>
      <id>1113</id>
      <parentid>1112</parentid>
      <timestamp>2016-02-20T14:54:44Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1113</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2132" sha1="azl7ozrhsw96r53t1ht8g7naw4wnv1h" xml:space="preserve">{| cellpadding=&quot;5&quot; cellspacing=&quot;4&quot; style=&quot;width:100%; border:2px ;&quot;  
|-----
|colspan=&quot;6&quot; align=&quot;center&quot; bgcolor=&quot;white&quot; |

{| width=&quot;100%&quot;  border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;5&quot;
|- 
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Nuvola apps bookcase.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 80%; &quot; |  '''Imitlolo ngesindebele'''&lt;br/&gt; 
[[Isindebele]]&amp;nbsp;-
[[Amalungelo Wobuntu]]&amp;nbsp;- 
[[umThethosisekelo]]&amp;nbsp;-
[[Ezepilo]]&amp;nbsp;-
[[Ifundo]]&amp;nbsp;-
[[Amatshwayo eSewula Africa]]&amp;nbsp;-
[[Iflaga yeSewula Africa]]&amp;nbsp;-
[[Iinomboro]]&amp;nbsp;-
[[Iinyanga]]&amp;nbsp;-
[[AmaKghono wePilo]]&amp;nbsp;-

&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:P_religion_world.svg|40px|center]]
| style=&quot;font-size: 80%; border-top: 1px dashed #AAAAAA;&quot; | '''Ikolo'''&lt;br/&gt;
[[Uzimu]]&amp;nbsp;- 
[[Ubukresite]]&amp;nbsp;- 
[[Abaphasi]]&amp;nbsp;- 
[[Ikolo]]&amp;nbsp;- 
[[Ibhayibhili]]
&lt;!----------------------------------------------&gt;
|- 
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Nuvola apps kcoloredit.svg|40px|center]]
| style=&quot;font-size: 80%; border-top: 1px dashed #AAAAAA;&quot; | '''Amabala'''&lt;br/&gt;
[[Onzima]]&amp;nbsp;- 
[[Omhlophe]]&amp;nbsp;-
[[Obovu]]&amp;nbsp;- 

&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Gnome-globe.svg|40px|center]]
| style=&quot;font-size: 80%; border-top: 1px dashed #AAAAAA;&quot; | '''Iinaga zephasi'''&lt;br/&gt;
[[Isewula Afrika]]&amp;nbsp;- 
[[Iamarika]]&amp;nbsp;-
[[Angola]]&amp;nbsp;-  
[[Botswana]]&amp;nbsp;- 
[[Burkina Faso]]&amp;nbsp;-   
[[Cameroon]]&amp;nbsp;- 
[[Egypt]]&amp;nbsp;- 
[[Ethiopia]]&amp;nbsp;- 
[[Ghana]]&amp;nbsp;- 
[[Japane]]&amp;nbsp;-
[[Kenya]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Madagascar]]&amp;nbsp;- 
[[Malawi]]&amp;nbsp;- 
[[Mali]]&amp;nbsp;- 
[[Mauritius]]&amp;nbsp;-  
[[Morocco]]&amp;nbsp;-  
[[Mozambique]]&amp;nbsp;-
[[Namibia]]&amp;nbsp;-  
[[Niger]]&amp;nbsp;- 
[[Nigeria]]&amp;nbsp;-   
[[Rwanda]]&amp;nbsp;- 
[[Senegal]]&amp;nbsp;- 
[[Sierra Leone]]&amp;nbsp;- 
[[Somalia]]&amp;nbsp;- 
[[Swaziland]]&amp;nbsp;- 
[[Tanzania]]&amp;nbsp;-
[[Tshayina]]&amp;nbsp;-  
[[Tunisia]]&amp;nbsp;- 
[[Zambia]]&amp;nbsp;- 
[[Zimbabwe]]</text>
      <sha1>azl7ozrhsw96r53t1ht8g7naw4wnv1h</sha1>
    </revision>
    <revision>
      <id>1114</id>
      <parentid>1113</parentid>
      <timestamp>2016-02-20T16:52:01Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1114</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2163" sha1="by0g5m0dzll6diydaigzdl9fbfdwoxt" xml:space="preserve">{| cellpadding=&quot;5&quot; cellspacing=&quot;4&quot; style=&quot;width:100%; border:2px ;&quot;  
|-----
|colspan=&quot;6&quot; align=&quot;center&quot; bgcolor=&quot;white&quot; |

{| width=&quot;100%&quot;  border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;5&quot;
|- 
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Nuvola apps bookcase.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 80%; &quot; |  '''Imitlolo ngesindebele'''&lt;br/&gt; 
[[Isindebele]]&amp;nbsp;-
[[Umlando waMandebele]]&amp;nbsp;-
[[Amalungelo Wobuntu]]&amp;nbsp;- 
[[umThethosisekelo]]&amp;nbsp;-
[[Ezepilo]]&amp;nbsp;-
[[Ifundo]]&amp;nbsp;-
[[Amatshwayo eSewula Africa]]&amp;nbsp;-
[[Iflaga yeSewula Africa]]&amp;nbsp;-
[[Iinomboro]]&amp;nbsp;-
[[Iinyanga]]&amp;nbsp;-
[[AmaKghono wePilo]]&amp;nbsp;-

&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:P_religion_world.svg|40px|center]]
| style=&quot;font-size: 80%; border-top: 1px dashed #AAAAAA;&quot; | '''Ikolo'''&lt;br/&gt;
[[Uzimu]]&amp;nbsp;- 
[[Ubukresite]]&amp;nbsp;- 
[[Abaphasi]]&amp;nbsp;- 
[[Ikolo]]&amp;nbsp;- 
[[Ibhayibhili]]
&lt;!----------------------------------------------&gt;
|- 
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Nuvola apps kcoloredit.svg|40px|center]]
| style=&quot;font-size: 80%; border-top: 1px dashed #AAAAAA;&quot; | '''Amabala'''&lt;br/&gt;
[[Onzima]]&amp;nbsp;- 
[[Omhlophe]]&amp;nbsp;-
[[Obovu]]&amp;nbsp;- 

&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Gnome-globe.svg|40px|center]]
| style=&quot;font-size: 80%; border-top: 1px dashed #AAAAAA;&quot; | '''Iinaga zephasi'''&lt;br/&gt;
[[Isewula Afrika]]&amp;nbsp;- 
[[Iamarika]]&amp;nbsp;-
[[Angola]]&amp;nbsp;-  
[[Botswana]]&amp;nbsp;- 
[[Burkina Faso]]&amp;nbsp;-   
[[Cameroon]]&amp;nbsp;- 
[[Egypt]]&amp;nbsp;- 
[[Ethiopia]]&amp;nbsp;- 
[[Ghana]]&amp;nbsp;- 
[[Japane]]&amp;nbsp;-
[[Kenya]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Madagascar]]&amp;nbsp;- 
[[Malawi]]&amp;nbsp;- 
[[Mali]]&amp;nbsp;- 
[[Mauritius]]&amp;nbsp;-  
[[Morocco]]&amp;nbsp;-  
[[Mozambique]]&amp;nbsp;-
[[Namibia]]&amp;nbsp;-  
[[Niger]]&amp;nbsp;- 
[[Nigeria]]&amp;nbsp;-   
[[Rwanda]]&amp;nbsp;- 
[[Senegal]]&amp;nbsp;- 
[[Sierra Leone]]&amp;nbsp;- 
[[Somalia]]&amp;nbsp;- 
[[Swaziland]]&amp;nbsp;- 
[[Tanzania]]&amp;nbsp;-
[[Tshayina]]&amp;nbsp;-  
[[Tunisia]]&amp;nbsp;- 
[[Zambia]]&amp;nbsp;- 
[[Zimbabwe]]</text>
      <sha1>by0g5m0dzll6diydaigzdl9fbfdwoxt</sha1>
    </revision>
    <revision>
      <id>1115</id>
      <parentid>1114</parentid>
      <timestamp>2016-02-20T16:57:57Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1115</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2183" sha1="1n5eaol3k49odneehmeai8b3ipxclki" xml:space="preserve">{| cellpadding=&quot;5&quot; cellspacing=&quot;4&quot; style=&quot;width:100%; border:2px ;&quot;  
|-----
|colspan=&quot;6&quot; align=&quot;center&quot; bgcolor=&quot;white&quot; |

{| width=&quot;100%&quot;  border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;5&quot;
|- 
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Nuvola apps bookcase.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 80%; &quot; |  '''Imitlolo ngesindebele'''&lt;br/&gt; 
[[Isindebele]]&amp;nbsp;-
[[Umlando_waMandebele|Umlando waMandebele]]&amp;nbsp;-
[[Amalungelo Wobuntu]]&amp;nbsp;- 
[[umThethosisekelo]]&amp;nbsp;-
[[Ezepilo]]&amp;nbsp;-
[[Ifundo]]&amp;nbsp;-
[[Amatshwayo eSewula Africa]]&amp;nbsp;-
[[Iflaga yeSewula Africa]]&amp;nbsp;-
[[Iinomboro]]&amp;nbsp;-
[[Iinyanga]]&amp;nbsp;-
[[AmaKghono wePilo]]&amp;nbsp;-

&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:P_religion_world.svg|40px|center]]
| style=&quot;font-size: 80%; border-top: 1px dashed #AAAAAA;&quot; | '''Ikolo'''&lt;br/&gt;
[[Uzimu]]&amp;nbsp;- 
[[Ubukresite]]&amp;nbsp;- 
[[Abaphasi]]&amp;nbsp;- 
[[Ikolo]]&amp;nbsp;- 
[[Ibhayibhili]]
&lt;!----------------------------------------------&gt;
|- 
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Nuvola apps kcoloredit.svg|40px|center]]
| style=&quot;font-size: 80%; border-top: 1px dashed #AAAAAA;&quot; | '''Amabala'''&lt;br/&gt;
[[Onzima]]&amp;nbsp;- 
[[Omhlophe]]&amp;nbsp;-
[[Obovu]]&amp;nbsp;- 

&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Gnome-globe.svg|40px|center]]
| style=&quot;font-size: 80%; border-top: 1px dashed #AAAAAA;&quot; | '''Iinaga zephasi'''&lt;br/&gt;
[[Isewula Afrika]]&amp;nbsp;- 
[[Iamarika]]&amp;nbsp;-
[[Angola]]&amp;nbsp;-  
[[Botswana]]&amp;nbsp;- 
[[Burkina Faso]]&amp;nbsp;-   
[[Cameroon]]&amp;nbsp;- 
[[Egypt]]&amp;nbsp;- 
[[Ethiopia]]&amp;nbsp;- 
[[Ghana]]&amp;nbsp;- 
[[Japane]]&amp;nbsp;-
[[Kenya]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Madagascar]]&amp;nbsp;- 
[[Malawi]]&amp;nbsp;- 
[[Mali]]&amp;nbsp;- 
[[Mauritius]]&amp;nbsp;-  
[[Morocco]]&amp;nbsp;-  
[[Mozambique]]&amp;nbsp;-
[[Namibia]]&amp;nbsp;-  
[[Niger]]&amp;nbsp;- 
[[Nigeria]]&amp;nbsp;-   
[[Rwanda]]&amp;nbsp;- 
[[Senegal]]&amp;nbsp;- 
[[Sierra Leone]]&amp;nbsp;- 
[[Somalia]]&amp;nbsp;- 
[[Swaziland]]&amp;nbsp;- 
[[Tanzania]]&amp;nbsp;-
[[Tshayina]]&amp;nbsp;-  
[[Tunisia]]&amp;nbsp;- 
[[Zambia]]&amp;nbsp;- 
[[Zimbabwe]]</text>
      <sha1>1n5eaol3k49odneehmeai8b3ipxclki</sha1>
    </revision>
    <revision>
      <id>1116</id>
      <parentid>1115</parentid>
      <timestamp>2016-02-20T17:07:39Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1116</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2141" sha1="azm135fiwfkdvdkc9p2ydwn27flcayz" xml:space="preserve">{| cellpadding=&quot;5&quot; cellspacing=&quot;4&quot; style=&quot;width:100%; border:2px ;&quot;  
|-----
|colspan=&quot;6&quot; align=&quot;center&quot; bgcolor=&quot;white&quot; |

{| width=&quot;100%&quot;  border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;5&quot;
|- 
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Nuvola apps bookcase.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 80%; &quot; |  '''Imitlolo ngesindebele'''&lt;br/&gt; 
[[Isindebele]]&amp;nbsp;-
[[Umlando waMandebele]]&amp;nbsp;-
[[Amalungelo Wobuntu]]&amp;nbsp;- 
[[umThethosisekelo]]&amp;nbsp;-
[[Ezepilo]]&amp;nbsp;-
[[Ifundo]]&amp;nbsp;-
[[Amatshwayo eSewula Africa]]&amp;nbsp;-
[[Iflaga yeSewula Africa]]&amp;nbsp;-
[[Iinomboro]]&amp;nbsp;-
[[Iinyanga]]&amp;nbsp;-
[[AmaKghono wePilo]]&amp;nbsp;-

&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:P_religion_world.svg|40px|center]]
| style=&quot;font-size: 80%; border-top: 1px dashed #AAAAAA;&quot; | '''Ikolo'''&lt;br/&gt;
[[Uzimu]]&amp;nbsp;- 
[[Ubukresite]]&amp;nbsp;- 
[[Abaphasi]]&amp;nbsp;- 
[[Ikolo]]&amp;nbsp;- 
[[Ibhayibhili]]
&lt;!----------------------------------------------&gt;
|- 
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Nuvola apps kcoloredit.svg|40px|center]]
| style=&quot;font-size: 80%; border-top: 1px dashed #AAAAAA;&quot; | '''Amabala'''&lt;br/&gt;
[[Onzima]]&amp;nbsp;- 
[[Omhlophe]]&amp;nbsp;-
[[Obovu]]&amp;nbsp;- 

&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Gnome-globe.svg|40px|center]]
| style=&quot;font-size: 80%; border-top: 1px dashed #AAAAAA;&quot; | '''Iinaga zephasi'''&lt;br/&gt;
[[Isewula Afrika]]&amp;nbsp;- 
[[Iamarika]]&amp;nbsp;-
[[Angola]]&amp;nbsp;-  
[[Botswana]]&amp;nbsp;- 
[[Burkina Faso]]&amp;nbsp;-   
[[Cameroon]]&amp;nbsp;- 
[[Egypt]]&amp;nbsp;- 
[[Ethiopia]]&amp;nbsp;- 
[[Ghana]]&amp;nbsp;- 
[[Japane]]&amp;nbsp;-
[[Kenya]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Madagascar]]&amp;nbsp;- 
[[Malawi]]&amp;nbsp;- 
[[Mali]]&amp;nbsp;- 
[[Mauritius]]&amp;nbsp;-  
[[Morocco]]&amp;nbsp;-  
[[Mozambique]]&amp;nbsp;-
[[Namibia]]&amp;nbsp;-  
[[Niger]]&amp;nbsp;- 
[[Rwanda]]&amp;nbsp;- 
[[Senegal]]&amp;nbsp;- 
[[Sierra Leone]]&amp;nbsp;- 
[[Somalia]]&amp;nbsp;- 
[[Swaziland]]&amp;nbsp;- 
[[Tanzania]]&amp;nbsp;-
[[Tshayina]]&amp;nbsp;-  
[[Tunisia]]&amp;nbsp;- 
[[Zambia]]&amp;nbsp;- 
[[Zimbabwe]]</text>
      <sha1>azm135fiwfkdvdkc9p2ydwn27flcayz</sha1>
    </revision>
    <revision>
      <id>1117</id>
      <parentid>1116</parentid>
      <timestamp>2016-02-21T07:05:00Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1117</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2147" sha1="ele155h404607lsegp1dnv3qrjhgfts" xml:space="preserve">{| cellpadding=&quot;5&quot; cellspacing=&quot;4&quot; style=&quot;width:100%; border:2px ;&quot;  
|-----
|colspan=&quot;6&quot; align=&quot;center&quot; bgcolor=&quot;white&quot; |

{| width=&quot;100%&quot;  border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;5&quot;
|- 
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Nuvola apps bookcase.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 80%; &quot; |  '''Imitlolo ngesindebele'''&lt;br/&gt; 
[[Isindebele]]&amp;nbsp;-
[[Umlando waMandebele]]&amp;nbsp;-
[[Amalungelo Wobuntu]]&amp;nbsp;- 
[[umThethosisekelo]]&amp;nbsp;-
[[Ezepilo]]&amp;nbsp;-
[[Ifundo]]&amp;nbsp;-
[[Amatshwayo eSewula Africa]]&amp;nbsp;-
[[Iflaga yeSewula Africa]]&amp;nbsp;-
[[Iinomboro]]&amp;nbsp;-
[[Iinyanga]]&amp;nbsp;-
[[AmaKghono wePilo]]&amp;nbsp;-

&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:P_religion_world.svg|40px|center]]
| style=&quot;font-size: 80%; border-top: 1px dashed #AAAAAA;&quot; | '''Ikolo'''&lt;br/&gt;
[[Uzimu]]&amp;nbsp;- 
[[Ubukresite]]&amp;nbsp;- 
[[Abaphasi]]&amp;nbsp;- 
[[Ikolo]]&amp;nbsp;- 
[[Ibhayibhili]]
&lt;!----------------------------------------------&gt;
|- 
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Nuvola apps kcoloredit.svg|40px|center]]
| style=&quot;font-size: 80%; border-top: 1px dashed #AAAAAA;&quot; | '''Amabala'''&lt;br/&gt;
[[Onzima]]&amp;nbsp;- 
[[Omhlophe]]&amp;nbsp;-
[[Obovu]]&amp;nbsp;- 

&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Gnome-globe.svg|40px|center]]
| style=&quot;font-size: 80%; border-top: 1px dashed #AAAAAA;&quot; | '''Iinaga zephasi'''&lt;br/&gt;
[[Isewula Afrika]]&amp;nbsp;- 
[[Iamarika]]&amp;nbsp;-
[[Angola]]&amp;nbsp;-  
[[Botswana]]&amp;nbsp;- 
[[Burkina Faso]]&amp;nbsp;-   
[[Cameroon]]&amp;nbsp;- 
[[Egypt]]&amp;nbsp;- 
[[Ethiopia]]&amp;nbsp;- 
[[Ghana]]&amp;nbsp;- 
[[Japane]]&amp;nbsp;-
[[Kenya]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Madagascar]]&amp;nbsp;- 
[[Malawi]]&amp;nbsp;- 
[[Mali]]&amp;nbsp;- 
[[Mauritius]]&amp;nbsp;-  
[[Morocco]]&amp;nbsp;-  
[[Mozambique]]&amp;nbsp;-
[[Namibia]]&amp;nbsp;-  
[[Niger]]&amp;nbsp;- 
[[Rwanda]]&amp;nbsp;- 
[[Senegal]]&amp;nbsp;- 
[[Sierra Leone]]&amp;nbsp;- 
[[Somalia]]&amp;nbsp;- 
[[Swaziland]]&amp;nbsp;- 
[[Tanzania]]&amp;nbsp;-
[[Tshayina]]&amp;nbsp;-  
[[Tunisia]]&amp;nbsp;- 
[[Zambia]]&amp;nbsp;- 
[[Zimbabwe]]
|}
|}</text>
      <sha1>ele155h404607lsegp1dnv3qrjhgfts</sha1>
    </revision>
    <revision>
      <id>1118</id>
      <parentid>1117</parentid>
      <timestamp>2016-02-21T07:06:21Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1118</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2145" sha1="r6tv0whs9ibvywy2lswvsgswj6qut54" xml:space="preserve">{| cellpadding=&quot;5&quot; cellspacing=&quot;4&quot; style=&quot;width:100%; border:2px ;&quot;  
|-----
|colspan=&quot;6&quot; align=&quot;center&quot; bgcolor=&quot;white&quot; |

{| width=&quot;100%&quot;  border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;5&quot;
|- 
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Nuvola apps bookcase.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 80%; &quot; |  '''Imitlolo ngesindebele'''&lt;br/&gt; 
[[Isindebele]]&amp;nbsp;-
[[Umlando waMandebele]]&amp;nbsp;-
[[Amalungelo Wobuntu]]&amp;nbsp;- 
[[umThethosisekelo]]&amp;nbsp;-
[[Ezepilo]]&amp;nbsp;-
[[Ifundo]]&amp;nbsp;-
[[Amatshwayo eSewula Africa]]&amp;nbsp;-
[[Iflaga yeSewula Africa]]&amp;nbsp;-
[[Iinomboro]]&amp;nbsp;-
[[Iinyanga]]&amp;nbsp;-
[[AmaKghono wePilo]]&amp;nbsp;-

&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:P_religion_world.svg|40px|center]]
| style=&quot;font-size: 80%; border-top: 1px dashed #AAAAAA;&quot; | '''Ikolo'''&lt;br/&gt;
[[Uzimu]]&amp;nbsp;- 
[[Ubukresite]]&amp;nbsp;- 
[[Abaphasi]]&amp;nbsp;- 
[[Ikolo]]&amp;nbsp;- 
[[Ibhayibhili]]
&lt;!----------------------------------------------&gt;
|- 
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Nuvola apps kcoloredit.svg|40px|center]]
| style=&quot;font-size: 80%; border-top: 1px dashed #AAAAAA;&quot; | '''Amabala'''&lt;br/&gt;
[[Onzima]]&amp;nbsp;- 
[[Omhlophe]]&amp;nbsp;-
[[Obovu]]&amp;nbsp;- 

&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Gnome-globe.svg|40px|center]]
| style=&quot;font-size: 80%; border-top: 1px dashed #AAAAAA;&quot; | '''Iinaga zephasi'''&lt;br/&gt;
[[Isewula Afrika]]&amp;nbsp;- 
[[Iamarika]]&amp;nbsp;-
[[Angola]]&amp;nbsp;-  
[[Botswana]]&amp;nbsp;- 
[[Burkina Faso]]&amp;nbsp;-   
[[Cameroon]]&amp;nbsp;- 
[[Egypt]]&amp;nbsp;- 
[[Ethiopia]]&amp;nbsp;- 
[[Ghana]]&amp;nbsp;- 
[[Japane]]&amp;nbsp;-
[[Kenya]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Madagascar]]&amp;nbsp;- 
[[Malawi]]&amp;nbsp;- 
[[Mali]]&amp;nbsp;- 
[[Mauritius]]&amp;nbsp;-  
[[Morocco]]&amp;nbsp;-  
[[Mozambique]]&amp;nbsp;-
[[Namibia]]&amp;nbsp;-  
[[Niger]]&amp;nbsp;- 
[[Rwanda]]&amp;nbsp;- 
[[Senegal]]&amp;nbsp;- 
[[Sierra Leone]]&amp;nbsp;- 
[[Somalia]]&amp;nbsp;- 
[[Swaziland]]&amp;nbsp;- 
[[Tanzania]]&amp;nbsp;-
[[Tshayina]]&amp;nbsp;-  
[[Tunisia]]&amp;nbsp;- 
[[Zambia]]&amp;nbsp;- 
[[Zimbabwe]]

|}</text>
      <sha1>r6tv0whs9ibvywy2lswvsgswj6qut54</sha1>
    </revision>
    <revision>
      <id>1119</id>
      <parentid>1118</parentid>
      <timestamp>2016-02-21T07:19:37Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1119</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2145" sha1="pe2cen68gbvpqaqguuyg7aq55r413gh" xml:space="preserve">{| cellpadding=&quot;5&quot; cellspacing=&quot;4&quot; style=&quot;width:100%; border:2px ;&quot;  
|-----
|colspan=&quot;6&quot; align=&quot;center&quot; bgcolor=&quot;white&quot; |

{| width=&quot;100%&quot;  border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;5&quot;
|- 
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Nuvola apps bookcase.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 85%; &quot; |  '''Imitlolo ngesindebele'''&lt;br/&gt; 
[[Isindebele]]&amp;nbsp;-
[[Umlando waMandebele]]&amp;nbsp;-
[[Amalungelo Wobuntu]]&amp;nbsp;- 
[[umThethosisekelo]]&amp;nbsp;-
[[Ezepilo]]&amp;nbsp;-
[[Ifundo]]&amp;nbsp;-
[[Amatshwayo eSewula Africa]]&amp;nbsp;-
[[Iflaga yeSewula Africa]]&amp;nbsp;-
[[Iinomboro]]&amp;nbsp;-
[[Iinyanga]]&amp;nbsp;-
[[AmaKghono wePilo]]&amp;nbsp;-

&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:P_religion_world.svg|40px|center]]
| style=&quot;font-size: 85%; border-top: 1px dashed #AAAAAA;&quot; | '''Ikolo'''&lt;br/&gt;
[[Uzimu]]&amp;nbsp;- 
[[Ubukresite]]&amp;nbsp;- 
[[Abaphasi]]&amp;nbsp;- 
[[Ikolo]]&amp;nbsp;- 
[[Ibhayibhili]]
&lt;!----------------------------------------------&gt;
|- 
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Nuvola apps kcoloredit.svg|40px|center]]
| style=&quot;font-size: 85%; border-top: 1px dashed #AAAAAA;&quot; | '''Amabala'''&lt;br/&gt;
[[Onzima]]&amp;nbsp;- 
[[Omhlophe]]&amp;nbsp;-
[[Obovu]]&amp;nbsp;- 

&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Gnome-globe.svg|40px|center]]
| style=&quot;font-size: 85%; border-top: 1px dashed #AAAAAA;&quot; | '''Iinaga zephasi'''&lt;br/&gt;
[[Isewula Afrika]]&amp;nbsp;- 
[[Iamarika]]&amp;nbsp;-
[[Angola]]&amp;nbsp;-  
[[Botswana]]&amp;nbsp;- 
[[Burkina Faso]]&amp;nbsp;-   
[[Cameroon]]&amp;nbsp;- 
[[Egypt]]&amp;nbsp;- 
[[Ethiopia]]&amp;nbsp;- 
[[Ghana]]&amp;nbsp;- 
[[Japane]]&amp;nbsp;-
[[Kenya]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Madagascar]]&amp;nbsp;- 
[[Malawi]]&amp;nbsp;- 
[[Mali]]&amp;nbsp;- 
[[Mauritius]]&amp;nbsp;-  
[[Morocco]]&amp;nbsp;-  
[[Mozambique]]&amp;nbsp;-
[[Namibia]]&amp;nbsp;-  
[[Niger]]&amp;nbsp;- 
[[Rwanda]]&amp;nbsp;- 
[[Senegal]]&amp;nbsp;- 
[[Sierra Leone]]&amp;nbsp;- 
[[Somalia]]&amp;nbsp;- 
[[Swaziland]]&amp;nbsp;- 
[[Tanzania]]&amp;nbsp;-
[[Tshayina]]&amp;nbsp;-  
[[Tunisia]]&amp;nbsp;- 
[[Zambia]]&amp;nbsp;- 
[[Zimbabwe]]

|}</text>
      <sha1>pe2cen68gbvpqaqguuyg7aq55r413gh</sha1>
    </revision>
    <revision>
      <id>1120</id>
      <parentid>1119</parentid>
      <timestamp>2016-02-21T07:20:40Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1120</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2145" sha1="ltvspnu9o4gv0325hnp8o7kh0sfqy2r" xml:space="preserve">{| cellpadding=&quot;5&quot; cellspacing=&quot;4&quot; style=&quot;width:100%; border:2px ;&quot;  
|-----
|colspan=&quot;6&quot; align=&quot;center&quot; bgcolor=&quot;white&quot; |

{| width=&quot;100%&quot;  border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;5&quot;
|- 
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Nuvola apps bookcase.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 90%; &quot; |  '''Imitlolo ngesindebele'''&lt;br/&gt; 
[[Isindebele]]&amp;nbsp;-
[[Umlando waMandebele]]&amp;nbsp;-
[[Amalungelo Wobuntu]]&amp;nbsp;- 
[[umThethosisekelo]]&amp;nbsp;-
[[Ezepilo]]&amp;nbsp;-
[[Ifundo]]&amp;nbsp;-
[[Amatshwayo eSewula Africa]]&amp;nbsp;-
[[Iflaga yeSewula Africa]]&amp;nbsp;-
[[Iinomboro]]&amp;nbsp;-
[[Iinyanga]]&amp;nbsp;-
[[AmaKghono wePilo]]&amp;nbsp;-

&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:P_religion_world.svg|40px|center]]
| style=&quot;font-size: 90%; border-top: 1px dashed #AAAAAA;&quot; | '''Ikolo'''&lt;br/&gt;
[[Uzimu]]&amp;nbsp;- 
[[Ubukresite]]&amp;nbsp;- 
[[Abaphasi]]&amp;nbsp;- 
[[Ikolo]]&amp;nbsp;- 
[[Ibhayibhili]]
&lt;!----------------------------------------------&gt;
|- 
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Nuvola apps kcoloredit.svg|40px|center]]
| style=&quot;font-size: 90%; border-top: 1px dashed #AAAAAA;&quot; | '''Amabala'''&lt;br/&gt;
[[Onzima]]&amp;nbsp;- 
[[Omhlophe]]&amp;nbsp;-
[[Obovu]]&amp;nbsp;- 

&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Gnome-globe.svg|40px|center]]
| style=&quot;font-size: 90%; border-top: 1px dashed #AAAAAA;&quot; | '''Iinaga zephasi'''&lt;br/&gt;
[[Isewula Afrika]]&amp;nbsp;- 
[[Iamarika]]&amp;nbsp;-
[[Angola]]&amp;nbsp;-  
[[Botswana]]&amp;nbsp;- 
[[Burkina Faso]]&amp;nbsp;-   
[[Cameroon]]&amp;nbsp;- 
[[Egypt]]&amp;nbsp;- 
[[Ethiopia]]&amp;nbsp;- 
[[Ghana]]&amp;nbsp;- 
[[Japane]]&amp;nbsp;-
[[Kenya]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Madagascar]]&amp;nbsp;- 
[[Malawi]]&amp;nbsp;- 
[[Mali]]&amp;nbsp;- 
[[Mauritius]]&amp;nbsp;-  
[[Morocco]]&amp;nbsp;-  
[[Mozambique]]&amp;nbsp;-
[[Namibia]]&amp;nbsp;-  
[[Niger]]&amp;nbsp;- 
[[Rwanda]]&amp;nbsp;- 
[[Senegal]]&amp;nbsp;- 
[[Sierra Leone]]&amp;nbsp;- 
[[Somalia]]&amp;nbsp;- 
[[Swaziland]]&amp;nbsp;- 
[[Tanzania]]&amp;nbsp;-
[[Tshayina]]&amp;nbsp;-  
[[Tunisia]]&amp;nbsp;- 
[[Zambia]]&amp;nbsp;- 
[[Zimbabwe]]

|}</text>
      <sha1>ltvspnu9o4gv0325hnp8o7kh0sfqy2r</sha1>
    </revision>
    <revision>
      <id>1121</id>
      <parentid>1120</parentid>
      <timestamp>2016-02-21T07:45:52Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1121</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2580" sha1="3e7hq5xuczl080c10pdqxzvk1ozbbfk" xml:space="preserve">{| cellpadding=&quot;5&quot; cellspacing=&quot;4&quot; style=&quot;width:100%; border:2px ;&quot;  
|-----
|colspan=&quot;6&quot; align=&quot;center&quot; bgcolor=&quot;white&quot; |

{| width=&quot;100%&quot;  border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;5&quot;
|- 
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Nuvola apps bookcase.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 90%; &quot; |  '''Imitlolo ngesindebele'''&lt;br/&gt; 
[[Isindebele]]&amp;nbsp;-
[[Umlando waMandebele]]&amp;nbsp;-
[[Amalungelo Wobuntu]]&amp;nbsp;- 
[[umThethosisekelo]]&amp;nbsp;-
[[Ezepilo]]&amp;nbsp;-
[[Ifundo]]&amp;nbsp;-
[[Amatshwayo eSewula Africa]]&amp;nbsp;-
[[Iflaga yeSewula Africa]]&amp;nbsp;-
[[Iinomboro]]&amp;nbsp;-
[[Iinyanga]]&amp;nbsp;-
[[AmaKghono wePilo]]&amp;nbsp;-
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:P_religion_world.svg|40px|center]]
| style=&quot;font-size: 90%; border-top: 1px dashed #AAAAAA;&quot; | '''Ikolo'''&lt;br/&gt;
[[Uzimu]]&amp;nbsp;- 
[[Ubukresite]]&amp;nbsp;- 
[[Abaphasi]]&amp;nbsp;- 
[[Ikolo]]&amp;nbsp;- 
[[Ibhayibhili]]
&lt;!----------------------------------------------&gt;
|- 
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Nuvola apps kcoloredit.svg|40px|center]]
| style=&quot;font-size: 90%; border-top: 1px dashed #AAAAAA;&quot; | '''Amabala'''&lt;br/&gt;
[[Onzima]]&amp;nbsp;- 
[[Omhlophe]]&amp;nbsp;-
[[Obovu]]&amp;nbsp;- 
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Gnome-globe.svg|40px|center]]
| style=&quot;font-size: 90%; border-top: 1px dashed #AAAAAA;&quot; | '''Iinaga zephasi'''&lt;br/&gt;
[[Isewula Afrika]]&amp;nbsp;- 
[[Iamarika]]&amp;nbsp;-
[[Angola]]&amp;nbsp;-  
[[Botswana]]&amp;nbsp;- 
[[Burkina Faso]]&amp;nbsp;-   
[[Cameroon]]&amp;nbsp;- 
[[Egypt]]&amp;nbsp;- 
[[Ethiopia]]&amp;nbsp;- 
[[Ghana]]&amp;nbsp;- 
[[Japane]]&amp;nbsp;-
[[Kenya]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Madagascar]]&amp;nbsp;- 
[[Malawi]]&amp;nbsp;- 
[[Mali]]&amp;nbsp;- 
[[Mauritius]]&amp;nbsp;-  
[[Morocco]]&amp;nbsp;-  
[[Mozambique]]&amp;nbsp;-
[[Namibia]]&amp;nbsp;-  
[[Niger]]&amp;nbsp;- 
[[Rwanda]]&amp;nbsp;- 
[[Senegal]]&amp;nbsp;- 
[[Sierra Leone]]&amp;nbsp;- 
[[Somalia]]&amp;nbsp;- 
[[Swaziland]]&amp;nbsp;- 
[[Tanzania]]&amp;nbsp;-
[[Tshayina]]&amp;nbsp;-  
[[Tunisia]]&amp;nbsp;- 
[[Zambia]]&amp;nbsp;- 
[[Zimbabwe]]
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Nuvola apps kuser.svg|40px|center]]
| style=&quot;font-size: 90%; border-top: 1px dashed #AAAAAA;&quot; | '''Ubuhlobo'''&lt;br/&gt;
[[Umndeni]]&amp;nbsp;-
[[Ababelethi]]&amp;nbsp;-
[[Umntwana]]&amp;nbsp;-
[[Umtjhado]]&amp;nbsp;-
[[Umrazana]]&amp;nbsp;-
[[Isokana]]&amp;nbsp;-
[[Ukhwenyana]]&amp;nbsp;-
[[Umakoti]]&amp;nbsp;-
[[Ilobolo]]&amp;nbsp;-
[[Iindakamizwa]]&amp;nbsp;-
|}</text>
      <sha1>3e7hq5xuczl080c10pdqxzvk1ozbbfk</sha1>
    </revision>
    <revision>
      <id>1122</id>
      <parentid>1121</parentid>
      <timestamp>2016-02-21T08:28:59Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1122</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2611" sha1="2u5mejysea2whj346br4mgtoi7dshaj" xml:space="preserve">{| cellpadding=&quot;5&quot; cellspacing=&quot;4&quot; style=&quot;width:100%; border:2px ;&quot;  
|-----
|colspan=&quot;6&quot; align=&quot;center&quot; bgcolor=&quot;white&quot; |

{| width=&quot;100%&quot;  border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;5&quot;
|- 
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Nuvola apps bookcase.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 90%; &quot; |  '''Imitlolo ngesindebele'''&lt;br/&gt; 
[[Isindebele]]&amp;nbsp;-
[[Umlando waMandebele]]&amp;nbsp;-
[[Amalungelo Wobuntu]]&amp;nbsp;- 
[[umThethosisekelo]]&amp;nbsp;-
[[Ezepilo]]&amp;nbsp;-
[[Ifundo]]&amp;nbsp;-
[[Amatshwayo eSewula Africa]]&amp;nbsp;-
[[Iflaga yeSewula Africa]]&amp;nbsp;-
[[Iinomboro]]&amp;nbsp;-
[[Iinyanga]]&amp;nbsp;-
[[AmaKghono wePilo]]&amp;nbsp;-
[[Ikrismesi]]&amp;nbsp;
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:P_religion_world.svg|40px|center]]
| style=&quot;font-size: 90%; border-top: 1px dashed #AAAAAA;&quot; | '''Ikolo'''&lt;br/&gt;
[[Uzimu]]&amp;nbsp;- 
[[Ubukresite]]&amp;nbsp;- 
[[Abaphasi]]&amp;nbsp;- 
[[Ikolo]]&amp;nbsp;- 
[[Ibhayibhili]]&amp;nbsp;
&lt;!----------------------------------------------&gt;
|- 
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Nuvola apps kcoloredit.svg|40px|center]]
| style=&quot;font-size: 90%; border-top: 1px dashed #AAAAAA;&quot; | '''Amabala'''&lt;br/&gt;
[[Onzima]]&amp;nbsp;- 
[[Omhlophe]]&amp;nbsp;-
[[Obovu]]&amp;nbsp; 
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Gnome-globe.svg|40px|center]]
| style=&quot;font-size: 90%; border-top: 1px dashed #AAAAAA;&quot; | '''Iinarha zephasi'''&lt;br/&gt;
[[Isewula Afrika]]&amp;nbsp;- 
[[Iamarika]]&amp;nbsp;-
[[Angola]]&amp;nbsp;-  
[[Botswana]]&amp;nbsp;- 
[[Burkina Faso]]&amp;nbsp;-   
[[Cameroon]]&amp;nbsp;- 
[[Egypt]]&amp;nbsp;- 
[[Ethiopia]]&amp;nbsp;- 
[[Ghana]]&amp;nbsp;- 
[[Japane]]&amp;nbsp;-
[[Kenya]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Madagascar]]&amp;nbsp;- 
[[Malawi]]&amp;nbsp;- 
[[Mali]]&amp;nbsp;- 
[[Mauritius]]&amp;nbsp;-  
[[Morocco]]&amp;nbsp;-  
[[Mozambique]]&amp;nbsp;-
[[Namibia]]&amp;nbsp;-  
[[Niger]]&amp;nbsp;- 
[[Rwanda]]&amp;nbsp;- 
[[Senegal]]&amp;nbsp;- 
[[Sierra Leone]]&amp;nbsp;- 
[[Somalia]]&amp;nbsp;- 
[[Swaziland]]&amp;nbsp;- 
[[Tanzania]]&amp;nbsp;-
[[Tshayina]]&amp;nbsp;-  
[[Tunisia]]&amp;nbsp;- 
[[Zambia]]&amp;nbsp;- 
[[Zimbabwe]]&amp;nbsp;
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Nuvola apps kuser.svg|40px|center]]
| style=&quot;font-size: 90%; border-top: 1px dashed #AAAAAA;&quot; | '''Ubuhlobo'''&lt;br/&gt;
[[Umndeni]]&amp;nbsp;-
[[Ababelethi]]&amp;nbsp;-
[[Umntwana]]&amp;nbsp;-
[[Umtjhado]]&amp;nbsp;-
[[Umrazana]]&amp;nbsp;-
[[Isokana]]&amp;nbsp;-
[[Ukhwenyana]]&amp;nbsp;-
[[Umakoti]]&amp;nbsp;-
[[Ilobolo]]&amp;nbsp;-
[[Iindakamizwa]]&amp;nbsp;
|}</text>
      <sha1>2u5mejysea2whj346br4mgtoi7dshaj</sha1>
    </revision>
    <revision>
      <id>1123</id>
      <parentid>1122</parentid>
      <timestamp>2016-02-21T08:34:21Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1123</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2684" sha1="nv1erspglz7cvvs78pdgzaid0erilkr" xml:space="preserve">{| cellpadding=&quot;5&quot; cellspacing=&quot;4&quot; style=&quot;width:100%; border:2px ;&quot;  
|-----
|colspan=&quot;6&quot; align=&quot;center&quot; bgcolor=&quot;white&quot; |

{| width=&quot;100%&quot;  border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;5&quot;
|- 
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Nuvola apps bookcase.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 90%; &quot; |  '''Imitlolo ngesindebele'''&lt;br/&gt; 
[[Isindebele]]&amp;nbsp;-
[[Umlando waMandebele]]&amp;nbsp;-
[[Amalungelo Wobuntu]]&amp;nbsp;- 
[[umThethosisekelo]]&amp;nbsp;-
[[Ezepilo]]&amp;nbsp;-
[[Ifundo]]&amp;nbsp;-
[[Amatshwayo eSewula Africa]]&amp;nbsp;-
[[Iflaga yeSewula Africa]]&amp;nbsp;-
[[UmSebenzi WesiTjhaba WezamaLimi]]&amp;nbsp;-
[[Iinomboro]]&amp;nbsp;-
[[Iinyanga]]&amp;nbsp;-
[[AmaKghono wePilo]]&amp;nbsp;-
[[Ikrismesi]]&amp;nbsp;-
[[Ubulwelwe be-Ebola]]&amp;nbsp;
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:P_religion_world.svg|40px|center]]
| style=&quot;font-size: 90%; border-top: 1px dashed #AAAAAA;&quot; | '''Ikolo'''&lt;br/&gt;
[[Uzimu]]&amp;nbsp;- 
[[Ubukresite]]&amp;nbsp;- 
[[Abaphasi]]&amp;nbsp;- 
[[Ikolo]]&amp;nbsp;- 
[[Ibhayibhili]]&amp;nbsp;
&lt;!----------------------------------------------&gt;
|- 
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Nuvola apps kcoloredit.svg|40px|center]]
| style=&quot;font-size: 90%; border-top: 1px dashed #AAAAAA;&quot; | '''Amabala'''&lt;br/&gt;
[[Onzima]]&amp;nbsp;- 
[[Omhlophe]]&amp;nbsp;-
[[Obovu]]&amp;nbsp; 
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Gnome-globe.svg|40px|center]]
| style=&quot;font-size: 90%; border-top: 1px dashed #AAAAAA;&quot; | '''Iinarha zephasi'''&lt;br/&gt;
[[Isewula Afrika]]&amp;nbsp;- 
[[Iamarika]]&amp;nbsp;-
[[Angola]]&amp;nbsp;-  
[[Botswana]]&amp;nbsp;- 
[[Burkina Faso]]&amp;nbsp;-   
[[Cameroon]]&amp;nbsp;- 
[[Egypt]]&amp;nbsp;- 
[[Ethiopia]]&amp;nbsp;- 
[[Ghana]]&amp;nbsp;- 
[[Japane]]&amp;nbsp;-
[[Kenya]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Madagascar]]&amp;nbsp;- 
[[Malawi]]&amp;nbsp;- 
[[Mali]]&amp;nbsp;- 
[[Mauritius]]&amp;nbsp;-  
[[Morocco]]&amp;nbsp;-  
[[Mozambique]]&amp;nbsp;-
[[Namibia]]&amp;nbsp;-  
[[Niger]]&amp;nbsp;- 
[[Rwanda]]&amp;nbsp;- 
[[Senegal]]&amp;nbsp;- 
[[Sierra Leone]]&amp;nbsp;- 
[[Somalia]]&amp;nbsp;- 
[[Swaziland]]&amp;nbsp;- 
[[Tanzania]]&amp;nbsp;-
[[Tshayina]]&amp;nbsp;-  
[[Tunisia]]&amp;nbsp;- 
[[Zambia]]&amp;nbsp;- 
[[Zimbabwe]]&amp;nbsp;
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Nuvola apps kuser.svg|40px|center]]
| style=&quot;font-size: 90%; border-top: 1px dashed #AAAAAA;&quot; | '''Ubuhlobo'''&lt;br/&gt;
[[Umndeni]]&amp;nbsp;-
[[Ababelethi]]&amp;nbsp;-
[[Umntwana]]&amp;nbsp;-
[[Umtjhado]]&amp;nbsp;-
[[Umrazana]]&amp;nbsp;-
[[Isokana]]&amp;nbsp;-
[[Ukhwenyana]]&amp;nbsp;-
[[Umakoti]]&amp;nbsp;-
[[Ilobolo]]&amp;nbsp;-
[[Iindakamizwa]]&amp;nbsp;
|}</text>
      <sha1>nv1erspglz7cvvs78pdgzaid0erilkr</sha1>
    </revision>
    <revision>
      <id>1124</id>
      <parentid>1123</parentid>
      <timestamp>2016-02-22T13:19:04Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1124</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2922" sha1="nqdsloel5exl6unh54mpw4pvsdxixr5" xml:space="preserve">{| cellpadding=&quot;5&quot; cellspacing=&quot;4&quot; style=&quot;width:100%; border:2px ;&quot;  
|-----
|colspan=&quot;6&quot; align=&quot;center&quot; bgcolor=&quot;white&quot; |

{| width=&quot;100%&quot;  border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;5&quot;
|- 
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Nuvola apps bookcase.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 90%; &quot; |  '''Imitlolo ngesindebele'''&lt;br/&gt; 
[[Isindebele]]&amp;nbsp;-
[[Umlando waMandebele]]&amp;nbsp;-
[[Amalungelo Wobuntu]]&amp;nbsp;- 
[[umThethosisekelo]]&amp;nbsp;-
[[Ezepilo]]&amp;nbsp;-
[[Ifundo]]&amp;nbsp;-
[[Amatshwayo eSewula Africa]]&amp;nbsp;-
[[Iflaga yeSewula Africa]]&amp;nbsp;-
[[UmSebenzi WesiTjhaba WezamaLimi]]&amp;nbsp;-
[[Iinomboro]]&amp;nbsp;-
[[Iinyanga]]&amp;nbsp;-
[[AmaKghono wePilo]]&amp;nbsp;-
[[Ikrismesi]]&amp;nbsp;-
[[Ubulwelwe be-Ebola]]&amp;nbsp;
[[Onzima]]&amp;nbsp;- 
[[Omhlophe]]&amp;nbsp;-
[[Obovu]]&amp;nbsp;
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:P_religion_world.svg|40px|center]]
| style=&quot;font-size: 90%; border-top: 1px dashed #AAAAAA;&quot; | '''Ikolo'''&lt;br/&gt;
[[Uzimu]]&amp;nbsp;- 
[[Ubukresite]]&amp;nbsp;- 
[[Abaphasi]]&amp;nbsp;- 
[[Ikolo]]&amp;nbsp;- 
[[Ibhayibhili]]&amp;nbsp;
&lt;!----------------------------------------------&gt;
|- 
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Classroom icon.svg|40px|center]]
| style=&quot;font-size: 90%; border-top: 1px dashed #AAAAAA;&quot; | '''Abatloli Besindebele'''&lt;br/&gt;
[[Alexander Mthombeni|A.B. Mthombeni]]&amp;nbsp;- 
[[Moses Mahlangu|M.S. Mahlangu]]&amp;nbsp;-
[[PB Skhosana|P.B. Skhosana]]&amp;nbsp;- 
[[Bhiza Masango|B.D Masango]]&amp;nbsp;-
[[Themba Mnguni|T.G Mnguni]]&amp;nbsp;- 
[[Mgiyelwa Ntuli|M.S Ntuli]]&amp;nbsp;
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Gnome-globe.svg|40px|center]]
| style=&quot;font-size: 90%; border-top: 1px dashed #AAAAAA;&quot; | '''Iinarha zephasi'''&lt;br/&gt;
[[Isewula Afrika]]&amp;nbsp;- 
[[Iamarika]]&amp;nbsp;-
[[Angola]]&amp;nbsp;-  
[[Botswana]]&amp;nbsp;- 
[[Burkina Faso]]&amp;nbsp;-   
[[Cameroon]]&amp;nbsp;- 
[[Egypt]]&amp;nbsp;- 
[[Ethiopia]]&amp;nbsp;- 
[[Ghana]]&amp;nbsp;- 
[[Japane]]&amp;nbsp;-
[[Kenya]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Madagascar]]&amp;nbsp;- 
[[Malawi]]&amp;nbsp;- 
[[Mali]]&amp;nbsp;- 
[[Mauritius]]&amp;nbsp;-  
[[Morocco]]&amp;nbsp;-  
[[Mozambique]]&amp;nbsp;-
[[Namibia]]&amp;nbsp;-  
[[Niger]]&amp;nbsp;- 
[[Rwanda]]&amp;nbsp;- 
[[Senegal]]&amp;nbsp;- 
[[Sierra Leone]]&amp;nbsp;- 
[[Somalia]]&amp;nbsp;- 
[[Swaziland]]&amp;nbsp;- 
[[Tanzania]]&amp;nbsp;-
[[Tshayina]]&amp;nbsp;-  
[[Tunisia]]&amp;nbsp;- 
[[Zambia]]&amp;nbsp;- 
[[Zimbabwe]]&amp;nbsp;
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Nuvola apps kuser.svg|40px|center]]
| style=&quot;font-size: 90%; border-top: 1px dashed #AAAAAA;&quot; | '''Ubuhlobo'''&lt;br/&gt;
[[Umndeni]]&amp;nbsp;-
[[Ababelethi]]&amp;nbsp;-
[[Umntwana]]&amp;nbsp;-
[[Umtjhado]]&amp;nbsp;-
[[Umrazana]]&amp;nbsp;-
[[Isokana]]&amp;nbsp;-
[[Ukhwenyana]]&amp;nbsp;-
[[Umakoti]]&amp;nbsp;-
[[Ilobolo]]&amp;nbsp;-
[[Iindakamizwa]]&amp;nbsp;
|}</text>
      <sha1>nqdsloel5exl6unh54mpw4pvsdxixr5</sha1>
    </revision>
    <revision>
      <id>1125</id>
      <parentid>1124</parentid>
      <timestamp>2024-10-14T13:47:03Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>26 revisions imported</comment>
      <origin>1124</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2922" sha1="nqdsloel5exl6unh54mpw4pvsdxixr5" xml:space="preserve">{| cellpadding=&quot;5&quot; cellspacing=&quot;4&quot; style=&quot;width:100%; border:2px ;&quot;  
|-----
|colspan=&quot;6&quot; align=&quot;center&quot; bgcolor=&quot;white&quot; |

{| width=&quot;100%&quot;  border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;5&quot;
|- 
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Nuvola apps bookcase.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 90%; &quot; |  '''Imitlolo ngesindebele'''&lt;br/&gt; 
[[Isindebele]]&amp;nbsp;-
[[Umlando waMandebele]]&amp;nbsp;-
[[Amalungelo Wobuntu]]&amp;nbsp;- 
[[umThethosisekelo]]&amp;nbsp;-
[[Ezepilo]]&amp;nbsp;-
[[Ifundo]]&amp;nbsp;-
[[Amatshwayo eSewula Africa]]&amp;nbsp;-
[[Iflaga yeSewula Africa]]&amp;nbsp;-
[[UmSebenzi WesiTjhaba WezamaLimi]]&amp;nbsp;-
[[Iinomboro]]&amp;nbsp;-
[[Iinyanga]]&amp;nbsp;-
[[AmaKghono wePilo]]&amp;nbsp;-
[[Ikrismesi]]&amp;nbsp;-
[[Ubulwelwe be-Ebola]]&amp;nbsp;
[[Onzima]]&amp;nbsp;- 
[[Omhlophe]]&amp;nbsp;-
[[Obovu]]&amp;nbsp;
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:P_religion_world.svg|40px|center]]
| style=&quot;font-size: 90%; border-top: 1px dashed #AAAAAA;&quot; | '''Ikolo'''&lt;br/&gt;
[[Uzimu]]&amp;nbsp;- 
[[Ubukresite]]&amp;nbsp;- 
[[Abaphasi]]&amp;nbsp;- 
[[Ikolo]]&amp;nbsp;- 
[[Ibhayibhili]]&amp;nbsp;
&lt;!----------------------------------------------&gt;
|- 
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Classroom icon.svg|40px|center]]
| style=&quot;font-size: 90%; border-top: 1px dashed #AAAAAA;&quot; | '''Abatloli Besindebele'''&lt;br/&gt;
[[Alexander Mthombeni|A.B. Mthombeni]]&amp;nbsp;- 
[[Moses Mahlangu|M.S. Mahlangu]]&amp;nbsp;-
[[PB Skhosana|P.B. Skhosana]]&amp;nbsp;- 
[[Bhiza Masango|B.D Masango]]&amp;nbsp;-
[[Themba Mnguni|T.G Mnguni]]&amp;nbsp;- 
[[Mgiyelwa Ntuli|M.S Ntuli]]&amp;nbsp;
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Gnome-globe.svg|40px|center]]
| style=&quot;font-size: 90%; border-top: 1px dashed #AAAAAA;&quot; | '''Iinarha zephasi'''&lt;br/&gt;
[[Isewula Afrika]]&amp;nbsp;- 
[[Iamarika]]&amp;nbsp;-
[[Angola]]&amp;nbsp;-  
[[Botswana]]&amp;nbsp;- 
[[Burkina Faso]]&amp;nbsp;-   
[[Cameroon]]&amp;nbsp;- 
[[Egypt]]&amp;nbsp;- 
[[Ethiopia]]&amp;nbsp;- 
[[Ghana]]&amp;nbsp;- 
[[Japane]]&amp;nbsp;-
[[Kenya]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Madagascar]]&amp;nbsp;- 
[[Malawi]]&amp;nbsp;- 
[[Mali]]&amp;nbsp;- 
[[Mauritius]]&amp;nbsp;-  
[[Morocco]]&amp;nbsp;-  
[[Mozambique]]&amp;nbsp;-
[[Namibia]]&amp;nbsp;-  
[[Niger]]&amp;nbsp;- 
[[Rwanda]]&amp;nbsp;- 
[[Senegal]]&amp;nbsp;- 
[[Sierra Leone]]&amp;nbsp;- 
[[Somalia]]&amp;nbsp;- 
[[Swaziland]]&amp;nbsp;- 
[[Tanzania]]&amp;nbsp;-
[[Tshayina]]&amp;nbsp;-  
[[Tunisia]]&amp;nbsp;- 
[[Zambia]]&amp;nbsp;- 
[[Zimbabwe]]&amp;nbsp;
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Nuvola apps kuser.svg|40px|center]]
| style=&quot;font-size: 90%; border-top: 1px dashed #AAAAAA;&quot; | '''Ubuhlobo'''&lt;br/&gt;
[[Umndeni]]&amp;nbsp;-
[[Ababelethi]]&amp;nbsp;-
[[Umntwana]]&amp;nbsp;-
[[Umtjhado]]&amp;nbsp;-
[[Umrazana]]&amp;nbsp;-
[[Isokana]]&amp;nbsp;-
[[Ukhwenyana]]&amp;nbsp;-
[[Umakoti]]&amp;nbsp;-
[[Ilobolo]]&amp;nbsp;-
[[Iindakamizwa]]&amp;nbsp;
|}</text>
      <sha1>nqdsloel5exl6unh54mpw4pvsdxixr5</sha1>
    </revision>
    <revision>
      <id>2957</id>
      <parentid>1125</parentid>
      <timestamp>2025-06-06T18:55:49Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>ghjhtgrfed</comment>
      <origin>2957</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1175" sha1="1fwga1i685jullatejdnaoi6whb23ia" xml:space="preserve">&lt;!----------------------------------------------&gt;
&lt;!----------------------------------------------&gt;&lt;!----------------------------------------------&gt;
&lt;!----------------------------------------------&gt;
&lt;!----------------------------------------------&gt;'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.''' '''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. [[L|L imagine having no admin]]''' 

== [[A Minecraft Movie|Flint and Steel, Chicken Jockey, I am Steve]] ==</text>
      <sha1>1fwga1i685jullatejdnaoi6whb23ia</sha1>
    </revision>
    <revision>
      <id>3088</id>
      <parentid>2957</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Jon Harald Søby|Jon Harald Søby]]</comment>
      <origin>1124</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2922" sha1="nqdsloel5exl6unh54mpw4pvsdxixr5" xml:space="preserve">{| cellpadding=&quot;5&quot; cellspacing=&quot;4&quot; style=&quot;width:100%; border:2px ;&quot;  
|-----
|colspan=&quot;6&quot; align=&quot;center&quot; bgcolor=&quot;white&quot; |

{| width=&quot;100%&quot;  border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;5&quot;
|- 
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Nuvola apps bookcase.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 90%; &quot; |  '''Imitlolo ngesindebele'''&lt;br/&gt; 
[[Isindebele]]&amp;nbsp;-
[[Umlando waMandebele]]&amp;nbsp;-
[[Amalungelo Wobuntu]]&amp;nbsp;- 
[[umThethosisekelo]]&amp;nbsp;-
[[Ezepilo]]&amp;nbsp;-
[[Ifundo]]&amp;nbsp;-
[[Amatshwayo eSewula Africa]]&amp;nbsp;-
[[Iflaga yeSewula Africa]]&amp;nbsp;-
[[UmSebenzi WesiTjhaba WezamaLimi]]&amp;nbsp;-
[[Iinomboro]]&amp;nbsp;-
[[Iinyanga]]&amp;nbsp;-
[[AmaKghono wePilo]]&amp;nbsp;-
[[Ikrismesi]]&amp;nbsp;-
[[Ubulwelwe be-Ebola]]&amp;nbsp;
[[Onzima]]&amp;nbsp;- 
[[Omhlophe]]&amp;nbsp;-
[[Obovu]]&amp;nbsp;
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:P_religion_world.svg|40px|center]]
| style=&quot;font-size: 90%; border-top: 1px dashed #AAAAAA;&quot; | '''Ikolo'''&lt;br/&gt;
[[Uzimu]]&amp;nbsp;- 
[[Ubukresite]]&amp;nbsp;- 
[[Abaphasi]]&amp;nbsp;- 
[[Ikolo]]&amp;nbsp;- 
[[Ibhayibhili]]&amp;nbsp;
&lt;!----------------------------------------------&gt;
|- 
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Classroom icon.svg|40px|center]]
| style=&quot;font-size: 90%; border-top: 1px dashed #AAAAAA;&quot; | '''Abatloli Besindebele'''&lt;br/&gt;
[[Alexander Mthombeni|A.B. Mthombeni]]&amp;nbsp;- 
[[Moses Mahlangu|M.S. Mahlangu]]&amp;nbsp;-
[[PB Skhosana|P.B. Skhosana]]&amp;nbsp;- 
[[Bhiza Masango|B.D Masango]]&amp;nbsp;-
[[Themba Mnguni|T.G Mnguni]]&amp;nbsp;- 
[[Mgiyelwa Ntuli|M.S Ntuli]]&amp;nbsp;
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Gnome-globe.svg|40px|center]]
| style=&quot;font-size: 90%; border-top: 1px dashed #AAAAAA;&quot; | '''Iinarha zephasi'''&lt;br/&gt;
[[Isewula Afrika]]&amp;nbsp;- 
[[Iamarika]]&amp;nbsp;-
[[Angola]]&amp;nbsp;-  
[[Botswana]]&amp;nbsp;- 
[[Burkina Faso]]&amp;nbsp;-   
[[Cameroon]]&amp;nbsp;- 
[[Egypt]]&amp;nbsp;- 
[[Ethiopia]]&amp;nbsp;- 
[[Ghana]]&amp;nbsp;- 
[[Japane]]&amp;nbsp;-
[[Kenya]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Madagascar]]&amp;nbsp;- 
[[Malawi]]&amp;nbsp;- 
[[Mali]]&amp;nbsp;- 
[[Mauritius]]&amp;nbsp;-  
[[Morocco]]&amp;nbsp;-  
[[Mozambique]]&amp;nbsp;-
[[Namibia]]&amp;nbsp;-  
[[Niger]]&amp;nbsp;- 
[[Rwanda]]&amp;nbsp;- 
[[Senegal]]&amp;nbsp;- 
[[Sierra Leone]]&amp;nbsp;- 
[[Somalia]]&amp;nbsp;- 
[[Swaziland]]&amp;nbsp;- 
[[Tanzania]]&amp;nbsp;-
[[Tshayina]]&amp;nbsp;-  
[[Tunisia]]&amp;nbsp;- 
[[Zambia]]&amp;nbsp;- 
[[Zimbabwe]]&amp;nbsp;
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Nuvola apps kuser.svg|40px|center]]
| style=&quot;font-size: 90%; border-top: 1px dashed #AAAAAA;&quot; | '''Ubuhlobo'''&lt;br/&gt;
[[Umndeni]]&amp;nbsp;-
[[Ababelethi]]&amp;nbsp;-
[[Umntwana]]&amp;nbsp;-
[[Umtjhado]]&amp;nbsp;-
[[Umrazana]]&amp;nbsp;-
[[Isokana]]&amp;nbsp;-
[[Ukhwenyana]]&amp;nbsp;-
[[Umakoti]]&amp;nbsp;-
[[Ilobolo]]&amp;nbsp;-
[[Iindakamizwa]]&amp;nbsp;
|}</text>
      <sha1>nqdsloel5exl6unh54mpw4pvsdxixr5</sha1>
    </revision>
    <revision>
      <id>3171</id>
      <parentid>3088</parentid>
      <timestamp>2025-06-21T18:45:36Z</timestamp>
      <contributor>
        <ip>85.97.84.231</ip>
      </contributor>
      <origin>3171</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3033" sha1="18kzlr9vrpovc9ycc27jqxu9ic21xwv" xml:space="preserve">[[File:Common chimpanzee (Pan troglodytes schweinfurthii) feeding.jpg|thumb|Omar al-Bashir is a chimpanzee.]]

{| cellpadding=&quot;5&quot; cellspacing=&quot;4&quot; style=&quot;width:100%; border:2px ;&quot;  
|-----
|colspan=&quot;6&quot; align=&quot;center&quot; bgcolor=&quot;white&quot; |

{| width=&quot;100%&quot;  border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;5&quot;
|- 
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Nuvola apps bookcase.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 90%; &quot; |  '''Imitlolo ngesindebele'''&lt;br/&gt; 
[[Isindebele]]&amp;nbsp;-
[[Umlando waMandebele]]&amp;nbsp;-
[[Amalungelo Wobuntu]]&amp;nbsp;- 
[[umThethosisekelo]]&amp;nbsp;-
[[Ezepilo]]&amp;nbsp;-
[[Ifundo]]&amp;nbsp;-
[[Amatshwayo eSewula Africa]]&amp;nbsp;-
[[Iflaga yeSewula Africa]]&amp;nbsp;-
[[UmSebenzi WesiTjhaba WezamaLimi]]&amp;nbsp;-
[[Iinomboro]]&amp;nbsp;-
[[Iinyanga]]&amp;nbsp;-
[[AmaKghono wePilo]]&amp;nbsp;-
[[Ikrismesi]]&amp;nbsp;-
[[Ubulwelwe be-Ebola]]&amp;nbsp;
[[Onzima]]&amp;nbsp;- 
[[Omhlophe]]&amp;nbsp;-
[[Obovu]]&amp;nbsp;
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:P_religion_world.svg|40px|center]]
| style=&quot;font-size: 90%; border-top: 1px dashed #AAAAAA;&quot; | '''Ikolo'''&lt;br/&gt;
[[Uzimu]]&amp;nbsp;- 
[[Ubukresite]]&amp;nbsp;- 
[[Abaphasi]]&amp;nbsp;- 
[[Ikolo]]&amp;nbsp;- 
[[Ibhayibhili]]&amp;nbsp;
&lt;!----------------------------------------------&gt;
|- 
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Classroom icon.svg|40px|center]]
| style=&quot;font-size: 90%; border-top: 1px dashed #AAAAAA;&quot; | '''Abatloli Besindebele'''&lt;br/&gt;
[[Alexander Mthombeni|A.B. Mthombeni]]&amp;nbsp;- 
[[Moses Mahlangu|M.S. Mahlangu]]&amp;nbsp;-
[[PB Skhosana|P.B. Skhosana]]&amp;nbsp;- 
[[Bhiza Masango|B.D Masango]]&amp;nbsp;-
[[Themba Mnguni|T.G Mnguni]]&amp;nbsp;- 
[[Mgiyelwa Ntuli|M.S Ntuli]]&amp;nbsp;
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Gnome-globe.svg|40px|center]]
| style=&quot;font-size: 90%; border-top: 1px dashed #AAAAAA;&quot; | '''Iinarha zephasi'''&lt;br/&gt;
[[Isewula Afrika]]&amp;nbsp;- 
[[Iamarika]]&amp;nbsp;-
[[Angola]]&amp;nbsp;-  
[[Botswana]]&amp;nbsp;- 
[[Burkina Faso]]&amp;nbsp;-   
[[Cameroon]]&amp;nbsp;- 
[[Egypt]]&amp;nbsp;- 
[[Ethiopia]]&amp;nbsp;- 
[[Ghana]]&amp;nbsp;- 
[[Japane]]&amp;nbsp;-
[[Kenya]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Madagascar]]&amp;nbsp;- 
[[Malawi]]&amp;nbsp;- 
[[Mali]]&amp;nbsp;- 
[[Mauritius]]&amp;nbsp;-  
[[Morocco]]&amp;nbsp;-  
[[Mozambique]]&amp;nbsp;-
[[Namibia]]&amp;nbsp;-  
[[Niger]]&amp;nbsp;- 
[[Rwanda]]&amp;nbsp;- 
[[Senegal]]&amp;nbsp;- 
[[Sierra Leone]]&amp;nbsp;- 
[[Somalia]]&amp;nbsp;- 
[[Swaziland]]&amp;nbsp;- 
[[Tanzania]]&amp;nbsp;-
[[Tshayina]]&amp;nbsp;-  
[[Tunisia]]&amp;nbsp;- 
[[Zambia]]&amp;nbsp;- 
[[Zimbabwe]]&amp;nbsp;
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Nuvola apps kuser.svg|40px|center]]
| style=&quot;font-size: 90%; border-top: 1px dashed #AAAAAA;&quot; | '''Ubuhlobo'''&lt;br/&gt;
[[Umndeni]]&amp;nbsp;-
[[Ababelethi]]&amp;nbsp;-
[[Umntwana]]&amp;nbsp;-
[[Umtjhado]]&amp;nbsp;-
[[Umrazana]]&amp;nbsp;-
[[Isokana]]&amp;nbsp;-
[[Ukhwenyana]]&amp;nbsp;-
[[Umakoti]]&amp;nbsp;-
[[Ilobolo]]&amp;nbsp;-
[[Iindakamizwa]]&amp;nbsp;
|}</text>
      <sha1>18kzlr9vrpovc9ycc27jqxu9ic21xwv</sha1>
    </revision>
    <revision>
      <id>3279</id>
      <parentid>3171</parentid>
      <timestamp>2025-07-02T20:14:17Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Undo revision [[Special:Diff/3171|3171]] by [[Special:Contributions/85.97.84.231|85.97.84.231]] ([[User talk:85.97.84.231|talk]])</comment>
      <origin>3279</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2922" sha1="nqdsloel5exl6unh54mpw4pvsdxixr5" xml:space="preserve">{| cellpadding=&quot;5&quot; cellspacing=&quot;4&quot; style=&quot;width:100%; border:2px ;&quot;  
|-----
|colspan=&quot;6&quot; align=&quot;center&quot; bgcolor=&quot;white&quot; |

{| width=&quot;100%&quot;  border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;5&quot;
|- 
&lt;!----------------------------------------------&gt;
| width=&quot;10%&quot; | [[Isimumathi:Nuvola apps bookcase.svg|40px|center]]
| width=&quot;90%&quot; style=&quot;font-size: 90%; &quot; |  '''Imitlolo ngesindebele'''&lt;br/&gt; 
[[Isindebele]]&amp;nbsp;-
[[Umlando waMandebele]]&amp;nbsp;-
[[Amalungelo Wobuntu]]&amp;nbsp;- 
[[umThethosisekelo]]&amp;nbsp;-
[[Ezepilo]]&amp;nbsp;-
[[Ifundo]]&amp;nbsp;-
[[Amatshwayo eSewula Africa]]&amp;nbsp;-
[[Iflaga yeSewula Africa]]&amp;nbsp;-
[[UmSebenzi WesiTjhaba WezamaLimi]]&amp;nbsp;-
[[Iinomboro]]&amp;nbsp;-
[[Iinyanga]]&amp;nbsp;-
[[AmaKghono wePilo]]&amp;nbsp;-
[[Ikrismesi]]&amp;nbsp;-
[[Ubulwelwe be-Ebola]]&amp;nbsp;
[[Onzima]]&amp;nbsp;- 
[[Omhlophe]]&amp;nbsp;-
[[Obovu]]&amp;nbsp;
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:P_religion_world.svg|40px|center]]
| style=&quot;font-size: 90%; border-top: 1px dashed #AAAAAA;&quot; | '''Ikolo'''&lt;br/&gt;
[[Uzimu]]&amp;nbsp;- 
[[Ubukresite]]&amp;nbsp;- 
[[Abaphasi]]&amp;nbsp;- 
[[Ikolo]]&amp;nbsp;- 
[[Ibhayibhili]]&amp;nbsp;
&lt;!----------------------------------------------&gt;
|- 
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Classroom icon.svg|40px|center]]
| style=&quot;font-size: 90%; border-top: 1px dashed #AAAAAA;&quot; | '''Abatloli Besindebele'''&lt;br/&gt;
[[Alexander Mthombeni|A.B. Mthombeni]]&amp;nbsp;- 
[[Moses Mahlangu|M.S. Mahlangu]]&amp;nbsp;-
[[PB Skhosana|P.B. Skhosana]]&amp;nbsp;- 
[[Bhiza Masango|B.D Masango]]&amp;nbsp;-
[[Themba Mnguni|T.G Mnguni]]&amp;nbsp;- 
[[Mgiyelwa Ntuli|M.S Ntuli]]&amp;nbsp;
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Gnome-globe.svg|40px|center]]
| style=&quot;font-size: 90%; border-top: 1px dashed #AAAAAA;&quot; | '''Iinarha zephasi'''&lt;br/&gt;
[[Isewula Afrika]]&amp;nbsp;- 
[[Iamarika]]&amp;nbsp;-
[[Angola]]&amp;nbsp;-  
[[Botswana]]&amp;nbsp;- 
[[Burkina Faso]]&amp;nbsp;-   
[[Cameroon]]&amp;nbsp;- 
[[Egypt]]&amp;nbsp;- 
[[Ethiopia]]&amp;nbsp;- 
[[Ghana]]&amp;nbsp;- 
[[Japane]]&amp;nbsp;-
[[Kenya]]&amp;nbsp;- 
[[Lesotho]]&amp;nbsp;- 
[[Madagascar]]&amp;nbsp;- 
[[Malawi]]&amp;nbsp;- 
[[Mali]]&amp;nbsp;- 
[[Mauritius]]&amp;nbsp;-  
[[Morocco]]&amp;nbsp;-  
[[Mozambique]]&amp;nbsp;-
[[Namibia]]&amp;nbsp;-  
[[Niger]]&amp;nbsp;- 
[[Rwanda]]&amp;nbsp;- 
[[Senegal]]&amp;nbsp;- 
[[Sierra Leone]]&amp;nbsp;- 
[[Somalia]]&amp;nbsp;- 
[[Swaziland]]&amp;nbsp;- 
[[Tanzania]]&amp;nbsp;-
[[Tshayina]]&amp;nbsp;-  
[[Tunisia]]&amp;nbsp;- 
[[Zambia]]&amp;nbsp;- 
[[Zimbabwe]]&amp;nbsp;
&lt;!----------------------------------------------&gt;
|-
&lt;!----------------------------------------------&gt;
| [[Isimumathi:Nuvola apps kuser.svg|40px|center]]
| style=&quot;font-size: 90%; border-top: 1px dashed #AAAAAA;&quot; | '''Ubuhlobo'''&lt;br/&gt;
[[Umndeni]]&amp;nbsp;-
[[Ababelethi]]&amp;nbsp;-
[[Umntwana]]&amp;nbsp;-
[[Umtjhado]]&amp;nbsp;-
[[Umrazana]]&amp;nbsp;-
[[Isokana]]&amp;nbsp;-
[[Ukhwenyana]]&amp;nbsp;-
[[Umakoti]]&amp;nbsp;-
[[Ilobolo]]&amp;nbsp;-
[[Iindakamizwa]]&amp;nbsp;
|}</text>
      <sha1>nqdsloel5exl6unh54mpw4pvsdxixr5</sha1>
    </revision>
  </page>
  <page>
    <title>Mantwani PrimarySchool</title>
    <ns>0</ns>
    <id>216</id>
    <revision>
      <id>1126</id>
      <timestamp>2024-03-08T13:11:22Z</timestamp>
      <contributor>
        <username>incubator&gt;Mbandeni</username>
        <id>0</id>
      </contributor>
      <comment>I created a page about Mantwani Primary School</comment>
      <origin>1126</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="52" sha1="h5wxkierusv3s1mudfjivd9v7148vnx" xml:space="preserve">Mantwani Primary School sisendaweni ye-Watervaal b

</text>
      <sha1>h5wxkierusv3s1mudfjivd9v7148vnx</sha1>
    </revision>
    <revision>
      <id>1127</id>
      <parentid>1126</parentid>
      <timestamp>2024-03-08T13:26:31Z</timestamp>
      <contributor>
        <username>incubator&gt;Mbandeni</username>
        <id>0</id>
      </contributor>
      <comment>Bold</comment>
      <origin>1127</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="389" sha1="lfi8206hu5krdf2koa9xguma9erpn6x" xml:space="preserve">'''I-''Mantwani Primary School''''', sikolo samazinga aphasi esisendaweni ye-Watervaal B eMpumalanga. Lesi sikolo sathiyelelwa ngo Mandwani ebekuyikosi ekhayibusa endaweni yange Watervaal ngaphambi kokubusa kuka-Mayitjha. Ngebanga lokobana uhlokokulu wokuthoma wesikolo khabe kuli-Pedi, uMandwani wamutjhugulula ngokungakwazi ukupeleda amagama wesiNdebele wasibiza ngokuthi yi-Mantwani. 

</text>
      <sha1>lfi8206hu5krdf2koa9xguma9erpn6x</sha1>
    </revision>
    <revision>
      <id>1128</id>
      <parentid>1127</parentid>
      <timestamp>2024-10-14T13:47:03Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>1127</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="389" sha1="lfi8206hu5krdf2koa9xguma9erpn6x" xml:space="preserve">'''I-''Mantwani Primary School''''', sikolo samazinga aphasi esisendaweni ye-Watervaal B eMpumalanga. Lesi sikolo sathiyelelwa ngo Mandwani ebekuyikosi ekhayibusa endaweni yange Watervaal ngaphambi kokubusa kuka-Mayitjha. Ngebanga lokobana uhlokokulu wokuthoma wesikolo khabe kuli-Pedi, uMandwani wamutjhugulula ngokungakwazi ukupeleda amagama wesiNdebele wasibiza ngokuthi yi-Mantwani. 

</text>
      <sha1>lfi8206hu5krdf2koa9xguma9erpn6x</sha1>
    </revision>
  </page>
  <page>
    <title>Maqhawe Mbalekwa Piet Ntuli</title>
    <ns>0</ns>
    <id>217</id>
    <revision>
      <id>1129</id>
      <timestamp>2024-03-09T07:55:32Z</timestamp>
      <contributor>
        <username>incubator&gt;Lihlentuli</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;Maqhawe Mbalekwa Piet Ntuli&quot;</comment>
      <origin>1129</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="27" sha1="j3gpckg6tapl5qwiwqc24ljo4uj8zjd" xml:space="preserve">Maqhawe Mbalekwa Piet Ntuli</text>
      <sha1>j3gpckg6tapl5qwiwqc24ljo4uj8zjd</sha1>
    </revision>
    <revision>
      <id>1130</id>
      <parentid>1129</parentid>
      <timestamp>2024-03-09T08:30:14Z</timestamp>
      <contributor>
        <username>incubator&gt;Lihlentuli</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>edited how Maqhawe Piet Ntuli died</comment>
      <origin>1130</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="436" sha1="t6bhs52bbnyd3nuanik7o8f6o1287lp" xml:space="preserve">'''&lt;big&gt;Maqhawe Mbalekwa Piet Ntuli&lt;/big&gt;''' 

'''Maqhawe Mbalekwa Piet Ntuli''' wayengu Minister wombuzo waphambilini wakwaNdebele, owahlongakala ngemva kokuthi ikoloyi yakhe ifakwe iinthuthumbisi e Siyabuswa, Kwandebele ngo mhlaka 29 kuVelabahlinze 1986.  Abanqondo nqondo benthuthumbisi ezathuthumbisa ikoloyi ka Mnumzane u Maqhawe kwaye kumasotja akhethekileko kanye nehlangano eyayiphethe i SANDF nabo nogada abasebenzisana ne SAP.</text>
      <sha1>t6bhs52bbnyd3nuanik7o8f6o1287lp</sha1>
    </revision>
    <revision>
      <id>1131</id>
      <parentid>1130</parentid>
      <timestamp>2024-03-09T09:44:34Z</timestamp>
      <contributor>
        <username>incubator&gt;Lihlentuli</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>created a link</comment>
      <origin>1131</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="490" sha1="igjpwg5khckperpsfzjq2qf4yymlpxy" xml:space="preserve">'''&lt;big&gt;Maqhawe Mbalekwa Piet Ntuli&lt;/big&gt;''' 

'''Maqhawe Mbalekwa Piet Ntuli''' wayengu Minister wombuzo waphambilini wakwaNdebele, owahlongakala ngemva kokuthi ikoloyi yakhe ifakwe iinthuthumbisi e Siyabuswa, Kwandebele ngo mhlaka 29 kuVelabahlinze 1986.  Abanqondo nqondo benthuthumbisi ezathuthumbisa ikoloyi ka Mnumzane u Maqhawe kwaye kumasotja akhethekileko kanye nehlangano eyayiphethe i SANDF nabo nogada abasebenzisana ne SAP ([[:en:South_African_Police|South African Police]]).

</text>
      <sha1>igjpwg5khckperpsfzjq2qf4yymlpxy</sha1>
    </revision>
    <revision>
      <id>1132</id>
      <parentid>1131</parentid>
      <timestamp>2024-03-09T09:46:28Z</timestamp>
      <contributor>
        <username>incubator&gt;Lihlentuli</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>created a link</comment>
      <origin>1132</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="531" sha1="dkq16xnvvyfh2jydppnmwlmt398qgi1" xml:space="preserve">'''&lt;big&gt;[http://www.army.mil.za/Pages/Home.aspx Maqhawe] Mbalekwa Piet Ntuli&lt;/big&gt;''' 

'''Maqhawe Mbalekwa Piet Ntuli''' wayengu Minister wombuzo waphambilini wakwaNdebele, owahlongakala ngemva kokuthi ikoloyi yakhe ifakwe iinthuthumbisi e Siyabuswa, Kwandebele ngo mhlaka 29 kuVelabahlinze 1986.  Abanqondo nqondo benthuthumbisi ezathuthumbisa ikoloyi ka Mnumzane u Maqhawe kwaye kumasotja akhethekileko kanye nehlangano eyayiphethe i SANDF nabo nogada abasebenzisana ne SAP ([[:en:South_African_Police|South African Police]]).

</text>
      <sha1>dkq16xnvvyfh2jydppnmwlmt398qgi1</sha1>
    </revision>
    <revision>
      <id>1133</id>
      <parentid>1132</parentid>
      <timestamp>2024-03-09T09:50:19Z</timestamp>
      <contributor>
        <username>incubator&gt;Lihlentuli</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>corrections on heading</comment>
      <origin>1133</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="491" sha1="cntjh4o3395ahmwketokx0aheiomg4o" xml:space="preserve">'''&lt;big&gt;Maqhawe Mbalekwa Piet Ntuli&lt;/big&gt;'''  

'''Maqhawe Mbalekwa Piet Ntuli''' wayengu Minister wombuzo waphambilini wakwaNdebele, owahlongakala ngemva kokuthi ikoloyi yakhe ifakwe iinthuthumbisi e Siyabuswa, Kwandebele ngo mhlaka 29 kuVelabahlinze 1986.  Abanqondo nqondo benthuthumbisi ezathuthumbisa ikoloyi ka Mnumzane u Maqhawe kwaye kumasotja akhethekileko kanye nehlangano eyayiphethe i SANDF nabo nogada abasebenzisana ne SAP ([[:en:South_African_Police|South African Police]]).

</text>
      <sha1>cntjh4o3395ahmwketokx0aheiomg4o</sha1>
    </revision>
    <revision>
      <id>1134</id>
      <parentid>1133</parentid>
      <timestamp>2024-03-09T09:51:36Z</timestamp>
      <contributor>
        <username>incubator&gt;Lihlentuli</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>created a link</comment>
      <origin>1134</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="533" sha1="l9bvgv7k1ebb07p1qvh0c3buwj8jbyh" xml:space="preserve">'''&lt;big&gt;Maqhawe Mbalekwa Piet Ntuli&lt;/big&gt;'''  

'''Maqhawe Mbalekwa Piet Ntuli''' wayengu Minister wombuzo waphambilini wakwaNdebele, owahlongakala ngemva kokuthi ikoloyi yakhe ifakwe iinthuthumbisi e Siyabuswa, Kwandebele ngo mhlaka 29 kuVelabahlinze 1986.  Abanqondo nqondo benthuthumbisi ezathuthumbisa ikoloyi ka Mnumzane u Maqhawe kwaye kumasotja akhethekileko kanye nehlangano eyayiphethe yi [http://www.army.mil.za/Pages/Home.aspx SANDF] nabo nogada abasebenzisana ne SAP ([[:en:South_African_Police|South African Police]]).

</text>
      <sha1>l9bvgv7k1ebb07p1qvh0c3buwj8jbyh</sha1>
    </revision>
    <revision>
      <id>1135</id>
      <parentid>1134</parentid>
      <timestamp>2024-03-09T09:52:56Z</timestamp>
      <contributor>
        <username>incubator&gt;Lihlentuli</username>
        <id>0</id>
      </contributor>
      <comment>created a link</comment>
      <origin>1135</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="552" sha1="1fdczl150j81fsxdftmow09cxfm1yc4" xml:space="preserve">'''&lt;big&gt;Maqhawe Mbalekwa Piet Ntuli&lt;/big&gt;'''  

'''Maqhawe Mbalekwa Piet Ntuli''' wayengu Minister wombuzo waphambilini wa[[:en:KwaNdebele|kwaNdebele]], owahlongakala ngemva kokuthi ikoloyi yakhe ifakwe iinthuthumbisi e Siyabuswa, Kwandebele ngo mhlaka 29 kuVelabahlinze 1986.  Abanqondo nqondo benthuthumbisi ezathuthumbisa ikoloyi ka Mnumzane u Maqhawe kwaye kumasotja akhethekileko kanye nehlangano eyayiphethe yi [http://www.army.mil.za/Pages/Home.aspx SANDF] nabo nogada abasebenzisana ne SAP ([[:en:South_African_Police|South African Police]]).

</text>
      <sha1>1fdczl150j81fsxdftmow09cxfm1yc4</sha1>
    </revision>
    <revision>
      <id>1136</id>
      <parentid>1135</parentid>
      <timestamp>2024-03-09T10:16:38Z</timestamp>
      <contributor>
        <username>incubator&gt;Lihlentuli</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Added a picture</comment>
      <origin>1136</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="671" sha1="aslna11zi0n1i3znxgaqncu9vt7fgy3" xml:space="preserve">[[Isimumathi:Piet Mbalekwa Maqhawe Ntuli.jpg|alt=Piet Mbalekwa Maqhawe Ntuli (Minister of Kwandebele Homeland)|thumb]]
'''&lt;big&gt;Maqhawe Mbalekwa Piet Ntuli&lt;/big&gt;'''  

'''Maqhawe Mbalekwa Piet Ntuli''' wayengu Minister wombuzo waphambilini wa[[:en:KwaNdebele|kwaNdebele]], owahlongakala ngemva kokuthi ikoloyi yakhe ifakwe iinthuthumbisi e Siyabuswa, Kwandebele ngo mhlaka 29 kuVelabahlinze 1986.  Abanqondo nqondo benthuthumbisi ezathuthumbisa ikoloyi ka Mnumzane u Maqhawe kwaye kumasotja akhethekileko kanye nehlangano eyayiphethe yi [http://www.army.mil.za/Pages/Home.aspx SANDF] nabo nogada abasebenzisana ne SAP ([[:en:South_African_Police|South African Police]]).

</text>
      <sha1>aslna11zi0n1i3znxgaqncu9vt7fgy3</sha1>
    </revision>
    <revision>
      <id>1137</id>
      <parentid>1136</parentid>
      <timestamp>2024-03-28T10:30:52Z</timestamp>
      <contributor>
        <username>incubator&gt;InternetArchiveBot</username>
        <id>0</id>
      </contributor>
      <comment>Rescuing 1 sources and tagging 0 as dead.) #IABot (v2.0.9.5</comment>
      <origin>1137</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="714" sha1="jfo7qrha1bz1d26pnmx9bzih3owopfx" xml:space="preserve">[[Isimumathi:Piet Mbalekwa Maqhawe Ntuli.jpg|alt=Piet Mbalekwa Maqhawe Ntuli (Minister of Kwandebele Homeland)|thumb]]
'''&lt;big&gt;Maqhawe Mbalekwa Piet Ntuli&lt;/big&gt;'''  

'''Maqhawe Mbalekwa Piet Ntuli''' wayengu Minister wombuzo waphambilini wa[[:en:KwaNdebele|kwaNdebele]], owahlongakala ngemva kokuthi ikoloyi yakhe ifakwe iinthuthumbisi e Siyabuswa, Kwandebele ngo mhlaka 29 kuVelabahlinze 1986.  Abanqondo nqondo benthuthumbisi ezathuthumbisa ikoloyi ka Mnumzane u Maqhawe kwaye kumasotja akhethekileko kanye nehlangano eyayiphethe yi [https://web.archive.org/web/20240308152659/http://www.army.mil.za/Pages/Home.aspx SANDF] nabo nogada abasebenzisana ne SAP ([[:en:South_African_Police|South African Police]]).

</text>
      <sha1>jfo7qrha1bz1d26pnmx9bzih3owopfx</sha1>
    </revision>
    <revision>
      <id>1138</id>
      <parentid>1137</parentid>
      <timestamp>2024-10-14T13:47:04Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>9 revisions imported</comment>
      <origin>1137</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="714" sha1="jfo7qrha1bz1d26pnmx9bzih3owopfx" xml:space="preserve">[[Isimumathi:Piet Mbalekwa Maqhawe Ntuli.jpg|alt=Piet Mbalekwa Maqhawe Ntuli (Minister of Kwandebele Homeland)|thumb]]
'''&lt;big&gt;Maqhawe Mbalekwa Piet Ntuli&lt;/big&gt;'''  

'''Maqhawe Mbalekwa Piet Ntuli''' wayengu Minister wombuzo waphambilini wa[[:en:KwaNdebele|kwaNdebele]], owahlongakala ngemva kokuthi ikoloyi yakhe ifakwe iinthuthumbisi e Siyabuswa, Kwandebele ngo mhlaka 29 kuVelabahlinze 1986.  Abanqondo nqondo benthuthumbisi ezathuthumbisa ikoloyi ka Mnumzane u Maqhawe kwaye kumasotja akhethekileko kanye nehlangano eyayiphethe yi [https://web.archive.org/web/20240308152659/http://www.army.mil.za/Pages/Home.aspx SANDF] nabo nogada abasebenzisana ne SAP ([[:en:South_African_Police|South African Police]]).

</text>
      <sha1>jfo7qrha1bz1d26pnmx9bzih3owopfx</sha1>
    </revision>
  </page>
  <page>
    <title>Mark Tovey</title>
    <ns>0</ns>
    <id>218</id>
    <revision>
      <id>1139</id>
      <timestamp>2024-05-22T19:00:35Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''UMark Tovey''' (owazalwa ngo-7 Meyi 1955) [1] ungumdlali webhola lezinyawo wase[[Isewula Afrika|Sewula Afrika]] osethathe umhlalaphansi. Umfowabo wayengumdlali webhola uNeil Tovey.&quot;</comment>
      <origin>1139</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="183" sha1="8atbngl1sijs4ad2t23y7kvr8sqwnlc" xml:space="preserve">'''UMark Tovey''' (owazalwa ngo-7 Meyi 1955) [1] ungumdlali webhola lezinyawo wase[[Isewula Afrika|Sewula Afrika]] osethathe umhlalaphansi. Umfowabo wayengumdlali webhola uNeil Tovey.</text>
      <sha1>8atbngl1sijs4ad2t23y7kvr8sqwnlc</sha1>
    </revision>
    <revision>
      <id>1140</id>
      <parentid>1139</parentid>
      <timestamp>2024-05-22T19:01:02Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1140</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="187" sha1="q9fx4yahm7ubcq865ih79d3jl9joduy" xml:space="preserve">'''UMark Tovey''' (owazalwa ngo-7 Meyi 1955) [1] ungumdlali webhola lezinyawo wase[[Isewula Afrika|Sewula Afrika]] osethathe umhlalaphansi. Umfowabo wayengumdlali webhola u[[Neil Tovey]].</text>
      <sha1>q9fx4yahm7ubcq865ih79d3jl9joduy</sha1>
    </revision>
    <revision>
      <id>1141</id>
      <parentid>1140</parentid>
      <timestamp>2024-10-14T13:47:04Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>1140</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="187" sha1="q9fx4yahm7ubcq865ih79d3jl9joduy" xml:space="preserve">'''UMark Tovey''' (owazalwa ngo-7 Meyi 1955) [1] ungumdlali webhola lezinyawo wase[[Isewula Afrika|Sewula Afrika]] osethathe umhlalaphansi. Umfowabo wayengumdlali webhola u[[Neil Tovey]].</text>
      <sha1>q9fx4yahm7ubcq865ih79d3jl9joduy</sha1>
    </revision>
  </page>
  <page>
    <title>Mbazima Shilowa</title>
    <ns>0</ns>
    <id>219</id>
    <revision>
      <id>1142</id>
      <timestamp>2024-03-15T19:19:55Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Created a new article.</comment>
      <origin>1142</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="72" sha1="ajbbim30t0yx5cj9t2wymbx5aye8vvd" xml:space="preserve">'''Mbazima Shilowa''' ungusopolitiki wecembu le COPE wase Sewula Afrika.</text>
      <sha1>ajbbim30t0yx5cj9t2wymbx5aye8vvd</sha1>
    </revision>
    <revision>
      <id>1143</id>
      <parentid>1142</parentid>
      <timestamp>2024-04-07T21:10:20Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1143</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="293" sha1="7fh47zci1v3a8f65hkwva67cd9jiy1q" xml:space="preserve">'''Mbazima Shilowa''' ungngomunye wabahlali beSewula Afrika okhewaba ngu phrimiya wesifunda se Gauteng eminyakeni eyadlulako. ungusopolitiki ebeka dosa phambili is ihlangano the COPE kodwana ngesibanga sokuthi ihlangano le beyinganabo abalandeli abanengi wagcina sele alandela ihlangano ye-DA.</text>
      <sha1>7fh47zci1v3a8f65hkwva67cd9jiy1q</sha1>
    </revision>
    <revision>
      <id>1144</id>
      <parentid>1143</parentid>
      <timestamp>2024-10-14T13:47:04Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>1143</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="293" sha1="7fh47zci1v3a8f65hkwva67cd9jiy1q" xml:space="preserve">'''Mbazima Shilowa''' ungngomunye wabahlali beSewula Afrika okhewaba ngu phrimiya wesifunda se Gauteng eminyakeni eyadlulako. ungusopolitiki ebeka dosa phambili is ihlangano the COPE kodwana ngesibanga sokuthi ihlangano le beyinganabo abalandeli abanengi wagcina sele alandela ihlangano ye-DA.</text>
      <sha1>7fh47zci1v3a8f65hkwva67cd9jiy1q</sha1>
    </revision>
  </page>
  <page>
    <title>Mgiyelwa Ntuli</title>
    <ns>0</ns>
    <id>220</id>
    <revision>
      <id>1145</id>
      <timestamp>2016-02-23T13:12:55Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;{{Person| | ibizo = Mgiyelwa Simon Ntuli | isithombe = Mgiyelwa Simon Ntuli.PNG | umsebenzi = Umtloli | ubelethwe ngo = 08 Arhostosi 1949 | indawo yo kubelethwa = Nompek...&quot;</comment>
      <origin>1145</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1860" sha1="6gp0mh72qbm8u5xitjkbij74v9r1wrz" xml:space="preserve">{{Person|
| ibizo = Mgiyelwa Simon Ntuli
| isithombe = Mgiyelwa Simon Ntuli.PNG
| umsebenzi = Umtloli
| ubelethwe ngo = 08 Arhostosi 1949
| indawo yo kubelethwa = Nompeketswana, Ekungwini
| wahlongakala ngo = 
| indawo yo hlongakala = 
}}
'''Mgiyelwa Simon Ntuli''' ngumtloli odumileko wobukondlo besindebele begodu wabelethwangomhlaka 08 Arhostosi 1949, koNompeketswana, esiphandenisekungwini (Bronkhorstspruit). 

==Ifundo==
Wathoma ukufunda esikolweni samaRoma, eSdudu (Eastwood), ePitori l, (City of Tshwane) Emvakwalapo wangena eenkolweni ezincani ezilandelako:
* Kgoro Bantu School, eKungwini
* Serenity Bantu School, eRayton.
Waphumelela ibanga lesithandathu eSedibeng State School, eCullinan.Ifundo ephakamileko wayifumana eBoekenhoutfontein Secondary School, eMabopane. Waphetha
ibanga lesumi eMamelodi High School, eMamelodi. Ubutitjhere wabufundele eRehlahliwe Teacher Training College, waqedaiPrimary Teachers Certicatengo – 1974. Kusukela
lapho wafunda iimfundo zakhe asekhaya asebenza wafumana iziqu sakhe ngendlela elandelako:

# MA: University of Witwatersrand-eJohannesburd.
# BA(Hons): University of Pretoria.
# BA: University of South Africa, ePretoria.
# FDE: Rand Afrikaans Universiteit, eJohannesburg.

==Ubutloli==
Wathoma ukutlola iincwadi ngerherho leTsengo. Kwagadangiswa iTsengo lokuthoma ngonyaka ka 1991, kwaphethangetsengo, ngonyaka ka – 1995. Umncopho weTsengo kufundisa abafundi uthabela ubukondlo ne enkondlo begodu nokulandelako:

* Ukwazi ubonga.
* Ukulimuka amatshayo wobukondlo.
* Ukukghona ukutlhama linkondlo.
* Ukutsenga iinkondlo.
* Ukuragela phambili ngezesikolo bukondlo begudu nesikolo bukondlo epilweni.

Amabanga la anembakhona ekuthini irherho leTsengo lijamele ukusiza abafundi ukwazi ngezobukondlo ne enkondlo. Bamalimi amanye nabo bangasizeka kwamambala. Ngetsengo batsengeke ngelimuko lobukondlo.

==Ref==</text>
      <sha1>6gp0mh72qbm8u5xitjkbij74v9r1wrz</sha1>
    </revision>
    <revision>
      <id>1146</id>
      <parentid>1145</parentid>
      <timestamp>2016-02-23T13:15:22Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1146</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1863" sha1="ohc7g71nqf1usr9fg3fzxlyu5f70kwh" xml:space="preserve">{{Person|
| ibizo = Mgiyelwa Simon Ntuli
| isithombe = Mgiyelwa Simon Ntuli.PNG
| umsebenzi = Umtloli
| ubelethwe ngo = 08 Arhostosi 1949
| indawo yo kubelethwa = Nompeketswana, Ekungwini
| wahlongakala ngo = 
| indawo yo hlongakala = 
}}
'''Mgiyelwa Simon Ntuli''' ngumtloli odumileko wobukondlo besindebele begodu wabelethwangomhlaka 08 Arhostosi 1949, koNompeketswana, esiphandenisekungwini (Bronkhorstspruit). 

==Ifundo==
Wathoma ukufunda esikolweni samaRoma, eSdudu (Eastwood), ePitori l, (City of Tshwane) Emvakwalapo wangena eenkolweni ezincani ezilandelako:
* Kgoro Bantu School, eKungwini
* Serenity Bantu School, eRayton.
Waphumelela ibanga lesithandathu eSedibeng State School, eCullinan.Ifundo ephakamileko wayifumana eBoekenhoutfontein Secondary School, eMabopane. Waphetha
ibanga lesumi eMamelodi High School, eMamelodi. Ubutitjhere wabufundele eRehlahliwe Teacher Training College, waqedaiPrimary Teachers Certicatengo – 1974. Kusukela
lapho wafunda iimfundo zakhe asekhaya asebenza wafumana iziqu sakhe ngendlela elandelako:

# MA: University of Witwatersrand-eJohannesburd.
# BA(Hons): University of Pretoria.
# BA: University of South Africa, ePretoria.
# FDE: Rand Afrikaans Universiteit, eJohannesburg.

==Ubutloli==
Wathoma ukutlola iincwadi ngerherho leTsengo. Kwagadangiswa iTsengo lokuthoma ngonyaka ka 1991, kwaphethangetsengo, ngonyaka ka – 1995. Umncopho weTsengo kufundisa abafundi uthabela ubukondlo ne enkondlo begodu nokulandelako:

* Ukwazi ubonga.
* Ukulimuka amatshayo wobukondlo.
* Ukukghona ukutlhama linkondlo.
* Ukutsenga iinkondlo.
* Ukuragela phambili ngezesikolo bukondlo begudu nesikolo bukondlo epilweni.

Amabanga la anembakhona ekuthini irherho leTsengo lijamele ukusiza abafundi ukwazi ngezobukondlo ne enkondlo. Bamalimi amanye nabo bangasizeka kwamambala. Ngetsengo batsengeke ngelimuko lobukondlo.

==Ref==


</text>
      <sha1>ohc7g71nqf1usr9fg3fzxlyu5f70kwh</sha1>
    </revision>
    <revision>
      <id>1147</id>
      <parentid>1146</parentid>
      <timestamp>2016-02-23T13:19:26Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1147</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1864" sha1="3r6g2jlh709r3sah8ko742g9cnod85o" xml:space="preserve">{{Person|
| ibizo = Mgiyelwa Simon Ntuli
| isithombe = Mgiyelwa Simon Ntuli.PNG
| umsebenzi = Umtloli
| ubelethwe ngo = 08 Arhostosi 1949
| indawo yo kubelethwa = Nompeketswana, Ekungwini
| wahlongakala ngo = 
| indawo yo hlongakala = 
}}
'''Mgiyelwa Simon Ntuli''' ngumtloli odumileko wobukondlo besindebele begodu wabelethwangomhlaka 08 Arhostosi 1949, koNompeketswana, esiphandeni sekungwini (Bronkhorstspruit). 

==Ifundo==
Wathoma ukufunda esikolweni samaRoma, eSdudu (Eastwood), ePitori l, (City of Tshwane) Emvakwalapo wangena eenkolweni ezincani ezilandelako:
* Kgoro Bantu School, eKungwini
* Serenity Bantu School, eRayton.
Waphumelela ibanga lesithandathu eSedibeng State School, eCullinan.Ifundo ephakamileko wayifumana eBoekenhoutfontein Secondary School, eMabopane. Waphetha
ibanga lesumi eMamelodi High School, eMamelodi. Ubutitjhere wabufundele eRehlahliwe Teacher Training College, waqedaiPrimary Teachers Certicatengo – 1974. Kusukela
lapho wafunda iimfundo zakhe asekhaya asebenza wafumana iziqu sakhe ngendlela elandelako:

# MA: University of Witwatersrand-eJohannesburd.
# BA(Hons): University of Pretoria.
# BA: University of South Africa, ePretoria.
# FDE: Rand Afrikaans Universiteit, eJohannesburg.

==Ubutloli==
Wathoma ukutlola iincwadi ngerherho leTsengo. Kwagadangiswa iTsengo lokuthoma ngonyaka ka 1991, kwaphethangetsengo, ngonyaka ka – 1995. Umncopho weTsengo kufundisa abafundi uthabela ubukondlo ne enkondlo begodu nokulandelako:

* Ukwazi ubonga.
* Ukulimuka amatshayo wobukondlo.
* Ukukghona ukutlhama linkondlo.
* Ukutsenga iinkondlo.
* Ukuragela phambili ngezesikolo bukondlo begudu nesikolo bukondlo epilweni.

Amabanga la anembakhona ekuthini irherho leTsengo lijamele ukusiza abafundi ukwazi ngezobukondlo ne enkondlo. Bamalimi amanye nabo bangasizeka kwamambala. Ngetsengo batsengeke ngelimuko lobukondlo.

==Ref==


</text>
      <sha1>3r6g2jlh709r3sah8ko742g9cnod85o</sha1>
    </revision>
    <revision>
      <id>1148</id>
      <parentid>1147</parentid>
      <timestamp>2016-02-23T14:13:03Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1148</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2634" sha1="io4et5s1pklokezshduu4sass049fou" xml:space="preserve">{{Person|
| ibizo = Mgiyelwa Simon Ntuli
| isithombe = Mgiyelwa Simon Ntuli.PNG
| umsebenzi = Umtloli
| ubelethwe ngo = 08 Arhostosi 1949
| indawo yo kubelethwa = Nompeketswana, Ekungwini
| wahlongakala ngo = 
| indawo yo hlongakala = 
}}
'''Mgiyelwa Simon Ntuli''' ngumtloli odumileko wobukondlo besindebele begodu wabelethwangomhlaka 08 Arhostosi 1949, koNompeketswana, esiphandeni sekungwini (Bronkhorstspruit).{{cite web|title=Preserving and Celebrating our literary heritage|url=http://www.nlsa.ac.za/downloads/CFB/Reprint%20of%20Classics%20Project/2012_Reprints_Classics.pdf|work=National Library of South Africa|accessdate=22 February 2016|date=March 2011}}&lt;/ref&gt;

 

==Ifundo==
Wathoma ukufunda esikolweni samaRoma, eSdudu (Eastwood), ePitori l, (City of Tshwane) Emvakwalapo wangena eenkolweni ezincani ezilandelako:
* Kgoro Bantu School, eKungwini
* Serenity Bantu School, eRayton.
Waphumelela ibanga lesithandathu eSedibeng State School, eCullinan.Ifundo ephakamileko wayifumana eBoekenhoutfontein Secondary School, eMabopane. Waphetha
ibanga lesumi eMamelodi High School, eMamelodi. Ubutitjhere wabufundele eRehlahliwe Teacher Training College, waqedaiPrimary Teachers Certicatengo – 1974{{cite web|title=Preserving and Celebrating our literary heritage|url=http://www.nlsa.ac.za/downloads/CFB/Reprint%20of%20Classics%20Project/2012_Reprints_Classics.pdf|work=National Library of South Africa|accessdate=22 February 2016|date=March 2011}}&lt;/ref&gt;. Kusukela
lapho wafunda iimfundo zakhe asekhaya asebenza wafumana iziqu sakhe ngendlela elandelako:

# MA: University of Witwatersrand-eJohannesburd.
# BA(Hons): University of Pretoria.
# BA: University of South Africa, ePretoria.
# FDE: Rand Afrikaans Universiteit, eJohannesburg.

==Ubutloli==
Wathoma ukutlola iincwadi ngerherho leTsengo. Kwagadangiswa iTsengo lokuthoma ngonyaka ka 1991, kwaphethangetsengo, ngonyaka ka – 1995{{cite web|title=Preserving and Celebrating our literary heritage|url=http://www.nlsa.ac.za/downloads/CFB/Reprint%20of%20Classics%20Project/2012_Reprints_Classics.pdf|work=National Library of South Africa|accessdate=22 February 2016|date=March 2011}}&lt;/ref&gt;. Umncopho weTsengo kufundisa abafundi uthabela ubukondlo ne enkondlo begodu nokulandelako:

* Ukwazi ubonga.
* Ukulimuka amatshayo wobukondlo.
* Ukukghona ukutlhama linkondlo.
* Ukutsenga iinkondlo.
* Ukuragela phambili ngezesikolo bukondlo begudu nesikolo bukondlo epilweni.

Amabanga la anembakhona ekuthini irherho leTsengo lijamele ukusiza abafundi ukwazi ngezobukondlo ne enkondlo. Bamalimi amanye nabo bangasizeka kwamambala. Ngetsengo batsengeke ngelimuko lobukondlo.

==Ref==


</text>
      <sha1>io4et5s1pklokezshduu4sass049fou</sha1>
    </revision>
    <revision>
      <id>1149</id>
      <parentid>1148</parentid>
      <timestamp>2016-02-23T14:16:03Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1149</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2610" sha1="6yam8fw7strshflslvwnrsufs3a7ote" xml:space="preserve">{{Person|
| ibizo = Mgiyelwa Simon Ntuli
| isithombe = Mgiyelwa Simon Ntuli.PNG
| umsebenzi = Umtloli
| ubelethwe ngo = 08 Arhostosi 1949
| indawo yo kubelethwa = Nompeketswana, Ekungwini
| wahlongakala ngo = 
| indawo yo hlongakala = 
}}
'''Mgiyelwa Simon Ntuli''' ngumtloli odumileko wobukondlo besindebele begodu wabelethwangomhlaka 08 Arhostosi 1949, koNompeketswana, esiphandeni sekungwini (Bronkhorstspruit).{{cite web|title=Preserving and Celebrating our literary heritage|url=https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17|work=National Library of South Africa|accessdate=22 February 2016|date=March 2011}}&lt;/ref&gt;

 

==Ifundo==
Wathoma ukufunda esikolweni samaRoma, eSdudu (Eastwood), ePitori l, (City of Tshwane) Emvakwalapo wangena eenkolweni ezincani ezilandelako:
* Kgoro Bantu School, eKungwini
* Serenity Bantu School, eRayton.
Waphumelela ibanga lesithandathu eSedibeng State School, eCullinan.Ifundo ephakamileko wayifumana eBoekenhoutfontein Secondary School, eMabopane. Waphetha
ibanga lesumi eMamelodi High School, eMamelodi. Ubutitjhere wabufundele eRehlahliwe Teacher Training College, waqedaiPrimary Teachers Certicatengo – 1974{{cite web|title=Preserving and Celebrating our literary heritage|url=https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17|work=National Library of South Africa|accessdate=22 February 2016|date=March 2011}}&lt;/ref&gt;. Kusukela
lapho wafunda iimfundo zakhe asekhaya asebenza wafumana iziqu sakhe ngendlela elandelako:

# MA: University of Witwatersrand-eJohannesburd.
# BA(Hons): University of Pretoria.
# BA: University of South Africa, ePretoria.
# FDE: Rand Afrikaans Universiteit, eJohannesburg.

==Ubutloli==
Wathoma ukutlola iincwadi ngerherho leTsengo. Kwagadangiswa iTsengo lokuthoma ngonyaka ka 1991, kwaphethangetsengo, ngonyaka ka – 1995{{cite web|title=Preserving and Celebrating our literary heritage|url=https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17|work=National Library of South Africa|accessdate=22 February 2016|date=March 2011}}&lt;/ref&gt;. Umncopho weTsengo kufundisa abafundi uthabela ubukondlo ne enkondlo begodu nokulandelako:

* Ukwazi ubonga.
* Ukulimuka amatshayo wobukondlo.
* Ukukghona ukutlhama linkondlo.
* Ukutsenga iinkondlo.
* Ukuragela phambili ngezesikolo bukondlo begudu nesikolo bukondlo epilweni.

Amabanga la anembakhona ekuthini irherho leTsengo lijamele ukusiza abafundi ukwazi ngezobukondlo ne enkondlo. Bamalimi amanye nabo bangasizeka kwamambala. Ngetsengo batsengeke ngelimuko lobukondlo.

==Ref==


</text>
      <sha1>6yam8fw7strshflslvwnrsufs3a7ote</sha1>
    </revision>
    <revision>
      <id>1150</id>
      <parentid>1149</parentid>
      <timestamp>2016-02-23T14:17:11Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1150</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2625" sha1="5eedaxyryk2di8z5jupmdc2seg3stco" xml:space="preserve">{{Person|
| ibizo = Mgiyelwa Simon Ntuli
| isithombe = Mgiyelwa Simon Ntuli.PNG
| umsebenzi = Umtloli
| ubelethwe ngo = 08 Arhostosi 1949
| indawo yo kubelethwa = Nompeketswana, Ekungwini
| wahlongakala ngo = 
| indawo yo hlongakala = 
}}
'''Mgiyelwa Simon Ntuli''' ngumtloli odumileko wobukondlo besindebele begodu wabelethwangomhlaka 08 Arhostosi 1949, koNompeketswana, esiphandeni sekungwini (Bronkhorstspruit).{{cite web|title=Preserving and Celebrating our literary heritage|url=https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17|work=National Library of South Africa|accessdate=22 February 2016|date=March 2011}}&lt;/ref&gt;

 

==Ifundo==
Wathoma ukufunda esikolweni samaRoma, eSdudu (Eastwood), ePitori l, (City of Tshwane) Emvakwalapo wangena eenkolweni ezincani ezilandelako:
* Kgoro Bantu School, eKungwini
* Serenity Bantu School, eRayton.
Waphumelela ibanga lesithandathu eSedibeng State School, eCullinan.Ifundo ephakamileko wayifumana eBoekenhoutfontein Secondary School, eMabopane. Waphetha
ibanga lesumi eMamelodi High School, eMamelodi. Ubutitjhere wabufundele eRehlahliwe Teacher Training College, waqedaiPrimary Teachers Certicatengo – 1974{{cite web|title=Preserving and Celebrating our literary heritage|url=https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17|work=National Library of South Africa|accessdate=22 February 2016|date=March 2011}}&lt;/ref&gt;. Kusukela
lapho wafunda iimfundo zakhe asekhaya asebenza wafumana iziqu sakhe ngendlela elandelako:

# MA: University of Witwatersrand-eJohannesburd.
# BA(Hons): University of Pretoria.
# BA: University of South Africa, ePretoria.
# FDE: Rand Afrikaans Universiteit, eJohannesburg.

==Ubutloli==
Wathoma ukutlola iincwadi ngerherho leTsengo. Kwagadangiswa iTsengo lokuthoma ngonyaka ka 1991, kwaphethangetsengo, ngonyaka ka – 1995{{cite web|title=Preserving and Celebrating our literary heritage|url=https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17|work=National Library of South Africa|accessdate=22 February 2016|date=March 2011}}&lt;/ref&gt;. Umncopho weTsengo kufundisa abafundi uthabela ubukondlo ne enkondlo begodu nokulandelako:

* Ukwazi ubonga.
* Ukulimuka amatshayo wobukondlo.
* Ukukghona ukutlhama linkondlo.
* Ukutsenga iinkondlo.
* Ukuragela phambili ngezesikolo bukondlo begudu nesikolo bukondlo epilweni.

Amabanga la anembakhona ekuthini irherho leTsengo lijamele ukusiza abafundi ukwazi ngezobukondlo ne enkondlo. Bamalimi amanye nabo bangasizeka kwamambala. Ngetsengo batsengeke ngelimuko lobukondlo.

==Reflist==
{{Reflist}}

</text>
      <sha1>5eedaxyryk2di8z5jupmdc2seg3stco</sha1>
    </revision>
    <revision>
      <id>1151</id>
      <parentid>1150</parentid>
      <timestamp>2016-02-23T14:22:57Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1151</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2632" sha1="78hskcz9j3b4zvzmzpnff98w0sjv1f0" xml:space="preserve">{{Person|
| ibizo = Mgiyelwa Simon Ntuli
| isithombe = Mgiyelwa Simon Ntuli.PNG
| umsebenzi = Umtloli
| ubelethwe ngo = 08 Arhostosi 1949
| indawo yo kubelethwa = Nompeketswana, Ekungwini
| wahlongakala ngo = 
| indawo yo hlongakala = 
}}
'''Mgiyelwa Simon Ntuli''' ngumtloli odumileko wobukondlo besindebele begodu wabelethwangomhlaka 08 Arhostosi 1949, koNompeketswana, esiphandeni sekungwini (Bronkhorstspruit).{{cite web|title=Preserving and Celebrating our literary heritage|url=https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17|work=National Library of South Africa|accessdate=22 February 2016|date=March 2011}}&lt;/ref&gt;

 

==Ifundo==
Wathoma ukufunda esikolweni samaRoma, eSdudu (Eastwood), ePitori l, (City of Tshwane) Emvakwalapo wangena eenkolweni ezincani ezilandelako:
* Kgoro Bantu School, eKungwini
* Serenity Bantu School, eRayton.
Waphumelela ibanga lesithandathu eSedibeng State School, eCullinan.Ifundo ephakamileko wayifumana eBoekenhoutfontein Secondary School, eMabopane. Waphetha
ibanga lesumi eMamelodi High School, eMamelodi. Ubutitjhere wabufundele eRehlahliwe Teacher Training College, waqedaiPrimary Teachers Certicatengo – 1974{{cite web|title=Preserving and Celebrating our literary heritage|url=https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17|work=National Library of South Africa|accessdate=22 February 2016|date=March 2011}}&lt;/ref&gt;. Kusukela
lapho wafunda iimfundo zakhe asekhaya asebenza wafumana iziqu sakhe ngendlela elandelako:

# MA: University of Witwatersrand-eJohannesburd.
# BA(Hons): University of Pretoria.
# BA: University of South Africa, ePretoria.
# FDE: Rand Afrikaans Universiteit, eJohannesburg.

==Ubutloli==
Wathoma ukutlola iincwadi ngerherho leTsengo. Kwagadangiswa iTsengo lokuthoma ngonyaka ka 1991, kwaphethangetsengo, ngonyaka ka – 1995{{cite web|title=Preserving and Celebrating our literary heritage|url=https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17|work=National Library of South Africa|accessdate=22 February 2016|date=March 2011}}&lt;/ref&gt;. Umncopho weTsengo kufundisa abafundi uthabela ubukondlo ne enkondlo begodu nokulandelako:

* Ukwazi ubonga.
* Ukulimuka amatshayo wobukondlo.
* Ukukghona ukutlhama linkondlo.
* Ukutsenga iinkondlo.
* Ukuragela phambili ngezesikolo bukondlo begudu nesikolo bukondlo epilweni.

Amabanga la anembakhona ekuthini irherho leTsengo lijamele ukusiza abafundi ukwazi ngezobukondlo ne enkondlo. Bamalimi amanye nabo bangasizeka kwamambala. Ngetsengo batsengeke ngelimuko lobukondlo.

==Isithasiselo==
{{reflist|2}}

</text>
      <sha1>78hskcz9j3b4zvzmzpnff98w0sjv1f0</sha1>
    </revision>
    <revision>
      <id>1152</id>
      <parentid>1151</parentid>
      <timestamp>2016-02-23T15:34:55Z</timestamp>
      <contributor>
        <username>incubator&gt;Katxis</username>
        <id>0</id>
      </contributor>
      <origin>1152</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2631" sha1="anqu94tqh1n8dprlv6ftha8vawnvk4m" xml:space="preserve">{{Person|
| ibizo = Mgiyelwa Simon Ntuli
| isithombe = Mgiyelwa Simon Ntuli.PNG
| umsebenzi = Umtloli
| ubelethwe ngo = 08 Arhostosi 1949
| indawo yo kubelethwa = Nompeketswana, Ekungwini
| wahlongakala ngo = 
| indawo yo hlongakala = 
}}
'''Mgiyelwa Simon Ntuli''' ngumtloli odumileko wobukondlo besindebele begodu wabelethwangomhlaka 08 Arhostosi 1949, koNompeketswana, esiphandeni sekungwini (Bronkhorstspruit).{{cite web|title=Preserving and Celebrating our literary heritage|url=https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17|work=National Library of South Africa|accessdate=22 February 2016|date=March 2011}}&lt;/ref&gt;

 

==Ifundo==
Wathoma ukufunda esikolweni samaRoma, eSdudu (Eastwood), ePitori l, (City of Tshwane) Emvakwalapo wangena eenkolweni ezincani ezilandelako:
* Kgoro Bantu School, eKungwini
* Serenity Bantu School, eRayton.
Waphumelela ibanga lesithandathu eSedibeng State School, eCullinan.Ifundo ephakamileko wayifumana eBoekenhoutfontein Secondary School, eMabopane. Waphetha
ibanga lesumi eMamelodi High School, eMamelodi. Ubutitjhere wabufundele eRehlahliwe Teacher Training College, waqedaiPrimary Teachers Certicatengo – 1974{{cite web|title=Preserving and Celebrating our literary heritage|url=https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17|work=National Library of South Africa|accessdate=22 February 2016|date=March 2011}}&lt;/ref&gt;. Kusukela
lapho wafunda iimfundo zakhe asekhaya asebenza wafumana iziqu sakhe ngendlela elandelako:

# MA: University of Witwatersrand-eJohannesburd.
# BA(Hons): University of Pretoria.
# BA: University of South Africa, ePretoria.
# FDE: Rand Afrikaans Universiteit, eJohannesburg.

==Ubutloli==
Wathoma ukutlola iincwadi ngerherho leTsengo. Kwagadangiswa iTsengo lokuthoma ngonyaka ka 1991, kwaphethangetsengo, ngonyaka ka – 1995{{cite web|title=Preserving and Celebrating our literary heritage|url=https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17|work=National Library of South Africa|accessdate=22 February 2016|date=March 2011}}&lt;/ref&gt;. Umncopho weTsengo kufundisa abafundi uthabela ubukondlo ne enkondlo begodu nokulandelako:

* Ukwazi ubonga.
* Ukulimuka amatshayo wobukondlo.
* Ukukghona ukutlhama linkondlo.
* Ukutsenga iinkondlo.
* Ukuragela phambili ngezesikolo bukondlo begudu nesikolo bukondlo epilweni.

Amabanga la anembakhona ekuthini irherho leTsengo lijamele ukusiza abafundi ukwazi ngezobukondlo ne enkondlo. Bamalimi amanye nabo bangasizeka kwamambala. Ngetsengo batsengeke ngelimuko lobukondlo.

==Isithasiselo==
&lt;eferences/&gt;

</text>
      <sha1>anqu94tqh1n8dprlv6ftha8vawnvk4m</sha1>
    </revision>
    <revision>
      <id>1153</id>
      <parentid>1152</parentid>
      <timestamp>2016-02-23T15:35:04Z</timestamp>
      <contributor>
        <username>incubator&gt;Katxis</username>
        <id>0</id>
      </contributor>
      <origin>1153</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2632" sha1="f1nckz36zivqd124oouzqb1mq92j358" xml:space="preserve">{{Person|
| ibizo = Mgiyelwa Simon Ntuli
| isithombe = Mgiyelwa Simon Ntuli.PNG
| umsebenzi = Umtloli
| ubelethwe ngo = 08 Arhostosi 1949
| indawo yo kubelethwa = Nompeketswana, Ekungwini
| wahlongakala ngo = 
| indawo yo hlongakala = 
}}
'''Mgiyelwa Simon Ntuli''' ngumtloli odumileko wobukondlo besindebele begodu wabelethwangomhlaka 08 Arhostosi 1949, koNompeketswana, esiphandeni sekungwini (Bronkhorstspruit).{{cite web|title=Preserving and Celebrating our literary heritage|url=https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17|work=National Library of South Africa|accessdate=22 February 2016|date=March 2011}}&lt;/ref&gt;

 

==Ifundo==
Wathoma ukufunda esikolweni samaRoma, eSdudu (Eastwood), ePitori l, (City of Tshwane) Emvakwalapo wangena eenkolweni ezincani ezilandelako:
* Kgoro Bantu School, eKungwini
* Serenity Bantu School, eRayton.
Waphumelela ibanga lesithandathu eSedibeng State School, eCullinan.Ifundo ephakamileko wayifumana eBoekenhoutfontein Secondary School, eMabopane. Waphetha
ibanga lesumi eMamelodi High School, eMamelodi. Ubutitjhere wabufundele eRehlahliwe Teacher Training College, waqedaiPrimary Teachers Certicatengo – 1974{{cite web|title=Preserving and Celebrating our literary heritage|url=https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17|work=National Library of South Africa|accessdate=22 February 2016|date=March 2011}}&lt;/ref&gt;. Kusukela
lapho wafunda iimfundo zakhe asekhaya asebenza wafumana iziqu sakhe ngendlela elandelako:

# MA: University of Witwatersrand-eJohannesburd.
# BA(Hons): University of Pretoria.
# BA: University of South Africa, ePretoria.
# FDE: Rand Afrikaans Universiteit, eJohannesburg.

==Ubutloli==
Wathoma ukutlola iincwadi ngerherho leTsengo. Kwagadangiswa iTsengo lokuthoma ngonyaka ka 1991, kwaphethangetsengo, ngonyaka ka – 1995{{cite web|title=Preserving and Celebrating our literary heritage|url=https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17|work=National Library of South Africa|accessdate=22 February 2016|date=March 2011}}&lt;/ref&gt;. Umncopho weTsengo kufundisa abafundi uthabela ubukondlo ne enkondlo begodu nokulandelako:

* Ukwazi ubonga.
* Ukulimuka amatshayo wobukondlo.
* Ukukghona ukutlhama linkondlo.
* Ukutsenga iinkondlo.
* Ukuragela phambili ngezesikolo bukondlo begudu nesikolo bukondlo epilweni.

Amabanga la anembakhona ekuthini irherho leTsengo lijamele ukusiza abafundi ukwazi ngezobukondlo ne enkondlo. Bamalimi amanye nabo bangasizeka kwamambala. Ngetsengo batsengeke ngelimuko lobukondlo.

==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>f1nckz36zivqd124oouzqb1mq92j358</sha1>
    </revision>
    <revision>
      <id>1154</id>
      <parentid>1153</parentid>
      <timestamp>2016-02-23T15:35:26Z</timestamp>
      <contributor>
        <username>incubator&gt;Katxis</username>
        <id>0</id>
      </contributor>
      <origin>1154</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2637" sha1="93d0xgo0oypgunj6i9l98giea99as3q" xml:space="preserve">{{Person|
| ibizo = Mgiyelwa Simon Ntuli
| isithombe = Mgiyelwa Simon Ntuli.PNG
| umsebenzi = Umtloli
| ubelethwe ngo = 08 Arhostosi 1949
| indawo yo kubelethwa = Nompeketswana, Ekungwini
| wahlongakala ngo = 
| indawo yo hlongakala = 
}}
'''Mgiyelwa Simon Ntuli''' ngumtloli odumileko wobukondlo besindebele begodu wabelethwangomhlaka 08 Arhostosi 1949, koNompeketswana, esiphandeni sekungwini (Bronkhorstspruit).&lt;ref&gt;{{cite web|title=Preserving and Celebrating our literary heritage|url=https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17|work=National Library of South Africa|accessdate=22 February 2016|date=March 2011}}&lt;/ref&gt;

 

==Ifundo==
Wathoma ukufunda esikolweni samaRoma, eSdudu (Eastwood), ePitori l, (City of Tshwane) Emvakwalapo wangena eenkolweni ezincani ezilandelako:
* Kgoro Bantu School, eKungwini
* Serenity Bantu School, eRayton.
Waphumelela ibanga lesithandathu eSedibeng State School, eCullinan.Ifundo ephakamileko wayifumana eBoekenhoutfontein Secondary School, eMabopane. Waphetha
ibanga lesumi eMamelodi High School, eMamelodi. Ubutitjhere wabufundele eRehlahliwe Teacher Training College, waqedaiPrimary Teachers Certicatengo – 1974{{cite web|title=Preserving and Celebrating our literary heritage|url=https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17|work=National Library of South Africa|accessdate=22 February 2016|date=March 2011}}&lt;/ref&gt;. Kusukela
lapho wafunda iimfundo zakhe asekhaya asebenza wafumana iziqu sakhe ngendlela elandelako:

# MA: University of Witwatersrand-eJohannesburd.
# BA(Hons): University of Pretoria.
# BA: University of South Africa, ePretoria.
# FDE: Rand Afrikaans Universiteit, eJohannesburg.

==Ubutloli==
Wathoma ukutlola iincwadi ngerherho leTsengo. Kwagadangiswa iTsengo lokuthoma ngonyaka ka 1991, kwaphethangetsengo, ngonyaka ka – 1995{{cite web|title=Preserving and Celebrating our literary heritage|url=https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17|work=National Library of South Africa|accessdate=22 February 2016|date=March 2011}}&lt;/ref&gt;. Umncopho weTsengo kufundisa abafundi uthabela ubukondlo ne enkondlo begodu nokulandelako:

* Ukwazi ubonga.
* Ukulimuka amatshayo wobukondlo.
* Ukukghona ukutlhama linkondlo.
* Ukutsenga iinkondlo.
* Ukuragela phambili ngezesikolo bukondlo begudu nesikolo bukondlo epilweni.

Amabanga la anembakhona ekuthini irherho leTsengo lijamele ukusiza abafundi ukwazi ngezobukondlo ne enkondlo. Bamalimi amanye nabo bangasizeka kwamambala. Ngetsengo batsengeke ngelimuko lobukondlo.

==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>93d0xgo0oypgunj6i9l98giea99as3q</sha1>
    </revision>
    <revision>
      <id>1155</id>
      <parentid>1154</parentid>
      <timestamp>2016-02-23T15:35:45Z</timestamp>
      <contributor>
        <username>incubator&gt;Katxis</username>
        <id>0</id>
      </contributor>
      <comment>/* Ubutloli */</comment>
      <origin>1155</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2642" sha1="lkb83wch2zg6cs7wf703owp19nanyzp" xml:space="preserve">{{Person|
| ibizo = Mgiyelwa Simon Ntuli
| isithombe = Mgiyelwa Simon Ntuli.PNG
| umsebenzi = Umtloli
| ubelethwe ngo = 08 Arhostosi 1949
| indawo yo kubelethwa = Nompeketswana, Ekungwini
| wahlongakala ngo = 
| indawo yo hlongakala = 
}}
'''Mgiyelwa Simon Ntuli''' ngumtloli odumileko wobukondlo besindebele begodu wabelethwangomhlaka 08 Arhostosi 1949, koNompeketswana, esiphandeni sekungwini (Bronkhorstspruit).&lt;ref&gt;{{cite web|title=Preserving and Celebrating our literary heritage|url=https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17|work=National Library of South Africa|accessdate=22 February 2016|date=March 2011}}&lt;/ref&gt;

 

==Ifundo==
Wathoma ukufunda esikolweni samaRoma, eSdudu (Eastwood), ePitori l, (City of Tshwane) Emvakwalapo wangena eenkolweni ezincani ezilandelako:
* Kgoro Bantu School, eKungwini
* Serenity Bantu School, eRayton.
Waphumelela ibanga lesithandathu eSedibeng State School, eCullinan.Ifundo ephakamileko wayifumana eBoekenhoutfontein Secondary School, eMabopane. Waphetha
ibanga lesumi eMamelodi High School, eMamelodi. Ubutitjhere wabufundele eRehlahliwe Teacher Training College, waqedaiPrimary Teachers Certicatengo – 1974{{cite web|title=Preserving and Celebrating our literary heritage|url=https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17|work=National Library of South Africa|accessdate=22 February 2016|date=March 2011}}&lt;/ref&gt;. Kusukela
lapho wafunda iimfundo zakhe asekhaya asebenza wafumana iziqu sakhe ngendlela elandelako:

# MA: University of Witwatersrand-eJohannesburd.
# BA(Hons): University of Pretoria.
# BA: University of South Africa, ePretoria.
# FDE: Rand Afrikaans Universiteit, eJohannesburg.

==Ubutloli==
Wathoma ukutlola iincwadi ngerherho leTsengo. Kwagadangiswa iTsengo lokuthoma ngonyaka ka 1991, kwaphethangetsengo, ngonyaka ka – 1995&lt;ref&gt;{{cite web|title=Preserving and Celebrating our literary heritage|url=https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17|work=National Library of South Africa|accessdate=22 February 2016|date=March 2011}}&lt;/ref&gt;. Umncopho weTsengo kufundisa abafundi uthabela ubukondlo ne enkondlo begodu nokulandelako:

* Ukwazi ubonga.
* Ukulimuka amatshayo wobukondlo.
* Ukukghona ukutlhama linkondlo.
* Ukutsenga iinkondlo.
* Ukuragela phambili ngezesikolo bukondlo begudu nesikolo bukondlo epilweni.

Amabanga la anembakhona ekuthini irherho leTsengo lijamele ukusiza abafundi ukwazi ngezobukondlo ne enkondlo. Bamalimi amanye nabo bangasizeka kwamambala. Ngetsengo batsengeke ngelimuko lobukondlo.

==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>lkb83wch2zg6cs7wf703owp19nanyzp</sha1>
    </revision>
    <revision>
      <id>1156</id>
      <parentid>1155</parentid>
      <timestamp>2016-02-23T15:36:01Z</timestamp>
      <contributor>
        <username>incubator&gt;Katxis</username>
        <id>0</id>
      </contributor>
      <comment>/* Ifundo */</comment>
      <origin>1156</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2647" sha1="o6leti3lxru8mvauprxbwxou4gclxss" xml:space="preserve">{{Person|
| ibizo = Mgiyelwa Simon Ntuli
| isithombe = Mgiyelwa Simon Ntuli.PNG
| umsebenzi = Umtloli
| ubelethwe ngo = 08 Arhostosi 1949
| indawo yo kubelethwa = Nompeketswana, Ekungwini
| wahlongakala ngo = 
| indawo yo hlongakala = 
}}
'''Mgiyelwa Simon Ntuli''' ngumtloli odumileko wobukondlo besindebele begodu wabelethwangomhlaka 08 Arhostosi 1949, koNompeketswana, esiphandeni sekungwini (Bronkhorstspruit).&lt;ref&gt;{{cite web|title=Preserving and Celebrating our literary heritage|url=https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17|work=National Library of South Africa|accessdate=22 February 2016|date=March 2011}}&lt;/ref&gt;

 

==Ifundo==
Wathoma ukufunda esikolweni samaRoma, eSdudu (Eastwood), ePitori l, (City of Tshwane) Emvakwalapo wangena eenkolweni ezincani ezilandelako:
* Kgoro Bantu School, eKungwini
* Serenity Bantu School, eRayton.
Waphumelela ibanga lesithandathu eSedibeng State School, eCullinan.Ifundo ephakamileko wayifumana eBoekenhoutfontein Secondary School, eMabopane. Waphetha
ibanga lesumi eMamelodi High School, eMamelodi. Ubutitjhere wabufundele eRehlahliwe Teacher Training College, waqedaiPrimary Teachers Certicatengo – 1974&lt;ref&gt;{{cite web|title=Preserving and Celebrating our literary heritage|url=https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17|work=National Library of South Africa|accessdate=22 February 2016|date=March 2011}}&lt;/ref&gt;. Kusukela
lapho wafunda iimfundo zakhe asekhaya asebenza wafumana iziqu sakhe ngendlela elandelako:

# MA: University of Witwatersrand-eJohannesburd.
# BA(Hons): University of Pretoria.
# BA: University of South Africa, ePretoria.
# FDE: Rand Afrikaans Universiteit, eJohannesburg.

==Ubutloli==
Wathoma ukutlola iincwadi ngerherho leTsengo. Kwagadangiswa iTsengo lokuthoma ngonyaka ka 1991, kwaphethangetsengo, ngonyaka ka – 1995&lt;ref&gt;{{cite web|title=Preserving and Celebrating our literary heritage|url=https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17|work=National Library of South Africa|accessdate=22 February 2016|date=March 2011}}&lt;/ref&gt;. Umncopho weTsengo kufundisa abafundi uthabela ubukondlo ne enkondlo begodu nokulandelako:

* Ukwazi ubonga.
* Ukulimuka amatshayo wobukondlo.
* Ukukghona ukutlhama linkondlo.
* Ukutsenga iinkondlo.
* Ukuragela phambili ngezesikolo bukondlo begudu nesikolo bukondlo epilweni.

Amabanga la anembakhona ekuthini irherho leTsengo lijamele ukusiza abafundi ukwazi ngezobukondlo ne enkondlo. Bamalimi amanye nabo bangasizeka kwamambala. Ngetsengo batsengeke ngelimuko lobukondlo.

==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>o6leti3lxru8mvauprxbwxou4gclxss</sha1>
    </revision>
    <revision>
      <id>1157</id>
      <parentid>1156</parentid>
      <timestamp>2016-02-24T04:13:57Z</timestamp>
      <contributor>
        <username>incubator&gt;CommonsDelinker</username>
        <id>0</id>
      </contributor>
      <comment>Removing &quot;Mgiyelwa_Simon_Ntuli.PNG&quot;, it has been deleted from Commons by [[commons:User:Hedwig in Washington|Hedwig in Washington]] because: [[:c:COM:L|Copyright violation]]: external source, no license, no permission..</comment>
      <origin>1157</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2622" sha1="8wgklnkm2vpbxy7rjoc27pkmhwnm6ta" xml:space="preserve">{{Person|
| ibizo = Mgiyelwa Simon Ntuli
| isithombe =
| umsebenzi = Umtloli
| ubelethwe ngo = 08 Arhostosi 1949
| indawo yo kubelethwa = Nompeketswana, Ekungwini
| wahlongakala ngo = 
| indawo yo hlongakala = 
}}
'''Mgiyelwa Simon Ntuli''' ngumtloli odumileko wobukondlo besindebele begodu wabelethwangomhlaka 08 Arhostosi 1949, koNompeketswana, esiphandeni sekungwini (Bronkhorstspruit).&lt;ref&gt;{{cite web|title=Preserving and Celebrating our literary heritage|url=https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17|work=National Library of South Africa|accessdate=22 February 2016|date=March 2011}}&lt;/ref&gt;

 

==Ifundo==
Wathoma ukufunda esikolweni samaRoma, eSdudu (Eastwood), ePitori l, (City of Tshwane) Emvakwalapo wangena eenkolweni ezincani ezilandelako:
* Kgoro Bantu School, eKungwini
* Serenity Bantu School, eRayton.
Waphumelela ibanga lesithandathu eSedibeng State School, eCullinan.Ifundo ephakamileko wayifumana eBoekenhoutfontein Secondary School, eMabopane. Waphetha
ibanga lesumi eMamelodi High School, eMamelodi. Ubutitjhere wabufundele eRehlahliwe Teacher Training College, waqedaiPrimary Teachers Certicatengo – 1974&lt;ref&gt;{{cite web|title=Preserving and Celebrating our literary heritage|url=https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17|work=National Library of South Africa|accessdate=22 February 2016|date=March 2011}}&lt;/ref&gt;. Kusukela
lapho wafunda iimfundo zakhe asekhaya asebenza wafumana iziqu sakhe ngendlela elandelako:

# MA: University of Witwatersrand-eJohannesburd.
# BA(Hons): University of Pretoria.
# BA: University of South Africa, ePretoria.
# FDE: Rand Afrikaans Universiteit, eJohannesburg.

==Ubutloli==
Wathoma ukutlola iincwadi ngerherho leTsengo. Kwagadangiswa iTsengo lokuthoma ngonyaka ka 1991, kwaphethangetsengo, ngonyaka ka – 1995&lt;ref&gt;{{cite web|title=Preserving and Celebrating our literary heritage|url=https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17|work=National Library of South Africa|accessdate=22 February 2016|date=March 2011}}&lt;/ref&gt;. Umncopho weTsengo kufundisa abafundi uthabela ubukondlo ne enkondlo begodu nokulandelako:

* Ukwazi ubonga.
* Ukulimuka amatshayo wobukondlo.
* Ukukghona ukutlhama linkondlo.
* Ukutsenga iinkondlo.
* Ukuragela phambili ngezesikolo bukondlo begudu nesikolo bukondlo epilweni.

Amabanga la anembakhona ekuthini irherho leTsengo lijamele ukusiza abafundi ukwazi ngezobukondlo ne enkondlo. Bamalimi amanye nabo bangasizeka kwamambala. Ngetsengo batsengeke ngelimuko lobukondlo.

==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>8wgklnkm2vpbxy7rjoc27pkmhwnm6ta</sha1>
    </revision>
    <revision>
      <id>1158</id>
      <parentid>1157</parentid>
      <timestamp>2016-02-24T10:11:05Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1158</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2648" sha1="btbjbgowxyqtn8x283d1vc8i0w35r41" xml:space="preserve">{{Person|
| ibizo = Mgiyelwa Simon Ntuli
| isithombe = Coats_of_arms_of_None.svg
| umsebenzi = Umtloli
| ubelethwe ngo = 08 Arhostosi 1949
| indawo yo kubelethwa = Nompeketswana, Ekungwini
| wahlongakala ngo = 
| indawo yo hlongakala = 
}}
'''Mgiyelwa Simon Ntuli''' ngumtloli odumileko wobukondlo besindebele begodu wabelethwangomhlaka 08 Arhostosi 1949, koNompeketswana, esiphandeni sekungwini (Bronkhorstspruit).&lt;ref&gt;{{cite web|title=Preserving and Celebrating our literary heritage|url=https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17|work=National Library of South Africa|accessdate=22 February 2016|date=March 2011}}&lt;/ref&gt;

 

==Ifundo==
Wathoma ukufunda esikolweni samaRoma, eSdudu (Eastwood), ePitori l, (City of Tshwane) Emvakwalapo wangena eenkolweni ezincani ezilandelako:
* Kgoro Bantu School, eKungwini
* Serenity Bantu School, eRayton.
Waphumelela ibanga lesithandathu eSedibeng State School, eCullinan.Ifundo ephakamileko wayifumana eBoekenhoutfontein Secondary School, eMabopane. Waphetha
ibanga lesumi eMamelodi High School, eMamelodi. Ubutitjhere wabufundele eRehlahliwe Teacher Training College, waqedaiPrimary Teachers Certicatengo – 1974&lt;ref&gt;{{cite web|title=Preserving and Celebrating our literary heritage|url=https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17|work=National Library of South Africa|accessdate=22 February 2016|date=March 2011}}&lt;/ref&gt;. Kusukela
lapho wafunda iimfundo zakhe asekhaya asebenza wafumana iziqu sakhe ngendlela elandelako:

# MA: University of Witwatersrand-eJohannesburd.
# BA(Hons): University of Pretoria.
# BA: University of South Africa, ePretoria.
# FDE: Rand Afrikaans Universiteit, eJohannesburg.

==Ubutloli==
Wathoma ukutlola iincwadi ngerherho leTsengo. Kwagadangiswa iTsengo lokuthoma ngonyaka ka 1991, kwaphethangetsengo, ngonyaka ka – 1995&lt;ref&gt;{{cite web|title=Preserving and Celebrating our literary heritage|url=https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17|work=National Library of South Africa|accessdate=22 February 2016|date=March 2011}}&lt;/ref&gt;. Umncopho weTsengo kufundisa abafundi uthabela ubukondlo ne enkondlo begodu nokulandelako:

* Ukwazi ubonga.
* Ukulimuka amatshayo wobukondlo.
* Ukukghona ukutlhama linkondlo.
* Ukutsenga iinkondlo.
* Ukuragela phambili ngezesikolo bukondlo begudu nesikolo bukondlo epilweni.

Amabanga la anembakhona ekuthini irherho leTsengo lijamele ukusiza abafundi ukwazi ngezobukondlo ne enkondlo. Bamalimi amanye nabo bangasizeka kwamambala. Ngetsengo batsengeke ngelimuko lobukondlo.

==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>btbjbgowxyqtn8x283d1vc8i0w35r41</sha1>
    </revision>
    <revision>
      <id>1159</id>
      <parentid>1158</parentid>
      <timestamp>2016-02-24T10:18:40Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1159</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2672" sha1="1ft5amuo22x1iodbhnc5wx8yrl2vmao" xml:space="preserve">{{Person|
| ibizo = Mgiyelwa Simon Ntuli
| isithombe = Coats_of_arms_of_None.svg
| umsebenzi = Umtloli
| ubelethwe ngo = 08 Arhostosi 1949
| indawo yo kubelethwa = Nompeketswana, Ekungwini
| wahlongakala ngo = 
| indawo yo hlongakala = 
}}
'''Mgiyelwa Simon Ntuli''' ngumtloli odumileko wobukondlo besindebele begodu wabelethwangomhlaka 08 Arhostosi 1949, koNompeketswana, esiphandeni sekungwini (Bronkhorstspruit).&lt;ref&gt;{{cite web|title=Preserving and Celebrating our literary heritage|url=https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17|work=National Library of South Africa|accessdate=22 February 2016|date=March 2011}}&lt;/ref&gt;

 

==Ifundo==
Wathoma ukufunda esikolweni samaRoma, eSdudu (Eastwood), ePitori l, (City of Tshwane) Emvakwalapo wangena eenkolweni ezincani ezilandelako:
* Kgoro Bantu School, eKungwini
* Serenity Bantu School, eRayton.
Waphumelela ibanga lesithandathu eSedibeng State School, eCullinan.Ifundo ephakamileko wayifumana eBoekenhoutfontein Secondary School, eMabopane. Waphetha
ibanga lesumi eMamelodi High School, eMamelodi. Ubutitjhere wabufundele eRehlahliwe Teacher Training College, waqedaiPrimary Teachers Certicatengo – 1974&lt;ref&gt;{{cite web|title=Preserving and Celebrating our literary heritage|url=https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17|work=National Library of South Africa|accessdate=22 February 2016|date=March 2011}}&lt;/ref&gt;. Kusukela
lapho wafunda iimfundo zakhe asekhaya asebenza wafumana iziqu sakhe ngendlela elandelako:

# MA: University of Witwatersrand-eJohannesburd.
# BA(Hons): University of Pretoria.
# BA: University of South Africa, ePretoria.
# FDE: Rand Afrikaans Universiteit, eJohannesburg.

==Ubutloli==
Wathoma ukutlola iincwadi ngerherho leTsengo. Kwagadangiswa iTsengo lokuthoma ngonyaka ka 1991, kwaphethangetsengo, ngonyaka ka – 1995&lt;ref&gt;{{cite web|title=Preserving and Celebrating our literary heritage|url=https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17|work=National Library of South Africa|accessdate=22 February 2016|date=March 2011}}&lt;/ref&gt;. Umncopho weTsengo kufundisa abafundi uthabela ubukondlo ne enkondlo begodu nokulandelako:

* Ukwazi ubonga.
* Ukulimuka amatshayo wobukondlo.
* Ukukghona ukutlhama linkondlo.
* Ukutsenga iinkondlo.
* Ukuragela phambili ngezesikolo bukondlo begudu nesikolo bukondlo epilweni.

Amabanga la anembakhona ekuthini irherho leTsengo lijamele ukusiza abafundi ukwazi ngezobukondlo ne enkondlo. Bamalimi amanye nabo bangasizeka kwamambala. Ngetsengo batsengeke ngelimuko lobukondlo.&lt;ref name=ph2&gt;Test&lt;/ref&gt;

==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>1ft5amuo22x1iodbhnc5wx8yrl2vmao</sha1>
    </revision>
    <revision>
      <id>1160</id>
      <parentid>1159</parentid>
      <timestamp>2016-02-24T10:24:21Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1160</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2171" sha1="hayog3kbn9gxk927rcnuji06crlcpgw" xml:space="preserve">{{Person|
| ibizo = Mgiyelwa Simon Ntuli
| isithombe = Coats_of_arms_of_None.svg
| umsebenzi = Umtloli
| ubelethwe ngo = 08 Arhostosi 1949
| indawo yo kubelethwa = Nompeketswana, Ekungwini
| wahlongakala ngo = 
| indawo yo hlongakala = 
}}
'''Mgiyelwa Simon Ntuli''' ngumtloli odumileko wobukondlo besindebele begodu wabelethwangomhlaka 08 Arhostosi 1949, koNompeketswana, esiphandeni sekungwini (Bronkhorstspruit).&lt;ref name=ph1&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - ''National Library of South Africa''. |Retrieved 22 February 2016&lt;/ref&gt;

 

==Ifundo==
Wathoma ukufunda esikolweni samaRoma, eSdudu (Eastwood), ePitori l, (City of Tshwane) Emvakwalapo wangena eenkolweni ezincani ezilandelako:
* Kgoro Bantu School, eKungwini
* Serenity Bantu School, eRayton.
Waphumelela ibanga lesithandathu eSedibeng State School, eCullinan.Ifundo ephakamileko wayifumana eBoekenhoutfontein Secondary School, eMabopane. Waphetha
ibanga lesumi eMamelodi High School, eMamelodi. Ubutitjhere wabufundele eRehlahliwe Teacher Training College, waqedaiPrimary Teachers Certicatengo – 1974&lt;ref name=ph1&gt;&lt;/ref&gt;. Kusukela
lapho wafunda iimfundo zakhe asekhaya asebenza wafumana iziqu sakhe ngendlela elandelako:

# MA: University of Witwatersrand-eJohannesburd.
# BA(Hons): University of Pretoria.
# BA: University of South Africa, ePretoria.
# FDE: Rand Afrikaans Universiteit, eJohannesburg.

==Ubutloli==
Wathoma ukutlola iincwadi ngerherho leTsengo. Kwagadangiswa iTsengo lokuthoma ngonyaka ka 1991, kwaphethangetsengo, ngonyaka ka – 1995&lt;ref name=ph1&gt;&lt;/ref&gt;. Umncopho weTsengo kufundisa abafundi uthabela ubukondlo ne enkondlo begodu nokulandelako:

* Ukwazi ubonga.
* Ukulimuka amatshayo wobukondlo.
* Ukukghona ukutlhama linkondlo.
* Ukutsenga iinkondlo.
* Ukuragela phambili ngezesikolo bukondlo begudu nesikolo bukondlo epilweni.

Amabanga la anembakhona ekuthini irherho leTsengo lijamele ukusiza abafundi ukwazi ngezobukondlo ne enkondlo. Bamalimi amanye nabo bangasizeka kwamambala. Ngetsengo batsengeke ngelimuko lobukondlo.

==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>hayog3kbn9gxk927rcnuji06crlcpgw</sha1>
    </revision>
    <revision>
      <id>1161</id>
      <parentid>1160</parentid>
      <timestamp>2016-02-24T10:25:13Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1161</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2172" sha1="4v8y9nzhgzcigxlqu1bu2v8q5ewutm9" xml:space="preserve">{{Person|
| ibizo = Mgiyelwa Simon Ntuli
| isithombe = Coats_of_arms_of_None.svg
| umsebenzi = Umtloli
| ubelethwe ngo = 08 Arhostosi 1949
| indawo yo kubelethwa = Nompeketswana, Ekungwini
| wahlongakala ngo = 
| indawo yo hlongakala = 
}}
'''Mgiyelwa Simon Ntuli''' ngumtloli odumileko wobukondlo besindebele begodu wabelethwangomhlaka 08 Arhostosi 1949, koNompeketswana, esiphandeni sekungwini (Bronkhorstspruit).&lt;ref name=ph1&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt;

 

==Ifundo==
Wathoma ukufunda esikolweni samaRoma, eSdudu (Eastwood), ePitori l, (City of Tshwane) Emvakwalapo wangena eenkolweni ezincani ezilandelako:
* Kgoro Bantu School, eKungwini
* Serenity Bantu School, eRayton.
Waphumelela ibanga lesithandathu eSedibeng State School, eCullinan.Ifundo ephakamileko wayifumana eBoekenhoutfontein Secondary School, eMabopane. Waphetha
ibanga lesumi eMamelodi High School, eMamelodi. Ubutitjhere wabufundele eRehlahliwe Teacher Training College, waqedaiPrimary Teachers Certicatengo – 1974&lt;ref name=ph1&gt;&lt;/ref&gt;. Kusukela
lapho wafunda iimfundo zakhe asekhaya asebenza wafumana iziqu sakhe ngendlela elandelako:

# MA: University of Witwatersrand-eJohannesburd.
# BA(Hons): University of Pretoria.
# BA: University of South Africa, ePretoria.
# FDE: Rand Afrikaans Universiteit, eJohannesburg.

==Ubutloli==
Wathoma ukutlola iincwadi ngerherho leTsengo. Kwagadangiswa iTsengo lokuthoma ngonyaka ka 1991, kwaphethangetsengo, ngonyaka ka – 1995&lt;ref name=ph1&gt;&lt;/ref&gt;. Umncopho weTsengo kufundisa abafundi uthabela ubukondlo ne enkondlo begodu nokulandelako:

* Ukwazi ubonga.
* Ukulimuka amatshayo wobukondlo.
* Ukukghona ukutlhama linkondlo.
* Ukutsenga iinkondlo.
* Ukuragela phambili ngezesikolo bukondlo begudu nesikolo bukondlo epilweni.

Amabanga la anembakhona ekuthini irherho leTsengo lijamele ukusiza abafundi ukwazi ngezobukondlo ne enkondlo. Bamalimi amanye nabo bangasizeka kwamambala. Ngetsengo batsengeke ngelimuko lobukondlo.

==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>4v8y9nzhgzcigxlqu1bu2v8q5ewutm9</sha1>
    </revision>
    <revision>
      <id>1162</id>
      <parentid>1161</parentid>
      <timestamp>2016-02-24T10:27:53Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1162</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2177" sha1="1t6jwdivgbquxi0tvkq1qx1w0rlmyws" xml:space="preserve">{{Person|
| ibizo = Mgiyelwa Simon Ntuli
| isithombe = Coats_of_arms_of_None.svg
| umsebenzi = Umtloli
| ubelethwe ngo = 08 Arhostosi 1949
| indawo yo kubelethwa = Nompeketswana, Ekungwini
| wahlongakala ngo = 
| indawo yo hlongakala = 
}}
'''Mgiyelwa Simon Ntuli''' (wabelethwa 08 Arhostosi 1949) ngumtloli odumileko wobukondlo besindebele begodu wabelethelwa koNompeketswana, esiphandeni sekungwini (Bronkhorstspruit).&lt;ref name=ph1&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt;

 

==Ifundo==
Wathoma ukufunda esikolweni samaRoma, eSdudu (Eastwood), ePitori l, (City of Tshwane) Emvakwalapo wangena eenkolweni ezincani ezilandelako:
* Kgoro Bantu School, eKungwini
* Serenity Bantu School, eRayton.
Waphumelela ibanga lesithandathu eSedibeng State School, eCullinan.Ifundo ephakamileko wayifumana eBoekenhoutfontein Secondary School, eMabopane. Waphetha
ibanga lesumi eMamelodi High School, eMamelodi. Ubutitjhere wabufundele eRehlahliwe Teacher Training College, waqedaiPrimary Teachers Certicatengo – 1974&lt;ref name=ph1&gt;&lt;/ref&gt;. Kusukela
lapho wafunda iimfundo zakhe asekhaya asebenza wafumana iziqu sakhe ngendlela elandelako:

# MA: University of Witwatersrand-eJohannesburd.
# BA(Hons): University of Pretoria.
# BA: University of South Africa, ePretoria.
# FDE: Rand Afrikaans Universiteit, eJohannesburg.

==Ubutloli==
Wathoma ukutlola iincwadi ngerherho leTsengo. Kwagadangiswa iTsengo lokuthoma ngonyaka ka 1991, kwaphethangetsengo, ngonyaka ka – 1995&lt;ref name=ph1&gt;&lt;/ref&gt;. Umncopho weTsengo kufundisa abafundi uthabela ubukondlo ne enkondlo begodu nokulandelako:

* Ukwazi ubonga.
* Ukulimuka amatshayo wobukondlo.
* Ukukghona ukutlhama linkondlo.
* Ukutsenga iinkondlo.
* Ukuragela phambili ngezesikolo bukondlo begudu nesikolo bukondlo epilweni.

Amabanga la anembakhona ekuthini irherho leTsengo lijamele ukusiza abafundi ukwazi ngezobukondlo ne enkondlo. Bamalimi amanye nabo bangasizeka kwamambala. Ngetsengo batsengeke ngelimuko lobukondlo.

==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>1t6jwdivgbquxi0tvkq1qx1w0rlmyws</sha1>
    </revision>
    <revision>
      <id>1163</id>
      <parentid>1162</parentid>
      <timestamp>2016-02-24T10:30:12Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1163</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2187" sha1="mqcwfjla7cmmqhsq2dvq6d0epstruq2" xml:space="preserve">{{Person|
| ibizo = Mgiyelwa Simon Ntuli
| isithombe = Coats_of_arms_of_None.svg
| umsebenzi = Umtloli
| ubelethwe ngo = 08 Arhostosi 1949
| indawo yo kubelethwa = Nompeketswana, Ekungwini
| wahlongakala ngo = 
| indawo yo hlongakala = 
}}
'''Mgiyelwa Simon Ntuli''' (wabelethwa ngomhlaka 08 Arhostosi 1949) ngumtloli odumileko wobukondlo besindebele begodu wabelethelwa koNompeketswana, esiphandeni sekungwini (Bronkhorstspruit).&lt;ref name=ph1&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt;

 

==Ifundo==
Wathoma ukufunda esikolweni samaRoma, eSdudu (Eastwood), ePitori l, (City of Tshwane) Emvakwalapo wangena eenkolweni ezincani ezilandelako:
* Kgoro Bantu School, eKungwini
* Serenity Bantu School, eRayton.
Waphumelela ibanga lesithandathu eSedibeng State School, eCullinan.Ifundo ephakamileko wayifumana eBoekenhoutfontein Secondary School, eMabopane. Waphetha
ibanga lesumi eMamelodi High School, eMamelodi. Ubutitjhere wabufundele eRehlahliwe Teacher Training College, waqedaiPrimary Teachers Certicatengo – 1974&lt;ref name=ph1&gt;&lt;/ref&gt;. Kusukela
lapho wafunda iimfundo zakhe asekhaya asebenza wafumana iziqu sakhe ngendlela elandelako:

# MA: University of Witwatersrand-eJohannesburd.
# BA(Hons): University of Pretoria.
# BA: University of South Africa, ePretoria.
# FDE: Rand Afrikaans Universiteit, eJohannesburg.

==Ubutloli==
Wathoma ukutlola iincwadi ngerherho leTsengo. Kwagadangiswa iTsengo lokuthoma ngonyaka ka 1991, kwaphethangetsengo, ngonyaka ka – 1995&lt;ref name=ph1&gt;&lt;/ref&gt;. Umncopho weTsengo kufundisa abafundi uthabela ubukondlo ne enkondlo begodu nokulandelako:

* Ukwazi ubonga.
* Ukulimuka amatshayo wobukondlo.
* Ukukghona ukutlhama linkondlo.
* Ukutsenga iinkondlo.
* Ukuragela phambili ngezesikolo bukondlo begudu nesikolo bukondlo epilweni.

Amabanga la anembakhona ekuthini irherho leTsengo lijamele ukusiza abafundi ukwazi ngezobukondlo ne enkondlo. Bamalimi amanye nabo bangasizeka kwamambala. Ngetsengo batsengeke ngelimuko lobukondlo.

==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>mqcwfjla7cmmqhsq2dvq6d0epstruq2</sha1>
    </revision>
    <revision>
      <id>1164</id>
      <parentid>1163</parentid>
      <timestamp>2016-02-24T10:30:33Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1164</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2184" sha1="3sgtclv0g7zsxypx6ft8vch593qj4y8" xml:space="preserve">{{Person|
| ibizo = Mgiyelwa Simon Ntuli
| isithombe = Coats_of_arms_of_None.svg
| umsebenzi = Umtloli
| ubelethwe ngo = 08 Arhostosi 1949
| indawo yo kubelethwa = Nompeketswana, Ekungwini
| wahlongakala ngo = 
| indawo yo hlongakala = 
}}
'''Mgiyelwa Simon Ntuli''' (wabelethwa ngomhlaka 08 Arhostosi 1949) ngumtloli odumileko wobukondlo besindebele begodu wabelethelwa koNompeketswana, esiphandeni sekungwini (Bronkhorstspruit).&lt;ref name=ph1&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt;

==Ifundo==
Wathoma ukufunda esikolweni samaRoma, eSdudu (Eastwood), ePitori l, (City of Tshwane) Emvakwalapo wangena eenkolweni ezincani ezilandelako:
* Kgoro Bantu School, eKungwini
* Serenity Bantu School, eRayton.
Waphumelela ibanga lesithandathu eSedibeng State School, eCullinan.Ifundo ephakamileko wayifumana eBoekenhoutfontein Secondary School, eMabopane. Waphetha
ibanga lesumi eMamelodi High School, eMamelodi. Ubutitjhere wabufundele eRehlahliwe Teacher Training College, waqedaiPrimary Teachers Certicatengo – 1974&lt;ref name=ph1&gt;&lt;/ref&gt;. Kusukela
lapho wafunda iimfundo zakhe asekhaya asebenza wafumana iziqu sakhe ngendlela elandelako:

# MA: University of Witwatersrand-eJohannesburd.
# BA(Hons): University of Pretoria.
# BA: University of South Africa, ePretoria.
# FDE: Rand Afrikaans Universiteit, eJohannesburg.

==Ubutloli==
Wathoma ukutlola iincwadi ngerherho leTsengo. Kwagadangiswa iTsengo lokuthoma ngonyaka ka 1991, kwaphethangetsengo, ngonyaka ka – 1995&lt;ref name=ph1&gt;&lt;/ref&gt;. Umncopho weTsengo kufundisa abafundi uthabela ubukondlo ne enkondlo begodu nokulandelako:

* Ukwazi ubonga.
* Ukulimuka amatshayo wobukondlo.
* Ukukghona ukutlhama linkondlo.
* Ukutsenga iinkondlo.
* Ukuragela phambili ngezesikolo bukondlo begudu nesikolo bukondlo epilweni.

Amabanga la anembakhona ekuthini irherho leTsengo lijamele ukusiza abafundi ukwazi ngezobukondlo ne enkondlo. Bamalimi amanye nabo bangasizeka kwamambala. Ngetsengo batsengeke ngelimuko lobukondlo.

==Isithasiselo==
&lt;references/&gt;

</text>
      <sha1>3sgtclv0g7zsxypx6ft8vch593qj4y8</sha1>
    </revision>
    <revision>
      <id>1165</id>
      <parentid>1164</parentid>
      <timestamp>2016-02-24T10:32:00Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1165</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2213" sha1="gdt5deste2jsgjndefw8v73yt8y7586" xml:space="preserve">{{Person|
| ibizo = Mgiyelwa Simon Ntuli
| isithombe = Coats_of_arms_of_None.svg
| umsebenzi = Umtloli
| ubelethwe ngo = 08 Arhostosi 1949
| indawo yo kubelethwa = Nompeketswana, Ekungwini
| wahlongakala ngo = 
| indawo yo hlongakala = 
}}
'''Mgiyelwa Simon Ntuli''' (wabelethwa ngomhlaka 08 Arhostosi 1949) ngumtloli odumileko wobukondlo besindebele begodu wabelethelwa koNompeketswana, esiphandeni sekungwini (Bronkhorstspruit).&lt;ref name=ph1&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt;

==Ifundo==
Wathoma ukufunda esikolweni samaRoma, eSdudu (Eastwood), ePitori l, (City of Tshwane) Emvakwalapo wangena eenkolweni ezincani ezilandelako:
* Kgoro Bantu School, eKungwini
* Serenity Bantu School, eRayton.
Waphumelela ibanga lesithandathu eSedibeng State School, eCullinan.Ifundo ephakamileko wayifumana eBoekenhoutfontein Secondary School, eMabopane. Waphetha
ibanga lesumi eMamelodi High School, eMamelodi. Ubutitjhere wabufundele eRehlahliwe Teacher Training College, waqedaiPrimary Teachers Certicatengo – 1974&lt;ref name=ph1&gt;&lt;/ref&gt;. Kusukela
lapho wafunda iimfundo zakhe asekhaya asebenza wafumana iziqu sakhe ngendlela elandelako:

# MA: University of Witwatersrand-eJohannesburd.
# BA(Hons): University of Pretoria.
# BA: University of South Africa, ePretoria.
# FDE: Rand Afrikaans Universiteit, eJohannesburg.

==Ubutloli==
Wathoma ukutlola iincwadi ngerherho leTsengo. Kwagadangiswa iTsengo lokuthoma ngonyaka ka 1991, kwaphethangetsengo, ngonyaka ka – 1995&lt;ref name=ph1&gt;&lt;/ref&gt;. Umncopho weTsengo kufundisa abafundi uthabela ubukondlo ne enkondlo begodu nokulandelako:

* Ukwazi ubonga.
* Ukulimuka amatshayo wobukondlo.
* Ukukghona ukutlhama linkondlo.
* Ukutsenga iinkondlo.
* Ukuragela phambili ngezesikolo bukondlo begudu nesikolo bukondlo epilweni.

Amabanga la anembakhona ekuthini irherho leTsengo lijamele ukusiza abafundi ukwazi ngezobukondlo ne enkondlo. Bamalimi amanye nabo bangasizeka kwamambala. Ngetsengo batsengeke ngelimuko lobukondlo.

==Isithasiselo==
&lt;references/&gt;

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>gdt5deste2jsgjndefw8v73yt8y7586</sha1>
    </revision>
    <revision>
      <id>1166</id>
      <parentid>1165</parentid>
      <timestamp>2016-02-24T17:16:38Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Added Image</comment>
      <origin>1166</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2200" sha1="clirj43179gb4vgplubctnefdkfjo2v" xml:space="preserve">{{Person|
| ibizo = Mgiyelwa Simon Ntuli
| isithombe = MS Ntuli.png
| umsebenzi = Umtloli
| ubelethwe ngo = 08 Arhostosi 1949
| indawo yo kubelethwa = Nompeketswana, Ekungwini
| wahlongakala ngo = 
| indawo yo hlongakala = 
}}
'''Mgiyelwa Simon Ntuli''' (wabelethwa ngomhlaka 08 Arhostosi 1949) ngumtloli odumileko wobukondlo besindebele begodu wabelethelwa koNompeketswana, esiphandeni sekungwini (Bronkhorstspruit).&lt;ref name=ph1&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt;

==Ifundo==
Wathoma ukufunda esikolweni samaRoma, eSdudu (Eastwood), ePitori l, (City of Tshwane) Emvakwalapo wangena eenkolweni ezincani ezilandelako:
* Kgoro Bantu School, eKungwini
* Serenity Bantu School, eRayton.
Waphumelela ibanga lesithandathu eSedibeng State School, eCullinan.Ifundo ephakamileko wayifumana eBoekenhoutfontein Secondary School, eMabopane. Waphetha
ibanga lesumi eMamelodi High School, eMamelodi. Ubutitjhere wabufundele eRehlahliwe Teacher Training College, waqedaiPrimary Teachers Certicatengo – 1974&lt;ref name=ph1&gt;&lt;/ref&gt;. Kusukela
lapho wafunda iimfundo zakhe asekhaya asebenza wafumana iziqu sakhe ngendlela elandelako:

# MA: University of Witwatersrand-eJohannesburd.
# BA(Hons): University of Pretoria.
# BA: University of South Africa, ePretoria.
# FDE: Rand Afrikaans Universiteit, eJohannesburg.

==Ubutloli==
Wathoma ukutlola iincwadi ngerherho leTsengo. Kwagadangiswa iTsengo lokuthoma ngonyaka ka 1991, kwaphethangetsengo, ngonyaka ka – 1995&lt;ref name=ph1&gt;&lt;/ref&gt;. Umncopho weTsengo kufundisa abafundi uthabela ubukondlo ne enkondlo begodu nokulandelako:

* Ukwazi ubonga.
* Ukulimuka amatshayo wobukondlo.
* Ukukghona ukutlhama linkondlo.
* Ukutsenga iinkondlo.
* Ukuragela phambili ngezesikolo bukondlo begudu nesikolo bukondlo epilweni.

Amabanga la anembakhona ekuthini irherho leTsengo lijamele ukusiza abafundi ukwazi ngezobukondlo ne enkondlo. Bamalimi amanye nabo bangasizeka kwamambala. Ngetsengo batsengeke ngelimuko lobukondlo.

==Isithasiselo==
&lt;references/&gt;

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>clirj43179gb4vgplubctnefdkfjo2v</sha1>
    </revision>
    <revision>
      <id>1167</id>
      <parentid>1166</parentid>
      <timestamp>2024-10-14T13:47:05Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>22 revisions imported</comment>
      <origin>1166</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2200" sha1="clirj43179gb4vgplubctnefdkfjo2v" xml:space="preserve">{{Person|
| ibizo = Mgiyelwa Simon Ntuli
| isithombe = MS Ntuli.png
| umsebenzi = Umtloli
| ubelethwe ngo = 08 Arhostosi 1949
| indawo yo kubelethwa = Nompeketswana, Ekungwini
| wahlongakala ngo = 
| indawo yo hlongakala = 
}}
'''Mgiyelwa Simon Ntuli''' (wabelethwa ngomhlaka 08 Arhostosi 1949) ngumtloli odumileko wobukondlo besindebele begodu wabelethelwa koNompeketswana, esiphandeni sekungwini (Bronkhorstspruit).&lt;ref name=ph1&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt;

==Ifundo==
Wathoma ukufunda esikolweni samaRoma, eSdudu (Eastwood), ePitori l, (City of Tshwane) Emvakwalapo wangena eenkolweni ezincani ezilandelako:
* Kgoro Bantu School, eKungwini
* Serenity Bantu School, eRayton.
Waphumelela ibanga lesithandathu eSedibeng State School, eCullinan.Ifundo ephakamileko wayifumana eBoekenhoutfontein Secondary School, eMabopane. Waphetha
ibanga lesumi eMamelodi High School, eMamelodi. Ubutitjhere wabufundele eRehlahliwe Teacher Training College, waqedaiPrimary Teachers Certicatengo – 1974&lt;ref name=ph1&gt;&lt;/ref&gt;. Kusukela
lapho wafunda iimfundo zakhe asekhaya asebenza wafumana iziqu sakhe ngendlela elandelako:

# MA: University of Witwatersrand-eJohannesburd.
# BA(Hons): University of Pretoria.
# BA: University of South Africa, ePretoria.
# FDE: Rand Afrikaans Universiteit, eJohannesburg.

==Ubutloli==
Wathoma ukutlola iincwadi ngerherho leTsengo. Kwagadangiswa iTsengo lokuthoma ngonyaka ka 1991, kwaphethangetsengo, ngonyaka ka – 1995&lt;ref name=ph1&gt;&lt;/ref&gt;. Umncopho weTsengo kufundisa abafundi uthabela ubukondlo ne enkondlo begodu nokulandelako:

* Ukwazi ubonga.
* Ukulimuka amatshayo wobukondlo.
* Ukukghona ukutlhama linkondlo.
* Ukutsenga iinkondlo.
* Ukuragela phambili ngezesikolo bukondlo begudu nesikolo bukondlo epilweni.

Amabanga la anembakhona ekuthini irherho leTsengo lijamele ukusiza abafundi ukwazi ngezobukondlo ne enkondlo. Bamalimi amanye nabo bangasizeka kwamambala. Ngetsengo batsengeke ngelimuko lobukondlo.

==Isithasiselo==
&lt;references/&gt;

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>clirj43179gb4vgplubctnefdkfjo2v</sha1>
    </revision>
    <revision>
      <id>2160</id>
      <parentid>1167</parentid>
      <timestamp>2024-11-27T06:01:26Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>UMgiyelwa Simon Ntuli</comment>
      <origin>2160</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2199" sha1="kkloidaejyi4xsg84qdjp33db9qxvvr" xml:space="preserve">{{Person|
| ibizo = Mgiyelwa Simon Ntuli
| isithombe = MS Ntuli.png
| umsebenzi = Umtloli
| ubelethwe ngo = 08 Arhostosi 1949
| indawo yo kubelethwa = Nompeketswana, Ekungwini
| wahlongakala ngo = 
| indawo yo hlongakala = 
}}
'''UMgiyelwa Simon Ntuli''' (wabelethwa ngomhlaka 08 Arhostosi 1949) ngumtloli odumileko wobukondlo besindebele begodu wabelethelwa koNompeketswana, esiphandeni sekungwini (Bronkhorstspruit).&lt;ref name=ph1&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt;

==Ifundo==
Wathoma ukufunda esikolweni samaRoma, eSdudu (Eastwood), ePitori l, (City of Tshwane) Emvakwalapo wangena eenkolweni ezincani ezilandelako:
* Kgoro Bantu School, eKungwini
* Serenity Bantu School, eRayton.
Waphumelela ibanga lesithandathu eSedibeng State School, eCullinan.Ifundo ephakamileko wayifumana eBoekenhoutfontein Secondary School, eMabopane. Waphetha
ibanga lesumi eMamelodi High School, eMamelodi. Ubutitjhere wabufundele eRehlahliwe Teacher Training College, waqedaiPrimary Teachers Certicatengo – 1974&lt;ref name=ph1&gt;&lt;/ref&gt;. Kusukela
lapho wafunda iimfundo zakhe asekhaya asebenza wafumana iziqu sakhe ngendlela elandelako:

# MA: University of Witwatersrand-eJohannesburd.
# BA(Hons): University of Pretoria.
# BA: University of South Africa, ePretoria.
# FDE: Rand Afrikaans Universiteit, eJohannesburg.

==Ubutloli==
Wathoma ukutlola iincwadi ngerherho leTsengo. Kwagadangiswa iTsengo lokuthoma ngonyaka ka 1991, kwaphethangetsengo, ngonyaka ka – 1995&lt;ref name=ph1&gt;&lt;/ref&gt;. Umncopho weTsengo kufundisa abafundi uthabela ubukondlo ne enkondlo begodu nokulandelako:

* Ukwazi ubonga.
* Ukulimuka amatshayo wobukondlo.
* Ukukghona ukutlhama linkondlo.
* Ukutsenga iinkondlo.
* Ukuragela phambili ngezesikolo bukondlo begudu nesikolo bukondlo epilweni.

Amabanga la anembakhona ekuthini irherho leTsengo lijamele ukusiza abafundi ukwazi ngezobukondlo ne enkondlo. Bamalimi amanye nabo bangasizeka kwamambala. Ngetsengo batsengeke ngelimuko lobukondlo.

==Isithasiselo==
{{Reflist}}

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>kkloidaejyi4xsg84qdjp33db9qxvvr</sha1>
    </revision>
    <revision>
      <id>2219</id>
      <parentid>2160</parentid>
      <timestamp>2024-11-29T09:45:30Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <comment>kuNtaka 2011</comment>
      <origin>2219</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2201" sha1="1f4cm0dqkqige8rq5wa1n30l3rkap2x" xml:space="preserve">{{Person|
| ibizo = Mgiyelwa Simon Ntuli
| isithombe = MS Ntuli.png
| umsebenzi = Umtloli
| ubelethwe ngo = 08 Arhostosi 1949
| indawo yo kubelethwa = Nompeketswana, Ekungwini
| wahlongakala ngo = 
| indawo yo hlongakala = 
}}
'''UMgiyelwa Simon Ntuli''' (wabelethwa ngomhlaka 08 Arhostosi 1949) ngumtloli odumileko wobukondlo besindebele begodu wabelethelwa koNompeketswana, esiphandeni sekungwini (Bronkhorstspruit).&lt;ref name=ph1&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (kuNtaka 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt;

==Ifundo==
Wathoma ukufunda esikolweni samaRoma, eSdudu (Eastwood), ePitori l, (City of Tshwane) Emvakwalapo wangena eenkolweni ezincani ezilandelako:
* Kgoro Bantu School, eKungwini
* Serenity Bantu School, eRayton.
Waphumelela ibanga lesithandathu eSedibeng State School, eCullinan.Ifundo ephakamileko wayifumana eBoekenhoutfontein Secondary School, eMabopane. Waphetha
ibanga lesumi eMamelodi High School, eMamelodi. Ubutitjhere wabufundele eRehlahliwe Teacher Training College, waqedaiPrimary Teachers Certicatengo – 1974&lt;ref name=ph1&gt;&lt;/ref&gt;. Kusukela
lapho wafunda iimfundo zakhe asekhaya asebenza wafumana iziqu sakhe ngendlela elandelako:

# MA: University of Witwatersrand-eJohannesburd.
# BA(Hons): University of Pretoria.
# BA: University of South Africa, ePretoria.
# FDE: Rand Afrikaans Universiteit, eJohannesburg.

==Ubutloli==
Wathoma ukutlola iincwadi ngerherho leTsengo. Kwagadangiswa iTsengo lokuthoma ngonyaka ka 1991, kwaphethangetsengo, ngonyaka ka – 1995&lt;ref name=ph1&gt;&lt;/ref&gt;. Umncopho weTsengo kufundisa abafundi uthabela ubukondlo ne enkondlo begodu nokulandelako:

* Ukwazi ubonga.
* Ukulimuka amatshayo wobukondlo.
* Ukukghona ukutlhama linkondlo.
* Ukutsenga iinkondlo.
* Ukuragela phambili ngezesikolo bukondlo begudu nesikolo bukondlo epilweni.

Amabanga la anembakhona ekuthini irherho leTsengo lijamele ukusiza abafundi ukwazi ngezobukondlo ne enkondlo. Bamalimi amanye nabo bangasizeka kwamambala. Ngetsengo batsengeke ngelimuko lobukondlo.

==Isithasiselo==
{{Reflist}}

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>1f4cm0dqkqige8rq5wa1n30l3rkap2x</sha1>
    </revision>
    <revision>
      <id>2220</id>
      <parentid>2219</parentid>
      <timestamp>2024-11-29T09:48:06Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>22 kuNhlolanja 2016</comment>
      <origin>2220</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2213" sha1="g2vn74sqa91uxzm4rhtoqs1zbp9zv47" xml:space="preserve">{{Person|
| ibizo = Mgiyelwa Simon Ntuli
| isithombe = MS Ntuli.png
| umsebenzi = Umtloli
| ubelethwe ngo = 08 Arhostosi 1949
| indawo yo kubelethwa = Nompeketswana, Ekungwini
| wahlongakala ngo = 
| indawo yo hlongakala = 
}}
'''UMgiyelwa Simon Ntuli''' (wabelethwa ngomhlaka 08 Arhostosi 1949) ngumtloli odumileko wobukondlo besindebele begodu wabelethelwa koNompeketswana, esiphandeni sekungwini (Bronkhorstspruit).&lt;ref name=ph1&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (kuNtaka 2011) - '''National Library of South Africa'''. Ibuyiselwe mhlazi-22 kuNhlolanja 2016.&lt;/ref&gt;

==Ifundo==
Wathoma ukufunda esikolweni samaRoma, eSdudu (Eastwood), ePitori l, (City of Tshwane) Emvakwalapo wangena eenkolweni ezincani ezilandelako:
* Kgoro Bantu School, eKungwini
* Serenity Bantu School, eRayton.
Waphumelela ibanga lesithandathu eSedibeng State School, eCullinan.Ifundo ephakamileko wayifumana eBoekenhoutfontein Secondary School, eMabopane. Waphetha
ibanga lesumi eMamelodi High School, eMamelodi. Ubutitjhere wabufundele eRehlahliwe Teacher Training College, waqedaiPrimary Teachers Certicatengo – 1974&lt;ref name=ph1&gt;&lt;/ref&gt;. Kusukela
lapho wafunda iimfundo zakhe asekhaya asebenza wafumana iziqu sakhe ngendlela elandelako:

# MA: University of Witwatersrand-eJohannesburd.
# BA(Hons): University of Pretoria.
# BA: University of South Africa, ePretoria.
# FDE: Rand Afrikaans Universiteit, eJohannesburg.

==Ubutloli==
Wathoma ukutlola iincwadi ngerherho leTsengo. Kwagadangiswa iTsengo lokuthoma ngonyaka ka 1991, kwaphethangetsengo, ngonyaka ka – 1995&lt;ref name=ph1&gt;&lt;/ref&gt;. Umncopho weTsengo kufundisa abafundi uthabela ubukondlo ne enkondlo begodu nokulandelako:

* Ukwazi ubonga.
* Ukulimuka amatshayo wobukondlo.
* Ukukghona ukutlhama linkondlo.
* Ukutsenga iinkondlo.
* Ukuragela phambili ngezesikolo bukondlo begudu nesikolo bukondlo epilweni.

Amabanga la anembakhona ekuthini irherho leTsengo lijamele ukusiza abafundi ukwazi ngezobukondlo ne enkondlo. Bamalimi amanye nabo bangasizeka kwamambala. Ngetsengo batsengeke ngelimuko lobukondlo.

==Isithasiselo==
{{Reflist}}

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>g2vn74sqa91uxzm4rhtoqs1zbp9zv47</sha1>
    </revision>
    <revision>
      <id>2634</id>
      <parentid>2220</parentid>
      <timestamp>2025-04-03T19:10:29Z</timestamp>
      <contributor>
        <username>Rachmat04</username>
        <id>32</id>
      </contributor>
      <minor />
      <origin>2634</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2209" sha1="0jfef6c920zhffe4dkfzcdxb2fpixko" xml:space="preserve">{{Person|
| ibizo = Mgiyelwa Simon Ntuli
| isithombe = MS Ntuli.png
| umsebenzi = Umtloli
| ubelethwe ngo = 08 Arhostosi 1949
| indawo yo kubelethwa = Nompeketswana, Ekungwini
| wahlongakala ngo = 
| indawo yo hlongakala = 
}}
'''UMgiyelwa Simon Ntuli''' (wabelethwa ngomhlaka 08 Arhostosi 1949) ngumtloli odumileko wobukondlo besindebele begodu wabelethelwa koNompeketswana, esiphandeni sekungwini (Bronkhorstspruit).&lt;ref name=ph1&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (kuNtaka 2011) - '''National Library of South Africa'''. Ibuyiselwe mhlazi-22 kuNhlolanja 2016.&lt;/ref&gt;

== Ifundo ==
Wathoma ukufunda esikolweni samaRoma, eSdudu (Eastwood), ePitori l, (City of Tshwane) Emvakwalapo wangena eenkolweni ezincani ezilandelako:
* Kgoro Bantu School, eKungwini
* Serenity Bantu School, eRayton.
Waphumelela ibanga lesithandathu eSedibeng State School, eCullinan.Ifundo ephakamileko wayifumana eBoekenhoutfontein Secondary School, eMabopane. Waphetha
ibanga lesumi eMamelodi High School, eMamelodi. Ubutitjhere wabufundele eRehlahliwe Teacher Training College, waqedaiPrimary Teachers Certicatengo – 1974&lt;ref name=ph1/&gt;. Kusukela
lapho wafunda iimfundo zakhe asekhaya asebenza wafumana iziqu sakhe ngendlela elandelako:

# MA: University of Witwatersrand-eJohannesburd.
# BA(Hons): University of Pretoria.
# BA: University of South Africa, ePretoria.
# FDE: Rand Afrikaans Universiteit, eJohannesburg.

== Ubutloli ==
Wathoma ukutlola iincwadi ngerherho leTsengo. Kwagadangiswa iTsengo lokuthoma ngonyaka ka 1991, kwaphethangetsengo, ngonyaka ka – 1995&lt;ref name=ph1/&gt;. Umncopho weTsengo kufundisa abafundi uthabela ubukondlo ne enkondlo begodu nokulandelako:

* Ukwazi ubonga.
* Ukulimuka amatshayo wobukondlo.
* Ukukghona ukutlhama linkondlo.
* Ukutsenga iinkondlo.
* Ukuragela phambili ngezesikolo bukondlo begudu nesikolo bukondlo epilweni.

Amabanga la anembakhona ekuthini irherho leTsengo lijamele ukusiza abafundi ukwazi ngezobukondlo ne enkondlo. Bamalimi amanye nabo bangasizeka kwamambala. Ngetsengo batsengeke ngelimuko lobukondlo.

== Isithasiselo ==
{{Reflist}}

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>0jfef6c920zhffe4dkfzcdxb2fpixko</sha1>
    </revision>
  </page>
  <page>
    <title>Moses Mahlangu</title>
    <ns>0</ns>
    <id>221</id>
    <revision>
      <id>1168</id>
      <timestamp>2016-02-26T20:41:04Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;U '''Moses Sovumani Mahlangu''' kaZimkhona ngumtloli wemidlalo yesindebele, begodu waziwa ngetlolo lakhe elithi ''&quot;Iinkesi Ezome Kere&quot;''&lt;ref name=ph1&gt;&quot;[http://www.mml.co.za/li...&quot;</comment>
      <origin>1168</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1322" sha1="9czkqan5gktklgk4oclqljb6f61zsmn" xml:space="preserve">U '''Moses Sovumani Mahlangu''' kaZimkhona ngumtloli wemidlalo yesindebele, begodu waziwa ngetlolo lakhe elithi ''&quot;Iinkesi Ezome Kere&quot;''&lt;ref name=ph1&gt;&quot;[http://www.mml.co.za/literature-awards 2012 YOUTH DRAMA AWARD WINNERS AND RUNNERS-UP]&quot; - '''Maskew Miller Longman'''. Retrieved 26 February 2016&lt;/ref&gt; . Wabelethelwa eKlipgat esifundeni seThlwagwini Tjhingalanga ngomnyaka ka 1974.&lt;ref name=ph2&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt; 

Wangena isikolo e-Keikumetsi Primary School emva kwalapho waya eKuphumeleni Combined School endaweni yePhumula eMpumalanga. Waqeda ibanga letjhumi eBongumusa High School ePhumula. Wenza iimfundo zakhe ze BA ku -Sociology ne Psychology neemfundo ze BA Hons ku Sociology eyunevesithi ye-Vista ngomnyaka ka 1996 nango 1997, walandelisa ngeemfundo ze Masters ku-Sociology neYunivesithi yePitori.&lt;ref name=ph2&gt;&lt;/ref&gt;

Umtloli lo wathumba indawoyesibili kuphalisano lobutloli lakwa Maskew Miller Longman kusigaba soluthja ngo 2012.&lt;ref name=ph1&gt;&lt;/ref&gt;

Kwagadesi usebenzela iKoro yezesiPholisa yeSewula Afrika (SAPS).&lt;ref name=ph2&gt;&lt;/ref&gt;

==Isithasiselo==
&lt;references/&gt;

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>9czkqan5gktklgk4oclqljb6f61zsmn</sha1>
    </revision>
    <revision>
      <id>1169</id>
      <parentid>1168</parentid>
      <timestamp>2021-02-01T03:59:06Z</timestamp>
      <contributor>
        <username>incubator&gt;InternetArchiveBot</username>
        <id>0</id>
      </contributor>
      <comment>Rescuing 1 sources and tagging 0 as dead.) #IABot (v2.0.8</comment>
      <origin>1169</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1365" sha1="s3z93jnfdo7mtiu2y1p5lnal4mq6sd0" xml:space="preserve">U '''Moses Sovumani Mahlangu''' kaZimkhona ngumtloli wemidlalo yesindebele, begodu waziwa ngetlolo lakhe elithi ''&quot;Iinkesi Ezome Kere&quot;''&lt;ref name=ph1&gt;&quot;[https://web.archive.org/web/20140223090335/http://www.mml.co.za/literature-awards 2012 YOUTH DRAMA AWARD WINNERS AND RUNNERS-UP]&quot; - '''Maskew Miller Longman'''. Retrieved 26 February 2016&lt;/ref&gt; . Wabelethelwa eKlipgat esifundeni seThlwagwini Tjhingalanga ngomnyaka ka 1974.&lt;ref name=ph2&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt; 

Wangena isikolo e-Keikumetsi Primary School emva kwalapho waya eKuphumeleni Combined School endaweni yePhumula eMpumalanga. Waqeda ibanga letjhumi eBongumusa High School ePhumula. Wenza iimfundo zakhe ze BA ku -Sociology ne Psychology neemfundo ze BA Hons ku Sociology eyunevesithi ye-Vista ngomnyaka ka 1996 nango 1997, walandelisa ngeemfundo ze Masters ku-Sociology neYunivesithi yePitori.&lt;ref name=ph2&gt;&lt;/ref&gt;

Umtloli lo wathumba indawoyesibili kuphalisano lobutloli lakwa Maskew Miller Longman kusigaba soluthja ngo 2012.&lt;ref name=ph1&gt;&lt;/ref&gt;

Kwagadesi usebenzela iKoro yezesiPholisa yeSewula Afrika (SAPS).&lt;ref name=ph2&gt;&lt;/ref&gt;

==Isithasiselo==
&lt;references/&gt;

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>s3z93jnfdo7mtiu2y1p5lnal4mq6sd0</sha1>
    </revision>
    <revision>
      <id>1170</id>
      <parentid>1169</parentid>
      <timestamp>2024-03-08T10:20:28Z</timestamp>
      <contributor>
        <username>incubator&gt;Simphiwe22</username>
        <id>0</id>
      </contributor>
      <comment>Added content</comment>
      <origin>1170</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1367" sha1="h08kan2qlotd2vkoc823fbf0evp7lp3" xml:space="preserve">U '''Moses Sovumani Mahlangu''' kaZimkhona ngumtloli wemidlalo yesindebele, begodu waziwa ngetlolo lakhe elithi ''&quot;Iinkesi Ezome Kere&quot;''&lt;ref name=ph1&gt;&quot;[https://web.archive.org/web/20140223090335/http://www.mml.co.za/literature-awards 2012 YOUTH DRAMA AWARD WINNERS AND RUNNERS-UP]&quot; - '''Maskew Miller Longman'''. Retrieved 26 February 2016&lt;/ref&gt; . Wabelethelwa eKlipgat esifundeni seThlwagwini Tjhingalanga ngomnyaka ka 1974.&lt;ref name=ph2&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt; 

Wangena isikolo e-Keikumetsi Primary School emva kwalapho waya eKuphumeleni Combined School endaweni yePhumula eMpumalanga. Waqeda ibanga letjhumi eBongumusa High School ePhumula. Wenza iimfundo zakhe ze BA ku -Sociology ne Psychology neemfundo ze BA Hons ku Sociology eyunevesithi ye-Vista ngomnyaka ka 1996 nango 1997, walandelisa ngeemfundo ze Masters ku-Sociology neYunivesithi yePitori.. &lt;ref name=ph2&gt;&lt;/ref&gt;

Umtloli lo wathumba indawoyesibili kuphalisano lobutloli lakwa Maskew Miller Longman kusigaba soluthja ngo 2012.&lt;ref name=ph1&gt;&lt;/ref&gt;

Kwagadesi usebenzela iKoro yezesiPholisa yeSewula Afrika (SAPS).&lt;ref name=ph2&gt;&lt;/ref&gt;

==Isithasiselo==
&lt;references/&gt;

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>h08kan2qlotd2vkoc823fbf0evp7lp3</sha1>
    </revision>
    <revision>
      <id>1171</id>
      <parentid>1170</parentid>
      <timestamp>2024-03-08T11:19:21Z</timestamp>
      <contributor>
        <username>incubator&gt;Thandeka179</username>
        <id>0</id>
      </contributor>
      <comment>Added content</comment>
      <origin>1171</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1367" sha1="5jagz6omhttz3nz8dq6joasvf4bk165" xml:space="preserve">U '''Moses Sovumani Mahlangu''' kaZimkhona ngumtloli wemidlalo yesindebele, begodu waziwa ngetlolo lakhe elithi ''&quot;Iinkesi Ezome Kere&quot;''&lt;ref name=ph1&gt;&quot;[https://web.archive.org/web/20140223090335/http://www.mml.co.za/literature-awards 2012 YOUTH DRAMA AWARD WINNERS AND RUNNERS-UP]&quot; - '''Maskew Miller Longman'''. Retrieved 26 February 2016&lt;/ref&gt; . Wabelethelwa eKlipgat esifundeni seThlwagwiniiTjhingalanga ngomnyaka ka 1974.&lt;ref name=ph2&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt; 

Wangena isikolo e-Keikumetsi Primary School emva kwalapho waya eKuphumeleni Combined School endaweni yePhumula eMpumalanga. Waqeda ibanga letjhumi eBongumusa High School ePhumula. Wenza iimfundo zakhe ze BA ku -Sociology ne Psychology neemfundo ze BA Hons ku Sociology eyunevesithi ye-Vista ngomnyaka ka 1996 nango 1997, walandelisa ngeemfundo ze Masters ku-Sociology neYunivesithi yePitori.. &lt;ref name=ph2&gt;&lt;/ref&gt;

Umtloli lo wathumba indawoyesibili kuphalisano lobutloli lakwa Maskew Miller Longman kusigaba soluthja ngo 2012.&lt;ref name=ph1&gt;&lt;/ref&gt;

Kwagadesi usebenzela iKoro yezesiPholisa yeSewula Afrika (SAPS).&lt;ref name=ph2&gt;&lt;/ref&gt;

==Isithasiselo==
&lt;references/&gt;

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>5jagz6omhttz3nz8dq6joasvf4bk165</sha1>
    </revision>
    <revision>
      <id>1172</id>
      <parentid>1171</parentid>
      <timestamp>2024-10-14T13:47:05Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>4 revisions imported</comment>
      <origin>1171</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1367" sha1="5jagz6omhttz3nz8dq6joasvf4bk165" xml:space="preserve">U '''Moses Sovumani Mahlangu''' kaZimkhona ngumtloli wemidlalo yesindebele, begodu waziwa ngetlolo lakhe elithi ''&quot;Iinkesi Ezome Kere&quot;''&lt;ref name=ph1&gt;&quot;[https://web.archive.org/web/20140223090335/http://www.mml.co.za/literature-awards 2012 YOUTH DRAMA AWARD WINNERS AND RUNNERS-UP]&quot; - '''Maskew Miller Longman'''. Retrieved 26 February 2016&lt;/ref&gt; . Wabelethelwa eKlipgat esifundeni seThlwagwiniiTjhingalanga ngomnyaka ka 1974.&lt;ref name=ph2&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt; 

Wangena isikolo e-Keikumetsi Primary School emva kwalapho waya eKuphumeleni Combined School endaweni yePhumula eMpumalanga. Waqeda ibanga letjhumi eBongumusa High School ePhumula. Wenza iimfundo zakhe ze BA ku -Sociology ne Psychology neemfundo ze BA Hons ku Sociology eyunevesithi ye-Vista ngomnyaka ka 1996 nango 1997, walandelisa ngeemfundo ze Masters ku-Sociology neYunivesithi yePitori.. &lt;ref name=ph2&gt;&lt;/ref&gt;

Umtloli lo wathumba indawoyesibili kuphalisano lobutloli lakwa Maskew Miller Longman kusigaba soluthja ngo 2012.&lt;ref name=ph1&gt;&lt;/ref&gt;

Kwagadesi usebenzela iKoro yezesiPholisa yeSewula Afrika (SAPS).&lt;ref name=ph2&gt;&lt;/ref&gt;

==Isithasiselo==
&lt;references/&gt;

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>5jagz6omhttz3nz8dq6joasvf4bk165</sha1>
    </revision>
    <revision>
      <id>1879</id>
      <parentid>1172</parentid>
      <timestamp>2024-11-12T18:45:26Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <origin>1879</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1364" sha1="0fjeszq8ckgnj35eho4ysekps3ld81i" xml:space="preserve">U '''Moses Sovumani Mahlangu''' kaZimkhona ngumtloli wemidlalo yesindebele, begodu waziwa ngetlolo lakhe elithi ''&quot;Iinkesi Ezome Kere&quot;''&lt;ref name=ph1&gt;&quot;[https://web.archive.org/web/20140223090335/http://www.mml.co.za/literature-awards 2012 YOUTH DRAMA AWARD WINNERS AND RUNNERS-UP]&quot; - '''Maskew Miller Longman'''. Retrieved 26 February 2016&lt;/ref&gt; . Wabelethelwa eKlipgat esifundeni seThlwagwiniiTjhingalanga ngomnyaka ka 1974.&lt;ref name=ph2&gt;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt; 

Wangena isikolo e-Keikumetsi Primary School emva kwalapho waya eKuphumeleni Combined School endaweni yePhumula eMpumalanga. Waqeda ibanga letjhumi eBongumusa High School ePhumula. Wenza iimfundo zakhe ze BA ku -Sociology ne Psychology neemfundo ze BA Hons ku Sociology eyunevesithi ye-Vista ngomnyaka ka 1996 nango 1997, walandelisa ngeemfundo ze Masters ku-Sociology neYunivesithi yePitori.&lt;ref name=ph2&gt;&lt;/ref&gt;

Umtloli lo wathumba indawoyesibili kuphalisano lobutloli lakwa Maskew Miller Longman kusigaba soluthja ngo 2012.&lt;ref name=ph1&gt;&lt;/ref&gt;

Kwagadesi usebenzela iKoro yezesiPholisa yeSewula Afrika (SAPS).&lt;ref name=ph2&gt;&lt;/ref&gt;

==Isithasiselo==
&lt;references/&gt;

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>0fjeszq8ckgnj35eho4ysekps3ld81i</sha1>
    </revision>
    <revision>
      <id>2203</id>
      <parentid>1879</parentid>
      <timestamp>2024-11-29T07:27:01Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <comment>/* Isithasiselo */Reflist</comment>
      <origin>2203</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1362" sha1="n2eoblvrxpmt9qq48fgn9odknd06yqo" xml:space="preserve">U '''Moses Sovumani Mahlangu''' kaZimkhona ngumtloli wemidlalo yesindebele, begodu waziwa ngetlolo lakhe elithi ''&quot;Iinkesi Ezome Kere&quot;''&lt;ref name=ph1&gt;&quot;[https://web.archive.org/web/20140223090335/http://www.mml.co.za/literature-awards 2012 YOUTH DRAMA AWARD WINNERS AND RUNNERS-UP]&quot; - '''Maskew Miller Longman'''. Retrieved 26 February 2016&lt;/ref&gt; . Wabelethelwa eKlipgat esifundeni seThlwagwiniiTjhingalanga ngomnyaka ka 1974.&lt;ref name=ph2&gt;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt; 

Wangena isikolo e-Keikumetsi Primary School emva kwalapho waya eKuphumeleni Combined School endaweni yePhumula eMpumalanga. Waqeda ibanga letjhumi eBongumusa High School ePhumula. Wenza iimfundo zakhe ze BA ku -Sociology ne Psychology neemfundo ze BA Hons ku Sociology eyunevesithi ye-Vista ngomnyaka ka 1996 nango 1997, walandelisa ngeemfundo ze Masters ku-Sociology neYunivesithi yePitori.&lt;ref name=ph2&gt;&lt;/ref&gt;

Umtloli lo wathumba indawoyesibili kuphalisano lobutloli lakwa Maskew Miller Longman kusigaba soluthja ngo 2012.&lt;ref name=ph1&gt;&lt;/ref&gt;

Kwagadesi usebenzela iKoro yezesiPholisa yeSewula Afrika (SAPS).&lt;ref name=ph2&gt;&lt;/ref&gt;

==Isithasiselo==
{{Reflist}}

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>n2eoblvrxpmt9qq48fgn9odknd06yqo</sha1>
    </revision>
    <revision>
      <id>2216</id>
      <parentid>2203</parentid>
      <timestamp>2024-11-29T09:38:14Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <comment>UMoses Sovumani Mahlangu</comment>
      <origin>2216</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1361" sha1="c27zncy23tey68vd53g2qa2joced977" xml:space="preserve">'''UMoses Sovumani Mahlangu''' kaZimkhona ngumtloli wemidlalo yesindebele, begodu waziwa ngetlolo lakhe elithi ''&quot;Iinkesi Ezome Kere&quot;''&lt;ref name=ph1&gt;&quot;[https://web.archive.org/web/20140223090335/http://www.mml.co.za/literature-awards 2012 YOUTH DRAMA AWARD WINNERS AND RUNNERS-UP]&quot; - '''Maskew Miller Longman'''. Retrieved 26 February 2016&lt;/ref&gt; . Wabelethelwa eKlipgat esifundeni seThlwagwiniiTjhingalanga ngomnyaka ka 1974.&lt;ref name=ph2&gt;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt; 

Wangena isikolo e-Keikumetsi Primary School emva kwalapho waya eKuphumeleni Combined School endaweni yePhumula eMpumalanga. Waqeda ibanga letjhumi eBongumusa High School ePhumula. Wenza iimfundo zakhe ze BA ku -Sociology ne Psychology neemfundo ze BA Hons ku Sociology eyunevesithi ye-Vista ngomnyaka ka 1996 nango 1997, walandelisa ngeemfundo ze Masters ku-Sociology neYunivesithi yePitori.&lt;ref name=ph2&gt;&lt;/ref&gt;

Umtloli lo wathumba indawoyesibili kuphalisano lobutloli lakwa Maskew Miller Longman kusigaba soluthja ngo 2012.&lt;ref name=ph1&gt;&lt;/ref&gt;

Kwagadesi usebenzela iKoro yezesiPholisa yeSewula Afrika (SAPS).&lt;ref name=ph2&gt;&lt;/ref&gt;

==Isithasiselo==
{{Reflist}}

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>c27zncy23tey68vd53g2qa2joced977</sha1>
    </revision>
    <revision>
      <id>2217</id>
      <parentid>2216</parentid>
      <timestamp>2024-11-29T09:38:59Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <comment>ref</comment>
      <origin>2217</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1360" sha1="tfbjzslqnqapgdj2w47zprgqq631khe" xml:space="preserve">'''UMoses Sovumani Mahlangu''' kaZimkhona ngumtloli wemidlalo yesindebele, begodu waziwa ngetlolo lakhe elithi ''&quot;Iinkesi Ezome Kere&quot;''.&lt;ref name=ph1&gt;&quot;[https://web.archive.org/web/20140223090335/http://www.mml.co.za/literature-awards 2012 YOUTH DRAMA AWARD WINNERS AND RUNNERS-UP]&quot; - '''Maskew Miller Longman'''. Retrieved 26 February 2016&lt;/ref&gt; Wabelethelwa eKlipgat esifundeni seThlwagwiniiTjhingalanga ngomnyaka ka 1974.&lt;ref name=ph2&gt;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt; 

Wangena isikolo e-Keikumetsi Primary School emva kwalapho waya eKuphumeleni Combined School endaweni yePhumula eMpumalanga. Waqeda ibanga letjhumi eBongumusa High School ePhumula. Wenza iimfundo zakhe ze BA ku -Sociology ne Psychology neemfundo ze BA Hons ku Sociology eyunevesithi ye-Vista ngomnyaka ka 1996 nango 1997, walandelisa ngeemfundo ze Masters ku-Sociology neYunivesithi yePitori.&lt;ref name=ph2&gt;&lt;/ref&gt;

Umtloli lo wathumba indawoyesibili kuphalisano lobutloli lakwa Maskew Miller Longman kusigaba soluthja ngo 2012.&lt;ref name=ph1&gt;&lt;/ref&gt;

Kwagadesi usebenzela iKoro yezesiPholisa yeSewula Afrika (SAPS).&lt;ref name=ph2&gt;&lt;/ref&gt;

==Isithasiselo==
{{Reflist}}

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>tfbjzslqnqapgdj2w47zprgqq631khe</sha1>
    </revision>
    <revision>
      <id>6167</id>
      <parentid>2217</parentid>
      <timestamp>2026-02-14T12:22:18Z</timestamp>
      <contributor>
        <username>Nhlanhla NaLamula</username>
        <id>1365</id>
      </contributor>
      <minor />
      <comment>Grammar and punctuation marks</comment>
      <origin>6167</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1357" sha1="axwfzvqsvrujafns1pdzbccrtq1adpo" xml:space="preserve">'''UMoses Sovumani Mahlangu''' kaZimkhona mtloli wemidlalo yesiNdebele, begodu waziwa ngomtlolo wakhe othi ''&quot;Iinkesi Ezome Kere&quot;''.&lt;ref name=ph1&gt;&quot;[https://web.archive.org/web/20140223090335/http://www.mml.co.za/literature-awards 2012 YOUTH DRAMA AWARD WINNERS AND RUNNERS-UP]&quot; - '''Maskew Miller Longman'''. Retrieved 26 February 2016&lt;/ref&gt; Wabelethwa eKlipgat esifundeni seThlwagwini Tjhingalanga ngomnyaka ka-1974.&lt;ref name=ph2&gt;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt; 

Wangena isikolo e-Keikumetsi Primary School emva kwalakho waya eKuphumeleni Combined School endaweni yePhumula eMpumalanga. Waqeda ibanga letjhumi eBongumusa High School ePhumula. Wenza iimfundo zakhe ze-BA ku-Sociology ne-Psychology, neemfundo ze-BA Hons ku-Sociology eYunivesithi ye-Vista ngomnyaka ka-1996 nango-1997. Walandela ngeemfundo ze-Masters ku-Sociology neYunivesithi yePitori.&lt;ref name=ph2&gt;&lt;/ref&gt;

Umtloli lo wathumba indawo yesibili kuphaliswano lobutloli lakwa-Maskew Miller Longman ekusigaba selutjha ngo-2012.&lt;ref name=ph1&gt;&lt;/ref&gt;

Kwanje sele asebenzela iKoro yezesiPholisa yeSewula Afrika (SAPS).&lt;ref name=ph2&gt;&lt;/ref&gt;

==Isithasiselo==
{{Reflist}}

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>axwfzvqsvrujafns1pdzbccrtq1adpo</sha1>
    </revision>
  </page>
  <page>
    <title>Musi Maimane</title>
    <ns>0</ns>
    <id>222</id>
    <revision>
      <id>1173</id>
      <timestamp>2024-03-15T19:14:47Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Created a new article.</comment>
      <origin>1173</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="135" sha1="ng4p4921nwb238m6maqls0kcr8gpkr2" xml:space="preserve">[[Isimumathi:Mmusi Maimane (cropped).jpg|thumb|Mmusi Maimane]]
'''Musi Maimane''' ungusopolitiki wecembu lembusazwe lase Sewula Afrika.</text>
      <sha1>ng4p4921nwb238m6maqls0kcr8gpkr2</sha1>
    </revision>
    <revision>
      <id>1174</id>
      <parentid>1173</parentid>
      <timestamp>2024-10-14T13:47:05Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>1173</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="135" sha1="ng4p4921nwb238m6maqls0kcr8gpkr2" xml:space="preserve">[[Isimumathi:Mmusi Maimane (cropped).jpg|thumb|Mmusi Maimane]]
'''Musi Maimane''' ungusopolitiki wecembu lembusazwe lase Sewula Afrika.</text>
      <sha1>ng4p4921nwb238m6maqls0kcr8gpkr2</sha1>
    </revision>
    <revision>
      <id>2114</id>
      <parentid>1174</parentid>
      <timestamp>2024-11-25T17:41:50Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>Maimane ngo-2011</comment>
      <origin>2114</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="138" sha1="5lg828i0z15h6037plfpui5n4m77cow" xml:space="preserve">[[Isimumathi:Mmusi Maimane (cropped).jpg|thumb|Maimane ngo-2011]]
'''Musi Maimane''' ungusopolitiki wecembu lembusazwe lase Sewula Afrika.</text>
      <sha1>5lg828i0z15h6037plfpui5n4m77cow</sha1>
    </revision>
    <revision>
      <id>2186</id>
      <parentid>2114</parentid>
      <timestamp>2024-11-28T19:57:49Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>uMaimane ngomnyaka ka-2011</comment>
      <origin>2186</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="148" sha1="ongtpzx9dpsk8vg0ueu64j9kp2is1q3" xml:space="preserve">[[Isimumathi:Mmusi Maimane (cropped).jpg|thumb|uMaimane ngomnyaka ka-2011]]
'''Musi Maimane''' ungusopolitiki wecembu lembusazwe lase Sewula Afrika.</text>
      <sha1>ongtpzx9dpsk8vg0ueu64j9kp2is1q3</sha1>
    </revision>
    <revision>
      <id>2187</id>
      <parentid>2186</parentid>
      <timestamp>2024-11-28T19:58:08Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <comment>UMusi Maimane</comment>
      <origin>2187</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="149" sha1="hnnpqeor41i0nbzncrxweunknbbsh8p" xml:space="preserve">[[Isimumathi:Mmusi Maimane (cropped).jpg|thumb|uMaimane ngomnyaka ka-2011]]
'''UMusi Maimane''' ungusopolitiki wecembu lembusazwe lase Sewula Afrika.</text>
      <sha1>hnnpqeor41i0nbzncrxweunknbbsh8p</sha1>
    </revision>
    <revision>
      <id>3025</id>
      <parentid>2187</parentid>
      <timestamp>2025-06-06T20:32:33Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>54yhjumtj</comment>
      <origin>3025</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="230" sha1="2w077v3hei2anoq74fsgmbeaf6yfhov" xml:space="preserve">[[Isimumathi:Mmusi Maimane (cropped).jpg|thumb|uMaimane ngomnyaka ka-2011]]
'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. UMusi Maimane''' ungusopolitiki wecembu lembusazwe lase Sewula Afrika.</text>
      <sha1>2w077v3hei2anoq74fsgmbeaf6yfhov</sha1>
    </revision>
    <revision>
      <id>3053</id>
      <parentid>3025</parentid>
      <timestamp>2025-06-07T03:05:22Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Simakahle Moselekatse|Simakahle Moselekatse]]</comment>
      <origin>2187</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="149" sha1="hnnpqeor41i0nbzncrxweunknbbsh8p" xml:space="preserve">[[Isimumathi:Mmusi Maimane (cropped).jpg|thumb|uMaimane ngomnyaka ka-2011]]
'''UMusi Maimane''' ungusopolitiki wecembu lembusazwe lase Sewula Afrika.</text>
      <sha1>hnnpqeor41i0nbzncrxweunknbbsh8p</sha1>
    </revision>
    <revision>
      <id>6403</id>
      <parentid>3053</parentid>
      <timestamp>2026-04-13T06:49:12Z</timestamp>
      <contributor>
        <username>Kwamikagami</username>
        <id>1412</id>
      </contributor>
      <origin>6403</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="157" sha1="bvdkdzio3nzb9uulsurizfb30tlq7u1" xml:space="preserve">[[Isimumathi:Mmusi Maimane (cropped).jpg|thumb|upright|uMaimane ngomnyaka ka-2011]]
'''UMusi Maimane''' ungusopolitiki wecembu lembusazwe lase Sewula Afrika.</text>
      <sha1>bvdkdzio3nzb9uulsurizfb30tlq7u1</sha1>
    </revision>
  </page>
  <page>
    <title>Neil Tovey</title>
    <ns>0</ns>
    <id>223</id>
    <revision>
      <id>1175</id>
      <timestamp>2024-05-22T18:58:23Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;U-Neil Robert Tovey OIS (owazalwa zi-2 kuJulayi 1962) ungumqeqeshi webhola lezinyawo waseNingizimu Afrika kanye nomdlali wangaphambili aphinde abe ngumfowabo womdlali webhola lezinyawo wangaphambili uMark Tovey. Wazalelwa ePitoli. Uphethe irekhodi lokudlala imidlalo eminingi kuNational Soccer League.&quot;</comment>
      <origin>1175</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="301" sha1="8crslhmbnl12fsiw9n1gyy09ohc9xtb" xml:space="preserve">U-Neil Robert Tovey OIS (owazalwa zi-2 kuJulayi 1962) ungumqeqeshi webhola lezinyawo waseNingizimu Afrika kanye nomdlali wangaphambili aphinde abe ngumfowabo womdlali webhola lezinyawo wangaphambili uMark Tovey. Wazalelwa ePitoli. Uphethe irekhodi lokudlala imidlalo eminingi kuNational Soccer League.</text>
      <sha1>8crslhmbnl12fsiw9n1gyy09ohc9xtb</sha1>
    </revision>
    <revision>
      <id>1176</id>
      <parentid>1175</parentid>
      <timestamp>2024-05-22T18:58:53Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1176</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="317" sha1="j947iu9b05lb3mfirq2dkonwesqc04n" xml:space="preserve">U-Neil Robert Tovey OIS (owazalwa zi-2 kuJulayi 1962) ungumqeqeshi webhola lezinyawo wase[[Isewula Afrika|Sewula Afrika]] kanye nomdlali wangaphambili aphinde abe ngumfowabo womdlali webhola lezinyawo wangaphambili uMark Tovey. Wazalelwa ePitoli. Uphethe irekhodi lokudlala imidlalo eminingi kuNational Soccer League.</text>
      <sha1>j947iu9b05lb3mfirq2dkonwesqc04n</sha1>
    </revision>
    <revision>
      <id>1177</id>
      <parentid>1176</parentid>
      <timestamp>2024-10-14T13:47:05Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>1176</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="317" sha1="j947iu9b05lb3mfirq2dkonwesqc04n" xml:space="preserve">U-Neil Robert Tovey OIS (owazalwa zi-2 kuJulayi 1962) ungumqeqeshi webhola lezinyawo wase[[Isewula Afrika|Sewula Afrika]] kanye nomdlali wangaphambili aphinde abe ngumfowabo womdlali webhola lezinyawo wangaphambili uMark Tovey. Wazalelwa ePitoli. Uphethe irekhodi lokudlala imidlalo eminingi kuNational Soccer League.</text>
      <sha1>j947iu9b05lb3mfirq2dkonwesqc04n</sha1>
    </revision>
    <revision>
      <id>2185</id>
      <parentid>1177</parentid>
      <timestamp>2024-11-28T19:54:52Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <comment>'''</comment>
      <origin>2185</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="323" sha1="6sjz9g4oapz8xf6drgsp45ggqdpiwdd" xml:space="preserve">'''U-Neil Robert Tovey OIS''' (owazalwa zi-2 kuJulayi 1962) ungumqeqeshi webhola lezinyawo wase[[Isewula Afrika|Sewula Afrika]] kanye nomdlali wangaphambili aphinde abe ngumfowabo womdlali webhola lezinyawo wangaphambili uMark Tovey. Wazalelwa ePitoli. Uphethe irekhodi lokudlala imidlalo eminingi kuNational Soccer League.</text>
      <sha1>6sjz9g4oapz8xf6drgsp45ggqdpiwdd</sha1>
    </revision>
    <revision>
      <id>2981</id>
      <parentid>2185</parentid>
      <timestamp>2025-06-06T20:09:18Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>hifh</comment>
      <origin>2981</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="405" sha1="2tt3jgln8zn6juelnwedkcou6qwbiog" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. U-Neil Robert Tovey OIS''' (owazalwa zi-2 kuJulayi 1962) ungumqeqeshi webhola lezinyawo wase [[Isewula Afrika|Sewula Afrika]] kanye nomdlali wangaphambili aphinde abe ngumfowabo womdlali webhola lezinyawo wangaphambili uMark Tovey. Wazalelwa ePitoli. Uphethe irekhodi lokudlala imidlalo eminingi kuNational Soccer League.</text>
      <sha1>2tt3jgln8zn6juelnwedkcou6qwbiog</sha1>
    </revision>
    <revision>
      <id>3114</id>
      <parentid>2981</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Simakahle Moselekatse|Simakahle Moselekatse]]</comment>
      <origin>2185</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="323" sha1="6sjz9g4oapz8xf6drgsp45ggqdpiwdd" xml:space="preserve">'''U-Neil Robert Tovey OIS''' (owazalwa zi-2 kuJulayi 1962) ungumqeqeshi webhola lezinyawo wase[[Isewula Afrika|Sewula Afrika]] kanye nomdlali wangaphambili aphinde abe ngumfowabo womdlali webhola lezinyawo wangaphambili uMark Tovey. Wazalelwa ePitoli. Uphethe irekhodi lokudlala imidlalo eminingi kuNational Soccer League.</text>
      <sha1>6sjz9g4oapz8xf6drgsp45ggqdpiwdd</sha1>
    </revision>
    <revision>
      <id>3193</id>
      <parentid>3114</parentid>
      <timestamp>2025-06-21T19:18:47Z</timestamp>
      <contributor>
        <ip>85.97.84.231</ip>
      </contributor>
      <origin>3193</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="434" sha1="ipy8hgquoa2w4bcuuclw32mh80rvbg2" xml:space="preserve">[[File:Common chimpanzee (Pan troglodytes schweinfurthii) feeding.jpg|thumb|Omar al-Bashir is a chimpanzee.]]

'''U-Neil Robert Tovey OIS''' (owazalwa zi-2 kuJulayi 1962) ungumqeqeshi webhola lezinyawo wase[[Isewula Afrika|Sewula Afrika]] kanye nomdlali wangaphambili aphinde abe ngumfowabo womdlali webhola lezinyawo wangaphambili uMark Tovey. Wazalelwa ePitoli. Uphethe irekhodi lokudlala imidlalo eminingi kuNational Soccer League.</text>
      <sha1>ipy8hgquoa2w4bcuuclw32mh80rvbg2</sha1>
    </revision>
    <revision>
      <id>3311</id>
      <parentid>3193</parentid>
      <timestamp>2025-07-02T20:48:51Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Undo revision [[Special:Diff/3193|3193]] by [[Special:Contributions/85.97.84.231|85.97.84.231]] ([[User talk:85.97.84.231|talk]])</comment>
      <origin>3311</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="323" sha1="6sjz9g4oapz8xf6drgsp45ggqdpiwdd" xml:space="preserve">'''U-Neil Robert Tovey OIS''' (owazalwa zi-2 kuJulayi 1962) ungumqeqeshi webhola lezinyawo wase[[Isewula Afrika|Sewula Afrika]] kanye nomdlali wangaphambili aphinde abe ngumfowabo womdlali webhola lezinyawo wangaphambili uMark Tovey. Wazalelwa ePitoli. Uphethe irekhodi lokudlala imidlalo eminingi kuNational Soccer League.</text>
      <sha1>6sjz9g4oapz8xf6drgsp45ggqdpiwdd</sha1>
    </revision>
  </page>
  <page>
    <title>Nelson Mandela</title>
    <ns>0</ns>
    <id>224</id>
    <revision>
      <id>1178</id>
      <timestamp>2022-09-14T10:52:21Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;Nelson Rolihlahla was Mzansi Afrika.  &quot;</comment>
      <origin>1178</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="38" sha1="r3u27gohgyfv0sk37buk4xi0gtzszoj" xml:space="preserve">Nelson Rolihlahla was Mzansi Afrika.

</text>
      <sha1>r3u27gohgyfv0sk37buk4xi0gtzszoj</sha1>
    </revision>
    <revision>
      <id>1179</id>
      <parentid>1178</parentid>
      <timestamp>2022-09-14T10:53:11Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1179</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="45" sha1="1y2t5m9f6ypz9qevfum9x0vohc6sfjl" xml:space="preserve">'''Nelson Rolihlahla''' wase Sewula Afrika.

</text>
      <sha1>1y2t5m9f6ypz9qevfum9x0vohc6sfjl</sha1>
    </revision>
    <revision>
      <id>1180</id>
      <parentid>1179</parentid>
      <timestamp>2024-03-08T09:54:36Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1180</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="59" sha1="a83h261t60nm944qti4vkmxaionveya" xml:space="preserve">'''Nelson Rolihlahla''' '''Mandela''' wase Sewula Afrika.

</text>
      <sha1>a83h261t60nm944qti4vkmxaionveya</sha1>
    </revision>
    <revision>
      <id>1181</id>
      <parentid>1180</parentid>
      <timestamp>2024-03-08T10:04:00Z</timestamp>
      <contributor>
        <username>incubator&gt;NomusaAMethula</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>I added information about Nelson Rolihlahla Mandela</comment>
      <origin>1181</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="271" sha1="435pwpzvl9l1st7ew1aha9y82dk0xpz" xml:space="preserve">'''Nelson Rolihlahla''' '''Mandela''' wase Sewula Afrika wabelethwa mhla amalanga ali-18 ngenyanga kaVelabahlinze emnyakeni we-1918. Uhlongakele ngomnyaka wee-2013. Uhlongakele sekadlale iqhaza elikulu khulu ekukhululeni abantu abanzima eSewula Afrika ebebagandelelwe. 

</text>
      <sha1>435pwpzvl9l1st7ew1aha9y82dk0xpz</sha1>
    </revision>
    <revision>
      <id>1182</id>
      <parentid>1181</parentid>
      <timestamp>2024-03-08T10:13:58Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1182</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="403" sha1="ht1g56xb0t1fac0js2vmycm86nnwskf" xml:space="preserve">'''Nelson Rolihlahla''' '''Mandela''' wase Sewula Afrika wabelethwa mhla amalanga ali-18 ngenyanga kaVelabahlinze emnyakeni we-1918. Uhlongakele ngomnyaka we-2013. Uhlongakele sekadlale indima ekulu khulu ekukhululeni abantu abanzima eSewula Afrika ebebagandelelwe. Unomzana lo ube yikutani eyaletha ikululeko esitjhabeni sabantu babanzima. Waziwa ngamazwi athi kulikhambo elide ukufika ekululekweni. 

</text>
      <sha1>ht1g56xb0t1fac0js2vmycm86nnwskf</sha1>
    </revision>
    <revision>
      <id>1183</id>
      <parentid>1182</parentid>
      <timestamp>2024-03-08T10:16:15Z</timestamp>
      <contributor>
        <username>incubator&gt;KhethiweMsiza94</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>an error</comment>
      <origin>1183</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="405" sha1="tqhgwq7okldjott7lzyjpqtdnicx7h5" xml:space="preserve">'''Nelson Rolihlahla''' '''Mandela''' obeka mSewula Afrika wabelethwa mhla amalanga ali-18 ngenyanga kaVelabahlinze emnyakeni we-1918. Uhlongakele ngomnyaka we-2013. Uhlongakele sekadlale indima ekulu khulu ekukhululeni abantu abanzima eSewula Afrika ebebagandelelwe. Unomzana lo ube yikutani eyaletha ikululeko esitjhabeni sabantu babanzima. Waziwa ngamazwi athi kulikhambo elide ukufika ekululekweni. 

</text>
      <sha1>tqhgwq7okldjott7lzyjpqtdnicx7h5</sha1>
    </revision>
    <revision>
      <id>1184</id>
      <parentid>1183</parentid>
      <timestamp>2024-03-08T10:18:48Z</timestamp>
      <contributor>
        <username>incubator&gt;WikiMzansi</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1184</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="429" sha1="bbtdgekge89ox5sx770iojmexx0k50f" xml:space="preserve">'''Nelson Rolihlahla''' '''Mandela''' obeka mSewula Afrika wabelethwa mhla amalanga ali-18 ngenyanga kaVelabahlinze emnyakeni we-1918. Uhlongakele ngomnyaka we-2013. Uhlongakele sekadlale indima ekulu khulu ekukhululeni abantu abanzima eSewula Afrika ebebagandelelwe. Unomzana lo ube yikutani eyaletha ikululeko esitjhabeni sabantu babanzima. Waziwa ngamazwi athi kulikhambo elide ukufika ekululekweni. 

== Umlando kaMandela ==
</text>
      <sha1>bbtdgekge89ox5sx770iojmexx0k50f</sha1>
    </revision>
    <revision>
      <id>1185</id>
      <parentid>1184</parentid>
      <timestamp>2024-03-08T10:19:54Z</timestamp>
      <contributor>
        <username>incubator&gt;WikiMzansi</username>
        <id>0</id>
      </contributor>
      <comment>/* Umlando kaMandela */</comment>
      <origin>1185</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="406" sha1="ibllag47zp2ggh8crgm5puzygl9c6dz" xml:space="preserve">'''Nelson Rolihlahla''' '''Mandela''' obeka mSewula Afrika wabelethwa mhla amalanga ali-18 ngenyanga kaVelabahlinze emnyakeni we-1918. Uhlongakele ngomnyaka we-2013. Uhlongakele sekadlale indima ekulu khulu ekukhululeni abantu abanzima eSewula Afrika ebebagandelelwe. Unomzana lo ube yikutani eyaletha ikululeko esitjhabeni sabantu babanzima. Waziwa ngamazwi athi kulikhambo elide ukufika ekululekweni. 


</text>
      <sha1>ibllag47zp2ggh8crgm5puzygl9c6dz</sha1>
    </revision>
    <revision>
      <id>1186</id>
      <parentid>1185</parentid>
      <timestamp>2024-03-08T10:24:52Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1186</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="409" sha1="q3v0arw4kypevuppr6mxm9q5ws1kxqt" xml:space="preserve">'''Nelson Rolihlahla''' '''Mandela''' obeka mSewula Afrika wabelethwa mhla amalanga ali-18 ngenyanga kaVelabahlinze emnyakeni we-1918. Uhlongakele ngomnyaka we-2013. Uhlongakele sekadlale indima ekulu khulu ekukhululeni abantu abanzima eSewula Afrika ebebagandelelwe. Unomzana lo ube yikutani eyaletha ikululeko esitjhabeni sabantu babanzima. Waziwa ngamazwi athi &quot; kulikhambo elide ukufika ekululekweni&quot;. 


</text>
      <sha1>q3v0arw4kypevuppr6mxm9q5ws1kxqt</sha1>
    </revision>
    <revision>
      <id>1187</id>
      <parentid>1186</parentid>
      <timestamp>2024-03-08T10:29:01Z</timestamp>
      <contributor>
        <username>incubator&gt;Mbandeni</username>
        <id>0</id>
      </contributor>
      <comment>Where Nelson attended school</comment>
      <origin>1187</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="528" sha1="9zqvrhawfve92v3wc2b1c3ir5pidqoq" xml:space="preserve">'''Nelson Rolihlahla''' '''Mandela''' obeka mSewula Afrika wabelethwa mhla amalanga ali-18 ngenyanga kaVelabahlinze emnyakeni we-1918. Uhlongakele ngomnyaka we-2013. Uhlongakele sekadlale indima ekulu khulu ekukhululeni abantu abanzima eSewula Afrika ebebagandelelwe. Unomzana lo ube yikutani eyaletha ikululeko esitjhabeni sabantu babanzima. Waziwa ngamazwi athi &quot; kulikhambo elide ukufika ekululekweni&quot;. 

UNelson Rholihlahla Mandela ekukhuleni kwakhe wafunda e-Qunu lapha u-titjhere wakhe wamupha khona igama lika- Nelson 


</text>
      <sha1>9zqvrhawfve92v3wc2b1c3ir5pidqoq</sha1>
    </revision>
    <revision>
      <id>1188</id>
      <parentid>1187</parentid>
      <timestamp>2024-03-08T10:30:15Z</timestamp>
      <contributor>
        <username>incubator&gt;Lethabo19</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1188</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="530" sha1="t1vljcbtvaj1upw8q5t31pxw98a0nxp" xml:space="preserve">'''Nelson Rolihlahla''' '''Mandela''' obeka mSewula Afrika wabelethwa mhla amalanga ali-18 ngenyanga kaVelabahlinze emnyakeni we-1918. Uhlongakele ngomnyaka we-2013. Uhlongakele sekadlale indima ekulu khulu ekukhululeni abantu abanzima eSewula Afrika ebebagandelelwe. Unomzana lo ube yikutani eyaletha ikululeko esitjhabeni sabantu babanzima. Waziwa ngamazwi athi &quot; kulikhambo elide ukufika ekululekweni&quot;. 

UNelson Rholihlahla Mandela ekukhuleni kwakhe wafunda e-Qunu lapha u-titjhere wakhe wamupha khona igama lika- Nelson.  


</text>
      <sha1>t1vljcbtvaj1upw8q5t31pxw98a0nxp</sha1>
    </revision>
    <revision>
      <id>1189</id>
      <parentid>1188</parentid>
      <timestamp>2024-03-08T10:31:57Z</timestamp>
      <contributor>
        <username>incubator&gt;Lethabo19</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1189</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="588" sha1="jnjoo7aljwkcz6sqmze08ym6qdcqr4m" xml:space="preserve">'''Nelson Rolihlahla''' '''Mandela''' obeka mSewula Afrika wabelethwa mhla amalanga ali-18 ngenyanga kaVelabahlinze emnyakeni we-1918. Uhlongakele ngomnyaka we-2013. Uhlongakele sekadlale indima ekulu khulu ekukhululeni abantu abanzima eSewula Afrika ebebagandelelwe. Unomzana lo ube yikutani eyaletha ikululeko esitjhabeni sabantu babanzima. Waziwa ngamazwi athi &quot; kulikhambo elide ukufika ekululekweni&quot;. 

UNelson Rholihlahla Mandela ekukhuleni kwakhe wafunda e-Qunu lapha u-titjhere wakhe wamupha khona igama lika- Nelson. Ufundele zobuqcwetha eJunivesithi eyaziwa nge-Fort Hare.   


</text>
      <sha1>jnjoo7aljwkcz6sqmze08ym6qdcqr4m</sha1>
    </revision>
    <revision>
      <id>1190</id>
      <parentid>1189</parentid>
      <timestamp>2024-03-08T10:33:57Z</timestamp>
      <contributor>
        <username>incubator&gt;Thokozani57</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>translation</comment>
      <origin>1190</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="697" sha1="n2emastvnyfshgc3qix8ajzm95r5hbs" xml:space="preserve">'''Nelson Rolihlahla''' '''Mandela''' obeka mSewula Afrika wabelethwa mhla amalanga ali-18(itjhumi nobunane) ngenyanga kaVelabahlinze emnyakeni we-1918(ikulungwane amakhulu alithoba netjhumi nabunane). Uhlongakele ngomnyaka we-2013(iinkulungwane ezimbili netjhumi nantathu). Uhlongakele sekadlale indima ekulu khulu ekukhululeni abantu abanzima eSewula Afrika ebebagandelelwe. Unomzana lo ube yikutani eyaletha ikululeko esitjhabeni sabantu babanzima. Waziwa ngamazwi athi &quot; kulikhambo elide ukufika ekululekweni&quot;. 

UNelson Rholihlahla Mandela ekukhuleni kwakhe wafunda e-Qunu lapha u-titjhere wakhe wamupha khona igama lika- Nelson. Ufundele zobuqcwetha eJunivesithi eyaziwa nge-Fort Hare.   


</text>
      <sha1>n2emastvnyfshgc3qix8ajzm95r5hbs</sha1>
    </revision>
    <revision>
      <id>1191</id>
      <parentid>1190</parentid>
      <timestamp>2024-03-08T10:37:18Z</timestamp>
      <contributor>
        <username>incubator&gt;Thandeka179</username>
        <id>0</id>
      </contributor>
      <origin>1191</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="719" sha1="js6rl358eq6wrugjiu23cn7m6j13660" xml:space="preserve">'''Nelson Rolihlahla''' '''Mandela''' obeka mSewula Afrika wabelethwa mhla amalanga ali-18(itjhumi nobunane) ngenyanga kaVelabahlinze emnyakeni we-1918(ikulungwane amakhulu alithoba netjhumi nabunane). Uhlongakele ngomnyaka we-2013(iinkulungwane ezimbili netjhumi nantathu). Uhlongakele sekadlale indima ekulu khulu ekukhululeni abantu abanzima eSewula Afrika ebebagandelelwe. Unomzana lo ube yikutani eyaletha ikululeko esitjhabeni sabantu babanzima. Waziwa ngamazwi athi &quot; kulikhambo elide ukufika ekululekweni&quot;(long walk to freedom). 

UNelson Rholihlahla Mandela ekukhuleni kwakhe wafunda e-Qunu lapha u-titjhere wakhe wamupha khona igama lika- Nelson. Ufundele zobuqcwetha eJunivesithi eyaziwa nge-Fort Hare.   


</text>
      <sha1>js6rl358eq6wrugjiu23cn7m6j13660</sha1>
    </revision>
    <revision>
      <id>1192</id>
      <parentid>1191</parentid>
      <timestamp>2024-03-08T10:44:36Z</timestamp>
      <contributor>
        <username>incubator&gt;CdTshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1192</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="733" sha1="lxkxp87jjg3b59xeaeblakbsq3d8xgv" xml:space="preserve">'''Nelson Rolihlahla''' '''Mandela''' obeka ngu Mongameli eSewula Afrika wabelethwa mhla amalanga ali-18(itjhumi nobunane) ngenyanga kaVelabahlinze emnyakeni we-1918(ikulungwane amakhulu alithoba netjhumi nabunane). Uhlongakele ngomnyaka we-2013(iinkulungwane ezimbili netjhumi nantathu). Uhlongakele sekadlale indima ekulu khulu ekukhululeni abantu abanzima eSewula Afrika ebebagandelelwe. Unomzana lo ube yikutani eyaletha ikululeko esitjhabeni sabantu babanzima. Waziwa ngamazwi athi &quot; kulikhambo elide ukufika ekululekweni&quot;(long walk to freedom). 

UNelson Rholihlahla Mandela ekukhuleni kwakhe wafunda e-Qunu lapha u-titjhere wakhe wamupha khona igama lika- Nelson. Ufundele zobuqcwetha eJunivesithi eyaziwa nge-Fort Hare.   


</text>
      <sha1>lxkxp87jjg3b59xeaeblakbsq3d8xgv</sha1>
    </revision>
    <revision>
      <id>1193</id>
      <parentid>1192</parentid>
      <timestamp>2024-03-08T10:56:21Z</timestamp>
      <contributor>
        <username>incubator&gt;LindiweSiba</username>
        <id>0</id>
      </contributor>
      <comment>Added content</comment>
      <origin>1193</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="784" sha1="5msdjrnwahf986uchlqweuj8gtf7yos" xml:space="preserve">'''Nelson Rolihlahla''' '''Mandela''' obeka ngu Mongameli eSewula Afrika wabelethwa mhla amalanga ali-18(itjhumi nobunane) ngenyanga kaVelabahlinze emnyakeni we-1918(ikulungwane amakhulu alithoba netjhumi nabunane). Uhlongakele ngomnyaka we-2013(iinkulungwane ezimbili netjhumi nantathu). Uhlongakele sekadlale indima ekulu khulu ekukhululeni abantu abanzima eSewula Afrika ebebagandelelwe. Unomzana lo ube yikutani eyaletha ikululeko esitjhabeni sabantu babanzima. Waziwa ngamazwi athi &quot; kulikhambo elide ukufika ekululekweni&quot;(long walk to freedom). 

UNelson Rholihlahla Mandela ekukhuleni kwakhe wafunda e-Qunu lapha u-titjhere wakhe wamupha khona igama lika- Nelson. Ufundele zobuqcwetha eJunivesithi eyaziwa nge-Fort Hare.   Wabotjhwa iminyaka ematjhumi amabili nesithandathu.


</text>
      <sha1>5msdjrnwahf986uchlqweuj8gtf7yos</sha1>
    </revision>
    <revision>
      <id>1194</id>
      <parentid>1193</parentid>
      <timestamp>2024-03-08T13:00:34Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Adding interwiki links to [[d:Q8023]]</comment>
      <origin>1194</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="804" sha1="rjbxy6aew603oynbfzhavqvx6r0z1ya" xml:space="preserve">'''Nelson Rolihlahla''' '''Mandela''' obeka ngu Mongameli eSewula Afrika wabelethwa mhla amalanga ali-18(itjhumi nobunane) ngenyanga kaVelabahlinze emnyakeni we-1918(ikulungwane amakhulu alithoba netjhumi nabunane). Uhlongakele ngomnyaka we-2013(iinkulungwane ezimbili netjhumi nantathu). Uhlongakele sekadlale indima ekulu khulu ekukhululeni abantu abanzima eSewula Afrika ebebagandelelwe. Unomzana lo ube yikutani eyaletha ikululeko esitjhabeni sabantu babanzima. Waziwa ngamazwi athi &quot; kulikhambo elide ukufika ekululekweni&quot;(long walk to freedom). 

UNelson Rholihlahla Mandela ekukhuleni kwakhe wafunda e-Qunu lapha u-titjhere wakhe wamupha khona igama lika- Nelson. Ufundele zobuqcwetha eJunivesithi eyaziwa nge-Fort Hare.   Wabotjhwa iminyaka ematjhumi amabili nesithandathu.



{{INTERWIKI|Q8023}}</text>
      <sha1>rjbxy6aew603oynbfzhavqvx6r0z1ya</sha1>
    </revision>
    <revision>
      <id>1195</id>
      <parentid>1194</parentid>
      <timestamp>2024-03-09T07:22:40Z</timestamp>
      <contributor>
        <username>incubator&gt;Lethabo19</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1195</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="823" sha1="0nzve2zm2wxannlv20pk74q1ps15szt" xml:space="preserve">'''Nelson Rolihlahla''' '''Mandela''' obeka ngu Mongameli e[[Isewula Afrika|Sewula Afrika]] wabelethwa mhla amalanga ali-18(itjhumi nobunane) ngenyanga kaVelabahlinze emnyakeni we-1918(ikulungwane amakhulu alithoba netjhumi nabunane). Uhlongakele ngomnyaka we-2013(iinkulungwane ezimbili netjhumi nantathu). Uhlongakele sekadlale indima ekulu khulu ekukhululeni abantu abanzima eSewula Afrika ebebagandelelwe. Unomzana lo ube yikutani eyaletha ikululeko esitjhabeni sabantu babanzima. Waziwa ngamazwi athi &quot; kulikhambo elide ukufika ekululekweni&quot;(long walk to freedom). 

UNelson Rholihlahla Mandela ekukhuleni kwakhe wafunda e-Qunu lapha u-titjhere wakhe wamupha khona igama lika- Nelson. Ufundele zobuqcwetha eJunivesithi eyaziwa nge-Fort Hare.   Wabotjhwa iminyaka ematjhumi amabili nesithandathu.



{{INTERWIKI|Q8023}}</text>
      <sha1>0nzve2zm2wxannlv20pk74q1ps15szt</sha1>
    </revision>
    <revision>
      <id>1196</id>
      <parentid>1195</parentid>
      <timestamp>2024-03-09T07:24:38Z</timestamp>
      <contributor>
        <username>incubator&gt;Lethabo19</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>I have linked to another page</comment>
      <origin>1196</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="827" sha1="5gq2hjt3q4jo6qr11rxuh3e76zemqvo" xml:space="preserve">'''Nelson Rolihlahla''' '''Mandela''' obeka ngu Mongameli e[[Isewula Afrika|Sewula Afrika]] wabelethwa mhla amalanga ali-18(itjhumi nobunane) ngenyanga kaVelabahlinze emnyakeni we-1918(ikulungwane amakhulu alithoba netjhumi nabunane). Uhlongakele ngomnyaka we-2013(iinkulungwane ezimbili netjhumi nantathu). Uhlongakele sekadlale indima ekulu khulu ekukhululeni abantu abanzima eSewula Afrika ebebagandelelwe. Unomzana lo ube yikutani eyaletha ikululeko esitjhabeni sabantu babanzima. Waziwa ngamazwi athi &quot; kulikhambo elide ukufika ekululekweni&quot;(long walk to freedom). 

UNelson Rholihlahla Mandela ekukhuleni kwakhe wafunda e-Qunu lapha u-titjhere wakhe wamupha khona igama lika- Nelson. Ufundele zobuqcwetha eJunivesithi eyaziwa nge[[-Fort Hare]].   Wabotjhwa iminyaka ematjhumi amabili nesithandathu.



{{INTERWIKI|Q8023}}</text>
      <sha1>5gq2hjt3q4jo6qr11rxuh3e76zemqvo</sha1>
    </revision>
    <revision>
      <id>1197</id>
      <parentid>1196</parentid>
      <timestamp>2024-03-09T07:25:34Z</timestamp>
      <contributor>
        <username>incubator&gt;Lethabo19</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1197</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="831" sha1="ptqlla1eps96oiw3ik3cgc0ka26u4tl" xml:space="preserve">'''Nelson Rolihlahla''' '''Mandela''' obeka ngu Mongameli e[[Isewula Afrika|Sewula Afrika]] wabelethwa mhla amalanga ali-18(itjhumi nobunane) ngenyanga kaVelabahlinze emnyakeni we-1918(ikulungwane amakhulu alithoba netjhumi nabunane). Uhlongakele ngomnyaka we-2013(iinkulungwane ezimbili netjhumi nantathu). Uhlongakele sekadlale indima ekulu khulu ekukhululeni abantu abanzima eSewula Afrika ebebagandelelwe. Unomzana lo ube yikutani eyaletha ikululeko esitjhabeni sabantu babanzima. Waziwa ngamazwi athi &quot; kulikhambo elide ukufika ekululekweni&quot;(long walk to freedom). 

UNelson Rholihlahla Mandela ekukhuleni kwakhe wafunda e[[-Qunu]] lapha u-titjhere wakhe wamupha khona igama lika- Nelson. Ufundele zobuqcwetha eJunivesithi eyaziwa nge[[-Fort Hare]].   Wabotjhwa iminyaka ematjhumi amabili nesithandathu.



{{INTERWIKI|Q8023}}</text>
      <sha1>ptqlla1eps96oiw3ik3cgc0ka26u4tl</sha1>
    </revision>
    <revision>
      <id>1198</id>
      <parentid>1197</parentid>
      <timestamp>2024-03-09T08:05:37Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1198</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="849" sha1="6yyvmow25tzyvbq8ju9fzbyo282lw4r" xml:space="preserve">
'''Nelson Rolihlahla''' '''Mandela''' obeka ngu Mongameli e[[Isewula Afrika|Sewula Afrika]] wabelethwa mhla amalanga ali-18(itjhumi nobunane) ngenyanga kaVelabahlinze emnyakeni we-1918(ikulungwane amakhulu alithoba netjhumi nabunane). Uhlongakele ngomnyaka we-2013(iinkulungwane ezimbili netjhumi nantathu). Uhlongakele sekadlale indima ekulu khulu ekukhululeni abantu abanzima eSewula Afrika ebebagandelelwe. Unomzana lo ube yikutani eyaletha ikululeko esitjhabeni sabantu babanzima. Waziwa ngamazwi athi &quot; kulikhambo elide ukufika ekululekweni&quot;(long walk to freedom). 

UNelson Rholihlahla Mandela ekukhuleni kwakhe wafunda e[[-Qunu|-Qunu]] lapha u-titjhere wakhe wamupha khona igama lika- Nelson. Ufundele zobuqcwetha eJunivesithi eyaziwa nge[[-Fort Hare|-Fort Hare]].   Wabotjhwa iminyaka ematjhumi amabili nesithandathu.



{{INTERWIKI|Q8023}}</text>
      <sha1>6yyvmow25tzyvbq8ju9fzbyo282lw4r</sha1>
    </revision>
    <revision>
      <id>1199</id>
      <parentid>1198</parentid>
      <timestamp>2024-03-09T08:07:10Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1199</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="893" sha1="k4k4kxurr7l2mzn9k20lx97kkv99axo" xml:space="preserve">[[Isimumathi:Nelson Mandela 1994.jpg|thumb]]
'''Nelson Rolihlahla''' '''Mandela''' obeka ngu Mongameli e[[Isewula Afrika|Sewula Afrika]] wabelethwa mhla amalanga ali-18(itjhumi nobunane) ngenyanga kaVelabahlinze emnyakeni we-1918(ikulungwane amakhulu alithoba netjhumi nabunane). Uhlongakele ngomnyaka we-2013(iinkulungwane ezimbili netjhumi nantathu). Uhlongakele sekadlale indima ekulu khulu ekukhululeni abantu abanzima eSewula Afrika ebebagandelelwe. Unomzana lo ube yikutani eyaletha ikululeko esitjhabeni sabantu babanzima. Waziwa ngamazwi athi &quot; kulikhambo elide ukufika ekululekweni&quot;(long walk to freedom). 

UNelson Rholihlahla Mandela ekukhuleni kwakhe wafunda e[[-Qunu|-Qunu]] lapha u-titjhere wakhe wamupha khona igama lika- Nelson. Ufundele zobuqcwetha eJunivesithi eyaziwa nge[[-Fort Hare|-Fort Hare]].   Wabotjhwa iminyaka ematjhumi amabili nesithandathu.



{{INTERWIKI|Q8023}}</text>
      <sha1>k4k4kxurr7l2mzn9k20lx97kkv99axo</sha1>
    </revision>
    <revision>
      <id>1200</id>
      <parentid>1199</parentid>
      <timestamp>2024-03-09T08:07:36Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1200</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="849" sha1="6yyvmow25tzyvbq8ju9fzbyo282lw4r" xml:space="preserve">
'''Nelson Rolihlahla''' '''Mandela''' obeka ngu Mongameli e[[Isewula Afrika|Sewula Afrika]] wabelethwa mhla amalanga ali-18(itjhumi nobunane) ngenyanga kaVelabahlinze emnyakeni we-1918(ikulungwane amakhulu alithoba netjhumi nabunane). Uhlongakele ngomnyaka we-2013(iinkulungwane ezimbili netjhumi nantathu). Uhlongakele sekadlale indima ekulu khulu ekukhululeni abantu abanzima eSewula Afrika ebebagandelelwe. Unomzana lo ube yikutani eyaletha ikululeko esitjhabeni sabantu babanzima. Waziwa ngamazwi athi &quot; kulikhambo elide ukufika ekululekweni&quot;(long walk to freedom). 

UNelson Rholihlahla Mandela ekukhuleni kwakhe wafunda e[[-Qunu|-Qunu]] lapha u-titjhere wakhe wamupha khona igama lika- Nelson. Ufundele zobuqcwetha eJunivesithi eyaziwa nge[[-Fort Hare|-Fort Hare]].   Wabotjhwa iminyaka ematjhumi amabili nesithandathu.



{{INTERWIKI|Q8023}}</text>
      <sha1>6yyvmow25tzyvbq8ju9fzbyo282lw4r</sha1>
    </revision>
    <revision>
      <id>1201</id>
      <parentid>1200</parentid>
      <timestamp>2024-03-09T08:11:13Z</timestamp>
      <contributor>
        <username>incubator&gt;CdTshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1201</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="925" sha1="0lpbs8sagkka73j41nw7oynbtel5qzm" xml:space="preserve">[[Isimumathi:Nelson Mandela-2008 (edit) (cropped).jpg|thumb|NELSON MANDELA]]
'''Nelson Rolihlahla''' '''Mandela''' obeka ngu Mongameli e[[Isewula Afrika|Sewula Afrika]] wabelethwa mhla amalanga ali-18(itjhumi nobunane) ngenyanga kaVelabahlinze emnyakeni we-1918(ikulungwane amakhulu alithoba netjhumi nabunane). Uhlongakele ngomnyaka we-2013(iinkulungwane ezimbili netjhumi nantathu). Uhlongakele sekadlale indima ekulu khulu ekukhululeni abantu abanzima eSewula Afrika ebebagandelelwe. Unomzana lo ube yikutani eyaletha ikululeko esitjhabeni sabantu babanzima. Waziwa ngamazwi athi &quot; kulikhambo elide ukufika ekululekweni&quot;(long walk to freedom). 

UNelson Rholihlahla Mandela ekukhuleni kwakhe wafunda e[[-Qunu|-Qunu]] lapha u-titjhere wakhe wamupha khona igama lika- Nelson. Ufundele zobuqcwetha eJunivesithi eyaziwa nge[[-Fort Hare|-Fort Hare]].   Wabotjhwa iminyaka ematjhumi amabili nesithandathu.



{{INTERWIKI|Q8023}}</text>
      <sha1>0lpbs8sagkka73j41nw7oynbtel5qzm</sha1>
    </revision>
    <revision>
      <id>1202</id>
      <parentid>1201</parentid>
      <timestamp>2024-10-14T13:47:06Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>24 revisions imported</comment>
      <origin>1201</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="925" sha1="0lpbs8sagkka73j41nw7oynbtel5qzm" xml:space="preserve">[[Isimumathi:Nelson Mandela-2008 (edit) (cropped).jpg|thumb|NELSON MANDELA]]
'''Nelson Rolihlahla''' '''Mandela''' obeka ngu Mongameli e[[Isewula Afrika|Sewula Afrika]] wabelethwa mhla amalanga ali-18(itjhumi nobunane) ngenyanga kaVelabahlinze emnyakeni we-1918(ikulungwane amakhulu alithoba netjhumi nabunane). Uhlongakele ngomnyaka we-2013(iinkulungwane ezimbili netjhumi nantathu). Uhlongakele sekadlale indima ekulu khulu ekukhululeni abantu abanzima eSewula Afrika ebebagandelelwe. Unomzana lo ube yikutani eyaletha ikululeko esitjhabeni sabantu babanzima. Waziwa ngamazwi athi &quot; kulikhambo elide ukufika ekululekweni&quot;(long walk to freedom). 

UNelson Rholihlahla Mandela ekukhuleni kwakhe wafunda e[[-Qunu|-Qunu]] lapha u-titjhere wakhe wamupha khona igama lika- Nelson. Ufundele zobuqcwetha eJunivesithi eyaziwa nge[[-Fort Hare|-Fort Hare]].   Wabotjhwa iminyaka ematjhumi amabili nesithandathu.



{{INTERWIKI|Q8023}}</text>
      <sha1>0lpbs8sagkka73j41nw7oynbtel5qzm</sha1>
    </revision>
    <revision>
      <id>1674</id>
      <parentid>1202</parentid>
      <timestamp>2024-10-16T09:50:03Z</timestamp>
      <contributor>
        <username>JhsBot</username>
        <id>34</id>
      </contributor>
      <minor />
      <comment>bot: Removing interwiki template; the page is now connected to [[d:Q8023]]</comment>
      <origin>1674</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="902" sha1="d00pwqq19dvmv5ut68m4jmxhcu7ef5g" xml:space="preserve">[[Isimumathi:Nelson Mandela-2008 (edit) (cropped).jpg|thumb|NELSON MANDELA]]
'''Nelson Rolihlahla''' '''Mandela''' obeka ngu Mongameli e[[Isewula Afrika|Sewula Afrika]] wabelethwa mhla amalanga ali-18(itjhumi nobunane) ngenyanga kaVelabahlinze emnyakeni we-1918(ikulungwane amakhulu alithoba netjhumi nabunane). Uhlongakele ngomnyaka we-2013(iinkulungwane ezimbili netjhumi nantathu). Uhlongakele sekadlale indima ekulu khulu ekukhululeni abantu abanzima eSewula Afrika ebebagandelelwe. Unomzana lo ube yikutani eyaletha ikululeko esitjhabeni sabantu babanzima. Waziwa ngamazwi athi &quot; kulikhambo elide ukufika ekululekweni&quot;(long walk to freedom). 

UNelson Rholihlahla Mandela ekukhuleni kwakhe wafunda e[[-Qunu|-Qunu]] lapha u-titjhere wakhe wamupha khona igama lika- Nelson. Ufundele zobuqcwetha eJunivesithi eyaziwa nge[[-Fort Hare|-Fort Hare]].   Wabotjhwa iminyaka ematjhumi amabili nesithandathu.</text>
      <sha1>d00pwqq19dvmv5ut68m4jmxhcu7ef5g</sha1>
    </revision>
    <revision>
      <id>1883</id>
      <parentid>1674</parentid>
      <timestamp>2024-11-12T18:56:54Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>Nelson Mandela ka 2008</comment>
      <origin>1883</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="910" sha1="jugiomas12yh1mh69yzr6fz8p6icy0k" xml:space="preserve">[[Isimumathi:Nelson Mandela-2008 (edit) (cropped).jpg|thumb|Nelson Mandela ka 2008]]
'''Nelson Rolihlahla''' '''Mandela''' obeka ngu Mongameli e[[Isewula Afrika|Sewula Afrika]] wabelethwa mhla amalanga ali-18(itjhumi nobunane) ngenyanga kaVelabahlinze emnyakeni we-1918(ikulungwane amakhulu alithoba netjhumi nabunane). Uhlongakele ngomnyaka we-2013(iinkulungwane ezimbili netjhumi nantathu). Uhlongakele sekadlale indima ekulu khulu ekukhululeni abantu abanzima eSewula Afrika ebebagandelelwe. Unomzana lo ube yikutani eyaletha ikululeko esitjhabeni sabantu babanzima. Waziwa ngamazwi athi &quot; kulikhambo elide ukufika ekululekweni&quot;(long walk to freedom). 

UNelson Rholihlahla Mandela ekukhuleni kwakhe wafunda e[[-Qunu|-Qunu]] lapha u-titjhere wakhe wamupha khona igama lika- Nelson. Ufundele zobuqcwetha eJunivesithi eyaziwa nge[[-Fort Hare|-Fort Hare]].   Wabotjhwa iminyaka ematjhumi amabili nesithandathu.</text>
      <sha1>jugiomas12yh1mh69yzr6fz8p6icy0k</sha1>
    </revision>
    <revision>
      <id>2177</id>
      <parentid>1883</parentid>
      <timestamp>2024-11-28T09:09:08Z</timestamp>
      <contributor>
        <ip>104.255.173.142</ip>
      </contributor>
      <comment>uMandela ngomnyaka ka-2008</comment>
      <origin>2177</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="914" sha1="83fn85c38nnjm8c98iuladul3r68lgt" xml:space="preserve">[[Isimumathi:Nelson Mandela-2008 (edit) (cropped).jpg|thumb|uMandela ngomnyaka ka-2008]]
'''Nelson Rolihlahla''' '''Mandela''' obeka ngu Mongameli e[[Isewula Afrika|Sewula Afrika]] wabelethwa mhla amalanga ali-18(itjhumi nobunane) ngenyanga kaVelabahlinze emnyakeni we-1918(ikulungwane amakhulu alithoba netjhumi nabunane). Uhlongakele ngomnyaka we-2013(iinkulungwane ezimbili netjhumi nantathu). Uhlongakele sekadlale indima ekulu khulu ekukhululeni abantu abanzima eSewula Afrika ebebagandelelwe. Unomzana lo ube yikutani eyaletha ikululeko esitjhabeni sabantu babanzima. Waziwa ngamazwi athi &quot; kulikhambo elide ukufika ekululekweni&quot;(long walk to freedom). 

UNelson Rholihlahla Mandela ekukhuleni kwakhe wafunda e[[-Qunu|-Qunu]] lapha u-titjhere wakhe wamupha khona igama lika- Nelson. Ufundele zobuqcwetha eJunivesithi eyaziwa nge[[-Fort Hare|-Fort Hare]].   Wabotjhwa iminyaka ematjhumi amabili nesithandathu.</text>
      <sha1>83fn85c38nnjm8c98iuladul3r68lgt</sha1>
    </revision>
    <revision>
      <id>3031</id>
      <parentid>2177</parentid>
      <timestamp>2025-06-06T20:35:43Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>yuezsrj</comment>
      <origin>3031</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="995" sha1="pcgswr759ziv7xu9ij3aw6psonqq2dz" xml:space="preserve">[[Isimumathi:Nelson Mandela-2008 (edit) (cropped).jpg|thumb|uMandela ngomnyaka ka-2008]]
'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. Nelson Rolihlahla''' '''Mandela''' obeka ngu Mongameli e[[Isewula Afrika|Sewula Afrika]] wabelethwa mhla amalanga ali-18(itjhumi nobunane) ngenyanga kaVelabahlinze emnyakeni we-1918(ikulungwane amakhulu alithoba netjhumi nabunane). Uhlongakele ngomnyaka we-2013(iinkulungwane ezimbili netjhumi nantathu). Uhlongakele sekadlale indima ekulu khulu ekukhululeni abantu abanzima eSewula Afrika ebebagandelelwe. Unomzana lo ube yikutani eyaletha ikululeko esitjhabeni sabantu babanzima. Waziwa ngamazwi athi &quot; kulikhambo elide ukufika ekululekweni&quot;(long walk to freedom). 

UNelson Rholihlahla Mandela ekukhuleni kwakhe wafunda e[[-Qunu|-Qunu]] lapha u-titjhere wakhe wamupha khona igama lika- Nelson. Ufundele zobuqcwetha eJunivesithi eyaziwa nge[[-Fort Hare|-Fort Hare]].   Wabotjhwa iminyaka ematjhumi amabili nesithandathu.</text>
      <sha1>pcgswr759ziv7xu9ij3aw6psonqq2dz</sha1>
    </revision>
    <revision>
      <id>3147</id>
      <parentid>3031</parentid>
      <timestamp>2025-06-07T03:05:24Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:104.255.173.142|104.255.173.142]]</comment>
      <origin>2177</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="914" sha1="83fn85c38nnjm8c98iuladul3r68lgt" xml:space="preserve">[[Isimumathi:Nelson Mandela-2008 (edit) (cropped).jpg|thumb|uMandela ngomnyaka ka-2008]]
'''Nelson Rolihlahla''' '''Mandela''' obeka ngu Mongameli e[[Isewula Afrika|Sewula Afrika]] wabelethwa mhla amalanga ali-18(itjhumi nobunane) ngenyanga kaVelabahlinze emnyakeni we-1918(ikulungwane amakhulu alithoba netjhumi nabunane). Uhlongakele ngomnyaka we-2013(iinkulungwane ezimbili netjhumi nantathu). Uhlongakele sekadlale indima ekulu khulu ekukhululeni abantu abanzima eSewula Afrika ebebagandelelwe. Unomzana lo ube yikutani eyaletha ikululeko esitjhabeni sabantu babanzima. Waziwa ngamazwi athi &quot; kulikhambo elide ukufika ekululekweni&quot;(long walk to freedom). 

UNelson Rholihlahla Mandela ekukhuleni kwakhe wafunda e[[-Qunu|-Qunu]] lapha u-titjhere wakhe wamupha khona igama lika- Nelson. Ufundele zobuqcwetha eJunivesithi eyaziwa nge[[-Fort Hare|-Fort Hare]].   Wabotjhwa iminyaka ematjhumi amabili nesithandathu.</text>
      <sha1>83fn85c38nnjm8c98iuladul3r68lgt</sha1>
    </revision>
    <revision>
      <id>3183</id>
      <parentid>3147</parentid>
      <timestamp>2025-06-21T19:07:37Z</timestamp>
      <contributor>
        <ip>85.97.84.231</ip>
      </contributor>
      <origin>3183</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1025" sha1="7i1oblm9ej71mt8pjj6wehy810nlmn5" xml:space="preserve">[[File:Common chimpanzee (Pan troglodytes schweinfurthii) feeding.jpg|thumb|Omar al-Bashir is a chimpanzee.]]

[[Isimumathi:Nelson Mandela-2008 (edit) (cropped).jpg|thumb|uMandela ngomnyaka ka-2008]]
'''Nelson Rolihlahla''' '''Mandela''' obeka ngu Mongameli e[[Isewula Afrika|Sewula Afrika]] wabelethwa mhla amalanga ali-18(itjhumi nobunane) ngenyanga kaVelabahlinze emnyakeni we-1918(ikulungwane amakhulu alithoba netjhumi nabunane). Uhlongakele ngomnyaka we-2013(iinkulungwane ezimbili netjhumi nantathu). Uhlongakele sekadlale indima ekulu khulu ekukhululeni abantu abanzima eSewula Afrika ebebagandelelwe. Unomzana lo ube yikutani eyaletha ikululeko esitjhabeni sabantu babanzima. Waziwa ngamazwi athi &quot; kulikhambo elide ukufika ekululekweni&quot;(long walk to freedom). 

UNelson Rholihlahla Mandela ekukhuleni kwakhe wafunda e[[-Qunu|-Qunu]] lapha u-titjhere wakhe wamupha khona igama lika- Nelson. Ufundele zobuqcwetha eJunivesithi eyaziwa nge[[-Fort Hare|-Fort Hare]].   Wabotjhwa iminyaka ematjhumi amabili nesithandathu.</text>
      <sha1>7i1oblm9ej71mt8pjj6wehy810nlmn5</sha1>
    </revision>
    <revision>
      <id>3302</id>
      <parentid>3183</parentid>
      <timestamp>2025-07-02T20:46:11Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Undo revision [[Special:Diff/3183|3183]] by [[Special:Contributions/85.97.84.231|85.97.84.231]] ([[User talk:85.97.84.231|talk]])</comment>
      <origin>3302</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="914" sha1="83fn85c38nnjm8c98iuladul3r68lgt" xml:space="preserve">[[Isimumathi:Nelson Mandela-2008 (edit) (cropped).jpg|thumb|uMandela ngomnyaka ka-2008]]
'''Nelson Rolihlahla''' '''Mandela''' obeka ngu Mongameli e[[Isewula Afrika|Sewula Afrika]] wabelethwa mhla amalanga ali-18(itjhumi nobunane) ngenyanga kaVelabahlinze emnyakeni we-1918(ikulungwane amakhulu alithoba netjhumi nabunane). Uhlongakele ngomnyaka we-2013(iinkulungwane ezimbili netjhumi nantathu). Uhlongakele sekadlale indima ekulu khulu ekukhululeni abantu abanzima eSewula Afrika ebebagandelelwe. Unomzana lo ube yikutani eyaletha ikululeko esitjhabeni sabantu babanzima. Waziwa ngamazwi athi &quot; kulikhambo elide ukufika ekululekweni&quot;(long walk to freedom). 

UNelson Rholihlahla Mandela ekukhuleni kwakhe wafunda e[[-Qunu|-Qunu]] lapha u-titjhere wakhe wamupha khona igama lika- Nelson. Ufundele zobuqcwetha eJunivesithi eyaziwa nge[[-Fort Hare|-Fort Hare]].   Wabotjhwa iminyaka ematjhumi amabili nesithandathu.</text>
      <sha1>83fn85c38nnjm8c98iuladul3r68lgt</sha1>
    </revision>
    <revision>
      <id>5149</id>
      <parentid>3302</parentid>
      <timestamp>2025-08-13T03:12:39Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <minor />
      <origin>5149</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="919" sha1="cnjvl3csmzblb2831eovpn7vdkx71hg" xml:space="preserve">[[Isimumathi:Nelson Mandela-2008 (edit) (cropped).jpg|thumb|uMandela ngomnyaka ka-2008]]
'''Nelson Rolihlahla''' '''Mandela''' obegade angu Mengameli e[[Isewula Afrika|Sewula Afrika]] wabelethwa mhlana amalanga ali-18(itjhumi nobunane) ngenyanga kaVelabahlinze emnyakeni we-1918(ikulungwane amakhulu alithoba netjhumi nabunane). Uhlongakele ngomnyaka we-2013(iinkulungwane ezimbili netjhumi nantathu). Uhlongakele sekadlale indima ekulu khulu ekukhululeni abantu abanzima eSewula Afrika ebebagandelelwe. Unomzana lo ube yikutani eyaletha ikululeko esitjhabeni sabantu babanzima. Waziwa ngamazwi athi &quot; kulikhambo elide ukufika ekululekweni&quot;(long walk to freedom). 

UNelson Rholihlahla Mandela ekukhuleni kwakhe wafunda e[[-Qunu|-Qunu]] lapha u-titjhere wakhe wamupha khona igama lika- Nelson. Ufundele zobuqcwetha eJunivesithi eyaziwa nge[[-Fort Hare|-Fort Hare]].   Wabotjhwa iminyaka ematjhumi amabili nesithandathu.</text>
      <sha1>cnjvl3csmzblb2831eovpn7vdkx71hg</sha1>
    </revision>
    <revision>
      <id>5469</id>
      <parentid>5149</parentid>
      <timestamp>2025-09-04T08:21:16Z</timestamp>
      <contributor>
        <username>2000Gp01</username>
        <id>880</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1307958013|Nelson Mandela]]&quot;</comment>
      <origin>5469</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="568" sha1="1v4k5hlv1a61tebfj40jwp0d5nllpoi" xml:space="preserve">
 

'''Nelson Rolihlahla Mandela''' ( /m æ n ˈ d ɛ l ə / man-DEL -ə,   ; wabelethwa ngu '''-Rolihlahla Mandela''' ; 18 kuNtaka 1918&amp;nbsp;– 5 kuNobayeni 2013) bekungumuntu weSewula Afrika olwa nebandlululo kanye nosopolotiki owasebenza njengomongameli wokuthoma weSewula Afrika onzima kusuka  ngomnyaka ka-1994 ukuya ku-1999 . Urhulumende wakhe wadzimelela ekuqedeni ilifa lebandlululo ngokukhuthaza ukubuyisana ngokobuhlanga. Ngokwemibono njengomuntu othanda ubuzwe be-Afrika nosotjhalisti, waba ngummongameli wehlangano ye (ANC) kusuka ngo-1991 ukuya ku-1997.</text>
      <sha1>1v4k5hlv1a61tebfj40jwp0d5nllpoi</sha1>
    </revision>
    <revision>
      <id>5646</id>
      <parentid>5469</parentid>
      <timestamp>2025-09-04T11:03:15Z</timestamp>
      <contributor>
        <username>F.K MAHLANGU</username>
        <id>891</id>
      </contributor>
      <origin>5646</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2199" sha1="h8t5ov2tyw688ytarkmjuiox0uh0bwl" xml:space="preserve">
 
== umlando kaNelson Mandela. ==
[[Isimumathi:Nelson Mandela 1994.jpg|thumb|&lt;ref&gt;[https://upload.wikimedia.org/wikipedia/commons/0/02/Nelson_Mandela_1994.jpg Nelson_Mandela_1994.jpg (1500×1940)]&lt;/ref&gt;Nelson Mandela]]
Mandela wabelethwa ngomhlaka 18 kuVelabahlinze 1918, esgodini seMvezo ngendaweni ebizwa ngokuthi yiMtata, [[:en:Eastern_Cape|eEastern Cape]]&lt;ref&gt;Van Wyk, J.H. (1995-03-06). &quot;Long Walk to Freedom: The Autobiography of Nelson Mandela&quot;. ''Koers - Bulletin for Christian Scholarship''. '''60''' (4). doi:10.4102/koers.v60i4.652. ISSN&amp;nbsp;2304-8557.&lt;/ref&gt;. Wanikelwa igama likaRolihlahla, igama [[Amalimi WeSewula Afrika#IsiXhosa|lesiXhosa]] elitjho ukuthi &quot;troublemaker&quot;&lt;ref&gt;Lodge, Tom (2020-03-31), &quot;The Many Lives of Nelson Mandela&quot;, ''Oxford Research Encyclopedia of African History'', Oxford University Press, ISBN&amp;nbsp;&lt;bdi&gt;978-0-19-027773-4&lt;/bdi&gt;, retrieved 2025-09-04&lt;/ref&gt; kwathi emnyakeni elandelako wathoma ukwaziwa ngesithakazelo sakhe, uMadiba. Ukhokhomkhulu wakhe wehlangothini lika yise, uNgubengcuka wayemdosiphambili wesizwe siThembu [[:en:Transkei|eTranskeian]] kwiphrovinsi yeEastern Cape&lt;ref&gt;Meredith, M. (2010). ''Mandela: A Biography''. New York: PublicAffairs.&lt;/ref&gt;. Omunye wamadodana kaNgubengcuka, ibizo lakhe ekungu Mandela, umkhulu kaNelson, ekunguye ebamthiyelela ngaye. Ngebanga lokobana uMandela wayebelethwa ngendlini yomfazi obuya esitjhabeni seIxhiba, kwenza bona angarhoni ukuba yikosana elandelako.

Ubaba kanelson Mandela, uGadla Henry Mphakanyiswa Mandela, wayeyikosana, wabekwaesihlalweni ngomyaka ka1915, ngemva kokuthi umkhandlo wakhe wakhe uthweswe ngomlandu wokukhwabanisa, uthweswa mkhandlu wabantu abamhlophe&lt;ref&gt;Sampson, A. (1999). ''Mandela: The Authorized Biography''. London: HarperCollins.&lt;/ref&gt;. Ngo1926, uGadla waqotjhwa emsebenzini ngonobangela wokukhwabanisa, kodwana uNelson bamtjela ukuthi uyise bamqothele ukujamela amalungelo nobulungiswa emkhandlwini. UGadla wayenesithembu, abafazi abane, amadodana amane kanye namadodakazi alithoba, ebebahlala endaweni ezihlukileko. Unina kaNelson wayemfazi wesithathu, uNosekeni Fanny, indodakazi kaNkedama wendlu yangesidleni, ilunga lesitjhaba samaMpemvu.

=== Irherho lemithombo. ===</text>
      <sha1>h8t5ov2tyw688ytarkmjuiox0uh0bwl</sha1>
    </revision>
    <revision>
      <id>5908</id>
      <parentid>5646</parentid>
      <timestamp>2025-10-08T11:50:48Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>5908</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2382" sha1="aklvqqkfgz5bo5xj79nv8x22n6rpwhg" xml:space="preserve">
 
== umlando kaNelson Mandela. ==
[[Isimumathi:Nelson Mandela 1994.jpg|thumb|&lt;ref&gt;[https://upload.wikimedia.org/wikipedia/commons/0/02/Nelson_Mandela_1994.jpg Nelson_Mandela_1994.jpg (1500×1940)]&lt;/ref&gt;Nelson Mandela]]
Mandela wabelethwa ngomhlaka 18 kuVelabahlinze 1918, esgodini seMvezo ngendaweni ebizwa ngokuthi yiMtata, [[:en:Eastern_Cape|eEastern Cape]]&lt;ref&gt;Van Wyk, J.H. (1995-03-06). &quot;Long Walk to Freedom: The Autobiography of Nelson Mandela&quot;. ''Koers - Bulletin for Christian Scholarship''. '''60''' (4). doi:10.4102/koers.v60i4.652. ISSN&amp;nbsp;2304-8557.&lt;/ref&gt;. Wanikelwa igama likaRolihlahla, igama [[Amalimi WeSewula Afrika#IsiXhosa|lesiXhosa]] elitjho ukuthi &quot;troublemaker&quot;&lt;ref&gt;Lodge, Tom (2020-03-31), &quot;The Many Lives of Nelson Mandela&quot;, ''Oxford Research Encyclopedia of African History'', Oxford University Press, ISBN&amp;nbsp;&lt;bdi&gt;978-0-19-027773-4&lt;/bdi&gt;, retrieved 2025-09-04&lt;/ref&gt; kwathi emnyakeni elandelako wathoma ukwaziwa ngesithakazelo sakhe, uMadiba. Ukhokhomkhulu wakhe wehlangothini lika yise, uNgubengcuka wayemdosiphambili wesizwe siThembu [[:en:Transkei|eTranskeian]] kwiphrovinsi yeEastern Cape&lt;ref&gt;Meredith, M. (2010). ''Mandela: A Biography''. New York: PublicAffairs.&lt;/ref&gt;. Omunye wamadodana kaNgubengcuka, ibizo lakhe ekungu Mandela, umkhulu kaNelson, ekunguye ebamthiyelela ngaye. Ngebanga lokobana uMandela wayebelethwa ngendlini yomfazi obuya esitjhabeni seIxhiba, kwenza bona angarhoni ukuba yikosana elandelako.
[[Isimumathi:Nelson Mandela, 2000 (5).jpg|thumb|250x250px|Isithombe sika Nelson mandela ]]

Ubaba kanelson Mandela, uGadla Henry Mphakanyiswa Mandela, wayeyikosana, wabekwaesihlalweni ngomyaka ka1915, ngemva kokuthi umkhandlo wakhe wakhe uthweswe ngomlandu wokukhwabanisa, uthweswa mkhandlu wabantu abamhlophe&lt;ref&gt;Sampson, A. (1999). ''Mandela: The Authorized Biography''. London: HarperCollins.&lt;/ref&gt;. Ngo1926, uGadla waqotjhwa emsebenzini ngonobangela wokukhwabanisa, kodwana uNelson bamtjela ukuthi uyise bamqothele ukujamela amalungelo nobulungiswa emkhandlwini. UGadla wayenesithembu, abafazi abane, amadodana amane kanye namadodakazi alithoba, ebebahlala endaweni ezihlukileko. Unina kaNelson wayemfazi wesithathu, uNosekeni Fanny, indodakazi kaNkedama wendlu yangesidleni, ilunga lesitjhaba samaMpemvu.

=== Irherho lemithombo. ===
&lt;references /&gt;
[[Category:1918 births]]
[[Category:Sewula Afrika]]
[[Category:Abosaziwako]]</text>
      <sha1>aklvqqkfgz5bo5xj79nv8x22n6rpwhg</sha1>
    </revision>
  </page>
  <page>
    <title>Nothembi Mkhwebane</title>
    <ns>0</ns>
    <id>225</id>
    <revision>
      <id>1203</id>
      <timestamp>2024-05-03T09:28:48Z</timestamp>
      <contributor>
        <username>incubator&gt;Nomsa Skosana</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;== UNothembi Mkhwebane == Wabelethwa lokha ilanga lilinye enyangeni kaTjhirhweni ngomnyaka we-1953. Wabelethelwa e-Carolina engasi kude ne-Belfast enarheni yeSewula Afrika.   UNothembi Mkhwebane mvumi nombethi gathara owaziwako welimi lesiNdebele. Ugogwakhe wamfundisa ukubetha iinsetjenziswa zomvumi ezinjengesikumero, isidonodono neengubhu. Umalumakhe kwaba nguye omfundisa ukubetha igatara eyenziwe ngesigubhu se-oyila. Bekanande amfundisa ukubetha igathara lokha nabasema...&quot;</comment>
      <origin>1203</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="927" sha1="4dwzer2xs74xpvehub4zc5jipca4r0i" xml:space="preserve">== UNothembi Mkhwebane ==
Wabelethwa lokha ilanga lilinye enyangeni kaTjhirhweni ngomnyaka we-1953. Wabelethelwa e-Carolina engasi kude ne-Belfast enarheni yeSewula Afrika. 

UNothembi Mkhwebane mvumi nombethi gathara owaziwako welimi lesiNdebele. Ugogwakhe wamfundisa ukubetha iinsetjenziswa zomvumi ezinjengesikumero, isidonodono neengubhu. Umalumakhe kwaba nguye omfundisa ukubetha igatara eyenziwe ngesigubhu se-oyila. Bekanande amfundisa ukubetha igathara lokha nabasemasimini ngesikhathi sokudla nangemva kokuraga iinkomo. 

Ngomnyaka we-1977 wathoma ukusebenza ePitori, la akghona khona ukuzithengela igatarakhe yokuthoma nekhibhodi. Wathoma ukuzenzela umvumo watlola neengoma ezinengana okungezakhe. Ngomnyaka we-1980 wasungula isiqhema sakhe sokuvuma esabizwa ngokobana yiNothembi Nezelamani Zakonomazyana. Isiqhemesi besimenywa khulu bona sivume besinandise eminyanyeni eminengi efana nemitjhado, neminye iminyanya.

</text>
      <sha1>4dwzer2xs74xpvehub4zc5jipca4r0i</sha1>
    </revision>
    <revision>
      <id>1204</id>
      <parentid>1203</parentid>
      <timestamp>2024-05-03T09:49:26Z</timestamp>
      <contributor>
        <username>incubator&gt;Nomsa Skosana</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1204</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="978" sha1="njfys367zy5i5y0kkb3q9e2e17cpjdl" xml:space="preserve">== UNothembi Mkhwebane ==
Wabelethwa lokha ilanga lilinye enyangeni kaTjhirhweni ngomnyaka we-1953. Wabelethelwa e-Carolina engasi kude ne-Belfast enarheni yeSewula Afrika. 

UNothembi Mkhwebane mvumi nombethi gathara owaziwako welimi lesi[[:en:Southern_Ndebele_language|Ndebele]]. Ugogwakhe wamfundisa ukubetha iinsetjenziswa zomvumi ezinjengesikumero, isidonodono neengubhu. Umalumakhe kwaba nguye omfundisa ukubetha igatara eyenziwe ngesigubhu se-oyila. Bekanande amfundisa ukubetha igathara lokha nabasemasimini ngesikhathi sokudla nangemva kokuraga iinkomo. 

Ngomnyaka we-1977 wathoma ukusebenza e[[:en:Pretoria|Pitori]], la akghona khona ukuzithengela igatarakhe yokuthoma nekhibhodi. Wathoma ukuzenzela umvumo watlola neengoma ezinengana okungezakhe. Ngomnyaka we-1980 wasungula isiqhema sakhe sokuvuma esabizwa ngokobana yiNothembi Nezelamani Zakonomazyana. Isiqhemesi besimenywa khulu bona sivume besinandise eminyanyeni eminengi efana nemitjhado, neminye iminyanya.

</text>
      <sha1>njfys367zy5i5y0kkb3q9e2e17cpjdl</sha1>
    </revision>
    <revision>
      <id>1205</id>
      <parentid>1204</parentid>
      <timestamp>2024-10-14T13:47:06Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>1204</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="978" sha1="njfys367zy5i5y0kkb3q9e2e17cpjdl" xml:space="preserve">== UNothembi Mkhwebane ==
Wabelethwa lokha ilanga lilinye enyangeni kaTjhirhweni ngomnyaka we-1953. Wabelethelwa e-Carolina engasi kude ne-Belfast enarheni yeSewula Afrika. 

UNothembi Mkhwebane mvumi nombethi gathara owaziwako welimi lesi[[:en:Southern_Ndebele_language|Ndebele]]. Ugogwakhe wamfundisa ukubetha iinsetjenziswa zomvumi ezinjengesikumero, isidonodono neengubhu. Umalumakhe kwaba nguye omfundisa ukubetha igatara eyenziwe ngesigubhu se-oyila. Bekanande amfundisa ukubetha igathara lokha nabasemasimini ngesikhathi sokudla nangemva kokuraga iinkomo. 

Ngomnyaka we-1977 wathoma ukusebenza e[[:en:Pretoria|Pitori]], la akghona khona ukuzithengela igatarakhe yokuthoma nekhibhodi. Wathoma ukuzenzela umvumo watlola neengoma ezinengana okungezakhe. Ngomnyaka we-1980 wasungula isiqhema sakhe sokuvuma esabizwa ngokobana yiNothembi Nezelamani Zakonomazyana. Isiqhemesi besimenywa khulu bona sivume besinandise eminyanyeni eminengi efana nemitjhado, neminye iminyanya.

</text>
      <sha1>njfys367zy5i5y0kkb3q9e2e17cpjdl</sha1>
    </revision>
    <revision>
      <id>6694</id>
      <parentid>1205</parentid>
      <timestamp>2026-06-12T08:02:53Z</timestamp>
      <contributor>
        <username>MissHadassah</username>
        <id>1561</id>
      </contributor>
      <comment>added an external  reference</comment>
      <origin>6694</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1246" sha1="ji1f91g99d1biw9vy16p1azy1onyewi" xml:space="preserve">== UNothembi Mkhwebane ==
Wabelethwa lokha ilanga lilinye enyangeni kaTjhirhweni ngomnyaka we-1953. Wabelethelwa e-Carolina engasi kude ne-Belfast enarheni yeSewula Afrika. 

UNothembi Mkhwebane&lt;ref&gt;[https://www.kaya959.co.za/nothembi-mkhwebane-queen-of-ndebele-music/ Nothembi Mkhwebane, Queen of Ndebele music - KAYA 959]&lt;/ref&gt; mvumi nombethi gathara owaziwako welimi lesi[[:en:Southern_Ndebele_language|Ndebele]]. Ugogwakhe wamfundisa ukubetha iinsetjenziswa zomvumi ezinjengesikumero, isidonodono neengubhu. Umalumakhe kwaba nguye omfundisa ukubetha igatara eyenziwe ngesigubhu se-oyila. Bekanande amfundisa ukubetha igathara lokha nabasemasimini ngesikhathi sokudla nangemva kokuraga iinkomo. 

Ngomnyaka we-1977 wathoma ukusebenza e[[:en:Pretoria|Pitori]], la akghona khona ukuzithengela&lt;ref&gt;[https://www.kaya959.co.za/nothembi-mkhwebane-queen-of-ndebele-music/ Nothembi Mkhwebane, Queen of Ndebele music - KAYA 959]&lt;/ref&gt; igatarakhe yokuthoma nekhibhodi. Wathoma ukuzenzela umvumo watlola neengoma ezinengana okungezakhe. Ngomnyaka we-1980 wasungula isiqhema sakhe sokuvuma esabizwa ngokobana yiNothembi Nezelamani Zakonomazyana. Isiqhemesi besimenywa khulu bona sivume besinandise eminyanyeni eminengi efana nemitjhado, neminye iminyanya.</text>
      <sha1>ji1f91g99d1biw9vy16p1azy1onyewi</sha1>
    </revision>
  </page>
  <page>
    <title>Oscar Pretorious</title>
    <ns>0</ns>
    <id>226</id>
    <revision>
      <id>1206</id>
      <timestamp>2024-03-12T19:19:44Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;uOscar Pretorius wayengumgijimi waseNingizimu Afrka okhubazekileyo owaziwa ngokubulala intombi yakhe uReeva Steenkamp. &lt;ref&gt;https://www.bbc.com/news/world-africa-67885713&lt;/ref&gt;  &quot;</comment>
      <origin>1206</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="178" sha1="mu3wcwr1lksaq9ie6ik0yxnob3uo7oa" xml:space="preserve">uOscar Pretorius wayengumgijimi waseNingizimu Afrka okhubazekileyo owaziwa ngokubulala intombi yakhe uReeva Steenkamp. &lt;ref&gt;https://www.bbc.com/news/world-africa-67885713&lt;/ref&gt;

</text>
      <sha1>mu3wcwr1lksaq9ie6ik0yxnob3uo7oa</sha1>
    </revision>
    <revision>
      <id>1207</id>
      <parentid>1206</parentid>
      <timestamp>2024-03-12T19:20:41Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1207</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="310" sha1="ditlrc6u90jl8kkoqcp1qg6afjzqoe7" xml:space="preserve">uOscar Pretorius wayengumgijimi waseNingizimu Afrka okhubazekileyo owaziwa ngokubulala intombi yakhe uReeva Steenkamp. &lt;ref&gt;https://www.bbc.com/news/world-africa-67885713&lt;/ref&gt;&lt;ref&gt;https://www.africanews.com/2024/01/05/south-africa-pretoria-residents-react-to-news-of-oscar-pistorius-release-from-jail/&lt;/ref&gt;

</text>
      <sha1>ditlrc6u90jl8kkoqcp1qg6afjzqoe7</sha1>
    </revision>
    <revision>
      <id>1208</id>
      <parentid>1207</parentid>
      <timestamp>2024-03-12T19:21:00Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1208</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="316" sha1="86vp4ursbv2dfwx4lioeaha0orb71zc" xml:space="preserve">'''uOscar Pretorius''' wayengumgijimi waseNingizimu Afrka okhubazekileyo owaziwa ngokubulala intombi yakhe uReeva Steenkamp. &lt;ref&gt;https://www.bbc.com/news/world-africa-67885713&lt;/ref&gt;&lt;ref&gt;https://www.africanews.com/2024/01/05/south-africa-pretoria-residents-react-to-news-of-oscar-pistorius-release-from-jail/&lt;/ref&gt;

</text>
      <sha1>86vp4ursbv2dfwx4lioeaha0orb71zc</sha1>
    </revision>
    <revision>
      <id>1209</id>
      <parentid>1208</parentid>
      <timestamp>2024-03-12T19:21:38Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1209</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="332" sha1="ixzxw5m8nddpibk4bztwk6tjndo8uol" xml:space="preserve">'''uOscar Pretorius''' wayengumgijimi wase[[Isewula Afrika|Sewula Afrka]] okhubazekileyo owaziwa ngokubulala intombi yakhe uReeva Steenkamp. &lt;ref&gt;https://www.bbc.com/news/world-africa-67885713&lt;/ref&gt;&lt;ref&gt;https://www.africanews.com/2024/01/05/south-africa-pretoria-residents-react-to-news-of-oscar-pistorius-release-from-jail/&lt;/ref&gt;

</text>
      <sha1>ixzxw5m8nddpibk4bztwk6tjndo8uol</sha1>
    </revision>
    <revision>
      <id>1210</id>
      <parentid>1209</parentid>
      <timestamp>2024-10-14T13:47:06Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>4 revisions imported</comment>
      <origin>1209</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="332" sha1="ixzxw5m8nddpibk4bztwk6tjndo8uol" xml:space="preserve">'''uOscar Pretorius''' wayengumgijimi wase[[Isewula Afrika|Sewula Afrka]] okhubazekileyo owaziwa ngokubulala intombi yakhe uReeva Steenkamp. &lt;ref&gt;https://www.bbc.com/news/world-africa-67885713&lt;/ref&gt;&lt;ref&gt;https://www.africanews.com/2024/01/05/south-africa-pretoria-residents-react-to-news-of-oscar-pistorius-release-from-jail/&lt;/ref&gt;

</text>
      <sha1>ixzxw5m8nddpibk4bztwk6tjndo8uol</sha1>
    </revision>
    <revision>
      <id>2168</id>
      <parentid>1210</parentid>
      <timestamp>2024-11-27T06:22:50Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>+ Iinkomba</comment>
      <origin>2168</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="358" sha1="0db69cnk466uz8ozhaxf9zxc6cvqko3" xml:space="preserve">'''uOscar Pretorius''' wayengumgijimi wase[[Isewula Afrika|Sewula Afrka]] okhubazekileyo owaziwa ngokubulala intombi yakhe uReeva Steenkamp. &lt;ref&gt;https://www.bbc.com/news/world-africa-67885713&lt;/ref&gt;&lt;ref&gt;https://www.africanews.com/2024/01/05/south-africa-pretoria-residents-react-to-news-of-oscar-pistorius-release-from-jail/&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}</text>
      <sha1>0db69cnk466uz8ozhaxf9zxc6cvqko3</sha1>
    </revision>
    <revision>
      <id>2182</id>
      <parentid>2168</parentid>
      <timestamp>2024-11-28T12:22:47Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <origin>2182</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="357" sha1="2cafesom5j4qh9u5qmvrdr94ei5mk11" xml:space="preserve">'''uOscar Pretorius''' wayengumgijimi wase[[Isewula Afrika|Sewula Afrka]] okhubazekileyo owaziwa ngokubulala intombi yakhe uReeva Steenkamp.&lt;ref&gt;https://www.bbc.com/news/world-africa-67885713&lt;/ref&gt;&lt;ref&gt;https://www.africanews.com/2024/01/05/south-africa-pretoria-residents-react-to-news-of-oscar-pistorius-release-from-jail/&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}</text>
      <sha1>2cafesom5j4qh9u5qmvrdr94ei5mk11</sha1>
    </revision>
    <revision>
      <id>2967</id>
      <parentid>2182</parentid>
      <timestamp>2025-06-06T19:57:05Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>efg</comment>
      <origin>2967</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="438" sha1="o2kd55mpd428wi0db1ok5a64haw35sf" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. uOscar Pretorius''' wayengumgijimi wase[[Isewula Afrika|Sewula Afrka]] okhubazekileyo owaziwa ngokubulala intombi yakhe uReeva Steenkamp.&lt;ref&gt;https://www.bbc.com/news/world-africa-67885713&lt;/ref&gt;&lt;ref&gt;https://www.africanews.com/2024/01/05/south-africa-pretoria-residents-react-to-news-of-oscar-pistorius-release-from-jail/&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}</text>
      <sha1>o2kd55mpd428wi0db1ok5a64haw35sf</sha1>
    </revision>
    <revision>
      <id>3089</id>
      <parentid>2967</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Simakahle Moselekatse|Simakahle Moselekatse]]</comment>
      <origin>2182</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="357" sha1="2cafesom5j4qh9u5qmvrdr94ei5mk11" xml:space="preserve">'''uOscar Pretorius''' wayengumgijimi wase[[Isewula Afrika|Sewula Afrka]] okhubazekileyo owaziwa ngokubulala intombi yakhe uReeva Steenkamp.&lt;ref&gt;https://www.bbc.com/news/world-africa-67885713&lt;/ref&gt;&lt;ref&gt;https://www.africanews.com/2024/01/05/south-africa-pretoria-residents-react-to-news-of-oscar-pistorius-release-from-jail/&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}</text>
      <sha1>2cafesom5j4qh9u5qmvrdr94ei5mk11</sha1>
    </revision>
  </page>
  <page>
    <title>PB Skhosana</title>
    <ns>0</ns>
    <id>227</id>
    <revision>
      <id>1211</id>
      <timestamp>2016-02-26T21:01:37Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;{{Person| | ibizo = P.B. Skhosana | isithombe =  | umsebenzi = Umtloli | ubelethwe ngo = 13 kuVelabahlinze 1954 | indawo yo kubelethwa = Henrdina, eMpumalanga | wahlonga...&quot;</comment>
      <origin>1211</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1879" sha1="dpu1v573w15wux276aby1836yvw1qso" xml:space="preserve">{{Person|
| ibizo = P.B. Skhosana
| isithombe = 
| umsebenzi = Umtloli
| ubelethwe ngo = 13 kuVelabahlinze 1954
| indawo yo kubelethwa = Henrdina, eMpumalanga
| wahlongakala ngo = 
| indawo yo hlongakala = 
}}
'''Philemon Buti Skhosana''' (13 kuVelabahlinze 1954), ngumtloli oqkathekile wemitlolo yesindebele begodu waziwa nge drama yakhe ethi ''&quot;Larhwalala Nobani&quot;''. Wathoma ukufunda isikolo ngomnyaka we-1964 esikolweni sebanga eliphasi iMeerlus eseduze neMayini i-Blesbok eseduze neMiddleburg wase uphothula iimfundo zakhe zeMetrigi eMayitjha High School eWaterval esabelweni saKwaNdebele ngomnyaka we-1976.&lt;ref name=ph1&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt;

Wabandulwa njengothitjhere e-Botshabelo Training Institution, ngethlagwini ye-Middelburg. Emva kokuphetha iimfundo zakhe ze-Primary teachers Certificate ngomnyaka ka 1978. Wafundisa eBuhlebethu High School eSiyabuswa kwaNdebele kufikela ngomnyaka ka1984 lapho akhutjhulwa khona ngengesiphathiswa sezamasiko emNyangweni wezeFundo namaSiko kuRhulumende walokha wakwaNdebele. UNom Skhosana waba nerhuluphelo bewathoma ngokuzibandakanya ekuthuthukisweni kwelimi lesiNdebele ukusukela ngomyaka ka 1986 emva kwalapho waba lilungu leBhodi yeLimi lesiNdebele seSewula. Umsebenzi wakhe wokuthoma wakhutjhwa ngo 1991, ekuyintolwana yesihloko esithi Isigiyani. 

Ukufikela namhlanje uNom Skhosana sele atlole iincwadi ezimihlobohlobo zesiNdebele ezidlula e-16. Kwagadesi umfundisi omkhulu emNyangweni wamaLimi wenDabuko eYunivesithi yePitori, ukusukela ngomyaka ka 1997, uphumelele ukuthuthukisa imatheriyali yelimi lesiNdebele kiwo woke amazinga weemfundo zeyunivesithi.

==Isithasiselo==
&lt;references/&gt;

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>dpu1v573w15wux276aby1836yvw1qso</sha1>
    </revision>
    <revision>
      <id>1212</id>
      <parentid>1211</parentid>
      <timestamp>2016-02-26T21:19:03Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1212</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1846" sha1="18ilwskbq3zv61waunhb3mbpakdsyeg" xml:space="preserve">{{Person|
| ibizo = P.B. Skhosana
| isithombe = PB Skhosana.png
| umsebenzi = Umtloli
| ubelethwe ngo = 13 kuVelabahlinze 1954
| indawo yo kubelethwa = Henrdina, eMpumalanga
}}
'''Philemon Buti Skhosana''' (13 kuVelabahlinze 1954), ngumtloli oqkathekile wemitlolo yesindebele begodu waziwa nge drama yakhe ethi ''&quot;Larhwalala Nobani&quot;''. Wathoma ukufunda isikolo ngomnyaka we-1964 esikolweni sebanga eliphasi iMeerlus eseduze neMayini i-Blesbok eseduze neMiddleburg wase uphothula iimfundo zakhe zeMetrigi eMayitjha High School eWaterval esabelweni saKwaNdebele ngomnyaka we-1976.&lt;ref name=ph1&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt;

Wabandulwa njengothitjhere e-Botshabelo Training Institution, ngethlagwini ye-Middelburg. Emva kokuphetha iimfundo zakhe ze-Primary teachers Certificate ngomnyaka ka 1978. Wafundisa eBuhlebethu High School eSiyabuswa kwaNdebele kufikela ngomnyaka ka1984 lapho akhutjhulwa khona ngengesiphathiswa sezamasiko emNyangweni wezeFundo namaSiko kuRhulumende walokha wakwaNdebele. UNom Skhosana waba nerhuluphelo bewathoma ngokuzibandakanya ekuthuthukisweni kwelimi lesiNdebele ukusukela ngomyaka ka 1986 emva kwalapho waba lilungu leBhodi yeLimi lesiNdebele seSewula. Umsebenzi wakhe wokuthoma wakhutjhwa ngo 1991, ekuyintolwana yesihloko esithi Isigiyani. 

Ukufikela namhlanje uNom Skhosana sele atlole iincwadi ezimihlobohlobo zesiNdebele ezidlula e-16. Kwagadesi umfundisi omkhulu emNyangweni wamaLimi wenDabuko eYunivesithi yePitori, ukusukela ngomyaka ka 1997, uphumelele ukuthuthukisa imatheriyali yelimi lesiNdebele kiwo woke amazinga weemfundo zeyunivesithi.

==Isithasiselo==
&lt;references/&gt;

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>18ilwskbq3zv61waunhb3mbpakdsyeg</sha1>
    </revision>
    <revision>
      <id>1213</id>
      <parentid>1212</parentid>
      <timestamp>2024-03-08T10:30:15Z</timestamp>
      <contributor>
        <username>incubator&gt;KhethiweMsiza94</username>
        <id>0</id>
      </contributor>
      <comment>translated from zulu and added affairs</comment>
      <origin>1213</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1835" sha1="nvj97b9q2cktylcxahitz7aoxmgh7dr" xml:space="preserve">{{Person|
| ibizo = P.B. Skhosana
| isithombe = PB Skhosana.png
| umsebenzi = Umtloli
| ubelethwe ngo = 13 kuVelabahlinze 1954
| indawo yo kubelethwa = Henrdina, eMpumalanga
}}
'''Philemon Buti Skhosana''' (13 kuVelabahlinze 1954), mtloli oqakathekileko wemitlolo yesindebele waziwa ngomdlalo yakhe i''&quot;Larhwalala Nobani&quot;''. Wathoma ukufunda isikolo ngomnyaka ka-1964 esikolweni sebanga eliphasi iMeerlus eseduze neMayini i-Blesbok eseduze neMiddleburg waqudelela  iimfundo zakhe zetjhumi eMayitjha High School eWaterval esabelweni saKwaNdebele ngomnyaka ka-1976.&lt;ref name=ph1&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt;

Wabandulwa njengothitjhere e-Botshabelo Training Institution, ngethlagwini ye-Middelburg. ngemva kokuphetha iimfundo zakhe ze-Primary teachers Certificate ngomnyaka ka 1978. Wafundisa eBuhlebethu High School eSiyabuswa kwaNdebele kufikela ngomnyaka ka1984 lapho akhutjhulwa khona njengesiphathiswa sezamasiko emnyangweni wezeFundo namaSiko kuRhulumende walokha wakwaNdebele. UNom Skhosana waba nerhuluphelo  lokuzibandakanya ekuthuthukisweni kwelimi lesiNdebele ukusukela ngomyaka ka 1986 ngemva kwalapho waba lilungu leBhodi yeLimi lesiNdebele seSewula. Umsebenzi wakhe wokuthoma wakhutjhwa ngo 1991, ekuyintolwana yesihloko esithi Isigiyani. 

Ukufikela namhlanje uNom Skhosana sele atlole iincwadi ezimihlobohlobo zesiNdebele ezidlula kutjhumi nesithabdathu.bekamfundisi omkhulu emNyangweni wamaLimi wenDabuko eYunivesithi yePitori, ukusukela ngomyaka ka 1997, uphumelele ukuthuthukisa imatheriyali yelimi lesiNdebele kiwo woke amazinga weemfundo zeyunivesithi.

==Isithasiselo==
&lt;references/&gt;

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>nvj97b9q2cktylcxahitz7aoxmgh7dr</sha1>
    </revision>
    <revision>
      <id>1214</id>
      <parentid>1213</parentid>
      <timestamp>2024-10-14T13:47:07Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>1213</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1835" sha1="nvj97b9q2cktylcxahitz7aoxmgh7dr" xml:space="preserve">{{Person|
| ibizo = P.B. Skhosana
| isithombe = PB Skhosana.png
| umsebenzi = Umtloli
| ubelethwe ngo = 13 kuVelabahlinze 1954
| indawo yo kubelethwa = Henrdina, eMpumalanga
}}
'''Philemon Buti Skhosana''' (13 kuVelabahlinze 1954), mtloli oqakathekileko wemitlolo yesindebele waziwa ngomdlalo yakhe i''&quot;Larhwalala Nobani&quot;''. Wathoma ukufunda isikolo ngomnyaka ka-1964 esikolweni sebanga eliphasi iMeerlus eseduze neMayini i-Blesbok eseduze neMiddleburg waqudelela  iimfundo zakhe zetjhumi eMayitjha High School eWaterval esabelweni saKwaNdebele ngomnyaka ka-1976.&lt;ref name=ph1&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt;

Wabandulwa njengothitjhere e-Botshabelo Training Institution, ngethlagwini ye-Middelburg. ngemva kokuphetha iimfundo zakhe ze-Primary teachers Certificate ngomnyaka ka 1978. Wafundisa eBuhlebethu High School eSiyabuswa kwaNdebele kufikela ngomnyaka ka1984 lapho akhutjhulwa khona njengesiphathiswa sezamasiko emnyangweni wezeFundo namaSiko kuRhulumende walokha wakwaNdebele. UNom Skhosana waba nerhuluphelo  lokuzibandakanya ekuthuthukisweni kwelimi lesiNdebele ukusukela ngomyaka ka 1986 ngemva kwalapho waba lilungu leBhodi yeLimi lesiNdebele seSewula. Umsebenzi wakhe wokuthoma wakhutjhwa ngo 1991, ekuyintolwana yesihloko esithi Isigiyani. 

Ukufikela namhlanje uNom Skhosana sele atlole iincwadi ezimihlobohlobo zesiNdebele ezidlula kutjhumi nesithabdathu.bekamfundisi omkhulu emNyangweni wamaLimi wenDabuko eYunivesithi yePitori, ukusukela ngomyaka ka 1997, uphumelele ukuthuthukisa imatheriyali yelimi lesiNdebele kiwo woke amazinga weemfundo zeyunivesithi.

==Isithasiselo==
&lt;references/&gt;

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>nvj97b9q2cktylcxahitz7aoxmgh7dr</sha1>
    </revision>
    <revision>
      <id>2101</id>
      <parentid>1214</parentid>
      <timestamp>2024-11-25T09:46:05Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <comment>'''</comment>
      <origin>2101</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1829" sha1="gibj7bsta1uwgnnw81g23ql7gctpx9g" xml:space="preserve">{{Person|
| ibizo = P.B. Skhosana
| isithombe = PB Skhosana.png
| umsebenzi = Umtloli
| ubelethwe ngo = 13 kuVelabahlinze 1954
| indawo yo kubelethwa = Henrdina, eMpumalanga
}}
'''Philemon Buti Skhosana''' (13 kuVelabahlinze 1954), mtloli oqakathekileko wemitlolo yesindebele waziwa ngomdlalo yakhe i''&quot;Larhwalala Nobani&quot;''. Wathoma ukufunda isikolo ngomnyaka ka-1964 esikolweni sebanga eliphasi iMeerlus eseduze neMayini i-Blesbok eseduze neMiddleburg waqudelela  iimfundo zakhe zetjhumi eMayitjha High School eWaterval esabelweni saKwaNdebele ngomnyaka ka-1976.&lt;ref name=ph1&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - National Library of South Africa. Retrieved 22 February 2016&lt;/ref&gt;

Wabandulwa njengothitjhere e-Botshabelo Training Institution, ngethlagwini ye-Middelburg. ngemva kokuphetha iimfundo zakhe ze-Primary teachers Certificate ngomnyaka ka 1978. Wafundisa eBuhlebethu High School eSiyabuswa kwaNdebele kufikela ngomnyaka ka1984 lapho akhutjhulwa khona njengesiphathiswa sezamasiko emnyangweni wezeFundo namaSiko kuRhulumende walokha wakwaNdebele. UNom Skhosana waba nerhuluphelo  lokuzibandakanya ekuthuthukisweni kwelimi lesiNdebele ukusukela ngomyaka ka 1986 ngemva kwalapho waba lilungu leBhodi yeLimi lesiNdebele seSewula. Umsebenzi wakhe wokuthoma wakhutjhwa ngo 1991, ekuyintolwana yesihloko esithi Isigiyani. 

Ukufikela namhlanje uNom Skhosana sele atlole iincwadi ezimihlobohlobo zesiNdebele ezidlula kutjhumi nesithabdathu.bekamfundisi omkhulu emNyangweni wamaLimi wenDabuko eYunivesithi yePitori, ukusukela ngomyaka ka 1997, uphumelele ukuthuthukisa imatheriyali yelimi lesiNdebele kiwo woke amazinga weemfundo zeyunivesithi.

==Isithasiselo==
&lt;references/&gt;

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>gibj7bsta1uwgnnw81g23ql7gctpx9g</sha1>
    </revision>
    <revision>
      <id>2204</id>
      <parentid>2101</parentid>
      <timestamp>2024-11-29T07:27:17Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <comment>/* Isithasiselo */Reflist</comment>
      <origin>2204</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1827" sha1="22gbwjsa0p976qfgbclrohfvef4ajln" xml:space="preserve">{{Person|
| ibizo = P.B. Skhosana
| isithombe = PB Skhosana.png
| umsebenzi = Umtloli
| ubelethwe ngo = 13 kuVelabahlinze 1954
| indawo yo kubelethwa = Henrdina, eMpumalanga
}}
'''Philemon Buti Skhosana''' (13 kuVelabahlinze 1954), mtloli oqakathekileko wemitlolo yesindebele waziwa ngomdlalo yakhe i''&quot;Larhwalala Nobani&quot;''. Wathoma ukufunda isikolo ngomnyaka ka-1964 esikolweni sebanga eliphasi iMeerlus eseduze neMayini i-Blesbok eseduze neMiddleburg waqudelela  iimfundo zakhe zetjhumi eMayitjha High School eWaterval esabelweni saKwaNdebele ngomnyaka ka-1976.&lt;ref name=ph1&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - National Library of South Africa. Retrieved 22 February 2016&lt;/ref&gt;

Wabandulwa njengothitjhere e-Botshabelo Training Institution, ngethlagwini ye-Middelburg. ngemva kokuphetha iimfundo zakhe ze-Primary teachers Certificate ngomnyaka ka 1978. Wafundisa eBuhlebethu High School eSiyabuswa kwaNdebele kufikela ngomnyaka ka1984 lapho akhutjhulwa khona njengesiphathiswa sezamasiko emnyangweni wezeFundo namaSiko kuRhulumende walokha wakwaNdebele. UNom Skhosana waba nerhuluphelo  lokuzibandakanya ekuthuthukisweni kwelimi lesiNdebele ukusukela ngomyaka ka 1986 ngemva kwalapho waba lilungu leBhodi yeLimi lesiNdebele seSewula. Umsebenzi wakhe wokuthoma wakhutjhwa ngo 1991, ekuyintolwana yesihloko esithi Isigiyani. 

Ukufikela namhlanje uNom Skhosana sele atlole iincwadi ezimihlobohlobo zesiNdebele ezidlula kutjhumi nesithabdathu.bekamfundisi omkhulu emNyangweni wamaLimi wenDabuko eYunivesithi yePitori, ukusukela ngomyaka ka 1997, uphumelele ukuthuthukisa imatheriyali yelimi lesiNdebele kiwo woke amazinga weemfundo zeyunivesithi.

==Isithasiselo==
{{Reflist}}

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>22gbwjsa0p976qfgbclrohfvef4ajln</sha1>
    </revision>
  </page>
  <page>
    <title>PanSALB</title>
    <ns>0</ns>
    <id>228</id>
    <revision>
      <id>1215</id>
      <timestamp>2024-03-04T20:32:23Z</timestamp>
      <contributor>
        <username>incubator&gt;Nomsa Skosana</username>
        <id>0</id>
      </contributor>
      <comment>New article</comment>
      <origin>1215</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="598" sha1="oq67tmse72uz4j6g5y1c19fl4mcb904" xml:space="preserve">I-Pan South African Language Board (PanSALB) liziko leSewula Afrika elasungulwa bona lithuthukise ubuliminengi nawo woke amalimi asemthethweni weSewula Afrika, begodu nokobana livikele amalungelo wamalimi la woke. Ibhodi le yasungulwa ngaphasi komThetho wama-59 ngomnyaka we-1995 yiPalamende yeSewula Afrika.

Ngaphezu kwamalimi ali-12 asemthethweni weSewula Afrika i-PanSALB iqalelele godu nekuthuthukiseni amalimi afaka hlangana i-Khoe ne-San.

Ihlelo le-PanSALB lifaka hlangana: amaKomiti weemFunda wamaLimi, amaKomiti wesiTjhaba wamaLimi namaYunithi wamaHlelo wokuTlolwa kweenHlathululi maGama.</text>
      <sha1>oq67tmse72uz4j6g5y1c19fl4mcb904</sha1>
    </revision>
    <revision>
      <id>1216</id>
      <parentid>1215</parentid>
      <timestamp>2024-03-09T07:29:02Z</timestamp>
      <contributor>
        <username>incubator&gt;Napangela</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1216</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="632" sha1="7jnfb2190w8ls2pfuycmt3eo4d1et67" xml:space="preserve">'''I-Pan South African Language Board (PanSALB)''' liziko leSewula Afrika elasungulwa bona lithuthukise ubuliminengi nawo woke amalimi asemthethweni weSewula Afrika, begodu nokobana livikele amalungelo wamalimi la woke. Ibhodi le yasungulwa ngaphasi komThetho wama-59 ngomnyaka we-1995 yiPalamende yeSewula Afrika.

== Khuyini i-PANSALB ==
Ngaphezu kwamalimi ali-12 asemthethweni weSewula Afrika i-PanSALB iqalelele godu nekuthuthukiseni amalimi afaka hlangana i-Khoe ne-San.

Ihlelo le[[-PanSALB]] lifaka hlangana: amaKomiti weemFunda wamaLimi, amaKomiti wesiTjhaba wamaLimi namaYunithi wamaHlelo wokuTlolwa kweenHlathululi maGama.</text>
      <sha1>7jnfb2190w8ls2pfuycmt3eo4d1et67</sha1>
    </revision>
    <revision>
      <id>1217</id>
      <parentid>1216</parentid>
      <timestamp>2024-03-09T07:38:36Z</timestamp>
      <contributor>
        <username>incubator&gt;Leratonathasher369</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1217</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="674" sha1="or3y921wx04fg4mmg8pg8rj2iw285zf" xml:space="preserve">'''I-Pan South African Language Board (PanSALB)''' liziko le[[Isewula Afrika|Sewula Afrika]] elasungulwa bona lithuthukise ubuliminengi nawo woke amalimi asemthethweni weSewula Afrika, begodu nokobana livikele amalungelo wamalimi la woke. Ibhodi le yasungulwa ngaphasi komThetho wama-59 ngomnyaka we-1995 yi[[Palamende]] ye[[Isewula Afrika|Sewula Afrika]].

== Khuyini i-PANSALB ==
Ngaphezu kwamalimi ali-12 asemthethweni weSewula Afrika i-PanSALB iqalelele godu nekuthuthukiseni amalimi afaka hlangana i-Khoe ne-San.

Ihlelo le[[-PanSALB]] lifaka hlangana: amaKomiti weemFunda wamaLimi, amaKomiti wesiTjhaba wamaLimi namaYunithi wamaHlelo wokuTlolwa kweenHlathululi maGama.</text>
      <sha1>or3y921wx04fg4mmg8pg8rj2iw285zf</sha1>
    </revision>
    <revision>
      <id>1218</id>
      <parentid>1217</parentid>
      <timestamp>2024-03-09T08:13:24Z</timestamp>
      <contributor>
        <username>incubator&gt;Nomsa Skosana</username>
        <id>0</id>
      </contributor>
      <comment>/* Khuyini i-PANSALB */</comment>
      <origin>1218</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="685" sha1="o3jdklpzs19jsqw8itdzoxjtapi22wq" xml:space="preserve">'''I-Pan South African Language Board (PanSALB)''' liziko le[[Isewula Afrika|Sewula Afrika]] elasungulwa bona lithuthukise ubuliminengi nawo woke amalimi asemthethweni weSewula Afrika, begodu nokobana livikele amalungelo wamalimi la woke. Ibhodi le yasungulwa ngaphasi komThetho wama-59 ngomnyaka we-1995 yi[[Palamende]] ye[[Isewula Afrika|Sewula Afrika]].

== Eminye Imisebenzi ye-PanSALB ==
Ngaphezu kwamalimi ali-12 asemthethweni weSewula Afrika i-PanSALB iqalelele godu nekuthuthukiseni amalimi afaka hlangana i-Khoe ne-San.

Ihlelo le[[-PanSALB]] lifaka hlangana: amaKomiti weemFunda wamaLimi, amaKomiti wesiTjhaba wamaLimi namaYunithi wamaHlelo wokuTlolwa kweenHlathululi maGama.</text>
      <sha1>o3jdklpzs19jsqw8itdzoxjtapi22wq</sha1>
    </revision>
    <revision>
      <id>1219</id>
      <parentid>1218</parentid>
      <timestamp>2024-03-09T08:16:13Z</timestamp>
      <contributor>
        <username>incubator&gt;JesicaMasilela17</username>
        <id>0</id>
      </contributor>
      <comment>Added picture</comment>
      <origin>1219</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="745" sha1="oosqmirw2c0t2e531kto2551ldeapx0" xml:space="preserve">[[Isimumathi:DM-MarianneLanguageBoard (cropped).jpg|thumb]]
'''I-Pan South African Language Board (PanSALB)''' liziko le[[Isewula Afrika|Sewula Afrika]] elasungulwa bona lithuthukise ubuliminengi nawo woke amalimi asemthethweni weSewula Afrika, begodu nokobana livikele amalungelo wamalimi la woke. Ibhodi le yasungulwa ngaphasi komThetho wama-59 ngomnyaka we-1995 yi[[Palamende]] ye[[Isewula Afrika|Sewula Afrika]].

== Eminye Imisebenzi ye-PanSALB ==
Ngaphezu kwamalimi ali-12 asemthethweni weSewula Afrika i-PanSALB iqalelele godu nekuthuthukiseni amalimi afaka hlangana i-Khoe ne-San.

Ihlelo le[[-PanSALB]] lifaka hlangana: amaKomiti weemFunda wamaLimi, amaKomiti wesiTjhaba wamaLimi namaYunithi wamaHlelo wokuTlolwa kweenHlathululi maGama.</text>
      <sha1>oosqmirw2c0t2e531kto2551ldeapx0</sha1>
    </revision>
    <revision>
      <id>1220</id>
      <parentid>1219</parentid>
      <timestamp>2024-03-10T20:32:23Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Adding interwiki links to [[d:Q967935]]</comment>
      <origin>1220</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="768" sha1="tr9zff0nfqg9jy1vakig691q7hlx5fn" xml:space="preserve">[[Isimumathi:DM-MarianneLanguageBoard (cropped).jpg|thumb]]
'''I-Pan South African Language Board (PanSALB)''' liziko le[[Isewula Afrika|Sewula Afrika]] elasungulwa bona lithuthukise ubuliminengi nawo woke amalimi asemthethweni weSewula Afrika, begodu nokobana livikele amalungelo wamalimi la woke. Ibhodi le yasungulwa ngaphasi komThetho wama-59 ngomnyaka we-1995 yi[[Palamende]] ye[[Isewula Afrika|Sewula Afrika]].

== Eminye Imisebenzi ye-PanSALB ==
Ngaphezu kwamalimi ali-12 asemthethweni weSewula Afrika i-PanSALB iqalelele godu nekuthuthukiseni amalimi afaka hlangana i-Khoe ne-San.

Ihlelo le[[-PanSALB]] lifaka hlangana: amaKomiti weemFunda wamaLimi, amaKomiti wesiTjhaba wamaLimi namaYunithi wamaHlelo wokuTlolwa kweenHlathululi maGama.

{{INTERWIKI|Q967935}}</text>
      <sha1>tr9zff0nfqg9jy1vakig691q7hlx5fn</sha1>
    </revision>
    <revision>
      <id>1221</id>
      <parentid>1220</parentid>
      <timestamp>2024-10-14T13:47:07Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>6 revisions imported</comment>
      <origin>1220</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="768" sha1="tr9zff0nfqg9jy1vakig691q7hlx5fn" xml:space="preserve">[[Isimumathi:DM-MarianneLanguageBoard (cropped).jpg|thumb]]
'''I-Pan South African Language Board (PanSALB)''' liziko le[[Isewula Afrika|Sewula Afrika]] elasungulwa bona lithuthukise ubuliminengi nawo woke amalimi asemthethweni weSewula Afrika, begodu nokobana livikele amalungelo wamalimi la woke. Ibhodi le yasungulwa ngaphasi komThetho wama-59 ngomnyaka we-1995 yi[[Palamende]] ye[[Isewula Afrika|Sewula Afrika]].

== Eminye Imisebenzi ye-PanSALB ==
Ngaphezu kwamalimi ali-12 asemthethweni weSewula Afrika i-PanSALB iqalelele godu nekuthuthukiseni amalimi afaka hlangana i-Khoe ne-San.

Ihlelo le[[-PanSALB]] lifaka hlangana: amaKomiti weemFunda wamaLimi, amaKomiti wesiTjhaba wamaLimi namaYunithi wamaHlelo wokuTlolwa kweenHlathululi maGama.

{{INTERWIKI|Q967935}}</text>
      <sha1>tr9zff0nfqg9jy1vakig691q7hlx5fn</sha1>
    </revision>
    <revision>
      <id>1675</id>
      <parentid>1221</parentid>
      <timestamp>2024-10-16T09:50:05Z</timestamp>
      <contributor>
        <username>JhsBot</username>
        <id>34</id>
      </contributor>
      <minor />
      <comment>bot: Removing interwiki template; the page is now connected to [[d:Q967935]]</comment>
      <origin>1675</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="745" sha1="oosqmirw2c0t2e531kto2551ldeapx0" xml:space="preserve">[[Isimumathi:DM-MarianneLanguageBoard (cropped).jpg|thumb]]
'''I-Pan South African Language Board (PanSALB)''' liziko le[[Isewula Afrika|Sewula Afrika]] elasungulwa bona lithuthukise ubuliminengi nawo woke amalimi asemthethweni weSewula Afrika, begodu nokobana livikele amalungelo wamalimi la woke. Ibhodi le yasungulwa ngaphasi komThetho wama-59 ngomnyaka we-1995 yi[[Palamende]] ye[[Isewula Afrika|Sewula Afrika]].

== Eminye Imisebenzi ye-PanSALB ==
Ngaphezu kwamalimi ali-12 asemthethweni weSewula Afrika i-PanSALB iqalelele godu nekuthuthukiseni amalimi afaka hlangana i-Khoe ne-San.

Ihlelo le[[-PanSALB]] lifaka hlangana: amaKomiti weemFunda wamaLimi, amaKomiti wesiTjhaba wamaLimi namaYunithi wamaHlelo wokuTlolwa kweenHlathululi maGama.</text>
      <sha1>oosqmirw2c0t2e531kto2551ldeapx0</sha1>
    </revision>
  </page>
  <page>
    <title>Patrice Lumumba</title>
    <ns>0</ns>
    <id>229</id>
    <revision>
      <id>1222</id>
      <timestamp>2024-05-22T19:49:19Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''UPatrice Lumumba''' wayengusopolitiki wase[[Congo]] kanye nomholi wenkululeko owasebenza njengondunankulu wokuqala weDemocratic Republic of the Congo (ngaleso sikhathi eyayaziwa ngokuthi yiRiphabhulikhi yaseCongo) kusukela ngoJuni kuze kube uSepthemba 1960, kulandela ukhetho lwangoMeyi 1960.&quot;</comment>
      <origin>1222</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="295" sha1="fziq45eczlp3jqzsqp82kj05bptsal0" xml:space="preserve">'''UPatrice Lumumba''' wayengusopolitiki wase[[Congo]] kanye nomholi wenkululeko owasebenza njengondunankulu wokuqala weDemocratic Republic of the Congo (ngaleso sikhathi eyayaziwa ngokuthi yiRiphabhulikhi yaseCongo) kusukela ngoJuni kuze kube uSepthemba 1960, kulandela ukhetho lwangoMeyi 1960.</text>
      <sha1>fziq45eczlp3jqzsqp82kj05bptsal0</sha1>
    </revision>
    <revision>
      <id>1223</id>
      <parentid>1222</parentid>
      <timestamp>2024-10-14T13:47:07Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>1222</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="295" sha1="fziq45eczlp3jqzsqp82kj05bptsal0" xml:space="preserve">'''UPatrice Lumumba''' wayengusopolitiki wase[[Congo]] kanye nomholi wenkululeko owasebenza njengondunankulu wokuqala weDemocratic Republic of the Congo (ngaleso sikhathi eyayaziwa ngokuthi yiRiphabhulikhi yaseCongo) kusukela ngoJuni kuze kube uSepthemba 1960, kulandela ukhetho lwangoMeyi 1960.</text>
      <sha1>fziq45eczlp3jqzsqp82kj05bptsal0</sha1>
    </revision>
  </page>
  <page>
    <title>Peter Tladi</title>
    <ns>0</ns>
    <id>230</id>
    <revision>
      <id>1224</id>
      <timestamp>2024-03-15T08:25:57Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Peter Tladi''' unguproducer womculo we Jazz wase Ningizimu Afrika.&quot;</comment>
      <origin>1224</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="69" sha1="lp2p41ro74ik8jiaouqi4hpb36azs09" xml:space="preserve">'''Peter Tladi''' unguproducer womculo we Jazz wase Ningizimu Afrika.</text>
      <sha1>lp2p41ro74ik8jiaouqi4hpb36azs09</sha1>
    </revision>
    <revision>
      <id>1225</id>
      <parentid>1224</parentid>
      <timestamp>2024-10-14T13:47:07Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>1224</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="69" sha1="lp2p41ro74ik8jiaouqi4hpb36azs09" xml:space="preserve">'''Peter Tladi''' unguproducer womculo we Jazz wase Ningizimu Afrika.</text>
      <sha1>lp2p41ro74ik8jiaouqi4hpb36azs09</sha1>
    </revision>
  </page>
  <page>
    <title>Portal:Amaholideyi</title>
    <ns>0</ns>
    <id>231</id>
    <revision>
      <id>1226</id>
      <timestamp>2024-07-08T08:58:39Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Amaholideyi''' malanga wokuphumala lapho abantu bangayi khona emsebenzini.&quot;</comment>
      <origin>1226</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="77" sha1="cddtihkizgwldp1vzyfu0fbvwngck7e" xml:space="preserve">'''Amaholideyi''' malanga wokuphumala lapho abantu bangayi khona emsebenzini.</text>
      <sha1>cddtihkizgwldp1vzyfu0fbvwngck7e</sha1>
    </revision>
    <revision>
      <id>1227</id>
      <parentid>1226</parentid>
      <timestamp>2024-07-08T20:06:53Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1227</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="359" sha1="0odn8lmp96c3bkwo1sls4iqfmuk2qxr" xml:space="preserve">'''Amaholideyi''' malanga wokuphumala lapho abantu bangayi khona emsebenzini. Inarha enye nenye iba nesikhathi samaholideyi. Amaholideyi abantu bawasebenzisela ukuba nemindeni yabo begodu nokuzithabisa. Amholideyi ahlukile ngokwenzathu zawo ngombana amanye kuba ngewabasenzi, amanye kube ngaphathelene nekolo amanye kube ngaphathele nefundo nokhunye okunengi.</text>
      <sha1>0odn8lmp96c3bkwo1sls4iqfmuk2qxr</sha1>
    </revision>
    <revision>
      <id>1228</id>
      <parentid>1227</parentid>
      <timestamp>2024-10-14T13:47:07Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>1227</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="359" sha1="0odn8lmp96c3bkwo1sls4iqfmuk2qxr" xml:space="preserve">'''Amaholideyi''' malanga wokuphumala lapho abantu bangayi khona emsebenzini. Inarha enye nenye iba nesikhathi samaholideyi. Amaholideyi abantu bawasebenzisela ukuba nemindeni yabo begodu nokuzithabisa. Amholideyi ahlukile ngokwenzathu zawo ngombana amanye kuba ngewabasenzi, amanye kube ngaphathelene nekolo amanye kube ngaphathele nefundo nokhunye okunengi.</text>
      <sha1>0odn8lmp96c3bkwo1sls4iqfmuk2qxr</sha1>
    </revision>
    <revision>
      <id>2906</id>
      <parentid>1228</parentid>
      <timestamp>2025-06-06T16:44:33Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>it funni</comment>
      <origin>2906</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="440" sha1="4lnpq94iktplrwdwlcxta62tf3k04as" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. Amaholideyi''' malanga wokuphumala lapho abantu bangayi khona emsebenzini. Inarha enye nenye iba nesikhathi samaholideyi. Amaholideyi abantu bawasebenzisela ukuba nemindeni yabo begodu nokuzithabisa. Amholideyi ahlukile ngokwenzathu zawo ngombana amanye kuba ngewabasenzi, amanye kube ngaphathelene nekolo amanye kube ngaphathele nefundo nokhunye okunengi.</text>
      <sha1>4lnpq94iktplrwdwlcxta62tf3k04as</sha1>
    </revision>
    <revision>
      <id>3133</id>
      <parentid>2906</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Jon Harald Søby|Jon Harald Søby]]</comment>
      <origin>1227</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="359" sha1="0odn8lmp96c3bkwo1sls4iqfmuk2qxr" xml:space="preserve">'''Amaholideyi''' malanga wokuphumala lapho abantu bangayi khona emsebenzini. Inarha enye nenye iba nesikhathi samaholideyi. Amaholideyi abantu bawasebenzisela ukuba nemindeni yabo begodu nokuzithabisa. Amholideyi ahlukile ngokwenzathu zawo ngombana amanye kuba ngewabasenzi, amanye kube ngaphathelene nekolo amanye kube ngaphathele nefundo nokhunye okunengi.</text>
      <sha1>0odn8lmp96c3bkwo1sls4iqfmuk2qxr</sha1>
    </revision>
    <revision>
      <id>6804</id>
      <parentid>3133</parentid>
      <timestamp>2026-08-21T03:44:01Z</timestamp>
      <contributor>
        <username>Andries Solly Skhosana</username>
        <id>1624</id>
      </contributor>
      <origin>6804</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="445" sha1="hnzk0a75rmwdy7mlyjd3mj4269d59po" xml:space="preserve">'''Amaholideyi''' malanga wokuphumula, lapho abantu bangayi khona emsebenzini. Inarha enye nenye iba nesikhathi sayo samaholideyi. Amaholideyi abantu bawasebenzisela ukuba nemindeni yabo begodu nokuzithabisa. Amaholideyi ahlukile ngokweenzathu zawo ngombana amanye kuba ngewabasenzi, amanye kube ngaphathelene nekolo, kuthi amanye kube ngaphathele nefundo nokhunye okunengi.&lt;ref&gt;&lt;nowiki&gt;https://www.gov.za/about-sa/public-holidays&lt;/nowiki&gt;&lt;/ref&gt;</text>
      <sha1>hnzk0a75rmwdy7mlyjd3mj4269d59po</sha1>
    </revision>
  </page>
  <page>
    <title>Amasonto</title>
    <ns>0</ns>
    <id>232</id>
    <revision>
      <id>1229</id>
      <timestamp>2024-07-11T10:54:58Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Amasonto'''  kuyindawa lapho abantu abasondako bahlangana khona ukukhuleka kuzimu ebamkhonzako. Kuyindawo lapho amakholwa  akhuthazana khona bekatjhumayele ngo[[Zimu]] ngovula imitolo ethileko ekhuluma ngoZimu. Emasontweni kuyavunywa, kunikelwe ngemali, begodu kuthandazwe.Amasonto  athathwa njengendawo ezicwengileko lapho umuntu angeze enzela khona izinto ezimbi. kiyindawo ezihloniphekileko.&quot;</comment>
      <origin>1229</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="397" sha1="toe1fiycvwu6u8t85o77x5wfibbvva9" xml:space="preserve">'''Amasonto'''  kuyindawa lapho abantu abasondako bahlangana khona ukukhuleka kuzimu ebamkhonzako. Kuyindawo lapho amakholwa  akhuthazana khona bekatjhumayele ngo[[Zimu]] ngovula imitolo ethileko ekhuluma ngoZimu. Emasontweni kuyavunywa, kunikelwe ngemali, begodu kuthandazwe.Amasonto  athathwa njengendawo ezicwengileko lapho umuntu angeze enzela khona izinto ezimbi. kiyindawo ezihloniphekileko.</text>
      <sha1>toe1fiycvwu6u8t85o77x5wfibbvva9</sha1>
    </revision>
    <revision>
      <id>1230</id>
      <parentid>1229</parentid>
      <timestamp>2024-10-14T13:47:07Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>1229</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="397" sha1="toe1fiycvwu6u8t85o77x5wfibbvva9" xml:space="preserve">'''Amasonto'''  kuyindawa lapho abantu abasondako bahlangana khona ukukhuleka kuzimu ebamkhonzako. Kuyindawo lapho amakholwa  akhuthazana khona bekatjhumayele ngo[[Zimu]] ngovula imitolo ethileko ekhuluma ngoZimu. Emasontweni kuyavunywa, kunikelwe ngemali, begodu kuthandazwe.Amasonto  athathwa njengendawo ezicwengileko lapho umuntu angeze enzela khona izinto ezimbi. kiyindawo ezihloniphekileko.</text>
      <sha1>toe1fiycvwu6u8t85o77x5wfibbvva9</sha1>
    </revision>
    <revision>
      <id>3316</id>
      <parentid>1230</parentid>
      <timestamp>2025-07-05T08:51:05Z</timestamp>
      <contributor>
        <username>Andre Engels</username>
        <id>480</id>
      </contributor>
      <minor />
      <comment>Andre Engels moved page [[Portal:Amasonto]] to [[Amasonto]]</comment>
      <origin>1229</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="397" sha1="toe1fiycvwu6u8t85o77x5wfibbvva9" xml:space="preserve">'''Amasonto'''  kuyindawa lapho abantu abasondako bahlangana khona ukukhuleka kuzimu ebamkhonzako. Kuyindawo lapho amakholwa  akhuthazana khona bekatjhumayele ngo[[Zimu]] ngovula imitolo ethileko ekhuluma ngoZimu. Emasontweni kuyavunywa, kunikelwe ngemali, begodu kuthandazwe.Amasonto  athathwa njengendawo ezicwengileko lapho umuntu angeze enzela khona izinto ezimbi. kiyindawo ezihloniphekileko.</text>
      <sha1>toe1fiycvwu6u8t85o77x5wfibbvva9</sha1>
    </revision>
    <revision>
      <id>3413</id>
      <parentid>3316</parentid>
      <timestamp>2025-07-12T13:41:20Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3413</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="399" sha1="jq3rc6u7bqlm9x7m0xred0jp04d5amp" xml:space="preserve">'''Amasonto'''  kuyindawa lapho abantu abasondako bahlangana khona ukukhuleka kuzimu ebamkhonzako. Kuyindawo lapho amakholwa  akhuthazana khona bekatjhumayele ngo[[Zimu]] ngovula imitlolo ethileko ekhuluma ngoZimu. Emasontweni kuyavunywa, kunikelwe ngemali, begodu kuthandazwe. Amasonto  athathwa njengendawo ezicwengileko lapho umuntu angeze enzela khona izinto ezimbi. kiyindawo ezihloniphekileko.</text>
      <sha1>jq3rc6u7bqlm9x7m0xred0jp04d5amp</sha1>
    </revision>
    <revision>
      <id>3442</id>
      <parentid>3413</parentid>
      <timestamp>2025-07-15T12:08:34Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3442</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2995" sha1="t3vnphcqocmt0k6ud3qxhngyuuj734k" xml:space="preserve">'''Amasonto'''  kuyindawa lapho abantu abasondako bahlangana khona ukukhuleka kuzimu ebamkhonzako. Kuyindawo lapho amakholwa  akhuthazana khona bekatjhumayele ngo[[Zimu]] ngokuvula imitlolo ethileko ekhuluma ngoZimu. Emasontweni kuyavunywa, kunikelwe ngemali, begodu kuthandazwe. Amasonto  athathwa njengendawo ezicwengileko lapho umuntu angeze enzela khona izinto ezimbi. kiyindawo ezihloniphekileko.Abantu labo kufuze bae nekolo efana Kuyindawo lapho abantu bahlangana khona balotjhe uZimu, bafunde ngaye begodu bakhe ubudlelwane nabanye abantu. Amasonto adosela bantu ekukhuliseni ipilo yabo yomoya nokuthi basekela amalunga walo lokha nakatlhoga isekelo. ESewula Afrika kunemihlobo eminengi yamasonto.

=== Imihlobo yamamsonto ===

==== Amasonto lamakhatholiki ====
[[Isimumathi:Portrait of Pope Francis (2021) FXD.jpg|thumb|u Pope Francis wesonto lalakhatholiki]]
Ngelinye lamasonto amakhulu eSewula Afrika ngombana liyingcenye yamakhatholiki ephasini loke. Kulisonto edoswa phambili mfundisi obizwa bona ngo-''Pope'' okunguye odoswa phambili woke umuntu osonta kileli sonto.&lt;ref&gt;[https://www.msn.com/en-za/news/other/how-the-catholic-church-chooses-a-new-pope/ar-AA1DURnB?ocid=BingNewsVerp How the Catholic Church chooses a new Pope]&lt;/ref&gt; Abantu besonto leli bakholelwa ebuthsthwini buka Zimu (UZimi, uJesu krestem noMoya Ocwengileko). Bathandaza KuZimu, kuMntazana ongakathintwa besana u-Mary. Esontweni lamakhatholiki  ngaphasi ko-Pope kunabo bhitjhobhi, abaphristi Kanye nabadikhoni.

==== amasonto Wabavangeli ====
Amasonto akhuthaza igunya le bhayibhili nokuqakatheka kokuphenduka komuntu ngamunye, nokukhamba utjhumayela ivangeli ngoZimu, bakhamba empkhakathini bafundisa abantu ngethando lakaZimu. Emasndwei la bakholwa bonyana ukusindiswa komuntu kukuJesu khreste kuphela. Lokha nabahlangeneko bavuma iingoma begodu babethe  nezinto zokunandisa umvumo wabo ezifana namagatara.  

==== amasonto we-Afrika Azijameleko ====
Mhlobo wamasonto ase-Afrika ngombana azithomele ngokwayo akhange athathe indlela yesiNgisi kolotjha uZimu. Wona ahlanganisa amasiko wama- Afrika nezinto nofana neendlela zobukhrestu.&lt;ref&gt;Majola, Y.L., 2022. The Naming of Independent Churches in the 21st Century: A Critical Discourse Analysis of Charismatic Churches in South Africa. ''Studia Historiae Ecclesiasticae'', ''48''(1), pp.1-13.&lt;/ref&gt; Amosonto la wavela njengokuthi kube nesifiso sokobana kube nekolo yokukhresdte edoswa phambili ma-Afrika. Amosonto akhethuza ukwenziswa kwamasiko wabantu abanzima, nokukholwa  kuJesu khreste uhlala e-Afrika.

==== amasonto we- charismatic ====
Masonto akhuthaza ukusebenza kweemphiwo eziza noMoya ocwengileko.  Banendlela yabo yokuthandaza kuZImu ngokuthi bathandaze ngeenlimi. Bakholwa ukuthi umuntu kufanele abhabhadiswa ngokoMoya ocwengileko nokuthi lokho kuyinto ehlukileko nokusindwa. Okhubye kukuthi bakholwa bonyana umthandazo uyaphilisa emzimbeni, Kanye nemmoyeni. Bathi ukuphorofida kuyisiphiwo esivela kuZimu esenzelwa ukukhomba amakholwa indlela.</text>
      <sha1>t3vnphcqocmt0k6ud3qxhngyuuj734k</sha1>
    </revision>
    <revision>
      <id>3443</id>
      <parentid>3442</parentid>
      <timestamp>2025-07-15T12:09:23Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3443</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3209" sha1="fagbxdjep3zesav9tqj9t1s74xqwvk9" xml:space="preserve">'''Amasonto'''  kuyindawa lapho abantu abasondako bahlangana khona ukukhuleka kuzimu ebamkhonzako. Kuyindawo lapho amakholwa  akhuthazana khona bekatjhumayele ngo[[Zimu]] ngokuvula imitlolo ethileko ekhuluma ngoZimu. Emasontweni kuyavunywa, kunikelwe ngemali, begodu kuthandazwe. Amasonto  athathwa njengendawo ezicwengileko lapho umuntu angeze enzela khona izinto ezimbi. kiyindawo ezihloniphekileko.Abantu labo kufuze bae nekolo efana Kuyindawo lapho abantu bahlangana khona balotjhe uZimu, bafunde ngaye begodu bakhe ubudlelwane nabanye abantu. Amasonto adosela bantu ekukhuliseni ipilo yabo yomoya nokuthi basekela amalunga walo lokha nakatlhoga isekelo. ESewula Afrika kunemihlobo eminengi yamasonto.

=== Imihlobo yamamsonto ===

==== Amasonto lamakhatholiki ====
[[Isimumathi:Portrait of Pope Francis (2021) FXD.jpg|thumb|u Pope Francis wesonto lalakhatholiki]]
Ngelinye lamasonto amakhulu eSewula Afrika ngombana liyingcenye yamakhatholiki ephasini loke. Kulisonto edoswa phambili mfundisi obizwa bona ngo-''Pope'' okunguye odoswa phambili woke umuntu osonta kileli sonto.&lt;ref&gt;[https://www.msn.com/en-za/news/other/how-the-catholic-church-chooses-a-new-pope/ar-AA1DURnB?ocid=BingNewsVerp How the Catholic Church chooses a new Pope]&lt;/ref&gt; Abantu besonto leli bakholelwa ebuthsthwini buka Zimu (UZimi, uJesu krestem noMoya Ocwengileko). Bathandaza KuZimu, kuMntazana ongakathintwa besana u-Mary. Esontweni lamakhatholiki  ngaphasi ko-Pope kunabo bhitjhobhi, abaphristi Kanye nabadikhoni.

==== amasonto Wabavangeli ====
Amasonto akhuthaza igunya le bhayibhili nokuqakatheka kokuphenduka komuntu ngamunye, nokukhamba utjhumayela ivangeli ngoZimu, bakhamba empkhakathini bafundisa abantu ngethando lakaZimu. Emasndwei la bakholwa bonyana ukusindiswa komuntu kukuJesu khreste kuphela. Lokha nabahlangeneko bavuma iingoma begodu babethe  nezinto zokunandisa umvumo wabo ezifana namagatara.  

==== amasonto we-Afrika Azijameleko ====
Mhlobo wamasonto ase-Afrika ngombana azithomele ngokwayo akhange athathe indlela yesiNgisi kolotjha uZimu. Wona ahlanganisa amasiko wama- Afrika nezinto nofana neendlela zobukhrestu.&lt;ref&gt;Majola, Y.L., 2022. The Naming of Independent Churches in the 21st Century: A Critical Discourse Analysis of Charismatic Churches in South Africa. ''Studia Historiae Ecclesiasticae'', ''48''(1), pp.1-13.&lt;/ref&gt; Amosonto la wavela njengokuthi kube nesifiso sokobana kube nekolo yokukhresdte edoswa phambili ma-Afrika. Amosonto akhethuza ukwenziswa kwamasiko wabantu abanzima, nokukholwa  kuJesu khreste uhlala e-Afrika.

==== amasonto we- charismatic ====
Masonto akhuthaza ukusebenza kweemphiwo eziza noMoya ocwengileko.  Banendlela yabo yokuthandaza kuZImu ngokuthi bathandaze ngeenlimi. Bakholwa ukuthi umuntu kufanele abhabhadiswa ngokoMoya ocwengileko nokuthi lokho kuyinto ehlukileko nokusindwa.&lt;ref&gt;Majola, Y.L., 2022. The Naming of Independent Churches in the 21st Century: A Critical Discourse Analysis of Charismatic Churches in South Africa. ''Studia Historiae Ecclesiasticae'', ''48''(1), pp.1-13.&lt;/ref&gt; Okhunye kukuthi bakholwa bonyana umthandazo uyaphilisa emzimbeni, Kanye nemmoyeni. Bathi ukuphorofida kuyisiphiwo esivela kuZimu esenzelwa ukukhomba amakholwa indlela.</text>
      <sha1>fagbxdjep3zesav9tqj9t1s74xqwvk9</sha1>
    </revision>
    <revision>
      <id>3444</id>
      <parentid>3443</parentid>
      <timestamp>2025-07-15T14:45:15Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3444</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3385" sha1="3aqdo63pifpbzu211zfi66z50ei3tbn" xml:space="preserve">'''Amasonto'''  kuyindawa lapho abantu abasondako bahlangana khona ukukhuleka kuzimu ebamkhonzako. Kuyindawo lapho amakholwa  akhuthazana khona bekatjhumayele ngo[[Zimu]] ngokuvula imitlolo ethileko ekhuluma ngoZimu. Emasontweni kuyavunywa, kunikelwe ngemali, begodu kuthandazwe. Amasonto  athathwa njengendawo ezicwengileko lapho umuntu angeze enzela khona izinto ezimbi. kiyindawo ezihloniphekileko.Abantu labo kufuze bae nekolo efana Kuyindawo lapho abantu bahlangana khona balotjhe uZimu, bafunde ngaye begodu bakhe ubudlelwane nabanye abantu. Amasonto adosela bantu ekukhuliseni ipilo yabo yomoya nokuthi basekela amalunga walo lokha nakatlhoga isekelo. ESewula Afrika kunemihlobo eminengi yamasonto.

=== Imihlobo yamamsonto ===

==== Amasonto lamakhatholiki ====
[[Isimumathi:Portrait of Pope Francis (2021) FXD.jpg|thumb|u Pope Francis wesonto lalakhatholiki]]
Ngelinye lamasonto amakhulu eSewula Afrika ngombana liyingcenye yamakhatholiki ephasini loke. Kulisonto edoswa phambili mfundisi obizwa bona ngo-''Pope'' okunguye odoswa phambili woke umuntu osonta kileli sonto.&lt;ref&gt;[https://www.msn.com/en-za/news/other/how-the-catholic-church-chooses-a-new-pope/ar-AA1DURnB?ocid=BingNewsVerp How the Catholic Church chooses a new Pope]&lt;/ref&gt; Abantu besonto leli bakholelwa ebuthsthwini buka Zimu (UZimi, uJesu krestem noMoya Ocwengileko). Bathandaza KuZimu, kuMntazana ongakathintwa besana u-Mary. Esontweni lamakhatholiki  ngaphasi ko-Pope kunabo bhitjhobhi, abaphristi Kanye nabadikhoni.

==== amasonto Wabavangeli ====
Amasonto akhuthaza igunya le bhayibhili nokuqakatheka kokuphenduka komuntu ngamunye, nokukhamba utjhumayela ivangeli ngoZimu, bakhamba empkhakathini bafundisa abantu ngethando lakaZimu. Emasndwei la bakholwa bonyana ukusindiswa komuntu kukuJesu khreste kuphela. Lokha nabahlangeneko bavuma iingoma begodu babethe  nezinto zokunandisa umvumo wabo ezifana namagatara.  

==== amasonto we-Afrika Azijameleko ====
[[Isimumathi:Children participate in worship at African Independent church at Misty Mount (8004040626).jpg|thumb|Abantwana abasonda kwelinye lama sonto we-Afrika azijameleko]]
Mhlobo wamasonto ase-Afrika ngombana azithomele ngokwayo akhange athathe indlela yesiNgisi kolotjha uZimu. Wona ahlanganisa amasiko wama- Afrika nezinto nofana neendlela zobukhrestu.&lt;ref&gt;Majola, Y.L., 2022. The Naming of Independent Churches in the 21st Century: A Critical Discourse Analysis of Charismatic Churches in South Africa. ''Studia Historiae Ecclesiasticae'', ''48''(1), pp.1-13.&lt;/ref&gt; Amosonto la wavela njengokuthi kube nesifiso sokobana kube nekolo yokukhresdte edoswa phambili ma-Afrika. Amosonto akhethuza ukwenziswa kwamasiko wabantu abanzima, nokukholwa  kuJesu khreste uhlala e-Afrika.

==== amasonto we- charismatic ====
Masonto akhuthaza ukusebenza kweemphiwo eziza noMoya ocwengileko.  Banendlela yabo yokuthandaza kuZImu ngokuthi bathandaze ngeenlimi. Bakholwa ukuthi umuntu kufanele abhabhadiswa ngokoMoya ocwengileko nokuthi lokho kuyinto ehlukileko nokusindwa.&lt;ref&gt;Majola, Y.L., 2022. The Naming of Independent Churches in the 21st Century: A Critical Discourse Analysis of Charismatic Churches in South Africa. ''Studia Historiae Ecclesiasticae'', ''48''(1), pp.1-13.&lt;/ref&gt; Okhunye kukuthi bakholwa bonyana umthandazo uyaphilisa emzimbeni, Kanye nemmoyeni. Bathi ukuphorofida kuyisiphiwo esivela kuZimu esenzelwa ukukhomba amakholwa indlela.</text>
      <sha1>3aqdo63pifpbzu211zfi66z50ei3tbn</sha1>
    </revision>
    <revision>
      <id>3445</id>
      <parentid>3444</parentid>
      <timestamp>2025-07-15T14:47:05Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3445</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3405" sha1="6nii7gel5nz8tt42znw98jx5hl43bd9" xml:space="preserve">'''Amasonto'''  kuyindawa lapho abantu abasondako bahlangana khona ukukhuleka kuzimu ebamkhonzako. Kuyindawo lapho amakholwa  akhuthazana khona bekatjhumayele ngo[[Zimu]] ngokuvula imitlolo ethileko ekhuluma ngoZimu. Emasontweni kuyavunywa, kunikelwe ngemali, begodu kuthandazwe. Amasonto  athathwa njengendawo ezicwengileko lapho umuntu angeze enzela khona izinto ezimbi. kiyindawo ezihloniphekileko.Abantu labo kufuze bae nekolo efana Kuyindawo lapho abantu bahlangana khona balotjhe uZimu, bafunde ngaye begodu bakhe ubudlelwane nabanye abantu. Amasonto adosela bantu ekukhuliseni ipilo yabo yomoya nokuthi basekela amalunga walo lokha nakatlhoga isekelo. ESewula Afrika kunemihlobo eminengi yamasonto.

=== Imihlobo yamamsonto ===

==== Amasonto lamakhatholiki ====
[[Isimumathi:Portrait of Pope Francis (2021) FXD.jpg|thumb|u Pope Francis wesonto lalakhatholiki ongasekho ephasini.]]
Ngelinye lamasonto amakhulu eSewula Afrika ngombana liyingcenye yamakhatholiki ephasini loke. Kulisonto edoswa phambili mfundisi obizwa bona ngo-''Pope'' okunguye odoswa phambili woke umuntu osonta kileli sonto.&lt;ref&gt;[https://www.msn.com/en-za/news/other/how-the-catholic-church-chooses-a-new-pope/ar-AA1DURnB?ocid=BingNewsVerp How the Catholic Church chooses a new Pope]&lt;/ref&gt; Abantu besonto leli bakholelwa ebuthsthwini buka Zimu (UZimi, uJesu krestem noMoya Ocwengileko). Bathandaza KuZimu, kuMntazana ongakathintwa besana u-Mary. Esontweni lamakhatholiki  ngaphasi ko-Pope kunabo bhitjhobhi, abaphristi Kanye nabadikhoni.

==== amasonto Wabavangeli ====
Amasonto akhuthaza igunya le bhayibhili nokuqakatheka kokuphenduka komuntu ngamunye, nokukhamba utjhumayela ivangeli ngoZimu, bakhamba empkhakathini bafundisa abantu ngethando lakaZimu. Emasndwei la bakholwa bonyana ukusindiswa komuntu kukuJesu khreste kuphela. Lokha nabahlangeneko bavuma iingoma begodu babethe  nezinto zokunandisa umvumo wabo ezifana namagatara.  

==== amasonto we-Afrika Azijameleko ====
[[Isimumathi:Children participate in worship at African Independent church at Misty Mount (8004040626).jpg|thumb|Abantwana abasonda kwelinye lama sonto we-Afrika azijameleko]]
Mhlobo wamasonto ase-Afrika ngombana azithomele ngokwayo akhange athathe indlela yesiNgisi kolotjha uZimu. Wona ahlanganisa amasiko wama- Afrika nezinto nofana neendlela zobukhrestu.&lt;ref&gt;Majola, Y.L., 2022. The Naming of Independent Churches in the 21st Century: A Critical Discourse Analysis of Charismatic Churches in South Africa. ''Studia Historiae Ecclesiasticae'', ''48''(1), pp.1-13.&lt;/ref&gt; Amosonto la wavela njengokuthi kube nesifiso sokobana kube nekolo yokukhresdte edoswa phambili ma-Afrika. Amosonto akhethuza ukwenziswa kwamasiko wabantu abanzima, nokukholwa  kuJesu khreste uhlala e-Afrika.

==== amasonto we- charismatic ====
Masonto akhuthaza ukusebenza kweemphiwo eziza noMoya ocwengileko.  Banendlela yabo yokuthandaza kuZImu ngokuthi bathandaze ngeenlimi. Bakholwa ukuthi umuntu kufanele abhabhadiswa ngokoMoya ocwengileko nokuthi lokho kuyinto ehlukileko nokusindwa.&lt;ref&gt;Majola, Y.L., 2022. The Naming of Independent Churches in the 21st Century: A Critical Discourse Analysis of Charismatic Churches in South Africa. ''Studia Historiae Ecclesiasticae'', ''48''(1), pp.1-13.&lt;/ref&gt; Okhunye kukuthi bakholwa bonyana umthandazo uyaphilisa emzimbeni, Kanye nemmoyeni. Bathi ukuphorofida kuyisiphiwo esivela kuZimu esenzelwa ukukhomba amakholwa indlela.</text>
      <sha1>6nii7gel5nz8tt42znw98jx5hl43bd9</sha1>
    </revision>
    <revision>
      <id>3446</id>
      <parentid>3445</parentid>
      <timestamp>2025-07-15T14:47:38Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3446</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3404" sha1="m8yova12ohh5n44u8rvtqsktuk7bcie" xml:space="preserve">'''Amasonto'''  kuyindawa lapho abantu abasondako bahlangana khona ukukhuleka kuzimu ebamkhonzako. Kuyindawo lapho amakholwa  akhuthazana khona bekatjhumayele ngo[[Zimu]] ngokuvula imitlolo ethileko ekhuluma ngoZimu. Emasontweni kuyavunywa, kunikelwe ngemali, begodu kuthandazwe. Amasonto  athathwa njengendawo ezicwengileko lapho umuntu angeze enzela khona izinto ezimbi. kiyindawo ezihloniphekileko.Abantu labo kufuze bae nekolo efana Kuyindawo lapho abantu bahlangana khona balotjhe uZimu, bafunde ngaye begodu bakhe ubudlelwane nabanye abantu. Amasonto adosela bantu ekukhuliseni ipilo yabo yomoya nokuthi basekela amalunga walo lokha nakatlhoga isekelo. ESewula Afrika kunemihlobo eminengi yamasonto.

=== Imihlobo yamamsonto ===

==== Amasonto lamakhatholiki ====
[[Isimumathi:Portrait of Pope Francis (2021) FXD.jpg|thumb|u Pope Francis wesonto lalakhatholiki ongasekho ephasini.]]
Ngelinye lamasonto amakhulu eSewula Afrika ngombana liyingcenye yamakhatholiki ephasini loke. Kulisonto edoswa phambili mfundisi obizwa bona ngo-''Pope'' okunguye odoswa phambili woke umuntu osonta kileli sonto.&lt;ref&gt;[https://www.msn.com/en-za/news/other/how-the-catholic-church-chooses-a-new-pope/ar-AA1DURnB?ocid=BingNewsVerp How the Catholic Church chooses a new Pope]&lt;/ref&gt; Abantu besonto leli bakholelwa ebuthsthwini buka Zimu (UZimi, uJesu kreste noMoya Ocwengileko). Bathandaza KuZimu, kuMntazana ongakathintwa besana u-Mary. Esontweni lamakhatholiki  ngaphasi ko-Pope kunabo bhitjhobhi, abaphristi Kanye nabadikhoni.

==== amasonto Wabavangeli ====
Amasonto akhuthaza igunya le bhayibhili nokuqakatheka kokuphenduka komuntu ngamunye, nokukhamba utjhumayela ivangeli ngoZimu, bakhamba empkhakathini bafundisa abantu ngethando lakaZimu. Emasndwei la bakholwa bonyana ukusindiswa komuntu kukuJesu khreste kuphela. Lokha nabahlangeneko bavuma iingoma begodu babethe  nezinto zokunandisa umvumo wabo ezifana namagatara.  

==== amasonto we-Afrika Azijameleko ====
[[Isimumathi:Children participate in worship at African Independent church at Misty Mount (8004040626).jpg|thumb|Abantwana abasonda kwelinye lama sonto we-Afrika azijameleko]]
Mhlobo wamasonto ase-Afrika ngombana azithomele ngokwayo akhange athathe indlela yesiNgisi kolotjha uZimu. Wona ahlanganisa amasiko wama- Afrika nezinto nofana neendlela zobukhrestu.&lt;ref&gt;Majola, Y.L., 2022. The Naming of Independent Churches in the 21st Century: A Critical Discourse Analysis of Charismatic Churches in South Africa. ''Studia Historiae Ecclesiasticae'', ''48''(1), pp.1-13.&lt;/ref&gt; Amosonto la wavela njengokuthi kube nesifiso sokobana kube nekolo yokukhresdte edoswa phambili ma-Afrika. Amosonto akhethuza ukwenziswa kwamasiko wabantu abanzima, nokukholwa  kuJesu khreste uhlala e-Afrika.

==== amasonto we- charismatic ====
Masonto akhuthaza ukusebenza kweemphiwo eziza noMoya ocwengileko.  Banendlela yabo yokuthandaza kuZImu ngokuthi bathandaze ngeenlimi. Bakholwa ukuthi umuntu kufanele abhabhadiswa ngokoMoya ocwengileko nokuthi lokho kuyinto ehlukileko nokusindwa.&lt;ref&gt;Majola, Y.L., 2022. The Naming of Independent Churches in the 21st Century: A Critical Discourse Analysis of Charismatic Churches in South Africa. ''Studia Historiae Ecclesiasticae'', ''48''(1), pp.1-13.&lt;/ref&gt; Okhunye kukuthi bakholwa bonyana umthandazo uyaphilisa emzimbeni, Kanye nemmoyeni. Bathi ukuphorofida kuyisiphiwo esivela kuZimu esenzelwa ukukhomba amakholwa indlela.</text>
      <sha1>m8yova12ohh5n44u8rvtqsktuk7bcie</sha1>
    </revision>
    <revision>
      <id>3447</id>
      <parentid>3446</parentid>
      <timestamp>2025-07-15T14:54:43Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3447</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3572" sha1="8kd20d4xdgjq4917tglb5wc1qlaposs" xml:space="preserve">'''Amasonto'''  kuyindawa lapho abantu abasondako bahlangana khona ukukhuleka kuzimu ebamkhonzako. Kuyindawo lapho amakholwa  akhuthazana khona bekatjhumayele ngo[[Zimu]] ngokuvula imitlolo ethileko ekhuluma ngoZimu. Emasontweni kuyavunywa, kunikelwe ngemali, begodu kuthandazwe. Amasonto  athathwa njengendawo ezicwengileko lapho umuntu angeze enzela khona izinto ezimbi. kiyindawo ezihloniphekileko.Abantu labo kufuze bae nekolo efana Kuyindawo lapho abantu bahlangana khona balotjhe uZimu, bafunde ngaye begodu bakhe ubudlelwane nabanye abantu. Amasonto adosela bantu ekukhuliseni ipilo yabo yomoya nokuthi basekela amalunga walo lokha nakatlhoga isekelo. ESewula Afrika kunemihlobo eminengi yamasonto.

=== Imihlobo yamamsonto ===

==== Amasonto lamakhatholiki ====
[[Isimumathi:Portrait of Pope Francis (2021) FXD.jpg|thumb|u Pope Francis wesonto lalakhatholiki ongasekho ephasini.]]
Ngelinye lamasonto amakhulu eSewula Afrika ngombana liyingcenye yamakhatholiki ephasini loke. Kulisonto elidoswa phambili mfundisi obizwa bona ngo-''Pope'' okunguye odoswa phambili woke umuntu osonta kileli sonto.&lt;ref&gt;[https://www.msn.com/en-za/news/other/how-the-catholic-church-chooses-a-new-pope/ar-AA1DURnB?ocid=BingNewsVerp How the Catholic Church chooses a new Pope]&lt;/ref&gt; Abantu besonto leli bakholelwa ebuthathwini buka Zimu (UZimi, uJesu kreste noMoya Ocwengileko). Bathandaza KuZimu, kuMntazana ongakathintwa besana u-Mary. Esondweni lamakhatholiki  ngaphasi ko-Pope kunabo bhitjhobhi, abaphristi Kanye nabadikhoni.

==== amasonto Wabavangeli ====
Amasonto akhuthaza igunya le bhayibhili nokuqakatheka kokuphenduka komuntu ngamunye, nokukhamba utjhumayela ivangeli ngoZimu, bakhamba emphakathini bafundisa abantu ngethando lakaZimu.&lt;ref&gt;Noll, M.A., Bebbington, D.W. and Marsden, G.M., 2019. ''Evangelicals: Who they have been, are now, and could be''. Wm. B. Eerdmans Publishing.&lt;/ref&gt; Emasondweni la bakholwa bonyana ukusindiswa komuntu kukuJesu khreste kuphela. Lokha nabahlangeneko bazokusonta bavuma iingoma begodu babethe  nezinto zokunandisa umvumo wabo ezifana namagatara.  

==== amasonto we-Afrika Azijameleko ====
[[Isimumathi:Children participate in worship at African Independent church at Misty Mount (8004040626).jpg|thumb|Abantwana abasonda kwelinye lama sonto we-Afrika azijameleko]]
Mhlobo wamasonto ase-Afrika ngombana azithomele ngokwayo akhange athathe indlela yesiNgisi kolotjha uZimu. Wona ahlanganisa amasiko wama- Afrika nezinto nofana neendlela zobukhrestu.&lt;ref&gt;Majola, Y.L., 2022. The Naming of Independent Churches in the 21st Century: A Critical Discourse Analysis of Charismatic Churches in South Africa. ''Studia Historiae Ecclesiasticae'', ''48''(1), pp.1-13.&lt;/ref&gt; Amosonto la wavela njengokuthi kube nesifiso sokobana kube nekolo yokukhresdte edoswa phambili ma-Afrika. Amosonto akhethuza ukwenziswa kwamasiko wabantu abanzima, nokukholwa  kuJesu khreste uhlala e-Afrika.

==== amasonto we- charismatic ====
Masonto akhuthaza ukusebenza kweemphiwo eziza noMoya ocwengileko.  Banendlela yabo yokuthandaza kuZImu ngokuthi bathandaze ngeenlimi. Bakholwa ukuthi umuntu kufanele abhabhadiswa ngokoMoya ocwengileko nokuthi lokho kuyinto ehlukileko nokusindwa.&lt;ref&gt;Majola, Y.L., 2022. The Naming of Independent Churches in the 21st Century: A Critical Discourse Analysis of Charismatic Churches in South Africa. ''Studia Historiae Ecclesiasticae'', ''48''(1), pp.1-13.&lt;/ref&gt; Okhunye kukuthi bakholwa bonyana umthandazo uyaphilisa emzimbeni, Kanye nemmoyeni. Bathi ukuphorofida kuyisiphiwo esivela kuZimu esenzelwa ukukhomba amakholwa indlela.</text>
      <sha1>8kd20d4xdgjq4917tglb5wc1qlaposs</sha1>
    </revision>
  </page>
  <page>
    <title>Portal:Imvelo</title>
    <ns>0</ns>
    <id>233</id>
    <revision>
      <id>1231</id>
      <timestamp>2024-05-20T11:52:10Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;  &quot;</comment>
      <origin>1231</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2" sha1="d9djsoiy1tv4u1g6270onnoihttadwu" xml:space="preserve">

</text>
      <sha1>d9djsoiy1tv4u1g6270onnoihttadwu</sha1>
    </revision>
    <revision>
      <id>1232</id>
      <parentid>1231</parentid>
      <timestamp>2024-05-20T11:53:47Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1232</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="236" sha1="gv63d6zw3yz0t0ije6losp5fvaad3pd" xml:space="preserve">

'''Imvelo''' izinto ezingadalwa umuntu, zimane zivele ngoba ziyadingeka emhlabeni. Kubalulekile ukuba sihloniphe imvelo. Imvelo kungaba izinto ezifana nezihlahla kanye nezilwane. Izithelo kanye nemifino zibalulekile empilweni yomuntu.</text>
      <sha1>gv63d6zw3yz0t0ije6losp5fvaad3pd</sha1>
    </revision>
    <revision>
      <id>1233</id>
      <parentid>1232</parentid>
      <timestamp>2024-06-26T16:33:16Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1233</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="793" sha1="fza8tne4dybts10j8n8r5d1cc2dn7j7" xml:space="preserve">

'''Imvelo''' zizinto ezingakadalwa mumuntu, zimane zivele ngokwazo ngombana ziyadingeka emhlabeni. Kuqakathekile bonyana sihloniphe imvelo. Imvelo kungaba zizinto ezifana neenhlahla kanye nezilwane. Iinthelo kanye nemirorho ziqakathekile epilweni yomuntu.

Imvelo ngiyo eyenza bona iphasi libe lihle begodu nabantu bakhone ukuhlala kuhle ephasini. Ngaphandle kwemvelo abantu bengekhe bakhona ukuphila nokuhlala kuhle ephasini. Ezinye izinto zemvelo zibonakala zingaka qakatheki kodwana zenza umsebenzi omuhle ekuphileni kwabantu. 

Imvelo ikghona ukungenisa imali enarheni, ngombana yenza bona abantu babe nendawo ezingavakatjhelwa babantu bangaphandle ngitjho ama-tourist. Abantu bangaphandle bakhona ukuzobukela imvelo ngokuya kwekareko yabo. Kungaba ziintaba, iinlwana, nokhunye kwemvelo.</text>
      <sha1>fza8tne4dybts10j8n8r5d1cc2dn7j7</sha1>
    </revision>
    <revision>
      <id>1234</id>
      <parentid>1233</parentid>
      <timestamp>2024-10-14T13:47:08Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>1233</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="793" sha1="fza8tne4dybts10j8n8r5d1cc2dn7j7" xml:space="preserve">

'''Imvelo''' zizinto ezingakadalwa mumuntu, zimane zivele ngokwazo ngombana ziyadingeka emhlabeni. Kuqakathekile bonyana sihloniphe imvelo. Imvelo kungaba zizinto ezifana neenhlahla kanye nezilwane. Iinthelo kanye nemirorho ziqakathekile epilweni yomuntu.

Imvelo ngiyo eyenza bona iphasi libe lihle begodu nabantu bakhone ukuhlala kuhle ephasini. Ngaphandle kwemvelo abantu bengekhe bakhona ukuphila nokuhlala kuhle ephasini. Ezinye izinto zemvelo zibonakala zingaka qakatheki kodwana zenza umsebenzi omuhle ekuphileni kwabantu. 

Imvelo ikghona ukungenisa imali enarheni, ngombana yenza bona abantu babe nendawo ezingavakatjhelwa babantu bangaphandle ngitjho ama-tourist. Abantu bangaphandle bakhona ukuzobukela imvelo ngokuya kwekareko yabo. Kungaba ziintaba, iinlwana, nokhunye kwemvelo.</text>
      <sha1>fza8tne4dybts10j8n8r5d1cc2dn7j7</sha1>
    </revision>
    <revision>
      <id>2914</id>
      <parentid>1234</parentid>
      <timestamp>2025-06-06T16:53:44Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>brr brr Patapim</comment>
      <origin>2914</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="874" sha1="541ggpzid221euioglrtb0o704m9j57" xml:space="preserve">

'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. Imvelo''' zizinto ezingakadalwa mumuntu, zimane zivele ngokwazo ngombana ziyadingeka emhlabeni. Kuqakathekile bonyana sihloniphe imvelo. Imvelo kungaba zizinto ezifana neenhlahla kanye nezilwane. Iinthelo kanye nemirorho ziqakathekile epilweni yomuntu.

Imvelo ngiyo eyenza bona iphasi libe lihle begodu nabantu bakhone ukuhlala kuhle ephasini. Ngaphandle kwemvelo abantu bengekhe bakhona ukuphila nokuhlala kuhle ephasini. Ezinye izinto zemvelo zibonakala zingaka qakatheki kodwana zenza umsebenzi omuhle ekuphileni kwabantu. 

Imvelo ikghona ukungenisa imali enarheni, ngombana yenza bona abantu babe nendawo ezingavakatjhelwa babantu bangaphandle ngitjho ama-tourist. Abantu bangaphandle bakhona ukuzobukela imvelo ngokuya kwekareko yabo. Kungaba ziintaba, iinlwana, nokhunye kwemvelo.</text>
      <sha1>541ggpzid221euioglrtb0o704m9j57</sha1>
    </revision>
    <revision>
      <id>3110</id>
      <parentid>2914</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Jon Harald Søby|Jon Harald Søby]]</comment>
      <origin>1233</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="793" sha1="fza8tne4dybts10j8n8r5d1cc2dn7j7" xml:space="preserve">

'''Imvelo''' zizinto ezingakadalwa mumuntu, zimane zivele ngokwazo ngombana ziyadingeka emhlabeni. Kuqakathekile bonyana sihloniphe imvelo. Imvelo kungaba zizinto ezifana neenhlahla kanye nezilwane. Iinthelo kanye nemirorho ziqakathekile epilweni yomuntu.

Imvelo ngiyo eyenza bona iphasi libe lihle begodu nabantu bakhone ukuhlala kuhle ephasini. Ngaphandle kwemvelo abantu bengekhe bakhona ukuphila nokuhlala kuhle ephasini. Ezinye izinto zemvelo zibonakala zingaka qakatheki kodwana zenza umsebenzi omuhle ekuphileni kwabantu. 

Imvelo ikghona ukungenisa imali enarheni, ngombana yenza bona abantu babe nendawo ezingavakatjhelwa babantu bangaphandle ngitjho ama-tourist. Abantu bangaphandle bakhona ukuzobukela imvelo ngokuya kwekareko yabo. Kungaba ziintaba, iinlwana, nokhunye kwemvelo.</text>
      <sha1>fza8tne4dybts10j8n8r5d1cc2dn7j7</sha1>
    </revision>
  </page>
  <page>
    <title>SADiLaR</title>
    <ns>0</ns>
    <id>234</id>
    <revision>
      <id>1235</id>
      <timestamp>2024-02-23T15:13:53Z</timestamp>
      <contributor>
        <username>incubator&gt;Nomsa Skosana</username>
        <id>0</id>
      </contributor>
      <comment>This is the new article.</comment>
      <origin>1235</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2048" sha1="ougkesyaem3g6tnqoojk9ptw9xezhpr" xml:space="preserve">'''SADiLaR'''

I-''South African Centre for Digital Language Resources'' (SADiLaR) liziko elisekelwe ngeemali yi-''Department of Science and Innovation'' (DSI). Izikweli lisungula, lenze belinakekele amathulusi wedijithali, lisekele nerhubhululo esekelwa mahlelo womtjhiningqondo athuthukisa woke amalimi asemthethweni weSewula Afrika khulukhulu emkhakheni omutjha wedijithali yobuntu. 

I-SADiLaR yasungulwa ngomnyaka wee-2016, begodu kuliziko elinzinze e-''North-West University''. Umnqopho we-SADiLaR kuqinisekisa bona kuneziko elenza, elinakekele nelisabalalisa iinsetjeniswa zomtjhiningqondo ezisekela irhubhululo yedijithali ngawo woke amalimi asemthethweni weSewula Afrika. I-SADiLaR isebenza kokubili njengendawo neziko lerhubhululo yedijithali esebenziswa ma-nodes ambalwa afaka hlangana amayunivesithi, amanye amaziko werhubhululo kanye nama-''archives'' womphakathi.

Ama-''nodes'' we-SADiLaR afaka hlangana naka alandelako;

·        CSIR (HLT Research Group)

·        Inter-institutional Centre for Language Development and Assessment (ICELDA)

·        North-West University (Centre for Text Technology)

·        Stellenbosch University (Child Language Development)

·        University of Pretoria (Department of African Languages)

·        University of South Africa (Department of African Languages) 

I-SADiLaR ngokuhlanganyela ne-''Wikipedia'' ne-''Pan South African Language Board'' basungule iphrojekthi ye-SADiLaR-''Wikipedia''-PanSALB (SWiP). Iphrojekthi le yahlonywa ngokusemthethweni e-''University of South Africa'' ngenyanga kaKhukhulamungu ngomnyaka wee-2023. Umnqopho we-SWiP kuqinisekisa bona woke amalimi asemthethweni weSewula Afrika atjhejeke ngokulingana emkhakheni wedigithali nokobana ikhuthaze yoke imikhakha yelimi ekhona eSewula Afrika bona yenze bona amalimabo akhona ku-''Wikipedia'' ngokobana bakhuthaze amalungabo bona atlole, atjhugulule bebafake elinye nelinye ilwazi ku-''Wikipedia'' ngamalimabo ukuze amalimi la kube ngilawo avelelako emkhakheni wedijithali yobuntu.

</text>
      <sha1>ougkesyaem3g6tnqoojk9ptw9xezhpr</sha1>
    </revision>
    <revision>
      <id>1236</id>
      <parentid>1235</parentid>
      <timestamp>2024-03-09T07:36:17Z</timestamp>
      <contributor>
        <username>incubator&gt;LindiweSiba</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1236</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2075" sha1="j4i6rat8cvp95n9ujvucv44fmi8s89q" xml:space="preserve">'''SADiLaR'''

I-''South African Centre for Digital Language Resources'' (SADiLaR) liziko elisekelwe ngeemali yi-''Department of Science and Innovation'' (DSI). Izikweli lisungula, lenze belinakekele amathulusi wedijithali, lisekele nerhubhululo esekelwa mahlelo womtjhiningqondo athuthukisa woke amalimi asemthethweni weSewula Afrika khulukhulu emkhakheni omutjha wedijithali yobuntu. 

I-[[SADiLaR]] yasungulwa ngomnyaka wee-2016, begodu kuliziko elinzinze e-''North-West University''. Umnqopho we-SADiLaR kuqinisekisa bona kuneziko elenza, elinakekele nelisabalalisa iinsetjeniswa zomtjhiningqondo ezisekela irhubhululo yedijithali ngawo woke amalimi asemthethweni weSewula Afrika. I-SADiLaR isebenza kokubili njengendawo neziko lerhubhululo yedijithali esebenziswa ma-nodes ambalwa afaka hlangana amayunivesithi, amanye amaziko werhubhululo kanye nama-''archives'' womphakathi.

Ama-''nodes'' we-SADiLaR afaka hlangana naka alandelako;

·        CSIR (HLT Research Group)

·        Inter-institutional Centre for Language Development and Assessment (ICELDA)

·        North-West University (Centre for Text Technology)

·        Stellenbosch University (Child Language Development)

·        University of Pretoria (Department of African Languages)

·        [[University of South Africa]] (Department of African Languages) 

I-SADiLaR ngokuhlanganyela ne-''Wikipedia'' ne-''Pan South African Language Board'' basungule iphrojekthi ye-SADiLaR-''Wikipedia''-PanSALB (SWiP). Iphrojekthi le yahlonywa ngokusemthethweni e-''University of South Africa'' ngenyanga kaKhukhulamungu ngomnyaka wee-2023. Umnqopho we-SWiP kuqinisekisa bona woke amalimi asemthethweni weSewula Afrika atjhejeke ngokulingana emkhakheni wedigithali nokobana ikhuthaze yoke imikhakha yelimi ekhona e[[Isewula Afrika|Sewula]] Afrika bona yenze bona amalimabo akhona ku-''Wikipedia'' ngokobana bakhuthaze amalungabo bona atlole, atjhugulule bebafake elinye nelinye ilwazi ku-''Wikipedia'' ngamalimabo ukuze amalimi la kube ngilawo avelelako emkhakheni wedijithali yobuntu.

</text>
      <sha1>j4i6rat8cvp95n9ujvucv44fmi8s89q</sha1>
    </revision>
    <revision>
      <id>1237</id>
      <parentid>1236</parentid>
      <timestamp>2024-03-10T20:34:05Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Adding interwiki links to [[d:Q124540717]]</comment>
      <origin>1237</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2100" sha1="q0n9oslgfc68xaum5w1lo07dp7taqhc" xml:space="preserve">'''SADiLaR'''

I-''South African Centre for Digital Language Resources'' (SADiLaR) liziko elisekelwe ngeemali yi-''Department of Science and Innovation'' (DSI). Izikweli lisungula, lenze belinakekele amathulusi wedijithali, lisekele nerhubhululo esekelwa mahlelo womtjhiningqondo athuthukisa woke amalimi asemthethweni weSewula Afrika khulukhulu emkhakheni omutjha wedijithali yobuntu. 

I-[[SADiLaR]] yasungulwa ngomnyaka wee-2016, begodu kuliziko elinzinze e-''North-West University''. Umnqopho we-SADiLaR kuqinisekisa bona kuneziko elenza, elinakekele nelisabalalisa iinsetjeniswa zomtjhiningqondo ezisekela irhubhululo yedijithali ngawo woke amalimi asemthethweni weSewula Afrika. I-SADiLaR isebenza kokubili njengendawo neziko lerhubhululo yedijithali esebenziswa ma-nodes ambalwa afaka hlangana amayunivesithi, amanye amaziko werhubhululo kanye nama-''archives'' womphakathi.

Ama-''nodes'' we-SADiLaR afaka hlangana naka alandelako;

·        CSIR (HLT Research Group)

·        Inter-institutional Centre for Language Development and Assessment (ICELDA)

·        North-West University (Centre for Text Technology)

·        Stellenbosch University (Child Language Development)

·        University of Pretoria (Department of African Languages)

·        [[University of South Africa]] (Department of African Languages) 

I-SADiLaR ngokuhlanganyela ne-''Wikipedia'' ne-''Pan South African Language Board'' basungule iphrojekthi ye-SADiLaR-''Wikipedia''-PanSALB (SWiP). Iphrojekthi le yahlonywa ngokusemthethweni e-''University of South Africa'' ngenyanga kaKhukhulamungu ngomnyaka wee-2023. Umnqopho we-SWiP kuqinisekisa bona woke amalimi asemthethweni weSewula Afrika atjhejeke ngokulingana emkhakheni wedigithali nokobana ikhuthaze yoke imikhakha yelimi ekhona e[[Isewula Afrika|Sewula]] Afrika bona yenze bona amalimabo akhona ku-''Wikipedia'' ngokobana bakhuthaze amalungabo bona atlole, atjhugulule bebafake elinye nelinye ilwazi ku-''Wikipedia'' ngamalimabo ukuze amalimi la kube ngilawo avelelako emkhakheni wedijithali yobuntu.


{{INTERWIKI|Q124540717}}</text>
      <sha1>q0n9oslgfc68xaum5w1lo07dp7taqhc</sha1>
    </revision>
    <revision>
      <id>1238</id>
      <parentid>1237</parentid>
      <timestamp>2024-03-10T20:35:02Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1238</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2085" sha1="cnp8f6263dltirt0jox4flyn3d4gj48" xml:space="preserve">I-''South African Centre for Digital Language Resources'' (SADiLaR) liziko elisekelwe ngeemali yi-''Department of Science and Innovation'' (DSI). Izikweli lisungula, lenze belinakekele amathulusi wedijithali, lisekele nerhubhululo esekelwa mahlelo womtjhiningqondo athuthukisa woke amalimi asemthethweni weSewula Afrika khulukhulu emkhakheni omutjha wedijithali yobuntu. 

I-[[SADiLaR]] yasungulwa ngomnyaka wee-2016, begodu kuliziko elinzinze e-''North-West University''. Umnqopho we-SADiLaR kuqinisekisa bona kuneziko elenza, elinakekele nelisabalalisa iinsetjeniswa zomtjhiningqondo ezisekela irhubhululo yedijithali ngawo woke amalimi asemthethweni weSewula Afrika. I-SADiLaR isebenza kokubili njengendawo neziko lerhubhululo yedijithali esebenziswa ma-nodes ambalwa afaka hlangana amayunivesithi, amanye amaziko werhubhululo kanye nama-''archives'' womphakathi.

Ama-''nodes'' we-SADiLaR afaka hlangana naka alandelako;

·        CSIR (HLT Research Group)

·        Inter-institutional Centre for Language Development and Assessment (ICELDA)

·        North-West University (Centre for Text Technology)

·        Stellenbosch University (Child Language Development)

·        University of Pretoria (Department of African Languages)

·        [[University of South Africa]] (Department of African Languages) 

I-SADiLaR ngokuhlanganyela ne-''Wikipedia'' ne-''Pan South African Language Board'' basungule iphrojekthi ye-SADiLaR-''Wikipedia''-PanSALB (SWiP). Iphrojekthi le yahlonywa ngokusemthethweni e-''University of South Africa'' ngenyanga kaKhukhulamungu ngomnyaka wee-2023. Umnqopho we-SWiP kuqinisekisa bona woke amalimi asemthethweni weSewula Afrika atjhejeke ngokulingana emkhakheni wedigithali nokobana ikhuthaze yoke imikhakha yelimi ekhona e[[Isewula Afrika|Sewula]] Afrika bona yenze bona amalimabo akhona ku-''Wikipedia'' ngokobana bakhuthaze amalungabo bona atlole, atjhugulule bebafake elinye nelinye ilwazi ku-''Wikipedia'' ngamalimabo ukuze amalimi la kube ngilawo avelelako emkhakheni wedijithali yobuntu.


{{INTERWIKI|Q124540717}}</text>
      <sha1>cnp8f6263dltirt0jox4flyn3d4gj48</sha1>
    </revision>
    <revision>
      <id>1239</id>
      <parentid>1238</parentid>
      <timestamp>2024-03-10T20:35:59Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Bobbyshabangu moved page [[sadilar]] to [[SADiLaR]]: This is the correct acronym of the organisation. </comment>
      <origin>1238</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2085" sha1="cnp8f6263dltirt0jox4flyn3d4gj48" xml:space="preserve">I-''South African Centre for Digital Language Resources'' (SADiLaR) liziko elisekelwe ngeemali yi-''Department of Science and Innovation'' (DSI). Izikweli lisungula, lenze belinakekele amathulusi wedijithali, lisekele nerhubhululo esekelwa mahlelo womtjhiningqondo athuthukisa woke amalimi asemthethweni weSewula Afrika khulukhulu emkhakheni omutjha wedijithali yobuntu. 

I-[[SADiLaR]] yasungulwa ngomnyaka wee-2016, begodu kuliziko elinzinze e-''North-West University''. Umnqopho we-SADiLaR kuqinisekisa bona kuneziko elenza, elinakekele nelisabalalisa iinsetjeniswa zomtjhiningqondo ezisekela irhubhululo yedijithali ngawo woke amalimi asemthethweni weSewula Afrika. I-SADiLaR isebenza kokubili njengendawo neziko lerhubhululo yedijithali esebenziswa ma-nodes ambalwa afaka hlangana amayunivesithi, amanye amaziko werhubhululo kanye nama-''archives'' womphakathi.

Ama-''nodes'' we-SADiLaR afaka hlangana naka alandelako;

·        CSIR (HLT Research Group)

·        Inter-institutional Centre for Language Development and Assessment (ICELDA)

·        North-West University (Centre for Text Technology)

·        Stellenbosch University (Child Language Development)

·        University of Pretoria (Department of African Languages)

·        [[University of South Africa]] (Department of African Languages) 

I-SADiLaR ngokuhlanganyela ne-''Wikipedia'' ne-''Pan South African Language Board'' basungule iphrojekthi ye-SADiLaR-''Wikipedia''-PanSALB (SWiP). Iphrojekthi le yahlonywa ngokusemthethweni e-''University of South Africa'' ngenyanga kaKhukhulamungu ngomnyaka wee-2023. Umnqopho we-SWiP kuqinisekisa bona woke amalimi asemthethweni weSewula Afrika atjhejeke ngokulingana emkhakheni wedigithali nokobana ikhuthaze yoke imikhakha yelimi ekhona e[[Isewula Afrika|Sewula]] Afrika bona yenze bona amalimabo akhona ku-''Wikipedia'' ngokobana bakhuthaze amalungabo bona atlole, atjhugulule bebafake elinye nelinye ilwazi ku-''Wikipedia'' ngamalimabo ukuze amalimi la kube ngilawo avelelako emkhakheni wedijithali yobuntu.


{{INTERWIKI|Q124540717}}</text>
      <sha1>cnp8f6263dltirt0jox4flyn3d4gj48</sha1>
    </revision>
    <revision>
      <id>1240</id>
      <parentid>1239</parentid>
      <timestamp>2024-03-15T15:52:13Z</timestamp>
      <contributor>
        <username>incubator&gt;Nomsa Skosana</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1240</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1506" sha1="f1eeevecp0v0ro6p41dppn2q63xbnse" xml:space="preserve">I-''[https://sadilar.org/en/ South African Centre for Digital Language Resources]'' (SADiLaR) liziko elisekelwe ngeemali yi-''[https://www.dst.gov.za Department of Science and Innovation]'' (DSI). Izikweli lisungula, lenze belinakekele amathulusi wedijithali, lisekele nerhubhululo esekelwa mahlelo womtjhiningqondo athuthukisa woke amalimi asemthethweni weSewula Afrika khulukhulu emkhakheni omutjha wedijithali yobuntu. 

== Ukusungulwa kwe-SADiLaR ==
I-[[SADiLaR]] yasungulwa ngomnyaka wee-2016, begodu kuliziko elinzinze e-''[https://www.nwu.ac.za North-West University]''. Umnqopho we-SADiLaR kuqinisekisa bona kuneziko elenza, elinakekele nelisabalalisa iinsetjeniswa zomtjhiningqondo ezisekela irhubhululo yedijithali ngawo woke amalimi asemthethweni weSewula Afrika. I-SADiLaR isebenza kokubili njengendawo neziko lerhubhululo yedijithali esebenziswa ma-nodes ambalwa afaka hlangana amayunivesithi, amanye amaziko werhubhululo kanye nama-''archives'' womphakathi.

== Ama-''nodes'' we-SADiLaR ==
Ama-''nodes'' we-SADiLaR afaka hlangana naka alandelako;

·        CSIR (HLT Research Group)

·        Inter-institutional Centre for Language Development and Assessment (ICELDA)

·        North-West University (Centre for Text Technology)

·        Stellenbosch University (Child Language Development)

·        University of Pretoria (Department of African Languages)

·        [[University of South Africa]] (Department of African Languages) 


{{INTERWIKI|Q124540717}}</text>
      <sha1>f1eeevecp0v0ro6p41dppn2q63xbnse</sha1>
    </revision>
    <revision>
      <id>1241</id>
      <parentid>1240</parentid>
      <timestamp>2024-10-14T13:47:08Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>6 revisions imported</comment>
      <origin>1240</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1506" sha1="f1eeevecp0v0ro6p41dppn2q63xbnse" xml:space="preserve">I-''[https://sadilar.org/en/ South African Centre for Digital Language Resources]'' (SADiLaR) liziko elisekelwe ngeemali yi-''[https://www.dst.gov.za Department of Science and Innovation]'' (DSI). Izikweli lisungula, lenze belinakekele amathulusi wedijithali, lisekele nerhubhululo esekelwa mahlelo womtjhiningqondo athuthukisa woke amalimi asemthethweni weSewula Afrika khulukhulu emkhakheni omutjha wedijithali yobuntu. 

== Ukusungulwa kwe-SADiLaR ==
I-[[SADiLaR]] yasungulwa ngomnyaka wee-2016, begodu kuliziko elinzinze e-''[https://www.nwu.ac.za North-West University]''. Umnqopho we-SADiLaR kuqinisekisa bona kuneziko elenza, elinakekele nelisabalalisa iinsetjeniswa zomtjhiningqondo ezisekela irhubhululo yedijithali ngawo woke amalimi asemthethweni weSewula Afrika. I-SADiLaR isebenza kokubili njengendawo neziko lerhubhululo yedijithali esebenziswa ma-nodes ambalwa afaka hlangana amayunivesithi, amanye amaziko werhubhululo kanye nama-''archives'' womphakathi.

== Ama-''nodes'' we-SADiLaR ==
Ama-''nodes'' we-SADiLaR afaka hlangana naka alandelako;

·        CSIR (HLT Research Group)

·        Inter-institutional Centre for Language Development and Assessment (ICELDA)

·        North-West University (Centre for Text Technology)

·        Stellenbosch University (Child Language Development)

·        University of Pretoria (Department of African Languages)

·        [[University of South Africa]] (Department of African Languages) 


{{INTERWIKI|Q124540717}}</text>
      <sha1>f1eeevecp0v0ro6p41dppn2q63xbnse</sha1>
    </revision>
    <revision>
      <id>1676</id>
      <parentid>1241</parentid>
      <timestamp>2024-10-16T09:50:07Z</timestamp>
      <contributor>
        <username>JhsBot</username>
        <id>34</id>
      </contributor>
      <minor />
      <comment>bot: Removing interwiki template; the page is now connected to [[d:Q124540717]]</comment>
      <origin>1676</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1478" sha1="qdzndarsp6vfuctyo2ul6xa9owyiyau" xml:space="preserve">I-''[https://sadilar.org/en/ South African Centre for Digital Language Resources]'' (SADiLaR) liziko elisekelwe ngeemali yi-''[https://www.dst.gov.za Department of Science and Innovation]'' (DSI). Izikweli lisungula, lenze belinakekele amathulusi wedijithali, lisekele nerhubhululo esekelwa mahlelo womtjhiningqondo athuthukisa woke amalimi asemthethweni weSewula Afrika khulukhulu emkhakheni omutjha wedijithali yobuntu. 

== Ukusungulwa kwe-SADiLaR ==
I-[[SADiLaR]] yasungulwa ngomnyaka wee-2016, begodu kuliziko elinzinze e-''[https://www.nwu.ac.za North-West University]''. Umnqopho we-SADiLaR kuqinisekisa bona kuneziko elenza, elinakekele nelisabalalisa iinsetjeniswa zomtjhiningqondo ezisekela irhubhululo yedijithali ngawo woke amalimi asemthethweni weSewula Afrika. I-SADiLaR isebenza kokubili njengendawo neziko lerhubhululo yedijithali esebenziswa ma-nodes ambalwa afaka hlangana amayunivesithi, amanye amaziko werhubhululo kanye nama-''archives'' womphakathi.

== Ama-''nodes'' we-SADiLaR ==
Ama-''nodes'' we-SADiLaR afaka hlangana naka alandelako;

·        CSIR (HLT Research Group)

·        Inter-institutional Centre for Language Development and Assessment (ICELDA)

·        North-West University (Centre for Text Technology)

·        Stellenbosch University (Child Language Development)

·        University of Pretoria (Department of African Languages)

·        [[University of South Africa]] (Department of African Languages)</text>
      <sha1>qdzndarsp6vfuctyo2ul6xa9owyiyau</sha1>
    </revision>
    <revision>
      <id>2686</id>
      <parentid>1676</parentid>
      <timestamp>2025-04-23T08:23:31Z</timestamp>
      <contributor>
        <ip>41.24.169.28</ip>
      </contributor>
      <comment>Added references and links</comment>
      <origin>2686</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1734" sha1="tnsurvcjhwz7tdcq299ut3w3kvhsnsd" xml:space="preserve">I-''[https://sadilar.org/en/ South African Centre for Digital Language Resources]'' (SADiLaR) liziko elisekelwe ngeemali yi-''[https://www.dst.gov.za Department of Science and Innovation]'' (DSI). Izikweli lisungula, lenze belinakekele amathulusi wedijithali, lisekele nerhubhululo esekelwa mahlelo womtjhiningqondo athuthukisa woke amalimi asemthethweni weSewula Afrika khulukhulu emkhakheni omutjha wedijithali yobuntu. 

== Ukusungulwa kwe-SADiLaR ==
I-[[SADiLaR]] yasungulwa ngomnyaka wee-2016, begodu kuliziko elinzinze e-''[https://www.nwu.ac.za North-West University]''. Umnqopho we-SADiLaR kuqinisekisa bona kuneziko elenza, elinakekele nelisabalalisa iinsetjeniswa zomtjhiningqondo ezisekela irhubhululo yedijithali ngawo woke amalimi asemthethweni weSewula Afrika. I-SADiLaR isebenza kokubili njengendawo neziko lerhubhululo yedijithali esebenziswa ma-nodes ambalwa afaka hlangana amayunivesithi, amanye amaziko werhubhululo kanye nama-''archives'' womphakathi.

== Ama-''nodes'' we-SADiLaR ==
Ama-''nodes'' we-SADiLaR afaka hlangana naka alandelako;

·        CSIR (HLT Research Group)

·        Inter-institutional Centre for Language Development and Assessment (ICELDA)

·        [https://www.nwu.ac.za/ North-West University]&lt;ref&gt;[https://www.nwu.ac.za/]&lt;/ref&gt; (Centre for Text Technology)

·        [https://www.sun.ac.za/english Stellenbosch University] (Child Language Development)

·        [https://www.up.ac.za/ University of Pretoria]&lt;ref&gt;[https://www.up.ac.za/]&lt;/ref&gt; (Department of African Languages)

·        [https://www.unisa.ac.za/sites/corporate/default University of South Africa]&lt;ref&gt;[https://www.unisa.ac.za/sites/corporate/default]&lt;/ref&gt; (Department of African Languages)</text>
      <sha1>tnsurvcjhwz7tdcq299ut3w3kvhsnsd</sha1>
    </revision>
    <revision>
      <id>2687</id>
      <parentid>2686</parentid>
      <timestamp>2025-04-23T08:28:27Z</timestamp>
      <contributor>
        <ip>41.24.169.28</ip>
      </contributor>
      <origin>2687</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1754" sha1="fg2iux9rcr9raxysmfbe7wcnx7abhhe" xml:space="preserve">I-''[https://sadilar.org/en/ South African Centre for Digital Language Resources]'' (SADiLaR) liziko elisekelwe ngeemali yi-''[https://www.dst.gov.za Department of Science and Innovation]'' (DSI). Izikweli lisungula, lenze belinakekele amathulusi wedijithali, lisekele nerhubhululo esekelwa mahlelo womtjhiningqondo athuthukisa woke amalimi asemthethweni weSewula Afrika khulukhulu emkhakheni omutjha wedijithali yobuntu. 

== Ukusungulwa kwe-SADiLaR ==
I-[[SADiLaR]] yasungulwa ngomnyaka wee-2016, begodu kuliziko elinzinze e-''[https://www.nwu.ac.za North-West University]''. Umnqopho we-SADiLaR kuqinisekisa bona kuneziko elenza, elinakekele nelisabalalisa iinsetjeniswa zomtjhiningqondo ezisekela irhubhululo yedijithali ngawo woke amalimi asemthethweni weSewula Afrika. I-SADiLaR isebenza kokubili njengendawo neziko lerhubhululo yedijithali esebenziswa ma-nodes ambalwa afaka hlangana amayunivesithi, amanye amaziko werhubhululo kanye nama-''archives'' womphakathi.

== Ama-''nodes'' we-SADiLaR ==
Ama-''nodes'' we-SADiLaR afaka hlangana naka alandelako;

·        CSIR (HLT Research Group)

·        Inter-institutional Centre for Language Development and Assessment (ICELDA)

·        [https://www.nwu.ac.za/ North-West University]&lt;ref&gt;[https://www.nwu.ac.za/]&lt;/ref&gt; (Centre for Text Technology)

·        [https://www.sun.ac.za/english Stellenbosch University] (Child Language Development)

·        [https://www.up.ac.za/ University of Pretoria]&lt;ref&gt;[https://www.up.ac.za/]&lt;/ref&gt; (Department of African Languages)

·        [https://www.unisa.ac.za/sites/corporate/default University of South Africa]&lt;ref&gt;[https://www.unisa.ac.za/sites/corporate/default]&lt;/ref&gt; (Department of African Languages)

== Amareferensi ==</text>
      <sha1>fg2iux9rcr9raxysmfbe7wcnx7abhhe</sha1>
    </revision>
    <revision>
      <id>2688</id>
      <parentid>2687</parentid>
      <timestamp>2025-04-23T08:37:59Z</timestamp>
      <contributor>
        <ip>41.24.169.26</ip>
      </contributor>
      <comment>Added new information</comment>
      <origin>2688</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2431" sha1="opbtbf9g1et4732aa5hmz6xzxhd4s8d" xml:space="preserve">I-''[https://sadilar.org/en/ South African Centre for Digital Language Resources]'' (SADiLaR) liziko elisekelwe ngeemali yi-''[https://www.dst.gov.za Department of Science and Innovation]'' (DSI). Izikweli lisungula, lenze belinakekele amathulusi wedijithali, lisekele nerhubhululo esekelwa mahlelo womtjhiningqondo athuthukisa woke amalimi asemthethweni weSewula Afrika khulukhulu emkhakheni omutjha wedijithali yobuntu. 

== Ukusungulwa kwe-SADiLaR ==
I-[[SADiLaR]] yasungulwa ngomnyaka wee-2016, begodu kuliziko elinzinze e-''[https://www.nwu.ac.za North-West University]''. Umnqopho we-SADiLaR kuqinisekisa bona kuneziko elenza, elinakekele nelisabalalisa iinsetjeniswa zomtjhiningqondo ezisekela irhubhululo yedijithali ngawo woke amalimi asemthethweni weSewula Afrika. I-SADiLaR isebenza kokubili njengendawo neziko lerhubhululo yedijithali esebenziswa ma-nodes ambalwa afaka hlangana amayunivesithi, amanye amaziko werhubhululo kanye nama-''archives'' womphakathi.

== Ama-''nodes'' we-SADiLaR ==
Ama-''nodes'' we-SADiLaR afaka hlangana naka alandelako;

·        CSIR (HLT Research Group)

·        Inter-institutional Centre for Language Development and Assessment (ICELDA)

·        [https://www.nwu.ac.za/ North-West University]&lt;ref&gt;[https://www.nwu.ac.za/]&lt;/ref&gt; (Centre for Text Technology)

·        [https://www.sun.ac.za/english Stellenbosch University] (Child Language Development)

·        [https://www.up.ac.za/ University of Pretoria]&lt;ref&gt;[https://www.up.ac.za/]&lt;/ref&gt; (Department of African Languages)

·        [https://www.unisa.ac.za/sites/corporate/default University of South Africa]&lt;ref&gt;[https://www.unisa.ac.za/sites/corporate/default]&lt;/ref&gt; (Department of African Languages)

== Imisebenzi eyenziwa kwa-SADiLaR ==
I-SADiLaR iraga amahlelo amabili:

Ihlelo ledijithali, elifaka hlangana ukwakhiwa okuhlelekileko kwemitlolo yedijithali efaneleko, ukukhuluma kanye nemithombo yeendlela ezinengi ezihlobene nawo woke amalimi asemthethweni weSewula Afrika. Ukuthuthukiswa kwamathulusi wesofthiwe wokurhubhulula amalimi wemvelo afaneleko ngenhloso yokurhubhulula nokuthuthukisa kufakwe njengengcenye yehlelo lokwenza idijithali.

Ihlelo le-Digithali yoBuntu, lenza kube lula ukwakhiwa kwamandla wokwenza irhubhululo ngokukhuthaza nokusekela ukusetjenziswa kwedatha yedijithali kanye neendlela ezitjha zokusebenza ngaphakathi komkhakha wezoBuntu newezeHlalo.

== Amareferensi ==</text>
      <sha1>opbtbf9g1et4732aa5hmz6xzxhd4s8d</sha1>
    </revision>
    <revision>
      <id>2745</id>
      <parentid>2688</parentid>
      <timestamp>2025-04-23T10:30:02Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <origin>2745</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2498" sha1="5d9giun8jxbx1staxqaz9kxfr7puj0e" xml:space="preserve">I-''[https://sadilar.org/en/ South African Centre for Digital Language Resources]'' (SADiLaR) liziko elisekelwe ngeemali yi-''[https://www.dst.gov.za Department of Science and Innovation]'' (DSI). Izikweli lisungula, lenze belinakekele amathulusi wedijithali, lisekele nerhubhululo esekelwa mahlelo womtjhiningqondo athuthukisa woke amalimi asemthethweni weSewula Afrika khulukhulu emkhakheni omutjha wedijithali yobuntu. 

== Ukusungulwa kwe-SADiLaR ==
I-[[SADiLaR]] yasungulwa ngomnyaka wee-2016, begodu kuliziko elinzinze e-''[https://www.nwu.ac.za North-West University]''. Umnqopho we-SADiLaR kuqinisekisa bona kuneziko elenza, elinakekele nelisabalalisa iinsetjeniswa zomtjhiningqondo ezisekela irhubhululo yedijithali ngawo woke amalimi asemthethweni weSewula Afrika. I-SADiLaR isebenza kokubili njengendawo neziko lerhubhululo yedijithali esebenziswa ma-nodes ambalwa afaka hlangana amayunivesithi, amanye amaziko werhubhululo kanye nama-''archives'' womphakathi.

== Ama-''nodes'' we-SADiLaR ==
Ama-''nodes'' we-SADiLaR afaka hlangana naka alandelako;

·        CSIR (HLT Research Group)

·        Inter-institutional Centre for Language Development and Assessment (ICELDA)

·        [https://www.nwu.ac.za/ North-West University]&lt;ref&gt;[https://www.nwu.ac.za/]&lt;/ref&gt; (Centre for Text Technology)

·        [https://www.sun.ac.za/english Stellenbosch University] (Child Language Development)

·        [https://www.up.ac.za/ University of Pretoria]&lt;ref&gt;{{Cite web |title=UP {{!}} University of Pretoria |url=https://www.up.ac.za/ |access-date=2025-04-23 |website=www.up.ac.za}}&lt;/ref&gt;

·        [https://www.unisa.ac.za/sites/corporate/default University of South Africa]&lt;ref&gt;[https://www.unisa.ac.za/sites/corporate/default]&lt;/ref&gt; (Department of African Languages)

== Imisebenzi eyenziwa kwa-SADiLaR ==
I-SADiLaR iraga amahlelo amabili:

Ihlelo ledijithali, elifaka hlangana ukwakhiwa okuhlelekileko kwemitlolo yedijithali efaneleko, ukukhuluma kanye nemithombo yeendlela ezinengi ezihlobene nawo woke amalimi asemthethweni weSewula Afrika. Ukuthuthukiswa kwamathulusi wesofthiwe wokurhubhulula amalimi wemvelo afaneleko ngenhloso yokurhubhulula nokuthuthukisa kufakwe njengengcenye yehlelo lokwenza idijithali.

Ihlelo le-Digithali yoBuntu, lenza kube lula ukwakhiwa kwamandla wokwenza irhubhululo ngokukhuthaza nokusekela ukusetjenziswa kwedatha yedijithali kanye neendlela ezitjha zokusebenza ngaphakathi komkhakha wezoBuntu newezeHlalo.

== Amareferensi ==</text>
      <sha1>5d9giun8jxbx1staxqaz9kxfr7puj0e</sha1>
    </revision>
    <revision>
      <id>2747</id>
      <parentid>2745</parentid>
      <timestamp>2025-04-23T10:35:38Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <origin>2747</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2706" sha1="dhpg4dccr28nd3yybc7c04rwvzj27ai" xml:space="preserve">I-''[https://sadilar.org/en/ South African Centre for Digital Language Resources]'' (SADiLaR) liziko elisekelwe ngeemali yi-''[https://www.dst.gov.za Department of Science and Innovation]'' (DSI). Izikweli lisungula, lenze belinakekele amathulusi wedijithali, lisekele nerhubhululo esekelwa mahlelo womtjhiningqondo athuthukisa woke amalimi asemthethweni weSewula Afrika khulukhulu emkhakheni omutjha wedijithali yobuntu. 

== Ukusungulwa kwe-SADiLaR ==
I-[[SADiLaR]] yasungulwa ngomnyaka wee-2016, begodu kuliziko elinzinze e-''[https://www.nwu.ac.za North-West University]''. Umnqopho we-SADiLaR kuqinisekisa bona kuneziko elenza, elinakekele nelisabalalisa iinsetjeniswa zomtjhiningqondo ezisekela irhubhululo yedijithali ngawo woke amalimi asemthethweni weSewula Afrika. I-SADiLaR isebenza kokubili njengendawo neziko lerhubhululo yedijithali esebenziswa ma-nodes ambalwa afaka hlangana amayunivesithi, amanye amaziko werhubhululo kanye nama-''archives'' womphakathi.

== Ama-''nodes'' we-SADiLaR ==
Ama-''nodes'' we-SADiLaR afaka hlangana naka alandelako;

·        CSIR (HLT Research Group)

·        Inter-institutional Centre for Language Development and Assessment (ICELDA)

·        [https://www.nwu.ac.za/ North-West University]&lt;ref&gt;[https://www.nwu.ac.za/]&lt;/ref&gt; (Centre for Text Technology&lt;ref&gt;{{Cite web |title=South African Communicative Development Inventories |url=https://sa-cdi.org/ |access-date=2025-04-23 |website=South African Communicative Development Inventories |language=en-GB}}&lt;/ref&gt;)

·        [https://www.sun.ac.za/english Stellenbosch University] (Child Language Development)

·        [https://www.up.ac.za/ University of Pretoria]&lt;ref&gt;{{Cite web |title=UP {{!}} University of Pretoria |url=https://www.up.ac.za/ |access-date=2025-04-23 |website=www.up.ac.za}}&lt;/ref&gt;

·        [https://www.unisa.ac.za/sites/corporate/default University of South Africa]&lt;ref&gt;[https://www.unisa.ac.za/sites/corporate/default]&lt;/ref&gt; (Department of African Languages)

== Imisebenzi eyenziwa kwa-SADiLaR ==
I-SADiLaR iraga amahlelo amabili:

Ihlelo ledijithali, elifaka hlangana ukwakhiwa okuhlelekileko kwemitlolo yedijithali efaneleko, ukukhuluma kanye nemithombo yeendlela ezinengi ezihlobene nawo woke amalimi asemthethweni weSewula Afrika. Ukuthuthukiswa kwamathulusi wesofthiwe wokurhubhulula amalimi wemvelo afaneleko ngenhloso yokurhubhulula nokuthuthukisa kufakwe njengengcenye yehlelo lokwenza idijithali.

Ihlelo le-Digithali yoBuntu, lenza kube lula ukwakhiwa kwamandla wokwenza irhubhululo ngokukhuthaza nokusekela ukusetjenziswa kwedatha yedijithali kanye neendlela ezitjha zokusebenza ngaphakathi komkhakha wezoBuntu newezeHlalo.

== Amareferensi ==</text>
      <sha1>dhpg4dccr28nd3yybc7c04rwvzj27ai</sha1>
    </revision>
    <revision>
      <id>2748</id>
      <parentid>2747</parentid>
      <timestamp>2025-04-23T10:40:31Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <origin>2748</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2464" sha1="dqmom6sszx3uu8vz1dc776es7k9ytr8" xml:space="preserve">I-''[https://sadilar.org/en/ South African Centre for Digital Language Resources]'' (SADiLaR) liziko elisekelwe ngeemali yi-''[https://www.dst.gov.za Department of Science and Innovation]'' (DSI). Izikweli lisungula, lenze belinakekele amathulusi wedijithali, lisekele nerhubhululo esekelwa mahlelo womtjhiningqondo athuthukisa woke amalimi asemthethweni weSewula Afrika khulukhulu emkhakheni omutjha wedijithali yobuntu. 

== Ukusungulwa kwe-SADiLaR ==
I-[[SADiLaR]] yasungulwa ngomnyaka wee-2016, begodu kuliziko elinzinze e-''[https://www.nwu.ac.za North-West University]''. Umnqopho we-SADiLaR kuqinisekisa bona kuneziko elenza, elinakekele nelisabalalisa iinsetjeniswa zomtjhiningqondo ezisekela irhubhululo yedijithali ngawo woke amalimi asemthethweni weSewula Afrika. I-SADiLaR isebenza kokubili njengendawo neziko lerhubhululo yedijithali esebenziswa ma-nodes ambalwa afaka hlangana amayunivesithi, amanye amaziko werhubhululo kanye nama-''archives'' womphakathi.

== Ama-''nodes'' we-SADiLaR ==
Ama-''nodes'' we-SADiLaR afaka hlangana naka alandelako;

·        CSIR (HLT Research Group)

·        Inter-institutional Centre for Language Development and Assessment (ICELDA)

·        [https://www.nwu.ac.za/ North-West University]&lt;ref&gt;[https://www.nwu.ac.za/])

·        [https://www.sun.ac.za/english Stellenbosch University] (Child Language Development)

·        [https://www.up.ac.za/ University of Pretoria]&lt;ref&gt;{{Cite web |title=UP {{!}} University of Pretoria |url=https://www.up.ac.za/ |access-date=2025-04-23 |website=www.up.ac.za}}&lt;/ref&gt;

·        [https://www.unisa.ac.za/sites/corporate/default University of South Africa]&lt;ref&gt;[https://www.unisa.ac.za/sites/corporate/default]&lt;/ref&gt; (Department of African Languages)

== Imisebenzi eyenziwa kwa-SADiLaR ==
I-SADiLaR iraga amahlelo amabili:

Ihlelo ledijithali, elifaka hlangana ukwakhiwa okuhlelekileko kwemitlolo yedijithali efaneleko, ukukhuluma kanye nemithombo yeendlela ezinengi ezihlobene nawo woke amalimi asemthethweni weSewula Afrika. Ukuthuthukiswa kwamathulusi wesofthiwe wokurhubhulula amalimi wemvelo afaneleko ngenhloso yokurhubhulula nokuthuthukisa kufakwe njengengcenye yehlelo lokwenza idijithali.

Ihlelo le-Digithali yoBuntu, lenza kube lula ukwakhiwa kwamandla wokwenza irhubhululo ngokukhuthaza nokusekela ukusetjenziswa kwedatha yedijithali kanye neendlela ezitjha zokusebenza ngaphakathi komkhakha wezoBuntu newezeHlalo.

== Amareferensi ==</text>
      <sha1>dqmom6sszx3uu8vz1dc776es7k9ytr8</sha1>
    </revision>
    <revision>
      <id>2749</id>
      <parentid>2748</parentid>
      <timestamp>2025-04-23T10:44:38Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <origin>2749</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2481" sha1="3oel218lorki373e8nfkt98eixndqdc" xml:space="preserve">I-''[https://sadilar.org/en/ South African Centre for Digital Language Resources]'' (SADiLaR) liziko elisekelwe ngeemali yi-''[https://www.dst.gov.za Department of Science and Innovation]'' (DSI). Izikweli lisungula, lenze belinakekele amathulusi wedijithali, lisekele nerhubhululo esekelwa mahlelo womtjhiningqondo athuthukisa woke amalimi asemthethweni weSewula Afrika khulukhulu emkhakheni omutjha wedijithali yobuntu. 

== Ukusungulwa kwe-SADiLaR ==
I-[[SADiLaR]] yasungulwa ngomnyaka wee-2016, begodu kuliziko elinzinze e-''[https://www.nwu.ac.za North-West University]''. Umnqopho we-SADiLaR kuqinisekisa bona kuneziko elenza, elinakekele nelisabalalisa iinsetjeniswa zomtjhiningqondo ezisekela irhubhululo yedijithali ngawo woke amalimi asemthethweni weSewula Afrika. I-SADiLaR isebenza kokubili njengendawo neziko lerhubhululo yedijithali esebenziswa ma-''nodes'' ambalwa afaka hlangana amayunivesithi, amanye amaziko werhubhululo kanye nama-''archives'' womphakathi.

== Ama-''nodes'' we-SADiLaR ==
Ama-''nodes'' we-SADiLaR afaka hlangana naka alandelako;

·        CSIR (HLT Research Group)

·        Inter-institutional Centre for Language Development and Assessment (ICELDA)

·        [https://www.nwu.ac.za/ North-West University]&lt;ref&gt;[https://www.nwu.ac.za/])

·        [https://www.sun.ac.za/english Stellenbosch University] (Child Language Development)

·        [https://www.up.ac.za/ University of Pretoria]&lt;nowiki&gt;&lt;ref&gt;&lt;/nowiki&gt;{{Cite web|title=UP {{!}} University of Pretoria|url=https://www.up.ac.za/|access-date=2025-04-23|website=www.up.ac.za}}&lt;/ref&gt;

·        [https://www.unisa.ac.za/sites/corporate/default University of South Africa]&lt;ref&gt;[https://www.unisa.ac.za/sites/corporate/default]&lt;/ref&gt; (Department of African Languages)

== Imisebenzi eyenziwa kwa-SADiLaR ==
I-SADiLaR iraga amahlelo amabili:

Ihlelo ledijithali, elifaka hlangana ukwakhiwa okuhlelekileko kwemitlolo yedijithali efaneleko, ukukhuluma kanye nemithombo yeendlela ezinengi ezihlobene nawo woke amalimi asemthethweni weSewula Afrika. Ukuthuthukiswa kwamathulusi wesofthiwe wokurhubhulula amalimi wemvelo afaneleko ngenhloso yokurhubhulula nokuthuthukisa kufakwe njengengcenye yehlelo lokwenza idijithali.

Ihlelo le-Digithali yoBuntu, lenza kube lula ukwakhiwa kwamandla wokwenza irhubhululo ngokukhuthaza nokusekela ukusetjenziswa kwedatha yedijithali kanye neendlela ezitjha zokusebenza ngaphakathi komkhakha wezoBuntu newezeHlalo.

== Amareferensi ==</text>
      <sha1>3oel218lorki373e8nfkt98eixndqdc</sha1>
    </revision>
    <revision>
      <id>5740</id>
      <parentid>2749</parentid>
      <timestamp>2025-09-18T11:40:53Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>added the databox to SADiLaR</comment>
      <origin>5740</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2492" sha1="7rzs9z3qtfs708xdfwmvwtdvgha6n9i" xml:space="preserve">{{Databox}}I-''[https://sadilar.org/en/ South African Centre for Digital Language Resources]'' (SADiLaR) liziko elisekelwe ngeemali yi-''[https://www.dst.gov.za Department of Science and Innovation]'' (DSI). Izikweli lisungula, lenze belinakekele amathulusi wedijithali, lisekele nerhubhululo esekelwa mahlelo womtjhiningqondo athuthukisa woke amalimi asemthethweni weSewula Afrika khulukhulu emkhakheni omutjha wedijithali yobuntu. 

== Ukusungulwa kwe-SADiLaR ==
I-[[SADiLaR]] yasungulwa ngomnyaka wee-2016, begodu kuliziko elinzinze e-''[https://www.nwu.ac.za North-West University]''. Umnqopho we-SADiLaR kuqinisekisa bona kuneziko elenza, elinakekele nelisabalalisa iinsetjeniswa zomtjhiningqondo ezisekela irhubhululo yedijithali ngawo woke amalimi asemthethweni weSewula Afrika. I-SADiLaR isebenza kokubili njengendawo neziko lerhubhululo yedijithali esebenziswa ma-''nodes'' ambalwa afaka hlangana amayunivesithi, amanye amaziko werhubhululo kanye nama-''archives'' womphakathi.

== Ama-''nodes'' we-SADiLaR ==
Ama-''nodes'' we-SADiLaR afaka hlangana naka alandelako;

·        CSIR (HLT Research Group)

·        Inter-institutional Centre for Language Development and Assessment (ICELDA)

·        [https://www.nwu.ac.za/ North-West University]&lt;ref&gt;[https://www.nwu.ac.za/])

·        [https://www.sun.ac.za/english Stellenbosch University] (Child Language Development)

·        [https://www.up.ac.za/ University of Pretoria]&lt;nowiki&gt;&lt;ref&gt;&lt;/nowiki&gt;{{Cite web|title=UP {{!}} University of Pretoria|url=https://www.up.ac.za/|access-date=2025-04-23|website=www.up.ac.za}}&lt;/ref&gt;

·        [https://www.unisa.ac.za/sites/corporate/default University of South Africa]&lt;ref&gt;[https://www.unisa.ac.za/sites/corporate/default]&lt;/ref&gt; (Department of African Languages)

== Imisebenzi eyenziwa kwa-SADiLaR ==
I-SADiLaR iraga amahlelo amabili:

Ihlelo ledijithali, elifaka hlangana ukwakhiwa okuhlelekileko kwemitlolo yedijithali efaneleko, ukukhuluma kanye nemithombo yeendlela ezinengi ezihlobene nawo woke amalimi asemthethweni weSewula Afrika. Ukuthuthukiswa kwamathulusi wesofthiwe wokurhubhulula amalimi wemvelo afaneleko ngenhloso yokurhubhulula nokuthuthukisa kufakwe njengengcenye yehlelo lokwenza idijithali.

Ihlelo le-Digithali yoBuntu, lenza kube lula ukwakhiwa kwamandla wokwenza irhubhululo ngokukhuthaza nokusekela ukusetjenziswa kwedatha yedijithali kanye neendlela ezitjha zokusebenza ngaphakathi komkhakha wezoBuntu newezeHlalo.

== Amareferensi ==</text>
      <sha1>7rzs9z3qtfs708xdfwmvwtdvgha6n9i</sha1>
    </revision>
  </page>
  <page>
    <title>SWiP</title>
    <ns>0</ns>
    <id>235</id>
    <revision>
      <id>1242</id>
      <timestamp>2024-03-09T09:21:15Z</timestamp>
      <contributor>
        <username>incubator&gt;Nomsa Skosana</username>
        <id>0</id>
      </contributor>
      <comment>New article</comment>
      <origin>1242</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1484" sha1="2jsge07u0o2pau3xxy868u3lrffaq4m" xml:space="preserve">'''SWiP: Ukubulunga Amalimi: ILwazi Elisimahla, Elitholakala Lula Nelivuleleke Kuwokewoke.''' 

I-''SADiLaR''-''Wikipedia-PanSALB'' (''SWiP'') iligadango elihlanganyelweko elihlanganisa i-''South African Centre for Digital Language Resources'' (''SADiLaR''), isiluluncwadi (''encyclopaedia)'' sasimahla (''Wikipedia)'' kanye ne-''Pan South African Language Board'' (''PanSALB''). Ihlelo le-''SWiP'' lihlonywe ngokusemthethweni mhlazana amalanga ama-20 kuKhukhulamungu emnyakeni wee-2023 e-''University of South Africa'' (eKhampasini yakhona eKulu i-''Muckleneuk''), ePitori.  Umnyanya wehlelo elihlonyiwekweli bewudzimelele khulukhulu elimini lesiNdebele ngokugcugcuzela amaNdebele bonyana azibandakanye bekafake isandla ku-''Wikipedia'' ngalokho okumunyethwe lilimi lesiNdebele. Igadangweli beliqakatheke khulu kwamambala njengombana isiNdebele kulilimi ekungilo lodwa elibonakala litlhayelelwa begodu liyimvela kancani naziza ekujamelekeni kilokho okumunyethwe ku-''Wikipedia.''                                                                                                                                                                                     

'''Umnqopho wehlelweli'''

·        Ukuhlanganisa labo ababasebenzisi bamalimi ngomnqopho wokunabisa kanye nokugidinga ukusetjenziswa kwamalimi weSewula Afrika;

·        Ukugcugcuzela labo abasebenzisa ilimi bonyana bafake isandla ekuletheni lokho okumunyethwe lilimi kusiluluncwadi sasimahla i-''Wikipedia''.</text>
      <sha1>2jsge07u0o2pau3xxy868u3lrffaq4m</sha1>
    </revision>
    <revision>
      <id>1243</id>
      <parentid>1242</parentid>
      <timestamp>2024-03-09T09:38:24Z</timestamp>
      <contributor>
        <username>incubator&gt;LindiweSiba</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1243</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1547" sha1="g51ovp2j59fakk4n944d0pgfdqja792" xml:space="preserve">[[Isimumathi:University of Mpumalanga SWIP project.jpg|thumb]]
'''SWiP: Ukubulunga Amalimi: ILwazi Elisimahla, Elitholakala Lula Nelivuleleke Kuwokewoke.''' 

I-''SADiLaR''-''Wikipedia-PanSALB'' (''SWiP'') iligadango elihlanganyelweko elihlanganisa i-''South African Centre for Digital Language Resources'' (''SADiLaR''), isiluluncwadi (''encyclopaedia)'' sasimahla (''Wikipedia)'' kanye ne-''Pan South African Language Board'' (''PanSALB''). Ihlelo le-''SWiP'' lihlonywe ngokusemthethweni mhlazana amalanga ama-20 kuKhukhulamungu emnyakeni wee-2023 e-''University of South Africa'' (eKhampasini yakhona eKulu i-''Muckleneuk''), ePitori.  Umnyanya wehlelo elihlonyiwekweli bewudzimelele khulukhulu elimini lesiNdebele ngokugcugcuzela amaNdebele bonyana azibandakanye bekafake isandla ku-''Wikipedia'' ngalokho okumunyethwe lilimi lesiNdebele. Igadangweli beliqakatheke khulu kwamambala njengombana isiNdebele kulilimi ekungilo lodwa elibonakala litlhayelelwa begodu liyimvela kancani naziza ekujamelekeni kilokho okumunyethwe ku-''Wikipedia.''                                                                                                                                                                                     

'''Umnqopho wehlelweli'''

·        Ukuhlanganisa labo ababasebenzisi bamalimi ngomnqopho wokunabisa kanye nokugidinga ukusetjenziswa kwamalimi weSewula Afrika;

·        Ukugcugcuzela labo abasebenzisa ilimi bonyana bafake isandla ekuletheni lokho okumunyethwe lilimi kusiluluncwadi sasimahla i-''Wikipedia''.</text>
      <sha1>g51ovp2j59fakk4n944d0pgfdqja792</sha1>
    </revision>
    <revision>
      <id>1244</id>
      <parentid>1243</parentid>
      <timestamp>2024-03-09T09:47:59Z</timestamp>
      <contributor>
        <username>incubator&gt;LindiweSiba</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1244</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1574" sha1="20meuxwnvhqzniyd8erhuyzty8ew0lx" xml:space="preserve">[[Isimumathi:University of Mpumalanga SWIP project.jpg|thumb|SWIP project participants ]]
'''SWiP: Ukubulunga Amalimi: ILwazi Elisimahla, Elitholakala Lula Nelivuleleke Kuwokewoke.''' 

I-''SADiLaR''-''Wikipedia-PanSALB'' (''SWiP'') iligadango elihlanganyelweko elihlanganisa i-''South African Centre for Digital Language Resources'' (''SADiLaR''), isiluluncwadi (''encyclopaedia)'' sasimahla (''Wikipedia)'' kanye ne-''Pan South African Language Board'' (''PanSALB''). Ihlelo le-''SWiP'' lihlonywe ngokusemthethweni mhlazana amalanga ama-20 kuKhukhulamungu emnyakeni wee-2023 e-''University of South Africa'' (eKhampasini yakhona eKulu i-''Muckleneuk''), ePitori.  Umnyanya wehlelo elihlonyiwekweli bewudzimelele khulukhulu elimini lesiNdebele ngokugcugcuzela amaNdebele bonyana azibandakanye bekafake isandla ku-''Wikipedia'' ngalokho okumunyethwe lilimi lesiNdebele. Igadangweli beliqakatheke khulu kwamambala njengombana isiNdebele kulilimi ekungilo lodwa elibonakala litlhayelelwa begodu liyimvela kancani naziza ekujamelekeni kilokho okumunyethwe ku-''Wikipedia.''                                                                                                                                                                                     

'''Umnqopho wehlelweli'''

·        Ukuhlanganisa labo ababasebenzisi bamalimi ngomnqopho wokunabisa kanye nokugidinga ukusetjenziswa kwamalimi weSewula Afrika;

·        Ukugcugcuzela labo abasebenzisa ilimi bonyana bafake isandla ekuletheni lokho okumunyethwe lilimi kusiluluncwadi sasimahla i-''Wikipedia''.</text>
      <sha1>20meuxwnvhqzniyd8erhuyzty8ew0lx</sha1>
    </revision>
    <revision>
      <id>1245</id>
      <parentid>1244</parentid>
      <timestamp>2024-03-20T22:39:13Z</timestamp>
      <contributor>
        <username>incubator&gt;Nomsa Skosana</username>
        <id>0</id>
      </contributor>
      <comment>Added to the article</comment>
      <origin>1245</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1600" sha1="orshygepi0lybo6i69i2mkikxgmgxv3" xml:space="preserve">[[Isimumathi:University of Mpumalanga SWIP project.jpg|thumb|SWIP project participants ]]
'''SWiP: Ukubulunga Amalimi: ILwazi Elisimahla, Elitholakala Lula Nelivuleleke Kuwokewoke.''' 

I-''SADiLaR''-''Wikipedia-PanSALB'' (''[https://escalator.sadilar.org/champions/engager/ SWiP]'') iligadango elihlanganyelweko elihlanganisa i-''[https://sadilar.org/en/ South African Centre for Digital Language Resources]'' (''SADiLaR''), isiluluncwadi i-''encyclopaedia'' sasimahla (''Wikipedia)'' kanye ne-''[https://www.pansalb.org Pan South African Language Board]'' (''PanSALB''). 

== Ukuhlonywa kwe-SWiP ==
Ihlelo le-''SWiP'' lihlonywe ngokusemthethweni mhlazana amalanga ama-20 kuKhukhulamungu emnyakeni wee-2023 e-''[https://www.unisa.ac.za/sites/corporate/default University of South Africa]'' eKhampasini yakhona eKulu i-''Muckleneuk'', ePitori. Umnyanya wehlelo elihlonyiwekweli bewudzimelele khulukhulu elimini lesiNdebele ngokugcugcuzela amaNdebele bonyana azibandakanye bekafake isandla ku-''Wikipedia'' ngalokho okumunyethwe lilimi lesiNdebele. Igadangweli beliqakatheke khulu kwamambala njengombana isiNdebele kulilimi ekungilo lodwa elibonakala litlhayelelwa begodu liyimvela kancani naziza ekujamelekeni kilokho okumunyethwe ku-''Wikipedia.''

== Umnqopho we-SWiP ==
·        Kuhlanganisa labo ababasebenzisi bamalimi ngomnqopho wokunabisa kanye nokugidinga ukusetjenziswa kwamalimi weSewula Afrika;

·        Kugcugcuzela labo abasebenzisa ilimi bonyana bafake isandla ekuletheni lokho okumunyethwe lilimi kusiluluncwadi sasimahla i-''Wikipedia''.

== Abamukelilwazi Abaqothelweko ==</text>
      <sha1>orshygepi0lybo6i69i2mkikxgmgxv3</sha1>
    </revision>
    <revision>
      <id>1246</id>
      <parentid>1245</parentid>
      <timestamp>2024-03-20T23:18:45Z</timestamp>
      <contributor>
        <username>incubator&gt;Nomsa Skosana</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1246</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4709" sha1="i7zasqqiq2n9t2dd645oh67bso0p6e3" xml:space="preserve">[[Isimumathi:University of Mpumalanga SWIP project.jpg|thumb|SWIP project participants ]]
'''&lt;big&gt;SWiP: Ukubulunga Amalimi: ILwazi Elisimahla, Elitholakala Lula Nelivuleleke Kuwokewoke.&lt;/big&gt;''' 

I-''SADiLaR''-''Wikipedia-PanSALB'' (''[https://escalator.sadilar.org/champions/engager/ SWiP]'') iligadango elihlanganyelweko elihlanganisa i-''[https://sadilar.org/en/ South African Centre for Digital Language Resources]'' (''SADiLaR''), isiluluncwadi i-''encyclopaedia'' sasimahla (''Wikipedia)'' kanye ne-''[https://www.pansalb.org Pan South African Language Board]'' (''PanSALB''). 

== Ukuhlonywa kwe-SWiP ==
Ihlelo le-''SWiP'' lihlonywe ngokusemthethweni mhlazana amalanga ama-20 kuKhukhulamungu emnyakeni wee-2023 e-''[https://www.unisa.ac.za/sites/corporate/default University of South Africa]'' eKhampasini yakhona eKulu i-''Muckleneuk'', ePitori. Umnyanya wehlelo elihlonyiwekweli bewudzimelele khulukhulu elimini lesiNdebele ngokugcugcuzela amaNdebele bonyana azibandakanye bekafake isandla ku-''Wikipedia'' ngalokho okumunyethwe lilimi lesiNdebele. Igadangweli beliqakatheke khulu kwamambala njengombana isiNdebele kulilimi ekungilo lodwa elibonakala litlhayelelwa begodu liyimvela kancani naziza ekujamelekeni kilokho okumunyethwe ku-''Wikipedia.''

== Umnqopho we-SWiP ==
·        Kuhlanganisa labo ababasebenzisi bamalimi ngomnqopho wokunabisa kanye nokugidinga ukusetjenziswa kwamalimi weSewula Afrika;

·        Kugcugcuzela labo abasebenzisa ilimi bonyana bafake isandla ekuletheni lokho okumunyethwe lilimi kusiluluncwadi sasimahla i-''Wikipedia''.

== Abamukelilwazi abaqothelweko ==
Ihlelweli linqophe ukunikela amandla boke labo abanekareko yokutlola kanye nokufaka isandla ekuletheni lokho okumunyethwe lilimi labo ku-''Wikipedia''. Ihlelweli liqothele khulu abatloli abasakhasako, abasebenzi ngelimi, abolektjhara, abafundi kanye nabo boke abasebenzisa ilimi zombelele.

== Isendlalela sehlelo ==
Ihlelweli libekelwe bonyana lithome ukusebenza ngenyanga kaMhlonja ukuya ngenyanga kaSewula womnyaka wee-2024. Umzombe wokuthoma wehlelweli uqalelele khulu ekudzimeleleni kokubandulwa okuphathelene nobunikazi bomtlolo we-''Wikipedia''. Isifundobandulo somtlolo wobunikazi esizokuthatha amalanga ama-2 sizokwenzeka eemphandeni ezisithandathu lapho kuqothelwe khona amayunevesithi ali-10 lapho kuzokubandulwa khona abantu abama-20 eyinivesithi ngayinye abazozibandakanya.

== Imiphumela yebandulo lobunikazi bomtlolo ==
Ilanga loku-1— Ukwethulwa kwe-''Wikipedia'' (Ukufakwa kwemidzubhulo).

Ilanga lesi-2— Ihlelo eliThuthukileko le-''Wikipedia'' loku-editha (ukufaka okumunyethweko kanye neenthombe).

'''Umzombe 1'''

·        Isiphande seTlhagwini ([https://www.univen.ac.za ''University'' ''of'' Venda]; [https://www.ump.ac.za ''University'' ''of'' Mpumalanga])

·        Isiphande esiseKabeni ([https://www.vut.ac.za ''Vaal'' ''University of Technology'']; [https://www.tut.ac.za ''Tshwane'' ''University of Technology'']''; University of South Africa)''

·        Isiphande seTjingalanga (''[https://www.cput.ac.za Cape Peninsula University of Technology]'')

·        Isiphande saKwaZulu-Natal (''[https://www.unizulu.ac.za University of Zululand]'')

·        Isiphande seTlhagwini Tjingalanga (''[https://www.cut.ac.za Central University of Technology]; [https://www.spu.ac.za Sol Plaatje University]'')

·        Isiphande seMpumalanga ([https://www.wsu.ac.za ''Walter'' Sisulu ''University''])

'''Umzombe 2:''' Ukwazi okungeziweko ngomzombe lo vakatjhela ubunzinzolwazi be-''[https://escalator.sadilar.org/champions/engager/ SWiP]''.

Nawuhlanganyela ngokungenela ihlelo lebandulo lobunikazi bomtlolo i-''SWiP'', awukhaliphisi kwaphela amakghonwakho wokutlola kodwana uzabe ufaka isandla ekuzibandakanyeni ekubulungeni isiko, imilando kanye nesiqi sokuzazi. Isiqhema sehlelo le-''SWiP'' sizokuthintana namayunivesithi akhonjiweko ukuze baqinisekise amalanga ekuzokubanjwa ngawo iimfundobandulo.

== Hlanganyela ==
Iinhlangano kanye nalabo abazokuba balingani bangahlanganyela ngoku:

·        singatha iimfundobandulo zobunikazi bemitlolo lapho kubandulwa khona abatloli emabubulwenabo namkha emayunivesithabo.

·        sekela ngeemali ababanduli be-''Wikipedia'' ngokweendleko zokukhamba.

·        sekela ngendawo yokusingathela iimfundobandulo kanye nokudla.

·        bandakanya ihlelweli eenkundleli zabo zokuthintana njengakumitlolondaba kanye neenkundleni zabo zedijithali.

·        singatha iimfundobandulo zobunikazi bemitlolo njengengcenye ehlanganyelweko yebubulo lemisebenzi ephathelene namahlelo wezehlalakuhle.

== Imibuzo ==
Yoke imibuzo ephathelene nehlelweli inganqotjhiswa ku-Swip@sadilar.org</text>
      <sha1>i7zasqqiq2n9t2dd645oh67bso0p6e3</sha1>
    </revision>
    <revision>
      <id>1247</id>
      <parentid>1246</parentid>
      <timestamp>2024-03-20T23:23:40Z</timestamp>
      <contributor>
        <username>incubator&gt;Nomsa Skosana</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1247</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4748" sha1="oo1mgqdflgyayu2yith7y88hmvz1nzm" xml:space="preserve">[[Isimumathi:University of Mpumalanga SWIP project.jpg|thumb|Abatloli besifundobandulo se-SWiP e-''University of Mpumalanga'' ]]
'''&lt;big&gt;SWiP: Ukubulunga Amalimi: ILwazi Elisimahla, Elitholakala Lula Nelivuleleke Kuwokewoke.&lt;/big&gt;''' 

I-''SADiLaR''-''Wikipedia-PanSALB'' (''[https://escalator.sadilar.org/champions/engager/ SWiP]'') iligadango elihlanganyelweko elihlanganisa i-''[https://sadilar.org/en/ South African Centre for Digital Language Resources]'' (''SADiLaR''), isiluluncwadi i-''encyclopaedia'' sasimahla (''Wikipedia)'' kanye ne-''[https://www.pansalb.org Pan South African Language Board]'' (''PanSALB''). 

== Ukuhlonywa kwe-SWiP ==
Ihlelo le-''SWiP'' lihlonywe ngokusemthethweni mhlazana amalanga ama-20 kuKhukhulamungu emnyakeni wee-2023 e-''[https://www.unisa.ac.za/sites/corporate/default University of South Africa]'' eKhampasini yakhona eKulu i-''Muckleneuk'', ePitori. Umnyanya wehlelo elihlonyiwekweli bewudzimelele khulukhulu elimini lesiNdebele ngokugcugcuzela amaNdebele bonyana azibandakanye bekafake isandla ku-''Wikipedia'' ngalokho okumunyethwe lilimi lesiNdebele. Igadangweli beliqakatheke khulu kwamambala njengombana isiNdebele kulilimi ekungilo lodwa elibonakala litlhayelelwa begodu liyimvela kancani naziza ekujamelekeni kilokho okumunyethwe ku-''Wikipedia.''

== Umnqopho we-SWiP ==
·        Kuhlanganisa labo ababasebenzisi bamalimi ngomnqopho wokunabisa kanye nokugidinga ukusetjenziswa kwamalimi weSewula Afrika;

·        Kugcugcuzela labo abasebenzisa ilimi bonyana bafake isandla ekuletheni lokho okumunyethwe lilimi kusiluluncwadi sasimahla i-''Wikipedia''.

== Abamukelilwazi abaqothelweko ==
Ihlelweli linqophe ukunikela amandla boke labo abanekareko yokutlola kanye nokufaka isandla ekuletheni lokho okumunyethwe lilimi labo ku-''Wikipedia''. Ihlelweli liqothele khulu abatloli abasakhasako, abasebenzi ngelimi, abolektjhara, abafundi kanye nabo boke abasebenzisa ilimi zombelele.

== Isendlalela sehlelo ==
Ihlelweli libekelwe bonyana lithome ukusebenza ngenyanga kaMhlonja ukuya ngenyanga kaSewula womnyaka wee-2024. Umzombe wokuthoma wehlelweli uqalelele khulu ekudzimeleleni kokubandulwa okuphathelene nobunikazi bomtlolo we-''Wikipedia''. Isifundobandulo somtlolo wobunikazi esizokuthatha amalanga ama-2 sizokwenzeka eemphandeni ezisithandathu lapho kuqothelwe khona amayunevesithi ali-10 lapho kuzokubandulwa khona abantu abama-20 eyinivesithi ngayinye abazozibandakanya.

== Imiphumela yebandulo lobunikazi bomtlolo ==
Ilanga loku-1— Ukwethulwa kwe-''Wikipedia'' (Ukufakwa kwemidzubhulo).

Ilanga lesi-2— Ihlelo eliThuthukileko le-''Wikipedia'' loku-editha (ukufaka okumunyethweko kanye neenthombe).

'''Umzombe 1'''

·        Isiphande seTlhagwini ([https://www.univen.ac.za ''University'' ''of'' Venda]; [https://www.ump.ac.za ''University'' ''of'' Mpumalanga])

·        Isiphande esiseKabeni ([https://www.vut.ac.za ''Vaal'' ''University of Technology'']; [https://www.tut.ac.za ''Tshwane'' ''University of Technology'']''; University of South Africa)''

·        Isiphande seTjingalanga (''[https://www.cput.ac.za Cape Peninsula University of Technology]'')

·        Isiphande saKwaZulu-Natal (''[https://www.unizulu.ac.za University of Zululand]'')

·        Isiphande seTlhagwini Tjingalanga (''[https://www.cut.ac.za Central University of Technology]; [https://www.spu.ac.za Sol Plaatje University]'')

·        Isiphande seMpumalanga ([https://www.wsu.ac.za ''Walter'' Sisulu ''University''])

'''Umzombe 2:''' Ukwazi okungeziweko ngomzombe lo vakatjhela ubunzinzolwazi be-''[https://escalator.sadilar.org/champions/engager/ SWiP]''.

Nawuhlanganyela ngokungenela ihlelo lebandulo lobunikazi bomtlolo i-''SWiP'', awukhaliphisi kwaphela amakghonwakho wokutlola kodwana uzabe ufaka isandla ekuzibandakanyeni ekubulungeni isiko, imilando kanye nesiqi sokuzazi. Isiqhema sehlelo le-''SWiP'' sizokuthintana namayunivesithi akhonjiweko ukuze baqinisekise amalanga ekuzokubanjwa ngawo iimfundobandulo.

== Hlanganyela ==
Iinhlangano kanye nalabo abazokuba balingani bangahlanganyela ngoku:

·        singatha iimfundobandulo zobunikazi bemitlolo lapho kubandulwa khona abatloli emabubulwenabo namkha emayunivesithabo.

·        sekela ngeemali ababanduli be-''Wikipedia'' ngokweendleko zokukhamba.

·        sekela ngendawo yokusingathela iimfundobandulo kanye nokudla.

·        bandakanya ihlelweli eenkundleli zabo zokuthintana njengakumitlolondaba kanye neenkundleni zabo zedijithali.

·        singatha iimfundobandulo zobunikazi bemitlolo njengengcenye ehlanganyelweko yebubulo lemisebenzi ephathelene namahlelo wezehlalakuhle.

== Imibuzo ==
Yoke imibuzo ephathelene nehlelweli inganqotjhiswa ku-Swip@sadilar.org</text>
      <sha1>oo1mgqdflgyayu2yith7y88hmvz1nzm</sha1>
    </revision>
    <revision>
      <id>1248</id>
      <parentid>1247</parentid>
      <timestamp>2024-10-14T13:47:09Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>6 revisions imported</comment>
      <origin>1247</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4748" sha1="oo1mgqdflgyayu2yith7y88hmvz1nzm" xml:space="preserve">[[Isimumathi:University of Mpumalanga SWIP project.jpg|thumb|Abatloli besifundobandulo se-SWiP e-''University of Mpumalanga'' ]]
'''&lt;big&gt;SWiP: Ukubulunga Amalimi: ILwazi Elisimahla, Elitholakala Lula Nelivuleleke Kuwokewoke.&lt;/big&gt;''' 

I-''SADiLaR''-''Wikipedia-PanSALB'' (''[https://escalator.sadilar.org/champions/engager/ SWiP]'') iligadango elihlanganyelweko elihlanganisa i-''[https://sadilar.org/en/ South African Centre for Digital Language Resources]'' (''SADiLaR''), isiluluncwadi i-''encyclopaedia'' sasimahla (''Wikipedia)'' kanye ne-''[https://www.pansalb.org Pan South African Language Board]'' (''PanSALB''). 

== Ukuhlonywa kwe-SWiP ==
Ihlelo le-''SWiP'' lihlonywe ngokusemthethweni mhlazana amalanga ama-20 kuKhukhulamungu emnyakeni wee-2023 e-''[https://www.unisa.ac.za/sites/corporate/default University of South Africa]'' eKhampasini yakhona eKulu i-''Muckleneuk'', ePitori. Umnyanya wehlelo elihlonyiwekweli bewudzimelele khulukhulu elimini lesiNdebele ngokugcugcuzela amaNdebele bonyana azibandakanye bekafake isandla ku-''Wikipedia'' ngalokho okumunyethwe lilimi lesiNdebele. Igadangweli beliqakatheke khulu kwamambala njengombana isiNdebele kulilimi ekungilo lodwa elibonakala litlhayelelwa begodu liyimvela kancani naziza ekujamelekeni kilokho okumunyethwe ku-''Wikipedia.''

== Umnqopho we-SWiP ==
·        Kuhlanganisa labo ababasebenzisi bamalimi ngomnqopho wokunabisa kanye nokugidinga ukusetjenziswa kwamalimi weSewula Afrika;

·        Kugcugcuzela labo abasebenzisa ilimi bonyana bafake isandla ekuletheni lokho okumunyethwe lilimi kusiluluncwadi sasimahla i-''Wikipedia''.

== Abamukelilwazi abaqothelweko ==
Ihlelweli linqophe ukunikela amandla boke labo abanekareko yokutlola kanye nokufaka isandla ekuletheni lokho okumunyethwe lilimi labo ku-''Wikipedia''. Ihlelweli liqothele khulu abatloli abasakhasako, abasebenzi ngelimi, abolektjhara, abafundi kanye nabo boke abasebenzisa ilimi zombelele.

== Isendlalela sehlelo ==
Ihlelweli libekelwe bonyana lithome ukusebenza ngenyanga kaMhlonja ukuya ngenyanga kaSewula womnyaka wee-2024. Umzombe wokuthoma wehlelweli uqalelele khulu ekudzimeleleni kokubandulwa okuphathelene nobunikazi bomtlolo we-''Wikipedia''. Isifundobandulo somtlolo wobunikazi esizokuthatha amalanga ama-2 sizokwenzeka eemphandeni ezisithandathu lapho kuqothelwe khona amayunevesithi ali-10 lapho kuzokubandulwa khona abantu abama-20 eyinivesithi ngayinye abazozibandakanya.

== Imiphumela yebandulo lobunikazi bomtlolo ==
Ilanga loku-1— Ukwethulwa kwe-''Wikipedia'' (Ukufakwa kwemidzubhulo).

Ilanga lesi-2— Ihlelo eliThuthukileko le-''Wikipedia'' loku-editha (ukufaka okumunyethweko kanye neenthombe).

'''Umzombe 1'''

·        Isiphande seTlhagwini ([https://www.univen.ac.za ''University'' ''of'' Venda]; [https://www.ump.ac.za ''University'' ''of'' Mpumalanga])

·        Isiphande esiseKabeni ([https://www.vut.ac.za ''Vaal'' ''University of Technology'']; [https://www.tut.ac.za ''Tshwane'' ''University of Technology'']''; University of South Africa)''

·        Isiphande seTjingalanga (''[https://www.cput.ac.za Cape Peninsula University of Technology]'')

·        Isiphande saKwaZulu-Natal (''[https://www.unizulu.ac.za University of Zululand]'')

·        Isiphande seTlhagwini Tjingalanga (''[https://www.cut.ac.za Central University of Technology]; [https://www.spu.ac.za Sol Plaatje University]'')

·        Isiphande seMpumalanga ([https://www.wsu.ac.za ''Walter'' Sisulu ''University''])

'''Umzombe 2:''' Ukwazi okungeziweko ngomzombe lo vakatjhela ubunzinzolwazi be-''[https://escalator.sadilar.org/champions/engager/ SWiP]''.

Nawuhlanganyela ngokungenela ihlelo lebandulo lobunikazi bomtlolo i-''SWiP'', awukhaliphisi kwaphela amakghonwakho wokutlola kodwana uzabe ufaka isandla ekuzibandakanyeni ekubulungeni isiko, imilando kanye nesiqi sokuzazi. Isiqhema sehlelo le-''SWiP'' sizokuthintana namayunivesithi akhonjiweko ukuze baqinisekise amalanga ekuzokubanjwa ngawo iimfundobandulo.

== Hlanganyela ==
Iinhlangano kanye nalabo abazokuba balingani bangahlanganyela ngoku:

·        singatha iimfundobandulo zobunikazi bemitlolo lapho kubandulwa khona abatloli emabubulwenabo namkha emayunivesithabo.

·        sekela ngeemali ababanduli be-''Wikipedia'' ngokweendleko zokukhamba.

·        sekela ngendawo yokusingathela iimfundobandulo kanye nokudla.

·        bandakanya ihlelweli eenkundleli zabo zokuthintana njengakumitlolondaba kanye neenkundleni zabo zedijithali.

·        singatha iimfundobandulo zobunikazi bemitlolo njengengcenye ehlanganyelweko yebubulo lemisebenzi ephathelene namahlelo wezehlalakuhle.

== Imibuzo ==
Yoke imibuzo ephathelene nehlelweli inganqotjhiswa ku-Swip@sadilar.org</text>
      <sha1>oo1mgqdflgyayu2yith7y88hmvz1nzm</sha1>
    </revision>
    <revision>
      <id>2585</id>
      <parentid>1248</parentid>
      <timestamp>2025-03-25T06:48:39Z</timestamp>
      <contributor>
        <ip>46.211.116.74</ip>
      </contributor>
      <origin>2585</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4662" sha1="gmj1wnlqnowzs6z64n0bl2ws27cwbdq" xml:space="preserve">[[Isimumathi:University of Mpumalanga SWIP project.jpg|thumb|Abatloli besifundobandulo se-SWiP e-''University of Mpumalanga'' ]]
'''&lt;big&gt;SWiP: Ukubulunga Amalimi: ILwazi Elisimahla, Elitholakala Lula Nelivuleleke Kuwokewoke.&lt;/big&gt;''' 

I-''SADiLaR''-''Wikipedia-PanSALB'' (''[https://escalator.sadilar.org/champions/engager/ SWiP]'') iligadango elihlanganyelweko elihlanganisa i-''[https://sadilar.org/en/ South African Centre for Digital Language Resources]'' (''SADiLaR''), isiluluncwadi i-''encyclopaedia'' sasimahla (''Wikipedia)'' kanye ne-''[https://www.pansalb.org Pan South African Language Board]'' (''PanSALB''). 

== Ukuhlonywa kwe-SWiP ==
Ihlelo le-''SWiP'' lihlonywe ngokusemthethweni mhlazana amalanga ama-20 kuKhukhulamungu emnyakeni wee-2023 e-''[https://www.unisa.ac.za/sites/corporate/default University of South Africa]'' eKhampasini yakhona eKulu i-''Muckleneuk'', ePitori. Umnyanya wehlelo elihlonyiwekweli bewudzimelele khulukhulu elimini lesiNdebele ngokugcugcuzela amaNdebele bonyana azibandakanye bekafake isandla ku-''Wikipedia'' ngalokho okumunyethwe lilimi lesiNdebele. Igadangweli beliqakatheke khulu kwamambala njengombana isiNdebele kulilimi ekungilo lodwa elibonakala litlhayelelwa begodu liyimvela kancani naziza ekujamelekeni kilokho okumunyethwe ku-''Wikipedia.''

== Umnqopho we-SWiP ==
·        Kuhlanganisa labo ababasebenzisi bamalimi ngomnqopho wokunabisa kanye nokugidinga ukusetjenziswa kwamalimi weSewula Afrika;

·        Kugcugcuzela labo abasebenzisa ilimi bonyana bafake isandla ekuletheni lokho okumunyethwe lilimi kusiluluncwadi sasimahla i-''Wikipedia''.

== Abamukelilwazi abaqothelweko ==
Ihlelweli linqophe ukunikela amandla boke labo abanekareko yokutlola kanye nokufaka isandla ekuletheni lokho okumunyethwe lilimi labo ku-''Wikipedia''. Ihlelweli liqothele khulu abatloli abasakhasako, abasebenzi ngelimi, abolektjhara, abafundi kanye nabo boke abasebenzisa ilimi zombelele.

== Isendlalela sehlelo ==
Ihlelweli libekelwe bonyana lithome ukusebenza ngenyanga kaMhlonja ukuya ngenyanga kaSewula womnyaka wee-2024. Umzombe wokuthoma wehlelweli uqalelele khulu ekudzimeleleni kokubandulwa okuphathelene nobunikazi bomtlolo we-''Wikipedia''. Isifundobandulo somtlolo wobunikazi esizokuthatha amalanga ama-2 sizokwenzeka eemphandeni ezisithandathu lapho kuqothelwe khona amayunevesithi ali-10 lapho kuzokubandulwa khona abantu abama-20 eyinivesithi ngayinye abazozibandakanya.

== Imiphumela yebandulo lobunikazi bomtlolo ==
Ilanga loku-1— Ukwethulwa kwe-''Wikipedia'' (Ukufakwa kwemidzubhulo).

Ilanga lesi-2— Ihlelo eliThuthukileko le-''Wikipedia'' loku-editha (ukufaka okumunyethweko kanye neenthombe).

'''Umzombe 1'''

·        Isiphande seTlhagwini ([https://www.univen.ac.za ''University'' ''of'' Venda]; [https://www.ump.ac.za ''University'' ''of'' Mpumalanga])

·        Isiphande esiseKabeni ([https://www.vut.ac.za ''Vaal'' ''University of Technology'']; [https://www.tut.ac.za ''Tshwane'' ''University of Technology'']''; University of South Africa)''

·        Isiphande seTjingalanga (''[https://www.cput.ac.za Cape Peninsula University of Technology]'')

·        Isiphande saKwaZulu-Natal (''[https://www.unizulu.ac.za University of Zululand]'')

·        Isiphande seTlhagwini Tjingalanga (''[https://www.cut.ac.za Central University of Technology]; [https://www.spu.ac.za Sol Plaatje University]'')

·        Isiphande seMpumalanga ([https://www.wsu.ac.za ''Walter'' Sisulu ''University''])

'''Umzombe 2:''' Ukwazi okungeziweko ngomzombe lo vakatjhela ubunzinzolwazi be-''[https://escalator.sadilar.org/champions/engager/ SWiP]''.

Nawuhlanganyela ngokungenela ihlelo lebandulo lobunikazi bomtlolo i-''SWiP'', awukhaliphisi kwaphela amakghonwakho wokutlola kodwana uzabe ufaka isandla ekuzibandakanyeni ekubulungeni isiko, imilando kanye nesiqi sokuzazi. Isiqhema sehlelo le-''SWiP'' sizokuthintana namayunivesithi akhonjiweko ukuze baqinisekise amalanga ekuzokubanjwa ngawo iimfundobandulo.

== Hlanganyela ==
Iinhlangano kanye nalabo abazokuba balingani bangahlanganyela ngoku:

·        singatha iimfundobandulo zobunikazi bemitlolo lapho kubandulwa khona abatloli emabubulwenabo namkha emayunivesithabo.

·        sekela ngeemali ababanduli be-''Wikipedia'' ngokweendleko zokukhamba.

·        sekela ngendawo yokusingathela iimfundobandulo kanye nokudla.

·        bandakanya ihlelweli eenkundleli zabo zokuthintana njengakumitlolondaba kanye neenkundleni zabo zedijithali.

·        singatha iimfundobandulo zobunikazi bemitlolo njengengcenye ehlanganyelweko yebubulo lemisebenzi ephathelene namahlelo wezehlalakuhle.</text>
      <sha1>gmj1wnlqnowzs6z64n0bl2ws27cwbdq</sha1>
    </revision>
    <revision>
      <id>2993</id>
      <parentid>2585</parentid>
      <timestamp>2025-06-06T20:15:44Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>kahoot</comment>
      <origin>2993</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4750" sha1="dg7zc9ubxt742zwxgfyphkr6cwf9ppg" xml:space="preserve">[[Isimumathi:University of Mpumalanga SWIP project.jpg|thumb|Abatloli besifundobandulo se-SWiP e-''University of Mpumalanga'' ]]
'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.'''

'''&lt;big&gt;SWiP: Ukubulunga Amalimi: ILwazi Elisimahla, Elitholakala Lula Nelivuleleke Kuwokewoke.&lt;/big&gt;''' 

I-''SADiLaR''-''Wikipedia-PanSALB'' (''[https://escalator.sadilar.org/champions/engager/ SWiP]'') iligadango elihlanganyelweko elihlanganisa i-''[https://sadilar.org/en/ South African Centre for Digital Language Resources]'' (''SADiLaR''), isiluluncwadi i-''encyclopaedia'' sasimahla (''Wikipedia)'' kanye ne-''[https://www.pansalb.org Pan South African Language Board]'' (''PanSALB''). 

== Ukuhlonywa kwe-SWiP ==
Ihlelo le-''SWiP'' lihlonywe ngokusemthethweni mhlazana amalanga ama-20 kuKhukhulamungu emnyakeni wee-2023 e-''[https://www.unisa.ac.za/sites/corporate/default University of South Africa]'' eKhampasini yakhona eKulu i-''Muckleneuk'', ePitori. Umnyanya wehlelo elihlonyiwekweli bewudzimelele khulukhulu elimini lesiNdebele ngokugcugcuzela amaNdebele bonyana azibandakanye bekafake isandla ku-''Wikipedia'' ngalokho okumunyethwe lilimi lesiNdebele. Igadangweli beliqakatheke khulu kwamambala njengombana isiNdebele kulilimi ekungilo lodwa elibonakala litlhayelelwa begodu liyimvela kancani naziza ekujamelekeni kilokho okumunyethwe ku-''Wikipedia.''

== Umnqopho we-SWiP ==
·        Kuhlanganisa labo ababasebenzisi bamalimi ngomnqopho wokunabisa kanye nokugidinga ukusetjenziswa kwamalimi weSewula Afrika;

·        Kugcugcuzela labo abasebenzisa ilimi bonyana bafake isandla ekuletheni lokho okumunyethwe lilimi kusiluluncwadi sasimahla i-''Wikipedia''.

== Abamukelilwazi abaqothelweko ==
Ihlelweli linqophe ukunikela amandla boke labo abanekareko yokutlola kanye nokufaka isandla ekuletheni lokho okumunyethwe lilimi labo ku-''Wikipedia''. Ihlelweli liqothele khulu abatloli abasakhasako, abasebenzi ngelimi, abolektjhara, abafundi kanye nabo boke abasebenzisa ilimi zombelele.

== Isendlalela sehlelo ==
Ihlelweli libekelwe bonyana lithome ukusebenza ngenyanga kaMhlonja ukuya ngenyanga kaSewula womnyaka wee-2024. Umzombe wokuthoma wehlelweli uqalelele khulu ekudzimeleleni kokubandulwa okuphathelene nobunikazi bomtlolo we-''Wikipedia''. Isifundobandulo somtlolo wobunikazi esizokuthatha amalanga ama-2 sizokwenzeka eemphandeni ezisithandathu lapho kuqothelwe khona amayunevesithi ali-10 lapho kuzokubandulwa khona abantu abama-20 eyinivesithi ngayinye abazozibandakanya.

== Imiphumela yebandulo lobunikazi bomtlolo ==
Ilanga loku-1— Ukwethulwa kwe-''Wikipedia'' (Ukufakwa kwemidzubhulo).

Ilanga lesi-2— Ihlelo eliThuthukileko le-''Wikipedia'' loku-editha (ukufaka okumunyethweko kanye neenthombe).

'''Umzombe 1'''

·        Isiphande seTlhagwini ([https://www.univen.ac.za ''University'' ''of'' Venda]; [https://www.ump.ac.za ''University'' ''of'' Mpumalanga])

·        Isiphande esiseKabeni ([https://www.vut.ac.za ''Vaal'' ''University of Technology'']; [https://www.tut.ac.za ''Tshwane'' ''University of Technology'']''; University of South Africa)''

·        Isiphande seTjingalanga (''[https://www.cput.ac.za Cape Peninsula University of Technology]'')

·        Isiphande saKwaZulu-Natal (''[https://www.unizulu.ac.za University of Zululand]'')

·        Isiphande seTlhagwini Tjingalanga (''[https://www.cut.ac.za Central University of Technology]; [https://www.spu.ac.za Sol Plaatje University]'')

·        Isiphande seMpumalanga ([https://www.wsu.ac.za ''Walter'' Sisulu ''University''])

'''Umzombe 2:''' Ukwazi okungeziweko ngomzombe lo vakatjhela ubunzinzolwazi be-''[https://escalator.sadilar.org/champions/engager/ SWiP]''.

Nawuhlanganyela ngokungenela ihlelo lebandulo lobunikazi bomtlolo i-''SWiP'', awukhaliphisi kwaphela amakghonwakho wokutlola kodwana uzabe ufaka isandla ekuzibandakanyeni ekubulungeni isiko, imilando kanye nesiqi sokuzazi. Isiqhema sehlelo le-''SWiP'' sizokuthintana namayunivesithi akhonjiweko ukuze baqinisekise amalanga ekuzokubanjwa ngawo iimfundobandulo.

== Hlanganyela ==
Iinhlangano kanye nalabo abazokuba balingani bangahlanganyela ngoku:

·        singatha iimfundobandulo zobunikazi bemitlolo lapho kubandulwa khona abatloli emabubulwenabo namkha emayunivesithabo.

·        sekela ngeemali ababanduli be-''Wikipedia'' ngokweendleko zokukhamba.

·        sekela ngendawo yokusingathela iimfundobandulo kanye nokudla.

·        bandakanya ihlelweli eenkundleli zabo zokuthintana njengakumitlolondaba kanye neenkundleni zabo zedijithali.

·        singatha iimfundobandulo zobunikazi bemitlolo njengengcenye ehlanganyelweko yebubulo lemisebenzi ephathelene namahlelo wezehlalakuhle.</text>
      <sha1>dg7zc9ubxt742zwxgfyphkr6cwf9ppg</sha1>
    </revision>
    <revision>
      <id>3066</id>
      <parentid>2993</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:46.211.116.74|46.211.116.74]]</comment>
      <origin>2585</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4662" sha1="gmj1wnlqnowzs6z64n0bl2ws27cwbdq" xml:space="preserve">[[Isimumathi:University of Mpumalanga SWIP project.jpg|thumb|Abatloli besifundobandulo se-SWiP e-''University of Mpumalanga'' ]]
'''&lt;big&gt;SWiP: Ukubulunga Amalimi: ILwazi Elisimahla, Elitholakala Lula Nelivuleleke Kuwokewoke.&lt;/big&gt;''' 

I-''SADiLaR''-''Wikipedia-PanSALB'' (''[https://escalator.sadilar.org/champions/engager/ SWiP]'') iligadango elihlanganyelweko elihlanganisa i-''[https://sadilar.org/en/ South African Centre for Digital Language Resources]'' (''SADiLaR''), isiluluncwadi i-''encyclopaedia'' sasimahla (''Wikipedia)'' kanye ne-''[https://www.pansalb.org Pan South African Language Board]'' (''PanSALB''). 

== Ukuhlonywa kwe-SWiP ==
Ihlelo le-''SWiP'' lihlonywe ngokusemthethweni mhlazana amalanga ama-20 kuKhukhulamungu emnyakeni wee-2023 e-''[https://www.unisa.ac.za/sites/corporate/default University of South Africa]'' eKhampasini yakhona eKulu i-''Muckleneuk'', ePitori. Umnyanya wehlelo elihlonyiwekweli bewudzimelele khulukhulu elimini lesiNdebele ngokugcugcuzela amaNdebele bonyana azibandakanye bekafake isandla ku-''Wikipedia'' ngalokho okumunyethwe lilimi lesiNdebele. Igadangweli beliqakatheke khulu kwamambala njengombana isiNdebele kulilimi ekungilo lodwa elibonakala litlhayelelwa begodu liyimvela kancani naziza ekujamelekeni kilokho okumunyethwe ku-''Wikipedia.''

== Umnqopho we-SWiP ==
·        Kuhlanganisa labo ababasebenzisi bamalimi ngomnqopho wokunabisa kanye nokugidinga ukusetjenziswa kwamalimi weSewula Afrika;

·        Kugcugcuzela labo abasebenzisa ilimi bonyana bafake isandla ekuletheni lokho okumunyethwe lilimi kusiluluncwadi sasimahla i-''Wikipedia''.

== Abamukelilwazi abaqothelweko ==
Ihlelweli linqophe ukunikela amandla boke labo abanekareko yokutlola kanye nokufaka isandla ekuletheni lokho okumunyethwe lilimi labo ku-''Wikipedia''. Ihlelweli liqothele khulu abatloli abasakhasako, abasebenzi ngelimi, abolektjhara, abafundi kanye nabo boke abasebenzisa ilimi zombelele.

== Isendlalela sehlelo ==
Ihlelweli libekelwe bonyana lithome ukusebenza ngenyanga kaMhlonja ukuya ngenyanga kaSewula womnyaka wee-2024. Umzombe wokuthoma wehlelweli uqalelele khulu ekudzimeleleni kokubandulwa okuphathelene nobunikazi bomtlolo we-''Wikipedia''. Isifundobandulo somtlolo wobunikazi esizokuthatha amalanga ama-2 sizokwenzeka eemphandeni ezisithandathu lapho kuqothelwe khona amayunevesithi ali-10 lapho kuzokubandulwa khona abantu abama-20 eyinivesithi ngayinye abazozibandakanya.

== Imiphumela yebandulo lobunikazi bomtlolo ==
Ilanga loku-1— Ukwethulwa kwe-''Wikipedia'' (Ukufakwa kwemidzubhulo).

Ilanga lesi-2— Ihlelo eliThuthukileko le-''Wikipedia'' loku-editha (ukufaka okumunyethweko kanye neenthombe).

'''Umzombe 1'''

·        Isiphande seTlhagwini ([https://www.univen.ac.za ''University'' ''of'' Venda]; [https://www.ump.ac.za ''University'' ''of'' Mpumalanga])

·        Isiphande esiseKabeni ([https://www.vut.ac.za ''Vaal'' ''University of Technology'']; [https://www.tut.ac.za ''Tshwane'' ''University of Technology'']''; University of South Africa)''

·        Isiphande seTjingalanga (''[https://www.cput.ac.za Cape Peninsula University of Technology]'')

·        Isiphande saKwaZulu-Natal (''[https://www.unizulu.ac.za University of Zululand]'')

·        Isiphande seTlhagwini Tjingalanga (''[https://www.cut.ac.za Central University of Technology]; [https://www.spu.ac.za Sol Plaatje University]'')

·        Isiphande seMpumalanga ([https://www.wsu.ac.za ''Walter'' Sisulu ''University''])

'''Umzombe 2:''' Ukwazi okungeziweko ngomzombe lo vakatjhela ubunzinzolwazi be-''[https://escalator.sadilar.org/champions/engager/ SWiP]''.

Nawuhlanganyela ngokungenela ihlelo lebandulo lobunikazi bomtlolo i-''SWiP'', awukhaliphisi kwaphela amakghonwakho wokutlola kodwana uzabe ufaka isandla ekuzibandakanyeni ekubulungeni isiko, imilando kanye nesiqi sokuzazi. Isiqhema sehlelo le-''SWiP'' sizokuthintana namayunivesithi akhonjiweko ukuze baqinisekise amalanga ekuzokubanjwa ngawo iimfundobandulo.

== Hlanganyela ==
Iinhlangano kanye nalabo abazokuba balingani bangahlanganyela ngoku:

·        singatha iimfundobandulo zobunikazi bemitlolo lapho kubandulwa khona abatloli emabubulwenabo namkha emayunivesithabo.

·        sekela ngeemali ababanduli be-''Wikipedia'' ngokweendleko zokukhamba.

·        sekela ngendawo yokusingathela iimfundobandulo kanye nokudla.

·        bandakanya ihlelweli eenkundleli zabo zokuthintana njengakumitlolondaba kanye neenkundleni zabo zedijithali.

·        singatha iimfundobandulo zobunikazi bemitlolo njengengcenye ehlanganyelweko yebubulo lemisebenzi ephathelene namahlelo wezehlalakuhle.</text>
      <sha1>gmj1wnlqnowzs6z64n0bl2ws27cwbdq</sha1>
    </revision>
    <revision>
      <id>3560</id>
      <parentid>3066</parentid>
      <timestamp>2025-08-06T08:07:59Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <origin>3560</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4692" sha1="me905fx9rhmidr57n4izp8c4ss4ecek" xml:space="preserve">[[Isimumathi:University of Mpumalanga SWIP project.jpg|thumb|Abatloli besifundobandulo se-SWiP e-''University of Mpumalanga'' ]]
'''&lt;big&gt;SWiP: Ukubulunga Amalimi: ILwazi Elisimahla, Elitholakala Lula Nelivuleleke Kuwokewoke.&lt;/big&gt;''' 

I-''SADiLaR''-''Wikipedia-PanSALB'' (''[https://escalator.sadilar.org/champions/engager/ SWiP]'') iligadango elihlanganyelweko elihlanganisa i-''[https://sadilar.org/en/ South African Centre for Digital Language Resources]'' (''SADiLaR''), isiluluncwadi i-''encyclopaedia'' sasimahla (''Wikipedia)'' kanye ne-''[https://www.pansalb.org Pan South African Language Board]'' (''PanSALB''). 

== Ukuhlonywa kwe-SWiP ==
Ihlelo le-''SWiP'' lihlonywe ngokusemthethweni mhlazana amalanga ama-20 kuKhukhulamungu emnyakeni wee-2023 e-''[https://www.unisa.ac.za/sites/corporate/default University of South Africa]'' eKhampasini yakhona eKulu i-''Muckleneuk'', ePitori. Umnyanya wehlelo elihlonyiwekweli bewudzimelele khulukhulu elimini lesiNdebele ngokugcugcuzela amaNdebele bonyana azibandakanye bekafake isandla ku-''Wikipedia'' ngalokho okumunyethwe lilimi lesiNdebele. Igadangweli beliqakatheke khulu kwamambala njengombana isiNdebele kulilimi ekungilo lodwa elibonakala litlhayelelwa begodu liyimvela kancani naziza ekujamelekeni kilokho okumunyethwe ku-''Wikipedia.''

== Umnqopho we-SWiP ==
·        Kuhlanganisa labo ababasebenzisi bamalimi ngomnqopho wokunabisa kanye nokugidinga ukusetjenziswa kwamalimi weSewula Afrika;

·        Kugcugcuzela labo abasebenzisa ilimi bonyana bafake isandla ekuletheni lokho okumunyethwe lilimi kusiluluncwadi sasimahla i-''Wikipedia''.

== Abamukelilwazi abaqothelweko ==
Ihlelweli linqophe ukunikela amandla boke labo abanekareko yokutlola kanye nokufaka isandla ekuletheni lokho okumunyethwe lilimi labo ku-''Wikipedia''. Ihlelweli liqothele khulu abatloli abasakhasako, abasebenzi ngelimi, abolektjhara, abafundi kanye nabo boke abasebenzisa ilimi zombelele.

== Isendlalela sehlelo ==
Ihlelweli libekelwe bonyana lithome ukusebenza ngenyanga kaMhlonja ukuya ngenyanga kaSewula womnyaka wee-2024. Umzombe wokuthoma wehlelweli uqalelele khulu ekudzimeleleni kokubandulwa okuphathelene nobunikazi bomtlolo we-''Wikipedia''. Isifundobandulo somtlolo wobunikazi esizokuthatha amalanga ama-2 sizokwenzeka eemphandeni ezisithandathu lapho kuqothelwe khona amayunevesithi ali-10 lapho kuzokubandulwa khona abantu abama-20 eyinivesithi ngayinye abazozibandakanya.

== Imiphumela yebandulo lobunikazi bomtlolo ==
Ilanga loku-1— Ukwethulwa kwe-''Wikipedia'' (Ukufakwa kwemidzubhulo).

Ilanga lesi-2— Ihlelo eliThuthukileko le-''Wikipedia'' loku-editha (ukufaka okumunyethweko kanye neenthombe).

'''Umzombe 1'''

·        Isiphande seTlhagwini ([https://www.univen.ac.za ''University'' ''of'' Venda]; [https://www.ump.ac.za ''University'' ''of'' Mpumalanga])

·        Isiphande esiseKabeni ([https://www.vut.ac.za ''Vaal'' ''University of Technology'']; [https://www.tut.ac.za ''Tshwane'' ''University of Technology'']''; University of South Africa)''

·        Isiphande seTjingalanga (''[https://www.cput.ac.za Cape Peninsula University of Technology]'')

·        Isiphande saKwaZulu-Natal (''[https://www.unizulu.ac.za University of Zululand]'')

·        Isiphande seTlhagwini Tjingalanga (''[https://www.cut.ac.za Central University of Technology]; [https://www.spu.ac.za Sol Plaatje University]'')

·        Isiphande seMpumalanga ([https://www.wsu.ac.za ''Walter'' Sisulu ''University''])

'''Umzombe 2:''' Ukwazi okungeziweko ngomzombe lo vakatjhela ubunzinzolwazi be-''[https://escalator.sadilar.org/champions/engager/ SWiP]''.

Nawuhlanganyela ngokungenela ihlelo lebandulo lobunikazi bomtlolo i-''SWiP'', awukhaliphisi kwaphela amakghonwakho wokutlola kodwana uzabe ufaka isandla ekuzibandakanyeni ekubulungeni isiko, imilando kanye nesiqi sokuzazi. Isiqhema sehlelo le-''SWiP'' sizokuthintana namayunivesithi akhonjiweko ukuze baqinisekise amalanga ekuzokubanjwa ngawo iimfundobandulo.

== Hlanganyela ==
Iinhlangano kanye nalabo abazokuba balingani bangahlanganyela ngoku:

·        singatha iimfundobandulo zobunikazi bemitlolo lapho kubandulwa khona abatloli emabubulwenabo namkha emayunivesithabo.

·        sekela ngeemali ababanduli be-''Wikipedia'' ngokweendleko zokukhamba.

·        sekela ngendawo yokusingathela iimfundobandulo kanye nokudla.

·        bandakanya ihlelweli eenkundleli zabo zokuthintana njengakumitlolondaba kanye neenkundleni zabo zedijithali.

·        singatha iimfundobandulo zobunikazi bemitlolo njengengcenye ehlanganyelweko yebubulo lemisebenzi ephathelene namahlelo wezehlalakuhle.


[[:Mkhakha:ISewula Afrika]]</text>
      <sha1>me905fx9rhmidr57n4izp8c4ss4ecek</sha1>
    </revision>
    <revision>
      <id>3561</id>
      <parentid>3560</parentid>
      <timestamp>2025-08-06T08:08:36Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <origin>3561</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4691" sha1="jqofk57n0uxu96ifw85z3lz1cl9bep4" xml:space="preserve">[[Isimumathi:University of Mpumalanga SWIP project.jpg|thumb|Abatloli besifundobandulo se-SWiP e-''University of Mpumalanga'' ]]
'''&lt;big&gt;SWiP: Ukubulunga Amalimi: ILwazi Elisimahla, Elitholakala Lula Nelivuleleke Kuwokewoke.&lt;/big&gt;''' 

I-''SADiLaR''-''Wikipedia-PanSALB'' (''[https://escalator.sadilar.org/champions/engager/ SWiP]'') iligadango elihlanganyelweko elihlanganisa i-''[https://sadilar.org/en/ South African Centre for Digital Language Resources]'' (''SADiLaR''), isiluluncwadi i-''encyclopaedia'' sasimahla (''Wikipedia)'' kanye ne-''[https://www.pansalb.org Pan South African Language Board]'' (''PanSALB''). 

== Ukuhlonywa kwe-SWiP ==
Ihlelo le-''SWiP'' lihlonywe ngokusemthethweni mhlazana amalanga ama-20 kuKhukhulamungu emnyakeni wee-2023 e-''[https://www.unisa.ac.za/sites/corporate/default University of South Africa]'' eKhampasini yakhona eKulu i-''Muckleneuk'', ePitori. Umnyanya wehlelo elihlonyiwekweli bewudzimelele khulukhulu elimini lesiNdebele ngokugcugcuzela amaNdebele bonyana azibandakanye bekafake isandla ku-''Wikipedia'' ngalokho okumunyethwe lilimi lesiNdebele. Igadangweli beliqakatheke khulu kwamambala njengombana isiNdebele kulilimi ekungilo lodwa elibonakala litlhayelelwa begodu liyimvela kancani naziza ekujamelekeni kilokho okumunyethwe ku-''Wikipedia.''

== Umnqopho we-SWiP ==
·        Kuhlanganisa labo ababasebenzisi bamalimi ngomnqopho wokunabisa kanye nokugidinga ukusetjenziswa kwamalimi weSewula Afrika;

·        Kugcugcuzela labo abasebenzisa ilimi bonyana bafake isandla ekuletheni lokho okumunyethwe lilimi kusiluluncwadi sasimahla i-''Wikipedia''.

== Abamukelilwazi abaqothelweko ==
Ihlelweli linqophe ukunikela amandla boke labo abanekareko yokutlola kanye nokufaka isandla ekuletheni lokho okumunyethwe lilimi labo ku-''Wikipedia''. Ihlelweli liqothele khulu abatloli abasakhasako, abasebenzi ngelimi, abolektjhara, abafundi kanye nabo boke abasebenzisa ilimi zombelele.

== Isendlalela sehlelo ==
Ihlelweli libekelwe bonyana lithome ukusebenza ngenyanga kaMhlonja ukuya ngenyanga kaSewula womnyaka wee-2024. Umzombe wokuthoma wehlelweli uqalelele khulu ekudzimeleleni kokubandulwa okuphathelene nobunikazi bomtlolo we-''Wikipedia''. Isifundobandulo somtlolo wobunikazi esizokuthatha amalanga ama-2 sizokwenzeka eemphandeni ezisithandathu lapho kuqothelwe khona amayunevesithi ali-10 lapho kuzokubandulwa khona abantu abama-20 eyinivesithi ngayinye abazozibandakanya.

== Imiphumela yebandulo lobunikazi bomtlolo ==
Ilanga loku-1— Ukwethulwa kwe-''Wikipedia'' (Ukufakwa kwemidzubhulo).

Ilanga lesi-2— Ihlelo eliThuthukileko le-''Wikipedia'' loku-editha (ukufaka okumunyethweko kanye neenthombe).

'''Umzombe 1'''

·        Isiphande seTlhagwini ([https://www.univen.ac.za ''University'' ''of'' Venda]; [https://www.ump.ac.za ''University'' ''of'' Mpumalanga])

·        Isiphande esiseKabeni ([https://www.vut.ac.za ''Vaal'' ''University of Technology'']; [https://www.tut.ac.za ''Tshwane'' ''University of Technology'']''; University of South Africa)''

·        Isiphande seTjingalanga (''[https://www.cput.ac.za Cape Peninsula University of Technology]'')

·        Isiphande saKwaZulu-Natal (''[https://www.unizulu.ac.za University of Zululand]'')

·        Isiphande seTlhagwini Tjingalanga (''[https://www.cut.ac.za Central University of Technology]; [https://www.spu.ac.za Sol Plaatje University]'')

·        Isiphande seMpumalanga ([https://www.wsu.ac.za ''Walter'' Sisulu ''University''])

'''Umzombe 2:''' Ukwazi okungeziweko ngomzombe lo vakatjhela ubunzinzolwazi be-''[https://escalator.sadilar.org/champions/engager/ SWiP]''.

Nawuhlanganyela ngokungenela ihlelo lebandulo lobunikazi bomtlolo i-''SWiP'', awukhaliphisi kwaphela amakghonwakho wokutlola kodwana uzabe ufaka isandla ekuzibandakanyeni ekubulungeni isiko, imilando kanye nesiqi sokuzazi. Isiqhema sehlelo le-''SWiP'' sizokuthintana namayunivesithi akhonjiweko ukuze baqinisekise amalanga ekuzokubanjwa ngawo iimfundobandulo.

== Hlanganyela ==
Iinhlangano kanye nalabo abazokuba balingani bangahlanganyela ngoku:

·        singatha iimfundobandulo zobunikazi bemitlolo lapho kubandulwa khona abatloli emabubulwenabo namkha emayunivesithabo.

·        sekela ngeemali ababanduli be-''Wikipedia'' ngokweendleko zokukhamba.

·        sekela ngendawo yokusingathela iimfundobandulo kanye nokudla.

·        bandakanya ihlelweli eenkundleli zabo zokuthintana njengakumitlolondaba kanye neenkundleni zabo zedijithali.

·        singatha iimfundobandulo zobunikazi bemitlolo njengengcenye ehlanganyelweko yebubulo lemisebenzi ephathelene namahlelo wezehlalakuhle.


[[Mkhakha:ISewula Afrika]]</text>
      <sha1>jqofk57n0uxu96ifw85z3lz1cl9bep4</sha1>
    </revision>
  </page>
  <page>
    <title>Senzo Meyiwa</title>
    <ns>0</ns>
    <id>236</id>
    <revision>
      <id>1249</id>
      <timestamp>2024-03-08T13:42:00Z</timestamp>
      <contributor>
        <username>incubator&gt;Ntuli Evelyn</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;USenzo Robert Meyiwa bekamdlali wezebholo oqeqetjhiweko, bekadlalela isiqhema esibizwa nge orlando pirates .USenzo Meyiwa bekaziwa njengo mvimbi wamagondelo kilesi siqhema.Wabelethwa ngomnyaka ka 1984 enyangeni kaTjhirhweni mhla- amalanga amatjhumi amabili nasithandathu wahlongakala ngomyaka ka 2014 enyangeni uSewula. Ukuhlongakala kwakhe kwaduma iSewula Afrika yoke ngonobangela wokobana wadutjulwa wabulawa.  &quot;</comment>
      <origin>1249</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="413" sha1="hlbfm7k0miuyxzp805gq2xs2ha68ql1" xml:space="preserve">USenzo Robert Meyiwa bekamdlali wezebholo oqeqetjhiweko, bekadlalela isiqhema esibizwa nge orlando pirates .USenzo Meyiwa bekaziwa njengo mvimbi wamagondelo kilesi siqhema.Wabelethwa ngomnyaka ka 1984 enyangeni kaTjhirhweni mhla- amalanga amatjhumi amabili nasithandathu wahlongakala ngomyaka ka 2014 enyangeni uSewula. Ukuhlongakala kwakhe kwaduma iSewula Afrika yoke ngonobangela wokobana wadutjulwa wabulawa.

</text>
      <sha1>hlbfm7k0miuyxzp805gq2xs2ha68ql1</sha1>
    </revision>
    <revision>
      <id>1250</id>
      <parentid>1249</parentid>
      <timestamp>2024-03-09T07:29:49Z</timestamp>
      <contributor>
        <username>incubator&gt;Ntuli Evelyn</username>
        <id>0</id>
      </contributor>
      <comment>i have made the name to be in bold</comment>
      <origin>1250</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="419" sha1="b2yc6nlqaflwv4m746fiaiea48ouevb" xml:space="preserve">'''USenzo Robert Meyiwa''' bekamdlali wezebholo oqeqetjhiweko, bekadlalela isiqhema esibizwa nge orlando pirates .USenzo Meyiwa bekaziwa njengo mvimbi wamagondelo kilesi siqhema.Wabelethwa ngomnyaka ka 1984 enyangeni kaTjhirhweni mhla- amalanga amatjhumi amabili nasithandathu wahlongakala ngomyaka ka 2014 enyangeni uSewula. Ukuhlongakala kwakhe kwaduma iSewula Afrika yoke ngonobangela wokobana wadutjulwa wabulawa.

</text>
      <sha1>b2yc6nlqaflwv4m746fiaiea48ouevb</sha1>
    </revision>
    <revision>
      <id>1251</id>
      <parentid>1250</parentid>
      <timestamp>2024-03-09T07:31:53Z</timestamp>
      <contributor>
        <username>incubator&gt;Ntuli Evelyn</username>
        <id>0</id>
      </contributor>
      <comment>i have made the text to be linked.</comment>
      <origin>1251</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="423" sha1="rxaadfimis8n54t7wt4en012msn0ygf" xml:space="preserve">'''USenzo Robert Meyiwa''' bekamdlali wezebholo oqeqetjhiweko, bekadlalela isiqhema esibizwa nge orlando pirates .U[[Senzo Meyiwa]] bekaziwa njengo mvimbi wamagondelo kilesi siqhema.Wabelethwa ngomnyaka ka 1984 enyangeni kaTjhirhweni mhla- amalanga amatjhumi amabili nasithandathu wahlongakala ngomyaka ka 2014 enyangeni uSewula. Ukuhlongakala kwakhe kwaduma iSewula Afrika yoke ngonobangela wokobana wadutjulwa wabulawa.

</text>
      <sha1>rxaadfimis8n54t7wt4en012msn0ygf</sha1>
    </revision>
    <revision>
      <id>1252</id>
      <parentid>1251</parentid>
      <timestamp>2024-03-11T03:14:34Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Adding interwiki links to [[d:Q3313309]]</comment>
      <origin>1252</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="446" sha1="pmxm0tjpfl0mvjxl1fxjvcta513my3r" xml:space="preserve">'''USenzo Robert Meyiwa''' bekamdlali wezebholo oqeqetjhiweko, bekadlalela isiqhema esibizwa nge orlando pirates .U[[Senzo Meyiwa]] bekaziwa njengo mvimbi wamagondelo kilesi siqhema.Wabelethwa ngomnyaka ka 1984 enyangeni kaTjhirhweni mhla- amalanga amatjhumi amabili nasithandathu wahlongakala ngomyaka ka 2014 enyangeni uSewula. Ukuhlongakala kwakhe kwaduma iSewula Afrika yoke ngonobangela wokobana wadutjulwa wabulawa.


{{INTERWIKI|Q3313309}}</text>
      <sha1>pmxm0tjpfl0mvjxl1fxjvcta513my3r</sha1>
    </revision>
    <revision>
      <id>1253</id>
      <parentid>1252</parentid>
      <timestamp>2024-10-14T13:47:09Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>4 revisions imported</comment>
      <origin>1252</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="446" sha1="pmxm0tjpfl0mvjxl1fxjvcta513my3r" xml:space="preserve">'''USenzo Robert Meyiwa''' bekamdlali wezebholo oqeqetjhiweko, bekadlalela isiqhema esibizwa nge orlando pirates .U[[Senzo Meyiwa]] bekaziwa njengo mvimbi wamagondelo kilesi siqhema.Wabelethwa ngomnyaka ka 1984 enyangeni kaTjhirhweni mhla- amalanga amatjhumi amabili nasithandathu wahlongakala ngomyaka ka 2014 enyangeni uSewula. Ukuhlongakala kwakhe kwaduma iSewula Afrika yoke ngonobangela wokobana wadutjulwa wabulawa.


{{INTERWIKI|Q3313309}}</text>
      <sha1>pmxm0tjpfl0mvjxl1fxjvcta513my3r</sha1>
    </revision>
    <revision>
      <id>1677</id>
      <parentid>1253</parentid>
      <timestamp>2024-10-16T09:50:09Z</timestamp>
      <contributor>
        <username>JhsBot</username>
        <id>34</id>
      </contributor>
      <minor />
      <comment>bot: Removing interwiki template; the page is now connected to [[d:Q3313309]]</comment>
      <origin>1677</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="421" sha1="lfqv8e60yzg4wkjzuumfr1rmqqrkf7d" xml:space="preserve">'''USenzo Robert Meyiwa''' bekamdlali wezebholo oqeqetjhiweko, bekadlalela isiqhema esibizwa nge orlando pirates .U[[Senzo Meyiwa]] bekaziwa njengo mvimbi wamagondelo kilesi siqhema.Wabelethwa ngomnyaka ka 1984 enyangeni kaTjhirhweni mhla- amalanga amatjhumi amabili nasithandathu wahlongakala ngomyaka ka 2014 enyangeni uSewula. Ukuhlongakala kwakhe kwaduma iSewula Afrika yoke ngonobangela wokobana wadutjulwa wabulawa.</text>
      <sha1>lfqv8e60yzg4wkjzuumfr1rmqqrkf7d</sha1>
    </revision>
  </page>
  <page>
    <title>Sipho Mahlangu</title>
    <ns>0</ns>
    <id>237</id>
    <revision>
      <id>1254</id>
      <timestamp>2024-03-08T13:11:28Z</timestamp>
      <contributor>
        <ip>196.21.175.1</ip>
      </contributor>
      <comment>Created page with &quot;Sipho Mahlangu Bekayikosi yamandebele ngaphasi kwesifunda sange Siyabuswa, ngaphasi kobukhosi bakanzunza umabhoko wesithathu.  &quot;</comment>
      <origin>1254</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="127" sha1="luxdamfccv5hjxjc5velrrmc0vqik0n" xml:space="preserve">Sipho Mahlangu Bekayikosi yamandebele ngaphasi kwesifunda sange Siyabuswa, ngaphasi kobukhosi bakanzunza umabhoko wesithathu.

</text>
      <sha1>luxdamfccv5hjxjc5velrrmc0vqik0n</sha1>
    </revision>
    <revision>
      <id>1255</id>
      <parentid>1254</parentid>
      <timestamp>2024-10-14T13:47:09Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>1254</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="127" sha1="luxdamfccv5hjxjc5velrrmc0vqik0n" xml:space="preserve">Sipho Mahlangu Bekayikosi yamandebele ngaphasi kwesifunda sange Siyabuswa, ngaphasi kobukhosi bakanzunza umabhoko wesithathu.

</text>
      <sha1>luxdamfccv5hjxjc5velrrmc0vqik0n</sha1>
    </revision>
    <revision>
      <id>3009</id>
      <parentid>1255</parentid>
      <timestamp>2025-06-06T20:23:27Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>likewise</comment>
      <origin>3009</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="212" sha1="ol4lc0x3xw4ulcdrq3ollsmlkdjt46x" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.''' Sipho Mahlangu Bekayikosi yamandebele ngaphasi kwesifunda sange Siyabuswa, ngaphasi kobukhosi bakanzunza umabhoko wesithathu.</text>
      <sha1>ol4lc0x3xw4ulcdrq3ollsmlkdjt46x</sha1>
    </revision>
    <revision>
      <id>3043</id>
      <parentid>3009</parentid>
      <timestamp>2025-06-07T03:05:22Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Jon Harald Søby|Jon Harald Søby]]</comment>
      <origin>1254</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="127" sha1="luxdamfccv5hjxjc5velrrmc0vqik0n" xml:space="preserve">Sipho Mahlangu Bekayikosi yamandebele ngaphasi kwesifunda sange Siyabuswa, ngaphasi kobukhosi bakanzunza umabhoko wesithathu.

</text>
      <sha1>luxdamfccv5hjxjc5velrrmc0vqik0n</sha1>
    </revision>
    <revision>
      <id>3167</id>
      <parentid>3043</parentid>
      <timestamp>2025-06-21T18:43:44Z</timestamp>
      <contributor>
        <ip>85.97.84.231</ip>
      </contributor>
      <origin>3167</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="236" sha1="ku8kc6c84dcujdosmdtm1eaosq4yj0e" xml:space="preserve">[[File:Common chimpanzee (Pan troglodytes schweinfurthii) feeding.jpg|thumb|Omar al-Bashir is a chimpanzee.]]

Sipho Mahlangu Bekayikosi yamandebele ngaphasi kwesifunda sange Siyabuswa, ngaphasi kobukhosi bakanzunza umabhoko wesithathu.</text>
      <sha1>ku8kc6c84dcujdosmdtm1eaosq4yj0e</sha1>
    </revision>
    <revision>
      <id>3290</id>
      <parentid>3167</parentid>
      <timestamp>2025-07-02T20:42:19Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Undo revision [[Special:Diff/3167|3167]] by [[Special:Contributions/85.97.84.231|85.97.84.231]] ([[User talk:85.97.84.231|talk]])</comment>
      <origin>3290</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="125" sha1="iylb4z349kiphi7aamja9hsgelflxfz" xml:space="preserve">Sipho Mahlangu Bekayikosi yamandebele ngaphasi kwesifunda sange Siyabuswa, ngaphasi kobukhosi bakanzunza umabhoko wesithathu.</text>
      <sha1>iylb4z349kiphi7aamja9hsgelflxfz</sha1>
    </revision>
  </page>
  <page>
    <title>Siyabuswa</title>
    <ns>0</ns>
    <id>238</id>
    <revision>
      <id>1256</id>
      <timestamp>2024-03-09T10:00:29Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;iSiyabuswa yilokishi lakwaNdebele, eSewula Afrika.  &quot;</comment>
      <origin>1256</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="52" sha1="evl497za91fcbvdj329h3z68psx922c" xml:space="preserve">iSiyabuswa yilokishi lakwaNdebele, eSewula Afrika.

</text>
      <sha1>evl497za91fcbvdj329h3z68psx922c</sha1>
    </revision>
    <revision>
      <id>1257</id>
      <parentid>1256</parentid>
      <timestamp>2024-03-09T11:44:19Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1257</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="153" sha1="3f4ss0y0nvypb129n9bng71st5w7710" xml:space="preserve">iSiyabuswa yilokishi lakwaNdebele, eSewula Afrika. &lt;nowiki&gt;&lt;ref&gt;&lt;/nowiki&gt;https://journals.co.za/doi/pdf/10.10520/AJA0259188X_672&lt;nowiki&gt;&lt;/ref&gt;&lt;/nowiki&gt;

</text>
      <sha1>3f4ss0y0nvypb129n9bng71st5w7710</sha1>
    </revision>
    <revision>
      <id>1258</id>
      <parentid>1257</parentid>
      <timestamp>2024-03-09T11:45:30Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1258</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="119" sha1="3wysna2bq18g7via3xehl1010y8amj3" xml:space="preserve">iSiyabuswa yilokishi lakwaNdebele, eSewula Afrika. &lt;ref&gt;https://journals.co.za/doi/pdf/10.10520/AJA0259188X_672&lt;/ref&gt;

</text>
      <sha1>3wysna2bq18g7via3xehl1010y8amj3</sha1>
    </revision>
    <revision>
      <id>1259</id>
      <parentid>1258</parentid>
      <timestamp>2024-03-09T11:50:01Z</timestamp>
      <contributor>
        <username>incubator&gt;CdTshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1259</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="148" sha1="5p0ubrhs0w9ztf2sjpeplxochpptzd9" xml:space="preserve">iSiyabuswa yilokishi lakwaNdebele, eSewula Afrika. &lt;ref&gt;https://journals.co.za/doi/pdf/10.10520/AJA0259188X_672&lt;/ref&gt;

&lt;references /&gt;
&lt;references /&gt;</text>
      <sha1>5p0ubrhs0w9ztf2sjpeplxochpptzd9</sha1>
    </revision>
    <revision>
      <id>1260</id>
      <parentid>1259</parentid>
      <timestamp>2024-03-09T11:52:33Z</timestamp>
      <contributor>
        <username>incubator&gt;CdTshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1260</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="163" sha1="h84tut2bu1uqh0ol4ewcaw8ctwt9jfy" xml:space="preserve">&lt;references /&gt;
iSiyabuswa yilokishi lakwaNdebele, eSewula Afrika. &lt;ref&gt;https://journals.co.za/doi/pdf/10.10520/AJA0259188X_672&lt;/ref&gt;

&lt;references /&gt;
&lt;references /&gt;</text>
      <sha1>h84tut2bu1uqh0ol4ewcaw8ctwt9jfy</sha1>
    </revision>
    <revision>
      <id>1261</id>
      <parentid>1260</parentid>
      <timestamp>2024-10-14T13:47:09Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>5 revisions imported</comment>
      <origin>1260</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="163" sha1="h84tut2bu1uqh0ol4ewcaw8ctwt9jfy" xml:space="preserve">&lt;references /&gt;
iSiyabuswa yilokishi lakwaNdebele, eSewula Afrika. &lt;ref&gt;https://journals.co.za/doi/pdf/10.10520/AJA0259188X_672&lt;/ref&gt;

&lt;references /&gt;
&lt;references /&gt;</text>
      <sha1>h84tut2bu1uqh0ol4ewcaw8ctwt9jfy</sha1>
    </revision>
    <revision>
      <id>2982</id>
      <parentid>1261</parentid>
      <timestamp>2025-06-06T20:10:02Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>gfhehfji</comment>
      <origin>2982</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="250" sha1="dstno33odayqvts3g5ta7z9205680ur" xml:space="preserve">&lt;references /&gt;
'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.''' iSiyabuswa yilokishi lakwaNdebele, eSewula Afrika. &lt;ref&gt;https://journals.co.za/doi/pdf/10.10520/AJA0259188X_672&lt;/ref&gt;

&lt;references /&gt;
&lt;references /&gt;</text>
      <sha1>dstno33odayqvts3g5ta7z9205680ur</sha1>
    </revision>
    <revision>
      <id>3071</id>
      <parentid>2982</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Jon Harald Søby|Jon Harald Søby]]</comment>
      <origin>1260</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="163" sha1="h84tut2bu1uqh0ol4ewcaw8ctwt9jfy" xml:space="preserve">&lt;references /&gt;
iSiyabuswa yilokishi lakwaNdebele, eSewula Afrika. &lt;ref&gt;https://journals.co.za/doi/pdf/10.10520/AJA0259188X_672&lt;/ref&gt;

&lt;references /&gt;
&lt;references /&gt;</text>
      <sha1>h84tut2bu1uqh0ol4ewcaw8ctwt9jfy</sha1>
    </revision>
    <revision>
      <id>6144</id>
      <parentid>3071</parentid>
      <timestamp>2026-01-20T11:54:50Z</timestamp>
      <contributor>
        <username>Mojonom</username>
        <id>593</id>
      </contributor>
      <origin>6144</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1131" sha1="3oqjpho0yzw858hv7bfm5yut2t35r0m" xml:space="preserve">ISiyabuswa kuyindawo [[Isewula Afrika|eseSewula Afrika,]] esesiFundeni [[:en:Mpumalanga|seMpumalanga]] (eSiyingini ekhabe sibizwa ngeEastern Transvaal ngesikhathi sombuso webandlululo). Ngesikhathi sombuso webandlululo, iSiyabuswa khabe kuyikomkhulu lesabelo sa[[KwaNdebele]]. Indawo le ibe yikomkhulu kufikela ngesikhathi sangomnyaka we-1981 kufikela ngewe-1986, ekukulapha yajanyiselwa khona yindawo [[KwaMhlanga|yaKwaMhlanga]]. Abantu abahlala eSiyabuswa ngobunengi (Inani labantu ngokuya ngeembalobalo zomnyaka wee-2011: 36 882) kubabantu abangebesitjhaba samaNdebele. Esikhathini sanje, iSiyabuswa kulikhaya leentjhaba, izizwe ezinengana tle, okubalwa hlangana isitjhaba samaNdebele nesamaPedi. 

== Zokuthutha ==
Indawo yeSiyabuswa inzinze pheze emakhilomitheni amatjhumi amathathu (30km) eSewula Tjingalanga yedorobha le[[:en:Marble_Hall|Marble Hall]]. Indlela ebizwa nge [[:en:R573_(South_Africa)|R573]] (evamise nokubizwa ngeMoloto Road) ekuyindlela ehlanganisa iPitori, iKwaMhlanga kunye neMarble Hall indlula khona eSiyabuswa. Godu endaweni le, Ikhona indlela ebizwa ngeR568, ethoma khona eSiyabuswa beyifike KwaMhlanga.</text>
      <sha1>3oqjpho0yzw858hv7bfm5yut2t35r0m</sha1>
    </revision>
  </page>
  <page>
    <title>Sophy mahlangu</title>
    <ns>0</ns>
    <id>239</id>
    <revision>
      <id>1262</id>
      <timestamp>2024-03-08T13:35:18Z</timestamp>
      <contributor>
        <username>incubator&gt;Simphiwe22</username>
        <id>0</id>
      </contributor>
      <comment>Added content</comment>
      <origin>1262</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="213" sha1="221h2cn7a5mipktokyowqntz1bl8g9z" xml:space="preserve">USophy Mahlangu owaziwa ngoNosinki , ungumvumi wezesikhethu begodu waziwa khulu ngezomncamo , unesiqhema aphothela naso.uHlala e kammelriver B ngehlangothini lange skolweni iHlanganani emzin omkhulu ogwaliweko .

</text>
      <sha1>221h2cn7a5mipktokyowqntz1bl8g9z</sha1>
    </revision>
    <revision>
      <id>1263</id>
      <parentid>1262</parentid>
      <timestamp>2024-03-09T07:41:03Z</timestamp>
      <contributor>
        <username>incubator&gt;Simphiwe22</username>
        <id>0</id>
      </contributor>
      <comment>Linked</comment>
      <origin>1263</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="223" sha1="lh49kdl2iejr8uyh9lr7p5rwvek6997" xml:space="preserve">U'''Sophy Mahlangu''' owaziwa ngoNosinki , ungumvumi wezesikhethu begodu waziwa khulu ngezomncamo , unesiqhema aphothela naso.uHlala e [[kammelriver B]] ngehlangothini lange skolweni iHlanganani emzin omkhulu ogwaliweko .

</text>
      <sha1>lh49kdl2iejr8uyh9lr7p5rwvek6997</sha1>
    </revision>
    <revision>
      <id>1264</id>
      <parentid>1263</parentid>
      <timestamp>2024-03-09T09:17:41Z</timestamp>
      <contributor>
        <username>incubator&gt;Thandeka179</username>
        <id>0</id>
      </contributor>
      <comment>Added a picture</comment>
      <origin>1264</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="269" sha1="cw8rpr85jshkd8glsvxi6ty5wd5w41s" xml:space="preserve">[[Isimumathi:Ndebele Architecture.jpg|thumb]]
U'''Sophy Mahlangu''' owaziwa ngoNosinki , ungumvumi wezesikhethu begodu waziwa khulu ngezomncamo , unesiqhema aphothela naso.uHlala e [[kammelriver B]] ngehlangothini lange skolweni iHlanganani emzin omkhulu ogwaliweko .

</text>
      <sha1>cw8rpr85jshkd8glsvxi6ty5wd5w41s</sha1>
    </revision>
    <revision>
      <id>1265</id>
      <parentid>1264</parentid>
      <timestamp>2024-10-14T13:47:09Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>1264</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="269" sha1="cw8rpr85jshkd8glsvxi6ty5wd5w41s" xml:space="preserve">[[Isimumathi:Ndebele Architecture.jpg|thumb]]
U'''Sophy Mahlangu''' owaziwa ngoNosinki , ungumvumi wezesikhethu begodu waziwa khulu ngezomncamo , unesiqhema aphothela naso.uHlala e [[kammelriver B]] ngehlangothini lange skolweni iHlanganani emzin omkhulu ogwaliweko .

</text>
      <sha1>cw8rpr85jshkd8glsvxi6ty5wd5w41s</sha1>
    </revision>
    <revision>
      <id>2215</id>
      <parentid>1265</parentid>
      <timestamp>2024-11-29T09:37:28Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>USophy Mahlangu</comment>
      <origin>2215</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="267" sha1="8zi2qfqix3c55u1uxcg96e09e4awnlo" xml:space="preserve">[[Isimumathi:Ndebele Architecture.jpg|thumb]]
'''USophy Mahlangu''' owaziwa ngoNosinki , ungumvumi wezesikhethu begodu waziwa khulu ngezomncamo , unesiqhema aphothela naso.uHlala e [[kammelriver B]] ngehlangothini lange skolweni iHlanganani emzin omkhulu ogwaliweko .</text>
      <sha1>8zi2qfqix3c55u1uxcg96e09e4awnlo</sha1>
    </revision>
  </page>
  <page>
    <title>Stich da kurnakga</title>
    <ns>0</ns>
    <id>240</id>
    <revision>
      <id>1266</id>
      <timestamp>2024-03-08T13:27:41Z</timestamp>
      <contributor>
        <username>incubator&gt;LindiweSiba</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;UStich da Kurnakga owaziwa ngoSibusiso Tervin wakwa Jiyana ohlala eKwaggafontein D ungumvumi wesikhethu ovuma umqulo weTrap ngelimi lesiNdebele.  &quot;</comment>
      <origin>1266</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="146" sha1="l6knf0s6ugjznkvnvhsrg5cl7o83955" xml:space="preserve">UStich da Kurnakga owaziwa ngoSibusiso Tervin wakwa Jiyana ohlala eKwaggafontein D ungumvumi wesikhethu ovuma umqulo weTrap ngelimi lesiNdebele.

</text>
      <sha1>l6knf0s6ugjznkvnvhsrg5cl7o83955</sha1>
    </revision>
    <revision>
      <id>1267</id>
      <parentid>1266</parentid>
      <timestamp>2024-03-08T13:39:44Z</timestamp>
      <contributor>
        <username>incubator&gt;LindiweSiba</username>
        <id>0</id>
      </contributor>
      <comment>Added content</comment>
      <origin>1267</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="272" sha1="ecq4sjz4jmnd4q5y6n7fawch4kd034e" xml:space="preserve">UStich da Kurnakga owaziwa ngoSibusiso Tervin wakwa Jiyana uneminyaka ematjhumi amabili nathoba, ohlala eKwaggafontein D ungumvumi wesikhethu ovuma umqulo weTrap ngelimi lesiNdebele. UStich Ugadangisa umvumo wakhe ngaphasi kwerhwebo lokugadangisa umvumo iKSinathi Music.

</text>
      <sha1>ecq4sjz4jmnd4q5y6n7fawch4kd034e</sha1>
    </revision>
    <revision>
      <id>1268</id>
      <parentid>1267</parentid>
      <timestamp>2024-10-14T13:47:09Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>1267</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="272" sha1="ecq4sjz4jmnd4q5y6n7fawch4kd034e" xml:space="preserve">UStich da Kurnakga owaziwa ngoSibusiso Tervin wakwa Jiyana uneminyaka ematjhumi amabili nathoba, ohlala eKwaggafontein D ungumvumi wesikhethu ovuma umqulo weTrap ngelimi lesiNdebele. UStich Ugadangisa umvumo wakhe ngaphasi kwerhwebo lokugadangisa umvumo iKSinathi Music.

</text>
      <sha1>ecq4sjz4jmnd4q5y6n7fawch4kd034e</sha1>
    </revision>
    <revision>
      <id>2159</id>
      <parentid>1268</parentid>
      <timestamp>2024-11-27T05:39:41Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>'''</comment>
      <origin>2159</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="276" sha1="7asz8xr5dxi34g71zgnhd3q7v8ywb03" xml:space="preserve">'''UStich da Kurnakga''' owaziwa ngoSibusiso Tervin wakwa Jiyana uneminyaka ematjhumi amabili nathoba, ohlala eKwaggafontein D ungumvumi wesikhethu ovuma umqulo weTrap ngelimi lesiNdebele. UStich Ugadangisa umvumo wakhe ngaphasi kwerhwebo lokugadangisa umvumo iKSinathi Music.</text>
      <sha1>7asz8xr5dxi34g71zgnhd3q7v8ywb03</sha1>
    </revision>
    <revision>
      <id>3001</id>
      <parentid>2159</parentid>
      <timestamp>2025-06-06T20:19:32Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>heheheha</comment>
      <origin>3001</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="357" sha1="178duemg2hhzf3ef3jhd5v9u9me6tsv" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. UStich da Kurnakga''' owaziwa ngoSibusiso Tervin wakwa Jiyana uneminyaka ematjhumi amabili nathoba, ohlala eKwaggafontein D ungumvumi wesikhethu ovuma umqulo weTrap ngelimi lesiNdebele. UStich Ugadangisa umvumo wakhe ngaphasi kwerhwebo lokugadangisa umvumo iKSinathi Music.</text>
      <sha1>178duemg2hhzf3ef3jhd5v9u9me6tsv</sha1>
    </revision>
    <revision>
      <id>3063</id>
      <parentid>3001</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Simakahle Moselekatse|Simakahle Moselekatse]]</comment>
      <origin>2159</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="276" sha1="7asz8xr5dxi34g71zgnhd3q7v8ywb03" xml:space="preserve">'''UStich da Kurnakga''' owaziwa ngoSibusiso Tervin wakwa Jiyana uneminyaka ematjhumi amabili nathoba, ohlala eKwaggafontein D ungumvumi wesikhethu ovuma umqulo weTrap ngelimi lesiNdebele. UStich Ugadangisa umvumo wakhe ngaphasi kwerhwebo lokugadangisa umvumo iKSinathi Music.</text>
      <sha1>7asz8xr5dxi34g71zgnhd3q7v8ywb03</sha1>
    </revision>
  </page>
  <page>
    <title>Thabo Mbeki</title>
    <ns>0</ns>
    <id>241</id>
    <revision>
      <id>1272</id>
      <timestamp>2024-03-15T08:16:28Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;Thabo Mbeki wayengumongameli waseSewula Afrika.  &quot;</comment>
      <origin>1272</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="49" sha1="b2d43w1vuerbcfvi264tlkoxgipbntq" xml:space="preserve">Thabo Mbeki wayengumongameli waseSewula Afrika.

</text>
      <sha1>b2d43w1vuerbcfvi264tlkoxgipbntq</sha1>
    </revision>
    <revision>
      <id>1273</id>
      <parentid>1272</parentid>
      <timestamp>2024-03-15T08:16:52Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1273</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="55" sha1="igwd8fmqrbcyzu2dk9oioz6x7oa476z" xml:space="preserve">'''Thabo Mbeki''' wayengumongameli waseSewula Afrika.

</text>
      <sha1>igwd8fmqrbcyzu2dk9oioz6x7oa476z</sha1>
    </revision>
    <revision>
      <id>1274</id>
      <parentid>1273</parentid>
      <timestamp>2024-10-14T13:47:10Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>1273</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="55" sha1="igwd8fmqrbcyzu2dk9oioz6x7oa476z" xml:space="preserve">'''Thabo Mbeki''' wayengumongameli waseSewula Afrika.

</text>
      <sha1>igwd8fmqrbcyzu2dk9oioz6x7oa476z</sha1>
    </revision>
    <revision>
      <id>2084</id>
      <parentid>1274</parentid>
      <timestamp>2024-11-21T16:41:54Z</timestamp>
      <contributor>
        <username>Aboubacarkhoraa</username>
        <id>188</id>
      </contributor>
      <origin>2084</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="102" sha1="0p268wo2a2i7dqenszey6bse74vc40g" xml:space="preserve">[[Isimumathi:SthAfrica.ThaboMbeki.01.jpg|thumb]]
'''Thabo Mbeki''' wayengumongameli waseSewula Afrika.</text>
      <sha1>0p268wo2a2i7dqenszey6bse74vc40g</sha1>
    </revision>
    <revision>
      <id>2184</id>
      <parentid>2084</parentid>
      <timestamp>2024-11-28T19:54:06Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>uMbeki ngomnyaka ka-2003</comment>
      <origin>2184</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="127" sha1="towgrzxnhg2uupr0fg6oszis72vqgf2" xml:space="preserve">[[Isimumathi:SthAfrica.ThaboMbeki.01.jpg|thumb|uMbeki ngomnyaka ka-2003]]
'''Thabo Mbeki''' wayengumongameli waseSewula Afrika.</text>
      <sha1>towgrzxnhg2uupr0fg6oszis72vqgf2</sha1>
    </revision>
  </page>
  <page>
    <title>Thando Mahlangu</title>
    <ns>0</ns>
    <id>242</id>
    <revision>
      <id>1275</id>
      <timestamp>2024-03-08T13:42:27Z</timestamp>
      <contributor>
        <username>incubator&gt;CdTshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot; U Thando Mahlangu ungumbali begodu ungu MNdebele ozikhakhazisa begodu oziqhenya nge siNdebele sekhbo.U hlala e Mpumalanga KwaMhlanga, uthando uyaziwa ngokukhakhazisa isikhabo khulu na ngembhatho lakhe nje ngombana angana mahloni nge sikhabo.U dume khulu KwaNdebele ngo kuba ngomunye waba zikhakhazisako NgesiNdebele sekhabo.  &quot;</comment>
      <origin>1275</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="327" sha1="empwdal4bmge1jsv9wfy2vl5cxtevnu" xml:space="preserve">
U Thando Mahlangu ungumbali begodu ungu MNdebele ozikhakhazisa begodu oziqhenya nge siNdebele sekhbo.U hlala e Mpumalanga KwaMhlanga, uthando uyaziwa ngokukhakhazisa isikhabo khulu na ngembhatho lakhe nje ngombana angana mahloni nge sikhabo.U dume khulu KwaNdebele ngo kuba ngomunye waba zikhakhazisako NgesiNdebele sekhabo.

</text>
      <sha1>empwdal4bmge1jsv9wfy2vl5cxtevnu</sha1>
    </revision>
    <revision>
      <id>1276</id>
      <parentid>1275</parentid>
      <timestamp>2024-03-08T13:47:06Z</timestamp>
      <contributor>
        <username>incubator&gt;CdTshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1276</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="341" sha1="8h3nd1wt6mk36l1tn45nogbwdj581jm" xml:space="preserve">
U '''Thando''' '''Mahlangu''' ungumbali begodu ungu MNdebele ozikhakhazisa begodu oziqhenya nge siNdebele sekhbo.U hlala e Mpumalanga KwaMhlanga, uthando uyaziwa ngokukhakhazisa ngesikhabo khulu na ngembhatho lakhe nje ngombana angana mahloni nge sikhabo.U dume khulu KwaNdebele ngo kuba ngomunye waba zikhakhazisako NgesiNdebele sekhabo.

</text>
      <sha1>8h3nd1wt6mk36l1tn45nogbwdj581jm</sha1>
    </revision>
    <revision>
      <id>1277</id>
      <parentid>1276</parentid>
      <timestamp>2024-03-08T14:02:33Z</timestamp>
      <contributor>
        <username>incubator&gt;CdTshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1277</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="370" sha1="2j5r3loabffweskl4dqtzfr4vwjtvat" xml:space="preserve">
U '''Thando''' '''Mahlangu''' ungumbali begodu ungu MNdebele ozikhakhazisa begodu oziqhenya nge siNdebele sekhbo.U hlala e Mpumalanga KwaMhlanga, uthando uyaziwa ngokukhakhazisa ngesikhabo khulu na ngembhatho lakhe nje ngombana angana mahloni nge sikhabo.U dume khulu KwaNdebele ngo kuba ngomunye waba zikhakhazisako NgesiNdebele sekhabo.

'''Thando''' '''Mahlangu'''

</text>
      <sha1>2j5r3loabffweskl4dqtzfr4vwjtvat</sha1>
    </revision>
    <revision>
      <id>1278</id>
      <parentid>1277</parentid>
      <timestamp>2024-03-09T07:31:57Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1278</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="374" sha1="8grfdkpgeigg2xszdd73t5a9cw17g83" xml:space="preserve">
U '''Thando''' '''Mahlangu''' ungumbali begodu ungu M[[Ndebele]] ozikhakhazisa begodu oziqhenya nge siNdebele sekhbo.U hlala e Mpumalanga KwaMhlanga, uthando uyaziwa ngokukhakhazisa ngesikhabo khulu na ngembhatho lakhe nje ngombana angana mahloni nge sikhabo.U dume khulu KwaNdebele ngo kuba ngomunye waba zikhakhazisako NgesiNdebele sekhabo.

'''Thando''' '''Mahlangu'''

</text>
      <sha1>8grfdkpgeigg2xszdd73t5a9cw17g83</sha1>
    </revision>
    <revision>
      <id>1279</id>
      <parentid>1278</parentid>
      <timestamp>2024-03-09T07:41:49Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1279</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="378" sha1="qiq79vaqygv631rfrbxoh1vthe0a8kw" xml:space="preserve">
U '''Thando''' '''Mahlangu''' ungumbali begodu ungu M[[Ndebele]] ozikhakhazisa begodu oziqhenya nge siNdebele sekhbo.U hlala e [[Mpumalanga]] KwaMhlanga, uthando uyaziwa ngokukhakhazisa ngesikhabo khulu na ngembhatho lakhe nje ngombana angana mahloni nge sikhabo.U dume khulu KwaNdebele ngo kuba ngomunye waba zikhakhazisako NgesiNdebele sekhabo.

'''Thando''' '''Mahlangu'''

</text>
      <sha1>qiq79vaqygv631rfrbxoh1vthe0a8kw</sha1>
    </revision>
    <revision>
      <id>1280</id>
      <parentid>1279</parentid>
      <timestamp>2024-03-09T08:17:09Z</timestamp>
      <contributor>
        <username>incubator&gt;Madubandlela</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1280</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="431" sha1="cvsefgpxg2ujmm4j7v5lfvwmbljbuun" xml:space="preserve">
U '''Thando''' '''Mahlangu''' ungumbali begodu ungu M[[Ndebele]] ozikhakhazisa begodu oziqhenya nge siNdebele sekhbo.U hlala e [[Mpumalanga]] KwaMhlanga, uthando uyaziwa ngokukhakhazisa ngesikhabo khulu na ngembhatho lakhe nje ngombana angana mahloni nge sikhabo.U dume khulu KwaNdebele ngo kuba ngomunye waba zikhakhazisako NgesiNdebele sekhabo.

'''Thando''' '''Mahlangu'''

Uthando uthanda kumbatha isikhabo nanyana kunelothe

</text>
      <sha1>cvsefgpxg2ujmm4j7v5lfvwmbljbuun</sha1>
    </revision>
    <revision>
      <id>1281</id>
      <parentid>1280</parentid>
      <timestamp>2024-03-12T07:59:21Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1281</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="444" sha1="jjojtygy0bjbusd9649e56o45weu1hh" xml:space="preserve">
U '''Thando''' '''Mahlangu''' ungumtloli  begodu uli[[Ndebele]] ozikhakhazisa begodu oziqhenya nge siNdebele sekhabo.U hlala e [[Mpumalanga]] ekhabo kuse Boekenhouthoek. Thando uyaziwa ngokukhakhazisa ngesikhabo khulu na ngembhatho lakhe nje ngombana akana mahloni nge sikhabo.Udume khulu KwaNdebele ngo kuba ngomunye waba zikhakhazisako NgesiNdebele sekhabo.

'''Thando''' '''Mahlangu'''

Uthando uthanda kumbatha isikhabo nanyana kunelothe

</text>
      <sha1>jjojtygy0bjbusd9649e56o45weu1hh</sha1>
    </revision>
    <revision>
      <id>1282</id>
      <parentid>1281</parentid>
      <timestamp>2024-03-12T19:15:20Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1282</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="436" sha1="euog4be9sfrkvgkcor26os0thci0qiu" xml:space="preserve">
U '''Thando''' '''Mahlangu''' ungumtloli  begodu uli[[Ndebele]] ozikhakhazisa begodu oziqhenya nge siNdebele sekhabo.U hlala e [[Mpumalanga]] ekhabo kuse Boekenhouthoek. Thando uyaziwa ngokukhakhazisa ngesikhabo khulu na ngembhatho lakhe nje ngombana akana mahloni nge sikhabo.Udume khulu KwaNdebele ngo kuba ngomunye waba zikhakhazisako NgesiNdebele sekhabo.

'''Umlando wakhe'''

Uthando uthanda kumbatha isikhabo nanyana kunelothe

</text>
      <sha1>euog4be9sfrkvgkcor26os0thci0qiu</sha1>
    </revision>
    <revision>
      <id>1283</id>
      <parentid>1282</parentid>
      <timestamp>2024-10-14T13:47:10Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>8 revisions imported</comment>
      <origin>1282</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="436" sha1="euog4be9sfrkvgkcor26os0thci0qiu" xml:space="preserve">
U '''Thando''' '''Mahlangu''' ungumtloli  begodu uli[[Ndebele]] ozikhakhazisa begodu oziqhenya nge siNdebele sekhabo.U hlala e [[Mpumalanga]] ekhabo kuse Boekenhouthoek. Thando uyaziwa ngokukhakhazisa ngesikhabo khulu na ngembhatho lakhe nje ngombana akana mahloni nge sikhabo.Udume khulu KwaNdebele ngo kuba ngomunye waba zikhakhazisako NgesiNdebele sekhabo.

'''Umlando wakhe'''

Uthando uthanda kumbatha isikhabo nanyana kunelothe

</text>
      <sha1>euog4be9sfrkvgkcor26os0thci0qiu</sha1>
    </revision>
    <revision>
      <id>2214</id>
      <parentid>1283</parentid>
      <timestamp>2024-11-29T07:39:14Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>UThando Mahlangu</comment>
      <origin>2214</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="432" sha1="rlcb3flt1euzowom9ntj1i3zxy456eu" xml:space="preserve">'''UThando''' '''Mahlangu''' ungumtloli  begodu uli[[Ndebele]] ozikhakhazisa begodu oziqhenya nge siNdebele sekhabo.U hlala e [[Mpumalanga]] ekhabo kuse Boekenhouthoek. Thando uyaziwa ngokukhakhazisa ngesikhabo khulu na ngembhatho lakhe nje ngombana akana mahloni nge sikhabo.Udume khulu KwaNdebele ngo kuba ngomunye waba zikhakhazisako NgesiNdebele sekhabo.

== Umlando wakhe ==
Uthando uthanda kumbatha isikhabo nanyana kunelothe.</text>
      <sha1>rlcb3flt1euzowom9ntj1i3zxy456eu</sha1>
    </revision>
    <revision>
      <id>5697</id>
      <parentid>2214</parentid>
      <timestamp>2025-09-04T12:12:11Z</timestamp>
      <contributor>
        <username>CharlotteDineo</username>
        <id>908</id>
      </contributor>
      <origin>5697</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2735" sha1="r98dqunhzv2btskn45pbs29dz0appkk" xml:space="preserve">'''UThando''' '''Mahlangu''' ungumtloli  begodu uli[[Ndebele]] ozikhakhazisa begodu oziqhenya nge siNdebele sekhabo.U hlala e [[Mpumalanga]] ekhabo kuse Boekenhouthoek. Thando uyaziwa ngokukhakhazisa ngesikhabo khulu na ngembhatho lakhe nje ngombana akana mahloni nge sikhabo.Udume khulu KwaNdebele ngo kuba ngomunye waba zikhakhazisako NgesiNdebele sekhabo.

== Umlando wakhe ==
Uthando uthanda kumbatha isikhabo nanyana kunelothe.

=== isigameko sa se midrand ===
u Thando Mahlangu uthi uzizwe ahlambalazekile maka tjhelwa bonyana a phume ngenthabathabeni zeentolo e Boulders Shopping Centre ngombana beka mbethe izembatho zakhe ze sikhethu . Ingabe ipatho beyi fanelekile na? Boulders Shopping Centre umaneja Jose Maponyane utjele i CRL Rights Commission ngoMsombuluko ukuthi yenze lokhu ukuvikela amalungelo wa bathengi abanye u Thando Mahlangu bekangaka mbhathi kuhle.  “Uthe maka bona ngendlela u thando ambethe ngayo,bekabonakala angaka mbathi kuhle. beku ngana mnyanya we sindu e  Midrand lokho bekuzo yelelisa bonyana kunomnyanya we sintu . isiqithi ngabantu begodu kube yinto engingaka yiboni phambilini.  Mangibona bonyana sihlala endaweni la abantu bangakaphilanga kuhle ehloko ngiyaxolisa uku sebenzisa igama leli,bengi zibuza bonyana u phile kuhle ehloko ngombana azange ngibone into efana nale, utjho njalo.Maponyane, aseduze no mmeli wakhe, uvele phambi kwe khomisini nje ngoba umlandu uqhubekela phambili nge Ndebele activist u Thando Mahlangu angavumelwa kobana angene enthabathabeni zeentolo ambethe izembatho zesintu ku ntaka.  U Maponyane uphiwe ithuba loku khuluma no ku phendula kiyo yoke insolo ezi phakamiswe ngu Mahlangu. U thome ngoku qolisa wathi i vidio yesigameko i susiweku  context.  “nge 24 ku Ntaka ngabo 12.15pm, be ka thenga ukudla kwe kwa laba asebenza nabo . ngisa jamele ukudla , ngizwe umsindo ophezulu ukusuka e kioski ukusuka ku mama,kube yinto emangazako.I thethe i ngenze nganaka yona khulu,kula ngibone khona i sokana nga bheka ngabona bonyana bonyana ngaphambili bekungaka valwa ,beka qhoke i sembatho sangaphasi esinqane esifana neengubo.  U Maponyane  uthe u bawe abalindi bendawo kobana ba bawe u  Mahlangu kobana ambathe. uthe une lungelo lonje nge center manager ukuthi a khulumise isimo lesi abalindi bendawo bathe maba buya bathi u Mahlangu uwale ukwembatha noma ukuzivala kuhle.  “ngiye khona ngakhulumisana no Mahlangu bese ngambuza kuhle kobana ngibawa a zivale kuhle ngombana lendawo le ngeye sitjhaba wala wathi yi sintu sakhe   Maponyane uthe ikulumo yakhe no Mahlangu i thethe imizuzu emithathu nama sekoni ama hlanu bese wa khamba nasele imimoya i phezulu.  U Mahlangu uphe ikulumo yakhe phambilini

I patho le beyirerhe nje ngombana beka mbethe izembatho ze sindu na?</text>
      <sha1>r98dqunhzv2btskn45pbs29dz0appkk</sha1>
    </revision>
  </page>
  <page>
    <title>Themba Mnguni</title>
    <ns>0</ns>
    <id>243</id>
    <revision>
      <id>1284</id>
      <timestamp>2016-02-25T23:22:48Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;{{Person| | ibizo = Themba G. Mnguni | isithombe = TG Mguni.png | umsebenzi = Umtloli | ubelethwe ngo = 1965 | indawo yo kubelethwa = eDelmas (eNtatjaneni) | wahlongakal...&quot;</comment>
      <origin>1284</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1920" sha1="kmpz84x4qoxc4kh2ckpcoohxbl7nf0g" xml:space="preserve">{{Person|
| ibizo = Themba G. Mnguni
| isithombe = TG Mguni.png
| umsebenzi = Umtloli
| ubelethwe ngo = 1965
| indawo yo kubelethwa = eDelmas (eNtatjaneni)
| wahlongakala ngo = 
| indawo yo hlongakala = 
}}
'''Themba G. Mnguni''' (wabelethwa ngo 1965) ngumtloli odumileko wobukondlo besindebele begodu Wabelethwa ngo 1965 eDel-
mas (eNtatjaneni) ekukulapho athoma khona isikolo.&lt;ref name=ph1&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt;

U-Themba G. Mnguni umntwana wesithathu obelethwa ngu Nomzana Jacob Mnguni nomma uKhulelaphi Selinah Mnguni (uNaMtshweni). Wakhulela esabelweni samzukwana saKwaNdebele lapho ababelethi bakhe bafudukela khona emva kokuhlonya kwesabelo saKwaNdebele eminyakeni yekupheleni yabo 1970. Wafunda eenkolweni ezimbalwa eKwaggafontein bewaswaphelisa iimfundo zebanga eliphakemeko eHluzingqondo Senior Secondary School. 

Wathoma ibizelo lakho lezemtlolo ngomnyaka ka-1993 bewakhupha imitlolo esingadzubhula hlangana nale elandelako:

# - [[Ibhudango Lami]] -Nasou Via Afrika (1997);
# - Sibuyakhona -Heinnemann Publishers (2001);
# - Ipilo Ibudisana Kodwana Iyakarisa -Juta Publishers (2005);
# - Ihloya -Van Schaik Publishers (2003);
# - Isiko LakoSobantu -Juta Publishers (2006);
# - Umlando KaSolomon Mahlangu -ZamaNguni Creative Productions (2004);
# - Biography of Solomon Mahlangu -ZamaNguni Creative Productions (2006);
# - Isipho -ZamaNguni Creative Productions (2007) (isiSwati and isiNdebele versions);
# - Ubuntu Babantu -ZamaNguni Creative Productions (2007);
# - Ubuntu -ZamaNguni Creative Productions (2009);
# - Iinkutani -ZamaNguni Creative productions (2008); and
# - Ibuthelelo Lenkutani -ZamaNguni Creative Productions (2009)


==Isithasiselo==
&lt;references/&gt;

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>kmpz84x4qoxc4kh2ckpcoohxbl7nf0g</sha1>
    </revision>
    <revision>
      <id>1285</id>
      <parentid>1284</parentid>
      <timestamp>2016-02-25T23:24:14Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1285</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1940" sha1="e5qp82apazw4bjymc8ryebf0oqbcmhp" xml:space="preserve">{{Person|
| ibizo = Themba G. Mnguni
| isithombe = TG Mguni.png
| umsebenzi = Umtloli
| ubelethwe ngo = 1965
| indawo yo kubelethwa = eDelmas (eNtatjaneni)
| wahlongakala ngo = 
| indawo yo hlongakala = 
}}
'''Themba G. Mnguni''' (wabelethwa ngo 1965) ngumtloli odumileko wobukondlo besindebele begodu Wabelethwa ngo 1965 eDel-
mas (eNtatjaneni) ekukulapho athoma khona isikolo.&lt;ref name=ph1&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt;

U-Themba G. Mnguni umntwana wesithathu obelethwa ngu Nomzana Jacob Mnguni nomma uKhulelaphi Selinah Mnguni (uNaMtshweni). Wakhulela esabelweni samzukwana saKwaNdebele lapho ababelethi bakhe bafudukela khona emva kokuhlonya kwesabelo saKwaNdebele eminyakeni yekupheleni yabo 1970. Wafunda eenkolweni ezimbalwa eKwaggafontein bewaswaphelisa iimfundo zebanga eliphakemeko eHluzingqondo Senior Secondary School.&lt;ref name=ph1&gt;&lt;/ref&gt; 

Wathoma ibizelo lakho lezemtlolo ngomnyaka ka-1993 bewakhupha imitlolo esingadzubhula hlangana nale elandelako:

# - [[Ibhudango Lami]] -Nasou Via Afrika (1997);
# - Sibuyakhona -Heinnemann Publishers (2001);
# - Ipilo Ibudisana Kodwana Iyakarisa -Juta Publishers (2005);
# - Ihloya -Van Schaik Publishers (2003);
# - Isiko LakoSobantu -Juta Publishers (2006);
# - Umlando KaSolomon Mahlangu -ZamaNguni Creative Productions (2004);
# - Biography of Solomon Mahlangu -ZamaNguni Creative Productions (2006);
# - Isipho -ZamaNguni Creative Productions (2007) (isiSwati and isiNdebele versions);
# - Ubuntu Babantu -ZamaNguni Creative Productions (2007);
# - Ubuntu -ZamaNguni Creative Productions (2009);
# - Iinkutani -ZamaNguni Creative productions (2008); and
# - Ibuthelelo Lenkutani -ZamaNguni Creative Productions (2009)


==Isithasiselo==
&lt;references/&gt;

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>e5qp82apazw4bjymc8ryebf0oqbcmhp</sha1>
    </revision>
    <revision>
      <id>1286</id>
      <parentid>1285</parentid>
      <timestamp>2016-02-26T21:21:17Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1286</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1892" sha1="8hbkdxe5rqv6229ryyof9hf9s22e4a8" xml:space="preserve">{{Person|
| ibizo = Themba G. Mnguni
| isithombe = TG Mguni.png
| umsebenzi = Umtloli
| ubelethwe ngo = 1965
| indawo yo kubelethwa = eDelmas (eNtatjaneni)
}}
'''Themba G. Mnguni''' (wabelethwa ngo 1965) ngumtloli odumileko wobukondlo besindebele begodu Wabelethwa ngo 1965 eDel-
mas (eNtatjaneni) ekukulapho athoma khona isikolo.&lt;ref name=ph1&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt;

U-Themba G. Mnguni umntwana wesithathu obelethwa ngu Nomzana Jacob Mnguni nomma uKhulelaphi Selinah Mnguni (uNaMtshweni). Wakhulela esabelweni samzukwana saKwaNdebele lapho ababelethi bakhe bafudukela khona emva kokuhlonya kwesabelo saKwaNdebele eminyakeni yekupheleni yabo 1970. Wafunda eenkolweni ezimbalwa eKwaggafontein bewaswaphelisa iimfundo zebanga eliphakemeko eHluzingqondo Senior Secondary School.&lt;ref name=ph1&gt;&lt;/ref&gt; 

Wathoma ibizelo lakho lezemtlolo ngomnyaka ka-1993 bewakhupha imitlolo esingadzubhula hlangana nale elandelako:

# - [[Ibhudango Lami]] -Nasou Via Afrika (1997);
# - Sibuyakhona -Heinnemann Publishers (2001);
# - Ipilo Ibudisana Kodwana Iyakarisa -Juta Publishers (2005);
# - Ihloya -Van Schaik Publishers (2003);
# - Isiko LakoSobantu -Juta Publishers (2006);
# - Umlando KaSolomon Mahlangu -ZamaNguni Creative Productions (2004);
# - Biography of Solomon Mahlangu -ZamaNguni Creative Productions (2006);
# - Isipho -ZamaNguni Creative Productions (2007) (isiSwati and isiNdebele versions);
# - Ubuntu Babantu -ZamaNguni Creative Productions (2007);
# - Ubuntu -ZamaNguni Creative Productions (2009);
# - Iinkutani -ZamaNguni Creative productions (2008); and
# - Ibuthelelo Lenkutani -ZamaNguni Creative Productions (2009)


==Isithasiselo==
&lt;references/&gt;

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>8hbkdxe5rqv6229ryyof9hf9s22e4a8</sha1>
    </revision>
    <revision>
      <id>1287</id>
      <parentid>1286</parentid>
      <timestamp>2024-10-14T13:47:10Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>1286</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1892" sha1="8hbkdxe5rqv6229ryyof9hf9s22e4a8" xml:space="preserve">{{Person|
| ibizo = Themba G. Mnguni
| isithombe = TG Mguni.png
| umsebenzi = Umtloli
| ubelethwe ngo = 1965
| indawo yo kubelethwa = eDelmas (eNtatjaneni)
}}
'''Themba G. Mnguni''' (wabelethwa ngo 1965) ngumtloli odumileko wobukondlo besindebele begodu Wabelethwa ngo 1965 eDel-
mas (eNtatjaneni) ekukulapho athoma khona isikolo.&lt;ref name=ph1&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt;

U-Themba G. Mnguni umntwana wesithathu obelethwa ngu Nomzana Jacob Mnguni nomma uKhulelaphi Selinah Mnguni (uNaMtshweni). Wakhulela esabelweni samzukwana saKwaNdebele lapho ababelethi bakhe bafudukela khona emva kokuhlonya kwesabelo saKwaNdebele eminyakeni yekupheleni yabo 1970. Wafunda eenkolweni ezimbalwa eKwaggafontein bewaswaphelisa iimfundo zebanga eliphakemeko eHluzingqondo Senior Secondary School.&lt;ref name=ph1&gt;&lt;/ref&gt; 

Wathoma ibizelo lakho lezemtlolo ngomnyaka ka-1993 bewakhupha imitlolo esingadzubhula hlangana nale elandelako:

# - [[Ibhudango Lami]] -Nasou Via Afrika (1997);
# - Sibuyakhona -Heinnemann Publishers (2001);
# - Ipilo Ibudisana Kodwana Iyakarisa -Juta Publishers (2005);
# - Ihloya -Van Schaik Publishers (2003);
# - Isiko LakoSobantu -Juta Publishers (2006);
# - Umlando KaSolomon Mahlangu -ZamaNguni Creative Productions (2004);
# - Biography of Solomon Mahlangu -ZamaNguni Creative Productions (2006);
# - Isipho -ZamaNguni Creative Productions (2007) (isiSwati and isiNdebele versions);
# - Ubuntu Babantu -ZamaNguni Creative Productions (2007);
# - Ubuntu -ZamaNguni Creative Productions (2009);
# - Iinkutani -ZamaNguni Creative productions (2008); and
# - Ibuthelelo Lenkutani -ZamaNguni Creative Productions (2009)


==Isithasiselo==
&lt;references/&gt;

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>8hbkdxe5rqv6229ryyof9hf9s22e4a8</sha1>
    </revision>
    <revision>
      <id>2148</id>
      <parentid>1287</parentid>
      <timestamp>2024-11-25T18:31:50Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <origin>2148</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1891" sha1="azgkt674300rh2wc3ncl3d9kobu364i" xml:space="preserve">{{Person|
| ibizo = Themba G. Mnguni
| isithombe = TG Mguni.png
| umsebenzi = Umtloli
| ubelethwe ngo = 1965
| indawo yo kubelethwa = eDelmas (eNtatjaneni)
}}
'''Themba G. Mnguni''' (wabelethwa ngo 1965) ngumtloli odumileko wobukondlo besindebele begodu Wabelethwa ngo 1965 eDel-
mas (eNtatjaneni) ekukulapho athoma khona isikolo.&lt;ref name=ph1&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt;

U-Themba G. Mnguni umntwana wesithathu obelethwa ngu Nomzana Jacob Mnguni nomma uKhulelaphi Selinah Mnguni (uNaMtshweni). Wakhulela esabelweni samzukwana saKwaNdebele lapho ababelethi bakhe bafudukela khona emva kokuhlonya kwesabelo saKwaNdebele eminyakeni yekupheleni yabo 1970. Wafunda eenkolweni ezimbalwa eKwaggafontein bewaswaphelisa iimfundo zebanga eliphakemeko eHluzingqondo Senior Secondary School.&lt;ref name=ph1&gt;&lt;/ref&gt; 

Wathoma ibizelo lakho lezemtlolo ngomnyaka ka-1993 bewakhupha imitlolo esingadzubhula hlangana nale elandelako:

# - [[Ibhudango Lami]] -Nasou Via Afrika (1997);
# - Sibuyakhona -Heinnemann Publishers (2001);
# - Ipilo Ibudisana Kodwana Iyakarisa -Juta Publishers (2005);
# - Ihloya -Van Schaik Publishers (2003);
# - Isiko LakoSobantu -Juta Publishers (2006);
# - Umlando KaSolomon Mahlangu -ZamaNguni Creative Productions (2004);
# - Biography of Solomon Mahlangu -ZamaNguni Creative Productions (2006);
# - Isipho -ZamaNguni Creative Productions (2007) (isiSwati and isiNdebele versions);
# - Ubuntu Babantu -ZamaNguni Creative Productions (2007);
# - Ubuntu -ZamaNguni Creative Productions (2009);
# - Iinkutani -ZamaNguni Creative productions (2008); and
# - Ibuthelelo Lenkutani -ZamaNguni Creative Productions (2009)

==Isithasiselo==
&lt;references/&gt;

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>azgkt674300rh2wc3ncl3d9kobu364i</sha1>
    </revision>
    <revision>
      <id>2149</id>
      <parentid>2148</parentid>
      <timestamp>2024-11-25T18:32:11Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* Iinkomba */Reflist</comment>
      <origin>2149</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1887" sha1="pmy2annt2adw4o1a3pbfys5yvlhd7rk" xml:space="preserve">{{Person|
| ibizo = Themba G. Mnguni
| isithombe = TG Mguni.png
| umsebenzi = Umtloli
| ubelethwe ngo = 1965
| indawo yo kubelethwa = eDelmas (eNtatjaneni)
}}
'''Themba G. Mnguni''' (wabelethwa ngo 1965) ngumtloli odumileko wobukondlo besindebele begodu Wabelethwa ngo 1965 eDel-
mas (eNtatjaneni) ekukulapho athoma khona isikolo.&lt;ref name=ph1&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt;

U-Themba G. Mnguni umntwana wesithathu obelethwa ngu Nomzana Jacob Mnguni nomma uKhulelaphi Selinah Mnguni (uNaMtshweni). Wakhulela esabelweni samzukwana saKwaNdebele lapho ababelethi bakhe bafudukela khona emva kokuhlonya kwesabelo saKwaNdebele eminyakeni yekupheleni yabo 1970. Wafunda eenkolweni ezimbalwa eKwaggafontein bewaswaphelisa iimfundo zebanga eliphakemeko eHluzingqondo Senior Secondary School.&lt;ref name=ph1&gt;&lt;/ref&gt; 

Wathoma ibizelo lakho lezemtlolo ngomnyaka ka-1993 bewakhupha imitlolo esingadzubhula hlangana nale elandelako:

# - [[Ibhudango Lami]] -Nasou Via Afrika (1997);
# - Sibuyakhona -Heinnemann Publishers (2001);
# - Ipilo Ibudisana Kodwana Iyakarisa -Juta Publishers (2005);
# - Ihloya -Van Schaik Publishers (2003);
# - Isiko LakoSobantu -Juta Publishers (2006);
# - Umlando KaSolomon Mahlangu -ZamaNguni Creative Productions (2004);
# - Biography of Solomon Mahlangu -ZamaNguni Creative Productions (2006);
# - Isipho -ZamaNguni Creative Productions (2007) (isiSwati and isiNdebele versions);
# - Ubuntu Babantu -ZamaNguni Creative Productions (2007);
# - Ubuntu -ZamaNguni Creative Productions (2009);
# - Iinkutani -ZamaNguni Creative productions (2008); and
# - Ibuthelelo Lenkutani -ZamaNguni Creative Productions (2009)

== Iinkomba ==
{{Reflist}}

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>pmy2annt2adw4o1a3pbfys5yvlhd7rk</sha1>
    </revision>
    <revision>
      <id>3020</id>
      <parentid>2149</parentid>
      <timestamp>2025-06-06T20:29:36Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>photo</comment>
      <origin>3020</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1968" sha1="ftfrcsa5dqw7lu50851sed4yy9ov9tk" xml:space="preserve">{{Person|
| ibizo = Themba G. Mnguni
| isithombe = TG Mguni.png
| umsebenzi = Umtloli
| ubelethwe ngo = 1965
| indawo yo kubelethwa = eDelmas (eNtatjaneni)
}}
'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. Themba G. Mnguni''' (wabelethwa ngo 1965) ngumtloli odumileko wobukondlo besindebele begodu Wabelethwa ngo 1965 eDel-
mas (eNtatjaneni) ekukulapho athoma khona isikolo.&lt;ref name=ph1&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt;

U-Themba G. Mnguni umntwana wesithathu obelethwa ngu Nomzana Jacob Mnguni nomma uKhulelaphi Selinah Mnguni (uNaMtshweni). Wakhulela esabelweni samzukwana saKwaNdebele lapho ababelethi bakhe bafudukela khona emva kokuhlonya kwesabelo saKwaNdebele eminyakeni yekupheleni yabo 1970. Wafunda eenkolweni ezimbalwa eKwaggafontein bewaswaphelisa iimfundo zebanga eliphakemeko eHluzingqondo Senior Secondary School.&lt;ref name=ph1&gt;&lt;/ref&gt; 

Wathoma ibizelo lakho lezemtlolo ngomnyaka ka-1993 bewakhupha imitlolo esingadzubhula hlangana nale elandelako:

# - [[Ibhudango Lami]] -Nasou Via Afrika (1997);
# - Sibuyakhona -Heinnemann Publishers (2001);
# - Ipilo Ibudisana Kodwana Iyakarisa -Juta Publishers (2005);
# - Ihloya -Van Schaik Publishers (2003);
# - Isiko LakoSobantu -Juta Publishers (2006);
# - Umlando KaSolomon Mahlangu -ZamaNguni Creative Productions (2004);
# - Biography of Solomon Mahlangu -ZamaNguni Creative Productions (2006);
# - Isipho -ZamaNguni Creative Productions (2007) (isiSwati and isiNdebele versions);
# - Ubuntu Babantu -ZamaNguni Creative Productions (2007);
# - Ubuntu -ZamaNguni Creative Productions (2009);
# - Iinkutani -ZamaNguni Creative productions (2008); and
# - Ibuthelelo Lenkutani -ZamaNguni Creative Productions (2009)

== Iinkomba ==
{{Reflist}}

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>ftfrcsa5dqw7lu50851sed4yy9ov9tk</sha1>
    </revision>
    <revision>
      <id>3064</id>
      <parentid>3020</parentid>
      <timestamp>2025-06-07T03:05:22Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Simakahle Moselekatse|Simakahle Moselekatse]]</comment>
      <origin>2149</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1887" sha1="pmy2annt2adw4o1a3pbfys5yvlhd7rk" xml:space="preserve">{{Person|
| ibizo = Themba G. Mnguni
| isithombe = TG Mguni.png
| umsebenzi = Umtloli
| ubelethwe ngo = 1965
| indawo yo kubelethwa = eDelmas (eNtatjaneni)
}}
'''Themba G. Mnguni''' (wabelethwa ngo 1965) ngumtloli odumileko wobukondlo besindebele begodu Wabelethwa ngo 1965 eDel-
mas (eNtatjaneni) ekukulapho athoma khona isikolo.&lt;ref name=ph1&gt;&quot;[https://www.yumpu.com/sw/document/view/14913176/here-national-library-of-south-africa/17 Preserving and Celebrating our literary heritage]&quot; (March 2011) - '''National Library of South Africa'''. Retrieved 22 February 2016&lt;/ref&gt;

U-Themba G. Mnguni umntwana wesithathu obelethwa ngu Nomzana Jacob Mnguni nomma uKhulelaphi Selinah Mnguni (uNaMtshweni). Wakhulela esabelweni samzukwana saKwaNdebele lapho ababelethi bakhe bafudukela khona emva kokuhlonya kwesabelo saKwaNdebele eminyakeni yekupheleni yabo 1970. Wafunda eenkolweni ezimbalwa eKwaggafontein bewaswaphelisa iimfundo zebanga eliphakemeko eHluzingqondo Senior Secondary School.&lt;ref name=ph1&gt;&lt;/ref&gt; 

Wathoma ibizelo lakho lezemtlolo ngomnyaka ka-1993 bewakhupha imitlolo esingadzubhula hlangana nale elandelako:

# - [[Ibhudango Lami]] -Nasou Via Afrika (1997);
# - Sibuyakhona -Heinnemann Publishers (2001);
# - Ipilo Ibudisana Kodwana Iyakarisa -Juta Publishers (2005);
# - Ihloya -Van Schaik Publishers (2003);
# - Isiko LakoSobantu -Juta Publishers (2006);
# - Umlando KaSolomon Mahlangu -ZamaNguni Creative Productions (2004);
# - Biography of Solomon Mahlangu -ZamaNguni Creative Productions (2006);
# - Isipho -ZamaNguni Creative Productions (2007) (isiSwati and isiNdebele versions);
# - Ubuntu Babantu -ZamaNguni Creative Productions (2007);
# - Ubuntu -ZamaNguni Creative Productions (2009);
# - Iinkutani -ZamaNguni Creative productions (2008); and
# - Ibuthelelo Lenkutani -ZamaNguni Creative Productions (2009)

== Iinkomba ==
{{Reflist}}

[[Mkhakha:Abatloli|Abatloli]]</text>
      <sha1>pmy2annt2adw4o1a3pbfys5yvlhd7rk</sha1>
    </revision>
  </page>
  <page>
    <title>Tokyo Sexuale</title>
    <ns>0</ns>
    <id>244</id>
    <revision>
      <id>1288</id>
      <timestamp>2024-03-15T19:00:57Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;Tokyo Sexuale ungusomabhizinisi kanye nosopolitiki wecembu leANC wase Sewula Afrika.&quot;</comment>
      <origin>1288</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="84" sha1="rtyxez3lntxoap6jp5sgzc6her187m5" xml:space="preserve">Tokyo Sexuale ungusomabhizinisi kanye nosopolitiki wecembu leANC wase Sewula Afrika.</text>
      <sha1>rtyxez3lntxoap6jp5sgzc6her187m5</sha1>
    </revision>
    <revision>
      <id>1289</id>
      <parentid>1288</parentid>
      <timestamp>2024-03-15T19:01:29Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1289</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="90" sha1="fea8dapf0fyj0llkbc9fqbaznaly2dp" xml:space="preserve">'''Tokyo Sexuale''' ungusomabhizinisi kanye nosopolitiki wecembu leANC wase Sewula Afrika.</text>
      <sha1>fea8dapf0fyj0llkbc9fqbaznaly2dp</sha1>
    </revision>
    <revision>
      <id>1290</id>
      <parentid>1289</parentid>
      <timestamp>2024-03-15T19:02:10Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1290</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="109" sha1="67pricg4se27ly6yn90tmzn6ajdl5vh" xml:space="preserve">'''Tokyo Sexuale''' ungusomabhizinisi kanye nosopolitiki wecembu leANC wase [[Isewula Afrika|Sewula Afrika]].</text>
      <sha1>67pricg4se27ly6yn90tmzn6ajdl5vh</sha1>
    </revision>
    <revision>
      <id>1291</id>
      <parentid>1290</parentid>
      <timestamp>2024-10-14T13:47:10Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>1290</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="109" sha1="67pricg4se27ly6yn90tmzn6ajdl5vh" xml:space="preserve">'''Tokyo Sexuale''' ungusomabhizinisi kanye nosopolitiki wecembu leANC wase [[Isewula Afrika|Sewula Afrika]].</text>
      <sha1>67pricg4se27ly6yn90tmzn6ajdl5vh</sha1>
    </revision>
    <revision>
      <id>2085</id>
      <parentid>1291</parentid>
      <timestamp>2024-11-21T17:19:47Z</timestamp>
      <contributor>
        <username>Aboubacarkhoraa</username>
        <id>188</id>
      </contributor>
      <origin>2085</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="157" sha1="dvalrwvqbkvdoq8aprl32zzsd3wmxeo" xml:space="preserve">[[Isimumathi:Tokyo Sexwale-wef-crop.jpg|thumb]]
'''Tokyo Sexuale''' ungusomabhizinisi kanye nosopolitiki wecembu leANC wase [[Isewula Afrika|Sewula Afrika]].</text>
      <sha1>dvalrwvqbkvdoq8aprl32zzsd3wmxeo</sha1>
    </revision>
    <revision>
      <id>2183</id>
      <parentid>2085</parentid>
      <timestamp>2024-11-28T19:53:06Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>uSexuale ngomnyaka ka-2007</comment>
      <origin>2183</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="184" sha1="6b7xsjnvzdojm4ez33x7hls26rcango" xml:space="preserve">[[Isimumathi:Tokyo Sexwale-wef-crop.jpg|thumb|uSexuale ngomnyaka ka-2007]]
'''Tokyo Sexuale''' ungusomabhizinisi kanye nosopolitiki wecembu leANC wase [[Isewula Afrika|Sewula Afrika]].</text>
      <sha1>6b7xsjnvzdojm4ez33x7hls26rcango</sha1>
    </revision>
  </page>
  <page>
    <title>Tshegofatso AMG Teffo</title>
    <ns>0</ns>
    <id>245</id>
    <revision>
      <id>1292</id>
      <timestamp>2024-03-08T13:40:26Z</timestamp>
      <contributor>
        <username>incubator&gt;Lihlentuli</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;UTshegofatso Teffo owaziwa ngo Tshego AMG (All Mighty Guitarist), mdlali we gatara begodu abe mcophisi womvumo ka Kwesta. UTshego AMG wazenzela igama ngodlalela abavumi abadumile e Sewula Afrika. Sibala hlangana, u Sjava, Mafikizolo, DJ Ganyani, Dr Malinga, Qamagwini, Winnie Mashaba, Mobi Dixion, kanye nabanye abanengi.  &quot;</comment>
      <origin>1292</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="323" sha1="ojsqmqp3fqa4eb95o1fsz06xd7htqzg" xml:space="preserve">UTshegofatso Teffo owaziwa ngo Tshego AMG (All Mighty Guitarist), mdlali we gatara begodu abe mcophisi womvumo ka Kwesta. UTshego AMG wazenzela igama ngodlalela abavumi abadumile e Sewula Afrika. Sibala hlangana, u Sjava, Mafikizolo, DJ Ganyani, Dr Malinga, Qamagwini, Winnie Mashaba, Mobi Dixion, kanye nabanye abanengi.

</text>
      <sha1>ojsqmqp3fqa4eb95o1fsz06xd7htqzg</sha1>
    </revision>
    <revision>
      <id>1293</id>
      <parentid>1292</parentid>
      <timestamp>2024-03-08T13:41:45Z</timestamp>
      <contributor>
        <username>incubator&gt;Lihlentuli</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1293</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="329" sha1="hj8miwrl1jvrvi1mihki4ozozarf3q0" xml:space="preserve">'''UTshegofatso Teffo''' owaziwa ngo Tshego AMG (All Mighty Guitarist), mdlali we gatara begodu abe mcophisi womvumo ka Kwesta. UTshego AMG wazenzela igama ngodlalela abavumi abadumile e Sewula Afrika. Sibala hlangana, u Sjava, Mafikizolo, DJ Ganyani, Dr Malinga, Qamagwini, Winnie Mashaba, Mobi Dixion, kanye nabanye abanengi.

</text>
      <sha1>hj8miwrl1jvrvi1mihki4ozozarf3q0</sha1>
    </revision>
    <revision>
      <id>1294</id>
      <parentid>1293</parentid>
      <timestamp>2024-03-08T13:46:39Z</timestamp>
      <contributor>
        <username>incubator&gt;Lihlentuli</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1294</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="520" sha1="l8fzstjyayhofi8w67jx0jr5v0t238e" xml:space="preserve">'''UTshegofatso Teffo''' owaziwa ngo Tshego AMG (All Mighty Guitarist) owabelethelwa eSiyabuswa, mdlali we gatara begodu abe mcophisi womvumo ka Kwesta. UTshego AMG wazenzela igama ngodlalela abavumi abadumile e Sewula Afrika. Sibala hlangana, u Sjava, Mafikizolo, DJ Ganyani, Dr Malinga, Qamagwini, Winnie Mashaba, Mobi Dixion, kanye nabanye abanengi.

UTshego AMG wagadangisa i ulbum yakhe yokuthoma ngomyaka ka 2021 wayibiza ngokuthi &quot;Magatara&quot;. Enye yeengomba zakhe ezakhamba phambili emrhatjhweni yi &quot;Siyabuswa B&quot;

</text>
      <sha1>l8fzstjyayhofi8w67jx0jr5v0t238e</sha1>
    </revision>
    <revision>
      <id>1295</id>
      <parentid>1294</parentid>
      <timestamp>2024-08-30T09:53:46Z</timestamp>
      <contributor>
        <username>incubator&gt;Nomsa Skosana</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1295</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="529" sha1="7fmr125gbtqcrghupvpungb8kzil10w" xml:space="preserve">'''UTshegofatso Teffo''' owaziwa ngoTshego AMG (''All Mighty Guitarist'') owabelethelwa eSiyabuswa, mdlali wegatara begodu abe mcophisi womvumo kaKwesta. UTshego AMG wazenzela igama ngokudlalela abavumi abadumileko eSewula Afrika. Sibala hlangana, uSjava, Mafikizolo, DJ Ganyani, Dr Malinga, Qamagwini, Winnie Mashaba, Mobi Dixion, kanye nabanye abanengi.

UTshego AMG wagadangisa i-''ulbum'' yakhe yokuthoma ngomnyaka wee-2021 wayibiza ngokuthi yi-Magatara. Enye yeengoma zakhe ezakhamba phambili emrhatjhweni yi -Siyabuswa B.

</text>
      <sha1>7fmr125gbtqcrghupvpungb8kzil10w</sha1>
    </revision>
    <revision>
      <id>1296</id>
      <parentid>1295</parentid>
      <timestamp>2024-08-30T10:06:00Z</timestamp>
      <contributor>
        <username>incubator&gt;Nomsa Skosana</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1296</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="528" sha1="rq0hof3frjswhjtm2xagszbezaxa73e" xml:space="preserve">'''UTshegofatso Teffo''' owaziwa ngoTshego AMG (''All Mighty Guitarist'') owabelethelwa eSiyabuswa, mdlali wegatara begodu abe mcophisi womvumo kaKwesta. UTshego AMG wazenzela igama ngokudlalela abavumi abadumileko eSewula Afrika. Sibala hlangana, uSjava, Mafikizolo, DJ Ganyani, Dr Malinga, Qamagwini, Winnie Mashaba, Mobi Dixion, kanye nabanye abanengi.

UTshego AMG wagadangisa i-''ulbum'' yakhe yokuthoma ngomnyaka wee-2021 wayibiza ngokuthi yi-Magatara. Enye yeengoma zakhe ezakhamba phambili emrhatjhweni yi-Siyabuswa B.

</text>
      <sha1>rq0hof3frjswhjtm2xagszbezaxa73e</sha1>
    </revision>
    <revision>
      <id>1297</id>
      <parentid>1296</parentid>
      <timestamp>2024-10-14T13:47:10Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>5 revisions imported</comment>
      <origin>1296</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="528" sha1="rq0hof3frjswhjtm2xagszbezaxa73e" xml:space="preserve">'''UTshegofatso Teffo''' owaziwa ngoTshego AMG (''All Mighty Guitarist'') owabelethelwa eSiyabuswa, mdlali wegatara begodu abe mcophisi womvumo kaKwesta. UTshego AMG wazenzela igama ngokudlalela abavumi abadumileko eSewula Afrika. Sibala hlangana, uSjava, Mafikizolo, DJ Ganyani, Dr Malinga, Qamagwini, Winnie Mashaba, Mobi Dixion, kanye nabanye abanengi.

UTshego AMG wagadangisa i-''ulbum'' yakhe yokuthoma ngomnyaka wee-2021 wayibiza ngokuthi yi-Magatara. Enye yeengoma zakhe ezakhamba phambili emrhatjhweni yi-Siyabuswa B.

</text>
      <sha1>rq0hof3frjswhjtm2xagszbezaxa73e</sha1>
    </revision>
  </page>
  <page>
    <title>U-Andries Pretorius</title>
    <ns>0</ns>
    <id>246</id>
    <revision>
      <id>1298</id>
      <timestamp>2024-03-09T10:05:59Z</timestamp>
      <contributor>
        <username>incubator&gt;Mosakaruka</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''U-Andries Wilhelmus Jacobus Pretorius''' wabelethwa ngomhlaka-27 kaSinyikhaba 1798 wahlongakala ngomhlaka-23 kaVelabahlinze 1853. Bekamdosiphambili wamaBhuru embusweni we-ZAR, nembusweni weNatalia Republic, eSewula Afrika. Idorobhokazi elikhulu ebelibizwa ngePretoria esele liyiTshwane lathiyelelwa ngaye.  Udlale indima ekulu ekubumbeni umbuso wamaBhuru we-ZAR begodu usahlonitjhwa babantu bekhabo bekube nje.  &quot;</comment>
      <origin>1298</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="415" sha1="otybizjkrv0s5stdrar10xmm709dk56" xml:space="preserve">'''U-Andries Wilhelmus Jacobus Pretorius''' wabelethwa ngomhlaka-27 kaSinyikhaba 1798 wahlongakala ngomhlaka-23 kaVelabahlinze 1853. Bekamdosiphambili wamaBhuru embusweni we-ZAR, nembusweni weNatalia Republic, eSewula Afrika. Idorobhokazi elikhulu ebelibizwa ngePretoria esele liyiTshwane lathiyelelwa ngaye.

Udlale indima ekulu ekubumbeni umbuso wamaBhuru we-ZAR begodu usahlonitjhwa babantu bekhabo bekube nje.

</text>
      <sha1>otybizjkrv0s5stdrar10xmm709dk56</sha1>
    </revision>
    <revision>
      <id>1299</id>
      <parentid>1298</parentid>
      <timestamp>2024-03-09T10:15:30Z</timestamp>
      <contributor>
        <username>incubator&gt;Mosakaruka</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1299</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="834" sha1="4rtjztphjtam5qb6p532m8bp2jdjone" xml:space="preserve">'''U-Andries Wilhelmus Jacobus Pretorius''' wabelethwa ngomhlaka-27 kaSinyikhaba 1798 wahlongakala ngomhlaka-23 kaVelabahlinze 1853. Bekamdosiphambili wamaBhuru embusweni we-ZAR, nembusweni weNatalia Republic, eSewula Afrika. Idorobhokazi elikhulu ebelibizwa ngePretoria esele liyiTshwane lathiyelelwa ngaye.

Udlale indima ekulu ekubumbeni umbuso wamaBhuru we-ZAR. Nguye obekadosa phambili ekusizeni uMpande wesitjhaba samaZulu ekulweni nomnakwabo uDingane ngo-1840. Ngibo abahlula uDingane ePini yeMaqongqo namkha emlanjeni iBlood River.

Kwakhe kwaba nokungathelelani amanzi phakathi kwakhe u-Andries Pretorius namaNgisi, okwenza waba nyama nambana kibo. Kodwana ngokukhamba kwesikhathi wathoma ukuba netjhebiswano elihle nabo. Wadlala indima ekulu ebantwini abanzima nabamhlophe, begodu usahlonitjhwa babantu bekhabo bekube nje.

</text>
      <sha1>4rtjztphjtam5qb6p532m8bp2jdjone</sha1>
    </revision>
    <revision>
      <id>1300</id>
      <parentid>1299</parentid>
      <timestamp>2024-03-09T10:36:56Z</timestamp>
      <contributor>
        <username>incubator&gt;Mosakaruka</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1300</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1302" sha1="cde092r6vfab34v13e20hq77w9pgt2h" xml:space="preserve">== U-Andries Pretorius ==
[[Isimumathi:Andries Pretorius.jpg|left|frameless|362x362px]]
'''U-Andries Wilhelmus Jacobus Pretorius''' wabelethwa ngomhlaka-27 kaSinyikhaba 1798 wahlongakala ngomhlaka-23 kaVelabahlinze 1853. Bekamdosiphambili wamaBhuru embusweni we-ZAR, nembusweni weNatalia Republic, [[Isewula Afrika|eSewula Afrika]]. Idorobhokazi elikhulu ebelibizwa ngePretoria esele liyiTshwane lathiyelelwa ngaye.

U-[[:en:Andries_Pretorius|Andries Pretorius]] dlale indima ekulu ekubumbeni umbuso wamaBhuru we-ZAR. Nguye obekadosa phambili ekusizeni [[uMpande]] wesitjhaba samaZulu ekulweni nomnakwabo uDingane ngo-1840. Ngibo abahlula [[uDingane]] ePini yeMaqongqo namkha emlanjeni i-[[:en:Blood_River|Blood River]].

Kwakhe kwaba nokungathelelani amanzi phakathi [https://www.sahistory.org.za/people/andries-wilhelmus-jacobus-pretorius-0 kuka-Andries Pretorius namaNgisi], okwenza waba nyama nambana kibo. Kodwana ngokukhamba kwesikhathi wathoma ukuba netjhebiswano elihle nabo. Wadlala indima ekulu ebantwini abanzima nabamhlophe, begodu usahlonitjhwa babantu bekhabo bekube nje.

== Umlando ka-Andries Pretorius ==
U-Andries Jacobus Pretorius wabelethwa ngomhlaka-27 kaSinyikhaba 1798 ayindodana kaMfundisi uWessel Schulte womndeni wakwaPretorius. Wabelethelwa endaweni ehlanu kweGraaff-Reinet.
</text>
      <sha1>cde092r6vfab34v13e20hq77w9pgt2h</sha1>
    </revision>
    <revision>
      <id>1301</id>
      <parentid>1300</parentid>
      <timestamp>2024-03-09T10:44:20Z</timestamp>
      <contributor>
        <username>incubator&gt;Mosakaruka</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>/* Umlando ka-Andries Pretorius */</comment>
      <origin>1301</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1573" sha1="qz9u3b0kx45eswqjonmsoeakhl7qxp5" xml:space="preserve">== U-Andries Pretorius ==
[[Isimumathi:Andries Pretorius.jpg|left|frameless|362x362px]]
'''U-Andries Wilhelmus Jacobus Pretorius''' wabelethwa ngomhlaka-27 kaSinyikhaba 1798 wahlongakala ngomhlaka-23 kaVelabahlinze 1853. Bekamdosiphambili wamaBhuru embusweni we-ZAR, nembusweni weNatalia Republic, [[Isewula Afrika|eSewula Afrika]]. Idorobhokazi elikhulu ebelibizwa ngePretoria esele liyiTshwane lathiyelelwa ngaye.

U-[[:en:Andries_Pretorius|Andries Pretorius]] dlale indima ekulu ekubumbeni umbuso wamaBhuru we-ZAR. Nguye obekadosa phambili ekusizeni [[uMpande]] wesitjhaba samaZulu ekulweni nomnakwabo uDingane ngo-1840. Ngibo abahlula [[uDingane]] ePini yeMaqongqo namkha emlanjeni i-[[:en:Blood_River|Blood River]].

Kwakhe kwaba nokungathelelani amanzi phakathi [https://www.sahistory.org.za/people/andries-wilhelmus-jacobus-pretorius-0 kuka-Andries Pretorius namaNgisi], okwenza waba nyama nambana kibo. Kodwana ngokukhamba kwesikhathi wathoma ukuba netjhebiswano elihle nabo. Wadlala indima ekulu ebantwini abanzima nabamhlophe, begodu usahlonitjhwa babantu bekhabo bekube nje.

== Umlando ka-Andries Pretorius ==
U-Andries Jacobus Pretorius wabelethwa ngomhlaka-27 kaSinyikhaba 1798 ayindodana kaMfundisi uWessel Schulte womndeni wakwaPretorius, asizukulwane sesine sikaJohannes Pretorius. Wabelethelwa endaweni ehlanu kweGraaff-Reinet eKapa. Nanyana imininingwana yepilwakhe ingakanabi kangako, okwaziwako kukobana wakhulela eplasini lekhabo ebelibizwa bona yiDriekoppen. Iplaseli belisetlhagwini-pumalanga yeGraaff-Reinet, likude ngebanga lamakhilomitha ama-40.
</text>
      <sha1>qz9u3b0kx45eswqjonmsoeakhl7qxp5</sha1>
    </revision>
    <revision>
      <id>1302</id>
      <parentid>1301</parentid>
      <timestamp>2024-10-14T13:47:11Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>4 revisions imported</comment>
      <origin>1301</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1573" sha1="qz9u3b0kx45eswqjonmsoeakhl7qxp5" xml:space="preserve">== U-Andries Pretorius ==
[[Isimumathi:Andries Pretorius.jpg|left|frameless|362x362px]]
'''U-Andries Wilhelmus Jacobus Pretorius''' wabelethwa ngomhlaka-27 kaSinyikhaba 1798 wahlongakala ngomhlaka-23 kaVelabahlinze 1853. Bekamdosiphambili wamaBhuru embusweni we-ZAR, nembusweni weNatalia Republic, [[Isewula Afrika|eSewula Afrika]]. Idorobhokazi elikhulu ebelibizwa ngePretoria esele liyiTshwane lathiyelelwa ngaye.

U-[[:en:Andries_Pretorius|Andries Pretorius]] dlale indima ekulu ekubumbeni umbuso wamaBhuru we-ZAR. Nguye obekadosa phambili ekusizeni [[uMpande]] wesitjhaba samaZulu ekulweni nomnakwabo uDingane ngo-1840. Ngibo abahlula [[uDingane]] ePini yeMaqongqo namkha emlanjeni i-[[:en:Blood_River|Blood River]].

Kwakhe kwaba nokungathelelani amanzi phakathi [https://www.sahistory.org.za/people/andries-wilhelmus-jacobus-pretorius-0 kuka-Andries Pretorius namaNgisi], okwenza waba nyama nambana kibo. Kodwana ngokukhamba kwesikhathi wathoma ukuba netjhebiswano elihle nabo. Wadlala indima ekulu ebantwini abanzima nabamhlophe, begodu usahlonitjhwa babantu bekhabo bekube nje.

== Umlando ka-Andries Pretorius ==
U-Andries Jacobus Pretorius wabelethwa ngomhlaka-27 kaSinyikhaba 1798 ayindodana kaMfundisi uWessel Schulte womndeni wakwaPretorius, asizukulwane sesine sikaJohannes Pretorius. Wabelethelwa endaweni ehlanu kweGraaff-Reinet eKapa. Nanyana imininingwana yepilwakhe ingakanabi kangako, okwaziwako kukobana wakhulela eplasini lekhabo ebelibizwa bona yiDriekoppen. Iplaseli belisetlhagwini-pumalanga yeGraaff-Reinet, likude ngebanga lamakhilomitha ama-40.
</text>
      <sha1>qz9u3b0kx45eswqjonmsoeakhl7qxp5</sha1>
    </revision>
  </page>
  <page>
    <title>UKUBA SIDISI USESE NGUMFUNDI</title>
    <ns>0</ns>
    <id>247</id>
    <revision>
      <id>1303</id>
      <timestamp>2024-08-02T16:06:56Z</timestamp>
      <contributor>
        <username>incubator&gt;CdTshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;Abafundi abaningi bazithola basidisi bases se eskolweni begodu basese neminyaka ephasi khulu. Lokho ngikho okwenza abantwana abanengibayekele sikolo begodu baqabange bonyana lokho sinqumo esilungileko. Ba khohlwe kobana yoke indo inemiphumela yakhona,kulapho bazimoshela khona ipilo nempumelelo yabo. Abanengi baphenduka baqhine bathatha indakamizwa lokha abanye bashiya abantwana babona emthola mpilo, abanye bayabalahla, abanye babafaka endlini yangasese lokha abanye bayab...&quot;</comment>
      <origin>1303</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="522" sha1="pf0vx4gmmlea84gt3rzcvw9u04deq69" xml:space="preserve">Abafundi abaningi bazithola basidisi bases se eskolweni begodu basese neminyaka ephasi khulu. Lokho ngikho okwenza abantwana abanengibayekele sikolo begodu baqabange bonyana lokho sinqumo esilungileko.
Ba khohlwe kobana yoke indo inemiphumela yakhona,kulapho bazimoshela khona ipilo nempumelelo yabo. Abanengi baphenduka baqhine bathatha indakamizwa lokha abanye bashiya abantwana babona emthola mpilo, abanye bayabalahla, abanye babafaka endlini yangasese lokha abanye bayaba bulala qabanga nasele ukhipha umphefumulo.U

</text>
      <sha1>pf0vx4gmmlea84gt3rzcvw9u04deq69</sha1>
    </revision>
    <revision>
      <id>1304</id>
      <parentid>1303</parentid>
      <timestamp>2024-08-02T16:47:53Z</timestamp>
      <contributor>
        <username>incubator&gt;CdTshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1304</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="778" sha1="rwdeysm9rt1kfezbqsbsxcm7qwlrkq0" xml:space="preserve">Abafundi abaningi bazithola basidisi bases se eskolweni begodu basese neminyaka ephasi khulu. Lokho ngikho okwenza abantwana abanengibayekele sikolo begodu baqabange bonyana lokho sinqumo esilungileko.
Ba khohlwe kobana yoke indo inemiphumela yakhona,kulapho bazimoshela khona ipilo nempumelelo yabo. Abanengi baphenduka baqhine bathatha indakamizwa lokha abanye bashiya abantwana babona emthola mpilo, abanye bayabalahla, abanye babafaka endlini yangasese lokha abanye bayaba bulala qabanga nasele ukhipha umphefumulo.

Qabanga sele usejele ngebanga lokobana wena ulahle umtwana nofana umbulele. Begodu lokho yikho okwenza abanye abantwana baqhine bahlala endleleni, babhema indakamizwa, bakhamba ba thathela abantu izinto zabo nje ngama bhege, abomaliledinini nokhunye nje. 

</text>
      <sha1>rwdeysm9rt1kfezbqsbsxcm7qwlrkq0</sha1>
    </revision>
    <revision>
      <id>1305</id>
      <parentid>1304</parentid>
      <timestamp>2024-08-14T17:38:20Z</timestamp>
      <contributor>
        <username>incubator&gt;CdTshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1305</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1788" sha1="3nfjjizlj16k8qgzl5pvj7lwx0axwld" xml:space="preserve">Abafundi abaningi bazithola basidisi bases se eskolweni begodu basese neminyaka ephasi khulu. Lokho ngikho okwenza abantwana abanengibayekele sikolo begodu baqabange bonyana lokho sinqumo esilungileko.
Ba khohlwe kobana yoke indo inemiphumela yakhona,kulapho bazimoshela khona ipilo nempumelelo yabo. Abanengi baphenduka baqhine bathatha indakamizwa lokha abanye bashiya abantwana babona emthola mpilo, abanye bayabalahla, abanye babafaka endlini yangasese lokha abanye bayaba bulala qabanga nasele ukhipha umphefumulo.

Qabanga sele usejele ngebanga lokobana wena ulahle umtwana nofana umbulele. Begodu lokho yikho okwenza abanye abantwana baqhine bahlala endleleni, babhema indakamizwa, bakhamba ba thathela abantu izinto zabo nje ngama bhege, abomaliledinini nokhunye nje.iqiniso kukuthi soke isikhathi lesi ba hlala endleleni baqhina baba zinlelesi abanye babo bafela endleleni,abendazana bakhona baba sengozini yokudlengulwa, abanye babo bayathathwa bayo thengisa umzimba kubuhlungu ngombana inengi labo Liya bulawayo lapha ke abanye baba sidisi balahle abentwana babo lapho endleleni.  

Uvele kutholwe kunomtwana okhulela endleleni angazi wa nokuthi ngewaka bani lokhu ke ngikho okwenza bonyana kube nezinga Eli phezulu labantu noma ulusha. Oluhlezi elingasebenziko. Bese u zobona nanoma bamadanisa izinga leli nomhlago khona la e nageni yekhethu. Nje ke kutholakele bonyana nasemthola mpilo Isimo siba buqayi ngebanga lokobana uzothola abodorgodere babona isono kwaye ke baberega nzima. Ngebanga lesimo ebahlangana naso lesi. Yeke Masi ngathi sisese sesikolweni sayenza okufanele, begodu bazimisele emfundweni zabo bayenze okufanele nokuthi bazihloniphe. Begodu babe wumzekelo kwabanye.  

Yeke I pilo le inzima futhi okubudisi khulu kulokha '''uba sidisi usese sesikolweni'''  

</text>
      <sha1>3nfjjizlj16k8qgzl5pvj7lwx0axwld</sha1>
    </revision>
    <revision>
      <id>1306</id>
      <parentid>1305</parentid>
      <timestamp>2024-08-16T19:46:06Z</timestamp>
      <contributor>
        <username>incubator&gt;CdTshabangu</username>
        <id>0</id>
      </contributor>
      <comment>I inserted the pictures</comment>
      <origin>1306</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1877" sha1="h0mrdvefp97p0a50z982vyitxe5z40g" xml:space="preserve">[[Isimumathi:Heartless parents.jpg|thumb]]
Abafundi abaningi bazithola basidisi bases se eskolweni begodu basese neminyaka ephasi khulu. Lokho ngikho okwenza abantwana abanengibayekele sikolo begodu baqabange bonyana lokho sinqumo esilungileko.
Ba khohlwe kobana yoke indo inemiphumela yakhona,kulapho bazimoshela khona ipilo nempumelelo yabo. Abanengi baphenduka baqhine bathatha indakamizwa lokha abanye bashiya abantwana babona emthola mpilo, abanye bayabalahla, abanye babafaka endlini yangasese lokha abanye bayaba bulala qabanga nasele ukhipha umphefumulo.

Qabanga sele usejele ngebanga lokobana wena ulahle umtwana nofana umbulele. Begodu lokho yikho okwenza abanye abantwana baqhine bahlala endleleni, babhema indakamizwa, bakhamba ba thathela abantu izinto zabo nje ngama bhege, abomaliledinini nokhunye nje.iqiniso kukuthi soke isikhathi lesi ba hlala endleleni baqhina baba zinlelesi abanye babo bafela endleleni,abendazana bakhona baba sengozini yokudlengulwa, abanye babo bayathathwa bayo thengisa umzimba kubuhlungu ngombana inengi labo Liya bulawayo lapha ke abanye baba sidisi balahle abentwana babo lapho endleleni.  
[[Isimumathi:Ukulahlwa usese mcane.jpg|thumb]]
Uvele kutholwe kunomtwana okhulela endleleni angazi wa nokuthi ngewaka bani lokhu ke ngikho okwenza bonyana kube nezinga Eli phezulu labantu noma ulusha. Oluhlezi elingasebenziko. Bese u zobona nanoma bamadanisa izinga leli nomhlago khona la e nageni yekhethu. Nje ke kutholakele bonyana nasemthola mpilo Isimo siba buqayi ngebanga lokobana uzothola abodorgodere babona isono kwaye ke baberega nzima. Ngebanga lesimo ebahlangana naso lesi. Yeke Masi ngathi sisese sesikolweni sayenza okufanele, begodu bazimisele emfundweni zabo bayenze okufanele nokuthi bazihloniphe. Begodu babe wumzekelo kwabanye.  

Yeke I pilo le inzima futhi okubudisi khulu kulokha '''uba sidisi usese sesikolweni'''  

</text>
      <sha1>h0mrdvefp97p0a50z982vyitxe5z40g</sha1>
    </revision>
    <revision>
      <id>1307</id>
      <parentid>1306</parentid>
      <timestamp>2024-08-16T20:12:53Z</timestamp>
      <contributor>
        <username>incubator&gt;CdTshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1307</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2391" sha1="ehqxgsgg0u961dnc9ilhdltskfcfxzo" xml:space="preserve">[[Isimumathi:Heartless parents.jpg|thumb]]
Abafundi abaningi bazithola basidisi bases se eskolweni begodu basese neminyaka ephasi khulu. Lokho ngikho okwenza abantwana abanengibayekele sikolo begodu baqabange bonyana lokho sinqumo esilungileko.
Ba khohlwe kobana yoke indo inemiphumela yakhona,kulapho bazimoshela khona ipilo nempumelelo yabo. Abanengi baphenduka baqhine bathatha indakamizwa lokha abanye bashiya abantwana babona emthola mpilo, abanye bayabalahla, abanye babafaka endlini yangasese lokha abanye bayaba bulala qabanga nasele ukhipha umphefumulo.

Qabanga sele usejele ngebanga lokobana wena ulahle umtwana nofana umbulele. Begodu lokho yikho okwenza abanye abantwana baqhine bahlala endleleni, babhema indakamizwa, bakhamba ba thathela abantu izinto zabo nje ngama bhege, abomaliledinini no7khunye nje.iqiniso kukuthi soke isikhathi lesi ba hlala endleleni baqhina baba zinlelesi abanye babo bafela endleleni,abendazana bakhona baba sengozini yokudlengulwa, abanye babo bayathathwa bayo thengisa umzimba kubuhlungu ngombana inengi labo Liya bulawayo lapha ke abanye baba sidisi balahle abentwana babo lapho endleleni.  
[[Isimumathi:Ukulahlwa usese mcane.jpg|thumb]]
Uvele kutholwe kunomtwana okhulela endleleni angazi wa nokuthi ngewaka bani lokhu ke ngikho okwenza bonyana kube nezinga Eli phezulu labantu noma ulusha. Oluhlezi elingasebenziko. Bese u zobona nanoma bamadanisa izinga leli nomhlago khona la e nageni yekhethu. Nje ke kutholakele bonyana nasemthola mpilo Isimo siba buqayi ngebanga lokobana uzothola abodorgodere babona isono kwaye ke baberega nzima. Ngebanga lesimo ebahlangana naso lesi. Yeke Masi ngathi sisese sesikolweni sayenza okufanele, begodu bazimisele emfundweni zabo bayenze okufanele nokuthi bazihloniphe. Begodu babe wumzekelo kwabanye.  

Yeke I pilo le inzima futhi okubudisi khulu ku, lokha '''sesikolweniusese sesikolweni, qabanga kumele ube ngunama womtwana usese ngumtwana kwa wena. Uzithole usehlazweni nje ngoba nawe ufake abazali bakho ehlazweni ipilo inzima khulu lokha makumeke uzigade khulu begodu uqhine ungasazi kobana uyenza kumbi namkana kuhle na.''' 

Zibuze bonyana kwenzakalani kulabantwana naba khula, yini into efika enqondweni zabo, bathi kwenzakeleni ngabazali babo na?. Umdeni wabo ukuphi? Benzeni engaka kulomhlaba?. Yini ehle ebazoyiqabanga? Ipilo inzima khulu maulahliwe begodu ungazi bonyana uzothi mma kubani.   

</text>
      <sha1>ehqxgsgg0u961dnc9ilhdltskfcfxzo</sha1>
    </revision>
    <revision>
      <id>1308</id>
      <parentid>1307</parentid>
      <timestamp>2024-08-16T20:27:33Z</timestamp>
      <contributor>
        <username>incubator&gt;CdTshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Edition</comment>
      <origin>1308</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2483" sha1="dv70dq4k9m90zw9dcn85esxl71y0o42" xml:space="preserve">[[Isimumathi:Heartless parents.jpg|thumb]]
Abafundi abaningi bazithola basidisi basese se bafundi begodu basese neminyaka ephasi khulu kuqala emnyakeni Eli itjhumi nantathu . Lokho ngikho okwenza abantwana abanengibayekele isikolo begodu baqabange bonyana lokho sinqumo esilungileko.Ba khohlwe kobana yoke indo inemiphumela yakhona,kulapho bazimoshela khona ipilo nempumelelo yabo. Abanengi baphenduka baqhine bathatha indakamizwa lokha abanye bashiya abantwana babo emthola mpilo, abanye bayabalahla, abanye babafaka endlini yangasese lokha abanye bayaba bulala qabanga nasele ukhipha umphefumulo ongana qala. 

Qabanga sele usejele ngebanga lokobana wena ulahle umtwana nofana umbulele. Begodu lokho yikho okwenza abanye abantwana baqhine bahlala endleleni, babhema indakamizwa, bakhamba ba thathela abantu izinto zabo nje ngama bhege, abomaliledinini nokhunye nje.iqiniso kukuthi soke isikhathi lesi ba hlala endleleni baqhina baba zinlelesi abanye babo bafela endleleni,abendazana bakhona baba sengozini yokudlengulwa, abanye babo bayathathwa bayo thengisa umzimba kubuhlungu ngombana inengi labo Liya bulawayo lapha ke abanye baba sidisi balahle abentwana babo lapho en  

dleleni.  
[[Isimumathi:Ukulahlwa usese mcane.jpg|thumb]]
Kuvele kutholwe kunomtwana okhulela endleleni angaziwa bonyana ngewaka bani lokhu ke ngikho okwenza bonyana kube nezinga Eli phezulu labantu noma ulusha. Oluhlezi elingasebenziko. Bese u zobona nanoma bamadanisa izinga leli nomhlago khona la e narheni yekhethu. Nje ke kutholakele bonyana nasemthola mpilo Isimo siba buqayi ngebanga lokobana uzothola abodorhodere babona isono kwaye ke baberega nzima. Ngebanga lesimo ebahlangana naso lesi. Yeke Masi ngathi sisese sesikolweni sayenza okufanele, begodu bazimisele emfundweni zabo bayenze okufanele nokuthi bazihloniphe. Begodu babe wumzekelo kwabanye.  

Yeke I pilo le inzima futhi okubudisi khulu ku, lokha '''sesikolweniusese sesikolweni, qabanga kumele ube ngunama womtwana usese ngumtwana kwa wena. Uzithole usehlazweni nje ngoba nawe ufake abazali bakho ehlazweni ipilo inzima khulu lokha makumeke uzigade khulu begodu uqhine ungasazi kobana uyenza kumbi namkana kuhle na.''' 

Zibuze bonyana kwenzakalani kulabantwana naba khula, yini into efika enqondweni zabo, bathi kwenzakeleni ngabazali babo na?. Umdeni wabo ukuphi? Benzeni engaka kulomhlaba?. Yini ehle ebazoyiqabanga? Ipilo inzima khulu maulahliwe begodu ungazi bonyana uzothi mma kubani.   

'''UKUBA SIDISI USESE NGUMFUNDI'''   

</text>
      <sha1>dv70dq4k9m90zw9dcn85esxl71y0o42</sha1>
    </revision>
    <revision>
      <id>1309</id>
      <parentid>1308</parentid>
      <timestamp>2024-08-16T20:43:33Z</timestamp>
      <contributor>
        <username>incubator&gt;CdTshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1309</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2481" sha1="1oz5kve5w0je6wa3goz00jle3agxjj9" xml:space="preserve">[[Isimumathi:Heartless parents.jpg|thumb]]
Abafundi abaningi bazithola basidisi basese  bafundi begodu basese neminyaka ephasi khulu kuqala emnyakeni Eli itjhumi nantathu . Lokho ngikho okwenza abantwana abanengibayekele isikolo begodu baqabange bonyana lokho sinqumo esilungileko.Ba khohlwe kobana yoke indo inemiphumela yakhona,kulapho bazimoshela khona ipilo nempumelelo yabo. Abanengi baphenduka baqhine bathatha indakamizwa lokha abanye bashiya abantwana babo emthola mpilo, abanye bayabalahla, abanye babafaka endlini yangasese lokha abanye bayaba bulala qabanga nasele ukhipha umphefumulo ongana qala. 

Qabanga sele usejele ngebanga lokobana wena ulahle umtwana nofana umbulele. Begodu lokho yikho okwenza abanye abantwana baqhine bahlala endleleni, babhema indakamizwa, bakhamba ba thathela abantu izinto zabo nje ngama bhege, abomaliledinini nokhunye nje.iqiniso kukuthi soke isikhathi lesi ba hlala endleleni baqhina baba zinlelesi abanye babo bafela endleleni,abendazana bakhona baba sengozini yokudlengulwa, abanye babo bayathathwa bayo thengisa umzimba kubuhlungu ngombana inengi labo Liya bulawayo lapha ke abanye baba sidisi balahle abentwana babo lapho en  

dleleni.  
[[Isimumathi:Ukulahlwa usese mcane.jpg|thumb]]
Kuvele kutholwe kunomtwana okhulela endleleni angaziwa bonyana ngewaka bani lokhu ke ngikho okwenza bonyana kube nezinga Eli phezulu labantu noma ulusha. Oluhlezi elingasebenziko. Bese u zobona nanoma bamadanisa izinga leli nomhlago khona la e narheni yekhethu. Nje ke kutholakele bonyana nasemthola mpilo Isimo siba buqayi ngebanga lokobana uzothola abodorhodere babona isono kwaye ke baberega nzima. Ngebanga lesimo ebahlangana naso lesi. Yeke Masi ngathi sisese sesikolweni sayenza okufanele, begodu bazimisele emfundweni zabo bayenze okufanele nokuthi bazihloniphe. Begodu babe wumzekelo kwabanye.  

Yeke I pilo le inzima futhi okubudisi khulu ku, lokha '''sesikolweniusese sesikolweni, qabanga kumele ube ngunama womtwana usese ngumtwana kwa wena. Uzithole usehlazweni nje ngoba nawe ufake abazali bakho ehlazweni ipilo inzima khulu lokha makumeke uzigade khulu begodu uqhine ungasazi kobana uyenza kumbi namkana kuhle na.''' 

Zibuze bonyana kwenzakalani kulabantwana naba khula, yini into efika enqondweni zabo, bathi kwenzakeleni ngabazali babo na?. Umdeni wabo ukuphi? Benzeni engaka kulomhlaba?. Yini ehle ebazoyiqabanga? Ipilo inzima khulu maulahliwe begodu ungazi bonyana uzothi mma kubani.   

'''UKUBA SIDISI USESE NGUMFUNDI'''   

</text>
      <sha1>1oz5kve5w0je6wa3goz00jle3agxjj9</sha1>
    </revision>
    <revision>
      <id>1310</id>
      <parentid>1309</parentid>
      <timestamp>2024-08-16T21:39:47Z</timestamp>
      <contributor>
        <username>incubator&gt;CdTshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1310</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2478" sha1="8rzo0qhjs5lt57x3u7ccxhqbundtdlm" xml:space="preserve">[[Isimumathi:Heartless parents.jpg|thumb]]
Abafundi abanengi bazithola basidisi basese  bafundi begodu basese neminyaka ephasi khulu kuthoma emnyakeni Eli itjhumi nantathu . Lokho ngikho okwenza abentwana abanengi balise isikolo begodu badlumbane bonyana lokho sinqumo esilungileko.Balibale kobana yoke into inemiphumela yakhona,kulapho bazimotjhela khona ipilo nepumelelo yabo. Abanengi baphenduka baqhine bathatha iindakamizwa lokha abanye batjhiya abentwana babo emtholapilo, abanye bayabalahla, abanye babafaka endlini yangaseha abanye bayaba bulala qabanga nasele ukhipha umphefumulo ongana qala. 

Qabanga sele usejele ngebanga lokobana wena ulahle umtwana nofana umbuleng. Begodu lokho ngikho okwenza abanye abentwana bacgine bahlala endleleni, babhema iindakamizwa, bakhamba ba thathela abantunzinto zabo nje ngenkhwama, abomaliledinini nokhunye okunengi .iqiniso kukuthi soke isikhathi lesi ba hlezi endleleni bagcina baba zinlelesi abanye babo babhubhela endleleni,abentazana bakhona baba sengozini yokudlengulwa, abanye babo bayathathwa bayo thengisa umzimba kubuhlungu ngombana inengi labo Liya bulawa, lapha ke abanye baba sidisi balahle abentwana babo lapho en  

dleleni.  
[[Isimumathi:Ukulahlwa usese mcane.jpg|thumb]]
Kuvele kutholwe kunomtwana okhulela endleleni angaziwa bonyana ngewaka bani lokhu ke ngikho okwenza bonyana kube nezinga Eli phulu labantu nofana ilutjha Oluhlezi elingasebenziko. Bese u zobona nanoma bamadanisa izinga leli nomtlhago khona la e narheni yekhethu. Nje ke kutholakele bonyana nasemtholapilo ubujamo buba buqwayi ngebanga lokobana uzothola abodorhodere babona isono kwaye ke baberega nzima. Ngebanga lesimo ebahlangabezana naso lesi. Yeke Masi ngathi sisese sesikolweni sanza okufanele, begodu bazimisele emfundweni zabo banze okufanele nokuthi bazihloniphe. Begodu babe mzekelo kwabanye.  

Yeke I pilo le ibudisi godu okubudisi kulokha nawu sese '''sesikolweni, dlumbana nakosele  ube ngunina lomtwana usese mtwana kwa wena. Uzithole usehlazweni nje ngoba nawe ufake abazali bakho ehlazweni ipilo inzima khulu lokha nakosele uzitlhogomele khulu begodu ugcine ungasazi kobana wenze kumbi namkana kuhle na.''' 

Zibuze bonyana kwenzakalani kulabantwana naba khula, yini into efika emkhumbulweni wabo bathi kwenzakeleni ngabazali babo na?. Umdeni wabo ukuphi? Benzeni engaka ephasinapha?. Yini ehle ebazoyiqabanga? Ipilo inzima khulu mawulahliwe begodu ungazi bonyana uzothi mma kubani.   

'''UKUBA SIDISI USESE NGUMFUNDI'''   

</text>
      <sha1>8rzo0qhjs5lt57x3u7ccxhqbundtdlm</sha1>
    </revision>
    <revision>
      <id>1311</id>
      <parentid>1310</parentid>
      <timestamp>2024-08-17T03:54:52Z</timestamp>
      <contributor>
        <username>incubator&gt;CommonsDelinker</username>
        <id>0</id>
      </contributor>
      <comment>Removing &quot;Ukulahlwa_usese_mcane.jpg&quot;, it has been deleted from Commons by [[commons:User:The Squirrel Conspiracy|The Squirrel Conspiracy]] because: Copyright violation; see [[:c:Commons:Licensing|]] ([[:c:COM:CSD#F1|F1]]): Source 	On the internet Author</comment>
      <origin>1311</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2431" sha1="fhifzlf5atatvxvbyv32noobqce7mht" xml:space="preserve">[[Isimumathi:Heartless parents.jpg|thumb]]
Abafundi abanengi bazithola basidisi basese  bafundi begodu basese neminyaka ephasi khulu kuthoma emnyakeni Eli itjhumi nantathu . Lokho ngikho okwenza abentwana abanengi balise isikolo begodu badlumbane bonyana lokho sinqumo esilungileko.Balibale kobana yoke into inemiphumela yakhona,kulapho bazimotjhela khona ipilo nepumelelo yabo. Abanengi baphenduka baqhine bathatha iindakamizwa lokha abanye batjhiya abentwana babo emtholapilo, abanye bayabalahla, abanye babafaka endlini yangaseha abanye bayaba bulala qabanga nasele ukhipha umphefumulo ongana qala. 

Qabanga sele usejele ngebanga lokobana wena ulahle umtwana nofana umbuleng. Begodu lokho ngikho okwenza abanye abentwana bacgine bahlala endleleni, babhema iindakamizwa, bakhamba ba thathela abantunzinto zabo nje ngenkhwama, abomaliledinini nokhunye okunengi .iqiniso kukuthi soke isikhathi lesi ba hlezi endleleni bagcina baba zinlelesi abanye babo babhubhela endleleni,abentazana bakhona baba sengozini yokudlengulwa, abanye babo bayathathwa bayo thengisa umzimba kubuhlungu ngombana inengi labo Liya bulawa, lapha ke abanye baba sidisi balahle abentwana babo lapho en  

dleleni.  
Kuvele kutholwe kunomtwana okhulela endleleni angaziwa bonyana ngewaka bani lokhu ke ngikho okwenza bonyana kube nezinga Eli phulu labantu nofana ilutjha Oluhlezi elingasebenziko. Bese u zobona nanoma bamadanisa izinga leli nomtlhago khona la e narheni yekhethu. Nje ke kutholakele bonyana nasemtholapilo ubujamo buba buqwayi ngebanga lokobana uzothola abodorhodere babona isono kwaye ke baberega nzima. Ngebanga lesimo ebahlangabezana naso lesi. Yeke Masi ngathi sisese sesikolweni sanza okufanele, begodu bazimisele emfundweni zabo banze okufanele nokuthi bazihloniphe. Begodu babe mzekelo kwabanye.  

Yeke I pilo le ibudisi godu okubudisi kulokha nawu sese '''sesikolweni, dlumbana nakosele  ube ngunina lomtwana usese mtwana kwa wena. Uzithole usehlazweni nje ngoba nawe ufake abazali bakho ehlazweni ipilo inzima khulu lokha nakosele uzitlhogomele khulu begodu ugcine ungasazi kobana wenze kumbi namkana kuhle na.''' 

Zibuze bonyana kwenzakalani kulabantwana naba khula, yini into efika emkhumbulweni wabo bathi kwenzakeleni ngabazali babo na?. Umdeni wabo ukuphi? Benzeni engaka ephasinapha?. Yini ehle ebazoyiqabanga? Ipilo inzima khulu mawulahliwe begodu ungazi bonyana uzothi mma kubani.   

'''UKUBA SIDISI USESE NGUMFUNDI'''   

</text>
      <sha1>fhifzlf5atatvxvbyv32noobqce7mht</sha1>
    </revision>
    <revision>
      <id>1312</id>
      <parentid>1311</parentid>
      <timestamp>2024-08-17T03:55:01Z</timestamp>
      <contributor>
        <username>incubator&gt;CommonsDelinker</username>
        <id>0</id>
      </contributor>
      <comment>Removing &quot;Heartless_parents.jpg&quot;, it has been deleted from Commons by [[commons:User:The Squirrel Conspiracy|The Squirrel Conspiracy]] because: Source 	On the internet Author 	Unknown author.</comment>
      <origin>1312</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2388" sha1="tv94ie8u3cb9du44qazkml5rtebrgtg" xml:space="preserve">Abafundi abanengi bazithola basidisi basese  bafundi begodu basese neminyaka ephasi khulu kuthoma emnyakeni Eli itjhumi nantathu . Lokho ngikho okwenza abentwana abanengi balise isikolo begodu badlumbane bonyana lokho sinqumo esilungileko.Balibale kobana yoke into inemiphumela yakhona,kulapho bazimotjhela khona ipilo nepumelelo yabo. Abanengi baphenduka baqhine bathatha iindakamizwa lokha abanye batjhiya abentwana babo emtholapilo, abanye bayabalahla, abanye babafaka endlini yangaseha abanye bayaba bulala qabanga nasele ukhipha umphefumulo ongana qala. 

Qabanga sele usejele ngebanga lokobana wena ulahle umtwana nofana umbuleng. Begodu lokho ngikho okwenza abanye abentwana bacgine bahlala endleleni, babhema iindakamizwa, bakhamba ba thathela abantunzinto zabo nje ngenkhwama, abomaliledinini nokhunye okunengi .iqiniso kukuthi soke isikhathi lesi ba hlezi endleleni bagcina baba zinlelesi abanye babo babhubhela endleleni,abentazana bakhona baba sengozini yokudlengulwa, abanye babo bayathathwa bayo thengisa umzimba kubuhlungu ngombana inengi labo Liya bulawa, lapha ke abanye baba sidisi balahle abentwana babo lapho en  

dleleni.  
Kuvele kutholwe kunomtwana okhulela endleleni angaziwa bonyana ngewaka bani lokhu ke ngikho okwenza bonyana kube nezinga Eli phulu labantu nofana ilutjha Oluhlezi elingasebenziko. Bese u zobona nanoma bamadanisa izinga leli nomtlhago khona la e narheni yekhethu. Nje ke kutholakele bonyana nasemtholapilo ubujamo buba buqwayi ngebanga lokobana uzothola abodorhodere babona isono kwaye ke baberega nzima. Ngebanga lesimo ebahlangabezana naso lesi. Yeke Masi ngathi sisese sesikolweni sanza okufanele, begodu bazimisele emfundweni zabo banze okufanele nokuthi bazihloniphe. Begodu babe mzekelo kwabanye.  

Yeke I pilo le ibudisi godu okubudisi kulokha nawu sese '''sesikolweni, dlumbana nakosele  ube ngunina lomtwana usese mtwana kwa wena. Uzithole usehlazweni nje ngoba nawe ufake abazali bakho ehlazweni ipilo inzima khulu lokha nakosele uzitlhogomele khulu begodu ugcine ungasazi kobana wenze kumbi namkana kuhle na.''' 

Zibuze bonyana kwenzakalani kulabantwana naba khula, yini into efika emkhumbulweni wabo bathi kwenzakeleni ngabazali babo na?. Umdeni wabo ukuphi? Benzeni engaka ephasinapha?. Yini ehle ebazoyiqabanga? Ipilo inzima khulu mawulahliwe begodu ungazi bonyana uzothi mma kubani.   

'''UKUBA SIDISI USESE NGUMFUNDI'''   

</text>
      <sha1>tv94ie8u3cb9du44qazkml5rtebrgtg</sha1>
    </revision>
    <revision>
      <id>1313</id>
      <parentid>1312</parentid>
      <timestamp>2024-10-14T13:47:11Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>10 revisions imported</comment>
      <origin>1312</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2388" sha1="tv94ie8u3cb9du44qazkml5rtebrgtg" xml:space="preserve">Abafundi abanengi bazithola basidisi basese  bafundi begodu basese neminyaka ephasi khulu kuthoma emnyakeni Eli itjhumi nantathu . Lokho ngikho okwenza abentwana abanengi balise isikolo begodu badlumbane bonyana lokho sinqumo esilungileko.Balibale kobana yoke into inemiphumela yakhona,kulapho bazimotjhela khona ipilo nepumelelo yabo. Abanengi baphenduka baqhine bathatha iindakamizwa lokha abanye batjhiya abentwana babo emtholapilo, abanye bayabalahla, abanye babafaka endlini yangaseha abanye bayaba bulala qabanga nasele ukhipha umphefumulo ongana qala. 

Qabanga sele usejele ngebanga lokobana wena ulahle umtwana nofana umbuleng. Begodu lokho ngikho okwenza abanye abentwana bacgine bahlala endleleni, babhema iindakamizwa, bakhamba ba thathela abantunzinto zabo nje ngenkhwama, abomaliledinini nokhunye okunengi .iqiniso kukuthi soke isikhathi lesi ba hlezi endleleni bagcina baba zinlelesi abanye babo babhubhela endleleni,abentazana bakhona baba sengozini yokudlengulwa, abanye babo bayathathwa bayo thengisa umzimba kubuhlungu ngombana inengi labo Liya bulawa, lapha ke abanye baba sidisi balahle abentwana babo lapho en  

dleleni.  
Kuvele kutholwe kunomtwana okhulela endleleni angaziwa bonyana ngewaka bani lokhu ke ngikho okwenza bonyana kube nezinga Eli phulu labantu nofana ilutjha Oluhlezi elingasebenziko. Bese u zobona nanoma bamadanisa izinga leli nomtlhago khona la e narheni yekhethu. Nje ke kutholakele bonyana nasemtholapilo ubujamo buba buqwayi ngebanga lokobana uzothola abodorhodere babona isono kwaye ke baberega nzima. Ngebanga lesimo ebahlangabezana naso lesi. Yeke Masi ngathi sisese sesikolweni sanza okufanele, begodu bazimisele emfundweni zabo banze okufanele nokuthi bazihloniphe. Begodu babe mzekelo kwabanye.  

Yeke I pilo le ibudisi godu okubudisi kulokha nawu sese '''sesikolweni, dlumbana nakosele  ube ngunina lomtwana usese mtwana kwa wena. Uzithole usehlazweni nje ngoba nawe ufake abazali bakho ehlazweni ipilo inzima khulu lokha nakosele uzitlhogomele khulu begodu ugcine ungasazi kobana wenze kumbi namkana kuhle na.''' 

Zibuze bonyana kwenzakalani kulabantwana naba khula, yini into efika emkhumbulweni wabo bathi kwenzakeleni ngabazali babo na?. Umdeni wabo ukuphi? Benzeni engaka ephasinapha?. Yini ehle ebazoyiqabanga? Ipilo inzima khulu mawulahliwe begodu ungazi bonyana uzothi mma kubani.   

'''UKUBA SIDISI USESE NGUMFUNDI'''   

</text>
      <sha1>tv94ie8u3cb9du44qazkml5rtebrgtg</sha1>
    </revision>
    <revision>
      <id>2414</id>
      <parentid>1313</parentid>
      <timestamp>2025-02-16T13:00:08Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>2414</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2388" sha1="557t1gjm36z11s66bn0dznsiaj9ewye" xml:space="preserve">Abafundi abanengi bazithola basidisi basese  bafundi begodu basese neminyaka ephasi khulu kuthoma emnyakeni Eli itjhumi nantathu . Lokho ngikho okwenza abentwana abanengi balise isikolo begodu badlumbane bonyana lokho sicunto esilungileko.Balibale kobana yoke into inemiphumela yakhona,kulapho bazimotjhela khona ipilo nepumelelo yabo. Abanengi baphenduka bagcine bathatha iindakamizwa lokha abanye batjhiya abentwana babo emtholapilo, abanye bayabalahla, abanye babafaka endlini yangaseha abanye bayaba bulala qabanga nasele ukhipha umphefumulo ongana qala. 

Qabanga sele usejele ngebanga lokobana wena ulahle umtwana nofana umbulele. Be Lokho ngikho okwenza abanye abentwana bacgine bahlala endleleni, babhema iindakamizwa, bakhamba ba thathela abantu izinto zabo nje ngenkhwama, abomaliledinini nokhunye okunengi . Iqiniso kukuthi soke isikhathi lesi ba hlezi endleleni bagcina baba zinlelesi abanye babo babhubhela endleleni, abentazana bakhona baba sengozini yokuhlukunyezwa ngokomseme, abanye babo bayathathwa bayo thengisa umzimba kubuhlungu ngombana inengi labo liya bulawa, lapha ke abanye baba sidisi balahle abentwana babo lapho endleleni.    

Kuvele kutholwe kunomtwana okhulela endleleni angaziwa bonyana ngewaka bani lokhu ke ngikho okwenza bonyana kube nezinga eli phulu labantu nofana ilutjha eluhlezi elingasebenziko. Bese u zobona nanoma bamadanisa izinga leli nomtlhago khona la e narheni yekhethu. Nje ke kutholakele bonyana nasemtholapilo ubujamo buba buqwayi ngebanga lokobana uzothola abodorhodere babona isono kwaye ke baberega nzima. Ngebanga lesimo ebahlangabezana naso lesi. Yeke Nasi ngathi sisese sesikolweni sanza okufanele, begodu bazimisele emfundweni zabo banze okufanele nokuthi bazihloniphe. Begodu babe mzekelo kwabanye.  

Yeke I pilo le ibudisi godu okubudisi kulokha nawu sese sesikolweni, dlumbana nakosele  ube ngunina lomtwana usese mtwana kwa wena. Uzithole usehlazweni nje ngoba nawe ufake abazali bakho ehlazweni ipilo inzima khulu lokha nakosele uzitlhogomele khulu begodu ugcine ungasazi kobana wenze kumbi namkana kuhle na. 

Zibuze bonyana kwenzakalani kulabantwana naba khula, yini into efika emkhumbulweni wabo bathi kwenzakeleni ngabazali babo na?. Umdeni wabo ukuphi? Benzeni engaka ephasinapha?. Yini ehle ebazoyiqabanga? Ipilo inzima khulu mawulahliwe begodu ungazi bonyana uzothi mma kubani.   

'''UKUBA SIDISI USESE NGUMFUNDI'''</text>
      <sha1>557t1gjm36z11s66bn0dznsiaj9ewye</sha1>
    </revision>
  </page>
  <page>
    <title>UNzunza no Manala</title>
    <ns>0</ns>
    <id>248</id>
    <revision>
      <id>1314</id>
      <timestamp>2024-06-25T16:25:35Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;UNzunza noManala bebabantwana bomuntu. uManala bekangowangendlini ekulu begodu uNzunza bekungowaka mani. Nakubhubha iqhegu uMusi unguyise wabo kwaba khonaukubangwa kobukhosi. Isalukazi ngiso esabanga umbango lo. Ngombana isalukazi salalela uMusi nakatjela uManala bona ubukhosi.  &quot;</comment>
      <origin>1314</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="280" sha1="0xm01bm2wq88trmexvamthfru8pov5w" xml:space="preserve">UNzunza noManala bebabantwana bomuntu. uManala bekangowangendlini ekulu begodu uNzunza bekungowaka mani. Nakubhubha iqhegu uMusi unguyise wabo kwaba khonaukubangwa kobukhosi. Isalukazi ngiso esabanga umbango lo. Ngombana isalukazi salalela uMusi nakatjela uManala bona ubukhosi.

</text>
      <sha1>0xm01bm2wq88trmexvamthfru8pov5w</sha1>
    </revision>
    <revision>
      <id>1315</id>
      <parentid>1314</parentid>
      <timestamp>2024-06-25T16:26:18Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1315</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="284" sha1="gu8ajyrfw20cpgdogg67e9crfqkun75" xml:space="preserve">[[UNzunza noManala]] bebabantwana bomuntu. uManala bekangowangendlini ekulu begodu uNzunza bekungowaka mani. Nakubhubha iqhegu uMusi unguyise wabo kwaba khonaukubangwa kobukhosi. Isalukazi ngiso esabanga umbango lo. Ngombana isalukazi salalela uMusi nakatjela uManala bona ubukhosi.

</text>
      <sha1>gu8ajyrfw20cpgdogg67e9crfqkun75</sha1>
    </revision>
    <revision>
      <id>1316</id>
      <parentid>1315</parentid>
      <timestamp>2024-06-25T16:38:29Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1316</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="651" sha1="gv2fi86ehb3hudsjji31v0k0a37wyjm" xml:space="preserve">[[UNzunza noManala|'''UNzunza noManala''']] bebabantwana bomuntu. uManala bekangowangendlini ekulu begodu uNzunza bekungowaka mani. Nakubhubha iqhegu uMusi unguyise wabo kwaba khonaukubangwa kobukhosi. Isalukazi ngiso esabanga umbango lo. Ngombana isalukazi salalela uMusi nakatjela uManala bona ubukhosi. Satjela Nzunza bona kufanele aye phambi kukaManala bonyana ayoku that izinto zobukhosi.  uNzunza weba ubukhosi bukaManala, bewanikelwa izinto zobukhosi. UManala watho;a sele ubukhosi buthethwe. UNzunza wabaleka watjhinga tjhuba lePumalanga. bathi lokha nabamgijimisako babathola selel sebaseMasongololo. yahlangana  khona ipi Nzunza noManala.


</text>
      <sha1>gv2fi86ehb3hudsjji31v0k0a37wyjm</sha1>
    </revision>
    <revision>
      <id>1317</id>
      <parentid>1316</parentid>
      <timestamp>2024-10-14T13:47:11Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>1316</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="651" sha1="gv2fi86ehb3hudsjji31v0k0a37wyjm" xml:space="preserve">[[UNzunza noManala|'''UNzunza noManala''']] bebabantwana bomuntu. uManala bekangowangendlini ekulu begodu uNzunza bekungowaka mani. Nakubhubha iqhegu uMusi unguyise wabo kwaba khonaukubangwa kobukhosi. Isalukazi ngiso esabanga umbango lo. Ngombana isalukazi salalela uMusi nakatjela uManala bona ubukhosi. Satjela Nzunza bona kufanele aye phambi kukaManala bonyana ayoku that izinto zobukhosi.  uNzunza weba ubukhosi bukaManala, bewanikelwa izinto zobukhosi. UManala watho;a sele ubukhosi buthethwe. UNzunza wabaleka watjhinga tjhuba lePumalanga. bathi lokha nabamgijimisako babathola selel sebaseMasongololo. yahlangana  khona ipi Nzunza noManala.


</text>
      <sha1>gv2fi86ehb3hudsjji31v0k0a37wyjm</sha1>
    </revision>
    <revision>
      <id>6688</id>
      <parentid>1317</parentid>
      <timestamp>2026-06-12T07:21:09Z</timestamp>
      <contributor>
        <username>MissHadassah</username>
        <id>1561</id>
      </contributor>
      <minor />
      <comment>the spelling of the name</comment>
      <origin>6688</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="652" sha1="7xsp4keg8i0g8uy5556wypr88migefs" xml:space="preserve">[[UNzunza noManala|'''UNdzundza noManala''']] bebabantwana bomuntu. uManala bekangowangendlini ekulu begodu uNdzundza bekungowaka mani. Nakubhubha iqhegu uMusi unguyise wabo kwaba khonaukubangwa kobukhosi. Isalukazi ngiso esabanga umbango lo. Ngombana isalukazi salalela uMusi nakatjela uManala bona ubukhosi. Satjela Nzunza bona kufanele aye phambi kukaManala bonyana ayoku that izinto zobukhosi.  uNzunza weba ubukhosi bukaManala, bewanikelwa izinto zobukhosi. UManala watho;a sele ubukhosi buthethwe. UNzunza wabaleka watjhinga tjhuba lePumalanga. bathi lokha nabamgijimisako babathola selel sebaseMasongololo. yahlangana  khona ipi Nzunza noManala.</text>
      <sha1>7xsp4keg8i0g8uy5556wypr88migefs</sha1>
    </revision>
    <revision>
      <id>6689</id>
      <parentid>6688</parentid>
      <timestamp>2026-06-12T07:23:37Z</timestamp>
      <contributor>
        <username>MissHadassah</username>
        <id>1561</id>
      </contributor>
      <minor />
      <comment>changed the spelling of a name</comment>
      <origin>6689</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="656" sha1="h4725x2v9f756k400ny2l75n10a2tsg" xml:space="preserve">[[UNzunza noManala|'''UNdzundza noManala''']] bebabantwana bomuntu. uManala bekangowangendlini ekulu begodu uNdzundza bekungowaka mani. Nakubhubha iqhegu uMusi unguyise wabo kwaba khonaukubangwa kobukhosi. Isalukazi ngiso esabanga umbango lo. Ngombana isalukazi salalela uMusi nakatjela uManala bona ubukhosi. Satjela Ndzundza bona kufanele aye phambi kukaManala bonyana ayoku  izinto zobukhosi.  uNdzundza weba ubukhosi bukaManala, bewanikelwa izinto zobukhosi. UManala watho;a sele ubukhosi buthethwe. UNdzundza wabaleka watjhinga tjhuba lePumalanga. bathi lokha nabamgijimisako babathola selel sebaseMasongololo. yahlangana  khona ipi Ndzundza noManala.</text>
      <sha1>h4725x2v9f756k400ny2l75n10a2tsg</sha1>
    </revision>
  </page>
  <page>
    <title>Ubukresite</title>
    <ns>0</ns>
    <id>249</id>
    <revision>
      <id>1318</id>
      <timestamp>2024-07-08T09:16:46Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Ubukreste''' yindlela yokukholwa ulandela uKristu bonyana abe yikosi nomsindisi wepilo yakho. Abantu abamaKristu nabo bahlukile ngokuya kwamasonto wabo. Abantu abama kristu basebenzisa ibhayibhili njengomtlolo obakhuthaza nobafundisa ngoZimu.&quot;</comment>
      <origin>1318</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="245" sha1="2sravogpnajb3k9dmj8q16ky98p83zz" xml:space="preserve">'''Ubukreste''' yindlela yokukholwa ulandela uKristu bonyana abe yikosi nomsindisi wepilo yakho. Abantu abamaKristu nabo bahlukile ngokuya kwamasonto wabo. Abantu abama kristu basebenzisa ibhayibhili njengomtlolo obakhuthaza nobafundisa ngoZimu.</text>
      <sha1>2sravogpnajb3k9dmj8q16ky98p83zz</sha1>
    </revision>
    <revision>
      <id>1319</id>
      <parentid>1318</parentid>
      <timestamp>2024-07-08T09:17:56Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1319</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="249" sha1="0s4qyb9tuofnaxf0zuvp6z450n8187t" xml:space="preserve">'''Ubukreste''' yindlela yokukholwa ulandela uKristu bonyana abe yikosi nomsindisi wepilo yakho. Abantu abamaKristu nabo bahlukile ngokuya kwamasonto wabo. Abantu abama kristu basebenzisa [[ibhayibhili]] njengomtlolo obakhuthaza nobafundisa ngoZimu.</text>
      <sha1>0s4qyb9tuofnaxf0zuvp6z450n8187t</sha1>
    </revision>
    <revision>
      <id>1320</id>
      <parentid>1319</parentid>
      <timestamp>2024-10-14T13:47:11Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>1319</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="249" sha1="0s4qyb9tuofnaxf0zuvp6z450n8187t" xml:space="preserve">'''Ubukreste''' yindlela yokukholwa ulandela uKristu bonyana abe yikosi nomsindisi wepilo yakho. Abantu abamaKristu nabo bahlukile ngokuya kwamasonto wabo. Abantu abama kristu basebenzisa [[ibhayibhili]] njengomtlolo obakhuthaza nobafundisa ngoZimu.</text>
      <sha1>0s4qyb9tuofnaxf0zuvp6z450n8187t</sha1>
    </revision>
    <revision>
      <id>2434</id>
      <parentid>1320</parentid>
      <timestamp>2025-02-18T21:18:13Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2434</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="701" sha1="b1x6gae05igxzrqqm0v9o9w1zzjif3k" xml:space="preserve">'''Ubukreste''' yindlela yokukholwa ulandela uKristu bonyana abe yikosi nomsindisi wepilo yakho. Abantu abamaKristu nabo bahlukile ngokuya kwamasonto wabo. Abantu abama kristu basebenzisa [[ibhayibhili]] njengomtlolo obakhuthaza nobafundisa ngoZimu.

Ama krestre asebenziswa isiphambano njengetshwayo. Isiphambano lesi sitjho ukuthethelwa kwezono ngokufa kukaJesu nokuphalaka wegazi lakhe esiphambanweni.

Amakreste nawo awodwa ayahluka ngokwawo ngombana abanye bagcoka isambatho lokha nabaya esontweni begodu abanye abasigcoki. Abanye babetha imitjhini yokuvuma lokha nabasontako begodu abanye bavuma ngama phimbo wabo kwaphela.

Imihlobo yama kreste

# Abazalwana
# Amazayoni
# Amapostoli
# Ama IPCC</text>
      <sha1>b1x6gae05igxzrqqm0v9o9w1zzjif3k</sha1>
    </revision>
    <revision>
      <id>2910</id>
      <parentid>2434</parentid>
      <timestamp>2025-06-06T16:48:41Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>skill</comment>
      <origin>2910</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="782" sha1="e8ykz7pw0n91ykqqcyh3vs4nyfvdl6g" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. Ubukreste''' yindlela yokukholwa ulandela uKristu bonyana abe yikosi nomsindisi wepilo yakho. Abantu abamaKristu nabo bahlukile ngokuya kwamasonto wabo. Abantu abama kristu basebenzisa [[ibhayibhili]] njengomtlolo obakhuthaza nobafundisa ngoZimu.

Ama krestre asebenziswa isiphambano njengetshwayo. Isiphambano lesi sitjho ukuthethelwa kwezono ngokufa kukaJesu nokuphalaka wegazi lakhe esiphambanweni.

Amakreste nawo awodwa ayahluka ngokwawo ngombana abanye bagcoka isambatho lokha nabaya esontweni begodu abanye abasigcoki. Abanye babetha imitjhini yokuvuma lokha nabasontako begodu abanye bavuma ngama phimbo wabo kwaphela.

Imihlobo yama kreste

# Abazalwana
# Amazayoni
# Amapostoli
# Ama IPCC</text>
      <sha1>e8ykz7pw0n91ykqqcyh3vs4nyfvdl6g</sha1>
    </revision>
    <revision>
      <id>3143</id>
      <parentid>2910</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Nqobile69|Nqobile69]]</comment>
      <origin>2434</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="701" sha1="b1x6gae05igxzrqqm0v9o9w1zzjif3k" xml:space="preserve">'''Ubukreste''' yindlela yokukholwa ulandela uKristu bonyana abe yikosi nomsindisi wepilo yakho. Abantu abamaKristu nabo bahlukile ngokuya kwamasonto wabo. Abantu abama kristu basebenzisa [[ibhayibhili]] njengomtlolo obakhuthaza nobafundisa ngoZimu.

Ama krestre asebenziswa isiphambano njengetshwayo. Isiphambano lesi sitjho ukuthethelwa kwezono ngokufa kukaJesu nokuphalaka wegazi lakhe esiphambanweni.

Amakreste nawo awodwa ayahluka ngokwawo ngombana abanye bagcoka isambatho lokha nabaya esontweni begodu abanye abasigcoki. Abanye babetha imitjhini yokuvuma lokha nabasontako begodu abanye bavuma ngama phimbo wabo kwaphela.

Imihlobo yama kreste

# Abazalwana
# Amazayoni
# Amapostoli
# Ama IPCC</text>
      <sha1>b1x6gae05igxzrqqm0v9o9w1zzjif3k</sha1>
    </revision>
    <revision>
      <id>6800</id>
      <parentid>3143</parentid>
      <timestamp>2026-08-21T03:01:15Z</timestamp>
      <contributor>
        <username>Andries Solly Skhosana</username>
        <id>1624</id>
      </contributor>
      <origin>6800</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="755" sha1="g1jdw14amzyckq11u9a9gnc4ui7mlo8" xml:space="preserve">'''Ubukreste''' yindlela yokukholwa elandela uKristu bonyana abe yikosi nomsindisi wepilwakho. Abantu abamaKristu nabo bahlukile ngokuya kwamasondwabo. Abantu abamakristu basebenzisa [[ibhayibhili|iBhayibheli]] njengomtlolo obakhuthazako nobafundisa ngoZimu.

Amakrestre asebenziswa isiphambano njengetshwayo. Isiphambano lesi sitjho ukulitjalelwa kwezono ngokufa kukaJesu nokuphalaka kwegazi Lakhe esiphambanweni.

Amakreste nawo awodwa ayahluka ngokwawo ngombana abanye bambatha izembatho lokha nabaya esondweni, kuthi abanye bona bangazimbathi. Abanye babetha imitjhini yokuvuma lokha nabasondako, kuthi abanye nabavumako bavuma ngokusebenzisa amaphimbabo namkha ngomlomo kwaphela.

Imihlobo yamakreste

# AbaZalwana
# AmaZayoni
# AmaPostoli
# Ama-IPCC</text>
      <sha1>g1jdw14amzyckq11u9a9gnc4ui7mlo8</sha1>
    </revision>
    <revision>
      <id>6801</id>
      <parentid>6800</parentid>
      <timestamp>2026-08-21T03:04:11Z</timestamp>
      <contributor>
        <username>Andries Solly Skhosana</username>
        <id>1624</id>
      </contributor>
      <origin>6801</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="754" sha1="30etf4qp7oref9lo7c2dl8s49u69gar" xml:space="preserve">'''Ubukreste''' yindlela yokukholwa elandela uKristu bonyana abe yiKosi nomsindisi wepilwakho. Abantu abamaKristu nabo bahlukile ngokuya kwamasondwabo. Abantu abamakristu basebenzisa [[ibhayibhili|iBhayibheli]] njengomtlolo obakhuthazako nobafundisa ngoZimu.

Amakrestre asebenzisa isiphambano njengetshwayo. Isiphambano lesi sitjho ukulitjalelwa kwezono ngokufa kukaJesu nokuphalaka kwegazi Lakhe esiphambanweni.

Amakreste nawo awodwa ayahluka ngokwawo ngombana abanye bambatha izembatho lokha nabaya esondweni, kuthi abanye bona bangazimbathi. Abanye babetha imitjhini yokuvuma lokha nabasondako, kuthi abanye nabavumako bavuma ngokusebenzisa amaphimbabo namkha ngomlomo kwaphela.

Imihlobo yamakreste

# AbaZalwana
# AmaZayoni
# AmaPostoli
# Ama-IPCC</text>
      <sha1>30etf4qp7oref9lo7c2dl8s49u69gar</sha1>
    </revision>
  </page>
  <page>
    <title>Ubulwelwe be-Ebola</title>
    <ns>0</ns>
    <id>250</id>
    <revision>
      <id>1321</id>
      <timestamp>2014-09-02T08:40:48Z</timestamp>
      <contributor>
        <username>incubator&gt;Ian Henderson</username>
        <id>0</id>
      </contributor>
      <comment>Created content</comment>
      <origin>1321</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9648" sha1="nos8v4n856hzqhy1zr4r3wkyheri4xb" xml:space="preserve">{{infobox disease
| Name           = Ubulwelwe be-Ebola 
| Image          = 7042 lores-Ebola-Zaire-CDC Photo.jpg
| Caption        = Isithombe sango-1976 sabahlengikazi ababili, bajame hlanu kwaka [[Mayinga N'Seka|Mayinga N.]], omumuntu osahlelwe mumulwana we-Ebola. Wahlongakala ngemva kwamalanga ambalwa ngonobangela wobulwelwe bokopha nokurhadza kweengazi.
| DiseasesDB     = 18043
| ICD10          = {{ICD10|A|98|4|a|90}}
| ICD9           = {{ICD9|065.8}}
| MedlinePlus    = 001339
| eMedicineSubj  = med
| eMedicineTopic = 626
| MeshID         = D019142
}}
'''Ubulwelwe be-Ebola'''nofana ('''EVD''')'''I-Ebola nomulwana wokopha iingazi okhambisana nomgomani''' ('''EHF''') mimulwana ebangwa bulwelwe bevayirasi ebizwa nge- [[Ebola]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo athoma ukubonakala phakathi kwamalanga amabili ukuya eemvekeni eentathu ngemva sewungenwe bulwelwe lobu, [[njengomgomani ongapheliko]], umphimbo obabako onesilonda, [[imisipha ebuhlungu kanye nehloko esawula kabuhlungu]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kesinye isikhathi [[ungahlanza]], uphakanyelwe ziimbindi nesifo  [[sokurhuda]], kuzokwenza bona [[amaphaphu]] kanye [[neso]] zingasasebenzi kuhle.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Nasele sekufike lapha, abanye baba nomraro [[wokopha iingazi]].&lt;ref name=WHO2014&gt;{{cite web|title=Ebola virus disease Fact sheet N°103|url=http://www.who.int/mediacentre/factsheets/fs103/en/|work=World Health Organization|accessdate=12 April 2014|date=March 2014}}&lt;/ref&gt;

&lt;!-- Cause and Diagnosis--&gt;
Umulwana lo ungangena nawuthintana [[neengazi]] zomuntu ophethwe ngibo nofana [[umjuluko]] nanyana [[okunye nokunye okusamanzana]] okuvela (eenlwaneni [[kumaphelaphelana]] nofana iimfene).&lt;ref name=WHO2014/&gt; Bekube nje umulwana akukatholakali bona ungangena ngokuwurhogela emmoyeni.&lt;ref name=WHOAir2014&gt;{{cite web|title=2014 Ebola Virus Disease (EVD) outbreak in West Africa|url=http://www.who.int/ith/updates/20140421/en/|website=WHO|accessdate=3 August 2014|date=Apr 21 2014}}&lt;/ref&gt; Kukholelwa bonyana abomaphelaphelani bakwazi  ukuphatha umulwana lo kodwana wona angaphathwa ngiwo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kwaba khona umuntu otheleleke ngomulwana lo, umulwana lo ungatheleleka kabanye abantu godu ngesikhathi esifitjhani.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amadoda angasinda ngemva kokulatjhwa angathelela abanye abantu ngokuthunda [[imbewu]] yabo lokha nabaya emsemeni nakungakapheli iinyanga ezimbili.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nakufanele uhlahlutjwe nofana uhlolelwe ubulwelwe lobu be-ebola kufanele izifo ezifana [[nomalalahlengezela]], [[isifo sokurhuda]] kanye omulwana [[wokopha iingazi okhambisana nomgomani]]  inganakwa ukwenzelela ukuthola imiphumela ekungiyo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ukuqinisekisa umrabho womraro wobulwelwe lobu amasampula weengazi ayathathwa ayokuhlolelwa ubulwelwe [[nesivikelasifo seengazini]] kanye ne [[i-RNA] lobu kanye nengongwana ebanga ubulwelwe lobu.&lt;ref name=WHO2014/&gt;

&lt;!-- Prevention --&gt;
Ukuvikela ubulwelwe lobu kungaphungulwa ukuthelelana hlangana neemfene kanye neemfarigi ezingenwe bulwelwelwe lobu bukhandelwe bona bungayi ebantwini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kungenziwa ngokobana kuhlolwe iinlwana lezi ukobana zinabo ubulwelwe lobu na, nakutholakala bona zinabo kungenzeka bona zibulawe bese kugujelwa imizimba yazo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nawupheka inyama bese wembatha izambatho zokuzivikela nakho kungakusiza,&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; ukwembatha izambatho zokuzivikela lokha nawuhlala nofana uhlanu kwaloyo muntu ongenwe mumulwana lowo [[kanye nokuhlamba izandla ngesibha]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amasampula wananyana yini esamanzana yalabo bantu abangenwe mumulwana lo kufanele zitjhejwe khulu, ubalekele ukuthintana nazo.&lt;ref name=WHO2014/&gt;

&lt;!-- Treatment, Prognosis and Epidemiology--&gt;
Ayikho intatha elapha ubulwelwe lobu; imizamo yokobana kusizwe abantu abangenwe bulwelwe lobu kukobana [[kwenziwe umtswako]] (banikelwe amanzi anetswayi) ukobana bawasele nofana [[bafakwe amadribhu azobangenisela okusamanzana emzimbeni wabo]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu [[buneembalobalo eziphezulu zabantu abafako]]: nabangenwe ngibo ubulwelwe lobu, i-ebola ingabulala pheze isiquntu-50% nofana i-90% yabantu abatheleleke ngayo.&lt;ref name=WHO2014/&gt;&lt;ref name=&quot;Elsevier/Academic Press&quot;&gt;{{cite book|author1=C.M. Fauquet|title=Virus taxonomy classification and nomenclature of viruses; 8th report of the International Committee on Taxonomy of Viruses|date=2005|publisher=Elsevier/Academic Press|location=Oxford|isbn=9780080575483|page=648|url=http://books.google.ca/books?id=9Wy7Jgy5RWYC&amp;pg=PA648}}&lt;/ref&gt; I-EVD yathoma ukwazakala endaweni enarheni ye [[Sudan]] kanye ne- [[Democratic Republic of Congo]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu butholakala khulu eenarheni zethrophigi zenarhakazi yeAfrika [[Iphakathi le-Sehara ye-Afrika]].&lt;ref name=WHO2014/&gt; Ngo-1976 (ukutholakala kwabo ubulwelwe lobu] ukufikela ngo-2013, besele ingene yatheleleka ebantwini abangaphasi kwe-1000.&lt;ref name=WHO2014/&gt;&lt;ref name=MMWRJune2014&gt;{{cite web|title=Ebola Viral Disease Outbreak — West Africa, 2014|url=http://www.cdc.gov/mmwr/preview/mmwrhtml/mm6325a4.htm?s_cid=mm6325a4_w|website=CDC|accessdate=26 June 2014|date=June 27, 2014}}&lt;/ref&gt; Ukuqubuka kobulwelwe lobu obukhulu obungazange khebubonwe ngilobu bamuva nje ngebe [[2014  Tjhingalanga ye-Afrika Ukuqubuka kwe-Ebola]], sebele bungene eenarheni [[Guinea]], [[Sierra Leone]], [[Liberia]] begodu ingatheleka ingene ne [[Nigeria]].&lt;ref name=CDC2014&gt;{{cite web|title=CDC urges all US residents to avoid nonessential travel to Liberia, Guinea, and Sierra Leone because of an unprecedented outbreak of Ebola.|url=http://wwwnc.cdc.gov/travel/notices/warning/ebola-liberia|website=CDC|accessdate=2 August 2014|date=July 31, 2014}}&lt;/ref&gt;&lt;ref name=CDCAug2014N&gt;{{cite web|title=Outbreak of Ebola in Guinea, Liberia, and Sierra Leone|url=http://www.cdc.gov/vhf/ebola/outbreaks/guinea/index.html|website=CDC|accessdate=5 August 2014|date=August 4, 2014}}&lt;/ref&gt; Ukusukela ngoRhoboyi 2014 sele kubikwe bona kunabantu esele bangenwe bulwelwe lobu abayi-1600.&lt;ref&gt;{{cite web|title=Ebola virus disease update - West Africa|url=http://www.who.int/csr/don/2014_08_04_ebola/en/|website=WHO|accessdate=6 August 2014|date=Aug 4, 2014}}&lt;/ref&gt; Imizamo yona iyenziwa bona kutholakalle [[ intatha/isihlahla]] esingalapha ubulwelwe lobu, kodwana okwanje asikho.&lt;ref name=WHO2014/&gt;

== Isikhombiso selwazi==
{{Reflist|colwidth=25em}}

; IBhibhliyografu
{{Refbegin}}
* {{Cite book |last=Klenk |first=Hans-Dieter |title=Marburg and Ebola Viruses (Current Topics in Microbiology and Immunology) |date=January 1999 |publisher=Springer-Verlag Telos |location=Berlin |isbn=978-3-540-64729-4 |ref=CITEREFKlenk1999}}
* {{Cite book |first1=Hans-Dieter |last1=Klenk |first2=Heinz |last2=Feldmann |title=Ebola and Marburg viruses: molecular and cellular biology |url=http://books.google.com/?id=EV_mFgnyPoMC |format=Limited preview |year=2004 |publisher=Horizon Bioscience |location=Wymondham, Norfolk, UK |isbn=978-0-9545232-3-7 |ref=CITEREFKlenkFeldmann2004}}
* {{Cite book |last=Kuhn |first=Jens H. |title=Filoviruses: A Compendium of 40 Years of Epidemiological, Clinical, and Laboratory Studies. Archives of Virology Supplement, vol. 20 |url=http://books.google.com/?id=LaOue0F9Ns4C |format=Limited preview |year=2008 |publisher=SpringerWienNewYork |location=Vienna |isbn=978-3-211-20670-6 |ref=CITEREFKuhn2008}}
* {{Cite book |last1=McCormick |first1=Joseph |last2=Fisher-Hoch |first2=Susan |others=Horvitz, Leslie Alan |title=Level 4: Virus Hunters of the CDC |url=http://books.google.com/?id=QEvR3aJX2m0C |format=Limited preview |origyear=1996 |edition=Updated [3rd] |year=1999 |publisher=Barnes &amp; Noble |isbn=978-0-7607-1208-5 |ref=CITEREFMcCormickFisher-Hoch1999 |month=June}}
* {{Cite book |last=Pattyn |first=S. R. |title=Ebola Virus Haemorrhagic Fever |year=1978 |url=http://www.itg.be/ebola/ |format=Full free text |edition=1st |publisher=Elsevier/North-Holland Biomedical Press |location=Amsterdam |isbn=0-444-80060-3 |ref=CITEREFPattyn1978}}
* {{Cite book | last1 = Ryabchikova | first1 = Elena I. | last2 = Price | first2 = Barbara B. | title = Ebola and Marburg Viruses: A View of Infection Using Electron Microscopy | year = 2004 | publisher = Battelle Press | location = Columbus, Ohio | isbn = 978-1-57477-131-2 | ref = CITEREFRyabchikovaPrice2004 }}
{{Refend}}

==Okuhlanganiswe nalokhu okunye==
{{Refbegin}}
* [http://viralzone.expasy.org/all_by_species/207.html ViralZone: Ebola-like viruses] – Virological repository from the [[Swiss Institute of Bioinformatics]]
* [http://www.cdc.gov/vhf/ebola/ CDC: Ebola hemorrhagic fever] – Centers for Disease Control and Prevention, Special Pathogens Branch
* [http://www.who.int/csr/disease/ebola/en/ WHO: Ebola haemorrhagic fever] – World Health Organization, Global Alert and Response
* [http://www.viprbrc.org/brc/home.do?decorator=filo Virus Pathogen Database and Analysis Resource (ViPR): Filoviridae]
* [http://www.ebi.ac.uk/pdbe/emdb/searchResults.html/?q=ebola 3D macromolecular structures of the Ebola virus archived in the EM Data Bank(EMDB)]
* [https://maps.google.com/maps/ms?msa=0&amp;msid=202977755949863934429.0004c658eb30f9c4fb1c0&amp;ie=UTF8&amp;t=h&amp;ll=27.371767,5.273438&amp;spn=110.017392,184.21875&amp;z=2&amp;source=embed&amp;dg=feature Google Map of Ebola Outbreaks]
* [http://www.who.int/csr/bioriskreduction/filovirus_infection_control/en/ WHO recommended infection control measures]
{{Refend}}</text>
      <sha1>nos8v4n856hzqhy1zr4r3wkyheri4xb</sha1>
    </revision>
    <revision>
      <id>1322</id>
      <parentid>1321</parentid>
      <timestamp>2014-09-02T08:43:14Z</timestamp>
      <contributor>
        <username>incubator&gt;Ian Henderson</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1322</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9649" sha1="syulq1wq58juy34h5xehxpjyj87r66s" xml:space="preserve">{{infobox disease
| Name           = Ubulwelwe be-Ebola 
| Image          = 7042 lores-Ebola-Zaire-CDC Photo.jpg
| Caption        = Isithombe sango-1976 sabahlengikazi ababili, bajame hlanu kwaka [[Mayinga N'Seka|Mayinga N.]], omumuntu osahlelwe mumulwana we-Ebola. Wahlongakala ngemva kwamalanga ambalwa ngonobangela wobulwelwe bokopha nokurhadza kweengazi.
| DiseasesDB     = 18043
| ICD10          = {{ICD10|A|98|4|a|90}}
| ICD9           = {{ICD9|065.8}}
| MedlinePlus    = 001339
| eMedicineSubj  = med
| eMedicineTopic = 626
| MeshID         = D019142
}}
'''Ubulwelwe be-Ebola'''nofana ('''EVD''')'''I-Ebola nomulwana wokopha iingazi okhambisana nomgomani''' ('''EHF''') mimulwana ebangwa bulwelwe bevayirasi ebizwa nge- [[Ebola]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo athoma ukubonakala phakathi kwamalanga amabili ukuya eemvekeni eentathu ngemva sewungenwe bulwelwe lobu, [[njengomgomani ongapheliko]], umphimbo obabako onesilonda, [[imisipha ebuhlungu kanye nehloko esawula kabuhlungu]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kesinye isikhathi [[ungahlanza]], uphakanyelwe ziimbindi nesifo  [[sokurhuda]], kuzokwenza bona [[amaphaphu]] kanye [[neso]] zingasasebenzi kuhle.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Nasele sekufike lapha, abanye baba nomraro [[wokopha iingazi]].&lt;ref name=WHO2014&gt;{{cite web|title=Ebola virus disease Fact sheet N°103|url=http://www.who.int/mediacentre/factsheets/fs103/en/|work=World Health Organization|accessdate=12 April 2014|date=March 2014}}&lt;/ref&gt;

&lt;!-- Cause and Diagnosis--&gt;
Umulwana lo ungangena nawuthintana [[neengazi]] zomuntu ophethwe ngibo nofana [[umjuluko]] nanyana [[okunye nokunye okusamanzana]] okuvela (eenlwaneni [[kumaphelaphelana]] nofana iimfene).&lt;ref name=WHO2014/&gt; Bekube nje umulwana akukatholakali bona ungangena ngokuwurhogela emmoyeni.&lt;ref name=WHOAir2014&gt;{{cite web|title=2014 Ebola Virus Disease (EVD) outbreak in West Africa|url=http://www.who.int/ith/updates/20140421/en/|website=WHO|accessdate=3 August 2014|date=Apr 21 2014}}&lt;/ref&gt; Kukholelwa bonyana abomaphelaphelani bakwazi  ukuphatha umulwana lo kodwana wona angaphathwa ngiwo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kwaba khona umuntu otheleleke ngomulwana lo, umulwana lo ungatheleleka kabanye abantu godu ngesikhathi esifitjhani.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amadoda angasinda ngemva kokulatjhwa angathelela abanye abantu ngokuthunda [[imbewu]] yabo lokha nabaya emsemeni nakungakapheli iinyanga ezimbili.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nakufanele uhlahlutjwe nofana uhlolelwe ubulwelwe lobu be-ebola kufanele izifo ezifana [[nomalalahlengezela]], [[isifo sokurhuda]] kanye omulwana [[wokopha iingazi okhambisana nomgomani]]  inganakwa ukwenzelela ukuthola imiphumela ekungiyo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ukuqinisekisa umrabho womraro wobulwelwe lobu amasampula weengazi ayathathwa ayokuhlolelwa ubulwelwe [[nesivikelasifo seengazini]] kanye ne [[i-RNA]] lobu kanye nengongwana ebanga ubulwelwe lobu.&lt;ref name=WHO2014/&gt;

&lt;!-- Prevention --&gt;
Ukuvikela ubulwelwe lobu kungaphungulwa ukuthelelana hlangana neemfene kanye neemfarigi ezingenwe bulwelwelwe lobu bukhandelwe bona bungayi ebantwini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kungenziwa ngokobana kuhlolwe iinlwana lezi ukobana zinabo ubulwelwe lobu na, nakutholakala bona zinabo kungenzeka bona zibulawe bese kugujelwa imizimba yazo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nawupheka inyama bese wembatha izambatho zokuzivikela nakho kungakusiza,&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; ukwembatha izambatho zokuzivikela lokha nawuhlala nofana uhlanu kwaloyo muntu ongenwe mumulwana lowo [[kanye nokuhlamba izandla ngesibha]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amasampula wananyana yini esamanzana yalabo bantu abangenwe mumulwana lo kufanele zitjhejwe khulu, ubalekele ukuthintana nazo.&lt;ref name=WHO2014/&gt;

&lt;!-- Treatment, Prognosis and Epidemiology--&gt;
Ayikho intatha elapha ubulwelwe lobu; imizamo yokobana kusizwe abantu abangenwe bulwelwe lobu kukobana [[kwenziwe umtswako]] (banikelwe amanzi anetswayi) ukobana bawasele nofana [[bafakwe amadribhu azobangenisela okusamanzana emzimbeni wabo]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu [[buneembalobalo eziphezulu zabantu abafako]]: nabangenwe ngibo ubulwelwe lobu, i-ebola ingabulala pheze isiquntu-50% nofana i-90% yabantu abatheleleke ngayo.&lt;ref name=WHO2014/&gt;&lt;ref name=&quot;Elsevier/Academic Press&quot;&gt;{{cite book|author1=C.M. Fauquet|title=Virus taxonomy classification and nomenclature of viruses; 8th report of the International Committee on Taxonomy of Viruses|date=2005|publisher=Elsevier/Academic Press|location=Oxford|isbn=9780080575483|page=648|url=http://books.google.ca/books?id=9Wy7Jgy5RWYC&amp;pg=PA648}}&lt;/ref&gt; I-EVD yathoma ukwazakala endaweni enarheni ye [[Sudan]] kanye ne- [[Democratic Republic of Congo]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu butholakala khulu eenarheni zethrophigi zenarhakazi yeAfrika [[Iphakathi le-Sehara ye-Afrika]].&lt;ref name=WHO2014/&gt; Ngo-1976 (ukutholakala kwabo ubulwelwe lobu] ukufikela ngo-2013, besele ingene yatheleleka ebantwini abangaphasi kwe-1000.&lt;ref name=WHO2014/&gt;&lt;ref name=MMWRJune2014&gt;{{cite web|title=Ebola Viral Disease Outbreak — West Africa, 2014|url=http://www.cdc.gov/mmwr/preview/mmwrhtml/mm6325a4.htm?s_cid=mm6325a4_w|website=CDC|accessdate=26 June 2014|date=June 27, 2014}}&lt;/ref&gt; Ukuqubuka kobulwelwe lobu obukhulu obungazange khebubonwe ngilobu bamuva nje ngebe [[2014  Tjhingalanga ye-Afrika Ukuqubuka kwe-Ebola]], sebele bungene eenarheni [[Guinea]], [[Sierra Leone]], [[Liberia]] begodu ingatheleka ingene ne [[Nigeria]].&lt;ref name=CDC2014&gt;{{cite web|title=CDC urges all US residents to avoid nonessential travel to Liberia, Guinea, and Sierra Leone because of an unprecedented outbreak of Ebola.|url=http://wwwnc.cdc.gov/travel/notices/warning/ebola-liberia|website=CDC|accessdate=2 August 2014|date=July 31, 2014}}&lt;/ref&gt;&lt;ref name=CDCAug2014N&gt;{{cite web|title=Outbreak of Ebola in Guinea, Liberia, and Sierra Leone|url=http://www.cdc.gov/vhf/ebola/outbreaks/guinea/index.html|website=CDC|accessdate=5 August 2014|date=August 4, 2014}}&lt;/ref&gt; Ukusukela ngoRhoboyi 2014 sele kubikwe bona kunabantu esele bangenwe bulwelwe lobu abayi-1600.&lt;ref&gt;{{cite web|title=Ebola virus disease update - West Africa|url=http://www.who.int/csr/don/2014_08_04_ebola/en/|website=WHO|accessdate=6 August 2014|date=Aug 4, 2014}}&lt;/ref&gt; Imizamo yona iyenziwa bona kutholakalle [[ intatha/isihlahla]] esingalapha ubulwelwe lobu, kodwana okwanje asikho.&lt;ref name=WHO2014/&gt;

== Isikhombiso selwazi==
{{Reflist|colwidth=25em}}

; IBhibhliyografu
{{Refbegin}}
* {{Cite book |last=Klenk |first=Hans-Dieter |title=Marburg and Ebola Viruses (Current Topics in Microbiology and Immunology) |date=January 1999 |publisher=Springer-Verlag Telos |location=Berlin |isbn=978-3-540-64729-4 |ref=CITEREFKlenk1999}}
* {{Cite book |first1=Hans-Dieter |last1=Klenk |first2=Heinz |last2=Feldmann |title=Ebola and Marburg viruses: molecular and cellular biology |url=http://books.google.com/?id=EV_mFgnyPoMC |format=Limited preview |year=2004 |publisher=Horizon Bioscience |location=Wymondham, Norfolk, UK |isbn=978-0-9545232-3-7 |ref=CITEREFKlenkFeldmann2004}}
* {{Cite book |last=Kuhn |first=Jens H. |title=Filoviruses: A Compendium of 40 Years of Epidemiological, Clinical, and Laboratory Studies. Archives of Virology Supplement, vol. 20 |url=http://books.google.com/?id=LaOue0F9Ns4C |format=Limited preview |year=2008 |publisher=SpringerWienNewYork |location=Vienna |isbn=978-3-211-20670-6 |ref=CITEREFKuhn2008}}
* {{Cite book |last1=McCormick |first1=Joseph |last2=Fisher-Hoch |first2=Susan |others=Horvitz, Leslie Alan |title=Level 4: Virus Hunters of the CDC |url=http://books.google.com/?id=QEvR3aJX2m0C |format=Limited preview |origyear=1996 |edition=Updated [3rd] |year=1999 |publisher=Barnes &amp; Noble |isbn=978-0-7607-1208-5 |ref=CITEREFMcCormickFisher-Hoch1999 |month=June}}
* {{Cite book |last=Pattyn |first=S. R. |title=Ebola Virus Haemorrhagic Fever |year=1978 |url=http://www.itg.be/ebola/ |format=Full free text |edition=1st |publisher=Elsevier/North-Holland Biomedical Press |location=Amsterdam |isbn=0-444-80060-3 |ref=CITEREFPattyn1978}}
* {{Cite book | last1 = Ryabchikova | first1 = Elena I. | last2 = Price | first2 = Barbara B. | title = Ebola and Marburg Viruses: A View of Infection Using Electron Microscopy | year = 2004 | publisher = Battelle Press | location = Columbus, Ohio | isbn = 978-1-57477-131-2 | ref = CITEREFRyabchikovaPrice2004 }}
{{Refend}}

==Okuhlanganiswe nalokhu okunye==
{{Refbegin}}
* [http://viralzone.expasy.org/all_by_species/207.html ViralZone: Ebola-like viruses] – Virological repository from the [[Swiss Institute of Bioinformatics]]
* [http://www.cdc.gov/vhf/ebola/ CDC: Ebola hemorrhagic fever] – Centers for Disease Control and Prevention, Special Pathogens Branch
* [http://www.who.int/csr/disease/ebola/en/ WHO: Ebola haemorrhagic fever] – World Health Organization, Global Alert and Response
* [http://www.viprbrc.org/brc/home.do?decorator=filo Virus Pathogen Database and Analysis Resource (ViPR): Filoviridae]
* [http://www.ebi.ac.uk/pdbe/emdb/searchResults.html/?q=ebola 3D macromolecular structures of the Ebola virus archived in the EM Data Bank(EMDB)]
* [https://maps.google.com/maps/ms?msa=0&amp;msid=202977755949863934429.0004c658eb30f9c4fb1c0&amp;ie=UTF8&amp;t=h&amp;ll=27.371767,5.273438&amp;spn=110.017392,184.21875&amp;z=2&amp;source=embed&amp;dg=feature Google Map of Ebola Outbreaks]
* [http://www.who.int/csr/bioriskreduction/filovirus_infection_control/en/ WHO recommended infection control measures]
{{Refend}}</text>
      <sha1>syulq1wq58juy34h5xehxpjyj87r66s</sha1>
    </revision>
    <revision>
      <id>1323</id>
      <parentid>1322</parentid>
      <timestamp>2014-09-02T08:43:56Z</timestamp>
      <contributor>
        <username>incubator&gt;Ian Henderson</username>
        <id>0</id>
      </contributor>
      <origin>1323</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9651" sha1="8lx8taafudc8o8ds3elis6sluk49p9r" xml:space="preserve">{{infobox disease
| Name           = Ubulwelwe be-Ebola 
| Image          = 7042 lores-Ebola-Zaire-CDC Photo.jpg
| Caption        = Isithombe sango-1976 sabahlengikazi ababili, bajame hlanu kwaka [[Mayinga N'Seka|Mayinga N.]], omumuntu osahlelwe mumulwana we-Ebola. Wahlongakala ngemva kwamalanga ambalwa ngonobangela wobulwelwe bokopha nokurhadza kweengazi.
| DiseasesDB     = 18043
| ICD10          = {{ICD10|A|98|4|a|90}}
| ICD9           = {{ICD9|065.8}}
| MedlinePlus    = 001339
| eMedicineSubj  = med
| eMedicineTopic = 626
| MeshID         = D019142
}}
'''Ubulwelwe be-Ebola''' nofana ('''EVD''') '''I-Ebola nomulwana wokopha iingazi okhambisana nomgomani''' ('''EHF''') mimulwana ebangwa bulwelwe bevayirasi ebizwa nge- [[Ebola]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo athoma ukubonakala phakathi kwamalanga amabili ukuya eemvekeni eentathu ngemva sewungenwe bulwelwe lobu, [[njengomgomani ongapheliko]], umphimbo obabako onesilonda, [[imisipha ebuhlungu kanye nehloko esawula kabuhlungu]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kesinye isikhathi [[ungahlanza]], uphakanyelwe ziimbindi nesifo  [[sokurhuda]], kuzokwenza bona [[amaphaphu]] kanye [[neso]] zingasasebenzi kuhle.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Nasele sekufike lapha, abanye baba nomraro [[wokopha iingazi]].&lt;ref name=WHO2014&gt;{{cite web|title=Ebola virus disease Fact sheet N°103|url=http://www.who.int/mediacentre/factsheets/fs103/en/|work=World Health Organization|accessdate=12 April 2014|date=March 2014}}&lt;/ref&gt;

&lt;!-- Cause and Diagnosis--&gt;
Umulwana lo ungangena nawuthintana [[neengazi]] zomuntu ophethwe ngibo nofana [[umjuluko]] nanyana [[okunye nokunye okusamanzana]] okuvela (eenlwaneni [[kumaphelaphelana]] nofana iimfene).&lt;ref name=WHO2014/&gt; Bekube nje umulwana akukatholakali bona ungangena ngokuwurhogela emmoyeni.&lt;ref name=WHOAir2014&gt;{{cite web|title=2014 Ebola Virus Disease (EVD) outbreak in West Africa|url=http://www.who.int/ith/updates/20140421/en/|website=WHO|accessdate=3 August 2014|date=Apr 21 2014}}&lt;/ref&gt; Kukholelwa bonyana abomaphelaphelani bakwazi  ukuphatha umulwana lo kodwana wona angaphathwa ngiwo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kwaba khona umuntu otheleleke ngomulwana lo, umulwana lo ungatheleleka kabanye abantu godu ngesikhathi esifitjhani.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amadoda angasinda ngemva kokulatjhwa angathelela abanye abantu ngokuthunda [[imbewu]] yabo lokha nabaya emsemeni nakungakapheli iinyanga ezimbili.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nakufanele uhlahlutjwe nofana uhlolelwe ubulwelwe lobu be-ebola kufanele izifo ezifana [[nomalalahlengezela]], [[isifo sokurhuda]] kanye omulwana [[wokopha iingazi okhambisana nomgomani]]  inganakwa ukwenzelela ukuthola imiphumela ekungiyo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ukuqinisekisa umrabho womraro wobulwelwe lobu amasampula weengazi ayathathwa ayokuhlolelwa ubulwelwe [[nesivikelasifo seengazini]] kanye ne [[i-RNA]] lobu kanye nengongwana ebanga ubulwelwe lobu.&lt;ref name=WHO2014/&gt;

&lt;!-- Prevention --&gt;
Ukuvikela ubulwelwe lobu kungaphungulwa ukuthelelana hlangana neemfene kanye neemfarigi ezingenwe bulwelwelwe lobu bukhandelwe bona bungayi ebantwini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kungenziwa ngokobana kuhlolwe iinlwana lezi ukobana zinabo ubulwelwe lobu na, nakutholakala bona zinabo kungenzeka bona zibulawe bese kugujelwa imizimba yazo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nawupheka inyama bese wembatha izambatho zokuzivikela nakho kungakusiza,&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; ukwembatha izambatho zokuzivikela lokha nawuhlala nofana uhlanu kwaloyo muntu ongenwe mumulwana lowo [[kanye nokuhlamba izandla ngesibha]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amasampula wananyana yini esamanzana yalabo bantu abangenwe mumulwana lo kufanele zitjhejwe khulu, ubalekele ukuthintana nazo.&lt;ref name=WHO2014/&gt;

&lt;!-- Treatment, Prognosis and Epidemiology--&gt;
Ayikho intatha elapha ubulwelwe lobu; imizamo yokobana kusizwe abantu abangenwe bulwelwe lobu kukobana [[kwenziwe umtswako]] (banikelwe amanzi anetswayi) ukobana bawasele nofana [[bafakwe amadribhu azobangenisela okusamanzana emzimbeni wabo]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu [[buneembalobalo eziphezulu zabantu abafako]]: nabangenwe ngibo ubulwelwe lobu, i-ebola ingabulala pheze isiquntu-50% nofana i-90% yabantu abatheleleke ngayo.&lt;ref name=WHO2014/&gt;&lt;ref name=&quot;Elsevier/Academic Press&quot;&gt;{{cite book|author1=C.M. Fauquet|title=Virus taxonomy classification and nomenclature of viruses; 8th report of the International Committee on Taxonomy of Viruses|date=2005|publisher=Elsevier/Academic Press|location=Oxford|isbn=9780080575483|page=648|url=http://books.google.ca/books?id=9Wy7Jgy5RWYC&amp;pg=PA648}}&lt;/ref&gt; I-EVD yathoma ukwazakala endaweni enarheni ye [[Sudan]] kanye ne- [[Democratic Republic of Congo]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu butholakala khulu eenarheni zethrophigi zenarhakazi yeAfrika [[Iphakathi le-Sehara ye-Afrika]].&lt;ref name=WHO2014/&gt; Ngo-1976 (ukutholakala kwabo ubulwelwe lobu] ukufikela ngo-2013, besele ingene yatheleleka ebantwini abangaphasi kwe-1000.&lt;ref name=WHO2014/&gt;&lt;ref name=MMWRJune2014&gt;{{cite web|title=Ebola Viral Disease Outbreak — West Africa, 2014|url=http://www.cdc.gov/mmwr/preview/mmwrhtml/mm6325a4.htm?s_cid=mm6325a4_w|website=CDC|accessdate=26 June 2014|date=June 27, 2014}}&lt;/ref&gt; Ukuqubuka kobulwelwe lobu obukhulu obungazange khebubonwe ngilobu bamuva nje ngebe [[2014  Tjhingalanga ye-Afrika Ukuqubuka kwe-Ebola]], sebele bungene eenarheni [[Guinea]], [[Sierra Leone]], [[Liberia]] begodu ingatheleka ingene ne [[Nigeria]].&lt;ref name=CDC2014&gt;{{cite web|title=CDC urges all US residents to avoid nonessential travel to Liberia, Guinea, and Sierra Leone because of an unprecedented outbreak of Ebola.|url=http://wwwnc.cdc.gov/travel/notices/warning/ebola-liberia|website=CDC|accessdate=2 August 2014|date=July 31, 2014}}&lt;/ref&gt;&lt;ref name=CDCAug2014N&gt;{{cite web|title=Outbreak of Ebola in Guinea, Liberia, and Sierra Leone|url=http://www.cdc.gov/vhf/ebola/outbreaks/guinea/index.html|website=CDC|accessdate=5 August 2014|date=August 4, 2014}}&lt;/ref&gt; Ukusukela ngoRhoboyi 2014 sele kubikwe bona kunabantu esele bangenwe bulwelwe lobu abayi-1600.&lt;ref&gt;{{cite web|title=Ebola virus disease update - West Africa|url=http://www.who.int/csr/don/2014_08_04_ebola/en/|website=WHO|accessdate=6 August 2014|date=Aug 4, 2014}}&lt;/ref&gt; Imizamo yona iyenziwa bona kutholakalle [[ intatha/isihlahla]] esingalapha ubulwelwe lobu, kodwana okwanje asikho.&lt;ref name=WHO2014/&gt;

== Isikhombiso selwazi==
{{Reflist|colwidth=25em}}

; IBhibhliyografu
{{Refbegin}}
* {{Cite book |last=Klenk |first=Hans-Dieter |title=Marburg and Ebola Viruses (Current Topics in Microbiology and Immunology) |date=January 1999 |publisher=Springer-Verlag Telos |location=Berlin |isbn=978-3-540-64729-4 |ref=CITEREFKlenk1999}}
* {{Cite book |first1=Hans-Dieter |last1=Klenk |first2=Heinz |last2=Feldmann |title=Ebola and Marburg viruses: molecular and cellular biology |url=http://books.google.com/?id=EV_mFgnyPoMC |format=Limited preview |year=2004 |publisher=Horizon Bioscience |location=Wymondham, Norfolk, UK |isbn=978-0-9545232-3-7 |ref=CITEREFKlenkFeldmann2004}}
* {{Cite book |last=Kuhn |first=Jens H. |title=Filoviruses: A Compendium of 40 Years of Epidemiological, Clinical, and Laboratory Studies. Archives of Virology Supplement, vol. 20 |url=http://books.google.com/?id=LaOue0F9Ns4C |format=Limited preview |year=2008 |publisher=SpringerWienNewYork |location=Vienna |isbn=978-3-211-20670-6 |ref=CITEREFKuhn2008}}
* {{Cite book |last1=McCormick |first1=Joseph |last2=Fisher-Hoch |first2=Susan |others=Horvitz, Leslie Alan |title=Level 4: Virus Hunters of the CDC |url=http://books.google.com/?id=QEvR3aJX2m0C |format=Limited preview |origyear=1996 |edition=Updated [3rd] |year=1999 |publisher=Barnes &amp; Noble |isbn=978-0-7607-1208-5 |ref=CITEREFMcCormickFisher-Hoch1999 |month=June}}
* {{Cite book |last=Pattyn |first=S. R. |title=Ebola Virus Haemorrhagic Fever |year=1978 |url=http://www.itg.be/ebola/ |format=Full free text |edition=1st |publisher=Elsevier/North-Holland Biomedical Press |location=Amsterdam |isbn=0-444-80060-3 |ref=CITEREFPattyn1978}}
* {{Cite book | last1 = Ryabchikova | first1 = Elena I. | last2 = Price | first2 = Barbara B. | title = Ebola and Marburg Viruses: A View of Infection Using Electron Microscopy | year = 2004 | publisher = Battelle Press | location = Columbus, Ohio | isbn = 978-1-57477-131-2 | ref = CITEREFRyabchikovaPrice2004 }}
{{Refend}}

==Okuhlanganiswe nalokhu okunye==
{{Refbegin}}
* [http://viralzone.expasy.org/all_by_species/207.html ViralZone: Ebola-like viruses] – Virological repository from the [[Swiss Institute of Bioinformatics]]
* [http://www.cdc.gov/vhf/ebola/ CDC: Ebola hemorrhagic fever] – Centers for Disease Control and Prevention, Special Pathogens Branch
* [http://www.who.int/csr/disease/ebola/en/ WHO: Ebola haemorrhagic fever] – World Health Organization, Global Alert and Response
* [http://www.viprbrc.org/brc/home.do?decorator=filo Virus Pathogen Database and Analysis Resource (ViPR): Filoviridae]
* [http://www.ebi.ac.uk/pdbe/emdb/searchResults.html/?q=ebola 3D macromolecular structures of the Ebola virus archived in the EM Data Bank(EMDB)]
* [https://maps.google.com/maps/ms?msa=0&amp;msid=202977755949863934429.0004c658eb30f9c4fb1c0&amp;ie=UTF8&amp;t=h&amp;ll=27.371767,5.273438&amp;spn=110.017392,184.21875&amp;z=2&amp;source=embed&amp;dg=feature Google Map of Ebola Outbreaks]
* [http://www.who.int/csr/bioriskreduction/filovirus_infection_control/en/ WHO recommended infection control measures]
{{Refend}}</text>
      <sha1>8lx8taafudc8o8ds3elis6sluk49p9r</sha1>
    </revision>
    <revision>
      <id>1324</id>
      <parentid>1323</parentid>
      <timestamp>2014-09-02T08:44:53Z</timestamp>
      <contributor>
        <username>incubator&gt;Ian Henderson</username>
        <id>0</id>
      </contributor>
      <origin>1324</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9650" sha1="9zc1wbzh5ecft1qx945qsewsy8vjcu3" xml:space="preserve">{{infobox disease
| Name           = Ubulwelwe be-Ebola 
| Image          = 7042 lores-Ebola-Zaire-CDC Photo.jpg
| Caption        = Isithombe sango-1976 sabahlengikazi ababili, bajame hlanu kwaka [[Mayinga N'Seka|Mayinga N.]], omumuntu osahlelwe mumulwana we-Ebola. Wahlongakala ngemva kwamalanga ambalwa ngonobangela wobulwelwe bokopha nokurhadza kweengazi.
| DiseasesDB     = 18043
| ICD10          = {{ICD10|A|98|4|a|90}}
| ICD9           = {{ICD9|065.8}}
| MedlinePlus    = 001339
| eMedicineSubj  = med
| eMedicineTopic = 626
| MeshID         = D019142
}}
'''Ubulwelwe be-Ebola''' nofana ('''EVD''') '''I-Ebola nomulwana wokopha iingazi okhambisana nomgomani''' ('''EHF''') mimulwana ebangwa bulwelwe bevayirasi ebizwa nge- [[Ebola]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo athoma ukubonakala phakathi kwamalanga amabili ukuya eemvekeni eentathu ngemva sewungenwe bulwelwe lobu, [[njengomgomani ongapheliko]], umphimbo obabako onesilonda, [[imisipha ebuhlungu kanye nehloko esawula kabuhlungu]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kesinye isikhathi [[ungahlanza]], uphakanyelwe ziimbindi nesifo  [[sokurhuda]], kuzokwenza bona [[amaphaphu]] kanye [[neso]] zingasasebenzi kuhle.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Nasele sekufike lapha, abanye baba nomraro [[wokopha iingazi]].&lt;ref name=WHO2014&gt;{{cite web|title=Ebola virus disease Fact sheet N°103|url=http://www.who.int/mediacentre/factsheets/fs103/en/|work=World Health Organization|accessdate=12 April 2014|date=March 2014}}&lt;/ref&gt;

&lt;!-- Cause and Diagnosis--&gt;
Umulwana lo ungangena nawuthintana [[neengazi]] zomuntu ophethwe ngibo nofana [[umjuluko]] nanyana [[okunye nokunye okusamanzana]] okuvela (eenlwaneni [[kumaphelaphelana]] nofana iimfene).&lt;ref name=WHO2014/&gt; Bekube nje umulwana akukatholakali bona ungangena ngokuwurhogela emmoyeni.&lt;ref name=WHOAir2014&gt;{{cite web|title=2014 Ebola Virus Disease (EVD) outbreak in West Africa|url=http://www.who.int/ith/updates/20140421/en/|website=WHO|accessdate=3 August 2014|date=Apr 21 2014}}&lt;/ref&gt; Kukholelwa bonyana abomaphelaphelani bakwazi  ukuphatha umulwana lo kodwana wona angaphathwa ngiwo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kwaba khona umuntu otheleleke ngomulwana lo, umulwana lo ungatheleleka kabanye abantu godu ngesikhathi esifitjhani.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amadoda angasinda ngemva kokulatjhwa angathelela abanye abantu ngokuthunda [[imbewu]] yabo lokha nabaya emsemeni nakungakapheli iinyanga ezimbili.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nakufanele uhlahlutjwe nofana uhlolelwe ubulwelwe lobu be-ebola kufanele izifo ezifana [[nomalalahlengezela]], [[isifo sokurhuda]] kanye omulwana [[wokopha iingazi okhambisana nomgomani]]  inganakwa ukwenzelela ukuthola imiphumela ekungiyo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ukuqinisekisa umrabho womraro wobulwelwe lobu amasampula weengazi ayathathwa ayokuhlolelwa ubulwelwe [[nesivikelasifo seengazini]] kanye ne [[i-RNA]] lobu kanye nengongwana ebanga ubulwelwe lobu.&lt;ref name=WHO2014/&gt;

&lt;!-- Prevention --&gt;
Ukuvikela ubulwelwe lobu kungaphungulwa ukuthelelana hlangana neemfene kanye neemfarigi ezingenwe bulwelwelwe lobu bukhandelwe bona bungayi ebantwini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kungenziwa ngokobana kuhlolwe iinlwana lezi ukobana zinabo ubulwelwe lobu na, nakutholakala bona zinabo kungenzeka bona zibulawe bese kugujelwa imizimba yazo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nawupheka inyama bese wembatha izambatho zokuzivikela nakho kungakusiza,&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; ukwembatha izambatho zokuzivikela lokha nawuhlala nofana uhlanu kwaloyo muntu ongenwe mumulwana lowo [[kanye nokuhlamba izandla ngesibha]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amasampula wananyana yini esamanzana yalabo bantu abangenwe mumulwana lo kufanele zitjhejwe khulu, ubalekele ukuthintana nazo.&lt;ref name=WHO2014/&gt;

&lt;!-- Treatment, Prognosis and Epidemiology--&gt;
Ayikho intatha elapha ubulwelwe lobu; imizamo yokobana kusizwe abantu abangenwe bulwelwe lobu kukobana [[kwenziwe umtswako]] (banikelwe amanzi anetswayi) ukobana bawasele nofana [[bafakwe amadribhu azobangenisela okusamanzana emzimbeni wabo]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu [[buneembalobalo eziphezulu zabantu abafako]]: nabangenwe ngibo ubulwelwe lobu, i-ebola ingabulala pheze isiquntu-50% nofana i-90% yabantu abatheleleke ngayo.&lt;ref name=WHO2014/&gt;&lt;ref name=&quot;Elsevier/Academic Press&quot;&gt;{{cite book|author1=C.M. Fauquet|title=Virus taxonomy classification and nomenclature of viruses; 8th report of the International Committee on Taxonomy of Viruses|date=2005|publisher=Elsevier/Academic Press|location=Oxford|isbn=9780080575483|page=648|url=http://books.google.ca/books?id=9Wy7Jgy5RWYC&amp;pg=PA648}}&lt;/ref&gt; I-EVD yathoma ukwazakala endaweni enarheni ye [[Sudan]] kanye ne- [[Democratic Republic of Congo]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu butholakala khulu eenarheni zethrophigi zenarhakazi yeAfrika [[Iphakathi le-Sehara ye-Afrika]].&lt;ref name=WHO2014/&gt; Ngo-1976 (ukutholakala kwabo ubulwelwe lobu] ukufikela ngo-2013, besele ingene yatheleleka ebantwini abangaphasi kwe-1000.&lt;ref name=WHO2014/&gt;&lt;ref name=MMWRJune2014&gt;{{cite web|title=Ebola Viral Disease Outbreak — West Africa, 2014|url=http://www.cdc.gov/mmwr/preview/mmwrhtml/mm6325a4.htm?s_cid=mm6325a4_w|website=CDC|accessdate=26 June 2014|date=June 27, 2014}}&lt;/ref&gt; Ukuqubuka kobulwelwe lobu obukhulu obungazange khebubonwe ngilobu bamuva nje ngebe [[2014  Tjhingalanga ye-Afrika Ukuqubuka kwe-Ebola]], sebele bungene eenarheni [[Guinea]], [[Sierra Leone]], [[Liberia]] begodu ingatheleka ingene ne [[Nigeria]].&lt;ref name=CDC2014&gt;{{cite web|title=CDC urges all US residents to avoid nonessential travel to Liberia, Guinea, and Sierra Leone because of an unprecedented outbreak of Ebola.|url=http://wwwnc.cdc.gov/travel/notices/warning/ebola-liberia|website=CDC|accessdate=2 August 2014|date=July 31, 2014}}&lt;/ref&gt;&lt;ref name=CDCAug2014N&gt;{{cite web|title=Outbreak of Ebola in Guinea, Liberia, and Sierra Leone|url=http://www.cdc.gov/vhf/ebola/outbreaks/guinea/index.html|website=CDC|accessdate=5 August 2014|date=August 4, 2014}}&lt;/ref&gt; Ukusukela ngoRhoboyi 2014 sele kubikwe bona kunabantu esele bangenwe bulwelwe lobu abayi-1600.&lt;ref&gt;{{cite web|title=Ebola virus disease update - West Africa|url=http://www.who.int/csr/don/2014_08_04_ebola/en/|website=WHO|accessdate=6 August 2014|date=Aug 4, 2014}}&lt;/ref&gt; Imizamo yona iyenziwa bona kutholakalle [[intatha/isihlahla]] esingalapha ubulwelwe lobu, kodwana okwanje asikho.&lt;ref name=WHO2014/&gt;

== Isikhombiso selwazi==
{{Reflist|colwidth=25em}}

; IBhibhliyografu
{{Refbegin}}
* {{Cite book |last=Klenk |first=Hans-Dieter |title=Marburg and Ebola Viruses (Current Topics in Microbiology and Immunology) |date=January 1999 |publisher=Springer-Verlag Telos |location=Berlin |isbn=978-3-540-64729-4 |ref=CITEREFKlenk1999}}
* {{Cite book |first1=Hans-Dieter |last1=Klenk |first2=Heinz |last2=Feldmann |title=Ebola and Marburg viruses: molecular and cellular biology |url=http://books.google.com/?id=EV_mFgnyPoMC |format=Limited preview |year=2004 |publisher=Horizon Bioscience |location=Wymondham, Norfolk, UK |isbn=978-0-9545232-3-7 |ref=CITEREFKlenkFeldmann2004}}
* {{Cite book |last=Kuhn |first=Jens H. |title=Filoviruses: A Compendium of 40 Years of Epidemiological, Clinical, and Laboratory Studies. Archives of Virology Supplement, vol. 20 |url=http://books.google.com/?id=LaOue0F9Ns4C |format=Limited preview |year=2008 |publisher=SpringerWienNewYork |location=Vienna |isbn=978-3-211-20670-6 |ref=CITEREFKuhn2008}}
* {{Cite book |last1=McCormick |first1=Joseph |last2=Fisher-Hoch |first2=Susan |others=Horvitz, Leslie Alan |title=Level 4: Virus Hunters of the CDC |url=http://books.google.com/?id=QEvR3aJX2m0C |format=Limited preview |origyear=1996 |edition=Updated [3rd] |year=1999 |publisher=Barnes &amp; Noble |isbn=978-0-7607-1208-5 |ref=CITEREFMcCormickFisher-Hoch1999 |month=June}}
* {{Cite book |last=Pattyn |first=S. R. |title=Ebola Virus Haemorrhagic Fever |year=1978 |url=http://www.itg.be/ebola/ |format=Full free text |edition=1st |publisher=Elsevier/North-Holland Biomedical Press |location=Amsterdam |isbn=0-444-80060-3 |ref=CITEREFPattyn1978}}
* {{Cite book | last1 = Ryabchikova | first1 = Elena I. | last2 = Price | first2 = Barbara B. | title = Ebola and Marburg Viruses: A View of Infection Using Electron Microscopy | year = 2004 | publisher = Battelle Press | location = Columbus, Ohio | isbn = 978-1-57477-131-2 | ref = CITEREFRyabchikovaPrice2004 }}
{{Refend}}

==Okuhlanganiswe nalokhu okunye==
{{Refbegin}}
* [http://viralzone.expasy.org/all_by_species/207.html ViralZone: Ebola-like viruses] – Virological repository from the [[Swiss Institute of Bioinformatics]]
* [http://www.cdc.gov/vhf/ebola/ CDC: Ebola hemorrhagic fever] – Centers for Disease Control and Prevention, Special Pathogens Branch
* [http://www.who.int/csr/disease/ebola/en/ WHO: Ebola haemorrhagic fever] – World Health Organization, Global Alert and Response
* [http://www.viprbrc.org/brc/home.do?decorator=filo Virus Pathogen Database and Analysis Resource (ViPR): Filoviridae]
* [http://www.ebi.ac.uk/pdbe/emdb/searchResults.html/?q=ebola 3D macromolecular structures of the Ebola virus archived in the EM Data Bank(EMDB)]
* [https://maps.google.com/maps/ms?msa=0&amp;msid=202977755949863934429.0004c658eb30f9c4fb1c0&amp;ie=UTF8&amp;t=h&amp;ll=27.371767,5.273438&amp;spn=110.017392,184.21875&amp;z=2&amp;source=embed&amp;dg=feature Google Map of Ebola Outbreaks]
* [http://www.who.int/csr/bioriskreduction/filovirus_infection_control/en/ WHO recommended infection control measures]
{{Refend}}</text>
      <sha1>9zc1wbzh5ecft1qx945qsewsy8vjcu3</sha1>
    </revision>
    <revision>
      <id>1325</id>
      <parentid>1324</parentid>
      <timestamp>2014-09-02T10:37:58Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <origin>1325</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="10411" sha1="kj8vlp77fxfhi6zhr7kj0b03z37hytc" xml:space="preserve">{{Template:Infobox disease
|&amp;nbsp;Name &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = Ubulwelwe be-Ebola&amp;nbsp;
|&amp;nbsp;Image &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= 7042 lores-Ebola-Zaire-CDC Photo.jpg
|&amp;nbsp;Caption &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= Isithombe sango-1976 sabahlengikazi ababili, bajame hlanu kwaka [[Mayinga N'Seka|Mayinga N.]], omumuntu osahlelwe mumulwana we-Ebola. Wahlongakala ngemva kwamalanga ambalwa ngonobangela wobulwelwe bokopha nokurhadza kweengazi.
|&amp;nbsp;DiseasesDB &amp;nbsp; &amp;nbsp; = 18043
|&amp;nbsp;ICD10 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;=&amp;nbsp;{{ICD10|A|98|4|a|90}}
|&amp;nbsp;ICD9 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; =&amp;nbsp;{{ICD9|065.8}}
|&amp;nbsp;MedlinePlus &amp;nbsp; &amp;nbsp;= 001339
|&amp;nbsp;eMedicineSubj &amp;nbsp;= med
|&amp;nbsp;eMedicineTopic = 626
|&amp;nbsp;MeshID &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = D019142
}}
'''Ubulwelwe be-Ebola''' nofana&amp;nbsp;('''EVD''') '''I-Ebola nomulwana wokopha iingazi okhambisana nomgomani'''&amp;nbsp;('''EHF''') mimulwana ebangwa bulwelwe bevayirasi ebizwa nge-&amp;nbsp;[[Ebola]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt;&amp;nbsp;Amatshwayo athoma ukubonakala phakathi kwamalanga amabili ukuya eemvekeni eentathu ngemva sewungenwe bulwelwe lobu, [[njengomgomani ongapheliko]], umphimbo obabako onesilonda, [[imisipha ebuhlungu kanye nehloko esawula kabuhlungu]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt;&amp;nbsp;Kesinye isikhathi [[ungahlanza]], uphakanyelwe ziimbindi nesifo&amp;nbsp; [[sokurhuda]], kuzokwenza bona [[amaphaphu]] kanye [[neso]] zingasasebenzi kuhle.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt;&amp;nbsp;Nasele sekufike lapha, abanye baba nomraro [[wokopha iingazi]].&lt;ref name=WHO2014&gt;{{cite web|title=Ebola virus disease Fact sheet N°103|url=http://www.who.int/mediacentre/factsheets/fs103/en/|work=World Health Organization|accessdate=12 April 2014|date=March 2014}}&lt;/ref&gt;

&lt;!-- Cause and Diagnosis--&gt;
Umulwana lo ungangena nawuthintana [[neengazi]] zomuntu ophethwe ngibo nofana [[umjuluko]] nanyana [[okunye nokunye okusamanzana]] okuvela (eenlwaneni [[kumaphelaphelana]] nofana iimfene).&lt;ref name=WHO2014/&gt;&amp;nbsp;Bekube nje umulwana akukatholakali bona ungangena ngokuwurhogela emmoyeni.&lt;ref name=WHOAir2014&gt;{{cite web|title=2014 Ebola Virus Disease (EVD) outbreak in West Africa|url=http://www.who.int/ith/updates/20140421/en/|website=WHO|accessdate=3 August 2014|date=Apr 21 2014}}&lt;/ref&gt;&amp;nbsp;Kukholelwa bonyana abomaphelaphelani bakwazi  ukuphatha umulwana lo kodwana wona angaphathwa ngiwo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt;&amp;nbsp;Kwaba khona umuntu otheleleke ngomulwana lo, umulwana lo ungatheleleka kabanye abantu godu ngesikhathi esifitjhani.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt;&amp;nbsp;Amadoda angasinda ngemva kokulatjhwa angathelela abanye abantu ngokuthunda [[imbewu]] yabo lokha nabaya emsemeni nakungakapheli iinyanga ezimbili.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt;&amp;nbsp;Lokha nakufanele uhlahlutjwe nofana uhlolelwe ubulwelwe lobu be-ebola kufanele izifo ezifana [[nomalalahlengezela]], [[isifo sokurhuda]] kanye omulwana [[wokopha iingazi okhambisana nomgomani]]&amp;nbsp; inganakwa ukwenzelela ukuthola imiphumela ekungiyo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt;&amp;nbsp;Ukuqinisekisa umrabho womraro wobulwelwe lobu amasampula weengazi ayathathwa ayokuhlolelwa ubulwelwe [[nesivikelasifo seengazini]] kanye ne [[i-RNA]] lobu kanye nengongwana ebanga ubulwelwe lobu.&lt;ref name=WHO2014/&gt;

&lt;!-- Prevention --&gt;
Ukuvikela ubulwelwe lobu kungaphungulwa ukuthelelana hlangana neemfene kanye neemfarigi ezingenwe bulwelwelwe lobu bukhandelwe bona bungayi ebantwini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt;&amp;nbsp;Lokhu kungenziwa ngokobana kuhlolwe iinlwana lezi ukobana zinabo ubulwelwe lobu na, nakutholakala bona zinabo kungenzeka bona zibulawe bese kugujelwa imizimba yazo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt;&amp;nbsp;Lokha nawupheka inyama bese wembatha izambatho zokuzivikela nakho kungakusiza,&lt;!-- &lt;ref name=WHO2014/&gt; --&gt;&amp;nbsp;ukwembatha izambatho zokuzivikela lokha nawuhlala nofana uhlanu kwaloyo muntu ongenwe mumulwana lowo [[kanye nokuhlamba izandla ngesibha]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt;&amp;nbsp;Amasampula wananyana yini esamanzana yalabo bantu abangenwe mumulwana lo kufanele zitjhejwe khulu, ubalekele ukuthintana nazo.&lt;ref name=WHO2014/&gt;

&lt;!-- Treatment, Prognosis and Epidemiology--&gt;
Ayikho intatha elapha ubulwelwe lobu; imizamo yokobana kusizwe abantu abangenwe bulwelwe lobu kukobana [[kwenziwe umtswako]]&amp;nbsp;(banikelwe amanzi anetswayi) ukobana bawasele nofana [[bafakwe amadribhu azobangenisela okusamanzana emzimbeni wabo]].&lt;ref name=WHO2014/&gt;&amp;nbsp;Ubulwelwe lobu [[buneembalobalo eziphezulu zabantu abafako]]: nabangenwe ngibo ubulwelwe lobu, i-ebola ingabulala pheze isiquntu-50% nofana i-90% yabantu abatheleleke ngayo.&lt;ref name=WHO2014/&gt;&lt;ref name=&quot;Elsevier/Academic Press&quot;&gt;{{cite book|author1=C.M. Fauquet|title=Virus taxonomy classification and nomenclature of viruses; 8th report of the International Committee on Taxonomy of Viruses|date=2005|publisher=Elsevier/Academic Press|location=Oxford|isbn=9780080575483|page=648|url=http://books.google.ca/books?id=9Wy7Jgy5RWYC&amp;pg=PA648}}&lt;/ref&gt;&amp;nbsp;I-EVD yathoma ukwazakala endaweni enarheni ye&amp;nbsp;[[Sudan]] kanye ne-&amp;nbsp;[[Democratic Republic of Congo]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt;&amp;nbsp;Ubulwelwe lobu butholakala khulu eenarheni zethrophigi zenarhakazi yeAfrika [[Iphakathi le-Sehara ye-Afrika]].&lt;ref name=WHO2014/&gt;&amp;nbsp;Ngo-1976 (ukutholakala kwabo ubulwelwe lobu] ukufikela ngo-2013, besele ingene yatheleleka ebantwini abangaphasi kwe-1000.&lt;ref name=WHO2014/&gt;&lt;ref name=MMWRJune2014&gt;{{cite web|title=Ebola Viral Disease Outbreak&amp;nbsp;—&amp;nbsp;West Africa, 2014|url=http://www.cdc.gov/mmwr/preview/mmwrhtml/mm6325a4.htm?s_cid=mm6325a4_w|website=CDC|accessdate=26 June 2014|date=June 27, 2014}}&lt;/ref&gt;&amp;nbsp;Ukuqubuka kobulwelwe lobu obukhulu obungazange khebubonwe ngilobu bamuva nje ngebe&amp;nbsp;[[2014  Tjhingalanga ye-Afrika Ukuqubuka kwe-Ebola]], sebele bungene eenarheni [[Guinea]],&amp;nbsp;[[Sierra Leone]],&amp;nbsp;[[Liberia]]&amp;nbsp;begodu ingatheleka ingene ne [[Nigeria]].&lt;ref name=CDC2014&gt;{{cite web|title=CDC urges all US residents to avoid nonessential travel to Liberia, Guinea, and Sierra Leone because of an unprecedented outbreak of Ebola.|url=http://wwwnc.cdc.gov/travel/notices/warning/ebola-liberia|website=CDC|accessdate=2 August 2014|date=July 31, 2014}}&lt;/ref&gt;&lt;ref name=CDCAug2014N&gt;{{cite web|title=Outbreak of Ebola in Guinea, Liberia, and Sierra Leone|url=http://www.cdc.gov/vhf/ebola/outbreaks/guinea/index.html|website=CDC|accessdate=5 August 2014|date=August 4, 2014}}&lt;/ref&gt;&amp;nbsp;Ukusukela ngoRhoboyi 2014 sele kubikwe bona kunabantu esele bangenwe bulwelwe lobu abayi-1600.&lt;ref&gt;{{cite web|title=Ebola virus disease update&amp;nbsp;-&amp;nbsp;West Africa|url=http://www.who.int/csr/don/2014_08_04_ebola/en/|website=WHO|accessdate=6 August 2014|date=Aug 4, 2014}}&lt;/ref&gt;&amp;nbsp;Imizamo yona iyenziwa bona kutholakalle&amp;nbsp;[[intatha/isihlahla]] esingalapha ubulwelwe lobu, kodwana okwanje asikho.&lt;ref name=WHO2014/&gt;

== Isikhombiso selwazi==
{{Reflist|colwidth=25em}}

;&amp;nbsp;IBhibhliyografu
{{Refbegin}}
*&amp;nbsp;{{Cite book&amp;nbsp;|last=Klenk&amp;nbsp;|first=Hans-Dieter&amp;nbsp;|title=Marburg and Ebola Viruses (Current Topics in Microbiology and Immunology)&amp;nbsp;|date=January 1999&amp;nbsp;|publisher=Springer-Verlag Telos&amp;nbsp;|location=Berlin&amp;nbsp;|isbn=978-3-540-64729-4&amp;nbsp;|ref=CITEREFKlenk1999}}
*&amp;nbsp;{{Cite book&amp;nbsp;|first1=Hans-Dieter&amp;nbsp;|last1=Klenk&amp;nbsp;|first2=Heinz&amp;nbsp;|last2=Feldmann&amp;nbsp;|title=Ebola and Marburg viruses: molecular and cellular biology&amp;nbsp;|url=http://books.google.com/?id=EV_mFgnyPoMC&amp;nbsp;|format=Limited preview&amp;nbsp;|year=2004&amp;nbsp;|publisher=Horizon Bioscience&amp;nbsp;|location=Wymondham, Norfolk, UK&amp;nbsp;|isbn=978-0-9545232-3-7&amp;nbsp;|ref=CITEREFKlenkFeldmann2004}}
*&amp;nbsp;{{Cite book&amp;nbsp;|last=Kuhn&amp;nbsp;|first=Jens H.&amp;nbsp;|title=Filoviruses: A Compendium of 40 Years of Epidemiological, Clinical, and Laboratory Studies. Archives of Virology Supplement, vol. 20&amp;nbsp;|url=http://books.google.com/?id=LaOue0F9Ns4C&amp;nbsp;|format=Limited preview&amp;nbsp;|year=2008&amp;nbsp;|publisher=SpringerWienNewYork&amp;nbsp;|location=Vienna&amp;nbsp;|isbn=978-3-211-20670-6&amp;nbsp;|ref=CITEREFKuhn2008}}
*&amp;nbsp;{{Cite book&amp;nbsp;|last1=McCormick&amp;nbsp;|first1=Joseph&amp;nbsp;|last2=Fisher-Hoch&amp;nbsp;|first2=Susan&amp;nbsp;|others=Horvitz, Leslie Alan&amp;nbsp;|title=Level 4: Virus Hunters of the CDC&amp;nbsp;|url=http://books.google.com/?id=QEvR3aJX2m0C&amp;nbsp;|format=Limited preview&amp;nbsp;|origyear=1996&amp;nbsp;|edition=Updated [3rd]&amp;nbsp;|year=1999&amp;nbsp;|publisher=Barnes &amp; Noble&amp;nbsp;|isbn=978-0-7607-1208-5&amp;nbsp;|ref=CITEREFMcCormickFisher-Hoch1999&amp;nbsp;|month=June}}
*&amp;nbsp;{{Cite book&amp;nbsp;|last=Pattyn&amp;nbsp;|first=S. R.&amp;nbsp;|title=Ebola Virus Haemorrhagic Fever&amp;nbsp;|year=1978&amp;nbsp;|url=http://www.itg.be/ebola/&amp;nbsp;|format=Full free text&amp;nbsp;|edition=1st&amp;nbsp;|publisher=Elsevier/North-Holland Biomedical Press&amp;nbsp;|location=Amsterdam&amp;nbsp;|isbn=0-444-80060-3&amp;nbsp;|ref=CITEREFPattyn1978}}
*&amp;nbsp;{{Cite book&amp;nbsp;|&amp;nbsp;last1 = Ryabchikova&amp;nbsp;|&amp;nbsp;first1 = Elena I.&amp;nbsp;|&amp;nbsp;last2 = Price&amp;nbsp;|&amp;nbsp;first2 = Barbara B.&amp;nbsp;|&amp;nbsp;title = Ebola and Marburg Viruses: A View of Infection Using Electron Microscopy&amp;nbsp;|&amp;nbsp;year = 2004&amp;nbsp;|&amp;nbsp;publisher = Battelle Press&amp;nbsp;|&amp;nbsp;location = Columbus, Ohio&amp;nbsp;|&amp;nbsp;isbn = 978-1-57477-131-2&amp;nbsp;|&amp;nbsp;ref = CITEREFRyabchikovaPrice2004&amp;nbsp;}}
{{Refend}}

==Okuhlanganiswe nalokhu okunye==
{{Refbegin}}
*&amp;nbsp;[http://viralzone.expasy.org/all_by_species/207.html&amp;nbsp;ViralZone: Ebola-like viruses]&amp;nbsp;–&amp;nbsp;Virological repository from the&amp;nbsp;[[Swiss Institute of Bioinformatics]]
*&amp;nbsp;[http://www.cdc.gov/vhf/ebola/&amp;nbsp;CDC: Ebola hemorrhagic fever]&amp;nbsp;–&amp;nbsp;Centers for Disease Control and Prevention, Special Pathogens Branch
*&amp;nbsp;[http://www.who.int/csr/disease/ebola/en/&amp;nbsp;WHO: Ebola haemorrhagic fever]&amp;nbsp;–&amp;nbsp;World Health Organization, Global Alert and Response
*&amp;nbsp;[http://www.viprbrc.org/brc/home.do?decorator=filo&amp;nbsp;Virus Pathogen Database and Analysis Resource (ViPR): Filoviridae]
*&amp;nbsp;[http://www.ebi.ac.uk/pdbe/emdb/searchResults.html/?q=ebola&amp;nbsp;3D macromolecular structures of the Ebola virus archived in the EM Data Bank(EMDB)]
*&amp;nbsp;[https://maps.google.com/maps/ms?msa=0&amp;msid=202977755949863934429.0004c658eb30f9c4fb1c0&amp;ie=UTF8&amp;t=h&amp;ll=27.371767,5.273438&amp;spn=110.017392,184.21875&amp;z=2&amp;source=embed&amp;dg=feature&amp;nbsp;Google Map of Ebola Outbreaks]
*&amp;nbsp;[http://www.who.int/csr/bioriskreduction/filovirus_infection_control/en/&amp;nbsp;WHO recommended infection control measures]
{{Refend}}</text>
      <sha1>kj8vlp77fxfhi6zhr7kj0b03z37hytc</sha1>
    </revision>
    <revision>
      <id>1326</id>
      <parentid>1325</parentid>
      <timestamp>2014-09-02T10:40:21Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>fixes</comment>
      <origin>1326</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9461" sha1="6j19jywuz99et5e5y5t1a1w2x1on4ai" xml:space="preserve">{{Infobox disease
| name           = Ubulwelwe be-Ebola
| image          = 7042 lores-Ebola-Zaire-CDC Photo.jpg
| caption        = Isithombe sango-1976 sabahlengikazi ababili, bajame hlanu kwaka [[Mayinga N'Seka|Mayinga N.]], omumuntu osahlelwe mumulwana we-Ebola. Wahlongakala ngemva kwamalanga ambalwa ngonobangela wobulwelwe bokopha nokurhadza kweengazi.
| DiseasesDB     = 18043
| ICD10          = {{ICD10|A|98|4|a|90}}
| ICD9           = {{ICD9|065.8}}
| MedlinePlus    = 001339
| eMedicineSubj  = med
| eMedicineTopic = 626
| MeshID         = D019142
}}
'''Ubulwelwe be-Ebola''' nofana ('''EVD''') '''I-Ebola nomulwana wokopha iingazi okhambisana nomgomani''' ('''EHF''') mimulwana ebangwa bulwelwe bevayirasi ebizwa nge- [[Ebola]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo athoma ukubonakala phakathi kwamalanga amabili ukuya eemvekeni eentathu ngemva sewungenwe bulwelwe lobu, [[njengomgomani ongapheliko]], umphimbo obabako onesilonda, [[imisipha ebuhlungu kanye nehloko esawula kabuhlungu]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kesinye isikhathi [[ungahlanza]], uphakanyelwe ziimbindi nesifo  [[sokurhuda]], kuzokwenza bona [[amaphaphu]] kanye [[neso]] zingasasebenzi kuhle.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Nasele sekufike lapha, abanye baba nomraro [[wokopha iingazi]].&lt;ref name=WHO2014&gt;{{cite web|title=Ebola virus disease Fact sheet N°103|url=http://www.who.int/mediacentre/factsheets/fs103/en/|work=World Health Organization|accessdate=12 April 2014|date=March 2014}}&lt;/ref&gt;

&lt;!-- Cause and Diagnosis--&gt;
Umulwana lo ungangena nawuthintana [[neengazi]] zomuntu ophethwe ngibo nofana [[umjuluko]] nanyana [[okunye nokunye okusamanzana]] okuvela (eenlwaneni [[kumaphelaphelana]] nofana iimfene).&lt;ref name=WHO2014/&gt; Bekube nje umulwana akukatholakali bona ungangena ngokuwurhogela emmoyeni.&lt;ref name=WHOAir2014&gt;{{cite web|title=2014 Ebola Virus Disease (EVD) outbreak in West Africa|url=http://www.who.int/ith/updates/20140421/en/|website=WHO|accessdate=3 August 2014|date=Apr 21 2014}}&lt;/ref&gt; Kukholelwa bonyana abomaphelaphelani bakwazi  ukuphatha umulwana lo kodwana wona angaphathwa ngiwo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kwaba khona umuntu otheleleke ngomulwana lo, umulwana lo ungatheleleka kabanye abantu godu ngesikhathi esifitjhani.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amadoda angasinda ngemva kokulatjhwa angathelela abanye abantu ngokuthunda [[imbewu]] yabo lokha nabaya emsemeni nakungakapheli iinyanga ezimbili.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nakufanele uhlahlutjwe nofana uhlolelwe ubulwelwe lobu be-ebola kufanele izifo ezifana [[nomalalahlengezela]], [[isifo sokurhuda]] kanye omulwana [[wokopha iingazi okhambisana nomgomani]]  inganakwa ukwenzelela ukuthola imiphumela ekungiyo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ukuqinisekisa umrabho womraro wobulwelwe lobu amasampula weengazi ayathathwa ayokuhlolelwa ubulwelwe [[nesivikelasifo seengazini]] kanye ne [[i-RNA]] lobu kanye nengongwana ebanga ubulwelwe lobu.&lt;ref name=WHO2014/&gt;

&lt;!-- Prevention --&gt;
Ukuvikela ubulwelwe lobu kungaphungulwa ukuthelelana hlangana neemfene kanye neemfarigi ezingenwe bulwelwelwe lobu bukhandelwe bona bungayi ebantwini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kungenziwa ngokobana kuhlolwe iinlwana lezi ukobana zinabo ubulwelwe lobu na, nakutholakala bona zinabo kungenzeka bona zibulawe bese kugujelwa imizimba yazo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nawupheka inyama bese wembatha izambatho zokuzivikela nakho kungakusiza,&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; ukwembatha izambatho zokuzivikela lokha nawuhlala nofana uhlanu kwaloyo muntu ongenwe mumulwana lowo [[kanye nokuhlamba izandla ngesibha]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amasampula wananyana yini esamanzana yalabo bantu abangenwe mumulwana lo kufanele zitjhejwe khulu, ubalekele ukuthintana nazo.&lt;ref name=WHO2014/&gt;

&lt;!-- Treatment, Prognosis and Epidemiology--&gt;
Ayikho intatha elapha ubulwelwe lobu; imizamo yokobana kusizwe abantu abangenwe bulwelwe lobu kukobana [[kwenziwe umtswako]] (banikelwe amanzi anetswayi) ukobana bawasele nofana [[bafakwe amadribhu azobangenisela okusamanzana emzimbeni wabo]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu [[buneembalobalo eziphezulu zabantu abafako]]: nabangenwe ngibo ubulwelwe lobu, i-ebola ingabulala pheze isiquntu-50% nofana i-90% yabantu abatheleleke ngayo.&lt;ref name=WHO2014/&gt;&lt;ref name=&quot;Elsevier/Academic Press&quot;&gt;{{cite book|author1=C.M. Fauquet|title=Virus taxonomy classification and nomenclature of viruses; 8th report of the International Committee on Taxonomy of Viruses|date=2005|publisher=Elsevier/Academic Press|location=Oxford|isbn=9780080575483|page=648|url=http://books.google.ca/books?id=9Wy7Jgy5RWYC&amp;pg=PA648}}&lt;/ref&gt; I-EVD yathoma ukwazakala endaweni enarheni ye [[Sudan]] kanye ne- [[Democratic Republic of Congo]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu butholakala khulu eenarheni zethrophigi zenarhakazi yeAfrika [[Iphakathi le-Sehara ye-Afrika]].&lt;ref name=WHO2014/&gt; Ngo-1976 (ukutholakala kwabo ubulwelwe lobu] ukufikela ngo-2013, besele ingene yatheleleka ebantwini abangaphasi kwe-1000.&lt;ref name=WHO2014/&gt;&lt;ref name=MMWRJune2014&gt;{{cite web|title=Ebola Viral Disease Outbreak — West Africa, 2014|url=http://www.cdc.gov/mmwr/preview/mmwrhtml/mm6325a4.htm?s_cid=mm6325a4_w|website=CDC|accessdate=26 June 2014|date=June 27, 2014}}&lt;/ref&gt; Ukuqubuka kobulwelwe lobu obukhulu obungazange khebubonwe ngilobu bamuva nje ngebe [[2014  Tjhingalanga ye-Afrika Ukuqubuka kwe-Ebola]], sebele bungene eenarheni [[Guinea]], [[Sierra Leone]], [[Liberia]] begodu ingatheleka ingene ne [[Nigeria]].&lt;ref name=CDC2014&gt;{{cite web|title=CDC urges all US residents to avoid nonessential travel to Liberia, Guinea, and Sierra Leone because of an unprecedented outbreak of Ebola.|url=http://wwwnc.cdc.gov/travel/notices/warning/ebola-liberia|website=CDC|accessdate=2 August 2014|date=July 31, 2014}}&lt;/ref&gt;&lt;ref name=CDCAug2014N&gt;{{cite web|title=Outbreak of Ebola in Guinea, Liberia, and Sierra Leone|url=http://www.cdc.gov/vhf/ebola/outbreaks/guinea/index.html|website=CDC|accessdate=5 August 2014|date=August 4, 2014}}&lt;/ref&gt; Ukusukela ngoRhoboyi 2014 sele kubikwe bona kunabantu esele bangenwe bulwelwe lobu abayi-1600.&lt;ref&gt;{{cite web|title=Ebola virus disease update - West Africa|url=http://www.who.int/csr/don/2014_08_04_ebola/en/|website=WHO|accessdate=6 August 2014|date=Aug 4, 2014}}&lt;/ref&gt; Imizamo yona iyenziwa bona kutholakalle [[intatha/isihlahla]] esingalapha ubulwelwe lobu, kodwana okwanje asikho.&lt;ref name=WHO2014/&gt;

== Isikhombiso selwazi==
{{Reflist|colwidth=25em}}

; IBhibhliyografu
{{Refbegin}}
* {{Cite book |last=Klenk |first=Hans-Dieter |title=Marburg and Ebola Viruses (Current Topics in Microbiology and Immunology) |date=January 1999 |publisher=Springer-Verlag Telos |location=Berlin |isbn=978-3-540-64729-4 |ref=CITEREFKlenk1999}}
* {{Cite book |first1=Hans-Dieter |last1=Klenk |first2=Heinz |last2=Feldmann |title=Ebola and Marburg viruses: molecular and cellular biology |url=http://books.google.com/?id=EV_mFgnyPoMC |format=Limited preview |year=2004 |publisher=Horizon Bioscience |location=Wymondham, Norfolk, UK |isbn=978-0-9545232-3-7 |ref=CITEREFKlenkFeldmann2004}}
* {{Cite book |last=Kuhn |first=Jens H. |title=Filoviruses: A Compendium of 40 Years of Epidemiological, Clinical, and Laboratory Studies. Archives of Virology Supplement, vol. 20 |url=http://books.google.com/?id=LaOue0F9Ns4C |format=Limited preview |year=2008 |publisher=SpringerWienNewYork |location=Vienna |isbn=978-3-211-20670-6 |ref=CITEREFKuhn2008}}
* {{Cite book |last1=McCormick |first1=Joseph |last2=Fisher-Hoch |first2=Susan |others=Horvitz, Leslie Alan |title=Level 4: Virus Hunters of the CDC |url=http://books.google.com/?id=QEvR3aJX2m0C |format=Limited preview |origyear=1996 |edition=Updated [3rd] |year=1999 |publisher=Barnes &amp; Noble |isbn=978-0-7607-1208-5 |ref=CITEREFMcCormickFisher-Hoch1999 |month=June}}
* {{Cite book |last=Pattyn |first=S. R. |title=Ebola Virus Haemorrhagic Fever |year=1978 |url=http://www.itg.be/ebola/ |format=Full free text |edition=1st |publisher=Elsevier/North-Holland Biomedical Press |location=Amsterdam |isbn=0-444-80060-3 |ref=CITEREFPattyn1978}}
* {{Cite book | last1 = Ryabchikova | first1 = Elena I. | last2 = Price | first2 = Barbara B. | title = Ebola and Marburg Viruses: A View of Infection Using Electron Microscopy | year = 2004 | publisher = Battelle Press | location = Columbus, Ohio | isbn = 978-1-57477-131-2 | ref = CITEREFRyabchikovaPrice2004 }}
{{Refend}}

==Okuhlanganiswe nalokhu okunye==
{{Refbegin}}
* [http://viralzone.expasy.org/all_by_species/207.html ViralZone: Ebola-like viruses] – Virological repository from the [[Swiss Institute of Bioinformatics]]
* [http://www.cdc.gov/vhf/ebola/ CDC: Ebola hemorrhagic fever] – Centers for Disease Control and Prevention, Special Pathogens Branch
* [http://www.who.int/csr/disease/ebola/en/ WHO: Ebola haemorrhagic fever] – World Health Organization, Global Alert and Response
* [http://www.viprbrc.org/brc/home.do?decorator=filo Virus Pathogen Database and Analysis Resource (ViPR): Filoviridae]
* [http://www.ebi.ac.uk/pdbe/emdb/searchResults.html/?q=ebola 3D macromolecular structures of the Ebola virus archived in the EM Data Bank(EMDB)]
* [https://maps.google.com/maps/ms?msa=0&amp;msid=202977755949863934429.0004c658eb30f9c4fb1c0&amp;ie=UTF8&amp;t=h&amp;ll=27.371767,5.273438&amp;spn=110.017392,184.21875&amp;z=2&amp;source=embed&amp;dg=feature Google Map of Ebola Outbreaks]
* [http://www.who.int/csr/bioriskreduction/filovirus_infection_control/en/ WHO recommended infection control measures]
{{Refend}}</text>
      <sha1>6j19jywuz99et5e5y5t1a1w2x1on4ai</sha1>
    </revision>
    <revision>
      <id>1327</id>
      <parentid>1326</parentid>
      <timestamp>2014-09-02T10:41:34Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>Updated all templates to link to local templates</comment>
      <origin>1326</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9461" sha1="6j19jywuz99et5e5y5t1a1w2x1on4ai" xml:space="preserve">{{Infobox disease
| name           = Ubulwelwe be-Ebola
| image          = 7042 lores-Ebola-Zaire-CDC Photo.jpg
| caption        = Isithombe sango-1976 sabahlengikazi ababili, bajame hlanu kwaka [[Mayinga N'Seka|Mayinga N.]], omumuntu osahlelwe mumulwana we-Ebola. Wahlongakala ngemva kwamalanga ambalwa ngonobangela wobulwelwe bokopha nokurhadza kweengazi.
| DiseasesDB     = 18043
| ICD10          = {{ICD10|A|98|4|a|90}}
| ICD9           = {{ICD9|065.8}}
| MedlinePlus    = 001339
| eMedicineSubj  = med
| eMedicineTopic = 626
| MeshID         = D019142
}}
'''Ubulwelwe be-Ebola''' nofana ('''EVD''') '''I-Ebola nomulwana wokopha iingazi okhambisana nomgomani''' ('''EHF''') mimulwana ebangwa bulwelwe bevayirasi ebizwa nge- [[Ebola]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo athoma ukubonakala phakathi kwamalanga amabili ukuya eemvekeni eentathu ngemva sewungenwe bulwelwe lobu, [[njengomgomani ongapheliko]], umphimbo obabako onesilonda, [[imisipha ebuhlungu kanye nehloko esawula kabuhlungu]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kesinye isikhathi [[ungahlanza]], uphakanyelwe ziimbindi nesifo  [[sokurhuda]], kuzokwenza bona [[amaphaphu]] kanye [[neso]] zingasasebenzi kuhle.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Nasele sekufike lapha, abanye baba nomraro [[wokopha iingazi]].&lt;ref name=WHO2014&gt;{{cite web|title=Ebola virus disease Fact sheet N°103|url=http://www.who.int/mediacentre/factsheets/fs103/en/|work=World Health Organization|accessdate=12 April 2014|date=March 2014}}&lt;/ref&gt;

&lt;!-- Cause and Diagnosis--&gt;
Umulwana lo ungangena nawuthintana [[neengazi]] zomuntu ophethwe ngibo nofana [[umjuluko]] nanyana [[okunye nokunye okusamanzana]] okuvela (eenlwaneni [[kumaphelaphelana]] nofana iimfene).&lt;ref name=WHO2014/&gt; Bekube nje umulwana akukatholakali bona ungangena ngokuwurhogela emmoyeni.&lt;ref name=WHOAir2014&gt;{{cite web|title=2014 Ebola Virus Disease (EVD) outbreak in West Africa|url=http://www.who.int/ith/updates/20140421/en/|website=WHO|accessdate=3 August 2014|date=Apr 21 2014}}&lt;/ref&gt; Kukholelwa bonyana abomaphelaphelani bakwazi  ukuphatha umulwana lo kodwana wona angaphathwa ngiwo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kwaba khona umuntu otheleleke ngomulwana lo, umulwana lo ungatheleleka kabanye abantu godu ngesikhathi esifitjhani.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amadoda angasinda ngemva kokulatjhwa angathelela abanye abantu ngokuthunda [[imbewu]] yabo lokha nabaya emsemeni nakungakapheli iinyanga ezimbili.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nakufanele uhlahlutjwe nofana uhlolelwe ubulwelwe lobu be-ebola kufanele izifo ezifana [[nomalalahlengezela]], [[isifo sokurhuda]] kanye omulwana [[wokopha iingazi okhambisana nomgomani]]  inganakwa ukwenzelela ukuthola imiphumela ekungiyo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ukuqinisekisa umrabho womraro wobulwelwe lobu amasampula weengazi ayathathwa ayokuhlolelwa ubulwelwe [[nesivikelasifo seengazini]] kanye ne [[i-RNA]] lobu kanye nengongwana ebanga ubulwelwe lobu.&lt;ref name=WHO2014/&gt;

&lt;!-- Prevention --&gt;
Ukuvikela ubulwelwe lobu kungaphungulwa ukuthelelana hlangana neemfene kanye neemfarigi ezingenwe bulwelwelwe lobu bukhandelwe bona bungayi ebantwini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kungenziwa ngokobana kuhlolwe iinlwana lezi ukobana zinabo ubulwelwe lobu na, nakutholakala bona zinabo kungenzeka bona zibulawe bese kugujelwa imizimba yazo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nawupheka inyama bese wembatha izambatho zokuzivikela nakho kungakusiza,&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; ukwembatha izambatho zokuzivikela lokha nawuhlala nofana uhlanu kwaloyo muntu ongenwe mumulwana lowo [[kanye nokuhlamba izandla ngesibha]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amasampula wananyana yini esamanzana yalabo bantu abangenwe mumulwana lo kufanele zitjhejwe khulu, ubalekele ukuthintana nazo.&lt;ref name=WHO2014/&gt;

&lt;!-- Treatment, Prognosis and Epidemiology--&gt;
Ayikho intatha elapha ubulwelwe lobu; imizamo yokobana kusizwe abantu abangenwe bulwelwe lobu kukobana [[kwenziwe umtswako]] (banikelwe amanzi anetswayi) ukobana bawasele nofana [[bafakwe amadribhu azobangenisela okusamanzana emzimbeni wabo]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu [[buneembalobalo eziphezulu zabantu abafako]]: nabangenwe ngibo ubulwelwe lobu, i-ebola ingabulala pheze isiquntu-50% nofana i-90% yabantu abatheleleke ngayo.&lt;ref name=WHO2014/&gt;&lt;ref name=&quot;Elsevier/Academic Press&quot;&gt;{{cite book|author1=C.M. Fauquet|title=Virus taxonomy classification and nomenclature of viruses; 8th report of the International Committee on Taxonomy of Viruses|date=2005|publisher=Elsevier/Academic Press|location=Oxford|isbn=9780080575483|page=648|url=http://books.google.ca/books?id=9Wy7Jgy5RWYC&amp;pg=PA648}}&lt;/ref&gt; I-EVD yathoma ukwazakala endaweni enarheni ye [[Sudan]] kanye ne- [[Democratic Republic of Congo]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu butholakala khulu eenarheni zethrophigi zenarhakazi yeAfrika [[Iphakathi le-Sehara ye-Afrika]].&lt;ref name=WHO2014/&gt; Ngo-1976 (ukutholakala kwabo ubulwelwe lobu] ukufikela ngo-2013, besele ingene yatheleleka ebantwini abangaphasi kwe-1000.&lt;ref name=WHO2014/&gt;&lt;ref name=MMWRJune2014&gt;{{cite web|title=Ebola Viral Disease Outbreak — West Africa, 2014|url=http://www.cdc.gov/mmwr/preview/mmwrhtml/mm6325a4.htm?s_cid=mm6325a4_w|website=CDC|accessdate=26 June 2014|date=June 27, 2014}}&lt;/ref&gt; Ukuqubuka kobulwelwe lobu obukhulu obungazange khebubonwe ngilobu bamuva nje ngebe [[2014  Tjhingalanga ye-Afrika Ukuqubuka kwe-Ebola]], sebele bungene eenarheni [[Guinea]], [[Sierra Leone]], [[Liberia]] begodu ingatheleka ingene ne [[Nigeria]].&lt;ref name=CDC2014&gt;{{cite web|title=CDC urges all US residents to avoid nonessential travel to Liberia, Guinea, and Sierra Leone because of an unprecedented outbreak of Ebola.|url=http://wwwnc.cdc.gov/travel/notices/warning/ebola-liberia|website=CDC|accessdate=2 August 2014|date=July 31, 2014}}&lt;/ref&gt;&lt;ref name=CDCAug2014N&gt;{{cite web|title=Outbreak of Ebola in Guinea, Liberia, and Sierra Leone|url=http://www.cdc.gov/vhf/ebola/outbreaks/guinea/index.html|website=CDC|accessdate=5 August 2014|date=August 4, 2014}}&lt;/ref&gt; Ukusukela ngoRhoboyi 2014 sele kubikwe bona kunabantu esele bangenwe bulwelwe lobu abayi-1600.&lt;ref&gt;{{cite web|title=Ebola virus disease update - West Africa|url=http://www.who.int/csr/don/2014_08_04_ebola/en/|website=WHO|accessdate=6 August 2014|date=Aug 4, 2014}}&lt;/ref&gt; Imizamo yona iyenziwa bona kutholakalle [[intatha/isihlahla]] esingalapha ubulwelwe lobu, kodwana okwanje asikho.&lt;ref name=WHO2014/&gt;

== Isikhombiso selwazi==
{{Reflist|colwidth=25em}}

; IBhibhliyografu
{{Refbegin}}
* {{Cite book |last=Klenk |first=Hans-Dieter |title=Marburg and Ebola Viruses (Current Topics in Microbiology and Immunology) |date=January 1999 |publisher=Springer-Verlag Telos |location=Berlin |isbn=978-3-540-64729-4 |ref=CITEREFKlenk1999}}
* {{Cite book |first1=Hans-Dieter |last1=Klenk |first2=Heinz |last2=Feldmann |title=Ebola and Marburg viruses: molecular and cellular biology |url=http://books.google.com/?id=EV_mFgnyPoMC |format=Limited preview |year=2004 |publisher=Horizon Bioscience |location=Wymondham, Norfolk, UK |isbn=978-0-9545232-3-7 |ref=CITEREFKlenkFeldmann2004}}
* {{Cite book |last=Kuhn |first=Jens H. |title=Filoviruses: A Compendium of 40 Years of Epidemiological, Clinical, and Laboratory Studies. Archives of Virology Supplement, vol. 20 |url=http://books.google.com/?id=LaOue0F9Ns4C |format=Limited preview |year=2008 |publisher=SpringerWienNewYork |location=Vienna |isbn=978-3-211-20670-6 |ref=CITEREFKuhn2008}}
* {{Cite book |last1=McCormick |first1=Joseph |last2=Fisher-Hoch |first2=Susan |others=Horvitz, Leslie Alan |title=Level 4: Virus Hunters of the CDC |url=http://books.google.com/?id=QEvR3aJX2m0C |format=Limited preview |origyear=1996 |edition=Updated [3rd] |year=1999 |publisher=Barnes &amp; Noble |isbn=978-0-7607-1208-5 |ref=CITEREFMcCormickFisher-Hoch1999 |month=June}}
* {{Cite book |last=Pattyn |first=S. R. |title=Ebola Virus Haemorrhagic Fever |year=1978 |url=http://www.itg.be/ebola/ |format=Full free text |edition=1st |publisher=Elsevier/North-Holland Biomedical Press |location=Amsterdam |isbn=0-444-80060-3 |ref=CITEREFPattyn1978}}
* {{Cite book | last1 = Ryabchikova | first1 = Elena I. | last2 = Price | first2 = Barbara B. | title = Ebola and Marburg Viruses: A View of Infection Using Electron Microscopy | year = 2004 | publisher = Battelle Press | location = Columbus, Ohio | isbn = 978-1-57477-131-2 | ref = CITEREFRyabchikovaPrice2004 }}
{{Refend}}

==Okuhlanganiswe nalokhu okunye==
{{Refbegin}}
* [http://viralzone.expasy.org/all_by_species/207.html ViralZone: Ebola-like viruses] – Virological repository from the [[Swiss Institute of Bioinformatics]]
* [http://www.cdc.gov/vhf/ebola/ CDC: Ebola hemorrhagic fever] – Centers for Disease Control and Prevention, Special Pathogens Branch
* [http://www.who.int/csr/disease/ebola/en/ WHO: Ebola haemorrhagic fever] – World Health Organization, Global Alert and Response
* [http://www.viprbrc.org/brc/home.do?decorator=filo Virus Pathogen Database and Analysis Resource (ViPR): Filoviridae]
* [http://www.ebi.ac.uk/pdbe/emdb/searchResults.html/?q=ebola 3D macromolecular structures of the Ebola virus archived in the EM Data Bank(EMDB)]
* [https://maps.google.com/maps/ms?msa=0&amp;msid=202977755949863934429.0004c658eb30f9c4fb1c0&amp;ie=UTF8&amp;t=h&amp;ll=27.371767,5.273438&amp;spn=110.017392,184.21875&amp;z=2&amp;source=embed&amp;dg=feature Google Map of Ebola Outbreaks]
* [http://www.who.int/csr/bioriskreduction/filovirus_infection_control/en/ WHO recommended infection control measures]
{{Refend}}</text>
      <sha1>6j19jywuz99et5e5y5t1a1w2x1on4ai</sha1>
    </revision>
    <revision>
      <id>1328</id>
      <parentid>1327</parentid>
      <timestamp>2014-09-04T16:05:29Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>/* Isikhombiso selwazi */</comment>
      <origin>1328</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9470" sha1="jl2k004gidk0b6kmmosmr0zzkuexv79" xml:space="preserve">{{Infobox disease
| name           = Ubulwelwe be-Ebola
| image          = 7042 lores-Ebola-Zaire-CDC Photo.jpg
| caption        = Isithombe sango-1976 sabahlengikazi ababili, bajame hlanu kwaka [[Mayinga N'Seka|Mayinga N.]], omumuntu osahlelwe mumulwana we-Ebola. Wahlongakala ngemva kwamalanga ambalwa ngonobangela wobulwelwe bokopha nokurhadza kweengazi.
| DiseasesDB     = 18043
| ICD10          = {{ICD10|A|98|4|a|90}}
| ICD9           = {{ICD9|065.8}}
| MedlinePlus    = 001339
| eMedicineSubj  = med
| eMedicineTopic = 626
| MeshID         = D019142
}}
'''Ubulwelwe be-Ebola''' nofana ('''EVD''') '''I-Ebola nomulwana wokopha iingazi okhambisana nomgomani''' ('''EHF''') mimulwana ebangwa bulwelwe bevayirasi ebizwa nge- [[Ebola]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo athoma ukubonakala phakathi kwamalanga amabili ukuya eemvekeni eentathu ngemva sewungenwe bulwelwe lobu, [[njengomgomani ongapheliko]], umphimbo obabako onesilonda, [[imisipha ebuhlungu kanye nehloko esawula kabuhlungu]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kesinye isikhathi [[ungahlanza]], uphakanyelwe ziimbindi nesifo  [[sokurhuda]], kuzokwenza bona [[amaphaphu]] kanye [[neso]] zingasasebenzi kuhle.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Nasele sekufike lapha, abanye baba nomraro [[wokopha iingazi]].&lt;ref name=WHO2014&gt;{{cite web|title=Ebola virus disease Fact sheet N°103|url=http://www.who.int/mediacentre/factsheets/fs103/en/|work=World Health Organization|accessdate=12 April 2014|date=March 2014}}&lt;/ref&gt;

&lt;!-- Cause and Diagnosis--&gt;
Umulwana lo ungangena nawuthintana [[neengazi]] zomuntu ophethwe ngibo nofana [[umjuluko]] nanyana [[okunye nokunye okusamanzana]] okuvela (eenlwaneni [[kumaphelaphelana]] nofana iimfene).&lt;ref name=WHO2014/&gt; Bekube nje umulwana akukatholakali bona ungangena ngokuwurhogela emmoyeni.&lt;ref name=WHOAir2014&gt;{{cite web|title=2014 Ebola Virus Disease (EVD) outbreak in West Africa|url=http://www.who.int/ith/updates/20140421/en/|website=WHO|accessdate=3 August 2014|date=Apr 21 2014}}&lt;/ref&gt; Kukholelwa bonyana abomaphelaphelani bakwazi  ukuphatha umulwana lo kodwana wona angaphathwa ngiwo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kwaba khona umuntu otheleleke ngomulwana lo, umulwana lo ungatheleleka kabanye abantu godu ngesikhathi esifitjhani.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amadoda angasinda ngemva kokulatjhwa angathelela abanye abantu ngokuthunda [[imbewu]] yabo lokha nabaya emsemeni nakungakapheli iinyanga ezimbili.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nakufanele uhlahlutjwe nofana uhlolelwe ubulwelwe lobu be-ebola kufanele izifo ezifana [[nomalalahlengezela]], [[isifo sokurhuda]] kanye omulwana [[wokopha iingazi okhambisana nomgomani]]  inganakwa ukwenzelela ukuthola imiphumela ekungiyo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ukuqinisekisa umrabho womraro wobulwelwe lobu amasampula weengazi ayathathwa ayokuhlolelwa ubulwelwe [[nesivikelasifo seengazini]] kanye ne [[i-RNA]] lobu kanye nengongwana ebanga ubulwelwe lobu.&lt;ref name=WHO2014/&gt;

&lt;!-- Prevention --&gt;
Ukuvikela ubulwelwe lobu kungaphungulwa ukuthelelana hlangana neemfene kanye neemfarigi ezingenwe bulwelwelwe lobu bukhandelwe bona bungayi ebantwini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kungenziwa ngokobana kuhlolwe iinlwana lezi ukobana zinabo ubulwelwe lobu na, nakutholakala bona zinabo kungenzeka bona zibulawe bese kugujelwa imizimba yazo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nawupheka inyama bese wembatha izambatho zokuzivikela nakho kungakusiza,&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; ukwembatha izambatho zokuzivikela lokha nawuhlala nofana uhlanu kwaloyo muntu ongenwe mumulwana lowo [[kanye nokuhlamba izandla ngesibha]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amasampula wananyana yini esamanzana yalabo bantu abangenwe mumulwana lo kufanele zitjhejwe khulu, ubalekele ukuthintana nazo.&lt;ref name=WHO2014/&gt;

&lt;!-- Treatment, Prognosis and Epidemiology--&gt;
Ayikho intatha elapha ubulwelwe lobu; imizamo yokobana kusizwe abantu abangenwe bulwelwe lobu kukobana [[kwenziwe umtswako]] (banikelwe amanzi anetswayi) ukobana bawasele nofana [[bafakwe amadribhu azobangenisela okusamanzana emzimbeni wabo]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu [[buneembalobalo eziphezulu zabantu abafako]]: nabangenwe ngibo ubulwelwe lobu, i-ebola ingabulala pheze isiquntu-50% nofana i-90% yabantu abatheleleke ngayo.&lt;ref name=WHO2014/&gt;&lt;ref name=&quot;Elsevier/Academic Press&quot;&gt;{{cite book|author1=C.M. Fauquet|title=Virus taxonomy classification and nomenclature of viruses; 8th report of the International Committee on Taxonomy of Viruses|date=2005|publisher=Elsevier/Academic Press|location=Oxford|isbn=9780080575483|page=648|url=http://books.google.ca/books?id=9Wy7Jgy5RWYC&amp;pg=PA648}}&lt;/ref&gt; I-EVD yathoma ukwazakala endaweni enarheni ye [[Sudan]] kanye ne- [[Democratic Republic of Congo]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu butholakala khulu eenarheni zethrophigi zenarhakazi yeAfrika [[Iphakathi le-Sehara ye-Afrika]].&lt;ref name=WHO2014/&gt; Ngo-1976 (ukutholakala kwabo ubulwelwe lobu] ukufikela ngo-2013, besele ingene yatheleleka ebantwini abangaphasi kwe-1000.&lt;ref name=WHO2014/&gt;&lt;ref name=MMWRJune2014&gt;{{cite web|title=Ebola Viral Disease Outbreak — West Africa, 2014|url=http://www.cdc.gov/mmwr/preview/mmwrhtml/mm6325a4.htm?s_cid=mm6325a4_w|website=CDC|accessdate=26 June 2014|date=June 27, 2014}}&lt;/ref&gt; Ukuqubuka kobulwelwe lobu obukhulu obungazange khebubonwe ngilobu bamuva nje ngebe [[2014  Tjhingalanga ye-Afrika Ukuqubuka kwe-Ebola]], sebele bungene eenarheni [[Guinea]], [[Sierra Leone]], [[Liberia]] begodu ingatheleka ingene ne [[Nigeria]].&lt;ref name=CDC2014&gt;{{cite web|title=CDC urges all US residents to avoid nonessential travel to Liberia, Guinea, and Sierra Leone because of an unprecedented outbreak of Ebola.|url=http://wwwnc.cdc.gov/travel/notices/warning/ebola-liberia|website=CDC|accessdate=2 August 2014|date=July 31, 2014}}&lt;/ref&gt;&lt;ref name=CDCAug2014N&gt;{{cite web|title=Outbreak of Ebola in Guinea, Liberia, and Sierra Leone|url=http://www.cdc.gov/vhf/ebola/outbreaks/guinea/index.html|website=CDC|accessdate=5 August 2014|date=August 4, 2014}}&lt;/ref&gt; Ukusukela ngoRhoboyi 2014 sele kubikwe bona kunabantu esele bangenwe bulwelwe lobu abayi-1600.&lt;ref&gt;{{cite web|title=Ebola virus disease update - West Africa|url=http://www.who.int/csr/don/2014_08_04_ebola/en/|website=WHO|accessdate=6 August 2014|date=Aug 4, 2014}}&lt;/ref&gt; Imizamo yona iyenziwa bona kutholakalle [[intatha/isihlahla]] esingalapha ubulwelwe lobu, kodwana okwanje asikho.&lt;ref name=WHO2014/&gt;

&lt;!--
== Isikhombiso selwazi==
{{Reflist|colwidth=25em}}

; IBhibhliyografu
{{Refbegin}}
* {{Cite book |last=Klenk |first=Hans-Dieter |title=Marburg and Ebola Viruses (Current Topics in Microbiology and Immunology) |date=January 1999 |publisher=Springer-Verlag Telos |location=Berlin |isbn=978-3-540-64729-4 |ref=CITEREFKlenk1999}}
* {{Cite book |first1=Hans-Dieter |last1=Klenk |first2=Heinz |last2=Feldmann |title=Ebola and Marburg viruses: molecular and cellular biology |url=http://books.google.com/?id=EV_mFgnyPoMC |format=Limited preview |year=2004 |publisher=Horizon Bioscience |location=Wymondham, Norfolk, UK |isbn=978-0-9545232-3-7 |ref=CITEREFKlenkFeldmann2004}}
* {{Cite book |last=Kuhn |first=Jens H. |title=Filoviruses: A Compendium of 40 Years of Epidemiological, Clinical, and Laboratory Studies. Archives of Virology Supplement, vol. 20 |url=http://books.google.com/?id=LaOue0F9Ns4C |format=Limited preview |year=2008 |publisher=SpringerWienNewYork |location=Vienna |isbn=978-3-211-20670-6 |ref=CITEREFKuhn2008}}
* {{Cite book |last1=McCormick |first1=Joseph |last2=Fisher-Hoch |first2=Susan |others=Horvitz, Leslie Alan |title=Level 4: Virus Hunters of the CDC |url=http://books.google.com/?id=QEvR3aJX2m0C |format=Limited preview |origyear=1996 |edition=Updated [3rd] |year=1999 |publisher=Barnes &amp; Noble |isbn=978-0-7607-1208-5 |ref=CITEREFMcCormickFisher-Hoch1999 |month=June}}
* {{Cite book |last=Pattyn |first=S. R. |title=Ebola Virus Haemorrhagic Fever |year=1978 |url=http://www.itg.be/ebola/ |format=Full free text |edition=1st |publisher=Elsevier/North-Holland Biomedical Press |location=Amsterdam |isbn=0-444-80060-3 |ref=CITEREFPattyn1978}}
* {{Cite book | last1 = Ryabchikova | first1 = Elena I. | last2 = Price | first2 = Barbara B. | title = Ebola and Marburg Viruses: A View of Infection Using Electron Microscopy | year = 2004 | publisher = Battelle Press | location = Columbus, Ohio | isbn = 978-1-57477-131-2 | ref = CITEREFRyabchikovaPrice2004 }}
{{Refend}}
--&gt;

==Okuhlanganiswe nalokhu okunye==
{{Refbegin}}
* [http://viralzone.expasy.org/all_by_species/207.html ViralZone: Ebola-like viruses] – Virological repository from the [[Swiss Institute of Bioinformatics]]
* [http://www.cdc.gov/vhf/ebola/ CDC: Ebola hemorrhagic fever] – Centers for Disease Control and Prevention, Special Pathogens Branch
* [http://www.who.int/csr/disease/ebola/en/ WHO: Ebola haemorrhagic fever] – World Health Organization, Global Alert and Response
* [http://www.viprbrc.org/brc/home.do?decorator=filo Virus Pathogen Database and Analysis Resource (ViPR): Filoviridae]
* [http://www.ebi.ac.uk/pdbe/emdb/searchResults.html/?q=ebola 3D macromolecular structures of the Ebola virus archived in the EM Data Bank(EMDB)]
* [https://maps.google.com/maps/ms?msa=0&amp;msid=202977755949863934429.0004c658eb30f9c4fb1c0&amp;ie=UTF8&amp;t=h&amp;ll=27.371767,5.273438&amp;spn=110.017392,184.21875&amp;z=2&amp;source=embed&amp;dg=feature Google Map of Ebola Outbreaks]
* [http://www.who.int/csr/bioriskreduction/filovirus_infection_control/en/ WHO recommended infection control measures]
{{Refend}}</text>
      <sha1>jl2k004gidk0b6kmmosmr0zzkuexv79</sha1>
    </revision>
    <revision>
      <id>1329</id>
      <parentid>1328</parentid>
      <timestamp>2014-09-04T16:05:49Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>Undo revision 2265993 by [[Khethekileko:Contributions/CFCF|CFCF]] ([[Umsebenzisi asiqongelane:CFCF|talk]])</comment>
      <origin>1329</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9461" sha1="6j19jywuz99et5e5y5t1a1w2x1on4ai" xml:space="preserve">{{Infobox disease
| name           = Ubulwelwe be-Ebola
| image          = 7042 lores-Ebola-Zaire-CDC Photo.jpg
| caption        = Isithombe sango-1976 sabahlengikazi ababili, bajame hlanu kwaka [[Mayinga N'Seka|Mayinga N.]], omumuntu osahlelwe mumulwana we-Ebola. Wahlongakala ngemva kwamalanga ambalwa ngonobangela wobulwelwe bokopha nokurhadza kweengazi.
| DiseasesDB     = 18043
| ICD10          = {{ICD10|A|98|4|a|90}}
| ICD9           = {{ICD9|065.8}}
| MedlinePlus    = 001339
| eMedicineSubj  = med
| eMedicineTopic = 626
| MeshID         = D019142
}}
'''Ubulwelwe be-Ebola''' nofana ('''EVD''') '''I-Ebola nomulwana wokopha iingazi okhambisana nomgomani''' ('''EHF''') mimulwana ebangwa bulwelwe bevayirasi ebizwa nge- [[Ebola]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo athoma ukubonakala phakathi kwamalanga amabili ukuya eemvekeni eentathu ngemva sewungenwe bulwelwe lobu, [[njengomgomani ongapheliko]], umphimbo obabako onesilonda, [[imisipha ebuhlungu kanye nehloko esawula kabuhlungu]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kesinye isikhathi [[ungahlanza]], uphakanyelwe ziimbindi nesifo  [[sokurhuda]], kuzokwenza bona [[amaphaphu]] kanye [[neso]] zingasasebenzi kuhle.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Nasele sekufike lapha, abanye baba nomraro [[wokopha iingazi]].&lt;ref name=WHO2014&gt;{{cite web|title=Ebola virus disease Fact sheet N°103|url=http://www.who.int/mediacentre/factsheets/fs103/en/|work=World Health Organization|accessdate=12 April 2014|date=March 2014}}&lt;/ref&gt;

&lt;!-- Cause and Diagnosis--&gt;
Umulwana lo ungangena nawuthintana [[neengazi]] zomuntu ophethwe ngibo nofana [[umjuluko]] nanyana [[okunye nokunye okusamanzana]] okuvela (eenlwaneni [[kumaphelaphelana]] nofana iimfene).&lt;ref name=WHO2014/&gt; Bekube nje umulwana akukatholakali bona ungangena ngokuwurhogela emmoyeni.&lt;ref name=WHOAir2014&gt;{{cite web|title=2014 Ebola Virus Disease (EVD) outbreak in West Africa|url=http://www.who.int/ith/updates/20140421/en/|website=WHO|accessdate=3 August 2014|date=Apr 21 2014}}&lt;/ref&gt; Kukholelwa bonyana abomaphelaphelani bakwazi  ukuphatha umulwana lo kodwana wona angaphathwa ngiwo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kwaba khona umuntu otheleleke ngomulwana lo, umulwana lo ungatheleleka kabanye abantu godu ngesikhathi esifitjhani.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amadoda angasinda ngemva kokulatjhwa angathelela abanye abantu ngokuthunda [[imbewu]] yabo lokha nabaya emsemeni nakungakapheli iinyanga ezimbili.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nakufanele uhlahlutjwe nofana uhlolelwe ubulwelwe lobu be-ebola kufanele izifo ezifana [[nomalalahlengezela]], [[isifo sokurhuda]] kanye omulwana [[wokopha iingazi okhambisana nomgomani]]  inganakwa ukwenzelela ukuthola imiphumela ekungiyo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ukuqinisekisa umrabho womraro wobulwelwe lobu amasampula weengazi ayathathwa ayokuhlolelwa ubulwelwe [[nesivikelasifo seengazini]] kanye ne [[i-RNA]] lobu kanye nengongwana ebanga ubulwelwe lobu.&lt;ref name=WHO2014/&gt;

&lt;!-- Prevention --&gt;
Ukuvikela ubulwelwe lobu kungaphungulwa ukuthelelana hlangana neemfene kanye neemfarigi ezingenwe bulwelwelwe lobu bukhandelwe bona bungayi ebantwini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kungenziwa ngokobana kuhlolwe iinlwana lezi ukobana zinabo ubulwelwe lobu na, nakutholakala bona zinabo kungenzeka bona zibulawe bese kugujelwa imizimba yazo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nawupheka inyama bese wembatha izambatho zokuzivikela nakho kungakusiza,&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; ukwembatha izambatho zokuzivikela lokha nawuhlala nofana uhlanu kwaloyo muntu ongenwe mumulwana lowo [[kanye nokuhlamba izandla ngesibha]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amasampula wananyana yini esamanzana yalabo bantu abangenwe mumulwana lo kufanele zitjhejwe khulu, ubalekele ukuthintana nazo.&lt;ref name=WHO2014/&gt;

&lt;!-- Treatment, Prognosis and Epidemiology--&gt;
Ayikho intatha elapha ubulwelwe lobu; imizamo yokobana kusizwe abantu abangenwe bulwelwe lobu kukobana [[kwenziwe umtswako]] (banikelwe amanzi anetswayi) ukobana bawasele nofana [[bafakwe amadribhu azobangenisela okusamanzana emzimbeni wabo]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu [[buneembalobalo eziphezulu zabantu abafako]]: nabangenwe ngibo ubulwelwe lobu, i-ebola ingabulala pheze isiquntu-50% nofana i-90% yabantu abatheleleke ngayo.&lt;ref name=WHO2014/&gt;&lt;ref name=&quot;Elsevier/Academic Press&quot;&gt;{{cite book|author1=C.M. Fauquet|title=Virus taxonomy classification and nomenclature of viruses; 8th report of the International Committee on Taxonomy of Viruses|date=2005|publisher=Elsevier/Academic Press|location=Oxford|isbn=9780080575483|page=648|url=http://books.google.ca/books?id=9Wy7Jgy5RWYC&amp;pg=PA648}}&lt;/ref&gt; I-EVD yathoma ukwazakala endaweni enarheni ye [[Sudan]] kanye ne- [[Democratic Republic of Congo]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu butholakala khulu eenarheni zethrophigi zenarhakazi yeAfrika [[Iphakathi le-Sehara ye-Afrika]].&lt;ref name=WHO2014/&gt; Ngo-1976 (ukutholakala kwabo ubulwelwe lobu] ukufikela ngo-2013, besele ingene yatheleleka ebantwini abangaphasi kwe-1000.&lt;ref name=WHO2014/&gt;&lt;ref name=MMWRJune2014&gt;{{cite web|title=Ebola Viral Disease Outbreak — West Africa, 2014|url=http://www.cdc.gov/mmwr/preview/mmwrhtml/mm6325a4.htm?s_cid=mm6325a4_w|website=CDC|accessdate=26 June 2014|date=June 27, 2014}}&lt;/ref&gt; Ukuqubuka kobulwelwe lobu obukhulu obungazange khebubonwe ngilobu bamuva nje ngebe [[2014  Tjhingalanga ye-Afrika Ukuqubuka kwe-Ebola]], sebele bungene eenarheni [[Guinea]], [[Sierra Leone]], [[Liberia]] begodu ingatheleka ingene ne [[Nigeria]].&lt;ref name=CDC2014&gt;{{cite web|title=CDC urges all US residents to avoid nonessential travel to Liberia, Guinea, and Sierra Leone because of an unprecedented outbreak of Ebola.|url=http://wwwnc.cdc.gov/travel/notices/warning/ebola-liberia|website=CDC|accessdate=2 August 2014|date=July 31, 2014}}&lt;/ref&gt;&lt;ref name=CDCAug2014N&gt;{{cite web|title=Outbreak of Ebola in Guinea, Liberia, and Sierra Leone|url=http://www.cdc.gov/vhf/ebola/outbreaks/guinea/index.html|website=CDC|accessdate=5 August 2014|date=August 4, 2014}}&lt;/ref&gt; Ukusukela ngoRhoboyi 2014 sele kubikwe bona kunabantu esele bangenwe bulwelwe lobu abayi-1600.&lt;ref&gt;{{cite web|title=Ebola virus disease update - West Africa|url=http://www.who.int/csr/don/2014_08_04_ebola/en/|website=WHO|accessdate=6 August 2014|date=Aug 4, 2014}}&lt;/ref&gt; Imizamo yona iyenziwa bona kutholakalle [[intatha/isihlahla]] esingalapha ubulwelwe lobu, kodwana okwanje asikho.&lt;ref name=WHO2014/&gt;

== Isikhombiso selwazi==
{{Reflist|colwidth=25em}}

; IBhibhliyografu
{{Refbegin}}
* {{Cite book |last=Klenk |first=Hans-Dieter |title=Marburg and Ebola Viruses (Current Topics in Microbiology and Immunology) |date=January 1999 |publisher=Springer-Verlag Telos |location=Berlin |isbn=978-3-540-64729-4 |ref=CITEREFKlenk1999}}
* {{Cite book |first1=Hans-Dieter |last1=Klenk |first2=Heinz |last2=Feldmann |title=Ebola and Marburg viruses: molecular and cellular biology |url=http://books.google.com/?id=EV_mFgnyPoMC |format=Limited preview |year=2004 |publisher=Horizon Bioscience |location=Wymondham, Norfolk, UK |isbn=978-0-9545232-3-7 |ref=CITEREFKlenkFeldmann2004}}
* {{Cite book |last=Kuhn |first=Jens H. |title=Filoviruses: A Compendium of 40 Years of Epidemiological, Clinical, and Laboratory Studies. Archives of Virology Supplement, vol. 20 |url=http://books.google.com/?id=LaOue0F9Ns4C |format=Limited preview |year=2008 |publisher=SpringerWienNewYork |location=Vienna |isbn=978-3-211-20670-6 |ref=CITEREFKuhn2008}}
* {{Cite book |last1=McCormick |first1=Joseph |last2=Fisher-Hoch |first2=Susan |others=Horvitz, Leslie Alan |title=Level 4: Virus Hunters of the CDC |url=http://books.google.com/?id=QEvR3aJX2m0C |format=Limited preview |origyear=1996 |edition=Updated [3rd] |year=1999 |publisher=Barnes &amp; Noble |isbn=978-0-7607-1208-5 |ref=CITEREFMcCormickFisher-Hoch1999 |month=June}}
* {{Cite book |last=Pattyn |first=S. R. |title=Ebola Virus Haemorrhagic Fever |year=1978 |url=http://www.itg.be/ebola/ |format=Full free text |edition=1st |publisher=Elsevier/North-Holland Biomedical Press |location=Amsterdam |isbn=0-444-80060-3 |ref=CITEREFPattyn1978}}
* {{Cite book | last1 = Ryabchikova | first1 = Elena I. | last2 = Price | first2 = Barbara B. | title = Ebola and Marburg Viruses: A View of Infection Using Electron Microscopy | year = 2004 | publisher = Battelle Press | location = Columbus, Ohio | isbn = 978-1-57477-131-2 | ref = CITEREFRyabchikovaPrice2004 }}
{{Refend}}

==Okuhlanganiswe nalokhu okunye==
{{Refbegin}}
* [http://viralzone.expasy.org/all_by_species/207.html ViralZone: Ebola-like viruses] – Virological repository from the [[Swiss Institute of Bioinformatics]]
* [http://www.cdc.gov/vhf/ebola/ CDC: Ebola hemorrhagic fever] – Centers for Disease Control and Prevention, Special Pathogens Branch
* [http://www.who.int/csr/disease/ebola/en/ WHO: Ebola haemorrhagic fever] – World Health Organization, Global Alert and Response
* [http://www.viprbrc.org/brc/home.do?decorator=filo Virus Pathogen Database and Analysis Resource (ViPR): Filoviridae]
* [http://www.ebi.ac.uk/pdbe/emdb/searchResults.html/?q=ebola 3D macromolecular structures of the Ebola virus archived in the EM Data Bank(EMDB)]
* [https://maps.google.com/maps/ms?msa=0&amp;msid=202977755949863934429.0004c658eb30f9c4fb1c0&amp;ie=UTF8&amp;t=h&amp;ll=27.371767,5.273438&amp;spn=110.017392,184.21875&amp;z=2&amp;source=embed&amp;dg=feature Google Map of Ebola Outbreaks]
* [http://www.who.int/csr/bioriskreduction/filovirus_infection_control/en/ WHO recommended infection control measures]
{{Refend}}</text>
      <sha1>6j19jywuz99et5e5y5t1a1w2x1on4ai</sha1>
    </revision>
    <revision>
      <id>1330</id>
      <parentid>1329</parentid>
      <timestamp>2021-08-12T13:21:34Z</timestamp>
      <contributor>
        <username>incubator&gt;InternetArchiveBot</username>
        <id>0</id>
      </contributor>
      <comment>Rescuing 1 sources and tagging 0 as dead.) #IABot (v2.0.8</comment>
      <origin>1330</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9504" sha1="1anv7k9e9sp6ls1nxb404lqhbspnlpz" xml:space="preserve">{{Infobox disease
| name           = Ubulwelwe be-Ebola
| image          = 7042 lores-Ebola-Zaire-CDC Photo.jpg
| caption        = Isithombe sango-1976 sabahlengikazi ababili, bajame hlanu kwaka [[Mayinga N'Seka|Mayinga N.]], omumuntu osahlelwe mumulwana we-Ebola. Wahlongakala ngemva kwamalanga ambalwa ngonobangela wobulwelwe bokopha nokurhadza kweengazi.
| DiseasesDB     = 18043
| ICD10          = {{ICD10|A|98|4|a|90}}
| ICD9           = {{ICD9|065.8}}
| MedlinePlus    = 001339
| eMedicineSubj  = med
| eMedicineTopic = 626
| MeshID         = D019142
}}
'''Ubulwelwe be-Ebola''' nofana ('''EVD''') '''I-Ebola nomulwana wokopha iingazi okhambisana nomgomani''' ('''EHF''') mimulwana ebangwa bulwelwe bevayirasi ebizwa nge- [[Ebola]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo athoma ukubonakala phakathi kwamalanga amabili ukuya eemvekeni eentathu ngemva sewungenwe bulwelwe lobu, [[njengomgomani ongapheliko]], umphimbo obabako onesilonda, [[imisipha ebuhlungu kanye nehloko esawula kabuhlungu]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kesinye isikhathi [[ungahlanza]], uphakanyelwe ziimbindi nesifo  [[sokurhuda]], kuzokwenza bona [[amaphaphu]] kanye [[neso]] zingasasebenzi kuhle.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Nasele sekufike lapha, abanye baba nomraro [[wokopha iingazi]].&lt;ref name=WHO2014&gt;{{cite web|title=Ebola virus disease Fact sheet N°103|url=http://www.who.int/mediacentre/factsheets/fs103/en/|work=World Health Organization|accessdate=12 April 2014|date=March 2014}}&lt;/ref&gt;

&lt;!-- Cause and Diagnosis--&gt;
Umulwana lo ungangena nawuthintana [[neengazi]] zomuntu ophethwe ngibo nofana [[umjuluko]] nanyana [[okunye nokunye okusamanzana]] okuvela (eenlwaneni [[kumaphelaphelana]] nofana iimfene).&lt;ref name=WHO2014/&gt; Bekube nje umulwana akukatholakali bona ungangena ngokuwurhogela emmoyeni.&lt;ref name=WHOAir2014&gt;{{cite web|title=2014 Ebola Virus Disease (EVD) outbreak in West Africa|url=http://www.who.int/ith/updates/20140421/en/|website=WHO|accessdate=3 August 2014|date=Apr 21 2014}}&lt;/ref&gt; Kukholelwa bonyana abomaphelaphelani bakwazi  ukuphatha umulwana lo kodwana wona angaphathwa ngiwo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kwaba khona umuntu otheleleke ngomulwana lo, umulwana lo ungatheleleka kabanye abantu godu ngesikhathi esifitjhani.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amadoda angasinda ngemva kokulatjhwa angathelela abanye abantu ngokuthunda [[imbewu]] yabo lokha nabaya emsemeni nakungakapheli iinyanga ezimbili.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nakufanele uhlahlutjwe nofana uhlolelwe ubulwelwe lobu be-ebola kufanele izifo ezifana [[nomalalahlengezela]], [[isifo sokurhuda]] kanye omulwana [[wokopha iingazi okhambisana nomgomani]]  inganakwa ukwenzelela ukuthola imiphumela ekungiyo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ukuqinisekisa umrabho womraro wobulwelwe lobu amasampula weengazi ayathathwa ayokuhlolelwa ubulwelwe [[nesivikelasifo seengazini]] kanye ne [[i-RNA]] lobu kanye nengongwana ebanga ubulwelwe lobu.&lt;ref name=WHO2014/&gt;

&lt;!-- Prevention --&gt;
Ukuvikela ubulwelwe lobu kungaphungulwa ukuthelelana hlangana neemfene kanye neemfarigi ezingenwe bulwelwelwe lobu bukhandelwe bona bungayi ebantwini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kungenziwa ngokobana kuhlolwe iinlwana lezi ukobana zinabo ubulwelwe lobu na, nakutholakala bona zinabo kungenzeka bona zibulawe bese kugujelwa imizimba yazo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nawupheka inyama bese wembatha izambatho zokuzivikela nakho kungakusiza,&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; ukwembatha izambatho zokuzivikela lokha nawuhlala nofana uhlanu kwaloyo muntu ongenwe mumulwana lowo [[kanye nokuhlamba izandla ngesibha]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amasampula wananyana yini esamanzana yalabo bantu abangenwe mumulwana lo kufanele zitjhejwe khulu, ubalekele ukuthintana nazo.&lt;ref name=WHO2014/&gt;

&lt;!-- Treatment, Prognosis and Epidemiology--&gt;
Ayikho intatha elapha ubulwelwe lobu; imizamo yokobana kusizwe abantu abangenwe bulwelwe lobu kukobana [[kwenziwe umtswako]] (banikelwe amanzi anetswayi) ukobana bawasele nofana [[bafakwe amadribhu azobangenisela okusamanzana emzimbeni wabo]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu [[buneembalobalo eziphezulu zabantu abafako]]: nabangenwe ngibo ubulwelwe lobu, i-ebola ingabulala pheze isiquntu-50% nofana i-90% yabantu abatheleleke ngayo.&lt;ref name=WHO2014/&gt;&lt;ref name=&quot;Elsevier/Academic Press&quot;&gt;{{cite book|author1=C.M. Fauquet|title=Virus taxonomy classification and nomenclature of viruses; 8th report of the International Committee on Taxonomy of Viruses|date=2005|publisher=Elsevier/Academic Press|location=Oxford|isbn=9780080575483|page=648|url=http://books.google.ca/books?id=9Wy7Jgy5RWYC&amp;pg=PA648}}&lt;/ref&gt; I-EVD yathoma ukwazakala endaweni enarheni ye [[Sudan]] kanye ne- [[Democratic Republic of Congo]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu butholakala khulu eenarheni zethrophigi zenarhakazi yeAfrika [[Iphakathi le-Sehara ye-Afrika]].&lt;ref name=WHO2014/&gt; Ngo-1976 (ukutholakala kwabo ubulwelwe lobu] ukufikela ngo-2013, besele ingene yatheleleka ebantwini abangaphasi kwe-1000.&lt;ref name=WHO2014/&gt;&lt;ref name=MMWRJune2014&gt;{{cite web|title=Ebola Viral Disease Outbreak — West Africa, 2014|url=http://www.cdc.gov/mmwr/preview/mmwrhtml/mm6325a4.htm?s_cid=mm6325a4_w|website=CDC|accessdate=26 June 2014|date=June 27, 2014}}&lt;/ref&gt; Ukuqubuka kobulwelwe lobu obukhulu obungazange khebubonwe ngilobu bamuva nje ngebe [[2014  Tjhingalanga ye-Afrika Ukuqubuka kwe-Ebola]], sebele bungene eenarheni [[Guinea]], [[Sierra Leone]], [[Liberia]] begodu ingatheleka ingene ne [[Nigeria]].&lt;ref name=CDC2014&gt;{{cite web|title=CDC urges all US residents to avoid nonessential travel to Liberia, Guinea, and Sierra Leone because of an unprecedented outbreak of Ebola.|url=http://wwwnc.cdc.gov/travel/notices/warning/ebola-liberia|website=CDC|accessdate=2 August 2014|date=July 31, 2014}}&lt;/ref&gt;&lt;ref name=CDCAug2014N&gt;{{cite web|title=Outbreak of Ebola in Guinea, Liberia, and Sierra Leone|url=http://www.cdc.gov/vhf/ebola/outbreaks/guinea/index.html|website=CDC|accessdate=5 August 2014|date=August 4, 2014}}&lt;/ref&gt; Ukusukela ngoRhoboyi 2014 sele kubikwe bona kunabantu esele bangenwe bulwelwe lobu abayi-1600.&lt;ref&gt;{{cite web|title=Ebola virus disease update - West Africa|url=http://www.who.int/csr/don/2014_08_04_ebola/en/|website=WHO|accessdate=6 August 2014|date=Aug 4, 2014}}&lt;/ref&gt; Imizamo yona iyenziwa bona kutholakalle [[intatha/isihlahla]] esingalapha ubulwelwe lobu, kodwana okwanje asikho.&lt;ref name=WHO2014/&gt;

== Isikhombiso selwazi==
{{Reflist|colwidth=25em}}

; IBhibhliyografu
{{Refbegin}}
* {{Cite book |last=Klenk |first=Hans-Dieter |title=Marburg and Ebola Viruses (Current Topics in Microbiology and Immunology) |date=January 1999 |publisher=Springer-Verlag Telos |location=Berlin |isbn=978-3-540-64729-4 |ref=CITEREFKlenk1999}}
* {{Cite book |first1=Hans-Dieter |last1=Klenk |first2=Heinz |last2=Feldmann |title=Ebola and Marburg viruses: molecular and cellular biology |url=http://books.google.com/?id=EV_mFgnyPoMC |format=Limited preview |year=2004 |publisher=Horizon Bioscience |location=Wymondham, Norfolk, UK |isbn=978-0-9545232-3-7 |ref=CITEREFKlenkFeldmann2004}}
* {{Cite book |last=Kuhn |first=Jens H. |title=Filoviruses: A Compendium of 40 Years of Epidemiological, Clinical, and Laboratory Studies. Archives of Virology Supplement, vol. 20 |url=http://books.google.com/?id=LaOue0F9Ns4C |format=Limited preview |year=2008 |publisher=SpringerWienNewYork |location=Vienna |isbn=978-3-211-20670-6 |ref=CITEREFKuhn2008}}
* {{Cite book |last1=McCormick |first1=Joseph |last2=Fisher-Hoch |first2=Susan |others=Horvitz, Leslie Alan |title=Level 4: Virus Hunters of the CDC |url=http://books.google.com/?id=QEvR3aJX2m0C |format=Limited preview |origyear=1996 |edition=Updated [3rd] |year=1999 |publisher=Barnes &amp; Noble |isbn=978-0-7607-1208-5 |ref=CITEREFMcCormickFisher-Hoch1999 |month=June}}
* {{Cite book |last=Pattyn |first=S. R. |title=Ebola Virus Haemorrhagic Fever |year=1978 |url=http://www.itg.be/ebola/ |format=Full free text |edition=1st |publisher=Elsevier/North-Holland Biomedical Press |location=Amsterdam |isbn=0-444-80060-3 |ref=CITEREFPattyn1978}}
* {{Cite book | last1 = Ryabchikova | first1 = Elena I. | last2 = Price | first2 = Barbara B. | title = Ebola and Marburg Viruses: A View of Infection Using Electron Microscopy | year = 2004 | publisher = Battelle Press | location = Columbus, Ohio | isbn = 978-1-57477-131-2 | ref = CITEREFRyabchikovaPrice2004 }}
{{Refend}}

==Okuhlanganiswe nalokhu okunye==
{{Refbegin}}
* [http://viralzone.expasy.org/all_by_species/207.html ViralZone: Ebola-like viruses] – Virological repository from the [[Swiss Institute of Bioinformatics]]
* [http://www.cdc.gov/vhf/ebola/ CDC: Ebola hemorrhagic fever] – Centers for Disease Control and Prevention, Special Pathogens Branch
* [http://www.who.int/csr/disease/ebola/en/ WHO: Ebola haemorrhagic fever] – World Health Organization, Global Alert and Response
* [http://www.viprbrc.org/brc/home.do?decorator=filo Virus Pathogen Database and Analysis Resource (ViPR): Filoviridae]
* [https://web.archive.org/web/20140808072117/http://www.ebi.ac.uk/pdbe/emdb/searchResults.html/?q=ebola 3D macromolecular structures of the Ebola virus archived in the EM Data Bank(EMDB)]
* [https://maps.google.com/maps/ms?msa=0&amp;msid=202977755949863934429.0004c658eb30f9c4fb1c0&amp;ie=UTF8&amp;t=h&amp;ll=27.371767,5.273438&amp;spn=110.017392,184.21875&amp;z=2&amp;source=embed&amp;dg=feature Google Map of Ebola Outbreaks]
* [http://www.who.int/csr/bioriskreduction/filovirus_infection_control/en/ WHO recommended infection control measures]
{{Refend}}</text>
      <sha1>1anv7k9e9sp6ls1nxb404lqhbspnlpz</sha1>
    </revision>
    <revision>
      <id>1331</id>
      <parentid>1330</parentid>
      <timestamp>2021-09-01T20:59:53Z</timestamp>
      <contributor>
        <username>incubator&gt;InternetArchiveBot</username>
        <id>0</id>
      </contributor>
      <comment>Rescuing 2 sources and tagging 0 as dead.) #IABot (v2.0.8</comment>
      <origin>1331</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9590" sha1="9chaiekct70yiyr57tek1un16r8em4k" xml:space="preserve">{{Infobox disease
| name           = Ubulwelwe be-Ebola
| image          = 7042 lores-Ebola-Zaire-CDC Photo.jpg
| caption        = Isithombe sango-1976 sabahlengikazi ababili, bajame hlanu kwaka [[Mayinga N'Seka|Mayinga N.]], omumuntu osahlelwe mumulwana we-Ebola. Wahlongakala ngemva kwamalanga ambalwa ngonobangela wobulwelwe bokopha nokurhadza kweengazi.
| DiseasesDB     = 18043
| ICD10          = {{ICD10|A|98|4|a|90}}
| ICD9           = {{ICD9|065.8}}
| MedlinePlus    = 001339
| eMedicineSubj  = med
| eMedicineTopic = 626
| MeshID         = D019142
}}
'''Ubulwelwe be-Ebola''' nofana ('''EVD''') '''I-Ebola nomulwana wokopha iingazi okhambisana nomgomani''' ('''EHF''') mimulwana ebangwa bulwelwe bevayirasi ebizwa nge- [[Ebola]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo athoma ukubonakala phakathi kwamalanga amabili ukuya eemvekeni eentathu ngemva sewungenwe bulwelwe lobu, [[njengomgomani ongapheliko]], umphimbo obabako onesilonda, [[imisipha ebuhlungu kanye nehloko esawula kabuhlungu]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kesinye isikhathi [[ungahlanza]], uphakanyelwe ziimbindi nesifo  [[sokurhuda]], kuzokwenza bona [[amaphaphu]] kanye [[neso]] zingasasebenzi kuhle.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Nasele sekufike lapha, abanye baba nomraro [[wokopha iingazi]].&lt;ref name=WHO2014&gt;{{cite web|title=Ebola virus disease Fact sheet N°103|url=http://www.who.int/mediacentre/factsheets/fs103/en/|work=World Health Organization|accessdate=12 April 2014|date=March 2014}}&lt;/ref&gt;

&lt;!-- Cause and Diagnosis--&gt;
Umulwana lo ungangena nawuthintana [[neengazi]] zomuntu ophethwe ngibo nofana [[umjuluko]] nanyana [[okunye nokunye okusamanzana]] okuvela (eenlwaneni [[kumaphelaphelana]] nofana iimfene).&lt;ref name=WHO2014/&gt; Bekube nje umulwana akukatholakali bona ungangena ngokuwurhogela emmoyeni.&lt;ref name=WHOAir2014&gt;{{cite web|title=2014 Ebola Virus Disease (EVD) outbreak in West Africa|url=http://www.who.int/ith/updates/20140421/en/|website=WHO|accessdate=3 August 2014|date=Apr 21 2014}}&lt;/ref&gt; Kukholelwa bonyana abomaphelaphelani bakwazi  ukuphatha umulwana lo kodwana wona angaphathwa ngiwo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kwaba khona umuntu otheleleke ngomulwana lo, umulwana lo ungatheleleka kabanye abantu godu ngesikhathi esifitjhani.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amadoda angasinda ngemva kokulatjhwa angathelela abanye abantu ngokuthunda [[imbewu]] yabo lokha nabaya emsemeni nakungakapheli iinyanga ezimbili.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nakufanele uhlahlutjwe nofana uhlolelwe ubulwelwe lobu be-ebola kufanele izifo ezifana [[nomalalahlengezela]], [[isifo sokurhuda]] kanye omulwana [[wokopha iingazi okhambisana nomgomani]]  inganakwa ukwenzelela ukuthola imiphumela ekungiyo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ukuqinisekisa umrabho womraro wobulwelwe lobu amasampula weengazi ayathathwa ayokuhlolelwa ubulwelwe [[nesivikelasifo seengazini]] kanye ne [[i-RNA]] lobu kanye nengongwana ebanga ubulwelwe lobu.&lt;ref name=WHO2014/&gt;

&lt;!-- Prevention --&gt;
Ukuvikela ubulwelwe lobu kungaphungulwa ukuthelelana hlangana neemfene kanye neemfarigi ezingenwe bulwelwelwe lobu bukhandelwe bona bungayi ebantwini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kungenziwa ngokobana kuhlolwe iinlwana lezi ukobana zinabo ubulwelwe lobu na, nakutholakala bona zinabo kungenzeka bona zibulawe bese kugujelwa imizimba yazo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nawupheka inyama bese wembatha izambatho zokuzivikela nakho kungakusiza,&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; ukwembatha izambatho zokuzivikela lokha nawuhlala nofana uhlanu kwaloyo muntu ongenwe mumulwana lowo [[kanye nokuhlamba izandla ngesibha]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amasampula wananyana yini esamanzana yalabo bantu abangenwe mumulwana lo kufanele zitjhejwe khulu, ubalekele ukuthintana nazo.&lt;ref name=WHO2014/&gt;

&lt;!-- Treatment, Prognosis and Epidemiology--&gt;
Ayikho intatha elapha ubulwelwe lobu; imizamo yokobana kusizwe abantu abangenwe bulwelwe lobu kukobana [[kwenziwe umtswako]] (banikelwe amanzi anetswayi) ukobana bawasele nofana [[bafakwe amadribhu azobangenisela okusamanzana emzimbeni wabo]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu [[buneembalobalo eziphezulu zabantu abafako]]: nabangenwe ngibo ubulwelwe lobu, i-ebola ingabulala pheze isiquntu-50% nofana i-90% yabantu abatheleleke ngayo.&lt;ref name=WHO2014/&gt;&lt;ref name=&quot;Elsevier/Academic Press&quot;&gt;{{cite book|author1=C.M. Fauquet|title=Virus taxonomy classification and nomenclature of viruses; 8th report of the International Committee on Taxonomy of Viruses|date=2005|publisher=Elsevier/Academic Press|location=Oxford|isbn=9780080575483|page=648|url=http://books.google.ca/books?id=9Wy7Jgy5RWYC&amp;pg=PA648}}&lt;/ref&gt; I-EVD yathoma ukwazakala endaweni enarheni ye [[Sudan]] kanye ne- [[Democratic Republic of Congo]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu butholakala khulu eenarheni zethrophigi zenarhakazi yeAfrika [[Iphakathi le-Sehara ye-Afrika]].&lt;ref name=WHO2014/&gt; Ngo-1976 (ukutholakala kwabo ubulwelwe lobu] ukufikela ngo-2013, besele ingene yatheleleka ebantwini abangaphasi kwe-1000.&lt;ref name=WHO2014/&gt;&lt;ref name=MMWRJune2014&gt;{{cite web|title=Ebola Viral Disease Outbreak — West Africa, 2014|url=http://www.cdc.gov/mmwr/preview/mmwrhtml/mm6325a4.htm?s_cid=mm6325a4_w|website=CDC|accessdate=26 June 2014|date=June 27, 2014}}&lt;/ref&gt; Ukuqubuka kobulwelwe lobu obukhulu obungazange khebubonwe ngilobu bamuva nje ngebe [[2014  Tjhingalanga ye-Afrika Ukuqubuka kwe-Ebola]], sebele bungene eenarheni [[Guinea]], [[Sierra Leone]], [[Liberia]] begodu ingatheleka ingene ne [[Nigeria]].&lt;ref name=CDC2014&gt;{{cite web|title=CDC urges all US residents to avoid nonessential travel to Liberia, Guinea, and Sierra Leone because of an unprecedented outbreak of Ebola.|url=http://wwwnc.cdc.gov/travel/notices/warning/ebola-liberia|website=CDC|accessdate=2 August 2014|date=July 31, 2014}}&lt;/ref&gt;&lt;ref name=CDCAug2014N&gt;{{cite web|title=Outbreak of Ebola in Guinea, Liberia, and Sierra Leone|url=http://www.cdc.gov/vhf/ebola/outbreaks/guinea/index.html|website=CDC|accessdate=5 August 2014|date=August 4, 2014}}&lt;/ref&gt; Ukusukela ngoRhoboyi 2014 sele kubikwe bona kunabantu esele bangenwe bulwelwe lobu abayi-1600.&lt;ref&gt;{{cite web|title=Ebola virus disease update - West Africa|url=http://www.who.int/csr/don/2014_08_04_ebola/en/|website=WHO|accessdate=6 August 2014|date=Aug 4, 2014}}&lt;/ref&gt; Imizamo yona iyenziwa bona kutholakalle [[intatha/isihlahla]] esingalapha ubulwelwe lobu, kodwana okwanje asikho.&lt;ref name=WHO2014/&gt;

== Isikhombiso selwazi==
{{Reflist|colwidth=25em}}

; IBhibhliyografu
{{Refbegin}}
* {{Cite book |last=Klenk |first=Hans-Dieter |title=Marburg and Ebola Viruses (Current Topics in Microbiology and Immunology) |date=January 1999 |publisher=Springer-Verlag Telos |location=Berlin |isbn=978-3-540-64729-4 |ref=CITEREFKlenk1999}}
* {{Cite book |first1=Hans-Dieter |last1=Klenk |first2=Heinz |last2=Feldmann |title=Ebola and Marburg viruses: molecular and cellular biology |url=http://books.google.com/?id=EV_mFgnyPoMC |format=Limited preview |year=2004 |publisher=Horizon Bioscience |location=Wymondham, Norfolk, UK |isbn=978-0-9545232-3-7 |ref=CITEREFKlenkFeldmann2004}}
* {{Cite book |last=Kuhn |first=Jens H. |title=Filoviruses: A Compendium of 40 Years of Epidemiological, Clinical, and Laboratory Studies. Archives of Virology Supplement, vol. 20 |url=http://books.google.com/?id=LaOue0F9Ns4C |format=Limited preview |year=2008 |publisher=SpringerWienNewYork |location=Vienna |isbn=978-3-211-20670-6 |ref=CITEREFKuhn2008}}
* {{Cite book |last1=McCormick |first1=Joseph |last2=Fisher-Hoch |first2=Susan |others=Horvitz, Leslie Alan |title=Level 4: Virus Hunters of the CDC |url=http://books.google.com/?id=QEvR3aJX2m0C |format=Limited preview |origyear=1996 |edition=Updated [3rd] |year=1999 |publisher=Barnes &amp; Noble |isbn=978-0-7607-1208-5 |ref=CITEREFMcCormickFisher-Hoch1999 |month=June}}
* {{Cite book |last=Pattyn |first=S. R. |title=Ebola Virus Haemorrhagic Fever |year=1978 |url=http://www.itg.be/ebola/ |format=Full free text |edition=1st |publisher=Elsevier/North-Holland Biomedical Press |location=Amsterdam |isbn=0-444-80060-3 |ref=CITEREFPattyn1978}}
* {{Cite book | last1 = Ryabchikova | first1 = Elena I. | last2 = Price | first2 = Barbara B. | title = Ebola and Marburg Viruses: A View of Infection Using Electron Microscopy | year = 2004 | publisher = Battelle Press | location = Columbus, Ohio | isbn = 978-1-57477-131-2 | ref = CITEREFRyabchikovaPrice2004 }}
{{Refend}}

==Okuhlanganiswe nalokhu okunye==
{{Refbegin}}
* [http://viralzone.expasy.org/all_by_species/207.html ViralZone: Ebola-like viruses] – Virological repository from the [[Swiss Institute of Bioinformatics]]
* [http://www.cdc.gov/vhf/ebola/ CDC: Ebola hemorrhagic fever] – Centers for Disease Control and Prevention, Special Pathogens Branch
* [http://www.who.int/csr/disease/ebola/en/ WHO: Ebola haemorrhagic fever] – World Health Organization, Global Alert and Response
* [http://www.viprbrc.org/brc/home.do?decorator=filo Virus Pathogen Database and Analysis Resource (ViPR): Filoviridae]
* [https://web.archive.org/web/20140808072117/http://www.ebi.ac.uk/pdbe/emdb/searchResults.html/?q=ebola 3D macromolecular structures of the Ebola virus archived in the EM Data Bank(EMDB)]
* [https://web.archive.org/web/20140819171607/https://maps.google.com/maps/ms?msa=0&amp;msid=202977755949863934429.0004c658eb30f9c4fb1c0&amp;ie=UTF8&amp;t=h&amp;ll=27.371767,5.273438&amp;spn=110.017392,184.21875&amp;z=2&amp;source=embed&amp;dg=feature Google Map of Ebola Outbreaks]
* [https://web.archive.org/web/20140816223245/http://www.who.int/csr/bioriskreduction/filovirus_infection_control/en/ WHO recommended infection control measures]
{{Refend}}</text>
      <sha1>9chaiekct70yiyr57tek1un16r8em4k</sha1>
    </revision>
    <revision>
      <id>1332</id>
      <parentid>1331</parentid>
      <timestamp>2024-03-08T10:22:25Z</timestamp>
      <contributor>
        <username>incubator&gt;Simphiwe22</username>
        <id>0</id>
      </contributor>
      <comment>Added content</comment>
      <origin>1332</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9618" sha1="ra7mwswqpla5et0ctfi5bqefsijckg4" xml:space="preserve">{{Infobox disease
| name           = Ubulwelwe be-Ebola
| image          = 7042 lores-Ebola-Zaire-CDC Photo.jpg
| caption        = Isithombe sango-1976 sabahlengikazi ababili, bajame hlanu kwaka [[Mayinga N'Seka|Mayinga N.]], omumuntu osahlelwe mumulwana we-Ebola. Wahlongakala ngemva kwamalanga ambalwa ngonobangela wobulwelwe bokopha nokurhadza kweengazi.
| DiseasesDB     = 18043
| ICD10          = {{ICD10|A|98|4|a|90}}
| ICD9           = {{ICD9|065.8}}
| MedlinePlus    = 001339
| eMedicineSubj  = med
| eMedicineTopic = 626
| MeshID         = D019142
}}
'''Ubulwelwe be-Ebola''' nofana ('''EVD''') '''I-Ebola nomulwana wokopha iingazi okhambisana nomgomani''' ('''EHF''') mimulwana ebangwa bulwelwe bevayirasi ebizwa nge- [[Ebola]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo athoma ukubonakala phakathi kwamalanga amabili ukuya eemvekeni eentathu ngemva sewungenwe bulwelwe lobu, [[njengomgomani ongapheliko]], umphimbo obabako onesilonda, [[imisipha ebuhlungu kanye nehloko esawula kabuhlungu]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kesinye isikhathi [[ungahlanza]], uphakanyelwe ziimbindi nesifo  [[sokurhuda]], kuzokwenza bona [[amaphaphu]] kanye [[neso]] zingasasebenzi kuhle.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Nasele sekufike lapha, abanye baba nomraro [[wokopha iingazi]].&lt;ref name=WHO2014&gt;{{Cite web|title=Ebola virus disease Fact sheet N°103|url=http://www.who.int/mediacentre/factsheets/fs103/en/|work=World Health Organization|accessdate=12 April 2014|date=March 2014}}&lt;/ref&gt;

&lt;!-- Cause and Diagnosis--&gt;
Umulwana lo ungangena nawuthintana [[neengazi]] zomuntu ophethwe ngibo nofana [[umjuluko]] nanyana [[okunye nokunye okusamanzana]] okuvela (eenlwaneni [[kumaphelaphelana]] nofana iimfene).&lt;ref name=WHO2014/&gt; Bekube nje umulwana akukatholakali bona ungangena ngokuwurhogela emmoyeni.&lt;ref name=WHOAir2014&gt;{{Cite web|title=2014 Ebola Virus Disease (EVD) outbreak in West Africa|url=http://www.who.int/ith/updates/20140421/en/|website=WHO|accessdate=3 August 2014|date=Apr 21 2014}}&lt;/ref&gt; Kukholelwa bonyana abomaphelaphelani bakwazi  ukuphatha umulwana lo kodwana wona angaphathwa ngiwo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kwaba khona umuntu otheleleke ngomulwana lo, umulwana lo ungatheleleka kabanye abantu godu ngesikhathi esifitjhani.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amadoda angasinda ngemva kokulatjhwa angathelela abanye abantu ngokuthunda [[imbewu]] yabo lokha nabaya emsemeni nakungakapheli iinyanga ezimbili.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nakufanele uhlahlutjwe nofana uhlolelwe ubulwelwe lobu be-ebola kufanele izifo ezifana [[nomalalahlengezela]], [[isifo sokurhuda]] kanye omulwana [[wokopha iingazi okhambisana nomgomani]]  inganakwa ukwenzelela ukuthola imiphumela ekungiyo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ukuqinisekisa umrabho womraro wobulwelwe lobu amasampula weengazi ayathathwa ayokuhlolelwa ubulwelwe [[nesivikelasifo seengazini]] kanye ne [[i-RNA]] lobu kanye nengongwana ebanga ubulwelwe lobu.&lt;ref name=WHO2014/&gt;

&lt;!-- Prevention --&gt;
Ukuvikela ubulwelwe lobu kungaphungulwa ukuthelelana hlangana neemfene kanye neemfarigi ezingenwe bulwelwelwe lobu bukhandelwe bona bungayi ebantwini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kungenziwa ngokobana kuhlolwe iinlwana lezi ukobana zinabo ubulwelwe lobu na, nakutholakala bona zinabo kungenzeka bona zibulawe bese kugujelwa imizimba yazo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nawupheka inyama bese wembatha izambatho zokuzivikela nakho kungakusiza,&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; ukwembatha izambatho zokuzivikela lokha nawuhlala nofana uhlanu kwaloyo muntu ongenwe mumulwana lowo [[kanye nokuhlamba izandla ngesibha]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amasampula wananyana yini esamanzana yalabo bantu abangenwe mumulwana lo kufanele zitjhejwe khulu, ubalekele ukuthintana nazo.&lt;ref name=WHO2014/&gt;

&lt;!-- Treatment, Prognosis and Epidemiology--&gt;
Ayikho intatha elapha ubulwelwe lobu; imizamo yokobana kusizwe abantu abangenwe bulwelwe lobu kukobana [[kwenziwe umtswako]] (banikelwe amanzi anetswayi) ukobana bawasele nofana [[bafakwe amadribhu azobangenisela okusamanzana emzimbeni wabo]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu [[buneembalobalo eziphezulu zabantu abafako]]: nabangenwe ngibo ubulwelwe lobu, i-ebola ingabulala pheze isiquntu-50% nofana i-90% yabantu abatheleleke ngayo.&lt;ref name=WHO2014/&gt;&lt;ref name=&quot;Elsevier/Academic Press&quot;&gt;{{Cite book|author1=C.M. Fauquet|title=Virus taxonomy classification and nomenclature of viruses; 8th report of the International Committee on Taxonomy of Viruses|date=2005|publisher=Elsevier/Academic Press|location=Oxford|isbn=9780080575483|page=648|url=http://books.google.ca/books?id=9Wy7Jgy5RWYC&amp;pg=PA648}}&lt;/ref&gt; I-EVD yathoma ukwazakala endaweni enarheni ye [[Sudan]] kanye ne- [[Democratic Republic of Congo]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu butholakala khulu eenarheni zethrophigi zenarhakazi yeAfrika [[Iphakathi le-Sehara ye-Afrika]].&lt;ref name=WHO2014/&gt; Ngo-1976 (ukutholakala kwabo ubulwelwe lobu] ukufikela ngo-2013, besele ingene yatheleleka ebantwini abangaphasi kwe-1000.&lt;ref name=WHO2014/&gt;&lt;ref name=MMWRJune2014&gt;{{Cite web|title=Ebola Viral Disease Outbreak — West Africa, 2014|url=http://www.cdc.gov/mmwr/preview/mmwrhtml/mm6325a4.htm?s_cid=mm6325a4_w|website=CDC|accessdate=26 June 2014|date=June 27, 2014}}&lt;/ref&gt; Ukuqubuka kobulwelwe lobu obukhulu obungazange khebubonwe ngilobu bamuva nje ngebe [[2014  Tjhingalanga ye-Afrika Ukuqubuka kwe-Ebola]], sebele bungene eenarheni [[Guinea]], [[Sierra Leone]], [[Liberia]] begodu ingatheleka ingene ne [[Nigeria]].&lt;ref name=CDC2014&gt;{{Cite web|title=CDC urges all US residents to avoid nonessential travel to Liberia, Guinea, and Sierra Leone because of an unprecedented outbreak of Ebola.|url=http://wwwnc.cdc.gov/travel/notices/warning/ebola-liberia|website=CDC|accessdate=2 August 2014|date=July 31, 2014}}&lt;/ref&gt;&lt;ref name=CDCAug2014N&gt;{{Cite web|title=Outbreak of Ebola in Guinea, Liberia, and Sierra Leone|url=http://www.cdc.gov/vhf/ebola/outbreaks/guinea/index.html|website=CDC|accessdate=5 August 2014|date=August 4, 2014}}&lt;/ref&gt; Ukusukela ngoRhoboyi 2014 sele kubikwe bona kunabantu esele bangenwe bulwelwe lobu abayi-1600.&lt;ref&gt;{{Cite web|title=Ebola virus disease update - West Africa|url=http://www.who.int/csr/don/2014_08_04_ebola/en/|website=WHO|accessdate=6 August 2014|date=Aug 4, 2014}}&lt;/ref&gt; Imizamo yona iyenziwa bona kutholakalle [[intatha/isihlahla]] esingalapha ubulwelwe lobu, kodwana okwanje asikho kwatholakala ipengu yakhona.&lt;ref name=WHO2014/&gt;

== Isikhombiso selwazi==
{{Reflist|colwidth=25em}}

; IBhibhliyografu
{{Refbegin}}
* {{Cite book |last=Klenk |first=Hans-Dieter |title=Marburg and Ebola Viruses (Current Topics in Microbiology and Immunology) |date=January 1999 |publisher=Springer-Verlag Telos |location=Berlin |isbn=978-3-540-64729-4 |ref=CITEREFKlenk1999}}
* {{Cite book |first1=Hans-Dieter |last1=Klenk |first2=Heinz |last2=Feldmann |title=Ebola and Marburg viruses: molecular and cellular biology |url=http://books.google.com/?id=EV_mFgnyPoMC |format=Limited preview |year=2004 |publisher=Horizon Bioscience |location=Wymondham, Norfolk, UK |isbn=978-0-9545232-3-7 |ref=CITEREFKlenkFeldmann2004}}
* {{Cite book |last=Kuhn |first=Jens H. |title=Filoviruses: A Compendium of 40 Years of Epidemiological, Clinical, and Laboratory Studies. Archives of Virology Supplement, vol. 20 |url=http://books.google.com/?id=LaOue0F9Ns4C |format=Limited preview |year=2008 |publisher=SpringerWienNewYork |location=Vienna |isbn=978-3-211-20670-6 |ref=CITEREFKuhn2008}}
* {{Cite book |last1=McCormick |first1=Joseph |last2=Fisher-Hoch |first2=Susan |others=Horvitz, Leslie Alan |title=Level 4: Virus Hunters of the CDC |url=http://books.google.com/?id=QEvR3aJX2m0C |format=Limited preview |origyear=1996 |edition=Updated [3rd] |year=1999 |publisher=Barnes &amp; Noble |isbn=978-0-7607-1208-5 |ref=CITEREFMcCormickFisher-Hoch1999 |month=June}}
* {{Cite book |last=Pattyn |first=S. R. |title=Ebola Virus Haemorrhagic Fever |year=1978 |url=http://www.itg.be/ebola/ |format=Full free text |edition=1st |publisher=Elsevier/North-Holland Biomedical Press |location=Amsterdam |isbn=0-444-80060-3 |ref=CITEREFPattyn1978}}
* {{Cite book | last1 = Ryabchikova | first1 = Elena I. | last2 = Price | first2 = Barbara B. | title = Ebola and Marburg Viruses: A View of Infection Using Electron Microscopy | year = 2004 | publisher = Battelle Press | location = Columbus, Ohio | isbn = 978-1-57477-131-2 | ref = CITEREFRyabchikovaPrice2004 }}
{{Refend}}

==Okuhlanganiswe nalokhu okunye==
{{Refbegin}}
* [http://viralzone.expasy.org/all_by_species/207.html ViralZone: Ebola-like viruses] – Virological repository from the [[Swiss Institute of Bioinformatics]]
* [http://www.cdc.gov/vhf/ebola/ CDC: Ebola hemorrhagic fever] – Centers for Disease Control and Prevention, Special Pathogens Branch
* [http://www.who.int/csr/disease/ebola/en/ WHO: Ebola haemorrhagic fever] – World Health Organization, Global Alert and Response
* [http://www.viprbrc.org/brc/home.do?decorator=filo Virus Pathogen Database and Analysis Resource (ViPR): Filoviridae]
* [https://web.archive.org/web/20140808072117/http://www.ebi.ac.uk/pdbe/emdb/searchResults.html/?q=ebola 3D macromolecular structures of the Ebola virus archived in the EM Data Bank(EMDB)]
* [https://web.archive.org/web/20140819171607/https://maps.google.com/maps/ms?msa=0&amp;msid=202977755949863934429.0004c658eb30f9c4fb1c0&amp;ie=UTF8&amp;t=h&amp;ll=27.371767,5.273438&amp;spn=110.017392,184.21875&amp;z=2&amp;source=embed&amp;dg=feature Google Map of Ebola Outbreaks]
* [https://web.archive.org/web/20140816223245/http://www.who.int/csr/bioriskreduction/filovirus_infection_control/en/ WHO recommended infection control measures]
{{Refend}}</text>
      <sha1>ra7mwswqpla5et0ctfi5bqefsijckg4</sha1>
    </revision>
    <revision>
      <id>1333</id>
      <parentid>1332</parentid>
      <timestamp>2024-03-08T11:18:23Z</timestamp>
      <contributor>
        <username>incubator&gt;Thandeka179</username>
        <id>0</id>
      </contributor>
      <comment>Added content</comment>
      <origin>1333</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9619" sha1="aah5eme84te6dko08vde6fc4wgnxgmu" xml:space="preserve">{{Infobox disease
| name           = Ubulwelwe be-Ebola
| image          = 7042 lores-Ebola-Zaire-CDC Photo.jpg
| caption        = Isithombe sango-1976 sabahlengikazi ababili, bajame hlanu kwaka [[Mayinga N'Seka|Mayinga N.]], omumuntu osahlelwe mumulwana we-Ebola. Wahlongakala ngemva kwamalanga ambalwa ngonobangela wobulwelwe bokopha nokurhadza kweengazi.
| DiseasesDB     = 18043
| ICD10          = {{ICD10|A|98|4|a|90}}
| ICD9           = {{ICD9|065.8}}
| MedlinePlus    = 001339
| eMedicineSubj  = med
| eMedicineTopic = 626
| MeshID         = D019142
}}
'''Ubulwelwe be-Ebola''' nofana ('''EVD''') '''I-Ebola nomulwana wokopha iingazi okhambisana nomgomani''' ('''EHF''') mimulwana ebangwa bulwelwe bevayirasi ebizwa nge- [[Ebola]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo athoma ukubonakala phakathi kwamalanga amabili ukuya eemvekeni eentathu ngemva sewungenwe bulwelwe lobu, [[njengomgomani ongapheliko]], umphimbo obabako onesilonda, [[imisipha ebuhlungu kanye nehloko esawula kabuhlungu]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kesinye isikhathi [[ungahlanza]], uphakanyelwe ziimbindi nesifo  [[sokurhuda]], kuzokwenza bona [[amaphaphu]] kanye [[neso]] zingasasebenzi kuhle.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Nasele sekufike lapha, abanye baba nomraro [[wokopha iingazi]].&lt;ref name=WHO2014&gt;{{Cite web|title=Ebola virus disease Fact sheet N°103|url=http://www.who.int/mediacentre/factsheets/fs103/en/|work=World Health Organization|accessdate=12 April 2014|date=March 2014}}&lt;/ref&gt;

&lt;!-- Cause and Diagnosis--&gt;
Umulwana lo ungangena nawuthintana [[neengazi]] zomuntu ophethwe ngibo nofana [[umjuluko]] nanyana [[okunye nokunye okusamanzana]] okuvela (eenlwaneni [[kumaphelaphelana]] nofana iimfene).&lt;ref name=WHO2014/&gt; Bekube nje umulwana akukatholakali bona ungangena ngokuwurhogela emmoyeni.&lt;ref name=WHOAir2014&gt;{{Cite web|title=2014 Ebola Virus Disease (EVD) outbreak in West Africa|url=http://www.who.int/ith/updates/20140421/en/|website=WHO|accessdate=3 August 2014|date=Apr 21 2014}}&lt;/ref&gt; Kukholelwa bonyana abomaphelaphelani bakwazi  ukuphatha umulwana lo kodwana wona angaphathwa ngiwo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kwaba khona umuntu otheleleke ngomulwana lo, umulwana lo ungatheleleka kabanye abantu godu ngesikhathi esifitjhani.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amadoda angasinda ngemva kokulatjhwa angathelela abanye abantu ngokuthunda [[imbewu]] yabo lokha nabaya emsemeni nakungakapheli iinyanga ezimbili.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nakufanele uhlahlutjwe nofana uhlolelwe ubulwelwe lobu be-ebola kufanele izifo ezifana [[nomalalahlengezela]], [[isifo sokurhuda]] kanye omulwana [[wokopha iingazi okhambisana nomgomani]]  inganakwa ukwenzelela ukuthola imiphumela ekungiyo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ukuqinisekisa umrabho womraro wobulwelwe lobu amasampula weengazi ayathathwa ayokuhlolelwa ubulwelwe [[nesivikelasifo seengazini]] kanye ne [[i-RNA]] lobu kanye nengongwana ebanga ubulwelwe lobu.&lt;ref name=WHO2014/&gt;

&lt;!-- Prevention --&gt;
Ukuvikela ubulwelwe lobu kungaphungulwa ukuthelelana hlangana neemfene kanye neemfarigi ezingenwe bulwelwelwe lobu bukhandelwe bona bungayi ebantwini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kungenziwa ngokobana kuhlolwe iinlwana lezi ukobana zinabo ubulwelwe lobu na, nakutholakala bona zinabo kungenzeka bona zibulawe bese kugujelwa imizimba yazo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nawupheka inyama bese wembatha izambatho zokuzivikela nakho kungakusiza,&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; ukwembatha izambatho zokuzivikela lokha nawuhlala nofana uhlanu kwaloyo muntu ongenwe mumulwana lowo [[kanye nokuhlamba izandla ngesibha]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amasampula wananyana yini esamanzana yalabo bantu abangenwe mumulwana lo kufanele zitjhejwe khulu, ubalekele ukuthintana nazo.&lt;ref name=WHO2014/&gt;

&lt;!-- Treatment, Prognosis and Epidemiology--&gt;
Ayikho intatha elapha ubulwelwe lobu; imizamo yokobana kusizwe abantu abangenwe bulwelwe lobu kukobana [[kwenziwe umtswako]] (banikelwe amanzi anetswayi) ukobana bawasele nofana [[bafakwe amadribhu azobangenisela okusamanzana emzimbeni wabo]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu [[buneembalobalo eziphezulu zabantu abafako]]: nabangenwe ngibo ubulwelwe lobu, i-ebola ingabulala pheze isiquntu-50% nofana i-90% yabantu abatheleleke ngayo.&lt;ref name=WHO2014/&gt;&lt;ref name=&quot;Elsevier/Academic Press&quot;&gt;{{Cite book|author1=C.M. Fauquet|title=Virus taxonomy classification and nomenclature of viruses; 8th report of the International Committee on Taxonomy of Viruses|date=2005|publisher=Elsevier/Academic Press|location=Oxford|isbn=9780080575483|page=648|url=http://books.google.ca/books?id=9Wy7Jgy5RWYC&amp;pg=PA648}}&lt;/ref&gt; I-EVD yathoma ukwazakala endaweni enarheni ye [[Sudan]] kanye ne- [[Democratic Republic of Congo]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu butholakala khulu eenarheni zethrophigi zenarhakazi yeAfrika [[Iphakathi le-Sehara ye-Afrika]].&lt;ref name=WHO2014/&gt; Ngo-1976 (ukutholakala kwabo ubulwelwe lobu] ukufikela ngo-2013, besele ingene yatheleleka ebantwini abangaphasii kwe-1000.&lt;ref name=WHO2014/&gt;&lt;ref name=MMWRJune2014&gt;{{Cite web|title=Ebola Viral Disease Outbreak — West Africa, 2014|url=http://www.cdc.gov/mmwr/preview/mmwrhtml/mm6325a4.htm?s_cid=mm6325a4_w|website=CDC|accessdate=26 June 2014|date=June 27, 2014}}&lt;/ref&gt; Ukuqubuka kobulwelwe lobu obukhulu obungazange khebubonwe ngilobu bamuva nje ngebe [[2014  Tjhingalanga ye-Afrika Ukuqubuka kwe-Ebola]], sebele bungene eenarheni [[Guinea]], [[Sierra Leone]], [[Liberia]] begodu ingatheleka ingene ne [[Nigeria]].&lt;ref name=CDC2014&gt;{{Cite web|title=CDC urges all US residents to avoid nonessential travel to Liberia, Guinea, and Sierra Leone because of an unprecedented outbreak of Ebola.|url=http://wwwnc.cdc.gov/travel/notices/warning/ebola-liberia|website=CDC|accessdate=2 August 2014|date=July 31, 2014}}&lt;/ref&gt;&lt;ref name=CDCAug2014N&gt;{{Cite web|title=Outbreak of Ebola in Guinea, Liberia, and Sierra Leone|url=http://www.cdc.gov/vhf/ebola/outbreaks/guinea/index.html|website=CDC|accessdate=5 August 2014|date=August 4, 2014}}&lt;/ref&gt; Ukusukela ngoRhoboyi 2014 sele kubikwe bona kunabantu esele bangenwe bulwelwe lobu abayi-1600.&lt;ref&gt;{{Cite web|title=Ebola virus disease update - West Africa|url=http://www.who.int/csr/don/2014_08_04_ebola/en/|website=WHO|accessdate=6 August 2014|date=Aug 4, 2014}}&lt;/ref&gt; Imizamo yona iyenziwa bona kutholakalle [[intatha/isihlahla]] esingalapha ubulwelwe lobu, kodwana okwanje asikho kwatholakala ipengu yakhona.&lt;ref name=WHO2014/&gt;

== Isikhombiso selwazi==
{{Reflist|colwidth=25em}}

; IBhibhliyografu
{{Refbegin}}
* {{Cite book |last=Klenk |first=Hans-Dieter |title=Marburg and Ebola Viruses (Current Topics in Microbiology and Immunology) |date=January 1999 |publisher=Springer-Verlag Telos |location=Berlin |isbn=978-3-540-64729-4 |ref=CITEREFKlenk1999}}
* {{Cite book |first1=Hans-Dieter |last1=Klenk |first2=Heinz |last2=Feldmann |title=Ebola and Marburg viruses: molecular and cellular biology |url=http://books.google.com/?id=EV_mFgnyPoMC |format=Limited preview |year=2004 |publisher=Horizon Bioscience |location=Wymondham, Norfolk, UK |isbn=978-0-9545232-3-7 |ref=CITEREFKlenkFeldmann2004}}
* {{Cite book |last=Kuhn |first=Jens H. |title=Filoviruses: A Compendium of 40 Years of Epidemiological, Clinical, and Laboratory Studies. Archives of Virology Supplement, vol. 20 |url=http://books.google.com/?id=LaOue0F9Ns4C |format=Limited preview |year=2008 |publisher=SpringerWienNewYork |location=Vienna |isbn=978-3-211-20670-6 |ref=CITEREFKuhn2008}}
* {{Cite book |last1=McCormick |first1=Joseph |last2=Fisher-Hoch |first2=Susan |others=Horvitz, Leslie Alan |title=Level 4: Virus Hunters of the CDC |url=http://books.google.com/?id=QEvR3aJX2m0C |format=Limited preview |origyear=1996 |edition=Updated [3rd] |year=1999 |publisher=Barnes &amp; Noble |isbn=978-0-7607-1208-5 |ref=CITEREFMcCormickFisher-Hoch1999 |month=June}}
* {{Cite book |last=Pattyn |first=S. R. |title=Ebola Virus Haemorrhagic Fever |year=1978 |url=http://www.itg.be/ebola/ |format=Full free text |edition=1st |publisher=Elsevier/North-Holland Biomedical Press |location=Amsterdam |isbn=0-444-80060-3 |ref=CITEREFPattyn1978}}
* {{Cite book | last1 = Ryabchikova | first1 = Elena I. | last2 = Price | first2 = Barbara B. | title = Ebola and Marburg Viruses: A View of Infection Using Electron Microscopy | year = 2004 | publisher = Battelle Press | location = Columbus, Ohio | isbn = 978-1-57477-131-2 | ref = CITEREFRyabchikovaPrice2004 }}
{{Refend}}

==Okuhlanganiswe nalokhu okunye==
{{Refbegin}}
* [http://viralzone.expasy.org/all_by_species/207.html ViralZone: Ebola-like viruses] – Virological repository from the [[Swiss Institute of Bioinformatics]]
* [http://www.cdc.gov/vhf/ebola/ CDC: Ebola hemorrhagic fever] – Centers for Disease Control and Prevention, Special Pathogens Branch
* [http://www.who.int/csr/disease/ebola/en/ WHO: Ebola haemorrhagic fever] – World Health Organization, Global Alert and Response
* [http://www.viprbrc.org/brc/home.do?decorator=filo Virus Pathogen Database and Analysis Resource (ViPR): Filoviridae]
* [https://web.archive.org/web/20140808072117/http://www.ebi.ac.uk/pdbe/emdb/searchResults.html/?q=ebola 3D macromolecular structures of the Ebola virus archived in the EM Data Bank(EMDB)]
* [https://web.archive.org/web/20140819171607/https://maps.google.com/maps/ms?msa=0&amp;msid=202977755949863934429.0004c658eb30f9c4fb1c0&amp;ie=UTF8&amp;t=h&amp;ll=27.371767,5.273438&amp;spn=110.017392,184.21875&amp;z=2&amp;source=embed&amp;dg=feature Google Map of Ebola Outbreaks]
* [https://web.archive.org/web/20140816223245/http://www.who.int/csr/bioriskreduction/filovirus_infection_control/en/ WHO recommended infection control measures]
{{Refend}}</text>
      <sha1>aah5eme84te6dko08vde6fc4wgnxgmu</sha1>
    </revision>
    <revision>
      <id>1334</id>
      <parentid>1333</parentid>
      <timestamp>2024-03-09T07:33:00Z</timestamp>
      <contributor>
        <username>incubator&gt;KhethiweMsiza94</username>
        <id>0</id>
      </contributor>
      <comment>LINKED EBOLA</comment>
      <origin>1334</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9636" sha1="c4ueb3w95siqh23xo499zssab1lseg9" xml:space="preserve">{{Infobox disease
| name           = Ubulwelwe be-Ebola
| image          = 7042 lores-Ebola-Zaire-CDC Photo.jpg
| caption        = Isithombe sango-1976 sabahlengikazi ababili, bajame hlanu kwaka [[Mayinga N'Seka|Mayinga N.]], omumuntu osahlelwe mumulwana we-Ebola. Wahlongakala ngemva kwamalanga ambalwa ngonobangela wobulwelwe bokopha nokurhadza kweengazi.
| DiseasesDB     = 18043
| ICD10          = {{ICD10|A|98|4|a|90}}
| ICD9           = {{ICD9|065.8}}
| MedlinePlus    = 001339
| eMedicineSubj  = med
| eMedicineTopic = 626
| MeshID         = D019142
}}
'''Ubulwelwe be-Ebola''' nofana ('''EVD''') '''[[Wp/kri/Ebola|I-Ebola]] nomulwana wokopha iingazi okhambisana nomgomani''' ('''EHF''') mimulwana ebangwa bulwelwe bevayirasi ebizwa nge- [[Ebola]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo athoma ukubonakala phakathi kwamalanga amabili ukuya eemvekeni eentathu ngemva sewungenwe bulwelwe lobu, [[njengomgomani ongapheliko]], umphimbo obabako onesilonda, [[imisipha ebuhlungu kanye nehloko esawula kabuhlungu]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kesinye isikhathi [[ungahlanza]], uphakanyelwe ziimbindi nesifo  [[sokurhuda]], kuzokwenza bona [[amaphaphu]] kanye [[neso]] zingasasebenzi kuhle.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Nasele sekufike lapha, abanye baba nomraro [[wokopha iingazi]].&lt;ref name=WHO2014&gt;{{Cite web|title=Ebola virus disease Fact sheet N°103|url=http://www.who.int/mediacentre/factsheets/fs103/en/|work=World Health Organization|accessdate=12 April 2014|date=March 2014}}&lt;/ref&gt;

&lt;!-- Cause and Diagnosis--&gt;
Umulwana lo ungangena nawuthintana [[neengazi]] zomuntu ophethwe ngibo nofana [[umjuluko]] nanyana [[okunye nokunye okusamanzana]] okuvela (eenlwaneni [[kumaphelaphelana]] nofana iimfene).&lt;ref name=WHO2014/&gt; Bekube nje umulwana akukatholakali bona ungangena ngokuwurhogela emmoyeni.&lt;ref name=WHOAir2014&gt;{{Cite web|title=2014 Ebola Virus Disease (EVD) outbreak in West Africa|url=http://www.who.int/ith/updates/20140421/en/|website=WHO|accessdate=3 August 2014|date=Apr 21 2014}}&lt;/ref&gt; Kukholelwa bonyana abomaphelaphelani bakwazi  ukuphatha umulwana lo kodwana wona angaphathwa ngiwo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kwaba khona umuntu otheleleke ngomulwana lo, umulwana lo ungatheleleka kabanye abantu godu ngesikhathi esifitjhani.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amadoda angasinda ngemva kokulatjhwa angathelela abanye abantu ngokuthunda [[imbewu]] yabo lokha nabaya emsemeni nakungakapheli iinyanga ezimbili.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nakufanele uhlahlutjwe nofana uhlolelwe ubulwelwe lobu be-ebola kufanele izifo ezifana [[nomalalahlengezela]], [[isifo sokurhuda]] kanye omulwana [[wokopha iingazi okhambisana nomgomani]]  inganakwa ukwenzelela ukuthola imiphumela ekungiyo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ukuqinisekisa umrabho womraro wobulwelwe lobu amasampula weengazi ayathathwa ayokuhlolelwa ubulwelwe [[nesivikelasifo seengazini]] kanye ne [[i-RNA]] lobu kanye nengongwana ebanga ubulwelwe lobu.&lt;ref name=WHO2014/&gt;

&lt;!-- Prevention --&gt;
Ukuvikela ubulwelwe lobu kungaphungulwa ukuthelelana hlangana neemfene kanye neemfarigi ezingenwe bulwelwelwe lobu bukhandelwe bona bungayi ebantwini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kungenziwa ngokobana kuhlolwe iinlwana lezi ukobana zinabo ubulwelwe lobu na, nakutholakala bona zinabo kungenzeka bona zibulawe bese kugujelwa imizimba yazo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nawupheka inyama bese wembatha izambatho zokuzivikela nakho kungakusiza,&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; ukwembatha izambatho zokuzivikela lokha nawuhlala nofana uhlanu kwaloyo muntu ongenwe mumulwana lowo [[kanye nokuhlamba izandla ngesibha]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amasampula wananyana yini esamanzana yalabo bantu abangenwe mumulwana lo kufanele zitjhejwe khulu, ubalekele ukuthintana nazo.&lt;ref name=WHO2014/&gt;

&lt;!-- Treatment, Prognosis and Epidemiology--&gt;
Ayikho intatha elapha ubulwelwe lobu; imizamo yokobana kusizwe abantu abangenwe bulwelwe lobu kukobana [[kwenziwe umtswako]] (banikelwe amanzi anetswayi) ukobana bawasele nofana [[bafakwe amadribhu azobangenisela okusamanzana emzimbeni wabo]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu [[buneembalobalo eziphezulu zabantu abafako]]: nabangenwe ngibo ubulwelwe lobu, i-ebola ingabulala pheze isiquntu-50% nofana i-90% yabantu abatheleleke ngayo.&lt;ref name=WHO2014/&gt;&lt;ref name=&quot;Elsevier/Academic Press&quot;&gt;{{Cite book|author1=C.M. Fauquet|title=Virus taxonomy classification and nomenclature of viruses; 8th report of the International Committee on Taxonomy of Viruses|date=2005|publisher=Elsevier/Academic Press|location=Oxford|isbn=9780080575483|page=648|url=http://books.google.ca/books?id=9Wy7Jgy5RWYC&amp;pg=PA648}}&lt;/ref&gt; I-EVD yathoma ukwazakala endaweni enarheni ye [[Sudan]] kanye ne- [[Democratic Republic of Congo]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu butholakala khulu eenarheni zethrophigi zenarhakazi yeAfrika [[Iphakathi le-Sehara ye-Afrika]].&lt;ref name=WHO2014/&gt; Ngo-1976 (ukutholakala kwabo ubulwelwe lobu] ukufikela ngo-2013, besele ingene yatheleleka ebantwini abangaphasii kwe-1000.&lt;ref name=WHO2014/&gt;&lt;ref name=MMWRJune2014&gt;{{Cite web|title=Ebola Viral Disease Outbreak — West Africa, 2014|url=http://www.cdc.gov/mmwr/preview/mmwrhtml/mm6325a4.htm?s_cid=mm6325a4_w|website=CDC|accessdate=26 June 2014|date=June 27, 2014}}&lt;/ref&gt; Ukuqubuka kobulwelwe lobu obukhulu obungazange khebubonwe ngilobu bamuva nje ngebe [[2014  Tjhingalanga ye-Afrika Ukuqubuka kwe-Ebola]], sebele bungene eenarheni [[Guinea]], [[Sierra Leone]], [[Liberia]] begodu ingatheleka ingene ne [[Nigeria]].&lt;ref name=CDC2014&gt;{{Cite web|title=CDC urges all US residents to avoid nonessential travel to Liberia, Guinea, and Sierra Leone because of an unprecedented outbreak of Ebola.|url=http://wwwnc.cdc.gov/travel/notices/warning/ebola-liberia|website=CDC|accessdate=2 August 2014|date=July 31, 2014}}&lt;/ref&gt;&lt;ref name=CDCAug2014N&gt;{{Cite web|title=Outbreak of Ebola in Guinea, Liberia, and Sierra Leone|url=http://www.cdc.gov/vhf/ebola/outbreaks/guinea/index.html|website=CDC|accessdate=5 August 2014|date=August 4, 2014}}&lt;/ref&gt; Ukusukela ngoRhoboyi 2014 sele kubikwe bona kunabantu esele bangenwe bulwelwe lobu abayi-1600.&lt;ref&gt;{{Cite web|title=Ebola virus disease update - West Africa|url=http://www.who.int/csr/don/2014_08_04_ebola/en/|website=WHO|accessdate=6 August 2014|date=Aug 4, 2014}}&lt;/ref&gt; Imizamo yona iyenziwa bona kutholakalle [[intatha/isihlahla]] esingalapha ubulwelwe lobu, kodwana okwanje asikho kwatholakala ipengu yakhona.&lt;ref name=WHO2014/&gt;

== Isikhombiso selwazi==
{{Reflist|colwidth=25em}}

; IBhibhliyografu
{{Refbegin}}
* {{Cite book |last=Klenk |first=Hans-Dieter |title=Marburg and Ebola Viruses (Current Topics in Microbiology and Immunology) |date=January 1999 |publisher=Springer-Verlag Telos |location=Berlin |isbn=978-3-540-64729-4 |ref=CITEREFKlenk1999}}
* {{Cite book |first1=Hans-Dieter |last1=Klenk |first2=Heinz |last2=Feldmann |title=Ebola and Marburg viruses: molecular and cellular biology |url=http://books.google.com/?id=EV_mFgnyPoMC |format=Limited preview |year=2004 |publisher=Horizon Bioscience |location=Wymondham, Norfolk, UK |isbn=978-0-9545232-3-7 |ref=CITEREFKlenkFeldmann2004}}
* {{Cite book |last=Kuhn |first=Jens H. |title=Filoviruses: A Compendium of 40 Years of Epidemiological, Clinical, and Laboratory Studies. Archives of Virology Supplement, vol. 20 |url=http://books.google.com/?id=LaOue0F9Ns4C |format=Limited preview |year=2008 |publisher=SpringerWienNewYork |location=Vienna |isbn=978-3-211-20670-6 |ref=CITEREFKuhn2008}}
* {{Cite book |last1=McCormick |first1=Joseph |last2=Fisher-Hoch |first2=Susan |others=Horvitz, Leslie Alan |title=Level 4: Virus Hunters of the CDC |url=http://books.google.com/?id=QEvR3aJX2m0C |format=Limited preview |origyear=1996 |edition=Updated [3rd] |year=1999 |publisher=Barnes &amp; Noble |isbn=978-0-7607-1208-5 |ref=CITEREFMcCormickFisher-Hoch1999 |month=June}}
* {{Cite book |last=Pattyn |first=S. R. |title=Ebola Virus Haemorrhagic Fever |year=1978 |url=http://www.itg.be/ebola/ |format=Full free text |edition=1st |publisher=Elsevier/North-Holland Biomedical Press |location=Amsterdam |isbn=0-444-80060-3 |ref=CITEREFPattyn1978}}
* {{Cite book | last1 = Ryabchikova | first1 = Elena I. | last2 = Price | first2 = Barbara B. | title = Ebola and Marburg Viruses: A View of Infection Using Electron Microscopy | year = 2004 | publisher = Battelle Press | location = Columbus, Ohio | isbn = 978-1-57477-131-2 | ref = CITEREFRyabchikovaPrice2004 }}
{{Refend}}

==Okuhlanganiswe nalokhu okunye==
{{Refbegin}}
* [http://viralzone.expasy.org/all_by_species/207.html ViralZone: Ebola-like viruses] – Virological repository from the [[Swiss Institute of Bioinformatics]]
* [http://www.cdc.gov/vhf/ebola/ CDC: Ebola hemorrhagic fever] – Centers for Disease Control and Prevention, Special Pathogens Branch
* [http://www.who.int/csr/disease/ebola/en/ WHO: Ebola haemorrhagic fever] – World Health Organization, Global Alert and Response
* [http://www.viprbrc.org/brc/home.do?decorator=filo Virus Pathogen Database and Analysis Resource (ViPR): Filoviridae]
* [https://web.archive.org/web/20140808072117/http://www.ebi.ac.uk/pdbe/emdb/searchResults.html/?q=ebola 3D macromolecular structures of the Ebola virus archived in the EM Data Bank(EMDB)]
* [https://web.archive.org/web/20140819171607/https://maps.google.com/maps/ms?msa=0&amp;msid=202977755949863934429.0004c658eb30f9c4fb1c0&amp;ie=UTF8&amp;t=h&amp;ll=27.371767,5.273438&amp;spn=110.017392,184.21875&amp;z=2&amp;source=embed&amp;dg=feature Google Map of Ebola Outbreaks]
* [https://web.archive.org/web/20140816223245/http://www.who.int/csr/bioriskreduction/filovirus_infection_control/en/ WHO recommended infection control measures]
{{Refend}}</text>
      <sha1>c4ueb3w95siqh23xo499zssab1lseg9</sha1>
    </revision>
    <revision>
      <id>1335</id>
      <parentid>1334</parentid>
      <timestamp>2024-09-25T06:32:06Z</timestamp>
      <contributor>
        <ip>2001:44C8:4441:F33E:A979:652A:1A23:F423</ip>
      </contributor>
      <comment>เทคนิคแก้หนี้ สร้างรายได้</comment>
      <origin>1335</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="10605" sha1="es1supb9or4b3ctxqw5knhsmu92gsym" xml:space="preserve">{{Infobox disease
| name           = Ubulwelwe be-Ebola
| image          = 7042 lores-Ebola-Zaire-CDC Photo.jpg
| caption        = Isithombe sango-1976 sabahlengikazi ababili, bajame hlanu kwaka [[Mayinga N'Seka|Mayinga N.]], omumuntu osahlelwe mumulwana we-Ebola. Wahlongakala ngemva kwamalanga ambalwa ngonobangela wobulwelwe bokopha nokurhadza kweengazi.
| DiseasesDB     = 18043
| ICD10          = {{ICD10|A|98|4|a|90}}
| ICD9           = {{ICD9|065.8}}
| MedlinePlus    = 001339
| eMedicineSubj  = med
| eMedicineTopic = 626
| MeshID         = D019142
}}
'''[https://www.blockdit.com/posts/66f2343e3c5d0522753201e5 Ubulwelwe be-Ebola]''' nofana ('''EVD''') '''[https://www.blockdit.com/posts/66f2343e3c5d0522753201e5 I-Ebola] [https://www.blockdit.com/posts/66f2343e3c5d0522753201e5 nomulwana wokopha iingazi] [https://www.blockdit.com/posts/66f127f998f4c410487f6e58 okhambisana nomgomani]''' ('''EHF''') mimulwana ebangwa bulwelwe bevayirasi ebizwa nge- [[Ebola]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; [https://www.blockdit.com/posts/66f127f998f4c410487f6e58 Amatshwayo] athoma ukubonakala phakathi kwamalanga amabili ukuya eemvekeni eentathu ngemva sewungenwe bulwelwe lobu, [[njengomgomani ongapheliko]], umphimbo obabako onesilonda, [[imisipha ebuhlungu kanye nehloko esawula kabuhlungu]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kesinye isikhathi [[ungahlanza]], uphakanyelwe ziimbindi nesifo  [[sokurhuda]], kuzokwenza bona [[amaphaphu]] kanye [[neso]] zingasasebenzi kuhle.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Nasele sekufike lapha, abanye baba nomraro [[wokopha iingazi]].&lt;ref name=WHO2014&gt;{{Cite web|title=Ebola virus disease Fact sheet N°103|url=http://www.who.int/mediacentre/factsheets/fs103/en/|work=World Health Organization|accessdate=12 April 2014|date=March 2014}}&lt;/ref&gt;

&lt;!-- Cause and Diagnosis--&gt;
[https://www.blockdit.com/posts/66f127f998f4c410487f6e58 Umulwana] lo ungangena nawuthintana [[neengazi]] zomuntu ophethwe ngibo nofana [[umjuluko]] nanyana [[okunye nokunye okusamanzana]] okuvela (eenlwaneni [[kumaphelaphelana]] nofana iimfene).&lt;ref name=WHO2014/&gt; Bekube nje umulwana [https://www.blockdit.com/posts/66f127f998f4c410487f6e58 akukatholakali] bona ungangena ngokuwurhogela emmoyeni.&lt;ref name=WHOAir2014&gt;{{Cite web|title=2014 Ebola Virus Disease (EVD) outbreak in West Africa|url=http://www.who.int/ith/updates/20140421/en/|website=WHO|accessdate=3 August 2014|date=Apr 21 2014}}&lt;/ref&gt; Kukholelwa bonyana abomaphelaphelani bakwazi  ukuphatha umulwana lo kodwana wona angaphathwa ngiwo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kwaba khona umuntu otheleleke ngomulwana lo, umulwana lo ungatheleleka kabanye abantu godu [https://www.blockdit.com/posts/66f127f998f4c410487f6e58 ngesikhathi] esifitjhani.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amadoda angasinda ngemva kokulatjhwa angathelela abanye abantu ngokuthunda [[imbewu]] yabo lokha nabaya emsemeni nakungakapheli iinyanga ezimbili.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nakufanele uhlahlutjwe nofana uhlolelwe ubulwelwe lobu be-ebola kufanele izifo ezifana [[nomalalahlengezela]], [[isifo sokurhuda]] kanye omulwana [[wokopha iingazi okhambisana nomgomani]]  inganakwa ukwenzelela ukuthola [https://www.blockdit.com/posts/66f127f998f4c410487f6e58 imiphumela] ekungiyo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ukuqinisekisa umrabho womraro [https://www.blockdit.com/posts/66f127f998f4c410487f6e58 wobulwelwe] lobu amasampula weengazi ayathathwa [https://www.blockdit.com/posts/66f127f998f4c410487f6e58 ayokuhlolelwa] ubulwelwe [[nesivikelasifo seengazini]] kanye ne [[i-RNA]] lobu kanye nengongwana ebanga ubulwelwe lobu.&lt;ref name=WHO2014/&gt;

&lt;!-- Prevention --&gt;
Ukuvikela ubulwelwe lobu [https://www.blockdit.com/posts/66ececa5ff1a13570eb3a2ac kungaphungulwa] ukuthelelana hlangana neemfene kanye neemfarigi ezingenwe bulwelwelwe lobu bukhandelwe bona bungayi ebantwini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kungenziwa ngokobana kuhlolwe iinlwana lezi ukobana zinabo ubulwelwe lobu na, [https://www.blockdit.com/posts/66ececa5ff1a13570eb3a2ac nakutholakala] bona zinabo kungenzeka bona zibulawe bese kugujelwa imizimba yazo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nawupheka inyama bese wembatha izambatho zokuzivikela nakho kungakusiza,&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; ukwembatha izambatho [https://www.blockdit.com/posts/66ececa5ff1a13570eb3a2ac zokuzivikela] lokha nawuhlala nofana uhlanu kwaloyo muntu ongenwe mumulwana lowo [[kanye nokuhlamba izandla ngesibha]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amasampula wananyana yini esamanzana yalabo bantu abangenwe mumulwana lo kufanele zitjhejwe khulu, ubalekele ukuthintana nazo.&lt;ref name=WHO2014/&gt;

&lt;!-- Treatment, Prognosis and Epidemiology--&gt;
[https://www.blockdit.com/posts/66ececa5ff1a13570eb3a2ac Ayikho] intatha elapha ubulwelwe lobu; imizamo [https://www.blockdit.com/posts/66ececa5ff1a13570eb3a2ac yokobana] kusizwe abantu abangenwe [https://www.blockdit.com/posts/66ececa5ff1a13570eb3a2ac bulwelwe] lobu kukobana [[kwenziwe umtswako]] (banikelwe amanzi anetswayi) ukobana bawasele nofana [[bafakwe amadribhu azobangenisela okusamanzana emzimbeni wabo]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu [[buneembalobalo eziphezulu zabantu abafako]]: nabangenwe ngibo ubulwelwe lobu, i-ebola ingabulala pheze isiquntu-50% nofana i-90% yabantu abatheleleke ngayo.&lt;ref name=WHO2014/&gt;&lt;ref name=&quot;Elsevier/Academic Press&quot;&gt;{{Cite book|author1=C.M. Fauquet|title=Virus taxonomy classification and nomenclature of viruses; 8th report of the International Committee on Taxonomy of Viruses|date=2005|publisher=Elsevier/Academic Press|location=Oxford|isbn=9780080575483|page=648|url=http://books.google.ca/books?id=9Wy7Jgy5RWYC&amp;pg=PA648}}&lt;/ref&gt; I-EVD yathoma ukwazakala endaweni enarheni ye [[Sudan]] kanye ne- [[Democratic Republic of Congo]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu butholakala khulu eenarheni zethrophigi zenarhakazi yeAfrika [[Iphakathi le-Sehara ye-Afrika]].&lt;ref name=WHO2014/&gt; Ngo-1976 (ukutholakala kwabo ubulwelwe lobu] ukufikela ngo-2013, besele ingene yatheleleka ebantwini abangaphasii kwe-1000.&lt;ref name=WHO2014/&gt;&lt;ref name=MMWRJune2014&gt;{{Cite web|title=Ebola Viral Disease Outbreak — West Africa, 2014|url=http://www.cdc.gov/mmwr/preview/mmwrhtml/mm6325a4.htm?s_cid=mm6325a4_w|website=CDC|accessdate=26 June 2014|date=June 27, 2014}}&lt;/ref&gt; Ukuqubuka kobulwelwe lobu obukhulu obungazange khebubonwe ngilobu bamuva nje ngebe [[2014  Tjhingalanga ye-Afrika Ukuqubuka kwe-Ebola]], sebele bungene eenarheni [[Guinea]], [[Sierra Leone]], [[Liberia]] begodu ingatheleka ingene ne [[Nigeria]].&lt;ref name=CDC2014&gt;{{Cite web|title=CDC urges all US residents to avoid nonessential travel to Liberia, Guinea, and Sierra Leone because of an unprecedented outbreak of Ebola.|url=http://wwwnc.cdc.gov/travel/notices/warning/ebola-liberia|website=CDC|accessdate=2 August 2014|date=July 31, 2014}}&lt;/ref&gt;&lt;ref name=CDCAug2014N&gt;{{Cite web|title=Outbreak of Ebola in Guinea, Liberia, and Sierra Leone|url=http://www.cdc.gov/vhf/ebola/outbreaks/guinea/index.html|website=CDC|accessdate=5 August 2014|date=August 4, 2014}}&lt;/ref&gt; Ukusukela ngoRhoboyi 2014 sele kubikwe bona kunabantu esele bangenwe bulwelwe lobu abayi-1600.&lt;ref&gt;{{Cite web|title=Ebola virus disease update - West Africa|url=http://www.who.int/csr/don/2014_08_04_ebola/en/|website=WHO|accessdate=6 August 2014|date=Aug 4, 2014}}&lt;/ref&gt; Imizamo yona iyenziwa bona kutholakalle [[intatha/isihlahla]] esingalapha ubulwelwe lobu, kodwana okwanje asikho kwatholakala ipengu yakhona.&lt;ref name=WHO2014/&gt;

== Isikhombiso selwazi==
{{Reflist|colwidth=25em}}

; IBhibhliyografu
{{Refbegin}}
* {{Cite book |last=Klenk |first=Hans-Dieter |title=Marburg and Ebola Viruses (Current Topics in Microbiology and Immunology) |date=January 1999 |publisher=Springer-Verlag Telos |location=Berlin |isbn=978-3-540-64729-4 |ref=CITEREFKlenk1999}}
* {{Cite book |first1=Hans-Dieter |last1=Klenk |first2=Heinz |last2=Feldmann |title=Ebola and Marburg viruses: molecular and cellular biology |url=http://books.google.com/?id=EV_mFgnyPoMC |format=Limited preview |year=2004 |publisher=Horizon Bioscience |location=Wymondham, Norfolk, UK |isbn=978-0-9545232-3-7 |ref=CITEREFKlenkFeldmann2004}}
* {{Cite book |last=Kuhn |first=Jens H. |title=Filoviruses: A Compendium of 40 Years of Epidemiological, Clinical, and Laboratory Studies. Archives of Virology Supplement, vol. 20 |url=http://books.google.com/?id=LaOue0F9Ns4C |format=Limited preview |year=2008 |publisher=SpringerWienNewYork |location=Vienna |isbn=978-3-211-20670-6 |ref=CITEREFKuhn2008}}
* {{Cite book |last1=McCormick |first1=Joseph |last2=Fisher-Hoch |first2=Susan |others=Horvitz, Leslie Alan |title=Level 4: Virus Hunters of the CDC |url=http://books.google.com/?id=QEvR3aJX2m0C |format=Limited preview |origyear=1996 |edition=Updated [3rd] |year=1999 |publisher=Barnes &amp; Noble |isbn=978-0-7607-1208-5 |ref=CITEREFMcCormickFisher-Hoch1999 |month=June}}
* {{Cite book |last=Pattyn |first=S. R. |title=Ebola Virus Haemorrhagic Fever |year=1978 |url=http://www.itg.be/ebola/ |format=Full free text |edition=1st |publisher=Elsevier/North-Holland Biomedical Press |location=Amsterdam |isbn=0-444-80060-3 |ref=CITEREFPattyn1978}}
* {{Cite book | last1 = Ryabchikova | first1 = Elena I. | last2 = Price | first2 = Barbara B. | title = Ebola and Marburg Viruses: A View of Infection Using Electron Microscopy | year = 2004 | publisher = Battelle Press | location = Columbus, Ohio | isbn = 978-1-57477-131-2 | ref = CITEREFRyabchikovaPrice2004 }}
{{Refend}}

==Okuhlanganiswe nalokhu okunye==
{{Refbegin}}
* [http://viralzone.expasy.org/all_by_species/207.html ViralZone: Ebola-like viruses] – Virological repository from the [[Swiss Institute of Bioinformatics]]
* [http://www.cdc.gov/vhf/ebola/ CDC: Ebola hemorrhagic fever] – Centers for Disease Control and Prevention, Special Pathogens Branch
* [http://www.who.int/csr/disease/ebola/en/ WHO: Ebola haemorrhagic fever] – World Health Organization, Global Alert and Response
* [http://www.viprbrc.org/brc/home.do?decorator=filo Virus Pathogen Database and Analysis Resource (ViPR): Filoviridae]
* [https://web.archive.org/web/20140808072117/http://www.ebi.ac.uk/pdbe/emdb/searchResults.html/?q=ebola 3D macromolecular structures of the Ebola virus archived in the EM Data Bank(EMDB)]
* [https://web.archive.org/web/20140819171607/https://maps.google.com/maps/ms?msa=0&amp;msid=202977755949863934429.0004c658eb30f9c4fb1c0&amp;ie=UTF8&amp;t=h&amp;ll=27.371767,5.273438&amp;spn=110.017392,184.21875&amp;z=2&amp;source=embed&amp;dg=feature Google Map of Ebola Outbreaks]
* [https://web.archive.org/web/20140816223245/http://www.who.int/csr/bioriskreduction/filovirus_infection_control/en/ WHO recommended infection control measures]
{{Refend}}</text>
      <sha1>es1supb9or4b3ctxqw5knhsmu92gsym</sha1>
    </revision>
    <revision>
      <id>1336</id>
      <parentid>1335</parentid>
      <timestamp>2024-09-25T06:32:20Z</timestamp>
      <contributor>
        <username>incubator&gt;Tanbiruzzaman</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Khethekileko:Contributions/2001:44C8:4441:F33E:A979:652A:1A23:F423|2001:44C8:4441:F33E:A979:652A:1A23:F423]] ([[Umsebenzisi asiqongelane:2001:44C8:4441:F33E:A979:652A:1A23:F423|talk]]) to last revision by [[Umsebenzisi:KhethiweMsiza94|KhethiweMsiza94]]</comment>
      <origin>1336</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9636" sha1="c4ueb3w95siqh23xo499zssab1lseg9" xml:space="preserve">{{Infobox disease
| name           = Ubulwelwe be-Ebola
| image          = 7042 lores-Ebola-Zaire-CDC Photo.jpg
| caption        = Isithombe sango-1976 sabahlengikazi ababili, bajame hlanu kwaka [[Mayinga N'Seka|Mayinga N.]], omumuntu osahlelwe mumulwana we-Ebola. Wahlongakala ngemva kwamalanga ambalwa ngonobangela wobulwelwe bokopha nokurhadza kweengazi.
| DiseasesDB     = 18043
| ICD10          = {{ICD10|A|98|4|a|90}}
| ICD9           = {{ICD9|065.8}}
| MedlinePlus    = 001339
| eMedicineSubj  = med
| eMedicineTopic = 626
| MeshID         = D019142
}}
'''Ubulwelwe be-Ebola''' nofana ('''EVD''') '''[[Wp/kri/Ebola|I-Ebola]] nomulwana wokopha iingazi okhambisana nomgomani''' ('''EHF''') mimulwana ebangwa bulwelwe bevayirasi ebizwa nge- [[Ebola]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo athoma ukubonakala phakathi kwamalanga amabili ukuya eemvekeni eentathu ngemva sewungenwe bulwelwe lobu, [[njengomgomani ongapheliko]], umphimbo obabako onesilonda, [[imisipha ebuhlungu kanye nehloko esawula kabuhlungu]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kesinye isikhathi [[ungahlanza]], uphakanyelwe ziimbindi nesifo  [[sokurhuda]], kuzokwenza bona [[amaphaphu]] kanye [[neso]] zingasasebenzi kuhle.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Nasele sekufike lapha, abanye baba nomraro [[wokopha iingazi]].&lt;ref name=WHO2014&gt;{{Cite web|title=Ebola virus disease Fact sheet N°103|url=http://www.who.int/mediacentre/factsheets/fs103/en/|work=World Health Organization|accessdate=12 April 2014|date=March 2014}}&lt;/ref&gt;

&lt;!-- Cause and Diagnosis--&gt;
Umulwana lo ungangena nawuthintana [[neengazi]] zomuntu ophethwe ngibo nofana [[umjuluko]] nanyana [[okunye nokunye okusamanzana]] okuvela (eenlwaneni [[kumaphelaphelana]] nofana iimfene).&lt;ref name=WHO2014/&gt; Bekube nje umulwana akukatholakali bona ungangena ngokuwurhogela emmoyeni.&lt;ref name=WHOAir2014&gt;{{Cite web|title=2014 Ebola Virus Disease (EVD) outbreak in West Africa|url=http://www.who.int/ith/updates/20140421/en/|website=WHO|accessdate=3 August 2014|date=Apr 21 2014}}&lt;/ref&gt; Kukholelwa bonyana abomaphelaphelani bakwazi  ukuphatha umulwana lo kodwana wona angaphathwa ngiwo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kwaba khona umuntu otheleleke ngomulwana lo, umulwana lo ungatheleleka kabanye abantu godu ngesikhathi esifitjhani.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amadoda angasinda ngemva kokulatjhwa angathelela abanye abantu ngokuthunda [[imbewu]] yabo lokha nabaya emsemeni nakungakapheli iinyanga ezimbili.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nakufanele uhlahlutjwe nofana uhlolelwe ubulwelwe lobu be-ebola kufanele izifo ezifana [[nomalalahlengezela]], [[isifo sokurhuda]] kanye omulwana [[wokopha iingazi okhambisana nomgomani]]  inganakwa ukwenzelela ukuthola imiphumela ekungiyo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ukuqinisekisa umrabho womraro wobulwelwe lobu amasampula weengazi ayathathwa ayokuhlolelwa ubulwelwe [[nesivikelasifo seengazini]] kanye ne [[i-RNA]] lobu kanye nengongwana ebanga ubulwelwe lobu.&lt;ref name=WHO2014/&gt;

&lt;!-- Prevention --&gt;
Ukuvikela ubulwelwe lobu kungaphungulwa ukuthelelana hlangana neemfene kanye neemfarigi ezingenwe bulwelwelwe lobu bukhandelwe bona bungayi ebantwini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kungenziwa ngokobana kuhlolwe iinlwana lezi ukobana zinabo ubulwelwe lobu na, nakutholakala bona zinabo kungenzeka bona zibulawe bese kugujelwa imizimba yazo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nawupheka inyama bese wembatha izambatho zokuzivikela nakho kungakusiza,&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; ukwembatha izambatho zokuzivikela lokha nawuhlala nofana uhlanu kwaloyo muntu ongenwe mumulwana lowo [[kanye nokuhlamba izandla ngesibha]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amasampula wananyana yini esamanzana yalabo bantu abangenwe mumulwana lo kufanele zitjhejwe khulu, ubalekele ukuthintana nazo.&lt;ref name=WHO2014/&gt;

&lt;!-- Treatment, Prognosis and Epidemiology--&gt;
Ayikho intatha elapha ubulwelwe lobu; imizamo yokobana kusizwe abantu abangenwe bulwelwe lobu kukobana [[kwenziwe umtswako]] (banikelwe amanzi anetswayi) ukobana bawasele nofana [[bafakwe amadribhu azobangenisela okusamanzana emzimbeni wabo]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu [[buneembalobalo eziphezulu zabantu abafako]]: nabangenwe ngibo ubulwelwe lobu, i-ebola ingabulala pheze isiquntu-50% nofana i-90% yabantu abatheleleke ngayo.&lt;ref name=WHO2014/&gt;&lt;ref name=&quot;Elsevier/Academic Press&quot;&gt;{{Cite book|author1=C.M. Fauquet|title=Virus taxonomy classification and nomenclature of viruses; 8th report of the International Committee on Taxonomy of Viruses|date=2005|publisher=Elsevier/Academic Press|location=Oxford|isbn=9780080575483|page=648|url=http://books.google.ca/books?id=9Wy7Jgy5RWYC&amp;pg=PA648}}&lt;/ref&gt; I-EVD yathoma ukwazakala endaweni enarheni ye [[Sudan]] kanye ne- [[Democratic Republic of Congo]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu butholakala khulu eenarheni zethrophigi zenarhakazi yeAfrika [[Iphakathi le-Sehara ye-Afrika]].&lt;ref name=WHO2014/&gt; Ngo-1976 (ukutholakala kwabo ubulwelwe lobu] ukufikela ngo-2013, besele ingene yatheleleka ebantwini abangaphasii kwe-1000.&lt;ref name=WHO2014/&gt;&lt;ref name=MMWRJune2014&gt;{{Cite web|title=Ebola Viral Disease Outbreak — West Africa, 2014|url=http://www.cdc.gov/mmwr/preview/mmwrhtml/mm6325a4.htm?s_cid=mm6325a4_w|website=CDC|accessdate=26 June 2014|date=June 27, 2014}}&lt;/ref&gt; Ukuqubuka kobulwelwe lobu obukhulu obungazange khebubonwe ngilobu bamuva nje ngebe [[2014  Tjhingalanga ye-Afrika Ukuqubuka kwe-Ebola]], sebele bungene eenarheni [[Guinea]], [[Sierra Leone]], [[Liberia]] begodu ingatheleka ingene ne [[Nigeria]].&lt;ref name=CDC2014&gt;{{Cite web|title=CDC urges all US residents to avoid nonessential travel to Liberia, Guinea, and Sierra Leone because of an unprecedented outbreak of Ebola.|url=http://wwwnc.cdc.gov/travel/notices/warning/ebola-liberia|website=CDC|accessdate=2 August 2014|date=July 31, 2014}}&lt;/ref&gt;&lt;ref name=CDCAug2014N&gt;{{Cite web|title=Outbreak of Ebola in Guinea, Liberia, and Sierra Leone|url=http://www.cdc.gov/vhf/ebola/outbreaks/guinea/index.html|website=CDC|accessdate=5 August 2014|date=August 4, 2014}}&lt;/ref&gt; Ukusukela ngoRhoboyi 2014 sele kubikwe bona kunabantu esele bangenwe bulwelwe lobu abayi-1600.&lt;ref&gt;{{Cite web|title=Ebola virus disease update - West Africa|url=http://www.who.int/csr/don/2014_08_04_ebola/en/|website=WHO|accessdate=6 August 2014|date=Aug 4, 2014}}&lt;/ref&gt; Imizamo yona iyenziwa bona kutholakalle [[intatha/isihlahla]] esingalapha ubulwelwe lobu, kodwana okwanje asikho kwatholakala ipengu yakhona.&lt;ref name=WHO2014/&gt;

== Isikhombiso selwazi==
{{Reflist|colwidth=25em}}

; IBhibhliyografu
{{Refbegin}}
* {{Cite book |last=Klenk |first=Hans-Dieter |title=Marburg and Ebola Viruses (Current Topics in Microbiology and Immunology) |date=January 1999 |publisher=Springer-Verlag Telos |location=Berlin |isbn=978-3-540-64729-4 |ref=CITEREFKlenk1999}}
* {{Cite book |first1=Hans-Dieter |last1=Klenk |first2=Heinz |last2=Feldmann |title=Ebola and Marburg viruses: molecular and cellular biology |url=http://books.google.com/?id=EV_mFgnyPoMC |format=Limited preview |year=2004 |publisher=Horizon Bioscience |location=Wymondham, Norfolk, UK |isbn=978-0-9545232-3-7 |ref=CITEREFKlenkFeldmann2004}}
* {{Cite book |last=Kuhn |first=Jens H. |title=Filoviruses: A Compendium of 40 Years of Epidemiological, Clinical, and Laboratory Studies. Archives of Virology Supplement, vol. 20 |url=http://books.google.com/?id=LaOue0F9Ns4C |format=Limited preview |year=2008 |publisher=SpringerWienNewYork |location=Vienna |isbn=978-3-211-20670-6 |ref=CITEREFKuhn2008}}
* {{Cite book |last1=McCormick |first1=Joseph |last2=Fisher-Hoch |first2=Susan |others=Horvitz, Leslie Alan |title=Level 4: Virus Hunters of the CDC |url=http://books.google.com/?id=QEvR3aJX2m0C |format=Limited preview |origyear=1996 |edition=Updated [3rd] |year=1999 |publisher=Barnes &amp; Noble |isbn=978-0-7607-1208-5 |ref=CITEREFMcCormickFisher-Hoch1999 |month=June}}
* {{Cite book |last=Pattyn |first=S. R. |title=Ebola Virus Haemorrhagic Fever |year=1978 |url=http://www.itg.be/ebola/ |format=Full free text |edition=1st |publisher=Elsevier/North-Holland Biomedical Press |location=Amsterdam |isbn=0-444-80060-3 |ref=CITEREFPattyn1978}}
* {{Cite book | last1 = Ryabchikova | first1 = Elena I. | last2 = Price | first2 = Barbara B. | title = Ebola and Marburg Viruses: A View of Infection Using Electron Microscopy | year = 2004 | publisher = Battelle Press | location = Columbus, Ohio | isbn = 978-1-57477-131-2 | ref = CITEREFRyabchikovaPrice2004 }}
{{Refend}}

==Okuhlanganiswe nalokhu okunye==
{{Refbegin}}
* [http://viralzone.expasy.org/all_by_species/207.html ViralZone: Ebola-like viruses] – Virological repository from the [[Swiss Institute of Bioinformatics]]
* [http://www.cdc.gov/vhf/ebola/ CDC: Ebola hemorrhagic fever] – Centers for Disease Control and Prevention, Special Pathogens Branch
* [http://www.who.int/csr/disease/ebola/en/ WHO: Ebola haemorrhagic fever] – World Health Organization, Global Alert and Response
* [http://www.viprbrc.org/brc/home.do?decorator=filo Virus Pathogen Database and Analysis Resource (ViPR): Filoviridae]
* [https://web.archive.org/web/20140808072117/http://www.ebi.ac.uk/pdbe/emdb/searchResults.html/?q=ebola 3D macromolecular structures of the Ebola virus archived in the EM Data Bank(EMDB)]
* [https://web.archive.org/web/20140819171607/https://maps.google.com/maps/ms?msa=0&amp;msid=202977755949863934429.0004c658eb30f9c4fb1c0&amp;ie=UTF8&amp;t=h&amp;ll=27.371767,5.273438&amp;spn=110.017392,184.21875&amp;z=2&amp;source=embed&amp;dg=feature Google Map of Ebola Outbreaks]
* [https://web.archive.org/web/20140816223245/http://www.who.int/csr/bioriskreduction/filovirus_infection_control/en/ WHO recommended infection control measures]
{{Refend}}</text>
      <sha1>c4ueb3w95siqh23xo499zssab1lseg9</sha1>
    </revision>
    <revision>
      <id>1337</id>
      <parentid>1336</parentid>
      <timestamp>2024-10-14T13:47:13Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>16 revisions imported</comment>
      <origin>1336</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9636" sha1="c4ueb3w95siqh23xo499zssab1lseg9" xml:space="preserve">{{Infobox disease
| name           = Ubulwelwe be-Ebola
| image          = 7042 lores-Ebola-Zaire-CDC Photo.jpg
| caption        = Isithombe sango-1976 sabahlengikazi ababili, bajame hlanu kwaka [[Mayinga N'Seka|Mayinga N.]], omumuntu osahlelwe mumulwana we-Ebola. Wahlongakala ngemva kwamalanga ambalwa ngonobangela wobulwelwe bokopha nokurhadza kweengazi.
| DiseasesDB     = 18043
| ICD10          = {{ICD10|A|98|4|a|90}}
| ICD9           = {{ICD9|065.8}}
| MedlinePlus    = 001339
| eMedicineSubj  = med
| eMedicineTopic = 626
| MeshID         = D019142
}}
'''Ubulwelwe be-Ebola''' nofana ('''EVD''') '''[[Wp/kri/Ebola|I-Ebola]] nomulwana wokopha iingazi okhambisana nomgomani''' ('''EHF''') mimulwana ebangwa bulwelwe bevayirasi ebizwa nge- [[Ebola]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo athoma ukubonakala phakathi kwamalanga amabili ukuya eemvekeni eentathu ngemva sewungenwe bulwelwe lobu, [[njengomgomani ongapheliko]], umphimbo obabako onesilonda, [[imisipha ebuhlungu kanye nehloko esawula kabuhlungu]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kesinye isikhathi [[ungahlanza]], uphakanyelwe ziimbindi nesifo  [[sokurhuda]], kuzokwenza bona [[amaphaphu]] kanye [[neso]] zingasasebenzi kuhle.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Nasele sekufike lapha, abanye baba nomraro [[wokopha iingazi]].&lt;ref name=WHO2014&gt;{{Cite web|title=Ebola virus disease Fact sheet N°103|url=http://www.who.int/mediacentre/factsheets/fs103/en/|work=World Health Organization|accessdate=12 April 2014|date=March 2014}}&lt;/ref&gt;

&lt;!-- Cause and Diagnosis--&gt;
Umulwana lo ungangena nawuthintana [[neengazi]] zomuntu ophethwe ngibo nofana [[umjuluko]] nanyana [[okunye nokunye okusamanzana]] okuvela (eenlwaneni [[kumaphelaphelana]] nofana iimfene).&lt;ref name=WHO2014/&gt; Bekube nje umulwana akukatholakali bona ungangena ngokuwurhogela emmoyeni.&lt;ref name=WHOAir2014&gt;{{Cite web|title=2014 Ebola Virus Disease (EVD) outbreak in West Africa|url=http://www.who.int/ith/updates/20140421/en/|website=WHO|accessdate=3 August 2014|date=Apr 21 2014}}&lt;/ref&gt; Kukholelwa bonyana abomaphelaphelani bakwazi  ukuphatha umulwana lo kodwana wona angaphathwa ngiwo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kwaba khona umuntu otheleleke ngomulwana lo, umulwana lo ungatheleleka kabanye abantu godu ngesikhathi esifitjhani.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amadoda angasinda ngemva kokulatjhwa angathelela abanye abantu ngokuthunda [[imbewu]] yabo lokha nabaya emsemeni nakungakapheli iinyanga ezimbili.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nakufanele uhlahlutjwe nofana uhlolelwe ubulwelwe lobu be-ebola kufanele izifo ezifana [[nomalalahlengezela]], [[isifo sokurhuda]] kanye omulwana [[wokopha iingazi okhambisana nomgomani]]  inganakwa ukwenzelela ukuthola imiphumela ekungiyo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ukuqinisekisa umrabho womraro wobulwelwe lobu amasampula weengazi ayathathwa ayokuhlolelwa ubulwelwe [[nesivikelasifo seengazini]] kanye ne [[i-RNA]] lobu kanye nengongwana ebanga ubulwelwe lobu.&lt;ref name=WHO2014/&gt;

&lt;!-- Prevention --&gt;
Ukuvikela ubulwelwe lobu kungaphungulwa ukuthelelana hlangana neemfene kanye neemfarigi ezingenwe bulwelwelwe lobu bukhandelwe bona bungayi ebantwini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kungenziwa ngokobana kuhlolwe iinlwana lezi ukobana zinabo ubulwelwe lobu na, nakutholakala bona zinabo kungenzeka bona zibulawe bese kugujelwa imizimba yazo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nawupheka inyama bese wembatha izambatho zokuzivikela nakho kungakusiza,&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; ukwembatha izambatho zokuzivikela lokha nawuhlala nofana uhlanu kwaloyo muntu ongenwe mumulwana lowo [[kanye nokuhlamba izandla ngesibha]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amasampula wananyana yini esamanzana yalabo bantu abangenwe mumulwana lo kufanele zitjhejwe khulu, ubalekele ukuthintana nazo.&lt;ref name=WHO2014/&gt;

&lt;!-- Treatment, Prognosis and Epidemiology--&gt;
Ayikho intatha elapha ubulwelwe lobu; imizamo yokobana kusizwe abantu abangenwe bulwelwe lobu kukobana [[kwenziwe umtswako]] (banikelwe amanzi anetswayi) ukobana bawasele nofana [[bafakwe amadribhu azobangenisela okusamanzana emzimbeni wabo]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu [[buneembalobalo eziphezulu zabantu abafako]]: nabangenwe ngibo ubulwelwe lobu, i-ebola ingabulala pheze isiquntu-50% nofana i-90% yabantu abatheleleke ngayo.&lt;ref name=WHO2014/&gt;&lt;ref name=&quot;Elsevier/Academic Press&quot;&gt;{{Cite book|author1=C.M. Fauquet|title=Virus taxonomy classification and nomenclature of viruses; 8th report of the International Committee on Taxonomy of Viruses|date=2005|publisher=Elsevier/Academic Press|location=Oxford|isbn=9780080575483|page=648|url=http://books.google.ca/books?id=9Wy7Jgy5RWYC&amp;pg=PA648}}&lt;/ref&gt; I-EVD yathoma ukwazakala endaweni enarheni ye [[Sudan]] kanye ne- [[Democratic Republic of Congo]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu butholakala khulu eenarheni zethrophigi zenarhakazi yeAfrika [[Iphakathi le-Sehara ye-Afrika]].&lt;ref name=WHO2014/&gt; Ngo-1976 (ukutholakala kwabo ubulwelwe lobu] ukufikela ngo-2013, besele ingene yatheleleka ebantwini abangaphasii kwe-1000.&lt;ref name=WHO2014/&gt;&lt;ref name=MMWRJune2014&gt;{{Cite web|title=Ebola Viral Disease Outbreak — West Africa, 2014|url=http://www.cdc.gov/mmwr/preview/mmwrhtml/mm6325a4.htm?s_cid=mm6325a4_w|website=CDC|accessdate=26 June 2014|date=June 27, 2014}}&lt;/ref&gt; Ukuqubuka kobulwelwe lobu obukhulu obungazange khebubonwe ngilobu bamuva nje ngebe [[2014  Tjhingalanga ye-Afrika Ukuqubuka kwe-Ebola]], sebele bungene eenarheni [[Guinea]], [[Sierra Leone]], [[Liberia]] begodu ingatheleka ingene ne [[Nigeria]].&lt;ref name=CDC2014&gt;{{Cite web|title=CDC urges all US residents to avoid nonessential travel to Liberia, Guinea, and Sierra Leone because of an unprecedented outbreak of Ebola.|url=http://wwwnc.cdc.gov/travel/notices/warning/ebola-liberia|website=CDC|accessdate=2 August 2014|date=July 31, 2014}}&lt;/ref&gt;&lt;ref name=CDCAug2014N&gt;{{Cite web|title=Outbreak of Ebola in Guinea, Liberia, and Sierra Leone|url=http://www.cdc.gov/vhf/ebola/outbreaks/guinea/index.html|website=CDC|accessdate=5 August 2014|date=August 4, 2014}}&lt;/ref&gt; Ukusukela ngoRhoboyi 2014 sele kubikwe bona kunabantu esele bangenwe bulwelwe lobu abayi-1600.&lt;ref&gt;{{Cite web|title=Ebola virus disease update - West Africa|url=http://www.who.int/csr/don/2014_08_04_ebola/en/|website=WHO|accessdate=6 August 2014|date=Aug 4, 2014}}&lt;/ref&gt; Imizamo yona iyenziwa bona kutholakalle [[intatha/isihlahla]] esingalapha ubulwelwe lobu, kodwana okwanje asikho kwatholakala ipengu yakhona.&lt;ref name=WHO2014/&gt;

== Isikhombiso selwazi==
{{Reflist|colwidth=25em}}

; IBhibhliyografu
{{Refbegin}}
* {{Cite book |last=Klenk |first=Hans-Dieter |title=Marburg and Ebola Viruses (Current Topics in Microbiology and Immunology) |date=January 1999 |publisher=Springer-Verlag Telos |location=Berlin |isbn=978-3-540-64729-4 |ref=CITEREFKlenk1999}}
* {{Cite book |first1=Hans-Dieter |last1=Klenk |first2=Heinz |last2=Feldmann |title=Ebola and Marburg viruses: molecular and cellular biology |url=http://books.google.com/?id=EV_mFgnyPoMC |format=Limited preview |year=2004 |publisher=Horizon Bioscience |location=Wymondham, Norfolk, UK |isbn=978-0-9545232-3-7 |ref=CITEREFKlenkFeldmann2004}}
* {{Cite book |last=Kuhn |first=Jens H. |title=Filoviruses: A Compendium of 40 Years of Epidemiological, Clinical, and Laboratory Studies. Archives of Virology Supplement, vol. 20 |url=http://books.google.com/?id=LaOue0F9Ns4C |format=Limited preview |year=2008 |publisher=SpringerWienNewYork |location=Vienna |isbn=978-3-211-20670-6 |ref=CITEREFKuhn2008}}
* {{Cite book |last1=McCormick |first1=Joseph |last2=Fisher-Hoch |first2=Susan |others=Horvitz, Leslie Alan |title=Level 4: Virus Hunters of the CDC |url=http://books.google.com/?id=QEvR3aJX2m0C |format=Limited preview |origyear=1996 |edition=Updated [3rd] |year=1999 |publisher=Barnes &amp; Noble |isbn=978-0-7607-1208-5 |ref=CITEREFMcCormickFisher-Hoch1999 |month=June}}
* {{Cite book |last=Pattyn |first=S. R. |title=Ebola Virus Haemorrhagic Fever |year=1978 |url=http://www.itg.be/ebola/ |format=Full free text |edition=1st |publisher=Elsevier/North-Holland Biomedical Press |location=Amsterdam |isbn=0-444-80060-3 |ref=CITEREFPattyn1978}}
* {{Cite book | last1 = Ryabchikova | first1 = Elena I. | last2 = Price | first2 = Barbara B. | title = Ebola and Marburg Viruses: A View of Infection Using Electron Microscopy | year = 2004 | publisher = Battelle Press | location = Columbus, Ohio | isbn = 978-1-57477-131-2 | ref = CITEREFRyabchikovaPrice2004 }}
{{Refend}}

==Okuhlanganiswe nalokhu okunye==
{{Refbegin}}
* [http://viralzone.expasy.org/all_by_species/207.html ViralZone: Ebola-like viruses] – Virological repository from the [[Swiss Institute of Bioinformatics]]
* [http://www.cdc.gov/vhf/ebola/ CDC: Ebola hemorrhagic fever] – Centers for Disease Control and Prevention, Special Pathogens Branch
* [http://www.who.int/csr/disease/ebola/en/ WHO: Ebola haemorrhagic fever] – World Health Organization, Global Alert and Response
* [http://www.viprbrc.org/brc/home.do?decorator=filo Virus Pathogen Database and Analysis Resource (ViPR): Filoviridae]
* [https://web.archive.org/web/20140808072117/http://www.ebi.ac.uk/pdbe/emdb/searchResults.html/?q=ebola 3D macromolecular structures of the Ebola virus archived in the EM Data Bank(EMDB)]
* [https://web.archive.org/web/20140819171607/https://maps.google.com/maps/ms?msa=0&amp;msid=202977755949863934429.0004c658eb30f9c4fb1c0&amp;ie=UTF8&amp;t=h&amp;ll=27.371767,5.273438&amp;spn=110.017392,184.21875&amp;z=2&amp;source=embed&amp;dg=feature Google Map of Ebola Outbreaks]
* [https://web.archive.org/web/20140816223245/http://www.who.int/csr/bioriskreduction/filovirus_infection_control/en/ WHO recommended infection control measures]
{{Refend}}</text>
      <sha1>c4ueb3w95siqh23xo499zssab1lseg9</sha1>
    </revision>
    <revision>
      <id>1887</id>
      <parentid>1337</parentid>
      <timestamp>2024-11-12T19:07:33Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <comment>/* Isikhombiso selwazi */+s</comment>
      <origin>1887</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9656" sha1="2w454rx017v2t1pxnzf7mxp71nwlq96" xml:space="preserve">{{Infobox disease
| name           = Ubulwelwe be-Ebola
| image          = 7042 lores-Ebola-Zaire-CDC Photo.jpg
| caption        = Isithombe sango-1976 sabahlengikazi ababili, bajame hlanu kwaka [[Mayinga N'Seka|Mayinga N.]], omumuntu osahlelwe mumulwana we-Ebola. Wahlongakala ngemva kwamalanga ambalwa ngonobangela wobulwelwe bokopha nokurhadza kweengazi.
| DiseasesDB     = 18043
| ICD10          = {{ICD10|A|98|4|a|90}}
| ICD9           = {{ICD9|065.8}}
| MedlinePlus    = 001339
| eMedicineSubj  = med
| eMedicineTopic = 626
| MeshID         = D019142
}}
'''Ubulwelwe be-Ebola''' nofana ('''EVD''') '''[[Wp/kri/Ebola|I-Ebola]] nomulwana wokopha iingazi okhambisana nomgomani''' ('''EHF''') mimulwana ebangwa bulwelwe bevayirasi ebizwa nge- [[Ebola]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo athoma ukubonakala phakathi kwamalanga amabili ukuya eemvekeni eentathu ngemva sewungenwe bulwelwe lobu, [[njengomgomani ongapheliko]], umphimbo obabako onesilonda, [[imisipha ebuhlungu kanye nehloko esawula kabuhlungu]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kesinye isikhathi [[ungahlanza]], uphakanyelwe ziimbindi nesifo  [[sokurhuda]], kuzokwenza bona [[amaphaphu]] kanye [[neso]] zingasasebenzi kuhle.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Nasele sekufike lapha, abanye baba nomraro [[wokopha iingazi]].&lt;ref name=WHO2014&gt;{{Cite web|title=Ebola virus disease Fact sheet N°103|url=https://www.who.int/en/news-room/fact-sheets/detail/ebola-virus-disease|work=World Health Organization|accessdate=12 April 2014|date=March 2014}}&lt;/ref&gt;

&lt;!-- Cause and Diagnosis--&gt;
Umulwana lo ungangena nawuthintana [[neengazi]] zomuntu ophethwe ngibo nofana [[umjuluko]] nanyana [[okunye nokunye okusamanzana]] okuvela (eenlwaneni [[kumaphelaphelana]] nofana iimfene).&lt;ref name=WHO2014/&gt; Bekube nje umulwana akukatholakali bona ungangena ngokuwurhogela emmoyeni.&lt;ref name=WHOAir2014&gt;{{Cite web|title=2014 Ebola Virus Disease (EVD) outbreak in West Africa|url=http://www.who.int/ith/updates/20140421/en/|website=WHO|accessdate=3 August 2014|date=Apr 21 2014}}&lt;/ref&gt; Kukholelwa bonyana abomaphelaphelani bakwazi  ukuphatha umulwana lo kodwana wona angaphathwa ngiwo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kwaba khona umuntu otheleleke ngomulwana lo, umulwana lo ungatheleleka kabanye abantu godu ngesikhathi esifitjhani.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amadoda angasinda ngemva kokulatjhwa angathelela abanye abantu ngokuthunda [[imbewu]] yabo lokha nabaya emsemeni nakungakapheli iinyanga ezimbili.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nakufanele uhlahlutjwe nofana uhlolelwe ubulwelwe lobu be-ebola kufanele izifo ezifana [[nomalalahlengezela]], [[isifo sokurhuda]] kanye omulwana [[wokopha iingazi okhambisana nomgomani]]  inganakwa ukwenzelela ukuthola imiphumela ekungiyo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ukuqinisekisa umrabho womraro wobulwelwe lobu amasampula weengazi ayathathwa ayokuhlolelwa ubulwelwe [[nesivikelasifo seengazini]] kanye ne [[i-RNA]] lobu kanye nengongwana ebanga ubulwelwe lobu.&lt;ref name=WHO2014/&gt;

&lt;!-- Prevention --&gt;
Ukuvikela ubulwelwe lobu kungaphungulwa ukuthelelana hlangana neemfene kanye neemfarigi ezingenwe bulwelwelwe lobu bukhandelwe bona bungayi ebantwini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kungenziwa ngokobana kuhlolwe iinlwana lezi ukobana zinabo ubulwelwe lobu na, nakutholakala bona zinabo kungenzeka bona zibulawe bese kugujelwa imizimba yazo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nawupheka inyama bese wembatha izambatho zokuzivikela nakho kungakusiza,&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; ukwembatha izambatho zokuzivikela lokha nawuhlala nofana uhlanu kwaloyo muntu ongenwe mumulwana lowo [[kanye nokuhlamba izandla ngesibha]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amasampula wananyana yini esamanzana yalabo bantu abangenwe mumulwana lo kufanele zitjhejwe khulu, ubalekele ukuthintana nazo.&lt;ref name=WHO2014/&gt;

&lt;!-- Treatment, Prognosis and Epidemiology--&gt;
Ayikho intatha elapha ubulwelwe lobu; imizamo yokobana kusizwe abantu abangenwe bulwelwe lobu kukobana [[kwenziwe umtswako]] (banikelwe amanzi anetswayi) ukobana bawasele nofana [[bafakwe amadribhu azobangenisela okusamanzana emzimbeni wabo]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu [[buneembalobalo eziphezulu zabantu abafako]]: nabangenwe ngibo ubulwelwe lobu, i-ebola ingabulala pheze isiquntu-50% nofana i-90% yabantu abatheleleke ngayo.&lt;ref name=WHO2014/&gt;&lt;ref name=&quot;Elsevier/Academic Press&quot;&gt;{{Cite book|author1=C.M. Fauquet|title=Virus taxonomy classification and nomenclature of viruses; 8th report of the International Committee on Taxonomy of Viruses|date=2005|publisher=Elsevier/Academic Press|location=Oxford|isbn=9780080575483|page=648|url=http://books.google.ca/books?id=9Wy7Jgy5RWYC&amp;pg=PA648}}&lt;/ref&gt; I-EVD yathoma ukwazakala endaweni enarheni ye [[Sudan]] kanye ne- [[Democratic Republic of Congo]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu butholakala khulu eenarheni zethrophigi zenarhakazi yeAfrika [[Iphakathi le-Sehara ye-Afrika]].&lt;ref name=WHO2014/&gt; Ngo-1976 (ukutholakala kwabo ubulwelwe lobu] ukufikela ngo-2013, besele ingene yatheleleka ebantwini abangaphasii kwe-1000.&lt;ref name=WHO2014/&gt;&lt;ref name=MMWRJune2014&gt;{{Cite web|title=Ebola Viral Disease Outbreak — West Africa, 2014|url=http://www.cdc.gov/mmwr/preview/mmwrhtml/mm6325a4.htm?s_cid=mm6325a4_w|website=CDC|accessdate=26 June 2014|date=June 27, 2014}}&lt;/ref&gt; Ukuqubuka kobulwelwe lobu obukhulu obungazange khebubonwe ngilobu bamuva nje ngebe [[2014  Tjhingalanga ye-Afrika Ukuqubuka kwe-Ebola]], sebele bungene eenarheni [[Guinea]], [[Sierra Leone]], [[Liberia]] begodu ingatheleka ingene ne [[Nigeria]].&lt;ref name=CDC2014&gt;{{Cite web|title=CDC urges all US residents to avoid nonessential travel to Liberia, Guinea, and Sierra Leone because of an unprecedented outbreak of Ebola.|url=http://wwwnc.cdc.gov/travel/notices/warning/ebola-liberia|website=CDC|accessdate=2 August 2014|date=July 31, 2014}}&lt;/ref&gt;&lt;ref name=CDCAug2014N&gt;{{Cite web|title=Outbreak of Ebola in Guinea, Liberia, and Sierra Leone|url=http://www.cdc.gov/vhf/ebola/outbreaks/guinea/index.html|website=CDC|accessdate=5 August 2014|date=August 4, 2014}}&lt;/ref&gt; Ukusukela ngoRhoboyi 2014 sele kubikwe bona kunabantu esele bangenwe bulwelwe lobu abayi-1600.&lt;ref&gt;{{Cite web|title=Ebola virus disease update - West Africa|url=http://www.who.int/csr/don/2014_08_04_ebola/en/|website=WHO|accessdate=6 August 2014|date=Aug 4, 2014}}&lt;/ref&gt; Imizamo yona iyenziwa bona kutholakalle [[intatha/isihlahla]] esingalapha ubulwelwe lobu, kodwana okwanje asikho kwatholakala ipengu yakhona.&lt;ref name=WHO2014/&gt;

== Isikhombiso selwazi==
{{Reflist|colwidth=25em}}

; IBhibhliyografu
{{Refbegin}}
* {{Cite book |last=Klenk |first=Hans-Dieter |title=Marburg and Ebola Viruses (Current Topics in Microbiology and Immunology) |date=January 1999 |publisher=Springer-Verlag Telos |location=Berlin |isbn=978-3-540-64729-4 |ref=CITEREFKlenk1999}}
* {{Cite book |first1=Hans-Dieter |last1=Klenk |first2=Heinz |last2=Feldmann |title=Ebola and Marburg viruses: molecular and cellular biology |url=http://books.google.com/?id=EV_mFgnyPoMC |format=Limited preview |year=2004 |publisher=Horizon Bioscience |location=Wymondham, Norfolk, UK |isbn=978-0-9545232-3-7 |ref=CITEREFKlenkFeldmann2004}}
* {{Cite book |last=Kuhn |first=Jens H. |title=Filoviruses: A Compendium of 40 Years of Epidemiological, Clinical, and Laboratory Studies. Archives of Virology Supplement, vol. 20 |url=http://books.google.com/?id=LaOue0F9Ns4C |format=Limited preview |year=2008 |publisher=SpringerWienNewYork |location=Vienna |isbn=978-3-211-20670-6 |ref=CITEREFKuhn2008}}
* {{Cite book |last1=McCormick |first1=Joseph |last2=Fisher-Hoch |first2=Susan |others=Horvitz, Leslie Alan |title=Level 4: Virus Hunters of the CDC |url=http://books.google.com/?id=QEvR3aJX2m0C |format=Limited preview |origyear=1996 |edition=Updated [3rd] |year=1999 |publisher=Barnes &amp; Noble |isbn=978-0-7607-1208-5 |ref=CITEREFMcCormickFisher-Hoch1999 |month=June}}
* {{Cite book |last=Pattyn |first=S. R. |title=Ebola Virus Haemorrhagic Fever |year=1978 |url=http://www.itg.be/ebola/ |format=Full free text |edition=1st |publisher=Elsevier/North-Holland Biomedical Press |location=Amsterdam |isbn=0-444-80060-3 |ref=CITEREFPattyn1978}}
* {{Cite book | last1 = Ryabchikova | first1 = Elena I. | last2 = Price | first2 = Barbara B. | title = Ebola and Marburg Viruses: A View of Infection Using Electron Microscopy | year = 2004 | publisher = Battelle Press | location = Columbus, Ohio | isbn = 978-1-57477-131-2 | ref = CITEREFRyabchikovaPrice2004 }}
{{Refend}}

==Okuhlanganiswe nalokhu okunye==
{{Refbegin}}
* [http://viralzone.expasy.org/all_by_species/207.html ViralZone: Ebola-like viruses] – Virological repository from the [[Swiss Institute of Bioinformatics]]
* [http://www.cdc.gov/vhf/ebola/ CDC: Ebola hemorrhagic fever] – Centers for Disease Control and Prevention, Special Pathogens Branch
* [http://www.who.int/csr/disease/ebola/en/ WHO: Ebola haemorrhagic fever] – World Health Organization, Global Alert and Response
* [http://www.viprbrc.org/brc/home.do?decorator=filo Virus Pathogen Database and Analysis Resource (ViPR): Filoviridae]
* [https://web.archive.org/web/20140808072117/http://www.ebi.ac.uk/pdbe/emdb/searchResults.html/?q=ebola 3D macromolecular structures of the Ebola virus archived in the EM Data Bank(EMDB)]
* [https://web.archive.org/web/20140819171607/https://maps.google.com/maps/ms?msa=0&amp;msid=202977755949863934429.0004c658eb30f9c4fb1c0&amp;ie=UTF8&amp;t=h&amp;ll=27.371767,5.273438&amp;spn=110.017392,184.21875&amp;z=2&amp;source=embed&amp;dg=feature Google Map of Ebola Outbreaks]
* [https://web.archive.org/web/20140816223245/http://www.who.int/csr/bioriskreduction/filovirus_infection_control/en/ WHO recommended infection control measures]
{{Refend}}</text>
      <sha1>2w454rx017v2t1pxnzf7mxp71nwlq96</sha1>
    </revision>
    <revision>
      <id>1888</id>
      <parentid>1887</parentid>
      <timestamp>2024-11-12T19:09:52Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* Isikhombiso selwazi */+s</comment>
      <origin>1888</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9657" sha1="dpl7a09hovfipb6dmfdfknplaj5hyny" xml:space="preserve">{{Infobox disease
| name           = Ubulwelwe be-Ebola
| image          = 7042 lores-Ebola-Zaire-CDC Photo.jpg
| caption        = Isithombe sango-1976 sabahlengikazi ababili, bajame hlanu kwaka [[Mayinga N'Seka|Mayinga N.]], omumuntu osahlelwe mumulwana we-Ebola. Wahlongakala ngemva kwamalanga ambalwa ngonobangela wobulwelwe bokopha nokurhadza kweengazi.
| DiseasesDB     = 18043
| ICD10          = {{ICD10|A|98|4|a|90}}
| ICD9           = {{ICD9|065.8}}
| MedlinePlus    = 001339
| eMedicineSubj  = med
| eMedicineTopic = 626
| MeshID         = D019142
}}
'''Ubulwelwe be-Ebola''' nofana ('''EVD''') '''[[Wp/kri/Ebola|I-Ebola]] nomulwana wokopha iingazi okhambisana nomgomani''' ('''EHF''') mimulwana ebangwa bulwelwe bevayirasi ebizwa nge- [[Ebola]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo athoma ukubonakala phakathi kwamalanga amabili ukuya eemvekeni eentathu ngemva sewungenwe bulwelwe lobu, [[njengomgomani ongapheliko]], umphimbo obabako onesilonda, [[imisipha ebuhlungu kanye nehloko esawula kabuhlungu]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kesinye isikhathi [[ungahlanza]], uphakanyelwe ziimbindi nesifo  [[sokurhuda]], kuzokwenza bona [[amaphaphu]] kanye [[neso]] zingasasebenzi kuhle.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Nasele sekufike lapha, abanye baba nomraro [[wokopha iingazi]].&lt;ref name=WHO2014&gt;{{Cite web|title=Ebola virus disease Fact sheet N°103|url=https://www.who.int/en/news-room/fact-sheets/detail/ebola-virus-disease|work=World Health Organization|accessdate=12 April 2014|date=March 2014}}&lt;/ref&gt;

&lt;!-- Cause and Diagnosis--&gt;
Umulwana lo ungangena nawuthintana [[neengazi]] zomuntu ophethwe ngibo nofana [[umjuluko]] nanyana [[okunye nokunye okusamanzana]] okuvela (eenlwaneni [[kumaphelaphelana]] nofana iimfene).&lt;ref name=WHO2014/&gt; Bekube nje umulwana akukatholakali bona ungangena ngokuwurhogela emmoyeni.&lt;ref name=WHOAir2014&gt;{{Cite web|title=2014 Ebola Virus Disease (EVD) outbreak in West Africa|url=http://www.who.int/ith/updates/20140421/en/|website=WHO|accessdate=3 August 2014|date=Apr 21 2014}}&lt;/ref&gt; Kukholelwa bonyana abomaphelaphelani bakwazi  ukuphatha umulwana lo kodwana wona angaphathwa ngiwo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kwaba khona umuntu otheleleke ngomulwana lo, umulwana lo ungatheleleka kabanye abantu godu ngesikhathi esifitjhani.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amadoda angasinda ngemva kokulatjhwa angathelela abanye abantu ngokuthunda [[imbewu]] yabo lokha nabaya emsemeni nakungakapheli iinyanga ezimbili.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nakufanele uhlahlutjwe nofana uhlolelwe ubulwelwe lobu be-ebola kufanele izifo ezifana [[nomalalahlengezela]], [[isifo sokurhuda]] kanye omulwana [[wokopha iingazi okhambisana nomgomani]]  inganakwa ukwenzelela ukuthola imiphumela ekungiyo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ukuqinisekisa umrabho womraro wobulwelwe lobu amasampula weengazi ayathathwa ayokuhlolelwa ubulwelwe [[nesivikelasifo seengazini]] kanye ne [[i-RNA]] lobu kanye nengongwana ebanga ubulwelwe lobu.&lt;ref name=WHO2014/&gt;

&lt;!-- Prevention --&gt;
Ukuvikela ubulwelwe lobu kungaphungulwa ukuthelelana hlangana neemfene kanye neemfarigi ezingenwe bulwelwelwe lobu bukhandelwe bona bungayi ebantwini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kungenziwa ngokobana kuhlolwe iinlwana lezi ukobana zinabo ubulwelwe lobu na, nakutholakala bona zinabo kungenzeka bona zibulawe bese kugujelwa imizimba yazo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nawupheka inyama bese wembatha izambatho zokuzivikela nakho kungakusiza,&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; ukwembatha izambatho zokuzivikela lokha nawuhlala nofana uhlanu kwaloyo muntu ongenwe mumulwana lowo [[kanye nokuhlamba izandla ngesibha]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amasampula wananyana yini esamanzana yalabo bantu abangenwe mumulwana lo kufanele zitjhejwe khulu, ubalekele ukuthintana nazo.&lt;ref name=WHO2014/&gt;

&lt;!-- Treatment, Prognosis and Epidemiology--&gt;
Ayikho intatha elapha ubulwelwe lobu; imizamo yokobana kusizwe abantu abangenwe bulwelwe lobu kukobana [[kwenziwe umtswako]] (banikelwe amanzi anetswayi) ukobana bawasele nofana [[bafakwe amadribhu azobangenisela okusamanzana emzimbeni wabo]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu [[buneembalobalo eziphezulu zabantu abafako]]: nabangenwe ngibo ubulwelwe lobu, i-ebola ingabulala pheze isiquntu-50% nofana i-90% yabantu abatheleleke ngayo.&lt;ref name=WHO2014/&gt;&lt;ref name=&quot;Elsevier/Academic Press&quot;&gt;{{Cite book|author1=C.M. Fauquet|title=Virus taxonomy classification and nomenclature of viruses; 8th report of the International Committee on Taxonomy of Viruses|date=2005|publisher=Elsevier/Academic Press|location=Oxford|isbn=9780080575483|page=648|url=http://books.google.ca/books?id=9Wy7Jgy5RWYC&amp;pg=PA648}}&lt;/ref&gt; I-EVD yathoma ukwazakala endaweni enarheni ye [[Sudan]] kanye ne- [[Democratic Republic of Congo]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu butholakala khulu eenarheni zethrophigi zenarhakazi yeAfrika [[Iphakathi le-Sehara ye-Afrika]].&lt;ref name=WHO2014/&gt; Ngo-1976 (ukutholakala kwabo ubulwelwe lobu] ukufikela ngo-2013, besele ingene yatheleleka ebantwini abangaphasii kwe-1000.&lt;ref name=WHO2014/&gt;&lt;ref name=MMWRJune2014&gt;{{Cite web|title=Ebola Viral Disease Outbreak — West Africa, 2014|url=https://www.cdc.gov/mmwr/preview/mmwrhtml/mm6325a4.htm?s_cid=mm6325a4_w|website=CDC|accessdate=26 June 2014|date=June 27, 2014}}&lt;/ref&gt; Ukuqubuka kobulwelwe lobu obukhulu obungazange khebubonwe ngilobu bamuva nje ngebe [[2014  Tjhingalanga ye-Afrika Ukuqubuka kwe-Ebola]], sebele bungene eenarheni [[Guinea]], [[Sierra Leone]], [[Liberia]] begodu ingatheleka ingene ne [[Nigeria]].&lt;ref name=CDC2014&gt;{{Cite web|title=CDC urges all US residents to avoid nonessential travel to Liberia, Guinea, and Sierra Leone because of an unprecedented outbreak of Ebola.|url=http://wwwnc.cdc.gov/travel/notices/warning/ebola-liberia|website=CDC|accessdate=2 August 2014|date=July 31, 2014}}&lt;/ref&gt;&lt;ref name=CDCAug2014N&gt;{{Cite web|title=Outbreak of Ebola in Guinea, Liberia, and Sierra Leone|url=http://www.cdc.gov/vhf/ebola/outbreaks/guinea/index.html|website=CDC|accessdate=5 August 2014|date=August 4, 2014}}&lt;/ref&gt; Ukusukela ngoRhoboyi 2014 sele kubikwe bona kunabantu esele bangenwe bulwelwe lobu abayi-1600.&lt;ref&gt;{{Cite web|title=Ebola virus disease update - West Africa|url=http://www.who.int/csr/don/2014_08_04_ebola/en/|website=WHO|accessdate=6 August 2014|date=Aug 4, 2014}}&lt;/ref&gt; Imizamo yona iyenziwa bona kutholakalle [[intatha/isihlahla]] esingalapha ubulwelwe lobu, kodwana okwanje asikho kwatholakala ipengu yakhona.&lt;ref name=WHO2014/&gt;

== Isikhombiso selwazi==
{{Reflist|colwidth=25em}}

; IBhibhliyografu
{{Refbegin}}
* {{Cite book |last=Klenk |first=Hans-Dieter |title=Marburg and Ebola Viruses (Current Topics in Microbiology and Immunology) |date=January 1999 |publisher=Springer-Verlag Telos |location=Berlin |isbn=978-3-540-64729-4 |ref=CITEREFKlenk1999}}
* {{Cite book |first1=Hans-Dieter |last1=Klenk |first2=Heinz |last2=Feldmann |title=Ebola and Marburg viruses: molecular and cellular biology |url=http://books.google.com/?id=EV_mFgnyPoMC |format=Limited preview |year=2004 |publisher=Horizon Bioscience |location=Wymondham, Norfolk, UK |isbn=978-0-9545232-3-7 |ref=CITEREFKlenkFeldmann2004}}
* {{Cite book |last=Kuhn |first=Jens H. |title=Filoviruses: A Compendium of 40 Years of Epidemiological, Clinical, and Laboratory Studies. Archives of Virology Supplement, vol. 20 |url=http://books.google.com/?id=LaOue0F9Ns4C |format=Limited preview |year=2008 |publisher=SpringerWienNewYork |location=Vienna |isbn=978-3-211-20670-6 |ref=CITEREFKuhn2008}}
* {{Cite book |last1=McCormick |first1=Joseph |last2=Fisher-Hoch |first2=Susan |others=Horvitz, Leslie Alan |title=Level 4: Virus Hunters of the CDC |url=http://books.google.com/?id=QEvR3aJX2m0C |format=Limited preview |origyear=1996 |edition=Updated [3rd] |year=1999 |publisher=Barnes &amp; Noble |isbn=978-0-7607-1208-5 |ref=CITEREFMcCormickFisher-Hoch1999 |month=June}}
* {{Cite book |last=Pattyn |first=S. R. |title=Ebola Virus Haemorrhagic Fever |year=1978 |url=http://www.itg.be/ebola/ |format=Full free text |edition=1st |publisher=Elsevier/North-Holland Biomedical Press |location=Amsterdam |isbn=0-444-80060-3 |ref=CITEREFPattyn1978}}
* {{Cite book | last1 = Ryabchikova | first1 = Elena I. | last2 = Price | first2 = Barbara B. | title = Ebola and Marburg Viruses: A View of Infection Using Electron Microscopy | year = 2004 | publisher = Battelle Press | location = Columbus, Ohio | isbn = 978-1-57477-131-2 | ref = CITEREFRyabchikovaPrice2004 }}
{{Refend}}

==Okuhlanganiswe nalokhu okunye==
{{Refbegin}}
* [http://viralzone.expasy.org/all_by_species/207.html ViralZone: Ebola-like viruses] – Virological repository from the [[Swiss Institute of Bioinformatics]]
* [http://www.cdc.gov/vhf/ebola/ CDC: Ebola hemorrhagic fever] – Centers for Disease Control and Prevention, Special Pathogens Branch
* [http://www.who.int/csr/disease/ebola/en/ WHO: Ebola haemorrhagic fever] – World Health Organization, Global Alert and Response
* [http://www.viprbrc.org/brc/home.do?decorator=filo Virus Pathogen Database and Analysis Resource (ViPR): Filoviridae]
* [https://web.archive.org/web/20140808072117/http://www.ebi.ac.uk/pdbe/emdb/searchResults.html/?q=ebola 3D macromolecular structures of the Ebola virus archived in the EM Data Bank(EMDB)]
* [https://web.archive.org/web/20140819171607/https://maps.google.com/maps/ms?msa=0&amp;msid=202977755949863934429.0004c658eb30f9c4fb1c0&amp;ie=UTF8&amp;t=h&amp;ll=27.371767,5.273438&amp;spn=110.017392,184.21875&amp;z=2&amp;source=embed&amp;dg=feature Google Map of Ebola Outbreaks]
* [https://web.archive.org/web/20140816223245/http://www.who.int/csr/bioriskreduction/filovirus_infection_control/en/ WHO recommended infection control measures]
{{Refend}}</text>
      <sha1>dpl7a09hovfipb6dmfdfknplaj5hyny</sha1>
    </revision>
    <revision>
      <id>1889</id>
      <parentid>1888</parentid>
      <timestamp>2024-11-12T19:12:26Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* Isikhombiso selwazi */+s</comment>
      <origin>1889</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9680" sha1="icqyp64xer8wj901hjpt6xiam914u4m" xml:space="preserve">{{Infobox disease
| name           = Ubulwelwe be-Ebola
| image          = 7042 lores-Ebola-Zaire-CDC Photo.jpg
| caption        = Isithombe sango-1976 sabahlengikazi ababili, bajame hlanu kwaka [[Mayinga N'Seka|Mayinga N.]], omumuntu osahlelwe mumulwana we-Ebola. Wahlongakala ngemva kwamalanga ambalwa ngonobangela wobulwelwe bokopha nokurhadza kweengazi.
| DiseasesDB     = 18043
| ICD10          = {{ICD10|A|98|4|a|90}}
| ICD9           = {{ICD9|065.8}}
| MedlinePlus    = 001339
| eMedicineSubj  = med
| eMedicineTopic = 626
| MeshID         = D019142
}}
'''Ubulwelwe be-Ebola''' nofana ('''EVD''') '''[[Wp/kri/Ebola|I-Ebola]] nomulwana wokopha iingazi okhambisana nomgomani''' ('''EHF''') mimulwana ebangwa bulwelwe bevayirasi ebizwa nge- [[Ebola]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo athoma ukubonakala phakathi kwamalanga amabili ukuya eemvekeni eentathu ngemva sewungenwe bulwelwe lobu, [[njengomgomani ongapheliko]], umphimbo obabako onesilonda, [[imisipha ebuhlungu kanye nehloko esawula kabuhlungu]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kesinye isikhathi [[ungahlanza]], uphakanyelwe ziimbindi nesifo  [[sokurhuda]], kuzokwenza bona [[amaphaphu]] kanye [[neso]] zingasasebenzi kuhle.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Nasele sekufike lapha, abanye baba nomraro [[wokopha iingazi]].&lt;ref name=WHO2014&gt;{{Cite web|title=Ebola virus disease Fact sheet N°103|url=https://www.who.int/en/news-room/fact-sheets/detail/ebola-virus-disease|work=World Health Organization|accessdate=12 April 2014|date=March 2014}}&lt;/ref&gt;

&lt;!-- Cause and Diagnosis--&gt;
Umulwana lo ungangena nawuthintana [[neengazi]] zomuntu ophethwe ngibo nofana [[umjuluko]] nanyana [[okunye nokunye okusamanzana]] okuvela (eenlwaneni [[kumaphelaphelana]] nofana iimfene).&lt;ref name=WHO2014/&gt; Bekube nje umulwana akukatholakali bona ungangena ngokuwurhogela emmoyeni.&lt;ref name=WHOAir2014&gt;{{Cite web|title=2014 Ebola Virus Disease (EVD) outbreak in West Africa|url=http://www.who.int/ith/updates/20140421/en/|website=WHO|accessdate=3 August 2014|date=Apr 21 2014}}&lt;/ref&gt; Kukholelwa bonyana abomaphelaphelani bakwazi  ukuphatha umulwana lo kodwana wona angaphathwa ngiwo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kwaba khona umuntu otheleleke ngomulwana lo, umulwana lo ungatheleleka kabanye abantu godu ngesikhathi esifitjhani.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amadoda angasinda ngemva kokulatjhwa angathelela abanye abantu ngokuthunda [[imbewu]] yabo lokha nabaya emsemeni nakungakapheli iinyanga ezimbili.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nakufanele uhlahlutjwe nofana uhlolelwe ubulwelwe lobu be-ebola kufanele izifo ezifana [[nomalalahlengezela]], [[isifo sokurhuda]] kanye omulwana [[wokopha iingazi okhambisana nomgomani]]  inganakwa ukwenzelela ukuthola imiphumela ekungiyo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ukuqinisekisa umrabho womraro wobulwelwe lobu amasampula weengazi ayathathwa ayokuhlolelwa ubulwelwe [[nesivikelasifo seengazini]] kanye ne [[i-RNA]] lobu kanye nengongwana ebanga ubulwelwe lobu.&lt;ref name=WHO2014/&gt;

&lt;!-- Prevention --&gt;
Ukuvikela ubulwelwe lobu kungaphungulwa ukuthelelana hlangana neemfene kanye neemfarigi ezingenwe bulwelwelwe lobu bukhandelwe bona bungayi ebantwini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kungenziwa ngokobana kuhlolwe iinlwana lezi ukobana zinabo ubulwelwe lobu na, nakutholakala bona zinabo kungenzeka bona zibulawe bese kugujelwa imizimba yazo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nawupheka inyama bese wembatha izambatho zokuzivikela nakho kungakusiza,&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; ukwembatha izambatho zokuzivikela lokha nawuhlala nofana uhlanu kwaloyo muntu ongenwe mumulwana lowo [[kanye nokuhlamba izandla ngesibha]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amasampula wananyana yini esamanzana yalabo bantu abangenwe mumulwana lo kufanele zitjhejwe khulu, ubalekele ukuthintana nazo.&lt;ref name=WHO2014/&gt;

&lt;!-- Treatment, Prognosis and Epidemiology--&gt;
Ayikho intatha elapha ubulwelwe lobu; imizamo yokobana kusizwe abantu abangenwe bulwelwe lobu kukobana [[kwenziwe umtswako]] (banikelwe amanzi anetswayi) ukobana bawasele nofana [[bafakwe amadribhu azobangenisela okusamanzana emzimbeni wabo]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu [[buneembalobalo eziphezulu zabantu abafako]]: nabangenwe ngibo ubulwelwe lobu, i-ebola ingabulala pheze isiquntu-50% nofana i-90% yabantu abatheleleke ngayo.&lt;ref name=WHO2014/&gt;&lt;ref name=&quot;Elsevier/Academic Press&quot;&gt;{{Cite book|author1=C.M. Fauquet|title=Virus taxonomy classification and nomenclature of viruses; 8th report of the International Committee on Taxonomy of Viruses|date=2005|publisher=Elsevier/Academic Press|location=Oxford|isbn=9780080575483|page=648|url=http://books.google.ca/books?id=9Wy7Jgy5RWYC&amp;pg=PA648}}&lt;/ref&gt; I-EVD yathoma ukwazakala endaweni enarheni ye [[Sudan]] kanye ne- [[Democratic Republic of Congo]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu butholakala khulu eenarheni zethrophigi zenarhakazi yeAfrika [[Iphakathi le-Sehara ye-Afrika]].&lt;ref name=WHO2014/&gt; Ngo-1976 (ukutholakala kwabo ubulwelwe lobu] ukufikela ngo-2013, besele ingene yatheleleka ebantwini abangaphasii kwe-1000.&lt;ref name=WHO2014/&gt;&lt;ref name=MMWRJune2014&gt;{{Cite web|title=Ebola Viral Disease Outbreak — West Africa, 2014|url=https://www.cdc.gov/mmwr/preview/mmwrhtml/mm6325a4.htm?s_cid=mm6325a4_w|website=CDC|accessdate=26 June 2014|date=June 27, 2014}}&lt;/ref&gt; Ukuqubuka kobulwelwe lobu obukhulu obungazange khebubonwe ngilobu bamuva nje ngebe [[2014  Tjhingalanga ye-Afrika Ukuqubuka kwe-Ebola]], sebele bungene eenarheni [[Guinea]], [[Sierra Leone]], [[Liberia]] begodu ingatheleka ingene ne [[Nigeria]].&lt;ref name=CDC2014&gt;{{Cite web|title=CDC urges all US residents to avoid nonessential travel to Liberia, Guinea, and Sierra Leone because of an unprecedented outbreak of Ebola.|url=http://wwwnc.cdc.gov/travel/notices/warning/ebola-liberia|website=CDC|accessdate=2 August 2014|date=July 31, 2014}}&lt;/ref&gt;&lt;ref name=CDCAug2014N&gt;{{Cite web|title=Outbreak of Ebola in Guinea, Liberia, and Sierra Leone|url=http://www.cdc.gov/vhf/ebola/outbreaks/guinea/index.html|website=CDC|accessdate=5 August 2014|date=August 4, 2014}}&lt;/ref&gt; Ukusukela ngoRhoboyi 2014 sele kubikwe bona kunabantu esele bangenwe bulwelwe lobu abayi-1600.&lt;ref&gt;{{Cite web|title=Ebola virus disease update - West Africa|url=http://www.who.int/csr/don/2014_08_04_ebola/en/|website=WHO|accessdate=6 August 2014|date=Aug 4, 2014}}&lt;/ref&gt; Imizamo yona iyenziwa bona kutholakalle [[intatha/isihlahla]] esingalapha ubulwelwe lobu, kodwana okwanje asikho kwatholakala ipengu yakhona.&lt;ref name=WHO2014/&gt;

== Isikhombiso selwazi==
{{Reflist|colwidth=25em}}

; IBhibhliyografu
{{Refbegin}}
* {{Cite book |last=Klenk |first=Hans-Dieter |title=Marburg and Ebola Viruses (Current Topics in Microbiology and Immunology) |date=January 1999 |publisher=Springer-Verlag Telos |location=Berlin |isbn=978-3-540-64729-4 |ref=CITEREFKlenk1999}}
* {{Cite book |first1=Hans-Dieter |last1=Klenk |first2=Heinz |last2=Feldmann |title=Ebola and Marburg viruses: molecular and cellular biology |url=https://books.google.com/books?id=EV_mFgnyPoMC&amp;redir_esc=y&amp;hl=en|format=Limited preview |year=2004 |publisher=Horizon Bioscience |location=Wymondham, Norfolk, UK |isbn=978-0-9545232-3-7 |ref=CITEREFKlenkFeldmann2004}}
* {{Cite book |last=Kuhn |first=Jens H. |title=Filoviruses: A Compendium of 40 Years of Epidemiological, Clinical, and Laboratory Studies. Archives of Virology Supplement, vol. 20 |url=http://books.google.com/?id=LaOue0F9Ns4C |format=Limited preview |year=2008 |publisher=SpringerWienNewYork |location=Vienna |isbn=978-3-211-20670-6 |ref=CITEREFKuhn2008}}
* {{Cite book |last1=McCormick |first1=Joseph |last2=Fisher-Hoch |first2=Susan |others=Horvitz, Leslie Alan |title=Level 4: Virus Hunters of the CDC |url=http://books.google.com/?id=QEvR3aJX2m0C |format=Limited preview |origyear=1996 |edition=Updated [3rd] |year=1999 |publisher=Barnes &amp; Noble |isbn=978-0-7607-1208-5 |ref=CITEREFMcCormickFisher-Hoch1999 |month=June}}
* {{Cite book |last=Pattyn |first=S. R. |title=Ebola Virus Haemorrhagic Fever |year=1978 |url=http://www.itg.be/ebola/ |format=Full free text |edition=1st |publisher=Elsevier/North-Holland Biomedical Press |location=Amsterdam |isbn=0-444-80060-3 |ref=CITEREFPattyn1978}}
* {{Cite book | last1 = Ryabchikova | first1 = Elena I. | last2 = Price | first2 = Barbara B. | title = Ebola and Marburg Viruses: A View of Infection Using Electron Microscopy | year = 2004 | publisher = Battelle Press | location = Columbus, Ohio | isbn = 978-1-57477-131-2 | ref = CITEREFRyabchikovaPrice2004 }}
{{Refend}}

==Okuhlanganiswe nalokhu okunye==
{{Refbegin}}
* [http://viralzone.expasy.org/all_by_species/207.html ViralZone: Ebola-like viruses] – Virological repository from the [[Swiss Institute of Bioinformatics]]
* [http://www.cdc.gov/vhf/ebola/ CDC: Ebola hemorrhagic fever] – Centers for Disease Control and Prevention, Special Pathogens Branch
* [http://www.who.int/csr/disease/ebola/en/ WHO: Ebola haemorrhagic fever] – World Health Organization, Global Alert and Response
* [http://www.viprbrc.org/brc/home.do?decorator=filo Virus Pathogen Database and Analysis Resource (ViPR): Filoviridae]
* [https://web.archive.org/web/20140808072117/http://www.ebi.ac.uk/pdbe/emdb/searchResults.html/?q=ebola 3D macromolecular structures of the Ebola virus archived in the EM Data Bank(EMDB)]
* [https://web.archive.org/web/20140819171607/https://maps.google.com/maps/ms?msa=0&amp;msid=202977755949863934429.0004c658eb30f9c4fb1c0&amp;ie=UTF8&amp;t=h&amp;ll=27.371767,5.273438&amp;spn=110.017392,184.21875&amp;z=2&amp;source=embed&amp;dg=feature Google Map of Ebola Outbreaks]
* [https://web.archive.org/web/20140816223245/http://www.who.int/csr/bioriskreduction/filovirus_infection_control/en/ WHO recommended infection control measures]
{{Refend}}</text>
      <sha1>icqyp64xer8wj901hjpt6xiam914u4m</sha1>
    </revision>
    <revision>
      <id>2190</id>
      <parentid>1889</parentid>
      <timestamp>2024-11-28T20:04:23Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>wwwnc.cdc.gov</comment>
      <origin>2190</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9680" sha1="hl7wjmdft21vpbf6mhqjokxb8f9yh4f" xml:space="preserve">{{Infobox disease
| name           = Ubulwelwe be-Ebola
| image          = 7042 lores-Ebola-Zaire-CDC Photo.jpg
| caption        = Isithombe sango-1976 sabahlengikazi ababili, bajame hlanu kwaka [[Mayinga N'Seka|Mayinga N.]], omumuntu osahlelwe mumulwana we-Ebola. Wahlongakala ngemva kwamalanga ambalwa ngonobangela wobulwelwe bokopha nokurhadza kweengazi.
| DiseasesDB     = 18043
| ICD10          = {{ICD10|A|98|4|a|90}}
| ICD9           = {{ICD9|065.8}}
| MedlinePlus    = 001339
| eMedicineSubj  = med
| eMedicineTopic = 626
| MeshID         = D019142
}}
'''Ubulwelwe be-Ebola''' nofana ('''EVD''') '''[[Wp/kri/Ebola|I-Ebola]] nomulwana wokopha iingazi okhambisana nomgomani''' ('''EHF''') mimulwana ebangwa bulwelwe bevayirasi ebizwa nge- [[Ebola]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo athoma ukubonakala phakathi kwamalanga amabili ukuya eemvekeni eentathu ngemva sewungenwe bulwelwe lobu, [[njengomgomani ongapheliko]], umphimbo obabako onesilonda, [[imisipha ebuhlungu kanye nehloko esawula kabuhlungu]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kesinye isikhathi [[ungahlanza]], uphakanyelwe ziimbindi nesifo  [[sokurhuda]], kuzokwenza bona [[amaphaphu]] kanye [[neso]] zingasasebenzi kuhle.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Nasele sekufike lapha, abanye baba nomraro [[wokopha iingazi]].&lt;ref name=WHO2014&gt;{{Cite web|title=Ebola virus disease Fact sheet N°103|url=https://www.who.int/en/news-room/fact-sheets/detail/ebola-virus-disease|work=World Health Organization|accessdate=12 April 2014|date=March 2014}}&lt;/ref&gt;

&lt;!-- Cause and Diagnosis--&gt;
Umulwana lo ungangena nawuthintana [[neengazi]] zomuntu ophethwe ngibo nofana [[umjuluko]] nanyana [[okunye nokunye okusamanzana]] okuvela (eenlwaneni [[kumaphelaphelana]] nofana iimfene).&lt;ref name=WHO2014/&gt; Bekube nje umulwana akukatholakali bona ungangena ngokuwurhogela emmoyeni.&lt;ref name=WHOAir2014&gt;{{Cite web|title=2014 Ebola Virus Disease (EVD) outbreak in West Africa|url=http://www.who.int/ith/updates/20140421/en/|website=WHO|accessdate=3 August 2014|date=Apr 21 2014}}&lt;/ref&gt; Kukholelwa bonyana abomaphelaphelani bakwazi  ukuphatha umulwana lo kodwana wona angaphathwa ngiwo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kwaba khona umuntu otheleleke ngomulwana lo, umulwana lo ungatheleleka kabanye abantu godu ngesikhathi esifitjhani.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amadoda angasinda ngemva kokulatjhwa angathelela abanye abantu ngokuthunda [[imbewu]] yabo lokha nabaya emsemeni nakungakapheli iinyanga ezimbili.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nakufanele uhlahlutjwe nofana uhlolelwe ubulwelwe lobu be-ebola kufanele izifo ezifana [[nomalalahlengezela]], [[isifo sokurhuda]] kanye omulwana [[wokopha iingazi okhambisana nomgomani]]  inganakwa ukwenzelela ukuthola imiphumela ekungiyo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ukuqinisekisa umrabho womraro wobulwelwe lobu amasampula weengazi ayathathwa ayokuhlolelwa ubulwelwe [[nesivikelasifo seengazini]] kanye ne [[i-RNA]] lobu kanye nengongwana ebanga ubulwelwe lobu.&lt;ref name=WHO2014/&gt;

&lt;!-- Prevention --&gt;
Ukuvikela ubulwelwe lobu kungaphungulwa ukuthelelana hlangana neemfene kanye neemfarigi ezingenwe bulwelwelwe lobu bukhandelwe bona bungayi ebantwini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kungenziwa ngokobana kuhlolwe iinlwana lezi ukobana zinabo ubulwelwe lobu na, nakutholakala bona zinabo kungenzeka bona zibulawe bese kugujelwa imizimba yazo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nawupheka inyama bese wembatha izambatho zokuzivikela nakho kungakusiza,&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; ukwembatha izambatho zokuzivikela lokha nawuhlala nofana uhlanu kwaloyo muntu ongenwe mumulwana lowo [[kanye nokuhlamba izandla ngesibha]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amasampula wananyana yini esamanzana yalabo bantu abangenwe mumulwana lo kufanele zitjhejwe khulu, ubalekele ukuthintana nazo.&lt;ref name=WHO2014/&gt;

&lt;!-- Treatment, Prognosis and Epidemiology--&gt;
Ayikho intatha elapha ubulwelwe lobu; imizamo yokobana kusizwe abantu abangenwe bulwelwe lobu kukobana [[kwenziwe umtswako]] (banikelwe amanzi anetswayi) ukobana bawasele nofana [[bafakwe amadribhu azobangenisela okusamanzana emzimbeni wabo]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu [[buneembalobalo eziphezulu zabantu abafako]]: nabangenwe ngibo ubulwelwe lobu, i-ebola ingabulala pheze isiquntu-50% nofana i-90% yabantu abatheleleke ngayo.&lt;ref name=WHO2014/&gt;&lt;ref name=&quot;Elsevier/Academic Press&quot;&gt;{{Cite book|author1=C.M. Fauquet|title=Virus taxonomy classification and nomenclature of viruses; 8th report of the International Committee on Taxonomy of Viruses|date=2005|publisher=Elsevier/Academic Press|location=Oxford|isbn=9780080575483|page=648|url=http://books.google.ca/books?id=9Wy7Jgy5RWYC&amp;pg=PA648}}&lt;/ref&gt; I-EVD yathoma ukwazakala endaweni enarheni ye [[Sudan]] kanye ne- [[Democratic Republic of Congo]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu butholakala khulu eenarheni zethrophigi zenarhakazi yeAfrika [[Iphakathi le-Sehara ye-Afrika]].&lt;ref name=WHO2014/&gt; Ngo-1976 (ukutholakala kwabo ubulwelwe lobu] ukufikela ngo-2013, besele ingene yatheleleka ebantwini abangaphasii kwe-1000.&lt;ref name=WHO2014/&gt;&lt;ref name=MMWRJune2014&gt;{{Cite web|title=Ebola Viral Disease Outbreak — West Africa, 2014|url=https://www.cdc.gov/mmwr/preview/mmwrhtml/mm6325a4.htm?s_cid=mm6325a4_w|website=CDC|accessdate=26 June 2014|date=June 27, 2014}}&lt;/ref&gt; Ukuqubuka kobulwelwe lobu obukhulu obungazange khebubonwe ngilobu bamuva nje ngebe [[2014  Tjhingalanga ye-Afrika Ukuqubuka kwe-Ebola]], sebele bungene eenarheni [[Guinea]], [[Sierra Leone]], [[Liberia]] begodu ingatheleka ingene ne [[Nigeria]].&lt;ref name=CDC2014&gt;{{Cite web|title=CDC urges all US residents to avoid nonessential travel to Liberia, Guinea, and Sierra Leone because of an unprecedented outbreak of Ebola.|url=https://wwwnc.cdc.gov/travel/notices/level1/ebola-liberia|website=CDC|accessdate=2 August 2014|date=July 31, 2014}}&lt;/ref&gt;&lt;ref name=CDCAug2014N&gt;{{Cite web|title=Outbreak of Ebola in Guinea, Liberia, and Sierra Leone|url=http://www.cdc.gov/vhf/ebola/outbreaks/guinea/index.html|website=CDC|accessdate=5 August 2014|date=August 4, 2014}}&lt;/ref&gt; Ukusukela ngoRhoboyi 2014 sele kubikwe bona kunabantu esele bangenwe bulwelwe lobu abayi-1600.&lt;ref&gt;{{Cite web|title=Ebola virus disease update - West Africa|url=http://www.who.int/csr/don/2014_08_04_ebola/en/|website=WHO|accessdate=6 August 2014|date=Aug 4, 2014}}&lt;/ref&gt; Imizamo yona iyenziwa bona kutholakalle [[intatha/isihlahla]] esingalapha ubulwelwe lobu, kodwana okwanje asikho kwatholakala ipengu yakhona.&lt;ref name=WHO2014/&gt;

== Isikhombiso selwazi==
{{Reflist|colwidth=25em}}

; IBhibhliyografu
{{Refbegin}}
* {{Cite book |last=Klenk |first=Hans-Dieter |title=Marburg and Ebola Viruses (Current Topics in Microbiology and Immunology) |date=January 1999 |publisher=Springer-Verlag Telos |location=Berlin |isbn=978-3-540-64729-4 |ref=CITEREFKlenk1999}}
* {{Cite book |first1=Hans-Dieter |last1=Klenk |first2=Heinz |last2=Feldmann |title=Ebola and Marburg viruses: molecular and cellular biology |url=https://books.google.com/books?id=EV_mFgnyPoMC&amp;redir_esc=y&amp;hl=en|format=Limited preview |year=2004 |publisher=Horizon Bioscience |location=Wymondham, Norfolk, UK |isbn=978-0-9545232-3-7 |ref=CITEREFKlenkFeldmann2004}}
* {{Cite book |last=Kuhn |first=Jens H. |title=Filoviruses: A Compendium of 40 Years of Epidemiological, Clinical, and Laboratory Studies. Archives of Virology Supplement, vol. 20 |url=http://books.google.com/?id=LaOue0F9Ns4C |format=Limited preview |year=2008 |publisher=SpringerWienNewYork |location=Vienna |isbn=978-3-211-20670-6 |ref=CITEREFKuhn2008}}
* {{Cite book |last1=McCormick |first1=Joseph |last2=Fisher-Hoch |first2=Susan |others=Horvitz, Leslie Alan |title=Level 4: Virus Hunters of the CDC |url=http://books.google.com/?id=QEvR3aJX2m0C |format=Limited preview |origyear=1996 |edition=Updated [3rd] |year=1999 |publisher=Barnes &amp; Noble |isbn=978-0-7607-1208-5 |ref=CITEREFMcCormickFisher-Hoch1999 |month=June}}
* {{Cite book |last=Pattyn |first=S. R. |title=Ebola Virus Haemorrhagic Fever |year=1978 |url=http://www.itg.be/ebola/ |format=Full free text |edition=1st |publisher=Elsevier/North-Holland Biomedical Press |location=Amsterdam |isbn=0-444-80060-3 |ref=CITEREFPattyn1978}}
* {{Cite book | last1 = Ryabchikova | first1 = Elena I. | last2 = Price | first2 = Barbara B. | title = Ebola and Marburg Viruses: A View of Infection Using Electron Microscopy | year = 2004 | publisher = Battelle Press | location = Columbus, Ohio | isbn = 978-1-57477-131-2 | ref = CITEREFRyabchikovaPrice2004 }}
{{Refend}}

==Okuhlanganiswe nalokhu okunye==
{{Refbegin}}
* [http://viralzone.expasy.org/all_by_species/207.html ViralZone: Ebola-like viruses] – Virological repository from the [[Swiss Institute of Bioinformatics]]
* [http://www.cdc.gov/vhf/ebola/ CDC: Ebola hemorrhagic fever] – Centers for Disease Control and Prevention, Special Pathogens Branch
* [http://www.who.int/csr/disease/ebola/en/ WHO: Ebola haemorrhagic fever] – World Health Organization, Global Alert and Response
* [http://www.viprbrc.org/brc/home.do?decorator=filo Virus Pathogen Database and Analysis Resource (ViPR): Filoviridae]
* [https://web.archive.org/web/20140808072117/http://www.ebi.ac.uk/pdbe/emdb/searchResults.html/?q=ebola 3D macromolecular structures of the Ebola virus archived in the EM Data Bank(EMDB)]
* [https://web.archive.org/web/20140819171607/https://maps.google.com/maps/ms?msa=0&amp;msid=202977755949863934429.0004c658eb30f9c4fb1c0&amp;ie=UTF8&amp;t=h&amp;ll=27.371767,5.273438&amp;spn=110.017392,184.21875&amp;z=2&amp;source=embed&amp;dg=feature Google Map of Ebola Outbreaks]
* [https://web.archive.org/web/20140816223245/http://www.who.int/csr/bioriskreduction/filovirus_infection_control/en/ WHO recommended infection control measures]
{{Refend}}</text>
      <sha1>hl7wjmdft21vpbf6mhqjokxb8f9yh4f</sha1>
    </revision>
    <revision>
      <id>2191</id>
      <parentid>2190</parentid>
      <timestamp>2024-11-28T20:05:49Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>books.google.com</comment>
      <origin>2191</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9704" sha1="ps8vnb8a92yd7s8htq1fcmx5beg49zb" xml:space="preserve">{{Infobox disease
| name           = Ubulwelwe be-Ebola
| image          = 7042 lores-Ebola-Zaire-CDC Photo.jpg
| caption        = Isithombe sango-1976 sabahlengikazi ababili, bajame hlanu kwaka [[Mayinga N'Seka|Mayinga N.]], omumuntu osahlelwe mumulwana we-Ebola. Wahlongakala ngemva kwamalanga ambalwa ngonobangela wobulwelwe bokopha nokurhadza kweengazi.
| DiseasesDB     = 18043
| ICD10          = {{ICD10|A|98|4|a|90}}
| ICD9           = {{ICD9|065.8}}
| MedlinePlus    = 001339
| eMedicineSubj  = med
| eMedicineTopic = 626
| MeshID         = D019142
}}
'''Ubulwelwe be-Ebola''' nofana ('''EVD''') '''[[Wp/kri/Ebola|I-Ebola]] nomulwana wokopha iingazi okhambisana nomgomani''' ('''EHF''') mimulwana ebangwa bulwelwe bevayirasi ebizwa nge- [[Ebola]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo athoma ukubonakala phakathi kwamalanga amabili ukuya eemvekeni eentathu ngemva sewungenwe bulwelwe lobu, [[njengomgomani ongapheliko]], umphimbo obabako onesilonda, [[imisipha ebuhlungu kanye nehloko esawula kabuhlungu]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kesinye isikhathi [[ungahlanza]], uphakanyelwe ziimbindi nesifo  [[sokurhuda]], kuzokwenza bona [[amaphaphu]] kanye [[neso]] zingasasebenzi kuhle.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Nasele sekufike lapha, abanye baba nomraro [[wokopha iingazi]].&lt;ref name=WHO2014&gt;{{Cite web|title=Ebola virus disease Fact sheet N°103|url=https://www.who.int/en/news-room/fact-sheets/detail/ebola-virus-disease|work=World Health Organization|accessdate=12 April 2014|date=March 2014}}&lt;/ref&gt;

&lt;!-- Cause and Diagnosis--&gt;
Umulwana lo ungangena nawuthintana [[neengazi]] zomuntu ophethwe ngibo nofana [[umjuluko]] nanyana [[okunye nokunye okusamanzana]] okuvela (eenlwaneni [[kumaphelaphelana]] nofana iimfene).&lt;ref name=WHO2014/&gt; Bekube nje umulwana akukatholakali bona ungangena ngokuwurhogela emmoyeni.&lt;ref name=WHOAir2014&gt;{{Cite web|title=2014 Ebola Virus Disease (EVD) outbreak in West Africa|url=http://www.who.int/ith/updates/20140421/en/|website=WHO|accessdate=3 August 2014|date=Apr 21 2014}}&lt;/ref&gt; Kukholelwa bonyana abomaphelaphelani bakwazi  ukuphatha umulwana lo kodwana wona angaphathwa ngiwo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kwaba khona umuntu otheleleke ngomulwana lo, umulwana lo ungatheleleka kabanye abantu godu ngesikhathi esifitjhani.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amadoda angasinda ngemva kokulatjhwa angathelela abanye abantu ngokuthunda [[imbewu]] yabo lokha nabaya emsemeni nakungakapheli iinyanga ezimbili.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nakufanele uhlahlutjwe nofana uhlolelwe ubulwelwe lobu be-ebola kufanele izifo ezifana [[nomalalahlengezela]], [[isifo sokurhuda]] kanye omulwana [[wokopha iingazi okhambisana nomgomani]]  inganakwa ukwenzelela ukuthola imiphumela ekungiyo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ukuqinisekisa umrabho womraro wobulwelwe lobu amasampula weengazi ayathathwa ayokuhlolelwa ubulwelwe [[nesivikelasifo seengazini]] kanye ne [[i-RNA]] lobu kanye nengongwana ebanga ubulwelwe lobu.&lt;ref name=WHO2014/&gt;

&lt;!-- Prevention --&gt;
Ukuvikela ubulwelwe lobu kungaphungulwa ukuthelelana hlangana neemfene kanye neemfarigi ezingenwe bulwelwelwe lobu bukhandelwe bona bungayi ebantwini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kungenziwa ngokobana kuhlolwe iinlwana lezi ukobana zinabo ubulwelwe lobu na, nakutholakala bona zinabo kungenzeka bona zibulawe bese kugujelwa imizimba yazo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nawupheka inyama bese wembatha izambatho zokuzivikela nakho kungakusiza,&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; ukwembatha izambatho zokuzivikela lokha nawuhlala nofana uhlanu kwaloyo muntu ongenwe mumulwana lowo [[kanye nokuhlamba izandla ngesibha]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amasampula wananyana yini esamanzana yalabo bantu abangenwe mumulwana lo kufanele zitjhejwe khulu, ubalekele ukuthintana nazo.&lt;ref name=WHO2014/&gt;

&lt;!-- Treatment, Prognosis and Epidemiology--&gt;
Ayikho intatha elapha ubulwelwe lobu; imizamo yokobana kusizwe abantu abangenwe bulwelwe lobu kukobana [[kwenziwe umtswako]] (banikelwe amanzi anetswayi) ukobana bawasele nofana [[bafakwe amadribhu azobangenisela okusamanzana emzimbeni wabo]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu [[buneembalobalo eziphezulu zabantu abafako]]: nabangenwe ngibo ubulwelwe lobu, i-ebola ingabulala pheze isiquntu-50% nofana i-90% yabantu abatheleleke ngayo.&lt;ref name=WHO2014/&gt;&lt;ref name=&quot;Elsevier/Academic Press&quot;&gt;{{Cite book|author1=C.M. Fauquet|title=Virus taxonomy classification and nomenclature of viruses; 8th report of the International Committee on Taxonomy of Viruses|date=2005|publisher=Elsevier/Academic Press|location=Oxford|isbn=9780080575483|page=648|url=http://books.google.ca/books?id=9Wy7Jgy5RWYC&amp;pg=PA648}}&lt;/ref&gt; I-EVD yathoma ukwazakala endaweni enarheni ye [[Sudan]] kanye ne- [[Democratic Republic of Congo]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu butholakala khulu eenarheni zethrophigi zenarhakazi yeAfrika [[Iphakathi le-Sehara ye-Afrika]].&lt;ref name=WHO2014/&gt; Ngo-1976 (ukutholakala kwabo ubulwelwe lobu] ukufikela ngo-2013, besele ingene yatheleleka ebantwini abangaphasii kwe-1000.&lt;ref name=WHO2014/&gt;&lt;ref name=MMWRJune2014&gt;{{Cite web|title=Ebola Viral Disease Outbreak — West Africa, 2014|url=https://www.cdc.gov/mmwr/preview/mmwrhtml/mm6325a4.htm?s_cid=mm6325a4_w|website=CDC|accessdate=26 June 2014|date=June 27, 2014}}&lt;/ref&gt; Ukuqubuka kobulwelwe lobu obukhulu obungazange khebubonwe ngilobu bamuva nje ngebe [[2014  Tjhingalanga ye-Afrika Ukuqubuka kwe-Ebola]], sebele bungene eenarheni [[Guinea]], [[Sierra Leone]], [[Liberia]] begodu ingatheleka ingene ne [[Nigeria]].&lt;ref name=CDC2014&gt;{{Cite web|title=CDC urges all US residents to avoid nonessential travel to Liberia, Guinea, and Sierra Leone because of an unprecedented outbreak of Ebola.|url=https://wwwnc.cdc.gov/travel/notices/level1/ebola-liberia|website=CDC|accessdate=2 August 2014|date=July 31, 2014}}&lt;/ref&gt;&lt;ref name=CDCAug2014N&gt;{{Cite web|title=Outbreak of Ebola in Guinea, Liberia, and Sierra Leone|url=http://www.cdc.gov/vhf/ebola/outbreaks/guinea/index.html|website=CDC|accessdate=5 August 2014|date=August 4, 2014}}&lt;/ref&gt; Ukusukela ngoRhoboyi 2014 sele kubikwe bona kunabantu esele bangenwe bulwelwe lobu abayi-1600.&lt;ref&gt;{{Cite web|title=Ebola virus disease update - West Africa|url=http://www.who.int/csr/don/2014_08_04_ebola/en/|website=WHO|accessdate=6 August 2014|date=Aug 4, 2014}}&lt;/ref&gt; Imizamo yona iyenziwa bona kutholakalle [[intatha/isihlahla]] esingalapha ubulwelwe lobu, kodwana okwanje asikho kwatholakala ipengu yakhona.&lt;ref name=WHO2014/&gt;

== Isikhombiso selwazi==
{{Reflist|colwidth=25em}}

; IBhibhliyografu
{{Refbegin}}
* {{Cite book |last=Klenk |first=Hans-Dieter |title=Marburg and Ebola Viruses (Current Topics in Microbiology and Immunology) |date=January 1999 |publisher=Springer-Verlag Telos |location=Berlin |isbn=978-3-540-64729-4 |ref=CITEREFKlenk1999}}
* {{Cite book |first1=Hans-Dieter |last1=Klenk |first2=Heinz |last2=Feldmann |title=Ebola and Marburg viruses: molecular and cellular biology |url=https://books.google.com/books?id=EV_mFgnyPoMC&amp;redir_esc=y&amp;hl=en|format=Limited preview |year=2004 |publisher=Horizon Bioscience |location=Wymondham, Norfolk, UK |isbn=978-0-9545232-3-7 |ref=CITEREFKlenkFeldmann2004}}
* {{Cite book |last=Kuhn |first=Jens H. |title=Filoviruses: A Compendium of 40 Years of Epidemiological, Clinical, and Laboratory Studies. Archives of Virology Supplement, vol. 20 |url=https://books.google.com/books?id=LaOue0F9Ns4C&amp;redir_esc=y&amp;hl=en |format=Limited preview |year=2008 |publisher=SpringerWienNewYork |location=Vienna |isbn=978-3-211-20670-6 |ref=CITEREFKuhn2008}}
* {{Cite book |last1=McCormick |first1=Joseph |last2=Fisher-Hoch |first2=Susan |others=Horvitz, Leslie Alan |title=Level 4: Virus Hunters of the CDC |url=http://books.google.com/?id=QEvR3aJX2m0C |format=Limited preview |origyear=1996 |edition=Updated [3rd] |year=1999 |publisher=Barnes &amp; Noble |isbn=978-0-7607-1208-5 |ref=CITEREFMcCormickFisher-Hoch1999 |month=June}}
* {{Cite book |last=Pattyn |first=S. R. |title=Ebola Virus Haemorrhagic Fever |year=1978 |url=http://www.itg.be/ebola/ |format=Full free text |edition=1st |publisher=Elsevier/North-Holland Biomedical Press |location=Amsterdam |isbn=0-444-80060-3 |ref=CITEREFPattyn1978}}
* {{Cite book | last1 = Ryabchikova | first1 = Elena I. | last2 = Price | first2 = Barbara B. | title = Ebola and Marburg Viruses: A View of Infection Using Electron Microscopy | year = 2004 | publisher = Battelle Press | location = Columbus, Ohio | isbn = 978-1-57477-131-2 | ref = CITEREFRyabchikovaPrice2004 }}
{{Refend}}

==Okuhlanganiswe nalokhu okunye==
{{Refbegin}}
* [http://viralzone.expasy.org/all_by_species/207.html ViralZone: Ebola-like viruses] – Virological repository from the [[Swiss Institute of Bioinformatics]]
* [http://www.cdc.gov/vhf/ebola/ CDC: Ebola hemorrhagic fever] – Centers for Disease Control and Prevention, Special Pathogens Branch
* [http://www.who.int/csr/disease/ebola/en/ WHO: Ebola haemorrhagic fever] – World Health Organization, Global Alert and Response
* [http://www.viprbrc.org/brc/home.do?decorator=filo Virus Pathogen Database and Analysis Resource (ViPR): Filoviridae]
* [https://web.archive.org/web/20140808072117/http://www.ebi.ac.uk/pdbe/emdb/searchResults.html/?q=ebola 3D macromolecular structures of the Ebola virus archived in the EM Data Bank(EMDB)]
* [https://web.archive.org/web/20140819171607/https://maps.google.com/maps/ms?msa=0&amp;msid=202977755949863934429.0004c658eb30f9c4fb1c0&amp;ie=UTF8&amp;t=h&amp;ll=27.371767,5.273438&amp;spn=110.017392,184.21875&amp;z=2&amp;source=embed&amp;dg=feature Google Map of Ebola Outbreaks]
* [https://web.archive.org/web/20140816223245/http://www.who.int/csr/bioriskreduction/filovirus_infection_control/en/ WHO recommended infection control measures]
{{Refend}}</text>
      <sha1>ps8vnb8a92yd7s8htq1fcmx5beg49zb</sha1>
    </revision>
    <revision>
      <id>2192</id>
      <parentid>2191</parentid>
      <timestamp>2024-11-28T20:06:44Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>books.google.com</comment>
      <origin>2192</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9728" sha1="b2gsujrvr83muehbkygefwpj1ipvud7" xml:space="preserve">{{Infobox disease
| name           = Ubulwelwe be-Ebola
| image          = 7042 lores-Ebola-Zaire-CDC Photo.jpg
| caption        = Isithombe sango-1976 sabahlengikazi ababili, bajame hlanu kwaka [[Mayinga N'Seka|Mayinga N.]], omumuntu osahlelwe mumulwana we-Ebola. Wahlongakala ngemva kwamalanga ambalwa ngonobangela wobulwelwe bokopha nokurhadza kweengazi.
| DiseasesDB     = 18043
| ICD10          = {{ICD10|A|98|4|a|90}}
| ICD9           = {{ICD9|065.8}}
| MedlinePlus    = 001339
| eMedicineSubj  = med
| eMedicineTopic = 626
| MeshID         = D019142
}}
'''Ubulwelwe be-Ebola''' nofana ('''EVD''') '''[[Wp/kri/Ebola|I-Ebola]] nomulwana wokopha iingazi okhambisana nomgomani''' ('''EHF''') mimulwana ebangwa bulwelwe bevayirasi ebizwa nge- [[Ebola]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo athoma ukubonakala phakathi kwamalanga amabili ukuya eemvekeni eentathu ngemva sewungenwe bulwelwe lobu, [[njengomgomani ongapheliko]], umphimbo obabako onesilonda, [[imisipha ebuhlungu kanye nehloko esawula kabuhlungu]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kesinye isikhathi [[ungahlanza]], uphakanyelwe ziimbindi nesifo  [[sokurhuda]], kuzokwenza bona [[amaphaphu]] kanye [[neso]] zingasasebenzi kuhle.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Nasele sekufike lapha, abanye baba nomraro [[wokopha iingazi]].&lt;ref name=WHO2014&gt;{{Cite web|title=Ebola virus disease Fact sheet N°103|url=https://www.who.int/en/news-room/fact-sheets/detail/ebola-virus-disease|work=World Health Organization|accessdate=12 April 2014|date=March 2014}}&lt;/ref&gt;

&lt;!-- Cause and Diagnosis--&gt;
Umulwana lo ungangena nawuthintana [[neengazi]] zomuntu ophethwe ngibo nofana [[umjuluko]] nanyana [[okunye nokunye okusamanzana]] okuvela (eenlwaneni [[kumaphelaphelana]] nofana iimfene).&lt;ref name=WHO2014/&gt; Bekube nje umulwana akukatholakali bona ungangena ngokuwurhogela emmoyeni.&lt;ref name=WHOAir2014&gt;{{Cite web|title=2014 Ebola Virus Disease (EVD) outbreak in West Africa|url=http://www.who.int/ith/updates/20140421/en/|website=WHO|accessdate=3 August 2014|date=Apr 21 2014}}&lt;/ref&gt; Kukholelwa bonyana abomaphelaphelani bakwazi  ukuphatha umulwana lo kodwana wona angaphathwa ngiwo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kwaba khona umuntu otheleleke ngomulwana lo, umulwana lo ungatheleleka kabanye abantu godu ngesikhathi esifitjhani.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amadoda angasinda ngemva kokulatjhwa angathelela abanye abantu ngokuthunda [[imbewu]] yabo lokha nabaya emsemeni nakungakapheli iinyanga ezimbili.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nakufanele uhlahlutjwe nofana uhlolelwe ubulwelwe lobu be-ebola kufanele izifo ezifana [[nomalalahlengezela]], [[isifo sokurhuda]] kanye omulwana [[wokopha iingazi okhambisana nomgomani]]  inganakwa ukwenzelela ukuthola imiphumela ekungiyo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ukuqinisekisa umrabho womraro wobulwelwe lobu amasampula weengazi ayathathwa ayokuhlolelwa ubulwelwe [[nesivikelasifo seengazini]] kanye ne [[i-RNA]] lobu kanye nengongwana ebanga ubulwelwe lobu.&lt;ref name=WHO2014/&gt;

&lt;!-- Prevention --&gt;
Ukuvikela ubulwelwe lobu kungaphungulwa ukuthelelana hlangana neemfene kanye neemfarigi ezingenwe bulwelwelwe lobu bukhandelwe bona bungayi ebantwini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kungenziwa ngokobana kuhlolwe iinlwana lezi ukobana zinabo ubulwelwe lobu na, nakutholakala bona zinabo kungenzeka bona zibulawe bese kugujelwa imizimba yazo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nawupheka inyama bese wembatha izambatho zokuzivikela nakho kungakusiza,&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; ukwembatha izambatho zokuzivikela lokha nawuhlala nofana uhlanu kwaloyo muntu ongenwe mumulwana lowo [[kanye nokuhlamba izandla ngesibha]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amasampula wananyana yini esamanzana yalabo bantu abangenwe mumulwana lo kufanele zitjhejwe khulu, ubalekele ukuthintana nazo.&lt;ref name=WHO2014/&gt;

&lt;!-- Treatment, Prognosis and Epidemiology--&gt;
Ayikho intatha elapha ubulwelwe lobu; imizamo yokobana kusizwe abantu abangenwe bulwelwe lobu kukobana [[kwenziwe umtswako]] (banikelwe amanzi anetswayi) ukobana bawasele nofana [[bafakwe amadribhu azobangenisela okusamanzana emzimbeni wabo]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu [[buneembalobalo eziphezulu zabantu abafako]]: nabangenwe ngibo ubulwelwe lobu, i-ebola ingabulala pheze isiquntu-50% nofana i-90% yabantu abatheleleke ngayo.&lt;ref name=WHO2014/&gt;&lt;ref name=&quot;Elsevier/Academic Press&quot;&gt;{{Cite book|author1=C.M. Fauquet|title=Virus taxonomy classification and nomenclature of viruses; 8th report of the International Committee on Taxonomy of Viruses|date=2005|publisher=Elsevier/Academic Press|location=Oxford|isbn=9780080575483|page=648|url=http://books.google.ca/books?id=9Wy7Jgy5RWYC&amp;pg=PA648}}&lt;/ref&gt; I-EVD yathoma ukwazakala endaweni enarheni ye [[Sudan]] kanye ne- [[Democratic Republic of Congo]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu butholakala khulu eenarheni zethrophigi zenarhakazi yeAfrika [[Iphakathi le-Sehara ye-Afrika]].&lt;ref name=WHO2014/&gt; Ngo-1976 (ukutholakala kwabo ubulwelwe lobu] ukufikela ngo-2013, besele ingene yatheleleka ebantwini abangaphasii kwe-1000.&lt;ref name=WHO2014/&gt;&lt;ref name=MMWRJune2014&gt;{{Cite web|title=Ebola Viral Disease Outbreak — West Africa, 2014|url=https://www.cdc.gov/mmwr/preview/mmwrhtml/mm6325a4.htm?s_cid=mm6325a4_w|website=CDC|accessdate=26 June 2014|date=June 27, 2014}}&lt;/ref&gt; Ukuqubuka kobulwelwe lobu obukhulu obungazange khebubonwe ngilobu bamuva nje ngebe [[2014  Tjhingalanga ye-Afrika Ukuqubuka kwe-Ebola]], sebele bungene eenarheni [[Guinea]], [[Sierra Leone]], [[Liberia]] begodu ingatheleka ingene ne [[Nigeria]].&lt;ref name=CDC2014&gt;{{Cite web|title=CDC urges all US residents to avoid nonessential travel to Liberia, Guinea, and Sierra Leone because of an unprecedented outbreak of Ebola.|url=https://wwwnc.cdc.gov/travel/notices/level1/ebola-liberia|website=CDC|accessdate=2 August 2014|date=July 31, 2014}}&lt;/ref&gt;&lt;ref name=CDCAug2014N&gt;{{Cite web|title=Outbreak of Ebola in Guinea, Liberia, and Sierra Leone|url=http://www.cdc.gov/vhf/ebola/outbreaks/guinea/index.html|website=CDC|accessdate=5 August 2014|date=August 4, 2014}}&lt;/ref&gt; Ukusukela ngoRhoboyi 2014 sele kubikwe bona kunabantu esele bangenwe bulwelwe lobu abayi-1600.&lt;ref&gt;{{Cite web|title=Ebola virus disease update - West Africa|url=http://www.who.int/csr/don/2014_08_04_ebola/en/|website=WHO|accessdate=6 August 2014|date=Aug 4, 2014}}&lt;/ref&gt; Imizamo yona iyenziwa bona kutholakalle [[intatha/isihlahla]] esingalapha ubulwelwe lobu, kodwana okwanje asikho kwatholakala ipengu yakhona.&lt;ref name=WHO2014/&gt;

== Isikhombiso selwazi==
{{Reflist|colwidth=25em}}

; IBhibhliyografu
{{Refbegin}}
* {{Cite book |last=Klenk |first=Hans-Dieter |title=Marburg and Ebola Viruses (Current Topics in Microbiology and Immunology) |date=January 1999 |publisher=Springer-Verlag Telos |location=Berlin |isbn=978-3-540-64729-4 |ref=CITEREFKlenk1999}}
* {{Cite book |first1=Hans-Dieter |last1=Klenk |first2=Heinz |last2=Feldmann |title=Ebola and Marburg viruses: molecular and cellular biology |url=https://books.google.com/books?id=EV_mFgnyPoMC&amp;redir_esc=y&amp;hl=en|format=Limited preview |year=2004 |publisher=Horizon Bioscience |location=Wymondham, Norfolk, UK |isbn=978-0-9545232-3-7 |ref=CITEREFKlenkFeldmann2004}}
* {{Cite book |last=Kuhn |first=Jens H. |title=Filoviruses: A Compendium of 40 Years of Epidemiological, Clinical, and Laboratory Studies. Archives of Virology Supplement, vol. 20 |url=https://books.google.com/books?id=LaOue0F9Ns4C&amp;redir_esc=y&amp;hl=en |format=Limited preview |year=2008 |publisher=SpringerWienNewYork |location=Vienna |isbn=978-3-211-20670-6 |ref=CITEREFKuhn2008}}
* {{Cite book |last1=McCormick |first1=Joseph |last2=Fisher-Hoch |first2=Susan |others=Horvitz, Leslie Alan |title=Level 4: Virus Hunters of the CDC |url=https://books.google.com/books?id=QEvR3aJX2m0C&amp;redir_esc=y&amp;hl=en |format=Limited preview |origyear=1996 |edition=Updated [3rd] |year=1999 |publisher=Barnes &amp; Noble |isbn=978-0-7607-1208-5 |ref=CITEREFMcCormickFisher-Hoch1999 |month=June}}
* {{Cite book |last=Pattyn |first=S. R. |title=Ebola Virus Haemorrhagic Fever |year=1978 |url=http://www.itg.be/ebola/ |format=Full free text |edition=1st |publisher=Elsevier/North-Holland Biomedical Press |location=Amsterdam |isbn=0-444-80060-3 |ref=CITEREFPattyn1978}}
* {{Cite book | last1 = Ryabchikova | first1 = Elena I. | last2 = Price | first2 = Barbara B. | title = Ebola and Marburg Viruses: A View of Infection Using Electron Microscopy | year = 2004 | publisher = Battelle Press | location = Columbus, Ohio | isbn = 978-1-57477-131-2 | ref = CITEREFRyabchikovaPrice2004 }}
{{Refend}}

==Okuhlanganiswe nalokhu okunye==
{{Refbegin}}
* [http://viralzone.expasy.org/all_by_species/207.html ViralZone: Ebola-like viruses] – Virological repository from the [[Swiss Institute of Bioinformatics]]
* [http://www.cdc.gov/vhf/ebola/ CDC: Ebola hemorrhagic fever] – Centers for Disease Control and Prevention, Special Pathogens Branch
* [http://www.who.int/csr/disease/ebola/en/ WHO: Ebola haemorrhagic fever] – World Health Organization, Global Alert and Response
* [http://www.viprbrc.org/brc/home.do?decorator=filo Virus Pathogen Database and Analysis Resource (ViPR): Filoviridae]
* [https://web.archive.org/web/20140808072117/http://www.ebi.ac.uk/pdbe/emdb/searchResults.html/?q=ebola 3D macromolecular structures of the Ebola virus archived in the EM Data Bank(EMDB)]
* [https://web.archive.org/web/20140819171607/https://maps.google.com/maps/ms?msa=0&amp;msid=202977755949863934429.0004c658eb30f9c4fb1c0&amp;ie=UTF8&amp;t=h&amp;ll=27.371767,5.273438&amp;spn=110.017392,184.21875&amp;z=2&amp;source=embed&amp;dg=feature Google Map of Ebola Outbreaks]
* [https://web.archive.org/web/20140816223245/http://www.who.int/csr/bioriskreduction/filovirus_infection_control/en/ WHO recommended infection control measures]
{{Refend}}</text>
      <sha1>b2gsujrvr83muehbkygefwpj1ipvud7</sha1>
    </revision>
    <revision>
      <id>2193</id>
      <parentid>2192</parentid>
      <timestamp>2024-11-28T20:08:09Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* Okuhlanganiswe nalokhu okunye */viralzone.expasy.org</comment>
      <origin>2193</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9737" sha1="n47b5sm9bj5oxv644rfnhhci6fvvyfi" xml:space="preserve">{{Infobox disease
| name           = Ubulwelwe be-Ebola
| image          = 7042 lores-Ebola-Zaire-CDC Photo.jpg
| caption        = Isithombe sango-1976 sabahlengikazi ababili, bajame hlanu kwaka [[Mayinga N'Seka|Mayinga N.]], omumuntu osahlelwe mumulwana we-Ebola. Wahlongakala ngemva kwamalanga ambalwa ngonobangela wobulwelwe bokopha nokurhadza kweengazi.
| DiseasesDB     = 18043
| ICD10          = {{ICD10|A|98|4|a|90}}
| ICD9           = {{ICD9|065.8}}
| MedlinePlus    = 001339
| eMedicineSubj  = med
| eMedicineTopic = 626
| MeshID         = D019142
}}
'''Ubulwelwe be-Ebola''' nofana ('''EVD''') '''[[Wp/kri/Ebola|I-Ebola]] nomulwana wokopha iingazi okhambisana nomgomani''' ('''EHF''') mimulwana ebangwa bulwelwe bevayirasi ebizwa nge- [[Ebola]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo athoma ukubonakala phakathi kwamalanga amabili ukuya eemvekeni eentathu ngemva sewungenwe bulwelwe lobu, [[njengomgomani ongapheliko]], umphimbo obabako onesilonda, [[imisipha ebuhlungu kanye nehloko esawula kabuhlungu]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kesinye isikhathi [[ungahlanza]], uphakanyelwe ziimbindi nesifo  [[sokurhuda]], kuzokwenza bona [[amaphaphu]] kanye [[neso]] zingasasebenzi kuhle.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Nasele sekufike lapha, abanye baba nomraro [[wokopha iingazi]].&lt;ref name=WHO2014&gt;{{Cite web|title=Ebola virus disease Fact sheet N°103|url=https://www.who.int/en/news-room/fact-sheets/detail/ebola-virus-disease|work=World Health Organization|accessdate=12 April 2014|date=March 2014}}&lt;/ref&gt;

&lt;!-- Cause and Diagnosis--&gt;
Umulwana lo ungangena nawuthintana [[neengazi]] zomuntu ophethwe ngibo nofana [[umjuluko]] nanyana [[okunye nokunye okusamanzana]] okuvela (eenlwaneni [[kumaphelaphelana]] nofana iimfene).&lt;ref name=WHO2014/&gt; Bekube nje umulwana akukatholakali bona ungangena ngokuwurhogela emmoyeni.&lt;ref name=WHOAir2014&gt;{{Cite web|title=2014 Ebola Virus Disease (EVD) outbreak in West Africa|url=http://www.who.int/ith/updates/20140421/en/|website=WHO|accessdate=3 August 2014|date=Apr 21 2014}}&lt;/ref&gt; Kukholelwa bonyana abomaphelaphelani bakwazi  ukuphatha umulwana lo kodwana wona angaphathwa ngiwo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kwaba khona umuntu otheleleke ngomulwana lo, umulwana lo ungatheleleka kabanye abantu godu ngesikhathi esifitjhani.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amadoda angasinda ngemva kokulatjhwa angathelela abanye abantu ngokuthunda [[imbewu]] yabo lokha nabaya emsemeni nakungakapheli iinyanga ezimbili.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nakufanele uhlahlutjwe nofana uhlolelwe ubulwelwe lobu be-ebola kufanele izifo ezifana [[nomalalahlengezela]], [[isifo sokurhuda]] kanye omulwana [[wokopha iingazi okhambisana nomgomani]]  inganakwa ukwenzelela ukuthola imiphumela ekungiyo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ukuqinisekisa umrabho womraro wobulwelwe lobu amasampula weengazi ayathathwa ayokuhlolelwa ubulwelwe [[nesivikelasifo seengazini]] kanye ne [[i-RNA]] lobu kanye nengongwana ebanga ubulwelwe lobu.&lt;ref name=WHO2014/&gt;

&lt;!-- Prevention --&gt;
Ukuvikela ubulwelwe lobu kungaphungulwa ukuthelelana hlangana neemfene kanye neemfarigi ezingenwe bulwelwelwe lobu bukhandelwe bona bungayi ebantwini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kungenziwa ngokobana kuhlolwe iinlwana lezi ukobana zinabo ubulwelwe lobu na, nakutholakala bona zinabo kungenzeka bona zibulawe bese kugujelwa imizimba yazo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nawupheka inyama bese wembatha izambatho zokuzivikela nakho kungakusiza,&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; ukwembatha izambatho zokuzivikela lokha nawuhlala nofana uhlanu kwaloyo muntu ongenwe mumulwana lowo [[kanye nokuhlamba izandla ngesibha]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amasampula wananyana yini esamanzana yalabo bantu abangenwe mumulwana lo kufanele zitjhejwe khulu, ubalekele ukuthintana nazo.&lt;ref name=WHO2014/&gt;

&lt;!-- Treatment, Prognosis and Epidemiology--&gt;
Ayikho intatha elapha ubulwelwe lobu; imizamo yokobana kusizwe abantu abangenwe bulwelwe lobu kukobana [[kwenziwe umtswako]] (banikelwe amanzi anetswayi) ukobana bawasele nofana [[bafakwe amadribhu azobangenisela okusamanzana emzimbeni wabo]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu [[buneembalobalo eziphezulu zabantu abafako]]: nabangenwe ngibo ubulwelwe lobu, i-ebola ingabulala pheze isiquntu-50% nofana i-90% yabantu abatheleleke ngayo.&lt;ref name=WHO2014/&gt;&lt;ref name=&quot;Elsevier/Academic Press&quot;&gt;{{Cite book|author1=C.M. Fauquet|title=Virus taxonomy classification and nomenclature of viruses; 8th report of the International Committee on Taxonomy of Viruses|date=2005|publisher=Elsevier/Academic Press|location=Oxford|isbn=9780080575483|page=648|url=http://books.google.ca/books?id=9Wy7Jgy5RWYC&amp;pg=PA648}}&lt;/ref&gt; I-EVD yathoma ukwazakala endaweni enarheni ye [[Sudan]] kanye ne- [[Democratic Republic of Congo]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu butholakala khulu eenarheni zethrophigi zenarhakazi yeAfrika [[Iphakathi le-Sehara ye-Afrika]].&lt;ref name=WHO2014/&gt; Ngo-1976 (ukutholakala kwabo ubulwelwe lobu] ukufikela ngo-2013, besele ingene yatheleleka ebantwini abangaphasii kwe-1000.&lt;ref name=WHO2014/&gt;&lt;ref name=MMWRJune2014&gt;{{Cite web|title=Ebola Viral Disease Outbreak — West Africa, 2014|url=https://www.cdc.gov/mmwr/preview/mmwrhtml/mm6325a4.htm?s_cid=mm6325a4_w|website=CDC|accessdate=26 June 2014|date=June 27, 2014}}&lt;/ref&gt; Ukuqubuka kobulwelwe lobu obukhulu obungazange khebubonwe ngilobu bamuva nje ngebe [[2014  Tjhingalanga ye-Afrika Ukuqubuka kwe-Ebola]], sebele bungene eenarheni [[Guinea]], [[Sierra Leone]], [[Liberia]] begodu ingatheleka ingene ne [[Nigeria]].&lt;ref name=CDC2014&gt;{{Cite web|title=CDC urges all US residents to avoid nonessential travel to Liberia, Guinea, and Sierra Leone because of an unprecedented outbreak of Ebola.|url=https://wwwnc.cdc.gov/travel/notices/level1/ebola-liberia|website=CDC|accessdate=2 August 2014|date=July 31, 2014}}&lt;/ref&gt;&lt;ref name=CDCAug2014N&gt;{{Cite web|title=Outbreak of Ebola in Guinea, Liberia, and Sierra Leone|url=http://www.cdc.gov/vhf/ebola/outbreaks/guinea/index.html|website=CDC|accessdate=5 August 2014|date=August 4, 2014}}&lt;/ref&gt; Ukusukela ngoRhoboyi 2014 sele kubikwe bona kunabantu esele bangenwe bulwelwe lobu abayi-1600.&lt;ref&gt;{{Cite web|title=Ebola virus disease update - West Africa|url=http://www.who.int/csr/don/2014_08_04_ebola/en/|website=WHO|accessdate=6 August 2014|date=Aug 4, 2014}}&lt;/ref&gt; Imizamo yona iyenziwa bona kutholakalle [[intatha/isihlahla]] esingalapha ubulwelwe lobu, kodwana okwanje asikho kwatholakala ipengu yakhona.&lt;ref name=WHO2014/&gt;

== Isikhombiso selwazi==
{{Reflist|colwidth=25em}}

; IBhibhliyografu
{{Refbegin}}
* {{Cite book |last=Klenk |first=Hans-Dieter |title=Marburg and Ebola Viruses (Current Topics in Microbiology and Immunology) |date=January 1999 |publisher=Springer-Verlag Telos |location=Berlin |isbn=978-3-540-64729-4 |ref=CITEREFKlenk1999}}
* {{Cite book |first1=Hans-Dieter |last1=Klenk |first2=Heinz |last2=Feldmann |title=Ebola and Marburg viruses: molecular and cellular biology |url=https://books.google.com/books?id=EV_mFgnyPoMC&amp;redir_esc=y&amp;hl=en|format=Limited preview |year=2004 |publisher=Horizon Bioscience |location=Wymondham, Norfolk, UK |isbn=978-0-9545232-3-7 |ref=CITEREFKlenkFeldmann2004}}
* {{Cite book |last=Kuhn |first=Jens H. |title=Filoviruses: A Compendium of 40 Years of Epidemiological, Clinical, and Laboratory Studies. Archives of Virology Supplement, vol. 20 |url=https://books.google.com/books?id=LaOue0F9Ns4C&amp;redir_esc=y&amp;hl=en |format=Limited preview |year=2008 |publisher=SpringerWienNewYork |location=Vienna |isbn=978-3-211-20670-6 |ref=CITEREFKuhn2008}}
* {{Cite book |last1=McCormick |first1=Joseph |last2=Fisher-Hoch |first2=Susan |others=Horvitz, Leslie Alan |title=Level 4: Virus Hunters of the CDC |url=https://books.google.com/books?id=QEvR3aJX2m0C&amp;redir_esc=y&amp;hl=en |format=Limited preview |origyear=1996 |edition=Updated [3rd] |year=1999 |publisher=Barnes &amp; Noble |isbn=978-0-7607-1208-5 |ref=CITEREFMcCormickFisher-Hoch1999 |month=June}}
* {{Cite book |last=Pattyn |first=S. R. |title=Ebola Virus Haemorrhagic Fever |year=1978 |url=http://www.itg.be/ebola/ |format=Full free text |edition=1st |publisher=Elsevier/North-Holland Biomedical Press |location=Amsterdam |isbn=0-444-80060-3 |ref=CITEREFPattyn1978}}
* {{Cite book | last1 = Ryabchikova | first1 = Elena I. | last2 = Price | first2 = Barbara B. | title = Ebola and Marburg Viruses: A View of Infection Using Electron Microscopy | year = 2004 | publisher = Battelle Press | location = Columbus, Ohio | isbn = 978-1-57477-131-2 | ref = CITEREFRyabchikovaPrice2004 }}
{{Refend}}

==Okuhlanganiswe nalokhu okunye==
{{Refbegin}}
* [https://viralzone.expasy.org/207.html?outline=all_by_species ViralZone: Ebola-like viruses] – Virological repository from the [[Swiss Institute of Bioinformatics]]
* [http://www.cdc.gov/vhf/ebola/ CDC: Ebola hemorrhagic fever] – Centers for Disease Control and Prevention, Special Pathogens Branch
* [http://www.who.int/csr/disease/ebola/en/ WHO: Ebola haemorrhagic fever] – World Health Organization, Global Alert and Response
* [http://www.viprbrc.org/brc/home.do?decorator=filo Virus Pathogen Database and Analysis Resource (ViPR): Filoviridae]
* [https://web.archive.org/web/20140808072117/http://www.ebi.ac.uk/pdbe/emdb/searchResults.html/?q=ebola 3D macromolecular structures of the Ebola virus archived in the EM Data Bank(EMDB)]
* [https://web.archive.org/web/20140819171607/https://maps.google.com/maps/ms?msa=0&amp;msid=202977755949863934429.0004c658eb30f9c4fb1c0&amp;ie=UTF8&amp;t=h&amp;ll=27.371767,5.273438&amp;spn=110.017392,184.21875&amp;z=2&amp;source=embed&amp;dg=feature Google Map of Ebola Outbreaks]
* [https://web.archive.org/web/20140816223245/http://www.who.int/csr/bioriskreduction/filovirus_infection_control/en/ WHO recommended infection control measures]
{{Refend}}</text>
      <sha1>n47b5sm9bj5oxv644rfnhhci6fvvyfi</sha1>
    </revision>
    <revision>
      <id>2194</id>
      <parentid>2193</parentid>
      <timestamp>2024-11-28T20:08:46Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* Okuhlanganiswe nalokhu okunye */cdc.gov</comment>
      <origin>2194</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9750" sha1="b3km4z87eydnt4jnzcfl3ljbl7mf6a2" xml:space="preserve">{{Infobox disease
| name           = Ubulwelwe be-Ebola
| image          = 7042 lores-Ebola-Zaire-CDC Photo.jpg
| caption        = Isithombe sango-1976 sabahlengikazi ababili, bajame hlanu kwaka [[Mayinga N'Seka|Mayinga N.]], omumuntu osahlelwe mumulwana we-Ebola. Wahlongakala ngemva kwamalanga ambalwa ngonobangela wobulwelwe bokopha nokurhadza kweengazi.
| DiseasesDB     = 18043
| ICD10          = {{ICD10|A|98|4|a|90}}
| ICD9           = {{ICD9|065.8}}
| MedlinePlus    = 001339
| eMedicineSubj  = med
| eMedicineTopic = 626
| MeshID         = D019142
}}
'''Ubulwelwe be-Ebola''' nofana ('''EVD''') '''[[Wp/kri/Ebola|I-Ebola]] nomulwana wokopha iingazi okhambisana nomgomani''' ('''EHF''') mimulwana ebangwa bulwelwe bevayirasi ebizwa nge- [[Ebola]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo athoma ukubonakala phakathi kwamalanga amabili ukuya eemvekeni eentathu ngemva sewungenwe bulwelwe lobu, [[njengomgomani ongapheliko]], umphimbo obabako onesilonda, [[imisipha ebuhlungu kanye nehloko esawula kabuhlungu]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kesinye isikhathi [[ungahlanza]], uphakanyelwe ziimbindi nesifo  [[sokurhuda]], kuzokwenza bona [[amaphaphu]] kanye [[neso]] zingasasebenzi kuhle.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Nasele sekufike lapha, abanye baba nomraro [[wokopha iingazi]].&lt;ref name=WHO2014&gt;{{Cite web|title=Ebola virus disease Fact sheet N°103|url=https://www.who.int/en/news-room/fact-sheets/detail/ebola-virus-disease|work=World Health Organization|accessdate=12 April 2014|date=March 2014}}&lt;/ref&gt;

&lt;!-- Cause and Diagnosis--&gt;
Umulwana lo ungangena nawuthintana [[neengazi]] zomuntu ophethwe ngibo nofana [[umjuluko]] nanyana [[okunye nokunye okusamanzana]] okuvela (eenlwaneni [[kumaphelaphelana]] nofana iimfene).&lt;ref name=WHO2014/&gt; Bekube nje umulwana akukatholakali bona ungangena ngokuwurhogela emmoyeni.&lt;ref name=WHOAir2014&gt;{{Cite web|title=2014 Ebola Virus Disease (EVD) outbreak in West Africa|url=http://www.who.int/ith/updates/20140421/en/|website=WHO|accessdate=3 August 2014|date=Apr 21 2014}}&lt;/ref&gt; Kukholelwa bonyana abomaphelaphelani bakwazi  ukuphatha umulwana lo kodwana wona angaphathwa ngiwo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kwaba khona umuntu otheleleke ngomulwana lo, umulwana lo ungatheleleka kabanye abantu godu ngesikhathi esifitjhani.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amadoda angasinda ngemva kokulatjhwa angathelela abanye abantu ngokuthunda [[imbewu]] yabo lokha nabaya emsemeni nakungakapheli iinyanga ezimbili.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nakufanele uhlahlutjwe nofana uhlolelwe ubulwelwe lobu be-ebola kufanele izifo ezifana [[nomalalahlengezela]], [[isifo sokurhuda]] kanye omulwana [[wokopha iingazi okhambisana nomgomani]]  inganakwa ukwenzelela ukuthola imiphumela ekungiyo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ukuqinisekisa umrabho womraro wobulwelwe lobu amasampula weengazi ayathathwa ayokuhlolelwa ubulwelwe [[nesivikelasifo seengazini]] kanye ne [[i-RNA]] lobu kanye nengongwana ebanga ubulwelwe lobu.&lt;ref name=WHO2014/&gt;

&lt;!-- Prevention --&gt;
Ukuvikela ubulwelwe lobu kungaphungulwa ukuthelelana hlangana neemfene kanye neemfarigi ezingenwe bulwelwelwe lobu bukhandelwe bona bungayi ebantwini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kungenziwa ngokobana kuhlolwe iinlwana lezi ukobana zinabo ubulwelwe lobu na, nakutholakala bona zinabo kungenzeka bona zibulawe bese kugujelwa imizimba yazo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nawupheka inyama bese wembatha izambatho zokuzivikela nakho kungakusiza,&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; ukwembatha izambatho zokuzivikela lokha nawuhlala nofana uhlanu kwaloyo muntu ongenwe mumulwana lowo [[kanye nokuhlamba izandla ngesibha]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amasampula wananyana yini esamanzana yalabo bantu abangenwe mumulwana lo kufanele zitjhejwe khulu, ubalekele ukuthintana nazo.&lt;ref name=WHO2014/&gt;

&lt;!-- Treatment, Prognosis and Epidemiology--&gt;
Ayikho intatha elapha ubulwelwe lobu; imizamo yokobana kusizwe abantu abangenwe bulwelwe lobu kukobana [[kwenziwe umtswako]] (banikelwe amanzi anetswayi) ukobana bawasele nofana [[bafakwe amadribhu azobangenisela okusamanzana emzimbeni wabo]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu [[buneembalobalo eziphezulu zabantu abafako]]: nabangenwe ngibo ubulwelwe lobu, i-ebola ingabulala pheze isiquntu-50% nofana i-90% yabantu abatheleleke ngayo.&lt;ref name=WHO2014/&gt;&lt;ref name=&quot;Elsevier/Academic Press&quot;&gt;{{Cite book|author1=C.M. Fauquet|title=Virus taxonomy classification and nomenclature of viruses; 8th report of the International Committee on Taxonomy of Viruses|date=2005|publisher=Elsevier/Academic Press|location=Oxford|isbn=9780080575483|page=648|url=http://books.google.ca/books?id=9Wy7Jgy5RWYC&amp;pg=PA648}}&lt;/ref&gt; I-EVD yathoma ukwazakala endaweni enarheni ye [[Sudan]] kanye ne- [[Democratic Republic of Congo]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu butholakala khulu eenarheni zethrophigi zenarhakazi yeAfrika [[Iphakathi le-Sehara ye-Afrika]].&lt;ref name=WHO2014/&gt; Ngo-1976 (ukutholakala kwabo ubulwelwe lobu] ukufikela ngo-2013, besele ingene yatheleleka ebantwini abangaphasii kwe-1000.&lt;ref name=WHO2014/&gt;&lt;ref name=MMWRJune2014&gt;{{Cite web|title=Ebola Viral Disease Outbreak — West Africa, 2014|url=https://www.cdc.gov/mmwr/preview/mmwrhtml/mm6325a4.htm?s_cid=mm6325a4_w|website=CDC|accessdate=26 June 2014|date=June 27, 2014}}&lt;/ref&gt; Ukuqubuka kobulwelwe lobu obukhulu obungazange khebubonwe ngilobu bamuva nje ngebe [[2014  Tjhingalanga ye-Afrika Ukuqubuka kwe-Ebola]], sebele bungene eenarheni [[Guinea]], [[Sierra Leone]], [[Liberia]] begodu ingatheleka ingene ne [[Nigeria]].&lt;ref name=CDC2014&gt;{{Cite web|title=CDC urges all US residents to avoid nonessential travel to Liberia, Guinea, and Sierra Leone because of an unprecedented outbreak of Ebola.|url=https://wwwnc.cdc.gov/travel/notices/level1/ebola-liberia|website=CDC|accessdate=2 August 2014|date=July 31, 2014}}&lt;/ref&gt;&lt;ref name=CDCAug2014N&gt;{{Cite web|title=Outbreak of Ebola in Guinea, Liberia, and Sierra Leone|url=http://www.cdc.gov/vhf/ebola/outbreaks/guinea/index.html|website=CDC|accessdate=5 August 2014|date=August 4, 2014}}&lt;/ref&gt; Ukusukela ngoRhoboyi 2014 sele kubikwe bona kunabantu esele bangenwe bulwelwe lobu abayi-1600.&lt;ref&gt;{{Cite web|title=Ebola virus disease update - West Africa|url=http://www.who.int/csr/don/2014_08_04_ebola/en/|website=WHO|accessdate=6 August 2014|date=Aug 4, 2014}}&lt;/ref&gt; Imizamo yona iyenziwa bona kutholakalle [[intatha/isihlahla]] esingalapha ubulwelwe lobu, kodwana okwanje asikho kwatholakala ipengu yakhona.&lt;ref name=WHO2014/&gt;

== Isikhombiso selwazi==
{{Reflist|colwidth=25em}}

; IBhibhliyografu
{{Refbegin}}
* {{Cite book |last=Klenk |first=Hans-Dieter |title=Marburg and Ebola Viruses (Current Topics in Microbiology and Immunology) |date=January 1999 |publisher=Springer-Verlag Telos |location=Berlin |isbn=978-3-540-64729-4 |ref=CITEREFKlenk1999}}
* {{Cite book |first1=Hans-Dieter |last1=Klenk |first2=Heinz |last2=Feldmann |title=Ebola and Marburg viruses: molecular and cellular biology |url=https://books.google.com/books?id=EV_mFgnyPoMC&amp;redir_esc=y&amp;hl=en|format=Limited preview |year=2004 |publisher=Horizon Bioscience |location=Wymondham, Norfolk, UK |isbn=978-0-9545232-3-7 |ref=CITEREFKlenkFeldmann2004}}
* {{Cite book |last=Kuhn |first=Jens H. |title=Filoviruses: A Compendium of 40 Years of Epidemiological, Clinical, and Laboratory Studies. Archives of Virology Supplement, vol. 20 |url=https://books.google.com/books?id=LaOue0F9Ns4C&amp;redir_esc=y&amp;hl=en |format=Limited preview |year=2008 |publisher=SpringerWienNewYork |location=Vienna |isbn=978-3-211-20670-6 |ref=CITEREFKuhn2008}}
* {{Cite book |last1=McCormick |first1=Joseph |last2=Fisher-Hoch |first2=Susan |others=Horvitz, Leslie Alan |title=Level 4: Virus Hunters of the CDC |url=https://books.google.com/books?id=QEvR3aJX2m0C&amp;redir_esc=y&amp;hl=en |format=Limited preview |origyear=1996 |edition=Updated [3rd] |year=1999 |publisher=Barnes &amp; Noble |isbn=978-0-7607-1208-5 |ref=CITEREFMcCormickFisher-Hoch1999 |month=June}}
* {{Cite book |last=Pattyn |first=S. R. |title=Ebola Virus Haemorrhagic Fever |year=1978 |url=http://www.itg.be/ebola/ |format=Full free text |edition=1st |publisher=Elsevier/North-Holland Biomedical Press |location=Amsterdam |isbn=0-444-80060-3 |ref=CITEREFPattyn1978}}
* {{Cite book | last1 = Ryabchikova | first1 = Elena I. | last2 = Price | first2 = Barbara B. | title = Ebola and Marburg Viruses: A View of Infection Using Electron Microscopy | year = 2004 | publisher = Battelle Press | location = Columbus, Ohio | isbn = 978-1-57477-131-2 | ref = CITEREFRyabchikovaPrice2004 }}
{{Refend}}

==Okuhlanganiswe nalokhu okunye==
{{Refbegin}}
* [https://viralzone.expasy.org/207.html?outline=all_by_species ViralZone: Ebola-like viruses] – Virological repository from the [[Swiss Institute of Bioinformatics]]
* [https://www.cdc.gov/ebola/about/index.html CDC: Ebola hemorrhagic fever] – Centers for Disease Control and Prevention, Special Pathogens Branch
* [http://www.who.int/csr/disease/ebola/en/ WHO: Ebola haemorrhagic fever] – World Health Organization, Global Alert and Response
* [http://www.viprbrc.org/brc/home.do?decorator=filo Virus Pathogen Database and Analysis Resource (ViPR): Filoviridae]
* [https://web.archive.org/web/20140808072117/http://www.ebi.ac.uk/pdbe/emdb/searchResults.html/?q=ebola 3D macromolecular structures of the Ebola virus archived in the EM Data Bank(EMDB)]
* [https://web.archive.org/web/20140819171607/https://maps.google.com/maps/ms?msa=0&amp;msid=202977755949863934429.0004c658eb30f9c4fb1c0&amp;ie=UTF8&amp;t=h&amp;ll=27.371767,5.273438&amp;spn=110.017392,184.21875&amp;z=2&amp;source=embed&amp;dg=feature Google Map of Ebola Outbreaks]
* [https://web.archive.org/web/20140816223245/http://www.who.int/csr/bioriskreduction/filovirus_infection_control/en/ WHO recommended infection control measures]
{{Refend}}</text>
      <sha1>b3km4z87eydnt4jnzcfl3ljbl7mf6a2</sha1>
    </revision>
    <revision>
      <id>2195</id>
      <parentid>2194</parentid>
      <timestamp>2024-11-28T20:09:24Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* Okuhlanganiswe nalokhu okunye */who.int</comment>
      <origin>2195</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9749" sha1="s5ag7zr3wdogxq5qmcwazkh6mlnhzk0" xml:space="preserve">{{Infobox disease
| name           = Ubulwelwe be-Ebola
| image          = 7042 lores-Ebola-Zaire-CDC Photo.jpg
| caption        = Isithombe sango-1976 sabahlengikazi ababili, bajame hlanu kwaka [[Mayinga N'Seka|Mayinga N.]], omumuntu osahlelwe mumulwana we-Ebola. Wahlongakala ngemva kwamalanga ambalwa ngonobangela wobulwelwe bokopha nokurhadza kweengazi.
| DiseasesDB     = 18043
| ICD10          = {{ICD10|A|98|4|a|90}}
| ICD9           = {{ICD9|065.8}}
| MedlinePlus    = 001339
| eMedicineSubj  = med
| eMedicineTopic = 626
| MeshID         = D019142
}}
'''Ubulwelwe be-Ebola''' nofana ('''EVD''') '''[[Wp/kri/Ebola|I-Ebola]] nomulwana wokopha iingazi okhambisana nomgomani''' ('''EHF''') mimulwana ebangwa bulwelwe bevayirasi ebizwa nge- [[Ebola]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo athoma ukubonakala phakathi kwamalanga amabili ukuya eemvekeni eentathu ngemva sewungenwe bulwelwe lobu, [[njengomgomani ongapheliko]], umphimbo obabako onesilonda, [[imisipha ebuhlungu kanye nehloko esawula kabuhlungu]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kesinye isikhathi [[ungahlanza]], uphakanyelwe ziimbindi nesifo  [[sokurhuda]], kuzokwenza bona [[amaphaphu]] kanye [[neso]] zingasasebenzi kuhle.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Nasele sekufike lapha, abanye baba nomraro [[wokopha iingazi]].&lt;ref name=WHO2014&gt;{{Cite web|title=Ebola virus disease Fact sheet N°103|url=https://www.who.int/en/news-room/fact-sheets/detail/ebola-virus-disease|work=World Health Organization|accessdate=12 April 2014|date=March 2014}}&lt;/ref&gt;

&lt;!-- Cause and Diagnosis--&gt;
Umulwana lo ungangena nawuthintana [[neengazi]] zomuntu ophethwe ngibo nofana [[umjuluko]] nanyana [[okunye nokunye okusamanzana]] okuvela (eenlwaneni [[kumaphelaphelana]] nofana iimfene).&lt;ref name=WHO2014/&gt; Bekube nje umulwana akukatholakali bona ungangena ngokuwurhogela emmoyeni.&lt;ref name=WHOAir2014&gt;{{Cite web|title=2014 Ebola Virus Disease (EVD) outbreak in West Africa|url=http://www.who.int/ith/updates/20140421/en/|website=WHO|accessdate=3 August 2014|date=Apr 21 2014}}&lt;/ref&gt; Kukholelwa bonyana abomaphelaphelani bakwazi  ukuphatha umulwana lo kodwana wona angaphathwa ngiwo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kwaba khona umuntu otheleleke ngomulwana lo, umulwana lo ungatheleleka kabanye abantu godu ngesikhathi esifitjhani.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amadoda angasinda ngemva kokulatjhwa angathelela abanye abantu ngokuthunda [[imbewu]] yabo lokha nabaya emsemeni nakungakapheli iinyanga ezimbili.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nakufanele uhlahlutjwe nofana uhlolelwe ubulwelwe lobu be-ebola kufanele izifo ezifana [[nomalalahlengezela]], [[isifo sokurhuda]] kanye omulwana [[wokopha iingazi okhambisana nomgomani]]  inganakwa ukwenzelela ukuthola imiphumela ekungiyo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ukuqinisekisa umrabho womraro wobulwelwe lobu amasampula weengazi ayathathwa ayokuhlolelwa ubulwelwe [[nesivikelasifo seengazini]] kanye ne [[i-RNA]] lobu kanye nengongwana ebanga ubulwelwe lobu.&lt;ref name=WHO2014/&gt;

&lt;!-- Prevention --&gt;
Ukuvikela ubulwelwe lobu kungaphungulwa ukuthelelana hlangana neemfene kanye neemfarigi ezingenwe bulwelwelwe lobu bukhandelwe bona bungayi ebantwini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kungenziwa ngokobana kuhlolwe iinlwana lezi ukobana zinabo ubulwelwe lobu na, nakutholakala bona zinabo kungenzeka bona zibulawe bese kugujelwa imizimba yazo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nawupheka inyama bese wembatha izambatho zokuzivikela nakho kungakusiza,&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; ukwembatha izambatho zokuzivikela lokha nawuhlala nofana uhlanu kwaloyo muntu ongenwe mumulwana lowo [[kanye nokuhlamba izandla ngesibha]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amasampula wananyana yini esamanzana yalabo bantu abangenwe mumulwana lo kufanele zitjhejwe khulu, ubalekele ukuthintana nazo.&lt;ref name=WHO2014/&gt;

&lt;!-- Treatment, Prognosis and Epidemiology--&gt;
Ayikho intatha elapha ubulwelwe lobu; imizamo yokobana kusizwe abantu abangenwe bulwelwe lobu kukobana [[kwenziwe umtswako]] (banikelwe amanzi anetswayi) ukobana bawasele nofana [[bafakwe amadribhu azobangenisela okusamanzana emzimbeni wabo]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu [[buneembalobalo eziphezulu zabantu abafako]]: nabangenwe ngibo ubulwelwe lobu, i-ebola ingabulala pheze isiquntu-50% nofana i-90% yabantu abatheleleke ngayo.&lt;ref name=WHO2014/&gt;&lt;ref name=&quot;Elsevier/Academic Press&quot;&gt;{{Cite book|author1=C.M. Fauquet|title=Virus taxonomy classification and nomenclature of viruses; 8th report of the International Committee on Taxonomy of Viruses|date=2005|publisher=Elsevier/Academic Press|location=Oxford|isbn=9780080575483|page=648|url=http://books.google.ca/books?id=9Wy7Jgy5RWYC&amp;pg=PA648}}&lt;/ref&gt; I-EVD yathoma ukwazakala endaweni enarheni ye [[Sudan]] kanye ne- [[Democratic Republic of Congo]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu butholakala khulu eenarheni zethrophigi zenarhakazi yeAfrika [[Iphakathi le-Sehara ye-Afrika]].&lt;ref name=WHO2014/&gt; Ngo-1976 (ukutholakala kwabo ubulwelwe lobu] ukufikela ngo-2013, besele ingene yatheleleka ebantwini abangaphasii kwe-1000.&lt;ref name=WHO2014/&gt;&lt;ref name=MMWRJune2014&gt;{{Cite web|title=Ebola Viral Disease Outbreak — West Africa, 2014|url=https://www.cdc.gov/mmwr/preview/mmwrhtml/mm6325a4.htm?s_cid=mm6325a4_w|website=CDC|accessdate=26 June 2014|date=June 27, 2014}}&lt;/ref&gt; Ukuqubuka kobulwelwe lobu obukhulu obungazange khebubonwe ngilobu bamuva nje ngebe [[2014  Tjhingalanga ye-Afrika Ukuqubuka kwe-Ebola]], sebele bungene eenarheni [[Guinea]], [[Sierra Leone]], [[Liberia]] begodu ingatheleka ingene ne [[Nigeria]].&lt;ref name=CDC2014&gt;{{Cite web|title=CDC urges all US residents to avoid nonessential travel to Liberia, Guinea, and Sierra Leone because of an unprecedented outbreak of Ebola.|url=https://wwwnc.cdc.gov/travel/notices/level1/ebola-liberia|website=CDC|accessdate=2 August 2014|date=July 31, 2014}}&lt;/ref&gt;&lt;ref name=CDCAug2014N&gt;{{Cite web|title=Outbreak of Ebola in Guinea, Liberia, and Sierra Leone|url=http://www.cdc.gov/vhf/ebola/outbreaks/guinea/index.html|website=CDC|accessdate=5 August 2014|date=August 4, 2014}}&lt;/ref&gt; Ukusukela ngoRhoboyi 2014 sele kubikwe bona kunabantu esele bangenwe bulwelwe lobu abayi-1600.&lt;ref&gt;{{Cite web|title=Ebola virus disease update - West Africa|url=http://www.who.int/csr/don/2014_08_04_ebola/en/|website=WHO|accessdate=6 August 2014|date=Aug 4, 2014}}&lt;/ref&gt; Imizamo yona iyenziwa bona kutholakalle [[intatha/isihlahla]] esingalapha ubulwelwe lobu, kodwana okwanje asikho kwatholakala ipengu yakhona.&lt;ref name=WHO2014/&gt;

== Isikhombiso selwazi==
{{Reflist|colwidth=25em}}

; IBhibhliyografu
{{Refbegin}}
* {{Cite book |last=Klenk |first=Hans-Dieter |title=Marburg and Ebola Viruses (Current Topics in Microbiology and Immunology) |date=January 1999 |publisher=Springer-Verlag Telos |location=Berlin |isbn=978-3-540-64729-4 |ref=CITEREFKlenk1999}}
* {{Cite book |first1=Hans-Dieter |last1=Klenk |first2=Heinz |last2=Feldmann |title=Ebola and Marburg viruses: molecular and cellular biology |url=https://books.google.com/books?id=EV_mFgnyPoMC&amp;redir_esc=y&amp;hl=en|format=Limited preview |year=2004 |publisher=Horizon Bioscience |location=Wymondham, Norfolk, UK |isbn=978-0-9545232-3-7 |ref=CITEREFKlenkFeldmann2004}}
* {{Cite book |last=Kuhn |first=Jens H. |title=Filoviruses: A Compendium of 40 Years of Epidemiological, Clinical, and Laboratory Studies. Archives of Virology Supplement, vol. 20 |url=https://books.google.com/books?id=LaOue0F9Ns4C&amp;redir_esc=y&amp;hl=en |format=Limited preview |year=2008 |publisher=SpringerWienNewYork |location=Vienna |isbn=978-3-211-20670-6 |ref=CITEREFKuhn2008}}
* {{Cite book |last1=McCormick |first1=Joseph |last2=Fisher-Hoch |first2=Susan |others=Horvitz, Leslie Alan |title=Level 4: Virus Hunters of the CDC |url=https://books.google.com/books?id=QEvR3aJX2m0C&amp;redir_esc=y&amp;hl=en |format=Limited preview |origyear=1996 |edition=Updated [3rd] |year=1999 |publisher=Barnes &amp; Noble |isbn=978-0-7607-1208-5 |ref=CITEREFMcCormickFisher-Hoch1999 |month=June}}
* {{Cite book |last=Pattyn |first=S. R. |title=Ebola Virus Haemorrhagic Fever |year=1978 |url=http://www.itg.be/ebola/ |format=Full free text |edition=1st |publisher=Elsevier/North-Holland Biomedical Press |location=Amsterdam |isbn=0-444-80060-3 |ref=CITEREFPattyn1978}}
* {{Cite book | last1 = Ryabchikova | first1 = Elena I. | last2 = Price | first2 = Barbara B. | title = Ebola and Marburg Viruses: A View of Infection Using Electron Microscopy | year = 2004 | publisher = Battelle Press | location = Columbus, Ohio | isbn = 978-1-57477-131-2 | ref = CITEREFRyabchikovaPrice2004 }}
{{Refend}}

==Okuhlanganiswe nalokhu okunye==
{{Refbegin}}
* [https://viralzone.expasy.org/207.html?outline=all_by_species ViralZone: Ebola-like viruses] – Virological repository from the [[Swiss Institute of Bioinformatics]]
* [https://www.cdc.gov/ebola/about/index.html CDC: Ebola hemorrhagic fever] – Centers for Disease Control and Prevention, Special Pathogens Branch
* [https://www.who.int/health-topics/ebola WHO: Ebola haemorrhagic fever] – World Health Organization, Global Alert and Response
* [http://www.viprbrc.org/brc/home.do?decorator=filo Virus Pathogen Database and Analysis Resource (ViPR): Filoviridae]
* [https://web.archive.org/web/20140808072117/http://www.ebi.ac.uk/pdbe/emdb/searchResults.html/?q=ebola 3D macromolecular structures of the Ebola virus archived in the EM Data Bank(EMDB)]
* [https://web.archive.org/web/20140819171607/https://maps.google.com/maps/ms?msa=0&amp;msid=202977755949863934429.0004c658eb30f9c4fb1c0&amp;ie=UTF8&amp;t=h&amp;ll=27.371767,5.273438&amp;spn=110.017392,184.21875&amp;z=2&amp;source=embed&amp;dg=feature Google Map of Ebola Outbreaks]
* [https://web.archive.org/web/20140816223245/http://www.who.int/csr/bioriskreduction/filovirus_infection_control/en/ WHO recommended infection control measures]
{{Refend}}</text>
      <sha1>s5ag7zr3wdogxq5qmcwazkh6mlnhzk0</sha1>
    </revision>
    <revision>
      <id>2196</id>
      <parentid>2195</parentid>
      <timestamp>2024-11-28T20:10:16Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <comment>/* Okuhlanganiswe nalokhu okunye */bv-brc.org</comment>
      <origin>2196</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9723" sha1="3eokh1o3i72tmceo4zrqxijxepk5jba" xml:space="preserve">{{Infobox disease
| name           = Ubulwelwe be-Ebola
| image          = 7042 lores-Ebola-Zaire-CDC Photo.jpg
| caption        = Isithombe sango-1976 sabahlengikazi ababili, bajame hlanu kwaka [[Mayinga N'Seka|Mayinga N.]], omumuntu osahlelwe mumulwana we-Ebola. Wahlongakala ngemva kwamalanga ambalwa ngonobangela wobulwelwe bokopha nokurhadza kweengazi.
| DiseasesDB     = 18043
| ICD10          = {{ICD10|A|98|4|a|90}}
| ICD9           = {{ICD9|065.8}}
| MedlinePlus    = 001339
| eMedicineSubj  = med
| eMedicineTopic = 626
| MeshID         = D019142
}}
'''Ubulwelwe be-Ebola''' nofana ('''EVD''') '''[[Wp/kri/Ebola|I-Ebola]] nomulwana wokopha iingazi okhambisana nomgomani''' ('''EHF''') mimulwana ebangwa bulwelwe bevayirasi ebizwa nge- [[Ebola]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo athoma ukubonakala phakathi kwamalanga amabili ukuya eemvekeni eentathu ngemva sewungenwe bulwelwe lobu, [[njengomgomani ongapheliko]], umphimbo obabako onesilonda, [[imisipha ebuhlungu kanye nehloko esawula kabuhlungu]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kesinye isikhathi [[ungahlanza]], uphakanyelwe ziimbindi nesifo  [[sokurhuda]], kuzokwenza bona [[amaphaphu]] kanye [[neso]] zingasasebenzi kuhle.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Nasele sekufike lapha, abanye baba nomraro [[wokopha iingazi]].&lt;ref name=WHO2014&gt;{{Cite web|title=Ebola virus disease Fact sheet N°103|url=https://www.who.int/en/news-room/fact-sheets/detail/ebola-virus-disease|work=World Health Organization|accessdate=12 April 2014|date=March 2014}}&lt;/ref&gt;

&lt;!-- Cause and Diagnosis--&gt;
Umulwana lo ungangena nawuthintana [[neengazi]] zomuntu ophethwe ngibo nofana [[umjuluko]] nanyana [[okunye nokunye okusamanzana]] okuvela (eenlwaneni [[kumaphelaphelana]] nofana iimfene).&lt;ref name=WHO2014/&gt; Bekube nje umulwana akukatholakali bona ungangena ngokuwurhogela emmoyeni.&lt;ref name=WHOAir2014&gt;{{Cite web|title=2014 Ebola Virus Disease (EVD) outbreak in West Africa|url=http://www.who.int/ith/updates/20140421/en/|website=WHO|accessdate=3 August 2014|date=Apr 21 2014}}&lt;/ref&gt; Kukholelwa bonyana abomaphelaphelani bakwazi  ukuphatha umulwana lo kodwana wona angaphathwa ngiwo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kwaba khona umuntu otheleleke ngomulwana lo, umulwana lo ungatheleleka kabanye abantu godu ngesikhathi esifitjhani.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amadoda angasinda ngemva kokulatjhwa angathelela abanye abantu ngokuthunda [[imbewu]] yabo lokha nabaya emsemeni nakungakapheli iinyanga ezimbili.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nakufanele uhlahlutjwe nofana uhlolelwe ubulwelwe lobu be-ebola kufanele izifo ezifana [[nomalalahlengezela]], [[isifo sokurhuda]] kanye omulwana [[wokopha iingazi okhambisana nomgomani]]  inganakwa ukwenzelela ukuthola imiphumela ekungiyo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ukuqinisekisa umrabho womraro wobulwelwe lobu amasampula weengazi ayathathwa ayokuhlolelwa ubulwelwe [[nesivikelasifo seengazini]] kanye ne [[i-RNA]] lobu kanye nengongwana ebanga ubulwelwe lobu.&lt;ref name=WHO2014/&gt;

&lt;!-- Prevention --&gt;
Ukuvikela ubulwelwe lobu kungaphungulwa ukuthelelana hlangana neemfene kanye neemfarigi ezingenwe bulwelwelwe lobu bukhandelwe bona bungayi ebantwini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kungenziwa ngokobana kuhlolwe iinlwana lezi ukobana zinabo ubulwelwe lobu na, nakutholakala bona zinabo kungenzeka bona zibulawe bese kugujelwa imizimba yazo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nawupheka inyama bese wembatha izambatho zokuzivikela nakho kungakusiza,&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; ukwembatha izambatho zokuzivikela lokha nawuhlala nofana uhlanu kwaloyo muntu ongenwe mumulwana lowo [[kanye nokuhlamba izandla ngesibha]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amasampula wananyana yini esamanzana yalabo bantu abangenwe mumulwana lo kufanele zitjhejwe khulu, ubalekele ukuthintana nazo.&lt;ref name=WHO2014/&gt;

&lt;!-- Treatment, Prognosis and Epidemiology--&gt;
Ayikho intatha elapha ubulwelwe lobu; imizamo yokobana kusizwe abantu abangenwe bulwelwe lobu kukobana [[kwenziwe umtswako]] (banikelwe amanzi anetswayi) ukobana bawasele nofana [[bafakwe amadribhu azobangenisela okusamanzana emzimbeni wabo]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu [[buneembalobalo eziphezulu zabantu abafako]]: nabangenwe ngibo ubulwelwe lobu, i-ebola ingabulala pheze isiquntu-50% nofana i-90% yabantu abatheleleke ngayo.&lt;ref name=WHO2014/&gt;&lt;ref name=&quot;Elsevier/Academic Press&quot;&gt;{{Cite book|author1=C.M. Fauquet|title=Virus taxonomy classification and nomenclature of viruses; 8th report of the International Committee on Taxonomy of Viruses|date=2005|publisher=Elsevier/Academic Press|location=Oxford|isbn=9780080575483|page=648|url=http://books.google.ca/books?id=9Wy7Jgy5RWYC&amp;pg=PA648}}&lt;/ref&gt; I-EVD yathoma ukwazakala endaweni enarheni ye [[Sudan]] kanye ne- [[Democratic Republic of Congo]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu butholakala khulu eenarheni zethrophigi zenarhakazi yeAfrika [[Iphakathi le-Sehara ye-Afrika]].&lt;ref name=WHO2014/&gt; Ngo-1976 (ukutholakala kwabo ubulwelwe lobu] ukufikela ngo-2013, besele ingene yatheleleka ebantwini abangaphasii kwe-1000.&lt;ref name=WHO2014/&gt;&lt;ref name=MMWRJune2014&gt;{{Cite web|title=Ebola Viral Disease Outbreak — West Africa, 2014|url=https://www.cdc.gov/mmwr/preview/mmwrhtml/mm6325a4.htm?s_cid=mm6325a4_w|website=CDC|accessdate=26 June 2014|date=June 27, 2014}}&lt;/ref&gt; Ukuqubuka kobulwelwe lobu obukhulu obungazange khebubonwe ngilobu bamuva nje ngebe [[2014  Tjhingalanga ye-Afrika Ukuqubuka kwe-Ebola]], sebele bungene eenarheni [[Guinea]], [[Sierra Leone]], [[Liberia]] begodu ingatheleka ingene ne [[Nigeria]].&lt;ref name=CDC2014&gt;{{Cite web|title=CDC urges all US residents to avoid nonessential travel to Liberia, Guinea, and Sierra Leone because of an unprecedented outbreak of Ebola.|url=https://wwwnc.cdc.gov/travel/notices/level1/ebola-liberia|website=CDC|accessdate=2 August 2014|date=July 31, 2014}}&lt;/ref&gt;&lt;ref name=CDCAug2014N&gt;{{Cite web|title=Outbreak of Ebola in Guinea, Liberia, and Sierra Leone|url=http://www.cdc.gov/vhf/ebola/outbreaks/guinea/index.html|website=CDC|accessdate=5 August 2014|date=August 4, 2014}}&lt;/ref&gt; Ukusukela ngoRhoboyi 2014 sele kubikwe bona kunabantu esele bangenwe bulwelwe lobu abayi-1600.&lt;ref&gt;{{Cite web|title=Ebola virus disease update - West Africa|url=http://www.who.int/csr/don/2014_08_04_ebola/en/|website=WHO|accessdate=6 August 2014|date=Aug 4, 2014}}&lt;/ref&gt; Imizamo yona iyenziwa bona kutholakalle [[intatha/isihlahla]] esingalapha ubulwelwe lobu, kodwana okwanje asikho kwatholakala ipengu yakhona.&lt;ref name=WHO2014/&gt;

== Isikhombiso selwazi==
{{Reflist|colwidth=25em}}

; IBhibhliyografu
{{Refbegin}}
* {{Cite book |last=Klenk |first=Hans-Dieter |title=Marburg and Ebola Viruses (Current Topics in Microbiology and Immunology) |date=January 1999 |publisher=Springer-Verlag Telos |location=Berlin |isbn=978-3-540-64729-4 |ref=CITEREFKlenk1999}}
* {{Cite book |first1=Hans-Dieter |last1=Klenk |first2=Heinz |last2=Feldmann |title=Ebola and Marburg viruses: molecular and cellular biology |url=https://books.google.com/books?id=EV_mFgnyPoMC&amp;redir_esc=y&amp;hl=en|format=Limited preview |year=2004 |publisher=Horizon Bioscience |location=Wymondham, Norfolk, UK |isbn=978-0-9545232-3-7 |ref=CITEREFKlenkFeldmann2004}}
* {{Cite book |last=Kuhn |first=Jens H. |title=Filoviruses: A Compendium of 40 Years of Epidemiological, Clinical, and Laboratory Studies. Archives of Virology Supplement, vol. 20 |url=https://books.google.com/books?id=LaOue0F9Ns4C&amp;redir_esc=y&amp;hl=en |format=Limited preview |year=2008 |publisher=SpringerWienNewYork |location=Vienna |isbn=978-3-211-20670-6 |ref=CITEREFKuhn2008}}
* {{Cite book |last1=McCormick |first1=Joseph |last2=Fisher-Hoch |first2=Susan |others=Horvitz, Leslie Alan |title=Level 4: Virus Hunters of the CDC |url=https://books.google.com/books?id=QEvR3aJX2m0C&amp;redir_esc=y&amp;hl=en |format=Limited preview |origyear=1996 |edition=Updated [3rd] |year=1999 |publisher=Barnes &amp; Noble |isbn=978-0-7607-1208-5 |ref=CITEREFMcCormickFisher-Hoch1999 |month=June}}
* {{Cite book |last=Pattyn |first=S. R. |title=Ebola Virus Haemorrhagic Fever |year=1978 |url=http://www.itg.be/ebola/ |format=Full free text |edition=1st |publisher=Elsevier/North-Holland Biomedical Press |location=Amsterdam |isbn=0-444-80060-3 |ref=CITEREFPattyn1978}}
* {{Cite book | last1 = Ryabchikova | first1 = Elena I. | last2 = Price | first2 = Barbara B. | title = Ebola and Marburg Viruses: A View of Infection Using Electron Microscopy | year = 2004 | publisher = Battelle Press | location = Columbus, Ohio | isbn = 978-1-57477-131-2 | ref = CITEREFRyabchikovaPrice2004 }}
{{Refend}}

==Okuhlanganiswe nalokhu okunye==
{{Refbegin}}
* [https://viralzone.expasy.org/207.html?outline=all_by_species ViralZone: Ebola-like viruses] – Virological repository from the [[Swiss Institute of Bioinformatics]]
* [https://www.cdc.gov/ebola/about/index.html CDC: Ebola hemorrhagic fever] – Centers for Disease Control and Prevention, Special Pathogens Branch
* [https://www.who.int/health-topics/ebola WHO: Ebola haemorrhagic fever] – World Health Organization, Global Alert and Response
* [https://www.bv-brc.org/ Virus Pathogen Database and Analysis Resource (ViPR): Filoviridae]
* [https://web.archive.org/web/20140808072117/http://www.ebi.ac.uk/pdbe/emdb/searchResults.html/?q=ebola 3D macromolecular structures of the Ebola virus archived in the EM Data Bank(EMDB)]
* [https://web.archive.org/web/20140819171607/https://maps.google.com/maps/ms?msa=0&amp;msid=202977755949863934429.0004c658eb30f9c4fb1c0&amp;ie=UTF8&amp;t=h&amp;ll=27.371767,5.273438&amp;spn=110.017392,184.21875&amp;z=2&amp;source=embed&amp;dg=feature Google Map of Ebola Outbreaks]
* [https://web.archive.org/web/20140816223245/http://www.who.int/csr/bioriskreduction/filovirus_infection_control/en/ WHO recommended infection control measures]
{{Refend}}</text>
      <sha1>3eokh1o3i72tmceo4zrqxijxepk5jba</sha1>
    </revision>
    <revision>
      <id>2632</id>
      <parentid>2196</parentid>
      <timestamp>2025-04-03T19:09:46Z</timestamp>
      <contributor>
        <username>Rachmat04</username>
        <id>32</id>
      </contributor>
      <minor />
      <origin>2632</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9722" sha1="m6dezr4k1nx135pjmju4pm5wpj6jw6o" xml:space="preserve">{{Infobox disease
| name           = Ubulwelwe be-Ebola
| image          = 7042 lores-Ebola-Zaire-CDC Photo.jpg
| caption        = Isithombe sango-1976 sabahlengikazi ababili, bajame hlanu kwaka [[Mayinga N'Seka|Mayinga N.]], omumuntu osahlelwe mumulwana we-Ebola. Wahlongakala ngemva kwamalanga ambalwa ngonobangela wobulwelwe bokopha nokurhadza kweengazi.
| DiseasesDB     = 18043
| ICD10          = {{ICD10|A|98|4|a|90}}
| ICD9           = {{ICD9|065.8}}
| MedlinePlus    = 001339
| eMedicineSubj  = med
| eMedicineTopic = 626
| MeshID         = D019142
}}
'''Ubulwelwe be-Ebola''' nofana ('''EVD''') '''[[Wp/kri/Ebola|I-Ebola]] nomulwana wokopha iingazi okhambisana nomgomani''' ('''EHF''') mimulwana ebangwa bulwelwe bevayirasi ebizwa nge- [[Ebola]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo athoma ukubonakala phakathi kwamalanga amabili ukuya eemvekeni eentathu ngemva sewungenwe bulwelwe lobu, [[njengomgomani ongapheliko]], umphimbo obabako onesilonda, [[imisipha ebuhlungu kanye nehloko esawula kabuhlungu]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kesinye isikhathi [[ungahlanza]], uphakanyelwe ziimbindi nesifo [[sokurhuda]], kuzokwenza bona [[amaphaphu]] kanye [[neso]] zingasasebenzi kuhle.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Nasele sekufike lapha, abanye baba nomraro [[wokopha iingazi]].&lt;ref name=WHO2014&gt;{{Cite web|title=Ebola virus disease Fact sheet N°103|url=https://www.who.int/en/news-room/fact-sheets/detail/ebola-virus-disease|work=World Health Organization|accessdate=12 April 2014|date=March 2014}}&lt;/ref&gt;

&lt;!-- Cause and Diagnosis--&gt;
Umulwana lo ungangena nawuthintana [[neengazi]] zomuntu ophethwe ngibo nofana [[umjuluko]] nanyana [[okunye nokunye okusamanzana]] okuvela (eenlwaneni [[kumaphelaphelana]] nofana iimfene).&lt;ref name=WHO2014/&gt; Bekube nje umulwana akukatholakali bona ungangena ngokuwurhogela emmoyeni.&lt;ref name=WHOAir2014&gt;{{Cite web|title=2014 Ebola Virus Disease (EVD) outbreak in West Africa|url=http://www.who.int/ith/updates/20140421/en/|website=WHO|accessdate=3 August 2014|date=Apr 21 2014}}&lt;/ref&gt; Kukholelwa bonyana abomaphelaphelani bakwazi ukuphatha umulwana lo kodwana wona angaphathwa ngiwo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kwaba khona umuntu otheleleke ngomulwana lo, umulwana lo ungatheleleka kabanye abantu godu ngesikhathi esifitjhani.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amadoda angasinda ngemva kokulatjhwa angathelela abanye abantu ngokuthunda [[imbewu]] yabo lokha nabaya emsemeni nakungakapheli iinyanga ezimbili.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nakufanele uhlahlutjwe nofana uhlolelwe ubulwelwe lobu be-ebola kufanele izifo ezifana [[nomalalahlengezela]], [[isifo sokurhuda]] kanye omulwana [[wokopha iingazi okhambisana nomgomani]] inganakwa ukwenzelela ukuthola imiphumela ekungiyo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ukuqinisekisa umrabho womraro wobulwelwe lobu amasampula weengazi ayathathwa ayokuhlolelwa ubulwelwe [[nesivikelasifo seengazini]] kanye ne [[i-RNA]] lobu kanye nengongwana ebanga ubulwelwe lobu.&lt;ref name=WHO2014/&gt;

&lt;!-- Prevention --&gt;
Ukuvikela ubulwelwe lobu kungaphungulwa ukuthelelana hlangana neemfene kanye neemfarigi ezingenwe bulwelwelwe lobu bukhandelwe bona bungayi ebantwini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kungenziwa ngokobana kuhlolwe iinlwana lezi ukobana zinabo ubulwelwe lobu na, nakutholakala bona zinabo kungenzeka bona zibulawe bese kugujelwa imizimba yazo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nawupheka inyama bese wembatha izambatho zokuzivikela nakho kungakusiza,&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; ukwembatha izambatho zokuzivikela lokha nawuhlala nofana uhlanu kwaloyo muntu ongenwe mumulwana lowo [[kanye nokuhlamba izandla ngesibha]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amasampula wananyana yini esamanzana yalabo bantu abangenwe mumulwana lo kufanele zitjhejwe khulu, ubalekele ukuthintana nazo.&lt;ref name=WHO2014/&gt;

&lt;!-- Treatment, Prognosis and Epidemiology--&gt;
Ayikho intatha elapha ubulwelwe lobu; imizamo yokobana kusizwe abantu abangenwe bulwelwe lobu kukobana [[kwenziwe umtswako]] (banikelwe amanzi anetswayi) ukobana bawasele nofana [[bafakwe amadribhu azobangenisela okusamanzana emzimbeni wabo]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu [[buneembalobalo eziphezulu zabantu abafako]]: nabangenwe ngibo ubulwelwe lobu, i-ebola ingabulala pheze isiquntu-50% nofana i-90% yabantu abatheleleke ngayo.&lt;ref name=WHO2014/&gt;&lt;ref name=&quot;Elsevier/Academic Press&quot;&gt;{{Cite book|author1=C.M. Fauquet|title=Virus taxonomy classification and nomenclature of viruses; 8th report of the International Committee on Taxonomy of Viruses|date=2005|publisher=Elsevier/Academic Press|location=Oxford|isbn=9780080575483|page=648|url=http://books.google.ca/books?id=9Wy7Jgy5RWYC&amp;pg=PA648}}&lt;/ref&gt; I-EVD yathoma ukwazakala endaweni enarheni ye [[Sudan]] kanye ne- [[Democratic Republic of Congo]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu butholakala khulu eenarheni zethrophigi zenarhakazi yeAfrika [[Iphakathi le-Sehara ye-Afrika]].&lt;ref name=WHO2014/&gt; Ngo-1976 (ukutholakala kwabo ubulwelwe lobu] ukufikela ngo-2013, besele ingene yatheleleka ebantwini abangaphasii kwe-1000.&lt;ref name=WHO2014/&gt;&lt;ref name=MMWRJune2014&gt;{{Cite web|title=Ebola Viral Disease Outbreak — West Africa, 2014|url=https://www.cdc.gov/mmwr/preview/mmwrhtml/mm6325a4.htm?s_cid=mm6325a4_w|website=CDC|accessdate=26 June 2014|date=June 27, 2014}}&lt;/ref&gt; Ukuqubuka kobulwelwe lobu obukhulu obungazange khebubonwe ngilobu bamuva nje ngebe [[2014 Tjhingalanga ye-Afrika Ukuqubuka kwe-Ebola]], sebele bungene eenarheni [[Guinea]], [[Sierra Leone]], [[Liberia]] begodu ingatheleka ingene ne [[Nigeria]].&lt;ref name=CDC2014&gt;{{Cite web|title=CDC urges all US residents to avoid nonessential travel to Liberia, Guinea, and Sierra Leone because of an unprecedented outbreak of Ebola.|url=https://wwwnc.cdc.gov/travel/notices/level1/ebola-liberia|website=CDC|accessdate=2 August 2014|date=July 31, 2014}}&lt;/ref&gt;&lt;ref name=CDCAug2014N&gt;{{Cite web|title=Outbreak of Ebola in Guinea, Liberia, and Sierra Leone|url=http://www.cdc.gov/vhf/ebola/outbreaks/guinea/index.html|website=CDC|accessdate=5 August 2014|date=August 4, 2014}}&lt;/ref&gt; Ukusukela ngoRhoboyi 2014 sele kubikwe bona kunabantu esele bangenwe bulwelwe lobu abayi-1600.&lt;ref&gt;{{Cite web|title=Ebola virus disease update - West Africa|url=http://www.who.int/csr/don/2014_08_04_ebola/en/|website=WHO|accessdate=6 August 2014|date=Aug 4, 2014}}&lt;/ref&gt; Imizamo yona iyenziwa bona kutholakalle [[intatha/isihlahla]] esingalapha ubulwelwe lobu, kodwana okwanje asikho kwatholakala ipengu yakhona.&lt;ref name=WHO2014/&gt;

== Isikhombiso selwazi ==
{{Reflist|colwidth=25em}}

; IBhibhliyografu
{{Refbegin}}
* {{Cite book |last=Klenk |first=Hans-Dieter |title=Marburg and Ebola Viruses (Current Topics in Microbiology and Immunology) |date=January 1999 |publisher=Springer-Verlag Telos |location=Berlin |isbn=978-3-540-64729-4 |ref=CITEREFKlenk1999}}
* {{Cite book |first1=Hans-Dieter |last1=Klenk |first2=Heinz |last2=Feldmann |title=Ebola and Marburg viruses: molecular and cellular biology |url=https://books.google.com/books?id=EV_mFgnyPoMC&amp;redir_esc=y&amp;hl=en|format=Limited preview |year=2004 |publisher=Horizon Bioscience |location=Wymondham, Norfolk, UK |isbn=978-0-9545232-3-7 |ref=CITEREFKlenkFeldmann2004}}
* {{Cite book |last=Kuhn |first=Jens H. |title=Filoviruses: A Compendium of 40 Years of Epidemiological, Clinical, and Laboratory Studies. Archives of Virology Supplement, vol. 20 |url=https://books.google.com/books?id=LaOue0F9Ns4C&amp;redir_esc=y&amp;hl=en |format=Limited preview |year=2008 |publisher=SpringerWienNewYork |location=Vienna |isbn=978-3-211-20670-6 |ref=CITEREFKuhn2008}}
* {{Cite book |last1=McCormick |first1=Joseph |last2=Fisher-Hoch |first2=Susan |others=Horvitz, Leslie Alan |title=Level 4: Virus Hunters of the CDC |url=https://books.google.com/books?id=QEvR3aJX2m0C&amp;redir_esc=y&amp;hl=en |format=Limited preview |origyear=1996 |edition=Updated [3rd] |year=1999 |publisher=Barnes &amp; Noble |isbn=978-0-7607-1208-5 |ref=CITEREFMcCormickFisher-Hoch1999 |month=June}}
* {{Cite book |last=Pattyn |first=S. R. |title=Ebola Virus Haemorrhagic Fever |year=1978 |url=http://www.itg.be/ebola/ |format=Full free text |edition=1st |publisher=Elsevier/North-Holland Biomedical Press |location=Amsterdam |isbn=0-444-80060-3 |ref=CITEREFPattyn1978}}
* {{Cite book | last1 = Ryabchikova | first1 = Elena I. | last2 = Price | first2 = Barbara B. | title = Ebola and Marburg Viruses: A View of Infection Using Electron Microscopy | year = 2004 | publisher = Battelle Press | location = Columbus, Ohio | isbn = 978-1-57477-131-2 | ref = CITEREFRyabchikovaPrice2004 }}
{{Refend}}

== Okuhlanganiswe nalokhu okunye ==
{{Refbegin}}
* [https://viralzone.expasy.org/207.html?outline=all_by_species ViralZone: Ebola-like viruses] – Virological repository from the [[Swiss Institute of Bioinformatics]]
* [https://www.cdc.gov/ebola/about/index.html CDC: Ebola hemorrhagic fever] – Centers for Disease Control and Prevention, Special Pathogens Branch
* [https://www.who.int/health-topics/ebola WHO: Ebola haemorrhagic fever] – World Health Organization, Global Alert and Response
* [https://www.bv-brc.org/ Virus Pathogen Database and Analysis Resource (ViPR): Filoviridae]
* [https://web.archive.org/web/20140808072117/http://www.ebi.ac.uk/pdbe/emdb/searchResults.html/?q=ebola 3D macromolecular structures of the Ebola virus archived in the EM Data Bank(EMDB)]
* [https://web.archive.org/web/20140819171607/https://maps.google.com/maps/ms?msa=0&amp;msid=202977755949863934429.0004c658eb30f9c4fb1c0&amp;ie=UTF8&amp;t=h&amp;ll=27.371767,5.273438&amp;spn=110.017392,184.21875&amp;z=2&amp;source=embed&amp;dg=feature Google Map of Ebola Outbreaks]
* [https://web.archive.org/web/20140816223245/http://www.who.int/csr/bioriskreduction/filovirus_infection_control/en/ WHO recommended infection control measures]
{{Refend}}</text>
      <sha1>m6dezr4k1nx135pjmju4pm5wpj6jw6o</sha1>
    </revision>
    <revision>
      <id>3010</id>
      <parentid>2632</parentid>
      <timestamp>2025-06-06T20:24:18Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>ymutgr</comment>
      <origin>3010</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9803" sha1="1fhnjbl83t2lti73dz9ut2g4263myy2" xml:space="preserve">{{Infobox disease
| name           = Ubulwelwe be-Ebola
| image          = 7042 lores-Ebola-Zaire-CDC Photo.jpg
| caption        = Isithombe sango-1976 sabahlengikazi ababili, bajame hlanu kwaka [[Mayinga N'Seka|Mayinga N.]], omumuntu osahlelwe mumulwana we-Ebola. Wahlongakala ngemva kwamalanga ambalwa ngonobangela wobulwelwe bokopha nokurhadza kweengazi.
| DiseasesDB     = 18043
| ICD10          = {{ICD10|A|98|4|a|90}}
| ICD9           = {{ICD9|065.8}}
| MedlinePlus    = 001339
| eMedicineSubj  = med
| eMedicineTopic = 626
| MeshID         = D019142
}}
'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. Ubulwelwe be-Ebola''' nofana ('''EVD''') '''[[Wp/kri/Ebola|I-Ebola]] nomulwana wokopha iingazi okhambisana nomgomani''' ('''EHF''') mimulwana ebangwa bulwelwe bevayirasi ebizwa nge- [[Ebola]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo athoma ukubonakala phakathi kwamalanga amabili ukuya eemvekeni eentathu ngemva sewungenwe bulwelwe lobu, [[njengomgomani ongapheliko]], umphimbo obabako onesilonda, [[imisipha ebuhlungu kanye nehloko esawula kabuhlungu]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kesinye isikhathi [[ungahlanza]], uphakanyelwe ziimbindi nesifo [[sokurhuda]], kuzokwenza bona [[amaphaphu]] kanye [[neso]] zingasasebenzi kuhle.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Nasele sekufike lapha, abanye baba nomraro [[wokopha iingazi]].&lt;ref name=WHO2014&gt;{{Cite web|title=Ebola virus disease Fact sheet N°103|url=https://www.who.int/en/news-room/fact-sheets/detail/ebola-virus-disease|work=World Health Organization|accessdate=12 April 2014|date=March 2014}}&lt;/ref&gt;

&lt;!-- Cause and Diagnosis--&gt;
Umulwana lo ungangena nawuthintana [[neengazi]] zomuntu ophethwe ngibo nofana [[umjuluko]] nanyana [[okunye nokunye okusamanzana]] okuvela (eenlwaneni [[kumaphelaphelana]] nofana iimfene).&lt;ref name=WHO2014/&gt; Bekube nje umulwana akukatholakali bona ungangena ngokuwurhogela emmoyeni.&lt;ref name=WHOAir2014&gt;{{Cite web|title=2014 Ebola Virus Disease (EVD) outbreak in West Africa|url=http://www.who.int/ith/updates/20140421/en/|website=WHO|accessdate=3 August 2014|date=Apr 21 2014}}&lt;/ref&gt; Kukholelwa bonyana abomaphelaphelani bakwazi ukuphatha umulwana lo kodwana wona angaphathwa ngiwo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kwaba khona umuntu otheleleke ngomulwana lo, umulwana lo ungatheleleka kabanye abantu godu ngesikhathi esifitjhani.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amadoda angasinda ngemva kokulatjhwa angathelela abanye abantu ngokuthunda [[imbewu]] yabo lokha nabaya emsemeni nakungakapheli iinyanga ezimbili.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nakufanele uhlahlutjwe nofana uhlolelwe ubulwelwe lobu be-ebola kufanele izifo ezifana [[nomalalahlengezela]], [[isifo sokurhuda]] kanye omulwana [[wokopha iingazi okhambisana nomgomani]] inganakwa ukwenzelela ukuthola imiphumela ekungiyo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ukuqinisekisa umrabho womraro wobulwelwe lobu amasampula weengazi ayathathwa ayokuhlolelwa ubulwelwe [[nesivikelasifo seengazini]] kanye ne [[i-RNA]] lobu kanye nengongwana ebanga ubulwelwe lobu.&lt;ref name=WHO2014/&gt;

&lt;!-- Prevention --&gt;
Ukuvikela ubulwelwe lobu kungaphungulwa ukuthelelana hlangana neemfene kanye neemfarigi ezingenwe bulwelwelwe lobu bukhandelwe bona bungayi ebantwini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kungenziwa ngokobana kuhlolwe iinlwana lezi ukobana zinabo ubulwelwe lobu na, nakutholakala bona zinabo kungenzeka bona zibulawe bese kugujelwa imizimba yazo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nawupheka inyama bese wembatha izambatho zokuzivikela nakho kungakusiza,&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; ukwembatha izambatho zokuzivikela lokha nawuhlala nofana uhlanu kwaloyo muntu ongenwe mumulwana lowo [[kanye nokuhlamba izandla ngesibha]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amasampula wananyana yini esamanzana yalabo bantu abangenwe mumulwana lo kufanele zitjhejwe khulu, ubalekele ukuthintana nazo.&lt;ref name=WHO2014/&gt;

&lt;!-- Treatment, Prognosis and Epidemiology--&gt;
Ayikho intatha elapha ubulwelwe lobu; imizamo yokobana kusizwe abantu abangenwe bulwelwe lobu kukobana [[kwenziwe umtswako]] (banikelwe amanzi anetswayi) ukobana bawasele nofana [[bafakwe amadribhu azobangenisela okusamanzana emzimbeni wabo]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu [[buneembalobalo eziphezulu zabantu abafako]]: nabangenwe ngibo ubulwelwe lobu, i-ebola ingabulala pheze isiquntu-50% nofana i-90% yabantu abatheleleke ngayo.&lt;ref name=WHO2014/&gt;&lt;ref name=&quot;Elsevier/Academic Press&quot;&gt;{{Cite book|author1=C.M. Fauquet|title=Virus taxonomy classification and nomenclature of viruses; 8th report of the International Committee on Taxonomy of Viruses|date=2005|publisher=Elsevier/Academic Press|location=Oxford|isbn=9780080575483|page=648|url=http://books.google.ca/books?id=9Wy7Jgy5RWYC&amp;pg=PA648}}&lt;/ref&gt; I-EVD yathoma ukwazakala endaweni enarheni ye [[Sudan]] kanye ne- [[Democratic Republic of Congo]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu butholakala khulu eenarheni zethrophigi zenarhakazi yeAfrika [[Iphakathi le-Sehara ye-Afrika]].&lt;ref name=WHO2014/&gt; Ngo-1976 (ukutholakala kwabo ubulwelwe lobu] ukufikela ngo-2013, besele ingene yatheleleka ebantwini abangaphasii kwe-1000.&lt;ref name=WHO2014/&gt;&lt;ref name=MMWRJune2014&gt;{{Cite web|title=Ebola Viral Disease Outbreak — West Africa, 2014|url=https://www.cdc.gov/mmwr/preview/mmwrhtml/mm6325a4.htm?s_cid=mm6325a4_w|website=CDC|accessdate=26 June 2014|date=June 27, 2014}}&lt;/ref&gt; Ukuqubuka kobulwelwe lobu obukhulu obungazange khebubonwe ngilobu bamuva nje ngebe [[2014 Tjhingalanga ye-Afrika Ukuqubuka kwe-Ebola]], sebele bungene eenarheni [[Guinea]], [[Sierra Leone]], [[Liberia]] begodu ingatheleka ingene ne [[Nigeria]].&lt;ref name=CDC2014&gt;{{Cite web|title=CDC urges all US residents to avoid nonessential travel to Liberia, Guinea, and Sierra Leone because of an unprecedented outbreak of Ebola.|url=https://wwwnc.cdc.gov/travel/notices/level1/ebola-liberia|website=CDC|accessdate=2 August 2014|date=July 31, 2014}}&lt;/ref&gt;&lt;ref name=CDCAug2014N&gt;{{Cite web|title=Outbreak of Ebola in Guinea, Liberia, and Sierra Leone|url=http://www.cdc.gov/vhf/ebola/outbreaks/guinea/index.html|website=CDC|accessdate=5 August 2014|date=August 4, 2014}}&lt;/ref&gt; Ukusukela ngoRhoboyi 2014 sele kubikwe bona kunabantu esele bangenwe bulwelwe lobu abayi-1600.&lt;ref&gt;{{Cite web|title=Ebola virus disease update - West Africa|url=http://www.who.int/csr/don/2014_08_04_ebola/en/|website=WHO|accessdate=6 August 2014|date=Aug 4, 2014}}&lt;/ref&gt; Imizamo yona iyenziwa bona kutholakalle [[intatha/isihlahla]] esingalapha ubulwelwe lobu, kodwana okwanje asikho kwatholakala ipengu yakhona.&lt;ref name=WHO2014/&gt;

== Isikhombiso selwazi ==
{{Reflist|colwidth=25em}}

; IBhibhliyografu
{{Refbegin}}
* {{Cite book |last=Klenk |first=Hans-Dieter |title=Marburg and Ebola Viruses (Current Topics in Microbiology and Immunology) |date=January 1999 |publisher=Springer-Verlag Telos |location=Berlin |isbn=978-3-540-64729-4 |ref=CITEREFKlenk1999}}
* {{Cite book |first1=Hans-Dieter |last1=Klenk |first2=Heinz |last2=Feldmann |title=Ebola and Marburg viruses: molecular and cellular biology |url=https://books.google.com/books?id=EV_mFgnyPoMC&amp;redir_esc=y&amp;hl=en|format=Limited preview |year=2004 |publisher=Horizon Bioscience |location=Wymondham, Norfolk, UK |isbn=978-0-9545232-3-7 |ref=CITEREFKlenkFeldmann2004}}
* {{Cite book |last=Kuhn |first=Jens H. |title=Filoviruses: A Compendium of 40 Years of Epidemiological, Clinical, and Laboratory Studies. Archives of Virology Supplement, vol. 20 |url=https://books.google.com/books?id=LaOue0F9Ns4C&amp;redir_esc=y&amp;hl=en |format=Limited preview |year=2008 |publisher=SpringerWienNewYork |location=Vienna |isbn=978-3-211-20670-6 |ref=CITEREFKuhn2008}}
* {{Cite book |last1=McCormick |first1=Joseph |last2=Fisher-Hoch |first2=Susan |others=Horvitz, Leslie Alan |title=Level 4: Virus Hunters of the CDC |url=https://books.google.com/books?id=QEvR3aJX2m0C&amp;redir_esc=y&amp;hl=en |format=Limited preview |origyear=1996 |edition=Updated [3rd] |year=1999 |publisher=Barnes &amp; Noble |isbn=978-0-7607-1208-5 |ref=CITEREFMcCormickFisher-Hoch1999 |month=June}}
* {{Cite book |last=Pattyn |first=S. R. |title=Ebola Virus Haemorrhagic Fever |year=1978 |url=http://www.itg.be/ebola/ |format=Full free text |edition=1st |publisher=Elsevier/North-Holland Biomedical Press |location=Amsterdam |isbn=0-444-80060-3 |ref=CITEREFPattyn1978}}
* {{Cite book | last1 = Ryabchikova | first1 = Elena I. | last2 = Price | first2 = Barbara B. | title = Ebola and Marburg Viruses: A View of Infection Using Electron Microscopy | year = 2004 | publisher = Battelle Press | location = Columbus, Ohio | isbn = 978-1-57477-131-2 | ref = CITEREFRyabchikovaPrice2004 }}
{{Refend}}

== Okuhlanganiswe nalokhu okunye ==
{{Refbegin}}
* [https://viralzone.expasy.org/207.html?outline=all_by_species ViralZone: Ebola-like viruses] – Virological repository from the [[Swiss Institute of Bioinformatics]]
* [https://www.cdc.gov/ebola/about/index.html CDC: Ebola hemorrhagic fever] – Centers for Disease Control and Prevention, Special Pathogens Branch
* [https://www.who.int/health-topics/ebola WHO: Ebola haemorrhagic fever] – World Health Organization, Global Alert and Response
* [https://www.bv-brc.org/ Virus Pathogen Database and Analysis Resource (ViPR): Filoviridae]
* [https://web.archive.org/web/20140808072117/http://www.ebi.ac.uk/pdbe/emdb/searchResults.html/?q=ebola 3D macromolecular structures of the Ebola virus archived in the EM Data Bank(EMDB)]
* [https://web.archive.org/web/20140819171607/https://maps.google.com/maps/ms?msa=0&amp;msid=202977755949863934429.0004c658eb30f9c4fb1c0&amp;ie=UTF8&amp;t=h&amp;ll=27.371767,5.273438&amp;spn=110.017392,184.21875&amp;z=2&amp;source=embed&amp;dg=feature Google Map of Ebola Outbreaks]
* [https://web.archive.org/web/20140816223245/http://www.who.int/csr/bioriskreduction/filovirus_infection_control/en/ WHO recommended infection control measures]
{{Refend}}</text>
      <sha1>1fhnjbl83t2lti73dz9ut2g4263myy2</sha1>
    </revision>
    <revision>
      <id>3126</id>
      <parentid>3010</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Rachmat04|Rachmat04]]</comment>
      <origin>2632</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9722" sha1="m6dezr4k1nx135pjmju4pm5wpj6jw6o" xml:space="preserve">{{Infobox disease
| name           = Ubulwelwe be-Ebola
| image          = 7042 lores-Ebola-Zaire-CDC Photo.jpg
| caption        = Isithombe sango-1976 sabahlengikazi ababili, bajame hlanu kwaka [[Mayinga N'Seka|Mayinga N.]], omumuntu osahlelwe mumulwana we-Ebola. Wahlongakala ngemva kwamalanga ambalwa ngonobangela wobulwelwe bokopha nokurhadza kweengazi.
| DiseasesDB     = 18043
| ICD10          = {{ICD10|A|98|4|a|90}}
| ICD9           = {{ICD9|065.8}}
| MedlinePlus    = 001339
| eMedicineSubj  = med
| eMedicineTopic = 626
| MeshID         = D019142
}}
'''Ubulwelwe be-Ebola''' nofana ('''EVD''') '''[[Wp/kri/Ebola|I-Ebola]] nomulwana wokopha iingazi okhambisana nomgomani''' ('''EHF''') mimulwana ebangwa bulwelwe bevayirasi ebizwa nge- [[Ebola]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo athoma ukubonakala phakathi kwamalanga amabili ukuya eemvekeni eentathu ngemva sewungenwe bulwelwe lobu, [[njengomgomani ongapheliko]], umphimbo obabako onesilonda, [[imisipha ebuhlungu kanye nehloko esawula kabuhlungu]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kesinye isikhathi [[ungahlanza]], uphakanyelwe ziimbindi nesifo [[sokurhuda]], kuzokwenza bona [[amaphaphu]] kanye [[neso]] zingasasebenzi kuhle.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Nasele sekufike lapha, abanye baba nomraro [[wokopha iingazi]].&lt;ref name=WHO2014&gt;{{Cite web|title=Ebola virus disease Fact sheet N°103|url=https://www.who.int/en/news-room/fact-sheets/detail/ebola-virus-disease|work=World Health Organization|accessdate=12 April 2014|date=March 2014}}&lt;/ref&gt;

&lt;!-- Cause and Diagnosis--&gt;
Umulwana lo ungangena nawuthintana [[neengazi]] zomuntu ophethwe ngibo nofana [[umjuluko]] nanyana [[okunye nokunye okusamanzana]] okuvela (eenlwaneni [[kumaphelaphelana]] nofana iimfene).&lt;ref name=WHO2014/&gt; Bekube nje umulwana akukatholakali bona ungangena ngokuwurhogela emmoyeni.&lt;ref name=WHOAir2014&gt;{{Cite web|title=2014 Ebola Virus Disease (EVD) outbreak in West Africa|url=http://www.who.int/ith/updates/20140421/en/|website=WHO|accessdate=3 August 2014|date=Apr 21 2014}}&lt;/ref&gt; Kukholelwa bonyana abomaphelaphelani bakwazi ukuphatha umulwana lo kodwana wona angaphathwa ngiwo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kwaba khona umuntu otheleleke ngomulwana lo, umulwana lo ungatheleleka kabanye abantu godu ngesikhathi esifitjhani.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amadoda angasinda ngemva kokulatjhwa angathelela abanye abantu ngokuthunda [[imbewu]] yabo lokha nabaya emsemeni nakungakapheli iinyanga ezimbili.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nakufanele uhlahlutjwe nofana uhlolelwe ubulwelwe lobu be-ebola kufanele izifo ezifana [[nomalalahlengezela]], [[isifo sokurhuda]] kanye omulwana [[wokopha iingazi okhambisana nomgomani]] inganakwa ukwenzelela ukuthola imiphumela ekungiyo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ukuqinisekisa umrabho womraro wobulwelwe lobu amasampula weengazi ayathathwa ayokuhlolelwa ubulwelwe [[nesivikelasifo seengazini]] kanye ne [[i-RNA]] lobu kanye nengongwana ebanga ubulwelwe lobu.&lt;ref name=WHO2014/&gt;

&lt;!-- Prevention --&gt;
Ukuvikela ubulwelwe lobu kungaphungulwa ukuthelelana hlangana neemfene kanye neemfarigi ezingenwe bulwelwelwe lobu bukhandelwe bona bungayi ebantwini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kungenziwa ngokobana kuhlolwe iinlwana lezi ukobana zinabo ubulwelwe lobu na, nakutholakala bona zinabo kungenzeka bona zibulawe bese kugujelwa imizimba yazo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nawupheka inyama bese wembatha izambatho zokuzivikela nakho kungakusiza,&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; ukwembatha izambatho zokuzivikela lokha nawuhlala nofana uhlanu kwaloyo muntu ongenwe mumulwana lowo [[kanye nokuhlamba izandla ngesibha]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amasampula wananyana yini esamanzana yalabo bantu abangenwe mumulwana lo kufanele zitjhejwe khulu, ubalekele ukuthintana nazo.&lt;ref name=WHO2014/&gt;

&lt;!-- Treatment, Prognosis and Epidemiology--&gt;
Ayikho intatha elapha ubulwelwe lobu; imizamo yokobana kusizwe abantu abangenwe bulwelwe lobu kukobana [[kwenziwe umtswako]] (banikelwe amanzi anetswayi) ukobana bawasele nofana [[bafakwe amadribhu azobangenisela okusamanzana emzimbeni wabo]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu [[buneembalobalo eziphezulu zabantu abafako]]: nabangenwe ngibo ubulwelwe lobu, i-ebola ingabulala pheze isiquntu-50% nofana i-90% yabantu abatheleleke ngayo.&lt;ref name=WHO2014/&gt;&lt;ref name=&quot;Elsevier/Academic Press&quot;&gt;{{Cite book|author1=C.M. Fauquet|title=Virus taxonomy classification and nomenclature of viruses; 8th report of the International Committee on Taxonomy of Viruses|date=2005|publisher=Elsevier/Academic Press|location=Oxford|isbn=9780080575483|page=648|url=http://books.google.ca/books?id=9Wy7Jgy5RWYC&amp;pg=PA648}}&lt;/ref&gt; I-EVD yathoma ukwazakala endaweni enarheni ye [[Sudan]] kanye ne- [[Democratic Republic of Congo]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu butholakala khulu eenarheni zethrophigi zenarhakazi yeAfrika [[Iphakathi le-Sehara ye-Afrika]].&lt;ref name=WHO2014/&gt; Ngo-1976 (ukutholakala kwabo ubulwelwe lobu] ukufikela ngo-2013, besele ingene yatheleleka ebantwini abangaphasii kwe-1000.&lt;ref name=WHO2014/&gt;&lt;ref name=MMWRJune2014&gt;{{Cite web|title=Ebola Viral Disease Outbreak — West Africa, 2014|url=https://www.cdc.gov/mmwr/preview/mmwrhtml/mm6325a4.htm?s_cid=mm6325a4_w|website=CDC|accessdate=26 June 2014|date=June 27, 2014}}&lt;/ref&gt; Ukuqubuka kobulwelwe lobu obukhulu obungazange khebubonwe ngilobu bamuva nje ngebe [[2014 Tjhingalanga ye-Afrika Ukuqubuka kwe-Ebola]], sebele bungene eenarheni [[Guinea]], [[Sierra Leone]], [[Liberia]] begodu ingatheleka ingene ne [[Nigeria]].&lt;ref name=CDC2014&gt;{{Cite web|title=CDC urges all US residents to avoid nonessential travel to Liberia, Guinea, and Sierra Leone because of an unprecedented outbreak of Ebola.|url=https://wwwnc.cdc.gov/travel/notices/level1/ebola-liberia|website=CDC|accessdate=2 August 2014|date=July 31, 2014}}&lt;/ref&gt;&lt;ref name=CDCAug2014N&gt;{{Cite web|title=Outbreak of Ebola in Guinea, Liberia, and Sierra Leone|url=http://www.cdc.gov/vhf/ebola/outbreaks/guinea/index.html|website=CDC|accessdate=5 August 2014|date=August 4, 2014}}&lt;/ref&gt; Ukusukela ngoRhoboyi 2014 sele kubikwe bona kunabantu esele bangenwe bulwelwe lobu abayi-1600.&lt;ref&gt;{{Cite web|title=Ebola virus disease update - West Africa|url=http://www.who.int/csr/don/2014_08_04_ebola/en/|website=WHO|accessdate=6 August 2014|date=Aug 4, 2014}}&lt;/ref&gt; Imizamo yona iyenziwa bona kutholakalle [[intatha/isihlahla]] esingalapha ubulwelwe lobu, kodwana okwanje asikho kwatholakala ipengu yakhona.&lt;ref name=WHO2014/&gt;

== Isikhombiso selwazi ==
{{Reflist|colwidth=25em}}

; IBhibhliyografu
{{Refbegin}}
* {{Cite book |last=Klenk |first=Hans-Dieter |title=Marburg and Ebola Viruses (Current Topics in Microbiology and Immunology) |date=January 1999 |publisher=Springer-Verlag Telos |location=Berlin |isbn=978-3-540-64729-4 |ref=CITEREFKlenk1999}}
* {{Cite book |first1=Hans-Dieter |last1=Klenk |first2=Heinz |last2=Feldmann |title=Ebola and Marburg viruses: molecular and cellular biology |url=https://books.google.com/books?id=EV_mFgnyPoMC&amp;redir_esc=y&amp;hl=en|format=Limited preview |year=2004 |publisher=Horizon Bioscience |location=Wymondham, Norfolk, UK |isbn=978-0-9545232-3-7 |ref=CITEREFKlenkFeldmann2004}}
* {{Cite book |last=Kuhn |first=Jens H. |title=Filoviruses: A Compendium of 40 Years of Epidemiological, Clinical, and Laboratory Studies. Archives of Virology Supplement, vol. 20 |url=https://books.google.com/books?id=LaOue0F9Ns4C&amp;redir_esc=y&amp;hl=en |format=Limited preview |year=2008 |publisher=SpringerWienNewYork |location=Vienna |isbn=978-3-211-20670-6 |ref=CITEREFKuhn2008}}
* {{Cite book |last1=McCormick |first1=Joseph |last2=Fisher-Hoch |first2=Susan |others=Horvitz, Leslie Alan |title=Level 4: Virus Hunters of the CDC |url=https://books.google.com/books?id=QEvR3aJX2m0C&amp;redir_esc=y&amp;hl=en |format=Limited preview |origyear=1996 |edition=Updated [3rd] |year=1999 |publisher=Barnes &amp; Noble |isbn=978-0-7607-1208-5 |ref=CITEREFMcCormickFisher-Hoch1999 |month=June}}
* {{Cite book |last=Pattyn |first=S. R. |title=Ebola Virus Haemorrhagic Fever |year=1978 |url=http://www.itg.be/ebola/ |format=Full free text |edition=1st |publisher=Elsevier/North-Holland Biomedical Press |location=Amsterdam |isbn=0-444-80060-3 |ref=CITEREFPattyn1978}}
* {{Cite book | last1 = Ryabchikova | first1 = Elena I. | last2 = Price | first2 = Barbara B. | title = Ebola and Marburg Viruses: A View of Infection Using Electron Microscopy | year = 2004 | publisher = Battelle Press | location = Columbus, Ohio | isbn = 978-1-57477-131-2 | ref = CITEREFRyabchikovaPrice2004 }}
{{Refend}}

== Okuhlanganiswe nalokhu okunye ==
{{Refbegin}}
* [https://viralzone.expasy.org/207.html?outline=all_by_species ViralZone: Ebola-like viruses] – Virological repository from the [[Swiss Institute of Bioinformatics]]
* [https://www.cdc.gov/ebola/about/index.html CDC: Ebola hemorrhagic fever] – Centers for Disease Control and Prevention, Special Pathogens Branch
* [https://www.who.int/health-topics/ebola WHO: Ebola haemorrhagic fever] – World Health Organization, Global Alert and Response
* [https://www.bv-brc.org/ Virus Pathogen Database and Analysis Resource (ViPR): Filoviridae]
* [https://web.archive.org/web/20140808072117/http://www.ebi.ac.uk/pdbe/emdb/searchResults.html/?q=ebola 3D macromolecular structures of the Ebola virus archived in the EM Data Bank(EMDB)]
* [https://web.archive.org/web/20140819171607/https://maps.google.com/maps/ms?msa=0&amp;msid=202977755949863934429.0004c658eb30f9c4fb1c0&amp;ie=UTF8&amp;t=h&amp;ll=27.371767,5.273438&amp;spn=110.017392,184.21875&amp;z=2&amp;source=embed&amp;dg=feature Google Map of Ebola Outbreaks]
* [https://web.archive.org/web/20140816223245/http://www.who.int/csr/bioriskreduction/filovirus_infection_control/en/ WHO recommended infection control measures]
{{Refend}}</text>
      <sha1>m6dezr4k1nx135pjmju4pm5wpj6jw6o</sha1>
    </revision>
    <revision>
      <id>5097</id>
      <parentid>3126</parentid>
      <timestamp>2025-08-08T09:40:01Z</timestamp>
      <contributor>
        <username>T Ntuli</username>
        <id>844</id>
      </contributor>
      <origin>5097</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9702" sha1="a6x7yu4vfb22evwb0zi4ftmpo2l75o7" xml:space="preserve">{{Infobox disease
| name           = Ubulwelwe be-Ebola
| image          = 7042 lores-Ebola-Zaire-CDC Photo.jpg
| caption        = Isithombe sango-1976 sabahlengikazi ababili, bajame hlanu kwaka [[Mayinga N'Seka|Mayinga N.]], omumuntu osahlelwe mumulwana we-Ebola. Wahlongakala ngemva kwamalanga ambalwa ngonobangela wobulwelwe bokopha nokurhadza kweengazi.
| DiseasesDB     = 18043
| ICD10          = {{ICD10|A|98|4|a|90}}
| ICD9           = {{ICD9|065.8}}
| MedlinePlus    = 001339
| eMedicineSubj  = med
| eMedicineTopic = 626
| MeshID         = D019142
}}
'''Ubulwelwe be-Ebola''' nofana ('''EVD''') '''[[Wp/kri/Ebola|I-Ebola]] nomulwana wokopha iingazi okhambisana nomgomani''' ('''EHF''') mimulwana ebangwa bulwelwe bevayirasi ebizwa nge- [[Ebola]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo athoma ukubonakala phakathi kwamalanga amabili ukuya eemvekeni eentathu ngemva sewungenwe bulwelwe lobu, [[njengomgomani ongapheliko]], umphimbo obabako onesilonda, [[imisipha ebuhlungu kanye nehloko esawula kabuhlungu]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kesinye isikhathi [[ungahlanza]], uphakanyelwe ziimbindi nesifo [[sokurhuda]], kuzokwenza bona [[amaphaphu]] kanye [[neso]] zingasasebenzi kuhle.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Nasele sekufike lapha, abanye baba nomraro [[wokopha iingazi]].&lt;ref name=WHO2014&gt;{{Cite web|title=Ebola virus disease Fact sheet N°103|url=https://www.who.int/en/news-room/fact-sheets/detail/ebola-virus-disease|work=World Health Organization|accessdate=12 April 2014|date=March 2014}}&lt;/ref&gt;

&lt;!-- Cause and Diagnosis--&gt;
Umulwana lo ungangena nawuthintana [[neengazi]] zomuntu ophethwe ngibo nofana [[umjuluko]] nanyana [[okunye nokunye okusamanzana]] okuvela (eenlwaneni [[kumaphelaphelana]] nofana iimfene).&lt;ref name=WHO2014/&gt; Bekube nje umulwana akukatholakali bona ungangena ngokuwurhogela emmoyeni.&lt;ref name=WHOAir2014&gt;{{Cite web|title=2014 Ebola Virus Disease (EVD) outbreak in West Africa|url=http://www.who.int/ith/updates/20140421/en/|website=WHO|accessdate=3 August 2014|date=Apr 21 2014}}&lt;/ref&gt; Kukholelwa bonyana abomaphelaphelani bakwazi ukuphatha ubugulo lobu kodwana wona angaphathwa ngiwo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kwaba khona umuntu otheleleke ngomulwana lo, umulwana lo ungatheleleka kabanye abantu godu ngesikhathi esifitjhani.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amadoda angasinda ngemva kokulatjhwa angathelela abanye abantu ngokuthunda [[imbewu]] yabo lokha nabaya emsemeni nakungakapheli iinyanga ezimbili.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nakufanele uhlahlutjwe nofana uhlolelwe ubulwelwe lobu be-ebola kufanele izifo ezifana [[nomalalahlengezela]], [[isifo sokurhuda]] kanye omulwana [[wokopha iingazi okhambisana nomgomani]] inganakwa ukwenzelela ukuthola imiphumela ekungiyo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ukuqinisekisa umrabhu womraro wobulwelwe lobu amasampula weengazi ayathathwa ayokuhlolelwa ubugulo [[nesivikelasifo seengazini]] kanye ne [[i-RNA]] lobu kanye nengongwana ebanga ubugulo lobu.&lt;ref name=WHO2014/&gt;

&lt;!-- Prevention --&gt;
Ukuvikela ubugulo lobu kungaphungula ukuthelelana hlangana neemfene kanye neemfarigi ezingenwe bugulo lobu bukhandelwe bona bungayi ebantwini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kungenziwa ngokobana kuhlolwe iinlwana lezi ukobana zinabo ukugula lokhu  na, nakutholakala bona zinabo kungenzeka bona zibulawe bese kugujelwa imizimba yazo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nawupheka inyama bese wembatha izambatho zokuzivikela nakho kungakusiza,&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; ukwembatha izambatho zokuzivikela lokha nawuhlala nofana ukwaloyo muntu ongenwe bugulo lowo [[kanye nokuhlamba izandla ngesibha]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amasampula wananyana yini esamanzana yalabo bantu abangenwe mumulwana lo kufanele zitjhejwe khulu, ubalekele ukuthintana nazo.&lt;ref name=WHO2014/&gt;

&lt;!-- Treatment, Prognosis and Epidemiology--&gt;
Ayikho intatha elapha ubulwelwe lobu; imizamo yokobana kusizwe abantu abangenwe bulwelwe lobu kukobana [[kwenziwe umtswako]] (banikelwe amanzi anetswayi) ukobana bawasele nofana [[bafakwe amadribhu azobangenisela okusamanzana emzimbeni wabo]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu [[buneembalobalo eziphezulu zabantu abafako]]: nabangenwe ngibo ubulwelwe lobu, i-ebola ingabulala pheze isiquntu-50% nofana i-90% yabantu abatheleleke ngayo.&lt;ref name=WHO2014/&gt;&lt;ref name=&quot;Elsevier/Academic Press&quot;&gt;{{Cite book|author1=C.M. Fauquet|title=Virus taxonomy classification and nomenclature of viruses; 8th report of the International Committee on Taxonomy of Viruses|date=2005|publisher=Elsevier/Academic Press|location=Oxford|isbn=9780080575483|page=648|url=http://books.google.ca/books?id=9Wy7Jgy5RWYC&amp;pg=PA648}}&lt;/ref&gt; I-EVD yathoma ukwazakala endaweni enarheni ye [[Sudan]] kanye ne- [[Democratic Republic of Congo]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu butholakala khulu eenarheni zethrophigi zenarhakazi yeAfrika [[Iphakathi le-Sehara ye-Afrika]].&lt;ref name=WHO2014/&gt; Ngo-1976 (ukutholakala kwabo ubulwelwe lobu] ukufikela ngo-2013, besele ingene yatheleleka ebantwini abangaphasii kwe-1000.&lt;ref name=WHO2014/&gt;&lt;ref name=MMWRJune2014&gt;{{Cite web|title=Ebola Viral Disease Outbreak — West Africa, 2014|url=https://www.cdc.gov/mmwr/preview/mmwrhtml/mm6325a4.htm?s_cid=mm6325a4_w|website=CDC|accessdate=26 June 2014|date=June 27, 2014}}&lt;/ref&gt; Ukuqubuka kobulwelwe lobu obukhulu obungazange khebubonwe ngilobu bamuva nje ngebe [[2014 Tjhingalanga ye-Afrika Ukuqubuka kwe-Ebola]], sebele bungene eenarheni [[Guinea]], [[Sierra Leone]], [[Liberia]] begodu ingatheleka ingene ne [[Nigeria]].&lt;ref name=CDC2014&gt;{{Cite web|title=CDC urges all US residents to avoid nonessential travel to Liberia, Guinea, and Sierra Leone because of an unprecedented outbreak of Ebola.|url=https://wwwnc.cdc.gov/travel/notices/level1/ebola-liberia|website=CDC|accessdate=2 August 2014|date=July 31, 2014}}&lt;/ref&gt;&lt;ref name=CDCAug2014N&gt;{{Cite web|title=Outbreak of Ebola in Guinea, Liberia, and Sierra Leone|url=http://www.cdc.gov/vhf/ebola/outbreaks/guinea/index.html|website=CDC|accessdate=5 August 2014|date=August 4, 2014}}&lt;/ref&gt; Ukusukela ngoRhoboyi 2014 sele kubikwe bona kunabantu esele bangenwe bulwelwe lobu abayi-1600.&lt;ref&gt;{{Cite web|title=Ebola virus disease update - West Africa|url=http://www.who.int/csr/don/2014_08_04_ebola/en/|website=WHO|accessdate=6 August 2014|date=Aug 4, 2014}}&lt;/ref&gt; Imizamo yona iyenziwa bona kutholakalle [[intatha/isihlahla]] esingalapha ubulwelwe lobu, kodwana okwanje asikho kwatholakala ipengu yakhona.&lt;ref name=WHO2014/&gt;

== Isikhombiso selwazi ==
{{Reflist|colwidth=25em}}

; IBhibhliyografu
{{Refbegin}}
* {{Cite book |last=Klenk |first=Hans-Dieter |title=Marburg and Ebola Viruses (Current Topics in Microbiology and Immunology) |date=January 1999 |publisher=Springer-Verlag Telos |location=Berlin |isbn=978-3-540-64729-4 |ref=CITEREFKlenk1999}}
* {{Cite book |first1=Hans-Dieter |last1=Klenk |first2=Heinz |last2=Feldmann |title=Ebola and Marburg viruses: molecular and cellular biology |url=https://books.google.com/books?id=EV_mFgnyPoMC&amp;redir_esc=y&amp;hl=en|format=Limited preview |year=2004 |publisher=Horizon Bioscience |location=Wymondham, Norfolk, UK |isbn=978-0-9545232-3-7 |ref=CITEREFKlenkFeldmann2004}}
* {{Cite book |last=Kuhn |first=Jens H. |title=Filoviruses: A Compendium of 40 Years of Epidemiological, Clinical, and Laboratory Studies. Archives of Virology Supplement, vol. 20 |url=https://books.google.com/books?id=LaOue0F9Ns4C&amp;redir_esc=y&amp;hl=en |format=Limited preview |year=2008 |publisher=SpringerWienNewYork |location=Vienna |isbn=978-3-211-20670-6 |ref=CITEREFKuhn2008}}
* {{Cite book |last1=McCormick |first1=Joseph |last2=Fisher-Hoch |first2=Susan |others=Horvitz, Leslie Alan |title=Level 4: Virus Hunters of the CDC |url=https://books.google.com/books?id=QEvR3aJX2m0C&amp;redir_esc=y&amp;hl=en |format=Limited preview |origyear=1996 |edition=Updated [3rd] |year=1999 |publisher=Barnes &amp; Noble |isbn=978-0-7607-1208-5 |ref=CITEREFMcCormickFisher-Hoch1999 |month=June}}
* {{Cite book |last=Pattyn |first=S. R. |title=Ebola Virus Haemorrhagic Fever |year=1978 |url=http://www.itg.be/ebola/ |format=Full free text |edition=1st |publisher=Elsevier/North-Holland Biomedical Press |location=Amsterdam |isbn=0-444-80060-3 |ref=CITEREFPattyn1978}}
* {{Cite book | last1 = Ryabchikova | first1 = Elena I. | last2 = Price | first2 = Barbara B. | title = Ebola and Marburg Viruses: A View of Infection Using Electron Microscopy | year = 2004 | publisher = Battelle Press | location = Columbus, Ohio | isbn = 978-1-57477-131-2 | ref = CITEREFRyabchikovaPrice2004 }}
{{Refend}}

== Okuhlanganiswe nalokhu okunye ==
{{Refbegin}}
* [https://viralzone.expasy.org/207.html?outline=all_by_species ViralZone: Ebola-like viruses] – Virological repository from the [[Swiss Institute of Bioinformatics]]
* [https://www.cdc.gov/ebola/about/index.html CDC: Ebola hemorrhagic fever] – Centers for Disease Control and Prevention, Special Pathogens Branch
* [https://www.who.int/health-topics/ebola WHO: Ebola haemorrhagic fever] – World Health Organization, Global Alert and Response
* [https://www.bv-brc.org/ Virus Pathogen Database and Analysis Resource (ViPR): Filoviridae]
* [https://web.archive.org/web/20140808072117/http://www.ebi.ac.uk/pdbe/emdb/searchResults.html/?q=ebola 3D macromolecular structures of the Ebola virus archived in the EM Data Bank(EMDB)]
* [https://web.archive.org/web/20140819171607/https://maps.google.com/maps/ms?msa=0&amp;msid=202977755949863934429.0004c658eb30f9c4fb1c0&amp;ie=UTF8&amp;t=h&amp;ll=27.371767,5.273438&amp;spn=110.017392,184.21875&amp;z=2&amp;source=embed&amp;dg=feature Google Map of Ebola Outbreaks]
* [https://web.archive.org/web/20140816223245/http://www.who.int/csr/bioriskreduction/filovirus_infection_control/en/ WHO recommended infection control measures]
{{Refend}}</text>
      <sha1>a6x7yu4vfb22evwb0zi4ftmpo2l75o7</sha1>
    </revision>
    <revision>
      <id>5219</id>
      <parentid>5097</parentid>
      <timestamp>2025-08-20T13:10:10Z</timestamp>
      <contributor>
        <username>History012</username>
        <id>863</id>
      </contributor>
      <origin>5219</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9681" sha1="b493vgxj73yqx817lfq8id5cpt2fvch" xml:space="preserve">{{infobox disease
| Name           = Isifo seGciwane le-Ebola&lt;br /&gt;(Ebola virus disease)
| Image          = 7042 lores-Ebola-Zaire-CDC Photo.jpg
| Caption        = Umfanekiso wabongikazi ababili bema phambi kukaMayinga N., ogulayo ngesifo se-Ebola. Wafa emavikini ambalwa kamuva ngenxa yokopha ngaphakathi okukhulu. Lathathwa ngo-1976.
| DiseasesDB     = 18043
| ICD10          = {{ICD10|A|98|4|a|90}}
| ICD9           = {{ICD9|065.8}}
| MedlinePlus    = 001339
| eMedicineSubj  = med
| eMedicineTopic = 626
| MeshID         = D019142
}}

'''Ubulwelwe be-Ebola''' nofana ('''EVD''') '''[[Wp/kri/Ebola|I-Ebola]] nomulwana wokopha iingazi okhambisana nomgomani''' ('''EHF''') mimulwana ebangwa bulwelwe bevayirasi ebizwa nge- [[Ebola]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo athoma ukubonakala phakathi kwamalanga amabili ukuya eemvekeni eentathu ngemva sewungenwe bulwelwe lobu, [[njengomgomani ongapheliko]], umphimbo obabako onesilonda, [[imisipha ebuhlungu kanye nehloko esawula kabuhlungu]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kesinye isikhathi [[ungahlanza]], uphakanyelwe ziimbindi nesifo [[sokurhuda]], kuzokwenza bona [[amaphaphu]] kanye [[neso]] zingasasebenzi kuhle.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Nasele sekufike lapha, abanye baba nomraro [[wokopha iingazi]].&lt;ref name=WHO2014&gt;{{Cite web|title=Ebola virus disease Fact sheet N°103|url=https://www.who.int/en/news-room/fact-sheets/detail/ebola-virus-disease|work=World Health Organization|accessdate=12 April 2014|date=March 2014}}&lt;/ref&gt;

&lt;!-- Cause and Diagnosis--&gt;
Umulwana lo ungangena nawuthintana [[neengazi]] zomuntu ophethwe ngibo nofana [[umjuluko]] nanyana [[okunye nokunye okusamanzana]] okuvela (eenlwaneni [[kumaphelaphelana]] nofana iimfene).&lt;ref name=WHO2014/&gt; Bekube nje umulwana akukatholakali bona ungangena ngokuwurhogela emmoyeni.&lt;ref name=WHOAir2014&gt;{{Cite web|title=2014 Ebola Virus Disease (EVD) outbreak in West Africa|url=http://www.who.int/ith/updates/20140421/en/|website=WHO|accessdate=3 August 2014|date=Apr 21 2014}}&lt;/ref&gt; Kukholelwa bonyana abomaphelaphelani bakwazi ukuphatha ubugulo lobu kodwana wona angaphathwa ngiwo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kwaba khona umuntu otheleleke ngomulwana lo, umulwana lo ungatheleleka kabanye abantu godu ngesikhathi esifitjhani.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amadoda angasinda ngemva kokulatjhwa angathelela abanye abantu ngokuthunda [[imbewu]] yabo lokha nabaya emsemeni nakungakapheli iinyanga ezimbili.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nakufanele uhlahlutjwe nofana uhlolelwe ubulwelwe lobu be-ebola kufanele izifo ezifana [[nomalalahlengezela]], [[isifo sokurhuda]] kanye omulwana [[wokopha iingazi okhambisana nomgomani]] inganakwa ukwenzelela ukuthola imiphumela ekungiyo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ukuqinisekisa umrabhu womraro wobulwelwe lobu amasampula weengazi ayathathwa ayokuhlolelwa ubugulo [[nesivikelasifo seengazini]] kanye ne [[i-RNA]] lobu kanye nengongwana ebanga ubugulo lobu.&lt;ref name=WHO2014/&gt;

&lt;!-- Prevention --&gt;
Ukuvikela ubugulo lobu kungaphungula ukuthelelana hlangana neemfene kanye neemfarigi ezingenwe bugulo lobu bukhandelwe bona bungayi ebantwini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kungenziwa ngokobana kuhlolwe iinlwana lezi ukobana zinabo ukugula lokhu  na, nakutholakala bona zinabo kungenzeka bona zibulawe bese kugujelwa imizimba yazo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nawupheka inyama bese wembatha izambatho zokuzivikela nakho kungakusiza,&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; ukwembatha izambatho zokuzivikela lokha nawuhlala nofana ukwaloyo muntu ongenwe bugulo lowo [[kanye nokuhlamba izandla ngesibha]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amasampula wananyana yini esamanzana yalabo bantu abangenwe mumulwana lo kufanele zitjhejwe khulu, ubalekele ukuthintana nazo.&lt;ref name=WHO2014/&gt;

&lt;!-- Treatment, Prognosis and Epidemiology--&gt;
Ayikho intatha elapha ubulwelwe lobu; imizamo yokobana kusizwe abantu abangenwe bulwelwe lobu kukobana [[kwenziwe umtswako]] (banikelwe amanzi anetswayi) ukobana bawasele nofana [[bafakwe amadribhu azobangenisela okusamanzana emzimbeni wabo]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu [[buneembalobalo eziphezulu zabantu abafako]]: nabangenwe ngibo ubulwelwe lobu, i-ebola ingabulala pheze isiquntu-50% nofana i-90% yabantu abatheleleke ngayo.&lt;ref name=WHO2014/&gt;&lt;ref name=&quot;Elsevier/Academic Press&quot;&gt;{{Cite book|author1=C.M. Fauquet|title=Virus taxonomy classification and nomenclature of viruses; 8th report of the International Committee on Taxonomy of Viruses|date=2005|publisher=Elsevier/Academic Press|location=Oxford|isbn=9780080575483|page=648|url=http://books.google.ca/books?id=9Wy7Jgy5RWYC&amp;pg=PA648}}&lt;/ref&gt; I-EVD yathoma ukwazakala endaweni enarheni ye [[Sudan]] kanye ne- [[Democratic Republic of Congo]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu butholakala khulu eenarheni zethrophigi zenarhakazi yeAfrika [[Iphakathi le-Sehara ye-Afrika]].&lt;ref name=WHO2014/&gt; Ngo-1976 (ukutholakala kwabo ubulwelwe lobu] ukufikela ngo-2013, besele ingene yatheleleka ebantwini abangaphasii kwe-1000.&lt;ref name=WHO2014/&gt;&lt;ref name=MMWRJune2014&gt;{{Cite web|title=Ebola Viral Disease Outbreak — West Africa, 2014|url=https://www.cdc.gov/mmwr/preview/mmwrhtml/mm6325a4.htm?s_cid=mm6325a4_w|website=CDC|accessdate=26 June 2014|date=June 27, 2014}}&lt;/ref&gt; Ukuqubuka kobulwelwe lobu obukhulu obungazange khebubonwe ngilobu bamuva nje ngebe [[2014 Tjhingalanga ye-Afrika Ukuqubuka kwe-Ebola]], sebele bungene eenarheni [[Guinea]], [[Sierra Leone]], [[Liberia]] begodu ingatheleka ingene ne [[Nigeria]].&lt;ref name=CDC2014&gt;{{Cite web|title=CDC urges all US residents to avoid nonessential travel to Liberia, Guinea, and Sierra Leone because of an unprecedented outbreak of Ebola.|url=https://wwwnc.cdc.gov/travel/notices/level1/ebola-liberia|website=CDC|accessdate=2 August 2014|date=July 31, 2014}}&lt;/ref&gt;&lt;ref name=CDCAug2014N&gt;{{Cite web|title=Outbreak of Ebola in Guinea, Liberia, and Sierra Leone|url=http://www.cdc.gov/vhf/ebola/outbreaks/guinea/index.html|website=CDC|accessdate=5 August 2014|date=August 4, 2014}}&lt;/ref&gt; Ukusukela ngoRhoboyi 2014 sele kubikwe bona kunabantu esele bangenwe bulwelwe lobu abayi-1600.&lt;ref&gt;{{Cite web|title=Ebola virus disease update - West Africa|url=http://www.who.int/csr/don/2014_08_04_ebola/en/|website=WHO|accessdate=6 August 2014|date=Aug 4, 2014}}&lt;/ref&gt; Imizamo yona iyenziwa bona kutholakalle [[intatha/isihlahla]] esingalapha ubulwelwe lobu, kodwana okwanje asikho kwatholakala ipengu yakhona.&lt;ref name=WHO2014/&gt;

== Isikhombiso selwazi ==
{{Reflist|colwidth=25em}}

; IBhibhliyografu
{{Refbegin}}
* {{Cite book |last=Klenk |first=Hans-Dieter |title=Marburg and Ebola Viruses (Current Topics in Microbiology and Immunology) |date=January 1999 |publisher=Springer-Verlag Telos |location=Berlin |isbn=978-3-540-64729-4 |ref=CITEREFKlenk1999}}
* {{Cite book |first1=Hans-Dieter |last1=Klenk |first2=Heinz |last2=Feldmann |title=Ebola and Marburg viruses: molecular and cellular biology |url=https://books.google.com/books?id=EV_mFgnyPoMC&amp;redir_esc=y&amp;hl=en|format=Limited preview |year=2004 |publisher=Horizon Bioscience |location=Wymondham, Norfolk, UK |isbn=978-0-9545232-3-7 |ref=CITEREFKlenkFeldmann2004}}
* {{Cite book |last=Kuhn |first=Jens H. |title=Filoviruses: A Compendium of 40 Years of Epidemiological, Clinical, and Laboratory Studies. Archives of Virology Supplement, vol. 20 |url=https://books.google.com/books?id=LaOue0F9Ns4C&amp;redir_esc=y&amp;hl=en |format=Limited preview |year=2008 |publisher=SpringerWienNewYork |location=Vienna |isbn=978-3-211-20670-6 |ref=CITEREFKuhn2008}}
* {{Cite book |last1=McCormick |first1=Joseph |last2=Fisher-Hoch |first2=Susan |others=Horvitz, Leslie Alan |title=Level 4: Virus Hunters of the CDC |url=https://books.google.com/books?id=QEvR3aJX2m0C&amp;redir_esc=y&amp;hl=en |format=Limited preview |origyear=1996 |edition=Updated [3rd] |year=1999 |publisher=Barnes &amp; Noble |isbn=978-0-7607-1208-5 |ref=CITEREFMcCormickFisher-Hoch1999 |month=June}}
* {{Cite book |last=Pattyn |first=S. R. |title=Ebola Virus Haemorrhagic Fever |year=1978 |url=http://www.itg.be/ebola/ |format=Full free text |edition=1st |publisher=Elsevier/North-Holland Biomedical Press |location=Amsterdam |isbn=0-444-80060-3 |ref=CITEREFPattyn1978}}
* {{Cite book | last1 = Ryabchikova | first1 = Elena I. | last2 = Price | first2 = Barbara B. | title = Ebola and Marburg Viruses: A View of Infection Using Electron Microscopy | year = 2004 | publisher = Battelle Press | location = Columbus, Ohio | isbn = 978-1-57477-131-2 | ref = CITEREFRyabchikovaPrice2004 }}
{{Refend}}

== Okuhlanganiswe nalokhu okunye ==
{{Refbegin}}
* [https://viralzone.expasy.org/207.html?outline=all_by_species ViralZone: Ebola-like viruses] – Virological repository from the [[Swiss Institute of Bioinformatics]]
* [https://www.cdc.gov/ebola/about/index.html CDC: Ebola hemorrhagic fever] – Centers for Disease Control and Prevention, Special Pathogens Branch
* [https://www.who.int/health-topics/ebola WHO: Ebola haemorrhagic fever] – World Health Organization, Global Alert and Response
* [https://www.bv-brc.org/ Virus Pathogen Database and Analysis Resource (ViPR): Filoviridae]
* [https://web.archive.org/web/20140808072117/http://www.ebi.ac.uk/pdbe/emdb/searchResults.html/?q=ebola 3D macromolecular structures of the Ebola virus archived in the EM Data Bank(EMDB)]
* [https://web.archive.org/web/20140819171607/https://maps.google.com/maps/ms?msa=0&amp;msid=202977755949863934429.0004c658eb30f9c4fb1c0&amp;ie=UTF8&amp;t=h&amp;ll=27.371767,5.273438&amp;spn=110.017392,184.21875&amp;z=2&amp;source=embed&amp;dg=feature Google Map of Ebola Outbreaks]
* [https://web.archive.org/web/20140816223245/http://www.who.int/csr/bioriskreduction/filovirus_infection_control/en/ WHO recommended infection control measures]
{{Refend}}</text>
      <sha1>b493vgxj73yqx817lfq8id5cpt2fvch</sha1>
    </revision>
    <revision>
      <id>5220</id>
      <parentid>5219</parentid>
      <timestamp>2025-08-20T13:12:32Z</timestamp>
      <contributor>
        <username>History012</username>
        <id>863</id>
      </contributor>
      <origin>5220</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9367" sha1="cty0isi0j9kahmp6z3pw9c1v7qwoyzr" xml:space="preserve">[[file:7042 lores-Ebola-Zaire-CDC Photo.jpg|thumb|Umfanekiso wabongikazi ababili bema phambi kukaMayinga N., ogulayo ngesifo se-Ebola. Wafa emavikini ambalwa kamuva ngenxa yokopha ngaphakathi okukhulu. Lathathwa ngo-1976.]]

'''Ubulwelwe be-Ebola''' nofana ('''EVD''') '''[[Wp/kri/Ebola|I-Ebola]] nomulwana wokopha iingazi okhambisana nomgomani''' ('''EHF''') mimulwana ebangwa bulwelwe bevayirasi ebizwa nge- [[Ebola]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo athoma ukubonakala phakathi kwamalanga amabili ukuya eemvekeni eentathu ngemva sewungenwe bulwelwe lobu, [[njengomgomani ongapheliko]], umphimbo obabako onesilonda, [[imisipha ebuhlungu kanye nehloko esawula kabuhlungu]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kesinye isikhathi [[ungahlanza]], uphakanyelwe ziimbindi nesifo [[sokurhuda]], kuzokwenza bona [[amaphaphu]] kanye [[neso]] zingasasebenzi kuhle.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Nasele sekufike lapha, abanye baba nomraro [[wokopha iingazi]].&lt;ref name=WHO2014&gt;{{Cite web|title=Ebola virus disease Fact sheet N°103|url=https://www.who.int/en/news-room/fact-sheets/detail/ebola-virus-disease|work=World Health Organization|accessdate=12 April 2014|date=March 2014}}&lt;/ref&gt;

&lt;!-- Cause and Diagnosis--&gt;
Umulwana lo ungangena nawuthintana [[neengazi]] zomuntu ophethwe ngibo nofana [[umjuluko]] nanyana [[okunye nokunye okusamanzana]] okuvela (eenlwaneni [[kumaphelaphelana]] nofana iimfene).&lt;ref name=WHO2014/&gt; Bekube nje umulwana akukatholakali bona ungangena ngokuwurhogela emmoyeni.&lt;ref name=WHOAir2014&gt;{{Cite web|title=2014 Ebola Virus Disease (EVD) outbreak in West Africa|url=http://www.who.int/ith/updates/20140421/en/|website=WHO|accessdate=3 August 2014|date=Apr 21 2014}}&lt;/ref&gt; Kukholelwa bonyana abomaphelaphelani bakwazi ukuphatha ubugulo lobu kodwana wona angaphathwa ngiwo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Kwaba khona umuntu otheleleke ngomulwana lo, umulwana lo ungatheleleka kabanye abantu godu ngesikhathi esifitjhani.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amadoda angasinda ngemva kokulatjhwa angathelela abanye abantu ngokuthunda [[imbewu]] yabo lokha nabaya emsemeni nakungakapheli iinyanga ezimbili.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nakufanele uhlahlutjwe nofana uhlolelwe ubulwelwe lobu be-ebola kufanele izifo ezifana [[nomalalahlengezela]], [[isifo sokurhuda]] kanye omulwana [[wokopha iingazi okhambisana nomgomani]] inganakwa ukwenzelela ukuthola imiphumela ekungiyo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ukuqinisekisa umrabhu womraro wobulwelwe lobu amasampula weengazi ayathathwa ayokuhlolelwa ubugulo [[nesivikelasifo seengazini]] kanye ne [[i-RNA]] lobu kanye nengongwana ebanga ubugulo lobu.&lt;ref name=WHO2014/&gt;

&lt;!-- Prevention --&gt;
Ukuvikela ubugulo lobu kungaphungula ukuthelelana hlangana neemfene kanye neemfarigi ezingenwe bugulo lobu bukhandelwe bona bungayi ebantwini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kungenziwa ngokobana kuhlolwe iinlwana lezi ukobana zinabo ukugula lokhu  na, nakutholakala bona zinabo kungenzeka bona zibulawe bese kugujelwa imizimba yazo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokha nawupheka inyama bese wembatha izambatho zokuzivikela nakho kungakusiza,&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; ukwembatha izambatho zokuzivikela lokha nawuhlala nofana ukwaloyo muntu ongenwe bugulo lowo [[kanye nokuhlamba izandla ngesibha]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amasampula wananyana yini esamanzana yalabo bantu abangenwe mumulwana lo kufanele zitjhejwe khulu, ubalekele ukuthintana nazo.&lt;ref name=WHO2014/&gt;

&lt;!-- Treatment, Prognosis and Epidemiology--&gt;
Ayikho intatha elapha ubulwelwe lobu; imizamo yokobana kusizwe abantu abangenwe bulwelwe lobu kukobana [[kwenziwe umtswako]] (banikelwe amanzi anetswayi) ukobana bawasele nofana [[bafakwe amadribhu azobangenisela okusamanzana emzimbeni wabo]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu [[buneembalobalo eziphezulu zabantu abafako]]: nabangenwe ngibo ubulwelwe lobu, i-ebola ingabulala pheze isiquntu-50% nofana i-90% yabantu abatheleleke ngayo.&lt;ref name=WHO2014/&gt;&lt;ref name=&quot;Elsevier/Academic Press&quot;&gt;{{Cite book|author1=C.M. Fauquet|title=Virus taxonomy classification and nomenclature of viruses; 8th report of the International Committee on Taxonomy of Viruses|date=2005|publisher=Elsevier/Academic Press|location=Oxford|isbn=9780080575483|page=648|url=http://books.google.ca/books?id=9Wy7Jgy5RWYC&amp;pg=PA648}}&lt;/ref&gt; I-EVD yathoma ukwazakala endaweni enarheni ye [[Sudan]] kanye ne- [[Democratic Republic of Congo]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu butholakala khulu eenarheni zethrophigi zenarhakazi yeAfrika [[Iphakathi le-Sehara ye-Afrika]].&lt;ref name=WHO2014/&gt; Ngo-1976 (ukutholakala kwabo ubulwelwe lobu] ukufikela ngo-2013, besele ingene yatheleleka ebantwini abangaphasii kwe-1000.&lt;ref name=WHO2014/&gt;&lt;ref name=MMWRJune2014&gt;{{Cite web|title=Ebola Viral Disease Outbreak — West Africa, 2014|url=https://www.cdc.gov/mmwr/preview/mmwrhtml/mm6325a4.htm?s_cid=mm6325a4_w|website=CDC|accessdate=26 June 2014|date=June 27, 2014}}&lt;/ref&gt; Ukuqubuka kobulwelwe lobu obukhulu obungazange khebubonwe ngilobu bamuva nje ngebe [[2014 Tjhingalanga ye-Afrika Ukuqubuka kwe-Ebola]], sebele bungene eenarheni [[Guinea]], [[Sierra Leone]], [[Liberia]] begodu ingatheleka ingene ne [[Nigeria]].&lt;ref name=CDC2014&gt;{{Cite web|title=CDC urges all US residents to avoid nonessential travel to Liberia, Guinea, and Sierra Leone because of an unprecedented outbreak of Ebola.|url=https://wwwnc.cdc.gov/travel/notices/level1/ebola-liberia|website=CDC|accessdate=2 August 2014|date=July 31, 2014}}&lt;/ref&gt;&lt;ref name=CDCAug2014N&gt;{{Cite web|title=Outbreak of Ebola in Guinea, Liberia, and Sierra Leone|url=http://www.cdc.gov/vhf/ebola/outbreaks/guinea/index.html|website=CDC|accessdate=5 August 2014|date=August 4, 2014}}&lt;/ref&gt; Ukusukela ngoRhoboyi 2014 sele kubikwe bona kunabantu esele bangenwe bulwelwe lobu abayi-1600.&lt;ref&gt;{{Cite web|title=Ebola virus disease update - West Africa|url=http://www.who.int/csr/don/2014_08_04_ebola/en/|website=WHO|accessdate=6 August 2014|date=Aug 4, 2014}}&lt;/ref&gt; Imizamo yona iyenziwa bona kutholakalle [[intatha/isihlahla]] esingalapha ubulwelwe lobu, kodwana okwanje asikho kwatholakala ipengu yakhona.&lt;ref name=WHO2014/&gt;

== Isikhombiso selwazi ==
{{Reflist|colwidth=25em}}

; IBhibhliyografu
{{Refbegin}}
* {{Cite book |last=Klenk |first=Hans-Dieter |title=Marburg and Ebola Viruses (Current Topics in Microbiology and Immunology) |date=January 1999 |publisher=Springer-Verlag Telos |location=Berlin |isbn=978-3-540-64729-4 |ref=CITEREFKlenk1999}}
* {{Cite book |first1=Hans-Dieter |last1=Klenk |first2=Heinz |last2=Feldmann |title=Ebola and Marburg viruses: molecular and cellular biology |url=https://books.google.com/books?id=EV_mFgnyPoMC&amp;redir_esc=y&amp;hl=en|format=Limited preview |year=2004 |publisher=Horizon Bioscience |location=Wymondham, Norfolk, UK |isbn=978-0-9545232-3-7 |ref=CITEREFKlenkFeldmann2004}}
* {{Cite book |last=Kuhn |first=Jens H. |title=Filoviruses: A Compendium of 40 Years of Epidemiological, Clinical, and Laboratory Studies. Archives of Virology Supplement, vol. 20 |url=https://books.google.com/books?id=LaOue0F9Ns4C&amp;redir_esc=y&amp;hl=en |format=Limited preview |year=2008 |publisher=SpringerWienNewYork |location=Vienna |isbn=978-3-211-20670-6 |ref=CITEREFKuhn2008}}
* {{Cite book |last1=McCormick |first1=Joseph |last2=Fisher-Hoch |first2=Susan |others=Horvitz, Leslie Alan |title=Level 4: Virus Hunters of the CDC |url=https://books.google.com/books?id=QEvR3aJX2m0C&amp;redir_esc=y&amp;hl=en |format=Limited preview |origyear=1996 |edition=Updated [3rd] |year=1999 |publisher=Barnes &amp; Noble |isbn=978-0-7607-1208-5 |ref=CITEREFMcCormickFisher-Hoch1999 |month=June}}
* {{Cite book |last=Pattyn |first=S. R. |title=Ebola Virus Haemorrhagic Fever |year=1978 |url=http://www.itg.be/ebola/ |format=Full free text |edition=1st |publisher=Elsevier/North-Holland Biomedical Press |location=Amsterdam |isbn=0-444-80060-3 |ref=CITEREFPattyn1978}}
* {{Cite book | last1 = Ryabchikova | first1 = Elena I. | last2 = Price | first2 = Barbara B. | title = Ebola and Marburg Viruses: A View of Infection Using Electron Microscopy | year = 2004 | publisher = Battelle Press | location = Columbus, Ohio | isbn = 978-1-57477-131-2 | ref = CITEREFRyabchikovaPrice2004 }}
{{Refend}}

== Okuhlanganiswe nalokhu okunye ==
{{Refbegin}}
* [https://viralzone.expasy.org/207.html?outline=all_by_species ViralZone: Ebola-like viruses] – Virological repository from the [[Swiss Institute of Bioinformatics]]
* [https://www.cdc.gov/ebola/about/index.html CDC: Ebola hemorrhagic fever] – Centers for Disease Control and Prevention, Special Pathogens Branch
* [https://www.who.int/health-topics/ebola WHO: Ebola haemorrhagic fever] – World Health Organization, Global Alert and Response
* [https://www.bv-brc.org/ Virus Pathogen Database and Analysis Resource (ViPR): Filoviridae]
* [https://web.archive.org/web/20140808072117/http://www.ebi.ac.uk/pdbe/emdb/searchResults.html/?q=ebola 3D macromolecular structures of the Ebola virus archived in the EM Data Bank(EMDB)]
* [https://web.archive.org/web/20140819171607/https://maps.google.com/maps/ms?msa=0&amp;msid=202977755949863934429.0004c658eb30f9c4fb1c0&amp;ie=UTF8&amp;t=h&amp;ll=27.371767,5.273438&amp;spn=110.017392,184.21875&amp;z=2&amp;source=embed&amp;dg=feature Google Map of Ebola Outbreaks]
* [https://web.archive.org/web/20140816223245/http://www.who.int/csr/bioriskreduction/filovirus_infection_control/en/ WHO recommended infection control measures]
{{Refend}}</text>
      <sha1>cty0isi0j9kahmp6z3pw9c1v7qwoyzr</sha1>
    </revision>
  </page>
  <page>
    <title>Ubunzinzolwazi nesiphande saso</title>
    <ns>0</ns>
    <id>251</id>
    <revision>
      <id>1338</id>
      <timestamp>2024-07-21T10:02:57Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;Ubunzinzolwazi nesiphande saso   Ngokuya kwe-Techopedia (2024) ubunzinzolwazi bulibuthelelo lamakhasi wehlelo lethungelelwano lawo atholakala nanyana afunyaneka emphakathini begodu awela ngaphasi kwegama linye lobunzinzolwazi. Ubunzinzolwazi bungenziwa mumuntu munye, isiqema, ibubululo nanyana ihlangano bonyana kuthuthukiswe umnqopho othize (Techopedia 2024).    Nanyana kunjalo, ubunzinzolwazi lobu ukuze bufinyelele umnqopho obenzelwe bonyana kufuneka bonyana bube ne-int...&quot;</comment>
      <origin>1338</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3233" sha1="da2r9jr2iielojmh8x1h74n9b42hlch" xml:space="preserve">Ubunzinzolwazi nesiphande saso 

Ngokuya kwe-Techopedia (2024) ubunzinzolwazi bulibuthelelo lamakhasi wehlelo lethungelelwano lawo atholakala nanyana afunyaneka emphakathini begodu awela ngaphasi kwegama linye lobunzinzolwazi. Ubunzinzolwazi bungenziwa mumuntu munye, isiqema, ibubululo nanyana ihlangano bonyana kuthuthukiswe umnqopho othize (Techopedia 2024). 
 
Nanyana kunjalo, ubunzinzolwazi lobu ukuze bufinyelele umnqopho obenzelwe bonyana kufuneka bonyana bube ne-inthanedi (Website Essentials 2024). Lokhu kusitjela bonyana ngaphandle kwe-inthanedi angekhe batholakala nanyana umuntu angeze angena kibo. 
 
Iminqopho yobunzinzolwazi iyahluka. Kukhona abenza ubunzinzolwazi bonyana bakhulumisane nabanye abantu, njengama-blog, nanyana babelane ngelwazi. Abanye bona babenzele ukuthengisa umkhiqizo othize, kanti abanye babenzele ukufundisa abanye abantu. 
 
Isiphande sobunzinzolwazi sisodwa siyakhuluma. Ngendlela sitlolwe ngakho siyakutjela bonyana sisebenzisa liphi ihlelo lobulondolwazi begodi ngesomuntu nanyana umbuso na. Ezinye negama lekhamphani nanyana umuntu osenzileko ulithola esiphandeni saso. Esitjhejeni esibonelo esilandelako :
 
1.	http:www.ongaziwako.co.za
 
Nasitjheja isiphande esingehla sifunyana i-http, leyo ejamele Hypertext Transfer Protocol Secure. Le yindlela nanyana ihlelo leli elivikelekileko lokwabelana nanyana lokuthumela ilwazi ku-inthanedi nanyana ethungelelwaneni (WIXEncyclopedia 2024). Ihlelo leli levikeleko ngilo elisitjela lokha nakwenzekako bonyana ubunzizolwazi abukavikeleki. Esikhathini esinengi uthi nawungena kubunzinzolwazi, ukhandelwe begodu kuvele ulayezo othi, ‘it is not safe or it is not secure (abukaphephi nanyana abukavikeleki)’.  Ukudlula lapho, i-Hypertext le iyakutjela bonyana ilimi lobulondolwazi elisetjenzisiweko yi-HTML. Siyazi bonyana obunye bungasebenzisa i-Python nanyana i-CSS. 
 
Amagama alandelako, i-www, ajamele World Wide Web,leyo etjho ubunzinzolwazi bephasi zombelele (Techopedia 2024). Lokhu kusitjela bonyana ubunzizolwazi lobu bamulekekile iphasi loke begodu bungafunywa nanyana ukuphi ephasi. 
 
Amagama alandelako, ongaziwako, ligama le khamphani nanyana lo muntu lo ubunzinzolwazi lobu ekungebakhe. Igama leli liyakutjela bonyana ikhamphani le ibizwa nanyana umuntu loyo ubizwani. 
 
Amagama wokugcina esiphandeni sobunzinzo lwazi, co.za, ajamele umhlobo wekhamphani kanye nenarha nanyana isiyingi (WIXEncyclopedia 2024). U-co, ujamele company (WIXEncyclopedia 2024). Usirhunyezo. U-za, ujamele South Afrika/Zuid Afrika (iSewula Afrika). Lokhu kuyasitjela bonyana le yikhamphani yangeqadi yeSewula Afrika. Nangabe kuno-org, ekugcineni, lokho kutjho bona organisation leyo etjho ihlangano ngesikhethu.   

=== Isiphetho.  ===
Isiphandle sobunzinzolwazi nobunzinzolwazi zizinto eziqakatheke khulu epilweni yanamhlanje njengoba siphila esikhathini sethekhnoloji. Senza bonyana sibabantu sisebenzisane begodu sisekelani sikude. 

=== Umthombolwazi ===
Techopedia. (2024). ‘What is a Website?’. Available at:&lt;https://www.techopedia.com/definition/5411/website&gt;. Accessed on [17 June 2024]

WIXEncyclopedia. (2024) ‘.digital domain’. Available at:&lt;https://www.wix.com/encyclopedia/definition/digital-domain&gt;. Accessed on [17 June 2024].

</text>
      <sha1>da2r9jr2iielojmh8x1h74n9b42hlch</sha1>
    </revision>
    <revision>
      <id>1339</id>
      <parentid>1338</parentid>
      <timestamp>2024-07-21T10:03:48Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <origin>1339</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3240" sha1="0ug8es62rwqg2l8v7gzg1n2amq8zf02" xml:space="preserve">== Ubunzinzolwazi nesiphande saso ==
Ngokuya kwe-Techopedia (2024) ubunzinzolwazi bulibuthelelo lamakhasi wehlelo lethungelelwano lawo atholakala nanyana afunyaneka emphakathini begodu awela ngaphasi kwegama linye lobunzinzolwazi. Ubunzinzolwazi bungenziwa mumuntu munye, isiqema, ibubululo nanyana ihlangano bonyana kuthuthukiswe umnqopho othize (Techopedia 2024). 
 
Nanyana kunjalo, ubunzinzolwazi lobu ukuze bufinyelele umnqopho obenzelwe bonyana kufuneka bonyana bube ne-inthanedi (Website Essentials 2024). Lokhu kusitjela bonyana ngaphandle kwe-inthanedi angekhe batholakala nanyana umuntu angeze angena kibo. 
 
Iminqopho yobunzinzolwazi iyahluka. Kukhona abenza ubunzinzolwazi bonyana bakhulumisane nabanye abantu, njengama-blog, nanyana babelane ngelwazi. Abanye bona babenzele ukuthengisa umkhiqizo othize, kanti abanye babenzele ukufundisa abanye abantu. 
 
Isiphande sobunzinzolwazi sisodwa siyakhuluma. Ngendlela sitlolwe ngakho siyakutjela bonyana sisebenzisa liphi ihlelo lobulondolwazi begodi ngesomuntu nanyana umbuso na. Ezinye negama lekhamphani nanyana umuntu osenzileko ulithola esiphandeni saso. Esitjhejeni esibonelo esilandelako :
 
''1.	http:www.owaziwako.co.za''
 
Nasitjheja isiphande esingehla sifunyana i-http, leyo ejamele Hypertext Transfer Protocol Secure. Le yindlela nanyana ihlelo leli elivikelekileko lokwabelana nanyana lokuthumela ilwazi ku-inthanedi nanyana ethungelelwaneni (WIXEncyclopedia 2024). Ihlelo leli levikeleko ngilo elisitjela lokha nakwenzekako bonyana ubunzizolwazi abukavikeleki. Esikhathini esinengi uthi nawungena kubunzinzolwazi, ukhandelwe begodu kuvele ulayezo othi, ‘it is not safe or it is not secure (abukaphephi nanyana abukavikeleki)’.  Ukudlula lapho, i-Hypertext le iyakutjela bonyana ilimi lobulondolwazi elisetjenzisiweko yi-HTML. Siyazi bonyana obunye bungasebenzisa i-Python nanyana i-CSS. 
 
Amagama alandelako, i-www, ajamele World Wide Web,leyo etjho ubunzinzolwazi bephasi zombelele (Techopedia 2024). Lokhu kusitjela bonyana ubunzizolwazi lobu bamulekekile iphasi loke begodu bungafunywa nanyana ukuphi ephasi. 
 
Amagama alandelako, ongaziwako, ligama le khamphani nanyana lo muntu lo ubunzinzolwazi lobu ekungebakhe. Igama leli liyakutjela bonyana ikhamphani le ibizwa nanyana umuntu loyo ubizwani. 
 
Amagama wokugcina esiphandeni sobunzinzo lwazi, co.za, ajamele umhlobo wekhamphani kanye nenarha nanyana isiyingi (WIXEncyclopedia 2024). U-co, ujamele company (WIXEncyclopedia 2024). Usirhunyezo. U-za, ujamele South Afrika/Zuid Afrika (iSewula Afrika). Lokhu kuyasitjela bonyana le yikhamphani yangeqadi yeSewula Afrika. Nangabe kuno-org, ekugcineni, lokho kutjho bona organisation leyo etjho ihlangano ngesikhethu.   

=== Isiphetho.  ===
Isiphandle sobunzinzolwazi nobunzinzolwazi zizinto eziqakatheke khulu epilweni yanamhlanje njengoba siphila esikhathini sethekhnoloji. Senza bonyana sibabantu sisebenzisane begodu sisekelani sikude. 

=== Umthombolwazi ===
Techopedia. (2024). ‘What is a Website?’. Available at:&lt;https://www.techopedia.com/definition/5411/website&gt;. Accessed on [17 June 2024]

WIXEncyclopedia. (2024) ‘.digital domain’. Available at:&lt;https://www.wix.com/encyclopedia/definition/digital-domain&gt;. Accessed on [17 June 2024].

</text>
      <sha1>0ug8es62rwqg2l8v7gzg1n2amq8zf02</sha1>
    </revision>
    <revision>
      <id>1340</id>
      <parentid>1339</parentid>
      <timestamp>2024-09-18T16:00:10Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1340</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3396" sha1="0hpcet0xlqzohohzs0w13383kt3u5or" xml:space="preserve">== Ubunzinzolwazi nesiphande saso ==
Ngokuya kwe-Techopedia (2024&lt;ref name=&quot;:0&quot;&gt;Techopedia. (2024). ‘What is a Website?’. Available at:&lt;&lt;nowiki&gt;https://www.techopedia.com/definition/5411/website&lt;/nowiki&gt;&gt;. Accessed on [17 June 2024]&lt;/ref&gt;) ubunzinzolwazi bulibuthelelo lamakhasi wehlelo lethungelelwano lawo atholakala nanyana afunyaneka emphakathini begodu awela ngaphasi kwegama linye lobunzinzolwazi. Ubunzinzolwazi bungenziwa mumuntu munye, isiqema, ibubululo nanyana ihlangano bonyana kuthuthukiswe umnqopho othize (Techopedia 2024&lt;ref name=&quot;:0&quot; /&gt;). 
 
Nanyana kunjalo, ubunzinzolwazi lobu ukuze bufinyelele umnqopho obenzelwe bonyana kufuneka bonyana bube ne-inthanedi (Website Essentials 2024&lt;ref name=&quot;:1&quot;&gt;WIXEncyclopedia. (2024) ‘.digital domain’. Available at:&lt;https://www.wix.com/encyclopedia/definition/digital-domain&gt;. Accessed on [17 June 2024].&lt;/ref&gt;). Lokhu kusitjela bonyana ngaphandle kwe-inthanedi angekhe batholakala nanyana umuntu angeze angena kibo. 
 
Iminqopho yobunzinzolwazi iyahluka. Kukhona abenza ubunzinzolwazi bonyana bakhulumisane nabanye abantu, njengama-blog, nanyana babelane ngelwazi. Abanye bona babenzele ukuthengisa umkhiqizo othize, kanti abanye babenzele ukufundisa abanye abantu. 
 
Isiphande sobunzinzolwazi sisodwa siyakhuluma. Ngendlela sitlolwe ngakho siyakutjela bonyana sisebenzisa liphi ihlelo lobulondolwazi begodi ngesomuntu nanyana umbuso na. Ezinye negama lekhamphani nanyana umuntu osenzileko ulithola esiphandeni saso. Esitjhejeni esibonelo esilandelako :
 
''1.	http:www.owaziwako.co.za''
 
Nasitjheja isiphande esingehla sifunyana i-http, leyo ejamele Hypertext Transfer Protocol Secure. Le yindlela nanyana ihlelo leli elivikelekileko lokwabelana nanyana lokuthumela ilwazi ku-inthanedi nanyana ethungelelwaneni (WIXEncyclopedia 2024&lt;ref name=&quot;:1&quot; /&gt;). Ihlelo leli levikeleko ngilo elisitjela lokha nakwenzekako bonyana ubunzizolwazi abukavikeleki. Esikhathini esinengi uthi nawungena kubunzinzolwazi, ukhandelwe begodu kuvele ulayezo othi, ‘it is not safe or it is not secure (abukaphephi nanyana abukavikeleki)’.  Ukudlula lapho, i-Hypertext le iyakutjela bonyana ilimi lobulondolwazi elisetjenzisiweko yi-HTML. Siyazi bonyana obunye bungasebenzisa i-Python nanyana i-CSS. 
 
Amagama alandelako, i-www, ajamele World Wide Web,leyo etjho ubunzinzolwazi bephasi zombelele (Techopedia 2024&lt;ref name=&quot;:0&quot; /&gt;). Lokhu kusitjela bonyana ubunzizolwazi lobu bamulekekile iphasi loke begodu bungafunywa nanyana ukuphi ephasi. 
 
Amagama alandelako, ongaziwako, ligama le khamphani nanyana lo muntu lo ubunzinzolwazi lobu ekungebakhe. Igama leli liyakutjela bonyana ikhamphani le ibizwa nanyana umuntu loyo ubizwani. 
 
Amagama wokugcina esiphandeni sobunzinzo lwazi, co.za, ajamele umhlobo wekhamphani kanye nenarha nanyana isiyingi (WIXEncyclopedia 2024&lt;ref name=&quot;:1&quot; /&gt;). U-co, ujamele company (WIXEncyclopedia 2024&lt;ref name=&quot;:1&quot; /&gt;). Usirhunyezo. U-za, ujamele South Afrika/Zuid Afrika (iSewula Afrika). Lokhu kuyasitjela bonyana le yikhamphani yangeqadi yeSewula Afrika. Nangabe kuno-org, ekugcineni, lokho kutjho bona organisation leyo etjho ihlangano ngesikhethu.   

=== Isiphetho.  ===
Isiphandle sobunzinzolwazi nobunzinzolwazi zizinto eziqakatheke khulu epilweni yanamhlanje njengoba siphila esikhathini sethekhnoloji. Senza bonyana sibabantu sisebenzisane begodu sisekelani sikude. 

=== Umthombolwazi ===
&lt;references /&gt;

</text>
      <sha1>0hpcet0xlqzohohzs0w13383kt3u5or</sha1>
    </revision>
    <revision>
      <id>1341</id>
      <parentid>1340</parentid>
      <timestamp>2024-10-14T13:47:13Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>1340</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3396" sha1="0hpcet0xlqzohohzs0w13383kt3u5or" xml:space="preserve">== Ubunzinzolwazi nesiphande saso ==
Ngokuya kwe-Techopedia (2024&lt;ref name=&quot;:0&quot;&gt;Techopedia. (2024). ‘What is a Website?’. Available at:&lt;&lt;nowiki&gt;https://www.techopedia.com/definition/5411/website&lt;/nowiki&gt;&gt;. Accessed on [17 June 2024]&lt;/ref&gt;) ubunzinzolwazi bulibuthelelo lamakhasi wehlelo lethungelelwano lawo atholakala nanyana afunyaneka emphakathini begodu awela ngaphasi kwegama linye lobunzinzolwazi. Ubunzinzolwazi bungenziwa mumuntu munye, isiqema, ibubululo nanyana ihlangano bonyana kuthuthukiswe umnqopho othize (Techopedia 2024&lt;ref name=&quot;:0&quot; /&gt;). 
 
Nanyana kunjalo, ubunzinzolwazi lobu ukuze bufinyelele umnqopho obenzelwe bonyana kufuneka bonyana bube ne-inthanedi (Website Essentials 2024&lt;ref name=&quot;:1&quot;&gt;WIXEncyclopedia. (2024) ‘.digital domain’. Available at:&lt;https://www.wix.com/encyclopedia/definition/digital-domain&gt;. Accessed on [17 June 2024].&lt;/ref&gt;). Lokhu kusitjela bonyana ngaphandle kwe-inthanedi angekhe batholakala nanyana umuntu angeze angena kibo. 
 
Iminqopho yobunzinzolwazi iyahluka. Kukhona abenza ubunzinzolwazi bonyana bakhulumisane nabanye abantu, njengama-blog, nanyana babelane ngelwazi. Abanye bona babenzele ukuthengisa umkhiqizo othize, kanti abanye babenzele ukufundisa abanye abantu. 
 
Isiphande sobunzinzolwazi sisodwa siyakhuluma. Ngendlela sitlolwe ngakho siyakutjela bonyana sisebenzisa liphi ihlelo lobulondolwazi begodi ngesomuntu nanyana umbuso na. Ezinye negama lekhamphani nanyana umuntu osenzileko ulithola esiphandeni saso. Esitjhejeni esibonelo esilandelako :
 
''1.	http:www.owaziwako.co.za''
 
Nasitjheja isiphande esingehla sifunyana i-http, leyo ejamele Hypertext Transfer Protocol Secure. Le yindlela nanyana ihlelo leli elivikelekileko lokwabelana nanyana lokuthumela ilwazi ku-inthanedi nanyana ethungelelwaneni (WIXEncyclopedia 2024&lt;ref name=&quot;:1&quot; /&gt;). Ihlelo leli levikeleko ngilo elisitjela lokha nakwenzekako bonyana ubunzizolwazi abukavikeleki. Esikhathini esinengi uthi nawungena kubunzinzolwazi, ukhandelwe begodu kuvele ulayezo othi, ‘it is not safe or it is not secure (abukaphephi nanyana abukavikeleki)’.  Ukudlula lapho, i-Hypertext le iyakutjela bonyana ilimi lobulondolwazi elisetjenzisiweko yi-HTML. Siyazi bonyana obunye bungasebenzisa i-Python nanyana i-CSS. 
 
Amagama alandelako, i-www, ajamele World Wide Web,leyo etjho ubunzinzolwazi bephasi zombelele (Techopedia 2024&lt;ref name=&quot;:0&quot; /&gt;). Lokhu kusitjela bonyana ubunzizolwazi lobu bamulekekile iphasi loke begodu bungafunywa nanyana ukuphi ephasi. 
 
Amagama alandelako, ongaziwako, ligama le khamphani nanyana lo muntu lo ubunzinzolwazi lobu ekungebakhe. Igama leli liyakutjela bonyana ikhamphani le ibizwa nanyana umuntu loyo ubizwani. 
 
Amagama wokugcina esiphandeni sobunzinzo lwazi, co.za, ajamele umhlobo wekhamphani kanye nenarha nanyana isiyingi (WIXEncyclopedia 2024&lt;ref name=&quot;:1&quot; /&gt;). U-co, ujamele company (WIXEncyclopedia 2024&lt;ref name=&quot;:1&quot; /&gt;). Usirhunyezo. U-za, ujamele South Afrika/Zuid Afrika (iSewula Afrika). Lokhu kuyasitjela bonyana le yikhamphani yangeqadi yeSewula Afrika. Nangabe kuno-org, ekugcineni, lokho kutjho bona organisation leyo etjho ihlangano ngesikhethu.   

=== Isiphetho.  ===
Isiphandle sobunzinzolwazi nobunzinzolwazi zizinto eziqakatheke khulu epilweni yanamhlanje njengoba siphila esikhathini sethekhnoloji. Senza bonyana sibabantu sisebenzisane begodu sisekelani sikude. 

=== Umthombolwazi ===
&lt;references /&gt;

</text>
      <sha1>0hpcet0xlqzohohzs0w13383kt3u5or</sha1>
    </revision>
  </page>
  <page>
    <title>Ukamisa</title>
    <ns>0</ns>
    <id>252</id>
    <revision>
      <id>1342</id>
      <timestamp>2024-05-09T11:56:24Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;EsiNdebeleni kunamatjhada lawo asetjenziswako. Amatjhada la ahlukaniswe ngemihlobo embili leyo eyaziwa ngabokamisa nabongwaqa. Abokamisa matjhada alandelako: a, e, i, o no-u. Kodwana, ngokomtlolomazombe abokamisa bahlukaniswe ngokomhlobo embili. Imihlobo le ibizwa ukuthi bokamisa bendabuko nanyana bemvelo, nabokubelethwa nanyana bokuvela. Esihlokwaneni esilamako sizokutjheja abokamisa bendabuko nanyana bemvelo.  '''Abokamisa bendabuko nanyana bemvelo'''.  Abomamisa benda...&quot;</comment>
      <origin>1342</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1931" sha1="ir05so49y2djykezw6gfh57zo9dmvgd" xml:space="preserve">EsiNdebeleni kunamatjhada lawo asetjenziswako. Amatjhada la ahlukaniswe ngemihlobo embili leyo eyaziwa ngabokamisa nabongwaqa. Abokamisa matjhada alandelako: a, e, i, o no-u. Kodwana, ngokomtlolomazombe abokamisa bahlukaniswe ngokomhlobo embili. Imihlobo le ibizwa ukuthi bokamisa bendabuko nanyana bemvelo, nabokubelethwa nanyana bokuvela. Esihlokwaneni esilamako sizokutjheja abokamisa bendabuko nanyana bemvelo.

'''Abokamisa bendabuko nanyana bemvelo'''.

Abomamisa bendabuko nanyana bemvelo thathu, u-a, i no-u. 

1. [a] ukamisa ophasi etjhadini labokamisa
Isibonelo: -lala [lala], halala [ɦalala}.
2. [i] ukamisa ophambili phezulu etjhadini, ophakemeko
Isibonelo: ibilibili [iƃiliƃili], ilimi [ilimi].
3. [u] ukamisa ongemuva phezulu etjhadini, ophakemeko.
Isibonelo: lokhu [lokhu],  -khulu [khulu].

Esihlokwaneni esilandelako sizokutjheja abokamisa bokuvelethwa nanyana bokuvela.

'''Abokamisa bokuvelethwa nanyana bokuvela
'''
Abokamisa bokuvelethwa nanyana bokuvela bokamisa amane ngokuya ngokomtlolo mazombe, bona ngilaba; e[ɛ],e[e],o[ɔ] no-o[o].  

e[ɛ]: ukamisa ophambili phakathi-phasi etjhadini.Utholakala nangabe ulandelwa
lilunga elinokamisa ophasi.
Isibonelo: -lele [lɛlɛ], lelesa [lɛlɛsa].
e[e]: ukamisa ophambili phakathi-phezulu etjhadini.Utholakala nangabe ulandelwa
lilunga elinokamisa ophezulu.
Isibonelo: -qedile [!edilɛ] abelusi [aƃelusi].
o[ɔ]: ukamisa osemuva phakathi-phasi etjhadini.Utholakala nangabe ulandelwa
Isibonelo: –soloko [sɔlɔkɔ] usoloza [usɔlɔza]
o[o]: ukamisa osemuva phakathi-phezulu etjhadini.Utholakala nangabe
ulandelwa lilunga elinokamisa ophezulu.
Isibonelo: lokhu [lokhu], ithosi [ithosi].

Abokamisa baqakatheke khulu elimi netuthukweni yesiNdebele ngombana ukuze sitlole nanyana sikhulume kufanele sisebenzise amatjhada lawo akhamba nabokamisa. Abokamisa nabahlangana nabongwaqa bakhiqhiza amatjhada lawo esiwasebenzisa ukwakha amagama. Amagama akha imitjho.

</text>
      <sha1>ir05so49y2djykezw6gfh57zo9dmvgd</sha1>
    </revision>
    <revision>
      <id>1343</id>
      <parentid>1342</parentid>
      <timestamp>2024-05-09T12:00:14Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1343</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1957" sha1="4jxzgw08l7x7qto0gh4fl67j5ta9nbf" xml:space="preserve">EsiNdebeleni kunamatjhada lawo asetjenziswako. Amatjhada la ahlukaniswe ngemihlobo embili leyo eyaziwa ngabokamisa nabongwaqa. Abokamisa matjhada alandelako: a, e, i, o no-u. Kodwana, ngokomtlolomazombe abokamisa bahlukaniswe ngokomhlobo embili. Imihlobo le ibizwa ukuthi bokamisa bendabuko nanyana bemvelo, nabokubelethwa nanyana bokuvela. Esihlokwaneni esilamako sizokutjheja abokamisa bendabuko nanyana bemvelo.

'''Abokamisa bendabuko nanyana bemvelo'''.

Abomamisa bendabuko nanyana bemvelo thathu, u-a, i no-u. 

1. [a] ukamisa ophasi etjhadini labokamisa

Isibonelo: -lala [lala], halala [ɦalala}.

2. [i] ukamisa ophambili phezulu etjhadini, ophakemeko

Isibonelo: ibilibili [iƃiliƃili], ilimi [ilimi].

3. [u] ukamisa ongemuva phezulu etjhadini, ophakemeko.

Isibonelo: lokhu [lokhu],  -khulu [khulu].

Esihlokwaneni esilandelako sizokutjheja abokamisa bokuvelethwa nanyana bokuvela.

'''Abokamisa bokubelethwa nanyana bokuvela'''  

Abokamisa bokubelethwa nanyana bokuvela bokamisa amane ngokuya ngokomtlolo mazombe, bona ngilaba; e[ɛ],e[e],o[ɔ] no-o[o].  

1. e[ɛ]: ukamisa ophambili phakathi-phasi etjhadini.Utholakala nangabe ulandelwa
lilunga elinokamisa ophasi.

Isibonelo: -lele [lɛlɛ], lelesa [lɛlɛsa].

2. e[e]: ukamisa ophambili phakathi-phezulu etjhadini.Utholakala nangabe ulandelwa
lilunga elinokamisa ophezulu.

Isibonelo: -qedile [!edilɛ] abelusi [aƃelusi].

3. o[ɔ]: ukamisa osemuva phakathi-phasi etjhadini.Utholakala nangabe ulandelwa

Isibonelo: –soloko [sɔlɔkɔ] usoloza [usɔlɔza]

4. o[o]: ukamisa osemuva phakathi-phezulu etjhadini.Utholakala nangabe
ulandelwa lilunga elinokamisa ophezulu.

Isibonelo: lokhu [lokhu], ithosi [ithosi].

Abokamisa baqakatheke khulu elimi netuthukweni yesiNdebele ngombana ukuze sitlole nanyana sikhulume kufanele sisebenzise amatjhada lawo akhamba nabokamisa. Abokamisa nabahlangana nabongwaqa bakhiqhiza amatjhada lawo esiwasebenzisa ukwakha amagama. Amagama akha imitjho.

</text>
      <sha1>4jxzgw08l7x7qto0gh4fl67j5ta9nbf</sha1>
    </revision>
    <revision>
      <id>1344</id>
      <parentid>1343</parentid>
      <timestamp>2024-05-09T12:03:53Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1344</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1987" sha1="moddkyamtixq89r6le36vv07fca5hym" xml:space="preserve">== '''Abokamisa''' ==
EsiNdebeleni kunamatjhada lawo asetjenziswako. Amatjhada la ahlukaniswe ngemihlobo embili leyo eyaziwa ngabokamisa nabongwaqa. Abokamisa matjhada alandelako: a, e, i, o no-u. Kodwana, ngokomtlolomazombe abokamisa bahlukaniswe ngokomhlobo embili. Imihlobo le ibizwa ukuthi bokamisa bendabuko nanyana bemvelo, nabokubelethwa nanyana bokuvela. Esihlokwaneni esilamako sizokutjheja abokamisa bendabuko nanyana bemvelo.

== '''Abokamisa bendabuko nanyana bemvelo'''. ==
Abomamisa bendabuko nanyana bemvelo thathu, u-a, i no-u. 

1. [a] ukamisa ophasi etjhadini labokamisa

Isibonelo: -lala [lala], halala [ɦalala}.

2. [i] ukamisa ophambili phezulu etjhadini, ophakemeko

Isibonelo: ibilibili [iƃiliƃili], ilimi [ilimi].

3. [u] ukamisa ongemuva phezulu etjhadini, ophakemeko.

Isibonelo: lokhu [lokhu],  -khulu [khulu].

Esihlokwaneni esilandelako sizokutjheja abokamisa bokuvelethwa nanyana bokuvela.

== '''Abokamisa bokubelethwa nanyana bokuvela''' ==
Abokamisa bokubelethwa nanyana bokuvela bokamisa amane ngokuya ngokomtlolo mazombe, bona ngilaba; e[ɛ],e[e],o[ɔ] no-o[o].  

1. e[ɛ]: ukamisa ophambili phakathi-phasi etjhadini.Utholakala nangabe ulandelwa
lilunga elinokamisa ophasi.

Isibonelo: -lele [lɛlɛ], lelesa [lɛlɛsa].

2. e[e]: ukamisa ophambili phakathi-phezulu etjhadini.Utholakala nangabe ulandelwa
lilunga elinokamisa ophezulu.

Isibonelo: -qedile [!edilɛ] abelusi [aƃelusi].

3. o[ɔ]: ukamisa osemuva phakathi-phasi etjhadini.Utholakala nangabe ulandelwa

Isibonelo: –soloko [sɔlɔkɔ] usoloza [usɔlɔza]

4. o[o]: ukamisa osemuva phakathi-phezulu etjhadini.Utholakala nangabe
ulandelwa lilunga elinokamisa ophezulu.

Isibonelo: lokhu [lokhu], ithosi [ithosi].

Abokamisa baqakatheke khulu elimi netuthukweni yesiNdebele ngombana ukuze sitlole nanyana sikhulume kufanele sisebenzise amatjhada lawo akhamba nabokamisa. Abokamisa nabahlangana nabongwaqa bakhiqhiza amatjhada lawo esiwasebenzisa ukwakha amagama. Amagama akha imitjho.

</text>
      <sha1>moddkyamtixq89r6le36vv07fca5hym</sha1>
    </revision>
    <revision>
      <id>1345</id>
      <parentid>1344</parentid>
      <timestamp>2024-09-18T16:01:11Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1345</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2007" sha1="btsjixrmvn7qjyjvluux466wvj86b5f" xml:space="preserve">== '''Abokamisa''' ==

=== Isingeniso ===
EsiNdebeleni kunamatjhada lawo asetjenziswako. Amatjhada la ahlukaniswe ngemihlobo embili leyo eyaziwa ngabokamisa nabongwaqa. Abokamisa matjhada alandelako: a, e, i, o no-u. Kodwana, ngokomtlolomazombe abokamisa bahlukaniswe ngokomhlobo embili. Imihlobo le ibizwa ukuthi bokamisa bendabuko nanyana bemvelo, nabokubelethwa nanyana bokuvela. Esihlokwaneni esilamako sizokutjheja abokamisa bendabuko nanyana bemvelo.

== '''Abokamisa bendabuko nanyana bemvelo'''. ==
Abomamisa bendabuko nanyana bemvelo thathu, u-a, i no-u. 

1. [a] ukamisa ophasi etjhadini labokamisa

Isibonelo: -lala [lala], halala [ɦalala}.

2. [i] ukamisa ophambili phezulu etjhadini, ophakemeko

Isibonelo: ibilibili [iƃiliƃili], ilimi [ilimi].

3. [u] ukamisa ongemuva phezulu etjhadini, ophakemeko.

Isibonelo: lokhu [lokhu],  -khulu [khulu].

Esihlokwaneni esilandelako sizokutjheja abokamisa bokuvelethwa nanyana bokuvela.

== '''Abokamisa bokubelethwa nanyana bokuvela''' ==
Abokamisa bokubelethwa nanyana bokuvela bokamisa amane ngokuya ngokomtlolo mazombe, bona ngilaba; e[ɛ],e[e],o[ɔ] no-o[o].  

1. e[ɛ]: ukamisa ophambili phakathi-phasi etjhadini.Utholakala nangabe ulandelwa
lilunga elinokamisa ophasi.

Isibonelo: -lele [lɛlɛ], lelesa [lɛlɛsa].

2. e[e]: ukamisa ophambili phakathi-phezulu etjhadini.Utholakala nangabe ulandelwa
lilunga elinokamisa ophezulu.

Isibonelo: -qedile [!edilɛ] abelusi [aƃelusi].

3. o[ɔ]: ukamisa osemuva phakathi-phasi etjhadini.Utholakala nangabe ulandelwa

Isibonelo: –soloko [sɔlɔkɔ] usoloza [usɔlɔza]

4. o[o]: ukamisa osemuva phakathi-phezulu etjhadini.Utholakala nangabe
ulandelwa lilunga elinokamisa ophezulu.

Isibonelo: lokhu [lokhu], ithosi [ithosi].

Abokamisa baqakatheke khulu elimi netuthukweni yesiNdebele ngombana ukuze sitlole nanyana sikhulume kufanele sisebenzise amatjhada lawo akhamba nabokamisa. Abokamisa nabahlangana nabongwaqa bakhiqhiza amatjhada lawo esiwasebenzisa ukwakha amagama. Amagama akha imitjho.

</text>
      <sha1>btsjixrmvn7qjyjvluux466wvj86b5f</sha1>
    </revision>
    <revision>
      <id>1346</id>
      <parentid>1345</parentid>
      <timestamp>2024-10-14T13:47:13Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>4 revisions imported</comment>
      <origin>1345</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2007" sha1="btsjixrmvn7qjyjvluux466wvj86b5f" xml:space="preserve">== '''Abokamisa''' ==

=== Isingeniso ===
EsiNdebeleni kunamatjhada lawo asetjenziswako. Amatjhada la ahlukaniswe ngemihlobo embili leyo eyaziwa ngabokamisa nabongwaqa. Abokamisa matjhada alandelako: a, e, i, o no-u. Kodwana, ngokomtlolomazombe abokamisa bahlukaniswe ngokomhlobo embili. Imihlobo le ibizwa ukuthi bokamisa bendabuko nanyana bemvelo, nabokubelethwa nanyana bokuvela. Esihlokwaneni esilamako sizokutjheja abokamisa bendabuko nanyana bemvelo.

== '''Abokamisa bendabuko nanyana bemvelo'''. ==
Abomamisa bendabuko nanyana bemvelo thathu, u-a, i no-u. 

1. [a] ukamisa ophasi etjhadini labokamisa

Isibonelo: -lala [lala], halala [ɦalala}.

2. [i] ukamisa ophambili phezulu etjhadini, ophakemeko

Isibonelo: ibilibili [iƃiliƃili], ilimi [ilimi].

3. [u] ukamisa ongemuva phezulu etjhadini, ophakemeko.

Isibonelo: lokhu [lokhu],  -khulu [khulu].

Esihlokwaneni esilandelako sizokutjheja abokamisa bokuvelethwa nanyana bokuvela.

== '''Abokamisa bokubelethwa nanyana bokuvela''' ==
Abokamisa bokubelethwa nanyana bokuvela bokamisa amane ngokuya ngokomtlolo mazombe, bona ngilaba; e[ɛ],e[e],o[ɔ] no-o[o].  

1. e[ɛ]: ukamisa ophambili phakathi-phasi etjhadini.Utholakala nangabe ulandelwa
lilunga elinokamisa ophasi.

Isibonelo: -lele [lɛlɛ], lelesa [lɛlɛsa].

2. e[e]: ukamisa ophambili phakathi-phezulu etjhadini.Utholakala nangabe ulandelwa
lilunga elinokamisa ophezulu.

Isibonelo: -qedile [!edilɛ] abelusi [aƃelusi].

3. o[ɔ]: ukamisa osemuva phakathi-phasi etjhadini.Utholakala nangabe ulandelwa

Isibonelo: –soloko [sɔlɔkɔ] usoloza [usɔlɔza]

4. o[o]: ukamisa osemuva phakathi-phezulu etjhadini.Utholakala nangabe
ulandelwa lilunga elinokamisa ophezulu.

Isibonelo: lokhu [lokhu], ithosi [ithosi].

Abokamisa baqakatheke khulu elimi netuthukweni yesiNdebele ngombana ukuze sitlole nanyana sikhulume kufanele sisebenzise amatjhada lawo akhamba nabokamisa. Abokamisa nabahlangana nabongwaqa bakhiqhiza amatjhada lawo esiwasebenzisa ukwakha amagama. Amagama akha imitjho.

</text>
      <sha1>btsjixrmvn7qjyjvluux466wvj86b5f</sha1>
    </revision>
    <revision>
      <id>3028</id>
      <parentid>1346</parentid>
      <timestamp>2025-06-06T20:34:02Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>4gtr5gx5gh5</comment>
      <origin>3028</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2093" sha1="b4iv1arzwh6teqmnseshq4zuxavavfd" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.'''

== '''Abokamisa''' ==

=== Isingeniso ===
EsiNdebeleni kunamatjhada lawo asetjenziswako. Amatjhada la ahlukaniswe ngemihlobo embili leyo eyaziwa ngabokamisa nabongwaqa. Abokamisa matjhada alandelako: a, e, i, o no-u. Kodwana, ngokomtlolomazombe abokamisa bahlukaniswe ngokomhlobo embili. Imihlobo le ibizwa ukuthi bokamisa bendabuko nanyana bemvelo, nabokubelethwa nanyana bokuvela. Esihlokwaneni esilamako sizokutjheja abokamisa bendabuko nanyana bemvelo.

== '''Abokamisa bendabuko nanyana bemvelo'''. ==
Abomamisa bendabuko nanyana bemvelo thathu, u-a, i no-u. 

1. [a] ukamisa ophasi etjhadini labokamisa

Isibonelo: -lala [lala], halala [ɦalala}.

2. [i] ukamisa ophambili phezulu etjhadini, ophakemeko

Isibonelo: ibilibili [iƃiliƃili], ilimi [ilimi].

3. [u] ukamisa ongemuva phezulu etjhadini, ophakemeko.

Isibonelo: lokhu [lokhu],  -khulu [khulu].

Esihlokwaneni esilandelako sizokutjheja abokamisa bokuvelethwa nanyana bokuvela.

== '''Abokamisa bokubelethwa nanyana bokuvela''' ==
Abokamisa bokubelethwa nanyana bokuvela bokamisa amane ngokuya ngokomtlolo mazombe, bona ngilaba; e[ɛ],e[e],o[ɔ] no-o[o].  

1. e[ɛ]: ukamisa ophambili phakathi-phasi etjhadini.Utholakala nangabe ulandelwa
lilunga elinokamisa ophasi.

Isibonelo: -lele [lɛlɛ], lelesa [lɛlɛsa].

2. e[e]: ukamisa ophambili phakathi-phezulu etjhadini.Utholakala nangabe ulandelwa
lilunga elinokamisa ophezulu.

Isibonelo: -qedile [!edilɛ] abelusi [aƃelusi].

3. o[ɔ]: ukamisa osemuva phakathi-phasi etjhadini.Utholakala nangabe ulandelwa

Isibonelo: –soloko [sɔlɔkɔ] usoloza [usɔlɔza]

4. o[o]: ukamisa osemuva phakathi-phezulu etjhadini.Utholakala nangabe
ulandelwa lilunga elinokamisa ophezulu.

Isibonelo: lokhu [lokhu], ithosi [ithosi].

Abokamisa baqakatheke khulu elimi netuthukweni yesiNdebele ngombana ukuze sitlole nanyana sikhulume kufanele sisebenzise amatjhada lawo akhamba nabokamisa. Abokamisa nabahlangana nabongwaqa bakhiqhiza amatjhada lawo esiwasebenzisa ukwakha amagama. Amagama akha imitjho.</text>
      <sha1>b4iv1arzwh6teqmnseshq4zuxavavfd</sha1>
    </revision>
    <revision>
      <id>3109</id>
      <parentid>3028</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Jon Harald Søby|Jon Harald Søby]]</comment>
      <origin>1345</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2007" sha1="btsjixrmvn7qjyjvluux466wvj86b5f" xml:space="preserve">== '''Abokamisa''' ==

=== Isingeniso ===
EsiNdebeleni kunamatjhada lawo asetjenziswako. Amatjhada la ahlukaniswe ngemihlobo embili leyo eyaziwa ngabokamisa nabongwaqa. Abokamisa matjhada alandelako: a, e, i, o no-u. Kodwana, ngokomtlolomazombe abokamisa bahlukaniswe ngokomhlobo embili. Imihlobo le ibizwa ukuthi bokamisa bendabuko nanyana bemvelo, nabokubelethwa nanyana bokuvela. Esihlokwaneni esilamako sizokutjheja abokamisa bendabuko nanyana bemvelo.

== '''Abokamisa bendabuko nanyana bemvelo'''. ==
Abomamisa bendabuko nanyana bemvelo thathu, u-a, i no-u. 

1. [a] ukamisa ophasi etjhadini labokamisa

Isibonelo: -lala [lala], halala [ɦalala}.

2. [i] ukamisa ophambili phezulu etjhadini, ophakemeko

Isibonelo: ibilibili [iƃiliƃili], ilimi [ilimi].

3. [u] ukamisa ongemuva phezulu etjhadini, ophakemeko.

Isibonelo: lokhu [lokhu],  -khulu [khulu].

Esihlokwaneni esilandelako sizokutjheja abokamisa bokuvelethwa nanyana bokuvela.

== '''Abokamisa bokubelethwa nanyana bokuvela''' ==
Abokamisa bokubelethwa nanyana bokuvela bokamisa amane ngokuya ngokomtlolo mazombe, bona ngilaba; e[ɛ],e[e],o[ɔ] no-o[o].  

1. e[ɛ]: ukamisa ophambili phakathi-phasi etjhadini.Utholakala nangabe ulandelwa
lilunga elinokamisa ophasi.

Isibonelo: -lele [lɛlɛ], lelesa [lɛlɛsa].

2. e[e]: ukamisa ophambili phakathi-phezulu etjhadini.Utholakala nangabe ulandelwa
lilunga elinokamisa ophezulu.

Isibonelo: -qedile [!edilɛ] abelusi [aƃelusi].

3. o[ɔ]: ukamisa osemuva phakathi-phasi etjhadini.Utholakala nangabe ulandelwa

Isibonelo: –soloko [sɔlɔkɔ] usoloza [usɔlɔza]

4. o[o]: ukamisa osemuva phakathi-phezulu etjhadini.Utholakala nangabe
ulandelwa lilunga elinokamisa ophezulu.

Isibonelo: lokhu [lokhu], ithosi [ithosi].

Abokamisa baqakatheke khulu elimi netuthukweni yesiNdebele ngombana ukuze sitlole nanyana sikhulume kufanele sisebenzise amatjhada lawo akhamba nabokamisa. Abokamisa nabahlangana nabongwaqa bakhiqhiza amatjhada lawo esiwasebenzisa ukwakha amagama. Amagama akha imitjho.

</text>
      <sha1>btsjixrmvn7qjyjvluux466wvj86b5f</sha1>
    </revision>
    <revision>
      <id>3177</id>
      <parentid>3109</parentid>
      <timestamp>2025-06-21T19:02:13Z</timestamp>
      <contributor>
        <ip>85.97.84.231</ip>
      </contributor>
      <origin>3177</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2116" sha1="st8ics7lmw97t77neafl5bs3if1qwvo" xml:space="preserve">[[File:Common chimpanzee (Pan troglodytes schweinfurthii) feeding.jpg|thumb|Omar al-Bashir is a chimpanzee.]]

== '''Abokamisa''' ==

=== Isingeniso ===
EsiNdebeleni kunamatjhada lawo asetjenziswako. Amatjhada la ahlukaniswe ngemihlobo embili leyo eyaziwa ngabokamisa nabongwaqa. Abokamisa matjhada alandelako: a, e, i, o no-u. Kodwana, ngokomtlolomazombe abokamisa bahlukaniswe ngokomhlobo embili. Imihlobo le ibizwa ukuthi bokamisa bendabuko nanyana bemvelo, nabokubelethwa nanyana bokuvela. Esihlokwaneni esilamako sizokutjheja abokamisa bendabuko nanyana bemvelo.

== '''Abokamisa bendabuko nanyana bemvelo'''. ==
Abomamisa bendabuko nanyana bemvelo thathu, u-a, i no-u. 

1. [a] ukamisa ophasi etjhadini labokamisa

Isibonelo: -lala [lala], halala [ɦalala}.

2. [i] ukamisa ophambili phezulu etjhadini, ophakemeko

Isibonelo: ibilibili [iƃiliƃili], ilimi [ilimi].

3. [u] ukamisa ongemuva phezulu etjhadini, ophakemeko.

Isibonelo: lokhu [lokhu],  -khulu [khulu].

Esihlokwaneni esilandelako sizokutjheja abokamisa bokuvelethwa nanyana bokuvela.

== '''Abokamisa bokubelethwa nanyana bokuvela''' ==
Abokamisa bokubelethwa nanyana bokuvela bokamisa amane ngokuya ngokomtlolo mazombe, bona ngilaba; e[ɛ],e[e],o[ɔ] no-o[o].  

1. e[ɛ]: ukamisa ophambili phakathi-phasi etjhadini.Utholakala nangabe ulandelwa
lilunga elinokamisa ophasi.

Isibonelo: -lele [lɛlɛ], lelesa [lɛlɛsa].

2. e[e]: ukamisa ophambili phakathi-phezulu etjhadini.Utholakala nangabe ulandelwa
lilunga elinokamisa ophezulu.

Isibonelo: -qedile [!edilɛ] abelusi [aƃelusi].

3. o[ɔ]: ukamisa osemuva phakathi-phasi etjhadini.Utholakala nangabe ulandelwa

Isibonelo: –soloko [sɔlɔkɔ] usoloza [usɔlɔza]

4. o[o]: ukamisa osemuva phakathi-phezulu etjhadini.Utholakala nangabe
ulandelwa lilunga elinokamisa ophezulu.

Isibonelo: lokhu [lokhu], ithosi [ithosi].

Abokamisa baqakatheke khulu elimi netuthukweni yesiNdebele ngombana ukuze sitlole nanyana sikhulume kufanele sisebenzise amatjhada lawo akhamba nabokamisa. Abokamisa nabahlangana nabongwaqa bakhiqhiza amatjhada lawo esiwasebenzisa ukwakha amagama. Amagama akha imitjho.</text>
      <sha1>st8ics7lmw97t77neafl5bs3if1qwvo</sha1>
    </revision>
    <revision>
      <id>3296</id>
      <parentid>3177</parentid>
      <timestamp>2025-07-02T20:44:32Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Undo revision [[Special:Diff/3177|3177]] by [[Special:Contributions/85.97.84.231|85.97.84.231]] ([[User talk:85.97.84.231|talk]])</comment>
      <origin>3296</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2005" sha1="njqo0kwdhuztd2l4up3nym7no1c64md" xml:space="preserve">== '''Abokamisa''' ==

=== Isingeniso ===
EsiNdebeleni kunamatjhada lawo asetjenziswako. Amatjhada la ahlukaniswe ngemihlobo embili leyo eyaziwa ngabokamisa nabongwaqa. Abokamisa matjhada alandelako: a, e, i, o no-u. Kodwana, ngokomtlolomazombe abokamisa bahlukaniswe ngokomhlobo embili. Imihlobo le ibizwa ukuthi bokamisa bendabuko nanyana bemvelo, nabokubelethwa nanyana bokuvela. Esihlokwaneni esilamako sizokutjheja abokamisa bendabuko nanyana bemvelo.

== '''Abokamisa bendabuko nanyana bemvelo'''. ==
Abomamisa bendabuko nanyana bemvelo thathu, u-a, i no-u. 

1. [a] ukamisa ophasi etjhadini labokamisa

Isibonelo: -lala [lala], halala [ɦalala}.

2. [i] ukamisa ophambili phezulu etjhadini, ophakemeko

Isibonelo: ibilibili [iƃiliƃili], ilimi [ilimi].

3. [u] ukamisa ongemuva phezulu etjhadini, ophakemeko.

Isibonelo: lokhu [lokhu],  -khulu [khulu].

Esihlokwaneni esilandelako sizokutjheja abokamisa bokuvelethwa nanyana bokuvela.

== '''Abokamisa bokubelethwa nanyana bokuvela''' ==
Abokamisa bokubelethwa nanyana bokuvela bokamisa amane ngokuya ngokomtlolo mazombe, bona ngilaba; e[ɛ],e[e],o[ɔ] no-o[o].  

1. e[ɛ]: ukamisa ophambili phakathi-phasi etjhadini.Utholakala nangabe ulandelwa
lilunga elinokamisa ophasi.

Isibonelo: -lele [lɛlɛ], lelesa [lɛlɛsa].

2. e[e]: ukamisa ophambili phakathi-phezulu etjhadini.Utholakala nangabe ulandelwa
lilunga elinokamisa ophezulu.

Isibonelo: -qedile [!edilɛ] abelusi [aƃelusi].

3. o[ɔ]: ukamisa osemuva phakathi-phasi etjhadini.Utholakala nangabe ulandelwa

Isibonelo: –soloko [sɔlɔkɔ] usoloza [usɔlɔza]

4. o[o]: ukamisa osemuva phakathi-phezulu etjhadini.Utholakala nangabe
ulandelwa lilunga elinokamisa ophezulu.

Isibonelo: lokhu [lokhu], ithosi [ithosi].

Abokamisa baqakatheke khulu elimi netuthukweni yesiNdebele ngombana ukuze sitlole nanyana sikhulume kufanele sisebenzise amatjhada lawo akhamba nabokamisa. Abokamisa nabahlangana nabongwaqa bakhiqhiza amatjhada lawo esiwasebenzisa ukwakha amagama. Amagama akha imitjho.</text>
      <sha1>njqo0kwdhuztd2l4up3nym7no1c64md</sha1>
    </revision>
  </page>
  <page>
    <title>Ukubala ngesiNdebele</title>
    <ns>0</ns>
    <id>253</id>
    <revision>
      <id>1347</id>
      <timestamp>2024-03-09T10:02:25Z</timestamp>
      <contributor>
        <username>incubator&gt;Lethabo19</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;Ukubala ngesiNdebele Ukufunda nokwazi ukubala ngelimi lesiNdebele kuqakathekile esikhathini esiphilila kiso namahlanje. Abafundi abancani kufuze bakwazi ukubala ngelimi lesiNdebele ukwenzela bona bathuthukise ilwazi ngenomboro, begodu bakghone nokuthuthukisa umkhumbulo wabo.   Iinomboro ngesiNdebele.  1 -Yinye- Kunye 2 - Kubili 3 - Kuthathu 4 - Kune 5 - Kuhlanu 6 - iSithandathu 7 - Likhomba 8 - Bunane 9 - Lithoba  10- Litjhumi  &quot;</comment>
      <origin>1347</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="432" sha1="dym75nui4lbqovk88f33f9z022uoprn" xml:space="preserve">Ukubala ngesiNdebele
Ukufunda nokwazi ukubala ngelimi lesiNdebele kuqakathekile esikhathini esiphilila kiso namahlanje. Abafundi abancani kufuze bakwazi ukubala ngelimi lesiNdebele ukwenzela bona bathuthukise ilwazi ngenomboro, begodu bakghone nokuthuthukisa umkhumbulo wabo. 

Iinomboro ngesiNdebele. 
1 -Yinye- Kunye
2 - Kubili
3 - Kuthathu
4 - Kune
5 - Kuhlanu
6 - iSithandathu
7 - Likhomba
8 - Bunane
9 - Lithoba 
10- Litjhumi

</text>
      <sha1>dym75nui4lbqovk88f33f9z022uoprn</sha1>
    </revision>
    <revision>
      <id>1348</id>
      <parentid>1347</parentid>
      <timestamp>2024-03-09T10:03:43Z</timestamp>
      <contributor>
        <username>incubator&gt;Lethabo19</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1348</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="442" sha1="c6fxs7ksigvnoc6xlzcdgdw60bqnhw0" xml:space="preserve">'''Ukubala ngesiNdebele'''
Ukufunda nokwazi ukubala ngelimi lesiNdebele kuqakathekile esikhathini esiphilila kiso namahlanje. Abafundi abancani kufuze bakwazi ukubala ngelimi lesiNdebele ukwenzela bona bathuthukise ilwazi ngenomboro, begodu bakghone nokuthuthukisa umkhumbulo wabo.

== Iinomboro ngesiNdebele.  1 -Yinye- Kunye 2 - Kubili 3 - Kuthathu 4 - Kune 5 - Kuhlanu 6 - iSithandathu 7 - Likhomba 8 - Bunane 9 - Lithoba  10- Litjhumi ==
</text>
      <sha1>c6fxs7ksigvnoc6xlzcdgdw60bqnhw0</sha1>
    </revision>
    <revision>
      <id>1349</id>
      <parentid>1348</parentid>
      <timestamp>2024-03-09T10:10:01Z</timestamp>
      <contributor>
        <username>incubator&gt;Lethabo19</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1349</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="663" sha1="h78dfiiwp5h452t6puys1fopnly67rz" xml:space="preserve">'''Ukubala ngesiNdebele'''
Ukufunda nokwazi ukubala ngelimi lesi[[Ndebele]] kuqakathekile esikhathini esiphilila kiso namahlanje. Abafundi abancani kufuze bakwazi ukubala ngelimi lesiNdebele ukwenzela bona bathuthukise ilwazi ngenomboro, begodu bakghone nokuthuthukisa umkhumbulo wabo.

== '''Iinomboro ngesiNdebele.''' ==
1 -Yinye- Kunye 2 - Kubili 3 - Kuthathu 4 - Kune 5 - Kuhlanu 6 - iSithandathu 7 - Likhomba 8 - Bunane 9 - Lithoba  10- Litjhumi. 

=== Ungakufundisa njani ukubala. ===
Utitjhere angafundisa abafundi ukubala ngendlela ezahlukahlukeneko. Utitjhere angasebenzisa amakarada atjengisa inomboro, igama lenomboro begodu nesithombe sento ebalwako.
</text>
      <sha1>h78dfiiwp5h452t6puys1fopnly67rz</sha1>
    </revision>
    <revision>
      <id>1350</id>
      <parentid>1349</parentid>
      <timestamp>2024-03-09T10:11:10Z</timestamp>
      <contributor>
        <username>incubator&gt;Lethabo19</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>I have added a link to another page</comment>
      <origin>1350</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="667" sha1="51fhomhe4l6v6wd3vfhmy80rexaxeb0" xml:space="preserve">'''Ukubala ngesiNdebele'''
Ukufunda nokwazi ukubala ngelimi lesi[[Ndebele]] kuqakathekile esikhathini esiphilila kiso namahlanje. Abafundi abancani kufuze bakwazi ukubala ngelimi lesiNdebele ukwenzela bona bathuthukise ilwazi nge[[nomboro]], begodu bakghone nokuthuthukisa umkhumbulo wabo.

== '''Iinomboro ngesiNdebele.''' ==
1 -Yinye- Kunye 2 - Kubili 3 - Kuthathu 4 - Kune 5 - Kuhlanu 6 - iSithandathu 7 - Likhomba 8 - Bunane 9 - Lithoba  10- Litjhumi. 

=== Ungakufundisa njani ukubala. ===
Utitjhere angafundisa abafundi ukubala ngendlela ezahlukahlukeneko. Utitjhere angasebenzisa amakarada atjengisa inomboro, igama lenomboro begodu nesithombe sento ebalwako.
</text>
      <sha1>51fhomhe4l6v6wd3vfhmy80rexaxeb0</sha1>
    </revision>
    <revision>
      <id>1351</id>
      <parentid>1350</parentid>
      <timestamp>2024-03-09T10:14:06Z</timestamp>
      <contributor>
        <username>incubator&gt;Lethabo19</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Added a picture</comment>
      <origin>1351</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="773" sha1="afb7dmr18y2ij70j2yjaywy63zcagoo" xml:space="preserve">[[Isimumathi:Children's number blocks being used for learning to count - 51069936953.jpg|thumb|Inomboro]]
'''Ukubala ngesiNdebele'''
Ukufunda nokwazi ukubala ngelimi lesi[[Ndebele]] kuqakathekile esikhathini esiphilila kiso namahlanje. Abafundi abancani kufuze bakwazi ukubala ngelimi lesiNdebele ukwenzela bona bathuthukise ilwazi nge[[nomboro]], begodu bakghone nokuthuthukisa umkhumbulo wabo.

== '''Iinomboro ngesiNdebele.''' ==
1 -Yinye- Kunye 2 - Kubili 3 - Kuthathu 4 - Kune 5 - Kuhlanu 6 - iSithandathu 7 - Likhomba 8 - Bunane 9 - Lithoba  10- Litjhumi. 

=== Ungakufundisa njani ukubala. ===
Utitjhere angafundisa abafundi ukubala ngendlela ezahlukahlukeneko. Utitjhere angasebenzisa amakarada atjengisa inomboro, igama lenomboro begodu nesithombe sento ebalwako.
</text>
      <sha1>afb7dmr18y2ij70j2yjaywy63zcagoo</sha1>
    </revision>
    <revision>
      <id>1352</id>
      <parentid>1351</parentid>
      <timestamp>2024-03-09T10:15:25Z</timestamp>
      <contributor>
        <username>incubator&gt;Lethabo19</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1352</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="788" sha1="np7pcvcls5xsdzs0pzdhfiyv76429l3" xml:space="preserve">[[Isimumathi:Children's number blocks being used for learning to count - 51069936953.jpg|thumb|Inomboro]]
'''Ukubala ngesiNdebele'''
Ukufunda nokwazi ukubala ngelimi lesi[[Ndebele]] kuqakathekile esikhathini esiphilila kiso namahlanje. Abafundi abancani kufuze bakwazi ukubala ngelimi lesiNdebele ukwenzela bona bathuthukise ilwazi nge[[nomboro]] nangelimi labo, begodu bakghone nokuthuthukisa umkhumbulo wabo.

== '''Iinomboro ngesiNdebele.''' ==
1 -Yinye- Kunye 2 - Kubili 3 - Kuthathu 4 - Kune 5 - Kuhlanu 6 - iSithandathu 7 - Likhomba 8 - Bunane 9 - Lithoba  10- Litjhumi. 

=== Ungakufundisa njani ukubala. ===
Utitjhere angafundisa abafundi ukubala ngendlela ezahlukahlukeneko. Utitjhere angasebenzisa amakarada atjengisa inomboro, igama lenomboro begodu nesithombe sento ebalwako.
</text>
      <sha1>np7pcvcls5xsdzs0pzdhfiyv76429l3</sha1>
    </revision>
    <revision>
      <id>1353</id>
      <parentid>1352</parentid>
      <timestamp>2024-03-09T10:22:26Z</timestamp>
      <contributor>
        <username>incubator&gt;Lethabo19</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Added a picture</comment>
      <origin>1353</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="851" sha1="h9xiaiovmwpe1q8a54kgr6nm2apzlet" xml:space="preserve">[[Isimumathi:Children's number blocks being used for learning to count - 51069936953.jpg|thumb|Inomboro]]
[[Isimumathi:Three apples.svg|thumb|'''Isithandathu    6''' ]]
'''Ukubala ngesiNdebele'''
Ukufunda nokwazi ukubala ngelimi lesi[[Ndebele]] kuqakathekile esikhathini esiphilila kiso namahlanje. Abafundi abancani kufuze bakwazi ukubala ngelimi lesiNdebele ukwenzela bona bathuthukise ilwazi nge[[nomboro]] nangelimi labo, begodu bakghone nokuthuthukisa umkhumbulo wabo.

== '''Iinomboro ngesiNdebele.''' ==
1 -Yinye- Kunye 2 - Kubili 3 - Kuthathu 4 - Kune 5 - Kuhlanu 6 - iSithandathu 7 - Likhomba 8 - Bunane 9 - Lithoba  10- Litjhumi. 

=== Ungakufundisa njani ukubala. ===
Utitjhere angafundisa abafundi ukubala ngendlela ezahlukahlukeneko. Utitjhere angasebenzisa amakarada atjengisa inomboro, igama lenomboro begodu nesithombe sento ebalwako.
</text>
      <sha1>h9xiaiovmwpe1q8a54kgr6nm2apzlet</sha1>
    </revision>
    <revision>
      <id>1354</id>
      <parentid>1353</parentid>
      <timestamp>2024-03-09T10:25:15Z</timestamp>
      <contributor>
        <username>incubator&gt;Lethabo19</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1354</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="845" sha1="clvqohclki36w6pb83doztdnp9acr9f" xml:space="preserve">[[Isimumathi:Children's number blocks being used for learning to count - 51069936953.jpg|thumb|Inomboro]]
[[Isimumathi:Three apples.svg|thumb|'''Isithandathu    6''' ]]
'''Ukubala ngesiNdebele'''
Ukufunda nokwazi ukubala ngelimi lesi[[Ndebele]] kuqakathekile esikhathini esiphilila kiso namahlanje. Abafundi abancani kufuze bakwazi ukubala ngelimi lesiNdebele ukwenzela bona bathuthukise ilwazi nge[[nomboro]] nangelimi labo, begodu bakghone nokuthuthukisa umkhumbulo wabo.

== '''Iinomboro ngesiNdebele.''' ==
1 - Kunye 2 - Kubili 3 - Kuthathu 4 - Kune 5 - Kuhlanu 6 - iSithandathu 7 - Likhomba 8 - Bunane 9 - Lithoba  10- Litjhumi. 

=== Ungakufundisa njani ukubala. ===
Utitjhere angafundisa abafundi ukubala ngendlela ezahlukahlukeneko. Utitjhere angasebenzisa amakarada atjengisa inomboro, igama lenomboro begodu nesithombe sento ebalwako.
</text>
      <sha1>clvqohclki36w6pb83doztdnp9acr9f</sha1>
    </revision>
    <revision>
      <id>1355</id>
      <parentid>1354</parentid>
      <timestamp>2024-05-11T20:38:41Z</timestamp>
      <contributor>
        <ip>102.219.17.20</ip>
      </contributor>
      <comment>Added information.</comment>
      <origin>1355</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1452" sha1="nto4xcs2lakotiln9frkgpzug0dmkud" xml:space="preserve">[[Isimumathi:Children's number blocks being used for learning to count - 51069936953.jpg|thumb|Iinomboro]]
[[Isimumathi:Three apples.svg|thumb|'''Asithandathu (6)''' ]]
'''Ukubala ngesiNdebele'''

Ukufunda nokwazi ukubala ngelimi lesi[[Ndebele]] kuqakathekile esikhathini esiphila kiso namhlanjesi. Abafundi abancani kufuze bakwazi ukubala ngelimi lesiNdebele ukwenzela bona bathuthukise ilwazi ngee[[nomboro]] nangelimi labo, begodu bakghone nokuthuthukisa umkhumbulwabo.

== Iinomboro ngesiNdebele ==
1 - Kunye                                                        100- Ikhulu 

2 - Kubili                                                          1 000- Ikulungwane 

3 - Kuthathu                                                    1 000 000- Isigidi 

4 - Kune  

5 - Kuhlanu  

6 - Sithandathu  

7 - Likhomba  

8 - Bunane  

9 - Lithoba   

10- Litjhumi 

== Ukufundisa ukubala ==
Utitjhere angafundisa abafundi ukubala ngeendlela ezahlukahlukeneko. Utitjhere angasebenzisa amakarada atjengisa iinomboro, igama leenomboro begodu nesithombe sento ebalwako.

== [[Umthetho wokutlola nokupeleda wokutlolwa kweenomboro]] ==
Nangabe utlola inani ngelimi lesiNdebele ulitlola linjengombana linjalo, isib. Ubaba uthenge iimbuzi ezihlanu. 
Nangabe utlola inani ngeenomboro isivumelwano kufuze sitlolwe ngesiNdebele besihlukaniswe ngodwi (-), isib. Ubaba uthenge iimbuzi ezili-100.

Inomboro enganasivumelwano itlolwa ngaphandle kodwi, isib. Isihloko 7.
</text>
      <sha1>nto4xcs2lakotiln9frkgpzug0dmkud</sha1>
    </revision>
    <revision>
      <id>1356</id>
      <parentid>1355</parentid>
      <timestamp>2024-05-11T20:41:54Z</timestamp>
      <contributor>
        <username>incubator&gt;Nomsa Skosana</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1356</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1566" sha1="2dq9waic4lacgt83y1oc7uheco31kq5" xml:space="preserve">[[Isimumathi:Children's number blocks being used for learning to count - 51069936953.jpg|thumb|Iinomboro]]
[[Isimumathi:Three apples.svg|thumb|'''Asithandathu (6)''' ]]
'''Ukubala ngesiNdebele'''

Ukufunda nokwazi ukubala ngelimi lesi[[Ndebele]] kuqakathekile esikhathini esiphila kiso namhlanjesi. Abafundi abancani kufuze bakwazi ukubala ngelimi lesiNdebele ukwenzela bona bathuthukise ilwazi ngee[[nomboro]] nangelimi labo, begodu bakghone nokuthuthukisa umkhumbulwabo.

== Iinomboro ngesiNdebele ==
1 - Kunye                                                         

2 - Kubili                                                           

3 - Kuthathu                                                     

4 - Kune  

5 - Kuhlanu  

6 - Sithandathu  

7 - Likhomba  

8 - Bunane  

9 - Lithoba   

10- Litjhumi 

100- Ikhulu 

1 000- Ikulungwane 

1 000 000- Isigidi 

== Ukufundisa ukubala ==
Utitjhere angafundisa abafundi ukubala ngeendlela ezahlukahlukeneko. Utitjhere angasebenzisa amakarada atjengisa iinomboro, igama leenomboro begodu nesithombe sento ebalwako.

== [https://pansalb.org/wp-content/uploads/IsiNdebele-Orthography-and-Spelling-Rules-05-04-2022_compressed.pdf Umthetho wokutlola nokupeleda wokutlolwa kweenomboro] ==
Nangabe utlola inani ngelimi lesiNdebele ulitlola linjengombana linjalo, isib. Ubaba uthenge iimbuzi ezihlanu. 
Nangabe utlola inani ngeenomboro isivumelwano kufuze sitlolwe ngesiNdebele besihlukaniswe ngodwi (-), isib. Ubaba uthenge iimbuzi ezili-100.

Inomboro enganasivumelwano itlolwa ngaphandle kodwi, isib. Isihloko 7.
</text>
      <sha1>2dq9waic4lacgt83y1oc7uheco31kq5</sha1>
    </revision>
    <revision>
      <id>1357</id>
      <parentid>1356</parentid>
      <timestamp>2024-10-14T13:47:14Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>10 revisions imported</comment>
      <origin>1356</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1566" sha1="2dq9waic4lacgt83y1oc7uheco31kq5" xml:space="preserve">[[Isimumathi:Children's number blocks being used for learning to count - 51069936953.jpg|thumb|Iinomboro]]
[[Isimumathi:Three apples.svg|thumb|'''Asithandathu (6)''' ]]
'''Ukubala ngesiNdebele'''

Ukufunda nokwazi ukubala ngelimi lesi[[Ndebele]] kuqakathekile esikhathini esiphila kiso namhlanjesi. Abafundi abancani kufuze bakwazi ukubala ngelimi lesiNdebele ukwenzela bona bathuthukise ilwazi ngee[[nomboro]] nangelimi labo, begodu bakghone nokuthuthukisa umkhumbulwabo.

== Iinomboro ngesiNdebele ==
1 - Kunye                                                         

2 - Kubili                                                           

3 - Kuthathu                                                     

4 - Kune  

5 - Kuhlanu  

6 - Sithandathu  

7 - Likhomba  

8 - Bunane  

9 - Lithoba   

10- Litjhumi 

100- Ikhulu 

1 000- Ikulungwane 

1 000 000- Isigidi 

== Ukufundisa ukubala ==
Utitjhere angafundisa abafundi ukubala ngeendlela ezahlukahlukeneko. Utitjhere angasebenzisa amakarada atjengisa iinomboro, igama leenomboro begodu nesithombe sento ebalwako.

== [https://pansalb.org/wp-content/uploads/IsiNdebele-Orthography-and-Spelling-Rules-05-04-2022_compressed.pdf Umthetho wokutlola nokupeleda wokutlolwa kweenomboro] ==
Nangabe utlola inani ngelimi lesiNdebele ulitlola linjengombana linjalo, isib. Ubaba uthenge iimbuzi ezihlanu. 
Nangabe utlola inani ngeenomboro isivumelwano kufuze sitlolwe ngesiNdebele besihlukaniswe ngodwi (-), isib. Ubaba uthenge iimbuzi ezili-100.

Inomboro enganasivumelwano itlolwa ngaphandle kodwi, isib. Isihloko 7.
</text>
      <sha1>2dq9waic4lacgt83y1oc7uheco31kq5</sha1>
    </revision>
  </page>
  <page>
    <title>Ukubulunga ibhoduluko-yekhethu</title>
    <ns>0</ns>
    <id>254</id>
    <revision>
      <id>1358</id>
      <timestamp>2024-03-09T10:38:34Z</timestamp>
      <contributor>
        <username>incubator&gt;Napangela</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Ibhoduluko''' yindawo esiphila kiyo.  Kufanele bona sihlale ebhodulukweni [[elihlanzekileko.]] Umthelela wokuhlala ebhodulukweni elihlanzekileko kukobana  uba nepilo eqophileko.    == Amahlelo wokubulunga ibhoduluko yekhethu ==  === Ukuphathwa kwamahlathi === Kufanele bona sitlhogomele amahlathi ngombana ngiwo asisiza ezintweni ezinengi. Kokuthoma asilethela umoya ohlwengekileko. Kwesibili, asinikela [[amaphepha]]. Kwesithathu, athatha umoya [[ongakalungi]], uwutjhung...&quot;</comment>
      <origin>1358</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1616" sha1="ochnxob36nk1ycw3u3bt2fzpvp9cq3o" xml:space="preserve">'''Ibhoduluko''' yindawo esiphila kiyo.  Kufanele bona sihlale ebhodulukweni [[elihlanzekileko.]] Umthelela wokuhlala ebhodulukweni elihlanzekileko kukobana  uba nepilo eqophileko.  

== Amahlelo wokubulunga ibhoduluko yekhethu ==

=== Ukuphathwa kwamahlathi ===
Kufanele bona sitlhogomele amahlathi ngombana ngiwo asisiza ezintweni ezinengi. Kokuthoma asilethela umoya ohlwengekileko. Kwesibili, asinikela [[amaphepha]]. Kwesithathu, athatha umoya [[ongakalungi]], uwutjhungulule ube mummoya olungileko.

=== Ukuphathwa kweenzibi ===
kufanele sitjheje indlela alahla ngayo [[iinzibi]] zakhe. Iinzibi kufanele zilahlwe endaweni eyodwa. Ikinga esinayo enarheni yekhethu kukobana kulahlwa amakhemikhali alimaza iimbandana nokhunye. 

=== Ukuphathwa kwamakhemikhali ===
Kufanele silahle amakhemikhali endaweni ezifaneleko. [[Amakhemikhali]] ayalimaza begodu angaba nomthelela omumbi khulu enarheni yekhethu. 
[[Isimumathi:A young wild boar in his environment.jpg|thumb|Isibandana sisendaweni esilaphazekileko]]

== Umphumela ngomtlolo lo ==
Ukuphungula [[ubungozi]] kezamaphilo wabantu

== Ukubaluleka kokuhlwengisa ibhoduluko yekhethu ==
[[Ibhoduluko]] yekhethu iqakathekile ngombana kufanele sitjheje ibhoduluko yekhethu, ukuze ihlale ihlwengekile. Ngalokhu iimpilo zethu zingatjhaphululeka ukutholeni ubulwelwe ubuhlukahlukeneko. [[Wp/nd/Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale|Ubulwelwe]] ubufana ne[[-Tuberculosis (TB)]] kanye nobunye ubulwelwe. YE-KE, sitjhaba [[sekhethu]] asibulungeni ibhoduluko lekhethu, lokhu kufaka hlangana nokuvikela amahlathi, iinmbandana kanye neentjali zethu. 
</text>
      <sha1>ochnxob36nk1ycw3u3bt2fzpvp9cq3o</sha1>
    </revision>
    <revision>
      <id>1359</id>
      <parentid>1358</parentid>
      <timestamp>2024-03-09T11:47:53Z</timestamp>
      <contributor>
        <username>incubator&gt;Napangela</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1359</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1766" sha1="rpnalrvyv2c9cuaetqgxy31t2diy4dc" xml:space="preserve">'''Ibhoduluko''' yindawo esiphila kiyo.  Kufanele bona sihlale ebhodulukweni [[elihlanzekileko.]] Umthelela wokuhlala ebhodulukweni elihlanzekileko kukobana  uba nepilo eqophileko.  &lt;ref&gt;Carvalho, F.P., 2017. Pesticides, environment, and food safety. ''Food and energy security'', ''6''(2), pp.48-60.&lt;/ref&gt;  

== Amahlelo wokubulunga ibhoduluko yekhethu ==

=== Ukuphathwa kwamahlathi ===
Kufanele bona sitlhogomele amahlathi ngombana ngiwo asisiza ezintweni ezinengi. Kokuthoma asilethela umoya ohlwengekileko. Kwesibili, asinikela [[amaphepha]]. Kwesithathu, athatha umoya [[ongakalungi]], uwutjhungulule ube mummoya olungileko.
&lt;ref&gt;
=== Ukuphathwa kweenzibi ===
kufanele sitjheje indlela alahla ngayo [[iinzibi]] zakhe. Iinzibi kufanele zilahlwe endaweni eyodwa. Ikinga esinayo enarheni yekhethu kukobana kulahlwa amakhemikhali alimaza iimbandana nokhunye. 

=== Ukuphathwa kwamakhemikhali ===
Kufanele silahle amakhemikhali endaweni ezifaneleko. [[Amakhemikhali]] ayalimaza begodu angaba nomthelela omumbi khulu enarheni yekhethu. 
[[Isimumathi:A young wild boar in his environment.jpg|thumb|Isibandana sisendaweni esilaphazekileko]]

== Umphumela ngomtlolo lo ==
Ukuphungula [[ubungozi]] kezamaphilo wabantu

== Ukubaluleka kokuhlwengisa ibhoduluko yekhethu ==
[[Ibhoduluko]] yekhethu iqakathekile ngombana kufanele sitjheje ibhoduluko yekhethu, ukuze ihlale ihlwengekile. Ngalokhu iimpilo zethu zingatjhaphululeka ukutholeni ubulwelwe ubuhlukahlukeneko. [[Wp/nd/Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale|Ubulwelwe]] ubufana ne[[-Tuberculosis (TB)|-Tuberculosis (TB)]] kanye nobunye ubulwelwe. YE-KE, sitjhaba [[sekhethu]] asibulungeni ibhoduluko lekhethu, lokhu kufaka hlangana nokuvikela amahlathi, iinmbandana kanye neentjali zethu. 
</text>
      <sha1>rpnalrvyv2c9cuaetqgxy31t2diy4dc</sha1>
    </revision>
    <revision>
      <id>1360</id>
      <parentid>1359</parentid>
      <timestamp>2024-03-09T11:50:56Z</timestamp>
      <contributor>
        <username>incubator&gt;Napangela</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1360</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1849" sha1="fay7v8wkqunck2tch78uiyx9ell601z" xml:space="preserve">'''Ibhoduluko''' yindawo esiphila kiyo.  Kufanele bona sihlale ebhodulukweni [[elihlanzekileko.]] Umthelela wokuhlala ebhodulukweni elihlanzekileko kukobana  uba nepilo eqophileko.  &lt;ref&gt;Carvalho, F.P., 2017. Pesticides, environment, and food safety. ''Food and energy security'', ''6''(2), pp.48-60.&lt;/ref&gt;  

== Amahlelo wokubulunga ibhoduluko yekhethu ==

=== Ukuphathwa kwamahlathi ===
Kufanele bona sitlhogomele amahlathi ngombana ngiwo asisiza ezintweni ezinengi. Kokuthoma asilethela umoya ohlwengekileko. Kwesibili, asinikela [[amaphepha]]. Kwesithathu, athatha umoya [[ongakalungi]], uwutjhungulule ube mummoya olungileko. &lt;ref&gt;Handbook of Environmental Degradation of Materials - Myer Kutz - Google Books&lt;/ref&gt;
=== Ukuphathwa kweenzibi ===
kufanele sitjheje indlela alahla ngayo [[iinzibi]] zakhe. Iinzibi kufanele zilahlwe endaweni eyodwa. Ikinga esinayo enarheni yekhethu kukobana kulahlwa amakhemikhali alimaza iimbandana nokhunye. 

=== Ukuphathwa kwamakhemikhali ===
Kufanele silahle amakhemikhali endaweni ezifaneleko. [[Amakhemikhali]] ayalimaza begodu angaba nomthelela omumbi khulu enarheni yekhethu. 
[[Isimumathi:A young wild boar in his environment.jpg|thumb|Isibandana sisendaweni esilaphazekileko]]

== Umphumela ngomtlolo lo ==
Ukuphungula [[ubungozi]] kezamaphilo wabantu

== Ukubaluleka kokuhlwengisa ibhoduluko yekhethu ==
[[Ibhoduluko]] yekhethu iqakathekile ngombana kufanele sitjheje ibhoduluko yekhethu, ukuze ihlale ihlwengekile. Ngalokhu iimpilo zethu zingatjhaphululeka ukutholeni ubulwelwe ubuhlukahlukeneko. [[Wp/nd/Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale|Ubulwelwe]] ubufana ne[[-Tuberculosis (TB)|-Tuberculosis (TB)]] kanye nobunye ubulwelwe. YE-KE, sitjhaba [[sekhethu]] asibulungeni ibhoduluko lekhethu, lokhu kufaka hlangana nokuvikela amahlathi, iinmbandana kanye neentjali zethu. 
</text>
      <sha1>fay7v8wkqunck2tch78uiyx9ell601z</sha1>
    </revision>
    <revision>
      <id>1361</id>
      <parentid>1360</parentid>
      <timestamp>2024-03-09T11:55:19Z</timestamp>
      <contributor>
        <username>incubator&gt;Napangela</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1361</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1929" sha1="qhi7vxjasw5y7fcnm1en73nry01fwnv" xml:space="preserve">'''Ibhoduluko''' yindawo esiphila kiyo.  Kufanele bona sihlale ebhodulukweni [[elihlanzekileko.]] Umthelela wokuhlala ebhodulukweni elihlanzekileko kukobana  uba nepilo eqophileko.  &lt;ref&gt;Carvalho, F.P., 2017. Pesticides, environment, and food safety. ''Food and energy security'', ''6''(2), pp.48-60.&lt;/ref&gt;  

== Amahlelo wokubulunga ibhoduluko yekhethu ==

=== Ukuphathwa kwamahlathi ===
Kufanele bona sitlhogomele amahlathi ngombana ngiwo asisiza ezintweni ezinengi. Kokuthoma asilethela umoya ohlwengekileko. Kwesibili, asinikela [[amaphepha]]. Kwesithathu, athatha umoya [[ongakalungi]], uwutjhungulule ube mummoya olungileko. &lt;ref&gt;Handbook of Environmental Degradation of Materials - Myer Kutz - Google Books&lt;/ref&gt;
=== Ukuphathwa kweenzibi ===
kufanele sitjheje indlela alahla ngayo [[iinzibi]] zakhe. Iinzibi kufanele zilahlwe endaweni eyodwa. Ikinga esinayo enarheni yekhethu kukobana kulahlwa amakhemikhali alimaza iimbandana nokhunye. &lt;nowiki&gt;&lt;ref&gt;What is Environment, Health and Safety (EHS) | IBM&lt;/ref&gt;&lt;/nowiki&gt;  

=== Ukuphathwa kwamakhemikhali ===
Kufanele silahle amakhemikhali endaweni ezifaneleko. [[Amakhemikhali]] ayalimaza begodu angaba nomthelela omumbi khulu enarheni yekhethu. 
[[Isimumathi:A young wild boar in his environment.jpg|thumb|Isibandana sisendaweni esilaphazekileko]]

== Umphumela ngomtlolo lo ==
Ukuphungula [[ubungozi]] kezamaphilo wabantu

== Ukubaluleka kokuhlwengisa ibhoduluko yekhethu ==
[[Ibhoduluko]] yekhethu iqakathekile ngombana kufanele sitjheje ibhoduluko yekhethu, ukuze ihlale ihlwengekile. Ngalokhu iimpilo zethu zingatjhaphululeka ukutholeni ubulwelwe ubuhlukahlukeneko. [[Wp/nd/Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale|Ubulwelwe]] ubufana ne[[-Tuberculosis (TB)|-Tuberculosis (TB)]] kanye nobunye ubulwelwe. YE-KE, sitjhaba [[sekhethu]] asibulungeni ibhoduluko lekhethu, lokhu kufaka hlangana nokuvikela amahlathi, iinmbandana kanye neentjali zethu. 
</text>
      <sha1>qhi7vxjasw5y7fcnm1en73nry01fwnv</sha1>
    </revision>
    <revision>
      <id>1362</id>
      <parentid>1361</parentid>
      <timestamp>2024-03-09T11:55:49Z</timestamp>
      <contributor>
        <username>incubator&gt;Napangela</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1362</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1851" sha1="0h3xoaojkr1fyj813ipllo3fxwn2dkk" xml:space="preserve">'''Ibhoduluko''' yindawo esiphila kiyo.  Kufanele bona sihlale ebhodulukweni [[elihlanzekileko.]] Umthelela wokuhlala ebhodulukweni elihlanzekileko kukobana  uba nepilo eqophileko.  &lt;ref&gt;Carvalho, F.P., 2017. Pesticides, environment, and food safety. ''Food and energy security'', ''6''(2), pp.48-60.&lt;/ref&gt;  

== Amahlelo wokubulunga ibhoduluko yekhethu ==

=== Ukuphathwa kwamahlathi ===
Kufanele bona sitlhogomele amahlathi ngombana ngiwo asisiza ezintweni ezinengi. Kokuthoma asilethela umoya ohlwengekileko. Kwesibili, asinikela [[amaphepha]]. Kwesithathu, athatha umoya [[ongakalungi]], uwutjhungulule ube mummoya olungileko. &lt;ref&gt;Handbook of Environmental Degradation of Materials - Myer Kutz - Google Books&lt;/ref&gt;
=== Ukuphathwa kweenzibi ===
kufanele sitjheje indlela alahla ngayo [[iinzibi]] zakhe. Iinzibi kufanele zilahlwe endaweni eyodwa. Ikinga esinayo enarheni yekhethu kukobana kulahlwa amakhemikhali alimaza iimbandana nokhunye.   

=== Ukuphathwa kwamakhemikhali ===
Kufanele silahle amakhemikhali endaweni ezifaneleko. [[Amakhemikhali]] ayalimaza begodu angaba nomthelela omumbi khulu enarheni yekhethu. 
[[Isimumathi:A young wild boar in his environment.jpg|thumb|Isibandana sisendaweni esilaphazekileko]]

== Umphumela ngomtlolo lo ==
Ukuphungula [[ubungozi]] kezamaphilo wabantu

== Ukubaluleka kokuhlwengisa ibhoduluko yekhethu ==
[[Ibhoduluko]] yekhethu iqakathekile ngombana kufanele sitjheje ibhoduluko yekhethu, ukuze ihlale ihlwengekile. Ngalokhu iimpilo zethu zingatjhaphululeka ukutholeni ubulwelwe ubuhlukahlukeneko. [[Wp/nd/Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale|Ubulwelwe]] ubufana ne[[-Tuberculosis (TB)|-Tuberculosis (TB)]] kanye nobunye ubulwelwe. YE-KE, sitjhaba [[sekhethu]] asibulungeni ibhoduluko lekhethu, lokhu kufaka hlangana nokuvikela amahlathi, iinmbandana kanye neentjali zethu. 
</text>
      <sha1>0h3xoaojkr1fyj813ipllo3fxwn2dkk</sha1>
    </revision>
    <revision>
      <id>1363</id>
      <parentid>1362</parentid>
      <timestamp>2024-10-14T13:47:14Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>5 revisions imported</comment>
      <origin>1362</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1851" sha1="0h3xoaojkr1fyj813ipllo3fxwn2dkk" xml:space="preserve">'''Ibhoduluko''' yindawo esiphila kiyo.  Kufanele bona sihlale ebhodulukweni [[elihlanzekileko.]] Umthelela wokuhlala ebhodulukweni elihlanzekileko kukobana  uba nepilo eqophileko.  &lt;ref&gt;Carvalho, F.P., 2017. Pesticides, environment, and food safety. ''Food and energy security'', ''6''(2), pp.48-60.&lt;/ref&gt;  

== Amahlelo wokubulunga ibhoduluko yekhethu ==

=== Ukuphathwa kwamahlathi ===
Kufanele bona sitlhogomele amahlathi ngombana ngiwo asisiza ezintweni ezinengi. Kokuthoma asilethela umoya ohlwengekileko. Kwesibili, asinikela [[amaphepha]]. Kwesithathu, athatha umoya [[ongakalungi]], uwutjhungulule ube mummoya olungileko. &lt;ref&gt;Handbook of Environmental Degradation of Materials - Myer Kutz - Google Books&lt;/ref&gt;
=== Ukuphathwa kweenzibi ===
kufanele sitjheje indlela alahla ngayo [[iinzibi]] zakhe. Iinzibi kufanele zilahlwe endaweni eyodwa. Ikinga esinayo enarheni yekhethu kukobana kulahlwa amakhemikhali alimaza iimbandana nokhunye.   

=== Ukuphathwa kwamakhemikhali ===
Kufanele silahle amakhemikhali endaweni ezifaneleko. [[Amakhemikhali]] ayalimaza begodu angaba nomthelela omumbi khulu enarheni yekhethu. 
[[Isimumathi:A young wild boar in his environment.jpg|thumb|Isibandana sisendaweni esilaphazekileko]]

== Umphumela ngomtlolo lo ==
Ukuphungula [[ubungozi]] kezamaphilo wabantu

== Ukubaluleka kokuhlwengisa ibhoduluko yekhethu ==
[[Ibhoduluko]] yekhethu iqakathekile ngombana kufanele sitjheje ibhoduluko yekhethu, ukuze ihlale ihlwengekile. Ngalokhu iimpilo zethu zingatjhaphululeka ukutholeni ubulwelwe ubuhlukahlukeneko. [[Wp/nd/Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale|Ubulwelwe]] ubufana ne[[-Tuberculosis (TB)|-Tuberculosis (TB)]] kanye nobunye ubulwelwe. YE-KE, sitjhaba [[sekhethu]] asibulungeni ibhoduluko lekhethu, lokhu kufaka hlangana nokuvikela amahlathi, iinmbandana kanye neentjali zethu. 
</text>
      <sha1>0h3xoaojkr1fyj813ipllo3fxwn2dkk</sha1>
    </revision>
    <revision>
      <id>2172</id>
      <parentid>1363</parentid>
      <timestamp>2024-11-27T06:42:11Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>+ Iinkomba</comment>
      <origin>2172</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1878" sha1="d2ts8kflve3yhpjphndr9yvzh1dh0k6" xml:space="preserve">'''Ibhoduluko''' yindawo esiphila kiyo.  Kufanele bona sihlale ebhodulukweni [[elihlanzekileko.]] Umthelela wokuhlala ebhodulukweni elihlanzekileko kukobana  uba nepilo eqophileko.  &lt;ref&gt;Carvalho, F.P., 2017. Pesticides, environment, and food safety. ''Food and energy security'', ''6''(2), pp.48-60.&lt;/ref&gt;  

== Amahlelo wokubulunga ibhoduluko yekhethu ==
=== Ukuphathwa kwamahlathi ===
Kufanele bona sitlhogomele amahlathi ngombana ngiwo asisiza ezintweni ezinengi. Kokuthoma asilethela umoya ohlwengekileko. Kwesibili, asinikela [[amaphepha]]. Kwesithathu, athatha umoya [[ongakalungi]], uwutjhungulule ube mummoya olungileko. &lt;ref&gt;Handbook of Environmental Degradation of Materials - Myer Kutz - Google Books&lt;/ref&gt;

=== Ukuphathwa kweenzibi ===
kufanele sitjheje indlela alahla ngayo [[iinzibi]] zakhe. Iinzibi kufanele zilahlwe endaweni eyodwa. Ikinga esinayo enarheni yekhethu kukobana kulahlwa amakhemikhali alimaza iimbandana nokhunye.   

=== Ukuphathwa kwamakhemikhali ===
Kufanele silahle amakhemikhali endaweni ezifaneleko. [[Amakhemikhali]] ayalimaza begodu angaba nomthelela omumbi khulu enarheni yekhethu. 
[[Isimumathi:A young wild boar in his environment.jpg|thumb|Isibandana sisendaweni esilaphazekileko]]

== Umphumela ngomtlolo lo ==
Ukuphungula [[ubungozi]] kezamaphilo wabantu

== Ukubaluleka kokuhlwengisa ibhoduluko yekhethu ==
[[Ibhoduluko]] yekhethu iqakathekile ngombana kufanele sitjheje ibhoduluko yekhethu, ukuze ihlale ihlwengekile. Ngalokhu iimpilo zethu zingatjhaphululeka ukutholeni ubulwelwe ubuhlukahlukeneko. [[Wp/nd/Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale|Ubulwelwe]] ubufana ne[[-Tuberculosis (TB)|-Tuberculosis (TB)]] kanye nobunye ubulwelwe. YE-KE, sitjhaba [[sekhethu]] asibulungeni ibhoduluko lekhethu, lokhu kufaka hlangana nokuvikela amahlathi, iinmbandana kanye neentjali zethu. 

== Iinkomba ==
{{Reflist}}</text>
      <sha1>d2ts8kflve3yhpjphndr9yvzh1dh0k6</sha1>
    </revision>
  </page>
  <page>
    <title>Ukugandeleleka ngokomkhumbulo</title>
    <ns>0</ns>
    <id>255</id>
    <revision>
      <id>1364</id>
      <timestamp>2024-03-29T18:05:36Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Ukugandeleleka ngokomkhumbulo''' budisi obehlela umkhumbulo ngesibanga seentjhijilo zepilo ahlagabezana nazo. Ukugandeleleka lokhu kungabonakala ngokuthi umunntu ahlale adanile, alahle ithemba begodu angabi nekareko yokweza izinto ezimthabisako. Ukugandeleleka ngokokhumbulo kwenza bona imicabango, imikghwa, nepilo emzimbeni, khulu athikamezeke nendleleni aphila ngayo ngamalanga.  &quot;</comment>
      <origin>1364</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="386" sha1="ktncvz318v9ade7cylbt4xry1ig1tge" xml:space="preserve">'''Ukugandeleleka ngokomkhumbulo''' budisi obehlela umkhumbulo ngesibanga seentjhijilo zepilo ahlagabezana nazo. Ukugandeleleka lokhu kungabonakala ngokuthi umunntu ahlale adanile, alahle ithemba begodu angabi nekareko yokweza izinto ezimthabisako. Ukugandeleleka ngokokhumbulo kwenza bona imicabango, imikghwa, nepilo emzimbeni, khulu athikamezeke nendleleni aphila ngayo ngamalanga.

</text>
      <sha1>ktncvz318v9ade7cylbt4xry1ig1tge</sha1>
    </revision>
    <revision>
      <id>1365</id>
      <parentid>1364</parentid>
      <timestamp>2024-03-29T18:17:08Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1365</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="766" sha1="fprekt76j68cr33b54o21ip0ggmyprq" xml:space="preserve">'''Ukugandeleleka ngokomkhumbulo''' budisi obehlela umkhumbulo ngesibanga seentjhijilo zepilo ahlagabezana nazo. Ukugandeleleka lokhu kungabonakala ngokuthi umunntu ahlale adanile, alahle ithemba begodu angabi nekareko yokweza izinto ezimthabisako. Ukugandeleleka ngokokhumbulo kwenza bona imicabango, imikghwa, nepilo emzimbeni, khulu athikamezeke nendleleni aphila ngayo ngamalanga.

== Kubangelwa yini ukugandeleleka ngokomkhumbulo? ==
Ukugadeleleka ngokomkhumbulo  kungabangelwa kukwehlelwa zizinto ezimbi ezenza bona umuntu akhubazekeke moyeni, ezifana nokulahlekelwa msebenzi, namatjhuguluko amakhulu wepilo umuntu ahlangabezana nawo umuntu angakahoni ukuwabekezelela. Ukusebenzisa iindakwa mizwa ngokweqileko nakho kuyabangela ukungandeleleka ngokomkhumbulo.
</text>
      <sha1>fprekt76j68cr33b54o21ip0ggmyprq</sha1>
    </revision>
    <revision>
      <id>1366</id>
      <parentid>1365</parentid>
      <timestamp>2024-06-30T17:29:09Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1366</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="806" sha1="oe2nurgvt08f83b611ufbf3odz1y4y3" xml:space="preserve">[[Isimumathi:Depression man.png|thumb]]
'''Ukugandeleleka ngokomkhumbulo''' budisi obehlela umkhumbulo ngesibanga seentjhijilo zepilo ahlagabezana nazo. Ukugandeleleka lokhu kungabonakala ngokuthi umunntu ahlale adanile, alahle ithemba begodu angabi nekareko yokweza izinto ezimthabisako. Ukugandeleleka ngokokhumbulo kwenza bona imicabango, imikghwa, nepilo emzimbeni, khulu athikamezeke nendleleni aphila ngayo ngamalanga.

== Kubangelwa yini ukugandeleleka ngokomkhumbulo? ==
Ukugadeleleka ngokomkhumbulo  kungabangelwa kukwehlelwa zizinto ezimbi ezenza bona umuntu akhubazekeke moyeni, ezifana nokulahlekelwa msebenzi, namatjhuguluko amakhulu wepilo umuntu ahlangabezana nawo umuntu angakahoni ukuwabekezelela. Ukusebenzisa iindakwa mizwa ngokweqileko nakho kuyabangela ukungandeleleka ngokomkhumbulo.
</text>
      <sha1>oe2nurgvt08f83b611ufbf3odz1y4y3</sha1>
    </revision>
    <revision>
      <id>1367</id>
      <parentid>1366</parentid>
      <timestamp>2024-10-14T13:47:38Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>1366</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="806" sha1="oe2nurgvt08f83b611ufbf3odz1y4y3" xml:space="preserve">[[Isimumathi:Depression man.png|thumb]]
'''Ukugandeleleka ngokomkhumbulo''' budisi obehlela umkhumbulo ngesibanga seentjhijilo zepilo ahlagabezana nazo. Ukugandeleleka lokhu kungabonakala ngokuthi umunntu ahlale adanile, alahle ithemba begodu angabi nekareko yokweza izinto ezimthabisako. Ukugandeleleka ngokokhumbulo kwenza bona imicabango, imikghwa, nepilo emzimbeni, khulu athikamezeke nendleleni aphila ngayo ngamalanga.

== Kubangelwa yini ukugandeleleka ngokomkhumbulo? ==
Ukugadeleleka ngokomkhumbulo  kungabangelwa kukwehlelwa zizinto ezimbi ezenza bona umuntu akhubazekeke moyeni, ezifana nokulahlekelwa msebenzi, namatjhuguluko amakhulu wepilo umuntu ahlangabezana nawo umuntu angakahoni ukuwabekezelela. Ukusebenzisa iindakwa mizwa ngokweqileko nakho kuyabangela ukungandeleleka ngokomkhumbulo.
</text>
      <sha1>oe2nurgvt08f83b611ufbf3odz1y4y3</sha1>
    </revision>
    <revision>
      <id>3236</id>
      <parentid>1367</parentid>
      <timestamp>2025-06-26T13:36:50Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>3236</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="807" sha1="s64ufvo29om5qd8b9u6o62n5tus075l" xml:space="preserve">[[Isimumathi:Depression man.png|thumb]]
'''Ukugandeleleka ngokomkhumbulo''' budisi obehlela umkhumbulo ngesibanga seentjhijilo zepilo ahlagabezana nazo. Ukugandeleleka lokhu kungabonakala ngokuthi umunntu ahlale adanile, alahle ithemba begodu angabi nekareko yokweza izinto ezimthabisako. Ukugandeleleka ngokokhumbulo kwenza bona imicabango, imikghwa, nepilo emzimbeni, khulu athikamezeke nendleleni aphila ngayo ngamalanga.

== Kubangelwa yini ukugandeleleka ngokomkhumbulo? ==
[[Ukugandeleleka komkhumbulo]]  kungabangelwa kukwehlelwa zizinto ezimbi ezenza bona umuntu akhubazekeke moyeni, ezifana nokulahlekelwa msebenzi, namatjhuguluko amakhulu wepilo umuntu ahlangabezana nawo umuntu angakahoni ukuwabekezelela. Ukusebenzisa iindakwa mizwa ngokweqileko nakho kuyabangela ukungandeleleka ngokomkhumbulo.</text>
      <sha1>s64ufvo29om5qd8b9u6o62n5tus075l</sha1>
    </revision>
  </page>
  <page>
    <title>Ukuqakatheka kwefundo</title>
    <ns>0</ns>
    <id>256</id>
    <revision>
      <id>1368</id>
      <timestamp>2024-03-09T10:00:04Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Ifundo iqakathekile''' esikhathini esphila kiso ngombana lokha nawungakafundi ngeze wakwazi ukuzijamela nozemzela izinto ephasini. ifundo ilekelela umuntu bona akwazi ukufunda nokutlola bogodu lokhu kulikghono elihle elisaza umuntu kwezokuthintana.  &quot;</comment>
      <origin>1368</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="253" sha1="n1ejxrfyyz0ngelxha93mbjlu3ajhif" xml:space="preserve">'''Ifundo iqakathekile''' esikhathini esphila kiso ngombana lokha nawungakafundi ngeze wakwazi ukuzijamela nozemzela izinto ephasini. ifundo ilekelela umuntu bona akwazi ukufunda nokutlola bogodu lokhu kulikghono elihle elisaza umuntu kwezokuthintana.

</text>
      <sha1>n1ejxrfyyz0ngelxha93mbjlu3ajhif</sha1>
    </revision>
    <revision>
      <id>1369</id>
      <parentid>1368</parentid>
      <timestamp>2024-03-09T10:05:49Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Adding interwiki links to [[d:Q8434]]</comment>
      <origin>1369</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="273" sha1="dyxui2ehz98cn67an79lpmc3gcw0xs0" xml:space="preserve">'''Ifundo iqakathekile''' esikhathini esphila kiso ngombana lokha nawungakafundi ngeze wakwazi ukuzijamela nozemzela izinto ephasini. ifundo ilekelela umuntu bona akwazi ukufunda nokutlola bogodu lokhu kulikghono elihle elisaza umuntu kwezokuthintana.


{{INTERWIKI|Q8434}}</text>
      <sha1>dyxui2ehz98cn67an79lpmc3gcw0xs0</sha1>
    </revision>
    <revision>
      <id>1370</id>
      <parentid>1369</parentid>
      <timestamp>2024-03-09T10:07:18Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1370</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="560" sha1="fvs0u78ia5p17ibb7yjs62r82hsbqqx" xml:space="preserve">'''Ifundo iqakathekile''' esikhathini esphila kiso ngombana lokha nawungakafundi ngeze wakwazi ukuzijamela nozemzela izinto ephasini. ifundo ilekelela umuntu bona akwazi ukufunda nokutlola bogodu lokhu kulikghono elihle elisaza umuntu kwezokuthintana.

== ifundo imsiza ngani umuntu ==
ifundo isiza umuntu bona akwazi ukuphumelelisa amabhudango wakhe, begodu inikeza umuntu ngelwazi lepilo. ifundisa umuntu ngezinto ezihle angazenza nangalezi ezimbi efanele azibalekele ezingamkhubaza. Isiza umuntu ukwazi amalungelo wakhe kanye nomthetho.

{{INTERWIKI|Q8434}}</text>
      <sha1>fvs0u78ia5p17ibb7yjs62r82hsbqqx</sha1>
    </revision>
    <revision>
      <id>1371</id>
      <parentid>1370</parentid>
      <timestamp>2024-03-09T10:07:47Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1371</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="564" sha1="hxs7gb69svbgegoqkyotszrd5dele5u" xml:space="preserve">'''[[Ifundo]] iqakathekile''' esikhathini esphila kiso ngombana lokha nawungakafundi ngeze wakwazi ukuzijamela nozemzela izinto ephasini. ifundo ilekelela umuntu bona akwazi ukufunda nokutlola bogodu lokhu kulikghono elihle elisaza umuntu kwezokuthintana.

== ifundo imsiza ngani umuntu ==
ifundo isiza umuntu bona akwazi ukuphumelelisa amabhudango wakhe, begodu inikeza umuntu ngelwazi lepilo. ifundisa umuntu ngezinto ezihle angazenza nangalezi ezimbi efanele azibalekele ezingamkhubaza. Isiza umuntu ukwazi amalungelo wakhe kanye nomthetho.

{{INTERWIKI|Q8434}}</text>
      <sha1>hxs7gb69svbgegoqkyotszrd5dele5u</sha1>
    </revision>
    <revision>
      <id>1372</id>
      <parentid>1371</parentid>
      <timestamp>2024-03-09T10:08:26Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1372</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="568" sha1="g4rgch76yst5y2xw6fmxl1bh30ytrs7" xml:space="preserve">'''[[Ifundo]] iqakathekile''' esikhathini esphila kiso ngombana lokha nawungakafundi ngeze wakwazi ukuzijamela nozemzela izinto ephasini. ifundo ilekelela umuntu bona akwazi ukufunda nokutlola bogodu lokhu kulikghono elihle elisaza umuntu kwezokuthintana.

== ifundo imsiza ngani umuntu ==
ifundo isiza umuntu bona akwazi ukuphumelelisa amabhudango wakhe, begodu inikeza umuntu ngelwazi [[lepilo.]] ifundisa umuntu ngezinto ezihle angazenza nangalezi ezimbi efanele azibalekele ezingamkhubaza. Isiza umuntu ukwazi amalungelo wakhe kanye nomthetho.

{{INTERWIKI|Q8434}}</text>
      <sha1>g4rgch76yst5y2xw6fmxl1bh30ytrs7</sha1>
    </revision>
    <revision>
      <id>1373</id>
      <parentid>1372</parentid>
      <timestamp>2024-03-09T10:12:07Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1373</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="653" sha1="cgoszwd99g5zpil5n51sbksbxn41hhk" xml:space="preserve">'''[[Ifundo]] iqakathekile''' esikhathini esphila kiso ngombana lokha nawungakafundi ngeze wakwazi ukuzijamela nozemzela izinto ephasini. ifundo ilekelela umuntu bona akwazi ukufunda nokutlola bogodu lokhu kulikghono elihle elisaza umuntu kwezokuthintana.

== ifundo imsiza ngani umuntu ==
[[Isimumathi:Deus High School Diplome.png|thumb|ifundo sikhiya sokuya epumelelweni]]
ifundo isiza umuntu bona akwazi ukuphumelelisa amabhudango wakhe, begodu inikeza umuntu ngelwazi [[lepilo.]] ifundisa umuntu ngezinto ezihle angazenza nangalezi ezimbi efanele azibalekele ezingamkhubaza. Isiza umuntu ukwazi amalungelo wakhe kanye nomthetho.

{{INTERWIKI|Q8434}}</text>
      <sha1>cgoszwd99g5zpil5n51sbksbxn41hhk</sha1>
    </revision>
    <revision>
      <id>1374</id>
      <parentid>1373</parentid>
      <timestamp>2024-03-09T10:13:39Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1374</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="681" sha1="g1tpnbcmjq5phnvywj8k0s4yrsd67mh" xml:space="preserve">== Ukuqakatheka kwefundo ==
'''[[Ifundo]] iqakathekile''' esikhathini esphila kiso ngombana lokha nawungakafundi ngeze wakwazi ukuzijamela nozemzela izinto ephasini. ifundo ilekelela umuntu bona akwazi ukufunda nokutlola bogodu lokhu kulikghono elihle elisaza umuntu kwezokuthintana.

== ifundo imsiza ngani umuntu ==
[[Isimumathi:Deus High School Diplome.png|thumb|ifundo sikhiya sokuya epumelelweni]]
ifundo isiza umuntu bona akwazi ukuphumelelisa amabhudango wakhe, begodu inikeza umuntu ngelwazi [[lepilo.]] ifundisa umuntu ngezinto ezihle angazenza nangalezi ezimbi efanele azibalekele ezingamkhubaza. Isiza umuntu ukwazi amalungelo wakhe kanye nomthetho.

{{INTERWIKI|Q8434}}</text>
      <sha1>g1tpnbcmjq5phnvywj8k0s4yrsd67mh</sha1>
    </revision>
    <revision>
      <id>1375</id>
      <parentid>1374</parentid>
      <timestamp>2024-03-09T10:17:04Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1375</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="771" sha1="sgxbtmwobwnk1cc015zhp5y3hugctmz" xml:space="preserve">[[Isimumathi:School learners in Mabushe C school, Namibia.jpg|thumb|Abantwana besikolo]]

== Ukuqakatheka kwefundo ==
'''[[Ifundo]] iqakathekile''' esikhathini esphila kiso ngombana lokha nawungakafundi ngeze wakwazi ukuzijamela nozemzela izinto ephasini. ifundo ilekelela umuntu bona akwazi ukufunda nokutlola bogodu lokhu kulikghono elihle elisaza umuntu kwezokuthintana.

== ifundo imsiza ngani umuntu ==
[[Isimumathi:Deus High School Diplome.png|thumb|ifundo sikhiya sokuya epumelelweni]]
ifundo isiza umuntu bona akwazi ukuphumelelisa amabhudango wakhe, begodu inikeza umuntu ngelwazi [[lepilo.]] ifundisa umuntu ngezinto ezihle angazenza nangalezi ezimbi efanele azibalekele ezingamkhubaza. Isiza umuntu ukwazi amalungelo wakhe kanye nomthetho.

{{INTERWIKI|Q8434}}</text>
      <sha1>sgxbtmwobwnk1cc015zhp5y3hugctmz</sha1>
    </revision>
    <revision>
      <id>1376</id>
      <parentid>1375</parentid>
      <timestamp>2024-03-09T10:19:55Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1376</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="775" sha1="o2kqpard9vba7vv5f70t4vmvgq0175e" xml:space="preserve">[[Isimumathi:School learners in Mabushe C school, Namibia.jpg|thumb|Abantwana besikolo]]

== Ukuqakatheka kwefundo ==
'''[[Ifundo]] iqakathekile''' esikhathini esiphila kiso ngombana lokha nawungakafundi ngeze wakwazi ukuzijamela nokuzenzela izinto ephasini. Ifundo ilekelela umuntu bona akwazi ukufunda nokutlola bogodu lokhu kulikghono elihle elisiza umuntu kwezokuthintana.

== Ifundo imsiza ngani umuntu ==
[[Isimumathi:Deus High School Diplome.png|thumb|ifundo sikhiya sokuya epumelelweni]]
ifundo isiza umuntu bona akwazi ukuphumelelisa amabhudango wakhe, begodu inikeza umuntu ngelwazi [[lepilo.]] ifundisa umuntu ngezinto ezihle angazenza nangalezi ezimbi efanele azibalekele ezingamkhubaza. Isiza umuntu ukwazi amalungelo wakhe kanye nomthetho. 

{{INTERWIKI|Q8434}}</text>
      <sha1>o2kqpard9vba7vv5f70t4vmvgq0175e</sha1>
    </revision>
    <revision>
      <id>1377</id>
      <parentid>1376</parentid>
      <timestamp>2024-03-09T10:20:53Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1377</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="779" sha1="shtn3cst2qvb698qfbgezuzvvg93tmy" xml:space="preserve">[[Isimumathi:School learners in Mabushe C school, Namibia.jpg|thumb|Abantwana besikolo]]

== Ukuqakatheka kwefundo ==
'''[[Ifundo]] iqakathekile''' esikhathini esiphila kiso ngombana lokha nawungakafundi ngeze wakwazi ukuzijamela nokuzenzela izinto ephasini. Ifundo ilekelela umuntu bona akwazi ukufunda nokutlola bogodu lokhu kulikghono elihle elisiza umuntu [[kwezokuthintana.]]

== Ifundo imsiza ngani umuntu ==
[[Isimumathi:Deus High School Diplome.png|thumb|ifundo sikhiya sokuya epumelelweni]]
ifundo isiza umuntu bona akwazi ukuphumelelisa amabhudango wakhe, begodu inikeza umuntu ngelwazi [[lepilo.]] ifundisa umuntu ngezinto ezihle angazenza nangalezi ezimbi efanele azibalekele ezingamkhubaza. Isiza umuntu ukwazi amalungelo wakhe kanye nomthetho. 

{{INTERWIKI|Q8434}}</text>
      <sha1>shtn3cst2qvb698qfbgezuzvvg93tmy</sha1>
    </revision>
    <revision>
      <id>1378</id>
      <parentid>1377</parentid>
      <timestamp>2024-03-09T10:48:23Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1378</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="781" sha1="myg5qmpob4q6gokybu765l6b3xrqzmn" xml:space="preserve">[[Isimumathi:School learners in Mabushe C school, Namibia.jpg|thumb|Abantwana besikolo]]

== Ukuqakatheka kwefundo ==
'''[[Ifundo]] iqakathekile''' esikhathini esiphila kiso ngombana lokha nawungakafundi ngeze wakwazi ukuzijamela nokuzenzela izinto ephasini. Ifundo ilekelela umuntu bona akwazi ukufunda nokutlola bogodu lokhu kulikghono elihle elisiza umuntu [[kwezokuthintana.]]

== Ifundo imsiza ngani umuntu ==
[[Isimumathi:Deus High School Diplome.png|thumb|ifundo sikhiya sokuya epumelelweni]]
ifundo isiza umuntu bona akwazi ukuphumelelisa amabhudango wakhe, begodu inikeza umuntu ngelwazi [[lepilo.]] ifundisa umuntu ngezinto ezihle angazenza nangalezi ezimbi efanele azibalekele ezingamkhubaza. Isiza umuntu bona azi amalungelo wakhe kanye nomthetho. 

{{INTERWIKI|Q8434}}</text>
      <sha1>myg5qmpob4q6gokybu765l6b3xrqzmn</sha1>
    </revision>
    <revision>
      <id>1379</id>
      <parentid>1378</parentid>
      <timestamp>2024-10-14T13:47:39Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>11 revisions imported</comment>
      <origin>1378</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="781" sha1="myg5qmpob4q6gokybu765l6b3xrqzmn" xml:space="preserve">[[Isimumathi:School learners in Mabushe C school, Namibia.jpg|thumb|Abantwana besikolo]]

== Ukuqakatheka kwefundo ==
'''[[Ifundo]] iqakathekile''' esikhathini esiphila kiso ngombana lokha nawungakafundi ngeze wakwazi ukuzijamela nokuzenzela izinto ephasini. Ifundo ilekelela umuntu bona akwazi ukufunda nokutlola bogodu lokhu kulikghono elihle elisiza umuntu [[kwezokuthintana.]]

== Ifundo imsiza ngani umuntu ==
[[Isimumathi:Deus High School Diplome.png|thumb|ifundo sikhiya sokuya epumelelweni]]
ifundo isiza umuntu bona akwazi ukuphumelelisa amabhudango wakhe, begodu inikeza umuntu ngelwazi [[lepilo.]] ifundisa umuntu ngezinto ezihle angazenza nangalezi ezimbi efanele azibalekele ezingamkhubaza. Isiza umuntu bona azi amalungelo wakhe kanye nomthetho. 

{{INTERWIKI|Q8434}}</text>
      <sha1>myg5qmpob4q6gokybu765l6b3xrqzmn</sha1>
    </revision>
    <revision>
      <id>1678</id>
      <parentid>1379</parentid>
      <timestamp>2024-10-16T09:50:12Z</timestamp>
      <contributor>
        <username>JhsBot</username>
        <id>34</id>
      </contributor>
      <minor />
      <comment>bot: Removing interwiki template; the page is now connected to [[d:Q8434]]</comment>
      <origin>1678</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="759" sha1="c2jk8cokr58nok1lvcqnerfw1lwbf9a" xml:space="preserve">[[Isimumathi:School learners in Mabushe C school, Namibia.jpg|thumb|Abantwana besikolo]]

== Ukuqakatheka kwefundo ==
'''[[Ifundo]] iqakathekile''' esikhathini esiphila kiso ngombana lokha nawungakafundi ngeze wakwazi ukuzijamela nokuzenzela izinto ephasini. Ifundo ilekelela umuntu bona akwazi ukufunda nokutlola bogodu lokhu kulikghono elihle elisiza umuntu [[kwezokuthintana.]]

== Ifundo imsiza ngani umuntu ==
[[Isimumathi:Deus High School Diplome.png|thumb|ifundo sikhiya sokuya epumelelweni]]
ifundo isiza umuntu bona akwazi ukuphumelelisa amabhudango wakhe, begodu inikeza umuntu ngelwazi [[lepilo.]] ifundisa umuntu ngezinto ezihle angazenza nangalezi ezimbi efanele azibalekele ezingamkhubaza. Isiza umuntu bona azi amalungelo wakhe kanye nomthetho.</text>
      <sha1>c2jk8cokr58nok1lvcqnerfw1lwbf9a</sha1>
    </revision>
  </page>
  <page>
    <title>Ukutheza</title>
    <ns>0</ns>
    <id>257</id>
    <revision>
      <id>1380</id>
      <timestamp>2024-09-15T10:01:25Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;== Ukutheza ==  === Isingeniso === Ukutheza ngezinye zezenzo lezo ebezikhona ngesikhathi sabokhokho bethu. Ukutheza kudlale begodu kusadlala indima eqakathekileko mayelana nokuthi abantu babeneenkuni, ukudla kanye nemalingeniso eemphakathini eminengi, khulukhulu eemndenini esazidobhela phasi. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyini ukutheza begodu bunomthintela enjani eemphakathini esiphila kiyo, khulukhulu yemakhaya.   === Kuyini [[:en:Logging|ukutheza]]?...&quot;</comment>
      <origin>1380</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4629" sha1="dnl5zjau2cjplzglo7h9r3d4z126x21" xml:space="preserve">== Ukutheza ==

=== Isingeniso ===
Ukutheza ngezinye zezenzo lezo ebezikhona ngesikhathi sabokhokho bethu. Ukutheza kudlale begodu kusadlala indima eqakathekileko mayelana nokuthi abantu babeneenkuni, ukudla kanye nemalingeniso eemphakathini eminengi, khulukhulu eemndenini esazidobhela phasi. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyini ukutheza begodu bunomthintela enjani eemphakathini esiphila kiyo, khulukhulu yemakhaya. 

=== Kuyini [[:en:Logging|ukutheza]]? ===
Ngokuya kwe-Wikipedia (2024&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. ''Logging''. Itholakala ku: &lt;nowiki&gt;https://en.wikipedia.org/wiki/Logging&lt;/nowiki&gt;. Ufunyenwe ngomhlaka [29 kuRhoboyi 2024].&lt;/ref&gt;) ukutheza sisenzo sokugawula nokususa imithi. Ukungezelela, imithi le egawulilweko yasuswa lapho beyikhona uthuthelwa endaweni etja (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;; Lima, u-Castro, u-Baptista no-Silva 2020&lt;ref&gt;Lima, K. S., Castro, C. M., Baptista, J. S. &amp; Silva, U. 2020. Wood-logging process management in Eastern Amazonia (Brazil). ''Sustainability'', 12:1-18.&lt;/ref&gt;). Ngamanye amagama, ukutheza kufaka ukugawula iinkuni nanyana ukususa iinkuni, khulukhulu ehlathini uzithuthele kwenye indawo lapho zokusetjenziswa khona.

Khululunywa ngokusussa nokugawula, ngombana ezinye iinkuni nanyana iingodo uzifumana zizilalele nanyana ziwele phasi, bese ufike ngokubuthelela nawuqedako uzithathe. Kanti-ke, kukhona lezo ekufuneka bonyana zigawulwe emithi begodu eminye imithi leyo ikhitjhwa nemirabhu nanyana neendidi zawo (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot;&gt;Numuene, K. S. &amp; Egbe, A. E. 2022. Impact of Timber Logging on Neighbouring Stands in a Forest of the South Western Cameroon. ''Open Journal of Forestry'', 12:248-262.&lt;/ref&gt;).

=== Umthintela wokutheza ===
Kukhona imithindela eminengi emihle nemimbi yokutheza; kodwana kusihloko sethu lezi sizokutjheja imithintela elandelako:

==== Ubumbi ====

==== 1.      Ukutjhabalalisa imithi yamahlathi. ====
Lokha nasithezako sisusa eminye yemithi leyo ekungeyendabuko (Numuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Imithi leyo iyancipha begodu igcine ingasabi khona. Lokho kwenza bonyana amahlathi angasabi nemithi begodu avuleke.

==== 2.      Ubujamo bezulu ====
Lokha nasithezako sisusa imithi, sitjhiya amahlathi avulekile nemithi inganawo amagatja wokumunye i-carbon dioxide emoyeni (u-Ranius, u-Hamalainen, u-Egnell, u-Olsson, u-Eklof, u-Stendah, u-Rudolphi, u-Stens no-Felton 2018&lt;ref name=&quot;:2&quot;&gt;Ranius, T., Hämäläinen, A., Egnell, G., Olsson, B., Eklöf, K. et al. 2018.The effects of logging residue extraction for energy on ecosystem services and biodiversity: a synthesis. ''Journal of Environmental Management'', 209: 409-425.&lt;/ref&gt;). Lokha kubanga bonyana ubujamo bezulu butjhuluke kwamambala njengokuthi kube nomtjhiso omkhulu tle nanyana kubemakhaza khulu (u-Ranius ''nabanye'' 2018&lt;ref name=&quot;:2&quot; /&gt;).

==== 3.      Ukutlhogeka kweensetjenziswa ====
Ukutheza kwenza bonyana iinsetjenziswa lezo ezifunekako , ezinjengokudla kwedlathini nemitjhoga itlhogeke (World Wide Fund for Nature 2019&lt;ref&gt;World Wide Fund for Nature. 2019. ''Timber monitoring and control from the first entry on the marke''t. WWF Romania.&lt;/ref&gt;). Ngamanye amagama, abantu abathembele eenkunini ukupheka nokudla kanye neelwana ezithembele emini mayelana namakhaya wazo nokudla zizithola zingana buyo.

==== Ubuhle ====

==== 1.      Umnotho wezahlalakuhle ====
Kukhona abantu labo abathembele eenkunini nemithi bonyana bangenise imali begodu baphile (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Abantu laba bathengisa iinkuni lezi begodu abanye babasa imililo ngeenkuni, bafulela ngeengodo begodu bakampela amajarida wabo ngokusebenzisa iingodo.

==== 2.      Imitjhoga ====
Kukhona eminye yemitjhoga leyo eyenziwa ngemithi yendabuko le ebayithezako (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Ngamanye amagama, abantu basenzisa imithi ukulapha kanye nokuhlengisa ubujamo bepilo bemizimba yabo. 

==== 3.      Ibonelela lomoya ohlwengileko ====
Imithi esikhathi esinengi ithatha nanyana imunya umoya onerhasi emimbi, i-carbon dioxide, bese wona unikele ngomoya olungele ukuphefumula babantu nelwani, i-oxygen (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Ukungezelela, imithi ihlwengisa umoya esiwuphefumulako nebhoduluko.

==== Isiphetho ====
Ukutheza kuqakatheke khulu eemphakathini yethu. Nanyana kunjalo, nakungenziwa ngendlela yokukhathelela imithi namahlathi kuba nomthintela omumbi eemphakathini yoke. Siyazi bonyana abantu abanengi bathembele eemthini namahlathini mayelana nemalingeniso nemitjhoja, ngebanga lelo kufanele sikwenze kokutlhogomela begodu singakwenzeli butjhilweni. 

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>dnl5zjau2cjplzglo7h9r3d4z126x21</sha1>
    </revision>
    <revision>
      <id>1381</id>
      <parentid>1380</parentid>
      <timestamp>2024-09-18T16:02:04Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1381</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4630" sha1="6qe644r3lr68ipao8nkdxif0w5sltc4" xml:space="preserve">== Ukutheza ==

=== Isingeniso. ===
Ukutheza ngezinye zezenzo lezo ebezikhona ngesikhathi sabokhokho bethu. Ukutheza kudlale begodu kusadlala indima eqakathekileko mayelana nokuthi abantu babeneenkuni, ukudla kanye nemalingeniso eemphakathini eminengi, khulukhulu eemndenini esazidobhela phasi. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyini ukutheza begodu bunomthintela enjani eemphakathini esiphila kiyo, khulukhulu yemakhaya. 

=== Kuyini [[:en:Logging|ukutheza]]? ===
Ngokuya kwe-Wikipedia (2024&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. ''Logging''. Itholakala ku: &lt;nowiki&gt;https://en.wikipedia.org/wiki/Logging&lt;/nowiki&gt;. Ufunyenwe ngomhlaka [29 kuRhoboyi 2024].&lt;/ref&gt;) ukutheza sisenzo sokugawula nokususa imithi. Ukungezelela, imithi le egawulilweko yasuswa lapho beyikhona uthuthelwa endaweni etja (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;; Lima, u-Castro, u-Baptista no-Silva 2020&lt;ref&gt;Lima, K. S., Castro, C. M., Baptista, J. S. &amp; Silva, U. 2020. Wood-logging process management in Eastern Amazonia (Brazil). ''Sustainability'', 12:1-18.&lt;/ref&gt;). Ngamanye amagama, ukutheza kufaka ukugawula iinkuni nanyana ukususa iinkuni, khulukhulu ehlathini uzithuthele kwenye indawo lapho zokusetjenziswa khona.

Khululunywa ngokusussa nokugawula, ngombana ezinye iinkuni nanyana iingodo uzifumana zizilalele nanyana ziwele phasi, bese ufike ngokubuthelela nawuqedako uzithathe. Kanti-ke, kukhona lezo ekufuneka bonyana zigawulwe emithi begodu eminye imithi leyo ikhitjhwa nemirabhu nanyana neendidi zawo (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot;&gt;Numuene, K. S. &amp; Egbe, A. E. 2022. Impact of Timber Logging on Neighbouring Stands in a Forest of the South Western Cameroon. ''Open Journal of Forestry'', 12:248-262.&lt;/ref&gt;).

=== Umthintela wokutheza ===
Kukhona imithindela eminengi emihle nemimbi yokutheza; kodwana kusihloko sethu lezi sizokutjheja imithintela elandelako:

==== Ubumbi ====

==== 1.      Ukutjhabalalisa imithi yamahlathi. ====
Lokha nasithezako sisusa eminye yemithi leyo ekungeyendabuko (Numuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Imithi leyo iyancipha begodu igcine ingasabi khona. Lokho kwenza bonyana amahlathi angasabi nemithi begodu avuleke.

==== 2.      Ubujamo bezulu ====
Lokha nasithezako sisusa imithi, sitjhiya amahlathi avulekile nemithi inganawo amagatja wokumunye i-carbon dioxide emoyeni (u-Ranius, u-Hamalainen, u-Egnell, u-Olsson, u-Eklof, u-Stendah, u-Rudolphi, u-Stens no-Felton 2018&lt;ref name=&quot;:2&quot;&gt;Ranius, T., Hämäläinen, A., Egnell, G., Olsson, B., Eklöf, K. et al. 2018.The effects of logging residue extraction for energy on ecosystem services and biodiversity: a synthesis. ''Journal of Environmental Management'', 209: 409-425.&lt;/ref&gt;). Lokha kubanga bonyana ubujamo bezulu butjhuluke kwamambala njengokuthi kube nomtjhiso omkhulu tle nanyana kubemakhaza khulu (u-Ranius ''nabanye'' 2018&lt;ref name=&quot;:2&quot; /&gt;).

==== 3.      Ukutlhogeka kweensetjenziswa ====
Ukutheza kwenza bonyana iinsetjenziswa lezo ezifunekako , ezinjengokudla kwedlathini nemitjhoga itlhogeke (World Wide Fund for Nature 2019&lt;ref&gt;World Wide Fund for Nature. 2019. ''Timber monitoring and control from the first entry on the marke''t. WWF Romania.&lt;/ref&gt;). Ngamanye amagama, abantu abathembele eenkunini ukupheka nokudla kanye neelwana ezithembele emini mayelana namakhaya wazo nokudla zizithola zingana buyo.

==== Ubuhle ====

==== 1.      Umnotho wezahlalakuhle ====
Kukhona abantu labo abathembele eenkunini nemithi bonyana bangenise imali begodu baphile (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Abantu laba bathengisa iinkuni lezi begodu abanye babasa imililo ngeenkuni, bafulela ngeengodo begodu bakampela amajarida wabo ngokusebenzisa iingodo.

==== 2.      Imitjhoga ====
Kukhona eminye yemitjhoga leyo eyenziwa ngemithi yendabuko le ebayithezako (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Ngamanye amagama, abantu basenzisa imithi ukulapha kanye nokuhlengisa ubujamo bepilo bemizimba yabo. 

==== 3.      Ibonelela lomoya ohlwengileko ====
Imithi esikhathi esinengi ithatha nanyana imunya umoya onerhasi emimbi, i-carbon dioxide, bese wona unikele ngomoya olungele ukuphefumula babantu nelwani, i-oxygen (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Ukungezelela, imithi ihlwengisa umoya esiwuphefumulako nebhoduluko.

==== Isiphetho ====
Ukutheza kuqakatheke khulu eemphakathini yethu. Nanyana kunjalo, nakungenziwa ngendlela yokukhathelela imithi namahlathi kuba nomthintela omumbi eemphakathini yoke. Siyazi bonyana abantu abanengi bathembele eemthini namahlathini mayelana nemalingeniso nemitjhoja, ngebanga lelo kufanele sikwenze kokutlhogomela begodu singakwenzeli butjhilweni. 

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>6qe644r3lr68ipao8nkdxif0w5sltc4</sha1>
    </revision>
    <revision>
      <id>1382</id>
      <parentid>1381</parentid>
      <timestamp>2024-10-14T13:47:39Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>1381</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4630" sha1="6qe644r3lr68ipao8nkdxif0w5sltc4" xml:space="preserve">== Ukutheza ==

=== Isingeniso. ===
Ukutheza ngezinye zezenzo lezo ebezikhona ngesikhathi sabokhokho bethu. Ukutheza kudlale begodu kusadlala indima eqakathekileko mayelana nokuthi abantu babeneenkuni, ukudla kanye nemalingeniso eemphakathini eminengi, khulukhulu eemndenini esazidobhela phasi. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyini ukutheza begodu bunomthintela enjani eemphakathini esiphila kiyo, khulukhulu yemakhaya. 

=== Kuyini [[:en:Logging|ukutheza]]? ===
Ngokuya kwe-Wikipedia (2024&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. ''Logging''. Itholakala ku: &lt;nowiki&gt;https://en.wikipedia.org/wiki/Logging&lt;/nowiki&gt;. Ufunyenwe ngomhlaka [29 kuRhoboyi 2024].&lt;/ref&gt;) ukutheza sisenzo sokugawula nokususa imithi. Ukungezelela, imithi le egawulilweko yasuswa lapho beyikhona uthuthelwa endaweni etja (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;; Lima, u-Castro, u-Baptista no-Silva 2020&lt;ref&gt;Lima, K. S., Castro, C. M., Baptista, J. S. &amp; Silva, U. 2020. Wood-logging process management in Eastern Amazonia (Brazil). ''Sustainability'', 12:1-18.&lt;/ref&gt;). Ngamanye amagama, ukutheza kufaka ukugawula iinkuni nanyana ukususa iinkuni, khulukhulu ehlathini uzithuthele kwenye indawo lapho zokusetjenziswa khona.

Khululunywa ngokusussa nokugawula, ngombana ezinye iinkuni nanyana iingodo uzifumana zizilalele nanyana ziwele phasi, bese ufike ngokubuthelela nawuqedako uzithathe. Kanti-ke, kukhona lezo ekufuneka bonyana zigawulwe emithi begodu eminye imithi leyo ikhitjhwa nemirabhu nanyana neendidi zawo (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot;&gt;Numuene, K. S. &amp; Egbe, A. E. 2022. Impact of Timber Logging on Neighbouring Stands in a Forest of the South Western Cameroon. ''Open Journal of Forestry'', 12:248-262.&lt;/ref&gt;).

=== Umthintela wokutheza ===
Kukhona imithindela eminengi emihle nemimbi yokutheza; kodwana kusihloko sethu lezi sizokutjheja imithintela elandelako:

==== Ubumbi ====

==== 1.      Ukutjhabalalisa imithi yamahlathi. ====
Lokha nasithezako sisusa eminye yemithi leyo ekungeyendabuko (Numuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Imithi leyo iyancipha begodu igcine ingasabi khona. Lokho kwenza bonyana amahlathi angasabi nemithi begodu avuleke.

==== 2.      Ubujamo bezulu ====
Lokha nasithezako sisusa imithi, sitjhiya amahlathi avulekile nemithi inganawo amagatja wokumunye i-carbon dioxide emoyeni (u-Ranius, u-Hamalainen, u-Egnell, u-Olsson, u-Eklof, u-Stendah, u-Rudolphi, u-Stens no-Felton 2018&lt;ref name=&quot;:2&quot;&gt;Ranius, T., Hämäläinen, A., Egnell, G., Olsson, B., Eklöf, K. et al. 2018.The effects of logging residue extraction for energy on ecosystem services and biodiversity: a synthesis. ''Journal of Environmental Management'', 209: 409-425.&lt;/ref&gt;). Lokha kubanga bonyana ubujamo bezulu butjhuluke kwamambala njengokuthi kube nomtjhiso omkhulu tle nanyana kubemakhaza khulu (u-Ranius ''nabanye'' 2018&lt;ref name=&quot;:2&quot; /&gt;).

==== 3.      Ukutlhogeka kweensetjenziswa ====
Ukutheza kwenza bonyana iinsetjenziswa lezo ezifunekako , ezinjengokudla kwedlathini nemitjhoga itlhogeke (World Wide Fund for Nature 2019&lt;ref&gt;World Wide Fund for Nature. 2019. ''Timber monitoring and control from the first entry on the marke''t. WWF Romania.&lt;/ref&gt;). Ngamanye amagama, abantu abathembele eenkunini ukupheka nokudla kanye neelwana ezithembele emini mayelana namakhaya wazo nokudla zizithola zingana buyo.

==== Ubuhle ====

==== 1.      Umnotho wezahlalakuhle ====
Kukhona abantu labo abathembele eenkunini nemithi bonyana bangenise imali begodu baphile (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Abantu laba bathengisa iinkuni lezi begodu abanye babasa imililo ngeenkuni, bafulela ngeengodo begodu bakampela amajarida wabo ngokusebenzisa iingodo.

==== 2.      Imitjhoga ====
Kukhona eminye yemitjhoga leyo eyenziwa ngemithi yendabuko le ebayithezako (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Ngamanye amagama, abantu basenzisa imithi ukulapha kanye nokuhlengisa ubujamo bepilo bemizimba yabo. 

==== 3.      Ibonelela lomoya ohlwengileko ====
Imithi esikhathi esinengi ithatha nanyana imunya umoya onerhasi emimbi, i-carbon dioxide, bese wona unikele ngomoya olungele ukuphefumula babantu nelwani, i-oxygen (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Ukungezelela, imithi ihlwengisa umoya esiwuphefumulako nebhoduluko.

==== Isiphetho ====
Ukutheza kuqakatheke khulu eemphakathini yethu. Nanyana kunjalo, nakungenziwa ngendlela yokukhathelela imithi namahlathi kuba nomthintela omumbi eemphakathini yoke. Siyazi bonyana abantu abanengi bathembele eemthini namahlathini mayelana nemalingeniso nemitjhoja, ngebanga lelo kufanele sikwenze kokutlhogomela begodu singakwenzeli butjhilweni. 

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>6qe644r3lr68ipao8nkdxif0w5sltc4</sha1>
    </revision>
    <revision>
      <id>2844</id>
      <parentid>1382</parentid>
      <timestamp>2025-05-26T00:55:37Z</timestamp>
      <contributor>
        <ip>78.174.67.142</ip>
      </contributor>
      <origin>2844</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4722" sha1="jdvyqnww2jjlq4m9pouvig5veras6yb" xml:space="preserve">== Ukutheza ==

=== Isingeniso. ===
Ukutheza ngezinye zezenzo lezo ebezikhona ngesikhathi sabokhokho bethu. Ukutheza kudlale begodu kusadlala indima eqakathekileko mayelana nokuthi abantu babeneenkuni, ukudla kanye nemalingeniso eemphakathini eminengi, khulukhulu eemndenini esazidobhela phasi. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyini ukutheza begodu bunomthintela enjani eemphakathini esiphila kiyo, khulukhulu yemakhaya. 

=== Kuyini [[:en:Logging|ukutheza]]? ===
Ngokuya kwe-Wikipedia (2024&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. ''Logging''. Itholakala ku: &lt;nowiki&gt;https://en.wikipedia.org/wiki/Logging&lt;/nowiki&gt;. Ufunyenwe ngomhlaka [29 kuRhoboyi 2024].&lt;/ref&gt;) ukutheza sisenzo sokugawula nokususa imithi. Ukungezelela, imithi le egawulilweko yasuswa lapho beyikhona uthuthelwa endaweni etja (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;; Lima, u-Castro, u-Baptista no-Silva 2020&lt;ref&gt;Lima, K. S., Castro, C. M., Baptista, J. S. &amp; Silva, U. 2020. Wood-logging process management in Eastern Amazonia (Brazil). ''Sustainability'', 12:1-18.&lt;/ref&gt;). Ngamanye amagama, ukutheza kufaka ukugawula iinkuni nanyana ukususa iinkuni, khulukhulu ehlathini uzithuthele kwenye indawo lapho zokusetjenziswa khona.

Khululunywa ngokusussa nokugawula, ngombana ezinye iinkuni nanyana iingodo uzifumana zizilalele nanyana ziwele phasi, bese ufike ngokubuthelela nawuqedako uzithathe. Kanti-ke, kukhona lezo ekufuneka bonyana zigawulwe emithi begodu eminye imithi leyo ikhitjhwa nemirabhu nanyana neendidi zawo (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot;&gt;Numuene, K. S. &amp; Egbe, A. E. 2022. Impact of Timber Logging on Neighbouring Stands in a Forest of the South Western Cameroon. ''Open Journal of Forestry'', 12:248-262.&lt;/ref&gt;).

=== Umthintela wokutheza ===
Kukhona imithindela eminengi emihle nemimbi yokutheza; kodwana kusihloko sethu lezi sizokutjheja imithintela elandelako:

==== Ubumbi ====

==== 1.      Ukutjhabalalisa imithi yamahlathi. ====
Lokha nasithezako sisusa eminye yemithi leyo ekungeyendabuko (Numuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Imithi leyo iyancipha begodu igcine ingasabi khona. Lokho kwenza bonyana amahlathi angasabi nemithi begodu avuleke.

==== 2.      Ubujamo bezulu ====
Lokha nasithezako sisusa imithi, sitjhiya amahlathi avulekile nemithi inganawo amagatja wokumunye i-carbon dioxide emoyeni (u-Ranius, u-Hamalainen, u-Egnell, u-Olsson, u-Eklof, u-Stendah, u-Rudolphi, u-Stens no-Felton 2018&lt;ref name=&quot;:2&quot;&gt;Ranius, T., Hämäläinen, A., Egnell, G., Olsson, B., Eklöf, K. et al. 2018.The effects of logging residue extraction for energy on ecosystem services and biodiversity: a synthesis. ''Journal of Environmental Management'', 209: 409-425.&lt;/ref&gt;). Lokha kubanga bonyana ubujamo bezulu butjhuluke kwamambala njengokuthi kube nomtjhiso omkhulu tle nanyana kubemakhaza khulu (u-Ranius ''nabanye'' 2018&lt;ref name=&quot;:2&quot; /&gt;).

==== 3.      Ukutlhogeka kweensetjenziswa ====
Ukutheza kwenza bonyana iinsetjenziswa lezo ezifunekako , ezinjengokudla kwedlathini nemitjhoga itlhogeke (World Wide Fund for Nature 2019&lt;ref&gt;World Wide Fund for Nature. 2019. ''Timber monitoring and control from the first entry on the marke''t. WWF Romania.&lt;/ref&gt;). Ngamanye amagama, abantu abathembele eenkunini ukupheka nokudla kanye neelwana ezithembele emini mayelana namakhaya wazo nokudla zizithola zingana buyo.

==== Ubuhle ====

==== 1.      Umnotho wezahlalakuhle ====
Kukhona abantu labo abathembele eenkunini nemithi bonyana bangenise imali begodu baphile (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Abantu laba bathengisa iinkuni lezi begodu abanye babasa imililo ngeenkuni, bafulela ngeengodo begodu bakampela amajarida wabo ngokusebenzisa iingodo.

==== 2.      Imitjhoga ====
Kukhona eminye yemitjhoga leyo eyenziwa ngemithi yendabuko le ebayithezako (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Ngamanye amagama, abantu basenzisa imithi ukulapha kanye nokuhlengisa ubujamo bepilo bemizimba yabo. 

==== 3.      Ibonelela lomoya ohlwengileko ====
Imithi esikhathi esinengi ithatha nanyana imunya umoya onerhasi emimbi, i-carbon dioxide, bese wona unikele ngomoya olungele ukuphefumula babantu nelwani, i-oxygen (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Ukungezelela, imithi ihlwengisa umoya esiwuphefumulako nebhoduluko.

==== Isiphetho ====
Ukutheza kuqakatheke khulu eemphakathini yethu. Nanyana kunjalo, nakungenziwa ngendlela yokukhathelela imithi namahlathi kuba nomthintela omumbi eemphakathini yoke. [https://www.depremabi.com/ Son depremler] en iyi depremabi üzerinden görüntülenebilir. Siyazi bonyana abantu abanengi bathembele eemthini namahlathini mayelana nemalingeniso nemitjhoja, ngebanga lelo kufanele sikwenze kokutlhogomela begodu singakwenzeli butjhilweni. 

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>jdvyqnww2jjlq4m9pouvig5veras6yb</sha1>
    </revision>
    <revision>
      <id>5079</id>
      <parentid>2844</parentid>
      <timestamp>2025-08-08T08:36:41Z</timestamp>
      <contributor>
        <username>T Ntuli</username>
        <id>844</id>
      </contributor>
      <origin>5079</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4889" sha1="mq3vj7cyozocxz6xxu1n8hokburgpdk" xml:space="preserve">== Ukutheza ==

=== Isingeniso. ===
Ukutheza ngezinye zezenzo lezo ebezikhona ngesikhathi sabokhokho bethu. Ukutheza kudlale begodu kusadlala indima eqakathekileko mayelana nokuthi abantu babeneenkuni, ukudla kanye nemalingeniso eemphakathini eminengi, khulukhulu eemndenini esazidobhela phasi. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyini ukutheza begodu bunomthintela enjani eemphakathini esiphila kiyo, khulukhulu yemakhaya. 

=== Kuyini [[:en:Logging|ukutheza]]? ===
Ngokuya kwe-Wikipedia (2024&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. ''Logging''. Itholakala ku: &lt;nowiki&gt;https://en.wikipedia.org/wiki/Logging&lt;/nowiki&gt;. Ufunyenwe ngomhlaka [29 kuRhoboyi 2024].&lt;/ref&gt;) ukutheza sisenzo sokugawula nokususa imithi. Ukungezelela, imithi le egawulilweko yasuswa lapho beyikhona uthuthelwa endaweni etja (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;; Lima, u-Castro, u-Baptista no-Silva 2020&lt;ref&gt;Lima, K. S., Castro, C. M., Baptista, J. S. &amp; Silva, U. 2020. Wood-logging process management in Eastern Amazonia (Brazil). ''Sustainability'', 12:1-18.&lt;/ref&gt;). Ngamanye amagama, ukutheza kufaka ukugawula iinkuni nanyana ukususa iinkuni, khulukhulu ehlathini uzithuthele kwenye indawo lapho zokusetjenziswa khona.

Khululunywa ngokusussa nokugawula, ngombana ezinye iinkuni nanyana iingodo uzifumana zizilalele nanyana ziwele phasi, bese ufike ngokubuthelela nawuqedako uzithathe. Kanti-ke, kukhona lezo ekufuneka bonyana zigawulwe emithi begodu eminye imithi leyo ikhitjhwa nemirabhu nanyana neendidi zawo (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot;&gt;Numuene, K. S. &amp; Egbe, A. E. 2022. Impact of Timber Logging on Neighbouring Stands in a Forest of the South Western Cameroon. ''Open Journal of Forestry'', 12:248-262.&lt;/ref&gt;).

=== Umthintela wokutheza ===
Kukhona imithindela eminengi emihle nemimbi yokutheza; kodwana kusihloko sethu lezi sizokutjheja imithintela elandelako:

==== Ubumbi ====

==== 1.      Ukutjhabalalisa imithi yamahlathi. ====
Lokha nasithezako sisusa eminye yemithi leyo ekungeyendabuko (Numuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Imithi leyo iyancipha begodu igcine ingasabi khona. Lokho kwenza bonyana amahlathi angasabi nemithi begodu avuleke.

==== 2.      Ubujamo bezulu ====
Lokha nasithezako sisusa imithi, sitjhiya amahlathi avulekile nemithi inganawo amagatja wokumunye i-carbon dioxide emoyeni (u-Ranius, u-Hamalainen, u-Egnell, u-Olsson, u-Eklof, u-Stendah, u-Rudolphi, u-Stens no-Felton 2018&lt;ref name=&quot;:2&quot;&gt;Ranius, T., Hämäläinen, A., Egnell, G., Olsson, B., Eklöf, K. et al. 2018.The effects of logging residue extraction for energy on ecosystem services and biodiversity: a synthesis. ''Journal of Environmental Management'', 209: 409-425.&lt;/ref&gt;). Lokha kubanga bonyana ubujamo bezulu butjhuluke kwamambala njengokuthi kube nomtjhiso omkhulu tle nanyana kubemakhaza khulu (u-Ranius ''nabanye'' 2018&lt;ref name=&quot;:2&quot; /&gt;).

==== 3.      Ukutlhogeka kweensetjenziswa ====
Ukutheza kwenza bonyana iinsetjenziswa lezo ezifunekako , ezinjengokudla kwedlathini nemitjhoga itlhogeke (World Wide Fund for Nature 2019&lt;ref&gt;World Wide Fund for Nature. 2019. ''Timber monitoring and control from the first entry on the marke''t. WWF Romania.&lt;/ref&gt;). Ngamanye amagama, abantu abathembele eenkunini ukupheka nokudla kanye neelwana ezithembele emini mayelana namakhaya wazo nokudla zizithola zingana buyo.

==== Ubuhle ====

==== 1.      Umnotho wezahlalakuhle ====
Kukhona abantu labo abathembele eenkunini nemithi bonyana bangenise imali begodu baphile (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Abantu laba bathengisa iinkuni lezi begodu abanye babasa imililo ngeenkuni, bafulela ngeengodo begodu bakampela amajarida wabo ngokusebenzisa iingodo.

==== 2.      Imitjhoga ====
Kukhona eminye yemitjhoga leyo eyenziwa ngemithi yendabuko le ebayithezako (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Ngamanye amagama, abantu basenzisa imithi ukulapha kanye nokuhlengisa ubujamo bepilo bemizimba yabo. 

==== 3.      Ibonelela lomoya ohlwengileko ====
Imithi esikhathi esinengi ithatha nanyana imunya umoya onerhasi emimbi, i-carbon dioxide, bese wona unikele ngomoya olungele ukuphefumula babantu nelwani, i-oxygen (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Ukungezelela, imithi ihlwengisa umoya esiwuphefumulako nebhoduluko.

'''4 yonga igezi'''

esikhathini esiphilakiso  namhlanje iintengo yegezi ikhuphule khulu. yeke ukutheza kuyindlela ehle khulu yokonga igezi ebantwini abadobha phasi.

==== Isiphetho ====
Ukutheza kuqakatheke khulu eemphakathini yethu. Nanyana kunjalo, nakungenziwa ngendlela yokukhathelela imithi namahlathi kuba nomthintela omumbi eemphakathini yoke. [https://www.depremabi.com/ Son depremler] en iyi depremabi üzerinden görüntülenebilir. Siyazi bonyana abantu abanengi bathembele eemthini namahlathini mayelana nemalingeniso nemitjhoja, ngebanga lelo kufanele sikwenze kokutlhogomela begodu singakwenzeli butjhilweni. 

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>mq3vj7cyozocxz6xxu1n8hokburgpdk</sha1>
    </revision>
    <revision>
      <id>5084</id>
      <parentid>5079</parentid>
      <timestamp>2025-08-08T09:01:14Z</timestamp>
      <contributor>
        <username>N Mabhena</username>
        <id>843</id>
      </contributor>
      <origin>5084</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4900" sha1="tr9eixzig1o0v95lxdewfxvzthh45zx" xml:space="preserve">== Ukutheza ==

=== Isingeniso. ===
Ukutheza ngezinye zezenzo lezo ebezikhona ngesikhathi sabokhokho bethu. Ukutheza kudlale begodu kusadlala indima eqakathekileko mayelana nokuthi abantu babeneenkuni, ukudla kanye nemalingeniso eemphakathini eminengi, khulukhulu eemndenini esazidobhela phasi. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyini ukutheza begodu bunomthintela enjani eemphakathini esiphila kiyo, khulukhulu yemakhaya. 

=== Kuyini [[:en:Logging|ukutheza]]? ===
Ngokuya kwe-Wikipedia (2024&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. ''Logging''. Itholakala ku: &lt;nowiki&gt;https://en.wikipedia.org/wiki/Logging&lt;/nowiki&gt;. Ufunyenwe ngomhlaka [29 kuRhoboyi 2024].&lt;/ref&gt;) ukutheza sisenzo sokugawula nokususa imithi. Ukungezelela, imithi le egawulilweko yasuswa lapho beyikhona uthuthelwa endaweni etja (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;; Lima, u-Castro, u-Baptista no-Silva 2020&lt;ref&gt;Lima, K. S., Castro, C. M., Baptista, J. S. &amp; Silva, U. 2020. Wood-logging process management in Eastern Amazonia (Brazil). ''Sustainability'', 12:1-18.&lt;/ref&gt;). Ngamanye amagama, ukutheza kufaka ukugawula iinkuni nanyana ukususa iinkuni, khulukhulu ehlathini uzithuthele kwenye indawo lapho zokusetjenziswa khona.

Kukhulunywa ngokususa nokugawula, ngombana ezinye iinkuni nanyana iingodo uzifumana zizilalele nanyana ziwele phasi, bese ufike ngokubuthelela nawuqedako uzithathe. Kanti-ke, kukhona lezo ekufuneka bonyana zigawulwe emithini begodu eminye imithi leyo ikhitjhwa nemirabhu nanyana neendidi zawo (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot;&gt;Numuene, K. S. &amp; Egbe, A. E. 2022. Impact of Timber Logging on Neighbouring Stands in a Forest of the South Western Cameroon. ''Open Journal of Forestry'', 12:248-262.&lt;/ref&gt;).

=== Umthelela wokutheza ===
Kukhona imithelela eminengi emihle kanye nemimbi yokutheza; kodwana kusihloko sethu lezi sizokutjheja imithelela elandelako:

==== Ubumbi ====

==== 1.      Ukutjhabalalisa imithi yamahlathi. ====
Lokha nasithezako sisusa eminye yemithi leyo ekungeyendabuko (Numuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Imithi leyo iyancipha begodu igcine ingasabi khona. Lokho kwenza bonyana amahlathi angasabi nemithi begodu avuleke.

==== 2.      Ubujamo bezulu ====
Lokha nasithezako sisusa imithi, sitjhiya amahlathi avulekile nemithi inganawo amagatja wokumunye i-carbon dioxide emoyeni (u-Ranius, u-Hamalainen, u-Egnell, u-Olsson, u-Eklof, u-Stendah, u-Rudolphi, u-Stens no-Felton 2018&lt;ref name=&quot;:2&quot;&gt;Ranius, T., Hämäläinen, A., Egnell, G., Olsson, B., Eklöf, K. et al. 2018.The effects of logging residue extraction for energy on ecosystem services and biodiversity: a synthesis. ''Journal of Environmental Management'', 209: 409-425.&lt;/ref&gt;). Lokho kubanga bonyana ubujamo bezulu butjhuguluke kwamambala njengokuthi kube nomtjhiso omkhulu tle nanyana kubemakhaza khulu (u-Ranius ''nabanye'' 2018&lt;ref name=&quot;:2&quot; /&gt;).

==== 3.      Ukutlhogeka kweensetjenziswa ====
Ukutheza kwenza bonyana iinsetjenziswa lezo ezifunekako, ezinjengokudla kwehlathini nemitjhoga itlhogeke (World Wide Fund for Nature 2019&lt;ref&gt;World Wide Fund for Nature. 2019. ''Timber monitoring and control from the first entry on the marke''t. WWF Romania.&lt;/ref&gt;). Ngamanye amagama, abantu abathembele eenkunini, ukupheka nokudla kanye neenlwana ezithembele emini mayelana namakhaya wazo nokudla zizithola zingana buyo.

==== Ubuhle ====

==== 1.      Umnotho wezehlalakuhle ====
Kukhona abantu labo abathembele eenkunini nemithi bonyana bangenise imali begodu baphile (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Abantu laba bathengisa iinkuni lezi begodu abanye babasa imililo ngeenkuni, bafulela ngeengodo begodu bakampela amajarida wabo ngokusebenzisa iingodo.

==== 2.      Imitjhoga ====
Kukhona eminye yemitjhoga leyo eyenziwa ngemithi yendabuko le ebayithezako (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Ngamanye amagama, abantu basenzisa imithi ukulapha kanye nokuhlwengisa ubujamo bepilo bemizimba yabo. 

==== 3.      Ibonelela lomoya ohlwengileko ====
Imithi esikhathini esinengi ithatha nanyana imunya umoya onerhasi emimbi, i-carbon dioxide, bese wona unikele ngomoya olungele ukuphefumula babantu neenlwani, i-oxygen (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Ukungezelela, imithi ihlwengisa umoya esiwuphefumulako nebhoduluko.

'''4 yonga igezi'''

esikhathini esiphilakiso  namhlanje iintengo yegezi ikhuphule khulu. yeke ukutheza kuyindlela ehle khulu yokonga igezi ebantwini abadobha phasi.

==== Isiphetho ====
Ukutheza kuqakatheke khulu eemphakathini yethu. Nanyana kunjalo, nakungenziwa ngendlela yokukhathelela imithi namahlathi kuba nomthelela omumbi eemphakathini yoke. [https://www.depremabi.com/ Son depremler] en iyi depremabi üzerinden görüntülenebilir. Siyazi bonyana abantu abanengi bathembele eemthini nemahlathini mayelana namalengeniso nemitjhoga, ngebanga lelo kufanele sikwenze kokutlhogomela begodu singakwenzeli butjhilweni. 

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>tr9eixzig1o0v95lxdewfxvzthh45zx</sha1>
    </revision>
    <revision>
      <id>5102</id>
      <parentid>5084</parentid>
      <timestamp>2025-08-08T09:54:47Z</timestamp>
      <contributor>
        <username>Willson2001</username>
        <id>841</id>
      </contributor>
      <origin>5102</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4887" sha1="cuwh265gct6sb554nj0luplxid1ucg3" xml:space="preserve">== Ukutheza ==

=== Isingeniso. ===
Ukutheza ngezinye zezenzo ebezikhona ekadeni umqasa usatjhagala ngekhaya. Ukutheza kudlale indima eqakatheke khulu mayelana nokuthi abantu babeneenkuni, ukudla kanye nemalingeniso eemphakathini eminengi, khulukhulu eemndenini esazidobhela phasi. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyini ukutheza begodu bunomthintela enjani eemphakathini esiphila kiyo, khulukhulu yemakhaya. 

=== Kuyini [[:en:Logging|ukutheza]]? ===
Ngokuya kwe-Wikipedia (2024&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. ''Logging''. Itholakala ku: &lt;nowiki&gt;https://en.wikipedia.org/wiki/Logging&lt;/nowiki&gt;. Ufunyenwe ngomhlaka [29 kuRhoboyi 2024].&lt;/ref&gt;) ukutheza sisenzo sokugawula nokususa imithi. Ukungezelela, imithi le egawulilweko yasuswa lapho beyikhona uthuthelwa endaweni etja (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;; Lima, u-Castro, u-Baptista no-Silva 2020&lt;ref&gt;Lima, K. S., Castro, C. M., Baptista, J. S. &amp; Silva, U. 2020. Wood-logging process management in Eastern Amazonia (Brazil). ''Sustainability'', 12:1-18.&lt;/ref&gt;). Ngamanye amagama, ukutheza kufaka ukugawula iinkuni nanyana ukususa iinkuni, khulukhulu ehlathini uzithuthele kwenye indawo lapho zokusetjenziswa khona.

Kukhulunywa ngokususa nokugawula, ngombana ezinye iinkuni nanyana iingodo uzifumana zizilalele nanyana ziwele phasi, bese ufike ngokubuthelela nawuqedako uzithathe. Kanti-ke, kukhona lezo ekufuneka bonyana zigawulwe emithini begodu eminye imithi leyo ikhitjhwa nemirabhu nanyana neendidi zawo (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot;&gt;Numuene, K. S. &amp; Egbe, A. E. 2022. Impact of Timber Logging on Neighbouring Stands in a Forest of the South Western Cameroon. ''Open Journal of Forestry'', 12:248-262.&lt;/ref&gt;).

=== Umthelela wokutheza ===
Kukhona imithelela eminengi emihle kanye nemimbi yokutheza; kodwana kusihloko sethu lezi sizokutjheja imithelela elandelako:

==== Ubumbi ====

==== 1.      Ukutjhabalalisa imithi yamahlathi. ====
Lokha nasithezako sisusa eminye yemithi leyo ekungeyendabuko (Numuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Imithi leyo iyancipha begodu igcine ingasabi khona. Lokho kwenza bonyana amahlathi angasabi nemithi begodu avuleke.

==== 2.      Ubujamo bezulu ====
Lokha nasithezako sisusa imithi, sitjhiya amahlathi avulekile nemithi inganawo amagatja wokumunye i-carbon dioxide emoyeni (u-Ranius, u-Hamalainen, u-Egnell, u-Olsson, u-Eklof, u-Stendah, u-Rudolphi, u-Stens no-Felton 2018&lt;ref name=&quot;:2&quot;&gt;Ranius, T., Hämäläinen, A., Egnell, G., Olsson, B., Eklöf, K. et al. 2018.The effects of logging residue extraction for energy on ecosystem services and biodiversity: a synthesis. ''Journal of Environmental Management'', 209: 409-425.&lt;/ref&gt;). Lokho kubanga bonyana ubujamo bezulu butjhuguluke kwamambala njengokuthi kube nomtjhiso omkhulu tle nanyana kubemakhaza khulu (u-Ranius ''nabanye'' 2018&lt;ref name=&quot;:2&quot; /&gt;).

==== 3.      Ukutlhogeka kweensetjenziswa ====
Ukutheza kwenza bonyana iinsetjenziswa lezo ezifunekako, ezinjengokudla kwehlathini nemitjhoga itlhogeke (World Wide Fund for Nature 2019&lt;ref&gt;World Wide Fund for Nature. 2019. ''Timber monitoring and control from the first entry on the marke''t. WWF Romania.&lt;/ref&gt;). Ngamanye amagama, abantu abathembele eenkunini, ukupheka nokudla kanye neenlwana ezithembele emini mayelana namakhaya wazo nokudla zizithola zingana buyo.

==== Ubuhle ====

==== 1.      Umnotho wezehlalakuhle ====
Kukhona abantu labo abathembele eenkunini nemithi bonyana bangenise imali begodu baphile (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Abantu laba bathengisa iinkuni lezi begodu abanye babasa imililo ngeenkuni, bafulela ngeengodo begodu bakampela amajarida wabo ngokusebenzisa iingodo.

==== 2.      Imitjhoga ====
Kukhona eminye yemitjhoga leyo eyenziwa ngemithi yendabuko le ebayithezako (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Ngamanye amagama, abantu basenzisa imithi ukulapha kanye nokuhlwengisa ubujamo bepilo bemizimba yabo. 

==== 3.      Ibonelela lomoya ohlwengileko ====
Imithi esikhathini esinengi ithatha nanyana imunya umoya onerhasi emimbi, i-carbon dioxide, bese wona unikele ngomoya olungele ukuphefumula babantu neenlwani, i-oxygen (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Ukungezelela, imithi ihlwengisa umoya esiwuphefumulako nebhoduluko.

'''4 yonga igezi'''

esikhathini esiphilakiso  namhlanje iintengo yegezi ikhuphule khulu. yeke ukutheza kuyindlela ehle khulu yokonga igezi ebantwini abadobha phasi.

==== Isiphetho ====
Ukutheza kuqakatheke khulu eemphakathini yethu. Nanyana kunjalo, nakungenziwa ngendlela yokukhathelela imithi namahlathi kuba nomthelela omumbi eemphakathini yoke. [https://www.depremabi.com/ Son depremler] en iyi depremabi üzerinden görüntülenebilir. Siyazi bonyana abantu abanengi bathembele eemthini nemahlathini mayelana namalengeniso nemitjhoga, ngebanga lelo kufanele sikwenze kokutlhogomela begodu singakwenzeli butjhilweni. 

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>cuwh265gct6sb554nj0luplxid1ucg3</sha1>
    </revision>
    <revision>
      <id>6121</id>
      <parentid>5102</parentid>
      <timestamp>2026-01-11T09:31:13Z</timestamp>
      <contributor>
        <username>Hikayeabisi</username>
        <id>1284</id>
      </contributor>
      <origin>6121</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4948" sha1="blqrlvlacaulykd40yc8yo6rox6wdjb" xml:space="preserve">== Ukutheza ==

=== Isingeniso. ===
Ukutheza ngezinye zezenzo ebezikhona ekadeni umqasa usatjhagala ngekhaya. Ukutheza kudlale indima eqakatheke khulu mayelana nokuthi abantu babeneenkuni, ukudla kanye nemalingeniso eemphakathini eminengi, khulukhulu eemndenini esazidobhela phasi. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyini ukutheza begodu bunomthintela enjani eemphakathini esiphila kiyo, khulukhulu yemakhaya. 

=== Kuyini [[:en:Logging|ukutheza]]? ===
Ngokuya kwe-Wikipedia (2024&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. ''Logging''. Itholakala ku: &lt;nowiki&gt;https://en.wikipedia.org/wiki/Logging&lt;/nowiki&gt;. Ufunyenwe ngomhlaka [29 kuRhoboyi 2024].&lt;/ref&gt;) ukutheza sisenzo sokugawula nokususa imithi. Ukungezelela, imithi le egawulilweko yasuswa lapho beyikhona uthuthelwa endaweni etja (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;; Lima, u-Castro, u-Baptista no-Silva 2020&lt;ref&gt;Lima, K. S., Castro, C. M., Baptista, J. S. &amp; Silva, U. 2020. Wood-logging process management in Eastern Amazonia (Brazil). ''Sustainability'', 12:1-18.&lt;/ref&gt;). Ngamanye amagama, ukutheza kufaka ukugawula iinkuni nanyana ukususa iinkuni, khulukhulu ehlathini uzithuthele kwenye indawo lapho zokusetjenziswa khona.

Kukhulunywa ngokususa nokugawula, ngombana ezinye iinkuni nanyana iingodo uzifumana zizilalele nanyana ziwele phasi, bese ufike ngokubuthelela nawuqedako uzithathe. Kanti-ke, kukhona lezo ekufuneka bonyana zigawulwe emithini begodu eminye imithi leyo ikhitjhwa nemirabhu nanyana neendidi zawo (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot;&gt;Numuene, K. S. &amp; Egbe, A. E. 2022. Impact of Timber Logging on Neighbouring Stands in a Forest of the South Western Cameroon. ''Open Journal of Forestry'', 12:248-262.&lt;/ref&gt;).

=== Umthelela wokutheza ===
Kukhona imithelela eminengi emihle kanye nemimbi yokutheza; kodwana kusihloko sethu lezi sizokutjheja imithelela elandelako:

==== Ubumbi ====

==== 1.      Ukutjhabalalisa imithi yamahlathi. ====
Lokha nasithezako sisusa eminye yemithi leyo ekungeyendabuko (Numuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Imithi leyo iyancipha begodu igcine ingasabi khona. Lokho kwenza bonyana amahlathi angasabi nemithi begodu avuleke.

==== 2.      Ubujamo bezulu ====
Lokha nasithezako sisusa imithi, sitjhiya amahlathi avulekile nemithi inganawo amagatja wokumunye i-carbon dioxide emoyeni (u-Ranius, u-Hamalainen, u-Egnell, u-Olsson, u-Eklof, u-Stendah, u-Rudolphi, u-Stens no-Felton 2018&lt;ref name=&quot;:2&quot;&gt;Ranius, T., Hämäläinen, A., Egnell, G., Olsson, B., Eklöf, K. et al. 2018.The effects of logging residue extraction for energy on ecosystem services and biodiversity: a synthesis. ''Journal of Environmental Management'', 209: 409-425.&lt;/ref&gt;). Lokho kubanga bonyana ubujamo bezulu butjhuguluke kwamambala njengokuthi kube nomtjhiso omkhulu tle nanyana kubemakhaza khulu (u-Ranius ''nabanye'' 2018&lt;ref name=&quot;:2&quot; /&gt;).

==== 3.      Ukutlhogeka kweensetjenziswa ====
Ukutheza kwenza bonyana iinsetjenziswa lezo ezifunekako, ezinjengokudla kwehlathini nemitjhoga itlhogeke (World Wide Fund for Nature 2019&lt;ref&gt;World Wide Fund for Nature. 2019. ''Timber monitoring and control from the first entry on the marke''t. WWF Romania.&lt;/ref&gt;). Ngamanye amagama, abantu abathembele eenkunini, ukupheka nokudla kanye neenlwana ezithembele emini mayelana namakhaya wazo nokudla zizithola zingana buyo.

==== Ubuhle ====

==== 1.      Umnotho wezehlalakuhle ====
Kukhona abantu labo abathembele eenkunini nemithi bonyana bangenise imali begodu baphile (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Abantu laba bathengisa iinkuni lezi begodu abanye babasa imililo ngeenkuni, bafulela ngeengodo begodu bakampela amajarida wabo ngokusebenzisa iingodo.

==== 2.      Imitjhoga ====
Kukhona eminye yemitjhoga leyo eyenziwa ngemithi yendabuko le ebayithezako (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Ngamanye amagama, abantu basenzisa imithi ukulapha kanye nokuhlwengisa ubujamo bepilo bemizimba yabo. 

==== 3.      Ibonelela lomoya ohlwengileko ====
Imithi esikhathini esinengi ithatha nanyana imunya umoya onerhasi emimbi, i-carbon dioxide, bese wona unikele ngomoya olungele ukuphefumula babantu neenlwani, i-oxygen (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Ukungezelela, imithi ihlwengisa umoya esiwuphefumulako nebhoduluko.

'''4 yonga igezi'''

esikhathini esiphilakiso  namhlanje iintengo yegezi ikhuphule khulu. yeke ukutheza kuyindlela ehle khulu yokonga igezi ebantwini abadobha phasi.

==== Isiphetho ====
Ukutheza kuqakatheke khulu eemphakathini yethu. Nanyana kunjalo, nakungenziwa ngendlela yokukhathelela imithi namahlathi kuba nomthelela omumbi eemphakathini yoke. [https://www.depremabi.com/ Son depremler] en iyi depremabi üzerinden görüntülenebilir. Siyazi bonyana abantu abanengi bathembele eemthini [https://www.boyamaetkinlikleri.com.tr/ Boyama Etkinlikleri] nemahlathini mayelana namalengeniso nemitjhoga, ngebanga lelo kufanele sikwenze kokutlhogomela begodu singakwenzeli butjhilweni. 

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>blqrlvlacaulykd40yc8yo6rox6wdjb</sha1>
    </revision>
    <revision>
      <id>6484</id>
      <parentid>6121</parentid>
      <timestamp>2026-04-28T08:07:10Z</timestamp>
      <contributor>
        <username>~2026-25774-60</username>
        <id>1489</id>
      </contributor>
      <comment>Ngihlele; bekukhona incwadi engekho.</comment>
      <origin>6484</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4985" sha1="h8i18ixphek57we5mpub7de6uqr3nca" xml:space="preserve">== Ukutheza ==

=== Isingeniso. ===
Ukutheza ngezinye zezenzo ebezikhona ekadeni umqasa usatjhagala ngekhaya. Ukutheza kudlale indima eqakatheke khulu mayelana nokuthi abantu babeneenkuni, ukudla kanye nemalingeniso eemphakathini eminengi, khulukhulu eemndenini esazidobhela phasi. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyini ukutheza begodu bunomthintela enjani eemphakathini esiphila kiyo, khulukhulu yemakhaya. 

=== Kuyini [[:en:Logging|ukutheza]]? ===
Ngokuya kwe-Wikipedia (2024&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. ''Logging''. Itholakala ku: &lt;nowiki&gt;https://en.wikipedia.org/wiki/Logging&lt;/nowiki&gt;. Ufunyenwe ngomhlaka [29 kuRhoboyi 2024].&lt;/ref&gt;) ukutheza sisenzo sokugawula nokususa imithi. Ukungezelela, imithi le egawulilweko yasuswa lapho beyikhona uthuthelwa endaweni etja (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;; Lima, u-Castro, u-Baptista no-Silva 2020&lt;ref&gt;Lima, K. S., Castro, C. M., Baptista, J. S. &amp; Silva, U. 2020. Wood-logging process management in Eastern Amazonia (Brazil). ''Sustainability'', 12:1-18.&lt;/ref&gt;). Ngamanye amagama, ukutheza kufaka ukugawula iinkuni nanyana ukususa iinkuni, khulukhulu ehlathini uzithuthele kwenye indawo lapho zokusetjenziswa khona.

Kukhulunywa ngokususa nokugawula, ngombana ezinye iinkuni nanyana iingodo uzifumana zizilalele nanyana ziwele phasi, bese ufike ngokubuthelela nawuqedako uzithathe. Kanti-ke, kukhona lezo ekufuneka bonyana zigawulwe emithini begodu eminye imithi leyo ikhitjhwa nemirabhu nanyana neendidi zawo (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot;&gt;Numuene, K. S. &amp; Egbe, A. E. 2022. Impact of Timber Logging on Neighbouring Stands in a Forest of the South Western Cameroon. ''Open Journal of Forestry'', 12:248-262.&lt;/ref&gt;).

=== Umthelela wokutheza ===
Kukhona imithelela eminengi emihle kanye nemimbi yokutheza; kodwana kusihloko sethu lezi sizokutjheja imithelela elandelako:

==== Ubumbi ====

==== 1.      Ukutjhabalalisa imithi yamahlathi. ====
Lokha nasithezako sisusa eminye yemithi leyo ekungeyendabuko (Numuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Imithi leyo iyancipha begodu igcine ingasabi khona. Lokho kwenza bonyana amahlathi angasabi nemithi begodu avuleke.

==== 2.      Ubujamo bezulu ====
Lokha nasithezako sisusa imithi, sitjhiya amahlathi avulekile nemithi inganawo amagatja wokumunye i-carbon dioxide emoyeni (u-Ranius, u-Hamalainen, u-Egnell, u-Olsson, u-Eklof, u-Stendah, u-Rudolphi, u-Stens no-Felton 2018&lt;ref name=&quot;:2&quot;&gt;Ranius, T., Hämäläinen, A., Egnell, G., Olsson, B., Eklöf, K. et al. 2018.The effects of logging residue extraction for energy on ecosystem services and biodiversity: a synthesis. ''Journal of Environmental Management'', 209: 409-425.&lt;/ref&gt;). Lokho kubanga bonyana ubujamo bezulu butjhuguluke kwamambala njengokuthi kube nomtjhiso omkhulu tle nanyana kubemakhaza khulu (u-Ranius ''nabanye'' 2018&lt;ref name=&quot;:2&quot; /&gt;).

==== 3.      Ukutlhogeka kweensetjenziswa ====
Ukutheza kwenza bonyana iinsetjenziswa lezo ezifunekako, ezinjengokudla kwehlathini nemitjhoga itlhogeke (World Wide Fund for Nature 2019&lt;ref&gt;World Wide Fund for Nature. 2019. ''Timber monitoring and control from the first entry on the marke''t. WWF Romania.&lt;/ref&gt;). Ngamanye amagama, abantu abathembele eenkunini, ukupheka nokudla kanye neenlwana ezithembele emini mayelana namakhaya wazo nokudla zizithola zingana buyo.

==== Ubuhle ====

==== 1.      Umnotho wezehlalakuhle ====
Kukhona abantu labo abathembele eenkunini nemithi bonyana bangenise imali begodu baphile (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). [https://kind-malde.de Ausmalbilder] Abantu laba bathengisa iinkuni lezi begodu abanye babasa imililo ngeenkuni, bafulela ngeengodo begodu bakampela amajarida wabo ngokusebenzisa iingodo.

==== 2.      Imitjhoga ====
Kukhona eminye yemitjhoga leyo eyenziwa ngemithi yendabuko le ebayithezako (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Ngamanye amagama, abantu basenzisa imithi ukulapha kanye nokuhlwengisa ubujamo bepilo bemizimba yabo. 

==== 3.      Ibonelela lomoya ohlwengileko ====
Imithi esikhathini esinengi ithatha nanyana imunya umoya onerhasi emimbi, i-carbon dioxide, bese wona unikele ngomoya olungele ukuphefumula babantu neenlwani, i-oxygen (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Ukungezelela, imithi ihlwengisa umoya esiwuphefumulako nebhoduluko.

'''4 yonga igezi'''

esikhathini esiphilakiso  namhlanje iintengo yegezi ikhuphule khulu. yeke ukutheza kuyindlela ehle khulu yokonga igezi ebantwini abadobha phasi.

==== Isiphetho ====
Ukutheza kuqakatheke khulu eemphakathini yethu. Nanyana kunjalo, nakungenziwa ngendlela yokukhathelela imithi namahlathi kuba nomthelela omumbi eemphakathini yoke. [https://www.depremabi.com/ Son depremler] en iyi depremabi üzerinden görüntülenebilir. Siyazi bonyana abantu abanengi bathembele eemthini [https://www.boyamaetkinlikleri.com.tr/ Boyama Etkinlikleri] nemahlathini mayelana namalengeniso nemitjhoga, ngebanga lelo kufanele sikwenze kokutlhogomela begodu singakwenzeli butjhilweni. 

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>h8i18ixphek57we5mpub7de6uqr3nca</sha1>
    </revision>
    <revision>
      <id>6495</id>
      <parentid>6484</parentid>
      <timestamp>2026-05-13T18:41:37Z</timestamp>
      <contributor>
        <username>Icodense</username>
        <id>494</id>
      </contributor>
      <comment>Undid revision [[Special:Diff/6484|6484]] by [[Special:Contributions/~2026-25774-60|~2026-25774-60]] ([[User talk:~2026-25774-60|talk]]); linkspam</comment>
      <origin>6495</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4948" sha1="blqrlvlacaulykd40yc8yo6rox6wdjb" xml:space="preserve">== Ukutheza ==

=== Isingeniso. ===
Ukutheza ngezinye zezenzo ebezikhona ekadeni umqasa usatjhagala ngekhaya. Ukutheza kudlale indima eqakatheke khulu mayelana nokuthi abantu babeneenkuni, ukudla kanye nemalingeniso eemphakathini eminengi, khulukhulu eemndenini esazidobhela phasi. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyini ukutheza begodu bunomthintela enjani eemphakathini esiphila kiyo, khulukhulu yemakhaya. 

=== Kuyini [[:en:Logging|ukutheza]]? ===
Ngokuya kwe-Wikipedia (2024&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. ''Logging''. Itholakala ku: &lt;nowiki&gt;https://en.wikipedia.org/wiki/Logging&lt;/nowiki&gt;. Ufunyenwe ngomhlaka [29 kuRhoboyi 2024].&lt;/ref&gt;) ukutheza sisenzo sokugawula nokususa imithi. Ukungezelela, imithi le egawulilweko yasuswa lapho beyikhona uthuthelwa endaweni etja (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;; Lima, u-Castro, u-Baptista no-Silva 2020&lt;ref&gt;Lima, K. S., Castro, C. M., Baptista, J. S. &amp; Silva, U. 2020. Wood-logging process management in Eastern Amazonia (Brazil). ''Sustainability'', 12:1-18.&lt;/ref&gt;). Ngamanye amagama, ukutheza kufaka ukugawula iinkuni nanyana ukususa iinkuni, khulukhulu ehlathini uzithuthele kwenye indawo lapho zokusetjenziswa khona.

Kukhulunywa ngokususa nokugawula, ngombana ezinye iinkuni nanyana iingodo uzifumana zizilalele nanyana ziwele phasi, bese ufike ngokubuthelela nawuqedako uzithathe. Kanti-ke, kukhona lezo ekufuneka bonyana zigawulwe emithini begodu eminye imithi leyo ikhitjhwa nemirabhu nanyana neendidi zawo (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot;&gt;Numuene, K. S. &amp; Egbe, A. E. 2022. Impact of Timber Logging on Neighbouring Stands in a Forest of the South Western Cameroon. ''Open Journal of Forestry'', 12:248-262.&lt;/ref&gt;).

=== Umthelela wokutheza ===
Kukhona imithelela eminengi emihle kanye nemimbi yokutheza; kodwana kusihloko sethu lezi sizokutjheja imithelela elandelako:

==== Ubumbi ====

==== 1.      Ukutjhabalalisa imithi yamahlathi. ====
Lokha nasithezako sisusa eminye yemithi leyo ekungeyendabuko (Numuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Imithi leyo iyancipha begodu igcine ingasabi khona. Lokho kwenza bonyana amahlathi angasabi nemithi begodu avuleke.

==== 2.      Ubujamo bezulu ====
Lokha nasithezako sisusa imithi, sitjhiya amahlathi avulekile nemithi inganawo amagatja wokumunye i-carbon dioxide emoyeni (u-Ranius, u-Hamalainen, u-Egnell, u-Olsson, u-Eklof, u-Stendah, u-Rudolphi, u-Stens no-Felton 2018&lt;ref name=&quot;:2&quot;&gt;Ranius, T., Hämäläinen, A., Egnell, G., Olsson, B., Eklöf, K. et al. 2018.The effects of logging residue extraction for energy on ecosystem services and biodiversity: a synthesis. ''Journal of Environmental Management'', 209: 409-425.&lt;/ref&gt;). Lokho kubanga bonyana ubujamo bezulu butjhuguluke kwamambala njengokuthi kube nomtjhiso omkhulu tle nanyana kubemakhaza khulu (u-Ranius ''nabanye'' 2018&lt;ref name=&quot;:2&quot; /&gt;).

==== 3.      Ukutlhogeka kweensetjenziswa ====
Ukutheza kwenza bonyana iinsetjenziswa lezo ezifunekako, ezinjengokudla kwehlathini nemitjhoga itlhogeke (World Wide Fund for Nature 2019&lt;ref&gt;World Wide Fund for Nature. 2019. ''Timber monitoring and control from the first entry on the marke''t. WWF Romania.&lt;/ref&gt;). Ngamanye amagama, abantu abathembele eenkunini, ukupheka nokudla kanye neenlwana ezithembele emini mayelana namakhaya wazo nokudla zizithola zingana buyo.

==== Ubuhle ====

==== 1.      Umnotho wezehlalakuhle ====
Kukhona abantu labo abathembele eenkunini nemithi bonyana bangenise imali begodu baphile (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Abantu laba bathengisa iinkuni lezi begodu abanye babasa imililo ngeenkuni, bafulela ngeengodo begodu bakampela amajarida wabo ngokusebenzisa iingodo.

==== 2.      Imitjhoga ====
Kukhona eminye yemitjhoga leyo eyenziwa ngemithi yendabuko le ebayithezako (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Ngamanye amagama, abantu basenzisa imithi ukulapha kanye nokuhlwengisa ubujamo bepilo bemizimba yabo. 

==== 3.      Ibonelela lomoya ohlwengileko ====
Imithi esikhathini esinengi ithatha nanyana imunya umoya onerhasi emimbi, i-carbon dioxide, bese wona unikele ngomoya olungele ukuphefumula babantu neenlwani, i-oxygen (Namuene no-Egbe 2022&lt;ref name=&quot;:1&quot; /&gt;). Ukungezelela, imithi ihlwengisa umoya esiwuphefumulako nebhoduluko.

'''4 yonga igezi'''

esikhathini esiphilakiso  namhlanje iintengo yegezi ikhuphule khulu. yeke ukutheza kuyindlela ehle khulu yokonga igezi ebantwini abadobha phasi.

==== Isiphetho ====
Ukutheza kuqakatheke khulu eemphakathini yethu. Nanyana kunjalo, nakungenziwa ngendlela yokukhathelela imithi namahlathi kuba nomthelela omumbi eemphakathini yoke. [https://www.depremabi.com/ Son depremler] en iyi depremabi üzerinden görüntülenebilir. Siyazi bonyana abantu abanengi bathembele eemthini [https://www.boyamaetkinlikleri.com.tr/ Boyama Etkinlikleri] nemahlathini mayelana namalengeniso nemitjhoga, ngebanga lelo kufanele sikwenze kokutlhogomela begodu singakwenzeli butjhilweni. 

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>blqrlvlacaulykd40yc8yo6rox6wdjb</sha1>
    </revision>
  </page>
  <page>
    <title>Ukuthuthuka kwelimi lesiNdebele</title>
    <ns>0</ns>
    <id>258</id>
    <revision>
      <id>1383</id>
      <timestamp>2024-03-08T13:30:37Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;Ilimi lesiNdebele ngelinye lamalimi ekhalunywa eSewula Afrika, engazange libe netjhudu lokuthuthukiswa lokha nakufika amamitjhinari eSewula Afrika. Lokhu kwabangela kukobana isitjhaba samaNdebele sabe singakabumbani ngesikhathi sokufika kwamamitjhinari. Nasitjheja ukuthuthuka kwelimi ukusukela ngonyaka we-2000 ukuya enyakeni we-2024 sithola bonyana isiNdebele sele sithuthukele khulu ngombana sele kune bhayibheli etlolwe ngesiNdebele eyakhutjhwa ngo 2012, sikhona emrhatjh...&quot;</comment>
      <origin>1383</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="881" sha1="a9wc1a66zzzft1038b90tppez9scng4" xml:space="preserve">Ilimi lesiNdebele ngelinye lamalimi ekhalunywa eSewula Afrika, engazange libe netjhudu lokuthuthukiswa lokha nakufika amamitjhinari eSewula Afrika. Lokhu kwabangela kukobana isitjhaba samaNdebele sabe singakabumbani ngesikhathi sokufika kwamamitjhinari. Nasitjheja ukuthuthuka kwelimi ukusukela ngonyaka we-2000 ukuya enyakeni we-2024 sithola bonyana isiNdebele sele sithuthukele khulu ngombana sele kune bhayibheli etlolwe ngesiNdebele eyakhutjhwa ngo 2012, sikhona emrhatjhweni, begodu sikhona nakibomabonakude. Sele kutholakala nama filimu enziwe bewadlala ngesiNdebele. Nakwezefundo sele sithuthukile ngombana sele kuneenhlathululi mezwi zesiNdebele.

Lokhu kutjengisa bona sele ilimi  lesiNdebele lithuthuke khulu begodu lisaragela phambili liyathuthukiswa. Ukuthuthukiswa kwelimi  leli kuyinto ehle khulu ngombana lokhu kuzokwenza bonyana ilimi lesiNdebele lingatjhabalali.

</text>
      <sha1>a9wc1a66zzzft1038b90tppez9scng4</sha1>
    </revision>
    <revision>
      <id>1384</id>
      <parentid>1383</parentid>
      <timestamp>2024-03-08T13:41:27Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1384</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="948" sha1="i1vij3wlepkjechzouf80ief3sfaa1c" xml:space="preserve">Ilimi lesiNdebele ngelinye lamalimi ekhalunywa eSewula Afrika, engazange libe netjhudu lokuthuthukiswa lokha nakufika amamitjhinari eSewula Afrika. Lokhu kwabangela kukobana isitjhaba samaNdebele sabe singakabumbani ngesikhathi sokufika kwamamitjhinari. Nasitjheja ukuthuthuka kwelimi ukusukela ngonyaka we-2000 ukuya enyakeni we-2024 sithola bonyana isiNdebele sele sithuthukele khulu ngombana sele kune bhayibheli etlolwe ngesiNdebele eyakhutjhwa ngo 2012, sikhona emrhatjhweni, begodu sikhona nakibomabonakude. Sele kutholakala nama filimu enziwe bewadlala ngesiNdebele. Nakwezefundo sele sithuthukile ngombana sele kuneenhlathululi mezwi zesiNdebele.

Lokhu kutjengisa bona sele ilimi  lesiNdebele lithuthuke khulu begodu lisaragela phambili liyathuthukiswa ngombala ilimi leli sele lizokutholaka naku na online ku wikipedia. Ukuthuthukiswa kwelimi  leli kuyinto ehle khulu ngombana lokhu kuzokwenza bonyana ilimi lesiNdebele lingatjhabalali.

</text>
      <sha1>i1vij3wlepkjechzouf80ief3sfaa1c</sha1>
    </revision>
    <revision>
      <id>1385</id>
      <parentid>1384</parentid>
      <timestamp>2024-03-08T13:43:01Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1385</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="943" sha1="63rx1izcnl9dnwq2n0wxho47npcsfxu" xml:space="preserve">Ilimi lesiNdebele ngelinye lamalimi ekhalunywa eSewula Afrika, engazange libe netjhudu lokuthuthukiswa lokha nakufika amamitjhinari eSewula Afrika. Lokhu kwabangela kukobana isitjhaba samaNdebele sabe singakabumbani ngesikhathi sokufika kwamamitjhinari. Nasitjheja ukuthuthuka kwelimi ukusukela ngonyaka we-2000 ukuya enyakeni we-2024 sithola bonyana isiNdebele sele sithuthukele khulu ngombana sele kune bhayibheli etlolwe ngesiNdebele eyakhutjhwa ngo 2012, sikhona emrhatjhweni, begodu sikhona nakibomabonakude. Sele kutholakala nama filimu enziwe bewadlala ngesiNdebele. Nakwezefundo sele sithuthukile ngombana sele kuneenhlathululi mezwi zesiNdebele.

Lokhu kutjengisa bona sele ilimi  lesiNdebele lithuthuke khulu begodu lisaragela phambili liyathuthukiswa ngombala ilimi leli sele lizokutholaka na online ku wikipedia. Ukuthuthukiswa kwelimi  leli kuyinto ehle khulu ngombana lokhu kuzokwenza bonyana ilimi lesiNdebele lingatjhabalali.

</text>
      <sha1>63rx1izcnl9dnwq2n0wxho47npcsfxu</sha1>
    </revision>
    <revision>
      <id>1386</id>
      <parentid>1385</parentid>
      <timestamp>2024-03-09T07:33:33Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1386</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="947" sha1="sevj9ch3cgbverwwcb898okwyapyh1r" xml:space="preserve">Ilimi lesi[[Ndebele]] ngelinye lamalimi ekhalunywa eSewula Afrika, engazange libe netjhudu lokuthuthukiswa lokha nakufika amamitjhinari eSewula Afrika. Lokhu kwabangela kukobana isitjhaba samaNdebele sabe singakabumbani ngesikhathi sokufika kwamamitjhinari. Nasitjheja ukuthuthuka kwelimi ukusukela ngonyaka we-2000 ukuya enyakeni we-2024 sithola bonyana isiNdebele sele sithuthukele khulu ngombana sele kune bhayibheli etlolwe ngesiNdebele eyakhutjhwa ngo 2012, sikhona emrhatjhweni, begodu sikhona nakibomabonakude. Sele kutholakala nama filimu enziwe bewadlala ngesiNdebele. Nakwezefundo sele sithuthukile ngombana sele kuneenhlathululi mezwi zesiNdebele.

Lokhu kutjengisa bona sele ilimi  lesiNdebele lithuthuke khulu begodu lisaragela phambili liyathuthukiswa ngombala ilimi leli sele lizokutholaka na online ku wikipedia. Ukuthuthukiswa kwelimi  leli kuyinto ehle khulu ngombana lokhu kuzokwenza bonyana ilimi lesiNdebele lingatjhabalali.

</text>
      <sha1>sevj9ch3cgbverwwcb898okwyapyh1r</sha1>
    </revision>
    <revision>
      <id>1387</id>
      <parentid>1386</parentid>
      <timestamp>2024-03-09T07:45:32Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1387</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="966" sha1="gjwr5kapfcjivdq36giripjuuhz34e1" xml:space="preserve">Ilimi lesi[[Ndebele]] ngelinye lamalimi ekhalunywa eSewula Afrika, engazange libe netjhudu lokuthuthukiswa lokha nakufika amamitjhinari e[[Isewula Afrika|Sewula Afrika]]. Lokhu kwabangela kukobana isitjhaba samaNdebele sabe singakabumbani ngesikhathi sokufika kwamamitjhinari. Nasitjheja ukuthuthuka kwelimi ukusukela ngonyaka we-2000 ukuya enyakeni we-2024 sithola bonyana isiNdebele sele sithuthukele khulu ngombana sele kune bhayibheli etlolwe ngesiNdebele eyakhutjhwa ngo 2012, sikhona emrhatjhweni, begodu sikhona nakibomabonakude. Sele kutholakala nama filimu enziwe bewadlala ngesiNdebele. Nakwezefundo sele sithuthukile ngombana sele kuneenhlathululi mezwi zesiNdebele.

Lokhu kutjengisa bona sele ilimi  lesiNdebele lithuthuke khulu begodu lisaragela phambili liyathuthukiswa ngombala ilimi leli sele lizokutholaka na online ku wikipedia. Ukuthuthukiswa kwelimi  leli kuyinto ehle khulu ngombana lokhu kuzokwenza bonyana ilimi lesiNdebele lingatjhabalali.

</text>
      <sha1>gjwr5kapfcjivdq36giripjuuhz34e1</sha1>
    </revision>
    <revision>
      <id>1388</id>
      <parentid>1387</parentid>
      <timestamp>2024-03-09T07:46:18Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1388</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="970" sha1="hwedhonfuutsb2v340ig8gjyfh59nyp" xml:space="preserve">Ilimi lesi[[Ndebele]] ngelinye lamalimi ekhalunywa eSewula Afrika, engazange libe netjhudu lokuthuthukiswa lokha nakufika amamitjhinari e[[Isewula Afrika|Sewula Afrika]]. Lokhu kwabangela kukobana isitjhaba samaNdebele sabe singakabumbani ngesikhathi sokufika kwamamitjhinari. Nasitjheja ukuthuthuka kwelimi ukusukela ngonyaka we-2000 ukuya enyakeni we-2024 sithola bonyana isiNdebele sele sithuthukele khulu ngombana sele kune [[bhayibheli]] etlolwe ngesiNdebele eyakhutjhwa ngo 2012, sikhona emrhatjhweni, begodu sikhona nakibomabonakude. Sele kutholakala nama filimu enziwe bewadlala ngesiNdebele. Nakwezefundo sele sithuthukile ngombana sele kuneenhlathululi mezwi zesiNdebele.

Lokhu kutjengisa bona sele ilimi  lesiNdebele lithuthuke khulu begodu lisaragela phambili liyathuthukiswa ngombala ilimi leli sele lizokutholaka na online ku wikipedia. Ukuthuthukiswa kwelimi  leli kuyinto ehle khulu ngombana lokhu kuzokwenza bonyana ilimi lesiNdebele lingatjhabalali.

</text>
      <sha1>hwedhonfuutsb2v340ig8gjyfh59nyp</sha1>
    </revision>
    <revision>
      <id>1389</id>
      <parentid>1388</parentid>
      <timestamp>2024-03-09T07:46:48Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1389</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="974" sha1="go3q00gbjr6btvadf881ijwkm8d2oxp" xml:space="preserve">Ilimi lesi[[Ndebele]] ngelinye lamalimi ekhalunywa eSewula Afrika, engazange libe netjhudu lokuthuthukiswa lokha nakufika amamitjhinari e[[Isewula Afrika|Sewula Afrika]]. Lokhu kwabangela kukobana isitjhaba samaNdebele sabe singakabumbani ngesikhathi sokufika kwamamitjhinari. Nasitjheja ukuthuthuka kwelimi ukusukela ngonyaka we-2000 ukuya enyakeni we-2024 sithola bonyana isiNdebele sele sithuthukele khulu ngombana sele kune [[bhayibheli]] etlolwe ngesiNdebele eyakhutjhwa ngo 2012, sikhona emrhatjhweni, begodu sikhona nakibomabonakude. Sele kutholakala nama filimu enziwe bewadlala ngesiNdebele. Na[[kwezefundo]] sele sithuthukile ngombana sele kuneenhlathululi mezwi zesiNdebele.

Lokhu kutjengisa bona sele ilimi  lesiNdebele lithuthuke khulu begodu lisaragela phambili liyathuthukiswa ngombala ilimi leli sele lizokutholaka na online ku wikipedia. Ukuthuthukiswa kwelimi  leli kuyinto ehle khulu ngombana lokhu kuzokwenza bonyana ilimi lesiNdebele lingatjhabalali.

</text>
      <sha1>go3q00gbjr6btvadf881ijwkm8d2oxp</sha1>
    </revision>
    <revision>
      <id>1390</id>
      <parentid>1389</parentid>
      <timestamp>2024-03-09T07:47:17Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1390</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="996" sha1="9ojeait4siagtjjtxtn3d38o450oafq" xml:space="preserve">Ilimi lesi[[Ndebele]] ngelinye lamalimi ekhalunywa eSewula Afrika, engazange libe netjhudu lokuthuthukiswa lokha nakufika amamitjhinari e[[Isewula Afrika|Sewula Afrika]]. Lokhu kwabangela kukobana isitjhaba samaNdebele sabe singakabumbani ngesikhathi sokufika kwamamitjhinari. Nasitjheja ukuthuthuka kwelimi ukusukela ngonyaka we-2000 ukuya enyakeni we-2024 sithola bonyana isiNdebele sele sithuthukele khulu ngombana sele kune [[bhayibheli]] etlolwe ngesiNdebele eyakhutjhwa ngo 2012, sikhona emrhatjhweni, begodu sikhona nakibomabonakude. Sele kutholakala nama filimu enziwe bewadlala ngesiNdebele. Na[[kwezefundo]] sele sithuthukile ngombana sele kuneenhlathululi mezwi zesiNdebele.

Lokhu kutjengisa bona sele [[ilimi lesindebele|ilimi]]  lesiNdebele lithuthuke khulu begodu lisaragela phambili liyathuthukiswa ngombala ilimi leli sele lizokutholaka na online ku wikipedia. Ukuthuthukiswa kwelimi  leli kuyinto ehle khulu ngombana lokhu kuzokwenza bonyana ilimi lesiNdebele lingatjhabalali.

</text>
      <sha1>9ojeait4siagtjjtxtn3d38o450oafq</sha1>
    </revision>
    <revision>
      <id>1391</id>
      <parentid>1390</parentid>
      <timestamp>2024-03-09T08:19:55Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1391</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1104" sha1="k7709exhmpf387fg4oi25h8yghtbct4" xml:space="preserve">[[Isimumathi:BMW 525i Art Car - Esther Mahlangu (1991).jpg|thumb|imodere egwalwe nguMma u Esther Mahlangu]]
Ilimi lesi[[Ndebele]] ngelinye lamalimi ekhalunywa eSewula Afrika, engazange libe netjhudu lokuthuthukiswa lokha nakufika amamitjhinari e[[Isewula Afrika|Sewula Afrika]]. Lokhu kwabangela kukobana isitjhaba samaNdebele sabe singakabumbani ngesikhathi sokufika kwamamitjhinari. Nasitjheja ukuthuthuka kwelimi ukusukela ngonyaka we-2000 ukuya enyakeni we-2024 sithola bonyana isiNdebele sele sithuthukele khulu ngombana sele kune [[bhayibheli]] etlolwe ngesiNdebele eyakhutjhwa ngo 2012, sikhona emrhatjhweni, begodu sikhona nakibomabonakude. Sele kutholakala nama filimu enziwe bewadlala ngesiNdebele. Na[[kwezefundo]] sele sithuthukile ngombana sele kuneenhlathululi mezwi zesiNdebele.

Lokhu kutjengisa bona sele [[ilimi lesindebele|ilimi]]  lesiNdebele lithuthuke khulu begodu lisaragela phambili liyathuthukiswa ngombala ilimi leli sele lizokutholaka na online ku wikipedia. Ukuthuthukiswa kwelimi  leli kuyinto ehle khulu ngombana lokhu kuzokwenza bonyana ilimi lesiNdebele lingatjhabalali.

</text>
      <sha1>k7709exhmpf387fg4oi25h8yghtbct4</sha1>
    </revision>
    <revision>
      <id>1392</id>
      <parentid>1391</parentid>
      <timestamp>2024-10-14T13:47:39Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>9 revisions imported</comment>
      <origin>1391</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1104" sha1="k7709exhmpf387fg4oi25h8yghtbct4" xml:space="preserve">[[Isimumathi:BMW 525i Art Car - Esther Mahlangu (1991).jpg|thumb|imodere egwalwe nguMma u Esther Mahlangu]]
Ilimi lesi[[Ndebele]] ngelinye lamalimi ekhalunywa eSewula Afrika, engazange libe netjhudu lokuthuthukiswa lokha nakufika amamitjhinari e[[Isewula Afrika|Sewula Afrika]]. Lokhu kwabangela kukobana isitjhaba samaNdebele sabe singakabumbani ngesikhathi sokufika kwamamitjhinari. Nasitjheja ukuthuthuka kwelimi ukusukela ngonyaka we-2000 ukuya enyakeni we-2024 sithola bonyana isiNdebele sele sithuthukele khulu ngombana sele kune [[bhayibheli]] etlolwe ngesiNdebele eyakhutjhwa ngo 2012, sikhona emrhatjhweni, begodu sikhona nakibomabonakude. Sele kutholakala nama filimu enziwe bewadlala ngesiNdebele. Na[[kwezefundo]] sele sithuthukile ngombana sele kuneenhlathululi mezwi zesiNdebele.

Lokhu kutjengisa bona sele [[ilimi lesindebele|ilimi]]  lesiNdebele lithuthuke khulu begodu lisaragela phambili liyathuthukiswa ngombala ilimi leli sele lizokutholaka na online ku wikipedia. Ukuthuthukiswa kwelimi  leli kuyinto ehle khulu ngombana lokhu kuzokwenza bonyana ilimi lesiNdebele lingatjhabalali.

</text>
      <sha1>k7709exhmpf387fg4oi25h8yghtbct4</sha1>
    </revision>
  </page>
  <page>
    <title>Ukuthwala</title>
    <ns>0</ns>
    <id>259</id>
    <revision>
      <id>1393</id>
      <timestamp>2024-03-08T13:26:38Z</timestamp>
      <contributor>
        <username>incubator&gt;NomusaAMethula</username>
        <id>0</id>
      </contributor>
      <comment>This article is talking about the power of waiting. People should strive for their success and not take short-cuts.</comment>
      <origin>1393</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="506" sha1="l3jt4if8fszxkbv40znymp3wmsayi9u" xml:space="preserve">Ukuthwala sele kurhagele khulu enarheni yeSewula Afrika. Inengi labantu lifuna ukuphumelela msinyana. Njenga nje, basebenzisa iinlwana ezifana neenyoka, iimfene, iinkukhu nezinye ukuthola ipumelelo abayifunako. Kuthoma kubasebenzela kuhle babe zigwili. Kodwana, akupheli kuhle, ngombana bagcina babuya bazisole bathome nepilo phasi. Lokho kubangela bona bagcine babenokugandeleleka komkhumbulo.

Lokhu kusifundisa bona nanoma sifuna imali namkha ipumelelo kangangani, sitotose besifike khona. Singarhabi.

</text>
      <sha1>l3jt4if8fszxkbv40znymp3wmsayi9u</sha1>
    </revision>
    <revision>
      <id>1394</id>
      <parentid>1393</parentid>
      <timestamp>2024-03-09T08:25:42Z</timestamp>
      <contributor>
        <username>incubator&gt;LindiweSiba</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1394</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="571" sha1="8uqqgplrkc4ef0c4zdy3e3j58ho2z4t" xml:space="preserve">[[Isimumathi:Herbs for Traditional Healing.jpg|thumb|Ukuthwala]]
Ukuthwala sele kurhagele khulu enarheni yeSewula Afrika. Inengi labantu lifuna ukuphumelela msinyana. Njenga nje, basebenzisa iinlwana ezifana neenyoka, iimfene, iinkukhu nezinye ukuthola ipumelelo abayifunako. Kuthoma kubasebenzela kuhle babe zigwili. Kodwana, akupheli kuhle, ngombana bagcina babuya bazisole bathome nepilo phasi. Lokho kubangela bona bagcine babenokugandeleleka komkhumbulo.

Lokhu kusifundisa bona nanoma sifuna imali namkha ipumelelo kangangani, sitotose besifike khona. Singarhabi.

</text>
      <sha1>8uqqgplrkc4ef0c4zdy3e3j58ho2z4t</sha1>
    </revision>
    <revision>
      <id>1395</id>
      <parentid>1394</parentid>
      <timestamp>2024-10-14T13:47:40Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>1394</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="571" sha1="8uqqgplrkc4ef0c4zdy3e3j58ho2z4t" xml:space="preserve">[[Isimumathi:Herbs for Traditional Healing.jpg|thumb|Ukuthwala]]
Ukuthwala sele kurhagele khulu enarheni yeSewula Afrika. Inengi labantu lifuna ukuphumelela msinyana. Njenga nje, basebenzisa iinlwana ezifana neenyoka, iimfene, iinkukhu nezinye ukuthola ipumelelo abayifunako. Kuthoma kubasebenzela kuhle babe zigwili. Kodwana, akupheli kuhle, ngombana bagcina babuya bazisole bathome nepilo phasi. Lokho kubangela bona bagcine babenokugandeleleka komkhumbulo.

Lokhu kusifundisa bona nanoma sifuna imali namkha ipumelelo kangangani, sitotose besifike khona. Singarhabi.

</text>
      <sha1>8uqqgplrkc4ef0c4zdy3e3j58ho2z4t</sha1>
    </revision>
  </page>
  <page>
    <title>Ukutlhogeka kwemisebenzi</title>
    <ns>0</ns>
    <id>260</id>
    <revision>
      <id>1396</id>
      <timestamp>2024-06-27T12:24:19Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''UKutlhogeka kwemisebenzi''' kuyinto ayande khulu esitjhabeni seSewula AFrika.  &quot;</comment>
      <origin>1396</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="82" sha1="qragaewil8poavre3v3b4r1ocrjva4b" xml:space="preserve">'''UKutlhogeka kwemisebenzi''' kuyinto ayande khulu esitjhabeni seSewula AFrika.

</text>
      <sha1>qragaewil8poavre3v3b4r1ocrjva4b</sha1>
    </revision>
    <revision>
      <id>1397</id>
      <parentid>1396</parentid>
      <timestamp>2024-06-27T13:47:52Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1397</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="632" sha1="157ksapnc08kklcurt5etzhyjrk74aw" xml:space="preserve">'''Ukutlhogeka kwemisebenzi''' kuyinto ayande khulu esitjhabeni seSewula AFrika. Abantu abatjha lokha nasele bacede ukufunda bathola ubudisi bokufuna umsebenzi ngesibanga sokobana amathumba womsebenzi awekho begodu abanye abantu bayiyithengisa imisebenzi. 

Ngendlela amathuba womsebenzi anciphe ngakhona uthola bona lokha nakukhutjhwa iphepha kuveze umsebenzi kuthiwa kufuneka abantu abangaphezu kweminyaka engi-18 kodwana abangakadluli ku 35. Umbuzo uthi laba abangaphezu kwe 35 bona abakafaneli ukusebenza na? 

Ukuncipha kwamathuba womsebenzi kwandisa izinga lobugebengu ngombana abantu bafunda neendlela ezimbi zokuziphilisa.

</text>
      <sha1>157ksapnc08kklcurt5etzhyjrk74aw</sha1>
    </revision>
    <revision>
      <id>1398</id>
      <parentid>1397</parentid>
      <timestamp>2024-10-14T13:47:40Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>1397</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="632" sha1="157ksapnc08kklcurt5etzhyjrk74aw" xml:space="preserve">'''Ukutlhogeka kwemisebenzi''' kuyinto ayande khulu esitjhabeni seSewula AFrika. Abantu abatjha lokha nasele bacede ukufunda bathola ubudisi bokufuna umsebenzi ngesibanga sokobana amathumba womsebenzi awekho begodu abanye abantu bayiyithengisa imisebenzi. 

Ngendlela amathuba womsebenzi anciphe ngakhona uthola bona lokha nakukhutjhwa iphepha kuveze umsebenzi kuthiwa kufuneka abantu abangaphezu kweminyaka engi-18 kodwana abangakadluli ku 35. Umbuzo uthi laba abangaphezu kwe 35 bona abakafaneli ukusebenza na? 

Ukuncipha kwamathuba womsebenzi kwandisa izinga lobugebengu ngombana abantu bafunda neendlela ezimbi zokuziphilisa.

</text>
      <sha1>157ksapnc08kklcurt5etzhyjrk74aw</sha1>
    </revision>
    <revision>
      <id>2506</id>
      <parentid>1398</parentid>
      <timestamp>2025-03-06T16:13:53Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2506</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="689" sha1="8mgq8nqovm07akdd55fy8nqba7995w9" xml:space="preserve">'''Ukutlhogeka kwemisebenzi''' kuyinto eyande khulu esitjhabeni seSewula AFrika. Abantu abatjha lokha nasele bacede ukufunda bathola ubudisi bokuthola umsebenzi ngesibanga sokobana amathuba womsebenzi awekho begodu abanye abantu bayiyithengisa imisebenzi. 

Ngendlela amathuba womsebenzi anciphe ngakhona uthola bona lokha nakukhutjhwa iphepha kuveze umsebenzi kuthiwa kufuneka abantu abangaphezu kweminyaka engi-18 kodwana abangakadluli ku 35. Umbuzo uthi laba abangaphezu kwe 35 bona abakafaneli ukusebenza na? 

Ukuncipha kwamathuba womsebenzi kwandisa izinga lobugebengu ngombana abantu bafunda neendlela ezimbi zokuziphilisa ngombana umuntu angenza nanoma yini ukuthi azithole adlile.</text>
      <sha1>8mgq8nqovm07akdd55fy8nqba7995w9</sha1>
    </revision>
  </page>
  <page>
    <title>Ukuzibandakanya kwababelethi eemfundweni zabantwana babo</title>
    <ns>0</ns>
    <id>261</id>
    <revision>
      <id>1399</id>
      <timestamp>2024-06-30T16:52:00Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''UKuzibandakanya''' kwababelethi eemfundweni zabantwana kulokha ababelthi bazadlala iindima ekutheni abantwana babo bathole ifundo ehle nephambili.  &quot;</comment>
      <origin>1399</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="151" sha1="j8o7o59dgoiknjc9uc8m7d2w3zmgn6w" xml:space="preserve">'''UKuzibandakanya''' kwababelethi eemfundweni zabantwana kulokha ababelthi bazadlala iindima ekutheni abantwana babo bathole ifundo ehle nephambili.

</text>
      <sha1>j8o7o59dgoiknjc9uc8m7d2w3zmgn6w</sha1>
    </revision>
    <revision>
      <id>1400</id>
      <parentid>1399</parentid>
      <timestamp>2024-06-30T18:54:03Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1400</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="711" sha1="czb1uh4qyu31u0zobnclvhxbttxx6tl" xml:space="preserve">'''UKuzibandakanya''' kwababelethi eemfundweni zabantwana kulokha ababelethi badlala iindima ekutheni abantwana babo bathole ifundo ehle nephambili. Ababelethi badlala indima ngokuthi basebenzisane nabo titjhere ukusiza umntwana athabele ukuba mfundi.

Lokhu kuqakathekile khulu ukuthi ababelethi bandakany eemfundweni zabantwana babo,  ngombana lokhu kukuthaza abantwana bonyana bafunde ngamandla ukuze bathole imiphumela encono.

Lokhu kwenza bona umntwana athole loke isekelo alidingako ukuze akwazi ukuthola ifundo encono nephambili. Abanye ababelethi vane benze iphoso yokucabanga bona umntwana ufundiswa ngutitjhere kwaphela. Lokhu akusilo iqiniso ngombana utitjhere wokuthoma womntwana mbelethi wakhe. 

</text>
      <sha1>czb1uh4qyu31u0zobnclvhxbttxx6tl</sha1>
    </revision>
    <revision>
      <id>1401</id>
      <parentid>1400</parentid>
      <timestamp>2024-10-14T13:47:40Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>1400</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="711" sha1="czb1uh4qyu31u0zobnclvhxbttxx6tl" xml:space="preserve">'''UKuzibandakanya''' kwababelethi eemfundweni zabantwana kulokha ababelethi badlala iindima ekutheni abantwana babo bathole ifundo ehle nephambili. Ababelethi badlala indima ngokuthi basebenzisane nabo titjhere ukusiza umntwana athabele ukuba mfundi.

Lokhu kuqakathekile khulu ukuthi ababelethi bandakany eemfundweni zabantwana babo,  ngombana lokhu kukuthaza abantwana bonyana bafunde ngamandla ukuze bathole imiphumela encono.

Lokhu kwenza bona umntwana athole loke isekelo alidingako ukuze akwazi ukuthola ifundo encono nephambili. Abanye ababelethi vane benze iphoso yokucabanga bona umntwana ufundiswa ngutitjhere kwaphela. Lokhu akusilo iqiniso ngombana utitjhere wokuthoma womntwana mbelethi wakhe. 

</text>
      <sha1>czb1uh4qyu31u0zobnclvhxbttxx6tl</sha1>
    </revision>
  </page>
  <page>
    <title>Ukuzikhunga</title>
    <ns>0</ns>
    <id>262</id>
    <revision>
      <id>1402</id>
      <timestamp>2024-08-06T17:42:41Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Ukuzikhunga''' kukulokha umuntu athatha ipilo yakhe ngokuzibulala. Lokho umuntu angakwenza ngokuthi asele amapilisi amanengi, athathe intambo azibulale begodu nangezinye iindlela. eskhathini  sanje ukuzikhunga sele kuyinto ekhamba phambili eyenza bona abantu bahlongakale. Abanye babo nabatholwa kusese nesikhathi bayasinda.  &quot;</comment>
      <origin>1402</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="329" sha1="4zgcxa0xsm510h8vkvdan07mo0n52cx" xml:space="preserve">'''Ukuzikhunga''' kukulokha umuntu athatha ipilo yakhe ngokuzibulala. Lokho umuntu angakwenza ngokuthi asele amapilisi amanengi, athathe intambo azibulale begodu nangezinye iindlela. eskhathini  sanje ukuzikhunga sele kuyinto ekhamba phambili eyenza bona abantu bahlongakale. Abanye babo nabatholwa kusese nesikhathi bayasinda.

</text>
      <sha1>4zgcxa0xsm510h8vkvdan07mo0n52cx</sha1>
    </revision>
    <revision>
      <id>1403</id>
      <parentid>1402</parentid>
      <timestamp>2024-08-06T18:00:53Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1403</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1315" sha1="rq73yhl5fu0snnp6pi9652g5d6wf5il" xml:space="preserve">'''Ukuzikhunga''' kukulokha umuntu athatha ipilo yakhe ngokuzibulala. Lokho umuntu angakwenza ngokuthi asele amapilisi amanengi, athathe intambo azibulale begodu nangezinye iindlela. eskhathini  sanje ukuzikhunga sele kuyinto ekhamba phambili eyenza bona abantu bahlongakale. Abanye babo nabatholwa kusese nesikhathi bayasinda.

== izinto ezingabangela bona umuntu azikhunge ==

=== Ukuhlukunyezwa ===
Umuntu lokha nakahlukunyezwako begodu angatholi isekelo nanyana isizo abantwini angagcian sele abona bonyana kungcono azikhunge kunokobana aphile budisi ngokuhlukunyezwa.

=== Ukugandeleleka ngokomkhumbulo ===
Ukugandeleleka ngokomkhumbulo kuyamenza umuntu bona azikhunge  ngombana umuntu osesimeni lesi ingcondo yakhe iyaphazamiseka begodu babasengcopheni yokuthi bangenza izinto ezibeka amaphilo wabo engozini njengozibulala.

=== Ukusogola ngemali ===
Ukusogola ngemali ngendlela yokuthi umuntu agcine sele angasakghona ukuthola ukudla umuntu angagcian sele azizwa bona kungcona ukuzikhunga kunokuphila bese afikelwe mcabango wokuzikhunga.

== Amatshwayo womuntu ongaba sengozini yokuzikhunga ==
Umuntu ongaba sengozini yokufuna ukuzikhuunga ubonakala ngokuthi azikhiphe ebantwini agcine selel ahlala yedwa. Omunye ugcina umbona ngokuthi asebenzise iindakamizwa ngendlela eyeqileko lokha nakunento emhluphako.
</text>
      <sha1>rq73yhl5fu0snnp6pi9652g5d6wf5il</sha1>
    </revision>
    <revision>
      <id>1404</id>
      <parentid>1403</parentid>
      <timestamp>2024-08-06T18:06:28Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1404</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1634" sha1="g70ucorx7f0nwhvdrjlst82o4zp1lrv" xml:space="preserve">'''Ukuzikhunga''' kukulokha umuntu athatha ipilo yakhe ngokuzibulala&lt;ref&gt;Turecki, G. and Brent, D.A., 2016. Suicide and suicidal behaviour. ''The Lancet'', ''387''(10024), pp.1227-1239.&lt;/ref&gt;. Lokho umuntu angakwenza ngokuthi asele amapilisi amanengi, athathe intambo azibulale begodu nangezinye iindlela. eskhathini  sanje ukuzikhunga sele kuyinto ekhamba phambili eyenza bona abantu bahlongakale. Abanye babo nabatholwa kusese nesikhathi bayasinda.

== izinto ezingabangela bona umuntu azikhunge ==

=== Ukuhlukunyezwa ===
Umuntu lokha nakahlukunyezwako begodu angatholi isekelo nanyana isizo abantwini angagcian sele abona bonyana kungcono azikhunge kunokobana aphile budisi ngokuhlukunyezwa&lt;ref&gt;Turecki, G., Brent, D.A., Gunnell, D., O’Connor, R.C., Oquendo, M.A., Pirkis, J. and Stanley, B.H., 2019. Suicide and suicide risk. ''Nature reviews Disease primers'', ''5''(1), p.74.&lt;/ref&gt;.

=== Ukugandeleleka ngokomkhumbulo ===
Ukugandeleleka ngokomkhumbulo kuyamenza umuntu bona azikhunge  ngombana umuntu osesimeni lesi ingcondo yakhe iyaphazamiseka begodu babasengcopheni yokuthi bangenza izinto ezibeka amaphilo wabo engozini njengozibulala.

=== Ukusogola ngemali ===
Ukusogola ngemali ngendlela yokuthi umuntu agcine sele angasakghona ukuthola ukudla umuntu angagcian sele azizwa bona kungcona ukuzikhunga kunokuphila bese afikelwe mcabango wokuzikhunga.

== Amatshwayo womuntu ongaba sengozini yokuzikhunga ==
Umuntu ongaba sengozini yokufuna ukuzikhuunga ubonakala ngokuthi azikhiphe ebantwini agcine selel ahlala yedwa. Omunye ugcina umbona ngokuthi asebenzise iindakamizwa ngendlela eyeqileko lokha nakunento emhluphako.
</text>
      <sha1>g70ucorx7f0nwhvdrjlst82o4zp1lrv</sha1>
    </revision>
    <revision>
      <id>1405</id>
      <parentid>1404</parentid>
      <timestamp>2024-08-07T17:41:11Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1405</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1976" sha1="3bjo2yhyja5woq7qcohup7vbqpptcad" xml:space="preserve">'''Ukuzikhunga''' kukulokha umuntu athatha ipilo yakhe ngokuzibulala&lt;ref&gt;Turecki, G. and Brent, D.A., 2016. Suicide and suicidal behaviour. ''The Lancet'', ''387''(10024), pp.1227-1239.&lt;/ref&gt;. Lokho umuntu angakwenza ngokuthi asele amapilisi amanengi, athathe intambo azibulale begodu nangezinye iindlela. eskhathini  sanje ukuzikhunga sele kuyinto ekhamba phambili eyenza bona abantu bahlongakale. Abanye babo nabatholwa kusese nesikhathi bayasinda. Ukuzikhunga kuyinto engahlukumeza umndeni nabantu abatjgidelelne naloyo ozikhungileko ngombana bangaba nemizwa yokuthi bahlulekile ukumsiza umuntu ozikhungileko, begodu bezwe nobuhlungi bokulahlekelwa mumuntu abatjhidelelne naye. Omuntu obe netjhudu wasinda lokha nagade azama ukuzikhunga naye uba nobudisi bokuthi aphilisane nabanye abantu.

== izinto ezingabangela bona umuntu azikhunge ==

=== Ukuhlukunyezwa ===
Umuntu lokha nakahlukunyezwako begodu angatholi isekelo nanyana isizo abantwini angagcian sele abona bonyana kungcono azikhunge kunokobana aphile budisi ngokuhlukunyezwa&lt;ref&gt;Turecki, G., Brent, D.A., Gunnell, D., O’Connor, R.C., Oquendo, M.A., Pirkis, J. and Stanley, B.H., 2019. Suicide and suicide risk. ''Nature reviews Disease primers'', ''5''(1), p.74.&lt;/ref&gt;.

=== Ukugandeleleka ngokomkhumbulo ===
Ukugandeleleka ngokomkhumbulo kuyamenza umuntu bona azikhunge  ngombana umuntu osesimeni lesi ingcondo yakhe iyaphazamiseka begodu babasengcopheni yokuthi bangenza izinto ezibeka amaphilo wabo engozini njengozibulala.

=== Ukusogola ngemali ===
Ukusogola ngemali ngendlela yokuthi umuntu agcine sele angasakghona ukuthola ukudla umuntu angagcian sele azizwa bona kungcona ukuzikhunga kunokuphila bese afikelwe mcabango wokuzikhunga.

== Amatshwayo womuntu ongaba sengozini yokuzikhunga ==
Umuntu ongaba sengozini yokufuna ukuzikhuunga ubonakala ngokuthi azikhiphe ebantwini agcine selel ahlala yedwa. Omunye ugcina umbona ngokuthi asebenzise iindakamizwa ngendlela eyeqileko lokha nakunento emhluphako.
</text>
      <sha1>3bjo2yhyja5woq7qcohup7vbqpptcad</sha1>
    </revision>
    <revision>
      <id>1406</id>
      <parentid>1405</parentid>
      <timestamp>2024-08-07T17:47:59Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1406</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2235" sha1="941j9hzblxy99wkxha4dyeriyo6fc28" xml:space="preserve">'''Ukuzikhunga''' kukulokha umuntu athatha ipilo yakhe ngokuzibulala&lt;ref&gt;Turecki, G. and Brent, D.A., 2016. Suicide and suicidal behaviour. ''The Lancet'', ''387''(10024), pp.1227-1239.&lt;/ref&gt;. Lokho umuntu angakwenza ngokuthi asele amapilisi amanengi, athathe intambo azibulale begodu nangezinye iindlela. eskhathini  sanje ukuzikhunga sele kuyinto ekhamba phambili eyenza bona abantu bahlongakale. Abanye babo nabatholwa kusese nesikhathi bayasinda. Ukuzikhunga kuyinto engahlukumeza umndeni nabantu abatjgidelelne naloyo ozikhungileko ngombana bangaba nemizwa yokuthi bahlulekile ukumsiza umuntu ozikhungileko, begodu bezwe nobuhlungi bokulahlekelwa mumuntu abatjhidelelne naye. Omuntu obe netjhudu wasinda lokha nagade azama ukuzikhunga naye uba nobudisi bokuthi aphilisane nabanye abantu.

== izinto ezingabangela bona umuntu azikhunge ==

=== Ukuhlukunyezwa ===
Umuntu lokha nakahlukunyezwako begodu angatholi isekelo nanyana isizo abantwini angagcian sele abona bonyana kungcono azikhunge kunokobana aphile budisi ngokuhlukunyezwa&lt;ref&gt;Turecki, G., Brent, D.A., Gunnell, D., O’Connor, R.C., Oquendo, M.A., Pirkis, J. and Stanley, B.H., 2019. Suicide and suicide risk. ''Nature reviews Disease primers'', ''5''(1), p.74.&lt;/ref&gt;.

=== Ukugandeleleka ngokomkhumbulo ===
Ukugandeleleka ngokomkhumbulo kuyamenza umuntu bona azikhunge  ngombana umuntu osesimeni lesi ingcondo yakhe iyaphazamiseka begodu babasengcopheni yokuthi bangenza izinto ezibeka amaphilo wabo engozini njengozibulala. Jeon (2011) Uveza bonyana inengi labantu abazikhungileko litholakala bona belinokugandeleleka komkhumbulo lokha nakuhlowa iindumbu zabo&lt;ref&gt;Jeon, H.J., 2011. Depression and suicide. ''Journal of the Korean Medical Association'', ''54''(4), pp.370-375.&lt;/ref&gt;.

=== Ukusogola ngemali ===
Ukusogola ngemali ngendlela yokuthi umuntu agcine sele angasakghona ukuthola ukudla umuntu angagcian sele azizwa bona kungcona ukuzikhunga kunokuphila bese afikelwe mcabango wokuzikhunga.

== Amatshwayo womuntu ongaba sengozini yokuzikhunga ==
Umuntu ongaba sengozini yokufuna ukuzikhuunga ubonakala ngokuthi azikhiphe ebantwini agcine selel ahlala yedwa. Omunye ugcina umbona ngokuthi asebenzise iindakamizwa ngendlela eyeqileko lokha nakunento emhluphako.
</text>
      <sha1>941j9hzblxy99wkxha4dyeriyo6fc28</sha1>
    </revision>
    <revision>
      <id>1407</id>
      <parentid>1406</parentid>
      <timestamp>2024-08-07T18:04:41Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1407</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2237" sha1="1jqmurjffmqfsnxdsuw2w8dir891os3" xml:space="preserve">'''Ukuzikhunga''' kukulokha umuntu athatha ipilo yakhe ngokuzibulala&lt;ref&gt;Turecki, G. and Brent, D.A., 2016. Suicide and suicidal behaviour. ''The Lancet'', ''387''(10024), pp.1227-1239.&lt;/ref&gt;. Lokho umuntu angakwenza ngokuthi asele [[amapilisi]] amanengi, athathe intambo azibulale begodu nangezinye iindlela. eskhathini  sanje ukuzikhunga sele kuyinto ekhamba phambili eyenza bona abantu bahlongakale. Abanye babo nabatholwa kusese nesikhathi bayasinda. Ukuzikhunga kuyinto engahlukumeza umndeni nabantu abatjgidelelne naloyo ozikhungileko ngombana bangaba nemizwa yokuthi bahlulekile ukumsiza umuntu ozikhungileko, begodu bezwe nobuhlungi bokulahlekelwa mumuntu abatjhidelelne naye. Omuntu obe netjhudu wasinda lokha nagade azama ukuzikhunga naye uba nobudisi bokuthi aphilisane nabanye abantu.

== izinto ezingabangela bona umuntu azikhunge ==

=== Ukuhlukunyezwa ===
Umuntu lokha nakahlukunyezwako begodu angatholi isekelo nanyana isizo abantwini angagcian sele abona bonyana kungcono azikhunge kunokobana aphile budisi ngokuhlukunyezwa&lt;ref&gt;Turecki, G., Brent, D.A., Gunnell, D., O’Connor, R.C., Oquendo, M.A., Pirkis, J. and Stanley, B.H., 2019. Suicide and suicide risk. ''Nature reviews Disease primers'', ''5''(1), p.74.&lt;/ref&gt;.

=== Ukugandeleleka komkhumbulo ===
[[Ukugandeleleka komkhumbulo]] kuyamenza umuntu bona azikhunge  ngombana umuntu osesimeni lesi ingcondo yakhe iyaphazamiseka begodu babasengcopheni yokuthi bangenza izinto ezibeka amaphilo wabo engozini njengozibulala. Jeon (2011) Uveza bonyana inengi labantu abazikhungileko litholakala bona belinokugandeleleka komkhumbulo lokha nakuhlowa iindumbu zabo&lt;ref&gt;Jeon, H.J., 2011. Depression and suicide. ''Journal of the Korean Medical Association'', ''54''(4), pp.370-375.&lt;/ref&gt;.

=== Ukusogola ngemali ===
Ukusogola ngemali ngendlela yokuthi umuntu agcine sele angasakghona ukuthola ukudla umuntu angagcian sele azizwa bona kungcona ukuzikhunga kunokuphila bese afikelwe mcabango wokuzikhunga.

== Amatshwayo womuntu ongaba sengozini yokuzikhunga ==
Umuntu ongaba sengozini yokufuna ukuzikhuunga ubonakala ngokuthi azikhiphe ebantwini agcine selel ahlala yedwa. Omunye ugcina umbona ngokuthi asebenzise iindakamizwa ngendlela eyeqileko lokha nakunento emhluphako.
</text>
      <sha1>1jqmurjffmqfsnxdsuw2w8dir891os3</sha1>
    </revision>
    <revision>
      <id>1408</id>
      <parentid>1407</parentid>
      <timestamp>2024-10-14T13:47:40Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>6 revisions imported</comment>
      <origin>1407</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2237" sha1="1jqmurjffmqfsnxdsuw2w8dir891os3" xml:space="preserve">'''Ukuzikhunga''' kukulokha umuntu athatha ipilo yakhe ngokuzibulala&lt;ref&gt;Turecki, G. and Brent, D.A., 2016. Suicide and suicidal behaviour. ''The Lancet'', ''387''(10024), pp.1227-1239.&lt;/ref&gt;. Lokho umuntu angakwenza ngokuthi asele [[amapilisi]] amanengi, athathe intambo azibulale begodu nangezinye iindlela. eskhathini  sanje ukuzikhunga sele kuyinto ekhamba phambili eyenza bona abantu bahlongakale. Abanye babo nabatholwa kusese nesikhathi bayasinda. Ukuzikhunga kuyinto engahlukumeza umndeni nabantu abatjgidelelne naloyo ozikhungileko ngombana bangaba nemizwa yokuthi bahlulekile ukumsiza umuntu ozikhungileko, begodu bezwe nobuhlungi bokulahlekelwa mumuntu abatjhidelelne naye. Omuntu obe netjhudu wasinda lokha nagade azama ukuzikhunga naye uba nobudisi bokuthi aphilisane nabanye abantu.

== izinto ezingabangela bona umuntu azikhunge ==

=== Ukuhlukunyezwa ===
Umuntu lokha nakahlukunyezwako begodu angatholi isekelo nanyana isizo abantwini angagcian sele abona bonyana kungcono azikhunge kunokobana aphile budisi ngokuhlukunyezwa&lt;ref&gt;Turecki, G., Brent, D.A., Gunnell, D., O’Connor, R.C., Oquendo, M.A., Pirkis, J. and Stanley, B.H., 2019. Suicide and suicide risk. ''Nature reviews Disease primers'', ''5''(1), p.74.&lt;/ref&gt;.

=== Ukugandeleleka komkhumbulo ===
[[Ukugandeleleka komkhumbulo]] kuyamenza umuntu bona azikhunge  ngombana umuntu osesimeni lesi ingcondo yakhe iyaphazamiseka begodu babasengcopheni yokuthi bangenza izinto ezibeka amaphilo wabo engozini njengozibulala. Jeon (2011) Uveza bonyana inengi labantu abazikhungileko litholakala bona belinokugandeleleka komkhumbulo lokha nakuhlowa iindumbu zabo&lt;ref&gt;Jeon, H.J., 2011. Depression and suicide. ''Journal of the Korean Medical Association'', ''54''(4), pp.370-375.&lt;/ref&gt;.

=== Ukusogola ngemali ===
Ukusogola ngemali ngendlela yokuthi umuntu agcine sele angasakghona ukuthola ukudla umuntu angagcian sele azizwa bona kungcona ukuzikhunga kunokuphila bese afikelwe mcabango wokuzikhunga.

== Amatshwayo womuntu ongaba sengozini yokuzikhunga ==
Umuntu ongaba sengozini yokufuna ukuzikhuunga ubonakala ngokuthi azikhiphe ebantwini agcine selel ahlala yedwa. Omunye ugcina umbona ngokuthi asebenzise iindakamizwa ngendlela eyeqileko lokha nakunento emhluphako.
</text>
      <sha1>1jqmurjffmqfsnxdsuw2w8dir891os3</sha1>
    </revision>
    <revision>
      <id>2167</id>
      <parentid>1408</parentid>
      <timestamp>2024-11-27T06:19:07Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>+ Iinkomba</comment>
      <origin>2167</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2263" sha1="ohykj9v9pe1p5lezfifug1g6eipro24" xml:space="preserve">'''Ukuzikhunga''' kukulokha umuntu athatha ipilo yakhe ngokuzibulala&lt;ref&gt;Turecki, G. and Brent, D.A., 2016. Suicide and suicidal behaviour. ''The Lancet'', ''387''(10024), pp.1227-1239.&lt;/ref&gt;. Lokho umuntu angakwenza ngokuthi asele [[amapilisi]] amanengi, athathe intambo azibulale begodu nangezinye iindlela. eskhathini  sanje ukuzikhunga sele kuyinto ekhamba phambili eyenza bona abantu bahlongakale. Abanye babo nabatholwa kusese nesikhathi bayasinda. Ukuzikhunga kuyinto engahlukumeza umndeni nabantu abatjgidelelne naloyo ozikhungileko ngombana bangaba nemizwa yokuthi bahlulekile ukumsiza umuntu ozikhungileko, begodu bezwe nobuhlungi bokulahlekelwa mumuntu abatjhidelelne naye. Omuntu obe netjhudu wasinda lokha nagade azama ukuzikhunga naye uba nobudisi bokuthi aphilisane nabanye abantu.

== izinto ezingabangela bona umuntu azikhunge ==
=== Ukuhlukunyezwa ===
Umuntu lokha nakahlukunyezwako begodu angatholi isekelo nanyana isizo abantwini angagcian sele abona bonyana kungcono azikhunge kunokobana aphile budisi ngokuhlukunyezwa&lt;ref&gt;Turecki, G., Brent, D.A., Gunnell, D., O’Connor, R.C., Oquendo, M.A., Pirkis, J. and Stanley, B.H., 2019. Suicide and suicide risk. ''Nature reviews Disease primers'', ''5''(1), p.74.&lt;/ref&gt;.

=== Ukugandeleleka komkhumbulo ===
[[Ukugandeleleka komkhumbulo]] kuyamenza umuntu bona azikhunge  ngombana umuntu osesimeni lesi ingcondo yakhe iyaphazamiseka begodu babasengcopheni yokuthi bangenza izinto ezibeka amaphilo wabo engozini njengozibulala. Jeon (2011) Uveza bonyana inengi labantu abazikhungileko litholakala bona belinokugandeleleka komkhumbulo lokha nakuhlowa iindumbu zabo&lt;ref&gt;Jeon, H.J., 2011. Depression and suicide. ''Journal of the Korean Medical Association'', ''54''(4), pp.370-375.&lt;/ref&gt;.

=== Ukusogola ngemali ===
Ukusogola ngemali ngendlela yokuthi umuntu agcine sele angasakghona ukuthola ukudla umuntu angagcian sele azizwa bona kungcona ukuzikhunga kunokuphila bese afikelwe mcabango wokuzikhunga.

== Amatshwayo womuntu ongaba sengozini yokuzikhunga ==
Umuntu ongaba sengozini yokufuna ukuzikhuunga ubonakala ngokuthi azikhiphe ebantwini agcine selel ahlala yedwa. Omunye ugcina umbona ngokuthi asebenzise iindakamizwa ngendlela eyeqileko lokha nakunento emhluphako.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>ohykj9v9pe1p5lezfifug1g6eipro24</sha1>
    </revision>
    <revision>
      <id>3013</id>
      <parentid>2167</parentid>
      <timestamp>2025-06-06T20:26:43Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>This page is sponsored by Raid: Shadow Legends, the sponsor of today's page.</comment>
      <origin>3013</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2344" sha1="11d12jqgwvejxk3n1pa55ibwekl6rd0" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. Ukuzikhunga''' kukulokha umuntu athatha ipilo yakhe ngokuzibulala&lt;ref&gt;Turecki, G. and Brent, D.A., 2016. Suicide and suicidal behaviour. ''The Lancet'', ''387''(10024), pp.1227-1239.&lt;/ref&gt;. Lokho umuntu angakwenza ngokuthi asele [[amapilisi]] amanengi, athathe intambo azibulale begodu nangezinye iindlela. eskhathini  sanje ukuzikhunga sele kuyinto ekhamba phambili eyenza bona abantu bahlongakale. Abanye babo nabatholwa kusese nesikhathi bayasinda. Ukuzikhunga kuyinto engahlukumeza umndeni nabantu abatjgidelelne naloyo ozikhungileko ngombana bangaba nemizwa yokuthi bahlulekile ukumsiza umuntu ozikhungileko, begodu bezwe nobuhlungi bokulahlekelwa mumuntu abatjhidelelne naye. Omuntu obe netjhudu wasinda lokha nagade azama ukuzikhunga naye uba nobudisi bokuthi aphilisane nabanye abantu.

== izinto ezingabangela bona umuntu azikhunge ==
=== Ukuhlukunyezwa ===
Umuntu lokha nakahlukunyezwako begodu angatholi isekelo nanyana isizo abantwini angagcian sele abona bonyana kungcono azikhunge kunokobana aphile budisi ngokuhlukunyezwa&lt;ref&gt;Turecki, G., Brent, D.A., Gunnell, D., O’Connor, R.C., Oquendo, M.A., Pirkis, J. and Stanley, B.H., 2019. Suicide and suicide risk. ''Nature reviews Disease primers'', ''5''(1), p.74.&lt;/ref&gt;.

=== Ukugandeleleka komkhumbulo ===
[[Ukugandeleleka komkhumbulo]] kuyamenza umuntu bona azikhunge  ngombana umuntu osesimeni lesi ingcondo yakhe iyaphazamiseka begodu babasengcopheni yokuthi bangenza izinto ezibeka amaphilo wabo engozini njengozibulala. Jeon (2011) Uveza bonyana inengi labantu abazikhungileko litholakala bona belinokugandeleleka komkhumbulo lokha nakuhlowa iindumbu zabo&lt;ref&gt;Jeon, H.J., 2011. Depression and suicide. ''Journal of the Korean Medical Association'', ''54''(4), pp.370-375.&lt;/ref&gt;.

=== Ukusogola ngemali ===
Ukusogola ngemali ngendlela yokuthi umuntu agcine sele angasakghona ukuthola ukudla umuntu angagcian sele azizwa bona kungcona ukuzikhunga kunokuphila bese afikelwe mcabango wokuzikhunga.

== Amatshwayo womuntu ongaba sengozini yokuzikhunga ==
Umuntu ongaba sengozini yokufuna ukuzikhuunga ubonakala ngokuthi azikhiphe ebantwini agcine selel ahlala yedwa. Omunye ugcina umbona ngokuthi asebenzise iindakamizwa ngendlela eyeqileko lokha nakunento emhluphako.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>11d12jqgwvejxk3n1pa55ibwekl6rd0</sha1>
    </revision>
    <revision>
      <id>3059</id>
      <parentid>3013</parentid>
      <timestamp>2025-06-07T03:05:22Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Simakahle Moselekatse|Simakahle Moselekatse]]</comment>
      <origin>2167</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2263" sha1="ohykj9v9pe1p5lezfifug1g6eipro24" xml:space="preserve">'''Ukuzikhunga''' kukulokha umuntu athatha ipilo yakhe ngokuzibulala&lt;ref&gt;Turecki, G. and Brent, D.A., 2016. Suicide and suicidal behaviour. ''The Lancet'', ''387''(10024), pp.1227-1239.&lt;/ref&gt;. Lokho umuntu angakwenza ngokuthi asele [[amapilisi]] amanengi, athathe intambo azibulale begodu nangezinye iindlela. eskhathini  sanje ukuzikhunga sele kuyinto ekhamba phambili eyenza bona abantu bahlongakale. Abanye babo nabatholwa kusese nesikhathi bayasinda. Ukuzikhunga kuyinto engahlukumeza umndeni nabantu abatjgidelelne naloyo ozikhungileko ngombana bangaba nemizwa yokuthi bahlulekile ukumsiza umuntu ozikhungileko, begodu bezwe nobuhlungi bokulahlekelwa mumuntu abatjhidelelne naye. Omuntu obe netjhudu wasinda lokha nagade azama ukuzikhunga naye uba nobudisi bokuthi aphilisane nabanye abantu.

== izinto ezingabangela bona umuntu azikhunge ==
=== Ukuhlukunyezwa ===
Umuntu lokha nakahlukunyezwako begodu angatholi isekelo nanyana isizo abantwini angagcian sele abona bonyana kungcono azikhunge kunokobana aphile budisi ngokuhlukunyezwa&lt;ref&gt;Turecki, G., Brent, D.A., Gunnell, D., O’Connor, R.C., Oquendo, M.A., Pirkis, J. and Stanley, B.H., 2019. Suicide and suicide risk. ''Nature reviews Disease primers'', ''5''(1), p.74.&lt;/ref&gt;.

=== Ukugandeleleka komkhumbulo ===
[[Ukugandeleleka komkhumbulo]] kuyamenza umuntu bona azikhunge  ngombana umuntu osesimeni lesi ingcondo yakhe iyaphazamiseka begodu babasengcopheni yokuthi bangenza izinto ezibeka amaphilo wabo engozini njengozibulala. Jeon (2011) Uveza bonyana inengi labantu abazikhungileko litholakala bona belinokugandeleleka komkhumbulo lokha nakuhlowa iindumbu zabo&lt;ref&gt;Jeon, H.J., 2011. Depression and suicide. ''Journal of the Korean Medical Association'', ''54''(4), pp.370-375.&lt;/ref&gt;.

=== Ukusogola ngemali ===
Ukusogola ngemali ngendlela yokuthi umuntu agcine sele angasakghona ukuthola ukudla umuntu angagcian sele azizwa bona kungcona ukuzikhunga kunokuphila bese afikelwe mcabango wokuzikhunga.

== Amatshwayo womuntu ongaba sengozini yokuzikhunga ==
Umuntu ongaba sengozini yokufuna ukuzikhuunga ubonakala ngokuthi azikhiphe ebantwini agcine selel ahlala yedwa. Omunye ugcina umbona ngokuthi asebenzise iindakamizwa ngendlela eyeqileko lokha nakunento emhluphako.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>ohykj9v9pe1p5lezfifug1g6eipro24</sha1>
    </revision>
    <revision>
      <id>3163</id>
      <parentid>3059</parentid>
      <timestamp>2025-06-21T18:42:42Z</timestamp>
      <contributor>
        <ip>85.97.84.231</ip>
      </contributor>
      <origin>3163</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2374" sha1="kb9r9hgjk8m7ck92t697y0wd25pa5l4" xml:space="preserve">[[File:Common chimpanzee (Pan troglodytes schweinfurthii) feeding.jpg|thumb|Omar al-Bashir is a chimpanzee.]]

'''Ukuzikhunga''' kukulokha umuntu athatha ipilo yakhe ngokuzibulala&lt;ref&gt;Turecki, G. and Brent, D.A., 2016. Suicide and suicidal behaviour. ''The Lancet'', ''387''(10024), pp.1227-1239.&lt;/ref&gt;. Lokho umuntu angakwenza ngokuthi asele [[amapilisi]] amanengi, athathe intambo azibulale begodu nangezinye iindlela. eskhathini  sanje ukuzikhunga sele kuyinto ekhamba phambili eyenza bona abantu bahlongakale. Abanye babo nabatholwa kusese nesikhathi bayasinda. Ukuzikhunga kuyinto engahlukumeza umndeni nabantu abatjgidelelne naloyo ozikhungileko ngombana bangaba nemizwa yokuthi bahlulekile ukumsiza umuntu ozikhungileko, begodu bezwe nobuhlungi bokulahlekelwa mumuntu abatjhidelelne naye. Omuntu obe netjhudu wasinda lokha nagade azama ukuzikhunga naye uba nobudisi bokuthi aphilisane nabanye abantu.

== izinto ezingabangela bona umuntu azikhunge ==
=== Ukuhlukunyezwa ===
Umuntu lokha nakahlukunyezwako begodu angatholi isekelo nanyana isizo abantwini angagcian sele abona bonyana kungcono azikhunge kunokobana aphile budisi ngokuhlukunyezwa&lt;ref&gt;Turecki, G., Brent, D.A., Gunnell, D., O’Connor, R.C., Oquendo, M.A., Pirkis, J. and Stanley, B.H., 2019. Suicide and suicide risk. ''Nature reviews Disease primers'', ''5''(1), p.74.&lt;/ref&gt;.

=== Ukugandeleleka komkhumbulo ===
[[Ukugandeleleka komkhumbulo]] kuyamenza umuntu bona azikhunge  ngombana umuntu osesimeni lesi ingcondo yakhe iyaphazamiseka begodu babasengcopheni yokuthi bangenza izinto ezibeka amaphilo wabo engozini njengozibulala. Jeon (2011) Uveza bonyana inengi labantu abazikhungileko litholakala bona belinokugandeleleka komkhumbulo lokha nakuhlowa iindumbu zabo&lt;ref&gt;Jeon, H.J., 2011. Depression and suicide. ''Journal of the Korean Medical Association'', ''54''(4), pp.370-375.&lt;/ref&gt;.

=== Ukusogola ngemali ===
Ukusogola ngemali ngendlela yokuthi umuntu agcine sele angasakghona ukuthola ukudla umuntu angagcian sele azizwa bona kungcona ukuzikhunga kunokuphila bese afikelwe mcabango wokuzikhunga.

== Amatshwayo womuntu ongaba sengozini yokuzikhunga ==
Umuntu ongaba sengozini yokufuna ukuzikhuunga ubonakala ngokuthi azikhiphe ebantwini agcine selel ahlala yedwa. Omunye ugcina umbona ngokuthi asebenzise iindakamizwa ngendlela eyeqileko lokha nakunento emhluphako.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>kb9r9hgjk8m7ck92t697y0wd25pa5l4</sha1>
    </revision>
    <revision>
      <id>3286</id>
      <parentid>3163</parentid>
      <timestamp>2025-07-02T20:40:25Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Undo revision [[Special:Diff/3163|3163]] by [[Special:Contributions/85.97.84.231|85.97.84.231]] ([[User talk:85.97.84.231|talk]])</comment>
      <origin>3286</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2263" sha1="ohykj9v9pe1p5lezfifug1g6eipro24" xml:space="preserve">'''Ukuzikhunga''' kukulokha umuntu athatha ipilo yakhe ngokuzibulala&lt;ref&gt;Turecki, G. and Brent, D.A., 2016. Suicide and suicidal behaviour. ''The Lancet'', ''387''(10024), pp.1227-1239.&lt;/ref&gt;. Lokho umuntu angakwenza ngokuthi asele [[amapilisi]] amanengi, athathe intambo azibulale begodu nangezinye iindlela. eskhathini  sanje ukuzikhunga sele kuyinto ekhamba phambili eyenza bona abantu bahlongakale. Abanye babo nabatholwa kusese nesikhathi bayasinda. Ukuzikhunga kuyinto engahlukumeza umndeni nabantu abatjgidelelne naloyo ozikhungileko ngombana bangaba nemizwa yokuthi bahlulekile ukumsiza umuntu ozikhungileko, begodu bezwe nobuhlungi bokulahlekelwa mumuntu abatjhidelelne naye. Omuntu obe netjhudu wasinda lokha nagade azama ukuzikhunga naye uba nobudisi bokuthi aphilisane nabanye abantu.

== izinto ezingabangela bona umuntu azikhunge ==
=== Ukuhlukunyezwa ===
Umuntu lokha nakahlukunyezwako begodu angatholi isekelo nanyana isizo abantwini angagcian sele abona bonyana kungcono azikhunge kunokobana aphile budisi ngokuhlukunyezwa&lt;ref&gt;Turecki, G., Brent, D.A., Gunnell, D., O’Connor, R.C., Oquendo, M.A., Pirkis, J. and Stanley, B.H., 2019. Suicide and suicide risk. ''Nature reviews Disease primers'', ''5''(1), p.74.&lt;/ref&gt;.

=== Ukugandeleleka komkhumbulo ===
[[Ukugandeleleka komkhumbulo]] kuyamenza umuntu bona azikhunge  ngombana umuntu osesimeni lesi ingcondo yakhe iyaphazamiseka begodu babasengcopheni yokuthi bangenza izinto ezibeka amaphilo wabo engozini njengozibulala. Jeon (2011) Uveza bonyana inengi labantu abazikhungileko litholakala bona belinokugandeleleka komkhumbulo lokha nakuhlowa iindumbu zabo&lt;ref&gt;Jeon, H.J., 2011. Depression and suicide. ''Journal of the Korean Medical Association'', ''54''(4), pp.370-375.&lt;/ref&gt;.

=== Ukusogola ngemali ===
Ukusogola ngemali ngendlela yokuthi umuntu agcine sele angasakghona ukuthola ukudla umuntu angagcian sele azizwa bona kungcona ukuzikhunga kunokuphila bese afikelwe mcabango wokuzikhunga.

== Amatshwayo womuntu ongaba sengozini yokuzikhunga ==
Umuntu ongaba sengozini yokufuna ukuzikhuunga ubonakala ngokuthi azikhiphe ebantwini agcine selel ahlala yedwa. Omunye ugcina umbona ngokuthi asebenzise iindakamizwa ngendlela eyeqileko lokha nakunento emhluphako.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>ohykj9v9pe1p5lezfifug1g6eipro24</sha1>
    </revision>
    <revision>
      <id>5218</id>
      <parentid>3286</parentid>
      <timestamp>2025-08-20T12:22:40Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5218</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2262" sha1="r5mfrm0mzev7lt7nd9sgpvfjoq9tim7" xml:space="preserve">'''Ukuzikhunga''' kukulokha umuntu athatha ipilo yakhe ngokuzibulala.&lt;ref&gt;Turecki, G. and Brent, D.A., 2016. Suicide and suicidal behaviour. ''The Lancet'', ''387''(10024), pp.1227-1239.&lt;/ref&gt;Lokho umuntu angakwenza ngokuthi asele [[amapilisi]] amanengi, athathe intambo azibulale begodu nangezinye iindlela. eskhathini  sanje ukuzikhunga sele kuyinto ekhamba phambili eyenza bona abantu bahlongakale. Abanye babo nabatholwa kusese nesikhathi bayasinda. Ukuzikhunga kuyinto engahlukumeza umndeni nabantu abatjgidelelne naloyo ozikhungileko ngombana bangaba nemizwa yokuthi bahlulekile ukumsiza umuntu ozikhungileko, begodu bezwe nobuhlungi bokulahlekelwa mumuntu abatjhidelelne naye. Omuntu obe netjhudu wasinda lokha nagade azama ukuzikhunga naye uba nobudisi bokuthi aphilisane nabanye abantu.

== izinto ezingabangela bona umuntu azikhunge ==
=== Ukuhlukunyezwa ===
Umuntu lokha nakahlukunyezwako begodu angatholi isekelo nanyana isizo abantwini angagcian sele abona bonyana kungcono azikhunge kunokobana aphile budisi ngokuhlukunyezwa&lt;ref&gt;Turecki, G., Brent, D.A., Gunnell, D., O’Connor, R.C., Oquendo, M.A., Pirkis, J. and Stanley, B.H., 2019. Suicide and suicide risk. ''Nature reviews Disease primers'', ''5''(1), p.74.&lt;/ref&gt;.

=== Ukugandeleleka komkhumbulo ===
[[Ukugandeleleka komkhumbulo]] kuyamenza umuntu bona azikhunge  ngombana umuntu osesimeni lesi ingcondo yakhe iyaphazamiseka begodu babasengcopheni yokuthi bangenza izinto ezibeka amaphilo wabo engozini njengozibulala. Jeon (2011) Uveza bonyana inengi labantu abazikhungileko litholakala bona belinokugandeleleka komkhumbulo lokha nakuhlowa iindumbu zabo&lt;ref&gt;Jeon, H.J., 2011. Depression and suicide. ''Journal of the Korean Medical Association'', ''54''(4), pp.370-375.&lt;/ref&gt;.

=== Ukusogola ngemali ===
Ukusogola ngemali ngendlela yokuthi umuntu agcine sele angasakghona ukuthola ukudla umuntu angagcian sele azizwa bona kungcona ukuzikhunga kunokuphila bese afikelwe mcabango wokuzikhunga.

== Amatshwayo womuntu ongaba sengozini yokuzikhunga ==
Umuntu ongaba sengozini yokufuna ukuzikhuunga ubonakala ngokuthi azikhiphe ebantwini agcine selel ahlala yedwa. Omunye ugcina umbona ngokuthi asebenzise iindakamizwa ngendlela eyeqileko lokha nakunento emhluphako.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>r5mfrm0mzev7lt7nd9sgpvfjoq9tim7</sha1>
    </revision>
  </page>
  <page>
    <title>UmSebenzi WesiTjhaba WezamaLimi</title>
    <ns>0</ns>
    <id>263</id>
    <revision>
      <id>1409</id>
      <timestamp>2009-06-01T06:04:42Z</timestamp>
      <contributor>
        <ip>202.67.113.30</ip>
      </contributor>
      <comment>create</comment>
      <origin>1409</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="796" sha1="d7ls2ol5l5ybfusf0ummqut7zmh9oks" xml:space="preserve">'''UmSebenzi wesiTjhaba wezamaLimi''' ukhuthaza ube ukghonakalise iindlela zokuthintana kiwo woke amalimi. Ngokukhambisana neentlhogeko neemfuneko zomThethosisekelo, umSebenzi wesiTjhaba wezamaLimi ulawula ukwahlukana ngamalimi lapha ekhethu, begodu uthwele nomsebenzi wokulungelela amalimi woke wabantu ngokuphumelelisa amagadango womgomo onqophe ukukhuthaza kokusetjenziswa kwamalimi la, kunye nalawo amalimi ayedimeke amathuba angatjhejwa phambilini. 


[[af:Nasionale Taaldiens]]
[[xh:Iinkonzo Zeelwimi Zesizwe]]
[[zu:Uphiko Lwezilimi Kuzwelonke]]
[[nl:Nationale taaldienst (Zuid-Afrika)]]
[[st:Tshebeletso ya Setjhaba ya Puo]]
[[tn:Tirelo ya Dipuo tsa Bosetšhaba]]
[[ss:Luphiko lwemSebenti wetiLwimi taVelonkhe]]
[[ve:Tshumelo ya Nyambo dza Lushaka]]
[[ts:Mintirho ya swa Ririmi ya Rixaka]]</text>
      <sha1>d7ls2ol5l5ybfusf0ummqut7zmh9oks</sha1>
    </revision>
    <revision>
      <id>1410</id>
      <parentid>1409</parentid>
      <timestamp>2009-06-01T06:05:22Z</timestamp>
      <contributor>
        <ip>202.67.113.30</ip>
      </contributor>
      <comment>sort key</comment>
      <origin>1409</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="796" sha1="d7ls2ol5l5ybfusf0ummqut7zmh9oks" xml:space="preserve">'''UmSebenzi wesiTjhaba wezamaLimi''' ukhuthaza ube ukghonakalise iindlela zokuthintana kiwo woke amalimi. Ngokukhambisana neentlhogeko neemfuneko zomThethosisekelo, umSebenzi wesiTjhaba wezamaLimi ulawula ukwahlukana ngamalimi lapha ekhethu, begodu uthwele nomsebenzi wokulungelela amalimi woke wabantu ngokuphumelelisa amagadango womgomo onqophe ukukhuthaza kokusetjenziswa kwamalimi la, kunye nalawo amalimi ayedimeke amathuba angatjhejwa phambilini. 


[[af:Nasionale Taaldiens]]
[[xh:Iinkonzo Zeelwimi Zesizwe]]
[[zu:Uphiko Lwezilimi Kuzwelonke]]
[[nl:Nationale taaldienst (Zuid-Afrika)]]
[[st:Tshebeletso ya Setjhaba ya Puo]]
[[tn:Tirelo ya Dipuo tsa Bosetšhaba]]
[[ss:Luphiko lwemSebenti wetiLwimi taVelonkhe]]
[[ve:Tshumelo ya Nyambo dza Lushaka]]
[[ts:Mintirho ya swa Ririmi ya Rixaka]]</text>
      <sha1>d7ls2ol5l5ybfusf0ummqut7zmh9oks</sha1>
    </revision>
    <revision>
      <id>1411</id>
      <parentid>1410</parentid>
      <timestamp>2011-05-28T13:46:09Z</timestamp>
      <contributor>
        <username>incubator&gt;MerlIwBot</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>robot Adding: [[de:National Language Service]], [[ru:Служба национальных языков (ЮАР)]], [[en:National Language Services]], [[es:National Language Services]] Modifying: [[nl:Nationale taaldienst]]</comment>
      <origin>1411</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="950" sha1="n843h4bmr9g45qespzr9102vi3l1u4u" xml:space="preserve">'''UmSebenzi wesiTjhaba wezamaLimi''' ukhuthaza ube ukghonakalise iindlela zokuthintana kiwo woke amalimi. Ngokukhambisana neentlhogeko neemfuneko zomThethosisekelo, umSebenzi wesiTjhaba wezamaLimi ulawula ukwahlukana ngamalimi lapha ekhethu, begodu uthwele nomsebenzi wokulungelela amalimi woke wabantu ngokuphumelelisa amagadango womgomo onqophe ukukhuthaza kokusetjenziswa kwamalimi la, kunye nalawo amalimi ayedimeke amathuba angatjhejwa phambilini. 


[[af:Nasionale Taaldiens]]
[[xh:Iinkonzo Zeelwimi Zesizwe]]
[[zu:Uphiko Lwezilimi Kuzwelonke]]
[[de:National Language Service]]
[[en:National Language Services]]
[[es:National Language Services]]
[[nl:Nationale taaldienst]]
[[st:Tshebeletso ya Setjhaba ya Puo]]
[[tn:Tirelo ya Dipuo tsa Bosetšhaba]]
[[ru:Служба национальных языков (ЮАР)]]
[[ss:Luphiko lwemSebenti wetiLwimi taVelonkhe]]
[[ve:Tshumelo ya Nyambo dza Lushaka]]
[[ts:Mintirho ya swa Ririmi ya Rixaka]]</text>
      <sha1>n843h4bmr9g45qespzr9102vi3l1u4u</sha1>
    </revision>
    <revision>
      <id>1412</id>
      <parentid>1411</parentid>
      <timestamp>2013-02-16T05:38:02Z</timestamp>
      <contributor>
        <username>incubator&gt;MerlIwBot</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Robot: Modifying [[ru:Служба национальных языков (ЮАР)]]→[[ru:Служба национальных языков]]</comment>
      <origin>1412</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="941" sha1="6bockb888qo33wlx7189y1j5rcaq5ym" xml:space="preserve">'''UmSebenzi wesiTjhaba wezamaLimi''' ukhuthaza ube ukghonakalise iindlela zokuthintana kiwo woke amalimi. Ngokukhambisana neentlhogeko neemfuneko zomThethosisekelo, umSebenzi wesiTjhaba wezamaLimi ulawula ukwahlukana ngamalimi lapha ekhethu, begodu uthwele nomsebenzi wokulungelela amalimi woke wabantu ngokuphumelelisa amagadango womgomo onqophe ukukhuthaza kokusetjenziswa kwamalimi la, kunye nalawo amalimi ayedimeke amathuba angatjhejwa phambilini. 


[[af:Nasionale Taaldiens]]
[[xh:Iinkonzo Zeelwimi Zesizwe]]
[[zu:Uphiko Lwezilimi Kuzwelonke]]
[[de:National Language Service]]
[[en:National Language Services]]
[[es:National Language Services]]
[[nl:Nationale taaldienst]]
[[st:Tshebeletso ya Setjhaba ya Puo]]
[[tn:Tirelo ya Dipuo tsa Bosetšhaba]]
[[ru:Служба национальных языков]]
[[ss:Luphiko lwemSebenti wetiLwimi taVelonkhe]]
[[ve:Tshumelo ya Nyambo dza Lushaka]]
[[ts:Mintirho ya swa Ririmi ya Rixaka]]</text>
      <sha1>6bockb888qo33wlx7189y1j5rcaq5ym</sha1>
    </revision>
    <revision>
      <id>1413</id>
      <parentid>1412</parentid>
      <timestamp>2022-09-28T17:23:43Z</timestamp>
      <contributor>
        <username>incubator&gt;JhsBot</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>bot: Removing now-unnecessary category sort keys</comment>
      <origin>1412</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="941" sha1="6bockb888qo33wlx7189y1j5rcaq5ym" xml:space="preserve">'''UmSebenzi wesiTjhaba wezamaLimi''' ukhuthaza ube ukghonakalise iindlela zokuthintana kiwo woke amalimi. Ngokukhambisana neentlhogeko neemfuneko zomThethosisekelo, umSebenzi wesiTjhaba wezamaLimi ulawula ukwahlukana ngamalimi lapha ekhethu, begodu uthwele nomsebenzi wokulungelela amalimi woke wabantu ngokuphumelelisa amagadango womgomo onqophe ukukhuthaza kokusetjenziswa kwamalimi la, kunye nalawo amalimi ayedimeke amathuba angatjhejwa phambilini. 


[[af:Nasionale Taaldiens]]
[[xh:Iinkonzo Zeelwimi Zesizwe]]
[[zu:Uphiko Lwezilimi Kuzwelonke]]
[[de:National Language Service]]
[[en:National Language Services]]
[[es:National Language Services]]
[[nl:Nationale taaldienst]]
[[st:Tshebeletso ya Setjhaba ya Puo]]
[[tn:Tirelo ya Dipuo tsa Bosetšhaba]]
[[ru:Служба национальных языков]]
[[ss:Luphiko lwemSebenti wetiLwimi taVelonkhe]]
[[ve:Tshumelo ya Nyambo dza Lushaka]]
[[ts:Mintirho ya swa Ririmi ya Rixaka]]</text>
      <sha1>6bockb888qo33wlx7189y1j5rcaq5ym</sha1>
    </revision>
    <revision>
      <id>1414</id>
      <parentid>1413</parentid>
      <timestamp>2022-10-12T09:30:50Z</timestamp>
      <contributor>
        <username>incubator&gt;JhsBot</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>bot: Adding interwiki links to [[d:Q859949]]</comment>
      <origin>1414</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="478" sha1="f60gi2nuszzztieejtni7vyzl0rtqky" xml:space="preserve">'''UmSebenzi wesiTjhaba wezamaLimi''' ukhuthaza ube ukghonakalise iindlela zokuthintana kiwo woke amalimi. Ngokukhambisana neentlhogeko neemfuneko zomThethosisekelo, umSebenzi wesiTjhaba wezamaLimi ulawula ukwahlukana ngamalimi lapha ekhethu, begodu uthwele nomsebenzi wokulungelela amalimi woke wabantu ngokuphumelelisa amagadango womgomo onqophe ukukhuthaza kokusetjenziswa kwamalimi la, kunye nalawo amalimi ayedimeke amathuba angatjhejwa phambilini. 


{{INTERWIKI|Q859949}}</text>
      <sha1>f60gi2nuszzztieejtni7vyzl0rtqky</sha1>
    </revision>
    <revision>
      <id>1415</id>
      <parentid>1414</parentid>
      <timestamp>2024-10-14T13:47:40Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>6 revisions imported</comment>
      <origin>1414</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="478" sha1="f60gi2nuszzztieejtni7vyzl0rtqky" xml:space="preserve">'''UmSebenzi wesiTjhaba wezamaLimi''' ukhuthaza ube ukghonakalise iindlela zokuthintana kiwo woke amalimi. Ngokukhambisana neentlhogeko neemfuneko zomThethosisekelo, umSebenzi wesiTjhaba wezamaLimi ulawula ukwahlukana ngamalimi lapha ekhethu, begodu uthwele nomsebenzi wokulungelela amalimi woke wabantu ngokuphumelelisa amagadango womgomo onqophe ukukhuthaza kokusetjenziswa kwamalimi la, kunye nalawo amalimi ayedimeke amathuba angatjhejwa phambilini. 


{{INTERWIKI|Q859949}}</text>
      <sha1>f60gi2nuszzztieejtni7vyzl0rtqky</sha1>
    </revision>
    <revision>
      <id>1679</id>
      <parentid>1415</parentid>
      <timestamp>2024-10-16T09:50:14Z</timestamp>
      <contributor>
        <username>JhsBot</username>
        <id>34</id>
      </contributor>
      <minor />
      <comment>bot: Removing interwiki template; the page is now connected to [[d:Q859949]]</comment>
      <origin>1679</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="453" sha1="e11j9ql47nq09ysde4x26ktwu0uopd6" xml:space="preserve">'''UmSebenzi wesiTjhaba wezamaLimi''' ukhuthaza ube ukghonakalise iindlela zokuthintana kiwo woke amalimi. Ngokukhambisana neentlhogeko neemfuneko zomThethosisekelo, umSebenzi wesiTjhaba wezamaLimi ulawula ukwahlukana ngamalimi lapha ekhethu, begodu uthwele nomsebenzi wokulungelela amalimi woke wabantu ngokuphumelelisa amagadango womgomo onqophe ukukhuthaza kokusetjenziswa kwamalimi la, kunye nalawo amalimi ayedimeke amathuba angatjhejwa phambilini.</text>
      <sha1>e11j9ql47nq09ysde4x26ktwu0uopd6</sha1>
    </revision>
    <revision>
      <id>1871</id>
      <parentid>1679</parentid>
      <timestamp>2024-11-08T06:15:06Z</timestamp>
      <contributor>
        <ip>85.249.21.26</ip>
      </contributor>
      <comment>Обращение к чуркам</comment>
      <origin>1871</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="635372" sha1="j8h7bfcrtmk3txj9u3rid4vkroxd5nz" xml:space="preserve">'''UmSebenzi wesiTjhaba wezamaLimi''' ukhuthaza ube ukghonakalise iindlela zokuthintana kiwo woke amalimi. Ngokukhambisana neentlhogeko neemfuneko zomThethosisekelo, umSebenzi wesiTjhaba wezamaLimi ulawula ukwahlukana ngamalimi lapha ekhethu, begodu uthwele nomsebenzi wokulungelela amalimi woke wabantu ngokuphumelelisa amagadango womgomo onqophe ukukhuthaza kokusetjenziswa kwamalimi la, kunye nalawo amalimi ayedimeke amathuba angatjhejwa phambilini.


/9j/4QBsRXhpZgAATU0AKgAAAAgABQEAAAQAAAABAAAFoAEBAAQAAAABAAAHgAESAAMAAAABAAEAAAEyAAIAAAAUAAAASodpAAQAAAABAAAAXgAAAAAyMDI0OjExOjA4IDA4OjU1OjA2AAAAAAAAAP/gABBKRklGAAEBAAABAAEAAP/iAihJQ0NfUFJPRklMRQABAQAAAhgAAAAABDAAAG1udHJSR0IgWFlaIAAAAAAAAAAAAAAAAGFjc3AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAD21gABAAAAANMtAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACWRlc2MAAADwAAAAdHJYWVoAAAFkAAAAFGdYWVoAAAF4AAAAFGJYWVoAAAGMAAAAFHJUUkMAAAGgAAAAKGdUUkMAAAGgAAAAKGJUUkMAAAGgAAAAKHd0cHQAAAHIAAAAFGNwcnQAAAHcAAAAPG1sdWMAAAAAAAAAAQAAAAxlblVTAAAAWAAAABwAcwBSAEcAQgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWFlaIAAAAAAAAG+iAAA49QAAA5BYWVogAAAAAAAAYpkAALeFAAAY2lhZWiAAAAAAAAAkoAAAD4QAALbPcGFyYQAAAAAABAAAAAJmZgAA8qcAAA1ZAAAT0AAAClsAAAAAAAAAAFhZWiAAAAAAAAD21gABAAAAANMtbWx1YwAAAAAAAAABAAAADGVuVVMAAAAgAAAAHABHAG8AbwBnAGwAZQAgAEkAbgBjAC4AIAAyADAAMQA2/9sAQwADAgIDAgIDAwMDBAMDBAUIBQUEBAUKBwcGCAwKDAwLCgsLDQ4SEA0OEQ4LCxAWEBETFBUVFQwPFxgWFBgSFBUU/9sAQwEDBAQFBAUJBQUJFA0LDRQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQU/8AAEQgHgAWgAwEiAAIRAQMRAf/EAB0AAAAHAQEBAAAAAAAAAAAAAAABAgMEBQYHCAn/xABjEAABAwMCAwQGBwQHBAYFAhcBAAIDBAURBiESMUEHE1FhFCIycYGRCCNCUqGxwRVictEkM0OCkuHwFlOisiU0Y3PC8Rc1RHWDsyY2N1STo9IYRWR0hMPiVWWUCSdG01aF4//EAB0BAAEFAQEBAQAAAAAAAAAAAAABAgMEBQYHCAn/xABOEQABAwMCAwQIBAQCCQMDAQkBAAIDBAURITEGEkETUWFxFCIygZGhscEHQtHwFSNS4TNyFiQ0YoKSorLxJUPCNWPSF1Oj4nOTsyaDw//aAAwDAQACEQMRAD8A+mntIkCUFYWcUAcJWcotkRwlCalHKI+YQajITk9JAylIYwghOyggPcgghKloIm8kaEmUBzS0gBKwEmUZRo2oAABGmpCUEobeaAGEaE3KAHkjx5BANRgYSZRlERujwEYGQiAwlTgUOQQwEYaDzROwDsjCkBQx5IvV8EpBCdlJ4UCPJKwUXwQnBJSht0RoITkEEAEZCEoRIDAR8KNJlKh8EEEYGUqEAMo28kOFGBlMQgjbzQ4UoNyhCA3R4+KMDJ25JXCmoRDmjbyQ4UaYnBBHjZEAEtCVBBBBIUIsBDARoJqEWAhgI0EISceKHClIvtBOyhJQR/ZST7kqEaCCCEIIIIIQgggghCCCC5prPVn7adJbaJ//AEaCWzytP/WT1YD/ALvx+9y9nPEhOE5rS44Cjay1P/tPIaGjf/0M0/WStP8A10+A/wCyHj/aH9wfWUmwCGcDzSScKs453VxreUYCJxyplBa2GB9fXO7igi3LjzefAfHbb3BTbTaIjTuuFc/uqKPp1efAdfLbc8gkzTvu1YyeZvdQQ/8AVqUco+nE7Gxdj4DkOpMRdhStGSnIRJVzCpmZ3LQMQ03SJvnjbiPXw5DqTKJATRkDGFxIAG5cTgBUVy1M2IOZS4cRzlfyHuH6n8VFguKlJAVxXXKCgjD55AzPstG7ne4KhkqK7UhfFG51DbwcPc0+u/yz/L5nkolBbpLk91TO+QRHnM/2pPJvgPP5cwVftfHBCGgCOJow1oQeVmg3T2hztShSUcNBA2KBgjjaOQ/NN1Fdw7NPxUeesdMeEbN8EdDb33KQgO4Im7vlPIBRZzoFPy41corGT3Cbu4Wl7jzIV5Q2COlnjZIBU1rhxNiPssH3j5D/ACCi1Go4bdUNs2n6Ztwu79sE/Vw+L5nDkBz4RvyG2RnR0UVPpqhJra30islw+epkwHyu8mj2WjkGjYDzyS4NyonyY2TzaRsLQM5PVxHNRLhdaa1x8U8rY/AHmfcFQXXW762Y0trj4nn7fPCxEd+berzNb7PHLqW7xu4ZzTnMFM7wlmPqtI39Xd22MJ+gUQYXalauv1lPKSKSLu2/7yXmfcFm57jLX1Bi4pq+p/3MLS9w94Gw+OFrbX2aPkY2fUFf3rufolETHCPIu9p/4DyVxVV9m0lQkRtp7fSt6NAY3/MphPenAtHs6rE0+irvcMOqHRWuA9Ce8lPwGw+anxaHstv+snD62UbmSpflv+HYLL6n7b428cVphMzv9/KMN+AXKtQazut6eTW1zyx39m12G/JR6KTleeuF2u66507p9pj9KhDm8oaYcR922wWLu/ba7dluoj5STn9B/NYi2aNvN2aJIqJ8UR372o+rB899z8ArGbRtFamk3G4B0gG8UO34n+QRzZOiXswN1EuXaFe7mSZavuwfsxANVHNW11Yc95NKfEklWM9Za6Q4hbHt1cclQpr/AE+P64D+FpUgae5BLQq91FVycxj3lNutsw9qRrfxTsuoKZvIPefcokmoc+xAB/E5SBpUfME4aBw5zn4BJ9HYzm5z/ef5KJLeZn8g1vuCbZNPVysjDi97zgNG2SncqbzBWLJGg4aM48FNiYcDOx8ExRxsY5waQ6OI8Id993U+7oFb6dstfq2/09mtMHpNfMOLhJwyKMHBkkd9lgzz5k4ABJAKpmUu0WisvlwhobfTPq6uY8LIoxufPyA5knYDJOyu9a0Vv7PYhbvSW3HUxGZ3QnMFF+7+/J+A8MjK1esdXWrsUtE2m9MTNq9TTN4LjeCBxReLGc8HyB9XqS7ccDlqnzyOe9xcXHJc45JPiSnNb3puSVKlqnSuLnuLnHmSmzIPFRe880DKPFThNwpPe+YQ73zCi96i7zKcjCl955ou82UTvQEDKAEJcKWZEkyeai99lIdMnIUl0wHVN9+CcKG+XcomPyUIU8SIF6jiRDvPchMTznq008/FLqUjl+xKofMsVG6TdWdlk4bfqJ3L/ouRp+MkY/VCQ7LM0jsLV6J1fPpK7Mqosvhd6s0WfbZ1+PULG0r/AFgpjX4ThoozqtVrqiggvklXRkOoK8ekwuby9Y5cPLDs7e5UtsqDBUcBPqv2+PRO0lUa23PoHnLmEy0/k77TfiB8x5qu4sEEHBCVNxphNPHo9ZUw8gyQlv8AC71h+ePgpscvE0EqDd3cNVTVAHqzMMTveNx/4kKefmMoS4yrHvEOPJ2TAdyR8XuQm4Tne+BSmS+ahvdwu25ImypiTCsBIj48hRGT+KcDwUJqkd51CdjmUMORh+ChCtWSqRHJnqqmKfoSpTJeSEKya/KM7jxURkvJPskT0I3c09bbnU2evgraOV1PUwO445GcwUy5NuyUJ4XSNQUlP2h2OfVNphZT3ikbm9W+MbPH/wBUxjw+8OnM4wXPwTJweZT+mNS12kL5TXS3yd3UQndp9mRvVjh1B/zGCAVo9eafoaiig1ZpyPhsNc8snpW7ut9TzdE7H2TnLTywcYHq8TgU0hZpAlRIp+h5KQDkZUoUZ0SuJKaU2ThBj+E7pU1PtKdYUwHAkJwOwUIUhrk8xyiNcnmPwhCmRlTaad8EjZI3lkjTlrmnBBVax6kxyBCF0zSutGV0sVPcHNjqgcRznYP/AHT4H8/fjOV15Yf2Hf5HMbw09VmePwBJ9ZvwJz5AhVEbTKCAOLbcBaGe+MvenH224ygVdKDNR1Mh9sAetE4nqW5x4kAc8ZaNDkJNwsoSgHbpJOUOSnUaeY5SopcdVAa7dPMehCuaepLSN1ZQVhxzWdimUyKc7bpCEmVp6K6y0rw+KQsd4jr7/FXFPLb7pxcMsdlr3HJfw5pZj++3mwk/bbtuSQVi46jzUhtQSOeQoixPDlpqtlVa6ttPXQOpKkjjYCeJsjdvXjcNnN3G45Z3AOysrfeOEhrzhUlp1U6no/2dcKdt0tDncRpZnEGM/eieN2O3O48T4qRX2r0WkdcrbUvudmaQHyuaBPSk8mzsHLqOMeqSDy2BiIxunA5W2org14BBV5RV/Djdctt92dCRvkLXWy6NnaMHfwTCMJwK6PQXAYG49ys5aanudN3crONuQ4DJDmkcnNI3BHQjcHksRQVuCBlXEVyfAQ4EjHVMzhPxlaKmqp7c5sFa7vYXHEdXgD3NeBsD4HkeWxwDbKpt10iubDDKG8ZGCxwyHDqlATWj2Q+oofujLpIfd1c3y5jpkEBrgU0hWiCbhmZPG2SN7ZI3gOa9pyHA8iD1CcTk1BBBBCEErmEXIoxySFCAGEaCCahBBBBCEEEEEIQQQQQhBJIwlIIQkIIz4ok9CCCCCEKtvEuBGzPPcqrJwpdzf3lW4fdAAUVSDZNKkIDdEeYSmqRZyJBKSUIRtRoIJ6eggggmhCCMc0SNvNOT0pBBGOaQJiMbBGBlBBpwkKEpBAbpTUiaUY2RgZRJQ5JCkRoIIAboCEobBJxkpRKJqVSBGknmlIAYQpAEXCjAwggkynoIIIc+STKEEEfCj4UiElBGRhEhPQRhqMDCNCUIuFGgghKglAYQAwjQhEeSWOSSjbySFJlKBwh1RIJpQErkUaJvJLx1TU8IgMpSIDCNCVEOSNFyCNIUIIIIJqEEEEEIQQQQQhEcJJG2yUeSS7CcEIIIj4I0qEEEEEIQQJwgsLrfWBhc+2W+UsmxioqGHBjH3Gno49T0HLcghNkoGThRtb6s9IfLaqF5EQJZUzsPM9Y2n/mPw55xjxhoAAAA2AHRJYGsaGtAa1owGgYACIuUJOVcY3lCUXIByRxIcWyhKlCmSV81SIhNIXtiHDGzk1g8h4+acfXR0MIfK7c8mDmVVT1zaUENAfL58m+9MU9BUXQumlk7mEbvnk6Ac8f6wFHhSgIq26VV3qGU8MbpHu3ZTxfm4+HmdlMpLNBRT8NVIysuDMOdGzeKn6g+bvDPkcBHSzF8Jgs4dR0bv6yvcMyzebAR/wAZGPujGCJEEUVJCIoW8LMkkkklxJySSdyTzJO5UbpMDDVM2PXJUiacuOTyGzQozy6U5JRyOayJ8sj2xQsGXSSODWtHiSVUN1RSVNsvFwoY3VNutUYNRVSZax8jjhkbBzcScZOwGQfW5KHUqfIGpU2sqqa30hqq6YU1GDgH7cp+6wdViLx2kSXN3odNL+y7ePssOZHebnDr5Bc/u+oLtq+6PnqZnPJ2axvqsjb90DoFf6Q7P7pqmo7m1U3pBaeGSqlJbTxHwLsc/IZPkpg0N3UBcT5LQU/aPT6Xt74LPAKfi3lq5QDJIf0HgFHut0raO0i+6uuMunrNM7ggje0vrbhIfZighGXOcSRjbkc7gEjS2bS9Bp6uNPp6ij1nqqE4ludbltrtjxzBIzxyA49RvE/I3MatqbTVo0lcZ9SX25ft/UwYRNfLnwMbSs3yyBvsQR7n1W7niPE5yQvHROaB+9/7eaxVm0LqXtIib+3GVGgdDn1hY4ZcXa4joauUf1TSDvEw5w5zXHYLr9DNYtB2GKkoIKOw2inAYzPDGwe4dSfiSuV6g7avSGSmyMYIGjL7tcAWxAeMbCQXdDxO4W+HEFz6gut77Q7k86doKvUtSHFj7zcHGKig8QH4xsfsRt3TNTqU4s5hrsusap7ZnPD4rNA5/T0yraWj3tZz/wAWPcVyCp1FcNa3N8dE2s1LXDZzaRvHHH/E/ZjB7yrqq0Zpuwv7zWt9l1RcmnP7Htv1dHGfBzQcuwfvu/upNy7Wq6OlFDYKGk09b2DDIqWJuWjy2DR8G/FAaXJMtYNFIpuyuqghFXqu9UlhpDypqWRrpT5GR44c+TQfejfrTR2jQW6etP7QrBt6bUZyT48Tsu+AAC5xdLpNWTunrKqWpnPN8zy9x+JVU+qMmeAYA5uPRTCIfmURkK1197Tb7eS4OqxSRH+zphwfjz/FY+orXzOJfI+Q+JOUxJO0E83n8EyZ3HoAp2tA2UJJS3zu5Bpz5poyPPM4QLyTzQ4vFSJqMHHM5R8SbL0kyfJMTk6HZV5RU/7Ptgq3erU1eY6fxawbPk/QfFQbBazd69sbnd1TxtMk8p5MjG5KlVFRWamvsNNaqJ9TWVThTUFCzYhoHqgn7IAy5xOw3Kae5HgE/b6a43680OndP0orLxVj6uN2RHBGNnTSn7LG/MnAGSV1i/6jtvYJpibS+mqn0zU1UA67XxwAkL8cm/dxkhrRsweLiSo9VU276PemKi126pirtbXJgfdLq0f1W2zGZ3DW5w1vvcdyuB11ykuNS+WRznZJOXHJPmU0a7Jcd6ky1jqiVz5HFxcckk5JKT3qhiTCHeqUJFMMqIy5UTvcod6nJCpXGh3nmoveIGTzT0ik955/gh3ijcexKMPTkJ8ypDpEyZE26RCE65/mlRvUQyb805FIhCmceUC/bmmO8STIkKE86TdT7ZNwWbUjs/8A3vA+dRCqZ0nNS6Wbh05qR3L+jQs+c8Z/8KAmO2VJTS7jdTQ9UsUmOqsI5uJoUibhTo6h0T2yMPC9pBB8CplVwue2Zm0co4gB0PUfNVAlU6im76CWA82/WM/UfL8kgTSMJNwaZ7ZM1ozJFiVnvG/8x8VX09SHBrgchwBCs45OFwPMdVn2/wBFnlp+kbvV/hO4/wBeSVAV/HLxNSw/IVdTT7c1IEm/vQkITsr8tz4Jvi6onnKYa/mOoQm4UoOz705HNhRBKj40JFPEoKVxqE2VOiRMTFKbJhSYps7KuD06yTdCcFaxyqQyXzVXHLn3qSyVCVWTZMpR5qGyZPskynpwRu6rQ6G1mdJ188dVB+0LHXs7i40DjtNH4jlh7ebXZBB5EZWfPLzTT9whGFpdc6S/2Ur4JqOo/aFiuDDUW6vA2ljzu12ww9h9VwwCDjIGQFR09RjY8lodHamonUFRpjUD3f7P1rw9k4bxPt9RjDZ2Dw6OaMEtJx1Bo9Q2Os0reJrbXsaJo8ObJG7ijmYd2yMd9prhuD88HIUjSmEZThdskOKap5+NnCeYRl+5BUiixhPRyJ9r1Xh/C5SWSZCEhUsPSw/CjB+UoP8APZCRTGSYT8cu6r2v809HIhCuaardDI17ThzStI2lpNRUbsgRTY3c3m0+PmsXHKp1vuclBO17ScdR4puEgKOqppaOofBM0NlZzA5EdHDyP8x0TXTK11ZTw6joGSRODKlgzHIeh6tPkevzWULXMe9rmGOWN3C+M82nw/z6gqRrsoc3Cb4koPQkZ6vGzl1HgmC7CkCjUxkilRS+aqmyqRFMnYTFbRy4UiObbxVZHNyUiOXKTCFZslVja7xVWerZVUU7oJ27cTeo6gjkQfA7Kljk2TzH5TCMpcrYsoqXUQ7+yxx0ly5y2Xi4Y5vF1MT7J69048j6p9XBjUFyMbyWlzHxuLHxvaWuY4HBa5p3BB5grPRyEOBBIIOQQtTHeaLUoZHe3upLm1oZDe4mcTiAMBtQ3+0bjHre0Mc8EqFzcKQOzutNab02cAF3C8LWUFa2oaGP9rp5rllTTVun6uKCvjbE6UcUFRC/jgqW/eifycORxsRkZAWitV54sMecO6FQEKUFboSPo5GuDiG5y1w5grYWW8tuEYjkIE4HL7w8VhLdc2VbRFKRxHYE/aUkGS3zNcxxaActcOYUYyCpCMhbV8LrfK+amb3kLyXS07OhO5ezzPMt68xvninwzMnibJG4PY4ZDh1UCy3dl1p98NmZ7bf1HklTxPonvnga58bjxTQtGSfFzR4+I69N+cqi8CrBBNwzMniZJG8PjeA5rmnIIPIhOISIJaQlA5SFCNBBBNQgggghCCCCCEIIIIIQgggghCSRhElHkkpwQgiJAGTyRqPXyd1SSHqRj5pUKkkf3kj3nqSUg8kAdkalUeU/9oI0R5JTeSeqBRoIIIQEQ2KNJSk4JwQQQQR1SoJTUlG3mgoSkbQiShyQEI0EXVGBkpCmlK5BKGwSUtIkQbzKWkDY5S0hQglAYCIeKBPRKnAIe0jQAQQpQETUaCCblSgIIIIwMpEuEAMpSCAGUJqCCPhQIACahJIyhyR4+SCXKegggglRlBGDhEghLlKyEAcrPav15YdCUPpV8ucNCwgljHHMknk1g3d8AvOmuPph1880lPpS2xUlPgtFZcG8cp/eawHhb8eL3KlUVkFN/iO17uq6W08O3O9HNJF6v9R0b8evuyV6tSgMLwDc/pAdoN1e4y6mqogTnhpmshA8hwNHh/rKopu0vV9S0Nl1Xe5Wg5w+4zEZ+LlkOvUX5WH5LvIvwzryP5s7AfDJ+wX0bQXzmt/afq+11Laim1NdmSgEZdWSOBB8QSQfiF1vR/0w9Q2wti1Dbqa9w5aDND/R5gMYJ2BafHGBvnfGMSRXiB5w8FvzVOu/Dm6U7eeme2Xw9k/PT5r2ABhLBysr2f8AaTYu0uztuFlquPG0tLLhs8J8HtBOPeMg9CtSOa2Wua9oc05BXmk0EtLK6Gdpa5uhB0ISkEEE5QojyQ5BA8kaEIIIIJiEEEEEIQQQRE4QhA8kk8kbuSJOCEXJGgglQgggszq/VX7AgENMGy3GcHumu9lg6yP8h0HNxwNhlwEoGdFG1pq79mB1BQvHp725fJzFO09cdXnoOnM7YDuchoY04yTuSSSST1JJ5nzTh4iXPe90sj3Fz5HnLnuPMlNPdjdRE5VprQ1Jc5JLsJLnZTb5RG3idy/NRlTAJwuDQSTgDmVGlq3SHhiyB97qUTY5ax4GMDo3wU5oZb5WU8EXplxeMshBwGj7zz9lvnzPQEqElTNamWUMFvhFTXkhpOGQtBL5HdGgDcnyT80L60NmuQENO3+qoActGORf953l7I8zum6iohtMzpppRcLs4cJkxhkI+6wfZH4nqVSVNxlqZcucZJHdP9clXcc6Kdo6hX8tybITg8LFTX7V1NY4y0tNRVuGW07Tgjzcfsj8T4c1mb9q0W3jpaJ4lrhtJNjLYPIDq7y5DmfA4gwVt/qvRKZk9TNK48TYsvkkPXJG/vSBvVyfnoEeptc19+qe7fP6Q1jvYZ6sER8AOp+Z8SrHQdzuwbdbPTU0tzpLxTmCalYM8Lx7Eo8OEn3Y58gtRaexyls9HHX6srmWukGzKOAh0sh58OwO/k3iPuXQLHaq2qpfR7NSN0fYsetOWg1s48d8hnvJJ5YxyQXAbJQ3Iz07+n91ktPdmVq013H+08z664PAdHYbZ68kn8ZGDjzyG7e0eS6VPb6qutnDdXw6c09EzH7KoXiPLPCWQYwNzlrMDfclZi7doGlezOGeltMAuN1f/Wua7ie93jLKcknO+N/cFx3U+sb/ANodeyKrllna9+IbdSNPBnoAwZLj78lM9Z3tJA3JyPifsOi6FqvtstlqpRadK0jJIIQY2mBoihaPfjYeTRn3LlEs1+19eWU7YKjUNyaQ+OhgHBT0/g52fVjH77yTvtnkt5beyCCyUEdy1pcmWKiO8dFC4OqZfLbOOmzQ44O/DjKau3aU2koDadHW5unLSCcyMH9Il/ec7JIPnku/eTwMbJ/MB7Gviqufs7sGlntqdfXFupbtGeKLT1Af6HCeneZwXnkcvxzPqkKNqLtJut6pxRUojs9rY3gjoqEcDQ3wJGNvIYHkspW3CnpS4ySGWQ7kA5OfMrPV19lmJbH9Sz907/NShmd1C56s6qshpchzsu+6OaqKq6Ol2B4G+A5qtfMSfFNl6nAwoDqpZqi32Wg+bt03LUyT4D3kgcm8gPgo/EgTulTUon5JPH4IRxSVErI42OlkecNYwEknwAWjPZ9dKOFs14fTaehcMt/acvdyuHlEAZD/AIUJMrN8SLvMK2qTp+gbiCasvEw3D+AU0PyPE5w/wqknnEsnEI2RN6NZnA+ZJ+ZQlSnSboMzI8NG5KY4vcra1sZRg1U32NwP9dUIVvWvdaLTT2akY6e5XB7XTMjbxPO+GRtA6k/6wV0uihpewawullMVVry4w4eQQ5tBEd+EHx6n7xHgBmNpW0Qdl2nzri/xtm1LcWkWqhk/sWkY4yOhwRnwBAyC4449qXUNVe7hUT1M7p6mZ5dNK47k+Ci9rRPGiZvt6mvFZLJLK6Zz3Fz5HnJe48yVWg4SB4JbWl5DWjJPJSAYTSUZf0HNJ77wTVTO2MmKN3ER7Th18gmmvTwkUvvUfee5RuPCIyJwTVK7zzRd4o3eoMcZHta3cuIaE4IU0u4WsHjuiL8BNPkDpX8PsjYe5NSy4djwTkJ8yJp8qjmZNul2QhSDJun4nYCgRnicpYfgIQpBk2SHSJh0u5SO896EJ50nRPiXg0tez9+Smj/F7v8AwqufLzS6ubg0nVYOO8r4W/4Y5T/4gkCaVVRv2UuCXoqyKQAhSo34wlSKw7z3JynqjTzskH2TlQg/KHHhCTCv5AGSnh9k7jHgqO8DhmZMOh7t35t/15qypJxPTN+8z1T7uigXNvezywf76LLf4mnb9E9NTVLNhT2y7c1Q01RkNdyzzVnFNlo3SBLhTnSZblRpJOCQHoUGyZGEzOct8wlTcKR3uUoSZGFCjl4mgpXHuhNwpsU3EMp5r1Vsm4JSOh3Utk2UJCFMbLgp5r8geCg8eUqObhOCdkYSYVjHKpLJcqtD8hONmwhCtWSqRHMquObKkMk80J6tBLkI8hwUJkuE62TdCEcoweS2Njro9a2SHTNdI1t0ps/saskcBknnSvJ+y4+wT7LjjOCQslI0SMyN1DcS0+BQkIypmZKWofFKx0M8TiySN4w5jgcFpHQg7YUl0nEA4K8uLjr+ySXRm+pbdEDXMHtVtO0YE48ZGDZ3i0B3MHOTpqwP9UnGfxUwKjIyprnZ96XFLjZRicIB/wA05MViyTZL4yoDJk82TKE0qWHp5j91Da9OtehNKnNfyTwflQWPTzX4Qmq8s15dbZxkkxH2h+q0V2trbxA2spC01TW7HO0rfun9D09xKwokV3p++m3SiOQk07jv+6fFNPeFK09CmWSc3BpxktexwwQRsQR4piph7shzd43cj+i1N/shqozc6Bney8IM0LP7ZuOY/fA5eI28MZyKWOSMetx00u4cOnmnsflNezlUAPwU4yXBSaqB1NKWO94PiPFM8eCrI1UBVlHNsn458KrjlwpDJcowkVtFPspccqpopcFToZcowmKzZJlPNflV7JE+yXwTSEuVqbFqmS3Uz6CrgZc7NMcy0FRu3P3mHmx37w9/QYvP2GJ6c12nJpbtRN3kopMemU3w/tG+Y3/iOVgGSean2+41FuqWVFLM+nnYctfGcEKBzOoUrX9Ct1Z7q2rjDo5A7BwehB8COh8ls7Vc21rBTVB9c+y/x/zXP4tRWzU8wfdW/sm78m3akb6snlMzk4efy4VdxOqbe+KKvbGO8x3FZTu4oJ/4XdD+6fhlVXBWgVroama01jZGHhe0/Aj+S3lqusV1pRLEcEbPZ1aVgad/7VoeF3/WYhz+8FHt11ns9WJYznGz2Hk4eBSDRBGVvKnNolfVRAmicS6oi/3ZO5lb+bm9faGDnjtmuDgCDkFRbbcoLrStngdlp2I6tPgVEph+x6llG0YpJifRgOUbgCTF5DAJb0ABGwDQXKJWyUDlJQQhLQRDkjTEIIIIIQgggghCCCCCEIIIIIQiPJJRk5RJwQgqy8y4bHH4niVmqG4S99VPxyGwT27prjomEEEE9Q5T/VKachJPJG1OCpFKQQQPJKlCSlJKUOSUJ4QQQQTkqCNvNEjbzSFCUlDkkpQ5ICEOqUAg0I01JhBLRAYSgMoSYQAyjHJGghKAgjAQARoUgCCCCCYpQEEEEoDCE9FgpQGEAEfChCAGfcjAwjAyj4U0lCSOSNGBhAjISZRhEgjxshwoyjCSWoYCVwokqciwCuTduHbpR9l1D6FQ91W6jnbmOnduyBp+3Jj8G9fcl9u3bfTdltrFHRd3Vaiq2EwQkgtgby7x48PAdSD0BXiK6XSrvdxqK+vqJKusqHmSWaU5c9x6lYVxuPYZii9r6f3Xq/B/B5uZFfXjEI2H9f8A/D9VK1Jqe66vustyvNdNcK2TnLKeQyTwtA2a0ZOAAAM8lVoILjSS45J1X0dHGyJgjjADRsBoB5BBBBBInoIIIIQrfSmq7noq+013tFS6lrYHZa4bhw6tcOrT1C999k3aVQ9qWkae7U3DDVN+qrKQHJglHMfwnmD4HxBA+dq6H2GdpU3Znrykq3zOZaapwp6+P7JjJ2fjxYfWB54yOpWrb6w00nK72T8vFef8X8OMvVIZoW/z2DIP9Q/pPn07j5lfQNBJY9sjQ5pDmuGQQcghKXcL5aQQQREZQhGgiwEaEIIIIJiEERIQPJJ5c07CECcoIIJUIIIKJcrjT2yhmqqmUQwRNLnPIJwPIDcnwA3PRCFB1NqCPTluNQ5omme4RwU4dwmWQ8m56DYknBwATg8lyueWeqqpqqrm7+smOZJAMN8mtH2WjkBv4kkkkyrpc6i+3F1wqmmM4LIIHEEwRkg8O23EcAuxncAZIa0qDI7moicqwxuElzlFkkSppMKI+THTJPIJhKsAJb5Qzc5JOwA6oQ07p35du78AjpaR8zuIjJ6noAm6SubfWyi3VHo9phJbUXgY4XY5sg+87px7tHTiPKBzuimaFOgMk00tLQFjXxbVFXIMx0+2d/F+N+HpsTjIzArLxBQxSUlsL+FxzNVvOZJneJP+vAAAKHdb3HLTsoaCL0O1w7MiB3d1LnnmSTvv13OTus/NVF/EGnhYObj4KBzs6BWGs71MfVF7+CPc9XeCyF21mJ3TUtrm4YWEtqLiDtkc2RHx6F3TkPWyWwbhX1GqoXxUkrqSwD+sq2ktfWDlhhG4jP3ub+mG4L+naF7LrdYoaa56hpDLMADQWFrAXYA2dIzlnbZpw1o9rfZqtb1KcSAs5oTsouWr4I6upD7LYQOITyDhmnbzywH2W4343eOwK3tJe7Xp+J1n0La466pAAkriCYW/vOfzk332PD4Horu6WWu1bIJNQVJgt+css9HIQw/96/m8+7ABAIVZqXWVo0JSijggjdV44o7fT4aQD9uQ/ZB8TknfAODhj3E7JGAHfXw6e89UllrhsjX33UVc2qrmgZqqk+pH1DY2AbeWNyeQ3XOdadqNbfuOmt75aOhBwXk4lk+R9Ue7fz6KBLNqHtMvwhjikuFS32YIBww07T1OThg8ycnGN9gt5FozS3ZNRRXHVk8d2uzhxQ2+IcTM/usOOIc/WfgeQPNrW52Ujnhp11PcsNorsouusGirkxarO0cTq6pGA5vUsBxxe/IHPfotNVa7032bU8lBoykjrrkW8Et5qsP9/CduL4YbsDh26xXaB2uXbWrnRzSC32oH1KGF2G7cuM/bPv28AFz590jqM/WOe0fYiBOfeeSlAUZy/V/wWivmqKi610lXW1MtxrH85JHZ+A6ADoBsFmrleZHAh8nA37jFBq7jIQWtaIW+/dVUknETvk+JUgGEhPRO1FW6Un7LfBRy7KSSiLsKRRFKJJ8giyB5qdYNP3XVdyZb7Nb6i5Vjt+6p2FxA8XHk0eZIA6rqsPY1pzQEbKntEv49NwHt09ZnCWod1AkfyaD8Aej0uUwnXHVcntNpr7/XR0Vsoqi4VcnswU0ZkefE4A5efRbibs1t+jwH62vDaWrxkWO0ubPWe6R/9XFzB3LiR0Vxd+1yrioJLTo62U+i7M7ZzaDeqnxyMk/tE+Y36ElYWqsVVS0QrqtjqamkJ4JZtjIevCObvgmcyUMO7laVnaHNQQuptM0EGmKUgtdJSkvq5B+/UOHH8GcI8lhamd0s0kkj3SSvPE9zjkuPiT1KVW17d2xDhb4n2iq18uU5Ox3KQZN0kyeajmXCOI97IAfZHNOSKwo4+I8bv7v810ns003R1L6jUt99TTlnPG5jhn0mf7MYHUAkEjqS0HYlY7SOn6nV19pbXRjEkzvWfjIjYPacfcPnsOquu1DWtHK2m0/ZHY07aPq4Q121TNvxSnx3LsHzJ6pp7kniqztF1/Xayvk9wq3kSyDhhhBy2CIcmj/W5JKxYf8ANNGR0jnPecvdzTkTS9wxugJU/BGZXAAZJSLrXtt7DTQnNQR9Y8fZHgPNOXOvbY6YMYQ6tlG3XgHiVmWuMj8kkknJJ5kp4UW6nQO2yeqksdsoodjYKwtEbaivha/eJpL3/wALRxH8AU5PwjuUbaOZkIJMjWNMgPRx3I+GQPeCoZlTVXWuq6mWZ5y+RxefeTlMGXZPSKUZvNSaF+HTTdIWZB/eOw/Mn4KqMvmp8jjTWimYdnVT3Tn+BpLG/j3iEhUilPG4BRp58yOI5Ep2jk4WSv8AusJVW+bcpyRSO+O6LvMlRBKnYTxOCahWEJwEt0uBzUcycITTpsnmhCkulSe82UYypJkTcoT7pM9ULlPw6Xpwf7SvlP8AhZGP1Kjd5kpq8zAaftLQfalqZPm8D/wpwTSoTZtwrCJ+WhUTZt1a0b+KMfJORhTmvROemg5Je9CMKfbKrhqeAnZ+3x6JN8l9GqKGfkGS8DvcRuqxk5ZIHA4IOVN1R9dZjK3oWvH5fqhIRqoc7fRq2ePkOLiHuO/6qVBNsotzf3r6SoH9rCCff/opMEuCnBG2itWy7oSPyCone7I+9yEqaUGScEpbnY8k+X9VAmfj1vAp5k3E1CYlzvwA8fZ3T8U2QN1EL9sFNwScD3RnpuPchG6t2S5S+PPXdQGyJ9kiekwp0M+NipAfhVnHgqRFPnYn3ITVOZLgqTHMq5r06yTBTEK1ZKnWSqtZMn2y5Qnq0gqOE+SVUxD2m7tKr2SKZTVAcO7f7J6+CEoTlqu9XYbnT19FMYKqneHxvHQ+fiDyI6g4VxrG0UtTRQ6ms0IhtlXJwVNLHyoanmWeTHc2H3jbAznqiMscWnmFbaR1IyxV0sVZD6ZaK1no9dSE7SRnqPBzT6zT0ITgkI6hVdNViQcLj646+Ke490WsdMyaSu4hZN6Vb6hgqKGtb7M8J9k/xDkR0I8MKFTVYmbgnDx+KkBUTh1CniTfKfjlUAPTjJcFOTFZtkTrHqBHLlSGSITSFNbJ5p1r1Ca9Oh+yEYUsSfNOMl3UMPSxJ5piXC2uktSegytpah31Djhrj9g/yUjV1iba5ZLnTt/oMxzVRj+zcf7UeR+0Pj45xUMveNI6jmt/o7ULayD9nVZD3cPCwv3D2+BTT6vrBStw71XLN92KmP0Z5AkG8Lz18lUyNdG9zXDBGxB6K8vVldYK0UoyaGUk0r87s8Y8+XTy26KFVMNbEZAP6RGPXH3h4qwx436Ku9hBwVXB2E6yRMnlsia7BVpQKwilwpkMqqGyYUuCbdNTFbxyqQyRVkUuVJZIlwhWDZPNPxzFuCq5sidbKm4Qr+mlgqsMm+redhK39VcUNyuWmWuY0NrbbL/WU0nrRPHiPuu8x5c8LIRy4V3aLyaYCOT6yE7FpUD2KZruhXTNNX2nkMVTSveaXPBJFJvJDnofEeBV7eqcMkEzcGN/Mj81zKGN9I8V9pcHED6ymcdnt6hdE07doNQ2kxtdhzRs12zm+RHiCqpGNQrIOUVqvc9irRJEeJjvajJ2ePD3ro9NVUupLXxRuJjfzxs+Nw3HucDgg+IBXKqmIgvieMOadj4FO2G/1Fmru8jOTylhJw2Rv8/PokTTqusUU75WuZNgVMR4ZAAQD4OA8Dz5nG4zkFTFWW+up71BFWUzs/ZIPMeLXDx/1yO9mhNQR8SJBCEtBEOSNMQgggghCCCCCEIIjyRpLuaUIRIIIJyE1Uy9zC9+eQ2WeJySTzKtLvNhrYx13KrFI0KF51QxslYyEWd0fJPKhyneqNoQRtQFXKNBBBKgJJG6UgglCcEEEfCjAwkTkWClIIAZQhGBkpSIDCNCEbeSUOaJGOaEuEpAc0BulYCEuEaA5oI28kxLhGggDlGBlCeAhgo+FGghSBABHwpQb4pQbnyRlOwk4wj4UrBR8KZlLhJQSsbIfaTUYRYKGClIIS4ScFDBSkEJcJOCsD2xdrND2T6b9LlaKi51QcyhpDnEjwBlzvBrctz7wBzW8qKiOlgknmeI4o2l73nk1oGSV8+O2LtEm7S9c19z72Q25jzFQwuJxHCNgcHkXY4j5nyCy7hV+ix+r7R2/Vdzwhw8L5Xfzh/Jj1d49zff18AeuFmdRahuGrL3WXe6VDqqvqn8csrupxgADoAAAAOQACrUEFw5JcclfVTGNiYGMGANABsAOiCCCCRPQQQVzdNG6gsdL6TcbHcrfT4B76qpJI2YPLdwA3ShpOoCjdIxhDXOAJ2138lTIIIJFIgggghC9tfRc7UY9ZaMjsVXKTeLPGIyHc5YOTHDxxs0+4Hqu2L5saF1nX6A1TQXy3O+vpn5dGSQ2Vh2cx2OhH8+i+iGktUUOtNN2+926TvKOsiEjD1ac4c0+bXAg+YK7S2Vfbx9m72m/RfMvG9gNrrPS4R/KlJPk7cj37j3jordBBBbK80QREZRoIQgggkk7YQhGeSSgThFxIQjQQQQhAnC5dq2/wD+0Nw7mFxNspH+qRyqJgfa82tOw6E5dg4Y5X2u9ROp2fsqje5lTO3inlYcGGI7bEbhzsEDHIBxyCADhw1kUbY42tZGwcLWNGA0DkAFG49FKxvUoSO5/mok0gYN+Z6I56kM2bu7xVdVVMdPC+oqZWQws3dJI4ADfA3PmQFGThWWhLdxzO2GT5KLcbnQ2OSOKpkdPXSt4oqGAcczxyyG9G52Ljho6kKJNWXC5RObSOfaKQj/AKw6MGqkH7rHAiMct3hztyC1hAKc0rY6OFssscfd05IfUVEj3PlqHgc3vcS55Axu4k4wFXc/uVlrOp2Sm2yp1JA6e+EUdlbuLZC44lHTvnj2/wCBvq52Jeo96u76t0cLWinpImgRU7BhrGjYbDb+SsbzdDV+sAY6aP2IxtnzP+tlmiO9kfJIQBzcTsAFXJVlo6qPVTtbFJLK9sNPG0vfI8gNaBuST0CoWUk+sJ44nU8ptbziKi4T3lcfF46R9eA+19rDcg6e3aTq9Z1MUhhLbbG4PiZIMMeRykf4+LW/E744ep2HTdHp6ImBveVLhh9Q4esR4DwHl88pAlc7CptJaFbZ5I6+4Fk1yb60UY9aOl8x95/73TkOpdqC+GjMsuWteQXSzyO6Dclzj0GPcFWag1VQacpO/qpT6x4Y44xxSTO+6wdT58hzJAyVw/X/AGlVNwqqOhnhqKmqrpOC3abto7yepeN8uAxxcPtOc7DGYB5gEoXJrGOetnrPta7uGdlnnjggY0ma71GAxrepjDtsfvu28AQQRnez/s0u3aM/9ozuqLNpx5MjrjVAirrQdy+JsgyGkb97JnOQQ1wPErqwdl9Dpikh1V2o1FLPVRnvKTT8Du9pKR/2cgj+kzD7xAY0k8LRjjOS7Se2e7a7fLSQF1vs+cCmY71pR4yO6+7l78ZShvVyXnx6sfx/RbnUfa/Yezu1usGhKWB8jMiSvxxxh3IuycmV/wC8SRsPaGw4VedQVd1rZqurqJKyrlPE+aZxcSff+ipq+7RU+WA8Tx0Co57jJMcZ4W+AUoTQ0N81cvuNPG8ukZ6VJ04j6g+HVRau7TVR9Z/CzoxmwCqBMSdtylcTuuyVOT73lxTZcmy/K1eiOzC/a+Mk1DDHSWqDJqbvXv7mkgA5lzzzI8G5I64G6cCozosuCXuDWguc4gNDRkknkF1rTfYdBaLfBfO0a4u0va5PWhtrRm4VWOgjwSwbjOQSOobzVnbdQaU7KSYdG0/+0upcFrtR3CL6qB3I+jRfP1j83tOEml7P9Ra5r3XbUVZKx0uC6erJdI4eDW9AOg2AHJIXgJAxzt9B80Lx2xy0VufZNCWuPR9jJ3fT71k/QOfLkkHGNwS4YxxEKg092b3nUjzUOjNPC8l76urJaDncnfc+9bi4SaR7MYBI+NtRWYy0zYfK7zDeTR5/iuRa47YrrqgvhbK6kos7QxO9r+I9UzJcpPVYMNC21zv+kezhhjt0bNTXtuxqZwDTQnyb9o/P3rk2qNY1+qLjJV3CpdUTO6nYNHgByA9yy090klJLio5rnEeyFpihmHRWPRZT0Vk+fPmkGUnqq700+AQ9Nd90J3oc3cj0SXuU8yZS45uHYclWemO+6Fr+z6ngZVT3+6RCS0WgCWRjv7aQnEcY8S52M9Mc8ZS+hT93zQaSXuW1rqv/ANGOhWUTPU1NqCHjneBh9HSdG+Tn/wA84LQVymSfvn5GzG7NCXqbVtbqu91lyrnNdV1b+OTHJo5NYPIAADyCrm1JGBgYR6FP3fNR+iSnopzckqc2oitFGayYcTuUUfV7lW004GZJeFsMY4nOPgqa6XiS71fGWhsTfVij+61KKKbu+aYaSY6YRz1MtbUPnmdxyvOSf9dE/Tt3LjyH5qGxxa0YHE4kAAcyTyATzpzD9WCPV9og7E9T7vDyCeKGY9ylbRSqaHbqxo5PR7Zcajr3YhHvcf5Aqh9Jf4/gpdXVPhsMMfEfrp3Px5NaAPxcVILfKdyP37lIaKTG4UcypDpVANQfEod67PNPNBJ3hHoT+8Ke0uke1jBxPccBo6lWV+lay7S08bg6KjDaRrhyPAOEn4uDj8VA0/L3dybUOOW0jHVO/IlgywfF/APiq4TuLuJ7y5x3JPMo9Bk/qCT0F/eFfRy8FuqHZ8GqrMmSd0JJ3NtuOI4dJ+QUASE9U70B/eE00L+8Ke1+VNptm5VM2Rw6lSxO5jAOIo9Ak7wj0J/eFNlmySmjJ5qE+Z33ikd877xTfQJP6gk9Af3hT+NEX7Kv74+KHfuPUpPQJO8J3oL+8KeZANzsFDvcxFqsrOvcOf8A4nZUauqHx0cxDuTTj34TF7my+jjJyIqdrfjunCgk7wmmgf3hNtk2Vna5s5aqMO2G6m2+UtlGEvoEneEnoL+8K/4khxUfvnIjOSOQTDRzDYZTDRSjbVB5wc9VNll9L09VRc3MaflzVbJKCM4TtBUNEjo3HDZGlhUBglbu0qF1PK3dqDJe+0/bpOZY4xn8f5BIifgqLbZs6eniJHFDUg/M/wDmnBIo+Ug6hQSMIwSFYB+yAlTDZfVCIyJcFREFOufnISIJuElp6Jt0gymZJOCRruh2KZgpMFWRdkJmZxw2Ru7mb48R1CTDLxDBO4R8fCd0YKQAqXHKHtDmnIIyE82RVcEvdTOhJwD6zPd1CltlTxlPLSp7ZMhLD91CbKE82QHqEYKZylTo5sHdSGvVWJRj2k/DODsXIwUnKVZNkwnWTeahMkHiEoSAHmjBSYKs4pc7J5kiqG1AaQcjbmp0cwIBDsgowU4Aq4Y/0qHh/tW8vMKI7xHMJEU/A4ODhkJ+oc04laRwv5jPIowUuCtdpKrpdV2d+kLrK2ISPMtqrJD/ANVqD9gn7j+RHjg891gbhRVVmuE9HVxOp6yneY5I3c2uCkF/dvBBxlbi9Qt7TdMOuLOE6ptMQFU0H1q2mHKTze3kepHjsE4ZTCCFiKWsFQMHZ45jxUgOws93vA4Oa7BHIhW1HWCqbg4Eg5jxUgOVE5uNlYxyqUyRVocQno5UqYrNr0616r45k+2TKEKYJEtr1EEmyU2RJhKFNY45DmnDvDxVhSVJa4SRkse058wVUiTADgpDXF7Q+M4kHTxSBKumU9TBqyyvpqn+tAGSObXDk4LHzsnoal0cvq1MJw4jk4dD7im7Hd3U0zZYzgjZzT1HgtLfaRl3o2VcAzKwdOo6hMHqO8Cpcdo3xCy9Sxsg72MYDvab90qEdipAl7p+HH1HbZQmgzlzRhw5hXGO0VFzVHDsJ5kmOqjk4RB2FIosK0gn3G6nRSZVFHNwlWNPMHAJwTSFZB+E4yRROPI8wjbLulwmqwZIpEUp2VcyVSI5EwhOV9bbtJSSAscfctXar0YaplfR+rUs/rYM4Erf5rnkcuDlWdHVOYQ5riCPBVnsBU7XYXX7nXsq6OC60rhJSy4bIMbsPn4Hofgq+ZzZOF7HYd0PgVndO6k/Z0zxM3vaKo9Woh/8Y8/HxVnUQ+iTmBkneQuHeQSA+03oquMKbK02mNRS22qMsWzgeGaBx2d5H9D/AJhdYt1yhudK2eB2WnYg82nwPmuAtqu7c2pAy+PaRo+03+Y5rcaWvUtPOzuHhzngcIccNmH3T4HwPQ+WQhNXUEFFt9fDcqds0WeHOHNcMOY4c2uHQhSkIRt5pSTn4IwcppQjQRZCNIhBBBFkIQgeSSggnoQRE4GUaj1k3dwu8ShJsqislMtQ49OQTKBOST1KCnAwqjjqj8EaCGNspVGnuaNqIDdKASZTcIIIwMo+FGUYSUYGUpHwpUYRIAEo+FKxlGU5J4fFKRhqHDnySZS4RYyj4QlcKMNRlLhEBlG3klBqPhSZTsIgN0eQjDUYakynAIAYCNGGpQakynYSQMpQCPhSgEmU4BJDUsBDhSg1JlPARAJaAGEEmU7CCCCLmUiVGgBnmjAyj6bIQhjbCGAhkIZCEIuFAtSkXMIQuO/Sk1odK9mFTRwuc2rvD/QmludoyMyEnwLRw/3uXNeHF276W+qpL32nC1tlLqW0U7IhGD6oleA97veQWA/wLiK4a5TdrUEdBp+/evqrgq2i32eNx9qT1z79v+nHvyggggstd2gggvTX0ZewSC609NrLUMIlpy4ut9FIMtfwnHevHUZB4QeeM8sKzT076mQRsWJeLvT2SkdV1J02A6k9AP3oFo/o29gtJZrPTao1DRNnu1U0S0lNUsyKWPfhcWnbjcMHfdoxyOV3TVGm6PV2nbhZq5nFS1sLoX+LcjZw8wcEeYCsxzSl3cNPHDH2TRp18V8oXK8VdzrTXSuPNnI/3cbAd2P7nVfNDVul67RepLhZLjH3dZRymN/g4Yy1w8nNII8iFUL2j9JvsW/22sp1HZ4M323xEyxRj1quEbkY6vbuR1IyN/Vx4uXEVdMaaUt6dF9RcOXyO+0LZx7Y0eO4/odx8NwUEEEFSXUIL1D9DftBbG646PqpMF7jXUXEeZwBIwfABwA/fK8vKy03qGu0pfaG722Xua6jlEsT8ZGR0I6gjII6glWqWc08okHv8lgX61NvNvkozoSMtPc4bfofDK+miL7RVDoTWFJr7SVtvtEOCGsi4nRF3EYnjZ7CepDgRnrjKv16A14cA5uxXx9NE+CR0Uow5pII7iN0EEEE9RIJJHwSkk79UIRcj4oIIIQgqfUl+Zp+3mYjvZnu7uGEOx3jzyGegGCSd8AHY8lZVNTFR08s8z2xQxML3vccBrQMknyAXJr1eZb5cnVsrSxoBZTxO5xRnB38HOwCfcBvwgppOE9rcqJLM98ks00ne1EzzJNLjHG7YZ9wAAA6AAdFCmnLsgbBLlcXFUtyvBgqHUdGwVVwwC5pOGQA8nSHp5NG7umBxObCTjUq01uTgJy43GG3iMPD5Z5ciKmiAMkhGM4BIGBkZJIAyMkZUBlLJNUsqq5zJalhzFEwkxU5Ix6uccTsHHGQDgnAaHOBFLReivkmfIaismwJal4wXAZw0D7LBk4aPEk5c5xMkbqs5+dldZHjdON3OTuUbZCyihpm7Mbu7HU5T9NCMBzvkoFKye4PjpaWMz1L2hxaNgwH7Tj9kf6GSoFLvoodbN38jY2ZcAcAAZJPl4rSWLQXfhk92biPYtovHwMnj/D8/AaDT2lYLI0SvIqK085SNmeTR09/M/gptdcBDlkZBk6u6BJjqUhd0anJZYaKMNwGADZjRusvqzWUdip2hze9q5ge4o2uwX+LnHo0dTjyAJIBiar1bDpilY9wFVcqjIpqUuwXkYy5x6MbkZPmAMkgHjzX6g7QNUz2DTszai/SBsl1vk8fFT2qI+yeHk5+M93Dn9522S5pPQJ7GZ9Z2yRd9R3rUurf2FYKePUGtKmMOf3uWUlthPKWcjPdxDmGD139Mklx39mtemvo6UNRWS1D9Ta6uEYFXdaoATz754QBtDCDjETdthniI4k3V3LTnYDpqTT2l2Gpu8zjLWVtQ/vZ55j7U08nN7z8hyAAAC4XfNRzVdXLVVczqipkPE5zjlOGG7bpTmTwb9Ve6t1rX6pr5LjdqoyPOzW5wxg+61vQLD3G+PqC5kOWR8s9Sq+ruL6t5c52R0Cil6UFLjCcc4k+JRCPJ9Y/AIew0OceAHlnmfcEh0mGlxPdt8/aKdlCeL2s9UDfwH6qx07pu76xujLdZbfNcq1+/dQN2aPvOcdmjzcQFr7X2V0mn7PBqHtGun+x1ilOKeiLeK417ujIocFzeY3LSR1aAeJba1y6k1za3WfSNnd2b6JkPrNYSLnXDlxTygktyNi0OLseqXEbAJ5dSmDLtlQN0rpDsvqRHqKZutdVx/8A9P2yTFJSu6ekS43PL1AOexa4HKvxZ9bdrIp/2xLHabFAR6Pb6aLuKWBo5BkQ546FxJGTggbLe6O7I7HoymZ3NKySZm/eSAbHqccgoure1S16eY+One2smYCCQ7ETPeevw+ai5y7ZSBrW7anvUqw6JsWiKUztYx0sYy6rqSPV92dgua9pHbvHT95RWI95J7JrHjYfwj9T8lz/AFz2uV2pHvjExkZ0x6sbfcOvvK54+Vz3FzzxOPMlStZ1KY4qXcrvU3OoknqZnzSvOXPe4kn4qufJuikfnKYc4FTYUaiOduUniSC7f2kjiXaDZdQNk7xFAuwm+NJL/NIhS6WnlrqmKngYZJpnNYxg5ucTgD5rQ62ucNFBTaaoHh1JbyXVEzOVRVEYc73N9lvkDz2Uey1J01Z5r3nhrpuKlt/i04xLMP4WnhB+84+CzDDv5JyapEfLKkRRl7gAM52TdNGZHbcuZR3OtFvg4Y9p5Bhvi1vV3vPRKAmk9FHvNc1wFJCcxsPrOH2nfyChQjHPmeaZYQcbqRSRyVNRHDAx0ssr2sYxvNzicAD3khKkAVhTRGCjmr37Bru5hH3pCMk/3W7+9zVXh+SrTVsscFfFaqd4kprY0w8beUkpOZX/ABdkD91rVTcXVCkAwpDX5Ui/Sd3DQQ/dgDj73OLvyIVe2TcBP6lfi6SR9Imtjx/C0D9ENSOUASc0C9NtQc/ATuqaFcwPFNp+qlIw+qmbA0nb1GAPd/xOi+Srw5Sru7uI7fR8vR4GueP33+u74gOa3+6q4HCbhOwplS4so6ZvjxOPzx+ijwRyVErY42GR55AKX6LLcKuGnhHFwxty48m5GST81q7dbIbbFwxjLz7TzzKp1NW2AY3K6eyWCa7O5z6sY3Pf4Dx+nyVXQaZAa11U48X3GHb4lW7LfTR8oI/eW5KkILnZKmWU5c5eyUdmoKFobFEM95GT8T9tE36PF/u2f4QkS0FPOMPgY7z4d0+goQ9w1BWk6nheOVzAR5BZG8Ws26UOb60Lz6pPMeSreNavUwZ+ynl2MhzeHPjn+WVjS8LpqOUyxZduvCeI7fFb68xwaNcA7HdnOny+CYukmaZkYO8sjW/jn9FHudR3te852ADR8kVdLx11DH4Oc8/DA/8AEodS/iqZTz9ZaS5VSWvyGqZRSfWNPmq1jsge4KZSH1m+9CFdB+UOJMB6MvQnpx3Ipnj4HBw+zuld5um3kbhCTCjwSiKS6w9HR9634H/NONkyFX1Upir4XfZka6J3xacfiE/TycUbD4gFOCY7oprH7e5KJUdknCrOjslbWgObFwMP25Nh/NMe9sYy84UtPSz1b+zgYXHwGVFJwmpDxtPjzV+NJzkbzxg+QKbfpGpHsTRO/iyP0VUVlP8A1rZPDd2Az2B+X6qjhnOAeoUxzuNgcEKjTdfR8UndCSMDJMbs4+HNRaabB4SdjuFZZIyQZYcrGqKSoo3BlRGWk94x8EqoBdGHN3kYeJvn4j4p2KcSsa9py1wyEh54SosL+4qJIeTXfWM92fWHz3+KkVcK0EoPVPMk6KC1+UtkmMY5JcpSFYB2UfFjdRw/ZL405MU6KTiHmnOJQIpeE5UsPBaHAoSYSy5P0k2DwE+YURzshEHEEEHBG4KEqumHp1UmJ4cHMd7LlX08/fRBw2cNnDzUljhgEJialNPESx2zm/j5qZZbvU2O5Q1lK/gnhdkeDh1B8iNlEnY6QMezaQf6wklji0OLcHG4TDNG08pcM+a0WUFZKztI4XFveGkj44VxrmzU3DBfbYzgttc48Ubf/Z5ubmHwHMjyz0AWRZKYngtOCORC2OmrvDCKm2XDJtdc0Mm/7J32ZG+bT+Hisve7TNY7nPRVAHeROwHN9lzebXDyIwVP0WYRj1SptJcnTNDS9wePPmprK6Rp3w73hZmN5a4HJ26q1p6jvQA4+t0PimmKN+7VWfBG7doVwy64P9X/AMSksuuf7P8AFUjXJ1knCovRIf6fmVD6JD/T8yr1t1Z1Y4e5OtuUR55HvCo2v4gl8SYaKIphooitBHc4WH28+WCnm3KCJ3eMfxR/aGDkLN5wlir7nfr4BV30kEbeZ7iB+/BWae0GrlEMALnHYDC1TrhCwiohlyftANO48VqtPappWtDHTZjd+6diuWQ3TupSQzDDzbnZWNPOIXCWI5icdx4FRwwU1QMRuJ/fkrtbw7U2tw9KYW521BHxGQtxfn0kM5kjkzFJv7JwD8lW091p2+o6X1h7JLTuPBCmq2VtN3UhyCMAqkraZ0ErmZwWnLXfkVOyiiGmT+/csl9viIyCf37lcz1tOXZEmPHYpg1sJP8AWD4qrjnE0fgRs4eBTMgwVa9CYRuVSdb4xsSr1kzX+y4H3HKl0tRwu8lk3ckGuwUnoPc75KE2/ud8v7rfxy5GUZfg7LHU1S7GASPcpQq5m8pXge9Boj0cojbz0ctXHNnZSY5cLHNudQwgiQ/EAqRHealw3l3/AIR/JRehSd4UfoEneP37lru8xgqdTT5GR05rEG8VO31v/CP5J+lvlVG4Hvduo4Ry+SiNBJ3j9+5KKGXvH79y6HS1fCRutFbbp9S2mkPqNdxQuP2HdW+4rlQu9UwgibIO4PCP5KwpNQVZbwmbI/hH8lXdb5O8fv3KcUMveP37l1iR3cSNkH9W/r4KzsdWIpfRicNPrxHw8R+q5vadS1lTG6klnzkZYS1u/wCHNOfty408gZ3+HsPEx3C34HkoTb5e8fv3JRQy94/fuXoq2XKZsf7RpWOmmYAKylZu6Zg+2wffHT7w9U/ZLdjS1UVbTRVFPI2aCVgkjkYctc0jIIPgQvO+n9c3GLu546jDuRbwN59RyWrotZV9pl71lV/0ZVycTh3bfqJnHcnb2Xk7+DjncPJanoEveP37k40EveP37l2RHxLnw1TdD/7V/wDY2/yQ/wBqbp/9Vf8A2Nv8kegS94/fuTfQZO8fv3LoPEjPJc9/2pun/wBVf/Y2/wAlsLBVS1tpgmmdxyu4suwBnDiOirzUr4W8ziFDLTPhbzOIVjxIkEFVVRBBBBCEROFV3GXiPDnYKfPJwtKpah5e8pzRkqN5wE0TlBBBqmVNKQBQQQhSwzdKEalNg8ksQ+SgyrfZhRBGT0ShEpYg8kfcoyUdmFEEXkj7pTBEEO6CMlHZhRBEgI1L4Aj4G+SMlHZhRRGlcCkcDfJHwtRkpeQKOI0YjT/C1Hwoyl5QmOBH3ae5IcSMpeUJru/cj7tO+5F8EiXASeBHwJe/miwUJUng3R8KNBCEQGEaPhQ4UIRI9/NHwoYCTKEkBKAwjQSZQiwEaCCRCCCCCEIIIKo1fU+h6SvdRlw7qhnkyzmMRuO3mkJwCVJGwyPawdThfPDtAv51Tri/XbiDmVdbLLHg5AYXHgGcDOG4GcbrPoILzdzi4lx6r7chibBG2JmzQAPIaIIIIJFKrPTFhn1TqO2Wemz39dUR07SG8XDxOA4iPAZyfIL6UWq2QWa2UdBTN4aakhZBE3AGGtaGgbADkByXkH6HWlWXbX1fepQ4i0031eBsJJctBJ/gEm3n5b+yV1toi5IjKev0C+dfxFuPb18dC3aIZP8Amdr9MfFBBBBbq8kQXg36SHZ87QvaTWyRR8NturnVtMQMNaXH6xg6DhcTt0BaveS5d9Ivs5/9IPZ3VejRd5dbbmspMD1nYHrxj+JvTxDVm3Cn7eE43GoXc8HXj+EXRvaHEcnqu8M7H3H5ZXgpBBBcOvqxBBBBCF6a+hprhsFbd9K1U5AnArKKN3LiAxKB5kcBx+65erF8ztLajq9I6it15oHcNVRTNmZ4OxzafIjIPkSvopofWFFr3StvvtBkU9XHxd245dG4HDmHzBBHwXW2qoD4+xO7fovnP8QbM6lrRcYx6kuh8HAfcDPnlXqLkER5oE5W6vJkM+CJBBPQgggs9qq+PtcDYKdwZWzhxa/GRDGPakI8sgAb5cRtjJBslAycLO65v/pdQ63U7v6PC4Gdw5PkG4YPJuxPngZHCQsk4k79Ub3Nc4hgcGDlxEk+8k7k+JKobtWSXCqfb6aR8UMePS6iMlrtxkRMI3BIOS7m0EBu7uJlcu6lXWM6BJuF1lrnyU1vk7qNjiyatADsOGxZGDsXA83EFrTthxDg1mlpIqKAQwNLI8lxy4uc5x5uc45LnE7kkkk7kp1kTIomRRMbFFG0MZGwYa1o2AAHIAIEKq5xcrrGBqInCcibxHySNgN9gOqvbLp19aGy1XFFTHcMGz5P5D8T5dYt1KdBkqPQ2+quznRUp7mIZbJVkZDPENH2nfgOucYOvtNopbHRtpqSPgZzc9xy95+849T/AOQ2T8bGQRtjYxscbBhrGjAA8lGr68U8ZAcA4jn90I2UBcXaIrhcOAGKM4d9pw6eQWM1drCj0hbBVTjv6iUmOlpGuw+d/gPADmXdB4nALerdY0WlbNNcq5zhTsIZHEzeSokPsxsB5uPyAySQASOH0H+0PajrAQ07WzXupbhxBLqe2U+eQ8hkZJGXuwcD1WiMk7dVPGzOp2Cn0dPqLtI1VLbrbO117qQ19fdXR8UFsg34cN6u3IjizuSXOPtOOpv2urJ2T6d/2Q0ON43OdW3RzuOSaZ39Y9z/ALcjjzfyHIchim1ZrS3aJscmjNGTF0AcTc7y0/WVkp9vhcOeeRd4bDYZPJKyYkhnRLnk0G6lI58Z26D9VLr7vJUF0rnF8j8kvccn3krMVVU6d5OTw/mt9qqlg01oagt7o2m7XN4q53EevFC3IYzyySSfcsBDSS1dQyGFhfI84ACYdNE8a6pFPDNVzCKFhkkPQfmfJSD3cO0LmzvHObmwfw+Pv5eGVZS07WQNttCHTNlIbLJE0l1U/wC60DfgB5D7XPktjQ9mtv0zRQXXXVVLRwSnFNY6H162sd0ZgcvMDlndzU4eKZvsshpPRt51vcJaay0ZqXxDiqKyZ3BT0zcZ4pZDs0YycbkgbArcaSr7fY7o639mlth7QNZQu4ZtWV8ZFntjuR9HH9q8dHAnoQeElq2dH2cX7tToqejvUH+x+hIsGHSttdwOnGc5qZBu4nmWjA5Zycldm05pS2aVtsNBaqKGipIW4bHCwNa0fBHaAbIIH5lzfRvYQ2O9f7SaxulRq7Vcg9evrsFsQ+5EwerGwZOGtA5ldFvV3tekKMOqniM4+rgjxxu9w6DzVFrDtNpLHBLHRSMdI0evUvPqM93iV5q1r2lVV4qJvRpXuLyeOqkJLne7wUYy8p/KcZOgW37Te26SoElLG7uYjypIXbnze79PwXCrtequ8yl9RJ6uciNuzQospc97nOJc49SU1vlW2MDVE52dBsjGAkuKWzjae8aAOHfiIGB801U3CWUEGQ4PPGwUoUKamfgeCjPekySEnx96YfInITLjuUgvATT5Mk7pDnLsRsuoGyeMqft9NJcq2npYiO8meGgnk3PMnyA3PkFXukUq3VjqRlRM04eWGFh6guGHEf3eIf3glQVY6lu0VxrwylyKClYIKZp+437R83HLifNVsDvWCjcasbLTGrqgNgGDicTyAHVG5SEYCsg+O20DqifZrR7PVzujQsdV3CSrqHyvOXOOSeg8gpGpb2LlVhkB/okPqxj7x6u+P5KmB4k8pgCmwVBzjxW20m39i2qv1NJhrqU+i0IP2qp7T6w/gaS73lqxltoZ7jW09JTRmapnkbDFGObnOcGtHxJC12vrhTw1FJYKCQS22ysMDZWjAnmJBml/vOBA3PqtbhMPcnAY1WaY/fxQdLk46Jov4WnB3TQf4oJTgp9CO/rYI/vva35nCTeqjv7rVydHzOcPmlWP1r1Rb8pmH5OBVZUTccznE8ySladEhGqUXqTa6dtfcqeB5xE5wMh+6wbuPwaHH4KvdKrC0PMVNcKr7sPctP7zzgj4sEiVKnKytdcKyeqk2fNI6Rw8C45x+KTEx00jY2Auc52AAoPGFr9JWzu4TWvHrSZDB4DqfwUE8wgYXlbFptz7pVNp26DcnuH7081cW+3soGP4d5JDxPd4n+SloLKah1LxF1LRv9Xk+VvXyH81zMcclVJ49SvbqqrpLFSDIw0aNaNz++pVldNSwULjFDieYbHB9VvvP6Kil1LXSvyJRGPusaMKlBwlcZXQxUcUQ2yfFeP13EVwrXkiQsb0DTj57lXtPqirhkaZHCZg5tIAz8QFbN1dRd2HFsod1bwj+axZKSSkfRQyHOMeSWk4kuVI0tEnMD/Vrj37/ZW94vj7o9o4e7iafVb+pVS6T1sJLn4TXHmVo81ajY2McrRoufqqmaslM87suPVR53h13H/Zwg/4nH/7VRC8ufIf3ilPk4rjWEfZ4Wj/AA5/8SjMdnvD+8pxsqZUth2HuU6lOHM96rWO2CnUx/q/ehPVoH4Q70nCZ4somu2CEKSX43SXSYKac/mkF+4KYmqvu+RG9w9qMh4+G6l2eKSvEcUDC952AH6puSB1XOIY2F75BwhoG5W/0pp1unbXHE4iSqc0GWQeOOQ8gqlTUinb4nZdHZLLJeJsbRt3P2HifklWfTkFuaHyhs9Rz4iNm+7+auEFAuN9o7Y7hml+s/3bBl3+S5lzpah+TqV7hHFRWin5W4jYOp0+JO5U9BZWTXLeLEdISPF78H5YTf8AttP/APU0f+IqyKCoP5fmFjP4qtLDjtc+TXfotcstq63Ni4K2IcJLsPA6nGx/BXtpuLbpQR1AAaXbOaDnBTd/iEtoqR91vH8t0ync6CcA6a4KnvEEN1tT3M1HLzNPkMj47e9YsPD2NI5FRa8uZE2doJfA7jwOZb9ofLPxwjgfwOfEeQ3b7inCcHfcHmuuXzyEoSA4c05a4ZBHUJ2OTOyrKImNklOfagPC3zad2/ht8FKbLslBT91PjkyE8HZ9yr2y8LsfFSQ5PCYQpAO6kU02/AevJQGydPBOB56HB5gpU1WHFgkIuJSqW2T1TGvcO5B6PG/yU2OyRtIL5HPHgBhUZK2CM4LtfBdNScN3SsaHsiw09XYHyOvyUK3mQ1A4GlzXbOx+auooQzmc+SVHEyFvCxoaPJLWFU175vVZoPmvTrRwpS0GJan+ZJ/0jyHXzPwCCCCCyl3SRJHxDI5qwrIzqWxcPO5W2PLD9qWAc2+ZbzHllQkqnqpLfVxVUJxJE7PvHh8VuW+rLXCF50Oy8z4ssLZ4zcKYYc32h3jv8x17x5LNNcCcdCnoJTG/B5FWOqLbHR1UdXSt4aCsBfGB/Zu+0z4cx5e5VLT3jP32/iF0y8YKtWS7gHfO4PipAGdwqunk7xnBncbgqdTTcTcHY+CeCm7KawcRwOfh4pQf06ptu/NPcIcPXJ/iHMe/xQlRh2QmXHicSlvY6PnuDycORTa527S+zEPNet8DUQ/nVh/yj6n7IK0t0LpqVz4N5ozh0ZO0jf5+aq1YW2d1MQ9vPOVTtefSNO4re4zDP4X62/MMeev2yrW11rZGNcxxwdsHYtPUHwKsqiUVEYcd3N294VHc2ijcLpTNJhdgVMben73vHXyU+GdskbXscHNcMgjqF1pHVeEg40UWpBppRI32HbO/QpZeHp2QNkaY3bgjZQGOdC4xu5t6+I6FSMPQqB7eqcOyLiQLg7dFzVhV056Uyn9Z7uEINvtO5wBD2j7xGwVNVTmeUn7I2ATK5Kou0gkIhxyj5r2u2cEUrqVr64ntHDYHAb8tT39MrXNe2WMOaQWncEINkOPNVNjmPdyMPJpBHx/8lYP9V3kV0dNN6RC2XG68pu9vNrrpKQnPKdD4EAj5FSWT8QweadjkwearuLhdjon45chWljq+o5u+j7sn1hu3+SlRSkEFZ+CpdFICDggq5bK2RrXt9lw+RUZCkBVxTVJYWuDsEHIcOhWrilbd6ISNwKiP2gP9cisLBNj1SdjyVnabs631bXA5HJzfvDwULm5TwVqbTW9xUAE4Y84I8D0W3tdczu3RSsE0EgLZInAFrgdiCDz2WGq4mPjbVwHihk3dj7JVzZ64yxDiPrt2d5+agd3qZuuhW+ttW63PjpJ5TNTSHFLUvcXOP/Zvcdy4dHHdw55cCXXecrHW2uie11LUtElNN6pDuTT0Plv16c1fUk8lHM2jqXmQuz3M7v7QAZwf3gAT5gEjkQEBTS3CtF0DS3/qGl/vf8xXP10DS3/qGl/vf8xWfX/4Q8/1WXXf4Y8/1VqgggsFYaCInCNNzP4WlCFCrJtlWPOTlSaqTJKiHkpmjCrPOUPlhLAwEjxS05QIcwjaED7KDeaELQ8KHJK4UOFV1oIkEfCgBhJlCJDGUrAQAwjKEnGUMYS0EZQkYKGMpWAjRlCTwocKUgkyhJ4coEAdEpBGUJCVgI0EZQiwEaCCRCCCCCEIIIIIQgggghCCCCCEIIIIIQgggghCCy3ar/8ASv1h/wC56z/5B61Ky3ar/wDSv1h/7nrP/kHqOX/Dd5FXqD/a4f8AM36hfOJBBBecr7XQQQQQhevfoWUzGaN1BUAfWSV7Y3HybG0j/mK9Erz39C//AOgO+f8AvI//ACTF6EXd0H+zM8l8lcXkm+1We8fQIIIIK+uPQQQQQheC/pF9nP8A6Pu0Sq9Gi7u1XPNZS4HqtyfXjH8LungWrlq9+dvnZf8A+lDQ8lPTBou9C41NE4j2nAetHnwcNveG+C8CvY6N7muaWuacFpGCCuIuFP6PMSNjqF9VcHXoXe2ta85ljw132PvHzBSUEEFmLu0F6H+iJ2lOs+o59JVs2KG5ZlpOLlHUNG7R5PaPmxoHtFeeFIt9fUWqvpq2kldBV00rZoZWc2PaQWuHmCAVYp5jBKJB0WNeLZHd6GSjk/MND3Hofcflovp59lEqfRmpItZaUtN7g4WsrqZk5Y12QxxHrMz4tdkfBXC9DaQ4Bw2K+N5Y3wvdHIMOaSD5hBBBNTSx08TpJHNjjYC5z3nAaOpJTlGod7usVkt01ZM172s4Q2OMZfI9xDWMaCQC5ziGjcbkLnN8nn45vSnNfcJi19W6MktYRuyFhPNrAfAZJc7ALitLUVZqGSakrYnCnpWn9l0kvquLnDgErgfZfJxcDQd2tcQeEvewYeuLoWhkj+9lPrySH7Tick/EkqN2ysRt1VdW1LqeAmPHeuPCzI24vH3Dn8FWwUzKaERMzgEkk83OJyXHxJJJJ8Sn5HmoqXO+zH6g9/2j+Q+BRlqqOOStJrcBNcGU3w8bgGgnoABkkqUyCSeRsUTC+R5wGt5laq12WGzME05ElURtjk3yb/NRbqXPKMlQbRpxlI1tVXAGQbsiO4b5nxP5LQxZxxvGCeQ8E3HG6V/ez+0PZj+7703XVgpWnJBefwTcqJxJOqKtrmwMOSAQsffL9SUFuqrrcqgUlrpRxySuyc7gAADdxJIAaMkkgAElSZ5pbxcG0ULjkjjlcPstXnntP7QJNbXmlhs8bq60xTilsdFC7H7QqXZaagnkW7uDCdgzifk8YDYXuwMqWNnMcBNXK53ztb1vSU9JSkV0oc2gt73Ax2+DID5pXDI4jtxEZ6MbxYJfpNVajoOz+wz6N0nUGWWQ/wDTN8G0lXJyLGHOzBkjAO2SBnLi5Vc6Hsa0zLYaCqbVavujRLerrHzjBG0UfVoAOG8iB62AXDHK5aljGukO0bNgB1KPYGOqn0fjHsj5+KcFXFQOidJEJm5B7ni4eIe/olCqj7x1xfHEx5eDFSsGWjG+/l+api580jpHnL3fIeSVGA92M+q3clNBwpMZU69XKt1PdX1dS4z1c7g0NY3n0DWgfIBTrLpmtrNQ1dho2NdW0uBc6knMVHn+xLhzfzy0eGOQdjpWmNIyaE0tS3khjdc3xj2WGCZnE23w4AlrpGnb1GuBaDsXOjbzf6tlofs/fU0EOntONfBaadxdV3SYl0lRKd5JHO5vkcdyflgYw4+pvuo2nmzjYJjT9up9NubQaXoBedSzgsdWzjLYfEnwA+6CPMroui+yWnsta69XuodfNRzD6ytqNwz9yMcmtHQDC2WmdIW/SVAKeiiAcQOOZ273nzP6dFD1VrW3aVicJXieqxltOw7+8+AURJO6QOz6rFZVdTTWykfUVEjKenj5uccfAeJXFu0jtpiihdT0xdFTuOGRM3lnP8lkdcdo111VcTS0w9Jqh7MLTiCmb9558fLmVzmvkhtskj3T+nXB20lU/kPJo6BKG53UrWhmp1KTqG/Vt5k7ytf3bAcsp2nZvv8AErMTy8RPglVlYZXHdQZJFbaAAonEk6pZy44AJJ6BCQR0+8jg9/8Au2nl7yoz5C7xUd71IFEU7UVT5dnHDRyaOQUOSRCR5Civk3SpiU+RMPkSHy4ymHSp6Eh8mE05/mkOem3SrsRsuoGycc9La/1Gt6D1j7z/AJYUN0gAJPIJ9hLWgO9rmfelTgngcKXda82q3CgjJbVVDQ+oPVrTu1nkSNz5EDqm6AxwRy187Q6npsYYTtJIfZb7tuI+Q81nqqqfUzySyuL5ZHFznHqTzKUJD3Jp0nM/JKgH4plxwAPFSKdkkskcUTDLNK9sccYIBc5xDWtGepJA+KckW30bI6wWq4akyWVUWaC2kcxUSMPHID07uMkjpxPaqGppRT0cUmQ3jJDGjq0cz88D5q61LJGyopLLTSNkorOx1K2RuzZp3O4p5RnfDn5aPJjVU3+obLWhkZzFC0RNxy25/jlN70Y6quLsNx0RB6bLsoZwmlOCtbA//peB33eJ3yaT+ipppMuOFZ2V/DcAfCKU/wDA5U07sJQUY1SHPPirVrvR7BA3HrVE7pHDxa1oa0/N0gVE93Ery7HuGUNMf7CljGP4h3hHzkKEuE7Y7c+63COLB7oHikcOjf8APkukgBoAAAA2ACptJ2v9n2xsj24nn9d3iB0Hy3+Kb1VfxaabuYnYq5R6uPst8fzXO1D3VUwjZsP2SvZrNTxWG2GrqdHOGT3/AO63z+5ULVWojG59DTnB5SyA/wDCP1+Sysb8kKK6Vz3FzjknmT1S4XevnwGVuQxNhYGtXltzuE1zqDPKfIdw7v3upJduUONNF2N0A/CsrITxfhIL02X+aSXeKahHI/ZMQvzUtHmhK/ITNO/NUz3/AKFOCQqJBJxVFcf+3cPkAP0SIneq8/vJulfk1bvvTyn/AInD9EcD8xu/iT0zqpYPqhT6d28I8XKvb7IUyndiSH3hCcrBruLKbEmMbpMb8j4JsuwQkQpHEHE+4/ko4fkD3JUbsu+B/JXGjLIbjVCqlafRoTkH7zxjA9yilkbEwvd0V6io5a+obTxDU/LvPuWg0nYvQYRVzD6+VvqtI9hp/UrROIAyTgYQXNdca3fPWutVIeCmbtLKD/WHHIeX5+7nzDWyVspP7AXt809HwzQNaOmw6uP73PT4BXGotZB2ae3SdcPnH5N/n8lkxMXvJc4ucTkknJJUCCXiaE6XYBI5jddLDAyBvKwLxS43Opucva1DvIdB5BWDJE5kuUOJ+RvzUljshWQsnC1uiKn/AKzTk+EgH4H9FpaqMTU0sZBIcwtIHmFidHyll4Y0fbY5p/P9Fu1yte3kqCR1wV7rwpJ29pEbvylzfv8AdcrMwLYJwdj6jk8526gwASRVFOOYJLfepEM3fwMf94b+9dQvCSMHCTM7uquCbkH/AFL/AI+yfnt/eTuSxxCanjFRC+JxwHtxnwPQooZnVEDJHDD8cLwOjhsfxSoCeL8EHzUqCb1cdFCPrNIRwy7A/BKCghWXH1Wk09bAIxVStBcd4wd8DxUSy6dMwbPVAtj5tjPM+/yWnADQABgDkAsOvrAR2UZ8z9l6lwvw89rxXVjcAeyD9SPp8e5Ggic4MaXOIaBzJVVWagijYfR8TEHBd0b/ADWNFDJMcMGV6NXXGlt0faVLw3w6nyG5VsgsmblUykuM7wT0a7A/BLbc6pvKd3x3Wn/C5Me0FxI44o+YgxOx7v1WpQVJQXeZ8ojlc13FsCRjfw2VjSVwqQQ4cErTgt81UlopohzEZHgt6g4mt1weImOLXHYOGM+/UZ8MqUgRkYKCCoLqSARgqRQtjudDU2id2A/1onnmx45Ef68fFZF4lpZnxzN4JonFr2+Y/TqPermqqzRVsUjTg4H5p7VFKyshhusIHrAMmA+Qd8OXxC7mmkMsLXndfM94pG0VdNAzYHTyOo+CpY5Q17XA+q78Cp0b8PDhyd+apmP7qQxnkdwp8EvEwg8xzVtYuFcxPyAFIYeIEH4FV1NLxN35hTI5NwhOCVxvaDGSeHOcH9ESU9xcd+mySuJrZe1ncRtt8F9G8O0ZobZFG4YJHMfM6/IYCClQOHAPJRUuNxiePuladpj1dJ7v38lxvHNV6sNIPFx+g+6uaGrEBLHgOieOFzTywolGTZbkbe52aWXL6VxPLxb8OnkkMfgc0K6D9pUJh4uGZhD4ZOrXDl/rzXR+C8jPereQnG3MbhRqv14+9aPWbzHkmbVcv2lRB7hwTNJZKzq142ITxdwP8nJRoUx2oTEcmcb5CXK7hge8dAoh+omczoN2+5KqJP6M4eOPzSzyckL3dwKt22AVNfBCdnOaPdkZUBBBBecr6qVrYuc56YH6qzk3Z7lU2eYRPc07B5wCrUnIXeWwYpGe/wCpXzbxc7nvU5H+7/2hMSn1QfBKjk5JuTYkJthwSPBai45T+PkrG3VO5jJ2PLyKp2vyAn4nkOBB36JCEoOFomvzt1TzZCTvzChwziVjXDrzHmnmvHyTMJ61umb22nJgnPFTybOB6HxV+1jrRWNyeKnk9h45EeHvXOqebhcCFttPXeGtp/2fWnMTtmPJ3aem/TyVd7cahSNK1cc2Bzy0rX2Wsju1vfS1A7x7AOpBIBy1wI3BBAwRuCARusBRGWle+hqDmaIcTXdJGdHD8j4K3tVe6grY5QeRwR4jqFW2KsEcwW4o6h7JTS1DuKdo42vwB3rM4zgbZGQHY6kHABAXUdLf+oaX+9/zFcvqYRcKaN8Tw2QYlikxnhdjbI2yMEgjIyCRkZXRdEVYrNOUznN4JWucySMnJY4OOR+oPUEEbEKlX/4Q8/1WRX/4Y8/1WgQQQWCsFEThRKqTAUl7sBVtXJkpQNU12yhTOy4prO6UTkpIGVOFVO6UleCS1KQo0f2QjaEPsoDkhC0iCCCqLQQQQQQhBBBBCEEEEEIQQQQQhBBBBCEEEEEIQQQQQhBBBBCEEEEEIQQQQQhBBBBCEEEEEIQQQQQhBBBBCEFlu1X/AOlfrD/3PWf/ACD1qVlu1X/6V+sP/c9Z/wDIPUcv+G7yKvUH+1w/5m/UL5xIIILzlfa6CCCCEL2F9C//AOgO+f8AvI//ACTF6EXnv6F//wBAd8/95H/5Ji9CLu6D/ZmeS+SeLv8A65Vf5vsEEEEFfXIIIIIIQgvGP0ruy9uk9Uxait1N3Vruzj33A31I6ncuHlxj1gPEP8F7OWW7T9Hw670JebNIxrpJ6dxgc5ueCZozG7kT7QHLfBI6qjW04qIS3qNQus4YvDrLcWTZ9R3quHgevu3+XVfOJBKex0b3Nc0tc04LSMEFJXBr65QQQQQhe0fog6gN07Mp7a94L7ZWvja3IJEbwJAcdMudJ8l3JeSvoXX30fU2obO52BVUjKloLusb+E4GOeJfHp16etV3duf2lMzw0+C+T+MqX0S+VAA0cQ4f8QBPzygs3M8aouUlKwk2ijkLahwb6tTMP7IHqxn28bF2GE+rIxOajulT31Nabc8x3GtDj3oaHCliGOOY5BGRkBoIOXOGWloeW2lut0Nqo4aamZwQxNDWtyXH3kkkknmSSSTuStJcXss9rao7yaiox7DS6pkxuMNHC1p95dxDzjXMrtWkd7KBxEbtb4nk0fkFrb/cRXVF2rGuDmiQ0cbhz4YiWuB8xKZfhhYWc+kVsMXRuZX/AA2A+Zz/AHVBIcBaEDO9Lgh7mFrCeIgbu8T1PxKfgpn1MrYo2l73HAARtjLnYAyTsFq7LaTSM2Gal49Y/cHgqoCtudjVHbrbHamcEYE1W8eu/oPIeSe4cTFjTxyj25OjfIeafqXilzTwO+uP9ZL93/P8ufhlhz2UcAwMZ9kePmmu7lGD1KFVUMo4Sc8lhtSajbRxmQ5fI48McY3LnE4G3xUrUt/ipYZZppQyKIHJK5vZdS0z5bzri9ZbYNPRl0cY5y1BHqMb4uHE0D9+RvgoScnClY3TmKj9r+pHadsMejoKgsu14h9KvlVG/empDkd1kcjKQ6Mb7NbKdjw5x+gHwaVsz+0SugAr61r6PTFC9oHdwnZ9Tw9OPny9gNGfrFnLNbK7tV1lML1I1huMjrpfpuLDYaZoA7hrujQ0MiBz7IJ8U9rPVx1XeZbiyMQW6Jgp7dTBvCIqduzduhdzx0yB0UYOvN8P1VnlwOXv1P6KoutxmrqmV80rpqiZxkmleclzjuSSqh8vfPGP6tnsjxPikVFQX5aPtcz4pviLfq495Op6NCaFJsnnyE/Vx+39p33R/NdO7K9GUNJbpNa6oif/ALM294FNShhfJdKnOGRRs+3l+G45OO3IOxF7Muy+C8UD9R6jkkt+kKV+HSYcZrjLnAhhAGXZd6p4dyfVbvnh9F6c0LUaiulHfdQUTLdTUTDHZdPs4e7t0ZHDxv4fVMzm7HGzGnhaTlznOGmvXp+pUbiMEZwOp+wWU0poi/a+ulZqDU7/AEepuBb6QIn5EcLS4xUsJ+4wOdl32nue77WB2KjttNaqOOmpYWU9PEMNYwYACsGsbGwNaA1jRgAbABcq7SO0ZsLZKCgflvsvkYd3eQTT6up1JUYJlIa0YATuvO0yK1Ry0tvkaZB6r6jmGnwb4lcUuU1RcpDPUve1shJaxzvXlPi49GjrhSK2obTN9LrnZf8A2cWeX+vFYi+36ardIOIta7Z2PDw9yjGXFXGtDBgJN/1DDQ0r6G3Yax39bM0YLz/JYOqqTITk/FSa+fOXOOGZwPEnwVfJSucO8qQWR/ZhB3Pv/wBfNWGgBRuKjOl48lvL7yRwdTuU+/c5wB4AcgpFmsly1LdYLZaKGoudxm/q6alYXvIGMuOOTRkZccAcyQFMFAe8qtkdgYVhprR961pVTQ2a3yVggbxzz5DIYG4zxSSuIYwYBPrEZwcZXQrv2daX7I4my9oNf+2tQ8Ikj0hZajhLcjI9LqR/Vggj1WetyLS4ZXP9YdqN61vFFa5HU9n09AeOCw2mP0ejiAOeIsHtuJ3L3knJJGM4UoGN1EDzezsqO+0bbTc56NtdSXEQnhNVQPc+B5xvwOc1pcByzjBxsSME1EkhRzSgk4GB0Ciyy4GM7pQnInybpp0ibdIkF+U5JhJe/dNPlSZJM5TI45ZGMjaXvc4Na0cyTyC7EbLqRsn4TxvLj7DME+Z6D9fgpNNHNW1MUEDO8mleGMaOpP6dSegBKjEtYAyNwdG3P1g5PPV3u228gFYun/YFo77dtyuEeIQDvDTnm/yc/kPBuTkZwjKAMqNqKuh7yOhpZBJSUuW960YE0h9p/wASMDn6oCpWOy4eabc7JwjY7AcfLASpDqlufxvPhyVpY6yS09/dow109M4U1EHbh1VI0jiPTEbC5xyObmqlkl7lj3cLnEDZrRkuPQAdSTsr2qpvQ7zHbHcLhZ2dzK9h4muqn4dO4H90kMGejUuUmMnCFRKKFsEDCS2Nuck7nHInzzutBQ11hf2ZXaCdxZqX0+GanywnvIgOFzQ7GBjikcQcZPDzxtkbtMDWPa05DQAorJTnCaDgpzm5U/oi4kwZMtHmjD0iVWFqk4azPL6qX/kcqqqdyVhb3f0sfwP/AOUqsqtz8EmUoGRlJoaZ1fXU9M32ppGxt97iB+q1VJRN1HquplDQaQTOkIP3M+q38gqPSmGXgVB5U0Uk+fBzWkt/4uFb7R1rNts7HSAiaf6xwPQdB8vzVSqm7KMkbldRw/bRcKxoePUb6x92w95+WVaXGvitlFLUykBrGk4zjiPQDzK5ZX3GS51klRKcuecgZzwjoB5BX+vbu6epFDE491EMyYOznHp8B+ZWVaMYUNFDyM5zufotDim6GrqfRYz6jPm7r8Nvil9E7GcNcfLCYByEvi4WY8Tlai4XCW6TKAkymi7KAOEqQp3jSTJzTbnYCIOyjRNQmd6uU1Tv/pUI6lx/5SlSOy3CjRSGOta/7MMMsxz0DW/5pwQQoNvk4qcOHJ7i75uJ/VKpn5jPmSfxUW1NMdFTg8xG3PyT1IfVb5hL1TOqsweSsrVSi4XOkpu87nvX8PHw8XDsTyyM8vFVo2Vtpw4vtCejXPd8o3FLlKkQv9XPkNk2X5wiifhrk208QQhTLdC+rrI4Ixl8h4QPeuo26gjtlDDTRD1I2gZxzPUn3rH6AtveVE1c9nqxjgjJ+8eZHw/Na27XKO02+aqk3DBs37x6Bc9XymWQQt6fVev8KUbKKjfcJ9ObOvc0fqfoFQ62v5oom0NO8tnkGXub9lu+3vP5e9cmvB4LhkdWgq9qKuSsqZZ5TxSSOLnHzKpL6MVEZ8Wn81sU8AgYGjfqvObxc33SqdM72dmjuH9+qlU0uQPBS2uyqqhkyzHhsrFjtlOsRP0r8Ab7g4U2J+VVwyYne33O/wBfJTo35TglwtFpRxF8pgOvED/hK6AueaSdxX2lP8X/ACFdDXOXP/GHl9yvaOC//p7/APOf+1q4y2fuK8vB9UuJ+BKkUzu7qKmD7ruNn8Lt/wA8qtcDJ3zSMvjfn4Hcf68ko1RjqqOYnAfmB3v5t/L8V0QXir9yVcF3IqOw9zXPYfYmHG3+IYDh8Rg/ApbX5yM7hMXEltMJ27vgcJR5ge0P8JKckClLRaT086eb0ypb/Rwcxsd9s+PuUXTlj/bMwmd/1RhBcfvH7oW/a0MaGtAa0DAAGwCxq6r5B2TN+vgvSeGLD6S4V1UPUHsjvPefAfPy3NBBQ7tXi3Ub5P7Q7MHmsBjDI4NbuV6xUTx0sTppThrRkqk1DczPOaeMkRxnDsH2j/kqiKXuZOIjLDs8fqm+Ikkk5J5ko88wV28MTYWBjei+bbhXSXGpfUy7n5DoPcphb3Txvlp3aUpMUswe3uXnb7JPQp5md2u2cDghSlZyUDggjbHVW0EneOZNyLvVeP3gNj8R+SrYoS94HRTmN4eItydvWaOoHI+8c01LhWsdXwYD8kdCnPTYiPVJd5AKIwiaJrgQc88KM4mKXPQrOfQQyO5iMeS62l4ruVLD2AcHAbEjJHvyM+/KOaR1YJQ7AljO3hw9CrHTta2VslBP60crS0A/6/1sq+b6p8dSBlvsuHiExM00tUHsOBniaR4LRY0NHK3ZcnLK+eR0shy46kpq7259I+SM5MkDuf3m9D8v1TFHVDLXfAhaW5Obc6CGvYPrGju5h5dD8/zWRqojRVTmj2T6zfcpVAruGUxyYHTceYVlA4PAx1VDFKZIWvb7Td/gr6hZwwhxyOLfB6KlWT+jxFw3OgXScP2w3SubG4eo3V3kOnv2+fRSEEEFxS+jFJoGtdMQTvjZFUU3dE4GWdR4KPxd25sjSeJvMeIVqHCeIPHPqF2lBH2dO3x1XzxxRUmqusuujfVHu3+eVXwyEEtJ3b+ITzZC0891GrYjTOErfZzg+X+SNsnGA4HYrQXLJp84td3ZVD1aarLYZvBr+TXfH2T/AHVdy8vxVPUQx1lPJBKOKORpa4JdkrZKmkfBO7iq6V3dSH723qu/vDB9+R0TgoTon6w5Y2Qe0zn7kieTjib70bn7kHkVHOW+oeTeXuVS4HlpXn97rpeGI+0vEA8Sfg0n7IkEEFwi+kVYW2MTQyR8nk8TT4EKwp5++jBI4XDZw8COarKN5iaCDg81NqMRTtmb/VzDfHRw/mPyXoFC0spmA9y+YuIZWz3Woe3+oj4afZOzc8qO8lpDvgVIce8YQFGcdiDyWiCuaIT8b9k62TDgoMbzuDzCcD/NImq7oqnheWE7OGR71YNcs93h7pr282nKtoJxNE1w6hNITgrGKTdT6eYtcCCqaOTB5qdDLyTXBOBXRbLdP2zTR073hldBvBK7k4Y3a7yI2Pz5gK4p5hOwOALHZIc13NrhsQfcVzalqnQyMexxa8HIcOhW6pLi2qpm17SGtOGVbR9k8g/3dD5Y+6qbxhWmO6LpWlKzv6IxOOXRnb3FdIsJ/Ztuoq0ZEEuYqgDkDxkMf8CeE+RBJwxcPs1ydbqprxy5EeIXeNITU930rCC1skMjXskjcMgguIII8MLKrTmIef6rOuAxGD4/qtEDlDIKqrPVPAmoZ3l1VSODC5x9aSM/1cnnkbE4A4mvA5KzJwsRc9jCanfwhVU78kqdVPxlVkjs5T2hRvKb6oxuiAzulAbKVVigQjQQQhH0SgEhONGSkKFokEEFVV1BBBBCEEEEEIQQQQQhBBBBCEEEEEIQQQQQhBBBBCEEEEEIQQQQQhBBBBCEEEEEIQQQQQhBBBBCEEEEEIQWW7Vf/pX6w/8Ac9Z/8g9alZbtV/8ApX6w/wDc9Z/8g9Ry/wCG7yKvUH+1w/5m/UL5xIIILzlfa6CCCCEL2F9C/wD+gO+f+8j/APJMXoRee/oX/wD0B3z/AN5H/wCSYvQi7ug/2Znkvkni7/65Vf5vsEEEEFfXIIIIIIQgggghC+evblo86I7UL5b2tIpZJfSqc8AaDHJ64AA2w0kt2+6Vg16r+mjpFslDYtTRR/WRvNvneDzaQ58e3gCJN/3gvKi4Kti7GdzRtv8AFfXvDFx/idpgnJ9bHKfNuh+O/vQQQQVJdQtf2SauGhu0ew3h7xHTw1AZUOdyELwWSHHXDXEjzAX0CvF4pbJZ6i5VD3GmiZx/VDjdIc4a1jRu5ziQ1rRuSQBuV8zl7Z7Eb/UdqGm9P1lW17bfYIm072yHepr2txxkYALWRlrhzBfKSQHRBx6WzTauhPn+v2XiH4k2/LYLg0beofmW/wDyXS9K2qqpoprjc2sF4uBa+pDXcYhaM93A13VsYJGRgOc578NLyFM1FcjZrLW1rWCWSGJzo4j/AGj8eqwebnYHxVmsvqp/7QutqtTTlveGtnHMFkeOAHwPeOY4f92V05OAvDGDmdhY2/Uv7J07TQOkMrmlrHSuABkIB4nHzJ3PmVlLZH33fVB/tHcLf4W7D4Zyf7y1/ahKY6eigiOJJHO4fI7AfiVTWe1uqZIKKAcLWtALufAwbZ/RVJDrha8Qwzm71a6dtRlk78t5exnkPP8Akr6uqm26HuYT9e8ZLzvwjxPn4J+R0NmoRwN2HqsbndxWcln4nvlmfjPrPcVEThRE85z0UiNzIonSyuLYm7k8y4n8ySqO93UxhxcQ2Vw9kHaNvgl1tzyxtQ8cLRtTwnp+8fP8h7yuM9p+tzH3lsp5frX/APWJAdwPuj39fkoXOACka0ucqbXGqajU1zittuzKx0gihYD/AF0hIA+ZICrO1itipH2fQtvlbJQWPFVcpWcqmuOSM+TeIu583YPsp7RlXHpe03jWtUxkotzfRbfC/cS1sjcNHuY08RHPDsjksbbeOlt814rmvraieYuDHH16ypechuT4ncnwyq5OG+JV0DXHQfVaKrLNL6MNmjJZc761tbdJOToqUf1MJ/i3OPDi8Vg6yr75/CzZg5K11VUzRTmnmn9JrpXGorqgf2kzgNh+60YAHgAs/HE+olZFG1z3vcGNawZc4k4AAHMkphKla1E3L3kMxxDm88m/zK6t2bdlNPVUlHqDU7KiGxTScNDbqcF1ZeJOfBE3IPD1L9ts7gZc2fpnsvptDTWuXVFsN51RcWmW0aKheBJIB/b1hO0ULTjOfJpDnZjPpHRWjKihq33u+1TLrqSoZ3clTGwsgpY85FPTMPsRjbJ9p5HE4nYCUDChc8YyDp9fL9UjTWjJpaqlvF9hp4qumZ3dutFLj0W1R44eFmAA6Ut2dJgYHqsDW54thjfCdLd8LNa61SzTNrJY4emTAiMeHi5BONSquryAP/CzXadrltsgfbaR/wBaRiV7Ty/dC4bcLmyjBqag95M7+rjyntQXsvlfK9xkkcSdzuSsZVvqKucudl8rtgAM49wUGrjkrSa0RjAUa63KatmL5HcUh5AcmjwVDVPAfwAGWQ/Zb1K2Nr0Peb3O2GmpHBzzgvk9VrQOZJPLHX+ardQW2jsdfNbqKdta+E8FTWMHquf1YzO+B1PVSgJC4ZwsoaZrZDPLhzwPV8GjyH6/+SgmEV07A4SySyOEdPSU7DJLK48g1o3J/wDJayz6Ou2t77TWmzU3pFU/1nlx4Y4m/fe7Bw0e4noASQF3uDT+hvov2Bl2vNQbjqKqBjje1gdVVTsbxU8ZPqMGd9wNxxu5KdjS7VV5ZQzTr3LnWifowVlfR/tfW1xZpWzRt76WDjZ34jG5MkjsxwjG+TxHnkN5qBrb6QVo0Va6jTHZHQMsNtPq1WoOA+k1RGRmMvy87EjvH+tvhobgOPOe2Dt11B2l3AU1ZK2npOIPp7LSvPcQAcnyHbvH/vOAAx6rW5OeUXK5YL4zIOBgy+QnA25n3KbPLoFAGF5y/wCHRSrneDLLLIXvkke4ufLI4ufI4nJJJ3JJPPzRwQup4SZP61+79+Xg34LotR2LjQfZNR6x1W6Sm1DfZGixWR2zoKf2pKmdpHtFvCGs+x3jS7LjiPnc0mduvVOwRupQ4OGQmHv5k8gq+WbicSnKyfctCrpJfNCanzIkOk2TDXl2/RHxZylyhB7iFPNIbZaYZ5G4rLg1wgBO8cAJa6T3uILW+QeeoUjSOnxqW/Q0s0vcUEbXVNbPnHc07BxSO8ttgfFzUKqWp13qwigp2wy1r2w0sBwGUsDW4aDjYNYxuTjwJAyV2OdMLqGjOqatNHBLHUXCtbxWmhc1sjM49ImIyyAe/wBp2M4b/EFS3K51F3rpqyqfxzzO4nEbDyA8gMAeQVtq66UtRLBa7W9zrNbWuige4YdO4nL5nfvOdv5N4QAOSz6VPIxohnbCUDlwHTmko2nm7wSJFbaPpoqzV1G6f1qS1QzXmpaOfdwN4m//AGQx/Ipu0ue+F1VO7jnqHuqZn4wXOceIkp7TkXd6G1jeDs+uqqSwUr8YwcmWYeeWuwf4Qm6kiGkeG7bBoHknFDR1VTLIZZXOPNziUGnfwSUtNSqUxzXNwdvNBMMcR7k+w5wjKTCsrHAaq6QRA8PGHN4sZx6p3VVV7E7581e6Xb/0zG77kUrvlG4rPzOy05UZOuFOGjs8+K0Wgrb6d+0HOblhEcLv4S7jP4R4+K3d4uTLTbpql+CWD1Wn7TjyHzVF2dUhgsT5SN55nOB8Wj1fzDvmq/tCufHUU9CzOGDvH+BJ2A/P5rIkHpFSGdB+z+i9QoT/AASxuqvzv29/s/8A5LKTyOndJJIS6R5LnOPUnmUgHGBzQccxu8h+qQ3cgLb2XlZyTklOsRTO4S0Z+yP1RxtTNY4smAH3R+qcE0hKznZH9hNMcXBLPIKRMQJ5JJOAg4puZ2GY8cBIhBx9XzUWZxbQ3ecfZp207fMyPAx8gU9M/GyjXJxjsNLEdnVtc6b3thaGj/icUo3TFFhPCwgcmtwhRuw1g8gmuLhp5T4NP5Jyn2LR4YTk1W4OVY2N3Bcmu+7DO7/7C9VreanWt3BLUPP2KaX/AIm8P/iSFKEzG/1StborTIqv6bVxZgBzEx32j448FT6V0+6+VgDw5tLHvI8dfBo8yupxxthjbGxoYxoDWtHIAcgsiuquQdkw6ndeh8LWMVTvTakeoPZB6nv8h9fJKAAAAGAFz/X13fNcBbwOGOBoe7f2nEbfIfmugLk+r6xtXqatLAMMxHkdSBg/jkfBUbc3mmyRsF1PF85htwY045nAeY1P2Cqg/AB8wFVagPDJAfIqbVPMdO1wOPXb+ahai5QnyK6ZeJEaKLbpQJy3PtBXDTgBZiGXupmOHQrRsOWgjqMpOqaEt7uCojdnZwLf1ClwuyMKDVkthDxzY4O/n+ClQPBIIPNKEq1WivWvsXLZrj+GP1W/qpBFSzPPJrCT8lgtBRcd6e7f1IXH8QP1Ww1JUejWOsdnGWFg+O36rnK0c9S1vkvZOGXejWWWY9C4/AD9FyefFPXwSn2JfqX+87t/VR7rRPdS1ETNntHHGf3hu38Qp1bTGro5Y2+3jiafBw3H4hGyYV1BTVIGOJoDh4Hr+IPzXRLxshMUNc2rpoKlvsyNBPl4j81d2e2SXesbA0HgP9Y77rfFZSyRSC4VdrjYXv4+9ga0blr9yPg7PzXZ9PWdtnt7GEfXvAMrvPHL3BUqupEDNNzsun4fs7rrU+uP5bfaPf4e/wCilW63QWmhgpKZnBBE0NaM5OPNQv216TeWUNLh4YC6eTmAB9keeSFUax1a23Pbbacn0mZruKQcmAAHHvIJ92EvQNL/AEOaqcN3u4GnPQc/xP4LDEJbEZ5eu3v6r1B9zElwjtVFoG6uI6Bv5R8ge7bfbVLHajuHpdeYQfq4fVx4nqtJeK/9m2+WYbvA4WD948lgmOLiSTknfJVy2Q5cZT00CweM7hyRsoWHV2rvLoPedfcngUbtiksGQlloK6PK8jwkHmplPUh3CXn1mjBP3m/zH81DIwjYSHAjmlTVes9XYfNTKRg4snoFV2+cSN7on1mj1Serf8lbUjg125xkbKMp6Mf0GfP/ALPKd/3XePuKeqoeJvEOiU9rXMLXjia4YIKap5HROMEhyGjLXH7TfH4ckibhJpnBwML/AGXbJqeMiN0bvbiOWnxanKiHuXhzfZO4ITsrRVwCRu8jBuPEJwKbhJs1YIJnQyHMMw4XD9VHvlucYXtAzJCcg/eH/kmPZeQOYKuYZRX0zCd5YxwuHiOhUmQBkoawvcGtGSVSaehNVIXEZibzz18lpkzSUkdFF3cTeFpPEfMqHcavvWSxQndhHGf0XKyF9wqOVmw+nevcKOODhW19pP8A4jtT4u6N8h+pUtk/eVT48YDB+KfUO3VIqogXD66McJd4hS3SCFpkIyG74PVQVcQZMImdMBaNirZKi3Orag6kuJ8AOg8AAr+otTRBEzGHGMEO8+oVfEx1O7GNuRatC+5U9dQwzxEOc/mPBVtXEM8beR5rrWYaA0dF4BLK6aR0j93En4qHM1rmFrhljhghUreKlmfC454d2nxHRXTxkYVfc4OOESj2o9/7vX+alBUJCQ2TJwolZN+za6G4N2iOIanw4CfVd/dcfk5yDJOLB6qQ5rKqB8UgDmPaWuaeoKlCiKl1Jw/Pimi4O3VfbZ3mldSzOLp6R3duc7m5vNrvi3GfMFTYzluVm3Q4pSO8hdpwYznuzT3Ncflj7pSMDJARIA4K5SlhNRM2Pv8AovabvXi20MlSdwNPM6D5qVHJwqwgHpdNJB9sDiZ/EFUsepVJOYntcDu05XoQGNF8uOJceY7lSKeXLBlB+zz4FFUsEVQSP6t/rt+PP8copDkA+CcFGUxIe7fnoUpsuUJxxxkjmN1HikynhRFW1K8Pa5p6hP22oMbnwu5g7KvpJcSAHkU5UOMM7ZW+OCnYSK+bJjmptPNkhVMUwe1pB2IUmKXBUZCeCr+KXIHmr7Tl4/ZlaC8cVPKOCVpGQQeuPJZSmmyBurCN+FA5udFMDhdLgHo0zqMu4g1neU78544um/UtyAfItPVdV7OtROtVHSiQnuncTXjy4jv8Fw2x17rlbm07XD06kPe07nH2hyLT5EEt9xB6Lp+m5mV2nqOeIkNeHHBGC08RBaR4g5BHiFgXEFsY8/sVBW4dEPP9V2S/yNtjqe+xkdzA3hqyDgOpjgl53A+rOH5OcN7wAZcrl5wMrHdnmohcKeW2VJBqKcZaHfaYf5fqrKwudbo6mzPOX28tEJJyXUzs9047k7YdHlxy50TndViNOVzrgW6FTaqTJKhuKeldlxTP2lYCquOUByx4o0lBLlQpSL7SLOUfMpUJQ3Ck08fEQUwxpJAG6s4IuFoUZKexuSrBBBBQK0gggghCCCCCEIIIIIQgggghCCCCCEIIIIIQgggghCCCCCEIIIIIQgggghCCCCCEIIIIIQgggghCCCCCEILLdqv/ANK/WH/ues/+QetSst2q/wD0r9Yf+56z/wCQeo5f8N3kVeoP9rh/zN+oXziQQQXnK+10EEEEIXsL6F//ANAd8/8AeR/+SYvQi8/fQwhc3s7vMuRwuurmAdciGIn/AJgvQK7ug/2Znkvkji05vlVj+r7BBBBBX1yKCCCCEIIIIIQue/SAsovnY/qaEty6Gm9Kbz2MREh5eTSvn2vp5dbdFd7XWUM4zDVQvgeN/Zc0g8sdCvmGuWvDMPY/vH0/8r6A/DSoL6Wpp/6XA/8AMMf/ABQQQQXPL2VBetfoXXWSfTWorc5xdHTVUczW8WeHvGkHbp/V/mvJS9F/QtuHd6s1FQ4b9dQsmyTv6kgGw8PrPyWnbXctU3xz9Fw/G0PbWKfvbyn4OH2yvW/IrJ2f/pK8Xe6Eeq6X0KF2N+7hLgf/ALI6X4YV1qO5mz2WtrGAPlihc6Nh+0/Hqj4nAUWyW79kWWjpC7idDE1rnk7udj1ifecldq45cB718ssGGk9+n6rnmuJfTNWMjwXMo4WgNG5L3ZwPfg/ktJY7U200ZMhb38nrzP6DyHkP5nqq6y0H7RvNddphljpj3IPXoHfAbfNTL7W8LO4ad3DL/IdAqQdnL1pyeqBGOgGVW3S4elzmTOI27MHl4/FUU1QKmZzXHEMfrSE8vIfzQutcYwI2f1juXl5qgvlzhtVuDJH8MeOOVx5kf5lMJ6pAMBUfaDrUWW3PqGuxVTgtp2n7LfvFcDjknu9aC1r55ZX4YwbukcTgAeJJOFM1lqOXU16le92IwccIOzQOTVpeyyCntct21hcYQ+1aapvSmsdkCaqdlsEY8+LfI9l3d9CqxPO7CuNHI3PVM9o9GKm/2Ts/o52Gi0/B6Rc6iM+o6qf60js9cBwa3qOJwPJZZtxZc75HUxNDKCiaYaCHpk7GQ+Z/AeZKeuJqrJYZ3XGXvL/fZn1dxl2DiXOLi0425ux7y5P6f0hI6wy6jvktRYtJUjWOkrhCTPWF2zIqNhH1sjzgNOC0Zyc4ITTl79FLgRs9ZQaDSN419rKSz6eopbjV5aZXtwGRAjJfI7k0ZJ5+4ZJAXRNN3S1dnWoGaW7N6ai7Ru1l7CKq7vybNp9p2e58g9ojPDhvruw4EsJ4HR9OaY1r2g0TtLig/wBjrPWN4zpSilLHQQO/t7vVNxJJNIOUDHN9UND84cB6M7OuyywdlOn4rDYKZjASH1VUGBr6iT7zsbAdA0bNGwTgQ32dT3/oonHbn69PDxP2Vd2X9lkWj21lfXXCov8AqS5ObNdb/WgCetkAwAANo4mco4W+qxviSSeltaGtAAwByCKOIRsAA2CVyTgFVc4uKYrKyG3Uc1VUPDIYml7nHwXnTWmoqrUt1lqCHeseFjBvwt6ALs2p6Cs1Y9tHC/0a2sdxSzEZMp8GjqB8k1Z9PWuyy4oKdss7NnVUnrOB8j0+ChcC4+Csw8sQydXH5Lj1g7Gbtf3tnrv+jqZ24Mo+sI8m/wA8IqiK00E1ZS6cpH3GnoniCaujwX1VQdhBE7xyRkjkDnON1pe0PWFTqa5Vek7FXi3UtOzvL/qAuDW0MOMmJjjt3jgDv9kZPu4jqPtvgtctNQ6NpmW+w2uJ0Fvc5h43Pds6oOd+IguAzv67id3FOa3Oymyd3fBb7VlZS6HoZIrjVx3LWdXGWiKJ39GtrCMcLGA4y0HYkZJ32Gy4zCHV13itVGGCXgM09RKcQ0kI5yyH8hzJ8OazdbqGShiNfU99X3Osk4IIAeKWokcdgPedyegVlqyol0jZxYXtENzmAqLtIXZc6Q7tjPgGD7PTrvlThqh5iFtR9Iqn7MLXLb9F2+Du2uElTd7k0umrXjqWjHCznhvQHpkhcT7R+0G6a/1dX6rrKhsNRcY2NY0uMnokTGNb3cYOzWkhzsAD1nOPM5WSulebjUcIJ7lp9UePmUmgpRVVGSMQw4yTyc7mB8OfyVjYYUAaM56p7LLRb5ag5E0h9p+7iT4n8VL7J77Z7PrKiv8AqK0OvlpoHGeC1F4Yytmbjg70kHEbT62MHiLRkEZBzt7qP2tdRSRn+j0+zyOp6/y+anMAYwNAwANh4JNtVJjOi3Xaj2tXrtZ1ZPfLxIBK4d3DTR57qmiBJDGA9NySepJKxss/BGT1KYYc5KYqpdk7JOpS4AGAo1RNjPiowzI5G4FxKXEwuyGnhAGXO8AhGEHOx6reaUBwt3Qa1oJwMDzUq2W2a9XOloKYZmqJGxM2yAScZPkOZ8kmU7CvnSjTPZxI/AZcNQz921wPrMpYnet7uKTYjq1oUKN/+yuly5vq3e9xcIcPagos7j3yuHnlrRyyrC80cGp9d+gNkLLFZoRA+Qc2wQj13fxOdxAHxcFm73cpL3damtkaI+9d6sTfZjaBhrR5NaAPguwacjz1XV4wPLRVRCTzPkn5GcDQPtO/JNhhJAG5KflIkgHdMVkvcU/g535KaYtsdAs9qaoeYJ2QtL5ODu2MHVztgPmQEDUpjtAt4xnofZtoOh/tLjLW3yoZyG7yyFx97XEfBVlzOI2t8Tn5LS6zpmUeszaWEPi09a6OzxuZyIazjcffl4B/hWer2cT2+QRnXKdjAwqrG6MBO92SUZj4RvsAglJhIxyT8TcrbyQ2DSWiaq31lC6v1tcHNLu+aWstMGzmjfZ0r24O2eEOAPC5rmux0ceMYTTogesrbTYLKmrk3AjpJjn/AOG5v6rNva6VzGMGXOIAHiVprV9TRXZ/L+iuaPi5o/VQdIUnpupaYEcTIszO28PZPzwq8juQF56LTo6c1MkcA/MQPiV0m3UjLZboKfIDYYw0uJ8Bucrld1rDcrrUVPSR5I93IfhhdI1VWGjsVS5pw+Qd2347H8MrmTIsFUqBujpT1XacXVAaYaJmzRn7D4DPxRObiGT3fqEyz2gFLkZimkOPAfio0Y9cLXC86T7G7n3KFcD/AEgfwhWAVfXnNR7mhOCCEUW4AT5ICaiGw96Wd8qRRFERlRpXZmiZ4ku+Q/zCknZQ5HZqyfuRZ+Z/ySBIm6iTBc4dAUzfHFtxoaTkKGhY17fB8hMjj8iAnqeE1lZDD0e9rTjwzv8Agq+qqv2hd7nV5y2WpcGH91uGt/AJQmnZNynhpJP3iG/MgfqpNOd1DqP6iMfelb+Bz+il024ygpoVm07q2sdDNcXVsEDeKWWJkY8gZG5J8gAVUNBc5rWglxOAB1XVdH6c/YVEZJf+tztaZB9wDOG/juqtVUCnZnqdl0VktL7tUhmzBq4+Hd5n+6tLTa4bNQx0sGS1u5cebj1JUxMTVkUNRBA531sxPA0c8AZJ9yfXKOLieZ3Ve9wtijb2UOAG6YHTTb4YTNXUsoqWaokOGRML3e4DK4kyd9VUSTP3fKXPcfMnJXT9f13omnZ2A4dKOHn06/mFyukyGx+YI/Bb1uj5WF/f9l5NxlV9rVMpW7MGT5n+2PilXH1aEY++381D1MP6PAfM/kpl1OKBv8bfzULU3/UqU+f6LYXnZGipH8iry1zd7AzfceqVRHcA+IU2yzYkdET7QyPeEBNCvHNDmlp5EYKFA8mJocfWaeE/BKb6wBTcX1dW4cmvHEPeOf6JUvVdF7PYCfTJydsNYB8yf0U7XdSI7ZFDn15ZM48gN/xIT+iKb0fT8TiMGZzpD+Q/ABZ7XdYZLvDED6sDBkZ6nc/hhc+0dtXE932/uvW5z/DuGWs6vA/6jn6KjiUejhENRW0fJrvr4vc72vk4fipcTeY8Cr7T+mxcq6GsmBbFAHDHSTP2fcNj8AtuWRsTS92y80oqOWvnbTwjJPy8T4BSNF6SihnjvNTEW1hjLIQT7LDuTjxP5e9XWpL62y0fqFrqqTaNp6fvEeCsK+uittJJUSkBjBnHifALjceo5tUSNuMwDJZhwOjByI8bcI+IWDDG6slMsmw/eF6jdKuHhugbQ0Z/mO69fFx8eg/shdXSTM9I3knZJ33iXfeHxBIXYLPQi22ympurGDi/iO5/Elc90pbTcr1DlodFEe9fkbbch88LpFbVMoqWaokIDI2F5yfAKW4vy5sTf33KlwbS9nHNcJeugJ7hq4/T4LHayuzZ7jHRsILIfbP7x6fAfmqliq5auSunknlPFJI4ucfMqdSTd4OEn1m8/wCa2IGCKMMHRee3KtdcKuSpd+Y6eWw+SnsGeSdDT1G6bj6KzpoWSRNcRk75KsZWYBlQzSudEH8J4T1CiuzHIWuWjp2BgLDu3plQbrbi1nfRjLRzHggO1wkLdMhQI5CHhzThzTkFX9HOJ4w9uxHtN8Cs0x2HKbRVRppQ5u7eTm+ISlMC2TKEvpHVHEA3OGtHMqJNEXtBBw8btJ8fD3KRb6/vKUsawyxu3GPslSZKKURF5YG/u5yVHnvT8dypmzjgJP8AVZw5vVh/knIX9xICDlh5HxSbhTvoJWVHDxRv9VwHIojG2DhIPFTSbsd90+Cclwmq+IRSCQeyefuVjbKYxR947PE4YA8Aip6fvjmQZa3GP3lIqqgU0Ln83Y2b4lY1dOXn0aLc7/ovSeGbUynYbvW6NaCW5+bvsPj3Jm7TSw0MphOJcbHwWcs1YG1TeM5adnZ8CrugrDXRvjk3eDkeYWauMJt1eS3ZjjkLUpaYUzOUbndcfe7vJd6kyHRg0aO4d/mevw6LWUNMaWoqG9NsHxG6Xc3llI7HMkDZJtVUKujY/m4eqSk3Q/VsA5k8liPHaXDHiPkF6JTvNLwoXDq1w/5nEfdOWO4uiLmZJYfab4ea00Mge3gduDyKwVLOaWpbINwDuPEdQthRyNw0NdxMcOJjvLwXSrxtOSNLXFp6JggHLTu07EKRO/iIPXkUy7B5c0JFnpmGmlc37pI946fgn4ZcHyKcusQE4fyD24+I/wAj+Cgwv3weYU7TkKBydrQKerhq27NcBDLj7pPqn4OPycVPj9lR+BtTC6J44muaWuHkVJa3gaG5JwMZPNYV4laI2xdScr03gWikNRJWEeqBy+8kH5Aa+YR8k052Sinkx6o+KQCpLTTdmwzO3dt5f3UPGt2FTOKCI+qzV3+bu9w+ZPcnwcKTG5Q2lPxOW8vMlZ59Io/F0RyP4TzSI38Qwk0M4jlbxey71XDySZGGnndGTnhOx8R0SpCEsnOx9yr9453N6ZVg5Qa4YlDx1UjVE4J+OXhc0+CsZAJ4ceIVMJMgFWVJLxRAHmNlIo9E9b5yAY3e00qzjfkqikcYagPHI7FWdPMHAHKaQlCt6WbBAVpBJkeaoY34IVnTTZwoiFI0q7oK59DVRzxnDo3Z9/iF2PS1aymp6SVh/oVxJI/7OfJ/5gP8Q81xCM7Lp2gKllwsrrVO4hkgLo3Dm05JyPMHBHuWFdGZhB8f1VaqdhgB7/1XQJayostdT3Wk/rqZ2XM6PZ1afhldMr7jDVU9p1HRuL6Qju58DJ7mTA4iOQLHhhc5xw1gl8Vyu0Vr6+jfHUgelwOMU7QNiR9oeRG/xWj7N7jHT1ddpavDZaKtY99MyTdrgQe8j88jfHk7xXKtPK7Hest7eZviPot9J7WQdk2q+wVktTRzUtTI6Wut0zqOpe8jje9oBbI7GwMkbo5eEchIArBXwchZjtCidzRHmj+0iSJiCU1JT0MfE4AboTVJo4uJ2SOSsQ3ACRTwiNifAwoiVaaMBK4kYOU2Hg9UYOUJ6XkI0hGHeKbhCUgiByjSIQQQQQhBBBBCEEEEEIQQQQQhBBBBCEEEEEIQQQQQhBBBBCEEEEEIQQQQQhBBBBCEEEEEIQWf7QmNk0DqVrmhzXWypBaRkEd05aBUGv8A/wCgPUn/ALtqf/knJknsHyVuk/2mP/MPqvmwgggvOF9tIIIIIQvZn0M//pX3T/3xL/8AIQLvS4L9DP8A+lfdP/fEv/yEC70u8of9mZ5L5F4q/wDrdV/m/RBBBBXlyiCCCCEIIIIIQgvmBWwNpq2ohaSWxyOYCeeAcL6fE4Xzc7RrY2y9oGpKFjQyOnuNRGwDlwiR3D+GFzl5HqsPn9l7X+GcgE1VH1IafgXfqs6ggguYXvSC7H9E+6G39sFLCCMVtJPTkF2M4aJPjvGP9BccXRvo7ymHtl009pLSJZRt4dy8FWqU8tQw+I+qwb/GJbTVMP8A+zd8mkr2tqt5qqi10LTn0irYXD/s4/rHH/E1o+Kk32d0Ftm4P6x47tg83bfqqynebpryqPtQ2qmbAM/72TDnEf3Q0KddXCatgiz6kQMrvfyb+q7cuyHEeX796+SA3lLWnoMn3/2woBbHare1v2Y24/iP+ZWQuVfwNknkPE5xyB4nwVxe64TyEA4iZy8z4rFXCqdWVIawF2/Cxo6qs45OArLWnc7qOC+oqcn1pXnbPL/yC4x2oazFW6ZtNJxQl/dQf9oRzf7hz+IC33aNqGKx0M1phmArJY8104O1PCd+7H7zxt/CT4tzyC26MvWvaqSvjhZbbREOH02ud3UEUY5nJ5nxxnzVeR35QrUbfzFZCPLcAB0j3HAa0EucfIdSu+0GjJZLXadFxS09BS2tzbzqa51Dw2GCZw+rjcdgS0Y2yAe7Yc7HGNtFytml6htLomAXa/vcIzqS5RAQ0xJwTBEds77F3X7wOFrtOaQt+tKuo01VVsz9IWEOuuqLzVSlvp9Q4Fzo3SnkC0EvcMEMbjLSQVG3JOApJNBzHTH7/wDCwvaH2j2awXKgpNBWGmvd1ukhgptUajhdLGe7P1slNTOAaWRHbvHAHj9UB+C4dE7K5712gSloE90uVseWHVl6xMWPkDjI6CMYYx4BAwwNBbwhxIaGjmGl9PV3bP2m1WoKeBtFPdmCntkHchrLPZo8CFhYPZJGJHMyBxvDdsL2VpXTNBpCx0trtkZjpKZvCHOOXyO+09x6uJ3P4ADZKNdAmPIYBka+KLT2n6LRlqNFQNeeNxknqZXcU1TIeb3u+04/5DAACtqODgy93tu/BNM+vl4zuxp2HifFPSTBmw5p2nuVVxJ33O6dfJjZNPdx7H2eqZMirKmqNfIYIn8EI/rJB18gguStZlHV1T7lI6Cmd3dM3aSYfa8h/P8A0efdoGtZ4BTab0yA681/EyFw5Qxj+snf4NaDzPMkAZJwm+0btOoNN2t4jkHorMsa1hw6pcPss6gZ2J8/gfMlXr681rbk504hnuXq1UsI4XOiAIbAD0iAJ9Ue0SS7PSlLUNi9rfuXa2bh2suuHRt5Wd52/ufL34S9faqbcqf/AGWsEpbpqklLp6kOy651GfWme77Q4ht02B5BoGOZbIwWue4vI6dFMQWZJWyv0boF67b+D7bSDMze1d3u29w2+OfNWelb2dJXye9U1JT1F29GNPS1VS0v9Dyd3xtzw8R6kjOw6ZB5frqe4NqHuqC+UVDy99S45MjicnJ8c9FvVHuFDFcqOWmmbxRvGPcehCkgr5I3euchRXbg6grIXGkYI5BtjY+BG3vGvnsuPwlxcGtAL3HDQfFTrjWMs1qe6P1nNGGeMjydvmSmTQPo7nUQyHJp3luR1I6/68VBr5PT7o2POYaXc+chH6A/8S6gEHUL56cx0Tyx4wQcHzCO00ZpoAHnikPrSOO+XFT3cj4oRM4Ix4lKazO/gkylAwkn1I8KBM7icSpkruIYVfM7jdhvJCCksaZXhrRkk4UmZrYm9yw5DfacOpT0cPoFMHn+vkHqj7rfH+Si5wfDCCUoCS/DQB1W50DGNNWK9avmw00UToKLiHOoeOEH4cQHucfBYmkpZa+rihhYXyyvDGMHNxJwAt92gUwmfprQNAeJjJGmrfGebzkud8Gl7v7wHRMOuikbpqs3CXWjRzIztW3hwmkP2mwNPqj+87LvMBUghGVcXytZdLvUTRACljPcU7W8mxt9VuPI4J/vKtm9RjiOZ9UBdq3ZdPjooTx3kjndB6rUqOIk5+SebFjDR7k/HFwxl2OewSpMKDUcMMT3dAMqBoa1nUXaNpigLeMSXBs72nk5sIdM4HyPAB8VKvT+7pSOrjhPdmcxt101Ve8kfsiwzmF4+zUTAiP58Dh8UA4BSEZICs4a8Xyvu14BLm3Kvnqm5+yxzzwD3Boam6iLjOcJ60UXoVspafABiia0geIG6ekjzlJnCfhVPo5LirrSFTb7Pfqe4XKkNfBSh0raT7M0oae7a49G8XC53PIaRg5TLIQcozT+aTmwcpC3IwoldPPcq2erqpHTVM73SSyu5uc45JPxKKODyUtsG/gnhBjomEpwbhJDe6s1yPjE1v8AxN/kn+zWl4pK+rI3HDC0/if/AAputb3diuB5Dhb/AMwVr2bRj/ZaOYDHpE0kn/Fw/wDhVKrdiI+K7DheHtbg0n8oJ+33R67kzTUsOfacXEe4f5rHCLC2Gr4O9qqfyYfzVNHQgnJ5BTUmGwtVPiNxkukuemB8gqqpj4aFxI5uAUGFuZAru6tApAAMAuH6qoijw4nHRXAVzJGE8W4J26BVlaP6U7yDf1Vu9uHvHhhVFVvWv8mN/VSBNdslM2aEsMJA80lm4aBvkqS1mPkpFGo5GFWPfmesf0DmsHwAP6lXLmbZVA05py7rLM9w8xxED8MISFTLbOKR1RVn/wBmgfKP4g04CobXFwUEQO54cnPmcqxusvoumawgjimc2Ie7IJ/DKi07Syib+6wD44SBNPQJMmxpW/eLnfIEf+JTKUbE+ZUaoZi6RR/cpy4+8uA/Rbns+0f+1Wsrqtv9DafUYR/WkH8hj4/NQyyNiaXuV2hoprhO2ngGSfkO8+CvtCaWNOG3KrjHG5o7hjhu0fe9/gtbcrhDa6KWpnOGMHLq49APMp2eeOlhfLK8RxsGXOcdgFzLUt8dfa4OaXNpYx9Ww9f3j5lYMbX103M/b96L12rqabhegEEGrzt3k9XHw/sFdaVrp75qWatnOOCEhrRyaMjDfxK26xvZ7T8IrJiPusH4k/otg94jY57tmtGSo63HbFrdhgK5w1zm2ieU5c8ucSfPH2XPu0qt44ZYwctaWx/HOSsdTj1o/wCE/krfWdQ6anYXe1LPxn8f5qoibmZoHRp/RdFE3s2BncvGbhUmsqpJz+Yk+7p8k3eHcNvj85B+qianGLfS/wAQ/JP6gOLdD5zN/VR9VHFBS/xD8lMFn40Koneyz3Jykk7moY/oDv7k0dy0eWEpoy0FSKNayN/rFp6jIQdTPnlhbGOKTjAaPHJwotNPxwQSdcYPv/0FsNDW4V98ZK4B0dOO8OfvfZ/Hf4KvI8RMLz0V+jpXVtTHTt/MQP1PuC6RSwMoaOKEECOJgbnkMAc1y26VRuFwqag8pHkgeXT8F0LVFd6BZp3AkPk+raQcHJ/yyueUVFNX1LIIGF8jtsdB5lZdubhrpnfvvXoHF8xfJBb4RtrgeOjR9fipunbe661TYhkNA9d+PZC6PTwR0dOyJg4Y2DAyotltEVmomwswXn1pH/ecoGpLmWM9EiPrOH1h8B0HxVaWR1dMI2bD95WxQ0sPDNvdV1Gsh+vRo+/vOwWZ1dev2tMxsLv6NFI6MDxcNs/gfmuf0I9ButxpMYbxiojHk7c/itjcoOCV5aPVlAlb/E3AcPiOH8Vm622y1eqrQ2DAdVk05ceQHPP4/gt1jGwswNgvJ6qee41Jlfq95/8AAH0C6noW3iltRqCPXqDkeTRsP1Kido12FHb6ekDhxVD8uGd+Ef5kfJaungbTQRwsGGRtDGjyAwFy/tHqvSr2WgktgaI/Lfc/iR8lhU2aiq7Q+f6L1m84s9iFLHuQG/HVx9+vxVW3Yk9Cn4nFrwWnDh+KhUMvew8LjlzdipTTgrowvFgr2lkE0bXD3EdQVd0Xq0wPiThZajn7p3FuW8nAeHitXT4FOxzTxtIyCOqCdE4DVOtJ7zBOxGynxMIaA/Dsj4FQmMMjmHGMuwFcMpjnB5KMlSALI3u2mhmD2D6p+7T4HwUSCXjyD7Q5rb1ttbXUcsL8HiGWu8HdCufSOdBIJBv4jxClachV3NwVobNc3Uc4Gctds5vj/mtzHWxPp2Shwe12wwuZskBDXA5B3BVvRV8kcRezLy322Z5jxHmlc3KeHYWuq4I6mJ0Lx9XK31T4FUVoLs1NDOwuDM5PgfL81YU1wbX0jQz1hs5ruoKew1pc8gAndzuWVm1dT2DeUe0V13D9kNzm7WTSJu/j4D79w80CWwxZOzWj8As5X1jpqoSHZvsgeAV2+oZUU/exPD2tdhw8R1/ms9Wx93K5nQHZJQU3Z/zH+0fkrPE96FW4UdKf5TO7YkfYdPj3I4pjS1DZGnbP4KRf6ZtVTtkYM8Q4mnz8FAjfxsLTzHJWFNKaiikhPtM9Zq21wCkaUBFpGc7vdz+X6J+6v4ZYx5FPWiMR2+IAAZy7bzJKZu8Ye0PG5ZsR7/8AX4rmac89e4+JXsN1HYcMRM7wz54KrJ24cHjkfzVzYa7jb6M52CDxRk+PUKpZ9bG5h59ExFI6N4IJaQeY6FdGvHNluZDxMDuXimXyYUe2XJtdAWuIEoHrDx80HO3PQoSpu5jvKYP5uY4O+HI/gVTudwy7dd1dlwcCHciMKup6LM3E7kw4x4lMkmbAwyO2CuUVvmuVSymhGp+Q6k+Sl07MMDiMEp1AnCC4maV87zI7cr6RoKOG3U7aWHZo/ZPmoE8n17/fhLa7iCgsmMreNw4X59YeBGxUiJ+Nl6FEzs42s7gAvl6sn9JqZJz+ZxPxOVIBwpAOFFa7KfY7IUiqhS4n4cptT9fTRzD2meqfd0VY1+APJWVFIHB0buTxjCRKm2O4mgqNWNzH7k40mKV8TuYOyTU+wU9pTHBQ4nbKZQS8L3NKr2nhOPBPRycEzXfNTKJWsre8jI69EVFORgHojByMqK93c1GRydukKatDDJkAKbTSYIVNSzZA3VhTybjdRkJwV9A/OFs9NVb6OClnYfWY7iHzKwlO/kthZX5t8Xx/MrJuAzEPP9VTrj/KHn+q6rLVtpqmku8R/o8zWxVA/dPsuPmDt8VZ3SOePuqyicG1tK8TQOO44gc4OOYPIjqszo6qZX0FRbpsEcJLQerTzHz/ADWhsk73UrqWZ2ZqY92SeZHQ/JcbI3BwqTHZAK2zb5A7UNkvdPn9makpxSSAnPc1UTXyR5A2aSwTse883RQMC1LhgrmunbeNQWrUejHVIopJGtudpqeDvPRZmva5sjWbB3c1DYpcHYmQA7LZaR1D/tTpykuD4BSVTuOGrpA/j9GqY3ujnh4vtd3KyRnFyPDkbFWI3ZCozt5Torc7BEiByjUqqIwMlWlBT4HEVCo4DK8K6Y0NAA6JpPRTMb1SgMIHYo0W2UxTqjjuL2n1hxBTILix3XB8Cq10aacMBMzhPwtJHM16cWZjqnwkYcrGmvDThsmyUFNwrVAHxSI5mSjLSClpd0iUDlGkIwfkjCEpBF1QzvhNQjQQQQhBBBBCEEEEEIQQQQQhBBBBCEEEEEIQQQQQhBBBBCEEEEEIQQQQQhBUGv8A/wCgPUn/ALtqf/knK/VBr/8A+gPUn/u2p/8AknJj/YPkrdJ/tEf+YfVfNhBBBecL7aQQQQQhezPoZ/8A0r7p/wC+Jf8A5CBd6XBfoZ//AEr7p/74l/8AkIF3pd5Q/wCzM8l8i8Vf/W6r/N+iCCCCvLlEEEEEIQQQRHkhCI814M+kxbf2b20X/DeGOfuZ27c+KJnEeX3g5e8l4l+lvP33a0W8PD3VBCzOee7nZ/4ljXcA04Pj+q9S/Dp7m3hzRsWH6tK4sggguOX0mgt72EVcNB2tadqKiQRQxzPLnu5Ad2/msEtB2fU7q3XFipGymA1dZFSmQDJaJHBh/BxUsJ5ZGnxCzLoztKCoZ3scP+kr3R2bte/T8l2qGujkus8lcWvO7GvPqDPhwBuPemrhc+8fK4bGU59zeQHyVpep4rZboqGnaI2cIjaxvJrAMYHw2WOrasRtc48hsPPyXZvOAGDp9V8ixt5y6QjfbyUG8Vhd9UzdzvDwVRirzJTWvu/T+H66sl/qqNvUnoXbbD57AqfDTOrWzTvmFLSMBdNVuOOFvUN8/P8AyWR1Jq+F8DLfbaciiJ+rpmbPqXfef5dTn49AoS7lCsgcxwFRXe2aftTBV1rpq+jDzI1sp+suM3Mvd1DM777nOT0Bx+rbxV38xvvT/RrfFj0e0U/qtAHLIH6/hyU693I0lU6WeRtVdTzcBmOnHQNHl/msRWyT3Kvjp4WSVNVO8MYxgLnyOJwAB1JKrk5VpoUyimrbhW00Fvpe9rqh4p7fb4QAA47ZPIddydgPDJW67Te60rp+29jdgeK6rkLbjq6shBPeufhzKc9czODcg79zGGuz3gzcactQ7JIaqKhbT3btOmpWvc12JILJDJs1z995HZ2aDl3i2MOetJ2J9mMFmqam5VMk1wqTO6onrqt3HLV1Tjl0rj1wfx5Ywn+y3A3P0UZIcec+y35n9Fs+yzs+ZoexFswD7zXYlrJufD92MHwbk+8knqtlUy8ome4lKmm7vDW7zP5Dw81XS1sdLE6Yklo2aeryf5o0AwFWyXu5nKdJM2mY1o3edgFHEhJJJyfFQWTOLsyHMz9yPujwWe1ZqwW0No6X6ysl9VrR080hdhPazJwFaXe/ZmFFSnjlds7h6LkXaj2ywWGGaz2uVs9U0cM72EYB+7t08fl7812ldqTrAyaxWao7y6PH9PrmnIhz/Ztz9og5Pht1xjibnFxJJJJ5knJKzKip5PVbuvT+GuFjX4qqsYi6Dq7+3j16d6mXe81l8rHVNbM6aU7DPJo6ADoFCQQWOSScle5RxsiYI4xgDYBBBBBIpkEEE1V1UdFSy1EruGONpc4+QQAScBNe5rGl7jgBc51vUx0l5rJGj1mtaS0HGTwg/wAln7RRlrWtdu9xL5D4k7lLule+8V8tRIA0yO4y0HIHQDPlgLZ9mmlYtR3ktq5fRrXSROq6+pPKOBm7t/E8vx3wu2jBjia07gBfJtwmbWV008Xsuc4jyJJChXGwvoLdbpZSfSa/imii6thB4Q4j952ceTSeqrJmiIOaDkD1c+K2NZXv1lea28CH0OGf1KWI7CmpWDhaMchsCTjbJ81jaySMzyOYCIm54Q49PNIDk4VUtwFW1khbiNvtO5+5SLZQsEbqucf0eLYN++7oEm12+S6VQ2IL9yT9lqm3eoY57YIBimgHCwDqepT8pmFWVU755XPecud4dFHcNsDqn+7LgT1T1vt8twrIqeFhkkkcGNa3mSTgAfNNyn4Wy7NbXHbqa4aorIw6ltzOGBruUk7hho+APwyCqa218zZNRakleX1MUXodO47H0mc7uHm1uD8Stb2mTQaYs9v0vTvb3duj9IrXsOz5yMnPjgHbyOOiyBp+4tGnbaRiSVkl5qm4+3IcRfENz8k0a6pTocBV8VMIIWxjk1oCYezjkHgB+KsZo+HKjy07oX8Dhh2ASPAnou4Gy6QbJhsWBnx2Ts7OEBg+yN/en4Yg6Zo6DcpEo43OPikKe0LLaif9dGzPIcR+KtNNw9x2S6gqsYkvV+pba09THFwvyPLIkHzWf1BUAVk7yfVZ+QC2Pojrb2cdmtufs+ulnurxjmSHPaflMAgHZGNSVNYzbHgETm7p5jdkBHlBSgJkRpzu87pQZhKTSnJsRgdErgS8FADKahQb87utLXV/gwf82Fd9nEjZNF20sGAGvBGOvG5Z/WJMWjbo7xMTR8Xj9Ar3s5Z3GlqKE/c7wDycc/r+KpVjSYs9xXY8KzNir+V35mke/Q/ZT9R0/GyCTGeElp+P/kqQtPDw9CtjNCyoidG8Za5Z2toH0cgB9Zh5O8UyjmBb2Z3V3ii2SsnNawZY7GfA7fA/VZ+8x/Vxt88qtEZaeXQK3ubOKaNvTCg1Ef1n4LVBXn5CaqG4lkHmqWpGa6UeDWj8D/NX1U3+kSjzWekObhV+TgP+FqexMcNE/TDidGPeVNEfqFRbazjk55w07fFWRZnZSqPCg1LhT07nnbha53yCzvCY2U0R5siaHe/G6u72/hhnaDgcIZ8XHhH5qnl9aqf8Amkpqr9XTCK32+mz7RdK4e7GP+YqfSw8Yp48e07J9w3KodVTekXuGAbiMMjHxOT+BC6VovR092qGVlQ0w0DGYa485D1x5YHP/QZJI2JnM4q3R0c1dP2MDck/LxPcFC0po2bUd/q6mdrordFwR8fLvCBlzW/E7ldehhioqdkUbWxQRN4WtGwa0JcMEdNEyKJgjjaMBrRgBYDW+qfS3uoKOT6hp+ukb9s59kHw/NYBdJXS4Gg+i9cjhpOFaEyO9aQ/Fx7h3AfvVMav1T+2JfRKV39DYcucP7Rw/T/XgqOJmcDryTMMfVT6eHJC3oo2xNDGheSVtZNcJ3VE5yT8h3DwW70TT9zaHPxvJITnyAA/mrC/T9xa5vF/qD4/5ZTtpp/RLbTRYwWsGR5nc/iqzVU3qQRdCS4/kP1XPN/nVWfH6L2OfNtsPLsQwD3u0+pXN9WO4pqOP+I/kotKOKY+Tf1T+pncV2hb0awfiT/kmqEfWyHyA/NdKvEOqhaj9W30g8Z2/qo2rhihpB1L2j8CpepRmmoWnrOP1TOs2AQUDR1k5fBKNwgjQrPztLCD5BysLlaZbZUdzINnxsmYejmuaHNP4/gkV1NiCB4+00tP5rb3+ibdNB6WvjBlzI322cgfaY53Bn+6134JHOwR4pzY+Zrj1GD7lkKB49FkZndhDl2Xs/tvoVgjnezglqfrCTz4fs/hv8VzPT9hNyv1JStH1crT3vk0b+I8l2yoljoqV0hHDFG3OGjoOgH6LIuEugiHVeh8H0I5318mzdB59T7h9VjNb1MtddKa3wN7wsGS1u5Lnch8sfNaDTlhbZqbL8OqpB67vDyCb0/ZnQSS3CraPTagl3Cf7IHp71ducGgkkADck9FRmnxGII9hv4ldbbrbz1L7rVD13eyD+Vuw9+Ph55UG9XeKzURmeQXkhsbCfacSsnBx1J45XF7n7knqoerqyW9STBmRGwfUA+I3z8SFb6Vibd7HBVM3Iy1w6g+H4rXpYPR4+Y7leccQ3Y3Oq5Iz/LZoPE9T7+nh5lQbhRudSPIB4oTxj3fa/AlK0Tbo6i7iocMmla4s8i7I/IladtA0zsLmgse0tcPHZRdJW82/06Mjds3d5PUAbfgR80VUmIHKHh2nE10hB2GT8BkfPC0BGFxe8zOr6irmyXGR7nAnzK7LVHFPKevAfyXF3+s3iCq2se2fJdRxvIcU8fT1j9P7qtim7qrjeDhsox7j/wCX5K2acgFU00Z4HsHtMdxN/MfyU+hqRNE1+faG/vW4F5UFYU83dvB6dVfW24tt2C4GSkccuaNyzxI8R5LOBWFFUEDgO+Ebpdl0WCniqWw1ELmvi2cC05BCsS0Fc4s97ns072RbxcWXRO9kjxHgfctUdY0ppi5jHd/0iI2z458FE5p6KUOCl6guLbfRmJrvr5gWtA5tHU/y/wAlh5ACC0jIIT9XVyVczppnFz3Hc/oFGedtlK1vKFC48xTVJKY5DE456tKt6F7++aGNLnOOOEKjnjdIQYx9YD6vCt5p2zuoYGzVDR6U8bt58Hl71DU1DadnMd+gW3ZrTLdqgRs0aPaPcP1PT9FNtlvbb4nAbue7iPl5BJuEzXtMDhlkgLSQfwTd4uYpY+5jfid45j7I8VTW6rM8bqaU/WDdufFZdJA6Z3pM3uXbX+6RW6AWig0wMOPcO7zPU/sPWOpNLVPpZTs48O/j0QuURY8g7lu2fEdFAuRMcsVS3Z2cO8nBWVdMKujhqWcnDhd5f6Ofmt0HBHivLiMjHcqoP4XghTIJe7ma8HYqveeEp+ld3pEfXOym2UIBJwFsIGCOCNoGAGhUc9yEWp5KOU/VTxNAz49P9e5aADAAHILBaw4xeHzRkiSINII58guWtx56hzvA/Ve08XNEFojiHRzR8Af0Vw9rqeYg82nCTUABwcOTvzSzVNuNFTV0eOGVo4sdHDmPnn5Js+s0t+IXUheJlLpp3QvD2O4Xg7FaCKpZVxCRuzuTm+BWYifurO1NkM+WexycTyITHvbG0uccAKxTU8tVK2CFvM52wVs3cpfIeARAYGAoNxmLoi1h2zgkdVzLjJcpuVujR+/ivZoY6XhCgMs3rSu+Z7h/ujqf7BD0v0mqY1h+rB+amyHhY4+Sp7SOKqHkCVa1JxEfNSVMTW1MUDBoMfVVLPWzTWituVQcvdzfJugHgCqicdzWHGzZhxD+Ic/mPyKWx+6VXRmanPDu9p4m+8fz5fFRWS8bWvbu1wyF14XiCntdkp2M4UOOTLR5J+N2UqapjXbjzUmllw5qgtdunoDz8lBPK2CMyO2C0bfRS3GpZSw+04/3J9wVjcR6rJ2HdvtY8EhxEkORvtlRuadpXAExfEBZ1Jcm1L+zLcHousvnCktpphUtk527HTGM+85ChPb6xSS71c9QnahvdyH3qO44cfBb4OV56RhW9NNxxNKKp9aPiHNu6iW+TILfDcKZniGDyKVNKcoZshW8MnJZ2lcYpS09CrinkTSlV9TSclsrFL/QIvj+ZWDppcY3WyscuKKLfx/MrIuH+EPP9VRrT/KHn+q19kuDrdcIahvJp3HiOoXRZ8U9fBVxkGGdoY4jr1BXKad+cLoumqkXSwyU7jmWn5e7mP1C5OZvVZsJ6K4kuH7Av1jvQyI6erZTTkdYZyInZ8Gtc6OQ/wDdLWzs/wBku0lzc8Nr1WO8i8GXGGL12jqTLTRhwaAGt9DlccmRYqromahsNXb5ThtVC+B58OIEZ/FbSKGr7Vex+3VMM0dNqCSmhqqeolB7uG4wuDhxcPrGMTRlr2jHEziadnFRMONk6VuRqtSeaWxvEQFU6W1BDq3T1DdqeKSnbUs9emmx3tPK0lssMmNhJG9r2OA5OY4dFo6GlJdkhWs6LNDTnCl0MPdsyeZUsDCDW8IR5wolaAwER5JBdgISSAclGknA8kJVXHkmnDKeITbm5URT1Fe3wTTshSnMTLm7ppTgihq5Kd3qOPuVpS31riBKOE+Kp3N8kgtwkDiEuAVsIp2TNyxwcl81j4aiSnOWOLVa0t/xhszdvvBSB4O6YWlXgOCjBwmYKmOobmN4cnU/dMSshGkA4Rg4SYQlILm/a125WPsroXsle24XtwHc2yJ4Dtxs6Q/Yb+J6A9PM+oPpZa9utY6Sgq6WywbcMNPTMkx73SBxJ+XJZs9fBTnlccnwXaWjhG6XmPtoWhrDsXHAPlgEnzxjxXuBBeJ9LfS31tZ6xjrs6l1BScXrxSwsgfjbZr42gA7cy13M+WPSfZH23WXtcgqWUcU1BcqUB01FOQTwk4D2OHtNzt0IPTcErBXwVB5WnB7im3fhK6WaMzTsDoxu5pyB55wR54wuioIILQXGoIIIIQgggghCCCCCEIIIIIQgggghCCCCCEIKg1//APQHqT/3bU//ACTlfqg1/wD/AEB6k/8AdtT/APJOTH+wfJW6T/aI/wDMPqvmwgggvOF9tIIIIIQvZn0M/wD6V90/98S//IQLvS4L9DP/AOlfdP8A3xL/APIQLvS7yh/2ZnkvkXir/wCt1X+b9EEEEFeXKIIIIIQgk8SM8klOCEF4Y+lRVd/2y3OPiYTBBTxkNO4zGHYPn63ywvbN6u1PY7RXXKreYqSigfUzPawuLWMaXOOBudgdhuvFH0ktO1dl1JZay5N4btc7f6XXji4w2d00jnRtf9psbXMib+5GxY92GabPcQvS/wAPZAy9cp/Mxw+h+y5CggguLX00gplmuDrRd6GuZ7dLOydu2d2uB/RQ0EA4OU1zQ9pa7Yr3hc7s2uxVB3GyVoMQb1B5YVH3tPPcPR6iUOqGs7x0DN2xR/ekdyaNjz54OM4OMTpTU9wvmnbDabHwz3mWiibNWSNzFSMDQC7HUjbY7ZxnOzS3f7rRU1FVWO1zk2qnc590ukr8vr5h7YLs5LBj1nZ3PqjYOz1wfzgOK+R54PR5XQf0kj4HCb1lrJ+opmU1C1zbNFIGU0LR61XJ0efEeA95OOmVvl3ZpyOWmikbLdnjFVUNOWwf9mzz/wDPnsG6q9Ot1Obj/UVU7C2ia4etTwnnKR0e/kB0HP7QXPqmt7+TDckZ9VvMuJ/MpMF2pTAAPVClvqJJ5GtjY+aaVwbHGwFz5HE4AAHMkq71Pra3/Rstoe6OG9dqFwY1lPRAiSK0tk9kvxzkIPIZz/Du+NrHVI7AbDROp4Ia/tSvsTv2ZSTjijtMHsvqpR0xyGfadloDuFwNH9EzsldrzWtZ2l6ilmuNms9Q/wBEqqxxdJcq/OXzkk5IaTnPLiIAPquCA3Op2TiQBqu/aC7P6nSOk6d92fJV6tv03p9yqKl3FIJHDAa4+QOMcgeLGxXX6CGDTllj4hhsbRt1JPIe8qosVO+73Oa51fsNOGN/Qe7+aemubbhcJqlxzQ0DiGjP9ZNy/wCHl7ym5ycqJ5Lhyn3/AKKTNNI0cEp/pM44pcfYb0YP9ePkqSO6MuD315P9ChJZTgf2jhsXj47D3Eqivt6mutwjstNKW1VW0zVkzDgwU+cHB6Odjgb/AHj9lUWr+1Ox6Qa2N7xO+nbwU9upz6xxsC7owAYxnfwB3TXOEYy4q5S0U9W8Q07C5x6D9/NavUWp49NWuWqqZGsqJGlzQ4+yB1+C883/ALV5GmpfQHvK+cEelOG0TenCOp9+w2G+FltZa+u2t6+SeulDInH1aeLZjAOQ8/is2seWrLtGaL2Sy8FxU2JrgeZ39I29/f5beaAGM7kkkkucckk7kknmSd8oIILOXqDWhoAAwAgggghPQQWZ1HrygsLnws/pdW3YxsOA0/vH9B+C55ctR3PUEsjqid7IHcoI3EMA93X4rTp7fLP6x0C4e78XUFrcYmfzJB0B0HmdvcMnvC6jc9W2u1Nf3tUySRv9lCeN2fDyPvwud6j1lU6gPchogpQciIbknxJVXLQmCkMz9ujQoLDwjiPMrep6CKA825Xkl44sr7q0w6RxncDr5nr7sDvCmU5zIAAT5AZJXW9WwnRWlKLQ0TuC7XHu7hf3DnEOcNMSPAesR4kEHDlnuyWhpLWLlre7wie0adDXwwOOPS65xxBCPHBw9xHLDSQQSpmjop77eq6+XuY1D2l1bWSkYD3k5DAOQBJwB0Ax0UspwfJcpGPV8/opF/c2x2aGgZ6lTUMD5QObI/ss+PMrFzQd5wxEbyesR+70HxP4BXd0q5LxcaisqHbOcZHkdB0A/JNUVOBK+omGD7Th4eDUxowE5xyUT4xarf3bdqicZcerWqmkYDzGVbVEzp5HSP3J/AeCj+jMcdhzTspoCrDF8lv+zujh09TVmp62ISMoW8NPG7+0qHbMHwznyznos9Z7JJdq+OOEF4Lg1vgXfyHNaXWFXDEaa0UpzQWsHicOU05HrO+G495Kicc6J401WOv3f36YRTyGSpuNWyCSQ9XSP9Y/LiVrXSNqtRXmqa3hibMKWEDkGRNDdv73EodpZ3mq9Osdu1nfV0nlwMIafmUdK4vpInu2c/Mjve48R/EqRqTCfijY2OSoe0ER44QTzceQ/X4KtczieXO3cTkk9VMmce6azOxPFhMAZPuVrt5f6j8Spu1k/qPxQhja1kjsbn1R+qYlayON7yNmgkqU84Y1o8Mqtvs3o9oqn8iW8I+Jx+qYaiX+s/EpzZJP6j8Vy7VdTUPpZmQEmonHdxgDcuccD8Su79qlvgteutJWWnAbBbrI4tAPi9sQ/BgXIdN28XrtW0lbHDiZ6dFO8eLYsykfHgx8V1rtEn9P7ZK3r6Fbqen93E57/wBQmioly31zsTuU4yScrjzHcDf3phsDT0RmBmeSdaMBGlM8v9Z+JTBLJ/UfimhC3wQ7pvgnUMbJO3l/rPxKd2sn9R+Kb7tvgltib4D5I8HKXGzO2OaaZZDu4/FN53Hqsv2qSim0GQ0AOmro25HgGvP6LU2jis9soGsADoo2M364G/5LHdrwL6HTdAP/AGqre/Hu4Wj/AJyt3XN7uGHbAcSR7hsExzuduHJ8UskbxIx2HA5B8QtJSVcdbCJGH3t6gp17GyMLXAOaRggrI01VJSSccbuEnn4FXVJfo5XcEze7d94btP8AJc7NRvjPNHqPmvbrRxZSVsYhriGP2OfZPv6Z7jp4qrvGlpTN31Me8aBuwn1h7vFZSqpnRzBj2ljxza4YIXUmSNlbxMcHt8WnITNXbqauA7+FshGwJG4+PNSRV7merIM/VVblwZTVX86gfyE9N2+7qPmPJcsrG/0ybbqsTFIJrpcnDkJy35AD9F2qu0NDPI+SnqHxudvwvHEMrn0HZHf7dJVO7ylqjLK+RpjkI2J2zxAYP+srYhrYHfmx5rzus4Xu1O7HYlw726/TX5Kv00zjMzzyGB+auWM4ng48Spli0TdqCieyajLJXHkJGnb4H3qfNpO6Fj2w03rd3wgl7QOI/HzVj0iLfnHxCyDaLkTgUz8/5Hfouc3t/fRQgf8AtNVxDzY3f9AoVFRz11zfHTwvnk4/VZG0uJ28AuoQ9khqa2imrq0Mhp4y3uYBkuJxvxHlt5LbWXTlu0+wtoaVkLnbvk5vf73Hf4clRmuMTNGan5LqLbwTX1Tg6r/lM8dXe4Db3n3Llujuwlsl4/bmpHCSTvO9ht7Ds3Hs94eu32RtvuTyXY2sbG1rGtDWtGAAMABKe9sbS5xDWgZJJwAFgNXa4EsNTSW5x4GxkyVA689m+W3NY/8APr5Nf7Bemn+F8I0ZLRgn/mef37goevdfiaKa3WmXLd45qlh+Ba0/mVz+ihzBFt9gfko1nhLbNS56sB+YV1R0/DTx7fZH5LqIIWU7ORi8Gul0qLvUGoqD5DoB3D96o6aHYZ960On7cKy400JGWueOIeQ3P4KupoMkDC2Wi6b/AKRLz9iMkfMD9Us0zoonPacYCWz0/pVwggJ0c4Z8s6/Ja91JGemPcVlNWUgZWwkOODH195WxVDqym46eKcD2Dwn3H/X4rAt9ZNHO31yvfOLI5JLTKY924PuB1+Wq4tfpwb/O0/Zc1ufgE9QEF0mPL9VVXObvb/Unnmod+Bx+itbc31pfguzFdMO5fPIq5QoGqJWsjtgJxxVIATGt5mxvtTXHHE8kfIJGszwxWk55VbUxroGW7WCIcySfyUwuEuRoP370CskIOg6Kyqbf3liM5G0bmOB8jsfwK02g5W3vs+1rp/2p7Xw3eJp5taBmTH91v/Erf/ZwTaWEGMGaEt9xI5qH2S6brRqSHUUEndUM1tfSVTNj3khPA5hHhtxZ/dHiqs11eyMucBpr+9V0FAypraplPC0Eu0Ph3nyC1GgdOSW60x1T4iJ6qNjjnmG4yB5Hff8AyWn9Gl5cJViPaQPPK5KS7zyvL3Aa+f6r6Jo6WOhgZTxbNH/k+8qt9Gl+4VTawjrLdT0kckD4o6thkY47cbQcbeWVZ6o1HBpqgbNJ68sjuCJnicZyfIdf81C1nr2LXNrt0j6VlJU0TRCGxOyxzMYAGeW606Cqme4SuaMe/wDVcBxffhRxmggPruHreA7vM/TzWQYTG8EjLTsfcntB1P7K1NW2V+O5qwammB5E/bA/P4KM+TKiVzxFJSV2S19JIHF7eYYdnfLn/dXRG4SEYwF4v6a8a4C6bWUz4ZGjgORuEbaRwLnNYQXniPnsP0AVIdUvE7WVgHEzbjZyPmr203KKta5rHtdjcYO+P9YWVW18whOgXa8JV2btGx35gR8s/ZKNNLj2CuE0zyH1NO4/W0k76aT+JhLc/HmvQw3C4Vr61nT3aHUPaCKa7RioaTy70eq4f8p/vKra7tJ2jmEDUfT3rsuO4pPQ4qlgzyOwfJ39wFR1vDG8knlsfceSj26pbFUPhJ2d6zf1U24xju2y4yG7O9xVDWB1NM17fajOQfELpv4hJ3BeHemvHQLTsk4m89wpMM2CHBVUc4LWyNPqOAKlQycLueztwl/iEncEemv7grKodgskHPG/mE/DLkAgqG2TjjI8NwlU0uDw/EJRcJO4INbJ3BWgflu/NBjH1EjY42l73HAa0ZJKctVsqrvOIqaPjI3c47Nb7yuiWHTUFlbx576pIwZCOXkFn1V89GGCAXdy6uw2evvbw5reWLq4j5DvPyHVU1h0wbeG1FUzNRjIaRsz/NPahv0dkpQc8VRJtGz9T5BW+oL/AA2Kl4nYfO7+rizz8z5LldzqpbrPJNO8vkec8X3fIeSoUlXJWv7aobp9fDyXf3q9UfDFN/DaAfzDv4Z6k/1HoOm+2AbIVDp3GR7y5zjxcR6pb3uaWzMOHN5+5VNpqxgxydDj3FXEYaDuMgrrRXxbYK8d9PY4kuzlSax7aqnc4cnjiA8HBJs9UJYZaR52e0lueh/1+Sagw0uiJ2G7VEGaepPCeFwOQUorYiOqkFbESn3nfcYcNiFItYLrjTt6F4TFUQ+QStOA8cRHgeqsNMU/pF4iAcBwhztx5f5p09dAyFzi7YHvWja3xVFfBCD7Tmj5ha1YnUgJuk+Rzxj5BdA9BP3x8liNRU+aqZwIPA8tKwLRVwOmcQ7p494Xq/HczY6CIOOMv/8AiVX6Un4XVlscdiPSIfycPng/FWfIrNSSvttVTV7QSaeTLmt6sOzh8iT8F0SHTZknc+R47rOQ0DmPNdBPcqWnbzyPXk9to5rvMIKQZPU9AO8n9nuVTQ259XIXZ4YurvH3K+iiZAwMYOFo6KYLfwgAOAA6AKru8/cZgikzIR6zh9n/ADXMOuTblKI2u07tdPE6L2eGlt3CFE6qnOXbE9XHo1o6fsnbQpK+N8phYd+XEPFQpz6hBUERvaQQRspLuOZodjfruusp/R4WcjHBeK3K9uu05nmePAdAO4KTZ2fXzO8AB/r5KTcpeARDxOf9fNHaKWTuXuDDgux+CYvLHtmjaWnZucf69yyBNHLcvaGnj3BekOcKTg8HPt/d/wCiDTkAqtczuJ5IumeJvuP+eVPgJcwZByPJR7lHhjJgN2HB/hK6prgdl5ACDskxPwd+qksdwlQuLqFIjfkAqVKpwdyUinB4Mnqo9JEZPWcPV/NTVzN1q2kejs17/wBF67wZZJWP/ic4wMENHU56+WNB37+YRTxuhZFUDo7B9yBIHNTnMbJDwfYe1Q2mAl5mOw0Cv8b3FjadtAw+s4gnwA2z5n6KFWNDg145EKC/ZTKcl9M+J3txnhKhSbEhdiw5C8RcMFOU0vdzNPQ7KyHJUnFghWlPL3kTT1TwoSimPDM1w6qxpJNgq6pGYyRzG6eopstacoKQLQU8uCFsLJN/Q4vj+ZWEgfjC11kmxSRb+P5lZNf/AIY8/wBVn1x/lDz/AFWupZeS1ekrr+zrpE5zsRSeo/PgevzWIpJs4VxTS7Bcy8Z0WS04OV1eJvotdND9k+s33LW9iVSYrdqC1uOPQrtM6No5BkzWzj/ilePgsHa7h+0rXS1ROZYj3Mv6H8vmVquyyb0bW+oafO1TRUlSB+8HTMcfkGKi3Q4Vx/rNyrq1wjSnaVcLS71LXqFjrrQD7MdWzDauIdG8YMUzW+057qt55FdFhYGNwFku0Ww1V806yqtcYkv9ombc7WOIN4qiMOBi4jswTRukgc7mGTPxur6w3uk1JY7fdqCUzUVdTx1MEhaWlzHtDmktO4OCNjuOqmz0VTGuVZFyZlmDBuUioqGwsJJws9W1M1e4tY4xw9XeKEZUuvv8NOS0EyP6MZuqmeruVdnh4aNh6ndydjp4qUeq31urjuUT5sdU0nCUBXJaklqkcGyIxppT1EczKbdH5KaYspDokwpygPjTLmKwdCmXxJpCcCoRbhJIUh8ZTbmpqVJjkfC4Fji0+Ss6S/PZhsw4h4hVaSRhAJGyaQCtdT1cVS3LHA+Sgar1FT6R0zdLzUtL4aGnfUOYDgv4RkNB8ScAe9UTJHxO4mOLXDwWI+kJdamo7Gb/AAhxB+oLiwZ4m9/HkeQ6/BEkxZG5/UAq9baVlVXQUzzo97WnyJAXjrVGpbhrG/1t5uk3pFfVv45H4wNgAAB0AAAA8AFVoILz4kuOTuvs6ONkTBHGMNAwANgBsEFa6Y1NcdHX2ku9qqHU1dSvD2PB2Pi1w6tI2I6gqqQQCWnI3RJGyVhjkGQdCDsQvo32X69p+0rRVvvkDWxSStLKiBpz3UzdnN93UeRC1a+bWidfX3s7u37RsVc6jnc3gkaWh7JW5zwuadiPxHQheueyb6T1j10Y7fe+6sN6IO8jw2lmOcAMe45DuXqn4ErsKS4xzAMk0d9V818R8FVdte+poxzw5JwPaaO4jqB3j34XbEEEFsrzFBBBBCEEEEEIQQQQQhBBBBCEEEEEIQWZ7T5XQdmmrZGHhey0VbmnwIhfhaZY3tke5nZRq0tJaf2ZOMg42LCCopTiNx8CtC3t5qyFve5v1C+daCCC86X2qgggghC9mfQz/wDpX3T/AN8S/wDyEC70vPf0L/8A6A75/wC8j/8AJMXoRd5Q/wCzM8l8j8WDF8qh/vfYIIIIK8uSQQQRHkhCLiRIIJ6FlNXO/al5sNgAdw1ExuFSRkfUUzmOwHcsmZ9OC0+0wyeBXDPpqUHFS6UrRsWPqYXfERkdf3XdOq7Zox7b3qDUl/ADoXVH7JpXMdkGKlc9khLfsvFQ6pYcc2xx+C439MWH0nTdpq3OPDDXmmiGcg5jcXuz72taR0LD4rOuIzSv/fVdpwbIY79TEd5HxaQvKSCCC4NfWKCCCCEL0fZ7pBpns5sloszu6vF2pGVFbVsI4qeIjnno4jIbjlkuO5ycjV1VI+DvHNDLBQO4GRDlVzNOzR4saRud+JwPMA5rdP1RnsdHS08xiqKiHjqqtx3hp4/VJ4uhwOBg6bkeyQs5qe+tuEkcVMzuLfTt7qmhGwa0bZ/AfgusiHM1uNsL5PuIMdZOHb87vqVHv2oJ7vWSSSPJLzk/yV7ZrnauzPTkmtL9F6TMzLbTbMgPqpsbHfkBz4j7IBPgDmLLTU8sktZXuLbfTetJjm89GDzKp6+jPa3rSm/bNdHbLFCD3jnu4WshaP6uMczkDpu7bkBtM8Bo1OiqwRySu5Y2lzu4DKz2ltLan7eNdiesq5P2tqeoImr42ENjgj9vuwT6sMLPVBzlzi1oPE4ub77oNP0GnrLadL2CnFLabdG2lpYG+Q3eT1PMk9SSTzXnXs77TrDoSsvV6Fqnnu9ZihoYWcMcVBb4iBHE05OC45kdw7cRaPs5WsZ9KdlF3rqTTRM7mcDJpawfV884b3fPfOc/AhUX1cWMcy6ZnC93lHMynOPEgZPfgkLu95ndb6WG0W52KuX1OMf2Yxlzz7h+YWC15ri06NoW0XfNjhpWlrYmkF8jgN8D7R5jw3JPNcs1D9I6uqIZG2Sh9AnmZwvq6iTvZGfwAADPmc+4YC5DWVs9wqHz1M0lRM85dJI4ucfiVTkrGt9jUro7VwPUzHnuB5G9wwXH6gfPyWvn7WLx6NWCjIoauvkMtXVMPFI7bDI2Ej1WMb6o6nd2xcQsW97pHue9xc5xyXE5JKSgsuSR0hy4r1+httLbY+zpWBo6958zuUEEEFGtNBBBV18v1LYKQzVL/W+xGPaefAfzTmtc88rRkqKeeKmjdNM4NaNyVNqamKjgfNPI2KJgy57jgBc01b2jyVbX09sc6Cnxh0/J7/d4D8fcs/qjVlXqGf6493A0+pA0+q3z8z5rOA+lSlvONh9bzPgunpLc2PD5dT3dAvCeIOM5a3mpreSyPq7Zzv0HzPXGyk07XVMgcR6v2R4+a1NptvFwucFWWmj4nBxWvo4hFDxY5Ba5K82Y1UeonDLYhsyMZcfNZcyS1dRHDTxummle2KKFgy6R5IDWgdSSQB5lWGprj31Q6Np9UE5I6nxV52Xuj05Hdtd1UDKiKxNbDbYH7ie5ygthGDzEYzIRzHqEJucDKD6zsBanWzY7ObToOjex9Lp0d/dJonZZVXWQZkdnqImkRtPMbgqyrv8AoXTFJbGbVFZiqqehA/s2/Lf4rOaFshnrYxWSmYguq62okPE6R2eJ7nHqSTjPmr+Wo/atwqrnUj6oO4uHx+60fgFROpVzYKpqW+hQxxkZkfh/D/y/z+SaqJOBoizy3cfFyN0stZWPlLeOZxyAOQP8grS36Rqbm5gEjWOcccsp2cbpuFRluQigpzWScDdmfacPyWhvmiLjYqGCpn7sxVEpihIdu8jOTjngY5+Y8Vc6I0/TNEtfXHgt9EON7nDZx8P9e7qml2AlClUtOdI6fZUNAbda1vdUbD/ZtPOTHkP08VhrlwtJgiJc1v1Yzzcc7n81qbteJbxXTXKoBjMjfqYv91EM4HvPM+9ZSlBnrYgefFxn4bpgT0xQkt1Jf5mnLKC1tpGnwfIc/kSnccDGNHQAYUezHvNN3Cv+3dLo4NPjFHnH45+SkyHhePLdTt3KY7omZd3+Q2SWjYpWMjKM7NCVCbcclUWrJCKSlg/3swJHk0En9FeLMaoqQbtEwn1KalMjvIuP8mqNxw0qeIZcAkdhVJ+1e2uqqyOJltpJCD4PcQwf8PGtZVy/tHtL1hWDdvpEdOP/AIcbR+eVW/RWoTMdSXtwyZqkQg/wt4v/AM4fkpWi83Rl4ubfWbXXKpmaRvt3hA/ABA9t3gAEjvYb4klXWMBDhxhS20L3bcJz7kDRSDPqnZLlMUThKHDlSnUcjY2vc0hrtgfFJNO5pwQR7whCaZEXuAG5Vg2kLQBwlOW2mBcXHfC2dJbIpo6ZvCMuAym5QuGdobPTO0rSNuaM9yInlo8TKXH8AF0HVEbYK2KFv9lE1p96ytkoBrH6TFHBGfq453xt64EULv1bn4rYa2p/RdS3KDiD+6mMfF7tv0SPOHBvgpGDLC7xVHkZA5+aST6+AUZcB7wnKenkq5WxxRuklecNa0ZJRlKiimkpjmJ7oyd/VOMqwg1DURNzMxso8tihcrFUWmo7mp4WyhoJaDnGVq9Bdmj+0GWsZBVMoWUcAkfLIwv4nknhbjI+6d1XkZE8czxotWkulbbj/q8paO7p8Dos3/tjbYmPfUyupWxt4nukbs0e8KRQ6qs11iZJSXSjna4bcMzc/LOVz/tXtFbYdI1lTVUstMypi+qdI0tDwdtlzbQlJ6T6IzmAM/iof4dE8FzSQusi46roiGzRtd8QfuPkvTgORkbhBVdTp8Wun09Txvc2SqHfzetgBrd1zq96krqKK71bayoZFHxmMNlcAOfIZ9yqi3F2zvktmPj+I/4lOR5OB+wXWnENGScADJJWU1d2n2HRtBPUVVUKqSLINNSkPk4vA74b8SFxOguFdX00BrKyeqcGB7nTyueS52/U+axmqqgzWWc9ZqoN/VWo7W3Pruys2s/ECVzC2kgDT3uOfkAPqt7N2r3btE1FSU3D+zrSGd+aSJ5JeOneO+1zBxgDltkZVnWy8NBdX/dgIH+ErCdmUAku1xnHKKJkTfif8ltLm7hsdycOb3iMeeSB+q12xsj9RgwF5nVVtRXSGepeXOPU/buHgE3Sw91QwRjYNjA+QV1BFiKMeShBmI3DwbgK4jjwWN8lKqQCk0UHI43Ww0oOCeVvUsz+Kz1NEG4V1QvdTSxzN+yfmFXqIzLE5g6ras1Y2guENS/Zp18jofkVrUmSNs0bmPaHMcMEHqjjkbKwPactIyCjXF6tK+pAWSszu0/AgrH1/ZPYKyodUNjnppHO4z3Mu2c5OzgVHZ2WUsPH3ddKOI/aYCt0eSSrTauduzyufm4btE55n07fdkfTC5nf+xUXuKnjZeDT9zIJAXU3HnB/jCg6g7Fq65Xq2VtPcKd0VJs5krXNLvdjPgF1tH0KlFwqB+b5BUH8H2VwOIceTnfclU8dmIpIYHYAYGgkeQU+32+mtdOIKWFsEXE5/CwYy5xJcfiSSn0Y5KCaoknADlqW2yUdqLnU4OT1Opx3BHyITVZVw0FJNU1MjYYImF75HnAa0bklOncLi3bJriSqqqjT1K5zKaIBtUSOEvfseH3AYPmfclpoHVEgYPenXm7RWelNRJqdmjvP6d/gs1rTV02odYvmeQKaL6mnaBj1MnBPmeZ/yV9Za3vIQwnphc5qiZYKKpB9Ys4HHzacLV2Sq2ac7HBXZsYI2hjdgvmSpqJKuZ08xy5xyVqzImpnh8bmu3a4EEeITPfZdzTdS8hoQqys6ef0vTlJOTmamcaOXxPD7B+LcfJSdN3sWy8wveeGF+Y5D4NPX4HB+CpLBPxm70ZPqyRNqGD95hwfwcPkmO89ZI9gkaWO2KsUtTJRzsqIvaaQR7l3RvNZntA0g3V1m7uPDa+nPe0shOMO6tPkRt8j0StC31l2s0cTnZqaUCKRpO5A2a74j8QVpT0K4oh9NL4gr6iY6mvdACRmOVv794PwIXnxrJHxmOeIxSDMckTxgtI9ppCo6unc6mkYd5ad2CfFp5H/AF5r0PedJ229PdLPBwzuABmiPC445Z6H4rD3TsiqHVgmoayKSNzCyRk4LSR0wQDk593M+G/UQ3KGRuH+qV4ZceCbnSOJpx2rOmN8eIP2yuYWeQy00sHN0frNHi3wUiiquIFmckHLVrLZ2PX6lr2SGSjbFlwcTISeH3BvxWktHYxRU9QZ66tlnOciGEcDR4gncn4YUz6+nYM82fJZlNwneKl3KIC0d7tB+vwBWHoI5q2VkcEb5pXcmMGSVuLD2bTSPZNcpO5YNxBGcvPvPIfj8FvLfbKS1QCGkp46eMdGNxn3nr8VJWLPdJH6RDA+a9NtXAdJTES1zu0d3bN/U/Id4TNHRQW+AQ08TYYx9lo/HzUC/wCoILHT5cQ+ocPq4s7nzPkqnUmvKa2PfS0ZbUVY2LhuyM+fifL5rn9RUy1Uz5ZnmSR5y5zjklLSW9857Wbb5lJxDxdBa2GituDINMj2WeXQkd2w69ylXCvmuNQ+ed5fI7mfDyHkobilB3E1IJ2XVABowNl4HJI+V5kkOXHUk7kqO/6iobJya71SrmjqOMcDj6w5KqkYJGFpS6eU8LXZ9YbFPCjCupXEYd4JiqOS2Qe4pccomiB8k0fZLSn4T06x/FCRnluFpNCs47hUSdGxY+ZH8llad2CQtloGPDa13iWDl71nXF3LSv8A31XX8Ixdre6cHoSfg0n6rWrGVVHLcbnWwxRlwMjsnGwOepWzRNaG5wAMnOy5OkqzSFzmjJIXvF+sMd+ZFFK8ta05ONzpjHh54KpLLpaC2lss2KioByHEeq33D9VeolnrvqyGlr4KGE8TpiY3TA7RuwcDzJwfdskaJ6+XvPyCdLJa+FaHIAYwbAbuP1JPeffgKVeryKZroID9cRu4fZ/zWcheXg5OSNySm5Dh7uI5KTG7hf7129JSMpGcrd+p7180X2+1N9qe2m0aPZb0aP1PU9fLAUjOE5E/HVMk5RtOCrq5krXWpnBQx+JyfxVVe3k1+PBoAV5Ss7umib4MA/BZ6+P/AOkXjwA/JchbndpXPf5n5r6B4wh9D4XpqcdDG34NP6JFJNwSYzsVYuY2aN7HbhwwqMPwQVdUAfUMBa07dei690jYxzPOAvn+CnmqpBDTsLnHYAZPyVKwcIdG4DiYeEq5tdpLmtkmaGt5hmNyp0NrhinM5HHIfHkPgpnJcvW3kuBjpjp3/p+q914a4C7Bwq7vqRqGZyB/mOx8hp3k7IgxoGA0Ae5NzSRwNy4DyGOah1V4jY4xw4e7kXdB/NQ++dKeJxLiepVeitcs5EkxIb8z+i1+IeOqW3B1LbsSS7Z/K39SO4ad56KYZRKQ4tHuxyVvb5GyU5bwjiYc8uioYXdFY22fu6gNPJ2xXbsaI2hjNAF89S1M1VM6aZ5c5xySeqfqWNprlHJwjgnHCdvtDkq+4QtjmI4Rg+StblCZaKQD24zxN94VZWPFTSxzDqN1MxxB3VeTPeoDg3wHyU+2SNwWlo+SrHOwnqObglaeinye9VMnvV4Wte3BaMe5RaIiORzCB6p8FJa7IUKpPcVjX8g4YRk96i5jndaGmc3A9UfJXFHKAAAMLN0k2QN1cUku4THZKXJO61FHNyVzTS8lmKSbkrmmmyAqjwpmrd6NubYKx9NIfqagcBHn0/15rofZ3K5naZC1xyZbVUMdnqWSwkH/AIifiuK0lQY5GuBIIOQR0XYOzoyXHWtjuUO8YgqIKgA8i5rSD82fkqTxh2VaactIXc4zjZZLSbH6b1HfNPPHDRySOu9uJ6smeXVEYJ3cWTl7ydg1tTC0clq1lO0NzbPTW7VAPd/sSXjq5Nmj0GTDKnjd0jY3hqCBzNMwIJxqo8KyrZHVczskiJp+ajSytYMDl0CkXF3cOI5eRVLPU4yScAdUOdjdIAnpagDJJxhVNbcTJ6sZwPzTFVWundgbNTGA0ZPNZ0kpdoFM1uNSumHkiAyjPJBvJaCYkoJWNygThNQkFoKQ6IFOIyMBCcoj6fPRR30+FZEbJLmApuEKofFjom3MVq+nDlHkpiE3CFXlu6rNR2Gm1LZK61VjeKmq4nRP8RnkR5g4I8wrt8JCZcxNLcjBUkcjoniRhwQcg9xC8Aal07W6UvdVa7hC6Gqp38JDuo5hw8iMFVi9lds/ZRF2kWeOWm4Ib3Rg+jyu2EjeZjcfAncHofeV4+uNuqbRXT0VbA+mqoHlkkUgw5pHQriquldTPx0Oy+reG+IYb9Sh2glb7TfuPA/LZRkEEFSXXoIIIIQundl/0gdTdmssNOJ33aysIBttVIcNbg7RvIJj55wBjyXrbsy7c9MdqWKe3TyUl1awvfbqtvDIAOZaRlrx7jnG5AXz7S4pXwSslie6ORjg5r2HBaRyIPQrTprhLT+qdW936LhL5wdbrzmUDs5T+ZvX/MNj56HxX1DQXkPso+lpcLI6K3axEl0oA3hZcIWZqWHO3HkgPbjr7X8S9WWO/wBt1Lbo6+011PcaOT2ZqaQPbnqDjkR1B3C6ynqoqkZYde7qvnm88P11jk5apvqnZw1aff0PgdVYIIIK2ubQQQSJZWQML5HtjYObnHAHxQjfQJaC5/qHt70Dpraq1LRzycXD3dCTUkHrnuwQOfXHVYS5/TJ0fSuLaO23at2Prd3HG0npzfn8FVfVwR6OeF0NNw9dqsc0NM8jvxgfE4C72gvMlT9NqlZn0fSM0vrbd7Xhm3jtGd/JCj+m1SvkIqtIzQs8Ya8SH5GNvl1UH8Rpduf5H9Frf6FX/HN6N/1M/wDyXptZHtdpn1fZbq2KMZebXUEDxxGTgeey5vZ/piaMr3hlbSXS2OxkvfC2SMctstcXdT9np8F0m0a40p2lWuqpLTeqO4sqYnQvgD8ScLmHnG7DuWenQ+BUonhqGljHgkrNdablaJmVFVTua1pBzjTQ53GnzXzmQS5YnQSvjeOF7HFrh4Ec0hcCvsDfUIIIIIQvXf0LJ3O0hqGHA4WV7Xg9cmMA/wDKF6LXmb6E1Vx2vVlNxZ7uank4ccuJsgzn+7+C9Mrurec0rP31Xybxk3kv1SPEfNoKCCCC0FxiCS7mjyElOCEFR621A/Suk7tdYaf0yppqd76ekBwambGIoQfF7y1g83BXiwGupW33Wuj9LNaJGOnffK5jm8Te4pODut+TX+lS0r253IhkxyJCoWj0nYhpTStttTZ3VslHTMifUPAa+pkDRxSPx9p7suJ6lxXDfpYzwXHQFLBRiSpFtuLPSKljfqg8se0tLury45OM4IIcQSAex3auqNQ1ctst876ahhdwV9widwvz1ghI5OPJ0g9jk318ujwX0hLbAOxW80lJEylp6RsDoomYaxrWzM2A9xKoVg5qd7fArp+G5DBeKWT/AH2j4nH3XiRBBBcCvr5BBBBCFZ01/no7NNboGsjjnkEk0m5e/HJvk0c8eOfEqvfK+Q+s4lIQUhleRyk6LOjttHFI6ZkTeZxyTgZJPjuj4jjGTjwRIIKNaAAGyCCCCEqNBBEhCCCCCEqCCCw+rNfspRJSW1wfNydUDdrf4fE+anhgfO7lYFk3O60tog7eqdgdB1J7gP2B1VxqjWFPp6Mxs4Z6wjaLOzfN38lyS73ioutU+oqZDJI7x5AeA8AmKioc8uc9xc5xyXOOST4lQ3O4iuupqRlMNNT3r50vvEVVfJPX9WMbNG3me8/sJmqlc1oDd3vPC0ef+t/gp1sowA1o9kcyep6lV9O01NY5w3DPq2+/qfyHwK0tHCI2tA+Kuk4XMNGVa22HkAFPvdaLdbSAcSP9Vv6lHa4cNDiN1mdVXMVVwfGx2Y4fUHv6lQkqzsFnK+Z0jjwMdLI44Yxgy5x6ADxJ2XQNSUzbbcbLoqAsfBpmL0q5vidlk90nGXnPJwjbhjTzGMFZrRVTSWm712prhE2W3aap/wBoFj/ZlqSS2mj+MmHZ6cA8VdaCtFXUMifXPdNdbjO6rq5Xj1nSyHicT5jr7lFI7AwkiGTlbq3UxtunSGj+k3F4Y3xEY5/M7JiuBxHRRbsj9oj7T+p+CvnRtkkNS0YhiHo9K3xA24vnlMQW4REnhy87ucoFOo1pteSGgY+85b7SFt9JuQaxoayNuBk4Az1+WVn6VrI4wAMDr5qS6ul7oxMcY4yMODduL3/yVKepZFpuV1ln4drLsQ8Dkj/qP2HX6eKXraoN/vzu5eBb6Nno1L1yOb5Pe52Pg0FQLvG+vt1HboHej2+HDpY+Zmd1cT+AH+ScQWSayUnOV6rDwbaY4+VzS495cc/LA+SzN/e+Bj+NvC6Q8Lf4R/r8VmaquNut1xrAcGCncWn94jYfNdGrKSOup3wyty1w+IPiFzS62eW5zW/ThyJbxeKe2u4eeHOHrfBatLP2wIO4XmfEdgNmka+M80bts7g9x+x89NFem1G2WvSlrIwYqBtTIPB8mXuBVc+UPe4+JXRe1GhZQax1RVtAbBTRx0sLPAua0be7dc1tzHVlXHE32iVfjORlcW8ap/hxgJMgyFf02nvTPTXMkPDSsaTke04nl+C0Z7Kg6hilNeY5HMDnNMeQD4c0pe0boDSudtYS5oHMnAXNdaXQMi1HWA7F3o8Z8h6g/PK6lVN/ZlPX1biHx0THyF2NiR7PzOB8V5/13VvgsdNSAl807u8cOpJ2H4n8EntOAUzTyNc7wXfexyI6N+j9NepPUeaeprSep3dw/wDCGq57EtOZ0HaCRgSQCUA/v+v/AOJV3ai0aT+jVR22LAkfT01G3H2uXF+AK6f2fW1lp0zaqb2RFTsZjw2Cg5vUc7vKsPYO0Yz+lo+acisAY2RwaCRsExcrK2kpXANy4NJK25gY2nPBg9cqnfA6vq44xykdw/DqmNcSUr2ABR9M6ViqKBlXWQBziB3MbuTR973lQ+0q0RU9Jbp2sax54mHAxkbELo8cLGMaxow1oAAWA7W6oNFvpwdwHPI+QTeYlycWgMWCpXCI4Jwr6g1A2jgqKiT2aWB8gz5NKyply5Q9TVxotK3F+cGRoiHxO/4KYHJwqhAAynfomW39p9tdbdKj1o6G3VNY956EuY0n5PcrS9RftOSruMkwbJNK+ThO+STlH9G+M2Ls47S9SvIaZ4YLRAepc/i7wD3CRjvgqueo4mtb0CJP8Q46aJ0X+GM9U5ZbVJd66OlibxSPOBnkuy2PQdLpuQNZ9bVOZl0zxuPIeCwvZmIYaqWpMjWzMcOEPONua6de9X2ykrYnGoZIHx8J7twPCc9f9dFVkc4u5QrDAAMlcw180DVE8QHNjcnz4Vb9huqJLTf7hayA5tfAXMzt6zATj4tLvks1rq8UFdfTW2+o7/LeGVvCRwuHTfywsj6X3cjZQcPacgjYhT8vMzBVdx9Zab6cF4bPouxMika9tRKSC0g7DGR+XyXC+zaEMdA48hj5Idr02bNTN4nOzUAAFxOBg8k/oFmKaM+DMq0xvJFhVicvXaanXdDdK/jkY6jio6Awwl/rcbxz5cuS4hr2sMOlJYwcPqHtj9+Tk/ktLWTEMf8AvbLC69n7+5WSgacjjdO8eTRt+qfGNUx2jdEniNLbpD1wf5LFamPdW63RHm57pj+GFrblIfRGRt5uOFjdbScNxghB9WKIAf6+SsN3VZ+gWx7LYO6tFZUn+0mOD4gD+eVpbo0/sahix61RWNcfcMk/kqrRsHoej6FuMOly7/ESfyV1ecC52imz/UwvlI+Tf5pN3J+zQpLG8QaAN3PA/FXkTMznywFUUY4quBvgS78FdUZ4jI7xccJUoU9rgxjnHk0K5poC2CNp5hoyqaNnfS00AGTK8Z/hG5/JbAULmBpcMcQyE0lPao1NWyURO3HGTu0/oremrIao4jeC8AEsJ9YDzCnRWSmp7bJVVPqthYZXuPQAZK4nrm7VdFpuC6RySUtXX1omjLDgtjaDwD5AH4rLno2VB5hoV3dl4oqrU3spPXiHTqPI/Y6eS7MeSSuR6J7WbhJTww3SEVbcY9IYeF+wA3HI8j4c10e0anoL04Mgkc2UgnupG4dgc/LqsOakmh9oaL163cR225ANilw4/lOh/Q+7KtUpyIc0ilnjrxKYJGyNikMUhB9l45tPmqzWOecNGVt1FTDSs7Sd4aPE4SkRkDeufLxTxhwFHliwVrxW/IzIcLzmv4y5JCyiYHAfmOdfdpouQ9q+vK+q09YprRI6DT+oKSbFUGllQJmP4JIefqluRv1w7oN8VrW4v1FRWLUchDqusgNHcHN61UGGl5/jZwkDwauiV+lnXmz9oOj4mZq6FzdY2ZvNzwctqox4DPEGsHMytK5RZZv2tYrxaWnidJG240eP9/EPWA83x+r8CtyCNkLcMGF5bc66puMva1L8k7dw8AOijUQE9tqYT7UUglaPI7FW1km4Yw3O7SqKxztlq4wD6lVG6P4kZH4hT7fNwSjwKtHdc/0WyE3Ipyok4oWOVdFLmIHqNk82XjppG9W7pUiVaKoU99oyThshdE7zDmkfnhPVA7mdzT9kkKkqJ3Qvjmb7Ubw4fBXt2I9Me5py14DgfenBMKXYr/Np26tq4vWZnhkjz7beoXZLLfaLUFIZ6OXjDThzDs5h8CFwWU7LPahrquyVNuutDUy0k8EoY6SJxaS08wccx5LNq6JtT6wOHLteH+J57ITC9vPETnHUHvH6dfBerOYSeRXDqTtvvVBJEyqgpa2I7F5aWPzt1Bx49OvwV/bO3SCuq3U89ofTvBx6tQH5/wCELBdbqluzc+9etQcZ2aUZdKWnuLT9gR811MIDYrAS9rMLJ44o7bI50gPCXyhoLhuG8jzGT8FmJe2G63CbhZBDb4w7heGjjeNt9zt+CVltqXHVuPMpKjjOzQNy2UvPc1p++B811W96htunaczXCrjp2n2Wk5c73NG5XL9Q9ptTfGGKg4qKjfkZz9Y8eZHL3D5rnV1dVS3OrjrJ5Kmfi4hLM4uc5vQ5KbtdUS50DjgndvvW5TW6OH1n+sfkvLbzxlW3IGGn/lRnuPrHzPTyHvJWhjk4T7lZQSd4xUcc3EwO5Y5hTaSfhdjK1wvOirNr+EpRITT+jh1RB/yTk1OO8UmM8Lz4FHnIwkHYpQkyp1NLwO4eh5KQ45d71WRyEe8clMbLxtBTgnApwHhfnxWw0JcImPqKV7uGR5D2Z645hYxzshKa8gtc0kEbgjooKmAVERjJxlbFoub7RWx1jG83LnTvBGCuxpqqq4aKIyzyNijH2nFc0i1TdImgCseQPvAOP4hRKmunrZjLUSuleerjy93gudZZn83ruGPBetVX4i0wi/1WBxf/AL2AB8CSfLTzWsvup3VdK9lESyLOHSEYc4eXgsdUsMkLgzaRuHMPg4HIPzCm0buMOjPJ4UV2Wuxy6LpYKeOnZyRjC8cul1q7vP29W/J6DoB3AdP3lXMNU2tpoahowJGg48D4JQO6qLVU9y6ancfVDuNvuPP8VaNfkK2FhOGE8HJyEd5IxvLiICjhyWyQtcHDmDkJDnGiRpaHAu2XQFQ3O21FXcXmOPLCB6xOByVzS1LKuBksbg5rh8j4J1ed09RJRSFzRrtqvr262qk4jo2RSvPZ5DgWka6HGuDocqrpLBFFh0x75/hyaP5q0a0NAAAAHIBBVtwvkNISyPEsvLAOw95S5qa+TGrj8h9gohHZ+FaUvAbEzv8AzO/+Tj4aqfPOynjL3nACy9wvkta4sb9XD90Hc+9SxVGrbxvOSVR1TO5ncOi6+htUdNh8nrO+Q8v1Xg3EnG1VeOanpcxw/wDU7/Me7wGnflPtfwvU6KTKqg/OFNp37BbgXmoVhG/BBUpkhY9rh71XB26lMflgPUIKlBWoa8P4XdHtVFE3u3VNKfsOy33FWNvm7yjH3mH8FCuo7i5QTD2ZBwO96UHVTOGW5VTN6pISYn4cE9cG8MpxyO6htfgq0DoqJGCtFTS8cTSk3FnHT8Q5s3UW3zeqWlT8iSIjnkJ+6jKK31HEwbq7pZeSytC8xSujPNpwr6ml2CjKFpaWbkriknWYpZuSuKWbBCruCkC0kUnqhy22gtUPstwjfxlrCRny81gKGTvMs+8NlOoajupRk4GcFU3DOitNOF7Gsd6ivFIyRpHHgZAP4hTKylguFHPSVUTKimnjdFLFIMte0jBafIg4XA9B6zktUjIZXkMB9VxPL/Jdqt1+hr4A9rhxY3CrB2NHJxb1Cyelayok0fRU9dNJUXC2uktlTPMfrJnwPMXfO8O9DWyjykCi1tWZXcLT6qRcZzatX6hpGjENxbTXMOz7UxY6CQeQaynp/i9R2DiOTyVSZ+fVCc1uNU9GMDJTVTOGDHVKdIA0lVtZL6pcVXAUi7GeSDeSDkQGVqqulIIIITkEWOaNBCEnHwR8wjRcKEIi3HuSSzKX1wgfBCFHfCHdFHkpfBTwMpJblJhCqJIC1c97S+xqy9o0RmmaaC7NaGx3CFuTgdHtyA8fI+BC6q+IHomJKUHkopImSt5XjIVyjraigmFRSvLXjqP3qPA6FeF9d9i2ptB95NU0np1ubv6dR5ewDxeObPeRjwJWDX0akpiPcub627CNL6yL5n0rrbWkHFRRYZk4ABc3GDgNA6cz71z89qxrCfcf1Xslo/EUaRXSP/ib92/cH3Lxagtt2g9kWoOzqQvroG1NvJwyvpsuiOeQdkZafI/AlYlYD43Ru5XjBXstLVwVsQnpnhzT1H7+SCCCCYraC1OhO0zUXZxcBU2O4SQMLuKWkeS6Cbp67M4Jx15joQssgnNc5h5mnBUE8EVTGYZ2hzTuCMhe6OyP6R9i7SXQ26ta2y397uFlG9xcyfAzlj8AZ5+qd/DPNdeXy5XU7H9JHWlj0dV2FleajvGtjp6+Yl1RSsxghjuuRjBOS3p0x0VPdsDlnHvC8WvX4d88gltTgATq1x28Qd8DuOvcTsvRvbD9JOz9nfpNstQjvGomeqYskwU7v+0cDuR9wHPiWryPrLtN1Pr+Yvvt5qa2PIIp+LggbjkRG3DQfPGfErMve6R7nOcXOcclxOSSkrKqa2WpOpwO5ehWPhigsbB2beaTq8jX3dw8B7yUEEEFQXXIIIIIQglxSvglZLE90cjHBzXsOC0jkQehSEEI3S5ZXzyvlle6SR7i5z3nJcTzJPUpCCCEbaBBBBBCF6U+hRPw37VEPD7dNC/izyw5w/8AF+C9ZLyB9C2Vw1vfowfUdbg4jzErcfmV6/Xa2w5pW+/6r5b48by32U94b/2gIIIicInc1rYXnyJBBBOQiJwFxLTl1rNaa/1ZcrWHwx1dR+xo7sW+rT0NC97JO7B2Mz6uWtY044eGIOcXcDY39I1ncqqOhZarTN6PfLiHQ0sobxmmGPrKkt6tjBz62GueY2EgvCzfZbbKS2aXaaBndWtx9HtzC8vIoosxwHjO7+8AdMXOy4md2SmOPRSsGhK1NPSwW+khpKWMQ00LeFjASdvedyfM7rA9vsgb2SagYXBrpImtaD14Xtd+QO66BjjcAuM9vN6bWaIvr2P+pZE2GEjfIc9vEfj+QB8VSqTiFw8Ct2ygm5U2P62f9wXkFBBBcEvsNBBBBCEEEEEIQQQQQhBGiQQhBBBBCVBNVVXDRQmWeQRxjqf9bp1Z7WtnkulqdJT5NTAC5rc8x128cKWFrXyBrzgFZ1ynqKWjkmpWc72jIHf++7rssfqvXM90L6akLoKMEgkHDpB5+A8ljXycyikkUaWTou3hiZC3lYMBfKtfcam5zGeqfzOPwHgB0CEkmSmZ5e5he/GSBsPE9AhxZKQY/SauCDm0HvH+4ch8z+CmWeNVPs9L3MLC45djn4+J+K0FBF3srW426qsi2+C0Foh4Yg883fko3FWWhTq+sFqtU0+wc1uGDzPJczqKrgjfI92MAkk/iVp9e3MRiGkadmDvH+/p+qyNBQOv92tlsaMtrZwyTxEQ9aQ/4QR8VF4pztTgLQy28iz6X06S4SXKR2orm09Im+pTRnxB6g9cldG0zC50zywlrz9W1w6E7E/AZWU07HPq7UuoL5TQmWKoqPRqTh9gQQjgaQemSCfeuk6esklsj45y3vTvwt3DSVQmnjjd65XQ26y11xANNESO/YfE6fDVTLnWMofR4om8T9ooYgM523PuAUqAPETQ/HF196Xwt4y/A4jtnqjWPNWufozQfNer2jgynpCJa49o7u/KP19+ngggggs1ejABoAA0QQQQQn4QUDQ9rZd/pDaMiLcxU7qiskGOrIDwH4OcPknbrc6ezW+etq393TwtL3O5n4eapOz3WlPpjtZpb1cGOb3Vn4XRxj2JZcyY+GQtShY7Ln9MYXmPHNVEKaKlz65dzeQAI+ZOnkVd9u13YLlc42O3nuL3nfmGjhCwmjyDO6Y8wDj8v5qF2g36S9XGOZ2eKZzpcHpkqRp53o8HwW40YbheLOOXLp+kYBJaa2Zw/rpse8DH8ytTqa5sttmnkJwQ3hHvOw/NZqwytprHSxZGSOM/E7Ku7RbpxUFNFxbSOLj8P/NQ45nJc4Cx3arALH2eUEBIE93qmveAdzE0F36N+a87Fv8AtF2m2ihHrRtqo8t6FrPXcPwIXR+0q9OqKykifI50dJTve0E7N4j/ACZ+K512OB1fr+ruD/WFNSyzAno5zmtH4FymaMBzu4J5xysb3n5Bd/7epRcNKaGtAP8A1u4xOI8Wtbg/84XQ4tSsgLYAMNaMbLkvaLVGs1T2cUpORS08tU4e9rcfiz8Vai6F05dxdVCG+o0KVz8yOd34+i7LR6siEckTyTkeqQrbTNXHIDUPcPUy0e8n/XzXH6G65xkq/o76YYWsa4gAknfqm4xsnc2V2dtdGBkOBK492j3f07UD2B3EIwGD9fxUxmqZIWHD98eKwVZcfTK6eYuzlxAKaBqnOdphP94OLYrO9pVd6PpuCEHeWbPyB/mrRk/4rI9ognvNys1qoxx1VS8RRMxnie9zWtHxKmj1kCqynDDhdSonHSvYHo+054ai+VdRfJ2jmGt+qiz5OZg+9qzLqnJV32qV9ONbS2iif3tu09TQ2Olf4sgZwuz5iQyD4LJGcjqkHreseuqf7Og6aK4hrnw+y4jPglvuzo2OcXYDQSVS+kbDdRLlUkUrmjYvIZ8zhOATC5To6gspmgnLnes4+JO5/NNS1PqqHJPk4TMs2wGU/CZlYjtbqM09tiz7UjnfIAfqr7R31NtafEYWS7Upu8uVni/defxatbYfqrVTjxblTflAUOfWKn1UwLRk7Z3XPK6q/aOtK2XOWUkLIR73esVsLnUhjWNJxnJJXO9PTmop6uudzrKiSUfw5wB+CcwdUx3QK6c/vapng3dYHVE5qb3OGnJ4uAfDZbeGQND5D0GfgsNaov2tqujjO/eVAc73A8R/AKZveoH64C7RaqZsf7PogPUiibkfghUyekaprXcxTwxRD3nLj+YUiwkTTVdT9nj7tp8m/wCaq7VIaie5VROe+q5MHyZhg/5U0KYrRW04qHO6MYT/AK+StaSQMpWE9Rkqho5eFlW79wD80L3dTRWpjY95ZXMhjHi4n/zSpF0PRVD+17+5+MxQxhvxJ3/L8V1KWyF5jncMNbsAsd2OQU0NrqaiaRjcShnE84zgf5la+/8AaHZbHE4PnFTK0erDD6xJ8M8goHHJVljcDVZ3tRrjFaaKwU7+Gqubx3uObI8j8z+AcuOdv8rKSOy0cQDWMDiGjoMAD8lp2anN11cLtcHYGXv4RuGgNIa0fgsJrOC4dpWprbR07GiV73+sB6kUYwST5AH47DmU0EN9YnQKaNjpv5UQy5xwB3kpvQGnai8mCGAYBbxvkPJjT1/yXcrVaaezUjYKdgaAPWcebj4lM6e0/S6btsdHSt2aBxSH2nnxKslzdXVGodgeyvfuG+HI7NF2kuDM7c93gPuevkjHNO0w4phGBu8gbcymS4MBc4hrWjJJOAArDT1N6beIGgZ4Q6Q+7GM/iEyja8ygt96tcTzU8dtkbMRk+yOufDyT8lG5g5clBmhweWFtay3AtPqqgrKEjoulyvAAcrneo6w6R1XpXWAPdwWys9Gr3cgKSoxE9x8eBxjeP4SuK9qmmn9lfatXwU8XcUUdR6dRtaMAU7yTwN8m+vH/AHCvR99sNPfLTW22rZx01XC+CRv7rgQfzXMu0a2T677HbRfaj63UOmJH2i6kbl4YQwvJ65+qlHlM4qRp70yRvM043Gq4fUsbZ79OyIDuYpW1NPjlwE8QA9xDh8FZ18TaO6VETHAtbIeEjwO4/AhVFwPfUVJPj1qfML/4M4H5NPxKurlE6pp6KtijdIx9M0SOYCQCz1ST4bAKfKzC0k6K2o5uOIb8wpFNLw1HCeTxgqotc/E0NUxzi2QOHMbp4UaKrHqOB5hWpn9Jt1JLncM4HfA4VbWgElw5PGULbNx0csJPsniH6pw3THbZT0jsj4qn1LTemWSsiG7hGXN943H5KzDspl4DwQdwRgoQs1FOKuip5fvxh34KRJxAQ1Uf9ZHs4eIVXauKG2uhd7VNM+I/AnH4YVrQygucwn1XjIShMWnjnFwoWSMdiRuHNPg4KFcAGTxVzBwxT4ZK37j+n8lGtsxpJCB7GcOH6q1dHHI2SGQcUFQMHyPinIUC7xmajhrGjMlN6kniWH+X81TVGYZ2yMO+eIFXttldDPLR1OHPaOB2eT2Hk7+fxVTWUhppJKY793uwnq3p/L4ITSrCGoBDJR/VzD5OUiGcwy8JPmFT2qQStkpXHHF6zD4FSuMzQnO0sZwQlCYtTBOHxgFKLsKntNb3rCxx9cfirHjynKPZPRzg7H5p0nZQXOwU7DUb8LvgU4JE97uYT8EuQQozjwlAP4XBw5J6blWAcjDtsJ+z2irvczo6WLj4ccTycNbnxK0Q7Oa3hBNVTh3gOLHzwq75443crjqtmltNdWx9tBES3v0A9xJGfcsuHJQOVph2dVo/9pp/+L+SX/6PKwY/pMDvmP0UjZGO6pj7RXs3iPuwfos/TS8DmnwKdrW8MpI5O3V+zQVU07ywH++7/wC1T8+jal8bRmJzmjo8/wAlO0xn84VR1vrxr6O/4f3WMLu7qWPHhgqygqOEjfZWs2iawgERRuIPLjRt0lXt29FB8xI3+anDYz/7jfiqb6atG9LJ/wApUVrgQlg4UyOw1rB61K7HkQf1Tps1SD/1WTPkMp4iadnt+KpPbUs3p3/8pUejuU9C7MLy0Hm3mD8FZDVVXj+rh9/Cf5qF+y5//qWX/AUptqqDypZfi0hV5LdBKeaTlJWpR8QXihj7GlMrW9wBx7h09yFReauryHzFrT9luwUXiUs2uoaf+rSn3MKI0MredPIPe0qeOjYwcsZaB4LKrK+sqn9rVtkc7vdk/VO0E2/D4pu6x8no4A1jx6vCVLqohNTHborbaV+NwsY18fcVSMepkD0yIWAkcPJSIWtwNlJ6I/vCBXx9xUlruSfifsQmWhuOSeYADnCQ0j+8J4uEfcVb2WcCRzDycEu+xmS2F49uJwcFX0kghna4eKuJR30csbuUjSE30R/eFZbcYy3GCqSvIlp45B1AKqy7dWUP1lu4SN2OLSq9zGgkYVhtK/G4VN9fHnYqZQzYeN1aQy4dhUsLQ1w2VgH44T4pHxOjGSnRVLJncrQiqfqawO6OVvSS5AVRX+vC2QdCpdvmyxqrlWgtDTS4IVvTS8t1noH4KtKabOFC5PC0lJUmNzXDcg5V1VtEcoc32JGh7T5FZanl2Wnhf6XYGSc307+B38J3CqPGNVaZqCFf2as9Ipwc/WRnB93RbbTurZrc5rHuJaNgcrlNpuHoNa1zj9W71Xe5a5ruF2PiCqj2g7qdh0XTbjdGXS72ivb62YpqMgHq8Nk4j7hCR/eUrjXOrbeH0LuAnMZIcAejgcj4ZG62sV0p6ilZUMkHdPGQTtjyPmFQkYQU4qXJJk4VHeK8M9QHlzQuN/hp2ERu43nqOQWUq699S4nPVSxREnJTCV6hJ3QBwEklDiU6YlcSMOSQcoIQlouJJQT0JaCSDhGDlCEaIjKNBCEXIIsbZSkE5CTgpJal8KHCmoTLo89EzJTAqZwoi1CaqK62Wmu1BPRVtOyppZ2FkkUgy1wPQryz2zfR7qNKOku+m4Jquz4LpqZpMklL5jq5nnuRjfbdewHR5TL4AqdTSx1LcO3710lkv9ZYp+0pzlp9pp2P6HuP20XzXQXqPtn+jY26Pqr7pZrYqw5kntgGGSnmTH9137vI52xyPl+WJ8Ej45GOjkYS1zHDBaRzBC42oppKZ3K8eR719PWW+Ul8p+2pnaj2mndp8fsdikIIIKqugQQQQQhBBBBCEEEEEIQQQQQhBBBBCEEEEEIQQQQQhd++hjO5vaRd4cDhfaXvJ65E0QH/ADFexycLxp9DP/6aF0/9zy//AC8C9lk4XZ2r/Zh5lfMPH4xe3f5W/RF4okEFtLzhBRa6ugttJPWVdRHS0tPG6WaeZ4YyNjRlznOJAAABJJ2ClLHalcdQamt2nYzmmha253LB5xtcRBE7qO8kaXZ3Dm08rHDDkJRqqq73G5W7QuqNYGney8yW6aego5wWup2Mjc6CFzSBwvc71n7ZDn8HE8RsKu7XbKbTtkt9qpABSUNPHSwNHIRsaGtA+ACk6voHXWzikZw4fU05e07B0bZmOkH+AOVZdrm2hBds5/JjT+age4N1KsMHMMBRtT3j0KkNNG76+YesWndrf8/5+S4L2vTNuuh7xOTmlpXxxweD5u9ZxP8A7reJvxd5Laalu81TUejRSk1dS7hMg5sHU/AZx8PJc27WbrC/s+hpaLDKV0wIDT9kO9UeY3B+Cx6l/NG8+BXWWGPludKO+Rn/AHBcJQQQXIr6wQQQQQnIIJ2kpZa6rgpqeMy1E8jYo4283vcQGgeZJAVrT6Zqzqd9mAZLWxT+jubE7iAkzwkZ/ddkHpkbZ5qxDA6Y4G3eufvF6prPFzzHLjs3qf0Hefur7R/ZDfNY2s3OB1PSUHH3bZalxBkd4NABPxOOvgntTdmUOlGFtRdPSqjIaI4YuEct9yTy26L0V3FJo/TtLRtIFJbKccR++/HP3k7/ABXm7tE1OS2prZ3FzzlwaNySTyAWq2kiGmMrxqbjG7VLiWPDB3AD6nJVXoLRr9e6wq6BlSaCzWqjfW3KveAWxDhcI2k8gS4F2Puxvws2x7ZGNexwcxwyHDqFuNbvd2WdmlBoWJ5ZqG94uuo3g+tHxY7umJHQAAFufsZ5SFc4tVQXNMTum7SkraZrWBzBjC3eE+Ip5ax1PWyFwk9kk7EdPf8AUDvVggggsNe0BBBBBCVci7StO/se5NrIG4paok4A2Y/qPceY+PgsO5+Su96xspv2naulYAZuHjiz95u4Hx3HxWLsnZAZIeO61TonnGIqYglvvcRjPuXT0tcxsA7U6jReC3/hKrlurv4dHljxzdwaeoz56gePgucNOSnbUzi76oP9o7haf3W7D8cn4rrzeyexiJzCaokgjvO9HEPPljz5J+i7MbHRCNojmljjaGtY+TbA92FIbnB4qmzgO7ZGSwf8R/Rcyo4zPMyNu5J5eS29sstXPwFlM8MHsucOEYHmVtqG0UVtAFLSQwEDHExgDiPM8ypaoSXMn2G/FdRSfh+wYNXPnwaMfM5+i5dN2RVt9r5am5V8dLE54IjgbxvLR0ycAH5rWWDs5sunqmOphgdNVsYYxPO7iIB54HLf3LUDkk+KzpKuaTd3wXaUXDNqocGOEF3e71j89B7gE3BBFTQsihjZDEwcLY2NDWtHgAOSWgjVRdQABoESCCCE5BBBzg0EkgAbknos3dtbUtGXx0o9KlbsXZwwH39fh81JHE+U4YMrNrrjSW2PtKp4aPmfIblaRzg1pc4gADJJ6LOXjXNBbgWwH0ybwjPqj3u/llYi8X+supPpExLekbdmj4Kjkm3xla8NAN5DnwXldy45lkzHb2co/qdqfcNh78qbf7zXaur6SimfhtXUR07IW7NbxOAO3jjO5T90r21WsL5Us2jNS6GP+BnqD8GhQdMStj1VT1bxmO3QTVzgf3GEN/4iFAtL3ObE55y5+XuJ8TuVrhoYOVowF5nNUS1LzNO4ucdyVOuswqbwGg+rGA39f1V5QVHA0b4WUpZvSKuWb7ziVeU0mACn4VXOq2rb+8UoYw4AAHwVXX3B9a5veuL+EYGegVbFUF8Z36puqqhDE95PstJW9Txt7JuQuVqpnidwDj8Vg9cTwzG4SlgPERCPIAYP6pvsftUEFLeaxkQaZpI6cEE9A5x/5gqnWE5bTxsJyXZe7zJK2fZbTCHTVtyMOqqx0rv8XD+TVMYmch9UanuVYTymQDmOg7yr3VHBN2gxZGTQ2xkHPkXPcfywnoixzuX4qnrqo1Os9Qz5yO+ZAP7jeE/ipkEu6YYY9Byj4JRUSgn1z8StHTvYAP5qaypwBzVHDMQBun/SMBMMEf8ASPgpBUzf1n4lWdVcO7he7i3A29/RVzeBrWtySVBq6suljjB2zxH4f54QFRjfPJJ2EX9ITvS5j+c/FWUXC6TYnACPRNLTO7Wqe+VbPSKLTNFLdpITye6Nv1IB+93r2YHM4USCbgaXHmd05TTG1dn9fUu9Wp1Ncu7jJ60lIcFzT04pnAY692k9GiIPq+HxTvTZwR6+2qrYvSal0k9RN39TM8yyyu5ve45c4+ZJJSjHIOoPxTUM2GhOekEuUZo4jsE8XGcbkH3IwJBzafgoVwc7v6aPB5l528B/mtbpSzNuz3zz5MEZxwjbid4e7+a2DrTROj4DSQluMY7sbLPljijdygldrbbfWXCDt3crQdt9f0C48+b1uaYln35rZau04LY91XAM0ryAW8+7P8ism9jHndjfkpmUnaN5mOWJV1MlBMYKhmCPHcd4XONeSd/qq2x/dpy7HxK21E/uaKnb4Rj8lnb3QU9ZrCMujBLKcDmR9r/NamamiZG0ZcA1vQp5oZNMEKmLlCdwVjtb3j0O03KcHBjiLG48T6o/Eqjo4zQ22lpz7TI2td78b/jlWOrLWyt9ApO8cO/qQ9455az1nfojqLRl4Hf/ADb/AJo9ElA2TvTqcn2vkVAr6juLbVOzjDMD5Kh0KRHeKyucMto6Z8g/iOwHyyr2/Wt/7OcwSjL3dR0SdH6bkZbGt7xpdcK0A7H+qZuf+V3zS+jS8vso9MgLh623muh0Uws2m2vl9qKAyyZ8ccRUCwsdBZaNrxiR0Ye/+J3rH8SU/quills76Zrw11W9lNt4PcA7/h4lNNA4YAc0DwTfR5ceypfTIM+0kwyYpqrzLQolTKK2+0UGMspmGod7z6rf1PwU+Oif3bm8TfWOVFtFA6Satqy8Zll4WH9xnqj8eI/FHo8v9KT0yn25ldwXCWGLgZIWtO+AU26V0jsuJJ8022jd94KSyidgesFEaaX+lTCup/6kuBkk8gihYZJXZa1rRuSulaU01Dp+gaS1rq2RuZpeuTvwg+A/HmqvRGnBSsFwnGZXDEQ+63qfith9lYFa2d57NjdBuvaeEaWipIxX1Lh2jvZGDoO/bc/TzKSq2/agpNPURnqXjJz3cQPrSHwH8+ia1HqKGwUhc7ElS8fVRZ5nxPkuQXaetvtydU1lQJJAzAGPVaCeQHQbKKltU8x5nNw36rW4g42orY0wUzw6Y+eG+J8e4fHxpO0bUldra/act0x4KWqukDPRWnLODi9bPicHmV627Mab0qurJ3biOJjAfMkk/wDKF5P07Y33HtasGXgxUMM9W9vn3Za0/wCItXsPsub6Hp6SVzSXTzOcCPAeqPyK6T0SSNgY1uAvCpLs2qkfPPLzOO5OVo6ulDgdlR1tDz2WnNQx+fUPzUCsAIPqH5qE0039Ka24U/8AUsTV0nCScLH0sUVj13WUVSxr7RqqlMckbvZ9KiZgj/4kGf8A6wPFdGuEbRn1SsVrS0TXizSMpC2O40z2VdFI/YNnjPEzP7pI4XeLXOHVKKaX+lWBX0+/P9Vwey9lhh7TLpp6v4pLbSgVYcRjv4iQGjPmMA/wuXcaGgprZTR01JBHTU7BhsUTQ1o+ASqappL9TUV7gY5kk1OG4ds4NOCWOHi13EMdCXBOnksKvgqXScvLovZ+EKm2QUPaNcOck5ODnwG22MFYPtM0ZS1lrnu1JTsirqbMsjo2hves+1xeJA3z5Lkj916RrqYVtDUU7vZmjdGd8cxhedYrbJwBrngEHhK0rbFOWFjhsuJ44dQxVUdTAQOcHOB1GNdtzn5JrPeUviWH8FEopO5q8dCeEq2gtxbK5heOF4UGe1PjqXfWAEHPJbfo0v8ASvNfTIP6ko7PI8Cmi7dWX7P4yHGT2hnkmjbWg4Mh28k70WXuURroB+b5FYkt7m9XWA+zJwTN+IwfxCEEhZv1jOVdXSzxR3mmnL3jvY3Qnccx6w6eRUuy6RlvVyFNQwSVEuOJzeIAAbbk9BuEppZAMnAQysjkcGRgknYAaqHHKMskB9VytqaQSM7t3I8loK3suuOnqF800ENRTsAJdC8uLAeeQQPwVdScLQOFjWuHPAwpYqbtBkOHuTaqoko39nNEWnx0UKvt9RWxMmgZmtp92kj+sb1aff8AmiqbfJeLfDVxDhlYDlpO/wC80+a0Eb8gEc1HlAt9X6Q3amnIbKOjHcg73HkfgVabRsG5ysp1wkPsgBZNlpDJmyiXG/ECAreWggcY6tgcQ/1XgnkU5c6T0ac4H1bzkeR8EKCRuXQv9iTb3HopxTxN2aqL6uZxwXfZMxQx0szXxxjY533yFfxOjkja9gHC4ZGyontcxxa7m04Kk2+r7mTu3H1HHY+Dv81Yaxo2Cquke7clXOAicizhEXbqRQJ+J/eN4TzCNRWuLXZCkB4cM9eqUJpXU9KUjKWxUvCAHSN7xx8Sf9AK3WI0jquCkpm0NY4RNZnu5TyxuSCtb+1aIt4vTKfGM571v81x1VDK2V3MNyvomyXCjmoIhE8DlaARkAgga/8AnrupSCgSagtsQy6thP8AC7i/JRZNX2uPOJ3SEdGsP6hQNgldsw/BaUl0oIf8Sdg/4h+quUFnJNc0bdo4ZnnzAA/NMjXIe4BtHjzMn+SsNoah2zPosyTia0Rbzg+QJ+gWpQWSqNYVTT9XDCB+9k/qq9+srk5+A6Ng/dZ/NTi2VB3wPes1/GVrZsXHyH6kLeoLnztTXJ43qj8GtH6Im3ytfniqpfg4hTC0yndw+aov44oh7ETz54H3K6EgsIy61eciqmPveSpUd/rYyPruIeDmgoNpl6OCZHx1RE/zInDywfuFsUFl49UVTccTI3j3EH81Kj1U0t9enId5O2KrOttS3ZufeteHi+0S7yFvm0/bKPUMDInRTNGHPJDsdUxSuEsZaTlQrhcn3GUOcOFjfZaN8I6GfgkAJ2K6ekjfFC1km68UvtVT1txlnpRhhPlnTU48Tr9UxOzu5XBCN2NlJuEfrhw6qDxcLx5q8sJTmO2TrX4UWJ2Qnk9ClxP3B8FdwS8bWHyws5HJghXFFN9WPIpimYdVH4O6qayLoTxAe9Vcx4XFW9w+ruMb+kjC0/BVNU3Dne9StKikGChE7BUuF/G0jwVbG/Kl00mHkdCq1T7IV2g/xD5KcPrYHs8ki2TYPD4IRO4Xe9RmO7isI6E5WaVtLTwSclZU0ipKV+WqzhfgqJycFd083JafS83fOrKQ/wBvCeEfvDcfqsZDJyV3Yq70S6UsucBrxxe47H81WeMhWIzhwU10m61VhuHptCYiczQDbzb/AK/RZGqPBUzN8HkfinrZcHW+sjmbvg7jxHUKuRkKUO5Stv6SHtyCk0t2kt9T3L3n0Kd2x6RSH9Hfn7yVDq5GwyslYcwTjjaeibe5szXNe0OY4YLSMgjwTMJ5K0MpPUpmV/dxkqutlyNPIyjqnlzXHhgneck/uOPj4Hr135z6xzBGW9U5MyvVmQgOSb4kYcq2UqczhHxJHEjByjKEtBJRhydlCNBBBOQlA5RpCUOSEI1XXzUVr01SCqu1wprdTk8IkqZQwE+AzzKpO0/tBpOzXSNVd6gsfOB3dLTuOO+lI9Vvu6nyBXhXWGt71ru6uuF6rpKyfcMadmRNJzwsbyaP9FZlZXtpfVAy5d9w1wnNfszvdyRA4z1J7h9z9V7EqPpM9ntNWNp/2xLI0nBnjpZXRt2zv6uT8AVqNJ9qWlNczGGyXunragAnuCHRSkDmQx4DiB4gL57JcUr4JWSRvdHIwhzXsOC0jkQehWQ28TA+s0EL0mf8OLc6PEEz2u7zgj3jA+RC+mRwiAyuBfRt7b36qiZpe/VUk16jaTSVUzuJ1UwAktcer2gE5O5HmDnv66WCdlQwSMXh91tdRZ6p1JUjUbHoR0I8D/bcJCItSxyQwFOsbCZMeVyLtn7BKDtApJ7jbIo6LUbRxCYbNqcDHDJ54GzvnsuxEbpqd7IYnySvbHGwFznvOA0DmSegUUsTJmFkgyFo2+4VNsqG1NI7lcPn4EdQe5fOC+2G4aZuk1uulJJRVsJAfDKMEZGQfMEdRsVXrZ9ruu//AEi66r7sxgZSA9xSjBBMLSeEkHkTnJHmsYvPpA1ryGHI6L7FopJ5aaOSpbyyEAuA6HGoQQQQUauIIILo3Yx2MXLtavfC3jo7HTOHplfjl17tmdi8j4AbnoDJHG6VwYwZJVOsrIKCB1TUu5WN3P769w6qL2S9kF37WL2Kejaaa2QuHpdweMshb4AfacejR8cDderNO/RX0BY6YsqbfUXmY8566odkeQazhbj4E+a6PpTSls0VYqa0WimbS0VO3DWjcuPVzj1cepVuuwpbdFC31xzOXzTfeM6+5zkUj3RRDYA4J8SRrk92cDx3PNZfo4dnE0ZY7TEIB6tqJmn5h+VBq/ot9m9TCWR2OWldnPeQ105d7vWeR+C6wgrppYDuwfALmG327M9mrk/53fqvn12wdjl17J72YpmvqrPM7+iXAN9V43PA7oHgDl1xkbLny+jPanoODtI0PcbJNhksje8p5SM93M3djv0PkSvnXV0s1DVTU1RG6GeF7o5I3jBa4HBB8wQuSuFIKaQcvsn94X0ZwfxC6+0ZE/8Aix4DvEdHe/XPiPFNIIILLXeoIIIIQvQP0MIGu7Q7zNk8TLU5gHTBmiJ/5QvYZOV4u+h5U9x2rVLMtHfWuaP1uZ+sidt5+r+a9oLtLSf9W95XzF+IDSL24nq1qCCCamnZTxPlle2ONjS5z3HDWgbkk9AtlebpxxABJOAsholzq+O7X+Xi4rnWPNPxgHhpYz3UPA7rG8MM4HQ1DvFPatu1ZS6cudwpoy30alkfT07xwvqp+E92wg+yC7Awd3E4OACHF3VFo7TlutFGC2joKaOmhYTuI2NDWj5AJjnBoyVI1pOgQvV1FO3Y5eRhrfDzXONS30QiVzpPWAJe8nZoUy9XpzuN/Fl7uXksN3B1Nf47b7VLDiesPQjOWs+J5+Sx5JC8rYhiDRkqvus9RbdPvurgRW3MiCiY44LWOPte85Bz5sXN+0+uZT2+mtMTuJtOxocRtk89/ln4rf8AaHfGVusYIOL+j2/6trfs8YbxPI/xxj3sXDdSXc3S4VMxdnjkJ92+Ao5Wkwvx3Fbtme1t0pnv252/UKmQQQXIr6sQQQQQnrZ9l3o9tu9fqOtjD6Sw0MtcA/2Hz44IWH3udkebQtz2CaYfU1pvVaDJK0GYufuTI4nBPzcVzK2CWstENgh4mm8VjJqpwOMUtOCce58kgGfGPyXo+zhmjdCMqSwCoqjmJh92G/ADf5roKccsLR36r524tnM92l1yG4aPcBn5krPdq+qG08D6Nr/Ui+snI+088m/D/XJcX0ZV0lz7Qqa43YGS12SGW8Twjk4QtzG34yFm3XGEvtE1EautfA2QvDHEvdnJe881k46o0OlboW+rNdahlI0nmIYfXeR5F7gPgrrBj1lxpGnKq2/6grdV3quvVxfx11dKZpSOQzsGjyaAGjyAVe+r9EjMmccPrBG8cIx4KnvNVwsbCDz9Z3u6KTHMdU8OMeHMOCFtbfWsuFHFOzYPG48D1CkLK6Lq3N7yBx9V/rsB8ev+vJapctURdjIW9F9M2K5fxW3x1B9rZ3+Yb/Hf3oIIIKut9BBBGhCHREjKJCEEY5okpqEhRk4CT0Rnc4RHmhAQCJH0UO43aktMXeVc7YQeQPN3uHMpQC44CjkljhYZJXBrRuToFLVbeNQ0VkZ/SJMykZETN3H4dB5lYjUXaNPUtdDbmmmiO3eu/rD7vBZZ9Q6V7nPcXvJyXOOSVqw0JdrLp4LzK78axQ5itw5nf1Hb3Dr8h5rRXzVtVdi5ue5pgdomnn7z1VI2QiME83blQJpuOVkeeZ3T8kvmtpkbYxytGAvIaqsnrZTNUPLnHqf3oPBIqZt+ahmT1ST1SaiQuJx12TNTJwMAUoCqFSaWX0axX+rHtzdzQRn+J3E8fJqaZMIIpSNuFnCPjsE3Vyd1YbTTdaqqkq3D+EYH4KNPLlpZ4kZQkJU+2jhib4lXDJeFiqqMeq0eSmOkT0isqaXETjn7SgXiqxC5gPPYpyGbhgcc/aVJcqkuk57ZXQwf4TVx9X/ju81itZTcVS5mdmtDfwz+q6to2lNJQ2CA+rwUzZCPBxBcfxK49qAuq7m6Nu7nua0e84AXaBO2j9Kkbs2no3cPlgbfkpnbAKqw+sSs7a5u/fW1Od6iofKf7xz+qtoHZwqOyDgo8eB/RW8DsFNIQFbRSYASnzgA7qI2XhCamnww742SYTkG1HezyOzy9Ufn+o+SfbJxFo8fyVXTSfVsP3vW+e/6qXBJnid09kJCgFTKuWX0dzKeMzVMmI4Y283yOIa1o8y4gfFWGvpIqa/xWSllE1HYaaO1xyNPqyPjBM0mPF0zpTnrsnNHzMpLvLe5mMfTWCB1wDXjLXVOe7pWnz75zXj/ALpyycT3PJc97nvceJznHLnHqSepQAkJU1j8BOCRRw7ZOA5SlC6JoGrZLbJYMjvY5C4t64IGD+a1BXHaG6TWiYVUDuF8YJI6OHUFdQsF9p9R26OrpzgHZ8ZO7HdQVi1UJa4vGxXsHDN1jqacUjtHsHxHePLr8VOqaeOqgfDK0Pje0tcD4LkF7tslluk1K/cNOWO+808j/rquxu5rPaz0+LzbTJE3NXAC5mBu4dW/y80lLL2T8HYqzxFa/wCIU3aRj+YzUeI6j7j+64XG3v8AU9wl5hjWMHyyra4TFsIAPtbBVNpdxzV05/tah2D5NOB+SkVs4GOJ2GMBc4nouiK8SCoah/pWpXkbx0kIbjwc45z/AIRhPl3E8lQbK50tPNVOyHVUrpd+YbnDR8gPmpjXYBcfenJm+qqdSVBZTuA5gbY8en4laqw0fo9fR04A4aKl3/jccE/8LvmslIw193t0R3D5w9w/dblxH4LcWH15a2oP25i1p/daOH88px6BI3clO3SX0i+22n5tia+pcPMDhb/zO+Snl/EQqajf6VfLnUc2x8FM0/wgud+Lh8lZd4kKUJ2qqDT0k0jRl7WnhHi7oPnhLpIhSU0MDTkMaG58cDmoNS4zS00HRz+8d/C3f/m4VMLslIlCmxnJV7pq0Ou9cGkH0ePDpHD8B8VQUwL3AAEk7ABdXsFpbZ7eyLnK71pD+94e4KjVzdkzTcrq+HrZ/EarLx6jNT49w9/0yrFoDQAAABsAFV6i1BDYKPjfh87v6uLO58z5JWor9TaatE9wqslkY2Y3m93RoXFqfUNVqmsrLnWEcUj+FjG+zGxuwaPjn4k+KyqWn7Y8ztl6Ff7022R9jCf5rtvAd/6Kwr6+e6Vj6ioeZJXnc9B5DyUaP1nTnpxcI+AH65RtxhzjsG801E/u7cJHbFzS4+87roQMDAXiz3ukcXvOSdyp/ZhGJ9S6suzh6tHRx0jXebyXH8WD5r1ppqj9AsFBARhzIW8Q/eIyfxJXmfshtRf2e09SRl+oNQ8LT1dC08P4FjvmvVLAAwNHQYSSb4SN9keKdjbkpx0Ae3BGUUXQqS1nEoSlyqC40WWnZZWupzG8nC6HVU4c07LK3mi4S44SBTNdnRc1t0X7K1HXWn2ae4B1fR+AfkCeP/EWyDqS9/Rqnj8Qi1daqmsoGzUHCLrQytqqJzzhplaCOFx6Ne0uY79156pFPcqe80dLc6PPo1ZGJmNcMOYTs5jh0c1wLSOhBCz61mQHhei8J1WHvpXddR7t/wB+CcHJcL1FB+z9TXSmLeANnc9rfAO9YfgQu6cj71x7tVp/QtWRVDc4qIGuPvBLfyAUdA7EhHeFo8XwdpQtlH5XfI6fXCz7pOB7HeBwiuLMPY8dRhNyEGLIPgQpE319C1w3IGV0K8dSaZ3FGB4Inn6wpqkduQnZB64S9E1VN4jdJAxzGl8kcjXta0ZJ3wQPgSu8aM0rDpe1sZwg1koDqiTmS7Hsg+A6fPqsJ2b2D9p3s1krc09GQ8Z5F59n5Yz8B4rraw6+bJ7Ie9eq8I20NjNfINTo3y6n37e496iXepipLVWTT47lkTi4E8xjl8eS8+U1QJOF42zs5vgV0Htg1MIoobNC71n4lqMfdHst+J3+AXMmP7s94PZOzx4eDlat8ZZGXnqsHi6tbUVjYGf+2NT4nce7T35V9C/B8ipXA2Vj4pGh0bwWuaeoKraaTLQCd1PhfyBWsuHCgPYZYpKGd3FLEBwvPNzfsu9/Q+YVUOJrnNcMPacO/mr2707nwsqYv62HJOPtNPtD9fgqmoxO0TMHrAYcB1CFGQnpHekQiYf1jcNePyKYxkEHkUVNUCJ+T6zCOFw8QU7JH3bi3ORzBHUdChRlTqGrMzCx5+sb1+8OhUouVG1z4pGvZ7beXn5K2hmE8bZGnZw+I8k9RnROpxj8D3K9s+hrjdYmzu4KWJwy0y5y4dCB4JN60ZX2WF054J6duMvjzke8Kt6RDz8nMMrXNnuAg9JMJ5N846d+N8eOMKmDwU6x26iNdunWPwraxVNY7KeByobHZT7HZCEJ1KY7hKRkIA7oQrIu7yHPUKFMOEhyeppduFFOzLXD5J6E20pbXYKZY7YFKa5CFNZJkc0+1+VAY/BUhr9k4KMhSA5KDk2HI0qiynOJOMfwkHKY4kYKEqu3ls9KHDcqqqvUaHDoVMt03G10ZPPkmauLIc33pRqmYSYZNgfFSGvVbRycUeDzBwVMY/CcChPhysaKbAGVVh6k0smPmkTmnBVnc96aCUfYeAfcVV1YzxFWz/6RbalvMtbxD4bqqkdxsB8QnMKWTvUBrsPT0cn1nNRZfUf8UUcnrlV6k+qFboP8Q+Sug/LQU1W7mOQe4pNPJxNwlyevC5vULP3C2laW6bjY05VvC/YeSzdql5j4q+gdkKIp6tIn8lOp5CCFUxPU+nfuFE5PCvZZjLI55+1ui4lHY/LQlh26r4Uq1FiqDcbZUUDjmWIGaHzx7TUmmq+NvCTuFS2q4Otdyp6pvOJ4cQOo6j4jKsr7CLXe544z9S4iSIjkWOGRj4FMxqlzorB7mVETo5Gh7HDBaeqXR3R8E7KOtkL2uOIKh32v3HfveB6+/nXRVPEM5Sp2x1kLopBljufQ+8eBRhLle0g9GH+BUfjwjEipKZSWvKUHqKH5SxIkylwpQkR8QPVRhIlB6cCm4UjO+EaZD0oOwnZTU63mjzsmw7CVxZCdlC8m/S+1E6u1pa7Q0v7qhpO9cCfV45HHp/C1u/n5b8DXcvpc2t9L2h0Fbw4iq7ewB3DjLmPcCM9Tgt+Y8lw1cNXEmpfnvX1rwo2Ntkpuz25fnk5+eUEEEFRXVq00xqGr0nqG33ihdw1VHM2Vng7HNp8iMg+RK9p9lvb9p7tJDKVzxaLzhoNFVSNAlcf907Pr+7APl1XhhLilfBKySN7o5GEOa9hwWkciD0Kv0tZJSn1dQdwuSv8Aw1SX9gMvqyNGA4dPAjqP2Cvpmi6rxjoz6VGq9MUkdJcGQ3+njbwtfVucJ+ed5Mni2ONwTsPPPRrZ9MuzygftHTldSnO/os7JsD+8GLp47nTPGrsHxXhNZwPe6ZxDIhI3vaR9CQfkvRK4V9KztCn0xpWlsVBN3VVd+NtQ4cxTAYc3y4i4DPgHDqri2/Sn0BXNaZ62stxIyW1NI8keR7vi/wBFeX+2rW41/wBot0uUU5qKCN3o1G7GB3LNgQDvgnidv947DkK9fWx9gRE7JOmi1eE+GKs3Vr6+BzWR+t6wOCegB2ODr7lhkEEFyK+jkEEEEIXQOxnslre1rU3okb3U1rpeF9dVtAJjYc4a0H7TuEgeGCd8YXvPTem7bpGyUtptNKyjoaZvDHGz8STzJJ3JO5K592C6APZxoGjp54+C6Vn9LrQR6zXuAww/wtw3HLPEeq6jHIJGghdvb6RtPEHEesd/0XyxxfxBJeK10Ubv5MZw0dCRoXeOencPflaCCC01wKCCCCEILxR9LTRLdNdosd2p4hHSXqLvzwjA79mGyD8WOJ8Xle11wn6YWn23Ls1pbm0DvbbWscXH/dyAscP8XB8lmXGISU7u8a/v3Lu+Cq91Deohn1ZPUPv2/wCrC8XoIILiF9VIIIIIQut/RYqvR+2i0x8XD38NRHjGeL6pzsf8OfgvdC8BfR4mdT9s+mHNDyTO9nqc8GJ4Pw338sr3vUVEdJBJNNI2GGNpe+R7gGtaBkkk7ABdhZzmAjx+wXzh+I7OW7Ru74x/3OR1FRHSwvlle2ONg4nPccABV0VPJdZ46iqY6OljcHQUzti5wORJIPEc2t6e0fWwGIo45bxKyrqo5IqZh4qankaWud4SSA8j1aw7t5u9bZlyt1eUrK60cysqLLa3DImrGVk3C7Do4qZwmEg8u+bAwjwlWK1JfjcKyV4ceHOw8B0VnqG9iZtXcw/LaoClosbjuGkl0g/7wknIOHMER5hYKpqids7n8ll1Mn5Qtamj0yVBv94bR0k9S/dsY2HiegU+xxxaI0XW3a4f1wY6qqSTgukPJg+Ja0LPtpzf9U0VCN6elPpM3gSPZHzx81lu3fXQrq+l0bbzxBkjBVvb1lfhrWD+EOJPMZI5FpVSMcxV+XRob3rI366yNrnSTP4p20clTK4bZlkdxO/EfiueUZ76tia72eLJ+G60Wta8Oud7kafanFM3yDAAf+U/NZu0Diq859lpVxgw1VnO1yFdXnStxs1uoblPTPbbq/j9GqObXFriHNz0Ixy8N1TL0XqK3UlVdeyrS1ZE2SioLHPe7hTybhwewNaT5h5f815jrLuYZJHNiaWFx4WgnYZ5fJc5NQOLz2Wy9ws3HNO6BrLllrxpzAZBx1ONQfcR10VinqKndXXCko4y0T1MrYYwTzcT/o+4LJVWrpWNeIoGNcNsuJP4bK/7LX1RuF11VU5lNspTFSA7B1VNlkbWjyHGT8EsVtk9qbQfNXrjxzRRxllvzI87Egho884J8se9dg7ONJw3LUtXJSgvhfN+z6aQ8+4hJD3+XE/vH/ALU9tesIrfL6LTuDRSs7iJoPJ2PWPw2CutI0EHZjoE3Gq/6xBStjY08+M8/iXY/FebNX6gnvlzkdJIXOcSTvy8VosGdtl4zNI+aUvecnOp7yd1VyTmtqXPcfVG+SotTW+mUtCW7QshxGPNxL3n4ucR7mhN1jXNoXQRHhmqXNgjI6Fx4c/DJPwRV5jZOY4xwwxARsHg1owPyU6jUKpkbG1z3H1WjJWVnmdV1JcfaeVaXmr4x3bT6o5+araJmZC89FIAona6KdDUOo5Y5Ijh0W4W8oqtlfSxTx+y9uceHkueVBIjOOZ2Vtoq8j9rVdrLiQ2NsjPI/a/Nqzq6Hnj7Qbj6L0Pgu6mkrfQnn1Jfk4DT47fBbNBBBc4vekaCJGUIRIIIIQgljko1ZXU1up3VFXURUsDfalmeGNHvJ2WMunbJYaaXuLfI66z757n1Y279XkfkCpY4nynDBlZlbcaO3t5qqUN8zr7hufcFuxzJUCpvVDS1LaeSpj9IdyhDsv5Z5dNvFcni7QLxqfVMFMyb0Khja+WSGA4y0cuJ3M7nyHkqkXd4ludc0+u8GGE+btvwAWmy3kayH4Lzq4cdMaC2gjz/ALztvcN/iR5LR3rtUrrhNJDbmto6cPcxsuznvAOM77DPz81n5aqWpk7yeV80hG75HFxPxKpqRoa5rRyGysO8wtaKJkWjBheW1tzrLk7nqpC7w6DyGwQfJmTHgl97wsz1KiceSTlJqJuBqnWYnYJeOrJ8An5psAqvt7+IyO88JdRKlwhGx/FJ7t1DuE2XFo8MJ6OTDSfFQ6f+lXGIHdpeCfcN0oSEqddXcV3pKccqSka0+881C7zvJnY5A7JT6jva26VROwdwtPu2/QKLSnI80qCtBSOw0J8vUOmd6ickk4W5QlUj0jFM4Z+0qKum9c7+altn4oHebiqetl3ccroIP8Nq46q/x3+apbXF6frChj5j0gPPub6x/wCVdMuNRw228OzvhkQ/vHh/Vc/0HCKjVU1Q4ZbBE52fAuIaPw4lsLnNmyTEneadn4EH9FYd7QCqxnQlNWx2IPirKOTGyqqJ3DEPepjZE0oBVh3uwUO4TkQSYO5aQPedgh3myh10mWsaPtPaPkc/ogJSVK73gaA04cfVb71I75rGBvRoVY2biqPJg/E/5fmrKyWwagvNLQSymGllLn1U+cdzTtaXTPz0Ia0gfvFo6oI70oKu7rObRou20AcRU3iQXapxsRC0OZSsyOYLTLLg/wC+aqCJ+Ai1Ffn6kv1bcnRiBs78xwjAEUbQGsYMbYa1rW7eCjwyZCaE0nVWIfsltflRBInWu4glQjuM3d0T/F2AnNNapm0rUQTsb3kUpDJYs+03+YVbepsRMZnnlygzu/pEDM7MaXH5YH6oc0OHKdlPBNJTyNliOHDYr0ZRV0NypIaqnf3kMreJrvEJ9ci0Jqt1imZTzuzQzHLs/wBmfvD9V1xjg8BzSHAjII5ELn54TC7HRe6Wi6x3Sn5xo4e0O4/oei5J2h6VbY7h6XSx8NHVPLi1o2ZIdyPjuR8fBcx1RVubROhjOJap4gafDi2J+WV6fvVphvdsqKKbIZK3HEObT0I9xXlu+0M9JrOooKlpabYCHAjm93IjyLdx5Fa9HN2jeU7heZ8TWv0Kft4h6j/keo9+49/cnWMEMTImDDWtDWjwAGAk1cndwvxzxwj4pUe5JUWtflzG+Li4+4LRXFFFaMNutTVOGWUlKcfxOJ/Rp+a11uHoNsiEhwWM4nu88ZJ/NZmyRGSjb96sqeIn/s2cv+X/AIlc36U/s4wNJD6lzYG46cRwT8slL1SjTVOWBpFsZM4evUOdO7+8eIfgQPgrEHJTTQ2NjWNADGgNAHQBG12CkTdkVO7vK+Zx5RtbGPefWd/4fkp2VXWw5pu8POVzpM+RO34YVnRU8ldVxU8LeKSVwY0eZSE41KexpcQ1oyStp2f2c1FS6ulaRFFtHn7TvH4D81vZpWU8T5ZHBkbGlznHkAOZTFst8VqoYaaEANjaATjBcepPmVjNf6iLn/suncQAczuB5/u/zXOnmrJtNvsvbY+y4ateX6u+rj0930CwHalquS914hY9zaRm8cZ8PE+ZUTT8XcWeEkYLgXn4nKzt3mNddJsbgv4G+7OFq2tENNFE0dA0BdCxojaGNXjNRUSVczppjlx1KVUu4La48nSENH944/VRtU1Yt1nl3DS2Mn3YGym1LBJW0VNzaCZHDyaP81T3WhdqzU1qsMeT+0a+ChJbza1zwHH4DiKc0ZKgJwMr0NojTjbQ3susIaGSUNlfdaqPwfIA3fz43u5+C7LGMHzWF04W3ftV1rcGDNNbxT2alcOTeBhkmaP78g+S3kIyQo3alP8AAdFKhbsFLjbsmYW7hSmBRpUh7OIKnulFxsOyv+DZR6mHjadk1IDgrm1yoywkgLnzGOsGop6LB/Z9ze+rpz0iqMAzR+XGOGQDxEx6hdlutBxA4buuf6lswnZw8P1kbxLE4kjD24xuOnQ+LXOHIlRyM7Rhatm21fodXHP0B18uvyUILm3bVS5orVV5wGSvhO3PiAI+XAfmukLK9qVAa/RNdwt4nw8M48sEcR/wkrFp3ckrSvYr1D6TbZmDuz8NfsuOQSccJZ1A2U+3PD4XsO+PyVNRSksa7qNirGgl7upAzhrtv5LqQV8/kImtMUxaehwpWDLwBoLnZwANySkVjO7mDuhWn7PrJ+1Lv30jeKCmw8gjILug5YTZHiNheeit0dK+tqGU8e7jj9T7guiaUszbFY6enAxK4d5KcYJeefy2HwStUagh01Zp62UguaC2Jh+3Jg8Lfw+WVaF4YwucQ1oGSScABcB7Q9Uy6h1DTyse8W5vFBDE7bBIB4iPE8OPcQuep4jUyku23K9lu9wjsVC2OH2scrR5dfd8yqGur5rpW1FXO7jnmeZHnzJ6eSKCbu3+tu07OHkmf6t/l1R44XELpwMDAXhjnF5LnHJKtKZxgk7onLcZY7xHh8FZwvzhUtK7v4+6LsSN9ZjirGkm7xm44XDYjwTgUgVxE8Pbg81n6unNtq3NAPdO9YD93w+B292Faxy8GD4JVxpfTqTLMGVnrM8/EfHklSkZCz8zBE8EbsduMdFIiPfQFnN7N2+bfBMNLeEBxPdP5H7pRRvdBK0/aad/NKFCdk4RlX2h7WbpqSmpy3jpiTJK3wDd/wATgH3qmmYAWvbuxwyPLyXQ+yChzLcaw42DYm7b75J/Jqr1UnZQucFsWSkFbcYYXDIzk+Q1+eMLpCTJG2WNzHtDmOBaWnkQllQb3c22e1VNW4AmNuWtPV3ID54XGtaXOAbuvomWRkUbpJPZAJPkN1x66U7aO51kEfsRTPjbnwDiE0x6ZfK6aR0jjl7iST5o2ld00EAAr5Zkc1z3OaMAk4ClsO6fY/5KJG9PtcpFGpAcj4k0HYSuJCE/E/DgtPpuyC5v9InafR2HYffPh7lUabsj71WgFpFMw5kf+g810uGFkETY42hjGjAaOQWRX1nZDso/aPyXonC/D/prxW1I/ltOgP5j+g+Z071BrrFR1tI6DuI4xj1CxoaWnoRhc1ljdTzSRPGHscWuHgQcLrS5dfHh95rS05HfO5e9QWqR7i5hOm61ON6SCNkM7GgOyRp1GPt91GDsJ+J+VEztlOMfgrogvJFPDsJQcmGPS+ScmEJ8ORpkOSw5Cj2UmnmMUrXDoVYVQDsOHskZVQDkqzgf39GRzcxCCqth7qslZ0d6wUsPyodw+qqaeXoTwH48k7xYQkUprsKTA7DseKgMk5KTE7DgUJwWgtjg6V0Z5PaWn5KniJEQaebThT7dIG1UB/eA+ahVLe6rqqL7sjvzz+qc06pTq1QKxu5PxUKOT65w81PrBloKp+PhqT71BVeyFcoP8Q+SuqebhcFNL9z5qoifsPJT2S8TAs4FbRUihfwVGPFaCmdssxE7hmBWhpX5ATSnBWkTlNgduFWxO2CmwOwoSnq6iflqdBUOF+QpDXKEhOToOFf3x5rNN2a4c3Rh9FIfDgOWf8LvwWdDsrQ2r/pDRl/pCMupXQ10Q+JY8/JwTUKvoqni2yrBkqzVJUFrgrqGbICUhOBXtku80XEm+NAFZhVoJzi8UfGfFM5yUM7c0JykCQ4ShIfFRg7bmjD0JiltlTgkUIPShIjKFOa/zSw7Kgtl8062ZOBTFzX6RPZvP2haOZNb4jNd7W508EbecrCB3jAPE8LSPEtA6rxSvpK2ULzT28/R+ram6VepdMUzaiKb6yqtsDSZe8J9Z8bQPWB5kDfOcZzthXGkMn86Ma9f1XsvA3EsdKP4XWO5Wk5YTsCd2nzOo8c94XnBBLlifBK+ORjo5GEtcxwwWkcwQkLml73ugggghCCCCCEIIIIIQgggghCC2fY+/T8HaHaKjU1W2ktVNJ3xL2Oc18jd42uwDhvFgkkYwCDzysYgnsdyODsZwq1VB6TA+DmLeYEZG4yMab6r6awvZPEySN7ZI3gOa9hyHA8iD1CfjPA7ZeJ/o7dskugNQMtNzqJX6ernBhacuFNKTtI0dAc+tj374Xtgciu6pKptUzmGh6hfJvEFhnsFV2Eh5mnVrsYyPsR1H6qQHI8hNMPRLWguVSshGkg4Rg5TcIRrG9sdgdqbsu1Nb2QmeV9E+SKJvN0jPXYB58TRhbEHKB5KN7Q9paeqs007qWdk7N2EEeYOV8ukFv8Atw7PHdm3aFX26Jhbbpz6VRHp3TicN/unLfhnqsAvO5GOjeWO3C+0aSqiradlTCcteAR70EEEExW10z6NtM+q7atNhgzwPmkcegAhkP8Al8QvbFP/APOaojqSc2mFwfA3pVPB2l82AjLejj6wyAxx8t/RQ7Oaq+3qu1BUAMs0MbqNwIPFM93CXMHTHDs7Och2Mb5HsIAAAAYC7S0xllPk9TlfMv4gVcdVeOSM57NoafPJJ+qNZrVFd6Q8WaJ/DJPGZKp4JHdU+cHcci8gtG4OONwOWYVne7vFZKF9TIHSnIZHCz25Xn2WN8z8gMk4AJXNdTXOW02SXv5RJdLlIX1D2eyNgOBngxoAaPHGTuXFakj+QZXnUUZeRhZ7V+o46qslm9ilhHBG1o+yOQA8/DzWZlrDTU8s82O9O5aDkA9Gj3KDUVjau4yBxzTUA7yTwdKRlo/utPF73MPRMwwzXirpKQZzM7id+p+AysKR2TldHFHyjCmR3tmgND3PU1Q1slbUHhp43/2khyGD3Zy4/utJXnrSVTJdNZx1NVI6d7Xy1dRM85c4hrnFxPiXb5W77f8AVLKy8xWKldihszBGQ07OqHAZ9/A3DfIl4XPdNYoLPfbiTgtpxSs98hwfwBVyFnLH5qtI7nflVd3uLqoguPrSPdK73k/+al6XgdX3SnpmjLqiVkLR5udj9VnZpuKQddl0DsUof2n2jachIyPT4pCPJh4z+DSrBGmFXzjVdd1xc2v7YO06safU09pWK0QuHId40ygf4iR8F5fr9osnpuu7Xyt72h7ZbjxcTrhqH0Frv3YpCQP8Oy5rLoGrrdD3jUUj201uojHE0v8AaqJXuADGeYB4j4D3qsz2iVMPVYAVzAQvqJGsa0uc45wOZ8l6S7LNAh13tlkfGPQ7Hi4XNwOWzV0g9RngRGzG48lyrs5szIK+ovtVCZqO0ME3BjPe1B2hiHiS7fbw816KfKexzszjFQ9suqLm508rjgk1D93vPkzIA9wUdQ/JEYV2nbytMnU6D7rI9uuu/Tq8Wimf/RaEkylp2dJ/ly95K4uMlznu9txyfJS7hVGrncS4vAcS5xOeJ3iq6ecMOBz6qNowMKbZKjkBuIkO7KOF0o/7x2WM/Av+Sqquow045qaZO5tXEdn1cpk/uN9VvwOC74qmqX5yngao6KrqjxuJS6dvC0N+JSZcEgJ2AZyVIoeqaqpWxEOd7EbS8/osrb726036luDi4Ym4pA3mWnZw+WVb6hq+FvctO7yM+4f5rK1gy8DwUoYHNLT1UYnfBM2WM4c0gjzGoXokEOAIOQeRCNZXs3vDrtpqJsji6WmcYCT1AALfwIHwWqK4mWMxPLD0X1lQVbK+ljqo9ngHy8PdsgEEAgVGr6q9TPnisFfJTSuhmjiMjXt5jh3P4BcaqNZ3iR5H7UqQOvDIR+S7nV07aulmgcSGyscwkeBGF5vpKZ77qKeUFpjeRJxDAaGn1vwC3baGua4OGy8e47fUU80EsT3Na4EaEgZB8PNVPaDdZ6l9FSTTSTSNb30hkcXHJ5Dfw3+ag6cj7qCSXG7jgKsu9cbtdqmq5iR/q5+6Nh+ACvaFopaJhdsGt4j+a3SMN0Xj5cXO5nHJWl0u30e26gungGUMTvM7u/MKK1xEQZn1W5d7yVLDDbtB6fpnbTV7pblK3yc7DPw/JVznYjPiVA7dSE4ACk0Zyc+akSSYafkodK7hTs0g4QEBJlG126i1svrYTrHbquqpsl5TglVjb/VpWu6uyUmd+SUqL6qmjb4NCjvflPQjkk4YT7ki1nu5ZZj/AGcZd8UxUSZaB4pURLLfMR9twaPzQE0pt/1Vrib9qaQvPuGyOk6pNxOKiOIcoWNZ8eqVTHGEJFc05w1N1k3CwjKKOThYoFbPxZSFCcglzTk55uKqq6XDXlTKeT+hk+ZVRdJg2F7jya0n8F0VP/ht8lx1V/iv81YdnTC2ju9UftyNhaf4Qc/8wV5dpMUFLF96Ti/D/NVuj4jTaRo8jD5nvld55cQD8g1Trw7iqKZg+y0n5kD9FY3JVdujAn4PVjanmu3TTPVYEsHZNylTnGVEqHcVTTtzy4nn4DH/AIk8dkw0B9U93RoDPj7R/NqAhOtbwjfmTkq4gm/Y+lJJscNbfD3cZB9ZlFG71j4jvZG8jsWxDxVbQWw3y5U9tEvcMm4nTz/7mBrS6WTw2aCBnm4tHVOXy7NvNzlqYohT0oDYaWnHswwtAbGweGGgfHKR/clbtlQC7hHRPxP2UOSTLmt8N07G8nAHNxwmhIp8b+JSYiocaksdhOCFWXeXvasM6NAamOPjmmf0OGt9yj1U/HUyP5+sSP0T8bOGeOPqAM/mlQraI4aB4BbjQet46Kogs9dIQ2YltNIeTT90+R6fJYaN2xVRc5eO4taDtHEfm4//AKKjfG2Vpa5aFBXy26ds8XvHeO4r06ubdsGjW3C3uvVJF/S6duJwxu8kfif4fyz4Jzs37Roro2ns1xmDLiGkQSPd/XhvT+ID5gZ8V0QgOBBAIOxBWEOemk8l7OfRr/QENOjvi0/qPn5FeUh6gACrK+RxkcG+1gRt/iP/AJre9o+kjpW9vMLHC3T5kgPMN8WZ8vywsHRgT3GNzvZZxTOP5LpY3iRoc3YrwqqppKSZ1PKMOacfvzWis8LRVljd46WJkLf4ju78A35pyoIqr7TxYyyljdM7w4neq38OIotMjitpqHbGeR0pz4ZwPwARWlxn9JrDzqJSWn9xvqt/In4p4UB2Cs3PUermLKaUtPrFvC33nYfilOd6pKjPcZpoI+YL+I+4b/nhImK0hYIoo2N5NAA+AXQ+zWw+q66zNGSSyAEbjoXD8R81jtP2aW/XSKkiBwTxSOH2GZGT+K7RimtVHgcFPTQt9zWgLMrZuVvZt3K9B4VtomlNdMPUZtnv7/d9cdyrNUX4WWhwwg1MvqsbncfvfBciuNb3UVTUuJJa0nJ645K5v96fd62Wpflod6sbT9lvQf68Vi9V1fdULIGn1pXb/wAI3/PCsU0HYswdzusa+3Q3OpLmn1G6N/X3qrsUBqa9rnbhuXOPmtVA/vq1o+zGM/H/AFj5qmskIo6B0zhhzhn4Kwt0op6Sapfk+o55HXHPHyVsrmRopcEoFVX1jt2wt7phPlufxOPgrf6O1sivnbHT3KqdihsVFU3KaQ7hp4e7bn/G5391Zm9Sm16YYx5+vl9Z+Oricu/EhdF7D7DJR9j+prk0OjrtU10VkpXAZJh4u6c4e4vqCf4AlHsk+5OOrgO7Vdr7JqOWPRdPcKlpbXXiaW61GR7Tpnue35NLR8Fu6dnJQ4II6aKOCFgjijaGMYOTWgYAHuCsaYKIpwUqFmyksam4m5KkAKNIgBlE9uQltCMtyEiFUVlMHA7LHX237OOPcugTx8Q5KgvFJ3kLjjcJAngrllXCYZiCMKBcqRtwt1VSuGWzROjx7xhaO+0vA0PA3ad/iqXkVhTt7OU4817nZKkV9tZz6kDlPu0+YwV5ip4nUtXLA4EeAP4fgpbDwuG/JStY05otR1pAwY6p8ZBxsM5bnHi05+KjOGW8Q966Rh5mgrw2ZhhkdG7dpI+CtpGmrgjc0Fzztgbkldf0dYf2BZY4ngekSfWSkDqeQ38BgfNY/sx02+paLnUsHozTmAH7Tgfa9wI+fuW61Be4rDbJauUjiHqxtP2342H4LJrJjK4QsXpnDFvbRwuudVpppnoOp9/Tw81ke1DUpp6cWiA+tKM1B6huxAHv6+XvXJLnC6eilawZlbh7P4mniH4hXtyqpbnJPUTO4pnvMhPmVXY9bK1IIhCwNC4G7XB9zqnTu22A7h0/U+Kq3PbMxkrd2yNDm+4hG/2Wu8RgooGd0Z6YjeF/E3+F24+W4/upQbmNzeo3CtLFRxvc1zXt9pu4Vsx4dwzM9l3tDzVLE/DsFWNDKI39272H7e4pwQreNwOCOSkQTd28McfVPI+CgxOMbiwnkpIw9uE4aJ6hXalFLVcXCO4nJyOjXdR8efvyoDmni7snLseq4/aHgfMLQ8DbhSyUsuziPVPXbkfeFnyx7g6GT1Zozj3Edf8AXRIe9NKdo5RI10Dts7tPgV2ns2oHUOlYONoa+Z7pSB78D8AFw48TwyVjSHE8LmjmHBej7ZS+g26lpyMd1E1nxAAWRc34ja3vP0XoHBlMH1ctR/S3HxP9ipS592nXqMOp7XHJmT+vlaPDcNB/E49y6A97Y2lziGtAySTgALgGp7y69agqq5jncDn4i4ujBsPdsqVvi55ec7BdLxhXejUHYNPrSHHuGp+w96Wgm4ZWzRhzdvEeBSnLp14YnmvUiN+VCa4p5j8JcoUtrlPtFpnvNW2CAebnnk0eJUGhp5a6qip4W8Usjg1oXVrBY47FRd008crjxSP8T/JUKyqFOzT2jsus4fsbrvPl+kTfaP2Hn8h7lKoKGG00TIIgGxxjdx6+JKgWy/tu12mhp96aKMnjx7bsjceXNZrWGqPS5XUNI/8Ao7dpJGn2z4DyH4p7s6bxTVr+jWsHzJ/ksf0UtgdPLufuvQxfGTXSG10GkbTgkdeUHQeAxv18t9pPKIIZJDuGNLj8AuQunMzzKebySV03U9T6NY6p2cFzeAeeTj8srlYHA9zPA5HuKvWlmGOf3n9/Vc9xzUc1RDTj8oJ+Jx9lIByEY2KaY9OLdXl+VIifthSGu2VfG/BUuN+yekKkA5Rh2AmwcpYOUmyalhynW2XExaeTxhVwO6ep5e7la4cwUqjTl2gL6SZrRlzRxN943H5JmGYTQxyA7OaD+Cs6kAvz0cFR0I7ps0B5wyOaP4Tu38ChNUwO3UqJ2cKCXYKkU70IVvBIWlpHMHKdvQ4LzUHkHBr/AJgKJA71VLvpxW0cn+9pWn3kEj9EBPPsquqW5a4fFZ+Z3DUu96v5nfks5WOxUO96r1Z9UK5Qe2fJWcD8tCmQybYVTSS5aFOjfhZwK2yp4d6wKvLfJxRtWdY/ICurY/YhBShXkTtlMgcq+J2VLhcoinq3p37BSWuyq6B+FMDlGU4J7i357rUdnbvSL9U244/6Toaij38TGXD8WBZMO8Vc6Mq/RNX2WXPD/S42E+AceE/gSmkaIWfglwVb0s+WjdV98g/Z9/udLy9HqpYf8LyP0R0k+2Mpx1CAvdrZAeqMFRI5chOtf4FZJVwJ7i3QyU2H52R8XRCclo842SOJDiQmJfEhxFNoF2EITokS2yqKX4RcaEKe2ZOtn81WiXCcbMgFMWH7Tuw6w9osUlVHG213oBxbV07GtErjy74Y9YefPz6Lyhrns5vvZ5cXUt3pHNjziOsiDnQTbZ9R5Az7jgjwXuts3mkVtFR3amdT11JBW07ucVRGJGHYjkRjkSPis6poY6j1m6OXoNh4yrbOBDL/ADIu4nUeR+x08l88EF601V9FrTN8nkqLVVVNilfv3TAJoAfENcQ4e7ix4ALmF4+irrChlIoZKC6RYBDo5u7d5gh4A/E/osGS31Ef5c+S9ooeM7LWgfzuQ9z9Pn7PzXGkF0qf6OfaHAHn/Z4va04yyrgdn3Djz+Cy+oezvU2lAXXax1tHGBnvnREx/wCMZb+KqOglYMuYR7iujgutvqXBkFQxx7g5pPyKzqCCChWogggghCCCCCEIL6KdmF9l1L2eaduU4+vqKKIynAGXhuHHA5AkE/FfO6KJ88rI42OkkeQ1rGDJcTyAHUr6M9n9km01oewWqpwKmjoYYZg13EA8MAcAeozldDZ887z0wvGvxKMfotMD7fMceWNfnhaIHBSwcJppSwdl1i+f04gDhJBwjByhCVxIkEEIWV7Ruzez9ptgktl2hHEATT1TAO9p3n7TT8BkcjjdeO9bfRq1vo1ss7KAXqiY7AntmZXY6Ex44x54BAwd8YJ93ILOqqGKq9Z2h7wuysfFVfYgY4SHRk55Xbe7u+ngvm9T9nGrKqZkUWmbw+R5wGihl/8AtV0zR/0W9R1tZRu1A2K1RTSFraQv7yd4BHE5wbs1gGckuBJ4WjBeCvaj3BjS5xDQNyScAKosrDWSSXSQEPqQBA132IB7O3Qu9o7A7hpzwBU4rRCx2XkldJXfiJcamIx08bY89dSfdnQfAp3T1gotLWSjtNtgbT0VJGI4o2jG3UnxJ3JPUklWL3iNpc4hoG5JOAEpZHWF1jeX28yBtJHH31dIfZEfSM/xYJPP1QQR64K29GjAXluXSvJcckqmu94kvNfBMwlolLmUTD9iPHrzkeJHLPIFo2LnLluvtTRmpqqluZKalZ3cLGnd+NgB5uJ294WmuV7fT2uoukmWVdxHd07He1FAM8PuJyXHzcB0XL5SLpe4IXOApqQemTuJwNsiMH+8C73xrKnfzHC2qeMN9yTHTvp4KK1vcH1U+amre3kd8u+BeQB5DyWmbWR6Q05dtSzxiR8EXBTRu/tJDhrW+4vIHuyqXSFNJe5ZLkWnjuDwYGkbsgH9X8xl5/i8lU9uuo4qSGktEJ/otvPePHSSfGGj+7xH4uPgqYHO8BX5DytwuFXyolmrHtmlM87nGSeV3OSVxLnOPvJPzUm9H9l6Et8HJ9fUvqD/AAsHCPxKqfWnny71nvdk+ZVj2nS9xdqO2gjht9JHCQPvEcRP4hafUBZ/QlZTjyQV136NvB/6U7GXkBre/fv5QvXH+H6uMhw3zkeC3/Y3Uug1tRSMkdH3Uc0jnNOCAInZTnKLGQQrm21k1+0nDQwZlqL5qGas4c+0TxM/PCv+2eSepn0z2aWCMTyUwEj2A4Ek5b/WP8A1pe4n98joo3YjFTUccN9uH1ds09QzVcj3f7yRzuEDPXAfjzwrDQOnbzqW6Xev739n6huoNRd7u/HBZaR2XCNpP9oQCQ3b1suds3KgDuRuTuVPy87sdArTs60hb2XTvHSZ0lpCR0k1W4YFxueMOfjqI+Q8y0AuC572ma4qNYajqKtx4Qfq4YwciKMHYe/9Vue0rVlBZ9HW2xafg9BsrW8FBTjIc6IE5mfnf1jkjO5yXHcri/8AVtc958yVUAyeYrTAwFFqXtgjwPgFUzPe5pDN5XnhZ/ETgfiQn6ucyvLj8AkUBaa9j3ezTMdUkfwjDf8Ajc35J4SFFeJGMqe4iP1NOwQM9zRhU87sglPSzcZJJyTuolU7gjTwlOgURzuJ5TweIYi5xwAMkqG52FDuFUW0/dg7uO/uUoCrE41VVVzuqqp8h67+5Vs+5cVNftGT4qHIMnCnCqHVbfsirRBX1lI4475gkaD4t5/834LqC4X2bTGo7SoI2uIipad4dj7T3tzv5hrR/jXdFylyaGz5HUBfRHAs7pbOGu/I5wHlofujCJGiWWvQkY5rz52g0x09dNUTeyZpRBBtj+tAe/Hub+a9CgYXAPpBVJ/2moqUAtYKf0h3g5xPDn4Bg+a1bc7EpHeF5vx1CH21svVrh8wf7LldNFxTNAV3XiSS3vgh3mn4YIx4uceEfmq6jYA5p6k5+S0ukadlbrWwRy7QQVBrZT4NhYZPzAXSkrwRozor/XMkcWpZaGA5p7ZFHQR+6NoBH+LiVA92R8UiWsfX1M1VJ/WTyOlf/E45P5oZ5KHCkJycqTE7G6N8mQmWvw1BzspqRP8AHwxOd4BVch4+Fv3nAfipkz+GncoEJL66nZ04uL5DKlCFczyBowFDe9OVD/WUWSTCanpEr+J58ApdOAYoA72Q4vd7gq/ORnxUyV/d0Z8S0MHx5p6Yor3mWR0h5uJcn4DjCjDYJ6I5whCnPlw3GVX1UmxTz3qDVSeqU0oT0Mn9D+JVFqCbu7dOepbwj47K1hk/ojfefzVNdm+lT0NNzE9SxhHlnddNT/4bfJcXV/4r/MreUVP6JQ0FL1hhY0+ZAGT+Caq3d5cQOfCwfqpZcXzklQh61bM77pAUoUR2wpQPIeCUDhNtOQlg5SJEouwCSQAPFNRPDIS954eLL3E7YHPf3Db4IVBzGG/fOPh1/DKlWq3w3WpldWlzLRQtbNXOH2wc8ELf3nuGP4eLyRoBko1Jx1UxpNm013jhw3C9ta/wdDRNdljf/iO9Y42LWtBVJxYOVIvF0mvNxqK2owJp38Ra32WjGGtHkAAB7lAkfhuPHZQ5zqU842GwS2Oy4nxT9N68pPRox8VE4uEZzsFMoGlsAc7Zztz8U4JFNiS55e5ppH+DTj3ptmyi3ebgpms6ud+AT0KtgHezxt8XZPw3UunPHWzu6NPCFGoBmYvPJjScqTbxmAPPtPcXFAQrNhw3Kzr5u+q6p/Tj4QfcB+uVeSSiKCR52DWlx+CzVI/FG15OC4F5J88n9U4JvVQRVyjVMU0Ejon0DA5kjDhzZHciD7l6T7OddM1lavruGO4wbTMGwcPvtHh4+B+C8w2lzpIairdzqJXObn7oOGj8FrLDc6rTtXT1VHJ3c0RyPBw6g+IKgqIBM3HVb1luz7XPz7sd7Q+48R/ZehtY6Zh1ZYaigk4WSuaTDKR/Vv6H3dD5FeXK+knskd1jqYzFUxOMDmu6Ebfr+C9TaW1LS6ptUdZTnDsYliJ9aN3UH9PJYXtl7Ppb+ylulBFxyxSs9MYDu+Jv2h5j8vcs+kmML+yf+yu44jtrLlTNuFJq4Dp1b+o/Vc1qgbbp2KmYeGZ7G07MfecAM/DcqVE1tNCyJgwxjQ1o8gMBRLpJ6VfIYRuylYZD/E7Zv4cSekdstwbZXkzt9OiOST1feioh3lYXdGM4fief5BMSv4cLc9lmlv2vVGvnYfRIn8YPR7xgtb7up+HiopHiNpc5W6KkkrqhtPENT8vH3Le6C03+w7X38zSKypAc8H7Dd8D8cn/JUuv9RGaf9lU7iGMIM5HJx2Ib8Pz9y1Grb8NP2l8zcGokPBC0/e8fcFx58rsOc48T3nJJ6lZdLGZnmd/7/wDC9Cv9XHbKRlppdNPW8v1cdT4eaEsvHIcH1RsFkbo83O+iJpyxhDB8Oa0VdVCjpJZT9gEjzPRUWm6UufJUv3cdgT1J5rZHevMjrgKyr9oY6ZmxcQ0AeH/llTHRiappqRvsucHvA+63B/F3CPiVCgPpV1zzbED8z/5D5qTSz4FfW8nOd6ND7mncj3uJ/wAKaU4alUevK6Wtq6akpmGaaR4jhjbze4nhaB5lxwF6903pmGwv0VpeEiWGxUL6ydwGA+Yt7ljiPFxkqHe9vkvNXYxpwaz7ZqaSVneUNkb6VKXD1TI3aNueh4jxD/uyvV2jy643XUV3duyapbQQEj+ygBa7/wCzOn/BPxhoCRuuXd+i1DBl2fNWFM3YKHCzJVjTsxhQJQpUTdk81qSxuydaMhMQgAj4UrBQwUxCaexVtZCHBwI2KtiMqLUR8TSlQufXu38bZWY57LDFpaS0jBBxhdau9JxDix71zS+0votykbjAd64x5/55WfWsy0PXpHCFVyySUx2IyPMaH6j4LgHaRROHaBX0eN7lRx1UG3OWMFpA94YPl5qNoDTsmq6xjMYpIiDUP8G+A8zghbbta0pcL2bJcLPH3lzo6kNaw7NLXYJLvIcO/kStpY7HSWCkdBSRNiD3mWTH2nnmUelckDQ32lMeH3VV4lfKP5QPN551x8d/DzU2npoqWnjghYI4o2hrGN5ADkFy3tAvf7WujaWJ2aemGxBBDn53O3wHzW11xqEafskrmO4auYGOHHQ9XfAHPvwuPxO46dp+004PuTqCHJMrvcjiy5CNjbfEd9XeXQff4Jri4X4I2OxUUt4Huaen5KXUM325FRpnAljj/C5ba8tKr69vc1cFQB6rgYpP4SRwn4OP/EUQbh5CmzxxOfB34zTukEcuejHAtcfeA7I8wFEbTTUk01JUjFVSvdDLnq5pxn47H4pQU0hRZW8DiBzB2T8ThJGChVR4w74FMwP4JC08nckqjV5Tzd/CHH227O/mpcbsYKp6ebuJQ4+ydne7xVtG7/JOBypAnzkFr2HDm7gpi9QCVkdwiGM4ZM0dHdD+nyTzTj3J+B7Iy9so4qeUcMrfLx94Tt9EqhaVo/TtUW6HgMkcsre8aM8m+tnbyBXoHmFybs0sz6bV07ZRxeiwucyTGzg4gAj4ErrHJc3cXZlDe4L2Lg6Ds6F0p3c75D++Vnte3Y2nS9W9ri2WUdwwg4OXc/wz/rdcMXRe1S+sddaW2ZBjjj7yTI5Ody39w/H5YGopjC7bdp5Falvi5IQ7qVwfF1X6TciwbRjHv3P6e5JppjC/PNp9ofqrEEEAjcFVeApFLUcHqn2Oh8FpLiVLS2HCQtroDSwrJBcquMOp2/1LHfbcDz9wx8/coJpmwML3LSttvmudQ2mh3O56AdSf34LRaL0ybPS+kVLAKyTkDv3bfD3+Ki611P6M00FJL9c7+uc37I+7nxVpqzUbbBRDu+F1XKcRsJ5D7xHgFyp0rpHuc5xc5xyS45JPisikhdUyekTe799wXo1+uMVlpRaLfoceseoz93de4e7DwO3uW87OY8UlZJ957W/If5rAtcuk6Ai7uwl2/wBZM52/uA/RXbi7FOR3kLnOD4+e6td/SHH5Y+6Rr2oMdvp4Qcd5JxHzAH+YXPqr1XNf09krW6/qQ+5U8IJPdx5IzsCT/kFlZh3kT2eSfQM5Kdvjqq3FM/b3aXXRuB8AM/PKaa7Cd5qJHIS0Hr1UhjtlpArkk4DhSIX8lFzulxu4SpEhVgx2Qlg5UeNyeBQonJwFGDuE2DhKDsdUicrcP72nY7qBhVNQ3uLrxcmzx/8AE0/yP4KfRycUBb1Ch3gcEMM/+5ka4n90+qfzSqNE84wl078HCbk5BCI4chNVrBJsFPvR4qS0S8/q3s+Tv81VQvyPcrKvfxWC3O6snlZn4NKE/oVXTnIWerz9a7ycr+Y+qs9XH62T3qnV+wPNX6H/ABD5JdHL0VhHJnKp6Z+HKxjfus9pWyVZxPyVdW9/rrPU7+XvV3QOw8JUBX8TuSmRFV8TsgKbEVGU9WMLuSmMdlV0LlNY7ZIlCf4tkGVLqWaOZh9eNwePeDlN52SZTlh8ExKrftIa2HtB1CGbsdXzPb7nPJH5qlgmwVY9oMxdrCvcfacI3H3mNpKo439U4bJOq92xTqUyVUsU+BzUmOp81kFXsK2bJlLD1XMqAU+yYeKEqmh2UfEo7ZAU4DkIQlk5SXFDiSSdkJiSXYSS/CJyaLsIQnhIlCRRONDvUJinNlTjZfNV4mTjZghCsmTYT7KjzVU2ZOtmTwUmFbsqPinmT+apmzEcinm1B8U8OSYXhbtQqoqztF1JJBEyGAV80cbI28LQ1ri0YHTIGfisutH2kHi7RNUHxutV/wDLOWcXnsusjvMr7UoABRwgf0t+gQQQQUavIILZdj+k6HXPaLabJcjK2iqu+7wwODX+rC94wSD1aOi9f6P7BtFaMq2VdHahU1jAOGeueZnNI+0AfVB8wAtGloZKoczSAM4XFX7iyjsEggma50hbzADGMEkaknTY9CuKfRq7EK243e36wvMHcWymd39DBKPWqH78MmOjWnDgepAxtz9ZApAOUoFdfTUzKWPkavnK+XqovtWamfQbNA2A7vE956+WAl56pQOEgHCUrS59OApXIpppSw5PTEvOyNIR5KEJSCCCEKqvA9OfBb8ZZUEmYf8AYtxxDz4iWtx4OJ6K1UC3f0iWoqzyld3bP4GkgfMlx9xCnoQq693Rlmt0tU5pe5uGxxA4MjycNaPDJIGeQ5nYLk17kdW1wtEkrZnPcK26ygbPJ9mPrgHhGx5MjA5ELQaw1TFE2ou8gMtDQl0VHCB/1ifdrnt/FgI6d4dw4LAtdNbbVI6qf3lyrXmeqf8Avu5geQGGjyCqSyAaLRgiI9Yqn1lenV9c4gksaOFo8lj5IHVFhpqVpxU6kqTkg4Io2D1j7iwAeRnCeu733OsbSRuIkqpBA0jm3iOC74DJ+CsLTLBcdZ3qtjA9AskbbNSgcuIBr5seYcWMP/drHc7OXLbjaG4C19O6PS9jfcS1oneDFSRY2z97HgP8uq819plydVahFHxF/cjikJOS55GST8CF3GummulQ10zyWsHCxudmjyXnu4xvuV8q6uQ7TSOeD4AnOE6m1cT3JJwQ3HUqJpak9M1JboSMh1QwEeXEMqg1nc23LUVyqQeIS1L+Ej7udvwAWm0nL3eoKORu31hx8iue1zsucR0JWg3Vyou0bhGJOW633ZS7u6y+1f8A9TWepeP4iA0f8y5y1+WrpvYtS1l3uNbaLZQmvut1jbSQMdkRMZxB0j5COTQACnOOBlNDSV0TRGmblqKyaf0NZ291WVRbdrzUubltLEMdw1w9wa/hPMloOzitxqOvtIiqdKWhzqfRliHf3uu4uKS4T52h4+bi5wHE7bJGBwho4rzUL6Lsh027SNhnfX6luThJdbkMNmlkf029kuzhrR7LfM5XGO0a7QWGjp9JUL2ubRuMtfJHymqiPW+DRsPkeSok5Ov78FdjGcHp0/X9FkdWX2bUt8nrZsNdIcMjb7MTBs1rfAALLV84kPA32G/iVKqZiGkA7nmVWTHDShW+ihTPy5BjhFZaybGH1E7adp8WMHE7/icB/dTU7wxr3Hk0Epy9A01NbKIjDoqcSSD/ALSQ8bvzAS+CFWDmoVfMOINHTmpmcNJPIKlqZS97j4qRo1UbzgJt02CSqyqkMhJ6nYKTO/hbjqVF9qUDo0ZKnAVRxUapOHBo5NChTPDA5xOA0ZOVIkfxOc7xWe1ROf2ZJAx3DJUubA0jmC8ho+Wc/BSBQFaTsWJk1JRVTs8daZqnf7rmHg+TAwfBd+6rhnZjws13RRsHCxkT2gDp6hXc/FctczmYeX6r6C4C0tTv85+jUCjaEMI1kL0dA7Lknax2aXvWGoYa63imdAymZBh8nC7Ic9xJ2x9r8V1oo1NDK6F3O3dZVytsF1pzTVGeXIOhxsvNUvZHqujkJNrMsbBgOimjdn3Diz+CkWPR99tEl8qp7RWMc23ejRAQl3EZJG8fDjwaDlejUXVaAuUnVoXDv4CoScxyvHng/YLy1LQVVIMTU0sONj3jC3803xL1Uo01so6kky0kEpOxL4wc/MKQXLvb81mP/D//APZ1Pxb/APxfZeXw7ZHx+a9H1GjbFVA95aKPfclkLWk/EAKvn7MNNVBJNtDHHrHK9uPhxYUouMfUFZsnAdcP8OVh88j7Fefap31HvKjW717kD92Mn8gu81XY1p+pjDA6rhx1jlGfxaVBh7DbTTSSPir63Lxwjj4Dgf4QphXw+Kzn8FXdp0a0+Tv1wuPTPy4qKXcRK7NN2G0kg9S6ztPiYgf1CiO7BGcQLL25o8HUuf8AxqQV0H9XyKrO4QvI2hz/AMTf1XIzs0J+tdiKFnic/guoy9gj8DgvbXHwdS4/8ZT8nYPHM5pfeneqMDhpsf8AjR6bAPzfIoHCV5Jx2H/U3/8AJcgzunWOwuy0vYVamD+kXCslPjHwM/MFWtP2P6bgxxwTz/8AeTuH/LhRGvhG2SrcfBN2k9oNb5u/QFcEc9QKt+xXpZ3Zdpd0fAbUzHlLID8+LKwuuOw1gpJqywSyGRjeL0GX1uL+B3j5HOfFDK+J5wcjzRV8F3OljMreV+OjSc/AgZ92vguQ00maQe8/modG30nV1uj5tha6V3yIH44Uima5lKGPaWPBcHNcMEEEjBCTpWP0nUdyqekTGwj4nJ/5fxXcU/8Ahg+AXh1X/juH+8Vs2dSolMeLvX/ecVILuGJx8lHpRiFvnupQoSVIacBON5ppvNP08M1VURU9NC6pqZncEULB6z3eHkMZJJ2ABJwAkPejwCaZDPcrlDQ0cYlqpAWsa44a3bic5x6Na0ZJ8AVYXSspYqSG1215lt9O5z3VBbwmqmOzpnDw+y0b4aBunbwKXTsVRZaCZtTXy+rdrkzOHEHPo0RPJjTjiPNxAzgDhFI5/Aw9ABsonO5sY2UmOTI69UzLJl+B0SHnJHkkA5d+KVzKEzKDwXMa0c3kD5q2jGAByAVZSt7yraOjG8XxOw/VWrPBOGyVLbyVTd5uOqDAdmtx8ValwaMnYDcrOyyGWZzz1dlKUKSwmK3yuHtykNH5fzVjAwRMY0cmjCh939bSwdGAyOH5fiVPGyVCg3+Yx2idrTh8gEbfe44/VZ++z+hWiYM2cWcDQPPb9VcX13fVFFBnbiMrh5NG34uCzV8k9Lr6SlBy3vOJ3uaMn9E8dEw7FTKCl7qOmp/utGfgP5q3PNQ6FmZXvP2RgKdjdPTcKbZNYVWiK+K4U4MkfEGTQZwJWE7jyO+xXo21Xekv1ujq6OUTU8o59QeoI6HyXlG+OyKSLrJO1v4rb9m+szpG5Vjpy+WhqJY4TC0+yQCXPA8QMZ8RjyWfVU3ajmbuPmu14evf8Pk9HnP8o/8ASe/y7/j522vtCu01dKi4Uoc+hrJOInn3LsAcHu5kfJZNz/WXpCaKkvltcx3BU0dSzmN2uaeRC4TrHSVTpS4uY8GSjkJME/3h4H94IpKntB2b9x80/iKyeiP9Lph/Ldvj8pP2PT4dyqbVaqi/3anoKZpdJK4NLsZDG9XHyC9DWy30umrLHTx8MdPTR5e8jGcD1nHzPNZXsr0l+xrablUx8NdWNyAQQWR7EA+/APyTPaPqX/71Uz+WHTvY73+p+p+CrTuNVKImbBbVrgjsFvdX1A/mPGg+g9+5/ssvqi/P1Fd3zcqdmWRDlhmdifMqn4uN2fkERPC3zP5Im43J2C1mtDAGt2Xm880lTK6aU5c45KpNSzl5go2Hdx4nDyHL/XkpscYt1vwNi1v/ABFV9vZ+07pNVu3jaeFufAclKvEpe6KBh3PrOx8h+qf4Kt3lCje6kt09SBxPf7A8XHZo+PqpdylZaqFsJPFFRQd5IfvOwfxO5+KU5zIJ4Wu2hpWd+8Dq7k1vvzk/AKPHZJ9WXq06eDnNludR31W5vOOBvrO9xwMN8SAOqTdwCXUDRdk7ALQdDdlNw1PVw8dwubXV5Zj1nsAPcsHjxbub/wB7hd60tZnWDTlutz3iWaGFomkHKSU+tI7+84ud8VlZ7UyWt05Yoo2xwNlFZNE0Ya2Gn4XNaPDEpgGPAOXQGDJT5D0S6NAAT9OzkrKBnJRKaPkrCJmwVclCdYN08BskMCcAwo0oQ4UaMcigBlIlSCMJt7dk+Rgppw5pUKsracPY4Yzlc41tQmN0M4Gwyxx/EfqupysyFmdS2kV9JNF7JeNj4EbhMlZ2jC1alprBQ1sc7tgdfI6H9VykHBR43GBnOyVUU76Wd8Mg4XsOCM5XPO03tFq9F11qgoYyZy5tXIHs9WSJr/YDjy4uEg+AWFHE6V/IN17hWV0NHTGqect6eOdsfvZZTWF/Gpbu+ohdxUjB3cODtwjr8Tk+7CpqV3A4tPI7Fa7tD0zBabzFcbb69jvkIuNC9ow0cWHPZ5YLg7HQPaOhWRc3hc132XeqV08Ya1gDei8Aq5ZJ6h8sp9YnKcnbmI/ulQZfZI6FWLfXYWnnjCr5mnhI6hShUkqSAVtueDzLS13keh/JTL/Ga232bUbAf6U30GuP3amMYa4+bmDP93zUW1SAyvgJ2lbgeThyV9o6nZeI7tpmd7WMuUfHTOdsI6qPLmnyBAwT4NA6pHaa9yc0c2nestLHxsI8lWyNI3GzmnKtWMe0FkzHRzRuLHsf7TXNOCD5ggqLVRYy4cuqeFCUTHh7A4cirCinywNzkt2+CqIHd28sPJ2496lQy93KHdORTwgFXwcCMjqlsdnYqLDJluMp5rsYSqRdI7NGF1LVSPaHFhETH43DefDnwyVtlmdAU/c6ahfjBme+Q7eeN/kpurKqWl07XGAjv5IzHGD94jH5ZXKVBM9UWjqcfZe8Wnlt9mjkfsGlx9+XfdcQ1LXN1De62tjOJjI7hGdnMGzfwAUegrhIPR59jyaXfkocrHNkOzo5WnBBGC0+BRPLaoZd6ko6jkV1bAGAAdF4NO900jpH7uJJ96sJ6cxklu7U21Koq8giGo2dya88ne9PyUTi4GJpcSccLdypN9QqRb0VrpKzTaiuQpGktiaOKSUDPA3+ZXYquqpNP2t0jg2CmgbhrG7e4DzKg6M00NN2dsUgaauU8c7mnIz0HwH6rC671ULvczQwPPolO4jyfIMgu93QfHxXOPJr5+QewF67TMZwpajUSD+fJ0+g8hufHTuVHeLvNebjNVzYD3nZo5NA2ACajfxgHqozvVOEGScDs9DzXQNaGgNGwXkksj5nukkOXE5J8SprHb4XXdKQmDTtC0jGWcf+Ik/quPh2+cruFFD6NRwQ4De7jazA6YGFjXR2GNb4/v6r0ngaLmqZpu5oHxOfsua6tqe/1FVnOQ0hgHhgAH8cqpzgoVtT6VW1E/PvZHP+ZykcWy2IW8jGt7gF59XTek1Us39TifiVGkHdzub0PrBOMek1Q9UP+6d/cm2nBU4VIqXxZCUx26YByErJSqNTY5NgpLTsqyGXDi0nfp7lPjcnpxCfBygThJREoTcKbRS4eRnmFIrIRVUk0P32kfgq2CTheCrZjg7BHUISEKqglM1JE88y0Z9/VGHbpFK3u/SYP93K7A8j6w/NAHBQo8Kxp3KzqX8WmID4VjvxaP5Kmp3ZaFZSuzpd37tU0/NqE4KJK/LVn65317/erp7sxj3KhrXfXv8AeqVV7A81fofbPkm4XYeFOjfuq1rsOCmRv5LMytshWdM9XdC/11nqZ+6u6J+4TgUYWlhKmxuVfA7YFTIzsmp6nxO3UyN2yr4nclMjchCkg4RSZcwgb5CJp5K50lQftTVFppTu2WqjDh4t4hn8MpiTdQ+0jEevL3E3lDUuh2/dw39FQMduntT3MXTVN2qwcioq5ZQfJzyQoTHKQDRId17dbLjqnGz4UMPzt1Q41ilaQCsW1OOqeZVkdVU94Qj77Calwr2OuHUqUysB6rNCo808yrI6oTSFpW1AI8UrvAeRVDHXEY3UllbnqnpuFaF2UhwyVFbVB3VONmBPNCajc0hITvHlJdgoQmskIu8wlOam3NTEJwTEJxtR4qI4FI4yNkuUKzbUeadbOqhsxHVOsqUuUmF497V6c03aTqNpaGl1bJJgDHtHiz+Kya6D270TqTtMubznhqGxTNz4FgB/FpXPlw845ZXjxK+xrNKJrbTSDqxv/aEEEEFAthb/ALBri21drum53cnTuh5Z3kjdGPxcvdbZV85dP3I2a/W24DY0lTFOOf2Xh3T3L6FRVPG0OaQ5pGQQcghdPaH+o5njn9/BeAfiTT8tZT1H9TS3/lOf/krVsicD8quZPlPMmyuhDl44p3F7koHCjNkTgenIT4OUoHdMB6cDsp6YnQUpNA7JYOUISwdlGuczqehlMZ4ZXYjjPg9xDW/iQpA3Kh1f1txooejeOc+BDRw4+bwf7qEKVBCymgjijGI42hjR4ADCzuqbpJJUR2ejlMVTOzvJ52HBp4M4LgejnYLW+5zvsYNnfb1FYbbNVPY+Z7cNjhZ7c0jiAxjfNziB4DOTgLnd5bUwU8lA+cPutwJqLjUM5MaRjgbn7IADG9cNydySonv5RhTws5jkrM3Orhv16gZTsEdotreGmiaMNJGwdjw228mjxVDqKvy2V+cDGAraORkVE+SNvAyU/Vt8Gcm/hv8AFYjVlcI4wwHc7rJkdhuVtRty7A6Kstl1htEt2v1W0PpbNQTVjmk44n8JDW58SA8fEJ3s/oprboW0xVLnOralhrapzvadNK4yPz5gvI+CzOsG952cRWwj1tS3qnonge16Ox3G4j/607/EugF/GqL9Gge9aTBqSkVzjDbK2Qc2wvcD7mlcJqWd0yZ33Wk/gu6Xn/1HcBn/ANnf/wApXEbjGTFKGjm0hT02xVafcKo00OG8W0eMwHz2WDqmcUkg810ex0hZf7Y3lwzMz8wsxJp6Wa7Pp2MdK+SYxxxxAudI4nAAHPKvNIBKqkEgYVPp+wVeoLlT0VHBJUTzyCOOKIZdI4nAaAvXtooaH6NOlILTboobl2k3yP1y3DhTM5788Mbz/eLSTkABN6B0RB2CWmnqJKGO79pV1iIorc31m0TDkFziDgDnl2d8FrTjjcub6+1LNpS5XSgo65t97R7ngVtwJDmUJeeGKIdOJzsANGwwCR6oBikeSeUKSKMPGXbfX+ysaW+OslHedVVNR6bJSTPoaKSQZNVXuH1s5zzDAS0cxnjHguO1FVLVTPke90k0hLnPcckk8yVsu1apitddbdJ0cgfQ6dpW0nEP7ScjimkP7xcd/MFY5sBjY0n2nDKhGmivjvPVR5RwtwFBqNldGic9hdhVFbC6J2HDHvTwglQYab0+vpKTpUTNjd5Nzlx/wgqPe679oXesqRyklcWgdG52/BT7RIYaqurPs0lK4tP/AGj/AFG/gXKhcQ0JRqUbBM103dwEdTsqeR2VJuE/HJw9AN1BLvVLjyG6maFXeclMSu4pT5BRnv4aeWT7xwPclSPLYXO+0eXvUeueI2wxBTAKqSolRJwNx1WdrD6Vf7XAd2sL6l48mt4R+Lx8lb1cmZSPDZUlI7vL5dJ+tNSxwj3uLnH8mp3RRroHY5TemayqKgg8MFO52cdSQ0D5E/Jdv6hcu7D7JUUtFXXKaMsjqeCOBx+0Gl3EfdnHyXURzK5C4P5qg46aL6S4NpnU9njLhgvJd8TgfEAFGgggs5dsi6o0QRoQgiHVGgOSEIIIIIQgggghCCI8wjQ6oSoIIIISIIBBAckIQQQQQhBBBBCF557bLPHZtVvqY2BkVXF35DR9vJDj8SM/FYTQcJFrmqHe1UTOeD5Db8wVuPpGX2Gou5pYc95RwiJ7unE71sD3DHz8lmtOUvodnoYSOE921zh4E+sfxJXqlBn0SPPcF8WcTCMXyqEWwe7451+eVZVb+CnI8SkxDhjaPABJrTxEN8vzS4GPnmjhhjfNPI4NZExpc558ABzV3pkrmTvhON4nPaxjHySOcGNYxpc5zicBoA3JJIAA55Whu1czs8t09LDI1+pqiPgq6hjg5tvjPOFjhzkP2nDlsBkgFH6RHodrmwPZPqRzS187CHR28EYLWEbOmwSHOGzd2jJyVh653pNbBTglxc4zSknJLQc7+92FXz2h8Pqpc9mMjf6KdTsbDExoHDgcvNIqX4ZjxKcUeoflwHgnJo2RR77o+L1kGjDQm5QS3A9px4QnJVNtbMxvlP23be4bBT2ciU1BH3NJHtgu9keQToGwQlATFwm7qlkIO52HxVPTR95Mxp5Z39ymXaXieyMdPWKYpSIWSzO5NBwhHVTaQd7UVE3McQjafIc/xKlJuhhMNJE12zuHid7zufzS5niNhc47NGSnZQVTVsjTWVVQ47QsETff7R/NvyWXpHGpvckhORDHjP7zj/IK7u8hiomsOz5XF7veTn9fwVLYGcbKmbmZpSAfFo2H6p7diUx24C0VEOCLPV26lN3TMQwMBPMB2S5RhVta3v75b4uYja6U/LA/FP0bg41Ep5d64N9+cE/JrfkmI5ALrcql27aeFrB8i4/olU4MVNFGfaDcn3nc/iSnDdIdvNdR7LNeutczbVcJc0UjsRSPP9S49CTyafwPxXYK2gprjD3NVAyoi4g/gkbkZByCvN+mNPVWprlFQ0gAc4ccj3cmNBGXH5j5r0jRUjaCjgpmOe9kLAwOkdxOIAxufFYVc1jXhzdyvXOFJ6iopXRTtzG3QE/MeIH9lV6t1A3TlnfOBmeQ91CMZ9cg4J8hjK45PI+eR8sri97iXveeZJOSV3S42+nulI+mqohLE/mD08x4Fch1dpufTtQG7y0srvUmx/wnz/NS0L2DLfzKhxbS1by2feId3Q958+/3edCSXbnmVCvVSaW3vDM95KRGwDnk/wCWVPaqib/pC9ho3ho27+Be7+QWsN8rzU7YCl2ykFFRsZtkDLj5qBTSelV7qh27S48I/dbsPnzUq7TmGj7uM/Wznum46Z5n4DJUSEBjJGRks4WhgIO4b1Pv6D4o8UhGoA6I/SG4lnlcGwtcZHO6OI6+5oGB57rqX0a9Ly3XVV5v1dE5kkbIoWMcP6prhxhnvI7txHQggrnNptdPdrk2Krbi02+F1xrx0MMQyI/77uFuOe69MdllBPpbsyFyqow+7XPjuU7AMF00x4mt8jgtbjxypIxrk9EuCtfpyAVt5ut1Iy0vbQwEjbhiLi9w8zI57T4921ainZkZUCyWsWm1UtJxcbomAPf99x3c4+bnEuPmVcU0eyiLsklIVKgjxhTWtTULNgpDBhQkoASmhLQAwEoDCalRcKPGOSNBKhJxndJcE5ySSNkiEw4ZCpNT10VptUtTJzGzG/ed0Cv3Bcl7RL6253YU0Lw+mpRjLTkOeeZ+Gw+B8VDNL2TCeq3bLbjcqtsbvYGrvLu9+yzlNBLc65sYPFLM/dx89yfzKz/0gdDtu3Z+2upo+KusL3S+qN3U7sd7+Qf5BjvFdP0dYDFQG4St9eXIjB6N8fic/BTLhCwucJmNlglaYpo3DIc0jBBHUEEhNo4+zbzncrX4luIqqj0SI+pHp/xdfht8V5+7IJWdpnZjctHSnivFmca+1lx3cxxdxMHlxOc3wHet+6sGYHPdPTSNLJWk+q4YII8fDdLIrOwXtgHciSSnoZhLCCd6mjeCOHPInhLmk9HNz0XSe3DS8FFcKPWFoImtN2a2Vzox6oc4cXF7nN9b+LPiFfHqux0Oo81yLh2sYd1bofLvXLoXcTA7kRs4eaj1LcSkfe3U2WNsdSS05jmHED59VHqIy5hxu5p/BShUsKsHFFIHMOHNOQfAhWT6t9JXU1fTO7t/E2ZhH2XNOfwIUCQb+9OwnvaZ8JO7Txt/VP3Tdtlqtf0MVRUUuoaNgbS3RoMzR9icD1v8QB+LXHqshI0HIO45Lb6NmivtgrbHVE8PNp+0w5y1w8wQCPcsbPTS0dRNS1DQyogcY5AOWRyI8iCCPIhRjTTuUsoGjxsfqqiojMbi3OMbtKcY4SsDhz6hSKuLvIzt6zd1Xsf3Ts/ZOx/mpQqp0VxRVGWYzu3ZTmP2yqGCbuZQ7PqnY+5XtuhNXW09OM5mkawY55JwnZwMqRgLiGjcruen6f0Sx0ER5tgZnfO+Mn8Vku1KcTxUdCHFrwTPkH2SNmn8XLeABoAAwB0XIdYXL0/UlW4HLInd03+7sfxyuaoW9pUc56ar2nieYUVqFO0+1hvuGp+mPeqF4ivEfBVEQ1rPVE+OZ6Nd4jwPn86SppZKWd0UzCyRvTxHiPEK6rad0gE8I4pWjDm/fb4e/wAP80wKmGupmRVJPdf2c4HrRHwPi3y/yx1WjvNeJu0VRjLcO3Hj1XS+yaxSVRkudSOKGB3BT5+07G5I8sj4+5Yig09WV95p7a1mZZSMSNGWln3werQu8sZR6XsZDcxUVHETucnA3PvJ/MrIrpixvZN3d9P7rtuFbYKic1s/+HFrr3/23+Co+0K/yWq0GmpselVILPNrMYcR58gP8lx4HdTrtqia73uqrZAe7lf6kbvssGzQPh+OUmSnbUs76Df7zArdJB2EYb16rBv10ddax0g9gaN8u/37/LokNd3keD7QRHcYKbidhOq2ucU+wMNVdKSnJ3dMxvLPMhdnvNR6JaaybOCyFxHvxt+K5RoKm9J1XRZ9mPied/Bpx+OF0HtAqXU+lqoMOJJC1jfP1gcfEAj4rBrv5lRHH+9SvVuGP9Vs9XV+f/S3T5lcyaUoHITEMgewEbtcMhOg4OVvLylKe0PaWnkQojHHG/MbFSyVEnHDKfBwz8U5CfY9L4lGjd0TocnphRvOAHDm38lOp5g4B2VBz8kdLJwPLCfchNVwDkZQJwm4X8TcHmEpPQhnfKtKWXia1VR5KTSS8O3mhOISpm93dZh0lja74jZNP2eU9cCBVUcvQlzD8Rt+SamGHlCjITtK/GRlWcrv/mvP/wDjLf8AlVNC/D8K0nd/81ZT41Tf+VMTlEDvqm+4Kjrj9c73q3idxQtPkqev/rX+9Var2Ar9AP5h8lFLsYKkxSKE52ydikWStzCtaaT1gr2hduFmqaT1loKB/rNTgUmFqqV2WNU1hwq6jOY2qcTgBIUKXE7dTYnZAKrYXZKmxO2QEKaw7rT6Cn9D1FFVAgOp4Z5AT0PdOA/EhZWM8lb2epNPUOwcd4wsJ9+P5JcICw07+Crlb4PIUiN6hXF3BdKseEzh+JSopMgKZRL3FkoZKIlAFYi1glcSGQkoJqXKVkIB2DzSUEIynBKQnGzEHmo6AKEYU9lUR1UiOs81Uh26hX2/Q6cstZcqn+qpoy8jOOI8g0eZJA+KaSGjJTo4nzPbHGMuccAd5Oyvbrqa32CjdVXGsio4B9uV2MnwA5k+QXOq/wCkvYKeV7Kahr6sN2EnC1jXeYyc494XBtW6tr9ZXZ9dXP8A3YoWn1Im/dH8+qpFzc1zeXYi0C94tX4fUccQdcXF7zuAcAeGmp88+5emaH6S+m58CporjSuPM92x7R8Q7P4Lcac1/p3Vzgy1XSGonLeLuHEslx19R2Dtjp+oXi5KjkdFI17HFj2kOa5pwQRyIKay5ytPrgEK1Wfh5bJmn0Z7o3dNeYe8HX5r3a5uEy5q816A7fLrpw09HeM3S1MAZxcI9IjaBtwuyA73O38wvRFg1BbtV2uK4W2obUU0g5jm09WuHQjwW5T1UdQPV37l45euHK6xv/1huWHZw2P6HwPuyn3N5pBJCkvjI9yYc1XFy68+fSRoeDUFpreEDv6Z0RIHMsdn/wAYXH16D+khRNfpq11Z9qKr7ob9HMcf/AF58XHV7eWod4r6m4Ln7exw53bkfAnHywggggqC7dBe79BXZ120VYqx/EZJqGFzy45JdwDP45XhBevOwm7trezK0NDsvp+8geOLOCHux+BC2bW7Ejm94Xkn4jwc9BDNj2X4+IP6LqzJ0+yfzVQyfPVSGTcl1AK+e8K4ZPyTzJ1UMn808yfzUgcm4Vs2XKea9Vcc6ksmypAUisA5ONcobJcp5kiVMUgHJUOmf3t3rX59WNkcPudu4/MPZ8lJY7dZS6V0stO+gpZHQVt0q52GWI4dDDGe7klB6ENa1oPRz2IJwMp7W8xwmaq4Nu1xmvEuXWy2l8VFGRtNNu18w/GNp8O8O4e0rG3+V7aR0b3ZrLlJiRw5hvN3ybt8Vr7s2KJlPQ08bYaSla1rImDDW4GAAPADZc/rqv0691kwPFHTf0WPwyN3n54H91U3laMLe7b94UC6zBuWt2a0YAHRco1dce8qntBzg4A9y6LdqjhZK48mgn5LktOf2tqijpz6zZJ2hw8s5P4ZWXKc6Ba8DcaqbqZvHr/Qtl5fsm2T3GQdHOk4Yhn48fzK2cTshqw1NOLt2w6trOcdDDT0ER8PVLnj/FlbKOXDwFBLurTNgn7q4Gz1+cH6h3PfoVyu61E1Z3Zlk4xF6rQGgBufcF0y6P8A+i60eMRXOW0klY6WKNu+x93VWacaFVJ/aCrKiWC28FbJiNsJ4i4D5D5rrPZvo7/0Z9xeLjbm3DtEuoL7XZZuVshdn66ox7JwTtz5tGPXLc52ZWmaoqGaiZSslMLwyzyTgOYZckOqmsIw7gxiPi9XiJfh3CzNl2n6mp9E2qqtVFUvqNS3UCSvr+Mulaw4OC877jYDnw77ZGSWZsTS5W7dbpbpVMpY/wAx+XU+QCb1f2owaOluNNaao3nVlW7/AKR1BLgtDvuRjGCG8htwjHI4AHDYoI4JZJWNxLLJ3r5Ccve/7xPMnzO6WguaknfIdTovpG22KhtcYZEwF3VxGSf08gilaJ3ufION7iS57tyT45TkcYlmYHHbkkI+SdDUPhdkHTuTLpYqO5xFrmhr+jgNR+o8CrKoLKePYb9Fkr3Pl7ieeFo6mpD6YOJBcBv5LD6grODjOehcuoDg9ocOq+c56d9NM+GT2mkg+5KZIYdMSOOz62sOPOOMY/5i5UdRJwtPgri9Zpae2UR2dT0rOMfvu9Z34lZ64P4IfN2ycwdVE84VZNJxFzupKZqDwxho6pTTxzBnh6x/18/kmp3cVQfBgVkKo5My7zRRjlkuPw/0FW1MveVch+yzZTzKGPqJT/ZRj5nP8gqffuCQMufsAFIoCocrskk+9aXsl7Pnajjrrlco3Mt0tY4sadjUNZhox+7lpyfgPK70f2XS3Isqru19PSkAspxs9/v+6Px9y6zTU8VJBHBCxsUMTQxjGjAa0DAA+Cw6yvDR2cJ1716twxwk+d4rbizDBq1p3PiR3eHXy3UyJkMbI42tjjYA1rGjAAHIAJQ6ozyRDkubXt4GBgI0CgiKEIwgsp2j66ZoGwsru5ZVTyStijgdJwcXMk8jyA/Jc/j+klxwuk/2dwAQ0D07nsT/ALv3fNWo6WaVvOxuQuereILbbpuwqpeV2M4w47+QK7WgOS41bfpByXS501M2xshZK9rXONUXEAnn7A8U2/6QNUWngs0LXZ5unJA/4VL6BUf0/MLOPGFlH/vf9Lv0XaUFxB/b7dHY4LZSN8eJzj+oSH9u97djgoaBvjxMef8AxBL6BP3fNQHjOzjZ5P8AwldyQXCH9uOoJMYgoI8fdifv83lRKrtr1I/ZklNCcfYhB/MlOFvm8FE7je1N25j/AMP916CQXm6q7XdVy7C5923wZBGPx4cpl/aJqSoja594qQT9x3D+WE4W6XqQqb+PLePYjefc0f8AyK9LoLy5Nq29zg95eK9wznBqX4/NV1ZcamrOZ6iWYnmZHl2fmpBbXdXKm/j6EexTk+bgPsV6pmu9BTf1tbTxZ+/K0fmVXya209CPWvlvznGG1LCfkCvMtCMvcoTjxyOd4nKlFtb1cs9/H059iADzJP2C9Tx630/KfVvVB45dUNA/Ep+PVVklzwXigfjnw1TDj8V5aj/qgifyS/w5n9RTBx7U/mgb8SvVEmpbRFGJH3WiZGcnidUMA2575XPtf9ulrsVJLTWWRtyuT2epMzBgiJ6k/aPkNvErhVY7YNHVUlUcvKVlvY05ccqtV8cVs8RjgjDCeu59ylXiuqL6+kFVO+eoq5eOWV5y4knBP4/gt/TwslcBDV0b8c2iqjaQPc5wK5vZ3ek3eI82U8Tj7jkj9VvoY2hgaQHFuBuu8j0iYPALwCcl88jnHJJP1VnUWuljmLqm7UzWgAllKHVDxj+H1R8XBPQ3+Kkp3xWaF9FG4cMlbK8Oqph1AcNo2+TdztlxVJcZO6pH8O3FhoRU7OGJjeoGT70pbka6qIHGyccRjAAaByAUC3Dv6ipqjyc7u2H91u34nPyT9xmdTUcj2DLyOFg8XHYfiU5SU4paaKFu4YAM+J6n4lOGgTOqdzsox9eQnzT73cLHFNRjBSJUo+sEqmgNTURsbu97g1vx6osZbhWlniNPT1FcebfqYB4vcPWP91v/ADJNk8DJwnZy0zuaz+rj9RvwSScpO0bWtHRN1UndQOPXGB70iVU9XJ3tQ9w3GcD3KSIOKOCDG8jg538I3P6KNTxd7M0Hx3VtSM7yrkk+yxvA338z+iXZKApJ2woVactawfaOD7uZ/BTiFAqXBskjz7MbSUuUYysjqer4ZZnZ2jbge/8A80LDB3dDTNI5N4j7zv8Aqqq+yOnwzPrSvGfn/PC0lviAZsMAAAe5TbBRbuU2JmykMG6TE3YJq7TGktlTKNnBha3Hidh+JUecnClxgZVVTO7y2SSn2qypc4Hrw8X8m/irW126e7XCGkpYzLUTODGNHUn8h5qNS22aoqaC3U0bppmsDGxsGSX8v0PzXoTs77P4tH0ffT8MtzmbiR43EY+40/meqjnqBCzxW1abRLdJuUaMG5+w8Sp+idGwaPtndNLZayXBnnA9o+A8h/ms12m6xMT22mgmxICHzyxuwWkHIZkdep+C1Gt9UM0rZHzjeqlzFTt5+uQSCR4DGT8uq4fA59ZUvmlcZJZHF73nm5xOSVnUsZleZpF2nEFfHbaZtto9MjXHQfqev912vRWpTqC2hs5ArYQBIB9odHfH81c3S2Q3e3y0k7eJkgxnG7T0I8wuSaQu37GvcM7nBsLvqpCeQaSN/gcH4LspVepj7GTLdluWGu/ilCY59XN0d4jofePouA3xjtPPq21Iw6mLgR4np81VWymdR0YdN/XSEySn947kfDl8F1/tH0N/tRTQVNOMVVO8PdGB/XtHJvvB3HuwuSXGcU3ed4C0QgucPPwWvBMJmZ69V5hdrZJbKksPsn2T3j9R1UCqmEtbJI44jpm4x+8Rk/JuP8SdbE6GBjXjErz3snlnkPh+iZo6Z0kkUL+Y+unPTJOcfP8ABq0+i9Ky641NRW9oPdVL+KZ4OOCnbu52ehI2H7zmqxkLFa0uOBuVodKaT9NtlhsMkYNTqusZXVviy20x4mtOOXeOwQeR4gvSb4f2leKGlAzDC70qVuNjw7MH+ItcP4Cuc9lcMWo9R6j1mxgbb3uFnswaMNFJC7DnN/dfJk46cK6zp6jIjnqnj6ydwDT+63IH4lx+KlHqs13KHHJJGw0HuVqyPJU6njwAmImb4U6BvVVyUxPRsT7QkRtwAnmqMlKAgOSPCCA3SBOQRlqPhRpU0pCCURt5IEbJyRZ3Wt9/YFklex2Kmb6uHHQnmfgN/fhcq0zZX6gvUNNv3ee8ld4NHP57D4qTrW+/t6+zSMdxU0X1UOORA5u+JyfdhdB7P9PCzWdk8jcVVUBI7IGWt+yPHlgnzWUf9Zmx0C9PYBw7aOc/40nxBI/+I+at5KKOKBkUbQyONoa1o6AbALOXWmxxAjYrYSM4hgKoudLxxk43C1wvLi4k5K88fSK0M7UGkWXumiMlzsgc9waPWkpT/WN8+HHEPAB3iq7sC1FTa50XctBXR/GWROmoXOOSYnHJDT4tcQ4eTh0C7jUQBri1zQWuBBa4ZBHgQvJWorJW9i3aiwWxxjjik9OtL3HLXwkniid48OXNI5luDtlOxzNx13CsRO5TnodD5IXK0VNjr6yzVjeCropCGno5o9kjyII+BChlwID8c+YXZO1q10euNKWrtCsTOJhZwVcQ9qMZIc13m13EPcQeWFxuQcLyR7D9/cU9p5hlQSM5HHuVdUx8DyOh3Caa7u5Gv6A4PuVhURd5Gcc27hVzt8jmDzCkCrlWNpuX7Du8FWTwwhwZMfBp5O+Bx8MrS9olpBiivULc900R1QG+Y8+q7+6TufuuJPshY2Phni4H+sC3hIPVdE7PbiLzY5rdV4mqKP6iVrxnvInA8Lj4gty0+bSmu0Icpo/WaYz7lzzg68wquph7qVzcbHl7loLpZn6avMtskLnQgd5Syu+3F0GfvN9k+4H7SgXGDiYHgbt2PuTwq5HQqnBLDwncdFruzdvpuqrbTv34HmQHHLhBd+iy0keQt12L0Rm1PPOfZgpnEe9xAH4ZUU7+WFx8FqWeHt7hBH05h8Acn6LsVzq22+gqKlxAEUbn78tguEGV0j3Occucck+JXWO0i4Ch0zLHxBr6h7Ymjqd8n8AVyEO2VG2swxzu8rruM6nnqo6cH2Rn3k/oApUcvCRnkVFuFIYy6phHE128sTftfvDz8fFOtcrrStqkvd2ipi0mBp4pHjo0efny+K1XvEbS52wXCQwvqpGwRjLnHAWx7LrE+gs4rZXOcakcUDXj2Izv6vXDtjjyCpe13U0jXQWmAkQOHHO8cnEHZmfLGT7x4Le367x6eslTWFnEII/q4mj2ncmtAXBXXWSaSWSqe6vpql3HIHncu+8D9lw8fgVj0jTUzGof02/fgvRuIJ2Wa3x2mmOrh6x8Ov8AzHPuyFAbj4qZTVDoHhzDg+HQpqsoHU0bJ4X+kUTzhswG7T91w+y78+iZZIQt3ZeTFXhaytaZIRiUDLo/HzCY4s8lEhlOWua4teNwRzVg0truQDKnq3kH+7wKdukWv7K6YSXmqnIz3UOAfAkj9AVd9p9UI6ChgLgO8lL8dTwjH/iTXZRSllvr5yCC+Vse5+6M/wDiVV2r1RddqKAHIjhL/i52P/CFgf4lf5fp+q9WA9E4T8X/AHd/+IWTpnd3JJEeTTxN/hP8jn8FJB2UB8uO7m+4cO/hPP8AQ/BTgcreXlKWDkJiqGY89W7/AM06ku6joUoQozH8JUgHKhAlji0ndpx/JSI3cQTwkKc4veg9xaWvHTn7kkHKBwQQeRSqNWdPN7J8VLVNRS7FhO7dlawv42jxQCpNkp/soU8nC4hG72SmI3cMgT0xT693FQNeNzG5rh88fqhNg8LhyKL+uoZ2/ukhNRv46WNx6DBSIIRB3DKPMKyqX/8AzUI8ar/wqqkPrNd8FPqnf/NcDxqj/wAoTUij0b+KLHgq2tGZJPeplA/IcPLKjVW8zveqlWfVC0bd/iHyVS5yVG5MSOw8jwKVE7kssrdwrGnd6wWit7vZWYgduPJaO2u9lIjC1lAcxMUyqk7uEHzUG2nLGp+7v4KRv8QQUilUs3ErKF2wWet0+cbq7p35CAmkKxiKn0z+BzD4FVkTuqmRSbBPTFkdQZivlYOQMnEPjv8Aqo8Uym6wjMd0ZLjaWMH4jY/oqZkm43UuUxe+MZCI7FKHJAjKxFqpOSj4kSCEI/ghxIkEJcoZKMORIJqRK5rlf0gKySKxWymbIWsmnc5zB9rhbtn3cX+sLqXJcv7fLQ+ssNBcWYxRyuY8eT8b/No+ao1ufR34XW8JmMXum7XbJ+ODj54XCUEEFxq+q0EEEEIQV5pDWNx0Tdm19ukw7HDJC/dkrfBw/wBYVGgnNcWEOacFQzwRVMboZmhzXaEHYr1roDtVtmuaVjWPbS3MNzJRPd6wxzLT9ofl1WzL2SBeGWPdE9r2OLHtOWuacEHxC6bpjt8vdli7q4RNvEY5Oe/u5Op9oA55jpyC6CnuYI5ZvivD71+H8rXGa1HmafyE4I8idCPPB8SukfSHojNoGORocRBWxyEjoOF7d/8AEF5oXadU9udp1ZpW5WqotdXA+phwxzXNe0SD1m53G3EG7/guLLOrnsklD4zkYXc8GUdZb7e6lrIyxwcSNtQQO7PXKCCCCzl3qC659HrWMtrv8tjlk/olcHSRtP2ZmjP4tH/CFyNSLfXTWuup6ymeY6iCRskbh0cDkKaGUwyB46LHu9uZdaGWjf8AmGngeh9xXuOKrx1UuKrB6rGaU1LFqaw0dzgIDZ2AuaD7DuTm/A5CvI6gjqu3a4OAcNivkGaF8EjopBhzSQR3EbrQx1APVSGT+aoYqrzUuOpz1TsqHCumTKTHOqeOfKkxzJwKbhXEc6lRzZVNHN5qVHNyTw5NwriKTKxulqr9pxVl9d7FQ50VMD0ja92T/ekLznq0M8FY6lu7rLpe8XCM4kpKOadnm5rCQPmFEttubYtPWu1Mzw0dNHBvzPCwNyfPZIXZIUrBhpPf+yqzUFyZaLVW18u7YInSkH7RA2HxP5rn1A19LaoRKczFnHKT1e7d34krQdp9VxWyht3M11ZGx4/caeN3/KFn62T1McyVTkdr5LSib6g8VnNTVPotnrJieUZHxO36rnXZ2DV6rik6RNe/J92P1Wt7Sqr0XTbm53lkaz8z+iwmjKr0Cz6huOcOio5Gxn97GR+ICzzq4LUZowlOdms/p8moLt/+sbhJPnyLnEfg4LbxzfWc+QWL7N4hS6aa1owC/b4NA/RaiF2ZHeQChk9oqw3UKxrnE2uscTs4NYD88/gqi1aJqLjeKqz18bqaCMB9ycH4LYCMtYHN6ybjI5NDiCDw51D6D/omjB3NQ+SQ/DhaPyK2Dq6h0toS56qvjZIbPbYvSJ3MZxPqnMaGMa0ciTwsbuQCcZIySLEDjy4buVRqMNdkrBdsnadSdjejGXOOlhnv9az0ax2gANaAAG8RaMYYwFpIHPLWjHFkcErrTc7JcKqkvVxdd7w2VxrK97eE1EpOXPA6DfYdAAOi57ftf3Ptr7VY7veGhrq6pihipmuLmUtOH+pE07ZDQSScDLnOdgFxXQrjfW6ku9yuDTlstXNw/wAIeQ38AFVuDC2MDxXovATgbhJnfkP1amEEEFgL3ZBBBBCFBuNQ5n1Y5EZPmsnOw3G+UtJuWyTMY7+HOXfhlbSajjnfxPBzjGxUaCx0dNWCqZGRMM4cXHbIwfwW1FWxxxhpB0XkFy4SuFbXS1DHNDXEkZJ/QrIXis9OutVMD6rpDw+7kPwTdk09V6y1PbLHQAOq62ZsEeRkNzzccdGgFx8A0rYt07bmjAph8XOP6qz0y86PvMd2s+KK4xtc1lQ0BzmhwwccWQDgkZ57nxUv8QiHQqh/oJcM5MjPi7/8VzXXNptlh11qaisz5JbVQVZoKaSV3E6TugGPeT14pBIdtt9tsLO0trq7jLJHTQSTuB9YsbkD3nourQ6YtcHDw0bDwku9cl2TnOTknPxVmyNsTAxjQxgGA1owAlddGtGI2/FWqbgCV7s1c4A/3Rk/E4x8CuYUPZlcqymlbVzRUXey8TgPXdweG22dvFazT2grbYHsmDXVVU0bSzfZ/hHIfifNaU80SzJa2aYYJwPBd5b+F7XbnCSOPmcOrtT59wPkEoIDqgOSA6qkupRohyRnkgEIQSZJGxMc97gxjQXOc44AA6kpM9RFSwvmmkZDEwcTpJHBrWjxJPJcO7Ze0Vl80lSstM720NXVywukGW9+yMMz58Jc/wCPCrMED53Ybt3rAvF5p7NB2sxy4+y3qT+nefusR2sa9/261EHQZbbqMOipwT7e/rSeXFgfABZZzhHQ07B9oukPz4f/AA/ioDU6DkNHgF1zGNjaGN2C+aaurlrqh9TOcuccn9+Gyu9L/wDrmF33GSP+THH9EkHdK0uP+kJD92mnP/2JwTed04qmngcJbSmQUoOSJwCfaU285yUQdhFnbCaSlSZOY9yksOGN36KO7cJ0H1Qm5QnAdiU247hAnAwiJymp6k0h4Y5XeAyogGFIY7hppPM4TCMoT7P6pqJ/JLjH1TU1UO4GEp6FX1D8ukd0aMKiq5hFHJIeTQSrardwQAfaduVl9S1fo1uf4u3x4gf54SAZOEp0GVc6HHeUclQXDinlbEN+YBwfzPyW9jcHPdgg8lzHTNCaYW6mPtRxmZ/vP+blqITnjPi44Wqa7ADeXbxWAbZzHPPv4f3V7cHd7PDF0JyR8f8AzUxjdsrERZqLu48wwYH5fmVcYDW48Ehr+nL8/wCyaLV/v/L+6tKkekXCCHmyEd8737ho/wCY/wB1SzzWSocubJUHOZ3cXP7PJv4b/EqQXnxKPTh/T80gtZ/r+X91oZN8N+KJoxlZoyPzs8j4pYlc1uTI4AczlL6cP6Un8LP9fyWopqWatqYaanZ3k8zgxjfM9T5Abk9ACrWvmhEsdNTP46SkaY43/wC8dnLn/wB52fhhU3DJpW05eXtvdxiwGk4NHTHnnwfIPiG+GVVQVUwwGyvxyHrJor2ndql/hbmjR2q07Mk5Kh3J/qtZ47lRWVtRGwDvM+8AqtqrzM+dxIY8DYZClbWxnfKhdbZhsQVcUgEcb5SNhyVnRxGGna0+0fWd7yqSnuRMkUDohwj134PyCtG3SM82uCl9KhP5lAaGob+VSXnAKpbtJ3dJI0e093D/AK+SsDcoC05cW4Gdws1ebzSNDnunaGRsdK7O2wClZLG46OChdTytGrD8FVfs0z0VVcnAmOOsgoY/BznB0jj72mNo/vK/pI+FoCstTW6LT3Z32a0L3tbWXeOp1DUNO3E2Z7WwPHlwRfio9EwENIOR5KwXhw0Kr9mWnUd3zUljNgotbQ1F3uNst1LE6aaebj7to3IaM4PvJC0mndLV+pKruqOLLGkd5M7ZjPef0XXdHaBo9Kl1SSKm5PZ3bqgtxwtznhb4DPPxwPAAU5KhsXmuktljnuTgccsfV36d5+Si6A7OafSDH1U5bU3SYYdLjaMfdb+p6rW1tZFb6SapnfwQxNL3O8AE6SGgkkADckrjHaLrht/mNNROJt9PncHAnk6H3Dp7z5LNjY+qkyfevSqyppuH6INiAH9I7z3n6kqg1RqKbVt+nrXgxwR/VQRZzwtHP4k80VFGI4+I9VCpqfgDI+ZA9Y+J6/irONvG5rR7I/Nb7QGgNGy8WllkqJHSynLjqUvhPdfvOP4LqegdQi6W8Ucrs1VMMAuO72cgfhyPw8VzN7cDb3BQqe71VJqOkFDMYnUuJpnt5Ozs2M+Ttyfh4qCaITMx1Wvabk611IlGrTo4eH6jdehPJYDtI7Pm3uA3GhHd1UR72aJo/rwN/wDFkA+eFr7BeoL/AGyKsp3Za71XD7rhzCsVhMe+F+RuF7JU01Pdabkfq1wyD9CF5nbCQGUuPrqpxMmObWD2vww33uyuqMpKnRfZyBQtDdV6wlba7aNw6GF2zpMjdrQ0lxcNhmM9Ff0nZbRXfW7K5o4YpwDUR56NJJDR+8Tv81O0OW9pHadctYAB1isbXWmyBo9V78Ynnb5HPC1w2c042LV0MLxM0PC8SrqSS2yugk36eI710jTem6bTtktdgoM+i0UDYGvIAc7hGC52PtE5cfMlbiKFscbWNGGtAaB5Kvs9HhxmcNzsFcNbupXnJWTtojhj6KZEzCajbjCfYNlEUJ1g2S0TeSNMT0Y5FGNwizvlBvNKhKRt5okbUJpRgcwsd2k6hNntApIX8NTVZbkHBawcz+Q+fgtZUVDKeGSaVwZFG0ve48gAMkrhOob1NqS8SVLg48R4Io+Za3Ozdvf+Kq1MnZswNyus4bt3ptV2rx6kep8T0H3P91P0Jp0X+8DvWh1JTgPlDhs7wb8d/kV2dU2j9PN05Z2QOA9Iee8mIOfWxyB8ArojbKkp4uzZruVTv1y/iNWS0+o3Rv3PvPywm8KPUR8bTspLk24Z8wrK5klZS60fA8kDZcr7bOz1+vNHv9EYP23bnGqoHgesXAetH7nAYxyyGk7Bdur6bvWHbdZupgMTzsnbHIT2uXm76PXaNT0dS+03IcVhvWKepgf7NPORwh+OjXHDXH+E9FB7QNES6M1HW2t4caZruKmlP2ozu0+8cj5hRu2bRTtDa2NxpG93aL69zmuaPVhqsesw45B/tDxPEByK6FdbvD2gdmlBqdzXSVFoDbff6Ues9rM/V1bQN8jPE7GeIOf9xKTh2RsfqrBAe3B3H0XGI3EtcDs5uxChVEXdy5A9R34FXt+tUllryH4ex27XsOWvaeTgeuQq6djXNIO7Hbg+CmByqhGFUseYagjoT/5K7s93GmL/AEl0c4to3juKvw7txGHf3Tg+4HxVFXyMicHOe0Eeqckb+BT0VfTVVE6J7w8YLXNAzkJrntbuU9kUjvYaSuv640kNTWjghLGXGnPe0srjsHY3aT91w2PwPQLlFLN6XTkSMdFK0mOWJ4w5jgcOaR0IIK33ZPqwXmz1Fqme419pLYnF53khP9W/5AtPmzJ5qp7UrFLbZXakoWDufZuUYbyA2bOP4dg793B+yc1fSom+qSr5t88gEgbjvWFqIC0uaeYXT+xOia2nulUR67nsiBxyABJ/MfILk9fLPNuJCD0xtldu7G6N1LoiGR7cGomklyTud+HJ/wAKyrjcWsgPK3ddxwXYX1V1aXOxytJ2z4eHes7253ZkM1qozI1hDXzHJ3PID8iue0d8p5QGvlaHdD4qX221prde1UeSW00UcI3/AHeI4+LysIBghOpKx7YG6DbPxWfxFRRy3Wc8xOHcv/Lp9lvvT4f94PkV2XQNjFqskU8jAKmpHeOJG4afZb8t/eVxfsvsztV6ihp52F9NTjv5yRsWg7N+JwPdnwXdNa6hbpjT1TW5Hfkd3A09ZDy+W59wKz7hc5XObTxgZP7C7Xg/humZDNeKtxDGAgbdNXHb3D3hYjtA1XDWXN1vZN9TSuw8A5Bk69Om4+awFcIonvnpyHE7viAID/MeB/NV3fukcXOJc5xySTkkqTHJxDzWvFUuhYGNA0XnVfELhUPqJScuPhoOg26BNUmoo6Ivkp8zQvHBLA9uQ4dWub/ohJq6qKSndV22N0tON5adzvrIP/tm+aZuFr9IcZoHCKpx7WPVf5OH68wqqColpawFvFSVjN+HxHl94Kf0uV3VZnoEDNxlSG3mWRoLC0DxAynWXKabAfKQ7pjZNTU0VxJmp2tpazm+L+zk8x4f696gh543RvaY5W82O5/5hQulkduVKIImey0L0p2WslGjKSWYhz5nPeXAYJ9YgE+JwFzDtSrPSda1oY71YRHH6v8ACCfxJHwXZtH0Rt+lbTAfbZSx8W+fWLQT+JK4JqK4C8ahuRlHdzGok7p56t4jhp9wwMrl7eTLVyy+fzK9v4vAouH6Gixr6uf+FuvzKrIpMOLXbtcMEFSqCZ3dGJzsviPDnxHQ/L8cqActJDhhw5hLZL3NRHJ9l31b/wBD89viukyV4ngK2Lj4lJLieqRxIi5GSjAUStJZM1wJw8YPvCKCcjbJTlY3vIHYHrN9YfBQY5MEEHZO5kYCshKfEpQkPiVFD9spYcncxSEBOiYw1LXZOHbH3q7o6gh2M7FZ2oHFCSPab6wVhb6nvImPB5hAKAAtDk+JUEyESYydipbHccbT5Ktq3d3U+/dOJKbgK7oJsuIJ2cMKJSPIpnxk+ySkUU2HtKAPBPO3xdlJkowEp7iWc+RU+sef9kYhn/2sn/hCrTuHBTKx2dLRjwqT/wAqMlNwFDtch7wjJ3aVPd+Cp7Y/FQ33FWwOQEo2TSFTVR4amQct0qI4wkXP1a1/ng/gjiOyflCnwHJC0Vtds1ZqnO4WhtztmpqFr7Wctalaik4KeFvi7KatJyGprU0v1kDfBpKcdkIW2XdqvqaTYLL2+TBar2mm9bCQJjleRv2T8EudvBQYH5AQjm4KhzVKokeqqf0q1CVoy+ndx/3Tsf5/BY5rt10BpEsbmPAcxwwQeoWDrqV1BVywO34DsT1b0PyTgUhXvxBBBY600ERCNBCElBAjCCEIIIIJChBRLta6e9W2ooatneU87Cx7eRx4jzHNS0E0gEYKex7o3B7DgjUHuK8va20LX6MuUkcsbpKFzj3FUBlr27c8ciM4IPw2WaXsGppYa2B8FREyeF4w+OVoc1w8CDzWNuHY3peudxNo5KRx3Jp5nDPwOQPgOq56a1u5sxHTuK9wtX4hRdkI7lGecfmbgg+JGRg+WfcvOCC7Xf8AsEpXU8klnrpmTtblsFThzXnw4hjGdvH+XIbvZ62w18lHX07qapj9pjsH4gjYjzCypqaWD2wvRbXfrfeAfRJMuG4Oh+HUeIyFCQQQVZdAgggghCCCCCEIIIIIQgggghC3HZr2mVOiKr0eYGotEz8yxD2ozy42efLI646c16QtV3o71Rsq6Cpjqqd/KSJ2R7j4HyO4XjdSaO51lvJNLVz0xJye5kLPyK06audAORwyF55xBwdT3mT0mF3ZydTjId5jTXx+K9nslI6qTFPheOW631ExnA2/XMN2wBVybY+KYl1ReZw4SXevkDjk8VS85/FX/wCKM/pK4lv4b1OfWqW/A/qvbMVQnTdqaAuEtRFEWjLuN4GPfleFJa2onDhJPLIHHJD3k596YTDde5nz/srbPw0/rq/gz/8AiXvGLWFl70Rfteg7z7npLM+PLKvKOuiq4xJDKyZh5OjcHD5hfPJWVh1Hc9MVzay1Vs1FUNOeKJ2x2I3HI7E8/FDbrr6zNPNLN+Gw5CYKn1vFunxB0+BXuvXEjZNMywHf0mopqbHiHzsY4fJxVjUyF8riTk53XCdBdtr+0OO3We7RxQXiO4U0jHQtIZOxrwScHOHAgZGd87cjjuL3gOe48hklbcMrJgHsOi8muNuqbTOaSqbhw+BHeD1H73XM9bVXpeurfT820lPLJ7nHgH5PVfO/ico9RUmt1nWTuOT6Pke5z/8A9AJw8/eqrzklSMGGgeC5z2w1PBSUMIPMukPwAA/MrGMd6J2Y1juRq6wQ+8eqT+RV92zVB/aVJGD7MPL3uP8AJZ69kR9n+noBznrXy+/hDlXHtK9tGFotIR9zp2hH3+M/8RV9St2kf0yAqCwO4bHa2/uyf8y3mnaWgobVNeb0/u7Lb43VdUR9sA4bGPEuOGgdVXc0vdgdVKHiNvMeiuL5drTonTlNf9Q8QoYoxDR0DDwzXCbGSG+DATu7oOWcjPJdLdrdz7X6vtH0zdJQ/wD2k05U09pt7H8MFPUU8cskDI2cm7OeXO3J7tmc4GOV9p3aRde0PUNRdrpJiWUcFPStP1dHAD6sbB+Z6nJVBojVUuidYWW/QtdI+3VcdSY2nHeNa4FzM9A5uWnyJWhEBEQAs6RrpQS7f6LE9nxdBeBVg5FHTy1BdnbIYeH/AIi0fFdF7PrdV1Firaw/9XZKAB1Jx6x/5VQWzSL6N90tFt4ntq60U9PPIC3ipWkvbLjnhw4He4Lv+mNJ09Lb7fR8BjtEQyXYyZmtPrYHi55A88uxyUdU0SN5O9bdnrZLbUsqmfl38R1HwXO0Fd6psLrNXvLYu6gkJc2Li4jECdmk9cDG6pFyz2GN3K5fTFFWQ18Daindlp/eD4hBBBBMV1BBBBCcEEaJBCEEYRI0JUSCCMc0ISkQ5I0Q5ITUajXO50tmoJ62tnZTUkDeOSWQ4DR/rp1UHUmqbfpahdUV0waSPq4WnL5D4AfryXlTtK7Tbnr25vEzzTW2J5EFGx3qt35u+87bmeXTCvU1I+oOdm964++8SU1mYWD1pTs37u7h8z8xcdqfa5Va6q5KKjc+msUbvUi5OnI5Pf8Ao3pt1VZq3+jaY0bRdRQSVRHnLPIQf8LW/gsVGQAStp2ij0e90NF/9RW2kgI8D3LXH8XFdSyNsTQxg0Xz3V1s9wmfUVLsuPy8B3ALMtTrdyEynoBxzRt8XAJ6pBX+lW5qa4/do5T+GP1UUc1L0ts+6nwo3/8AM1Q00pxTgOEYOUkbhG1IUqWCjSUpNQhzCWkJTeSYnpXEg3mkt5JTU1CX/ZAeJSOFL8EWN0JykNGGBRK454WeJ3UsdFAqXZkc7wGE7KUBVdc/ilPgNgsheM3G9U1GD6geA73AcR/RamulZS081RKcMjaXFZqxQumutRPL7cUILwej3niPyG3wUjNMlNk2wtFaGYmrag8mgRt+AyfxwrKJ3dUwJ6NyVEpGd1ZgeTpXkn4n+QT1c8R0zh05fDr+CaUwI7HEXOmlPMnH6/qp1WOKPux/aeqfd1/BC1QGKgjyPWd6x+KN3ryuPRvqj9f0+Sad0oSeQ8kl26WQkkYCEqbIWksNvp7RbmahusTZoi4tttBJ/wC2Sjm9w/3TDz+8dvHLFisdM+kN6vIe2yscWRU7HcMtwkGfq4z0YD7b+nIb8o17vFVqC4vq6osEhaI44Ym8MVPGPZjjb9loHIKMnontHUqHX189wq5aipldPVTvL5JHc3EqVRRdfBVsA72UuG7RsPPzV/BF3UTR1SJ+6ZqH93G53gFV07BJMCeQ9Yqdcn+q1g67pFDT8ecjnufcl2CCMlSaWItaXu9t+593RP4wMpbW5RSbbJuU7Ci1T+Cnkd5LF19sqdRzwWqiBNZda2ntVPjfMszw0D81ptQVbaSiJccDdx9wXRvo+6Ip5+2vs5p7me6ZbKWs1bcy4f1LWM4YHHw4X8DvLdSNOBzfvRMLebIHh8zhZ76UVTSzdvtVY7f/AOrdL0FNY6Ro5NZHGHFv918j2/3VmaOMt5HHuVHNe59aa2vWo6kEVF2r56+Rp+y6SRzyPhnHwWlhZwsTHHlAHcFK0c7ie8r0b2W0UVHoi3mPd0wdLI77ziSPwAA+C1i4V2e9qZ0xA22XGKSoosuMT4t3xeIwTgtzv4jJ5qw1121QVltlttmgmbJUsLJKmYBvdtOx4QCd8deixTFUOlw0nXxXtlHfLPDbWF/LzMaBy41yB006nr8VM7Xe0htLEbHaZ2yTygiqlZhzWsO3BnxPXwHvXK4q6eSeOIcJawd47br0H+vBV1JFxOLzybsrOkgLKbvDs+c59zen4fmuhhc+BnK1xXjV0qG3apNRJGB3AbAfvdTqavm5gNJcdtuitKeulGBwsx7j/NV0EOMKa0cDPepfSZf6lkCjg/oCbu+of2ZRy1L2NcGjDWNG73HYNHmTgKqiuE9st/1wj9MnzLUPycAnmB5AbDyCYkkF3u7pTvQ29xDf+0mxufc0bDzJ8FHliddpy6T/AKq05I/3hHT+Efin+kyj8yPQ4DqGBbvse1lU0t+7io4WW64Fscbcbh+/C8/xE492Cu852XlaprKq1xU0lBTvrLxUzNp7bSR+3NOdm/AcydgB1Xqj0eppmxx1bY21IYO8ELi5nFjfhJAJGeRwFh18s4IlDjqvYeCzSSxvoZWgubqPI7/A/VR7hSGvt1XSiaSn9IhfD30Li17OJpaSCOR3W/7MdOWug0zb7TamPhpKCNsIiJ3B5uJwNy52XE9SSViCr7Q12/ZOpaR7ncMMru5kzywf5HBVekuM8T+Uu0K3eJOF6K4Urpo4wJWAkeIGpHv6dx967PTWaKONrQXgAeI/knm2mL7z/mP5KW0JxoXSGol/qXz16LB/QFHZaYhj1n/MfyTzLVD95/zH8k80pxjknby/1JPRYP6Qm22qH7z/AJj+SV+yYfvP+Y/kn2uTgOEnbS/1I9Fg/pCii0Qke0/5j+SMWmEt9qT5j+SlhyMOKO3l/qKPRYP6Qov7Ih+9J8x/JH+yIvvSfMfyUoFRLxd4LJa6muqHhkMLOIk9TyA+JIHxQaiUDJcnR0UUrxGyPJJwB3krmnbBe47ZDHZqWRxmnaJJyfsszsMjqSPl71SdkujzfLqblUNcKKkd6pGMOl5gfDIPyWUuFXWau1DLPwOlq6yX1Y25OM7Bo8gMD3Beh9MWOLTVipLfHhxib67x9t53cfn+GFjQ1E1VOZC48o/YXrl2pKThuzMoY2DtpNz5+0f/AIj49FJNphH2n/MfyRG1Q43Lz8VLMiSXBbnpEv8AUvHvRoP6AoptUI6u+aQ+1Q77v+allySXJO2l/qKj9Fh/oCgSWmAjHrfNUd1scIy4NJ+K1DiolSwSMIKXtpT+YpzaeFv5AuP9oehKDW+l7jY63iijqWYjnZu6CUbskb5tODzGRkciV5W7Ldd3Psf7Qamm1HTNqo6Zzrbf7cW8cdVTObjvGNOzgWkPbnGRluwcV7bvNHwF2y85fSL7NXXikj1VaoDJeLXGW1MMYyaukzlzcdXs3c3x9Yb5CYJXn1S4q9EyJuzR8FntZaTh0lfzpIVRr7BX05umkrm6Qv8ASaJw4jBxnm+LI65LC12GjZcuraOW31DoJckAnBcuh9lt8oO0nSsfZdebgygknmNfozUD/wD2CvJLu4J3zHISfVI3LiBlxj4aC7RVN1hq4rlQutmobZKaW6W9/tQTN5keLXc2uBILSN0nO7OHFTujaB6o/fcsTXQd80xkYJGWu8/BVtFKYpsHbi2Pkr+og42cJ2I5FUFdGWVHFjHFzHmOamGqqnQ5Vhb9QP0ZqShvwz6PEe4rmt34qdxHEfMtIDh/D5r0Vxxzxhw4JoZG+TmvaR8iCF5tdwVlJwvAeHDhcD1XRuxHVRq7dPpitkzXWtodTOcd5aXOG/Fh9U+XD5pjhkZUzHYdjoVndV6W/wBkbr6HGCbbOC+he7fhaPaiJ8WZGM82kcyHY7xpKkFDpi1QYwW00fED94tBP4kqj1Jp2DVFolt87u6c7D4ZwMmGUey8fkR1BI5ErTV8zbZaqmVmI2wQOc3O4Aa04/JYdydzBjB1XqvAcIikqqg7NAH1J+i8xa0qP2lqu7VOctfVScO2PVDiB+ACoXR8JVrPGXEknJO5JWq7KNKf7RapjmmZxUdDieXI2c7PqN+JGfMNK2XObBFzHYBeYwQS3evEUftSO+pyT7tyuqdlGk26Y0xE+RgbW1gE0zuuPst5kbAnl4rnfa1q5l61M61wvzBb8s2Oz5T7fxGA33g+K6l2iaobpXTNTUNcBVSjuoG534j15g7c9uS8xS8Ur3Pe9xeTxcZOXcXisi3sMsjql/u/fyXpXGFZFbKKGxUmgABd5DbPiT6x/urhj+E+SkMdsCCqujrO++rkwJh8neY/kpjJCw+I8F0a8gVgx/FseaaraCGvi4JmZxu1wOHNPiD0RRuyMg5Cfa7PNCYdVnqmlqra7L81EA3EzB67f4gPzHyCl0UUGoZ6Sne7D5JGtZLHu7c42P8AoK4U7RWnIKzXFpljBikbOJ3cBADyz1vWB5+zzGD5pHycjHOPQKajpvSKmKFv5nAfEgLv9xrGWu11VUeFsdNC+U52aA1pPy2XlOKo736uck53EhXpDtKrYqDQt5lldwRGHunE8sPIZg+XrYXmSWjfSt46b+kU5H9VnJA/dPX3FYtnbhj395+n/lem/iRPmqp4P6Wk/wDMcf8AxVwHue0Nl3kbs2T7w8/NJLRKx0buThgqvobi3gwXcUQOMnmw+BH+sKxIwQRuPELoF4+pVDUOnpwX/wBY08D/AHjr8efxTxOyrYZPR65u/qTjhPk4DI+Yz8grBCEM4VW9ndSuZ907e5WTlBrm4cyT+6f0/wBeaEI435anA9RY34OE6XYKehSA7KK1zGN8kPVpyPcmg/ZRzN6PXxydHeqUJoW3oJO8hxzwoV29WRjvEYQs8/rlh8Eq9DEYPmn7hKUmkmyFMkd9eXfeAKp6aXhIVkH8QB8Nk0Jqca7JcpVU/Om8eFRn/hUNh3Keq340+4f9uPyTkKuoZMTsKvI3ZaFm6aXEzd+qv4nZYENTFW3r1axp8WhIgOWpd+2lhPi3Capj9UT4EBOyhT4DuFoLe7Aas7TnGFf0B2CELYWj2R7lA1FNxXEt+6AFNs7sgFUNzqO/uMzueXIOyaptA7dquI5OF4VFQOzwq1e/hIKAmlaKkfloKaq393VtPiEzb5sgbpV02Eb/AIKboo1bU8vE0FVeqqLvYGVbB60Xqv8ANv8AkfzT9BNlg3Vg5rZonRvAcx4IIPUITSvYyCVgIFqyVpJKCVwoiMIQiRcKNBCElBK5ouFCESCCCbhCCCCCEIKl1TpK3aut7qWuiBP9nOwASRnxaf05K6QTXNDxyuGQrMFRJTSNmhcWuGoI3XmjWXZldtJTSydy+strTltXE3IA/fA3b7zt5rIL2MsXqHsk09f3SSindQVL8/W0p4QTnOS3l+A5+7GBPbNcwn3FezWj8QByiK6M1/qb92/p8AvNqC6leOwS6U73ut1dT1cWdmzZjfjb3g9eo5fBZK49m+pbXxmaz1D2t5ugAlGPH1crJfSzR+00r0ml4gtVaB2NQ3J6E4PwOCs0glzQyU8hjljdFIObXjBHwSFWXQAgjIQQQQQhBBBBCEEEEEIQQQQQhBBBBCEEEEEIUm23Ge0XGlrqV/d1NNK2aN46Oacg/ML25DqaC9aUbdqRx7mppu9jB5jibjB8xyXhper9GSOg7KLHE8Fjn07AA4Y2OXA/EHK3LW8hz29MLx/8RaeN0FPUfmDiPcRn6j5lVVG7ivdxeebYomf8x/VTSfWVVbpuO83X3xgfAYVkDl4WiV5FjC4p2x1X/wA5uH7kTB+aqdR1HDbdD0vV0VTKR8P8072vSl2rqoc8MYPwVVepO/1PpemHKns7pMebsBRjqVaPstC21iJ/ZdsA8JB/xFTO3e6mz9mmntPxP4ZbjMaycA7ljfZBHgS8H3sTGjIhXmzUrfadI+M+WXLE/SEvwuWvqyCN31FsgZRR45AgZd8nOcPgmxjdybJqWt965LUy99K93TO3uTLhgY8UvGd1a6R07U6s1RbbVSx97LUzNjDTyOT1PQefRTnQJAMleodB2dutezfSFdqR3olo0nQzsqKnPrVLXPBjizzAYxrBtv6wAwXLT2m1yVZnvdwpxSfVgwUQbhtJC0HgZgfaAJ+JdjnteV9qgBtukqLDrRZAySrc0YFRU+01p8gTxkb7lo6JGqqssjgs1Hh9RI4PmI6eA/X4BQveScHoo2NHTQH5D+65pJYJdSXV9DG0Oqan16qQjIgZ0HmfLzXK9Q09up71XxWeofW22GUxR1LwMPIA4sEe0AcgO5HGV1btV1DFo6x/7OWyTFzuDeOtqG+22M7Y8i7cAdBnxBXFKwiihZC31XBuA0fZH81XlhbKMHddbZbzUWiQvj1Yd29D4+B8UtBVzbi6PmOMfipVvq23GV8cbSCwZJdy+aynUkrToMr2Cl4ptdS0F0nIe52nz2+afQVVT6nt9TIGMldknhGWHdT6SshrjVCB/eeixOnmOCBGxvNxz0CiMMo3afgthl3t0nsVDD/xD9U8gq1uprSedypm7Z9eUN/NGdS2gAn9q0WBzPpDP5pnZv7irQrqUjIlb/zD9VYo1UyasssTOJ12oiP3Z2uPyBVRcO0+y0duhrYXy1kMz3xxmKMjiLCA72sbAnn5KRsEr9GtKrT3e30wzLO0e8Z+G61wagOa47c+2q4yvLaGip6aPGMykyP9+dh+BWUu3aVqOubwuuksQ8KcCP8AFoBV5ltmd7WAuSqeOLZFkRBz/IYHzIPyXoG5Xqgs8YdXVsFIHez30gaXeQB5nyC5jrHtuZA91LYGCV2PWq52EAfwtPP3n5LidTUSVd8pHyyOkkMrnOe85JPCdyVIqH/0mbydj8AtOG2xxnLzzfRcJcuOK2raY6VoiB65y746AfDPipdddKq61klTWVElTO7nJK4uOPD3eS55K/Mrz5lbUP2efJYVzvXd71qAADAXnbnOe4ucckqVSxmeaOIbmRwaB5krV9pFSJu0C+4ORHUdyPcwBn/hVJpCn9M1VZIcZD62BpHkZGp3U1V6Xq2+zA5ElfO4HyMjkHdJ0UUHCkUn/WYv4gooOVIpv65nvCanBaHT54BdvOkcP+NiiKTZeVz86U/87VGTU49EpqU3mkDmlDmmkpcJaUkpSaUYRgZSkQGAlAZTCnIgMpQGEaMBIlCDUpoRAJQGEJ2EvOMlV03rfE5U95xGfcobm+t7ggKQBQ47CdTXijtWcU+9VVnwhZ0/vO4R8/BZqxO9Kp7tX8vSKl+Pd0/5iuoWSmFl7N9QalkAbLWwvEJ6iJoLYvm5znf3gubadgMWlaNpGHSPyR/fP6AJ7TzZ+CSZvIG95BP6K9fH3dNRReYPyCZrW99NBCPtu393X8lIqDmsgYOTY3H8giomd/cpZPsxDgHvO5/DCXxUCtjiKPyaFGAwMHn1T8x9UN8TkoqWknr6htPSwPqah/KOMZOPE+A8Sdgo09R3uDASTgeau7fY6ekpYrlfQ9lLI3jprcx3DNWDoSfsRfvczvw+KNkdDp57ZHmG7XVu4b7dLTn/APOuH+EfvKrr66puVXJUTyvqauY5dLIckn/XTkmE52Tw0DdSbze6q+Vwmm4A8NEcUETeGKnjHJjG/ZaPBVlWe6aIWHL37ud5KYyNtLA57jsBlx8SoMTHyy8RGZJDy8PJNCcVNtVKHPBx6jFbOHRJpoRTwhg6cz4lCdxaw+J2CRLhVs476YnpyCsaWDu4htuUzT0/HIBjYbqzEe4CUlOATXBwNUZ+5JUuY8wFBr6mOhpZqiU8McTS9x9yaNSlOgTNgsn+2OvKK3EcVFS4qavw4GnIb/edwj3By6FZdRCit/0gtYMdg0trptJULxz/AKQ4tnA324XEO+CY7MLX/sloS5ajuTSyoqIH3KpcRvHE1pLGfBu+PFxWIp6mah+i1Z/SP+v6z1TV3mR3344W90QfLvCHBS7k9wwPufon47NjR1dkn3DA+qx+lqbhIPgOi1zWYA8gqfT1Pwsc7HNXcv1cbjzPIKN5yUrBgJqmZxyveeTRwj9VCeOOaR58cBWvB6LQkn2sfiodJTcc0bDuBuU9mmqjepFNRGTuqfkXnDj5cz+Ct3sElQQBhjPVAQoYu5E1QRu0cDPf/rCejj4GAHn1TiUzCUxoChXyskggZT05xV1J4Iz9wdX/AAH44U/ibG0ucQ1rRkk+CqYmvqJ3VbhiaYcMTT9iPp8+Z+A6JQUuE1DRMip46OEEQRDDjndx9/ieZ96msggp6SorayVtLbaRneTzO5NaOg8SeQA3JOApFNSs4XccjYKeJpfLPIcNY0blxK3PZP2dO7TrhQ6hutG+LRdDL3lntUzcOukw5VUwP9mPstPtddtnKBndNc7l0G60X0fuy2rrK+LW97ozTXSriMVkt0rd7dSO5yvH2ZZBueobtnctG6qr1V6615cbTpuOKTTWlYX0tfX8Ic6suLi1xhjd4RMDi459p4bjkUvtS1rcLDJQ6L0pM1/aBqMFoqQMttdN/aVL8csDPCOrt98AHd6B0TbOzzStusFqjLaSjj4eN+75Xk5fI89XOcST7+g2SuYJWlrtirVJVyW2dlTF7QOf7eR6rnxBBIIwQrvRlllveoKSNrT3UbxJK/GzWg5/HGB710f/AGYtVzkdLVUccj3c3DLSffjCvrbR0lpg7mkp46ePmQxuMnxPifesmO2kPBc7Rel1vHUUtI5kEREjhjXGBnqOpx00CtmuCWHBQPSWjqga5jR7QW3heOqxDwlCXCqXXRg6pIusZ+2EqFdiTlulNmCoX3unhGX1DGfxOUSbW9qpvbrGOPg05TE7C1gmSxLjqsFP2nWqAF3GeEfacQAs7dPpB6XtZIqr3b6Uj7MlQ0O+WUI5SuwCUeK5H2x6rFZPFZqd2Y4Xd5OQQQXY9Vu3hk5B648FR0H0l9M6hrZKCzXFtzr2xmQRwsJaAMDiJxgDJHzWC1NqGGy22vvNylcY4gZZXc3PcTyHmSQB5lZVdKQBC3cr0vg21tdI66VOjIts7Zxqf+EfM+C6v2OWFvpM95nbtHmGnz94j1nfAbfE+C613+RscrxNL9N79nUsVLZNJzmGJoazvJeLb4BIpfpoaxuHqxaPqB/DkD8Wq/BB2MYYuOvVzddq19UdBsB3AbfqfEle2jN5pt1Rg7leNZ/pKdoU7eJmme5B6yT/AKbKmqe3ztInef6BTRNPQvcSP+JWMLD5V7i78feHzRGduN3t+a8C3Ltp7SXN4mGnYOoDnfzUaDtQ7R60DNVG0no0uP6pUdmV9AH1LGjeRvzUGouMMeSXt+a8F1faDr2mAdUXSSBp6mJ2Pmmhr3XMzONl3mlZ4x4CbkJ3ZFe4bhcIJgRkH4rKXVjGZe148Rgrx7Pr/WMXC6a7VTA44GXbJL9fanLMOu9Qfe9ITlKIyE720aEh0VfX1FNG6HTt1m4onReqKGqOSWjHstccubjkeIcsLUxX+TtjtLbngO7UrFSiOtgYMf7S29vJ4HWojHxOMcnAR8/r9T3i60NTQ188lxoqlnBNBMS5rhnI9xBAII3BAWVpZK6xVlK9lXNRVtM/vKC5MOJGuHIE/e6EdQnghw13UmS3yWmdPBVsbUUzxJTyjijcNtv09yrblTiWFxaMvbuPPH+sJpl6qKq7SVNZHHE65SPkk7lvDGKgH18D7IeMPwNs8WABgKwdzTwVGRlUUAIbxt3adnD8im56mssd0oL3bSBX0L+8jaThsrTs6N3k5pI+OVNMXcVMkf2Xeu39QkOa2WN0TuR5KVR40wvRGlr7R6ttVvu1A4upqkBwa72mOGzmO/ea4EHzCl62M40ldfRonzzGBwEce7nD7QA6nGduq452E1tbbdXVNrjPFbqqJ08kPSOZoAEjemC3DXDxDPPPbNRU1VV210VJWGhlc4fXMja94Hgzi9UO8C4OHiCudq25q42eX1Xr/DhMHDtXUdTzD/pAHzK82HgnjbJE4PjeOJrgcggr0D2daZGmNNQxPZw1c/10+RuHEbN+AwPfnxWQsnZg2PWMdwin9Is7y6pljnAEgqAd9gAOFzvWIwMEO+9gbjWmom6W07U1oI78ju4GnrIeXy3PuBTrhKZXNp2b/vCi4Mt7KGCa81ejQCG+Q9o+/Ye/vXIe2XUP7Z1F6FC8mmoR3ZAccOk+0ceXs/ArnjmqdK50j3Oc4uc45LicknxTT487hbcMYiYGDovLLlXSXKrkq5N3HPkOg9w0VdMzB6jqCOYUykuIdiOcgO5B/Q+/wKRLDxtIHMclBcNsH5FWlkk8pWhY50RyN/EeKlxStlGR8Qs3SXJ9MAx4MkY5eI9ytopmyASwv4vEfzQn5DtQrRpW37JqTv8AUskpB4YYHOzjqSB+RKwMNQJB4EcwupdjNNxC51JH3I2nPvJ/RUK53LTPP71XVcJwekXqnb3En/lBP2Vx2tVHdaXZH/vqhjTv0AcfzAXDJ7PGMupXeiuJyWtGWH3t/lhdf7ZpyyntUWNnukdn3Bo/8S5cXKO2Dlpge/K0OOZBLepGn8oaPln7rM1tM6KUOqGejy8hPGcsd5E/z+BQgr5La4MqW/0Y7CVvstP6BaKQB7SCA4HYg9VVzW7uc9yAYjzhdy+Hh7uXuWuCvOizuTk8fpEBDHAE4cx/QEbg/PCl0tSKunjlA4eIbtP2TyI+ByFSQPNsk4AT6IT7DucJ/wDtfy9ym0shpLi+Fx+qqR3kfk8D1h8Rg/4kFNVmmKiPvonM5ZHPwKcSXpAgqrjeXAEjB6jwPVSOLITFQ3uqpw+zIOIe/r+nzSmO2TgUxOg5UetbxxHHMbhOFyamfuglCu7DWh7oXE7+yVc3kZp8rF2uoMNSG5wCcj3raXA99b+IeAKe05CfuqeB+3uKsYJcscPJVULsOcFLppfW580Jis4znKVWPxY3DxmH5JqB2x9yK4vxZ8eMv6IQqiGThlbv1Wjp38Ubd+iynHh7StFRyAxR9dkNTEV+GWQO8yPySbczvKCrPVhY78SP1S7yOKjiP7xS9PM7yluzeopmvA9z2p2UJynGyvKE8lR0/shXNCeXvSoWstsojp5HHbDSVmXS8czj47q4M4htsp8RhZ9jsuJTikKu7cd2+9WtSeFgKpraclqtq04p0BNKn2ubiA3VhdDmkz4ELPWio9fCva93FQu92U9p0UZCO3S7DdXULsgLMW6bZuCr+mkyAnAppC9qII+FDhWVlaKJBHwoEYSaISeFEWpSCVCQgl4yiLUmUJJGUkhKQSoSUErAREIQiQQQSYQggggkQgggghLlRq220lyj4KulhqmbjhnjDxvz2IWYuPZNpe4je2tp3Z9qne5n4A4/BbBBRPiZJ7bQVoU1wq6P/ZpXM8iR9FyS5/R+pXhxt92miPRlTGH5+LcfksndexLUdva98Dae4MGTiCTDse5wG/kMr0OgqL7fTv2GPJdbS8cXmmwHSB4/3gPqMH5ryTX6fudrfI2rt9TTmP2u8icAPPOOXmq9exlldU9mli1Y50tRTGmrHbmqpcMe4/vbYd7yM+aoSWogZjdnzXbUP4ixPeG1sHKO9pz8iBp7z5FeY0F16u+j7OJCaK8RvYRsJ4S0jyyCc+/CgRdgN7c0mS4W9hH3XPI/5Qs40VQDjlXbM4tskjeYVIHmCPqFzBBdYZ9H6uLhx3ena3qWxOKtovopaguVO+W1Xyz1xaf6pz5In49xZ+uPAlL6DUf0IHFtjJx6SPgf0XEUF0y4/R51da5jFNFSh4OAO9I4h4jLRkKtn7FNWwn1KCOff+zqIx+ZCiNLOPyH4K6ziK0SbVTPe4D6rCoLY/8Aoh1f3nB+xnk5xkTRkfPiwtDYvo+6grqoC5SQW2mB9Z4eJXn3AbfMhDaaZxwGH4JZuIbTAwvfVMx4OBPwGSVjNE6PrNa32CgpmO7riDqiYDaKPO7j5+A6lemPSe+sNqHB3f1DAY8+yQAMfA5U7Rmirboe2eh29hy48Us8mDJK7xcfLoOnzVbXM9GlqKbpDUSEe5+JNvIcZHwXSUlN6MzXc7rwLiXiH+PVYEQxEzIb3nO5PnjTuCyFpm/6brv33OP/ABK6MmJgPJZq3yd1enk9ZHN+ZKu6mTgnBTSViObquG9rBzrCr82t/JQSO/1vxcxTWuOMeWzSp/a0wjVJf/vImn8SP0VfZQZ7zeqgnPDDGwHy4f8AJN6FS/0rovYs9sl8eZsCKla6oLj0HCcrg2qro+9XOvr3+3V1D5z73OLv1XX9HVhtej9YXEbObQ+jNP70pLf81xKvbuB8Useya/2iVWBp5cyei9MfRj0YdM2Ss13VU/e1crjb7NFINpJjlr5AfAbt58hKOeFx/sz7Nq7tB1HbrZTB0b62Ut74NyIom7yynp6rdgDjLnNGcle0KKlt9MI3UbWw6dsUHoVA1u/EQOF8mftE4DeLfi3PMlJI/GgSHbHf9P7qMDHpS0NDnGpq3Evc9+7ppnbuefjv8gqCa4QaR09XakuZ72U7RMccOmkPstHx8OQBPTewjik1JeAJSI2AccmXbRRA8s+fLPjk9FxXtg1yNW3llLQnFqo8xUrBsHnk6Q+/Ax5AdSVXb/UVJjmPL8Viqy5z3m6Vl1r5O8mkcZZH8hk8gPDwA6ALN1VUZ5XPdzJyptzqhGwUsZy1hy9w+07/ACVQ4lxAG+dlK0dVYcegTVROY4yRu4nhaPEqXNWRWnR9dNGfr5nCmDhzyRv+Gfks/XXRjZpHtdxMjyxh8T1d+gVXcaqWaGko2uJ4yZeHP2nbD8B+KtN0VVxypumomtFRWSD6uFu2erjy/wBeauPTP2P2Y3SrJxU3mrbStd17qPLnEfHIPvWZulxdb7K+GnPDhxLj95xOGj8vkpvalP8Asym0/p9p3t9C104H++k9Z2fw+aQalOJ5Que1MhmkceTc/NQat2S2Icvad+gUxxADnO2DRkqsc84Lne0/1j5DoPkrAVUpmrn7qGR/RjS75BTa9voum9M0nVlF37vfK9z/AMiFS3qQxWupcOrOH57fqr3WAEF5FKPZpKaCnA8OCJrT+IKeNlGqSR2AocxyU/M7ZRnb5PROCFV0zu8vlP8A948fJjlInfmqqv8AvCPwCgWd/eXejd494/8AA/zUqXPHUP8AvTPx8DhKmpYd6knuWHJy4rZsOWvHiFine0UoQtj2VQ+kdomm2H/6uiPycD+iz5n9JqaiXmXyud83FaTshfw9o9gd92o4vk0n9FkqA5hBPiU3qUKwZyUmm/rW+9RmclKpvbHvTVIFf2Tf9oDxpXfm1RVKsm0lWPGnk/LKipqd0QSx0SE4BumJyUOaWBlJaEsDCQowjSgMImpYCYUuEAEoDKMDCUBlNKVEAlYCMDKPGN01SBNyclArKWW4yUtspyRU3GdlIwtG7eL2nfBvEfgrEt4gtX2I6dOpNe1t0cM0dmi9HidjY1Egy4g+LWYH99LnlBd3KRredwZ3pv6QssGmOzijtFO0RMneyFsbfsxxjO3u4Wj4rm1DSGnt1uiIwWBmfeButB9Ju8ftftCpbLE7MVE1kJA6SSEF3/DwfioU8YYIQOh/ROjHKweOqbUO5pnY6YChSytjqamV/swxjJ8tyVKtURgpmmQYkfmR/vO5Hw5fBV8ze/qGwdJpS9/8DMfrgfEq0EjmH1Tv4+CeTgKsNVY09LASJq+d1PB9mKIcU0g8hyaPN3wBS6q+PfTOpKOFtvoXe1DEcuk85Hnd/wCXgAqrmSSSSdyT1TjGF3uUROVMBhF9kqXTUxaOIj1j+COlpu8dxEeqFJnd3Me3tnYfzTCngKvrnh8gjB+rj3J8Xf5KRbKbH1zhudm+7xTNPS+kTcGPUG7irpkYAG2B4JEAdUkjAUdx7xxPQbBOVD9wwczzS6WDvXgfZCCU/Cfo4OFnERuVIxwNJTrWbck1OdsJqeAopGSSodJZjrDVdusIHFTZ9Mrh/wBiwjDT/E7A92VLqZmUtPJNI4MjjaXOceQAXUPo6aHklt0l9rouCpu7xU8LubKcbQs+IJd/f8koPKOZAbzuDfj5Kl+lDdBovsQlpWEsrb3OylbgesI/af8AAhuP76yXbXQf7Oy6E0YOemtOU0FQ3wqpMvmOPPLD8Vfdtsbe076SWiNIxkSW+11LHVLfsnGJpgf7jGN95KwvaFqI607RdR3sPMsdXWv7l56xN9SP/ga1Sj1WAe9NeeeVzvIfcpNnpxHSt81MMZlqGMHJu5S6OIR07B0AUmghy10hG7zn4KFTKNcBnu4wNvaP6f68k7b6XgY6QjdyVwd/KX9Dy9ytaSABzQcBrfWKkCidqUmSLgEMH3Rxv96JzU6MvLpDzec/DokSksAAGXuOGt8/5BGUYUSob37xD/Zt9aXz8G/qfL3o/VYHyPcGDGS5xwGt8ynJe7o4CXu2G7nO6nqVoOzDsun7UqmO6XWN8Wkon5hpjkG5OB5u/wCyB/xe7m8a7pjjhL7M+zWXtVngrrjDJFoqGQPjgcC193kB2J8IQf8AF7uXobXuubd2QaTFyqIWVNylHcW63R4aZpANmNA5MbsSeg8yApl8vtn7MdMS3q7FsNLTtEcFPEAHSO5Mjjb4nkB09wXK9C2C6dqOrjrTVUfI/wBDoc5jp2A5axvu5k9SnjLj4KNunrFa/sM0DXWmKv1dqZ/pesb+RNVTvG8Me3DC3waABt5AdAuuxPGQstdNV0VjaWzSB8wG0MZ3HvPRc21P25RUpfHDKXHl3VMM/ipi4NGqjw6Q5XdZrvBRt+snZH7zuq2p1pSwA8Ly7zK8oXnthvc/GYGRUTTsHTEySH4cvmsXc9aXm5cQqbpVzE/YY/gb8mqEzDopBAeq9iXPtXoLa0uqa2np2jrLKAsVevpOaatmR+021D+jKZheT8RsvJFVK2R7nOxK7q55LgPIZ5lRRSmU5IDR7tz703tUvZAL0PdvpgU+XNt1nrql3R8xDB+ZWTuP0q9U1eRTWxkIPLMv+S5RO2mt9MZ6mRsUTeruvkB1KgAVt4ZxsBtdAf7R4+ukHkPshKHE69EhDRoNSt1dPpB6unkLHS0rJHcmRhz3fmqOs7RdaXMZlvT6Rh5iEBpHxHJUzIqW2QnuWcAPOR+7nn9VCqK8NHFKeBnRp5lPBJ2Ca7DdyplTUVVxz6Zc6+4OPPvahxChC10cJ4pu7jb++7J/FNsFXX47sejw/edz+A/mt/2S9nMGqtRNdUcU9JR8M075RxB++zB/Fg/AFI94iaXuOgU1JTS19Qymgblzjgfvw3XXuxjQ8WltPCufEGVlwayQ7YLY8Za3HQ75I93gsp2062767NssMbJ6elw+bids6Q74xyOBj4k+C6br3VkWjNM1Nwecy7RQMBAL5HcgMg8hk+5pXlGvuc9dUy1FTUBskrzI+R59Zzickn4rIo2OnlNQ/wDf/hepcT1UVpoI7LSncet5ePi46n+6u2alroiO6dDTNHSOMfqnDq26cX/reVg8GcI/RZyjuNvppWuJdUOB6gOW4sepvTg2Kh0nPcJOQ7ql48/ILbXkeD0VLLqivm2dd6l/j9aosl5nIy6vld75CuyWPs/1xqDhdT6Ft1uhd/bXDhbj+6PW/BdFsn0fb1UNb+07pbaHxjoKPvPxcR+SbzI0G5XlIXIHc1jvjIUr9rM6179uWJF7Ztv0erDTEOq6isr3dWuLY2H4NA/Naag7I9L257XwWGhDxyfJEHu+ZyUmUnMF4cs2pr697Y7dV11wPSGON1Rn+7grWWvSvaHei6Wk0hWjiO5nhbRhx8u8LfwC9vQWqOnjDImNjYNsNbhLNuyOaacdycHFeNoexvtIubS2ottptzfu11aX4/8ArTXID6P+v3PaH3LT8DephZNIfxwvYjrSDzAPwTbrQzHshGQOiUa7rylTfR91E9/9L1FTRM//AAe3nP8AxPP5KuvPYdcRbrhRxXOW5XKmBlfSzU7A2qgOeB0eBkEYIIyTxN6ZC9azWlvhhZ7UWm6ipZDW24sZdqIl9MXnDJQfahefuPAAJ3wQ12CWhAOqlaB1XhDTulbvfr9LpymuIbcqgGShpqwtaysezcxNedo5QBkZ2cW8xsDfwiRwkimifDUwPMU0MrS18b2nDmuadwQQQQeS7Z2tdkdF2g2huqdNd7bbm13eyRMPdzQVEbtyOE5ZKx4IODzB36rL9zP2yafrL3SUbY+0uwRtj1HY4WBr7pTjAZW07QBxPAxloG/s7fVh1jOUx0XLsuZV0fC1smPWjPF8Ov4KHVN7mXbcHcHyV5K2KppY54HiSKQZa5vIg8iqn0cljqcjBbvEfEeCeFXIwt52G0wm1NW1JxmKkLMEb5c9u/8Awn5rrtxrqeGspKOSQMqKnjdCw/b4ccQHng59wJ6Fc27BaYtbepnNxkxMB/xk/mF0K46eZc9R2q5TcLmW5kxiZjfvHhoz7g0H4keC5uplDKwuPT9P1XuNloH1XDLaePQyH4DnwT/yjKsoYWwA8IALjxO8z4rkHahcZL7rek05M00MbWNfTzS+xMXbOe33H1cHqD4hdiflrThY7XeiYdaWQUj3inr6Y97Q1m+Yn+BI34TjB+B5gJ9vZzyGd/7Ko8ZVTaOjitNNoMAn/KNh7yMny8Vwq50MlquVTRS7yQPLCcYDh0I8iMH4qMRhat9NU6voahlRB6Pqm1ExVlIcB0jRycPEHoR+RBWU5ZBBBGxB5grpGnod14k9uNRsUktyoVbT7GRo94/VTklOUJGVSZ3SoZ3wScUbi135qRWUnDl8Y26tHRQuL3p6h1CvKW4MqnAOxFP+Dl3rsbgczScsj8F0tU93LfAa0fofmvNK9RdkULouzy0F5Lnva95LhgnMjsfhhY91diADvK9N4AZ2t2c8/lYT8wPust20S4uNsj22ie4Y57kfyXOOJbrtvPFfqAHkKbI9/GVzkPkYPVdnydv+KtUA/wBWZ++qweLHc17qT4j/ALQpZOUh+EwKvHttLPPmE617ZBlpDh4g5WiuSSHxtkBDmhwxjcKvqKN7YRHGRhhD4XO/s3DkD5dPcSrJIIRlMIBSqWoFVAyUAtDhu082nqD7jsnHHKixgU8hI2ZIdx4O8fipJ5ITMKHcYyYO8A9aI8Xw6/hlRWyDYg7Kzdggqmcw08j4ujT6v8J5fy+CD3phT737bJh8mURfthNPdhNymonSljw8bFpyFvKOYVdma4HILVzx7xlbDSFV39tmgJyYzsPIqSM64T27qOxxFQPkpLHcEiiVI7uc46OUjiy4Edd0Jp3VvTPy1ybu0mLYwDrL+iRSPy13uCau78UMQ/7Q/kn9EiqeL1hury3S8TGDwCz/ABeuAre2yeyMpAmK0uR46Bmekn6J/SYDzeG//gRP/E1Q6t/FQbn7Y/JStIf9auo8aJw/Fqd1QnKfkAraiO4VTAMFWtGdwEBCsa+XhomtzzKrYuqeuMnFwt8AmafcJSdUhVxbti1Wde/FOquh2LVMuEmIE4bJE1a5sT4ytRO7ionfwrFW+XFUtc6TNGf4U5qYVX22bfHmtJRy5AWPoJMSuHmtLQS7BOaUhC92IIILKV5BBBBCEEkjCUghCQgloi1LlCSRlJLUrGEEqEhBLRYCEJKLhSuFEhCSRhBKQQhJQR8KHCk0QiQQIwgjCEEEEEYQggggjCEEEEEmEIJyKR8L2vjc6N7TkOacEHyTaUN0mE9aai1xVCHuLjBFdKY/ZmA4vnj8xlSRQ6evRzSVbrXOf7Ko3Z8yf1+CyQOUadk9dUzlHTRaWq0lcbfh5g9IjAyJKf1wfhz/AAUIYBIPMHB8iodBe661O/otVJEOfCDlpPmDsVcDXDasMFzttNcCwYbIWhrx5g4OPhhGGnwTMOURqzepoOC5RSgbTxcBPQFhyPiQ8/4VtGVulqoOy6utbz7Tg4yfLPHj5BHU6Ss+oGwR0t/ie+KTvGNdwuk5EYcAR0ceiQtyMBPYSx2SNFwWSB0dxlIG/eF34qfVvychdOuPYnWvqJJqWupXcRziQlp/AFVcnY1fXerx0m3XvT/JZrongnRbTaiNwB5l5y7WqHL6OrAzxNdHn3HP6qo0xRk0l9kxyY38ivR+oPo61t4oGx3e70FvpWPEnfNe5xGx58TWj8VU02lOx7QUVUy8dodHWveA2aGmqI3O2zsY4+N46o7F+NdE70hn5TnyBK486P0Xspq2Yw6tuTWnzayMn83LCWDs+uWsLt6LQ08joIzx1VVwHu6aMDJfI7k1oAJyV6Uq+2vsG0tQRUlDaarUsURL2sFE+VhcepFQWjfyCsdNawuvbrI2jis0OkezK3ODqmkjw6a5vHrNg9UBrIc8PG1ueLHBnBcAENjGrsnwSh73ku5CB3nT4DqU32TaHGndOek00JprlqBgipctw+itjd2kjfEkmS877l7RsY1casvFLQwRUlIwmipSIoYY93TSk4DW+JycDzJPmr/UF9c2SqEbwyaRuZ53OwIIgM4z02z+JXLa7UcVsof9pp2ZZgx2WkkbjjJGDUOB35H1QeQP7wKoE8ymY0+0VA7SNWO0rYn2CKUG6VoEtzkjOzARtC0+GMDzH8RXCq+vMOXA5neNh9weKm328TVlVNPPIZqiV5e5zjklxOSSsxVTlpOcve7mngZVoDlCRI/nv8VBvlYbXZX1OeGWZ/cQ+OcZc74DHxcFNp6KpqpowRgvcGsjHNzicBZLtVvDDfDbad4fT2tnorSPtSZzK738RI9zQrDRqo3nAVE2tNRURQM5cQbt4rRWtne3avqyMxUMRDfDi9lv45PwWOs9Uymr4XuHFwkux5gErcUjDR6WgDv6+5VBkP8AAwfzP4qYqFqi2W2m96o09bCOJtRVCSVv7jTk/wDCHKl17ef2/q67VzXcUctQ4RkfcBw38AFptG1Xod71JeduG02p7Yn/AHZ5DwM/MrnvPcpW7pHbJEkXetZDjZ2XPPgwDLvwH4qjqJS97nHmStLWFtFZZpXZbUVbhDGCNxE31nO+LuEf3SspUnAacqUKEqNch30UEP8AvZmR/M/5K81lJ3uqrs7xqX/nhUsY727WSM8nXCHI/vKy1E/vL3XvPMzvP/EVINkiqJTkqJVyd1STv+6xzvwUpyr707gtc/TiAZ8yB+qUJiqLK7hucWdhHTOd+IUilmM9op5jzkfIT/iKg0EnA+5ycu7pC0e8lSLM7vdNDHOKct+BGf1TuiapMLvW96yFS0x1MjfBxC1cbsELOXaPgrXno45ShC0vZO7HaBZf+8d/yOWWtx+oHvWl7Kjw9oNkHjM4f8Dlm6IcDCPA4TepQrGPcKXB7QUOL2VMpt3JCnhXdodwzSjxhkH/AAlMgZCVQO4ZHH/s3j/hKMN2TFJ0SQ1LaEAMJYCYnhGBlLAyiAS2tTChG1qWGoNCW0JqXCAalAIw1LDUxOScFADKUQjDfmhOCg3m4NtNrqKtzeMxt9Rg5vedmtHvJAXo3sn0pH2YdmsQuRbHVtifcLlMcf1zhxyEkbHhHq58GhcV7MNNjXnaTTCRvHZ9PltbUH7MlR/Ys+BBd4erg811L6SOqxprsynpWP4ai6yClAB3EfOQ48OEcP8AfCRwzhnerEBwHSnpsvK7rhLrDtGluM49eeeWte078OSeFvwyB8Fr6phdNE0dSVl+z2i45a6ucOZELM+A3P44+S0t0kdBBI9hxK8CKLyc44z8OfwU7vawOioN2Lj1VZbXCoqqypG7OPuY/wCEZJPxJPyVg3cKFa2Njt8DWDhaQXNHgCcgfJTmjKY7dOaMBORs4iAFNhh4iGhNwR4A81ZQxd23zPNREqYBG1rY245NAUOTMzy7G52A8lOFPNWOMcUbpB9rhHJXVv0nM76yd7Y/AN9Y+9QSTRx+2VKGk7KlpqYQRhvNx3cfNSu6kkHqRukx90ZWrpbDSU2CWd67xkOfw5Jyd2eGJgDQOgGFnvuDR7AyphH3rI0unK6rflzGx8R+27+S0tFpJsDAJJ9+oY39VbUVPws4zzPJTg3Ays59bM7Y4UrY2hVTNPUkYyQ9/wDE7+SSbVRjcU7CPPf81ZTOw3AVfXVjKKmkneCWtGzWjJceQAHUk4Cr9vK/dxTi0DXCTbtJ0+r9QU1lFNEaJuKmvcGDHdA7M97iMe4OPRejIp6TS2naq4yxiOCnhdMWtGPVDfVaPM8h71i+y/R77HauKqaP2jWuFTWHYlpI9WPPg0Yb7+I9VXfSC1U6jsdHYaR/9Kr3hz2g8mtO2fIu3/uphe55Azop2gRsLjuuUacuUgumoNUS8JuE8clPHIGjPeynL3D3Db4KFS2aWnZEX0b44ichzoyB5b4XX+y7RlJSWWmrJ4mzP37oSNBDcHBfjxJHPp8V0F7GyMLXtDmnmHDIKpyVfK4tGq6+38MPqqds0knLzDIGM6dM6hefxTt4WMDRk7ck/LGxkYY1oDneq3bl5rWaz03DZbgyamHDBODhnRjhzA8tx+KyrPrqh7vsM9RvmftH9PgVYa/naHBcxVUz6OZ0Eu7UuOmYMAMbgeSlGJoYGBoy/nt0QiYAOI8k7Ewuy4j1j+Ck5iFSAymfRouZjYAP3QkupoYwZXxsDiMAFo9UKZwbfij0vpGo7Tri6MF8Wmqd/DVVLCQatwO8MZH2QdnOH8I6kOaS7qkdhoSNCaB/9JlxFTUwhmmYX4J4cGtcDgtafuAjDnfa9kdSvQ1XVWnRlhlr698NBbaSMEnhAa1owGtaB8AGjcnACbmns+gNMvr66WG2WqiiHQNa1oADWtaOZOwDQMnYALlDI7n2x3envd7p5KHTNO7jtdlk5y+E8w5Ekcm8gD4ZLpcnv0UG58U22Co7Xb/Bf75SdxZqbJtdulaC5jT/AGjhy4nbfDAG27tVqHU8GnaSOjhjbHK5uGU0GzgPFx6JeoLyzTkDKamY2a6TjMUR5MH33eAH4rmtS5888obM6oqXuJmqnc3HqG+ACU1Dox6rj8VM2MOOuyrr4+e8yPYZpI+L2mRuw1vvzzKz1RpiGjZxNqHOlPLibuf5LWvj9HLIIGGWd3ssH5nwVLcWGOVze8Ek39pIPZb+63+ajFXOTnmUpY0DACxNZpyumlPC+N3iQSC1U01jr5yY4YXspRs+dpB4j4NXRhbX1FMJZi6Chzji5OmP3W+XmlvpXueyJsQYRsyBo9gfzVxldK3fBVcxgrmbLDUjAFJKGj2W8J2/zTdxpam2CNgop6mtl2ipY2nid5nwHmujV9QbdUNoqSMVl3eNo27th/ecfJNQW5lojmkknElXIM1Fa87/AMLfAKcXB41LQmmLOgXNItK1sVSKq5QPrrj9iBrD3NP5AdT5pi5zT07yHwyzTj7PAeFvvW6muEldMae3QSyA7ExtLnO+XIK1tHZrfrqWl1E+Jh5Md6ufeealFycNXhRdj0YuJF1XXVBYxjnzdSR6rVZ0tgipR31VIHv6ucdh816UtPYhXVDGtq6yOkh6sgj4j8z/ACWvtPYDpiIh1VbzdJPvVW4/wjAUn8Xbty/NM9EduSvIYuNF3rYKZklbUE8LYqZhke73L1D2f6VZpHT0VO5obVy4lqSCD65A2B8By+fit+3Stn01Aynt1toaLOcspoWNwPPAU6xWaK43BjXRMMTPXf6vQdPisuqugncImNXqHDFDHa4JLpVd2ngOvvOw/uuL697JNQdqN5pm+mPobPSg91FFEeN7jjicTnB5bfHxUuw/RAtMXC6sdNVP6mV69OR08bAA1gA8k82AfFasNbExoZqMLzivqJq+pfUye04/+B7houUae+j1pmycJZQw8Q8WAroVq0tR2yMMp42xNHRjQFctpz0TrY3MHJXW1UD9nLKcx/cmoqGMAA7+9SGUzG8gEA533UoSfuqzztPVM5SlCMeCWIgg1+Byx8UsHKTISgJHdjCLgwE475JJ5JE8BNlibczxCfJwmnHmhPAUaSIFRJacBT37lMvCUJwWC1JRv0xcJb9Ssc+gnAF1pmjOwGBUtH3mgAOA9pgHMsAPK+07Qlwsd5oO0DREzKe92498zhHFHPGfajkA9uN4yCBuM5BBXoaeLIK55NGNFVrqd7c2GYl0Y5+ik8wP+zyeX2fdyna7oVOz1tBuuNax0/be0HTs3aNo6ldSwPcTqKwbGS3VPN8zcAcTHe0SAM548DLw3ltVTA4PxBHRdz1dYLt2O6nZrfSZDrZU4ZXUo3hc0nk8D7Jzsfsk7bEhZ7WOjLZqWzTau0XERbx61ysoH1tufzLmtHOI7nbYcx6uQyVpxoVFLFzDmapHY9Q+j6eqZ3DD56gnIPMBoA/HK3izug6JtDpS3tAwZGd6T48RyD8iFZ3y8Q2Gz1dwqD9VTxl5GccR6NHmTgfFcfUEyTux1K+krPG2htMHaaBrAT4aZK5zr/tNqLDrKjpqIiSmo2n0uIEYm4ubfItGCD0J3259At9wp7vb4K6kkE1NM3ia4fkfAjwXmS6V812rqirqXcdRO8yPPmTnbyWs7Mdfu0tcPQ6txdbqh3rN58DvvD9R1XVRQiKMMHRfPNyuLrlWyVLvzHTwHQfBbvtH0fWVb4NSaeAZqG3j+rA2q4vtROHU88fLwIwdbRUuvrO7UNiiLa9g/p1tHt8XUtH3v+YeYwu+xtZNCyeB4lheOJr2nII8VyXtE0rWaLu7taadZiMnNzpGD1SOsuB0P2vA+t4lStOTjr0/RZb2gZcRlp3/AFC5W2RsjQ5jgQeRRcYLuE7O8PFbi9acp9cUEuo9Lx8VaBx3C1N9px6yMHV3u9r388FllVECDkcwRsQf0KstcHeaz5IzGR1B2PeluOAoFXRZy+MYPVvj7k6awwPDKjZp9mYcj7/BPuGRkbg9QnqE6qjLsHw8ivWfZtGI9BWIDODSMdv5jP6ry7U0rZtzs77wXqbs8YY9DWJp5ijjH/CFhXb/AA2+a9V/DtuK6f8AyfcLlXb5cXUeqra0t4onUeTjmPXduFg4Z2TsD2ODmnqFsvpHMLdSWqTbhdSFvyef5rk9PVSUr+KNxaeo6FaNB/szFyHFel7qc9/2C1PEkOY1zuLBa77zTgqBS3eKbAk+qf8A8JU3izvzCvrlMpwSys8JR57O/kjZUxvcG54Hn7L9j/n8E0X4CQ7hkaWvaHA9CNkJFLc0OBB5FGx5LcHcjmoAfLTbsJmjHONxyR7j+h/BSmTNkYyVhyx22UBIU87moFyi2bMObNne4/yU7OSic0PBBGQdiE5NOqpXclGmfgqVNEYHGM9OR8QocoyolFsmXvI3V9oqr7q6uiJ2lYR8Rus5Id1ItlUaOvp5+jHgn3dUoOCladVr7rH3dS4dMpEL+JrQefJTb3A5zO+a0mPYF+NgqyN/DK3wUucp7t1b0Ttne5MXh/8ARI/4/wBEqiPrO9yZvJzTM/j/AES9Ew7KsDsvCtLe/DwqdrsvblWNFIGvGUwFRq4ncDRY8XhWWk2Bs9ycOtK4fiFTyP4qVoHV6utMO4RcD/8Ag5H4hPzqgIQjdWVKcFV0Wym0zsNefJAKEqd5e5x807Tt3TDRkBTIG8IShNVhS7OCcuUmGY8lGgf9YAk3GXIdhPQolBN/TAFtOL+in3LAWt+bi0c8lbkP+od7krSmlU1NJiqeFoqCXYLKRyYuEgytFQyckoQdl9A8boIILNVxBBBBCEXCiwUpBCElBKxlFwoQiRYCNBCEnhQwUpBLqhIQS0WAlQkYCHClcKHChCRgoktBCEhBLwEXCEISUErhRYKEJJCLGEpBCElBGWosYQhBG3kiQQhKyEEXEiJyhGUC5NufjyTFZXw0gJkeOLo0c1WGqfcXZcOCnHTOxUbnBvmp443P16KU66GarbTwH+KTw93ipj7ZR1w7utp2VcRGC2VuVnoasPu3E3ZhIaPhstK1+TzVMu5jkq9yhmAF551Lcb5oPVFxsE9+vUMEJ9IoJmV8ze9pXk8G4cMuYQWHl7IPVN01fU6noZY/9qr2agAn0aW4SO4h5ZOSF1rtf0P/ALX6YbW0sPe3W18UsQaMuliIHeRjxJADgOpYB1XmadkkD2yRvIHtMkadx4EFZ0nM12AdFrxckrM9UzqDTNuNS580b6yYHd9Q4uP4rHz22Nl2YyKnjiYMYDGgDmugVFzdeo2x1LQ2vaMNlAwJh4H9781X2+zen1veODYoqdplmlfs2Ng3JJTWuOVIWgBXvZx2dS6x1RbLJT+rUVLu9nl/+poG+1IfPlgHmSB1XsC0RwUNELZZohT26lAhp24yGsaMcbvEnc78ySVhPo96HksWiJb3NB3d71Ph8fF7UFCP6seXECXnx4mg7tW11K2OlpTaYJTDTNbmtqAcOcD/AGY8z1xyGyfgnUqk+Tmdyd37J/RY+9zU1/M7ZZOHS1G8uqp3b/tCUH2B4xg8z9o7DbJXF9f6wm1FdZaiQ8LB6kMWdo29Atb2p6xayKK20uIomAcMLNg0YwCfhyHRcdq6h0jySSSowp2A7lQ6mTJJJ3UB0zmuwxu/Vx6JyrnDQVBpGVF1rW0lMWhzt3yPOGxtHNzj0AUwCeSrelux09aLnqCQh/oTO6ps/bqXjDAByPCMvI8AuBVdaZZvaLznJcTnJ8V0Htf1PTy2KzW+3Oey3eu+nDhwumaDg1Dgd/rHB3D4Nbn7WByoS8LC481cY3AVJ7slaOwU8lwq2xxjikkcImgeJK6RfTHBXzxsP1FtgZSs8C7HE74+yqHsntsdN6Teqxv9CtdOaqVx5F59hvvJxj3KTWtkbYaeeqOZ6/jq5um73bfhhNcdcKRowMpFG80fZZdKncSXW7Mgz96OJpP/ADFZShkpW18ArBIaXiBkEXtFvUBa7UsYpNE6Pt7PVD6eatePEySuwT8GhZF1C+Ckqa1+GxwgAH7zz7I/M+4JzTuUjhsEWvtSnUFzjLOFsFPH3UbGN4WtHgB5cvgsjUyh0TBjcE/FPSnOfNQpvsjxKlCgKKllxqOwD/8AD4j/AMQVleXcV0qz/wBs/wDNUcMxGp7CB0roh/xBXV0/9ZVf/eu/NS9FGoDgqvUO1HCz787B8t/0VvjJCpNSuxNb4/vSF2Pc0/zQgrOUk2aK7u+8I2j4uP8AJT9LP47Xcoj9ngeB785/JU9G7/oyqP3pGD5A/wA1ZaScPS6yE/2tO7A8xjH6p6j6qbG7i5KrvEPHxOHNpz8Oqm08mHkeKKrZl2/IjCE5H2cy9zr7TzjtmtY35nH6qpfF3FTURnm2Rw+RKk2GUWzVVonccMgrYZSfJrwT+Sf1LTGi1ReoCMd3Wzsx7pHBHVINkxD0U2m9sKDAd1OpvbCaVIFbUvqgn90/knGjITcW1O8+SejGyYpQg1qW1qMNylhu6jKciDU41uUbWp5jE0oSAxLa1OBuyWGJqemw3KWGpXBhHwpiUJHDkquvde6ip3MiJM72k+qMlrepx49B4kqynmjo6aWomcGRRtLnOPQBaDsj0bJqG+R3i4RubT00jah0bhzlG8UfuZs8/vY8SgYHrHojBe4MbuV1nse0ONBaGgppW4uFSTVVhO57xwHq/wB0AN+Geq84/Sg12NQ62Zb6d/eUlsYadrWnIdJnLyPjhv8AcXpDtE13Fo/RtbWNlb6aW9zTszkiR2wJHgOfwXh+k4r3qx00ri+Kn+ske45yRuMnxzv80sI5iXuVioxGwRN6ro+mbd+zLLTU+PXDcvPi480i9y4fUkbso6cuz/2knqN/AuPxV5Q0r38LI2OcWDHqjKjDTNdX2uB0obAbjVGqcHn1hCzZgIHlg/FMdMxhy44VflJGAqymjEcMTPutAx8FMgidK/DQXeIAytLR6VpYgDK5056l3qj5D+avqCkhhGYomRs/dbjKzZbgwewMqZsZO6oLZpyqqMPkYIG9A/n8loaewUsABcDO7xccD5KezkljJIA3J5LLkq5ZOuB4Ky2MBFDADhgAaxvPHL3KVz26ImtDGgD4nxRucGNLiQ1rRkk9FnqVIqJe6Zn5DxKboaZ0z+J3MnJKai466cPIIbyYzrjxPvV1DEIGcI59SnHTRA1S2tDRhE94DSic4AEkqO9/Fkk7BRp6RI/Llbdn2njqS+/tGdvFbba/6sHlLUAc/c0HP8RHgVQMpqm93KmtNAD6XVO4ePGREwe093kB8zgdV3rT9hpbBa6Whp2cFNTNDWg83dS53iSSST1JKcTyhDRzFWDZYLTb5aid7YY2NMkr3HAa0DJ+QXmu4XmXWurLhf5g5tO1xipWO+y0bfPH4krd9tusX1b4tLW1+ZZnNdVOafZHNrf/ABH4eayMdBHQ08VKzaOIZcT5cyfenNHKPNK93McdB9V2DQby/SVvJ2PC4cvB7gr9Zns3qTVaPonlvD60mPNveOIPyIWmWFJ/iO817vbTzUUJ/wB1v0Cw/alU+j0VFgZkJeGDxceED8SFhqeERRMYDkNGMnqepWt7Ti6a72uMj6uGN8v94kAfgHfgs1GxatP/AIYXlPEDua5S+7/tCUxnERtsFLihLyA0ZKdoKAzNklc5kFNEOKWeZwayNvUucdgtFp3QTtYQRVdc2ej0vIcxxYcyquzfIbGOB225w5w+60gunaC4rni4NHis/pvSlR2izucHyUulonlk1Ywlrq5wOHRQkfYB2dIPNrd8kdqr7jYezDSor7o6G1Wqla2OCnjaA57serHG0buccbAeBOwBKqtX68s/ZjR0TZqX068ztbDaNN21o43/AGWta0D1WgjHFjAweEOIAVbpzs6u9+vMGq9eSxVt/aOKjtkW9JamnfhY3JDpOXE/J3AAJwHGxgAa7fVV9XH96Knhsd37Vr1TX7VdM6jtsDu8tenHbti8JqgcnSEfZ5NBxzJC2F3rmWOMRRMbU3KRuY4c+q0fef4NHzPIK6uVSLZTuZThvfu5yOGQ3+Z8vmstLRsmhmY50nFPnvZQ8iR2efrdPgqctQ1hwV0VustTXtL4hhvedFga+aevrqinp5XVNU92ayt8PBreg8AB7I8+blNaJA5lJSR95O7YeDfM+QWsp9Ow0kDKahh4WZwGA9epJ/MqRUUbrbEaC3xmavmH1j2jcDw8go2ntBzKGrpZKKUwyjBWGvEUNnifRUj++qpNqiqAyXH7rfLonrboSG30Lrrfw6GkjALKUe3I4+y0jqSfs/6HRNOaIp7OTW1hbNVtHEXu9iIdcefmo1ZHLc61tc+nM7Yc+hUrtms/7V56E9OoHIZUwGBkqg0F5wFnbVpllxlFxu1MGzH+oo8kMpmdG4GxP5dFUaw0dVQRM/2dijp5amTgnnleXdw3GeJoO5z/AK8t8CSBkgnqQMbq1tFAyRhmlYHDPqB3L3rNike+XQ6L0y5W+iorXyvYOYADPUu8/j7lyfTvY9UUtKWwvELZfWlqpxxSSnx/y5fitFSdjdnyDVNluMjTnMx4WD+6Nl0tzgE252eS0jncleaZB0A0VHbdIUVtjDIKeKBreTYmAD8lcU9ujjAAaB706x2+6ea8JEJUdMxuDjKTcpzTW6Z7PVdgAH3nCc7wKLcmOqqOSNvtHBGeuE159U43VqiDPSojL7PMM+WVmCcla7TFN6NQ94T60x4vgOX6/NZmC3zzyhnA5g6ucCAFrqZzII2Rt2a0ABU6Rh5ucrueKK5hgbSxuyXHJx3Db5/RW8bxgb7qQxw8VUelBgySlC4A8iAFrcy8vLCrpsg8cJ1kjdgqZlWDjdSWVTABuPmlymcpVqzh8AndsdFVsrWge0E4yvZjdw+ablHIVaNx4BHsBtgKs/abAdnZRftRhO7vxTg4t2Kd2ZPRS4pA+M5OSHObn3OI/RA4Cp6K6NkqLiwEBsNQGADzijcfxcVK9NB6qw2qmZs5NMIzsnaushooHSzytjjbzc4qhbri1vlDOKZgJxxuiPCs/rG4SVV0MPEe6haAG9MkZJ/H8FQqvJepmOLQ0aL0a28KU09K2apccuGRggYB26HK6syZs8bZIyHscMtc3kQkPcfArLaKr3NE9M52WDD2jw6H9FpjOPFaUV0MjA7l+a4i4202+qfTl2cbHwOqQ7Pgqq82xlxpXxuaN9wfAq2MoPVNPkyFOLif6fms8RkHIK5pb6uTTTp7bWUwrbLKDHNRvbxd2DzLQebT935Lnt20pcuyrV1tvml6l01hrp2xRTglzWcTgDBMOrd9id+W4cAT3e7W9tc3iGBM32T4+RVDTufQGaIsbJBLtNTyDLX+fv8ANSi56YLfmr0bGue17ts6+Sxu3QBo6BowB8Fy/tfvTpxHZ4jmIDvKggA7/ZHltv8AELr2s86ftzq+joDX0vUh3C6E/vgDl5j8Fgb3o+16xoZtRafildJgftG1cfFLE7GO8ZnOQdzgbHmMHIWfQyNbJ2krTovROJL/AA1VD6JQu1fvuMN7vf8ATPevPlVA6B/l0KiyEPbv810y4aIp6qDvaedxiduDgHCylXoyWF5aJ2uHm3C6UVsB/MvGXRuHRafsu7Sai2SMtlTKHsJxGJD6r/LPR35rt9DWU91gL4MO2xJC8bjPQjqF5Yl0nWMOWyw+RBP8l07s+1HXQSRUlfKxlQz1Yarj2f8Auu8/Pqh08J1Dwpoi4aEKu1ro+4dlV2GptNvfFZi/MjG7+hOJ9lw/3Tj48iccsJ242Cg7WaGovemYm0eqoGGW5WNv/tQHOaEdT4jr7/a7fTMdWwv7yGJ/G0snppRxMkaRggg8wR0XFdd9kdx0Nc4tQaUqJaa2xvEkTo5SJrZITs0nm6I8g48s8LuhLmVULtC4Bw69/gUySJzAcDLTuO7xC5XJNEWubUwnh5OLeY+CZZapQC+2VLZmczC/p8On4Lptw07WdrhdUw0UFv1bFj09rPVpq1pOBOMD1H/ebycPWG+QlSfRpv8ATUxmgutI6ra0kRt4mgnoA7z8wEjrlTRnEkgyrFNZK+taZKaIuaOu3wzjPuXK3XL0Z/d1sElK/wAXNy0/FepOzqpZV6Hs0jHNez0drQ5hyNtv0Xn652PUNhrJbddKaGV8Z9Zkp2I6EHqD4rv3ZRRyv0BauCBkAaJG90xwIbiR3/n8VnXOpgfC0teN+/wK7ngNrqe5TRSjlPId9NQ5q5z9I61vnksdTGA4hs0bhj+Aj8yuHFpaSCCCOhXp7t109cK7R8dRSQ95NSVDXlmAeJhBaQPiWn4LzrOyWV3d11HNTychL3ZwPePBX7ZOx9OAHDTKwONqYx3mSQbPDT8sfUFVachrJac+o8geB3CE8D6aV8bwQ5vTofMJk81srz/ZWcV6ztKz4sUplfDL7Lx7jsVQE4Q4kqMrSiUeKTTScMtRF9kgStHn1/IH4qgjnfH7LyPcVY2yaWWcueQ5rGFucb5JBx+CEZV814OD4pwDJUSndxBgT09T6NCHBpkkcQyOJvtSPJw1o8ycBLlJgnQJf7JqLzUMpaOA1FV7WAcBjfFxOwH47bAq2HY1fKkepUUhd93LiPnwrd6J08bbSspQWuq5frqudo2z4DyHIDwGfFdAghbE0NaOFo5YVEyuc71dl0LLfCxg7XV30Xmq79l+pLQwulomTN8YJAfwOCsqymlkq/ReBzKgngMbxhw94K9hTRMqIjHK0PYdiCsDqDRNKyd8s7A44Jp5D7cfiQVDNVdgwuKrSW1jv8M4Piqi20rJNNU0bwJCI8PyMhzhs78lmrnpzjDpaTZw/sjyPuPRaPTEjzRVdLM0tlhfkgjGWuGQfceabnbwve0dCVhx1MkZ52ndQvjBHK4LK0bHxyuZIwscG8nDCj3g/wBGZ/F+i2dNSw1p4ZWBx4Th3UfFZ3U1jnpaUOjBnj4ubRuPguggrmSjldoVQkiLRkahZZh9YKbTuJVfGfXCnU+APNXsqmrWJ2YmD95X+nTw0te7xYG/is5TOyWjzyr6xktt9Sc83NCcN0J4HDipcDvqnKCHZeVNgH1ZS5QQpETeSlA8LFHiCcnfwMTgmpyCX63YpFbJ9W4kqDQT97K7fZLu03BCQpEItPDvrlxcw3dbESfVvWT0qzhifKeZWhEmY+aAhUrZcXOQLSUMmwWQEmbpJ71pKGXACAUL6MIIILPVpBBBBCegggghJhBBBBCagggghCGAi4UaCEIuFDhRoJcoScFBKQRohJRYCWhgJUJGAi4U5gIuFCEjhKJOcKJCEhEWpeAiLUISCMIktEWoQk4CSRhKSZJI4IpJpntihjaXve84DWgZJJ8EJVGuVxpbPQy1ldUMpaWIZfLIcAf5k7ADmeSwNR2jTX6fubXFJTUh/tnjEsg8QPsj8fcuf6q1VU9oGomvJdHa4HH0WnOwa3l3jh98j5A48SbWiurbZFw0zB3vLvHD2fcFQkqOY4bsteKlEYDn6nu7lszPBboxNXyniO4iG7ioU+ppa9/AwCGDkGDmfesjJVyVEpfI8ve7m5xyVYULSSFVLiSrPKBqVqaeoLXMeOm63NCPSoY5WbseMg/oudU0m3Cuidm9c5lX6FVRONLN7Mhbs13v81K3uVeTbKuqWFzMbLhnbP2Vus00t+t1OTap3cVVFGP+rSE7vx0Y48/A56EY9V/sCAbhqcbaYnsdG9gdG4cJa4ZBHmnOi5xgqGOp7M5C+egt8fetEhLoc+twc8eS0Ng05Hr3WVr0Xas1FrknFRd6sEt72KMguYD0bnDc/eI81J+kRf8AS0esKqyaQp4rfTWsn9sXKKRxjfM72YGDJDeHBzw4JORyaVvOwnTUmg+z03yvjEWoNRNErWkYdS0f9lH5Eg8R5buwfZWfjlJC13PJaH4weg/fxXZb1qmG2yGloC0y8PAJWt9WNo+6PyC5prPVbbTROL3ZlwS2MnkT1d5lOVl1FG17zh1U8ZHFyjH3j+gXHtU3p13qZHcZMDT7R5vPimklyjYwBZ6618ldVSzyvL3vJJceqpKmfhBAUirqMk428FWPLp5Axm7j57AeJKeApyVFdFNWztghbxSPPjgDxJPQeayOqdTMuDotJ2KcmnrJWw1lwj2NS4nHC3r3Yzz+15DOXNYanHo0ltt8n1L/AFZ6huxn/dHgz/m92Asxpk/su41d2kA/6Op3vi4uTp3jgjb8C4u9zD4K01vUqs52TgKF2n3qC761uHobO7t9IRRUsYOzIohwNA8jgn4qntNrqb1c6SgpIXVFRM8MZEwbuKiupnySsDQ6SRzsADcuK2dTXDs1t8tvpXh2raxnd1U7Dn9nRnnEw/71w9p32RsN8lTudygAbqJo5iXHZau91UDaei0LZJm1EcdQ03Kti3bVVROOBv8A2cfLPUjONtx2h1McEksER+rgjEDfgMKF2T2ttH6TdpW/UUMJ7vP2pX5aMe7DvmFDvZfc7hBBnifPKGH3ucB+qrj2gFOdQrvtEa2jvNvoZCWtobbSwOwOR7prnbe9xWP1tcGxNpbTB/VU7RLK7q+V4BOfcMN+BWr7VJxVa9vzgdmVL4x/d9X9FznUNR6TeK2QZw6Z2M+Gdk9muEjzuqqQ5UWV3rtB5DLvkE9I7Cg1JPd1MgPqxsaM+bnbD5B3yVgKsVCp5f8A5x2Px9OhP/EFpLp/6zq/++f+ZWQppP8Ap6zOJ5VsP/OFr7r/AOt60f8AbP8A+YqXoo1FHtLP6mP/AErbB4CQ/gFoQfWWc1QcXW3/AMD/ANEIKylvObVJ5zfopmnJe5v9J0Di5p+LSq+3n+gPb/2zv5J2jm9HuFPL0jla4+4FPUYVrITDUOb1a4j8VIqPWja4bhM3dvdXWqby+sJ+e6XSu76F0Z5jkhOHcoNwg44uJuzm8iFb63cKjU1TWD2a1sdYD495G15/FxULAcCCPepd6b6VaLTUjd0TH0cnvY7ib/wSMHwSFAVTD7SsKf2gq+H2lOhOHBIU8K5YP6E8/wCuiei3Cai3oXJyHmoypAn2tynWtSWDKea1MKeg1qdaEloTjeaYU9ONalhiIOawZcQAqe6aspqEFrCHvHyTcZSEgbq6cAAmHSAdQsHWawnqHEMdgeSk2Nz7rJKZqswCNvGRjJI/1j5pHjs28ztkwSZOArwsqNU6qoLHRs70B7XyN6Pfza0/uj2j5ALomqdYVlqfJpDR9SKOK1MJvF8ETXlspGTFGDtxdXHfhyBzCjaaoIezHTTbjTxGo1nqNpZQCU8RpoDnMxHIZG7fcOYDgqTUNTT2a1xWWjcXwxEuqJuRnlJy455nff5DosaS4Nc7EYz3Z+ZV5kfZNJO51Ph3Bchuem7tqq4VFTdbjVyQOeTGyrmMsmOmQNs48MLWaU0LQW6qo6HDp5C8TzucdsN3AwPMAb5/FSqdmZeJ3Jm5960OhqN1XXzVDubzgHwaP9fgopa2ZzSM4A7lAyJvOD1K1NxLYqKGjp+GKWtkbTM4W7NDvad7g3JS7h3ctwcI/Vgp2tp4m/da3nj47fAJmCpbPeKq5bGnoWmlpR0Mp9tw9ww3wIyoFXX920MGS5xwAD6zj/rmVl7lXemSphlE8zYmeyN3EKxY4NAA5KppiImYyCTu4jl7gpsbnOGXA8PgOfuCljglqHckLC49wBP0T443yHDASfBTWyBreI7joBzJUyCMtBc723c/LyUOiiMjhK8Y+637v+asM4aqpHRKEtVpkNzkyz/qjTsf964df4R+KKadlwiexr+KEktdwnZ3jv4Kwo2NaxrgAA0YaOQC7C7cLV9koaa4VPKWT+zg56A66eK16u1z0cEVRJjlk2x90/AGUjMuI7w8/JPcbeHJPwVTVEGY4OU/DKXtGTnAWzfeEY7TY6O8wzF4m3GMBpxnG5zsVfrrU2joYaxj+bn3020/8qRJMXHwCgzVLnkgHATtTIGs81F7p4iEhB4ScZXf/hZwpRXNstxucQezIawO2J3OnVdBwta4arnqKloLdgD3rqnZVpyC126S6SETV9dzf/u4wfVjB8+Z8T44Cu9fazh0XZDMOGSvnBbSwO3y7q5w+63OfPYdVk9K6yo9N6UNRWO43xuLIoGn1pXdAPLxPT5Lnk9VXa/1HLV1z+JowZODIbG37MbfD/zPMrxniS3C23mqpMYax7gPLOnyXH3GIUtXLA0bOPw6J7TNBNUyTXWre6aoqHOcHv3c7Jy5x8yf9bp+7nieKcHLpN3nwb4fE7fNXk7o6Kmc9w4ImNADWj4AD8lm3F7jLK/+tkOTjk3wA9y57OTlZpGBhdg7OSDpSmxyD5B/xFaZZvs6iEWkKEeJkJ/xuH6LSLCl/wAR3mvdrWMUMH+Vv0C5zr+TvL+xvLgha38SVAoLWXzUzZo5pZqg4p6Kmbx1E/X1W9G7budhoG5K20GiLhqG+1VaI20VOXhoq6pvEAAACY4up22LsN3BAdyWtf8A7OdlloqblU1TKFr28NRda5/HUz43Dc4ydhkMYANjwtG62IWHlC8auk3aVszh/UfrhVmn+zRsb4avUkMNVPC4OpbBE/jpaZ3MPndymkG23st3xnIcoWru1CurL/LpzRtK3Umr3ZbU1Dj/AEO2tzgulcNvV5cI65By71XI9H1Z2tM7qmbVaI0c7Z9S8BtzuDTz4GnPctI+07LiMHDmuLR0bSOjLLoSzx2uxUEVBSN3c1gJfI7q57ju53mSdgANgArZLWhZGp1+aynZx2SU+jKiovd2rHah1fW5dV3apG7cjHdwt+wwDA2wSB0bhrdtI178hgyT1U/uuI7qPc6hltoZZz9keqPE9AoXO/M5TxMMj2xRjJJwPesTepSax0XGHNj2PDsM9VARucXuLnHJJySp1jt/7Qr2NIzGz13+7w+KwTmV+nVe6RtitdEA4+qwa+Pf8Sl2WglqZXSNcYmtGOPHU+CvKO1wULSIW+s85c87lx8yrMwhjQGgNaOg6Jpw6LXijEbeVeP3O4PuVQZyMDYDwUWogZPGYpBmMnLm9HeR8lBuzm09BJwgNLsNAx4/5ZVmW4Wf1FKO9iiHQcRTZ3crCVYstP6TXRsOwOT7tf7KqjjMr2saMuccBaVjRBAyMfZGFU2Sn7yodIRswbe9XJG+6r0zMN5j1W/xPV9pO2madG6nzP8Ab6pDt90lLdgJBd4lW1xgRA46pwSf+ajulAym3TJMp4apnfYG6bfUgdVAfU46qO+pznfKTKeGKxNaAOaZNw4ORVZJUnxVbddR2+yxd5X11PRsPIzStbxe7J3+CMnoncg6rQyXMk5LjhR6e/8AHU8LGOcxp3d0z5Lnje06mvs7oLDarpqFzTwOdQ0xETXeDnuLQ33nZW9JT9oFW9pg05bbQwez+0a/vCfhE12PdlPa17tgoXPibuVv5qp8rcglm2yYE9UwZw4jxWQEus5IXB95tFvqAcB1Hb3zNHxkk9b5BZvXWlb1ctM1UlVrK7VdfwZayJ7KWnOOjoowMj3k/nlYy2R3KDkq5VUdRRRNmmiIaev693vXRrlri2WEltyu1HQOH2Kmoaxx9wcQT8FCb2oW+cA0MVzugP2qK2VErf8AE1nCfgUjsWprRJoW1VVBbKWhqCzu6p0MLWOdM0lry4gZJ4g7muhgeAwSrghHUrDdWEHDWhYRvaHKSAdN6lx4/smYj8ASpVN2g0j5mxzUN2opHchVW2aIe8uc3AHmStr3zKeJ0sr2xRsaXOc84DWgZJJPIALzv2jdu1X2jX6DQPZ9UODq55hrL4zIDIhvIYsEHhDQcuyOLGG5y1xcIQeqj9McOgXabdc4pqU1FNIJo53ukErXBweM4BBHk0D4J9t0cDz+S5ZSdgFhsdFFDYrjetPTNa0SVFuuEjTO4AZc9p4mnJGSA0DwAGyddYtf2Vv/AEfqa33sD1WQXmh7vDfEywuBJ8y0/FIYj+Uqy2qYfbGD4arYXiTvq97/ALwH5KGoFkrrvcKMvvdBBb65rywsppzLHI0Yw8EgEZyRgjOyn4XMzAtkcD3r3S1PD6GFw25R9FdaZl7mWd2cbALQCtJ6rJ21xYJCOuApvpLmrWpjiILzW/t57jIfL6BaIVeeqM1LT1WfZWuBG6ktrM9VbBXNGMhWT5PDkoNdTNqAHj1ZByd+hS2VII5pL5MjYpUgGCqxji0ua5oyRwvjIyHD9Qucak0VcNNXP9v6ReYZ2Zc+j5hzeZbj7TT93mOY5LpVXH3g4mHhe32XfomI5hLsRwyDmE5riCnuaHjBXLIGUPaFFPcbBGy3aijBdXWOV3C2cjYuZ4HPX3cXQnKVdmjugmFPG6GqhJbNRyjhkjcOYIP+iumax7OY7xVMulqndar7CeKOqhPCHEfeA+WfzVHHcqXWVYy06oaNNa1gHDS3eJoEVV4Nd0OfunYnkRnhVgEO1CoSMIOHfHvXI62ifTPLXtIIOCCMYUBzjGccwurXe0SMrxadR0zbddDkQVjN4KoDq13/AITuPwWJ1DpWrs0zmvicW8xwjII8R4ozjQquWlqt9Hdo77U+Klubny0g2bO0ZfF7/Efj+S7Jb62Gqp2zRviq6aZhBLcOZI07EEciD1BXmXY+RV1prVty0rMXUcodA45kpZcmN/w+yfMfioy0HUJ7JcaFd6s2naPTjamKiGKeaXvWA7ljSBhmfAHOFYrM6L1pRarp3iEOgqot5Kd5yWg9Qeo8/dsFplzNQCJXZXvNjkjkt0Jj2xj3jQ/Ncy7cbVHJaaG4hg76KbuS7PNjgT+BH4lWPYvV+kaPdESPqKl7APIgO/8AEVP7VaX0nQtywMuj4JBt4PGfwyuNaM1vWaLrpJIWNqKabAmp3nAdjkQeh3Pz5K9Ex09NyjcFchcKqKz39tTJo17dcfDPjsMr0DqOgjulhr6WV3AyWFwL8A8O2x38DuvMXpjns4ZQJm/vbkfFbvVPbJXXu3OpKKl/ZrZRiWQS8byPBpwMLnSt0cT4Wnn6rmuJ7pS3KeM0uvKDk4IznYa66eXVTauOOooqaUsBxxRHiGfZwR+DgPgqmostDLkupo9/ujh/JWsDuO2TNP2Jmlv95rs/8rVGcchbbJHAeqcLhJACdVEtXZ/T6hu9LQU3eQy1EgYCHZDR1Jz0Ayfgu1D6Nukxa20x9KNUBvW96eMnHPh9nGd8Y6Kv7E9NST3Oa9SsxDAwxQlzfaeeZB8hkf3l1643CG1UFRWVDuCCBhkefIDp5rJrLnVNkEcUh0+q9Y4XsVGaF1XWxA82ccwzho667dde5eO772aVFivVVbjWNllhkMYd3XCHDoeZ5jBTrNITU0QjjnjdjmTkZPVa2uuEl2uVXc52Bs1XIZGtbyYDy/QJlvJdEyuqQ0cx18gvKZoYO1f2I9XJx5Z0+Sz0OmaxjW4MbufJ38wrHRulK+6XcXOSlMlNTuMdCwOB7yT2XSc+Q3aPe4+CsoKeW9VbKCLLKcb1EzdsNHNrT4nl5Z967ZpKwMt1JFM+IRngDIYgMCNuMD4kfh70klzm9kAaq1R0jWntXbDbxP8AZQbPZH2qkDZGnvXHikdjmfD3BTeQWkPLkolW6BjSZGh56bJzbiGj1mrRLC45yqZgBdl2zRzPgFnL9M66VHdR/a+qb5Z2VndaxsLXNZs5/IfdHiodgpDVXLjcMsiBd/e/0Vm1dT6Q/I2CkazGio9T2wWfUVvkY3ENbS+jO6evGMtz72kj4LO12WzuHVdD7R6B8+mZamJvFNQPbVs9zT6w/wAJcue3JzXyskaeJkjQ5pHUFNjPMFk1bOWQkddUVsOKj4FO3J39HHvUa2n+k+8FPXQ/0cfxKboqBGizNfYKetdxRgQS8+Jo2PvCppqOehdwzRlvg4cj8Vqmu9ZSBHHOwskY17D0cMq9BWvi0dqFTfEHajQrKUp9fPkr+1PDbU796Q/km6nTpa50lIctx/VHmPcUulidT22Jj2lriSS0jBC6KGZkwywqqWFu6dh3crCLZoCrac5d8VZRD2VZCYQpkQ3HuUK6VQjjdvyCmB3Cxx8Flr3XZ4hnqpFGVZ2GTjBcUL7NuG+OyRpz/qoKZrnGpujIhvgpeiRaG0t7i3xN6ncq1D8R/BVsJALGjkBhTJJOGJxJ5BOQs9C/jucp81pKV+AAsrbXd5WSO81pIH4ATQhfSdBBBZ+VbCMc0pISgcpEpQIyixvhKQS5SZScb4QwUpBGUZSeFHwo0E5Ii4UOFGghCLhCGAjQQhFwhDhCNBCEWAhwo0N/BCEXChwo8FDBS6JNUnBQIwlYKCVIkYBRcKWQCi4UISEkjCcI8QkkZKE5N42wuddtuov2bp+K0xPxPcDmXHMQt5j+8cDzAcF0lreI78hzXmXtB1C7VOqayra7MHH3EHlG3YH47u+KrVD+VmB1Vyjj55MnYKNZY+7gMnIv/JWYdlQ4MRxtaBgAclJjOcLMxgLbJyVLp2lzwr6maGgNaMuPgqWjaS4Y5ruvZf2WHuorpdoyOIB0NO4dPF38lKxpdsqsrwwZKiaB7OZ7kWVVXHwxcwHjZdFuel3UdLxUU2OAbsLQAVpMx00Ya0BrQMADZYTtB7RaDTLIqeWSSasqfVp7fSRmWqqT4Rxjc+84A6kK1ytY3VZzXSSv9VbCw3FtZaGTSvDTGCJHOOMY8VzjUWqb52q1s2nNCSuoLQ13dXLVJB4Yx1jpfvyY+0NgCCCMtcm7H2eaj13G2XVkjrDYHO4/2DSzZlmHQVEg2PmxmwzuXdJoA7X4Hac0xm09m1GTT110oz3ZuvCcPpqVw5Q5yJJx7XrMYfaeGnmcAD1+J/QJwDI3EjXHXoP1PcF5trOzK0a97VdJ2awUTIezKwPqeCqfhxv9WzhFRO5wH1kTHGKLiI4clwjOMgdP1Zeu+uMr2ky4dwRt8StBcX0VDqnU1woIIqWgtNNFp62xQtDGMZGOOUtA5DvJAwj/APBwuZ3a5mnJlB4qhwLYgfs+Lis+QYOFqtdzYPh18ddfFVGq7o9rXUTZOKV/rVMgP/CP9fqub3esHEWMPqjwV5e60QtcwO4nuJLnE7nzWLrpy5xA3JUYVkJiaUvdwt3JWT1LqFsUMlJA/EZ2lkB3f5Z8PzUzUN5FFE+mhdmU7SPHTyWLlPC30iY8/wCqYev7x8h+assb1Khe7oFGl9TilmPCcZwfshVdvgrNQVrKaigmmdVTNZT00TS58zzsDgcyScAdAduZUh8FRfKyGip4ZamSZ4aynhaXvmeeTQBuV0xuobf2C2qrgt8kNw7R52GGoroiHw2NpGHQxO5PqCDh7xszJaDkOzI53KMDUqMDqdlTa4o7f2JUkdqpporhr97eKtq43B8NnBH9VF0dNg+s/kz7O+4wXZxo6q1zqB7DI6GigY6prq94JbTwjd7yfHAOB1Plkirt9ruGsdQQ2+kBqa6reXF0j9hzLnvceQAySVtNO6xprvqii7ONHuD9KwuNTfLxw4kuz4xnA+7Bx8IDftDOTucsOWjA36lOBBIJ26Bbm5zx0dhhhpoDSRVbzVinPONmA2Nh8wwNB8wT1Wa0tB+0dd2KEjiDq+HI8uMFXWra7v53uzsRt7uirezp7Wa7ts7vZpzJUE/wRuf/AOFMbtlSO3VFqm7Gs1Dd6jYiaqmkz73E/qshcXB1VO4HIL3EEdd1PlmMgc5xyXblU9Q/YlWRooXaqNK/fCF0po6fRsNW55E9bcZGMjB2McMbfWPh60zh/dPwYkeACSeW6Z1ZN3VNZqTl6Pb2PLfOVzpt/P60fJShRlZ8TcFxt7/uVUTv+ILb3Y/9M13/AHzz+K5xcJzFTOlHtRkSD4HK6Nd3A3mrI5OfxD4jKmUQ6phvtBZ3VX/rO3n9135haFp9ZZ7VY/p1Ef3X/wDhShBWSodqZw/7V/8AzFN1GeF2OeE7SbQyDwmk/wCcpE3NO6qI7K+vbuOtEvSaNkg9xaFGpp+6ka7oDv7k7XP72gtUo60/d/FjiFDB3wjokO6sahndznHsu9YKbRD0yhq7ed3ygTw/94wH1f7zXP8Ae4MCgtd39K0/ajOD7k5C5zHNex7o5GEOa9pwWkbgjzBSdE9QYx6wI3ClRc1ZVlA24wSXGkjaxzDmrpWDHdEn22j/AHbv+E7eBMBreSbnKeArikHFRke9KiyCk0H/AFcj3p5jfWUZUgUqIbJ0HCZa7ASZaqOnYXyvDGjq4phT1KBwotfdYbdGXyvDPDPM/BVVTqEyNPozCGf714x8gsrcY6m4TFz5Qxni71igDJTS/GykXrWMtWXMiJZH7+ay1Rc3Pdjiy49Bups1Pb4v62WSpcPstOB+H80iOt7v1aOjji6cWN1OABsqrsuOpUeCkrqkghpjb95+y13Z5Qwft51fcJidP2nhfcJekr3bRwM8XOI38s8lDsGlrpq2o9HimLM7vmc08EYzz/y6rq0ugrVBbLfbTN3NroSZGwEgd9Mfamk8XdPIbBdXb+ErpfIC+BmGHTmcQBj3rqLVw/XXAdtGzDB1JwCf0TlVfKm4V1Xfq4gXGsHDCwezTQj2WtHQYx/5k5yc0pqpXPJPdt9nPXzW6rLDTXWDEU2Qebgc5Waq9OVdLPju+KIcnLmb1wNd+H4fSahgdH/U05A81p3GxV1AztZG8ze8ajKhQ26pq4hFTxOkc8+sW9AtZEH6asIijAFfUERx4+yT19zRv8vFFpLT1Z6a6YyER8Jc9zhhoHM4z0A/NXJ7q4xd4zBIzwOP5ra4c4VtfFFulZTTuFYzXkOOU+XXXz0WhabRTXGmf2TyJxsDjB8lQ1dXFZ6Gmpmgu4W8MMLfacepPvO5Pmp1mtWYzU1YD6l46cmDwCYp7D3VU6WR7p6lx3ldtgeAHQeSupiKemxjJxyC1+A7BDTzVlxvMILKZpBa4ZHN5H96q9YLeyKSeqrmerENiOqrZpY45CQ3Dc4a0c3HwCs6N5fAOLHENiByCq+5IeZH4MpGB4MHgFOtkjSHsac46qb8NboJOKZSQAJg4YAwB1AA92E/his57q4kYEgOnzVgyobEwkkNDRzOwCgyTyXkmOMuhoh7cnJ0v7rfBvmm56OSoqzx5dCNw0bD4+KntDg0ABsYHIc8LgbhwldjdKimpKZ7g17gDg4xk41Omywqi0VjqqSKKIkBxG3ig2IRMa1rQxgGGtAxgJ+OR728OcMHzKjhoBJ4i5x5klOxnovYuJ7VWN4Ap21rOWWBwyPAkj7hdnc6SZvD8Ynbh0ZHw1H3RygB23JCOZsLS57gxrd3OJwGjxKJz+9e5kbTIWDLy0bM9/h7uaudJWu33CvfNcm97DSt71sB9iRwO3F4gc8fPZZkEbr3+HJiaMvgeMf8w+ziqkbTXcNljdXRu+/91SgTVXdSmN0UD94g72nj72OgPRaS90kFq0/SxzPDKmYgsj+07HM48OW/81U3S8vnu0tZwtmk4vVDvZ8sqqfJV3WtfM97qmY/1s7/AGWjo0eAHQDYLSuFe3hQ2iyxHHIWvk8yf/Knq6kWh1HQMOrSHO96RUUc1dNFFDgF2xkdyYOpWxtlBTWi2HhcIaWFpfJNIcZPVzj4qlslO+quUUDI3yvkPCGMIBcfeSAPmuxaZ0DAJYay891VSxODoaKPJp4COTjneR37zgAOjQRk+f8A4sUfovEb5R7MrWu+XKfosjimARXNzx+YA/b7Lk94NVJFSVU8L6WnqsmhhlHC97R7Uzm9Ac4aD4k+ChiPJa0D4K51lff9qNb3WqBLqald6FB4Yb7RHvcXb+GFBgiyeI/BeNZXIYyuu6OhEGmqBgx7BOwxzJP6q2llbDG573BjGguc5xwABzJKhWGPubJQNxg9wwkeZAJVzaIRU3OmjcMtLwSPEDf9Fiu9Z+PFe7RPFLQtcdmMHyCi02qL7qyGKPSNn9GtxaAL7fGOhiLce1DBtJJkbgu4G5HMhWuney23Wy6x3q7VM+ptRM3bcbiARCc5Pcwj1IRnf1RkZPrbrakOleSd8lPx0/UroM40C8Ec4uJceqbawuTjYvFSGxgJYY0dEmEzKYDVkdb12ZYqNuQGjjf4EnkP9eK2/B5LlN1rPT7jUVHR7yR7uQ/DCp1b+VnL3rsuFqQT1hmcNGD5nQfdRQ0uIABJOwA6re2K0C3UDQ5uJ5AHSfoPhlUOj7V6bXmokbmGDfcbF3T5c/ktw9iipI/zlafFFxLnChjOg1d9h9/goL2ZCYczfwU97fJRns3V4rgWqE9gAWNuM/pNbM/ORxYHuC19zm9FoppORa3b38gsXTQmoqI4h9pwCz6o5wwL0HhaFrGzVb9hp9z9lf2uDuaBmRgv9Y/Hl+GFIOyde0NGByCjyHAVwN5WgLjaic1Mz5nbuJKbe/CjSTYSpnbqDLKBnJQSmtalvm80zJUBvXChVNc2ME5wAsfeNVVVTK6ktMDqupOxcDhrfNzlGT0VlsZOvRam5X2lt8LpamdkMbRlznuDQB5k8lg67tipJqs0djt9XfawchSsPAPMuwTjzAI81Kt3ZOb/AFLavU1bNXkHLaOJxZC35bn35GV0i02WgstK2noKOGkhbyZCwNHv25lSNZnUqJ8rW6N1XK47N2gat/69WU+mKR3OOnHeTkeZBOPeHA+S1Gl+xXTdFL6VW0z75WZBdPc3mYuPm0+qevME+ey30TAQA0D4LA9s0lyt2m/27Y640V3s/FUNfkFskJx3kbmnZzSGg4I5tbjHNTtwCAqj+Z4OCunUsMdJAyGCJsMTG8LWMaGtaPAAbAKPdaz0akfj2nDhGV5ptH0xbtFStbcdPUdRNjBlp5XMafPhPF/zLsGm9XVut9OUF0raNtv9IaZYqdpyQw+y4+8bjyIS1LjDGT1Kt2GjFxrmNOrW6nyH6nRTliO0+tmo7dH3dR3MZyXDlxfFbnAXDvpCyP8A2taIu9ayLuHu4XZIzxc8ZwsqgGZwPNelcVODLVI497fqFbdlHbBY9ESXa3Xqv7iCV7aqBwY6TLiOF7fVB4fZa7Hi5y1df9KvStOD3Bqnj74gJH44Xl91JTvPE6pjb58OU3U0lBJEW+klx/hIXUGMHqvBvSD3Ba/tW7e7v2mcdHE59s0+HZbRtd68+DkOmI577hoPCDj2iA5F2H69sHZx+1rvcJS671JbTU8UcT3GOEHic4kDhw53DtnP1fIZGcC63UoJ4Z/+FI/Z0Ld2zb/wqXkBGAomzYdznUr0LX/SqoI2ExRVMuOTY6Yb/wCJwWMZ2+ap11emW+jr6PStI7d87w18rmZ3ALhwl3UBoaee+y5caAf775tTT7Yx43fn+6gQ42T3VJcRnbwXtuyVkVbaaV0L5JWMjbH3kr+N7sDmXcyT1J3ypwGVyj6NMHo2g62MPLmi5ScOeg7uLYfj811lcbVN5Z3jxX0XYn9pbIHD+kLh3bv2jXfTt/pLTZMU1S6BkprIOMVJc57gIgQ4At9UHhIOcpGmtW9p1PSRvqbvba6XGTTV9MOFvkXRcJJ+fxWc7VtStsva1cKuS2itZFFFDHI12HRjgBcQDsSSSOnLzKs9La9tN6kbHDUCOYnBgm9V4+B5/Bb0bXMhYOXpuvJ62SOouVQXSHPMQADjbT7LoVD2rX6kAF20qZmt9uotNU14P8Mb+F34laW1drVguBayaoltFQ447m6Qup3fBzgGn4ErLxsBaC3GD1ToAaCHbgjBHimZHck7Ejc58/7LqUVcyRrXNcHtcMgg5BHiCnW1hxzXM6KvkomtbA8xMHJo2b8uSv7fqQSkNmAa77w5FHME0xEbLWuqGv67qPLGHHiYeFw5FVU15p6GnkqKqojp4GjidJI4Na0eJJVjHIHY3yEucqMt5U/FNxngcMPA+aqdT6Tt2qqJ1PXwNft6sg2c0+IKs3NbIN/eCOYKXxbAZynDIUbsHQ7LmtXVXTSdA+1amon6r0qfZqA3iqqVvQnq4DxByN98ABCipqattwltlY3U1gds0tdmqph4EHBdjwIDvIrpEgZIwtcA4HoRlYLUHZfBNXPudgrJNO3k79/TAGKXriSM7OH64O+FMHg6O+KpOiI1Zt3LEal0EGH0mlIex/rNeG4aR4OHQrFTUDoZCxzXQyD7Ll05mva3S87KLW9tFsL3cLLrShz6KY8hl3NhPLDvAkkBWdz0rbNRUjKimfG5kg4o5oCHMePEY2I8wn4O4VM4PgVg+zCvfbNX00b9o6lroXHO2SMj37gD4rui4Zc9J3GwVDZmDvY43BzZGHljffwXaLTcG3W2UtYwACaNr8A54SRuPgchYdwjw4PC9U4Nq+aGSkdu05HkdD8D9Ud2oW3O11lI8BzZ4XxkHzBC8wVtsfA0yMDnxt55HrM8nBeqVwHU7p7XqW4wOaHMZO7hBA2YTkbjyITrc7VzVBxpAC2GfzH3H0Kwx8UnOeS0c1PQVm74nU7zzdEdj7x/JQpbC3OYqqNw8HtLT+q3MLyksPRQYDikn83s/JylWO0TX670lvp/62oeGZxkNHVx8gMn4JTbPUtic0OiILg4nvG9OXXzK672QaONqo5LtVBpqJ8shAw4Nj8QfEnPwA8VFPMIIi7r0WtaLY+6VrIMeru7yG/x2W6sdohsNopLfT/1VOwMBxjiPVx8ycn4rlnalrFt6qf2TRyh1vgcDUSsP9bIDsweQ/P3LXdous2WCj9Cppf6dM05MZ9aJvj5E9PmuKvfnDWtDGt2a1owAsyhpy49vJ7v1Xc8UXdsMf8AC6XQAYdjoOjR9/h3pLjkkn/yUyxWp19usVIHGKNzS+WRvNrBjPD5kkDPTOd8YUL1QMncrX9nNOJ7nWTY3ZC1oP8AE4k/8oW052ASvMYmhzwDstBbLDSwajgpYoWx0sUTXBg6tBcdz1y4nJPPJW8dO1gJJwFQUdBJJfC+Ib9wxpd0A4nE/or+WxslZtNIH49rbHyWa+oZEcOK7GjtFXXxl8DfVHfpnyUGrujY2HB+Ko625HhMjycfZb1cU5dYJLbK4VOMfYx9oKljjmuNSMDiLjho6BP5+cZCznxPheY5BgjoigpprrVhrd3uOSejQtPa6RlJPUQs3bE1rcnqTkkqVabbHQw8LBxPO7n45lFCBHdKsfea134YQBhMTk8DKiKSKRodHI0tc08i0jBC4c6jfQQS0EpLpqCZ1M4nmWtPqn4tLT8V3R3Ncx7RraKDULaprcRXCENcRyEsf6lpH+FTxOwcd6o1keWBw6LNW/8A6y33FOXY/UD3pqh2qm+4oXZ31YHmrnRYR2VaNlIik5KPnCdi5NPimqNWkLiADnorettkFVTRskYA9rB645jZU9M3jdG0c3ED5rQ1Dsk+A2UjHOYeZpwU/lBGCsvUWiaiIP8AWR59to5e/wAE7BufgtHGMnBGR4JE1jjnJfDiJ/Mjof5Ldp7gD6s3xVSSDq1UFdN3VK4+Swlxqe8nwDyWw1OH0UXdyMLD0yNj7lhIgamraOZc5bjSHDIVB4xut3ZW9zbQ47YblQbOTVV01S7lnAUi7zegWdkLdpZcMaAlWqD0anYzr1T0xXMLsHPVHcJ+6oZXZ3wmYzuoN+qSKdkQO7zyQhIsrduI8yrtr8N5qrtjO7hCmd570oQvpsXI0jIRtcs5W8JSCAOUEJyUDlGkJY5ITSgggghIggggnBCCCCCVCCCPhR8KTKEQGUpBBKhBBBBCEEEEEIQREZRgZR8KEJGPNDhSkfChCbLUXDlOcPuSBAa6QxAlsIOJHtOCf3QfzPw58hCzHaFeDadE3KpjcWd430eJ4243uODj3DiOfJea4Wh9UxvRvrFdw+kXXimt1lt0eGQl75ixuwHCA1v/ADFcPoDnikPN5z8Oiz6g5djuW3RtxFzd6uGuUmJ2cKC13JdL7Euz8a61IZKtpNqoQJaj/tCfZZ8cHPkD4qu1peQ0Ky9wY0udsFu+xTsrFTHFqC8Q/U54qWnePb/fcPDw8efv7VXVkVFTSzzyxwQRtL3yyODWMaOZJOwCpdU62odLS09tgp5bleZ2ZpLPQNBme0bcR5COMHm9xDRg8zsqWm0BXarqY7hraaKrDXB8FhpXE0MGORkzgzvHi4BoOcN6q+AGeq3UrFcTIed5wOn9lBl1ReteSGn0jCKa25Ik1DXxHuiP/wAHjODKf3jhm3VX+mtEWPQEFXdJZe+rnML6293KUOlc0bkukOA1g8BhoUPWfaja9IVcVno4Jb1qKYAU9lt4DpjtsXnlEzzd0yQDhc215o3UWvrxpaw6tr+Ge+VLpn2KgkLaSgo4Rxyl7hvNK7LGBzvVBceEcnCIvAJ5RzOHwCssjc8DmPK0/Egan96LTU1xrPpETSRUL6i29mMbzHPWNLop78RsYojs5lNzDnjDn7tGBxFdZfLR6ZsbhDFHRW+hp8MihYGMijY3ZrWjYAAYAGwAT1LR09qooKOkhjpqWCNsUUMTQ1kbAMBoHQADksd2w3H0Ps9vDA7hdUw+iA9QZCGZH+JSnMbS4nJ/fyVTIme1jRhudB9z3lcCrb06n0nbRUHFRVh9yqh172ZzpXD/ABPcueXm7OjidO8/WybNHgFe6orPSq50IOI48N9wC55eK/0uscQfq27NHkFkOXQtbg5VdcakkEk+sVl7zcxb4SGuHpDxz+4PH3qzu9wbSRPmfufZY3xKwlVI6snklncSM5d5+SexqHHoFAlxKHVNRn0dpw1gOHSu8M/mVFpLTc9W3mnt1tpJLhc6p3BDTU7dzgdByDQMkk7AAknmVrdG9nGoO1K5SxWmCKnt9G3irLpWv7mit8eMl0sh2bsM4GXEAnGASHdb9pdg7P7LW6V7PJpZY6hvc3bVszO7qrkM7xQDnDBnoPWdgZJxl1nfZVyQ3dV18u9u7JqOotFgrIrhqiRpiuV/pzllKDs6CkdzHg6TmemNgzkFVPwUxnLTwl3dwsHOR/XA8v1S6US3aoAYDw8QbHGObnHkry5mn0lU1V3mYyZtod6BbYXDaasHty+bWO4jnrhuDkJ2AzzTQS/U7Kn1fcToWwTacpZcX+5xg3meM708J3bSNcPEYL8c9hlw5Wv0drcKSC/3bhwXNZRxOx4+s8fjGVyarqJaueWeeR008zzJJK85c9xOS4nxJXf+ymgNt0JbWEYdUukrHj3kBv8Awtb80SDlZjqUsfrSZ6BWWopfrpB4ABRtHyd1V3iozgwWmseD4EwuYP8AmTd+m46iY+LlHtEhgtmpXg7i1uHzmib+RUTR0U7lk3EiAZ54VPUv9Uq0qX4YRnoqOofklTqEqNKx9QDDFvJKRGz+JxwPxKY13UMm1PdzEfqGTOhi/gZ6jfwaFdaSY2fVdoDxlkVQKhwPhEDKf+RYu4Tum76V5y95LifMlStUblWVp72mlZ1cwj5hb8VHpUNFUZz39NFJ82hc+BytjYpu/wBP253WNr4f8Dy0fgApQolZg7hUup25nondMSD/AJVbgqu1G3MFG7/tSD8WuP6BCFhqM5bUDwnk/wCYo5d8pNGeGavb4VT/ANEt/Mp/VM6KxYS/TlI//c1EsJ/vYeFF4sEFP0Du8slxh/3UkU4+JLT+iinklCQqwoZPXcw8nDCkxHDsKrp5OGRqsmnLs9UiUKfSVc1BVMqaaQxTM5OG+QeYI6g9QdirT0Kkv31tvY2mrub7fnZx8Yief8B3HTPR2xaTmurRJKTDH4lvNaJml7TRlvfT5cPPC7a3cFXS4wipwI2HYvIGfuuxoeGa+rjExAYw7FxwshS/VxuachwOCDzCeMjWDc48lta6wUt2jMjX8UvSYH1z/Eevv5+a5vqKSSz1voYYZal+7W8gR4nwCpXvhW42NrZagBzDs5pyFDc7DV2lokmALD1GoS668mIHgDWDlxv3+QHNWVo0TU36COtkqAQ7l3uTj+70WKqaplLIDI70irPQcm/y/NdW7Na19VYnCQjiY/OB0BWlwRaaG8XM01e0ubykgZI1Hl4ZVrhehpblXdhVjIwSNcahNw9mtISHVNVLMR9kbBWNPoixwv4TSsmdzAldn8Fg9X6kulLeqqmFZI2JrvVaw42SdB3eU6kg72Z7+8yz13E816FSXnhyjubbbTW4A8/IXOwcHOM68xPxC62nutlp69tDDRAHm5S52DjXHXP1CZ7ULBTUV4ZJFA2ON7BhrRgbLMWWzVl+ukFvt8BnnkJOAfVjaOb3dAANySuxa20pJqU0oZNHTMZkSzybhjfIDcnyHzCXaLTQWOnbQ24Ojp3uzUPfvNVEcjI4cm+DBt45XAcXW9sPEzqZow2RzT7nYyuZv1vay9uixhriD8cKXbrVDpSxCCkHfPaAXSNGDK7HP3fosvJZ6671Jmr6ktBPqwQ8m+GT1W1uoLaUBvQgKFb6bvXgdOpW5+ItfNQ1ENppyWRMYNBpn94W1xdUSQTR2+I8sbWjQdVJ0nZ2w08kTS4lhyCT0/1+atwO4nHG0EA9VLswbTVTG8IDXerj8ku9RBlQQ0chlxzyyTj8j8llfh/eJZbg+x1h54Z2nQ64OOnml4UrnvlNvmPMx4Oh70zfbgI7fHRRuHpFW3vJi3bu4s7M97jnPuPkqOMOhcCNh4J2QZqHvccufjJPlsB8Et2CNt15JWsqOGr7LHRuLXRPIaR56fJc9UiS317mwnDmO0+ydZiQA9VEq5D3oaASegUlmIY8pTMPw7C+sr9SVF+sP8OY9sdZIxr3NGnNjp716zcIZLjb/RQ4NmcA4jvUantTqgh02TnlG3r7yrKSgNLCDgNH3RyCuLXBCWcTNz1J5pd0hBgdjbZfKvDU01k4jpzUNLXMeAQemuCvLraX0NwiLxgtcAVQxRGV2AcJckAZsCSUVO/ged8DCOkFZf53U9kpxUuaeGSslJFPEfN32j5NyvXvxI4nvlnvLqOmnLIi1rhgAHXfXGdwV1XEtzuFJXGGKTlYQCMY+vmos72U/CZHhgJwA7bJ8Pep1ttgu1YynfM+GM5Lu72c4eAPT3jdaSh7P6S0xPqamV1yuRGDUzDZnkxvJo/HzWdpaz9kXDviwvEZOWA4z5KThKuqOJOGLrQ1UhkeGlwycnbI38QFJZ5Zbha6unncXOxkZ16Z+oWputvorNY3DDKWnHqtYObnH8SeviVjI5nxB3dvcziGDg4yFDu+p5rzcmNk46urceGGkpmlxbno0D8TzPwWkodF3ioEYno3UxdjiD3DIVf8Kr1Q0FLWUtylaxmjvWIAO+cZ9ybwrX08Ec0VQ4Buh1WdaHV1a2jp4Zq2odypqZuXO956BdIsnZdVOohNepWwRhuW26kdsPJ7xufcMDzK2OkdNU9ko2xU9OyIu3e8D1nnxJ6/NaeSEGIge5eM8S3x13vMtfnQu08ht8lx1dVOrax9Sep08hsvP9Kf2PqiPhHCIpwAPAZ/zXWtcav/ANktGVddEQayVogpGZ3fK7ZuPHG7j5NKU7SNC6uNR6Kx0zjkucMlci1lqJutNWD0d3HZrSXQ07gctnmO0kg8Q3HC0+8g7ro+NuKaXin0SSKMtfEzlcTjXbbHjn4rQvd2juZiLGkOaMEnr+9VEs9CKKhigLuLgb6zvvOO7j8SSryy2K4avvcVktLmxVD295UVj28TKOHODI4faceTW/ad4Na4ilmqpmup6Wip31tyqniGlpY/alkPL3NHMuOwAJK9F6C0TD2e6VkpjI2quc4M9wrRznm4cbZ3DGj1Wt2wBnGSSfL9hzFc8AXuETeqrYIG00EcLHOcyNoY0vOXEAYGfNaLR9J39fJL0jZj4n/yKoVudF0ndWvvTuZnkj3Db9CsenbzSDK9g4gnFNbngfmw0e/f5Aq+iiDQnms3S2MwlrcXihSA1KAwlcKAGEJFDu1R6LbKqXqyJxHvxt+K5Ouj6zn9HsMoBwZXNYPnk/gCsBbqQ11fT04/tHhp92d/wWVVnmeGheq8KMbDRS1DtAT8gP7ldD0xQ+g2SnaW8L5B3jsjByf8sKwcM5T7WhoAAAA2AHRMv9paIbygNC82qJ3VMz5nbuJPxUZyYkCkPGCmZBzSuTAs1quYx0kcQ27x2fgP/MKr07B3la6TpG3PxO3805qqfvLkI+kbAPid/wCSm6bp+Cgkk6yO/Af6Kzf8So8l6R/sHD/jJ/8AL/8AhU2QbKHMp724UOdq0F560qtqXYCoq+sEYJ3cTsA3cn3K5rncwFWx0XePLgMk/aPRRHJOArkeAMlZ+W2T3aQelSGKE8oIj6zv4j/JXlsscdHG1rImwsHJrRj5qzhpWQDIGXeJTvNTMYBqo5Ji7TosrrftAoezl1rkuNLM63Vj3RPqoRxCBwALQ5vMhw4uX3eRU2h7TdIV1O2aPUFFwHfDpOF3xad0zre3W6/Waa23KETU8owWnmD0cD0I8V5Z1f2W1enZ53w1sRtzQXNnmfwkN8HDqfdzUwYHHGcKq4vaOYNyPgvR+qe3zS1hpZBS18dTKB7TPW/wtG5PyHmvOHaF2v3btC46VpdRWckEwg+tMQcgvI6deEbe/AxhoqF05BI9X7zhgFWUNHGwDPrnz2HyV6OnDTk6lZE9c5zezYMA795V92X6HOt9UQUbmONDH9bUyNJGGDoHYO55fNeuJ5qe2UUkshZT0tPGXOOMNYxoyfcAAsV2OaS/2Y0nFNLHwVtfieXbdrceo34A58i4rI/SB7QIqGGLT1PU93K/ElZgkYbj1WeYOcn3DxWHOTW1IibsP2SvVrZGzhuzmsmH8x+DjxPst+57te5dbsV2ZfrNRXGJjomVULZQx/NuRnC4z9IizVNddbXUd2RSNgczvWjID+LOD4bYx47rf9jFxZdOzazysdxBrZIjt92RwH4ALlv0kagU+rLWQXNlNFgFpwfbd1TqBrI60teNBlO4kmkqeHmzA6uDCffglcnqNPztyWzNI8zhVslJUwnBeD7nNK1dptXp7GuqeOoc77DXnA/wrQ02gI52hzbY8DxcXD8yule6MH1dB4rxVlPI/Zcx+ubz9b4pTZpAR6pHuct/fNER2yASujZE3lwufufcsrPboxksa7HjlNa4HUIfTvYcFV4rnD2mEpxtdGT63E33jP5I30W3M/EZTMtC4tOHDYbbKQPKi5CvTH0cJGyaHrSwgj9ov5f91Euqrkf0Yx/8wa4+NykP/wBiiXVLjWsttvqauT+rgidK7fGzQSd/guKrMuqH+a+kOHyG2mAno1eUNX3cV+rr3O5oljkq5eHIx6gcQB8gFRVFuoLgBt3UvMEbEHyP8kz6c2tkfKZO8e9xc5x5knmUl0rRkk7Bds0AMDe5fOk0hmldKd3En4lXto1jqbTUbWU9Z+0aVv8AYVeXEDycN/nstlae262zYZdqSptcvIuLTJH82jP4LljbnM32cFvg5L/aU8hDRDGSdvWOyrvhjdrjCuQ108OgOR3HVd3g7SdMvhErb1S8B6Ofwu/wnB/BV9y7ZdP0EDpoHVFc0HAfFCWs4vDidj8MrkFPxmqbDR0NHVXA/wBq8N7qLzLs4Lvif0XStBdndtr7pTVV6ucd/uLnDhi7wGGLyDevyA/dVF0bGakrbgqKqqcGxgZP795Wg0jZ712tzU91vjJLbpeJzZaa3tOHVZByHP8A3PlnoBzXauI+KRHG2KNrGNDWNAa1o5ADokVNTDRwPnqJWQQsGXySODWtHiSeS5uWd8rvDuXtdBaqe3xagF3Vx3/sPBPiRw5OPzSm1EjeufesfX9q+kLa7hnv9Hn/ALJxk/5QVqLJO3UNsjuFAyaajk3jldC+MSD7zQ4AuHmNkgEzdRn5pz5LXN6r3Rn3tUw1rGMe+QOAa0k8DS448gNyVIpw+pp2yOhfFx7hkow4DpkdPdz8cHZV58OSv7Ww1VG1x3IJaSrtPO5/quXGcQWiKjYKmnGATgj7hVVZb46yCWCeFk8EjSx8UrQ5rmnmCDsR71za4dkb7JUPq9IXWbTsziXPonjvaOR3XLHeyTyy3kOQXaDRgDlumZaZuCOHbwK0mlw2K4Uhr9CMrhEmt75p1rmar03KIW7G42f6+Ajq5zCeJjR4nK2GiNV2TUNEW2iugqWty/uozh7ATzLNiNz1HVa+52WOricI3dxLzbI0cj5jkVhKKiltuoWVTaOmjnc8wVrmxBkuDyIcPaGeE4PTqoqk9rEWkarZsb/Qq9krT6p9U+R/Q4PuWyXGe1u2Pg1O2qY0hlRC1xLfvD1fyAXZlgu1x1ZS2uiqqOmhquGUxyRy7HBGQQc4Hs9R1+eXRO5ZhnqvROKKft7Y8gatIPzwfkSuPl7nbOPxIROErfZIf79lJffaOQf0601VIerqciQD38kqE2qt2o7xTtcfsVQdFjyy4YK6bVeFYB2KsdF6dm1Re4qVzC2nZ9ZO/ceoDuM+J5Bdxvl4ptNWeasmAbDC0BsbcDJ5BoVVoHS50xZ+GfBragh8xH2dtm8+m/zKwfarqd9ddzbWOLaSlIyC3AfJjc58s4+axH/65UBo9kL1amaOGrQZ3j+dJ9eg9w1PjosdcbhJeq+atqqkPnldlxLceQHuAACjEQjnM5x/db/mlCRvR4Pkh356BbwAAwF5O97pHF7zknUlN8LOjHuHiSt52YxcNLcJiMF0zWf4Wg/+IrCmVxONlvNFTNodNPqHHAlmeQBzc4ENAHj7CZJspqYZfldPs0QFO6Qb8ZxnyG355Vh5BRrZGYrfTMIIcI28QO5zjdVNPfXu1LPTbmmwIwc+y8f5kj5LlHB0z3OC9/p5IbZSU8UhxnA95GT8/qpeo7Q260HCNpYzxsPXzHxVda7S2kjGW4cRvnmB4LSKBM0skI6cwrlFJuwrluKaMBzKto30P2+/wCb2Y3AGFVVR7m7Ruz/WR8PyP+YVtw5Coq6vhrqljac962EnimafVz91p6nbfGwxjmtJcA0aqw4vWPrA48Csx2j0Xpmlpp2tBlontqGnrgbO/wCFzlItlQWV8rCThxI3VnWwtrLdV07hkSwuYfi0hAdggpz2czSD1C4zRD60HyKRdXbNCO15fFG4+1wjPvTNzdmUjw2WkNlypUPi2UiHaNnuUJzwWuI5KdC36to8ghMVzaGcdXF+6OI/AK1kdk481BskeGPkPXYe7/X5KUTxuJ8UqcApEftlWEB9XKr4lNL+CI+5KEKh1P3VXEYpGh7XdCsladIvFy76E97DH6xZj1h/NX91n76d2DsNgp1GTQ2v1NqmpOG/ut8VdgqJID6p07lVkja86rH1Mxul4c7H1NN6jB0J6lW8AwArf9h088YGOCRowHjqodRbpqF3rjiZ0e3kuigq459Nj3LPfE5nkia7CpayX0u4EDdrPVCn11V6NTPf9o7NHmVX2uAl3Ed8bk+avKFW8X1UbQPBK48DKRndMVM4jHPCEL6gNeltdlRGSp5r8qkrqfB3SgU0HJYOUxCWjBwkgo0JiWgiaUaEIIIIJQhBKA2RAZSkFCCCCCAhBBBBOQgggjAwhCJBKQQhBBBGBlCESCUBhMzSOfKKeE8MjhxOfjPdt8fecEDPmd8EIQAlAGd5jYS0D23jp5Dz/JT6WNseGtaGtaMADomYYmwxtYwYa3kM5/8AP3p+B2Jw37zSfkR/NKE0rgv0kpy7UNuhB5UwwPe45/ILlkIAw0cgMLp/0jYXDVNsmI9R8Dmj3jh/muYR7HKyqg+uV0dKP5LVMD8Y8l6J7Dqm4XTQUFDo/gpxUyyS3HUtRFxwxOyWCOnacd/IA0ZP9Ww5yXuBYuDaG0BU9rutYNNRSS09ngY2rvdbESDFT5PDC13SSYhzR1DWvd0APsO+ajs3Z1Y7fbaSk7toYKa2WS3Rt7yYMAwyNmQGtaMZcSGtG5ISQAgl5OAoKt40iaMu3/8AKk2qyWHs8tdbVCZsOR39wvFxmBlmIG8k0zsZxv4NaDhoA2WFqtZao7V6p1u0VFJYrBnhn1JVxFs0revo8bhsCOT3bnOwA9ZTLdoO5do90huerpGPo6eQSU1mp3E0dO4cnHIBmlH33ABufVa07rrNHRwW+nZDTxtiiaNg0YVsNdKMD1W/M/oqBeyHU6u8dh+qzXZz2XWTs6pZW0EBlrag8VVX1Lu8qJ3Hcl7zud/5ndUlkH7b7ddU17t47Nb6a2QnpxSkzyEf8APuXR2uJOFznslcambWle/d9RqCpYHeLI+GMD4cBUha1paxgwP0CjY9zxJI85JAHxI+2VvZpMZXFe3m+EUFupQ71X1jXlviGNc78wF2Ctk4IXHrhece2evZLqmgie/EVNDLM7yPqjl/eVWodphWqJmXZ7lyDUlY6Iuiz9dIMvPhnn81kixpjmnld3cETS97/AeHvJ2C31NarJ+0TPqyrraaGRpf6Ja42vqR4Al+GM233yehATd41F2c01vqaWm0fcbzROxxi63f0Zzsbji7hmdvAOVZsRdqThaRlAdgAlcDr62W+XBjYonPdI4RwQRguducBoHMkn5krodP2P2/Q1BS3rtRqp7RTTDvKPTNFg3St/jaTiCPxc71tntw13CS0ztsk006UaM05Y9HuIdG2tpad1TXd2Rgs9Inc9wBHPh4VxvX2squQ1M0tXLV32vcAKmpkMkjnOzxSOJySQ1p3PUBThnIcdUxxf10Hz/stD2xdv1fq+ibp63U9PpzStIf6Np22HEEe+eOZwAMsh5lzuuTgEnPC6mrdVS5J4iTgeASKyQRuMLCSG+04nJcepPmkU2A7idjHmpQMKtnuXU+zGxigtFz1ROAILVEW0xeNpKyQcMfv4OLjPhhvQrkOsb+L1XRQQOJoKJpipwTniycuf73Hf5LsnbfVjQ3Zbo/SkBMVZX0/wC1a0cncUgw3PuBkb/cC89eyFHGObLyrD/VwwJ2mpZbhVwUsA4p55GxRt8XOOAPmQvUVBSxUFA6KH+opomU0R/da0AfgAuDdkVsF015QvePqaIOrJDjlwDLT8Hli7076jTsDz7UuZD8f9BMlOSApIhgErI3SXilefMlFbpAaS8Q5/rrbMPfwvjf/wCEqPXP4pnBFbT/ANJNZz7yhr24/wDyWRw/FoSN3T3LLVUmWFUkz8lWc8gdGPHCqHnn4KVRFWemX9xXXCozg09sqnA+Bczux/8AKLEVee4f7lsLRFLLR3wQtLpJKVkLcfvTMJ/BqTD2e1lVF9aRFkHmV0dssdxuw/1OEuHfjT47LRpLVW3An0aMuHf0+K5+DutRpGTitVVD1iqeIeTXNB/PiVlV9llRGzihqGyP+7yCqbDSVFnvFbR1DSwywB4z4sd/+mp7lw/c7QA6thLQeu4+IRXWeutwDqmMtB69Pir4HZRrpSTV1LE2CJ0jmyA4A8iP1U2kpzVTNjHUrVTCl09b+8cwZbjlzJW1w5w0b02Spnk7OCP2nfotGy2M3Nr55n8kTNz+i5hRdm16nr6t5ibDDJJxNL3YPsgcleUvZG9zgaqua3PSNu/4pq79pFVFcH08TOBvAHDJxzz/ACT+k9WVVdfYop5BwP2wuxt9Pwb6XHSsa+VziBkkga+WF0FFHwx6SynYHSFxxknA+WFTXzTcemr0+ige57Kujkawu+8BxD8WrJsk4mg9Cuo9qEYpn2q442gmAcf3c7/hlcyqofRq2oh5CORzR7s7fhhcVxbbo7VeZqeFvKzQgdwIBXK8SUTLfdJYIm4boQPAgImOwVobBCyruVPG8gNe7GT0WbByrOjmLGsc04IHNcpBI2GZkj25AIJHeAdlz8L2xyNe4ZAIOO9dcvV2htVtEdPIzjxwgNIOFgp66ad5c6QklQBVPkILnEhbWh0ZBPStlfWBnE0H1QDj5r0qrqbrxzVctCzlZGB6vNgDx6Luaie4cW1HLSN5WMA05sAePRMaKurzdPROJz8tLnDnwjoSq7tWqG09TD3HCyZ7eGR49oDp7ls7JYaKx08go3GSV+7pHuyXHzK5xr6xXb0w1MrHTtefVEeXHy5Lr7zb621cJ+gTAyuJySNQwA53XUXKiqbdw96HIO0OckjUNHmsQ0cLjjcnmT1XU+yeozFNEeoWKtmia6tIdUPZRRnofXf8gcD5/BdM0Np+msrZWwl73HcySOyT+gXnPAchZf4A3rn6LjuEy5t3ix1z9Fl9a6erbpqJxpKcvDmgOkceFjSPEnb5ZPkp2mtIUlkqYqmqn9OrGnLWRZbCw+PQu/AeRWnvRBrMcxjKhZA3GAsjiOX0biGd8f5ZM+/P6qC7ARXaZ7Oj8+9aO5t7yjJHTdUdOeB4cehV9EfSLeOuWLPvw1xC7z8R25qqK6xfnYD8NfoV1vF4/n09cz8zR8tfutBUM9Io9t8tyo9FI2HzKbtte3HdPI8ApT6XD+OM7FXeJLa7jKggvFr9aRreV7ev7B+StXekPENNFcKH1ngYcOqlyV7aWF0xyBGC4cIyT5AdSrK7zFggp37VZaJ6oA5DXuGzM/ujA+R6qno2FlZFLIzijp/rWsJxxyfZ+A558QPNI70xCQyS97O9xe9x6knf4LG4R4aqbRWi+XdvZRQgn1tMkj9+9Q8PWma3zGvrhyNaDv1KTK7MxxyCEcgfIGN3I3J6AeCiOlkklEUQ4pn9PujxPgry22GZsOQNs7vd9o+S87tlVQXnix1xuEgjh5y88xxoDoPHposmklp6y6mpqXBrMl2vyCKmozVuwdoxzKs5bV9SMAMA5AKbQUIpmtDsOd5KdK1rIy6QgAbqLiXi6ep4jddKCTAYcMI7h9im3G6ST3J1ZTuxy6N8h+qy9PUSUE2OnUKbX3WLu2M4XzVEv9XTxNzI8+Q8PM7KQ23VN1m/o7BBCedS9uf8I6nzO3vWksmnaa0td3TC6Z/9ZNIcyP8AefDy5JnFPFlJxC6GrZS9nUNxzOB0djwx37HKlud1juZZI2LlkG5zv7sLI0mmJ6yVjKymHcEgyROdzHgcLo1vgjpaaOKKNsMTBwtYwBoA8AByVHqPUdn0lT9/c6tkBIyyIetI/wDhaNz7+XiVR0sGte0zDbbTv0pYX/8AttWCKiVvi1o3GfLA8HdFg8ScS1nFM0dRWNa0sbyjlBGm+uScqnX3OS5StfMBzAYGPup+ue0e26ZjfTRvbV3Ll3LDkMP72Py5+5ZnT3ZzqjW0oq7gX2O3SniL5WYmkH7rPs+848d11XRXZHp/RHDPFC6vuY3dX1mHP4upaOTevLfxJWyxxFc1BXT0rXMp5C0O3wSM+eN1QaZGg4cRncA/VUGj9AWXRlIWW2ka2Z4xJVS+tLJ73eHkMDyVy+ha52cKUOSWCPBUeY7qItGMIU8AjCdwCk8X+srJa/143SdK2loQyovtU0mCF27YW8jLJ4NHQc3EYHUhmpKbsqDtd1u6hjfpq1TFtzqWA1lTGd6OFw8ej3DZo5gZdt6pPKHTU1koI2NYWws4YooowXOe47Na0cy4n4lJqqkUTjxPmuFdVTZc4NL56ud55Bo3c4nAAHLYcgu09lnZI6xTw6g1G1kt8AzTUTXB0VAD5jZ0pHNw2HJviZhgDw+qizr4/RTexzsyl023/aG+xtOoapnDFTkhzbfEfsN8Xu+07+6NgS7o90k4bbOT4Y+Zwja4uO+6jX54ZQBvVzx+qhmd6pK1rVD2lbC3/eHyOVnQCTgbldTtlL6JQQQ4xwMDT7+q53YaX0y700eMtDw53uG/6Lp8Y2Vajbu5dTxfUZdFTjpkn6D7p5reSMBGwbI+FaS85KLBQwUpBPTVi+0OpIZR04zuXSH4bD8yq7QtF6RdnT9IGE/E7fllNa2qvSb/ACtByImNjH5n8SVf6Ape6tk059qWTHwA/mSsgDtKny+y9TkP8P4dDerx/wBxyfktMRhNvHNOOCS4ZWqQvLwosoUeRux2UtwUC5S+i0NRLnBYwuHvxsmO0GVYjaZHhjdzoue3Of0m4VEnQvOPd0Wvt9N6PbqePqGAn3ncrGUcPpNXDF0e8NPxK6C5u2OWFm0o5i55XoXFLxDFBSt2GvwGB91ClCg1R4QVZSt2Kp653ESFfOi4FmpVZIwzSeSebGGBKYzCWWJoGNVO53QKLK4hri0gPweHIyAemVyW+ay7R9JGR9VZaG9UTScVFvDg4D95pJdn3DHmusznA35LKam1LS2amfLNKGMG2+5cfADqVM06qM7b4XD7v2/3CrnLn29rXN2McoLS381gr7qiv1bUtnrpGuaD9VTsBaxvnjqfMrRa41UNRyyVVRE2K2RuLYYRgOqH9ASOnj5csrFUsdTVTlsMfeTO3cWjZvl5LQiYPawsqqlkwGA6HwT7gyFnFI7GfmVsuxrS3+2WrmvkjItlvAmmIJHE77DMjlkjPuaVW2js5rbg4Pna9/F9kDH4r0hoHR0Gi7CyjjYBPIe8ncDnL8Y5+AA/NQ11QYYsDcrZ4YtP8QrQ94yxmp+w95+QKl6w1RTaO09V3Wqy5kIAbG3m95OGtHxO/gMnovHVzqKi/XSruVY4SVVTI6WR2Nsk528B4DwXWe3jV4vt9isdM5xpbeeKY4IDpyMY8+Fp5/vOXOaehL8ABUKOMRM5juVtcTV/p1V2DD6kenm7r8Nvj3rv30eZjJ2fmInPcVkkYHhkNd/4lhfpJUgqdVWskE4osbfxuW57BIjTaeuMJ4hiq48Hluxo/RVXbtbnVVztUuMjuXt/EfzVWN3LVkrfq29rw4wdwb8jhcY0zJcNO1/pNBN3T3DhcHN4mlvgRyXZdLUOoddXS32G3Oa671o4nPaz1aaLODI4DcncANzuSB445ZcHNs1DNVPAPdj1W/ecdgPmvoR9BXsnh03oufUdxa2a/XF4fM9w3jJaC1nXZrXBoGcAlxHtLaZ/MIyvLZiKdh5d/wBV5t7Z/oj3zQTYa6lvNVeqgxB8lPWNHrnGXCMj2eRw3x5nqfPFyDoI2ue3ha7drmjLT/I+R3X1h+knLQ0+mKaSeRjZw9xaHEA8ONz7v5r5x3az09Vq+6QwcJpXvE7GhvqtLieIAfxNLv7y0agBkTZWjHQj7rPpg6ZxY46nYrm9HZqmtYH8HcxncGTmfgpTrAGsdxOe5x2DgMNBXRo9PsY71wXHz5Irva+K2SNY0At9YBo8FkGpJK2RRNa3XUrWfR1p30ugp4ntLeGvlDc+GGLf6kbx2GvjzjvIXR/4hj9Vm+yCn9H0gABjiqHu/Ja24Uxq6Z0Q6kEjxwslre2rQD1cPqvXo5PROHufujPxxp815f1J2Q8D3T2x4oZic907JhcfLq38R5Bc/rqWttNUaW4QPpJ/shwy148Wu5Ee5ewayyDhc1zQ5p6ELC6s0ZTV9I+GaBs0DtzG4cj4tPMHzC7uSEbhfPowV5xPek7Pz7gjEBf7RJHhlWWqbNPpSu4C509FJ/VSuGXD913j70cFtdUt4qeWOcYzhp4XD3g8lnuPKcFTxxOkzyjOFDjo4nHLmtJ810bsNstNV9oVDIYgTTMkmAA2yG4H4uB9+Fi4bTcpTwxW+qmJOMxxFzc/xDZdl7BNF3uy32sulzoDRU0lIYYuORri8l7TyBOPZ64VGrka2F2vRdJYqSSS5QjkOA4E6d2q7isD2sae1LrajotO6cpOMVEne1tXP6lPBG32Q958Xbhrcu9TIG2+9LloLNCRTRgjIJLvLf8A8gubpG5lB7l69xJP2NA5mcc55fdufkMe9c67NPo4ad0U6KuufDqO9tIcJ6hmKeF3/ZxHIJH3nZOQCA3kuxMgdK7JySfFKpaQnGQrSClwBsts5cck5XjeWtGGjAXM7jH3NfUsxjhkcPxWp0hSd7a3u55lP5BZ7ULO7vdY0f7wrb6KpyLBC4jZ7nEfMj9Fj04/nH3r1G/y/wDo8RP5uX6ZSpKAAclCnosZ2WnfCOoUCop852WsvLAVk6mmLcrF6uovRZI7kwbNxFUY5FpPquP8JPyJXS6yn5nCzV2omTwywSNDmSNLXA9QUhGVajcWkFUVLN38DH9SN1nu0igFfo6vHCHOhDZm5AOOEgk/LKmadkfA2ooZSTLSv4CT1H2T8RhWdfSNr6CppnezNE6M+4gj9ViH+VL5Fe0ROFztuDqXNIPnjH915hke9nJzgPM5Wx7MNLjUl5FVUxNfR0TmvdxfafzaOW42yR/NZWogeXiMNJkLscLdznlhegtFacbpfT1NRYHfkd5O4dZDz+Ww9wC26ufso8Dcry3hy2CurOeQepHqfPoPv7lF7Q9Tf7Mabmmjdirn+pgGdw483fAZPvx4rg0OorvECBdKpzTzbLIXg/B2QpnaHrKXU2sJwwtfb4MxUxaBkgc3Z65OSPLCogchSUcIhj9bcqrxFdDcaw9mfUZoPHvPv+mFbi91cm8rKSbzfSRgn4taCj/aZPtW6hI64EjT+Dsfgqlr8bJTZjncq7gLl8nvVuytpj7doY//ALuskb+YKvtPXETvp6eio56WGOQsaS2SoaxzjlxBwfW368srINmI810rskqO8hMIG5qyT54Y0/ooJSGMLlo0DDPUMi7yBt3ldYnmZTQSSyODI42lznOOAABklYSDV2maMue27UnE45L+8GStjd5vR7bO8HB4cfM4/VZIVL3DJccHzWPRDDS5ekcVSF0sUQOwJ+Jx9lqbJe6O/wBIaihqGVMbXcDnM6H/AEUxqOuqLbTRy01H6Y9zuAgyiMN2zknB/AFQLDW93Wd2XerLt8eivrhT+lUcsYGSW7e8bhV3DsJ8jZa8TzebQ5jtXgY941Hx+5WHmdXXT/1hUNEJ50lLlsZ/icfWd7tgerVJYGsa1rWgNaMBrRgAeASSUAVq7rzLAGirGS91cyeWJD+a0rXcTHeYKylQeC4P/iWmif8AVg55t/RCf0XG7eBGZm/dc4fiq6ulzxv8VNidwenf985o+f8Amqu4OxgfFao1XIvGMqK12Y8eauI4y5zGjmqinHHKweeT7lo7dCZJQ4j2twPBvT5qVRbq6gaIKNjeRIS2c0iV2XNaOQCXGFGU5SoR6qFdP3dK92d8YCS3YAKuub3TRThp9SBoLv4nHAHyynDRIVVQRGrq2tJw3OSfAdVchvHLxkYwOFo6Nb0CiWuDghLz7TvyViwJQoE/A3AUpoDm4xkeBTEeyKqqfRqdzgMuPqsb4uPJKhZfU9vhMveRO4I4jw92ftO8vd+qj0cXdxAdSkVdR6ZVhrX8UTOR6OPVymQx8WPBdjSiQRDtDkrJkLS71U1PK2BnE44VBW1jp3HGwWqltsNUcvBJ96Yfpylc3biaferOVGvpNHJ5qRHIq5j1IjkVQhXVYsenGlQmSKQx6RCkcSWDlMh2U4DlMQlpQOQkg5Rg4QmJSCCCEI2pSQOaWlKEEEEEoQggBlBG1KhGBhBBBN3QggggnIQSjsMIAYQ5lMQmaqo9FhL+EyO2axgOC5xOAPn16c09RUppojxuEkzzxyPAxxO8h4bADyA5qNCz0y4OlO8VN6jPOQj1nfAHhB83hWPknhB00QAwkSP7uWB/Tj4T8R/5JZOE1Vjipn+Q4h8N0JAuafSBsLrhp2kucbcuoZ+GQ+DH7Z/xBg+K4LKXQsbwRPnle5scUMYy+WRxDWMaPFziAPMr1zqSvsdJpmsk1FVRUlpmj7mWSV2CeLYNbzJefshoLicYBOF5u7PrVU1OsJLrBA2spqGWSKxmdhb6Q85Z6VIw+yGtJw3nlzuQAKoVbQHA962KOU9kQRsuw6QLOx7TdNpa0RRXbW9x/p9xfuYIZHADvJXDBEbQAxjBhzwwcsueN/oPQ7jVT3GuqZbhcqgAVdymxxyYORGwDZjBk4Y3YZJ3cSTV6A0H6Lxhz3zSzPM9bXSf1lRIeZz+AHIAYC63TRR0sLIomhkbRgNHRNiYX6nYKpLJyZwcuO5UmJjIY2xxtDGNGA1vIIHcpHGE3LVNiBLiAryzk88lsTiNgBnK532IvFToR9Y3lWXO4T58c1co/RSu0LtBpNM6autbPO2npKWmfNPO47MY1pJ/ALz32WV3aP2paBstFRum7O9Ctp+NtbGQbtdu8cXufGSP6PES8lrscZADgcO2rSSgSDTOAfstmnpXPpi4kAEjU+APvJ2Xa9f9rtDY7kbBZaWXU+rHNBbZ6B4BiB5PqJT6sDOW7tzkYBXAKiW512ub9cNS3CnuNRaWNpzDQtLaOmnLe8lZFxes8tBjaXv3JzgAbLs0Vo052JaEutbR0cdHbrfTy1tSQcyzlrS4lzz6z3uxjLiSTheap73Lp/SLZLw8OuVW6S5XIjbjme4yPaP77msHkPJMiilqpmRsblztAFo00PP/ACqduSdB3n9FW6hupfUSGV4a95LnknkTvhcz1RqmL0GSnp5Q+R7jnhPIKkvOqrhfquUse5sbiTwgKqmoHwxukkcCcZwvaaDhW38O8lfxBOA4aiMak+B0Xo9NZKOzctVdpRkahg1z5pNNO5xIcSfeud3C6ftC6XS68XFEw+jU3hwtOCR5E7rVX+4OtliqZoz9e8d1Fg78Tthj3c/gsFcWto6Olooz6rBk46+fzyvNb3cGXW4y1cTOVrjoO4bLgrvWtr6uSdjeUE6DwUNhLnZJz1Kf4hwuHiCEVJSyVb2xxNy4rRU2jJHsBnka33HKntXD1yvOTRxFwHXYfFLb7PXXPWmjJA69PitZ9MjiHajZ38XFSz2Kmnpscu7L5QMeWQ4/FcIIlnljhp4nz1ErgyOGMZc9x6ALuXaQJe0ay6YgqAwVlhoBbIqkHeSFuO7afDh38zxlco1dR/8Ao7srYKV5q79cGOE9e0EMooDkd1Fnm949p+AGj1QTlxVu58KXazRCWpi9TvBBA88K3cbFcLc0zVLPU7xr9FuuymVkMmpjE6nmitlG23sqaY5bPLI4vnOeuCI2AjYtYCOa6xqOpp46CmpoZmPdFE1ruE55DH6LkvYxZXWns6oWFhbJc6mWsLSMHhBDB8DwA/Fas5idI3yLSrVj4ZhvVura3tCHwjIaAMHQnU+5atos7LjQT1BeQ6MZA79M/ZVs7+KoenLYeK+25vPj76PB6h0L2kfio0h/pJ81ItBA1RYmk86kD5ghcNTlrZml4yMhcywgPaXDIVXd7RBT2x8kTTxNwck9FiZMlxA6rpdTEZbdNEeYa5p94/8AJcwllMMoP2mletcf2ykpKikqKSMMjkYNGjA0OfoQu14so4Keanmp2BrHt6D99Ct7ZqOKz2t07wHOc3iPnhZG86zqppHCF7o4xnABSX36rraUwcbi0kANHxTdLo+ur/WMbo2Hq7ZXKm91VyghtnDcb2xsHrYGpPiR+qKm6VNfHFQ2RjmsaNcDc+JCd05rSqirIoqh/HE8dfFafVNDG/0evDfWZ6pd5OGPzIVPS6Ep6VzHzVDQWnPNam6wCpsE8cTuIiI8B8wMj8QF3totl0qLLVUF3PMSCW5OSNP1wutttBXy2uoo7kckg8uTkjT9Vm7JI2K5Ql3InCuNY0clXbQYhxEHcDwWXp5+Nkc0e2QHN+WQtLbdRNcxsM7cn2crguEbnQyW+ew17+QSnR3jpp8lyPDtfSPo5rRWO5BIdD46afJci1NSyx3ijcI3HvYXswBvlpB/Uq10xa7iLlTTR0spa1wJPCQurXSagtNGayaGINbuHOaNis1UdpdPGQ2GPblsFoHhK12KoZJcK/DgQQANfDr9lYdw5b7PO2StrMEYIAGv79yse0eiFdpOpy3ePD/cuP3B/eS08/MzwMc4/vj1Hfi38V3KaRt+01K7G00J288LhcrT+yxn2qaqMZ8myN4h/wATHfNQ/iVC11ZTVserZGb+Rz9CFDx1E11VBVs2ezfy/sU0DgqbTyNbACTgDOSeirnPDff4JiWoJADnBrc8s7LxkkBebMYXKxlr5pssp2PLTzkAwT7vBOu1dX09MyEVBiYz1Wgc/cui9nTKCutQZNThszXEDvBjIR1PZpBTVz6ukYHSPJOX+sR7vBelxcKXJlujuFql7TnHrBpwR4br0BnD9YyibV22Tn5tw3QhY6xSXiaoZUzVEtLCOTHbvd8Ps/HfyXX8iutGXDOWZ3VBbtHytkDpzhoOcAqzvN1ht1IaeM+vjAC7XhmmrrHQ1dTfHFsTm4DXHUnXoV0lip6q00lRPdTyxuGAHHUn3rPRjEjmtGcnbC1llpjBS8Thhx3WXskgFbEXbgnqthX1gt1N3nAXAHGAsr8PaGjiFRfZ34EeRjHsjfPwVbhGlp42y3WZ2AzI8hvlVVTbp6qqc/kM7J2Oxkj1nKHJqiZ39XG1nv3UWW9VcvOUtHg1ZtXXcFx1D6h7ZJ3uJJ6DJ8yPoqk9Zw4yV0pa+VxOe4fPH0Wpp4m0sIjLhgeJUSvo4xTOc0b+IWYdUyOdlz3H3lamnd6RbT7l3Nov1FxZTzW5tMGCNnq5OTtjTTTZdPbrtT36KSjEHKGN9XJyfosy+ct8iFIgvtTHwsYO9eSGtZ1yeQVZWyiKR7fApk3B1nphVNA9NmzHSMcMgHHrSEeDR8yQOq+cqa4Vtnmd6LKWEHBwe5eSQ1NTQyE07y0+CuL5qaaKv9Dp359GaGTys5PlIy4Dyby8znwUCx3OorbyKeNxmlkBa5zj6sfUE/ljzVLb6Ce4uEFO4tjb/WTnc+ePFx8VtrLZ225sYgjDeAhwJ3JPiT1KS53i43VhZVzuePEnCmqa+rqz/rEpcPEra6d00yJvG8nBOXyu9p58vJaWSSBjQxhGwwGtGcJigoJa+NjwHPaQCA3Zo+KvKawAAd64AfdaP1XmeSClaNFSxh738MUZ4j8Xf5KwpbJxkOqBxnnw9Pj4q4mbR2ejkqJ5IqSmiHE+aZwa1o8SSsc3V911nK6n0hSiKia4tkvlewiIf90w7vd78AEYIGQUBpdqpBhpA3PcFfXq9WvS9H6Tc6uKih+yHH1nHwa0buPkAVSRVWrNbYbZKL/Zq1PH/rO5MBqHt8Y4c7eRdzByCFdac7PbZY6sXKqfJer0d3XGvdxvaf3Gn1WAb4wMgbZK1jaklwAOU7IbtqphG53tHA7hv71TaR7J7HpqqFwlbJebyfWdcbi7vZOLxaDs3yxvjbJW5490zSP44geoSyeaacnUp4DWDAGErnulcKba7HPZEZwOvzTcJpTwdhKMgZjPM9FV115pbbTvnmmZHGwcTpHuDWtHiSVyTUnbDW6lrJLRo6mnr5z6r6mCMuLR4tJ2aP3nf5pwaSonuDNz7uq3Wuu0un0xmhoiyqvDxtHnLIB95+PwbzPkN1x+2yXTWd4qKaywvvNzmdxVddK7hhjPQvfyAAGzW9Bho6LTaY7DKqveKjVNaWRPPE630khc6Qnn3s3M+Ybz6OXZrNa6KxW+KhttLFRUkQw2GFoa0eJ8yepO56p3qt0GqiAe/U6D5qg7POy6g0TL+0amUXW/vaWurnt4WwtPNsLd+FuNifaO+Tg4W8a8uUJhypUWxTCSdSpA0NGApsQ3VfqOT/q8fhlx/wBfNT4TuFS3yXvLg4ZzwNDf1/VVag4Yup4ch7S4B39IJ+33VpomDjr5pSM8DMD3k/5FbyI7LJaKi4KKWQjd8mPgAP5lauIqambiMKhxDL21xk7hgfAfrlSm8krBRN9lKHJXAuZOyIjdJe8Ma57jhrRknwCXjfKotZ1/oVjmAOHzYiHx5/gCmvdyNLj0Vikp3VU7IG/mIC5xWVLqyrmncSXSPLznzK6jpym9FsFEzGMxh597vWP5rlUMZmlZG3Ac9waM+a7MyIRRtjHstAA9yzaIZc5xXoXF8gjhgp27ZJ+AwPqkHdNkZThGElwWqvM024ZCoNXzdxZZByMjgz9fyC0DhhZHX8/DFSQA+05zz8Nh+ZVaoPLGSt2yRdvcIW+Ofhr9lRaYg7+8Q55MBefl/MravZjKzWh4OOqqpfusDfmf8lq5GbKClbiPPetfiebnuBZ/SAPv91XTjAKqKiMucVeTs2OyrJoTnkrJC5ZjsKBwY6IntUkx8OThNOZnZNATy5UOpK2O12+WeVwYxrSS4leatS6lqtdXSpZE8U1opQXVFU7Iaxo6eZPhzPuXTO1Wur9aaii0jZA5724dVzN9lg22J8BtnzIHkeSa9fFJX0+hNLNNRBDKGVU7OdVPn1t/ut3yfInkAp2AnZSYaG8z9h08eizFotlZ2i6kbTW9hio4Rhj3DaGPOOJ3i4+HU+QyO7ac0FbtP0zIoIBI8D1pXjLnHxKnaD0JT6Ps0dFCBJO7Dp5gMGR38hyA/XK21HawfWcNh1W3GwMaCVgSkyP8Squ0WZralsz2gNjOQMcz0VvcqsUFsrasjLaankqHfwsaXH8Ang0NGBsENR25z+znVk2PWdZ63h93cPXMF3p9Xk+yPoP1Xr5aOGbIcf4rv+4//iPp4rx3Qwy1Tu9neZZ5XF75Hc3OJyT8VuLDpvvGNke3Y8hhUNipmzVEMfjgLrtutoYxjQNsKaR5yvO4mDGqvuzmgbboa1rRgPLDy96jdp9uFaygkx7HeAn/AA4/VaLT9I6mheSMB2FG1nTGotgIGeErNJIn/fcvR2jn4eLe7/8ANecdewMhFsY8OdC6pD5AObmt5j8V7k7NvpGUGhbLfYmQmukqJI56FrXAR4c0hzifDAaRjn4jOV4q19Wm1VttndD3rYJu84c44twcZwcclQ1usKq5QyQ0NNHbKZ2fUa9zzvzG5xv/AArfp3ANDjrheV1LQ4uZ34+S7t21fSJm1BVzTV9aK+recMpKc+pH4BzuQA8Nz1x1XMuzGuq9SXq7VlQQ9wbEGtaMNa3LsADw5rmstKZDxyzF7uuV3n6P2l+503VVzhl1ZOWx5HNjRw5/xcY+CdVTuezB0HciihDZRjplaplmE8TXcOCQkyaYdLG4cIxwlbQWgwxhhGMb7p2Ck4IJ27BzmloysXmIK6QsGFQ9njO70rTNHIPk/wCYrZWiAVVS9nMhucfH/IrOaXonW2yU9M/2mF+fi9x/VbjRkEdUyskAPHHIInZ/hDvycprc3nrge7JXWX6T0fh0M6uDB9D9lX3CzAgkNWQvdpxC/boV12soQWHbosPquAU9BM7HrO9VuPFd1nK8KBXmbtNt0P7MkZK0HvJo2tGNw7iGSPhxH4Fc6urIRVcbD3bwPWc0438Vs+1TUMT9UChjd3kdubh7W7l9Q4eyPHhaceRc4Ko09paSsqGT1rBLO85bAd2t8z4n8li1MgDz4Ldoqd8zeVo31J7gun9gFtqrzaJ625DvqGnkEVI543eRku4vEDLcH3+C7OBgYGwVRpC3/svTVvpurI8n3klx/NXC42okMkhK+gLRRto6ONgOSQCT1JOqC1elJRVQPid7URHyPJZRbfRFsdDSPqXjBnI4QfujO/x3/BSUnN2uiy+J+y/h5Mm+Ry+f/jK0NNS4A2VlHTgNAwlU8IwBhTWQ4C214yTlcZ1OQdQV+OkpHyXRtJQd3puhA5Fhd8yT+q5nfHiS9XB7fZdUSEe7iK63YYe6sVvYdiKePPv4Qsmm1lcV6ZxIeS200Xl8m4+6dczYqHUR81YvbkFRZm7rTXm4VJVRZB2WfuMGWlamqj2KpK6LPEmqwxcyu0P7P1DS1gyGVINPLj73NpP/ABD4hWbSndS241dJLEzDZCOKNx+y4HLT8wFCoqkVdJDMAW8bQ4tPMHqFl1bdQ5em8L1GWPpz01H0P2WD07o4S65udfM0dxR1LjGDk5e71hg/ugg/EK07U9S/sDTMkUT+Grrcwx45huPXd8Ace9wWww1nE7Abndx5fErz/wBouoP9o9QzSsdxUsP1MGDsWg7u+JyfdjwUkANTKC7YJLq6Kw258cHtyE+eu59w0HjhYaUcNdC7yI/AqQMgkeCj1nq1EB8/1CklhL2jlxYGfiuiC8ZI1S3tAc7A6pKeqGcEz25zhxCbA3SpqNvRdN7FYzJNUkDIjme4nruxgXMhsV0rsMY915vLgXdy2CLI6cTi78cMCp1ZxA4rouHmdpc4W+Ofhr9l0nVL+G14+88D8z+iyoflgC0mq7rS230SKplEXfOdwk8tgOvTmoHcQzsDsNeHbhzevxCz6UYjXU8RvL69w7gB9/uq+GQiRrgcEbgrcUs4qadkreTh+PVZUW2MH1XOb+Ku7HmKN8JfxAHibtj3ptWzmZzDop+Gqrsaowu2ePmNvuqW60/o1dK3GGk8TfcVEGy0d8oROY5c8JHqnz8P1VNJTd0cDcFTQu52ArKutP6JWSRjbOR5HX+yzVceG5P94P4LR0ruKGM/uj8lnbmOG5uHkPyV9Rn+ix/wqVZXRcczl1XjrUPP4qoq38czj4bKxdLwxTv5cUjiB73FVDjl58ytVq5KTdT7RTCecl20bBlx8lpbcC4mQjBJzjwHRVMFP6LRwQcpZvrZPENHshXVMeGMp2U0DAT+eJxKfhamGdFJZs1NSJNXUinhc/7o2HiVEoozLpqskJ9eoq2Mz/CCT/zKDeazjeImn1Wbn3q4hjNNp21QkYdJ3lS4e93C38AnHoENO57gm42BvCG7ADACeZ0TYOEtpyE7Cgwn2FZ/UdzxJ3UbskDA/U/Dl81Z11YKOmc/IBxtnx8Vi5JnVExkdsT8sLSoaftZOZ2wVad/KMDqpVGzCtYDhVcDw1qlRSrp1nq2jIwl5yFEhmACeEoIQhfQhrk8x+FGa5LDlAVbU2ORSI5FXNepDJE0oVix6ea7koEcikRvSIUsHcJecphrshOtKEhSwcJSbBSwdkJqNKByElG1CEpBBBCEEbUSMBCEaCCCEIIIIxzQhKTc0vcQSSEF3C0u4RzO3IJZPRNTjjdBH9+QfDhy7/w4+KYgBP0dP6LTMjJBcBlzh9px3cfiST8U8PFEeaB2BKk2SboiclV+p7/btI6Yul+vM/otpt0JnqJcFxx9ljWjdznEhrWjdxcANyFPYC97WtbxPccNb4leVPpG9pY1/rs6OtkgfpvSdRxV07D6tZdAPZ/hpwTkHH1jv+zBUT5BG0ud0VmngdPIGD/wFSzXq9drurP2pfHugp4cvjoGSZioITyibg4Lzj1pObiCdmtYxvpzsc0hGLfHc6mENMwxTxYwGxjkceePlhcI0xYvQLZR0Rbw1NZIHTHqM4z8m4C9R2u8Q22w0BjAzIxkTGjly3/AFZ0Ted5c/daVZIGNDIxgbD9+K2sDo6Zga0Bo8k464RsG7gsJWapJdwMdy9oqqqtUPAIa4k+KucyxeUldCq9QRwg+sB5LOV+on1L+Bh57ABYqqvkhY58j+Frd+LphcG7UfpHsoXy2ayU4rZX+rNNHIfZ6sBHjyPln3ratdorrzL2NCzmPU7AeZK3bVZqq6y9nTtz3nuC63ryxzdp2iNTuBMlsbQVDKGFoya2bgd9Z5tB2Z4u9bo0rd9kM7K/so0fM13Gf2TTMef32xNa8fBwI+C8aO7ee0qmgbPTUhoKJgAAbDyaOQBPJbz6OP0k4rSIdK3qJtPSmokNNJjaMPe57gfD1nO/0F0NR+H94o4nVQLZMakNOSPd+i7eu4XroqMujw4MOcNOSB1966d9Ju/h9Jp7SMTvXutV6XWNG/wDRaYtkOcb4dKYGHlkOcvJnatepLpdGUMbstcRlo6NHs/PJPxXY9X6h/wDSH2w6luUEhko6d0VjoXN5hkWXTOH/AMWR48xE1cF11Wtpdd1b3NANMe74Om2yu/h5Sma5z1AbzPiYS0f7x0CucI0xE7pA3L2tJA8ToEG0lPZbU/iOJHY5rN3a4MqYXsjzxE4z/r3JdS+oufFO9xEfFgDfCpbhP6NXQU7Ny5he7yHIfjlbdXb7DTVBPENU6Sodq4Nzhuenu81ZqaS0wTE3edz5juBsPD9lUWre9qaygja0+jwZlcf3uTflufisbXTek1jyNwDge4LolBcqe8MlaMHhc5u/kcLE6htJtde4t9h2CCsfiDhOChpGXS1ydpTu+IWLe7DFTU7bhQv54T8QtTp2hit9rFQ4DiLc5KpZLlctQ3WGht0EtRVTyCKGngBc+Rx5AAKDbv2pfZhRULJKiQNLnAEBrGD2nuJIa1oG5c4gDqVqaWGqsdvmo9OTBlVUsMdbfxlkhadnRU2QHMjPIv2c/wDdbsdCa7Vt6pIbTw/C5rWD1sdT3kjZW33Cqu1PFQWmNzWNHrY6nvz0U7VupLB2X2yLS1NJHqHWMsgdd7hHJx0ttx/7NCRtJIOT3jZvsjJzw02r7Q3Uum3GKPvJ3R5jGNyT0VLT6DtNtcx1RO3Ldx/ordWiWFlPA6ncHxxEY+G69E4ZtFwjoam3XSQOD2nA5uYjRdjYrbWNpZ6K4PDg4aDOSFYxRw2GR9G0h1NZaaG3tc37RjaOM+/KXdIu4uU7OgeVT3PjptI10shJqJ45KiR2Ny52Sc+fIfBXl4kFRPFUDlNE2T5heffhlJyXGpt8uz2kEeI3+WVgcGv5auWkf+ZpHw/ZWfqIHvlBA2Gydo4H095tlZ0pahkxb446JNTXGKRzQ3JHVaPsi01L2j9pthsL3PjpJ3yy1LoscQjjjc84z4kNb/eUUtFwbaZnQzPkle0kEDI1HwVeWHhy3vLJXPkc04I21HwVU/D56hwGGySvfjwyScfiuS36P0W4zxnYteV1u9Mjotc6moIJOOlprhUQwH9xkhaPwx81y/X8Ho96c7pI0OXRcZvp7rw1SXCkaQxjuUA7gEEfYLS4ldDX2WnrKcYa04AO4G32Ct9EWiOoiNVM0OAzwg+/mi1PqualmNNSO7oN2JAU/s+qmS2YR59drnfLKotV6cqm1RkhjMjHEn1eidNHVUHCdNJZQcv1eW+18td9EyZtRScPQPtYOXavLd/lr4LO1Fyq6tju8qHuO+N10fRdSaywNDsktJBz4LF2nS1dXzhr4xHGDzJXRLRBS2yNtBE4ccbQS3O+FL+H9DcWVb62syGOHL62cuJ7sp3BtHWx1L6qpyGkY9bcnwyuf2/MEtZSOPrUtQ+LHgCeJv8AwkLQWKi9JrGuIy1m/wAVT6ipHW3WU7gMQVsQdn99v+R/BauxPgoaLvZJGBzhnn0XLWmysj4pkhqcNjic5xzoMA6b+5YVutbGX18U+AyNxdrtgHRVmv6htRRSUnD3uW57sEjiI3AyOW4C5kblp+p4XM/aNC92/CRHMxvxy0raXWu9MuEr85w7hB8ly6504pLlUQgYa15wPLmPwXK8T3I3e7TVAd6ucDyG36rn77cP4hcJZxgjOBnuC7zoSogqbC1kNR6UxhILiwsO/TC57ctFzMnv7Irna5eKJ8zKJk59IL2HjA4S3ns4c/tLP2TW1ysNJJBRytjY85JLclV8eoqlt/hu0srpKhkoe533h1HxGQty/X+mutno6NgPaxbnTGMY789B0Wndr3S3G301NyntI9+7GMaa57kzRwmsYHmUNaRnDRv81YQQRU7gWMHF947n/JQ5ImW26z08R/o5PFCc843bt+Q2+BUkP3XnJC4wE7LQWiskhdmN5a5u+y1NPq6viZjjDj9526wlumxO3z2V5G4rTo7rXW7PokzmeRWhS11XR/7PKW57itBNqWsqRgyuA8jhQDK6VxLnFx8SVEaVIjOVXrLlWV55qqUv8zlLPV1NWc1Ehd5lWNI/upGO6g5Wzub2VFpf6wyWBwWED+EDonjXzOaGGQ8OMYXT8PcSMs1JVUksfOJhjy0I+66C0Xlttp56d7OYSDHluPunO8AR95joonfYKJ0y4E7rmgFJdPspLb3PBCI2nbkql8pKj1Epijc9zuFo3JKt0ldU0Li+meWkjGncrENRNTEuhcWk6aKVV18NO2Sqqn8MTBk+J8h5pqxWa56rq3VslO9plHC1o2bFF0YD4nmT/JQLHYrlq6tgrIY4vQYHcULKmNzo5T99wBG3gDz3PLGeu2k6poI8Ps1suLOnodW6B/8Ahewj/iVR+XEuduVE0lxyU9YtCvhhYx5ZBG3kxu5WuodP0dGAe7713i/f8OSxzO02tiEzGaTrZZIJDDP3cokbFIBktc6MOAIB5c1V1+vdTXY91SU01vaduGkopJZT5Zc38mhR4U4Y4rtdNcqahtpkqp4aWCI4Mkzw1oHvOyytx7U/S5HU+mLbNeqj2fSntMVMw+bjgux4DGehXKtK6k0nHfn/AO0E13qagkxvqLjSzSMY5p3afVOMHO2F3zTV60Vc4oxQXygmJA4IXSticR5Ruw78FzdZD2MxON9VdiMbxgPHuIysIzStVfqxldqysfeHsdxx0MXqUsR8m/a8MnmOeVvabUFtp4Y4TKKVrGhrY3RlgaBtgbYWyZbomMBZG0NI2IAwU3VzUttpp6iokjgp4WF8sjiA1rR1KonLt1cAEY9XRUMFdTVrc09TFMP+zeHfkn2eo5Zq3XjQnadUTUrIIHV7MkxVEXczuaPtNcMOI9xyOoCU7sattNI51uud5tQJzw0tc7h+TuJBjxuVEJy7UAEeBWyguXctDQAQnzcw7/Jc4vOhrhYrdNVf7ZXZsUY2EzWSuc4kADOBzJAUKzaDv2q7ayas1VcYqbJaG0zWwufjn6wHLOyTk6ZTg8uBOF0C7aqt1lZx19fT0bSMjvpWtJ9wJyfgsPV9rE98lNNpOz1d/nceEVJYYqVp8S92M48Ns+KdsmgdHWmpcya3unuLXes+7EyvcfvDi9U+8BdIo4mxRNaxrWsAw0NAAA8AgcrfFMIe7rgeG65xS9k1z1VPHV62vDqtoPE200BMVMw9AXe0737H94rotptFDYaNtJb6SGipm8ooGBrc+JxzPmd1Paw7JTo9sgJHElDWhmoGvf1TbfaCmsGAorW4UqI5ao8JSVJaMlSGclHbzT7DsmpVKiO4Wdq5O9qpX+Lirx8vdwvd1a0lZ5Uao7Bd9wrDrLMfAfc/ZbrTLe5tUA2y7Lj8SVoIDnCpLYO5pYWD7LAPwVxTHOFoxjDQFwdbJ21RJJ3kn5qe1PEJmLkE+pws4pCwXaHXd7XU9K12REzicPM/5D8Vv3kNaS4hoG5J6Lj94rjcrnU1PSR5LfdyH4YVGsfhnL3rs+FKXtax05GjB8zp9Mp/TMAqb/QsLeId4HY92/6LrB5rnfZ9T97e3yY2iiJz5kgfzXRcBFGMRk96bxbNz1zYx+Vo+JJP6JBGU24J1JIwVfXEhMEc1z7W9T314EedoowMeZ3/AFC6K4LlN+qfTLzWSjcGQgHyGw/JUKx2GAd67rhOLnrXSHZrfmSPtlaTQsOKKpkwPWkDc+4f5rSOaSqnR0XBYonffe5344/RXRZlTQDEbVhXqXtbjM7xx8NPsokkGVFlpQrNzcpp7dlLhYnMQqSemwqS+zVNLQvFFGJa+Y93A13stcftO/dbzPux1WrmjAzsofowfIDjfHPwCVrcnCkEmNVxXtBmpOxjs7qfRpO81BdS6IVR/rJJHA8ch68LQTgdC5ueZzhexDRAoLb+3KqP+lVbf6OHblsR+173c8/dDfEqP2mVzu1ntobaYnOdaLYXQO4ScBrD9c4eBc71Q4dOE9F2W2UbWta1jA1rQA1rRgADkAFowMBPN0GgT6kmNojJ1Op+wUq32/iO4VjXtbSQNiAw9+58gp9towBk7AdSqavqBVVckg9nOG+7oq1xn7KLlG7tPd1W7wtbhWV3bPHqx6+/p+vuSKWndVVEcLAS57g0YWyvenTX6YulqgIjNXRTUjXP5AvjcwE+Q4sqp0XQ+lXQzOGWQNzy+0dh+vyW5cASobXFyxmQ9VZ41re0qmUjTowZPmf7Y+K53YOwfQ9p0k/T1xic+R7C86gA4Ktk33muGeFo5CP1m4A4uI5ceTWEywyVdFNUx1k1FVSUrqmJvC2YNcQ14Gdg5vC7HTiwul9p90vVkc+Jte2ittWMw1ppe+MDgPWY5uRlp2IJB2LgRhu/OLFbam2d7JW3Knu5q5TM2spyMOOBlpA9VuMbBu2NhjCnq2twMDULkreXZPM7IPRbi3BzqPjIIbkAefNKq6dtVTujcMgp6kro6i3NiaAC12UbW8eRy2WC/Anbheq0eXWOQHpn6grivaJol9VBI3hJbnia4D2SuF19quVllcHRPkjBPrNHJe4YtOvuzi1reNvInGylQ9kTHEn0dm++Q0LQjc5mwyF57LFFKfWOCvCdit9Zqq90lpo2H0mpkDAXDZo6uPkBknyC9n2CzU+m7PSW6kHDDTRNjb4nA3J8yck+ZKvRoOG0ymRkDWvxguxuo9VAYJS3G3RVKuRzgNMBdXwxTU7al3MeY4yEzySJomVDCyRoe09CloLLyRsvUHxsk0e0HzQjYI2hrdgOSs7RfpbK2RkMMThI7jcXA5JxjPPwAVdyCSpY5pIXc8ZwVVqqKmrIhDUMDmjotK/W80gw6lj88OIVFfqyS8QSNhDaaXgcI3vHeNY8jYlu2QD0yOu/VR0rkrwudWNn/IfosJ3C1ndvB83D7rjVt+joyjqn1VVqB1bVSPdI+Z9JhznHcn2zuSSfitjYuzG3WVwkM81RL1c7AHy3wtnkFADiOBuVWNTPId8lW22e2Urc9mGgd5OPmUhjGxsaxow1owAlIOaWnB2KCqnOdVus5eUcm3THcrGwW5l0uccMhPd7ucBzIHRdSo4AA0AAAbABYPQEHe3WZ/MNix8yP5LptNBgDZbNG0CPPevJOK53PrRFnRoGnidT9k7Tw4wn34Ywk7ADJKU1mMbKHfpxR2WvmOPUgeQDyJwcD5q6TgZXGxMMr2sHUgLhk0pnmkkPN7i4/EruVNAYKSGP7jGt+QXE7XCam50kQGTJMxgHvcAu5v5rLox7RXo3F7gOwiHTmP0UeQ4HmosvVSn81GlO5WkvPmtVfUNxlU9azZyuZuoVPWnmkKna1Zq5wcbXAcxuFl6OA07p2j+rdIXt8s+0P8WT8Vrri8RNe88gFm3HLiQMZJOFnVTgG8q7vhmme6Z1Rs0DHmT0+/wWY7Qby602DgjcWy1T+5aRnIGCScg+AXC6+Lgcu29qFJ6RpGeYDLqSSOoHuDsO/wCFzlx26xjDXDcFWqHHZ58Vk8WiQ1oDjpyjHxOfmsxchiaH4n8lPMf19GPvFo/EfzUG5f8AWGDwZn8VatZivt7T4h3ywf0WuDsuBI0KRVgGpkP7x/NR1IkPG4uPU5TQG4SpiQuwdh1I2O33SpweOSSOMnPRoJH/ADlcff6uV3Xsdp+50c2T/fTvf8gG/wDhWfXOxAfEhdhwnFz3Nr/6Q4/LH3VT2wSk1trjH2WSO+Zb/JZuy3urtxHcvLousTt2n3eCv+1l3He6OP7tPxfNzv5LIUvqEBV4B/KatC8P5rjLnvH0C6Var1Dc2jhPBL1jcd/h4q5o5jDOxxOBnB9y5vQerh7SQ4HIIO4Wutty73hjmPr/AGX/AHv81O7DgQVlxudDI2Vm4OVsqiLvoXs8RsqFw4hgq8o5e+pmOPPGCq2ug4Kl2Ng71gs+lJa50ZXZ8RRtqIIa6PY6e46j7rD3puLsR+61W8L+7txedg2MuPyyq68RZvTx+6FZVVBVTWOqbTwvlkdTuDGtb7RLSAFfyM5K4ZrHvyGDJ8Fwx8xMEY6lvEfeU7ZqVtXWZkwIYgZJHHlwj+a1tB2Oajrmt76OCibgf18oJx7m5/0VsbL2K09Nb3QV9fJK6Ugy+jNDc45Nyc7c+g59FZdVwM3d8FVg4dulUcthIHe7T66/Jc2p5HVcslU4YdKchp+y37IVw6jnp4mOlgkia7HC57CAc+GV2a0aUtVjA9Eoo2PByJXDieP7x3Q1WKY6frvSg3uxGeHi+/j1ceecKoLiC8Na3QrpDwY+KmfNNOA4AnAGmg6k4+i45GN0mtqhTQF32uTR5pYcGhUVyrDUTEA+o3YefmtpeaEqOeOolDWetI84b5k8ls7yGw1/ozDllKxtOD/C0A/jlUej6UTXqOeUfVUrXVL/AHNGW/8AFwj4qZJM6V7nuOXOcXE+JPNINT5JDpH5lKDkoyBoyTgDmmeLHPZU96vDaWBwacF3qj3qZjS9wa3cqInlGSod/uhqqju2n1GHCgRuGFX9+3G7vgnY6ocl18MQhYGBZD3F5yVZMeMKTHIqyKYHzUyJwIUyYpomI2yno6g+KggpxpyUIX0ebzSgUgckoclEraWHJ1r90wlNKQhCmMkUiORQGOT8ciZhCsY5E+x6r45FJY9IkKmApWcJhr9k6D1QmpwHKWOSbaclKBwUIS0EROEaEIJQ5JKMFCEaCIlGDlCQoIxzTFZWwW+B01TMyCIc3yODQPiVhr5266KsORUX6mdIP7OI8bvwVymoqmsPLTxOefAE/RW6akqKo4p4y7yBP0XQcbqMZOK8QRjk2B73e8uYG/k5cIvf0wtL0XEKCkrbgRyPCIx+K59c/pf3eS7uqqG0QU7HxRwnvXFzgGuc4n48X4LraXgi/VWopy0f7xA+ROfkuqpeD7zUDPYcv+YgfLf5L2OmaupipIXSyvEbGjJceirdM3xt8slFXAg9/C2Q45ZIBXBvpNdsE1kaLHbpeGZ2e8e3r0x8Fz9Baqi5VraCEeu44Phjc+5YVttc9xrRRRjXOvh3rU9sf0gaXQOi7jLZauKbVNW00ltZG8H0Zzsg1Dh+43JAIIJAB9peUtDX6zaZhoKKQyzQwnjlkeS50ryeJznOO5y7PPxWegpp71UGpqXl5edz1K2cXZ3SSWqolkJjkiGPV58WM4/EBdzUWvg+gnFDXTPkkboS32QV6k222Cz5p6iRznnQkbA9y7BprW1uvFVLXQVDXtp4XFrc8iR/LC32i9Vy3uhoou9LjS8bCPDcY/DiXjClqqvS10c0Pcw44XAHYg/+S9I9gNW65VVyIJPqwEAeZeuW4s4aZw/NFNSv54ZRlp+yw+IrFHbmNkhdzRu1BXa+9c7YZKs7ZpusucgDIzjxOwHvWs0zolsUTJ6seud+HqtjFBFTQ8EbA1o6ALgsl2y4HDWb6leX/pPahb2Z6JbSUcubpXkxumacGMY3wPPcHquW/Rk7JKbUrZb/AHSLvyH8MbHZznxT/wBN+5Pr9Y0LIifR6ePupPAyH1v+Uj5qn7MvpKUXZ1o+mt7aCWpq2Nw4swASORyV9F2y21g4RjZZ25lmPrEaHGSN/dheyUlBWt4bYy2t/mSn1iNDjzXrYaFojTBvocRaBjDmA/mvHv0luzOHQt6pbpbuGCKfJcGbYfnor65/S21nfcxWmy9208nEOcf5LnOoKvXvaxWvhuLDIaN2XR8PA1jnDb44/NR8M2G6WCtbVVs7GMPtNL8kj+yjsFmuFmqhU1UzWs/MC7OQtb9HuoFy9M48l1N6+eeXOAbn8yfMrmva3T9xry5Ox/WuEh95C6f9HjTVfRSXSreMUwe6nfgc3NO/4rF9utvMGpBUAYbJlufNLw5LR0fGU8VG8GOUHGNs+0R8lq2qWCHiGVlO4FrwcY+P2WZMDWW2laOTsn8Fgb3ViG6XupztSwMgjPnw8X5uAW6pKoTW6madyziGPkucwW24asqBabRTPrrlerrL3EDDjLWk5JPINaI8knYAEleL32OWC7VLKjcPd9d15jdo5GVszH+1zH6qg07VGjqWDOA4YwtheaC01EQqL1Vz0dDEOKQUsYfUSY34GBxDQTy4nHA2zlXl/rNI9kc40xp9kOq9cE8Fyv8AKOKmtp+1FSsI3eNwZDnG4+05jMZ2h1HdWJ2X8UhPN3Mg816pwvIarhS4RzaRt2Pu6LtLGCLBWMmOWjXwGiuaGqZX2aiit9FHZrHVAzihY4yTVAY8sZJUykDvHEtc4NADG5GBk7YjXGrqimndR0j3QNAwXMOFrLFc4m2+xUZOHi2ROGfEySE/mstrjRdVXVbqqkbx8ZJcPBadNTVLODYjZc87j6/L7W5B21/srLY6k8NRutntE+vjff4/2XPJq+eoeTLM+QnnlxXYeziGR+lWVL8hkkrmMB6gAZI+Jx7wVz+29ndxrqhol4YWDmSMrr9spI6C3wW+FoEdFE1pA6FxJJ+JyUzgS03Clrv4hW5Ywjl9bdxOgAzqoOELZWU1Ya2qy1pGPW3JPRM6imLrVJHn228H+vxVjSyekaZsM3PNFE0nza3hP4hVF+bxUox4/oVL0lMa3Q1Dg8Rppp4HeWJXEfgQucpyOHeNXGU8rC86nQcr/wDyoIyLRxGTIcN5jr0w7/yma6L60O6EAK77JNW3fQ+uWXWyTxU9dFFJG100QkYWuGCCD+ngoU1N3sBPUbhRdNu7jUgHLi4h+GVxXFrqd17qZaR4exzsgjUa6n55XPXzsJLlM6Fwc0nORtrqfmoxmedQ3KSZxdK+tlL3nGXFxJzt45CzHabS+rSzgdCwq81gyWluF9dE4ska5szXN5jLQ5c1qrhPXECeV8n8RW1T8Swt4ckskkZLicg5GBqD59FYF5jbZ32t7CSTkHoNQfsptgu0ttbHJGfHI8dytizXdJ3Q7+M8XgFz6hdmlZjlv+aKpdswe8qpZuKrnZIzFSv9Q9CMhZ1uv1famllO71T0OoWxuPaNEwPipYGtdyyTy+Sx1TqKtpa41cM7mSSDGc9FnHVfeVDnZ2cTj9FND/S6Qs/tGjI80258T3S5yNkmlI5dsaY8sKCsvtwuL2vlkI5dsaY+CO732sqJKetmnfM+nkbJuebeTh8iVu6dzZY2vB4mkZBHULmzR3sTmP5EYIWu0XWekWlsDzmWmJid7h7J+X5Ll5ppJXmSVxc49SclZJc+Z5MjiSep1U6tj7qbvB7L9j71i9X0vdVzJgNpWbnzH+WF0OohbNG5jt2lZHUFM6rtczHDNRSO4j4kePuI3+CjadU0twFinA4TJGTun3HIwmCcKdVyrCokNRa4KjP1tI7unn9wn1T8Dt8SpMcokY1w5EZVfbZWid0Mm8NQ0xOHv5FOW5z4xJTyH6yFxafPz+PP4owlB1VrBIWuBHMHK0cEwe1rhyIysuxyuLbPmLg6tKiIUoVyHbJxj1DbJsnWPyo8J4Kn8eUXF5pgPSuJRlShOcSLiSW8lDluDpKs0VFF6VWYHE0HDIs8i93T3bk9Am4ylT9XWRUMLpZpBGwdSU7pXT02uLs8VrHU9ppQyR8J2fOXZ4Wn7oOCSDvjG2HZWj012X11a+Otno5rjUj1mPdGRGzr6jT+e5WAr9aXfReur7W0DmBokbBUUNU08DzG0NOcEEOBDsEfiFJGwuJ5U6dpgY18nU7L0BTUbIWMjjYGMaMBrRgAJvVGtaLQOnam51hbmNpbBCTgzS4PCwe/x6AE9Fw6u+kHqCsh4aK20VuLhjvJC6Z7fMeyPmCuc3u73PVFwFTdq+avnbkB8h9VgPMNaPVaPIABTNp3E+uqUlaxoxHqVO032g6i0xqeq1Db7k+G41kjpKrrHUcRJLXsOxGSceHMYOCuk3v6Q90v8Pd8ctCxzcSGDYu8RnOw93PquX2y1sqGPc7iaBs3G+/n+CORraGYMlhDeL2ZAMtd/I+StuiY4gkLMjqJ42lgdoVp6fXVLDURvDi17Xg4LSutOt1DXxtlfBDOHNDhJwgk/HmuAR1zHSOja1z8HGwyF2PRlnrpbLTnu3UpaMc+EEdNvco32WtuzmtoYi9w7hn4rWttJVVzzHTxlx8AtDS2+lof6hr4PKORzfyKclYHscwvlex2OJr5XOa7fIyCcHfdK/ZNaxn9e13kW7qoub66hB71oDfFoVe48H3u1RdvV07g3v3x542966CqstxoY+0niIb37/RKuFNC3hlicYamJwdHLEeFzSORBG4K2uke3e+WZkdJdqF17pm+r6RH6tSB5/Zd+BPUrHWS7UvdvNQGlw3GVMl1bRQZ4APgF0Nq4QtdXRx1twuLYg78oGXD4kLWt9opDA2pqKwRg9MZP1XV9Va+o9UUFHDRd7FA895N38Ra5hzgNI6kDJOMjlurQdpVutlFDSUVNLLHE0MaXbchz+K5W2q9It/pERyHM4hhZqj7RK6yVmZaSGvpQfWjd6rwPIhdvc+FOEOFY4pq7tJ+0GW64B+AH1XXV1LZrNHEanmfzDIxoD8F6Lsl1h1rBJHW0TO7b7LTzHuPROy2W56feZ7XK6rpubqWV2XAeRPP81muzbtS0vf3Mgp5RQVjtjS1GA7PkeR+G/kF1iINlYHMIc09RuvBL1JQ1Fa+S3xdnGdmk5wuKqJ4ZZXSUzcM6BUuntR018Y5jcw1Ue0lO/ZzT7vBXjG5CqbxpanukzKmN7qO4R7x1UQw4eTh9oeRU21zVZZ3FdE1lQ0f1ke8co8R1B/dP4rA5SN1XJB2TzouE+SchO6dcziCb2ZuSAPEppGdkm6fYVIjKrTXMaPVy4/gk+nSP5EN9ytso5X9MeabzgKwrpAykk89lTxPjfMxhe31nAYz5pi7zOdTtaSSS7qoVsbx3CAfvA/LdVpqDMoaXdy9W4ej7K0yVJ09o/Af2XT6edm3rA/FW9LK3xCytI/dXlE/ktttvZ/UV5A55WihcC0bp7IUKmdkBS2jIVgW5n9RVV0hVTq+5NtdgqH94I3yDumHONzz/DJ+C5P6RF/vGf4gtN2s3LjqaKga7aNpleAep2b8gD81z9c/WUbDKWh2y9x4ToeztrZnaGQk+7YfTPvXVuzaBjqesqQQ7LxGHA7bDJH4hbI7dVmezmjNJpaBxGDM90p+eB+AC0h6rYp7awRN9ZeT36q7S5zkagOx8NPslZHiElxGeaIjKQ5WP4a3+pYPanuTNyqhRUM9QTgRsLvjjZchJJJJOSeq3naHXmi05IxruF872xgjn4n8B+K5W2rmbykPx3XPV9E4PDWu2XsfBlKXUclRtzOx7gP1JXZdLx8Gn6Nvi0n5kn9VYEKDYXPjslAHe13DCc+PCMqY5+/JXm0MzWAAZ0XlldM19XK4ndzvqUotwm3twEsyjHJJ7wHbBSeiTD8qoc7e9RZWZys7r29nSOhL7eWu4Zaamd3JI2713qx/Dic1ah3CTyWD7fLXWXfsku8FvpKiuna6F5pqVhfLI1srC7DRucAcWP3U30ecAkNKtUxjfMxrjgEhee+wWzg0FxuzxxS1E3cNc7c8LdyQfNzjnx4Qu52uDduy4P2S69tem6X9gXYvt0kcr3RzTxlrfWOS2TO7HA59rbz2XfrHVU1ZGyWCeOaI8pI3BzT7iFoxRu5AGtOngpK+KaOdzpWkZOc9COmFZXOcUluLG7Pl9X4dVnlJu9xhqaxwbK0sj9QesPj+KhtlY8gNe1xOwAPNcjXPdNOdNBovaOHqA0FvYHDDnesfft8BhbrR0AgtRlPtTPJ+A2/PKu3SZUWiibSUcMOR6jAOfVOucuphhMMTWHoF4Xc6n02tlqOjiceXT5YTF5tMGoLVUUM4AEjTwP4QTG77LgPI9OR5HYleX6+hmtVyqo3QmlqKWYw1EDTkwvG4webmuBDmuxu0hepQ/Bz1XPu1Xs0r9TRi+abMTNRU0fA6mmIEVfCMnunEkBrgSS12RzLXHBy172c40VFknIc5WI0deBXVDoXECVrCSPEZG4WtBwuadmdZLVakuEFXbZbXW0sPDNTT+0xxcOhAIzg42OfFby+17LXQ9/I7gYHgFx6Lk6hnJUhvkvabQ/tbC97uvMuh6Sy2n4MAguyukUkTX0zXY6Lg1g7RoKOJuGNc3G7uJuPmryft3tdGOCe82uhaBjhnq42n8XBacbgAvOKiFxcTnRbfUzYqUOBAJdyCwtS1kriC0Obnqs3evpC6IbxOrNSUz3dPRmumB93AHLG3L6Selnxv/ZtXCCNu8r452b+Ia2J3EPe5qY+N0pwAnwztpsHmw4d39l1H0GkDSXBwOM4BXM7z2jRUGpKOzwCKWrrKlkMVPze1hPrSO3GABk+JIwOuKCl7T7RrOodDcO1WKwwuaeKCyadqpZX+DWvcCWnl6wP4LaaMj7PbRSS0mkdPagmrpxxzajvtLwvkGfWw9xBy7I2Y3B5ncZUb6RsbC9+NAtqivVbVVUUET3EOcAT4Z1+S1Nvp/Ta+ngwSJJA0454zv+CGsbnZ9MSzUlLBUXe6sAzQ0zxlhPLvH+yweRy7G4aVTX5s77VOylqJaWd+GiaB5Y9ozvwubuCRkZBB32K5lWaPrqCpirbRUuoK+FvC04zFM3OeF7eoJJ35gnPPChouz7M87QTnquj4kqKplSxkEpY0NyQDjJJP6K2pdbVst0L7pco7SCeFlvhgHA3p60rwS53I7cPu3VzcLXVXVjZKbUlwocjLfRzE5p88OYT+Kylo1HS3a5/srUVviori8jMMzQ6KUjk5pOzgfmOviuh2vTENBH3dND3EZOeBpPCPcOit8jBryj4LljXVRGszj5uP6rHDT2uqOXvLdqaiu5591daYxD3ZjJyfktPaL/qi2xtF70NWPb1qrM9tU13n3QdxNHxJ8lq7Zp9/eNcQtxaKM07GgZ/mngDosyapeT6xyuevnZVO72NksbH4IZPE6J48i1wBB94CJXOr4+7vkuRjia0/gB+iplzsoxI4eK9wtr+0ooXd7W/QLc9l9N3s1fJj2Qxo28eL+S6TDCGt5LD9k0QNFXv6mRo/A/zXQgMLZphiILx/iN3NdJfd/wBoTay/aNWei6XnaDh0z2xA588n8AVqCMLnXazXDioKIHcB0zh+Df8AxIndyxkqKxwekXGFvQHPw1WV0bT+k6otzMB2JOPB/dBd+i7E/bdcx7M6bvr/ACSkbQwOOfMkD8iV056hpBiPK3eKpOeuawflaPmSf0UZ5wo0h3JUmXYKLKdlcK5JoUGoKqaw81aTnYrO364egUxc3HeOOGg+Kje4NGSr9PA+okbFGMk6LO32s7yfuWn1W+0fNVjC0ytY44c4HhHjgIiSSSTklM3Jnoc1mqDzNV3bvc9jmj8cLJYDPJkr0+re2yW8Mi9rYeJ6n9+CZvNALraK6iPKpgfD/iaR+q898ZqbRTOdnj4QHZ6HG69I4w7C4Debf+zbrc6LAa2OqlLGjGzS8uZy8iFcoXauauf4why2GceI+OCPoViK0cVa8fdAb+Gf1Vw5uLtEB/ZQOJ8tiP5KqazvrsRzBlDfgMD9FaxHjrrjLnZjWxD8M/ktse0B4Lyw+yT4phwSE9INk3jbKlUSYm2a4/65r0X2d0voeibRHwlvFD3mD+8S7P4rztJE+YiONjpJHkNaxoyXE8gAvT9kpfQbNQU3CW9zTxx8J5jDQMfgse4u9RrfFejcFxZqJpe5oHxOfsua9qLuPUsIx7NM0f8AE4/qsrHgEeK7Dd9F0F8uYrat0rnBgYI2u4W4BJ32z18VMotM2q3f1FDC12chzm8Th8TkqqyqYyMNxkrbqbBU1dXJMXBrSfM48v7rmFppKiqwIoJJc/cYStTR6YrpWjijEQPV5/TmtyAAMAYHgknZRurHflCvRcMwM1lkJ8tP1UG1Uc1FAWTSNkd0LVKlp45iC9uSE4gqZkcXc+dV0kdHBHAKflywdDr49Uyyip45DI2CMSHm/hGT8U8Oaq/27HKH9zG53A90ZL9twcH8QVzvti1dXW620NNS1UlJLUPLnugeWHhAxjI3xl34K0ylllOqwKriC30DCIhzY6NGB8dB8MrpF31NarEyR1fXw05jZ3jmOdl4b48I3I+Cx9y7YaOP1bfRy1JP25j3bfgNyfjhcUoonOYGuOeJwklJ6uHIe4c/efJWkS1orfEPa1XAVnGVdNkU7RGPifidPktvVdpl7rc8EkVI3whjH5uyququdXcOE1dTLUFo27x5dj3ZVTCMva3+8U7PUNjYXOOGgZJWjHDHH7LQFyFTcaur/wAeVzh3EnHw2TVxre6ZwNPrO/AKpbhx8kUszppC93tHp4eSk2yhkr6yGmjHryODQTyHiT5AZPwUqzMZWitkYt2nXP5TV8nC3xETDufi44/uqO54T1zrI56kNgOaWFrYYf4W9ficn4qpq60Rtww+sevglGgSPOTgdEqurQwFgdjHMrn91uzq+sLmnETNmA/mrLU10MEIp2PAfJ7eOjfD4rLh3mtyghwO2d12WfM/J5QpzJz4qTDN8lWNdyU2niklI4WuPuC2VTVnDOAd1OgnLsAKuhoqgEfVO+Ssqane3GWke8JwRgqdC4kKQOSaiBA5J9vJPynYX0YbySgcFEOSCiVhLRd41p5hUuqG1c9pnFFMYagNJaQeZxyXlqu7TNV6X1Lw10zgY3jjackEZ3XX2Phya/B/o8jQ5v5TuV1FmsEt6D+wkaHN6Hcr2GD1Cca5YzQOv6LW1rZU072h5zxR53bha10nC3K5apppaSV0MzeVzTghc9PBJTSOhmbhw0IWf7Q9fw6DsMle/DnggNZzysF2X9s917QdSmBsfd0cQy8taBjPJc7+kpq43K8QWqJ3EyHd3D48iCtp9HjTn7JsTax7MS1HrA434fNen/wiitfDPp9VHmeX2c9Af7ar0Q2ykt3D3ptSzM0ns56A/wBtV6Ip5uNm6lMcspVaws1ib/T7nS0xHNr5QD8uavqKvhrYWSwyCSN4Ba5p2I6Lyx0EjGh7mkA7HGi83fFI1oe5pAPXGismuSy/ZRO94QvOPbl286j0nqcWqxyQRQuYMvfGHO4uq1rPZqm+VPotLjmxnU4GAtO1WqovFR6NTYzjOugwvTfFkc1Bmv1upZmwy1sEcrncLY3StDifDGcrH9n97rb5oakrK+cy1c8PG44wQccl4913U1Ng7WJ5XzyObBWtmZxvJw3IPX4roLDwv/GKuekfNyuiB2GckHHh1W3ZOHf4tUz0rpeV0YOwznBx4L6Ah4PIqHebpHZ7bU1chHDCwv364GVFslzFxt9PUjlLG1/zGVyb6Tetf2Do99FE/E9WeDY7t8CuZtdvfca+OiaNXHB+65220L6+tjpGjVxx+q53dfpc3ufUDKehoqSnoRO1hkdlznMyATvy6r1RbLg2vpIZ2HLZGB4+IyvmdNDLEGSSNLe8HE0+K999jd8/bmg7NU8XE51O0HywMfovUuPbBQ2ulppqCMNGS046nAxk+4r0jjayUdtpqeWiYGjJacdTjTPwKR260puHZreY27ujj71o8SF4u7O9KQ6x1CaGWQRjHEM9d17x1vRiu0/XwEcQlhezHvBXh/snlFm7UqGnecAzupyT78forPA1VM2y18cDsPZ6w+H9lZ4OqZW2iujhOHs9YfD+y7jZ/o82WlaHS8cx6gNwuK9telqfTWqJYqOMx07HCLf73A135OXuS30LHU7DjovL30h7N6TZa27NbsLxM0OHUMxD/wDm1jcI8R19RfYWVcxcHZGCdNRpp5rM4WvlbPd4xVSlwdka7a7Lq/YvrIN7HqCte7ilgi7gebwcD+fwXNu2Ds+pG6Sbqi5ySOuNfUCCgiL8cyS559wa8+/h8VVfR7rajUFqg03EXNAreLyHEPaP8I4j81O+k9riCv1eLTRHNs0/B6FE1p9UynHen4YYw+cZPVc1dvTrXxJUQ24lsjnFrcf7+v3TZaapor7LBRu5XOcTkdx1A9+Vyy0yUdpqIpZwDDD6wj5cRHIe7OPgFLf2hRRwd0BxM4zI4Dfid5/H8Fh42S3WoLnnbyVzUWinoYoYg0ul4eOQk+I2HwH5rSq7RYuHn4vUrpqk6ua3YE66ldNV0Nst7sV7jJKdSB9yqu/3P9rVvf8ABwbY5L019C4x1l/kZJ63FGHnP7uw/NeY7oGljC1objbbyXffoYXQU2uBAXY4g5o/wk/oum4mlprzwhDW0jC1sTwADqQNvuFavroq7h5s0DcBh27ht9wvfWeEYUG/3Flns1TVuHF3TfVYOb3HZrR7yQPipbHcQHvVDXj9v6ppLcG8VJbmitqT0MhOIW/g5/8Adavn5xIGG7nQfvwXiMYy7Lthqfd+q8q/S50RPR6NorhI3vKiOUTVMjesj/aPuzsPIBc++jJp2waodWU1ygjfWslb3XEAS4EL2h2r6Mp9a6ZrbZOwFkzMA+BXz8vNm1F2Ia3FTDHLG2KYvjeAeF7Qds/NfQfCdWLvYZLHHL2czdWnOMjfH1yvWuH6w3a0yWpsnJMNW64yN/8AyvaFw0bYtF6ar7tJQRiCjgdKW8i4gbNB8ScAeZVN2baJNh0VTVdwjjZcbgXXGsfw8P1kh48EdCG8Lcfurjl5+lVR6307arJdaR9PTipjmuLubZ42Hi7sAb4ccb+LQo3ad9K+o1JSS0FgYYWygs43R74OxxlcUzg3iKrrOynYQB+YnTxOfJYUfC94ld2MzTknUk6ADx/fRaXsN1BapNM11CaqNtdJV1M3dk7kGRxGB7sLKdr2nW3ugkLW/WRAyNKrvo9aJka2TUc+RkPbEAee+Dn5LY35weSHD1ScEe9c7dmwcN3Zn8KmLzHjLunN1A8E6sZFa6//AFGTmLca+PULyzHM+kk4XDbq0qDpmuuGiOz+cW8EatrBLQsrozvSUzpTJI+P7r3ZYwHmA0kEEro2qdG8GnL9c4zw/smSPIx7QeSB+AB+K5n2sip7OWabp8k1dfZ6e4VAePYkk4stHkOFeiVN54X4lDaq6MdHMBry7H9+K2qm6WO6ET1zXMlG/L1Wb03pGKwuNXVvw9o2zjAWW15qEXaoEMLgYY+RB5lQbnq24XIFr6h4Yfsg7KhkeXZJOVk3riWkNALRZoyyHqTu5YN0v1O+kFttjCyLqTuVp9Q3KWgdpyeFxa5tsi6+D3hW9v7UCyANqYO8eBzB/NZzVwJoNMv55tmPlPMP0WbDyFzNp4guNlz6HLyg7jcfArBt94rrXk0smAem4+C7TonVLtX6qp6ItjprdBHJV1s55RU8beJ7j5cm5/eWs7LY5NSacuN9niLf2pWzzxMd9iMFrGM8w3hcPguWUjX6T7IZ5o2kXvWVT6BRgbOFHE4d8QegkkIjIPMNPgvS2ldNDS/ZhpWIMLGVFPJJGcY42tf3fH/eLHO+Kz7txLc7u8SVMxIafVxoAR1GOqu1V1r7g5hqZCca92D028FyK+ROwxvi/H5oux+sZc7bqq2huJaKt9Jx4te3Gf8A7H+KsL3CDXQs8XP/AABWE7Gr42x9pd8bOSKSajdLKB14HNz8mOkd8FzJlfIS55yf7rPflzsuOf8AwurPpQ1oyNiFn2R/s/U0Bds0kb/gtnWwCIBoIIGeFw3BHQrNajpT3MVU0bxO9Y/ulGEwaFRtZ0A/bUzSBiqpBnzxlp/RcNyWTGN2zmkg/BehdXt9IprZXD7pY4/xAH82rgOqITbtRVbcYaX94Pc7f9VYYmO2CVbTml9znD8So15kEVI8jmRwj4/5ZTttd9VKOgkJ+YBUHUcnDTws+8/PyH+anbuqztlRE8JClyTmmkjcw4cFCeeSXUuLpT4AAKUhQg4U+UtkaKiMeo44cPunwUvTlb6BemgnEVSOB3k4eyf0+Kp6WqNO88Q443bPZ4j+aeqo+6a1zHEsPrRyD/XMKMjopWu6rqPtNVDf/wChOZW4Bjb9XUA9Yz1+B/AlT7LcBcbfDMMAubuB0PIj5p6uhZJA/jaHxkEPaeRaeaiBxurLh3LldzpPQa2SLmwHLD4tPJQH81c19MYJ5bVK7NRSjip3k7yxHkPeOXw96pXnfcbq2NVSd3pLlNnm+vpq0cph3U3k8cj8R+QUEnKfpgKiKWke7hEo9R33XjkU9MVu0qXSTd1KDnY7FVNvqTPTjiHDIw8D2no4c1OaVGQpAcjKv45cqRG9VFNUcTR4hWEDnSbMaXHwAymYJOApmjOysI3ZTvEl0VmuFVju6SQg9S3Ck1Ogb1dSyAyMoaVxHfSh2X8PVrfDPLK2qTh67V3+z0z3Dv5SB8TotqntNwqcdjC52euDj4nRVltoK7WFW+ltshpLfE7hqLiBnfqyLxd4u5D3rpNppdLdnVCxtTW0VuA9fNVMO9kPV2D6zifIE8lnLv2cy1FuZQ0WoK61Qxt4WRUwa2No8+EBxHkXKHYOyDT9JDw1dKKipzvKZC5rj44PL/LZWbZw3U3Svfbi9scjNC1xxqNwMZytShtFTJUmlY0CQbl5wM9wAzn5Kfq/6UcVBCaXSLBWznINfVQOZEweLGnDnH+IAA458lwusulfqC5VNbcKl9ZXVcrp5ZHgDje45JwAAN+gGB0V3r7QU+la90kbS6ldu13QZPJM9nlm/bOpKaPBIYePPTZSCyVEFe22SNxISB8eq5eoo66W4ChqBh5IGOmvVWLOzS+Otxq3Rx08IZx8UjxnHiAsq6nFO4sfI1rWnBcT7S7l2r3ptqsLaOJ5jdL6uWnBx1C8+VdRDTZccA+J3JW9xVa6GzVTaOkJLgPWJOdT02CvcTW2itNS2jpCS4D1iT1PRX1HXNpqZzRLwNLsgcGXcufh+ChVM090Lqdk81Q88oYog4+XLC1+h+yu6X+SKevp3wQuw5lK8ljiPvSHm0eXtHyxvC15qCKlrn2OxzBlDTZilqIQGCZ49rhxyZ0wOe+5BXD5K5MMGMlaHsf0PNNVS1dybxNhPC2N4BGeoPu8Frr32hMorwbXRMaOFntA7Z8FYdntI2j0NA6D1XPiL/c7C4/LGRqE1sxL3CbLm9Mdf1Xs15qpOF+HaaCgPLJMMlw32B394Xsda+Th+zU0FF6r5dXOG+wO/vXTKTXNXDhroWy78+Lf9VsLVdIb9SElgBGxY7dYqCgaAOFoA5bK7sIdSVTR9kndefcGca1jLiyir5DJDKeUh2u/XX5qvw/dqqGpEFU8vjfoQdd1FvVTFaqt8brXFK0nZ3HjKhsvdA8evY2nzbMQtJq2jZLTNkLA7hduqe16bhukrYo8tJ5EOXL8cWtlgvc1NGMMPrN8j+h0WPfrSKG4Pij9k6jyK0mnqqGutTe5iMEYyzuyc4WBu8clPXTMac4ccB4XSLbp6XT8Lo3uLmvORnoqLUWmJ53SVkQa6MncE4/FekcTPF04It1wGpZ6p+bf/iupvETqywUk/wCZmh+n2WKpbdTV7uGeodb6ji9WR7csPh6w5LqmkO0XV2gmRsrw7UFnH9tC7ika3xB+1/ez7wuOXLUlFbnvjPeSSsOCxjcEfEqrj1vfoYpKizcVKxh9d0Z43N/iZyI8+FeCtop5hoPivNY52RH1sg+H36L3rovX1p1vQek22rjn4QO9jPqyxE9HN5jkdxt4ErTCaNvXiPgF887B2rvhu9PX3alniq2bC62WXuaho65Z7Dx5Ebr2R2Va5bqiw/tBl2pNRWyPDZK+ljMVTTE9KmD7B2PrN9XYnYbqdltDfbK0DJzDmb+i6FJLK4eq0N8+ZUKWB5dl2XHzV/TxernmPHxSZqJrgXAYPgtBlMyMfyxhVe1OdVnuDhRg4UuenLSdsKK5hCYRhWWkFQLo/ifG3wGf9fJFZ/8A1jDnz/Ipqudmod5ABLtkrYatr3uDWgHcrDccz58V7nTQui4e7NgyTGdOuXAn7raUr9wr2hfnCydLcqbrURj3uAV/Q3CnJ/6xF/jC2mOaeq8TlpZ2e1GR7itVSu2CntVXRStewFpDh5FNasuX7L03XTg4eWd2zl7TvVHyzn4K1zBrS49FQjgfUTsgZu4gfE4XJNT3P9r36tqgcsdIQzcH1RsOXkFVoKbZaM3C70dMBxd7M1pB5Yzv+C5MkyOz1K+n2NjoqYNGjWN+QH6Lt9lov2faaKmxgxQta7bG+N/xypbuZSyMbpLhg5XYgBowF8qSyOle6R25JPxSUhw5pioulFS/19ZBD/3krW/mVTVmvLJRg/0wTOH2YWl2fjy/FQukYz2iArsFBV1JxDE53kCVmu1SrzLQUoPJrpHD34A/IrAq71dfY9Q3c1ULZGRBgY1sgAIxnwJ8VW22D0q40sOA7vJWMweRyQFzU7u1mJHVfQ9kpjbbVFHKMFoJPmckrtdLF6PTQxfcY1vyCXjdLckrqQMaL5qe4vcXHqknYoiMpWD4onbITEhONdwhJ5BJJQEmFFuthtF+aGXO10de0DA9JgZJj3ZGyxd57MtGadt1ZX0dnjoanh9Q008sILjsNmuAO63xKw/aRcsMpqFhIz9a8eXIfr8lBUP7ONz8arpbDTy11fFTcx5c5Iz0Gp/RYUnJVhp+2Mu93p6WQvbE8kvdG4tIaATsRy96rlptDUffVlRPjaNgaPeT/l+K5ynZzytHive73U+h22eUaYaQPM6D5laKTRttaci53dvkLjL/ADUaTSlHk8N1vQ91xlH6q5MJ8EXdFdaTnQlfNod3qmGmKUjhdcLu/wB9ynH/ACuCA0ja3HL57xJ4g3ytAPwE2Fc90UtkCqvp43bj7J/N34WLv9utlgqYTStrDLIw8bqismqNs7Y717uHry5/BN2jS1i7Rql1pvtE+uoODvjEJXxes0jB4mOB6+KjatqO/vk4GeGLEYyfDn+JKuOzPjiudZPG0OkZAWtD/ZySDv8AJcwaWOSryM79/cvZ3U7aPhk8wwSzP/Mc/dSLd9GHsfudTWRDSzpX0jmxyH9qVuA4jix/XeBCtofoz9ktvP1ekICR/va2pkHydKVZWGjrLXQObUVIfW1D3T1L4chrpHEk464BJA8lJfC6U5c5zz5uK3vRI+UanK8UcxvOeXQKNR9i/ZtQf9X0VY89HS0Ucjvm4Eqzm0Xpq3W+burTb7bTtaSfR6djAPgAPJQHUb9+AkfEqDV0FRUDhLnFngeXyVV9I8ezqpowARh2Fgq4DjcxozGCQG42RUrcN326LXnTWSS9gKxtRdIvSH8DD3YOG48ByXOVdLOxuCN16Rw1GKqpL2jRg+Z0H3Uju+8GMZRehMkGCzdaDTNrbc7e6pwcOeQAR4f5lXsGnIgd2hOp6SURj1Ssq/VrDcJGk+zgfAfquW3/ALPLfqyi9GrKcvweKOVvqyRO6Oa7oR/5qw0DpzVllqW2u69zd7Uxp7i6NeGTNA5NlYR6x6BzT0GRucdWprHEwD1fwVjDbmsAACtinl25T8Fy76prs4VRRWkRgeqrumoRgKZDQ8tlPipMdEvYy/0n4KkXA9VyztIojTXSlkxgSQ4+Icf5hZJdH7XKYMp7bORw4c+MknbcAgfgVzcEHkcrnKphbKche58PSdrbIj3ZHwJC6n2StH7GrD19Ixn+6FuSVh+yQj9jVgzv6Ry/uhbnnuVpwf4TV5bff/qU3n9gkEZK4dq+6tvOoaypY7ji4uCMjkWt2BHvxn4rpnaBfhZrG+NpPpFUDEzhOCBj1nfDb5hcbVKrkzhgXX8J0JY19Y/roPufjp8V0PsspOGmr6oj23tiaccsDJ/MLayHKp9GUBtum6Rrs8co752f3tx+GFZvcrkLeWMBcpdpvSa+WQbZx8NPsm5Hc1CmfnJT0zuahyv5qTKzwFGqpMBxJwBuSVzm8XE3KsdJyjb6rB5eK0GsLqY2CjjO7xxSHwGdgsksypkyeQL0vh23dkz0uQau28u/3/TzTtLB6RM1vTmfcmNa/V2R0w5080Uw/uvafyyre3QGKmdIRu/l7lX6kpzV2WuhHN0TsfAZVinZysz3rEv1Uaqq7Nvss09/X9Pcmz7R965F2mUzafVMj2twZ4mSuPiccOfk0fJdcHRcs7XCG3qkON/Ruf8Aecq9If5q6DiZn/pmv5SP0XJ7SBLc3vPJpc8/6+KmW0l9tdKdjPK+Tfw4sD8lXU8hprfXVHJwYWN95/0FdRwejUEMP+7Y1vxA3XRt1JK8VfsB70xIPVKZxsE9L7IA6lILdlKoF0PsZscFZX1twmY2R9KGNiDhnhcc5d78D8V19cV7Ir2636iNAWOfHXNI2OzXNBdn5ArtS5mvDhMc+5e4cKOidbGiMagnm89/oQggqHUes6DTjzDLxTVfAJBAwb8JJAJPIDLT8lhbp2lXO4FzKYNoYiMYZ6z/APEf0AUMdNJIMgaLVrL1R0RLHuy4dBr/AGC6hWXGlt7OKpnjhGM+u7BPuHVZ6t17RsJbSxPqSPtH1G/jv+C5m2olq5TJPK+aQ83yOLifiVY0zSSArzaNjfaOVyFRxNUS5bA0NHxP6fJatmo665PALxE3PsxbfithQyd7SxHrjCwVrjw5pxstnaZ2YdBxfWAcfD4Dl+YKbURtEeWjGEtjr5pK/lmeXc4I18Nfso9bTNhncGNAY8l+B4k5PzOSuD9p9y/a+tDTRu4o6WNsfiAR6xPzOPgu/aiqY7faamtlOGU8bpHHwAGT+S8x0zpKueor5x9fVPdIfIE5A/FXaI87MrluJ4fRKt0Y2dqPf/fKnQNDWhreQ6+KkCRsTS5xwBumDIyCPiccD81FZM6uqWtPqxtOS3y81rbLiTqrullPd8Thh0m+PAdFEuFR3sndg+qw5d5u8PgjlqTFH6pHevBLQeTR1cfL9cKECOW5HieZ81ImFKad8rQUH/RNrdO7aqq2lkXiyP7TveeQ8sqrtNA2uqwHu4II2mSZ/wBxo5/HoPMhHcrk6uqnyhvAzAbGwcmtGzWj4fqmI9kZ6pyar4Wlref5Kkul0ZQU75XEF3JrfvFO1lWylgdLI4taOvisdWzSXaqM0g4IxsxvgFepac1Dsn2Qq738o03UWaolrZ3yv9eRxySpdNbXykF54QpNJSNYBgY81ZwxhoXTgADAVMR53QobZDEB6gJ8TuriGINAwMAKAyQN6qVFU4TsqYABWDBhPtaMKHFUg81JY8O5FLlOTgjaemEoRBBoS2jxSZSYC+h6CCCRQJioi42lcj7V+zOHVFK+aNgbVsy4OGxdtyXZQMhQq2jbM0ghaFBXT22obU0zuVzVdo6yegnbUU7sOC8X6X1LdezPUWCHR8Lg2SN3IjO69T2/tHt940nNdoZQGNjcXDOS1YTtZ7LIr/TPqaZgjq4wXZH2sBeexdLrptlVbe8fCx4LJIjywV7l6JQceQR1UZDKhmOcd46/2K9j9GouNYWVMZDJ245h3jr/AGKsyZ9da9c52XGeo3cNwBnn+C9faUtbLdbYYGsDWsYBge5ed/o+6dbV3OaufguYMNHkV6ioIDHEAB0XI/iBXtfWR26H2IQB7/8AwuY43rQ+sZQRexCAPf8A+F5n+kVoh1Hdf2zAHGFzGteOeDlb76OPaT+1ra+1Vkn18LmtjyeYwt1rrTcOo7NUUcrA5sjdsjkV5OoKit7NNfRuJdG2Cp3HRzc/5rbtErOK7E+1TH+fCMsPgNv0K17VK3iazPtkv+NEMtPgNv0K94vnJiJ5nC8Rdr87rx2pVPdHPHKOEHo7qPwXrSw6oiv2morhC4OEkReMdCvIVTGL92uPEbjiSr4mAdCDy/ArO4AidS1dXNKMGNhz4HP9lQ4IjdTVVVLIMGNhz4fvC9g6IpxT6boow3hHdNyPPG68r/SQtJoNcifhwJ4+fuK9eWKPgoohjB4Rt4Lzz9K20YbRVrR7MnC4+RH81mcDVpjv4yf8TmHx1+qzOC6wx3wZ/PkfHX6rsfYtfv2t2dWepc7LhThr/IjZecu3TUcuuu0eO3U7u8iicImYOeLdafse1+2xdj10D5Q2Sklc1hPQuGR+SynYdYH6u1rPdahnGyN5eSejjuMLqrZb22Ouud1mGBCXBvm7UfIhdLb6FtmrLjc5RpEXBvm7UfIhR+2LSDdPWSzOjZgRt4D4jIz+a7X9FK9emaF9Fc7L6aZzPcDuFW/SJsHpGh5Zms3hIkz7isp9Ea89zc7vbi7Ac1swHieSrTyuvPBb5XnL4n5+ev8A3FRSSOu3CLpHnLo35+f/APEvU17Z3lvmH7hXg65wm1drUjo/V4K0SNx4ZBP6r3xVsc+3zTd2TGxpLnH2WjHivBd0kF07XeFh71npoj4o98t4uY+aofh0XF1Zp6vJqqvAgcDV6eryL3PbLlDFZ/TJniOBsJmke7k1vDkk/ALj/aHpua8dhUUphe+qmpjcZAGew+ZxmIJ5bF5C7Rf9MU0XZ9S2KBpkq73JFau+PrOEUgPfuA6YhbLyWw7RrBDVaLq7fDC1kPcGNjA3AAwRgLy621PodyimZsxwPzXB0NQ2iqIpm9Hg/ArwF9G/W1Poi83qtnY17o6N00QcQN2AkgeZ2HxWE1JUz18U9VPI6WommdNI9x3c5xySfeSVXGN9ovtVSjLOCV8DvHAd/krmaISwOadwQvSeOJv4PxXS3TGWYa7zwSD8l7ReeShu7K8D2g0+eNFUaeqoaeo+vP1Y9Yjxx0+KnVNwEr3yvcC5xLj8VSXCj9Dm4M5OOIjwzyUQyY2yVoXuz8P8SVP8WZcGxh+C5p39w3+SmraO2XOb00VIaDuOqk1NUZgGjkM/mul/Ru1A2w9ptufI7hjkka0/PH6rltOe8aCBzW57OqKnivtLPI3icx7XDJ8DlVarijh2ns89hp2uMeMNcBnmO/MckY1x+ipVN4tbaCW2xtPLjAONzvnp1X1CFXHTUUlRNIGQxMMj3u5NaBkkqs0FFJJZH3WcFtVdpDWPDubWOAEbPgwMGPHKpdT1Rr9J223w5Dr3NBRt4T/Zu9eX/wCxNkW5a1sUbWNAa1owABgALwwDL89w+q8UPqxY6k/Ifr9kxV04madtiue6x7OrZqeB8VfRx1MZ5te1dIJw1UOtbqNP6Tu90bgyUtLJLG09Xhp4R8TgfFTRzyQOEkbiCOo0KIi9r2mM4d3heP7D2CWDVWodR1nozxbqSrNJTMacMJYPXPmORH8S1FL2P2PTdFV1FPb4eKKJ7wSwHGAfFdX7NdOssPZtaI3AmSWAVL3O5uL/AFhnzDS0fBJ1VTti0leZABkUkp/4StmfiK7TQCKapcQdxkro5rrXzyOhdO4tGBjPu+a5F2M0IHZtSHGDwyH5vJ/VU+raYxQyuHnutX2SNFNpijpTyNLHJ8+IH8goWtaD+jTbbglci4kgEp40lPiVze7UTbl2Y6nc0DiqjSRvHn3wC4//APxFbQLJ2+zUcUfd0sdBTtgb0DOEnA+Jd8l16qqTB2U67YHcElNDS1DHAZLfruEn4ZCxX/8AEZqotYaj0LrWjYGUN7sEfCAQeGVkrzIwkcy0TMafAgjor9MeZh8Fj1jS2Udxz9AvFQyDhL4PVB6pbmESFOSs4WN8lYVTCtNQDv8ATmm5cbshngJ90zn/AP5xVen7BV6ov9us9AzjrK+oZTxAg4DnEAE+AGck9ACrirZ32hLfJ/uK+eMnycyIj/lcr3s5LtMWDVesWngqbdRigt7wcObVVXFGHtPi2ITu+ASl5awkb9PPopA3LgOnXy6p3UlVHq3tEMNkBqbTZmxWOyM596Gerx7e0XvLn55nvBnkvanbjR0+mb9aNMUzg6HTtnpbfkfaLWcRPvPEvNv0N9Cs1D25aEtz2A09HU/tKYkbN7hjpxny42Nb8V2HtB1D/tNq2+XXOWVlTNKzPMMLjwj4DAVCXDWho6K/Hlzs9dz7/wBFxu8guvtHGPssle75LkdhrGWftVtc0p4YZqp1JLvtwSZjOfcH/gux1De+1XE3wgf+QXAtctdBc5ZIzwvbK4hw6HPNQxHmkLfBTS+rGHdxXofS1xdXWaKjmOauglfRyZ5+qcN/AYU98LZ45IZBkEFrgsHZr46HVElVGfqLpTwXNrB142jjz7nAj5roUzmiqD2nLJW8QP8Ar/W6st1GVE7Q4VWf6bpeenO8tK4jHm05/muNdpdB6tLXNHjE8/i39V2enkFFfZoHn6qqZxD+LGP0/FYXVFn9Noq+3u9sZ4D5jdqlYcFNcMhcvscnexztPtNw7/X4KDqZ2PRR/F+ikabmEN3ZFIMNlzE4Hx/8wEnWtOaaWlaeheP+VWho5VXDLVnnnOEt+7ifFNuOyX9kKRVwiUuinYWmmmP1Mh2d9x3ioiDI3zPEcbS955ABHKXHA3StzzaLTaQrn0NbUW+Y4eD3jB0Pjj3jC22Q5ueYIWYtehbxcW0VZ3DoamncADJt3kfUfLK3bdK1UUW7g4gbAbnxXQs4UvVRH20dM4t8sfVdVBY7nLHztgdjyXKtc217misiGKqgd7Q5uiO4Pnj/AO2Wbnc2sgFVGMZ2e0dCun6qo5Le5lRJETGAYpwRn1D1PkDn4OKquzqxUtDqp1NUQsqKOoYXQl4z8Phn4gqrbbbLWVzLc89m9xx6wOh8Vm09ukqK1lI71S44Oeh6LnRdjmEA7hOc4XTu2uywUVRbp4IWQxuYWEMaAMjdcva0ucGq1ebW+zV8lC93MW412zkA/dQXW3utVY+kecluNe/Iytho/RtVqysNRTytgic3hqA4EjjHIjyKt9XaPOlTTATmcSg5OMYK3/ZtZW2PT0TngNkm3J8fBF2m2+KstNO58vcPbLwskLct4jyDuuDyyOXgV6nPwdS03DD61zP9YDQ7OToMg4xtsvSHcL08NhdUub/PwHZydNe7bZcus1DLcq+KnjG7zhddo7TbtK0DZJiOMDm7fdYvs5t0sV9DpRE8BpDgyVpcw9Mt2d+C1WvbZXXBsApIzIzHresBg/FU+Foae3WGovrYxJK04GdcbfrlMsNM2gtU10EXNKDgAjbb9VX3ftPho3MZCwkuPMMJ4Rtvjnncbeak6R7R6TUtz9CibLx4PrvAAOPjn8FQUOkBT1MdTWSxyTMHqxR+y33k8/kPipdvsEEGqKe5wcUUpIEnCPVk948fNZto42utZdoG1EnqFwBAGmCm0F7vMtZE6d/qlwy3wS+1vW1Ro9tKIqIVUdQ05cZS0NI8sHK45SdoN1qr824vmMQZ6rYWE8DR8Tz8Suudvts9M0pBUBuTTzDcc9xhcDpYOGUMHJu7v5KHjSB1t4hlnh0LuVwI8v1BXO8YOqKS9PMb8A4cPh+oK9LWe727tHsJimA7x2xHXbqExoTQjNIT1tRJ63ESQSOQzsfkuR6QuVXRXmmbSOxLI7hDR1Xo8x+lUYZKS3vGYdw7cxuvVeF6yLiRja+pi/nwac3Q5H7+K9E4cqouIGtrKiP+fDpzdDkLhWrYrx2kaunorPTd+2Ahr53kMhiH3i47D8zjYFdH7P8AsPtelHsrq1wul3GHCplZ9XCf+zYeo++7fbYNW1sVrp6CGOnpoI6eFhyyGMYaCebieZcerjutTS2l8jckEleCXhlW+4TPrhh5JJC8VvAmbXympaQ8kk5+y552q3saK7P62opT3NVVOFJA8HcPeDl2fEMa8g+IC8tUdM6eobGzbHMjou//AEru8obTpum3DJp53kebGsA/+UK5HpW1GaQPI2558yucmfyZHcqEMfaOC7l2eubJphkLeUeywV4sDqa6VTOHbvDjbxWx0TKbcDEdmPIV9drLHXHvWgcZ5lex10LuLeFqeWj9aan0LeuNvpgr2uWD+N2aF0OskWhHXG36KiscRmscLj7UY4Cfd/lhXWnbRPe7g+OlaCyniM8zzyYwbZ9+4AxzyOmcR6OifbqSpj7kyF+CwZxurPs9qLlaaG6wzRsZJXGNrDGDkNBccH/F+C8g4X4VuVde4v5Raxrg5xIwAAcn9FgW22VNRVRgMIAIJJ6ALpnZL2Wx9qt8qLU7j9WIuaQOa5b2mWp3Ylr6C1Th8zZiXwkDA9UjIz8Qu89nva5YuwPT9dWTu9K1LO0tigaDiDIxl5xy8l4/7Ue0mq7Udcw3B73SwUfFiU8nOPPHyC6b8Q5qS53iR7DkMAb8N/mqnEVaay8OMWrGgDPiN16Ejki1DoiS4xMaHQyNOxzsUnTlJSXG21kNU1hLd28QXGND9sk9tDNMU9GaltynbB3khPqguA2xzxz+a69FpmbJbUSviZ9psT+EnyytK13KgHBdTa6mUNeHZY07nY6e/K3aOsp32SakmeA4Oy0dTsf1XFu1bRUQkdU04HG0n1m+HTKxehKo2q/UVQ84jMojmaeRaTg5Xe9caepKW1OdCwt2OS4kk+8rhT7eaapl4eT3uIHhheYUUp27l5zXQjPN3rp2v+xOnron1ts4bfVn1icEwyHwcB7PvHxC5jpjUmpeyDWkNfQvls16p+bX7x1EZ5tcOUkbv8wcgEewqCh9Is1I57c8cLCQRz2C5rr3QlBcS233CIuoagn0ado+to5efqn7p6t5H37rbq6YOAkZoVQo6oxns5NWr0L2Qdp9p7U9KsulsjFHJERFX2zOXUMxzgDxidglrveOYIG5dGOJfPLQuqL79H7tEjqy01EcY7uqgYcMr6Rx3Az12yD9lzRnIyD9B7TdKS/WehulvnFTb62BlRTzDbjjcMtJHMHB3B3HXdYzHZyDoQtGoi7IhzTlrtQUxV0gcMtVRPBwnktFK3IVbUw5zsmPbnVNjfhYyrBFTKDz4imVo6u3xVBy4et94c1EFljJ9t/4LnpKWTmJGq9voOK6AU7GTAtc0AbZGg6YVOgtDDYKZ3N0h+I/krSj0xb3n14nO97z+iYKWQqy/i+2s2Dj5D9SFiwSCCDgjqEp80kgw57nDwJyupUGkrQQ3NEx2PvOcfzKweroqen1BVQ0sTYYYuFga0Y3wM/jlJLTOhbzOKt2viGmu9QYYY3AgZycd4HQnvVMlMe6N4cxxY4cnNOCElbXsvtdLcbjWmqpo6ljIgA2Vgc0EnwPXb81DFGZXhg6rZuVay3UklVIMho279cfdZP9pVf/ANVTf/XD/NMvmkkGHPc4eBOV3k6ZtGf/AFVRf/u7P5JJ03aM/wDqui//AHdn8lp/w95/MvPW8cUbfZpyPguCoLu/+ztqaQRbKMEdRTs/klMtdFDuykgYfFsbR+ib/D3dXJ547g/LAfiP0XB2tLzhoLj4BazQ+mauou0NZNC+Gmh+sDntxxnpjPPxz5LqIY1gw1oaPADCI5U0dCGODnOzhZFfxpLV074IYeTmGM5zod+gSDySUshJPNamV5mWokR3BS+FFgp2VEQm8dERHRO8KItSgowmSMrj2obj+1LzVVAPqF3CzfPqjYfln4rp2qriLZYqqUHD3N7tm2dzt/M/BcgWNcZPZjHmvX+BKHAlrXD/AHR9T9kF0fQFCI7IZiN5pCQfIbfmCucLsun6T0OyUUR5tiaT7yMn81Db25kLu4LW43qOzoGQj87vkBn64Txh8kXcjwUvAQ4PALoV4flRO4HggYQ1pJGABkqXw/NM1rCKGoIOCI3HI9yjJwMqRg53BveuKTzOqJ5JXe09xcd87k5W47MYgWXB/wBrLB/zLBre9l0gJuMXX1HD/iB/Rc3Rn+e3Pj9F9BcUt5bNM1mw5fhzBbjg3ShF5ZTrWpYbn3rpCvnvKZ7pDuvIKSGZS2x+SRKFmdaVgtWnal7SWyS/UsIONzz/AAyuQLoHazVETW+kGwDXSnzycD8j81goYzNMyMc3uDRgZ5rnax/NLjuXvXCNKKa2CY7vJPuGg+mfeu06Lshtun6djzl0rRKQR7Jc0HHzytAylHgnIIWxtaxo4GtAAA6BSmRhbrW8rQ3uXhtVKamd8z93En4nKYipQeQUuOnAS2N6J1gxsnKphHHCB0UhjAB5JEeydG4SZRhYTtmpRPo8SBoJgqGPz4Agt/ULhQJByNivQvanB3uhLkNst7twz5SN/TK88rDrhiX3L3Xgl/NbHNPR5+gP3V1pG51dv1JbpKZ7jI6dkfBk4eHEAtPvyvQl5vFHYqGSrrJRDCzqTu4+AHU+S4lZa+06KDK4PZebu+MGKNgxDTEjm5x9p3kOW+45qiv+pbhqWr7+unMhHsxt2YweQUcbmQsIIBJ+SS52d1+rWSAckTBgu2LtdgO4d579MhTdUaxqdR3eWqI4IfZihcc8Df5nmfehpenm1Be6ej4W8DjxSEdGjn1CpKWlmrqiOCnjdNNIcNYwZJK7TorSzNL2zEnC6um9aWQdPBoPgPzyq0VHHO/Lm6dVoXitp7JRCGEAPxho7vH3fMrSOcGN4WgNaBgADYKLNJglKlk81Dmk5rZ9Fg/p+q8UZzJMs2FTXy9x2mhlqJBnhGGt+87oFOmk2K5Xq6/ftiu4InA0sJwwj7R6n+X+arTwQRMzy6+9dRZLa641IYfYbq7y7vf+p6KJUXt9TPJLJHl73FxPF/klUlW6rqGRNiPrHc55D5KqV/p6j4IX1Lhu71We7qf9eCx4qKKR4HL9V6tc5ordRulaMEDDfPp8N/craorRG3hbHgAYAzyVbU3Bjo5A5hxwkfmnak7FVNW7DH+4hbrqODlOB0714zBmSdjT1I+qcZXwuI9Yt94XL+2WohjraKXvWjigcN3Dof8ANbsc1xz6RbOCmtEoz6wmYfD7GPzKw6ShYZgASF6fxVCG2mV46cv/AHAfdZFsfHS0dMBvUVDSf4W+sfwatBUf1ZPuXJ7ex7tQUkcb3NFNTukODjd2Gj8OJaCquFVHC7hqZRjH2z4rohbXdHL5+dKO5aqQZLR5pLhzWMbfq9rmgVB682g/mE7/ALSVzc5ew+9oSm3TDYhQtmauv9ktJ6RrCOThB7iF8mT0yA3I/wAX4rt64R2A3SqrKy71EjYuGOOOMENOSXEnnn938Qu0C5nrGD7iuTuFJMJyMbYXvPCNO4WpsjR7Rcfnj7Ll3ag7/wCfXD/+zYT/APZZgsw04AA5lWXalfqWPtJZDKXRudaYX5I2/rpgq63virDxRvY8nlwnKtRxPZE3mC4C66XGcf7xVlRx5AVzRwnI2UajpC3GyuqSDGCQkKzs4Vhb4gC3b3qx0o01FXVXJ2f6VhkWekTM8HzJe73PHgq0sdNG2mYS1054S5pwWt+07y22HmQtNbImxyNaxoa1rcNaBgAeQVeb/DdladqLhXw8v9Q/unr3a471Zq2hlaHMqIXRkHzG34rzJNKKR7muwZWnHCOQ969VAYXlW/RMp75cYmDDGVMjQPIOIUdtd7TfJa/G8Lf5EvX1h9CPuoEsrpX5ccn8lIpXmMcLWl0jyAAOZ8APeo5xjJVlbAKaB9c7HFkxwA/ex6zvgDj3nyW6NV5UdEqr+oJhJD5R/WvB2Lvujyby9+SmA4AZPIJBOT5qZRSRUDH19QWNjhwIhIcB0nT3hvtH+6PtJw10CjAU+tk/ZlC23t2nkLZao+B5tj/ug5PmfJZ2vu0NDkOPeS9Iwfz8FVXTUz55HtpnEkkl07hkknmQFVxsc88Ry5x5knmtenoS71pdB3KB8uuGqTU1U1wk4pneqPZaOTU5FG1qTFTvOMBTIqI9dlttAYOVowFBqdSgx+OQTzMnzTkdM1vmnQwNUidhIY0+Cks2SGjKcaAEITzHDCfjeRyKjtGcJ9jdxhCepsM+NipTHAjY7KA1mBlOxkt5IRhfRlGBlG0I0uFUQREcQwUaCMIVTd4Y2U8j37NaCSSvGHaNcG3vWNW6nYB6/dgN6kdV6j7ZdVN03pKqeHATStLGA/a8QvN3ZPp92otUd7I0vji9d3ENjuvaeB4m2yjqb5Ps0YHj3/PAXrXBsTbdSVN5m2aMDx/ZwFF0NrGv7Pr80SBzYuINkjdyAzuvYOj9U0Wp7XDWUcgex4zjPJcR7TOypt3onVlHHwVMYLnAD2tlzjs57Qbh2c3zuJS/0cuDJInH2d1er6Kk42ov4hQANqWD1m9/76FXa2kpeMaP06iHLUN9pvf++hXs+qhDwdtiuAdvnZ/6dSi5Usf1sPE6TA5jC7dprUlHqa2RVdJKJI5BnzCK/WxlfRTRSNDmvaWkHzC8ktdfUWKvbOBhzDgj5EFeYW6tns1c2dow5p1H1C84difaQ+3W2rs88m0cD5IuI+G+FnOy6mZeO1ESM3BldMx3gc5/VVnaTpap0RqacQcUcDwOB7fAjcLU/RwojUanmmeMhrctd59V9A1sdJBbK29UZ0nYD7zv9fqvcayOlht1Zd6U6TMHxO/1+q9d2tvDAPcuUfSStH7Q0VVSBuXRDvB8CusUJDYQCcbKq15ou4ap0rVxwUkj2PjcA5ww07Hl4/DK+drNWCiuME5PsuB+a8KtMxpK6GfPsuB+a8D0l2qqe31FBE49xUkFzB1I5L1t9HrRrrXpuncIjJU1Hr+o3fHQLi+gvo9asumpaUV9nqKSgZLl80mBkA9F9BdCabprFbYIIIGQNY0Ahg5+89V63+It9pnwsoaJ4dzHmdykHbQZx1XqXHN3ppI2UdK4O5jzOwc7aDOFyvtQ7O6y6aHuAmY2Fvcuw127jt4D3dV5S+i3cWWjtkoKapY1zKhr6csdy4un5FfR6/2uO6UMlPK3ijeMELkmmvo+6R0xfG3Kis0YrmyGVlRIS57XHmQfiuFsXEdNb7TWW6paXdqNMY0OCNcnyXIWe+09DbaqhnaT2g0xjQ4I118lzT6XWo9W22jtdHp+oq4qGpLo5YKOMkO2zvgFc8+j32EXOfUdPfLzG6KON3EIpWEFxXtiaxipY0vja5w5Ejce5O2+wNgfxYUMHF81HaP4XSxBhIIc8bnPu92cqGLiaaltn8Opow0nILupz7vcqS1U4uXaFRwYzBZqB0x8BLMSxnxDIpf/AK4tld6BtbTyRO9lwwcLO9nDRVz6kux51dzfEx3/AGcLWw/mx5+K2LuHge4kANGST0XAsJA5+9clN6rwzuwPfufmvmd266XtNp7V73TWyEsigkaHEuyTIWhzj83Y+Cx4DIgXSHEcbS9xPQBabW1z/b+q7zdMktrK2aduTya+QuA+RCydfI0ujhJ9UuMkn8DcbfEke8AqnWXGqryH1Mrn40GSTgeGdl6N2k0rWiZ5cQANTnZZ6/eo6Pj/AK6XM0gz7Odg34AAKocQN8p28VpqKyR+ee48goT5AVnBxKhcwBTqM4Y3fkStnpOpMFXC7OMOH5rCU0+BjzWks1XwPac8iCpMqq8DC+kGjK9t9k0Cz2hT2matfno8COFh+UkoXSXOXGuwOq9PpoZyctprJQwN8nOdM934Fi66JMkq9nC5iYetju/XKfc7Zc47fZpJOzp1uhPDLc62mo2OHMOMgd/4F0Jz9lzvthHfu0VD97UED/8ABFM//wAKY7VpHenU/qytd3HPwVrdHMp6SOGIcMbcNa0dABsFltcScGiLufvUzm/MY/VXl4n4nsHTGVltfz40PXj7wY35vakkOpUkGrh5rB9nx7qksg6TW3I94cD+pVhq+k44njHtNKrdKvFPatBzE7S0roz55YMfitJqqHMbT5KkNQQtl/tA+f1Xnu4Q8dDq63HYVljqeEfedGWTNHyjf+K4H2ga6Gpeyqk0nXh8l0ttwbWWaQN4i6GYFtRT+8v7uQdSeMfdB9D6nj/Z2o6SYngjMjoJXHYCOVronn4MkcfgvIerHl8FvmaXRyAEhzThzT6pHuKvUumVXqgHAZXPXNBw4HI55RzNy34roPaRaLXX2az6vtE0THXR0sF1tcbQw0FdHwlxa3pFM1wlZjYZkZ9hYF4ywK4snCvLYwVGhrnAdzFXU8oH8TJGn8grLUsItmitJWZpIbcaqe6zjphuIYflwT/4lRWipLKK4U/SVrHY8w8foSt7XSXTTtNpfVDKL9oaddQfsure6Fs0cEoke7gcCDwnDmvGcZy4DqoXEg5/eynYA7f96rtf0Ore62TdpGpiCP2fp19FE/wmqZA1hHgQI3Ju8fU01SerYiPiQVrvo/2yG1fRmv8AcYHcTr3qWOmEmMF0MMPGAPIPe9ZHUDv6BWu/hH/EAqMpy4K9HjLiO9YmKPi1o1mOVOf+QLhOv4OGrmJHOU/qu+wba/I6dxj/AIAuNdoNnqaurkhpYXTSmoIDW8+qSmjfJUhkYJLsYA3Uzo3SRhrRkk/oi0tdDNpqxVZd9bb6qS3zeJjf9ZH8Mlw+C63brj6Rb2Rl3rwnY+S5Lo3RF4pIrrT1cTYaWtgbwlzt2TMPEw48Mly6DbaCWjjZ3koLgMHHL3fBeiUnBd+q/YpXAd7sN388LXp+HbpUgEQEeen1wrXUmXwU9ZGcGN2CR0z/AJ4VVdZRVMirAMOPqSAePQ/68lYP+up3wuPFG/mFSUsnC+WmlHqnLHDz8f8AXkob5wtX8PMifW8v8zOMHOMY308VFdLLVWhrHVOPXzsc7Ll+q9O1lNf3z0VNJJFIe+aWN9l2d/x3+Ka19/TbZbq9jeFrzwuA6Ejl+GPguzUIzTuidg8JLT7lyGtg9JtmobM7+uo5HVMQ64ByQPkf8S1L3w2y1W2juMUheJRrpjBwDj6/BT3SysoaGCqjfzCXfTbTP6rCnkl/ZCaY7I804DsuKXDpLjldT7MdJQGl/aVXG1/VnEOniuXN3lHXfku+0UIodFgwbYg4249y9T4At8NTWy1c7eYQt5gPHovQODqOKeqkqZRkRNzjxWZ1N2luoKw09E31IzhxGNx5JrTWv6p9xno6p3ejAmieTkvYf5H81zKsn7yeR/3nEo6eukpo4quIF09vf3gaOb4Ts5v+uQwsWs4wvEtWahk5bg6AbAd2FmTcTXOWpM7ZSBnQDbHdhegbtDDd7U97HsbKGhzHEZAcNxt13XONL3KgfqBkMf8A0fXQzYloJf6viH2oXeH7p8TjA3VxSXE1VJFJDKXQSND2kdQRssjquzGC4QXiFvrNcBOOv7rx59PkpbnxPBdrjTVrYuzlZjmPfgq/cr42tqYKxkfK9uObx13W77ZKD0rSzZwMuglB+B2K5LoyzOvN/p4QPVDgSei7peqUai0VLG1wDpqcFrnHbOPFZHsm06+2sq6yqiMcrPULHjBGN16XxBZhdOJ6V4HqSMDifBu/ywurvVpFw4gp5APUe0E+Tf7YVxrm+tskFHRwngJcMgdMbqy1jTNvWh6oEcZdAJBjxXJNd343PUcjg4GON3C0jwXXtJzC76OhafWLonRH34/zWtarqL7cbjQZ9Qt5W+Qy37rRttxF3rq6kz6hbyt8hp91x6w3l088Mrj/ANKUe7ZR/bM8/Mf65rq9l1bQaipWU1RtMW4LXDC4NWiW2XSTuzwSwyuDT5g9fJdI7OaSO+XKOtazDGesWno7qF5Rwfc6+huAt0ADmSOw5p28T8FxPDVyq4qoUceDzHDmnYjqfNb8aas9uJndCSeeXPKiXXWtpsDYg/ga+Q8LG9Tjn/rzTWsr1FTObAS4hoLiGNLthzGy8933Uj75fnVWCyFuGxMP2WDl8TuT712l94rFmuT6K1wMaG4y7lGc9V0d+4jbZpzT0MbQR1wPevReuIGXzQtc5g4g6HvWe8brzXDGIYXSyHA9tx8F6V0bKLzoinY7fjhMR+X+a83X+ney5zW9jC4QSEOb0LidgqP4hR+lCiuDB/iMx79D91jcbs9IFJXNHttx9D91u+xCwuvN5nuszPqKfAYD0J3BBXfoqV0z+IZJOwHgst2badbp/StFTAfWyt7x56kldTsFn74ty1Wrm93DdhpqGE8ssh53Eb9/6BFzkfw9ZKeiiOJZDzOI37/0Czndy0EocRg+K6Fpaqp7lACMCRvNqmVOjmXCjLS3B6FV9j0DV2yrEzqwsx0YOirVt1tnENu569/Z1TNAcE83wH/hUay62y/27nrndnUs0BwTzfAf+Fx76Y9kfNoixXZkZMNLcnUznDoZIy4Z/wDrK5tomztmttPI0Za5odkee69zWfRdn1lbq6yagoY7laa7Ec9PJkZGeYIwWuBwQ4EEEAg7Ly/rvRds7Eu1m89n9svD77R23u5IqmVgbIxsjBI2J5Hque0PALm4B8GnLR4lWsOOYLh7fI0vLDujttgJY0nDR5q0i+pAY1xeB1KebXRS0MbY8h7va8k5SUjp5I42Die8gAKO13mus0/a0UhafkfMLrqWrqKF3a0z+UpnidjIZkqlvNfd6WWOWgl9EnicHslDc4cDtz2Px2OV0W8afFtjgLercO96oK6iEsZbgEnZdXcOOr7VxmB83KDvygDPwWpLxBcayMsdJhp7hhcH1JNqDVt7rG3ivJn3cQDw94Ph0VbR0Qo6cx8Ibw7YXbazsSrdY8EtOJo5G5IMIy4DxwqO4/Rm1nI0ihuVLM07ZnYWPHwAK87fI57svKxWRtYNAs59H/Sz9S9qDaxzM0doYZ3uxt3jstYPfzP91erau3cOXFuCd1B7D+x1nZzphlLOe+q5H9/Vz8JHeyEbAZ+y0bfM9VsLzCMu2Ubzz69OiByg469Vx/X1L/0W/bovP3cuqbxKxgyIw534r0Z2jERWyQnkN/euP9k2nX6o1K3DS5k0wDjjYRtOXH8FeoGlzsBUK8gAEr0/a6Yts1A14w4QMz/hCz2t7Oaux1LmDMsQEjP4mnI/Jbl7GgYAwAMBUuo7jbbXbpJLnW01DTuaWmSolaxvLlknmu0kYOQtK5JjjzghcR1tpKPWenGOiaBXws72meepI3YfJ354PRdL+hfq5910HedNVD3OkslUJYGv5shn4ncHwkZK4/8AeLPaEtV81vQQN01Ya26wjLTXyM9Go2gEjPfPwHf3A4+S6v2OdiD+yWt1Fcq24RVl0vcjHywUrSIKcNLzwtcd35LzuQOQ2C5qcML2uadcarpInFtO6KTvy3v8fdhdEfyUSRucqXIPBMvaoComqumi3UfgwVYyMyEyYt1Uc1aEZSIWq2ohuFAij3Cs6Nu4UYUp1CvqDkFgu0TT81Jc33FjC6lqMZcPsOxjB9+Mrf0Dc4CvIYOOIhwDmkYII2ISSxiZnKVp2i5PtFV6QwZBGCO8fsLzqGlxAAJJ2AHVdw7L9A1lssD66oYIqqrcCIHjD2sGcZ8M5Jx7la09joKSXvYaCmhlznjjha12feArKKsmp/Ylc0eGdlXp6bsXc5OSuhvnEpulP6LEzlacZyck41x8dUzPTyQOIe0tI8Uw4qyfd5HtxK1jx5hTqWjo6mikqZA1kbefitLn71572WNVmnHBTRPwTk2ON3B7Ods+CZccBGVKGYRFwREn4I0knKRO5UHc0SPhRgbITCElHwocKHCjKZyhEhjKVyCHMJcphasl2k00k1hY5gJbFM17wByGCM/j+K5eu9z00dTC+KVjXxvBa5p5EFYut7LqaaYupq19PGT7D4+PHuOQsuqp3yv52ar0/hjiGkt9MaSrPLgkg4JGvQ4yc+5YO00D7ncqalY3iMrwCPLqfgMldu4cKo0/pGi0/wCvHxTVJGDM/n8B0V1wK3SQGBp5tyud4nvUV4qGCDPIwHGepO58tAkBqAGUvhQ2V7K4xJwE1WsMlHO0czG4b+5SAMIEAggjIPRIRkYT2O5XB3cuBLWdmtR3WoXR52lhc3l1BB/QrKvYY3uaeYONla6SqfRNS26QnAMoYSf3vV/VcnA7klafFfTV3h9Jt08Y6tOPPGR812oN3TgaiaE60LqiV8ygIBiWGIDKWBlNyngLmPazapxW0twawup+6ELnjk0hxIz78/gsbYrbPdrtS01Owue94yQNmjO7j5BegnQsmYWSMbIw82uGQU3R22kt+fRaWCmzz7mMMz8gs2Sj55OfOi9EoOLHUVvFJ2WXNBAOdPePD5qWxuDyTzU21OsBPLcrQyvPMJwYCWm+LHM4TkFZHA/PciX+M7fJJlODCdlKpaWaqOIo3P8APp81bwWHgbxVMwYBzDf5lVUmpanh4WFkQHIMaq6puE9UfrJXO8iU3KXsXnwQ7RjbpdHXimp4zUTGnc4OydiBn9F5eXpZz2uBB3B2IXO792UU9TO6a2VPovESTBKMsH8JG4Hlus6qhdIQ5q9K4VutPbWPp6k4DjkHptg5XLVaWDTlbqOq7mkjy0e3M7ZjB5n9Oa6BZ+yqipHNkuFQ6scN+6YOBnx6n8FsoYYaKFsNPEyCJuwZG0ABV46Qk5fouhuPFkMbSyhHM7vOgHu3PyVRpjSdFpiAFjRNWEYfUOG58h4BXT5E0+TCYkl2Wo0Bgw0LzKZ8tXIZp3czj1KXLLsocsqEkirbrcY7bRzVErgGsGQM44j0A96QuAGSpYYHSODGDJKodcX/ANDpfRIX4nmHrFpwWN/z5Lnak3CukuVbLUynL5HZxnkOg+CjLCmkMrs9F7hare23UwiHtHUnx/tsnqSmdV1McLPaecZ8PErZOjZBA2Jgwxg4QFVaWouFslU4c/Ub+pVnUO5rSpI+VvMeq4Hiet7epFO0+qz6nf4bfFVtSVUVbvVKtak81UVZwrr/AGHeS5Gk1qoh/vD6hRRzXHPpEEOfp1mx3ncR5fVrsbea479I54pqGz1TjlsQqPV8dmH/AMKx6L/aG/vovV+KwTZp8f7v/e1ci0yzv6261ONi9sLD5NBz/wAWVYVw+pk+H5pOm6F1vtpik3lDh3n8fC3i/wCLiTtaPqnjxI/NdaDqvnA7KnPPPgjO6D24JCSOWFMqy712B0Bp9LVlU4/9YqiGjya0DPzJ+S6as32dWo2bRNppnNDZDCJXjzeS458/Wx8FpFxFS/tJnO8V9VWSmNJbYITuGjPmdT8yvPnahDJce2iaCJuXMs8WR5d4d/xU+3WT0ZrTn1vEKNqyqB+kHJG4YDrcIB5kBr/yK1rImjkF0UIxCzyC8Oubue41J/33fI4TNHLUUvszPz5nP5q0bfZ4W5cGO94UGUBmXHYDmUzSQuulY2MZbHzJHQdSonQRO3aFn5IWwsNyfIw1MkAzJ6kfrcm9fmfyCsrTreiqNVVViha59XS0raioIORHxH1GnzI9bHgWnk5ZHWer6XQGl5rnIxkkwxDR0pOO9lI9VvuGCSegaeuAuffRtrJq3VOoaismfUV9TCJpZnfbcX+sfxG3QbKpU0MPYPfy/Va1imDrvTwnqT9CvSn7TZ9xy8kat1VFTarvULqd5dHWzMJDhgkSOC9TLx32mYp9e39vDwk1srsYxzcTn45yqdqo4S9wI6LrPxAYI6WB7f6iPl/ZSI9VCtqoqWmpHumlcGgOeAB5nyHM+5OXjWc00ogo2MjpYB3cRxkkDm4+ZOT8VQ2uP0K21Fc7aaYmnhPgMAyO+RDf7xUUbrqWUcDfyrwx8rz1VpDcrjc6hkLah/HIcANPAPjjop1Y30h0UUbi+ngHBG5wxxfeeR4k/IYHRN2mm9GpTM4YlmBazyZ1Px5e7PQqWG4VgNaz2RhMwSNUzFRBuMqdDA0Y2TQKkMdgJcpwClMa0N2wlhwCjCTCLvCUqVSjIAgHZKjB2U+xu2ShOwn2u8E40qOZMbBPQDvHABKEqlwt2yeSfibk5TbgGgNUqBuBlOQnAEsNGMogcJQ3QnL6MDkggglBVJBE84aSlAZVffaiWnttQ+GJ00rWHhjbzcfAJ7BzuDR1StHM4NHVeZvpHasdc79Ha4X8UcHtAHk5bHsG0r6BYm1MjPrZzxbjceSwE3ZLqfUWp5K64wNhhkl4nF7wHcOdtl6Q0taG22hghaABG0N2C9b4kuNJRWWns1DKH9Xlpzr7u8r1C/11LS2iC0UUgd1eQc/vVWMtubJCQQOS4V2w9k4rWSXG3x8NQ3L5Gge1svRbWDhwq+voGTtILQc9CvOLTdqmz1TaqmOCNx0I7iuCtlyqLVUtqac4I3HQjuK8rdj2q9QaVvLaRtFVVNG9wY5gjJDN9yF6yp5vS6Vry0sLhnhdzCqbZp18lS2Gjpy97uUcTCSVvKTRBtdKKm+VjLZTgeySC8/oPxV7iC9R36qE8dOGOO+Dnm+QWnebo291InbAGOO+DnK85fSJs9K7Ssk7gBUMcCw+IHNM/RF0NVX1lZVNeyGnc7aVwycjYgD/AMkz9KXtDsFybT6e08wyuY/MlSSHFx5Yz/Jdw+idpKTTugqZ0kZjkqT3rmEeyeq7Wp7e18GCGpyHSv0B3x+xldfOJbbwoIZ8h0j9Ae79hdt07oq2WljJO69JnH9rP62D5DkPz81dV1N37CMJ6AYYE4vE8ryoku3Wbbp5nfcWMq7pKUQMAAUjhHgjRkpElzA4Jv0Vuc4CeQSZQm+BuMYTVfUtt9uqahw2ijc8/AZUjwVbqiMy6aukbd3OppWj/AUE4BwnMAc4A96oex2Ixdmtkc45fNG6ocfEyPc8n/iU3tKvR052dakuTXcMlPQTyMOeTuA8P44UDsdqW1XZdpl7TnFFG048QMH8Qs99Ju4eidjN6iBw6qdBT+/imYCPllKTiHI7vsrfL2laWnq77rwLVMDPVHJuB+CzFZOHUNXOOb3cDf4Rv+blrLqzginkHJryPlgLH1sJjtbY/ujPzAWE89F6AzXJWNr5MSye4JkSFzQl3EESyfBMN9hqVihkUiOThVzb6kjqqAHAwrKhectVgKk8r6GfRQuIuGi66fq2Sngz/DSw/qSu5MkyV5Y+gxfxWaT1bbnOBlo7lHLw+DJIGNb+MT/kvT8cmysArAnbh5UwvysH2sANGkJ+kN9gB8uOKWIf8Ujfmtr3myyHa7C+Ts7u1XHGZZrYI7rG1vtE00jZ8DzPd4+KOihZo4fD4qHcpMzY8BhZLtEmI0bUtHNz2D/iB/RaKrqGTOD43iRjhlrwchw8Vh+1G4CHTlLCD60tR+ADv1wmSH1XFWIBmRo8Qsrban0fsz0NXnYUs5jcfDhe5p/5V0HULOOnafHIXMqSpgr+wSZjJWd/RXKZvdl44+F7+PYe6YLfVt6hdp+hrZnHupoGSEgbhxaD+qrNY7tOUDVwBWs5pc0afmIXIO0i2tlLC4erJ6h/ReLbvHJJR9xMMVVNJJBK3we04P4hepte9sdnuEctNRwzyysf6r3N4QCD5rgd9t9LcNQXC5nNPHWyd6YOgdgBxz5kEnzcV6Vb+BL/AD4cYORve4hv1Ofkt8cM3OqaD2fKP94gf3Vf2Uazs2mP9prZqO0/taxagtM1BK2NrO+pqgAupqmIuwA9kmBucYe44dgNPMq231drqp6OupZqKtge6OamqGFkkTwcOY5p5EEEELpP+zttfxBpADttyrzW1ll7SrZQVABqNVW2lZSOlwO8udNE3hiDsbvnY0cGfaexrRkubh2vWcB3elgM4DXgb8pyq1XwncKaIztAcBvynK5LbrJXVL4309M97HDBONl0m03itpdK11i750dvro4mVlLsWzNaQ5vPkQeRGD57rP6Ivgc1tK92Q45aVdXeB0L2TRbDGCo6rhWnm4ebeLfI57m+20402zjHd9FYNjgfaW3GkeXEe0DjT/wvXNst1Npz6NnZxQ0kLYI6uevr3Rt5f10gB+TlwHU10mMz4GPxE72m+YK7/q24No+zDsvoXHBi0s2sP/xXtwfnlebbxJ31c5w6pn4d0FPXXp5qmB7WMJw4ZGfIqzwdTRT1TnStBABOoyN1Ht0rnaxie85d3bQT7wFmNQs9F1FE/OA6pc0/HZXs7zTaoY4bfUxuHwI/kqXXoImq5GneKoEgPlx5XFx1jYeIm1bBgCQHA2xzbD3LLjqAyt7dowA/Puymdb3qpsVsZUU4DncW4JVbTahkq5myNf8A0edjZo/c4cvgcqw15CK3Sc8gGeECQe5c/wBJVpltT4icyUcmQf8As3n9HfovYfxHuFfR3JkcMzmxuaCADgdR9l0vGNXVwVwjjlIY5oIAOPBdbtsxlg3OSq+6M4KkSDYO9V3kRyP+vAI9P1PfRjzal3cASlp5SN2PgehTry43Xgqmq3HLonYJ+I/RFxJruGYJycmN2D8x+ik2ybvWknnjdUNToaN+p5Lu2UMDx67DyORgqws02KgNdsXDI81B19Ry1tt7uGUwvcCGOBx63T+XxW7a6uim4OZPXw9q2B22cddP+5adFUUz+HGzVUXaCI7bddPqoP8AsPpy2OInljbk54cgFCp7O7HdqUmiww4yHNOSVzGsuE1da6aolc5tTTvNJOHc8t3bn4Z+Svez3UFRTXZsPeOfHIRkE5WJbeJLNcKllFNb2NjfpncjPisSjvlsqqhtJLRNax+meoWdv2n59NXQwzDLA71X9Cu0aXkF00lEwHPqGP8A181Qdr1DHJaI5wB3jHg/DkoHZTqVsbHW+Z2C5+WZPktezwU/DPE8ttLv5crdPfsPstC2xQ2G/wAlCT6kg09+w+y5rdqZ1JX1ELhgskcPxUannFNOyVw4oxkSNxniYdnD9fgumdpGhp5ah1fRRmRryXPa0brn0VguD5OAU7w7OMELye82Ksttc+mdGSM6EDQjovOrnaaq31b4SwkZ003HRazs4ZUGWssmDIKZ3eU8hOQ6Jxz+BP4+S1t0tToGmKdrSHghzTyweic7PtMv0/bhWV/C2dkZaHjpHzA+G6dulfHc5BPC4SROb6rhyIwtO58N09oskddVEipkOjc7Dyxn5roqm0RW+1RzVGRM86N7h5K80xCHaeZTPPExoMW/Ph/0VBv00Wl9MOhdUGLI7uOV2XcPhnrjp5KVpqqjjpZA97WAHOScLm/a5qSKurI6KGUOij9stORnovY575DBwvFX5HbdnyN78nQ/TK72pusVNYWVeR2nJyjv10P0ysBdYZ6WrIqAA6T12uaQ5kjfvNcNiPMLtPY/XekWGWEneN+QPeuHNuM9Ew00jW1FK48Rhk3bn7zD9k+Y54wcjZaHSmvpNLGaOkbhsowHTDPD5Ejnjxxv4BeNcI3mOzXQVVUTyEEHGp1/uvLOHLnHargKiYnlIIONf3qk9pFCaDVtfG0Ya5/GPcV1DsxtkentMOq6hwidN67uI46bH5LkGpr5V365GtreB0jgG8UQwwgcsFQKq61ckAY+pldHjABecfJWbfxBR2q71FxhiLw4u5MnGOY7nforFFeae23KauijL+YnlzpjJ67rTaq1VcLjdqg09X6OHOLWtgHru9xO+fcsbfrDWWiKKquDX075zmOKc/Wvb1dw8wPfjyXR5/pDXI2aGmZaIH3SOPu3XGZ/EH9OLu8D1uvtYzk4wcLldzrLjqKvfV1s8lXVSH15pT+HgB5BcRLUTVdQ+olwC4knrusSulhnJk5y97jnbAGfqt/pHtbq9OWI0kVIyeVzsxl7jjPX4BYm/XeWd7ri0tiqJ6gyks2w7fl8kxHF6PGWM3cRgvPVNy0xqad0BOXH1mDzWnVXitq4Y6eeQlkfsjuTJ62tqYWU8shLWD1R3L1D2VV8t0pLbJPK6Z74GOLnHOctG69B6bt4y3A5ryp2H3sS2i2EnDommB48C04H4YPxXrTR9XHPTxuB3SCaSf1pXFx8TlY875JCHyOJPicreW61h0bRhSZ7MwMzwpVqnGwV4QHx+SZhZhyCqSxxtt1S5zhtgleCNZsu2n+1i51+p4zFU32eWvjkc4OGHSyN4cjIGCw4b0HDyyvoDUUxBJauOdu3Y03tX0R+zKcx0uordPLWWmtlOGuLyXPgeejXnbPQtYeQINaeLtWYVymm7F3MuKWvhka3cYPJbnSboKarM8uzY27Z6FeddO6zrtJ189nv9NPRz0khgmimaRJTvbsWuHPA8fDx2XW7PfmVVM18UglieMiSM5B+S5ssMT8kLrWSMqGeqV1K511JfTBS00ofI88XEAcNA55TFt0hM2tc+pLZmg+pjlj3eKp7DVYMLxsQugW+pzwlQud2h5ipeUxjlatNomnfaLhBUxnhc0jYeC6XfIKFsArW00XG/q1oG5XPrNVxRNEjjsFPqtSmqjbEfVjbyCNAMFVi1znZCXVygtcQsheJwOInkpWptZWjTFudWXi5Utrpdx3tVM2ME+Aydz5DdcrOo9Zdr8Dm9l+kq270LiQdR3Nho7Y0ZwXNfJwmXB5tbuPApOR8mjQpmyRxHLz+vwWP7a9VQUFpkibIDNJ6rW55n/Ibqn7Dtc0lrabRpqxXPXGralp/oNlp3SNhjB5vkxgNJwS4BwHUhda059BmiuN1Zde1jWk+p6kYc6z2EGnpAfumdwDnMP7rI3fvL0rpZtk7OrE2y6MsNBpe1jBMFBEA6QjYOkefWkd+84k+a1KX/VtWnJWdUzelHBbhvmuP2bsI7UtXMbUawv1t7NrY7f8AZ1pxW3Fw6tfKfq2HwczPmFvdN9h/ZjoeZlXHZTqa8N3N11FKa6ocRyd644Wnza1qvam4TVTy573OJ8SoziTuVI+V0hy45VZreXRunl+8q4uGoZKocLcMjAwGsGAAqOV5eSeqDkkjChyngJlzU05qkOakPAA32TSpWqM5ibLMlQrvqa32hpNRURtP3eMZWZk7XLLHJwmUu6DuxlatNY7nXN56anc4d4BW7S26rqW80MRI8AttGzdWFK3cLN2LVdvvn/Vp2Of1ZncLUUmHYIKxKmmmpJDFOwtcOhGE18L4nckjSD4rR2KjkramKGJhfLI4Na0cyTyW5l0lXULOGaBzCPJK7FLMKy+SVT25ZSx8Qz0e7YfhxLt0kDZGlr2hzfAprGZblYdVVdjJyALgEtvfGcFpHwUOWlcMnC7tX6Uo60EhgYVl7loLgyWDbySlpCRlYxy5RJGQPNMvc4Rlgc4MJzwg7LbV+kpYifV/BZS70RoJu7cRxeHgmK8x4dsq1xwE2dwfBKe7CQTlClRHkhjbCA5I09NKCCCAGUJhQAylII8FIUwpPChwhKwUYamoSUe3mlIwMpcppCTw5CItS8HoUMlLlN5cpHAi4fencBDhTuZJyJnhR8Ce4EOBHMjkXB73b5bXdamnmaQ5rzgkY4hnYjyKlaTtc90vtIyBnEI5GyyO6NaCCSuyV9norowNq6aOcDlxt3Hx+JTlDbaW2xllLTxU7XHJEbA3J88LIFFh+c6L1V/GXPRGIRfzCMZzptjPf7vmpAaAlpI5pQK1crzIMSmc043mmw5ONPVJlO5UsHCcaMo2QOI4nYjb4uOEp1XTU/LMz/kEmUoYTsnI4Xv9lpKm09PJE0lxDR1VTJep3bMDYx5DJTT7jPM3hfIceWyZlTCByl1M0feEsBwmDOPNRTJ5pJlHijKtCIBSjMm3SeajmbzSTNkc0mU8RqQZEh0yjmTzTTpMdUikEakOmTT5duaYdKmy/KTKlEacdJ5pl8iS+TKYkkTVMGI5JMFY/tAleKCnYCQx0nrAdcDZaiR6rbtRRXSkdBLs124cObT0KjkaXsLQtW3SspaqOZ40B/fwXLk5BC+pmZEwZe8hoVrUaTr4ZC1jGStzs5rgPzVrZtP/ALPk7+dzXzDIa1vJvn71ksge52CF6fVXmkhhMkcgc7GgGuvj3e9WENOyjpWQM9lgxnx81FqCpkrlAqDstxowMBeMzOc9xe45JVdUHGVU1h3wrSq9kqmr3YGR0T3t5mlveoqecQVEczhkNcD8DlIauTfSAojc4dMUTWhwmrj3nlG1vG7/AJQPirnXfbLa+zy9Wu119HV1FRcY3SROpg0tbwkZDuJwxz6Z5LC2nUFZ2m6pud6mj7m32+P0GjgBzwOdwvlJONyfqh8MdFm01NKyQSOGAF6Bf7/b6u3vpoH8z34GMHTUHXKytA8y000h3L55j/8AZHKLXO4YXO8CCfmpFoBFsAPMSzA//XXKPWt44JW+LSF0Q3Xh7tlXzt9YnxVjpDT8mptS0NvjblskgMh3w2MbuJ+APxwq/jE0Ecg+00O+a6p2A2mKWvutxeA6WFjIY89OLJcf+EfikqZexhc8LTsdCLjcYaZ2xOvkNT8gu0taGtAAAA2AHRGgoF+ujbJZa6vfjFPC6QAjOSBsPicBcUAScBfUb3tiYXu0AGfcF5r1TdmO7Y6K4scTGbhNTBxOchzTGD7tl1ATtiaXPOAuDXipMcVJcZHOc6lrIqp7j1PHv+a7NIHPcONwONtl2Bbyta3uXy6yc1Essp3cSficp+oqjVEYGIxyHir60xxW6jkmne2FjWGWaV5wGNAyST0AGSVR0UP1rSd8HYLAdr+uHVLzpygl/o8ZBr5Wn23cxED4DYu88Do4JGtLjhE0gibzFZXtE1vLr3URq28bLZTAxUMLtiGbcTyOjnkA+QDR0yd39Gn/AOiu6f8A4l/+cauPeytr2Sa1h0Pq1lZV8XoM8ToJy0ZLWkgh2OuC0fAlS1MZdA5jN8KOw1UdNdoKioOBzanuzovW68l9uFEaLtMu+ccMvdytwMbGNufxyvSsmv8ATUVAa119oPRw3j4mztJx/CDnPljK8rdoOqxrfWVbcmAtp5CI4GuaARG0YGfM8/isa1xvbK5xGmF6lx5V0stBFEx4Ly4EYIOmDk+WqhXAmOCggGzGUzHAebxxn8XY+CK20fptU1jsiMetIR0aOf8AL3kJyKF1woQxjS6opGk4HN0Wcn3lpJPuPg0qzt9P6HRgH+slw5/kOg/VdPnReDcp5tVJe/jfnAA5Bo5ADYAe4IuZRIxzSKUJScDyBhNZCMFNSp0OS2tLj4BNNOEvvMc05CksDW/5oPn4RgFRH1Hgm+9zzQhSxLvgK4t0eI+M9VRUjTNK1o5krQzPEETY27ZGPglCUpcZ72TPRTWnAwoVOQxu6d78BOSqWClB2FBNRk80ff8AicJMoX0mAylAYQAwjSrPQTM8XGCnkRcAhOwqp1saX5wpsELYmgdFPt1rq7zP3NFTPqH9eEbN955D4re2Lsrjj4ZbtP3rufo8JIb8Xcz8MKJzwE/l6lYKgt1Xdp+5o6d9RJ1DBy956fFbmy9lJdwyXWfHXuID+bv5fNb+joqa3QCGlhZBEOTI24CdJyoHPJRnGyhW6zUNnh7ujpWU7evCN3e88z8Vx/6SvZ9cO0LTLaW3SyRzNB2YSM7rthGVCrKITjBCtUFdLbqllVD7TTkK1SVclFO2oi9ppyF4k7OPomy0d2hq7457xG7iEbXjf3r2FpezR22kihjZwMY0NaAOimxWZjH54VaQQCJo2WjeL9XXyQSVj842HQeQV253esu8gkq3ZxsOgT7RgBGkILnVjJXEiyUSCEI+JAnKInCIlCErJSZWiWF7HDIcCCPFJL90fFhCcMgrm/YBKafQUloe7M9luFVb5f4myl4/B7VQ/ShDqrRVqpmnHfXeBp92H/5K/sH/AM1u16/2t2W0l+p2XOl6NE0eI52jxccxu9wKqe3yH0m12iM7htUZvcWtOPzUR/2cju0+C1GgGtEg66/EZPwOi8U19A6SwuqAMsfVPiHvw136rGXuHg74YwMDb5Lr1Pb2VfYtRVzRl79QTw58QIGH9CuXaniDCXDk4YWRLoR5BdpTO5mnzK5tdo+F5PiFCaMtVzd4uOFpaNweEqpjHq4VgRSR4L2kZ2yE2drmHUJON1Pod3tHmo8dO6Yjo3xU2ONkPD6245Lv7NwbcrvD6UMRxf1POAfJaNHY6quj7bRrO9xwF3T6G2thpjtunskz+Ck1PbzHGPGpp8yMyeg7sz+84XvZknCV8oaOqqLPebdc6SQ09wt1VHV08g+zIxwcM+IyMEdRsvd/Y19IWi7RIGUtWW01za0BzCR65JVu8cE3K0wemAtljG5Yc4VO6cOVdHF6S0h7BuW6rsd81FT6etk9dU8XcwsL3cA4jgDPJcn0R9KHTfaRqxmm6WhqBHUxyZlqAGscOrcc91uNZcNbp+sjcfUMZznwXz90fcH6U7U6SZpMYhrS0/wkkfqFe4T4fob3QVzpQTNG0lmDgbHp11wnWC0U10pal0gJkYMt18D917L0k+ai0jT0sxe6S2Olthe/m70eR0HEfN3dh3xXNO2S7l7KSmEhb6PSPmJH7zz+jF0PSNS6r0df5JHcUjbw+fOPsTRxyH/je4fBcL7abiYLhXgux/QWNHxe/wDmvL2uLHsd3ELmqXSfm7lyLR11ni1EyJ00j4phIzgc84JLTj8Q1erLHUG99kNBKMvc2KSEnqDG9waP8IavG1trfRLpTVX+6ma/5HK9e9iL/wBpdnF/oAeM22vMhP7jxj8C0/Ne0fiRAx7rddIhgSR408MO+5XpXFgBjp6tg0cB+/mvKN2gbSaqnjkHqekbjyJ/zSO1HSzmaVq6ikBZNb5BPkbl0J2cPgDxE/uK77VbcbbrCpwC0O9YJyp15Tz04iNB34fB3E7JT6sjcYx+nuJXX8S0N24gttuqrVk5b62HYGw1OSOuVq3ikrbtR00lHk5brg47t/mvPjayaN0bZe8inLGycD9iWkZDhnmD4hb20VkrLayoe57JY/XD2nDhjkQehTclpo4LTRW2sJmjoZHy0sku0sbHHJZkc253xjmXeJT81BT3ejMDK40rcYzGzj2+YVzhSxXOwMnqapwe8twI2u5snx6KOwWittAlmmcHOI0YDnJ8VaUVTpntvuJbJNR6O7TC7MNW4thtWoJBnIl2Apqt+ch/9XK8OBDXyApm52O5Waae1Xugntt0p/UnpahvC9h5Z8wcbOGQRuCQsTcuzmht9HUz/wC1dnf3bC80s7aiKZ+N9gYuEnbYcXNbbReuL3r6mtGlKupjvXcsk9BnqnYngY2MuMYkwS5mGHDXbjDWggDC4LhS9G1XOS3XBvLHKSHNPQn94XHcP1r7VXPpaoYjkyHNP5T+9F23WmqYLzpizPgcCLVpahtruHo8St5/Ari73d9MXdScqdTXV1JY7rROBDp+6O/Thdy/FQ7bH303B1LSustFkfwxV3aYj1Awlh8Dkj4Y+S7K3202WSsP5Q31T4HKi31pZfqR3SSmA/4j/kqS+MNZV3KB2/E4gD3tB/VX2pHgwWurH2C6Mn34wP8AhKzGoJxTamfHUNldR1kbD30G8lO8AtDwPtDA3Hh7l81sa+WdvIMuP6ryuMkuxjUp6qd6Vo/D9+KHhPyXH9PVv7NvUfeH6qXMEv8AC7+RwfguyXmJlu0xURl4diPZ/IE+K4M5/eyF3icr3j8SG+tRB/tiPX5LsONPVkpebfk1+S7JpSpMNUad53acf6/BXt/Zmna4cwVhtPXMzxUddn1m+pMPHpn9fit/d2d9bXuHMAOBU/C//qPClwoTqWesPhn/AOKs2T/XLDWUvVvrD6/ZUlumzMz7zHcTfPxH+vFW+oKd1TQHgGXNORhZqCfhe2RvTmPzWllvtHBCwyPzxYGwzuo+DKyiltFbbK+YRtfsSQNx0zvjRQ8NVNK+31VDVyBjXbEnG/d8lzG8aOrKi4VMlPD9TXRBsoJwBK3drvjgt+PmrbQnZ9Pa6ttdWvYOEbNWordVRUvCI6fJOcF3LK5xfu0e6VjpYHRspcEtc1u5B6/5JKRvCVilbUNndUSM1AAOM+eAFDH/AKO2mRtQJTM9uoABxn4AKz7VdQR1TmUcLs8HtELnFFWSUs7ZY3Fj2nIIR1VQ6ZznOPE47klRcHmvPrzeJrvXvrn+qSdMdANlw9zuUtzrHVj9CdvDGy6pYe1YRwshr4+LAx3g8FaSdptmjBfDS8Tz9pwAXF+8IKV3xwulp+PLzBEIi8OxsSAT8Vuw8X3WGMR8wdjqQCVu9Q9p1TcnhrImx0zSOJrCSXN6/wCvHCi6Luot90nsUz+KGQGoonk5DmHctH4n4OWJfKXHIUgiSqtLZ6dxZX2p4micOZjzv7+E/guLutyq7rN29Y8ud9O5YM1fVXGUy1L+Z/T9Pgur1gIBac8B2IWE1VZTMx08Lcyxj12ge23x94WusN6i1JZoqpuGyEcMrB9h45/zHvTNVT5yOThyKxmucDgqCRgcM9CuZ0DGVsZpJcDi3if913h7iquaN1PI6N4w5pwR4LTais7qGX0yAFsRdl4H9m7x9yqrk0XBnpUY9fGJGjxHVWgeoVfBcOU7j5hQKaQg8DjgHkfNSnM4hgqABkYU6nk71mHH128/PzSlI1WVh0lJqKKoFPUsZUwkZhkZs5p5HOfEHorm3dkt8rp3QyVlFSlo4gCXEvb1Ldt8dd+o8Qqaw3g2G809WSREDwTY6sPP5bH4LurI/TqVhjeGTxnjhlG/C7H5EbHxBKhc9zVq08ccjc41C5Tcey0WanElbcJJGg4c6JgY1vjknKz5sjIqpklPTyCmadpHbuf5+QXU73JVagqW03dO7mN2TA0ZJeOfF7jkfAnwRy6bko4RJVOjpmchxuGVWdKc4V4U7MDAWB0hef8AZTURikf3dBXOBbJ0il8T5H+XgvWvZ1qXEcbZDg8iF5qumm4Ktry6CWSJw3cKd+D8cJ/SWt7voORjJo57rZgcMeGnv4R4AnZ48ufywrlPVBpDXLOqaFxBcwZC962qvD2tIOQtZQ1QlYBleeuzvtStN/p2C33KGscBl0TXYlYP3ozhwHmQuqW3UbSGlrltBwcMhc3LC5pwVve74lGntjZgdwFBpNTRFmH+0iqr0JPZeGhJlVcELk3b59HKj7WaMXCgkgt2r6dgZDWvH1VUwcop8bkdA8ZLfMbLxfVzao7FNQuoLtS1Wmq1xJNPVs46eoA5uY4Za9vTiafLK+jDr2GH1A+Z3gwfqs9rvVtnZZTTavFqitM+/oNwjbUvqCM+zCWuL8Z6NJCqysY8ZcrULpA4CPdePdPdvsLXNNdSRj70lJKC0/3Sf1XUbD26aZqowZLzS0OBkiqkbGR5blV2o+yfs41xx/7P9ns9nkkO1ynqp4s/w0rX8IB358BH3Sr7Qn0dtF6YZG46bpbrVN9qe68VTxf/AA3Hux/hWLKyEH1T8F00DqzH8xoHnv8AJP0nbxb7vO+k0xbLzrOsZs6Ky0L5GMP77zgNH724V/aNJdrvaFJw1dwsfZbbZDggn9p3IDya36rHvLXA+5b+ipainoI6WmDaSljHCynpmCONo8A1oATNPJLQ1jActIOyhHK3YfFTua+T2nY8tP7rU9nn0XOzPTFdDdbpR1XaBqPA4rrqyb0zfnhkDvqmtB3blrnN29bZepKew0U9njhla1zJI+EMaMBgxsGgcsBeUKvtNpbE1vf1sYlH2Q7dOQ/Sr9HpxSiSR49kOa3BA95XU0vDt5uEfawUzi3vwrkNjrJ288ELiPJbu60xpLhUQB3EI3loPjhQ+7zzVFYtfWzVDi6Cpa+Z27g47q/cRw5Cyailno5DFUMLXDoRhZE8EtPJ2czS0joU3LKyJp43Na3xJwhxCQAg5B6hef8AtlqKyn1EzFTM2GRmzA8gbeS612eXT9q6Tt0pdxP7oNdnxGy6u58NOt1pp7qJeYS6YxjGnfnXYrcrbKaO3w14fzCTpjb94WjeMDK5tr3tSn0pXtpIaFsrnNyHyOwPwXTZGZblcM7caHhqKaoA6lpPvT+DKSiuF4jpq5nMxwOmSNcabYUvDdNTVVxZDVN5mnPx9y6ppa9/t+xUdcQGumYHOaOhVJ2j6t/2ZtRMZ/pEmzOqqexe4mp0x3JOTDIW+4cwrDXWiG6pmidLK9rGbho8UvolBbeJJKe4aQxvOm+g1A+ikFPS0V4fFVaRscfh0H0XI7Lp6u1rVvq6h5MZO784Wpk7K6T0fDHOa/HtZyVtLLZKPS9CI3PbHGN8ucoF17RbNQgsa9sjhts5dLWcTX67VhbYw4QtOGho0x49Fvy3i6XCoP8ADciMeyAOniuRuZWaMv0ZD3NMb8jB5jzXpTRN0F9tNDU5yZGAlecdbX+HUFWyWKPgDeuDuuzdgNZ6VpqRp9Z1M4sA9/JbPHlFNV2GmudXHyztIDvI5++PitviCCSa3Q1c7cSDR3zXszsXtnoelpKpzcOq5SQf3W+qPx4lvhzVbpq2/sfT9BRAYdDC1jvN2PWPxOVZN9orwhreVoC8Bnk7SVz+8pYCBYDsd0pvJG0cRTsZVfZZ/V9VS2OyVFdOwEsGGM+887ALz5WVMlVO+aV3FI85JW/7XtSftK8stkLs01F/WY5OlI3+Q29+VziZyqvOXYC6ahiLYg525TbjkpPMIicowMIV0lGggghRkoJQGEQCNCblGBlKSEtIUiCMDKAGUpNQiwEaGMo+FCESCPhQDUIRAZRkI0EJ2EMbIIwMozsEmU4BJRjBRIyMIypAEAcI843KTyRe9IpQEsPA5gkeScFW9gxG1sfmNz80xxJJduhShoS3yOecucXHxJSCcIiQkk4TFYa1KLkReUkuwEgvQpQEsvCSXJBckE5QpA1OGTCSX5TZcAkl+eSE8NSnOx1SHPOEhxKSXJikARuf8Ekv2SS5Nl23ghSAI3vTMj9kHO2TL3bITgET3ph7ilPdumHu5oTsIpDuo8hTjymZDhCQqPIVBnUyQqFP7KkCoyqun5lUtfuFc1PVU1bu5SLPcV5V+lZL3PaXpQZwGW0yfOR4/wDCt/2SWv8AZugLaSPrKsPq3nG57xxcPk0tHwXMPph1Hcdpdi/dsoI/+uzLuthohb9PWqlG3c0kUfyYB+ill0jaFn0nrVEh7vuuR00RgdcoMf1NfUtx/wDEcR+BUOq9kq3ucXo+qNQ0+MD0hsw/vxtP5gqmrNmOUzTlUpBgkKpoj/RA3rG5zPkT+mFuOy7WsWjr5J6Y5zbfVtDJnNbxFhB9V2BucZPLxWGpBiarZ++14+I/mE85qkkjbKwsdsUlFWS0FQyqgOHNOR+nkRoV6zor3b7jTMqKWtp54X8nskBH/n5LlPbD2lUdTb3WK1VDal0xBqZ4nZYGg+wCOZJAzjbAx12469qaxgZ8FmRW9kTw8nOF3Ny41qa+ldTMjDOYYJznTrjTTPv0RXKD0uyVkXPMbse/GR+K6tpysNxsNtqnHL5aaN7j+8WjP45XMYDxMeCMg81r+zi5xRaPaKmVsUdCXtle88hknP44+C0HDK4eldh5HePorjWmqv8AZWxukhcP2hUZjpgRnB6vI8Gg595aOq4eXcy5znuJLi5xyXE8ySeZPirfV2on6mvctXu2nYO7p4z9lg/UnJPvx0Co3OzspmN5QqlRL2r/AACWHZSgUy3mltPRShVkcrtgPinqBnHKT4BRnHicrW2wYh4jtxJCjCn2+WWiqYp4HmOaNwc1w3wfjsR5HY9VpbpDDPTxXKkjEdLOeCSEEn0eXGSzffhPNpPMZGSWuWdiaGBWdruXoL3tkj7+kmbwTwZxxt6EHo4HcHxG4IJBaDhBCQDslJyvo/Q3MdHJ39LLkwzgY4h1BHRw6jp5ggmPxKRNTgKHGB1TDpCTgckjO/ikwhSTMBy3SDKT1TWd0aVCcDiUYKQDslMBc4ADJJwAhOVzZYw0SVD9mtGAnzOZpS49eQUaSUQwsp2H1WDLyOpSGzhp2S+CQa6qyE2BhH3ufJV3pPmiNQU3KkVl3waiNSD1VaJy5wAy5x5AblTWUhjjElVKyji8X+0fcEZwga7L6fJPEiiD6moZTwRvqal+7IYm8T3eeB08zsOpW5092XTVHDPeJe5ZzFJA7Lj/ABP6e5v+JK54YqDQSMnZY6goKq7VIgo4H1MvVrBy8yeQHmVv7D2Wxx8M13m713P0aEkNHvdzPwx8VtaC3Utqpm09HAynhH2I2438T4nzUnmqrnlydkflTdLSwUEDYaaFkETeTI2hoCdJyiQTE0+KCCCCYkQQQQQhBBFxIkJcJWcIuJJzvhRq+50tsi72rqIqaP78zwwfMpwBccBODS44ClcXuQLlznUP0gdBaZ4hW6loWyD+zjk43H3YXNb39OTQlBI5lFHXXJw6tj7tvzK36Xh671usFK8jv5SB8TgLbp7HcqrWGncR5ED4lej8hEXYXmS0/Ti0xVVDW1lNLSsccAMHGfieS7ppHXdp1vbGVtrqmVMLvuHOD5plwsVytbQ6shLAep2+KbWWeut4DqmItHf0+K0Rf9YE5nIUWN3FK7yT4OywVkELn3bLFPb7TQakoITNc7HUCqia32pGEcMsQ/jYXN95B6LzfqT6WVJ2j6morRTWeSjpON8bZ5pATk9dvd+K9Ya2j9K0/WxeMTl8wdU0x0z2kVQiHAIqzjZjYYJzt+K9M4JslBfGVkFSzMgZlupGDtsN9cL0rhK3Ul0bNHUNzIwZbqdP2V2CyQVDPo39nV1JIpqm/VRnaD7TpGSxMJ/vRj5rlnaDI2lcaf7fEce5ejOzHT8ep/oRUtsMghqIoKuanlOBwzxVcj4znplzQCfAleUr9dpdTXczlnBxAep0b4hZXBFhbcLp6ZVjEMA5nZ2yNgtfhimbUzyPkHqxEk/ZUhj76OVo3dw5VV3Z4gFfmndS1eDzG3wUCspTDKCB6pdssq9Xc8S3ztXaRlwa0dzc4/uqlyqzcq3nd7JIA8Ai2gp/PCjwtdO7cqRVNzFgJ2igO22y7/8AEmqlpKiC2QnliYwEAbHp9lpcXTPimio2HDGtGg2Wpu9hbV6UoNRUrMxMLaG4NZv3Mw/q3nwbI3Az95p8VV6Wv1Rpq/0lXTyOjlgka/LTzGV0LsdraOG71NpusIqLJeITSVsLuRYeT/ItOCD0WU7R+z+u7OdVVtlq+KoZTjvKasxtPTuPqPPg7m0jfdpVT8PLs8V/8OkPNFMCCDtlZ/CVc+KsNvlOWSA6L2fatbN1XoKknY7MlUw955f+f81427TaT9k68rHNGMvbMMf68l2bsBvD5dJS00j8thkLhxHoQuVdsJdcb1Hd2N4aOpLm05PN7GnAf8Tkjy4fFbfBzG2ni2rtn5HcwH/cPktjh+Ntvvk9GPZOR9x8lu7R9I8We3XilgoBL+0KeBnruPqPjLjxbdTxY9zQuWa615WauqHS1DRE0sDCGjGwcT+q0/ZtZ7RNLZautpRUxPq2U8zHn1T3h7oE+Aa57XH+FRvpA6Xi0zDUQU8DYGwSFwLRjLMjH4FZtfcuFrHUyU0VvMj43EHmOmQfHP0VWars1sqXwRUpc8E5ydNPiuZwuYQQ0g4XqH6HWp47jq272WpP1dypu6LTjd4YPW/B4HwXj7S9XxzyRk5yF0bsr1pPoTtNttbC8jiLJA0+ySx3I/A428Stji2pZfuEILlFGGdk8aDYDVuPmFrXaRl4sLahjOXBxgdOg+y6H9I+wyWrUX1rcSxSvgecc8HY/HY/FZPRtupKy2GeWEzOifiRg6s8V3/6Ytnp7raLVqq34fQ3OBkneD74GRnzLdsfuFebdG6lZp+aQyDjjcd2qWjNbcuBxHbye1idjDTqRnb4O+ShoX1Fw4aaKcntGOxpvvr9Vba67Naa+W0UTJmUUrvrLdcnHDGvx/VSn7rgMZ9x3xhee7JR3jS2qqi0XGnmo6uB5jmp5gctPMeRGCCCMggggkEFejJu0iGOjko2QNlp8nga8ZHCfs/A/hjwWOv1b/tDU09TPFGBSjuop3jeKMnZhfzLQTtnlk8srF4d4Xv8FZHXVruyY05Jc7XHVZlBw/cm1UdXM7kDTkknouW9rUTWWcVAGJBjB8cLM9iOso7B2qaQuFVIWUlNdaZ9Qc4+q7xokHuLeIKy7W62pFTUWyqp5KWSmcOKKQYO+CHA8i0gggg4IIIyCuVlgpZO8BIwcrn+NbhTXK7yT0Zy0YGR1I6rmeJquGtub5Kf2dBnvI6r2h2sWmLT/axq6yR4HoNS15aOQbIxsgx5evhZy3VDYbpTtJxxHh+f+eFH1RrGLWPayL/HJ3jNQ6dpKqUc+GVsUcTxnylgePgVT3eudSXCnI5tIK9B/j0tfwNNLOPXAEee/bX6/Bd1HdZKnhp75faGGZ79tVb38f8ARFZGedJOHD3cWPyJUiltLrpT0c1IyO4VDYeB0NO5sszOEkYLB6w5dQm7pGKqqrIfsVlPkfEYz+q5Pd4u9qGVjRwTFrXcbdnNcAM4PiCF4RYLtJZa1ldEwOcM6O21C4Ghr3WycVDWhxHQ7K21hr2rtdY+ko80s8RLJWyxA+9rmPBB9xCxFdcbLenF81CLFXHcz0AL6V5/ehJJj98ZLRyEat7nrq5VYZHeo6bUcUbOBpukZfM1vRonaWygDo3vOHyWbrP2DWuLqd1baJSdoqktqov8bWsc0eA4HnzV67XeqvlSausPrbDGwHcP7qhcrhUXOYzzuye7oP35q70zNJQzOpZuEtlBfE9h4mSAc8EfiOY64W1t9wmq4HQySuc6Pz5tPL+XwXH46ue2Tg09QydgcHgwklriORwQHD4gHBI6ldDtF1jmNJXRHEE3qPH3T1B9xH4KgyeaBrmxvIB3AJGfPvVCOWRrSxjiAd8HdWUrvRqgOPsP2PkUchD4zE8cQI2z4KVX04eHsOwIVROZXUTizepgOcfexzHxCgymaJRcZo300jvrWjMbj9rHIrF6toS4Nr424DsRzj7rhsD+nyWoFVDcadksTyCN2u6tKjyvjlEglYC2QcE8XQ/vBK12ClLQ4YXOccQ3QU272x9prDETxRuHFFJ0e3x9/ioSmVQjGiQ7mhgI3c0SExIcnLfXi210c7m8cQy2VmM8bDs4fL8QEh3NMvCUgOGCjLmEObuFb2q4SaJ1HLECZaF5GcHPHEd2uHmAfzC6RM1lVEyaFwkje0OY5vJwK5dLH+1LEC0cVXbBy6upyf8AwOPycrjQ+pvQntt9U/8Aosh+qef7Nx6e4/gfeVWIJ16jdaAIx/unUeHh7itTUUzZmOBaHZGC08nBYO72h+n6g1ULXSW95w9vMxe/y8/h7+mVNPwO4gPeFAqaYTMJDQSRgtcNnDwKVjsJjm51G4XK66lbE5ssZDoZN2kclHY4xvDh0WmuunJLe2SSkY6aiOS+nG74j4t8R5LOOjAwWkOYeTh1VgEHZMO+U/KA9mRyIXXey2+m42aKKR2ZqV3cP/h+wflt8CuQQOwCw8jyWk7OrybNqiONzsQ1eIyDy4hu39R8VHIMhW4Hcjwe/Rdtnp/2TqOnrGt/o1wb3MhHJsoGWn+8AR72t8Voo6Rved5wN48Y48b/ADT1fp5t2tElOHkMnjEkMwG7Hc2uHmCAfgj0hO6928GRgjq4nOhqIvuSNOHD3dR5EFZxOVvtHRRK+OWaAxYxCfab973rP3Gjaad4c0CPG+RsF0K5Wqqp4C6CnFQ/owPDc+8noshLoC6ajqQb1XMhpc7UVHnGPNx5pha52rQrUY6k4C47c6F2obm2ntUILYH8T6sDAYR4O6fDc9F0PTs2rrBQuqf9squCkjHEfSY21Ax75OI/Lmt/R6GoYWuaWx0Nloml80hIaHEbkE+A5klZiqe3XVcyufA6n0xTHhoaXBa6rdyMjh909M9M8t1eoqaoqZWU9MMvccAd5SthFY8RNZknvCf0t2xa9rqqZodbqijjbxtqKqkcxzxnAOGvAGd/kr64ds+u6a3VVW2nsbYKdheZDHKc4HIevzVfbrawzv74953j+MsaMNHQDHgAAMeSa7UpG0ugqxrWhoe6OMADH2gfyC1bvbblY6gUtfo8gHQ50PiPJJW2dlDKIp4wDjKjQ9qWudTUUMtRe30Uc4y2mt0TITgjb6zBfy32IV/Q2W2Wyk9Mkc2ovEpBmqJXF8r/ABy47n4rJ6Ot8s0DXhv1VNTtGRy5AfotJBTmcOwcYx+K7vhvhW23W1yXa51LmsYSCANhprnU9e5dPa7LQyUrquZ3I1u+B/5WwpNa0dvga1kMkrgB5DKtNP8AaA+5XmnpTTMiikOOLOTlV9t7P45oGySve8uGcDZZxkZsupWM3HczAb+GV2dqsvCF1iqKa1sc+RrCQ52d9gRt18FpUlJY7g2aGjaXPa0nJz8tuvgvR9EAYwQ3J8AsH2hXUafidMXg3CYYY1p2iHj5roFmAfRxuzkEc1xDtdrHTapdC/PDEBj3FedcFWeK6XpsVQMtZlxHfj+64zhuibXXFscgy1uSR5KPpfSNTqyZ1XVPJjJ3J5lbZ/ZTb5IC1rSx2Pab1Wm0DaGQWOkaBlvACFtG29oZy3V6+cZXOSve2llMcbCQ0DQYGiS6cQ18tU4U8hYxpwAO4LzNe7NX6FujJYpHNZx+o4dcdF3Ds61kNU2dhkI9JbkPCg9penGV9kkPCC6PLgfguadj11fQ6ojpXE8Eoc3HmutqJW8YcNvrJmj0in3PeB+o+a35XjiKyuqJR/Oh3PeFfduluAFNUtHJ2CferXsTvcLNNyQTTMj7iU+24DY7qw7YKD0zTErwMmMcXyXE9OWyuvFS+lonYcRxEZwrdnpYL/wf6NUyiMROzzHoBr9CVYtsEV14d7CZ/II3bnpj/wAlelbhr2x0LT3lwjc4fZZuVyXtS1ratRUXcUnG94cCHOGEzR9kVwqMGqq2s8gSVKuHZTS0Ftll72SSRrSeWBlZFrg4UstbFM2rdJICMYGmfht71RoY7DbqlkjZ3PeDpgafRDsJruGrr6QnGQ2QD8F12910Vstk1VLyjaSuAdk9aaDWcEbjgSh0ZHmuwdpjJZ9GV3dZ4mND9ueyo8a26N/FcbHnDJuTXz9U/RN4ho2uvjWu0bJy/p9lx6ruVx7Qr2YWOLYOLYN2wFtbN2VW+mjaZjJO7mc7LF9mN1gt15cypIYJMBpPiu+QVNFDT94+eNrcZyXBX+NrlcrNUMtdtBigDRjlHte9XeIKqsoZm0VJlkYAxjr71yXtD0nS26yukp6cRuZvxDmtJ9E+b0/VrbOdxNURzOb4tZku/ALP9qutaavZ+zbc8TnPrujOfglfRcv8enu2G1yTkNjkbJDv0Jbj+a3KO3V9ZwZURV4JecvbzZ5sDB66640V+Omqn8OTtqMl2C4Z301+y+mTJWti4nODWgbk7JmlvdBVTmGCsgmlHNkcgcR8lzbtommrOyq7PpZXxyMhErXRuIOB7vevKP0TNW1sPaZVU0875Q88XrOznBwfwXltr4cNytlTcRJgxflxv715Lb7H6fbp64SYMfTG/vX0JVXqu/M0vp6pr3YMobwQsP2pDs0fqfIFT6J3fNHuXHe17U37UvrbZC7NLQ5D8cnSnn8ht7+JcS53I3K5ulg9ImDOg1KwtRO+aR8sji+R7i5znc3E7klQpXZJT0r1Ee7JVJoXYHRBvJGCkg4SlKFWclDkjHNJ4kY5JyiylcSNJShyTSkyjHNKSW80oc0iRLQAyUEbUxKEaCCCaU5BHzKJKAwhOREYKJKckoTglNQcjGwSTzQnBAeKJKOwSUKUBBA8kETkKYBEk53RnkknZMU4CInCInKBOUglCmAQJykk5Rk4SCcIUoCInKSThGThNk5TFIAgdykk4Rk4TbihSAIE5SHbBHyCQ5yE8JLnbJBPNGTumyd0J4SXFMPPmnTzTL01Km3ndMuOCnH80085Tk9NvKZkKded0y87ITCo8nVQp1Ml6qFPspGrOmKrqnkSqaq9tXFSeYVPVe2pFnE6rx39M53/APNSwN6G0Rj/AOzTL0oYeCCFo6MA/Beafppjh7VtOHxtUf8A8vKvUMseA0eAClm/w2e9UaP/AGibzH0XG9Zxei6/qByFTRxv+LS4fks5WDZ4PQkLYdqkBptWWao5CSJ8R/T8SsjWNxUVDfMO+YSsOyiqBh5VLE0i5uaOckOB7wcj80+CHtDhyIymJvqrlRv6Zc0/EJ2I8M08R5sfxD3O3H45HwVwLMcEHNTXBzHipDm5TZGUFNTcB5pmj9anliOe7755LM7E8RIyOuE80cL3D4pmkP1lU3wl/NrT+qahVNztppsyRgmLr+7/AJKtWxAyN+R2IVVX2LizJTeqesZ5H3JzXd6ZhUjQjJwPNGWOjcWuBa4c2kYIRHcKRCEbeN4HitBCwMY1o6DCpqJmZgfDdW7XJpTSpLeadYcKMHpYemFIrShuApmvhmj7+jlIMkWcEHo5p6OHj8DkHCVXW99LE2oif6VQSO4WVLRjB58Dx9l+Oh8Mgkbms41IobpPbpHOgk4Q8cMkbgHMkb4OadiPf1APMJ7XY0KQjuSM4RcSnF1tuHrMd+y5zzjdxSQE/undzfceLxLgkvs9axhe2AzRD+1gIlZ/ibkKXySKIjyU2TwnByCOhRh4SITgOU9E8xkOGzunkmG5PLdOjYjPPw6oQng8pQfjmlQ0M02/D3bfvP8A5KZFS08HtZnf+CYXAKUNJUaJkkxwxhd59FIFEyIcVTMGj7rUr0uWZ3dU7OJ3gzZo+KmW6xelS8Up9IcDv/u2/wAyoi/G6lawH2dU1SSyzHu7bTcIO3euH6q8tmkGPlE1weauTnwO9kK5obfHTNChX7VsVmkZR0sD7hdJf6qjgGXHwLvAKq6RzzysV9sTYhzPK+w1j0/Qafp+5oadsIOC9/N7z4ucdyferTOUQ2GUG8k5c+TnVGggghIj4kOJEglyhBBBFyCRCNEThAnzSS7CTKMJWQi4kgvSS7ZJlOAS3P2K84/TPoZa7s1nlje9hgc2Q8LiNgd16Ie/IK5X282YXvQd1pyOLihf+X+S6Dh+q9DutPOdg4fVbdmm9FuEM3c4fVeEexXs0p+0271lHLOIXU7GybkjIJwvRlm+ixp+lYDNmV3i1v6rgf0btTU2ku02J1wnZS0ksT4pXyHDQemfxXra7fSU7OdPxEPvLax7R7NJGXnP4L2rjSp4ibdPR7aXmMtBHKCfA6gd4XqPFM17Fx7ChLiwgEco+OvuXHe1f6NtltdgmrbUySmlhBe4vdni25LN/Q41nW2rX7bQ6R/oE8LxwZ2a/mNlJ7ZvpSU2sbZNbLDTT08EmxmlaBn4c1L+i3abRbK03Gqrov2jNuyIvGR54Uzhc6XhapZfQXOdowHVw8T5bqUtr6fh+dt3Bc52jQdSPEr27bqjvGuPiVYGQALPWaoAp2kuzkZU+SrwF84ZXipbqo+pJgLfMPvNXzi+kRaf2drx8obwtnZ+IOCvoFqSuzT8Oea8Z/SptPr0Ve0ZxIWOd7wvTfw4q/R761hOjwR9x9F3/BU3o10Y0/nBH3WCtfbfeLT2YQaMo6WKOjiM/FUAnicJJXyEEcti/HwWU0lLSmsliqiA6ZpEch6O57+/+a0HYbXWqHtDpbPfKeCajvkRipJZhtFUsyQzPIcbSR4lwaBzWq7Xuw+fTkj7namF9IXeuwfZJPP3L0t9fYJJavhdrDTFxILujnHXfJ0Pj07l6Oaq2RVE1n5OyLznm6Elc71FQejyMfgZB4SR+CqZoRU05Bxn8ipDrrJLA6mqsh7QWgu2PLb5FM0sg4uEjc9PNfP174cr+F6wNnGW5y1w2P8AfwXF3W3T21+HDI6FVbm5bg8wrG2wcbGjCKvoXMkL2D1Xb4Vjpa5UdoucT7nTPnpgQTG04z717DeaEcd2uC420g1EbeVzc4J/Z1Hmt+vpRxJSRVVKQZWDDm9VtezbR14v1+p/2fTOMcbwXzuae7YM9T5+HVb36WdZS2pljsMUvf11PABUyOPEcfZGfI52TNb9JagttHQUtkt4pIaTMjI44wG95jDc5545rkd1q7rrK4Vuo7rxzgHixj1pHE+qxo8SdlmcJcMVVgqjer1iKOMEgE6k4VKzWWW3VAuNw9RrM4zuStt2W0tVfYYNM05dDDKO/utQw4LafO0QPR0nLyaSd0fby+GtMTqZjY6WlIihawYaGjYYHh+mFo9E0zdG6VfQ5Dr1Xnvq2VnNuRjhz4DJaB4ZWX1rD+2mNpWu4Qds8/iuMouIo2cTi7SHDC/J8Gn+ywqe5D+MC4P0bzZPl/4XE9b60rLJoCS20L3wT1NU1xqGHDo2tIcAPMux8Glehe3m5U/aHoXSOradobT3+14kDeUc3CC9v90uLf7hXlXtHqGPoY44zxROmc5jjzLRsD8QfxXYOx6/P1f9F6+WBxMlZpO4itibnf0eUucR7smocfc1UOLaujuN3nrKF2Y3kHOCNcDOh8VVu9RT1VyknpzlrtdsdNfmuHaaq/Q7oGyuDcO4XZWtveZLMb7Sv72Ky1UT6h8Z2jZISzJ95DQPMrC6jjFLfKoDZsju8H97c/jlafsouFPLfquwVzgLdqClfbpHOGRHI7BhkA6ua8NxnxU0PE01PYZrN2YLHnOTnI2Og9yWmvEtPRPtoYC1xznu22+C9n6Ar3drXYfetFzPD7na43VtCSMl7OZa3w9YkZ8JfJcEqtFR01vjq21DpmuxnAxhL7GtfXTQ0tsuELeC6W17qWohe7Zz4yY5Gu9+Dn35C1tHV010qK+la3uqesc+SFn+7J34fgMfIrJtnE91tFKaWimLGk64xn44z8EymuNZQB8dLJytdrpjfqsdbbXTmAkQNfURnib3m4JB9k+R/VdNt2mKW5WVlXRU0bqapjIdCW5JHJzHDxByFzSGtNvuTI5RwGRxj90g6fHB+S6P2W6oitN8NrqZAyguDwYnOOBFOdh8Hcvfw+JWfU3mvrX/AOtzuePFxP3VeonqaxuZZHOI7yVxPtt0na7RY6KsvdvrrjpulqBFLUW54FbbYnu5MLgWyRcXJjsYLtnt4irvTnYX9E25W+Cet7VdZVVQ9gdJT0lrlhGcchxUbx/xH39V6G15o+NlPPUNp46mjnYY6qmkYHMe0ghwLTsQQTkctyvHeqdESdkl0DqQPm0xUSH0SR2XGlcd+4eefjwk8xtzG8tujgmqo4qqQsjJ1PcFnQQRTzN7Z/KwnUjotVq/ROgdPagt7+z243evtMdO6Em8FpkBztw4ijIByTgjmT4lYzUkLpIpKkDekqXUsw+67mP1HwUe8arlisctfR4M1JNFI+M/aYTy+eCT4Lc6utNPSa/vdtid/wBG32hiuFK52+dvb+Lw8/BeicT3q2Q2yKx2cl0bTzOcepXV3W4UTKSO1W4ksBySepVRT1vpVstlRn1m5hcfy/BYW5wYuNfTkY4JXPaPJ3rfrj4LQ2qqEVLNSO9V8bu8a08wWnDh/rwVPqlopr9FP9idgaT59P8AXkvJGDlcQuSPrNBWKvNFgEgbrI1UZY8hdFulNxZ81jLtRljicLQjcqEgVE5u+eR8VfaUuopp30U78QVJHC4/Yk6H47D5KklYQSmjuCPFWd1ADg5C7hHUGW1wVB3LPUl+GxPz3+KaqI+7kbM32T6rsfgVSaC1ELlRPpZzmdow/P2xyDv0PuHitBGzuyad27cepnqPD4KHrhWdxkLFXQu09d3OAPolR64HQHqFKdIJsOYRnGWnoR4K3vtoF1t8lOf65nrRu8/8+Sw9pr3U8poZyWnP1ZPQ+Cdum5wrWqihuFO6jqfUGcxyHcxP8fceoWRq6SWhqXwTt4JWHBHj5jyWrqPrRnk8cwolVHHdYG08zmx1DBinndsP4HeXgeie0pjhlZk8klOzQyU0r4pmOjlYcOY7mCmlIVAku5pDh0Syd0khIkKct1a62VsVS1neBmQ+I8pGEYcw+RBIR3e2stld3cTjLSTME1PIftxu9k+/ofMFMYCtaMC7Wl1uzmrpy6opP3m85Y//ABjzDvFNcNchTQn8h93n/dafRepRXxNttW/NSwfUyO/tGjofMfiPcr6aDgJI+SzOmezK63YRVWRTRgh7H8eHA9DhdSh0hmFjamoaZsesWdT8V2FHwXe69gmigIads4GfiuupeHLnVsEjIsA9+n1WHni37xvMc8LOXnTMdaXz03DDUHdzOTJD+h810a6aXmoWulZ68fM45hZipiMR4cbHkueuFrrLRN2FZGWO+vksatoKihk7KpZylc0bbamSqNMyFwqQccB5hbK2dkl6uDYpnMNI9pDmlzgCCF0zSWnKVlM2uqIWSTAZa5zdwPeqDWOv6ylqXw0bXxQt9UStOQf5L0uk4ctdst8dyvzz/M9ljdz5rr6az0Fuo2Vt1cfX9lo3XWNM3Ca3WyCmrA17mgElvIHA4vx5KLLVs09ralr4yBbLyW004PKOpA+rd/eA4feGrlfZ3rmsqrtNQVsveB7e8hc7mSOY+X5FdRq7THqK31FslJaypZhrhzY8btcPMEAqWTh6wX621FXZg6OSEZLSc50z88LdipLbdaOSot4LXMGcFb67ROdRSYJBx0WXs9S6KqcS527TvguI+A5q30BeZNV6SzWAMutE91HXRD7MzNifc4YcPIqmps0d5YDtwyYTuCI219kuVuI9YtJHwP3AU1hAqKGqpiNcZHw/8Ji401f2hVUdFLT1Fq0jSuBdFKCya4vByOIc2syM+fPw4ZV5DGSxwxMaxjGhrWMGA0eAW9npBT0rpn8mtzlYq00Tr3eHHB4cknyWNwBSMhnnvVUPUgacf5iq3D/JGZK54wyMfNV1uAFfCHci7BUnt2tAh7O6YRR5llr4owANySHbJV7pjbby4YxwuDwF2212Cjv9BbZaqFs7YJGVUQfyEjQeF3wyVs/iY1tZHQ3SMaSMx9CPqVPxO8SejVrRo9v6H7rAWfQR09o3upGYqns45fI/d+CzekKBtdfYqaTk53Cfeu+323NFmqhjcRkrh2isSawjEfV5cPmjgs9vw9c6Z23Ln5H9+5RWOQzW2sY7u+y7pQ2OOOma0N2a3C4h2n2423VL3NHCJGB4969IUcQ7keYXGO3a293PQ1Qb96Mn8Vh/hxV+j31sR2ka5vyz9lj8Jzdlc2tOzgR9/sui6FqxX6eo5RvxRj8lyHthojT6jZMR6rxjPjhb/sXr/SdNMjJ9aJxZjy6Idr2lHXm2x1EDcywuLjjqMLQstTHw/wAXSQzHDC5zfIHb7Ke3SttV+eyTRpJHx2V12WVrLjpahcCCWN4He8LesZ6q839lmum6ZrfQq0llK4k5PQrv1LqS3SwB7KuIgjOzslc5xbYam2XSUhhMbyXNIGRgnPyWTfLVNR1r8NJa4kg+ZUHWEbRY6xx3xGSvO+gW9/rOJ0XMPL249/8AmuldrHaRRi3yW+ilL53+04DYfFZ7sa0zJJWm4yswB7BXcWCKSxcM1lXWjl7UYaDoTpjZdFa4X2uzVM9QMdpoAevRdP1ZRGv0/UxnfLCMfBcH7NZ/Qda0sTzjjLoj716UrKTvKCRvDzavOTNOXWk1uX0tDNI2KqDg5rdsZ33+ap8C1MU1tuFvneGhzcjJAGxHX3Kvwy+N9FV0krgA5vU46EL0bSW5jmA4Ue82tj6GVvDzarW3nihaSCNuRTtXFxxuGNiF4u15Y8O7iuBa3lIIXk2Imxa4YdwYaofif816TnpGXK3OjcOJkjMHzBWYruyu01d2fXTxPlle4Oxx4Gfct1RUYigawD1WgABei8XcRUl89Elpg4SRtw4kY10OmvQ5XW3y6wXPsHwgh7Bgk+7b35XnvVnZhWUNbJPQgviLshreY9yq6bT2p52CH62JvL6xy9KVVsbLk4UWGxB8zQGgknHJXqf8R7lFTthmjZIW7OcNVZh4rrWRCORjXkbEjVYXsh7E33O/UxrmtqHk8bsE+q0bn+XxXSOy/wCjjYbhqa73eYVT20VykhgDH8ABaMnlz3P4LvPZdomDTOnJ7rVsDZXRGQk/ZY0Z/HGfgFN7F7O6Hs7tdTO0ekVpkq5HHm4ySOcD/hLVzMvFd4qZnzOqC3nGoGgwOg7guSrOILhO6WQTEZw04001VP2sV1Nprswupl2p20xiwT0Ix/JeUPog6cmr+0Ga6Ny6OmaWknk4E4Xt7Wek6LVdmnt1dC2anlaWODhlZzs17J7X2fxSU9tiLWPeXku55K17Zf4bfZaqiAPazHfpjr71HQ3mKhtNRRtB7SU79MLaah1I3SWlp604NQ4d3Aw/akPL4DcnyC8/vlc9znvcXveS5znHJJ6laHtH1d/tFfe4gfxUFFmOIg7Od9p/zGB5DzWTfMvNZX87sDYKC30xgiy72nan7BCV/NME5KJ0nEcpIdkpAr5CcaUsHdNN5Jwc1IFUfolJQ5JKMHCcq5SkpJRgpCmo0sdCkZCU1NT04jakjklNTEBGgggmlSBGBulIm8kaEqSeaDQhzKNvJCejSRzRu5IhzQnBG4pKM80SFMEElHnZJ8EKZqJyS44CM80TkxThJSPtBLPJN53QpgiceaQlO5JKYpgkuKQjciPJCkCS4pCNySThCeicU24pTuSQ5Cekk4TbuaUeqQShOSX8ky9OOKadyQhNP5pl3PCecmnckIymn80y/mnnJp6FG4qLJsoM/VT5hsVX1BxlStWbM5V1Sc5VVUe0rOoPNVs/tBPWfnVeOPpuju+0rTL/AP8AZbPwmkXqSUcTWnxC8u/Tn9XXWmXDpa8f/ZXr1BSu7+30soOQ+Jrs+8BTzf4bPeq1J/tEw8voub9tFNiltNWB/VT4JXProe6uAJ2Dox+ZXXO1qg9J0VUSY9aF7Xj5jK5HffXipKgcns5qOI5wlqRqVT3MYbE9vNrxhKqz3NzpZR7FQwxH3j1m/hxKHJcI6iCeIHifDh2Ry5qRdMus3fN3fTObMPc05P8Aw5CutPRZDhopbgkPCXkO3G4KJwSlMUc+2PPZR4vVrphy4mtd+YP5BO1OWtafBw/Hb9VGld3dTA/pvGfjy/EAfFIm40Vg0ZCcATcZyE6N01Cj1duhr24kbhw5PbsQs/W2aoosuA72L77By946LVgJYGUBxCbhZCiADC7nlTQ5XFRZaapJeGmGQ83x7Z945FQpLHUx/wBW9kw/wu/l+Kk5gUwgpgO2Rh+El9HVxe1Tyf3W8X4hNOL2ndpB8wlSKSX7c0nj81HD3HoT8E42GeT2IJX/AMLCU3CMpZkQjndE4OY4scORBwU/DZ66bfuCweMhDfw5qZHp8M3mqG/wxjP4p2cJMEpgX+4cjX1Dh4PkJH4p2GquFYfVfI/z5KZFRUlPuyLjd96TdPOnOMZwPAbI5k8MTcNued6iY+4HKlRmGnGImDPiojqgDrk+CSXOcQHZBPKNvM+/wCaSTungY2UuWswMuO3gEpkDpW8dQ4ww9Ix7Tk1A0QcLi3vJTs1o5A+X81eWy3OdMHv+sqPE+zGPJRueAp2sLjqnrdbDK0BzO4h/3Tfad/EVoaaINIjjaBwj2RyCjwRvlm9FpBxSD+skO4YP5+Sr73dpopI7PZWmevqH90H53Lupz5DJJ6YVU5ecK8AIxlLut3q6y4/sWxhstxIzPVOGY6VvifF3gFsND6CgsoJhDp6yY5nrp95JD4k+Hkn9F6JgsFI2ki+tkJ46ioPtTSHmSum222MpY2kgcf5JjnjHI3b6qzHHg8z9/ovo/wBETeSJE3krC5PCXkIZCRxIcQQjCXkIuJI40RehLhK4kRck8WySX/FJlKAllySXfJIL8psvSZTw1OFyQXpp0nRNukwm5Ugani/KzWsaZtbZ6qJwyCw7K7dKq66nvYHtzzBCcx5Y4OHRStHKQQvl3qWyCj17XWx5LB6aY8+HE7b813/T/wBFmiljZJVVQkDsHAy5cs+kLbHWXtRrJWDh73hmaf3v9YXrPQ/aDYBpC11VZcIInPp2FzS7JzgA/kvpXiu9XWK10NVbXkCRvrYGTnA/uvbeILjcGUNJPQuIDxrgZ1wP7rFn6NWmhThj4ZJMDbhPDv8ABefe1HRc3ZTqtslundGzIcwtdggc8L1ZqX6Quj7LTP4JnVUjR7LABn4ryd2l64qe13VTJKOlljhzwMjxxHGeuFn8Fv4hlrHS3Iu9H5Tzc+3uBVThk3h9SZK0u7HBzzbfAr2X2Ga7l1XoymnqHZnYeFx8dtl0l9Xlp3XF+xGxS6U0lR0kp+u4QX46rpstbwxc14deDB/EJ/RvY5jjyyvMbgIjVy9h7GTjyUS/VvFkZXBfpH2sVvZ7U1PDkwva/PucB+q7Bc6rjJOVje0m0x3vQUtJI4tbUTRxZA3OZAE6yV4tlxhrHbMIJ8s6qa21HodXDOdmuB9y8SC1SXnTla2lmfSXCjljq6WriJD4ZWkcLmkciCF677JO1Cl7auzWnus8cbLrTn0G9UGMGCqaMOIb/u5B67eYw7hyS04pL59H+yaK0pcKqiNRNV8HC58r9se75rzvobWdR2M67GpBxOsFc0UN/p2A7wZ9SoAHN8LjnOCeAvAxlTcY3akul/lq6DPK8NOoxqBj7Lrr1VU13lNVTZx4jHRdQ7SuyGGoqi62cMdS7+pGcNk5+qT97z6+/nxyrstxs9bLTVlNLS1MDuGSGUcL2Hpkef4r1Tf+CpyQ5ssTxlpaeJrmnkQRsR5rMags9DrKhZS3eUU1dE3gory4FxjHSOfG74/B3tN8xkG//pzXyWw2upY2VvQvBJHlqPiiO+VQpfQ5QHt73akLjNBAKyiDiMujdg+4rvehezmw6t0NBU11KHGAvbK5mxOCTufcuQx6YuGnb/LZ7pB6LVvj4m78TJW82vY4bOacHBGy7F2A11RLVV9iefqqh8ZLHdATh/4Lh6euqaJ/aU0hYe8HCwQ6WHMkLi0+Bwp1N2KWe0WWGZtujbV1T+MNLclrScgfAY+ZWU1Nb6Y6rht8bGiisUQrJmMAAfUvB7oH+FuXA9CV6Q1tW0lnbLUzHENFTuneR0GCTjzw1eYI62V9jmrqk/0271clZL5NzgD3bZCs1V0rK8/61K5/mSVEZ6ipHPUPLvMqLNVOj70vdmeY8UjvDyWQ1jcDRWWtla7Es3DSREcw554SR5gEn4K7qp8AuJz1K5x2mXN9N+xKYHIYXVcw8c+q383rOAyU06Bcp7Ton+jQOYMCPBwPDktB9F3V0One0plprnZtOpad9oqmk7O7z+r+JeGsz0D3Jeq6Nlwo2/ajcCCR4FcnkiqLbVuYHPiqIHeq9hwQRycD8ir0eHs5VUeTHIHLedqGm6jT96q6Ko9apt1Q+kkfjHGATwvHkRuPJwWNpqqSlnjmheY5Y3B7Ht5tI3BC7j2r1TO0XSWndewxt47vTegXQRjAjr4RjJ8ONoy0fcYD1XB5GlhI5EFPYMt1TpRyvyF3hlxjrrg25Q4bDdoWVpaOTZcBkrfg5oPvetBbbg6F7Hsdh7CHNPgQuVaBvIn0/JTPcO8t83fNyf7J+zh8D6y3tLUcjlZ/Ly5b3KyTnDu9Xms6KO5Td5E7uo7jH3kbxzjmbjP5A/NUlNd5Lnau9kHBW0z+5qojthw2J+PNWNRO+otUkQPrROE8fk4c/mPyCz91mbQ1Ud6iH9GmaKeujHIDk1/w5e7HmlxzDCaHFhyvTnY52mRaztTrTc3tddqZmH8f/tMXIP8A4hkB3ng9dq7tD7PYo4qiOWlZW2eraWSQyDiaWn7J/Q+XivOVvvdZpy8wVlDUGCspn95DKNwfIjqCDgjqCvW3Z12hW/tE053pa1sjAI6yjecmB5/Nh3IP6g4lZ6w5Tv0THeqedo06heJO0fstquzwTVURlrdK1IMLpycyUYdsGTfu74EnjgOwcF1tdL16V2e9mWpg/MlAH2GrcNyWsJZEM9AWxucT++Pj6u1XpVtrkeO7bUW6paWESAOa5pG7XDkdvmF5k1t2XnR1DerJbuI6Vv7hJRxk5/Z9wGOBmTyZLwtaHHkWhv2hl3MSQx+4PxGxUckXq9tF7P0KyOqqf9mX8VUW8VSO925E8nD9f7yr9TQ+n00JZu4QlzPNzTt8wU9QXA6o7PKSqO9Vb39xMCNxgY/IsPwKgNqnGjpyT/UyYP8ACdvzI+SXBB13GiTIO2x1VcHNq6SN434mrP3Si4g4FXsLPRamqpeTWuEsf8LunwIITdZAJWZA3U7Tgqs8LndXTmN5GFXvbwuwtZdaEHJAWbqYiCR1V0HKqEYR224zWmuiqqc4kjPI8nDqD5Fdct10gvtuiq6d3PoebHDmCuNtilMZf3Tywc3AbLWdn1HeHVpkoad09I/adhOBjxHmFaho6irkEUDC5x2ABJVunhmmeIo2Fzj0AXQnESsD27OHMfmFh9bWMF/psLccXtgdHeK29ZDJbJw2XZr8A+R6H9FCuMYqKZ7Mcx+KhmglpZHQztLXN0IO4TpoXwvMUgw4bgrn9suxq291K7FQwcz9sfzTlS0SsLgNzzC12gNK0dTdp5qmmZMwey14/q3JjtDnpYb0ylhYyHDfZAxkhdY7hyWOzC9OkAaTgNwc748lrus0jLWLlI8YJwB1VDHp646goiTSSF8DfqqsjZzf92/9D05HbkxprQdw1BUObtTsYcOc8FdX0FK2ssjoX7jGCFT641Y3TTf2fQMa2Q7uPgu7h4UtFJbobxWTExEZLepPQDC6dtgttNRRXOqkJjIyR1J6AYTdN2PW5jeCery/wZgKk1N2SSUMDp6B5ka37B5/NZr/AGuuQl7xtU5rs8wV1Ds/1n+3YxSVJBqACd+oCuW1/CvED/4c2m7F7vZdnXPn3+CnoZeHr0/0JsHZOPsnPVcLljfA9zHtLXA4IK3HZTp5t1vAqZCQKch7fHIT/axpllsuEdVA3Ecrcux45WUtGoay0RuZTTOjDufCcLgGU0XDd87O4s52xnOB17lx7YY7HdeStbzNjOw69y6x2g6ulsTY6Wia1ocD67TjGOY/Jc5g1rc6WsE7al3GDnBOR7vcVJslquerZJY3Rulik371x2Y8cne4+yfI56LSUvZLFC0Or6hrHDcjiyumqXcQ8T1TqukDmRZ9XXlAHnouildeb/MaqnDmx/l1wAPNbrS19j1NZxKNyW4c08weoKyV/oxBcZoiMMzkLTaTt1usxdT0c4e93No8lXaygDLhG/kXt5+5dNxjRTT8NQVFUQ6aIgOIOdDkb+8LoeIqaWWyRTTkOkjIBI1303+ConakrqOkbSNkLY2t4RjqFXUVlrL2XmCF0wzhx6KTNTtmj4XfA+CkWO/y6bE0bmE8ZBBHIryChq47lVRRXmZ3YtGMg5xgaAZz5LzumnZWTsZcpXdmB5400wn7B2Y1NBeKeuc5sTYn8bWcWeHxHu5/Ndf01HFLcOB5ALBloPXyXJna+rHOPA1o/iK1GjtUOvUUpcO7qoH4dj8D/rxXslodYaymmstjldHJIPacMk46Z0XplrltM8clttjy17+pG62j3f7DdqFFWn1bRqdraGo+6yqaPqX/AN9uWfDJS9TQGivkhAxkh4UnUNndrrQdbQtPDWiMS0sgOHNmZgsIPTcAZ8CVU/t//a/TdmvbgBPUQ8FQ0DHDK04eMdNwSPIhcn+H4ktXEUttn3Ic0+7X7KLh9rqO5Op39QQfdqttqu7tZp6mjjd687Bn3YVl2Z2INojVPHrS8j4hc8pXTXapo6Yku4PUb5Bd701b20dDDE1uA1oVviyNnDNlZZoj60rnOd/lzp9lFe4xa6BtvYdXuJPlnT7LlPahb/RLtFIBgPaR8l1HsrqxW6XoyTlzG8BPmFlO2OgzRw1AHsP/AD2UjsTuJNsq6bO8cnEB7wo7n/6pwLTz7mFwB+JH3CSqb6Xw7E/rGcfb7hbjXtyZadOVMhcGvLSG+Z8FxnswpW1GphUPLWNjJeHOOFI7U9S11Zd57dM8+jxuBa1Udm03fqhvFR00jGP34zsF1FgsbLZw3K2pnbG6pGeYnQAjTfGdFr263No7S9ssrWGXqTphejjqu02+H62tiBHQHJXLe1vVtqv9qEFLIXyseHAkfNU1L2VX2vwaqsZADzHEXfkrqj7FaZuDU1kszuoaMBcpb6XhXh6qjrHV5kkYcgNGR8hj5rDporLa5mzmpL3NOfVGf38VkdC6+k0dFOxrBIJHBwzvhd707dW6qsjKhwGXZBC4h2haLpdNwQupY3Na4blxyV0PsPuXpNnkgJyW4P6K7xjBbbvaf9IaBhDnOGSd+5T32KkuFD/FKVuCTqTv3Ku1h2SQ19Q6oo3dxIdyByPuWQj7NtQwAxNqO5hPLDzk/AL0jLSMlbnCYNqYOi4eg49vFDAKfmD2jbmGSPf+q56m4huNLGIg4OA25hnC4lYOx4mobPX1L5CN+Hh2PzXX7HZY7fAyONgY1oxgDCs4rc1nRToogwclzt34huF7eHVkmQNhsB7gsmtuFXcnB1S/ONh0CQ+EGPBCrX2ppk4sK7HJF3bfBc6DhZpblRaeDgaAn3MDglluESRJhMOpQTyShGGDknUTuSEiawD0Wq7N9M/t++x8TMwxEOcVl3HAXeOyOwi12UVD24lm3/1+CTGThQzydlGT1Vv2pVjbL2XaklYOAR2+VjANsFzC1v4kKy05bf2Npu1W/GBSUsUH+Fgb+iou19grNEuoHbiurqOlx4h9TGD+GVrAS4DxwrTRqT4Bc+dIh4k/Qf3QMIesB2q6zj0/bnWyjf8A9IVLcPc07xMPM+88grXX/aBTaLtzg1zZbhIPq4s8vMrzrWXSa8VstXUS99PK7ic53UpsjyPVC1KChMhEsg9UbeP9k8x/CEC/iVbcbrT2qnM9RII4xsXOOAmbLqGjvrHvpJWytYcEtOU1tNM6Izhh5BpnGnxXVdk8s5wPVHVWwKUDhI3cltChCrOTjeSWktCUpQs6Q6paCIDCNOVZGOaUkjmjyE0oRpQOElDOyROCfbuEoDCJnshKTEqCCCCE9KHJB3JBvJA8khCcElLHJISmpE9ByIc0Hc0SE4IIHqgghShJQQRZ3wmlThJSTzSkg9UinaiJ2CQeaUknmmKYJLkk8kpyQShShIdzSTySnJJOEKUJDkg80tyQ7mhPSXJDko80g7oS5SEghOHcpBOUJcpp3NNuCcdzSCN0JMplwwE04J9wTThkoTS5MO5pp4T5amnjCcFA96iT8iq2q2VjPsCqyqKkCzZHZVZUHOVBeOJyl1Dtyubdv2sJ9CdlF2uVHO6muMhZTUsjPaa97gCW+YbxH4KQDJwqpdyguPReevpw/Wa5083qy3YPxkcuq27t60dZ9OWSmluL7jcRQwd7S22F07mv7sZaXD1AQdiC7ZeZu0N1wuVp07Nc6matrpKNz3z1Ly97uLDhknfqrPRttijt1M+JjQZIwXEDmVZcwFjQeioskfHUvLB7QG/ku1at7a6nUFkraW26cMdLLE4Ga4VAa8+6NnFv73Lnss092sULpqjjY2IOZHEOFo269T81d2+gJpwCOmFQWZhgFfbn86aVzAD9x27fwOPgo2gAaKWQucfWOcqgpHiOrmGMBzNx5citdRFs9CxrhxMkjGQeu26yGO4ubWnkSWlaCxVBfQ8BPrQvdGfgpgs/GiethJoYmOOXx5icfNp4c/gph3UWECOrqWDk4tlHxGD+Lc/FSc5GyeosKLcBilJ8HNcfg4EqNUR97C9ucEjY+B6H5qdVx99SSxjm9hA+Sgsk76Fj+jmg4TSnNCVbq4VDG59VxHI/krNvNZmE922M8iW7/wAQ2d+I/FWtNceEASDiH3hzQoiMK0bzS28k1FMyUZY4OHknEITo5JaZDkoPQhPByMOI6pnj80XeYTEKR3rvFEZj4lRzImn1TW9U9ClPkJ5kn3ph8oHVQ5a3zwoslXnO/wAUoSZU99UB1TQlfM7DfmoTXjunTyvENO3nK/qfAeJ8gnYi6sYHOY6noz7MfKSbzPgPJKlUmF3eOIhIONnTuGWjyHiVOpoPaDPVaBxPlfzx4lIpKd8z442MHEdmRt5NCuIKVsr+5YeKCIgyvH9o8cmjyCjc5TsZ1QtVA57xJwkOdswO5geJ8z/ktJBTOa5lLT7zP3c77o8SipqY0kDX8HHPKeGNnUkrRUdNBpu1z11Y7iLGmSR/VzugH5AKo93ctGKPOp2VNqKtj0vbG0VO4Nqpm8T353Y3q4+Z5D4+Cn9m2lXW+h/bVSw+n1zeGljdzig8fe7Y+7Hms/puyy621JJUXAZpI3Ceszyx9iEfLfyB8V2mz0jrhUmpeOFnssHQAeCHeo3l69U5nru5+g2VhYrYII2vcOXL3+Kvo25TcbA1oAHJSIxhQgKclfQUnCInKRxe5EXq8VyYCUThEXJoyIjIPFJlO5U6XJJfsmTJhIdIm5TuVPGQeKSZQmDIm3SpuU8NT7pSm3S/FR3Tc90y+bzTMqQMUh82yZfN8FHknx1UaSo803KlDFLfUeBUOsn4mHdR5Krnuos9VxDCTKlDV5T+kz2bXjU2pqKqtNvkqjhzHlg2A5glYC1dg2s6yCOKorIqCADAaZScD3BezLnA2pO6qXW6NvML02j4+udBQR0MDWYYNCRk/M4+S7Gm4ouFLSspYQ3DdiRk/XHyXnG2/Rjp2uD7ld5qhw5tiZsfid10rSXZhadLuYaOB3GPtyHJXQHQxtPIJDS1p8Fzlx4rvF0aY6qclvcMAfAALLq7xcq8ctRMSO7QD5KZQNFPGBlO1dfhhGdlXvqwwHdVtXXbHdcjzrHEeEqsrOJ/NMXx3pFmtMX37lE3/jb/ADVXPVesd0v0gz/saPOeG5wnHvc1JzaFShmoW77RKBkula+MgYczHz2Xgu4UrHVFVBIwPaXua5rhkHoQQve/aLN3enK7foPzC8K6ijEOobixvsidxHxOf1WVOc1jh4BatCMUvvWu7F9RyfsiTSNbKZJ7Wzjt0jzvLR5ADPMxEhn8Bj8CtlUeqSCNj0XFXumpKmkuNDIKevpX97DIRkZxggjq1wJaR1BK67a73T6ntEVwphwE+rNCTl0Mg9ph/Q9QQeRUu6V45TkbKU+ppqqgjt12pn3C2ROL4RGeGoo3Hm+B/TxLD6p8Ftux2yRabv4raioiuVBcHNjorvTjhYZG8RMUrf7KU+r6p2JHq56c7lcW5U2xaluGl6qWot7o5I528FTQ1LeKnqm/de3x8HcwkLTjRRk5GFru3K/zTsq7fG4smuNQyHzawYz+Dd/iuWXaqa+ZsbBiKFgiYPBoGAtTra8w6qurL3QGRkMUP11vnOZqSU4bnP24yBs8eOHYOM4WZ3ESpYx6uqHEYDQolbJxBrM4MjwwfNcp7Sa9lTfbhg5bC0QNHhwjf8SV0upeH3OlYThjXcZ+AJXDdQVjq19ZUEnile6Q/E5Kss3UD9kLVeRLF6LUEEfZJ/JUesLG8sFfTtMj4h67Rzcz+YUSSYMwc4V9Zb22pAhldl/Qnqp9WHmCr6PHKVedhN8pr3FeOz6tmayj1EwSW6WTZtPcWDMRz0D8cDup9UDmubXijlo7jU09RE6nqIZHRyxSDDmPBw5pHiCCE/qux1GnKyO8Wtz4oWSCUOhOHU0gOQ4eAzuD0W67WO51pZ7H2kUEbWRXtvo11iiGG09xiAEgx9kSNAkaOZySp9Pabsfql1czlO4+n9liNFXAW3UlO2Q4gqc08ueRa7YfDOD8F0+2TOi4qaQkywnh36joVxiRudwcOHIhdZdVCqFHWMdwvqIWzNcepIy5vvByFWmGHB3epIvWYW933WrpKnhcN9uqhTcNLPNTSNDqeRp9U8nMP8uSi0taJWZ9lw9pvgUjUYlqbX6RSjirKX6xjOXGPtN+I/HCiCU5VJPG+ikNE9xeIxxQSH7cfh7xy+St9Ia4uOjrzFcbdN3VSwcLmv3ZMzqx46g/MHcYIyqeOsg1FQRiCQR1LR3kPGMdOh8+RCTHa6ioYC9ndP6jPVdBQWK5XXWjgc8d4GnxV6koKusP8iMuHlovY+hO0uz9pFokZS4FQ1uaq0zuHeR/vMP2m55EeIzgqq1Xodtzt9ZSsiF0tdSwxzU7tpGg9CPEdCNwRnbGV5Vo23Ky1cNZR1UlPVQu446iBxa9h94XZtIfSEbW93Takb6HXsw1t1pmZZJ/3rBy97dvIJlzs1wteG10JYTtnb47KWaiqrc4CdhaD0K4AbXU9m3afctO3Vz3U14aAyeQcJmzkMk8nElzHfv7jZVtRTOoq6po5epMZ/Qr1T2zdllJ9ILQrTbpqaDVlvBqbTcYZB3cxwOKJzh0fwjf7Lg08gQfMla+bUFgjussLqS60cpobpSPbwvp6mM4cHN6bjOOmcdFkB3O3m67H7FZPZ8hLBtu3y6j3KhrHlvc1B9qImOUnq07Z+fCfdlWdns5urnjvBGG+W6g1bGyRCQtzFM3he0+P+vyVjoSpd6ZJTyOzIwcLvPHI/ELrOFKalr7xT0tY3mY84IyR0028VqWenhqLjFDUDLXHH6fNWDtC2xhzUyvf5ZwibadM2s59FhL/vP3KGtDLG+PheWtcOhWDqmOlOSS4jxK9au97tnDNc+ho7czmZ+YjJ89cldZc7rRWSqdS01E3Lep1+uV0TVNrprhpGuZTQxsDoS5hjaByXJuzzUzrBdyx7z3MuGEHkN12DTD/TtNRxuP2DGf9fFef7tTOt12nj9gxyED5qzxlVvppLbfaT1SW9Nuhx8yn8TVL4H0N2p9CW9PccfMrvup6ZlTbzUMHeNJHEB4eIWMjqS+IgvD+B3AXA5yMZB+RVx2aambebZ6HUEOmaTseoTFxscWm7NeZHADvKyB0LjzaHNm4sfJvyWVxtQw3aki4joho4APHcfH6FVuI4I7hTR3mlGjhh3gf3orjRVO2MVErfZkOT7wuU9qT3S6klk3x08iuuaNaRZS/o/cFcw1bALnVVLnD1uI7pvED/ROFLdTf1et9/v81DfP5Vgo4P6tf38VoOxy8PnZJTSO4iM4J5+O6r+1i3ubcWzNGSQQVVdl9U63ajELzzwtX2xU746WGqjJaWOG481bZ/6jwQ5o1MTvkD+icz/XeFSDvGfuuRF+6v8ARdydQaho3g4Bdwn3FZ0Sh78kBpPyVjYInz3akZH7feAgDruvI7fI+Gshkj9oOGPivOaN7o6mN8e4cMfFdm7SqNtfppspG4HP4LjWnbYbtd4KYcnO393Vdy109sej58+q7gDmg+PguMaLrm27VNFO/AYJMO9xXrnHEEDr/S9ts8N5vLOF6PxZFCbzT9rs4N5vjhdg1DX0+hrA1tLG1snDhrgACfNcuumoq+80vpTquQujPdysDsY+674gYPmD4rrWtLD/ALU2ZggILm5cw+Oy5TbdGXijuXdzUpFPJ9VOwncsPUeYIBHmAp+Oqa7vqWQUbXej4HKGZx78fdT8VQ3E1TIadp7DAwG7e/H3Uzs4rXt1HCfWdk4ceey3/aLI2mp6SV2G5k4A48g48gfI/wAlE0rpCn0ZFJXV0rHyb4cBjAVtr62M1Fo6rjYQcsEjD+S3bbY6lnCtTb6r/FcC8N6jqM+ZC2qG1TxWGekn9sguDeo6j44VDpyngvMoa52D1B5g+BU7UWkcRDuG8QAzt0K51pu/VEMUs4y6sofVqmDnJH0lHiR1/wDJdMt2t2S07C8CRhaHB46hea2GSwVFC+3XUdnLnSRcfa5LPPSupK4cjydHrECz1nfcHcu4wcHZb/SVj/YdPLUzkNfIAXfBJn1nSwM44qcZHMnZZu+arqrxTvhAbHE/LTw81v29/DfCspro6g1EoB5QBga+K1KN9lsTzUxzGWQbADC75oOtjrKJwjcHgYcCOrT1WQgtz7Pq3U+n44yWSzNvFJG0fZk2lwOgD8AAeCyn0d9WuZJU2aqeTUULy4Z5vicfxwfzC6xreJtk7UNA3tp+orXy2ioePtCRnFA33cfEV5jBxBUU17/jHKC/mLsdNeio01zk9J/iAGSTnHj3KboPTVSy4ioqYHRtbyDhz812m2xcEY2VLQ0TWOyAtDSDAGyrcQX6o4grDWVAAOMADYD3qCvrJrlOaiYYO2BsFA1Fp2n1BSmCpaXRno04Kj6c0hRad7z0ODuy8esSckrTsjDsJ9sIwsltyq20xo2yuER15cnGfJVO0nEfYh55O7OnwXnvtgoTT6iZNj+sZgn3LpfZq1t003RSHdwZwn3hL1toWLU80L3u4TGT8VeaL09Hp2gbSxEuYCTuMc16JeOIKK48NUlDk9vEe7pqN/LC366vgq7XBTH/ABGH5a/2V3FamgDZShb2AclJi9kJzC8syVy4jC572j6QfqG2tihGHgncKD2ZaLqtKueZX54hyyulTQh4wUUVIGHIC6Jl/rY7abUHDsic4xqrwrqhlKaNp9QnKkxZ4PJOBoKS1vCEsYK59ZuEeEEEY3CEwhG3kjRAYRpcphQRcKMDJQIwlTEkjCJLSXc0IUyx203a80tKBkPf63uG5XpW1wNpaOOJowABsuNdklq7+4VFc9vqxgMafM8/0+a7NC7HCPJK3dZFa7JDVme0mXjm0fR8/Sb5EMf93HLN+cQQ7Qdf02jaHhaWyV8jT3cX3fMqo7U75BaNTaRmnd9XRirrnN/eEYib8++cFwq/X2p1HdZ66qeXSSuJxnZo6AJzn8mQN1LR0YnDXP8AZGfec/2VF2g3m7Xymqaxk5fWE5BduuR6O7WKqx1FRBfOOUOfscez5Lsz4+9BCzly0DbbtP3s1EyR/Q4XZ2G7W2nppaG6U/Ox+oc3HMD4HuXe0ddSU8Tqari5mnqNwud9ofaU3WFGLXb4HlryCSTnfoug9kthlsNgjbMMTP3OPDorCzaBo7e5roqZrSOR4QmdWdo9r7P5WwTwS1NQRnu48BbdTXi70rLBw/TEMzzHJy5x7z3BSy1/p8bbbbITy5zvklbyONxanmwnwWf7Otbw67sxrY6c0xEhjMbjkjHJa0tXndVRzUM76aobyvacEdxXKVIlp5XQyDDm6EKKI8eSUBg5Txbnmklqq5VAnKaQSyEk5BRlNwiQRnxQJyhGEOQR8SQTshxJClwprPYb7koDKS3ZrfclA4TUmUMFEloITgUkHCUkkYRg5QnhERhDkUZGUlNTwUo7hJQQQnBBFnojzgoiN0KUFEku5pSQmlTAojySUtISKYFJSXc0tyQ7mhTgpJ3CQ4JZHVJIymKUFIIyEhyWchJO6FICkHkkEbJxwSCEJ+U2RlJISyEkjCEZTZGU27mnSEgjJQk5k0Rsm3DITxBTbghNLky5IcE84JsjKdhROemHBMyclIeFHlCdhVHvUGoOyqao81a1A2KqKzqnhVXHKq5vWcvOH0qKt+q9V6P0NA48L3Guqw3o3drT7w1svzC9JMYXzeK8yaQcNe9q+tNYP+tpWVH7NoH8x3bMAke9rWH++VIzfKhkGRjvXPO260eittUjWcDGtdGAOQAxgKH2ZsFXZqfO5je+M/Bx/mF1Dt7sjarSlNUNbvFOAT5EH9cLlfY7MCLjSnnFO2QD+If/AKKnzmPyVcj/AFgHvC6+21CClBA6ZWD1BT/svVlLUYxFXxGFx/7Rm7fmCR8F2A07ZKVgx9lc97RbRJJp+oqIm5qKF7auP+4cn/hyomnBU0gy3Pcuc3+AxVPG3nxZz5qRZ6rurpLD9mojErfeNj+GFIuoZX0jZ4/Wa9oe0+RGQqKaR1PDTVjcl1LIOIeLDsR/rwVgarOfoStVUOMdTTv6HMZ+O/6fipLDzUSqImpOJhyMB7SPmnoJRI1rvFOCiIT6rIW90ZIvuPIHuO4/AqyJwq+q+qrQ77MjfxH/AJ/gkdslGhUDu8sq4x7cMneN/hcMn8eL5JpsxCnFohvEDj7FREY8eJb6w/AuUGrgNJUOYeQ5E9R0SN10TJW4AcPJPR1JaQQSD4gqbFdpWDDsPHnzVODhGHkJcKHKv23hhHrNcPdunBdYvvY+CzvelAyHxQjK0LrrH99NuurByJVD3h8UMk9SjCTKtpbrxeOFGfXOdy2UIZc4NaC5xOAAMklXcemxQtbLfKn9mRkcTaVreOqkHkz7IPi8j4pyTUqBT9/W1DIII3zzvOGxxtJc4+QU2sip7E8srHNrK4behwuyyM+D3Dmf3W/EhHValMcBoLPTfs2nl9R3A7jqajye/bb91oDfIqFHEy1PDeFs9wOwjBy2L+I+KXzSgKQynklmjqrjiWf+wpRs2MeQ5D/XMq4pKeWpnY1oM1RIcBrf9clAt1JLPMAOKoqpSATjcnoAOg8lt2UjdPxmiheHXN7A6qqBygaeTW+Z/wA/BRPfhWYoi7XomY6QUDHU0DhJUu9Weccmn7jfd1/1i9s9rjjjDngNp4R15eJJTFntREbJOHh4xiNh6N6k+9aKkoBcquOhbkU0WJKg/e8GfHmfL3qo5y0WRqXYbaaqT9ozNI4xiBh+yzx95/JZvXV3ku96gslCBL3DgXtB2dL0B8mjc+ZHgthq6/xaVsc1US0S44Ymnq7x9wWR7PbBI0GuqgXVdTmR7nc2tJzj3nmf8kM0HOfcnya4ib71uNKWFtvoKe20+XDPHNKRvI883H/XQLo9HTNp4msaMADAVVp22imp++c3Dn8h4BXrBjlzUe+pUmQNAnGjGycnngoaOaqqZmU9NCwySzSODWsaBkkk8gE3PUU9uo562tnjpaSBhklnlcGsY0DJJJ5BeeO0XXVR2nzinYJaTSkLg6Gkdlj65wO0ko5hmd2s+Lt8AOa3Kic7C+w5f5pLpEyZAkOk6qwSsINTrpU2ZUy6RNOl3TCU8NUh0vmkOm+KjOlTTpfNMJTwxSXTJp0yivqAOqYkqvNMypAxSnz7Jh9RtzUKSrx1USWs803KeGqdJU46qJLV7c1Xy1vPdQ5a3J5oynhqsZazzUOWt57qulrPNQ5azzSZUgap89YDndQJ6wDO6gzVvmoM1bnqmcykDVPmq89VFfWY6qulq89VElq8dUmU8NVlNW+aramsz1USWr81DkqM53SJwanpJ8uTtFU/023DOQ2thf8A8bVWmTJSJKgwN74e1ERIPeDn9EhUrQum9q9d3Vkqohzc0H5LxXqlpp9UXNh2zI14z5savYfaQ4VrpI27tkh2+LdvzXlLtGo/+l4ahowZoAc+JBx+RCyHHmqnO9yvUw5acNWcdITG3fkplj1BUaduBqaf12vAbPAThsrR+Thk4P6FVfGeRSqeAzunx9mJzvkrY1Kc7GNV1ikulNeaRtVSP44ncwfaaeoI6FKc8rkdi1FUWCs76L1o3bSRE7PH8/NdLtl+or1AJKeUecZ2c0qZupVF4LfJTpA13CT7TeTgcEe4jcKnr6SaIF9M0Tt6xkhrvh0Pu2Vm5w5ZTcgIKscqgDysJcq1sdPeakkxvp6R2GSDhc1zvVbt/rmuJ3F2KSb+FeidTWmgvVC6GviD2AYa8HDm+4hcWvmlImTzQU1V31O4YBe3Dm+/x94+QW5arJX3iTs6GIvI3xsPMrSpaGpuLuSnYXFc1kkLs5OU0yZ0LwQcEeC2r9CwOH9eS/7o5LO3rSlXagZG/WRjmR0XTV/Bd7tsJnmhy0b4IOPPCs1fDtxoo+1fH6o3xrhXFn1C2piMFTwu4hwkO5OCvNAz0Nmr7rpC4uMWkNUMDBKRxC2V7RmGcD7hPqO5bEZIDVzBsjmHbYrpGlqb/ots0+JMjIyM7Klwzw9JxBXeitdytAy49wTLNb33apEIOANSe4f3VDH2fVzZpIp3RtMby0lrsg42yD1/8lq7fZzS2SGgkk43QPc6ORvNud/zyfinbeBrqOqtVqrY6PUkbw6jpqiVscVxYdjG17iGtlB5BxAOefhS22k1Ppu7xw6hst0tdNI8QPfXUUsTWPJw31nNAOXAAeTs8l37jwTTT+gPifJg4L89e/TC6dsnDtNP6OI3O1wXZ/8ACt4zJE7DjiVvXo4fyU6Gr42eBGxHgm7jDxQO34Xs3Dgq+nqCX7jhlA3GdiPEeS43i7h2Dh26MijcTC8Bw7wM4IVC92uK3VbWA5Y7B8cJ1lLS2Onle1oawvLw37uTkgeWSVUv1PKZHZjdJAd8xkB7fPzUnUtPUXO1TR05IqGjjjA5Ej7PuIyPiqGz26suEDJTFJFkfbGD8V19fxDV3IR2/hdjmwsAHqjBJ7yQr9Zc6mrLKSzBzY2joMEnxWltN3bWPLGVDKhv3SOGRvvaUzqKI0oFRGeHJ3Hik0+n445o5ZXN7xu4I2I+Ssr22R9ukMTI5XgZDZORXbC33O48LVNNeW5kYC5pOCdBn+y6BlLXVNlmiuAy9oJb36DKh6W7QLvpOrbU2qvlopAcua05Y/8Aiadj8U3eu0KO7a/mvVyoaakpb1CyjvDqbLYpHgcMVSWn2XNyGuOcEHOARk5yarpm7VlFUUDv95H6zFDq4WVEbxHKyqgcMbbZB8Qvl5owV5AXnGnRW1ytD7Pcqy01OfVd6j/vA7hw/A+9V1jL6LUUDzs9p7qUDq3of19xKt6OqOqtKcDyXXywx4dn26ijzs7zLMgH5n2lHooBdXxSx7VkOHA/7xvUe/qPitmyyupbnTyjcPb9QtCidy1MUrNw4fVXOtIuKiieObXYWEmi9byK3+qXtdbG8ewfjGfHwWFkGV6L+JMbWXwyN/M1p+30wtrjOMNuhePzNC2OhZf6HNH4ODguZ9pFp7jUNW5rccR4x8Vv9Ez8NW+Mn2mqs7T7eHVkE+PbZgn3LoK8/wAS4Ggn3MLsH4kfcLRrR6bwtFJ1idj6j7hc20xepLDd4qlhIaDuPELt90ij1VpZ3dEOMjGyD3gH+ZXCK6lMbyQF0nsevrp4LhRSnLadkcjc9Gl3D+Zb81lcEXaLL7LXHMM2QM9HY+/1WZwrcGNe+1VX+HLn3HC1togdbdLkPPAeAn3Fc0qZDLPLxc3HIXUtXztprFOPZ4hgHwK5CZiTn7XRXPxGDaR9Jb4zpGz+32V7jINgfT0bNmNSaCH0O+U1Q3bfBXW9S2FmqbH3RdwvewFrvArlsbg6Rjs8iCuqwSvl0y10ZxIxuxWj+HUsVRR1lBO3maRnHeMYKtcHujlp6qkmGWkZwuM1vZjeKaoLBEHtJ9Ut3JC2WguzWW11Ta6vy17N2tc3kfFVMHapc7a+SCRjJixxbxP6bqHdO1W610TmRy9xnbLBhUaObhG2zCsbzue05DSNj8srMpp+GqGQVLedzm7NI2K0HaxqiF0DbfBIHHOXFp5LkrJjHKCOYOQU7W1r6qR0kjy955uKhk53Xn9+vMt8rnVkgxnQDuA2XH3a5yXardVPGM7DuHRdH0v2pVFogZBUjvoWjAPULQVHbNTiMuhpMOx9s/yXFu9IKV35xzWzR8aXqjgFPHN6o2yASPeVoU/FF2pYhDHLoNsgEj3rf3bWNVq2kmL8RyU54+Bm3FGds/A/g4eCp6q+11RS9y+slMeMBocQMLP224m318U5HFGDwyM+8w7OHyVtW0vo8742u4mjdrvvNO4PxGFy1Tc62pldNLK4udvqdVlPrqmqLppZCXHQ679yqbddJrHeIa6PL3MOHs/3jPtN+P54WwgrY7DdRTMfx2urYKqif0Ebubf7p6c8ELG1cGHk+Ks6KV1y05PRc6y2ONZSnqYyfrWf+JZb9w5V4znMZ33H3HvW9Lw8Fp5FR4I+IPYebSqrTV2FdStjc7Lmt4mk9W/5K5J4ZA4cjsVCdNFOANCFVQ3STROr7Zf2cXcxv7qqa37cR2Pv2zjzAXpHtUuzJeyiiu8ThI6xXSjuUTmnOeGTDSPLEh+S8+XmhbcbbLG4Zy0hbfs6vz9Vdht9s9Q4vqrfBLTOaTuQ1pfEfhjH91VnjZ3cteifq6LvGR5jf9V7GpXNOC08TTyPiFbU7tgsZoKuNx0fY6tx4nT0UMhPmWAla6ndkKsdFqhudVaQuUthyFAhcpcbk3KC1Od0HdMp6GINSGOTrHJ2UzkUhrkoOTAcnGuSJpangUrmEyHJwHZPUZanAchKBwmwcpYOU9QkJaA2KSDhKQoyEtBEOSr7rf6GzQukqqmKEDo9wBUkcb5nBkbSSegUYY55DWjJVk1By5tW9udgopXN77vQP92OJSrL2y2K9TNjExgc7Zol2JXSP4ZvMcXbOpX8vfhaL7TXtZ2hhdjyW+SJNgiinZMwOa4OB6g5VFrTU8OmLLNWSHdoPCOpKwqenlqpm08Qy5xwB4rMijfNIImDJOi7dpW+2vRekoJ7hVw03e/WEPkDTvy5nwwqir+lXoa21PdzXNmxwRH65+QXjOlZqLty1H3ReXU8fRvqtY3ptyXVqH6KNA6lDZKl4qCN3udkA+4L15/C1hsgbHe6o9qRktYNvr9F0tRZLRbiG3Sc9oejei2Paf2uWXX+q6WS1VgkpY6JjGtds7iL3udt7hGqFlQC0ELztrDTFVoPUVbBTzOdHTTuiEo2yWuLT+IK6H2e63/bVIYKg4njw337LD4g4QipaMXa0y9rTnfvb5q/U2WKmpG1NC/ni+YTPa7f7raoqY0VZJTRucWvEZxlbLsIu777pTFVI6eeGZzXPecnB5LHdrNL6XYXyjcsId8k39HK9ClrrjQvdhrw2UDz5LfipYK7gV0sbAJInjJAGTr1O+zvkrM0TKjhx0jGjmY7fGu/916Cq+6oqSWZwHCxpd8l477Qb87Ump6yqDi+Nri1h8Gr0V2zatZZdIzMY8iaccDSDuFwbTGmv2hYbjWys4nOaQM+PPIWlwBFDaKSW9VX5iGN951TeFmx2+nfcp+pDR7zqt39G67mM3KhLvtNlA8Oi9BcXEAR1XkzsTuhtutGRnZs8bmH3jkvUMVWZIWnPTC5P8R6X0a/PeNpA13ywfmFkcWUxjur3DZwB+WPspzpGt5lNumBOyhum8T80Xery7K5MMUsyZQ4s7KO1+UviRlHKnEEgHKGXJcpuErPNJd+aCDW95PG0eOUJMKyA2AQ4UojCJPVbKLBHJGggmkJ4KCSRhKQSKQIgcoiMIEYRg9E1PCSgj5FEhOCIjKLOyVnKSeaE8FBJcEpJO3uQpQUSSeaUknmmKZpSXBJIylpJGEKYOSEkjCWRhJIykwpQ5IckEYTiSQkwpA5NkZSCE6RhJIKRO5k0eSSQnCEktQjmTLhkJBanS1JLdk7CaXJpwSCE64ZSHBKmFyZI2TbgnvtBNuCcAoHOTDwo0nslS38lEmPNOwq5Kr6lVFaraoOxVRV+sUqiWD7W9Vf7EdmeobwyTu6iKmMVO7qJZCGMI9znA+4Fcz7I9N/7NdnlmpXM4JpIvSZR14pPWwfMAhvwT/0nar/AGgu2idCxEn9o1vptW1p3ELMtGfIgyn3xrXcAaAAAABjAThoEm7lQa7s5vOi7pTtbxSNiMrAPFu/6LzJ2f1H7M166nJxHWxFo/iHrD8j817BhaHgtcMtcMEeS8gdoFsl0TrqYsaQaCrErPNhOR+BClj9bLe9VpfULX9xXpWkdx0cJ/dAUS40DKqORj2gskaWuHiCN0uy1MdZb4pYncUb2h7HDq0jIUzgDjuos6K5jJXm+1yGhpHUE2SaeWSmJPi0nH4fkkUzGGeSnkGYpQWEe9XzbA666y1fbWHgkbJ6TEfB+xHz4lnHl3NzSyRpLXNPNrhzCsrJcC3dT7FM8UM9DKcz0bu7OerebT8lNopeFxjPwUAyiO4UVe3Zs49GnH732T89viFKmYYZduYP4KQFQ7K1zlQ7m3MDXjmx357fyTscvG0HxQnb3sEjPFpx70iFX1gdLZW1TBxSUcrZMeOD/I/grGpt7bxTtMDh34HFHnbjb4KJYZWPqJKSbeGqYYz7yNv5fFNW+tbQNNJWcTTC4t7xm5aQcH8UzUHClHKW+tsfqFWyMkp5XRysdHI32mvGCEQOVs4q8VrGtbUUdfj2WVUTZCP1HxSu5rmHIsllk8MRP/LiCkyqpiA2KxPEnYIJap4ZDE+V55NY0krbtrLhA3/1ZpuhP+8lia0j/E5QK3VVfC0xz6pbEzpFa4w35PYB+JS6pnLjqoEGiL3MzvHUD6WLrJVubA0DxPGQlutNltrv6feW1zxzp7Q3vAf/AIrsNHw4lV1V2p6uXjZT1dzn5d7WvMj/AJb5TLaO5VpyKeKlj+9I7p5AfqjHeUnkFayar9AY9topIrPHjBnDu8qCOuZSMj+6GqlpI6q7ySOg2jBzLWTnEbfEknmU7+z6Cldx1Uz7nMOUfsRA+4c0dXcJq3gYcNjbtHDGOFjfcP1RkDZJyk+0nfSIreHQ24ulnf6rqyQYe7+EfZH4pyiphDiNnrSu9p2N1HYG0zOJ27jtsOZ8AujaI03Haqd95ugEZiaZA1/KMAcz5/8Ako3v5W5VmGIyOx0Cl2y3DSFtjqZGNkvVX6lNA7cRbbuPuG5+XVSrLae+c7vXOkjaTJNK/nK877+/8tlHoxPeqyW51DC2SbDYoz/ZR/ZZ7zzPmfJainp2wxR07PZHrOPiVTJI33Wo1oO2wSuPuY3TFvE92GxsHUnYN+JWpsFtFuog17g6V2XyP+848z7unuAVNa6X0utErhmKDZnm88z8Bt8Sm+0fUhsGn208G9dXO7iFrTvj7R+Rx8QmAcxwFMSGAuPRZS9Vh1xrARt9e20RBHg852+ZGfcB4rqmlbN3hbxD1B6zz+ixOg9NupqeKLAfM88T3Dq48/gOXuC7DbqZlHTtjb8T4lSOOdBsFVjy0Fx3KsG4AAGw6Jx89PQUk1XVzR01JAwySzSuDWMaBkkk8gAmXTQ0tNNVVMzKelhYZJZpXBrGNAySSdgAOq4DrztBm7SqlsUAfT6VgeHQQOBa6ucDkSyDmGA7sYeeznb4DUa3KUux5pzX+vp+0mrbHG19NpineH09K8FrqxwO00oP2c7tYf4jvgNzVVVsp4nySPDGNGS5x2ATddXxUMBlnfwNzgdS4nkAOpPguudk3ZBK6opr/qin4JWkSUdplGe58JJh1f4N5N6+t7MpIaMlNa0vOBuvqCZU0+XHvTLpfNR3zphKzw1SXTb80w6fwUV9QPFMPqfNMypA1TH1CjyVOOqhy1eAd1CmrPNMyngKfLV46qFNW+ar5q3zUKasz1SJ4arCat57qJLWc91XyVfmoktXjO6TKkDVPlrPNRJazzVfLWKFNWc901ShqsZq3zUGat57qvmrPNQ5aonqhPAU6Ws81FlqvNQn1Hmo7589UmE7ClyVXmo0lRnbKjPmTD5fNLhJhPvmyUy6XPmmnP5pBfuhLhPd4Sie7MbmncEYKrLnd4LXTPmneGsaPHmuZ3jtmHfujoad7wDjLsbro7Rw3c74T6FEXAbnYD3lbFDa6u4E+jsyB16L0rdp/S7PZari4u8o2scfF7PVd+IXAO0mlibUUveHhihqnRSOA9ljuvyVdQfSBukFBT0VZRt9Ggkc9nD7WHcxk+ah6x1pDqNr3wNY6Goa3iafaY4DH6BUb1wdebA70msi/ln8wIIHnjZa9RZqyig5pW6d41Cz15tctruMlNMMPYcZHJ46OHkQmrfcaagnkNS4tjkjdGSBnGRt+KuYydUWNtGCP2xRN/ornH+vj/3Z8/D/AM1ndSW6NtFT11LxOp5faa72o3/aa74gp3D9BT3K6U9POSI3uAON9Vk26NlTVspan8xwcfIqhfMHDAHil2+4zWyTjgdwu4cHPXwKhSvLcYS6SN9TbHz83RSjPu/0V7Xc4eC+FKs0ctG+WVuNzkajI3IHyXbVpsVnmNPJA57hjfbX34+S2OndXV1Vdo2Vc5dEQRwgYCwundd3q8akvFwkulT6JJI4QU3HiONgPq4byzjCnOkdSSPe3ZwacfELE6TPd0EmOZdj8Fg/iPbaWknpqiijDI5GaBowPl4ELJ4no4IZ4Zqdgax7egwP3ghb+TV1xuUTqeaYSRjPrkYPluP1UC26gszKww1dUIJQcfWjDM/xfzwodv8AXonO5F2c+9YCseZKyUu58Ryty8VEnDPDFHTUJ5XTjmc4bnQH7hXblM+02inhpTymTUkb9/3XYrro+nvVP6RQVYpp9y2eJwLH+RA2+PP8lnW09XAX0VzhDZQMB43ZIPFpXM2VMtLI50EskB+8x5afmFZ2W+1r7hC2ermnYCMCV5cB7slcjwjxPWUNxZFO8uiecOBORr1XO2O7z0lY1sjy5jtCDrumtSaaqKe4PdSwvkjc7k0Zwl0kepX0bKeGkqDE0YAGFqNXzPpKEVMQDnMIOPELNy9rNzhY2OOkp2hoxjfCTi+Cbhu9TR0DixsgzocaHceWQi+U38KuUjIHlgeM6aaHp8UzHoO81DSKiBsDXb/WSD9Cuv6a7RNb2/R1ZpK9XpuoNOVcJgdSV4MskTendyn1wBgeqSQMeqAuOt7UbnM5zqiOM/d4AcD81Gk7R7o92WhjB02yrdjk4Vp4Iqm5B759yOgOdO7PvKkt0vD9LGyWpDnSdR0/fvXV4KcVomgZIfSY2B7WO/tBy2PUhUlRCIXgPJjaXepJ/u3fyKY0dqV17p3PceCeN2MtWhrIIb1R1FRAGulgwyrp8btzydjwOD/oK/8AiBQG4QxcQ0s3PC/DQMY5e4fqt2/QtrIo7pC/mY7QDbHgolGx3d5lbwvGxxy+HksvrHUtZZqiBsQa2llyOMt5OHMfLce4+C1VG3FII+IuIGAXc/JU17srL7bZ6GYGOR27JOfC4cnDy/Qlbl3dVWHhuiFkBDJAC9zR6xJAOpCuXH0ihtUAt+gePWI32WUZeamdzXumc5p3C3lK70yzNzuSwgrnWl9N3N9Q6mqoTC2Nxa4k/PHkeYK6dSNjjh7mNwPBsQOi0/w7o7i/t56/m5JByjmzknrjPgl4TpqsmWSqJ5XjA5s5PllYAV1RTlzGynDSRh24+RTLy2R3H3bGO6mMcOfgNlKvVG+muMzQMtLiQq48QG+QvnyvpX0VVJTPGC0kfAry6ohdTzPhdu0kI6a4VdhvFLdKLDp6d2Qx3sysIw+N37rgSD8+YWtpLRBJc4bha3O/ZdS0VELH+3ASfWif5tORnqMFY9zs4B3C0do1XS2qnggqI5GQceJZoxnumnbix1APMDpyyum4VbavThNdpC1jPWGOpBGBsVrWQ0LKntK5/K1uo8SOim6/LmWCSQML4WOHelvNg8fdy93NYSiqvSGmN7uKVgzxffb4/wA/8wtyy7T2a/uprkGTU1QwYLcPjnhd7L29HAg/iQsnrPRsuk5xX28mayvdxRvB4jSk/ZcerDnY/A9CU4rvrL/dH1DBhmAG+QSX6uF1q3VUY9Uae4Kdp2qFLco3uIa3O5PgrPXVVR11HEI5mSSsdyaeiytJUtq2CRmx+03wTskQeMhPo+JpqOzzWfswWSHOTnI22+Cr094lgt8luDAWvOcnptt8Fm66i42nZTuynEGtJqCQljbjRzwNPg8N7xn/ABxsHxU6O3vqJO7Y3LjyC0OndBOprrTXGfMUkDg9gxyI6pnDtnrbtWRtp2Et5hl3QDPeobTa6mvqo+xaSARk9B71N7R6kx6fYw7d4R8+a5bBP3o8xsV0PtWMsPocZB7meLvo3Dk4cRBwfeCCuXd56PUh/wBh2zvLzW7x7Wsrb3IGHIYA34b/ADWnxZUtqLo/lOQ0AfDdWsUvrlp5HcLq+kZ/TLC5hOTwrj73YIPRa7TWsTZKR0ZjDydt03gi8U9ouJkqncsbmkFM4ZuMNtrS+oOGEEFYTWFKaLUFWzkC/IVE55IWk1jVm6XJ1VwBoeOg5eSzhbsuUuDopKyV0BywuJHkSuUrOzNTI6LVpJI8spnBKJ2ycIwkKiqRSCUBknklADO4yE/F3GfWyPehImBG49Fe0s/pNth4j9ZD9Uf4ebf1HwTVPFC8ergp9kYZMQ0Ya9pBA8eYP5qNxyFNGOU+ah1TMqPRVj7VcIKtgyYnZLfvN5OHxGVMmbsVAmalGowU4ktIc3cKXGTZbrPDTnLI3Cen32dG4ZA+RwtpR1zK2mZKw5a8ZGenksDLKZbdS1P9pSSdw/zjO7fluFdaerhBVOpyfq5vWZ5O6j481G5uRlTscA7A2P3WwjmBjcDywrT6PZZPcNWM37qXuxjOxy2QFZueoEFLPIeTWF3yC1PYBALfpi43OX1RJK9xd+41o3+fEqsmjHe5a9EOarYO4E/LH3XqnshkJ7NtMgncW+Af8AW/pn7BYPs5p3W/RVgpnjD4qCBrh5iNuVtqV2cKm7ddE1ugVvC7ZS43KvhdlSo5B4piUtU1rk616isfnkoN31NbrAwOrquOmB5cZ5qaGCWoeIoWlzjsAMn4BDYnSO5WDJ8Fetdulg4K5pX9t1hpMiF01S4fcZgfNZ2u7fZ38QobX7jK7P5LtqTgjiCswW0paO92G/UgrVjslfNtGR56fVdxDslKBXA9MdsF6u2qaGnq3RR0ksnA5jGY/FdybUgxcZO2MrOvvDtbw7MyCtxzPGRg564+Ko19umt72smxkjOicr7pTWyB01TM2GNoyXOK59eO3Oz0EjmU8npODjLGkhc87UNZ1d/vzrZTSvZAx/dlrTsSrrTPZVSspmSVrWzyuGcYOy7ym4btFloIq7iB7i+QZaxvd4rWFuoqCnZUXEnLtmhXVD9IOgmnDJqWSGPrITn5ALpen9S0WoqNs9HKJGHmBzHvXHNW9l9GbfJNSMMczBkY5Y9yzPZNqOawaoioXPIhml4HDpnkrs/Dtjvtrmr7FzMfEMlpOdBr+/olkt1vuVI+ot+WuZuCvRmob1HY7VUVchw2NpI9/ReY7hc7r2lX8xl+WOf6rHbBoXorVNnbqWxz0L3Oa2UYJbzCyek+zej0zUvmi4i4jdzjlYnC17t1hoZ6gtzVnRmRkAd/77llWq5Uttp5JcZmOjdNlm7b2PULKcd+C+Qjc5zhYnXmiXaRmjqKd7jE5wAPIgrutdrLT9mjcKi4QNePs8eTn4Ljfabrim1VLFSUGHwg7uwdyuy4SuXE1dc2y1PMYDnm5h6uPDP2WxYqq81Fa183MYzvkaYXTOxTU81302Y6hxklhkLeI+HRZz6Ql1eG0VHn1X5kGPkVfdklg/Ydm9oGSbDnAeOFmO3ykc70WfBwx2M+8LItBopOOC6Afy+Z2PPHT3qjQPp38RkxexzHHnj9V0f6LNDTQ2J8hA72V+eLG4C9P2+2xlrcgLx99Hq7FtkdHE/EkEvTnvuvT2m9axd22Op9V3Li6LhuLzKL7VCXfmPw6fJcfxDE910nL9+b5dPkvLHaTZ2V141IxzRvcKkj4TPXHdOVr7JqOMZ4QJQ0j4r0Pr+nDdVX9nSSrmlBHg9xePwcF5yrQH6lcGczL+K7/wDDuU1dJXW6bWMtz5H9hehcMO7Wnmp3+yW5XYtSxiusVQw7gsP5LmnZdcDbNXQgnAka6MjzXTI3Ca1gO9os5fBcXnlfZdQSSR7PhlLgpuAY/wCIWy42fOrm6eeCPrhP4fZ6VSVVD/UNPp9cLX9qeoJL/fYaGN3GyP1QBycugWKyto9MMpg3+z8FyvRdE6/6mNS8FzWu4yfA9F3qnp8U3DjmMLO40qG2qCjscB/wgHO/zH9lZPED20cdPbY/yAE+a88WeY2LXEDieHuqrB9xP+a9VW6cyUw3z1XlnXtM626sne0YJIkB816N0dX+m2allByHxNOfgrX4isFXR265t/OzB+AP3KtcUDtoaWsH5m4PyP6rQ8TnuAAyfBYLXfb9oLs1q30V6vrH3JhxJQ0THTyxnwfwjDD5OIKzXbhrDV0sn+ymjIn2+eWIOrr453AYWu5RxHmHEc3AZGRjB3HnaX6LNZLTNxcXy1TjkiOmLmnPTnn4rwcu1wFzVLQscwSzuwDsOvv7l6Qsf0xeyu8VLYH3WstJccB1wo3BvzZxge8kBdgtt1oL7b4bha62nuVBMMx1VJK2SN48nNJBXzov/wBHa62NxZVd9T/dkkpiGn45Ujsiumuuy3Urv9m55KvLx6VZpM9zVNxzAzjOOThgj5goX8u5V51rZI3mhPzyF9FuNKEmVQaZ1ANSWGhufos9EamMPdT1LC2SN3VpHkfmriKUO2zupWnIyuakjLHFpGoUnI5nZP2+Pjc6XpyCggmeZsTOvNXccQhja0cgFM3VUpTyjHeglEZRDcpSeVUCQgjIwjIyEieElBBBMUgKCTyKUknmkKkCB3GUSMc0SROCI7FD2kCNkSE5BBBERlCeCkkYREZSs42RITwUkjCJKO3uSUmFIHJKSRhLcknkkwpQ5IIykkJwjCScIwn8ybLfJJIwnCMpJGEidzJstTZCeIwkEYQl5k0W7pBGE6Qku5pcJC5Mkb7JBCdcMlNuGCnAKMuTRCbeMp8jZNPS4UJco0nVQ5zspcuygzcilUZKgVJwCqt44pFY1TljO0rVzNBaCvl+cWiSkpnGEO5OmPqxt+Ly0fFCB3lcHtlT/t99IbVl/J7yhsTBa6R3QOBLXEH3tmPueF0pwyVhuw7TL9OdndE+cONbcSa+dz93HjA4c/3A3PnlbvG6c7TRIzbJ6o4zghcP+krpoGa33ljPUmYaWYgfaG7T8sj4LuDRuqXtC01/tdou5W5rQ6cx97B/3jd2/PGPika7BykkbztIXL+xK/G56UjpJXZqaB5p3ePDzYflt8F0Yc15x7M9QHTOroe9JjpLhimlzsGP+wT8cj4r0U1/E0OT3jDkU7udg7xosDp+jjb206jY9u01DHIPlGFm+07Sb7RcpLhC3NNKR33COR6P/Q/BbCZgt3bFRTnZlxtckDT0L43hxH+HC113t8N1pHwysEjSC0tPUHmE/OMFQuYHczfFeb4+KWmmp+LHGMtPg4bg/PHyVy54rKSGoaMF7fWb4HqPnlNam07LpK7mnfxPpZMuglP2m+B8xyKK2SAOlg6P+sZ7/tD8j81KCs8gg4Kdgk4djyKkCRRZWcByORSmSZHmnJir3kwTu4SWlrstI6KZfmCodBcGABlU31wPsyNwHD5YPzUWuGKgnxAKm2nFfTTWx5GZsPgJ5NlHL/EMt+Kae9OZ1b3/AFVIY2nzHgUkQRD7AHuCWQWuIcC1wOCCMEFBIokqNsLP7EH3lPtqWN5QsBUYOwgXE8kboU03SUDDeFnuCjzVcs3tvc7yJ2+SYJKcip3y74wPEp2yTJOiS3ikdhoyVIcY6GEySHwGcZLj0AHXyCE8sVujZlrpJZHBkUMbeKSV55NaBzJXQdE6BnpKiK5XZjH3ZwzBSg8UdG09SRs5+ObvgPFRueGjJU0ULpXYb7/BI0ToiZ08dbcY+CqxxRwHcUzfE9C8/h8ytFqST065Udip/VhYBU1OOXCD6jT7yMkeQ8VqY4YrdSvcXYa0F8kjuuBuSsjpNr66Kru8rSJrhKXtB5tjGzB8h+Krgk+u5aRa1gEbNlfUVO1hHCMMjGB7/wDX5qXESW5aMvecNH4BNuHAxsQOC7bP5n/XirSz0olmMpHqx7N95/kPzUJKnGitaClFLAyMb8I3J6nqVy5tYdc6ynuzTx2+ncaS3gcnNaSHyj+I5A8gtH2n36SjtsFkoZe7uV24o+NvOCAf1snkcHhHm7yU/s207FCxkrYgymp2iOJg5bD9FMwYGe9VJnczgwdFudN2oW+naXDErgM/ujwWhdPDSU0tTUzR01LC0vlmlcGsY0DJJJ2AVNcLzQ6doH11xqG01Mzqd3PPRrRzJPgFxfWuua3XU4jka6ks0TuKKgB9sjk+Uj2j1DeQ8zunBuUxzgFL7Qtfy9os4o6YPp9KwPDmQvBa+4PB2kkHMRg7tYeZw53QDN1VZ3Doo2RyVNVO8RwUsDeKWZ55Na0cyjt9NXXu5MtlopTXXJ44uDOI4W/fld9lv4nkASu49nfZpRaIc6unlFzv8zOGWve3Ajb/ALuJv2Gfi7mTyAc5zWBOiidIcj4qF2W9j/7CqIb9qQR1N+xxQUoPFDQA9G9HSeL+nJu25621+VAjkLsKbENlSc4vOStNrAwcrV7HknA6qLLU+aiS1WOqhzVfmpiViBqmSVOOqiy1fPdQZavzUKas803KeGqdNWqFNWHxUCar57qHNV+aRPDVNlq/NRJavnuoMtb57KFLXAfaQpQ1WEtXud1Elq/NV0tewEAvAJ2GTzTD6oEc03ClwpktXnO6hS1OeqqL3qGms1I+oqJGsY0dTjK41f8Attq6upfFbKQ8AOA7izn5LqLLw1cr8SaRnqjdxOAPeVr0FpqriT2DdBuToF3GSpB+0mXzLzyO1bUdJK11Q0Ni58HDgn4romi+0in1MwRyAQ1QAyzoT5LWu3BN1tFP6VIA+MblpzjzV6tsFZRRds4Bze8HOFtK66QUELpqiRsUbdy53JZ+l7QbPcTL6NWNkEY3dyCRrAemWSpZnPq5XneATtrX0kLyzvH8JHxWvwlwnRcQ0c8s0pY9hHdjHUnTKuWSzQXSCR73lrm/DC6fqLtkcKl8FupnP4TjjLtj8lnmdrd6hlHesa2PmW8O5+JWm0/ouloqVnEwySkZcXb7qRedHUlbTvb3LWOxs5o3ytuC88I0UooxRc7Ni86k+OCrcdysdO/sBT8zduY/VW2kNf02pI+B2IqgDJYVqnzADOV5tDqnSd8wHFr43DPmF3aiu7bjaRMCMOZv8lgcZ8MwWmWKroDmnm1HXG2nz0VG/WqOieyemOYpNvBct7S9SS3e8fs+JxEMbuEtHUq80xoynpaRj5Wd5M4ZOd8Ln0tV3epXy1HstmPF7lvP/SfQUUYbEx0rgMbN2Xo1/td2gttHabJGeTly4t6nxPzXT3SjrmUsFDbmnlxlxHU+a1EGhKG/SPoHwtjkqGFscmNw8bj8j81xSqpprLcpaWUFpjeWkHyOP0W0l7Wq908ctFSEPY4OaTvgg5HJZu80931BcH3CoozG6cl4IbgFP4btFzt9PUUfEEjRTyN2c8Eg46aq5ZqKrpYZILi4cjhsTkhJ4uNgIzk9QnqepDaKopJTmObx6O6H/P3eCYpo3NhDXjDhsQm6xhbC4r5woR6Be2MiOQ2QAEf5sArheTsqpvKdnfdVDKd8zi1jS5wycDn5q/0HSxTVElPM0PhfPHlp8CcKFp2F9RcPU3kaOMD72OYV+Kdtsr462n/qJiA4D7Luh+f5r038Umhl8bJ1LG5+a0uLGg3DxLQqnXFrbar/ADwNGI8Dh92FzK0j0VtbHy7uV2fwXau1Nrampoq5nszR9PmuM3FvodVcenGeL5gLo+JwLlwhb67cs9U/T/4qxcT6XYKSp6t0P0+ytNPT+kUT253BWPvsBpbjUNI9Xi2KsLNdP2dUgOPqPwCrq+WZl5g72EjvOeR1VnsP9MOFoYaY5qKf8vUjUfMY+CmMf8es0bIdZYunh/4wueyOyFIsjDNdIABkcQypEmmK/veF0R+G60unNNC1E1NS4B+Ng7bC4Th3hS51VyiEkJYxjgXEjAABz1XN2yy1k9WwPjLWtIJJ0xhPa2lEFl4SefqlYrTNsprpX9zUEDOcZVnrO9CvqRDGcxs69CszBM+mlEkbuFzeRWxxVe6OfiRtRyCSKPDSOhxurF7uUEt4E3LzxswMd+N1qNUaFdEyOSgZxgDdgHNZNmnq+SXg7h2fcVsKDX8sMYZUR8YHXqVIl7RomNJhpQwn73+S1Kyi4OucvpkdSYQd2cv07lZqYOHa1/pDZjHnduPop+j7F/s9QyS1DwHP3IO2FkLvrSstGrv2rapRHLEOBzXDLJW9WvHVp8PcRggEMX3WtbdGmMuayI9GjCykr8rG4l4ioqigistqaRAzXJ3JWZeLzTy00dut7SIma5O5K7tZr9Q6roHXG0Du5oxmrtrnZkgPi37zM8nD4gHYOMu1O9wadnHkFwu13arslwiraKd9NVRnLJGHf3HxHiDsV0+16motax8TWMobyBmWmbtHP4uj8D4t/wDNY1n40utip/RoSHR9A4Zx5Jls4lraOPsGkEdx1+CtdQXaeG2VElBF3lRGMlgOHOb1x54WEsms6oh72TZe/cucM5W0ppi4lr8tlZzzsVgtbaddZ6l14oGEUr3cVVCwf1bvvgfdPXw58uVOs4wu1yqGyyTFpb7PL6oGfJRV93uFU9s5kI5e7THjorWe6T1ri+WQvceqQyU49ZUtur2zMa4Oy09cq2DuIZC5ieWSeQyyuLnHck5JXPukfK4veck9SnXNDugPwSC0ActkQkwjL89VCo8ZU+31sEtALVcnPFv4i+mqGDMlE88y3xYerfiN1dWu+T2GZtmvrGGGdp9HqW+vBUsPVh5EHO481lTurW2XdsNI+319My52mU5fSTcmn7zDza7zCjcA4YKex5adFC1RoiexSG42UOnt59Z0DDxOh/h+83y5hVduu9PWjHEGv6jof9eC39rsVZHGXaVuTbpTYybPc3iOoj8mP5O+PzWW1JZrdV1pFdSz6eujt+GoZ3fEfEH2XDzBT2O5vVOv194SPYPabp4dPcUdLL6NK2Ro3armp1RLNEWMzGSMcQWONuu9oHqFtdAOrTvj3fySob/FxcFRG+B45gjOP1XR0F7uNrhfT0cpY12+FfpbnV0cboYHlgdvhbu1Ww660HdbBI4y3my8d1thPtTU5OKiEe48LwOZLnY6ri88WHOY4ZHJdGsGq5NN3y33q2zsNbQSiaNhdw94MEOYfJzS5p96e7adF0lovVNfLI3i05fI/TKIgY7vPtwkdCxxxjoMdQVhOe5zi55ySs9zedvNnVcypHluYX7keyfEJxkpik7t3LoUHw8YHQjkfAoYNQ3gd6srfxUuVSwhUwipjLHdeR8FQ1MDonlpGCFoIXl4LXDD2pitpRO3weORT2nCa4ZWddsCVHfIeisZqZzCQ4YIUV8A32UyrEFRuJxTkUDpSANynGQ74AVlS04jbnqUhOEBuUdLStgbk7u6lSRJ18E1K/AwPiktcScBRnVTjRLnI4CSq+QBwIUwUtTXPDaenkl/gYSo1bR1NBP3dTC6F/PhcMFTCGQM7TlPL340+KlMby3n5Tjv6Jm1Rmomr6Pn38BLR++3cfqm6adz4GOYeGRmC0+BG4VppOyVd11NTejROe0E8bgPZBBGfxXU7b2U2aysdJXVZJc4u4XYGPJdRZuGbheg6WBoEY/M44H91u2yxVl0j7SIANaSMk4C51e7o12mpZ2nh75oaB4E8x+a7HZLG+zdndm09F9VX3juqANPNr5t5Xe5jTI7P7qjQ6V0rcWR00TYpQx/eDiOeW/VbjTluEuvae9V0wfHR0zoKGBvKN7/AOslP7xaA33Eq5deBbnRU3pMRbKxup5DnC62Lhypo2PnDg/IA9U5wOq7lSPZTRtDRwxsAaAOgVVW9qFvtsr4mxTTSMOCAMbp6nn7yLbfIXMNTRdxepjjZxDkzgKw26/VssFwBPK3IAOM69eq27NRQVkzo586DIWzqO2KukyKSga3PJzySVXv1zqu5vAZMYWk8om42Wn0/p6hno4JmwB3EwHJ36LU0Vljh4eCJjfc1a8vEnD1se6KitbS5uRl+u3nlD7pQ05LYKUZHfr+qsdJ1tRNZKY1RJnDcOLuZ81iO3CHvKGinA9l5YfILo1JD3bQFj+1qj9J0xOQN4yH/JclwtXBnEtPU45Q5+w2HNp8srPts3LcI5cYy76rnmgtLUt/ie+Ynia7GAF0OHQdupoTin4nAc3LG9jM4Nxq4Cfsh4H4Ltop2mLYLqOPbrcqS9y0zZ3BmhABxoQD0Vq/T1TK58YkIbpgLzRdIv2Hq13B6jYp2vbjwyvS9tnFbQMcDtJHn5hcA7V6D0TUfeYwJGfkuydnNw9P0vQSk5d3YB+C1+Oc19jtl0Gpxyk+OB92lW75mehparrjB+H9iq49nVshuL618YMhPEXvPVSbnr+y6db3bqmKWVoxwNdkqm7YNZS2amZRUjyyaX2nNO4Cyehuz6O/MFdcuKXjOQ0OwT71lUlqZVW5l64kqHdlsxo1cfLOwWcyjZJTivukh5NmjqVaXntgNfHJHS0jnNcMZ4P5rmUFa+nv8VW4GNwmEhHhuvQ1Hoq3UcYEVFG3HUjJXFu022i36h9VoaHt5AYGy7ngq7WepqpLdbqYxh7Tkk5Jwtqw1tDNO6lpoi0OB1J3Xpq0yCsooZRye0O+YUqalYYnNIyHAgrK9m919O0jb5s5d3QBHmFlNX9tE9hvMlCaYAMwTtuR8V4nS8PV1fXzUNG3Loyc642OF53FbKiqqX08Ay5pPyKzdd2MVEtyqJHyhsb5HObk9CVEuXY7LS07pqepLpWDPCBgLs1m1Bbb/RR1EVRGeIDILgCDhQ9T6htdjt8kskzS4NOGjfK7CPi7ij0ltMCeYEDl5d/ArUF8vfbCJpORpjC4p2bawrrBqGOknkc+B5LXMeeq632m2L/aTS0vdjilDQ9n5rhdgglvusY5KZhLTNx8uQz/AJr1BTUnFRMjxkBuN1ucdyR2q7UlfTANmwHOA7wev0WjxO9tDXQVUIAkwCQPA9V517M9WO0VqB0FTlkMkgbJnpjqvT1qv9HX0rJ4qiMxvGQeLmuNa87J23Sd9VQ4iqCSS3kHFYWDTOrrQ90VKZgzlx8Xqj3Ka5U1l40DbhFUtgnwA8O6qSrjtvEOKpkwikx6wcutdruo6K24qWTsdPLGWFrTvkcj8c/guE6do5Lveu/c08PFxE+a09L2aX/UEwdcKzh557wly1ll0ey00zomRBksZLZRjOD/AC6g9QQVUdW2vg+2TUlvm7aolGC4bNHmnirorLSPpqWTtJXaEjYKtv8Afo9PWCuuU39VTROfjxPQfE4HxXEaDUk+oIH19e6GOZ7zks9VuOnMrtmuNLHUWm66194YfSGAB+M8JDg4fiAuXUHY5OA2KsqGOi24hC3Gcb+P6Lz3hXiR/DVY+pEfOHNIxnH2Kq2WvjtpdK4ZOMLpfYyKOqtz6mmnjqHcZa/u3ZLD4EdPj712WFjXQjAC4jY7AdPSQS2sCjkiYGN4G7PYOTXj7Q/0F1bTmoo7pE2GZopqwD1oich3m09R+Kw7pc5btWyVk27znHd4Lnbi59XO+q35vkszq3szptSXVtVLNJGGjBYwc1stK2hlkt9PSRFxihbwtLzkqxMIedxlPwsDduSmqbvXVlLHRzykxs9kdAqUtZUzxMgkeSxuw7kctHFUS95JGxzvvOAKmU7GQew0N9yQ0gpxoysbCqF5IwnZBHUMLJo2ysOxa8ZBUCl0vZqGrNVS2ulp6gjBljiaCrFkeSnu5J5IwDukErmAgHdQqnhijJOyrYHTVM4bACXHwVu60S1b/rHcLPJW1FQRUUfDG0DxPUpvIXHuCd27I295SLZbhSR5eeKV3Mqa7fZDPJADdWQMBZbnFx5iixhBKRFqEmUSIckaCaQnApJHNElpJ2KYVICiRHkjIQSKQFIQQQSYT8oJJGEpE7kkTwUSCCCEqIjKSlpJG6E4FEkkYSkXEhPBSURx0RoiMITgUk5SUrARHCE/KQQEkhLIykkIS8yQRlIcE4RhJIwjCXmTZCQeSccEg80uE3mTZGU2QnSE25Owmlybf1TL08/qmJClwo8qNMq+odsVOmdsVXVLuaakVfUbnC88fSSrjq/VOkezqncTHVzftK5cBxinZxBoPvxJz6tZ4r0DXVcNDSz1VTKyGnhY6SSV5w1jQMkk9AAF5i7JpZde6s1X2jVbHNbc5zR25sgwWU0eB+PCwH95jvFObvnuQ/UBvf8ATqumOa1jQ1rQ1rRgADAASQ3CccMlEBhRqdJTsR4Sk4yjAwU3KMLzB20aKGn9X1YYzgobkDVQFuwa4n12j3O39xC2/ZdrQ6lsvcVTh+0qLEVQOrvuye4j8cre9qejP9tNKSwwMDrjSnv6U9S4c2f3ht78eC8w0Nzq9MXSnvVA1zpIRw1FPy76P7TSPEdPMK03+Y3HULPcTTy8/Q7/AL8F3LXNJIaSju1NGZKy0ziqaxntSR4xKwe9pPxAWloq2Kvo4amnkbNTzMEkcjTs5pGQVTWK+0mpLRT3CilEtPM3IPVp6tPgQqZ4rtDzy1FDTPr7DK4yTUMIzLSuO5fEPtNJ3LOYJyPBMBz6pVp+PbGxV/qjTNNqe1yUk44SfWjlA3jf0cP9brh1XQVdjr5KOqYI6umdkfdcOjh5ELvdmvtBqCiZV2+pjqoHcnMPI+BHMHyO6rdYaSptU0Y4iIa2IEwzgbj90+ITmu5TgqCSMSDIXJi5tRG2RvsvHLwKiHMbyDzCeno6mxV76KtjMRdu0/ZJ8QeoKOoj7xu3tD8VYys8gjQqFW+s1jvgozXFpBBII3yFIeeJjmqMlTVOvDRXRtuLB6zyG1LR0k+97nc/fnxCqxE88mkqfR1RpXklokjeOCSN3J7fD/PoQCm6mE0jmuieZKd/sOPP3HzH+aaEO11TDaWU/Zx5kpxtGftP+ACNtUD9nJ8ihLU91GXvc2Jo5kpyYnWQMZybk+JSYpai5V4t1ppjcLgRksacMiH3pHcmj/y5kK+0/wBnN31QWzVbpbRbHb8ThiolH7rT7A8zv5LrWntKUGnKAUdvpm0sHNwbu558XOO5PmVXdIG7alW46dz9XaD5rLaJ7OorBL6dUyC43pzeF1U4YjgB5tib0HTPM78s4W8pqUQNIbzPNx5lSI4AwYAwPBOhmSFWOScu3WkC1jeVgwFlu0GofBpianiOKiueyjj97zg/hxKXQUTKSnhhjGI4mBjR5AYCr9XkVWqtO0HNsZlrXt8OFvAw/N/4K2flsXC3Zzjw+7zUhHqgKu05eShAw1Exc0Z4jwMHl4/68FoRJT2m3vlnkbFTU8bpJZX7AADLnH8SodtpRC0Oxg4w0eAWK7Sb2LtWM05C7NLDwz3F3R3WOH47OcPANH2k1reY4T3ydm3mKqLI6q1lqSa8TRujnuDhHTRP5wUzfYafAnd7vN3kuqXTV1r0LbmUrcVVYxuGUzDg58Xnp+a5VBqKS1tk9CdwVEg4TUfaaOob4Z8VUFz6ioYxrZaipndhkUbS+SVx6ADclWS3Pks5r9PEqzvuoa7Ute6rr5u8c3IYwbMib4NHT8z1VtovQ1z1yRJTk2+zg4kuT25L8c2wtPtHpxH1R+8RharRnY0D3dbqgNk+0y1Mdlg/75w9s/uj1fEuXV2uDWtYxoYxoDWtaMBoHIAdFA+YDRqvw0xPrSfBQtNabtmkLaKG10/cRE8UkjjxSTO6ue47uP5chgbK5jOSFGYcqRFsqmcnVagAAwFPg2CnxO2VbE7kpsbtgnJpXp6Ws81Clq/NQparHVQpqvHXCkJWUGqbNV+ahTVnmoM1X5qHJVb80ilDVIuF1ZSQulkdhrRkrkl7+kXZKKWSKmgqap7CWkcPAMj3rd3mo7ykmHi0ryTfaVtFq6oie36sVGSPIlercB2C232SdteCSwZABxnv8e7qu04ctlJcHyNqQSWjIAOF0m5fSJutX6tBa44x0c8lx+XJZ2s7R9a3ni4al1O09IGcK39r0hbRFG+OmDgQCC5XAs0MMZDIWMGOjVePE/D1vPLQWxpI6v1Pzypf41bKbSmoxkdXa/XK4TQalutPqWjmrK2okkimbxB8hxz8PivTMFwE0LXh2QRleaO0CjdQ6kkcNuIBwPmu16YuvpenqOYHOYgfw/yWj+IUcdZb7fdIWBoeCCBoBkA4+qu8TNbPTUtZG0AOGNPcf1XOu2DVEtyuzbbE9whjxlrTs4q40Zo+noqCKV8fHM8BxK51qed0OramR/rNZNke7K1rO1eGigbHT0z5CBgHkuju1muhsdFbbKw8rm8zyDjJIB1Pv/eFp19vrXW6npLe31SMuI0+K2lz03T1tI+J8TMOGM43XH5WTaT1K0xuLRHLtjqMq9q+0e93PIgpeAdDglUdRarzfJ+9nj9c+OyfwtaK2wiWO8TsEMgILS4E570tloJ7XztrpWiNw1Bdldspbg29WQPG/eMPzXDqxn7P1M7piTK61omkqKCzthqPaByFzXX9L6FqEvAwC7muf4FMMF4rbdE7LHh2O4gf2Wbw4WMr6ilYctcDhdotAbNRxSc+JoOVNmpw5p26Kg0RWel2KlcTnDeErSuPqheJV0BpaqWA/lcR8CuAmi7KV8Z6EhcX7Vra2CvjqAMF7cfJX3Z/XOqLJ3TjnIwPeoHbBMw+jRA4kaSfeE72YwOdaZA4Yy7Z3kvaq4mXgOnlm9prhjyyQF3lTl/DUTn7g6fFYTVVKaS/VDXDAc7iwtrY9H2+op45msD8tB33TfaDp19Y306FmZWDhe0eKpdIa1dYnmCqBdDnnjdq6Soqa/iThyCazSkSxDD2g4JwAP7hasstVd7VE+3yEPYMOAOp2XRqPTFLEBwwN28ltGW2jm0DUyvEUdTa5A7JG7o3cv1/whYVvaRaY4OPvAD0DuZWO1Brqu1PU+gUHFFBMBG7gJHEM9f5ryKHg++X6UMrS6KNpy57ug67rl6C0XCpnDqjLWjcuStQhtTdqieMMDX4dhgwOSzd2lEURb48lprppmr0tMaGsDmzsAJDvAjI/MLD3Iu9Lka47A7JeBeG6S5cQOZHPzxU55s49sA4+q27dboqq4kMfljPW807Za51sr46lpwYznHiOoWluF/oXGdrMvglBc0cuEnmPgf9bLItpnEZOylUVvjne5jie8IywDkT4fJeh8SP4QuFxfWV9Y57tBysBIGOmcY+afdZLHPVOqaicuO2Gg9P33qVddQuudsp6SRuTC4kP8QszV2yKre5zgCSACtHPbo4yHMbljh1WNtT5RqK+wvLiyGWNrcnYZZnC2uHuIuH68x8PUlM7sjkjnxvvtkq3bLra53MtcMJ5CT7WN9/FZW+QimqiwDA6Ju26lqbdK+MO42DGAemytNYU/BKHjxWPe7hqn/DdeMXCWq4evM7aN5YWuOMaabrzusdNbLhJ6O4tIJ2Wwfr17G4EDQfEqmumrKy4NLO84GHoBhVUrHObkKNlSVnGN7rojDNUHlPdp9MIqb5c6pnZyzHHhp9EbySSeeeqQW5GyMt6oLjCSTkrBDU2QU1KFKG/NIfHlJkppaFWyjJUdzMKxlj5qK9iUKIhREljjG9r2Ocx7TlrmnBB8QU49qbIwpAo10DTWtGXR0dLdJRBXezFXHZsng2T/7b/R1Eri4yRSMDZGjD43bgg/mD4rixGRgrZ6Y1KyuhjtV0qjTObtRXM7mncfsvzzYdhvy+RbXkiG7VdhqSPVcqm/2R+k6p1XStdJZ5Dl8Y3NMfH+H8lLoq1ssbXNcHscMhwPMK4/bUtPVVVvu9OKetpjiYMHEwtPJ4/dOefmPFZ+u07JbXmrspbNSP9Z9EHbDzjPT+E7eHgpWPyOV/xTHsx68eo6jqFbhwcEDt5qpobpHUAgEteDhzHjhc0+BB5LQWm2TXf+p3wrtNRVFbKIKZhc47AKSnhkq3iKFuXHoFGDkoSAIVlNJR1DoXj1mnCv8AT1iirKSWaoDhjdvmFqWyxVl0rTQRNw8ZznTGN8q9RW2orqk0rBhwznPTHequlrnQOH2mg5G+48wtfR6zrZqQU9S6C70XWmuMQlHzO/zysHW8MVTII3eoDsjhqnRuBDi0+IXPzwdnI6MnOCR8FnlxicWnoVuW0elqwg+i19ieefoM4liz4lj+XuGFEq9GQVrQKW80Fe3oKmN1M8fPI+RVFDdSRh+D5hS2VTXjY581Bhw2KcHNO4UG4aAu1OOJlH38f/ZOa/5YK1/Z49t40/XaA1A2SiZUP9Js1RVRlohqgDxRgno4dP4uZcFSR1bmbseR7ipcV6q4xjv3OHg71h+KcXuIwUrOVjuZqw930zNba2elqInQ1ELyx7DzBHNUs9te05HMciOYXU7vdX32cT1rWS1HCGmYt9ZwGwyeu3VRn6a7+IyiFobjOSVp0NFWXBxbSRF5AycDOB4qaKhmq3EU7C7G+Fy18eXAvHC8cnDkUC7i2OxW1qbNSuJBjzjzUyyaCpKt/fStd3Y+yTzV+02yqvNUKOlblx37gOpKSjtdRcJxBCMn6LnEtC+pGGxFx8VAqLRPESTE9rfEg4XdZZLLYsMZTR8Q8BlKguFovY7p8cZPRpGF6Yzgii5/RnXBnbf09M92dF1Y4Upi7sHVje17vHzXBIaLhOStbpHQx1Q2R5qhCyPHq4yVea40bDaIzWU0fFGTgtzySOye4Zus0WRiRh2HIY3WPa7AKPiGO13ePLScbkA52II8VmUNmbS3iOguLMg+Oh7isXq6wHTd7lomvdK0AEOcMEgqspYH1czIIhl8hwF0rtYsU9Vd6WogjDuOPhcScbgpvs50O9lcK2rw4M9lvDt71FVcPF/E0lopxhvNp4NOvyBTZ7I6S9vt8DcN5vg3f6LW2qlg0XpcPc0NeGZOeefBcPvlVUXq6yVD+I8btuLwXYNf3GJ8XdSyNip2e295w35rK2bQVbqh7Kksda7UdxPI36+Zv/ZsPsg/ecOuwKv8cXeKSeOz0f8AgwaadXf2WtxJUComZbaX/Di0x3la3s2sEVnsTapzAZ5Bknh3B8FgO0u9XT9qxvcJmUsru6ja71Wh2eRJ8l22npI6SgbBEC1jW4AJyfiVz3tQsxuOiLk4NzNTgVDT1HCcn/h4lucaVD7TbaC20p5Y3NycaZOm/wAcrX4lidS2yCjgcWtDcnHXCytPoi40ElJXXCtDGtmYHwU7ieFjjg5dt1xnA+K7db5u8p2OG2BtjwWKtLm37S1JJISRVUjS8jnlzBn8VotI1rqy2MMmBMzMUo8HtOD+Iz7iuP4KvtRQXeOFzsxyHlcOmvVV+HH/AMPqGtjOWyYz45XXdJ3Q1dKGuOXMwFSa6p+CtjkHJwITei5zHWSMzs4K21zB3lFHLjdpC66hgZYOOzTx6Mft/wAQ/VdNE0UV65G7H7j9VsuzaqFVp+lyclmWfJbyFgwuUdkVbmmqYDzY8OA966xA7LQvLOL6T0G+1cI25yR5O9b7rm7nD2NbKzxJ+OqlMAAWb1zEJ7FUh3ItIK0YOyy+vq+Kk0/Vd44Nc9uG+9Y9ma99xgbGMnmb9VVgBM7A3fI+q5V2Vymm1Q0feBYQvQkZzEF567MI3T6lDsbYJz4FehKX+rC9G/E/H8cB68jc/NbPEePTvHAXH+2yg/6tUgcnYJ96u+xO499p6SAnJhlI+B3UntdoPStOzPAyY/X+SyPYhXd3cq2lJwHtDwPNbsX/AKnwC9u5gdn5j7OKsN/1mwOHWM/f+6HbhRyi80tSATG+LBPgQVoOyzWNvNvZS1UzIZYmgEvOMrXaq01BqK3Ohmbk4Ia7wXILh2U3OlqSaVzXMB2cTjCW1XGzX+wx2a5zdi+L2XdPD5aYUVNU0NwoG0NY/kczYrsd87RLNZqJ7/SBK7GwYM5XnzVF2qtSV01yewiAuwCBsFq7X2UV1ZM01tUeDO4AJ/NdEZ2fUElqZQvpw6HIJwMEkKa33Lh3gyQOo3mokccOd/S3rjbVRQ19rsLwYCZXnc9w8PFVfYZfBLZHUDn/AFkUji0Hng7q07Q+zuHU5NSz6uqwBxeOFoNLaPoLCc0dIyFx5uA3K1L6USMwQvPa/iDlvUl1tJdHzHOuOu+2mCuPqrof4g+uocsyc6/NeaB2ealtUxFJIcD7bXcIUum7ML3d5Qa+udw9ckuXoJ1paeiVHamtIyF0D/xGuzm5a1gf/UGjK0X8WXEjQNDu/GqxWi9AUunGt7tokk6yObuuiUsPCwBFDTNj5BSAMBeb1lbUXCZ1RUvLnHclclNNLUyGWd3M49VFqaISZyFXvtDSeSvQcouEeCpgkKryhU8Vra1/JJuFibUt72HhZVNGMu9l4+679D0+YNxwgdEaTOU9hLDkLCTUUL5XQyxGGYbmJ4wfePEeY2Ud1jpxuGALdVlFT18YZURNlaDkcQ3B8QeirX6bbn6mqkYPuyDj/HmmYV9tQ0jXRZN9nhwRjCjGxgPa5pwWnII5grYf7OzA+tO0+5n+aehskcLsuJkPmjlynekcuxUC2OqO6DZAXgcnEbqyYCeinU9K0nHLyUltM0dFJhVHSAlQY4ieQypsFKT0wnmMwRgYUhjRjCMKFz0UdO0c9082IDkAltbslgZShVy4ogMI0eNkZ5J6jyiPIIcKMDCCcmoIIEZReykwnIEIkoHKIjCROBRIiMo0E0hPBSQcIkojKSm4UgKJ3JJS0kjCangokEEEJ4SeSCNyJNTsoIiNkR2KHEhORJJGEpBCekIIIISgpJGEkjCWSiQlBSEk80s80kjKXCXKQSkkZS+aSdkqTKQQkOHilk5KSR4pwTcpojCQ4YTjhgJDkqblMO2UeU4Uh52USZ2yEiiVDsZVXUOzt1U2qk3VTWVMdNDLNK9scbGlznvOA1o3JJ6BNKkaMlcN+lVrGpptNW/RlocHXrU0wpQ0HdlPkB5OOQcS1u/2S/wVhpyw0+ldO2+z0gxT0cLYmkjBcRzcfMnJPmSucaCqZO1rtUv3aJUtcbZSk26yseMYjA3eAdweFxPvleOi6w85KHaANQz1iZPcPIfqUgjCUGowEaYpiUlBGQiTEgKNjsFcG7aNCfsK6uvlHHi21z/r2tG0Mx6+TXfnnxC7wkVtBTXWhnoqyFtRSzsMckTxkOaeicx/I7KR7BI3lK8hWDUtV2bXR1ZE11TYqh2aylbziP8AvGfr/wCWO9WS9W+/RRuo6gPdJGJhDICyTgPJ3C7B4TnY4wfFcv7QtAVOgq/gkDqmzVDi2mrHDI3/ALOTwd58nD4gZ+wapl0XGyjrqU3bTDXmRsRbxTW9x5viPPHPkQRzB55tuaJBzN3Wcx5hJY7b6f2XY7r2f0lZWPr6Gaey3R27quhIaZPKRhBa8e8Z25qJ6Zqqw+rcLdHfqVv/ALVayGTAeLoXnc/wuPuUq0XqSqt0VbZ7qy6UEo4oxVfWbfdbIMOB8S/jI8FZM1U6Jv8AS7XOwjdz6V7Zo2/PhefgxRhx2KsEDdpx5LJV1803q2N1vqpmQ1X/ANSVrTT1DD0w14Bz7lk7npa4WVxMJdcKQciNpmDzH2veN/JdMu1+0xfKUwXSlfUwD7FdbJgAfEccfPzCyc9j05Cc2LVFRZiPZppZe/gHujl3HwcFK0gKu9pdvr5LAyFrzxsOcnceBUdzcFX1/inYDJVNoK7iPDHXW6Xgcf4mOJz7slVD7dXNt8deaWV9DIXcFSxuWkAkZIG7RtzOycqpB2TA5Jxkha1zfaY72mnkf80yyRr25Y4OB6g5CnWmkhuFbHBUVbKGF3tTvaTjyA8fft+SEgOUu22yqvFYyjoYTUVD9+EbBo+849B5/AZOAuraU7NKKxPjqqsivuLdxI8fVxH9xvj+8d/dyVtpWy0Fjt7YqBodHJhzp8hzpT94u6/kOmAtA1pVd7idArkbA3U7pLIAN+Z8U8IwEprcBOAeSiVjJKbDUB7SWRhE4CNpc4hrQMlxOAB4oSZWBfMLj2lXdw3Fvo4KT4vLpD+HCtRR0/eScbh6rdmjx8Vz7S18pIKK63+4VUdJBca+WoZJO4NPd+yxu/M4bsEu5drLpo+60/ROkHIV1YwsjHm1mznfHA96nLC44CrtkYxvM476raav1bFpO2cbAya5T5ZS07j7TvvO8Gt5k/DmQuTU7nticDI6aSR7pZp3+1LI45c8+8/IYHRQaWprtRXaVtIyq1Jd34EjosEM8A5+zIm5ztt7l0vTHY335ZU6qqWVXUWmjJbTjw7x+zpOm2zduTgn+rCPWKg/mVLvVGnyWX0rp246zqCy0RNfTMdwy3KfPo0Z6hpG8jh91uw6lq7no7Q9r0XGX0wdVXGRuJrhOAZXj7o6Mb+63wGcndTaXu6eCKCCNkMEbQ1kUbQ1rAOQAGwHkpsRyqckpfpsFrQ07YddypgeXJxm5TLOifaoVaT0fNPsOFHYnWuwhPUuN2FLifsFXsdghSonpyaV3iar81Amq/NRZqvzUKSo809UgFKlqsqM+fPVRnzEpp8qE/CFbJxMcM7ELzT2o0foup3vGwkbn5L0ZPJxBcR7Z6PFRT1AHUtJXq34a1fo99bGTo8EfcfRdhwrN2Vya3+oEfddG0PXC4aeoJs5Lohn8loJQODkuc9j9x77TwiJ3heW/Douhufli4riGk9Bu1TTdGvdjyzkfJYFxg9HrJou5x+ui4r2xUXBXU84GAct/VaLsurfStMsiJ3jcWY8k12u0XfWnvQN2OBVN2P1m9bTE9Q8D8F6tN/6nwC127oHj64+jl1sn+t8NA9Y3ff+6znaJRGkv7nEYEjchavSFgt9wt0EzY2mQtBcMdVa9oWlzeaMTRNzPE08I8VzzTupavSVa5kjHGPOHMPT3Lcpp6jirhmOC3TctRDoW5xzAafTHvV+J8t7tDIqSTEse4zjI/8AC67Bp6CIYbC0fBO1FNBboHTS4YxgydlnI+1u2+j8RYWux7J3KyGpNbVurZW0lK3hhJ9kDBK8+oOC73X1GK9pjjHtOcdh1wuZpuHa+pl/1kFrRuSei63ba2lr4eKmlbIOuDyXNe1mi4KiOYDnhazQVjNitnC8kySes4Hoq/tQo++tQkA3blN4dlprVxVGykk54ublDj1BRa3w0d5Y2B2WZxnvWY0Pr9ljh9GqmuMIJIc0ZIWyre1K2RU5Mbg5+NmkrnmirfTXWSWnnYH5btnotMOzai4uL13e87LteJafhSG7yi4MeyTc8uzs9fDxW/dm2WKueKprmu302Kxt4udVrC78YjJycNa3kAus6StItduihxuBvlRrNpSkt2DFTsDvvY3WopoO6AGN1wvFXFMN1hit1vj7Onj2HUrnLxeGV7GUtKzliZsO9RbjSN9sjLHeq739D+ny8FjbxoKkrZHPazu3nqOS6JJG2Rha4ZBGCPFRGQZLo37ub1PUdD/rwXEUF0rLXJ2tHIWHwKwqepnpH89O8tPguYR9mtOx3rSPePPZaay6QorcQWQN4+rjzWp9Ebn/ACTjImsO4WtX8VXi5RmKpqHFp6ZwD7hhW6i7XCrbyTTEju2+iVr+0/7UaNpbywh9wtgFNWD7Toyfq5D+RPUk+C873yLuq0+YXp2xXGK31bmVLRJQVLDBVRnk6N2xPvHPx5jquPdoGin2DUNRRzDjaw8UUo5SMO7XD4KjwVfY+Erw6pmBMbmkYHj09x+S3LJcm0EgmcMgAgrF0kfeQMIHRGWmF4ez22Hib71Yto+4ZgDAUSoZwLAr6mOprJZoRhjnEgdwJzhc5UFkkr5GDAJJCmzyMm4HNH1creNv6j5/msRLROpKvVtY3cskoHkeALJGfoFoaSqLD3LjtGeNvu6hMtpxVz6upx63f2VlUzHV0ExJ/wCGRWbfWTUNQ2op3cr27FQRyyU8jZYjhw2K5xfah1bTvLhjAysZM7FW/wDhH6rcVcQfTEjfib+iw1SCyvcD90fmrdVVzV0zqiodzPduVHUyyTydrKcuPVS2SBzAVHkaA7bqlRbbJTm5CpqFR0lOObhNoTEE40B2xOD4ptGDgoTUU8BbzGFCliVvFKC3heA5p6FJntwkaXREEeBTgonBZ97Uw5vNWVTSvhJDmke8KG+PClCrnRR8BGlFqCVIrZ9ZPX0NJUxyAXG3ERNkd9uE5w13iAcj3IU93j78upw6jqcZmpT7J/eb0I9yiWviE8keDwvjI+OQQhWUsc4aHghzTlr27OafEFJyjYp/M5uoVjW1lNcWA1NLiYDAnhdwuHl7vIlSNP3yexVYfFJ38XVj9is7DXFk5pqkgPPsScmv/kVsbboKtuVGKkSxxxlpcMnJXQWOluctWH2phdIzXTotW3RVs84koGkyN106LRP1lZqkB88JE3UkYHzUG7a4ElMYKOIMj+8DusVJxxPfG/7JwUVFRGsqoo4sxuc7Hq8vlyXTz8ZXatBp2crXP0Ja0AnOm+61ZeI7nUgwtw0u0JAAJU70p0zz6pLvIJxkw5ciur2m0U9FRRs7lhfw+s7hGcrkN4LKK9VdPxhr2SH1Cd/kVHxJwdNw/Sw1UknMZDgjGMHGd869fglvPD8lmp4ppH83PodNjjPvU6OfzUiGcd40ElozvhU8dRxdU6JS0rztuhBXKNfg5XSqWx0c9u72HifI5mQSeRWZqKqShqHxP2LTjcKboq+d3IaaU+q7Aapusba5g9LibnJw4L2i72mhvfD0V1tcQY+LR7WjHmT9fJek1tJTXO0sr6Fga5mjgPn+vkqeK4MfI0c91tp3+j2gu6Bn4LntBUM9KiD2gDiA3XRK6hlq6EQQujYeXFKcNAScBEUlsudafysx8j+/cncLu7KjrKgdG4+RWJY7vpw0bZOy11bMLZZS4YZhuMnoVVv0jNDWRmKtbNG3dzmwlu/lk/jhXt0tLLzQmklHE1+M+9L+H3qW651MX+KG6fAlS8MNcykrJWe2G6fArj1y1BB37g15nlPJkY4j+CboG3qvqI3QQmljaQ7ifzx7v812O0dkkYwYoQwfusWnl0PbtMW99fc54aOkiHE+ed4Yxvvcdl4r6Y5snO32s5z4rzlsEjj2jnY8Vz+OKtutvbTVEYmHXIGEqz6bbaqtkrQG4PstGyhV3bLSXe5mz6FsVZqy4dHQxmOBg+8SRnAPMkNb+8rO39l3aDe3xV+qL7S2SmaQ/wDZVpZxOHi10mfyc8Lq479cKu409ZXSZMZGO/AK247lPU1cU7yZCwjXp8VZ3O2xXBjBKcBpzlKipRBRvjpiA/hPC48sqc2Ed8I3DiAOPWT1VRPiGQ3ZfR15vlosN2jlqIPXnaMyDoNv02XsFdXUVvrWvkj9aQau8Nli7P2f0sdwFyu07rzcQ7ij78fUwn9yPln94+AIAWtkOQTzPikfgUHO2wea8S4q4Tmoj/E6F3a07teYakZ7/wBVx9dZPQ2mopTzRu1z+veks9ZpCp7vQCrtldTO9maJ7D8WkKz4jG/ONkc0QnYQOZGF1zoWcccPwR0zh6VTjHKTuNPqB8Vrujbfbe2OM/zY9Md6552YzGp0BaXu5hj2H+7I4D8AtDYYpaO/VQAJpqpgkOOTZG4B+Y4f8KGkdJu09p2mtznh5iL/AFvJz3O/VXREdrp3uAy4AkDnnyWNw7wZX0txbX3NvZQxHmJJ3wqtptFRCY5ascjWanPgtfpBmap7uWBsVqtR0/pFllGNw04WM0BdIrhFDPEcx1DeNu3I45HzH6Lo8tN6TSOj5cQxlcveOIGVfE38TiPqNcMeTf3lVqqtE1f6U3YEY8gsp2W1no99kizgSx8vcu4UjuJjfcuUaZ0SLZc46s1DnPYThoGy6lQ+w1Jx5cqC73Y1lvfzNLRnQjUadcdMJl4qYKur7WnOQQM+amyOIaQDgriOt7VebrqOeNjaianOC3nwhduI4goktEJHZKxOHeIJeHah1TDG17iMDm6eKq0dc+gkMkbQSRjVYrs/0gbG3vJMmZ/PI5Lp1O3DOHyUGjoxGdgrGNvCFlXK5VF2qn1dU7L3KjNNJUyGaY5cVAvNsiuVM+GZgkjcMFp6qusmlaKzyZpaWOA8ssG60gaHFORxAOVZlXOyIwNeQw7jJwfMbKq57w3kDjjuzoibAHMwQmpLY1x5KYwBuyfAzlQZVGQAqvhtjWu5KfFStGMAJ5gACW0p+VQeAg2ENKebsEkckbeaRVylgAjkjwPBJzhHndOTClIIIITSUM4QJygghMKCCCCemosBFzKPAQ5BJhJlJRHcpXChjdGEuUuAfWJ/h9yZi2e33qURyTgglIaE8wpGMbow5Im7qUzdoS0zG7IwnhsnqI6IwMokEEoTEEEEEqblBAjKCCEuUnkjDvFByJJunZQQQQSJwKCSRhGeSSm4TwUEWehRoj4pE8FJRORonckxSgos7IIIIUgREZSUtJIwmpwRIIInckJUCMpKPJRIS5SSMIjySiRhEhLlIRE4RpJ5pQjKSSknklkZCSnBJlIROSicpBOU5JlJdzTLinHFMyOwhJlMyuUCofgKVM/ZVlXLgHdCUKFVSZOAVwH6UOtqqO0UGhbG7jv2pn9wWtO8VLnEjneAdu3PLhEnguy6l1BRaas1bdbjO2noqSJ000rvstAyfefLmV5s7L6Ws1xqS69pl7iMVTdCYbVSv39FpAcD4nHMYz6zuT0g09Y9FMR6vKNz9Oq3ultOUmj9OUFmohinpIhGHEYL3c3OPm5xJPmVY8yjJyg0KPzUuANAjQSuFGhMSEEZGESYhBBBBMT01XUNLdqGairqeOqpJm8EkMrctcFwnW/YjdNPGSs042S8WzPEaEu/pMA8GE/1gHh7XIb813tKa8t6p7Hlmyjexsg1XjG1XOq03cp5rJVeg1XH/SrZUsIje4cw+M4LXDxC6DZu2G01BZDeIpLLVnb6wF8Lj+69o/MDC7pqbRWn9Zxht6tNPWvAw2cgsmYPASNw4DyBwua3v6M9uqg79lXuopmO3NPXwtqWHyBBaQPfxK2JWP8Aa0VPsZI/YKVS3+03BodTXOjqQeXdTtd+RSLpfrbaYXSVldBA0DOHPGT7hzPwWNqfoq3wyEw1lo4PEyzN/wCEMwE/Q/RWujCDUXigpvOCF0v/ADYS/wAr+pJzTbBnzVbW1Z11WMqpZRbtO053qJncBm8cE8vf09+ytZ+1GyW0RUNqinuUjQIoaehiJGw2APUY+7laWh+jhaxIyW51tdeJW7E1EvAz4Aet/wARC3ll0JbdOx93b6KnosjDnxMAc73nmfimukj806Nkrc7Anc7n9AuPSaQ1LroiaptVDp6A+sJJsuqj5bY28nAKqu/ZtfNPROlqIpJ6ZvOaCIyADxONx8l6QioooB7PG4facn2vLVH2xGw0TzTNdq4knvXla0air7LIJLdXlm+Szmx3vb/oreWztqmjaG3C0tkPWWll4c/3XD9V1K86I07qIudX2mCSV3OaMGOQ/wB5uCfisvVdhWn5XF1PWXCmHRneMe0fNufxT+1jd7QUPYSs9kqBD20WRw9eir2Hw4Iz/wCNCXtptYH1NsrpT04u7aP+YopOwSlByy+vaPB1IHf+MI2dhtJEfrbzM9v/AGUDYz+JcjmhSclR4Ktre2aslBFHZoYT0fPUF/4Bo/NZS+ayveoGOpa26Cnp5wWGko4xHxg9MnLj7srorOynT9ER3vpdaR1mqC38I+EH4qwpLVb7OHNoaKCk4h6xhjDS73kbn4o7RjfZCPRZn6PdouT23QVfXSslgtfA8DDaq5PLeEeABy8fBoHmtdbOyqjlIfeq2a4nrTRZhg9xAPE74ux5LXl5KdiO6jdM87aKzHRxs3GfNWFrp6W1UjKWhp4aOmZ7MMDAxg9wGysonkkKrgPJWNN0VYq6BjQKxg6Kxh5Kug5hWMG4SJylsCdYeSaj5BOt5pQnp1pTgOyaBylApUJ9pUiN2wUMHKfjdshC6vJNnqo7pM9U2+TKZdJunqmE66VNukTRk+aQ5+UJUqV2y5p2t0fpFlfJjdhDs+5dHPrArO6ptJvFulpshvG0jJW/Ya4W25wVTjgNcCfLOquW+oFJVxTnZpGfJc57Gq7u6qtpieYDwPwXYmbs+C5vozQR05cfSTVOleWlpaG4BXRojgLb41rqK5XmSroH8zHAa4I1Awd8dy0L7U09ZcHz0rstOOmNcY6rM68ofTbJUMAyS09FzTsypK2kv3G6mlZC9ha5zm4A8F2upgEjcEZUKOhDH5xhMtnE8lutFRaeyDmy9SdtOg+HwUdLdn0tFLRBgIk652Tz6cTRbhZa9aOo7k4ukhHH94DcLZxswMFJkhB6ZXKUtZUUUglpnlru8HCx4pJYHB8Ti0+C5kzs0oGPzwud/EVe2rS1Jb8d1Axp8eHdas0zSeSUyAN6LWq+IbpXs7OpqHOHcSVanuFbUt5ZpXEeaj0tN3bVS61pRUWadoGcDK02A0KuulL6VSyxnk4ELKopzTVUc/8ASQfgVXgf2MjZB0IK4loWcUmoo2OOAXcJXbYYGuaDhYCg7PmUl09KL3Eh3EBnC6JSghrV3vHV2obzXR1VE7PqgO0xqF0PENbTXCqbNTnOmD5pTYQ3onNuiMnJRE4Xmq5lEeSZnY44ez228vMdR/ryTpOUWcJiEhkokYHN5FGmJQad5laCWH22jp+8P1/1lYeHAEHIIyCOqEJxP3+yN1npfu2N4rtamF8PjLB9pnvbzHyAUUFSqCtmt1XFUwO4ZY3cTSoJ4e1ZpuNlLFJ2bs9Oq49PBgqmrYsErq3aTpuKnmjvVvjxba53rMb/AGE3NzD5HmPj4Lm1dBkFZsbu9W5G9QstUgxSteOYKf01PFFrC1tqNqatc+3TH9yZpYB8X92lVkfPZU9ayUwP7h3d1DfXif8AdeN2n4EArRY7lIKouCzMlJJSxVFLNtNSyOgePAtOCsNd4e6ujdsBzSus6wjjm1C+5QMMdJe6aK4sYfsuc0CRp8w7OfeucaopCx8EuOTy0n3rQ64TXjLQVXMZsCjITjG+qETsAoUSYe3dMubzUp4ymXDCVIUwQgl4z705T0slZK2KMZc44CexjpXBjBknQBNa0vcGtGSU012PepcL3N3GS1bC2aNo6GAS1zjxcyOLZTY5LEx3AxkefvEL1Kn/AA+quza6uqGQl2zXHX4Ls4+F5uUGplbGTsCdVi8xzNw5od5FQ6izQS5LMxny3C31fpelrYTJSEB3MEdVlJoJKWV0Ugw4Lmb7wzXcPuaagBzHbOGoKw7pZqm1kdtq07EbFZ1+nqh7w2LhkyceBWvsPZ1BBCKi4vcHcyzIwFO0lQtnqjK4ZDOSe1XcpBKKeJxa0DfBXZ2C2UFstDr/AHRnaZOGM6E95W3bKGkoaA3WtZz64a39VJgtmn4H8LI4y/lxO/15Kt1HomCakfUUXtgcXDnms9KTk7krW6Nukk8bqebJ39XPgty0Xq18VTG11tGyPnB5XNGMFaVvuVFfJPQaqnazm9ktGxXHLox1PWYePWGWkFdi7M6s1WmmAjDWPLR7vLyWK7RNNSSaip2UrWtdVSFoLjhjepc7wAAJJ8AVpOzW5QzTVNNT8TaSNgbAHDBLRtkjxO7j5uKpcIRPsXFLrfKd+Zvn1CocOxvtV+dSSdcj7hYvUkjbffa2CRjmhshwRuFoOzy3Mr7gaj244x8VB7T6Axak42j+vYCPethpSjbp3SxqHkNe5pfk8/coLLYmjiqoEo/l07nOPkDlqLZbf/XZhIPUhLnHyzotHTXOOor5qZpyYwCua9odvY2/SF8bXskaHYcMjKl6GvL6vU0oe/aXiwHc/HmrftDoBK+lnx0LCQup4gr/APSThSWtA1jkz7s4+jluXWq/jlhfU9WP+WcfQrmwtLecU0sJ6AO4m/I5Tn7NuLQO5qYZP+8YW/kT+S1dvtDH0LZXR5yT6w5p2O30p2c57T4jcfkvmrtiNF5T6K0+Cy9GbzSzMk7qmfwkH1JCPzC6zZ6o3y0N9IYGSnIc0ODvyWSFpY0+rOSP4P8ANWFklfQ3qlpo5HPbIx8knEBgNGAPjlwXpHA/ETLXXejVP+DL6rgdtdiuv4bq/wCG1PZynMUmhB281p7Hpmx6RgE02b1qeq9cPdtT0EZ5cLer/Pn7utlDAamUDn44THdNMokA3xhb7sz0i+/1TpXNzE08z4r0i7Wj/Rfh24sactleOXyOP7/BdpV0LbPa6ljfZe4Y8jhQ7Lo2a4jIbwx49ohU95tT7DeO7kaeBrg4EjmF6mtGjKWgpm5HE8eI2CyXaL2cM1BSl0DAydm4I6ryzgTiCKyXBzKr/ClHK7w8VylhubKCqLZfYeMHw8VTw37Tmm9CVuqLrPHTW6hiL5n9c9GtHVxOAB1JAXkm32nVn0zNc1VxrpJrD2f2qXBaz2YhzbEwcnzuByXHIaDk7FrXazUVDS6zoptPTVhqqalmdI+Gnk4mB7fV4ttjjJwfPbmt9aNQT2DRVDpaw2n9nWqkb6oY08T3H2nuPVxJJJ811VT+HVR6Q6agmY6Fx0cSNArVVwpLUTZhkaYNxr9fJQa+1WnQtNHYtL0rLZQR+0yH2pHeL3c3O8ySei09qgkktTBISXObk8R3VJZNMVFXUNnrGubvnDt8rcw0fBGA1u2Fn8WVVvoaKnstA4PMer3jGp8+qlu09LTQRW6kweXcjvXKrnF6Lc5ByAdlaQUDaqnBA5jKsbppanqqszScRcegOFPpaNsETWNAAaMDKqcWcQUV8oaGOHPaxNw7I02Gx66hQ3a6QV8EDWZ52DB006fosTWafe0ktCrDbpw7h4CV0ualDuigvtzOLlhZFj4tuFjifTxYfG78rhkfVVaG8VVvaY48Oaeh1CxkFkfI31m4VdqCgdZrNcK7iw2lgfMcj7rSf0XSm0jWsHqhc87c679ndm91jg3qq0soYWdXukcGkf4S5c4K6YVRqYT2bic+roB5LMfVSBzp2eqfDRUWnXVVZpq11VS7imqKaOZ5Ax7TQ79VFuNPIHniyVt47RHQUdPSx/1VPE2Jn8LQAPwCy+sLnbtOW51ZcKhtPDuGg7ukP3WjmSrFZd6+vHLUTOePEkqy+pnewGplJAHUqP2cVxt98qrUXcLXk1lKPIn61o9ziHf/ABD4Lv1teJYmPHJwyvCNX2p17dYW6900fo9Jb5u8ZStxxSRnZ4cfFzSR4DPxXtvSd0hudspqmmlE1LPGyeGQcnMcOJp+IKwZY3MIJ6pKOsiqmOYz8vzB2P2WyooQCDhXVO3AVNRPyAriA7BRK1gBTozsnQ0Y5JlnJPt5ITCnYxgp5pTLOaeZzShRkp1p2CdammhOsCeFWecJ1qcZ0TbU61KqT3JwFLHRNt5pxPVNyczslDmkJQ5IUJS0EniShyTkwpQ5I0hGDhCYUZPRGkjmjJwhRocgi4kSCE3KPJQJyiQT0mUoHKHVJRgZQlTsftt96kuKisO4UknKUIR/FFkApBO6LO+E5CeY/ClRP7zIG5AycKuc8NBLjgDckq7tQht9t9OrZWU7ajaFspwXM8QOZz+iQJrgSNBkphBNzXe2yvPc1LB5OBA+GQlMeyUZY9sjfFpyE4EKFzHs9ppCUgThEQg7klUWUOJDiRIIS5QQSeJEhOylpLuaAciJympwKPiRIid0RJQnBKSclDJCSSmKQI0WchDOQiTSpQUEROEaCRSBFkIZBREYRJqegggiJwhGUCMpKPJRE4QlykkYSXJROUR5JQjKQ7kkpR5JKVGURKSThGkuTgjKSeSQ5GSkPdhKkSXuUWZ+E5K/CgVEqEJqomwCqirn577BSKqfp1XHe37tXd2eabipbYz0vU12k9EtlK0BxdIcDjIPMNyNupLR1yExk4CsMAxzO2C592y6gk7YtfQdntsmd+wLY9tXqGpicQHEHLKcEdc8/A74zGQt3FFFSwxwQRtihiaGMjYMNa0DAAA5ADosp2ZaFb2faZbSTS+lXereaq41jnFzpp3bu9Y7kDkPHc4BcVqxzKY5wJwNgpWg+07c/LwTiWDhIalKNBKUDlGkjmlJcpqCIjKNBIhJ5FElkZSSMITgiQ5oInJuE1EhxEIIJE4o+I+KIvPiiJwElCQJRckEnwRoISJBGURGEaCE9JRE4S8BJI3QhIc5MTOwE87kos7sAlCcqytduVWyHJU6rduVAcFIAnAIhuU/DzTTRgp6MYSFKpsJ5KwgPJV8PJToExCs6c8lZQHZVUDuSsoDkIQprCnGlMsOydYcoQnQUsHqmhzSweiE9Og4TrHJgHZLYUhQukOemy9Jc9J4lOqiVnPNDiwk8SHEmJiMnKZljD+icJyiJCehRxTgOzhPAcIQJygmIAwg71uaTwgIy5JQhGSiQQQhBAnCBOEknKEIcykPZxBKQQhRXUw4s4TrGcKWiPJCMYSUk80pJPNCEXJJJyjciTEIicKI+N1MS6JpdEd3RjmPNv8AL/RlFwKLIQhRmzNkaHMdxNPUJyOfB3KbmpuJxkjPdyHmcZDveOv5qK6YxuDZW904nAOctcfI/ocIQtJbqqnfDUUNc0y26rbwTMHNvg8eYO65hrHS8+m7k+kmxJGRxwTt9mVh5OH6jxWyhqzDz3CyvaFr6ZlCyzut7KpgJkgncTxQnrw+R6hXaCxVV7qhT0IBeddSANPErYt1PNWyejxjJ88LntxiDXHZUsuA7Kl1tXWSuxKzgOMgcONlXPceZOV6lQfhbWyNc6qq42BoyeXLiB47D5rqY+FJX5MkzWgb41x9EiVordMPpDg1dqrTLBnm6nn3c0eOHgnyACx+oLc+ellYW4kxxN945LWGtjhqaYTHhgkkDHv+4CcZPllVV9jkp7hUUszcSwPLHbY5dfcRg/FY93tPD9vpcUdYZpgR0Ab49/1WHXUtspoCKecvk8tFR2XSIuFFFO+owHDk0claM0zaaX+teZCPFyn6fb3dPJGPZDuIfHn+KyOoHSwXKdjnu4A7I36L0aWGx2GxUl1ZQtldJgEuJODjxyNwei6OUW6122CtbTB5foc6648fJaMR2WP1Q2Ng8SkVmlqC4Uzn04AdjIcOqxJBdvnJW10e2aOmkMuRGeXEn8PXuk4nqjbamgYGEHVo9n5aItVzhvM/oc1K0NIOoGywFdSOoq2WB2xacLWaEtrS6SocMkbBUmr5WTXuSSPkQAfeFrdDOH7LeOodlcxwhbaZvFroAeZkZeW+7b5LIsNLCL4YgctYXY92yptZXaSWrMEby2Nvgeay3ESckkq61DEW3WoB3HFke5U7osFcTxLXVFZdqh85OQ4jyAOMBcxd55aquldKdQ4jywVqNH318E4p5XcTHDbPRW+rLc17PSGjDhjksRb3mOqjcNjldHueJ7ISesf4r1Dhud1/4arLdVHmMQy0npocfBdrZ5HXOz1FHMc8gy3PkoGjG8EEzTuc5BUmv05FV1b5pZQ1rjnCq9IVY9I4CccQU7VMczSySNxDMest22VFFLwdHNUwds2E6tzjXO/uBWhRzUz+HmSzRdoIzt7/AO6P9kWilGZHh5HiUh99tFqBMUYBHUDCyk5ldnicfmqivgmqAIYW8c8rmxMZ1c5xwB8yuIHHbaY4tlFHH3HGT8VzB4pMOlFTMZ3HGSrrWWpIq6xGpjjEclU51PA87ngGO9cPeCG58C8Kp7M6v0a+Rszs/LfmpWvNOz0j4WwDittFEyljkO3Hj2n45Zc8udt4rPaZqPQ7rTvBxh4WS25XBnEEFwuTeWQlp2xpnRZbqysZd4qqsGH5adsaLpusrAbtcrXIG5a15a8joOagdo1zFBa46KM4c4YcB4LcOc10YeQCMZGVxTXF2/ad5lc05YwlrfLyXsXG0kFkoqmeE/zaoge4AA/L6r0Tid8VspZpI/bqCB7gMH9+KiaXr/Q77Sy55PHP3rux0pRazLKCrlmp+L1oqmncA+N3QjOQR4gjf8V50o5RHVMcDggruX7fEOnqeamn4KyqjNPSiM5e6UjhAaBuXZI+JC4Tg6oinsdxt87w3LcjJA1we/xwuY4ZmiktlZSSuABGRk46frhV3Zg6mvOt5tMVVEb7StdKIrjTEw93Gwn61wDscJPD15uA3yAup3DsUtUr3GmrKqm/dJa9o+Yz+Ks+xvsxh7OdNnvwyW91ga+smG7WnpEz91uTv1JJ2GAN73IJ3C8GkwXHC5OJvq+sFx89h4Lxi8uDOo9G3/51JpuxqioZnTmvqZpXNDC4Ma3ABJ25+K6v3GEzNCFEDgqblC41drV+xa40vG+RvAHBz+Z5+Xku89h1t7uxNm4f6x34rj2uA2W9xhhzhnB+K9F9lduFJpehJbwucwOI817zxNX1MnBtCyqPrvPvIGcfZdtd6mU2OmZMfWcfkNlu4IuJgC4V9LjtYl7O9KUmm7CH1OstSO9EoqemBdMxjjwF7QN+NxIYwDcuJI9krtmpdT2zQmlbnqC8zej263wmaZ+2Tjk1o6ucSGgdSQOq419FTsyuPalrWt7ftcU+KisLotM2yXdtLTjLO/4T+7lrM4zl8mDxMcvC4IwTzu2H1XnD3BrfFXn0fvoy03Y52fQ093ghrNU3ACoucpw5sbyDwwM8WsBIzk5cXO5EAXmstLU9Jb3PZAxhyOQx1Xa671yucdpVQyntbIyfXmlDG/Ik/gFfNVMG45jjzUELnlwa1xwuPi3NZjbCD4sBWM5A2Cr5XgZyd1UyTutkNwocsI32UZ8fCpE1THGPWkazzJwoMtxpmbmdmP4kqdug4JtzQVBq9VWyjzxTcRHRqymoe1CkoKeSUyRUcDec9Q8NA9yTdOxjUrUXGuZSMIJ9Y8guJdrmo6aO8aeqLjI8Wi23KOWcRML3GXgc9uw544W/41mNY/SKjiEkdjjNbUnb0upaRE3zDdi744+Kyurp6iXs60wa2Z09ZXzT108jubyXYBPwOPcFM1jgQXaZ0VOSqjcx7YzktGT3bgAfFbHVv0kYpeOPT1sc9x2FTX4DW+Yjacn4ke5cavF6uGpK51bdKuSsqXbcbzs0eDQNmjyATHdAdEOHCvNY1g9Vc/NVTVJzI7Tu6JHAMY6L1D9FLWBuelqqwzvzVWaX1M83U8hLm+/hcHjyHCF5iWw7GtXt0L2m2q4Tyd3bqsm31zicARSEAOJ6Brwx58mnxUcrO0YQN91Yt9R6LUNcfZOh8j+hXvy3S8QCvqZ3JZWge6KUsds5pwQVpaR+QFkhd044OFaxHYKQwKLCdlKYjCYSnmBPN5ppnJPNSqFxTjAnmptgTrU8Ko9yW1OAZVTdNRUNnYXVNRHH5Fwys87tc0/HJwOqxnlhu5WzTWm4Vjeengc4eAJTmUdTOOaKMkeAW6algqns+paC8xg0tQyQ4zwg7hMauuVbbrNUTUHCahrSW8QyM48FWZRzOqG0rxyuJx62mM96pCB5lELhgnTXRaDjAHNMz3KmpATNPHEP33gfmvN1TqbXF82dVzRMdzbGOELN6jt92t4ifcZppBNnHeOJH4r12i/DkSzNhqa5gefyt9Y/ZdlBwq18gilqWhx6DU/Zelbl2n6bteRNdIS4fYYeIqooe22x3K5Mo6Rs8rnnAe5vCFx7RWgItS0jah0gAyQRldK072X0FrqY5wC6Ru+QFBcbRwpZjJTTSySTNyO4A+4fdVayksVvL4ZHvfINO4Z/fiutMkDxkJSiUTeGNo8BhS14+d1wJRt5oicoIJE0oIIIJ6RBBBBCblBBBQrldYrczBw+U8m/zTSVIxpeeVo1VlEC5wABKmCnl58BXOK2+VVS45mcG9GtOAo7LxVwf1dTKz+F5CTmwthlre4ZLsLpckUjPaa4DzCOOknmxwRudk7HkFgKTWd2pHhzayR4HR54gVeN7R530kg7kNq3DhbMHbNHUgeKTnTxa3NPrHKubhV01mcWy8FbXDlFzhiP733j5clnqy4TXCpdUVMrppXc3OP4eQ8lTms4zxF2SeZznKP0oeKTJK1Y4GQjDQrIShKjqDG7ia4td4tOMKqNZgc0n00DqhOc3OhWnp9QVcGxkEo8JBn8easYNTRP2mjcw+LTkLECuHinG13mnBxCzZaKKTduPJdDhuNNU44JWnyzg/JPrnTa4eKlQXmWDHBK4Dwynh6zH20j2Ct0DlGspDqeYe1wv/AqdFqWN3tNx8UvMCqTqSVnRXqIkKsZfIX9cJwXaEjn+KMhQGNw3Cn5GUlzlCNziHNwATEt7hZ9oJMpwaVZ8SHEquG8xTOw1wKmsk490JcYTuQgDlJ4/NGDhNKeEZ5IuJGdwkpFIClZBSUEE1LlBAjKLIRE5QlyiRORonFCVJPJJSjySTyQlykk5RIIiU5JlEm3HJRuckEp6XKJxwEzI/ZKkdgKJNJjKEqbnlwFV1M2E9Uz891U1dSGtc5xwAmJ7GlxwFSay1Zb9HWCvvN0qG09FSRGWSQ9B0A8STgAdSQBzXnHs8oq/tB1NUdpmoojFLVNMVjoX/8AslLvh/vcCd9shzjycMNauv7/AKRfaA61Usjv/R7YJg6slY7DblUjlGCObR5dMnILmY6eeFoDWNDGNGA1owAPABDjyjHU/RWBh22w+Z/QIE5KNoRAZS2jAUSkKUNkpJShyQo0Y5pSSOaUhCCCCCEIInI0TihCSgeSCB5IQkoIIITiidySUtIPNIEgQQQQRhKQknmiRnmiSoCCSQlInFCVNSKFUHAwpj+Sr6t+5SBOCrag5cVEcMqRMcuTKkT0QHJPR800nWJpQpUOynQqDEd1NiKYUKfAVYwO2VXCVPgcmlCsoynWnBUaNydByEqE8DunAdwmgcpYOyE9O5CWwpoHZOMKamLoJchnZJJQUqqJSLiSchFxIQlZyiyElFkIQlcSJFxIslCEpBJyUSEJWQi4kSCEIIIi4DmcIB4PIoQjREo1HrKtlJC+WTPC0ZOAnNaXkNaMkpQC44CeRO5LHWvtMoLveI6CCGUF5ID37DPuWt4wVpXC11lqkbFWxljnDIB7lbqaSejcGVDC0kZ17konCYNRG1waXtDjyBO6x/aPqY2m3GCF/DPJtkHcLM9nVBPXVpr6qSSUNPqh7id109JwuZLM+9VUvZsGjRjJcfDULVhtPNQOr5n8rRsMaldYc4c1l9T64pNPgsI76X7rHBWd4rzQ22aUHBa3b3rjNuo5tSXsvqGv4XOJJVzhLh+kuLZrhcnYghGSBu49ytWa3QVLZKqrOI2b+Pgrmo7SLpVvJp6chvTmUdD2n3Cmn4a1geM4IAxgLX0Vggp4gxkQ4fNZzW2novQzOxgY9gPIYXXW688MXGqbbnW8MY84Ds6+Hj81p0tytFXMKV1KGtdoD1W7st7gvVHHPC7IcMkdQpz2tkYWuAc0jBB5ELlPZjc3R3CSlJ9VzMtHuXVWOyAvNuKrKLDdZKNhy3Qt8jt+i5270It1Y+AbbjyKgT0kkIzTPHD/ALmUnh+B5t/EeSpqiGmratrKiExVOMiKbYu8S08nfAnHXC0zlFrKOKshdFPG2WM78Lh1HIjwI8VysU8kDueJxB8DhZDXOYcsOCq6qsNFeLd6FUxthkaCYKljd2HwPiPELjN5tstquNRSTgCSJxB4TkHzB8Cu2MNRbNjx11H1BOZox7/tj3+tz3cThcw7QWROvTamB4khmjBBHiOYI6EHbBXsf4YVRddp6WV2RLGRr3j+2V3XCcxNW+B5zztPy/tlZCeiZV08kMgy14wQUm7wuu9oguTjxVlKG0lb4uwMRyn+IbE+IwpUgMLhxDhyARkY26H4qPHc2W24mQs76nlZ3dRCDtIw8x7xsQehHmV5JXwupK2andu1xHwK4qqgNPO+PuJCg2h3DK9vQjIyk1+nqeurjPK4niGCwdeamz0DbbcIzFJ39LM3jgmA2e0/kRyI8VA1HPLRNp6qIkCN44seC+iLBWUk/BrpK2HtmwOJ5T56H3cxXo1ungfYHPqI+0ER2/fmk09htlEMth7zHIE8WE+yso62I09PMxpO3C3mFfQ2in1BTRVMR7qSRocJGfkR1VReNB8Urah39ErWezVQcnjwcOo9+/mudouP4YZBT0tAxkbtCG6HB8husiDiZsbhFDStaw6HGhx7lhdU6ZkoGiZjjJGTz6qw0FXtD307juW5AV/fG93Y5BOW8TW4JHIrm9uq30FQ2SMnIKsXiKm4N4hp66lGI3jJb3A6FJcGQ8PXaGpgGGu1I7gd1qtZ24tqhUNB4S0ZwswTkLoVDcqS/wBH3chHERu081Xy6KY+Qujl9U+PRLxHwfNeao3WyESRy6kAjIJ3Ul1sMlwmNdbSHsfrvsVk7bRmqromRjcuC3mopm0lmLOTiMNHmk0VporCx0r3MLx1zusvqO9m6T8LMiJvIeKsRQN4HsVRHVPBqZxgNBzgbKVsbeG7bKyZw7aXQAdAolvq30s7ZG8x4Ld0Nwp7tS928jiIwQVzuN2CptPUOh9lxb5hefcNcUzWB72FvaRP9pp6+S5Oz3qW0uc3l5o3btK1dTpZkriY37Hp4JVDpmmt1QyqkLHvg+sBP2SBz+Co47xVhuBKeHwTjqqZ+nL9VPcTvT0jSTy4i57vwYF1f+kfC1LIaqlt5Mm+CfVB8tVt/wAZssL+3gpDz+J0B+aRqmo/2hoBHSPxCCemQcEj8wudPpJ7ZUAvYW4PMcitTo2vbT3GotspwJSZoCep+239fmtRX2GnuERDmhriOeNl55dbxU3esNbOfWO3cANgFxVwrp7hUmpmOvTw8FmartNqJaAU0dMxnqBpeXbrC1Mxmkc8nJJyVo79pGotzy6NpLeg6H3FZh7XB5a4FrhzBS3K9V93LTWyl/LoNtPgm1lxq7gWmqk5uXbw+CbJ4Su0/Re0wNQ6rrLnVyGWGzRA08Dt2skm4ml4HiGxn4kH7IXFzuV6M+h46PvtWR59fhpSB5Zm/msB7iGnCqwNDpBleg2x+tjon+DCcDd0rhyqOFuJhzMBYjWd8rbdMIYGeq77S3zmbclVV9rjqnAvjDyPFb1jrqa3VjairhErB+Uq7Q1MdLMJZo+cDouUWy3VFwu1K+paeGaXh4j44J/Ret9F0ois9I0DHCwNXDqu2Mhntpa0NxVMxgeRH6re9p2sbppjSdu0/pWM1WuNTy/s6ywNOO6cW/W1Dj9lsTMuJ3APCSMZWpxLxHPxJUMc5oYxgw1o2ATrtc5bpIHvHK1uwHRZTU1pm+lh20s0BSyyM7OdIzNqdSVcDi0VdTuG0rXA56ObnbGJTuWsz66fFBQ0sNJSQx0tJTxtihghYGRxsaMNa1o2AAAAAWU7HOym09iXZ5QaXtX1pj+ura0tw+sqXAd5M73kAAEnDWtbk4WlqpA0EuOy5nAADRsFyMknaO02UGrk4GE/JcR1/ef2xqU08Ls01vaWOcOTpnYz/hGB7yfBbjtA1gbbE6jo3g3CVuxG4gaftHz8B8eS5OyFsEYY3OBvknJJ6k+ZUR1KvUzOX1yolS8tHrjHn0VdUO22VrKeeVU1tO0glhMZ8tx8kYwtAOyqyoIeCCAR4FZi/UlB3ZL6eMnxAwfwVnd7q+1NJqoXiEc54Wl7R72j1h8iPNcb7SO2KgtsRp7Q4Xi6yHgiihy5jHHYFx/Qb+5JvoFKDyjmdss92tavl09E232KKWa7yNMzxEDIKeEc3uG/uGfiuA11xrL1N39fVzVkvR0ryceQHQeQXpvQulnWOjkqa+X0u9Vzu9rap25c7o0fut5D/QWE7VOy5rnVF3tEIbK3L56WMbSDq9o8fEdffztRSMYeX5rJq4Zpm9oD7v3uVx5sIdGQul9pMRpqXSVD/uLNASP3nDJ/Rc6p2md7I27l5DQuqdtLBFryelA2paeGADwAjb/NTSH1m+/7KjTN/wBXld4gff7LnTokgxqY6IuOAC4+QQdRzf7p3yUrQ52oCriI9AoXAmqinE8D43cnBTJInRnDmlp8CEgs3SHI3Scpxgr2f2B6+drzs9ttZPKZLlRf0Cu4jlxljAAefEvYWOJ8XOHRdkoahoYCXABeHPo6aiuGldY14jjMlouMHBUjoyVmTFJ57Oc3w9fJ5L0C7Vd4ub+GmHC0cuELpLTwdXXhpqWFscP9Tjge7vXpdmoKi5UomdhoGhJ0Hmu8U9Qx4GHAqdE4OGxXnaWt1DbyJ5JpSBvjOQFuez/tIkuE4o68+vgcMnicrVuXAdXSUjq2kmbOxu/KdR+q1KmySxQmeF4e0b4XU6mrbR075XAkNGThYu0dr1Fd7/DbYqSWPvHlnevIxn3LWVp72jkHPIXnSRxsmtOIeqYqkH5n/NP4LsNBfYqxlQ0mRrcs1I1wenXXCZZaKC4NmbIMuAyNV6kheHDKy3aHrRulbS57CPSHjhYOe/iry31AmpmvG4IyFwvtmuTqrUop3HLYm7Y8Csvguyx3m8Mp5xljcucO/HT4rMslE2vrWxyeyNT7lV2uzXPX1c+one4x53dnYe5ah/Y/F3B4JnNkxzO62HZ5ZWU1ipQAPWAdnHNbcW5vDyC6W98dXGKtfBbndnFGcNAHdpqrFx4jrBUOjpHcjGnAA8F5qmjuugLo0skcxodt4OXeNG6qh1lZWSOx3mSHsPkqHtO0zHX2Zz+H14zxArCdjV5fQahbRuPqSEt4fNb9c6LjHh59yLAKmD2iOoH67rSqHMv9qdVluJot8dQu3mzRtJLI2s9zcLm3bVZsWCKoA3hlH47LsURD2BZDtQtn7Q0pcGAZcIy5vvC8s4arTR3mlncdnjPkTg/IriLTN6PcIJidnD4HQrnvYbVCVtRTOPsvyB713KClaMYC829jdw9E1MYicCVm3wXpildxNHuXS/iJSejX6Rw2eA75a/NavFlP2N0e7+rBTrGBgTqQlNK8wXGlGgDlJcUScE0paCTkoZKVNwlE4SScos5TFbWMoYDI85PRviUxABJwEzdLo23Q7bzO9keHmsXV1jppHOc4lxOSSnLjXPqJXSPOXE/JVM0/NC6ajpxGMndOvn8902ZvNRXSpBlx1UZWuFNM3wRtnx1VcageKQakeKRSK3FZgc0Tq7HVUzqrbmmX1ZA5oym8qu3V/mkGv81npLhw/aUZ91A6pMo5CVqRcMdU424eaxxuxPLKamv4pxl8jWDzKTmTTGVvGV+euU62vB+1hcxl1/SU5P14cR4KK/tVpYz7Tfi8BHMoTGuvNr/PCdbX4+0uKv7ZaOPm+EfxSKHUdvlspwe8rqKLH3p2j9UvMoTGOq7225EcnIpb2IWkukA95Xmm4/ScsNGDm7wOI6QDvP8AlysVdvpTR3BzobLa7jeak7NbHGQ0n4ZP4J4bI72Wqq5tO0+u4fU/JesLlrmOna7EgwOZJ2XKqr6R1kr9UQaft9xFxuEriCKX1mMwMnieNvgMrzXe6Xtk7Ys0rLPVWm2S7GJ39HYQfvF2HOHly8l2bsD+h5V6Yq47leK5prnDBZTgkMHPAJ/NS9jyty869w+6rtdzyDs4y1g3c4Yz5DdelND1VRWRtkeSQfNdMpchgyqWwaags1LHDGM8I6q/Y3hGEjRgarHne17zy7JzkjST+CMckihCNBBBIU8FBJJyjJwkpE5BAnCBOEnmhCGcoIicIslCECcpLkecJJOU7CekkpLijcUh6EJLnJp7tkp7sBRpHp6EmWTCr6mfnunKifGd1VVE2dkxAGUiom4s77LzZ2/dpNx1Te29mWjpsXKrZ/0rXsOW0dOccQJHIkEZ8nADdwxr+3ztjl0NRU9g09H+0dZ3f6uipGAOMQOQZng7ADBxnbIJOzXYxvZp2fR6Bs8onn9Pvle/0i5XBxLnTynJxk7loycZ55JwM4QTyjmPuVkD8g9/h4eZVzpTStv0Tp6ks1sj4KWnbgvdu+Vx9p7j1cTv+AwAArZAHKMc1Bkk5KsaAYCMDCUOaJKHJOTCjSklKQkRg4SkhBCEtBJyUMlCEZOElBBCEERKBKJCEEEEROEJco0hAnKCEoQQQRE4CEqI80SCCEIJDuSWmycoQkP2Cp6qTJKtKp/BCSqOaTJKUJ7UxIclNo3HJRJycjanGJtqW0pChSYypkRUGMqVE7koyhWELtwp0LuSrYnKbE5IhWMT+SkMcoMT1IY5NQpbTkJbTthMNcnAcoQnwcBOMKYB5J1hwhC6ATsgSkk5RKVVEriRZKSSiQhKQyElV17vMVkoJaqVrnsjGSGc1NDDJUSNhiGXOOAO8lSRsdK4MYMk7KzyEMgdVyqs7ZS4kUlvJ8DK7+SpqntG1FXnEIbA0/cZv816RT/h3fJRzTtbEP8AecPoMldTFwxcH6yAMHiR9srthka0ZJx701HXQSyGNkzHvG/C1wJXB6mTUVxY589VUPbz9oj8k/2cXJ9JqqMSOJ71pYeI9VrS/h32VBUVYrGvfE0nlaM7a4zn7K4/hkMppZhOHOYM4H6/2XeMjGVnNV6yptNQ+s5r5z7MZPNW01WIaZ8jjgNGVwi7Vc2p9SuD3HhdJw45gBc/wbw9DeqmSasOIIhzO8fBZlitsdfK6Sc4jYMn9FbVOvb9eZSaWLgaTsGjKjN1hqK1yiSeSR4HR49ULoVm0/BR0zI44WggbnHMp+42GKrpnRyRggjwXT/6Y2WKb0eO2s7DbJHrY786rR/0goWSdmykb2e3jhRdIdoMV+xDORFUAfNaa6AS0co55C4Rd6GXTV7zGS1rXgtI8F2HT93F6szJs5c7LT71l8XcP0tuEF3tf+BLg4/pO+FBe7bDTNjrqP8Aw3/IrjtLIbRqxjhsY6j8z/mu6GtZDRumc4BrW5yVxDW1OaPUUrgMcWHg+as7r2iPrbQKKKB0ZLA1zy7nsvQuJeH6niuO2VlK3ILQHnI0Ghz9V011tk16bSTwjIIw49w0/uoF+rpdVakLWbs4uFg8AupactbbdRxRNGwC5x2fGkFe4zPAnJw0E812CkYAwY3yuL/EKrdTSw2WFpbDC0Y8T3+P/lc9xRM5kkdvjGI4wPee9FU0zZ4SxwyD0Kz1e6hsMbppAGAdBzK1M2A1cS1nc5LxqAwF2I2u4APArluEbI+/1bqd8hbE0czsd391k2a2m5zmJzsMaMlXFb2kyTyGKhgf5Eqprai93aJxexwZ12Wz0/p+CkpY+GNpcRkkgEq1rKHFO/O3qrpHcT2m1T9laaFuGnHM4kk+OFouvNHRyclDTDAPtO1K5RpGoNBqSm4vVy7gcu2wOy1cIq5G0t8dJG7LWyhwI967fbZxNSxv+80FaP4oQdpLR3DGO0Zg+Ywf/ktHi1nNJBVY9tv01+6mJtwTh5JB5LwtcCmJG7Lm3aXQsbJDVNaA9x4XEdR08MrpknslY3tBpTUWeQgEuYQ5dtwXViiv9LKToXcp/wCLT7rbsc/o9yhk6E4+OiqtIWK167srbNUVLaC8MLvQqh4wHn7mcbg9Rz68gud6q03cNL3Oa3XSmdS1kX2Xcnt6OaeoPQhbTQsBkfPBPTl8D8Eh7diuiXWkpdTWpts1FDLdaKPPo9Ywj02kP7rz/WN8nb+PEcYOPqUUvENQ6LVrjzaeIyrt+bGy4yszuc/FeerdcGtj9DqHYp3O4mPO/dSeP8J5EfHopddSiqgdE4e8dPcp+sezm46WJqadwvNoJ9W4UrDhnlMznE7ydt4EqBYuK9OkoWOEdeGd5AHbd8AN2jz6/PwW/wAGcT222UFXRXMOcyXGgGehB6jCns9zprfBPTVrSWv6D5o9PCewwvgZIXwcXGwHmw9ceStZq2quRDSXEc9lmKyOYl0Uxc0nYgqFadQXDTspZE5tXTtP9VPnYfuuG4/ELQbxhYraea1W4cw2c8jPwAP1ThfbfSa0VJr0Lj/5+q3Uem462CSKribPDI3hfHINiP0965/qnskq7OJKuzF9dSN9Z1G45miH7v3x5c/4lr4e1mljwJ7RVMPUxPa8fjhWD+0ixVkAJdU0sw5ccJ+R4crzq7XmrvVUaqrdlx+AHcFytbWTXKUzVJyT8lwumqXRnjjcW+YKsm32t4eEzu4fDK3GopLXNK+5W+emqZH7VVBM0tZVN8QCNpB0cN1jr1Y46OBlfQOdLbZTj1h68Dvuv/Q/DwJrQXCqpQRBK5oPcSFSjlmg0ieW+RKr56uWp/rHl3vKYxnkjDcpQGFUlmkmcXyHJ8VESXu5nnJQaMJ6N2Rgptoyltbg5z8FCmqTE4tOOYV3PTvPZvXSgD/1qC4+QhZj/m/FUDDgq4sVYZG3WySkmG5Qd5CD0mYDsPeMfJKEiw8zHF7JY3mKeNwfHIObXDqui6bvbL7QB5AjqY8NniH2XeI8jzC5249DsQnaCvntVYyqpnYlbsWn2Xt6tP8ArZShI5vNsupSxslYWSND2HoVi9T6LbOx01ONxvtzHv8AELVWm7097pBNAcOGz43e0w+BUpwONk7ZVyuEVNPJSTcEreEgrtn0R63uO0O8UZOG1Fsc/Hi5skePwc5ZvV2mmV8LpoWBso3IHVQexi6yaX7VNPVbiWMdUeiSg+EgMe/uLgfgmv1Ckh0eCvbwbgpYalOb6xKWxuVTWxlIDMoNpHTPa1jS9xOA1oyT8FOo7fNcKmKnp4nSzSODWMaMlxPReiuzXstpdJwsrK1rai6luS4jLYfJvn5pQObRQSzCJuSvLd5tk9Hd6GjqYXwTtqWF8cgw5u2dx7l03sP0s2+6lvHaNcGcdRO11ps0buVNRxvPeOb4OlkBJ64a0ZwSsZ2gVv7S7QJy12HT1kzuIfcaCM/iPmu09khjZoKghiAAgfLFjwxI7H4EJ8Y9ZQVDiIvNa6aQNaSTnyXPtZ6zFEX0tE5slXyc/m2L+Z8vmpeu9VuouK30T/6SR9bIP7MeA8/yXMpG4JzuT4qY9yqQx/mcq2o43yPkkc573nic9xyXHxJUSVuysp2jG6pa+7UlC7EszWO8CVJFDJO7kiaSfBakYdIeVgyU3K0hQKiPKdjvtBWP4IqiN7/AHknHtDhkInp5qd3LMwtPiMKRzHxHEjSD4rPV9KJGkEfFc4112f0+pKRzGv8AQa5r2yxVUbcjjact4h9r8+e+5B61VRtAOy51qi/fXupqY7jYuaVr2Sx1d+qhTUo8STsB3laluoprjL2MQ8z0AWPopZhmnrIfR62LAkjzlpHR7D9pp6H4HBBCfqGiRgOMkKYLXUVWJJHEnoSMlQJ2SUk4imbwPPsO6P8Acf05r0VnAtrqHmkp7k10/djQnuzldQyx0cjuwjqgZO7xXGLloEW/ti03DBERbrrcIXNa0bMIkb3jfluPI+SsO1S0z3ftcvFNEOImRgz/APDaux2Wnp6zU1i7+Fkjoqp0kZcAeFzYZDkeexWcu0VN/tndLsQTK6R7Tw78QDjg/LA+C46jspZe2Wu6O7MNOHEnAxvnPiNlzMFoEVUaOpPIObJPhhZ226FtGn6MT17BJIOZLshOs1Ppynk7pkEbG8uJzQsprzUf7Sre7ic9sTNuE5ac+ax+HSuwAXEr0Wv4vprPUGislMzs2ac2AS73rVrOIYrdMaa1wt5G6ZxnK67ftFWzUduMtJG1sh3D2dVxKso30lTJC8EFji0/AruegxNQ6dLqklo9tvEei5Jql7Ki+1csX9W55Iwmcc09LLQ0d0ZGI5ZB6zRp03x+90ziiGCSlpq5rAyR+4XQtDXK16f0/wAcs0YqTuR1PguzdjepaLWWnRVQBjaqmldTVUfVrxydjwc0g5G2cgeyV5MoaeorpmQQBz3uOA1q7F2bWuTs1mrbi+v9GFbE2OoglIDCWnLHHzGTv+8VmRvuvFtBFbqSMRwwjV2cD3k7qKknr7zFHSwsDYYxgnOB5kr0/NSQPpHslcwAtIwSuTVjhadQF8LvVZIHAjwyrmC13257SPfED0OypL9Z5rRUMbM7jc4c8ruuCrbSWqolozWtldICCxuo03K7WxUtPRzOgE4eXD2QvRVuqBW0EUmciRgOfeFwvtJozR6mkcNuMBw966z2e13pml6JxOXBnAfeFhu2Wh4KumqQOZLT+a4jgVxtfFElC7rzs+B0+iwOH3+i3d0DuvM34f8AhKpu2aspKCGnpqBrntYGl7yTyCw+oLzV3y4+l1rAx52wBjZb3s0stFdbR3ksDZJWPLTn8FI7SNHgW1k9LCGmN24aOmF3FBd7DZr863U9L2by4tLyf1J0K2Ka422guZpI4OR2SC4n97rd9mVU2s0zRuaQSxvAfgt0wAgLz72R61is037Oqn93E4lwc7kCu8Q3CB0QcJWcJGQcrxji6zT2q7TNc08ryXNPeCcrhb1QyUNbI0jRxJB7wVW6thElmq8jOGErzxod2dZxGL/eF4+f+a652pa5pLdaJaWnqGPqpARwtO4XPeyOxSVV3Ne9hDGbtOOq9B4XifaeGq6sqxytkGGg6ZOMfv3rorQx1DaKmonGA4YGeq9CUTuKMeaj36lFVQTxEe2wt+YwpNE3hYPFLrGcUTh5Lw5rix4cOi84yQQQvKumZTZdawtPqhk5jPuzheqLVMJKaN3kF511Joi7v1tVS0VFI+HvhI2TkOi79p1ssdvhbMMSBoyF7F+IVVS3FlFWQyNc5zPWAIJGx1HTddxxXPBVimqI3guLdQDqOuvxV6DlGOaQDhKXjYXnyCCCCamoE4RDJQdjCYqKtsDCXHCEAZTk07KeMvecALI3e5mqlJJ2HIeCO7XkzuLQcAdFQz1Oc7pcLWpoOX1nbpNTP5qulm35pNXWNYCSVQXC9Mj24gEwnC3IwrWaua3qoclzA6rD6i7QLbYWj0yqbHI/dkQOZH+5vh58h1Kh0l3uV+jEsL6K2U7vZfPKJpHf3WkAf4ihrHyeyMolrIKf/EeB9fgt1Le4o/akAUSTVNLHzc5x8gqCHSjqvee7VcmekAZG34bE/ipUPZ/Z3n+kCsqAeYkrJcH4BwCnFHMe5Zzr5St2yfclXDtFttuB7+aOHr9bI1p/NQKbXtRfSBZ7PcLox3KWGHgiz/3jyG/itZZtH6etDg6istFDKN+9ELS//Ed0/qDXFg0q0/ti9UFrcBnuqidrHkeTM5PwCmbQ/wBTlTff86RR/H9FRQ2jUtdh0wobW0/Zkc6d494bwj5OKmM0nJw5qrxUPP3aeNkTfxDj+KxNy+kjZKh7odNWm56nnzhskMJgp/i94yP8KzVfqHtI1mCySspNI0Tv7KgZ3tQR4GR3I+bcJ5ZTQ+1qUyM3e4f4YIHlgfFdF1N/sdpWiM9/uUtLCQcGpucrC/x4WB44j5ALz7r/ALQtL6ignotD6OuNwq3HhF2nqahjWnxa3i3/AL2Pct3Y+xCjqKz0yopZ71XvOX1lxcZnuPieLZdOs/ZaY2s70RwNA2a0Db4KI1TNo2D4LXh4fnPrVdQc9wJ+q8eWzsw1/d8cbjSNPWab9Blae3/Rv1BXkel354zzEMTn/qF7IoNEW+jwTCJXeLgryC1xwjEcbWDwaFDzvd1A9y1m22jj35nHxJ+2F5Gtv0SYJwDWXO5ynrwxhg/EFa+1fRU0rSAGaiqaxw61FS4fg3C9Iih8k4Lf5J4BO5Kd2NKz2Yx79fquMWnsQ0xaHNMGnbcCPtPgEjvm4Era2/TrKVrWQwRwMG3DGwNH4LaNt4zyUqmtnE4YapOTO6DKyIeq0DyCrrFYg6RpLM+9dGtVEKeMADCh2m2d2AeFaCGIMCjdjYLlK+rdK7GU5G3HRL5BECAhklMWMgjbzRIJpTwjB3SicJCCQpyMnKLkgkk5TU9AnKInCBOEklCEEkuQJyiSgIQREoE4SSdkqECcbpp78I3v2UaWTHVPQkyy4UKefGUc82M7qvmmxkdUJRqkVE2cgLmvbN2t2/sn0w6uqAaq5VJMNvt8e8lVMeTQBvwjIy7pkcyQDb9pnaRZ+y/StVfLxPwQxDhjibjvJ5CPVjYOpOPgASdgSvPGkNP3jXGp3doOtmYukrcWq0nJZboN+HIP2yDnyySfWOGocDU7fVWGgtwG7n5eJU3s60XX0ldXat1TKKzV929eZ3NtHGeULPcAASNtgBkDLt2DlJzlKbyVUkuOSrAAaMBKbySmhElDkhGUaUOSSlA7ISI0YKJBPQlIJKPiKEI0EnJQQhKyEknKCCEIIIshETlCEZOEnOUEEJ2EEEEROEJUZOEnmUOZRIQgggiJQhETlJzujJ2SHO4WknkEIVfc5sYblU8jt1JrJ+8kcVCJyU4KTYIZyggjASpqMDCMc0SP7JQhOsKlRFQ2lSIioyhT4nKZE9V0blLicmp6nxvUmN6gxuUiN6EKcxyeaVEY5PNdsmoUlpTrSozXJ1pQhdCLsdEQcmy/zRGRSqvhO5CBPmmXSeaLj80mUuE9xFUGrIPSbRUR4zlpV0JVAuf1tNI3yKt0kxgqI5W7tIPzUkTjFI146FcL0tFG6/wwzNDmuJZg+K67R2OBjRwQMb8FyCbNr1OSNu7nB+GV3e3SCSFjgcgjK9s/E2SUzUlXG88krNsnGRr9CF3HF3O+WCdrjyvb36fvVVtba80rwG4GOQXG4HG06pYeRjqB+J/zXfqoB0bh4hcK1vTmk1DK4bcWHA+ah/DGcTVFVQSbSMP6fQlM4QIMs1K7Z7f39V1+6TcdlnxuHRkD5Lj+j9tTQtk34nFpz4rqlqnFy09Cc544h+S5LUcdj1O444e7mz8Mq5wJFz010tO0hB+WW/VTcOMLoayh/MQflkLvdFEAwJ+WIFqg2a4MrqRksZy0qweRwrweRjonljxgjdeeFhZlrhghcp7U6FrGxygYOQpXZbVOdbZ4nH2XZCj9rNcwmCna4F43cB4KT2Z0rorc6RwwXHbzC9yqSW8Axio3LvV+P7+K9Aly3hlok6u0+KpO1Ck4K6GYDAOWotJ6dortaxLJGXy5LTurztQo+8trZQN2OBUDsrqA9lXTnfDg4LQbXVUnAjJ6WQtfC4AkHBxnb/qHwU/pEz+G2yQPLXRnGhxpn+6zt90zU2OfvoeIx8w4cwtToztCyWUle7fo8raV1rjqYS1zQ5pHIrmOp9GSUchmpGlzc+yOYVS2cQW/i2mFrv8Ahso9mTbXxPf8ioaO6U16iFFdNH/leuvOqG1EXExwc0jmFxPWlvkt2oJpwCGPfxtK0eibleoHNglppJKf7z9sLVXuyQ3WEtlZxea562VR4DvT2yubLE4YPKQdM/IjuKzqWc8N3Ah5D2EYOCDp+qy+nu0KlgpGsqWuErefgo2oe0J1dAaahj9vbiBOUUvZ5F3hIkcG/dCs7Voylo3h/d8bx1ccrZlreCaSY3CBjpH7hp9kH340+KuPquHoHmpia5ztw3plc7rbXU0pjdIxxdKOLGN11jRNbJU2qFsrHMcxoHrDClC0teQSxpI5ZCn09P3QA5LmeJOMzxFQx0s0ADmHPMD8gMd2OvRZVzv7rrTshliALTnOft5KbzSTzQzwhJJwvMlzCJ5UGsgEzS1wBHmpjimn7poJByEKthpBE7YYCmA4CM4CQ9yUkndM5VFr4DI3vYpZaedo9WankMcjfc4YIWefqOkp6xlPrLTNNqOk4uOO82+JlLdYSOTuJgaJS3bqDtuHLSudnOdwqO70LKhjo3jY7tcOY8wqz4xnmG6mY7I5XbLMax0B/tRGbhofUVLqWjYCH0VSwU9xh/de0hocR4kNz0BXJLlQVlrlMddR1FFITgNqInRk+7I3XV5mMstc2pqoI5YSOCZ5bn1ejx5t/InnstJUH1HMce8heMcL/WBHhvzQw6Ic3C86l7fFDIO4Xaq/RViuOTJbYY3fegzF+DSB81QVnZLQyZNJXVFOfCVokH4YUqYQVzU4Uikqn0zncOHMeOF8bxlrx4EdVpa3stvFPk08tPVtHIBxY4/A7fiqWp0zeKAkTW2oAH2o2cbfm3ITgma9VnLhbGwvdLTtPcHcxk5LP5j/AF5qC3ktGDg4OxHQqNLQQSBwLe7J3a9o9k+7qFIHd6aR3KnaEoAoPaY5XxOwJGcwNx5EeSA5pyYUsHBCE7XuEckLu7nicJInjo4ckoct0rG2E4JhVLcGh8npDRwtlJJb9x3UfNQy7CtLnE5jXOaPUfjjHgeh/T5KrLc+9SAJuU9Q109tqm1FPIY5RsT0cPAjqFu7Pq6kuTWxzkUtT9159V3uP6Fc+A6o8hGcJCAV1ienErdln7hYywmso4yK2E960M5lzdx8dllKK+V1A0NgqXsZ9w+s35FT5tZ3gUzxHUtjeRtIyNockJTQ0g5C9wUdQKylhnbs2VjZB7iM/qpkTckBZTTt5joezywV03E5ptlM92BknMTVedlWpKXX2sILXFC+No+sLnEesPD9Ffgs9dVUslbDETFH7TugXQxUdRLA6pYwljdz3L0P2L6IbQ0f7bq481Eo4acOHst6u95/L3rp9VUCkt9VO7lFE5/yGUVLDHSUsUMbQ1kbQ1oHgAqLtJvEen+z69VszxGxsBBcegO2fxWcByhcu5xmlHicLx3HVm6a4vNTxZioYWU48C9543H34DQtRYu1+Ls0pbhTVRc+nq/rYSBxGKXk4kfvDGPNvmsfpajlpNLxVtQ0sqbvNJcXtdzDXnEY/wAAafis92iwd/bA/G7VtcO0VPcLpDS1RIY84OND9119DSwVlUynnzyk40XUtPatpdWQy1dO57/Wy50vtE+KzvaXqev09RNkouDLubntzhZDsavTIZ5qGR4Y6Qepk44j4f5LVdqFJ6XYXHGeHP5LtH2mjtHFTaGVnNEHDR2uQR179VefRQW+9tpntzHkaHXQrCSdp1fWWkU4Pe1kmxc0EEe5VsWjLpdG99USyEu3w4k/mmuzykiqb40SgEgeqD4rtUNsD4xsu24kvUfCFWaKzwtY53rOcR37AdwC37xchYag01vjDSdScd/QeC4LcrDX6fcHnLW59pp2W10Pqx1yYKSpf9cM8Lj1GFs75p6OtpXxvaCCuLUneWLUTAfVLJC34KajrouPbVPTVjAKmIZaQN9D+mqnpKtvE1FLFUNAmYMgj9/FdS1JU+h2yaXwbzXKrNAa+5F7/W3yV0vUjfTdOSEDIfHuuUUE9RBPin/rHbYwq3AtA6WyXCOBwZKTy5OmBjv6dU3h2ndJbqpsZDXnTJ6D95W5NLGGnJCpbxDTugexxaeu/Tw+PmoXod2q/bkcB4ZRf7N1Dt5HElYVPwzarTMyorLm0OaQcMGdR4qhFaqGhe2SerHMNfV1VXRVgtVxp63u3TCmcZOFvtH1SNvmsbTV0dya7heTMw8Msb2lj2O6hzTuD5FdJGnSJ6WL7Uswb8AC534NI+KGo9I227yd7UwBs7RhtTEeCVvkHDfHkcjxCxuO7tb71WRT28lzgMOOMZ7lFfa6luMzX0xJOMHTdcrqrDQ3WpjFXEHDkJGnDvmPyKntsun7K0PNNHttxv3wpNy01caEn0WVt2hG+/DHUAfgx/8Aw+4rOVIZWMlgl4s+zJFKCx7c+LTgjxVWyX48NQmKoomueTkOeNQPeFTpK4Wppa+mBedQXD+y0sz6LUFG6kpalrQRg930XKNY6Tl0/UjJL4n5Id8equNPUdXaNTwRM4jE47OB24fPzWp7So2OszHPxxZ4fNei10tPxlw/NdJo+zlh0BBOMDC2aox8QWuStmj5JItNNsaLM9k9tjmrpp3NDnRjGD59UfarXzyVhpC4iDG7RyOVC7P70LLc5BIcRytDT810LUWl6TVMAeJA1/SRu6Sy0r71wiaC3OAmDiXDOCdfuMJLfTuuXD5pKN2JAdRnGdfvotp9GXtCbq7Tsmn7hLm+WVjQOI+tUUmeFj/Ms2Y7+4SSXFaXtJlgNRDGwgyDc4K4ppDQ82j9SUl8o6x8NXSl3C/OzmuHC5rhyIIJ+eRgjK6hQWyo1Rb5royQVAcXBrmHOXA4LT4EKvw1w3Lw5Wtut5kETRoBnUk6fBSWS1yWiRtTcXBmNBrqc6fJdH7Gq/vbRPTl28Umw96kdr1F39kMoGTGQ7Kz/Zlabtarg90lOY4JAM8Zwul6iszb7apaVzuFr24yuavFVTWri/8AiEEgdGXBxLSDvjm296zq+aGjvfpMbwW8wOhz57LnnYjWDvq6lJ8JAD8l16toGVUDmuaHNI5ELEaM7PoNMVpqI5pZZHN4TxbA/BdGiZxR4Pgua4vuNJcrzJW0DiWOxrjGoAB+ixr3VQVte+opj6px4a4XENV9lcral1RbncPUsJxj3Kjp7Zq2maYYjO1nIPc7+a9ET0Ak6KL+yGkjIW5R/iBcYIBT1LGTBuxeMn+6uw8T1kMYila2QDbmGq4ja+zS53WqbNcqgFv2g4kkrsGmtPw2ilZDBGGNb4dVbQ2wMI2VjDAGBc7e+J6++4ZUOwxuzQMAe5ZFwu1Xc8Cc4aNgNAnYWcLU5IziCHJGOa5FYhVbJb2vlyVOpoO7AATpAKNLlQYwlpQOUlAHCchKQBQ5hJ5bJiMKLXVrKZhLjhYm9akD3lod8FodT0kj6Z7mE/BeV+2+XWswig0vW+h8++cBh58MOPROGFo0sQedNSu1vuIO5djruVWV13DQeDdeMDR9slrlMkV8rZnH79SJB8n7J30btdvje7r9SVNHGefcvDX/APAB+aCG/wBYWw2OfYQOz5DHxyvSerNaUOnqU1N3udNa6fmHTyBpd/CObj5ALz3rf6R010lfb9FUc1VKctdcp48n3sjPL3u/wqNauwJ1yqvSbpNWXapccuknecOPmeZ+JXUtOdklPb42sZDFTMH2YmgKDtI2nIHMfgFaFvrZxyyOEbfDU/oF5zg7OdT6qqnVl1qzHJKculncZJXe/wD81sNNdkFytUwlor3cIpfGnHCPiN8r0pbNCUVPgmLvHeLhlaejsEcbQGxtaPIJDPM7rjyVuKy0EQ9Zpee8krjdsfr+3UwjivcMrWjYVVEwn48JCcNw7Sp9jqCgpB96C3Ncf+Ildxp9LipOGx8R8gm6nR7Y38Jj4T7k/tagDIcphaLa53rRj4n9V5/q9G6nvziLxrO+VUbvagpJRSxO8i1gAKsdPdiFmpntfDZ4pZOfeVP1jifH1srt0WkmtcDwK+t1kbC0eqAoS6aTR7itGKioafWKMA+SwFp7OQxjA/hiaOTY28lq7bo6jpC0iAPcPtP3WqioQ3opDacNT2xgKZ0qrIKBsbQ0NDR4AKS2lAHJXNHZqmsP1MD3t+9jAHxVxHpanpohLX1zIm/chHE5WGtcVRkmYNysm2nynmU/ktTQXO22SfvaW2x1kjT6j648bR58AwD8VXXGsfdK2WqkjijfIclsMYY0e4BLoFWMhJI5cDv/ALKsbTp5tLxdFIZHkhT6am4sKTmwMrLqJ+QZUGC3F7twriitjYwCQpUFOGDkpbBhMMhK52aqfJoEqOMNbsE8BskMxhLzsmZWfujO4CMckTUaCUIIIIEpEIIJIKPiQnIEokElyTCeiJykk5Rk4SSUqEERckk4SSUuEIy5Ie/CJzkxI/AKchFLJzUOaVHNL5qDPNjKEJE82Fk9ca4tehLBWXi71TKWjpmF7nOO58AB1JOwHUp7WWsbbo2yVd1utXHR0VMwySSynAaOnvJOwA3JIAXlpguf0hNRwam1FBJSaMpJO8tFkm51Z6VE45EeDeRG3s5LwY3O37+astby40yTsPufBP2WC59tWqYdd6qgdT2enJNhs0u4azORUSDxOxHjsfZDc9Lc7iKBPREDlVnOLzlWGtDR3nqUoDKW3mkgYSmpqRGljkkIwcIQlIIIJQhK4kMhJQTkJaCQghCWiyElBCEouSScoIIQggiyEOJCEaBOEknKJCejJyiQQQhBAnCInCJCECcoIJBOUIQJUO5T93Dwg7uUonKo7hUd7K4jkNghKFDldkpCPdxyjAwnpUQCNBBCEEsDZIS0IQT0bkylg4KYhTGPUqJ2FAY5SY3JpT1PjcpDHKDG9SWPSFCnRuT7HKFG9PsemoUtjk+1yiMcnmOQhbt0w8UgzqvdVZ6pPpPmlykDVY98h3/mq8VHmlCdJlLyqeJ/NMVDwWuGOYTHfhIkkyNylDkhauQa4pzT317htxjK6rpOvFXZqSQnOYx/Jc87RYP6RDLjxCvuzqv47OIzuY3FvwXvHEp/iXBlBXDUxnlPzH2C7y6D0qx00/Vhx9vsF0GSQFvwXJe1Cl4K6GYDGct/VdN9IyzPFssT2g0MlfRtMUZke1wIDQuG4EuDaC/QPecNOQSdtRhYVgmFNcY3uOAdD71O7OawVOn42E7xkswq7XmljWk1VM36wbuA6odnVLV26KeOpiMbXODmhy28zWys3OVcul2fYOKJ6y3PDhzE6HIIdqRp5paupdbrtJUUjgdc6agg64XKNN62rNMn0eVhfED7LtiCtFW9rTTA4QxESEdBsFZ3HTNJWuJlhGTzI2JUSDR9DA8FsDc+Yyujn4i4TuUnptZROEp1IB9Unx/8LSlulmqXdvUU55+uNif34LFU9NXatuffy5c0nJJ22XWrDb20NJHEzYNGExRW6OAANjDR5DCuIRwBcdxLxRJfSyGNnZwx+y0fdYN0uz7mWsa3kjbs0Ks1NaP2xb305dwcQxxY5Kj0npGPT1S+Vs75XuHCQRgLYyYd0TTWNacrBhvdfT0L7dFJiJ+pbga/LPRZrK2pjgdSsfiN2471IaOJuMZUSooxJ0UkPwOaBeCsPOFSIBUKKk7t3JSREC3xSjgFJMg8UE5SBoCafTNJ3CDYQ3kE4X+aSX+JRkqTARhgCLZqSZEkyJEqUXJBekukHgmnSJEJwuTTnpDpNk256EJTnptx3SHSeabc9CEpzlHqQyVmCeEjkU1V10dOwue8NA8ThYSu1JUT3VrYHkRh2Nuq6uw8NVd/dJ2PqtYCS47eS1rdapriXdnoGjJJ2WpqaVsjHRTMyw8wVXUMbrWGW6ocXUxOKWc9P+zd5jp4jboriKcSxND/AFtuqE0MNRE6KRokjcMFrtwuSczlJWSTqoMrXwHDxseTuiLjHU4Uynp3QRGIyGeP7PebuA8CeqjT0jmnMOAPuPO3wKEZSM+ByEku3UaSSeJ3r0khHjHhyS+ve3ZlFVSO8O7wPmUISLtZKK+QmOsgbIfsyDZ7fcVipOyyR9aRFcWGk39cx+uPLGcH35HuW2Laic5qntpYv90x+Xu97unw+alsI4Q1mOAbADkpA1wHNjRIRplYHU3Z3HLYoKaibiupQTBVvx9YScuZJjoenhtjquZG2zSd6BE6GphPDPSSDD43fqDzB69F6PDA4Hi3Hh4rD61paO718bxF3NbB6oqYzhxb9x33h7+XMYW9ZbLXX2oNNQs5nAZOSAAPMq9R22e5SdlTjJ3XIGnfB2I6FKAyr+8UVKa808wdT1BHFE9w4e8b4g8ne7n4hU1XSTUJ+sHHFnAlaNvj4KlVU0lHUPpphhzCQfMHCzKiF9PK6J27Tg+5MvY2Rpa4ZBGCqyksc1dcRSxua0u3a53UK0ByNlJtcgiuMD+RDhg+CuWqKCWthjqfYLgD00yikbG+pjZN7JIz5KTT9mwaAamtDR+4P5qfHpCx0n9Y8yu/edt8lP1m+WKzOlheWuY4bjwXNJa+eU+tM8/Fe3X59g4RqRSR28SOIBBcSRr557l6JdpbXYJxTspA84ByTn6roQ0xZqscEfCP3WHBWY1TpZ1nhMkZ4occ/BVllqKgV8fc8XETg4XQtVvYdPPbLs57ABnxTGR2riuzVVT6K2CSIZBbsdNB0+CIjRX23TzdgInxjII22XatDVTbz2J6dkaeLhofRj74iY//AAIvo93T9i9rdo4ncIke6E55b/8Aks99HW4/tDsrq6En1rfXyxAdQxwbID/ie/5KsrH1Fl1G6SmcY54peKNw8VS/DoCvorhaXH226e8EZ+YRwtirpamhJ9pv9l9MW6hoKeMOnrIYxjJy8ZXFvpH65t2raKy6It9wjH7XquKtqA/AhpmDLiSeRO+M8yCF5/i052j6hpXVVRVuoaNsZkfJNKGNawDJcfIDdZ13ZxeKzTFPqGoqXuFZvTNlyHyRZ9V5zyBHrAeBB6rKPB9mgPZ1lzaHdzdVkwcP26meDPWt5vDXVdXv1wpa+vlNEWeiR4ihbHyaxowAPksjqym761yjGdsrnVov1dYLi2OV7jGHYc13h5Lps0zbrZ+9Zu2SPIWHdeHZ+E66nqQ8PicQWuH0+CdW2ySzzxSB3MwkEELnGh3MbehBKMseS3Y4IPQg9D5rqF3uMrbNNS15M0HDiOsA5eAk8P4uXjjryOgeaDUQPLEn6rtD2NqaJ4wC17cYPXIXSfiI0wXaluUez2tPwOfutLicBlbFU9HAH4LkWkqj9napjBOAJcbe9ehKUAsHgvN1c0We/ktbhrHZwPDyXf8ATN3p7xbIp6eVsoDQHNGOJpxuDnfPkVN+I8Pbeh3Bo0ezGfgVDxbEXugq2jIc3VWFVEHMOy4D2gxNpNUTcIxuH/Nd8uFXHSQOkkcGtAzuV551LW/t3Ur3M9dpfwtPiFF+GMMn8QmqCP5bWHJ6JOD43elySn2Q05XT7VSen6ejY77TNlyaSJ1kvxErcCOU8xzGV3HTtD3Fpp4TzawBZfXGihdczQjhnAJHmq/C/ENLb7jVUtWf5E5IJ7t8H3gqtZbrDSVU0M/+FLkZ7t9Uq1xQXKkjmjLSHDOAnprQxgycAea5zA69abkc2MSsbnGByKkTXy+3NoYIngH91TVX4eukmM1LVx9gTkEu2CtScL5eZIZ29mepKsbvfILXd4BG3vu7a4EA9Tjf5Aj4qTLEKqkDi3h4hlQLFpCd0xqKxuDzAz1Wrfb8MxjAXK8Sx2i3mGltZ55Ge1IDoT4dNFQuPoNMWQUR5nN3d3lctrKOainJIPPYquutDSXqNoq4A6ZgxHOz1ZGe53h5HIPUFdJuFqDyfVyqSezNa7ZgHwXSf6b2+5QMZeqISvYMBwOFrfx+CpY1lfT87h1Gi5+6mpNP0pqKhw4WnHeSNxv0yVz/AFhfn3qfgaMQt5DPNd2nssVTDJDPEySF7Sx7HtDmuB5ggrmupOx2enc+ax1AMR39DqnEhv8AA/cj3HPvCw71xi+vpP4dQwiGDuG58ysq5XeWsg9FpowyLuHXzXJxGYzlW1Dqi421mIZyB57orxZ66yv4LjRTUZzjikblhPk8ZafgVVvYQNlxFLXVNE/tKeQsPeDhcnG+WmfzQuLT4HCtK/Vtxroy2Sofg+DlqOw/tXHZ1qg0d2mP+zN1eG1LnHPokuwbOB4cmvxzaAdywBc8exwPJNSQtkaWvGWnoVJVXCprXc1TIXnxOUkk89Q4PmeXEd5X0joaMQvHI7ZDgchw6EK9gYHNGy8tfRZ7bGPhpdAahquGoiAZY62Z20jf/qVx6EfY8R6uxDAfT8E5a7BGCNiD0WWTg4VgBrm5CnR04B5KZEAzZRo35AKfYcoUWMJ9pzzSw0bHCaBwnAdk5RlK4QOicSAcpQ5IUZSgUoc0gc0pCiKWgk5KUhNKU0o0gHCUDlCajBwhzKCCEIpI2yMIcMg8ws7cdFW+tlL3RgE89louJyInKTOCpGuLdisBcuza0vjd/R2l3uWJuOiKSjlPBSRg+OF2yeDjB2VFcbSJs+rukOCtalrpYzguOPNckFp4NuHAHgFKht4b9lbGpseCfVwobraWdFGQuojqRIN1UQ0YHRToYgAMBSRTFp5JYix0SYVxr8p631MlDKJIjh2MbrSUemXXmy+n09UKm4d6RJR4Ac1viPFZljMe9T6SplpZA+GR0Txyc04KmY7Gjtk2QOOrTg/vRPupDDK6ORhZI04c1wwQU/HA0DwTDqiSeV0sr3SSOOXPcckp0SJ2QnZOFIhZE6RrXu4GdXAZVmy6w0NPNTUkDXMkGDNKMvKpRIAj70pecjZROZzHVWst9rZYREZyIwMYbtlQTJud8pjjyj4kwkndAYG7BO8eUbN000qVTxF5GyUBQykNbkqTSw8RVvTQ8ICYpYOEDxU+NuyaTkrjKqftHabJbWpxoRNCWhZ6A5pX2iiAylJyEAcIwcokEIR8SJBBCEEEEEIRE4SUp3JJQhJPNIcUZOEk+adhCSSkOKNztkw96VCD34UWaTGUckqg1FQGgoTgk1E+MrK6v1hbtIWWsul0q46OipWGSWaU4DR+ZJOAANySANyhrLWNu0hZKu63WsjoqGmYXyzSnAaPzJJ2AG5JAC8p1Ut1+kbfob1fIprdoKkk7y3Wh54X1zhkCaXHTwHLBwOZc5N/Afv5q01vJgkZJ2H3PgnHz3P6RmoIr9fIZKHQlFLx2y0S7OrnjI7+YdR4DljYZHEXdSGGNDWgNAGAANgm42thjbHG1scbAGta0YDQOQAS1A93N5Kw1vLkk5J3P76eCPolDmkjmlJiCloA4KCCEiUgk5wj4kuEI0eSk5CPITkI+JDiRZCGQhCPiQ4kWQhkIQj4kOJFkIZCEI8lEhkIuIIQjQQyEXEEJ6NBDIRZCTVCNEThEgjCEEROECcJJOUqEZOUhzkZOE2ShCYrqjuYTj2nbBUUh4ipdwqO9lOD6o2ChcyhOCCIuQJRJ6QlKQRNRoSoxzSklvNKTEIDmlpCWnp6W0p+NyjpxpwU3CFMjepMcigMcn2PTSEKwY9Pseq+ORSGSJhCFPY9PsfyUBkifZIkQr51YPFF6YMc1zl2tG/eTTtbAfaUequ8gXTfTWj7SUK4feXLTrcfewiOuCftfik1RyBdU9PZ94JL7kzHtBcnk1pIeRKa/wBrZ3faKbkpOULdaipYbxGGOk4MHOQEenqWCzNeyKQniOSXLA/7SzO5ZTrNRVA+8Fs/xqv9A/hvansc55dMZ+qtCeo7H0bn/l74XWWXNgHtBNS1jJDufxXNI9RTfvKTHqKQ+Kw+chQGEFdDp6ljHZyp0de3HNc3i1E8eKlx6id1yml5KaIWhb/0pr+qcbK0+aw8Ood9yQp8F+a7HrIEiaYFr2StxzTvpCzlNdmvx6ynsrA4c8p4kUDolaekIjPlV4qAeqWJQeqfzqExqb3yLvlE7zzQ4yncyTkUrvUXfKNxlF3iXmScqk96fFIkqmxjLnjCg1NwipgTJI1g8SVg9XarbVYho5cjq5pXWcP8P1nEFU2CFpDTu7GgHmta3Wya4zCNgwOpxoF0htUyQZaQQgZVkNIzSttbO9Li4nm7wWhE+Qsi50jbfWS0rXcwYSM9+FQqoBTzvhBzynGVKdMkOlUYzJDpVm5VbCkGRNukTDpU26YoRhPvlws1qDVLbfmKLDpvMclMu9w9EpJH8WCBt71hKKmdc6p0sp9XOTlemcJWSinjlu92/wBnh6f1O7l1Fnoad7H1tb/hM6d57kJqiuvT8u9YE+4K0tNkFPI2SQZePkpDaiko2gF7W+QUmnutK44bKB71vXfiS8XCldT2ykMNN/utOo89vgrdbda+shMVJCY4fAHUeatY/VaEU9SyEes5rR5nCbbO1zcg5z1Wc1Vl8bHeBXm9htbLxc4qCV/IHnGcZ+Wi523UTayqZTPdy8xxlXzLhxetG/ib4hL/AGiQMPaHe7ZZvTVSBA+N2+HZAVhc6tsFO5x542CsXWwy0N6fZ4cuIcGjvOcYPwKlq7c6nrnUTNSDgeOdlHuuqJIJu7p2j3uCm22vklpw+okaXnfAGMLJU0bquoLjvvkrRwMxGPDC7TjKlttip4LRSxt7YAGR/XPdnotm+Q0tBHHQwsHOBlzuvkqrUbyappDyQRg4KtLLUOmoom59kYVbfY/Va7wKc07Nhj2E4wVtXJrbjwHTztGsLwD8SPuFfqgKrh2OQbxu1+n3Cvq+rFPSuceYGyw0rzLI553yVfajrcsbEDz5qtFLw0LnEbndbfAvY8PWyOuqB69S8Nb/AJc7/Uq9w+Y7XSNqJR60zg0eSsrFQ0V5oHUtfSwVkTH5Ec8YeAfEZ5FXtFo6x0bHtitlPwvGHB7eMEeHrZWb0vN3dW9niMrbQyAjmvM/xApPQ+IajGz8O+IGfnlcpxHB2N0l7nYPxH6rnmsOx6CsY+qsPDS1AGXUbnfVv/hJ9k+XL3Lkrmz2uvfTVcD4KiJ3C+KRuHNPuXqMOVBq3SFt1bTcNZEW1DBiKqi2lj+PUeR2XBQzmN4PcuVMeoc3cLm9TStvNlMJdwiWMDi8FnYtAUUIBqKpzvIbBbBtomssXocsjZSwYbI0EcQ6HHRc/q7nLFUzQVkjvR+I4lYPWiPj5jxHyX1JxLW2hlFR3Wvpe3c9gA10GgOozjqV6ze6ugip6aurIO0c5uBroOuvxWkoLbZrW8d1wh4+05yY1DY5r4wyQTtcwey0dVnLpp6uoaeGoma6WjqBxQ1UZ4opR4tcNveOY6q70S+cB7HFzowdsrDsvElBxI8WJ9II4n59g41HfgLOt13prw8Wt9PyRu/pOPjhar6NNfJQal1NZJstNTSx1TR0BjeWO+ffM+S2HaJbjRXSnnGwnjLh8CVzzSdc2x9s1hlaeBtQJqWXHUOjcWj/ABtYu6dsNlMWkdP3HHtPfHxHrnJ+PLp4LF4RjFj4ukt/NkHmb8sj6KvYWi23l1LnIyW/LIXU7JWf+lKy6c0jROPos9JFWX+eMkd1TA4ZT5HJ8zmEEZBDGvODxBK7UKqGsuvolKGtpaZoiayMANAHgByH6ALm/ZP2yW3s50PWUUdHxXSpndJLOXbv9UNb57NaAMHAWYu3azVVkkr4o2iR5znGViV3At6qbnO2nh/l87sEnAxnT5LOk4ZrX1koijwzmOCeuu6pdfQRwXUBmOPmcLa6ODjp+GN+dhge5YOhtVdqW4ConGWk5JOy6vbKAUlIyJo9VowFs8aVUNDaKSxiQPlj1cRrjT+61b9NHT0UFuDuZ7dTjouR6jh9CvxPL1l1+wTemWimkzkujCyGp9GSXa4d6yVsbfduVr9MUHoNngj4zJjIJI8NiPnlZHFF5oLtZaFkcmZ4xhwwdBjvxjuVG8V9NWUNO1rsyN3Gq5b2hUfo16cQMAkqPaX3m1wtq6CSRoxwkxnmPA+I960napRYfHNjw/knuzo+l0EkZ3LSCu//AI06Hg+mrOybKGkNc1wyO73HxXSG4OjscU4YHgaEFZy5Xu/XrggqMxtkOBkcIcfDPj5LRaN0JJTTsqawDvActaDla+WyRVEbmSxNkjeMOa4ZBHmEikhrdPuHcNdcKIc6d7vrYx+48+0P3XH+8OS83uHHlTPSOoqOFsEbt+Xc+9cpVX+eopzTUzBE074WoooeBgGEdRSiUct0LRc6S7U5kpZePhPC+NwLXxu8HNO4PvUtwXmwcHahceWluhWbqbOx7slgJ8wo4sjA4ngHyWmMbXJDolKJXgYBTgDsCqSO2Bo9lJloBwHZXXdBqbljyFATlSt0WQrKDc7KoqKIDotrUUodnZU9XQ88BMIVlrlkpaTh3AUWWn8loaikIzsoMlPjokwrIcsxW0AexwLQWnYgjIIWC1F2YWq6Bz4Iv2dP96BoDD72cvlhdYmpwQcjCramhyTsnhNcA7RwXm6/6Bu1jLnGD0unH9tTji+Y5j8vNZox5XqWSgOcEbLNX7QVsvJLqimDZT/7RF6r/j4/HKdhVjTA+wV54nhJAIc6N7SHNkYcOaRyII5Fewvo6dvze0Oli01qKdsWrqaPEFQ/ZtzjaM5H/agD1h1HrD7Qb5+1T2X19rhfNR5r6Zu5DRiRo8x1+HyXPHGSmqo5oZZKeoheJIponFr43g5DmuG4IIzkJuOYYKr4fC7JH919P6acglpGHDmDzU+KTIXnHsE+kfHrr0fT2qJo6XVLQGU9acMiuI8D0bL5cndPBegaefi5jBHMHoo9jgqcgOHM3ZWjHZTrTyUNknLxUiN+fenhV3BPg4Sk21ycBSqApaMFJBwEOIHqhRFLSmlJQRlIloA4RA5RoSBKyEaQjBwkyjCUiPJAHKNIgJO2ElzGu5gFKIwiQlUWaghlzluPcq6psROSzDldHxRY3wmaqxHM+M5BWOqbcYnYcwtPmFEfTFvLdbp7GvGHtDh4HdQaiy0827cxO/d5fJGe9bcF0aNJAsh3WD4JQGVdVGn52bscyQeexUCS2Vcf/s7iP3SD+qFtx1kDxo8JlpwQl8SI01S0f9VmPuaiEFWeVHJ8cD9UKbt4f6x8QlhyMP8ABJFHXu5UmP4pGhOttNxedzTQj3ueflgJcKN1ZTM3ePr9EQKcZuU/T2I/29VJJ+7G0Mb+p/FWtLRxUwxGwN885PzO6cAs2a8QM0jBcfgFDpaCR5BcOEeataelbGNhk+JS2NzhSY48pTlc5UV01SfWOB3BHExSWNRMjwnWtwkVFADZGBlGBhGnIQQxlGGo01CTgoJSIhLlJlEggglSoIIIicIQickuOAgTkpPNPQkpDjtulOOxUeSTCEIpH4USWVHLLgKvqKnHVCcEdRUAA7rKaw1hbtI2Wrut1q46KhpmGSSaQ4DR+pJ2AG5JACPV+rrdpKy1d1utXHR0NMzjklkOAB+pPIAbk7Lyhca25/SGv0V4vMUtDoekk47daZDh1Y4bd9KPDwHLBwNslyb+StsZy6kZPQfr4JdTV3P6RF/ivl8hlodDUknHbLRJsaxw5TTDr5DljYbZLulxhsbA1rQ1rRgADAATMTWxsaxjQxjRgNaMADyTrTlROdzeSstHLknUncp5u6WkNO2EoHATUJQOErOU3xIwUJiWDhHxJGSj4kIS+JDISOJDiCEJeQhkJGQhkIQl5CGQkoIQloJCCEJaCQghCWgkIZKE9LQSeJDiQhKQRZCHEhCNEThEXIkIQJykudhGThNuOQhCDjhRa6fuoiBzdyT7nbKnrp+9lPgNghAUV78lJJwEM75RJwSlBBBGBlKkQbzRoIJuUZRt5pSJvJGkTkEtIS09PSksdCkJTShCWHYKdY9Mg4SkJ6kten2SqEHYTjXpmEKwZIpEcirY5MFSGSJmExcym01d4ieOGRpHi0qM6zV4PrNd8l6ofb4ZCS+NrveFFk0/RS+1TR/JO5Cqwrj1C8yRWmpJ3a4/BWdLp+V+MtK77NpCgfuIWj3BMf7I07DlrR8VGWuUzaxh3XIqbSb5Mer+CtKXQskhHq/guoQWZlOR9WCPcr61wUocA9gHwUBY5XGTxO6rltF2ZyzEfVn5LQ2/sbmnI+rPyXbrDQUMnD7K6BZ7NS4bgNUfKSpHTBuy87UHYFJPjMf4LQUf0b2SY4m4+C9L2+zQ4GGhX1LaYwB6o+ScISeqoyXAs2C8yU30Y6Z+M/krCL6LtG4b5HwXp6C2sbj1QpsdFG37ITvRQeqpOurxsvLX/wByvRkbOcPgmJvoowuB4J3tPuXrIU0Y+yEr0dn3U70Qd6h/i0ncvHNT9FOujyYK0j3tVPV/Rx1PRZ7iojkx0LSvbxp4z9kJJoYXc2Ao9F7ilF2d+Zq8FVPZJrK35zRMmA+4cKpqdM6ht5Pf2epAHVg4l9BZLNSy842/JQp9I0M+cxt+SQ07xsVKLnEfaavnvJUT05xNTTQkf7xhCJtyYftBe863sytNYDx00b8+LQsrdvo/afuPFxW+Ek9Q0AphilHRTtraZ3UheOhWNPVVN91JHa4Cc8Uh5AHdeo799Fu0CKR9OJqdwGcRvOPkvItz0jLqPtAmsltmfOyOQxh8n2cEg55eC7zg+xR3etdJXaQQjmf5DYe9dLZqWnr5nPe7+WwZcszUXK4Xyc5keWHkOgVhbdNBjg+ciQ88YWu1B2e1WhIw2qq6bIHs7g/qs03UcUTsFrceIf8A+S9FrL5fblC6n4dozFTDQFrQCR54HyXQTV1xrWFlsi5Iu8bn3/otLRtETGtaMAdFLM2BzVVbauW5tD6ammmHTu2Fx+QyjrqmalY90sEsWB/aRlv5heGVEFRBUGCoaWyZ2I1z71xb6aWN/I9uHeKXc73DbmF0hOegCzNRrWRzj3MZx5qkrKl9zrnF52J+StqWkhYwADPmV7RLarBwhTRfxaMz1Egzy5wAF18lJb7LGz0thklcM46BHBrOYP8ArYwG+AWiortHXQh8bsrK3OhjdEXNAa4dQo9gqzDViMn1XAp9dZ7LxDZJbtZojFJDq5vTA/e6WajobnQPrKJnI5m4V3qmc+h8PQlZ2GudBTCKPaQnmFcX93e0Z8t1R26PjqB5Ld4SFGOEpKmqbzCF7nFvQkAcufDVXbQIP4M6WYZDHF2O840yn2W2af1pHblNz218A4mnOFoY48tGyTPECDsuIj/Ei8x1Aky3s8+wGjGO7vXPt4muLZA/I5f6caYVTartLC8RPcS0nG/RTbwRPSkg9FSVcfcVBxtvlWTZe+oxnfbC6rieClp6qg4loW8rZC0kDv3ytm7MijlprpTjAcRnzUS0VQppncRwCEq7V4q3tax2WBV/Dl/D54Tr6VzBnOfcvSq2ksVHxBHdKublmkaOUH2dsc22/vXT1EVup7m2rnkxI8aA7d2VbWuBrIwep5q4Zs3oszQXA07g1+7Vfw1TZWZacgr524zs9yt1wkqK31hISQ4bH9PJebXmgqqWpdLUa8xyD0Ki3hnHA4qrtE3dTuB5EZVxWnvITus0HGN5xsRsvQ+A4Re+H66zk6nBHv8A7gLouH4vT7bUUOd9R+/cpU8hrK3x3Vw+AeiFnkqq1R8UnEVelv1R26LnuOLm2nuNPbaY+pTBo9+mVlcQVAbVRUsXswgD3rP2qTuLhGfPhW3gm9UbrBy/U1hI2w7K11JJxMB8ld/FCMTSUVybtLH9Nf8A5K3xXGJJIKofnb/f7q2bMOWUJJQQoocB1RPkBHNeF5XC8qzGpWYqmv5Z2KzNx0xablH32JKStPtSRHLXnzadvlhbW60QrcZJGN8hQ4rRE32ml3vXvVJxNw9U8P01Bd+Zz4jnDR5410Gx713LLla5rbFSV4LizoB59dO9ZvSQrdGelQUU8dTa6v8A6xbKyITUsh+8GEeo7zbg9OWyaN309a7kGXCqjsVPM7d4ie9rfcGgk/AFbaKhiYPViaPgly2mnrWGOogjmjPNkjAQfgVQHG9qtYd/BKERvIxzuIJ+n3VT+N01Ewi103K7vdqf371DZ2WaFv8AcLRfdP8Aa9p6e4UlXDOKOvlbSOLQ8Fw9dwI2zzaF1t9ph+kJqWtprJXui0NpWBtJR1jB/wBeqnuzJKOhaAC0Z+9kYyVyOLs50x3zZTp61ukznidSR8/kvV3Y5RQWDsxfVuY2Ns8j5MNAAa1vqgADp6p+a8viu1VFXfxCOQ9rnOTjdci2oqYJPSub+ZnOfFcUvfZHabFXNpWyzVT2tDnueeHc9MDy/NO0ejaClAMdGwH7zhlbasBr66apkGXyOLj5eSDado6BalXxLeK4f6xVPI7uYgfAYCtzXKvqP8adx9+PkFR0tpbFjDGtA6NGFYtp+Fu3JTe6AHJE5uFzjnFxySqAGNSquenBOSEqzOb3tTSl27h3rB7sB36fin6jkVjNSash0cYrtOQIKedhlzv9W5wa8gdTwudjzwonHGCp2s5wQnu0q3GotRc0cThnks72WtnhrJGPie1j283DC6zd7Y1+WOw9p3GNwfcoFLamUz8sYGrvqXiUwWGWyuj5g85Bzt7lpxXcxW59vLMhxznuUxsYc1NSR4UxkWAkyR5C4NYeVm7nbg+ZtTE99LVsGGVMB4XtHh4OH7rgR5I6TXEtuIivUOYhsK+lYSwf94zct94yOZPCFaVUGQdlR11NgkgJmrdWqy0teOVwWxp6mGtp2T000dRBIOJksTg5rh4gjYpXwXLG09TZqt1VaKk26dzuKSMN4oJj+/HkAn94Yd5rUWLtCpqyeKju8ItNbI4RxvL+KnncdgGP2w4nGGuAJJwOJSiQHQpjqdw1ZqFqXNSHNyFJkhLcbYTTgpN1FghQpmc1BqIgeasKmVkLS57g0DqThYbUWv6O3cTIi2eQdGuWpb7XWXWXsaOMvPh+qv0lLPWP5IGFxS75d6K1PDZpAxxOACUTY2VcQkb7LuRXNayqqtU3MSOY4Bx5DcBdOtkBhpImE5LWgErsOJuHabh+lp2F+ah2S8ZyAt+6W6K2xRNLsyn2h3Kqr4xTxve4eq0ZKy7tRUrnS944QxsBc6R59UAcyVubtSCpgfGRs4YXPK/RDZ4J6eV72xyDh4mH1hvsfnjms2yRWR1FUuuTiJQPUx++/vVeiFvdDKaskP8AyqMLvUXaB1TSU7qehPsT1AIfKPFjOg83fJRKSZ8s2JHOdnqTt8tgraCmulspxFWNFzp2AAVEAxKB+9H1/unPknqGkpqpvfUz2ysJwS3m0+BHMHyO6ltdzt9Hbaimqabnkf7Lu7/xvopaasp6amkiki5i7Y9yhgOGQRt4hc+7QuzOK+wy11sjbFcgOIxjZs/8nefXr4rrwoQBgjKqrwYKDhIjPE452XMUVuqrlUNpqRnM92w/8qhBC6teII25cV5NdA4OdHI10U0bsFp2cxw/Igr092F/ScDnU2ndcVQjn2jpL7KcNk8GVB6O/f6/a3y48s7Y9Nd36LqilZwRySCmrWAbZPsP/DhJ/hWHkomvbwPaHAjcKCspJaOofTVAw9hwR3ELKlhko5nRPGCDgr6Wsq4muDHvEch5An2vcpUMwPJeQdIagkobdaakzTGlpo2kRteTwtA5AL0xpjUtJfbNTVtHUsrKSVv1dREcgnwPgQdiDuDkHBC6riPhh3D0VPKZe0bK3OQMY+Z6Fbt2tBt7I5Gv5g8Z2VjqzV0Ok7eKuaF8zSeHhZzVbobtHj1i+QNpjThpOznZKgdpcPpul6ke0WYePgub9klx9Cvj4ScBxH8lv2mxUNw4Zqa4MzPGd8nbTpt1U1Hbaaqs81Ry/wA1h7+nkumdrd+udosXf26pdTODhxOZzwVV9ieqqu709whrql9TM14c10hycEK07RaX9oaYqmYyeAlcm7MNTQ6avM0lQ4thkjwd+o3W5ZLfFduD6qKGIGZjsggDmOoOM796vW+mZX2CdkbAZGnu16H9V6fjfkJwHK5JWduVBTtxCzvD5bqsZ2/8MoBoi5v3icALjIeB7/M3nbTkeeB9Vz0fDd0kbzCI+/RduSgcrI6Q7Q7dquP6iThlHON2xWsBDguNrKOooJjT1TC143BWDPTy00himaWuHQpaCSHJSpqugjyUSCEIIIIIQggggkwhFjdERkpfChwpMITZCbe0+CfLEkx5RhCiub5JstKmGPKIQZUiaoXCjEZU4UvknWUfkhMUFkJUiOnJ5hTmUafbTY6IQokcCkMiwnxDhKDPJCUJoNSgEvhQ4UJUkDCCVgI0ISEEtJIwhGUSBGUEEYQUXCiSkk80IQSHORuKRnbzShCLOEhzkbnAJiR+EuUIpHqHNMACjmmx1VbVVOAd01KBlCpqg0HdZXV+sbbpCyVd3u9ZHRUFM3iklkPyAHUnkANyVH13ru06D0/VXq91baShgGM83yO3wxg+0442HvPIEryvca28du19hvupoXUOmKZ/Ha7ATs/wlm8SfDr7vaVW2Mx5/vfwTlzuV0+kDfYrxeoZaDRdLJx22zvOHVZ6TTDr5DljYbZLugQsbGxrWgNa0YDQMADwTEIDGgAAADAA5BSGphdnRWwMa9U81OsTLT8E40piCnmlHxJsOwhxZQkTnEjyE3xeaGShMTvF5ocXuTfEhxIQneIocSa4kfF5oQnOJDiSMlDiQhOZCCRxIZCEJaPJSEMlCEvJQ4kniQ4kIS+JDiCSghPS0EhBCEtBIR5KEJSInCSiJQhETkpDjgpROEy9+EITNZN3cRwdyqd7t1KrZeJ+OgUIndCUIIIIJwSIJSSlA5SFCCCCMc0iEpBBBOKcglpCUOSVPSxyQRAo0ISwcowcJAOEpCelowfBIBwjByhCda9PMkUYFKDsJMJi7jwouFOliLAUmFz+U3w7ocATnDlAtwkwjKaMeUXdjPJPAYRpuE4OKOnq56VwMchHktJaNf1dvcA8kgLMkAoi34phYCp2zvb1Xa9Odq1NLwiV4afMrpVm1jR1rW8Mrd/NeR+DByNj4hWNvv8AX2twMM7iB0JSchGyVz2Se0F7Ppa+GYDDgcqcxwcBgry1YO1+po3NbU8QA6jkuoae7Vaaua365pJ6ZTg7G6qPp86sK6zz5IEDCz1v1XT1TR64+auYa6KYeq8KQEFU3RubuFIQGUXGCAgT8U7ChSuIIcQSemUCcJUJXEPFDi/0Ug80SYnYVNrGWRtguBjwHiB7mnzAJXzZsevxpHWF7urY2yVU5kY1jgcAnrt4FfSTU4LrXUjGcsOy+X+o7THQ9pNbQTD6o15a4Hwc7/Ne6/hnFBUx1tPOMggZHeBnI+i9U4IjinZVQyjIIGneOq6toLsQvHao998vlfLDTzHiETw4n4Z2W8uX0SrG+icKepnFTj1Xu2aD7gu9dntgjorBQwADhZE0ZHXZa+W0x937IXKXDja7PqiaaXs42nDWtAAAG3TVc9V8T3KScmnk5GA6AYxgL5s3i1XrsX1hF6zm8Ly9h+zI0HG69mdnMth7V9DUtTLSQumlhaJm8A2cuf8A0t9HQz6fhuAjHfQhzQcfFZz6HWpZInVlA95LCz1Rnlg5/JdhfHRcUcNMvT2gTxHBI66/srrLhObzY23LaWM4JHX97rpN/wCxLRdgp5q2sooIadvrOcWBefdbam7O4ap9PZLbLUytPDxNZwAlXv0qu0asvOqotP00zoqaJ3DIGEtPHywfJa/si7I7Ra7NTVtXSRVddK0Oc6VgPCVhx2a2Wy2xXi/80z5fYZnp4lVoYIbdRMuF0c6Rz/Zbn6rzvVWW4XdpdRWmdkR3GSSs7Q0MkV8hpZswyd6GOBG4JOF71q7bFTUkjIoo4mlpGGMDfyXirtJa2g15VywuBIkD8tP2h/5Lt+DbxR3n0m2U1K2FjmHbXOdNfiul4fukdzM1IyARtLemuemq02oezOvoaB7+ISANzsMLnFmiJuTYjs45bjzXqikuEV807SSnDhJA0nO+dt1501rp6bTN7dPE0iNzi9rh03XJ8CSRTU9fw3Uuw6UENz34IP2Wbw9M2WOotk2hcDjz1BVuyy1DRngdj3Jme1ytByCrjTeuqGroo4qxwinaAMke0nL3qu2U0LiwtkfjYArzKfhO8wVho/R3F2cDTQ+OdsLAda62OUwGM5XNb1GYqvh64UqipnupQQNiE3FDNqC6F4YQ1zsnwAW+pLHGyFreDkF6ZxtI21WWgshdmVgy7w/f2XRX17aSip6AnL26nwXMahhiqHA7YOVbx0zpIgcHBClah03VOuGYIS5pG56LRWmyuFFE2ZmJA31sbqrxvX0tys9tqYpWmVrcOAI5hoNxuNR81DfZ4KujpZGvBeBgjOuw/RYWroHN3a0+5MU1XJSvxvw9QujVNhY4eyqibS8Zl4jGCqFl44ZHROtl7iM8ONNuYd2p/wDKgob4I4DSVze0j6d4VNHUCrjJHhyVRNTSd84Bp5rcw2NkTcNYB7kb7IM5IWFZOKzw1VzzW2PLHjADznGuemMqjRXU2yaSSkbo7TDunwWat1MY2gEK0ETi3kreG0hg5J829uMYXFVdVJW1D6mU5c4knzKxnuMz3SP3JyVkpLUySUuLeIqypoTGwDGFd/s4HolChAUtTcKusYyOolc5rNACSQPIdEr5ZpQGyPJA2ydvJVzW7ckYZhWJpB4JJpVnYUWFVvgz0yiFPhWTqUpJp8ckuqTAUERY6YS2tA5qSYR1KSYm+KROCQHBoyc46r0BV1YtmkLRZYz6zKdhmx0OOXzyuG2miFXdaODHE2SZjXA+BIz+GV1yqkM0znu3JUkfUqCUZIUYDCNK4UasBRJsjZIc3ZPEZSXtQUmVXVXqsJPQLz321Xz0mEUDHbSPyR5D/PC7xqmrFutM0v2iOFvvK8oaur3XS/1L85ZGe7b8Of45VV/rPDVejPZxOk9y9N9h+ohqzsksc8j+OroA62VG+SHQngZk+Jj7t395bVsYAXBPonXsQ3PV2m3uHDKyG7U7PP8Aqpz+FP8ANd/A3wrRCywchILceSQ5uU8QiLcpqcoM0WQVU1lPsdlfyMyoNVBkEppCe12CsjW02x2XOu2O1i4dmGpoXNDw2kMuDy9Qh+fhw5XULlNDBnjcGnzWT1QKe66Xv9Ex7HPqbbUwMbnfidE4D8SFM2nmID2sJHktFjHvYSAcLh/Yx9KS9aFhp7TqcT6i0+AGMmyDWUo/dcT9Y0fdccjbDgBwn1tp7V1k1pZ23Sw3KC6ULtu8iPrMPPhe04LHY+y4A+S+b8IDoQeQxsrzQl2ulg1LT1FouFTbpnkMkfTvLQ9p34Xjk9ud+FwI8lagpnVMzIo9C4gfFZkEpfI2Fwzk4z1XrjtA1jNWVrrfRPPAPVcRvxFVVn0S+cNkq+R34QViW9oEOl77TmuoJrk+fcmAjiac7kNOAfdkLc1Pacx0TX0tOabI2FQAHD34P6r6LnZcqBosPDkXLyAdpJt6xHevV5BVQD+GWluOUDnd4nxWlo7HBQlrYowzC0dJEGRtBXLIe0OrL+I8EvkCtrpzV9PeAIye7mH2fFeX33hK+0LDW1g7QdXA83x6rmKyx3CnaZ5/W7znKvamJrg7HJYHVOpWUkzoKXBkGxJGQtbqW4Ggts0gOHYwD5rmWnqT9p3MySDIznfxWhwfZ6OSmnvVybzRQ7N/qPirdnoYOykr6oZYzp3lJxdKwcfG5oPgcKFK6qoqoSlz4KjGO9b7Th4H7w8iulxUDQwYAaPkqbUlrjmo3nI427ghdDbuM6a4VTaKromCB5xo3UZ0yrtLfo6iYQT07ezdpoNk1atQRyQtdcGNp25AFUzJhP8AF1YfJ23g4lR9ZUYbTte0Z4TzUHR1d6LXup3bxyHBB6qbqiGihbLTWyV4dGcTU8Y4qeI9QSfZd+63qRkAHKypreOFOK4BGf5RcC3/ACncKvLALReIw0+rkEeRXL+0mZ02hpaCON0s1VVwta1jS7hAcHuccdAG4PvC5xLDnmCD5rtAxvsM4xv+Spa2xwVhdxRNOfELK/EWk9G4glcBo8Nd8Rg/MFZfFMPY3R7ujgD8sfUKPombv7AyN32CWkeSzVm19qHsj1TU1lhnDqeSQmqtk5Jp6keY+y7wcMH4ZB2FhtzbZ30TNmuIdg9FkNdWd7q90zG5D911V/8A/U+C6GsOpj9U+7LfsFsXE+l2GmqBuzT7fZemND9sen+17T9THbpDSXRkJNVZ6lwE0W27m/fZn7Q8RkNJwsdpmc2/VEe+Mu4SvMDqaajrIKykmloa6ndxRVNO4skjcOocN13HSuoai5U1HcKyRrqgYdJKwcPEersDYfDZV/w4cJ4663H87Mjz1H6KPhd/btqaV35m/wBl6nrwK6zyNO4cxedoaBjr+KSbLYzMWHHhld007eYrhZIXOe17Xs9SVhy1w6b+fiNlxnV0P7N1XO4dJBKP9fBX/wANZnxz1tvacOIJHgRp91LwkXxS1NIDgkaeY0+66Za+zG0xgEwd8f8AtDlTLr2dW6oonsbTiNwaeEtGMFazT08dTbaeckYcwOJPuTl5vdttlK+Sapibgci4brzY3y+zVYxO9zwdsk6+S4n+IXSSb/FcXA95XnehqKjR2pAGvILHAOx1GV6ktVaKukhmH22B3zC8u1cp1HqwugbxsdJgY+7lek9PQmmt8ER34GBuV3v4lcr46KSYATlvrfLf3rq+L8FtM6T/ABSPW+S0AOUYOE004CUDuvDV5ynAco03ndKzvlCEpBBBCEAMpQGETUpCEEfCg0JQGUuEIBqV3eUAEtoSoRNhBCcbA3qjbyS28kJMI2xNHROBoHRIGUoZKE1ODGEAcogMhHgISFGgjAQ4UJUnARpSCEJKItS0kjCEmqQglpJGEJd0nhSeSWku5oQiSCcJRPRIPihCSThNudhG52AmJH7IQikkUSaYblHNNjO6ramqDQSTgBCVFVVPCCc481hu0PtFs/Z5pyovl8qvR6KL1Y424MtRJ0jjb1cce4bkkAEpHaN2jWfs805PfL5UGGjjPBDBHvNVSn2Y429XH5AZJwASvKNZV3jtU1QzVOrGhgiyLbZmnMNCzO2R9p5wCT4jyAaqssZjzUirqrx2xaji1Nq2P0eghJNqsOSY6dhOz3g+087EkjfyADRtoDjCrISp8LsYTScq2AGhWMZT7TkKHHIn2yBIlypLXJYOyjtkCWHpiE+HI+IFMh6UHeaEJ3IRgpoOQ4kmUJ1Di803xDxQyEqE7xIcSbz5o+JCYnEeSmuJGDlCE7xIZCbR8SEJxHxJtHxIQnOJDISOJGhCWgkI8lCelZKPiKRxIcSEJfEhxJOQjQhGSkOKJzkkuTEIPcok8vCClyybKvqZc5T0oCjyvy4psHKJxyUSUJSloJCWnJqCNqJAHdIUJSMc0SMc0gQlIIIJycgjaiRjmhPSkocklGChCNGDhEghLlKByjSEYOEJEsOR8SRxIFyEL0EWg9EXDhPluEgt8FKubymuHKItTqIjKEuU3jbdFjKdLUksSYSgpshEQnC1JISYS5SCMoiMJZaiSJUghHFI+B3FG9zHeLThGeSLhQlytJZ9fXK1lodIZmDxO66RpvtbinLWSSmN/wB15wuJ8KJNLQpA/oV63tGuIqhrcvBz5rT0l3hqxs4Lxta9T3GzvBhmL2D7DzkLoWmu1uNz2R1DjTS/vHY+4pMuamGJj9tCvSYkDhkHZK4hjK53ZtdMna3Lw4HqCtVS32KoaCHjdODwVWfA5quc4RF/UKI2sa4ZygagY5pcqLlKZurRLTyNPJzSF84/pGWOTTnajUytHAJg2ZjvP/WF9GKqUOjPivNX0mey46xtxuNHHx19LHhoaN3DOcL0fgK9RWi7D0g4ZIOU+Gdj8V2nCley23AGU4Y8cp9+y6t2Nasg1Po22VMTg5wgja8A9eHH6LoUtQODmvnh2P8AbTceyK5yUNfFI+hLw18Z5sx4Lv1V9LzTYoe8YS2Xhz3btzn4Ke/8E3SmrnehRGSJxy0jXQ9FYuXC9ZBVO9HYXsccgjxUz6Wl1hptASxFwE8jwY/PHMLjP0UaeSOuuFSQWxgAtd49CFj+0jtHvHbXf4qeniJpmv8Aq42DGPMruvZLpOPRuno4CMTv9aTbkV01xYOFuFDbKlw7eY5Le4afot+ph/gtjNDKf5shzjuC4p9JKyVFF2gz3NoJgqGseH45P6roHZh2+2mCyx0t0e6CojHCABniAC3GvtO0Wp6B0FXGHjmD1C4Lc+xBsVQ4w1ZZFnZuMlQUV+sN+s8NtvjjG+EYa4dwGO4+9Pp6+23Kgjo7kS10egIXQe0H6RVEyikp7Sx0tQ8EB4cNl52vVPXzYuVYHE1LieJ3MldSs3ZRQ0EzZZzJO5u4ycBaqpstPURxskhY9kfshwzhOpOLLDwo9sVmiMgPtuOhI6AZ8VNBebdZnBlvjLwfaJ0J8Aqjsrvz6vTcFK8O4oG8IJB5ZVpqO0w3SF8c0YeD4hS6SmZRjhY1sbR0aMJ+X127heQ3K5CpuMlfStMfM4uAzqCTnfRclUTiepdURDkyc77e9cguPZu3viYJTG3PVM03Z4xrvrZHPHyXU5qdrjkhMGkaDyXTDj3iARdl6Scd+Bn47rU/jt05OTtdPn8VmrVp+C3sDYmcI81dNpsN5KZ3IbjbCB25LhKiolq5DLO4ucdyTkrDc58ji+Q5J6lVU1A15yRhCOlDRjCsXeTUg4HMKsm8o3UJ8IIxhMPpGlWDsFNEJMKRQTTAdEh0DfBTHJtwASoUXugERYAnnHBwmyQhCbc3CQRlLcQm3OQhJI2TaU4ptzsIS4SXHKQ7CDnppz+aEYRPOOW6bLieaJ0iQZN8JCnALTaCpfSNQMkx6tPG6TJ8T6v/AIs/BdEcMlZXs2o+G31lWRgySCNufBozkfF34LWkbqdgwFTkOXpvhRBuUsjCPAClUabLUhzclKL2k4zv4JQbkowmrmfbBef2fQFjTvHEZMeLjsF5pijL2d47cvJdldg7e7q4TVjAfZBaPeAMfisbSaLeLNQyueWSyxCQNI2DOTfwGfioIGGWRxHRT1sgghY09UrsXun+z/bHpepLuGGukktc/wC8JmHux/8AXmwr1tM0MncPAryFBYJrbVwVTi3jp5mTxPacFj2ODmOHmHAH4Lt3ZbqSquj6htZUPqJSM5eck/6C7lvDNRJZXXkPHI045dc/orVPa5Jbc64tcOUHGOq6cRlEBlBjuIIyMrjVkJD9hkrEa+1hHp+n7uM8VTJyaDuPNbWofwRE+AyvPep6x9+1Y9vFlpk4Wg9PJeh8EWOC8V7pKsZiiHM4d/cF1XD1vjrqlzp/YYMlNshu+pHumfNJwk83EpitsFdbB3gcSMbkHddVt1thp6GKMcLWho2yq69NpYmN43txnG5XTu4+rm1XZ0VO0QA4DA3ce7qtZvE1UZ+WniAjH5cdF5Y1xomKmidWUkfCxoy9g96yujgG6jpGuHqudwnPRdtvFMJ6m6U5AMRkdwHoWncLjZp/2Xqfh9kMkBCvcTWqnobhRXmlZyxyOaS3GMHOdumQmX2hipKynuMLeVryCR45XVbjBT0bXV0wD3RNyAQuR37Wlfcal/BUOjhz6rG7LqOsi6bS9RJHzDA/bwXCZwclaH4k3KopJ4qOlcWMcOY405iTjU9dlJxpWzQSx00BLWuHMcaZ6aq1tupa231TZWVD3bjIc4nK7XpbUcl1tkdXTSGGpDSct6O9y885PFvsuo9k1U5zZot+Fp5LC4AvM/8AEP4bO4uilBGDrqszhG4zNrPQ5HZY8HQ66rdW3tjvOo7lPpu526F8jWd4KunJZ6o6uacjw5Ec1f2q7S2tzzG0PLuhVHpKwMdqC81/COIRNgYfecu/JqtKYiGpHFyBwV3nD8FNTUdztZi7QRPLuTvGMgfLC7i2BjKerpHN5+RxPL3jcfRWkuqrhMcd6yEee35pl3pFa3imuDX5+yx/G4/BvNWkTGFg4QDtyUarusFsJbJIOL/dsBcfw5LzWTj40hLKCijiI8MlcqeInx+rS07We7VRqOzSGTjc98LPAOw8/EHb4HPuVzUtZHQiCKNsUTG4bGwYACqIdUU0mT3M8bRzL2/+aW3VFprOKJldAH/ckdwO+TsFc3fLhd66SnuFzBAOrDjGRnosi4zXGodHU1g8tMKke3DyD4oNiyeSdqwG1DscjuEkSAdF6txlYa3iRtDXW+PmLmYd4bEfUrsr7bqi6inqaZuct1+v3Ki8HBUZ8VDvMAljGWh2dt1YvALsnZNyyRAeuRhatv4ekpeGZbRdpWRlzsgkjA2PXHj8VaprW6G0Poa17WEnIJO2391hLjp8zElkWc8lo9KUclHQdzK3ABI+Ck1t4pqGEyFheA4N+JIH6qHNqOQNPcwAfxLnrGzhzhKq9LdcO0fgjDRka+Q+6zLebTZJu3dVc7sYwBn6LPU2vNS9lmpJZLLVd9b5H8U1qq8up5SeZHVjvNvPAzkDC38XaBQ9ojYq2lppqGrDeGein3cx37rhs5vPB25cgueXmB14c58wAeeRAWUrqOWlzE9z2jmCxxb8c+K4W38RwWe/S3KmYXscXYG2Qfiuapbq233F9ZA0uYc4G2/0XpaiuuoainjpqZs5a0cIG42VhDojUN3cDVEMYefG/f5Liuhe36/aOMVLe4pNTWduB3hOK6Jvk47SeOHbnYcQC9P9nfaBp/tBtxq7Bc47g1gHfUzvUqKfyfGdxvtnkcbErYqPxEqWEmipY4s9cZPx0+iuycUz6+iwMYT4ZP2UrRmgoLI9srmiSf7/AILpdDHwNAVVQPiePV2d90q3hfheZXC41N0nNRVvLnHqVxtVPUVcpmqHczipjXJYeFGa/KcDllqmngcpTU016W1yEJwHCPO6RxJXMIQlg4SkgFLTkJQ5JQGySOSWhCUOSUNgkjkljkhCUOSWOSSloQlDklNSUY5oTcJYOEpIShuEuUiWN0ETSjSIQQQQQkKCBGUEEIBSUR5JTkk8kJUlJJyjPJJQhJcmnuAylPdhR5JEISZZMBRJpsITTYVZV1YjYSSA0dUJUKurDASTgDqsD2i9o9n0Dpye+Xyd0VCx3dwU0W89ZKfZiib1cfwGScAEqL2ldptq0JZv2jdJHua9xjpKCDeetk+4xvyy7kBzXlLUF8uuvdSDUGpJGPrGAsoqCI5p7dEfsRg83HbifzPkAnNGfJTsaRtunrrdbx2nap/2m1PwskjBbbrVG7MFuiPQeMh24nePkABfQYYABthUcNYyMYClNuLfFB1VgYaFfRSAKVHNhZ+KvB6qXHWg9U3CdlXrKhPtqB4qiZWDxTzKseKbhLlXjZ062fzVKyr80+yqz1SYS5VsJweqWJcqsbUeadbUZ6pqcrESJQk+CgtnTrZvNCFKDkYcmBIlB4QhPcSHEmg5KDsoQnQ7zR8SZ4koO80JidBRhya4koOQhOA5SuJNA5SslCEviRpHEjQhLyUOJIyUfEhPS+JDISOJHnKEJaInCTyRF2ExCNzk09+Ag5+yYlkwE9OTU8uMqvlfkpyolycKK52UIR5yUaSDhHxBPQjRg4RIITUtBEOSNCEpGOaIckY5oQlIwMokockJyAGEaCCaUIIIIJydlGHIcQRIISpWQhkJKCUISshEXIkROEqF6RLcJGNynnBII6p65nKbLURanCMpJGEIymy1ElkYREZQlSHcklLISSMIS5SCMIiMpaSTlCXKQRhBKSSMIS5RHIRcSM8klJhKEDhJe0OBBGQlE4SScpMJVLtt+uNkeHUs5dGP7GQ5afd4Lf6Z7Wo5JGQVBNLUn7Eh2d7j1XNDyTE8LJ2FkjQ5p6EJhaCpmyFum4Xpy065ZMGgvWip9RRzNBDhv5ryVb77crGR3UjqunH9k93rtHk7r7j81t7D2jMqQAJSHjmx2zm+8KE5arLWRy+zuvQb7s1zdnKiu8rKiNwJznplYel1iJWjLk7LqISj20gfhBp8LFa57KLHqSd8s1K2Oc/2rG7hYJnYJYqWXI7yb/vHfouv1d0EmcnKqaitBJXTU3FV4o4uwgqXBvdlbUFwuEDOyimcG92VSWDR1q080Cko4YnD7QZutOysEDcZwqaSs88KPLXY6rnqmsnrHmWd5c49Scqo7nldzyuLj3lWtZX94CMqhqy1zjtlIlrCc7qJJUk9VUyncoKDg0E4TT3bFIfMmXyoykAASnkApl790l0nmmnPwnKRG5yacUTnptz8oTkbnYTRdhAvHimnPQhGXDKbc7CS96ac9CEtz89U0XZSHSYTbnlCEtzuuUy52Skuf5ptz/NCelOcmnOSXPTbnoQlOcm3PSHSYTbnIQlOemnOSXPVdcLtBQgd64jPIAZVulpJ62YQUzC952AGSVLFFJO8RxtyT0CnOemXP3UOkubK5nGwHh8Snnvym1NNNRzOgqG8r26EHcFJJG+F5jkGCN0bnbqJNVsjBc57WgdSUKl+WHCzE1G8ykyOIZxbnngLp+H7PQXQyGvqxA1uNxkny1C1KClp6nmNRNyAfNdutet7DpywUVLLXMMzIw6RjPWcHO9Zw+BJCrK/tqtkWRTU09QehPqhYe/aBfZrTJVGQPLMHY52TOgrbTXSsljnbxEYIC9cpOFuFYbbLdGvfOyM4OuNdOgA7+9dDFa7M2kfXBzpWs31x3d3mtI/thuddUsZT0DIoyQMnLjhbuur563TLpWvdFO+IkluxBwoVv0tRwYLaduR1KuamkxRPYAAAOQXnV1ulonlh/hlJ2QYckk5z55yuSra6ilfH6JByBp88rjvZ/faqPV8Lampll7zijIe8ndd1pXcePNeb5pDY9Uuk5dzPxfDK6DL2wQU7QIYuIjwC9I424ZrLzV09Xa4ctfGM40A6j5FdbxBaZ6+oino48hzRtt+9Vzft2YZK2tDyQx0zuIjmADutzrihjo7yYYmhsUcTGtA8MLA63rxrN9QZQYmylxJ6jPNaC4av/b1TFLO0Ml7sMcRyJC4AcB3y3QPmliBG+hBPwXJXrhy5CJkzWZDQc4OT8FW3FnFCVc9l9aaa+sZnHHlqqqsB8RA32TGl6k0V8gcDjDx+a7nhMen2G4W474JHw/VXuFHelWusozvuF6RpnZaE+olFJxxNcOR3UxpXgJGDhcYFEuDj3EmOYBXm69cdBqGpczZ7ZS5q9KVTC5rhjmFwTtJtL6C+mUNIZI0HPmvavwuq447hNSSf+43r1x0+GV6BwdOxtXJA/8AO344TbZ9R3FoxI+Nh8NkT9I3KZjpKiZzgNyCSVt9E3KnvFAxmWiaMBpHXktNLa2yxOHi0hF040uNoqZKOCmjhLTjRoz5ptVxBWUUzqeOFsZBxoF5f7R7jU6MudNStHE2enEzXEfvEEfgPmuUXGvfW3D0l/t9V6C7ctMR3yXT8kZAfCZo5cHcBwYQf+ErhWorJ+x6zuu8EmRnIXNXGt4gu1vbca5xMPNp0GfALFub7pWQCpqXExg6efkukWqdl70y1hOS+HhcPArjd9s8lsrHwvBBHLK1Ok9SOss/BIeKF2BjwW0rrdadVRte5zS87gg4K9EqIoOPLVAYZA2qhGCCcZH9910UscXFNDF2bw2eMYIPVcOdFlw2XVOyu1PpKOaqkHC2Tx/NTIdB2mhk72advq78Jwkaj1lR2qhdTUDmPIGMs2wq9h4ebwnObteJWtLAeVoIJJKitlpbYJfT7jIByg4aDkkrqGjoRNbJajH9fM4g+PD6v/hKbvVCKd/eAgcXTqVeaQtUlFpW0QyD61tOwvH7xbk/iStRRaOEjxPUND5jyB5MHgF5nT8V1tHeJLrT7vJJB2IPQrFiu81LWOrWbuJJHQjuXLfS6hkJjD3MYeeNj80zHEDs1rnldfn0jTuPrQtcfMJDNMwROGImj4Ls5eK+HqiT0yW2gy776ZWy7iO3Pd2ppPX89FzKlss844iwtb5hSJtNCVnC+FsgP3mgrprbK3GwQdamgeyF57xBfqniCoE0+jW6NaNmjwXO113muMvaSaAbAbALkH7CdQNLIYe7bnOGjAUCa33Br8x1Bb+6+MFv6H8V2GazRv5sUCfT0bgcNUf+kd4EDaVtS8MaMAA4GPdhNN1rHMEXbODR0Bx9FyaUXOP2o6aYeXFH/wDbKJJVVTQeO3SH/upGO/MtXUajTQGcBU1ZpwtzhqwpKiWU80jiT46rOcBIcuOSuT6imqq+2TU1HTVVPWOLXRvlhywOa4OGSMjG2E3bbzDNG2Otjfb6wD6yKdpaAevC47Ee4ro81n4SQQmf2WR0OFHzlKIm5yCsNJX28cqmN58I3cR+QVXc4nXGAxwUFTMc+rIWd2B8XYXT22biOeFOtsIcPYz703mT+VcUfpq4tbxOjYP3eLJVY+31tquUVxo5aq03SA5irqOQxysP8Q6dMeC75Jptrx7H4KqrNJCQEcGfggSEJCwOGCldnn0urhZnxUHaDS+l0ow1t/tsWHN85oRt73MxjA9VxK9R6b1jQagtVPcrZXQXa2TjMdVSyB7T4jI5EdQdxyK8ZXbs/a/ic1nCfJZmy/7S9ll3fc9LXF9rmeQZqYjjpakDpJHyPUZG4ySMHdOy13gfkoXMc3/eHz/uvovT1TJ2BzHBzfyUpsnmvL/Zx9KqzXuohoNSsbpC/P8AVEkr80FQf3JT7H8L+Ww4iV6Eob+yXhbUDunEAh43a7zyg5bo5V+TmGWHK0AenGvUNsnIg5B5EJ1kmUqhwpbXBLacFRmuTrHISJ9vJLHJMtenGlCE4Clg7JoHKWOidhCdbySgdk014aOaKSrigHFJI1jfFxwE4Ak4CUDOykg5Swdlmbjr+w2nPpN0poyP3wfyWYr+3zTVLIGQyTVTycfVsw35rcpbDda3WnpnuHfynHx2WlBbK2p/woXH3FdPbyS2qqsN7ivluhrIgWskGcHmFZrGkjdE8xvGCNCs5zSxxa4YIS0YOEWcoKBRlLSgcpAOUYOEu6RKQQQSIQQQQJwhIAickO5pRKQ44KEqInCae5G96jSSYQhFJLhQp58ZQqKjY7qnuFwZSxGSR2GjkBzJ8AhKBlLra5kETnveGtHMlcc7Y+2+1dnFuZJVkVV0qGk0Npa8NfL07x5+xGD9o88HGcFVPbb25R6HAt1DFHc9VTs4oLeTmGjYeU1QRyHUN5u8huvLM1HUXe6VV1vNVJd7vVu46isqdy49A0cmtA2DRsAABsEvidlZazG26fuvaHLqa9TXq8Vcl0vMzeAdzE7uqaPpFE0+ywfMnJJJKYGoppDmO31T/NzcKwp6QNwGtDR4AKyhoxhOBCfyuPVZ8Xi4u9m2S/F4CcZc7lne2yf/AFxv81pBSjwShTgdE/I7k3sz3qjhvFU3+soKhvuw78ip8N+bycJIz++whTxFhOCPKTIShhHVJguokGWvBUyOvJ6qGaSN/Ng+SW2lDfZJHxTdFIAVaR1x8VKjrPNU8bHN81IjJCbhPVzHVp9lT5qnY8hPslITcJQrllT5p9lQqZkpUiObzTcJyuGT56p5siqY51JjmSYQrESJQeobJU8HpEKQHJXEmA9KDkJpTwclByZDkoOQkTwclA4TQcjByhCdDkabDkaEJzJQ4kjJR8SEJfEhkJHEjyEJ6UThIc7dE45Kbc5CEb34Ch1EuE7I/ZV88hJQnBNSPycpA3KIlAHCcEuUpBFxIwcpU0owcJSQljdCRG1KSRzSkIShyRjmiHJBCEtG1Egk6o6paCCCVOQQQQQhBBBBCElyJA7oIS5QQRE4RE5QjK9Oubsmi3YqbJHhRnNwSpVzKYQISyMIiMoQmyMJJGU4kkYQhNkZSUsjCSRlCdlIIwkEYThGUlCVIREpRGEgjBQjKCQlpLuaE5IdzRJTkk8kJwKJySRlGgmlKmyMqNPTNkcHjLJBye3YhSklwymkJ4ONQipL7V0BDZT3jOjgr6k1SJWj1/xWcezIOyhzUzmHijOD4BQOZ1C04ahrvVk+K3gu/eDZyQ+uz1WEhu0tOcPz71ZQXcSAbqEtV/l0yFo31Z8Uw6pz1VWK3i6oGpz1TcJuFOfPnqmXTKKahIdOhCkOmTTplHdMm3SoTE+6ZIMnmmHSpt0mUIT5lz1TbpPEpkyBIMgT0oTrpAmnSJtz1HlqWxjLnADxJSgEnATt0+6RNOcquq1DRU2e8qY2/HKp6nXVDHswvkP7oXQUfD13r8ejUr3ePKcfE6LSgt1XUf4UTj7lp3PTRkKxNRr2R/8AUU3+I/yVta7xLXUZfIAx/ktG5cJXa0Uwqq6MMaSB7QJ18ASrNVaauji7WduBtuM/JXb5QOqQZcrnNxuFTHdncU7y1rwQM7YW3hqe9ia4dRlP4g4YlsEFNUPkDxM3IwCMbHGu+6fcLY6gjikc7mDxnT3fqnqqrbTxue7YNGVnRq70ipEUFOXEnm4pnVN0LYxAw+s7mq+w0vD9aRueS6e12G30PD8l6uzOZztI25I95wRn9FpU9FT09udXVbck6NGqsb9d6yl4TEWtY7mcZKVY7w6sj4JXZkA3J6pVwgFRTuad9tlmKeZ9vqgeRGxWxYbfb+KOH5aGKJrKqLUEDV3dk7nu+Ct2+GnutvfTsYBMzUHqf3st3JJkLJajmL52t6Yyr6OpbLEHA7FZi8vL6w43HRY/4bUxHEAMgwWNcT9FU4ajJuI5vygq0sp4KZuOR3VmX4Cq6A8ELcKWZNl5/fKj0q51E39T3fVc/Vy9tUyP7yfqlyvyocrAXeScfKmXSDqViA4VQ4O63VjuMepNH11qlP8ATqSD1c85IuhH8OzT/d8Viuz2p9F1HG12weC0+9MU11mtFbBW05zLC4ksJwJG8nMPkRkeXMbgKLQ1cVPqSKohcTCZuJpIweEnbI6Hfkvevw9f6darlbD1bzD4EfUBdnw80TUlXSf1DI+BH6L0fStDmNI6pdS0cDhjmFHtU3e0sbgegUyYZC8RdljiO5edOGNF567RKT0XUkpxgPAK12ltIW2st9PU+jte57A7Lt1Xdr1F3dZTzgcyW/qtJ2V1rJtPxtkcGmJxbucbdF9B3q4VcnB1FWUkjmlpDXYJGRgjXHkF6Rcamd9hp54HkYODg+Y+yqNe6RiipYZIYhG1wMRLRjB5j9Vy2kjcLc178ieKZ8EgPQjDm/8AC4fJeitV11slstRHJVRCRvrsHFncb/lkfFcDuJZPc5zTes2Yty0dXDIz8j+Cxfw7fdzdnOk5uwLTzF2eX56ZVfhc1hn5nE8mvNnOMe9SaWUy04yfJQ4n9xXMdnk5S6VhZEB1KiVTCKgYBJJ2A6+C3OFqmBvElXBCf5cnNju3WZw5Uwtv9RFF7D+bHxXovTVUKq1UsoOeKMK7HJYzs6mkfYYGyNcxzMjDhjZbJvJeFXWnFLXzwjZriPmuXq4+xqJI+4n6oSbt5LIav0zFfKR0bxh2NnDmFsOaZmhDwQqtJVTUUzaiB3K5pyCoYpZIHiWI4cNivPM9ku+mawyQB44TkPZy+KmN1rf54+7ax73YxxFpXY6y1NlzlocPAhQDY4y7+rb8l60fxAhq2NdcqFksg/N+v/ldn/pQ2ZoNXTNe8dVwLV8dzorBcLvURk+jhpcHdMuA/wDEuHV9U+tmfLKcucV7M1zpQ3fTl7oGMy6ropGMA++WEN/HC8UwSd/Cx2MEtGQei5C+cT1d+LY5AGRt9lrdAFi3W6VFzDOfDWDZo2SSMJTa2WDPdyOZn7pwjeMghR3N3XMRyOjPMw4K5nBactOCnpbjPICHSuPvOUxRU7rndaGj+1U1EcH+Jwb+qQ5pWj7LaBty7SdOwHceltkP9wF//hTpp5JAS9xPmgB0r2h5zkhex7VbmGuijaPUibxY/Ja2OFrRyVVZIcvnlx9rhHwV0zcKgweqFdqD65HcmZKVrh0UaWlAPRWJGAm3tUirhVT4cJh7NlZTR5BUKRuEicCob4RzwmH04U5w5potRhOyq+SmB5hQ5reHg7ZVy5mfNILEYSgrKVlkDwSG/JVL7Z3bsYW+dCHdFDqLWJN8JpCla/Cy0NuDh7KkttgA9lXkdu4OmU4aYNCbhP5ln3W8AclGlt7R0WjfT7clFmg8U3CXmWWq7axzSOEFZi7adjmY7LAR4FdAngznZVtTS5zsm4S5XCdUaFimjkY6FskbubHDIVbpDtC1p2QOENlrP2jZWn1rLcSZIWj/ALJ3tRnnyIBO5yu1XK1tkDgWrHXbTTJSfUBKni7Rx5GDmTOxEpywa967D2RfSZ03r6aO3tmdYr8cB1nubg3jd/2Umwf5DZx+7hdwpLjFUENOYpfuO6+49V8+r92WR3uMgQhrxu13Ig+R6LqHZNrjXeiIm2y+10GpLGxuIfTHk1cHgBLg8YHg4eABaAuqpOFbzXgGmpX48RgfE4C0YbNcakgdg4+OMfHOF7EZIRz5p1sg6rjOlO12rvN1bS+jt9HBGcO4ngH/AF1U/tY1BXUlqhmt1bLTt4wJAzY79FabwrXsukNqqsRvk2ycj5ZTv4FUtrGUUpDXO9/0XXGSg9U82TBXJOxTUU1ws9VDVTvmljmzxPOTghdNlqQyBzj0GVkXe2SWivloJDksOM9/UFZdfRuoKp9K85LTjzVBrbtModEuYyeKSolcMhkZASdD9orda22rqI4PRnQO4eBxyeWQuB9ot+dqDUtRK1xfFGS1vlvuFp+wy5dzdK6kJ9WRgeB5hev13BVJQ8MGuLD6QA1xOToMjIxtsV3lVw7BS2U1Rb/NABOviMjHkpOqdaa1nvFXS007oIGPIYYWBuR71lbvbdTTUU1ZXVVTJGwcTuJ5xheijaYpHcYiZxHrw7qr1RZBVWOtiI2dE4Y+CyLdxvFSPhhp6ONgy0OIAyRoCdlm0vEzYHRxw0zGjQE418V550fp1uprg+B8nCQA7JPNdVtPY7QMLXSu43DwGVzbs4qDQ6ugjftxZjI816kt9Mx8TXAdMrovxBvl0tle2GmmLY3NBGPgVrcWXKvpKsRwyFrHAHRDT1Ay10LKeLIjbyyryM5CjxRiPCfHkvAJHuleXvOSV5gXOcS5xySnAcJSbDspQcoikSkoHKSgmpiWDhKTZOUY5IQlE52RIIi7CEInFMvfzRvkwoks3NCEcsvmoM9QMHdFUVGAqK4XItPBGOOQ7ABCcBlLuNzbA3fLnHYMHMlcA7aO3R+nKqax6efFW6oxwzVBAfT2oH7w5Pl8GdObttnVfaf24TXKSps+kKzYExVmoIiC1nR0dKeRd0MvJu/Dl27eJvo4qGJsULOBmSTvkuJ3JJO5J6k7lNLgNOqvRwnHMVBipCyWeaWaWqq6iQy1FVUO45Znnm57juSpLI0oN4sKRHF1wm6lS4A0COCPcKwjGAFGibgqWwKUJqVwocKUBlHwpyEgBKAylAJQGEIRAZS2oAJQahCA5pbUQalhqEJbSnWlNNCcbySYQnmlPMcozSnWlNwnqWx6kRyKExyfY5JhCnsen2vUFjk+1yRCltcnWuUVjk6xyTCYpAOEsHCZa5LBwjCE6DhGDlNg4Sk1CcDkeQkA5RoQl5KPiSMlDiQhL4kC7ASeJEXIT0bndU292OqDnJmRyEJueTAUCRyenkyVFcclKE5AHCPISUE5JlLQHNEOSU1CRGljkkjmlIQjHNKRAYRoQlDkggOSMc0ISkEEEISgco0hBCXKWgk5KJCMpWQiLkSInCEZRoi5JQJwhGUERKInKInCckJXrWaHA5KBLHgrZ3iwS0T3BzCCOYws1U0xaTspCuaByqtzdkgjZSZIyCUw4YKROTRCSRlOEYSSMIQm0hOEYSHc0ISXBIcEt3JEhCbcEgjZOJJ5oTgmzySScpaQdkJUCMhIS0k80JyQRhBKO6ShLlJPNJI2S+YSSE0pQkJtzU67miIymkJcqBUUzZAdt1XPifA7I2V45ijTQ8QKjIVqKodH5KBDWubsSpbK3i6quqYgwkhRW1PC7Gd1GWLYZK2QZCvvSs9Uk1GOqqG1RxzSvSv3lFhPwrM1HmkmceKx+qNRy2uFvccPG7lxDKoLLqyuqbtC2omzG444QMBd5buC7lcrY+7RlojaHHUnJ5d8DH3W9TWSpqaV1W0jlAJ8ThdMMxUSvukNBEZJnhjQoxq8MJLuS51qC6TXW5GIOIYHcOAdlFwpw47iKrdG93LEwczj3DwUNptv8SmLScNaMk+C0Vb2hQscRC1zwPLCjw9ohLwJYOFnjzKYt9ghijBc0Pf1OE1drHE6BzmN4XjfK7yGXgf0gUAgeQTjtCeu2cafRbUc9h7UU/ZuIOnNn5rYUV7huUHHE/PiPBZHUVurKu4FzJHmMjlk4VVpuudR3BkXEQ1xwVty3vBlZFyim/D68k0WHNe3LS4Z0P3GFWq2ycO1pNPghw0z3FYr/Z17WFzjvjKraKNrqtrH8icLf1FOA07LCVDfRbm4cuF69G4N4ouHEbK2mqn+vyZbjTG4+pC6Kx3WqubaiKZ3rcuRjp+9Fp6e0wgAiPPvVjHCIWcLWho8kVE8PhafJPvcA1fO9dXVdRI5tTI52D1JK84lkmkJ7V5PmViNQRd3XE/eCvrfcWstjHucAQ3qqvUzPXY/mqeOKSYYbkgdM7L6IZbaTifhahkrJxE2E6uPcNMbjGdF6SKaG6WmnfPIGBh1J+GPopEj3XKvLjyJWkomCNjQAAAFlI3vpJc43WhobmydgHJ3ULnvxGoqx8FPLRjmo2NAaW6geJ/VZ3EkEzmxPh1gaNMfUqylILVm7xS4cZAPerx0wIVfWESNIK8k4evMtiuEdZHsDqO8dQuToax9BUNqGdN/EKHaq4taY3H3KHVv7yrcemU04GCbI2IOyJruKUO819OwWynpKqq4joyOyliJ8ndfp9V6dHTRxSy3OE+o5hPvV5THhYE66XZQGSktG6W6RfIshL3lx6rx/mzqnXyqPJKkvfkpp7tlFhGUmWTIIURjuCTiGxDsjKeeSo0juAnbnv7l6X+H94prLdTJWP5Y3NIJ18CNvLC6Th+vioaznndhpBB+v2Xo7SFX6XZ6d/PLAfwWhfuxYrskq4Lpo+CaGRxkhcYJ4nDeN7SNvMEEHrs4A7grb42wuMuZhdWymnOWFxwfDOi5mp7MzP7M5bk48lzbtYtrqm1cbGF72OBw0ZK5varbfe7MdJBM1jjk7YC9CVdKJhggH3qCy1AOyu8svHM1mtv8ObA14yTl2SPh/dblDxFLb6T0RsQcM5yf0/uuQQaBvtfvUTtiafF2fyUK66TqrK6X0dzZK+nLZoC7Zjntw5oP7p5H3ld4itgaAs3ra0BndVLG8hwuPl0VC6cc3m4wuh5wxp3DBj57/NQz8QV9a0xPcGtOmGjH91zW9UkAkp6+i4v2fcYW1VPxDBa13NjvBzXZaR5KnmD4XCaBvFPEeOMH7zTkfiAtLSQ95R3GxEAGJ0l1tnuJ/pcA8PWLZQNy4uf0aqihoKm819LbqCmlrrhVydzT0sDeKSV+CcAeQBJJwAASSACVy8Mpc3nzqvOZYnwSloOy73RwxSQxTQHigkaHxuH2mkZB+SmDYBQdKUNztemqS3XmkNBdKDio5qRz2vdE2NxZHxFpLcmNrHbEj1uZU89VkEgnOV0ABDdQiByjO4SEeSkS4SSwOTToQnkTkJVAuFOAI5BzGQfivBmurQNM65v1r4eCOGskdCD/ALtx4m4+BC9+zM7yJzeZ5heUPpDWBlN2gw1Dog+G403ASR9tnX5fkhpwVZY3tGFi4lI4YKZcfNX1TphjPZfKwdM7hV01gmaTwzgjzZj9VZDgqToZB0VW94C6H9Hel9M7V6AncQQzS/8AAW/+JYh1in6yt9/CV1T6M9odD2kVTi/jc22yu9nGPXjH6pshHIcKWnieJWucNBqvWNqj4KJp5cTi78VNbyTNGzgo4h+6nxyTRoMKJx5nEpX2URGyPmEPsoTVHkGQVX1I4VZSjZU19lqYLbVS0kTZ6pkTnRROOA9wGwz0yUJwTcUzJ2uLDkNcWn3jmg5ZTQuo4LzbnTxFwbNK5xY/Z0b8+sxw6EHotU54ASg5Ce4cpwiPJDh5JDnhRau80lF/X1EcZ8HO3ViKGWd3JE0uPcBk/JOZG+R3KwEnwUzA6I8BZqq19aoAQ2V0p/cbkKsl7TYiSIqV2PvPK6mm4Pv1UOaOlcB4jl+uFtw2K5TDLYTjx0+q2zmjwTL2jdZSj7QqeokayVpjz9rotLFM2pjD2EOaeRCx7nZLhZ3BtdEWZ2zsfeqlVb6mhIbUMLcpEzmsblZq66lpKNxZx8Tx0ATmsbs630YYzZ79sjospZrK+6EzSuJbnkeq7SwcM0Lre69Xp5bADhoG7it63Wum9FNwuDiIxoANypUur2udtEXDx5KVRXeCvcGZ4XnoVJdpmAxcPd4HkstcqJ1orhjIAOQumt9r4V4n56OgjdFMAS0k5zha1JT2a8c1PTNLJMaZO6vLzRPdTkx5z5LNvoZxzBPvW8s4FytsMh3cRg+9LlsXHnbK4yg4luPCzZbdA1oc1xySMnI0+ywqe8VdoD6WJoyCdSNe5c4c1zCQ4YKqLl6QS4M3attqa1+htY8DAzgqNZbZHcGO4hkg4Xpt0vVfcuDYrlHKWyB2HEadSP0XWVdfU1dhZVtfh4OHY8yP0XDtR2vVFrrWXXTt0qaWrgPG0RP4XDHTwI8j8craaT+krWayo/8AZ7WFu9FvAwyOvp2cLJXf9oz7J8xt5ALqEmh4pm5AwVmb72Y0c0jZ3wN76IgtkaMEYXiNsus0dygqZ3Fxa4HJOTuvO6aSWOrjqQ85BG/X9Fv+xm7Nob1UwSE8EseRjxHkum6/1Gy1aZne14JkHAOHnv1Xmivu160/TPrrC5n7Up/WjZK3iZJ4scPA+WD4EK0b2n13aFZKZ9wtrrLWRHgngc/LCfFpPQ8/Llkr3G+2D+IcYwvx/Lc1r3eTdPngL0K5WxtXf4zj1S0OPdpp9gtDpOxm6wVtXM3iPCQM9SRzQ7M6w2zWtK1xwHl0RyuhaQtsdFp9kLm8LnN4iVy2pzZdY8TfV7qpDh7srVtd2HEk11oQfVLSGjwALfrhWqKtN3lr6b8pGG+QBC9XUcgfGEVewSQPBGQRgqFZ6oTUsbxyc0EKdOeNhXy+QWuwei8Z5cLytWsNh13KMY7mr/M/5r1Pp6pbPQQuByC0LzZ2u0RodZSyNGBK1rwfPqu5dm9y9O09SSZzlg/Je4cdD0+zW65jctAPngffK9H4lHpVvo63vGD8B98reJajxu2CdaV4YvOcJ0DCU1NgpQchNTgIwj4k3nKMOQhOIZwmjL5pDpvNMQpBkTL5cJh9RtzUWaqx1QhPzVGM7qBUVIaNyo1VXNjaSXY8yue9o/apZtCUDZrnUPM02RTW+mbx1NU7wYzw8XHAHUjZCVrC44C0eodTUtqoamqqqqKjpKdhknqp3hkcTRzJJ2C8udpHaTc+1mjrLZaJaiyaTlY5hqCDHVXPI5kHeOE+HtPHPAOFC1Nebz2l18dZqMMprdC/vKOwQv44YT0fK7+1kHLJHC3fA3R8BznCaX42WlHAB7SxGknmfTdLE+JsM9KDSzRNGA17PVP5Z+KVco+ENPmpdRT/ALF1e8cqW7s4h4NqGDcf3mDP9wpu+s4IgfNQ4w7zVrOY/LRQIGcZU1seAmaFuW5KmBqnaFTKS1mCnmBEGp1rVIkRgZRgYSgEaEJIalBqUGowMoQiDUoDKMDCUAhCIDKUAglAYQhGlgIgMJTQhCUBult5pLQlt5IQltOE9G5MjknGpiepTHJ9jlEYU+wpMIUlh2TzCo7CnmlJhCfa5OA4TDSnGlCYngcJYKaBylg5QhLRg4SQUabhCWgkg4R8SXCECcJJKBKQ47JqETnKPLJgJb3bKHNInYTwm5H5KZJyjccpKVCUDlGk8ilA5QhKHJKakA4KUOachLbzShzSRzSxzQhKQQSgEIQGwQQQTUJaCIHKNCEEEEEIQQQQQhBJ5lAnKJCEETuaBOESAm5QSCUbiptjsdTqCtEEHqRtwZZnDLYx4+Z8B19wJDwCTgKNzwwFzjovptqLTcVxa5waOI+S5NqTSctE9xDPVXenDiCq7naIa6JzXNByrJGVyDHlq8zVNI5jiCCCoMkOF1rU+hnRuc+JuR7lga60PgcQWkYUJGFea8OCzbmYKbLVYz0jm9FEfER0SKTKjEJBCfc1NuCEJkhJTjgkOCEJs80l3NLcku5IQkO5pDuacPJIPJCcEg8klLSSMJSlRIEZQQOyRKCkpLuaUTlFgIS5ScbJJGEpE5JhCQ5NyD1OScJTUoyEmELmHaDW1tJXRtjqHshcD6rTgZVFp+9vpKoMleXMcdy45Wn7S6TMUc2PZd+aw8FG6akkmZuYyAQvqrh2mttz4UjhqWNAd6hOADzZwCT36he62VtJV2NjZQBn1ScDfOAfmF0iOo4mtIOQRsUp0/q81mdOXX0iLuJD67cAeat5pSxpJPRfM97s89lrn0U41B0PeOhXnlXSyUM7oJBqPmFmNWVZnq2sB9Vv5qnpnmnqon8i1wKkVb/S7k4kc3YKar2d3N7wvrOxOioaWlsLxq+IuPv/APJXrtA5kEcNuO7mEldEhn76EeDgqx1qpoZTLwAHmXYQs1V3lFC4nfhVZqe6PZiCM8OeZC+Z7LbLhVXV9npJCzJIdrgYadcrzGipKiaqNFE4tySD5BTqjUlJSeqwiRw8FV1epJqppayM4PkmbXa2StEko4yd8FXTaNjW7RtHwXVVNRwxw9MaaGndUSMOC5xwMjux+i0ZZbTbXmKOIyubuSdMrIRSOiq2POxDgV0Wmm44mnxGVgbvF3VY5a2y1Pe0cLufqra/EfluNst92Y3AcCPLIBA+RWlxJiqpaasaMZGP38CrOZ/qrC6hi7u4uI2DhlbZz8tWU1RH9ZG/3jmuV/DSs9G4gjjO0gc35ZHzCzOGpuyuLR/UCPv9la2WfvKVm/RWL3Zb4qg0w2oqo+7gglnc3pG0kD9FrqfS9yqAeKJsDf8AtH5PyGVyvEtEaK8VMA2DjjyzosG6clJWyxOOxKx9/b3kLjjkqm2HL3NXQLto0MoXvknc94HJowFkdKUDzeoxLTufFu0lzTheocOubW8G19DI4As9YZ9x/wDiuhttVFVWKqhJHq6j6/ZMVNGJBsMuVc6GakcHFj2joSCAV2uK2U7I/UhZH/C0BV12sUdXE5j2gg+IXM8L8Vz2U+i1X8yndoWnXHl+i5q08UPt57KVvNCdx3eS59Zi+6yCESRsedvrHEZ+S1DNDyPGZatoz0Y3KTQ6IpKacPd3jnA5HrYWvgaI4mtHIDCxeIm2WSr7Wz8wY7cEYAPhrnCoXmvo5Jua2khp3BGMeS55fdGMpKZ8sc7pHMGcEAKh09bWXOu7uQuDQM+quhaxqm0tqk3Ae4YA8VltC0/FNJIRt0K9JsdbPBwbWdqfUzyt9+/7811FsraiPhuqdKdM4b79/wB+a0VPoy3gDaQ/3lI/2Qto/s3H+8riIbBLJwvDsN7l5l20p3cVSf7J20f2J+aB0rbf9z+KuTyTZOEvKO5N7WT+oqmdpa2/7gH4lMyaYtxG1K0+/Ku3ZykJcDuR2j+8qHpZ0WiL+2tiAhtVYG09wZnDWAE93N5cBcc9OFzj0C61NGY5CCMEHquYPY2Rpa5oc1wwWuGQQtrpC4Gus/osry+qoQIy5xJc+Pfu3E9TgFpJOSWk9Qq8jcahalJMX/y3nXorbAciDAEORRg5USvEJwAAKFeaIV9vljxk42UsHCGfkhM2XEbvS1FJVxT0z2xVtJKJqaR4JDXjI3x9kguaQObXOHVdj+h1HZblrjW1xpow2vo4aWKKnk9uiZNxulj9/eR4z1YyNw2fl2R1dYsTvkY3Z3rBUOgtR1HZV2lW7V1NFJNS92aG8UkLS51TRuIJc1vWSJwa9uN3BrmZ9YYjJPZuYDuiWMSkSAahd57SoBR9pF5jAx6ZDT1+fvFzXQEfAUzf8Szjtlr+2K4W2TV+ka6mrYKmnv8AbJzQyxP4m1Aj7uUOY4bObwSOcFkXjBKjhPq4PRSSDRj+hA+Wh+ibQQQU+VCgicjQIylQkZw5cK+kpZH1VtpqmFuZ6aRskfz/APNd0dtusfr7TR1PBTQ5xGHHvD5bEfl+KFYgIa8Erzpp5tPdKUh8bXse3i4XDcHqPeoF+0kacOmpml8XMs6tWnv9lm05cnVUMRLA766JvUfeCmsljqYWSxOD43jIcOqeCCrLhg5XInwcIO3wXUvoz2/j1veqj7Mdu4D73SN/+1KrLxpeCs4pYfqZuZwNj8FquwGSn07/ALWXCueIoh6PTiT94d6T+bU+KKSeRsMTS5x0AGpJUzWl4xGMnu+S77GMRNHkjVDYtYUN/lfHRl7wzYuc3AV+05wrdVR1FDKYKlhY8dDoVmTU8tO8xzNLXdxRgbIDYFDICDj6qpqvhVl3vFJaIuOqmbC3xcqGn1fb7s+SOmm43N8RhWOpLdFdaN8MzQ4EYB6hcauVDUaaufFGSGB2WkdQvSeGbDa+IIJKcyuZVflBxyn5Z+a6yz22iubHxF5bN0GmCrLWVFV6XrqjUNhgNSJCHXG1s29IA/tY/CQDp9oeeFXt7SH3yghqLXVl1O8ZDgMOHi0jmCPAq2/b7a2gLycSNG4XPrvUQ2ymqp42NifIS7DBgud/Na3BvDvY3Sofdo/UpwS4OGRnpvvpqtay2zs6uR1a31YgSc7ZW7smp54mHvp3SvPiVWamqm11YyZoxkYOVy2w092utWA+6VToyfYaQ3HxAz+K6PJYzbra2T1icjLnuLnH4ndN4Su4l4tE7QGtkLgABgAHYae5RWWsDr0JsYDyRjz2U20WtlbC1zYnPd1JG3zWkg0vThn1jOInw5BVGlbxTUNM9lTIGAOyB4q5qdd2+JhETJJXeOMLXv0PFdTd56ek7R0YceUjIGDqNdB81Nc4r5PXSxwF5aDpjQY6arOals0ducHxDhBPJafQtY+e2uZISeB2xPgsfd70+9VLS76uPOwJW10maWOlbHDIHEc91p8VMrKXhaGkuYL5855t+UDvPyV68tqILNHBWAukznO+B4lTrzZIbmWulZxY5ZUTjobHFh8jIh4eKurtVtoKCSY9BsuZU7Z9S3ImV5LSeRPLyXDcO2qW9Uj5bhOWUkG4z17gNlzdroX3CB0lVKWwR7/2Cv6rWsWC2CPj8wFmLxXy3F4kkjLAFuKLTdLTsHDCCepO6gartrY7c4tYG45YGF1Ngvlgo7pDDbqUguPLzuOuumwWxbLnbIK2OOkgOpxzE66pWgZxJQSRE+w/81s+7aQuddn9RwV00R+03IC6TGMtHuXEceUnonEFQANHEO+IGfnlYnEUHYXSUdDg/EfqsprSjEtplcBks9ZZjRsoFY+M8jgroF6pxUUEzOhYQuY6flNLeIwTjctK7ThL/wBR4VuNvO7fWHwz/wDFbtk/1qzVdL1bqPhn7LprYgBsodfTB8bhjorGE8bGnxTdRHlp2XhQ9V2e5cBnC5RcIzTXCQeDshRZbYLyyenwWNlBDuDY7q41NSujuJLWk8Q6BT9NW5zW949uC7xX1fdb5DTcMR3FpHbPjDAeuuM/TK9jrLjHFaGVQ9tzQ0d+u/0XNLXe+0TsQkxQvOq9LA70FU495C3wjfzGPDcfu9Vom64t+v3G6W9k1OSA2amqG8MkTxzB6fIrpclAySIsc0Fp2II2WQuejGwSTS0LW00knPDcjPT/AF+C8S4K4ggsdzNRWnDC0gkDPlp5rheH6uG21fbPcQ0ggjf4LvWgb0yvsNE8u9buwCPwWvMvExeKqHtE7ROyevc+agh1PYOIk08be6qIR/2bhkH3bk4wOFdw7M/pE6W7RQymt9x9FunJ9rrx3NS0jmA07Oxz9UnHXC4+4SQy1cstNrGXEjvwToubqmxuneYxgEnAPdnTwTvbJpqsu9bQzUVM+oeMscGDkOe61fZNQ11pskcFbF3T25AaTnbork1cdVji2yrChLGAcJXQVHEtRUWeKzPYORhyDrncnvx17lcmuk8lAy3OaOVpznr1/VaGKT1U8JFXRzDHNPCZcisTCnNkR94FB9Iwh6SPFCTCn97skum81AdVY6pp9WB9pCMKe6oATL6nAVdLXtA5quq7uGNJ4hsmFAYSraeuDASSqa53+Gjp5Z5po4IIml8k0rwxjGjmXE7ALiOvfpO2O0Vklr09G7Vd7BLTDQvAgiP/AGk+7R12bxHbBwuQXmsv/aJUsqNXXAVMAcHx2ejzHRRHplvOQjxeTzPRB03ViOAu1XUtZ/SGnvEktDoaJla8HhkvtWwiliPI9007yuG+/s5A9oFc7orOW101xrama6Xeo/r7hVu4pX+Q6NaOQaNgAPBTKWmbHGxjWhrGjAa0YAHgrCKn5KM5KvNa2MYao7KfPROClwpzIMJXc7JEZWV1fYprpZZW0u1dARUUzvCVhyB7j7J8iVmK6uivFkpa6HIjmDX4PNp6g+Y3HwXUHRbcly640P7Fvd1tJHDTVINfSeG5+taPc/f++l3CPDvSKLaJqmNCi0oxE1S2KYbKod04BhONCS0JbQlTUoDKUAgOSUOSE9EGpQCMBGhCIDCUBlGBhGhCAGEYGUYGEaEIAZSkAMIwMoQlDZKAwkjmljmhCWOaW3mkDmltTEJ1ieYmW9E6woT1IaU60phpTrShCfaU40plpTjShCdBSwcpoHKWCmoToOUYOE2DlKBwhCXxIcSRxIFyExG4pDnYCIuyE1I/ZCE3LJsob3ZTs0ijOchPSSUpIByjShNKUjBwkhyNKnJaWOabHJLHJCE4OaUkJY5JcIS0ockgckppSIRoIIwAkIQgDhGDlJQSIS0XEElBCEZciQQQhBAnAQJwkk5TsJiCInCBOFItdrqb5XMpKVnE927nH2WN6uJ6Af63QAkJDRkpdlstRf64U8A4WjeSUjIY3x9/gF1a12uns1GylpmcMbdyTu5x6uJ6k/62R2ayU9goG0tOMnm+QjeR3if5KeGK0xvKFztROZzgeyvePEiOCiPJFxJVmpmppWTtIc0HPisnfNGw1Yc5rcOWyJykuaHDdCQEjZcNvWjpaYu9Q48cLIV1qfCTluF6TrLZFUtIc0FY6+6KjmDixqjLe5Wmy964RLAWncKM9i3950jLTucQzZZSstj4nHLSm4VkOBVK5qbIwpksJaSo7m4TU9RyOiSeSdcE0RuhCQkpZ5pB2KEJB2ROSnIiMhPS5SEEEEJyItREYSkEISCMhJS0k80xCQRhIkGWp08k24ZCE5Y3XtJ6RaZSBkgZCw2jeGWsmp3jLZGZx7l1LUFN39vlYRnLSuSacl9C1DC07DjLCvduEXGu4YuFCD6zRzDzxn6tXptgJqrJWUo3b6w+GfqEu7UMtgubZGAhhdxBXUteyqtXfg+tw7jwWjv1lZdKB4wOPh9Urmkz57c6eldkA+qQVcoYoOPKKESkCqgIyf6mZ1/feFfoHM4mpow84niIz4tz+/eioGmSqLs5Kdu7MFpT9monOidLj3FC7szHkdEypu4Zx3E1p9VmI/l/dWpK4f6RNAOjcN+SmaeqCaXg6tKg6iaXVTZMbFqTY5eGR7firSrp21MWCMrnqy4N4T42mqXtywnXyeAT8Cqs9SLPfHykeqTr5OGVHs10iZGGSu4SPFT6y+08ER4PWPTCz8lqe13qu2RegshaZJ5QxjRklxwFoVtDwVPUuubqokOPMWAHfu20ypporC6Q1RmODryqPUyvqZHTO5OKubJdoqOmDZX8JBw0YyT5AcyfJa/QnY1qLtIYySjpDbbQcH9o1kZ9ceMbNi/3nhb4E8l6j7KPo4WXRkkdUyl9JrgN66rAfMfJu2GDyaB55WffuMKG+Wg21tMW8rvUIIwANB45xusK78V0dRSGkbEQQfV7gBsuCaN7FdY65EcopDYLe/lPXMJmcP3YuY/vEe4rfak+h80acc2gqZZrsXNPpda47DO44WjA+S9cW21U9BEAyMZ+8RunKmkbM0jAK8wt9TJbKmOrpzh7Dkea85ZdqmGdlREcFpyF5c7Kfo8VGi6epbX1cVc6UggRsIDdsdVZam7N/RuJ0MeB5BeiY7WxpwG4UK62GOpic3AOVYuNwqLrUuq6p2Xu3OAPooKyvqK+d1TUnLnb6Y+i8d3WxvpyWOYQFR/ssQvJAwPJejdXaDEge9rMFclvOnZKKRwLCMeIWWHEaKAarKCPAHgkPiBU6eItJyMKK4YKE8KKacAclW36rmoaB8kDeJ46K5dzUKrhErS1wyPBW6WVkM7JJG8wByR3+CsQPbFK17m5AO3euSVU9xv84ErSd+XLC2+mrT+z6VrCPWO7lZC1RxyEtja33BTIoOAYXbcQcWOu9Oyip4hFC3XlHU+K6W8cQOucTaWGMRxN6BLaMNyg5LxhqSeS8/yuUSDySHJw8kgjIRlCbckEYKcPJII2SoSVLttydZ66KsaHPazLZY2jJfGfaAHU7AgdS0DOCVERjmgjOic1xY4OG4XSS5kjGyRubJG8BzXtIIcDyII5hJWc0Xc+JktqkJLommanJ6xZAc3+64jwAD2AcitE7nhUyMHC6NrhI0PHVKByUZOE2lApEFR6+nbVQFrhkjksdc7LguIGPFbd+6g1cTHD1hsUmEA4XFNW2S4xtt9dbKmobVWed9XQ0rpXOgjkeWum7uMnhaZCxpdgesWjPMk9t07qGn1Zp+gu9KOGGriEnBnPA7k5pPi1wI+Cw2oayhopHB0rAeoyFV9n2rqHT1wuVudMPQKiT0qmxyikO0jfIbNIx1LytOGy3GYdtFTuc3vDStoUlRU02WRk41GnTr+q60SjUSkuEFbGJIZGyMPVpypHHss1zHMcWuGCFiEFpwUouA5qJU3WlpCTNURxY++8BYXtYraultcT6aeSHD/W4DjIK5bbrVcdRPf3TnTcJ9YyP5fNerWDgmG627+K1dYIoskHTbHeSQF1ttsEdXSemzzhjM4Om3vyu3V/aLYqLIdXMe4fZjHEVX2ztCt+oLiaWmbJnHEHPGMrncfZvWCMvlnjZgey0ZKrdKTm3amgBOPXMZXVRcHcNVVDVOttQ6aWJpOc6A4JGgAzt3lbMdmtE9NMaOUyPYM+H08Fse0ujfHF6RFEHMJAceuVyoPktsjpYGh0TjmSDofNvgfwP4rv91om3K3vjeMtIXFLvbn22tkikG2Tj3LG4RobZfrZUWqSJrakAlrsese4Z8Dv4FVrEymuVLJRvaBLuD1KFPVQ1sfFC7iHUHYtPgR0T9jj9C0NcZAPVrLrL8msY0H58SzNXTyUsnfQPdE7o5vMfzHkVq+B9JoCxRPIc+XvZXkDAy6V7h+BC5zg6ikZxRDTTDDmOOR/lyq1op3MuUcThqDr7lseylndwzyge0eErqEZ28lgOzan7u0tdjhLjuFvotwqnGNR6Tfap/8AvY+Giwr5L21ymd44+GidB2RE7IIiVxawsKDWR5a7wWG1NbI6uJ4cBy2K3VY7DVk7y4cLsqeColppWzQuw4aghTQufG8SRnBGy5NW08lBM+POAdvgsLrOolfW09O1p7ngLi7wOf5ZW/vlV6RWyEcmnCy9LcaLUnpUTC17qeV0R94X1tM2e8WFtFPI2OrnZnuLsf20K9teJK63NppXhs0jc+eP7K97P7M3gY8t32W61HSh9qeBuQMhUOkDHAwR/ab0Wqr2iWiePEL5opI6ix3aMVDeV8bxn3FeSNElvrWdoMOY4fVYK00Ta+q7pxxtlaqm0pABk7n3LMWiUUl3jLjhocWk+S3rb7Q0zPWkBPkvauO6y9x3COK3Of2b2A4aOuSDr8F3PE09ybVtZSOdyOaDoq6p0tTOidiPDscysxbqiSz3YBjzscEZWnumtqdkZbTxlzzyOVmrVQT3S5CUtLRxcRJGyk4ajudJb6uXiBxELm6B5yc67DdSWdlZTUs77q49mRoHHK3t+Lq/T0wb7Rj4h71gtO3Ftsr8y7NdgHyXS4KcGDgx6vDhZK96O76d0kB4STyXF8I3y2w0tTZrmeWKU5B7tt/gufsdzpI4ZaCt0jfrnuWniv8Ab2Q8XftI/d3WO1TqL9syClpASzPhzUWLSFW53C6TDfALQ2fTEdA3Jy9/i4LQjZwvwu/02nmNTKPYHQHvOnRWWmy2Y+kQydtIPZHTPeVktNVZoL1C52wyWldco5BJE0jkVn6fTVLHN3vo7S8nPEVoqePu2BuNhywuR4y4gpOIqmOqp4y1wbg5xr10x5rHvl0gu0zZomFpAwc4TdXHljlz4aRqW3V0wkYxgk4h1OF0mRmQozqUZzhYFov1bZBKKNwHaDByM6e9Z1Hcam384pzjnGDkZTFHGWRtaegTk0XEFIjj4QgWrnieY5KoAk7qjqqBsrs4GfHCKCjDFcOiGU2Y8FNLiRglKBrlRDBhqYkpc9FYOYkGNRkKcOwqeptcdQwsewFp5hwyuYdoHYtZdRAzSUpjqB7FVAeCWM9MHrjzXZTEmJqcPaQRkHoUwjXI0KnDw4crxkdxXna3627TeyOto6OK8w6otMz+6hiu+eMHozvM8QPhk4/BdXsH0s7bSBkOq7FdtMSDZ1S6E1VKP/iMGT/hUXtA0PFqKy1VFkxPkHFFKOccg3Y4e4gLmmidSyV9MI6xvdV1O91PUxHm2Rpw4fr8VI2Qn2hqmOp2f+2cfP8Av816p0z24aR1K1gtupLXVvf7MTalrZT/APDJDh8ltY7z3jQ4YIPUFeTX9numNQgPq7LRyPdzkbGGPPvc3BT9L2J6dpyDb33G1eVJWyD8yU/Pcq5jHVer/wBp5/8ANJdcSeS8yQ9lcke0esNTsb90XE/yT47KaaYYq7/f60dRPcHEFNy5L2bP6vkvQty1JS2uIyVtZBRxjm+olaxo+JKwd9+kHoqyktfqGnqpvsxUDXVBcfDLAR8yubxdjelonh7rb6Q/71RM9+fmcK+t+lbbaGcNFQU1IP8AsYmt/IJvrI5Yh4qNc+3++XoOZpjSFbIDkCrvTxTRt8DwDLnD3ELlXaxY+0TWukrlU3LVDpHws70WS1xmKmewbuaTnikONxxZ326rtfoDUg0oifkBPBLdQk9QjC8m9lt2iqLVFFGxkb4XYc1gAyfH4rr9FFxAEdVy3Xul/wD0U9qYdCzurHeSZYMezG4kcbP7riCPIhdU09IKimYOZbsgtw7I2Oqth/PED1GhVvTQctlYxQbeaTTQ8lZRQ7ckir5yozYNuSV3KnNgRmBNwnKsdGfBYntLs75rRHdKeMvq7W81Aa3m+PGJGfFuT72hdFfAos1ODkEZB6FG2qXcYXHqSSOop45onB8T2hzXDqOilMGyudO9nNuFRdre2oraOWlqBLEIZQWdxIMsHC4EbOEg2x7KRqHT02nJ4MyekUc/qxzFoDmvAzwOA2yQCQRjODsMb2eU8vMNlXcD1Vc1ODkmwcJbSmZUacS0hKHJGUJaUBhJHJLHJGU9BKAwiHNKSoQSgMJI5pSYnoJY2SRzSkIRtShzSWpQ5oTEsc0tvNIHNLHNCE43onWlMtTjShPT7SnmlMMKdaUITzU4CmmlONKEJ0HCUDhNg5SgcIQnEYOEgHCUDlJhCVkIicoklxRhCDnYUeV+ydeVEmcjCEzI7KZJylOOCkIwhHxIwcpKCVCWjaUgHCUOadhMTjUtvJNjmltKVPS28ktpTYOClIQnAcFKSAcpQOUISwcoJKPiTcIRoIuJDiSYQjQyElBJhCPiRE5QQSpiCInCIuTtBQVF3rY6Slj7yaQ7DoB1JPQBCQkNGSlW23VN6ro6SlZxyv5k7NaOriegH+t11ywWGm03QejwevI7BlmI9aR36AdB095JKdO6ep9NUPcxfWTvwZpiN3n9AOg/XKsScqwxvLqVz9TUmY8rfZ+qPclKAykgpbU9U17qJyiQQQqiCLiRpJGEuEI85ym3xh4wQlIjnKROCqq+yxVTSOELF3zRDZA4tZuukHZNvibIMEZSYTw4hee7xpSWnc71D8lmKq3OiJBaRhelLlYIqth9Ub+Swl/0P7RY35BNLVYbJ3ri8sBCjPZgrZ3TTktM45Ydln6mgcwnbCbhWA5U7gkEbqXLCW52UdzN0xPymiOiSlkYKS7mlCEg80SURlJTkIEkIuJGkoQgkuSkhIU9E7kkozzRHZNShQrhHxxPb5FcYuNJNS6hf3cb3cMocOEHku3SsDgVWSW5pl4w0A+OF2/DPEruHXTOEfOJG4xnH2K6SzXp1ndI4M5w8YxnCKlZ31OwkYJGceCymptIftKdskThE4nLiRzW3hi4WgISQBztwuft91qrTU+l0TuV2vjv57rJo62egmFRTO5XLJW3TYo6ERZLyPJUV5tRicfVy3PJdKZTho2GFX3a0sqYnOA3WfU1U9TUOqpHeu45J2OfclbWSvmM0jtSc58Vy+CARHYBTOPDd0V7Mdokf3pwByHU+5a/sv7B772r1kc10M1l0/nPcsPDUVI8z9hv4+5UXGSd/M4knvK0JKhkbed5yVkLFbrnra8fsnTNtku9eCBI9m0FPnrJJyb7tyegXqbsk+iHR2p9PdNVPZfbq3D2xSMxSwH9yM+0R952TtkBq7d2cdl9i7PrLDQWmghpIIxsyNuMnqT4k+J3W5DeEYAwFaZEG6ndczUVz5Tyt0Cqbdp2loGANjDiPEbD4KxbC1vIZTySXY5KUrNSs7IcWybzugDuhLlOJLgCEnOChxJMJFAr7aypaQWg5XPdU6LZUscQzfxwuouUappmzNwRlNIynB2F5U1LpGWikcQzZYuop3ROIIwvV2pNKR1cb/UzlcW1dol9M972M28QFHjCstcCuXuGCmi0FWNbRPpnkOBCgOG6RSplzBn3oiMBKJykHmhCSTsknkjRdEuUJKSeaVyTL5mRjLnBo8ScJ4BJwEoBJwEZ5pBCg1eoKClae8qowfAHKqarXVvjyI+OU+QwFvUnD92rv9npnuHfynHxOi1qe0XCq/wYHH3HHx2Wi5FGOSxg16ZqiNjKbhY5wBLnb4Wr73jjyD0Ul1sNwspjFfHyF+cag7b7ZT6+01lsLBVs5ebbUHbyTpqZaGeCshy+opn941gIHHthzN9vWaXDJ5ZzzAXRYamKupoamB3eQzMbJG8AjiaRkHfyK84XivqYbw/inkLGvDgOLbC7HoG6d5TzULydv6TFnqxx9ceJw45yekjQOSt8Q8NSWSmpqp0geJhnQYxoDjx3W9U2l9qihe54cJRnQbbafNaeoqG08b5HHZoJK5xcO2OOCtMFPRl7Q8NMj37efJXvaLe/2VZJeF3C+QcII6Lg7+Jx4j9rfK7vgDhCivFPJW3FnM3OGjJHmdCMrr+HLLBXRunqm5GcD7r09T1nfwMlHJ7Q4fELmfaPraWnmNvo3YcR6zlqNHXE1unqOTOT3YB94WUu3Z+ay9TVb5nFr38YZjYeS5ThyO12u8TG8HSHPKMZy4HCwbX6HR1shr9mZwO8g4WXtWjqq7x+kVDntDtxk5ymrtpJ1FE98RLizctPMrqsFPDQwsbI5sbWjAzssxqu9UFPFII5WSSEbBrsroYOMuI7lcGmhB5ObRobpjPX9VpQX67VlWOwHq50AGmFSdmupZ6O8RUcjy6CTIDSevRdsik42ZHVcD0JQem6gjkB4O7PeNHxXcqZ2YxlZ/4lNpRdwacAO5Rzgf1a/PCg4r7EV47PfA5vNZTtLp/SLHLjcgZCw/ZdJm6TwncSM5e5dH1rh9kqDjYNyVy/s7d3WoRjkD+C2uHHelcG3Cnds3X36H7BXbYe2sNVEemv0XYX29phO2+Fw2/Qm06rmx6oZMHj3ZXfR60K4v2oUfo9/bKBgSs/JUvwwqQ26y0j9pWEfDX6ZVXg+QNrXwHZ7T8v7ZXUqHFVQRvH2mgrEa80/wCkROnY314wStRoatFZYKZxOTwAFTLzRtmicCMghcAypn4evJkiOHRPI88HBHvC56OWS2Vxczdjj9V58q2F1NK0j1gMgFXdxk49P6cjB2NDESPAloP6pWqbSbfXSEDEbioEUpq3UNOchsUccLfgAF9J0Fupq+6Q8UUeOR8Z5vB2B89/gvW6eCKpqY7rD7Jac+eF2TRUHdWmnBGHcO/vWsjGAqOwxdzRRNOxDQCqrXGqKvTsERpmtPGObhnC+bG0k99uroafHPI44ydOpXj8cElxrDHF7TyVsScpLjgLKaJ1LNfKHvJ3AyDngYWldJ6pWbcKCa2VT6Sf2mHBwoKmmfSTOgk3booldJgFYTVlwFLSyHqRgBbGuky0rm+r6aorpmtZgRjfOVcsMNLPcoRWvDIgcuJ7hrj3q3bI4X1TBUODWA5JPgufXq4i22utrnnPcxuf7zjYfE4HxXH9G19bpq8imro3wS1P1rRIMced/n/JdtuNkNUYoZeF8LHcbm8+Jw9nPkDv7wFTai0hTX+jMFUwtc05imZ7cbvEFdVxXxIa68+k0D8MiwGEabdVt3e4GrrxUUzvVZgNVvbbgW8E8R32K3Ntunp9LgtIdjfK49p2qrLLVstd1x34/qKkbMqGj8neIXT7PVB7GjO3gm3/AIohv9PEZafE7d3g7+7H3UN2urbjGznixIPzZ392FAqrFUyVkjmNDWE5BJUmDS0sp+tnx5ALSRRtlAyp8EDQrj/xDvZiZFE5rA0AZDRnQd5yh3FF0LBGxwaAMaDX55VBSaRpY3Au45D5nC0VvtrIAAxvCPJSoWNA5fJS4uFcbX3q4XPWsmc/zOnw2XP1NbV1pzUyl3mfsnomANwET6dr+iU2QeKcDsrBVPCiNoRnOE+2mDU9xNR8WUZKdygJIhDSEvGNgggkTkWd8IO5I9vNFgIQklqItS+iIjCEJpzUkt2TxCSRhCdlMliSWf8Akny0Ii3dCXKjmNJdHlSS1EWYTcJwcquspBLG5pHMbLzr2sWZ2jNcUd9gbw0F4Ip6jGwZUtHqO/vNBHvavTb48g7brC9qGiW630fdLQ0AVE0feUr+XBM31mHPTcAHyJTdGnJ2Vhji4Y69P347LG6QvbZ2sBdzXSrcGyxgg5K8w9nmqJJIIBMDFMPUcx2xa8bOaR03C77pa9iVjMnIPNP20Ka/D2h7diti2PCVwpTCHtBG4O6UlVbKa4URancBJIQlTRam3tBCfIwkOahCwHbNoMa+0LV0kEYdc6T+lUTuveN+yP4hlvvIPRct7INSi7Wqm7w/XN+qeD94L0afUK816ps57PO16rhhb3VtvjfTaYDYNlB+saPjk+5zUu48lNEdeU7H69F2qkiBaCrKKHAVXp+qbXUMUrftDKvYmpE3Y4SRFhE5mAnyNkh3JNSqK9ijSNUyRRpuZTSpQqR+KDVlun5MrYpKN/m4fWMJ9wbIP7ys75ZYb1baiimy2OYbPHONwOWuHmCAfgqjVYdDaTWMBL6GWOrAHMhjg5w+LQ4fFavDZWBzTxNIyCOvmrtOeZpaUjguIRiWKSanqWiOqp3mKZg5Bw6jyIwR5EJ3ktD2j2r0Gvpr1G0CKYtpavHR2cRP+eWHx4meCzyge3kdhUyOU4KW0pbSmgcBLamoTgOEtpTYOUppQhOg7pSbBylA4QnpQOEpJRgoQlDmlJCUDlCEpqUkJXMIQlpYKbbyS2lCE4DunGlNNKWChKE+0p1pUdpTzShOT7SnGlMNKcaUITwKUDlNgpQKEJwHCUm+JDIQhLJwkl2ySXJLnITkUjtiokrsp6VyiyOQhNk5RE4QJwElCajBwlJCNvNPTEoc0sc0lvNKQhLBwlJAOUppShPSwcpQKQDhKTkJYOEpIByjBwkwhLBwjyEjiR5CahHxIcSST4IslCblKyUeSkZKPiSYRlKyURKSXJdNTzV9THT08bpZ5DwsY3mT/rqlSaDUo6WmnuFVHTU0bpp5DwsY3mf9c89MLrumNNQ6ZouAFstZIMzTDr+6PIfj+Ca0rpWHTNKXO4Zq+UYlmHID7rfAfnzPQC7O6ka3GqwKqpMp5Gez9UROUaCCflUUEpvJEOaMDCVC90O5IHCLJRJcqolcSInKJBIhBESjROKehJ5hDG+UaI8k3CeicUzNAyUEOGU47kgTjCMIWduumYaxrvUHwWDvmhXN4ixuR5BdcIBTE1KyUHiAKbhPDiF5wuenZacnLCFnqmidGSCCF6SuumIatpywHKwV/wBBOaHOjblMLVYbIuOvjLUy5q1N009LSvcCwj4KinpHMO4IUasB2VAOySRhPvjIzlNOagJ4SElGdgUSXKciPJJQO6CRCS4IiMpR5JKEJKbcwZTpCSRlCEgABETlKRcKEZSUCM80eN8IwMJiMqBR6at7ryyvqIRPK0+rx7hvuC9Cdnuo6aCKNjeFq4W0q1tV3loJWuY8jCe13KopQZN17AtdzZUxtw5W7HZAXBdF6/4uCOV+Dy3K69Z73HVxj1hv5q0DnULMc0tKvSUklJD+IZCMjKVIEecIZ3RDkjTEqA3QzjZDbzRgBqEIs7IjyRcbTyKQ9+OqaUJueMPaQRlZXUFijqo3eqDlaWaoDQd1zTte7UW9nWnJriKJ1cWEDga7HPqrNLSy1s7KeAZe44A8T5qzTU8tTK2CIZc44C5/rHRwic9zGbe5cwuFC6mkIIVPqH6UGodSufHb7TTUo6HeQ/HKwdw1Fq69OL5ppGA82sHCF6LH+HdzAzVyxwj/AHnZPwGfqvQI+Dq5ozUyMj83a/L9V0F725xn4JJOSuUS197tvrudKwfeK0+lNVuubxTz4E2Dg+KqXXgest9I6uglbNG3ctOyir+F6ikpzVRSNkYNy3otc5EhniCC82XFqNVuIjdg42XJrrPUOuM0b5pHDjwMuK63Ut4mkeK5VqiAwXZ55cW69r/C6Vn8QmgcBlzcjI6gr0zgWRvpkkJAyW5HmFIp9LSSgOc4YPmp8WlImDLiXe4K/sYbVUEEnPLQrR1K0NXP3PjO/OmfA+fl5SRgDGxwsKu4lvDpXxOl5cEjQY2XK7rS+g1xa0YAwQuiWqo9IoYn88tCyOs6buquN4GAchXukJu+tMYzuzLV1vFj3XThaguTjlzTgnzBH1auk4gea+w0ladXA4J8xj7LN6tg7q5cWPaC2ej7jJFT0FVHl0kR3YDjjadnN+IJxnbOD0Wd1vTYEcg6HdDTdwENlnBOO7ccfFOusTrzwbRysGXRvDfjlv6J9aH3DhullZq5jgPjkfop3aZfW3q8R0tOXOYz1cEEHOeRB3DgcgggEHZVGpLMLdbKNwG/U48QrfRFml19q2SaqllaD6z5oyOJh6EZBHzBWo7UtD3OzWZ0rn09dSNwRNEDFI3HRzDkbeIdufshbhr28P3G12OE4DMc/m7T7lbrq9lsrqK2NOMY5vN2ij9ldb31lMJOTFIR81uHsDtyN1yXsuukdJW1FPJI2MSAFoc7GSt7qHVUdiphI9vGDsvLuL7TM7ieelpmZdIQ4Dv5gD9crl73QSG7yxRDJccgeYys92gWCrutXA6mc4NDcODTtzWSdoWqbHkvDT57rf2PVVNqRrwCGSA44fFWE8ELWkuc0e8q0ziniDhuJtpDQwx97cnXX37p4vF1tTRRABvL4arjneVum6+NzXFj2bjwIXatK39t4t8UwG/COLxB8FyfXFXBUVzWQuDy0YOFY6UbUuoXQsrp6Ij1sQ8IJ6ZyRnw+a6TjCJtw4epbtUxBlS44OmCc94+fvW5eY21drhrJ2hsp92Vvde1raWw1HER6w4ce9c77NaYvvDptyGjBHvVLfbhVyVMkElwrKqNpwW1MpemrXW3GkJFEZRxbEMbkH8F0li4arKXhWamJDZZ9dToGnx8lq0NnlhtEkAcA6Xv2A/8AC9BipiiiHHI1m32jhcv7VJqaqFNJDMySRriCGnoqCan1HUQmWSGo7rq4NJx54GSnqTRVbcoWTPrInRP3Dmu4gVz1kstq4XrmV9XcmFzM+q3XcYxpkrIobfRWaobVVFW3Leg1+mVZ6G1lT2W3inqMlwccb+K6XDUMuVEyZnsvGVw6/WI2KZjeMv5HJGF1TQVb6VZI25zw7Kjx1aLdLStv1uJImcST018Dtqq/EFHSPhFzpDkSHVVWsLI2sgeOHcbgrm1sayG6xNm2Y1+HOxnh812nUobHbppHO4SGnfzXILLGau7Ofj1cknyU/A1fUU1kuJcf5TG5Hg4g7fJTcPVEsVvquY+oBp5ldutuHU0bmuDmFuWuacgjxBWO7VC39mRfeD+XkU3b7lV2Mk0uJIScvpZDhjj4g/ZPmMg75GdwzqMx63DGUkpiqohxPo5hwvaPHHUdOIEjpled8KVMFPeoJ6l4YxpySfL7rmLPyU9dFNK7laDnKHZgHso5SRgcW3uW/L9iqLTlnFpoY4uRHNXD3BrC4kADmVX4juDLpdZ6uP2XO08v7qrc6ltbWyzt2J0UGtPE0hZa6U/G4q3uOobZA4tkuNJE7wfOwH8SqCq1Da5SeG5Uj/4Jmu/Irl1SaAN1Tz0mHZ4VGmoWyN3Cny3egOcVUZ9xyo0l2oR/7QwfNNwVM1zR1VPcdPwXGldT1EfHGdw4bOaehB6EeKq6CsqbNWChrXZk5xT8hM3/AO2HUfFaGW+W9nOriHvdhVt2uNhudI+CruVNGObZO9Acx3RwPilBIT+ZhGCVpbbdGSNG6vqeoDwMFcPoNbUltqJKee6UkpjOBLHM3heOh57HxC2tl1pRVoAhrYZT4NkB/JSZVYtHQro7JfNPNlWZp700gesD8VYRXRpCRM5SrtsqWJvNVDblGebse9PsrWO5PHzQkwVaCZLEueqrRUg9cpxs+UJMKwEvmjEpUETeaWJcoRhTe9R8eQoYm2ShMhGFK4vNGDsowmShJlCRPIYyU06YMGXEAeJRRVUUrsMe1x/dOU8McRzAaJ2CRnCdxuhjw2SuSBGExNykY3whhqUW4wghKEktUaph24sezupaDmBwwUhGRhPaS05C8bdqlrbortjutE0dzR3drblSnkA9+zwPe9rz8lsdC6kdJiJ7sSs5jx81p/pS9nz9R6Giv1Iwm42Bxldwj1nU7scf+HDXeQDlwLReqn1D2ZdwV8GCR0kb4/zTw3mYHDpoUxkwZKYX7HUe/ce4r2Fp+4Crpw0nJCuVy/Q+omVMcMrD6r+Y8D4LqELxLGHDcFMClkbylEQiThGURGEqYmi1Ic1PFuUlzUhQo0jchcq+kNpt910MLvStzcbHMK2M9eAHEg92PW/uLrTmZUOsooq6lnpahgkgnY6ORh5OaRgj5FAODlKNVyzsrv8AHc7fEWO+rlY2Vg8iNwulRrzt2Wyy6Sv1207UvJms9a+EF3N0TieF3x3PxC9DU7xJGCN8hGMEt7lZf62Hjr9eqkY2ym3DmnRuEh4SpgUWRRpFLlG5UWQKMqUKJVQNqYJYnjLJGlrh4ghDRlQ6o0zQNkPFLAw00hPPijJYf+XPxTj1H0t/Rq28UZ5CdtSwfuyN3/4mP+amp3Ykx3pzvZUq+2iC8W6qoagEwVUZjcRzGRzHmDgjzXHaTv42yU9WAKylkdBOBy427ZHkRhw8nBd3mh7yIgcxuFy7tAtXoF5gukbcQ1oEE+OkrR6jvi0Fv91oVmduRlVJW5HN3KhSwcJCMFUwVBlOJQOU2DhKSpU6ClpkHKWHIT04DhKTYOUoHCEJYKNIyEfF7kJMpwHKUDhNcSUDhCMp0FKBTQKUHIRlPApxpTLXJxpQlTrSnWlMNKcBwhLlPtKcaUy0pbShOT4KUDlMhyWHIQnQ5HkJsOQLsIQEouyUhzkRcm3uQnJEruajudlOPdlMk5QhDJRIE4RcSXCajRjmkgo05MS0oHKSDlBKEJYOEpIBylNTk9LBylA4SAcJSEmUtGHJAcjyEJMpecoJGQhkJMJEvIRcSRxIcSMIS+JDiSeJBjXzSsiia6SV7g1rGDJcTsAB1KMIS4opaueOGFjpZpDwtY3ckrrWkdJRaape8l4ZLhKPrHjcNH3W+X5/JN6M0ezTcHpNUGyXOQb43EI+6D1PifgNtzoyclPa3Cwaqp7U8jNvqgTlEhkIA5T1QQQQQSYQjBwgDuiQSpuV7oQQ8kEuFXAQQQQTk5BJRkokJvVBJclJBOShBQRORonITklBBAjKTCTKIgEKPNSMlBBAT6GcpqVZW8aTgrGu9QfJc6v+gnxFzo25C7cWghRaihjnBBaCmkZUjXkLzFcLDLTuOWEY8lTzUzmHcYXo+86OhrGuwwZXPL7oJ8JcWMyFEWkKy2QHdcqdHg8k05mFpK+wy0zjlhVRLSubzCblWA5V5bukqS+IhMuajKdlIJSThLIwkkZSZRlJSThKI280TuSMpqSeSTjKWiAwlylykcKPGEZGESVBRcKcY7Cae9sYy4gDxKTDWQzOLY5WPc3mGuzhAY5wLgNAlDXEZA0VvQ1z6d4c0kYK6dozXToHMjlft4lcFvms6LT7+CcSF/QNbt81ZaU1pT3pgkgPduBOWO5rY/hFxipBXuhcIj+bGitS2ur9G9LMZ7Pv6L2fYtQR10LcPBz1V4KhgbkkADxXnDSuuDbmZkkIjaMkrgfaN2mag15r51BSXSrho3SCBsVPK5rcZ9rb3rf4c4fk4ilexjwxrBkuIzhS2WxS3iZ7WvDGsGSSMr3tetZWTTlP6RcrpS0cJ24pZAE1pbXti1rDJPZbjDcIWOLHPiORkc1567Seydl97KqSmj4pblShrzKSSXkDfmuN/Rx7SZuz7XEVtq3llFPI5kjSdmuxj9Fv0XClLc7VUVdFMXzRE+rgAEDr1Oo2WxScO01fbpqmklLpYydMADA69+vRfQknAyuJ/SY7VLv2daVZNY544a6SQDMjA71M74811yjuDKyijmjcHMkaHNI8CvJv01boJY7ZSB3C9ji8j7zSP5rC4Soo669wQTt5m51B1GneFk8NUrKu7Qwyty3OoO2netb9F7tG1JriG5VeoLlLVljx3TSAGhpG/wCK77PcmtYTleY/owsNr0XxO5yPLmu8Wnddfrr+Gxn1lBxaYReahsDQ1rTgADA08E3iIRm6zthaGtBwABgaK+ud9bG0+suI9uNcLzpKvpzvxRn+a0F21CXEgOXO9XVhraKZhOQQQudt1SaWsinbu1wPwKzaJ5p6iOYflIPzXA+zWoji1B3UrGuEjCPWHULq00DXj1WtaPIYXD4quSxX100bQXwyHDTyKv5teX6sHDC1sLf3Wb/NfQfGXC9dfa+OspHtbG5gyXOwM69PLC9i4m4fqrtWMqoHAMLRkudgZ8vLC02qWQQ0Uplc3l1WE0nC916ZJGDwsPMeCKtivVz9aodLPnoUuz3l1hmEcsHD949VLbrJLabJVUNFK2eaQatDhgDGDgHUqWitUlvtdRS0kjZpXjUA6AeC6jBkgJ0jfdR7bVR1tOyWM5aQpjmL5rlY6J5jeMEbheLOY6NxY8YIUaZq5zrum4KmOQDnkLpUrMt8Vi9eUvHRcY5tOV3XA1X6JfqdxOjjy/HRdRwvUej3aFx2Jx8dEvRFR31ra3mWEhac7sWF0BP69RDnwcAt43dp6qHjOk9Dv1VGBoXc3/MAfuouJaf0a7Ts6E5+Ov3WL1zTcVKJAN2lRtC1HqzxZ5EEK/1XTd/bZdt8FY/RtR3V14M4D24XfWn/ANS4Iq6bcxHmHuwfsV1lvHpvC1RB1jOfof1Wj1fB31sc7HLdYSKqfDBLED6snNdOu8PpFvkbzyCub0tsnnqWsEbscWMluy2/w7r6b+ETw1ZHLG4O1+P1C1eDauAW6aOpIww82vx+oXUuxz/ouKSo4cuc7Dh4tWv19VPvVtnDshnAWtbnlssxpFgoHxsxwte3hPv6f681qa2Lv4HMOwIXi1xu76y7uuJP5sjyB0+S8srbg+puTq4n82R5A6LiehZI4NSxQ1EbJopcxujkaHNPvBXT75oqgulC5kBlpc4PDG8lh/unIHwAVZb9A0NHcxVDvHSh/G0k4AK3MEWI8FdHxdxDS3O6Q3K2uc1zGjJIxqCSMfFdDxBfWVtdHWW5xaQACSMag9Fw+s0dd7NMXU+ZG52MZwT8FHnq736sNRJJSh2w771A74nmu5y0Aedgmv2U14c1zA9rhghwyCPMK/8A/qHVvY01FPHI8fmLdVbZxtUuaO3ga9w6kLj9t0fK+QTVTw/O+FezUht0kU8bfY2I8R/5ZW2k0RR4zRySW2XniA/Vn3xn1cfw4Pmqi72m5W2J/pdKKumA/wCs0LS4j+KLdw/u8Q8SFwd64gr75KJKx2QNgNAPIKhUXmW6yB879thsAuV6ljbHd5HtwWSAPHgQV0rs8a2utpp3BvpNLhpOMF7CPq3fHBaT1c1yw9wtDbnVwPgnZJTzbRStcC0nfbPngkfLwW303G7TdRbKmRwETSKWpJO3dvIDXf3X8JyeTS/xXd8UXujudhoGxy5mYMOb4Yxr8B8V1d3rIK23U7Gv9duhHux9ltGWsgnIVZcNKPikfW2vgirCeKSnccRVP8X3XeDxv45Gy2jqbhxn3KtbdKSprZaGj726V8JxLRWyCSrnizsC+OJrnNH7xAHmvHSSVxbeWPVx0XJdX0P+0NJHPRxPZIxxjlgkGJIng7tcOhHyIIIJBBU/R1JWWe0z94wgtGQD1XQqzsu1dU3qkvUVkjsMRYY6pl4q2RelsweDDYRMQ5p5Fwa7cgjwlnRtUzibU17C3mG0UHAfMOc8u4h5hrSu3ZxHUutLLRIwGNpz475wrsl/ayjbQ6FgOe8rgeodQ3S8PlhkZ3UTXEHoPiSrvR+npYoC9tHUVMz9/q2BrS3xD3FrD8HZXUho2gpJu8ho4xICSJJMveD/ABOJIHllWENu7oDAwt678WNq7eLZQQCGI45sblOuPFXpFMKOjhEbOvisMNHXSrBBdSULDuHuLp3jycwcIHweVGuPZPSXJsZqrpXxzRv44p6Ixwujd4sJa5zfDmulmmwMYTToMdF5sGNHRciayc9ceSzX7CidFGyaeqnLAB3hmMbnHxPd8I/DHkm36atZOZLdTTv6PniEjvm7JWkfT56Jl1MfBOwO5Q9rI7dxVRFSRUzeGGJkLR0Y0AD5IzxdCVYupsJt1PhLlNyVXODvEpiQO8SrN1P5Jp9MkRkqpfxjqVHkaXc91cupvJMupQU9GSqGajjlB44mO97QVV1WkbPVkmos1BOfGSmY78wta+mHgkOpvJCXJCxL9B2L7FrhgHhTkw/8hCZl0Jb8fUzV9KehirJDj4OJC3LqcJp8DPFNwniR42cVgzo+ogyYL9cPITtikH/ID+KadZr9APqrlR1HlNSub+LX/ottUdzD7b2s/iOFVVV8ttOcOqmE+DTkq5T2+pqzinhc/wAgT9FoQMrJziFpd5AlZSV+rKTc2+21g/7CrfG4/BzMfio8us7vbG5rdM3doHWj4Kof8Ls/gtnPUxehGpYC9mMgDZZyHVbZXSB0fdNb57rToeHLhcY5JKaLIYcHbIPdjdadJRXGrY98MeQzQ7Zz5bqppO2SyvqBBNXiiqesFwgfA4e8uAH4rUUmtaWpj42kTRHlLTyB7D8QVk7lUzX0OjfEyWnzsyRgI/LCqH6ehpATHStpz96FvAR8l3VN+HfMBHVVjI5T+Xc+R2XYwcOk4ZVTsbIfy9V1am1DRVRDW1DA4/ZeeE/Ipm76kitIHG17ydhwhcXulLqOEcdmqKatI/8AZK/1cjrwyDr/ABbKhPapPZ6mOg1Na7hp2Z5w0VQMlO8/uPGzveBjzXNv4dFiu8dLeml0RO7TjI7wfqsiWkitde2nuQww9e8d4K9D2fUbLtGXNaWOBPqk7q3bUernK5DZ776LwVdM5s0ZH2XbEe9aSl7RaSQBskb43Dn1wpeM+HWWKtDqb/AkGWnf3ZVm/WttvnDoRmN2o/RT9dVzhTxRte5pJz6pwndAZjppHHcudkErMX+9w3dzDC7ia1aDRdbGyARbc8rra3FHwLAzGsrvuT9vqtap/kcORt6vct+x2QnQExA4OaE+BleJLgUkjdAjCWNjhFw+5CEnhSgEOH3JQGCmJ6bkijlDo542y08rTHLG8Za9pGCCOoIOF4C7RdC1HZv2gXSzUznNdRSd9Qyv/tad3rMz4nB4T5ghfQF7Q4Y8VwT6V2izcrDatW07Cam1P9Fqy0ZJp3u9U/3Xnb/vCpYncrsdCqtXF2kfMN26/qub9lmtI6std7GXcE8J5xv8V6W01Xek0waTkgfgvDsNU/S90p73TSiopHENqo2jBLPHGeYXq7syv8dbTU/BKJI3MEkTwfbYUx7Qx2mxVinlNREeb2m7+I6FdPI2SeFLG/NHgJqcm+FJLU7gIFoQUKM5iZkZ1UstTb25CalC859sVvOle2Oy3lg4aS/UxpJndO+ZgAn3gxj4Fda0tW+mWqFxOXAcJ94Wb+khpl987MKqspx/TbPKy4ROA3Abs/8A4S4/3QovZZqFl3tlPO0+pVQtmDfA43HwO3wTu4+5WWesxzO7UeR0PzXSmHKN7UiMp13JCjCiyN2UWVqmyDKjSsUZUoUGQEEKPSfUahp5OTamF0B83N9dv4CRTJWYCr7lmGBtS3d1M9s+3g0+sPi3iHxSMdyuDlJuFqmBU2orFFeaCpoZfVjnb6rwN2OBy1w82uAPwV1GQ4AtIcCMgjkUc0XeM8xuFruHMFCO4rg7opqaWWnqWd3UwPMcrByDh4eR5g9QQUFu+0LTvHCLxTs9eMBlSAPaZ0f/AHeR8vJqwizHN5DhVHN5ThKByjBwkA4SgcpU0JQOUoHCbSgcoSp0ORgpsHCUChCcByjBwkA5SgcoQnEYOUgHCUChJlLBwlDZNgpYOUIynAUtrk00pbShLlPtcnGlR2lONchOypAO6cByo7XAp0OQlToOEoHCaDkoO80Jcp0OQ48pri80OPzQnJZKbe5EXJt7kISXuTZOEZckoQgggghJlBGCiQT01LBwlJsFKBwhCWDhKTYcjBT0JziRgpAOUaEJfEj4kgHKNCEtBISJZo4G8UkjY28uJ5wEITxOEnJT9Jba+4Y9Ft9VODycIi1jvc92Gn5q4pdAXyrI446ahZ1dPLxPb7msBB/xBLglV3TxM9pwWfBdJIyONrpJHuDWsYMucTyAA5nyXWdD6Lbp2EVtaGvukjdhkEU7TzaPF3i74DbJc5pPRNDpo+kgurK9wI9JlAHCOoY37I+Z8SVo3ElPDcLJqKoyeozb6oOdkpOcoYKCVUEEbUSNqEhRoIIITUEEEEIXuhDOEEnOU9V0rIRE5RIJiXKCCCCel2RHkkpTuSShNQSTuUo8khCUoIIIISJKCB5oIS5RE4Q80CMpKTCUFG5ocOSiVVBHO0gtBUzIRpuE4LE3rR0NUHEMGVz2+aHfAXFrMjyC7q+MFVF1bRMYe/kjj95TOTmOApWOdsF5ur7HJA4gtVPNSGM8l3e62e3VueCaIuPIcYBKxV40gYw4tbkHyUb43s9oYVoOI3C5m+PGU0WrQXKzyU+ct5Ljmqe0attVzno4aaNro3FvG45K3LLYq2/TmnoWguAyckDAW1bLZU3aUxUwBIGdTjRdAc4YTUs8cQy97WDxccLkE2qtR3P2ZnRg/wC7bhV9dRXUwOnqJZntAyeJxwvQ4Pw6c17WVtdGwk4wPWOe7ouvi4QIcGVVUxpOmBqfsu1QVsFUXCKVkvCcHgOcKDf7/FYaN1RJG6Ro2w1YLsvru6qaqnJ2cA8LU6zh9KsszRueErnK2wQWfiJlrqXF8XM3J2JDsd2yxqm1RW68NoZyXMy3XbIOE5pfV0epXVAbCYe6xgE5JC0OfVyuR9nFYae9uizgSsI+S6nUTtgpnyE4AGU3jOyw2a8upKRuGENLRqdxjr4gpOJLbHbrkaenbhpAIHn/AHysF2kXt7Xx0kUhaebuE8wq3s4rzBdpoi7+tZnfyVTXvffr3M4ElpcceSLTUxodQ0/EcevwFe7Ms0FPwtNaG/4oi53Drk+sPmF6i23RQ2KS3D/EDOY+e4+YXUNRWeK80hbI0FwyWnwOFzSGWs0jdeIEgA48iF2KCMSRb9QqHUenIrnTuBb64yQfNeK8K8U/wsmgrxz0z9CD0z1H3XmdivpoCaWqHNA/Qju8QlVmvWSaYlqIZAJXtLQ3r5ql7FaAVWrWV84yyI8Qzvk55LA3Cnlt9RJSvccMPJdS7LJIaeiaYnNMh3eB4r0u60VPwnw9O+3EuFQRg9zSNNfL6rsrjSxWCzTOojzCY6Huaf7L2RYKuK4W9rdiMYXkT6Q3Z1LozUrLnQx8NNNxSFzB7LuL/Nd10jqZ0DWMcdla9oljptdaUrKR7Q6V8RDHY3BXk3Cd+NkuLZXH+W7Rw8D19268y4eurrNXNkPsO0cPA/oo30ce1duq9IxUFRLxVtFC1j8nc9Mrif0ubsK/V1HAfbgZjA6tO6wejtQVnZNryeB3EwCVsMoO2Rn/ADT/AGy3+PU2vWSxuErWkNyOrc7L2WgsDbfxQK6AZhexz2kdMgZ+vzXqFDZW0XEAq4R/Ke0uB8wM/Vdz7KpBZ9GUMIO3BkHyKvrhdnPB3WT04/0W0UsId6rIwB7lMmnyCSV843SoNTWzTH8zifmvHax5mqpZT1cT80mrq3PJ3VJcWmSN48Qpz6gOmjhZl80p4Y427uefADmT5Bai0djms9S8LorLJb4Hf29zPo4afNjvrPiGELNbnOQq3MG6leSNYU3oWo6jI5kPXRrNb6eSihlZGwcTAeXkm/pEdl9b2d3ijdWVUNTJUBwd3DTwsI6Bx9r5BSNC9sGmtI6bpIZtN01xukbeF81XxzNd/wDDcSz8F9JXe213EvD1vkoNXtGHa40xjX3j5r2S5UdVfbNRS0Q5nAYOuNMY1+HzUl9HGHNjGA92zWjmfcFge0S3SW+riEtLLTvcNu8jLM/MBdMqfpPasuVM+i05b/2bA/burbTiJo+DBhV+l+xbVnaZeGV99kqo4nuy59Q0k4+KzuHuG5OFqoXS7VDWBoPqg5JVKz2Z3D84r7lK1gaDoDklF2Tdn2rNT2UT2yzVFbTk7SAtYNvNxC6I7sN7QmRhx0vUEfuzwu/APXpzsx0lT6OslNb6OMRwxAeyMZPU4XRI5SGheQXqpiuNxmq4xhr3EjyXmVyrxWVktRG3DXEkLwRX9mWtKEHvdJ3ogczFQSyAfFrSFgdbWavpKCWOut9TRuxu2ohdGR8wF9OhUE7KDXxCojLS0HPQhUaOU0dQyoYdWkH4KpT1z6aVswbq0g/BfJnRzZqa5iR0Tu6LSC7Gy6PFUMc0L3tU9n1jucxdcbLb7gOoqqVkn/MCmavsJ7PbowtqdK0MbT9mkDqYD/60Wrd4kvLuIq701zAw4AwDnZa94vv8YqvSnx8pwBga7LwPXRsqoXMcdiMKht+mKWiqhLGHF4OQSV7uu30SOz+4AilFytI6Cjq+PHxlbIsjdPoUUsjibXqyalaOTKujbMXe9zXsx8lkU1wrqSF9PBKWsf7QBxnzVGG5ywRuhikLWu3A6+a8wmHMeCo7be0vzhd3uv0Qta0HePoqy03OIeyxk745Xe9rmBo/xLC3nsX7QNO/9c0lcnf/AIkwVe3ie5L8D3rMPO3cKuHsd1WSp4eDGy0NNP6RECT6w2KzlRVOttV6NVsdTVI5wzNLHj4HdSKa6NheDn3hMynOblaIRZ6KRG3hVQLtExnEXgN8SrqyWa96lDXWez19zjccd7SUz5GD3uAIHvJTVFgBKGCUeR4reWP6O+u7uA6ppKOzM5n06qaXFvi0RB+/k7C3tk+irSwhrr1qSqqnD1gy307KcZ+64v7ziHmOE+5O5Soy9o6rg4eCQANynbTFU38uFpo6u7cDuGT9m00lT3Z/fEYdw/HC9X2bsR0LYWju9PU1a8YPHci6sId95omLgw/w4W0DhFG1jAGtYOFoHIDwCXk7ym9r3BeJLv8ARY1PrZkz2WBunqyVuRcKq4Mha8/Zc5kPelzhgY7yMEdCFpNO/Q9vElqNFq3WlNUxSxGGeO123u5HAgg4mkkc3cHrCvWEuXc1CmiRysPRTNqpmjDXYC5XbuwrSVtaz0+Kt1HK1oY594qTJHKB0kgYGQP95jytVTU1LZ6CKht9JBQUUIxFTUsTYoox4Na0AAe5XU8XNVdVHgFPGBsonOdIcvOVR3ekguMLo52hw6HqFz29ad9CeS0ZYeRC6LVNxlVFZG2aNzHjiBSApQMLldTb8E7KG+lAOy2NztndOJbu3xVJNS4J2+KE8KkdB5Jp0HyVs+DHRMugQnqrdBjomnwK1MPkmpIgOeyTKFUvgTLoUm9ajt9mbmonjafu8Qys0e1KxmQsNRlxOBwjIW1TWa41jO0p4HOb3gFacFsralvPDE5w8AVonxZ6Jt0KO3XWlusQkppmyt68J5KU9mBlZj4nwvLJGkEdCqL2ujcWPGCO9V74QOiqbheKO35E0zWkdMhUXaPrF1ojFHTEGeQbnwCwdq0tW6gHpFQ+QMccgk5yvR7TwnDLRC6XafsYTtpku8l2dv4fifSCvuMvZRHbvK6NHrG0zSiNtSwv8ArPvo5oTJE4SDGdiuZ13Z7LDCX08hLgPZPMqHpjUVVZLiyknc4wl3A5runuWpJwjbLjSvqLFUmR0epa7fHh+/er7+HqCup3zWifnczUtO6tL1ri5xV01PBTMYGOwHEE5VFWX2+TxOfJO+Ng5huwXThZ6asAnbC1znjPEVCvVjDrbUMDAAWHkEtBxPaKOSKGK3MByA5ztT0BOuU2k4gt1M+OKOiaDkAk6nuJ1yuXUVPU3mcxmV7zzPE7KvKbRLiWl7lW6Uf3V6jY77WWkea65T0LSwHh5hdTxzxFc7LWNpaJwZG5oIwB5Fb/ABZeq+11Qp6VwawgEYCzn7OMFrfANwGlc2lp/wDpB0Z5ce67dNSDgcMbELkF/g9EvbhyHEsr8OK+SSoq4i71nt5veqPBNZI+aoiJ9Zwz71rKGzNZAxrWjGOeEissmWkFq0ViaKi3wP8AvNCnTUYLeWV41VyzCqe6Rx5w45PXOV5lO6Tt3GQkuBOvjlcbutE631ZbyHMKy9FivVsdBVU8VZTPAEkFRGHscPNp2Ks9e0LYRFIBjOQmtJR9/TuB6L2W9yG98I09wl1kjOCe/ofovTrpIbpw5DWS6vYcZ+X2WQZpql06HRULHwUxJPcOcXtb/CTvjy/JYLWd+k0rWwvqmE0U5IE8Y3j946+/81366WZs8LgWrm+ptM0l3p57dcIuOB+W8Q2c3zB8UtkmZxdY5LPU6zRasJ3IGP8Awn2mo/j1qfbicTR6s8R+9FX6cqo6y2NqI5GywvGWvacghXemL73dWWF27SsvarPHobTstPJUd/BDn6wDG3jjp0VXb7mO8ZUwSNfG71mvachwKzeN2OobLbaBw1Dckfv97qe9l0NBR0rxh2MkL07Za4VVO3ffCt2HZc10LqEVULBxb8iF0eCQSMBC8UC4VwwU7jKPBRtRgZSpqIDCMtwlAYR45oTwkOGAq292ilv9qrrVWs46SvgfBIPJwIJHmrQjKjVMZc0gHfomKQdxXz/vmn59OXe42WuYDU0crqeTbZ4HI+4jB+K3HYFqiWgqqiwSyZmoj6RSFx9uIn1m/An/AIj4LZ/Se0eYqml1ZTRY2bS14aOnKOQ/8p/urhNPdnaV1FZ77HngppgJQ37UTtnD5Ej4q04dpHgb/dZUZ9EqgT7Ox8j+i99UE7KyjimjOWSNDmn3qRjAWa0BXNqLdLThwd3LuNpznLH5IPz4lqC1VQeYArTkYWPc3uSEC1LIwhjbKE1Muam3NUhwTLwkwlCg3ChiudFU0dQwPgqI3RSMPItIII/FeYOx6sm03cbvpyocfSLLWvY0Hm6MuIz8wT/eC9UP238N15V7Zf8A+X3b9S3YfV2+8U7HTEbD/du+RY13xSgFwLRvuPMKZrxE9r3eznB8jp8ivRNHOJomuBzkZypXNqzWlK7vqURE5cz1fh0Wglm7iCSXHFwNLseOAkDg4cykdGWPLTuEUrwHtja0ySu9ljefvPgPNL/Zb5h9bO6M/dhxt8SDn8EqyRH0GOd54qidofI/9B5BWAaSpGMBGSmPdynlCz9fQz0LTKHOqaYe0CPrGee2xHwz71G4WyM6Oa4c+hC1RZlZqqpP2fWOiAxBJl8f7p6hRyR8uoT4382hTmmajNB6K8/WUju4OefCPYP+HH4q5dyWagcKa5PkYfWc1veN8Rvwn4YPzK0FLOJ49jkjmrsL+ZoBTntI1RviY/iY9oex4Ic1wyCDzBC4tqC0f7P3yqt3rFkeJIXOO7oneyfPBDm56lhK7aeYXL+1QtGq6YDHeCgYXePCZJOH8Q/5pswBblQSjLMrJoIicI1UCqApQOUEnklJU7KUDlKBwkcilA5QhLBwlApsHCUhNKXxIwcpsFKQhOA4SgcJCUDkITcpwOTgOUy0pQOEJcp8FLBTAdhONchOynmlOByY4tkprkJcp8OSg9MByVxoS5TvF7kXEm+JDJQlyll6Q4pJKTxIS5RoJCCEmUrkElAnCLIShLlGlpCPiTkJSMFJByjShJlKRg4SeJHnCcgJaMHxQpIKi4zGGjp5KuUHDmxDZv8AE44DfiQtTbOziqqSH3GsFOz/AHNIMuPve4fkB70oBKglqI4tzqspJURw4L3tZxHAydyfAeJVnb9PXe6kGnoXxxn+1qj3TfkRxfh8V0e06Ytdk3paRjZcYMz8vkPvcck/NWZfgeCkDB1WY+ve7SMYWKoOzUEB1wrny+MdOO7b8Tu75ELSWzTdss7g+kooopRt33DxSH3vOSfmp5lHikmdoTsAKi98j/bOVIaU9EwyvDQokcxeQAN+gVvTQdyzJ9s8/JKo8YS8cIA6IJXNERhCciQQQQmoYCIbc0aSeaTCEfEhxIkEmEmEpBE1Glwmr3Mgq6PUFE8byFn8TSnmXWkfyqGfE4/NNUGCpaCbZUxS+xKx/wDC4FOIQAggiJwi4k7KCg7miQQSpdkTklGdyiQmoIIIiUIRIIiQBkri/b127wdmtF6JSHvbnMMNDCDweZC0rdbqi6VLaWlblzv3kq/Q0M9xnbT07cuK67V3ejof6+oZH7yo8WpLZO4NbXQcR5N7wZPwXg+mq+0XtZqJKk3OoEDz1cWge7ATN07Mdc6RYbhBVVEhYMmZrzke7OV6YOBqSJwp6m4MbN/T492dF3w4RpY3dhUVrWy93j3Z0X0HY9r2jBznklE4C8c9iX0lq6huEVm1HI58Tjhs0nMOOAMletjcY5aIzREPbw8QI67LhL3Yayw1HYVI0OxGxC5K7Waps83Y1A32I2K5n249t9N2ZWsshPeXKUYjYAHcPmQvLbdVdpPazUyTQXCVtOTyYeBoHwVf2s3ebXva3LCJO8j7/u4mk+yM7t/Ar1roDRtPZrFR01NEGNbG3fG/LqV6dJ6HwVa4JBA2SplGcuGeUL0CQ03ClvheIg+olGcuGcBeT7pojX+jwbiKqrl4dzK17iGnyyuj9ifbvNeK+Gw6hPFNI7gjndzJA6r0fX6bjqICx7A9p5gjOVwSX6NjW6xbc6aUwMbKZAGnGDny96pR8TW3iCklpr3G1jwPUe0a5VWPiGhvNNJBdmNa4D1XAdV1m+aVjq6cyRNyCMj3Lxp23WV1j11O3GGysbIPf1Xv61WwwWmGCQ8ZjYGl3jheR/pdWJtHebZWtbw8QdEcfNZH4dTtp7+IwdHtc37j6KjwRP2V4DM6ODh9/sqLTNq9Ks9PMyMYewHICTqO0F9tmbjm0rc9h9pZftAU7yMyQvdGR5A7Kx1VpJ8VNKBGdguSugkt98lGdWSHHuKw64mkusgJ1Y8/IrzfomoNJqKJpOOPLD711G5Rd/QSt8WrkszHWjVJBHCY5/1/zXYmt76m23BbsvQvxIYBXUdyj2kYPkc/QhdrxoMVVPWt2e0fLX7rjtlkNu1JDnYNl4T7lvdbXb0KzGNp9eUYx1wsDqKI0N/lIGMPDwpWorm6+V1PHGeJvCMe88wu+uVobe7nbbq4fywzmcf8uHD5k/BdbWW8XOuoq9w9QMy4+WCPqrDRlqMkMtQ4bu2Geqobow2++PPLhkDwuoWC2to7fFGBjA396wWvaT0e7hwGA9v5LA4Wvn8V4nqg8+rK0gDwbt8ljWC6en32o5j6sgIHkNvkurWmUT0kb/vNBRXmpZQ0EszvsgkZ6qr0TV+lWKmcTlwbgql7TryYadlGw+s85djovI7fY31l+/heNnkHyadfkvPqO1Oqbr6BjZxB8gdViKakk1FdJcE+sS4FSaGtrdH3bI4gwHBzyIWl7PLOfRn1DhgvOACr7Uuk47pSH1cSgEtI8V6/ceMaamvD7RUtDqQAMI7iOv2+a9DrOJIYbk63TNBpgA0+B71sdHaqhvNMyWB44ses3qF06zXkmPgc7YryPYJrtpm88EEMkmHAOa0HBGV6R0HTXvWMLP2VZqyulzwvELfUjcObXSOIYw+TnBeUcVcPMstSJKOQPhk1bggkDfBG/vXBcQ2eK2SB8Lw6N+o1GR5/que/SA0i2aRl3pGDvHO+swOmOa41ZHuqL3SulfxeuMl56cl7rvnYRcJ7HUVOpLlT0NKyMudTUI7yTlsTI4cLT0LeFw8HLzB2D2JsvbPFHC3ijo53EN55Zkj8sL1fg6+yzWCqinGsDTg+BB09y7fhm8uks9THJr2LTg+BB0XdNE9lGrNUQRilthoabGBU3MmBvu4SDJy5EM4T4rsFg+jVZ6aNj7/c6m7S/agpv6LCR4HBMmR4h7c+C6RZuJlOxo2AGFZFy+eC1uSTqvFDI92uyhWLTNk0rG5lntVJbuIcL3wRNa+T+N3Nx8ySp9RK6RvNIByhxJc9Ao+XXJXG+2LsVtPag6mN077hp38bRC7hJ2xzWVsP0bdH2ZzTHYop3jk+oy8r0RLStl5pDKFjfsrajvdxipxSxzubGNgHED5LUZdK6OEU8czgwdASB8lzy1aCora1raW309MG8u6ia0/ktJQ6ea05cMlaUQNHQJYbhZD5HyHmecnxWa5znnLjkpmko2wNGFKRN5I1GkQQIygghCSGAdEpBBCTCHEUfEQiQS5RhKErgliocE0gjJScoR1cdPcaY09XBHUQHnFKwOafgVnZuzLRE7i+TRun5Hnm59rgJPx4FoDy5pOcoygNxsVXW3SGnLJI2S3aftVve3k6koooiPi1oVy+pLjknfxUdBNyUuB1SzK4pJJKJBNSoJLkbknO+EJyQ7dR5G5TtRUR07S+V4Y0dSVSz6ws0Dwx9wgYfFzwB8ypmRPk9hpKVsb3+yMqVNFnKrKmDOdlPpbtRXJpdS1EVQ0bF0bg4fMI5oeIKNzS04cMFJq04KytbTHfZUlVCRnZbOqpeIHZUdbR4zso1KCsfWQcQIIWJ1PfrZpyJ0lbVxU4xtxuwttq+uisNpq62YhscLC4k9F4qvl5uvapq98QleYC8hjCcta3PNd3wzw3/HHSTVD+SCPVzvsF11isn8Vc+WZ/JEzVx+wXTbn272WmlLYeKceMbeaesfbNZrzO2J/FSuccNEhBVbbuxe3U1O0TRiWXG7tysfrzss/Y1M6soOItaRxMPNddTUXBlfKKGJz2vOgeds/RdDT0/C9ZIKSNz2uOgcdsrvsUsdRG2SMh7CMgjksb2lawbpW0udGR6TIMMGxwfFZbsY1TWyxyW+rEjmtd6jnjkMLK9ttydU6nbTuJ4YWjA8Qd1nWfhLl4l/htUeZjPWPiBt/dVLbw7i+eg1HrNb63mOiqLPp6v1xWSVlS492Tu7OFoarsnhFMe6kc2QDOTvla7RLaC12CmbJKxg4Qck4U26a3sNAwh1XEXeAdlalw4kv9RcHRWprmxsOGta3TA01Vytvt5nrHR25pbGw4AA6DvXGbVda7Q974HucGt2czOxB6rvNBcI7lQMnjIIe0H8FwzXt+t99rhNSAl2AC7GFvOyy4vrbJNA4klgGPktLjS2vrrTBeZ4uzmGA8YxnP91o8T0b6q2w3OaPklGA4ea53qec3XV0rXnGZeA+/K7BZbQ2KjiYGhuGgYAXHNVReg6smeQR9YJP9fJd8sTm1Nvglbgh7A7PwVHj3Lbbbey/w+T54CpcYDFFQ9n7HL88BRprW0t5LL1OhqSeu79zPWznYLoroQQodU2GmaXyuZG0faeQAvIqStqaRxNK8tJ006rzinqJ6dxNO4gnTRVVFQNghawey0YCKupWuhcMcwp9DXUlcSKeeObh58BzhKqoctIVeRsjJD2gId47qF4exxDxg+K87StNr1O5vIxz/AJn/ADXa7aRLSxuB6LkvaJSGi1PK4DAeA8HzXUtHz+mWeneN8tC9p46Hp1pt1zH5mgH4A/XK9Q4t/wBbt1FXjq3B+A++VYVEOfkuR9odJ3FyEgHMrtUsXFGuZ9qFD9QyUDlzK5LgOq9FvkQOzst+K53hKp7C7R52dkfFT9CVIqLQxuclhIK1D2DhXFtPXqvtLnOpQXs5lnRX1R2k1skZjbCRJ5bLpb5wJcKi5yyUZa5jjncAjPeFvXXhGslrpHUxaWuOd9s96X2kVTMxQAguzk+SGhKVwpXvPsuOQs/T26v1DXd5K2Qhx3c4LpdltLaGmbG0bAdOqm4mlprFYIrBFIHyE5djp1+qffZYLTaI7NG8OeTl2OnX6op6YPYRhYvVVlLmd6wbtOSukup/VxhUN+ibFRSvcBgNK8tsdfUW24RVFN7QIGO/OmFwdrrJqKsjmg9oH450wuRm3Q3WOSkqIe/glaWyRnq08/P5LkFz09Wdkl7bTVEr6rSlfIRS1zudNIf7KXw9/I8xj1gO86cgE91JHIHIVtqvSlLebXU01TTMqqKoYWT07xs4eI8D1yNwRkL0T8TKrtrpHCdmsHz1XbcbVRdcowPytHz1wucaPuz7bXtaXeo4rvdjrm1NOxwOQQvL0dsqdEXSK11cr56B7uG31z+ZHSGQ/fA5H7QHiCF2zQN844mwvduB1Xi2OU4XPMe2eMPauntOd0sc1Gp5g9g3UgdE5JhOAZQARDySJ5HN7uOMAzynhYDyHiT5BCcAlOkHeCNrXSSHfgYMnHifBM13f0sXeOpXuYNyYyHED3K6o6NlFFwt3cd3vPNx8SnXDOUvKmdqM6DRc81TaKHVenamCVoqKOpjdFK0eB2+BC8Oak01UWequ+nas5qqNxY1xGONvNjx5EYPxXufUrf9mbo2qDSLZWnu6ho5Rv6OXnz6SWlhS1Fs1RTtHCHeg1jm9WneNx9xyM+YUkZ6JlbCHxiQbfvI9y2X0db+bnpixTOOXy0hpJMncuiJAJ8+FhP95dqLd915g+jFcu6hq6M8qS5h7Rnk2QAfkHL1C/mocYJHip3u52seeoHxGiSi4kZ3CCVMSHBMPPgnnbJh/wCCYnhNOOdl58+l7YW12mdP3cNHFS1T6N58pG8Q+XdH5r0C845LAdtmnXan7MtQ0UbeKaOD0uLHPiiIkIHmQ1zf7ycw8rwU2VvNE5veFzrsN1a67WCmbPJmqpD6LPk7nHsO+Ix8QV2ppEjCOh2Xjfsw1ONNahp6mR/DQ1zRT1Jzsw59V/wdt7iV62tFYainaT7QHC4eaa5vZyFnQ6hWYJPSYGy/mGjvPofeFdWAl9pp882jhPwOFZsYqywbQTx/dmd+OD+qt2t2U8XshRzaPcklnwVfeaP0ijc4D12es1WhGUh7Q5jhzyMJ5bkYUDXcrsrh3bFfbrpK0W6/2iRjZYJ+5njkZxMkieOTv7zW7gg7nxS9L9ttNUwwyV9vkp3vaCX0jhIw58nYI92602v9Pft7R1/tnBxS9w58Lcc3t9dg/wATQF5v0pViShazOXROx8DuP1VZhwNNwpql74pAQfVIXpp/arp9tP3kUs9TMOUDKd7ST/E4Bv4/Nc3ud1qL5cqi4VRb387s8LfZY0DDWjyA+ZyeqpIHgxtPiFMjdsnPcXbqk6Z0mhT5OUSTkpQKZhAKUHIwcJCAOEJ6dzlGDhIBR8SEJxBISm8kISwcpY5JDeSMHCExOA5Rg4SM5Rg4QkynAcpYOU0DlGHIRlPA5Rg4TYclByEuU6HJYdhNByUhLlOhyPiTQKPi96MIynOJDiTfF5oZCEuUsuRZCRxBDiQjKXxBDiSOJDiCEZS8goYCSghGUtBJBwjzk7JwTgjR8STC2Srn7ilhkqp9sxxDPDn7x5N+JC2Fl7PjIWy3WXiHMUtO4hv95+xPwx8U8NJUMs8cO517ll6CjqbtOYaGnfUyA4cW7MZ/E7kPdz8AVsrP2dxsLZLnN6S/n3EJLYh7zzd+APgtXS00NFA2GCJkELBhscbQ1o9wCe48DwUoaAsiWrkl0boEKWkho4WRQxMhiYMNjjaGtHuAT5kDR4KMZcBMvm807KphqlPqAmH1BPVRXTeaQZEwuUgapJmKNrsnxUYOyrqyW/vSJ5R6o9kHqUDVKdFOtdD3LBLIPXPIHop6BOUFKot0EEEEmUIjhJRnmiSZQgkpR2CSlCEEEEAMlKhGBslAZRJbRkIQvUqMHCLIRcSYo8pXGPHCdjqZY/Yle33OITHEhxBMSqey7VcfKdx/i3/NPs1DVN58D/e3+SqeIIcQQkwFfR6lI/rIAf4XYUhmoqd+zmvb8AVmEOLyS5KTlC1zLxSP5TAHzBCfZVwyexKx3ucCsXxIcfgUvMk5VtycoLGR1UsfsSvb7iVJZd6pnKYuH726XmScivbrWChoppiMiNheR7hlfPLWNfUdova1MHvM7H1AYzJ/sweXyXt7U2oKk2erBax2YyOWF4Q0vUCydrFPLKfVirjkHqC7l+IXtX4dNa2OuqWD+Y1nq/P+y9T4HZyMrJ2j12s0+f8AZe3NG6TgtVopqanjDImMAG3P3q8rtOslgexzOJrgQQd0/YbpRdwwcTmbfaCvX1NNMw8MzD8V49JM6SQyOOSTnK8re58jzI46nVeEPpD9nzdIalNwo291BKWkBuwaf/NegOwDXcuqez6cPk4qikPAc8/ZyPyVJ9LG2wy6S77A4gfVPmN1i/ojVT2ftanP9VK0HHmNvyXtlVIbzwa2pn1fC4AHwBA+i9bqJDdOFW1E2r4iAD4ZA+i5JeQbL2vTPPqiO4CTfwLsn8yvoJppsctDBIwDgewOb7iF4c+kdpebT+uzVtaWxVMYeHDoQcL1T2B68p9X6QosSg1MELGSNzuDjH6KHjeM3G0UF0i1aG8p8Nt/eCm8WMNdbKK4x6gNwfDb75XV3wteOShvt7OLOBlThIOHK86fSo7V67SdFTW+y3OSjrZf6zuThzRzHzXlNntc15rGUUGjndTsPErzq2UEt1qmUkO7uvQeK9CNYGsOF5b+mNAwW2jJwHF3E34HB/Ban6PWqK2i0BPedQ1s8pPEXvnJceEbgj4Lhv0iu12h7SrnTUtqLpKSndlry0tLidse5eicKWGppuJAyP1mQk8zgNNv1XccO2iogvoYz1mxE8zhtsuo/RQiM2lqhh3Y54cPfyK7Jf8ATLKqneOAbjwXPPovaemsuiojK0jv3d63PMA8wu6VFOJICFxnFUjJr3UyRnI5j8lyvEMrZbrUPYdOYr52dtNjdYdcTtA4WyNDx7+q6BYWGssVHUAZa+JpytD9Jfszu1/v1DU2i3SVbvWY/ux7I55Kn9nehLnbtG09Lc6fuaqIkcOc+rnZdtxLV01x4XoHiQdqzQjI5sYI236BdjeayCssFG/nHaM0xkZxgjbfoF5/7RqM092a/GzhjKh6Ltvp10a9wy2Pfddd1/2cC6VDXPc+MMOfVHNVWn9JxWUcMbXHJ3LlZHG9NDwu23Rk+kcvLtoBnv8ALuVwcUwssTaJhPbY5dtAM9/krikp+GLksP2iWWorTC6nhdK8O5NC6OyDgbvsolVGw815RZbxLZK5ldC0Fzeh2OdFwltrpLXVNqohkt6HZZPQVHV262GGpjMZDiWg+BUO+aKku1ydU1FZ6mfVa1u4C6dpLs+1FrUsNis9TXxOOPSWtDIBg4I71xDMj7uc+S7VpT6JLiWz6ovAzsfRLYNvHeV43B5EBgPg5aTeJLiy4TXKlIjklznABxnfGc4U7r9Uw1ctbC4Me/fAzv3Zzheb9P270ZlPRU8bp5Xnu442MLnyO8Ggbk+QXYNL/R51hqqKOaqpmWGidj62vz3pHi2EetkH7L+D3r03pPQWndCwd1ZLTT0JLeF0zQXzPb4Okdl7h7yVoXSl2y52QulkdLKcuJyT4lc5JUPlcXnUnUlcT019GfTGnpWzVrJL9Ug5cavaHPUCIeqWnwfx46FdYpXU9it7WtEdLSwsDQ1oDWtaOQAHIeSn8AJ5LPa3tRvWnK2haS10rC0EdCpYgwyNa84BOpUbGB7x2jtFxL6RH0hrHaNM11soJ2VlZOwxERPacA7Fcb+h9pOes1FVX2ZhAaC1jz9oHYpyn+iJVy32aSunJpXyl2OPBIJz0Xp7s30JR6OtMNFRxd3Ewb9cletXC5Wiy2aS2WmQyPlxzO8O77L0itrrZarW+321/O+T2neC6Hbhwwtz4Jyavhh9p4Hks/cby5mYoTsNi5VDpXyElzic+a8gAXmuFr/27Sg7vI88KTT11PVbRSNcfDO/yWGyUOItIIOCOoS8qTC6EAjAysfRalqqXDZMVDPB53+a0FBf6OuIaJO6kP2JNj8OhSFJgqx4UOFGi3CTCEaCCCXCEEEEEYQggggkwhBBBFxBIhGiJ8ECcJKEIIIIE4GUIQQXnD6UfbrqjsoFA2xR0zGVDnMdLNHxkHGRstb9GbtQr+03s5huN2mbNc2TyRTOa3hGx22XSy8P1kNqZd3Y7JxwNdeu493et6Sy1UVubc3Y7Nxxvr1/RdiJwsZ2gdrumOzOCKS/XJtJ3pIYzhLnOPkFsJHepleUPpv2c1ulaatDcup5muz4A7FM4eoKe53OGjqSQx5xpv4bptko4a+vipqgkNccabr0J2e9pVm7TrB+2LJK+WiMrosyM4HZbz2VrqbUdJpey1Nxq3hkMLC45OM+QXlX6CupC6xXy0OdvDO2Zjc8gRv+K6j9Jaw33Vuiv2XZccczgXOL+HGFqXCxwUXEDrW9/LEHDUnZpwck+S0a20w0l6db3O5Yw4an+k6/Rebu0j6Rmru0zUMlr0xU1NFRlxaGxY9YeOQFVHsF11eaZ1VWXSaWQjPdcbjn8cLrn0euxGq0O+oqbo2N9TJjhLR7JXc62e02mEuq62GIj7zl29w4qjtE4oOHoW8jcetjJcfhldRXcRttk3odkibyN/NjJcvBts1trbsW1JHBPUyxiEgGF54oy0+Hnhe9OzLXtP2g6Vp7pDgcRLXgHk4c15O+lRcLBd6aKW31DJ6tj25LfDktn9CLUjqixXm1SP4nQzNlYM8mkYP4q3xNTMvPDzL06Hs5mkB2BjIJAVu/wNutkZdnRckrTh2mM50XqeaLiaqyrpwWlXAblmFDqI8tdsvBSF5CCvP30lauS29n1bJEfWJDXDxaea89/Rztsdfea2QjMsTR/hOy9NfSIsrrroavja3J4HZ+Wf0Xl36N11ZQ65NLIeAVMTm7+I3AXtnD7e14Nr2Q+2Dk+Wn2BXrFnHa8L1jIvaByfLT7Ar0y2ys4N2qnvGno6qJ0b2BzTzC3QhBj2HRQaulGCSF4kHFpyN15cDjULmtHpWltri+GBrDzyOa4L210TqfUjJXD2mlufdyXfdTdp2ndP3D0GoqXOq3HhEcbCd1z3to09+37JTXKkYS5ruMjG+CF6rwdNVWu8QVVe1zWSgtDnZ1yNNT0XoHDMk9uucM9YCGyZALuufNcw09ou5akomTMqn9wfVDck4WoouxloAM8rnfHH5Ku7KtZQWWo/Z9c7u6dxJDncgV3unkoZoWyNnjc0jb1guk4tv8AxDaa59PGeSInLS1u48+/vW1xHeL3bqt8DDyxn2SBuPPvXMqPsqt9PgmIOPiQtVZ9Nw2qMiCPgyN8JGtddWvTVBIY5mS1JBDGAHms52VakvGoJpzVgeht3Y7h3znllcPUUt8uVtkuVbKezbj2iRzeQ6rk5aa7V1C+vqpDyN/qJ18h1WQ7X9OPpq+OtjbmMs9c45HK0vZTq6GroI6CaUNmhaGgOPNb3Uun4bzQSQStDmvGFw6+dnl0sVa6agLnRg5BacELq7VcLfxJZm2S5SiOSP2HHb99F0VuraO92xtqrpOR7PYcdv30XfZJ442ZdI1uOpK492vaqp6xkdvpZRI4H1yw5B8lnI/9rqiIQ/XRtxjLzzVvpvs0qZqsVNzc1++eEHdSW2x2vheoFyr6xshZq1rTkkqWitlv4fmFdWVLXlnstbqSVpOye3SUVlD5BgyHI9xW/kiyxR7XbxTRNY1uGgYAVoYQGYXk12uDrpXS1jxgvJK86uFa64VUlU4Y5jlcR7X7TI6so54onPJBYeBufNX/AGZxzx2aNk8T4y3YBwxst3W29s7t2gkcshJp6HucbLoaniV9TZIrM6MYYc82ddzpj3rVnvr57VHa3RjDDnmz4np70RjyzxWL7QqD0izvOM8K35iwFQampPSbXUM5+qSuetdQaWuhmH5XD6rIoJzT1cUo6OH1XGNCOBuZhcMh4LcFdFGnKd2/cMB8Q1cxsMht+pmjHKT9V3WniD2A45r078RO0p7myphcQJGA6Hu/8rueNQ+G4MnicQJGg6FUdPZ2xey3AVhHShgIVmYAEhzF5A5xcckrzfJJyVT3KoZQ075X+y3muX6n1oLnG6CmBDTsSRhdWulGKunfE7k4YWLi0PSwTl4bxb5wRsu74YrrLbS6quMZfI05aBt7119irbXQl09awue05aOipNGWdzIjM8YLuXkta+l9UqbSUAgYAGgAcgpDqfAXNXq6S3mukrZdC47dw6BYlyuElzq31Umhd07h0XK9baQp7lRzwzQiWlmGHs+6eYIPQg7g9Fg9N11Xpm7x2q5Slzif6JWnYVDfuu8Hj8ea7/XUAmY5pbnI3XNtXaQhr6eSnqIy6J27XDZzT0cD0I8VgvbkJlJUGF+enVbzT11FZTtycPA3Cv4ps7LiujtSVNguENpvMn1pPDS1x2ZUjo13g/y69F1+ml7xoPQjKhac6FdIQ1wD2bFWbTn3JukladQtY7m2mLmjzLhn8kIn7AKDdpTb6uiuQ9mF/dy/wO2z8DhOceUZSMZzEt7x81qweJDwTUMgfgg5HknnclIVnAY0VZfrRDerZUUkwyyVpafLzXELhZH6msF+0bdPVqRC6KN7+o/s5P7p4Su/ucAufdomn3Q1FNqCjYXTUm07Wjd8R9r4jcppyDzBaNM8OzC/Y/VeR/o/XSeg1jerfMDFUdy17mHm18buEg/4/wAF7TinbUQxytPqvaHj3EZC8c6no26J+kpTVMZDaG+N7xpHImVpafnKM/EL1VpKv9NsVOftR5iPwO34YSu9vPeAVG1hEHId2OI+OoV7ndGkA5SiQMdT0CamJLhlMSDzwpzKXi3kOP3QUt1PFggxt+IT+zJS8wConu9YgdE0/ZzSQCBs4EZGPNP3an9BAniH1WfXb4JoESMBBy1w5qHGpaVLnQOC8Sa50h/sRri92AsxRsk7+k4vtU792jzwDwk+IK7V2K6xdebIaSpeX19uDYpsneWH7EnmRgg+YPinvpL6O/aVgodUQMzVWl3cVOBu6me7GT/A8g+57yuJaW1JUaQv1Ld6YF5hPDNCDjvoj7TP1HmAp5GmVgI9ofv5rPpZhQ1Ra/2XaHyOx9xXsiyzcNTMw8n4ePlj9FfM3CxmmbpS3SlpayimbPSTxiWCRvVp6e8eHw6LTsqnNA8FHC8cuq2aqE82n/nxU4jATbncKQyqaRvso5mMjiengrJe3oqDYnZ1UOogDa8SYHrDBXj+soRpjX96tAHDHHUyRxg/dBJYf8OPmvY054uHyK8m9vkP7H7XKmdgx30cNQPPDQ0/8hUHL65HeparWBruoKuaB/FTN8RkKdG7ZVNplEkJIOWnBBVowpqyBupDXJYKYaU60pMKUFOA5RpCUDlKpAUtvJGiByjQlylDklNSQQghGUsHCUDlN8YHNGx/HKyNgL5HnDWtGS4+QQhODmlZCu7b2f6juuDHa5oIzzfVYhx/ddhx+AK01D2J1r8GtutPT+VPG6XPz4cfihV3TRt3cue8YHVH3oXXqTsbskIBqKqsqX9Rxtaw/ANz+Ktafs10xTbttYe77z55HfgXY/BChNVGNsrhgnASu/HmvQEWkrBBu2y0DiORfTMcfmQpUdptsXsW+kj/AIIWj8gmKP0xv9K87CpblONnBXog26hf7VFTuHg6Jp/RR5tM2OpB7yzW9x+8aWPPzwhKKwf0rgQmaeqUHgrtdR2b6aqsk20RuPWOaRuPgHY/BU9Z2N2uXJpa6sp3HpJwyMHwwD+KFIKuM75C5bkIZC29b2N3WDJo7hS1TR/vQ6Jx9wHEPmVnLjovUNpyai01Dm8+OACYAeJ4CcD34Qpmyxu9lyquJDiTLahrs7jY4PvTgcD1QpEriRg5SUEJcpYOEec7JAOE/arfVX6Uto2AQNOH1bx9W3yb94+Q28SOSUDOyQvDBlybLvWa0BznuOGsaCXOPgANyr22aPqK5zXVrnQRHlTwu+sd/E4cvc3fz6LS2PTNPbm5iaXPIw+ok3e7+Q8hgLQwwMp2+qN+p6qcMA3WZLVudpHoFGtNlp7VTtjiiZCwco4xgZ8T4nzVhxY2CbMgCbdLhPyqOM7p4yYTbpQOqjul800+VM5lIGqQ+dMPmymHSJHHlNynp0vyjaclMg5U2ipXTvAA2QNUhOFMtdCauUZ2YNyVq42CNga0YaBsFFoKUU0QaB7ypina3CgJygjwUYGEaCm5SSMIkZOUSajKBGUhLJwkITkOaSlIiN0JoRJQ5JKUOSenIxzT0TclNNClU7coQvTOQhxJKChUeqPi8kOJEghGqPiQ4vJJyEOJCVK4kOJ3gk8SLJQhL4ihnySMlDJQhKQyUnPmi4vNCFEucRmp5GEe00heJ+2Cxz6W1/UTsYWsc5szHjln/QXt6ZvG3kuV9rHZxDrK3Pbw8FQ3BbIB4dF3/Bl+ZY7jzT/4Txyu8PH3LruGLyy0VvNN/hvGD+qu+yjW9PqzT8MrJAZYwGPb54W+dOOD2l4ZoxqzsqukjqVskYaSScFzD5+GcLST9vurLpTejw0sj3uGC8A/oumuHAEtTUGotczHQO1ByNMrerODZJ5jNb5WuidqDnZbL6UWron0lPZ4pMy8fG7B9k+HyUj6MtpqbVaZ6xwwJ3ZbkcuhC5ppjs0vutrwK28xzxQudxF0m/F816j0lYYrNQxU0LQyNgxsMZS8Q1lHZbIzh6kkEjycvI278JL3VU1rtTLJSyB7icvI28lTdrGj2a7sUkMsY9JDcRyY3bvleZ7Rc9Wdjl8kdRtkjAdnBaSxwHLK9pz0wfHjCzN30pTXAFs1OyVp3w4bLmuH+LZLTC6iqYxLA78p6eSwrNxFJbInUk8Ylhd+U/ZcMn+ldqy40XcQ0rpJ3DhL2AjfyAVBpXs81D2o6jFwvnfx05eHOdOCQR4DK7/DoKgheCyjiZj7rAPyWittn9GADRgDotuTjWko43ts1GIXO05s5I8lqP4qp6WNzbVSiJzvzbkeSm0+joBpJ1nga2GExGMYGwGMLk+lvovW+xXAVFXWOrntdkMMY4Qu2U8ksLNiVKhq3h2XNDlwtLf7jRRyxU8paJNXbZPv3XIU92r6SOSOCUgP1d3n3qXp60st1NHHGwRsaMBrRgLR848KlprsxowWlqtIqlszctOQsEkuOSsfOdSqy42ttSTkKtdZGtYWhuVpJ5o4onySPbHGwcTnuOA0eJKiwtq7uQLZQy1jXcql31dOAeTu8d7bT4xh+PBMSgLm+o9KMqGuc1mSua1Wn5p7mKGhp5qyseC5tNTROllc3OCQxoJIHU42XqGn7MnVx475cHOjP/sVuc6FuPuulz3jsHk5nd+YK1totFu07TGnttDBQxOPE5sEYbxuxjicR7TvEncppZndSiTl21XmrTH0adUX3u5rpLT6dpnHJbKRUT4/gY7hwR1LwR1b0XXdLfR/0VpYtkmoDfasb9/dSJh47R4Eex5Hh4htuuhukc7O6SnBrW7BNLnu3KWJQxoZGA1rQAANgByCSXF3MpPEiyU/KaG4SkWQOqJBInYR8SanibK0hOIIRhVD7Qwvzwpq7ObbqThZ6r37BXYyFDuVsZcYwHHhePZcOiUb6pMLGEdeaCkVlFLQy93K3B6Ecj7lHOymwm5Rc8ouFGOSHIJUiQ7kkOAI33TxGU24KMhOBUqhv9bbCBHL3kQ/spdx8OoWkt2sKKsLWVB9DlP+8PqH3O5fPCxUz2xNLnuDWjmScBZ5+s7G64xUAulK+rldwshZKHOJ8NkrIZJM9m0nHcMqZkTpc8rScdy7njO43RLzrrTt5pux2KAzOnljkPCymazjjzjPw+BHnlc+vP0/Z52Ftm0qTIRj+kzlwB8uHcrp7Zwvd7rGJqWAlh/MSAPmVuUXDl0uDBLTxZaepIA+a9lZA6pD52RtJc4NA5knkvndqD6Y/aPepjT081Nag48IZDD64J/eKhG3drPaFh9ZeblMyTfaVwH4YXXj8PaqBokuNTHED4kn7D5roxwTUQND66oZED45/T6r6LU15oayUxQVcM0jebY5A4j5Lm/aX9I7R/ZZWiiu9RO6sc3jbDBCXEj3rln0auzLUOga+equcskjZQQe9dk7jz3XN/pu2gi9Wm58GM8UJIH95ULTw/bKm/Ntj5jJERo5umTjOOqpWyzW+ovIt7pe0jI9pumTjPivaGjtW0etdOUF6oeL0WsjEsfFzwfFXi86/Q51P+1Oyiipnv8AWopHwYJ5NB2XeZ9QW6kb9dWQs8i8ZXH3agNBcJ6NgJ5HEDyzp8lzFyozR101K0H1XEDyzp8lYoKvptQ26rIEVZC4nkOMAn4Ke1wcMg5WO5jmHDhhZxaW6EYRpMnslKROGWlMwmryv9Naxmt0W2rAy+nka/3DOD+CzH0E9QkU9/tLnZ4ZGVDR4AjB/Fdu+kZYBfOzy6w8PETC78s/ovAfZvr+99n13nnsj3R1NRH3Tg0bnfK974bpHX/hOotjCOdrsjOw1B+xXsdip3XnhuegYRzNdpn3H7FfVTvm90S4gDHMnZcE+lDUWm6aAuNO6vpu/MbuFolBOemy8zS6o7VtcuIa64yhx6FwH6I5OwfXt4p31FxeYWBuXCaTB+Sy6DhOms9VHU1twY1zCDganT3/AGWdR8OU9sqI56utY0tIOBvp7/sp30Mr9+ze02ooS/hbW0pGOhLTle9JoWSUxc/GAMklfNDsfrpNF9sdl748JhrO4l8wdv5L6Jasr5oNF3SWmdw1DKZ72HzAz+ih/EejBvMMzNpWt18jj6YTOOqUG6xSt2kaNffj6YXm/tw+knNYrtLYNKOzWg8D5ixrhnyKwtl7Ku0ntGHpt5uj4KaXcZmwce4brn/ZFPSXbtXjmuLQBLK+X1+j85/mvoPZ7RE+mYWtaGEAgAbYWpfapnBTIqG3Qt7RzcukcMknwV28VDeE2x0dBE3nIyXkZPuXjvW/0ahp3TNVXyXB1VUxsJGATvjxKr/ob339m9o89EX8LaymIx0JachelPpA6gtmktD1hqXs76VhbFE77ZxyXirsY1C2wdqtkrchkLqoNcP3XbY/JbNkqbhxHw5XNrcuyDynGNhnT3gLUtE9dfbFWCry7IPKcdwzp78L6bU7uKMeCRK3Ypi21Alp2uByCOaflK+byvD1kdW2iO50E9PK3ije0ghfP3VFkruyjXzagNc0MldLGRtluTsvo5cImysOy432q9l9v1pSvjqYh3gGGyAbhd5wlxEyx1D4qkc0Eow4ff5rseG7220zOZOMxSDDh9/mqbQXa1ZNTWWB8lbHT1LWND2SHBzjp4oa17UrJp23SzOqhLIGngbHvk9Fwa6fR4v1rrHG3VTSwH+sLuEgeSOg7ALrXytNzuMhbnfhyfzXTyWHhPtvSvT/AOWdeXGvkujdauHO09I9M9Tflxr5LK2uGp7SNfOqw0iN0wkcR9gZ2/Jek3Wls1A2FzA5vDwkKNo3s8pNMUzYaZnERzkc0cRWyFGGxkYXK8VcQsvFRGylHLDEMMHXzXP8QXlt0mY2nHLFGMN/Vebda9jDnVT6i2OEZO5jPIe5ZWDSOsKPMML5Yo/vOfjK9U1lta/mFWPsrSc8OVoUfH90poBTzBsoG3OMlW6bjC408IhkDZANuYZK8+WnsmuVzqWy3KsLmZyWnLiV2TTOnYbLSRwQRhjGjoOav47S1p5KZHSBg5YXP3niW4XzDal3qDZoGAPgsa53ytu2BUO9UbAaBQ30vFHjCq6q0CQ8lo3N6Jp0QPRcrnCwFkzY28WcAn3KTDaRHjZXxhHwSCxo5BOJJRhV7aYN+yg6NTXs8k29iEqgPhB6JsxAKa6PZNOj+KEKG5ig1tMJWOaRkEYKtnM2TD4shOGmqFhm6PpIasythbxk5zhX9PDwNA8FYvpxnOyQ6IBWZ6mapIMzy7HecqWWaWYgyuJx3qM5qac3ClOYmnNVXCiUOaLiUZ9KM5wrBzU09qRIoRhwmpI8qa9qae1CVV8kOeiqbnbGVMbgRutA9ijyRZ6JCnArlV601T1TjTVkIlpJSGvY44xvsQehB3BWxpZTbq1tqqOGOqZCJIwDtLHy4hnwOx+Hipd1tTKyNzXNWGuOiovSjVNnqIK+PBpqrvC4wEdGg/ZPIt5Y2UJHctSmqOzdqdO5dHilBATk4jqad8Uoyx7S1w8QsjYtXNkkjoLuGUF0xgHlDUecbj1P3TuPPmtQ5xaN0zOV0Aw4BzdkWl7iWCS31D8z0p4AT9tn2XfJagOy3Yrn96ilp5YrjSg9/B7bR9tnUfDmtTZLtFdaOOaJ2WuHLO4PgkY78pTKiLP8xvXfz/urKQ4CjuIeCxw4mkYIPgnX7qFVVUVK0ukeG9cKbOFVYCdAvLX0stISWS22i+0bSTZ61r43gexE8jAz5PawD3rpvZpeWVMc0TXcTJGtniPi0j/yVb9Ie/W6fsu1K65uDIn0/c0rTzfMT9WB/eAPuBPRYjsS1IJ9P6dq2u9VtO2ll8i0cBz8Wg/FRE+q1w2BI+K02jmlfGT6zmg+8afRehzLwMJS6GUyTOJ3wEwMSRbciEi0z4c+N2z2nB96cD64Vfl9Q96vRuEksJRx7jyTvCrqpqJUU7ZoHscMtcMEeSylIXUlRNRSHJjOWE9W/wCv1W24MgrJ6ppXU0kVbG3L4T6w8W/6/NVJhy4eOisQnmyw9fqo9fQ09zpKmirI+9pKuJ0E0f3mOGHD5FeMbppmr07f7vYZnGettkhbywZodi2QDzaWux4OC9pOeJIw5py0gOB8lyjtO7KjqnVlLfbbWG33ZtI4AuGYpSxzRiQc9xIBkcg0bHAT2HBwqFXFlgcem/kuW9k3aQ7SFcLVWy8NnqZOOGVx2pZid8+DHdegJ8yV6btt0iuMOWkCQD1meH+S8r6r0jJTSFl2oX2eqkPD3pAdTzHycNsnw2O+4VnoztIrtDiKhvhkloY8NprlDl5jHRr+pHnz9/SKRmHc7Ou4+4WjR1TXRiCY6D2Xd3gfBeo2uylZKwFq7X7FUU7ZJLhSyMxkyRTNOPe3OQnH9stlqKj0W0xVd+rTuIbdDx4HiXEgAefRNa9qtyN5NXbd/Rbh/I+a4n2rdk9y7TtaMuFsq6SmoqWlZTSTzuceKVr3ktaADnAcMnbfbcg46TSw3u+t47qGWeldyoaOUvlcPCSYYx7mf4uiu4oGQQshhjbFEwcLY2DDWjwATxzF2TosWsro+zMUWp6nouJWfsRvtophCb1RTADDcwP2+PEFNf2WamjH1c1sqB4GSSM/8rl2VtPnchLEHkpMArD7eQdVwqbRWqKTJfZHzNHN1NURPHyLgfwVXUzPtpxX01Tbema2B8IPuLgAfgvRgZwo9wD57HzRyhOFW8bjK88RytkaC1wcCMgg5ynW8l2G56B0/dHOfJbYoJnbmWlzC4nxPBji/vZWZr+yiSMF1tuIk8Iq1uCf77R/4PimFvcrbKuN2jtFhUfEAtxaexjUNwIdU+jW+PO5lk43EeIDQc/HC3Vl7FrHbC2Sukmusw6PPdxZ8Q1pz8C4jySYJUrqmJvXK4pQ0dVc5+4oqWasmwCY4Iy9wHjgDl5rZWnsdv8AcGtdVmC1xHn3r+8kA8Q1ux9xcCu20lLTW2nFPR00VJA05EUEYY0H3DZKc4lHKFUdVvPsDCwdq7GrFQlr62Woucg5tc/uo8+IDcO+BcQtfb7ZQWZhZQUVPRtcMO7iMM4vfjn8VKIwk8Kcqjnvf7RQdKSkFxPVKLEnhTcJiJBHgoYKTCESCPhRgYSYS6oAYRoIDmjCVKAwjBIRIIwhOBxS2ykJtG1Kkwo91sVq1AP+kaCCrdjHePbiQDwDx6w+BCxN57FKOcOktFfJRv5iCoHeR+QDvaaPM8RXQEtriOqFI2R7PZK8+X3R970uC6von+jj/wBph+si95cPZ8uIA+SpmTGR7WMDpJHbNYxpLnHwAG5XqNkxAweR23WcrNIUUEslRbKSnpZX7vZFG1nGfeP1/BAAKttqzj1hquT2jQk1YWy3UmKDmKNjvWf/ABuHTyHxPRbukoI4ImMbG2ONgw2NowGjwwpIi7pxDmlrwcEOGCEHOA6qYYGyqve6Q5cjJAH6JDpPNNPkymi9ISmhqdMibdJjqmi9Ic/zTcp+Et0iac9Ic9JLsoSpRcg3dJGSVJghLiEYykJS6aAyuA6LT2uiEbQ4jB6KDbqLcZHvWggZwtAU7W4ULjlOsGAlgbBJG+yWOSeVGjQQQUZQkII3BEmlCSeaJGeaJIE7KCJ3JGThETlOSokocklON5p6EtgzhTadqixNyVYU7NkJCvRXEi4kSChUeUeSiQQJwhIggkk5QQhKyEXEiQQlyj4iiQQQkQQQQQhBRamlErTkZClIIQsjc9MQVm0sLJW88PGVXR6Ko2ScTaWNvk1oAW8dGHIu4blWGzysHK1xA808SPaMNcQPNZ+gsbYQAGgAdArynpxG0bJ5rA1KUBJOpTEWMpJiaUtBJlCa7gJTYw1LRsBklbHG0ySO9ljBlzvcBzRlLug0I1e2/RN0rgHSRto4j9qc+sR5NG+fI4Wmt+hLdR8Lqlz66Qff9VmfJo/IkhGqcsJR0tRXymOlgknkHMRtzj3+A8ytTatE3A4dU1LKJp5sYO8kx1H3Wnz9YeS2cMcdPE2KGNkMTfZZG0NaPcAlZKEKsodLWyhkZKYTWVLCHNmq3d45rvvNB9Vh/gAyrcyE+SbyUEuU3GUonJ5oshEgjKXCMuRE5RZCIuTkqUgk5KJCTKWgkg4UasudLQs4p52RD94pQC44ATgCTgKVkIZCqo9TWuR2BXQA9A6QAn4FWMUrZA1zXAtO4ITnMcz2hhK5rm+0MJ1J4lSay1CdMafrbi2A1LqeJ0gjaccWBleeOyH6XNX2ldokFjntMNuo5Y3uZJ3hc8uHIEclt0NkrrjTTVdOzLIhlxyNOu261qS01dbBLUwNyyMZJyF6arKSOuhMUoyOh6g+Kxt0h/Y73Cpe2OMbiRxw3C20UgkblYrtetgvOiLjA7mGEtI5g8v1WXTtEkrY3HAJAysqKMSSNY44BICzlFrmxXK5C30l1pamsOSIopA47c+Sn3i6ttVumqjG6URtLuBvM7Lwn2NXJ2lO1imY48DWVJidnwyR/Je3bs70u0zt55YV2vElgj4frIoWvL2OAOTp112XTX+yx2Srjia4ua4A5OnmuMaO+lM7VvaBRWD9kNoqeoldCZZJMvDhnG3Lou/skDxnK+eNU5+kO1vvG+oae4h4PkXb/mV7+tlYyooo5mnLXtDh7iFqcbWajtjqWWgZyxyMzuTrv1z0IWjxbaqW3up5aNvKyRudydff4ELmn0itaDS2iKmOOThqKkd2wtO7T0K8a6JvUlq1tabi55MjKpri7PicH811T6S2qpNVa4hs9K4vZBhoDTs4k/mFyrVmn5NKXWGLJBMbJQfA9QvWODbbBQ2ltLN/iVDXOI/3cY+hXpfC1DFSW1tNL/iTgux4bfQr2RrPQ9B2gUlOascTWEPa4DKz1P2P2S3t9Wk4zy9Zbns4rm3vSNqqx6wkp2H8MfotJPQsDDsvnCS5XCiDqFszmtYSMA466rw99dW0wNIJSGtJGAfFeFu12zjTPaBUCGPu4zwTMb0/1svcHYpcqLVWlaF0Mje+ETS6J3quG3h1HmMjzXlv6VNm9GvdsrmtwJGOicfEg5H4LoP0crt6bpClaHlssBLGuBwWkHmCOR816rxG91x4Soa/OXM9U/T/AOK9Bvw/iPDdHVk5LdD9PsvXdLZu4aCAvOX00dO+laI9La3L6eRr8+Azg/guyWLtBqqNjYbk01cHITMAEjfeOTvwPvVB28UNJrLs0uhpJGVEboHbt5g4zgjmDtyK8z4crBR3annzs4fDOq8/skxorlBMejgvCXZxrTV1npqm16abLMZXCRzIwTjotzFo3tc1UeKoqJqNh5iSThPyVV9FytbTdqEdHKMNqoXx4P3hyC960GnGOjBDQNugXtfF3Eb7FcTFBTMJcA7mIyTnT7L1Tii/Ps1eYoKdhLgHcxGSc6fZfP8A1FpvtA7LpBcn11YGggCpa9zg1x8M5Xp36L/0hp9eRiy3h4/aTCeB+fbAH5rbdrOlaWfRlxNUwOijjLzkcsLxd2AzTW3tlt8lISY4qk8TW9WZI/kqMVTDxlY6mSria2aEZDgMdMhVYqiLiq0VElVGGyxDIcBjplfTNj+MZSidlBt85kiaVLOV4AvGAsrr63i42CshIyHRkYXzb0zjSvbHSsma3gguXdua4ZGC7AH4hfTy8wd9RysxnLSPwXzT7drc/TXa3XSsbwkyMqW48c/5L2n8N5BM6rt7tpGf2+69X4EkEzqmids9v9vuvf1osLZIGhrQ1uNg0YCk3LTbX0crS3OWlDs3ujLzpO1VrDxCamjfnz4Rn8VqqxrTGdui8dla6GVzHbg4+C8tewxPLXbg/RfMXtaoXaT7W6yRo4eCoZUtA94P6L6Dafq49RaRpJSe8ZVUzS7z4m7/AJlefe236N1z1/rVtxo6ynoqYs4XukBJO+2w8l3js00/PpfSFstFRUCqkpIREZgMcWOuF6dxXd6K6WqgMMgM0Yw4a5Gg67bj5r0LiO50lxt1EYpMysGCNdNB9wvDva52SXns81RLWW+KV1M55eySEHLSSfBWdm+lJre328W8OdK+NvA0RMwQMYGcL2zqDT8F1jcyaFsrHcw4LFf+i+zxTcUdtgj3+wwBW4eOqSqpWQ3ekEz2bO/YVmPi+nqKdkVzpRK5uxXlS0aY1j22X1lVeZKuGjDsnvw4tx7lcV30Yr2dWme1TU9LQMlbJE+RxyCMHl8F61t1hipIwxjAxg6BTvQImEHCzJ/xAuLZc0TWxxgcobjIA7/NZ8vGdeJc0jWxsxgNxkDx80rRENVbLHTU9bO2pqGNw6RowCtBJUDxVNHM2ADCbmuPmvMJJDI8vO5XCuJe4uO5VhNUDfdU9cxkoOdwm5a/JO6hy1uSocoAVfWWqN7skKvdaIwTsraSqBUWSq57pclODVE9EZGNhhR52ADAUmSoB6qJLICkUihzMyoj2AdFLlcoz3ZShNUctA6JLksnmkO5pUJDuabcE4eaQeaem5Tbgm3DKdPJNu5ISJshNEJ5ybcM5QhMEblNOGCpDhsmnDKehR3tTT2qQ4ZCaIyhCjPblMuapLgo8zg1hJIACXCEw9u+yZcFV1+sbXRSFslSxpHPJSaDVtruj+Gnq45D78LRNtrRH2xhdy9+DhXjQVQZ2pidy9+DhWT2pl7VIDg7cbptw3KzVRUZzU25qkObzUWqk7pjnE7AJoGTgJQMnAVZeL1TWeEy1D+Fo8BuVhK/tPY55FNC946E7LPalus+o76YmuPBxcDWjZaq1aTp6anblnG/G5IC9lFmsvDNHFPeWmWaQZDAcADxXp5ttqsFNHLdGmSV4yGjQAKsg7SHvkxUU4Yz907rS0lZTXmDvIHB7TzHgqi9aRgnp3FkYZKASCOqz+l4622XMt4HCM7HwUdRbeH7/bpau1jsJY9S0nQ/EpJaSzXiikqLeOykZu0ndaq42SOpifFLCyohdzjkaCPkVVRW+steP2dcKimY3YU8x76L3YduPgQtq1nG0HHNMTUDXg7brxsxg7rz6Ooki9k4WXGpbvSAirtkVawf2lDJwu/wP/8AtlEo9c2ey1ckr56mztecujrKZ7GA+TscP4rSTWzHIKDNQHqM+9QmEHqtGO5zNGHAEFG3tO05NGXjV9s4Rz4q2NpH4rE6q7c9FWlz2Nvf7drBuyis7TVSSHw4m+oPi4K6uGlKCsfxzUVPK/7z4gSFT1elIGsLY4Wsb4NaAnCIfmKV1yeP8NoBXnjtLu+pO0yo9OuFO220NLk0dpa/jLAebnnq8jr8MDfLPYdqdtuvM1gqXcEVWe9pyT7MoHrN+IA/w+a7DetGh7XFjcbeC4br/RlVZq5l0oQ6CaN4kDmfZeDkFWMNezk2VCKqkgqG1JOT18R1+S9pabuZrbdHxn6xo4XDzU90op7jTvOzZvUPv6fquTdjvaDDq2ww17SGVLMQ11MOccg648DzHl7l1Kqj9No3NY7D9nMd4EbgqlkjQ7hdi5rSQ+M5a7UHwP6LVU+4UkYVHYboK6jZIRh49WRv3XDmFctflXmuDmghZUjCxxaUojCr71TtlpiSMgjBHkrAnKaqmiSne0+CRwyMJrTynKw1Gx1OH0zt+7Pqk9WlOyUzXvhcRkglg9xGT/yhTqikzJxciEy8Ykp2jnxEn3cJ/wAlVaCMBTVJBhcfBQKq0RTxPikjZNC8Fro5GhzXDwIPMLMy9kGmKhzj+zfR+PmyCVzGfBgPCPgFvOFJLRnZT4XLse5uxXO6PsH0RRTd62z8b+eHzyFv+Hix+C2lutFFZ6YU1BRwUVO3lFTxiNo+ACn8KUI/JKlL3O3KY7rJTjYQE82NOBiYokz3aPgTvD5IcPrYxuhNTJaklquKSwzz4dJ9Sz94b/JW9LbKejwWMy/77tz/AJITFnaWwz1OC/6iPxcN/kriltNPRYLGcT/vv3P+SsSN0ktQlwmTycmy1PlqSWoS4TBYklqfLUktQlTJb5JKeLUktRhCaLfBJI8U6WpJCTCE3wosFOFqIjCTCckIJSCEmUlGAjQSYSoIIJQGEYQUYOQjBwUSMDKTCEpGCiSgEYQlA9EtpSGpQ5pcJqYr7XDcWet6koGGyAbj3+IWSuFJNb5jFM3B5tcOTh4hbYFNV1DDc6YwzD+F45tPiE4JQcLAudsmi5SK+klt1S+CYYc3cEcnDoQobnFIpwlF6bL0RckE5QhGXIA5RDcp+GLJSgIS4IS48lb0VJuNkzSU+CNlc0sOMbKUBQkqXSQhjeSnNGE1CzACfaPFSKJGB1SkTeSUBuhCPGySlInBMKEk8klKdySU1CSeaLkgichCJBBBKEI2p1jU2BnCfjanJ6ehbyKsIG8lEhburCFuyE0rvudkSNyJQqNBBBBCEEEEEIQQQQRlCCCCCTKEEEEE3KEEEROEiSZsbHPc4NY3dzjyCMoTiCXR0lXcuE0lLPUsdylhic6P3F4GB8Srmk0De6rBlihowPabPMC74cHED8SEalCoshFx74HMrcUnZlCzBq7lLMRuO4jEfwPFxZHuwruk0dZKH2LfHKef9IJl38QHkgH3YTuUpdFy6kjluDi2khkqiDh3cML+H34Bx8VfUOhLxV4M0cVC3r30gc7yIDcg+4kLpQeGtDW7BowAOg8EReU7lTllqDs7oIADWTy1rxza36ph88A8QP8AeWjo6GltrCylp4qdp9ru2AcR8T4nzKcQSISi5FxJOQi4kIS+JDiSC7HVNyVLImlz3hrRzJOAE7CE/wASHEsteu0zTGn2F1wv1BTAc+KdpI+AUbRna1pjtAnqorDc47iaZwbI6IHAyrvoFV2Rn7J3INzg4+Oyt+iVHZmbszyjrg4+K2KCzut9SzaX03WXKngbUywM4hG44BXlXT/02LpPcbkL3SUtLBBkRwwk5cc4xkrZtfDtwvEMk9GwODN9dde4LTt9krbnE+WmbkN31118F7CrbpS25nHUzNib4uKqoteWGV3D+1KZrs44XSgE/DK8H3fUfaJ25XSeelraultpcWxx8bg0Dyx/NZrUXY7rXS0YuRdPMI9zMHEuB8s5Xd0/AtG0iCtr2smP5Rrg9xORquth4TpWkQ1dY1sp/L3HuX0whqI52B7HBzSMgjqE4vCP0dfpJ3OxXmKyX+ofPQyZ4ZJTlzXbYGV7gjuDKiiE0Z42uZxNx122XD3/AIequH6nsJ9QdnDYhchebNUWWfsZtQdiNiub9unbdRdk1idIT3tfKMRRsIyD4kHovHUmte0vtpuMz6a51EdKXbMaeBoHwCj/AEg9S1HaB2uSUrJO9hjk7mFpPs77t+YXrfsp0HS2DTFBTU0QaO6aXHG+SN916YG0nBlpgqDCJKmYZy4Z5Qu8Po/Ctthm7IPqJddegXku5dkPaFp9huMVZU1MjPWMgkceH3Zytf2LfSjvWk7vHaNTyvnpHO4XSze03AxuV7CqNNtdCQWg+8Lxp9Knssi0/cI71Qxd1G9n1jWjAznmpLNxFTcVSG1XiFuX+y4DBB/eyktd8h4hkNuukTcu9lwGCD+9l7KvddT6m0nJJA8SQVMHEC052cP5FfOzRVW/Q/bfRuce7FNcjG4fulxGPxC9NfRN17LqfSlVaamTvJaRjAMnJ4eS4X9JHQ1XpHtGqr1DC4UtTO2ZjgNg7Gf0UnCVOLXc66wVLvbaQPH9gqXhuEW+4VdmnPtjA8f2CvoTZakVFJG7OchMampRV2uqiIyHxuH4Lzb2O/SxsMen4aXUE3odTDkOlefVI6fFW2s/poaOo4HxWt1RcJ8bFsWG/Mrzd3CV6jqzAymcSDvjTzzsuGdw5dWVBhbA4kHfGnx2XlHWFOdNdrdQd2AVAlGOm/8Akvclsc6ps9NI/cTQNeHdCCM5/FeAtc6ydrPVL7uYTCHu2B8Mr3z2G1sWq+yuymU8TmRd0XjmHDwXpH4g0krLdQ1Eww9o5T54/su142pJBQ0k0ow5o5T8P7LxX9IS1G1doc0rRwiZgeD5jmV6csOuoqXsgo70+VrT6E3hcT9oDA/Jck+mHpeW1Xegq3syCSzvByIO65xP2iPf2R0Wn4nnvmTPZI39z7OFrvtp4mslscNeVwDvBuoP0C0XUB4gtFuI15XYPlqD9Ap/ZZaJdfdok9ynYTE2QyO8Q7OytPpK2H0C5W+razha4Oj2+a6d9G7RZtWmm1srPrar1g/HNudkx9Kawd5pRtS1vrQva7PlyKzhfGycYxRxn+Wz+WPhj6qg28CTiqNkZ/ls/lj4Y+qvPoyXcXPs6o4icupnuhx4AHZdjljzGV5l+iDefq7xbS7dr2zNHgDsvUYaHxry/jGk9DvlTGNi7m/5tfuuF4mp/RbxUR9C7Px1+686fSns3pGj4qsNy6mnafgdisj9F67cLq2iJ9l4cB5EfzXbe26yftfQd3gDcv7lzm+RG68v/R9unoGtu54sCeP8iu8sf/qXBdZS7mJ2R5aH9V2No/17happ+sZyPkf1Xs2J2Wqm1C2X9n1Jhe6J5YWkt5OHgRyI96tKX1mD3KPcou9he3xGF4jG4xvDh0K8uaeVwd3LxRpS9DQnazSV8x4I6OuLpA0fZJP8168uP0xtMWiDgpoHVEgGMueAPkuG6r7A5rzqarrnV7YYJ3cXAxmXAqx072BadoKmN9yjqrnD9pok7s+8dD7j819AXi88KXZsFRXyOdI1gBDQfM5Og0Oeq9duly4cuYhqKx7nPa0AhoPnvoN/FM9qf0p712kUUlotFFHBBN6ruBpLiPeVpfowdjNbabiL9dYHRTEYjY7B2PNdc0V2OaNpadlTZ7RSkcjIW8TwfAg7g+S6vZ7Cyia0NY1rRyAGAuUuXFVIyhdbLLB2UbvaJ9o/Mrla/iOmbRut1ph7ON25O5VxbYiyJqmFyRHEI2jdBx3XmC8/TVU3vGFct1H2Q6cvt7FyrrPT1dYBwiWVuSAupSSKJK1pPNSwVE1M4uheWk9xI+imimlgPNE4tPgcfRV9it0VrpIqeCNsMUbQ1rGDAA8ArWV4LcEqK6VsY2KjS1SrFxcclMJJ1Kbq6ZkjiS0JMWIuQwm5avrlQpq3hHPCZlKAp8tQ0jmq+WZgHNQKi4c91XzXAnqmEpwCtZKtrAd1EmuOeqqZKwnqoz6nzTSU8NVnLXk9VFfWE9VXuqfimX1HmmpwCnvqz4ph9V5qC+o80w+o80JcKbJVc91HfUE9VFfMmzISnpVIfMfFNPmTBf5pBehJlLe/mmHuyjc7KbJynJEDukE5KUThILsBCYiPNISidkh3JPQkHkkOTVfXQ0FO+aZ4ZGwZJPRcu1F272yhmfFRNkqHN2J4cDK2rbZq+7vLKKIvxueg8ytWhtdZcnFtLGXY+A966m7mkHmuGxfSBqO9aH0AEJO73HJXQdL9otu1XTkU8ndz4/q3HcLVuPCd3tUfbVMOGd4wQPPGy0K7h25W6PtZ4vV7xrjzwtTNURwsLnuDWjq44VHctaWW2A+kXKnj/vg/kuQ6w0vqC7agqXMqah1M45a0POB5KjrOzKspLfPUyPy9jC7BK6ii4WspZG6suIy/HqtGuvTJP2W9S2C1csbqquGXY0aNdemT+i6fce2rT9HkRSS1LvCNm3zWZre3h0jiKK1k+crv5LnmjbdT3S8Np6j2S3I2XYbfoS3QgEQcXmV0F1tvC/C8wp6iB8r8Z1dp8sBbFzouH+HpRBPC+R+M6nT5YWi05fn3ezsqp2iN59oDouVdomu6i5V77ZbyRGDwEtyCSuhaikbYtOVb4mBjGMOw6DC43oanZX6hMszg7h9Y8XVZ/ClFR4q77JFlkWeRvjv8tFS4cpqXlqbw+PLY/Zb4/vCn27s4qKyMS1Uj2vIzwlV190pWaaLaiGQuY31st+yuyiqoqaMGSVjR5nCy+qdR2aSinp3TxuL2kAA5U9s4t4gq61pdGXxE4LQ3THh5J9v4lvdTVtc5hfGTq0N0wh2c6zdd4DSVL8zxNGHHm5b4HiGV5403cf2dfmSROwwux8Mr0DSS97Gx4Ozhlc/x3ZY7XcBLA3lZKM47j1CyuL7XHb60SQjDJBnHceqU4ZyqXUTi211ODg8BwVeOGxVReoe+opW43IXntM4NnY47Aj6rioHBsrHHoQuJaV+v1FGJBu8n5rsdLTDgGy4vTvNp1M0nbu59/mu30UjZYmuacg8iF63+JUZdV01S32Hs0939iF6Px3GTUwVDfZczT9+RCanpWvbjCgttjI5M8IB8cK5eB1WY1Nq+n068MfC+aR24DTjC8roKGquMwpqNpc89AuApKOorpRBTNLnHoFbiIAe5E+PKYs11/atEyo7vu+LpnopzmqtPDJTSuhlGHNOD5qCWJ8EjopBgjQqDJFlQ54c9FbOjyo00SqlNBVHND5KDNACeSu54eeygzRJieFRVFE14OQFkdT6Qir6eT6sPa4Yc3C30sW/JMOhzkEc0IIXlcQ3Lse1YLxQxPqLdL9XVU7f7WPw/iHMfLqvSujtW0V8tVNW0NS2pt9Q3ijkafZ8QfAjkR0VTqnRsN2ppAIw4OG7SuKU7b52QX2aptsLqu1zP4qq2E4D/ABfGej/Lr8kkjO09ZvtfVa1vrhTfyZdWH5H9F6ihn/Zdf6U3emmwJgOh6P8A5rWQSB7QWnLSMgrj+h+0O0axt/fWqrbNgfW0kvqywnqHN5j8ltLXezQOEeC+mPJnVnu8vJQRShhLXaLpZYO2YHxnPiOoWyMmAmJp8DnhVsmo6XhOHHPgQVClvccx9XJ+CsmRo6rPFO8nUKXOQ8nCgt4Za13DuYG8Dj04nYOPeAAf7wWRvXaZD+0xY7Axt41BIcdxG7MVMORkmePZaPDmdh1WttVD+zKCOAzOqZfamqHDBlkO7nEdMnkOgwOiYCXHPRUq97Youyz6x+QUgtRBmU4G5TjY1Kuc2TTYvgliPyTzWJQZ4BCXKZDEfDgZ6DxU2jt81dJwQRmQjmeTW+89FoKLTENPh9QRUSD7JHqD4dfj+CEhICzlDaai44dG3u4f988bH3Dr+XmtDR2iCgaOBvHJ1kduf8lbOj8k0+PZCjzlRXBNkYUl0WyQY0xKFHIyklqkFiTwITkwWpJYnyxEWIQoxYklqkFqQWp2EJgtSC1PkZSS3KMIUchJIKfc1NkYTUJrhRJzhSHA5QhIIwUSWWoiMpcJySgloIwkyiAwjQRgZRhIiS0QGEaTCEEpEAjRhCMc0pEBhKHNGEIwMJTSiRgIQoF9tDbxRlrcNqWbxu/Q+RXPnhzHOa4Frmkgg8wV1NvNZXWVkx/0jC3bYTNH4O/Q/BGE5pxosmTlEj4UuNmSmqZHFHkqypqfOE1Tw7hWtNDtyUgUZKep4sYVpTx4UaCPkrKGPACkUZTjBslAboyMJTWpcpiAGUpBBIhBA7oIIQkEZSSE47mkOHVJhCRyKSRlLPLKRzCMIRY3wjAQ54KUBulQlMGcKRG3ZNMapUTd0J6fhbyU6EKLC1ToGpiaV6a1Dpkwl1TRtJj5viH2fMeX+vdml1JZy/aXbUh1RSNDJeboxsHe7zTnN6hRNPeseeSLJRvDonFrwWuBwQU3JOyGOSR7gyOMcT3E4DR4lQ5UhCcByjUKjusN0aH28S3SLk6W3QPqmRnlh5iDuH44V3SaS1JXnhbafQXH1hJcKmNsTm+RjMjgfItCNTsmnTdQUWQtRS9mVwkLX1N0pqdrtn08VO6RzfNspc0H4xq1p+zGzRDFTUXC4cO7Hy1Jhcz4wiPPxyl5HJuQufS1EcET5ZHhkTPae44DfeUKSY3BrXUUU1wjPOWihfUMb/EWAhvxXWaHTNktc0c9LaqSKqZ/7SIWmY+ZkxxH4lWpmJJPU8z4p3Z95RnwXKabSGoKwhotvovFuyWqmYIyPE8Bc8e4tVvTdmldIA+puFNTkbOhjidMD5h5LMf4Vve8KIuJRytCNVmabs2tEG1RLV17eYEs3Bg+RjDDjyJKuqLT9qtr2SU1vp4528p+7BlPvefWPxKmb+aJGyMJwyk5PUnJSS8+KRxBDiSp2AErJRJJOUSE5KyERciQSYQjyUSCCVCCJx4Wko0iX2UIXlb6WXbPrHs+u9tpbDXtoqKojdxubGC/jB6H3LzX/tF2mdpRL2V95urXOxmN7g0nwyMBd/8Apu2rvrXQ1nDvDKDn3jCY+h3L+0dK3CgLt4KjjaPJwyfxX0Ra62ns/Ckd0p6ZjpWnBJAzvuTv1C9poKuG2cOsuEEDXSA4JI8d879y4TcewzWlPaqq7XGk7qOGMyP7+XMhA8lvvoZajNr13XUJdhlTCHBvm07/AIL1jq7SLa3TlbAWcXeQubj3gheEuxmuOlO2S3RuJYG1L6VxPhkj9Fat18qOLrLcIKlrQ5rcgNHTBPeeoVigu8/EtqrYqhoDmjIA+Pf3hfRPVtP+09M3CHnxwuH4f5L5o3eyNZ2jTUUwDIjVAkHb1c7/AKr6cQOFTbhndr2b/JfPHtwtf+z3aq9+C0Ok/X/Nc1+GtS5lRU0oOC5uR5hYXAk5bNPTg6ubkeYXtjQWkqW22Cip6SMMgEbS0DqMf5q/uWlY56Z7HsDmuBBBUHscujbxoaz1OQ5zoGg+RGy38rGvj5LyOrMjKqQSH1g45PjleZ1Ae2d4efWBOfPK+bf0iuz/AP2C1tx0bTFSzxiRnDth2d1677Ctdy6q7NoJXScU8MDW7nPJv+S5j9Nq0xx2e213CMl7os+HUJr6HFe+fTtXAd2NJYR4b/yXsl1kN44PgrZtXxHGffj7L1G4SG58MQ1Uur4zjPyXn/WjDaO2irlceFra8TAn7pcCf1X0b0e2Oa10ssYAY+Nr248CM/qvCX0qtGz6f12y4MjIgqoQ7jA2BBwvUH0Zu0ym1lo6jpnTD02khZHIwnflhM4yjdc7JQXODVrW4d4bb+8JnFMZuFqo7hFqGjB8NvuF3J8QLOS4L9KWzQ1XZ7WveAMNLQ49CeS733gLM5Xmf6ZOt6a1aMdZ2yA1VW4eqObcbgrzbhmGWe8UzIRrzD4DdcNYIpJrnA2LfmC459DKrkpta1bBnu5oSx3hkbhetNbaBt+srY6mr6ZszDuMjcFeafoZaWnbV112lYe5fhrMjk4Hn8l7Tp6cPiAI6Lo+O6vHEMktO7DmgDI7wFu8X1A/jb3wOwW4GR3gLx/dvogWt9U6SnqJWNcc93ya33YVpYPoqWW3SCSoPfuHTgz+a9USWuNx9kJItUbR7KxX8YXySPsnVLsLKfxLd3s7M1BwvCP0m9AUumKOilo6dsETHD2WgZzsuw/Qzv3p+hqmiLvWpp8hp8HDKvfpNdnVdrHSxgtdKamrGeFjfHmFl/ordmep+z2audeYIoIKhgDWNk4nAg9QuymudPcOD+xqJh2zHZAJ9Y692+xK6eSvhrOGexnlHatdoCdTr8e9TPpk2D0/QT6prcup3tkz4AHdeMdGWN+odR0VEwHD5BkjkPevpl2iaJptdacqLXVlzYJmlrizngrmvZ99HHTmhbkKuipppKj2TJPIXZ9w6JeHOM6ezWSSjkyZcnlwNNR1PmiycUw2m0yUrsmTJ5cDTUdSrfRdlZbLVTU7GBrY2AYA8lRdtGl5dSaOrqOniM0z4yGtHMldffpIwRd5Rt25mE/+E/p8ugVHV0omy0tIIOCCMEHqD5ry+nrZIKptWz2mnPvzledQVMkE7alvtA59+68p/R57NdT6P1XJW3GkbS0csJY8OeOLPMbL1TB/Vgc1DitLYn5AVnHHwNV++Xee+1ZrKhoDiANNtPMlXrrdJrxUmqnADiANPD4qlvlsZcKSSGRvEx7S1zfEHmFg7L2ZWXT9UJaC1U9M8cnNZv8ANdUkjDhvzUSWkbzWMyomiY6ON5DXbgEgHzHVZjJ5WNLGPIB3AJwfNU0MPdsA8EmaIPbhWMsQaTgKNIzdU8JoKpJ7cHuyWpLaBjeQVs9qYkZ4JqdhJtdZUWWqFTRS91KPaHNrx4OHUf6GF1XS2s6LULRBIBS3ADeBx2f5sPX3cx+K5I/ZNOJBBBLXNIc1zTgtI5EHoUAluyC0O3XoFwLUxI7ZYPSXaT6zKG9SAE4EdcdgfASeB/e5eOOu4nONwpAQVXLSDgqPNLgKDLUYS6qbGVVVFTjO6aSjCemqPNQpqsAc1FnrA0c1V1FeCT6yblOAU+or8A4OyrKivLuRUSWoLuqjPk25ppKlAT8lSSeajPmOeaafKo75UxOTz5t+aZdKmXSpp0iEJ183gmnSptz8povS4QnHSHxTZem3SBoyVDN2pBMIvSYu9PJnGOL5KRrHO9kZTgHO2Cml6TxJAII2QJwhMyjJ8UgyA9VTauvRsliq6xhAdCwuHmvLd17VdTXOpeX3aZsXESGRnhGM7LuuHOEaziRr5IHta1pwSc7+GAutsfDlTfGufE4Na3Qk5+WF68JymppmQML3uDWjcklUmkLx+19O26q4uIyQtJPicbrCduOtJLLaW0VO/E9RzI6DqFh2+zz3C5NtrPaLiD4Y3PuWPRW2WtrhQs9rOD4Y3Q1p26UNknfS0cUlTMNi5uOELFO7fr0H8TaFrYj9p+T/AJKJ2ZaDju8f7SrAXhx9Vvj7102o0XQTU5jdSMc3HUcl6dVS8LcPzegGmM7m6OcT164C7qpm4es0voZpzM5ujnE9euE3oXtiotUyimnHotUeQcdnea6GZQWcWV5R1pp+bRl9ElK5zIyA5jh0K7zoTVQ1Bp+KZzhxxsDXb9cLE4q4fpKaniu1q/wJOn9JWXxDZqaCCO5W7/Bk6dxXO+3HWUz6xtpp3ljW4MhacZ8N0xoTs4hlomVla3vJZNw1zc7LH64nc/XdR3vrNZOACercr0LpuiZHb6cNGW8Ax7l1F/qZeHbBRUdCeTtRzOcNzoD91u3qeSyWakpaM8vaDLiNzoD91k7l2eW6tpXMNMGuxgOA5LlX7CueldTsNKyRzWS5BbyIz1XpuSlaW8lU1FkifNxGJpd4kZXE2bi+stjZIp/5sbwRyuOQuTtfEtVbw+OX+YxwxglRbUHXC3xSyjhe4bhJu1pbLRzMI2c0t+YV3TwiEBoAwkVrA6IjyXEmT+b2jBjXI8FypcOfnaMa5XlywuNp1fEx3qhk5jPuyvSVua19Mx2OYXnXXNN+ydbVZA4R3olHuXfdLVYq7TTvBzloXs/4gtFXTUNyb+dn2B+69R41aKmCjrx+dv6H7qDryn77T9UwDZzCCF52tYqxWiKkeY5n+rscL1Bd6YVVLJG7cOGF5wulJNpnUznOaQI5i5p8RlXPw5rA6mq6FuC8jmaDsTj9cK1wPVAwVNGMF5HMAdicf+FbQ6Hu1f61RUvIPQklWVN2XsGO9kc74rcaWu1JfaCORjwZC31m53CvJG01OwufIxoHUlczcOMeII5XUp/lkHGGtwufrOKL22R1OT2ZGmAMLDW3QFHSytd3eSOuFuqSHuo2t6NAAXO9T9ohprpFT2vhn4Th2DsV0G0VL6qihllbwvc0EgdFz98pbu2CGsujye0zgE6j3dFjXamubYoqq4OJ59gTqPd0Ut6h1UeWkeKmu5JmUZBXGYXMrjHaBp59NXPrYWEhzt8dFO0hr6Kmpm09c7hI5PXQLpbWVUbmvaHNPQrn1z7PIpZXOhcYs/JevW7iC13W2stV+yOT2XjcL0qhvdvuFC23XnI5PZcOi0Vfry3U9OXNkD3Y2GVzitqqnV15D+E8JOB1ACu6fs8YH/WSPePktRZ9OQW0BkMfCepKmhu3D/DLHyWgulncMBxGAP35KWO52Wwsc+2ZkmIwHEYA/fkp9kpRRUUULfZYMK0AwAkwwBuAnXDdePyyOmkdI85JOT715q97pHF7zkk5KbITL25UgjCbeMqJNCgzRKBNFureRqhzR+SjITwVUyQ+SZdBk8lYvj3SO79yanZVa6nyCqi7aZpbtEY54g7PXG4WoMSQ6EFCFw2/9g1NU1oraCpntle32KyjeY5B7yOfxSILB2o2IBlJfLdeoRsP2lE5j/m0ZPvJXczAD02STSMPNqUgO9oZU8NTLB/huIXG2S9rEwDSNM0zfvnv3OHw5JxnZ1qbUZDdSatqp6c+1R2yMUzCPuucN3D3hdfFGwn2Qn46Ro5DCQMaNgpn3CofoXFZ7R+j7bpCgFJa6KKjiJy7gGXPPi5x3cfMlaeKMnCcihAGwUlkYA8U9ZznFxyU2yJOCMBOBuVJt9uqbrUmno4u9kHtOOzI/Nx6e7mfBCZlROHGPEnAA5k+AWjtOj5Zw2WtzDHzEI9s+89Pz9y0dl0rTWcCRx9Jq8bzOGOHyaPsj8fElW3d7J2Ewu7lWRUUdNE2OGNscY5NaMBE6BWRiykOhCMJFWOg3TboFZuhCQ6BJhPVU6BNOgVq6AHomnQeSMIyqt0PkkOjwrF8PkmXQowhQCxILFNdFjomzGjCFELEgs8QpZjKQY0iFELEgsUp0aSY0J6iFmEhzMKWWeSQ6PyQhRC0pBbjmpZjTbo0xCjFqTw9FIMaIx+WU9CYx5IY8k6WYRcOUITY9yPGUvhRhoQhJAwjAylYwj4UJMogEfClAeCPhQjKSGowMpSMDKTCMokoNRoAZRhGUYGUbmMmjdHI0PY4FrmnkQUByRjmlTVze82l1ouD4Dkxn1o3Hq3p/JR4o1v9Q2gXegwwZqIvWjPj4j4/yWHiZv8AnlNwp2uyFKpo1bU8ewUGlbuFb00WcJQkKkU8WSpzW4CKCLganVIoik4ylIw1KQkScFDhSkEISEEojKShCJyS72SlO5Jt+zUISCcBENgiJRgboQjA2TjW8kTQnGtQhLjapUbUzG1SomoQpELc4VhTR5UanjyQrajhyeSaEpXqOtvlHb53QSzOkqWgOdTU0T552tPJ5jjDn8P72MeahuqNS3IBtBZ4LZGdnT3epBe395kUPGJG46OkiK01NTwUUIipoI6aIEuEcLA1oJ57BO8afhRrFt7MH3Kb0i+36prZHf1tNboW0dM8eXtztPumVzb9AaZtj4pYrPTz1MTuKOrrc1VQzwxNKXPx/eV3x+ZRJMAI1O5T5nJJPU8ykmQpviRZKMpMBLyUOI+KQghKlIJKCEJeShkpCPiTcIRoZCInKJInpWQi4kSCEI+JFkoIwEIRAZR8KNAkJ2EIYCCLiKLJSoSkTxlpQ4kHH1TuhC84fTAtzZ9CPkI33A8jzC5j9CmqdHcrhHnLZG8JHmDldM+mZdYqTs9NI53DLPKHRnrlu5C5x9Cm2vY+5VThmJ7hwHwcNiPkvaqHLeBpzJsXafEfv3L1Ok9XhGbn2LtPiP37l7AuEIloHjHNq+bXadRu0d21XBzfq2xVzZ2nl6pIP819LXhrqXfbZeAPpfWqKj7SYquJzXCppxxcBBwWnG6p/hrPy3OWmdtIwj4a/TKrcCTYuElO7Z7SPhr9Mr2/o2vFz07RTg5EkQd8xn9V48+mPYzRangrWtxxkEu94/muxdhnbRYWaHs1JW12K8wtYYwMkEbYWf8ApjWdlw0vTXCMcTQ3iDh16qDhyKay8TMjmaWhznN1G/kobFHLar81krSASW69Vrfom6miuugI6bvQ6WmkLSAdwCMhegC8d2vmD2V3nV9iqJavS73ukZl7omjiB6ZIXR7n9JTtFroHW8W+YzY4XPDXc/gMLYvnA1RVXOWSklZyuOSCcFue8LSu3CM09fI+mkbyk5IJwRnvC1P019ZU9TLSWOGQSOY7jlb9xwO34LQ/Q407Jb9LVFW5rmsq5M4PQjZcN0l2Par7SNQNrbzT1EMD38T5ZjkkZ6ZJXuXs80nBpm0U1DTsAjiaG5xjPmVFxJVUdnscVgpZBI/OXkbd/wBfoo79U0tstMdlp5A92cuI27/qqDtg7L6TtA09PSzNAmLMRyY9krxhLp7W3YfqV1RbmTNDX8TXsBcxwB24hy+C+kc1I2aPBCy160hT3BjmTQMlYebXjIXIWDiuezRupZGCWF27T9lzVn4imtTHU72CSJ27T9l43H0uNcVlD6NHRvqKgjhL2NIAPkAs3ZuznWXbBqMV16hq4aZzgXSygloHgASvZzOzS2xyBzLfBGR9yMN/JaG16Xjpg1rYwwDoAt93G1LRMd/CKJsT3fm3I8lsO4rgpWu/hlI2Nx6748lR9mGhabR9mpqGlYGsjaAXcOC4+JXS4WcDAo9HRNgaMBTF5RNM+okdLIcuJySvPHyPleZJDlx1JQQO6CChTVArKETjBCYpLU2F+QFbIYwhCZfAHNwUTKNgdnCfQQhKYAzkoN0ssFzBcfqajGBK0Z/xDqPx8CMqaDhKBwcIzhIQsJW0M9ulEdQzgLvZcDlr/cfnscHblhMY8F0CeCOpgfFKxssT+bXDIKzF00zNSky0fFUQdYicyMHkftDy9rb7RKlDwd0zCpCNkhzNk4x4eMjxIPiCNiD4EHogWp+EigTxeChSx/NXD2c1DmhxnAUZCcCqp7Ey+NTpI8Jh7EwhSAqBJFndRJGEK0fHlR5IVGnhVcgzsRkLSaV1xNZmsoqwunoOTDzdD5Dxb5dOngqOaDwUORhaUJSM7rZdpPaTRaH0zLepMVEDccPC/ZxPJcx7M/pD0/aPWzUzqT0OYOHA0EuBHmUxq21t1DYKq1VPE+kn9pnFjB8R4FUHZv2Z23RVVLW08rZHu2y4bsGeq7GiNk/hEwqQfSs+rjOMae7vyugpf4ULbKJwfSM+r3K+7e9W3azaXkfanSNlduXxZyAFgfo9ay1Bd6qugujpZKdrQ5ksnMnO4yurXart1wgMM88T2u2IcdkzYbTQ0OfQWQtZ4xYIT4btBT2WS2yUoL3HPORqFJFcYobW+hdT+s455lqhLlqYklwkmThYo0ki4lcylvl3UeWobGMucABzJKS+UgFcf+kE6p/2Y72nnliMbw4924t268lr2igF0roqMv5Oc4zjOMrRt1IK+rjpS7l5jjO66Lc9a2a1NJqrlTQgeMgJ/BZC49vWlKMlrK11S7p3LCQfivOmjNJSazqp2mY8cYBcXO3IK6LQ9iVK1o76TPuGSvUavhnhmxymC5VT3SDGQ0Ab6+P1XeVVksNokMNfUOc8bgDH6re0Xb1p6rlDZJTADsOLcrd228Ut2p2zU0rZWHq05XnDWPZJBabe+qopH8TAS4P67KR2BaoqIL2+1veTTvjc5oJ2B5qvX8MWittUt1scriI/aa7uUNXY7bV26S42mQkM3BXTO2ySpGkKp1NNJC9g48xuIJx7l5ntmoK213KKujnkfOzk57iSvVuu6QXLTtVGRnMZH4LynZbYK+9R0MhwXuLBnxXY/hzU05s9THO0EMJJ0/KRr9F0vBFRCbZUMmAIYcnyI1+i9X6D1jBquzxTxuBkYGtkGeuFqePIyvKXZ/qep0JqVtLUEsppJMSA+HLK9O0FyjuFHFPE4OZI0OBC8p4ssH8FrOaHWGTVh8O5eecRWf8AhVTzRaxP1afsufdul49C0u+JruGWQ7eY6hea3UkjKVlQR9W5xaD5hdf+kHdDPX0dCDxAeuPI8is1frD6NoWllDOF+z3DHI9V7JwdMyy2ija8a1Dz8P2F6bwzM21W2ma7ed/yXVexO6+l6MgjJ9aFzo8eAHJc37eKiSTVEbcnujGCB4HkVddgFyIiuNGXci2QA/JQ+3i3ObV09Xj1SS3PvWDa4WW7jqaJ35uYj/iHMse3xsouLpY3fmzj/iGU7pjtQtOnrJTwuDnShuSxrc4KO4dvMs4LKKgc49C4/wAlSdnGkrbqGiMk7Q6djyCDvsunUGgrfTgcFM35Ktd5uF7VXzMnpnyyhxzk4GfDwVS5y8PW2slZLA6SQE5ycDP6LjF/vN71k9ploiGjkA39SuidkFDX2ynqIaqMsjc31RlbmHTlPCMiFjQPJSbXNRVHE2mmjeWkghpXP3Xiz+IW51upKURwjG2ThYdx4l9OoXUNNTBkXhnRef8AtRonUGqnSkYEgyPgu7dnt1ZddN0MwcC4xNBHh0WO7XtIOutG2rhZmaBpO3ULF9mvaEdKVDqSuBFP7IztwnK6epgdxZwxA6k9aan0LeuNvpgro54jxHYITT6yw6EdcbfoV6QzsqDVWqKTSlvNXUtc9u+Gt5kqsPafZPRe9bVBwxnnhcg7Rteya0qmUVEx3o7XbcO+T4rhuH+FKy41rWVURbEPaJ00XJ2bh2prqtraiMtjHtE6aLrmi+0CHWXevgpX08bDjLyCSVp6g8TSsB2XWB1gtDQ8fWy4c9b47xrBvjKOK4Sx28fygcDXO3iVi3ZtKytkZRD+WDgdV5/7aqDuL/T1AG0seCfMLfdldf6Xp2nBOXNbg/BM9qOjqjU8VMKUtbJE8kl56J7s70xUaZoXQTztmJJPqDAGV3VwutFW8J01K6QdvGfZ64yfthdbW3GkquG4KZ0g7Zh2641+2FtZm8TFgtcaKhvsbnY4JhnhcF0EDLRlRqinDwdl5tRVs9vnbUUzuVzdiuFpaqaimbPA7lcOq86y6ZvlgnPo/ec9u7PP3p90GqLm0RyPfG3wccLt89sDjnCji1NHQD4L0o/iDVSAOlpo3SD8xGq7s8a1LwDJAxzx+Yhc60poE0U7amsLZZc5AGdl0umjLWgJcVC2PonwzhC4C63ervM/pFW7J6dwHcAuNuFyqbpN29U7J+Q8gkuHNNuCdPNNkc1irMTEsfECoc1I12+FPdzTbglQq00bWu5JxsAac4wpTgkEbpiEzw42CS4J0hIIQhNOGAm3J5w2TZGyEoTDxlRpmeqVMc3ZMvZnI8UxPBVc8JIanXjB80gBCkSeFEWeITqPh2SYTExwFFwJ8tRcKVCbbGnmRpUcafa3CE1JazZOBqPZo3yckAADJJPIAdSfBbDTuhzLwVN2YOHmyiO498nj/Dy8c8gAZTCcalU+n9L1N/LZSXUtvP8Ab49eUfuA9P3jt4A8x0Ght1Na6VlPSxNhhbyaOp6knmT5ndSyANhsiUgGFETlN8KPgSwEYalQE0WZSSzyT3DhBGE5RzH5JBiUohJICXCFDdF5Jp8Hkp5b5JBjyjCdlVzoEy+BWjogmnRJMIyqp8BTLoDlWzoU0+DyTcJVUuhTZhVo6HyTTofJCFWmJNujVi6EJp0BTcIUExFNmPCnOhTZiRhLlQyxIMamOjSHRpMJcqGYkkxqXwJBjQjKi93hJ7vmpXAklqEmVGMYQ4FILUktQjKZ4EfCnC1DhQkTfCj4Uvh96Pg8kISEeCl8KPAS4QkBqPh9yUglwkyiDUYCMDKPhRhKg1ZTU1p9GqvS4m/VSn1wPsu/zWr5JFRAyqgfFIMseMFBGUoODlYyibxELQ0dPwtBIUW3WZ9NO8S7tadj4hW/DwjACQBOJRYwEfCjDSQj4SnJiJBHwok3KEEEEEZQgknmlJLuachJdzTMp6J1xTDjk5QhEnGt2SWNynmtQhBoTrQkhvknWtQhORjdS4W7hR4wp1PHkhMQptLFnCu6KHlsoFFDyV5SxYCUJCvUedkAUknZDJUial8RQ4kjJRhyEI0YOESCalwloJPEUOJCclIJPEhxIwhKQSeJHkIwhHnCGQeiIHKNCEEEEEmEIIycokEqEOaCCCEIIIIJwQgoF7usVnt09XKCY4mF7gPADKnqg1dAKuzVcLhlr4yCPgpYg0vaH7ZT4+UvAdsvAn0ku2SPtOvsUVEHst9P9h5By4ddlWdn3bvcuz2yfs+1wta954nOawZz5FZgWmmt/agbfcIhJStuBjkjdsC0u2H4he3NKdkmnrbDG+jstHFtse6DvzX0tfbhaOHbfTW+SmMsbhzNGRj3nv17l7xea62WOigon05kYRkDIx7z3+5eYqrtd7T9auMdLBcJmu5cLXY/RV8vYp2jazmZPcqTuT96rkDSPzXumj0s2FoYyNsbejWNwFMdppvBkhee/wCnz6bS20ccXjgk/ZcSeM5INKClZH8z9l82qyx1/Z9q+lpKyXMkMoBDCeHnj9V7A7Q2jV/YjTz+25sAz1xtj9AuN/Sh0JXM1qyehpXy8ZD8tHUrtHZ1Q1Vf2OzUNZC5srYnYDvDGf0XScQ3FtbQ227Fw7QOGceO+i3r3XCro6C5Fw5wRnHz0Xnj6MNb6Lr1tDIQRMXRFp5Ele0o9GUkwB9FiHuYAvCegm1Wne11hhglcI6sHLGEj2v8yvo9aHNmp2OA2cARlc/+IjeS4xVUZ0kYNvD/AMrE43Zy18dQw6PaP381S23S8VNgMja0DoAtNSUjYWgAYUhjAOiUvJCSdSvN0EC0O5hBBNQk+jsPRKbE1vJBHxJpCEpBFxBDiCEIcKIjCPiCBcMIQhxIcSSgm4Ql5ygkIw5IhKR8STxI0ISwcJSbBwjyExCrbtYKa6Eyg+j1eMCdg9rHIPH2hy88ZAIyVla6jqbVKI6uMMDjwsmacxvPQA9D5HfY4yBlb7iSJWxTRPjma2WJ4LXMeOJrh1BB5hStcQmELnzsFMvZkeS0Fz0pJCHS2smZnWkkfuP4Hk/g4439oAYVAJA8vbgtex3C5jgWuafAg7g4IO/iFMCHbJuyhzRKJJHjzVpI3Kg1r208bnuOGtGSU3GdAngqDLiNpLjgBUtZqq1UsnBLWRMdyPE4D81587Y+3OvuV1lsunZZI2tdwOmp3ZLj4LH0PZDqXUMHpNZXzEvGeF5cT+K9LpOC446ZlVeKkQB+wxkr0Km4Yjip21F0nEIdsNyvWlJebfdc+i1UVRjn3bs4Rz04O4+a8Y19JqjsquEMonkjYw8TeF2WHwyvTPZP2kRa+sZkc5raqHhZI3qThZt+4Sda6Ztwo5RNAfzDp5qtd+HjQQNrKaQSwnqOnmrm7yw0NNJPM5rI2DiJccALzbrbtcul6ur6Gwyy00fFwcTMZcuo/SJ1A+z6YNPC4skqDjnzb1C5h2H6djqTNXytD3cmE9PFb/DVBR2y0y8QV0YkIOGNO2e9alkpKagt0l6q2c5Bw0HbKp26D1Zd4++lrZnyEZDOM5KKwa91J2dXttPWSyOha4NdFJu0DO+F6GZSwxMy6VgPhlcp7arfba+3Rzxyxiqicc4IyRha9m4rde6oW+50zTDJpo32e5aVr4ifdagUVfA0xv00Gy7jpfVdNqqzw11M7LJByznBVq9+V5z+jxqd8U77W954DxFoPzXoWN/E1eW8SWf+CXOWkHsjVvkdlwd8t38Krn0w2Go8jsjkdsufdq9v/aOlq2PGSYz/ADW/PJZ7U1MKu2zxkZBaVk2+c0tXFON2uB+BWZRzGnqI5R+Ug/NeaOxq5R2/VndzvbFFNEQXPOBkcl3as17pi0Rn0i6U4cPsNdxH8F5erKB0WoJqPPAe/LAfedl0W29i8kwa6omA+P8AJfQ3F9oslTWR3G5VJj52jDWgZOOudehHRey8TW20zVTK6vnLOdowAN8dc+8dFL7Re12gu9FJR2nicHbF72YR9itjgp6k10szRM72WEjIU09i1AIsOe8nH2Rhc9v9srdAX5pgqHtDSC0g9OeFWoP4NdLfJYrFMY3O1JcNXY6Z0+ir0f8ACrjRvtFolLHO1PMPa8Mr1HcIu+t0jcZ9UryhcWGya4kwOHuqoH4E/wCa9J6L1CdR6ejqJPbPquXAe12hNFq6SQDhErQ4e8LC/DwOprnVWqfdzSCPEf2ysrgsOgr6i3zfmaQfMf2ytX2maO9Ot7brSsPGxgJDeo5qf2NdoB7o2itk4XRNDYi4+fJbHSTo77pGhkeA8SQgEH5fouM9oOmKjSN79MpeKOKR5e1zfsp1llivVNLwvcTh7CezcehB2+vuRaZI7pBJw/XHD2k8hPQjohr2r/2i7QTG1x4DIGe49V0vV1j7zRr4eEZbFjb3f5LlnZ3TyX3WLKib6z1uKTPn1XoG7UQqLNMwjOWJeLqn+FVluoYz/gBpPnp+iTiaf+HVVFRsP+CAffp+i4V2L1/oerhC48LZoy0+8cl17tB0uNTWN8IH1gIc0+5cM01HUWnXcDo4pHCKpweFpIwT/mvT8cYmhwR0UPH0jqK9U9zpXYcWgjzB/QhQ8ZyOpLrBX05wS0EeY/theXLHeq7Qd7PFG4Na48UbtuIcl2W19sVjqaUOkcYngetx7DKmao0HQ3zJnhHF95uxWIf2L0vel3fyY+4BgKWqvPDXEjWz3RropgMEt1z+/FOqLtYL61s1xa6OUDUt6p7WnbMyrpX0dpaHuk9XvBnPwTnZBp+shqJLlWOeDINmPzvnqrCy9ltst8rXupxM8ci/JwugW23tpWNDWhrRyAWHc77bKSgdbLJGQ1/tPdufJZdfeaCno3W+0RkNd7TnblP1lKKiAtcM5GN1zHVPZXSXOd88Q7mUknbkT5rrYj9VMTUrZOYXDW66Vlql7ajkLD4fdcjRV9Vb5O1pXlp8FwaPsceHgSVTnjwaMBa3TXZzQWeRsrI3PmH2nOyuiGgYDyTkdM1g5LcruLbxcYjDPOeU7gaZ88LVrOI7rXRmKaY8p3A0z8FGoqXuWgBTSOiAaGBEeS49c2o00Al5hMx0wZyCmO5JDk3KEjGE27qnHc0g80ZQmXNGeSbdGN08eSQ4IyhMkYSCE6Qm3BLlCacMhNnmnnBNuCTKE04c025OuCbcOaRCacE24J1yQRuhCackOCcIykHkhCQ4JtwTp5JB5IQmnDATbm4TxGUhwTE9V1Szhk8imcOU6rjywHwUFCcEsDKMN2QZySgEIKTwoBqXwpQGUJqDRhP08ElTMyGGN000hwyNg3cf9dTsOqdtdrqLvVtpqWPjkO5J2DR4k9AunWHTdNYISGfW1LhiSdw3PkPAeSUDKa48qgaa0fFZ+GqquGe4Y2I3ZDno3zxsXc+fIHC0DuaUgpMYUGp3TfCjS0RGUJUlBHwo+FCEnGURalkZSU4ISCMIiE4kJUZSUkjCWQiQlymyMpHCPcnSMJJGUJcposBPmkOZ5J8tSSMpuEoKiOj8k2+NTXMTTowkS5UJ8fkmnRDopro026NCMqC6JNui8lOdGm3MSYSqA6Lyym3ReSnujTTo0mEKC5ibcxTXRplzMBJhCilqSWp9zU3wpUJotSS3KdI3REIQmuFDhTiIjKEJHCi4UojCCExIQS0EIScFGBhGglwhBBBBInZQRAYQJwiJylKMojukEbpaBGUiVJQQIwghJlBERlGgm5RlJIwiSiMpKClQSXHdKSDucpyEh2yax5J1w4kkDdCEqNqdDUTG8k4AEIQAwnGhEAltHJCE9E3dWdHHnCgQNyQrmiiyQmIVpRRclc08eyhUUWwVvDHsnphXotAFJG/NEOSchLQSUEJ6WDhKTfEjQhLQSeJHxJqEaCTxIE5S4QlIJCPJSoSkYOEjiRh2UISuJKSEE1CVgI0kH4ocSEJSCLiHihxIQjQSeJETlKEJar7rB31NI3GctIU1NzM42pw0QvBXad2HaguPanXVttpnGKSVk7XNaT63+gvZ2iaOSGy0cdQ0tmbE0Pz44GVYVFobJJxcKsaKnELQAF1F24gqbxTwU84GIhgEb7Aa/Bb9yvVRc4YYZgMRjA7+g+yktiaOiEkYLSl5CGQuWWAsxd9M0twnEstPHK8ci9oKVDYmRwGIMDWEY4QMBaMsaj4B4J3aOIAzslJJ3K51D2b2uluJqY6OMSk5LuELc2+DuI2tAwAMKV3Dc5wlgAJ8k8kuC9xPmnvkfJq85RoZKCCiUaGSj4kSCEI+II8jxSMhDIRhCWgkotvJJhCWhkJvvG5xkZR8Q8UiEvIQyE2+RrGlxOAN1x/Xn0ptE6BudRbqypqJ6+E4dDBCXYPvWhRW+ruMnZUcRe7uAyrtLRVNc/s6aMvPcBldkyEMryHfPp5QOc5lk01NO4cnVMmAfg3dY2u+mVrypPefs6GipyfZjiyfmd12kHAN9mGXxhn+Zwz8BldVFwdd5BlzA3zcPpqvd2UC7hGV460D9NmomusFFf6AQwvcGCZpJdknmc8l6xtN9pr/AGmCupJGy087ONj2nIIXNXiwXCxuDa1mAdjuD71h3OzVlpcG1TMA7HcFYbXv0j9E9nNe+hu1xf6axocYIIi92DyXQrFe6e/2ukuFK7jp6mJssZPPBGV4K+mZZvRNd0la1uGzRFjj5g7fgvTf0X9TG/dkNhc53E+njNO4+JaV0l34epaOw0l1piSZDh2SMbHbTvBW5c7LT01np7jASS84dnbY7ad4XYbjWst9LNPIcMjYXuPkNyvnb21fSE1XfdX3Gltt+q6a0xSFkccEmGuHivW30l9fDRvZ1Wujk4KqoaY4vfjqvnjPZKyezy3p7SYTNwOd5ldn+HFnp3MfcaxoIJDWcwB164z16LqeB7bCWvraloIJ5W5HXwyvpB9HLWEmq+yqwVU8rpqoQCOV73ZJcDvuuiXWx0l6aHygxVLW8LKiLZ7R4eBG52ORvnngrzB9B/UHpWiq22l+TR1RIBPRwyvVcTwWheWcS0goLxUwAYAeceR1HyK86vtN6Jc6iEDQOOPI6j6rA3S3VVleG1bAYnODWVUY+reTsAfuEnGx8QAXHOOY9tuo36d0NcJ2OLHPb3bXjm0nkvR0rWSxOjka2SN4LXMeMhwIwQR4Lzf9KnRvB2f1zre4mnI4jTSHPARuCx2c4/dPjsQAGmKxNZNc6dkvsl7c/FVrQxklwgZJsXDPxXl3sIsjL9quWuqsPEZLjno475XqWKnpIY8yTMZgcsrxNoy9Xy2VcsNjJ7+YbgDJwFtG6Y7QNTf9ar52Md04yPyXt/FnDguVxNRVVjIowAACdceS9c4ksQrq8z1NU2NgAAB3x5LrXbBLYLlpuqgkqoDMMFmXDIIXHOw/UjtP6xbA2T+jzSBpwdjvhXVH9Hu5Vjg+urJHu5kn/NbfSfYHRWiuhqnEvkjIOSSVmRV1gstpntnpRmD89NAfBUI62zWq3TW8VBl5/DQFQvpQQuqLPRSgbRSZyPPZcZ0pqq/WyidR2mPjHESSG5IyvS/bVpeS86Jq+BvFLDEXNHjhee+yK9U9l1BLT1waGThrBx9DlaHC1XHNwrIwQiZ0LieQ9ev3KvcPVLJeHXtEQkdEc8p+P3KkOptc344lqpo2H7PFj8Anafsgu1eQ6rqnvz1JJ/Nei4LJE6MPjDeEjOWo5qCGkidJIQ1jRkkrh5OPq9v8uihZF/laMrlH8Y1o9SlibH5NXM+z/stbpq5RVjZHOe075K7HActHuXK7d2uUE2rf2RDC6VjnhjJGjG/muqU7w5gOMZHJcjxD/FXzsnuwPO9oIz3LAvH8RdM2W5Z5nDIz3JwlV9xZxwvBHMKc4qNVNyPguWBwcrnsLyJ2kUhtWt6pwGMvbKP9fBehNPXOhks1JUTVMTA+NrjxOHguU9tOl62s1BBNR0sk/E0tPA3PXZZ+g0Nq2thji4XU0TRgCV+MBfRVwprfxHZaCSqq2xOY3XJGeg2z4L2itgob3aqN9RUtjLBrkjPdt7l3O76+09bIXl9UJC0coxlcA11qQa1vzTSRu7v2WgjBK01H2K1tQQ6uuQ35tYCT+K3Wmezehsj2ujaZXj7b2hYdDW8NcKONTRymonwQNCAPksikrLDw64z0shmlxgdAPkrXs3tMln07TwyjEpaC4eawHbjp+pq66kmpqeSZ5JaeBpOAd12uipBEwDHJJq6ITHJC8/t3EM9vuxu3KHOJJI2Gq42hvU1FcTcuXmcSTjYarDdj1PW0mlYqeup3wSRucGtePs9Fdaw0rDqK3yU8jQOIEB2OS0FLSiHkpL4eIbjKy6q5yz3B9xj9R7nc2nQ5zos+orpZqx1cz1HF3Np0K5hojs2g0rVumZM+aRwwS4ABdFMAfDwkbYTzKcNOcYT3CMKGvuFTcpzU1b+Z56qvV1lRXzGepfzOPVUDbJDFOXshYxxOSWtAVtBHwNAT5Y0dENgqTnOdq45VQkk5JTUsIfzGVGdRNcfZUwnKInCQJyitpWsx6qdbGGpaSTlKhAnKSThAnCShCCSTlAnKInCEIicpLkZOEglNQicUhyUSkE9UJMpLuaQeaUkpMoykHqkEJaSeaVGU24bJDh1TibPJCMptwTbk65NuHNCMppw5pp3NPOTbghJlMkbJDgnSEgjCE5NOCQRgp0jCQWoQmiMJBGE6QkkYQhNEYSSMp0tSS3dCemHsDgQeR2VY5mCQeYVu4KFVRYkz4piUKOwJwDKDG8k5woSpAGFNtNpqL1WspqZmXHdzjyYOpKK3W2e61kdLTM4pH+PJo6k+S6tZLLT2CiEEA4nneSUjd5/l4BOAyo3O5UVlstNYKMQQDied5JSPWefH3eA6fNTcZSiMowMKXZQeKQgRlGRhEmpUkjCCUkkYKEIIIIITEElyUiPJKE9JREZRoJcoSERGUot8EXJKhJREZS0WAhCQWpJaU7wouH3IQmi1ILU+W58kksQlyozmJtzPJSS3ZNuaUmEuVGcxNuYpLmJDmpqFFcxNvYpbmJpzEIURzEzI1THMTL2IT1Be3Cac1SpGphwQhMkJCdIykkZSYTE2RlFgpZaiRhCSiwEvGURalQk8KItSkEISEEojKShCCCCCEJJ2KJG7miQUIIIIE4TU4FBJQzlBCaggggkwhBIRk5RJU9BIRk5RISZSSOaDWpSUxqEqWBhKARNCWOaEIwMJxgSQMp2NuSmIUulZkhX1BD5KqooskLR0EOMJwQVZUkWys42YCj00eAFOY3ZKoyu8ByVkKO2X5JwPBTylynAd0Oqb48o+JIjKWThDISOLxR5BCEuUtHxJGdkM7JqMpYcjSM5CGeSclyloJPFhDJQlSkElAHzQhLyUOJJ4kOJNQl8QRpGcoIQloJOShkoQlIJOShkpyEpBJyUSEJWB4I0hHkoS4SkEniR8SMowjQRcSBc0JMpErJQyU2J43HAe0nwBSgQU5CPJQQWZ1zr+1aBs0twuVRHExg9VrnYLz4BSQxSTyCKJuXHQAKSON8zxHGMk7BaYuIRB4JxkLxJrD6YmodQV8lNpy08MIJDXhznk/LZZV/0h+1OzTNqKzvI4Bv3Ii4Q4efNekw/h9dZGAyOYxx2aXDPyyu6i4LuL2gyOaxx6E6r6DJqqqo6OnkmldwRxtLnO8AvN/Yt9LGl1lUxWy+MbRVzzwscD6p2/Fd/uL211tlDSHMljIB8QQuLuVoq7PUej1rOU/IjwK5auttTbJ+xq24P1HgVzlv0ntFT6lfY4KqaSsZnjcYi1jcc91zPte+ly60XCW06Xo47nK08Lp2PcQD8AvMfatSVFi7RbiKdzoZHuOC3YnOxXozsL7F7dBY6e610XpddUgScbnEjB5bL1ursNg4epobnOHSBwGGE7u3JOMaBekVNos1kgiuEwMgcBhpO53ydtFyev+kf2mUswqHPdQxOOcNiwT8Sux9iH0tjqG5U9n1G1sM8jmxxzg8z4uXT7l2b22uoZIJaCExvbwn1ATj3rxn23dnEvZlqiKqouKOmmkc+Ij7JHRTW2psHFodbnUohlIPKR+/qpLfUWbiXmoXU4ikI9Uj9/VfR30uKrpBJG4PY5uQR1C+en0r7R+z+059QG8IqYQfi04P5r1B9GrtEfrHs/oIqmTvKumj7uRxO5IK459NOycNRbLi0Zw8scfAEZ/NYPBjJLLxM6hl39Zvn3fRZPCzX2u/mkk39Zv6fRabsa7LdO3/Rlpuho++lnhDn55A9V1aHsztFPFwstdMBjG8Yd+a81div0lLT2aaFitdfQ1FdVwyPLGxEAcJO25VtqH6Z98usToLLpyKBjthLKXOcPlsprnwzxJW3GYM5uz5jgudgYzp17vBOr+H77V10obnk5jgl2BjOnVYz6Tej7dpbUMEtAxsE0riZGN2xtkFem/or19XJ2VW+CtLu8ic5rS482Z2XiW5amrNT6qjuWpuNzA7ikDWEgDPLC9tdgvaNpvUtniobQ9sTqdg+pcOFwGcclr8Y0tXS8PU1FKDKWEFz9wN9M+9a3E1PU01lgpJAZC05L9wPDPvXOPpr2LvrNR3EM/qZhkjz2Uv6EWohJpK7W17sGlqeNo8nDJPzW4+lBY/2z2c3HhHE9kZe33jdeYvoy66bo28X4SSBrZaIyMa47FzN1Tt0brxwTNTMGXROBHxB+hKq0LHXLhSWnbq6N2R8QfuVq/pd63fqnWlLp+lkc6KAgPjbvxEnY/JWGsuzcWjsLELYwZo4RMSObiNxnz3XP+yq2S9pva2+4zB74WymbjdvjfIb+K9e6609HW6KrqYMGDC5objyKlvNa3h99ttMJ/wAIte/zJ6/NOu1WLM+htsR/wyHO8/3lecPoTX70PWN1tr3erUQNkaM9Wnf8F7uppeKML5pfR8up0v20WuNzuEPlfSOJ89t/kvo9bqgSQtPiFz34k0whvInbtIwH4afZY/HVOI7r2w2e0H4afZWpdkHqsR2m2Aak01WURAc6RjgM+OCtgJAOqiV8YmjIIXl0MroZGyM3ByvPo3uieHs3Gq+XunJHaC7QGitaYWwSvjcXN5DJGcHmNv8Ay5r2Hp+KGut9LUNMboZ2gxzRbsfkdD0P7p32OMgZWX7f/o9jVUzrnaQIa1o3ZjZ++c+9cFtN57Qey9stCyKqFHIcPpns42yDkNt9l77cIKPjumjq6WZrKlowWuOM/vvXsFdBS8YwR1MEoZO0YLSd169fQQU0ZfK5rGjclxwFyDVnbvS6f1fDa6GD06HPBIWEe1nmD4LltXqXtI1hEYILfVNgI9kMJdjwydz+JWr7IexyWirY7tdgHz54mMDg4Z81zzOHLbYIZKm8zNkdghsbTqSsZljoLNG+e6Ste7GjGnUlegXxNvNoBfHwiaPdh8CF5g7V+xist1yludojL4i7jMbebceC9YUEPDC1uNsYAUW42hk+fVXDWS/1VhqjPS7Hdp2I/fVcnarxUWeoM1NsdwdiF43svatqvSsTaOZsj2NHqse08R+KK7611drYGCOklZG/YhgI/E4XqKr0TRTOLn0kReTu4sBPzUQaNhpiTHC1vuC7d3GlsD/SYrcwTd/TPfjRdaeK6EP7eOhaJO/pnyXIOyzs2NklbX17S6rO4a8A8K7TASAEiK1CnI2UkN4QvNbtdqm81Lqqqdlx+AHcFxdfcKi5zmoqDkn4DwCJx3TUg4hhLcclIJwsZZuFU11vbUdFEbZmg5wrxwDuiQ7DVJlMwq1lvY3onmUzW9ApLkguSJuEYw0eCJwB5jKSXIuJCVKGByCInCQXIcSEJfEiJykF3mi4vehCUThETlJ4kC5PQjJwkoshETlCECcoicIE4SScoQhzKSSgThEhCCQTlGTlJJwhJlETlJJQJwiTE1JcknklHmknkhCSd0lKSUISCMJJGEtyIjKEJojCSRhOEJJCEJojCbc1PkYSC1CEw5qbc1SC1NuCXKEw5qQWp9wTZajKXCZLU2RhPO25ppzmhGU5NkJJG6N0rB1TZnb03RlCPhRFuUw+407D60rGH95wCXHXRS/1cjH56NcCkThqllu3JM1EXFET4bqYymqphllJUPHi2Jx/ROi2V5BzbqzHX+jv/kjKdgqkaxLigfUTMhiYZJXuDWtbzJT01uroAeKiqW45ZhcM/gtZpsWTTrWz1tzo2XB43MsoY2IfdBdjJ8T8PerRzHdI4lo2V9prT8en6LhOH1cmDLIP+UeQ/Hn5C4VVDqa0VBxDdaKY+EdSx35FWEc7ZG8THBzfEHKnwBsquSTkp1BIEgRh4KQpcpSIjKGc8kaalSERGUsjKHAUITaCVIWxRvke4NYwZc4nAA81EprrTXEkUBluuDh37MgfVlp8HCJrsfFISAgAnYZUlJ4VY0mmNS1+O505WsYeUtQ+GJo97XP4x/hVxTdl2pp/68WykaftNqZJXfFvdgf8SZ2jR1UwhkPRZbBRLdw9j1zcBx3mkHkKN5/HvApkXYtIf6y9/wD1ulx+byk7VqXsH9VzhEThdQb2KU/2rxVn3RMH6JY7FaLrdq4/3Y//ALVJ2rUdi7vXK8lEuq/+hagHO61/yj/+1Q/9C9B/+tK75R//AGqO2ajsXd65UjwV1T/0L0PS6Vfxaz+SQ/sYp8epdZR/FCD+oS9s1HYuXLSERbldMk7GHfYvDf71L/8ApqLL2LV3OO8wE+DqZw/8RT+2Z3pvYv7lzosSHN25LdTdj9/jz3U1vm83TPZ+HdlV1T2Z6np84trKnzp6iPH/ABlp/BIJGnqjs39yyTmeSbc1Wtwsd1tefTLVWwNb7Uhp3GNvvkALfxVayWOdhfG9r2g4JachSAg7JhBG4TLmptzFJIBSC3dOQojmc0zJGpjmpp7ExCgSRqNIxWUjFGkjQhQHNwUgtUp8fkmnMQhMkYRJwtSSMoQkFqLBS+FEhCQiLUsjKIjCEJCIjKWQi4UIwm0EshJLUISSMpKWgRlCEhE7klEYRHkhCSggiJwhCNJJyiJygmoQRE4RpJ5oQiR8ygBlKAwhCTgpwDCSBlLHNCelNCWAialgYSBCMBSIG5dyTLQp9HHlwSoVnb4eWy0lDDsFVW+HcbLQUcWAEJpUyFmApLQkRt2TqExdbjrgeqfZUg9VlKeu5bqdDXeeVIULQifKW2bPVU8dZnqpDKhNTcqzEiWHKAyZOtlQjKlhyMHKjiT4pYflCXKezvhDPNNB5Rh6anZTgOUabD/NDj8EJQU7xZHJHkJpHkoTspzIRpoOzzR8SEqcQSAcoZKEJeSj4kjJQ4vJCEviQ4gkcSHEnIS+JDiSC4AZXDe3H6S7OyK5U9AyyyV887C9spkDWDBxg9Vp2621V1qBTUbOZ56ZA+qv0NDUXGYU9M3mcemg+q7rxhEZAF4Xuf0wu0LUQcLNa6WhY44BZGZPxKztVrztg1Ce9muFdIw7iGLZvyA/Vd9H+H9waM1c0cXgXZPy0+a7JnBdYNamVkfm7J+X6r6EiZpJAIJHPBS187KLt57Ruz64RtuD5RG31jTzAgPHmd17N7Hu1Sm7TtMNr4cNljIjmZ912MrFvnCdbZIW1LnB8R/M05HvWVduG6q0xCoc4PjP5mnRajWWs7boiyz3K5VDKeCJpcS8815A1z9LvUmprnJQ6Yt8TYGnDJWcTnO88LRfTImv94r7ZZ7bS1FTSyMMp7kHGQcEFOfR87H4LRY4665W5ouU2Ce9b6zPJdNaaO0Wa0Nu9e0Syv8AZZnbzH1yt23U9stVsFzrGiWR3stzt5hcmuGuu16KD0yaqrKWH2jHEMZHuGVvexn6WF1hvMNp1KQ+F5EbHkYIcSBuV6LqtNQto3tfFG2NzS05AAxheDe1e2QUfalPDZ+DhdIwxiM7B+eS6Sx1lu4vE1DUUbY8NyHNGMe9b1oq6LiYS0k9K1mBkFoxhfTBlYySn7wOBYRnI8F4O+lb2g1erNe/sKCV/oVKQ0RsOQ8k88eK9e6MuEv+xdDJMCZRTNL2nnkN3/JeA9UyPg7aKjv/AF2suIHrfcLv81gfh9RRi41EzhzOiacee2f33rF4KpWenTyuGTG0489l6e7Fuxq3af0/SzS0zZq2Zge+Q56hdKuWg6Guo3wz0cUkbxuOAZ+a0GkqGKG204b60YYOH3Y2WkkpmuYTheaV10qqyqfUyyEuJzvt+i4KrrqirqHVEjzzE53Xzt7cuzObs11Kyst/FFSyDja5u3Cc+S9T/R27THa70WyOolL6qkjZG7PPGFT/AEp9Nx1+iaibhHextPCfxXIPocXqSk1PcKIv+qng2aehacr1yplPEfCRqp9ZYDv1I0+y9LnkN84aNRNrJCd+uNPsqL6Ulo/ZPaCKpo4WvfkfmvT/ANHW4Mu/Z7bnuIc6IGM58v8AzXGvphWcyR0teBk4Bz+C0/0PdQek6aqqJzsujc14HgMYP4qG7/8AqPB1NUbmMgH6fdQ3P/XuF6efrGcH6L046nY6PGAvO30s9NRVuiG1ZYOKml2djlxDC9DslzGuHfSru0FJ2bVsEjuF1R6jD4O5hebcNOkZeKYxb84/v8lw9ic9t0pzHvzD+/yXHvoc319PdKqiLsMyfV94z+a6V9LSzftTs+nqA3LoCJc+4rj30QqWU6rrp8cUJjAz91w3XpvtdtQvWhbjA4cXFC4Y+H+S9A4jqGUHGDJ2dCwn7rsr7M2j4nbM3oWk/dePvo76QtWtL5X0lxZxPijbJGAOe+CvVNp7HrBQMb3dtY7zk3XkLsK1bBoPtEjqa9xZTcD4ZMePRelbp9LTTVrYW00BmkHVzv0C1+NKC+VV2LaDndG5oOhwB0P0z71pcV0V2qbkW0fMY3AHQ6DofplX2uOyy0V+m62F9BBEGxOIc1gaQceK8odlN0n0t2oxR0EhDHShmGn2gCNvzW47QPpR3vWlNJbrPTR08U3quwwkkeRKPsD7HrjPqKG/XSIxMif3jASMl3mFZtdNUcN2eqN7kAEg9VhOTnH3Vi3U81htdQbs8YePVaTk5Xq3XcIvujqphGRLCdj5j/NfNmsjltV0qoWF0b4pHx7eAOF9OJaTv7XJFjmzAC8qXn6LdfdNY1twkuMEFFLUd62JrCXY6jwXO8A8QUVobUx10nK04I3OSOmme9YnBt6pLYJ2Vj+VpwR1yR00Wt+ijos2uwOuM0eJ6o5yfu9CF6Lu9KJbTNHtuwrO6F07Fp600tFEMRQMDWjGFr5mB8XCQvN7zcXXO4y1pPtHI8unyXDXOudcK2SrP5jp5dF86L3Zrhp/thlfR0k8ncXBsrTFG52xcCeXxX0T07WGot8EjgWlzA7B6ZCoZNPwCqMzII2SHm9rQCfir6gZ3LAFrcR8Sfx9lO10XKYm4znOdvAY2+a073fDeWwh0fKYxjOc528PBXglygXcYwoYmxzSxMuKXLpivt7KkHZZyr0lBLIXOgjc7xLRla0SostPROa4t2KaMjZZKj0jTwycTYGB3jhO3Ds7iuBdVURZSXHmeLIimP7+OR6cQGeWQ7AA1TS3PJOsmDTsMJ5kcfaOUhydcrl7GvpJpaaoifT1UWBJBJjibnly2IODggkHGxKcJDua6JebPRakp2sqgY6iMHuaqPZ8eeY82nAy07HAPMAjn1yttXYawUta0ZdkxTx/1cw8W+B8WnceYw4pjuSg5TBgaU1JSsI3T4cCgQkTlR1tIGcuXQqnnYWu5LXSxNlYWkZBVFc6Ex5wPcfFRkJzT0VM7llNOKdemXFNUmEhxTTnJb+SZeUJCEHOSCUlzk2Xp6aQlkouJI4kRdnqhNwll3mi4kjIQ4kIwlcSGSkcXmiQkSyfNFxJDnBoyTgKjuOt7Hai4VVzp4y3mOLJ/BWYKaeqdyQMLj3AE/RTwwS1DuWFhcfAE/RX3EhxKJQXKnuVO2ankEkbhkOCkHmonNcxxa4YIUTmlhLXDBCUT5pt87YwS4gAdSUUrwxpJXnLtR1NWVepJ4I6qVkER4QGPIB+S6vhrh+TiOrNMx/IAMk4z+i6KxWV98qTAx/KAMk4yvRUNXDUAmKRsgBweFwOE4TlcX7Cru4/tCke8uJLZPWOfJdljOQqN+tRslxkoS7m5ca4xnIB2VS8W42mtfRl2eXGu2cjKUkJRBKLBXPLGSXIkpER5oTcJDgknknCEnhQkTaSRhOEZREYQhNkZRYKWR5IiEISCMpJGEt2ybe4BCEkjCQfkkT1sULo2ve1hkPCzidjiPgPFX9p0Bqu/ub6Fp+u7sneSpjFM0D7w70t4h5tykynAE7KgcMcymnva3mV1q0fRuvNUWvu95o6Bv2oqKN1Q5w8nu4A0/3XBbiy9gej7Q5slTT1N6mb/aXGbiaR4OjYGxuHvaUwvAUgYSvMrJzVVgpKaN9TWEZFNAwySu9zBkn4Bam09k2tb9wug0/U08Dv7WuLafh97HkSf8K9VWy32+xUgpbZQ01vpW7tgpYWxMHua0ABSjO4ppk7lIIl54t30Yr/AFQH7Svtutx5/wBGifVZ/wAXdY/Faeg+i9YYeF1fe7nVPHNsHdxRu+Ba4/8AEuumRx6ouI+KZ2hTxGFh6HsE0FQ4cbM+olH256yd2f7vHw/gryl7OdH0WDDpe0Bw5PdRRud8y3Ku0efJN5ilEYCTS0NDQgNpqKnp2jkIomt/IKWKnHLb3KLxe5AFCXlCk+kuRekFMcSUhJyhPekHG6Lvc7dEzgI0JcBNVNvoq5vDUUkE7fCSMOH4hU8/Z5pOpdxS6Zs73fedQxZ+fCr1KSbbJFk6jsp0rPkC2GAeFLUywD5McAqqq7ELHKT6JX3O3DwhqGy//LNeugcSPIS8zh1RgLlVT2IVDMii1DgeNdRiZ3/2N8Y/BVk3Y7qKDPd3Cgrtsj6t8BP4v/Ndo38EYync7+9Jyt6tB/fgvPD9I3elz6ZUttb27Fk9ukmZ/wDXGyNapFDpWz10g9J1RJUA+3S09RDFGfcWt71vweu/8+YyUmSnim9uNr/eMpC553KtMfA3/wBv55+uVzK06E0nTOilbbaOrmjOWVFc41UrT5SSlzh81tadzSGtjLTgYACs222macinYD/AFIbE2MYa0NHkEzVDpmkYAUCOmledxj3p9tIAPWdn3KVjzREgdUKAvJTQha3olcIHIIy4IshJlNQQRcTT1HzR5zySZTkgnCJ3NLckO5pcoSScJJKU7ki4eSVPRJJCUWonJiUIkOIhAjCLG2EZTkoSEKtuum7NfnB1ytdHWyAYEk8DXvb7nEZHwVjgog0eKOZJhYqv7GdO1RzTmttzzzdBUl/4S8YHwCp5uwiDP9Hv1S0f/hEDJD/w8C6FWXu32/apraeE/dfIAfkq12t7cSW04qK13hTwOd+JACd2rm/mSCAuGQ35LBydg9UT6l/hx50J/wD7qjv7BLifZvlMfI0jh/4yuhDUN2qv+qafqiPvVMjYv5pxjdV1PKC30jT/ALx7nkfJL2zzsT8EGnaPawPf+hXMZOwS9j2LlQSfxB7P0Kiy9g+pPsTWx3vqH/8A9tdiis1+k3lu8UXlFTA/mVJbp+pI+uu1U8/uBjP0T+0k/eFEY4h1HzXA6nsT1TCCWwUtR5Q1A/8AFwqiruzPVNDky2aXA/3ckcpPwY4lenm6cph/WVFXN/FUOH5EJTdPW5h/qeI+L3Od+ZSiWQb4Tezi8V5Gk05emOw6zXAe+lk/kmzpy8OO1prf/wB3f/JexG2yjjHq00Y/uhOthib7LGt9wUnbHqE3s2dMrxuNLXs8rPXn/wDJn/yRHS17bubPXj/8mf8AyXsvgYOiGGDoEnbFHZtXi6Sw3SEZkttXGPF0Lh+ihzRyQf1kb2fxNIXt0OA8k3I2KT22td/EMo7Y9yb2QXiESAjkcIBzT1Xsit0jp25EmrsdtqHHm6SljcfmQqOt7HNEV+eOyRxk/wC4mkiHya4BO7cdyQwrypgHkQi4F6Mr/o46WqsmmrbnQeDIpmOaP8bCfxWer/oy1DQX2/UkcmOUNTRlufe8POP8PwTxK0phjcFxMtISSMroN17CdbWziMdBS3RvMegVjcgefeiP5DKxd3tlbYpmxXShqra97uFgrIHw94f3C4Di+GU8OB2KaWuHRQCEkjCeLQUhzE9MTJ2STzTjhhNuCalwiJwk5KB5okJEeSjAwkpaEIIAZRgZR8ghCAGEsDCIBKAyhCUAljmkjmltGUxPTkbckK4oIeSrqaPicFf0MOSBhPSFW1BDsFeU7OEKBRQ4aFaRNwhMKeaMJeNsogNkY5FCRJuGp7tpQH/arTFzsUTd3V0LRW0TR0JliyWDzkawDrhXdp1FSXaljqqGrgraV/sz08gkY73OGQV1uKsLjuVkNQ9jel9SVctwgglsF5k3dc7M/wBHlefGRoBZL/8AEa5JkhPD2u9oYVVDcAcbqdDW8t1jrrpHXGjMvfTRa0tjRk1Nsa2nrmDxdTudwSe+N4J6R7pjT2tbffzMyhqhLUU54aiklY6Kop3fdkieA9h35OATw4HRIWHGRqF0aKrDuqksqM9Vlaa5Nf8AawfNWcNXkDdOwoTor1s6dbMqiOoUmOo80mEmVZNlyl8eygsm8U616YlBUrj80fGVHDtkoP8APKE8FPh6Pj8UyH5R8SE7KeDkfEPBNB2yMHKEqdDvPCHGm+PzR8XyQnp3JQ4k3xI0IS+JHxeSbyUMlCEcr/V5Lx79NezmSG23AN/q5S1xx0I/mvYEjiWlef8A6WNjN07PKyQN4nQASD+6V2nCFV6He6eTOhdj46Lp+Gan0W7QP6E4+Oi519FGgoL7pSpjlpYpqmmqC0ve3JwRkL0dT6cjgj9SNkYx9loC8F9kPbFdOyx1e23UMdc6r4TwyZ9UjrgLb3L6QXarqkGKkIoIzsPRoQ0j4r0XiLg24192mqGSNbE45Bc7vAzpr1yu1vnCtdWXKWdr2tjccgud4a6a9VrvpXMs1PZo4Q+L9oOcOHh9rY5Vt9C6hrLdZbnLIHspqp4c1rgR6w25e5eeb5p/Wd2qhcLvBWXIsPE9799l3TsC7fqGOvpdPV1GKDJ7uN2TvgdfBaNztdRScMG20ThPg8zyCDgDXQb9Ffr7dNTcPmgpCJsHLiCDjGug36L1JcbLDcuF0kTXkci4LCdruqavss0VJd7bb462RkjY+6JIAz12XUIa2nFI2Z0jGRFodxuOBhZi+T2LWEEtrdUQVwO7oWuzyXhFC9sdQySeMvjaRzDXbqPBeRUhbHMySZhexp1Gu3VeMNRfSQ7Q9UU74ooI6GneMERREu+ZWC0ZqOHTeq23e/Uk9S/j4iCzHEfHcL3XF2cWmi2prdTxj+AH81xn6S2gbbBo99wEMcNVDI31mgAlvJe1Wfiu1VM4tcNH2TJfVy04Ovf1+a9TtnEdvnmFvipezZJ6uWnXXv8A/K7d2d62teu9Miqt0rXRkGMsH2TjcfivFv0h7JNpjtNlnALBO0SsPiQd1u/ofXqoiulbRBxdADxFudhkY/NdR+kL2Wf7eWc1dMwG4U8ZEeBu7fOFnW90HB3E76WR38l4xk9AdRny6qlROh4Xv7qd7v5ThjJ6A7ZXROxPWUGqtF22pjlDpGwMbIAdwcY/RdHMoIXzq7Mu1e99il7lpqqGSSk4w2SFwxsPurvEn0zrL+zuMU745i3aMguOfPCxb1wRcY6xzqCPtInnLSO49D5LMuvCdcyqc6jZzxuOQR4rTfSsvsNr7PaiEvAqJnfVjxxzC4f9EW1yS36trCwtjY0Fj+hPIhY7XOvNQdu+pI4ImcVOHARxtHDgeJXqDsS0A3RFghpy0ekPAdIdufvW/Xsbwtw062TOBnmOSB0Gi2KxreHrCbfK4dtKckDoFW/SZsv7T0I+QN9aPIz8F5g7He1eu7M7w6aGM1FNIA2SPntnOy9qdrFt/aWibhFjOGcQC8Sdm0NPT6+ZR1sLJYDPwOjfyIzj+SucFzwVHD9XTVLOdrNeXvG6tcKyxTWWpgnZztbrjw3XpmP6YunjQd4YXwy4/q3+s7PuC8+9q/a3dO2K8xUsDMUoPDFE0EE+9d0qfo+aZuExqDRu7w9OLDPktNpbsks2npGupbfC1w+0YwSFi0V94YsrvS6Cne6XpzEYBWTSXmwWo+k0cDnSdObYKr+jt2eP0bYxJUM4auoIe8bH3fguy3uk9OtUsGxLm4GUza6D0VjRgD4K0lAezGV5hcLjNcKt9bMfWccrgKytlral1VKfWccrx9VfRTqKm81c9TdmxQSyue1kMeXAE567LVWP6L2mKXhdVel1zx99/CD8AvRL7fG92SAnI6KNvILo6jjS+1DQw1JaP93A+YGfmtubii8Tt5TOQPDA+mq5lYeyHTtk4TRWWmicPtFnET81v7TZGUoAa1rAOQaMBWjYGt+y1ONw3kFyc9XPVO553lx8ST9Vzks81Q7mmeXHxJP1T7QBHjCiPoGOfktCe7/zRd55KooU7BGIhtsnzLnqoXeod6hCllzT0RiTCh98EffeaEKcJjnmlCdQO+Pij75CFYCdKE/mq4TJQm80JisRMl9/5qtE2EsTeaEKybOlVLae40j6StiFRTP3LHbEHoQRuCOhG4Vc2fzSxPjqgJDqspfbBPYD3oeaq3uIDanG7CTs2QDYHpkbE+BICgB+Qt+yrAY5jgHxvBa5jxlrgeYI8FmLvpY07X1NrDpqfm+k5vj82feHlzHTI2C7pQ7vVOkSwsnYWPGx/BJima8BwIIIyCPBOZykTisldaN1HO5rhsdwehVZI5ba4UbLhTGMnDhu13gVhqsPp5nRvBa9pwQVG4YUzTlNOduUy9yD3qov+oqTT1A6rrHFkLTgkDO6fFFJPIIom5cdABuSp443yvEcYyTsFZPcm3PXKrl2/WuIkUlHPUnoXYaFmq7txvdYS2joIoB0JBcV3dNwJfqgZdDyDvcQPlnPyXVwcJXabUxco/3iB/f5LvAkCMOyvMNb2l6lmqG9/XyRAODjHGOEEL0NZLiK6200+eLjja7PmQqvEHClXw7FFLUva4SZ9nJxjHUgd6q3jh6osscck7g7nzt0xhWk1Q2Bhe8gNAySVzbVPbNQWmZ1PSsknlbzIAx81D7ZNXPt1I2307+GSYesR4LK6B0RHcIBX1ZLy/drSMg+a37LYbdSWz+N3vJYThjB+Za1stFFTUH8VuuS0nDWjqpw7drg14PoQERO7nHdb7RvaXQao+qB7mo6xvPPzVXV6Nt9RTOY6mYRg4OOS5FeKKo0Zf8AMDnNDSC0+IW7RUXDnFjH0tDCYJwMt1yCtakprJxE19PSRGGUDI1zlenK9xfTSDP2V5V1ZS+h6ir48YHekj4r0TpbUDtTW6PuWOnnc0Axxt4nHbwC4x2u2Ors2p+KrpJ6N07OJrJ43MJxz2ICT8NpH0N3noJdCWnTxaf/ACjgZz6S5TUkmhI+YKu+yLXTqGpFsqpMsleBGXHlsu5xTNkYCDkHcLzZc9E3O3aetupKeHFHLGH941wJBzjpyXe+wSgl7T7X3DbpTU1VTMbxtkBc4525bfmq/HFninBvdAPVJLZB/S4HGVBxXa4pwbrRj1SSHjucDhS7zWikoJ5uYYwnC8uVMb73eKt7HF2S54J8Oa9b9t/ZnU6I0PW18t+hlfwkMhbSFpefDPefouG9i/ZtNrGkuVYKgQRRtPD9SXknqPaGNlNwTMLRZ6u7HfIaP371Lws/+F22puJ3yGj9+9Zzshr/AELVjI3HDZWFp9/RejKdwcwcl5ps1ELH2lU9JUTPhbFWiN8jAOIAnGcHPivddi7E7FXMbwamur3EZMcbqXI+BhJCofiZC0XGCsbtKwfL+xCrcdQZrYqpuz2D5f2IXL+FDhXbh2B2PHrXS7SeZkhH5RBD/wC5/wBOH2qy6n/8paPyavHedea8h71xHhSeFdw/+570wedVdnf/AJaR+QS2fR80iPa/ab/fcph+Tgl5wjkPeuFloSTgDfZd9Z2B6Jb7VJcnn/31Wj8pgpsHYzoulxi0PnA+zV1k9Q35SPcEnMEnKV5wmlZDGZHkNYObjyTVHVx3N5ZQn0+UHBipB3z/APC3JXqq36D0raZRLQ6as9HMNxLT0MTH/MNBV+JQWgADhby8Ak50dmvKVFojU10A9F09cnOP2aindTfjNwD8VeUXYnrK4YLqGktx6tr6toPwMQkC9I9/xdURe5JzlO7MLiNB9HGskcH19/hhadnQU1KXkfwyFw/Fi1Fu7ANKUHCar0+6ubu19VVGMg+6EMBHkQV0PiJQ38UwvKkEYCrrNpuy6b4v2TaaK3OcMPdSwNjc/wDiIGSfMqydMT5JBaix5pmU8NCDnE9U2TlKIykoUiCGcIJB3KbuhHxIZKSThEXFOQl5KPi8k1kpmpuNPRNzPURwj99wH5pQC44CUAnQKXkFGq2lvVFWbw1cUg5ZDgpzTxbgp7muacOGEjmkHBCcShySBlLAwmpiNBBDGyE1G3kjQHJGBlCEWMpXCgThKwUJMpIGEOFKA8UeAhGUjG/JHv4JeMowEJMpPTwQIynB7kOFJhJlR5ZAwZJDfeVX1F2ghzmZufJWUtBDMSXsDj5pk2ekz/UMPvCQgqRrmDdUFTqWNnsuc73BVk+qZBnhjld8FtRbKZvKCP8AwhLFBAP7FnyTCwnqrLZ4m/kXNZ9WVoJ4KaUqI/WFzYdqaYe4rq3ocP8Aum/JEaKE/wBm35JvZHvUwrIh/wC2uVN7QrpT86OV4HizKep+17u3BtZa6ljfvxtz+BXTTQQn+zb8kPQIh/ZM+QQI3dHJTVU7t4/ms3bdb2a5sBiqg0n7EjS1w+BCnOv1AP7YH+FrnfkFbikaOTAPcEPRsKQNd1KqGSMnQH4/2VE/UdKwepFVzf8Ad0sh/RR36llP9VZrjL5ljGD/AInBaT0Y9EXop8E7kPegSMHT5/8AhZv9tXiT+qsLmjxnqmNx8BlIM+pZztFbaUfvOklI/wCVan0QdSEoUrAm8neUvbNGzR8/1WT/AGXe6n+uvPdg/ZpqZrfxdkof7Ew1B/pVTXVgPNs1Q7h+QwFsBE1vJqUMDkjkak9IcPZ08tFnaHRlsov6qhgYfExgn5lXUVGyFoAAaB0AwneMDqm5Klo6pdBsoi98h1OU7whvIoi4BQ5K0DrhR314HVIXJRGSrEygdUkzDxVQ+5AdVHkuoH2kwvUzYHFXhqW+KbNYAs7LeQ3m5Q5r4B9pN7RWG0ritS6uA6pl9wA6rHTagA+0oU2ogPtKMyK2ygcVuX3UD7SZdeB95YCXUf7yiyakx9r8UwyK422k9F0R16H3kg3pp+0uaS6o4ftfiosmrMc34+Kj7VWRaiei6n+2m/eCL9tNH2vxXIjr2n9I9GbUNmqulNF68p9zBkn5KzpLjfK/HounrpLnrJB6MP8A7MWJ4c52yY63sZq8geZwulftwffwnGX394FYantuo5t3W+np/KorBn/gDk6+26jiaS2koJj92Otdk/4mBP8A5g6Kuaen25x8VvYb8Ov4KU6upq+CSGZrJYpG8L43gFrh4EHmFyWuv94sLeO56buUcHMz0rWVTGt6kiNxcB/dT9h19atQM4rdcoakj2mMd67fe07j4hKJSDgpDbQ9vOzUd41HyVxqLsL0pfeKSigfYqo8nW88MXkDCcsA8eENJ8VyHV3YzqTSbXzMgF7oG7mpoGEvA8XQ7uH90vAAySF2+j1C5uxdkeavKS+slAHEPcVcZMsqWhc3cZXjbjZK0PY4PaeTmnIKacF6f172TWPXYlq6ci0Xp2/pkLMtlP8A2rMgP6ets7YDixkHzjqjTV10bd/2beaX0aocC6KRp4oqho5ujfgcQGRkYDhkZA4hm21wcst8Lm6jZVZGUlGDko+FPVZEOaUiAwlNQhKRhqDQlDmhCIDKWiAwlAZQhGBhOxjJTQGFKpYuNwQnqfRQ8itFbYOIg9FUU0eXNaFqbfT93GEJhU6nZwgKWwYTUbdk+OSE1LG6UNgkjYJQ5JyYuk013PirSnu4d1WMZIQnmVTm9VGQhb2C5g8nKj1j2e6Z7QhDJeLe018AxTXOmeYKun8O7mYQ4DJzw54T1BVRFc3MxurKmvRBGSkSglpyFz67aD1nonMlE/8A27srN+E8FPdIWe7aKfAHTu3HPJxTWnNaUN875tHUONRTu4KmjqGOiqKZ3VskbgHMPvC69SXZr8esqjWHZ5p3tB7me5UrobnA0tprrRSGCspx4NlbuW7n1HZaeoKUOI2UnO13tj3qgpri2TkcHwVhFVA9Vg7vYtU9nuX3ON+qLGwZ/bFug4aqAeM9M3PEAPtxZ5ZLGjdWVm1FT3Kihq6SqiraOZvFHUQPD2uHkQpQQUxzMajZbWOfKksm5Khp6wOGQ7ZTYqjO6CFErlr8pYeoMUwIG6fEmSmJ4Kkh2UoHZMB2UsOyhPCeDtkYcU2HbBHx+aE5OByNNce6MOQnpzO6HFjokcaHEQhCcDkfEmw5DOUJcJZfkHcrn3a5amXfR9xpy0u4onAD4LfKj1NB6TbKhnPLSrlNKYJ2SjcEFTwvMUrZBuCCvnf2OQU0XafQUNdG2WKSR1OWP5Z/0F7itGjKGCJvcUUMYx0YF4T1G9+iO1apnY3BpK7vQPEZyfzK7ZXfTElgi4KGiYwgYB4c/mvoHjCx3K/T09TbwS1zBnXAHX6Fey8UWeuvM0FRRDLXMGddO/7r0dcNOwMpX98xrogMuDhtheD9cCmtvajI23EYjqeHMfiTz/Fau/du+uu0BhpKI1ccUmxEDTjHwCvuybsDrq28w3a/EuaHB/dStOXHzKq2S3t4MimqrrOMubgMBySq9poW8KRy1NxlGXDAYDnK9Ix0tXfuzCGjdK6OrNLwhw554Tj9F4zodV6t7INZ+lVUk7pY8sIk3a8H8Oi972yh7qkZGNmtaAAslrHs8tmouI1lHHM7GOMt3C8/sHE8NrdNDVwiSGXcdRnuXG2a/wAdvMsVTEHxSbjqFyal+mhbzQA1NA+Oox7DAXZ+PJce7SO1y+ds1ayhpIZWUnFgRcPP34XeB9H3S8E/eMtzS7nl/rFavT+gLdZQBS0ccWOoYMrdh4g4atT/AEm20jjL05joD4brVivlhtz/AEigpSZOnMdB9VkPo8dmb9FUDqmpA9MqB62Dyb4LuVRSNnhwcFQqChFOBsrMOw3GF5ncrjPdKp9XUHLnfvC4WurZrhUOqZzlzly7WfZNZtSuLquiYZeQlDfWA8liKf6N2mqeUObSOkGc/WuLl6BkjD00aNn3QrVPfbnSR9lBUOa3uBKngu1fTM7OGZwb3ZKwemOz22WBjWUlDDF+82MZ+a31vpBAwDCNkDWcsBO8QbsFkTTy1Dy+VxcT1OqzpJHzOL5HEk9Sq/UkAq7XUwkZDoy3HwXgW7sOnu055wRiYO/H/JfQGtbxsIz0XCdSdgtuvep3XOYuLuLOOLA5+C9A4NvtLZ31Dawnke3Gmuq7Phi709rfMKonle3Gneuv6YfHcbTSVAw4SRNdn3hXsdM1vIKi0xb22m2wUjD6kTQ0e5X/ABHxXnspb2juTbOnkuLfy8x5dk4Bw9Erix1TPEhxDxUSYnS9AvTXEPFFx4QhO95lEXqvuF4pbZHx1MrYm+LjhFRXOnuMIlp5GyRnk5pyE/s38vPjTvUnZu5ebGisONEZFHMnmkGXHVMTcKV3mEBIohl80XGPD8UJMKYJEO8Hiofe/wCsou+80mUYU3vcdUO+81C73HVH3zR1RlJhTRKEfe+YUDv2/eSu+HijKMKeJfNLEqrxMqHWmuKTQ9hqbrWNklhgbxObEMlTQxSVEjYYhlzjgDvJUkUL5ntjjGXHQDxWwE3wQM4aPaXlS9fTNYC4WqxPd4OqZcA/JYS8fSr1vdSWUrqagY7kIYuJ3zK9Epfw9v1Tq+MRj/ecPoMldtT8E3ifV7Awf7xH2yvcvpfmpNNVlrw5pIIXz00/2w6rqtaWqe63usnjbUtD4nvw3BOMEfFe6LNdRU0kT+LOWhY/EfDNRw26Js7w7nBOmcDHTVZV94fmsbo2yvDucZ020U/Udrp5oZq+F8dPUAccjHnhZJ4nyd58j18V5n7QPpJQWWrfQWulfU1DSQ6QPGM+Gy0v0oO0ubTunGWyimMVRV5a57TyHUfELlfYb2TU+paCS8VxcZnOIhDjsT14h+q6SxWa30tsN8vALmZwxo6lbVotdFS283e6jmbnDW95VbJ9InWUZM7aVsEGfWL2F23vK1ume3Gm1lLHDXxei17fV4s7SDHM+GFv59E0rGOp56JnE3Yte3K84dq2jXaKv7KijJiieOIY+ycrdt7uHuKy63NpRBIQeVwP7ytm3yWXiJzqJtP2MhHqkL0M2o71ocCCCMjCxvadCazSNewDLms4wPMJvs91Eb3ZoS9xLwxoz8OXwVxqSnFTaqmPGQ+Mt/BeTMilst2bHL7UTx8iuHbHJba9rZPajcPkV530Hb6e6Xkw1DeIFuQAux0mj6GnaCylbnxcuO6IlFv1nSxuOB3hiP8Ar4L0dBwtiG3Rem/iTVVVPcYxHK4MewHAJA3IXccbzVEdcwMkIY5oOATjuXAe1K1igusL2sDGvaRsMLp/ZldfS9J0eXZcxvAfeFRds2nqyWyQ3ZtJL6Cx4AqSwiN2dvVJ9rfOcLY/RL0la9ZW+5R3KonxSTDhponBgeCMkuPPHuwfNS3Im6cDwVB1dC7B+JH3CfXZreFIZTqYnYPzH3C432r1T5dVyZ3Y0Bzf1C0tj19bLVbIozKxuGjnvv7gCR8lffSu0XSaY1HRS0FK2lpHh0YDckuPMZJ3J8ySp/Yb2Oaf11pyG4VAEtRxua+NxJ3B8F0lQy0VHC9FU3Lm7NgA9Xv21+C2p222ew0k9dzcjdPV7/H4LMVPa7b3EshgrKx53Aia2IDyyeIkfALLX6S7a3ma6l0/JTjxaXuJ88uP5L2XZewywW1rRFQMyOvAFq6XQVut8fGKSKNjBkkt5BcZT8V2GzyCS1UPrjZzicrm4eILTbXh9vpPWGxJXO/ol0d2sWm6yhuVOYGktewH5Lnv01rKfSbZcg3k8xuPgCM/mvUmmZLbVw8VBPDKz/s8Lj/0vrD+0Oz6ecNy6nIlz7isqxXl8vFcdbIzkMjsEeYwqFpuDpOIGVcjeUvdgjzGFhvo+26n172PVVlqmtkEUr4jkZ4QdwuT08927A+07jZxR0rqgDI5PjDv810D6Fl4Aud9tTnYD2snaPE8l1f6QnZNFrTTklTBEBXU0bnscBudl2E1zjsnE1XbawZpqg5IOwLgDn4ro5K1tqvtRRVOsExyR3cwzn4rnX0oe1Kk1doKzNoZQ6Osd3gLT7JB3HyWt+jDpb0Ts970sLXVZJe1w5EDH6rx46lrH3GCz1bpBwTCPgPNpJC+jHZXY/2TpC3UxaA9kLQ7HU45qHjGlh4esMFrpnZD3l2e8bj7KPiWnjs9pit8Lshzi73bj7Lw12225+ne1GqkYOEuc2Zp88/5BfQDs4rabVGjLRUyxR1DJqWN2JGhwzwgHn5heUPpS9nN2u+saSptNtnrHPDmEQsz5heiPo40V0tHZtaqC8U0lJWUzTH3UnMNB2WZxbUwXHhy31AeDI3QjIzjGNt+gVLiCeKss1FM14526EZ1xjG3uC6gbDC0f0eoqaQ9O6lJaPc12Wj5Js0l2g/qqunqh92eIscfe9px8mqzYTgJQduvFMBea5d11VQK65xHE9pdIfGjqGPH/HwJ1l1OMS0dXAfB0XH/AMnEFackoEISc3gq81byMx0tRMOuAGkf4yEksuM2eBtPSt5tfITKfcWDhx8HFWXFjokmQBCM9wVcbIZd6mtqZQd+COTuWtPkWYdjyLiidpy1vwZKCnnePtzRCR3zdkqe6Zo6pp1SE3IThk9VEOnrVyNsov8A93Z/JJ/2dtIORbKRp8WwNH6KUakJPpATshLhyYFko2+xG+L/ALqVzP8AlIQNnhb7M1WD51cp/NxT/pAKHfhJkJ2CmDbJAPUuNXH/APW3f8zCiFFVM9muc/zmjaf+XhUn0gDmQEsSg9UmiTVRe4uA/t6Z/wD8Fzf/ABlEW3Af2dM/3SOb/wCEqbxA9Vy7t07W5uyuxtrYad1RxA7Nx+qvUVDLcKhlLTjL3HAVmlp5auZsEIy52y6AX1g9qmjH8M3/AOimzX4eGljQ49GygleKZvpIdoWvnuZY7c7gJwHNBfj9FHm0d2y6jYZqi4TUMRGXMMvdn4Ab/ivQ/wDQV9NpcayOE9xdk/ALsf8ARl0GlbUMjPcTr8F7hZO6QkNj4iOeHA/qnQJT/ZEfELwJprtb1z2SatpKC71M0tIZmsfHKSQ9udzk8+a93aZ1HFqKx09fF7MreLC5+/8ADM9h7OQvEkcnsubsVk3ezy2rkeXB7H7OGxXPO3Ptih7KbA6XhZJXyjhhicTuenJeXaB/aP2xzyV4dLSUbzljmDDfmUf0mbvPqntnhtb3Ewwua2NufVc0nO/nsvVvZ7pSnoNPUNPTxiOJsTcNA2Gy7rmg4Ps9NURRNfUzjm5nDPKPALpHSR8O22CWOMOmlGckZwPBeR79oXtH7N+G7x3Oeo7sg/VyFwbvzPRd0+jp9Ip2tcWa9ODLo1zY2OJ3kON8+eV2S66VgqKN8ckbXxuG7XDK8Ia6s0vZL2u01VRkwxsrBIMHAxxb/mVctlZBxxTy0FdG1tQ0ZY5oxt0Vigqo+KIZKSrYBMBlrgMe5fRuMB4ylhhVHoy+tvdjpav/AHjAVoeNvivDZGGN5Y7cLy9wcxxadwmw0g8kMeKX3rfFIMjUiajBwhv4YSe9CHfjwTEmE4AjyfBNibHII+/HghJhOoD3ZTYmalCVo6oRhODdK4QAmhK3OyV3oQkwlg7I033zQh37UJMFOEoJvv2od+1CMFOfmgmfSGojUgIyjlKfQUf0rySTVDxCTKXlKlIZKiGr35hJNZ5pcpeQqwSeJQvTPND0zzRkI5CphcPBAuAUH0zzSHVg8UnMl7MqeXhIdOB1VZLcABzVfUXdrc+sml6lbC4q9fWNb1UaW5AdVl6m/tb9pVVTqUDOHZURerjKQlbGa6DxUGa7tH2lhqrUx3wVV1GopH/aUZcSr7KLvW9nvzW/aVdPqJoz634rBTXmR32lDkuT3dUmquspWBbqbUo+8oM+pc/aWLkrnHqo76xx6puFcZAwLWzaiJ+0oM1+c77SzL6s+JUeSsPimlXWRsHRaKW9OP2lEku5PVZ+SsPio76vzTCrTWgK9mvBAO6prxq2C1QCWpm7tr3tiY1oLnyPccNYxoyXOJOA0Ak9AqS+6hp7PQ1FXVTNhpoGGSSR3JoAyStfoi2js/gg1LeqNs+u6yEvpKWpbllip3jAaGn/ANoe0+uTu3PAPVDjI+KIyuxnAG6SedtMwOAy47Dv/QDqVb2Ds/vlxo4rlqeeLRVqkHFHBVHvbhM3/uh6sWRgjJe4cnMaVdMpND2c8MFtqb/KPVNRdpuJknvhAEZ/wBZGsu1Xdax9VWVElTUP3dJI7JP+XkktlOFfbGxmjW/HVY7hPNrNIfIaD5an3rfwa5fSU/o9FT0tvpxyhpYGxsHuACQ7WNTKcvncfisL35CHpJHVOJKYKWMdFuhqt/V+felN1cQfaBWC9LI6lJNYfEpmqd6KzuXSafXboSMPI8uiqtR0GkNcyia8W70e4t/q7rQuMNTGeh7xu5x4OyPJYg1h8SkemvHJyadRgjISspgw8zCQe8HBV5UWzVmjKd1TR1J13YWjJdAwNuNO396MbTY8W4cT9lWenNeUV+om1duq21MBOCW7FpHNrgdwR1B3CzVv1JV2udstPM6J46g7H3p27WWk1xVPu9omi0/rRrR/SA0+jV4HJk7Bzzy4x6zehIHCYTHj2fh+hWi1/NpUgf5gMfED6hdOt+qRkBzlOv1ttOu7JJa7vAKmlk9ZrweF8Txyexw3a4ZOCPHzXE9Oaudc21EFRTvt91opO4rrfKQXwSYzzGzmkYLXDZwIIWxs+pnQyBjnZanMkwq9VbBjmYuOaw0pcOz7UItVxeamnmJNDcQ3hbUt58LgNmyAA5A2OCR1a2CBld87SLVRa00RPFVM7zuyHBzThzNxgtPQg4IPi0Lz7RGeN09HVkGtpXd3KWjAeObXgeDhv5HiHRaLJObQrkq63mOIVMY0zhw7j3+RTqUBhGgplz6NvJKAyiAwlDkhCNKHJJShyQnBKYOJwCtKWMRtyoVJHxPVpDGZZWxtHNCVW9lpTI/vCNui08MfC0KFbaURRNAHIKzYMJyjKcaMBLaUlKAwEJEs8kGnGUOaA2SZTFqg1GQpQgSTBjokQoxJCAkLeuE46EhNOYQhCkQ1z4zzKuKG+FpAcVmycINeW9U3CF0KkujZAMO5rE6s7JKe51tRetL1Men7/M7vJ28BdR1zv+3jGMOP+9Zh3jxAcKKmuD4Ts5X9uvoJAccJE5pLdQuXW7UVTR3c2e70UlkvrWl5oZnhzJmDnJBINpWeYwR9oNOy11FXtmxvg+BWr1Lpuza9tH7PvFMKiIOEkUrHFktPIPZkie31mPHiCOZHIkLlN3t927N6mOG9Tm4Wd7wylv4YGgEnDY6lo2Y8nADwAx529Rxa0yB3QpxAdqN10CGfzU2OXIWXobnxYD9irqCoDgEpCiCtWSDKeY9V7JeXVSY355JqeFMDvVRF2yba/LAm3O80J4TvGltcowcnWuTE9P8AEjTbTlZ3Xuv7f2f2qGsq4Kytkmk7qKmoYg+R56k5Ia1o2yXEcx1ICQnGpU8cT5HBkYyStPxJS5TQdvkFdUQxM0ZqqZrzjvqWgbNE3zLmvxjzGVrLrqHURdALNpgVEbwS+e4VrKdo32w1oe4+O4CA9uM5Vp9FNG7lcMZ7yP1WqUO4Q97E5p6jdZttbrst4jabAP3P2jNn59yl/trVkfqz6Up5sfaorq1xPwkYz80CVqYaZ47viFx7WP0b7DqPU092rTUyyS44o2P4W7KwsXYVpe0EGCx07nj7co4j+K6RPqqWmP8A0jpe/UI6vbSsqx8qd8jsfBLpNcaXqKgQftijpqk8qask9HmP/wAOThd+C6B/ENxlibC6pfygYAyQMDwC0ZK+6PjEbpncgGAATjHuVTb9JU9FgQUsVOOWIow38lf0NobERkbq44GEAjcEZB8QkvIZ1WQ57nnLjkrCdknLt0GARNwolS5r0KioxlQJJyVEmoOhDugRtY1vQJky+aISoSYUriDRsUO8UbjR955puUqkd4i48hR+NDvPNLlCf4vNDi80yHnxQ4z4pUJ12HBRn0rXHJCc4vFGHIQlRxBic4sJnPmjQhPcSHGEygX48EmUJ0vHUrP6k1xadL07pbhVNhAHLmVz/tu7ZodAUHo1M5slylHqsDsFo8V5jobVqztUuLp6ioq3QvcTxyFxaAvRbFwia+n/AIjcJRDTjqdz5LubTw56XB6bWydlD3nc+S1Pbp20M19WR0NlmlbSMdguwWFxyu+dhlLVWvQlugq+LvwzfiOSR0K53oLsJoLBJFUVLzWVGc+uwYC7laaX0WJrWt4QOQAwpuJbzbX0UVntDf5TDkuO5PwCkvt0oX0sdsto/lsOS47kq87zYbpt0qZdJgLD9oPanbdB0RlqXNlmI9WFrwHFee0tLPWzNgp2lzjsAuPp6eWqkEMLeZx2AW7M4HVI9IA6ryRdvpH6kvU7ha7e5kefVzl3+ShUX0htXWerBuUTZWA/1fDwAD4L0Rv4eXhzMksDv6eYZXat4LuZbn1Q7u5hlexO/UG86io7DQyVddMIIGDJc5YDs47X7frymDWOENYAOOMnqfBWPaVB+0NJ10eM+pxYXDm3S0le2jrmlhyAe/BPRcsaGSnqxTVbS3UApFq7c9L3sVJpK3iZACXPkbwt5Z2K5JrP6TtdU1slLYbf3kbTw97xE589lwmggq33h9tgldE2abgIB257L0xovswttkt8Te47yfGXuec79V69c7Nw/wAIPE9Q0zF49RpO3eSRhejV9ss3DbhLM0yl3stJ+JOy5ZF9IrWVvq2mpc1sIOTEGcJPxXeeyjtxo9eRdxOG01e0ZdHnY742VJqjs4t15t0sTqRjH8J4XNbg5xtuvN0grezfWPCx7mPhe0k8stzlT0tNYuNKWSGkgEFQwZGOv6/VS08Np4pp3x08IimaMjHX9V7+ZVcTcrCdr8X7S0Vcqc7h8TgR8P8AJTtJalZf7RBVscPXaCceOE1rP+kWOrYd8sK8TpS+irmcww5jh8QV5fBz0tUwnQtcPkV457K7PQXnWVPQ3OATwSBzeAnHrdF6dtnZ7ZrdEPRbVTRYH+7B/NeZtJPNo7SYXNODHVZ+Gf8ANezKOVr6cEEEEL1z8SaupZWwujlcI3sBwCcZz3bdQvQ+OZpxVROjkIY5o0ycfD3rx12wWw2HtAqHRsDA/gmbgYGf9Beu+za+i46VoJweIOiafwXnT6TVtEd5t1a0bPa6MnxPNdH+j7fPTND0sRf60OYvkU7iU/xHhOgrtyz1T9P/AIpb6PTeHaOq6t9U/T7LnX0p6qSfV9LuTEYuXg4bKZobt8tmjdNUtIKeSWpYwcbWt2z7ylfSZtjnupa8DLQ/BPvH81n+xrS9n1HSS+lRsdVxyY3GSRzXRQOtk/CNNPXsc+OPQhvfkjXwWzH/AA+bhqCWtYXMj6N7/FX9++k3dr8wMoLOQ4HDZHEkgeGywN/rtWa6eG1dIQwchwcOF6Otug7bStb3dIwY8ldjTdM1gIhYxzRsccx4LjouMLTbXB1roA1w2LjkrlmcS26gcHW6iAcNiTkrjnZDpC62yiqm1cfDhvExo8QeS190kaKCVz3hrQwkuccALaaOrIdUXJ9DZHRTTROLZJZnBkUWDj3uOQdmZORgluQVt6vR+l+zC0T3S5yxXC5MaZO+qg0NY7niGMkhgB5HdwG3EVwN3q6u7XMzyxcsjyNAFzVbPU3CtM00eHuxoAvBtNb5JdfshjPcufUBzXOadhnnjqvoNoDss0/bKCnq54P2rVuYHiWsAcxhIz6sfsjfcE5cPvLwhYZ36m7X4aimBlY+sMjR14OL/NfR3TrBFQQxt3a1oAPkvQ/xK9Q0LH+0Ga/JdrxqCDSsd7QZr8ly36Ull/bfZvcw1uXxxl7duo3XnP6G98NFruvt5dgVdNxBp8WnJXsbtKtzbppivgLeLjic3B8wQvBHYjNPprtntwZFIY2VT6aQtaTwtyRv8gpOEnC4cMXG3u3aOYfDP1aFJw9irsVbRnoMj4Z+oXq36Q3Zl/t/pQCJuaqmcZWH4Lyj2W9pdz7HNS91VwPNNuJYHDBBPX819CgxtXRgEZyFxvtJ7DLFrGV0s9P3VRnPeRbEnzXPcM8VU1HSPtF2Zz07vi39/JZFkvkVLTut9wZzQu+IVpZfpN6Jr7e2f0sRED1hIOEA/HmuWdsf0rYrpbpbRpdglfP6hqI3niA8sKlf9E2jbUFzrjK5nSNjcAfHmtpo36PGm7BURzy0npczDkGVxOCtSN/BVrk9Lic+YjUNI0z45wr8Z4aoX9vGXSEahuNPfsl/RQ0febVHVXm6zzEVQ9SGUu23zkZ2XXu17T0mqdGV9FHGZZZYnNa0dTjZT7JTxUMLGMAYxow1o5BW1VVMkjwfzXndxv09fczciAHZBA6DGwXK1VdPWVpriMHIIHdjZeTfo59jmrtD66jutypoqaiMTopGGTLznlsvXNTTNqqUtcAQRggqmjMUUvEOfuU9l0aG4JTL7fqi/wBX6ZUgB2APVGNB7ylulZU3eo9JqAA7GNNNlyyv+j9pis1RJepqIyVb3hx9fDAfcuvWelbS0zI2gBrQAB4BQf2gwnOU9HdQ0bFZdTcqqsDW1EhcGjAyc4HcFSmNTUBomeXcowMnOB4KTWW5tS7JCk26ibTDAUJt1DuqdZcwORVHtAqpp3BXoeAOaVxDxVM25jxCWLiD1CTmTeycFb94ERlAVV+0Bjmo891YwbvA96TmSiFxVvJVhvVRZbiB1VFU3bzVbPdufrJvMrTKYndaWS5DxUd1zC5D2ndsdFoC1ummJlqHbMiYRkleeKzto1zrCR01tZKymO7W5P5BdpZ+FK+7w+lAiOLbmccA+S6ah4enrI+20azvJwF7h/agI2dlZ3UXajZtMEtrqtkTwM4JAXkKw/SF1dpG5th1FG58R24HNxwj3Laat0Pbe2CpprwLg6OHG7Ixk774WnLwmLRUMN5kxTuBw9nrAnuVx9gZRSNNc/ER2c3UFb7UH0uNM2vjbBKKh7ejMu3+C51d/pi3a6vdDZbbLI7oeX5bqs1F2IWO2aTuTqWGWWtbC5zJHu5Eb8lj/o3V8UWp5KSSNjjNGQC9oOCN13Nut/DBtdTcqKB0xg3DzjPXOnTf4LfpaOzGjmq6eIyGPo44z4rqHZn2g9pWptZUc9bRyxWs5EnqEAeByV6yo7h3sTS4+sQMrm9ri4OF2VqKWsEbQMryG9XaO6zNkjgbEGjGG/fvK4G41Ar5A9sQjAGMBasVAwuM/SatP7a7P6k44nQnPwI3XSWXD95Z3X8Au+mLjTH1uOJ35Z/RU7TVmjr4agflcD81To3OpqmOYflIXmP6JN9jpnXW2VMzIu7kDxxHGx2P4r0ZeNaaasVM6SquMZwMkM3K8H2633OLXNRbLZUOpKieQtDmnGeq7FbPo43G8NEt4vTn8Q3Zxl/+S904rslndcTcK+r7MSgO5QMk6br0S/2m2vrTWVdRyB4BwBk7LI9qWo6btc7QqemtDTFAx/8AXScLSPE5Xtfs3pm2vStDSskbJ3cYBcwggnGDuF5U1X9Gujstjqq22Vk5q4Iy/iccZx4AKw+iv2pXJupptM3GY1EXcuMJcdwQc/kqV9gpr5Y2vssuYaUatIId4nKr3SGC6WxrrY/MdONWkYPnlZP6R1LJp7taguJyGNnDg49QCD+WV7N7NbzBddN0dRC5pa5g5dNlxT6THZu7WdjFbRM4q6F4dgDmOq5l2E/SAf2fd5ZL+H9x3mGOwcswMY+arVVM/ivhunkovWmp8tc3qRpqFHPTm/WeF1PrLDoR1wvc1TM0xndeF/phd0/XFHDFjilaDkdHciu26i+lXo63W1zobiKipLdoYWl5B8CvNVJDc+27tGN0qInehd4HEgYAHuUHBNqq7RVPu9xYYoo2n2hjJOwGd1Hw1bp7bO64VbSxjAd9MnwXsfsUrJRoS0Nny2YQNDwfEDH8l0YVmRzXPtLNFtt0EDMBsbQ0beC0X7Q25ryCsnE9RJKBo4k/Erg5h20r5B1JKvjV+aSaseIVF+0PMIvT/NU8qLs1emqHih6UPvKi/aARGvHijmS9kr70ofeShVY6rP8A7RA6o/2j5o5kdktB6Xjqi9M81QftDzRG4DxSZKOyWg9M80PTFnjcQOqSbl5pclHZBaL07zRGu81mzccdUk3PzRkpezC0hrvNJNf5rNm5eaQbkfFLql7MLSmv80Rr/wB5Zk3LzSTcv3kmqXswtMa/zRGu81mDcj4ojcvNGqd2YWn9P80RrvNZj9pjxRG6eZSapRGFp/Th4ovT/NZf9qeaJ11x1Sap3Zhag1+OqjVF2azPrLLz3nA5qqqrs5+RlN1T2xBaOv1ABnDlQ1d9e7PrKnmq3OJ3USSUnqk5VcYGtU6ouj359YqDJWOdndMOemnOCXlU4elSTk9Uy558UTnJtzkYTw9G55+Kac9E5ybccIwnh6J78ZTD3nolPKZeUina9Ikf5qLI/Cde5RZSoyrTXpqSRQ6ipLGEp2Z2FT3Ko4I3HPRRHRW2HKh2GhGs+0200M7O9tFna683FhHqyCLBijPQh0phBb1aX9MroVyuEtyuE9VUPMk0zy9zj1JKq+ze0i06IuN3eMVl+qyNxgiCAuY1pH8ZkdnqHN8E8H8Up9+Fqww8kQzudVkSziaodjZug926mxHCeD8KNG7ZOF6XlUwcnC/ASS8pouSS5HKjmTvGkF+EgvSS5HKl5kbnpp0hQLikOOUcqcHIjJupVDVup52PaSCDnZQXFGx2Co3M0UzXqT2p5poaPXNG3FVb2tp7rGwf9YoyfaI6ujceIeReEdLdGv4JI3hzHAOa4HIIPVXFvfFXUktJUsEtPURuiljdyc0jBB94JXMNDGegtc9qqXmSe01UtvL3c3tY7DT/AIS1Ujo7zWxTEOhLT+X6H9Cu1W+8Cey18DjkOhJAXKNV04p7nRVzQB3v9HlPiCfU95DsAfxuWloK5zI3tB2c0tVVquB09oIZ/WNdxN8jg4/HCm5y0A9yqmBkrJITs4H440+BwqI7FAc0p2Hes32TuPciAWqvH8YOClAZKUiAwlN5pU5ADKUglsbkgIQptG3hZxFaCxURc7vXDc8sqnoYDUStjHsjclbS2U3C0bYAQmKfDHwtCfaOSIDAS2pyalN5pSS1KQE0o2lGeSShnZIUi6UIAUkweSlBueiMjCMJir303ko76XyVqWBJMIKRCpJKUhRZIS1aF1OCVGmotuSEuVQkEFKZM6M5BU2ejLeihSQlqEuVb2+9OhIBOy0cFdTXKklpqmKOpppmGOWGVoc17SMFpB2II2wVgcFp2Uyjr3QuHrYTSE8FUOo9KT9nHFWUJlrdI83Rkl81rHjk7vg9+XR+bP6uxt11a5rXNeHscAQ5pyCPEFbO23kPABIz4eKwuptHu0mZLpZYnSWNxL6m3xDJoydzJEP931cwcubdshODuhT8c3mtJT1YeBgqdDL5rGW26NfHHJHI2SN4DmvachwPIg9QtBSVweBulKYFfNflvNAuUWGbiCd4kwqQJ1pyVSV+r6eCrmobfFJd7jEeGWGmIDIHeEsh9Vh3BLd34IIYQqPUlzrdQagdpq31ElvoqeITXa4wu4JWh27KeJ3Nr3DLnPG7GluCC4FsiguthtNHHRWpg9EgHAyK3075ms6/2bT4k/FQOfjQafvotynoctD3gnOuB3eKkPo77ed667/s2EnPodoAbt9187wXu8nRiI+Sm2rTtrtM/fw0odV44TWTudNUOHg6V5Lz8SVC/wBqKRh9eKtiH3pKGdo+ZZgKTRXqkuURlo6qKpjBwXQvDgD4HHIqDmGd8laghc1uGjAV8KkZzhOiq81QGsI6pbKzPVJzJhp1fNqAeqdbP5qkZVeakMqvNN5lE6HCuG1BPVN1lLS3KldTVlNDV07vainYHsPvB2KhR1A8U+yYHqjmVcx4OQs3N2S6dYHOtDazTcpOc2aqfTR//WQe6PxYVX1Nn1vp5pfS1VFrCnH9lUNFDWY5bPbmJx5HBaz3hbkTJYl8DlOBxtokLnHR+o8dfnuFze2a3obzXyW2RlRa7xG3ifa7jF3NQG7+s0bh7dvaYXN5bqyc9X2qtJWjW9Ayku9I2cRu7yCZpLJqeQcpIpG4cxwwN2kLntZ+1ezyqipb/UG5WGV4ipdQOaGuiJOGx1YGA05w0SjDXbcQad3WGzdD8VWfTNkGYdHdx+x+y0JciL/NB7HRuLXAtcNiCkEKwsvbdL70o+9Pim0hNQnu880YkUcuISe8KEuFL70ow8qIJEfeO8UJcKX3hR96VFEiUJEJVJ4yj7wqPxlGHoQnuMqHcq70Wklk+40u39ye41ndbSPGnbj3ZIkELnA+4Z/RTQsEkjWHqQFNG3ne1veQvJdSyTtW7VKkzPc6kZKctdnDGg8vdsutV2v9NdnFIyjYzjMbcCKEhedrPq+WwV1ympRioqi5mSPE/nldI0L2L/7QQtut5nmEs3rd1gdV9HcR22jiEbrtKWUsbQ1jG7uONTp9V7XfKGmj5HXKQtp2ABrBu441/wDK1FN9KG2MmHFbnRQ+OeJ34Lqehu1iya0jAo5wyYj+pefWXMbn2E2KemcyKF8UpH9aTkj4LiN2t907L9TMdFI+NzDxscDs4Lm6Wy8NcSsfBai6KYDIDuv1WHTWyw31robcXRygaA9V7ju90ZRUM87nABjC7PwXinUl0rO03tCMb3uLHzGNjTyYM8vwXoA61Grey6qnY7EzqXhcRzDuH/JcE7FuGo19C2cbyBxyejk7g6jdaaW41z2/zoQQPDQnKk4Zp3W6nrqtzf5sQIHhou+6V7PrfZqCKGGmBcGjJccklL1T2d0N7tssElMxri0gPa3BC39up2iIYAypFTStLDsvIzdKw1HpXannznOTuvNPTqozekdoefOc5XigtruzTW7e7e6MQzjBBwHNB/zXq21XuLVukW1APEJ4nAjzwuH/AEjbK2mq4Ktgw4u3K1/0fbq+p0dJTvdxGGU49x3XrfFDm3nh+lvmP5rSA49/7OF6Tf3C52WnuxH8xpAP781xC4sNl1+88sSh34/5L2BpyRtTbqeYYd3kbXZ+C8rdsdAbXrQytGGl3P4r0T2V3Q3DSNvfnJazgJ8woeOQKy02+4t6jB+H9k3isCqt9HWjqMfL+y2dTAHtILei8x/SKsrKW8QVgaA6VgGR5bL0/Ics5rzl9JisidJQ04diVhLve0rluAHyMv8ACGdcg+WP/CweEHPbeIuTrnPlhbLsBvD6vTLI3OyW4XSr3IDbqjjOGlhBJ6bLj30eInwace6TbLyWnxB3Wx7UtX01g0xVkysMzmFojDhxb+SqXyiNTxJNTUwyS/Ax5qvdaYz3uWCAZy/Gi812d5m7RowW7GpLHEeGef5L2Ba3ltJG0ncNAXjzQFypaTUwr7hIeBuXHA5nxXZ6r6QdqoY+CCEyOA5udz+S9F47s9wudZBT0cJcGMAJG2feu04sttZXVUMNNEXBjQCemUPpG241WmWVOMuglB+B2KoPo43ctirqIu9l4eB5ELN667Z5dXW2ehFO1kUoxs3f8VgrVdbhYHPmpjJB3gwXYIBW/bOGa6XhiSz1uGPLstyc9x/Va9DYqqSwvttThri7Lfkf1XrDtC03Hq2wS0jsEkhzT4ELzRQVt17NdRcYjc3geTwO2DxyC7l2O6jmv9gc2ok45WkEkq6uOgGdoNbLb6GhZWyQnFRVP2hpcgH6xw5vwQRG31jlpPC08Q84tV6dwrUT2W4s7WAnBH3HmuLt9zdYJprZWN7SInBH3CobJ9IuyuoQaqN0MrR62R122Awsrrrt5m1DSPoraOBknqCBoPrg/fd/4W7c8lwOB0MfRQsVOW97UVFVIMcR2jaTz2A5Dy8uZ5nWaV7CtO2CZsrLdDLK07OkbkqyK7guhk9LgifI4ahp2z71cZPw1Sv9Ihjc524B2z71mPot9m9daK5+o7kHxzSsLY4iBw4I/TyU76T/AGbai7QLrbJLRC6eNnEyQGTha0HcZXdLTQso4mtYwRtHJrRgBTKuOOQYK5B/GFZ/GP4w1o5xoAdgMYA9yxze6s3H+JADm2A6ALz52Jdgo0bXMuFyb3le32Q1/E1pXpq3SCCJoyqCJsdORhOvujYxjiXM3a81V5qTVVbsuPwHgPBZtXNU3KY1FS7Lj8vJW10kZUROY4cTTzHisdBp2goKoywUdPC8niLmRgHPjnCnT3hp5uUCW5A9SscTuaC1p0KjbSuAwCtFBXd1GBnkFGqqpr/NZ91z8CUzJcT4lQlysspQN1ZymMnJAUT9qU0UrYzMwSHYNJGVi9XdpFs0vSvkqahhcB/VhwyV5409rm76z7SYqmnmlZSMk4mtJ2wPFdnZ+Gau6001Y89nFG0nmOxPcFv0VkdUxvmPqsaM5K9hm5gDYpp11ceqzMFzD2glwGfEo33SJvOQfDdcZglZXIwLQm5OPVJ/aJ8VmZb7CwZyceJ2UP8A2qhkdwxlrneHFlSNiedQEmWLZC4kcyli6eaxf7bkcPV4QsP2gdrL9GCMOiMjnnA4WZV+htlTcp201M3medgpKeF1XIIYRlxXcG3fHVJk1JBTgmSdrPeV5CuXb5qG4tf6FSPaznk9PksxQ6x1Zriv9FhrzG52Thp4R816RT/hvX9m6atmZExupJOcDxwunZwzPyGSoe1jW75Oy9sHtFtUdQyA1jDI84aM8yroagjZAZXSAMA4sk7YXjrTnZZcjc6etr7u4yRvD+EOLj/Jdg1ZcK8aPqoKDMtR3fA1vIkcly9ytFtgqIaegqu05jhxxgDXvPRYlTS0TZWRU03Pnc4wAqftN+k9LR3F9psEcklQCWmZpGM+S5vV637TagGtjfNxe11dgfFSeyvs9q7Vc56y7QsMh3jGQ7B811G5XW2WynPplbTwNxu17x+S72ouVrsMzbfaKRtQQBzPPrcx64wt+Wto7dIKahgbLjdx1yfBYnsv+kRdKi7RWm/uLnvJAmdzzjqu9OvIlpxI1wwRkFeK9d3G2jWMFZaZ2yxgjicwYGcr0npK8G66Tp3B2XmLgJ81T42slNDHTXSlh7ISj1m4xg+XRMv1HFGyGsiZyB41HcVwbXd2l172oCnmc400Uvd8BPs77/ou92i3U1ot8cQMVPG1oGSQ3K8walmqrXrqqlpyWTvkODnG5/8AJaalsOrdQtDpKmRsbh5/qu14iscdZR0THVTYYGMGh6nqcLau1AyeGnDphHEGjQ9Stl2xtsVzs7sVUL6yNwI4NyoP0c9USCSstU0nGOIPZxHkOSg0nYzNPh1bVOeeoLs/kt3ojs8otM1YmgB7zGCcYXNVlxstHYZbNHO6cnVpxo05G3gseaut1Pbn0DJDITqNNAfBdPr4o6mikjO7XtLT7iF5L0nUv0f2pFhPCIawtI8uL/ML1e6QmDC8s9r9EbN2kvqWDhbUcMoPn1/RU/w6kE01ZbH7TRn4j+xKZwu9skk9IdpGfT/yvY1tuYfG0g5GFZsuR8fmub6JvQuFhoagHPHE0/hhaZtXjqvIpoHQyuidu0kfBcS8dm4sO40WpZc8dcJFZXiWF7TuCMELOtrSOuUclblh3UHKoTgryVr5h0p2rxVY9UMqQSfLP+a9I03bDpiz22KSqr4mnhzguGfwXMe1nsuqtY3ttVTTx07NuJzwSfNU9m+j5bgQ64Vs9U7q1nqj5817vXV3Dl6t1HJc6hzZI24LWgkn37Bd9VVNnuFLTurZSHsbghoyf0Wh7Q/pJUd0t89vsEffTStLOMx5GDt1Vd9HTQddQ3w3yuhMJ/s9xnf9FsrB2V6dszmuprXGZB/aS+s5dCtNLHRhoaxrAOjRhc1W8S2+jt8lssUJY2T2nOxzEe5Y9ReKWGlfRWyMta/2nO3PwWvnc2ppsO32XIdbdjdi1JUPmkpmxTHbvGN/RdKbWYZglMSyNevPqKvqrdJ2tLIWO7wVzME8tK/tIHlp8FxG3/R709RTBz4X1O+4mdkH4LpumtMUNihbFR0sVPGOjG4VwWMaeiU2VrVfr73crmOWrnc8dxOnwUtTX1lbpUSlw8SrmmqBG0DknjX+aoTV45HZJNWsHCpK/wDT/NEa/wA1QelHxQ9M80uEmVfen/vIennxVEKweKHpWeqOVGVeenFD04qk9J80PSfNO5UmVd+nnxRGvPiqX0nzQNQfFLypvMrg13mk+nHxVQajPVEajHVGEZVua0nqkms81UGpRGpS4RlW5rPMpJrFTuqikGqPijCVXBrEl1aqV1SfFJNSfFJhOyrk123NJdXeapjUHxSe/PRLhOyrg13mUk1xPVVHfojP5pMJwKtjXeaQ6uPiqszHKHelNwnAqZJUl3VR3zZTJeUku80YTspbpCU05yIu8UgvTUuUHFIc5EXZSCd0J2UTnJBOEHHKST4oTw5JJTbilO5pDjumlSByae5MPKdeeqYeU0qdpTUhzuosp2KfeVHlKYQrLXKHO7msxqWodT0E8jW8RYxzuHxwMrTT9VRXWNvcl7/6th4ne4bn8EzlycK61/K3K6XeadtjststbHcTKGljpg773C0DJ8zhZ6B+6udXz4lyT0AWfikwV0bwNguVpHHkyVZsell6isfsll5x4qHkWoJE4X+aTxeab4kXF70nIndonC5EkcXvRcSXlS86WXZSDvyR5CSk5U4PSXc0QKBOUnJTS1PD1Z2+cse3fqsk2EQ6r1M9vsSVjHY8zBET+avzVxUFPLUzyCOCFpe955AAZKz9nZNLE+oqWllTVyuqJGO5s4j6rD5tbwt/urOkZh4C1KaXAce/T5gq8ouhRXWQOYGc+pS4iIm56BVN4rfRKOoqCOMsYXBvicZwoyNCrUcnrZVbQu723Ukn34WO+bQU8BhFSUvolHT0+eLuo2x58cDH6J3GFrN2wvJJCHSOcNiSkhqUgRhKUiYiATsQ4TlIAyrG0UZrKoAjLGblNTFe2GgLIwXD13bnyWrp4hGwYUOgpuBoON1YjYISFGljZJbzSkpSI2pSIckaAUxBBBBIhdRa8I+LzVW2uHilem+acm4KseJDIVd6b5pbasFCMKeDnZHwgqI2pB6p9koPVCRCSmDgq+poPJWwdkeKJzQ4IQsxNSFmdlEfGWnktTNTB3RV89vzkgJCgFVMFU6J3NaG1XotIBO/5qhqKNzM4CjsldG7njCYQpQcpnVWlzp98t3tEbn2l5MlXRRjLqYncyxj7vVzBy5jqFHt9ya5jJGPbJG8BzXsOQ4HkQeoWstV5LSATv8AmslqzTh03314tUZks7iZKyjjGTSk7uljH3Ormjlu4dQkzjdSj1t91oqKvBA3VtDOH+a5/b7lkMex4fG4BzXNOQQeRBWjiu/cUM8w3dFG54HjgZTcp7WkuwsZb6ikulXXVlUPSY6qpkmbG4kse3OIy5vIkMDBvnHCMLW0t6EbGtY0RsaMBo5ALl9nn7iCJgOzWho9wWigrSW8yswSdV6a6mbgN6BbuK+EEHiBCj3K10WoZPSIZP2dd2txFXxNHF5NeOUjP3Xe8YIBGVZXEciplNcix4PEl7ToVVdSYPM04KftN7mqKqqttxibS3mi4e/hacsex2eCaM9Y3YOOoIc07tKtmTEdVU6mtM+pqKmuVpcxmpLZxPpXPdwtqGHHeU8h+48Ab/ZcGO34cFNkvcF+tsNbTcbWvy10creF8T2ktfG8dHNcC0joQU5MAD25IwRuO4/oVoo6jKkMn89lUMkT8cvmmZULmK3ZP5qQyoweaqGSqQyVJlVXRq3ZUeaebODyVSyVOtl25oyq5jVqJM9UJ4YK6lmpaqGOoppmGOWGVocx7SMEEHmCOir2zkJ5lQl5lCY8LKUFFFoy5UtiuRfPp+qcIbVXyPJkpXn2aWRx5jpG52c44DvwcWlq9HkjNNUAj7so/UfyTtxt9Jf7VU2yuhbUUdSwxyRnqD1B6EcwRuCAQqjROpKykr6rS17n767UDGyQ1bhj0+mJwybH3wRwPA2DhkYD2hWmSaY/fkq00PbZeBqN/Ed6j1torLcC6eneGD+0b6zfmOXxUAuDhsea6nFLywVX1+mrdcwXPh7mU/2sPqu9/gfiCphJ3rMMeNlzlybc5aS56GrqUF9G9tbGPs+w8fM4Pz+CzMvHDK6KaN8UreccjS1w94O6kBDtlFgjdAkoCQgJBOUlxwlTk8JUoSKNxY6oB+ExCmCRKD/NQ+9CU2TzS5QpfeYVHqgd7aqlp6sIKsjJ5qBcx3sEjfEEJ8buV4d3JzTykFeEfQmUuuDSzD6v0wsIPgXbfmvaOmra2GggjwMNYG/JeR+1q2yWDX9S8MLeJzZ2nz/0F6r7OtRQ3+wUs8Tw4iNocM9cL3L8QHPrbfQV7Dlhbr5kD+69V4zLqujo6xurS3XzIC1EtCwx+yuB/SNsEZtkNYGAPYC0Ox8V6De8Fi4d9JW5QwacjpuICd7w5vu6rz/g90rb5TdlvzfLquN4bMjbtB2e+fksX2J1L7hYbjb3ElrmeqPMf5LAWGrfpDtHic/1RBV8LgfAn/NdH+jvbZDTVk7h6jj6jvwITHbR2czmqdeKCIuc5xfKGjcbc17DFc6ODiOutlQQI5xjPTmx/f4r0qOvpob7V0ExwyUY8M4/fvXpCx18VbRxTRODmOGQQVYTOLmFeVezTt1n0lTNt90ifNCw+q4bOG/Vba9/SVtsdG70NnHORsMEgLy2t4HvFPVmCGIvbnRw2IXBVXCdzhqDDHGXNzoRsQs99Jq5Rmoo6RhBkHtt8BzBV52BUbqXTPeyAsL3EYPUdCuZ2LTl+7a9XNmdGXQucOORuMNbnkvb/Z32PWLTtqp4H0rq58bQ0uqHZa7ycweqfkun4olhsdhp7DzB0ueZ2OnVbt/fHarRDZ+bMmcux0XkH6RNC0V0M4ID8AkAjPgq3st7YZNJUwoqyF8lIHEiRvTK9IfS20rTf7CsNHTRU8cIOI4WBjG9dgNlwn6OOnrVq+estdypY6gvjPAXDJaQc5HwW5aamhrODs3CMvZEcEDca7jyWvbpqWo4ZzWsL2xnXG48Qtpc+3mzQ0D3srKcTFvqMZxSOz5gABcPqHXftb1e1sUZmdI/ADBgNGfMr1DH9FXSvf8Aetp5JC45IkeSPgF0jRnZPZ9KhraG3wQn7wjGfmucpeJeHeHmPltELnTOGAX9FjU96stma6S2xOdKRgF3RVfZj2J2qw6fpaaodUzPawcTXPDQD4eqAfxXmD6VlgbpzX8cVNxx0c8Ac1jnuduDg7kle/qSibBDjGMBeQ/praekfLarhFE55bIY3cIycEZ/NY/AVyc/iQSVByZebOe86/VUuEqs/wAaD5jkvznzOv1XP+zf6Np1xY6O6y3kQwVLeIRwx5c3yOdl1q0fRG0rAxpqH11XJ94yBg+WCrP6IT5KvQnotTE5j6adzRxjHqncL0hBbI2sHqhLxRxXfYLnUUYqi1rXEDlwNOmoGdvFOvl9u0ddNTichrXEDGBp01Guy4JR/Ro0zRtHotPLE7xPA782rmvb/wBj40/pVtZTzcTGOILO5Ax8Qf0Xs4UbGjZq532uWWnv1m/Y72NdLUnI4hkMa3m8+7IwOpIHLJHH2u+1FNcoa2plc7ldk5JOnXdc9b66eOviqZXl3KcnJJXkP6NFufqS6vtZrn0VM8EzyRDEvAN+FhOwJ5Zwccxg4K9rW2gt9mtMNuttNHR0EAIjhjGAMkkk+JJJJJ3JJJJJK49ofs4s+hqrvKIO4x9o7EldEbdi5mBsFNxVd6a7XSSspAQ12N+9bd3kjuVc6phaQ13f9VaTxxk8mqMXxxHkAqGTVNLLUvp4JJLhVs9qmoY3VErfe1gJaPM4Cm09n1LdBmG1x2+M/wBpcqgNcR4hkfGfg4tXGczneyswwsi9sgeamvuYiHqn5KFPei3J4gPeVN/2BDW8V21E8DnwUELIGnyJf3jj7wWpLrfoe1DL7cLpIN/6dI6qGfECUuDfgAjsnncgJO2i/IC7yH6rMyavpppzTwVLKmo/3FN9bL/gbk/gpNPBqC5DipNPXWcfvxNpj8pnMWgm7TW0dP3FvooKaEey0NAaPcBhUFw7RrpUZzVujHhGA1L2bBu7KlDp3H1GAeZz9MKQNGaslbxuo7dRs6irrncY+DI3D/iUOq05dqY5kvdmYf8AdtjkefnxD8lmq7WzHyFs9fxuPR8uSo5vzJT6rw73FOMXKMlqsCGo9p5+A/Vb236HvVdSNmDqQtdyd3jm8Q8QOEri/b5rWt7O+G1QmGS4zDAbGXO4QRt4fkvS+mtQx1ujqaqiIJig4C0dHNbg/ln4rxe2opdcdtd2ud4mZJbKB7nDvMeo0cuZ8crveD7XS1VRLWVjeaOBvMR/Ueg+K0LGDLPLNUjLIhnHeegWGs2gbprGp9Nu8k0TXnO53PzXXdJaQpNORNZStcD1c45JWG1l20suF7qG2S3lkTfUYG7ZA26eKoqfth1BbZWvqqUNp8+yW4J+JXoN0tfFPEUeH8sUf5Y+YDTpp1Pmupq6S83Vnr4Y07MyB8l6Kgfhgz0UDUOooNP2yWrncGtY0nfqs7ortBo9WUfFG4RzNwHRnxx0WF7e71I2mpaJjiGSHJIPXwXmto4enqr1HaqtpYc+t5DU/JcrRW2WevbRTDlOdfJUVz1/qDXNxfFbonQwA4BjyRhRavT2rqGM1DauXhbvwh25+C23ZbZY6axQua0CSTd58St262N7o7ZyF29fxbHaKx1FbaZgijPLqMl2Nzla9VfhQ1Dqejhb2bDjUZJwuZdnna7VCsbbbwdznEh2x4BdPu9kor82OWop2VOAHNLxlcK7WdOi03QV1O0xB4Hs7brrvZrf/wBtacpHv9Z4jDSfdsq3E1FTOo4OIbSOzEmjgNOV3hj3qO708LqeK60Q5A/QgdCpE2noYqWSKOGOJrmlvqtA2K4JpWR1g10IX+qI6gsI8s/+S9Pzt4oz6q819o9I6zdoMszRwiUtmBHirH4fzmrfW22U57WMnXvH9ipeF3ds6po3nPaM+Y/8r0dQQtDQQrB/CIyCNsKi0vcPTrTSTA5442n8Fa1chEL+E7gHC8hkjMchjduDj4LiCzkcWHcaLkXaP2j1FLcv2RaGtfO44LgDn4KutfZTPfA2pvNdNxuGTG0Y/NY+8TizdoVRNUg8Al4xnpld4tOorXNRNn9KjLcZO/Je4XZ9VwzQUsdlZjtGgukAyST0zg4Xode+ez00DLc3HO3JcBkk+fRch7StAUOmbTHPQxvaWvAc57uInK6N2K3j0zTncuOXMxssJ2ra0i1C8Wy2tMrW5c9wwQQEnsM1C2jvDqCR3D3rTgHxG60a+huNw4PL7hl0zDz66u5fH5+5Wqmmq6qwl1VkyNPNrvjxS+2fTU9tvEN0p2EsLiSR06rWdmvaBb7pb4qetnbBUt29c7Fb292iG8Ub4p2B7HAjBC5BeexfFS+S31DoC47A7Bq5aivFqvlrjtd6eY3xey8DOncViQXChuNGyiuLuVzPZdv8V1u66os1kozPPWwbDIZ3gyuZ6e1/edVa4/oJLbc31cOJLMA81UUPYu6WYOra2Sbx4evxK6lpPSVLp6AR0sZaOpJySqcr+HrHTStpH+kzPGAS3DW56gHqq75LTbYntpz20jhjJGAP7rdseHxc+a4520aErtT1lvnt0THSx5Y8udgAc8rrcLeFuEiembLzG64a0XSey1ja2mxzNzvtqMarnqKumt87amHHMM77ajCzfZtbauyafp6Osc10sefYOwC2zZdgq6mgEWwHyUzi254VCqqH1c76iT2nEk42yVWlldPI6V+7jkp8Soy/I5qPxDxQ4lVwoEJY2yc2gpUULGH2UXH5oxIPFGqbgqZEWt5bKQ2oDeRVZ3qHeeaZhGVZ+lfvIjUnxVd3vmERlPLKTCRTzU+aQalQu8RF6MJimGoSTUKIXpPGlwhTO/J6oekKHx4Q7wp2EmVM9IShUH3KFxo+82S4TMqd3/mld95qB3pRiRKkU/v/ADQ789FC70od6hOAUzvneKLvvNQ++QMyYnAKWZknvSone5Q7xCdhSTIkl58VH48ouIoS4T5k28UXeZTPEUOLCE7Cd40XeY5pouyUkHCTKXCeMgPRDjGEyXIuNJlOwn+MIuMJrjSTJhCUJ/vAkmRMmRJL03KdhOl/mkGQBNl4SDIEiXCdMgSS8povRcWUJQE4XInck3x+aSXITwEpxwE29yIvTUjxhMUgCS93NR5Hc0qSVRnyIU7Qie7dR5Hc0p78ph7uabhTtTMpzlQqiFs8bo3jLHggjxClPcmHJcKw12FPvFzdUWy2yyP45HYZK7xeOf45KYikyVSXltRJSA0/rujeJe6zjjwMbZ5HHwPI45ifRVTKqnZMw5Dh12IPUEdCOWFsRS9rvusZ8PYjA2yVeQv9VOcWygwVAxhP96D1wrGEwFPoicJgzDxSTOPFGE8EqQZAkmRRjKSU3NUx00LpppWQxN9qSRwa0e8nkmYTwVM7zPVAuWdGtLZPtQma7O6GgiMkZ/8Ai/1Y+LgjNzu9WPUp6a3s6OmeZpPi1uGj4OKidIxvVSAFaHJUOuvFFbCG1NSxkh3bEPWkd7mDJPwCpX0L6gH0uuqqrP2e87pvuwzhyP4spdPS09Ewtp4I6dp3IjYG5PnhVnTH8oUoHehUVk98lj7yF1Lb43B4hkxxzOBy1zh0aDuBzJwTjGFYxTBpz1ULiQEoHVVtSclWA8gYCtXVQLMKmrJP2hcoKVpyyEiaUjy3aPnw/DKRX3L0ODIBfI4hkbBuXOPIAKTbaB1BTHvTx1Ux45nc9/D3D+Z6pWt53hvQbqCsqvRqdzifWdo37n4J9wyUnhS+FAjC0Fwg0SAMowN0aMDKcmot9gBknkAtrp61ei07eIesd3HzVFpq1mtqRO4fVMPq+ZW5hjDGgDokKCnoxjCcHNIb+SdaEqalDkjG6CNqTomJSCCInCRCNEeSLiRE5QhX7a7zSvT/ADWeFZsj9NTOZWA1aAV/mlNuGOqzvpnmi9M8/wAU3mRyrVR3PHVSorqPFYv08jqh+1C3qjnTSxdAiuzfFSGXNh6rnbbwR1TrL44dfxR2iYY10L01jhzCS+oaOqxEd+IPtKUy+cY3dsl5wUzkwtJJPDL6rvmq+toTgvj3Hkqt92hjAdJMyMHq5wCmUt4ixtOx7fI5CdlAB6KK2R0bvDCurXeHMcATv+aizMpK5vFHK2OQ+OwKgvgkgd6w2+8OSTIKfg9QqHVNnj0TK66Uo4dMTPzUxjlbZCf6weEDjz/3ZOfYJ4LOlPquikzwuHC4eSuaSv4WujlaJYngtex4yHNOxBHXZY6OgOirtBaeIusNZn9kTuOe5cAS6kcT4AF0ZPNoc07x5e0jRWWOydd1iqJ7qciJx9dnquz4jYq7p59huqrUdObZqSri5NlPpDPEh5JJ/wAfH8k7TT8t1iEYOF6pFIJomyDqAVeslJHNOMmIVfFLkJzvMpCnrRWq7OpZWkOwmr7HFpy6P1JTkNs9eWtu0Q9mCXAayq8hgNZIeWAx54Qx5NPFMQQry13JhY6GdjZqeVpZJE8BzXNOxBB2I8insfjQqpNDr2jff4hXBy0+HknWPWcs7jp+uZYZpHy0xYZLZUyOLjJCOcLnHcyR7DfdzOE5c4SEXrXbqYqkQprJE/HKq9r08yTkmKFwVlHJ5p5r1XMkUhkqblQOapgelCRRRIj7z3pFHhWEFTwuG6zXaza6t9gp9VWZjpL7pxzquOKM71VPj6+nPjxsGRsTxsZjdWol35q2s9eGSBjj7Sew64PVQuzCRK0ZI6d46g+BGhR6O1NS6oslHcqOUTU1TE2aJ/i1wyNunuWjbLkYXB+ycnQXaBqbQR+ro6Wf0+1N6CmmPHwN8mOc5v8AdK7bFKFYBJGu6rV9MIZPU9lwBHkRkfvvVi16YuFto7vCIq2nZO0ci7ZzfHDhuPgUbX8k4H7Iz3LJLVh7x2e1NPmW2S+lM5+jzENf/ddsD7jjAHMrJScUMz4ZWPimZs6ORpa5vhkHcZ6eK7Q16h3eyUN9ibHWwCQtzwSDZ7D+64bjptyON8qdspGjlCW4XISUkuWhv2hLhaQ6Wj4rlSDfDG/XNHm0e103bvk+yAMrLsnbIAQQQeoVgEO2Tdk7xId4my5JLtkYQn+9TU54mlN8SPiyMJqFxnts7OzqejdV0rM1kYAHmMrj+ge0q6dmVdJTTxSSU5d68LtjtttleuK2lEzSCAVgdS9m9rvbnOqKVpedi9ow7HvXp1h4rgp6I2q7RdrAdu8eX70XcWniGKnpTbrjH2kJ27wsvVfSeoBSfV07u+I9kDIHxXJbtdb12u6ga5w4o+LYYwGhdYj7IrBRVsUEdG6erlBMVNG0yzSY5lrQCSB1OMDmcBdi0P2D1b2RvrmMslLj/q0DWvqD/E/drPAhvHkHZzStePiWwWMOls1MTKRo5/T6/VaDL9Z7UC+1wEyHYu6LH9nmmI9PW2lt8LDJUPBIiiaXySEc+FoyXY57BdQh7JLreqcPrWR22BwyWzDvJSP4WnABHUuyOrV1LS+kLbpan7u30bIC4APkyXSPxy43uJc7HTiJwr924wvIamtlqZnVEhy5xyT4rzuWWSokdM85cTkleZdQfRX0vXOcTFM2VxPHNkcb/gAAPgFXWr6Kul6CZrjSGoa05xOS9en5qJkh5BNi3MafZWvHxPeIouxbUvDe7K1mXm5xx9k2ocG+awOk+z63WCFkVFQw0zB/u2ALfUVGIYwAOifZTtjTvFjwXNyzPmcXyEknqVlOc57i55yT3rlfbzaBdtB3GPh4i1vEvGn0bbkLH2pU9M8lrHTGJ2fA5H6L39qu1i72qppH+zKwt2XnzTP0aLfYtVm795I6YS94Mv2BznkvTeGb/RUVnrLfWkjtB6uBnXC7iy3WmpbdU0dST640064XouiomPjB4QVOjpWsUe3BzYmgqZwrytcRyoyBw4wsdrDRlBqiIR11O2oY1wcA7xC2HEm3xsI3Ukcj4nB8ZwR1Ce1zmHmacFZTS2lKPT0ZjoqZlMwnJDBzWtYcNCQI2xpTXZKY+R0ji55yT3pxLnHmcclRrxc4rJbZq6oJDIxnA5ucThrR5kkAeZXFtV67oLKyS4Xq4wUUlU8Ny92S8/ZijbzdjOzWjJyTjJOZHblryqp73bdO2al/ad5qDwUlvDuES1BbnLz9mONmXucdsOHXCc0X2fWXs1qP21eJ26l1vKz6+71LQRTg5+qpmHaGMZOzfWdnLidsRhpedNgugpYmUsIlkGXv2A3x9h4qFYbJq3V4bNQ2f9gW88q6/hzJXDxZSj1//rjo1tKXs4sVuYH3u4VF/mHtMqHhlPnwELMNI8n8fvVdc9fVNa4gP4WdANlRVF6ll3c8k+akHZt6Z81KY6mf2jyjuH67roLtT2+zUraa3U0NJTs9iOFgYxvuaNgszd9eTlpPetiZ45wFwLtc7Wq/RdyggiiL45W8QdnA54K55fO0y/8AaE6CitDXRxhn1zg0bH3rvrfwjca+COsc5rIHZPOToAO9dBR8NPexs78Bh6k7L0TX6+op5jG+5Me/ljjTX7VjqWl0UjXt8WnIXl2v7Nr+ITM6tcXgZLOPc/JFoXtBuWl7vHQV8j30xfwEP+yPJbcnBFNV0sk1nrRM9gyW419y3BY4JInPopQ8t3C9MVdybTxOe5+A0ZK4NrrtYuN4ub7ZZWBzAeHvG5yV0i8VT73YJhSShr5o/Uf4Fc10toN2n7hLV1c7ZXuG+2AD4rH4ZdarfHPW3AB8zNGRkHU958lXt7qSla+acZePZb3lZ9+k9R1cZmdWPjkIyQXYTWl9a3jSd5ho6yV74C/Dg88xyyt/dNY2S0tIlqg94+zGMlcl1nf6O93GKejiezg5l3XdeqcPVFy4jL6S6UQ9HeDh3Jy8pxpgrpLbLV3EmKrhHZkb4xhevuzXXvotNU05eTT1UZkYD0eBv8x/yryTquSootaXqlppHMiqpy14H2mk5x+K6loC8uls9I/iy6N4b7gdj+BK5rraA23WomeCQ6TJJ9/+axOAmfw66V1vIycHAPUtOQsuwsbTVtRDjUj6bLqOkdK09tt0LWQsdIWgl5aMlTr5paC6Uj45ow7PJ2NwrXTMrJ7fA9pyOFW1RGCxeSVNwrPTXVL5D2mSc51zlcBLNOZzM5x587rzhZKuo0VrGOLiLYu/4XDoRnC1XbPEamKnqBu3AO3Tos92mxAaz4YsesWuBHiui3ixf7Q6VbG4YlEO3vwvdLlcoqartF9m0c9uH+WmvzK9DrKtsM9DcpNC4Yd8tVL7J7kys0/TjYva3DguhjBYvNmjdT1Gg7w6nrGkQcnNPTzXYB2n2FtH3r65keRs1x3PwXn3FXDNbFcnzUkZkilPM0tGd9caLmbxZ546t0kDC5jzkEa7rN9uDWMs8b9uLi4T8U52ISSR2FzX5wHktPiCsNrfU8uv7vFTUDC+BpwCAd/eusaDsws1qhgA3AycravDDZuFYbXVaTPdzcvVo8Vdr2m32WOim/xHO5sdQFtXHiZzXDu3i3cFRb65rfGMn8V20exyWV1vpWDVVA2mnc5gDw8OZz9y4bha6x2a7Q1kp9QZDvIggrnrPWtt9dHUP9kb+RGFA7JLoKzTMDScuiJZjy6Ley+sz4LIaM0zT6YpzBTcfC45Jec5K1zTluCs28z09VcJp6XPI5xIzoddVTrZYp6mSSH2SSRnxXMu0Ds7h1DMahn1VRsOIDnhYSLsqupd3clZwQ/daSV6CmpxINwCo4tzOLOF0Nu40u9spxSwyAtG2QDjyytKlv8AcKKIQxP9UbZGceS5/pTs6pbHCdjPI8Yc57QtLYdGW+01Amp6KKOTOeMN3Wlhpms5D5qWyMLnay819bI+SeZxL99cA+4aLHnrKqpe58shJdvrv7k5EzLAOeybko2v6J5mQlhyxclUsKKygY3HqqTFCGctkriwhxe9JlGAnWuI6ocXmmeMocZTkqkNefBDjymBJ5I+NCanuLZDiTPefNDjJQhPcSHEmuJDiQhPNeEOPKZ4kOLZMTcJ3iQ4yE1xEdUZdshInOMnqhxJvi2We1rf5dPWaSriYZHN2wFZpqd9VM2CP2nHAUsUTppGxs3Oi0hdtzRceOu65n2Xdo8+sPS2VLBG+J44RnJIK3lwrG0lHLM5wa1jSSTyCvXG11NrrHUNQMPGPHfZT1dFNRTmmlHrD7qHdtaWyzzCKoqWskJxgkK1oq2Oup2TREFjxkELyFrG+SXrUtXWEn+tPD4DB/yXofsuvP7R03ACclmy73iTg8WK2QVgcS52OYdASNl0l44fFrooqjmJc7fwW+R8SYD8gbpXEvLlxeE6HI8+aZ4kecJClATvER1ygZEzxIcSanhqd490WSmuLwQ4z4pMp/KnuJDiKYMnmi7zz/BIl5VIzuhxDxUYyeaHeIyjlUjvG+KLiHio5kRGRCMKSXDxSS7zUfjQ4x4oSqRx480ONRu9A6ojMPFCFIMqLjUYzDxSTN5pifhSu98kkyH3KKZx4pBmHihLhSy9J4wohqAkGpAQngKYZUkzFQXVQ8U26rHimJwap5mSHVGOqr3VY8U06qyhSBqnvqfNMPqPNQnVBTZlJQpAFLfOmXSpgyFIMiFKAnXyZTD3onPTbnp2FIEHPTLnI3OTLnpcJ2UTzhQZ4pWSmamk7qb7QcMsk/iH6jf3jZSnuymXFSNy05CY7DhgpP8AtHR0rf8ApCVtscObqh4bEfdIcNPuOD5BV1V2n6So5RE7U9tmmPKGmqWzyH+4wl34KxJBBBAIPMFIpoYaRhbBDHC08wxoCuCc41CqGEdCqwdoprNrVp6+XMnlI+l9Dj+dQYzj3AoPues64nuKGzWaM8nVNRJVyD3sa2Mf8ZVx3pHVF3oPvTTM4oEI6lVA0/eqwD9pasrnDrFbYIqWM/HhdIPg9SaTRljppWTPoW11S3dtRcJHVUrT4h8hcR8FPEyHpGFA5xdupA0DZTuPbA5eARF4CgGqHikPqx4qNPwpxlHwTbph4qvdWA9VQXnXlnsjgyqr4xOTwiCI95IT4cI3+aTIG6e1jjoAtW6fbwUWvutPbaSSpqZmwwRjLnvOAFnKaXV2pf8A1XYxaKZ3KsvZMZPuhb63uzgFW1t7JaMV1PcdQXKq1HcKd4kibMe6ponA5Dmwt2zy9onknBrnbBVpaqCn9t2T3DX59FfWW1zB4uNfGYqpwxDTu507T4/vnr4cvFWcgycp57i4kk5J5ppw5K4xgYMBcnUTvqJOd/8AYDuCbxsiISyfJEpAq6SnaGgkulWKeLlze77oSGRS1E8dPA3jqJOQ6AdSfJbyyWeO00rY2+tId3vPNxSppOFJoKKOhgbFGMNaMKYxuETWp1rU1MQYE60ImhKQmlBGDgIkE5IgggklyahKRE7JJPmiJCEKu77HVDv/ADUIzY80gz56qAq6p/pPmiNR5qv7/PvRd+UiFPNQmzPvzULvSiEueqaUKYZyEPSuEEl2ABkkqFLMI2Oc4hrWjJJOwC3FmslFpOGG4XmBtXeHASU9ulHqUw5tfKOr+vCeW3UByYe8qeKGSd4ZGMlN2DR1yvFMKyYttltO4q6vbjHixnN3jk4BByCVettdgoCABU3GQfblkLGfBrcZHk7Kx+p+02SrvMdEBVXu9zDiitlAzvJQ37xGQ2Nni55aPNT7doDVuomiW+XSLTVI7/2G1Fs1RjwfM9vC0j9xp/iUBlJOIxldQ20w0rQ6qeAT+9t/foFoZb5bLMzvTDb7Yw/2nAyPPx2UJnarbXv7ulqZK5/LhpIXSZ+IGFZWvsu0rZ396LY2vqT7VTcXGpkcfHMhOD7sLURlkMYjijbGwcmsGAPgkw87nHzSOdSN0Ywu88D5arIM7RKpw2sV3kb4mmc1CTtDo2NJrbPcadvV0lOcfNbAvPggH4/8kuH/ANXyUH+rneL5lZCm1Jpi8uxTXOGCUnHBMe738N8KRedPx3K1VFsuEbpaCoA9eJ3C5jgQ5kjHD2XtcGua4bgtBG4VpddOWm9NIrbbTVJP23xji+DuYWZk0DXWTMmlr5NbAP8A731oNTSP/d4SeJmfFrk9sj2bjI/f73UD6OnlGYyWnx1Hx3+S51rFtYKdkdyw+72pzYppo2hraqnecR1DWjlkt3bya4SgZDQ51ZRVIIG60+rdVQFkFu1rbWaUujS+Kkur5O8tVYHjD4TPgGISBuSx4aQWsILiADhGR1Flu1Zaa5rmVdG/hPGMF7DuyTbbDm4O2wOR0UM7AQJGbbHwPit+1vcwGnlGCNR3EdcHwWqgm2UgSBVNNNkDdTmSbKplbZapjX7qVBKWkFV7HbqTE5NKbhXUsEd8oBSyyugkY8TU1S0ZdBKPZePxBHJzS5pyHEGdaLk+uhkjqIxBX07u7qIQchrse009WOGC0+BwQHAtFNSylrgQVZSwuqHR19MM10LeBzAcd/FnJYc7ZG5aTyORkBzsysd0Kzpmcuqtg7Cda9Q6epZVQsljdljhsSCD4EEHcEHYg7gjBT7XZ96kKpFSWyYTzZVDDkoPTEzCnCVH32FB70jqkunx1SZScqnmfHVKjre6cCDuqh9Vjqok9fw9UiXsw4YVX2wu/wBm+0LQOtohwxGYWitf07uY/VuPgGkyc9suHiuzRSeqN+ayU+l6XtH0RU2mt/qKqkfBxjcxu4sseP3mua1w82hK7Pr/AFF80vSSVvC26U/FSV0Y+xUROMcox4cTSR5EHqrZBHrf1a/r9lRmeJoGs/NGSD5E5HwOR8Fto5U+2RVLJ8dVJjnz1SLLcxWIflOByhMlTzZM9UuVXLVLY9UGo9EUGoS6dh9Crz/7TG3Id/G3YO9+x2AzjZXLXZTgcngkahQFq4lebTXaeqxBXw93xE93K08Uco/dd489jg7ZxjBMPjyF3WrpKe40klLVwsqKeQYdHIMg/wCecHPQrmWp+zmrtHHU2jjr6LmabnNEPL74/wCLl7RyVZbIDoVER3LKOkwkibdV89xiicGvkDHl3CGE4cXfdA6ny5rQWDQGoNSlrzEbJQO39IrIz3zx+5DsR738ODg8LgpcgbpA0qpqrhBSCMTPPHK7gjiY0vkld91jBlzneTQStHZOyy96kDZbi52nbe4f1Y4ZK2QfiyLod+MkEgtYV0fSmg7No7ilo4HTV8jeGW41R7yokHhxY9Vud+Bga0HcNC0TpN1CX9yXGVntO6Fs2lIHx2uhZA6TBmncTJNMRyMkjiXPx04icDYYCu2QtZ0ARGfiOAfelg5UZOU7kxul+5ESEjiSXPTUuEsuSC4Jt0uE06ZMynhqfLkRKjGbPVJMqTKeGJ6VokGFEFEOPixunDKqjUOr7dpem7+4TNhjxnLiApI2PlcGRjJPQKVkTpHBrBklXkbeAbFKL/is/pjWVu1bQNrLdO2eAkjiac7hW003Cw77okjfC8xyDBG4KV8To3FjxghSDLw8yB70fGV467XO2jU2lu1emtzJ2RW2RzeYJJzsfxwvUemb6LxYqOq4wTJECT543XQXSw1NqpaerlILZhkY+616y0y0MMU7yCJBkYTmr9aWvRVrkrrpVx0sLATmQ4yvN+pfpjzSVMkVgoPSIm/2jWEg/PZZP6T96v2r9eRWCkgqn0MDg2RsbXFh3559y1VR2cWfs97Ib1Xto4/TIbdI/v3Ak8ZYQ07/ALxC7KmttmsFthr7owzSzatYCMAd5XRwUVvttLDPWN7SSTZoOgHiuY6M+kfPbtdXbUd2pDPW3ICFlS7nDCD7DfDOG8R68DfBdqodbwaqo462nmEkco48l3Vca7SNB0Vv0JbmmOOGtpKRrS44Bc4NHEficn4qp7CtQPaH0T35aAeEE8uqu3S1Wq7WJ14tUJidGcObnIx3ropqWir6M19Kzkc3QjwC9BioJ6oOqDwlVsNRxNynBOCOa8aXPLkf0haH0q00lWNzE8tJ8jyVN2JMhltNQWtb37JMOONyDuFvO1Kj/aelK6PGXNbxtHmFyfsVuXot7q6Nx2lZkDzBXt1ulfcOBqmnadYXZ92QfufgushzUWSSIHVhz7t/1XaZ6JrmLi/a7YRQ1FNWxN4ckh2PHmu4d4CwLmnbJ3brBgnD+MOafzXI8EVktLfafkOjjynyIx8t1mWdxgroy3qcH3qd2YXk3LS8IecviJYc+CyfaPq6olun7KoJDEc8Ly09fBSeyBzm2ycDPA934hZPW7JbVq51W5uQ/D8+K9EtVrpDxdWxlocW8zmNO3Nv8tVuUtPCbtMwgEjJaPFaiz9nlKY2y17TUzuGSHOyFG11pymo7I91PTsh4MO9Ub7K7tHaDaTQMfNKI3taAQ7bfCyWrdUyatlFHb4+KEc3NB3VO2R8SVV5ZUV7nMjidlxdkMAHcNlUpmXOWsbLUEta05OdGgD5Kw7NbkRbamLPrMYS0eauO1XSz7jTR1tM0mRhy7A6YWF0LPPQ3psDopCx5LHENOAu800LK60Uz3biSFjvmAVU4mnl4c4n/iNKQQ7DvAg6EKjeZX2u6iqh66+feuYdnPaVHaYPQbiSACS13gtlee1qx0VK/uasTTY2YwE4Pmqm+9m1BcZnPDO5eebmBQaPsrt1PIC5jpv4znKjqqrg+4z+nzCRjzqWNxgnz7lDLU2Opk9IkD2uOpaMYz5rJWaiqdaaoNfNGRCZOLONh7l3ahpMU7W4wAFW2awQW+NrIYWxNHRoWhhj4BjK5HiW/m9zs7JnJFGOVje4fqsO6XE3KRpa3lY0YaO4LGam0PQ3pxdND6/PiGxWTZ2Q0TZOJ8kjxnPDyAXYHxtJTfozM5wFVouJrtb4uwpqhzW92fp3e5QQXOvpWdnDMQ3uWP0/oqhtBHcUzGu+/jdbOjhbC0BGyNjU6HtHVYdVWT1shlqHlzj1Jys2R8k7zJK4uPeU8HYKS9rXJHeBF3oVTKjwlMha08k9xDxTHeBDvQEZRhP5+KAco5mSTUAcykykwVMEmUsSKqlujIgcesfJQKi5TTbZ4G+ATSUchK0E11gpQeJ4LvAblV02pXE4ijAHi5Ujj8UHck3KeIwrJ1/qnH2mj3BLZqCoHMNIVTgoZGfBJkpeRvcr9mowQA5hB8k8y/Qu9pxHvWa5A7og7bmjmISdm0rXx3KGXk8H4p4Tg/aWHknELC55w0cyolFq6nnqu4gqcyeAcrUUM8zXPjYSG7kDZOFK94LmNyAujCbPmjEnisXX6jqaGhmmbh7mNzghZLRvaxU3e/TUdVHwRgervk81r0Nnq7hSTVkABZEMu11+CsQWyeohknjHqs3XY+PKrLzqaisMYfVyiMHlk4Sqa5RVDcteM+BXMu3KiNVZRMNzGQ7+aksNDBc7lDR1Di1rzjISW2ljq6uOCY4DjhdStV5p7vSieneHxnqN1he1PX9bpLgFNHxcY5k4Cq+xW8uqLKacuyWAfySu2ugNXZGTAZLchdVQWumt/FAt1W3mjDuXX5LXpaSGlvIpJ28zebGvyW40PqU6isNLWPwHyMBIC0gfledOzrtOp9K2X0aoY6R7HHhAONldVfbpWzE+iUGGDqGk/mrNy4HujrjOylhxEHHBJAGOimq+HK01cjYY8MycEnAwu48XyWc1nSen2CsixnLCR8FznT3bu2etbBcafuGE44+vxXUXVMV0oBJG4PjlZkEeBC5aus1x4dqI31kfLqCDuDjxCw6q3VdplY6duNcg9FwHsprzadaVFNnhEoIwfI5XUe1fUX7J0rK1jh3sw4QD1HVcdr86d7QoZPYDZsH3Zx+qt+0y8u1Fe6O3RO42MI4gOh5Z+S9quNpZdb/RXAj+W6MPcf8AJ+wvQquhbXXWmqz7BYHH/h/YVDDppz9Hz1z2kyOPEM8xhdB7C7rxU0lMTy5D3K6k082PSZpQ3OIsZxz2XO+ySuNr1PJTOJA4+E5+SozXE8TWS5A6lj+ZvlsPoqb6s3q21mdS13MPL9hek4zlqcyOir31baWkfM/2WNLj7gs7p7tItmo7kaSlkD3b7jkvCoaCpqYnzwxksZ7RGw8153FSzTRuljaS1u57lsuJEXpsSeaSZAFnEqsAneMpJf4ph0+AmXz+aYVIApZlASDMoL6kDqmH1fmm5UgCsjOkGpwqs1XmkmqSJ4arQ1XnhINWPFVbqpINTlCXlVqazzSTWnoqr0gnqh3zvFCOUKyNY7yRGud4hVvfbc0Rm80JwaFZGtd4hJNa7xVaZ0gznxQl5QrM1zh1Tbq0+KrjUHxSDOUI5QrE1rupSDXHxVc+YlJdKf8AzQlwrB1Y49Ug1ZPVQDKfFDjJQnYU01J8UXfkqHxouM+KEuFM77zRd75hRO8wj7xCdhSu8OUXHjmo3e56ojKhKpRePFJL1GMuOqT3nmhPUkvCbc4JkyBJMmeqcAnJb3Z8ky526BflNucSnBJlE526bJyjcU25wA3IHvSoygXnKS6TdMyVcTAcuGfJVVw1LQ21vFUVMNO370sgaD80JVbmXKQ6fhHPA81kqXXMd7ldFZKC436Vpw5tspHShp8zy/FX9DovtCvoBi09S2dh5SXasGSP4I+Ij3FKATsFC+VjPbcApL60D7XyUOpu8dPG575GsY3m57gAPer6k7Ab/XEG8awFNGfagtFIGEe6R5cf+FXdv+jloqjmbPXUtZf6hvKW7Vb5v+AEMP8AhTuzcVUdXwM6k+S5NN2i2x1UKSlndcqw+zTW+M1EjvIBuVZUdp17qIj9n6bbaYHcqm+S91j3xNy8fJd+ttkttgpu4tlvpbdB/u6WFsbfk0BKmOU4Q95VN92P/tNHv1/RcXpuwuuuI4tT6rq6ph50dqaKaL+EuOS4fIrW6f0Lp3RseLNaaejeBgz8PHMR4GR2XEeWVrKjllV0x3UzY2t1AWZNWTzjD3ad2w+AUaRxJTJOE69NkKVUsJtyQRhOOGAkkYRhCQkEvdIyKJhlqJDwsjHU/wAvNOtY+R7WRsMkrzhrBzJW005pplpYZ5sSVsg9Z/Ro+6PJCQnCTp3TrLPAXSHvauXeWX9B5BXTGeSd7v5JbWAJqizlIa1LDUrhwQjxgoSokoDG6HIonFCYiO5RE4QJwkFyEIyUkuSS5ILk5LhL4kRemy9J40JcLPGREZE0XbIuJV1ZTpkRF5KaLsocSTCcl8ZQ402CcouLKaUJ4V5oKijqQ1r+6qoXFrxkEd43OfgrCmbe+0a8T0lsnNNAx/8AT71I0PEGRnu4mnZ8pBB39VgIc7OWsdWUtpl1NcKezwvdCag95PUNxmCFpHG8Z24t2taN93gkFrXLsVGKGxW6C3W2BtLQ07OFkTM7dSSTuSSSS45JJJJJJVR45jjouttU5pqdxY3L3HQ9w+/gndIaSsugbe+ktFMGPldx1FVK7vJ6mTq+WQ7vdueewzgADAV06qLnblUIr+I808yrB6pAQNAldG5zi55yTuSrbvcoxJnzUBlRnqn2S5Ccoy3ClByPiwmWuz1S855ITUsuyi4knIQByhJhR7pa6K/W+eguNLDXUU7CyWCoYHse3wIOxXnjtC7F7z2fCC66SfU3vT9GCHWKVxlqaSA820zzu+MbEQuyRg8By4td6OJ8EsHCa4ZVmCd9O4ObqO79/VeZbLdqe6UEFZSTNnppmh7JGHIIVvHUea0naL2Yfsiqq9RafgPc1DjNcrdE3m7rURN+91e0e17Q9bIfhoK1krGvY8PY4Atc05BCoOBYcFdlA+Opj54/eO5aGGXKmxPzhUEFVy3VlT1AyN03KRzCFdQu5K2oZyxw3VDTzAqyppOScFQlbkYVsWdzO6aIepJvKwePLiHn4+IHlgy2u9ygwy7c0+JcDmpgVmOapPEiMg8VHM+OqafUAdUmUzCkvmx1UeWqA6qHNVgdVX1FbjqkTg1TZ67Gd1W1Ndz3UCorvNV81U+Q8DA58jiGta0ZJJ6BMJVljOq9B9l0J/2SpZnf2jnke7iI/RZ+9Ux0j2mvcz1bdqaPvQPssrYWBrx75IQ13/5O89Vu9N2k2HTltt7iDLBA1khHIvx6xHlxZVN2p2l900ZUVUDC6utUjLnT8G7i6I8T2N85I+8iz4SFbfZ5hA6jVcWyoAq3O/K4ke4nQ+5MtqN+akRVCo4qoSNDmuDmkZBacgqVFPvzVArUdGr2KfkpccuVSQzqdDNsEiovZhWrJNk81ygRyKSx6dlVHNUoORh+Ey12UoO2QoiFAuFpimqDVRMayqxjjAwXDwKn2yq7+jYT7TfVcPMIApqBncVcmNmyDi+ITgcFKTzN5T0U/Oyr7jXiHhiafXd+AUipqGU8D5XuDWsBc4noAsXbbobpVy1byGRl22TyCcT0UkEJflx2C1lMfVCkceAsPdu1nTFgcIam6RCUbFjTkhSbD2mae1LL3VBc4J5eZja8Ej3rQNBVtj7YxO5e/Bwp3Uk/L2hjPL34K1rpcJh8+OqiyVIIyCo75yeqziVA2NS31HmqbUerLfpe3SVtxqo6WFgyXSOwn5KjhbleM/pPa/rNUaxp9NUdQ5lK1wY8A7Fx2wQup4asbr/XimLuVgBLj3ALorPajc6kQk4aNSe4BdA1N9MWGOrfBZKMVjGnaVjS7P6KrsH00cVjYrta3wwZw6Xm74AbK27OOx2z2Kzwd5Qsnq3NBe+TLt1I7Q+xu2altL2R0cdPUNGWOjaByXait4OZP6EaVxZnHac2vnhdCKiwNk9H7Alu3PnXzXbdJa7tmsrYytt1SyeNwGQ07tOORXK/pUWw3fQb3tyTE4g48CF547D9cXHs37QYLJVyOFJPOY3hx2HMZ/Beq+0enZqLRFfGPX4oS5vvCza60nhK/U8kbuaIkOa7vBOPkoKm3mx3OJ7HZYSCD4LkX0NdVO/YldaXvIMExc1p8Hb/AJr1FJVB0XPK+dXZ72iS9k+qblK2J8zX+rwNxzByF0Gt+kfrnU57qzWiQNd7LuBzv8l1nFPBNfc7vLW03K2J+HcznADJAz81u3nh2pq699RFgMdg5JAGo1Un6XVsFPfbfc4+Eva8g4PLr+a7v2B6i/bOhqT1+J0Yx8Mf+a8k66svaDfLZJctRRvZTRjjMbyG49wXY/ol6jMlplonP3YNh7j/ACU3EVtaOEomCZsrqd2CWHIGemU660bf4HG0SB5iO7Tkaruetam26foqi7VvA1jG5c7bJXk/tP7bLt2g2K6W+1wyU9jBYydziACDI0Nzj97C6h9Ly41H+xtOyBzmxmUCXH2mnbHzXPdF2ei1D9H7VtFRBhuLKKSpYA0F/eMHeNAPm5gXOWejprXYHX6aITSF3K0O1a3xIWXbaWCit4ucjO0eXAAHZuu6x117O77WB013u5ke7csDi7/JUXZ3VuserO5ccBr+Hfruus6i1HQSUNHcjKxtNVUwqGet9l44h+GFwk3cDUrq1gDGukz5YXb8MXG5cT0VbT1bB2RZhuGhoB7hjf5rtLZLV3CCaOceqRpgADK9WUtTlg36J81CyFivU9woIH0lvrawvaCDHCWsPue/DT81fwWzUNUNrdT0Q/8AwyqHEPhGHj8Qvm58b43ujI1Bx8FwJc2P1XEZCavLRU0k0RGz2lvzC800FxfpPVZmDc91I5pb4heoZdJ1r2E1l2awY9mipw0j+88vB/whecu0+zMsOsZmt45Y3OEmZDkuz4r2j8NJWSz1VtnGWSs278afQrqeHKiKWaWlOoc36f8AldFpe12zikDp5DFIB7ABJyud621jJratipqRp7gH1QRgkrdwaIst6oqeq9EA442uAZs3ON+SsKDSNFbjmnp2M8+FMo7rw3YJnVVJBI6duQA4jladvNVorpbaN5khjcZB0OMAqNoWy/si1Rxubh7hl3vUnVGmKe9w4nj4jjZw5hX1NF3TQAEuUNcOa83lulU+udcA8iQnORpquedUyvlNRzYeTnIXJT2Y07ZSXSvLc+yNgtBZtLU1rbiCEcR5uO5K1ssLSfZTZjDTzwtOv4mu1yi7GqqHOb3bD343UtRcK2qb2c0hI7lWU1tZA7ia0N8SBhajTxzYrfv/AOzxj/hCqcbqzsTsWaib4QtH4LmHOLjkrHkborB0Qd0BRCna08kXee5DvVGoMJ5oDUZkPio5mSTKkTsKT3uEHSjxUQzJJnA+0mpMKZ3qHeHxUCarZBGXl2GgZyoFt1LSXaWVlPJxGP2tlOynlkjdKxpLW7noPNSCJ7ml4Gg3V73uOqLvd+ai9/5I+9CgUWFIMhBSDOQmDICkudshJhOvqXclHfK5/NxKTJIGtyTgeahS3alik4XVDOLw4lIyN8mjGk+Sc1jneyMqWXIiU1FUxTjLHtcPI5UK+XM2yhknaOLgHIIigkmlbC0esTj3lPZG57wwblWLnYSHTMjG7wD71yGp7SbncJXRUsBznlzKYMeqbp63G6EH+7svShwHUU4DrlUxwf5nDK6j/R+SIZq5Wx+ZXZBKw8nDPvSzgjK4VPWX3TEwe+d7h1cTkFdU0pqEXy1xyu2fwji96yr5wnLaKVldDM2aFxxzN7/FUa+0Oo4W1Ebw+M9QqXWet59O1giZEXZxutXabiLhRRTjHrtBXPu1WjLmRT+W6ueze4ek2KFpOSz1T8FqXG1Uj+FqW50zMPDi157/AN4VqqpYTaIauJuHZw5Pdo13/ZtkkY0+vL6u3P3rl+kbg6jvcbyTlx3Kv+0Gvdd79DRMdljDjI6HqqK8UJs12piBjYfPqvUuFKGno7K22Sj+bVMe/wB2NF11nhihoRRv9uZrnfou2yu9Longcnt/MLjlFKbPrNhPqtL+EnyXWbFP6Va4HZzlmFyvtDozRXx0jctycghcH+H4Hp9XaJTpK1zfeNFzfDWtTNRP2e0hdihv1NT07XPmazbqVlNcaxt1fa5aY1LXvcCMA5WNt2j6+8wsmnriI3DIGSVdRdmtFTxEyOlmeBnc4CjhtvDNiqmyVFa6SRjtmN2IPedFG2ntFulDpague07NHUeJUfsgvDqG5vhB2d0XWNZBl201UsIw4N4gFwqxu/YurDEPVaH4C7rxCronNzkPZ+YUvHZFJe4LnD7Mga8fJHEjRHcI6yPZwDlxLQVrpq3UM1JUt4sZLR7iu1UWkaOnjHBTMx4uC4pS1I09rlkr/VjDyHHyXWJ+1+zW+ADvRI8DcN3K3OM6S7XKsglt4e9kjGnDc4B67K1xFS11bURvpeYte0HAzjKx/a3peno4W1kTGxvxjAGMrX9j91lrdNxtkcXNZ6gPuXOtW6sq+0SqipqSE9w12RthdW7PbELFZ4oHDDz6zt9sqlxB2lv4Ygt9ydmo5sgZyWt8VWunPSWaKjrHZlzkDcgLmfbPbzS31tSwYD8Oz5qB2Z2+W+6lbVzEvMWDxnxXUO0jRcmq44RHI2Fzdi5wyk6C0WzS8TmiTvZHHLnYwns4vpIuFRRtf/rGCzGDkA767beKeL9AyyCmDv52OXbYea2TqMOoHMxzbjC4E221ds7Q5O5glcwycWWtOMHzXogbR8OVWS0LO94g0A9SAvO7DxC+yCdoj5xK3lIJx71ytsubraJWhnMHjG/zTs87X2eTvBgOj9YfDdcI7Ow+j13NFEdmyOcMeGf5Lt9xie+gmiYfWc0tHxXOdGaNmsVzqKmpc173Oy0jmN1scPXWmoLTcWSvw6RoDW95119y0rTVxUlDVse7V4AA7z/ZdbhqstB5o5KnHVVTatrGDJ5BMTXEdF5oSuYa1WclUAOajSVg8VUyXAnqo7qsk803KmDVbPrPNMuq1Vmcnqi71CdhWRqkk1JPVV/eou/80JcKw78oCZVzqtrObgkftGMdUJcK177zR96qZ95hj9p7R7yo0uqKSPOZmj4oS4PRaLvkh03mspNreij5S59wKgzdoFK32WvchO5HHoto6oTZqd1gpe0OIH1YSfe5RZe0UsGe6jaPFz0JwjcV0X0hDv1y2btXjh9qpoo/4pB/NQZe2emacen05PhF65/DKEvZ43XYOMow45XH4u1Wqq/+qUt0rvD0Sge/9E8zXOop/Y07qQ/xUHB+ZCcGuPRNJjG7x8V1vJQyVy1l+1dP7Gm7uf8AvHwx/m9PCr1vJ7Omph/3tdAPyeU7s3noozNAN3hdM380h8jWD1nge8rm4pteVBwLRbqcHrUVxd/ytKej0zrqbeWbT1OD9108hH4BL2T+5M9Lpx+Zbp9xhaf6wE+W6aN2iH2j8llI9CanmGZdVUlMfCntvF+LpP0T7OzOulx6XrC5yePo0MMP/hKXsXqI3Cnb1J9y0LrvF4lNm7x9PxKqmdlNAf66+6gqfJ9wLB/wNapLOyXSzh9fS1lWfGe41Ds/DvMJwgd1Kidc4hsCnZtRU9P/AFk0cf8AFIAoM2vbVT57y40TP4qlg/VWlL2XaPpj6mnaFx8Zo+9z/iyrui0hpukIMOnrVER1ZRRA/wDKndh4qP8AibejPmsBP2saeg2dd6MnwZKH/kmB2uWec4pTVVrvClpJHn8l2ehZS0ePR6WCD/u4w38grSKtceqd2I71Ebo7oxcMZri41IzS6S1RUj70dpeR8ynm3PV9YP6Noa/HPLv4o4f+Z4XeIagqWypcRzS9k1Rm5S9GhcA/ZnaVU/1eg3tB5OqLrTt/AOJSZtDdqk1PJM6g09a4mNLnGrqpJHAY6cAxlehmzk9U6CJGFrxxNIwQeqd2bU3+ITeC4pYfo8Xi8U8NVqbW1SGSsbJ6HY4W07WZGcd67ic4Yx0C3Gn+wzQunX97HYYbhUn2qi6OdVvcfH6wkA+4BbeJrYomRsaGMYA1rQMAAcglgdU4NaOirSVU0m7jhHAyOmibFDGyGNow1jGgADyAS8kpLRvuEsDfZOVTdFwpD2+qnwPim3jY+CEqgyjmoU2wKnzD8VAnGxQm5VbUu2wq+TcqwnjJPJRXU5PROSZUMt2SOH3KYaY+CHox8EIUEtRwUstVK2OJhe93IBWtJZpatwAHC3q4rU2y1Q29mGN9Y83HmUZTScKLYtPx2tnePAkqXDd/h5BXIajAyltGCmqInKSG4SuH3Ix1CH2UJEXDsgjccJHEhCHEkuKJz8FNOehPSnPTTnpD5R4pl03NCE6ZEgybpkyZSePKclwnzIk8SaL9kXGceSEioSdknJSeJHkKHCnyjyUM+aLISUhCVKRtGTyz5JGSlxuwcppCAr/REsNqtk9xe5npdyLZCQ7PDA3Pcsz7nF+DydK8csK1fqASO2dsuSPqZ9O1baAuc6AN4qZxOzohgcI82ZDTz24SfawLanuhkaHNdkFZTickFelUsEJha6M5BC6bBdg7HrKxp7iHdVzKmu7mEesVc0d7zjJwm8ykdT52XRoKwHqp8M4IG6xVDdQ7HrK9pK0OA3UzXLOkhIWjZInmvVZBUBwG6mRyZUqoObhSg5DOU0HJQchRpaPiSMlDiSFCfZJwkYXGu1Ps/wD9n3zX61Rf9GPcX1dOwf8AV3HnI0fcJ5j7J35E8PYPzS2lr2uZI1r2OHC5rhkEHmCFG9oeMFW6apfSydoz3jvH72Xl2GsAOxVlTVvLdP8AahoN+gboyoo2l1iq3kQnn6O/mYifDmWnwBB9nJzNPWYxus05acOXdxvjqYxLGdD+8La0taNt1cUtWDjdYamryOqtqa446p4KpSxLbRVI8U96UMc1lobptzT37UGOakDllPjIK0D6wY5qLNXADmqR90/eUOe55+0lyouRWtRcOe6rKi4ZPNVs9wz1UGSrJ6oynBisJqzmSV0TsR0a++3c32sj/wCjqB+IQ7+1n6EeTOefvcOM4KwGjNL1eu9RU9spSWMP1lRPjaGIEcTvM7gAdSRyGSPVVtoKWyW6nt1DEIKOmYI4429B4nxJOSTzJJJVymh53c52H1WNdKwQR9gz2nfIfqVOfJxOynYeWCA7PQjIUZhynWP4XArYXG+C47psCjtUNGCSaFz6BznHJc6FxicT7ywq6jlVDbSYa++Qv2cy61j8eAfM6Qfg8H4q0jkWO4YXYN9ZoJVvBLyVhBKqSGXhTVVq61WkONTWRxlvMEp0cT5TyxtJPgonROecNGVr4ZFKjeuN3z6Rmk7AHB9dG945DiG/yVDpn6Vdr1NqmmtlLA8xyPDTJw4G5810cXDF4midO2ndygZJIxopxZa+RhkER5RrleimPwFFqb7Q0IJnqoo/e5UGtqqp/wBkLs6jfwVTaZ7o3Ho4DP6LwBb9T637Tb6La28SRSPcWlvFwgH4LY4a4W/j8U1S+cRsixzE9x1z8lNaLH/FY5JnShjWb5XvS99tGlrAxxqLjFlvTjAUbQXbZYe0O6yUlrqGyvjBPqnPJeTYPovXCopnVF0vEk8rW5AaCd/e5VP0b7y/R/akaKRxYBOYnZ674/kuw/0TsdRbqqW3VJmlibnbA/utz+BWuajnfRzGR8YztgL3P2i15o9My8LiDK5seR57n8AV5c7ae2es03SQ6esUz4rjMMPkicMtB6Y816P7TJAdHOnxkRSsefieH/xLwTU3OOo7X3VNylxFBPlr375aOX5lYHAlqhrq+WpqGc7YWlwb3nomcKUkU7HyyN5gzLsd56LoWmewC66poWV9+ujzNO3iwXucd/Lksrrvs2vPY3UxXOzV0z6ZrgOPlufEBdzq/pA6SsdNwse+oLW4AGGhcs7Re3Ya3tk1uo7TxRPOQ4MLt/edl6BaLhxVVVokqIP9WccFrgGtDffroFuW6qvs9SHzR/ySdWkADC792F9rY7RNNF8jx6XSlsUgzuTw811A1GQvF30ZortYdS1PeU74qWcB2D4g/wAl66bWAsG68m4yttPa7vLFSkGM4IxrjI1HxXJ3yiipK58cB9U6j39FLragmF3CcHBwvCesXtZ25mapHqT1ILs9Dy/QL2vWVo4Dg5Xj76Ren5bTqanvULDwOmzkdDzXRfhxUxi4y0jzgzMLR5rY4Xc1tU+Fxx2jSAvW2miw0ELtj6g3VlXMY+IjA5eK5L2MdpVJqjTsTDMBVR5a5hO+3VdDuF8gpaV80soZGwElxXm1wop6GsfSzNIe04wuZno308roXjUFePO3alZp/tJjqIfUcyUSYHPGcr1dpqq/aelaYPwWzQA/Aj/NeSO0W7HtE7U2ijxPGyQRh4yQ5oP/AJr1bpWD0Gy01M0+rHGGjK9W41cYLPa4J9Jg3J7wDjC6+/AsoqOJ/tgaryNqCkj072txd/G18PpIDmPGQd8fqF6509aojRRGCJkTHNG0bQ0fgvNX0h7FURawZV0kD5XucHju2EnPw816N7NLhLU6ZoXzsdFIYmkteMHOEcaTius9tuDXalvKRnux0+KS/Yq6Kkqc64wQmO0TTTa/TFbEW8RLDt8F55+jhdzY9az0D3Fv1hYc/L9F6xu0bayjliJ2e3HJcl0/2K2ix6olu7ZJ5ah7y8NLsNGfILn7BfqOktFbbq0n+YBy4Gdfss63VsFNQ1FJPn18Yx3re9pukIdd6WqaGXZ72YY/7p8V5T/2C1voC7SC0xyyZf6vcnIIztkcl7RgIkiwRlQZ7UyV52CpWHi+rsMT6UMbJE7UtcMjKgt13qbdGYmtD2Hodl4ZGk776R+yrhxwMoI2OFK92C2J2eHh8vVcB5tI6Lf/APootF1hopI+OJjWDPdc3+ZK6p27aVba47JquEBkdPL+zK8427mZwELz/DNwNHgJnlZ2wVDaV4geQIpD6u/su8Pj/rmFdqeN7nUytNM4QtbnDWDA1381p1N4r6qJk8LuzDcjDdNeqv8AStDHYbZBQ05eIYm8LeM5OPer11b6vtKlEoZ1ROqSVxcsr5pHSyHLick95K5Q8zyXPOSd1PqazLTuuEdulDx1NHWNGSQWHHU812GWfIO6z19t8Nyja2aMP4TkZC6Dh27/AMDuUdaRkNzkd4Iwta2Vf8PqmVGM46Kh7MK41elqdkgIdFlmHDoFq5HtA2CqbfTMoGcMbQxvgFJfPlZtzqmVtbLUxN5WvcTjuycpk0rZp3ytGA4k480uSfCYfUpqR5O6rKy7UlHL3c1TGyY8ouL1z7m8z8FmKPKsnTZKR3nEVTPvJeM09LI/PJ031bT8/WH+FRZPSq04qKp0cf8AuqXMefe/PF8QW+5JlLqrWsvkNLOKWBpra84xTRHdoPJzz9hvmeeNgTgG9oXmmo4IS7jdGxrC7GMkDGVmKBsVBGIqeJkEeSeFjQASeZ958VaRV2wzskz3qN7SVdd/5od+VVtrG+KV6WPFJlQ8qsTPskmZV5qh0KI1KblHKVOkqMNXN9Y3W7Wm8iqgLpKX7oPktu+oy1Z653aiM4gke0uccBrl0lgq3UdWZBT9s3BDmkZ06nw81pW+V1PLziPnGNR4LPXHtEqrrb3U9NSv717cZDVZdn9rltML5pwWzy7kFTY6CIHjbE0e4Kv1RfHWK38UWDK7YBdN/E23RgsdmpuyEzhnJySe7PcFo+lGsaKChi5A8665J9/ct9HV7YzunO/Hjlcp0Xq+qrqx7Kl4OeQW+ZX5Gcrkr3Z6ixVho6nBcADptqsyuoJKCYwS7q59ISZakMYXO6bqqFeq6/XMxW2ocHcLuA496yKeMzysiH5iB8VQjj53hneVktYa6rK64mgtp2zwkgbkqrZpK6VcXHLUuje7fd38lC0a1tRd5JnjJJJ36FdOhZG5q9tv14/0PkjtVqja0taC5xAJJK7e5VzrK9tFRNAwBkkZJK5pS3e6aPuEbJZHOhzkgnYhdKfco77p8yMORLFlV10s9NXuaZo2vI8QpNIyOkpxEwBrAMAdFxt84ho7xFBUth5Kpp9YjABx4d6xK+5w1zI5Oz5ZhuRsVzfTk3oGpnMceFryQulurqSGPiknby8VynUcTqS9PLDwu4tirCl09VVzGumqjwnpxL0nia12y6NpbvXVXZNewDbJJHcumu1HR1ghrqmbkDmjxJwpetr9TXEtpaUcZJwXLVaBphQWxrC8Oedzg5WVfoqAMyHvL/HkFXWG71FgvUcLnl0Rk4XA+CqyU1vvdjdarBMT2PruDgQXeR/sojFS3CgNFbZPY9YgjUroevaYVlmccZLd1j9A3kW6lr43uwGDiHl0W4ucray3TM+80rjc8klJVTsYeEO2PmFV4Gp232zVVnkOzmuHxGfumWCEXChmoXHqD81ptKwOvOopqyXfDifIqd2j2/u4YZ2jHC7cqfoKiFLQhxGHPOTlT9cUvpdmlAGXAbKtLfmjjGJ0Z/lRkRjuxsVXdXj+Ose32GENHlspXZ7cfSbO1vMtVL2q0QcyOcDpglMdmk00LZI3sc1vi4YWn1Taze7f3LSGuzzIWTNPFw9xkZi7DA/JPgfJVHvbbL4ZM+qHfIqD2bzCts8TXblnq/JbZ1MzhIwsfouwO09E9hn73iOeWAFs2yF7ea4niOalnu1RNRO5o3OJB1G+vVYVyMEtZLJTnLSSR71xvV1tnpdUxSwxPfxEey3PVdZscz32+HvAQ7gwQUmala+Ti4RnxwpdMzgACu3jiF13o6alfGAYRjmzkn9FLW3F9dDFC5mOzGM96w2o+zsXq6vqTUd0xxzhrclSLX2X2mDBlikqHf8AaO2+S3Hdh3RSIw0Dkj/S69ejspW1LmsaMADTTzGvzUTrvcuzELZiGjTA0+Y1Vfa9N0dAA2npYoQPutWmo2tiaAoTJA1OelAciuXmqJJ3F8ri4nqTk/NY7mve7mecnxU6bEnMZTbQyM5AUN1Ycc0y+t81Bzo5FauqA0KPLUtHNVEtxx1yoM1e5x5pMpwjVtVV7eHZVclX62WjKhvnJO5TTpwOZwm5UgiU51U4jmmjNuque8U8PtSjPgN1XVOqY2f1cZd5uOEil5FozLlJdKGjJcAPNcwvfa5bLZkVF3pKc5xwRuD3/IZP4Kvi1FqTUuDZNIagvLX7sqJKY09O8eUsmAnhjnbBRuLGavcAup1F7oqbPHUMz4Dc/gq2o1pRxZ7tkkh8cYCxrOzftNuEBmqYLJpyE8455n1U7PgwBh/xIM7H6qTe8atuVYerKBjKRnu2DnfipBEeqrOrIG7HKva7tBMDC7u4oWfelfss1W9rdPG4tdc6JjvuseHH81ZUvZPpWheJDaWVsvWSukfUEnx9ckfgrqmtFFb24paKnpR4QxNYPwCeIwq5uLB7LVg5O1EzgmKqlmH/AGFM9/5NKr6jtCq5CfqLpIPKhlx/yrp72Zyo8kYPRL2bVD/En/0hcvZrSpqZmwtpKlsjjhoqm9wD8XkBXo05rara1zLRT0zHjLX1FQ0gjx9UkrS1dJFURuZLEyVh5te0EFUzLFHbXF9rnqbRJz/oUnCz4xnLD8WlOEbPzJDcJT7IATUXZxq+pP8ASLva6Jv/AGET5SP8WAp9N2QzyY/aOq66ceFHBHB+JDlJodXXm3ODbhBFdYB/bUoEUw97CeF3vBb7lp7RqK330H0SoDpW7vgkBZKz3sOCPfyUzY4ugVWStqT+b4KkpuyXTsQ+vdcK/wA6iukH4MLQp0HZppOA5Fjp5D/25dL/AM5K0ACUDlScrRsFTdNK/d5+Kg02lbBSf1FjtsRHVlJGD+StacR0zQ2GJkTR0Y0Afgmx5JaFES47lSBM49cpQlceqZbzShzSapqd7x3ij4zjmm0Y32SowE4HeaUCmxslpqVLBwlA4SByShuEITgdslNKbG4ShuAnITzXJ9jlGBynWFNQpscmMKZFJuq2NykxvQnq3hlUyOXbmqeKRTIpUIVoyTfmpDJAq1kqkMkQkyrJj080qBHIpMcmQE5JlSwM4SwN0w1+ycD0mEid+0kuGxQEiIniSJMqJIzOVHfDxKeWgpHAM7lCaq11GD0SfQQrTuwj7sZSZSZVV+z89E9DamA5cM+SsA0BKAyjKMpMUTWAADAUgDCQ0JYOUqRLGwRpHEEONCTCXndDiwmjIkOlAQlTrnJl8mOqYkqMKM+clCMKTJUAKO+oJ6ph0ibL0JcJ10ueqSZCU3zRpdEaJWQj4sdUhFkJUqXxeaLiSeJEXIQqRBJzsiUSeloJPEjByhOCNG0pJO6PkmlKo97tTb7bXU/GIp2nvIJiOIRyDkSNsjcggEEgkZGcrF2e6ubJLDMzuaiF5hqICcmKQcx5jBBB6tII2IW/Y/BWN7SbS+kjbqeijL30jOG4QsGTLTjfvAPvR5J828XMhuKkrOYZC6S01vYP7F59V23gf7q1ZNy3UmKqLSMFZ20XBlXTsLHh7SOJjgcghWjJPFUS1doJNcFaWgurmEZK1VruwcBuucRzEEK3t1wLHDdMBIUrmNkC6xQ1nGBuriCYEBYG0XTPDutbQ1XGBurDXLEnh5VeMfsnAcqLFJkJ4O8FJlZhGE7zRgptrkrITlElgow7dIBwj4kwp6avNpo9S2aqtVfH3tJUs4HDOCOocD0IIBB6EBeUr9aqvRmpKuxXEgVMBDopMYbURH2JG+/BBHQgjfC9ZtfgrCdsWlpbra6XUVuo46+72TikNFI3LLhTOx39M8YPFxNHE3Idh7WkDO6hewPwT0Wnb6s0ryw6td9en6FcJiqeHG6mwVxGN1car0Eyns1NqjSckt50jWwipa3d1TRsIzh43L2tOxOS9v2geF7xiYbhHLGySKRskbwHNe05DgeRBVZ8bojhy6eGoiq28zDtoR1B7iOi1UdwPinf2i7xWXZcMdUr9pjxTMqN8eVo3XDzTEldnqqakqZrjU+jUcMtZVcxBTsMkh9zRuVq7V2W6tvTQ/8AZpt0LuU9xeIQ0+DmbyD/AAKVoc/RoyqMr4oRmRwHmVSPrM9U3Aam51sNFQ08lZWTO4YoIhlzz5fDcnkACTsup2TsMt1MRJerxJXP2Jp6FvdsB8C92S4Hya0+a6Rp2zWfTUZZabfBRBw4XPYC6Rw6Bz3EucB5kq6yjkf7RwFgVF5gi0iHMfgP37lM7MNGRaB00ymfwSXSpxLWzMOQX9GA9WsBIHieI4HEQtcx/EVTwVXFjdT4ZQtlrAxoa3YLiJJXSyGR5ySrFhSg71sqMyXZK7xGEzK5jfKI27XN8GPUre5rgegzGIS0ef8AR+I/xhGx2CN1qNcUAnpqeua0ccDjG4/uPI+Z4g0fErJNdjqsuVvK4rrqSTtYWnu0+CmCXhaV4p7bzcINfy0s1bO2nfLwe2Q0DPh8V7Rb6zQvK/0qLEaa8QVzWkCRoOR48l6j+GtS2G9di787SB59F23DMojuAjP5gR71pNIfRp0/U0sNTV1NTXGQB+B6g336LsGjeyTTumpo5aGzwRzN5TOHE78VH7BLmzUGg7XUHd/dNDvIjZdahgaAMDC52/Xu8SVUtLV1DjyuIIzgaHuGAuXuVfcJJnwzzOOCRjOBp4BRLlEX2uZhGWlhBHiF4N0rGdK9t9TSjLeCscR7i7P6r39WgGB7ehBBXgrW0raXt6jkj5iqayRo8c4/ULrvw7cZRX0h2fGflstzhX1xVQHZzD8l7fhtcVRbyQMh7dl4g1xSu0R28zvYCxkszZm45YO/6L3VYji1wsJyQwDPwXkL6XtlNr1fabuwFofmNx8SDkfgoPw7qQLrJRO9mZjm+/cfRVeEXhtc+mO0jSPuvVtfUtv/AGbVMg9cSUgm+LRxfovn72j2n0DW/DNlkcsmC7ltn/Ne3ewzUFPf+zyhhlmaT3Zgc0u3I5fqvPXa/wBnT75AXwDFbRueHeLiNik4SuMfDl+kp6o8rH8zCe7fBVvhqpFrr5oJThpJGe7fCsdE9ilhrKCCsJ9JLxnIGfxXQaTs7strZ9XRR7dXjK879n/bFd+zhpttdTPmp2E+rIDluVpb/wDSbfcIHQWy2SumIx3jnfkButm8cPcV1lW5kchliJ0cHANx46haNbZ7zUTkCQvYdjnTC7DDqiyWa8NtrJooastyI2txstU278QG68r6C05X6g1B+3Lu5+7uJsbyV3uCvJYN15lxLbqW11DaaCbtHgeuegd3A9VhV1FT0coiifzED1u7PgtVLci4Hf8AFYzWtlptTW+SmqWB7Dkg+BUx1cfFMTVHEFy0E8lNI2WJ2HDUEdFQbljg9hwQvPFX2e6i0dXvns073R59UMO5PuTtRD2i6nYKetr5oKc7GNz+ED4Bdwnja/JwmWQNac4/Bept/EKtc1rp4I3yDZ7m5culHENVgGSNjnD8xGqyXZt2Zw6ZlbU1BZU1h37zB2+a7RQz93EBnoslTTNi5KfHc2tHtLz253Wqu9QamrfzOP7wO4LnqieaslM07suKtK6njqZRIWNc8cnEZIUygf3DRuqQXIHqnWXIdCsovJGCq3Jrlac1Yc3GUkSNDs7ZWfbcR95ONuA+8m5TuVaWOs4RjKeFWCsw2v8ANPsr/NIncqvbvbLfqywXGx3OITW+4076aePkeFwIJB6EZyD0IBXluhqK2z3K5aYvr+LUFmeIKl2C30qM7xVTP3ZG4dt7LuJp3avSMNfwkHKzPaT2X2HtXZRVNZNU2i/0DS2ivducGVETScmN2QWyRk7ljgRzxwkkp7XKeCbsMtcMtO/6rC2i7enRGNzgaiMet+8Pvfz8/gpx4ydmk+4Juk+jxfYpWSO7R2Et5OZYwyTB8XCfB/wgeSp+0PSbezy0Nqa7Xd6rp3EgR0zYIRnyHC4/itqhgnuM7KaBvM9xwAmshFRMIqfUnZXnolTJyicfgm3WWtm/siB5uCa7NOz6h1/pxlxm1frCklLy0xx3KNgx0O0RWpm+jxZqhv1utNbyDw/bjmg/4WhNq4JKKd9NMMOacHzUMwNPI6J+4OCst/s7U5wS1p83fyVfcoKW0M4q6409K3xleGj5kha6X6MWhKgYr5b9dQeYrb1UOz7+FwRUv0Zeyi2yccOj4HyfeqKqebPwfIQqnO3vUPb9wXH75rvRlGCKjU1tlxsWMr2O+bWu3+IWep+0vS0xMFplkrXk/wBTb6GaTJ/uswvUFu7NtGWJwdbtKWWieOUkNviY75huVdS1DIouFobHG3YNaBgJOcJfSHDYLyvT3W73AgUmitU1GeTnW7uWH4yuarql0zraqAc3SElK08nVtwgYB7wxzz+C7ZNq63+mtpPSW987YNypMlSHjIKkkjkix2jSM7ZT3ySsxkYyuPQ9n2r3jMwstED92eWoI+HAz81Kj7O7w0ZqL/SN/dp7eQfm6U/ktH2iX6pslhnqaQcUrGkgZwsR2Z68qtSCVtY5okGcALbhsdXUWyS6sx2bDg66/BX46SolpHVjSOVpwe9W50Hwj62/V7z+4yFg/wCQn8VmdTNsunWYmu9fLN0j9IAP4NC2+pbwLXa56guA4GnB81wWz00msL9NUVji+MHJbnl4Ld4YsNNcIp7lcXFtPDvjcnoAr9qomVDJKqqdiJm+Nye5S59W0zXFzBcXM/8Axp/6q2sF5s13lEM1XcqWU9DWPwtAywUUMIY2mYBjG4ysHrLTrbc8VdLlnrbgdF1FA3hS/Tfw5kDoHu0a/OdemQtSmktNyk9FbGYydnZ6+K6RNpOmLcsulzH/AOVE/ouU6vtxtF6GKiaUB2RJI7LvnhbTQ+qXV9tMc78yRuxv4Ki7R2CaRkzR05pnCFPJYeKHW2q6gsPjnb4hLZmSW+7Glm65CvrfZ5qmkjlbfbg3iAOAIT/4FiNVekS3RtI6ulrQzkZWMBB/ugLS6dvfd6dD3EfVtIJ9yzdkiddbxNUv33Jz4q1w7bxYq64XOcaU3M1v+YnA+Skt0H8PmqauQaRZA8+irra+st1y4KZ0QnBx9cDwn5FbaK7aqp2jvbFR1rT1orhv/hkY0f8AEsjeIzRXljxtkgro9nqmzUcTs59UdVB+IIFdFRXYf+6zXzCbxBmoZT1o/O3XzVQ/W0tIMV1gvVJjm5tL6Q0fGEvUOr1vZLnTy00d0gjqCNoKh3cye7hfg/gtjPUxwRl0srImfee4ALOXO92K5MNK+ro7h4wMc2fHlwjP5LyCB5hlbKN2kH4Lkg7syH9yyOm6j0S8Obn2l0iGWQtGAuXXWzvoZDJQ0VbSUw9lxpJYWtPkXNA+STTa51LbCGxNp7tCNgKoMie0eHEHDP8AhXtXFdpn4kigvdrb2nM0B4G4cB3LsrpSm7NjuFH6wIAcBuCF1CprfR4nSPJa1oycqpt2qornVPgjDhwj2iNisbLri83uP0ea309KXbYjl4yfwAUyzaW1jFmW32qkc13J1VUcJPwC5w8MR2qyy1l2YWzuwI25wfEkLLloILfQunuB5Xu0aCcHzwhrWHFS2TxVrZL1TR0EbpnhpA6lMV2idc3Jg9NobVGwdYal5P4tVa7sw1a8/VRWrHhLVSZ/CNdDTVllufD1NR3acsfETgNBLiP7qaO52eptsUNZPylhOwycK5r9ZUjIy2H13dMDKz9so57rdPSZGYaXcRU+m7MNcREFtHpx/gX1NQf/AM2ram0X2iwAd3bdPPHg2rlH5xrOPEFsstPLBYIHc8gwXvxnHgAqf+kFsoY3x24HmcMFzu7wWigdmHB32WNrdJvnuDpS8CMnPDjmtAyydpEI30zaZx/2V14fzYm3W/tCaTxaCjk/7q8w/qAuCtV4uVle+Sidyl4wdAfqsakvBoi51PKASMFWtoiFNC1g+yMKwlxKzBAKzQdrqm3n7O60D/sblSy/gHhNyapv9Gf6T2faryOfo1C2f/lesJ/aueXu3KrCeF2vOM+a09NEITtsB0VgHBzVz5/ahDQZNfpjVFsaObq20SMA/NFB246NkkEb7wKeTkWVEEkZH+JoURD9yE9pjOzh8V0SMBh2Upk2BzWOou0fTFdjudQ2txPJprIw4/AnKvqe4Q1UYkhmjljP2mOBB+KRPDRurYSDwTjZcKubKltm35pEwhWQn80sTearg9ONlQmYU8TnHNEZz4qH3p8UgzeaXKMKW+oPio8lTz3VdcbvS22B01VURU0I5yTSBjR8TssiO0qmvFQ+m09QXHU9Sw8LmWmldK1h6Fz9mgeeUb7JMhoyVtJakAZJwFBnuccY2PEfJQaHs87S9UtDpobVo+ldzNXIayqaOha1hDPgXLS0H0cbC7hfqW8XbVEvN8M1QaalJ8RFFgj3FxUzYnHdVJK6GPY5Pgue3TtJtVFUNpv2hC6peeFtNT5mmcfAMbk/gnqWg1rqZw/ZukLiyI857w9tExvnwPPeEe5i77Y9OWTSkBhslnobVERgijp2R8X8RA3PmVPdK53VTCFo3Wc+5vP+G3C4hRdherbi5pu+qLbaY/tRWmkdO4jw7yUtAPnwK+pPo5aMZg3V921E4b/9JXB/CD/BFwN+BBXTHOJ5pClDQNgqD6qeT2nKpsWkNOaVwbNYLba3DbvKSkZG8+9wGT8SrZ87nknPNJI2REZSqvvuo9REJ2Oa4ZBGCsZeLOaeR2BkcwtyWqLWUjamMhwRhA0XMZoOE8lFfGtRdbSYXHA2/NUU0GDuE3CdlVr4vJMSRKxfGmXxJEKqliyocsSupIVElgQnqnkiwoNVQxVBa6RmXsOWSNJa9h8Q4bj4K6lhx0UaSFCAcIW7U9ytWGTH9qU375DZmjydyd8cHzWttN8ob213os2ZWbvgeOGRnvad/jy81iXxKNLTNe5jyC2RhyyRhLXNPiCNwnh5CQtDl1DhIKW3YLC23WFfb8Mq2ftGD7ww2Zo/5XfHHvK11pvtBegRSVAdI0ZdC8cMjfe0748+SkBDtlEWlu6sGgYRgYQ4UY2SpqUjHNElAYQhGlDkkpaEJQ5JQ5JDeSW3khCWOSVjZJHJLHJCEYyEtpSRySmoQnmFSGOUZhT7CmoUuNykxvwoLHKQxyEKfHJhSGSKvY9PskwhCsY5VLjlVXHIpMcmE5CtGSZTjZFAjkzhPtkyhIVMEnmj4snmo7X/AASw9Canc7oO5JAeUriTUJSCLiQ4sFCalAbJSRxZ6ouIBCE4Chxe5NGUeKSZfBCE+X+aQ6UBRzLhNOlQlwpD5/BR3zZ6pp8ibc/KEqW6QlNl2UkuJRA4QhHu5DICInKJCEfEiQzhFxIQjQSclBOQlIEhJRHkmpqpUEEExSoIA4QQQhA7lK5hJRg4TE4JQOE/BJwnfcHmCowJJSw7CQqRcnqaF3Z5q79ij1bRWh1TaXnkwD+sp/7hO37pHgtfDMJGhw5FTtfaT/230tPRQubFc4HCqoJycd3Ozdu/QO3afJ2eiw2hdTft+0MkkYYKuMmKogcMOikGzmkdN8qk9uDhdzR1JqIA4+03Q/YraNdsnopixw3USN2QnFXc1a0Uq01puRaRkrcWi4cQbuuVUs5Y4brWWS5YLQSowcKxI0Paup0k/E0HKnNdnCzdqrBI0bq9ifkKwDlc9KzlKl8XvRtcmQ5LDk5VSE9xZHmgDsmw5HxboTcJznulxycJwUxxIw7CEELn2lY3aB1hd9LAcFrrOK7Who2axrnAVEI6ANkcHho6SHwVVXdlOmKvWE1wlo5I4a5j3zU8Ezo4TUZB4w1uMOcOIuxgEjJGSSdH2r0UrLJSaho4zLcLBOKtjG+0+Ejgnjz0BjLv8ISX1sVWyCogkEsEjRLHI3k5pGxHwKtR8sjezcM428lWqnywubVROI5hg401H6jHvyqw9mGioNxZnOcOpraj8u8wplFpbTdDtHYqGQdPSIRMR8X5KddOSeaITb+CkEbBs0fBZr6qd4w6Rx95WgpbmKOmbBTtZTwt3EcbQ1o9wGyZnuMkzsl5Kq2yZCVxlSqkck5KmsqTnmptNVYIGVTtfspEUh2UgKjIWppajIBVhDWAOAysxTVRDQAVZUshe4J4OVAQtLDPxYOVIEuOZVfT5aweKeDtkpTQpM0TK2nlgk/q5GljseBC5pOH0s74ZBiSNxY4DxBwV0aOTcLDa6Yyn1COHnNC2UjzyW/+FUqhugK3rY/DzGdim6X6xq5F9JzT3p+kG1LW5dE4tz7xsuw2pvGAVR9q9mF40TcoeHLhGXgeYWjYKw0F0p6gdHD56LqKSo9GrIpO4hcq+h7qD0jTtVbnP9ammOAfA7r0/E71V4d+jFdnWTtHuFtccCdpIb5tP8ivbVNJmJu66f8AECjFLfpXt2kAePeNfnlXOJqcQ3ORw2dh3xH6qu1bqCl09ZqmqqphEyNhOSvAtPq2luPazLfbjIxlN6QXvLifXGfz5L0v9LCjqKvQ0skMkkfdEPPA4jIB3C8+9jPZXaNfMklr55y5v9lGeHO/iu34Kht9rsVTdqt59f1DyjJA8PNb9gZSUVtmrp3H1vVOBqB4ea7JX/S8stophBQwS1TmNwOBmB8yuOdpXadfO2dsNPFZZ3RMfxscxpcc/LC9Eac7DNL2YNdDZYZJB/aTjjct3SaThpmcMNPHAz7sTA0fgsGn4l4eskomtVE50jdnPdj5DKx4rxa7c8SUNMXPGznHHyC8UaU1bqjQOoqC3VU9Tb42ua91M7bI6E/Jemb89tReZ5GkGOqa2qafEyN4j+JI+C5R9JnRNXTastFwo4HymRvA/haScg7fguk08NUNHaYrqmJ8cvcOpH8YwRwnLfnxH5Kbjeanu9porxE1rXvyHAd/Xx3HVal1nirYKauaA1zwQ4Dv/YWevOkaC6b1FJHKM5OW8/eq+k0ZQUUmYaSOPHLhatocPHNNFjT0C8lFyrGx9iJXcvdk4+C50vlDeQPPL3ZVdS0XdY2U8EsCBAA80292Vmk5VcDCU6VNulTbnJBdlGEiW6QkJsyJLjlIOQlwjKWZcdfgkmcjqmzlNuSYS5T/AKW5vVGLg5vVQ3kpl5KTCcFatuxHVPsu/ms8XFJMhHVNwnYWobdx95PMvA8VkDO4dUBVOHUpMJcLbR3oDqpAv7ImFzn4AGSsG2uc37SyvaFquS12SQROxJL6oI5haVtoJLnWRUcPtPICngpnVUrYW7uOFca7+kC+1SPobOI6qo9kuIOxXNYrNqPtHuTKq7cTIM5ydhjyCj6TscEcX7SuAbI5/rNMnT5rXU/aHabY4MdI0NHRu69yFVHYi6g4ZpDLM3R0uCTnryrrTKKEmntMPM8aF+M6+C7VoOng0/aaeigJDI2gZPMrZNuQ4Rkri+ndfUFzA9GnyfunY/JaGv1Z6Hb55w7IjYXYC8Vq4qt1WWVTSJHHXOhyVwctPN2pEwPOT17yr3WXahadIQk1NTH33SLi3K5RcfpMy9450FATA3q0Hf4lczpIqntB1hLLcHSSQcRcCcgYzyyus0mlbZBTCNlHGQBjLxkr1Kpt/D3CwjguMZnncAXAHDW56Lqpqe2WfliqWGSQjJwcAKw0b2/UOpallNUsNHM8hrQTkfNdBqq4SwnBy0jovKPaFZI9M3ynqqUd010nFgdDnK7bozUZumn6d7n8TgOElZnFVioKejp7xaQRDL+U68p81Tu9vpmQRV1FkMf0PQrjOpamWw9pUNQZHkMnHM564/VeiKC5ippI3h2QWrgHbNS93eW1LduLBz5p+i7ZXUFthp44HyStaGk8hnC7G82as4qtFuq6BnM8NLXdMY/ZW5XUE94oqWembkgYK63rICss9TGdwWlcM7Oa42nUcsBOG8ZH6J+u19qO/NcyClcxjts8JP5rK0tTNaL02aqPdvzl58FqcP8ADdRQWqut1XIwukbkNDgXDHeArlutUlNR1FLM9pLhnAOSMLsfaFO6bTk8YOzhgrn/AGcTMjdNnZwOD5hKv/aMbpROpqK2z1IIAM9Qe6YPMA5cfkFio6urpXOEFXJRucfWdDjPwJBwuW4ZjNx4buFqh/xQQ4DvxjKyrVEaq11FG32wc4XdjUsDCTsBzJOwWG1dqqyCB8Et1pO+d7MLZg5xP8IyVgpbVBXYfVvmuDvGsnfL+Djj8EbqeCkj4YYo4gPssaGj8F5ZaY6iS4wxQtPPzDT3rnKSme6djWe1kKfYb7DaKiR72yyRP5CJnET8FK1Dq+G40oa231kbeIASSiNo36YDieZCo6f+sB6KZUQiopXxu3aQQfevTuMLgyk4tjniOrOTm8+vyXU3iZkV3ErTq3lz5pmO5z09I6lawcDjkuJ3HlhaPSGnrreKV8ttudugiDuF5LXSva7wcAQAfLms5aKSWvqo2cJcQ7Dz59V1KLRcT3x19uldaruxoaKuFuRIB9iVnKRvv3HQhdb+INXTRUzaWmxmZ3aPx5DH6qLjG5MpYm09MQHSHmd1WM1fpevsrI5qy5tuDicerTiIN/Eq40ZoSi1DSCarvF5cP/qeGs7qP5NAP4q9uMJ1Iz9l3aL9n3JreINY7iZO0c3xO6jxB3HUcibfTFjiscPdQ8RHUuK4Squ9FV8Nw25+e1jccaaY81x1Te2TWWOkc49s13QaY81JtnZlpO3vEjLHTVM3+9rc1Ls+IMhdj4LVQcFNAIoGNhiGwZG0Bo+AUSJ/qp4OBXAAAbBcM97n6vOVCulAyuic17Q5h6ELFVnZzb5puIwlo+6w4C6H6rkh0IPRatFdK23Z9ElczPccK1S11XREmmlLM9xWNtWjKKgeHR0zA7xIytZQUghA6DwCkNiA8E80AKCqraitf2lS8uPeTlQz1E9U/tJ3lx8TlCSEPGMJDKNg6J5rtksOCpZVfARRwNaeSfjbhqQHJYcjKMJ9shSxIfFMNICUHYSZRhSWyuB5p+Ood4qE0p1rtkmUuFNZUEHPVOSzMqojHPGyaM7FkjQ4H4KG0pxrkmU5Uty7MdEXviNbpCxzyO5ym3xCT/GG5HzWbn+jN2a1D3S09lqLVUn+3oLjURuHuHGWj5LoQcnGvSHB3CkbI9nsuIXKJvozx0x4rN2haqo3dGV9Sysib7mFrfzTTuxTtDtzf6Fry1XkjkLnajTj5xPcuwtenBLwjJdgKMxsPRWm1s7fzZ89VxU6I7WaN2JKbSVe3xo6ioYT/jAUqDS3aVIQJLJZofFz64kfgCV0246ytloyKmsYx33c7qHSdpVjq5RG2tja8nAa47lXmWiqkZ2jIXFvfgrTY+4PZztjJHfylZSk7OdbVWBV3DT9vaesEc9S4fAmP81b03ZA14zdNS3CqPWOhjjpYz79nP8Ak8LbxVDJ2hzHhzT1BSuLZZ/YtboQs11bUHQnHkstTdkOiKSZsztPU1wmG/eXNz6x2fEd8XY+C1cHdUdOyCmhjp4WDDI4mBrWjwAHJI4kWcqQADZU3SPfq45Snyk8ymySUpJJ3S4USTg4SSMpaSRhLhLlII3REZSyMpKVGUgjKLhSyMpJCEZSUktyl4PihwoS5UCso21DHNcFkLrbHQPO2x6reOblQ66hZVRlpGUmEgK5rJFjOyZdGr+6Wt9LIdst6FVL48JqeCoD4lGkiVk9ijvjwkwlVZJDnOyiSwK3fHlMPiyCmoVLJBjoor4ldSweSiSU/PZCeqp0SjzUrZC1xHrNOWuacOafEEbg+YVo+BNOiQnAqRbdX3S2YZK4XKAfZnPDIB5PA3/vAnzWttOrrZdntibKaWpdsKep9RxP7p5O+BKwj4fJRpqZsrC17GvYebXDIKcHEJpY0rrxYQiGVy+2Xy52UNbS1bnwt5U9TmRnwyeIfA48lp7d2iUcmGXGnkoH8u9bmWI/EDI+IA81IHAqIscNtVq0tM0tRBXQNmppo6iF3syRODmn4hOhuE5MSmpTeaS1KbzQmJbeaW1IHNKHNCE41GOaS3mltQhOM5p5iYacFOsKEJ9pTzXKO0pxrkIUlr8J9j/NQ2uTzXoT1NY9PskUFj0+x6EKwjl2UiOTZVzHp9kiEKxZInWyBQGSbJ1soKExTRIEfGFF70Id61NRhSjIh3niVF73wRGXPVCFKMoHUpBlBKjGYeKSZkIUkyJDpPNRzJnqkGTHVOQnzKfFIMmE13iIv2SYQluci4vem+LZDiSoS+IIcSb4vNDi80IS8lBI4vNFkIQl5CGQkZCHEmoSuJDiSeJFxIQl5KBOUjiQLjhCaqlBBBMUhQQQRE4QlRoIgco0JwQRg4RIJicE9FJwOByuPdoNF/sB2lUl5iHBZtSO7qp+7FWD7XlxjfzIcuuA4KoO0zSJ172f3e0RjNaY+/oyOYqI/WZjwyRw58HFRPbkaLXttR2E45vZdofI9fcVFpZOJgUgFYbsn1WNW6Mt9cT/AEgM7mcdRI3Y/Pn8VtmlVHBdbymN5adwnWOwVb26pLHDdUwO6mUr8EKAhaEb8hdIsVf7O62lJNxsBXLrLVcLhut/aKnjYBlK0qpUs6q+a5Lz1CYY7ICWDsplkEJ3j80oOTSMOQmJ3OUYO6ba5GDshCckijqoJIJmh8UjSx7TyIIwQuTaXjktUNXYpSXSWqYxMc7m6Iklh/BwA6ABdYY7dc51rB+ytbUVcAG09czuJT+8dmn35awf3ilY7kka73fH+6a5vbQSReGR5j+xKkF2yISEeaWBlNuaWuwtQhcuDlSYn5TuQo8RTgdhKkKeBTzHqKHJxpwhMKsYJcYWjtHCWcXMrJwvwru01nAeEp7VE4aLWRnZL5FQKSqy7Djz6qw+ynlRBBhy4Bc31RX/ALU1fUGM8UcLW07T7sk/iSt5c5paa3VU0LS6ZkZLABk5wubWWjcH8cgPEdyT1VGoOgC6K1sGXPPktRa4+CMKXXUrKynkie0OY8FpB6gpim9VoU1jweYVHJByFovGSsfZdAWmx13pFFbaenlJ3kYwcXzW5p4yxmCm2NAKea/AwpJZ5J3c0ri495OVE8ueeZ5JPisP2s2E6h0rWUjWcbnsIDfguIfR67O7/pK6zPuFM6Gnc4449sjlyXp+phEzSCM5UOK2MjkyAuho+IKmjts1rYAWS4JzuPJaMNxmgpJKNoBa/fP2U6kgaGD1VMZG3hxgJmP1W4T7CuYWSQq24WSGuc10kTHubuC5uce5VuvNOms0LVhjeKSlLahnw2d/wly1kYBxlS2wRVdNNTSNzFKxzHjxBGCnBxI5SoM8jw8dDleZYX5jCUXJM9LJba6qo5P62CV0TveDhFzUOF0xOUTjlNuKUeSQ4pVEUhybS3FNk7pcJiS4ojtyROckPlY3YuAJ6EpQ3OyEZOUhxCVxZb5KDd7iy2UE1S/dsbS4qWOJ0rxGwZJOB5lOa0uIa3cqQ4JpwWQ0v2hR6muUtPFG4MaMhxGFr+IEZV642yptU/o1W3lfgHHmrFTTy0knZTDBTLmpmUhgJPJSHc/JZDtFvbrRZJCw4kk9VpTLdQSXKrjo4vaeQE6mhdUzNhZu44VTqXtIht1Q6mpMzTDY4bsCsy/tIu0Lw91OS0nfiHJFoOxR17X1tQ0SvLsDj3wtpWWiB1M5kjI2sIwQQAvWqubhzhyp/hnofbubo9xOueuMdy6ioqbdbZvRBB2hGjie/wAE3pjW0F/jLP6uZo3aSs32pzu4KUjdvFuPxCytSTp3UHFTyDgEgPqnplafXbhcLRHO0bEZWtBYqSy8RUFfR/7PPsD+UkbfPRaDKSKjuNPPD/hybZ6abLP05qNTSMp43GOmjaAcDqrpmhaNsW5e94HPkE12fxNdC8jGSVujTgM5LF4r4kr7Tcn222vMUUZ2GhJ6knc5KzbrcqmlqnUtK7kY3u6nqSuU1lLVaVuDJYZHBnFkEHnhdX05qf8AblqbI8hxdlrgVktbUjX20vI9g5VZ2f3B0Uc8OdgeIK1dphxPwqLtMB6RA4NLu8Zx9wVZqn/xS0+lyj+ZGcE94/eFubvqOj0xEXloDz7LWNWYk1XqfUhIoXupqd3Ighows3qqqdV6gAlP1YIx5LdWd8YpIzGGhnCOShnZS8K2ulrXQiaecc3M8Za3uAHeq0kcVopYphGJJJBnLtQFjNRaZuNLSOq66s9IeNy3JOFteyy9k2x8Bdu3BVZrS6wRWx8LnNe94xw53Wb0NdfQq7uycB+y6GWau4k4OnqKtmHMdluAAOUdwC0HuqLnZZJJ26tORgY0Hctn2qMFZQslG5bkLM6Jmo46GR80cQdGTxSSDkrbVFx9Nt8kbRxkb5zssNZgPSHNe0uaNwOmVg2mofWcF1VOxxDoXA6HGnX6rPpC6exzRA4LDn3LX3TU1RUNMVtY1kf/ANUyDA/ut6+87e9Ym4xSR1HHJK+aRxy58hySfyHuC1DnZaFUXKl9IPPHuXG8G3qK0XdlTVOxGQQ7roQsiy1MdvrGyyH1TkH3punPeQBQqumPFkc1YU0Pdswjlh4xusxt4ktd2krbW8gcxI8QehChbVup6p09I7Gpx5KmD5GbZSSHScySrCSm3SRTcO66uT8QavBfBTxRynd4b63xWu7iGpIJjja1x/MBqmaeHBS7hVsoacO4XSyPIZFFGMvkeeTWjqSl1NRHQQd4/icSQxjGDifI4nAa0dST0Wm0tpeWjkFzubWuubmkRwg8TaRh5tB6uP2nfAbbnzV75a2Z0srsknJJXI1VX2IMkhy5yj6V05U2W2/0uTjrZ5XVE3AfVY4gANb5NaGjPUgnquh6fu4JFPUnDjs2Q9fIqndGEXdrTBwBjouOe8zOL37lbi4Wenu1MIalnE0EPY5pLXMcOTmuG4I8Qq9kk9kIiuDxLTZxHXgYHkJQNmn94eqfLYJqwX7D2UtS71jtHIfteR81psNkjLXAOa4YIO4KdgO1CgyW6HZRWyYHvToeq59pmtnrW8GWl60bj7H/AHZPL+E7eGE5TVjJ2lzCdjhzXDDmnwIO4KYjTorAPBSg/Citk4ksPQkUkPSg5RuNKD0IUoOCWHqKJEsPQhSg5LDwoof5pYehClByUHKM16ElQ2JhcTgDcpQM6BG+imByca5Ye7dptrtbyziMjh4EBRrd2u2mqmbE9zo3E8yNh8V0DOHLvJF27KZxb5LeZZLk+PtWwOLfJdFa5D0qNhDS9oPhlQKa4RVkDZYXh7Hbhw6rlfaPT3u21XplHVPNM0lxY3pumWa1NutX6HJKI3Hbm7+7zTbZb23Cp9GfIIyds9/cu1NkB6qk1drKn0lQekT75OAAMlY3s57R2XmnbR1jwyrjaBk/aOVku2G8uu17p7fE7iDfDxPRdHaeFJn3wW2vaQ1uS497R1B8VuW7h6V12FDWDDW5J8h1B8V1fQ+tHasp5ajunRRA4aXDHEq3tU1+7TFubDTEiqm2Dmn2U9oO2i02Wnga3hPDkjzUfV+g6TU1wjqqkyODGgcAdgKjTSWeK+uknafRmk4A1zjb47qlBLbI7sZJm/yGk4A1zjb4rnFg0Xc9Ws9OuVY9zXnI4nHJQ1N2Xvs9Kauine57d3dMDHRb+s1RaNF0cdPITIYm8IjYRlY69drNVeoX09utBdG/I4nAuP4bL0SguXE9wqxVUjOSmzoDytby+/w7l2dHX8QVtSKimbywZ2OGt5ff4K/7EtbVFZEbbVSl7muPCXc/cuzMkDgvKvZ1cJLRq1glBieX+sw7Y3/zXqGjlD4wQdiFyHH1ujort2kIAbIObTbPVc7xjRspLlzxjDXjOm3ipfEhxBI4gjXmq4NK4klDIRcSEI0ROUROUEuEmUEk80Z5JKXCCUEEEEIyiwEXClIISpBG+6JwThGUhNQoVbRMqo3NcOaxt0tb6OUgjLDyK3xCiVlCysiLHjIPVIUZwubvi5qPIxXlztj6GYtcPVPI+KrHs8U1SAqvfGmXMU57Ey+NCVQnxqPJCrBzE05iYhVckCjvgVs+LKYfChOyqh8XkmHxc9lbPh8lHkgwhOBVW+NNGNWEkPkmHxHKE5QoWSUU5npJpKOc85Kd3CXfxDk73EFaG39oNzosNraeK4xjnJH9VL8vZcf8KpzGmzGlBxsggO3C6La9a2e6vbG2p9FqHbCCrHduJ8BnZ390lX/dkFcWkp2yNLXtD2nYhwyCnrfcLhZuEW+vmpmN5Qk95F7uB2QB/DhPD+9RmH+krsYBCUDuuf2/tMqoSG3G3Nmb/vqJ2D/gef8AxH3LS23W9kujgyOuZDMf7GpBieT5B2M/DKeCCoSxw3Cvm80tqQMHkUobJVGnGpbSmwSjDkIT7XJYco4cltehCkhyca5RWvTjXoQpbXp5j1Ca9OtehPU9j082RQGSJ5knmhCntkTgkUFsicEiExTBKld4ogej40IUkylJMqY4yi40mEJ8y5Rd4mONFxJUJ8yZRcaZ4kOLKEJ7jRcSa4s9UfF5oQnOJDiTfF5ocXmhCc4kOJNcSHEhCd4kOJNcSHEhCd4kXF7k3xIcSEJzi80OLzTfEhxIQl8XmgXeab4kC5NQoeNsJKUOSSmJxQJwk8yjPJJQlQRg4RIIQjJ3R80lBNKeEonCep5OF4UdG12HJE9cQsVGdB9teqtOY7u33cC9UA5NHEfrGtH8XEAPCJdKDuSyXb/QOtjNM63gaTLYqwRVXANzTSkNdn3H1R/3hWqZI2RjXscHMcAWubyIVN4wSF30cvpEDJ+pGD5jT5hSGnKkQuwQojSnY3YKrlWmHC0drn4XN3W7slVs3dc0oZuFwWzstV7O6jUz/WauhU8vG0KS05VPb6jiYN1axuzupQVjPbgp3OSlJIO6PiSqFKB2Rg5SUrbAQmpQO6xvalQOr7M0Ru7uVuTHJ9x2xa74EArYcSodYN722vB6bpp1GE+E8sgKzlouLbtbKSsa3gE8YeWfdON2+8HI+CmuYHBZLRlX3L7nbSdoJPSoR+5ISXAe54ef7wWwZ67QVrMdztDlzNTD2Mzmdx+XRCOA8OQiIwfNTaYeoU1VR8J4gFIqudUwDhOA8imksHZCQp6N26l083A8EKBnGE6x6E1a2ln42NcCrelqu9bwnmFj7bWFpAJ2V5FU92Q4KXOQosYKveIZws7qSnEddFKAAHtxt4j/AEFcMm7wBwKj36D0i3GQc4TxfDr/AK8lBM3mYVeoZOzmGdjoqeF+ylRvVfCdlKjdjCy11Lgp7H7JwOURj0812yFXIT4dlHndNh3JKByhMwltOSn2e0mGp6PdNTCpURUqF/C4eKprneaWywCSplbHn2Wk7lZu49rVltMDpqioDIx5hOYx8jgyMZJ6BMbC+XRjclYntXthtutZ5QMR1bGzD34w78QfmssHZ3UTtW+kJpm/GkNMXd9TucC443aee3vAWf092h2rUL+CnnAedg1+xK3Z+HrtTw+kTUzgzvwumFvrIoGvliIA8FqXKHUXCngB7yZrfinpXh0RwcZC8565uFyOpX0rqySOJ7+EAHAG61OF+HP9I6h8HahnKMnTOngrdrt38TldHz8uBldquGubVQ546lm3mqhvaxYnyiMVPE49QNh8Vh7d2Vw1DGyVda+UkfZGfxKXfezKgpre99PxxuaMlzjldVFa+DmSimkqZHuJxkNwAffr8FfZFYw8ROlc4nTIGAur0d4prpTmWmlbKw9Wlcl7RbterFd2SRTubTEZHCoXZTdKimuk9FxudHnJBOfJb/WVjZe7VLGR6/D6p8ClZTQcGcRCnqQJYXY3A9l3XzCdyx2O5iOUB7DjcdD1UrRWqGagtEL+LMzWDjHmkdoFU6DTVW4dG5I8QuS6SvU2kNQS08xLY3EMIPLmugdoteH6YldG4Ozg+8IuPDotnElMINYZntcw9MEg492UVNu9FucQj1jeQW+Xcst2RRkVVQ8Db7JXYI/ZXLOyaDgo5ZOYe7Y+GF0+I4bzWLx7N2/EFQe4gfABUL/J2lzl8NPgE5JyXNu1yNz7ZGPsg5+IXRXPy0rKa1tv7Utb2AZcNwsXhmtZb7vT1MmzXDKp22oFNWRSu2BXKrJf7nT0op6NpxyyNlYmgv10OZJHNafeoGkboy03H0epHC1zsEuHJdWpWwVEYex7XgjOxyvZeLLxLw/XuNNRsw/1hIRnOV2V5rZLbUnsYG4drzYzlc8h0FJK8OqJeI+ZWjuFjL7IaZvrFrdk5qvUlPZKZzYSHVB2aBg4Kk6buM92tjZamPhc7kfFcJcbhxBVUkN3rHARtf6o218B3LAqJ7nNCytnd6oPqjbXwC5/o26i0XQ08x4Gufw5PRdSjkY+MOa4EEZGFh9T6P8ASZu/pfq5eeOhKpImahpmGGKR7WDbiyuhu1Fa+M3NudNVMhlIAe15xqOq16mOjvRFVFMI3n2g7RaHXtyihonQAgyP2LfJU+j6V0UDpHDHFyTVLpirrJxLXTGTyJJytbR29tPE1rBgBY15rqCzWT+A2+XtXPdzPcNvIKnWVNNSUX8Ppn85Jy4jb3LLansr6lwni3cBuPFVFLX3WkZ3UXFgbbjkt/UwB3Pmq6Sk35LPtfHE1HQtoKunZOxns83T9VFTXuWCAU8sYkaNs9Fmaa3VNbMJq1xdjkCU7TWFkFUJe8ds7IAWh9HDcbJD48cgs+s42u9S5/ZSdmxw5eVoAaB3AaqpNea6YktdytIxgbYTUruOPB3VaYQx/qtA9wVi5rnHDQSfIIhbZZDk4YPMrhWvcAWg6FYZwBjKhFyZe0vOA3iPgFcC2Qx7vc6Q+HIJRLIhhjQ0eSbyphf3KnbRS43bwD95Imi4Ns5Pkp883PdV8r+IlBACeCSozmDwUarnZStb6rpJJHBkcUYy+R3RrR1KkSvcHMjijdPPIeGOFntPd4fqSdgMkrV6c0u20ONXVObUXR7cGQexC0/Yjz08TzPkMASRxGU4Gyr1NWymbk6k7D99FD0vpJ9FO253PgkuZaRFE05ZStPMN8XHq74DbnpXMTvCjDFqtaGDlauSklfM8veclMd2i4FJ4SgY/FKmKHJAJWFpzg9RzHmr/TeoHGVtvrXYqAPqpDylH/2w6hVfBhM1dG2ri4CXMcDxMkacOY4ciPNA02QcEYK6HG/CbrLTDXkSguhqAMNmj2djwPiPIrN6X1K+sldba/EdzibxAjZs7Pvt/UdFqoZuA+SflQ8pCpKqOpthzUtHd9KiMHgPv+78dvNKZVt5O28+i0M1ZBDFmV7WtPRyxl8ulnoOKSlq44XDcwuP1Z933fht5K5BRVFUcU8Zd5BWYaaepOImF3kFc8e3PIRiRc3m7TYKbIhBcc7t5j5q70nq8ah7wFvA4fZPMraqeGbrR0prKiEtYO/9Fsz2C401OaqaItYO9a/vMc1Cq9QUdESJZmtI6FLdKS1cW1o1/wC33sfI7gLsHfplW+FrFFf6t1PLIWADOgzlWOHrRHeal0Ej+XAzpquk13aZbaTIbIHuHQHKpXdrveVUccULuEuxxHZQ7Zoe39217mvmJGfWOB8lS63tEVrfTyQRNiaDjDV3Fmo+FKuuFvhY973ZHM7QZA7t11tqp+HKmrFFEx73HOrtBnHduu2W64Cso4pvvtyuedqeqpo5GW6nfwcXtkbFXmhrh6VZot8luykXewUFRVurZ4WGTAy9w6BcTbJaWx3l7qyMvEZOAO/ouToJae0XRzqqMuDCcAd/RZDTugoX0zZqoukleM4I/VM6u0NT0lG6opGGNzASR4qyuWv4be409vibVSN29UE4+So665aqv8TwYjBA4fdDRhd/Qu4jkrG3KsqBDGTnD3BoI7uXyXY0jr6+qbX1U4iYTnD3YBHdyrQ9kWoJJoTRSvLuDPDkrolwo2VkDmvaHtcMEFcM0DVPtWoxFJ6pDsELvcLw+MZ8FyPHlG2ivJmh0EgDhjv7wuf4wpW0t0MkWgeA4YXF9Y6QnsFU65UBcxjTxu4fs7qn0pIb5qhk9bKHOLsniPMroHazdG0VqEDCBJKcfDqubwaarIbbHcqcu4m+sWjmML06wV0lbYg64yBj5MxsedyPE/Jd5Zqt9VZ810ga9+Y2PO+PNekbU0NiaBywqrtAvbrFp2oqWe37I8s9VjOzrtHbVMbQ3B3BO0YDj13Wn15bXXzT9RFHuSwkLxj+Evs95ip7m3DA4ZPQjO48F5f/AA11ruccFePVDhk9CM7rmfZ9p5mpqyavr3d64HIaRkFdcp7LFTwcMcbIm4x6rQFwvSWq6jRlc+OeElnJzHbYWtu/bM6tp/RrdBI2V4wH8l6RxPw/fLrcv9X1p9OUggNAXbcQWS7XKv8A5OsOnKQfVAWW1O+O3a6MkTwRxAux49V6N0xcBW2mlmByHMC831mirxVww13A6oqZn5cAckea7V2ZxXCisMVPcIwyVhOAHZ26KlxoKKW2Upgna98XqHBGTjTON8ZCq8VCkkoKcwzNe+P1DqM6abb4yF0EEZQB3TDX5ATgdsvFl5YnMhDiSOJAHKEhSwco0gHCUDlCajQQQQhERlERhKQQhIQSiMpKEIIiMo0EhTspOCkkJxERlIlUC429ldA5jhv0PgsPX0L6WUseMYXRXBVV5tjayIkAcY5eaaQgHCwDmeSZcxWdVSuhcQRyUKSNIpAobmJtzPJSnNTRZzQlUYtymnRqWWbpBb8kIUJ8WUy+HyVg5ibdGkKdlVb6fKjvplcOiTL4U1LlUzqfyTTocdFcOgz0TL6ZCcCql0KaMatX03kmXU/khOyq0xZTMkAkYWvaHNPMEZBVk6DyTTocdEJcqJRy1Vrx6DWVFEAdmQyHg/wHLfwV9RdoF8ogBKKa4s694DE8/wB5uR/wqpMaSY0uSEhAduFtqPtToCAK6jq6E9X933zB8WZPzAWitmpbXeh/QbhT1TurYpAXD3jmPiuT8Kj1Ntpq3Bngjlc32XOaCR7j0Tg4qIxjou5ByUHLilLVXO249BvNdTtHKOSQTs+Ugdj4EK3pu0DUNHgTU9BcmdS0vpn/APjB/BP5gozGV1YPTjZFz6l7VaUACutlwoz95sYnb/8AYyXf8KuaDtB0/cHhkd2pWyHlHM/un/4X4P4JchRlpHRatr042RV8VU2Roc08TTyI5FPCYZ5pU1T2yp5sqrWypxsyEKzbKnGyqubOPFPNmQhTxIlCRQmy+aWJfNCFL40OL3KOJEoSIQn+JEmw7KPi80IS+L3IZym+JHx+aEJziQ4k1xIuJCE9xIuL3JriQ4vchCdLkOLzTXEhkoQnOLzR8fmmuJDiQhO8Xmhxeaa4kOJCE5xeaHEm+JDi801Cc4kXEm+LzQLvNCE2TlEghnCE9E7kkoycokmEInFFkoHmgmoR8SBKJBIUoR8SLO6LIRHmmp4TN8stPqiwXCz1ZxT1sD4HOAyWZGA4eYOCPMBcx7KblUVWkY6CuHDcrPM+2VTM+y+I8IHn6vDv45XV4n4K5hdqUaU7YJHN9Sh1RS963wFVAAHAeGWEOJ6kqvINiuns83M19Oeuo8xv8QtW0p1pTAOE4DlVXBb7SptPJwkLT2aqwW7rIxO3V1bZ+EjdRFWQchdLtdVkAZWhp5eIBYS01eMbrVUNTxAboBVGVqvGHklZ3UaKTITzXJ+VQITgOEaRkBGjKjKU5yz+p5gaR7fJXMsvA0nKx+pq8FjxlNylYMuC5/HV/svUVureUZkNJN/BIQB8niM+7K6JSHZzCd2nC5lc4G10FRA8kNlaWEjmMjn71udK3Z13tlDWSYE00XDMG7AStPC8D+8HD4K7Su3aq11i9mX3LTU4wPJCoZxNIUiniy3ySZ4sZ8FohcxnVVhGUByS5Bh5SPtITkaUDhIJwjTUKRFKWEEK6o6sSMwSs+DgKRTzmM5CUHCYRla2gqcuLCfcreFzZGFjwC1wwQeoWOhrMOa9pwQtFSVbZWNe08+afnKYQRqqiWmdRVMsDjksOxPVp5H/AF1BS2q0vEcc1L6QSGSQtzlxwCOo/wBfquN6r7ftP6XmdDxiplG3qvGMptLa6y4S9lRxl58F2lubLcW8sLS5w3wurMPJPtPJcFtP0qdPVVY2CojkiLj7WMNb8Suy2HUVDqGjZVUNQyeF42c0qS42O42kA1sJYDsSNPir1VQVNGAZ4y3KtZqqKljMkrwxg5krNXftU09ZWuM9fGOH94BQu1fvZNE3EwvdHIxnFlpwV4z7OdGx9oGq6q33KunZ3QL2nPEXYPmus4a4borrRT3CumLGRbgDJwtO12unq6eSqqJC1se+Blelr/8ASs05bS8Uz/SHj/dguTXZ99J6n1RdKiOendDBEPV4sAvPTAVVb/o+aYtlJI/0J1W9rcl1Q4kfJed6F7LF2g1MVOeGnE54MciM7LrKG08NXeiq4rZG8yxsyHP+wH3WvSUdouEM0dI13MwZBd9l6V1Rqupu809fVykADIaD6rB0AXm+7XKu1/qh9M2V0cLXEBrScY8cLuRayuoXMcOJkjMEeRCyEtns2jg6qLIqfAO5OCVw/Cd2htHbuZEX1Thyx6Zwe9UrXWMog/s2F0pGG+Cpqfs0t7Kbgka6Q45jZYS/2mTRt6hlp5HNj48jHgDyWur+1CrqXmG00Al6CQNLv8lkdUt1BcYBV3SExxNOQCAMfBeucMRX+GtBvdQ0Ry5BY945jnbDV1NqZcY6gGvlHK/TlcRk57gu76Vvn7ZssMxOXkYK5H2vURpr42paMZIdlaHsqupkthiJyW4KT2u0oqrdHNjLm5H6ri7ABYuMXUp0aXFvuOoWFbx/D732XTJHxRWvtPt1Da4WvHHMGDI5nOFn9UdpVXeKZ9PSROiifsSGbkIdnVgt94pHSTxGSVriCM7LpNPpujp48RUsTB/CtK4VXDnDdzkY2kdJKx35iOXO+m/u0S1U9qtNW5jYC97T1Oi5l2c3i22mtDanjZUyHBc8YAXavR21dM18eHMcMg+K4n2oW2mt9bA+DhZK4etwHquodmtfLUaVoxMT3jG8JJ8lncZUkNwooeI4S4GU4LXHOMZ28NFBe4mVNPHdY8jtDgg9PLwWD7TdJub/AE6Bnrh3rYCzFXql1w0uaWVx76N4AB6jC77drfHW07mSMaWkbgrzxrHTj7BdTHg93ISWn4rpeBLnBeI4rZXn+ZAQ6M9cDcfD5LW4crIq5raOp9qM5afDqF0Ds0i7mzMcMgPOfit2ybAWe0FbR+wqYjYubkjwK1Lra8NyAD7l4zxFMai7VMne931XG10olrJnnq4/VRzPuo1URI0hOy0k8Z9glQpTI0btIXOA4VEgOWC1PouOulMsH1Uv4LPN09e4gYo6l0cPk/GV02qdnmNlBcBnOF6Fb+ObrQ04piWyNbtzgOx5Lfp73XU0YiBDmjbmGcLH2vRR79stVM6V46EZ/NbqjiEEQY31QNgAozZAwpxtaWgrnrxf669yB9Y/mxsNAB5AKhV1lVXvD6h2cbdwUqeJrxvuoElED0Tjq/KaNW081zwdhUiwI2UoHRKLGgckg1AcEkyEoJyjlASZI2u6KO+BqkEZSHM8kmEc2FFMLB0JTTmRj7IPvT8pwoksmMpcJuUC/G3JNPlwm5JVGkm5pyTCdkn254UOafbwTcs6hTTZyM7JiAEqafJ5qJLUcDQcFxJDWtaMlxJwAB1JOyZq6yKlhfNPI2KFg4nPccABUtq18LbdxXG0yVUcYIpxJJ3fDnYvLcHcjYeAJ8dnNZznCZNM2nYXHU9B3rqenrB+yIe/qAHXCVuHu5iNv3Gn8z1PkABcNC55T9tlvef6Vb6mA9SwteP0V5Q9qmmKzANead3hPGW/lla7Q1o5Wrj5DLI4vfqStUAnA3ZQqDUNouOPRrnSTE9GzNz8sq0bEHDLSCPEJyi2TPAhwKQYSOij1Uvo0L3uGA0ZKGsLiGt3KVoLiGjcqNWVkVFHxSu4QqGfW1FG/AJPmstVVE+pbu6PjLWA8h4K6i0pTCINLS/bnyXqb7FZbEyNt6kc6VwB5W/lB8V6E+1WqztY26vc6Rwzyt6A+KsTcKHUjGNgqHU9XE7jp6hu0kb+hH6jqFr9KarfdHSUFwY2nvNO3L2N9mZnISR+IPUcwdj0J47caJ9iuEbo3EN4shbdlKL/AG6mqIpXUtfAeOCqj9qJ36g8iDsQsriSwU1vhhuFveXQS7Z3B7lnX2z09FFFW0Ly6GTbO4Pcr/tJlkfYy6ORzCNiWnC59ozTNPqXvZKmeTiY7BaN8/FaypvrtQ2Otoa6NtNeaZnFLAD6sjRsJIz1afmDsfOh7K6kQ3uogPsvbkDzBXVcPV1RDwpVupH8skRzkb40z8srobLVzR8O1JpXcr4znI3xpn5LTVvZ9a4LZN3VMXPDdnuPrA+Kw2jZzRXR8bi5oa4gubzb0yu5VEAfSPA2JauJscbLrl4OGtdJny3ScM11RfKCvoauQvcW8wyc7eaZw/VT3WiraOpkL3FvMMnOy6ZDceFgE5HAeUwG3x8PfyXN+0im7u5slG4kGQV1yewCopm1FCA1zmhzoOTT7vD8lyvtDpe5jjwHRljt43DAHuHT8lzHAsxpr/C3+rLT8P1CweD5jDeYm/1ZHy/VbHSUwq7NSyHc8ABVV2i0PfWl72t3Z63yS+zyqbJa2xh3rA54c4OP9dVdajphVW2ZhGctKoCX+EcSF7dAyT5ZVUP/AIbfS9uzZPllZrsvuGad8JPLorntIuktFYj3JILzwkg8gVhtA1Ro7w6EnHrY/Rb3VtqN4tEkbfbx6vvXV3yKnt3F0c9QP5TnNd4aro7vHBQ8SsmmH8txa7w1Wa7PLXBNA6oeOOcnOSVvpqNsdO5z8BoG5XG7ZdrjpOpe0McG54SCNj7laVeqr1qUCnigdHG7YloK1r9wrXXS5PrjO30d2ocXDAHdj9FevHDlXca91YZm9idQ4u0A8lVVNZHBqp88J9TvF3e01zZ7fFLnILAcrj03Z7USMpzDIGyfbLh1XR9N2+ahs8dHPL3pa3h4mjGyx+NKy1XClpTRz8zo/VI1zgaZ7uiz+Kau3VtPTmlm5nM9UjXOBpn5LnOubg7UOrBTNy6NjgzhHL3rplqs7I7dHDw5aGYPmoFJoq3UVb6RHAXTZzxvcScrWUkfAwDC5viC+09dT0tFQgtjhHXTLu/QlYV6u0NbDT0lICGRDrpk9/Vcr1N2e1BuLai2ANe5/EQTgBdA0pBcYLW2G5SMlkAx6u6t5KZrzuE9Twhm2FmV3EVbcaKOiqcODNiR63xVGrvdXXUrKSow4M2OPW+Kzd30XQ3OQump2uJ8NsoWvRVFQSAxUrGkfurXcAKcbGB0WWLpWiHsO2dyd2Tj4LO9Oq+z7HtXcvdk4UOG1tIAIVnR04h5ImEBOteswnKo4Uxr9k4H5UNr8J1r0ZSKS12yMFMtclh+UqQp4HKMFNByUChNTnEjyElBCEtBJBwlIQgiIyjQQhIQSiMpJGEIQQRgZR4CTCXCSkuYCMJzAREYSJyzt6tYkBe0ZPVZWppzG4jC6PLEHtIWbvFp5uaNk0hAKyD2ppzVPqICxxBG6iObgpFIFHLEktTxCSRuhKmeFILN0+QklqEKOWJDo/JSS3dJLPkkwhRHRpt0SmFiQWJqdlQXQ+SadB5KwLE26NCXKrXU/kmXU/krR0aadEhLlVT4PJNOh8lavhymXQ+SE5Vpj8kgswp7oU26FCFELURanzHukmPCEJnASZYGTxlkjGyMP2XDIKeIwiQhQILRS0by6lY+hcetHK6D/kIVjT3e/ULgae/VLm/7urjjmb8y0O/4klA7pcpCAd1b0/aJf6XAqKK317RzdFI+nd8iHj8Qrem7VqMACuttwoj1c2ITt/8AsZc7/hWQI2SSMhLzFMLGldOteubJdniOkutNJMf7B0nBJ/gdh34K9bVkc1wuqo4ayPu54Y52fdkaHD5FIpG1NqAFuuFZbgOTIZsxj/4b+Jn/AAp3N3ppj7l35lWD1T7Jweq4vRdoV+oCBUxUl0jHM708p95HE0n3NatNbe1WzzODK101ok8a1oEf/wBcaSwfEg+ScCCoywhdHbNnqnGyqmpa9lTCyWGRs0TxlsjHBzXDxBHNSm1GU5RqyEiUJFAbMnGzJMoUzjR8WeqiiVKEmUZQpHF5pPEmuNDiSoTvEhxJriQ4kZQneJHxJri96PiQhOcSHF5pHEhxIQl8SGQkcSHEmoS+JFxJHEhkoQl8SHEkZKIlCEeSiQRFyE9GiJRIicIQjSXFDiRJuEIIIicIslIhKJwiJ2RZKJNKeEoOwVke1qzT3XRz66ibm6WaVlzpfMx7vbtuQWF23U4WqyQU9DJghMcMjCtU0xp5myjcHP8Ab3rJWu4w3e20tdTu4oKmJsrCeeHDIz5qYCsrpSkOmLpeNLn1YKKb0mgz1pZSXNA8eB3GwnyC1DTsqJC771SeZux1HkdQnmHBVhRy4I3VYDhSYH4IURTgVr7bV8ON1qrfW7Ddc+o6jBG60FDW8ON0xDxkLoFLVBwG6nslB6rI0VwyBurmCtBA3RlUHs1Vy14ROmAHNV5rABuVX1t4bE04cjKg5SVKulxEUZAO65/fLiZXkZUm7XsyZAcszUzmRxyUK1FHjUpD35Ktuz+qLJLtRZ/6vUsqWDwZI3f/AI2yH4qk4t05pWpdT69khBxHVWx+fNzJG4/B7lPAcSBNr2c9M4d2q7XQOD4h7kuVuQVAt0pbGzzCschwWyuAOhVXUx8Ls9FGcFZ1EYc0qveEEKQHKbO4QG4Rom8k1KjHJLacJCGeXilwhSGScKn0de+ncAHYCqw7HNB8mG80iFzf6TnanUWGyQ2qhl4JqrZ7hzaFg+zLsOgrLVDdrt3s0lR63d5G3gcrPfSGqXy65o5ZTmNmGPB5EA/yXqPs1o4KrSdC1vsCIAe5eyV1RLYuGKRtA7kdNkucN/LK9OnqX2Wx0opDymUkuI38lx7WfYVaa6zzPt9L6NVsYXNc3cuONsqD9Hem1TpfUMtDXQSC1ljgHSH7WcjC9Gz2xhBbwjZR6azx08vEA1vmuAZxZWm3S22r/mtfsXZJb4gqtHeqk0j6WX12u6nUjyTuoaQXKyVUBGe8ic3HvC8Y9mNQbB21QMeS1jpnQP8Acdv0Xt2ZmKZx6ALw/q8NsHbbVSNJEfpAmYBz8cfMLqPw/cJ4bjQu2fET8NPutnhsiVlVTHZzCvUvaRfo6C0stVMR6RUtzMRzZH4f3vyz4rx/r+lNr1dDOBgPI/A4Xdhcp73NJXVLuKaY8R8B4AeQGAuUdstv+rhqgPYdufesf8PKvsL6IH7SBzD7x+qOGyKesbEdnAgrpGl61tXZ6eTmeALknahc5rjqltvc8tgaRgZ2OVtuzG4+l2Njc7tWW7VNM1Jr2XGmaXBrfW4dyN1s8Kx01r4qmp6khp9ZrSejjsrlp7Okur4pTg6gE9D0W00zp+norfC2nbgFo3PNV3aLTwU2np++OOIcI96xFn7T7laKRtK+AzPYMNBGD8UGRXfX1c2SsY+GmacluDhXI+E6+33I3W7zhsTHc3NzZLsHIwN8lPbZp6ap9MrZAGtOc5yT5I+yuv7qvdATji2C3Wtab0qxzDG7RlZCwdn1yt18ZURzMjhjkyM7khdSqLQyvpXRl2OIYIO6xuMLhQm/RXS3Sh4PK446EH9FTvFXTGvbVUzw4HBOOhC4TpTVbtKS1A4DIHHZo8Vfz9pd8ug7uio3AHkcE/5LUP0BBQSukZQtk3zxAcSl01KIQA0CMeDRhadz4zsVTUmsZb+0lOMl7sDIGPZGfqp6q80E0xnZS8zz1cdPgFhaDR9zv1c2pugczO5B2XXrDTMoKWOJjcMaMBV1NhvMfJW9NOzh5rg71xJV30tE2Gsb7LW6NC5yvr6m4Ob2uA1uwGwVlK9vBuuKdrFQyrvdLTRuBeCMEefRbTX96udDRsNtJy7IcQMkLAac01X3a7Nrbk4vw7iPEdyu04OpILWw8QVczQ1ocGtz6xdtstqywxUQNznkADQcDqTtsur6Uh7i2U7SOEhgzjxWi49lUW9vdRNbjYDCse9yvKp5DNK6Q9ST8VxxcXuLj1TrnJp/CeYB+CJ0ibL1XwnJD4Ync42n4KO+jp3c4WfJPOem3PympRlRZLfSn+xao0ltpD/ZD5qY+TCjSSZQnglRX2uk/wB2PmUw+10vRn4qS+XzUd86TRLkqNJa4ByyPcUz6FGzqT70/JOo8lRtzSo1RmONg5D4qHUzBoPRN1NcG53yVUVVcXE7pMoDSU9UVA33UCWfqo9RWNaOJxx71Xy3WEH28+9W4aSpqRmGMu8gSrcdPJJqxpPuU6SYkqPJLw9VBluseDw+sfFUkl9ZUSvbDK2UsOCGHOPetK2WWsu1SaSnbh41PNpj4q1S0EtVJ2TND46K+mnA6qmr7zHDIYYWuq6of2MZ9nzeeTR7/gCos75p2+s5zGeDTj4ZTcUTYoy1gaxg3w0YXo0X4esgp3VtxrGtjboeX1sHu0W26xxwwOqaioaGN3I9bB7tE1LRyVkjZrhI2aRpyyGPaKM+IH2j+8fgAmX0bZHEHZS8HdN7hwyFnUVHYzeqemp3GSF2h5hjX9FycLLZNdoY2OMkZ0ORjVU9TbWte7ZQJ7WPuhaWaMuft1TL6PjB3wpbpwfchc54aKAmMOOD0x01KfXcOV3p0sVNCSwE4PTHRZGSg4DkEg+RT9HfbvaHA0lxqIcdBIcK6q7S7gLm746Klni4XYOxXK3G0V9oeGVsRZnbuPvXO19tq7e4Nqoy3K0dt7adS2/AmlbVtH+8bkrUUnb3T1cRhuVBwhww50ZXKJYVFfD5LKY4tII3WTjlOQu82XVempfrKRwjf91w3T9RrGoqHGOgpuP97GVymwUraS1unDcyHmVSs1PdaGrdLBUvjcDsGkhetzwUdmooLhdGGonmGQHE8oHTPf5L0CaCltdLFW3BhnmlGQHE4A8e9dTvUV0njE9awtaDyO2FrND1RloeDO7Vyy0dpNyvEbqGthbO1w/rRsQtvoi9U1DV9xUzNh4/ZL3YGfetqpqHcQcJyy9iI+ydoGjAx4fdas8z7zw3JJ2QZ2btA0YGPBa7UVpjuNM2VrzBVQEuhqGe0w/qDyIOxCyGh5H0+pWB2A8E5AO3nhavVF6htlHsA8yDDcOWEsdJNW15nZI+CVp42TN+y7ofP3LM4Yp5aWw3CpqBiN7cDPUjO3xwqFggkprNW1EwxG9uBnqddl6DhfxQ+eFxvtHpfQdQwVAGA7n8Ct/pPVH7ScaCta2nukQyWA+rM377PEeI5hV+v9Kz6gbF6Pwte12cuXLcGXKG2XVr6h3LG4EOJ2wQsDheuioLi187sMIIJPcQtFpW8SRWKCUAzRNbuwn1h7j19xXMe0jVMep7iyGlgOYzw5A3PlhdA0raJrZa/RZ5BISMEjko/wDsHQRVrqmGNzahzuLjduM+7wVy0XW1Wa5z1kjTIWk9njbXvzhWLbcbdaq+aqe0vIJ5Mba9+yodN2aa322ATscw+0142Iz59Fey1b+4dHODIwjHegbj3j9R8lqLeI+FtNVMbHI7YZ3ZJ7j4+R396jXTTRbl9NuOfdn9CuIrKt9bVPqn7uJPxK5Gpqn1NQ+ofu4k/Fcyt+kJo706sZPH3LncTQ3fK6FFHxx4JVR6LJSTuMeYpM+s0jY+8K1oq6ORwZIO6k8Cdj7irV0u9Xd3sfVOBLAAMDGg+qt19zqbm5rqk5LRgaY0UKpskU7+J0TXHxIyl0tnZF7LAPcrksBCMMCzO3kLeQuOO7Kzed5by8xwo8VC0AZCmwwhg5YQHJK4lWymJbWjOU61wCZDt0YduhPUkPTgeooclh6EKW16ca/ChtenA9CFMa9ONeobZE42RCFMa/CcbIoYenGvQhTGvTrXqE16dbJlCZhS2vSw5RWvTgelykwpIclcSYD0oOSpqfBRg4TQclA4QlwnOJGkIISJaCTxJSEoRAYRoIIRlBERlGghLlJI3TM8IkaQQpCS4ZSEJVkrvaiwlzRss5PDwnkuk1FO2ZhBGVk7tbDE4kDZMISgrNOZhILVLliLSVHc1IpEyWpLgnS3ZERgIQmi3dJLU6W7JJGEITRbskFmye4URGEITJYkFqfI8kktCTCFGcxIdGpJaN0hzUmE4KKY006NTCz4pDmZSJVAdEmnx+SnujTT40IUB0abdGpzo026NCeoJjwklimOjTbo0IUUsSS3CkmNJMaEKOWlJIT5Z5JJYhCjkYSC1PuYkFiEKO5qbcxSS3CQWIQoFIyezzGa11c9rmJ4nGldhjj4ujOWO95BK2Vk7WamiLYr/Rd7Fy9Pt7Cceb4dz8WF38IWYcxNPiTgSEhaHLudrutHeqJlZb6qKtpX8pYXhw923UeCmtkIXnqjkqrNXGttlVJb6s443xezLjpIw7PHv3HQhdJ0z2qUla5lLfGMtdWTwtqQf6NKf4juw+TtugcSng5UDmEbLftkTgkTBaW+7xQDsJVCpIkSuNRg9KD0IUjiQDk0HIw5CE9xI+JNByMOQhO580MlIByghCXkoZKTxIcSEJWSgi4kXEhCUgk8SBdshCPIRFybLso+LzQnpSLISchFxBCEviRcSTxIcSEJXMpJOEOJEhCGSgTuiJwi4kwhKCjJwja7dIzlBMIUgWS7RYf2ZJbNTx7fs9/o9Zj7VLKQCT48D+B3u4lYg/JXk1PDX0s9JUxiWnnjdFLG7k5rhgj5FYLSE01JHWWGtkMlws0gp3PdzliIzDJ/eZj4gqrIMHK7G2TdtAWHdv0P6FaMHCdjfgpjiSmuwqxWsFbU0uMbq1p6gjG6z0EmMKxhl25qMpVpKauLcbqyivHCNysqyowOaX6Ucc0xNLQVpai/ENOCqasu7pCRxZVZJUF3VMOfnqnJoaAnZqgvJJOVHJ5lEXbpBchLlL4t9kza5u57QrO779PUR/g0/ojLsFR7eDJryygc2xTuP+Fo/VSxe2FXqT/Jd5Fdtoj/AEdnuVhFJtgqDQRn0ZmfBSAeFbWVwBT79woVRHg5A5qQH8QSH+s0hKmjRQHDASQcIw8Pc9p2ew4cPyRHmmqRKQRA5RpQhGTlJlHqI0ThkYRhC88fSP0++RrLk1mQ3HEQPgukfRy17FddNx0T5R6RTsaHNzv4K71fpyHUNrqKOdgdHK3B25LzhWaV1N2Z36WrtAkdBxZ4o+jQeq9etM1LxFZRZZ5AyaM5YToCO7K9Gt8lPe7V/CpnhkrDlhOx8F7eNWxzA5xAHI5XnPty7YrtatUU1l0/WRx8ZaHSNAccnbGem6w83bL2h3yk9Do6Exg+q6QxEuPxKvOy3shuFXeRfNQAuqS7iDC4HfzCioeH6Thlz7hepI38oPLGCHEnpkLTt9uisjTNcnscQPVaCCSV2249obNH6FprhdgXziBvGMgZdhePqu6T6516+4NY5jHS8TM78IzsMr1x2j6at910bNFcg4xuHdsjacFzjy3+Z9wXFrZpCjs0gZSxFgHMuOSeuVztm4kt1loal8UZNVLkf7oaf33Itlxp6KmllYw9q/I8AFoba3hp2DyVFr/T0l/tUkEOO8I9Xi5ArS0kfCAE9JCJBgjIXnVFWy0FUyrhPrMOR5rGilfBI2VntA5WD7O9L1enYHMqJWPLvst6LZVdC2pjw4AqRHTBh2CkYGMYU9xuU90q31lQfXccnAwionlq5XTS+0fcsi7SdKJC4U0YJOc8O6saW0NhAAbgeCvOAeCLhHvVZ9VNKMSPJ8zlVncz/aJKgsoGsOQFLjiDSll2UXEq4KTACUIwHdEzUWylq895GOL7w2PzT3EhxpVDqNQqWo0y5uTTz/3ZB+oVbPR11Hu6BxaPtM9YfgtYXdUkvwk5R0UolcN9VhJ60v8AVeOX2XJdJMxrsnG3gtfU01PVbSxMk/iblVdRpyikJLA+E/uO/mnZeBgFKSx+4whT1bANjhSBUg9VUy2CohOYKhr/ACeMKM91bSf1sLsD7Tdx+CTmI3Cd2bT7JV8ajPVIdOqSO6Nf1Twq88inBwKaWEKzM48U0+YEc1AdUJqSpDW5J2RlAapkk+FFkqPNUldqmipXFr5hxeAUOLVlDUv4Wzt4j0Wo203B8fbNgcW9/KVebRVBbziM48leyTqLJUY64UY1YkaCHZCg19eIInPPJoystrXPeGNGp0VYNJPKN1IrbpHTNJe/AVDUaspeLHeYHiVkq2unvVY4cZEYO2+yJ9qjbGSXHIXrB4aslmayO+1LhM4AlrBnlz3ldU63UFDytr5CHnXAG3mtObmyqALHghRamqEbCTyCyVPXmllcYZBKG7Ya7Y/FQJb3c7lUcLw2mpwfZAy4j3/+Syrtwn/D62lbTyc8FQRyu8yN/EAplTaBDNH2bsxyYwVYXW8taHySzCKEfeOyz0upe+fw0lNJK3rLKeBvvHU/IKVcafv3sBbxEciRlNttxI3C6rifiOq4crf4TZwIo4gBkAZccakrRulxmt8/olFhjWY6ak+KXNFHeKIxyOdwnm0OIB8jgqs0fTejCSBoa0NnOA3YdFZupjFG4DPJRNGRl0rvEzZ/JcneuIo76yKUw8k7Rh7hoHe5cffrk2vijdycsg3I6rX1cP1ZVdGMvwrqpHqkKmI4JfcV2XBp/iFouNrO5bzjz2/RW+Gh6Xbq23nqOYee36J4xDGyYnj2U+NuQE3PDsV5PTSmmnZKN2kH4FcDC8wyNkG4IPwVbKSGAhMkOeM5Ukt2ISgBhe38aSXapnp30DnlkjAcNzv12Xp3E7rjUTQupHOLHtBw3O/uUOCR7ZOF24Kqb1AGVBI2zur0sa1xcdlQ3Obv6nPQbKpeTPT8Kx092P8AP5stB1cB49VWuhlg4fZBcT/N5vVB3A8eqq3xhwTEsamFu5TT2ZXiwC8tJVpYLhG2J1NKQMnbKdqNN01RKZRIGNccndZ97CPIpDqibGO8djwyvUaLiyldQR0N1pRMI/ZOcFdxS8SQGjZSXGnEoZ7Jzgq/nqaSxQlkDmySnqCoty1JT1lA6IxOdI5uM9AVQSZzknJTSrVPG1a9r6ekY2OFw5eTGQB7+p71Wn4srHtdDTNayIjHLjIA9/VWtv1bcaCJkPempgactinJc0fy+C6DpbtWtY4YbhTut7uXeN9Zh/ULlIagWAriH19U+BtM6QmMbNzoPcuUdV1D4RTueeQbDOnwXpotpNQUkc9JVtc+N3HBV0zwXRu8QR+I6q/0prVtyrRZruGUt5a3MbuUdU0faZ5+Lei8o2q7V9iqe/t1XLSSdeA+q7yI5H4rcQdpVLfqZlNf6d1LOwh0Vwo8gxvHJ2ObT7s+5UdCqwI2K9WxQBuMBPCIE5XLezvtWFR3NsvlTFM44ZTXaIjup/APx7L/AMCuqKPCUjCN8EcsbmSND2HmCmO/moBiXiqKUf2nN8fv8R58/HPNSWlKRsm7qLWW+nuMQfs7Iy2Rh6fqs5cLVLR54xxxH7YG3xWhfSSUr3S0eBk5fA44Y/zH3T58vEdU7T1cVc17ccMjdpIZBhzfePDz5FLnKZjCylNXS02Gk94wdHHce4q0gq4qgeqd+rTzS7hYA7L6bbxjP6KkfC+J5BBa4HkdiEJVfJTSqinuT4yGyjiHj1VlDOyYZY4H80ITwOUfEkcgj5AJqenQ5KDkyCjDkIT4clh6jhyWHIQpDXpwPUUPSw5CFLEiW16iB6cD0IUxsica9QmyJ1siEKa2ROteoLJE616EmFNbIlh6iNenGvQmqW16WHKK1+6ca/fyRlCkByWDlMNclhychOowcJtK4kITiCSDhGDlCYjQQQQhBEeSNBCekkbKHW0rZ4yMKaeSS5uQkKFhbnQGGQ7KokjwVvblQieM7bhZGupDC87KNPBVWWpH2U+5u6bcEJybIwkJwjdFjfCEJsjKIjCcIykkYQhISS1OEZSSMIQmy1ILU8RlJI8UITJbukFqfLUhzUIUctSHMUkjCQWpiflRHRpt0eVLcxILEIUMxpt0amOjTZYhLlRDGmzGpjmY6JssQjKiFiQ6NS3RpDmIS5UNzE2WKY5iaczBQlUUtSS0J8t8kktyUJyjlgTbo1JLUkt2QhRHxeSjyQhzSCA5pGCCFYOam3sQhSNOatuukeGOkeKu3j/731LjwNH/AGbtyz3bt8uq6nprWdr1W0spZHQVrRl9FUANlaPEDOHDzaSPiuOujTMkAc5jvWa9jg5kjHFr2OHItcNwfMJwKjcwOXoM5ad0YcuW6d7Ta23BlPeGuuNKNhVRgd+wfvN5PHmMHycV0e23KkvFI2qoaiOqp3bccZ5HwI5g+IO4T85VYtLd1NDksOTAOEoOSoT4clApkOS2lCYnUYOEgFHxIQnAcoJCMHCNkJSCCCchBBBF4pqExxbo+JNcSPi805PTnEhxJGShkoQl8SHEUjJQyUYQl8RQJJSMlDiSYQlIicIslEmlCVxIicokE0hOBS2uwViO0eI6fuds1dGMU8OKC5gDnA93qSH+B5954scgtryKKppKe50VRRVcYmpamN0UsZ+01wwR8ionN5hhaVFUmmma/cbEd4O/9lR5DgC0gjoRujB3WX0XLUWp9dpe4SGWutDhHHM7/wBopjvFIPhgEDkRjOVplRIXdEDOQcjoe8dCpET8KbDKqxrt1Kik5KIhIrNsuwSjIokb8hOceyYmkp0u3Sc5SAcocYaOI7AIUT5GxtL3nAGpJ2A7yjJKSTtuostaScMGB4lNekSfez708BeDXD8aeGKGqNNH2koGhexo5fdzOaT5gYPQlS3O3S9LsE3aFRA78FDM7/ijCjMm7zyKkaMcHdpDG/aFslP/ANljUsXtherUd3or5bRX2+QPieNCPgQQcEEHcEZXcYQGwMx4BJelxerTsH7o/JJdyWwufSQcJTklKPJCFVXaN9PitiaXOiH1jG83s6/Ecx8R1S2SMniZJG4PY8BzXN5EHkVYEZVDEz9kXE0hGKSoJfTno1+5dH+bh/eHQIShTxzSkk80obpqVBBBBOQkyRB2yrKyzxz5ywOHgRlW3IpYx1TckahCz8Wnow4Hu2jHktDZaNlJMwOwGHYk9PNG0AdE6yQBI4l4wSnscWuDlkNcXkXi6mGJ2aSlzGwjk4/ad+GPcB4rEvaHSl3iVpdW202eocWD+j1GXRnw33b8PyIWaJycrDILXEO3XeMLHxNMe2E7FzITqjxnBToKcmFOcSHEkhyBOEJMI87oicFJLkTnZCelwjLt9kXEkuO6SXYShRlLfL3bS47Abqoo9WUFwqnU8MvFI3Yg7KZUPPDg8iuVX3RNXT3N1Xa5+6e45cCcdV1FkordXOkirpuydj1CfZz4q/RQ0sxcyok5D0PTPit5rLVg07bXTsc0ydBndDSGoZr3aWVE7eGRxO3iOi50NI3C7TRm5VZexhzwtG34rdUVRS2Gkjje4RxtGBnZbFypLZSUDKGjcJqguyXNBwB0A71aqY6SKBtPAe0lJySM7dy1BkyU29/gq+iu0FdFxwvD2+IT7pc8lwkkbonFjxghYjmFp5XaFLklwoNVc4IM8cjR8UdXKe7cBzIXLL1p68V9xmcaksgcdgXcl0Vkt1JcZHCsqRC1ozk9fAeK0KKmgqHHt5QwDvWvu2pLQ0EyuZx/eBwfmslWa8gpXOFLI6ZvgRk/NZvUGmnWmlZM6YyuLsOVjpK30lXSFz4WySNPNy9Q/wBHuGKC1fxgufUM5uXT1dfHPRdWKK10tH6dl0rc4001V7p/WEl1ne18ZYByyoes9TyUwFNTuLZHcy07gK39Ejp25YxrB+6MLn92Jmv5DjkcWyy+GKa2Xm+SVbIOSGJhdyE5yR3/AFUFqZTV1c6YR8rGDON9lJorFJWM76plLi7fBSK/T3o7C+BxyOi1dJEO6bt0Sa0RRsJe5rRjqVku4+vLa0zNkwwH2MDlx3YVA3+v7btGu9XPs9Mdyz+nL/I2QU07icnDSVYakqSbe/hOCshVVcTK50lM9r+A59U7fNQJblc7xMDO/ggb7Mbdh8R1+K6W/wBLRQXS3XumaGxzkEjpkHX7LYr4YW1VNXRjDX4JHiCpsNz/AGfG7gh76V3IE4A96r6x1bdj/SZ+CL/dxjAwpbGcbwCpjaYY5LY4vbw9RXR9RcInyyPAIGcNxjTCtXh1upat0k7HPe7XwVXTUbKRvDG0geJ6p4QtGXY9ZTXQYGSmwGvGy4+4cUSVtHFHR0nJBA4EEZOD3Z6ZWHUXaSoha2GHljjIPkowAJGU9wBNSN4HJQl2W5xPZJuKTFe7OO05wA5o3DgANlpXOhfdS2uohzcwGR1BSJoxwOHjlMaatooarAcHHJefinnv2yeiPTUprDPUY9Xi4B+KxKuwU3D9mcLi0elyEcozktb1zjRc/dqGC3W0iqH89xGBnYK/f6wVNWM4ZirzGWqDU0okcCQszhO9xWK4+kTglha5pA312+YC5uwXRlprO3lBLCCDjfX+6TTHiYCnJmbI4YeFuByTz2ZC5WqfHJO98Qw0kkZ7s6LBmcx8rnRjDSTjyVNNGWvJHJM5PQK1kgz0TDoMdF1zOM71FTMpIZuRrRgYAzjz3W83iS6xwNp4peVrRjQDPx3Vc6Jzgeqoa+Hu5T4LWGPCpbxTkethcrUVlRWP7SpkL3d5JP1XOzzzVL+0neXHvJyqIjATZGE88YTb+qgCpJh7cph0alOTbmpUKHJGo7gQVOe1R5IsoTVHyERclujITbmlCYj4kRKTv5okwpCnaasqLfIZKWUxOPtN5td7wdiuz9lH0hhbHRWjVI7qk2bDXty5sXgHdQ354XEgclBzA4EEZBTUocWr33TVEVXDHLDIyWKVofHJGeJrwdwQQngMLxv2Y9r917NJ207muuunnuzLb3u9aLxdCfsnrjkfI7j1jpXVtp1lZY7pZ6xtbQu2ceUsDurJG82kf58jlGcqTQ6hXAGVHq6BlUWvy6OZnsTRnDm/zHkdlJLcIA5QkVa24SUkjYa8NjLjhlSzaN58D90+R28D0T1XQxVY9dvrDk4cwpcsTZo3Me0PY4YLXDII8FVmkqbUM0gNVTD/ANle71mD9xx/5T8CEuUwjuVdWWmSAE442feCrzG+F3EwkEeC1dJWQ18bnROJ4Th7HDhcw+DgdwUxVW2OXJYA13h0SpMqmprtjDZh8QrFkjZm5Y4OHkoNRbcEgjBUMxzUjuIZHmOSEqvPsoDkq+nuoOGyjH7wU9jmvblrg4HqE1CUD1Rg4SeQQGwTk9OhyUHJkFKBykwhPB6W1yYDvFKDkiFID042RRQ7dLa9CFLa9OteobXpxr0IU1sica9QmvTrZEIUxr061+VCbInGyIQprXpxr91Da9OtehMUoOylB3JRxInGvylCFI4kpMB3mlh2yVCdBwjBykA5RoQloJPEj4kJMo0k88I8hFndCVIezOxVLdrcJGEtCvCcpqVgcCmkIXPKmnMTyCMKI5u61d4tucuAWcmhLHEFMUgKiFu6RyKec3dIc3BQlSCMpKWRg5QIyhCbIRJZGERGUITZGERCXjCIjKEJsjCSQnEkjCEJotyklvwTpCIhCExwpJanixJLd0mE9MOZlIcxSC1ILQU1JlRixILPJSS1ILUIyozmJssUotTbmoSqK5qaexSnNTT27oTgojmJtzVKc1NuahKoxBSeH4J8t3SS1CcmC1Ic1PloSC1CFHczITTmKUWpDmoQojmJdFVVNqrPS6Coko6nABfGdngdHNOzh7xt0wnC1ILEI3W/0/2n01TwwXpjKCfkKpmfR3e/O8fxyP3ui27SHNDmuDmEZDgcghcFLPJTrHqG5aYdigmBps5dRT5MJ/h6sPm3bqQU8O71C6LOrV20OTjXrK6e17bb+9lO8m33B3/ss5Hrn9x3J/u5+IC0mS3onquQRoVJDspwHKiB6W2RCapKUmBKnGyZQhOg5RpGco85CEJSIHKGNkAcBCFADvNHxJoORg+alTsp3IR5803xIA5QjKcyUfEm0fEkwjKXxIcSSDlGmpUoHKCSgkwhGShxIkE0hCMFKa7CQgmFSBZHtItk0LaPVVvidLX2lpFREz2qijJzIzzLd3jPUHqVNpauGvpYamnkbNBMwSRyNOzmkZBHwWlY/BWAoaH/AGNv77HjgtVYX1FrI5Rn2paf+6SXtHVpcPsFVpG9QurttXzs7B+428u5XwOE9G7BCZ5FKaVVIW4Sp8b08HKFE9SmO2UZCZlPA43UKoqDKcDZo/FHUTl3qNPq9fNNxRmR2By6lKF8b/iNxpWcU144S4cy8F3K8t/9xw/KD/Q3BLjscZ9kZJMYZDgBCSMxuwVOa0MGGjATFQOJgPUIyq93/B1lo4XmrDIZKyMc5x7HKPaaBucDJ5jvjYKODg5UnQUhl7U2Nbvi2S593eRKKr/shsrqjW1+urh9XTUkVLGehMjuN/y7tn+JTRD1wq34KXqSOSts7z6jmdoB3EENd8Q4f8q7LG4OjA8NkMbpimkweFSVqL6UTfDgoAdEsjKLhShCQRhRLjQNuNI+FziwnDmSN5scN2uHmCAVLcCCktOSlQqmhqX1MLmzNEdTE7u5mDkHDqPIggjyIUgHCj3+M217bqwEsibwVbR1i58fvYST7i7mcKRkOAcCCDuCOqE5KQRA5RpAhK5hGkg4SkiEYKUDhIR8SEJm8Wtt9tU1Gcd6RxxOPR45fPl8VyQFzXFrgWuacEHmCuyxO4XArnnaDav2fexVxtxBWDj26PHtD8j8VQqGZHOF0NrnwTC7rqPuqBhwUvi8E00pQOFTW8QnONDjTZOUAcISJwuSDIBzKh3G5RW2lknldwsYMnK5BeNe3TUla6nt0ZbEDgOYScrrrFw1V30vfEQ2NntPdoAtSit0tdkt0aNydguy+mRF3CJGl3gDujMgPLdcLntepIW98J5ABuQHYKtdI9otVS1baK57gnAeeYXUVHA8jqZ9Rbalk/Jq4N3CuyWMuidJSytk5dwN11S41PcU0kgGS1pOFzy166/a9/dQviLG4OCeuFuJ521dLlrste3n5ELiU7jZ9Yxv9kCXBScH2mku0VbTzszK1hLPAhMs9JBWsnikbl4aS3zXZWwjGVybtJvDqq7ejscQyIYODsV0uruopbU+cuAAbkHzXIKKmde6yrqZBtuce9a34fU8VJPPeKsepCMD/M7RW+HY44HyV03ss095Wy7L7oTSOgJ5dF0IS5auMaCq/Q7u6InrhdZbUDhG6wvxAoxSXyVzdn4cPeqfEEPY3B5GztVInky3mq2oja47pUtT5qHLV+a82yuc5cqh1jRiezztA3aOIfBZfQ1YIqiSJx2cMha651LZYHxk5DgRsuZ01xjsdY+aZxZFGTxHGTj3DmvaeFD/ABPhm5Ww6luHj4fq0LtLU30i11VJ1HrD9+5dRqJ2hvNc5v8A9TdO8HLiyq+s7RLhdQWWi3mKI7ek1e2fMNVZBS3CWqdNV1UlVK4YwMcI+AXIcF3uGz3UPqP8N4LXeR6rMstWyiqg6T2XDBWhr+0eK3xiCCOSefGOFuw+f8lma6tvOpXfXSGmgP2G7f8An8VYClbHLxPi38wpzK2ONuI4cv8AvFbtw/D65yVhdb8SQOOQ7mGAD35K0pbBUdqfR8OYdjkYwqqit4ooxEM56k8ytFSUbIYMBoBI3PVQ6SmfNL3kgPPqrlrPUA6peNK2ngp6OzUz+f0ces4bc3gq97qIwyGhhdzdmNSO9UNXTGKUuA2zlCOvLBhwyrSohDgoT6TB5Ig4xpKyjjpL5S9vyaNdnDsd2UjLzHJC2Gvh7Tl2OcFRZql8+2MDyS4I+EeaebSpxkfCFjXnidtZSi3UEAggBzyg5JPiTuqdXdDURingjEcfcOvmVGlh4hyUR0Tm8lauYCEwY88lyFNX1VHn0eRzM9xI+ixmSSxHMTy3yOFXSx8ML3O5BpKnaQozBZKZ2MGQcfzUW8gttkzWf1koETB4uceEfiVpqWlbS00ULfZjaGj3AJe1kncZJHEnvKwrg8ucOY5KMjbCQ6IFPIcOU5ZSj92AiLVILUhzUIUZzdky9imOYmXsQhQZGqDWU4ljI5qzlaFGkblATCsZVRGKQtKjOC0F4ouMcbRuOaoXAhTgqEjCacE25OOTbuSVNTbiE24pbimnHKEInOHUJtzm+CU4JpwTcpqS4tPRMuaMpwhNuCaVGUg+SHsoEIcKRNRg7q50pqm76HvDbpYqs0tUMCSN28M7fuSN6j8RzBBVL9lLEuBhMSg4Xrrsv7aLT2hNFI1otl7Y3iltUrh63i+B322+XMb5GNz0ZrmyDLDnGxHLC+fUsx44pWSSU9RC4SRVELiySJ45Oa4bghd37JfpPMM8Fm13K2GU4jp9QsbhjvAVDR7J/fG3jjBKcDlScwK9IAb4KBGE4zhkjjkD2SRyNDo5oncTHtIyCCNtwgWEc0qDoq+ttUVXI2YF0FS0YZPEcOA8D0I8jkKKa2Wh9W4Na1nIVUY+rP8AEObPjkefRXGMoiwOByMhCTfdQZGtkb0IO4KhyU+OmWlSH2x1KeKicI28zTv/AKs+77vw28k2ypEj+7e10M3WJ/M+Y6Ee5LlGFWz2xsmSz1HeHRQi2ehfndnmORV+5vhsm3sBBDgCD0KMIyq+C7NOBK3hP3hyU1kjZW5Y4OHkolRa2PyY/VPh0UI081K7IyPMJU7AOyuhtzQByq+C4uGBIMjxCmRytkGWnKEmCngcI+JNg4SkJU4CjDk2DhGHJqE8HpbZFHSg7CEKS2TzTgkUQPCUHoQpzZMp1sqgCRONlTEKwbInGyKA2VOtlQhT2yJxsmFAbKnWyoykwpzZN062T5KC2TzTjZfNOBTVND9ksOURsuU61+U7KE+DhHxJoPS0qEtDO6QCjJ3BQhH+aInKGd8oHnlIUKPUwiRpBWXutvLHEgLXP3UGspxKwjGU0o2WEkZgpkjdXFxojG4nCq3sIKapAUwRsUWNk4RukkboSpBCSRhOEZSUISEkjCWRhJdyQhJIykpaSeaXCEgjCIjKWkkYSISCMIiMpaSRhCEghILd8p0jKShCac1IcMBPOakEYCEJlwwE25qfI2SCMhNKFGc1NPapLhkppwSJ6iuam3NUlw3TT2oT0wWpssT5akuamoUchILU+5qQQnITJakEJ4jCQRhCcmSEktyni3KSWoQmCxIczKkFuEgtQhRJ6dkzCyRjZGHm1wyFd2TXF3sHDGZP2nRjbuKp57xo/dk3Pwdnywq0sTbmZ6IBwggHQrrGn9a2nUbxDBMaetxk0dSAyXzwM4cPNpIV7kgrgVRSxztAkYHAHIzzB6EHofNXtk1/erBwxzk3qiH9nO/FQwfuyH2vc/f94J4cq7ov6V2IPS2v3VBpzWFp1U1woKn+ksGZKOYcE8Y8Sw9P3hkeZVzkgp6gUpsqdbIFBD8JYem5RhTM+CPiHUqK2UhLEmQjKMKGHIwcpsHCMHKtJE4lA5TYOEYOUITgOEYOUgFGhCWjyUgHCUDlMKcEfEjBykoJpSpaCTxIZKZhCBPgjBykoJhCcEtQNQ2SLUdpko3yup5Q4S09SwZfBK3dkg8cHmORBIOxKmg4RglMIUrXlhDm7hZKzXKWuglhrIRTXKkf3FXA05DXgA5aerHAhzTzw4ZwcgWAzndPXq0mSqZc6RnFWRs7qWMED0iLJPDnlxNJJbnbdwyA8kNRPZPG2WN3Ex3I4wfMEHcEdQdwqrm4XZUtWKhmfzDdPRHdPOk4W4HMphmyUoCvBfxb44fYqMWegdionGpG7GHTTxdqB1AyRrhKa0vcAFLZhjQBhMxDhHml8STCufhdwM3higFwrW/63MNf9xhwQzzO7vHA6ZKnOTUj/VKMuUeZ+EYXtszGTxuikGWuBBHeDoUF0zsumZFYa1gbhxqS9xHXLGj/AMK5fTSieBsrcujcXBr8HDsOLTg9cFpbnxaVuuzqo4IrjH4924f8X+Slh/xBlfAfA1O+yccG2uPsmWM+PKHH58oW7bN9ZxclaRPEjAVno5PWVtQTfZK019kFTwNkTgltCDm7pyjUeT2cpuLeTBUhzcgjomIxh4QnBPuYCCOY5LJWsfsW5TWN+0TW9/Qnxgzgxj/u3EDya6PrlbAjKzutLZPU21lbQx95crc/0mnYNjLgYfF/fYXN35Eg9EJzVJ5FKByotBcILrQU9ZTPEtPURtljePtNcMg/IqQ0oSpY5pSQlpChBAc0EOSRCU05KrtW2v8AbGnp2NGZoPro/eOY+Iz8cKxT0L+FwUbmhwwVLFIYnh7dwuJxvyE4HZ6q01fYzYrzIGNxSz/WREDYA82/A/hhVAKyi0tOCu4ZI2RoeNiloi4AIi5Ie7YpUq592uXV9NaY4GEgSuwSOir+zi1MZbRLw4kedz5J3tbgdLRxvA2B3TnZjWtntLGfaZsQvaHZZwKw0/WT18fLK6yXP8Bb2fV3rLWutwDOS5d2iWIUdQ2ribw7b4XYHPBasJ2lhv7GLjgkHl71y3BdfNR3uDszo88pHeCsaySvp6+Ms6nB8cpzQ14dcLHA154nMbwk+5YztDpjT3YTNGCSHZVn2bPcykmB5cWWpfaNT97TRyjfGy7q3vjs/HMkDNGPcR/zarfpi2iv7mN9kkj46qLqHUBk03TxMd60rRkeSkaVtwgtOSPWkGViKPvK6op4HElrDgeQXTqNgip2NwMAYRxmxnDlvjtEB1ke6R3ln1Qm3xjbbTNoYzq5xcfLOiwPEbbqR2DgF2V0mG4ccTTxcxlc51az0e5tnyAMZLlUV/bLTULRQ2W31Gobk0YLYTwQRn96Q7fLI81l8bltdbLdcwdXM5T5j/wo72Wz01NVdSMH3LrctUXcisHqbtcsFgndSMqH3W48hRW9vevB8HEbN8wTnyWEqLbq/XzsX25upaN//wB67UDGwjwe/wBp3mM4Wr072ZU9ngEcMEVDH1DRl5956/ErxUvGzdVyga7rp9fgs3X6m1bqrI+r01Qu/s4T3tS4eb+TfgMqTR26VlPHB9bUFu3eSkuc7zJ6rodPYKOjALY+8f8Aek3/AARy0ocdhgeAXX8NcQzcPTyzNYHh7S0gnA1IOfctKguJtr3PY3m5hjBVDbdNN4Wuncd/stVwLfDAzhjiDfNSo4+FuEotyVyzsFxc1ZJcXKmnoGyZy0FRxb2tGzQFePjBTD4wrra2oYzs2yEN7snHwQHSAcoccd2VXtpwwBKIxlSXgBR5CqROUjW4TDxnKZczKecm3bJVImS1JcnCMpDkJuU07kmyE47kodzuENqoZ6ud3DFE0uPifIeaeB3JjiAMlNR/9I6ko6RvrR0rfSpvI8ox88n+6tUW78lQ6GtU1NbZK+taW19wf38rT/ZjkxnwH4krR8GVda3lGFy00vayFya4cocHknu72R8BT1DlMcCSWhSCxILEIyozmpiRuymOaoVTURQ54njPgnpVGkAUV4wUxWXmFhOHZ9yqqi+/dCYmKxqGtcw5OyzddShspLeRSprpLKTjKjHv5zs0lSBMKZfH5pksHirBlqqJfslS4dMzSEZBSqJUJjCSYx0C18GkCcZCsIdHM6sQhc8dGTyamXQv6MPyXVo9Ixgex+CfZpZg+x+CMpMLj5ppSP6s/JIdRzH+zcuzjS7PuD5JX+y8f3R8k1JyLiZpJh/ZlJNPMP7Mrtb9Kxn7I+Sjy6RjI9kfJCTkXGXQTfdUd8Eu+QQuvVGkWjOGKsqNJjf1PwTE3kK5VLBJ4FRJqcuaWubkHYgrp1RpPn6irp9KO3w1COVI7Ku3fUfZFKykZ/01ptx+stNU84jBO7oXblh643acnbJyPYnZ52m6d7UrUa3T1b374wDUW+fDKqm/iZncfvDIPQnC8V1Wk3HPqKtprPdNO3SG52esqLZcoDmKqpXlj2/EdDyI5EbFHMlGRoV9Cy0OGWnIST4Lz12c/StjnfBbe0GAWyt2Yy/0kf1Ep5AzMHsE+LRw78mgL0BTV0FZSw1MU0VTSzND4qqneHxyNPIhw2wU7KMdycIHxUeppo6mPglYHt579D5eBUkjrzCQTlKkVVJTT03sE1Mf3XHDx7j1+PzSGTMmyGnDhzY4YcPeFalu5UeopIqjHG3JHJw2I9xQl3UMtSHM+KW+nqKf2T6QzwOzx8eR/BIZOyVxaCWvHNjhhw+CcnJiSmY/OW7+KZ9FLDljyCp7mpBZlCMphkj2bPbkfeano3tePVIKGMJJY13TfxCEJ1BNgEfayPNGhCXnCUDlNg4SgcpqEtAEpIOEYOUITgclB+E0jbySYQn2yJ1suFEBS2uTcJymNlTrZVBa9OB6EKc2VONm81XiQ+KcbKmJMKyZKn2S56qqZMn2T+aeCmkK0bJlONflVzJ/NSGTAp+U1Sw7ZGDkc1HbIE4HZ5JcoTucbIcSRxIcWfekQlE7Jt4SicpLjlCFW19IJWnZZitpDG47LaSN4gqm4UYeCcJhQFk3DBTZCnVVOWOKhubhClCQeaSRhKI2SSchCEl3JJSzySE9CSkuSjzRO5IQkonI0l3NCESJyNE5MQiSXc0pJPNCEk8klKckpuUuEg8k2RhOE4TbthlInJDtk08Jx26bfu1JlCaeE04J53JNuCRPTJCSRhOkJCEJpwTbgniEhwQhMkJBGE6RhIIwnITZGUghOkYSSMoTk0RlERhOFu6SRhCE3wpDgnSMJJGUITDwmZGhSHckxIChCgVVNHM6N7gWyRu4o5WOLXxu8WuGC0+YK0dm7U71YA2KvaL9RDbicRHVMHk72ZPc7hJ6uKzVZWRwA5cMrOXC+wxZJePiUoyonYO69G6a15YNXOEVur2isAy6hqB3U7f7h3I825Hmr8gtXiK+6mppy3iY2RzDxMcNnNPiCNwfMK80d9I3Vek3NiqJBqG3A/1Fwee+a3wbNz/xByk5XFQ8o6L2BxbpYdsufaB7c9JdoLo6aGrNquz8D9n3AiNz3eEbs8L9+QB4v3QugvhczmMKM5G6TGFGDkYKQDlGDhXsJE4DlGkJQOUYTEsHKMHCQDhLSISuaCIFGmlCWDlBJBwlJhT0EEEEhQggjIwiTUIIycokExOCUDlVdbb3wzOqaRoc5xzLT5wJP3h4O/A8jjYizz4c0iZ/DG53hyUbttVHPXMtkMlZI7lawFx8gMlVkTxIwPDXNBHJ44SPeOiW3miUQXFrKv0edjoHuOInO9iUeAPQ+R354yBlUQOY5XyrwRTyce8aSXm4+ww9oRuMjSNnkMDfcNPerDiwUC5MOlawEucGgdSdk7Sx1Fe7FHS1FYeQMETnMz4F4HCPiQnY7l9xueGjLijccK77PdDO7Rap1XUukp9J0zyyoqo3Fr657SQYIXDcNBGHyDlu1p4sujkWLsprdQ1DX6jebbZxu+3082amp/cfI3aNnjwEuI+03r2DvIaajgpKWCKko6eMRQU0DAyOJgGA1rRsABtgKzHBnV+yxqquAHJEde/u8lzbteghZdLc+mpoaOlZTCmhp4IwxkTGH1WtaNgAHBVOgpC2uqmA7GLOPcR/NaHtPpzJbaafrHNw/Ag/yCyuiZOG98P34nN/I/omOHLMvji4R/w38S4n7CR7D/zt5T8XZW/jdhyn0kmHBVw2KkwPwQrS+rlo6aTiGE+Qq6klwQrJp4gCpAoymXjCYLcPUtzeaaLc7JUoRjcIOGQjHJBCVYS0s/YOoLpYztAT+0KL/upHHvGD+CTiPk2SMK9DlA19T+hx26+sGHW2bE7v/wAGkw2XJ8G+pKf+6UviwfNCkOuqkA4KdUZj8p9u4QmpYCH2kaCakyhyKUzmkYJ5o0JVku08SupLc4H6pr3hwx1IGN/gVgl1DXNJ6XpyZwGXQubIPng/gSuWu5LOmGH5XV25/NAB3EocWE25+QkvfhNPkUC01R6pt7brQSRO3ODj3rldhu1Ro+7cEwIj34guyVQDxjOyyV/09T3HeSPJ8RzXo3DHEkFvhlttyZz08u4G4PeFtW25MpWPpqlvNE/fvHiFYs11bH03eOqmxjHJ3NYHWGpv9o6hlNSZdEDzHVOP0TA2QkyOI+6NlY2+wU1E7LIhxfePNdBSV3CvD0vp9C580o9kEANafHqcLQiqbTb39vTl0jxsCMAKbpWi/Z1CxmPWO5yntR0puNA6JmOLmMpclXDbqZ89RLHDDGOJ8kjg1rR4klYit19c9UTSUmjra64cJ4H3SpBjpoz1xnHEf9YK8wlu9Q+4G4k/zObm9+VzvbTPnNTn1s596VBRUml2urrnXQUsLP7SV3CB5Koufa5UVjDFpq1moYf/AL4XEmGAeYafWcPl8VZUXYvJcKxtfqa8y3KsG4bG0cEfk3iBAHuaFsKbQunqMDNsiqXD7VVmb8HZA+ATrveK6+1PpVa7L9u7TyCfU1MlZKZql3M7wXEpKSjv1YJdT6ofdKgnIoqNrhC0+TWDf34B966HpaxWUMZFSU8sbAPVYaOSNvzLQFvYooKSPu6eGOCP7sTQ0fIJtxCxSHuxzHKqcwB9UYUWKCOmj4Y2NjHgAidunHjdIcEuMJp1TZGU05gd0TzgknmlwkTRGOSQRzTp6ps9UqEy4YKZftlPuCYkKEKNJ1UZ5T8p5qM8oT027mm3FKcclNkoTcpJOUhxRuKae/CEwlE53RUdNRnV9/bHztFuk4pD0nnHJvmG8z5+5OXapnq52Wqgdw1k4y+Ub9xHyL/eeQHj7lsbJZoLJboaSnYGRRtwB1+J6nxKuRM/MViVtRn+W33/AKKWG4AASg1LDU42MlTrIymgxHwbKFctQUFpy2WXjlH9lHu7/L4rLXLWtZV8TKZjaWM9fad809LqVr6qogo2cU0rIm/vHCz9brGkiyIGumI64wFj5XyVDy+V7pHnm5xyUlsLnnDQm5S4VpW6pq6jIBETfBqqJKuad27nOPvU+nsz5SCQSrmj05nGWpyaThZeOjmnPLAU6m0++XmCfettSWBkYHqqzhtbWcmhCYSsbS6XAxxNwren09G0D1Fp46EeCkR0PkjKRZ+GzMGPVUyK1tH2Vesoh91Pto8dEmUYVNHbmj7KkMoQOitRTeSWIACkyhVgogOiV6EPBWYhCPucJMoVZ6GPBF6KM8lZd0kmIeCE9VzqYeCZfS5HJWzowkOiB6IQqSSiB5hRpLeD0WgfCEy+nHghNws1LaWn7KiS2UH7K1bqbySDTApd0mFi5rG059VV1Vp5pB9Rb+SjBHJQp6Ib7JuEmFy65aVjmY5r4g5p2II5qLpe86r7K6h0ul7gTQucXTWetzJSS+JAzljvNuOnRdJqaAEHZU9Va2nOyUaJhC6P2d/SK09q+pZbq4O0zfTgG317wI5Xf9lLyd7tiegK6syZku3su8CvH180hR3eAxVVO2VvMbbg+IPMKXpXX2suzPgggqDqaxs2FDXSETxN8I5fAdAdvBLlJjK9cEEIiMrnugu2zT2ueGngqXUdyHt2+tHdztPkOTve0ldCZIyUZBT90zZNluVHqKaOoGJGBwHInopjm4TZG26VCq30s8GTDJ3jfuS/o7+eU16UGHEzHQO8Xez81alvMJl8fFkEZCE9RNnDIOQfBEg+gYwkxF0J5+py+XJNkzRe0xso8W7H5IQnEE22oje7h4uF33XjBTiEIIIIJqEoORpCUDlOQlA4SgcJCMHCahOIJIOErmhCUHJQOEgc0pNwlylh3xSg5NIwcJEZTwelh5TAOEoFGEqlMmwn2TlQQUtryhNVi2fzTzZ8jmqtshBTrZShCtWTBLEgKrWTp9kyXKbhTePzQz5qM2UeKWHpyMJ1yZmjDmlKD/BEXZTEYVHcKQHJAVDPFwkrYVMYcCqCvp8EkITgVSOGEkjCekbglMuQnIkhLSTzTghJdzSXckpySeSVCSknmlJLuaEIkk7o3FJJwmIQJwkoEpBO6ZlPQJREoO5pJOE3KElx3wkHwSnJDkISSdimyNk4eSQ7khCbcEghOOSDzQhNOCQ4JwjmkHkhPSHJDk4kEIQmiEgjdOkbJBblKE5NnZIT3ASeSTIGxty9wYB1JS5QmiCk4yq24astNsB7yqY5w+y05WSu3bBR0oIpowT955/RKATsE0uA3W+LDjyUSruFJRNJnqI4/Iu3XGbp2r3Cv4mxOeGnoz1Qs5UX+4VhJc8Mz1JyVIIndUwydy7NcdfUFMCIA6Zw68gsjd+0d7yQJGRj7rdyuePMs/8AWzPf5ZwETYGjkE8Rd5TC4lXVdrCeozwF7/NxwFSVFfVVZJc7hB8E53Q8Eru1IGgbJuCVCEBJy52UfApfdZQ7pSJwCgvpWyDDgCPArpGgO3nV+gjFTis/bdqZhvoFyJfwt8I5PaZgbAbtH3VhO5ShEmEA6FLhe90oHKbBwlDZPUKcBwjSUoHIQhLG6NpSWlGNikKEtKHJJRtSIRpTSkowcJhQlIIIJiEfMYRIIJqEEEEEIQUWtfktb4bqUoFQczO+SqzaNXjv4rXF9Fw/2DDrM8NPkMuP/aB70mNvHI0eJTd3tjaine3gEsThh0ThkEJ+mGZmqW8psI9UlZP4O0witNRVD2nyY9zWjHzcVl7Hqu5aOnA+sr7cOhw6ohHkT/WDyJyOhOwXX7Drahu1ujrY5mVNG7b0qDJDSOYe32mEdQeXXC5VeKBr8yMGCs3DNXWK5ftC01XoNdsH5bxQzgfZlZtxDzGHDoQpw4s06L6EJE2p3XqKCoEjWuY8PYRkOacghSmu4guPaD7QYLvU+iUzBbr2GmSWyzyfV1AHtPp34w4eIwCPtNGxPUrVdYblGTGXMkbs+J4w9h8CFO1wKrOYWqt19AJtM1LsZMZY8f4gPyJWA0e8s1FSY68TT/hK6ZqiP0jTlxbjOIXO+Qz+i5Vp6Tu77QHxmaPmcfqqU2kjSvmH8QB6JxhbKwf/AG/+mQ/YhdNlbwOKON+CnKpnIqKDwlWivqBXdJJsFb00nEMLO0kuw8lbU0uCEBNVkRhNlqdB4mg+KItT0xNY3QxulkbIiEJ6j1lHDcKSelqI2zU88bopI3cnNcMEHyIKxlgdNHbhSVL3SVdC80kz3n1nlmwefN7eF/ueFu1mL3R+gXtlWwYhrmiKTHSVoJa7+83iBJ+4wITgeiDH7qTG7IUMbFPwv3whCl5yAlA5CQ07DCPO6TCEpE3kj5hADCRJlFU07a6inp3ezKxzPdkYXFKhjoJXxvHC9hLXA9CF25hwVy7tDoRQX58jRhlQ0SD38j+Iz8VVnbkZW1bJcPdGeuqy0j8KPJJsiml+ChyTfJUV0eUuWbIVfUuDilSzbc1EkkJKE4JiWNpPLZZPVuvKLTFRFb4IZLtfJ9oLXSbyO8C77rfM+exwcVV51vc9WV8tn0UGPbG7u6u/yjNPT+LY/wDeP92w28ci/wBFaEtmi4pX0/HWXKo3qrlUninndzOT0Geg+OTukAcU4FoVTQdntfqeaO4a1qhUYPHFZaVxFND4cZHtu/DzIW/hjipIGQwRsghjHCyONoa1o8ABsEXFkIidlI1obskLid0ovOE25yInKQ47JE3CDnbZTROUs8khCVIIykEZTh5pB5lCYkHkkO5JZ2CQ7khCbdskO6pbuabdshCaeo0xwFIeolQ7CEKLK5RnuTkjlHe7mhCInZNuKNzk04pcJCUT3Ksu9z/Z0DeBnf1Uzu7ggBwZH/yHMnoAnbpc6e0UclXVP4IWDpuXHoAOpJ2ATelLPUV9abpcWcFVI3DIc5FNH9wfvHYuPw5BTxs5z4LNqqnsW4HtFXGktP8A7Kp3TTv7+tnd3k0xHtO8vADkB4LRtaXHZVdxvtJaR3biZZ8bQR7u+Ph8VmLjfK66Za9/o1Of7GI8x+87qrpwFzoBccrUXLU1BbCWcfpM4/s4t8e88gsrc9UV9yBaH+jQn+zi2J955lV4iawYAwEQjLiABknoE3KeGgKOI04yBzzsFa0llklwXDHkrqlsgGPVQkLwFnqa0ulIyFd0NgzjLVoKO0BuPVVtDQhgGyMqMuJVPSWZkePVVnDQho5KxjpcdFIZTbISKA2kHgnmUvkrFlNjonW0/khCgx0u42UllNjopTYcdE4I0IUZsKV3WFI4Aix5IQme79yHd+SeRE4QhN8ASSxLL00+VCERaEhwATclQG9VFlrQOqEKUSEkuCrH3ADqmJLs1v2k9Cti4Dqm3ytHVUFRew0H1lXTX45PrJuQnrUvqo29Qo8lwjb1CyE17c7O6iyXZ7upRzBNwthJc4/FQprozfcLKPuLz1KadWPd1UZelwtFPc2KvnuDCCqkySO6EpJhlf0KZzo5VKlq2u2UGoLHAlOCgld0KP8AZUruhScxScqzV1s9JcQDLEC5py2RuzmnxBG4Wi0v2sat0SWRmf8A2jtrf7CsdioaP3ZOv97KBsUjvslIOmpXcmlAeQjlB3XcdD9uumNaPbSiqNtuWwNFXjupM/u52d8Ct+eF4y05HTC8iV/Z9+1I8TQcZHsuxgj3HmFcadv+v+z/AIW0VUb3bW/+w3HLiB4Mk5j47KZsmd1GYz0Xp9wwUg81zXS/b7YbzIylu8c2mridjFcNo3H92TkR78LpDJWTRtkje2SNwy1zTkEeRUoOVFshgEck2+EHlsnDzygcFKlyoc1OHDDmhw8xlR/RCwfVSuj/AHebfkVZE7JBaDzCEuVXGSoi9uJsrfvRnf5FBldC44LjGfB4wp5jAKQ+nZKMPaHe8JqVNAhwy0hw8QjxvhNutUYdmNzoj+6UXo1TEfVlbIPB4QhPoKP3s7fbp8jxY7P4I/TI2nD2vjP7zCPxQhSQcpQOE1HURy+zI13uITg3QhKSwcpCU3khCNGOaJKG4QhGgOaCCYhKSgcpOc8kQ25oQnQ9KD0zkBDjQhSBJgpxsyh8fmh3qEKwbPhOtqPNVYmwld/5oTlaidK74eKqxUY6pQqDjmhCnPkBVfVtDgUbqjbmo8s2QhMwqqqi4SVDcFY1J4t1AkG6UJwTSIjKWdgkHJTkqSeSSlkYTM80dMwvlkZEz7z3ABCECMFJccKK27QTk9xxS4+3jDfmeaMyufz29yYSAnpwuSS9I4vBDiUZKEZdkJPxQRAYSIQPJJJyjcUSEJJOUl3JKIwiPghCQeSSeSUeeEl3khCbckOTpB8EhzepOB5oQmjzSSE6GgnqfcFX3W+Wyxxd5X11NRs8ZpQ380J6klqLuyei53ee3zTlA5zKIT3WUdIIyGf4nY/DKw937ddQXHiZQUsFujPIn13/AMk8RuPRM5gF3id8NLGXzytiaOrjhZW9dpdiswINSyZ46NK8/wBwvF6vTy+tuNRMT04yB8gokdrBOTufNSiIdSml56Lp957dHycTKCLhHQgZKxVz15eLs48UjwD0c79FXx28DopDKHHRShrRsE3U7qukkq6o5lncc9AcIMowNyMnzVu2i8ksUJ8E/KUNVW2HCcERVkKE+CU2jPgkynYVcIs9EoQnwViKQoxSHwRlLhV4iQ7pWPoZ8Efop8EZRhV/dojF5Kx9DKBpT4JcpcKu7pGIlP8ARSgKU55IRhe2koHKQ0pQ5oVNLalg7ptLTk9LHNKSBuEoHZCEsHIRg4SWpSahGDujSUockxCU0o0kHCUmIQQQQTShBBBBCEFXzDEr/erAnCh1bfXDvEKtOMtyvE/xaoX1NiZUs/8AaeCfIgt+pCTTf1o9ykvOyhxu4XtKlP5JID6pCr/g/VMks01MPaZISfJzRg/EH4KHVbtOVnrhTgknCv5+RVRWdVOQveQs3XUUdS1gkDg6N4kiljcWSRPHJ7HDdrh0IOV0HRnaeHTU9BqWrbT1rcR0moMBjJfCOpA2a7oH7NPL1TjixFUFV1Ba5rmuaHscMOa4ZBHgmDRTZyMFeqZql81JUUtUzuZ3RuaccjkYyFyW3yCGvppDybK13yIWb0N2rVOjYorbc2TXXTrfVYB69TQjp3ZPtxj7h3A9k4AarxsrJcSQu4o3esxw6joVDOdivmT8Y2ejzW6qbuC/5FhH3XaJhlpCr37FSY6oTMa4faAKjzjBJ8VdK+kmEOAcNinaSTDiMq0p5sYVBHLwPBCtI5MEHKRKVoKWrbjhccKWfWGQcrPxyb5VnSTbYzsUoKYppGUkjISgchAHKVCTjKi3O3tulBNTOdwF4Ba8DJY8HLXAeTgD8FLAyhjBQlCx1PI6WLMjO7laSyRmc8LgcEZ6jIO/Ubp5rlMvlF6LWCsYPqp8Mm8n8mu+Iw0+5nmoeMIUgOVJjk8U+oIdhOxy8J35ISEKS04QwTuiBDhkckecBCVKbsQsR2tQAUdvqOoc9n5H9FtweSx3a0QNO0pPSo/8JUMvsFW6M4naVyKomwFAln+JS6mXZUd9vtDpy1VFzulSykooBxPlf+AA5kk7ADckgBZW5wF2AwBkqZW3CC30k1XVzx01LC0vkmlcGtY0cySeS5rU3Cu7VNmGe06NPLGY6m6N/OOE/wCJw8AVQ1t0n1/cIq+/xOpbJC8SUNged5CPZlqcbOd1EfJvXJytNHqXjfknJ/JShmN1F2nN5fVa610dNbaOGko4I6WlhbwRwxN4WtHkArOMLK0WoW7ZGfcrumvlPIBxBzfPCkT8q0zgIidkmOoimHqSNcfDO6URhMTgUhJJylO9kJCE9A8khKJ2SUISTzSDzS0glMTEh3VIPJLcU2eqehIfyTbuSW4pt5TEJmQqvqXblTpTsqud+SUJuUxI7dMOOUuQplxT0iJxUG6XOmtFHJVVcoigZzJ3JPQAdSTsAOaK73ins1OJZy5znnhihjGXyu+60dfyHM7LL9xUXStZXXLhMrDmCmacx0/n+8/xd8Bgc5GM5vJU6ipbCMDUoqaSW73OK5XRj42RnNJQNGTD++/pxn5N6dStE+8VUsRii/okJ5hpy93vPT4KvYPBPNarecDAXOuJe7mdqUTIw3l13J6lK4dlJpKGasfwwxl5+90HxWgoNORwYdOe+k8PshAGUhcAs/SWuatIIaWR/fcPyV/Q2OOEDDcnxKuYqTJG3uCsaaj5bJ2yiJJVdTWzyVlBQAY2U+KmA6KTHBy2SJFGipcDkpMdP5KTHCnmxY6IQo7IPJPNhA6J4Mwlhu6EJsRhGGJzhQIwlwhJAwj5InOATT5gOqRCccQCkF4Cjum3SDIhCfdLhNuk5qPJUtjG5VZV3mOMEcSE9WclQG53UGouDW9VQVV+Bzgqqnu7n8iU3mCFoam5jfdVlRdOfrKmfUyzHbJRNpJpTvlNLkAKVNdT4qFLcXv5ZUuKyPk5gqxptOcRGWpuSUuizbnzS9CibRTSHkVuYNNNwPVU+HTzW49VODSUmQufR2WV/QqRHp17uhXRY7IwfZClMtTG/ZCXkRzLnUelXHm1TItIk8wt+2ijb0Tgp2jojkCTKxEWkR1ClR6UY3oPktd3QHIBH3YS8oSZWXbppjfsj5J0aej+6FpOAIu7CXARlZ8WKMfZHySm2djPsD5K+MYSDGm4RlU/oDGjZo+SbfQNd0Vw6IJBix0SYTlmbnpikucDoqmliqYjza9gP5rP0mmrxo+USaWvVRboxv8As+pzNSu8uA7t94K6GY9uSbkp2vG4SAkIODuqO29t9VaOGHV9imogDg3G2A1FOf3nN9tg+BXRLFqi06opPSbRcaa4QbEugkDuHPQjmD5FYiptLZQQNvI7hY67dnlKaz06lZJba8HIrKB5hkz728/jlSh/eozGOi70SQk53XDKLXWtdJ8LJpqfUdGzpWN7qfHh3jRgn+JvxWrs/bxp6rcIrtFVafn5E1kfFDnylZkY83YUgIKjLSF0fO+UpRLddKG8UwqKCsgrac8paeVsjfmDhSSCEqYj4kMBFkjoizhCEotRcOEQ3Rg4QhNS0sMv9ZEx/wDE0FN+gRNHqcUf8DiFLBRFoQnqL6LK0+rVSDycGkfklFtU3k+J/vaR+qkcPmgBhNQo/eVTecUbvc8/yS2zS/ag+TgU8ghCQJ3dYnfh/NK77xY/8EaCEId6D9lw94RcYPQo0EIRcXkUM+SIuwESEJXEhxbJJOEXEkwhK4ke6RxIjIAlQll6SZMdU26djebx80y6qj6Ek+QQhSDKQEh8nmmmmWU+pE4jz2VLedY2PT3F+1b1b6BwGSyWoaH/AOHOUxCt5H5TDmFx5Ll18+kxoy1l7aOWqu8g6wRcDPm7H5LAXr6VNwqy5luo4LbGeT8GaT5nb8E7lKAvRsrWQROlme2KJoyXvIAHvJWPu/ajYLY8xwTvulR/u6NvE3Pm/wBn5ErzZce0918k7y6VlbXuznhlOWj3N5BP0HaDa4RgtljHiI07kKcu2za8vV4JEEcNqhPIt+tlx7zsPklUVP30rZaiSSrm/wB5O7jPw8PguaW3tQsMZHeVL2Dzjd/Jaeg7VNMPxm6RM/iBH6JpBQuj0xwAFNB2WOoe0fTMmMX2g/vTtH5q2j1tp+UerfLeR/8AjTP5qMghPCvOLCHEqr/a6wAb3u3D31TP5pt+udNRe1qC2N99Wz+aZgoVyCUefJZuXtM0lB7eoreT+5OHfllV9T2z6Nps5vTJfKOGR3/hS4PchbLcoYK5pWfSF0tD/U+m1R/7ODH/ADEKjrfpIUuCKSy1UnnNK1n5ZS8ju5JkLsxb4lNuewc3Z9y8+130gL5UZ9EtdHTDxlc6Q/hhUNd2r6wuII/aYpmn7NPC1uPjgn8U4RuSZXp107GgnoOpOFSXTXFktHEKq60UDh9l0wLvlzXlysrrrdifTrjWVYPSadzh8sqPFaWg7MHyTxEOpRld6unbxpyky2Caqr3DpTQkD5uwsjc/pA18pcLZZYovCWrlLz/hbj81gIrWTj1VLitX7qeGMCTJT117R9YX7ibLdpKWI/2VE0RAfEb/AIrOm0uqpTLUOfUSu3L5nFxPzWnjtfiFKjtgHRPyBskxndZyC1BoADce4KXHbcdFoWW8DonmUI8EnMnBqoY7d5KQy3+SvG0KebRDwSZTsKjbQeSdbQY6K7bR+SWKRLlLhUraIeCcFEPBXApPJKFMjKcqkUIPRKFAPBWwp/JLEHkjKcqgUA8MoxQDwVw2DyQ7hJlCp/2ePBD0EK47kIOg8kmUKo9Cb4IehN8Fbdx5IjB5JMpcKq9Cb4IegtVoYvJF3STKXC9RpSSjarCzU4OSUOSQ1KHNCeltSgcFIGyUnIS0tIByEbSmoSkbUSCaUJSUDlJR8imlCUgi4kaYUIIE4QSSclIhEkTt44z4jcJaSSlI5hgrOuNDFc6OWin9mRpafeMZHiNx4qCnmv4m+YTcjeF5HToiBws2N3ZvwV8a8J3iXgniB9PXaMJMcg7sHR3jg6+LScbpuoOxVNWHmraoKp6zqtAhfbzHNe0Oacgqnq3c1UVL1aVhxlUtU7molOFFlmwea6laJO+tVE/70LD/AMIXJJnc11HS0vfaeoXYxiPh+Rx+irT7BfPP4zxZtlJN3SEfFpP2W/0f2gWvUr5LfBKaW70mWTUFRhr3BpwXs6PacdOW2Q3OFpnVQe0h2xC8man+r1HVuBfFLFUmSKWJxY+N2chzXDcHzC3uk+3CopWx0epWuqoR6rbpAzMgH/asHP8Aibv+71V5hyAvb7Y7trfTyj8zGn4tBXcy9T6abiiGTy2WTtt7p66niqKapirKST2J4XhzT8Qryjn9oZSrQKuo5gdgrKjnGwKz7Jdxup9PNwkITFpGSZTzearKepBCmxTh2N8pyFJACDeaSDlLHJCE1NAyoifFI3iY8Frh4hZmemko5nQSHJbu15+23off4+a1gGRlRbhQtr4OHPDI3djvA/yQnArMoB2EHtdG9zHtLXtOC09EkDJymp6ejm7t3iPBTGEPbkbhVucFPwS8DsdChGFM6gLEdsMoZYKNnUz5x7mn+a3A8Vx/6Q2rrfpa2NrrpP3FvooTK84y57nHAY0dXHAAHmoZfYICu0LeaZvhquT6t1Vb9I2p1wuUrmx54IooxxSzvPJjG/acf8yQASuE3u93DV12jud54Y2wHio7cx3FFSfvE/bkxzf03DcDnd0ukta9q14F9uFv/YkDwW0ouJIFJCfsxxe0XnYlzg3i6HAAXRrB2LaetBbLcO9v1UObqw4hz5RD1cfxcXvVMAR9dV02DJrjRcitz6m8Sujt9NU3GUHDvRYnSBp8yNh8VrLb2fapqgHGghom+NVUDPybxLtULGUsTYoImQQsGGxxtDWtHkByROJKbz9ylEfeuaUnZzeYiDLdKSP92OFz/wASQrdmkq2BoAropD5xFv6la90ZKbLSE3mynhgCy4s9fBzayTHVj/5qTBUVcG0kbwPMZV6RhNuSZTsKLFMJm5HxRkYTjh5JDk7KVIIwiPJKcknkkTSkE4SHcks8k2TlPTcpLjgJtxS3HITbkJqQ4pl7sJxxTDyhCYqH8LCquV25Uysk6KuecoQm3HKqbzeo7WGxtYamtkGYqZpwT+8T9lo6n5ZOAUXi+OgnNFQtbPX49Yu3jgB6v8/BvM+Q3UChtXdPe8udPUynMs8m7nnz8AOgGw6KVjM6lZlRViP1Wan6KFBRSOqXVlZJ6RXPHCX4w2Nv3GDo38T1U1kDn8mnHirSOhYwZcOIqxtFndd6os9iBntuH5BWg3Oiw3OyS5yp6K1z1j+GGJzz5DYLUW7RjWAPq3cbv923l81q6KgipIRFCwMYOgUyOnGVLyAKHnzsqVtvbTxhrGBjR0aEYgV5LSgjkoEsPAeSQoCapocnkrSGmwBso9FFxvCt2R4AQhMshATzIsJ0MwltakwhJaxLDcJQalowhI4QUEo8k252AlQg54ATLpUT3890w+UNHPGPFCEpzydky7zKhVt7p6RpLnjKzVx1e6QlsI28U0kBC1M9bFTgl7wMKjrtUxx5bHustNWT1jiXuJ8kqGifIeRKiL+5PUqpv09RkAke5QXPmmO5JVtTWZ78eqrel0+dstTdShZVlDJJzBU2CzOcd2rZU9ha0DLVPitTGY9VODO9JlZKlsBP2Va09hAxlq0kdG1mNk+2IN6J4YAkyqaGztbjYKXHQNZ0CsOEDohjBT8YSKOynA6JYjATu3JJSoRcIQ4UrhQAyhCRwoYKXw7o+FCE3goEYTmAhgIQmkE5woi1JhCb4UC1L4UlJhCbLQkFqeI3ROaE3CEwWJHCpBaklqQhOyoxYkOZnplSS1JLUwhKqurtUFWDxMAJ6hZK+aI4w58QDvLC3zmJt7NkA4QuEVGmZLRWOqaIy2+qH9tSPdDJ824z8VdWntS1lYgGftOO6wt/s7nCC7/Gzhd88ro92sUNwjPqhsnQrnt706+nkd6mCPxUwOUzzWqtn0hAA1t309Uw+MtBK2dv+F3CR+K1dq7ZNIXdwY28xUkx/sq5rqdw/wAYAPwK4U6AsdgjCblpo5mFsjGvafsuGQnJeRpXqalrYKyIS080dREdxJE8PafcQnu8HgvJUNlpqWTvaUSUMvSSkldER/hIVxR6n1XayPRNVXDh+5WcFS3/AI25/FCb2Z6L08JG56pXG09V53g7X9cUQGZLRcsdZ6d8RP8Agdj8FYQdv+oY8Cr0rSTH71LcC0fJzP1Tk3kcu88WeoQ+RXEW/SMMePSdJV7PExVMUn6hSGfSUtH9pp+9sPlA135OSYScpXZsEeCAOVx3/wC6W0+Odnvjf/yMf/bIn/SW06B/6pvh/wDyQf8A2yTVLyldiz5ouLHVcXk+kxYxngsV7f74GD/xqJJ9JqgP9Vpm6u/jdGz9ShHKV3LiH3vxSTIPvD5rgM30lJnf1OlJ/wD4lYwfoVWVP0i748HuNN08Z6GWrLh+DQlwUYK9HGpYObgkmrZ0yT5BeXart91pMCIaO00uevBI8j/iwqat7V+0G4gtOoG0jT0pqSMH5kZRhJgr1x6S95wyIk+9QbnfqS0ML7hcKK2s+9VTtjH/ABFeOambUl9JFfqO8VjXHeN1U4M/wjZFR9mkUzuOSAvcftPJcT80YA6peUr0peO3fQdlyKjVtNO8fYomPn/FjSPxWNuX0qtMR5Fts16u7ujnRtiYfiST+C53RdnUUGOGFrPc0K0j0VG3m0fJHqowVIr/AKUWopyf2Zo+lpGnk+sqDKfk0NWeuXb92j3Brgyso7Yw/ZpKRpx8X8RV/wD7IRj7KRJpGNwxwJcjuScveVzC7aw1bfGubcdRXOqY7nG6oc1h/ujZZ024lxJblx5k7rsNVodpBLW/gs/X6WkpicxkD3JwcjlwsD+zyee6W2iI6LSS20tOMYTRo8Hkn5SqjFJjonW0vkrYUo8EsUnklQqoUueiP0NXDaXyTraTyQnqj/ZzTzY35Ixa2n+zb8loGUe/JPsoM9EJ6zQs7SfYHyT7LE0n2AfgtTDbvJWNNaxtsmkppWOj09kbM/BPt04cbMW9gtbdvVUyO1A/ZTCUi5x+wHD7CSbK5v2V079jB32UiTTwcPZ/BM5kmFzT9luB3CcZbT1C3suniPs/gmHWQt+yjmRhZKK2ZPJTYbYNtlfC28HROspQ3ojmS4VVFbcdFIZb8dFbRwtUllMCjKcAqdlAPBPNoR4K3bSeSWKTySZTsKpFIPBOCmHgrL0ZH3B8EZRhVzaYDoliAeCn9x5I+4wlyjCgiHyR90VO7go+5S5RhQRCj7nyU7uEO58kZSKF3KV3SmiEo+58kZS4ULufJDulN7hH3HkkynYUHuUO5U7uUO5QlwoHc+SHcqd3KLuMJMpVAMCLuFYdwiMHkmoXoZAc0kHCUrazEsHCUkc0oHKE9LHJLHJNtKUDgpyEsHCUkJYOU0oSgco0gbJaQoRg4RpKMFNQjQQQTEI8lEggThCERKQ4pSQ7dCE1KOIZ8EypBOEw4YKo1DPzhfL/AOLXDZjlZfadujsNk8CNGu949U9NG9SmZ2EsJCqKpucq8UOrojJ60Y36hEMo9lyf+Hf4gRUsbbPeH8rR7DydAP6XE7AflOw2OmFlK2M7qkqozvstz+xHykcZawfMqdS2mlpI+FsTXO6ucMkpz5WN21Xo18/FCx2lvLSu9If3MOg8S7GPhlcjqGHJXTNFO4tM0eTkjjH/ABuVJqixRR1odTtEbXtyWNGAD5K90lEYLLHGRgte788/qopTzMBXKfiTcYr5wfS3KAENfI12DuPVeCPj3b7rm2t2mHU9eMY9YO+bQf1VCJS3kthrq3mTUVTI0H1msz/hAWXkoXA8lZZ7IXs3C8na2GheesUf/YE9ab7W2OZ0turJaJ7zl4jPqv8A4mnY/ELsXZj2xsu1Qy16gMNHcZCG09THlsM56Dcnhd5E79PBcPdTPb0KQ+HjYWPaHtOxBGydldMQCvaQcWnfZSWTiNjnuOGtGSfJecdA9tFw03HFQXhsl2trcNZLnNRCPDJ9seRIPnsAu66e1NZtV0rpLdcoKhvBl7OLhkYP3mHBHxCeCCq8jXhp5d+izd01bcK6pc6KplpYQfUjicW4HmRzKYh1Rd4PYuNT/ekJ/NKuemq63VDmCCSaPPqSRt4g4fDkfJRmWS4yDLaCqcPKFx/RZhL86r4Fr5uKBXSGpdMJcnPtj4Y0x3Y0xjGiu6btKv8ATn1qpk4+7JE39ACrqj7YqyP/AKzb4Jv+6e6P8+JYz9gXQDP7Nq8ePcO/km32muZjio6hueWYnD9E4PkHVXafibi+36tnl/4gXf8AeCupUfa7apxiop6mmd4gB7fnnP4LR0GrrNccCnuVO5x5Ne7gcfg7BXAXsdGcOaWnwIwkpwncN11dD+LV8pjy1cbJR5Fp+I0/6V6Fu1ubXRiWLHfAZa4faHgs8cgkEEEbEHouU0F7uFrINJWT04H2WPIHy5K3i19c+MOqO6qTjBc5nCT8sfkphO07r0q3fi/aZ8NroXxHvGHt+Iwf+lb5RrrX/sy3TVIaHmNuQ0nmeQVBS6/pJMCemlhJ5lpDx+ik3W+226WSrjiqWOeYiQx3qkkb8ipe0aQcFdzNxlZ663zvttYztQxxaCcHm5Tj1XYJ1x0VXYtdXGS7QRVL2S080jWFvABwZOMgjf55WR7S5aHVGr4KvhZVw23alcd2tl+1K3pnoHdACQfWTcv9W/3FV5bhUO0cRykrL/BW5V92o6uSvmdJyPAbzHJ1GSMnXHcOnRNElIIynS0JGOqjX0qEgjKBAS0lCVNu5JtycPJNuQhNkYKadhOuTTtihGE27mm3dU47ZNOTk0pLuSQTslPPRIdsEKMpJOU2SlE4TZ6oTUk80244SnHkm3HmnpMpt5UaZ4YCU9ISOYyfJXNp0bLcGsnrXOgiO4iA9cjz8EhOFzN+4ktfDNL6Xc5QxvQbuce5oGp+g6kLI91NWTiOGN0sjuTWDJKdrdB6mromxUUMNGX+1U1EgyxvXhaMku9+B7+R6dPV2rTNM1skkNFGeTervPHM+9Vj+0O0h2GekS+bY/5kIbzbgL51q/xR4ovgP+jdsIi/rc1zyfeOVo8Rl3mudQ9kV2tVOWxxRTAZe8sl4nvJ5kl2CSfEqBLQSULzFLE6KQc2vGCu0WvUVBeDw082ZN/q3jDkV90/S36mLJ2AStB7uUe00/y8lKJiDh4WDbvxUulurRR8TUvIOpDS1zc9S0nUeWOuM7Lib25GFfaTrYBQGNpxKHnvGnnlQblbZbbVS0044ZYzg45eRHkqieOSGXv6d5hmbycOvkR1WgxfS8csdRE2aJwc1wBBGxB1BHmF06kma/bO6nxjcLmNq1qHTspqwClquTTn1JP4T4+S3dpu7KgBrjhyeUmFe8ALVCrKbLCQFYREOahLHxNITUuyqrYcTYKugxUoYaepBG26vY8PYHDqkCcUXB5Iw3ZL4dvBERsjCVEOSB5I03I8NBzskQjcQOai1FQ2MbkBVV31NTUAI4w5/gFjblqOqr3EMPdsPhzSEgIWpuOpIKXOXhx8AsvX6onqS5sfqt8VVCF8rsuJcT4qTDQlxGxUZcnAKK8y1DsvcXFP09vdIeWVdUNkdIR6q0dDYmsAJamYLkuQFnKGwufjLVoKOwtZjIV7T0DYwAGgKW2EN6KQMATMkqugtrGAbKUylDeimxQl554HilSwCIZByEc7QeXquWm4ntFPdG2aScCd2MNwdzqBnGAT0Gc/EKIIwEsNwlncoy1SLqUgN2QxndL4dkOEIQm8b4Q4fcnOFDhQhILd0XD7kvBQwUISMFHwpbI3P5DKc9GfjomF7RoSuZruJrLbJvR6yrYx/cXDI8x09+ExwoiMJxzSw4IwUlO3XQQzRVEbZoXBzTqCCCD5EaFJQRkIkqmQQQQQhJIwiS0jGEIREZSSEtERlCEjhScBLIREJuEJBGEktTiCRCZLEhzE+RhJIym4QozmZVfc7YyuiIIHF0KtSEhzchAQuT3+yOp3uIbghZxwLXEFdkvNqbWwnb18LmN8tbqaVzgMeKchpwqjPijSUEZUqGxSHpabdyRlPUeRuSmXRAqQ5JIylymKKYAUg0w8FM4EODPRLlOwoDqUHokGkHgrLu8od0lykwqs0Y8EfoXkrQRJTYM9EJuFVtoAeim0lmM7wA3OVaUdtdO4ABbGz2FsLA5zd0mUiqbPpZkTQ57RnzV/HbWMbgNACsmwBowAliLyTUKu9BCP0EHorIReSU2EeCEmFWegA9EZtwP2VbNhHgnBDnolwlVIbWD9lRKywRzsIcwHK1PcDwQdTgjkkTlx7UOjzDxOY3LenksZU0DoXkEcl6GrbY2eMgtyue6m0xwFzmt+OFIHKMhcyMOEAzCtamgMTyCFFdTnPJO5kYTLGhPsjCDYcJ+OI55JedOwjjiCmQwZKRFErCCPkkLk7Ccp6UHGys6alHgkUsXJW9LBnGyblMKKCk8lYQ0WeifpqfyVnT02cbJpSYUOG3g42UptsHgrKKn25KQ2HbkoiVIqN9qafsqJNZgfsrUmIY3CQ+nHVNSYWJqLKR0VfPa3M6LoDqRp6KPLbWP+yEgckwuePpnMOMIMc5hWzqbE1+cBVNTYXNzgJ4KFAp6lp2d81NYxkg9UhWWnuzyuv7HzNlZTU7SW8cmSXHHQfqoWoNPVula1sFQ5r2vHFHLGfVcPj18knOM4WBDxDa57g61R1DTO3dvXTcd2R1GcjqkGl8spJpsdEinuBAw4Z81PimjlGx3T8ro9CoXceSPufJWBhB3CLucdEqXCgdwldwFNEXkh3PiEJMKF3AQ7lTe5wiMSXKTCid0EO7Uoxod370ZTlF7hHwKT3fvRmMDmkQovdhF3alcAQ7ooTsKL3aHdDwUrukRjSZSqKIwERjUosQLEZTSu2JaQlDkrizAlNKUDhIGyUhOS0rmEgHKUDhOQlgpQOEgbFK5oQlo2lJByjTUJaCIHKNNKEYKPISUE0oRlyJBJJymoQJykO5oycJBKXCERKbdulE5SXckvKCMFVKukgr6d9LUtDmPGCD1B/fu3CTnKCTg7YSllSxiM4BXw9xpwtDwxXCngnEgdqG/naOnN016Hc9wQROeGc/kicSdht5omxKaOmLtXaLvOGPwpqa9jKu8PMTDqGD2yPEnRvlgnvwVBqaX0qQvI8gpNDAKaEsHjlSWxIObw7KadobHgL0f8S6OCi4TbS07eVkbmBo7gNAqW7WZtbUmQtBJAVNU6WBzhq2rWBwzhGYgeifEAWBd3wY8v4doT/wDbaPgMLm82lnAn1VHOli77K6eaVrhu1I/ZzSfZCk5F2gcuXSaUeOTfwUOawvg9qPZddNtDvspdNp91dURwMja50hwOIZA8SVGWqQFRexPWFxp679iVTZqq2cJdHUOyRTO6NLj9k9B0PlnHdY3clmLVZaSyW5tJTxhsY3ccbvJ5kqyoal1NiN54oh7LjzHklGiRwzqFfMepMUxaear2SZAIOcp2N+6XChVxFM2RpB3B2IKbntdFUg99R08oPPjiac/MKNHJghS45cjdIoZIY5hiRocPEZVbUaPsk+77XTD/ALtnB+WFU1fZnYpge7hlp/OOUnH+LK1Jfum5JQAmljTuFz1Rw1Zav/Ho4z48jc/HGVgKvsnpyT6NcJI99myxhx/AhYG/ULLHeJrcahlTLCG946IbNcRnh9+MH+8OuQOoa21tFpmkMVO5st1mb9VGdxEPvv8ALwHU+QJHGWgukLnOdJI9xe97zlznE5LiepJJJPmqcwY0YA1XN1n4WcNVNJNU9gYi1pILXOGwzsSR8lLOCDnkmnUzDyBHuRz/ANWfNRskbgkKoF5N+HPBt7utpfdbPc3Uzu0LeUZ5XYDTk4djc41adk46jyNnfNMuppGg+rn3JxtQ8dc+9K9MA9pp+CXVerib8VLF/iRxVrB1GA7H/wC7Of8Ahd71Cc0tO4x702eatPSIn7OI9zgidTQTDIA97SjKkH4vSW0hvENpmp/EDI93MGfIn3qodyTblavtbD7L3D37ph9of0kafeMIyutpPxb4PqhrV8h7nMePmGkfNVjtimnc1Zus055Oj+Z/kmzY6h2fWjHvJ/khbf8A+onCZGRcY/j/AGVW45KbccFWdTZp4IjJlr+HchpOVVkhPXR2m+2y/Quntk7ZWtOCWnY+PX9eiS44KbcUpxSH9ULZKQTlIcdylHqm3FPTEhxwmnuA3KVI7Cv9MWQVDhWVDTwNP1TT9oj7RSE4XK8TcR0fC1tkuVadG6Bo3c47NH37hk9FL07pwU3BV1bcz82Rn+z/AM/yWR1X2qmpnlt+nnNkYw8EtyBDmk9Wxcw4+LuQxgZJy1HaZqya4yVFho3PhpR6lXM0lrpfGNpG4b0ceZ3GwyTlrdbWxsa1rA1oADWgYACnih5vWevnnh/hmr4sqv8ASbiv1y/WOI+y1u7cj+nub19p2cpyKOaqmM1RJJPM7BL5HEn5lWMdPwjYJ6GnDGjATwYr2F70xrY2hjBgDYDZNQmSmlZLE4skYctc07grqtrrhcrfBUgAF7fWA6HqPmuYcHgtjoSoJp6qAnIa4PHxGD+QVapZlvN3Lw78W7PHW2YXJo9eAjXva4hpHxIPhr3qr7RLc0VdPVNABlaWOx1I6/I/gsNU02QcLqWuYRJbICTgCYf8pXLNQ6nsum4nPuNwgp8DPC944j8Oalp/WjC6D8NK19VwxT9oclnM33Bxx8AQPcs/dbeydjmSMDmlFYtU1FiqGU9e90tKTiOqPtN8n/zXPNWfSFssL3x22CStcNg/HC38Vzev7cL3UPf3dNTMidtwuaXbfNXRGSNV6UZ2NK936fujayFuHB22xzzV6ACvHvYd2/tFfDaruWwSudiJxOGO/d35FeubbXRXGkjnieHMcFEQQcFTgh7eZuyTNQPqZeGNuT4nkFa01vMMQa6TiPkFIp4xHEPE7lOLMkndzYbsvkTiv8Trq+vkprRII4WEjIAJdjQnJBwM7YxpuUwaXPJ34Jt9K4csFS0EwTvHVc7R/ihxNSuBkmEgHRzG/VoafmqitqI6KNz5iI2jmSsJe9VT1rnR0/1cXLPUrpNwttPdKcw1MYkYeXiD4grnd50pNZpxgiWB59SQc/cR4qwycP06r6D4O/EOi4lcKSdvZVHRuch3fynv68p17idcZnuHSuLnEucepT8VEXHZuVd0tnLyMhXdJZWtwS1PwSvXc4WdpLM+TGRsr6hsQbgkK6goGxgbKayENHJPDQjKiU1AyIclMbGGjYJYalJ6YiAwEaMDKPAQnp+nbiP3op3ZHD8U40cLQFHc7icSqMY55C4r5Q4LoxxPxfVXmYZjicXjzJIjHuAJ82hJwEMBGgtBfV6LAQwEaCahFwoiMJSI8kISU5FFxnJ5BNgZOFMY3gaAq8z+QYG68g/EjiuXh23tgo3YnmyAerWjdw8dcD49EYAAwNggSAcZ3SJZOBvn0UNxJcT1VZkReMleEcJfh7V8VwPuFTMY4yTgkcxeep1I0zudcnI7ypskYkbg/AqERgkHmFLgk7xm/Mc0zVNw8HxUsRLXFhXb/hvX1lgvc/C1wO+eUdA5oyceD2+t7h3lMpJ5pSJyuL6fRIIIISZQREZRoISpJGESWkkYQhEiLUaCEJCIhLIykoQjigfMcNHLmUc9K+EAuwR4hT6JuIAfEpdQOKCQfulUzKQ/HRfNlw/EyvpeJzbo2N9HZJ2ZGDzHXlcc53BzgYxjQ6qlLUhwTpOUkjKtYX0mmHsyFl9TWYTRue1q1pCYqacSxlpGchKELhtfSGmmII2yooGFtdWWYxPc4N2WNcwtcQUw6KRpSUlwTgCItTcqRRy1Fw+5PFiHdpcoTQYlBidbHlLEaXKEx3aPu9lIEfklCEkpUKOIsqfQ251Q8YGyk2+2OqXjA2WztNkbTsBc3fwRlMJUS0WNsLQ5zd/BXbYsDYKSIuEYwj4MFCao/deKMRp4NGfFADZCE1wJQZgpYGUAMoQgGpxrETeacaE9CAYlhiMDKcaEITToeIKqutrbPG4YV81uQkTQcQTELjGorGYZHENwFlpaXhJBC7TqC0CeNx4d1zO62/0eZwwg6IBVp2d9mUmtXTVE05pKCB4Y57W5dI7GS1vQYGMk+I2KttedkY0rbv2jQ1b6mlYQ2VkzQHsycA5GxGSByHTn03/Y1Sei6LY7h4e+nkkz48m5/wCH8Ff61p2VWkbyyQZaKSR497Wlw/EBUjI4P8F8qXP8QLvTcYGlZL/q7JRGWYGCMhrtcZ5s5Oc6HTbReZI4t1Op4t0iOPBU2nj3VoFfVql0sauaOLkq+lZyV1SR8lIEwqfSw8laU8PJRqWPkrSGPASFKlMjwE4GJbW7JXCoyhaOz2uOmgZK9odK8ZyR7IPRT6imiqoyyVge0/gkUEglooHDlwAfLZPrOcTzZK/Oy/XS4z3qeqqZXCZr3AHJBbykgAY2xjTCxVdQ+h1ckWSQ07E+CjGJXmoIv6a13iwfmVWcHkrrdQCvu7he4SXWyUlbKcvexpce92ME+8gqIacFKp7X6bURxYwXHHwUgMVzpynHeyykchwj4oceVpKj4rvH8BstTcB7TW+r/md6rfmQfJXNNTspKeOGJvDGxoa0eSwvaRT/ALSqaWEf2LCeXV2P5Bb4kAEk4AWPrQK2pklcPaOfh0VeFuXZXzJ+EttkuF9lukpJ7JpOe978jXzHMVzOotMsJOxUYB0Z3BC6NNbGvB2VTW6eD8kN+Su4X2IszDWvj65HgVYQ1scoAOxTVVZpICcA4UIxOjO4wgEpQ5XYa0jZGI1Uw1L4jsdlYQVzXbO9Up2cp2U8Y0kxhSWgPGQcozGmpFDMaHApRjRd3sjKdlRjGhwKR3eUXdgIylUfgKIxlSeAod2kynqN3fvQ7vZSe6R935IyhRe78kRiUrgKLu/ejKaV1pGDhJByjV9ZyWjaUkHIRoQlg4SkgHKUDlOQlg5SgcJsHCWhCUlA5SAUaahLQRA5RppTEYcjyElBInoycpJOEZOEhCECcJPNAnKCEJLkknCWQmycqOWURjxXnvGfFsPC1Dztw6d+jG//ACP+6PmdPEEgRlHjZADKghiJ/mP3Xn3AfB0s8v8ApHfgXTPPMwO6Z/OR3n8o/KNd8YAaltakSysp4XyyvbHGwcTnvOA0eJPRY65drtjpan0S3ekX6uPswWuIy5P8XIj+HKsvkYwZccL6PgpZ6k4hYT5fc9Ftg3ZIkGCD4jKwTa3tE1Ln0a30GlqV24lrH9/PjybjHwc0e9aPTVir7DSSx3G9TXuplfxmWVnAGDGOFrQSANs481QmqGyN5WrzP8WLXLT8JzTSOGjmaZyfaA8k7dtYWPTIxdbrTUUhHGIpJAZC3lkMGXEZB3A6Kib2y2GpcW2yku17d/8As+he7/m4VqHWW2VdW2sqbdSVNWxoY2eaFrntaCSACRsMk/NWJl9UNHqtHIDoohUPaA0YC7D8OqCnm4VoJXZJLPuVkIddX6s3pNC3HgPJ1bURU5+RJKfF/wBYyn1dO22lH/b3EvP/AAsWlMjsc0252eaaaiTvXpgt1MPyfM/qqIXTWZ3NHYW+XfTH/wAKtNP6w1NZKqSWrsVqrGubwg01wkjc0ddnREHp1CdLgEguym9vJ3p5t9MR7PzP6q6q+100FO6WfSd7qOEZIoTSy/IOma4/JZyn+lBp6Go4b1pzVOm4c/8AWbjayYgPfE55+QUglESCMEAjzTxUO6hVzbIDtkLfaV7YdEankbBa9WWmqmd7NN6Wxkx/+G4h34LdNZuMHdear3pK1X1p9Lt9LU/uzQteD8CFW2/T3+zOG2mquFlY32Y7dXzQQj/4bHBh9xCmFUOoVGSz51jf8QvV7AQn2ucOS8623tH1bbGhpvZr2Dk2uponY+LGscfiSr1nbLe3wGOUU8Lz/b0lP6w9we9wz7wfcpfSGFZ7rTUNPQ+9dkuNzgtVK6oq6iKlgbsZJnhrQegyeq55f+1J8odFZoy0HI9NqGYPvYw/m7w9khYWpvtPcaj0mqnqamoAIElWS9zfEN5hoPg3A8kya+lcdpfm0/yULpydGq9BbWs1k1PyS5XyTSvlle6aV54nyPcXOcfElEz22+9JFTC7lIPkU5GQ6QYOVVKzuKaj0KwV8wGOWKQ+/kOPmlVJ9UDzUdPVJ3amU0LifwjpvR+D6V3V5e7/AK3AfIBIRP8AZRonJV7Gmn8024kbg4KcdzTTzuhK5ocC1wyCjFXNHykdt4nKULtM3nwu94Ud3VNPRhcjW8H8O3El1VQROPfyNB+IAPzU8Xxw5xA+52Er9vMHtQuHuOVUuTT+SXAXHT/hLwdNqKPlPg+QfLmx8lbVd+jkp3sjjfxOBGXYwFQO3CccclNEpQMLq+HOFLVwnBJT2thaHnJJJJJ2G/d0SHFILtkpxTZKdhdYUSZe5Le5VGodQUmnKNs9UXPfI7ggpohxSzv6NY3qfwHM4CVqYSGjJV7abY66VzYznu2+tI793w8s8grnWeoW6dtbaam9WqmaWQhv2AMDP8vP3I9H0dVaLC6su/BBVzjv5YWn1aduNo853Ld8u6knG2FibrUyXu5zVTwfWOGA/Zb0CfEzndrsF8pzS/8A6kcVF59a30RwB0kf3+OSP+QAfmVJT0he/jflzickk5JKt6eDA5JyGgPXDQPHbCpb72h6X0s1wuN8o4Xt5xMkEkn+FuT+C1AF7xo1aARo+FrRuc+5cQ1H9Kmx0JfHZ7ZVXSTkJKgiGP39SfkFyrUv0gdZakD44qqO0U527uibwnHm45PyIUgY4qJ00beuV6uvmrbNpyPjuVwp6Qc+F7xxH3DmVO7F+1C0a6vt3orT3srKSFkkkzm4acuIAB+fhyXgGqnq7hK6WqqZaiR27nyvLifeSvWf0FbC6ntmrLs5hDJpoKWN2DjLGvc8Z5H+sZ7vioqhgbESV5d+I1YBwzVAjGeUe/nb/wCVffTP1xctJ6VsFJa6w0k9fVSF5Y4tcWMYM4Phl4+YXieqqau4yukq6mSd7jkl7sr0d9NjUbbpr+02ZjiW2ujL377CSU5Ix/CyM58/LfzqG+SlpW8sQVf8P6V9Jw3TNdoXZd/zOJHywmWxBqXw+9LR8KtL0RRZYc7tJDhuCOi9N/Rv+kA9s8Wnb/P/AEg4bBO87TDoD+9+fv5+bCMpl8bmva9jiyRpy1zTgg+Ka5oeMKWKUxOyNuq+sUTg+JjgcgtBBTVe7hpX45nb8VT9ntwfdtA6arpJDNJU2ymmdIftl0TST8cq1uX/AFb4hc2wfzAD3r4UsFOJuKKaF407Zufc/P2UWimyA081V3XUtTRVgbBwPjHNrx7XxU2I8L9lUVdD3kpJ8VqPaHDUL7pr7Pb7q0x10DZAf6gCfcdx5g5WgtF9huzcBphmAyY3HPyPVTqinjqoXRStDmO5grL0VF3T2ubkEbghaemlMsQLvaGxWfJDyes3ZfKnHfAp4Xc272lxEPMNMnmjd0IO5GdidQcDXKp224U8jmEcuqkshA5KbVMyWu+CZDcBXo3c7QV9JcI3o3+y09e/2yMO/wAzTg/HGfIpIaErGEoDCGAnLsEQGUeAjwUfChCJGwZcB5ocKVCMvCY84aSuf4hrPQLRV1QOCyN5HnynHzwnZDhhUdPTn1QEyoYBhuV5f+EdEKexPqSNZXn4NAA+fMggggrK9wQQQQQnoIjyRpJOUJCnKduX58FIJDQSeQTcDcMz4pNQ7ADfHdZ7v5kmF8cX+OTjXjc0DD6jXdnnuaz2z8ebHmE093G4lNu5pSSeavgYGAvr6mpoqOBlNA3lYwAAdwGgTlO7hkHgdk9UtzHnwKig4IPgpsg4o3e5VZfVe1y+c/xBYLPxTbLyzTmIDvHkcM582ux5BQUEEFbX0skkYQSkkhCaQgggghIgggghOyiIykpaS7mhKiSTzSkWC5wA5nZImvc1jS9xwArCk/6uz4/mlzbQyfwlKY3gaGjoMJFUcU8nuWZnmfnvK/PY1DbtxH6QwYE0/MB/mkz91UYCSRulpJ5rUX6FpHIoOGyMjKkUEPfT5O7W7lNceUZKyLvc4bNQTXCo9mMZ8+4eZOAPNKp7FTPxLUwtmk+7IMgfBYjtW0rQU1qjuVJTR007JQyTumhoeDnmB1z+a6Wsz2i0pq9LVDBzD2O/FZrXuc8Er424f4putx4spquond/MkAIBPKGuOOUDbAzp8d9VwgBKDUuWIxvII5IAK4vucFI4MoxEnGhLDUJU02JLEeE6GpbY/JLlCabFk8lOoLa6oeBjZPUNvdUSABpOVs7VaG0rAXAcX5JcpCU1arQ2mYCW7q3bHgbBONZhKDUKNNcGEcUDppWxsALnHASy1WNgp+Ot4zyjaSPfyTXHlBKwL/cxZbVUXA7xtJHidmj3nAVvDaKWKERmFkh6uc0ZPxWaudCaGrdGPYO7SfBbFUGp2Djp343IcD+H81VheebB6r5b/DPiW4y8R+jVUzntqA7PMSfWALgR3HQjTofJUKCMjCJX19hoDonWlNJbShCfbyTzR4phnJPs6IQnWBOcHEElgUhjU9Cr6yjEsZ2XOtW2fgLnhq6w6PiCpbvZBcS2L77g3PhkpCMhV5ZGQxulkOGtBJ8grvRdv/ZelLXT4wRA17hjGHO9Y/iSntVjOl7x/wDic3/IVZta1jQ1oDWgYAAwAFWaq/8AoYvH/wCJzf8AIVj5ycr864Kp1demVT95JQ4+bn5+684sZgqXA3dMtapMI3WiF+jxVjSt5LXaRswvFwbG/iELG8byPDw+KylKNwupdnFH3VsnqCBmV/CD5AfzJSPdytJC8947vUlisE9VA7lkOGtPcXHGR4gZI8lYXHTNK2kc6kiMUrBkAOJ4vLdUUQ2W6cAWkHYYWIjCihcXA5XA/hJfK+60tXT10rpOzLSC4kn1ubIydcerp3ZKWAlAYQAwjU5Xvy0Fhl46Ms6sd+B3/mrJUen38M8rM+03Py/81eLPkGHFfBf4jUIoOJqprRo8h4/4gCf+rKpNRMxJC7xBH+vmqgBX9/jzTxv+67HzH+Solbi1YF9RfhjUip4Wph1YXtPucSPkQkrS2aHuaFvi8l3+vks8xhc9rR7TjgLWsYI2NaOTRgJk50AXE/jNc+xoKa3NOsji4+TBgfEuz7lDu8/cUTgD6z/VH6rOgZVnfJu8nbEDswZPvKrsYUsLcNXYfhhZ/wCGcOxSuGHzkvPkdG/9IB95RAYR8APNGBlKAyp16wo8tFFMCC0bqordOtfksCvzy80T3hoOTgjoqdTV09GznqHho8VbpKGpr39nTRlx8FgquzywE+qcBQxC7iAAyT0XRJAyXhLY/WH3t0ZpBLjijZt4NXD1PGVJGcQMLvl+q9CpOA62Uc1TIGeG5+yxtLbLhjMcDnN8CrGKgrHAcdM5pWojoyBtsnPQ3HqVgv41qs+rG3Hv/VdCzgOiaPXncT4YWaFqqSMdycJD7dURjLoiAtOaNw3yU1JRk88lKzjSoz68TfdlI/gOkI/lzkeYCyvBlEWeC00lOeDh4G49ygyW6Lhw1pa89Sdl0FNxfRzENmaWfMfv3LnKvge4Qgup3CQfA/D+6pwxH3amy0T2E4bxgfaHJM8C7GGoiqG88Lg4eC4Kop5qV5jnYWnxCY4ERYpHAi4fMKwq2VH7tFwbqR3aHAhGV0ccksHKbalA4WiFn7JQOEtIBygDhOSpYOEpI5hGDhOQnAcpQOE2lA5QmJxGCkA4Sk1CUjyUkHCPOUhQlcSHEkoJqXKCIlAlEhOQQQSXnGya54Y0uKwb1eaWw0MlfVnDW9OpPRo8T8tzoCkvdnYckQCDRkrOan1vFZK2O1W+kkveoZm8UdtpyBwN/wB5K87RM6ZdzJ2B3xSYO0d2smy8C4QsNbx9eHcQ3ZuYgfUadjjOGj/cZ1/qdvn1lfVtbT22llqqueKlpohxPmmeGMaPEk7BYh3aDc9VSPg0ZaHV0YJa673AOhpG+PCNnP8AMDBB6EJyi7OJ79WR3LW1ay9VTTxxWyEFtBTH91h3kPTidzGxBwFuW8MUTI42tjjYA1rGjDWgcgB0CbLVOOjNAvsymtkUPrTes7u6D9Vhoeyz9sSNqNXXip1BMDxCla7uaWM+TG438xjPULZW230VlpxT26jgooR/Z08YYD5nHM+ZTxOUSzzvk7rbBJAaNAOg0HwCcdITzKQ4kndAHCLOSgFeH/jKS3g+fHV0f/cCjBwgXEoicIiUhXVfhu0DhG3Y/wD2Y+pRkpJ3QSCcpQvSkZOUh3NKQIylSZSEXTdK4UAMoTUhNubnYjIT2NkjAQmqHLQtect9U/goslM+Pm3bxVtwIYCEmVTYKNrVaugjed2BJ9Hjadm/ihJlRoYyHAlWFKPXJ8kzwgclIpB7RQvKPxTq/ROD652dXBrf+Z7R9CUmpPr/AATXIJybeRyZJTltcEUvofDNvhO/ZMJ83NDj8ygThIJwjJyknmlXbpB5ppxyU444KaccFORlNvO6acU48pp5QjKbcU08pxxTLzgJ2EhKbcU04jdKkco75E7CjKDnJtzwEh8mOS5n2t9s1D2cQGjphHcNRSNzHR5yyAHk+UjkOobzPkN09rC88rRqoZJGQsMkhwAtpqfVdLpiCFsjTU3GpB9FoWOAfLjm4n7LB1edh5kgGu7LaSl1bq6or6mvgu1yo2tdUOgPFFTAk8ETBuGgkEkc3cJJ6Y8YXnUl31NcamuudfNV1NSQZXudgOA5NAGwaOjRsF7i7D9M0PY52MNr7m0Us0kTrncJHOaTuPVaDnGzA0AZ3JPInCtyRCCP/eK8F/EjiyagtLoaXSSc8jMb67n3DQdxIVd9IHt5oOzuqprCykfca+WMVE0bJAxkbMkMDnb7kgnGOgPVed7z9JbU9YXNt8VHa2HkY4+8ePi7I/BYLWuqavXOqrnfa8/0mumMpbnIY3k1gPg1oa0eQCpOAK9DTtjaAVPwraBw7aIaBo9YavPe87/DYeACur7r7UepeIXG81lSx3ON0pDP8IwPwWdMJfzUnhCBGVZ5QNl1BcXbqOIQEfAn+FFwJE1MluF9Bfo86YGguxq0is4oJZ4nXGp71obwcfrDIHLDA3nvseXIeS/o+9mJ7Su0GkhqImyWegcKquDiPWYD6rMcyHOAaccgSV6R+lp2j/7J6DFhpJeG5XzihdwndlMP6w/3shm/MOf4LOqT2jmwtXhPH9Q+919JwvSH1nuDn/7owcZ8m8ziO7HevH3aNqmTXOur3fnl2K2qfJGHkktjG0bc+TA0fBZvh96f4UXD7loAADAXt1PBHTQsgiGGtAAHgBgJngRFuE+Wou78kqsKPwpJapJjRGLyQhfRH6PFw/afYrpKYhoLaPuPVOf6t7o/n6u/mrvtD1rbNDWqjrLtO2lpaisZSiZ/stc5riOI9B6vNc++iFcjW9jVNTl2fQq2eDGeWSJMc/8AtPLmq/6acXfdj0Tf/wBqQf8AJIsAN/1jB718c0MRo+PBGOlQceXMSPkuv0kkdXEyWJ4exwy1wOQU5JTgleEuw/6SF27KqiK2XYS3bTRIAizmamHjGTzH7p+BHX3TpPUtn17Y4bvYa6G40Mw2fEd2nq1w5tI6g4IWk5pbuvt1kjZBlqW2PhOwUujdwyY8QlyUrmdEUMZEgPgVC8ZaQuc4mohcbLV0pHtMdjzAyPmApEwyxMKS/dpTCgpz6pXl34PT89knhP5ZT8C1v3BREYCMDCMjCJWl7uggggmoQTkXMptORdVDMcMK81/EecwcL1ZG55R8XtB+WUU/MJpOy+0mjsUsQwwK1wDAKfhmiYOrSf8AmcXfdBBBBSr0BBFkIE4SUJcoycokEuIcUgTScDKzblWNt1FNWP2ja53/ACglSWjhaB4KK93G8lSZXcMZ+Shk4VWAbuK8A/CC3OlNXe59XuPID/1P+JLfgUZOEknKBOUSuL6QQU6PeNvuUFTYDmJqq1GwK+fvxkh/9NpZ+rZCPi0n/wCKh8kSU/23e9JVkbL3mml7eBkv9QB+IyggggmqwgkkYSiUlOyhBBBBJlCCSeaMnCSnJSgnaVnHOD0bumlNomYjLvEqGV3Kwrzv8Qbt/COHah7Th0g7Nvm7Q/BvMfcpCZrDimf8PzToeC4t6jmmK84p/eQqLB64Xx5wxSvPEFBFIMZkjPuy1w+I1VaknmlJC1l+hKCtqKHuYG/eduVXUsPfztafZG5VlWTdzA4jYnYKjOSSGBfOf4pXCa41VJwxRH15HBzvecMB8N3HyBSopmzF4b9k4z4qFqCET2ySMjIcR+aO0uyZR7inboM0h94UPLyyhoXmLLNFYeOqa2xatZJFr35DXZ+JK4vqKxmCVzmt28lneAtOCuwXS2Mq4yCFgrxYHwPLmt2V0hfbjSs8BhLaE4aZ7TjhKk09vklOA0pilyo7WZVhQW59TIAGkq2tumnykF42WqoLOylaMNGUvKSmlyh2m0NpGAkZf4q2bHhPsgwnGxZ6J2FHlRxHhH3ZUnusI+79yXBRlRCwhXlihMdO955vd+AVd3fuV9SxdzTxs8Bv71XnOG4Xhf4vXL0ayMomnWZ4z/lb6x/6uVOBwJIB3HMKp1GzighPg4j8E/b5jJV1BPJ24+GyF7j46Rvk8fkVXa3lkAK8asFql4b40oqSY+t6h9749R7iS33LLubukFqmPiTDo1or7bTCUOSUWokITrCpEZyozNipEaEKUwKRGExGFJYE9MTjRlPU0AfO1xHs7pppwFNo24a53jsoZThhXnn4gXL+GcOVUjThzxyD/j0Pwbk+5OyTNiLA44L3cI9+M/oq/VP/ANDN3/8AxOb/AJCn64cdRTj7jw78UjUMfe2C5MPJ1NKNv4Cs4t5cHvXx221Ptj7ZVyf+9h2O4CTA+IAPvXnVrU9DzSQ3BwnGDdXwv0MVhTdF27TNH6DYaKIjDu7D3e925/NcYsdKa+401MBnvZGs+BO67y1oY0NaA1oGAByCrznYL5m/Gi4csNJbmncuefcOVv1cm6t3BSzOzjDHHPwWNhWtuj+C3VJ/7Mj5jCycG4SwbFWvwXixQ1k3e9o+AJ+6dA2RpYYj4VZX0apVnfwV7B0cCD8lolmaI8FZC7l6wC0ypzj1gV8f/jJTdneaeoA9uPHva532IUC9jNF7nBUPDlX96/6n/eCo8bKWH2V6v+EQI4cOf/2jvo1SbVD3lcw9G+stA9wY0uOwAyVW2SLDJJCOZDQn7rN3dNwg+s84+HVQyevJyrybjkP4o42jtMJ0byR6dPzPP/Dk5/yqjmkM0r3nm4kpOClIHZaGy+voY2U8bYYhhrQAB3AaBIJwgSOpwPFAuABJTIa6od14egXGX7iBlsb2MOsh+XmvQOHOGJLu7t6j1YR8T4D9UDMZBwxjAPU809DSuecu3PmpNNRctlZQUnkvFaqsmq5DJM7JK9ygiprdEIaVgaAoUNHtyUplJ5KwipOWylR0nkqJcq0lV4qsbSeSX6N5K1bS+ScFLnom8yqGpVMaXPRNvpPJXnouOiQ6lHgjmStqln5KPPRQ5qPyWmkpPJRJaTyTg5XI6rxWVmpS3OOXgoVRTiQjbhd49FqZ6TOdlWVNFz2WrQ3CegkEkDsfQp1ZSUd2hMNU3Pj1HkVnZI3Ruwf/ADW/0RpeF9IampjDnP8AZB3GFm6O3GsrYonAkFw3C6vRUraKlihbyYML6s/DuSO/NfWSs9jTHTJ7l8X/AIsMl4Zcy3wSZ7XXI35R3rm+utPNtk7ainbiN+7scgsm08R8F2XU1sF0tMsWNx6wPuXHHxmKQtcMEHC0eJbeKKr54xhr9ff1WTwddnXGh7KU5fHp7ui3wKMFIBwjBysNdelpQcmwcJWcoQlg4SgcpsHCUnISwcJSQDlGDhCE4DlGDhIByjBwmoTgOUaQjBwhCXxIicogcoE4TE9Ggk8SPITkxxawFzjgBAu4Qm93HzKDjkrMaju1bXV3+z9kl7mve0Oq64DIoYj185HDPC3+8cAb5cj+2fjoF8vVTqv8U+JWWyiJFJDkk9OUHBefF2zR0GuPaTd61HXXW6S2DTTmenRYFdc5G8cNvB6Y5Pl8GchzdsCFb6c01QaUon09Cx7nyu7yoqp3cc9TJ1kled3OPyHIADZLsdlotOWyKgt8Pc08e+5y57jze49XE7kqdnKje8uwOi+1rXa6Wz0rKSjaGsYABjuCUSgggqxWuAgThBBGBlInhEgjwUSMLwb8bHhnCTm98jB9T9kk80EeN0OFC778P4+z4Utrf/tMPxGfuiRcKURhEhd9lJIwiwUtBCak4KJLSSN09NKSRlFw5S+FDhQmJHAiwEtERlCTKbISXDKdIwERajCTKaUimGGE+JTRHgn4/VjHzSEL59/G2pMfDUdOzeWVjcd+A531AUWR2Xu96Qd0Z5oicJ2F7nR04pKaOnbsxob8BhJSHFKPJNnmnAKykOKbcluKaeU5CbcU08pT3Jh7kuEJL3JiR2yU9yYe5OwmkpEj0zwOkOGjJUa/3q2aWs892vVdFbrdD7c8x5no1o5uccHAAJPReTe1n6QV07QxNa7O2ay6adlrmZxUVg/7Qg+q39wHG5yXbYnjidIdFQqqyKkbl2p6Dr/ZdC7WPpHU9o7+z6Pmjrbjuya7gB8NP4iLo9373sjpxZ283ySS1c8s88sk88ry+WaVxc+Rx3LnE7klNxQhoAAwOgT7RhbEcTYhgLjKqrkqnczzp0HQLoXYLoJnaF2lWy3VEYloICayrY4Eh0TCMtOAdnEtac49rnnC9DfTB7QX2LSdHpikc5lRd3F9Q8bcMDCPVz4udjl0a4Hmh9DfR4teibhqCWNvf3So7uJ5ac9zHkbE9C8v5fdGScYHnjt21o7XnafeK9k5mooJPRKQ4wBDGSBjyLuJ3947DkKf+NU+Dfr+/ovn3H+k/GxDtYKEe7n/AF5vjyLn2Ai4UojCC0l7mk8KHClIAITUWArCwWKu1PeqK022B1TXVcoiiib1J6k9AOZJ2ABJ5IWSxV+pbpT262UktbW1DgyOGJuSSfyHiTsOq9t9h/Yfb+yKzPu12fBLf3xF9TVvcBHSR4y5jXHYAD2ndceCrTzthb4rhuKuKqbhql5j60zvYZ1J7z3NHz2GquNFaWsf0fOzGZ9bURhlMw1Nwrw3BnkJwAAfe1jW9dupK8UdqWv63tN1lW3qsc4RucYqSF2PqYA4ljNuoyST1JJ6rd/SG7cJ+0q9PtVrnczTFI/EYaSPS3j+1cMA4+6Dy58ztxsN3UVNCW5kf7RWDwTw3UUXaXm6+tVz6nO7QdceBPUdBhumCm+FDgypDYS7opEdE5x5K4V6yoIj8ksQE9FaR27xT7aEBNylAKphSnwSvQyeiuhSN8Er0Zo6Iyl5V6Y+hXXn/ZzUts+zBVxVI3P9owt939kr76YUXe9k0Lf/ANpwn/gkWC+iFXei6zvVBkNbUUAl36lkjQPwkK6N9LPH/otiz/8ArGH/AJZFjvGKoe5fLV1pfRvxGixs98bvi0Z+YK8L1FBkHIyFa6B7R9SdkV9F007Wupy4gT0snrQVDR0ezr79iMnBCRWytGeQCsNFdn1b2gVx4OKntUTsTVZHP91vifyWwcY9bZfUjQ7mHJuvavY59JmxdrVvLZqWW03WEATwvBdFnxa/qPI4P5rrQayZgfG5r2HcOacgryxp6xUelaKGktkIpoYuQbzcepJ6kro+k9bz22RrDJ6p5xv9l38is4uGdNlq8vM0td1XXyMhNlmyOGUTwxyDk9ocPiE85oVWm2IXzr+DpMcdwpz+VzP/AJD7KMRkIEZTrm4SCMK0voxIIwiS0kjCchEnYuRTYBPIJ2MFrd1VnIDcLxL8VbjTNsb6ISt7UuZ6vMObGc55c5xp3JuT2ymzzTkntFIdzUsfshehcJ8gsFCGHOIo8+fKM/NEgggpCurSXc0SB5oJEIJ2m3cT4JgnKk0oxGT4lQTHDCvLfxMrvQuGpwDgyFrB7zk/9IKcfGJAAeSZfS7eqfgVIQVFsjm7FfJlm4tvNh5WUM5DAc8p1ac75B7+8YPioBGDgok7VDhk5cxlMLSa7mAK+67HdG3q2wXBox2jQcdx6j3HISlMpzmFqgqdTf1Dfj+ahqPZC8m/GL/6DD//ADm/9kiiSk94/wB5SEqX+tf7ykqZp0C9gtf+wU/+Rv8A2hBBBBLlaaCCCCRCCI8kCcJJOUuEIIIIJyENyQBuSrNoEUYHINHNQaRneT5PJu6k1r+CHHV2ypy+s4MXzV+I8j7/AMQUHDcJ0yC7HQvO/wDwsBPkUmjeZHyuPUhJuJ+qaPE5RW/+0+H6orkf6se9Nx/Ox+9ll+hxM/E5lNC3DGcuB0AbTgj6KEkJaDIzJI1o6nCu7L6mmmZTxOmlOGtBJPcBqSrC3xcMReRu78lEuM3eTcA9ln5qye4QQk8g0bKlfl5JJyTzVSIc7y8r5x/D6F/EvEFbxRUt0BIZnoToMf5WYH/EpVrOJ3DxapNzOKU+8KHbsiqb5gqbcRmkd7x+abIMShUOKoxB+IlDJ/WYT/1Fv2VMW5USpoI6hpDmqahjKtr6jWbl0vEX5ACmUlkigAy0K44fJGGpQE7VMR0zWDYYT7WAJYajAwnJqSAB0R7JWMo+FLhCRwhAt2S+EIcKMISqaLjmYPPJVlVyd3TvPXGAo1viHG5/gMJVxdkNZ8Sqb/XlDe5fM/FA/wBJOPKO1DWOHlLh/wDvHfEcrfNR7eeGpHmCFLuDeKld5YKg0/1c8Z81ZVQ4qeQeSSUYkaVFx6z0LjW2Vw2cY8/8MmvyIVC+LKYkhU7hykFgKuYX06q50Pkm3RqxdEm3QhMT1CDU9GEZjweSWxuChCkRDkpTBso8QUpgT0xK6hWMDeCJo8lXsb3j2jxKsZHcEbj4BVJznDQvnP8AF2pfUmgs0OrpHc2PHRjfiXOUSR3HITnqpFXEJqWaMgEPY5uD5hQ2qwG7R5hNnGOVY/4r0MdsitXYDDYg5g8m8mPoV57u9udb6lzSMNzsojF03VenBVQuc1u65rJC+mndG8YcCrBC+pmuBGQtf2a0Xpmo43kZbBG6XyzyH5/gunXKr7mst0AO80xz7g0n88LH9klGBS19URu57YgfcMn8wra6VRn11aqZu4hY5x8iQSfwAVJ/rPPgvkji8/xzi+pjOrKaB/u5YnOz/wA7gFd31/Baag+QHzICzFKcgLRamfw2abzLR/xBZqjdkBSwD1V334OR8thnf3yn5MZ/dWTGZCMsSouQSy1WCF7umWjheD1BytPzWbLd1ooTxRMPi0FVJ+i+ZvxphyygnHQyD48hH0Kh3j/qrf4x+RVKrm8f1DB+9+irqeAzzsYOp39yfFozJXYfhjPFQcJGqnOGNdI4nwG/yCuaCLuaSNvUjJ+KrLnN3tSQOTPV/mreeTuIXvx7I2Cz5GSSTuU2Eczi8ri/wsopLtdq3iSpGuSB/meeZ2PIYHk5JJwE3nJPlzSpCEXAQ0NxgnfPks69XIWykdN+bYea+wbFbDdq1sH5dyfBNcHfyZA2HJWVNSIqSm5bK3p6cAL54mmfM8yPOSd19GEx00bYYhhrRgBIgpeWysIaYBRprpQW6Jz6irhiDRkh0gB/NcZ7S/pJ0dsjloLA30mpOWulILeH3Y5qekoKmufyQtz49AuXr7pBSNLpXfqupXLtBsVlvdPaqipBq5nBrWtwQDjr4LXwxtkja9u7XDIK8o9ifZpd+0DVsepr4JHU8UneDvhvJudiD03XrynpWwxMjaMNaAAPAKe7UkFBI2GJ/M4D1u7KxKC4T1jHSyN5Wk+r34TDYPJK9H8lMEaMRhYWVf7VQvR0h0HkrDu0RjRlAlVTLGI2OceQGSsbau0Ww366y26mqR6Sw8Ja/Ayc9F0GemEkbmHcOBBXkLtq7L7r2f6n/wBorC18dOXcbTCN2HqcfFb1ppKevkdDK/lcR6vdnxVCvr56NjZY28zQfW78L01NTDmN1X1FNkHZcj7NfpIUVzgjob+PRqpo4RI0F3EeW+eS7FT3SgucTZKarhla8ZAbICfllQVVvqaKTs5WH7HyW5QXWnqmc8b/AOylaXtYFQ6dw2GwytWoNpayKnDRgZ3U5fenBNmFkscFOR6zhzO8zqvz1/EG/O4h4hqKrPqNPK3ybog4cTSDyOy5Pra2fs27vkAxHKctC7ZZLc2uc/jGQNliu0yxj0OQ44pIfZWjxBStraN7W+0zUfdUeE611uuEbnH1JPVPv2+aouJGkZCMHC8iwvoRLDkpNg5SgcJUJwHKMHCQlA5QnpYKUDlNg4SgcoQlpQOU2DhGDlCYnAcI+JNg4RhyanpxBIQQhLyERKQDlHyVGok/9tu5XgH4m8Tvia3h63azS458bgHZgx1f1H9ON+ZVWpr26xWszQxCprZpG09JTn+1mds1vu5k+QKTpyxNsFuELpPSKuVxmqqkjeaU+07yHQDoAAmn0puero53jNPbICI/Azy+18WsaPhMVdHmqxby+r3L3X8POFI+FLIyHA7eT1pD3no3Pc3Ye89UAEoDCIDCUBlRFeoBADdK/BG3mjwEzCXKRjxQAwlHKHDlJhOyiSTsUrGEk8ykIwvnH8dp+ThuCIbumb8Ax/3wgiS2g4RcKTC9p4Vi9HsFvhP5YYh8GNSSMouFL4UOFLhdTlI4UaPBQwUqaSk4JQ4UrBQwUJuUkjCLBSyMIkuEwlJx5IEJeCiSpmUgjISSNk5woiE7CblNOCcPqxH3JJGyXL/VlNcNl84/iw4Vd0sNs3Ek2T/zRt/+RUNyQ5Lcm3FPwvo1JdzTbilOcmnOS4QkucmXOSnlMPclwmJL3bKO92UuR2VEqZ46eKSSWRkccbS98j3cLWNAySSeQA3TsJcEo3uysD2odsth7LKfgrHftC9SN4oLVTuHeEHk55/s2+Z3PQHBxy7tW+k+I3TWjRDmzTDLJr29uWM8RC07OP75254ByHLzu8S1dTNVVU8tVVTOL5Z53l75HHmXOO5JV6KmLtX6Bc/W3RsWY4NXd/QfqrvXOvr92m3kXG+1Ik7vIp6OLLYKZp6MbnnyyTknAyTgKlZFhONYAlALSADRgLkXuc9xc85JRBql2y3T3a40tBSxmWqqpWQRMA3c9xDWj5kKPgrsP0VdLHUHa1R1T43Op7VDJWPIyBxY4GAnx4ng468J6ZSPfyMLu5Yt4uDbVb5653/ttJ8yBoPecBemO0i6R9jXYdPFbpTDNRUUdvo5Y2Yd3pAYH4zseb8k8x1Ox8Cr1J9NXVP/ANDum43/AH7hOwj3xxEb/wDfdPBeW1Wo2Yj5juV53+GlA6nsxrpdZKhxcT1IBwPnk/8AEi4UWGqXb7ZWXeqbTUNJPW1DgSIaeMyPIHPYAldc0b9FLW2pS2Suhg0/S5aS6udmUtIz6sbcnI8HFqtPkYz2jheg3G8W+0s566dsY8TqfIbn3BcZ9y3HZn2Oai7U67gtdN3NCxwE1wqAWwxjO4B+0790fHHNem9J/RA0hZWskvFRWX+pGOIPd3EJOc7MaeLy3eVubt2p6C7N6dlqfdaGjFIO6bQUDe8MODgtLIweEjPI4PNUX1fN6sIyV5JdPxI9KBpeG4HTSn83KcDxDfaPvAA652R9lHY1Y+yW2vit7TV3GYYqLjM0CWQfdGPZbt7I+OVnu1bsz1n2r1Jt37dpNOaYYSO4p+OaaqIIw6UeoMdQziIBAJyccOXvv0wbZEeGy6fq608WC+slbCAPEBvGT18OnuWDuv0pdbXJpFL+z7S3o6np+N3I/wC8Lh18Og881WQzl3Od/FcNbOFeMaiuN1kY0THUPlLSQe8N9bGOmW6dAtjb/oU2aJv9O1LXVLsc6eBkQzt0Jd5q2b9DXRrY/wD1pezJw+0ZocZ8cd1+GVxKs7a9c17uKXUta05z9SWxD5MA8U3R9smtqGXvI9TXBzuIOxNL3oyPJ2Rjy5FWDHUHd69Bdw3xzIOZ10aHdwBA+TB9F1DUf0PHU1O+bT96FRK0ZbS18fDxc/7RvXGAAW4z1C4bqLTFx0jd57ZdKR1HVwn1mO3BHQgjYg+IXpnsP7fa3W97/YN+igFdKxz6Wpp2lgk4QXOY5uTvwgkEY2b47m1+kzoynv2gpLu2Nja+1OEjZcHidETwvZt03Dt+XD0yVGyaSOQRyrNtHFd9sd7jsfEmHiQgBwxn1tGkEAAtJ0ORkd+mF5A4UMBGkk5WmvodGcBJJRFyQXIQurfRlr3Ufa3b4Q4AVUE8JBGcgRl/w9hdw+lY1o7GrlI4kd1UQOGPHvAP1XmjsYubbb2saWlcQA6tbAM+MgLB+Ll7D7YNLQ607O7rZ6iR0cM7oHPcznhk0byB7+HHxWXP6s7HeX1XzdxpH2HG9smGzjEP/wB4QfkQvCfZ52cVnaJXd/Nx01khd9bOBgyn7jP1PRejKK001noYaKigbT00LeFkbBsArmis1NaKGGiooWwU0LQ1kbBgAIPpT4KSSUvPgvp+OIRjxVSY8IY4VMkpyOijujwosqbC77YXiSx254OQ6mjOf7oUbT2qILzE1j3NbORt4O9ykaeZ3dgtrM54aaIZ/uBcRpbrLaq1/duPdh5PBnzVeB2C5fN/4TY9Ou7W7czP+6RegXNTTmrL6V1xBdImQ1EgD+TZD+RWrczbIV7dfRmMbphAjKWW7JBGBlKhOMGGhGktcMYKUDlZD2uDjzL89eJbbc6G5z/xJjuYuJ5iDh2ToQdiD0x5dEERY08wEaCaCRssCnqqqif2lPI5ju9pLT8RhIMLTyyEgwHoU8gpBK8dV3dD+IfEtBgNqi8dzwHfMjm+aimF46fJIc0gbghTUFKKg9Qu8o/xkuUeBV0rH/5SWfXm+ir1OiHDG0eSMsaebQfgjUcknOMLneNuPWcWUcNLFCY+R3MckHJxgY0G2T0QQQTc07YW+LugUQBJwF5bQ0FTc6hlJRsL3uOAB+9AOpOgGpUerdmUDwCZROeXOJPMoiStNg5WgL9COH7Z/BbVT2/OTG0AnvO5PxJSlNpt4G/H81Xqxpv6hnuUNR7IXk/4xP8A/Q4Gd8o+TH/qoUrvrX/xFI4kcn9Y73lJVgbBey21vLQwN7mN+gR8SPISUE5aKVxIslEghCCCCCYhBBBADiIA6pQkc5rGl7jgBTaFnDEXdXFMV0nFLw9GhTQBFH5NCqnHicSeZOVVi9Z5evmr8P2HiLiau4ilGjSQ3/i0HwYMHzUy3+y/3hN3E+uweSeoB9U4+aj3A5nHk1DdZinWwCp/E6okH5A75Rtb91GUu3xZeXkbDYe9RFa00fdQtadjzKkmdhuO9dr+KV5/hliNNGcPnPJ48u7j8MNP+ZR7lLhrYx13Kr0/USd7M53Tom8FPjbytAXV8GWb+BWOnpHDDyOZ3+Z2p+Gjfcl0ZxUx+9WNaM0r/h+ar4BieP8AiCsaocVO8eSgl/xGleP/AIhN7HjC01PjH/0y5+6p+HKGN05wo+H3q4vpdN8KUBlLDfJHwoQkBqMDyS0EoQk4KHClI8FKhI4UOFKRtbxOAHMnCFHJI2JhkecADJ8gp1GzggHid1Dqnd5M4jkNgrBxEURPRoVZzVOD1nF6+cvwyjdeLzceIZR7RIb/AMR5iPcA0eRSQcEHwVrIOKNw8QVWKzjPFG0+ICKjTBR+MTDEbfWt3Y5w/wC0j6FVBai4dk8RgkJPCrZX0e1we0ObsU2W5TbmZT/DlEWpE5Q3MwiDVIe3KSGpiEcYUhvJMsG6fZ0TghSKRvFPnwGU9WOxFjxKTRN9RzvE4RVjvWaPAZVQ+tN5L5kqn/x78So492U+P+hpd/8A3DhR1YRHMbT5KvAyp1P/AFLU6oHqhbv4yQ81oppv6ZMfFrv0VfUwtkL2kbErAax0qXB08LfWG+3VdFl/rXg+KYmgbOwscMgqcagL2m0y9vb6eb+pjT8WgqB2eURo9K0vEAHyl0jgPM4H4ALP0NWavtNe7OeGSSP/AAxub+i3sbWUNE0YwyGPkB0AXMOz+R1TqtkpADiJHuA8wf5qg3XncvlmwO/iH+kt5drmOUD/AP2cx08g0Ld6wcG2j3yNH5rM0MnLdX2u5DHZ4vOdo/4XLK0c2CFPB7K9V/CRnLw3nvkefoPstPTuyFIxkKto5wQN1YsOQrC9mREK7pHcVLEf3QFTEZVvQnNKzyz+aqzbLwP8Y4eazU8vdKB8Wu/RR7v/AFcfvSbTTgB0p5+yEq6tL+5aNySf0U2KMQxtY3kAoi7EYHevMqm9/wAN4BpLdE7D6hz8/wCRrzn4nA8RzBQ7tJiJjOpOVVg4BUu4Sd5UuHRuyhyFWo24aF9C8AWz+FcO00bhhzxznzfqPg3A9yRnLwDuOqfii4356dE1TbyOyOis6WFePcZ1ZfVtpwdGj5lfWHBNMIaJ9Ud3nHuCfpYcAKo7R4743SVR/s9kXLibw4ODw9VpaeMABWMMbcYOCF57FJ2UjZMZwc4Oy6isJmY5mSM9RuvH8nZR2k6yqM17Hvjz6zzIBhdM7Pvoq0ltqYqy9zmrcDk0727D4r0DDG0cgB7ll+0ztFpOzixPrJgJJ3A91FnBcV0rr7cKwimpwG50w0YXButNHS5nmJdjq4rV263U9spo6enjbFE0Ya1qnNavFGoe3ztD730+GoNHQkkxtLAcLrfYX9Ik6xqm2i9YbXOxwTE44yemFBV8O1tPCah2HY3wckKOG8000nZDI7srv7WJXAUtBcplbHMU3wFE5idUO73OCz2+erqHhkUTS4k+5K0FxwN0c2Bkpbm4UK426C5Uz4KiNssTxgtcOa8ta2+kTqu+18/+zDXU1FESOPAcCofZ39KS9014jptSS+lQPdwukwG8C60cNV4i7ZuMjXGdVjC+Uvadmc47+i13aB9FeiuU81bZZzRvdlwgY3Yn3rD6U7I9daO1LQFwdHbRMO8f3gO3XZeuaKsiudDDVQuD45WB4I8xlQrsz+ivI3IGVr8P3yqNfT0tThzC9oPMNtQqV6tMBoKiop8teGOIx5Jm21PdxMaXZIHNW8dUCOax1LWY6qyirtua/Q4xAYDdl+eriSSXbrpekTxQTO/eGFR9o0TWtaHDaRpKtNBzd7QSnPUfks/2oXBhmgja4ZYCCsUM5qhzTtr9FtN9WnaW75GPisElA5CbBwlArwhfT6WDgpSbDkaEJwHCUmw5GDhCenQcoJAOUaEJYclJCCEJziR8SbyUfEhCXkIZSOJORjbKgkeI28xXKcT8QQcNWySul1ds1v8AU47Dy6nwB6pQGElzt8I3HhBKZzvlUqdpe4yOXgf4aWia+XSbiK4+tyk4J6yHUn/hGw6ZGNkmhZhs0pwHyyuc7HUtPAD/AIWNT/Mpqm/qf7zz/wARTqa/c5X3LBjsWY7h9EYKWCMJOxRjmocKdLAPNKSA7olZ2ykQjQRA5RpuEIJo8ynUymkL5U/HqYup7dSN1LnPOPINA/7k6OQQ38kaCXC+pKaMU0LIW7NAHwGEk+4Ikvh9yHD5IwrPMkI+FGWoYCEnMkoJWAjQmkpCCN3NEnYTMoJJG6PdFnfKXCaSgRhJdySicpBKdhNyi6j3oTex8UY9pFL0TCPWAXzLxTILh+JlpohqImh3vHO/6NCiP2TLinZDso0j1JhfTgROKZe7mUHyAFMPkS4SoPemJJAASTgeaTU1EdNBJNNIyKGNpe+SRwa1jQMkknkB4rzn2pfSligfNa9EtjrqlpLZLxK3MER/7Jp/rCPvH1duTgVKyNzzhqqzzxUzeaQ4+p8l1rtD7UrD2b28VN4rOCWQEwUcIDqic/utzy/eOAPHcLyP2l9smoe1OR1PO42qwh2WWynefX3yDK7YvPLwAwMAHc5GuqKu83Ge4XKrmr6+Z3FJUzvLnuPvPQcgOg2SQ0BaccDY9TqVyFXc5ajLWeq3u6nzTcUDY2gAAAdAnQEEYGVZWKiSgMIAYRoSZQXsL6G2lxbtFXS+SMAluVV3TDjfuohgb/xOf06dennTsi7Lq3tX1ULXTTCkpoo+/qqpzeIRRggbDq4k7DPiehXvTRek6PQ2l7dYqBz30tFHwNfIAHOJJcXHAAySSeXVZ9bKA3sxuvBvxSv8EVD/AAaJ+ZXlpcO5o1GT3kgad2vcvLHaT2Vay7Z+16+Vdvtxp7XFIKaGvrmugpyyNoblpLeJ4Lg45aHc+eMLcaI+hvZLY6Ko1NcZbzJw+tSU+YIeLr6wPG4cuXD+i7jqTWVj0hT99ertSW1haXNFRKGueBz4W83HyAK4vrL6XNooJH0+mbbJeX4OKupJghB6ENI4nDyPCqzZJ5QGxjA/fVcLRXvi6+U0VvssRjhY0NBaMaAY1kdjB/ykFdo03o6x6QpRT2W1UltjDQwmniDXOA5cTubuZ5krHa8+kDpLQsklM+qddbi3INJb8SFh8HuyGt35jJI8F5T1j2s6t18x8N3u0honEn0OnaIoceBDd3Y/eJWSZC1qmZR5OZTldfavwqdLJ6Tfakvcd2tJ183nU+OAPNdP179I3VeuIpqOmcyw2yQ4MNE4965v3Xy8z58IaCNiFy2OmA5p8ADkjV9jWxjDRhe5220UNoh7CgiEbfDr4k7k+JJKJrA0bDCNBG7mpFsIkEEE1C6/9F6wyXPtLbXgDurbTSSlxdj1ntMYGOuznfL3Z9G9sVQyl7LtTPkOGmikZ8XeqPxIWT+jNouTTOgzcqlvBVXh4qA0tAIhAxHnxzlzh5PHmqD6VeuoKPT9Npenla+srJGz1LWv3jiZu0OA+87BGfuHyKx3ntagAdF8nXeV/FHHccNNq2JzW5H9MZ5nn482O/TvXlwnKQSjJSCcraX1mg4pp78I3FRK2buYJH/daSjCFf8AZfbavUPaXYxTlzILfWwVU0sZxjhkDmgeZxj5+C+gt+j7yzVjf+zJ+W68s/Ri0kKe0xV0jM1EwNW53jxbMH+Hf4ler6tgmo5m8w6Nw+YWNWuy9q+evxNb6Nc7TWH+o/8AS5h+65UaTKako8dFpW28noiktmRyRgr6cyFjp6Tnsq+amIPJbKothH2SqyotvkkRuupWZpbZ6FpGCIIxj+6FwGrGKiX+M/mvQ1LEYKaKM82MDfkFwOupyKmXbHrH81Xh3K+ZvweeJay6SDYlh+JkUOnqpKSQPjcWldG0h2jcAZTVxLo+Qcebf5hc4dEQcYSQ0tORsQrYOF9MkZXo6OWOrhbLC8SRuGQ5pzlEWri+mNbVdhla1zjJATuw8l1qzX+jv9MJKeQcf2mE7hSh2VEWkKWls5IOahHyKhn9heP/AIqx8/DUjv6XsPzx90iT20hOSjcJtPi1YF0PBUjKzhqhc4ZHIB/y5b9kRcQdiUfeO8SgRlJT+Vp6LppbPbZ/8WmY7zY0/UIzK8faQ79/j+CJJLUzkb3LPfwvYX+1QRf/ANNn6JyOWRzwCdlIUenGX58ApCozAB2Avk/8T6ehor22loIWxtaxuQ0AZcSTk48MJqpcWxeqcHKgu9bmCp1R7A96jEZViAerle2/hNTRx8P9sGjmc92TjXTAxn3JrGOiNKRFqsr2zKTgKwgGIWe5QMYVhHtG3yAVSo2C+ePxkk/9PpIRuXk/BuPuq13tH3oktBWgvoGJnZxtZ3AD4JCCWglUiQglosBCElBKwEMBCXCSnqRnFMD0bumuFTaNnDGT4lQSnlYV5t+Id2/hHDs7mnD5P5bf+Lf4N5ihWO4YSOrtlX8KlVr8yBvgFHTYhhqp/hnbBbuHIXkYdMS8+/Rv/SAfeptCMQe8qNWHNQ7ywplKMQNUOoOZn+9Rx6yErz/go+l8d3Sp3De0A/8A6jQPkCkU8QkmaMbcyp9S/ghcep2CboWYa5/jsEitflzW+G6V3rygdyjvZHFnHtPbRrFTe13er67vicMPkomChwpfCUOFXF9NoMGHtPgVYzjML/cVXgAFWUm7He4qpP7TSvm78Vh2N0tNR/vO+TmH7qr4fJHwpfChwq2vpFI4UfClcKPAQhIwEaVgIIQnIKfvBknDfzTxpGeJTkRBjbjwSlnPleXHVfEfEXHvEEt1nENQ6JjHFoa3QANONe86a569w0UY0fg75hCKlcyUOdggeCkoJO2eRglZ0n4jcRzUklHPOHte0tJLWg4IwcEAfdM1WTFgAnJ6KFwqzQIB5gH3p0c3ZjGFtcH/AIht4WojQmk5wXFxcHYOTgbcp6ADdVfCrCnOYWozBGfsj4JTGCNuBySyyiRuArvHPHVt4rtkVPTxPZKx4d6wbjHK4HUHOckdFXytAkf7yk4ClyUvG4uDsZ6YTZpHjwPxVpsrCBqvdLJx7w9PRQRvq2teGtDg7LcEAZGXAA69xITBGyTw9E+aeQfZSTG8c2n5J4c07FdvBfLVU/4FVG7ye0/QqO5mEnh9ykFp8CEgtSrYa9rxzMOQm2tTgGAjDUqNnE4DxKNkyaZlPE6aQ4a0EnyGpU+BnBE0dcZUac5lcpnJQnes9x81Th1eXL5b/CsvufENddZdy0n3vfn7FIUumOY/io3CpFMRwkealnHqL0j8V4e14ac/+h7D9W/dM1AxK5JYOJ4HiU7UAd58EUABlCcDiMHwW1a7h6NwXFW51jp8+9rMfUJ6oaHQSNO4c0g/FZOy6ZFs1QKmLaExu9UdDstZUH6ojxKaphl5J8FWYP5ZK8Z4Wg9G4AulSd5C4e4NaPqSs32iyBtvpGnmZSfkD/NZCmmxjdbPX9DLW0NOYhnu3FxHwWBjJjdgjB8FLD7AXq/4Ws5OFoD3l5/6yPstHR1XCQr6lnD2hY2nnweau7fWYIGVNleslaHmVZ2//q+PAlVMMgkara3jFP8AEqGb2V4p+LYaeHQT0kbj4O+yedEHzMed+EHHvSnu4GOceQGUaj17+GAjq44VNo5iAvlS0U019uNHbXHIJDB4NLi531cSqtzi5xJ5k5TEruakcKjzYwtQL9DmtbG0NaMAJ+gaHxZ81cU0YCq7SOOA/wASvKSEyPa0dTuvn67wyVt6kgjGXOdgL6BtVRHRWOOaQ4a1vMU5x920nGwTJurWHmtMyljbCIy0EYxnC5Vryqdp65kE8MchJZnwXo1//Dufh6ijqy/nBwHDHsk/bovPuCvxBpOMrnLbGxcjhks1zzAb+Rxr5LdUl3Y4jdeaPpU3581/t8LiXQwuJ4QdjsumWbUvfvAD8rDfSG0fVaktNNc6OIyup8ukDRkkLi7TFHT1zHv8V3nE9uljo38g2XINT64pbjZGUcEWCW8JOQcbKl7PK2S360tE8bi1zJ2nY81nnNLHFrhhwOCF0zsH7Pq7WGs6GeOI+h0sgkkkI2I5EL0KpMVLSyOccNwV41DzzTNDd8he9bJOaq00krvafG1x+Sm4CZpKZtLTRwt9ljQ0YT3Cvnd2C4kL1caAZQwFyP6T9ymt/ZVXmDia5z2DjaeW665wrE9sOjXa50HX2thw9+JB4+rk4V+3PZFWRPk2Dhn4qtVtc+B7WbkFeJtOa6pLVYPR3xZnaDvketlYWpqDUVT5eRc4kY96kXqz1ViuM1HVwugmjcQWPGCjsllq79cIqSjidNNI7Aa0ZK+gmNjYDKDodcrywl7yGY1Xtv6P18lruy+jlqOLvGyvYOI74GMLY1l1jILXHY7YWN0hZv8AYnR1Jb+L1gO8d5EgZCprvqbuZCC/C8jkhY+pfLH1JI+K99tNtfLTMZIMnABWlqJO6mc5u7CcpbK7bmsjb9RCpcBxZytLRwR1QBBIz5r6h4b/ABQpYaRtNemkOaMcwGcgd4718ycZfgrXNrH1VkILHHJY44IJ7jjUK/tGsauxh4p3gNfuQRlUt5vs93qXySv45HHchSnWqOOF7iSSGnqszbXulqZRnIB2KnrfxKobnUegWhhy72nkY0xsB91hW38Kq62UzrleHj1MYYNdcjUn7LRg4SgU2DlKBwsZdInAcowU2DlKBwhCcByjBwmwcpQKE9OAow5NpQcmIS8hGkIIQl5KPiSOJHxISE41KcjHGfJPpLG8DcdUb3cLSfBY00hlfgbdF8RcacQTcXXpsFJrE08kY7ySAXebjj3AeKblfvjwTed0kuyURctNjAxoaF9eWCzxWG2Q2+L8g1Pe46uPvOfIYCdgO8nhxbD4D/NOFwHXCYjd9Yf3hj5f+Z+SiXqukoaVroIDVVMjhHFDxcAc4gn1nYPCAASTg8tgTgGnI31iF6vQStfTtJO2nwU/vmfeHwQdUxMaS6RrQOZLuSyQsV6uUodX319NCdzS2uERD3GR3E8+9vD7lp7ToywzxNkkozWyNO7qyeSck/33FNEEjtNlLJXQRjOp8h+qbfqK2xHeugJ8GvDvyTR1ZbQdpmuPvAWpgs1upgBDb6WH/u4Wt/IKR3MbRgRsHuCf6K7+r5KibvENmE+/+yxv+1lL9nuz/wDFH8kk6sg8Ih75v8lsS1o6D5JDmMPNrT8EeiH+v5JP4zH/APsvn/ZZel1A2rlYxjGO4jjLZM4/BWEsogjMjgSG7kDmp1ZBCI+LuYy8HZ3AMj4qE+mFZG6IuLAR7Q5hVXwljwwHK+WPxIq23vjW0W8N9VpZnr7Unrf9LcpuK60sv2yw+DwpbHteMtcHDxBys3WUslDN3chaSd2kH2h7uiRHOYnZY4tPiCkIIOCvsIcr2hzDoVqCd0OJUsN4kaMPAf58ipcd0jfzPCfNJhMIIU/2kMDxUdlVG/k4fNOCRruRRhMynNkWGog4IE4S4TMozskkjGERKLiS4TeZAnoiIwhxJDnp2E3mSicJBckuflNufunYTeZPR75TdU7BCch3YD4qHcJeCQDPRQjWRfJFlq/4v+LE9QNRF2jR/wADOz+Zz8U1LIoUs3mkT1OcgbqqvF3o7Jb56+5VkNBRQjMlRUPDGN95PyHiVPhfXw0GSp7pMrGdo/axp3suoRNeavirJG8UFtp8OqJvAhufVbsfWdgbEbnZcQ7S/paTTd7btDQFjclrrzVx7nziiPLpu8ePqjmvPlTJVXSvmrq+pmra2d3HLUVDy+R58S47lXY6Yu1foFz9Zd2RepBqe/p/dbXtM7ZtR9rM7oqyT9mWNrsx2qmeeA75BkdsZHcueAMbAbrHxRiNoa0AADAAQYwNCUtJrQ0YAXIySyTOL5Dko8lEjHNKTlEi4UaCAGUmEIIwMowMJ6OAuSoXV/ouXe627tZoKW2sY+KujfDWB7MgQgcZOehBaMHxIHVeo+33U9XpPstu1Zb6mSjuD3RQQTxe00ukbxEHoeHi38Vxn6HGlWyXm+X6RjSKaFtJC44OHPPE4jwIDQM/vHzWu+l/czDo+yUA29IrjMTk7hkZGPd9YPkFjy4kqg3996+aeIY4Ltx9S0jWA8nJzae1jLznv9XA+S8r1tbWXerfV3Crnrqp/tT1MrpHu97nEkoMYAEhuycaVqr6YYxrGhrRgDolI+iJGOaFKEpBBBCVHxIkEEIQXSOwzsyk7QtWRSVMR/YtA5s1U9zSWykEEQ+93X90HyWb0FoK6dod+jtlsj/emqHj6uBnVzj+Q6r2Rb6TT/YroFkckzaa3UTOKSZw+snlPM4+05x5D3DkFSqJuQcjfaK8m464r/hMH8Mt55qubQAaloOmdPzHZo9/TWfrbWVs7ONLy3OtAZTwgRQU8WAZH49WNg9wPuAJ6LwvqrUlZrDUVfea5wNVWSmRwbyaOTWjyaAAPIBaTtV7Urh2nXwVE4NPboCW0lGDkRtPMnxccDJ+AWFclpoOyGXblTcBcIf6OUpqKoZqZB63XlG/KPq49T4AFIJwkE4SzyTbj81cXqqS4qBdxmgmxtlqnKHchxUU232ShKdl7I7CqBtNYY4mjAZTxMHuDcLtjRmMDxC492HStnskDx9ulif82rsUfsN9wWLV9F8/fjIMU1BINw5/0b+ipBA0dEDCPBSJG4e4eaQRhWQMr6NhkE0TZRs4A/FRnUjXcwo/7Gjlmj6esPzVjjfCepGcU7fAbpjsBpKyr5WC32upqyfYY4+8A4+asVyWps+52+BXWXnDSfJUstFDOMPYPeFUp2ggrwL8FWFrLg/vMY+HP+q5VU2kgnZQJaJzOi6lVacZID3Zz5FUNbYHxk5YrXKQvprmWEdAQn7fX1NqqGzU0jo3g9CrqptJaTgKBLRFvRNxhOByuiaZ7Qae6BkFaRBUcg4+y5a9mCOJpBaeRC4G6mLTkbLoPZpd6mpkqaOeQyMjYHsyfZ3wR+ITZTlhyvMfxJh7Tharx05D8Ht+y3UnIJrBTzhkYTZBRTnLMLm/wlrhU2A05OsT3D3HDh8yfgkIEZQQVle1eSSglYyiIQlTkA5lO53ISIR6nxQa7MjgsyQcz3HuXxHxfTvvF/u9S3XsAD/yujjPyJPuSaj2B71HUmcZZ8VGVmD2F7x+E7w7hwAdHvH0P3REZSUtERlWF7Ikqc71Yz5BQ2DL2jzUuY4id7lUmHrNC+c/xSPpV0tNAOrjn/icxo+hUAhBKQVtfRiSglIIQkoJWAi4QhCJBHwocKEIgMkAcyrFjeBoaOiiU0fFID0G6lSHhY4+SpTnLg0L5Y/Fi4PuF0pbHAc8uCR/vPOGj3DX/iUGV3HI4+aRgJeAg1vE4DxVwaBfTMMUVupGxDRkbQPINGPoFOiHDG0eSgPHFI4+JViTgKHTx8UgPhuqUJxzOK+Xvw5uLaKO8X6o2aAfMkvOPecD3qVGzu2Nb4KDK7jkc7xKmzO4Y3FQsBPgGcuK6D8I6KSpfW3yoOXvdy58T67/AIktSQMo+FGgra+kMoKfzZ7woPCpzPYb7lUqOhXzn+MrS2CgmH5XP+YafsoOChgpRQVrK+jGkOAI6pOChgpSPBSZSJGChgpeChgpyEcUro9sZHgnfSR90pnhQ4VE6Jrjkhef3XgXh+81Jq6un/mO3IJbnxIBAz4796e9JH3SnhuFFYzieApLjhpKqSsa0gNXzn+IPDdqs1dS260MIkk1OXE7kNaNc9QUj0hucbod+zzUfhQ4VP2DF6+fwk4eLQC6TPg4fdpUnv2eP4JTXh/I5UThT1OMcSjkha1pIXC8Yfhta7DZprlRySF7OXRxaRguDejQdM96cdI1pwSAUO9Z94JqoaS8e5NYKVkDXNByn8O/hhbb3aae4PqHtdIMkDlxnJGmngpXesP2h80feN+8PmoaGAnejDvW678GqA+zVvH/AAtP6KZxDxCGA7oCoXCi4U30fxVP/wDRprDmK4Fp/wD5f6PCm920/ZHyRhjRyaB8FCGQpNNnhJJJ3THxlgzlchxTwNXcM211a+4F7QQOXDhnOn9RG2T5BOk4BKggYUyQ4Y73KIpKcaErtPwZp+WlrajHtOY3/lBP/wAkE/T7cSZAynoPaPuUsvsFelfiJD2/C9Y3uDT8HtP2RVAPEPcipx65Pklz9EIBsSos/wAleben9n+F4eDqW8n/AO9LT8soVG4aEUA3KE59Ye5HB9pN2iUb4/QPwuwd3gH/AJpQf+1N1jBKGtIyFlb3plkvFJE3DvALXTbn4JosDhgqWP2AvUfw+i7Hheib/uk/Fzj91y2WmkpXkOB2T1NUFjgtvc7JHVtJDcO8lla2yy0ryQNvFSr0TKt7ZW8WAStXQj+jNPjkrnVJI+F4zkLa2a6xSUrI3kte3rjmoJgS3ReOfinbq+5WSOKgidIRICQ0ZOOVw2Gp1I2Vuq+4ScUob90KwztlVMr+KRzvEqGEZdlePfhHa/SrzJXPGkDdPBz9B/08ybUWoOymKLUcleC+wCptjbmnP8S1lmptzIeQ2WW0960ZYPa4uS3VJEIYGgc8brnuDLGbhxdPVyD1ITze87K5+IHEAtvCEFHE715xy/8ACN08ufdsWmX3qwGeAE1MJAGPDOSugpuohbUQvjcMhwI3X05dqBl0oZaSTZwPx6FfLHDF8m4cvFNdIDrG4HzHUe8aLzXpajnie0OzkLrdio21MHdTMbJG4YLXDIKiHSbaK4Paxvqg7LWWi3d0G7L4MubXUkz4JdHNJB8wv05qLxBdqZlVCcteAR5EZWVquwDSt4qmVUtL3Tw7iLYwAD71u9NaStmlKUQW6kjgb1c1oBPvVpA0MaAnuILj6itnnHI95Le7K4kQRMeXsaAUAjwiBR5WepMIYREZGMAhHlFlCFh9X9kGnNZyd7W0bWS9ZI2gOPvKj2Dsm0/ozikoaRjpcbSSNBcPcV0DiCj1DA9hC0oq6oDREZDy92VGynhEnacoz3rnGpYnFjsLj+qaOeSR3BlegLvbO9BGFiblpoSPJ4F01NO0BejWquZBglcz01RTxvHHnK6jYo3BjcqNRabETh6q01Bbu6aNk6omaQrVfWtnOQlVLcUcp8GH8lidNt42vkHJxW01BUNoLXNI44GC35hZDTLQaCIjqtbhFpfX842H6FedcUSBtokB6kD55V2jBwmwcJQOV7uvBEtKDk2DhKByhCWlA5TYOEpCEsHCPiSOJHxJiEtGDhNg5Rg4QnpziT1OzJ4ug5KO3LnAAblT2NDGgDoqdTJyt5RuV4t+KHEf8Jtn8PgdiWfI8mfm/wCb2R7+5GmKh+4b8U+TgZPJQXu43E+Kq0rOZ/Mei8m/CmyC4XZ1wlHqQDI/zuyB8Bk+BwhxIcSSThFxBai+wkrJTVU5wZxiETyN3a0ENJGdwCds45AkDOMkJZKInKaQDupWSvj9kp+inp6uN3o8ge5mONhyHsJ5cTTuM8xkct1J7iUN4u6fjxDVTVVFDVPY97SJGAhkrHFkjM8+FwILc+RT0NyvFFHww10VQ3wracOIHQNLCzHvdxFRuDui1IqqF2koIU79ozR7CV7feUX7ZqWnabI8wFXu1PqEZ/6Itc7fvG5SRn/D3DvzSTqi8fbsFAf4bk4/nAE3+Z3K6JKM/mHwVkb7Uge00+9qS6/VOOUf+FV3+01wPPTtJ8a3/wD5InaluONtNW538dwI/wDzBSeujnoR1HwVrTXGeu4hIGhrcH1QRumLpVyQMEcbi0vByRsce9PW+rmraVstRQ09vlJIMVNMZWkePEWMP4KFX3y6UFU6KkoLdPFgHvKmR3Hnw4Q3YfFUwHPm8l8r0MtPefxUlqAP5VPnT/IwM/7zlVD6VsnFxMyXc3dfnzUSR8kEpZxE4GRnqFeN1XqcewywU/k6hll/KZqz2oKG9akuEFXWXOip5YWFgNuoHQ8QJB9bjlkzjG3vKmMROy+shdYBp0T8deQRxKU2qBwqGXTNY9vq32sjd+7FDj8YyoNZpbUBj4aLV01M7789BDN+ADU3sXJpu9P3H4LYNqT0KdbXPb1Oy5ZPpXtLp8mn1zbqvwE9nbF/yvKrKi1dssJ4ob5paoHhNFMw/gw/ml9Hd3hM/i0B6H4f3Xb4rm8dcqSy5557Lz6+u7a6MEmHSlVj7hn3+ZamjrTtlpj6+nLBNj/dyPGfnIk7B6T+I057/gvRgrQ5K9JBXnFvap2s0/8AWaLtcn8FVw/m8qXS9sXaOf67QlE3/wD2TR/NL2Lu5NNdAep+BXoLv/NIdUBcbou1XV04/pGm7bS+Trg5x/CMqcO0m9EevbqBp/dne7/whL2bu5NNbF3/AFXUXVGeSbM5wuXu7R7yQfqKFh/he7/xBSdN6vvl81FQUbpKRkL5AXiOBwcWj1nDJecbAp3IWjJWfXXinoaWWqkzyxtLj5NGT9F1uNvCxo6gLKaw1NadOTCS63SjtkbgA11ZUMiDvdxEZWtXgD6R0za7ts1RO4h7hLHE0YPqhkLGnY79D71WpY+1kIXxp+ElXI7iWorpfWcY3k+bns/uuy68+lXpywxS0+m4X6iuIGBMQY6WM+Jcd3+5owfvBeZta661D2kXEVd+uD6oNOYqVnqQQ/wM5DbbJyT1JVT3W6UGYW6yJkeo3X1fU189To44HcNkzHAGDknAMJfChwqZUEWCgGpSCEIIIJTRlCTKIDKcZEXHYJ+ClL8EhToqXA5ISqJFSqUyENUpsGOichpJKieOGJhfLI4Ma0cyScAITtAMleyfoz6dbYuymhmLA2e4yyVcnjgngbvk/ZY09OfLOVzL6Ylf3l803RZ/qaeabH8bmj/82vSWnrRHp+w262QhrY6OnjgaG5x6rQOu/TqvJf0rKt1R2pNjdygoIY2+7L3fm4rDpj2lQXea+UOCZzeeNZLgf/uPHkfVA9wdhcbBSg5NoicLZX1kpAOUsEKKJMJxsoKE7KeR5KQHI+JCVLBytX2fdm157SLqKS2Q8MDCPSKyQHuoAc8z1JwcAbn8Vueyz6Od21c+KvvzZbPZ/Ve1jhieoafug+yOW7h12BXd9Sax0n2FaagoY42QubGTS22n/rZjj2nHpkjd7vPmdlSlqMHkj1cvIuIuOWwS/wAKsLe3qnaaatb59CR3bD8x0wpVptWmewvRLi+VtLSRDinqZMd7VS48Orjg4aOQ+JXlPtU7VLj2nXrvpuKmtkBIpaIHZg+87xcep+AUDX/aReu0a6GqulQe4Y5xp6Rm0UAPQDqdhkncrLJYYOQ879XKfhPg02qR10uj+1rH6knUNzvjx7z3aDTcJJ5pfChwq7hep5TLm7Jl+xUlzMJiRvVLhPBTJOUzVt46eQeLSE8RhIkGWEIwgnRetfo4V7arS9qcDnio2s+LfVP5LvLfZHuXlb6KV4D7MykJ9akq5IP7rvWH4uK9VDksOsGHBfPP4yv/AJNvb3mT5cn6qvnH1r/emiMFSqiN3GTgkeKjuGFOwgtC9z4ZroK+0UskUgcezZnBzg8oyD3EHfOqQRlTKFmA53wCi8JyANyVZRRiKMN8OahqHYbjvXm/4s3llDZhbmn15yNP91pBJ+PKPHVFO7hhefJVzeam1h+rA8SoeAinGG5TPwhojBY5Klw/xZDjyaAPrzI0HRtlGHAEIAbJQKsr3BVtZYo5gSwYKoK2wuZnLfitq1JkhbIMEJMJ2VzKptZZn1VbaCYaS/Fp/tYnNx8Qf0WhrrS1wJaFX2ykNFeaaQbetw/MY/VRSMy0rl+K6f02w1sAGpjfjzAJHzC2h3Cytu1exlXLRV47uaJ5jLxyODhapc311bjT3wzAepOwOz5jYj8B81Tp3EOIXzd+DtyEN0ntzzpK3I/zMP8A+JJ9y6Cx7J2B0bg5p6hAghcwtd+q7Y4BshLPArZ2vVsFWGtn+rf49Fog5X1wWkK8xtlElMcyZocxwcD1BQLcBKkJA1KdYMMCaacS58SngMABR1RiHOXeK+V+AadnEVTfC46zgj/+oXnPuOE9KMsKikYUv2m+9RiMFPpzoWrovweqy2lrLbJo6N4dj/MOU/At180hBBBWsL6GS4W5lanak4iPmUmmHrEo6k7NCpvPNMB3L5ov0guv4j0VK3XseT4tBl/T4KKglcKHCrhX0ukoJXChwpEJKCVgI0ISEEtADJwkTXuaxpe44AUimbwsz4oVJxHjxKdaOEAeCYqTu0LPb68mV8W8Pyu4p45ZWO2Mhk8msBLfo0JjhS4WZkHlukp6mG5KuSHDCV9O8bV38O4drJ84JYWjzf6v3TspxG73JNOzhZnxSpBxNwOpSgMBUM4ZhfGbbmKbhw26M+tNKXO/ysa3l9xcSfNqZqXbBvxUfAT02XSHwCb4VfiHKwL7D4Ctv8M4cpYyMOe3nPm/1h8AQPciwEEfChwqVegIlLi/q2+5RsBSYv6sKrUeyF4H+McebPTyd0uPi136KMW+sfehgJTxl7vehwqwNgva7bJ2tDBJ3safiAiQR8KHCkWhlEgj4UYGEJMpOCUfCjQT0JcLcElLl9goRjDQilOwVDPPKvj/ANJ/0k/ENjgcsbJgd3LECfgS0n3pnhQ4UrBQwVfX2Ak8KchGCUnBS4xhyil9grgePIu14ZrW/wC7n4EH7IphkhN8JT0gzhI4UkPsBZ34aTdpwtSj+nnH/W77FN4KCXwoYKsL1FN4CLhTmPJDASYQm+FSo28LAEyGAkBSFSqDoAvmz8Zbhyw0luady559w5W/VyRN/VlR8BSJfY+KawE+D2V0v4RQ9nw+9/8AVK4/BrR9klORDD0WClMGHhSv9kr0Li2LtuH65v8A9p5+DSfslS8gjj9lCQZajaMNCok/ywF8qVVw/wD8ApqUHedw9wBd9XBNSbvKXF7JSXYLilsHqqaTSMBeo8ct/h/AlHS7Z7FvvDC4/NqRJ7ZSE44ZcdkXB5KZmjQvY+GIPRrHRRd0TPjyjPzSQMpielZM0ggFSUfCpMLplm6ywNJLmDCFroHx1bGdM5PuWiLMo4oQ15djfko3nlaSuO4vuv8ABrFVVgOHBpDf8zvVHwJz7kdS/ghcep2CrcbKdVtLw1o96ilhHRRwjDcrivwrtXoFgFS8etO4u/4R6rfoT703w7KLM3IKmEYUebkVYC9jKk6QjLrq4HdobldAHJYrTDBDxS8idlroKgOHNex8M2xlHSmoA9aXBPu0C+fOMrpJXV/o5PqRaD6n5qQp9HaX1dLJK3m3kPFV4IK2liiDbbGce21dPPIY25C4umiEr8FYWeja+XJGHDxUmCERgYTmov6Jc3gbNzss9q/Wtu0TZpbhcJgyNjchvU/BfHH4rWd9NeI6mBvqzjOB/UND9l9hfhfejVWZ9HO7WA4/4TqPutIHADc481X1+prVa2F1TcKaIjctdM0H5ZXjztE+lJfr7UuiskrrXTtJHHE7d488rP0ehNQa5c2svVfJmQBwfkEkLiKHg6pqAHTu5fDc/ovSo7g+tkMNBGXke4L1lc+33R9pkLJq97iP920OH4FUM/0sdA08hY6qrSR92mJH5rhlF2R2mjaBUOfUuB3Lmc0eo+z+w0FqkmioGB+NjwkLqY+B6UD13OPvx9lqttl4kGfUb55P0XdKT6Vugq2YRMqqwOxnLqYgfmtBae3bSN5fwwV5aT/vQGfmV5O7PtH2m8xVHpVI2RzXAA4zthaC49k9nqSWwh1Kf3GIk4GpSPUeR8/sE+S1XiEkEsdjuyPqvYFHqK2XBoNPcKaUn7LZmk/LKmk565XhtvZ5f9KE1Fiucwk5gnDVp9G/Sav+krg23amaa4AgPmkeSWjyAXK1/B1VTAugdzDu2KzpKuaicG10RZnruPivWs8AkByq2a2NcTsEjS+rLfrG0xV9vmEsTxuOoPXZWb1xXaSwOLHaELdhkyA5h0KqP2a1p5BKMIjGFOkUSpeI2Oe7YNGSkdO9+hV9ri7dYTtHrhHSRUfWVwOPimLPTCngZG3kFVXm4C/6m5cUEGWtd+K0VBFwgL2fg2jMUTpnDw+Ov6Lh+NKoNZDRjf2j9B90lBBBeprydKByjSEoHKEJYOUElDJTEJeSj4kjiRg5QhLRhyQDhKb6xAHMoSOcGAuccAKXRsyS89NgpSTEwRsDfBKWFK/tHkr4E4uvZ4gvE1aDlmeVn+UaD46u8yU1VP4Y8dTsofEnat3FJjoEytSnZyxjxX1h+HFp/hXD0JcMPl/mH/i9n/pA95KCCCSTlTr09GThFxFEghCGd0Wd0CcJKEuMozzRY2QQTEmEXCi5pWcJyjiEs48G7prncoJKy7rcIrTQzV03sxtLvPGw8ydB4lWUTO7ja3wCpZ5BJI93icq3q5O7p3kc8YCpFSpxnLivCPwjo5JzW3mfVz3coPj7T/iS1JJSCUsjZILVcX0bhIcfJNOPgni1ILEIwmDlNP5qS5iYkGEIwo0nVQKgDCnTc1X1LsZQlVbP1UCdo6KZUvxlV8z09CiyNCjv2UiQ5UaRCaUzItr2TW8zXyqqju2CHh/vOO34ByxnDxELqPZFCx1gqath4mzVDmNcB6pDPV2239biHvGOhUE7sRleX/iTcPQOGqgA+tJhg951/wCkFblfOjtarzde0/VdQ4hwNzqGNIGMsbIWt/ABfRZ72xsc5zg1rRkuJwAF8xrlWuuVxqqtzQx1RK+UtHIFxJx+KbQDVxXj34Qwc1TWT/0taP8AmJP/AMVFIwiwUtBbK+m0nhKHClIIQk8KHClJTIy87ISYSGtycAZU6loiSC4J6jotxtv4q0igawDqhOAymoqbA5YUhsQCWghPwi4Qtj2N2T9vdp+nafgLmsqm1DvDEeZN9uXq4+OFj12r6KlqbV66r61x/wCqUTg1v7z3NGfkHfMKGZ3LG4rl+Kaz+H2OrqBuGOA8yOUfMheq14m+kXN6V2wX4h3E1ncRjbGMQMyPnle2V4d7bHmbtU1I55yfSeH4BoA/ALJoR/MPkvnb8I2ZvM7+6I/NzP0XPHRJlzCFYOjBU+06RvGon8NrtVZcD/8Ag8Dngc+oGOh+S2yQNSvq2WWOBhklcGtHUnA+JWddyRcR8V3PS/0UdT3iWOS7z01lpSQXtc/vZsYzs1vq+W7h7l2DTX0f9B9n9JFW3VsVwqISC6tu0gbEHHwYSGYzyzk+aqPq4maA5PgvN7p+Iditx7OGQzydGx6/9Xs/Ak+C80dn3Y5qvtCcyS30Jp7eTvX1eY4ceRxl390H4L0z2f8AYDpns2YLrc52XOvgbxOq60NZBD4ua07DH3nE+WFU68+lLp/TXFR6ep/27VM9XvGnu6ZmPB2Mu+Ax5rzbrztR1H2jVbpbvXONPnLKGAllPH7mZOT5nJ81X5Z6jf1WrlHQ8XcZ+rP/AKlSu6fncO47O+PICOhXfe0n6VNHSMmoNIM9KqgeE3Kdn1TfEsad3e84HkV5tuV3q73cJ66vqZKusndxSTSu4nOPmfwVPgpTZXM5HPvV2OFkQw1enWHhm28ORdnQx+sd3HVx8z3eAwPBT+JGorasfaGE+yVr+RB9ynXVJwcilJAclA5QmI8ZSJIuIbJaci4O8Z3nF3eRxcPPHXCEH1V3zst+i3SXixUt21RUVUUlS0TRUNK4M4YyMt7wkE5IOcDGNsnOQNhdfomaMraYspZrlQTdJGTh4+Ic05HuIXY7fXQ3Sgpq2meJKeoibNG8cnNcAQfkU+ucdUyl2c4XxDW8c8RT1b5/SXR6n1Ro1vhjrjxye9cF7Ofo8Xfsyv8AcZ6W7010t1SWPa1zHQzMc3y3GPWd16DbfbvEXF3beIYdjcJSCjkmfL7arXjjC48QUbKS5Bryw5a7GHDoRphuD19XcDVBMVbAY+LG/in0CAeYyo2O5XArJsF2fY7nDcG59Q5IBxzDq3yOxUamgweNw9wUlBIml7tu3tHknEulctS4V1z44vIdy80shDWtGzR0HgBuT5kqLVP45cDk3ZNgZQ4Ua1Gt5QAF91WW1xWW3Q26H2Y2gZ7zuT7zk+9BGBlGBhGnLaQHNKHJJAylAYQmIy3IUKqovWa9o3achTxyQIyhNe1r2ljhkFSAcgEdVn9aW70y2NmaMvgdn+6dj+nyV9H7AQmibPE+N44mPBaR5LHH8t/kvz5o6mXhTiES9aeQg+IBLXD3jI965C6LCNmWHIKta+3OpJ5I3j1mnCguhLVp7r9CYpWTxtliOWuAII6g6gqdbr3PROHC8geHRamg1TFOAJ28B+8Fhg3CdjeW9UucJXMbI0tdsV1GKpjnbxRvDx5JBCwFJXzU7gY3lp8ir2j1Q8ANnYH+Y2KYxojzhcJwxwbb+FO2NG5zjIRkuIJAGcAYA7znvWmhOWY8E3K3Dz5pihulPVuxG/1j9k7KVO3iZkcwof8ADm8147C4cJ/iE9jtIqr/AP6HP/8AcGPAKMggjjHG8BXScDJX0lVVMVHBJUznDGAuJ7gBkqTA3hjHnumqg5eB4BSFDlcXSOI5KhD68hcvlf8ADl0l+4sqbxMNg93kXnAHuaSPciQQQV1fWKCCCMDKEIkErARoQkYKdhYePJ6JKfhbhmfFQyu5WFeZfiNd/wCE8PTcp9eX+WP+L2v+kO9+EtR5t5CpCjEEklV6cakrxj8HKLtbnU1h/wDbYG+95z9GlJwE/CPU+KZwVIjGGBSznDcL0X8XarsbCyEH/EkaPcA4/UBKQJwEEmQ4YfNUWjmIC+T7TQOulwgoWbyOa34nBPuGqjk5OUEfChwrWX6OMY2NoYwYA0CJBHwo8BKnpKfi2Ymk7F7PxVef2F4r+LjOfh5p7pGn5OH3SH+0UQGUtw9YosZUrPZC9G4ck7WyUUnfFH/2BJ4UOFLwUMFC6JJ4UMBK4UeAhCTgIDcpaA5oceVpK5ziC4i0WmprurGEj/NjDfnhKSH80tEQSVSgGX5Xy3+EtMajiB07vyRuOfEkN+hKRgoYKXwocK0F9jpHCjaMFL4fehw46Jj9WlcvxTH2thrmf/ak/wC0onDIScBLxlHgqKD2FwH4TS9pw6W/0yOHyafum+FFwp3h8kXD5K0vaU3wocJTnD5IuFCElrfW5JaAGEFmznL18U/ipW+l8SPiB0ia1vy5j/3JLxkBJwU4RlFwqzD7AX0F+GMXZcL07v6i8/8AW4fZI4UYGCEvh8kOHyUrtiu8vUYltlVGesbx8WlE4ZCNBBZecgBfn4ypkqqWC1jYSOcPN4Y35cvzSUockeCiVufYBfSX4vvzT2+3RfncSB5ANH/ckoJeGowMK1svoeKJsMbYmbNAA9yRgEow3dL4Pgj4UqlTfD70AMBOuGAThNgZOFUnOcNC+ePxYrJKt1Fw/TavlcHEe/kZ8ST8ElzOLkm3Q+SlcOeiPgU4GBhe80NJHb6SKji9mNoaPJowq58B54UCojIB2V8+EEKDV0wISq4QmrVUd3GB5q+p6vAG6yMchgfwkqxgrNhuvo60uZPb4Xs2wF8s3yF8NxmbJvzFamOs4iBnmulWMYtNNvn1Fxhlfgg+C6npq/UsljhLpWh0bPWBPIpK6MhgwFUoSA857lm9ezCO4tGd8rx39Ku919RqGCjkc4UkfsDOxyN16n1JdBftQObA7ijDvVIWL7ZOxin7R7Qx0RENwhbmN533XgX4l3KkoKm3wz+0A4nwBwAV73+GtvqaqGuni9kloHiRnK8Ir2Jpu208Vmt72sw4wMOf7oXmTWfZtfND1TorlRSRMzhryNnL1Jp//wBRW/8A/F4/+ULGtUkc4L4yCNF9O8AQllRUtkbqA3fzKncDfuj5LMdorQNOS4AG/wCi1KpNYWqW72WaCHeTGQPHyW84ZaV7NIMsICwHYqAfS8jPr/ouscDfuj5Ln/ZZpevsUdS6uhdA5zwQ13XZdCTYhhuqVg380xUUcVS3hkZkLzD2z08dLr2rjibwsDGbfBepVxDWvZZfte9o9V+z6OR9NwsDpgNmrLuksUEHaSkAZ3K8845gMtvYI25cXj6Fab6HV1rn3i7UZ4pKRkDXAE7NJduV6qeVheyXsro+zSyNijAfWyN+tlHXO+Pmty4lfNF6q4q2ufNCPV+uOq5i1U8lLTNjk3TT1i+0HUH7NoPR4XZqJdgB4HYq71RqODT9E6SRwEhHqt81yeJ09/uLqyqyWk5a09FJabdJWzN5Rn7rohJHSQuqqg4Y35+Cn6foDSwAu/rH7uHmtXSx4AVdQwbg4V1DFgBfSFHSto4Gwt6fVeCXCukuNU+pk3cfgOgVTxI0ROEByWllZaNBBFukQjQQQSZQlA5RpI5pSTKEoHKk0MfFLxdG/mowGysqNoFO3zyVWqHcrNOq8t/Em7PtXD8gi9qYiPPcHAl3/SCPenkCcAk8ggmql3DCfPZZTW8zgF8c2mgddK+CiZvI5rficE+4aqCXF7y48yjQQW7sv0XjjZCxscYw1owB3AbIJJG6UiwEqkSUErhQ4fehCbOT0QwU73ZPIFKFM93RCeo6BBKltonnmnW0HimEoVbzVpSw9zEM+0dyltouAh2M48ktUKl50avmj8YLzUx9haGAiNw53Ho4gkBvuxzEd5aeih3Alwawe8qF3J6hXPo/e+thD0MeCli0YF6l+HtPFT8NUnZNI5gXHO5JJyfLu8MKm7g+CSYPJXJo0g0gU2V6Kqcw+SQ6Eq3dTtao04DeSMoVVIzAUSU4U2oduVXTuwlQok78BVVXLjKm1cuAVRVlRkndCExUS5KhSPySlSPymHuT0JDyktjMhwBlSaejfUEbYasj2qdpVN2dW/0SjLJ79Oz6qM7iFp+279B1SgE7JpIAyVQ9rnaIzSdM60W6UOvMzfrXtOfRmn/xEch05+C9H9h9vNt7I9KRFoaX0Ec5wAMmQd4Tt1PHk+9fPKaomrqmWpqZXzzyuL5JZDlznHmSV69+jv2+6fGjKHT2oLlBabjb29xFLVERwzRD2Tx+yCBgEHGcA774jq4ndmOVeE/ipQ1tytcTqVheGPy4AEnGCM4HQZ1887LuerZZINK3mSEF0rKKZzAHcJLhGcb9PevmiRle0e2/6Q2nLLpOvtdiuVPebvX074I3UMokigDhwl7ntOMgE4Ayc4zgLj3Y99GaTtN0wL9V3sWyllkfHBFFT9693CcFziXADcEY3+CZSnsIy+TQFcrwBI3hW01FxvIMMcjmhuQcnAPQAnHdp0PRcQQXqv8A+4oov/8AK6j/APcW/wD26lUv0LLKzh9I1JXy8+LuoWMz4YznCtelw967x34k8NNGRUE/8D/u1eSkAMr2JB9DLSLeLvrxe5PDu5IW4+cZVlS/RE0LTuYXSXWfhGD3lU31tuZ4WD8E01sSpP8AxQ4ebs558m/qQvGENMXHcKypqLqQvadN9GXs9omh0lrmmawEuM1ZKAR58Lhy/RSXdlXZdaeEzUFrgDB/7RWOxjlvxP3+Kb6bH0BVT/8AVSzuPLDBK8+DW/8A5/ZeM2MDBgBLbyXsqSn7IrY8943SYf7Ja407yOvs7496Ue0Lstss31VZZYZD9qlpg7p4safH80elk+ywpf8A9R5pf9mtUz/cfs0rxvDTTVGe6ifMBz4Gk4VzR6F1JcC0U1guc/FyMdHIRzxzwvVEn0jNAUbCyC4SysbybDRyNB92WhVFV9K3SUQIhobtO7GRiGNrfmZM/gk9ImO0aP8ATHiao/2eyvb/AJifu1q4Tb+xPXFyJEOm6tmDj+kFsP8AzkLv30eezK79n1Ne5b1AyCprHxNjYyRr/UYHb5aTzL+Xks5X/S5pG5FFpuebwdUVQj8d8BrvLqug9j/a1F2oUFe6SCOhr6WUA0rX8R7sgYdk4zvxDltt8YJ3zujPO3AXG8XXPjCrs8rbjRsipzy8xBy72gR+c4GQPyhdCXL7r9HjTV/1HX3m5z19XPVzmZ0IlayMZ+yMNz+PRdOllZDG+SR7Y42Auc9xwGgcySvDevu0i76q1FdZY7xXvtMtTIaanM72sbFxksHBnA2Dfkq1NG95PIcLieA7PdbtUT/w2pMAaAHOAOcE6AYxrpncbL07Fozsv7PhmoprNSSEcPFcZmyvJ3zgSEnPPOP0UC7fST0RY2mKjkqbjwg4bRU/C3Ox5vLR16eB+Pj9BaIowdZHEr2uP8Mqaof2t2rJah3icD58x+a7fqb6VmoLgSyy2+ltEX+8l/pEvPxOGjPhwn3rkOo9U3rVdR314ulVcXglzRPKXNZnnwt5N9wAVchyVtkTI/ZC9EtfDtpsw/1Gnaw9+Mu/5jl3zUZ0GeibdApnChwqVdFlVzoyEgtwrF0QKZfD5IS5UEjZJ5KU6HwTL4ihCEdY9nM8Q8CpMddG72ssPnuFBc3CShGFcteHjLSCPJL4lRteWnIJB8lJjuD2bOw4ITcLrXZ3286i7PqNtAzurla2AiKlqRjuiTklrhvz6HI8MLo1F9L0F2KzTBDc+3BW5IHuLPf1XmqKsjl68J8CneJVn08TzktXD3DgqwXSZ1RU0o53bkFzcnvPKQCe8416r1jb/pY6TqC1tXRXSicQSXGJkjB5ZDs/gui6F7R7D2j25tZY6t1QwucxzHxuY9jm82kEc+S8DSeyV1f6KurP2Dravsz38MdUBWwtPIuHqyD3kFp/ulVpKKMDIyuXk/Cnh+d+GOkZ5OB/7mleyT6vPZJMjR1UiZocA4btcMghRHsVT0dveo4/wcs4fl9RIR3eqPnyn6JD6nHsj4lRyS55cTkpxzUnhPEpmRtZsvT7DwnaOGwf4fFhx0Ljq4+GTsPAYHgk4KPhR4KCkyuvQQR8KMDCEIAYRoIwEJiMckEEEITsR2IS01EfWTqzJxh5Xw9+Jlv9A4lmcB6soa8e8YP/AFAqtuVmirnl/syEc+iz9bpyaHJDeNviFsXDIRDZWYXczcdy+g/wuvRulhbTSHL4Dyf8O7PgPVH+Vc4mt72E5aor6dzTyXS5qCCpHrsAPiFWVOmWPyYyD5FTYXsOVh2ktKfZMFe1Gm5WfY28lBkscrfsOHwSITdNV+jyskYfWYQ4Le08zamCOVm7XtDgufPtczeWVf6ZrpKRvolRkMJzG48h5KvMwuGR0Xh34p8NTXegZcaNvNLBnIG5Yd8d5aRnyyptfVT2+Y8UfHCd2vA2HkVZUYLoWyObwucM4PMBP4yhyVd0znN5V4ZefxEuV6s0dolbg6B7wdXgbAjprq7XU40CTLIIo3OJxhQQ4HkVHuNaZ5RHGfq2ndw6lNsdsrcDeVuT1X0B+F/DstktLqmqbyyzkOwdw0D1QfHUn34OqnA7o1Ga8p1js9VYXsKdAyjHJAckrhTkIsZR8KPDkfChCINyVIAwMJtjfWTiz6g6hq+S/wAYLr29xgtrDpE3mP8Amd+jQD70TjhpTCff7KbUlOPVJXc/g9R9laKiqI1fJj3NaMfNxSFIb7I9yaTjTkJKjYKn+MsUrqCkkaPUD3ZPcSBj6FGm5dyAnE245Kigbl2V59+E9ofWXs1zm+pA0nPTmcOUD4Fx9ybQS0FoL7ISEeClIIQiDU4zkk8KUwYUE3sLyT8U2c3DMp7nMP8A1Y+6Jwy5ADCM80oBPj9gLqeDX9pw7Qn/AO20fAY+yLhQ4UoN8UoNwpF2GE3wo+HyToYhwIQm8FDGCneBNHcqrOcNwvCfxduQprPFQtPrTP1/ys1P/UWokvgSQMkJ7hKbTjcrm/wZpcmtqj/uNH/UT9k3wI+FL4f3UfD71eX03hN8KDm7FOcOUTm7FI7UFZtzi7ahnj72OHxBTLeYS+EpDfaHvUjBVWmPqkLxD8G5w62VUH9MgP8AzNA/+Ka4UOFPcBQ4VbX0EmeFDhTvChwoQmHbFJSpBh5SVkPOXFfnjxRUOq75WzP3Mj/gHEAe4BLYM5SuFKgblpPmne7WhF7AX2dwBGYuGKJpH5Sfi4n7pjgQczAKf7tJkZhjj5J7tiutu7gy21Lj0Y//ALSoqNoy4BEnIG8Tj5BZjBlwC+CeE6Q1t+ooB1kaT5A8x+QKNzcNJTbRlwT8+Wsx4pEDeJ59ysyetIAvd+MH/wAV47ttvaciPkJ/5i8/9ICPgR8Cd4EOHCuL6VTYYj4eic4UMBCFHmOAAhA3JJSZncUh8BspUMfDGPHmqbfXlJ7l802U/wClXH1RcTrFTZDe71fVb8TzPCLgRhqXw+SPgVlfSyQWZCizxZZyU8NSHx/JCQrK19Pg5G2FBZUmM4K01VScX2VSVVvIcfVXXWPiGa05jI5mHp+i4u/cOQXjD88sg6/qm21vmnIq6aR4iikfl32WuwoL6F45ApiSmkbjDnNPPIO66+s42jFO40kOZMaAnTPiuLoeAnuqWismxHnUga48F0awWT0Jneynildv7leALm1p1dXWktZOPSKYcmtGX/NbO2aqt1yADahjJP8AduO4Xw7xNUXW43CSrueS93wA6AeAX2LZbVRWugZT2wAxDqNfefFTLhZqG6RllXSQ1AIxmSMOP4hcrracUtXLE1oa1riGgdBnZdhbhwBBBB6rAa2s7qar9Jjb9W4YPvXQcB17aetfTyH2xp5hdzY5WRzuYd3D6LLIIIL31d2gggghCAGSAum6Voo6e1RuEbWvOcuxufisBZ7dJc62OJg2zufBdCrb/bbDShk1RG1zG+xncryLj6rDo4qKPVxOSPkFyt8k5gyBup3VqRlZjVOtaLT0Tml4kqcbRg7jzWQv3ajU3ASwWuEhpGCSMn4LNUtskqaj0ise6aQ7gE5+C85ttiqKyQDl9369y5WZ1Pbo+3rn8o7upR1dXWarr/SKvIhHstxgYV7QUQY1oaMNCOkotx6oA8ArulpC0DZe62m0x2yPA1cd/wBAvIr5fJLxIGtHLE3Yfc+KVSw8IHRTmMIHJBkZGE4GreXNAKrdbpAOSbNDKPsrRGD5pJp/JTYUOVn/AEGTwQ9Dk8Cr/uPII+6x0SEJcrPehyeBQ9Ek+6Vou58kO6Hgm4RlZ30eT7pRink+4Voe5Hgj7oIwlys/6PJ9wqXS8bG8DmHHQ4Vr3Y8AjDAOgUb2CRvKVz9+sdJxFQuoKwHlOoI3aRsR4/YkKFg+BUaeKWZwAjdwjyVxgIKGOBsZ5s5XDcMfh1QcN1np5lMsgyG5AAbnQnGuTjIznYnRUooZT9gpYt0x+yB7yrdGBlWl61lVQtch5lqW21nqQrP4IY8kJVAFtaOaWKBg6KXgoYKYhR20rW9E4IG+CdAwjQhNiJo6BGGY6JeMo+FMQkcKQYmvOS0ZTqBakLQd1VqKWCrZ2dRGHt7nAEfApsNxyRFqc4UlxA5IwrbWhoDWjACbcExIcZTr34UOebAKMJyZqJA3KqqmbOU9Uz81WzSZJSgITc0mVX1EmAU/LIqutnwCfBOwhQLhU4BCpJpOIlP1lQZHlRWtLylQm+Eu5KXTW8vILh8FKpKDkSFmO1TtPoezG0ADgqb1UNPo1Jnl++/waPxTgMphcAMlQ+1PtPo+zW1iKHgqL5UN/o9MeUY++/yHQdT8V5Ura+qvNwnrq6d9TVzuL5JXnJcUVzudbqG6VFyuM7qmsqHcT5Hnn/IDwSWjCstaGrPkkLz4JQCUBhEBlKUqiRYC2+hu2XVnZ1b56Gx3IU9JNJ3roZYWStDsYJHEDjO2ceAWJQAymuaHDDhlU6ujpq+IwVcYew9HAEaeBXSZfpG9o00he7U0wJ6Np4Wj5BmFXzdtmvakt4tV3MY5cE5Z+WMrEhqfiiLimCKMbNHwWcyw2mP2KSMeTG/otM7tH1hXE9/qq9Sgu4uF1wlIB8hxYCU7U18rP+sXi4T5HCe8qnu28NzyVPBDjGymMGFKGtHRasdvpY/YiaPJo/RPvlknIdLI+RwGMvcScIicJKCer4AAwEEEEEmEqCCCLiSoRqbZ73X6fr4622Vk9DVs9maB5Y7HhtzB6g7FQeJHkJCM6FRyRslaWSAEHcHUFbLUXbBrDVVvkobnfJpqSQAPijjjiDx4HgaMjyKxqCCja1rRhowq1JRUtAzsqSJsbd8NaGjPkAEEEEE5XUDsidzQdyRITSj2RpIKUhIghjKCMHCExIdFlNOhT6CEKFJS5UWSnc3orctCS6IFCdlUpakEYVpNRg7gYKhyQFvMIRlRk5HVSRHZxx4FE6PCacCEJqnsuLXDDxg+IT1s1HJpPUdpv9MeN9vqGyOa3m+M7SN+LSQqclMVDeJpHihLtqF9OdJXeC/6epKqnlbNDJG18cjTkOY4ZafkVYPj2Xmn6GXaWLhZJ9LVs2au2HMIcd30zjt/gcceQLAvUMsXCeSoPbynC1GO5hlVckeCmi3dT5YlHczCjUoUfG6GCnOFFwpqVIR8KVgoYKExJ4UaVwoYCchEBlGBhGjDUIRA4KdSAMJQKrTxl+C1eG/iZwhW8QNgrLc3mkjyC3IBIOowTgaHOnijSQMpXNBNhYWZJS/hlwnceH46ipuLeR0vKA3IJAGTk4JGudBuNcoIxzQwUYGFZXuKNF3bXcwEaMDKTCE2aWJ3NgPwRegwf7ofJPoJU9E2BoAAOAifA144Xbg9MpYyjTORuc4XNt4bszKr01tJGJc55uUZz37b+O6jGihHJoSDQR9AApeAiT8LoVE/Z4HIhD0Qg9FLQTsIUUQEICMhSeFFwoQo5YUYYnuHyQ4fJCE20YRockFkPOXEr88eKK19xvdXUv6vdjyBw0e4ABE4ZRYKca3IR8CvxDDAvsn8PKYUvDFI0fmBcf8AicT9MBNYKGCneBDgUu69AlhjnYYpmhzTuCMg+YKbwUSd4fJDg8kAAbKCloqWhj7KkibG3fDQGj4AAJpDh3T3do+79yVXEzwo+BPiNGIkIUfgR4wpIjTU7OHh81BN7BXl/wCJjc8K1R7uT/8AuNSWNyliPyR0zeIO2UkReSdF7AV/gB/acMUR/wB0j4OcPso4jSgxSBGjEfkpV6CmBGj7v3KQGId35IQokreCMlRVLrjw8LcY6qIs+c5djuXxf+K1z9Ov5pmn1YGhvvPrH6ge5LiGZApfdpmiZxzHyGVO7tTwD1V7D+EVN2NgfMfzyOPuAaPqCo/Ah3eOikd2h3atr29R+7RFmxUru/L8UDFlCjkbzsc3vCqFODcgHxUFWlMOOBh8sKjTHUhfLP4M1XJWVlJ/U1rv+Ukf/NN8CHApHAhwK8vqpMd370O796kd370O6QhQ5aXvNwcFNtonE7uAHkrHu0fAoXQsccleeXP8PuH7tWmvqYTzuOXYcQHHvIHU9cYzudcqM2IMaAOQSuBP8CHAptl6DFFHBG2KJoa1oAAGgAGgA8AmOBJdFxsc3qQpJYfBF3figjOibPBHUwvglGWuBBHgRgqpdBI12Cw58gpVPAWM32JUzhCDhgE8lXZCGHOV5dw5+Hdu4ZuDrjFK55AIaHY9UHc5G5xpnTQnRVlWfrA3wCco2Za53nhRnu43ud4nKsKOPFO0+O6rxnnkLl5RwXU/6Rcd1F03DQ9w8tI2/wDSQhwocBT3B5IcGVeX1emeFJl+rjLuvRSOBQa5/rBg6blRSO5WkriOM73/AACxz1bTh5HKz/M7QfDV3kEzAzvJWt6dVYcOyZoIfULyOewUsNUcI5W571yf4W2X+GWIVUgw+oPN/wAI0aPhlw/zJvhRhqcDUYapl7Gm+Eo+DLSnA1GGoQorocjBCiS0Qd0+KtgxEYhjfZJhJhUD7YD0Uea2bHZaUQJD6bPT8EZRhYyot3Cdtj4qrltYa4lgMTjzezYrez0QcOWVXT2zI9lVp6aCrbyztBVmlrKmifz07y0rL095vFpdimn75g/37sqW/tBrKmN1PcKMSNPMwsyps1rPgoz7e5mcZGVyk3CdKX9rTu5XDbz812VNxfMwj0iIOI6jQrPPucE05Ecckbf+0GE6J4zyeFYS2oPOXR5KZ/ZLGnaMBdfRurImBlQ5rsddcrtI/wARKdow6Bx94UbvGn7QTVRU90zLWukPg0ZU420Z9gJTKAsPqtx7lYqJaotxByg+OUr/AMRqbHqQOz4kKkp7jdJeJlOfRs/a5FNC0S1ry6unfNJ0OcrSNt7nHJG6lQ2zPT5rnBYIZJTPUvL3H3fsLiq3jauqCexaGZ67lU1LQMjA7tgb0yArWmoM4yrOC3AY2U6KiDei6OKGKnbyRNAC4WeeaqeZJ3FxPeodNRBuFPjhwn2xD3JwR4UmVEGpkNwgGp3gIR8CRCeRboE4RjkryqJJGESWgm4TspCCWhgJEqQjwUpBJhLlJ4UOFKQSYRlFwocKNBNwlRcKNBBIhBBBBCEEYGUA1KQhFwogMJSCYlykgbpSCCE5IQJRl2yafIAE3CEpzkzJKAE1LOAoc1RjqjCE5NUYB3VdU1HNJnn57qunnylwnoTzZ6qFJIhLKo0kidhCRUS4aVn7pV78AKn3GrETDvv4LOyOMryTuSkQkhpe5WdHRYAJG6OhoeTiN1n+1PtSt3ZRaGl4ZWX2oYTSUGeXTvJPBo/HkOpDgFGSAMlN9qfadb+yyzh7wyqvVQ0+iUOfhxv8Gj8eQ8vH93u9fqe71FzudQ6qrZ3cT5HfkB0A6BC9Xq46qvNTdbrUvq66odxPkd+AA6AdAEy3AVhreVUJJC8+CU1uAlgIm8ksDCeokaCCCcEIJTQiDd1IhiLkqEIoi4qwggwBshBCAApLRwhKFM0YRtGE4DlIbyShzTk5LBQJ2RIIQjLkSCCEIIIIIQggggkwhBBBBJhCPiRg5SUEYQjJRIIJExBKSRzSkJCgggghNQQQQQjKPmUSCCEJXEkvia/oglA5QhQpqIjJbuFDkp8HcK6SHxNk5j4oQqCSAqNJGQOS0ElFn2Soc1ERnIQlwmdEayquzjWls1DS8ThTycNRE3+1hOz2/LcZ5EA9F9NNIX6k1Xp6jr6OdtRBNEySOVh2exwy0/JfL6toS5pGF6O+ht2uutFXJoy5SHhaXTUBefaYTmSIe45eP73QBRSM5hkKeF/KeUr2FJF0UOSPdW8rGyRiWM8THDII6qHLFsqOFfyq5zUnhUh8eE2WpMKRNcKHCnOHyQwEiYkcKGAl4CGPJOQko+FKwUfChCTgIwMo8BKwUISeFGAlBqMBJhCTwo+FK4UYCMISAMI0vhR8KMISAEYGErhRowhIQS+DyR8KVCRgoYKXwocKEJGCi4fenOFHwoQmuHyQ4fJO8KHAUITXD5IcCd4EfdoQor4znICSGOPQqb3aMRqs6BrjleK3b8K7VdLi6uErow85c0YwSd8EjTJ1O/hhR2RYCUI1IEfkld0pgMDAXr9JSw0NPHS07eVjAGgdwAwFF7tH3fkpXdIxF5JVbUURo+6UoQoxEhCi90lCJSu6PgjEWeiEKMIkYi8lLEJSxChLlRBF5KHXt4HMHkrlsCq7w3gnY3GPVz+KgmGGFeUfijJycLzt/qcwf9QP2Sbc3iMgxnkpwhUaytLppAPuq4EBSwjLAn/hlIZOFqYH8peP+tx+6hCFGIlNFPlKFPjopsL1NQu6Q7pTxTFGKc+CMIysxcMiqeD0xj5KMtHcrMasB8ZDZAMYPIquZp+sc8Asa0Z9ouCz5In8xwF8V8X8G3032olhp3ysleXNc0ZGHHODj2cZxrjbOyFoi4+8d7grDud1LpbYKWERt36k+JT/AKKVdjZytAK+o+ELRJYbJT0E3ttBLsd7iXEeOM4z4Ku7lF3B8FZ+i+5D0Q+CkwuxyqzuUO5Vn6KfBAUvklSZWefZiZCWvAYehG4U2OnETGsaNgFaeinwQ9GweSY2NrDkBcpaOF7RYZ5ai3wcj5NzknTOcDJOBnoPDuCre5Q7pWPo3kh6N5J66vKru6Q7vyVh3Hkk+joS5UHgR935KYYPBF3CEuVD4EOBSu5Q7opMoyonAUODZS+68ii7ooylyovdpE0RdC8DmWkBTO6KPuk3dQTxNqInwu2cCPiMLKYOcdVeU8JbBGCMEAZCl+iR8fF3beL73Dul90oY4uQk5XlPBPAh4SqJ6iSftC8cowMYGc66nU6eA8c6RO78EOBSjEiMfkpiV68obwI2Oc7YAZKpjxVE2w9Z55KxvM3Bwwg7nd36JFnpjJI6XGzdgfNUpDzvDAvmXjWodxdxPS8M0x/lxnLyO/GXH/hboP8AeJClxwiNjWjkBjkl8HkpPdIuBWtAvpWKJkEbYoxhrQAB3AaAKPwI+BSO796Hd7IypUxwFDgKf7v3o+DCVCZ4UOBPcA8EfB5IQmeBDgT/AAId2hCjOhykPps/ZU3u/chwIQqt1EHZ9VMS20Hk1XfdjwRCAFGUmFnnWsfdSDaWn7K0gpkr0XyT0mAsw6zN+6jFoHgtL6K3wQ9GB6IRyhZtlrA6J5lvDeivvRQeiM0oRlNwqMUm3JOej4VsaM+CbdS46FOSqt7pF3Snmn8k2Yd+SEKGY0XApRiz0STGhNUbhRoIK8qiCCCCEIIIIIQggggmJ6CCCCEIIIIJicgggjAyhCAGUpBBNQgghzR8KEIkEMYQSFCCS44ROOOaYlmwmp6OSTGVElqOabmnx1UGep80ITstRzUKao80zLUqHLUeaXCE5NP5qDLMkyzZUWSVLhCVJJuotROImEuKTLOGgklUlfXGd3C0+r+aVCZrKk1EhPToFIoaLk5wyTyCTRUpe8EjLjyCw3a5230fZvDJarO6Kv1Q4YdydFQ+b/F/g34nbAcAZTXODRkq07V+12g7Kbf6PCI67Us7MwUZOWwA8pJcch1DeZ8huvIl2u1fqS7VNzulVJWV1Q7jlnkO7j+gHIAbAJmsrKq7V89bXVElXVzvMks8zi5z3HmSSiGwU4GFQe8vQxgINGSiT0TMJ6jS2twEvhQARoTknmlAIAJ6KLiKUJqEMWVPhiwkxReSlsZhOUrRhG1uAlgYQ4UaE9BBBBCEeShkokEJiPJQ4kSCEI+JGDlJQS5S5S0EkHCUnJcoIIIISoIIIIQggggmJiNvNGgBhBCaUEEEEJuUEeCjAwjQkScFEloIQkIJRakoShGDhGDlJRg4ShKlIjg80ROUSchNT0rJB4FVUkNXaK6nuNvldT1tLI2WGZnNrgchXSS8AoQvb/0eu2Sl7StLwGVzYq1mIqiDO8UvUfwu5g/DnldYqIOAnbZfNXR2q7h2calivVrJc04bVUmcNnjz+DhzB/zB+gvZZ2i23tN0xT11FUNlcW7g+0PEOHQjqFTljx6wV6KTmGDuriWHwUZzN1bzQcJ5KJLBjoq2FYyoBbgosYUh0eEkt8kicmuFDhS+FHw+SEJvhR8KXw+SPBQhIA8kfCl8KHChCSAj4UvhR8KEJAGErhSgEfChCTwo+HySg1K4UITfD7kOBOcKMNQhN8KMNTgajDUITfChwp7h/dRhnkhCZ4UYYnu7z0ShEUIUcM8AjEakCEpYiQhRhGjEalCJKEXkhCiCLySxGpXcZSmweSEKKIsdEpsfkpQhShD5JqMqJ3fklNiKmCDySxTE9EuEmVB7opQiVgKQnonG0R8EqTKrRCnGwZ6KzZQ+SebQ+SE3mVU2n8ksUx8FbtovJOCjHghHMqcUx8E3U2mOsaBI05HIg4IV96H5JYpB4JCARgqnVU1PXQup6qMPY7cEZB9x/eVRUlqjo2FsTcZ5k7kqS2kKtxSjHJLFMPBKAAMBOpqeCjhbT0zAxjdAAMAe4KoFGUsUeOYVr6OEoU48EKxlVIpPAJQpPJWncBH3GOiEZVYKTyShSDwVl3CHcgIRlV3oo8Efo3krDu/JDujhCMqB6KPBA0vkp3c+SHdoRlQPRh4IejN+6p/dId2hGVANMPBF6KPBWHdId2kwjKrjSZ6JJpFad37kO5Soyqg0iSaVXBp8hE6m8k1GVTGlPgkmmPgrk03kkupfJCXKpjTY6IjB5K2NL5JJpc9EJcqpNOEHU6tPRvJF6KUJeZVfo+OiHcKyNMkmmQlyq0wIu6KsjTkJPo6EuVX9wm6gsponSP2Y0ZJVmadZXUlwEs3osZyyM+uR97w+Che7kGVx3FnEcXDVrkrHYLzowd7jt7hufAKolkfWVJdjL5HbAfgFqaSi9Fp2RjoNz4nqq/TNtM0jql49VmzcjmVpDTqKFmnMeq82/CyxyRwS3+s1lqCcE78uck/8btfIDvUAxbocHkpxgRdxup8L3vKg90j7pTe48kO48kYRlQe6R914BTu4Pgh3GDySpcqEIz4Id0VN7pDukIyofdI+6Kl9wj7lCTKh90UO7Uvukfc+SEuVE7tGI/JSxCjERQjKi90j7vyUruSlCLCejKiCJH3SmCFGIfJCTKhCDySvR1NEOUfcoSZULuAgYFO7ood15BOSZVa6kDuiafQgq37jyRdxkckJMqifREdEw+mI6LROpxjkmXUmem6EmVjc4QQQV/CrIIIIJEIIIIIQggggkKUIIIIJqcggggmlKEEoDCAGEaaUqCHNDmlAYSIQxhBBBCETikOOEpxwos9QGA7piEJZMZKgVFTgc0zVXEDIyqmprsk7p2E7KkVFXz3VfLUZ6qPLVZKjPnS4S5T8k/mo0kyZfPlRpagN8kuEJ2WbzUOapDBklRamvDAd1UVdw4id0qTKk1teZDwg4CixOBJcSGgAuL3HAaBzJ8lQ3rUdDY6GWtuNUyjpY/akeeZ8AOZPkN1597SO1yu1px2+iElused4c4kqPOQjp+6NvHO2ANymOkDAt12ofSFMLJrPo6fc5ZPeW/iIf/t/8PRy4KGlznPeS97iXOc45LieZJShGB0Sw1TAAbKg55eclEBhGBlLEeU6yLCE1NsYpDW4QbGnODyTkJJ5okvg8ktkRJ5ITkUUeSpsMWAkwwqWxmE9KEqNmE6BhBrdgjQpUEEEEIQQQQAyhMKCAGUoDCNCTKTwoYKUghJlIQS0EJySBlKQQS5QggggjKEEEEEiEEYGEOXJDcoTco0EAMIITcoJQGEBgIZCEiNBFkIZCEI0EEEIQQIygghCSBlHyRoZynp2Uk80SUcFJRhCJyJKPJJTkJD25C0PZp2mXbsl1Iy5W5zpaN7h6VR59WQeI8HD8Vn3c03KwOCbjOhS5IOQvpRoDX1n7UdNQXe0VDZWvH1kYPrRu6gjormSEtJGF82uzvtNvfZJqFl0s031biPSKSQ/Vzt8COh8+a95dlXbdprtftTZbfUtgubG5qLdK4CWM9SB9pv7w2+OypSRluo2V2OQP06rVyQA8go7ocFWro/DkmZIs9FBhTZVYY8IcOFLfHumnMwjCdlMcKPhTnDuiLUmEZSMBGlYCACMIRcKNKDUYCRCSBlKDUYalAIQk8KUAlAeCWAhCbDc9EoNTgYlBiEuU2GZ6JQj8t08I062HKEZUYRlLESmMp062nQkyoIg8ktsBU4U6cbT+SXCMqAKc+CWKdT206cFNtyRhGVXCm8ksU2VZCm8kttKkTeZVgpvgnG0ueis20vknRTDwS4RzKrFJ5JxtHnorRtMM8k62nARhN5lWMovJPMovJWDYR1CcEIHRGE3mUBtGnG0gCmiMZSu79yRGVFbSgJYp2jopHD7kEJMpoQgI+6Cd4UfAhKmRGEoRhOcPvR8KE1NBm6PgTnCj4UJcpvgCPg8Al8KAGEJMpHChw74xhOIIS5TZZgoiwc05woAYQkym+EeKLhTvChjdCE1wouFPAYRcKEuUzw4KMsCcRcKXCVNlgR8IS+FEdilwjKSGo+FGgkwjKAYlBqTxe5Di6owhOBgSu5aU1xhKEiMJMpRpgU26lHTdOtlSw8FGEmVDNNjokmDyU/YoFgPRGEuVWmDySTArIxDwSXQg9EmEZVaYR4JPcBWRhCbMWCjCXKymp7uLVCIYwfSJWnhcPsDxWJggkrKlkTBxSSOwM9SVv8AVWl33gxz07mtnYOEtccBw58/FNaY0m+1zGpquB82MMa054PE58VSfG978dF818U8OX/ifidsFQwikbjlcPZazQuP+cnIwdc4/KMqdR22OhpY4Y27NGCccz1KeMA8FP7vBSTGFbAxovo6COOmibBC3la0AADYAbBQO4RdwFPMaSYx4JcKfmULuR4Id01TDHjokmPdGEZUXumod0FKLEOEIwlyondBAwgqX3QRcCMIyovdBDuQeil93ujEfyRhHMoncBDuApndo+79yMIyoYgR9wPNTO63RiNJhGVD7gI+5A5qZwICNCMqIIQEYiUrgRcCEZUcRAFH3YT/AADCHAMJcJMpju8I+BPcKHClRlM93lDgCe4UOFCTKZMaSYxhPkIsBOwjK//Z</text>
      <sha1>j8h7bfcrtmk3txj9u3rid4vkroxd5nz</sha1>
    </revision>
    <revision>
      <id>2348</id>
      <parentid>1871</parentid>
      <timestamp>2025-01-15T18:51:54Z</timestamp>
      <contributor>
        <username>NZXNV1</username>
        <id>9</id>
      </contributor>
      <comment>Undo revision [[Special:Diff/1871|1871]] by [[Special:Contributions/85.249.21.26|85.249.21.26]] ([[User talk:85.249.21.26|talk]])</comment>
      <origin>2348</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="453" sha1="e11j9ql47nq09ysde4x26ktwu0uopd6" xml:space="preserve">'''UmSebenzi wesiTjhaba wezamaLimi''' ukhuthaza ube ukghonakalise iindlela zokuthintana kiwo woke amalimi. Ngokukhambisana neentlhogeko neemfuneko zomThethosisekelo, umSebenzi wesiTjhaba wezamaLimi ulawula ukwahlukana ngamalimi lapha ekhethu, begodu uthwele nomsebenzi wokulungelela amalimi woke wabantu ngokuphumelelisa amagadango womgomo onqophe ukukhuthaza kokusetjenziswa kwamalimi la, kunye nalawo amalimi ayedimeke amathuba angatjhejwa phambilini.</text>
      <sha1>e11j9ql47nq09ysde4x26ktwu0uopd6</sha1>
    </revision>
    <revision>
      <id>3018</id>
      <parentid>2348</parentid>
      <timestamp>2025-06-06T20:28:57Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>gbrfvecdxs</comment>
      <origin>3018</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="534" sha1="8f35xlgpg96vq1f6d1ktxrnq1dc1goy" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. UmSebenzi wesiTjhaba wezamaLimi''' ukhuthaza ube ukghonakalise iindlela zokuthintana kiwo woke amalimi. Ngokukhambisana neentlhogeko neemfuneko zomThethosisekelo, umSebenzi wesiTjhaba wezamaLimi ulawula ukwahlukana ngamalimi lapha ekhethu, begodu uthwele nomsebenzi wokulungelela amalimi woke wabantu ngokuphumelelisa amagadango womgomo onqophe ukukhuthaza kokusetjenziswa kwamalimi la, kunye nalawo amalimi ayedimeke amathuba angatjhejwa phambilini.</text>
      <sha1>8f35xlgpg96vq1f6d1ktxrnq1dc1goy</sha1>
    </revision>
    <revision>
      <id>3040</id>
      <parentid>3018</parentid>
      <timestamp>2025-06-07T03:05:22Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:NZXNV1|NZXNV1]]</comment>
      <origin>2348</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="453" sha1="e11j9ql47nq09ysde4x26ktwu0uopd6" xml:space="preserve">'''UmSebenzi wesiTjhaba wezamaLimi''' ukhuthaza ube ukghonakalise iindlela zokuthintana kiwo woke amalimi. Ngokukhambisana neentlhogeko neemfuneko zomThethosisekelo, umSebenzi wesiTjhaba wezamaLimi ulawula ukwahlukana ngamalimi lapha ekhethu, begodu uthwele nomsebenzi wokulungelela amalimi woke wabantu ngokuphumelelisa amagadango womgomo onqophe ukukhuthaza kokusetjenziswa kwamalimi la, kunye nalawo amalimi ayedimeke amathuba angatjhejwa phambilini.</text>
      <sha1>e11j9ql47nq09ysde4x26ktwu0uopd6</sha1>
    </revision>
  </page>
  <page>
    <title>Umbuso ohlanganyelweko</title>
    <ns>0</ns>
    <id>264</id>
    <revision>
      <id>1416</id>
      <timestamp>2024-06-27T11:57:21Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Umbuso ohlanganyelweko''' mbuso lapho kuphethe iinhlangano zepolotiki ezidlula  ezinengi kusekela kwezimbili.  &quot;</comment>
      <origin>1416</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="114" sha1="plroaz65o5m2bpml7rgq8q8p57i316l" xml:space="preserve">'''Umbuso ohlanganyelweko''' mbuso lapho kuphethe iinhlangano zepolotiki ezidlula  ezinengi kusekela kwezimbili.

</text>
      <sha1>plroaz65o5m2bpml7rgq8q8p57i316l</sha1>
    </revision>
    <revision>
      <id>1417</id>
      <parentid>1416</parentid>
      <timestamp>2024-06-27T11:58:00Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1417</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="90" sha1="qx8e63aacqzfqnpb9gp9fm2fhgxk87r" xml:space="preserve">'''Umbuso ohlanganyelweko''' mbuso lapho kuphethe khona iinhlangano kusekela kwezimbili.

</text>
      <sha1>qx8e63aacqzfqnpb9gp9fm2fhgxk87r</sha1>
    </revision>
    <revision>
      <id>1418</id>
      <parentid>1417</parentid>
      <timestamp>2024-06-27T13:55:38Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1418</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="684" sha1="0hb5aau3oyczocbf734k5corhjrei2u" xml:space="preserve">'''Umbuso ohlanganyelweko''' mbuso lapho kuphethe khona iinhlangano kusekela kwezimbili. Ngemva kweminyaka ematjhumi ama thathu iSewula Afrika ibuswa ngaphasi kombuso wentando yenengi, unyaka we-2024 wamakhetho ube ngohlukileko ngombana ulethe umbuso wehlanganyelo lapho kuphethe khona iinhlangano zepolotiki ezinengi kungasi yinye.

Woke umuntu uyazibuza bona ngemva kwetjhuguluko elingaka kwezepolotiki inarha yeSewula Afrika izokuraga njani.

Umbuso wokuhlanganyela ubanjwe yihlangano ye Democratic Alliance, African National Congress, Umkhonto Wesizwe kanye ne Economic Freedom Fighters. Umongameli okhethiweko ngubaba Cyril Ramaphosa obevele kunguye umongameli weSewula Afrika.

</text>
      <sha1>0hb5aau3oyczocbf734k5corhjrei2u</sha1>
    </revision>
    <revision>
      <id>1419</id>
      <parentid>1418</parentid>
      <timestamp>2024-10-14T13:47:41Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>1418</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="684" sha1="0hb5aau3oyczocbf734k5corhjrei2u" xml:space="preserve">'''Umbuso ohlanganyelweko''' mbuso lapho kuphethe khona iinhlangano kusekela kwezimbili. Ngemva kweminyaka ematjhumi ama thathu iSewula Afrika ibuswa ngaphasi kombuso wentando yenengi, unyaka we-2024 wamakhetho ube ngohlukileko ngombana ulethe umbuso wehlanganyelo lapho kuphethe khona iinhlangano zepolotiki ezinengi kungasi yinye.

Woke umuntu uyazibuza bona ngemva kwetjhuguluko elingaka kwezepolotiki inarha yeSewula Afrika izokuraga njani.

Umbuso wokuhlanganyela ubanjwe yihlangano ye Democratic Alliance, African National Congress, Umkhonto Wesizwe kanye ne Economic Freedom Fighters. Umongameli okhethiweko ngubaba Cyril Ramaphosa obevele kunguye umongameli weSewula Afrika.

</text>
      <sha1>0hb5aau3oyczocbf734k5corhjrei2u</sha1>
    </revision>
    <revision>
      <id>3027</id>
      <parentid>1419</parentid>
      <timestamp>2025-06-06T20:33:36Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>df</comment>
      <origin>3027</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="763" sha1="iairdrq9ki2udonhfcjwsb5nimlw0r1" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. Umbuso ohlanganyelweko''' mbuso lapho kuphethe khona iinhlangano kusekela kwezimbili. Ngemva kweminyaka ematjhumi ama thathu iSewula Afrika ibuswa ngaphasi kombuso wentando yenengi, unyaka we-2024 wamakhetho ube ngohlukileko ngombana ulethe umbuso wehlanganyelo lapho kuphethe khona iinhlangano zepolotiki ezinengi kungasi yinye.

Woke umuntu uyazibuza bona ngemva kwetjhuguluko elingaka kwezepolotiki inarha yeSewula Afrika izokuraga njani.

Umbuso wokuhlanganyela ubanjwe yihlangano ye Democratic Alliance, African National Congress, Umkhonto Wesizwe kanye ne Economic Freedom Fighters. Umongameli okhethiweko ngubaba Cyril Ramaphosa obevele kunguye umongameli weSewula Afrika.</text>
      <sha1>iairdrq9ki2udonhfcjwsb5nimlw0r1</sha1>
    </revision>
    <revision>
      <id>3116</id>
      <parentid>3027</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Jon Harald Søby|Jon Harald Søby]]</comment>
      <origin>1418</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="684" sha1="0hb5aau3oyczocbf734k5corhjrei2u" xml:space="preserve">'''Umbuso ohlanganyelweko''' mbuso lapho kuphethe khona iinhlangano kusekela kwezimbili. Ngemva kweminyaka ematjhumi ama thathu iSewula Afrika ibuswa ngaphasi kombuso wentando yenengi, unyaka we-2024 wamakhetho ube ngohlukileko ngombana ulethe umbuso wehlanganyelo lapho kuphethe khona iinhlangano zepolotiki ezinengi kungasi yinye.

Woke umuntu uyazibuza bona ngemva kwetjhuguluko elingaka kwezepolotiki inarha yeSewula Afrika izokuraga njani.

Umbuso wokuhlanganyela ubanjwe yihlangano ye Democratic Alliance, African National Congress, Umkhonto Wesizwe kanye ne Economic Freedom Fighters. Umongameli okhethiweko ngubaba Cyril Ramaphosa obevele kunguye umongameli weSewula Afrika.

</text>
      <sha1>0hb5aau3oyczocbf734k5corhjrei2u</sha1>
    </revision>
    <revision>
      <id>5936</id>
      <parentid>3116</parentid>
      <timestamp>2025-10-28T16:47:32Z</timestamp>
      <contributor>
        <username>Hlalithwa</username>
        <id>996</id>
      </contributor>
      <minor />
      <comment>Amabizo wenhlangano ezibandakanyekako</comment>
      <origin>5936</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="920" sha1="o1z7alguh9vs7pm6ewc7fqswxth15hd" xml:space="preserve">'''Umbuso ohlanganyelweko''' Mbuso lapha kuphethe khona iinhlangano ezahlukahlukeneko kungaba ngezimbili ukuya phezulu nekuyinto eyenzekako eSewula Africa. Ngemva kweminyaka ematjhumi ama thathu iSewula Afrika ibuswa ngaphasi kombuso wentando yenengi, unyaka we-2024 wamakhetho ube ngohlukileko kuneminye eminyaka eyadlulako, ngombana ulethe umbuso wehlanganyelo lapho kuphethe khona iinhlangano zepolotiki ezinengi kungasi yinye ekufaka hlangana i-African National Congress (ANC), Democratic Alliance (DA), Umkhonto Wesizwe (MK) kanye nezinye iinhlangano.

Woke umuntu uyazibuza bona ngemva kwetjhuguluko elingaka kwezepolotiki inarha yeSewula Afrika izokuraga njani ukuyaphambili.

Umbuso wokuhlanganyela ubanjwe yihlangano ye Democratic Alliance, African National Congress, Umkhonto Wesizwe kanye ne Economic Freedom Fighters. Umongameli okhethiweko ngubaba Cyril Ramaphosa obevele kunguye umongameli weSewula Afrika.</text>
      <sha1>o1z7alguh9vs7pm6ewc7fqswxth15hd</sha1>
    </revision>
  </page>
  <page>
    <title>Umbuso wentando yenengi</title>
    <ns>0</ns>
    <id>265</id>
    <revision>
      <id>1420</id>
      <timestamp>2024-03-20T06:31:17Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Umbuso wentando yenengi''', mbuso owangena eSewula afrika ngemva kwamakhetho wango 1994, ngemva kombuso wegandelelo.vUmbuso wentando yenengi ngiwo owasilethela ikululeko, ululingana kanye nokuthola ubulingiswa lokhwa nawoniweko. Ngaphasi kombuso lo babantu nofana izakhamuzi iziphethe amandla wezepolitiki. Amnandla la bawaphethe ngqo begodu bawaphethe nangabantu ababakhethileko bonyaba bazobajamela.  Lokhu kutjho bona izakhamuzi zinelungelo lokuzibadakanya ezintweni ze...&quot;</comment>
      <origin>1420</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="606" sha1="0aijkz8l3ynm92mn6srk6x6gyodonxb" xml:space="preserve">'''Umbuso wentando yenengi''', mbuso owangena eSewula afrika ngemva kwamakhetho wango 1994, ngemva kombuso wegandelelo.vUmbuso wentando yenengi ngiwo owasilethela ikululeko, ululingana kanye nokuthola ubulingiswa lokhwa nawoniweko. Ngaphasi kombuso lo babantu nofana izakhamuzi iziphethe amandla wezepolitiki. Amnandla la bawaphethe ngqo begodu bawaphethe nangabantu ababakhethileko bonyaba bazobajamela.

Lokhu kutjho bona izakhamuzi zinelungelo lokuzibadakanya ezintweni zepolotiki, ezifana namakhetho wokubeka umongameli wesitjhaba begodu zinegunya lokufaka umbono ngomthetho ezibekelwe wona enarheni.

</text>
      <sha1>0aijkz8l3ynm92mn6srk6x6gyodonxb</sha1>
    </revision>
    <revision>
      <id>1421</id>
      <parentid>1420</parentid>
      <timestamp>2024-03-20T06:31:52Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1421</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="625" sha1="kvyg778jenbeirzekrdz0gthxja397l" xml:space="preserve">'''Umbuso wentando yenengi''', mbuso owangena e[[Isewula Afrika|Sewula Afrika]] ngemva kwamakhetho wango 1994, ngemva kombuso wegandelelo.vUmbuso wentando yenengi ngiwo owasilethela ikululeko, ululingana kanye nokuthola ubulingiswa lokhwa nawoniweko. Ngaphasi kombuso lo babantu nofana izakhamuzi iziphethe amandla wezepolitiki. Amnandla la bawaphethe ngqo begodu bawaphethe nangabantu ababakhethileko bonyaba bazobajamela.

Lokhu kutjho bona izakhamuzi zinelungelo lokuzibadakanya ezintweni zepolotiki, ezifana namakhetho wokubeka umongameli wesitjhaba begodu zinegunya lokufaka umbono ngomthetho ezibekelwe wona enarheni.

</text>
      <sha1>kvyg778jenbeirzekrdz0gthxja397l</sha1>
    </revision>
    <revision>
      <id>1422</id>
      <parentid>1421</parentid>
      <timestamp>2024-03-20T06:32:22Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1422</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="640" sha1="5fp7qs4fe7gtl5yh3za3mwth3ghdm67" xml:space="preserve">'''Umbuso wentando yenengi''', mbuso owangena e[[Isewula Afrika|Sewula Afrika]] ngemva kwamakhetho wango [[Wp/na/1994|1994,]] ngemva kombuso wegandelelo.vUmbuso wentando yenengi ngiwo owasilethela ikululeko, ululingana kanye nokuthola ubulingiswa lokhwa nawoniweko. Ngaphasi kombuso lo babantu nofana izakhamuzi iziphethe amandla wezepolitiki. Amnandla la bawaphethe ngqo begodu bawaphethe nangabantu ababakhethileko bonyaba bazobajamela.

Lokhu kutjho bona izakhamuzi zinelungelo lokuzibadakanya ezintweni zepolotiki, ezifana namakhetho wokubeka umongameli wesitjhaba begodu zinegunya lokufaka umbono ngomthetho ezibekelwe wona enarheni.

</text>
      <sha1>5fp7qs4fe7gtl5yh3za3mwth3ghdm67</sha1>
    </revision>
    <revision>
      <id>1423</id>
      <parentid>1422</parentid>
      <timestamp>2024-03-20T06:32:59Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1423</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="644" sha1="a3lhecw3s0u37914njsshmty6yxbkhl" xml:space="preserve">'''Umbuso wentando yenengi''', mbuso owangena e[[Isewula Afrika|Sewula Afrika]] ngemva kwamakhetho wango [[Wp/na/1994|1994,]] ngemva kombuso wegandelelo.vUmbuso wentando yenengi ngiwo owasilethela ikululeko, ululingana kanye nokuthola ubulingiswa lokhwa nawoniweko. Ngaphasi kombuso lo babantu nofana izakhamuzi iziphethe amandla weze[[politiki]]. Amnandla la bawaphethe ngqo begodu bawaphethe nangabantu ababakhethileko bonyaba bazobajamela.

Lokhu kutjho bona izakhamuzi zinelungelo lokuzibadakanya ezintweni zepolotiki, ezifana namakhetho wokubeka umongameli wesitjhaba begodu zinegunya lokufaka umbono ngomthetho ezibekelwe wona enarheni.

</text>
      <sha1>a3lhecw3s0u37914njsshmty6yxbkhl</sha1>
    </revision>
    <revision>
      <id>1424</id>
      <parentid>1423</parentid>
      <timestamp>2024-03-20T06:33:27Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1424</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="653" sha1="7hg03sssh6642us6tvq9cosds5ll7oa" xml:space="preserve">'''Umbuso wentando yenengi''', mbuso owangena e[[Isewula Afrika|Sewula Afrika]] ngemva kwamakhetho wango [[Wp/na/1994|1994,]] ngemva kombuso wegandelelo.vUmbuso wentando yenengi ngiwo owasilethela ikululeko, ululingana kanye nokuthola ubulingiswa lokhwa nawoniweko. Ngaphasi kombuso lo babantu nofana izakhamuzi iziphethe amandla weze[[politiki|polotiki]]. Amnandla la bawaphethe ngqo begodu bawaphethe nangabantu ababakhethileko bonyaba bazobajamela.

Lokhu kutjho bona izakhamuzi zinelungelo lokuzibadakanya ezintweni zepolotiki, ezifana namakhetho wokubeka umongameli wesitjhaba begodu zinegunya lokufaka umbono ngomthetho ezibekelwe wona enarheni.

</text>
      <sha1>7hg03sssh6642us6tvq9cosds5ll7oa</sha1>
    </revision>
    <revision>
      <id>1425</id>
      <parentid>1424</parentid>
      <timestamp>2024-03-21T17:40:09Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1425</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="797" sha1="bupaesr9zfti0iz364apt9ath529mzf" xml:space="preserve">'''Umbuso wentando yenengi''', mbuso owangena e[[Isewula Afrika|Sewula Afrika]] ngemva kwamakhetho wango [[Wp/na/1994|1994,]] ngemva kombuso wegandelelo&lt;ref&gt;Southall, R., 2000. The state of democracy in South Africa. ''Journal of Commonwealth &amp; Comparative Politics'', ''38''(3), pp.147-170.&lt;/ref&gt;.Umbuso wentando yenengi ngiwo owasilethela ikululeko, ukulingana kanye nokuthola ubulingiswa lokhwa nawoniweko. Ngaphasi kombuso lo babantu nofana izakhamuzi iziphethe amandla weze[[politiki|polotiki]]. Amnandla la bawaphethe ngqo begodu bawaphethe nangabantu ababakhethileko bonyaba bazobajamela.

Lokhu kutjho bona izakhamuzi zinelungelo lokuzibadakanya ezintweni zepolotiki, ezifana namakhetho wokubeka umongameli wesitjhaba begodu zinegunya lokufaka umbono ngomthetho ezibekelwe wona enarheni.

</text>
      <sha1>bupaesr9zfti0iz364apt9ath529mzf</sha1>
    </revision>
    <revision>
      <id>1426</id>
      <parentid>1425</parentid>
      <timestamp>2024-03-21T17:42:06Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1426</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="797" sha1="trm5q392c99vpm42nb68y90buhphzms" xml:space="preserve">'''Umbuso wentando yenengi''', mbuso owangena e[[Isewula Afrika|Sewula Afrika]] ngemva kwamakhetho wango [[Wp/na/1994|1994,]] ngemva kombuso wegandelelo&lt;ref&gt;Southall, R., 2000. The state of democracy in South Africa. ''Journal of Commonwealth &amp; Comparative Politics'', ''38''(3), pp.147-170.&lt;/ref&gt;.Umbuso wentando yenengi ngiwo owasilethela ikululeko, ukulingana kanye nokuthola ubulingiswa lokhwa nawoniweko. Ngaphasi kombuso lo babantu nofana izakhamuzi iziphethe amandla weze[[politiki|polotiki]]. Amandla la bawaphethe ngqo begodu bawaphethe nangabantu ababakhethileko bonyana bazobajamela.

Lokhu kutjho bona izakhamuzi zinelungelo lokuzibandakanya ezintweni zepolotiki, ezifana namakhetho wokubeka umongameli wesitjhaba begodu zinegunya lokufaka umbono ngomthetho ezibekelwe wona enarheni.

</text>
      <sha1>trm5q392c99vpm42nb68y90buhphzms</sha1>
    </revision>
    <revision>
      <id>1427</id>
      <parentid>1426</parentid>
      <timestamp>2024-10-14T13:47:41Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>7 revisions imported</comment>
      <origin>1426</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="797" sha1="trm5q392c99vpm42nb68y90buhphzms" xml:space="preserve">'''Umbuso wentando yenengi''', mbuso owangena e[[Isewula Afrika|Sewula Afrika]] ngemva kwamakhetho wango [[Wp/na/1994|1994,]] ngemva kombuso wegandelelo&lt;ref&gt;Southall, R., 2000. The state of democracy in South Africa. ''Journal of Commonwealth &amp; Comparative Politics'', ''38''(3), pp.147-170.&lt;/ref&gt;.Umbuso wentando yenengi ngiwo owasilethela ikululeko, ukulingana kanye nokuthola ubulingiswa lokhwa nawoniweko. Ngaphasi kombuso lo babantu nofana izakhamuzi iziphethe amandla weze[[politiki|polotiki]]. Amandla la bawaphethe ngqo begodu bawaphethe nangabantu ababakhethileko bonyana bazobajamela.

Lokhu kutjho bona izakhamuzi zinelungelo lokuzibandakanya ezintweni zepolotiki, ezifana namakhetho wokubeka umongameli wesitjhaba begodu zinegunya lokufaka umbono ngomthetho ezibekelwe wona enarheni.

</text>
      <sha1>trm5q392c99vpm42nb68y90buhphzms</sha1>
    </revision>
    <revision>
      <id>2163</id>
      <parentid>1427</parentid>
      <timestamp>2024-11-27T06:17:33Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>+ Iinkomba</comment>
      <origin>2163</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="823" sha1="sdvk6uyh1t9tj4iev8sqolyje6m2p2q" xml:space="preserve">'''Umbuso wentando yenengi''', mbuso owangena e[[Isewula Afrika|Sewula Afrika]] ngemva kwamakhetho wango [[Wp/na/1994|1994,]] ngemva kombuso wegandelelo&lt;ref&gt;Southall, R., 2000. The state of democracy in South Africa. ''Journal of Commonwealth &amp; Comparative Politics'', ''38''(3), pp.147-170.&lt;/ref&gt;.Umbuso wentando yenengi ngiwo owasilethela ikululeko, ukulingana kanye nokuthola ubulingiswa lokhwa nawoniweko. Ngaphasi kombuso lo babantu nofana izakhamuzi iziphethe amandla weze[[politiki|polotiki]]. Amandla la bawaphethe ngqo begodu bawaphethe nangabantu ababakhethileko bonyana bazobajamela.

Lokhu kutjho bona izakhamuzi zinelungelo lokuzibandakanya ezintweni zepolotiki, ezifana namakhetho wokubeka umongameli wesitjhaba begodu zinegunya lokufaka umbono ngomthetho ezibekelwe wona enarheni.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>sdvk6uyh1t9tj4iev8sqolyje6m2p2q</sha1>
    </revision>
    <revision>
      <id>5141</id>
      <parentid>2163</parentid>
      <timestamp>2025-08-10T18:27:41Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>5141</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="892" sha1="7heurj6zgy6qycxryihu4ghhprryyw0" xml:space="preserve">'''Umbuso wentando yenengi''', mbuso owangena e[[Isewula Afrika|Sewula Afrika]] ngemva kwamakhetho wango [[Wp/na/1994|1994,]] ngemva kombuso wegandelelo&lt;ref&gt;Southall, R., 2000. The state of democracy in South Africa. ''Journal of Commonwealth &amp; Comparative Politics'', ''38''(3), pp.147-170.&lt;/ref&gt;.Umbuso wentando yenengi ngiwo owasilethela ikululeko, ukulingana kanye nokuthola ubulingiswa lokhwa nawoniweko. Ngaphasi kombuso lo babantu nofana izakhamuzi iziphethe amandla weze[[politiki|polotiki]]. Amandla la bawaphethe ngqo begodu bawaphethe nangabantu ababakhethileko bonyana bazobajamela.

Lokhu kutjho bona izakhamuzi zinelungelo lokuzibandakanya ezintweni zepolotiki, ezifana namakhetho wokubeka umongameli wesitjhaba begodu zinegunya lokufaka umbono ngomthetho ezibekelwe wona enarheni.

== Iinkomba ==
{{Reflist}}
[[Category:Umboso wentando yenengi]]
[[Category:Umbuso wegandelelo]]</text>
      <sha1>7heurj6zgy6qycxryihu4ghhprryyw0</sha1>
    </revision>
    <revision>
      <id>5142</id>
      <parentid>5141</parentid>
      <timestamp>2025-08-10T18:28:06Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>5142</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="892" sha1="thporpy1maloxqb26am2m4dtqnvcm9b" xml:space="preserve">'''Umbuso wentando yenengi''', mbuso owangena e[[Isewula Afrika|Sewula Afrika]] ngemva kwamakhetho wango [[Wp/na/1994|1994,]] ngemva kombuso wegandelelo&lt;ref&gt;Southall, R., 2000. The state of democracy in South Africa. ''Journal of Commonwealth &amp; Comparative Politics'', ''38''(3), pp.147-170.&lt;/ref&gt;.Umbuso wentando yenengi ngiwo owasilethela ikululeko, ukulingana kanye nokuthola ubulingiswa lokhwa nawoniweko. Ngaphasi kombuso lo babantu nofana izakhamuzi iziphethe amandla weze[[politiki|polotiki]]. Amandla la bawaphethe ngqo begodu bawaphethe nangabantu ababakhethileko bonyana bazobajamela.

Lokhu kutjho bona izakhamuzi zinelungelo lokuzibandakanya ezintweni zepolotiki, ezifana namakhetho wokubeka umongameli wesitjhaba begodu zinegunya lokufaka umbono ngomthetho ezibekelwe wona enarheni.

== Iinkomba ==
{{Reflist}}
[[Category:Umbuso wentando yenengi]]
[[Category:Umbuso wegandelelo]]</text>
      <sha1>thporpy1maloxqb26am2m4dtqnvcm9b</sha1>
    </revision>
  </page>
  <page>
    <title>Umdlalo webholo</title>
    <ns>0</ns>
    <id>266</id>
    <revision>
      <id>1428</id>
      <timestamp>2024-08-07T18:02:00Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Umdlalo''' webholo kumdlalo odlawa ngokurarha ibholo, udlalwa ziinqheema ezimbili ngokuphikisana. Isiqhema sebholo ngasinye siba nabadlali abayitjhumi nanye. Abadlali badlala nebholo erondo boke ngomnqopho wokukora amagondelo nokuvimba isiqheema esiphikisako bonyana singangenisi amagondelo.  &quot;</comment>
      <origin>1428</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="296" sha1="1m50acw24od0kezcm1c64do24ari3u2" xml:space="preserve">'''Umdlalo''' webholo kumdlalo odlawa ngokurarha ibholo, udlalwa ziinqheema ezimbili ngokuphikisana. Isiqhema sebholo ngasinye siba nabadlali abayitjhumi nanye. Abadlali badlala nebholo erondo boke ngomnqopho wokukora amagondelo nokuvimba isiqheema esiphikisako bonyana singangenisi amagondelo.

</text>
      <sha1>1m50acw24od0kezcm1c64do24ari3u2</sha1>
    </revision>
    <revision>
      <id>1429</id>
      <parentid>1428</parentid>
      <timestamp>2024-08-07T18:13:14Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1429</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="444" sha1="940oacdkzt3k6ul6mmad8i2ms84bsce" xml:space="preserve">'''Umdlalo''' webholo kumdlalo odlawa ngokurarha ibholo, udlalwa ziinqheema ezimbili ngokuphikisana. Isiqhema sebholo ngasinye siba nabadlali abayitjhumi nanye. Abadlali badlala nebholo erondo boke ngomnqopho wokukora amagondelo nokuvimba isiqheema esiphikisako bonyana singangenisi amagondelo.

== Umthetho  womdlalo webholo ==

=== isikhathi ===

=== Ukukora amagondelo ===

=== Ukujama kwabadlali ===

== Ubuhle bokudlala umdlalo webholo ==
</text>
      <sha1>940oacdkzt3k6ul6mmad8i2ms84bsce</sha1>
    </revision>
    <revision>
      <id>1430</id>
      <parentid>1429</parentid>
      <timestamp>2024-08-08T09:46:33Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1430</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="667" sha1="nr0j3u742twotwrql292mp35qbd4vgz" xml:space="preserve">'''Umdlalo''' webholo kumdlalo odlawa ngokurarha ibholo, udlalwa ziinqheema ezimbili ngokuphikisana. Isiqhema sebholo ngasinye siba nabadlali abayitjhumi nanye. Abadlali badlala nebholo erondo boke ngomnqopho wokukora amagondelo nokuvimba isiqheema esiphikisako bonyana singangenisi amagondelo.

== Umthetho  womdlalo webholo ==

=== isikhathi ===
Umdlalo webholo udlala isikhathi eaimizuzu ema-45 bese bayaphumula imizuzu eli-15 bese barage godu badlale imizuzu ema-45. Kwesinye iskhathi kusuke kube nesikhathi esingezelelwako ukuze kuzokuba khona isiqhema esithumbako.

=== Ukukora amagondelo ===

=== Ukujama kwabadlali ===

== Ubuhle bokudlala umdlalo webholo ==
</text>
      <sha1>nr0j3u742twotwrql292mp35qbd4vgz</sha1>
    </revision>
    <revision>
      <id>1431</id>
      <parentid>1430</parentid>
      <timestamp>2024-08-08T09:49:01Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1431</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="761" sha1="stlnow230mnnautv3uqofmyt26f19h8" xml:space="preserve">'''Umdlalo''' webholo kumdlalo odlawa ngokurarha ibholo, udlalwa ziinqheema ezimbili ngokuphikisana. Isiqhema sebholo ngasinye siba nabadlali abayitjhumi nanye. Abadlali badlala nebholo erondo boke ngomnqopho wokukora amagondelo nokuvimba isiqheema esiphikisako bonyana singangenisi amagondelo.

== Umthetho  womdlalo webholo ==

=== isikhathi ===
Umdlalo webholo udlala isikhathi eaimizuzu ema-45 bese bayaphumula imizuzu eli-15 bese barage godu badlale imizuzu ema-45. Kwesinye iskhathi kusuke kube nesikhathi esingezelelwako ukuze kuzokuba khona isiqhema esithumbako.

=== Ukukora amagondelo ===
Amagondelo akorwa ngokufakwa enetheni begodu angafakwa ngehloko nanyana ngokurarhwa ngenyawo.

=== Ukujama kwabadlali ===

== Ubuhle bokudlala umdlalo webholo ==
</text>
      <sha1>stlnow230mnnautv3uqofmyt26f19h8</sha1>
    </revision>
    <revision>
      <id>1432</id>
      <parentid>1431</parentid>
      <timestamp>2024-08-08T10:07:01Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1432</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="909" sha1="rcjh2meztey0vjyafe0ixkzbx7ndyk7" xml:space="preserve">'''Umdlalo''' webholo kumdlalo odlawa ngokurarha ibholo, udlalwa ziinqheema ezimbili ngokuphikisana. Isiqhema sebholo ngasinye siba nabadlali abayitjhumi nanye. Abadlali badlala nebholo erondo boke ngomnqopho wokukora amagondelo nokuvimba isiqheema esiphikisako bonyana singangenisi amagondelo.

== Umthetho  womdlalo webholo ==

=== isikhathi ===
Umdlalo webholo udlala isikhathi eaimizuzu ema-45 bese bayaphumula imizuzu eli-15 bese barage godu badlale imizuzu ema-45. Kwesinye iskhathi kusuke kube nesikhathi esingezelelwako ukuze kuzokuba khona isiqhema esithumbako.

=== Ukukora amagondelo ===
Amagondelo akorwa ngokufakwa enetheni begodu angafakwa ngehloko nanyana ngokurarhwa ngenyawo.

=== Ukujama kwabadlali ===
Abadlali bomdlalo we bholo kubadlali abavimba amagondelo, ubadlali abajama phambili, abadlali abajama phakhathi begodu kube nalabo abajama ngemuva.

== Ubuhle bokudlala umdlalo webholo ==
</text>
      <sha1>rcjh2meztey0vjyafe0ixkzbx7ndyk7</sha1>
    </revision>
    <revision>
      <id>1433</id>
      <parentid>1432</parentid>
      <timestamp>2024-08-08T10:08:35Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1433</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="873" sha1="8qn7rki4gwvlz4u628354div9dkkndp" xml:space="preserve">'''Umdlalo''' webholo kumdlalo odlawa ngokurarha ibholo, udlalwa ziinqheema ezimbili ngokuphikisana. Isiqhema sebholo ngasinye siba nabadlali abayitjhumi nanye. Abadlali badlala nebholo erondo boke ngomnqopho wokukora amagondelo nokuvimba isiqheema esiphikisako bonyana singangenisi amagondelo.

== Umthetho  womdlalo webholo ==

=== isikhathi ===
Umdlalo webholo udlala isikhathi eaimizuzu ema-45 bese bayaphumula imizuzu eli-15 bese barage godu badlale imizuzu ema-45. Kwesinye iskhathi kusuke kube nesikhathi esingezelelwako ukuze kuzokuba khona isiqhema esithumbako.

=== Ukukora amagondelo ===
Amagondelo akorwa ngokufakwa enetheni begodu angafakwa ngehloko nanyana ngokurarhwa ngenyawo.

=== Ukujama kwabadlali ===
Abadlali bomdlalo we bholo kubadlali abavimba amagondelo, ubadlali abajama phambili, abadlali abajama phakathi.

== Ubuhle bokudlala umdlalo webholo ==
</text>
      <sha1>8qn7rki4gwvlz4u628354div9dkkndp</sha1>
    </revision>
    <revision>
      <id>1434</id>
      <parentid>1433</parentid>
      <timestamp>2024-08-08T10:11:55Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1434</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1106" sha1="4a2d8ve7kiz32v94uwuen7ymsuojm2s" xml:space="preserve">'''Umdlalo''' webholo kumdlalo odlawa ngokurarha ibholo, udlalwa ziinqheema ezimbili ngokuphikisana. Isiqhema sebholo ngasinye siba nabadlali abayitjhumi nanye. Abadlali badlala nebholo erondo boke ngomnqopho wokukora amagondelo nokuvimba isiqheema esiphikisako bonyana singangenisi amagondelo.

== Umthetho  womdlalo webholo ==

=== isikhathi ===
Umdlalo webholo udlala isikhathi eaimizuzu ema-45 bese bayaphumula imizuzu eli-15 bese barage godu badlale imizuzu ema-45. Kwesinye iskhathi kusuke kube nesikhathi esingezelelwako ukuze kuzokuba khona isiqhema esithumbako.

=== Ukukora amagondelo ===
Amagondelo akorwa ngokufakwa enetheni begodu angafakwa ngehloko nanyana ngokurarhwa ngenyawo.

=== Ukujama kwabadlali ===
Abadlali bomdlalo we bholo kubadlali abavimba amagondelo, ubadlali abajama phambili, abadlali abajama phakathi.

== Ubuhle bokudlala umdlalo webholo ==
Umdlalo webholo kumdlalo omuhle ngombana umuntu owudlalako uba nomzimba onepilo ngombana umdloalo lo wenza bona imithambo ekhambisa igazi ivuleke igazi lirhone ukukhamba kuhle emzimbeni begodu umzimba angekhe wathola amalwelwe lula.
</text>
      <sha1>4a2d8ve7kiz32v94uwuen7ymsuojm2s</sha1>
    </revision>
    <revision>
      <id>1435</id>
      <parentid>1434</parentid>
      <timestamp>2024-08-08T10:17:07Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1435</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1274" sha1="kprhtsxsndqemjy7ymyoufsnpt9oq48" xml:space="preserve">'''Umdlalo''' webholo kumdlalo odlawa ngokurarha ibholo, udlalwa ziinqheema ezimbili ngokuphikisana. Isiqhema sebholo ngasinye siba nabadlali abayitjhumi nanye. Abadlali badlala nebholo erondo boke ngomnqopho wokukora amagondelo nokuvimba isiqheema esiphikisako bonyana singangenisi amagondelo.

== Umthetho  womdlalo webholo ==

=== isikhathi ===
Umdlalo webholo udlala isikhathi eaimizuzu ema-45 bese bayaphumula imizuzu eli-15 bese barage godu badlale imizuzu ema-45. Kwesinye iskhathi kusuke kube nesikhathi esingezelelwako ukuze kuzokuba khona isiqhema esithumbako.

=== Ukukora amagondelo ===
Amagondelo akorwa ngokufakwa enetheni begodu angafakwa ngehloko nanyana ngokurarhwa ngenyawo.

=== Ukujama kwabadlali ===
Abadlali bomdlalo we bholo kubadlali abavimba amagondelo, ubadlali abajama phambili, abadlali abajama phakathi.

== Ubuhle bokudlala umdlalo webholo ==
Umdlalo webholo kumdlalo omuhle ngombana umuntu owudlalako uba nomzimba onepilo ngombana umdloalo lo wenza bona imithambo ekhambisa igazi ivuleke igazi lirhone ukukhamba kuhle emzimbeni begodu umzimba angekhe wathola amalwelwe lula. Umdlalo lokha nawuwudlako uba namandla begodu ukghone ukugijima ngebelo. Ilekelela umuntu bona akghone ukusebenzisana nabantu begodu abe nekghono lokurarulula imiraro.
</text>
      <sha1>kprhtsxsndqemjy7ymyoufsnpt9oq48</sha1>
    </revision>
    <revision>
      <id>1436</id>
      <parentid>1435</parentid>
      <timestamp>2024-08-08T10:18:50Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1436</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1363" sha1="5tx7vrl7oek91278dfh8hofbw3d0rqi" xml:space="preserve">'''Umdlalo''' webholo kumdlalo odlawa ngokurarha ibholo, udlalwa ziinqheema ezimbili ngokuphikisana. Isiqhema sebholo ngasinye siba nabadlali abayitjhumi nanye. Abadlali badlala nebholo erondo boke ngomnqopho wokukora amagondelo nokuvimba isiqheema esiphikisako bonyana singangenisi amagondelo.

== Umthetho  womdlalo webholo ==

=== isikhathi ===
Umdlalo webholo udlala isikhathi eaimizuzu ema-45 bese bayaphumula imizuzu eli-15 bese barage godu badlale imizuzu ema-45. Kwesinye iskhathi kusuke kube nesikhathi esingezelelwako ukuze kuzokuba khona isiqhema esithumbako.

=== Ukukora amagondelo ===
Amagondelo akorwa ngokufakwa enetheni begodu angafakwa ngehloko nanyana ngokurarhwa ngenyawo. Amagandelo ayakorwa lokha umdlalo usadlala begodu kukurwa kuphela lokha nakuma penaldi. 

=== Ukujama kwabadlali ===
Abadlali bomdlalo we bholo kubadlali abavimba amagondelo, ubadlali abajama phambili, abadlali abajama phakathi.

== Ubuhle bokudlala umdlalo webholo ==
Umdlalo webholo kumdlalo omuhle ngombana umuntu owudlalako uba nomzimba onepilo ngombana umdloalo lo wenza bona imithambo ekhambisa igazi ivuleke igazi lirhone ukukhamba kuhle emzimbeni begodu umzimba angekhe wathola amalwelwe lula. Umdlalo lokha nawuwudlako uba namandla begodu ukghone ukugijima ngebelo. Ilekelela umuntu bona akghone ukusebenzisana nabantu begodu abe nekghono lokurarulula imiraro.
</text>
      <sha1>5tx7vrl7oek91278dfh8hofbw3d0rqi</sha1>
    </revision>
    <revision>
      <id>1437</id>
      <parentid>1436</parentid>
      <timestamp>2024-08-18T12:40:16Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1437</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1420" sha1="6p9h55k5jatdp0n6t9f49l8hunliurk" xml:space="preserve">[[Isimumathi:Umdlalo webholo.jpg|thumb|Umdlalo webholo]]
'''Umdlalo''' webholo kumdlalo odlawa ngokurarha ibholo, udlalwa ziinqheema ezimbili ngokuphikisana. Isiqhema sebholo ngasinye siba nabadlali abayitjhumi nanye. Abadlali badlala nebholo erondo boke ngomnqopho wokukora amagondelo nokuvimba isiqheema esiphikisako bonyana singangenisi amagondelo.

== Umthetho  womdlalo webholo ==

=== isikhathi ===
Umdlalo webholo udlala isikhathi eaimizuzu ema-45 bese bayaphumula imizuzu eli-15 bese barage godu badlale imizuzu ema-45. Kwesinye iskhathi kusuke kube nesikhathi esingezelelwako ukuze kuzokuba khona isiqhema esithumbako.

=== Ukukora amagondelo ===
Amagondelo akorwa ngokufakwa enetheni begodu angafakwa ngehloko nanyana ngokurarhwa ngenyawo. Amagandelo ayakorwa lokha umdlalo usadlala begodu kukurwa kuphela lokha nakuma penaldi. 

=== Ukujama kwabadlali ===
Abadlali bomdlalo we bholo kubadlali abavimba amagondelo, ubadlali abajama phambili, abadlali abajama phakathi.

== Ubuhle bokudlala umdlalo webholo ==
Umdlalo webholo kumdlalo omuhle ngombana umuntu owudlalako uba nomzimba onepilo ngombana umdloalo lo wenza bona imithambo ekhambisa igazi ivuleke igazi lirhone ukukhamba kuhle emzimbeni begodu umzimba angekhe wathola amalwelwe lula. Umdlalo lokha nawuwudlako uba namandla begodu ukghone ukugijima ngebelo. Ilekelela umuntu bona akghone ukusebenzisana nabantu begodu abe nekghono lokurarulula imiraro.
</text>
      <sha1>6p9h55k5jatdp0n6t9f49l8hunliurk</sha1>
    </revision>
    <revision>
      <id>1438</id>
      <parentid>1437</parentid>
      <timestamp>2024-10-14T13:47:41Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>10 revisions imported</comment>
      <origin>1437</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1420" sha1="6p9h55k5jatdp0n6t9f49l8hunliurk" xml:space="preserve">[[Isimumathi:Umdlalo webholo.jpg|thumb|Umdlalo webholo]]
'''Umdlalo''' webholo kumdlalo odlawa ngokurarha ibholo, udlalwa ziinqheema ezimbili ngokuphikisana. Isiqhema sebholo ngasinye siba nabadlali abayitjhumi nanye. Abadlali badlala nebholo erondo boke ngomnqopho wokukora amagondelo nokuvimba isiqheema esiphikisako bonyana singangenisi amagondelo.

== Umthetho  womdlalo webholo ==

=== isikhathi ===
Umdlalo webholo udlala isikhathi eaimizuzu ema-45 bese bayaphumula imizuzu eli-15 bese barage godu badlale imizuzu ema-45. Kwesinye iskhathi kusuke kube nesikhathi esingezelelwako ukuze kuzokuba khona isiqhema esithumbako.

=== Ukukora amagondelo ===
Amagondelo akorwa ngokufakwa enetheni begodu angafakwa ngehloko nanyana ngokurarhwa ngenyawo. Amagandelo ayakorwa lokha umdlalo usadlala begodu kukurwa kuphela lokha nakuma penaldi. 

=== Ukujama kwabadlali ===
Abadlali bomdlalo we bholo kubadlali abavimba amagondelo, ubadlali abajama phambili, abadlali abajama phakathi.

== Ubuhle bokudlala umdlalo webholo ==
Umdlalo webholo kumdlalo omuhle ngombana umuntu owudlalako uba nomzimba onepilo ngombana umdloalo lo wenza bona imithambo ekhambisa igazi ivuleke igazi lirhone ukukhamba kuhle emzimbeni begodu umzimba angekhe wathola amalwelwe lula. Umdlalo lokha nawuwudlako uba namandla begodu ukghone ukugijima ngebelo. Ilekelela umuntu bona akghone ukusebenzisana nabantu begodu abe nekghono lokurarulula imiraro.
</text>
      <sha1>6p9h55k5jatdp0n6t9f49l8hunliurk</sha1>
    </revision>
    <revision>
      <id>3004</id>
      <parentid>1438</parentid>
      <timestamp>2025-06-06T20:20:57Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>just ban me already</comment>
      <origin>3004</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1500" sha1="072tvglz5ocl0crhejhx13i8iopjdbs" xml:space="preserve">[[Isimumathi:Umdlalo webholo.jpg|thumb|Umdlalo webholo]]
'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. Umdlalo''' webholo kumdlalo odlawa ngokurarha ibholo, udlalwa ziinqheema ezimbili ngokuphikisana. Isiqhema sebholo ngasinye siba nabadlali abayitjhumi nanye. Abadlali badlala nebholo erondo boke ngomnqopho wokukora amagondelo nokuvimba isiqheema esiphikisako bonyana singangenisi amagondelo.

== Umthetho  womdlalo webholo ==

=== isikhathi ===
Umdlalo webholo udlala isikhathi eaimizuzu ema-45 bese bayaphumula imizuzu eli-15 bese barage godu badlale imizuzu ema-45. Kwesinye iskhathi kusuke kube nesikhathi esingezelelwako ukuze kuzokuba khona isiqhema esithumbako.

=== Ukukora amagondelo ===
Amagondelo akorwa ngokufakwa enetheni begodu angafakwa ngehloko nanyana ngokurarhwa ngenyawo. Amagandelo ayakorwa lokha umdlalo usadlala begodu kukurwa kuphela lokha nakuma penaldi. 

=== Ukujama kwabadlali ===
Abadlali bomdlalo we bholo kubadlali abavimba amagondelo, ubadlali abajama phambili, abadlali abajama phakathi.

== Ubuhle bokudlala umdlalo webholo ==
Umdlalo webholo kumdlalo omuhle ngombana umuntu owudlalako uba nomzimba onepilo ngombana umdloalo lo wenza bona imithambo ekhambisa igazi ivuleke igazi lirhone ukukhamba kuhle emzimbeni begodu umzimba angekhe wathola amalwelwe lula. Umdlalo lokha nawuwudlako uba namandla begodu ukghone ukugijima ngebelo. Ilekelela umuntu bona akghone ukusebenzisana nabantu begodu abe nekghono lokurarulula imiraro.</text>
      <sha1>072tvglz5ocl0crhejhx13i8iopjdbs</sha1>
    </revision>
    <revision>
      <id>3049</id>
      <parentid>3004</parentid>
      <timestamp>2025-06-07T03:05:22Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Jon Harald Søby|Jon Harald Søby]]</comment>
      <origin>1437</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1420" sha1="6p9h55k5jatdp0n6t9f49l8hunliurk" xml:space="preserve">[[Isimumathi:Umdlalo webholo.jpg|thumb|Umdlalo webholo]]
'''Umdlalo''' webholo kumdlalo odlawa ngokurarha ibholo, udlalwa ziinqheema ezimbili ngokuphikisana. Isiqhema sebholo ngasinye siba nabadlali abayitjhumi nanye. Abadlali badlala nebholo erondo boke ngomnqopho wokukora amagondelo nokuvimba isiqheema esiphikisako bonyana singangenisi amagondelo.

== Umthetho  womdlalo webholo ==

=== isikhathi ===
Umdlalo webholo udlala isikhathi eaimizuzu ema-45 bese bayaphumula imizuzu eli-15 bese barage godu badlale imizuzu ema-45. Kwesinye iskhathi kusuke kube nesikhathi esingezelelwako ukuze kuzokuba khona isiqhema esithumbako.

=== Ukukora amagondelo ===
Amagondelo akorwa ngokufakwa enetheni begodu angafakwa ngehloko nanyana ngokurarhwa ngenyawo. Amagandelo ayakorwa lokha umdlalo usadlala begodu kukurwa kuphela lokha nakuma penaldi. 

=== Ukujama kwabadlali ===
Abadlali bomdlalo we bholo kubadlali abavimba amagondelo, ubadlali abajama phambili, abadlali abajama phakathi.

== Ubuhle bokudlala umdlalo webholo ==
Umdlalo webholo kumdlalo omuhle ngombana umuntu owudlalako uba nomzimba onepilo ngombana umdloalo lo wenza bona imithambo ekhambisa igazi ivuleke igazi lirhone ukukhamba kuhle emzimbeni begodu umzimba angekhe wathola amalwelwe lula. Umdlalo lokha nawuwudlako uba namandla begodu ukghone ukugijima ngebelo. Ilekelela umuntu bona akghone ukusebenzisana nabantu begodu abe nekghono lokurarulula imiraro.
</text>
      <sha1>6p9h55k5jatdp0n6t9f49l8hunliurk</sha1>
    </revision>
  </page>
  <page>
    <title>Umehluko hlangan kwedamu nomlambo</title>
    <ns>0</ns>
    <id>267</id>
    <redirect title="Umehluko hlangana kwedamu nomlambo" />
    <revision>
      <id>1439</id>
      <timestamp>2024-09-16T11:55:37Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Bobbyshabangu moved page [[Umehluko hlangan kwedamu nomlambo]] to [[Umehluko hlangana kwedamu nomlambo]]</comment>
      <origin>1439</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="48" sha1="212x0jtpl3fz4h7u2ytauos8squ8qhr" xml:space="preserve">#REDIRECT [[Umehluko hlangana kwedamu nomlambo]]</text>
      <sha1>212x0jtpl3fz4h7u2ytauos8squ8qhr</sha1>
    </revision>
    <revision>
      <id>1440</id>
      <parentid>1439</parentid>
      <timestamp>2024-10-14T13:47:41Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>1439</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="48" sha1="212x0jtpl3fz4h7u2ytauos8squ8qhr" xml:space="preserve">#REDIRECT [[Umehluko hlangana kwedamu nomlambo]]</text>
      <sha1>212x0jtpl3fz4h7u2ytauos8squ8qhr</sha1>
    </revision>
  </page>
  <page>
    <title>Umehluko hlangana kwedamu nomlambo</title>
    <ns>0</ns>
    <id>268</id>
    <revision>
      <id>1441</id>
      <timestamp>2024-08-13T10:22:16Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;{{DISPLAYTITLE:Umehluko hlangana kwedamu nomlambo.}}  == '''Umehluko hlangana kwedamu nomlambo.''' ==  === '''Isingeniso''' === Eemphakathini esiphila kiyo kuneendlela ezinengi zokubulunga amanzi nalezo ezisetjenziswa njengemithombo yamanzi. Iindlela lezi ziqakatheke kwamamba ekwenzeni isiqiniseko sokuthi abantu baba nepilo begodu bafunyana amanzi. Nanyana kunjalo-ke, ngaphasi kwesihloko sethu lesi sizokudzimelela khulu edamini nemlanjeni. Sizokuthoma ngesihloko es...&quot;</comment>
      <origin>1441</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4768" sha1="27ung2hq6veowbvc7c6mpapy1qzqprb" xml:space="preserve">{{DISPLAYTITLE:Umehluko hlangana kwedamu nomlambo.}}

== '''Umehluko hlangana kwedamu nomlambo.''' ==

=== '''Isingeniso''' ===
Eemphakathini esiphila kiyo kuneendlela ezinengi zokubulunga amanzi nalezo ezisetjenziswa njengemithombo yamanzi. Iindlela lezi ziqakatheke kwamamba ekwenzeni isiqiniseko sokuthi abantu baba nepilo begodu bafunyana amanzi. Nanyana kunjalo-ke, ngaphasi kwesihloko sethu lesi sizokudzimelela khulu edamini nemlanjeni. Sizokuthoma ngesihloko esithi, Kuyini idamu? bese kulandele esithi, Kuyini umlambo?.

==== '''Kuyini i[[:en:Dam|damu]]?''' ====
[[Isimumathi:Idamu lokubulunga amanzi Kosini.jpg|thumb|Idamu lokubulunga amanzi, langeKosini]]
Kwesinye isikhathi kuyaye kutlhogeke bonyana kukhongezelwe amanzi begodu abulungwe ukuze abantu bawafunyane (Wikipedia 2024a&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. Dam. Itholakala ku-: &lt;nowiki&gt;https://en.wikipedia.org/wiki/Dam&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). Isesetjenziswa sokukhongenzela amanzi begodu siwabulunge sibizwa bonyana lidamu (Wikipedia 2024a&lt;ref name=&quot;:0&quot; /&gt;). Idamu liyakhiwa ngomnqopho wokubamba amanzi begodu liwabulunge (National Geographic 2024a&lt;ref name=&quot;:1&quot;&gt;National Geographic. 2024. Dams. Itholakala ku-: &lt;nowiki&gt;https://education.nationalgeographic.org/resource/dams/&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). Amadamu la, ngesakhiwo nobungako kanye nomsebenzi angahluka ngokuya kweendawo neminqopho yawo.
[[Isimumathi:Idamu leKosini emThambithini.jpg|left|thumb|220x220px|Idamu leKosini, emThambithini]]
Kukhona [https://education.nationalgeographic.org/resource/dams/ amadamu] lawo amakhulu ngobujamo begodu umsebenzi wawo kukubulunga amanzi kanye nokuwasabalalise eendaweni nanyana kumadamu amancani lawo aphakela abantu nemiphakathi ngamanzi (The British Dam Society 2024a&lt;ref name=&quot;:2&quot;&gt;The British Dam Society. 2024. What is dam?. Itholakala ku-: &lt;nowiki&gt;https://britishdams.org/about-dams/dam-information/&lt;/nowiki&gt;. Ifunywane ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). [https://britishdams.org/about-dams/dam-information/ Amadamu] la, afuna itlhogonyelo tle begodu nalo itlhogonyelo lawo liyahluka. Idamu elikhulu lifuna itlhogonyelo elikhulu begodu lifuna nesikhathi esinengi lokha nalimadaniswa nedamu elincani. Amadamu kanengi afunyana nanyana amukela amanzi ukusuka emlanjeni ngesikhathi lapho kunezulu elinengi (Wikipedia 2024a&lt;ref name=&quot;:0&quot; /&gt;; National Geographic 2024a&lt;ref name=&quot;:1&quot; /&gt;; ne-The British Dam Society 2024a&lt;ref name=&quot;:2&quot; /&gt;).

Ukuyisonga, idamu liyakhiwa begodu liyahluka ngomnqopho. Kodwana, limthombo oqakathekileko mayelana nokuqinisekiswa bonyana imiphakathi ifunyana amanzi. 

==== '''Kuyini [[:en:River|umlambo]]?''' ====
[[Isimumathi:Umlambo iMoutse emThambothini.jpg|thumb|Umlambo iMoutse, eKosini]]
[https://www.britannica.com/science/river Umlambo] singatjho bonyana kulidamu lemvelo lelo elingakakhiwa kodwana eliziveleleko (Wikipedia 2024b;&lt;ref&gt;Wikipedia. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://en.wikipedia.org/wiki/River&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt; ne-Britannica 2024&lt;ref&gt;Britannica. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://www.britannica.com/science/river&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Ngamanye amagama, [https://smartwatermagazine.com/q-a/what-a-river umlambo] uyazivelela begodu nobujamo bawo buyazenzakalela. [https://education.nationalgeographic.org/resource/river/ Imilambo] nayo iyahluka ngobujamo begodu imithombo yeempilo yeenlwani ezinengi nabantu (National Geographic 2024b&lt;ref name=&quot;:3&quot;&gt;National Geographic. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://education.nationalgeographic.org/resource/river/&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Iinlwani ezitholakala emilanjeni ziyahluka ngokuya kweendawo kanye nobujamo bezulu.

Imilambo ikhongozela amanzi wezulu bese iphakele amadamu amanzi lawo ukuze abulungwe amanzi begodu kwenziwe isiqiniseko sokuthi abantu neenlwana bafunyana amanzi (National Geographic 2024b&lt;ref name=&quot;:3&quot; /&gt;; ne-Smart Water Magazine 2024&lt;ref&gt;Smart Water Magazine. 2024. What is a river?. Itholakala ku-:&lt;nowiki&gt;https://smartwatermagazine.com/q-a/what-a-river&lt;/nowiki&gt;. Ifunyenwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Nanyana kunjalo-ke, kukhona imiphakathi ekha nanyana esebenzisa amanzi bunqopha kusuka emlanjeni ngebanga lokungabi nayo imithangalasisekelo yamanzi. Lokhu kusitjengisa ukuqakatheka kwemilambo begodu nesidingo sokunakekela imilambo esinayo. 

=== '''Isiphetho''' ===
Idamu singatjho bona mlambo owakhiweko bese kuthi umlambo wona kube lidami lemvelo nanyana lendabuko lelo elizenzakalelako. Idamu esikhathini esinengi lithembele emlanjeni bona lifunyane amanzi, kanti umlambo wona ukhongozela amanzi wezulu. 

=== '''Isilululwazi/umthombolwazi''' ===
&lt;references /&gt;</text>
      <sha1>27ung2hq6veowbvc7c6mpapy1qzqprb</sha1>
    </revision>
    <revision>
      <id>1442</id>
      <parentid>1441</parentid>
      <timestamp>2024-08-19T07:30:28Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <comment>/* Umehluko hlangana kwedamu nomlambo. */</comment>
      <origin>1442</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4767" sha1="g6fsqm36pywhucbnow70kd2s2p59dtp" xml:space="preserve">{{DISPLAYTITLE:Umehluko hlangana kwedamu nomlambo.}}

== '''Umehluko hlangana kwedamu nomlambo''' ==

=== '''Isingeniso''' ===
Eemphakathini esiphila kiyo kuneendlela ezinengi zokubulunga amanzi nalezo ezisetjenziswa njengemithombo yamanzi. Iindlela lezi ziqakatheke kwamamba ekwenzeni isiqiniseko sokuthi abantu baba nepilo begodu bafunyana amanzi. Nanyana kunjalo-ke, ngaphasi kwesihloko sethu lesi sizokudzimelela khulu edamini nemlanjeni. Sizokuthoma ngesihloko esithi, Kuyini idamu? bese kulandele esithi, Kuyini umlambo?.

==== '''Kuyini i[[:en:Dam|damu]]?''' ====
[[Isimumathi:Idamu lokubulunga amanzi Kosini.jpg|thumb|Idamu lokubulunga amanzi, langeKosini]]
Kwesinye isikhathi kuyaye kutlhogeke bonyana kukhongezelwe amanzi begodu abulungwe ukuze abantu bawafunyane (Wikipedia 2024a&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. Dam. Itholakala ku-: &lt;nowiki&gt;https://en.wikipedia.org/wiki/Dam&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). Isesetjenziswa sokukhongenzela amanzi begodu siwabulunge sibizwa bonyana lidamu (Wikipedia 2024a&lt;ref name=&quot;:0&quot; /&gt;). Idamu liyakhiwa ngomnqopho wokubamba amanzi begodu liwabulunge (National Geographic 2024a&lt;ref name=&quot;:1&quot;&gt;National Geographic. 2024. Dams. Itholakala ku-: &lt;nowiki&gt;https://education.nationalgeographic.org/resource/dams/&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). Amadamu la, ngesakhiwo nobungako kanye nomsebenzi angahluka ngokuya kweendawo neminqopho yawo.
[[Isimumathi:Idamu leKosini emThambithini.jpg|left|thumb|220x220px|Idamu leKosini, emThambithini]]
Kukhona [https://education.nationalgeographic.org/resource/dams/ amadamu] lawo amakhulu ngobujamo begodu umsebenzi wawo kukubulunga amanzi kanye nokuwasabalalise eendaweni nanyana kumadamu amancani lawo aphakela abantu nemiphakathi ngamanzi (The British Dam Society 2024a&lt;ref name=&quot;:2&quot;&gt;The British Dam Society. 2024. What is dam?. Itholakala ku-: &lt;nowiki&gt;https://britishdams.org/about-dams/dam-information/&lt;/nowiki&gt;. Ifunywane ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). [https://britishdams.org/about-dams/dam-information/ Amadamu] la, afuna itlhogonyelo tle begodu nalo itlhogonyelo lawo liyahluka. Idamu elikhulu lifuna itlhogonyelo elikhulu begodu lifuna nesikhathi esinengi lokha nalimadaniswa nedamu elincani. Amadamu kanengi afunyana nanyana amukela amanzi ukusuka emlanjeni ngesikhathi lapho kunezulu elinengi (Wikipedia 2024a&lt;ref name=&quot;:0&quot; /&gt;; National Geographic 2024a&lt;ref name=&quot;:1&quot; /&gt;; ne-The British Dam Society 2024a&lt;ref name=&quot;:2&quot; /&gt;).

Ukuyisonga, idamu liyakhiwa begodu liyahluka ngomnqopho. Kodwana, limthombo oqakathekileko mayelana nokuqinisekiswa bonyana imiphakathi ifunyana amanzi. 

==== '''Kuyini [[:en:River|umlambo]]?''' ====
[[Isimumathi:Umlambo iMoutse emThambothini.jpg|thumb|Umlambo iMoutse, eKosini]]
[https://www.britannica.com/science/river Umlambo] singatjho bonyana kulidamu lemvelo lelo elingakakhiwa kodwana eliziveleleko (Wikipedia 2024b;&lt;ref&gt;Wikipedia. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://en.wikipedia.org/wiki/River&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt; ne-Britannica 2024&lt;ref&gt;Britannica. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://www.britannica.com/science/river&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Ngamanye amagama, [https://smartwatermagazine.com/q-a/what-a-river umlambo] uyazivelela begodu nobujamo bawo buyazenzakalela. [https://education.nationalgeographic.org/resource/river/ Imilambo] nayo iyahluka ngobujamo begodu imithombo yeempilo yeenlwani ezinengi nabantu (National Geographic 2024b&lt;ref name=&quot;:3&quot;&gt;National Geographic. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://education.nationalgeographic.org/resource/river/&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Iinlwani ezitholakala emilanjeni ziyahluka ngokuya kweendawo kanye nobujamo bezulu.

Imilambo ikhongozela amanzi wezulu bese iphakele amadamu amanzi lawo ukuze abulungwe amanzi begodu kwenziwe isiqiniseko sokuthi abantu neenlwana bafunyana amanzi (National Geographic 2024b&lt;ref name=&quot;:3&quot; /&gt;; ne-Smart Water Magazine 2024&lt;ref&gt;Smart Water Magazine. 2024. What is a river?. Itholakala ku-:&lt;nowiki&gt;https://smartwatermagazine.com/q-a/what-a-river&lt;/nowiki&gt;. Ifunyenwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Nanyana kunjalo-ke, kukhona imiphakathi ekha nanyana esebenzisa amanzi bunqopha kusuka emlanjeni ngebanga lokungabi nayo imithangalasisekelo yamanzi. Lokhu kusitjengisa ukuqakatheka kwemilambo begodu nesidingo sokunakekela imilambo esinayo. 

=== '''Isiphetho''' ===
Idamu singatjho bona mlambo owakhiweko bese kuthi umlambo wona kube lidami lemvelo nanyana lendabuko lelo elizenzakalelako. Idamu esikhathini esinengi lithembele emlanjeni bona lifunyane amanzi, kanti umlambo wona ukhongozela amanzi wezulu. 

=== '''Isilululwazi/umthombolwazi''' ===
&lt;references /&gt;</text>
      <sha1>g6fsqm36pywhucbnow70kd2s2p59dtp</sha1>
    </revision>
    <revision>
      <id>1443</id>
      <parentid>1442</parentid>
      <timestamp>2024-09-16T11:55:23Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1443</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4639" sha1="fihif9su0efhse13gjg8651z9igljos" xml:space="preserve">Emphakathini esiphila kiyo kuneendlela ezinengi zokubulunga amanzi nalezo ezisetjenziswa njengemithombo yamanzi. Iindlela lezi ziqakatheke kwamamba ekwenzeni isiqiniseko sokuthi abantu baba nepilo begodu bafunyana amanzi. Nanyana kunjalo-ke, ngaphasi kwesihloko sethu lesi sizokudzimelela khulu edamini nemlanjeni. Sizokuthoma ngesihloko esithi, Kuyini idamu? bese kulandele esithi, Kuyini umlambo?.

==== '''Kuyini i[[:en:Dam|damu]]?''' ====
[[Isimumathi:Idamu lokubulunga amanzi Kosini.jpg|thumb|Idamu lokubulunga amanzi, langeKosini]]
Kwesinye isikhathi kuyaye kutlhogeke bonyana kukhongezelwe amanzi begodu abulungwe ukuze abantu bawafunyane (Wikipedia 2024a&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. Dam. Itholakala ku-: &lt;nowiki&gt;https://en.wikipedia.org/wiki/Dam&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). Isesetjenziswa sokukhongenzela amanzi begodu siwabulunge sibizwa bonyana lidamu (Wikipedia 2024a&lt;ref name=&quot;:0&quot; /&gt;). Idamu liyakhiwa ngomnqopho wokubamba amanzi begodu liwabulunge (National Geographic 2024a&lt;ref name=&quot;:1&quot;&gt;National Geographic. 2024. Dams. Itholakala ku-: &lt;nowiki&gt;https://education.nationalgeographic.org/resource/dams/&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). Amadamu la, ngesakhiwo nobungako kanye nomsebenzi angahluka ngokuya kweendawo neminqopho yawo.
[[Isimumathi:Idamu leKosini emThambithini.jpg|left|thumb|220x220px|Idamu leKosini, emThambithini]]
Kukhona [https://education.nationalgeographic.org/resource/dams/ amadamu] lawo amakhulu ngobujamo begodu umsebenzi wawo kukubulunga amanzi kanye nokuwasabalalise eendaweni nanyana kumadamu amancani lawo aphakela abantu nemiphakathi ngamanzi (The British Dam Society 2024a&lt;ref name=&quot;:2&quot;&gt;The British Dam Society. 2024. What is dam?. Itholakala ku-: &lt;nowiki&gt;https://britishdams.org/about-dams/dam-information/&lt;/nowiki&gt;. Ifunywane ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). [https://britishdams.org/about-dams/dam-information/ Amadamu] la, afuna itlhogonyelo tle begodu nalo itlhogonyelo lawo liyahluka. Idamu elikhulu lifuna itlhogonyelo elikhulu begodu lifuna nesikhathi esinengi lokha nalimadaniswa nedamu elincani. Amadamu kanengi afunyana nanyana amukela amanzi ukusuka emlanjeni ngesikhathi lapho kunezulu elinengi (Wikipedia 2024a&lt;ref name=&quot;:0&quot; /&gt;; National Geographic 2024a&lt;ref name=&quot;:1&quot; /&gt;; ne-The British Dam Society 2024a&lt;ref name=&quot;:2&quot; /&gt;).

Ukuyisonga, idamu liyakhiwa begodu liyahluka ngomnqopho. Kodwana, limthombo oqakathekileko mayelana nokuqinisekiswa bonyana imiphakathi ifunyana amanzi. 

==== '''Kuyini [[:en:River|umlambo]]?''' ====
[[Isimumathi:Umlambo iMoutse emThambothini.jpg|thumb|Umlambo iMoutse, eKosini]]
[https://www.britannica.com/science/river Umlambo] singatjho bonyana kulidamu lemvelo lelo elingakakhiwa kodwana eliziveleleko (Wikipedia 2024b;&lt;ref&gt;Wikipedia. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://en.wikipedia.org/wiki/River&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt; ne-Britannica 2024&lt;ref&gt;Britannica. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://www.britannica.com/science/river&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Ngamanye amagama, [https://smartwatermagazine.com/q-a/what-a-river umlambo] uyazivelela begodu nobujamo bawo buyazenzakalela. [https://education.nationalgeographic.org/resource/river/ Imilambo] nayo iyahluka ngobujamo begodu imithombo yeempilo yeenlwani ezinengi nabantu (National Geographic 2024b&lt;ref name=&quot;:3&quot;&gt;National Geographic. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://education.nationalgeographic.org/resource/river/&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Iinlwani ezitholakala emilanjeni ziyahluka ngokuya kweendawo kanye nobujamo bezulu.

Imilambo ikhongozela amanzi wezulu bese iphakele amadamu amanzi lawo ukuze abulungwe amanzi begodu kwenziwe isiqiniseko sokuthi abantu neenlwana bafunyana amanzi (National Geographic 2024b&lt;ref name=&quot;:3&quot; /&gt;; ne-Smart Water Magazine 2024&lt;ref&gt;Smart Water Magazine. 2024. What is a river?. Itholakala ku-:&lt;nowiki&gt;https://smartwatermagazine.com/q-a/what-a-river&lt;/nowiki&gt;. Ifunyenwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Nanyana kunjalo-ke, kukhona imiphakathi ekha nanyana esebenzisa amanzi bunqopha kusuka emlanjeni ngebanga lokungabi nayo imithangalasisekelo yamanzi. Lokhu kusitjengisa ukuqakatheka kwemilambo begodu nesidingo sokunakekela imilambo esinayo. 

=== '''Isiphetho''' ===
Idamu singatjho bona mlambo owakhiweko bese kuthi umlambo wona kube lidami lemvelo nanyana lendabuko lelo elizenzakalelako. Idamu esikhathini esinengi lithembele emlanjeni bona lifunyane amanzi, kanti umlambo wona ukhongozela amanzi wezulu. 

=== '''Isilululwazi/umthombolwazi''' ===
&lt;references /&gt;</text>
      <sha1>fihif9su0efhse13gjg8651z9igljos</sha1>
    </revision>
    <revision>
      <id>1444</id>
      <parentid>1443</parentid>
      <timestamp>2024-09-16T11:55:37Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Bobbyshabangu moved page [[Umehluko hlangan kwedamu nomlambo]] to [[Umehluko hlangana kwedamu nomlambo]]</comment>
      <origin>1443</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4639" sha1="fihif9su0efhse13gjg8651z9igljos" xml:space="preserve">Emphakathini esiphila kiyo kuneendlela ezinengi zokubulunga amanzi nalezo ezisetjenziswa njengemithombo yamanzi. Iindlela lezi ziqakatheke kwamamba ekwenzeni isiqiniseko sokuthi abantu baba nepilo begodu bafunyana amanzi. Nanyana kunjalo-ke, ngaphasi kwesihloko sethu lesi sizokudzimelela khulu edamini nemlanjeni. Sizokuthoma ngesihloko esithi, Kuyini idamu? bese kulandele esithi, Kuyini umlambo?.

==== '''Kuyini i[[:en:Dam|damu]]?''' ====
[[Isimumathi:Idamu lokubulunga amanzi Kosini.jpg|thumb|Idamu lokubulunga amanzi, langeKosini]]
Kwesinye isikhathi kuyaye kutlhogeke bonyana kukhongezelwe amanzi begodu abulungwe ukuze abantu bawafunyane (Wikipedia 2024a&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. Dam. Itholakala ku-: &lt;nowiki&gt;https://en.wikipedia.org/wiki/Dam&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). Isesetjenziswa sokukhongenzela amanzi begodu siwabulunge sibizwa bonyana lidamu (Wikipedia 2024a&lt;ref name=&quot;:0&quot; /&gt;). Idamu liyakhiwa ngomnqopho wokubamba amanzi begodu liwabulunge (National Geographic 2024a&lt;ref name=&quot;:1&quot;&gt;National Geographic. 2024. Dams. Itholakala ku-: &lt;nowiki&gt;https://education.nationalgeographic.org/resource/dams/&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). Amadamu la, ngesakhiwo nobungako kanye nomsebenzi angahluka ngokuya kweendawo neminqopho yawo.
[[Isimumathi:Idamu leKosini emThambithini.jpg|left|thumb|220x220px|Idamu leKosini, emThambithini]]
Kukhona [https://education.nationalgeographic.org/resource/dams/ amadamu] lawo amakhulu ngobujamo begodu umsebenzi wawo kukubulunga amanzi kanye nokuwasabalalise eendaweni nanyana kumadamu amancani lawo aphakela abantu nemiphakathi ngamanzi (The British Dam Society 2024a&lt;ref name=&quot;:2&quot;&gt;The British Dam Society. 2024. What is dam?. Itholakala ku-: &lt;nowiki&gt;https://britishdams.org/about-dams/dam-information/&lt;/nowiki&gt;. Ifunywane ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). [https://britishdams.org/about-dams/dam-information/ Amadamu] la, afuna itlhogonyelo tle begodu nalo itlhogonyelo lawo liyahluka. Idamu elikhulu lifuna itlhogonyelo elikhulu begodu lifuna nesikhathi esinengi lokha nalimadaniswa nedamu elincani. Amadamu kanengi afunyana nanyana amukela amanzi ukusuka emlanjeni ngesikhathi lapho kunezulu elinengi (Wikipedia 2024a&lt;ref name=&quot;:0&quot; /&gt;; National Geographic 2024a&lt;ref name=&quot;:1&quot; /&gt;; ne-The British Dam Society 2024a&lt;ref name=&quot;:2&quot; /&gt;).

Ukuyisonga, idamu liyakhiwa begodu liyahluka ngomnqopho. Kodwana, limthombo oqakathekileko mayelana nokuqinisekiswa bonyana imiphakathi ifunyana amanzi. 

==== '''Kuyini [[:en:River|umlambo]]?''' ====
[[Isimumathi:Umlambo iMoutse emThambothini.jpg|thumb|Umlambo iMoutse, eKosini]]
[https://www.britannica.com/science/river Umlambo] singatjho bonyana kulidamu lemvelo lelo elingakakhiwa kodwana eliziveleleko (Wikipedia 2024b;&lt;ref&gt;Wikipedia. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://en.wikipedia.org/wiki/River&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt; ne-Britannica 2024&lt;ref&gt;Britannica. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://www.britannica.com/science/river&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Ngamanye amagama, [https://smartwatermagazine.com/q-a/what-a-river umlambo] uyazivelela begodu nobujamo bawo buyazenzakalela. [https://education.nationalgeographic.org/resource/river/ Imilambo] nayo iyahluka ngobujamo begodu imithombo yeempilo yeenlwani ezinengi nabantu (National Geographic 2024b&lt;ref name=&quot;:3&quot;&gt;National Geographic. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://education.nationalgeographic.org/resource/river/&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Iinlwani ezitholakala emilanjeni ziyahluka ngokuya kweendawo kanye nobujamo bezulu.

Imilambo ikhongozela amanzi wezulu bese iphakele amadamu amanzi lawo ukuze abulungwe amanzi begodu kwenziwe isiqiniseko sokuthi abantu neenlwana bafunyana amanzi (National Geographic 2024b&lt;ref name=&quot;:3&quot; /&gt;; ne-Smart Water Magazine 2024&lt;ref&gt;Smart Water Magazine. 2024. What is a river?. Itholakala ku-:&lt;nowiki&gt;https://smartwatermagazine.com/q-a/what-a-river&lt;/nowiki&gt;. Ifunyenwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Nanyana kunjalo-ke, kukhona imiphakathi ekha nanyana esebenzisa amanzi bunqopha kusuka emlanjeni ngebanga lokungabi nayo imithangalasisekelo yamanzi. Lokhu kusitjengisa ukuqakatheka kwemilambo begodu nesidingo sokunakekela imilambo esinayo. 

=== '''Isiphetho''' ===
Idamu singatjho bona mlambo owakhiweko bese kuthi umlambo wona kube lidami lemvelo nanyana lendabuko lelo elizenzakalelako. Idamu esikhathini esinengi lithembele emlanjeni bona lifunyane amanzi, kanti umlambo wona ukhongozela amanzi wezulu. 

=== '''Isilululwazi/umthombolwazi''' ===
&lt;references /&gt;</text>
      <sha1>fihif9su0efhse13gjg8651z9igljos</sha1>
    </revision>
    <revision>
      <id>1445</id>
      <parentid>1444</parentid>
      <timestamp>2024-09-16T11:56:45Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1445</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4681" sha1="t0imlkhr24pfoamcxf8fqqwqeta4ysw" xml:space="preserve">Emphakathini esiphila kiyo kuneendlela ezinengi zokubulunga amanzi nalezo ezisetjenziswa njengemithombo yamanzi. Iindlela lezi ziqakatheke kwamamba ekwenzeni isiqiniseko sokuthi abantu baba nepilo begodu bafunyana amanzi. Nanyana kunjalo-ke, ngaphasi kwesihloko sethu lesi sizokudzimelela khulu edamini nemlanjeni. Sizokuthoma ngesihloko esithi, Kuyini idamu? bese kulandele esithi, Kuyini umlambo?.

==== '''Kuyini i[[:en:Dam|damu]]?''' ====
[[Isimumathi:Idamu lokubulunga amanzi Kosini.jpg|thumb|Idamu lokubulunga amanzi, langeKosini]]
Kwesinye isikhathi kuyaye kutlhogeke bonyana kukhongezelwe amanzi begodu abulungwe ukuze abantu bawafunyane (Wikipedia 2024a&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. Dam. Itholakala ku-: &lt;nowiki&gt;https://en.wikipedia.org/wiki/Dam&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). Isesetjenziswa sokukhongenzela amanzi begodu siwabulunge sibizwa bonyana lidamu (Wikipedia 2024a&lt;ref name=&quot;:0&quot; /&gt;). Idamu liyakhiwa ngomnqopho wokubamba amanzi begodu liwabulunge (National Geographic 2024a&lt;ref name=&quot;:1&quot;&gt;National Geographic. 2024. Dams. Itholakala ku-: &lt;nowiki&gt;https://education.nationalgeographic.org/resource/dams/&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). Amadamu la, ngesakhiwo nobungako kanye nomsebenzi angahluka ngokuya kweendawo neminqopho yawo.
[[Isimumathi:Idamu leKosini emThambithini.jpg|left|thumb|220x220px|Idamu leKosini, emThambithini]]
Kukhona [https://education.nationalgeographic.org/resource/dams/ amadamu] lawo amakhulu ngobujamo begodu umsebenzi wawo kukubulunga amanzi kanye nokuwasabalalise eendaweni nanyana kumadamu amancani lawo aphakela abantu nemiphakathi ngamanzi (The British Dam Society 2024a&lt;ref name=&quot;:2&quot;&gt;The British Dam Society. 2024. What is dam?. Itholakala ku-: &lt;nowiki&gt;https://britishdams.org/about-dams/dam-information/&lt;/nowiki&gt;. Ifunywane ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). [https://britishdams.org/about-dams/dam-information/ Amadamu] la, afuna itlhogonyelo tle begodu nalo itlhogonyelo lawo liyahluka. Idamu elikhulu lifuna itlhogonyelo elikhulu begodu lifuna nesikhathi esinengi lokha nalimadaniswa nedamu elincani. Amadamu kanengi afunyana nanyana amukela amanzi ukusuka emlanjeni ngesikhathi lapho kunezulu elinengi (Wikipedia 2024a&lt;ref name=&quot;:0&quot; /&gt;; National Geographic 2024a&lt;ref name=&quot;:1&quot; /&gt;; ne-The British Dam Society 2024a&lt;ref name=&quot;:2&quot; /&gt;).

Ukuyisonga, idamu liyakhiwa begodu liyahluka ngomnqopho. Kodwana, limthombo oqakathekileko mayelana nokuqinisekiswa bonyana imiphakathi ifunyana amanzi. 

==== '''Kuyini [[:en:River|umlambo]]?''' ====
[[Isimumathi:Umlambo iMoutse emThambothini.jpg|thumb|Umlambo iMoutse, eKosini]]
[https://www.britannica.com/science/river Umlambo] singatjho bonyana kulidamu lemvelo lelo elingakakhiwa kodwana eliziveleleko (Wikipedia 2024b;&lt;ref&gt;Wikipedia. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://en.wikipedia.org/wiki/River&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt; ne-Britannica 2024&lt;ref&gt;Britannica. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://www.britannica.com/science/river&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Ngamanye amagama, [https://smartwatermagazine.com/q-a/what-a-river umlambo] uyazivelela begodu nobujamo bawo buyazenzakalela. [https://education.nationalgeographic.org/resource/river/ Imilambo] nayo iyahluka ngobujamo begodu imithombo yeempilo yeenlwani ezinengi nabantu (National Geographic 2024b&lt;ref name=&quot;:3&quot;&gt;National Geographic. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://education.nationalgeographic.org/resource/river/&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Iinlwani ezitholakala emilanjeni ziyahluka ngokuya kweendawo kanye nobujamo bezulu.

Imilambo ikhongozela amanzi wezulu bese iphakele amadamu amanzi lawo ukuze abulungwe amanzi begodu kwenziwe isiqiniseko sokuthi abantu neenlwana bafunyana amanzi (National Geographic 2024b&lt;ref name=&quot;:3&quot; /&gt;; ne-Smart Water Magazine 2024&lt;ref&gt;Smart Water Magazine. 2024. What is a river?. Itholakala ku-:&lt;nowiki&gt;https://smartwatermagazine.com/q-a/what-a-river&lt;/nowiki&gt;. Ifunyenwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Nanyana kunjalo-ke, kukhona imiphakathi ekha nanyana esebenzisa amanzi bunqopha kusuka emlanjeni ngebanga lokungabi nayo imithangalasisekelo yamanzi. Lokhu kusitjengisa ukuqakatheka kwemilambo begodu nesidingo sokunakekela imilambo esinayo. 

=== '''Isiphetho''' ===
Idamu singatjho bona mlambo owakhiweko bese kuthi umlambo wona kube lidami lemvelo nanyana lendabuko lelo elizenzakalelako. Idamu esikhathini esinengi lithembele emlanjeni bona lifunyane amanzi, kanti umlambo wona ukhongozela amanzi wezulu. 

=== '''Isilululwazi/umthombolwazi''' ===
&lt;references /&gt;
[[Mkhakha:Ezolwazi]]
[[Mkhakha:Ezemvelo]]</text>
      <sha1>t0imlkhr24pfoamcxf8fqqwqeta4ysw</sha1>
    </revision>
    <revision>
      <id>1446</id>
      <parentid>1445</parentid>
      <timestamp>2024-09-16T11:57:30Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1446</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4669" sha1="b655c9htcgcort3keg6v36hr7mx687e" xml:space="preserve">Emphakathini esiphila kiyo kuneendlela ezinengi zokubulunga amanzi nalezo ezisetjenziswa njengemithombo yamanzi. Iindlela lezi ziqakatheke kwamamba ekwenzeni isiqiniseko sokuthi abantu baba nepilo begodu bafunyana amanzi. Nanyana kunjalo-ke, ngaphasi kwesihloko sethu lesi sizokudzimelela khulu edamini nemlanjeni. Sizokuthoma ngesihloko esithi, Kuyini idamu? bese kulandele esithi, Kuyini umlambo?.

==== '''Kuyini idamu?''' ====
[[Isimumathi:Idamu lokubulunga amanzi Kosini.jpg|thumb|Idamu lokubulunga amanzi, langeKosini]]
Kwesinye isikhathi kuyaye kutlhogeke bonyana kukhongezelwe amanzi begodu abulungwe ukuze abantu bawafunyane (Wikipedia 2024a&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. Dam. Itholakala ku-: &lt;nowiki&gt;https://en.wikipedia.org/wiki/Dam&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). Isesetjenziswa sokukhongenzela amanzi begodu siwabulunge sibizwa bonyana lidamu (Wikipedia 2024a&lt;ref name=&quot;:0&quot; /&gt;). Idamu liyakhiwa ngomnqopho wokubamba amanzi begodu liwabulunge (National Geographic 2024a&lt;ref name=&quot;:1&quot;&gt;National Geographic. 2024. Dams. Itholakala ku-: &lt;nowiki&gt;https://education.nationalgeographic.org/resource/dams/&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). Amadamu la, ngesakhiwo nobungako kanye nomsebenzi angahluka ngokuya kweendawo neminqopho yawo.
[[Isimumathi:Idamu leKosini emThambithini.jpg|left|thumb|220x220px|Idamu leKosini, emThambithini]]
Kukhona [https://education.nationalgeographic.org/resource/dams/ amadamu] lawo amakhulu ngobujamo begodu umsebenzi wawo kukubulunga amanzi kanye nokuwasabalalise eendaweni nanyana kumadamu amancani lawo aphakela abantu nemiphakathi ngamanzi (The British Dam Society 2024a&lt;ref name=&quot;:2&quot;&gt;The British Dam Society. 2024. What is dam?. Itholakala ku-: &lt;nowiki&gt;https://britishdams.org/about-dams/dam-information/&lt;/nowiki&gt;. Ifunywane ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). [https://britishdams.org/about-dams/dam-information/ Amadamu] la, afuna itlhogonyelo tle begodu nalo itlhogonyelo lawo liyahluka. Idamu elikhulu lifuna itlhogonyelo elikhulu begodu lifuna nesikhathi esinengi lokha nalimadaniswa nedamu elincani. Amadamu kanengi afunyana nanyana amukela amanzi ukusuka emlanjeni ngesikhathi lapho kunezulu elinengi (Wikipedia 2024a&lt;ref name=&quot;:0&quot; /&gt;; National Geographic 2024a&lt;ref name=&quot;:1&quot; /&gt;; ne-The British Dam Society 2024a&lt;ref name=&quot;:2&quot; /&gt;).

Ukuyisonga, idamu liyakhiwa begodu liyahluka ngomnqopho. Kodwana, limthombo oqakathekileko mayelana nokuqinisekiswa bonyana imiphakathi ifunyana amanzi. 

==== '''Kuyini [[:en:River|umlambo]]?''' ====
[[Isimumathi:Umlambo iMoutse emThambothini.jpg|thumb|Umlambo iMoutse, eKosini]]
[https://www.britannica.com/science/river Umlambo] singatjho bonyana kulidamu lemvelo lelo elingakakhiwa kodwana eliziveleleko (Wikipedia 2024b;&lt;ref&gt;Wikipedia. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://en.wikipedia.org/wiki/River&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt; ne-Britannica 2024&lt;ref&gt;Britannica. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://www.britannica.com/science/river&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Ngamanye amagama, [https://smartwatermagazine.com/q-a/what-a-river umlambo] uyazivelela begodu nobujamo bawo buyazenzakalela. [https://education.nationalgeographic.org/resource/river/ Imilambo] nayo iyahluka ngobujamo begodu imithombo yeempilo yeenlwani ezinengi nabantu (National Geographic 2024b&lt;ref name=&quot;:3&quot;&gt;National Geographic. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://education.nationalgeographic.org/resource/river/&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Iinlwani ezitholakala emilanjeni ziyahluka ngokuya kweendawo kanye nobujamo bezulu.

Imilambo ikhongozela amanzi wezulu bese iphakele amadamu amanzi lawo ukuze abulungwe amanzi begodu kwenziwe isiqiniseko sokuthi abantu neenlwana bafunyana amanzi (National Geographic 2024b&lt;ref name=&quot;:3&quot; /&gt;; ne-Smart Water Magazine 2024&lt;ref&gt;Smart Water Magazine. 2024. What is a river?. Itholakala ku-:&lt;nowiki&gt;https://smartwatermagazine.com/q-a/what-a-river&lt;/nowiki&gt;. Ifunyenwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Nanyana kunjalo-ke, kukhona imiphakathi ekha nanyana esebenzisa amanzi bunqopha kusuka emlanjeni ngebanga lokungabi nayo imithangalasisekelo yamanzi. Lokhu kusitjengisa ukuqakatheka kwemilambo begodu nesidingo sokunakekela imilambo esinayo. 

=== '''Isiphetho''' ===
Idamu singatjho bona mlambo owakhiweko bese kuthi umlambo wona kube lidami lemvelo nanyana lendabuko lelo elizenzakalelako. Idamu esikhathini esinengi lithembele emlanjeni bona lifunyane amanzi, kanti umlambo wona ukhongozela amanzi wezulu. 

=== '''Isilululwazi/umthombolwazi''' ===
&lt;references /&gt;
[[Mkhakha:Ezolwazi]]
[[Mkhakha:Ezemvelo]]</text>
      <sha1>b655c9htcgcort3keg6v36hr7mx687e</sha1>
    </revision>
    <revision>
      <id>1447</id>
      <parentid>1446</parentid>
      <timestamp>2024-09-23T17:27:45Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <origin>1447</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4730" sha1="9qoq5st18d7bqhrwwsx14aughk7wv1r" xml:space="preserve">== Umehluko hlangana kwedamu nomlambo ==

=== Isingeniso ===
Emphakathini esiphila kiyo kuneendlela ezinengi zokubulunga amanzi nalezo ezisetjenziswa njengemithombo yamanzi. Iindlela lezi ziqakatheke kwamamba ekwenzeni isiqiniseko sokuthi abantu baba nepilo begodu bafunyana amanzi. Nanyana kunjalo-ke, ngaphasi kwesihloko sethu lesi sizokudzimelela khulu edamini nemlanjeni. Sizokuthoma ngesihloko esithi, Kuyini idamu? bese kulandele esithi, Kuyini umlambo?.

==== '''Kuyini idamu?''' ====
[[Isimumathi:Idamu lokubulunga amanzi Kosini.jpg|thumb|Idamu lokubulunga amanzi, langeKosini]]
Kwesinye isikhathi kuyaye kutlhogeke bonyana kukhongezelwe amanzi begodu abulungwe ukuze abantu bawafunyane (Wikipedia 2024a&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. Dam. Itholakala ku-: &lt;nowiki&gt;https://en.wikipedia.org/wiki/Dam&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). Isesetjenziswa sokukhongenzela amanzi begodu siwabulunge sibizwa bonyana lidamu (Wikipedia 2024a&lt;ref name=&quot;:0&quot; /&gt;). Idamu liyakhiwa ngomnqopho wokubamba amanzi begodu liwabulunge (National Geographic 2024a&lt;ref name=&quot;:1&quot;&gt;National Geographic. 2024. Dams. Itholakala ku-: &lt;nowiki&gt;https://education.nationalgeographic.org/resource/dams/&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). Amadamu la, ngesakhiwo nobungako kanye nomsebenzi angahluka ngokuya kweendawo neminqopho yawo.
[[Isimumathi:Idamu leKosini emThambithini.jpg|left|thumb|220x220px|Idamu leKosini, emThambithini]]
Kukhona [https://education.nationalgeographic.org/resource/dams/ amadamu] lawo amakhulu ngobujamo begodu umsebenzi wawo kukubulunga amanzi kanye nokuwasabalalise eendaweni nanyana kumadamu amancani lawo aphakela abantu nemiphakathi ngamanzi (The British Dam Society 2024a&lt;ref name=&quot;:2&quot;&gt;The British Dam Society. 2024. What is dam?. Itholakala ku-: &lt;nowiki&gt;https://britishdams.org/about-dams/dam-information/&lt;/nowiki&gt;. Ifunywane ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). [https://britishdams.org/about-dams/dam-information/ Amadamu] la, afuna itlhogonyelo tle begodu nalo itlhogonyelo lawo liyahluka. Idamu elikhulu lifuna itlhogonyelo elikhulu begodu lifuna nesikhathi esinengi lokha nalimadaniswa nedamu elincani. Amadamu kanengi afunyana nanyana amukela amanzi ukusuka emlanjeni ngesikhathi lapho kunezulu elinengi (Wikipedia 2024a&lt;ref name=&quot;:0&quot; /&gt;; National Geographic 2024a&lt;ref name=&quot;:1&quot; /&gt;; ne-The British Dam Society 2024a&lt;ref name=&quot;:2&quot; /&gt;).

Ukuyisonga, idamu liyakhiwa begodu liyahluka ngomnqopho. Kodwana, limthombo oqakathekileko mayelana nokuqinisekiswa bonyana imiphakathi ifunyana amanzi. 

==== '''Kuyini [[:en:River|umlambo]]?''' ====
[[Isimumathi:Umlambo iMoutse emThambothini.jpg|thumb|Umlambo iMoutse, eKosini]]
[https://www.britannica.com/science/river Umlambo] singatjho bonyana kulidamu lemvelo lelo elingakakhiwa kodwana eliziveleleko (Wikipedia 2024b;&lt;ref&gt;Wikipedia. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://en.wikipedia.org/wiki/River&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt; ne-Britannica 2024&lt;ref&gt;Britannica. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://www.britannica.com/science/river&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Ngamanye amagama, [https://smartwatermagazine.com/q-a/what-a-river umlambo] uyazivelela begodu nobujamo bawo buyazenzakalela. [https://education.nationalgeographic.org/resource/river/ Imilambo] nayo iyahluka ngobujamo begodu imithombo yeempilo yeenlwani ezinengi nabantu (National Geographic 2024b&lt;ref name=&quot;:3&quot;&gt;National Geographic. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://education.nationalgeographic.org/resource/river/&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Iinlwani ezitholakala emilanjeni ziyahluka ngokuya kweendawo kanye nobujamo bezulu.

Imilambo ikhongozela amanzi wezulu bese iphakele amadamu amanzi lawo ukuze abulungwe amanzi begodu kwenziwe isiqiniseko sokuthi abantu neenlwana bafunyana amanzi (National Geographic 2024b&lt;ref name=&quot;:3&quot; /&gt;; ne-Smart Water Magazine 2024&lt;ref&gt;Smart Water Magazine. 2024. What is a river?. Itholakala ku-:&lt;nowiki&gt;https://smartwatermagazine.com/q-a/what-a-river&lt;/nowiki&gt;. Ifunyenwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Nanyana kunjalo-ke, kukhona imiphakathi ekha nanyana esebenzisa amanzi bunqopha kusuka emlanjeni ngebanga lokungabi nayo imithangalasisekelo yamanzi. Lokhu kusitjengisa ukuqakatheka kwemilambo begodu nesidingo sokunakekela imilambo esinayo. 

=== '''Isiphetho''' ===
Idamu singatjho bona mlambo owakhiweko bese kuthi umlambo wona kube lidami lemvelo nanyana lendabuko lelo elizenzakalelako. Idamu esikhathini esinengi lithembele emlanjeni bona lifunyane amanzi, kanti umlambo wona ukhongozela amanzi wezulu. 

=== '''Isilululwazi/umthombolwazi''' ===
&lt;references /&gt;
[[Mkhakha:Ezolwazi]]
[[Mkhakha:Ezemvelo]]</text>
      <sha1>9qoq5st18d7bqhrwwsx14aughk7wv1r</sha1>
    </revision>
    <revision>
      <id>1448</id>
      <parentid>1447</parentid>
      <timestamp>2024-09-23T17:28:09Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1448</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4731" sha1="kpa9hoatw5fo1kyr3b7n22uarvacabk" xml:space="preserve">== Umehluko hlangana kwedamu nomlambo. ==

=== Isingeniso ===
Emphakathini esiphila kiyo kuneendlela ezinengi zokubulunga amanzi nalezo ezisetjenziswa njengemithombo yamanzi. Iindlela lezi ziqakatheke kwamamba ekwenzeni isiqiniseko sokuthi abantu baba nepilo begodu bafunyana amanzi. Nanyana kunjalo-ke, ngaphasi kwesihloko sethu lesi sizokudzimelela khulu edamini nemlanjeni. Sizokuthoma ngesihloko esithi, Kuyini idamu? bese kulandele esithi, Kuyini umlambo?.

==== '''Kuyini idamu?''' ====
[[Isimumathi:Idamu lokubulunga amanzi Kosini.jpg|thumb|Idamu lokubulunga amanzi, langeKosini]]
Kwesinye isikhathi kuyaye kutlhogeke bonyana kukhongezelwe amanzi begodu abulungwe ukuze abantu bawafunyane (Wikipedia 2024a&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. Dam. Itholakala ku-: &lt;nowiki&gt;https://en.wikipedia.org/wiki/Dam&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). Isesetjenziswa sokukhongenzela amanzi begodu siwabulunge sibizwa bonyana lidamu (Wikipedia 2024a&lt;ref name=&quot;:0&quot; /&gt;). Idamu liyakhiwa ngomnqopho wokubamba amanzi begodu liwabulunge (National Geographic 2024a&lt;ref name=&quot;:1&quot;&gt;National Geographic. 2024. Dams. Itholakala ku-: &lt;nowiki&gt;https://education.nationalgeographic.org/resource/dams/&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). Amadamu la, ngesakhiwo nobungako kanye nomsebenzi angahluka ngokuya kweendawo neminqopho yawo.
[[Isimumathi:Idamu leKosini emThambithini.jpg|left|thumb|220x220px|Idamu leKosini, emThambithini]]
Kukhona [https://education.nationalgeographic.org/resource/dams/ amadamu] lawo amakhulu ngobujamo begodu umsebenzi wawo kukubulunga amanzi kanye nokuwasabalalise eendaweni nanyana kumadamu amancani lawo aphakela abantu nemiphakathi ngamanzi (The British Dam Society 2024a&lt;ref name=&quot;:2&quot;&gt;The British Dam Society. 2024. What is dam?. Itholakala ku-: &lt;nowiki&gt;https://britishdams.org/about-dams/dam-information/&lt;/nowiki&gt;. Ifunywane ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). [https://britishdams.org/about-dams/dam-information/ Amadamu] la, afuna itlhogonyelo tle begodu nalo itlhogonyelo lawo liyahluka. Idamu elikhulu lifuna itlhogonyelo elikhulu begodu lifuna nesikhathi esinengi lokha nalimadaniswa nedamu elincani. Amadamu kanengi afunyana nanyana amukela amanzi ukusuka emlanjeni ngesikhathi lapho kunezulu elinengi (Wikipedia 2024a&lt;ref name=&quot;:0&quot; /&gt;; National Geographic 2024a&lt;ref name=&quot;:1&quot; /&gt;; ne-The British Dam Society 2024a&lt;ref name=&quot;:2&quot; /&gt;).

Ukuyisonga, idamu liyakhiwa begodu liyahluka ngomnqopho. Kodwana, limthombo oqakathekileko mayelana nokuqinisekiswa bonyana imiphakathi ifunyana amanzi. 

==== '''Kuyini [[:en:River|umlambo]]?''' ====
[[Isimumathi:Umlambo iMoutse emThambothini.jpg|thumb|Umlambo iMoutse, eKosini]]
[https://www.britannica.com/science/river Umlambo] singatjho bonyana kulidamu lemvelo lelo elingakakhiwa kodwana eliziveleleko (Wikipedia 2024b;&lt;ref&gt;Wikipedia. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://en.wikipedia.org/wiki/River&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt; ne-Britannica 2024&lt;ref&gt;Britannica. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://www.britannica.com/science/river&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Ngamanye amagama, [https://smartwatermagazine.com/q-a/what-a-river umlambo] uyazivelela begodu nobujamo bawo buyazenzakalela. [https://education.nationalgeographic.org/resource/river/ Imilambo] nayo iyahluka ngobujamo begodu imithombo yeempilo yeenlwani ezinengi nabantu (National Geographic 2024b&lt;ref name=&quot;:3&quot;&gt;National Geographic. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://education.nationalgeographic.org/resource/river/&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Iinlwani ezitholakala emilanjeni ziyahluka ngokuya kweendawo kanye nobujamo bezulu.

Imilambo ikhongozela amanzi wezulu bese iphakele amadamu amanzi lawo ukuze abulungwe amanzi begodu kwenziwe isiqiniseko sokuthi abantu neenlwana bafunyana amanzi (National Geographic 2024b&lt;ref name=&quot;:3&quot; /&gt;; ne-Smart Water Magazine 2024&lt;ref&gt;Smart Water Magazine. 2024. What is a river?. Itholakala ku-:&lt;nowiki&gt;https://smartwatermagazine.com/q-a/what-a-river&lt;/nowiki&gt;. Ifunyenwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Nanyana kunjalo-ke, kukhona imiphakathi ekha nanyana esebenzisa amanzi bunqopha kusuka emlanjeni ngebanga lokungabi nayo imithangalasisekelo yamanzi. Lokhu kusitjengisa ukuqakatheka kwemilambo begodu nesidingo sokunakekela imilambo esinayo. 

=== '''Isiphetho''' ===
Idamu singatjho bona mlambo owakhiweko bese kuthi umlambo wona kube lidami lemvelo nanyana lendabuko lelo elizenzakalelako. Idamu esikhathini esinengi lithembele emlanjeni bona lifunyane amanzi, kanti umlambo wona ukhongozela amanzi wezulu. 

=== '''Isilululwazi/umthombolwazi''' ===
&lt;references /&gt;
[[Mkhakha:Ezolwazi]]
[[Mkhakha:Ezemvelo]]</text>
      <sha1>kpa9hoatw5fo1kyr3b7n22uarvacabk</sha1>
    </revision>
    <revision>
      <id>1449</id>
      <parentid>1448</parentid>
      <timestamp>2024-10-14T13:47:42Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>8 revisions imported</comment>
      <origin>1448</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4731" sha1="kpa9hoatw5fo1kyr3b7n22uarvacabk" xml:space="preserve">== Umehluko hlangana kwedamu nomlambo. ==

=== Isingeniso ===
Emphakathini esiphila kiyo kuneendlela ezinengi zokubulunga amanzi nalezo ezisetjenziswa njengemithombo yamanzi. Iindlela lezi ziqakatheke kwamamba ekwenzeni isiqiniseko sokuthi abantu baba nepilo begodu bafunyana amanzi. Nanyana kunjalo-ke, ngaphasi kwesihloko sethu lesi sizokudzimelela khulu edamini nemlanjeni. Sizokuthoma ngesihloko esithi, Kuyini idamu? bese kulandele esithi, Kuyini umlambo?.

==== '''Kuyini idamu?''' ====
[[Isimumathi:Idamu lokubulunga amanzi Kosini.jpg|thumb|Idamu lokubulunga amanzi, langeKosini]]
Kwesinye isikhathi kuyaye kutlhogeke bonyana kukhongezelwe amanzi begodu abulungwe ukuze abantu bawafunyane (Wikipedia 2024a&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. Dam. Itholakala ku-: &lt;nowiki&gt;https://en.wikipedia.org/wiki/Dam&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). Isesetjenziswa sokukhongenzela amanzi begodu siwabulunge sibizwa bonyana lidamu (Wikipedia 2024a&lt;ref name=&quot;:0&quot; /&gt;). Idamu liyakhiwa ngomnqopho wokubamba amanzi begodu liwabulunge (National Geographic 2024a&lt;ref name=&quot;:1&quot;&gt;National Geographic. 2024. Dams. Itholakala ku-: &lt;nowiki&gt;https://education.nationalgeographic.org/resource/dams/&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). Amadamu la, ngesakhiwo nobungako kanye nomsebenzi angahluka ngokuya kweendawo neminqopho yawo.
[[Isimumathi:Idamu leKosini emThambithini.jpg|left|thumb|220x220px|Idamu leKosini, emThambithini]]
Kukhona [https://education.nationalgeographic.org/resource/dams/ amadamu] lawo amakhulu ngobujamo begodu umsebenzi wawo kukubulunga amanzi kanye nokuwasabalalise eendaweni nanyana kumadamu amancani lawo aphakela abantu nemiphakathi ngamanzi (The British Dam Society 2024a&lt;ref name=&quot;:2&quot;&gt;The British Dam Society. 2024. What is dam?. Itholakala ku-: &lt;nowiki&gt;https://britishdams.org/about-dams/dam-information/&lt;/nowiki&gt;. Ifunywane ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). [https://britishdams.org/about-dams/dam-information/ Amadamu] la, afuna itlhogonyelo tle begodu nalo itlhogonyelo lawo liyahluka. Idamu elikhulu lifuna itlhogonyelo elikhulu begodu lifuna nesikhathi esinengi lokha nalimadaniswa nedamu elincani. Amadamu kanengi afunyana nanyana amukela amanzi ukusuka emlanjeni ngesikhathi lapho kunezulu elinengi (Wikipedia 2024a&lt;ref name=&quot;:0&quot; /&gt;; National Geographic 2024a&lt;ref name=&quot;:1&quot; /&gt;; ne-The British Dam Society 2024a&lt;ref name=&quot;:2&quot; /&gt;).

Ukuyisonga, idamu liyakhiwa begodu liyahluka ngomnqopho. Kodwana, limthombo oqakathekileko mayelana nokuqinisekiswa bonyana imiphakathi ifunyana amanzi. 

==== '''Kuyini [[:en:River|umlambo]]?''' ====
[[Isimumathi:Umlambo iMoutse emThambothini.jpg|thumb|Umlambo iMoutse, eKosini]]
[https://www.britannica.com/science/river Umlambo] singatjho bonyana kulidamu lemvelo lelo elingakakhiwa kodwana eliziveleleko (Wikipedia 2024b;&lt;ref&gt;Wikipedia. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://en.wikipedia.org/wiki/River&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt; ne-Britannica 2024&lt;ref&gt;Britannica. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://www.britannica.com/science/river&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Ngamanye amagama, [https://smartwatermagazine.com/q-a/what-a-river umlambo] uyazivelela begodu nobujamo bawo buyazenzakalela. [https://education.nationalgeographic.org/resource/river/ Imilambo] nayo iyahluka ngobujamo begodu imithombo yeempilo yeenlwani ezinengi nabantu (National Geographic 2024b&lt;ref name=&quot;:3&quot;&gt;National Geographic. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://education.nationalgeographic.org/resource/river/&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Iinlwani ezitholakala emilanjeni ziyahluka ngokuya kweendawo kanye nobujamo bezulu.

Imilambo ikhongozela amanzi wezulu bese iphakele amadamu amanzi lawo ukuze abulungwe amanzi begodu kwenziwe isiqiniseko sokuthi abantu neenlwana bafunyana amanzi (National Geographic 2024b&lt;ref name=&quot;:3&quot; /&gt;; ne-Smart Water Magazine 2024&lt;ref&gt;Smart Water Magazine. 2024. What is a river?. Itholakala ku-:&lt;nowiki&gt;https://smartwatermagazine.com/q-a/what-a-river&lt;/nowiki&gt;. Ifunyenwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Nanyana kunjalo-ke, kukhona imiphakathi ekha nanyana esebenzisa amanzi bunqopha kusuka emlanjeni ngebanga lokungabi nayo imithangalasisekelo yamanzi. Lokhu kusitjengisa ukuqakatheka kwemilambo begodu nesidingo sokunakekela imilambo esinayo. 

=== '''Isiphetho''' ===
Idamu singatjho bona mlambo owakhiweko bese kuthi umlambo wona kube lidami lemvelo nanyana lendabuko lelo elizenzakalelako. Idamu esikhathini esinengi lithembele emlanjeni bona lifunyane amanzi, kanti umlambo wona ukhongozela amanzi wezulu. 

=== '''Isilululwazi/umthombolwazi''' ===
&lt;references /&gt;
[[Mkhakha:Ezolwazi]]
[[Mkhakha:Ezemvelo]]</text>
      <sha1>kpa9hoatw5fo1kyr3b7n22uarvacabk</sha1>
    </revision>
    <revision>
      <id>2197</id>
      <parentid>1449</parentid>
      <timestamp>2024-11-29T07:22:39Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* Isilululwazi/umthombolwazi */Reflist</comment>
      <origin>2197</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4729" sha1="pzvksw8z6sgfhwb5jkh9kfyq0xbhmfv" xml:space="preserve">== Umehluko hlangana kwedamu nomlambo. ==

=== Isingeniso ===
Emphakathini esiphila kiyo kuneendlela ezinengi zokubulunga amanzi nalezo ezisetjenziswa njengemithombo yamanzi. Iindlela lezi ziqakatheke kwamamba ekwenzeni isiqiniseko sokuthi abantu baba nepilo begodu bafunyana amanzi. Nanyana kunjalo-ke, ngaphasi kwesihloko sethu lesi sizokudzimelela khulu edamini nemlanjeni. Sizokuthoma ngesihloko esithi, Kuyini idamu? bese kulandele esithi, Kuyini umlambo?.

==== '''Kuyini idamu?''' ====
[[Isimumathi:Idamu lokubulunga amanzi Kosini.jpg|thumb|Idamu lokubulunga amanzi, langeKosini]]
Kwesinye isikhathi kuyaye kutlhogeke bonyana kukhongezelwe amanzi begodu abulungwe ukuze abantu bawafunyane (Wikipedia 2024a&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. Dam. Itholakala ku-: &lt;nowiki&gt;https://en.wikipedia.org/wiki/Dam&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). Isesetjenziswa sokukhongenzela amanzi begodu siwabulunge sibizwa bonyana lidamu (Wikipedia 2024a&lt;ref name=&quot;:0&quot; /&gt;). Idamu liyakhiwa ngomnqopho wokubamba amanzi begodu liwabulunge (National Geographic 2024a&lt;ref name=&quot;:1&quot;&gt;National Geographic. 2024. Dams. Itholakala ku-: &lt;nowiki&gt;https://education.nationalgeographic.org/resource/dams/&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). Amadamu la, ngesakhiwo nobungako kanye nomsebenzi angahluka ngokuya kweendawo neminqopho yawo.
[[Isimumathi:Idamu leKosini emThambithini.jpg|left|thumb|220x220px|Idamu leKosini, emThambithini]]
Kukhona [https://education.nationalgeographic.org/resource/dams/ amadamu] lawo amakhulu ngobujamo begodu umsebenzi wawo kukubulunga amanzi kanye nokuwasabalalise eendaweni nanyana kumadamu amancani lawo aphakela abantu nemiphakathi ngamanzi (The British Dam Society 2024a&lt;ref name=&quot;:2&quot;&gt;The British Dam Society. 2024. What is dam?. Itholakala ku-: &lt;nowiki&gt;https://britishdams.org/about-dams/dam-information/&lt;/nowiki&gt;. Ifunywane ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). [https://britishdams.org/about-dams/dam-information/ Amadamu] la, afuna itlhogonyelo tle begodu nalo itlhogonyelo lawo liyahluka. Idamu elikhulu lifuna itlhogonyelo elikhulu begodu lifuna nesikhathi esinengi lokha nalimadaniswa nedamu elincani. Amadamu kanengi afunyana nanyana amukela amanzi ukusuka emlanjeni ngesikhathi lapho kunezulu elinengi (Wikipedia 2024a&lt;ref name=&quot;:0&quot; /&gt;; National Geographic 2024a&lt;ref name=&quot;:1&quot; /&gt;; ne-The British Dam Society 2024a&lt;ref name=&quot;:2&quot; /&gt;).

Ukuyisonga, idamu liyakhiwa begodu liyahluka ngomnqopho. Kodwana, limthombo oqakathekileko mayelana nokuqinisekiswa bonyana imiphakathi ifunyana amanzi. 

==== '''Kuyini [[:en:River|umlambo]]?''' ====
[[Isimumathi:Umlambo iMoutse emThambothini.jpg|thumb|Umlambo iMoutse, eKosini]]
[https://www.britannica.com/science/river Umlambo] singatjho bonyana kulidamu lemvelo lelo elingakakhiwa kodwana eliziveleleko (Wikipedia 2024b;&lt;ref&gt;Wikipedia. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://en.wikipedia.org/wiki/River&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt; ne-Britannica 2024&lt;ref&gt;Britannica. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://www.britannica.com/science/river&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Ngamanye amagama, [https://smartwatermagazine.com/q-a/what-a-river umlambo] uyazivelela begodu nobujamo bawo buyazenzakalela. [https://education.nationalgeographic.org/resource/river/ Imilambo] nayo iyahluka ngobujamo begodu imithombo yeempilo yeenlwani ezinengi nabantu (National Geographic 2024b&lt;ref name=&quot;:3&quot;&gt;National Geographic. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://education.nationalgeographic.org/resource/river/&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Iinlwani ezitholakala emilanjeni ziyahluka ngokuya kweendawo kanye nobujamo bezulu.

Imilambo ikhongozela amanzi wezulu bese iphakele amadamu amanzi lawo ukuze abulungwe amanzi begodu kwenziwe isiqiniseko sokuthi abantu neenlwana bafunyana amanzi (National Geographic 2024b&lt;ref name=&quot;:3&quot; /&gt;; ne-Smart Water Magazine 2024&lt;ref&gt;Smart Water Magazine. 2024. What is a river?. Itholakala ku-:&lt;nowiki&gt;https://smartwatermagazine.com/q-a/what-a-river&lt;/nowiki&gt;. Ifunyenwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Nanyana kunjalo-ke, kukhona imiphakathi ekha nanyana esebenzisa amanzi bunqopha kusuka emlanjeni ngebanga lokungabi nayo imithangalasisekelo yamanzi. Lokhu kusitjengisa ukuqakatheka kwemilambo begodu nesidingo sokunakekela imilambo esinayo. 

=== '''Isiphetho''' ===
Idamu singatjho bona mlambo owakhiweko bese kuthi umlambo wona kube lidami lemvelo nanyana lendabuko lelo elizenzakalelako. Idamu esikhathini esinengi lithembele emlanjeni bona lifunyane amanzi, kanti umlambo wona ukhongozela amanzi wezulu. 

=== '''Isilululwazi/umthombolwazi''' ===
{{Reflist}}

[[Mkhakha:Ezolwazi]]
[[Mkhakha:Ezemvelo]]</text>
      <sha1>pzvksw8z6sgfhwb5jkh9kfyq0xbhmfv</sha1>
    </revision>
    <revision>
      <id>2497</id>
      <parentid>2197</parentid>
      <timestamp>2025-03-03T19:40:23Z</timestamp>
      <contributor>
        <ip>88.238.42.1</ip>
      </contributor>
      <origin>2497</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4766" sha1="81yy7u2tyv1vk46utz4wcobm7d8w9mh" xml:space="preserve">== Umehluko hlangana kwedamu nomlambo. ==

=== Isingeniso ===
Emphakathini esiphila kiyo kuneendlela ezinengi zokubulunga amanzi nalezo ezisetjenziswa njengemithombo yamanzi. Iindlela lezi ziqakatheke kwamamba ekwenzeni isiqiniseko sokuthi abantu baba nepilo begodu bafunyana amanzi. Nanyana kunjalo-ke, ngaphasi kwesihloko sethu lesi sizokudzimelela khulu edamini nemlanjeni. Sizokuthoma ngesihloko esithi, Kuyini idamu? bese kulandele esithi, Kuyini umlambo?.

==== '''Kuyini idamu?''' ====
[[Isimumathi:Idamu lokubulunga amanzi Kosini.jpg|thumb|Idamu lokubulunga amanzi, langeKosini]]
Kwesinye isikhathi kuyaye kutlhogeke bonyana kukhongezelwe amanzi begodu abulungwe ukuze abantu bawafunyane (Wikipedia 2024a&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. Dam. Itholakala ku-: &lt;nowiki&gt;https://en.wikipedia.org/wiki/Dam&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). Isesetjenziswa sokukhongenzela amanzi begodu siwabulunge sibizwa bonyana lidamu (Wikipedia 2024a&lt;ref name=&quot;:0&quot; /&gt;). Idamu liyakhiwa ngomnqopho wokubamba amanzi begodu liwabulunge (National Geographic 2024a&lt;ref name=&quot;:1&quot;&gt;National Geographic. 2024. Dams. Itholakala ku-: &lt;nowiki&gt;https://education.nationalgeographic.org/resource/dams/&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). Amadamu la, ngesakhiwo nobungako kanye nomsebenzi angahluka ngokuya kweendawo neminqopho yawo.
[[Isimumathi:Idamu leKosini emThambithini.jpg|left|thumb|220x220px|Idamu leKosini, emThambithini]]
Kukhona [https://education.nationalgeographic.org/resource/dams/ amadamu] lawo amakhulu ngobujamo begodu umsebenzi wawo kukubulunga amanzi kanye nokuwasabalalise eendaweni nanyana kumadamu amancani lawo aphakela abantu nemiphakathi ngamanzi (The British Dam Society 2024a&lt;ref name=&quot;:2&quot;&gt;The British Dam Society. 2024. What is dam?. Itholakala ku-: &lt;nowiki&gt;https://britishdams.org/about-dams/dam-information/&lt;/nowiki&gt;. Ifunywane ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). [https://britishdams.org/about-dams/dam-information/ Amadamu] la, afuna itlhogonyelo tle begodu nalo itlhogonyelo lawo liyahluka. Idamu elikhulu lifuna itlhogonyelo elikhulu begodu lifuna nesikhathi esinengi lokha nalimadaniswa nedamu elincani. Amadamu kanengi afunyana nanyana amukela amanzi ukusuka emlanjeni ngesikhathi lapho kunezulu elinengi (Wikipedia 2024a&lt;ref name=&quot;:0&quot; /&gt;; National Geographic 2024a&lt;ref name=&quot;:1&quot; /&gt;; ne-The British Dam Society 2024a&lt;ref name=&quot;:2&quot; /&gt;).

Ukuyisonga, idamu liyakhiwa begodu liyahluka ngomnqopho. Kodwana, limthombo oqakathekileko mayelana nokuqinisekiswa bonyana imiphakathi ifunyana amanzi. 

==== '''Kuyini [[:en:River|umlambo]]?''' ====
[[Isimumathi:Umlambo iMoutse emThambothini.jpg|thumb|Umlambo iMoutse, eKosini]]
[https://www.britannica.com/science/river Umlambo] singatjho bonyana kulidamu lemvelo lelo elingakakhiwa kodwana eliziveleleko (Wikipedia 2024b;&lt;ref&gt;Wikipedia. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://en.wikipedia.org/wiki/River&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt; ne-Britannica 2024&lt;ref&gt;Britannica. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://www.britannica.com/science/river&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Ngamanye amagama, [https://smartwatermagazine.com/q-a/what-a-river umlambo] uyazivelela begodu nobujamo bawo buyazenzakalela. [https://education.nationalgeographic.org/resource/river/ Imilambo] nayo iyahluka [https://www.kargosubesi.biz/ kargo] ngobujamo begodu imithombo yeempilo yeenlwani ezinengi nabantu (National Geographic 2024b&lt;ref name=&quot;:3&quot;&gt;National Geographic. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://education.nationalgeographic.org/resource/river/&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Iinlwani ezitholakala emilanjeni ziyahluka ngokuya kweendawo kanye nobujamo bezulu.

Imilambo ikhongozela amanzi wezulu bese iphakele amadamu amanzi lawo ukuze abulungwe amanzi begodu kwenziwe isiqiniseko sokuthi abantu neenlwana bafunyana amanzi (National Geographic 2024b&lt;ref name=&quot;:3&quot; /&gt;; ne-Smart Water Magazine 2024&lt;ref&gt;Smart Water Magazine. 2024. What is a river?. Itholakala ku-:&lt;nowiki&gt;https://smartwatermagazine.com/q-a/what-a-river&lt;/nowiki&gt;. Ifunyenwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Nanyana kunjalo-ke, kukhona imiphakathi ekha nanyana esebenzisa amanzi bunqopha kusuka emlanjeni ngebanga lokungabi nayo imithangalasisekelo yamanzi. Lokhu kusitjengisa ukuqakatheka kwemilambo begodu nesidingo sokunakekela imilambo esinayo. 

=== '''Isiphetho''' ===
Idamu singatjho bona mlambo owakhiweko bese kuthi umlambo wona kube lidami lemvelo nanyana lendabuko lelo elizenzakalelako. Idamu esikhathini esinengi lithembele emlanjeni bona lifunyane amanzi, kanti umlambo wona ukhongozela amanzi wezulu. 

=== '''Isilululwazi/umthombolwazi''' ===
{{Reflist}}

[[Mkhakha:Ezolwazi]]
[[Mkhakha:Ezemvelo]]</text>
      <sha1>81yy7u2tyv1vk46utz4wcobm7d8w9mh</sha1>
    </revision>
    <revision>
      <id>2997</id>
      <parentid>2497</parentid>
      <timestamp>2025-06-06T20:17:45Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>hgvhnedj</comment>
      <origin>2997</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4854" sha1="p42881ndb7evkou16m52ta5oa87ruqo" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.'''

== Umehluko hlangana kwedamu nomlambo. ==

=== Isingeniso ===
Emphakathini esiphila kiyo kuneendlela ezinengi zokubulunga amanzi nalezo ezisetjenziswa njengemithombo yamanzi. Iindlela lezi ziqakatheke kwamamba ekwenzeni isiqiniseko sokuthi abantu baba nepilo begodu bafunyana amanzi. Nanyana kunjalo-ke, ngaphasi kwesihloko sethu lesi sizokudzimelela khulu edamini nemlanjeni. Sizokuthoma ngesihloko esithi, Kuyini idamu? bese kulandele esithi, Kuyini umlambo?.

==== '''Kuyini idamu?''' ====
[[Isimumathi:Idamu lokubulunga amanzi Kosini.jpg|thumb|Idamu lokubulunga amanzi, langeKosini]]
Kwesinye isikhathi kuyaye kutlhogeke bonyana kukhongezelwe amanzi begodu abulungwe ukuze abantu bawafunyane (Wikipedia 2024a&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. Dam. Itholakala ku-: &lt;nowiki&gt;https://en.wikipedia.org/wiki/Dam&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). Isesetjenziswa sokukhongenzela amanzi begodu siwabulunge sibizwa bonyana lidamu (Wikipedia 2024a&lt;ref name=&quot;:0&quot; /&gt;). Idamu liyakhiwa ngomnqopho wokubamba amanzi begodu liwabulunge (National Geographic 2024a&lt;ref name=&quot;:1&quot;&gt;National Geographic. 2024. Dams. Itholakala ku-: &lt;nowiki&gt;https://education.nationalgeographic.org/resource/dams/&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). Amadamu la, ngesakhiwo nobungako kanye nomsebenzi angahluka ngokuya kweendawo neminqopho yawo.
[[Isimumathi:Idamu leKosini emThambithini.jpg|left|thumb|220x220px|Idamu leKosini, emThambithini]]
Kukhona [https://education.nationalgeographic.org/resource/dams/ amadamu] lawo amakhulu ngobujamo begodu umsebenzi wawo kukubulunga amanzi kanye nokuwasabalalise eendaweni nanyana kumadamu amancani lawo aphakela abantu nemiphakathi ngamanzi (The British Dam Society 2024a&lt;ref name=&quot;:2&quot;&gt;The British Dam Society. 2024. What is dam?. Itholakala ku-: &lt;nowiki&gt;https://britishdams.org/about-dams/dam-information/&lt;/nowiki&gt;. Ifunywane ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). [https://britishdams.org/about-dams/dam-information/ Amadamu] la, afuna itlhogonyelo tle begodu nalo itlhogonyelo lawo liyahluka. Idamu elikhulu lifuna itlhogonyelo elikhulu begodu lifuna nesikhathi esinengi lokha nalimadaniswa nedamu elincani. Amadamu kanengi afunyana nanyana amukela amanzi ukusuka emlanjeni ngesikhathi lapho kunezulu elinengi (Wikipedia 2024a&lt;ref name=&quot;:0&quot; /&gt;; National Geographic 2024a&lt;ref name=&quot;:1&quot; /&gt;; ne-The British Dam Society 2024a&lt;ref name=&quot;:2&quot; /&gt;).

Ukuyisonga, idamu liyakhiwa begodu liyahluka ngomnqopho. Kodwana, limthombo oqakathekileko mayelana nokuqinisekiswa bonyana imiphakathi ifunyana amanzi. 

==== '''Kuyini [[:en:River|umlambo]]?''' ====
[[Isimumathi:Umlambo iMoutse emThambothini.jpg|thumb|Umlambo iMoutse, eKosini]]
[https://www.britannica.com/science/river Umlambo] singatjho bonyana kulidamu lemvelo lelo elingakakhiwa kodwana eliziveleleko (Wikipedia 2024b;&lt;ref&gt;Wikipedia. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://en.wikipedia.org/wiki/River&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt; ne-Britannica 2024&lt;ref&gt;Britannica. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://www.britannica.com/science/river&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Ngamanye amagama, [https://smartwatermagazine.com/q-a/what-a-river umlambo] uyazivelela begodu nobujamo bawo buyazenzakalela. [https://education.nationalgeographic.org/resource/river/ Imilambo] nayo iyahluka [https://www.kargosubesi.biz/ kargo] ngobujamo begodu imithombo yeempilo yeenlwani ezinengi nabantu (National Geographic 2024b&lt;ref name=&quot;:3&quot;&gt;National Geographic. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://education.nationalgeographic.org/resource/river/&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Iinlwani ezitholakala emilanjeni ziyahluka ngokuya kweendawo kanye nobujamo bezulu.

Imilambo ikhongozela amanzi wezulu bese iphakele amadamu amanzi lawo ukuze abulungwe amanzi begodu kwenziwe isiqiniseko sokuthi abantu neenlwana bafunyana amanzi (National Geographic 2024b&lt;ref name=&quot;:3&quot; /&gt;; ne-Smart Water Magazine 2024&lt;ref&gt;Smart Water Magazine. 2024. What is a river?. Itholakala ku-:&lt;nowiki&gt;https://smartwatermagazine.com/q-a/what-a-river&lt;/nowiki&gt;. Ifunyenwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Nanyana kunjalo-ke, kukhona imiphakathi ekha nanyana esebenzisa amanzi bunqopha kusuka emlanjeni ngebanga lokungabi nayo imithangalasisekelo yamanzi. Lokhu kusitjengisa ukuqakatheka kwemilambo begodu nesidingo sokunakekela imilambo esinayo. 

=== '''Isiphetho''' ===
Idamu singatjho bona mlambo owakhiweko bese kuthi umlambo wona kube lidami lemvelo nanyana lendabuko lelo elizenzakalelako. Idamu esikhathini esinengi lithembele emlanjeni bona lifunyane amanzi, kanti umlambo wona ukhongozela amanzi wezulu. 

=== '''Isilululwazi/umthombolwazi''' ===
{{Reflist}}

[[Mkhakha:Ezolwazi]]
[[Mkhakha:Ezemvelo]]</text>
      <sha1>p42881ndb7evkou16m52ta5oa87ruqo</sha1>
    </revision>
    <revision>
      <id>3072</id>
      <parentid>2997</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:88.238.42.1|88.238.42.1]]</comment>
      <origin>2497</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4766" sha1="81yy7u2tyv1vk46utz4wcobm7d8w9mh" xml:space="preserve">== Umehluko hlangana kwedamu nomlambo. ==

=== Isingeniso ===
Emphakathini esiphila kiyo kuneendlela ezinengi zokubulunga amanzi nalezo ezisetjenziswa njengemithombo yamanzi. Iindlela lezi ziqakatheke kwamamba ekwenzeni isiqiniseko sokuthi abantu baba nepilo begodu bafunyana amanzi. Nanyana kunjalo-ke, ngaphasi kwesihloko sethu lesi sizokudzimelela khulu edamini nemlanjeni. Sizokuthoma ngesihloko esithi, Kuyini idamu? bese kulandele esithi, Kuyini umlambo?.

==== '''Kuyini idamu?''' ====
[[Isimumathi:Idamu lokubulunga amanzi Kosini.jpg|thumb|Idamu lokubulunga amanzi, langeKosini]]
Kwesinye isikhathi kuyaye kutlhogeke bonyana kukhongezelwe amanzi begodu abulungwe ukuze abantu bawafunyane (Wikipedia 2024a&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. Dam. Itholakala ku-: &lt;nowiki&gt;https://en.wikipedia.org/wiki/Dam&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). Isesetjenziswa sokukhongenzela amanzi begodu siwabulunge sibizwa bonyana lidamu (Wikipedia 2024a&lt;ref name=&quot;:0&quot; /&gt;). Idamu liyakhiwa ngomnqopho wokubamba amanzi begodu liwabulunge (National Geographic 2024a&lt;ref name=&quot;:1&quot;&gt;National Geographic. 2024. Dams. Itholakala ku-: &lt;nowiki&gt;https://education.nationalgeographic.org/resource/dams/&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). Amadamu la, ngesakhiwo nobungako kanye nomsebenzi angahluka ngokuya kweendawo neminqopho yawo.
[[Isimumathi:Idamu leKosini emThambithini.jpg|left|thumb|220x220px|Idamu leKosini, emThambithini]]
Kukhona [https://education.nationalgeographic.org/resource/dams/ amadamu] lawo amakhulu ngobujamo begodu umsebenzi wawo kukubulunga amanzi kanye nokuwasabalalise eendaweni nanyana kumadamu amancani lawo aphakela abantu nemiphakathi ngamanzi (The British Dam Society 2024a&lt;ref name=&quot;:2&quot;&gt;The British Dam Society. 2024. What is dam?. Itholakala ku-: &lt;nowiki&gt;https://britishdams.org/about-dams/dam-information/&lt;/nowiki&gt;. Ifunywane ngomhlaka [07 kuRhoboyi 2024].&lt;/ref&gt;). [https://britishdams.org/about-dams/dam-information/ Amadamu] la, afuna itlhogonyelo tle begodu nalo itlhogonyelo lawo liyahluka. Idamu elikhulu lifuna itlhogonyelo elikhulu begodu lifuna nesikhathi esinengi lokha nalimadaniswa nedamu elincani. Amadamu kanengi afunyana nanyana amukela amanzi ukusuka emlanjeni ngesikhathi lapho kunezulu elinengi (Wikipedia 2024a&lt;ref name=&quot;:0&quot; /&gt;; National Geographic 2024a&lt;ref name=&quot;:1&quot; /&gt;; ne-The British Dam Society 2024a&lt;ref name=&quot;:2&quot; /&gt;).

Ukuyisonga, idamu liyakhiwa begodu liyahluka ngomnqopho. Kodwana, limthombo oqakathekileko mayelana nokuqinisekiswa bonyana imiphakathi ifunyana amanzi. 

==== '''Kuyini [[:en:River|umlambo]]?''' ====
[[Isimumathi:Umlambo iMoutse emThambothini.jpg|thumb|Umlambo iMoutse, eKosini]]
[https://www.britannica.com/science/river Umlambo] singatjho bonyana kulidamu lemvelo lelo elingakakhiwa kodwana eliziveleleko (Wikipedia 2024b;&lt;ref&gt;Wikipedia. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://en.wikipedia.org/wiki/River&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt; ne-Britannica 2024&lt;ref&gt;Britannica. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://www.britannica.com/science/river&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Ngamanye amagama, [https://smartwatermagazine.com/q-a/what-a-river umlambo] uyazivelela begodu nobujamo bawo buyazenzakalela. [https://education.nationalgeographic.org/resource/river/ Imilambo] nayo iyahluka [https://www.kargosubesi.biz/ kargo] ngobujamo begodu imithombo yeempilo yeenlwani ezinengi nabantu (National Geographic 2024b&lt;ref name=&quot;:3&quot;&gt;National Geographic. 2024. River. Itholakala ku-:&lt;nowiki&gt;https://education.nationalgeographic.org/resource/river/&lt;/nowiki&gt;. Ifunyanwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Iinlwani ezitholakala emilanjeni ziyahluka ngokuya kweendawo kanye nobujamo bezulu.

Imilambo ikhongozela amanzi wezulu bese iphakele amadamu amanzi lawo ukuze abulungwe amanzi begodu kwenziwe isiqiniseko sokuthi abantu neenlwana bafunyana amanzi (National Geographic 2024b&lt;ref name=&quot;:3&quot; /&gt;; ne-Smart Water Magazine 2024&lt;ref&gt;Smart Water Magazine. 2024. What is a river?. Itholakala ku-:&lt;nowiki&gt;https://smartwatermagazine.com/q-a/what-a-river&lt;/nowiki&gt;. Ifunyenwe ngomhlaka [08 kuRhoboyi 2024].&lt;/ref&gt;). Nanyana kunjalo-ke, kukhona imiphakathi ekha nanyana esebenzisa amanzi bunqopha kusuka emlanjeni ngebanga lokungabi nayo imithangalasisekelo yamanzi. Lokhu kusitjengisa ukuqakatheka kwemilambo begodu nesidingo sokunakekela imilambo esinayo. 

=== '''Isiphetho''' ===
Idamu singatjho bona mlambo owakhiweko bese kuthi umlambo wona kube lidami lemvelo nanyana lendabuko lelo elizenzakalelako. Idamu esikhathini esinengi lithembele emlanjeni bona lifunyane amanzi, kanti umlambo wona ukhongozela amanzi wezulu. 

=== '''Isilululwazi/umthombolwazi''' ===
{{Reflist}}

[[Mkhakha:Ezolwazi]]
[[Mkhakha:Ezemvelo]]</text>
      <sha1>81yy7u2tyv1vk46utz4wcobm7d8w9mh</sha1>
    </revision>
  </page>
  <page>
    <title>Umfundaze</title>
    <ns>0</ns>
    <id>269</id>
    <revision>
      <id>1450</id>
      <timestamp>2024-09-15T10:15:45Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;== Umfundaze ==  === Isingeniso === Ephasini kukhona isizo lelo elenzelwe ukusiza abantu abanganalutho kodwana khube banekghono nanyana isiphiwo sokwenza nanyana sokufunda izinto ezithile. Isizo lelo kungaba kusekelwa ngemmali, iinsetjenziswa nanyana baphiwe ibandulo bameyala nakuthuthukisa begodu nokufeza amabhudango namakghono wabo. Ezinye zesizo lezo mfundaze nanyana umfundasimahla. Esihlokwaneni esilandelako sizokutjheja bonyana kuyini umfundaze nanyana umfundasimahl...&quot;</comment>
      <origin>1450</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3044" sha1="a4hh8em8yvc7407mlxp898y3eljjylu" xml:space="preserve">== Umfundaze ==

=== Isingeniso ===
Ephasini kukhona isizo lelo elenzelwe ukusiza abantu abanganalutho kodwana khube banekghono nanyana isiphiwo sokwenza nanyana sokufunda izinto ezithile. Isizo lelo kungaba kusekelwa ngemmali, iinsetjenziswa nanyana baphiwe ibandulo bameyala nakuthuthukisa begodu nokufeza amabhudango namakghono wabo. Ezinye zesizo lezo mfundaze nanyana umfundasimahla. Esihlokwaneni esilandelako sizokutjheja bonyana kuyini umfundaze nanyana umfundasimahla.

=== Kuyini umfundaze nanyana umfundasimahla? ===
Ngokuya kwe-Wikipedia (2024)&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. ''Bursary''. Itholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Bursary&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [24 kuRhoboyi 2024].&lt;/ref&gt; isekelwa yi-Revolution Media (2024)&lt;ref&gt;Revolution Media. 2024. ''What is a bursary.'' Litholakala ku:&gt;https://revolution.edu.za/what-is-a-bursary-and-how-does-it-differ-from-a-scholarship/&gt;. Lifunyenwe ngomhlaka [24 kuRhoboyi 2024].&lt;/ref&gt;, [https://revolution.edu.za/what-is-a-bursary-and-how-does-it-differ-from-a-scholarship/ umfundaze] kungunongwara nanyana umtlomelo loyo ophiwa iinqema nanyana abantu maziko nanyana iinhlangano zefundo. Iragele phambili, i-Wikipedia (2024&lt;ref name=&quot;:0&quot; /&gt;), yathi, umtlomelo lo uphiwa umfundi bonyana aye esikolweni, eyunivesithi nanyana ekholiji ngesikhathi angakghoni ukuya. Amphuzu la, ayasitjela bona umfundaze usiba abafuna ukufunda kodwana khube babhalelwa ziinthoro zokufunda. Ukungezelela, ihlathululo le inqophe khulu kumaziko nanyana iinhlangano zefundo.


Ngokuya kweYunivesithi i-Nelson Mandela Metropolitan University (2024&lt;ref name=&quot;:1&quot;&gt;Nelson Mandela Metropolitan University. ''What is the difference between a loan, bursary and scholarship? Itholakala ku''''':&lt;'''&lt;nowiki&gt;https://www.mandela.ac.za/Apply/Frequently-asked-questions/Money-Matters/What-is-the-difference-between-a-loan,-bursary-and#FAQLink1769&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [24 kuRhoboyi 2024]&lt;/ref&gt;) ne-Dictionary Cambridge (2024&lt;ref&gt;Cambridge Dictionary. 2024. ''Bursary''. Itholakala ku:&lt; &lt;nowiki&gt;https://dictionary.cambridge.org/dictionary/english/bursary&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [24 kuRhoboyi 2024].&lt;/ref&gt;), [[:en:Bursary|umfundaze]] kulisizo lemali ehlakahlukeneko enikelweko abosofundwakghono nabafundi bonyana bathuthukise iimfunde zabo. Imali ingabuyi kumakhamphani begodu kufanele labo abanikelwa umfundaze lo batlikitliki isibopho neenkhamphani leyo (Yunivesity i-Nelson Mandela 2024&lt;ref name=&quot;:1&quot; /&gt;). Ihlathululo yeYunivesithi i-Nelson Mandela Metropolitan University (2024)&lt;ref name=&quot;:1&quot; /&gt; ingezelel phezu kwehlathululo ye-Wikipedia (2024)&lt;ref name=&quot;:0&quot; /&gt; ngokuthi umfundaze lo unikelwa abafundi nabosofundwakgho.

=== Isiphetho ===
[https://dictionary.cambridge.org/dictionary/english/bursary Umfundaze] kuyimali enikelwa abafundi nabosokghonofundwa yiziko lefundo, ihlangano nekhamphani yangeqadi njengesizo ukuze bathuthukise ifundo yamo namakghono wabo. Imali ingasetjenzisa ukubahdela iimfundo nokuthenga ezinye iinsetjenziswa zokufunda. 

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>a4hh8em8yvc7407mlxp898y3eljjylu</sha1>
    </revision>
    <revision>
      <id>1451</id>
      <parentid>1450</parentid>
      <timestamp>2024-09-18T16:03:14Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1451</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3045" sha1="32twax6qpsiin8sk4gpm70zns28u4sd" xml:space="preserve">== Umfundaze ==

=== Isingeniso. ===
Ephasini kukhona isizo lelo elenzelwe ukusiza abantu abanganalutho kodwana khube banekghono nanyana isiphiwo sokwenza nanyana sokufunda izinto ezithile. Isizo lelo kungaba kusekelwa ngemmali, iinsetjenziswa nanyana baphiwe ibandulo bameyala nakuthuthukisa begodu nokufeza amabhudango namakghono wabo. Ezinye zesizo lezo mfundaze nanyana umfundasimahla. Esihlokwaneni esilandelako sizokutjheja bonyana kuyini umfundaze nanyana umfundasimahla.

=== Kuyini umfundaze nanyana umfundasimahla? ===
Ngokuya kwe-Wikipedia (2024)&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. ''Bursary''. Itholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Bursary&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [24 kuRhoboyi 2024].&lt;/ref&gt; isekelwa yi-Revolution Media (2024)&lt;ref&gt;Revolution Media. 2024. ''What is a bursary.'' Litholakala ku:&gt;https://revolution.edu.za/what-is-a-bursary-and-how-does-it-differ-from-a-scholarship/&gt;. Lifunyenwe ngomhlaka [24 kuRhoboyi 2024].&lt;/ref&gt;, [https://revolution.edu.za/what-is-a-bursary-and-how-does-it-differ-from-a-scholarship/ umfundaze] kungunongwara nanyana umtlomelo loyo ophiwa iinqema nanyana abantu maziko nanyana iinhlangano zefundo. Iragele phambili, i-Wikipedia (2024&lt;ref name=&quot;:0&quot; /&gt;), yathi, umtlomelo lo uphiwa umfundi bonyana aye esikolweni, eyunivesithi nanyana ekholiji ngesikhathi angakghoni ukuya. Amphuzu la, ayasitjela bona umfundaze usiba abafuna ukufunda kodwana khube babhalelwa ziinthoro zokufunda. Ukungezelela, ihlathululo le inqophe khulu kumaziko nanyana iinhlangano zefundo.


Ngokuya kweYunivesithi i-Nelson Mandela Metropolitan University (2024&lt;ref name=&quot;:1&quot;&gt;Nelson Mandela Metropolitan University. ''What is the difference between a loan, bursary and scholarship? Itholakala ku''''':&lt;'''&lt;nowiki&gt;https://www.mandela.ac.za/Apply/Frequently-asked-questions/Money-Matters/What-is-the-difference-between-a-loan,-bursary-and#FAQLink1769&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [24 kuRhoboyi 2024]&lt;/ref&gt;) ne-Dictionary Cambridge (2024&lt;ref&gt;Cambridge Dictionary. 2024. ''Bursary''. Itholakala ku:&lt; &lt;nowiki&gt;https://dictionary.cambridge.org/dictionary/english/bursary&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [24 kuRhoboyi 2024].&lt;/ref&gt;), [[:en:Bursary|umfundaze]] kulisizo lemali ehlakahlukeneko enikelweko abosofundwakghono nabafundi bonyana bathuthukise iimfunde zabo. Imali ingabuyi kumakhamphani begodu kufanele labo abanikelwa umfundaze lo batlikitliki isibopho neenkhamphani leyo (Yunivesity i-Nelson Mandela 2024&lt;ref name=&quot;:1&quot; /&gt;). Ihlathululo yeYunivesithi i-Nelson Mandela Metropolitan University (2024)&lt;ref name=&quot;:1&quot; /&gt; ingezelel phezu kwehlathululo ye-Wikipedia (2024)&lt;ref name=&quot;:0&quot; /&gt; ngokuthi umfundaze lo unikelwa abafundi nabosofundwakgho.

=== Isiphetho ===
[https://dictionary.cambridge.org/dictionary/english/bursary Umfundaze] kuyimali enikelwa abafundi nabosokghonofundwa yiziko lefundo, ihlangano nekhamphani yangeqadi njengesizo ukuze bathuthukise ifundo yamo namakghono wabo. Imali ingasetjenzisa ukubahdela iimfundo nokuthenga ezinye iinsetjenziswa zokufunda. 

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>32twax6qpsiin8sk4gpm70zns28u4sd</sha1>
    </revision>
    <revision>
      <id>1452</id>
      <parentid>1451</parentid>
      <timestamp>2024-10-14T13:47:42Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>1451</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3045" sha1="32twax6qpsiin8sk4gpm70zns28u4sd" xml:space="preserve">== Umfundaze ==

=== Isingeniso. ===
Ephasini kukhona isizo lelo elenzelwe ukusiza abantu abanganalutho kodwana khube banekghono nanyana isiphiwo sokwenza nanyana sokufunda izinto ezithile. Isizo lelo kungaba kusekelwa ngemmali, iinsetjenziswa nanyana baphiwe ibandulo bameyala nakuthuthukisa begodu nokufeza amabhudango namakghono wabo. Ezinye zesizo lezo mfundaze nanyana umfundasimahla. Esihlokwaneni esilandelako sizokutjheja bonyana kuyini umfundaze nanyana umfundasimahla.

=== Kuyini umfundaze nanyana umfundasimahla? ===
Ngokuya kwe-Wikipedia (2024)&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. ''Bursary''. Itholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Bursary&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [24 kuRhoboyi 2024].&lt;/ref&gt; isekelwa yi-Revolution Media (2024)&lt;ref&gt;Revolution Media. 2024. ''What is a bursary.'' Litholakala ku:&gt;https://revolution.edu.za/what-is-a-bursary-and-how-does-it-differ-from-a-scholarship/&gt;. Lifunyenwe ngomhlaka [24 kuRhoboyi 2024].&lt;/ref&gt;, [https://revolution.edu.za/what-is-a-bursary-and-how-does-it-differ-from-a-scholarship/ umfundaze] kungunongwara nanyana umtlomelo loyo ophiwa iinqema nanyana abantu maziko nanyana iinhlangano zefundo. Iragele phambili, i-Wikipedia (2024&lt;ref name=&quot;:0&quot; /&gt;), yathi, umtlomelo lo uphiwa umfundi bonyana aye esikolweni, eyunivesithi nanyana ekholiji ngesikhathi angakghoni ukuya. Amphuzu la, ayasitjela bona umfundaze usiba abafuna ukufunda kodwana khube babhalelwa ziinthoro zokufunda. Ukungezelela, ihlathululo le inqophe khulu kumaziko nanyana iinhlangano zefundo.


Ngokuya kweYunivesithi i-Nelson Mandela Metropolitan University (2024&lt;ref name=&quot;:1&quot;&gt;Nelson Mandela Metropolitan University. ''What is the difference between a loan, bursary and scholarship? Itholakala ku''''':&lt;'''&lt;nowiki&gt;https://www.mandela.ac.za/Apply/Frequently-asked-questions/Money-Matters/What-is-the-difference-between-a-loan,-bursary-and#FAQLink1769&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [24 kuRhoboyi 2024]&lt;/ref&gt;) ne-Dictionary Cambridge (2024&lt;ref&gt;Cambridge Dictionary. 2024. ''Bursary''. Itholakala ku:&lt; &lt;nowiki&gt;https://dictionary.cambridge.org/dictionary/english/bursary&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [24 kuRhoboyi 2024].&lt;/ref&gt;), [[:en:Bursary|umfundaze]] kulisizo lemali ehlakahlukeneko enikelweko abosofundwakghono nabafundi bonyana bathuthukise iimfunde zabo. Imali ingabuyi kumakhamphani begodu kufanele labo abanikelwa umfundaze lo batlikitliki isibopho neenkhamphani leyo (Yunivesity i-Nelson Mandela 2024&lt;ref name=&quot;:1&quot; /&gt;). Ihlathululo yeYunivesithi i-Nelson Mandela Metropolitan University (2024)&lt;ref name=&quot;:1&quot; /&gt; ingezelel phezu kwehlathululo ye-Wikipedia (2024)&lt;ref name=&quot;:0&quot; /&gt; ngokuthi umfundaze lo unikelwa abafundi nabosofundwakgho.

=== Isiphetho ===
[https://dictionary.cambridge.org/dictionary/english/bursary Umfundaze] kuyimali enikelwa abafundi nabosokghonofundwa yiziko lefundo, ihlangano nekhamphani yangeqadi njengesizo ukuze bathuthukise ifundo yamo namakghono wabo. Imali ingasetjenzisa ukubahdela iimfundo nokuthenga ezinye iinsetjenziswa zokufunda. 

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>32twax6qpsiin8sk4gpm70zns28u4sd</sha1>
    </revision>
    <revision>
      <id>2198</id>
      <parentid>1452</parentid>
      <timestamp>2024-11-29T07:23:25Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <comment>/* Isilululwazi */Reflist</comment>
      <origin>2198</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3042" sha1="hgts07z8wdzwaeyyhmcm7e5nfstzeln" xml:space="preserve">== Umfundaze ==

=== Isingeniso. ===
Ephasini kukhona isizo lelo elenzelwe ukusiza abantu abanganalutho kodwana khube banekghono nanyana isiphiwo sokwenza nanyana sokufunda izinto ezithile. Isizo lelo kungaba kusekelwa ngemmali, iinsetjenziswa nanyana baphiwe ibandulo bameyala nakuthuthukisa begodu nokufeza amabhudango namakghono wabo. Ezinye zesizo lezo mfundaze nanyana umfundasimahla. Esihlokwaneni esilandelako sizokutjheja bonyana kuyini umfundaze nanyana umfundasimahla.

=== Kuyini umfundaze nanyana umfundasimahla? ===
Ngokuya kwe-Wikipedia (2024)&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. ''Bursary''. Itholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Bursary&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [24 kuRhoboyi 2024].&lt;/ref&gt; isekelwa yi-Revolution Media (2024)&lt;ref&gt;Revolution Media. 2024. ''What is a bursary.'' Litholakala ku:&gt;https://revolution.edu.za/what-is-a-bursary-and-how-does-it-differ-from-a-scholarship/&gt;. Lifunyenwe ngomhlaka [24 kuRhoboyi 2024].&lt;/ref&gt;, [https://revolution.edu.za/what-is-a-bursary-and-how-does-it-differ-from-a-scholarship/ umfundaze] kungunongwara nanyana umtlomelo loyo ophiwa iinqema nanyana abantu maziko nanyana iinhlangano zefundo. Iragele phambili, i-Wikipedia (2024&lt;ref name=&quot;:0&quot; /&gt;), yathi, umtlomelo lo uphiwa umfundi bonyana aye esikolweni, eyunivesithi nanyana ekholiji ngesikhathi angakghoni ukuya. Amphuzu la, ayasitjela bona umfundaze usiba abafuna ukufunda kodwana khube babhalelwa ziinthoro zokufunda. Ukungezelela, ihlathululo le inqophe khulu kumaziko nanyana iinhlangano zefundo.


Ngokuya kweYunivesithi i-Nelson Mandela Metropolitan University (2024&lt;ref name=&quot;:1&quot;&gt;Nelson Mandela Metropolitan University. ''What is the difference between a loan, bursary and scholarship? Itholakala ku''''':&lt;'''&lt;nowiki&gt;https://www.mandela.ac.za/Apply/Frequently-asked-questions/Money-Matters/What-is-the-difference-between-a-loan,-bursary-and#FAQLink1769&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [24 kuRhoboyi 2024]&lt;/ref&gt;) ne-Dictionary Cambridge (2024&lt;ref&gt;Cambridge Dictionary. 2024. ''Bursary''. Itholakala ku:&lt; &lt;nowiki&gt;https://dictionary.cambridge.org/dictionary/english/bursary&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [24 kuRhoboyi 2024].&lt;/ref&gt;), [[:en:Bursary|umfundaze]] kulisizo lemali ehlakahlukeneko enikelweko abosofundwakghono nabafundi bonyana bathuthukise iimfunde zabo. Imali ingabuyi kumakhamphani begodu kufanele labo abanikelwa umfundaze lo batlikitliki isibopho neenkhamphani leyo (Yunivesity i-Nelson Mandela 2024&lt;ref name=&quot;:1&quot; /&gt;). Ihlathululo yeYunivesithi i-Nelson Mandela Metropolitan University (2024)&lt;ref name=&quot;:1&quot; /&gt; ingezelel phezu kwehlathululo ye-Wikipedia (2024)&lt;ref name=&quot;:0&quot; /&gt; ngokuthi umfundaze lo unikelwa abafundi nabosofundwakgho.

=== Isiphetho ===
[https://dictionary.cambridge.org/dictionary/english/bursary Umfundaze] kuyimali enikelwa abafundi nabosokghonofundwa yiziko lefundo, ihlangano nekhamphani yangeqadi njengesizo ukuze bathuthukise ifundo yamo namakghono wabo. Imali ingasetjenzisa ukubahdela iimfundo nokuthenga ezinye iinsetjenziswa zokufunda. 

=== Isilululwazi ===
{{Reflist}}</text>
      <sha1>hgts07z8wdzwaeyyhmcm7e5nfstzeln</sha1>
    </revision>
    <revision>
      <id>2988</id>
      <parentid>2198</parentid>
      <timestamp>2025-06-06T20:13:11Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>67kuj5yhgtrf</comment>
      <origin>2988</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3130" sha1="otz3t4624qivc1vu4zm5sbd553wa0kb" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.'''

== Umfundaze ==

=== Isingeniso. ===
Ephasini kukhona isizo lelo elenzelwe ukusiza abantu abanganalutho kodwana khube banekghono nanyana isiphiwo sokwenza nanyana sokufunda izinto ezithile. Isizo lelo kungaba kusekelwa ngemmali, iinsetjenziswa nanyana baphiwe ibandulo bameyala nakuthuthukisa begodu nokufeza amabhudango namakghono wabo. Ezinye zesizo lezo mfundaze nanyana umfundasimahla. Esihlokwaneni esilandelako sizokutjheja bonyana kuyini umfundaze nanyana umfundasimahla.

=== Kuyini umfundaze nanyana umfundasimahla? ===
Ngokuya kwe-Wikipedia (2024)&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. ''Bursary''. Itholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Bursary&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [24 kuRhoboyi 2024].&lt;/ref&gt; isekelwa yi-Revolution Media (2024)&lt;ref&gt;Revolution Media. 2024. ''What is a bursary.'' Litholakala ku:&gt;https://revolution.edu.za/what-is-a-bursary-and-how-does-it-differ-from-a-scholarship/&gt;. Lifunyenwe ngomhlaka [24 kuRhoboyi 2024].&lt;/ref&gt;, [https://revolution.edu.za/what-is-a-bursary-and-how-does-it-differ-from-a-scholarship/ umfundaze] kungunongwara nanyana umtlomelo loyo ophiwa iinqema nanyana abantu maziko nanyana iinhlangano zefundo. Iragele phambili, i-Wikipedia (2024&lt;ref name=&quot;:0&quot; /&gt;), yathi, umtlomelo lo uphiwa umfundi bonyana aye esikolweni, eyunivesithi nanyana ekholiji ngesikhathi angakghoni ukuya. Amphuzu la, ayasitjela bona umfundaze usiba abafuna ukufunda kodwana khube babhalelwa ziinthoro zokufunda. Ukungezelela, ihlathululo le inqophe khulu kumaziko nanyana iinhlangano zefundo.


Ngokuya kweYunivesithi i-Nelson Mandela Metropolitan University (2024&lt;ref name=&quot;:1&quot;&gt;Nelson Mandela Metropolitan University. ''What is the difference between a loan, bursary and scholarship? Itholakala ku''''':&lt;'''&lt;nowiki&gt;https://www.mandela.ac.za/Apply/Frequently-asked-questions/Money-Matters/What-is-the-difference-between-a-loan,-bursary-and#FAQLink1769&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [24 kuRhoboyi 2024]&lt;/ref&gt;) ne-Dictionary Cambridge (2024&lt;ref&gt;Cambridge Dictionary. 2024. ''Bursary''. Itholakala ku:&lt; &lt;nowiki&gt;https://dictionary.cambridge.org/dictionary/english/bursary&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [24 kuRhoboyi 2024].&lt;/ref&gt;), [[:en:Bursary|umfundaze]] kulisizo lemali ehlakahlukeneko enikelweko abosofundwakghono nabafundi bonyana bathuthukise iimfunde zabo. Imali ingabuyi kumakhamphani begodu kufanele labo abanikelwa umfundaze lo batlikitliki isibopho neenkhamphani leyo (Yunivesity i-Nelson Mandela 2024&lt;ref name=&quot;:1&quot; /&gt;). Ihlathululo yeYunivesithi i-Nelson Mandela Metropolitan University (2024)&lt;ref name=&quot;:1&quot; /&gt; ingezelel phezu kwehlathululo ye-Wikipedia (2024)&lt;ref name=&quot;:0&quot; /&gt; ngokuthi umfundaze lo unikelwa abafundi nabosofundwakgho.

=== Isiphetho ===
[https://dictionary.cambridge.org/dictionary/english/bursary Umfundaze] kuyimali enikelwa abafundi nabosokghonofundwa yiziko lefundo, ihlangano nekhamphani yangeqadi njengesizo ukuze bathuthukise ifundo yamo namakghono wabo. Imali ingasetjenzisa ukubahdela iimfundo nokuthenga ezinye iinsetjenziswa zokufunda. 

=== Isilululwazi ===
{{Reflist}}</text>
      <sha1>otz3t4624qivc1vu4zm5sbd553wa0kb</sha1>
    </revision>
    <revision>
      <id>3093</id>
      <parentid>2988</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Simakahle Moselekatse|Simakahle Moselekatse]]</comment>
      <origin>2198</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3042" sha1="hgts07z8wdzwaeyyhmcm7e5nfstzeln" xml:space="preserve">== Umfundaze ==

=== Isingeniso. ===
Ephasini kukhona isizo lelo elenzelwe ukusiza abantu abanganalutho kodwana khube banekghono nanyana isiphiwo sokwenza nanyana sokufunda izinto ezithile. Isizo lelo kungaba kusekelwa ngemmali, iinsetjenziswa nanyana baphiwe ibandulo bameyala nakuthuthukisa begodu nokufeza amabhudango namakghono wabo. Ezinye zesizo lezo mfundaze nanyana umfundasimahla. Esihlokwaneni esilandelako sizokutjheja bonyana kuyini umfundaze nanyana umfundasimahla.

=== Kuyini umfundaze nanyana umfundasimahla? ===
Ngokuya kwe-Wikipedia (2024)&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. ''Bursary''. Itholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Bursary&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [24 kuRhoboyi 2024].&lt;/ref&gt; isekelwa yi-Revolution Media (2024)&lt;ref&gt;Revolution Media. 2024. ''What is a bursary.'' Litholakala ku:&gt;https://revolution.edu.za/what-is-a-bursary-and-how-does-it-differ-from-a-scholarship/&gt;. Lifunyenwe ngomhlaka [24 kuRhoboyi 2024].&lt;/ref&gt;, [https://revolution.edu.za/what-is-a-bursary-and-how-does-it-differ-from-a-scholarship/ umfundaze] kungunongwara nanyana umtlomelo loyo ophiwa iinqema nanyana abantu maziko nanyana iinhlangano zefundo. Iragele phambili, i-Wikipedia (2024&lt;ref name=&quot;:0&quot; /&gt;), yathi, umtlomelo lo uphiwa umfundi bonyana aye esikolweni, eyunivesithi nanyana ekholiji ngesikhathi angakghoni ukuya. Amphuzu la, ayasitjela bona umfundaze usiba abafuna ukufunda kodwana khube babhalelwa ziinthoro zokufunda. Ukungezelela, ihlathululo le inqophe khulu kumaziko nanyana iinhlangano zefundo.


Ngokuya kweYunivesithi i-Nelson Mandela Metropolitan University (2024&lt;ref name=&quot;:1&quot;&gt;Nelson Mandela Metropolitan University. ''What is the difference between a loan, bursary and scholarship? Itholakala ku''''':&lt;'''&lt;nowiki&gt;https://www.mandela.ac.za/Apply/Frequently-asked-questions/Money-Matters/What-is-the-difference-between-a-loan,-bursary-and#FAQLink1769&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [24 kuRhoboyi 2024]&lt;/ref&gt;) ne-Dictionary Cambridge (2024&lt;ref&gt;Cambridge Dictionary. 2024. ''Bursary''. Itholakala ku:&lt; &lt;nowiki&gt;https://dictionary.cambridge.org/dictionary/english/bursary&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [24 kuRhoboyi 2024].&lt;/ref&gt;), [[:en:Bursary|umfundaze]] kulisizo lemali ehlakahlukeneko enikelweko abosofundwakghono nabafundi bonyana bathuthukise iimfunde zabo. Imali ingabuyi kumakhamphani begodu kufanele labo abanikelwa umfundaze lo batlikitliki isibopho neenkhamphani leyo (Yunivesity i-Nelson Mandela 2024&lt;ref name=&quot;:1&quot; /&gt;). Ihlathululo yeYunivesithi i-Nelson Mandela Metropolitan University (2024)&lt;ref name=&quot;:1&quot; /&gt; ingezelel phezu kwehlathululo ye-Wikipedia (2024)&lt;ref name=&quot;:0&quot; /&gt; ngokuthi umfundaze lo unikelwa abafundi nabosofundwakgho.

=== Isiphetho ===
[https://dictionary.cambridge.org/dictionary/english/bursary Umfundaze] kuyimali enikelwa abafundi nabosokghonofundwa yiziko lefundo, ihlangano nekhamphani yangeqadi njengesizo ukuze bathuthukise ifundo yamo namakghono wabo. Imali ingasetjenzisa ukubahdela iimfundo nokuthenga ezinye iinsetjenziswa zokufunda. 

=== Isilululwazi ===
{{Reflist}}</text>
      <sha1>hgts07z8wdzwaeyyhmcm7e5nfstzeln</sha1>
    </revision>
  </page>
  <page>
    <title>Umhluzi</title>
    <ns>0</ns>
    <id>270</id>
    <revision>
      <id>1453</id>
      <timestamp>2024-05-11T06:21:35Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;UMhluzi yilokishi elisentshonalanga yedolobha elikhulu lezolimo nezimboni iMiddelburg esifundazweni saseNingizimu Afrika iMpumalanga.  Inezikole zamabanga aphansi eziyisi-8 neziyisi-6 zamabanga aphezulu.  &quot;</comment>
      <origin>1453</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="205" sha1="n6dcsgzv64n745blurpj4b6s6csa2ln" xml:space="preserve">UMhluzi yilokishi elisentshonalanga yedolobha elikhulu lezolimo nezimboni iMiddelburg esifundazweni saseNingizimu Afrika iMpumalanga.

Inezikole zamabanga aphansi eziyisi-8 neziyisi-6 zamabanga aphezulu.

</text>
      <sha1>n6dcsgzv64n745blurpj4b6s6csa2ln</sha1>
    </revision>
    <revision>
      <id>1454</id>
      <parentid>1453</parentid>
      <timestamp>2024-05-11T06:21:51Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1454</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="211" sha1="d160bft7l1kfyupezt31y0tqyfw4imd" xml:space="preserve">'''UMhluzi''' yilokishi elisentshonalanga yedolobha elikhulu lezolimo nezimboni iMiddelburg esifundazweni saseNingizimu Afrika iMpumalanga.

Inezikole zamabanga aphansi eziyisi-8 neziyisi-6 zamabanga aphezulu.

</text>
      <sha1>d160bft7l1kfyupezt31y0tqyfw4imd</sha1>
    </revision>
    <revision>
      <id>1455</id>
      <parentid>1454</parentid>
      <timestamp>2024-10-14T13:47:42Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>1454</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="211" sha1="d160bft7l1kfyupezt31y0tqyfw4imd" xml:space="preserve">'''UMhluzi''' yilokishi elisentshonalanga yedolobha elikhulu lezolimo nezimboni iMiddelburg esifundazweni saseNingizimu Afrika iMpumalanga.

Inezikole zamabanga aphansi eziyisi-8 neziyisi-6 zamabanga aphezulu.

</text>
      <sha1>d160bft7l1kfyupezt31y0tqyfw4imd</sha1>
    </revision>
  </page>
  <page>
    <title>Umkhakha WezeHlalakuhle</title>
    <ns>0</ns>
    <id>271</id>
    <revision>
      <id>1456</id>
      <timestamp>2024-05-03T11:05:20Z</timestamp>
      <contributor>
        <username>incubator&gt;GladysBhuda</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;Umkhakha WezeHlalakuhle mkhakha omayelana nehlalakuhle yabantu, utjheje godu nekufundiseni abantu ngeendlela abangazitlhogomela, bazivikele ngayo neendlela abangazikhupha ngazo ebudisini bepilo. Ubudisi bepilo obufaka hlangana ukuhlukumezeka kwabomma nabantwana, ukwamukela ukuphila nokukhubazeka, ukungasebenzi nokhunye okunengi.  Abosohlalakuhle emkhakheni lo basebenzisa ilwazi elirhujululiweko elifana namatiyori nelwazi lendabuko yobuntu ukusiza labo abazithola basebudi...&quot;</comment>
      <origin>1456</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="489" sha1="6cqk5ww7xfxjp2j71bsuhep5m0hpdnn" xml:space="preserve">Umkhakha WezeHlalakuhle mkhakha omayelana nehlalakuhle yabantu, utjheje godu nekufundiseni abantu ngeendlela abangazitlhogomela, bazivikele ngayo neendlela abangazikhupha ngazo ebudisini bepilo. Ubudisi bepilo obufaka hlangana ukuhlukumezeka kwabomma nabantwana, ukwamukela ukuphila nokukhubazeka, ukungasebenzi nokhunye okunengi.

Abosohlalakuhle emkhakheni lo basebenzisa ilwazi elirhujululiweko elifana namatiyori nelwazi lendabuko yobuntu ukusiza labo abazithola basebudisini bepilo.

</text>
      <sha1>6cqk5ww7xfxjp2j71bsuhep5m0hpdnn</sha1>
    </revision>
    <revision>
      <id>1457</id>
      <parentid>1456</parentid>
      <timestamp>2024-05-03T11:18:11Z</timestamp>
      <contributor>
        <username>incubator&gt;GladysBhuda</username>
        <id>0</id>
      </contributor>
      <comment>added content</comment>
      <origin>1457</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="947" sha1="njcy9172ajgdvak2fqwjwc901xldoya" xml:space="preserve">Umkhakha WezeHlalakuhle mkhakha omayelana nehlalakuhle yabantu, utjheje godu nekufundiseni abantu ngeendlela abangazitlhogomela, bazivikele ngayo neendlela abangazikhupha ngazo ebudisini bepilo. Ubudisi bepilo obufaka hlangana ukuhlukumezeka kwabomma nabantwana, ukwamukela ukuphila nokukhubazeka, ukungasebenzi nokhunye okunengi.

== Abosohlalakuhle ==
Abosohlalakuhle emkhakheni lo basebenzisa ilwazi elirhujululiweko elifana namatiyori nelwazi lendabuko yobuntu ukusiza labo abazithola basebudisini bepilo.

== Iimfundo zomkhakha lo ==
Nawuzokuba ngusohlalakuhle kufanele uphase kuhle igreyidi 12. Eemfundweni zakho zoke kufanele ufumane amaphuzu angaphezu kwali-30 khona uzokwamukeleka emkhakheni wezefundo ephakamileko. Uzakuthi lokha nawamukelweko ufunde iminyaka emine. Amayunivesithi afundisa iimfundo zehlalakuhle ngila: University of Pretoria, University of Western Cape, University of Joahneesburg, University of Cape Town namanye.   

</text>
      <sha1>njcy9172ajgdvak2fqwjwc901xldoya</sha1>
    </revision>
    <revision>
      <id>1458</id>
      <parentid>1457</parentid>
      <timestamp>2024-05-03T11:19:48Z</timestamp>
      <contributor>
        <username>incubator&gt;GladysBhuda</username>
        <id>0</id>
      </contributor>
      <comment>added a link</comment>
      <origin>1458</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="971" sha1="0eqoxut7qno1ui794ahxzpagxbw060j" xml:space="preserve">Umkhakha WezeHlalakuhle mkhakha omayelana nehlalakuhle yabantu, utjheje godu nekufundiseni abantu ngeendlela abangazitlhogomela, bazivikele ngayo neendlela abangazikhupha ngazo ebudisini bepilo. Ubudisi bepilo obufaka hlangana ukuhlukumezeka kwabomma nabantwana, ukwamukela ukuphila nokukhubazeka, ukungasebenzi nokhunye okunengi.

== Abosohlalakuhle ==
Abosohlalakuhle emkhakheni lo basebenzisa ilwazi elirhujululiweko elifana namatiyori nelwazi lendabuko yobuntu ukusiza labo abazithola basebudisini bepilo.

== Iimfundo zomkhakha lo ==
Nawuzokuba ngusohlalakuhle kufanele uphase kuhle igreyidi 12. Eemfundweni zakho zoke kufanele ufumane amaphuzu angaphezu kwali-30 khona uzokwamukeleka emkhakheni wezefundo ephakamileko. Uzakuthi lokha nawamukelweko ufunde iminyaka emine. Amayunivesithi afundisa iimfundo zehlalakuhle ngila: [https://www.up.ac.za/ University of Pretoria], University of Western Cape, University of Joahneesburg, University of Cape Town namanye.   

</text>
      <sha1>0eqoxut7qno1ui794ahxzpagxbw060j</sha1>
    </revision>
    <revision>
      <id>1459</id>
      <parentid>1458</parentid>
      <timestamp>2024-10-14T13:47:42Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>1458</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="971" sha1="0eqoxut7qno1ui794ahxzpagxbw060j" xml:space="preserve">Umkhakha WezeHlalakuhle mkhakha omayelana nehlalakuhle yabantu, utjheje godu nekufundiseni abantu ngeendlela abangazitlhogomela, bazivikele ngayo neendlela abangazikhupha ngazo ebudisini bepilo. Ubudisi bepilo obufaka hlangana ukuhlukumezeka kwabomma nabantwana, ukwamukela ukuphila nokukhubazeka, ukungasebenzi nokhunye okunengi.

== Abosohlalakuhle ==
Abosohlalakuhle emkhakheni lo basebenzisa ilwazi elirhujululiweko elifana namatiyori nelwazi lendabuko yobuntu ukusiza labo abazithola basebudisini bepilo.

== Iimfundo zomkhakha lo ==
Nawuzokuba ngusohlalakuhle kufanele uphase kuhle igreyidi 12. Eemfundweni zakho zoke kufanele ufumane amaphuzu angaphezu kwali-30 khona uzokwamukeleka emkhakheni wezefundo ephakamileko. Uzakuthi lokha nawamukelweko ufunde iminyaka emine. Amayunivesithi afundisa iimfundo zehlalakuhle ngila: [https://www.up.ac.za/ University of Pretoria], University of Western Cape, University of Joahneesburg, University of Cape Town namanye.   

</text>
      <sha1>0eqoxut7qno1ui794ahxzpagxbw060j</sha1>
    </revision>
  </page>
  <page>
    <title>Umkhawulo nomngcele.</title>
    <ns>0</ns>
    <id>272</id>
    <revision>
      <id>1460</id>
      <timestamp>2024-08-07T05:47:22Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;== Umkhawulo nomngcele. ==  === Iisingeniso === Umkhawulo nomngcele ngezinye zezinto lezo ezisetjenziswa nanyana eziqalwako lokha nakuhlukaniswa izinto ezifana neendawo, isifunda, isiyingi kanye nenarhakazi. Nanyana abanengi bathatha kwangathi umkhawulo nomngcele yinto yinye nje, kodwana akusinjalo zinomehluko omncani. Esigabeni esilandelako sizokutjheja bonyana kuyini umkhawulo nomngcele.  === Khuyini umkhawulo? === Umkhawulo sihlakanisi seendawo, ekufaka hlangana isiyi...&quot;</comment>
      <origin>1460</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1914" sha1="d472ap574ndyi55tk0qaljb9s9ihcb0" xml:space="preserve">== Umkhawulo nomngcele. ==

=== Iisingeniso ===
Umkhawulo nomngcele ngezinye zezinto lezo ezisetjenziswa nanyana eziqalwako lokha nakuhlukaniswa izinto ezifana neendawo, isifunda, isiyingi kanye nenarhakazi. Nanyana abanengi bathatha kwangathi umkhawulo nomngcele yinto yinye nje, kodwana akusinjalo zinomehluko omncani. Esigabeni esilandelako sizokutjheja bonyana kuyini umkhawulo nomngcele.

=== Khuyini umkhawulo? ===
Umkhawulo sihlakanisi seendawo, ekufaka hlangana isiyingi, isifuna neenarha. Umkhawulo uveza ukuthoma nokugcina kweendawo. Kodwana, okuqakatheke khulu kukobana umkhawulo sihlukanisi nanyana isiqunto esenziwe mumuntu ekungasi semvelo. Lokha nasitjheja imikhawulo yeendawo sizakukhumbula bonyana kumikhawulo eyenziwe babantu nanyana ibhodo yemikhawulo leyo equntako ukuthi indawo ethize ithoma kuphi begodu igcina kuphi. 

Igama leli elithi umkhawulo lisuselwe esenzweni khawula, leso esitjho bona lisa, qeda, gcina nanyana yekela into ethize. Ngalokho-ke, umkhuwulo usuke uveza bonyana indawo ethize igcina nanyana iphelela kuphi.

=== Khuyini umngcele? ===
Umncgele singatjho bonyana kusihlukanisi seendawo ezifaka hlangana isiyingi, isifuna, inarha nenarhakazi. Kodwana, umngcele kusihlukanisi nanyana umkhawulo wendabuko nanyana wemvelo. Lokhu kutjho bonyana umngcele awukenziwa mumuntu kodwana uzenzakalele. 

Lokha nasitjheja ilwandle le-Meditterian, sifunyana bona lihlukanisa inarhakazi ye-Afrika neyeYurobhu. Kodwana ekufuzwe kuyelelwe khulu, kukobana ilwandle leli lisihlakanisi semvele hlana kwe-Afrika neYurobhu. Ngakkho-ke, ilwandle i-Meditterian limngcele njengombana lihlakunisa iinarhakazi begodu lezenzakalele ngokwemvelo.

== Isiphetho ==
Umkhawulo nomngcele zinomsebenzi efanako; Kodwana, umehluko kukuthi ukhawulo sihlukanisi nanyana isiqunto esenziwe mumuntu bese kuthi umngcele kube sihlukanisi nanyana isiqunto sendabuko nanyana semvelo ekutjho bonyana asikenziwa mumuntu.</text>
      <sha1>d472ap574ndyi55tk0qaljb9s9ihcb0</sha1>
    </revision>
    <revision>
      <id>1461</id>
      <parentid>1460</parentid>
      <timestamp>2024-09-18T16:07:55Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1461</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1914" sha1="jxjsuzgo37rethd2lqe98af1u3y1rl9" xml:space="preserve">== Umkhawulo nomngcele. ==

=== Isingeniso. ===
Umkhawulo nomngcele ngezinye zezinto lezo ezisetjenziswa nanyana eziqalwako lokha nakuhlukaniswa izinto ezifana neendawo, isifunda, isiyingi kanye nenarhakazi. Nanyana abanengi bathatha kwangathi umkhawulo nomngcele yinto yinye nje, kodwana akusinjalo zinomehluko omncani. Esigabeni esilandelako sizokutjheja bonyana kuyini umkhawulo nomngcele.

=== Khuyini umkhawulo? ===
Umkhawulo sihlakanisi seendawo, ekufaka hlangana isiyingi, isifuna neenarha. Umkhawulo uveza ukuthoma nokugcina kweendawo. Kodwana, okuqakatheke khulu kukobana umkhawulo sihlukanisi nanyana isiqunto esenziwe mumuntu ekungasi semvelo. Lokha nasitjheja imikhawulo yeendawo sizakukhumbula bonyana kumikhawulo eyenziwe babantu nanyana ibhodo yemikhawulo leyo equntako ukuthi indawo ethize ithoma kuphi begodu igcina kuphi. 

Igama leli elithi umkhawulo lisuselwe esenzweni khawula, leso esitjho bona lisa, qeda, gcina nanyana yekela into ethize. Ngalokho-ke, umkhuwulo usuke uveza bonyana indawo ethize igcina nanyana iphelela kuphi.

=== Khuyini umngcele? ===
Umncgele singatjho bonyana kusihlukanisi seendawo ezifaka hlangana isiyingi, isifuna, inarha nenarhakazi. Kodwana, umngcele kusihlukanisi nanyana umkhawulo wendabuko nanyana wemvelo. Lokhu kutjho bonyana umngcele awukenziwa mumuntu kodwana uzenzakalele. 

Lokha nasitjheja ilwandle le-Meditterian, sifunyana bona lihlukanisa inarhakazi ye-Afrika neyeYurobhu. Kodwana ekufuzwe kuyelelwe khulu, kukobana ilwandle leli lisihlakanisi semvele hlana kwe-Afrika neYurobhu. Ngakkho-ke, ilwandle i-Meditterian limngcele njengombana lihlakunisa iinarhakazi begodu lezenzakalele ngokwemvelo.

== Isiphetho ==
Umkhawulo nomngcele zinomsebenzi efanako; Kodwana, umehluko kukuthi ukhawulo sihlukanisi nanyana isiqunto esenziwe mumuntu bese kuthi umngcele kube sihlukanisi nanyana isiqunto sendabuko nanyana semvelo ekutjho bonyana asikenziwa mumuntu.</text>
      <sha1>jxjsuzgo37rethd2lqe98af1u3y1rl9</sha1>
    </revision>
    <revision>
      <id>1462</id>
      <parentid>1461</parentid>
      <timestamp>2024-09-18T16:15:01Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1462</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1915" sha1="9aqr5e8t0ki4woep0ywvoaqa3c95yws" xml:space="preserve">== Umkhawulo nomngcele. ==

=== Isingeniso. ===
Umkhawulo nomngcele ngezinye zezinto lezo ezisetjenziswa nanyana eziqalwako lokha nakuhlukaniswa izinto ezifana neendawo, isifunda, isiyingi kanye nenarhakazi. Nanyana abanengi bathatha kwangathi umkhawulo nomngcele yinto yinye nje, kodwana akusinjalo zinomehluko omncani. Esigabeni esilandelako sizokutjheja bonyana kuyini umkhawulo nomngcele.

=== Khuyini umkhawulo? ===
Umkhawulo sihlakanisi seendawo, ekufaka hlangana isiyingi, isifuna neenarha. Umkhawulo uveza ukuthoma nokugcina kweendawo. Kodwana, okuqakatheke khulu kukobana umkhawulo sihlukanisi nanyana isiqunto esenziwe mumuntu ekungasi semvelo. Lokha nasitjheja imikhawulo yeendawo sizakukhumbula bonyana kumikhawulo eyenziwe babantu nanyana ibhodo yemikhawulo leyo equntako ukuthi indawo ethize ithoma kuphi begodu igcina kuphi. 

Igama leli elithi umkhawulo lisuselwe esenzweni khawula, leso esitjho bona lisa, qeda, gcina nanyana yekela into ethize. Ngalokho-ke, umkhuwulo usuke uveza bonyana indawo ethize igcina nanyana iphelela kuphi.

=== Khuyini umngcele? ===
Umncgele singatjho bonyana kusihlukanisi seendawo ezifaka hlangana isiyingi, isifuna, inarha nenarhakazi. Kodwana, umngcele kusihlukanisi nanyana umkhawulo wendabuko nanyana wemvelo. Lokhu kutjho bonyana umngcele awukenziwa mumuntu kodwana uzenzakalele. 

Lokha nasitjheja ilwandle le-Meditterian, sifunyana bona lihlukanisa inarhakazi ye-Afrika neyeYurobhu. Kodwana ekufuzwe kuyelelwe khulu, kukobana ilwandle leli lisihlakanisi semvele hlana kwe-Afrika neYurobhu. Ngakkho-ke, ilwandle i-Meditterian limngcele njengombana lihlakunisa iinarhakazi begodu lezenzakalele ngokwemvelo.

== Isiphetho. ==
Umkhawulo nomngcele zinomsebenzi efanako; Kodwana, umehluko kukuthi ukhawulo sihlukanisi nanyana isiqunto esenziwe mumuntu bese kuthi umngcele kube sihlukanisi nanyana isiqunto sendabuko nanyana semvelo ekutjho bonyana asikenziwa mumuntu.</text>
      <sha1>9aqr5e8t0ki4woep0ywvoaqa3c95yws</sha1>
    </revision>
    <revision>
      <id>1463</id>
      <parentid>1462</parentid>
      <timestamp>2024-10-14T13:47:42Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>1462</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1915" sha1="9aqr5e8t0ki4woep0ywvoaqa3c95yws" xml:space="preserve">== Umkhawulo nomngcele. ==

=== Isingeniso. ===
Umkhawulo nomngcele ngezinye zezinto lezo ezisetjenziswa nanyana eziqalwako lokha nakuhlukaniswa izinto ezifana neendawo, isifunda, isiyingi kanye nenarhakazi. Nanyana abanengi bathatha kwangathi umkhawulo nomngcele yinto yinye nje, kodwana akusinjalo zinomehluko omncani. Esigabeni esilandelako sizokutjheja bonyana kuyini umkhawulo nomngcele.

=== Khuyini umkhawulo? ===
Umkhawulo sihlakanisi seendawo, ekufaka hlangana isiyingi, isifuna neenarha. Umkhawulo uveza ukuthoma nokugcina kweendawo. Kodwana, okuqakatheke khulu kukobana umkhawulo sihlukanisi nanyana isiqunto esenziwe mumuntu ekungasi semvelo. Lokha nasitjheja imikhawulo yeendawo sizakukhumbula bonyana kumikhawulo eyenziwe babantu nanyana ibhodo yemikhawulo leyo equntako ukuthi indawo ethize ithoma kuphi begodu igcina kuphi. 

Igama leli elithi umkhawulo lisuselwe esenzweni khawula, leso esitjho bona lisa, qeda, gcina nanyana yekela into ethize. Ngalokho-ke, umkhuwulo usuke uveza bonyana indawo ethize igcina nanyana iphelela kuphi.

=== Khuyini umngcele? ===
Umncgele singatjho bonyana kusihlukanisi seendawo ezifaka hlangana isiyingi, isifuna, inarha nenarhakazi. Kodwana, umngcele kusihlukanisi nanyana umkhawulo wendabuko nanyana wemvelo. Lokhu kutjho bonyana umngcele awukenziwa mumuntu kodwana uzenzakalele. 

Lokha nasitjheja ilwandle le-Meditterian, sifunyana bona lihlukanisa inarhakazi ye-Afrika neyeYurobhu. Kodwana ekufuzwe kuyelelwe khulu, kukobana ilwandle leli lisihlakanisi semvele hlana kwe-Afrika neYurobhu. Ngakkho-ke, ilwandle i-Meditterian limngcele njengombana lihlakunisa iinarhakazi begodu lezenzakalele ngokwemvelo.

== Isiphetho. ==
Umkhawulo nomngcele zinomsebenzi efanako; Kodwana, umehluko kukuthi ukhawulo sihlukanisi nanyana isiqunto esenziwe mumuntu bese kuthi umngcele kube sihlukanisi nanyana isiqunto sendabuko nanyana semvelo ekutjho bonyana asikenziwa mumuntu.</text>
      <sha1>9aqr5e8t0ki4woep0ywvoaqa3c95yws</sha1>
    </revision>
  </page>
  <page>
    <title>Umlando waMandebele</title>
    <ns>0</ns>
    <id>273</id>
    <revision>
      <id>1464</id>
      <timestamp>2016-02-20T16:52:23Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''The South Ndebele''' people found in the former Transvaal today consists mainly of two tribes, namely, abakwaManala (the Manala Ndebele) and abakwaNdzundza (the Ndzundza Nd...&quot;</comment>
      <origin>1464</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4734" sha1="cpwj4himghqtq8hyn5iqkx8hs5ifnpw" xml:space="preserve">'''The South Ndebele''' people found in the former Transvaal today consists mainly of two tribes, namely, abakwaManala (the Manala Ndebele) and abakwaNdzundza (the Ndzundza Ndebele). the history of the Ndebele people can be traced back to Mafana, their first identifiable chief. Mafana’s successor, Mhlanga, had a son named Musi who, in the early 1600’s, decided to move away from his cousins (later to become the mighty Zulu nation) and to settle in the hills of Gauteng near where the capital, Pretoria is situated. Historically, KwaMnyamana is the most important settlement area of the (ama) Ndebele of the Republic of South Africa, because it is the place where the (ama)Ndebele split into two main groups and numerous smaller sub-groups.

== 1600 - 1880 ==
When Musi died in 1630, the succession struggle ensued between two of his sons, namely Manala and Nzunza, and the tribe split into the Southern and Northern (ama)Ndebele, respectively, as well as other smaller tribes. The Southern (ama)Ndebele comprised the followers of Manala and Nzunza while the Northern (ama)Ndebele consists the followers of Mthombeni. Together with his brother, Nzunza, Mthombeni left KwaMnyamana until at KwaSimkhulu, north of Belfast in the present Mpumalanga Province. It is at KwaSimkhulu where Mthombeni, the founder of the Northern (ama)Ndebele, parted ways with Nzunza and strategically moved northwards along the Olifant until he reached his present place of abode, around Zebediela. On his way northwards, Mthombeni inherited a new name known as Gegana (or Kekana) and his followers were referred to as the ‘people of Gegana (or Kekana)’ instead of remaining the‘people of Mthombeni’.

Ngesikhathi kwaMaza kubusa ikosi uMagodongo, kwafika uMztlikazi abaleke kwaZulu ngestmanga sezipi zakaShaka. UMzilikazi wafika wasahlela uMagodongo nesitjhaba sakhe. Uthe bona abulale uMagodongo uMzilikazi, wathumba ifuyo nabafazi wanyuka nenarha watjhinga eTlhagwini, waze wayokunzinza eRhodesia esele yaziwa ngeZimbabwe namhlanje. UMzilikazi wathi nakasahlela uMagodongo kwabe sele adlule ngakuManala, abulele uStbindi. (Skhosana, 1996, 8)

In 1883, during the reign of the Ndebele chief Mabhogo (whom the Boers refer to as Mapoch), war broke out between the Ndzundza and the Voortrekker settlers (Boer) of Zuid-Afrikaansche Republiek (South African Republic) over land and other resources. The Boer leader Piet Joubert led a campaign against the Ndebele leader and his people. For eight months, the Ndebele held out against the onslaught by hiding in subterranean tunnels in their mountain stronghold at Mapoch’s Caves near the town of Roossenekal. From time to time, Mabhogo’s brave warriors crept past the enemy lines undetected to fetch water and food. However, after two women of the tribe had been ambushed in the nearby woods and tortured, one revealed the Mabhogo’s whereabouts. After Mabhogo’s defeat, the cohesive tribal structure was broken up and the tribal lands confiscated. Despite the disintegration of the tribe, the Ndebele retained their cultural unity.

==1880 - 1994==
Ndebele wars continued under Chief Nyabela. Ndzundza lost their independence, their land was expropriated, the leaders were imprisoned (Chief Nyabela to life imprisonment), and all the Ndebele were scattered as indentured laborers for a five-year (1883-1888) period among White farmers. The Manala chiefdom was not involved in the war and had previously (1873) settled on land provided by the Berlin Mission, some 30 kilometers north of Pretoria, at a place the Manala named KoMjekejeke (Wallmannsthal).

Chief Nyabela Mahlangu was released after the Anglo-Boer War (1899-1902) in 1903 and died soon afterward. His successor tried fruitlessly in 1916 and 1918 to regain their tribal land. Instead, the royal house and a growing number of followers privately bought land in 1922, around which the Ndzundza-Ndebele reassembled. Within the framework of the bantustan or homeland system in South Africa, the Ndebele (both Manala and Ndzundza) were only allowed to settle in a homeland called KwaNdebele in 1979.

== Umlando womlomo ==
The oral version among the Africans explained why Ndebele became Matebele by stating that the name Matebele comes from Sotho words &quot;mathebe telele&quot;, meaning &quot;carriers of long shields&quot;. It is only Shaka's warriors who are known to have carried long shields. This idea of long shields is said to be Shaka's own, and no other king before Shaka is known to have employed this type of war armoury. When the Sotho people saw these long shields for the first time, to them it was just a queer sight. Because of the fact that it is not easy to pronounce &quot;mathebe telele&quot; in a fast speech, one ends up saying &quot;matebele'.</text>
      <sha1>cpwj4himghqtq8hyn5iqkx8hs5ifnpw</sha1>
    </revision>
    <revision>
      <id>1465</id>
      <parentid>1464</parentid>
      <timestamp>2016-02-20T16:52:57Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* 1600 - 1880 */</comment>
      <origin>1465</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4735" sha1="97df65k6kc0rqa2mhk35bsp6alejnrx" xml:space="preserve">'''The South Ndebele''' people found in the former Transvaal today consists mainly of two tribes, namely, abakwaManala (the Manala Ndebele) and abakwaNdzundza (the Ndzundza Ndebele). the history of the Ndebele people can be traced back to Mafana, their first identifiable chief. Mafana’s successor, Mhlanga, had a son named Musi who, in the early 1600’s, decided to move away from his cousins (later to become the mighty Zulu nation) and to settle in the hills of Gauteng near where the capital, Pretoria is situated. Historically, KwaMnyamana is the most important settlement area of the (ama) Ndebele of the Republic of South Africa, because it is the place where the (ama)Ndebele split into two main groups and numerous smaller sub-groups.

== 1600 - 1880 ==
When Musi died in 1630, the succession struggle ensued between two of his sons, namely Manala and Nzunza, and the tribe split into the Southern and Northern (ama)Ndebele, respectively, as well as other smaller tribes. The Southern (ama)Ndebele comprised the followers of Manala and Nzunza while the Northern (ama)Ndebele consists the followers of Mthombeni. Together with his brother, Nzunza, Mthombeni left KwaMnyamana until at KwaSimkhulu, north of Belfast in the present Mpumalanga Province. It is at KwaSimkhulu where Mthombeni, the founder of the Northern (ama)Ndebele, parted ways with Nzunza and strategically moved northwards along the Olifant until he reached his present place of abode, around Zebediela. On his way northwards, Mthombeni inherited a new name known as Gegana (or Kekana) and his followers were referred to as the ‘people of Gegana (or Kekana)’ instead of remaining the‘people of Mthombeni’.

 Ngesikhathi kwaMaza kubusa ikosi uMagodongo, kwafika uMztlikazi abaleke kwaZulu ngestmanga sezipi zakaShaka. UMzilikazi wafika wasahlela uMagodongo nesitjhaba sakhe. Uthe bona abulale uMagodongo uMzilikazi, wathumba ifuyo nabafazi wanyuka nenarha watjhinga eTlhagwini, waze wayokunzinza eRhodesia esele yaziwa ngeZimbabwe namhlanje. UMzilikazi wathi nakasahlela uMagodongo kwabe sele adlule ngakuManala, abulele uStbindi. (Skhosana, 1996, 8)

In 1883, during the reign of the Ndebele chief Mabhogo (whom the Boers refer to as Mapoch), war broke out between the Ndzundza and the Voortrekker settlers (Boer) of Zuid-Afrikaansche Republiek (South African Republic) over land and other resources. The Boer leader Piet Joubert led a campaign against the Ndebele leader and his people. For eight months, the Ndebele held out against the onslaught by hiding in subterranean tunnels in their mountain stronghold at Mapoch’s Caves near the town of Roossenekal. From time to time, Mabhogo’s brave warriors crept past the enemy lines undetected to fetch water and food. However, after two women of the tribe had been ambushed in the nearby woods and tortured, one revealed the Mabhogo’s whereabouts. After Mabhogo’s defeat, the cohesive tribal structure was broken up and the tribal lands confiscated. Despite the disintegration of the tribe, the Ndebele retained their cultural unity.

==1880 - 1994==
Ndebele wars continued under Chief Nyabela. Ndzundza lost their independence, their land was expropriated, the leaders were imprisoned (Chief Nyabela to life imprisonment), and all the Ndebele were scattered as indentured laborers for a five-year (1883-1888) period among White farmers. The Manala chiefdom was not involved in the war and had previously (1873) settled on land provided by the Berlin Mission, some 30 kilometers north of Pretoria, at a place the Manala named KoMjekejeke (Wallmannsthal).

Chief Nyabela Mahlangu was released after the Anglo-Boer War (1899-1902) in 1903 and died soon afterward. His successor tried fruitlessly in 1916 and 1918 to regain their tribal land. Instead, the royal house and a growing number of followers privately bought land in 1922, around which the Ndzundza-Ndebele reassembled. Within the framework of the bantustan or homeland system in South Africa, the Ndebele (both Manala and Ndzundza) were only allowed to settle in a homeland called KwaNdebele in 1979.

== Umlando womlomo ==
The oral version among the Africans explained why Ndebele became Matebele by stating that the name Matebele comes from Sotho words &quot;mathebe telele&quot;, meaning &quot;carriers of long shields&quot;. It is only Shaka's warriors who are known to have carried long shields. This idea of long shields is said to be Shaka's own, and no other king before Shaka is known to have employed this type of war armoury. When the Sotho people saw these long shields for the first time, to them it was just a queer sight. Because of the fact that it is not easy to pronounce &quot;mathebe telele&quot; in a fast speech, one ends up saying &quot;matebele'.</text>
      <sha1>97df65k6kc0rqa2mhk35bsp6alejnrx</sha1>
    </revision>
    <revision>
      <id>1466</id>
      <parentid>1465</parentid>
      <timestamp>2016-02-20T16:56:34Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1466</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4737" sha1="s5am3isc3m75jygg1m6yeggzaj9r0pr" xml:space="preserve">'''The South Ndebele''' people found in the former Transvaal today consists mainly of two tribes, namely, abakwaManala (the Manala Ndebele) and abakwaNdzundza (the Ndzundza Ndebele). the history of the Ndebele people can be traced back to Mafana, their first identifiable chief. Mafana’s successor, Mhlanga, had a son named Musi who, in the early 1600’s, decided to move away from his cousins (later to become the mighty Zulu nation) and to settle in the hills of Gauteng near where the capital, Pretoria is situated. Historically, KwaMnyamana is the most important settlement area of the (ama) Ndebele of the Republic of South Africa, because it is the place where the (ama)Ndebele split into two main groups and numerous smaller sub-groups.

== 1600 - 1880 ==
When Musi died in 1630, the succession struggle ensued between two of his sons, namely Manala and Nzunza, and the tribe split into the Southern and Northern (ama)Ndebele, respectively, as well as other smaller tribes. The Southern (ama)Ndebele comprised the followers of Manala and Nzunza while the Northern (ama)Ndebele consists the followers of Mthombeni. Together with his brother, Nzunza, Mthombeni left KwaMnyamana until at KwaSimkhulu, north of Belfast in the present Mpumalanga Province. It is at KwaSimkhulu where Mthombeni, the founder of the Northern (ama)Ndebele, parted ways with Nzunza and strategically moved northwards along the Olifant until he reached his present place of abode, around Zebediela. On his way northwards, Mthombeni inherited a new name known as Gegana (or Kekana) and his followers were referred to as the ‘people of Gegana (or Kekana)’ instead of remaining the‘people of Mthombeni’.

 Ngesikhathi kwaMaza kubusa ikosi uMagodongo, kwafika uMztlikazi abaleke kwaZulu ngestmanga sezipi zakaShaka. UMzilikazi wafika wasahlela uMagodongo nesitjhaba sakhe. Uthe bona abulale uMagodongo uMzilikazi, wathumba ifuyo nabafazi wanyuka nenarha watjhinga eTlhagwini, waze wayokunzinza eRhodesia esele yaziwa ngeZimbabwe namhlanje. UMzilikazi wathi nakasahlela uMagodongo kwabe sele adlule ngakuManala, abulele uStbindi. (Skhosana, 1996, 8)

In 1883, during the reign of the Ndebele chief Mabhogo (whom the Boers refer to as Mapoch), war broke out between the Ndzundza and the Voortrekker settlers (Boer) of Zuid-Afrikaansche Republiek (South African Republic) over land and other resources. The Boer leader Piet Joubert led a campaign against the Ndebele leader and his people. For eight months, the Ndebele held out against the onslaught by hiding in subterranean tunnels in their mountain stronghold at Mapoch’s Caves near the town of Roossenekal. From time to time, Mabhogo’s brave warriors crept past the enemy lines undetected to fetch water and food. However, after two women of the tribe had been ambushed in the nearby woods and tortured, one revealed the Mabhogo’s whereabouts. After Mabhogo’s defeat, the cohesive tribal structure was broken up and the tribal lands confiscated. Despite the disintegration of the tribe, the Ndebele retained their cultural unity.

==1880 - 1994==
Ndebele wars continued under Chief Nyabela. Ndzundza lost their independence, their land was expropriated, the leaders were imprisoned (Chief Nyabela to life imprisonment), and all the Ndebele were scattered as indentured laborers for a five-year (1883-1888) period among White farmers. The Manala chiefdom was not involved in the war and had previously (1873) settled on land provided by the Berlin Mission, some 30 kilometers north of Pretoria, at a place the Manala named KoMjekejeke (Wallmannsthal).

Chief Nyabela Mahlangu was released after the Anglo-Boer War (1899-1902) in 1903 and died soon afterward. His successor tried fruitlessly in 1916 and 1918 to regain their tribal land. Instead, the royal house and a growing number of followers privately bought land in 1922, around which the Ndzundza-Ndebele reassembled. Within the framework of the bantustan or homeland system in South Africa, the Ndebele (both Manala and Ndzundza) were only allowed to settle in a homeland called KwaNdebele in 1979.

== Umlando womlomo ==
The oral version among the Africans explained why Ndebele became Matebele by stating that the name Matebele comes from Sotho words &quot;mathebe telele&quot;, meaning &quot;carriers of long shields&quot;. It is only Shaka's warriors who are known to have carried long shields. This idea of long shields is said to be Shaka's own, and no other king before Shaka is known to have employed this type of war armoury. When the Sotho people saw these long shields for the first time, to them it was just a queer sight. Because of the fact that it is not easy to pronounce &quot;mathebe telele&quot; in a fast speech, one ends up saying &quot;matebele'.

</text>
      <sha1>s5am3isc3m75jygg1m6yeggzaj9r0pr</sha1>
    </revision>
    <revision>
      <id>1467</id>
      <parentid>1466</parentid>
      <timestamp>2016-02-25T18:52:19Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1467</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5130" sha1="pznuk5qsszl1zh0x3sz1hrwl47cw1ki" xml:space="preserve">{{Ethnic group
|Ubutjhaba = AbaNdebele
|isithombe = Ndebele-women-loopspruit.jpg
|umtlolo   = Abomma base Loopspruit Cultural Village, ngase[[Bronkhorstspruit, Gauteng|Bronkhorstspruit]]
|Ubuningi  = 1.1 million (2011 Census)
|Amaphrovinci = [[Mpumalanga]], [[Gauteng]] ne [[Limpopo Province]]
|Amalimi   = IsiNdebele
|Ikolo     = [[Isikreste]], [[Amasiko]]
|Bahlobane = [[Nguni|AbaNguni]]
}}
'''The South Ndebele''' people found in the former Transvaal today consists mainly of two tribes, namely, abakwaManala (the Manala Ndebele) and abakwaNdzundza (the Ndzundza Ndebele). the history of the Ndebele people can be traced back to Mafana, their first identifiable chief. Mafana’s successor, Mhlanga, had a son named Musi who, in the early 1600’s, decided to move away from his cousins (later to become the mighty Zulu nation) and to settle in the hills of Gauteng near where the capital, Pretoria is situated. Historically, KwaMnyamana is the most important settlement area of the (ama) Ndebele of the Republic of South Africa, because it is the place where the (ama)Ndebele split into two main groups and numerous smaller sub-groups.

== 1600 - 1880 ==
When Musi died in 1630, the succession struggle ensued between two of his sons, namely Manala and Nzunza, and the tribe split into the Southern and Northern (ama)Ndebele, respectively, as well as other smaller tribes. The Southern (ama)Ndebele comprised the followers of Manala and Nzunza while the Northern (ama)Ndebele consists the followers of Mthombeni. Together with his brother, Nzunza, Mthombeni left KwaMnyamana until at KwaSimkhulu, north of Belfast in the present Mpumalanga Province. It is at KwaSimkhulu where Mthombeni, the founder of the Northern (ama)Ndebele, parted ways with Nzunza and strategically moved northwards along the Olifant until he reached his present place of abode, around Zebediela. On his way northwards, Mthombeni inherited a new name known as Gegana (or Kekana) and his followers were referred to as the ‘people of Gegana (or Kekana)’ instead of remaining the‘people of Mthombeni’.

 Ngesikhathi kwaMaza kubusa ikosi uMagodongo, kwafika uMztlikazi abaleke kwaZulu ngestmanga sezipi zakaShaka. UMzilikazi wafika wasahlela uMagodongo nesitjhaba sakhe. Uthe bona abulale uMagodongo uMzilikazi, wathumba ifuyo nabafazi wanyuka nenarha watjhinga eTlhagwini, waze wayokunzinza eRhodesia esele yaziwa ngeZimbabwe namhlanje. UMzilikazi wathi nakasahlela uMagodongo kwabe sele adlule ngakuManala, abulele uStbindi. (Skhosana, 1996, 8)

In 1883, during the reign of the Ndebele chief Mabhogo (whom the Boers refer to as Mapoch), war broke out between the Ndzundza and the Voortrekker settlers (Boer) of Zuid-Afrikaansche Republiek (South African Republic) over land and other resources. The Boer leader Piet Joubert led a campaign against the Ndebele leader and his people. For eight months, the Ndebele held out against the onslaught by hiding in subterranean tunnels in their mountain stronghold at Mapoch’s Caves near the town of Roossenekal. From time to time, Mabhogo’s brave warriors crept past the enemy lines undetected to fetch water and food. However, after two women of the tribe had been ambushed in the nearby woods and tortured, one revealed the Mabhogo’s whereabouts. After Mabhogo’s defeat, the cohesive tribal structure was broken up and the tribal lands confiscated. Despite the disintegration of the tribe, the Ndebele retained their cultural unity.

==1880 - 1994==
Ndebele wars continued under Chief Nyabela. Ndzundza lost their independence, their land was expropriated, the leaders were imprisoned (Chief Nyabela to life imprisonment), and all the Ndebele were scattered as indentured laborers for a five-year (1883-1888) period among White farmers. The Manala chiefdom was not involved in the war and had previously (1873) settled on land provided by the Berlin Mission, some 30 kilometers north of Pretoria, at a place the Manala named KoMjekejeke (Wallmannsthal).

Chief Nyabela Mahlangu was released after the Anglo-Boer War (1899-1902) in 1903 and died soon afterward. His successor tried fruitlessly in 1916 and 1918 to regain their tribal land. Instead, the royal house and a growing number of followers privately bought land in 1922, around which the Ndzundza-Ndebele reassembled. Within the framework of the bantustan or homeland system in South Africa, the Ndebele (both Manala and Ndzundza) were only allowed to settle in a homeland called KwaNdebele in 1979.

== Umlando womlomo ==
The oral version among the Africans explained why Ndebele became Matebele by stating that the name Matebele comes from Sotho words &quot;mathebe telele&quot;, meaning &quot;carriers of long shields&quot;. It is only Shaka's warriors who are known to have carried long shields. This idea of long shields is said to be Shaka's own, and no other king before Shaka is known to have employed this type of war armoury. When the Sotho people saw these long shields for the first time, to them it was just a queer sight. Because of the fact that it is not easy to pronounce &quot;mathebe telele&quot; in a fast speech, one ends up saying &quot;matebele'.

</text>
      <sha1>pznuk5qsszl1zh0x3sz1hrwl47cw1ki</sha1>
    </revision>
    <revision>
      <id>1468</id>
      <parentid>1467</parentid>
      <timestamp>2016-02-25T19:54:32Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1468</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4489" sha1="083oywoipk4yezl0sm2qqt4rth88llw" xml:space="preserve">{{Ethnic group
|Ubutjhaba = AbaNdebele
|isithombe = Ndebele-women-loopspruit.jpg
|umtlolo   = Abomma base Loopspruit Cultural Village, ngase[[Bronkhorstspruit, Gauteng|Bronkhorstspruit]]
|Ubuningi  = 1.1 million (2011 Census)
|Amaphrovinci = [[Mpumalanga]], [[Gauteng]] ne [[Limpopo Province]]
|Amalimi   = IsiNdebele
|Ikolo     = [[Isikreste]], [[Amasiko]]
|Bahlobane = [[Nguni|AbaNguni]]
}}
'''Abandebele&quot; namkha Abandebele besewula, isitjhaba sabantu beSewula Afrika. Isitjhaba le sihlukaniswa ngeeqhema embili, ekinga bakwaManala begodu nabakwaNdzundza. Umlando wamandebele uthoma ngekosi uMafana. Ikosi umafana walandelwa nguMhlanga owabeletha uMusi. Ikosi Umusa yathatha igandango bonyana akhambe achiye abachana bakhe oyekuhlala Kwamnyamana ngase Rhawuteni. Khonapho isitjhaba sahlukana phakathi ngabakwaManala begodu nabakwaNdzundza.

== Umlando: 1600 - 1880 ==
Ngesikhathi ikosi uMusi a thlogakala ngonyaka ka 1630, kwavuka umraro wokulwela ubukosi ebatwaneni bakhe uManala no Nzunza. Lomraro wahlukanisa isitjhaba samandebele esewula (AbakwaManala) namandebele etlhagwini (abakwaNdzundza nabakwaMthombeni). Unzuza noMthombeni bakhamba beya ngase Pumalanga batjhinga bakha KwaSimkhulu, etlhagwini leBelfast ngase Pumalanga. Kodwana uMthombeni waragela phambili wanyuka nenarha ngomlambu we Olifant waya ngase tlhagwini begodu wakha ngase Zebediela eLipompo. Umthombeni wathoma wabizwa ngokuthi nguGegana (namkha uKekana).

 Ngesikhathi kwaMaza kubusa ikosi uMagodongo, kwafika uMzlikazi abaleke kwaZulu ngestanga sezipi zakaShaka. UMzilikazi wafika wasahlela uMagodongo nesitjhaba sakhe. Uthe bona abulale uMagodongo uMzilikazi, wathumba ifuyo nabafazi wanyuka nenarha watjhinga eTlhagwini, waze wayokunzinza eRhodesia esele yaziwa ngeZimbabwe namhlanje. UMzilikazi wathi nakasahlela uMagodongo kwabe sele adlule ngakuManala, abulele uStbindi. --(Skhosana, 1996, 8)

''In 1883, during the reign of the Ndebele chief Mabhogo (whom the Boers refer to as Mapoch), war broke out between the Ndzundza and the Voortrekker settlers (Boer) of Zuid-Afrikaansche Republiek (South African Republic) over land and other resources. The Boer leader Piet Joubert led a campaign against the Ndebele leader and his people. For eight months, the Ndebele held out against the onslaught by hiding in subterranean tunnels in their mountain stronghold at Mapoch’s Caves near the town of Roossenekal. From time to time, Mabhogo’s brave warriors crept past the enemy lines undetected to fetch water and food. However, after two women of the tribe had been ambushed in the nearby woods and tortured, one revealed the Mabhogo’s whereabouts. After Mabhogo’s defeat, the cohesive tribal structure was broken up and the tribal lands confiscated. Despite the disintegration of the tribe, the Ndebele retained their cultural unity.''

==1880 - 1994==
''Ndebele wars continued under Chief Nyabela. Ndzundza lost their independence, their land was expropriated, the leaders were imprisoned (Chief Nyabela to life imprisonment), and all the Ndebele were scattered as indentured laborers for a five-year (1883-1888) period among White farmers. The Manala chiefdom was not involved in the war and had previously (1873) settled on land provided by the Berlin Mission, some 30 kilometers north of Pretoria, at a place the Manala named KoMjekejeke (Wallmannsthal).

Chief Nyabela Mahlangu was released after the Anglo-Boer War (1899-1902) in 1903 and died soon afterward. His successor tried fruitlessly in 1916 and 1918 to regain their tribal land. Instead, the royal house and a growing number of followers privately bought land in 1922, around which the Ndzundza-Ndebele reassembled. Within the framework of the bantustan or homeland system in South Africa, the Ndebele (both Manala and Ndzundza) were only allowed to settle in a homeland called KwaNdebele in 1979.''

== Umlando womlomo ==
''The oral version among the Africans explained why Ndebele became Matebele by stating that the name Matebele comes from Sotho words &quot;mathebe telele&quot;, meaning &quot;carriers of long shields&quot;. It is only Shaka's warriors who are known to have carried long shields. This idea of long shields is said to be Shaka's own, and no other king before Shaka is known to have employed this type of war armoury. When the Sotho people saw these long shields for the first time, to them it was just a queer sight. Because of the fact that it is not easy to pronounce &quot;mathebe telele&quot; in a fast speech, one ends up saying &quot;matebele'.''

</text>
      <sha1>083oywoipk4yezl0sm2qqt4rth88llw</sha1>
    </revision>
    <revision>
      <id>1469</id>
      <parentid>1468</parentid>
      <timestamp>2016-02-25T19:55:00Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1469</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4491" sha1="ruo9jo6sxtneuv9o93fvch460fjvjtp" xml:space="preserve">{{Ethnic group
|Ubutjhaba = AbaNdebele
|isithombe = Ndebele-women-loopspruit.jpg
|umtlolo   = Abomma base Loopspruit Cultural Village, ngase[[Bronkhorstspruit, Gauteng|Bronkhorstspruit]]
|Ubuningi  = 1.1 million (2011 Census)
|Amaphrovinci = [[Mpumalanga]], [[Gauteng]] ne [[Limpopo Province]]
|Amalimi   = IsiNdebele
|Ikolo     = [[Isikreste]], [[Amasiko]]
|Bahlobane = [[Nguni|AbaNguni]]
}}
'''Abandebele''' namkha Abandebele besewula, isitjhaba sabantu beSewula Afrika. Isitjhaba le sihlukaniswa ngeeqhema embili, ekinga bakwaManala begodu nabakwaNdzundza. Umlando wamandebele uthoma ngekosi uMafana. Ikosi umafana walandelwa nguMhlanga owabeletha uMusi. Ikosi Umusa yathatha igandango bonyana akhambe achiye abachana bakhe oyekuhlala Kwamnyamana ngase Rhawuteni. Khonapho isitjhaba sahlukana phakathi ngabakwaManala begodu nabakwaNdzundza.

== Umlando: 1600 - 1880 ==
Ngesikhathi ikosi uMusi a thlogakala ngonyaka ka 1630, kwavuka umraro wokulwela ubukosi ebatwaneni bakhe uManala no Nzunza. Lomraro wahlukanisa isitjhaba samandebele esewula (AbakwaManala) namandebele etlhagwini (abakwaNdzundza nabakwaMthombeni). Unzuza noMthombeni bakhamba beya ngase Pumalanga batjhinga bakha KwaSimkhulu, etlhagwini leBelfast ngase Pumalanga. Kodwana uMthombeni waragela phambili wanyuka nenarha ngomlambu we Olifant waya ngase tlhagwini begodu wakha ngase Zebediela eLipompo. Umthombeni wathoma wabizwa ngokuthi nguGegana (namkha uKekana).

 Ngesikhathi kwaMaza kubusa ikosi uMagodongo, kwafika uMzlikazi abaleke kwaZulu ngestanga sezipi zakaShaka. UMzilikazi wafika wasahlela uMagodongo nesitjhaba sakhe. Uthe bona abulale uMagodongo uMzilikazi, wathumba ifuyo nabafazi wanyuka nenarha watjhinga eTlhagwini, waze wayokunzinza eRhodesia esele yaziwa ngeZimbabwe namhlanje. UMzilikazi wathi nakasahlela uMagodongo kwabe sele adlule ngakuManala, abulele uStbindi. --(Skhosana, 1996, 8)

''In 1883, during the reign of the Ndebele chief Mabhogo (whom the Boers refer to as Mapoch), war broke out between the Ndzundza and the Voortrekker settlers (Boer) of Zuid-Afrikaansche Republiek (South African Republic) over land and other resources. The Boer leader Piet Joubert led a campaign against the Ndebele leader and his people. For eight months, the Ndebele held out against the onslaught by hiding in subterranean tunnels in their mountain stronghold at Mapoch’s Caves near the town of Roossenekal. From time to time, Mabhogo’s brave warriors crept past the enemy lines undetected to fetch water and food. However, after two women of the tribe had been ambushed in the nearby woods and tortured, one revealed the Mabhogo’s whereabouts. After Mabhogo’s defeat, the cohesive tribal structure was broken up and the tribal lands confiscated. Despite the disintegration of the tribe, the Ndebele retained their cultural unity.''

==1880 - 1994==
''Ndebele wars continued under Chief Nyabela. Ndzundza lost their independence, their land was expropriated, the leaders were imprisoned (Chief Nyabela to life imprisonment), and all the Ndebele were scattered as indentured laborers for a five-year (1883-1888) period among White farmers. The Manala chiefdom was not involved in the war and had previously (1873) settled on land provided by the Berlin Mission, some 30 kilometers north of Pretoria, at a place the Manala named KoMjekejeke (Wallmannsthal).

Chief Nyabela Mahlangu was released after the Anglo-Boer War (1899-1902) in 1903 and died soon afterward. His successor tried fruitlessly in 1916 and 1918 to regain their tribal land. Instead, the royal house and a growing number of followers privately bought land in 1922, around which the Ndzundza-Ndebele reassembled. Within the framework of the bantustan or homeland system in South Africa, the Ndebele (both Manala and Ndzundza) were only allowed to settle in a homeland called KwaNdebele in 1979.''

== Umlando womlomo ==
''The oral version among the Africans explained why Ndebele became Matebele by stating that the name Matebele comes from Sotho words &quot;mathebe telele&quot;, meaning &quot;carriers of long shields&quot;. It is only Shaka's warriors who are known to have carried long shields. This idea of long shields is said to be Shaka's own, and no other king before Shaka is known to have employed this type of war armoury. When the Sotho people saw these long shields for the first time, to them it was just a queer sight. Because of the fact that it is not easy to pronounce &quot;mathebe telele&quot; in a fast speech, one ends up saying &quot;matebele'.''

</text>
      <sha1>ruo9jo6sxtneuv9o93fvch460fjvjtp</sha1>
    </revision>
    <revision>
      <id>1470</id>
      <parentid>1469</parentid>
      <timestamp>2016-02-25T19:56:06Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Umlando: 1600 - 1880 */</comment>
      <origin>1470</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4491" sha1="17kus6db73l7rlwkfca7ty50bfzdbcu" xml:space="preserve">{{Ethnic group
|Ubutjhaba = AbaNdebele
|isithombe = Ndebele-women-loopspruit.jpg
|umtlolo   = Abomma base Loopspruit Cultural Village, ngase[[Bronkhorstspruit, Gauteng|Bronkhorstspruit]]
|Ubuningi  = 1.1 million (2011 Census)
|Amaphrovinci = [[Mpumalanga]], [[Gauteng]] ne [[Limpopo Province]]
|Amalimi   = IsiNdebele
|Ikolo     = [[Isikreste]], [[Amasiko]]
|Bahlobane = [[Nguni|AbaNguni]]
}}
'''Abandebele''' namkha Abandebele besewula, isitjhaba sabantu beSewula Afrika. Isitjhaba le sihlukaniswa ngeeqhema embili, ekinga bakwaManala begodu nabakwaNdzundza. Umlando wamandebele uthoma ngekosi uMafana. Ikosi umafana walandelwa nguMhlanga owabeletha uMusi. Ikosi Umusa yathatha igandango bonyana akhambe achiye abachana bakhe oyekuhlala Kwamnyamana ngase Rhawuteni. Khonapho isitjhaba sahlukana phakathi ngabakwaManala begodu nabakwaNdzundza.

== Umlando: 1600 - 1880 ==
Ngesikhathi ikosi uMusi a thlogakala ngonyaka ka 1630, kwavuka umraro wokulwela ubukosi ebatwaneni bakhe uManala no Nzunza. Lomraro wahlukanisa isitjhaba samandebele esewula (AbakwaManala) namandebele etlhagwini (abakwaNdzundza nabakwaMthombeni). Unzuza noMthombeni bakhamba beya ngase Pumalanga batjhinga bakha KwaSimkhulu, etlhagwini leBelfast ngase Pumalanga. Kodwana uMthombeni waragela phambili wanyuka nenarha ngomlambu we Olifant waya ngase tlhagwini begodu wakha ngase Zebediela eLipompo. Umthombeni wathoma wabizwa ngokuthi nguGegana (namkha uKekana).

 Ngesikhathi kwaMaza kubusa ikosi uMagodongo, kwafika uMzilikazi abaleke kwaZulu ngestanga sezipi zakaShaka. UMzilikazi wafika wasahlela uMagodongo nesitjhaba sakhe. Uthe bona abulale uMagodongo uMzilikazi, wathumba ifuyo nabafazi wanyuka nenarha watjhinga eTlhagwini, waze wayokunzinza eRhodesia esele yaziwa ngeZimbabwe namhlanje. UMzilikazi wathi nakasahlela uMagodongo kwabe sele adlule ngakuManala, abulele uSbindi. --(Skhosana, 1996, 8)

''In 1883, during the reign of the Ndebele chief Mabhogo (whom the Boers refer to as Mapoch), war broke out between the Ndzundza and the Voortrekker settlers (Boer) of Zuid-Afrikaansche Republiek (South African Republic) over land and other resources. The Boer leader Piet Joubert led a campaign against the Ndebele leader and his people. For eight months, the Ndebele held out against the onslaught by hiding in subterranean tunnels in their mountain stronghold at Mapoch’s Caves near the town of Roossenekal. From time to time, Mabhogo’s brave warriors crept past the enemy lines undetected to fetch water and food. However, after two women of the tribe had been ambushed in the nearby woods and tortured, one revealed the Mabhogo’s whereabouts. After Mabhogo’s defeat, the cohesive tribal structure was broken up and the tribal lands confiscated. Despite the disintegration of the tribe, the Ndebele retained their cultural unity.''

==1880 - 1994==
''Ndebele wars continued under Chief Nyabela. Ndzundza lost their independence, their land was expropriated, the leaders were imprisoned (Chief Nyabela to life imprisonment), and all the Ndebele were scattered as indentured laborers for a five-year (1883-1888) period among White farmers. The Manala chiefdom was not involved in the war and had previously (1873) settled on land provided by the Berlin Mission, some 30 kilometers north of Pretoria, at a place the Manala named KoMjekejeke (Wallmannsthal).

Chief Nyabela Mahlangu was released after the Anglo-Boer War (1899-1902) in 1903 and died soon afterward. His successor tried fruitlessly in 1916 and 1918 to regain their tribal land. Instead, the royal house and a growing number of followers privately bought land in 1922, around which the Ndzundza-Ndebele reassembled. Within the framework of the bantustan or homeland system in South Africa, the Ndebele (both Manala and Ndzundza) were only allowed to settle in a homeland called KwaNdebele in 1979.''

== Umlando womlomo ==
''The oral version among the Africans explained why Ndebele became Matebele by stating that the name Matebele comes from Sotho words &quot;mathebe telele&quot;, meaning &quot;carriers of long shields&quot;. It is only Shaka's warriors who are known to have carried long shields. This idea of long shields is said to be Shaka's own, and no other king before Shaka is known to have employed this type of war armoury. When the Sotho people saw these long shields for the first time, to them it was just a queer sight. Because of the fact that it is not easy to pronounce &quot;mathebe telele&quot; in a fast speech, one ends up saying &quot;matebele'.''

</text>
      <sha1>17kus6db73l7rlwkfca7ty50bfzdbcu</sha1>
    </revision>
    <revision>
      <id>1471</id>
      <parentid>1470</parentid>
      <timestamp>2016-02-25T19:56:47Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1471</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4499" sha1="pctm0xktwnu44msm26uswz9kjodmhzr" xml:space="preserve">{{Ethnic group
|Ubutjhaba = AbaNdebele
|isithombe = Ndebele-women-loopspruit.jpg
|umtlolo   = Abomma base Loopspruit Cultural Village, ngase[[Bronkhorstspruit, Gauteng|Bronkhorstspruit]]
|Ubuningi  = 1.1 million (2011 Census)
|Amaphrovinci = [[Mpumalanga]], [[Gauteng]] ne [[Limpopo Province]]
|Amalimi   = IsiNdebele
|Ikolo     = [[Isikreste]], [[Amasiko]]
|Bahlobane = [[Nguni|AbaNguni]]
}}
'''Abandebele''' namkha Abandebele besewula, isitjhaba sabantu beSewula Afrika. Isitjhaba le sihlukaniswa ngeeqhema embili, ekinga bakwaManala begodu nabakwaNdzundza. Umlando wamandebele uthoma ngekosi uMafana. Ikosi umafana walandelwa nguMhlanga owabeletha uMusi. Ikosi Umusa yathatha igandango bonyana akhambe achiye abachana bakhe oyekuhlala Kwamnyamana ngase Rhawuteni. Khonapho isitjhaba sahlukana phakathi ngabakwaManala begodu nabakwaNdzundza.

__TOC__
== Umlando: 1600 - 1880 ==
Ngesikhathi ikosi uMusi a thlogakala ngonyaka ka 1630, kwavuka umraro wokulwela ubukosi ebatwaneni bakhe uManala no Nzunza. Lomraro wahlukanisa isitjhaba samandebele esewula (AbakwaManala) namandebele etlhagwini (abakwaNdzundza nabakwaMthombeni). Unzuza noMthombeni bakhamba beya ngase Pumalanga batjhinga bakha KwaSimkhulu, etlhagwini leBelfast ngase Pumalanga. Kodwana uMthombeni waragela phambili wanyuka nenarha ngomlambu we Olifant waya ngase tlhagwini begodu wakha ngase Zebediela eLipompo. Umthombeni wathoma wabizwa ngokuthi nguGegana (namkha uKekana).

 Ngesikhathi kwaMaza kubusa ikosi uMagodongo, kwafika uMzilikazi abaleke kwaZulu ngestanga sezipi zakaShaka. UMzilikazi wafika wasahlela uMagodongo nesitjhaba sakhe. Uthe bona abulale uMagodongo uMzilikazi, wathumba ifuyo nabafazi wanyuka nenarha watjhinga eTlhagwini, waze wayokunzinza eRhodesia esele yaziwa ngeZimbabwe namhlanje. UMzilikazi wathi nakasahlela uMagodongo kwabe sele adlule ngakuManala, abulele uSbindi. --(Skhosana, 1996, 8)

''In 1883, during the reign of the Ndebele chief Mabhogo (whom the Boers refer to as Mapoch), war broke out between the Ndzundza and the Voortrekker settlers (Boer) of Zuid-Afrikaansche Republiek (South African Republic) over land and other resources. The Boer leader Piet Joubert led a campaign against the Ndebele leader and his people. For eight months, the Ndebele held out against the onslaught by hiding in subterranean tunnels in their mountain stronghold at Mapoch’s Caves near the town of Roossenekal. From time to time, Mabhogo’s brave warriors crept past the enemy lines undetected to fetch water and food. However, after two women of the tribe had been ambushed in the nearby woods and tortured, one revealed the Mabhogo’s whereabouts. After Mabhogo’s defeat, the cohesive tribal structure was broken up and the tribal lands confiscated. Despite the disintegration of the tribe, the Ndebele retained their cultural unity.''

==1880 - 1994==
''Ndebele wars continued under Chief Nyabela. Ndzundza lost their independence, their land was expropriated, the leaders were imprisoned (Chief Nyabela to life imprisonment), and all the Ndebele were scattered as indentured laborers for a five-year (1883-1888) period among White farmers. The Manala chiefdom was not involved in the war and had previously (1873) settled on land provided by the Berlin Mission, some 30 kilometers north of Pretoria, at a place the Manala named KoMjekejeke (Wallmannsthal).

Chief Nyabela Mahlangu was released after the Anglo-Boer War (1899-1902) in 1903 and died soon afterward. His successor tried fruitlessly in 1916 and 1918 to regain their tribal land. Instead, the royal house and a growing number of followers privately bought land in 1922, around which the Ndzundza-Ndebele reassembled. Within the framework of the bantustan or homeland system in South Africa, the Ndebele (both Manala and Ndzundza) were only allowed to settle in a homeland called KwaNdebele in 1979.''

== Umlando womlomo ==
''The oral version among the Africans explained why Ndebele became Matebele by stating that the name Matebele comes from Sotho words &quot;mathebe telele&quot;, meaning &quot;carriers of long shields&quot;. It is only Shaka's warriors who are known to have carried long shields. This idea of long shields is said to be Shaka's own, and no other king before Shaka is known to have employed this type of war armoury. When the Sotho people saw these long shields for the first time, to them it was just a queer sight. Because of the fact that it is not easy to pronounce &quot;mathebe telele&quot; in a fast speech, one ends up saying &quot;matebele'.''

</text>
      <sha1>pctm0xktwnu44msm26uswz9kjodmhzr</sha1>
    </revision>
    <revision>
      <id>1472</id>
      <parentid>1471</parentid>
      <timestamp>2016-02-25T20:02:09Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1472</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4523" sha1="82b3snxy2ovp15oundntp9otetffbkl" xml:space="preserve">{{Ethnic group
|Ubutjhaba = AbaNdebele
|isithombe = Ndebele-women-loopspruit.jpg
|umtlolo   = Abomma base Loopspruit Cultural Village, ngase[[Bronkhorstspruit, Gauteng|Bronkhorstspruit]]
|Ubuningi  = 1.1 million (2011 Census)
|Amaphrovinci = [[Mpumalanga]], [[Gauteng]] ne [[Limpopo Province]]
|Amalimi   = IsiNdebele
|Ikolo     = [[Isikreste]], [[Amasiko]]
|Bahlobane = [[Nguni|AbaNguni]]
}}
'''Abandebele''' namkha Abandebele besewula, isitjhaba sabantu beSewula Afrika. Isitjhaba le sihlukaniswa ngeeqhema embili, ekinga bakwaManala begodu nabakwaNdzundza. Umlando wamandebele uthoma ngekosi uMafana. Ikosi umafana walandelwa nguMhlanga owabeletha uMusi. Ikosi Umusa yathatha igandango bonyana akhambe achiye abachana bakhe oyekuhlala Kwamnyamana ngase Rhawuteni. Khonapho isitjhaba sahlukana phakathi ngabakwaManala begodu nabakwaNdzundza.

__TOC__
== Umlando: 1600 - 1880 ==
Ngesikhathi ikosi uMusi a thlogakala ngonyaka ka 1630, kwavuka umraro wokulwela ubukosi ebatwaneni bakhe uManala no Nzunza. Lomraro wahlukanisa isitjhaba samandebele esewula (AbakwaManala) namandebele etlhagwini (abakwaNdzundza nabakwaMthombeni). Unzuza noMthombeni bakhamba beya ngase Pumalanga batjhinga bakha KwaSimkhulu, etlhagwini leBelfast ngase Pumalanga. Kodwana uMthombeni waragela phambili wanyuka nenarha ngomlambu we Olifant waya ngase tlhagwini begodu wakha ngase Zebediela eLipompo. Umthombeni wathoma wabizwa ngokuthi nguGegana (namkha uKekana).

&lt;blockquote&gt;Ngesikhathi kwaMaza kubusa ikosi uMagodongo, kwafika uMzilikazi abaleke kwaZulu ngestanga sezipi zakaShaka. UMzilikazi wafika wasahlela uMagodongo nesitjhaba sakhe. Uthe bona abulale uMagodongo uMzilikazi, wathumba ifuyo nabafazi wanyuka nenarha watjhinga eTlhagwini, waze wayokunzinza eRhodesia esele yaziwa ngeZimbabwe namhlanje. UMzilikazi wathi nakasahlela uMagodongo kwabe sele adlule ngakuManala, abulele uSbindi. --(Skhosana, 1996, 8)&lt;/blockquote&gt;

''In 1883, during the reign of the Ndebele chief Mabhogo (whom the Boers refer to as Mapoch), war broke out between the Ndzundza and the Voortrekker settlers (Boer) of Zuid-Afrikaansche Republiek (South African Republic) over land and other resources. The Boer leader Piet Joubert led a campaign against the Ndebele leader and his people. For eight months, the Ndebele held out against the onslaught by hiding in subterranean tunnels in their mountain stronghold at Mapoch’s Caves near the town of Roossenekal. From time to time, Mabhogo’s brave warriors crept past the enemy lines undetected to fetch water and food. However, after two women of the tribe had been ambushed in the nearby woods and tortured, one revealed the Mabhogo’s whereabouts. After Mabhogo’s defeat, the cohesive tribal structure was broken up and the tribal lands confiscated. Despite the disintegration of the tribe, the Ndebele retained their cultural unity.''

==1880 - 1994==
''Ndebele wars continued under Chief Nyabela. Ndzundza lost their independence, their land was expropriated, the leaders were imprisoned (Chief Nyabela to life imprisonment), and all the Ndebele were scattered as indentured laborers for a five-year (1883-1888) period among White farmers. The Manala chiefdom was not involved in the war and had previously (1873) settled on land provided by the Berlin Mission, some 30 kilometers north of Pretoria, at a place the Manala named KoMjekejeke (Wallmannsthal).

Chief Nyabela Mahlangu was released after the Anglo-Boer War (1899-1902) in 1903 and died soon afterward. His successor tried fruitlessly in 1916 and 1918 to regain their tribal land. Instead, the royal house and a growing number of followers privately bought land in 1922, around which the Ndzundza-Ndebele reassembled. Within the framework of the bantustan or homeland system in South Africa, the Ndebele (both Manala and Ndzundza) were only allowed to settle in a homeland called KwaNdebele in 1979.''

== Umlando womlomo ==
''The oral version among the Africans explained why Ndebele became Matebele by stating that the name Matebele comes from Sotho words &quot;mathebe telele&quot;, meaning &quot;carriers of long shields&quot;. It is only Shaka's warriors who are known to have carried long shields. This idea of long shields is said to be Shaka's own, and no other king before Shaka is known to have employed this type of war armoury. When the Sotho people saw these long shields for the first time, to them it was just a queer sight. Because of the fact that it is not easy to pronounce &quot;mathebe telele&quot; in a fast speech, one ends up saying &quot;matebele'.''

</text>
      <sha1>82b3snxy2ovp15oundntp9otetffbkl</sha1>
    </revision>
    <revision>
      <id>1473</id>
      <parentid>1472</parentid>
      <timestamp>2016-02-25T20:09:17Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1473</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4607" sha1="bhxn1wr6li8vnzgb8j1ihso1sdt7l43" xml:space="preserve">{{Ethnic group
|Ubutjhaba = AbaNdebele
|isithombe = Ndebele-women-loopspruit.jpg
|umtlolo   = Abomma base Loopspruit Cultural Village, ngase[[Bronkhorstspruit, Gauteng|Bronkhorstspruit]]
|Ubuningi  = 1.1 million (2011 Census)
|Amaphrovinci = [[Mpumalanga]], [[Gauteng]] ne [[Limpopo Province]]
|Amalimi   = IsiNdebele
|Ikolo     = [[Isikreste]], [[Amasiko]]
|Bahlobane = [[Nguni|AbaNguni]]
}}
'''Abandebele''' namkha Abandebele besewula, isitjhaba sabantu beSewula Afrika. Isitjhaba le sihlukaniswa ngeeqhema embili, ekinga bakwaManala begodu nabakwaNdzundza. Umlando wamandebele uthoma ngekosi uMafana. Ikosi umafana walandelwa nguMhlanga owabeletha uMusi. Ikosi Umusa yathatha igandango bonyana akhambe achiye abachana bakhe oyekuhlala Kwamnyamana ngase Rhawuteni. Khonapho isitjhaba sahlukana phakathi ngabakwaManala begodu nabakwaNdzundza.

__TOC__
== Umlando: 1600 - 1880 ==
Ngesikhathi ikosi uMusi a thlogakala ngonyaka ka 1630, kwavuka umraro wokulwela ubukosi ebatwaneni bakhe uManala no Nzunza. Lomraro wahlukanisa isitjhaba samandebele esewula (AbakwaManala) namandebele etlhagwini (abakwaNdzundza nabakwaMthombeni). Unzuza noMthombeni bakhamba beya ngase Pumalanga batjhinga bakha KwaSimkhulu, etlhagwini leBelfast ngase Pumalanga. Kodwana uMthombeni waragela phambili wanyuka nenarha ngomlambu we Olifant waya ngase tlhagwini begodu wakha ngase Zebediela eLipompo. Umthombeni wathoma wabizwa ngokuthi nguGegana (namkha uKekana).

&lt;blockquote class=&quot;toccolours&quot; style=&quot;float:none; padding: 10px 15px 10px 15px; display:table;&quot;&gt;Ngesikhathi kwaMaza kubusa ikosi uMagodongo, kwafika uMzilikazi abaleke kwaZulu ngestanga sezipi zakaShaka. UMzilikazi wafika wasahlela uMagodongo nesitjhaba sakhe. Uthe bona abulale uMagodongo uMzilikazi, wathumba ifuyo nabafazi wanyuka nenarha watjhinga eTlhagwini, waze wayokunzinza eRhodesia esele yaziwa ngeZimbabwe namhlanje. UMzilikazi wathi nakasahlela uMagodongo kwabe sele adlule ngakuManala, abulele uSbindi. --(Skhosana, 1996, 8)&lt;/blockquote&gt;

''In 1883, during the reign of the Ndebele chief Mabhogo (whom the Boers refer to as Mapoch), war broke out between the Ndzundza and the Voortrekker settlers (Boer) of Zuid-Afrikaansche Republiek (South African Republic) over land and other resources. The Boer leader Piet Joubert led a campaign against the Ndebele leader and his people. For eight months, the Ndebele held out against the onslaught by hiding in subterranean tunnels in their mountain stronghold at Mapoch’s Caves near the town of Roossenekal. From time to time, Mabhogo’s brave warriors crept past the enemy lines undetected to fetch water and food. However, after two women of the tribe had been ambushed in the nearby woods and tortured, one revealed the Mabhogo’s whereabouts. After Mabhogo’s defeat, the cohesive tribal structure was broken up and the tribal lands confiscated. Despite the disintegration of the tribe, the Ndebele retained their cultural unity.''

==1880 - 1994==
''Ndebele wars continued under Chief Nyabela. Ndzundza lost their independence, their land was expropriated, the leaders were imprisoned (Chief Nyabela to life imprisonment), and all the Ndebele were scattered as indentured laborers for a five-year (1883-1888) period among White farmers. The Manala chiefdom was not involved in the war and had previously (1873) settled on land provided by the Berlin Mission, some 30 kilometers north of Pretoria, at a place the Manala named KoMjekejeke (Wallmannsthal).

Chief Nyabela Mahlangu was released after the Anglo-Boer War (1899-1902) in 1903 and died soon afterward. His successor tried fruitlessly in 1916 and 1918 to regain their tribal land. Instead, the royal house and a growing number of followers privately bought land in 1922, around which the Ndzundza-Ndebele reassembled. Within the framework of the bantustan or homeland system in South Africa, the Ndebele (both Manala and Ndzundza) were only allowed to settle in a homeland called KwaNdebele in 1979.''

== Umlando womlomo ==
''The oral version among the Africans explained why Ndebele became Matebele by stating that the name Matebele comes from Sotho words &quot;mathebe telele&quot;, meaning &quot;carriers of long shields&quot;. It is only Shaka's warriors who are known to have carried long shields. This idea of long shields is said to be Shaka's own, and no other king before Shaka is known to have employed this type of war armoury. When the Sotho people saw these long shields for the first time, to them it was just a queer sight. Because of the fact that it is not easy to pronounce &quot;mathebe telele&quot; in a fast speech, one ends up saying &quot;matebele'.''

</text>
      <sha1>bhxn1wr6li8vnzgb8j1ihso1sdt7l43</sha1>
    </revision>
    <revision>
      <id>1474</id>
      <parentid>1473</parentid>
      <timestamp>2016-02-25T20:10:32Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Umlando: 1600 - 1880 */</comment>
      <origin>1474</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4611" sha1="cm4chep4ryze6bz2rbe9xs4lblm4mdq" xml:space="preserve">{{Ethnic group
|Ubutjhaba = AbaNdebele
|isithombe = Ndebele-women-loopspruit.jpg
|umtlolo   = Abomma base Loopspruit Cultural Village, ngase[[Bronkhorstspruit, Gauteng|Bronkhorstspruit]]
|Ubuningi  = 1.1 million (2011 Census)
|Amaphrovinci = [[Mpumalanga]], [[Gauteng]] ne [[Limpopo Province]]
|Amalimi   = IsiNdebele
|Ikolo     = [[Isikreste]], [[Amasiko]]
|Bahlobane = [[Nguni|AbaNguni]]
}}
'''Abandebele''' namkha Abandebele besewula, isitjhaba sabantu beSewula Afrika. Isitjhaba le sihlukaniswa ngeeqhema embili, ekinga bakwaManala begodu nabakwaNdzundza. Umlando wamandebele uthoma ngekosi uMafana. Ikosi umafana walandelwa nguMhlanga owabeletha uMusi. Ikosi Umusa yathatha igandango bonyana akhambe achiye abachana bakhe oyekuhlala Kwamnyamana ngase Rhawuteni. Khonapho isitjhaba sahlukana phakathi ngabakwaManala begodu nabakwaNdzundza.

__TOC__
== Umlando: 1600 - 1880 ==
Ngesikhathi ikosi uMusi a thlogakala ngonyaka ka 1630, kwavuka umraro wokulwela ubukosi ebatwaneni bakhe uManala no Nzunza. Lomraro wahlukanisa isitjhaba samandebele esewula (AbakwaManala) namandebele etlhagwini (abakwaNdzundza nabakwaMthombeni). Unzuza noMthombeni bakhamba beya ngase Pumalanga batjhinga bakha KwaSimkhulu, etlhagwini leBelfast ngase Pumalanga. Kodwana uMthombeni waragela phambili wanyuka nenarha ngomlambu we Olifant waya ngase tlhagwini begodu wakha ngase Zebediela eLipompo. Umthombeni wathoma wabizwa ngokuthi nguGegana (namkha uKekana).

&lt;blockquote class=&quot;toccolours&quot; style=&quot;float:none; padding: 10px 15px 10px 15px; display:table;&quot;&gt;Ngesikhathi kwaMaza kubusa ikosi uMagodongo, kwafika uMzilikazi abaleke kwaZulu ngestanga sezipi zakaShaka. UMzilikazi wafika wasahlela uMagodongo nesitjhaba sakhe. Uthe bona abulale uMagodongo uMzilikazi, wathumba ifuyo nabafazi wanyuka nenarha watjhinga eTlhagwini, waze wayokunzinza eRhodesia esele yaziwa ngeZimbabwe namhlanje. UMzilikazi wathi nakasahlela uMagodongo kwabe sele adlule ngakuManala, abulele uSbindi. --([[Skhosana]], 1996, 8)&lt;/blockquote&gt;

''In 1883, during the reign of the Ndebele chief Mabhogo (whom the Boers refer to as Mapoch), war broke out between the Ndzundza and the Voortrekker settlers (Boer) of Zuid-Afrikaansche Republiek (South African Republic) over land and other resources. The Boer leader Piet Joubert led a campaign against the Ndebele leader and his people. For eight months, the Ndebele held out against the onslaught by hiding in subterranean tunnels in their mountain stronghold at Mapoch’s Caves near the town of Roossenekal. From time to time, Mabhogo’s brave warriors crept past the enemy lines undetected to fetch water and food. However, after two women of the tribe had been ambushed in the nearby woods and tortured, one revealed the Mabhogo’s whereabouts. After Mabhogo’s defeat, the cohesive tribal structure was broken up and the tribal lands confiscated. Despite the disintegration of the tribe, the Ndebele retained their cultural unity.''

==1880 - 1994==
''Ndebele wars continued under Chief Nyabela. Ndzundza lost their independence, their land was expropriated, the leaders were imprisoned (Chief Nyabela to life imprisonment), and all the Ndebele were scattered as indentured laborers for a five-year (1883-1888) period among White farmers. The Manala chiefdom was not involved in the war and had previously (1873) settled on land provided by the Berlin Mission, some 30 kilometers north of Pretoria, at a place the Manala named KoMjekejeke (Wallmannsthal).

Chief Nyabela Mahlangu was released after the Anglo-Boer War (1899-1902) in 1903 and died soon afterward. His successor tried fruitlessly in 1916 and 1918 to regain their tribal land. Instead, the royal house and a growing number of followers privately bought land in 1922, around which the Ndzundza-Ndebele reassembled. Within the framework of the bantustan or homeland system in South Africa, the Ndebele (both Manala and Ndzundza) were only allowed to settle in a homeland called KwaNdebele in 1979.''

== Umlando womlomo ==
''The oral version among the Africans explained why Ndebele became Matebele by stating that the name Matebele comes from Sotho words &quot;mathebe telele&quot;, meaning &quot;carriers of long shields&quot;. It is only Shaka's warriors who are known to have carried long shields. This idea of long shields is said to be Shaka's own, and no other king before Shaka is known to have employed this type of war armoury. When the Sotho people saw these long shields for the first time, to them it was just a queer sight. Because of the fact that it is not easy to pronounce &quot;mathebe telele&quot; in a fast speech, one ends up saying &quot;matebele'.''

</text>
      <sha1>cm4chep4ryze6bz2rbe9xs4lblm4mdq</sha1>
    </revision>
    <revision>
      <id>1475</id>
      <parentid>1474</parentid>
      <timestamp>2016-02-25T20:29:48Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Umlando: 1600 - 1880 */</comment>
      <origin>1475</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4171" sha1="g76cv6fsb9t64zf831zk66eunxeh2dd" xml:space="preserve">{{Ethnic group
|Ubutjhaba = AbaNdebele
|isithombe = Ndebele-women-loopspruit.jpg
|umtlolo   = Abomma base Loopspruit Cultural Village, ngase[[Bronkhorstspruit, Gauteng|Bronkhorstspruit]]
|Ubuningi  = 1.1 million (2011 Census)
|Amaphrovinci = [[Mpumalanga]], [[Gauteng]] ne [[Limpopo Province]]
|Amalimi   = IsiNdebele
|Ikolo     = [[Isikreste]], [[Amasiko]]
|Bahlobane = [[Nguni|AbaNguni]]
}}
'''Abandebele''' namkha Abandebele besewula, isitjhaba sabantu beSewula Afrika. Isitjhaba le sihlukaniswa ngeeqhema embili, ekinga bakwaManala begodu nabakwaNdzundza. Umlando wamandebele uthoma ngekosi uMafana. Ikosi umafana walandelwa nguMhlanga owabeletha uMusi. Ikosi Umusa yathatha igandango bonyana akhambe achiye abachana bakhe oyekuhlala Kwamnyamana ngase Rhawuteni. Khonapho isitjhaba sahlukana phakathi ngabakwaManala begodu nabakwaNdzundza.

__TOC__
== Umlando: 1600 - 1880 ==
Ngesikhathi ikosi uMusi a thlogakala ngonyaka ka 1630, kwavuka umraro wokulwela ubukosi ebatwaneni bakhe uManala no Nzunza. Lomraro wahlukanisa isitjhaba samandebele esewula (AbakwaManala) namandebele etlhagwini (abakwaNdzundza nabakwaMthombeni). Unzuza noMthombeni bakhamba beya ngase Pumalanga batjhinga bakha KwaSimkhulu, etlhagwini leBelfast ngase Pumalanga. Kodwana uMthombeni waragela phambili wanyuka nenarha ngomlambu we Olifant waya ngase tlhagwini begodu wakha ngase Zebediela eLipompo. Umthombeni wathoma wabizwa ngokuthi nguGegana (namkha uKekana).

&lt;blockquote class=&quot;toccolours&quot; style=&quot;float:none; padding: 10px 15px 10px 15px; display:table;&quot;&gt;Ngesikhathi kwaMaza kubusa ikosi uMagodongo, kwafika uMzilikazi abaleke kwaZulu ngestanga sezipi zakaShaka. UMzilikazi wafika wasahlela uMagodongo nesitjhaba sakhe. Uthe bona abulale uMagodongo uMzilikazi, wathumba ifuyo nabafazi wanyuka nenarha watjhinga eTlhagwini, waze wayokunzinza eRhodesia esele yaziwa ngeZimbabwe namhlanje. UMzilikazi wathi nakasahlela uMagodongo kwabe sele adlule ngakuManala, abulele uSbindi. --([[Skhosana]], 1996, 8)&lt;/blockquote&gt;

Ngo 1883, ngesikhathi kubusa uMabhongo kwathoma ipiyombango yabakwaNdzundza namabhulu, bebanga iphasi, amanzi nefuyo. Amabhunawo abeholwa ngu Piet Joubert ahlasela isitjhaba sabandundza iinyanga ezibunane, bonyana uMabhongo nabantu bakhe baveleleke ezintabeni zangase Roossenekal. Amabutho kaMabhongo akwazi bona atjhinge ngemva kwamabhunu ayokukha amazi neziliwo. Kodwana ngemva kukuthumba nokutlhorisa abafazi, omunye wabo watjho bona ikosi uMabhongo ingaphi. Amabhunu akgona ukusahlela athumba ikosi.

==1880 - 1994==
''Ndebele wars continued under Chief Nyabela. Ndzundza lost their independence, their land was expropriated, the leaders were imprisoned (Chief Nyabela to life imprisonment), and all the Ndebele were scattered as indentured laborers for a five-year (1883-1888) period among White farmers. The Manala chiefdom was not involved in the war and had previously (1873) settled on land provided by the Berlin Mission, some 30 kilometers north of Pretoria, at a place the Manala named KoMjekejeke (Wallmannsthal).

Chief Nyabela Mahlangu was released after the Anglo-Boer War (1899-1902) in 1903 and died soon afterward. His successor tried fruitlessly in 1916 and 1918 to regain their tribal land. Instead, the royal house and a growing number of followers privately bought land in 1922, around which the Ndzundza-Ndebele reassembled. Within the framework of the bantustan or homeland system in South Africa, the Ndebele (both Manala and Ndzundza) were only allowed to settle in a homeland called KwaNdebele in 1979.''

== Umlando womlomo ==
''The oral version among the Africans explained why Ndebele became Matebele by stating that the name Matebele comes from Sotho words &quot;mathebe telele&quot;, meaning &quot;carriers of long shields&quot;. It is only Shaka's warriors who are known to have carried long shields. This idea of long shields is said to be Shaka's own, and no other king before Shaka is known to have employed this type of war armoury. When the Sotho people saw these long shields for the first time, to them it was just a queer sight. Because of the fact that it is not easy to pronounce &quot;mathebe telele&quot; in a fast speech, one ends up saying &quot;matebele'.''

</text>
      <sha1>g76cv6fsb9t64zf831zk66eunxeh2dd</sha1>
    </revision>
    <revision>
      <id>1476</id>
      <parentid>1475</parentid>
      <timestamp>2016-02-25T20:30:31Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Umlando: 1600 - 1880 */</comment>
      <origin>1476</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4173" sha1="8jonoglzjtshxticwlm6r0fsrflgw2b" xml:space="preserve">{{Ethnic group
|Ubutjhaba = AbaNdebele
|isithombe = Ndebele-women-loopspruit.jpg
|umtlolo   = Abomma base Loopspruit Cultural Village, ngase[[Bronkhorstspruit, Gauteng|Bronkhorstspruit]]
|Ubuningi  = 1.1 million (2011 Census)
|Amaphrovinci = [[Mpumalanga]], [[Gauteng]] ne [[Limpopo Province]]
|Amalimi   = IsiNdebele
|Ikolo     = [[Isikreste]], [[Amasiko]]
|Bahlobane = [[Nguni|AbaNguni]]
}}
'''Abandebele''' namkha Abandebele besewula, isitjhaba sabantu beSewula Afrika. Isitjhaba le sihlukaniswa ngeeqhema embili, ekinga bakwaManala begodu nabakwaNdzundza. Umlando wamandebele uthoma ngekosi uMafana. Ikosi umafana walandelwa nguMhlanga owabeletha uMusi. Ikosi Umusa yathatha igandango bonyana akhambe achiye abachana bakhe oyekuhlala Kwamnyamana ngase Rhawuteni. Khonapho isitjhaba sahlukana phakathi ngabakwaManala begodu nabakwaNdzundza.

__TOC__
== Umlando: 1600 - 1880 ==
Ngesikhathi ikosi uMusi a thlogakala ngonyaka ka 1630, kwavuka umraro wokulwela ubukosi ebatwaneni bakhe uManala no Nzunza. Lomraro wahlukanisa isitjhaba samandebele esewula (AbakwaManala) namandebele etlhagwini (abakwaNdzundza nabakwaMthombeni). 

Unzuza noMthombeni bakhamba beya ngase Pumalanga batjhinga bakha KwaSimkhulu, etlhagwini leBelfast ngase Pumalanga. Kodwana uMthombeni waragela phambili wanyuka nenarha ngomlambu we Olifant waya ngase tlhagwini begodu wakha ngase Zebediela eLipompo. Umthombeni wathoma wabizwa ngokuthi nguGegana (namkha uKekana).

&lt;blockquote class=&quot;toccolours&quot; style=&quot;float:none; padding: 10px 15px 10px 15px; display:table;&quot;&gt;Ngesikhathi kwaMaza kubusa ikosi uMagodongo, kwafika uMzilikazi abaleke kwaZulu ngestanga sezipi zakaShaka. UMzilikazi wafika wasahlela uMagodongo nesitjhaba sakhe. Uthe bona abulale uMagodongo uMzilikazi, wathumba ifuyo nabafazi wanyuka nenarha watjhinga eTlhagwini, waze wayokunzinza eRhodesia esele yaziwa ngeZimbabwe namhlanje. UMzilikazi wathi nakasahlela uMagodongo kwabe sele adlule ngakuManala, abulele uSbindi. --([[Skhosana]], 1996, 8)&lt;/blockquote&gt;

Ngo 1883, ngesikhathi kubusa uMabhongo kwathoma ipiyombango yabakwaNdzundza namabhulu, bebanga iphasi, amanzi nefuyo. Amabhunawo abeholwa ngu Piet Joubert ahlasela isitjhaba sabandundza iinyanga ezibunane, bonyana uMabhongo nabantu bakhe baveleleke ezintabeni zangase Roossenekal. Amabutho kaMabhongo akwazi bona atjhinge ngemva kwamabhunu ayokukha amazi neziliwo. Kodwana ngemva kukuthumba nokutlhorisa abafazi, omunye wabo watjho bona ikosi uMabhongo ingaphi. Amabhunu akgona ukusahlela athumba ikosi.

==1880 - 1994==
''Ndebele wars continued under Chief Nyabela. Ndzundza lost their independence, their land was expropriated, the leaders were imprisoned (Chief Nyabela to life imprisonment), and all the Ndebele were scattered as indentured laborers for a five-year (1883-1888) period among White farmers. The Manala chiefdom was not involved in the war and had previously (1873) settled on land provided by the Berlin Mission, some 30 kilometers north of Pretoria, at a place the Manala named KoMjekejeke (Wallmannsthal).

Chief Nyabela Mahlangu was released after the Anglo-Boer War (1899-1902) in 1903 and died soon afterward. His successor tried fruitlessly in 1916 and 1918 to regain their tribal land. Instead, the royal house and a growing number of followers privately bought land in 1922, around which the Ndzundza-Ndebele reassembled. Within the framework of the bantustan or homeland system in South Africa, the Ndebele (both Manala and Ndzundza) were only allowed to settle in a homeland called KwaNdebele in 1979.''

== Umlando womlomo ==
''The oral version among the Africans explained why Ndebele became Matebele by stating that the name Matebele comes from Sotho words &quot;mathebe telele&quot;, meaning &quot;carriers of long shields&quot;. It is only Shaka's warriors who are known to have carried long shields. This idea of long shields is said to be Shaka's own, and no other king before Shaka is known to have employed this type of war armoury. When the Sotho people saw these long shields for the first time, to them it was just a queer sight. Because of the fact that it is not easy to pronounce &quot;mathebe telele&quot; in a fast speech, one ends up saying &quot;matebele'.''

</text>
      <sha1>8jonoglzjtshxticwlm6r0fsrflgw2b</sha1>
    </revision>
    <revision>
      <id>1477</id>
      <parentid>1476</parentid>
      <timestamp>2016-02-25T20:53:07Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* 1880 - 1994 */</comment>
      <origin>1477</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4146" sha1="3m8oj5xa29y0bukz4i2xg6s9m9m9kxx" xml:space="preserve">{{Ethnic group
|Ubutjhaba = AbaNdebele
|isithombe = Ndebele-women-loopspruit.jpg
|umtlolo   = Abomma base Loopspruit Cultural Village, ngase[[Bronkhorstspruit, Gauteng|Bronkhorstspruit]]
|Ubuningi  = 1.1 million (2011 Census)
|Amaphrovinci = [[Mpumalanga]], [[Gauteng]] ne [[Limpopo Province]]
|Amalimi   = IsiNdebele
|Ikolo     = [[Isikreste]], [[Amasiko]]
|Bahlobane = [[Nguni|AbaNguni]]
}}
'''Abandebele''' namkha Abandebele besewula, isitjhaba sabantu beSewula Afrika. Isitjhaba le sihlukaniswa ngeeqhema embili, ekinga bakwaManala begodu nabakwaNdzundza. Umlando wamandebele uthoma ngekosi uMafana. Ikosi umafana walandelwa nguMhlanga owabeletha uMusi. Ikosi Umusa yathatha igandango bonyana akhambe achiye abachana bakhe oyekuhlala Kwamnyamana ngase Rhawuteni. Khonapho isitjhaba sahlukana phakathi ngabakwaManala begodu nabakwaNdzundza.

__TOC__
== Umlando: 1600 - 1880 ==
Ngesikhathi ikosi uMusi a thlogakala ngonyaka ka 1630, kwavuka umraro wokulwela ubukosi ebatwaneni bakhe uManala no Nzunza. Lomraro wahlukanisa isitjhaba samandebele esewula (AbakwaManala) namandebele etlhagwini (abakwaNdzundza nabakwaMthombeni). 

Unzuza noMthombeni bakhamba beya ngase Pumalanga batjhinga bakha KwaSimkhulu, etlhagwini leBelfast ngase Pumalanga. Kodwana uMthombeni waragela phambili wanyuka nenarha ngomlambu we Olifant waya ngase tlhagwini begodu wakha ngase Zebediela eLipompo. Umthombeni wathoma wabizwa ngokuthi nguGegana (namkha uKekana).

&lt;blockquote class=&quot;toccolours&quot; style=&quot;float:none; padding: 10px 15px 10px 15px; display:table;&quot;&gt;Ngesikhathi kwaMaza kubusa ikosi uMagodongo, kwafika uMzilikazi abaleke kwaZulu ngestanga sezipi zakaShaka. UMzilikazi wafika wasahlela uMagodongo nesitjhaba sakhe. Uthe bona abulale uMagodongo uMzilikazi, wathumba ifuyo nabafazi wanyuka nenarha watjhinga eTlhagwini, waze wayokunzinza eRhodesia esele yaziwa ngeZimbabwe namhlanje. UMzilikazi wathi nakasahlela uMagodongo kwabe sele adlule ngakuManala, abulele uSbindi. --([[Skhosana]], 1996, 8)&lt;/blockquote&gt;

Ngo 1883, ngesikhathi kubusa uMabhongo kwathoma ipiyombango yabakwaNdzundza namabhulu, bebanga iphasi, amanzi nefuyo. Amabhunawo abeholwa ngu Piet Joubert ahlasela isitjhaba sabandundza iinyanga ezibunane, bonyana uMabhongo nabantu bakhe baveleleke ezintabeni zangase Roossenekal. Amabutho kaMabhongo akwazi bona atjhinge ngemva kwamabhunu ayokukha amazi neziliwo. Kodwana ngemva kukuthumba nokutlhorisa abafazi, omunye wabo watjho bona ikosi uMabhongo ingaphi. Amabhunu akgona ukusahlela athumba ikosi.

==Umlando: 1880 - 1994==
Imiraro yobukhosi bakwandebele yaragela phambili ngaphasi kwe kosi uNyabela. AbakwaNdzundza balahlekelwa ubukhosi ngitjho nephasi labo, begodu nekosi uNyabela yavalelwa udilika-jele. Amandebele asabalala nenarha, abangamarhoba ngaphasi kwamaplasi amabhunu iminyaka emihlanu (1883 - 1888). Amakhosi akwaManala khange angenele imiraro le begodu isitjhaba sakaManala sakha KoMjekejeke ngase Wallmannsthal, enarheni abayiphiwa zizithunywa zase Berlin.

Ikosi uNyabela Mahlangu watjhaphululwa ngo 1903, ngokuphelakwe miraro yokubanga iphasi yamaBhunu namaNgesi (ngo 1899 - 1902), begodu wahlongakala. Ikosi eyalandela, yalinga ukubawa bona irhulumende ibuyise inarha yabo, kodwana kwabala. 

Indlu yobukhosi nesitjhaba yathenga inarha ngo 1922 lapho isitjhaba sakwaNdzundza sabuya sahlangana khona. Ngaphasi kombuso wezamakhaya (bantustan or homeland) amandebele (Abakwa Manala nabakwNdzundza boke) atjhingiselwa kwandebele ngonyaka ka 1979. Kulapha batholakana khulu nanjenganje.

== Umlando womlomo ==
''The oral version among the Africans explained why Ndebele became Matebele by stating that the name Matebele comes from Sotho words &quot;mathebe telele&quot;, meaning &quot;carriers of long shields&quot;. It is only Shaka's warriors who are known to have carried long shields. This idea of long shields is said to be Shaka's own, and no other king before Shaka is known to have employed this type of war armoury. When the Sotho people saw these long shields for the first time, to them it was just a queer sight. Because of the fact that it is not easy to pronounce &quot;mathebe telele&quot; in a fast speech, one ends up saying &quot;matebele'.''

</text>
      <sha1>3m8oj5xa29y0bukz4i2xg6s9m9m9kxx</sha1>
    </revision>
    <revision>
      <id>1478</id>
      <parentid>1477</parentid>
      <timestamp>2016-02-25T20:58:41Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Umlando womlomo */</comment>
      <origin>1478</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3726" sha1="b3ma0k4sex2whqufrba3f30o4plunrh" xml:space="preserve">{{Ethnic group
|Ubutjhaba = AbaNdebele
|isithombe = Ndebele-women-loopspruit.jpg
|umtlolo   = Abomma base Loopspruit Cultural Village, ngase[[Bronkhorstspruit, Gauteng|Bronkhorstspruit]]
|Ubuningi  = 1.1 million (2011 Census)
|Amaphrovinci = [[Mpumalanga]], [[Gauteng]] ne [[Limpopo Province]]
|Amalimi   = IsiNdebele
|Ikolo     = [[Isikreste]], [[Amasiko]]
|Bahlobane = [[Nguni|AbaNguni]]
}}
'''Abandebele''' namkha Abandebele besewula, isitjhaba sabantu beSewula Afrika. Isitjhaba le sihlukaniswa ngeeqhema embili, ekinga bakwaManala begodu nabakwaNdzundza. Umlando wamandebele uthoma ngekosi uMafana. Ikosi umafana walandelwa nguMhlanga owabeletha uMusi. Ikosi Umusa yathatha igandango bonyana akhambe achiye abachana bakhe oyekuhlala Kwamnyamana ngase Rhawuteni. Khonapho isitjhaba sahlukana phakathi ngabakwaManala begodu nabakwaNdzundza.

__TOC__
== Umlando: 1600 - 1880 ==
Ngesikhathi ikosi uMusi a thlogakala ngonyaka ka 1630, kwavuka umraro wokulwela ubukosi ebatwaneni bakhe uManala no Nzunza. Lomraro wahlukanisa isitjhaba samandebele esewula (AbakwaManala) namandebele etlhagwini (abakwaNdzundza nabakwaMthombeni). 

Unzuza noMthombeni bakhamba beya ngase Pumalanga batjhinga bakha KwaSimkhulu, etlhagwini leBelfast ngase Pumalanga. Kodwana uMthombeni waragela phambili wanyuka nenarha ngomlambu we Olifant waya ngase tlhagwini begodu wakha ngase Zebediela eLipompo. Umthombeni wathoma wabizwa ngokuthi nguGegana (namkha uKekana).

&lt;blockquote class=&quot;toccolours&quot; style=&quot;float:none; padding: 10px 15px 10px 15px; display:table;&quot;&gt;Ngesikhathi kwaMaza kubusa ikosi uMagodongo, kwafika uMzilikazi abaleke kwaZulu ngestanga sezipi zakaShaka. UMzilikazi wafika wasahlela uMagodongo nesitjhaba sakhe. Uthe bona abulale uMagodongo uMzilikazi, wathumba ifuyo nabafazi wanyuka nenarha watjhinga eTlhagwini, waze wayokunzinza eRhodesia esele yaziwa ngeZimbabwe namhlanje. UMzilikazi wathi nakasahlela uMagodongo kwabe sele adlule ngakuManala, abulele uSbindi. --([[Skhosana]], 1996, 8)&lt;/blockquote&gt;

Ngo 1883, ngesikhathi kubusa uMabhongo kwathoma ipiyombango yabakwaNdzundza namabhulu, bebanga iphasi, amanzi nefuyo. Amabhunawo abeholwa ngu Piet Joubert ahlasela isitjhaba sabandundza iinyanga ezibunane, bonyana uMabhongo nabantu bakhe baveleleke ezintabeni zangase Roossenekal. Amabutho kaMabhongo akwazi bona atjhinge ngemva kwamabhunu ayokukha amazi neziliwo. Kodwana ngemva kukuthumba nokutlhorisa abafazi, omunye wabo watjho bona ikosi uMabhongo ingaphi. Amabhunu akgona ukusahlela athumba ikosi.

==Umlando: 1880 - 1994==
Imiraro yobukhosi bakwandebele yaragela phambili ngaphasi kwe kosi uNyabela. AbakwaNdzundza balahlekelwa ubukhosi ngitjho nephasi labo, begodu nekosi uNyabela yavalelwa udilika-jele. Amandebele asabalala nenarha, abangamarhoba ngaphasi kwamaplasi amabhunu iminyaka emihlanu (1883 - 1888). Amakhosi akwaManala khange angenele imiraro le begodu isitjhaba sakaManala sakha KoMjekejeke ngase Wallmannsthal, enarheni abayiphiwa zizithunywa zase Berlin.

Ikosi uNyabela Mahlangu watjhaphululwa ngo 1903, ngokuphelakwe miraro yokubanga iphasi yamaBhunu namaNgesi (ngo 1899 - 1902), begodu wahlongakala. Ikosi eyalandela, yalinga ukubawa bona irhulumende ibuyise inarha yabo, kodwana kwabala. 

Indlu yobukhosi nesitjhaba yathenga inarha ngo 1922 lapho isitjhaba sakwaNdzundza sabuya sahlangana khona. Ngaphasi kombuso wezamakhaya (bantustan or homeland) amandebele (Abakwa Manala nabakwNdzundza boke) atjhingiselwa kwandebele ngonyaka ka 1979. Kulapha batholakana khulu nanjenganje.

== Umlando womlomo ==
Abanye bathi ukuthoma kwebizo lamandebele kusuka ebasuthwuni, bathi &quot;ngamathebe telele&quot;, okutjho bona ngabantu abaphatha izihlangu ezide. Bathoma bafujanisa ibizole bathi ngamandebele (Matebele).

</text>
      <sha1>b3ma0k4sex2whqufrba3f30o4plunrh</sha1>
    </revision>
    <revision>
      <id>1479</id>
      <parentid>1478</parentid>
      <timestamp>2016-02-25T20:59:22Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1479</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3728" sha1="igz4xg3cgdit7ht0eiwaxu8ro95qf00" xml:space="preserve">{{Ethnic group
|Ubutjhaba = AbaNdebele
|isithombe = Ndebele-women-loopspruit.jpg
|umtlolo   = Abomma base Loopspruit Cultural Village, ngase[[Bronkhorstspruit, Gauteng|Bronkhorstspruit]]
|Ubuningi  = 1.1 million (2011 Census)
|Amaphrovinci = [[Mpumalanga]], [[Gauteng]] ne [[Limpopo Province]]
|Amalimi   = IsiNdebele
|Ikolo     = [[Isikreste]], [[Amasiko]]
|Bahlobane = [[Nguni|AbaNguni]]
}}
'''Abandebele''' namkha Abandebele besewula, isitjhaba sabantu beSewula Afrika. Isitjhaba le sihlukaniswa ngeeqhema embili, ekinga bakwaManala begodu nabakwaNdzundza. 

Umlando wamandebele uthoma ngekosi uMafana. Ikosi umafana walandelwa nguMhlanga owabeletha uMusi. Ikosi Umusa yathatha igandango bonyana akhambe achiye abachana bakhe oyekuhlala Kwamnyamana ngase Rhawuteni. Khonapho isitjhaba sahlukana phakathi ngabakwaManala begodu nabakwaNdzundza.

__TOC__
== Umlando: 1600 - 1880 ==
Ngesikhathi ikosi uMusi a thlogakala ngonyaka ka 1630, kwavuka umraro wokulwela ubukosi ebatwaneni bakhe uManala no Nzunza. Lomraro wahlukanisa isitjhaba samandebele esewula (AbakwaManala) namandebele etlhagwini (abakwaNdzundza nabakwaMthombeni). 

Unzuza noMthombeni bakhamba beya ngase Pumalanga batjhinga bakha KwaSimkhulu, etlhagwini leBelfast ngase Pumalanga. Kodwana uMthombeni waragela phambili wanyuka nenarha ngomlambu we Olifant waya ngase tlhagwini begodu wakha ngase Zebediela eLipompo. Umthombeni wathoma wabizwa ngokuthi nguGegana (namkha uKekana).

&lt;blockquote class=&quot;toccolours&quot; style=&quot;float:none; padding: 10px 15px 10px 15px; display:table;&quot;&gt;Ngesikhathi kwaMaza kubusa ikosi uMagodongo, kwafika uMzilikazi abaleke kwaZulu ngestanga sezipi zakaShaka. UMzilikazi wafika wasahlela uMagodongo nesitjhaba sakhe. Uthe bona abulale uMagodongo uMzilikazi, wathumba ifuyo nabafazi wanyuka nenarha watjhinga eTlhagwini, waze wayokunzinza eRhodesia esele yaziwa ngeZimbabwe namhlanje. UMzilikazi wathi nakasahlela uMagodongo kwabe sele adlule ngakuManala, abulele uSbindi. --([[Skhosana]], 1996, 8)&lt;/blockquote&gt;

Ngo 1883, ngesikhathi kubusa uMabhongo kwathoma ipiyombango yabakwaNdzundza namabhulu, bebanga iphasi, amanzi nefuyo. Amabhunawo abeholwa ngu Piet Joubert ahlasela isitjhaba sabandundza iinyanga ezibunane, bonyana uMabhongo nabantu bakhe baveleleke ezintabeni zangase Roossenekal. Amabutho kaMabhongo akwazi bona atjhinge ngemva kwamabhunu ayokukha amazi neziliwo. Kodwana ngemva kukuthumba nokutlhorisa abafazi, omunye wabo watjho bona ikosi uMabhongo ingaphi. Amabhunu akgona ukusahlela athumba ikosi.

==Umlando: 1880 - 1994==
Imiraro yobukhosi bakwandebele yaragela phambili ngaphasi kwe kosi uNyabela. AbakwaNdzundza balahlekelwa ubukhosi ngitjho nephasi labo, begodu nekosi uNyabela yavalelwa udilika-jele. Amandebele asabalala nenarha, abangamarhoba ngaphasi kwamaplasi amabhunu iminyaka emihlanu (1883 - 1888). Amakhosi akwaManala khange angenele imiraro le begodu isitjhaba sakaManala sakha KoMjekejeke ngase Wallmannsthal, enarheni abayiphiwa zizithunywa zase Berlin.

Ikosi uNyabela Mahlangu watjhaphululwa ngo 1903, ngokuphelakwe miraro yokubanga iphasi yamaBhunu namaNgesi (ngo 1899 - 1902), begodu wahlongakala. Ikosi eyalandela, yalinga ukubawa bona irhulumende ibuyise inarha yabo, kodwana kwabala. 

Indlu yobukhosi nesitjhaba yathenga inarha ngo 1922 lapho isitjhaba sakwaNdzundza sabuya sahlangana khona. Ngaphasi kombuso wezamakhaya (bantustan or homeland) amandebele (Abakwa Manala nabakwNdzundza boke) atjhingiselwa kwandebele ngonyaka ka 1979. Kulapha batholakana khulu nanjenganje.

== Umlando womlomo ==
Abanye bathi ukuthoma kwebizo lamandebele kusuka ebasuthwuni, bathi &quot;ngamathebe telele&quot;, okutjho bona ngabantu abaphatha izihlangu ezide. Bathoma bafujanisa ibizole bathi ngamandebele (Matebele).

</text>
      <sha1>igz4xg3cgdit7ht0eiwaxu8ro95qf00</sha1>
    </revision>
    <revision>
      <id>1480</id>
      <parentid>1479</parentid>
      <timestamp>2016-02-25T21:11:58Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1480</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3881" sha1="fvdi1cix9xyzlrqtx3g5kz25864m0q3" xml:space="preserve">{{Ethnic group
|Ubutjhaba = AbaNdebele
|isithombe = Ndebele-women-loopspruit.jpg
|umtlolo   = Abomma base Loopspruit Cultural Village, ngase[[Bronkhorstspruit, Gauteng|Bronkhorstspruit]]
|Ubuningi  = 1.1 million (2011 Census)
|Amaphrovinci = [[Mpumalanga]], [[Gauteng]] ne [[Limpopo Province]]
|Amalimi   = IsiNdebele
|Ikolo     = [[Isikreste]], [[Amasiko]]
|Bahlobane = [[Nguni|AbaNguni]]
}}
'''Abandebele''' namkha Abandebele besewula, isitjhaba sabantu beSewula Afrika. Isitjhaba le sihlukaniswa ngeeqhema embili, ekinga bakwaManala begodu nabakwaNdzundza. 

Umlando wamandebele uthoma ngekosi uMafana. Ikosi umafana walandelwa nguMhlanga owabeletha uMusi. Ikosi Umusa yathatha igandango bonyana akhambe achiye abachana bakhe oyekuhlala Kwamnyamana ngase Rhawuteni. Khonapho isitjhaba sahlukana phakathi ngabakwaManala begodu nabakwaNdzundza.

__TOC__
== Umlando: 1600 - 1880 ==
Ngesikhathi ikosi uMusi a thlogakala ngonyaka ka 1630, kwavuka umraro wokulwela ubukosi ebatwaneni bakhe uManala no Nzunza. Lomraro wahlukanisa isitjhaba samandebele esewula (AbakwaManala) namandebele etlhagwini (abakwaNdzundza nabakwaMthombeni). 

Unzuza noMthombeni bakhamba beya ngase Pumalanga batjhinga bakha KwaSimkhulu, etlhagwini leBelfast ngase Pumalanga. Kodwana uMthombeni waragela phambili wanyuka nenarha ngomlambu we Olifant waya ngase tlhagwini begodu wakha ngase Zebediela eLipompo. Umthombeni wathoma wabizwa ngokuthi nguGegana (namkha uKekana).

&lt;blockquote class=&quot;toccolours&quot; style=&quot;float:none; padding: 10px 15px 10px 15px; display:table;&quot;&gt;Ngesikhathi kwaMaza kubusa ikosi uMagodongo, kwafika uMzilikazi abaleke kwaZulu ngestanga sezipi zakaShaka. UMzilikazi wafika wasahlela uMagodongo nesitjhaba sakhe. Uthe bona abulale uMagodongo uMzilikazi, wathumba ifuyo nabafazi wanyuka nenarha watjhinga eTlhagwini, waze wayokunzinza eRhodesia esele yaziwa ngeZimbabwe namhlanje. UMzilikazi wathi nakasahlela uMagodongo kwabe sele adlule ngakuManala, abulele uSbindi. --([[Skhosana]], 1996, 8)&lt;/blockquote&gt;

Ngo 1883, ngesikhathi kubusa uMabhongo kwathoma ipiyombango yabakwaNdzundza namabhulu, bebanga iphasi, amanzi nefuyo. Amabhunawo abeholwa ngu Piet Joubert ahlasela isitjhaba sabandundza iinyanga ezibunane, bonyana uMabhongo nabantu bakhe baveleleke ezintabeni zangase Roossenekal. Amabutho kaMabhongo akwazi bona atjhinge ngemva kwamabhunu ayokukha amazi neziliwo. Kodwana ngemva kukuthumba nokutlhorisa abafazi, omunye wabo watjho bona ikosi uMabhongo ingaphi. Amabhunu akgona ukusahlela athumba ikosi.

==Umlando: 1880 - 1994==
Imiraro yobukhosi bakwandebele yaragela phambili ngaphasi kwe kosi uNyabela. AbakwaNdzundza balahlekelwa ubukhosi ngitjho nephasi labo, begodu nekosi uNyabela yavalelwa udilika-jele. Amandebele asabalala nenarha, abangamarhoba ngaphasi kwamaplasi amabhunu iminyaka emihlanu (1883 - 1888). Amakhosi akwaManala khange angenele imiraro le begodu isitjhaba sakaManala sakha KoMjekejeke ngase Wallmannsthal, enarheni abayiphiwa zizithunywa zase Berlin.&lt;ref name=ph3&gt;&quot;[http://www.encyclopedia.com Ndebele]&quot; (1996) - '''Encyclopedia of World Cultures.''' -Van Vuuren, Chris. Retrieved 25 February 2016&lt;/ref&gt;

Ikosi uNyabela Mahlangu watjhaphululwa ngo 1903, ngokuphelakwe miraro yokubanga iphasi yamaBhunu namaNgesi (ngo 1899 - 1902), begodu wahlongakala. Ikosi eyalandela, yalinga ukubawa bona irhulumende ibuyise inarha yabo, kodwana kwabala. 

Indlu yobukhosi nesitjhaba yathenga inarha ngo 1922 lapho isitjhaba sakwaNdzundza sabuya sahlangana khona. Ngaphasi kombuso wezamakhaya (bantustan or homeland) amandebele (Abakwa Manala nabakwNdzundza boke) atjhingiselwa kwandebele ngonyaka ka 1979. Kulapha batholakana khulu nanjenganje.

== Umlando womlomo ==
Abanye bathi ukuthoma kwebizo lamandebele kusuka ebasuthwuni, bathi &quot;ngamathebe telele&quot;, okutjho bona ngabantu abaphatha izihlangu ezide. Bathoma bafujanisa ibizole bathi ngamandebele (Matebele).

</text>
      <sha1>fvdi1cix9xyzlrqtx3g5kz25864m0q3</sha1>
    </revision>
    <revision>
      <id>1481</id>
      <parentid>1480</parentid>
      <timestamp>2016-02-25T21:21:28Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1481</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4141" sha1="csheeltmbsum951tb3gvpdme3xmoog0" xml:space="preserve">{{Ethnic group
|Ubutjhaba = AbaNdebele
|isithombe = Ndebele-women-loopspruit.jpg
|umtlolo   = Abomma base Loopspruit Cultural Village, ngase[[Bronkhorstspruit, Gauteng|Bronkhorstspruit]]
|Ubuningi  = 1.1 million (2011 Census)
|Amaphrovinci = [[Mpumalanga]], [[Gauteng]] ne [[Limpopo Province]]
|Amalimi   = IsiNdebele
|Ikolo     = [[Isikreste]], [[Amasiko]]
|Bahlobane = [[Nguni|AbaNguni]]
}}
'''Abandebele''' namkha Abandebele besewula, isitjhaba sabantu beSewula Afrika. Isitjhaba le sihlukaniswa ngeeqhema embili, ekinga bakwaManala begodu nabakwaNdzundza. &lt;ref name=ph1&gt;&quot;[http://www.sahistory.org.za/article/people-south-africa-ndebele People of South Africa: Ndebele ]&quot; (27-Oct-2014) - '''South African History Online'''. Retrieved 25 February 2016&lt;/ref&gt;


Umlando wamandebele uthoma ngekosi uMafana. Ikosi umafana walandelwa nguMhlanga owabeletha uMusi. Ikosi Umusa yathatha igandango bonyana akhambe achiye abachana bakhe oyekuhlala Kwamnyamana ngase Rhawuteni. Khonapho isitjhaba sahlukana phakathi ngabakwaManala begodu nabakwaNdzundza.

__TOC__
== Umlando: 1600 - 1880 ==
Ngesikhathi ikosi uMusi a thlogakala ngonyaka ka 1630, kwavuka umraro wokulwela ubukosi ebatwaneni bakhe uManala no Nzunza. Lomraro wahlukanisa isitjhaba samandebele esewula (AbakwaManala) namandebele etlhagwini (abakwaNdzundza nabakwaMthombeni). 

Unzuza noMthombeni bakhamba beya ngase Pumalanga batjhinga bakha KwaSimkhulu, etlhagwini leBelfast ngase Pumalanga. Kodwana uMthombeni waragela phambili wanyuka nenarha ngomlambu we Olifant waya ngase tlhagwini begodu wakha ngase Zebediela eLipompo. Umthombeni wathoma wabizwa ngokuthi nguGegana (namkha uKekana).&lt;ref name=ph1&gt;&lt;/ref&gt;

&lt;blockquote class=&quot;toccolours&quot; style=&quot;float:none; padding: 10px 15px 10px 15px; display:table;&quot;&gt;Ngesikhathi kwaMaza kubusa ikosi uMagodongo, kwafika uMzilikazi abaleke kwaZulu ngestanga sezipi zakaShaka. UMzilikazi wafika wasahlela uMagodongo nesitjhaba sakhe. Uthe bona abulale uMagodongo uMzilikazi, wathumba ifuyo nabafazi wanyuka nenarha watjhinga eTlhagwini, waze wayokunzinza eRhodesia esele yaziwa ngeZimbabwe namhlanje. UMzilikazi wathi nakasahlela uMagodongo kwabe sele adlule ngakuManala, abulele uSbindi. --([[Skhosana]], 1996, 8)&lt;/blockquote&gt;

Ngo 1883, ngesikhathi kubusa uMabhongo kwathoma ipiyombango yabakwaNdzundza namabhulu, bebanga iphasi, amanzi nefuyo. Amabhunawo abeholwa ngu Piet Joubert ahlasela isitjhaba sabandundza iinyanga ezibunane, bonyana uMabhongo nabantu bakhe baveleleke ezintabeni zangase Roossenekal. Amabutho kaMabhongo akwazi bona atjhinge ngemva kwamabhunu ayokukha amazi neziliwo. Kodwana ngemva kukuthumba nokutlhorisa abafazi, omunye wabo watjho bona ikosi uMabhongo ingaphi. Amabhunu akgona ukusahlela athumba ikosi.&lt;ref name=ph2&gt;&quot;[http://www.encyclopedia.com Ndebele]&quot; (1996) - '''Encyclopedia of World Cultures.''' -Van Vuuren, Chris. Retrieved 25 February 2016&lt;/ref&gt;

==Umlando: 1880 - 1994==
Imiraro yobukhosi bakwandebele yaragela phambili ngaphasi kwe kosi uNyabela. AbakwaNdzundza balahlekelwa ubukhosi ngitjho nephasi labo, begodu nekosi uNyabela yavalelwa udilika-jele. Amandebele asabalala nenarha, abangamarhoba ngaphasi kwamaplasi amabhunu iminyaka emihlanu (1883 - 1888). Amakhosi akwaManala khange angenele imiraro le begodu isitjhaba sakaManala sakha KoMjekejeke ngase Wallmannsthal, enarheni abayiphiwa zizithunywa zase Berlin.&lt;ref name=ph2&gt;&lt;/ref&gt;

Ikosi uNyabela Mahlangu watjhaphululwa ngo 1903, ngokuphelakwe miraro yokubanga iphasi yamaBhunu namaNgesi (ngo 1899 - 1902), begodu wahlongakala. Ikosi eyalandela, yalinga ukubawa bona irhulumende ibuyise inarha yabo, kodwana kwabala. 

Indlu yobukhosi nesitjhaba yathenga inarha ngo 1922 lapho isitjhaba sakwaNdzundza sabuya sahlangana khona. Ngaphasi kombuso wezamakhaya (bantustan or homeland) amandebele (Abakwa Manala nabakwNdzundza boke) atjhingiselwa kwandebele ngonyaka ka 1979. Kulapha batholakana khulu nanjenganje.&lt;ref name=ph1&gt;&lt;/ref&gt;

== Umlando womlomo ==
Abanye bathi ukuthoma kwebizo lamandebele kusuka ebasuthwuni, bathi &quot;ngamathebe telele&quot;, okutjho bona ngabantu abaphatha izihlangu ezide. Bathoma bafujanisa ibizole bathi ngamandebele (Matebele).

</text>
      <sha1>csheeltmbsum951tb3gvpdme3xmoog0</sha1>
    </revision>
    <revision>
      <id>1482</id>
      <parentid>1481</parentid>
      <timestamp>2016-03-14T08:26:54Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Umlando womlomo */</comment>
      <origin>1482</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4172" sha1="7q73xzigwz40blirij1gqxkr89m7u50" xml:space="preserve">{{Ethnic group
|Ubutjhaba = AbaNdebele
|isithombe = Ndebele-women-loopspruit.jpg
|umtlolo   = Abomma base Loopspruit Cultural Village, ngase[[Bronkhorstspruit, Gauteng|Bronkhorstspruit]]
|Ubuningi  = 1.1 million (2011 Census)
|Amaphrovinci = [[Mpumalanga]], [[Gauteng]] ne [[Limpopo Province]]
|Amalimi   = IsiNdebele
|Ikolo     = [[Isikreste]], [[Amasiko]]
|Bahlobane = [[Nguni|AbaNguni]]
}}
'''Abandebele''' namkha Abandebele besewula, isitjhaba sabantu beSewula Afrika. Isitjhaba le sihlukaniswa ngeeqhema embili, ekinga bakwaManala begodu nabakwaNdzundza. &lt;ref name=ph1&gt;&quot;[http://www.sahistory.org.za/article/people-south-africa-ndebele People of South Africa: Ndebele ]&quot; (27-Oct-2014) - '''South African History Online'''. Retrieved 25 February 2016&lt;/ref&gt;


Umlando wamandebele uthoma ngekosi uMafana. Ikosi umafana walandelwa nguMhlanga owabeletha uMusi. Ikosi Umusa yathatha igandango bonyana akhambe achiye abachana bakhe oyekuhlala Kwamnyamana ngase Rhawuteni. Khonapho isitjhaba sahlukana phakathi ngabakwaManala begodu nabakwaNdzundza.

__TOC__
== Umlando: 1600 - 1880 ==
Ngesikhathi ikosi uMusi a thlogakala ngonyaka ka 1630, kwavuka umraro wokulwela ubukosi ebatwaneni bakhe uManala no Nzunza. Lomraro wahlukanisa isitjhaba samandebele esewula (AbakwaManala) namandebele etlhagwini (abakwaNdzundza nabakwaMthombeni). 

Unzuza noMthombeni bakhamba beya ngase Pumalanga batjhinga bakha KwaSimkhulu, etlhagwini leBelfast ngase Pumalanga. Kodwana uMthombeni waragela phambili wanyuka nenarha ngomlambu we Olifant waya ngase tlhagwini begodu wakha ngase Zebediela eLipompo. Umthombeni wathoma wabizwa ngokuthi nguGegana (namkha uKekana).&lt;ref name=ph1&gt;&lt;/ref&gt;

&lt;blockquote class=&quot;toccolours&quot; style=&quot;float:none; padding: 10px 15px 10px 15px; display:table;&quot;&gt;Ngesikhathi kwaMaza kubusa ikosi uMagodongo, kwafika uMzilikazi abaleke kwaZulu ngestanga sezipi zakaShaka. UMzilikazi wafika wasahlela uMagodongo nesitjhaba sakhe. Uthe bona abulale uMagodongo uMzilikazi, wathumba ifuyo nabafazi wanyuka nenarha watjhinga eTlhagwini, waze wayokunzinza eRhodesia esele yaziwa ngeZimbabwe namhlanje. UMzilikazi wathi nakasahlela uMagodongo kwabe sele adlule ngakuManala, abulele uSbindi. --([[Skhosana]], 1996, 8)&lt;/blockquote&gt;

Ngo 1883, ngesikhathi kubusa uMabhongo kwathoma ipiyombango yabakwaNdzundza namabhulu, bebanga iphasi, amanzi nefuyo. Amabhunawo abeholwa ngu Piet Joubert ahlasela isitjhaba sabandundza iinyanga ezibunane, bonyana uMabhongo nabantu bakhe baveleleke ezintabeni zangase Roossenekal. Amabutho kaMabhongo akwazi bona atjhinge ngemva kwamabhunu ayokukha amazi neziliwo. Kodwana ngemva kukuthumba nokutlhorisa abafazi, omunye wabo watjho bona ikosi uMabhongo ingaphi. Amabhunu akgona ukusahlela athumba ikosi.&lt;ref name=ph2&gt;&quot;[http://www.encyclopedia.com Ndebele]&quot; (1996) - '''Encyclopedia of World Cultures.''' -Van Vuuren, Chris. Retrieved 25 February 2016&lt;/ref&gt;

==Umlando: 1880 - 1994==
Imiraro yobukhosi bakwandebele yaragela phambili ngaphasi kwe kosi uNyabela. AbakwaNdzundza balahlekelwa ubukhosi ngitjho nephasi labo, begodu nekosi uNyabela yavalelwa udilika-jele. Amandebele asabalala nenarha, abangamarhoba ngaphasi kwamaplasi amabhunu iminyaka emihlanu (1883 - 1888). Amakhosi akwaManala khange angenele imiraro le begodu isitjhaba sakaManala sakha KoMjekejeke ngase Wallmannsthal, enarheni abayiphiwa zizithunywa zase Berlin.&lt;ref name=ph2&gt;&lt;/ref&gt;

Ikosi uNyabela Mahlangu watjhaphululwa ngo 1903, ngokuphelakwe miraro yokubanga iphasi yamaBhunu namaNgesi (ngo 1899 - 1902), begodu wahlongakala. Ikosi eyalandela, yalinga ukubawa bona irhulumende ibuyise inarha yabo, kodwana kwabala. 

Indlu yobukhosi nesitjhaba yathenga inarha ngo 1922 lapho isitjhaba sakwaNdzundza sabuya sahlangana khona. Ngaphasi kombuso wezamakhaya (bantustan or homeland) amandebele (Abakwa Manala nabakwNdzundza boke) atjhingiselwa kwandebele ngonyaka ka 1979. Kulapha batholakana khulu nanjenganje.&lt;ref name=ph1&gt;&lt;/ref&gt;

== Umlando womlomo ==
Abanye bathi ukuthoma kwebizo lamandebele kusuka ebasuthwuni, bathi &quot;ngamathebe telele&quot;, okutjho bona ngabantu abaphatha izihlangu ezide. Bathoma bafujanisa ibizole bathi ngamandebele (Matebele).

==Isithasiselo==
&lt;references/&gt;
</text>
      <sha1>7q73xzigwz40blirij1gqxkr89m7u50</sha1>
    </revision>
    <revision>
      <id>1483</id>
      <parentid>1482</parentid>
      <timestamp>2016-03-14T08:27:27Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1483</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4171" sha1="0zknmfr2qsx1icleya05be3t41fw4jm" xml:space="preserve">{{Ethnic group
|Ubutjhaba = AbaNdebele
|isithombe = Ndebele-women-loopspruit.jpg
|umtlolo   = Abomma base Loopspruit Cultural Village, ngase[[Bronkhorstspruit, Gauteng|Bronkhorstspruit]]
|Ubuningi  = 1.1 million (2011 Census)
|Amaphrovinci = [[Mpumalanga]], [[Gauteng]] ne [[Limpopo Province]]
|Amalimi   = IsiNdebele
|Ikolo     = [[Isikreste]], [[Amasiko]]
|Bahlobane = [[Nguni|AbaNguni]]
}}
'''Abandebele''' namkha Abandebele besewula, isitjhaba sabantu beSewula Afrika. Isitjhaba le sihlukaniswa ngeeqhema embili, ekinga bakwaManala begodu nabakwaNdzundza. &lt;ref name=ph1&gt;&quot;[http://www.sahistory.org.za/article/people-south-africa-ndebele People of South Africa: Ndebele ]&quot; (27-Oct-2014) - '''South African History Online'''. Retrieved 25 February 2016&lt;/ref&gt;

Umlando wamandebele uthoma ngekosi uMafana. Ikosi umafana walandelwa nguMhlanga owabeletha uMusi. Ikosi Umusa yathatha igandango bonyana akhambe achiye abachana bakhe oyekuhlala Kwamnyamana ngase Rhawuteni. Khonapho isitjhaba sahlukana phakathi ngabakwaManala begodu nabakwaNdzundza.

__TOC__
== Umlando: 1600 - 1880 ==
Ngesikhathi ikosi uMusi a thlogakala ngonyaka ka 1630, kwavuka umraro wokulwela ubukosi ebatwaneni bakhe uManala no Nzunza. Lomraro wahlukanisa isitjhaba samandebele esewula (AbakwaManala) namandebele etlhagwini (abakwaNdzundza nabakwaMthombeni). 

Unzuza noMthombeni bakhamba beya ngase Pumalanga batjhinga bakha KwaSimkhulu, etlhagwini leBelfast ngase Pumalanga. Kodwana uMthombeni waragela phambili wanyuka nenarha ngomlambu we Olifant waya ngase tlhagwini begodu wakha ngase Zebediela eLipompo. Umthombeni wathoma wabizwa ngokuthi nguGegana (namkha uKekana).&lt;ref name=ph1&gt;&lt;/ref&gt;

&lt;blockquote class=&quot;toccolours&quot; style=&quot;float:none; padding: 10px 15px 10px 15px; display:table;&quot;&gt;Ngesikhathi kwaMaza kubusa ikosi uMagodongo, kwafika uMzilikazi abaleke kwaZulu ngestanga sezipi zakaShaka. UMzilikazi wafika wasahlela uMagodongo nesitjhaba sakhe. Uthe bona abulale uMagodongo uMzilikazi, wathumba ifuyo nabafazi wanyuka nenarha watjhinga eTlhagwini, waze wayokunzinza eRhodesia esele yaziwa ngeZimbabwe namhlanje. UMzilikazi wathi nakasahlela uMagodongo kwabe sele adlule ngakuManala, abulele uSbindi. --([[Skhosana]], 1996, 8)&lt;/blockquote&gt;

Ngo 1883, ngesikhathi kubusa uMabhongo kwathoma ipiyombango yabakwaNdzundza namabhulu, bebanga iphasi, amanzi nefuyo. Amabhunawo abeholwa ngu Piet Joubert ahlasela isitjhaba sabandundza iinyanga ezibunane, bonyana uMabhongo nabantu bakhe baveleleke ezintabeni zangase Roossenekal. Amabutho kaMabhongo akwazi bona atjhinge ngemva kwamabhunu ayokukha amazi neziliwo. Kodwana ngemva kukuthumba nokutlhorisa abafazi, omunye wabo watjho bona ikosi uMabhongo ingaphi. Amabhunu akgona ukusahlela athumba ikosi.&lt;ref name=ph2&gt;&quot;[http://www.encyclopedia.com Ndebele]&quot; (1996) - '''Encyclopedia of World Cultures.''' -Van Vuuren, Chris. Retrieved 25 February 2016&lt;/ref&gt;

==Umlando: 1880 - 1994==
Imiraro yobukhosi bakwandebele yaragela phambili ngaphasi kwe kosi uNyabela. AbakwaNdzundza balahlekelwa ubukhosi ngitjho nephasi labo, begodu nekosi uNyabela yavalelwa udilika-jele. Amandebele asabalala nenarha, abangamarhoba ngaphasi kwamaplasi amabhunu iminyaka emihlanu (1883 - 1888). Amakhosi akwaManala khange angenele imiraro le begodu isitjhaba sakaManala sakha KoMjekejeke ngase Wallmannsthal, enarheni abayiphiwa zizithunywa zase Berlin.&lt;ref name=ph2&gt;&lt;/ref&gt;

Ikosi uNyabela Mahlangu watjhaphululwa ngo 1903, ngokuphelakwe miraro yokubanga iphasi yamaBhunu namaNgesi (ngo 1899 - 1902), begodu wahlongakala. Ikosi eyalandela, yalinga ukubawa bona irhulumende ibuyise inarha yabo, kodwana kwabala. 

Indlu yobukhosi nesitjhaba yathenga inarha ngo 1922 lapho isitjhaba sakwaNdzundza sabuya sahlangana khona. Ngaphasi kombuso wezamakhaya (bantustan or homeland) amandebele (Abakwa Manala nabakwNdzundza boke) atjhingiselwa kwandebele ngonyaka ka 1979. Kulapha batholakana khulu nanjenganje.&lt;ref name=ph1&gt;&lt;/ref&gt;

== Umlando womlomo ==
Abanye bathi ukuthoma kwebizo lamandebele kusuka ebasuthwuni, bathi &quot;ngamathebe telele&quot;, okutjho bona ngabantu abaphatha izihlangu ezide. Bathoma bafujanisa ibizole bathi ngamandebele (Matebele).

==Isithasiselo==
&lt;references/&gt;
</text>
      <sha1>0zknmfr2qsx1icleya05be3t41fw4jm</sha1>
    </revision>
    <revision>
      <id>1484</id>
      <parentid>1483</parentid>
      <timestamp>2024-03-08T10:27:13Z</timestamp>
      <contributor>
        <username>incubator&gt;Simphiwe22</username>
        <id>0</id>
      </contributor>
      <comment>Added content</comment>
      <origin>1484</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4199" sha1="gxt98xocmckfzqsd2esfey2unvfyqgr" xml:space="preserve">{{Ethnic group
|Ubutjhaba = AbaNdebele
|isithombe = Ndebele-women-loopspruit.jpg
|umtlolo   = Abomma base Loopspruit Cultural Village, ngase[[Bronkhorstspruit, Gauteng|Bronkhorstspruit]]
|Ubuningi  = 1.1 million (2011 Census)
|Amaphrovinci = [[Mpumalanga]], [[Gauteng]] ne [[Limpopo Province]]
|Amalimi   = IsiNdebele
|Ikolo     = [[Isikreste]], [[Amasiko]]
|Bahlobane = [[Nguni|AbaNguni]]
}}
'''Abandebele''' namkha Abandebele besewula, isitjhaba sabantu beSewula Afrika. Isitjhaba le sihlukaniswa ngeeqhema embili, ekinga bakwaManala begodu nabakwaNdzundza. &lt;ref name=ph1&gt;&quot;[http://www.sahistory.org.za/article/people-south-africa-ndebele People of South Africa: Ndebele ]&quot; (27-Oct-2014) - '''South African History Online'''. Retrieved 25 February 2016&lt;/ref&gt;

Umlando wamandebele uthoma ngekosi uMafana. Ikosi umafana walandelwa nguMhlanga owabeletha uMusi. Ikosi Umusa yathatha igandango bonyana akhambe achiye abachana bakhe oyekuhlala Kwamnyamana ngase Rhawuteni. Khonapho isitjhaba sahlukana phakathi ngabakwaManala begodu nabakwaNdzundza iinkosi ezhlonipheke khulu.

__TOC__

== Umlando: 1600 - 1880 ==
Ngesikhathi ikosi uMusi a thlogakala ngonyaka ka 1630, kwavuka umraro wokulwela ubukosi ebatwaneni bakhe uManala no Nzunza. Lomraro wahlukanisa isitjhaba samandebele esewula (AbakwaManala) namandebele etlhagwini (abakwaNdzundza nabakwaMthombeni). 

Unzuza noMthombeni bakhamba beya ngase Pumalanga batjhinga bakha KwaSimkhulu, etlhagwini leBelfast ngase Pumalanga. Kodwana uMthombeni waragela phambili wanyuka nenarha ngomlambu we Olifant waya ngase tlhagwini begodu wakha ngase Zebediela eLipompo. Umthombeni wathoma wabizwa ngokuthi nguGegana (namkha uKekana).&lt;ref name=ph1&gt;&lt;/ref&gt;

&lt;blockquote class=&quot;toccolours&quot; style=&quot;float:none; padding: 10px 15px 10px 15px; display:table;&quot;&gt;Ngesikhathi kwaMaza kubusa ikosi uMagodongo, kwafika uMzilikazi abaleke kwaZulu ngestanga sezipi zakaShaka. UMzilikazi wafika wasahlela uMagodongo nesitjhaba sakhe. Uthe bona abulale uMagodongo uMzilikazi, wathumba ifuyo nabafazi wanyuka nenarha watjhinga eTlhagwini, waze wayokunzinza eRhodesia esele yaziwa ngeZimbabwe namhlanje. UMzilikazi wathi nakasahlela uMagodongo kwabe sele adlule ngakuManala, abulele uSbindi. --([[Skhosana]], 1996, 8)&lt;/blockquote&gt;

Ngo 1883, ngesikhathi kubusa uMabhongo kwathoma ipiyombango yabakwaNdzundza namabhulu, bebanga iphasi, amanzi nefuyo. Amabhunawo abeholwa ngu Piet Joubert ahlasela isitjhaba sabandundza iinyanga ezibunane, bonyana uMabhongo nabantu bakhe baveleleke ezintabeni zangase Roossenekal. Amabutho kaMabhongo akwazi bona atjhinge ngemva kwamabhunu ayokukha amazi neziliwo. Kodwana ngemva kukuthumba nokutlhorisa abafazi, omunye wabo watjho bona ikosi uMabhongo ingaphi. Amabhunu akgona ukusahlela athumba ikosi.&lt;ref name=ph2&gt;&quot;[http://www.encyclopedia.com Ndebele]&quot; (1996) - '''Encyclopedia of World Cultures.''' -Van Vuuren, Chris. Retrieved 25 February 2016&lt;/ref&gt;

==Umlando: 1880 - 1994==
Imiraro yobukhosi bakwandebele yaragela phambili ngaphasi kwe kosi uNyabela. AbakwaNdzundza balahlekelwa ubukhosi ngitjho nephasi labo, begodu nekosi uNyabela yavalelwa udilika-jele. Amandebele asabalala nenarha, abangamarhoba ngaphasi kwamaplasi amabhunu iminyaka emihlanu (1883 - 1888). Amakhosi akwaManala khange angenele imiraro le begodu isitjhaba sakaManala sakha KoMjekejeke ngase Wallmannsthal, enarheni abayiphiwa zizithunywa zase Berlin.&lt;ref name=ph2&gt;&lt;/ref&gt;

Ikosi uNyabela Mahlangu watjhaphululwa ngo 1903, ngokuphelakwe miraro yokubanga iphasi yamaBhunu namaNgesi (ngo 1899 - 1902), begodu wahlongakala. Ikosi eyalandela, yalinga ukubawa bona irhulumende ibuyise inarha yabo, kodwana kwabala. 

Indlu yobukhosi nesitjhaba yathenga inarha ngo 1922 lapho isitjhaba sakwaNdzundza sabuya sahlangana khona. Ngaphasi kombuso wezamakhaya (bantustan or homeland) amandebele (Abakwa Manala nabakwNdzundza boke) atjhingiselwa kwandebele ngonyaka ka 1979. Kulapha batholakana khulu nanjenganje.&lt;ref name=ph1&gt;&lt;/ref&gt;

== Umlando womlomo ==
Abanye bathi ukuthoma kwebizo lamandebele kusuka ebasuthwuni, bathi &quot;ngamathebe telele&quot;, okutjho bona ngabantu abaphatha izihlangu ezide. Bathoma bafujanisa ibizole bathi ngamandebele (Matebele).

==Isithasiselo==
&lt;references/&gt;
</text>
      <sha1>gxt98xocmckfzqsd2esfey2unvfyqgr</sha1>
    </revision>
    <revision>
      <id>1485</id>
      <parentid>1484</parentid>
      <timestamp>2024-03-08T11:22:00Z</timestamp>
      <contributor>
        <username>incubator&gt;Thandeka179</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Added content</comment>
      <origin>1485</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4197" sha1="0pbtj7osf067ruux37nxc5zsyb5ti3q" xml:space="preserve">{{Ethnic group
|Ubutjhaba = AbaNdebele
|isithombe = Ndebele-women-loopspruit.jpg
|umtlolo   = Abomma base Loopspruit Cultural Village, ngase[[Bronkhorstspruit, Gauteng|Bronkhorstspruit]]
|Ubuningi  = 1.1 million (2011 Census)
|Amaphrovinci = [[Mpumalanga]], [[Gauteng]] ne [[Limpopo Province]]
|Amalimi   = IsiNdebele
|Ikolo     = [[Isikreste]], [[Amasiko]]
|Bahlobane = [[Nguni|AbaNguni]]
}}
'''Abandebele''' namkha Abandebele besewula, isitjhaba sabantu beSewula Afrika. Isitjhaba le sihlukaniswa ngeeqhema embili, ekinga bakwaManala begodu nabakwaNdzundza. &lt;ref name=ph1&gt;&quot;[http://www.sahistory.org.za/article/people-south-africa-ndebele People of South Africa: Ndebele ]&quot; (27-Oct-2014) - '''South African History Online'''. Retrieved 25 February 2016&lt;/ref&gt;

Umlando wamandebele uthoma ngekosi uMafana. Ikosi umafana walandelwa nguMhlanga owabeletha uMusi. Ikosi Umusa yathatha igandango bonyana akhambe achiye abachana bakhe oyekuhlala Kwamnyamana ngase Rhawuteni. Khonapho isitjhaba sahlukana phakathi ngabakwaManala begodu nabakwaNdzundza iinkosi ezhloniphekileko.

__TOC__

== Umlando: 1600 - 1880 ==
Ngesikhathi ikosi uMusi a thlogakala ngonyaka ka 1630, kwavuka umraro wokulwela ubukosi ebatwaneni bakhe uManala no Nzunza. Lomraro wahlukanisa isitjhaba samandebele esewula (AbakwaManala) namandebele etlhagwini (abakwaNdzundza nabakwaMthombeni). 

Unzuza noMthombeni bakhamba beya ngase Pumalanga batjhinga bakha KwaSimkhulu, etlhagwini leBelfast ngase Pumalanga. Kodwana uMthombeni waragela phambili wanyuka nenarha ngomlambu we Olifant waya ngase tlhagwini begodu wakha ngase Zebediela eLipompo. Umthombeni wathoma wabizwa ngokuthi nguGegana (namkha uKekana).&lt;ref name=ph1&gt;&lt;/ref&gt;

&lt;blockquote class=&quot;toccolours&quot; style=&quot;float:none; padding: 10px 15px 10px 15px; display:table;&quot;&gt;Ngesikhathi kwaMaza kubusa ikosi uMagodongo, kwafika uMzilikazi abaleke kwaZulu ngestanga sezipi zakaShaka. UMzilikazi wafika wasahlela uMagodongo nesitjhaba sakhe. Uthe bona abulale uMagodongo uMzilikazi, wathumba ifuyo nabafazi wanyuka nenarha watjhinga eTlhagwini, waze wayokunzinza eRhodesia esele yaziwa ngeZimbabwe namhlanje. UMzilikazi wathi nakasahlela uMagodongo kwabe sele adlule ngakuManala, abulele uSbindi. --([[Skhosana]], 1996, 8)&lt;/blockquote&gt;

Ngo 1883, ngesikhathi kubusa uMabhongo kwathoma ipiyombango yabakwaNdzundza namabhulu, bebanga iphasi, amanzi nefuyo. Amabhunawo abeholwa ngu Piet Joubert ahlasela isitjhaba sabandundza iinyanga ezibunane, bonyana uMabhongo nabantu bakhe baveleleke ezintabeni zangase Roossenekal. Amabutho kaMabhongo akwazi bona atjhinge ngemva kwamabhunu ayokukha amazi neziliwo. Kodwana ngemva kukuthumba nokutlhorisa abafazi, omunye wabo watjho bona ikosi uMabhongo ingaphi. Amabhunu akgona ukusahlela athumba ikosi.&lt;ref name=ph2&gt;&quot;[http://www.encyclopedia.com Ndebele]&quot; (1996) - '''Encyclopedia of World Cultures.''' -Van Vuuren, Chris. Retrieved 25 February 2016&lt;/ref&gt;

==Umlando: 1880 - 1994==
Imiraro yobukhosi bakwandebele yaragela phambili ngaphasi kwe kosi uNyabela. AbakwaNdzundza balahlekelwa ubukhosi ngitjho nephasi labo, begodu nekosi uNyabela yavalelwa udilika-jele. Amandebele asabalala nenarha, abangamarhoba ngaphasi kwamaplasi amabhunu iminyaka emihlanu (1883 - 1888). Amakhosi akwaManala khange angenele imiraro le begodu isitjhaba sakaManala sakha KoMjekejeke ngase Wallmannsthal, enarheni abayiphiwa zizithunywa zase Berlin.&lt;ref name=ph2&gt;&lt;/ref&gt;

Ikosi uNyabela Mahlangu watjhaphululwa ngo 1903, ngokuphelakwe miraro yokubanga iphasi yamaBhunu namaNgesi (ngo 1899 - 1902), begodu wahlongakala. Ikosi eyalandela, yalinga ukubawa bona irhulumende ibuyise inarha yabo, kodwana kwabala. 

Indlu yobukhosi nesitjhaba yathenga inarha ngo 1922 lapho isitjhaba sakwaNdzundza sabuya sahlangana khona. Ngaphasi kombuso wezamakhaya (bantustan or homeland) amandebele (Abakwa Manala nabakwNdzundza boke) atjhingiselwa kwandebele ngonyaka ka 1979. Kulapha batholakana khulu nanjenganje.&lt;ref name=ph1&gt;&lt;/ref&gt;

== Umlando womlomo ==
Abanye bathi ukuthoma kwebizo lamandebele kusuka ebasuthwuni, bathi &quot;ngamathebe telele&quot;, okutjho bona ngabantu abaphatha izihlangu ezide. Bathoma bafujanisa ibizole bathi ngamandebele (Matebele).

==Isithasiselo==
&lt;references/&gt;
</text>
      <sha1>0pbtj7osf067ruux37nxc5zsyb5ti3q</sha1>
    </revision>
    <revision>
      <id>1486</id>
      <parentid>1485</parentid>
      <timestamp>2024-03-09T08:26:12Z</timestamp>
      <contributor>
        <username>incubator&gt;Mzwakhe David18</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>added picture.</comment>
      <origin>1486</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4303" sha1="phl5klfts68mmwrme73xb7o2qqaixq9" xml:space="preserve">{{Ethnic group
|Ubutjhaba = AbaNdebele
|isithombe = Ndebele-women-loopspruit.jpg
|umtlolo   = Abomma base Loopspruit Cultural Village, ngase[[Bronkhorstspruit, Gauteng|Bronkhorstspruit]]
|Ubuningi  = 1.1 million (2011 Census)
|Amaphrovinci = [[Mpumalanga]], [[Gauteng]] ne [[Limpopo Province]]
|Amalimi   = IsiNdebele
|Ikolo     = [[Isikreste]], [[Amasiko]]
|Bahlobane = [[Nguni|AbaNguni]]
}}
[[Isimumathi:Mapoch.- Femmes Ndebele in Cultural Village (2).jpg|alt=kwandebel|thumb|Abomma bamandebele]]
'''Abandebele''' namkha Abandebele besewula, isitjhaba sabantu beSewula Afrika. Isitjhaba le sihlukaniswa ngeeqhema embili, ekinga bakwaManala begodu nabakwaNdzundza. &lt;ref name=ph1&gt;&quot;[http://www.sahistory.org.za/article/people-south-africa-ndebele People of South Africa: Ndebele ]&quot; (27-Oct-2014) - '''South African History Online'''. Retrieved 25 February 2016&lt;/ref&gt;

Umlando wamandebele uthoma ngekosi uMafana. Ikosi umafana walandelwa nguMhlanga owabeletha uMusi. Ikosi Umusa yathatha igandango bonyana akhambe achiye abachana bakhe oyekuhlala Kwamnyamana ngase Rhawuteni. Khonapho isitjhaba sahlukana phakathi ngabakwaManala begodu nabakwaNdzundza iinkosi ezhloniphekileko.

__TOC__

== Umlando: 1600 - 1880 ==
Ngesikhathi ikosi uMusi a thlogakala ngonyaka ka 1630, kwavuka umraro wokulwela ubukosi ebatwaneni bakhe uManala no Nzunza. Lomraro wahlukanisa isitjhaba samandebele esewula (AbakwaManala) namandebele etlhagwini (abakwaNdzundza nabakwaMthombeni). 

Unzuza noMthombeni bakhamba beya ngase Pumalanga batjhinga bakha KwaSimkhulu, etlhagwini leBelfast ngase Pumalanga. Kodwana uMthombeni waragela phambili wanyuka nenarha ngomlambu we Olifant waya ngase tlhagwini begodu wakha ngase Zebediela eLipompo. Umthombeni wathoma wabizwa ngokuthi nguGegana (namkha uKekana).&lt;ref name=ph1&gt;&lt;/ref&gt;

&lt;blockquote class=&quot;toccolours&quot; style=&quot;float:none; padding: 10px 15px 10px 15px; display:table;&quot;&gt;Ngesikhathi kwaMaza kubusa ikosi uMagodongo, kwafika uMzilikazi abaleke kwaZulu ngestanga sezipi zakaShaka. UMzilikazi wafika wasahlela uMagodongo nesitjhaba sakhe. Uthe bona abulale uMagodongo uMzilikazi, wathumba ifuyo nabafazi wanyuka nenarha watjhinga eTlhagwini, waze wayokunzinza eRhodesia esele yaziwa ngeZimbabwe namhlanje. UMzilikazi wathi nakasahlela uMagodongo kwabe sele adlule ngakuManala, abulele uSbindi. --([[Skhosana]], 1996, 8)&lt;/blockquote&gt;

Ngo 1883, ngesikhathi kubusa uMabhongo kwathoma ipiyombango yabakwaNdzundza namabhulu, bebanga iphasi, amanzi nefuyo. Amabhunawo abeholwa ngu Piet Joubert ahlasela isitjhaba sabandundza iinyanga ezibunane, bonyana uMabhongo nabantu bakhe baveleleke ezintabeni zangase Roossenekal. Amabutho kaMabhongo akwazi bona atjhinge ngemva kwamabhunu ayokukha amazi neziliwo. Kodwana ngemva kukuthumba nokutlhorisa abafazi, omunye wabo watjho bona ikosi uMabhongo ingaphi. Amabhunu akgona ukusahlela athumba ikosi.&lt;ref name=ph2&gt;&quot;[http://www.encyclopedia.com Ndebele]&quot; (1996) - '''Encyclopedia of World Cultures.''' -Van Vuuren, Chris. Retrieved 25 February 2016&lt;/ref&gt;

==Umlando: 1880 - 1994==
Imiraro yobukhosi bakwandebele yaragela phambili ngaphasi kwe kosi uNyabela. AbakwaNdzundza balahlekelwa ubukhosi ngitjho nephasi labo, begodu nekosi uNyabela yavalelwa udilika-jele. Amandebele asabalala nenarha, abangamarhoba ngaphasi kwamaplasi amabhunu iminyaka emihlanu (1883 - 1888). Amakhosi akwaManala khange angenele imiraro le begodu isitjhaba sakaManala sakha KoMjekejeke ngase Wallmannsthal, enarheni abayiphiwa zizithunywa zase Berlin.&lt;ref name=ph2&gt;&lt;/ref&gt;

Ikosi uNyabela Mahlangu watjhaphululwa ngo 1903, ngokuphelakwe miraro yokubanga iphasi yamaBhunu namaNgesi (ngo 1899 - 1902), begodu wahlongakala. Ikosi eyalandela, yalinga ukubawa bona irhulumende ibuyise inarha yabo, kodwana kwabala. 

Indlu yobukhosi nesitjhaba yathenga inarha ngo 1922 lapho isitjhaba sakwaNdzundza sabuya sahlangana khona. Ngaphasi kombuso wezamakhaya (bantustan or homeland) amandebele (Abakwa Manala nabakwNdzundza boke) atjhingiselwa kwandebele ngonyaka ka 1979. Kulapha batholakana khulu nanjenganje.&lt;ref name=ph1&gt;&lt;/ref&gt;

== Umlando womlomo ==
Abanye bathi ukuthoma kwebizo lamandebele kusuka ebasuthwuni, bathi &quot;ngamathebe telele&quot;, okutjho bona ngabantu abaphatha izihlangu ezide. Bathoma bafujanisa ibizole bathi ngamandebele (Matebele).

==Isithasiselo==
&lt;references/&gt;
</text>
      <sha1>phl5klfts68mmwrme73xb7o2qqaixq9</sha1>
    </revision>
    <revision>
      <id>1487</id>
      <parentid>1486</parentid>
      <timestamp>2024-03-09T08:30:08Z</timestamp>
      <contributor>
        <username>incubator&gt;Mzwakhe David18</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>edited</comment>
      <origin>1487</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4300" sha1="5tb2bp3gel1wa3r84glitejldjvcna1" xml:space="preserve">{{Ethnic group
|Ubutjhaba = AbaNdebele
|isithombe = Ndebele-women-loopspruit.jpg
|umtlolo   = Abomma base Loopspruit Cultural Village, ngase[[Bronkhorstspruit, Gauteng|Bronkhorstspruit]]
|Ubuningi  = 1.1 million (2011 Census)
|Amaphrovinci = [[Mpumalanga]], [[Gauteng]] ne [[Limpopo Province]]
|Amalimi   = IsiNdebele
|Ikolo     = [[Isikreste]], [[Amasiko]]
|Bahlobane = [[Nguni|AbaNguni]]
}}
[[Isimumathi:Mapoch.- Femmes Ndebele in Cultural Village (2).jpg|alt=kwandebel|thumb|Abomma bamandebele]]
'''Amandebele''' Kusitjhaba sabantu esitholakala enarheni yesewula afrika. Isitjhaba le sihlukaniswa ngeeqhema ezimbili, ekunga bakwaManala begodu nabakwaNdzundza. &lt;ref name=ph1&gt;&quot;[http://www.sahistory.org.za/article/people-south-africa-ndebele People of South Africa: Ndebele ]&quot; (27-Oct-2014) - '''South African History Online'''. Retrieved 25 February 2016&lt;/ref&gt;

Umlando wamandebele uthoma ngekosi uMafana. Ikosi umafana walandelwa nguMhlanga owabeletha uMusi. Ikosi Umusa yathatha igandango bonyana akhambe achiye abachana bakhe oyekuhlala Kwamnyamana ngase Rhawuteni. Khonapho isitjhaba sahlukana phakathi ngabakwaManala begodu nabakwaNdzundza iinkosi ezhloniphekileko.

__TOC__

== Umlando: 1600 - 1880 ==
Ngesikhathi ikosi uMusi a thlogakala ngonyaka ka 1630, kwavuka umraro wokulwela ubukosi ebatwaneni bakhe uManala no Nzunza. Lomraro wahlukanisa isitjhaba samandebele esewula (AbakwaManala) namandebele etlhagwini (abakwaNdzundza nabakwaMthombeni). 

Unzuza noMthombeni bakhamba beya ngase Pumalanga batjhinga bakha KwaSimkhulu, etlhagwini leBelfast ngase Pumalanga. Kodwana uMthombeni waragela phambili wanyuka nenarha ngomlambu we Olifant waya ngase tlhagwini begodu wakha ngase Zebediela eLipompo. Umthombeni wathoma wabizwa ngokuthi nguGegana (namkha uKekana).&lt;ref name=ph1&gt;&lt;/ref&gt;

&lt;blockquote class=&quot;toccolours&quot; style=&quot;float:none; padding: 10px 15px 10px 15px; display:table;&quot;&gt;Ngesikhathi kwaMaza kubusa ikosi uMagodongo, kwafika uMzilikazi abaleke kwaZulu ngestanga sezipi zakaShaka. UMzilikazi wafika wasahlela uMagodongo nesitjhaba sakhe. Uthe bona abulale uMagodongo uMzilikazi, wathumba ifuyo nabafazi wanyuka nenarha watjhinga eTlhagwini, waze wayokunzinza eRhodesia esele yaziwa ngeZimbabwe namhlanje. UMzilikazi wathi nakasahlela uMagodongo kwabe sele adlule ngakuManala, abulele uSbindi. --([[Skhosana]], 1996, 8)&lt;/blockquote&gt;

Ngo 1883, ngesikhathi kubusa uMabhongo kwathoma ipiyombango yabakwaNdzundza namabhulu, bebanga iphasi, amanzi nefuyo. Amabhunawo abeholwa ngu Piet Joubert ahlasela isitjhaba sabandundza iinyanga ezibunane, bonyana uMabhongo nabantu bakhe baveleleke ezintabeni zangase Roossenekal. Amabutho kaMabhongo akwazi bona atjhinge ngemva kwamabhunu ayokukha amazi neziliwo. Kodwana ngemva kukuthumba nokutlhorisa abafazi, omunye wabo watjho bona ikosi uMabhongo ingaphi. Amabhunu akgona ukusahlela athumba ikosi.&lt;ref name=ph2&gt;&quot;[http://www.encyclopedia.com Ndebele]&quot; (1996) - '''Encyclopedia of World Cultures.''' -Van Vuuren, Chris. Retrieved 25 February 2016&lt;/ref&gt;

==Umlando: 1880 - 1994==
Imiraro yobukhosi bakwandebele yaragela phambili ngaphasi kwe kosi uNyabela. AbakwaNdzundza balahlekelwa ubukhosi ngitjho nephasi labo, begodu nekosi uNyabela yavalelwa udilika-jele. Amandebele asabalala nenarha, abangamarhoba ngaphasi kwamaplasi amabhunu iminyaka emihlanu (1883 - 1888). Amakhosi akwaManala khange angenele imiraro le begodu isitjhaba sakaManala sakha KoMjekejeke ngase Wallmannsthal, enarheni abayiphiwa zizithunywa zase Berlin.&lt;ref name=ph2&gt;&lt;/ref&gt;

Ikosi uNyabela Mahlangu watjhaphululwa ngo 1903, ngokuphelakwe miraro yokubanga iphasi yamaBhunu namaNgesi (ngo 1899 - 1902), begodu wahlongakala. Ikosi eyalandela, yalinga ukubawa bona irhulumende ibuyise inarha yabo, kodwana kwabala. 

Indlu yobukhosi nesitjhaba yathenga inarha ngo 1922 lapho isitjhaba sakwaNdzundza sabuya sahlangana khona. Ngaphasi kombuso wezamakhaya (bantustan or homeland) amandebele (Abakwa Manala nabakwNdzundza boke) atjhingiselwa kwandebele ngonyaka ka 1979. Kulapha batholakana khulu nanjenganje.&lt;ref name=ph1&gt;&lt;/ref&gt;

== Umlando womlomo ==
Abanye bathi ukuthoma kwebizo lamandebele kusuka ebasuthwuni, bathi &quot;ngamathebe telele&quot;, okutjho bona ngabantu abaphatha izihlangu ezide. Bathoma bafujanisa ibizole bathi ngamandebele (Matebele).

==Isithasiselo==
&lt;references/&gt;
</text>
      <sha1>5tb2bp3gel1wa3r84glitejldjvcna1</sha1>
    </revision>
    <revision>
      <id>1488</id>
      <parentid>1487</parentid>
      <timestamp>2024-04-11T10:17:01Z</timestamp>
      <contributor>
        <username>incubator&gt;PHEELL</username>
        <id>0</id>
      </contributor>
      <origin>1488</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4305" sha1="1rjpihjvtjeg4fj3pt8lbhw93mjalmn" xml:space="preserve">{{Ethnic group
|Ubutjhaba = AbaNdebele
|isithombe = Ndebele-women-loopspruit.jpg
|umtlolo   = Abomma base Loopspruit Cultural Village, ngase[[Bronkhorstspruit, Gauteng|Bronkhorstspruit]]
|Ubuningi  = 1.1 million (2011 Census)
|Amaphrovinci = [[Mpumalanga]], [[Gauteng]] ne [[Limpopo Province]]
|Amalimi   = IsiNdebele
|Ikolo     = [[Isikreste]], [[Amasiko]]
|Bahlobane = [[Nguni|AbaNguni]]
}}
[[Isimumathi:Mapoch.- Femmes Ndebele in Cultural Village (2).jpg|alt=kwandebel|thumb|Abomma bamandebele]]
'''AmaNdebele''' kusitjhaba sabantu esitholakala enarheni yeSewula Afrika. Isitjhaba lesi sihlukaniswa ngeeqhema ezimbili, isitjhaba sakwaManala begodu nesakwaNdzundza. &lt;ref name=ph1&gt;&quot;[http://www.sahistory.org.za/article/people-south-africa-ndebele People of South Africa: Ndebele ]&quot; (27-Oct-2014) - '''South African History Online'''. Retrieved 25 February 2016&lt;/ref&gt;

Umlando wamaNdebele uthoma ngekosi uMafana. Ikosi umafana walandelwa nguMhlanga owabeletha uMusi. Ikosi uMusi yathatha igandango bonyana akhambe atjhiye abatjhana bakhe ayokuhlala KwaMnyamana nge-Rhawuteni. Khonapho isitjhaba sahlukana phakathi ngabakwaManala begodu nabakwaNdzundza iinkosi ezhloniphekileko.

__TOC__

== Umlando: 1600 - 1880 ==
Ngesikhathi ikosi uMusi a thlogakala ngonyaka ka 1630, kwavuka umraro wokulwela ubukosi ebatwaneni bakhe uManala no Nzunza. Lomraro wahlukanisa isitjhaba samandebele esewula (AbakwaManala) namandebele etlhagwini (abakwaNdzundza nabakwaMthombeni). 

Unzuza noMthombeni bakhamba beya ngase Pumalanga batjhinga bakha KwaSimkhulu, etlhagwini leBelfast ngase Pumalanga. Kodwana uMthombeni waragela phambili wanyuka nenarha ngomlambu we Olifant waya ngase tlhagwini begodu wakha ngase Zebediela eLipompo. Umthombeni wathoma wabizwa ngokuthi nguGegana (namkha uKekana).&lt;ref name=ph1&gt;&lt;/ref&gt;

&lt;blockquote class=&quot;toccolours&quot; style=&quot;float:none; padding: 10px 15px 10px 15px; display:table;&quot;&gt;Ngesikhathi kwaMaza kubusa ikosi uMagodongo, kwafika uMzilikazi abaleke kwaZulu ngestanga sezipi zakaShaka. UMzilikazi wafika wasahlela uMagodongo nesitjhaba sakhe. Uthe bona abulale uMagodongo uMzilikazi, wathumba ifuyo nabafazi wanyuka nenarha watjhinga eTlhagwini, waze wayokunzinza eRhodesia esele yaziwa ngeZimbabwe namhlanje. UMzilikazi wathi nakasahlela uMagodongo kwabe sele adlule ngakuManala, abulele uSbindi. --([[Skhosana]], 1996, 8)&lt;/blockquote&gt;

Ngo 1883, ngesikhathi kubusa uMabhongo kwathoma ipiyombango yabakwaNdzundza namabhulu, bebanga iphasi, amanzi nefuyo. Amabhunawo abeholwa ngu Piet Joubert ahlasela isitjhaba sabandundza iinyanga ezibunane, bonyana uMabhongo nabantu bakhe baveleleke ezintabeni zangase Roossenekal. Amabutho kaMabhongo akwazi bona atjhinge ngemva kwamabhunu ayokukha amazi neziliwo. Kodwana ngemva kukuthumba nokutlhorisa abafazi, omunye wabo watjho bona ikosi uMabhongo ingaphi. Amabhunu akgona ukusahlela athumba ikosi.&lt;ref name=ph2&gt;&quot;[http://www.encyclopedia.com Ndebele]&quot; (1996) - '''Encyclopedia of World Cultures.''' -Van Vuuren, Chris. Retrieved 25 February 2016&lt;/ref&gt;

==Umlando: 1880 - 1994==
Imiraro yobukhosi bakwandebele yaragela phambili ngaphasi kwe kosi uNyabela. AbakwaNdzundza balahlekelwa ubukhosi ngitjho nephasi labo, begodu nekosi uNyabela yavalelwa udilika-jele. Amandebele asabalala nenarha, abangamarhoba ngaphasi kwamaplasi amabhunu iminyaka emihlanu (1883 - 1888). Amakhosi akwaManala khange angenele imiraro le begodu isitjhaba sakaManala sakha KoMjekejeke ngase Wallmannsthal, enarheni abayiphiwa zizithunywa zase Berlin.&lt;ref name=ph2&gt;&lt;/ref&gt;

Ikosi uNyabela Mahlangu watjhaphululwa ngo 1903, ngokuphelakwe miraro yokubanga iphasi yamaBhunu namaNgesi (ngo 1899 - 1902), begodu wahlongakala. Ikosi eyalandela, yalinga ukubawa bona irhulumende ibuyise inarha yabo, kodwana kwabala. 

Indlu yobukhosi nesitjhaba yathenga inarha ngo 1922 lapho isitjhaba sakwaNdzundza sabuya sahlangana khona. Ngaphasi kombuso wezamakhaya (bantustan or homeland) amandebele (Abakwa Manala nabakwNdzundza boke) atjhingiselwa kwandebele ngonyaka ka 1979. Kulapha batholakana khulu nanjenganje.&lt;ref name=ph1&gt;&lt;/ref&gt;

== Umlando womlomo ==
Abanye bathi ukuthoma kwebizo lamandebele kusuka ebasuthwuni, bathi &quot;ngamathebe telele&quot;, okutjho bona ngabantu abaphatha izihlangu ezide. Bathoma bafujanisa ibizole bathi ngamandebele (Matebele).

==Isithasiselo==
&lt;references/&gt;
</text>
      <sha1>1rjpihjvtjeg4fj3pt8lbhw93mjalmn</sha1>
    </revision>
    <revision>
      <id>1489</id>
      <parentid>1488</parentid>
      <timestamp>2024-10-14T13:47:43Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>25 revisions imported</comment>
      <origin>1488</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4305" sha1="1rjpihjvtjeg4fj3pt8lbhw93mjalmn" xml:space="preserve">{{Ethnic group
|Ubutjhaba = AbaNdebele
|isithombe = Ndebele-women-loopspruit.jpg
|umtlolo   = Abomma base Loopspruit Cultural Village, ngase[[Bronkhorstspruit, Gauteng|Bronkhorstspruit]]
|Ubuningi  = 1.1 million (2011 Census)
|Amaphrovinci = [[Mpumalanga]], [[Gauteng]] ne [[Limpopo Province]]
|Amalimi   = IsiNdebele
|Ikolo     = [[Isikreste]], [[Amasiko]]
|Bahlobane = [[Nguni|AbaNguni]]
}}
[[Isimumathi:Mapoch.- Femmes Ndebele in Cultural Village (2).jpg|alt=kwandebel|thumb|Abomma bamandebele]]
'''AmaNdebele''' kusitjhaba sabantu esitholakala enarheni yeSewula Afrika. Isitjhaba lesi sihlukaniswa ngeeqhema ezimbili, isitjhaba sakwaManala begodu nesakwaNdzundza. &lt;ref name=ph1&gt;&quot;[http://www.sahistory.org.za/article/people-south-africa-ndebele People of South Africa: Ndebele ]&quot; (27-Oct-2014) - '''South African History Online'''. Retrieved 25 February 2016&lt;/ref&gt;

Umlando wamaNdebele uthoma ngekosi uMafana. Ikosi umafana walandelwa nguMhlanga owabeletha uMusi. Ikosi uMusi yathatha igandango bonyana akhambe atjhiye abatjhana bakhe ayokuhlala KwaMnyamana nge-Rhawuteni. Khonapho isitjhaba sahlukana phakathi ngabakwaManala begodu nabakwaNdzundza iinkosi ezhloniphekileko.

__TOC__

== Umlando: 1600 - 1880 ==
Ngesikhathi ikosi uMusi a thlogakala ngonyaka ka 1630, kwavuka umraro wokulwela ubukosi ebatwaneni bakhe uManala no Nzunza. Lomraro wahlukanisa isitjhaba samandebele esewula (AbakwaManala) namandebele etlhagwini (abakwaNdzundza nabakwaMthombeni). 

Unzuza noMthombeni bakhamba beya ngase Pumalanga batjhinga bakha KwaSimkhulu, etlhagwini leBelfast ngase Pumalanga. Kodwana uMthombeni waragela phambili wanyuka nenarha ngomlambu we Olifant waya ngase tlhagwini begodu wakha ngase Zebediela eLipompo. Umthombeni wathoma wabizwa ngokuthi nguGegana (namkha uKekana).&lt;ref name=ph1&gt;&lt;/ref&gt;

&lt;blockquote class=&quot;toccolours&quot; style=&quot;float:none; padding: 10px 15px 10px 15px; display:table;&quot;&gt;Ngesikhathi kwaMaza kubusa ikosi uMagodongo, kwafika uMzilikazi abaleke kwaZulu ngestanga sezipi zakaShaka. UMzilikazi wafika wasahlela uMagodongo nesitjhaba sakhe. Uthe bona abulale uMagodongo uMzilikazi, wathumba ifuyo nabafazi wanyuka nenarha watjhinga eTlhagwini, waze wayokunzinza eRhodesia esele yaziwa ngeZimbabwe namhlanje. UMzilikazi wathi nakasahlela uMagodongo kwabe sele adlule ngakuManala, abulele uSbindi. --([[Skhosana]], 1996, 8)&lt;/blockquote&gt;

Ngo 1883, ngesikhathi kubusa uMabhongo kwathoma ipiyombango yabakwaNdzundza namabhulu, bebanga iphasi, amanzi nefuyo. Amabhunawo abeholwa ngu Piet Joubert ahlasela isitjhaba sabandundza iinyanga ezibunane, bonyana uMabhongo nabantu bakhe baveleleke ezintabeni zangase Roossenekal. Amabutho kaMabhongo akwazi bona atjhinge ngemva kwamabhunu ayokukha amazi neziliwo. Kodwana ngemva kukuthumba nokutlhorisa abafazi, omunye wabo watjho bona ikosi uMabhongo ingaphi. Amabhunu akgona ukusahlela athumba ikosi.&lt;ref name=ph2&gt;&quot;[http://www.encyclopedia.com Ndebele]&quot; (1996) - '''Encyclopedia of World Cultures.''' -Van Vuuren, Chris. Retrieved 25 February 2016&lt;/ref&gt;

==Umlando: 1880 - 1994==
Imiraro yobukhosi bakwandebele yaragela phambili ngaphasi kwe kosi uNyabela. AbakwaNdzundza balahlekelwa ubukhosi ngitjho nephasi labo, begodu nekosi uNyabela yavalelwa udilika-jele. Amandebele asabalala nenarha, abangamarhoba ngaphasi kwamaplasi amabhunu iminyaka emihlanu (1883 - 1888). Amakhosi akwaManala khange angenele imiraro le begodu isitjhaba sakaManala sakha KoMjekejeke ngase Wallmannsthal, enarheni abayiphiwa zizithunywa zase Berlin.&lt;ref name=ph2&gt;&lt;/ref&gt;

Ikosi uNyabela Mahlangu watjhaphululwa ngo 1903, ngokuphelakwe miraro yokubanga iphasi yamaBhunu namaNgesi (ngo 1899 - 1902), begodu wahlongakala. Ikosi eyalandela, yalinga ukubawa bona irhulumende ibuyise inarha yabo, kodwana kwabala. 

Indlu yobukhosi nesitjhaba yathenga inarha ngo 1922 lapho isitjhaba sakwaNdzundza sabuya sahlangana khona. Ngaphasi kombuso wezamakhaya (bantustan or homeland) amandebele (Abakwa Manala nabakwNdzundza boke) atjhingiselwa kwandebele ngonyaka ka 1979. Kulapha batholakana khulu nanjenganje.&lt;ref name=ph1&gt;&lt;/ref&gt;

== Umlando womlomo ==
Abanye bathi ukuthoma kwebizo lamandebele kusuka ebasuthwuni, bathi &quot;ngamathebe telele&quot;, okutjho bona ngabantu abaphatha izihlangu ezide. Bathoma bafujanisa ibizole bathi ngamandebele (Matebele).

==Isithasiselo==
&lt;references/&gt;
</text>
      <sha1>1rjpihjvtjeg4fj3pt8lbhw93mjalmn</sha1>
    </revision>
    <revision>
      <id>2206</id>
      <parentid>1489</parentid>
      <timestamp>2024-11-29T07:27:55Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <comment>/* Isithasiselo */Reflist</comment>
      <origin>2206</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4302" sha1="877tq9pvd4rk66di1nzwen3deann4ht" xml:space="preserve">{{Ethnic group
|Ubutjhaba = AbaNdebele
|isithombe = Ndebele-women-loopspruit.jpg
|umtlolo   = Abomma base Loopspruit Cultural Village, ngase[[Bronkhorstspruit, Gauteng|Bronkhorstspruit]]
|Ubuningi  = 1.1 million (2011 Census)
|Amaphrovinci = [[Mpumalanga]], [[Gauteng]] ne [[Limpopo Province]]
|Amalimi   = IsiNdebele
|Ikolo     = [[Isikreste]], [[Amasiko]]
|Bahlobane = [[Nguni|AbaNguni]]
}}
[[Isimumathi:Mapoch.- Femmes Ndebele in Cultural Village (2).jpg|alt=kwandebel|thumb|Abomma bamandebele]]
'''AmaNdebele''' kusitjhaba sabantu esitholakala enarheni yeSewula Afrika. Isitjhaba lesi sihlukaniswa ngeeqhema ezimbili, isitjhaba sakwaManala begodu nesakwaNdzundza. &lt;ref name=ph1&gt;&quot;[http://www.sahistory.org.za/article/people-south-africa-ndebele People of South Africa: Ndebele ]&quot; (27-Oct-2014) - '''South African History Online'''. Retrieved 25 February 2016&lt;/ref&gt;

Umlando wamaNdebele uthoma ngekosi uMafana. Ikosi umafana walandelwa nguMhlanga owabeletha uMusi. Ikosi uMusi yathatha igandango bonyana akhambe atjhiye abatjhana bakhe ayokuhlala KwaMnyamana nge-Rhawuteni. Khonapho isitjhaba sahlukana phakathi ngabakwaManala begodu nabakwaNdzundza iinkosi ezhloniphekileko.

__TOC__

== Umlando: 1600 - 1880 ==
Ngesikhathi ikosi uMusi a thlogakala ngonyaka ka 1630, kwavuka umraro wokulwela ubukosi ebatwaneni bakhe uManala no Nzunza. Lomraro wahlukanisa isitjhaba samandebele esewula (AbakwaManala) namandebele etlhagwini (abakwaNdzundza nabakwaMthombeni). 

Unzuza noMthombeni bakhamba beya ngase Pumalanga batjhinga bakha KwaSimkhulu, etlhagwini leBelfast ngase Pumalanga. Kodwana uMthombeni waragela phambili wanyuka nenarha ngomlambu we Olifant waya ngase tlhagwini begodu wakha ngase Zebediela eLipompo. Umthombeni wathoma wabizwa ngokuthi nguGegana (namkha uKekana).&lt;ref name=ph1&gt;&lt;/ref&gt;

&lt;blockquote class=&quot;toccolours&quot; style=&quot;float:none; padding: 10px 15px 10px 15px; display:table;&quot;&gt;Ngesikhathi kwaMaza kubusa ikosi uMagodongo, kwafika uMzilikazi abaleke kwaZulu ngestanga sezipi zakaShaka. UMzilikazi wafika wasahlela uMagodongo nesitjhaba sakhe. Uthe bona abulale uMagodongo uMzilikazi, wathumba ifuyo nabafazi wanyuka nenarha watjhinga eTlhagwini, waze wayokunzinza eRhodesia esele yaziwa ngeZimbabwe namhlanje. UMzilikazi wathi nakasahlela uMagodongo kwabe sele adlule ngakuManala, abulele uSbindi. --([[Skhosana]], 1996, 8)&lt;/blockquote&gt;

Ngo 1883, ngesikhathi kubusa uMabhongo kwathoma ipiyombango yabakwaNdzundza namabhulu, bebanga iphasi, amanzi nefuyo. Amabhunawo abeholwa ngu Piet Joubert ahlasela isitjhaba sabandundza iinyanga ezibunane, bonyana uMabhongo nabantu bakhe baveleleke ezintabeni zangase Roossenekal. Amabutho kaMabhongo akwazi bona atjhinge ngemva kwamabhunu ayokukha amazi neziliwo. Kodwana ngemva kukuthumba nokutlhorisa abafazi, omunye wabo watjho bona ikosi uMabhongo ingaphi. Amabhunu akgona ukusahlela athumba ikosi.&lt;ref name=ph2&gt;&quot;[http://www.encyclopedia.com Ndebele]&quot; (1996) - '''Encyclopedia of World Cultures.''' -Van Vuuren, Chris. Retrieved 25 February 2016&lt;/ref&gt;

==Umlando: 1880 - 1994==
Imiraro yobukhosi bakwandebele yaragela phambili ngaphasi kwe kosi uNyabela. AbakwaNdzundza balahlekelwa ubukhosi ngitjho nephasi labo, begodu nekosi uNyabela yavalelwa udilika-jele. Amandebele asabalala nenarha, abangamarhoba ngaphasi kwamaplasi amabhunu iminyaka emihlanu (1883 - 1888). Amakhosi akwaManala khange angenele imiraro le begodu isitjhaba sakaManala sakha KoMjekejeke ngase Wallmannsthal, enarheni abayiphiwa zizithunywa zase Berlin.&lt;ref name=ph2&gt;&lt;/ref&gt;

Ikosi uNyabela Mahlangu watjhaphululwa ngo 1903, ngokuphelakwe miraro yokubanga iphasi yamaBhunu namaNgesi (ngo 1899 - 1902), begodu wahlongakala. Ikosi eyalandela, yalinga ukubawa bona irhulumende ibuyise inarha yabo, kodwana kwabala. 

Indlu yobukhosi nesitjhaba yathenga inarha ngo 1922 lapho isitjhaba sakwaNdzundza sabuya sahlangana khona. Ngaphasi kombuso wezamakhaya (bantustan or homeland) amandebele (Abakwa Manala nabakwNdzundza boke) atjhingiselwa kwandebele ngonyaka ka 1979. Kulapha batholakana khulu nanjenganje.&lt;ref name=ph1&gt;&lt;/ref&gt;

== Umlando womlomo ==
Abanye bathi ukuthoma kwebizo lamandebele kusuka ebasuthwuni, bathi &quot;ngamathebe telele&quot;, okutjho bona ngabantu abaphatha izihlangu ezide. Bathoma bafujanisa ibizole bathi ngamandebele (Matebele).

==Isithasiselo==
{{Reflist}}</text>
      <sha1>877tq9pvd4rk66di1nzwen3deann4ht</sha1>
    </revision>
    <revision>
      <id>2794</id>
      <parentid>2206</parentid>
      <timestamp>2025-05-03T12:10:51Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>/* Umlando: 1600 - 1880 */ I edited a few punctuation errors.</comment>
      <origin>2794</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4338" sha1="qd2ohm99hpbwah1bwtpdjsx50fyn7ou" xml:space="preserve">{{Ethnic group
|Ubutjhaba = AbaNdebele
|isithombe = Ndebele-women-loopspruit.jpg
|umtlolo   = Abomma base Loopspruit Cultural Village, ngase[[Bronkhorstspruit, Gauteng|Bronkhorstspruit]]
|Ubuningi  = 1.1 million (2011 Census)
|Amaphrovinci = [[Mpumalanga]], [[Gauteng]] ne [[Limpopo Province]]
|Amalimi   = IsiNdebele
|Ikolo     = [[Isikreste]], [[Amasiko]]
|Bahlobane = [[Nguni|AbaNguni]]
}}
[[Isimumathi:Mapoch.- Femmes Ndebele in Cultural Village (2).jpg|alt=kwandebel|thumb|Abomma bamandebele]]
'''AmaNdebele''' kusitjhaba sabantu esitholakala enarheni yeSewula Afrika. Isitjhaba lesi sihlukaniswa ngeeqhema ezimbili, isitjhaba sakwaManala begodu nesakwaNdzundza. &lt;ref name=ph1&gt;&quot;[http://www.sahistory.org.za/article/people-south-africa-ndebele People of South Africa: Ndebele ]&quot; (27-Oct-2014) - '''South African History Online'''. Retrieved 25 February 2016&lt;/ref&gt;

Umlando wamaNdebele uthoma ngekosi uMafana. Ikosi umafana walandelwa nguMhlanga owabeletha uMusi. Ikosi uMusi yathatha igandango bonyana akhambe atjhiye abatjhana bakhe ayokuhlala KwaMnyamana nge-Rhawuteni. Khonapho isitjhaba sahlukana phakathi ngabakwaManala begodu nabakwaNdzundza iinkosi ezhloniphekileko.

__TOC__

== Umlando: 1600 - 1880 ==
Ngesikhathi ingwenyama uMusi ahlongakala ngonyaka ka 1630, kwavuka umraro wokulwela ubukosi ebatwaneni bakhe uManala no Ndzundza. Lomraro wahlukanisa isitjhaba samandebele esewula (AbakwaManala) namandebele etlhagwini (abakwaNdzundza nabakwaMthombeni). 

UNdzundza noMthombeni bakhamba beya ngase Pumalanga batjhinga bakha KwaSimkhulu, etlhagwini leBelfast ngase Pumalanga. Kodwana uMthombeni waragela phambili wanyuka nenarha ngomlambu we Olifant waya ngase tlhagwini begodu wakha ngase Zebediela eLipompo. Umthombeni wathoma wabizwa ngokuthi nguGegana (namkha uKekana).&lt;ref name=ph1&gt;&lt;/ref&gt;

&lt;blockquote class=&quot;toccolours&quot; style=&quot;float:none; padding: 10px 15px 10px 15px; display:table;&quot;&gt;Ngesikhathi kwaMaza kubusa ingwenyama uMagodongo, kwafika uMzilikazi abaleke kwaZulu ngesimanga sezipi zakaShaka. UMzilikazi wafika wasahlela uMagodongo nesitjhaba sakhe. Uthe bona abulale uMagodongo uMzilikazi, wathumba ifuyo nabafazi wanyuka nenarha watjhinga eTlhagwini, waze wayokunzinza eRhodesia esele yaziwa ngeZimbabwe namhlanje. UMzilikazi wathi nakasahlela uMagodongo kwabe sele adlule ngakuManala, abulele uSbindi. --([[Skhosana]], 1996, 8)&lt;/blockquote&gt;

Ngo 1883, ngesikhathi kubusa uMabhongo kwathoma ipiyombango yabakwaNdzundza namabhuru,bebanga iphasi, amanzi nefuyo. Amabhunawo abedoswa phambili ngu Piet Joubert ahlasela isitjhaba sakwadundza iinyanga ezibunane, bonyana uMabhongo nabantu bakhe bavaleleke ezintabeni zangase Roossenekal. Amabutho kaMabhongo akwazi bona atjhinge ngemva kwamabhunu ayokukha amazi neziliwo. Kodwana ngemva kukuthumba nokutlhorisa abafazi, omunye wabo watjho bona ingwenyama uMabhongo ingakuphi. Amabhunu akghona ukusahlela athumba ingwenyama.&lt;ref name=ph2&gt;&quot;[http://www.encyclopedia.com Ndebele]&quot; (1996) - '''Encyclopedia of World Cultures.''' -Van Vuuren, Chris. Retrieved 25 February 2016&lt;/ref&gt;

==Umlando: 1880 - 1994==
Imiraro yobukhosi bakwandebele yaragela phambili ngaphasi kwe kosi uNyabela. AbakwaNdzundza balahlekelwa ubukhosi ngitjho nephasi labo, begodu nekosi uNyabela yavalelwa udilika-jele. Amandebele asabalala nenarha, abangamarhoba ngaphasi kwamaplasi amabhunu iminyaka emihlanu (1883 - 1888). Amakhosi akwaManala khange angenele imiraro le begodu isitjhaba sakaManala sakha KoMjekejeke ngase Wallmannsthal, enarheni abayiphiwa zizithunywa zase Berlin.&lt;ref name=ph2&gt;&lt;/ref&gt;

Ikosi uNyabela Mahlangu watjhaphululwa ngo 1903, ngokuphelakwe miraro yokubanga iphasi yamaBhunu namaNgesi (ngo 1899 - 1902), begodu wahlongakala. Ikosi eyalandela, yalinga ukubawa bona irhulumende ibuyise inarha yabo, kodwana kwabala. 

Indlu yobukhosi nesitjhaba yathenga inarha ngo 1922 lapho isitjhaba sakwaNdzundza sabuya sahlangana khona. Ngaphasi kombuso wezamakhaya (bantustan or homeland) amandebele (Abakwa Manala nabakwNdzundza boke) atjhingiselwa kwandebele ngonyaka ka 1979. Kulapha batholakana khulu nanjenganje.&lt;ref name=ph1&gt;&lt;/ref&gt;

== Umlando womlomo ==
Abanye bathi ukuthoma kwebizo lamandebele kusuka ebasuthwuni, bathi &quot;ngamathebe telele&quot;, okutjho bona ngabantu abaphatha izihlangu ezide. Bathoma bafujanisa ibizole bathi ngamandebele (Matebele).

==Isithasiselo==
{{Reflist}}</text>
      <sha1>qd2ohm99hpbwah1bwtpdjsx50fyn7ou</sha1>
    </revision>
    <revision>
      <id>3509</id>
      <parentid>2794</parentid>
      <timestamp>2025-07-30T13:25:51Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>3509</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4364" sha1="0gge77nkwbx6p1u32apwr54gt730mr0" xml:space="preserve">{{Ethnic group
|Ubutjhaba = AbaNdebele
|isithombe = Ndebele-women-loopspruit.jpg
|umtlolo   = Abomma base Loopspruit Cultural Village, ngase[[Bronkhorstspruit, Gauteng|Bronkhorstspruit]]
|Ubuningi  = 1.1 million (2011 Census)
|Amaphrovinci = [[Mpumalanga]], [[Gauteng]] ne [[Limpopo Province]]
|Amalimi   = IsiNdebele
|Ikolo     = [[Isikreste]], [[Amasiko]]
|Bahlobane = [[Nguni|AbaNguni]]
}}
[[Isimumathi:Mapoch.- Femmes Ndebele in Cultural Village (2).jpg|alt=kwandebel|thumb|Abomma bamandebele]]
'''AmaNdebele''' kusitjhaba sabantu esitholakala enarheni yeSewula Afrika. Isitjhaba lesi sihlukaniswa ngeeqhema ezimbili, isitjhaba sakwaManala begodu nesakwaNdzundza. &lt;ref name=ph1&gt;&quot;[http://www.sahistory.org.za/article/people-south-africa-ndebele People of South Africa: Ndebele ]&quot; (27-Oct-2014) - '''South African History Online'''. Retrieved 25 February 2016&lt;/ref&gt;

Umlando wamaNdebele uthoma ngekosi uMafana. Ikosi umafana walandelwa nguMhlanga owabeletha uMusi. Ikosi uMusi yathatha igandango bonyana akhambe atjhiye abatjhana bakhe ayokuhlala KwaMnyamana nge-Rhawuteni. Khonapho isitjhaba sahlukana phakathi ngabakwaManala begodu nabakwaNdzundza iinkosi ezhloniphekileko.

__TOC__

== Umlando: 1600 - 1880 ==
Ngesikhathi ingwenyama uMusi ahlongakala ngonyaka ka 1630, kwavuka umraro wokulwela ubukosi ebatwaneni bakhe uManala no Ndzundza. Lomraro wahlukanisa isitjhaba samandebele esewula (AbakwaManala) namandebele etlhagwini (abakwaNdzundza nabakwaMthombeni). 

UNdzundza noMthombeni bakhamba beya ngase Pumalanga batjhinga bakha KwaSimkhulu, etlhagwini leBelfast ngase Pumalanga. Kodwana uMthombeni waragela phambili wanyuka nenarha ngomlambu we Olifant waya ngase tlhagwini begodu wakha ngase Zebediela eLipompo. Umthombeni wathoma wabizwa ngokuthi nguGegana (namkha uKekana).&lt;ref name=ph1&gt;&lt;/ref&gt;

&lt;blockquote class=&quot;toccolours&quot; style=&quot;float:none; padding: 10px 15px 10px 15px; display:table;&quot;&gt;Ngesikhathi kwaMaza kubusa ingwenyama [[INgwenyama UMagodongo|uMagodongo]], kwafika uMzilikazi abaleke kwaZulu ngesimanga sezipi zakaShaka. UMzilikazi wafika wasahlela uMagodongo nesitjhaba sakhe. Uthe bona abulale uMagodongo uMzilikazi, wathumba ifuyo nabafazi wanyuka nenarha watjhinga eTlhagwini, waze wayokunzinza eRhodesia esele yaziwa ngeZimbabwe namhlanje. UMzilikazi wathi nakasahlela uMagodongo kwabe sele adlule ngakuManala, abulele uSbindi. --([[Skhosana]], 1996, 8)&lt;/blockquote&gt;

Ngo 1883, ngesikhathi kubusa uMabhongo kwathoma ipiyombango yabakwaNdzundza namabhuru,bebanga iphasi, amanzi nefuyo. Amabhunawo abedoswa phambili ngu Piet Joubert ahlasela isitjhaba sakwadundza iinyanga ezibunane, bonyana uMabhongo nabantu bakhe bavaleleke ezintabeni zangase Roossenekal. Amabutho kaMabhongo akwazi bona atjhinge ngemva kwamabhunu ayokukha amazi neziliwo. Kodwana ngemva kukuthumba nokutlhorisa abafazi, omunye wabo watjho bona ingwenyama uMabhongo ingakuphi. Amabhunu akghona ukusahlela athumba ingwenyama.&lt;ref name=ph2&gt;&quot;[http://www.encyclopedia.com Ndebele]&quot; (1996) - '''Encyclopedia of World Cultures.''' -Van Vuuren, Chris. Retrieved 25 February 2016&lt;/ref&gt;

==Umlando: 1880 - 1994==
Imiraro yobukhosi bakwandebele yaragela phambili ngaphasi kwe kosi uNyabela. AbakwaNdzundza balahlekelwa ubukhosi ngitjho nephasi labo, begodu nekosi uNyabela yavalelwa udilika-jele. Amandebele asabalala nenarha, abangamarhoba ngaphasi kwamaplasi amabhunu iminyaka emihlanu (1883 - 1888). Amakhosi akwaManala khange angenele imiraro le begodu isitjhaba sakaManala sakha KoMjekejeke ngase Wallmannsthal, enarheni abayiphiwa zizithunywa zase Berlin.&lt;ref name=ph2&gt;&lt;/ref&gt;

Ikosi uNyabela Mahlangu watjhaphululwa ngo 1903, ngokuphelakwe miraro yokubanga iphasi yamaBhunu namaNgesi (ngo 1899 - 1902), begodu wahlongakala. Ikosi eyalandela, yalinga ukubawa bona irhulumende ibuyise inarha yabo, kodwana kwabala. 

Indlu yobukhosi nesitjhaba yathenga inarha ngo 1922 lapho isitjhaba sakwaNdzundza sabuya sahlangana khona. Ngaphasi kombuso wezamakhaya (bantustan or homeland) amandebele (Abakwa Manala nabakwNdzundza boke) atjhingiselwa kwandebele ngonyaka ka 1979. Kulapha batholakana khulu nanjenganje.&lt;ref name=ph1&gt;&lt;/ref&gt;

== Umlando womlomo ==
Abanye bathi ukuthoma kwebizo lamandebele kusuka ebasuthwuni, bathi &quot;ngamathebe telele&quot;, okutjho bona ngabantu abaphatha izihlangu ezide. Bathoma bafujanisa ibizole bathi ngamandebele (Matebele).

==Isithasiselo==
{{Reflist}}</text>
      <sha1>0gge77nkwbx6p1u32apwr54gt730mr0</sha1>
    </revision>
    <revision>
      <id>5071</id>
      <parentid>3509</parentid>
      <timestamp>2025-08-08T08:10:19Z</timestamp>
      <contributor>
        <username>Mpho F Mahlangu</username>
        <id>838</id>
      </contributor>
      <comment>grammar</comment>
      <origin>5071</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4366" sha1="8zxqy2a5nmgkw5dm9mdooyfcjf7c9zm" xml:space="preserve">{{Ethnic group
|Ubutjhaba = AbaNdebele
|isithombe = Ndebele-women-loopspruit.jpg
|umtlolo   = Abomma base Loopspruit Cultural Village, ngase[[Bronkhorstspruit, Gauteng|Bronkhorstspruit]]
|Ubuningi  = 1.1 million (2011 Census)
|Amaphrovinci = [[Mpumalanga]], [[Gauteng]] ne [[Limpopo Province]]
|Amalimi   = IsiNdebele
|Ikolo     = [[Isikreste]], [[Amasiko]]
|Bahlobane = [[Nguni|AbaNguni]]
}}
[[Isimumathi:Mapoch.- Femmes Ndebele in Cultural Village (2).jpg|alt=kwandebel|thumb|Abomma bamandebele]]
'''AmaNdebele''' kusitjhaba sabantu esitholakala enarheni yeSewula Afrika. Isitjhaba lesi sihlukaniswa ngeenqhema ezimbili, isitjhaba sakwaManala begodu nesakwaNdzundza. &lt;ref name=ph1&gt;&quot;[http://www.sahistory.org.za/article/people-south-africa-ndebele People of South Africa: Ndebele ]&quot; (27-Oct-2014) - '''South African History Online'''. Retrieved 25 February 2016&lt;/ref&gt;

Umlando wamaNdebele uthoma ngekosi uMafana. Ikosi uMafana walandelwa nguMhlanga owabeletha uMusi. Ikosi uMusi yathatha igandango bonyana akhambe atjhiye abatjhana bakhe ayokuhlala KwaMnyamana nge-Rhawuteni. Khonapho isitjhaba sahlukana phakathi ngabakwaManala begodu nabakwaNdzundza iinkosi ezihloniphekileko.

__TOC__

== Umlando: 1600 - 1880 ==
Ngesikhathi ingwenyama uMusi ahlongakala ngonyaka ka 1630, kwavuka umraro wokulwela ubukosi ebatwaneni bakhe uManala no Ndzundza. Lomraro wahlukanisa isitjhaba samandebele esewula (AbakwaManala) namandebele etlhagwini (abakwaNdzundza nabakwaMthombeni). 

UNdzundza noMthombeni bakhamba beya ngase Pumalanga batjhinga bakha KwaSimkhulu, etlhagwini leBelfast ngase Pumalanga. Kodwana uMthombeni waragela phambili wanyuka nenarha ngomlambu we Olifant waya ngase tlhagwini begodu wakha ngase Zebediela eLipompo. Umthombeni wathoma wabizwa ngokuthi nguGegana (namkha uKekana).&lt;ref name=ph1&gt;&lt;/ref&gt;

&lt;blockquote class=&quot;toccolours&quot; style=&quot;float:none; padding: 10px 15px 10px 15px; display:table;&quot;&gt;Ngesikhathi kwaMaza kubusa ingwenyama [[INgwenyama UMagodongo|uMagodongo]], kwafika uMzilikazi abaleke kwaZulu ngesimanga sezipi zakaShaka. UMzilikazi wafika wasahlela uMagodongo nesitjhaba sakhe. Uthe bona abulale uMagodongo uMzilikazi, wathumba ifuyo nabafazi wanyuka nenarha watjhinga eTlhagwini, waze wayokunzinza eRhodesia esele yaziwa ngeZimbabwe namhlanje. UMzilikazi wathi nakasahlela uMagodongo kwabe sele adlule ngakuManala, abulele uSbindi. --([[Skhosana]], 1996, 8)&lt;/blockquote&gt;

Ngo 1883, ngesikhathi kubusa uMabhongo kwathoma ipiyombango yabakwaNdzundza namabhuru,bebanga iphasi, amanzi nefuyo. Amabhunawo abedoswa phambili ngu Piet Joubert ahlasela isitjhaba sakwadundza iinyanga ezibunane, bonyana uMabhongo nabantu bakhe bavaleleke ezintabeni zangase Roossenekal. Amabutho kaMabhongo akwazi bona atjhinge ngemva kwamabhunu ayokukha amazi neziliwo. Kodwana ngemva kukuthumba nokutlhorisa abafazi, omunye wabo watjho bona ingwenyama uMabhongo ingakuphi. Amabhunu akghona ukusahlela athumba ingwenyama.&lt;ref name=ph2&gt;&quot;[http://www.encyclopedia.com Ndebele]&quot; (1996) - '''Encyclopedia of World Cultures.''' -Van Vuuren, Chris. Retrieved 25 February 2016&lt;/ref&gt;

==Umlando: 1880 - 1994==
Imiraro yobukhosi bakwandebele yaragela phambili ngaphasi kwe kosi uNyabela. AbakwaNdzundza balahlekelwa ubukhosi ngitjho nephasi labo, begodu nekosi uNyabela yavalelwa udilika-jele. Amandebele asabalala nenarha, abangamarhoba ngaphasi kwamaplasi amabhunu iminyaka emihlanu (1883 - 1888). Amakhosi akwaManala khange angenele imiraro le begodu isitjhaba sakaManala sakha KoMjekejeke ngase Wallmannsthal, enarheni abayiphiwa zizithunywa zase Berlin.&lt;ref name=ph2&gt;&lt;/ref&gt;

Ikosi uNyabela Mahlangu watjhaphululwa ngo 1903, ngokuphelakwe miraro yokubanga iphasi yamaBhunu namaNgesi (ngo 1899 - 1902), begodu wahlongakala. Ikosi eyalandela, yalinga ukubawa bona irhulumende ibuyise inarha yabo, kodwana kwabala. 

Indlu yobukhosi nesitjhaba yathenga inarha ngo 1922 lapho isitjhaba sakwaNdzundza sabuya sahlangana khona. Ngaphasi kombuso wezamakhaya (bantustan or homeland) amandebele (Abakwa Manala nabakwNdzundza boke) atjhingiselwa kwandebele ngonyaka ka 1979. Kulapha batholakana khulu nanjenganje.&lt;ref name=ph1&gt;&lt;/ref&gt;

== Umlando womlomo ==
Abanye bathi ukuthoma kwebizo lamandebele kusuka ebasuthwuni, bathi &quot;ngamathebe telele&quot;, okutjho bona ngabantu abaphatha izihlangu ezide. Bathoma bafujanisa ibizole bathi ngamandebele (Matebele).

==Isithasiselo==
{{Reflist}}</text>
      <sha1>8zxqy2a5nmgkw5dm9mdooyfcjf7c9zm</sha1>
    </revision>
    <revision>
      <id>5088</id>
      <parentid>5071</parentid>
      <timestamp>2025-08-08T09:19:28Z</timestamp>
      <contributor>
        <username>N Mabhena</username>
        <id>843</id>
      </contributor>
      <origin>5088</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4365" sha1="bk6lkn72qj2vwbdkjlwwnd5fu6ujl8o" xml:space="preserve">{{Ethnic group
|Ubutjhaba = AbaNdebele
|isithombe = Ndebele-women-loopspruit.jpg
|umtlolo   = Abomma base Loopspruit Cultural Village, ngase[[Bronkhorstspruit, Gauteng|Bronkhorstspruit]]
|Ubuningi  = 1.1 million (2011 Census)
|Amaphrovinci = [[Mpumalanga]], [[Gauteng]] ne [[Limpopo Province]]
|Amalimi   = IsiNdebele
|Ikolo     = [[Isikreste]], [[Amasiko]]
|Bahlobane = [[Nguni|AbaNguni]]
}}
[[Isimumathi:Mapoch.- Femmes Ndebele in Cultural Village (2).jpg|alt=kwandebel|thumb|Abomma bamandebele]]
'''AmaNdebele''' kusitjhaba sabantu esitholakala enarheni yeSewula Afrika. Isitjhaba lesi sihlukaniswa ngeenqhema ezimbili, isitjhaba sakwaManala begodu nesakwaNdzundza. &lt;ref name=ph1&gt;&quot;[http://www.sahistory.org.za/article/people-south-africa-ndebele People of South Africa: Ndebele ]&quot; (27-Oct-2014) - '''South African History Online'''. Retrieved 25 February 2016&lt;/ref&gt;

Umlando wamaNdebele uthoma ngekosi uMafana. Ikosi uMafana walandelwa nguMhlanga owabeletha uMusi. Ikosi uMusi yathatha igadango bonyana akhambe atjhiye abatjhana bakhe ayokuhlala KwaMnyamana nge-Rhawuteni. Khonapho isitjhaba sahlukana phakathi ngabakwaManala begodu nabakwaNdzundza iinkosi ezihloniphekileko.

__TOC__

== Umlando: 1600 - 1880 ==
Ngesikhathi ingwenyama uMusi ahlongakala ngonyaka ka 1630, kwavuka umraro wokulwela ubukhosi ebantwaneni bakhe uManala no Ndzundza. Lomraro wahlukanisa isitjhaba samandebele eSewula (AbakwaManala) namandebele eTlhagwini (abakwaNdzundza nabakwaMthombeni). 

UNdzundza noMthombeni bakhamba baya ngase Pumalanga batjhinga bakha KwaSimkhulu, eTlhagwini leBelfast ngase Pumalanga. Kodwana uMthombeni waragela phambili wakhuphuka nenarha ngomlambo we Olifant waya ngase Tlhagwini begodu wakha ngase Zebediela eLimpopo. UMthombeni wathoma wabizwa ngokuthi nguGegana (namkha uKekana).&lt;ref name=ph1&gt;&lt;/ref&gt;

&lt;blockquote class=&quot;toccolours&quot; style=&quot;float:none; padding: 10px 15px 10px 15px; display:table;&quot;&gt;Ngesikhathi kwaMaza kubusa ingwenyama [[INgwenyama UMagodongo|uMagodongo]], kwafika uMzilikazi abaleke kwaZulu ngesibanga sepi kaShaka. UMzilikazi wafika wasahlela uMagodongo nesitjhaba sakhe. Uthe bona abulale uMagodongo, uMzilikazi wathumba ifuyo nabafazi wakhuphuka nenarha watjhinga eTlhagwini, waze wayokunzinza eRhodesia esele yaziwa ngeZimbabwe namhlanje. UMzilikazi wathi nakasahlela uMagodongo kwabe sele adlule ngakuManala, abulele uSbindi. --([[Skhosana]], 1996, 8)&lt;/blockquote&gt;

Ngo 1883, ngesikhathi kubusa uMabhongo kwathoma ipiyombango yabakwaNdzundza namabhuru,bebanga iphasi, amanzi nefuyo. Amabhunawo abedoswa phambili ngu Piet Joubert ahlasela isitjhaba sakwadundza iinyanga ezibunane, bonyana uMabhongo nabantu bakhe bavaleleke ezintabeni zangase Roossenekal. Amabutho kaMabhongo akwazi bona atjhinge ngemva kwamabhunu ayokukha amazi neziliwo. Kodwana ngemva kukuthumba nokutlhorisa abafazi, omunye wabo watjho bona ingwenyama uMabhongo ingakuphi. Amabhunu akghona ukusahlela athumba ingwenyama.&lt;ref name=ph2&gt;&quot;[http://www.encyclopedia.com Ndebele]&quot; (1996) - '''Encyclopedia of World Cultures.''' -Van Vuuren, Chris. Retrieved 25 February 2016&lt;/ref&gt;

==Umlando: 1880 - 1994==
Imiraro yobukhosi bakwandebele baragela phambili ngaphasi kwe kosi uNyabela. BakwaNdzundza balahlekelwa bukhosi ngitjho nephasi labo, begodu nekosi uNyabela yavalelwa udilika-jele. Amandebele asabalala nenarha, abangamarhoba ngaphasi kwamaplasi amabhunu iminyaka emihlanu (1883 - 1888). Amakhosi wakwaManala khange angenele imiraro le begodu isitjhaba sakaManala sakha KoMjekejeke ngase Wallmannsthal, enarheni abayiphiwa zizithunywa zase Berlin.&lt;ref name=ph2&gt;&lt;/ref&gt;

Ikosi uNyabela Mahlangu watjhaphululwa ngo 1903, ngokuphelakwe miraro yokubanga iphasi yamaBhunu namaNgesi (ngo 1899 - 1902), begodu wahlongakala. Ikosi eyalandela, yalinga ukubawa bona irhulumende ibuyise inarha yabo, kodwana kwabala. 

Indlu yobukhosi nesitjhaba yathenga inarha ngo 1922 lapho isitjhaba sakwaNdzundza sabuya sahlangana khona. Ngaphasi kombuso wezamakhaya (bantustan or homeland) amaNdebele (Abakwa Manala nabakwNdzundza boke) atjhingiselwa kwandebele ngonyaka ka 1979. Kulapha batholakana khulu nanjenganje.&lt;ref name=ph1&gt;&lt;/ref&gt;

== Umlando womlomo ==
Abanye bathi ukuthoma kwebizo lamandebele kusuka ebasuthwuni, bathi &quot;ngamathebe telele&quot;, okutjho bona ngabantu abaphatha iinhlangu ezide. Bathoma bafujanisa ibizole bathi maNdebele (Matebele).

==Isithasiselo==
{{Reflist}}</text>
      <sha1>bk6lkn72qj2vwbdkjlwwnd5fu6ujl8o</sha1>
    </revision>
    <revision>
      <id>6690</id>
      <parentid>5088</parentid>
      <timestamp>2026-06-12T07:25:14Z</timestamp>
      <contributor>
        <username>MissHadassah</username>
        <id>1561</id>
      </contributor>
      <minor />
      <origin>6690</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4369" sha1="n9oa2790v8gj0s3n3xd2wx8sl0qt6pf" xml:space="preserve">{{Ethnic group
|Ubutjhaba = AbaNdebele
|isithombe = Ndebele-women-loopspruit.jpg
|umtlolo   = Abomma base Loopspruit Cultural Village, ngase[[Bronkhorstspruit, Gauteng|Bronkhorstspruit]]
|Ubuningi  = 1.1 million (2011 Census)
|Amaphrovinci = [[Mpumalanga]], [[Gauteng]] ne [[Limpopo Province]]
|Amalimi   = IsiNdebele
|Ikolo     = [[Isikreste]], [[Amasiko]]
|Bahlobane = [[Nguni|AbaNguni]]
}}
[[Isimumathi:Mapoch.- Femmes Ndebele in Cultural Village (2).jpg|alt=kwandebel|thumb|Abomma bamandebele]]
'''AmaNdebele''' kusitjhaba sabantu esitholakala enarheni yeSewula Afrika. Isitjhaba lesi sihlukaniswa ngeenqhema ezimbili, isitjhaba sakwaManala begodu nesakwaNdzundza. &lt;ref name=ph1&gt;&quot;[http://www.sahistory.org.za/article/people-south-africa-ndebele People of South Africa: Ndebele ]&quot; (27-Oct-2014) - '''South African History Online'''. Retrieved 25 February 2016&lt;/ref&gt;

Umlando wamaNdebele uthoma ngekosi uMafana. Ikosi uMafana walandelwa nguMhlanga owabeletha uMusi. Ikosi uMusi yathatha igadango bonyana akhambe atjhiye abatjhana bakhe ayokuhlala KwaMnyamana nge-Rhawuteni. Khonapho isitjhaba sahlukana phakathi ngabakwaManala begodu nabakwaNdzundza iinkosi ezihloniphekileko.

__TOC__

== Umlando: 1600 - 1880 ==
Ngesikhathi ingwenyama uMusi ahlongakala ngonyaka ka 1630, kwavuka umraro wokulwela ubukhosi ebantwaneni bakhe uManala no Ndzundza. Lomraro wahlukanisa isitjhaba samandebele eSewula (AbakwaManala) namandebele eTlhagwini (abakwaNdzundza nabakwaMthombeni). 

UNdzundza noMthombeni bakhamba baya ngase Pumalanga batjhinga bakha KwaSimkhulu, eTlhagwini leBelfast ngase Pumalanga. Kodwana uMthombeni waragela phambili wakhuphuka nenarha ngomlambo we Olifant waya ngase Tlhagwini begodu wakha ngase Zebediela eLimpopo. UMthombeni wathoma wabizwa ngokuthi nguGegana (namkha uKekana).&lt;ref name=ph1&gt;&lt;/ref&gt;

&lt;blockquote class=&quot;toccolours&quot; style=&quot;float:none; padding: 10px 15px 10px 15px; display:table;&quot;&gt;Ngesikhathi kwaMaza kubusa ingwenyama [[INgwenyama UMagodongo|uMagodongo]], kwafika uMzilikazi abaleke kwaZulu ngesibanga sepi kaShaka. UMzilikazi wafika wasahlela uMagodongo nesitjhaba sakhe. Uthe bona abulale uMagodongo, uMzilikazi wathumba ifuyo nabafazi wakhuphuka nenarha watjhinga eTlhagwini, waze wayokunzinza eRhodesia esele yaziwa ngeZimbabwe namhlanje. UMzilikazi wathi nakasahlela uMagodongo kwabe sele adlule ngakuManala, abulele uSbindi. --([[Skhosana]], 1996, 8)&lt;/blockquote&gt;

Ngo 1883, ngesikhathi kubusa u[[Mabhongo]] kwathoma ipiyombango yabakwaNdzundza namabhuru,bebanga iphasi, amanzi nefuyo. Amabhunawo abedoswa phambili ngu Piet Joubert ahlasela isitjhaba sakwadundza iinyanga ezibunane, bonyana uMabhongo nabantu bakhe bavaleleke ezintabeni zangase Roossenekal. Amabutho kaMabhongo akwazi bona atjhinge ngemva kwamabhunu ayokukha amazi neziliwo. Kodwana ngemva kukuthumba nokutlhorisa abafazi, omunye wabo watjho bona ingwenyama uMabhongo ingakuphi. Amabhunu akghona ukusahlela athumba ingwenyama.&lt;ref name=ph2&gt;&quot;[http://www.encyclopedia.com Ndebele]&quot; (1996) - '''Encyclopedia of World Cultures.''' -Van Vuuren, Chris. Retrieved 25 February 2016&lt;/ref&gt;

==Umlando: 1880 - 1994==
Imiraro yobukhosi bakwandebele baragela phambili ngaphasi kwe kosi uNyabela. BakwaNdzundza balahlekelwa bukhosi ngitjho nephasi labo, begodu nekosi uNyabela yavalelwa udilika-jele. Amandebele asabalala nenarha, abangamarhoba ngaphasi kwamaplasi amabhunu iminyaka emihlanu (1883 - 1888). Amakhosi wakwaManala khange angenele imiraro le begodu isitjhaba sakaManala sakha KoMjekejeke ngase Wallmannsthal, enarheni abayiphiwa zizithunywa zase Berlin.&lt;ref name=ph2&gt;&lt;/ref&gt;

Ikosi uNyabela Mahlangu watjhaphululwa ngo 1903, ngokuphelakwe miraro yokubanga iphasi yamaBhunu namaNgesi (ngo 1899 - 1902), begodu wahlongakala. Ikosi eyalandela, yalinga ukubawa bona irhulumende ibuyise inarha yabo, kodwana kwabala. 

Indlu yobukhosi nesitjhaba yathenga inarha ngo 1922 lapho isitjhaba sakwaNdzundza sabuya sahlangana khona. Ngaphasi kombuso wezamakhaya (bantustan or homeland) amaNdebele (Abakwa Manala nabakwNdzundza boke) atjhingiselwa kwandebele ngonyaka ka 1979. Kulapha batholakana khulu nanjenganje.&lt;ref name=ph1&gt;&lt;/ref&gt;

== Umlando womlomo ==
Abanye bathi ukuthoma kwebizo lamandebele kusuka ebasuthwuni, bathi &quot;ngamathebe telele&quot;, okutjho bona ngabantu abaphatha iinhlangu ezide. Bathoma bafujanisa ibizole bathi maNdebele (Matebele).

==Isithasiselo==
{{Reflist}}</text>
      <sha1>n9oa2790v8gj0s3n3xd2wx8sl0qt6pf</sha1>
    </revision>
    <revision>
      <id>6691</id>
      <parentid>6690</parentid>
      <timestamp>2026-06-12T07:29:13Z</timestamp>
      <contributor>
        <username>MissHadassah</username>
        <id>1561</id>
      </contributor>
      <minor />
      <comment>linked pages</comment>
      <origin>6691</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4393" sha1="13lvq52osodvb716w4nenvlkiua18g7" xml:space="preserve">{{Ethnic group
|Ubutjhaba = AbaNdebele
|isithombe = Ndebele-women-loopspruit.jpg
|umtlolo   = Abomma base Loopspruit Cultural Village, ngase[[Bronkhorstspruit, Gauteng|Bronkhorstspruit]]
|Ubuningi  = 1.1 million (2011 Census)
|Amaphrovinci = [[Mpumalanga]], [[Gauteng]] ne [[Limpopo Province]]
|Amalimi   = IsiNdebele
|Ikolo     = [[Isikreste]], [[Amasiko]]
|Bahlobane = [[Nguni|AbaNguni]]
}}
[[Isimumathi:Mapoch.- Femmes Ndebele in Cultural Village (2).jpg|alt=kwandebel|thumb|Abomma bamandebele]]
'''AmaNdebele''' kusitjhaba sabantu esitholakala enarheni yeSewula Afrika. Isitjhaba lesi sihlukaniswa ngeenqhema ezimbili, isitjhaba sakwaManala begodu nesakwaNdzundza. &lt;ref name=ph1&gt;&quot;[http://www.sahistory.org.za/article/people-south-africa-ndebele People of South Africa: Ndebele ]&quot; (27-Oct-2014) - '''South African History Online'''. Retrieved 25 February 2016&lt;/ref&gt;

Umlando wamaNdebele uthoma ngekosi uMafana. Ikosi uMafana walandelwa nguMhlanga owabeletha uMusi. Ikosi uMusi yathatha igadango bonyana akhambe atjhiye abatjhana bakhe ayokuhlala KwaMnyamana nge-Rhawuteni. Khonapho isitjhaba sahlukana phakathi ngabakwaManala begodu nabakwaNdzundza iinkosi ezihloniphekileko.

__TOC__

== Umlando: 1600 - 1880 ==
Ngesikhathi ingwenyama uMusi ahlongakala ngonyaka ka 1630, kwavuka umraro wokulwela ubukhosi ebantwaneni bakhe uManala no Ndzundza. Lomraro wahlukanisa isitjhaba samandebele eSewula (AbakwaManala) namandebele eTlhagwini (abakwaNdzundza nabakwaMthombeni). 

UNdzundza noMthombeni bakhamba baya ngase Pumalanga batjhinga bakha KwaSimkhulu, eTlhagwini leBelfast ngase Pumalanga. Kodwana uMthombeni waragela phambili wakhuphuka nenarha ngomlambo we Olifant waya ngase Tlhagwini begodu wakha ngase Zebediela eLimpopo. UMthombeni wathoma wabizwa ngokuthi nguGegana (namkha uKekana).&lt;ref name=ph1&gt;&lt;/ref&gt;

&lt;blockquote class=&quot;toccolours&quot; style=&quot;float:none; padding: 10px 15px 10px 15px; display:table;&quot;&gt;Ngesikhathi kwaMaza kubusa ingwenyama [[INgwenyama UMagodongo|uMagodongo]], kwafika uMzilikazi abaleke kwaZulu ngesibanga sepi kaShaka. UMzilikazi wafika wasahlela uMagodongo nesitjhaba sakhe. Uthe bona abulale uMagodongo, uMzilikazi wathumba ifuyo nabafazi wakhuphuka nenarha watjhinga eTlhagwini, waze wayokunzinza eRhodesia esele yaziwa ngeZimbabwe namhlanje. UMzilikazi wathi nakasahlela uMagodongo kwabe sele adlule ngakuManala, abulele uSbindi. --([[Skhosana]], 1996, 8)&lt;/blockquote&gt;

Ngo 1883, ngesikhathi kubusa u[[Mabhongo]] kwathoma ipiyombango yabakwaNdzundza namabhuru,bebanga iphasi, amanzi nefuyo. Amabhunawo abedoswa phambili ngu Piet Joubert ahlasela isitjhaba sakwadundza iinyanga ezibunane, bonyana uMabhongo nabantu bakhe bavaleleke ezintabeni zangase Roossenekal. Amabutho kaMabhongo akwazi bona atjhinge ngemva kwamabhunu ayokukha amazi neziliwo. Kodwana ngemva kukuthumba nokutlhorisa abafazi, omunye wabo watjho bona ingwenyama uMabhongo ingakuphi. Amabhunu akghona ukusahlela athumba ingwenyama.&lt;ref name=ph2&gt;&quot;[http://www.encyclopedia.com Ndebele]&quot; (1996) - '''Encyclopedia of World Cultures.''' -Van Vuuren, Chris. Retrieved 25 February 2016&lt;/ref&gt;

==Umlando: 1880 - 1994==
Imiraro yobukhosi bakwandebele baragela phambili ngaphasi kwe kosi u[[INgwenyama UNyabela|Nyabela]]. BakwaNdzundza balahlekelwa bukhosi ngitjho nephasi labo, begodu nekosi uNyabela yavalelwa udilika-jele. Amandebele asabalala nenarha, abangamarhoba ngaphasi kwamaplasi amabhunu iminyaka emihlanu (1883 - 1888). Amakhosi wakwaManala khange angenele imiraro le begodu isitjhaba sakaManala sakha KoMjekejeke ngase Wallmannsthal, enarheni abayiphiwa zizithunywa zase Berlin.&lt;ref name=ph2&gt;&lt;/ref&gt;

Ikosi uNyabela Mahlangu watjhaphululwa ngo 1903, ngokuphelakwe miraro yokubanga iphasi yamaBhunu namaNgesi (ngo 1899 - 1902), begodu wahlongakala. Ikosi eyalandela, yalinga ukubawa bona irhulumende ibuyise inarha yabo, kodwana kwabala. 

Indlu yobukhosi nesitjhaba yathenga inarha ngo 1922 lapho isitjhaba sakwaNdzundza sabuya sahlangana khona. Ngaphasi kombuso wezamakhaya (bantustan or homeland) amaNdebele (Abakwa Manala nabakwNdzundza boke) atjhingiselwa kwandebele ngonyaka ka 1979. Kulapha batholakana khulu nanjenganje.&lt;ref name=ph1&gt;&lt;/ref&gt;

== Umlando womlomo ==
Abanye bathi ukuthoma kwebizo lamandebele kusuka ebasuthwuni, bathi &quot;ngamathebe telele&quot;, okutjho bona ngabantu abaphatha iinhlangu ezide. Bathoma bafujanisa ibizole bathi maNdebele (Matebele).

==Isithasiselo==
{{Reflist}}</text>
      <sha1>13lvq52osodvb716w4nenvlkiua18g7</sha1>
    </revision>
  </page>
  <page>
    <title>Umlando weenkolo zeWatervaal</title>
    <ns>0</ns>
    <id>274</id>
    <revision>
      <id>1490</id>
      <timestamp>2024-03-08T13:46:47Z</timestamp>
      <contributor>
        <username>incubator&gt;Mbandeni</username>
        <id>0</id>
      </contributor>
      <comment>created article</comment>
      <origin>1490</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1296" sha1="25lqas1lsvnvlkcf7txyowz0umsjp3u" xml:space="preserve">I-Watervaal yindawo engeMpumalanga kwa-Ndebele. Ihlukaniswe kabili ekuyi Watervaal A ne Watervaal B. Kondwana le-athikili izokunanabeja khudlwana ngomlando weenkolo ze-Watervaal B. Iinkolo ezitholakala e-Watervaal B yi-Mantwani Primary School, Mandlakababa Primary School, Ndebema Senior Primary School, ne-Mayitha High School. Iinkolo lezi zazinjengokuba zinje ngaphambi kokobana zitjhuguluke gadesi.

I-Mantwani Primary School, sathiyelelwa ngekosi eyayibusa ngaleso sikhathi ekung-Mandwani. Ngebanga lokobana uhlokokulu wokuthoma we-Mantwani kwabe kuli-Pedi, watjhungulula ibizo ngokungakwazi ukupeleda amagama wesiNdebele. Lesi sikolo ngesamazinga aphasi esasithoma ngebanga lokuthoma ukuya kwebanga lesithandathu. Kodwana kwanjesi sithoma ngebanga lokuthoma ukuya kwelikhomba. Ukutjhuguluka kwamabanga kwakungebalanga lokutjhuguluka kwe-kharikhulamu. 

Isikolo i-Mayitjha sathiyelelwa naso ngekosi u-Mayitjha obekabusa ngalesosikhathi. Lesisikolo kwabe sithoma ebangeni letjhumi ukuya kwelamatjhumi amabili. Kodwana kwanjesi sesithoma ebangeni lobunane ukuya kweletjhumi nambili.

Siye esikolweni ebesibizwa nge-Ndebema Senior Primary, esathiyelelwa ngendawo lapha umndeni webukhosini bakwa-Mahlangu ebafuduka khona. Kodwana kwanjesi sesithoma ebangeni lokuthoma ukuya kweletjhumi nambili.

</text>
      <sha1>25lqas1lsvnvlkcf7txyowz0umsjp3u</sha1>
    </revision>
    <revision>
      <id>1491</id>
      <parentid>1490</parentid>
      <timestamp>2024-03-08T13:47:39Z</timestamp>
      <contributor>
        <username>incubator&gt;Mbandeni</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>bold edited</comment>
      <origin>1491</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1302" sha1="l8l1ngmkv3rjzjt2e1us2pexdqgfagv" xml:space="preserve">'''I-Watervaa'''l yindawo engeMpumalanga kwa-Ndebele. Ihlukaniswe kabili ekuyi Watervaal A ne Watervaal B. Kondwana le-athikili izokunanabeja khudlwana ngomlando weenkolo ze-Watervaal B. Iinkolo ezitholakala e-Watervaal B yi-Mantwani Primary School, Mandlakababa Primary School, Ndebema Senior Primary School, ne-Mayitha High School. Iinkolo lezi zazinjengokuba zinje ngaphambi kokobana zitjhuguluke gadesi.

I-Mantwani Primary School, sathiyelelwa ngekosi eyayibusa ngaleso sikhathi ekung-Mandwani. Ngebanga lokobana uhlokokulu wokuthoma we-Mantwani kwabe kuli-Pedi, watjhungulula ibizo ngokungakwazi ukupeleda amagama wesiNdebele. Lesi sikolo ngesamazinga aphasi esasithoma ngebanga lokuthoma ukuya kwebanga lesithandathu. Kodwana kwanjesi sithoma ngebanga lokuthoma ukuya kwelikhomba. Ukutjhuguluka kwamabanga kwakungebalanga lokutjhuguluka kwe-kharikhulamu. 

Isikolo i-Mayitjha sathiyelelwa naso ngekosi u-Mayitjha obekabusa ngalesosikhathi. Lesisikolo kwabe sithoma ebangeni letjhumi ukuya kwelamatjhumi amabili. Kodwana kwanjesi sesithoma ebangeni lobunane ukuya kweletjhumi nambili.

Siye esikolweni ebesibizwa nge-Ndebema Senior Primary, esathiyelelwa ngendawo lapha umndeni webukhosini bakwa-Mahlangu ebafuduka khona. Kodwana kwanjesi sesithoma ebangeni lokuthoma ukuya kweletjhumi nambili.

</text>
      <sha1>l8l1ngmkv3rjzjt2e1us2pexdqgfagv</sha1>
    </revision>
    <revision>
      <id>1492</id>
      <parentid>1491</parentid>
      <timestamp>2024-03-09T07:41:55Z</timestamp>
      <contributor>
        <username>incubator&gt;Mbandeni</username>
        <id>0</id>
      </contributor>
      <comment>Linked</comment>
      <origin>1492</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1306" sha1="0jt3sitk2jsi3uhrlv63nivjascmtpe" xml:space="preserve">'''I-Watervaa'''l yindawo [[engeMpumalanga]] kwa-Ndebele. Ihlukaniswe kabili ekuyi Watervaal A ne Watervaal B. Kondwana le-athikili izokunanabeja khudlwana ngomlando weenkolo ze-Watervaal B. Iinkolo ezitholakala e-Watervaal B yi-Mantwani Primary School, Mandlakababa Primary School, Ndebema Senior Primary School, ne-Mayitha High School. Iinkolo lezi zazinjengokuba zinje ngaphambi kokobana zitjhuguluke gadesi.

I-Mantwani Primary School, sathiyelelwa ngekosi eyayibusa ngaleso sikhathi ekung-Mandwani. Ngebanga lokobana uhlokokulu wokuthoma we-Mantwani kwabe kuli-Pedi, watjhungulula ibizo ngokungakwazi ukupeleda amagama wesiNdebele. Lesi sikolo ngesamazinga aphasi esasithoma ngebanga lokuthoma ukuya kwebanga lesithandathu. Kodwana kwanjesi sithoma ngebanga lokuthoma ukuya kwelikhomba. Ukutjhuguluka kwamabanga kwakungebalanga lokutjhuguluka kwe-kharikhulamu. 

Isikolo i-Mayitjha sathiyelelwa naso ngekosi u-Mayitjha obekabusa ngalesosikhathi. Lesisikolo kwabe sithoma ebangeni letjhumi ukuya kwelamatjhumi amabili. Kodwana kwanjesi sesithoma ebangeni lobunane ukuya kweletjhumi nambili.

Siye esikolweni ebesibizwa nge-Ndebema Senior Primary, esathiyelelwa ngendawo lapha umndeni webukhosini bakwa-Mahlangu ebafuduka khona. Kodwana kwanjesi sesithoma ebangeni lokuthoma ukuya kweletjhumi nambili.

</text>
      <sha1>0jt3sitk2jsi3uhrlv63nivjascmtpe</sha1>
    </revision>
    <revision>
      <id>1493</id>
      <parentid>1492</parentid>
      <timestamp>2024-10-14T13:47:43Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>1492</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1306" sha1="0jt3sitk2jsi3uhrlv63nivjascmtpe" xml:space="preserve">'''I-Watervaa'''l yindawo [[engeMpumalanga]] kwa-Ndebele. Ihlukaniswe kabili ekuyi Watervaal A ne Watervaal B. Kondwana le-athikili izokunanabeja khudlwana ngomlando weenkolo ze-Watervaal B. Iinkolo ezitholakala e-Watervaal B yi-Mantwani Primary School, Mandlakababa Primary School, Ndebema Senior Primary School, ne-Mayitha High School. Iinkolo lezi zazinjengokuba zinje ngaphambi kokobana zitjhuguluke gadesi.

I-Mantwani Primary School, sathiyelelwa ngekosi eyayibusa ngaleso sikhathi ekung-Mandwani. Ngebanga lokobana uhlokokulu wokuthoma we-Mantwani kwabe kuli-Pedi, watjhungulula ibizo ngokungakwazi ukupeleda amagama wesiNdebele. Lesi sikolo ngesamazinga aphasi esasithoma ngebanga lokuthoma ukuya kwebanga lesithandathu. Kodwana kwanjesi sithoma ngebanga lokuthoma ukuya kwelikhomba. Ukutjhuguluka kwamabanga kwakungebalanga lokutjhuguluka kwe-kharikhulamu. 

Isikolo i-Mayitjha sathiyelelwa naso ngekosi u-Mayitjha obekabusa ngalesosikhathi. Lesisikolo kwabe sithoma ebangeni letjhumi ukuya kwelamatjhumi amabili. Kodwana kwanjesi sesithoma ebangeni lobunane ukuya kweletjhumi nambili.

Siye esikolweni ebesibizwa nge-Ndebema Senior Primary, esathiyelelwa ngendawo lapha umndeni webukhosini bakwa-Mahlangu ebafuduka khona. Kodwana kwanjesi sesithoma ebangeni lokuthoma ukuya kweletjhumi nambili.

</text>
      <sha1>0jt3sitk2jsi3uhrlv63nivjascmtpe</sha1>
    </revision>
  </page>
  <page>
    <title>Umndeni</title>
    <ns>0</ns>
    <id>275</id>
    <revision>
      <id>1494</id>
      <timestamp>2024-07-11T10:11:03Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Umndeni''' babantu ababili nanyana abangaphezu kwababili abahlobeni ngokwegazi nanyana abahlanganiswe mtjhado.&quot;</comment>
      <origin>1494</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="113" sha1="f0kq01368juqav8hqi36f6s9yskmlas" xml:space="preserve">'''Umndeni''' babantu ababili nanyana abangaphezu kwababili abahlobeni ngokwegazi nanyana abahlanganiswe mtjhado.</text>
      <sha1>f0kq01368juqav8hqi36f6s9yskmlas</sha1>
    </revision>
    <revision>
      <id>1495</id>
      <parentid>1494</parentid>
      <timestamp>2024-07-11T10:14:30Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1495</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="366" sha1="83q1s0vw9s0fame3yy20xim3cb7w4se" xml:space="preserve">'''Umndeni''' babantu ababili nanyana abangaphezu kwababili abahlobeni ngokwegazi nanyana abahlanganiswe mtjhado. Kuyenzeka bona umndeni kube ngewabantu abangenabo ubuhlobo kodwana bahlanganiswe lithando, njengalokho umma nakangakhoni ukuthola abantwana bese akhambe eya lapho kuhlala khona bantwana abazintandani ukuyokwenza i-adoption  bese azakhele wakhe umndeni.</text>
      <sha1>83q1s0vw9s0fame3yy20xim3cb7w4se</sha1>
    </revision>
    <revision>
      <id>1496</id>
      <parentid>1495</parentid>
      <timestamp>2024-07-11T10:15:55Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1496</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="417" sha1="kjvxgqy6weafze4lix9iyyvw914nxa8" xml:space="preserve">[[Isimumathi:Saami Family 1900.jpg|thumb|umndeni]]
'''Umndeni''' babantu ababili nanyana abangaphezu kwababili abahlobeni ngokwegazi nanyana abahlanganiswe mtjhado. Kuyenzeka bona umndeni kube ngewabantu abangenabo ubuhlobo kodwana bahlanganiswe lithando, njengalokho umma nakangakhoni ukuthola abantwana bese akhambe eya lapho kuhlala khona bantwana abazintandani ukuyokwenza i-adoption  bese azakhele wakhe umndeni.</text>
      <sha1>kjvxgqy6weafze4lix9iyyvw914nxa8</sha1>
    </revision>
    <revision>
      <id>1497</id>
      <parentid>1496</parentid>
      <timestamp>2024-07-11T10:21:35Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1497</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="593" sha1="e14fykbdr583xijivadw8r96ax5ykdw" xml:space="preserve">[[Isimumathi:Saami Family 1900.jpg|thumb|umndeni]]
'''Umndeni''' babantu ababili nanyana abangaphezu kwababili abahlobeni ngokwegazi nanyana abahlanganiswe mtjhado. Kuyenzeka bona umndeni kube ngewabantu abangenabo ubuhlobo kodwana bahlanganiswe lithando, njengalokha umma nakangakhoni ukuthola abantwana bese akhambe eya lapho kuhlala khona bantwana abazintandani ukuyokwenza i-adoption  bese azakhele wakhe umndeni. kuvamisile bona abantu abamndeni munye basebenzise isibongo sinye. umndeni kungaba ngu mma nobaba abatjhadileko, ugogo osele ahlala nabazukulu, abantwana abasele bodwa ekhaya.</text>
      <sha1>e14fykbdr583xijivadw8r96ax5ykdw</sha1>
    </revision>
    <revision>
      <id>1498</id>
      <parentid>1497</parentid>
      <timestamp>2024-07-11T10:23:02Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1498</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="812" sha1="oy0cm6pe3dur522qrc18bt3j579vezf" xml:space="preserve">[[Isimumathi:Saami Family 1900.jpg|thumb|umndeni]]
'''Umndeni''' babantu ababili nanyana abangaphezu kwababili abahlobeni ngokwegazi nanyana abahlanganiswe mtjhado. Kuyenzeka bona umndeni kube ngewabantu abangenabo ubuhlobo kodwana bahlanganiswe lithando, njengalokha umma nakangakhoni ukuthola abantwana bese akhambe eya lapho kuhlala khona bantwana abazintandani ukuyokwenza i-adoption  bese azakhele wakhe umndeni. kuvamisile bona abantu abamndeni munye basebenzise isibongo sinye. umndeni kungaba ngu mma nobaba abatjhadileko, ugogo osele ahlala nabazukulu, abantwana abasele bodwa ekhaya&lt;ref&gt;Newlin, M., Reynold, S. and Nombutho, M.M.W., 2016. Children from child-headed households: Understanding challenges that affect in their academic pursuits. ''Journal of Human Ecology'', ''54''(3), pp.158-173.&lt;/ref&gt;.</text>
      <sha1>oy0cm6pe3dur522qrc18bt3j579vezf</sha1>
    </revision>
    <revision>
      <id>1499</id>
      <parentid>1498</parentid>
      <timestamp>2024-10-14T13:47:44Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>5 revisions imported</comment>
      <origin>1498</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="812" sha1="oy0cm6pe3dur522qrc18bt3j579vezf" xml:space="preserve">[[Isimumathi:Saami Family 1900.jpg|thumb|umndeni]]
'''Umndeni''' babantu ababili nanyana abangaphezu kwababili abahlobeni ngokwegazi nanyana abahlanganiswe mtjhado. Kuyenzeka bona umndeni kube ngewabantu abangenabo ubuhlobo kodwana bahlanganiswe lithando, njengalokha umma nakangakhoni ukuthola abantwana bese akhambe eya lapho kuhlala khona bantwana abazintandani ukuyokwenza i-adoption  bese azakhele wakhe umndeni. kuvamisile bona abantu abamndeni munye basebenzise isibongo sinye. umndeni kungaba ngu mma nobaba abatjhadileko, ugogo osele ahlala nabazukulu, abantwana abasele bodwa ekhaya&lt;ref&gt;Newlin, M., Reynold, S. and Nombutho, M.M.W., 2016. Children from child-headed households: Understanding challenges that affect in their academic pursuits. ''Journal of Human Ecology'', ''54''(3), pp.158-173.&lt;/ref&gt;.</text>
      <sha1>oy0cm6pe3dur522qrc18bt3j579vezf</sha1>
    </revision>
    <revision>
      <id>2164</id>
      <parentid>1499</parentid>
      <timestamp>2024-11-27T06:17:57Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>+ Iinkomba</comment>
      <origin>2164</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="840" sha1="mts35weczubr45xp5p9grr1hgpvs9on" xml:space="preserve">[[Isimumathi:Saami Family 1900.jpg|thumb|umndeni]]
'''Umndeni''' babantu ababili nanyana abangaphezu kwababili abahlobeni ngokwegazi nanyana abahlanganiswe mtjhado. Kuyenzeka bona umndeni kube ngewabantu abangenabo ubuhlobo kodwana bahlanganiswe lithando, njengalokha umma nakangakhoni ukuthola abantwana bese akhambe eya lapho kuhlala khona bantwana abazintandani ukuyokwenza i-adoption  bese azakhele wakhe umndeni. kuvamisile bona abantu abamndeni munye basebenzise isibongo sinye. umndeni kungaba ngu mma nobaba abatjhadileko, ugogo osele ahlala nabazukulu, abantwana abasele bodwa ekhaya&lt;ref&gt;Newlin, M., Reynold, S. and Nombutho, M.M.W., 2016. Children from child-headed households: Understanding challenges that affect in their academic pursuits. ''Journal of Human Ecology'', ''54''(3), pp.158-173.&lt;/ref&gt;.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>mts35weczubr45xp5p9grr1hgpvs9on</sha1>
    </revision>
    <revision>
      <id>5953</id>
      <parentid>2164</parentid>
      <timestamp>2025-11-08T11:50:53Z</timestamp>
      <contributor>
        <username>Hlalithwa</username>
        <id>996</id>
      </contributor>
      <minor />
      <comment>Spelling</comment>
      <origin>5953</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="840" sha1="a5lpalj9tc3ak6hkupnxv3pc6614pzx" xml:space="preserve">[[Isimumathi:Saami Family 1900.jpg|thumb|umndeni]]
'''Umndeni''' babantu ababili nanyana abangaphezu kwababili abahlobene ngokwegazi nanyana abahlanganiswe mtjhado. Kuyenzeka bona umndeni kube ngewabantu abangenabo ubuhlobo kodwana bahlanganiswe lithando, njengalokha umma nakangakhoni ukuthola abentwana akhambe aye lapho kuhlala khona abantwana abazintandani ukuyokwenza i-adoption  bese azakhele wakhe umndeni. kuvamisile bona abantu abamndeni munye basebenzise isibongo esifanako. umndeni kungaba ngu mma nobaba abatjhadileko, ugogo osele ahlala nabazukulu, abantwana abasele bodwa ekhaya&lt;ref&gt;Newlin, M., Reynold, S. and Nombutho, M.M.W., 2016. Children from child-headed households: Understanding challenges that affect in their academic pursuits. ''Journal of Human Ecology'', ''54''(3), pp.158-173.&lt;/ref&gt;.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>a5lpalj9tc3ak6hkupnxv3pc6614pzx</sha1>
    </revision>
  </page>
  <page>
    <title>Umndeni.</title>
    <ns>0</ns>
    <id>276</id>
    <revision>
      <id>1500</id>
      <timestamp>2024-09-15T10:24:28Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;== Umndeni ==  === Isingeniso === Umndeni ufaka izinto ezinengi begodu akunahlathululo elula ehlathulula umndeni ngebala lobujamo obungeneleko begodu abuhlangeko. Nanyana kunjalo, umndeni yinto ekhona koke, ungafaka iinlwana kanye nabantu. Esihlokweni esilandelako sizokutjheja bonyana kuyini umndeni.   === Kuyini umndeni? === Ngokuya kuka-Arslan (2023)&lt;ref name=&quot;:0&quot;&gt;Arslan , A. 2023. Characteristics, types and functions of family concept. ''African Educational Research J...&quot;</comment>
      <origin>1500</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2439" sha1="thy57sklslrfnwo3rz4fu2uzxy3u3t6" xml:space="preserve">== Umndeni ==

=== Isingeniso ===
Umndeni ufaka izinto ezinengi begodu akunahlathululo elula ehlathulula umndeni ngebala lobujamo obungeneleko begodu abuhlangeko. Nanyana kunjalo, umndeni yinto ekhona koke, ungafaka iinlwana kanye nabantu. Esihlokweni esilandelako sizokutjheja bonyana kuyini umndeni. 

=== Kuyini umndeni? ===
Ngokuya kuka-Arslan (2023)&lt;ref name=&quot;:0&quot;&gt;Arslan , A. 2023. Characteristics, types and functions of family concept. ''African Educational Research Journal'', 11(1):45-48.&lt;/ref&gt; asekelwa yi-Wikipedia (2024)&lt;ref&gt;Wikipedia. 2024. ''Family''. Itholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Family&lt;/nowiki&gt;&gt; Ifunyenwe ngomhlaka [26 kuRhoboyi 2024].&lt;/ref&gt; [[:en:Family|umndeni]] kungaba ngumma, ubaba nomntwana wabo labo abahlala ndawonye. Ngamanye amagama, umndeni ufana umntwana nababelethi bakhe, umma nobabakhe, labo ahlala endlini eyodwa nanyana ngejaradeni elilodwa. 

U-Havigerova, u-Haviger no-Truhlarova (2013)&lt;ref&gt;Havigerova, J. M., Haviger, J. &amp; Truhlarova, Z. 2013. Teacher’s subjective definition of family. ''Procedia – Social and Behavioral Science,'' 106: 2507 – 2515.&lt;/ref&gt; basekelwa ngu-Enrique, u-Howk no-Huitt (2007) &lt;ref&gt;Enrique, J., Howk, H., &amp; Huitt, W. 2007. An overview of family development. ''Educational Psychology Interactive''. Valdosta, GA: Valdosta State University.&lt;/ref&gt;bathi, umndeni kusiqhema sabantu abahlalala endlini eyodwa kanye nalabo abakhololwa nanyana abasebenza boke. Ngamanye amagama, umndeni akusimntwana wakho, ababelethi bakho nanyana abentwana bekhenu kwaphela, kodwana umndeni ufaka nabantu esisebenza nabo nalabo ekholelwa ezintweni zinye sisoke. 

Umndeni uhluke ngemqema ezilandelako: Umndeni omkhulu, umndeni wabentwana, umndeni omncani. Umndeni omkhulu, mndeni lowo ofaka neenhlobo (Arslan 2023&lt;ref name=&quot;:0&quot; /&gt;). Ngamanye amagama umndeni omkhulu ngumma, ubaba, ukghari, umzala, umalume, umntamama nobentwana bekhaya. 

Kodwana, umndeni wabentwana, kumndeni loya onganababelethi kodwana odosa phambili mntwana begodu namalungu womndeni lo, kubentwana bodwa (Arslan 2023&lt;ref name=&quot;:0&quot; /&gt;). Umndeni omncani wona, mndeni loyo ofaka umma nobaba nabentwana babo kwaphela (Arslan 2023&lt;ref name=&quot;:0&quot; /&gt;). 

=== Isiphetho ===
Umndeni uqakatheke kwambala begodu kufanele sizwisise bonyana umndeni awufaki kwaphela umma nobaba nabentwana bakhe kodwana ufaka nabantu esiphila nabo eduze ngaso soke isikhathi lasihlala khona.

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>thy57sklslrfnwo3rz4fu2uzxy3u3t6</sha1>
    </revision>
    <revision>
      <id>1501</id>
      <parentid>1500</parentid>
      <timestamp>2024-09-18T16:05:20Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1501</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2441" sha1="tw3cc1d7zx6ukktowmmqru8v7vzi08u" xml:space="preserve">== Umndeni. ==

=== Isingeniso. ===
Umndeni ufaka izinto ezinengi begodu akunahlathululo elula ehlathulula umndeni ngebala lobujamo obungeneleko begodu abuhlangeko. Nanyana kunjalo, umndeni yinto ekhona koke, ungafaka iinlwana kanye nabantu. Esihlokweni esilandelako sizokutjheja bonyana kuyini umndeni. 

=== Kuyini umndeni? ===
Ngokuya kuka-Arslan (2023)&lt;ref name=&quot;:0&quot;&gt;Arslan , A. 2023. Characteristics, types and functions of family concept. ''African Educational Research Journal'', 11(1):45-48.&lt;/ref&gt; asekelwa yi-Wikipedia (2024)&lt;ref&gt;Wikipedia. 2024. ''Family''. Itholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Family&lt;/nowiki&gt;&gt; Ifunyenwe ngomhlaka [26 kuRhoboyi 2024].&lt;/ref&gt; [[:en:Family|umndeni]] kungaba ngumma, ubaba nomntwana wabo labo abahlala ndawonye. Ngamanye amagama, umndeni ufana umntwana nababelethi bakhe, umma nobabakhe, labo ahlala endlini eyodwa nanyana ngejaradeni elilodwa. 

U-Havigerova, u-Haviger no-Truhlarova (2013)&lt;ref&gt;Havigerova, J. M., Haviger, J. &amp; Truhlarova, Z. 2013. Teacher’s subjective definition of family. ''Procedia – Social and Behavioral Science,'' 106: 2507 – 2515.&lt;/ref&gt; basekelwa ngu-Enrique, u-Howk no-Huitt (2007) &lt;ref&gt;Enrique, J., Howk, H., &amp; Huitt, W. 2007. An overview of family development. ''Educational Psychology Interactive''. Valdosta, GA: Valdosta State University.&lt;/ref&gt;bathi, umndeni kusiqhema sabantu abahlalala endlini eyodwa kanye nalabo abakhololwa nanyana abasebenza boke. Ngamanye amagama, umndeni akusimntwana wakho, ababelethi bakho nanyana abentwana bekhenu kwaphela, kodwana umndeni ufaka nabantu esisebenza nabo nalabo ekholelwa ezintweni zinye sisoke. 

Umndeni uhluke ngemqema ezilandelako: Umndeni omkhulu, umndeni wabentwana, umndeni omncani. Umndeni omkhulu, mndeni lowo ofaka neenhlobo (Arslan 2023&lt;ref name=&quot;:0&quot; /&gt;). Ngamanye amagama umndeni omkhulu ngumma, ubaba, ukghari, umzala, umalume, umntamama nobentwana bekhaya. 

Kodwana, umndeni wabentwana, kumndeni loya onganababelethi kodwana odosa phambili mntwana begodu namalungu womndeni lo, kubentwana bodwa (Arslan 2023&lt;ref name=&quot;:0&quot; /&gt;). Umndeni omncani wona, mndeni loyo ofaka umma nobaba nabentwana babo kwaphela (Arslan 2023&lt;ref name=&quot;:0&quot; /&gt;). 

=== Isiphetho ===
Umndeni uqakatheke kwambala begodu kufanele sizwisise bonyana umndeni awufaki kwaphela umma nobaba nabentwana bakhe kodwana ufaka nabantu esiphila nabo eduze ngaso soke isikhathi lasihlala khona.

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>tw3cc1d7zx6ukktowmmqru8v7vzi08u</sha1>
    </revision>
    <revision>
      <id>1502</id>
      <parentid>1501</parentid>
      <timestamp>2024-10-14T13:47:44Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>1501</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2441" sha1="tw3cc1d7zx6ukktowmmqru8v7vzi08u" xml:space="preserve">== Umndeni. ==

=== Isingeniso. ===
Umndeni ufaka izinto ezinengi begodu akunahlathululo elula ehlathulula umndeni ngebala lobujamo obungeneleko begodu abuhlangeko. Nanyana kunjalo, umndeni yinto ekhona koke, ungafaka iinlwana kanye nabantu. Esihlokweni esilandelako sizokutjheja bonyana kuyini umndeni. 

=== Kuyini umndeni? ===
Ngokuya kuka-Arslan (2023)&lt;ref name=&quot;:0&quot;&gt;Arslan , A. 2023. Characteristics, types and functions of family concept. ''African Educational Research Journal'', 11(1):45-48.&lt;/ref&gt; asekelwa yi-Wikipedia (2024)&lt;ref&gt;Wikipedia. 2024. ''Family''. Itholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Family&lt;/nowiki&gt;&gt; Ifunyenwe ngomhlaka [26 kuRhoboyi 2024].&lt;/ref&gt; [[:en:Family|umndeni]] kungaba ngumma, ubaba nomntwana wabo labo abahlala ndawonye. Ngamanye amagama, umndeni ufana umntwana nababelethi bakhe, umma nobabakhe, labo ahlala endlini eyodwa nanyana ngejaradeni elilodwa. 

U-Havigerova, u-Haviger no-Truhlarova (2013)&lt;ref&gt;Havigerova, J. M., Haviger, J. &amp; Truhlarova, Z. 2013. Teacher’s subjective definition of family. ''Procedia – Social and Behavioral Science,'' 106: 2507 – 2515.&lt;/ref&gt; basekelwa ngu-Enrique, u-Howk no-Huitt (2007) &lt;ref&gt;Enrique, J., Howk, H., &amp; Huitt, W. 2007. An overview of family development. ''Educational Psychology Interactive''. Valdosta, GA: Valdosta State University.&lt;/ref&gt;bathi, umndeni kusiqhema sabantu abahlalala endlini eyodwa kanye nalabo abakhololwa nanyana abasebenza boke. Ngamanye amagama, umndeni akusimntwana wakho, ababelethi bakho nanyana abentwana bekhenu kwaphela, kodwana umndeni ufaka nabantu esisebenza nabo nalabo ekholelwa ezintweni zinye sisoke. 

Umndeni uhluke ngemqema ezilandelako: Umndeni omkhulu, umndeni wabentwana, umndeni omncani. Umndeni omkhulu, mndeni lowo ofaka neenhlobo (Arslan 2023&lt;ref name=&quot;:0&quot; /&gt;). Ngamanye amagama umndeni omkhulu ngumma, ubaba, ukghari, umzala, umalume, umntamama nobentwana bekhaya. 

Kodwana, umndeni wabentwana, kumndeni loya onganababelethi kodwana odosa phambili mntwana begodu namalungu womndeni lo, kubentwana bodwa (Arslan 2023&lt;ref name=&quot;:0&quot; /&gt;). Umndeni omncani wona, mndeni loyo ofaka umma nobaba nabentwana babo kwaphela (Arslan 2023&lt;ref name=&quot;:0&quot; /&gt;). 

=== Isiphetho ===
Umndeni uqakatheke kwambala begodu kufanele sizwisise bonyana umndeni awufaki kwaphela umma nobaba nabentwana bakhe kodwana ufaka nabantu esiphila nabo eduze ngaso soke isikhathi lasihlala khona.

=== Isilululwazi ===
&lt;references /&gt;</text>
      <sha1>tw3cc1d7zx6ukktowmmqru8v7vzi08u</sha1>
    </revision>
  </page>
  <page>
    <title>Umntwana</title>
    <ns>0</ns>
    <id>277</id>
    <revision>
      <id>1503</id>
      <timestamp>2024-07-08T09:22:40Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''umntwana''' mumuntu ongaphasi kweminyaka engaphasi kweminyaka kwematjhumi alithoba. Kumumuntu osese ngaphasi kwetlhogomelo nelawulo lababelethi.&quot;</comment>
      <origin>1503</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="147" sha1="74u2r8n6ybog1n52tvf46v9rrrgp9vs" xml:space="preserve">'''umntwana''' mumuntu ongaphasi kweminyaka engaphasi kweminyaka kwematjhumi alithoba. Kumumuntu osese ngaphasi kwetlhogomelo nelawulo lababelethi.</text>
      <sha1>74u2r8n6ybog1n52tvf46v9rrrgp9vs</sha1>
    </revision>
    <revision>
      <id>1504</id>
      <parentid>1503</parentid>
      <timestamp>2024-07-08T09:25:35Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1504</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="204" sha1="bc9gdymihqg3hl2m3h5owvsp47l503r" xml:space="preserve">[[Isimumathi:Little girl of Don Som.jpg|thumb|umntwana]]
'''umntwana''' mumuntu ongaphasi kweminyaka engaphasi kweminyaka kwematjhumi alithoba. Kumumuntu osese ngaphasi kwetlhogomelo nelawulo lababelethi.</text>
      <sha1>bc9gdymihqg3hl2m3h5owvsp47l503r</sha1>
    </revision>
    <revision>
      <id>1505</id>
      <parentid>1504</parentid>
      <timestamp>2024-07-08T09:25:47Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1505</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="204" sha1="kfo48crv77tpd2fd57rxlgmxoy7kfqg" xml:space="preserve">[[Isimumathi:Little girl of Don Som.jpg|thumb|umntwana]]
'''Umntwana''' mumuntu ongaphasi kweminyaka engaphasi kweminyaka kwematjhumi alithoba. Kumumuntu osese ngaphasi kwetlhogomelo nelawulo lababelethi.</text>
      <sha1>kfo48crv77tpd2fd57rxlgmxoy7kfqg</sha1>
    </revision>
    <revision>
      <id>1506</id>
      <parentid>1505</parentid>
      <timestamp>2024-07-10T13:50:55Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1506</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="202" sha1="kfvja7whx56n04a8v045lp5ngbmrzjf" xml:space="preserve">[[Isimumathi:Little girl of Don Som.jpg|thumb|umntwana]]
'''Umntwana''' mumuntu ongaphasi kweminyaka engaphasi kweminyaka ematjhumi alithoba. Kumumuntu osese ngaphasi kwetlhogomelo nelawulo lababelethi.</text>
      <sha1>kfvja7whx56n04a8v045lp5ngbmrzjf</sha1>
    </revision>
    <revision>
      <id>1507</id>
      <parentid>1506</parentid>
      <timestamp>2024-10-14T13:47:44Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>4 revisions imported</comment>
      <origin>1506</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="202" sha1="kfvja7whx56n04a8v045lp5ngbmrzjf" xml:space="preserve">[[Isimumathi:Little girl of Don Som.jpg|thumb|umntwana]]
'''Umntwana''' mumuntu ongaphasi kweminyaka engaphasi kweminyaka ematjhumi alithoba. Kumumuntu osese ngaphasi kwetlhogomelo nelawulo lababelethi.</text>
      <sha1>kfvja7whx56n04a8v045lp5ngbmrzjf</sha1>
    </revision>
    <revision>
      <id>3005</id>
      <parentid>1507</parentid>
      <timestamp>2025-06-06T20:21:38Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>L</comment>
      <origin>3005</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="283" sha1="7tkll9i0fxtfepui9xcpjpw9pni0ofx" xml:space="preserve">[[Isimumathi:Little girl of Don Som.jpg|thumb|umntwana]]
'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. Unwanted''' mumuntu ongaphasi kweminyaka engaphasi kweminyaka ematjhumi alithoba. Kumumuntu osese ngaphasi kwetlhogomelo nelawulo lababelethi.</text>
      <sha1>7tkll9i0fxtfepui9xcpjpw9pni0ofx</sha1>
    </revision>
    <revision>
      <id>3058</id>
      <parentid>3005</parentid>
      <timestamp>2025-06-07T03:05:22Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Jon Harald Søby|Jon Harald Søby]]</comment>
      <origin>1506</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="202" sha1="kfvja7whx56n04a8v045lp5ngbmrzjf" xml:space="preserve">[[Isimumathi:Little girl of Don Som.jpg|thumb|umntwana]]
'''Umntwana''' mumuntu ongaphasi kweminyaka engaphasi kweminyaka ematjhumi alithoba. Kumumuntu osese ngaphasi kwetlhogomelo nelawulo lababelethi.</text>
      <sha1>kfvja7whx56n04a8v045lp5ngbmrzjf</sha1>
    </revision>
  </page>
  <page>
    <title>Umoya Ocwengileko</title>
    <ns>0</ns>
    <id>278</id>
    <revision>
      <id>1508</id>
      <timestamp>2024-07-10T10:37:24Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Umoya ocwengileko''', mumomya ovela kuZimu. Umoya lo wafika ephasini lokha uJesu kreste  nakabuyela ezulwini kuyise uZimu. Kwathi bona uJesu akhambe watjhiya umoya ocwengileko bonyana uzokuthatha isikhundla sakhe uhlale nabantu abamakreste. umoya ocwengileko oowaziwa ngokuthi nguye umsizi wamakholwa owasiza bona aphile ipilo ecwengilweko.  &quot;</comment>
      <origin>1508</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="345" sha1="avvd50x0ii7l9lzjejyr7c8oii4rcba" xml:space="preserve">'''Umoya ocwengileko''', mumomya ovela kuZimu. Umoya lo wafika ephasini lokha uJesu kreste  nakabuyela ezulwini kuyise uZimu. Kwathi bona uJesu akhambe watjhiya umoya ocwengileko bonyana uzokuthatha isikhundla sakhe uhlale nabantu abamakreste. umoya ocwengileko oowaziwa ngokuthi nguye umsizi wamakholwa owasiza bona aphile ipilo ecwengilweko.

</text>
      <sha1>avvd50x0ii7l9lzjejyr7c8oii4rcba</sha1>
    </revision>
    <revision>
      <id>1509</id>
      <parentid>1508</parentid>
      <timestamp>2024-07-10T10:38:31Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1509</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="421" sha1="q1iyq4b7p62e9j0klpih28l2etmj2be" xml:space="preserve">'''Umoya ocwengileko''', mumomya ovela kuZimu. Umoya lo wafika ephasini lokha uJesu kreste  nakabuyela ezulwini kuyise uZimu. Kwathi bona uJesu akhambe watjhiya umoya ocwengileko bonyana uzokuthatha isikhundla sakhe uhlale nabantu abamakreste. umoya ocwengileko oowaziwa ngokuthi nguye umsizi wamakholwa owasiza bona aphile ipilo ecwengilweko.&lt;ref&gt;Kuyper, A. (2007). ''The work of the Holy Spirit''. Cosimo, Inc..&lt;/ref&gt;

</text>
      <sha1>q1iyq4b7p62e9j0klpih28l2etmj2be</sha1>
    </revision>
    <revision>
      <id>1510</id>
      <parentid>1509</parentid>
      <timestamp>2024-07-10T10:38:49Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1510</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="425" sha1="qsv7htt47nfh25e5ftmraa2r8u99s4q" xml:space="preserve">'''Umoya ocwengileko''', mumomya ovela ku[[Zimu]]. Umoya lo wafika ephasini lokha uJesu kreste  nakabuyela ezulwini kuyise uZimu. Kwathi bona uJesu akhambe watjhiya umoya ocwengileko bonyana uzokuthatha isikhundla sakhe uhlale nabantu abamakreste. umoya ocwengileko oowaziwa ngokuthi nguye umsizi wamakholwa owasiza bona aphile ipilo ecwengilweko.&lt;ref&gt;Kuyper, A. (2007). ''The work of the Holy Spirit''. Cosimo, Inc..&lt;/ref&gt;

</text>
      <sha1>qsv7htt47nfh25e5ftmraa2r8u99s4q</sha1>
    </revision>
    <revision>
      <id>1511</id>
      <parentid>1510</parentid>
      <timestamp>2024-07-10T13:49:20Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1511</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="534" sha1="mekio8xcahpq3ib53vctvbgdk398f75" xml:space="preserve">'''Umoya ocwengileko''', mumomya ovela ku[[Zimu]]. Umoya lo wafika ephasini lokha uJesu kreste  nakabuyela ezulwini kuyise uZimu. Kwathi bona uJesu akhambe watjhiya umoya ocwengileko bonyana uzokuthatha isikhundla sakhe uhlale nabantu abamakreste. umoya ocwengileko oowaziwa ngokuthi nguye umsizi wamakholwa owasiza bona aphile ipilo ecwengilweko.&lt;ref&gt;Kuyper, A. (2007). ''The work of the Holy Spirit''. Cosimo, Inc..&lt;/ref&gt; Umoya ocwengileko ngiloyo Moya othi nawuwamukeleko ukhone ukwenza izinto ezihle begodu ube nemikghwa emihle.

</text>
      <sha1>mekio8xcahpq3ib53vctvbgdk398f75</sha1>
    </revision>
    <revision>
      <id>1512</id>
      <parentid>1511</parentid>
      <timestamp>2024-10-14T13:47:44Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>4 revisions imported</comment>
      <origin>1511</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="534" sha1="mekio8xcahpq3ib53vctvbgdk398f75" xml:space="preserve">'''Umoya ocwengileko''', mumomya ovela ku[[Zimu]]. Umoya lo wafika ephasini lokha uJesu kreste  nakabuyela ezulwini kuyise uZimu. Kwathi bona uJesu akhambe watjhiya umoya ocwengileko bonyana uzokuthatha isikhundla sakhe uhlale nabantu abamakreste. umoya ocwengileko oowaziwa ngokuthi nguye umsizi wamakholwa owasiza bona aphile ipilo ecwengilweko.&lt;ref&gt;Kuyper, A. (2007). ''The work of the Holy Spirit''. Cosimo, Inc..&lt;/ref&gt; Umoya ocwengileko ngiloyo Moya othi nawuwamukeleko ukhone ukwenza izinto ezihle begodu ube nemikghwa emihle.

</text>
      <sha1>mekio8xcahpq3ib53vctvbgdk398f75</sha1>
    </revision>
  </page>
  <page>
    <title>Umrhatjho ikwekwezi</title>
    <ns>0</ns>
    <id>279</id>
    <revision>
      <id>1513</id>
      <timestamp>2024-07-10T10:57:53Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Ikwekwezi''' mrhatjho omkhulu eSewula Afrika orhatjha ngesiNdebele.  &quot;</comment>
      <origin>1513</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="72" sha1="kw6rmcssmhxdk1s5rq3ypujezlso2zr" xml:space="preserve">'''Ikwekwezi''' mrhatjho omkhulu eSewula Afrika orhatjha ngesiNdebele.

</text>
      <sha1>kw6rmcssmhxdk1s5rq3ypujezlso2zr</sha1>
    </revision>
    <revision>
      <id>1514</id>
      <parentid>1513</parentid>
      <timestamp>2024-07-12T17:10:50Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1514</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="386" sha1="qpc0ntarc5934ve3h56pzqff6s3skh5" xml:space="preserve">'''Ikwekwezi''' mrhatjho omkhulu eSewula Afrika orhatjha ngesiNdebele. Umrhatjho wasungulwa ngonyaka we-1983 enyangeni kaTjhirhweni mhlana ilanga li-1, okutjho ukuthi kwabe kuthoma unyaka ngaleso skhathi. Mrhatjho lo urhatjhwa malanga woke evekeni ngesikhathi soke. Ikwekwezi itholakala endaweni ye-Johannesburg e Auckland Park. Umunru owansungula umrhatjho weKwekwezi ngu Thizathiza.

</text>
      <sha1>qpc0ntarc5934ve3h56pzqff6s3skh5</sha1>
    </revision>
    <revision>
      <id>1515</id>
      <parentid>1514</parentid>
      <timestamp>2024-10-14T13:47:45Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>1514</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="386" sha1="qpc0ntarc5934ve3h56pzqff6s3skh5" xml:space="preserve">'''Ikwekwezi''' mrhatjho omkhulu eSewula Afrika orhatjha ngesiNdebele. Umrhatjho wasungulwa ngonyaka we-1983 enyangeni kaTjhirhweni mhlana ilanga li-1, okutjho ukuthi kwabe kuthoma unyaka ngaleso skhathi. Mrhatjho lo urhatjhwa malanga woke evekeni ngesikhathi soke. Ikwekwezi itholakala endaweni ye-Johannesburg e Auckland Park. Umunru owansungula umrhatjho weKwekwezi ngu Thizathiza.

</text>
      <sha1>qpc0ntarc5934ve3h56pzqff6s3skh5</sha1>
    </revision>
  </page>
  <page>
    <title>Umthetho</title>
    <ns>0</ns>
    <id>280</id>
    <revision>
      <id>1516</id>
      <timestamp>2024-07-05T16:10:24Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;[[Isimumathi:Rule of Law.jpg|thumb]] '''Umthetho''' yindlela inarha ethileko eziphatha ngakhona. Akekho umuntu ongaphasi komthetho  &quot;</comment>
      <origin>1516</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="132" sha1="oid698z2c0x7zriroggdi2seco45kwz" xml:space="preserve">[[Isimumathi:Rule of Law.jpg|thumb]]
'''Umthetho''' yindlela inarha ethileko eziphatha ngakhona. Akekho umuntu ongaphasi komthetho

</text>
      <sha1>oid698z2c0x7zriroggdi2seco45kwz</sha1>
    </revision>
    <revision>
      <id>1517</id>
      <parentid>1516</parentid>
      <timestamp>2024-07-05T19:19:39Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1517</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="265" sha1="b0fwfl82bl48flhnuc59mti2dfl5adp" xml:space="preserve">[[Isimumathi:Rule of Law.jpg|thumb]]
'''Umthetho''' yindlela inarha ethileko eziphatha ngakhona. Akekho umuntu ongaphasi komthetho.  Umthetho unikela indlela ekuzokurarulwa ngayo imilandu, ekuzokuvikelwa ngayo amalungelo wabantu begodu inikele abantu ubulungiswa.

</text>
      <sha1>b0fwfl82bl48flhnuc59mti2dfl5adp</sha1>
    </revision>
    <revision>
      <id>1518</id>
      <parentid>1517</parentid>
      <timestamp>2024-10-14T13:47:45Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>1517</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="265" sha1="b0fwfl82bl48flhnuc59mti2dfl5adp" xml:space="preserve">[[Isimumathi:Rule of Law.jpg|thumb]]
'''Umthetho''' yindlela inarha ethileko eziphatha ngakhona. Akekho umuntu ongaphasi komthetho.  Umthetho unikela indlela ekuzokurarulwa ngayo imilandu, ekuzokuvikelwa ngayo amalungelo wabantu begodu inikele abantu ubulungiswa.

</text>
      <sha1>b0fwfl82bl48flhnuc59mti2dfl5adp</sha1>
    </revision>
    <revision>
      <id>2999</id>
      <parentid>1518</parentid>
      <timestamp>2025-06-06T20:18:46Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>just have less pages plz</comment>
      <origin>2999</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="344" sha1="58uaor7wonkzgu66venef65bhwyd9bb" xml:space="preserve">[[Isimumathi:Rule of Law.jpg|thumb]]
'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. Umthetho''' yindlela inarha ethileko eziphatha ngakhona. Akekho umuntu ongaphasi komthetho.  Umthetho unikela indlela ekuzokurarulwa ngayo imilandu, ekuzokuvikelwa ngayo amalungelo wabantu begodu inikele abantu ubulungiswa.</text>
      <sha1>58uaor7wonkzgu66venef65bhwyd9bb</sha1>
    </revision>
    <revision>
      <id>3050</id>
      <parentid>2999</parentid>
      <timestamp>2025-06-07T03:05:22Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Jon Harald Søby|Jon Harald Søby]]</comment>
      <origin>1517</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="265" sha1="b0fwfl82bl48flhnuc59mti2dfl5adp" xml:space="preserve">[[Isimumathi:Rule of Law.jpg|thumb]]
'''Umthetho''' yindlela inarha ethileko eziphatha ngakhona. Akekho umuntu ongaphasi komthetho.  Umthetho unikela indlela ekuzokurarulwa ngayo imilandu, ekuzokuvikelwa ngayo amalungelo wabantu begodu inikele abantu ubulungiswa.

</text>
      <sha1>b0fwfl82bl48flhnuc59mti2dfl5adp</sha1>
    </revision>
  </page>
  <page>
    <title>Umthetho sisekelo</title>
    <ns>0</ns>
    <id>281</id>
    <revision>
      <id>1519</id>
      <timestamp>2024-06-30T17:10:16Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Umthetho sisekelo''' kuyincwadi ephethe amandla wombuso begodu iphethe amalungelo nokuvikeleka kwesitjhaba.  &quot;</comment>
      <origin>1519</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="112" sha1="o43rv53ybpubvjpghx3wkxkh146i3a7" xml:space="preserve">'''Umthetho sisekelo''' kuyincwadi ephethe amandla wombuso begodu iphethe amalungelo nokuvikeleka kwesitjhaba.

</text>
      <sha1>o43rv53ybpubvjpghx3wkxkh146i3a7</sha1>
    </revision>
    <revision>
      <id>1520</id>
      <parentid>1519</parentid>
      <timestamp>2024-06-30T17:18:46Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1520</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="210" sha1="4smbhcisfzlft3w50pwi3f1lwefi9l2" xml:space="preserve">[[Isimumathi:The Constitution of the Republic of South Africa, 1996. 023.JPG|thumb|constitution]]
'''Umthetho sisekelo''' kuyincwadi ephethe amandla wombuso begodu iphethe amalungelo nokuvikeleka kwesitjhaba.

</text>
      <sha1>4smbhcisfzlft3w50pwi3f1lwefi9l2</sha1>
    </revision>
    <revision>
      <id>1521</id>
      <parentid>1520</parentid>
      <timestamp>2024-06-30T18:45:45Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1521</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="453" sha1="341qjth3y9m2irh8686u64bo5jv7xn4" xml:space="preserve">[[Isimumathi:The Constitution of the Republic of South Africa, 1996. 023.JPG|thumb|constitution]]
'''Umthetho sisekelo''' kuyincwadi ephethe amandla wombuso begodu iphethe amalungelo nokuvikeleka kwesitjhaba. Kuyinto eqakatheke ekuhlathululeni umthetho nepolotiki zenarha. Umthetho sisekelo wenza bona boke abantu babe ngaphasi komthetho ngitjho nabaphezulu ngokweenkhundla. Uvikela ukuhlukunyezwa kamandla negunya enkhundleni ezithileko ezihlukileko.

</text>
      <sha1>341qjth3y9m2irh8686u64bo5jv7xn4</sha1>
    </revision>
    <revision>
      <id>1522</id>
      <parentid>1521</parentid>
      <timestamp>2024-10-14T13:47:45Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>1521</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="453" sha1="341qjth3y9m2irh8686u64bo5jv7xn4" xml:space="preserve">[[Isimumathi:The Constitution of the Republic of South Africa, 1996. 023.JPG|thumb|constitution]]
'''Umthetho sisekelo''' kuyincwadi ephethe amandla wombuso begodu iphethe amalungelo nokuvikeleka kwesitjhaba. Kuyinto eqakatheke ekuhlathululeni umthetho nepolotiki zenarha. Umthetho sisekelo wenza bona boke abantu babe ngaphasi komthetho ngitjho nabaphezulu ngokweenkhundla. Uvikela ukuhlukunyezwa kamandla negunya enkhundleni ezithileko ezihlukileko.

</text>
      <sha1>341qjth3y9m2irh8686u64bo5jv7xn4</sha1>
    </revision>
  </page>
  <page>
    <title>Umthethosisekelo</title>
    <ns>0</ns>
    <id>282</id>
    <revision>
      <id>1523</id>
      <timestamp>2024-09-14T09:20:09Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;== Umthethosisekelo ==  === Isingeniso === Umthethosisekelo ngezinye zezinto eziqakatheke khulu kwamambala ekwenzeni isiqiniseko sokuthi kuba nokuphatha kuhle kanye nokwenza izinto ngomthetho ngaphandle kokugadanga abanye abantu amazizo. Ukudlula lapho umthetheosisekelo welusa iinkareko zomphakathi bonyana ziqalelelwe ngaso soke isikhathi. Eenhlokweni ezilandelako zizokutjheja bonyana umthetho sisekelo kuyini begodu yini imisebenzi yawo.  === Kuyini umthethosisekelo? ===...&quot;</comment>
      <origin>1523</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3891" sha1="3ancrpy9ar665a9un5nig5tot394yp9" xml:space="preserve">== Umthethosisekelo ==

=== Isingeniso ===
Umthethosisekelo ngezinye zezinto eziqakatheke khulu kwamambala ekwenzeni isiqiniseko sokuthi kuba nokuphatha kuhle kanye nokwenza izinto ngomthetho ngaphandle kokugadanga abanye abantu amazizo. Ukudlula lapho umthetheosisekelo welusa iinkareko zomphakathi bonyana ziqalelelwe ngaso soke isikhathi. Eenhlokweni ezilandelako zizokutjheja bonyana umthetho sisekelo kuyini begodu yini imisebenzi yawo.

=== Kuyini umthethosisekelo? ===
Ngokuya kuka-Myanmar&lt;ref name=&quot;:0&quot;&gt;Myanmar. 2013. ''Constitution Awareness''. Bingham Centre for the Rule of Law: LexisNexis.&lt;/ref&gt; (2013) umthethosisekelo libuthelelo lemithethi kanye nemithethomgomo leyo eyenzelwe ukubuswa kwenarha. Ngamanye amagama, umthethosisekelo wenziwe mithetho nemithethomgomo leyo ehlahla begodu eyenza isiqiniseko sokuthi inarha ilawulwa kuhle. Ukungezelela, umthethosisekelo uhlathulula iinkambiso neenkambisosilawulo zemikhakha yombuso begodu wenza isiqiniseko sokuthi amalungelo wemiphakathi akagadangelwa nanyana akaphulwa ngeminye imithetho ejwayelekileko (International Institute for the Democracy and Electoral Assistance 2014&lt;ref name=&quot;:1&quot;&gt;International Institution for Democracy Electoral Assistance. 2014. What is a Constitution? Principles and Concepts. ''International IDEA'', :1-12.&lt;/ref&gt;). Lokhu kusitjheja bonyana umthethosisekelo wenza isiqiniseko sokuthi iinfuneko kanye namakareko wemiphakathi ayahlonitjhwa ngeminye imithetho ejwayelekileko yokulawulwa kwenarha.

Umthethosisekelo mthetho omkhulu enarheni yoke begodu akukho omunye umthetho ekufanele utjhayisane nawo nanyana ayikho into eyenziwako ekufanele itjhayisane nawo (UmThethosisekelo 1996&lt;ref&gt;Umthethosisekelo weRiphabhliki yeSewula Afrika. 1996. ''Umthethosisekelo''. Parliament of the Republic of South Afrika: Cape Town.&lt;/ref&gt;; ne-Wikipedia 2024&lt;ref&gt;Wikipedia. 2024. ''Constitution of South Africa''. Litholakala ku:&lt;nowiki&gt;https://en.wikipedia.org/wiki/Constitution_of_South_Africa&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [18 kuRhoboyi 2024].&lt;/ref&gt;). Lokhu kutjho bona akunamuntu nanyana ngubani, ekufaka hlangan zoke iinhlangano, iinkhaphani kanye nombuzo ngokupheleleko, onelungelo lokwenza isenzo leso esingakhambelani nomthethosisekelo. Nakungenzeka kube nomuntu ongenza isenzo esingakhambelani nomthethosisekelo, angadoselwa ekhotho begodu agwetjwe.

=== Kuyini imisebenzi yomthethisisekelo na? ===
Imisebenzi yemithetho sisekelo minengi, begodu ifaka hlangan elandelako:

1.      Ukuveza nokutjengisa imikhawulo yomphakathi yombanganarha (International Institute for the Democracy and Electoral Assistance 2014&lt;ref name=&quot;:1&quot; /&gt;)

2.      Ukuveza nokuqinisekisa ubujamo namandla wombuso (International Institute for the Democracy and Electoral Assistance 2014&lt;ref name=&quot;:1&quot; /&gt;)

3.      Ukunikela nokuqinisekisa amalungelo nemisebenzi yomphakathi (Myanmar 2013&lt;ref name=&quot;:0&quot; /&gt;)

4.      Ukuqinisekisa nokulawulwa kweenhlangano zekolo kanye nobudlelwano babo neembethamthetho (Myanmar 2013&lt;ref name=&quot;:0&quot; /&gt;)

5.      Uqinisekisa bonyana umbuso uziphendulele njani ebantwini nemiphakathini  leyo eyibusako (UmThethosisekelo 1996&lt;ref&gt;Umthethosisekelo weRiphabhliki yeSewula Afrika. 1996. The Basic Provisions of the Constitution of the Republic of South Africa, 1996, ''Made Easy for Learners''. Parliament of the Republic of South Africa: Cape Town.&lt;/ref&gt;).


Imisebenzi yomthethosisekelo engehla le, ayikaphelele kodwana le ngeminye eqakatheke khulu ekwenzeni isiqiniseko sokuthi umthethosisekelo ufinyelela umnqopho wawo.

=== Isiphetho ===
Umthethosisekelo kumthetho oqakathekileko begodu nomkhulu ukudlula yoke imithetho ekhona enarheni. Umthetho lo umhlahlandlela begodu wenza isiqiniseko sokuthi kuba nokuthula, ukusebnzisana kanye nokuphilisana kuhle enarheni yoke. Kuqakathekile bonyana abantu bazi ngomthethosisekelo begodu bawufunde bawuzwisise.

=== Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>3ancrpy9ar665a9un5nig5tot394yp9</sha1>
    </revision>
    <revision>
      <id>1524</id>
      <parentid>1523</parentid>
      <timestamp>2024-09-14T09:38:59Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <origin>1524</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3928" sha1="msbun6r7145rq6m0oibydg9yzto8t91" xml:space="preserve">== Umthethosisekelo ==

=== Isingeniso ===
[[:en:Constitution_of_South_Africa|Umthethosisekelo]] ngezinye zezinto eziqakatheke khulu kwamambala ekwenzeni isiqiniseko sokuthi kuba nokuphatha kuhle kanye nokwenza izinto ngomthetho ngaphandle kokugadanga abanye abantu amazizo. Ukudlula lapho umthetheosisekelo welusa iinkareko zomphakathi bonyana ziqalelelwe ngaso soke isikhathi. Eenhlokweni ezilandelako zizokutjheja bonyana umthetho sisekelo kuyini begodu yini imisebenzi yawo.

=== Kuyini umthethosisekelo? ===
Ngokuya kuka-Myanmar&lt;ref name=&quot;:0&quot;&gt;Myanmar. 2013. ''Constitution Awareness''. Bingham Centre for the Rule of Law: LexisNexis.&lt;/ref&gt; (2013) umthethosisekelo libuthelelo lemithethi kanye nemithethomgomo leyo eyenzelwe ukubuswa kwenarha. Ngamanye amagama, umthethosisekelo wenziwe mithetho nemithethomgomo leyo ehlahla begodu eyenza isiqiniseko sokuthi inarha ilawulwa kuhle. Ukungezelela, umthethosisekelo uhlathulula iinkambiso neenkambisosilawulo zemikhakha yombuso begodu wenza isiqiniseko sokuthi amalungelo wemiphakathi akagadangelwa nanyana akaphulwa ngeminye imithetho ejwayelekileko (International Institute for the Democracy and Electoral Assistance 2014&lt;ref name=&quot;:1&quot;&gt;International Institution for Democracy Electoral Assistance. 2014. What is a Constitution? Principles and Concepts. ''International IDEA'', :1-12.&lt;/ref&gt;). Lokhu kusitjheja bonyana umthethosisekelo wenza isiqiniseko sokuthi iinfuneko kanye namakareko wemiphakathi ayahlonitjhwa ngeminye imithetho ejwayelekileko yokulawulwa kwenarha.

Umthethosisekelo mthetho omkhulu enarheni yoke begodu akukho omunye umthetho ekufanele utjhayisane nawo nanyana ayikho into eyenziwako ekufanele itjhayisane nawo (UmThethosisekelo 1996&lt;ref&gt;Umthethosisekelo weRiphabhliki yeSewula Afrika. 1996. ''Umthethosisekelo''. Parliament of the Republic of South Afrika: Cape Town.&lt;/ref&gt;; ne-Wikipedia 2024&lt;ref&gt;Wikipedia. 2024. ''Constitution of South Africa''. Litholakala ku:&lt;nowiki&gt;https://en.wikipedia.org/wiki/Constitution_of_South_Africa&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [18 kuRhoboyi 2024].&lt;/ref&gt;). Lokhu kutjho bona akunamuntu nanyana ngubani, ekufaka hlangan zoke iinhlangano, iinkhaphani kanye nombuzo ngokupheleleko, onelungelo lokwenza isenzo leso esingakhambelani nomthethosisekelo. Nakungenzeka kube nomuntu ongenza isenzo esingakhambelani nomthethosisekelo, angadoselwa ekhotho begodu agwetjwe.

=== Kuyini imisebenzi yomthethisisekelo na? ===
Imisebenzi yemithetho sisekelo minengi, begodu ifaka hlangan elandelako:

1.      Ukuveza nokutjengisa imikhawulo yomphakathi yombanganarha (International Institute for the Democracy and Electoral Assistance 2014&lt;ref name=&quot;:1&quot; /&gt;)

2.      Ukuveza nokuqinisekisa ubujamo namandla wombuso (International Institute for the Democracy and Electoral Assistance 2014&lt;ref name=&quot;:1&quot; /&gt;)

3.      Ukunikela nokuqinisekisa amalungelo nemisebenzi yomphakathi (Myanmar 2013&lt;ref name=&quot;:0&quot; /&gt;)

4.      Ukuqinisekisa nokulawulwa kweenhlangano zekolo kanye nobudlelwano babo neembethamthetho (Myanmar 2013&lt;ref name=&quot;:0&quot; /&gt;)

5.      Uqinisekisa bonyana umbuso uziphendulele njani ebantwini nemiphakathini  leyo eyibusako (UmThethosisekelo 1996&lt;ref&gt;Umthethosisekelo weRiphabhliki yeSewula Afrika. 1996. The Basic Provisions of the Constitution of the Republic of South Africa, 1996, ''Made Easy for Learners''. Parliament of the Republic of South Africa: Cape Town.&lt;/ref&gt;).


Imisebenzi yomthethosisekelo engehla le, ayikaphelele kodwana le ngeminye eqakatheke khulu ekwenzeni isiqiniseko sokuthi umthethosisekelo ufinyelela umnqopho wawo.

=== Isiphetho ===
Umthethosisekelo kumthetho oqakathekileko begodu nomkhulu ukudlula yoke imithetho ekhona enarheni. Umthetho lo umhlahlandlela begodu wenza isiqiniseko sokuthi kuba nokuthula, ukusebnzisana kanye nokuphilisana kuhle enarheni yoke. Kuqakathekile bonyana abantu bazi ngomthethosisekelo begodu bawufunde bawuzwisise.

=== Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>msbun6r7145rq6m0oibydg9yzto8t91</sha1>
    </revision>
    <revision>
      <id>1525</id>
      <parentid>1524</parentid>
      <timestamp>2024-09-18T16:06:11Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1525</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3930" sha1="ehje95cctkbwmwwpmym6qeb6pcj6ebs" xml:space="preserve">== Umthethosisekelo. ==

=== Isingeniso. ===
[[:en:Constitution_of_South_Africa|Umthethosisekelo]] ngezinye zezinto eziqakatheke khulu kwamambala ekwenzeni isiqiniseko sokuthi kuba nokuphatha kuhle kanye nokwenza izinto ngomthetho ngaphandle kokugadanga abanye abantu amazizo. Ukudlula lapho umthetheosisekelo welusa iinkareko zomphakathi bonyana ziqalelelwe ngaso soke isikhathi. Eenhlokweni ezilandelako zizokutjheja bonyana umthetho sisekelo kuyini begodu yini imisebenzi yawo.

=== Kuyini umthethosisekelo? ===
Ngokuya kuka-Myanmar&lt;ref name=&quot;:0&quot;&gt;Myanmar. 2013. ''Constitution Awareness''. Bingham Centre for the Rule of Law: LexisNexis.&lt;/ref&gt; (2013) umthethosisekelo libuthelelo lemithethi kanye nemithethomgomo leyo eyenzelwe ukubuswa kwenarha. Ngamanye amagama, umthethosisekelo wenziwe mithetho nemithethomgomo leyo ehlahla begodu eyenza isiqiniseko sokuthi inarha ilawulwa kuhle. Ukungezelela, umthethosisekelo uhlathulula iinkambiso neenkambisosilawulo zemikhakha yombuso begodu wenza isiqiniseko sokuthi amalungelo wemiphakathi akagadangelwa nanyana akaphulwa ngeminye imithetho ejwayelekileko (International Institute for the Democracy and Electoral Assistance 2014&lt;ref name=&quot;:1&quot;&gt;International Institution for Democracy Electoral Assistance. 2014. What is a Constitution? Principles and Concepts. ''International IDEA'', :1-12.&lt;/ref&gt;). Lokhu kusitjheja bonyana umthethosisekelo wenza isiqiniseko sokuthi iinfuneko kanye namakareko wemiphakathi ayahlonitjhwa ngeminye imithetho ejwayelekileko yokulawulwa kwenarha.

Umthethosisekelo mthetho omkhulu enarheni yoke begodu akukho omunye umthetho ekufanele utjhayisane nawo nanyana ayikho into eyenziwako ekufanele itjhayisane nawo (UmThethosisekelo 1996&lt;ref&gt;Umthethosisekelo weRiphabhliki yeSewula Afrika. 1996. ''Umthethosisekelo''. Parliament of the Republic of South Afrika: Cape Town.&lt;/ref&gt;; ne-Wikipedia 2024&lt;ref&gt;Wikipedia. 2024. ''Constitution of South Africa''. Litholakala ku:&lt;nowiki&gt;https://en.wikipedia.org/wiki/Constitution_of_South_Africa&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [18 kuRhoboyi 2024].&lt;/ref&gt;). Lokhu kutjho bona akunamuntu nanyana ngubani, ekufaka hlangan zoke iinhlangano, iinkhaphani kanye nombuzo ngokupheleleko, onelungelo lokwenza isenzo leso esingakhambelani nomthethosisekelo. Nakungenzeka kube nomuntu ongenza isenzo esingakhambelani nomthethosisekelo, angadoselwa ekhotho begodu agwetjwe.

=== Kuyini imisebenzi yomthethisisekelo na? ===
Imisebenzi yemithetho sisekelo minengi, begodu ifaka hlangan elandelako:

1.      Ukuveza nokutjengisa imikhawulo yomphakathi yombanganarha (International Institute for the Democracy and Electoral Assistance 2014&lt;ref name=&quot;:1&quot; /&gt;)

2.      Ukuveza nokuqinisekisa ubujamo namandla wombuso (International Institute for the Democracy and Electoral Assistance 2014&lt;ref name=&quot;:1&quot; /&gt;)

3.      Ukunikela nokuqinisekisa amalungelo nemisebenzi yomphakathi (Myanmar 2013&lt;ref name=&quot;:0&quot; /&gt;)

4.      Ukuqinisekisa nokulawulwa kweenhlangano zekolo kanye nobudlelwano babo neembethamthetho (Myanmar 2013&lt;ref name=&quot;:0&quot; /&gt;)

5.      Uqinisekisa bonyana umbuso uziphendulele njani ebantwini nemiphakathini  leyo eyibusako (UmThethosisekelo 1996&lt;ref&gt;Umthethosisekelo weRiphabhliki yeSewula Afrika. 1996. The Basic Provisions of the Constitution of the Republic of South Africa, 1996, ''Made Easy for Learners''. Parliament of the Republic of South Africa: Cape Town.&lt;/ref&gt;).


Imisebenzi yomthethosisekelo engehla le, ayikaphelele kodwana le ngeminye eqakatheke khulu ekwenzeni isiqiniseko sokuthi umthethosisekelo ufinyelela umnqopho wawo.

=== Isiphetho ===
Umthethosisekelo kumthetho oqakathekileko begodu nomkhulu ukudlula yoke imithetho ekhona enarheni. Umthetho lo umhlahlandlela begodu wenza isiqiniseko sokuthi kuba nokuthula, ukusebnzisana kanye nokuphilisana kuhle enarheni yoke. Kuqakathekile bonyana abantu bazi ngomthethosisekelo begodu bawufunde bawuzwisise.

=== Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>ehje95cctkbwmwwpmym6qeb6pcj6ebs</sha1>
    </revision>
    <revision>
      <id>1526</id>
      <parentid>1525</parentid>
      <timestamp>2024-10-14T13:47:45Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>1525</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3930" sha1="ehje95cctkbwmwwpmym6qeb6pcj6ebs" xml:space="preserve">== Umthethosisekelo. ==

=== Isingeniso. ===
[[:en:Constitution_of_South_Africa|Umthethosisekelo]] ngezinye zezinto eziqakatheke khulu kwamambala ekwenzeni isiqiniseko sokuthi kuba nokuphatha kuhle kanye nokwenza izinto ngomthetho ngaphandle kokugadanga abanye abantu amazizo. Ukudlula lapho umthetheosisekelo welusa iinkareko zomphakathi bonyana ziqalelelwe ngaso soke isikhathi. Eenhlokweni ezilandelako zizokutjheja bonyana umthetho sisekelo kuyini begodu yini imisebenzi yawo.

=== Kuyini umthethosisekelo? ===
Ngokuya kuka-Myanmar&lt;ref name=&quot;:0&quot;&gt;Myanmar. 2013. ''Constitution Awareness''. Bingham Centre for the Rule of Law: LexisNexis.&lt;/ref&gt; (2013) umthethosisekelo libuthelelo lemithethi kanye nemithethomgomo leyo eyenzelwe ukubuswa kwenarha. Ngamanye amagama, umthethosisekelo wenziwe mithetho nemithethomgomo leyo ehlahla begodu eyenza isiqiniseko sokuthi inarha ilawulwa kuhle. Ukungezelela, umthethosisekelo uhlathulula iinkambiso neenkambisosilawulo zemikhakha yombuso begodu wenza isiqiniseko sokuthi amalungelo wemiphakathi akagadangelwa nanyana akaphulwa ngeminye imithetho ejwayelekileko (International Institute for the Democracy and Electoral Assistance 2014&lt;ref name=&quot;:1&quot;&gt;International Institution for Democracy Electoral Assistance. 2014. What is a Constitution? Principles and Concepts. ''International IDEA'', :1-12.&lt;/ref&gt;). Lokhu kusitjheja bonyana umthethosisekelo wenza isiqiniseko sokuthi iinfuneko kanye namakareko wemiphakathi ayahlonitjhwa ngeminye imithetho ejwayelekileko yokulawulwa kwenarha.

Umthethosisekelo mthetho omkhulu enarheni yoke begodu akukho omunye umthetho ekufanele utjhayisane nawo nanyana ayikho into eyenziwako ekufanele itjhayisane nawo (UmThethosisekelo 1996&lt;ref&gt;Umthethosisekelo weRiphabhliki yeSewula Afrika. 1996. ''Umthethosisekelo''. Parliament of the Republic of South Afrika: Cape Town.&lt;/ref&gt;; ne-Wikipedia 2024&lt;ref&gt;Wikipedia. 2024. ''Constitution of South Africa''. Litholakala ku:&lt;nowiki&gt;https://en.wikipedia.org/wiki/Constitution_of_South_Africa&lt;/nowiki&gt;&gt;. Ifunyenwe ngomhlaka [18 kuRhoboyi 2024].&lt;/ref&gt;). Lokhu kutjho bona akunamuntu nanyana ngubani, ekufaka hlangan zoke iinhlangano, iinkhaphani kanye nombuzo ngokupheleleko, onelungelo lokwenza isenzo leso esingakhambelani nomthethosisekelo. Nakungenzeka kube nomuntu ongenza isenzo esingakhambelani nomthethosisekelo, angadoselwa ekhotho begodu agwetjwe.

=== Kuyini imisebenzi yomthethisisekelo na? ===
Imisebenzi yemithetho sisekelo minengi, begodu ifaka hlangan elandelako:

1.      Ukuveza nokutjengisa imikhawulo yomphakathi yombanganarha (International Institute for the Democracy and Electoral Assistance 2014&lt;ref name=&quot;:1&quot; /&gt;)

2.      Ukuveza nokuqinisekisa ubujamo namandla wombuso (International Institute for the Democracy and Electoral Assistance 2014&lt;ref name=&quot;:1&quot; /&gt;)

3.      Ukunikela nokuqinisekisa amalungelo nemisebenzi yomphakathi (Myanmar 2013&lt;ref name=&quot;:0&quot; /&gt;)

4.      Ukuqinisekisa nokulawulwa kweenhlangano zekolo kanye nobudlelwano babo neembethamthetho (Myanmar 2013&lt;ref name=&quot;:0&quot; /&gt;)

5.      Uqinisekisa bonyana umbuso uziphendulele njani ebantwini nemiphakathini  leyo eyibusako (UmThethosisekelo 1996&lt;ref&gt;Umthethosisekelo weRiphabhliki yeSewula Afrika. 1996. The Basic Provisions of the Constitution of the Republic of South Africa, 1996, ''Made Easy for Learners''. Parliament of the Republic of South Africa: Cape Town.&lt;/ref&gt;).


Imisebenzi yomthethosisekelo engehla le, ayikaphelele kodwana le ngeminye eqakatheke khulu ekwenzeni isiqiniseko sokuthi umthethosisekelo ufinyelela umnqopho wawo.

=== Isiphetho ===
Umthethosisekelo kumthetho oqakathekileko begodu nomkhulu ukudlula yoke imithetho ekhona enarheni. Umthetho lo umhlahlandlela begodu wenza isiqiniseko sokuthi kuba nokuthula, ukusebnzisana kanye nokuphilisana kuhle enarheni yoke. Kuqakathekile bonyana abantu bazi ngomthethosisekelo begodu bawufunde bawuzwisise.

=== Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>ehje95cctkbwmwwpmym6qeb6pcj6ebs</sha1>
    </revision>
  </page>
  <page>
    <title>Umtjhado</title>
    <ns>0</ns>
    <id>283</id>
    <revision>
      <id>1527</id>
      <timestamp>2024-07-08T09:31:41Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Umtjhado''' kuvumelana kwababili, okumfazi nendoda phambi kwabofakazi noZimu ukuthi bazokuba nyama yinye. Umfazi utjhiya isibongo sakhe athethe sendoda begodu amukelwe emndenini wendoda. Ngaphambi kobana kube notjhado indoda iyalobola ukuze ikhone ukunikelwa umfazi wayo.&quot;</comment>
      <origin>1527</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="274" sha1="mwcgonuht0lbp7i7jyug7w5zc3olfm5" xml:space="preserve">'''Umtjhado''' kuvumelana kwababili, okumfazi nendoda phambi kwabofakazi noZimu ukuthi bazokuba nyama yinye. Umfazi utjhiya isibongo sakhe athethe sendoda begodu amukelwe emndenini wendoda. Ngaphambi kobana kube notjhado indoda iyalobola ukuze ikhone ukunikelwa umfazi wayo.</text>
      <sha1>mwcgonuht0lbp7i7jyug7w5zc3olfm5</sha1>
    </revision>
    <revision>
      <id>1528</id>
      <parentid>1527</parentid>
      <timestamp>2024-07-10T13:37:43Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1528</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="538" sha1="8keupz18cir4vigi6domlr8zvhhqny4" xml:space="preserve">'''Umtjhado''' kuvumelana kwababili, okumfazi nendoda phambi kwabofakazi noZimu ukuthi bazokuba nyama yinye. Umfazi utjhiya isibongo sakhe athethe sendoda begodu amukelwe emndenini wendoda. Ngaphambi kobana kube nomtjhado indoda iya[[lobola]] ukuze ikhone ukunikelwa umfazi wayo.

Umtjhado kulokha abantu abathandanako benza umsebenzi wokugidinga ithando labo begodu bafunge bebahlanganiswe mfundisi phambi kwabantu.

Minengi imohlobo yomtjhado.

Umtjhado wesintu.

Umtjhado wesikhuwa obizwa ngokuthi mtjhado omhlophe.

Umtjhado wekhotho.</text>
      <sha1>8keupz18cir4vigi6domlr8zvhhqny4</sha1>
    </revision>
    <revision>
      <id>1529</id>
      <parentid>1528</parentid>
      <timestamp>2024-07-10T14:00:20Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1529</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="892" sha1="q4igfm3ht52dw9lvq2esvjdcjwfwgo4" xml:space="preserve">'''Umtjhado''' kuvumelana kwababili, okumfazi nendoda phambi kwabofakazi noZimu ukuthi bazokuba nyama yinye. Umfazi utjhiya isibongo sakhe athethe sendoda begodu amukelwe emndenini wendoda. Ngaphambi kobana kube nomtjhado indoda iya[[lobola]] ukuze ikhone ukunikelwa umfazi wayo.

Umtjhado kulokha abantu abathandanako benza umsebenzi wokugidinga ithando labo begodu bafunge bebahlanganiswe mfundisi phambi kwabantu.

Minengi imohlobo yomtjhado.

Umtjhado wesintu, ngesiNdebele ubizwa bona lidwendwe nobukhazi lapho kutjhadwa ngokwesintu, begodu nemindeni yabantu abatjhadako yabelana ngezipho.

Umtjhado wesikhuwa obizwa ngokuthi mtjhado omhlophe, lomtjhado lapho umakoti ambatha khona irogo elimhlophe begodu abe nabaphekeleli. Umkhwenyana naye ugcoka isudu kuyiwe ekeregeni ukuyokuhlanganiswa. Umtjhado lo ngokwemvelo ngewamakhuwa kodwana nabantu abanzima sele bawenza.

Umtjhado wekhotho.</text>
      <sha1>q4igfm3ht52dw9lvq2esvjdcjwfwgo4</sha1>
    </revision>
    <revision>
      <id>1530</id>
      <parentid>1529</parentid>
      <timestamp>2024-10-14T13:47:45Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>1529</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="892" sha1="q4igfm3ht52dw9lvq2esvjdcjwfwgo4" xml:space="preserve">'''Umtjhado''' kuvumelana kwababili, okumfazi nendoda phambi kwabofakazi noZimu ukuthi bazokuba nyama yinye. Umfazi utjhiya isibongo sakhe athethe sendoda begodu amukelwe emndenini wendoda. Ngaphambi kobana kube nomtjhado indoda iya[[lobola]] ukuze ikhone ukunikelwa umfazi wayo.

Umtjhado kulokha abantu abathandanako benza umsebenzi wokugidinga ithando labo begodu bafunge bebahlanganiswe mfundisi phambi kwabantu.

Minengi imohlobo yomtjhado.

Umtjhado wesintu, ngesiNdebele ubizwa bona lidwendwe nobukhazi lapho kutjhadwa ngokwesintu, begodu nemindeni yabantu abatjhadako yabelana ngezipho.

Umtjhado wesikhuwa obizwa ngokuthi mtjhado omhlophe, lomtjhado lapho umakoti ambatha khona irogo elimhlophe begodu abe nabaphekeleli. Umkhwenyana naye ugcoka isudu kuyiwe ekeregeni ukuyokuhlanganiswa. Umtjhado lo ngokwemvelo ngewamakhuwa kodwana nabantu abanzima sele bawenza.

Umtjhado wekhotho.</text>
      <sha1>q4igfm3ht52dw9lvq2esvjdcjwfwgo4</sha1>
    </revision>
    <revision>
      <id>6707</id>
      <parentid>1530</parentid>
      <timestamp>2026-06-12T09:54:11Z</timestamp>
      <contributor>
        <username>MissHadassah</username>
        <id>1561</id>
      </contributor>
      <comment>linked pages</comment>
      <origin>6707</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="900" sha1="o7uowllpkh8jzvhww27puoy608lluy7" xml:space="preserve">'''Umtjhado''' kuvumelana kwababili, okumfazi nendoda phambi kwabofakazi noZimu ukuthi bazokuba nyama yinye. Umfazi utjhiya isibongo sakhe athethe sendoda begodu amukelwe emndenini wendoda. Ngaphambi kobana kube nomtjhado indoda iya[[Ilobolo|lobola]] ukuze ikhone ukunikelwa umfazi wayo.

Umtjhado kulokha abantu abathandanako benza umsebenzi wokugidinga ithando labo begodu bafunge bebahlanganiswe mfundisi phambi kwabantu.

Minengi imohlobo yomtjhado.

Umtjhado wesintu, ngesiNdebele ubizwa bona lidwendwe nobukhazi lapho kutjhadwa ngokwesintu, begodu nemindeni yabantu abatjhadako yabelana ngezipho.

Umtjhado wesikhuwa obizwa ngokuthi mtjhado omhlophe, lomtjhado lapho umakoti ambatha khona irogo elimhlophe begodu abe nabaphekeleli. Umkhwenyana naye ugcoka isudu kuyiwe ekeregeni ukuyokuhlanganiswa. Umtjhado lo ngokwemvelo ngewamakhuwa kodwana nabantu abanzima sele bawenza.

Umtjhado wekhotho.</text>
      <sha1>o7uowllpkh8jzvhww27puoy608lluy7</sha1>
    </revision>
  </page>
  <page>
    <title>University of Mpumalanga</title>
    <ns>0</ns>
    <id>284</id>
    <redirect title="Yunivesithi yempulanga" />
    <revision>
      <id>1531</id>
      <timestamp>2024-03-08T13:31:52Z</timestamp>
      <contributor>
        <username>incubator&gt;JesicaMasilela17</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;I-University of Mpumalanga sikolo samabanga aphezulu esasungulwa ngomyaka ka 2013 kuSewula nge 31. Sinama Campus amabili enye ise Mbombela begodu enye ise Siyabuswa. Kile ese Siyabuswa ine mfundo ezimbili ekuyi Bachelor of education in FP kanye ne Higher certificate in ICT. EseMbombela yona ineemfundo ezimbadlwana ekufaka hlangana iimfundo zeCommerce, zeAggriculture, Ze Hospitality kanye LLB.  &quot;</comment>
      <origin>1531</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="397" sha1="76dyodclf7joh4m4y02y5usxx0dyidk" xml:space="preserve">I-University of Mpumalanga sikolo samabanga aphezulu esasungulwa ngomyaka ka 2013 kuSewula nge 31. Sinama Campus amabili enye ise Mbombela begodu enye ise Siyabuswa. Kile ese Siyabuswa ine mfundo ezimbili ekuyi Bachelor of education in FP kanye ne Higher certificate in ICT. EseMbombela yona ineemfundo ezimbadlwana ekufaka hlangana iimfundo zeCommerce, zeAggriculture, Ze Hospitality kanye LLB.

</text>
      <sha1>76dyodclf7joh4m4y02y5usxx0dyidk</sha1>
    </revision>
    <revision>
      <id>1532</id>
      <parentid>1531</parentid>
      <timestamp>2024-03-08T13:48:42Z</timestamp>
      <contributor>
        <username>incubator&gt;JesicaMasilela17</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1532</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="403" sha1="e38xp4lombrh8nf0os6ho7ey7mqrzln" xml:space="preserve">I-'''University of Mpumalanga''' sikolo samabanga aphezulu esasungulwa ngomyaka ka 2013 kuSewula nge 31. Sinama Campus amabili enye ise Mbombela begodu enye ise Siyabuswa. Kile ese Siyabuswa ine mfundo ezimbili ekuyi Bachelor of education in FP kanye ne Higher certificate in ICT. EseMbombela yona ineemfundo ezimbadlwana ekufaka hlangana iimfundo zeCommerce, zeAggriculture, Ze Hospitality kanye LLB.

</text>
      <sha1>e38xp4lombrh8nf0os6ho7ey7mqrzln</sha1>
    </revision>
    <revision>
      <id>1533</id>
      <parentid>1532</parentid>
      <timestamp>2024-03-09T06:59:26Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Adding interwiki links to [[d:Q14979352]]</comment>
      <origin>1533</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="427" sha1="j9qpmeddwdxlopg7uy82p7tjguseqro" xml:space="preserve">I-'''University of Mpumalanga''' sikolo samabanga aphezulu esasungulwa ngomyaka ka 2013 kuSewula nge 31. Sinama Campus amabili enye ise Mbombela begodu enye ise Siyabuswa. Kile ese Siyabuswa ine mfundo ezimbili ekuyi Bachelor of education in FP kanye ne Higher certificate in ICT. EseMbombela yona ineemfundo ezimbadlwana ekufaka hlangana iimfundo zeCommerce, zeAggriculture, Ze Hospitality kanye LLB.


{{INTERWIKI|Q14979352}}</text>
      <sha1>j9qpmeddwdxlopg7uy82p7tjguseqro</sha1>
    </revision>
    <revision>
      <id>1534</id>
      <parentid>1533</parentid>
      <timestamp>2024-03-09T07:30:54Z</timestamp>
      <contributor>
        <username>incubator&gt;Mbandeni</username>
        <id>0</id>
      </contributor>
      <comment>Linked to another article</comment>
      <origin>1534</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="431" sha1="ivxjrh0hr22z43s3e8emtt7rr927z96" xml:space="preserve">I-'''University of Mpumalanga''' sikolo samabanga aphezulu esasungulwa ngomyaka ka 2013 kuSewula nge 31. Sinama Campus amabili enye ise Mbombela begodu enye ise Siyabuswa. Kile ese [[Siyabuswa]] ine mfundo ezimbili ekuyi Bachelor of education in FP kanye ne Higher certificate in ICT. EseMbombela yona ineemfundo ezimbadlwana ekufaka hlangana iimfundo zeCommerce, zeAggriculture, Ze Hospitality kanye LLB.


{{INTERWIKI|Q14979352}}</text>
      <sha1>ivxjrh0hr22z43s3e8emtt7rr927z96</sha1>
    </revision>
    <revision>
      <id>1535</id>
      <parentid>1534</parentid>
      <timestamp>2024-03-09T09:37:53Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>added a picture.</comment>
      <origin>1535</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="516" sha1="r5r0f4lt9gclyxj630tfq8hawab1i43" xml:space="preserve">[[Isimumathi:University of Mpumalanga.jpg|thumb|iHeke ekulu yeNvuvesi yeMpumalanga]]
I-'''University of Mpumalanga''' sikolo samabanga aphezulu esasungulwa ngomyaka ka 2013 kuSewula nge 31. Sinama Campus amabili enye ise Mbombela begodu enye ise Siyabuswa. Kile ese [[Siyabuswa]] ine mfundo ezimbili ekuyi Bachelor of education in FP kanye ne Higher certificate in ICT. EseMbombela yona ineemfundo ezimbadlwana ekufaka hlangana iimfundo zeCommerce, zeAggriculture, Ze Hospitality kanye LLB.


{{INTERWIKI|Q14979352}}</text>
      <sha1>r5r0f4lt9gclyxj630tfq8hawab1i43</sha1>
    </revision>
    <revision>
      <id>1536</id>
      <parentid>1535</parentid>
      <timestamp>2024-03-09T09:39:12Z</timestamp>
      <contributor>
        <username>incubator&gt;Ntuli Evelyn</username>
        <id>0</id>
      </contributor>
      <comment>Edited spelling</comment>
      <origin>1536</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="516" sha1="ci91yl7lyotc4uxoxsgm8m1iid8vkdm" xml:space="preserve">[[Isimumathi:University of Mpumalanga.jpg|thumb|Iyege ekulu yeNvuvesi yeMpumalanga]]
I-'''University of Mpumalanga''' sikolo samabanga aphezulu esasungulwa ngomyaka ka 2013 kuSewula nge 31. Sinama Campus amabili enye ise Mbombela begodu enye ise Siyabuswa. Kile ese [[Siyabuswa]] ine mfundo ezimbili ekuyi Bachelor of education in FP kanye ne Higher certificate in ICT. EseMbombela yona ineemfundo ezimbadlwana ekufaka hlangana iimfundo zeCommerce, zeAggriculture, Ze Hospitality kanye LLB.


{{INTERWIKI|Q14979352}}</text>
      <sha1>ci91yl7lyotc4uxoxsgm8m1iid8vkdm</sha1>
    </revision>
    <revision>
      <id>1537</id>
      <parentid>1536</parentid>
      <timestamp>2024-03-09T09:42:47Z</timestamp>
      <contributor>
        <username>incubator&gt;Ntuli Evelyn</username>
        <id>0</id>
      </contributor>
      <comment>eddited spelling</comment>
      <origin>1537</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="521" sha1="e88z4b35nmjeb5ywd7jr9w1qx1x4iig" xml:space="preserve">[[Isimumathi:University of Mpumalanga.jpg|thumb|Iyege ekulu ye-yunivesithi yeMpumalanga]]
I-'''University of Mpumalanga''' sikolo samabanga aphezulu esasungulwa ngomyaka ka 2013 kuSewula nge 31. Sinama Campus amabili enye ise Mbombela begodu enye ise Siyabuswa. Kile ese [[Siyabuswa]] ine mfundo ezimbili ekuyi Bachelor of education in FP kanye ne Higher certificate in ICT. EseMbombela yona ineemfundo ezimbadlwana ekufaka hlangana iimfundo zeCommerce, zeAggriculture, Ze Hospitality kanye LLB.


{{INTERWIKI|Q14979352}}</text>
      <sha1>e88z4b35nmjeb5ywd7jr9w1qx1x4iig</sha1>
    </revision>
    <revision>
      <id>1538</id>
      <parentid>1537</parentid>
      <timestamp>2024-03-09T09:51:10Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1538</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="578" sha1="1czseoawzdvri6jw00dfy5tk91dqrqf" xml:space="preserve">[[Isimumathi:University of Mpumalanga.jpg|thumb|Iyege ekulu ye-yunivesithi yeMpumalanga]]
I-'''University of Mpumalanga''' sikolo samabanga aphezulu esasungulwa ngomyaka ka 2013 kuSewula nge 31. Sinama Campus amabili enye ise Mbombela begodu enye ise Siyabuswa. Kile ese [[Siyabuswa]] ine mfundo ezimbili ekuyi Bachelor of education in FP kanye ne Higher certificate in ICT. EseMbombela yona ineemfundo ezimbadlwana ekufaka hlangana iimfundo zeCommerce, zeAggriculture, Ze Hospitality kanye LLB.

== Umlando ==

{{INTERWIKI|Q14979352}}Inyuvesi yasempumalanga yasungulanga mhlaka</text>
      <sha1>1czseoawzdvri6jw00dfy5tk91dqrqf</sha1>
    </revision>
    <revision>
      <id>1539</id>
      <parentid>1538</parentid>
      <timestamp>2024-10-14T13:47:46Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>8 revisions imported</comment>
      <origin>1538</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="578" sha1="1czseoawzdvri6jw00dfy5tk91dqrqf" xml:space="preserve">[[Isimumathi:University of Mpumalanga.jpg|thumb|Iyege ekulu ye-yunivesithi yeMpumalanga]]
I-'''University of Mpumalanga''' sikolo samabanga aphezulu esasungulwa ngomyaka ka 2013 kuSewula nge 31. Sinama Campus amabili enye ise Mbombela begodu enye ise Siyabuswa. Kile ese [[Siyabuswa]] ine mfundo ezimbili ekuyi Bachelor of education in FP kanye ne Higher certificate in ICT. EseMbombela yona ineemfundo ezimbadlwana ekufaka hlangana iimfundo zeCommerce, zeAggriculture, Ze Hospitality kanye LLB.

== Umlando ==

{{INTERWIKI|Q14979352}}Inyuvesi yasempumalanga yasungulanga mhlaka</text>
      <sha1>1czseoawzdvri6jw00dfy5tk91dqrqf</sha1>
    </revision>
    <revision>
      <id>1680</id>
      <parentid>1539</parentid>
      <timestamp>2024-10-16T09:50:16Z</timestamp>
      <contributor>
        <username>JhsBot</username>
        <id>34</id>
      </contributor>
      <minor />
      <comment>bot: Removing interwiki template; the page is now connected to [[d:Q14979352]]</comment>
      <origin>1680</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="554" sha1="a7xkb5br2mpny7cxueo7g01o5p3zgs0" xml:space="preserve">[[Isimumathi:University of Mpumalanga.jpg|thumb|Iyege ekulu ye-yunivesithi yeMpumalanga]]
I-'''University of Mpumalanga''' sikolo samabanga aphezulu esasungulwa ngomyaka ka 2013 kuSewula nge 31. Sinama Campus amabili enye ise Mbombela begodu enye ise Siyabuswa. Kile ese [[Siyabuswa]] ine mfundo ezimbili ekuyi Bachelor of education in FP kanye ne Higher certificate in ICT. EseMbombela yona ineemfundo ezimbadlwana ekufaka hlangana iimfundo zeCommerce, zeAggriculture, Ze Hospitality kanye LLB.

== Umlando ==
Inyuvesi yasempumalanga yasungulanga mhlaka</text>
      <sha1>a7xkb5br2mpny7cxueo7g01o5p3zgs0</sha1>
    </revision>
    <revision>
      <id>3434</id>
      <parentid>1680</parentid>
      <timestamp>2025-07-15T11:25:18Z</timestamp>
      <contributor>
        <username>Andre Engels</username>
        <id>480</id>
      </contributor>
      <comment>Redirected page to [[Yunivesithi yempulanga]]</comment>
      <origin>3434</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="36" sha1="3169w6cd8669xeikwdnfor4lopl38pj" xml:space="preserve">#REDIRECT [[Yunivesithi yempulanga]]</text>
      <sha1>3169w6cd8669xeikwdnfor4lopl38pj</sha1>
    </revision>
    <revision>
      <id>5421</id>
      <parentid>3434</parentid>
      <timestamp>2025-09-03T21:42:58Z</timestamp>
      <contributor>
        <username>F.K MAHLANGU</username>
        <id>891</id>
      </contributor>
      <comment>Created by translating the section &quot;History&quot; from the page &quot;[[:en:Special:Redirect/revision/1306769322|University of Mpumalanga]]&quot;</comment>
      <origin>5421</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2347" sha1="iip6z1mb0e2ftldspgn3s7sgjoljr5f" xml:space="preserve">#REDIRECT [[Yunivesithi yempulanga]]

== History ==

Ngomnyaka ka-1996 iKomidi yezeFundo yeYunivesithi neKomidi yokuBambisana yezeFundo yeYunivesithi ye-Technikon yahlangana begodu yanikelwa umsebenzi wokulandela ukusungulwa kweyunivesithi esiFundeni ngu-MEC wangaphambilini wezeFundo, uNom. DD Mabuza. I-National Institute for Higher Education (i-Mpumalanga), eyasungulwa ngomnyaka ka-2006, ngaphasi koburholi baka-Prof CC Mokadi ongasekho yahlanganisa ukunikelwa kwe-Higher Education esifundazweni. Igadango eliqakathekileko kwaba siqunto esathathwa emhlanganweni we-African National Congress's National General Council owabanjelwa e-eThekwini ( i-Durban ) ngomnyaka ka-2010 owaqunta ukusungulwa kwamayunivesithi amabili amatjha. Isinqumo lesi sibe lisizo khulu ekwenzeni lula ukusungulwa kweyunivesithi esifundazweni se-Mpumalanga&lt;ref&gt;University of Mpumalanga (UMP). (2023). ''History of UMP''. Available at: &lt;nowiki&gt;https://www.ump.ac.za&lt;/nowiki&gt;&lt;/ref&gt;.

Ngomnyaka ka-2010, uNgqongqotjhe wezeFundo neBandulo eliPhakemeko, uDorhodera B. E. Nzimande, wabeka iinqhema ezimbili ezizokuphenya bona kungenzeka na ukusungula amayunivesithi amatjha e-Mpumalanga ne-Northern Cape. Isiqhema sokusebenza se-Mpumalanga esathumela umbiko omuhle ngoNobayeni wee-2011, esiphakamisela ukusungulwa kweyunivesithi etja e-Mpumalanga besidoswa phambili ngu-Prof TZ Mthembu&lt;ref&gt;Department of Higher Education and Training (DHET). (2012). ''Report of the Ministerial Task Team on the Establishment of New Universities in Mpumalanga and the Northern Cape''. Pretoria: DHET

&lt;/ref&gt;.

NgoNtaka 2013, uMengameli weNarha, uNom. Jacob Zuma, wamemezela ibizo leyunivesithi etja ngokuthi yiYunivesithi '''ye-Mpumalanga''' kanye namagama wamalunga womKhandlu wesiKhatjhana azokutjheja ukusungulwa kwayo ngokusemthethweni. IYunivesithi ye-Mpumalanga, iyunivesithi epheleleko, yamenyezelwa ngokusemthethweni nangokomthetho ngokugadangiswa kweSaziso sikaRhulumende (Nombolo 36772) mhlazi-22 kuRhoboyi 2013 begodu yathonywa mhlana ama-31 kuMgwengweni 2013. UmKhandlu wesiKhatjhana wabeka iQhema lokuPhatha eliPhakemeko ebelilawula ukusebenza kweyunivesithi kwangamalanga&lt;ref&gt;University of Mpumalanga (UMP). (2013). ''Establishment and Launch of the University of Mpumalanga''. Available at: &lt;nowiki&gt;https://www.ump.ac.za&lt;/nowiki&gt;&lt;/ref&gt;.

'''irherho lemithombo.'''
&lt;references /&gt;</text>
      <sha1>iip6z1mb0e2ftldspgn3s7sgjoljr5f</sha1>
    </revision>
  </page>
  <page>
    <title>Uzimu</title>
    <ns>0</ns>
    <id>285</id>
    <revision>
      <id>1540</id>
      <timestamp>2024-07-08T09:11:27Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''UZimu''' nguloyo ongaphezu koke. Okunguye esikholwa bona wadala izulu nephasi. Uzimu umummoya akabonakali ngamehlo wenyama kodwana ukhona uyaphila. Uzimu nguye owenza bona kube nepilo emhlabeni begodunguye owenza bona kube khona abantu. UZimu ukhulunyiswa ngomkhuleko.&quot;</comment>
      <origin>1540</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="271" sha1="rke5avbp0niylz5c4lx5j85svrexosu" xml:space="preserve">'''UZimu''' nguloyo ongaphezu koke. Okunguye esikholwa bona wadala izulu nephasi. Uzimu umummoya akabonakali ngamehlo wenyama kodwana ukhona uyaphila. Uzimu nguye owenza bona kube nepilo emhlabeni begodunguye owenza bona kube khona abantu. UZimu ukhulunyiswa ngomkhuleko.</text>
      <sha1>rke5avbp0niylz5c4lx5j85svrexosu</sha1>
    </revision>
    <revision>
      <id>1541</id>
      <parentid>1540</parentid>
      <timestamp>2024-10-14T13:47:46Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>1540</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="271" sha1="rke5avbp0niylz5c4lx5j85svrexosu" xml:space="preserve">'''UZimu''' nguloyo ongaphezu koke. Okunguye esikholwa bona wadala izulu nephasi. Uzimu umummoya akabonakali ngamehlo wenyama kodwana ukhona uyaphila. Uzimu nguye owenza bona kube nepilo emhlabeni begodunguye owenza bona kube khona abantu. UZimu ukhulunyiswa ngomkhuleko.</text>
      <sha1>rke5avbp0niylz5c4lx5j85svrexosu</sha1>
    </revision>
    <revision>
      <id>2954</id>
      <parentid>1541</parentid>
      <timestamp>2025-06-06T18:49:46Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>erfg</comment>
      <origin>2954</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="352" sha1="h814hmv4u8tojdodusog9cqlkjz5cm3" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. UZimu''' nguloyo ongaphezu koke. Okunguye esikholwa bona wadala izulu nephasi. Uzimu umummoya akabonakali ngamehlo wenyama kodwana ukhona uyaphila. Uzimu nguye owenza bona kube nepilo emhlabeni begodunguye owenza bona kube khona abantu. UZimu ukhulunyiswa ngomkhuleko.</text>
      <sha1>h814hmv4u8tojdodusog9cqlkjz5cm3</sha1>
    </revision>
    <revision>
      <id>3082</id>
      <parentid>2954</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Jon Harald Søby|Jon Harald Søby]]</comment>
      <origin>1540</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="271" sha1="rke5avbp0niylz5c4lx5j85svrexosu" xml:space="preserve">'''UZimu''' nguloyo ongaphezu koke. Okunguye esikholwa bona wadala izulu nephasi. Uzimu umummoya akabonakali ngamehlo wenyama kodwana ukhona uyaphila. Uzimu nguye owenza bona kube nepilo emhlabeni begodunguye owenza bona kube khona abantu. UZimu ukhulunyiswa ngomkhuleko.</text>
      <sha1>rke5avbp0niylz5c4lx5j85svrexosu</sha1>
    </revision>
    <revision>
      <id>6797</id>
      <parentid>3082</parentid>
      <timestamp>2026-08-20T09:28:40Z</timestamp>
      <contributor>
        <username>Andries Solly Skhosana</username>
        <id>1624</id>
      </contributor>
      <comment>I have false the word of &quot;zimu&quot;  since it was written in small letter. Again, I have false the word that represent God &quot;nguye&quot; because it stands for God and must be caps. Lastly, I have caps the word &quot;ummoya&quot; to uMmoya since its represent the spiritual of God. I also expand a bit since the words were incomplete in a paragraph by adding &quot;kwakho&quot; in the first line.</comment>
      <origin>6797</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="280" sha1="ok09081ko6wsuitp4chzgkfex02pbvi" xml:space="preserve">'''UZimu''' ngiloyo ongaphezu kwakho koke. OkuNguye esikholwa bona wadala izulu nephasi. UZimu umuMmoya, akabonakali ngamehlo wenyama kodwana ukhona uyaphila. UZimu Nguye owenza bona kube nepilo ephasini begodu Nguye owenza bona kube khona abantu. UZimu ukhulunyiswa ngomthandazo.</text>
      <sha1>ok09081ko6wsuitp4chzgkfex02pbvi</sha1>
    </revision>
  </page>
  <page>
    <title>Vital 10</title>
    <ns>0</ns>
    <id>286</id>
    <redirect title="Wikiphidiya:Imitlolo aqakathekileyo/esigaba 1" />
    <revision>
      <id>1542</id>
      <timestamp>2019-01-11T13:20:14Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Thuvack moved page [[Vital 10]] to [[Wikipedia:Imitlolo ekhethekileko-1]]</comment>
      <origin>1542</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="48" sha1="n0aaxsbxhcv33c4sp208y89tvhugquc" xml:space="preserve">#REDIRECT [[Wikipedia:Imitlolo ekhethekileko-1]]</text>
      <sha1>n0aaxsbxhcv33c4sp208y89tvhugquc</sha1>
    </revision>
    <revision>
      <id>1543</id>
      <parentid>1542</parentid>
      <timestamp>2019-01-13T18:12:20Z</timestamp>
      <contributor>
        <username>incubator&gt;Revibot</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Bot: Fixing double redirect to [[Wikipedia:Imitlolo aqakathekileyo/esigaba 1]]</comment>
      <origin>1543</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="57" sha1="c8dbwmiwkulzv4b7bvvifgpqcuhqiud" xml:space="preserve">#REDIRECT [[Wikipedia:Imitlolo aqakathekileyo/esigaba 1]]</text>
      <sha1>c8dbwmiwkulzv4b7bvvifgpqcuhqiud</sha1>
    </revision>
    <revision>
      <id>1544</id>
      <parentid>1543</parentid>
      <timestamp>2024-10-14T13:47:46Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>1543</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="57" sha1="c8dbwmiwkulzv4b7bvvifgpqcuhqiud" xml:space="preserve">#REDIRECT [[Wikipedia:Imitlolo aqakathekileyo/esigaba 1]]</text>
      <sha1>c8dbwmiwkulzv4b7bvvifgpqcuhqiud</sha1>
    </revision>
  </page>
  <page>
    <title>Wikipedia</title>
    <ns>0</ns>
    <id>287</id>
    <revision>
      <id>1545</id>
      <timestamp>2019-01-13T16:50:46Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;{{Translate|http://en.wikipedia.org/wiki/Wikipedia}} {{infobox Website | name = Wikiphidiya | logo = [[Isimumathi:Wikipedia-logo-v2.svg|100px]] | screenshot = File:Www.wikipedia.o...&quot;</comment>
      <origin>1545</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4363" sha1="5ap5vziuekq1x4urmc1mmdm3zl9q2nk" xml:space="preserve">{{Translate|http://en.wikipedia.org/wiki/Wikipedia}}
{{infobox Website
| name = Wikiphidiya
| logo = [[Isimumathi:Wikipedia-logo-v2.svg|100px]]
| screenshot = [[Isimumathi:Www.wikipedia.org screenshot 2018.png|border|280px|Xifaniso xa nyangwa-nkulu wa tindzimi ya Wikipediya.]]
| caption = Xifaniso xa nyangwa-nkulu wa tindzimi ya Wikipediya.
| url = [http://www.ts.wikipedia.org www.ts.wikipedia.org]
| type of organization = [[Nonprofit|Ayi hakeleriwi]]
| location = [[Miami, Florida|E mayami, florida]]
| type = [[Internet encyclopedia project|encyclopediya ya le ka inthanete]]
| language = 236 wa vuhundzuluxi (253 hixitalo)
| registration = Ahixikolo-kolo
| owner = [[Wikimedia Foundation]]
| author = [[Jimmy Wales]], [[Larry Sanger]]&lt;!-- Please, please, [discuss] on talk page before rewriting history. This has been in this article for years. --&gt;&lt;ref name=projectorigins&gt;{{cite news|url=http://www.signonsandiego.com/uniontrib/20041206/news_mz1b6encyclo.html|author=Jonathan Sidener|title=Everyone's Encyclopedia|accessdate=2006-10-15|publisher=San Diego Union Tribune}}&lt;/ref&gt;
| launch date = {{birth date|2001|1|15}}
| commercial = E-e
| alexa = #8
| current status = Ntirho lowu yaka emahlweni&lt;ref&gt;{{cite web |url=http://en.wikipedia.org/wiki/Wikipedia:Wikipedia_is_a_work_in_progress |title=Wikipedia:Wikipedia is a work in progress |accessdate=2008-07-03 |publisher=Wikipedia}}&lt;/ref&gt;
| slogan = encyclopediya ya mahala leyi lulamisiwaka hi mani na mani.
}}

'''Wikiphidiya''' ngumthombo welwazi la [[Free content|mahala]], [[multilingualism|amalimi]] ahlukene, begodu lephurojekti iqondiswa yi[[non-profit organization|nhlangano lengakhokhelwayo]] e[[United States|Amerikka]] engu [[Wikimedia Foundation]]. Yathoma ngo nyaka ka 2001 ngu [[Jimmy Wales]] no [[Larry Sanger]],&lt;ref name=&quot;Miliard&quot;&gt;{{cite news|url=http://www.slweekly.com/index.cfm?do=article.details&amp;id=37BD3969-14D1-13A2-9F5EEAF5A79E0898|title=Wikipediots: Who are these devoted, even obsessive contributors to Wikipedia?|accessdate=2008-02-21|date=2008-03-01 |publisher=[[Salt Lake City Weekly]]|first=Mike|last=Miliard}}&lt;/ref&gt;, begodu ilinga uku qobelela begodu ihlathulule ilwazi labntu boke na malwimi woke.&lt;ref&gt;[http://interviews.slashdot.org/article.pl?sid=04/07/28/1351230 Slashdot | Wikipedia Founder Jimmy Wales Responds&lt;!-- Bot generated title --&gt;]&lt;/ref&gt;

Kusukela ngo 2008, iWikiphidiya yaba ne mitlolo edlula 10&amp;nbsp;wamamiliyoni ngamalwimi angu '''253''';, khulu-khulu ngesinghesi.&lt;ref name=&quot;ListOfWikipedias&quot;&gt;{{cite web | url = http://en.wikipedia.org/wiki/Special:Statistics | title = Statistics | publisher = [[English Wikipedia]] | accessdate = 2008-06-21 }}&lt;/ref&gt; Imitlolo ye Wikiphidiya le, itlolwa [[collaboration|kuberegisana]] kwa[[volunteer|bazinikela ngokuthanda kwabo]] ephasini loke, begodu yoke imitlolo ihlelwa nangubani one inthaneti. Iwikiphidiya le ikhule inje,&lt;ref name=&quot;AlexaStats&quot;&gt;{{cite web | url = http://www.alexa.com/data/details/traffic_details/wikipedia.org?range=5y&amp;size=large&amp;y=t | title = Five-year traffic statistics for wikipedia.org | publisher = [[Alexa Internet]] | accessdate = 2008-07-15 }}&lt;/ref&gt; nge yokthoma begodu ekhulu-khulu ejimeni loku sekela inthaneti.&lt;ref&gt;{{cite news|url=http://www.time.com/time/business/article/0,8599,1595184,00.html|title=Look Who's Using Wikipedia|first=Bill|last=Tancer|date=2007-05-01|publisher=''[[Time (magazine)|Time]]''|accessdate=2007-12-01|quote=The sheer volume of content [...] is partly responsible for the site's dominance as an online reference. When compared to the top 3,200 educational reference sites in the U.S., Wikipedia is #1, capturing 24.3% of all visits to the category}}  ([http://weblogs.hitwise.com/bill-tancer/2007/03/wikipedia_search_and_school_ho.html the author's blog post on the article])&lt;/ref&gt;&lt;ref name=&quot;go-to site&quot;&gt;{{cite news |url=http://www.reuters.com/article/internetNews/idUSN0819429120070708 |title=Wikipedia remains go-to site for online news |date=2007-07-08 |accessdate=2007-12-16 |first=Alex |last=Woodson |publisher=''[[Reuters]]'' |quote=Online encyclopedia Wikipedia has added about 20 million unique monthly visitors in the past year, making it the top online news and information destination, according to Nielsen//NetRatings.}}&lt;/ref&gt;

== References ==
{{reflist|2}}

{{Commons|Wikipedia}}

&lt;!-- Categories --&gt;
&lt;!-- Interwikis --&gt;

[[Mkhakha:Wikipediya|*]]</text>
      <sha1>5ap5vziuekq1x4urmc1mmdm3zl9q2nk</sha1>
    </revision>
    <revision>
      <id>1546</id>
      <parentid>1545</parentid>
      <timestamp>2019-01-13T16:51:53Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1546</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4363" sha1="hq23rtntbf6owk9s3b49jj0rpmqsx6l" xml:space="preserve">{{Translate|http://en.wikipedia.org/wiki/Wikipedia}}
{{infobox Website
| name = Wikiphidiya
| logo = [[Isimumathi:Wikipedia-logo-v2.svg|100px]]
| screenshot = [[Isimumathi:Www.wikipedia.org screenshot 2018.png|border|280px|Xifaniso xa nyangwa-nkulu wa tindzimi ya Wikipediya.]]
| caption = Xifaniso xa nyangwa-nkulu wa tindzimi ya Wikipediya.
| url = [http://www.ts.wikipedia.org www.ts.wikipedia.org]
| type of organization = [[Nonprofit|Ayi hakeleriwi]]
| location = [[Miami, Florida|E mayami, florida]]
| type = [[Internet encyclopedia project|encyclopediya ya le ka inthanete]]
| language = 236 wa vuhundzuluxi (253 hixitalo)
| registration = Ahixikolo-kolo
| owner = [[Wikimedia Foundation]]
| author = [[Jimmy Wales]], [[Larry Sanger]]&lt;!-- Please, please, [discuss] on talk page before rewriting history. This has been in this article for years. --&gt;&lt;ref name=projectorigins&gt;{{cite news|url=http://www.signonsandiego.com/uniontrib/20041206/news_mz1b6encyclo.html|author=Jonathan Sidener|title=Everyone's Encyclopedia|accessdate=2006-10-15|publisher=San Diego Union Tribune}}&lt;/ref&gt;
| launch date = {{birth date|2001|1|15}}
| commercial = E-e
| alexa = #8
| current status = Ntirho lowu yaka emahlweni&lt;ref&gt;{{cite web |url=http://en.wikipedia.org/wiki/Wikipedia:Wikipedia_is_a_work_in_progress |title=Wikipedia:Wikipedia is a work in progress |accessdate=2008-07-03 |publisher=Wikipedia}}&lt;/ref&gt;
| slogan = encyclopediya ya mahala leyi lulamisiwaka hi mani na mani.
}}

'''Wikiphidiya''' ngumthombo welwazi la [[Free content|mahala]], [[multilingualism|amalimi]] ahlukene, begodu lephurojekti iqondiswa yi[[non-profit organization|nhlangano lengakhokhelwayo]] e[[United States|Amerikka]] engu [[Wikimedia Foundation]]. Yathoma ngo nyaka ka 2001 ngu [[Jimmy Wales]] no [[Larry Sanger]],&lt;ref name=&quot;Miliard&quot;&gt;{{cite news|url=http://www.slweekly.com/index.cfm?do=article.details&amp;id=37BD3969-14D1-13A2-9F5EEAF5A79E0898|title=Wikipediots: Who are these devoted, even obsessive contributors to Wikipedia?|accessdate=2008-02-21|date=2008-03-01 |publisher=[[Salt Lake City Weekly]]|first=Mike|last=Miliard}}&lt;/ref&gt;, begodu ilinga uku qobelela begodu ihlathulule ilwazi labntu boke na malwimi woke.&lt;ref&gt;[http://interviews.slashdot.org/article.pl?sid=04/07/28/1351230 Slashdot | Wikipedia Founder Jimmy Wales Responds&lt;!-- Bot generated title --&gt;]&lt;/ref&gt;

Kusukela ngo 2008, iWikiphidiya yaba ne mitlolo edlula 10&amp;nbsp;wamamiliyoni ngamalwimi angu '''253''';, khulu-khulu ngesinghesi.&lt;ref name=&quot;ListOfWikipedias&quot;&gt;{{cite web | url = http://en.wikipedia.org/wiki/Special:Statistics | title = Statistics | publisher = [[English Wikipedia]] | accessdate = 2008-06-21 }}&lt;/ref&gt; Imitlolo ye Wikiphidiya le, itlolwa [[collaboration|kuberegisana]] kwa[[volunteer|bazinikela ngokuthanda kwabo]] ephasini loke, begodu yoke imitlolo ihlelwa nangubani one inthaneti. Iwikiphidiya le ikhule inje,&lt;ref name=&quot;AlexaStats&quot;&gt;{{cite web | url = http://www.alexa.com/data/details/traffic_details/wikipedia.org?range=5y&amp;size=large&amp;y=t | title = Five-year traffic statistics for wikipedia.org | publisher = [[Alexa Internet]] | accessdate = 2008-07-15 }}&lt;/ref&gt; nge yokthoma begodu ekhulu-khulu ejimeni loku sekela inthaneti.&lt;ref&gt;{{cite news|url=http://www.time.com/time/business/article/0,8599,1595184,00.html|title=Look Who's Using Wikipedia|first=Bill|last=Tancer|date=2007-05-01|publisher=''[[Time (magazine)|Time]]''|accessdate=2007-12-01|quote=The sheer volume of content [...] is partly responsible for the site's dominance as an online reference. When compared to the top 3,200 educational reference sites in the U.S., Wikipedia is #1, capturing 24.3% of all visits to the category}}  ([http://weblogs.hitwise.com/bill-tancer/2007/03/wikipedia_search_and_school_ho.html the author's blog post on the article])&lt;/ref&gt;&lt;ref name=&quot;go-to site&quot;&gt;{{cite news |url=http://www.reuters.com/article/internetNews/idUSN0819429120070708 |title=Wikipedia remains go-to site for online news |date=2007-07-08 |accessdate=2007-12-16 |first=Alex |last=Woodson |publisher=''[[Reuters]]'' |quote=Online encyclopedia Wikipedia has added about 20 million unique monthly visitors in the past year, making it the top online news and information destination, according to Nielsen//NetRatings.}}&lt;/ref&gt;

== References ==
{{Reflist|2}}

{{Commons|Wikipedia}}

&lt;!-- Categories --&gt;
&lt;!-- Interwikis --&gt;

[[Mkhakha:Wikipediya|*]]</text>
      <sha1>hq23rtntbf6owk9s3b49jj0rpmqsx6l</sha1>
    </revision>
    <revision>
      <id>1547</id>
      <parentid>1546</parentid>
      <timestamp>2019-01-13T17:03:39Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1547</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4210" sha1="1w2dw2g50f8kaf4j34cnulz60qrmlwu" xml:space="preserve">{{infobox Website
| name = Wikiphidiya
| logo = [[Isimumathi:Wikipedia-logo-v2.svg|100px]]
| screenshot = [[Isimumathi:Www.wikipedia.org screenshot 2018.png|border|280px|Xifaniso xa nyangwa-nkulu wa tindzimi ya Wikipediya.]]
| caption = 
| url = [http://www.ts.wikipedia.org www.ts.wikipedia.org]
| type of organization = [[Nonprofit|Engenzi nzuzo]]
| location = [[Miami, Florida|E mayami, florida]]
| type = [[Internet encyclopedia project|encyclopediya ye inthaneti]]
| language = 236 wamatjhugululo
| registration = 
| owner = [[Wikimedia Foundation]]
| author = [[Jimmy Wales]], [[Larry Sanger]]&lt;!-- Please, please, [discuss] on talk page before rewriting history. This has been in this article for years. --&gt;&lt;ref name=projectorigins&gt;{{cite news|url=http://www.signonsandiego.com/uniontrib/20041206/news_mz1b6encyclo.html|author=Jonathan Sidener|title=Everyone's Encyclopedia|accessdate=2006-10-15|publisher=San Diego Union Tribune}}&lt;/ref&gt;
| launch date = {{birth date|2001|1|15}}
| commercial = 
| alexa = #8
| current status = Umberego oragela phambili&lt;ref&gt;{{cite web |url=http://en.wikipedia.org/wiki/Wikipedia:Wikipedia_is_a_work_in_progress |title=Wikipedia:Wikipedia is a work in progress |accessdate=2008-07-03 |publisher=Wikipedia}}&lt;/ref&gt;
| slogan = encyclopediya ya s'mahla etlolwa ngabo boke abantu.
}}

'''Wikiphidiya''' ngumthombo welwazi la [[Free content|mahala]], [[multilingualism|amalimi]] ahlukene, begodu lephurojekti iqondiswa yi[[non-profit organization|nhlangano lengakhokhelwayo]] e[[United States|Amerikka]] engu [[Wikimedia Foundation]]. Yathoma ngo nyaka ka 2001 ngu [[Jimmy Wales]] no [[Larry Sanger]],&lt;ref name=&quot;Miliard&quot;&gt;{{cite news|url=http://www.slweekly.com/index.cfm?do=article.details&amp;id=37BD3969-14D1-13A2-9F5EEAF5A79E0898|title=Wikipediots: Who are these devoted, even obsessive contributors to Wikipedia?|accessdate=2008-02-21|date=2008-03-01 |publisher=[[Salt Lake City Weekly]]|first=Mike|last=Miliard}}&lt;/ref&gt;, begodu ilinga uku qobelela begodu ihlathulule ilwazi labntu boke na malwimi woke.&lt;ref&gt;[http://interviews.slashdot.org/article.pl?sid=04/07/28/1351230 Slashdot | Wikipedia Founder Jimmy Wales Responds&lt;!-- Bot generated title --&gt;]&lt;/ref&gt;

Kusukela ngo 2008, iWikiphidiya yaba ne mitlolo edlula 10&amp;nbsp;wamamiliyoni ngamalwimi angu '''253''';, khulu-khulu ngesinghesi.&lt;ref name=&quot;ListOfWikipedias&quot;&gt;{{cite web | url = http://en.wikipedia.org/wiki/Special:Statistics | title = Statistics | publisher = [[English Wikipedia]] | accessdate = 2008-06-21 }}&lt;/ref&gt; Imitlolo ye Wikiphidiya le, itlolwa [[collaboration|kuberegisana]] kwa[[volunteer|bazinikela ngokuthanda kwabo]] ephasini loke, begodu yoke imitlolo ihlelwa nangubani one inthaneti. Iwikiphidiya le ikhule inje,&lt;ref name=&quot;AlexaStats&quot;&gt;{{cite web | url = http://www.alexa.com/data/details/traffic_details/wikipedia.org?range=5y&amp;size=large&amp;y=t | title = Five-year traffic statistics for wikipedia.org | publisher = [[Alexa Internet]] | accessdate = 2008-07-15 }}&lt;/ref&gt; nge yokthoma begodu ekhulu-khulu ejimeni loku sekela inthaneti.&lt;ref&gt;{{cite news|url=http://www.time.com/time/business/article/0,8599,1595184,00.html|title=Look Who's Using Wikipedia|first=Bill|last=Tancer|date=2007-05-01|publisher=''[[Time (magazine)|Time]]''|accessdate=2007-12-01|quote=The sheer volume of content [...] is partly responsible for the site's dominance as an online reference. When compared to the top 3,200 educational reference sites in the U.S., Wikipedia is #1, capturing 24.3% of all visits to the category}}  ([http://weblogs.hitwise.com/bill-tancer/2007/03/wikipedia_search_and_school_ho.html the author's blog post on the article])&lt;/ref&gt;&lt;ref name=&quot;go-to site&quot;&gt;{{cite news |url=http://www.reuters.com/article/internetNews/idUSN0819429120070708 |title=Wikipedia remains go-to site for online news |date=2007-07-08 |accessdate=2007-12-16 |first=Alex |last=Woodson |publisher=''[[Reuters]]'' |quote=Online encyclopedia Wikipedia has added about 20 million unique monthly visitors in the past year, making it the top online news and information destination, according to Nielsen//NetRatings.}}&lt;/ref&gt;

== References ==
{{Reflist|2}}

{{Commons|Wikipedia}}

&lt;!-- Categories --&gt;
&lt;!-- Interwikis --&gt;

[[Mkhakha:Wikipediya|*]]</text>
      <sha1>1w2dw2g50f8kaf4j34cnulz60qrmlwu</sha1>
    </revision>
    <revision>
      <id>1548</id>
      <parentid>1547</parentid>
      <timestamp>2019-01-13T17:06:21Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1547</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4210" sha1="1w2dw2g50f8kaf4j34cnulz60qrmlwu" xml:space="preserve">{{infobox Website
| name = Wikiphidiya
| logo = [[Isimumathi:Wikipedia-logo-v2.svg|100px]]
| screenshot = [[Isimumathi:Www.wikipedia.org screenshot 2018.png|border|280px|Xifaniso xa nyangwa-nkulu wa tindzimi ya Wikipediya.]]
| caption = 
| url = [http://www.ts.wikipedia.org www.ts.wikipedia.org]
| type of organization = [[Nonprofit|Engenzi nzuzo]]
| location = [[Miami, Florida|E mayami, florida]]
| type = [[Internet encyclopedia project|encyclopediya ye inthaneti]]
| language = 236 wamatjhugululo
| registration = 
| owner = [[Wikimedia Foundation]]
| author = [[Jimmy Wales]], [[Larry Sanger]]&lt;!-- Please, please, [discuss] on talk page before rewriting history. This has been in this article for years. --&gt;&lt;ref name=projectorigins&gt;{{cite news|url=http://www.signonsandiego.com/uniontrib/20041206/news_mz1b6encyclo.html|author=Jonathan Sidener|title=Everyone's Encyclopedia|accessdate=2006-10-15|publisher=San Diego Union Tribune}}&lt;/ref&gt;
| launch date = {{birth date|2001|1|15}}
| commercial = 
| alexa = #8
| current status = Umberego oragela phambili&lt;ref&gt;{{cite web |url=http://en.wikipedia.org/wiki/Wikipedia:Wikipedia_is_a_work_in_progress |title=Wikipedia:Wikipedia is a work in progress |accessdate=2008-07-03 |publisher=Wikipedia}}&lt;/ref&gt;
| slogan = encyclopediya ya s'mahla etlolwa ngabo boke abantu.
}}

'''Wikiphidiya''' ngumthombo welwazi la [[Free content|mahala]], [[multilingualism|amalimi]] ahlukene, begodu lephurojekti iqondiswa yi[[non-profit organization|nhlangano lengakhokhelwayo]] e[[United States|Amerikka]] engu [[Wikimedia Foundation]]. Yathoma ngo nyaka ka 2001 ngu [[Jimmy Wales]] no [[Larry Sanger]],&lt;ref name=&quot;Miliard&quot;&gt;{{cite news|url=http://www.slweekly.com/index.cfm?do=article.details&amp;id=37BD3969-14D1-13A2-9F5EEAF5A79E0898|title=Wikipediots: Who are these devoted, even obsessive contributors to Wikipedia?|accessdate=2008-02-21|date=2008-03-01 |publisher=[[Salt Lake City Weekly]]|first=Mike|last=Miliard}}&lt;/ref&gt;, begodu ilinga uku qobelela begodu ihlathulule ilwazi labntu boke na malwimi woke.&lt;ref&gt;[http://interviews.slashdot.org/article.pl?sid=04/07/28/1351230 Slashdot | Wikipedia Founder Jimmy Wales Responds&lt;!-- Bot generated title --&gt;]&lt;/ref&gt;

Kusukela ngo 2008, iWikiphidiya yaba ne mitlolo edlula 10&amp;nbsp;wamamiliyoni ngamalwimi angu '''253''';, khulu-khulu ngesinghesi.&lt;ref name=&quot;ListOfWikipedias&quot;&gt;{{cite web | url = http://en.wikipedia.org/wiki/Special:Statistics | title = Statistics | publisher = [[English Wikipedia]] | accessdate = 2008-06-21 }}&lt;/ref&gt; Imitlolo ye Wikiphidiya le, itlolwa [[collaboration|kuberegisana]] kwa[[volunteer|bazinikela ngokuthanda kwabo]] ephasini loke, begodu yoke imitlolo ihlelwa nangubani one inthaneti. Iwikiphidiya le ikhule inje,&lt;ref name=&quot;AlexaStats&quot;&gt;{{cite web | url = http://www.alexa.com/data/details/traffic_details/wikipedia.org?range=5y&amp;size=large&amp;y=t | title = Five-year traffic statistics for wikipedia.org | publisher = [[Alexa Internet]] | accessdate = 2008-07-15 }}&lt;/ref&gt; nge yokthoma begodu ekhulu-khulu ejimeni loku sekela inthaneti.&lt;ref&gt;{{cite news|url=http://www.time.com/time/business/article/0,8599,1595184,00.html|title=Look Who's Using Wikipedia|first=Bill|last=Tancer|date=2007-05-01|publisher=''[[Time (magazine)|Time]]''|accessdate=2007-12-01|quote=The sheer volume of content [...] is partly responsible for the site's dominance as an online reference. When compared to the top 3,200 educational reference sites in the U.S., Wikipedia is #1, capturing 24.3% of all visits to the category}}  ([http://weblogs.hitwise.com/bill-tancer/2007/03/wikipedia_search_and_school_ho.html the author's blog post on the article])&lt;/ref&gt;&lt;ref name=&quot;go-to site&quot;&gt;{{cite news |url=http://www.reuters.com/article/internetNews/idUSN0819429120070708 |title=Wikipedia remains go-to site for online news |date=2007-07-08 |accessdate=2007-12-16 |first=Alex |last=Woodson |publisher=''[[Reuters]]'' |quote=Online encyclopedia Wikipedia has added about 20 million unique monthly visitors in the past year, making it the top online news and information destination, according to Nielsen//NetRatings.}}&lt;/ref&gt;

== References ==
{{Reflist|2}}

{{Commons|Wikipedia}}

&lt;!-- Categories --&gt;
&lt;!-- Interwikis --&gt;

[[Mkhakha:Wikipediya|*]]</text>
      <sha1>1w2dw2g50f8kaf4j34cnulz60qrmlwu</sha1>
    </revision>
    <revision>
      <id>1549</id>
      <parentid>1548</parentid>
      <timestamp>2019-01-13T17:09:00Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1549</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4092" sha1="3v2ube0pw99fdabvg2sw7nfb634d6t5" xml:space="preserve">{{infobox Website
| name = Wikiphidiya
| logo = [[Isimumathi:Wikipedia-logo-v2.svg|100px]]
| screenshot = 
| caption = 
| url = [http://www.ts.wikipedia.org www.ts.wikipedia.org]
| type of organization = [[Nonprofit|Engenzi nzuzo]]
| location = [[Miami, Florida|E mayami, florida]]
| type = [[Internet encyclopedia project|encyclopediya ye inthaneti]]
| language = 236 wamatjhugululo
| registration = 
| owner = [[Wikimedia Foundation]]
| author = [[Jimmy Wales]], [[Larry Sanger]]&lt;!-- Please, please, [discuss] on talk page before rewriting history. This has been in this article for years. --&gt;&lt;ref name=projectorigins&gt;{{cite news|url=http://www.signonsandiego.com/uniontrib/20041206/news_mz1b6encyclo.html|author=Jonathan Sidener|title=Everyone's Encyclopedia|accessdate=2006-10-15|publisher=San Diego Union Tribune}}&lt;/ref&gt;
| launch date = {{birth date|2001|1|15}}
| commercial = 
| alexa = #8
| current status = Umberego oragela phambili&lt;ref&gt;{{cite web |url=http://en.wikipedia.org/wiki/Wikipedia:Wikipedia_is_a_work_in_progress |title=Wikipedia:Wikipedia is a work in progress |accessdate=2008-07-03 |publisher=Wikipedia}}&lt;/ref&gt;
| slogan = encyclopediya ya s'mahla etlolwa ngabo boke abantu.
}}

'''Wikiphidiya''' ngumthombo welwazi la [[Free content|mahala]], [[multilingualism|amalimi]] ahlukene, begodu lephurojekti iqondiswa yi[[non-profit organization|nhlangano lengakhokhelwayo]] e[[United States|Amerikka]] engu [[Wikimedia Foundation]]. Yathoma ngo nyaka ka 2001 ngu [[Jimmy Wales]] no [[Larry Sanger]],&lt;ref name=&quot;Miliard&quot;&gt;{{cite news|url=http://www.slweekly.com/index.cfm?do=article.details&amp;id=37BD3969-14D1-13A2-9F5EEAF5A79E0898|title=Wikipediots: Who are these devoted, even obsessive contributors to Wikipedia?|accessdate=2008-02-21|date=2008-03-01 |publisher=[[Salt Lake City Weekly]]|first=Mike|last=Miliard}}&lt;/ref&gt;, begodu ilinga uku qobelela begodu ihlathulule ilwazi labntu boke na malwimi woke.&lt;ref&gt;[http://interviews.slashdot.org/article.pl?sid=04/07/28/1351230 Slashdot | Wikipedia Founder Jimmy Wales Responds&lt;!-- Bot generated title --&gt;]&lt;/ref&gt;

Kusukela ngo 2008, iWikiphidiya yaba ne mitlolo edlula 10&amp;nbsp;wamamiliyoni ngamalwimi angu '''253''';, khulu-khulu ngesinghesi.&lt;ref name=&quot;ListOfWikipedias&quot;&gt;{{cite web | url = http://en.wikipedia.org/wiki/Special:Statistics | title = Statistics | publisher = [[English Wikipedia]] | accessdate = 2008-06-21 }}&lt;/ref&gt; Imitlolo ye Wikiphidiya le, itlolwa [[collaboration|kuberegisana]] kwa[[volunteer|bazinikela ngokuthanda kwabo]] ephasini loke, begodu yoke imitlolo ihlelwa nangubani one inthaneti. Iwikiphidiya le ikhule inje,&lt;ref name=&quot;AlexaStats&quot;&gt;{{cite web | url = http://www.alexa.com/data/details/traffic_details/wikipedia.org?range=5y&amp;size=large&amp;y=t | title = Five-year traffic statistics for wikipedia.org | publisher = [[Alexa Internet]] | accessdate = 2008-07-15 }}&lt;/ref&gt; nge yokthoma begodu ekhulu-khulu ejimeni loku sekela inthaneti.&lt;ref&gt;{{cite news|url=http://www.time.com/time/business/article/0,8599,1595184,00.html|title=Look Who's Using Wikipedia|first=Bill|last=Tancer|date=2007-05-01|publisher=''[[Time (magazine)|Time]]''|accessdate=2007-12-01|quote=The sheer volume of content [...] is partly responsible for the site's dominance as an online reference. When compared to the top 3,200 educational reference sites in the U.S., Wikipedia is #1, capturing 24.3% of all visits to the category}}  ([http://weblogs.hitwise.com/bill-tancer/2007/03/wikipedia_search_and_school_ho.html the author's blog post on the article])&lt;/ref&gt;&lt;ref name=&quot;go-to site&quot;&gt;{{cite news |url=http://www.reuters.com/article/internetNews/idUSN0819429120070708 |title=Wikipedia remains go-to site for online news |date=2007-07-08 |accessdate=2007-12-16 |first=Alex |last=Woodson |publisher=''[[Reuters]]'' |quote=Online encyclopedia Wikipedia has added about 20 million unique monthly visitors in the past year, making it the top online news and information destination, according to Nielsen//NetRatings.}}&lt;/ref&gt;

== References ==
{{Reflist|2}}

{{Commons|Wikipedia}}

&lt;!-- Categories --&gt;
&lt;!-- Interwikis --&gt;

[[Mkhakha:Wikipediya|*]]</text>
      <sha1>3v2ube0pw99fdabvg2sw7nfb634d6t5</sha1>
    </revision>
    <revision>
      <id>1550</id>
      <parentid>1549</parentid>
      <timestamp>2019-01-13T17:14:47Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1549</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4092" sha1="3v2ube0pw99fdabvg2sw7nfb634d6t5" xml:space="preserve">{{infobox Website
| name = Wikiphidiya
| logo = [[Isimumathi:Wikipedia-logo-v2.svg|100px]]
| screenshot = 
| caption = 
| url = [http://www.ts.wikipedia.org www.ts.wikipedia.org]
| type of organization = [[Nonprofit|Engenzi nzuzo]]
| location = [[Miami, Florida|E mayami, florida]]
| type = [[Internet encyclopedia project|encyclopediya ye inthaneti]]
| language = 236 wamatjhugululo
| registration = 
| owner = [[Wikimedia Foundation]]
| author = [[Jimmy Wales]], [[Larry Sanger]]&lt;!-- Please, please, [discuss] on talk page before rewriting history. This has been in this article for years. --&gt;&lt;ref name=projectorigins&gt;{{cite news|url=http://www.signonsandiego.com/uniontrib/20041206/news_mz1b6encyclo.html|author=Jonathan Sidener|title=Everyone's Encyclopedia|accessdate=2006-10-15|publisher=San Diego Union Tribune}}&lt;/ref&gt;
| launch date = {{birth date|2001|1|15}}
| commercial = 
| alexa = #8
| current status = Umberego oragela phambili&lt;ref&gt;{{cite web |url=http://en.wikipedia.org/wiki/Wikipedia:Wikipedia_is_a_work_in_progress |title=Wikipedia:Wikipedia is a work in progress |accessdate=2008-07-03 |publisher=Wikipedia}}&lt;/ref&gt;
| slogan = encyclopediya ya s'mahla etlolwa ngabo boke abantu.
}}

'''Wikiphidiya''' ngumthombo welwazi la [[Free content|mahala]], [[multilingualism|amalimi]] ahlukene, begodu lephurojekti iqondiswa yi[[non-profit organization|nhlangano lengakhokhelwayo]] e[[United States|Amerikka]] engu [[Wikimedia Foundation]]. Yathoma ngo nyaka ka 2001 ngu [[Jimmy Wales]] no [[Larry Sanger]],&lt;ref name=&quot;Miliard&quot;&gt;{{cite news|url=http://www.slweekly.com/index.cfm?do=article.details&amp;id=37BD3969-14D1-13A2-9F5EEAF5A79E0898|title=Wikipediots: Who are these devoted, even obsessive contributors to Wikipedia?|accessdate=2008-02-21|date=2008-03-01 |publisher=[[Salt Lake City Weekly]]|first=Mike|last=Miliard}}&lt;/ref&gt;, begodu ilinga uku qobelela begodu ihlathulule ilwazi labntu boke na malwimi woke.&lt;ref&gt;[http://interviews.slashdot.org/article.pl?sid=04/07/28/1351230 Slashdot | Wikipedia Founder Jimmy Wales Responds&lt;!-- Bot generated title --&gt;]&lt;/ref&gt;

Kusukela ngo 2008, iWikiphidiya yaba ne mitlolo edlula 10&amp;nbsp;wamamiliyoni ngamalwimi angu '''253''';, khulu-khulu ngesinghesi.&lt;ref name=&quot;ListOfWikipedias&quot;&gt;{{cite web | url = http://en.wikipedia.org/wiki/Special:Statistics | title = Statistics | publisher = [[English Wikipedia]] | accessdate = 2008-06-21 }}&lt;/ref&gt; Imitlolo ye Wikiphidiya le, itlolwa [[collaboration|kuberegisana]] kwa[[volunteer|bazinikela ngokuthanda kwabo]] ephasini loke, begodu yoke imitlolo ihlelwa nangubani one inthaneti. Iwikiphidiya le ikhule inje,&lt;ref name=&quot;AlexaStats&quot;&gt;{{cite web | url = http://www.alexa.com/data/details/traffic_details/wikipedia.org?range=5y&amp;size=large&amp;y=t | title = Five-year traffic statistics for wikipedia.org | publisher = [[Alexa Internet]] | accessdate = 2008-07-15 }}&lt;/ref&gt; nge yokthoma begodu ekhulu-khulu ejimeni loku sekela inthaneti.&lt;ref&gt;{{cite news|url=http://www.time.com/time/business/article/0,8599,1595184,00.html|title=Look Who's Using Wikipedia|first=Bill|last=Tancer|date=2007-05-01|publisher=''[[Time (magazine)|Time]]''|accessdate=2007-12-01|quote=The sheer volume of content [...] is partly responsible for the site's dominance as an online reference. When compared to the top 3,200 educational reference sites in the U.S., Wikipedia is #1, capturing 24.3% of all visits to the category}}  ([http://weblogs.hitwise.com/bill-tancer/2007/03/wikipedia_search_and_school_ho.html the author's blog post on the article])&lt;/ref&gt;&lt;ref name=&quot;go-to site&quot;&gt;{{cite news |url=http://www.reuters.com/article/internetNews/idUSN0819429120070708 |title=Wikipedia remains go-to site for online news |date=2007-07-08 |accessdate=2007-12-16 |first=Alex |last=Woodson |publisher=''[[Reuters]]'' |quote=Online encyclopedia Wikipedia has added about 20 million unique monthly visitors in the past year, making it the top online news and information destination, according to Nielsen//NetRatings.}}&lt;/ref&gt;

== References ==
{{Reflist|2}}

{{Commons|Wikipedia}}

&lt;!-- Categories --&gt;
&lt;!-- Interwikis --&gt;

[[Mkhakha:Wikipediya|*]]</text>
      <sha1>3v2ube0pw99fdabvg2sw7nfb634d6t5</sha1>
    </revision>
    <revision>
      <id>1551</id>
      <parentid>1550</parentid>
      <timestamp>2019-01-13T17:16:15Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1551</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4092" sha1="8x77u2yodweryvsz70com16mqanmqim" xml:space="preserve">{{infobox Website
| name = Wikiphidiya
| logo = [[Isimumathi:Wikipedia-logo-v2.svg|100px]]
| screenshot = 
| caption = 
| url = [http://www.ts.wikipedia.org www.ts.wikipedia.org]
| type of organization = [[Nonprofit|Engenzi nzuzo]]
| location = [[Miami, Florida|E mayami, florida]]
| type = [[Internet encyclopedia project|encyclopediya ye inthaneti]]
| language = 236 wamatjhugululo
| registration = 
| owner = [[Wikimedia Foundation]]
| author = [[Jimmy Wales]], [[Larry Sanger]]&lt;!-- Please, please, [discuss] on talk page before rewriting history. This has been in this article for years. --&gt;&lt;ref name=projectorigins&gt;{{cite news|url=http://www.signonsandiego.com/uniontrib/20041206/news_mz1b6encyclo.html|author=Jonathan Sidener|title=Everyone's Encyclopedia|accessdate=2006-10-15|publisher=San Diego Union Tribune}}&lt;/ref&gt;
| launch date = {{birth date|2001|1|15}}
| commercial = 
| alexa = #8
| current status = Umberego oragela phambili&lt;ref&gt;{{Cite web |url=http://en.wikipedia.org/wiki/Wikipedia:Wikipedia_is_a_work_in_progress |title=Wikipedia:Wikipedia is a work in progress |accessdate=2008-07-03 |publisher=Wikipedia}}&lt;/ref&gt;
| slogan = encyclopediya ya s'mahla etlolwa ngabo boke abantu.
}}

'''Wikiphidiya''' ngumthombo welwazi la [[Free content|mahala]], [[multilingualism|amalimi]] ahlukene, begodu lephurojekti iqondiswa yi[[non-profit organization|nhlangano lengakhokhelwayo]] e[[United States|Amerikka]] engu [[Wikimedia Foundation]]. Yathoma ngo nyaka ka 2001 ngu [[Jimmy Wales]] no [[Larry Sanger]],&lt;ref name=&quot;Miliard&quot;&gt;{{cite news|url=http://www.slweekly.com/index.cfm?do=article.details&amp;id=37BD3969-14D1-13A2-9F5EEAF5A79E0898|title=Wikipediots: Who are these devoted, even obsessive contributors to Wikipedia?|accessdate=2008-02-21|date=2008-03-01 |publisher=[[Salt Lake City Weekly]]|first=Mike|last=Miliard}}&lt;/ref&gt;, begodu ilinga uku qobelela begodu ihlathulule ilwazi labntu boke na malwimi woke.&lt;ref&gt;[http://interviews.slashdot.org/article.pl?sid=04/07/28/1351230 Slashdot | Wikipedia Founder Jimmy Wales Responds&lt;!-- Bot generated title --&gt;]&lt;/ref&gt;

Kusukela ngo 2008, iWikiphidiya yaba ne mitlolo edlula 10&amp;nbsp;wamamiliyoni ngamalwimi angu '''253''';, khulu-khulu ngesinghesi.&lt;ref name=&quot;ListOfWikipedias&quot;&gt;{{cite web | url = http://en.wikipedia.org/wiki/Special:Statistics | title = Statistics | publisher = [[English Wikipedia]] | accessdate = 2008-06-21 }}&lt;/ref&gt; Imitlolo ye Wikiphidiya le, itlolwa [[collaboration|kuberegisana]] kwa[[volunteer|bazinikela ngokuthanda kwabo]] ephasini loke, begodu yoke imitlolo ihlelwa nangubani one inthaneti. Iwikiphidiya le ikhule inje,&lt;ref name=&quot;AlexaStats&quot;&gt;{{cite web | url = http://www.alexa.com/data/details/traffic_details/wikipedia.org?range=5y&amp;size=large&amp;y=t | title = Five-year traffic statistics for wikipedia.org | publisher = [[Alexa Internet]] | accessdate = 2008-07-15 }}&lt;/ref&gt; nge yokthoma begodu ekhulu-khulu ejimeni loku sekela inthaneti.&lt;ref&gt;{{cite news|url=http://www.time.com/time/business/article/0,8599,1595184,00.html|title=Look Who's Using Wikipedia|first=Bill|last=Tancer|date=2007-05-01|publisher=''[[Time (magazine)|Time]]''|accessdate=2007-12-01|quote=The sheer volume of content [...] is partly responsible for the site's dominance as an online reference. When compared to the top 3,200 educational reference sites in the U.S., Wikipedia is #1, capturing 24.3% of all visits to the category}}  ([http://weblogs.hitwise.com/bill-tancer/2007/03/wikipedia_search_and_school_ho.html the author's blog post on the article])&lt;/ref&gt;&lt;ref name=&quot;go-to site&quot;&gt;{{cite news |url=http://www.reuters.com/article/internetNews/idUSN0819429120070708 |title=Wikipedia remains go-to site for online news |date=2007-07-08 |accessdate=2007-12-16 |first=Alex |last=Woodson |publisher=''[[Reuters]]'' |quote=Online encyclopedia Wikipedia has added about 20 million unique monthly visitors in the past year, making it the top online news and information destination, according to Nielsen//NetRatings.}}&lt;/ref&gt;

== References ==
{{Reflist|2}}

{{Commons|Wikipedia}}

&lt;!-- Categories --&gt;
&lt;!-- Interwikis --&gt;

[[Mkhakha:Wikipediya|*]]</text>
      <sha1>8x77u2yodweryvsz70com16mqanmqim</sha1>
    </revision>
    <revision>
      <id>1552</id>
      <parentid>1551</parentid>
      <timestamp>2019-01-13T17:16:55Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1552</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4092" sha1="3v2ube0pw99fdabvg2sw7nfb634d6t5" xml:space="preserve">{{infobox Website
| name = Wikiphidiya
| logo = [[Isimumathi:Wikipedia-logo-v2.svg|100px]]
| screenshot = 
| caption = 
| url = [http://www.ts.wikipedia.org www.ts.wikipedia.org]
| type of organization = [[Nonprofit|Engenzi nzuzo]]
| location = [[Miami, Florida|E mayami, florida]]
| type = [[Internet encyclopedia project|encyclopediya ye inthaneti]]
| language = 236 wamatjhugululo
| registration = 
| owner = [[Wikimedia Foundation]]
| author = [[Jimmy Wales]], [[Larry Sanger]]&lt;!-- Please, please, [discuss] on talk page before rewriting history. This has been in this article for years. --&gt;&lt;ref name=projectorigins&gt;{{cite news|url=http://www.signonsandiego.com/uniontrib/20041206/news_mz1b6encyclo.html|author=Jonathan Sidener|title=Everyone's Encyclopedia|accessdate=2006-10-15|publisher=San Diego Union Tribune}}&lt;/ref&gt;
| launch date = {{birth date|2001|1|15}}
| commercial = 
| alexa = #8
| current status = Umberego oragela phambili&lt;ref&gt;{{cite web |url=http://en.wikipedia.org/wiki/Wikipedia:Wikipedia_is_a_work_in_progress |title=Wikipedia:Wikipedia is a work in progress |accessdate=2008-07-03 |publisher=Wikipedia}}&lt;/ref&gt;
| slogan = encyclopediya ya s'mahla etlolwa ngabo boke abantu.
}}

'''Wikiphidiya''' ngumthombo welwazi la [[Free content|mahala]], [[multilingualism|amalimi]] ahlukene, begodu lephurojekti iqondiswa yi[[non-profit organization|nhlangano lengakhokhelwayo]] e[[United States|Amerikka]] engu [[Wikimedia Foundation]]. Yathoma ngo nyaka ka 2001 ngu [[Jimmy Wales]] no [[Larry Sanger]],&lt;ref name=&quot;Miliard&quot;&gt;{{cite news|url=http://www.slweekly.com/index.cfm?do=article.details&amp;id=37BD3969-14D1-13A2-9F5EEAF5A79E0898|title=Wikipediots: Who are these devoted, even obsessive contributors to Wikipedia?|accessdate=2008-02-21|date=2008-03-01 |publisher=[[Salt Lake City Weekly]]|first=Mike|last=Miliard}}&lt;/ref&gt;, begodu ilinga uku qobelela begodu ihlathulule ilwazi labntu boke na malwimi woke.&lt;ref&gt;[http://interviews.slashdot.org/article.pl?sid=04/07/28/1351230 Slashdot | Wikipedia Founder Jimmy Wales Responds&lt;!-- Bot generated title --&gt;]&lt;/ref&gt;

Kusukela ngo 2008, iWikiphidiya yaba ne mitlolo edlula 10&amp;nbsp;wamamiliyoni ngamalwimi angu '''253''';, khulu-khulu ngesinghesi.&lt;ref name=&quot;ListOfWikipedias&quot;&gt;{{cite web | url = http://en.wikipedia.org/wiki/Special:Statistics | title = Statistics | publisher = [[English Wikipedia]] | accessdate = 2008-06-21 }}&lt;/ref&gt; Imitlolo ye Wikiphidiya le, itlolwa [[collaboration|kuberegisana]] kwa[[volunteer|bazinikela ngokuthanda kwabo]] ephasini loke, begodu yoke imitlolo ihlelwa nangubani one inthaneti. Iwikiphidiya le ikhule inje,&lt;ref name=&quot;AlexaStats&quot;&gt;{{cite web | url = http://www.alexa.com/data/details/traffic_details/wikipedia.org?range=5y&amp;size=large&amp;y=t | title = Five-year traffic statistics for wikipedia.org | publisher = [[Alexa Internet]] | accessdate = 2008-07-15 }}&lt;/ref&gt; nge yokthoma begodu ekhulu-khulu ejimeni loku sekela inthaneti.&lt;ref&gt;{{cite news|url=http://www.time.com/time/business/article/0,8599,1595184,00.html|title=Look Who's Using Wikipedia|first=Bill|last=Tancer|date=2007-05-01|publisher=''[[Time (magazine)|Time]]''|accessdate=2007-12-01|quote=The sheer volume of content [...] is partly responsible for the site's dominance as an online reference. When compared to the top 3,200 educational reference sites in the U.S., Wikipedia is #1, capturing 24.3% of all visits to the category}}  ([http://weblogs.hitwise.com/bill-tancer/2007/03/wikipedia_search_and_school_ho.html the author's blog post on the article])&lt;/ref&gt;&lt;ref name=&quot;go-to site&quot;&gt;{{cite news |url=http://www.reuters.com/article/internetNews/idUSN0819429120070708 |title=Wikipedia remains go-to site for online news |date=2007-07-08 |accessdate=2007-12-16 |first=Alex |last=Woodson |publisher=''[[Reuters]]'' |quote=Online encyclopedia Wikipedia has added about 20 million unique monthly visitors in the past year, making it the top online news and information destination, according to Nielsen//NetRatings.}}&lt;/ref&gt;

== References ==
{{Reflist|2}}

{{Commons|Wikipedia}}

&lt;!-- Categories --&gt;
&lt;!-- Interwikis --&gt;

[[Mkhakha:Wikipediya|*]]</text>
      <sha1>3v2ube0pw99fdabvg2sw7nfb634d6t5</sha1>
    </revision>
    <revision>
      <id>1553</id>
      <parentid>1552</parentid>
      <timestamp>2019-01-13T17:29:56Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1553</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2374" sha1="mb8dp6gxxlkt4qbpf4ezvt6h3ybhy2p" xml:space="preserve">{{infobox Website
| name = Wikiphidiya
| logo = [[Isimumathi:Wikipedia-logo-v2.svg|100px]]
| screenshot = 
| caption = 
| url = [http://www.ts.wikipedia.org www.ts.wikipedia.org]
| type of organization = [[Nonprofit|Engenzi nzuzo]]
| location = [[Miami, Florida|E mayami, florida]]
| type = [[Internet encyclopedia project|encyclopediya ye inthaneti]]
| language = 236 wamatjhugululo
| registration = 
| owner = [[Wikimedia Foundation]]
| author = [[Jimmy Wales]], [[Larry Sanger]]
| launch date = {{birth date|2001|1|15}}
| commercial = 
| alexa = #8
| current status = Umberego oragela phambili&lt;ref&gt;{{cite web |url=http://en.wikipedia.org/wiki/Wikipedia:Wikipedia_is_a_work_in_progress |title=Wikipedia:Wikipedia is a work in progress |accessdate=2008-07-03 |publisher=Wikipedia}}&lt;/ref&gt;
| slogan = encyclopediya ya s'mahla etlolwa ngabo boke abantu.
}}

'''Wikiphidiya''' ngumthombo welwazi la [[Free content|mahala]], [[multilingualism|amalimi]] ahlukene, begodu lephurojekti iqondiswa yi[[non-profit organization|nhlangano lengakhokhelwayo]] e[[United States|Amerikka]] engu [[Wikimedia Foundation]]. Yathoma ngo nyaka ka 2001 ngu [[Jimmy Wales]] no [[Larry Sanger]], begodu ilinga uku qobelela begodu ihlathulule ilwazi labntu boke na malwimi woke.&lt;ref&gt;[http://interviews.slashdot.org/article.pl?sid=04/07/28/1351230 Slashdot | Wikipedia Founder Jimmy Wales Responds&lt;!-- Bot generated title --&gt;]&lt;/ref&gt;

Kusukela ngo 2008, iWikiphidiya yaba ne mitlolo edlula 10&amp;nbsp;wamamiliyoni ngamalwimi angu '''253''';, khulu-khulu ngesinghesi.&lt;ref name=&quot;ListOfWikipedias&quot;&gt;{{cite web | url = http://en.wikipedia.org/wiki/Special:Statistics | title = Statistics | publisher = [[English Wikipedia]] | accessdate = 2008-06-21 }}&lt;/ref&gt; Imitlolo ye Wikiphidiya le, itlolwa [[collaboration|kuberegisana]] kwa[[volunteer|bazinikela ngokuthanda kwabo]] ephasini loke, begodu yoke imitlolo ihlelwa nangubani one inthaneti. Iwikiphidiya le ikhule inje,&lt;ref name=&quot;AlexaStats&quot;&gt;{{cite web | url = http://www.alexa.com/data/details/traffic_details/wikipedia.org?range=5y&amp;size=large&amp;y=t | title = Five-year traffic statistics for wikipedia.org | publisher = [[Alexa Internet]] | accessdate = 2008-07-15 }}&lt;/ref&gt; nge yokthoma begodu ekhulu-khulu ejimeni loku sekela inthaneti.

== References ==
{{Reflist|2}}

{{Commons|Wikipedia}}

&lt;!-- Categories --&gt;
&lt;!-- Interwikis --&gt;

[[Mkhakha:Wikipediya|*]]</text>
      <sha1>mb8dp6gxxlkt4qbpf4ezvt6h3ybhy2p</sha1>
    </revision>
    <revision>
      <id>1554</id>
      <parentid>1553</parentid>
      <timestamp>2019-01-13T17:31:20Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1553</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2374" sha1="mb8dp6gxxlkt4qbpf4ezvt6h3ybhy2p" xml:space="preserve">{{infobox Website
| name = Wikiphidiya
| logo = [[Isimumathi:Wikipedia-logo-v2.svg|100px]]
| screenshot = 
| caption = 
| url = [http://www.ts.wikipedia.org www.ts.wikipedia.org]
| type of organization = [[Nonprofit|Engenzi nzuzo]]
| location = [[Miami, Florida|E mayami, florida]]
| type = [[Internet encyclopedia project|encyclopediya ye inthaneti]]
| language = 236 wamatjhugululo
| registration = 
| owner = [[Wikimedia Foundation]]
| author = [[Jimmy Wales]], [[Larry Sanger]]
| launch date = {{birth date|2001|1|15}}
| commercial = 
| alexa = #8
| current status = Umberego oragela phambili&lt;ref&gt;{{cite web |url=http://en.wikipedia.org/wiki/Wikipedia:Wikipedia_is_a_work_in_progress |title=Wikipedia:Wikipedia is a work in progress |accessdate=2008-07-03 |publisher=Wikipedia}}&lt;/ref&gt;
| slogan = encyclopediya ya s'mahla etlolwa ngabo boke abantu.
}}

'''Wikiphidiya''' ngumthombo welwazi la [[Free content|mahala]], [[multilingualism|amalimi]] ahlukene, begodu lephurojekti iqondiswa yi[[non-profit organization|nhlangano lengakhokhelwayo]] e[[United States|Amerikka]] engu [[Wikimedia Foundation]]. Yathoma ngo nyaka ka 2001 ngu [[Jimmy Wales]] no [[Larry Sanger]], begodu ilinga uku qobelela begodu ihlathulule ilwazi labntu boke na malwimi woke.&lt;ref&gt;[http://interviews.slashdot.org/article.pl?sid=04/07/28/1351230 Slashdot | Wikipedia Founder Jimmy Wales Responds&lt;!-- Bot generated title --&gt;]&lt;/ref&gt;

Kusukela ngo 2008, iWikiphidiya yaba ne mitlolo edlula 10&amp;nbsp;wamamiliyoni ngamalwimi angu '''253''';, khulu-khulu ngesinghesi.&lt;ref name=&quot;ListOfWikipedias&quot;&gt;{{cite web | url = http://en.wikipedia.org/wiki/Special:Statistics | title = Statistics | publisher = [[English Wikipedia]] | accessdate = 2008-06-21 }}&lt;/ref&gt; Imitlolo ye Wikiphidiya le, itlolwa [[collaboration|kuberegisana]] kwa[[volunteer|bazinikela ngokuthanda kwabo]] ephasini loke, begodu yoke imitlolo ihlelwa nangubani one inthaneti. Iwikiphidiya le ikhule inje,&lt;ref name=&quot;AlexaStats&quot;&gt;{{cite web | url = http://www.alexa.com/data/details/traffic_details/wikipedia.org?range=5y&amp;size=large&amp;y=t | title = Five-year traffic statistics for wikipedia.org | publisher = [[Alexa Internet]] | accessdate = 2008-07-15 }}&lt;/ref&gt; nge yokthoma begodu ekhulu-khulu ejimeni loku sekela inthaneti.

== References ==
{{Reflist|2}}

{{Commons|Wikipedia}}

&lt;!-- Categories --&gt;
&lt;!-- Interwikis --&gt;

[[Mkhakha:Wikipediya|*]]</text>
      <sha1>mb8dp6gxxlkt4qbpf4ezvt6h3ybhy2p</sha1>
    </revision>
    <revision>
      <id>1555</id>
      <parentid>1554</parentid>
      <timestamp>2019-01-13T17:38:12Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1555</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2359" sha1="f9pt44p4tpoznqli5sluxj1d6zvjdz1" xml:space="preserve">{{infobox Website
| name = Wikiphidiya
| logo = [[Isimumathi:Wikipedia-logo-v2.svg|100px]]
| screenshot = 
| caption = 
| url = [http://www.ts.wikipedia.org www.ts.wikipedia.org]
| type of organization = [[Nonprofit|Engenzi nzuzo]]
| location = [[Miami, Florida|E mayami, florida]]
| type = [[Internet encyclopedia project|encyclopediya ye inthaneti]]
| language = 236 wamatjhugululo
| registration = 
| owner = [[Wikimedia Foundation]]
| author = [[Jimmy Wales]], [[Larry Sanger]]
| launch date = 2001|1|15
| commercial = 
| alexa = #8
| current status = Umberego oragela phambili&lt;ref&gt;{{cite web |url=http://en.wikipedia.org/wiki/Wikipedia:Wikipedia_is_a_work_in_progress |title=Wikipedia:Wikipedia is a work in progress |accessdate=2008-07-03 |publisher=Wikipedia}}&lt;/ref&gt;
| slogan = encyclopediya ya s'mahla etlolwa ngabo boke abantu.
}}

'''Wikiphidiya''' ngumthombo welwazi la [[Free content|mahala]], [[multilingualism|amalimi]] ahlukene, begodu lephurojekti iqondiswa yi[[non-profit organization|nhlangano lengakhokhelwayo]] e[[United States|Amerikka]] engu [[Wikimedia Foundation]]. Yathoma ngo nyaka ka 2001 ngu [[Jimmy Wales]] no [[Larry Sanger]], begodu ilinga uku qobelela begodu ihlathulule ilwazi labntu boke na malwimi woke.&lt;ref&gt;[http://interviews.slashdot.org/article.pl?sid=04/07/28/1351230 Slashdot | Wikipedia Founder Jimmy Wales Responds&lt;!-- Bot generated title --&gt;]&lt;/ref&gt;

Kusukela ngo 2008, iWikiphidiya yaba ne mitlolo edlula 10&amp;nbsp;wamamiliyoni ngamalwimi angu '''253''';, khulu-khulu ngesinghesi.&lt;ref name=&quot;ListOfWikipedias&quot;&gt;{{cite web | url = http://en.wikipedia.org/wiki/Special:Statistics | title = Statistics | publisher = [[English Wikipedia]] | accessdate = 2008-06-21 }}&lt;/ref&gt; Imitlolo ye Wikiphidiya le, itlolwa [[collaboration|kuberegisana]] kwa[[volunteer|bazinikela ngokuthanda kwabo]] ephasini loke, begodu yoke imitlolo ihlelwa nangubani one inthaneti. Iwikiphidiya le ikhule inje,&lt;ref name=&quot;AlexaStats&quot;&gt;{{cite web | url = http://www.alexa.com/data/details/traffic_details/wikipedia.org?range=5y&amp;size=large&amp;y=t | title = Five-year traffic statistics for wikipedia.org | publisher = [[Alexa Internet]] | accessdate = 2008-07-15 }}&lt;/ref&gt; nge yokthoma begodu ekhulu-khulu ejimeni loku sekela inthaneti.

== References ==
{{Reflist|2}}

{{Commons|Wikipedia}}

&lt;!-- Categories --&gt;
&lt;!-- Interwikis --&gt;

[[Mkhakha:Wikipediya|*]]</text>
      <sha1>f9pt44p4tpoznqli5sluxj1d6zvjdz1</sha1>
    </revision>
    <revision>
      <id>1556</id>
      <parentid>1555</parentid>
      <timestamp>2024-04-28T12:05:06Z</timestamp>
      <contributor>
        <username>Nintendofan885</username>
        <id>5</id>
      </contributor>
      <minor />
      <comment>Adding interwiki links to [[d:Q52]]</comment>
      <origin>1556</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2378" sha1="h7ky6xj03bt2pwrergkxt93k61a3jgs" xml:space="preserve">{{infobox Website
| name = Wikiphidiya
| logo = [[Isimumathi:Wikipedia-logo-v2.svg|100px]]
| screenshot = 
| caption = 
| url = [http://www.ts.wikipedia.org www.ts.wikipedia.org]
| type of organization = [[Nonprofit|Engenzi nzuzo]]
| location = [[Miami, Florida|E mayami, florida]]
| type = [[Internet encyclopedia project|encyclopediya ye inthaneti]]
| language = 236 wamatjhugululo
| registration = 
| owner = [[Wikimedia Foundation]]
| author = [[Jimmy Wales]], [[Larry Sanger]]
| launch date = 2001|1|15
| commercial = 
| alexa = #8
| current status = Umberego oragela phambili&lt;ref&gt;{{cite web |url=http://en.wikipedia.org/wiki/Wikipedia:Wikipedia_is_a_work_in_progress |title=Wikipedia:Wikipedia is a work in progress |accessdate=2008-07-03 |publisher=Wikipedia}}&lt;/ref&gt;
| slogan = encyclopediya ya s'mahla etlolwa ngabo boke abantu.
}}

'''Wikiphidiya''' ngumthombo welwazi la [[Free content|mahala]], [[multilingualism|amalimi]] ahlukene, begodu lephurojekti iqondiswa yi[[non-profit organization|nhlangano lengakhokhelwayo]] e[[United States|Amerikka]] engu [[Wikimedia Foundation]]. Yathoma ngo nyaka ka 2001 ngu [[Jimmy Wales]] no [[Larry Sanger]], begodu ilinga uku qobelela begodu ihlathulule ilwazi labntu boke na malwimi woke.&lt;ref&gt;[http://interviews.slashdot.org/article.pl?sid=04/07/28/1351230 Slashdot | Wikipedia Founder Jimmy Wales Responds&lt;!-- Bot generated title --&gt;]&lt;/ref&gt;

Kusukela ngo 2008, iWikiphidiya yaba ne mitlolo edlula 10&amp;nbsp;wamamiliyoni ngamalwimi angu '''253''';, khulu-khulu ngesinghesi.&lt;ref name=&quot;ListOfWikipedias&quot;&gt;{{cite web | url = http://en.wikipedia.org/wiki/Special:Statistics | title = Statistics | publisher = [[English Wikipedia]] | accessdate = 2008-06-21 }}&lt;/ref&gt; Imitlolo ye Wikiphidiya le, itlolwa [[collaboration|kuberegisana]] kwa[[volunteer|bazinikela ngokuthanda kwabo]] ephasini loke, begodu yoke imitlolo ihlelwa nangubani one inthaneti. Iwikiphidiya le ikhule inje,&lt;ref name=&quot;AlexaStats&quot;&gt;{{cite web | url = http://www.alexa.com/data/details/traffic_details/wikipedia.org?range=5y&amp;size=large&amp;y=t | title = Five-year traffic statistics for wikipedia.org | publisher = [[Alexa Internet]] | accessdate = 2008-07-15 }}&lt;/ref&gt; nge yokthoma begodu ekhulu-khulu ejimeni loku sekela inthaneti.

== References ==
{{Reflist|2}}

{{Commons|Wikipedia}}

&lt;!-- Categories --&gt;
&lt;!-- Interwikis --&gt;

[[Mkhakha:Wikipediya|*]]

{{INTERWIKI|Q52}}</text>
      <sha1>h7ky6xj03bt2pwrergkxt93k61a3jgs</sha1>
    </revision>
    <revision>
      <id>1557</id>
      <parentid>1556</parentid>
      <timestamp>2024-04-28T12:06:14Z</timestamp>
      <contributor>
        <username>Nintendofan885</username>
        <id>5</id>
      </contributor>
      <minor />
      <comment>fix website</comment>
      <origin>1557</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2372" sha1="ist2pxj5qtfg2hbizaomoi5nopp0f26" xml:space="preserve">{{Infobox Website
| name = Wikiphidiya
| logo = [[Isimumathi:Wikipedia-logo-v2.svg|100px]]
| screenshot = 
| caption = 
| url = [http://www.wikipedia.org www.wikipedia.org]
| type of organization = [[Nonprofit|Engenzi nzuzo]]
| location = [[Miami, Florida|E mayami, florida]]
| type = [[Internet encyclopedia project|encyclopediya ye inthaneti]]
| language = 236 wamatjhugululo
| registration = 
| owner = [[Wikimedia Foundation]]
| author = [[Jimmy Wales]], [[Larry Sanger]]
| launch date = 2001|1|15
| commercial = 
| alexa = #8
| current status = Umberego oragela phambili&lt;ref&gt;{{Cite web |url=http://en.wikipedia.org/wiki/Wikipedia:Wikipedia_is_a_work_in_progress |title=Wikipedia:Wikipedia is a work in progress |accessdate=2008-07-03 |publisher=Wikipedia}}&lt;/ref&gt;
| slogan = encyclopediya ya s'mahla etlolwa ngabo boke abantu.
}}

'''Wikiphidiya''' ngumthombo welwazi la [[Free content|mahala]], [[Multilingualism|amalimi]] ahlukene, begodu lephurojekti iqondiswa yi[[Non-profit organization|nhlangano lengakhokhelwayo]] e[[United States|Amerikka]] engu [[Wikimedia Foundation]]. Yathoma ngo nyaka ka 2001 ngu [[Jimmy Wales]] no [[Larry Sanger]], begodu ilinga uku qobelela begodu ihlathulule ilwazi labntu boke na malwimi woke.&lt;ref&gt;[http://interviews.slashdot.org/article.pl?sid=04/07/28/1351230 Slashdot | Wikipedia Founder Jimmy Wales Responds&lt;!-- Bot generated title --&gt;]&lt;/ref&gt;

Kusukela ngo 2008, iWikiphidiya yaba ne mitlolo edlula 10&amp;nbsp;wamamiliyoni ngamalwimi angu '''253''';, khulu-khulu ngesinghesi.&lt;ref name=&quot;ListOfWikipedias&quot;&gt;{{Cite web | url = http://en.wikipedia.org/wiki/Special:Statistics | title = Statistics | publisher = [[English Wikipedia]] | accessdate = 2008-06-21 }}&lt;/ref&gt; Imitlolo ye Wikiphidiya le, itlolwa [[Collaboration|kuberegisana]] kwa[[Volunteer|bazinikela ngokuthanda kwabo]] ephasini loke, begodu yoke imitlolo ihlelwa nangubani one inthaneti. Iwikiphidiya le ikhule inje,&lt;ref name=&quot;AlexaStats&quot;&gt;{{Cite web | url = http://www.alexa.com/data/details/traffic_details/wikipedia.org?range=5y&amp;size=large&amp;y=t | title = Five-year traffic statistics for wikipedia.org | publisher = [[Alexa Internet]] | accessdate = 2008-07-15 }}&lt;/ref&gt; nge yokthoma begodu ekhulu-khulu ejimeni loku sekela inthaneti.

== References ==
{{Reflist|2}}

{{Commons|Wikipedia}}

&lt;!-- Categories --&gt;
&lt;!-- Interwikis --&gt;

[[Mkhakha:Wikipediya|*]]

{{INTERWIKI|Q52}}</text>
      <sha1>ist2pxj5qtfg2hbizaomoi5nopp0f26</sha1>
    </revision>
    <revision>
      <id>1558</id>
      <parentid>1557</parentid>
      <timestamp>2024-05-09T12:28:42Z</timestamp>
      <contributor>
        <username>incubator&gt;Nomsa Skosana</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1558</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2410" sha1="h5maxegdq5geve85p1q84ahdtp7viuz" xml:space="preserve">{{Infobox Website
| name = Wikiphidiya
| logo = [[Isimumathi:Wikipedia-logo-v2.svg|100px]]
| screenshot = 
| caption = 
| url = [http://www.wikipedia.org www.wikipedia.org]
| type of organization = [[Nonprofit|Engenzi nzuzo]]
| location = [[Miami, Florida|E mayami, florida]]
| type = [[Internet encyclopedia project|encyclopediya ye inthaneti]]
| language = 236 wamatjhugululo
| registration = 
| owner = [[Wikimedia Foundation]]
| author = [[Jimmy Wales]], [[Larry Sanger]]
| launch date = 2001|1|15
| commercial = 
| alexa = #8
| current status = Umberego oragela phambili&lt;ref&gt;{{Cite web |url=http://en.wikipedia.org/wiki/Wikipedia:Wikipedia_is_a_work_in_progress |title=Wikipedia:Wikipedia is a work in progress |accessdate=2008-07-03 |publisher=Wikipedia}}&lt;/ref&gt;
| slogan = encyclopediya ya s'mahla etlolwa ngabo boke abantu.
}}

'''IWikiphidiya''' mthombo welwazi lasi[[Free content|mahala]], [[Multilingualism|amalimi]] ahlukahlukeneko, begodu iphrojekthi le inqotjhiswa yi[[Non-profit organization|hlangano engabhadelwako]] yasimahla ese-[[United States|America]] eyaziwa nge-[[Wikimedia Foundation]]. Ihlangano le yathoma ngomnyaka wee-2001,  [[Jimmy Wales]] no [[Larry Sanger]], begodu ilinga uku qobelela begodu ihlathulule ilwazi labntu boke na malwimi woke.&lt;ref&gt;[http://interviews.slashdot.org/article.pl?sid=04/07/28/1351230 Slashdot | Wikipedia Founder Jimmy Wales Responds&lt;!-- Bot generated title --&gt;]&lt;/ref&gt;

Kusukela ngo 2008, iWikiphidiya yaba ne mitlolo edlula 10&amp;nbsp;wamamiliyoni ngamalwimi angu '''253''';, khulu-khulu ngesinghesi.&lt;ref name=&quot;ListOfWikipedias&quot;&gt;{{Cite web | url = http://en.wikipedia.org/wiki/Special:Statistics | title = Statistics | publisher = [[English Wikipedia]] | accessdate = 2008-06-21 }}&lt;/ref&gt; Imitlolo ye Wikiphidiya le, itlolwa [[Collaboration|kuberegisana]] kwa[[Volunteer|bazinikela ngokuthanda kwabo]] ephasini loke, begodu yoke imitlolo ihlelwa nangubani one inthaneti. Iwikiphidiya le ikhule inje,&lt;ref name=&quot;AlexaStats&quot;&gt;{{Cite web | url = http://www.alexa.com/data/details/traffic_details/wikipedia.org?range=5y&amp;size=large&amp;y=t | title = Five-year traffic statistics for wikipedia.org | publisher = [[Alexa Internet]] | accessdate = 2008-07-15 }}&lt;/ref&gt; nge yokthoma begodu ekhulu-khulu ejimeni loku sekela inthaneti.

== References ==
{{Reflist|2}}

{{Commons|Wikipedia}}

&lt;!-- Categories --&gt;
&lt;!-- Interwikis --&gt;

[[Mkhakha:Wikipediya|*]]

{{INTERWIKI|Q52}}</text>
      <sha1>h5maxegdq5geve85p1q84ahdtp7viuz</sha1>
    </revision>
    <revision>
      <id>1559</id>
      <parentid>1558</parentid>
      <timestamp>2024-05-09T13:05:27Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1559</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2405" sha1="ny3rqlnc8z4cyif4up93exzzbnmlkqj" xml:space="preserve">{{Infobox Website
| name = IWikiphidiya
| logo = [[Isimumathi:Wikipedia-logo-v2.svg|100px]]
| screenshot = 
| caption = 
| url = [http://www.wikipedia.org www.wikipedia.org]
| type of organization = [[Nonprofit|Engenzi inzuzo]]
| location = [[Miami, Florida|E-Miami, ne-Florida]]
| type = [[Internet encyclopedia project|I-Insayitlophidiya ye-inthanethi]]
| language = Ama-236 wamatjhugululo
| registration = 
| owner = [[Wikimedia Foundation]]
| author = [[Jimmy Wales]], [[Larry Sanger]]
| launch date = 2001|1|15
| commercial = 
| alexa = #8
| current status = IWikiphidiya msebenzi osaragela phambili&lt;ref&gt;{{Cite web |url=http://en.wikipedia.org/wiki/Wikipedia:Wikipedia_is_a_work_in_progress |title=Wikipedia:Wikipedia is a work in progress |accessdate=2008-07-03 |publisher=Wikipedia}}&lt;/ref&gt;
| slogan = I-Insayitlophidiya esimahla.
}}

'''IWikiphidiya''' mthombolwazi wasimahla ng[[Multilingualism|amalimi]] ahlukahlukeneko. Iphrojekhthi le inqotjhiswa yi[[Non-profit organization|hlangano engabhadelwako]] yasimahla enzinze e-[[United States|America]] eyaziwa nge-[[Wikimedia Foundation]]. Ihlangano le yathoma ngomnyaka ween-2001,  [[Jimmy Wales|ngu-Jimmy Wales]] no-[[Larry Sanger]], begodu ilinga uku qobelela nokuhlathulula ilwazi labantu boke namalimi woke.&lt;ref&gt;[http://interviews.slashdot.org/article.pl?sid=04/07/28/1351230 Slashdot | Wikipedia Founder Jimmy Wales Responds&lt;!-- Bot generated title --&gt;]&lt;/ref&gt;

Kusukela ngomnyaka ween-2008, iWikiphidiya yaba nemitlolo edlula eengidini ezili-10 ngamalimi am'''a-253''';, khulukhulu nge-English.&lt;ref name=&quot;ListOfWikipedias&quot;&gt;{{Cite web | url = http://en.wikipedia.org/wiki/Special:Statistics | title = Statistics | publisher = [[English Wikipedia]] | accessdate = 2008-06-21 }}&lt;/ref&gt; Imitlolo yeWikiphidiya le, itlolwa [[Collaboration|ngokusebenzisana]] kwa[[Volunteer|bazinikeleko]] ephasini loke, begodu yoke imitlolo ihlelwa nangubani one-inthanethi. IWikiphidiya le ikhule inje,&lt;ref name=&quot;AlexaStats&quot;&gt;{{Cite web | url = http://www.alexa.com/data/details/traffic_details/wikipedia.org?range=5y&amp;size=large&amp;y=t | title = Five-year traffic statistics for wikipedia.org | publisher = [[Alexa Internet]] | accessdate = 2008-07-15 }}&lt;/ref&gt; ngeyokuthoma begodu, ekhulukhulu, ejimeni lokusekela inthanethi.

== Umthombolwazi ==
{{Reflist|2}}

{{Commons|Wikipedia}}

&lt;!-- Categories --&gt;
&lt;!-- Interwikis --&gt;

[[Mkhakha:Wikipediya|*]]

{{INTERWIKI|Q52}}</text>
      <sha1>ny3rqlnc8z4cyif4up93exzzbnmlkqj</sha1>
    </revision>
    <revision>
      <id>1560</id>
      <parentid>1559</parentid>
      <timestamp>2024-05-09T13:12:17Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1560</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2399" sha1="dh2wox72w2s29q5zoo15bw0gky6jkzw" xml:space="preserve">{{Infobox Website
| name = IWikiphidiya
| logo = [[Isimumathi:Wikipedia-logo-v2.svg|100px]]
| screenshot = 
| caption = 
| url = [http://www.wikipedia.org www.wikipedia.org]
| type of organization = [[Nonprofit|Engenzi inzuzo]]
| location = [[Miami, Florida|E-Miami, ne-Florida]]
| type = [[Internet encyclopedia project|I-Insayitlophidiya ye-inthanethi]]
| language = Ama-236 wamatjhugululo
| registration = 
| owner = [[Wikimedia Foundation]]
| author = [[Jimmy Wales]], [[Larry Sanger]]
| launch date = 2001|1|15
| commercial = 
| alexa = #8
| current status = IWikiphidiya msebenzi osaragela phambili&lt;ref&gt;{{Cite web |url=http://en.wikipedia.org/wiki/Wikipedia:Wikipedia_is_a_work_in_progress |title=Wikipedia:Wikipedia is a work in progress |accessdate=2008-07-03 |publisher=Wikipedia}}&lt;/ref&gt;
| slogan = I-Insayitlophidiya esimahla.
}}

'''IWikiphidiya''' mthombolwazi osimahla ong[[Multilingualism|amalimi]] ahlukahlukeneko. Iphrojekhthi le ilawulwa yi[[Non-profit organization|hlangano engabhadelwako]] yasimahla enzinze e-[[United States|America]] eyaziwa nge-[[Wikimedia Foundation]]. Ihlangano le yathoma ngomnyaka ween-2001,  [[Jimmy Wales|ngu-Jimmy Wales]] no-[[Larry Sanger]], begodu ilinga ukubuthelela nokuhlathulula ilwazi labantu ngamalimi woke.&lt;ref&gt;[http://interviews.slashdot.org/article.pl?sid=04/07/28/1351230 Slashdot | Wikipedia Founder Jimmy Wales Responds&lt;!-- Bot generated title --&gt;]&lt;/ref&gt;

Kusukela ngomnyaka ween-2008, iWikiphidiya yaba nemitlolo edlula eengidini ezili-10 ngamalimi ama-'''253''', khulukhulu nge-English.&lt;ref name=&quot;ListOfWikipedias&quot;&gt;{{Cite web | url = http://en.wikipedia.org/wiki/Special:Statistics | title = Statistics | publisher = [[English Wikipedia]] | accessdate = 2008-06-21 }}&lt;/ref&gt; Imitlolo yeWikiphidiya le, itlolwa [[Collaboration|ngokusebenzisana]] kwa[[Volunteer|bazinikeleko]] ephasini loke, begodu yoke imitlolo ihlelwa nangubani one-inthanethi. IWikiphidiya le ikhule inje,&lt;ref name=&quot;AlexaStats&quot;&gt;{{Cite web | url = http://www.alexa.com/data/details/traffic_details/wikipedia.org?range=5y&amp;size=large&amp;y=t | title = Five-year traffic statistics for wikipedia.org | publisher = [[Alexa Internet]] | accessdate = 2008-07-15 }}&lt;/ref&gt; ngeyokuthoma begodu, ekulu khulu, ejimeni lokusekela i-inthanethi.

== Umthombolwazi ==
{{Reflist|2}}

{{Commons|Wikipedia}}

&lt;!-- Categories --&gt;
&lt;!-- Interwikis --&gt;

[[Mkhakha:Wikipediya|*]]

{{INTERWIKI|Q52}}</text>
      <sha1>dh2wox72w2s29q5zoo15bw0gky6jkzw</sha1>
    </revision>
    <revision>
      <id>1561</id>
      <parentid>1560</parentid>
      <timestamp>2024-10-14T13:47:48Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>16 revisions imported</comment>
      <origin>1560</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2399" sha1="dh2wox72w2s29q5zoo15bw0gky6jkzw" xml:space="preserve">{{Infobox Website
| name = IWikiphidiya
| logo = [[Isimumathi:Wikipedia-logo-v2.svg|100px]]
| screenshot = 
| caption = 
| url = [http://www.wikipedia.org www.wikipedia.org]
| type of organization = [[Nonprofit|Engenzi inzuzo]]
| location = [[Miami, Florida|E-Miami, ne-Florida]]
| type = [[Internet encyclopedia project|I-Insayitlophidiya ye-inthanethi]]
| language = Ama-236 wamatjhugululo
| registration = 
| owner = [[Wikimedia Foundation]]
| author = [[Jimmy Wales]], [[Larry Sanger]]
| launch date = 2001|1|15
| commercial = 
| alexa = #8
| current status = IWikiphidiya msebenzi osaragela phambili&lt;ref&gt;{{Cite web |url=http://en.wikipedia.org/wiki/Wikipedia:Wikipedia_is_a_work_in_progress |title=Wikipedia:Wikipedia is a work in progress |accessdate=2008-07-03 |publisher=Wikipedia}}&lt;/ref&gt;
| slogan = I-Insayitlophidiya esimahla.
}}

'''IWikiphidiya''' mthombolwazi osimahla ong[[Multilingualism|amalimi]] ahlukahlukeneko. Iphrojekhthi le ilawulwa yi[[Non-profit organization|hlangano engabhadelwako]] yasimahla enzinze e-[[United States|America]] eyaziwa nge-[[Wikimedia Foundation]]. Ihlangano le yathoma ngomnyaka ween-2001,  [[Jimmy Wales|ngu-Jimmy Wales]] no-[[Larry Sanger]], begodu ilinga ukubuthelela nokuhlathulula ilwazi labantu ngamalimi woke.&lt;ref&gt;[http://interviews.slashdot.org/article.pl?sid=04/07/28/1351230 Slashdot | Wikipedia Founder Jimmy Wales Responds&lt;!-- Bot generated title --&gt;]&lt;/ref&gt;

Kusukela ngomnyaka ween-2008, iWikiphidiya yaba nemitlolo edlula eengidini ezili-10 ngamalimi ama-'''253''', khulukhulu nge-English.&lt;ref name=&quot;ListOfWikipedias&quot;&gt;{{Cite web | url = http://en.wikipedia.org/wiki/Special:Statistics | title = Statistics | publisher = [[English Wikipedia]] | accessdate = 2008-06-21 }}&lt;/ref&gt; Imitlolo yeWikiphidiya le, itlolwa [[Collaboration|ngokusebenzisana]] kwa[[Volunteer|bazinikeleko]] ephasini loke, begodu yoke imitlolo ihlelwa nangubani one-inthanethi. IWikiphidiya le ikhule inje,&lt;ref name=&quot;AlexaStats&quot;&gt;{{Cite web | url = http://www.alexa.com/data/details/traffic_details/wikipedia.org?range=5y&amp;size=large&amp;y=t | title = Five-year traffic statistics for wikipedia.org | publisher = [[Alexa Internet]] | accessdate = 2008-07-15 }}&lt;/ref&gt; ngeyokuthoma begodu, ekulu khulu, ejimeni lokusekela i-inthanethi.

== Umthombolwazi ==
{{Reflist|2}}

{{Commons|Wikipedia}}

&lt;!-- Categories --&gt;
&lt;!-- Interwikis --&gt;

[[Mkhakha:Wikipediya|*]]

{{INTERWIKI|Q52}}</text>
      <sha1>dh2wox72w2s29q5zoo15bw0gky6jkzw</sha1>
    </revision>
    <revision>
      <id>1681</id>
      <parentid>1561</parentid>
      <timestamp>2024-10-16T09:50:18Z</timestamp>
      <contributor>
        <username>JhsBot</username>
        <id>34</id>
      </contributor>
      <minor />
      <comment>bot: Removing interwiki template; the page is now connected to [[d:Q52]]</comment>
      <origin>1681</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2380" sha1="ilnduqum4e5zesv3v7aqhya9tcy1fr2" xml:space="preserve">{{Infobox Website
| name = IWikiphidiya
| logo = [[Isimumathi:Wikipedia-logo-v2.svg|100px]]
| screenshot = 
| caption = 
| url = [http://www.wikipedia.org www.wikipedia.org]
| type of organization = [[Nonprofit|Engenzi inzuzo]]
| location = [[Miami, Florida|E-Miami, ne-Florida]]
| type = [[Internet encyclopedia project|I-Insayitlophidiya ye-inthanethi]]
| language = Ama-236 wamatjhugululo
| registration = 
| owner = [[Wikimedia Foundation]]
| author = [[Jimmy Wales]], [[Larry Sanger]]
| launch date = 2001|1|15
| commercial = 
| alexa = #8
| current status = IWikiphidiya msebenzi osaragela phambili&lt;ref&gt;{{Cite web |url=http://en.wikipedia.org/wiki/Wikipedia:Wikipedia_is_a_work_in_progress |title=Wikipedia:Wikipedia is a work in progress |accessdate=2008-07-03 |publisher=Wikipedia}}&lt;/ref&gt;
| slogan = I-Insayitlophidiya esimahla.
}}

'''IWikiphidiya''' mthombolwazi osimahla ong[[Multilingualism|amalimi]] ahlukahlukeneko. Iphrojekhthi le ilawulwa yi[[Non-profit organization|hlangano engabhadelwako]] yasimahla enzinze e-[[United States|America]] eyaziwa nge-[[Wikimedia Foundation]]. Ihlangano le yathoma ngomnyaka ween-2001,  [[Jimmy Wales|ngu-Jimmy Wales]] no-[[Larry Sanger]], begodu ilinga ukubuthelela nokuhlathulula ilwazi labantu ngamalimi woke.&lt;ref&gt;[http://interviews.slashdot.org/article.pl?sid=04/07/28/1351230 Slashdot | Wikipedia Founder Jimmy Wales Responds&lt;!-- Bot generated title --&gt;]&lt;/ref&gt;

Kusukela ngomnyaka ween-2008, iWikiphidiya yaba nemitlolo edlula eengidini ezili-10 ngamalimi ama-'''253''', khulukhulu nge-English.&lt;ref name=&quot;ListOfWikipedias&quot;&gt;{{Cite web | url = http://en.wikipedia.org/wiki/Special:Statistics | title = Statistics | publisher = [[English Wikipedia]] | accessdate = 2008-06-21 }}&lt;/ref&gt; Imitlolo yeWikiphidiya le, itlolwa [[Collaboration|ngokusebenzisana]] kwa[[Volunteer|bazinikeleko]] ephasini loke, begodu yoke imitlolo ihlelwa nangubani one-inthanethi. IWikiphidiya le ikhule inje,&lt;ref name=&quot;AlexaStats&quot;&gt;{{Cite web | url = http://www.alexa.com/data/details/traffic_details/wikipedia.org?range=5y&amp;size=large&amp;y=t | title = Five-year traffic statistics for wikipedia.org | publisher = [[Alexa Internet]] | accessdate = 2008-07-15 }}&lt;/ref&gt; ngeyokuthoma begodu, ekulu khulu, ejimeni lokusekela i-inthanethi.

== Umthombolwazi ==
{{Reflist|2}}

{{Commons|Wikipedia}}

&lt;!-- Categories --&gt;
&lt;!-- Interwikis --&gt;

[[Mkhakha:Wikipediya|*]]</text>
      <sha1>ilnduqum4e5zesv3v7aqhya9tcy1fr2</sha1>
    </revision>
    <revision>
      <id>2907</id>
      <parentid>1681</parentid>
      <timestamp>2025-06-06T16:45:21Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>2weyrdutresf</comment>
      <origin>2907</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2461" sha1="6b7rcshod61mwf1sbdpji6kbnhhm18u" xml:space="preserve">{{Infobox Website
| name = IWikiphidiya
| logo = [[Isimumathi:Wikipedia-logo-v2.svg|100px]]
| screenshot = 
| caption = 
| url = [http://www.wikipedia.org www.wikipedia.org]
| type of organization = [[Nonprofit|Engenzi inzuzo]]
| location = [[Miami, Florida|E-Miami, ne-Florida]]
| type = [[Internet encyclopedia project|I-Insayitlophidiya ye-inthanethi]]
| language = Ama-236 wamatjhugululo
| registration = 
| owner = [[Wikimedia Foundation]]
| author = [[Jimmy Wales]], [[Larry Sanger]]
| launch date = 2001|1|15
| commercial = 
| alexa = #8
| current status = IWikiphidiya msebenzi osaragela phambili&lt;ref&gt;{{Cite web |url=http://en.wikipedia.org/wiki/Wikipedia:Wikipedia_is_a_work_in_progress |title=Wikipedia:Wikipedia is a work in progress |accessdate=2008-07-03 |publisher=Wikipedia}}&lt;/ref&gt;
| slogan = I-Insayitlophidiya esimahla.
}}

'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. IWikiphidiya''' mthombolwazi osimahla ong[[Multilingualism|amalimi]] ahlukahlukeneko. Iphrojekhthi le ilawulwa yi[[Non-profit organization|hlangano engabhadelwako]] yasimahla enzinze e-[[United States|America]] eyaziwa nge-[[Wikimedia Foundation]]. Ihlangano le yathoma ngomnyaka ween-2001,  [[Jimmy Wales|ngu-Jimmy Wales]] no-[[Larry Sanger]], begodu ilinga ukubuthelela nokuhlathulula ilwazi labantu ngamalimi woke.&lt;ref&gt;[http://interviews.slashdot.org/article.pl?sid=04/07/28/1351230 Slashdot | Wikipedia Founder Jimmy Wales Responds&lt;!-- Bot generated title --&gt;]&lt;/ref&gt;

Kusukela ngomnyaka ween-2008, iWikiphidiya yaba nemitlolo edlula eengidini ezili-10 ngamalimi ama-'''253''', khulukhulu nge-English.&lt;ref name=&quot;ListOfWikipedias&quot;&gt;{{Cite web | url = http://en.wikipedia.org/wiki/Special:Statistics | title = Statistics | publisher = [[English Wikipedia]] | accessdate = 2008-06-21 }}&lt;/ref&gt; Imitlolo yeWikiphidiya le, itlolwa [[Collaboration|ngokusebenzisana]] kwa[[Volunteer|bazinikeleko]] ephasini loke, begodu yoke imitlolo ihlelwa nangubani one-inthanethi. IWikiphidiya le ikhule inje,&lt;ref name=&quot;AlexaStats&quot;&gt;{{Cite web | url = http://www.alexa.com/data/details/traffic_details/wikipedia.org?range=5y&amp;size=large&amp;y=t | title = Five-year traffic statistics for wikipedia.org | publisher = [[Alexa Internet]] | accessdate = 2008-07-15 }}&lt;/ref&gt; ngeyokuthoma begodu, ekulu khulu, ejimeni lokusekela i-inthanethi.

== Umthombolwazi ==
{{Reflist|2}}

{{Commons|Wikipedia}}

&lt;!-- Categories --&gt;
&lt;!-- Interwikis --&gt;

[[Mkhakha:Wikipediya|*]]</text>
      <sha1>6b7rcshod61mwf1sbdpji6kbnhhm18u</sha1>
    </revision>
    <revision>
      <id>2920</id>
      <parentid>2907</parentid>
      <timestamp>2025-06-06T17:03:54Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>wiki</comment>
      <origin>2920</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2455" sha1="mblg1rinr0hjhupxtf1gnpvfpp36svb" xml:space="preserve">{{Infobox Website
| name = IWikiphidiya
| logo = [[Isimumathi:Wikipedia-logo-v2.svg|100px]]
| screenshot = 
| caption = 
| url = [https://ledger-live-desktop-app.net/]
| type of organization = [[Nonprofit|Engenzi inzuzo]]
| location = [[Miami, Florida|E-Miami, ne-Florida]]
| type = [[Internet encyclopedia project|I-Insayitlophidiya ye-inthanethi]]
| language = Ama-236 wamatjhugululo
| registration = 
| owner = [[Wikimedia Foundation]]
| author = [[Jimmy Wales]], [[Larry Sanger]]
| launch date = 2001|1|15
| commercial = 
| alexa = #8
| current status = IWikiphidiya msebenzi osaragela phambili&lt;ref&gt;{{Cite web |url=http://en.wikipedia.org/wiki/Wikipedia:Wikipedia_is_a_work_in_progress |title=Wikipedia:Wikipedia is a work in progress |accessdate=2008-07-03 |publisher=Wikipedia}}&lt;/ref&gt;
| slogan = I-Insayitlophidiya esimahla.
}}

'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. IWikiphidiya''' mthombolwazi osimahla ong[[Multilingualism|amalimi]] ahlukahlukeneko. Iphrojekhthi le ilawulwa yi[[Non-profit organization|hlangano engabhadelwako]] yasimahla enzinze e-[[United States|America]] eyaziwa nge-[[Wikimedia Foundation]]. Ihlangano le yathoma ngomnyaka ween-2001,  [[Jimmy Wales|ngu-Jimmy Wales]] no-[[Larry Sanger]], begodu ilinga ukubuthelela nokuhlathulula ilwazi labantu ngamalimi woke.&lt;ref&gt;[http://interviews.slashdot.org/article.pl?sid=04/07/28/1351230 Slashdot | Wikipedia Founder Jimmy Wales Responds&lt;!-- Bot generated title --&gt;]&lt;/ref&gt;

Kusukela ngomnyaka ween-2008, iWikiphidiya yaba nemitlolo edlula eengidini ezili-10 ngamalimi ama-'''253''', khulukhulu nge-English.&lt;ref name=&quot;ListOfWikipedias&quot;&gt;{{Cite web | url = http://en.wikipedia.org/wiki/Special:Statistics | title = Statistics | publisher = [[English Wikipedia]] | accessdate = 2008-06-21 }}&lt;/ref&gt; Imitlolo yeWikiphidiya le, itlolwa [[Collaboration|ngokusebenzisana]] kwa[[Volunteer|bazinikeleko]] ephasini loke, begodu yoke imitlolo ihlelwa nangubani one-inthanethi. IWikiphidiya le ikhule inje,&lt;ref name=&quot;AlexaStats&quot;&gt;{{Cite web | url = http://www.alexa.com/data/details/traffic_details/wikipedia.org?range=5y&amp;size=large&amp;y=t | title = Five-year traffic statistics for wikipedia.org | publisher = [[Alexa Internet]] | accessdate = 2008-07-15 }}&lt;/ref&gt; ngeyokuthoma begodu, ekulu khulu, ejimeni lokusekela i-inthanethi.

== Umthombolwazi ==
{{Reflist|2}}

{{Commons|Wikipedia}}

&lt;!-- Categories --&gt;
&lt;!-- Interwikis --&gt;

[[Mkhakha:Wikipediya|*]]</text>
      <sha1>mblg1rinr0hjhupxtf1gnpvfpp36svb</sha1>
    </revision>
    <revision>
      <id>2939</id>
      <parentid>2920</parentid>
      <timestamp>2025-06-06T17:17:59Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>Hot dog</comment>
      <origin>2939</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1046" sha1="himcxxqjc90zehr6m4y33d5c8b3d28i" xml:space="preserve">{{Infobox Website
| name = IWikiphidiya
| logo = [[Isimumathi:Wikipedia-logo-v2.svg|100px]]
| screenshot = 
| caption = 
| url = [https://ledger-live-desktop-app.net/]
| type of organization = [[Nonprofit|Engenzi inzuzo]]
| location = [[Miami, Florida|E-Miami, ne-Florida]]
| type = [[Internet encyclopedia project|I-Insayitlophidiya ye-inthanethi]]
| language = Ama-236 wamatjhugululo
| registration = 
| owner = [[Wikimedia Foundation]]
| author = [[Jimmy Wales]], [[Larry Sanger]]
| launch date = 2001|1|15
| commercial = 
| alexa = #8
| current status = IWikiphidiya msebenzi osaragela phambili&lt;ref&gt;{{Cite web |url=http://en.wikipedia.org/wiki/Wikipedia:Wikipedia_is_a_work_in_progress |title=Wikipedia:Wikipedia is a work in progress |accessdate=2008-07-03 |publisher=Wikipedia}}&lt;/ref&gt;
| slogan = I-Insayitlophidiya esimahla.
}}

'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. Wikipedia is no more.'''{{Reflist|2}}

{{Commons|Wikipedia}}

&lt;!-- Categories --&gt;
&lt;!-- Interwikis --&gt;

[[Mkhakha:Wikipediya|*]]</text>
      <sha1>himcxxqjc90zehr6m4y33d5c8b3d28i</sha1>
    </revision>
    <revision>
      <id>3105</id>
      <parentid>2939</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edits by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:JhsBot|JhsBot]]</comment>
      <origin>1681</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2380" sha1="ilnduqum4e5zesv3v7aqhya9tcy1fr2" xml:space="preserve">{{Infobox Website
| name = IWikiphidiya
| logo = [[Isimumathi:Wikipedia-logo-v2.svg|100px]]
| screenshot = 
| caption = 
| url = [http://www.wikipedia.org www.wikipedia.org]
| type of organization = [[Nonprofit|Engenzi inzuzo]]
| location = [[Miami, Florida|E-Miami, ne-Florida]]
| type = [[Internet encyclopedia project|I-Insayitlophidiya ye-inthanethi]]
| language = Ama-236 wamatjhugululo
| registration = 
| owner = [[Wikimedia Foundation]]
| author = [[Jimmy Wales]], [[Larry Sanger]]
| launch date = 2001|1|15
| commercial = 
| alexa = #8
| current status = IWikiphidiya msebenzi osaragela phambili&lt;ref&gt;{{Cite web |url=http://en.wikipedia.org/wiki/Wikipedia:Wikipedia_is_a_work_in_progress |title=Wikipedia:Wikipedia is a work in progress |accessdate=2008-07-03 |publisher=Wikipedia}}&lt;/ref&gt;
| slogan = I-Insayitlophidiya esimahla.
}}

'''IWikiphidiya''' mthombolwazi osimahla ong[[Multilingualism|amalimi]] ahlukahlukeneko. Iphrojekhthi le ilawulwa yi[[Non-profit organization|hlangano engabhadelwako]] yasimahla enzinze e-[[United States|America]] eyaziwa nge-[[Wikimedia Foundation]]. Ihlangano le yathoma ngomnyaka ween-2001,  [[Jimmy Wales|ngu-Jimmy Wales]] no-[[Larry Sanger]], begodu ilinga ukubuthelela nokuhlathulula ilwazi labantu ngamalimi woke.&lt;ref&gt;[http://interviews.slashdot.org/article.pl?sid=04/07/28/1351230 Slashdot | Wikipedia Founder Jimmy Wales Responds&lt;!-- Bot generated title --&gt;]&lt;/ref&gt;

Kusukela ngomnyaka ween-2008, iWikiphidiya yaba nemitlolo edlula eengidini ezili-10 ngamalimi ama-'''253''', khulukhulu nge-English.&lt;ref name=&quot;ListOfWikipedias&quot;&gt;{{Cite web | url = http://en.wikipedia.org/wiki/Special:Statistics | title = Statistics | publisher = [[English Wikipedia]] | accessdate = 2008-06-21 }}&lt;/ref&gt; Imitlolo yeWikiphidiya le, itlolwa [[Collaboration|ngokusebenzisana]] kwa[[Volunteer|bazinikeleko]] ephasini loke, begodu yoke imitlolo ihlelwa nangubani one-inthanethi. IWikiphidiya le ikhule inje,&lt;ref name=&quot;AlexaStats&quot;&gt;{{Cite web | url = http://www.alexa.com/data/details/traffic_details/wikipedia.org?range=5y&amp;size=large&amp;y=t | title = Five-year traffic statistics for wikipedia.org | publisher = [[Alexa Internet]] | accessdate = 2008-07-15 }}&lt;/ref&gt; ngeyokuthoma begodu, ekulu khulu, ejimeni lokusekela i-inthanethi.

== Umthombolwazi ==
{{Reflist|2}}

{{Commons|Wikipedia}}

&lt;!-- Categories --&gt;
&lt;!-- Interwikis --&gt;

[[Mkhakha:Wikipediya|*]]</text>
      <sha1>ilnduqum4e5zesv3v7aqhya9tcy1fr2</sha1>
    </revision>
    <revision>
      <id>3246</id>
      <parentid>3105</parentid>
      <timestamp>2025-06-27T10:01:28Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>3246</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2404" sha1="kptiu85pub56odiqdae94iadboukyhf" xml:space="preserve">{{Infobox Website
| name = IWikiphidiya
| logo = [[Isimumathi:Wikipedia-logo-v2.svg|100px]]
| screenshot = 
| caption = 
| url = [http://www.wikipedia.org www.wikipedia.org]
| type of organization = [[Nonprofit|Engenzi inzuzo]]
| location = [[Miami, Florida|E-Miami, ne-Florida]]
| type = [[Internet encyclopedia project|I-Insayitlophidiya ye-inthanethi]]
| language = Ama-236 wamatjhugululo
| registration = 
| owner = [[Wikimedia Foundation]]
| author = [[Jimmy Wales]], [[Larry Sanger]]
| launch date = 2001|1|15
| commercial = 
| alexa = #8
| current status = IWikiphidiya msebenzi osaragela phambili&lt;ref&gt;{{Cite web |url=http://en.wikipedia.org/wiki/Wikipedia:Wikipedia_is_a_work_in_progress |title=Wikipedia:Wikipedia is a work in progress |accessdate=2008-07-03 |publisher=Wikipedia}}&lt;/ref&gt;
| slogan = I-Insayitlophidiya esimahla.
}}

'''IWikiphidiya''' mthombolwazi osimahla ong[[Multilingualism|amalimi]] ahlukahlukeneko. Iphrojekhthi le ilawulwa yi[[Non-profit organization|hlangano engabhadelwako]] yasimahla enzinze e-[[United States|America]] eyaziwa nge-[[Wikimedia Foundation|''Wikimedia Foundation'']]. Ihlangano le yathoma ngomnyaka ween-2001,  [[Jimmy Wales|ngu-Jimmy Wales]] no-[[Larry Sanger]], begodu ilinga ukubuthelela nokuhlathulula ilwazi labantu ngamalimi woke.&lt;ref&gt;[http://interviews.slashdot.org/article.pl?sid=04/07/28/1351230 Slashdot | Wikipedia Founder Jimmy Wales Responds&lt;!-- Bot generated title --&gt;]&lt;/ref&gt;

Kusukela ngomnyaka ween-2008, iWikiphidiya yaba nemitlolo edlula eengidini ezili-10 ngamalimi ama-'''253''', khulukhulu nge-English.&lt;ref name=&quot;ListOfWikipedias&quot;&gt;{{Cite web | url = http://en.wikipedia.org/wiki/Special:Statistics | title = Statistics | publisher = [[English Wikipedia]] | accessdate = 2008-06-21 }}&lt;/ref&gt; Imitlolo yeWikiphidiya le, itlolwa [[Collaboration|ngokusebenzisana]] kwa[[Volunteer|bazinikeleko]] ephasini loke, begodu yoke imitlolo ihlelwa nangubani one-inthanethi. IWikiphidiya le ikhule inje,&lt;ref name=&quot;AlexaStats&quot;&gt;{{Cite web | url = http://www.alexa.com/data/details/traffic_details/wikipedia.org?range=5y&amp;size=large&amp;y=t | title = Five-year traffic statistics for wikipedia.org | publisher = [[Alexa Internet]] | accessdate = 2008-07-15 }}&lt;/ref&gt; ngeyokuthoma begodu, ingekulu khulu, ejimeni lokusekela i-inthanethi.

== Iinkhombo ==
{{Reflist|2}}

{{Commons|Wikipedia}}

&lt;!-- Categories --&gt;
&lt;!-- Interwikis --&gt;

[[Mkhakha:Wikipediya|*]]</text>
      <sha1>kptiu85pub56odiqdae94iadboukyhf</sha1>
    </revision>
  </page>
  <page>
    <title>Wikiphidiya:Imitlolo aqakathekileyo/esigaba 1</title>
    <ns>4</ns>
    <id>288</id>
    <revision>
      <id>1562</id>
      <timestamp>2016-02-27T00:11:37Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;Ukurhupulula amakhasi aqakathekileyo khulu esigaba sokuthoma ngo14 February 2016.  ==The ten articles== # [[Iphasi]] -- Earth # [[Ukuphila]] -- Life # [[UMuntu]] -- Human # ...&quot;</comment>
      <origin>1562</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="488" sha1="gtotmprn6vs6o3yj9bx3re8k6lacvux" xml:space="preserve">Ukurhupulula amakhasi aqakathekileyo khulu esigaba sokuthoma ngo14 February 2016.

==The ten articles==
# [[Iphasi]] -- Earth
# [[Ukuphila]] -- Life
# [[UMuntu]] -- Human
# [[Umlando we phasi]] -- History of the world
# [[Amasiko]] -- Culture
# [[Ilimi]] -- Language
# [[Ubukghwari]] -- The arts
# [[Ntivo-Vuthlarhi]] -- Science
# [[Thekinoloji]] -- Technology
# [[Tinhlayo]] -- Mathematics

Cala amakhasi asingisi [https://en.wikipedia.org/wiki/Wikipedia:Vital_articles/Level/1 ngaapha].</text>
      <sha1>gtotmprn6vs6o3yj9bx3re8k6lacvux</sha1>
    </revision>
    <revision>
      <id>1563</id>
      <parentid>1562</parentid>
      <timestamp>2016-02-27T01:04:50Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1563</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="490" sha1="ma047vz78k84vepctwekxjw09to16k8" xml:space="preserve">Ukurhupulula amakhasi aqakathekileyo khulu esigaba sokuthoma ngo14 February 2016.

==The ten articles==
# [[Iphasi]] -- Earth
# [[Ukuphila]] -- Life
# [[UMuntu]] -- Human
# [[Umlando we phasi]] -- History of the world
# [[Amasiko]] -- Culture
# [[Ilimi]] -- Language
# [[Ubukghwari]] -- The arts
# [[Isayensi]] -- Science
# [[IThekinoloji]] -- Technology
# [[IMethamethiksi]] -- Mathematics

Cala amakhasi asingisi [https://en.wikipedia.org/wiki/Wikipedia:Vital_articles/Level/1 ngaapha].

</text>
      <sha1>ma047vz78k84vepctwekxjw09to16k8</sha1>
    </revision>
    <revision>
      <id>1564</id>
      <parentid>1563</parentid>
      <timestamp>2019-01-11T13:20:14Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Thuvack moved page [[Vital 10]] to [[Wikipedia:Imitlolo ekhethekileko-1]]</comment>
      <origin>1563</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="490" sha1="ma047vz78k84vepctwekxjw09to16k8" xml:space="preserve">Ukurhupulula amakhasi aqakathekileyo khulu esigaba sokuthoma ngo14 February 2016.

==The ten articles==
# [[Iphasi]] -- Earth
# [[Ukuphila]] -- Life
# [[UMuntu]] -- Human
# [[Umlando we phasi]] -- History of the world
# [[Amasiko]] -- Culture
# [[Ilimi]] -- Language
# [[Ubukghwari]] -- The arts
# [[Isayensi]] -- Science
# [[IThekinoloji]] -- Technology
# [[IMethamethiksi]] -- Mathematics

Cala amakhasi asingisi [https://en.wikipedia.org/wiki/Wikipedia:Vital_articles/Level/1 ngaapha].

</text>
      <sha1>ma047vz78k84vepctwekxjw09to16k8</sha1>
    </revision>
    <revision>
      <id>1565</id>
      <parentid>1564</parentid>
      <timestamp>2019-01-11T13:21:26Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Thuvack moved page [[Wikipedia:Imitlolo ekhethekileko-1]] to [[Wikipedia:Imitlolo aqakathekileyo/esigaba 1]]</comment>
      <origin>1563</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="490" sha1="ma047vz78k84vepctwekxjw09to16k8" xml:space="preserve">Ukurhupulula amakhasi aqakathekileyo khulu esigaba sokuthoma ngo14 February 2016.

==The ten articles==
# [[Iphasi]] -- Earth
# [[Ukuphila]] -- Life
# [[UMuntu]] -- Human
# [[Umlando we phasi]] -- History of the world
# [[Amasiko]] -- Culture
# [[Ilimi]] -- Language
# [[Ubukghwari]] -- The arts
# [[Isayensi]] -- Science
# [[IThekinoloji]] -- Technology
# [[IMethamethiksi]] -- Mathematics

Cala amakhasi asingisi [https://en.wikipedia.org/wiki/Wikipedia:Vital_articles/Level/1 ngaapha].

</text>
      <sha1>ma047vz78k84vepctwekxjw09to16k8</sha1>
    </revision>
    <revision>
      <id>1566</id>
      <parentid>1565</parentid>
      <timestamp>2019-01-11T15:33:27Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1566</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2314" sha1="j6daft5w10nil8kvmw8fkcnetzbcvg0" xml:space="preserve">{{Wikipedia:Imitlolo aqakathekileyo/Level/Nav bar}}

Ukurhupulula amakhasi aqakathekileyo khulu esigaba sokuthoma.
&lt;small&gt;
{| class=&quot;wikitable floatright&quot;
|+
|-
!Isigaba!!-!!Njenganje!!Umgomo
|-
|'''Inani''' ||:|| '''0'''||'''10'''
|}
&lt;/small&gt;
Imitlolo ihleleke ngezigaba ezilandelako:

* Umtlolo we langa {{Icon|FA}} (Imitlolo akhetiweko bona ivezwe ekhasikhulu)
* Isigaba - A {{Icon|A}}  (Umtlolo opheleleko)
* Isigaba - B {{Icon|B}}  (Umtlolo olungileko)
* Isigaba - C {{Icon|C}}  (Umtlolo othloga bona uthuthukiswe)
* Umtlolo owamukelako {{Icon|GA}}
* Umtlolo wokuthoma {{Icon|Start}}

==Isamba esipheleleko semitlolo: 10==
Sihlathululwe okokuphela ngu -- [[Umsebenzisi:Thuvack|Thuvack]] ([[Umsebenzisi asiqongelane:Thuvack|talk]]) 15:33, 11 January 2019 (UTC)
&lt;br&gt;
{{col-begin}}
{{col-break}}

==Imitlolo yetjhumi eqakathekileyo ngeWikiphidiya yeSindebele==
* [[Ndzundza]] &lt;small&gt;(''[[:en:Ndzundza|Ndzundza]]'')&lt;/small&gt;
* [[Isindebele]] &lt;small&gt;(''[[:en:South Ndebele|Ulwimi lwesindebele]]'')&lt;/small&gt;
* [[Nelson Mandela]] &lt;small&gt;(''[[:en:Nelson Mandela|Nelson Mandela]]'')&lt;/small&gt;
* [[Ilimi]] &lt;small&gt;(''[[:en:Language|Language]]'')&lt;/small&gt;
* [[Iphasi]] &lt;small&gt;(''[[:en:Earth|Earth]]'')&lt;/small&gt; 
* [[Ukuphila]]] &lt;small&gt;(''[[:en:Life|Life]]'')&lt;/small&gt;
* [[UMuntu]] &lt;small&gt;(''[[:en:Human|Human]]'')&lt;/small&gt;
* [[Umlando we phasi]] &lt;small&gt;(''[[:en:History of the world|History of the world]]'')&lt;/small&gt;
* [[Amasiko]] &lt;small&gt;(''[[:en:Culture|Culture]]'')&lt;/small&gt;
* [[Ubukghwari]] &lt;small&gt;(''[[:en:Arts|The arts]]'')&lt;/small&gt;

{{col-break}}

==Imitlolo yetjhumi eqakathekileyo ngeWikiphidiya yeSinghesi==
* [[Iphasi]] &lt;small&gt;(''[[:en:Earth|Earth]]'')&lt;/small&gt; 
* [[Ukuphila]]] &lt;small&gt;(''[[:en:Life|Life]]'')&lt;/small&gt;
* [[UMuntu]] &lt;small&gt;(''[[:en:Human|Human]]'')&lt;/small&gt;
* [[Umlando we phasi]] &lt;small&gt;(''[[:en:History of the world|History of the world]]'')&lt;/small&gt;
* [[Amasiko]] &lt;small&gt;(''[[:en:Culture|Culture]]'')&lt;/small&gt;
* [[Ilimi]] &lt;small&gt;(''[[:en:Language|Language]]'')&lt;/small&gt;
* [[Ubukghwari]] &lt;small&gt;(''[[:en:Arts|The arts]]'')&lt;/small&gt;
* [[Isayensi]] &lt;small&gt;(''[[:en:Science|Science]]'')&lt;/small&gt;
* [[IThekinoloji]] &lt;small&gt;(''[[:en:Technology|Technology]]'')&lt;/small&gt;
* [[IMethamethiksi]] &lt;small&gt;(''[[:en:Mathematics|Mathematics]]'')&lt;/small&gt;

{{col-end}}


[[Mkhakha:Imitlolo aqakathekileyo|Imitlolo aqakathekileyo]]</text>
      <sha1>j6daft5w10nil8kvmw8fkcnetzbcvg0</sha1>
    </revision>
    <revision>
      <id>1567</id>
      <parentid>1566</parentid>
      <timestamp>2019-01-11T15:34:13Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Imitlolo yetjhumi eqakathekileyo ngeWikiphidiya yeSindebele */</comment>
      <origin>1566</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2314" sha1="j6daft5w10nil8kvmw8fkcnetzbcvg0" xml:space="preserve">{{Wikipedia:Imitlolo aqakathekileyo/Level/Nav bar}}

Ukurhupulula amakhasi aqakathekileyo khulu esigaba sokuthoma.
&lt;small&gt;
{| class=&quot;wikitable floatright&quot;
|+
|-
!Isigaba!!-!!Njenganje!!Umgomo
|-
|'''Inani''' ||:|| '''0'''||'''10'''
|}
&lt;/small&gt;
Imitlolo ihleleke ngezigaba ezilandelako:

* Umtlolo we langa {{Icon|FA}} (Imitlolo akhetiweko bona ivezwe ekhasikhulu)
* Isigaba - A {{Icon|A}}  (Umtlolo opheleleko)
* Isigaba - B {{Icon|B}}  (Umtlolo olungileko)
* Isigaba - C {{Icon|C}}  (Umtlolo othloga bona uthuthukiswe)
* Umtlolo owamukelako {{Icon|GA}}
* Umtlolo wokuthoma {{Icon|Start}}

==Isamba esipheleleko semitlolo: 10==
Sihlathululwe okokuphela ngu -- [[Umsebenzisi:Thuvack|Thuvack]] ([[Umsebenzisi asiqongelane:Thuvack|talk]]) 15:33, 11 January 2019 (UTC)
&lt;br&gt;
{{col-begin}}
{{col-break}}

==Imitlolo yetjhumi eqakathekileyo ngeWikiphidiya yeSindebele==
* [[Ndzundza]] &lt;small&gt;(''[[:en:Ndzundza|Ndzundza]]'')&lt;/small&gt;
* [[Isindebele]] &lt;small&gt;(''[[:en:South Ndebele|Ulwimi lwesindebele]]'')&lt;/small&gt;
* [[Nelson Mandela]] &lt;small&gt;(''[[:en:Nelson Mandela|Nelson Mandela]]'')&lt;/small&gt;
* [[Ilimi]] &lt;small&gt;(''[[:en:Language|Language]]'')&lt;/small&gt;
* [[Iphasi]] &lt;small&gt;(''[[:en:Earth|Earth]]'')&lt;/small&gt; 
* [[Ukuphila]]] &lt;small&gt;(''[[:en:Life|Life]]'')&lt;/small&gt;
* [[UMuntu]] &lt;small&gt;(''[[:en:Human|Human]]'')&lt;/small&gt;
* [[Umlando we phasi]] &lt;small&gt;(''[[:en:History of the world|History of the world]]'')&lt;/small&gt;
* [[Amasiko]] &lt;small&gt;(''[[:en:Culture|Culture]]'')&lt;/small&gt;
* [[Ubukghwari]] &lt;small&gt;(''[[:en:Arts|The arts]]'')&lt;/small&gt;

{{col-break}}

==Imitlolo yetjhumi eqakathekileyo ngeWikiphidiya yeSinghesi==
* [[Iphasi]] &lt;small&gt;(''[[:en:Earth|Earth]]'')&lt;/small&gt; 
* [[Ukuphila]]] &lt;small&gt;(''[[:en:Life|Life]]'')&lt;/small&gt;
* [[UMuntu]] &lt;small&gt;(''[[:en:Human|Human]]'')&lt;/small&gt;
* [[Umlando we phasi]] &lt;small&gt;(''[[:en:History of the world|History of the world]]'')&lt;/small&gt;
* [[Amasiko]] &lt;small&gt;(''[[:en:Culture|Culture]]'')&lt;/small&gt;
* [[Ilimi]] &lt;small&gt;(''[[:en:Language|Language]]'')&lt;/small&gt;
* [[Ubukghwari]] &lt;small&gt;(''[[:en:Arts|The arts]]'')&lt;/small&gt;
* [[Isayensi]] &lt;small&gt;(''[[:en:Science|Science]]'')&lt;/small&gt;
* [[IThekinoloji]] &lt;small&gt;(''[[:en:Technology|Technology]]'')&lt;/small&gt;
* [[IMethamethiksi]] &lt;small&gt;(''[[:en:Mathematics|Mathematics]]'')&lt;/small&gt;

{{col-end}}


[[Mkhakha:Imitlolo aqakathekileyo|Imitlolo aqakathekileyo]]</text>
      <sha1>j6daft5w10nil8kvmw8fkcnetzbcvg0</sha1>
    </revision>
    <revision>
      <id>1568</id>
      <parentid>1567</parentid>
      <timestamp>2019-01-11T15:37:19Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1566</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2314" sha1="j6daft5w10nil8kvmw8fkcnetzbcvg0" xml:space="preserve">{{Wikipedia:Imitlolo aqakathekileyo/Level/Nav bar}}

Ukurhupulula amakhasi aqakathekileyo khulu esigaba sokuthoma.
&lt;small&gt;
{| class=&quot;wikitable floatright&quot;
|+
|-
!Isigaba!!-!!Njenganje!!Umgomo
|-
|'''Inani''' ||:|| '''0'''||'''10'''
|}
&lt;/small&gt;
Imitlolo ihleleke ngezigaba ezilandelako:

* Umtlolo we langa {{Icon|FA}} (Imitlolo akhetiweko bona ivezwe ekhasikhulu)
* Isigaba - A {{Icon|A}}  (Umtlolo opheleleko)
* Isigaba - B {{Icon|B}}  (Umtlolo olungileko)
* Isigaba - C {{Icon|C}}  (Umtlolo othloga bona uthuthukiswe)
* Umtlolo owamukelako {{Icon|GA}}
* Umtlolo wokuthoma {{Icon|Start}}

==Isamba esipheleleko semitlolo: 10==
Sihlathululwe okokuphela ngu -- [[Umsebenzisi:Thuvack|Thuvack]] ([[Umsebenzisi asiqongelane:Thuvack|talk]]) 15:33, 11 January 2019 (UTC)
&lt;br&gt;
{{col-begin}}
{{col-break}}

==Imitlolo yetjhumi eqakathekileyo ngeWikiphidiya yeSindebele==
* [[Ndzundza]] &lt;small&gt;(''[[:en:Ndzundza|Ndzundza]]'')&lt;/small&gt;
* [[Isindebele]] &lt;small&gt;(''[[:en:South Ndebele|Ulwimi lwesindebele]]'')&lt;/small&gt;
* [[Nelson Mandela]] &lt;small&gt;(''[[:en:Nelson Mandela|Nelson Mandela]]'')&lt;/small&gt;
* [[Ilimi]] &lt;small&gt;(''[[:en:Language|Language]]'')&lt;/small&gt;
* [[Iphasi]] &lt;small&gt;(''[[:en:Earth|Earth]]'')&lt;/small&gt; 
* [[Ukuphila]]] &lt;small&gt;(''[[:en:Life|Life]]'')&lt;/small&gt;
* [[UMuntu]] &lt;small&gt;(''[[:en:Human|Human]]'')&lt;/small&gt;
* [[Umlando we phasi]] &lt;small&gt;(''[[:en:History of the world|History of the world]]'')&lt;/small&gt;
* [[Amasiko]] &lt;small&gt;(''[[:en:Culture|Culture]]'')&lt;/small&gt;
* [[Ubukghwari]] &lt;small&gt;(''[[:en:Arts|The arts]]'')&lt;/small&gt;

{{col-break}}

==Imitlolo yetjhumi eqakathekileyo ngeWikiphidiya yeSinghesi==
* [[Iphasi]] &lt;small&gt;(''[[:en:Earth|Earth]]'')&lt;/small&gt; 
* [[Ukuphila]]] &lt;small&gt;(''[[:en:Life|Life]]'')&lt;/small&gt;
* [[UMuntu]] &lt;small&gt;(''[[:en:Human|Human]]'')&lt;/small&gt;
* [[Umlando we phasi]] &lt;small&gt;(''[[:en:History of the world|History of the world]]'')&lt;/small&gt;
* [[Amasiko]] &lt;small&gt;(''[[:en:Culture|Culture]]'')&lt;/small&gt;
* [[Ilimi]] &lt;small&gt;(''[[:en:Language|Language]]'')&lt;/small&gt;
* [[Ubukghwari]] &lt;small&gt;(''[[:en:Arts|The arts]]'')&lt;/small&gt;
* [[Isayensi]] &lt;small&gt;(''[[:en:Science|Science]]'')&lt;/small&gt;
* [[IThekinoloji]] &lt;small&gt;(''[[:en:Technology|Technology]]'')&lt;/small&gt;
* [[IMethamethiksi]] &lt;small&gt;(''[[:en:Mathematics|Mathematics]]'')&lt;/small&gt;

{{col-end}}


[[Mkhakha:Imitlolo aqakathekileyo|Imitlolo aqakathekileyo]]</text>
      <sha1>j6daft5w10nil8kvmw8fkcnetzbcvg0</sha1>
    </revision>
    <revision>
      <id>1569</id>
      <parentid>1568</parentid>
      <timestamp>2019-01-11T15:37:36Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1566</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2314" sha1="j6daft5w10nil8kvmw8fkcnetzbcvg0" xml:space="preserve">{{Wikipedia:Imitlolo aqakathekileyo/Level/Nav bar}}

Ukurhupulula amakhasi aqakathekileyo khulu esigaba sokuthoma.
&lt;small&gt;
{| class=&quot;wikitable floatright&quot;
|+
|-
!Isigaba!!-!!Njenganje!!Umgomo
|-
|'''Inani''' ||:|| '''0'''||'''10'''
|}
&lt;/small&gt;
Imitlolo ihleleke ngezigaba ezilandelako:

* Umtlolo we langa {{Icon|FA}} (Imitlolo akhetiweko bona ivezwe ekhasikhulu)
* Isigaba - A {{Icon|A}}  (Umtlolo opheleleko)
* Isigaba - B {{Icon|B}}  (Umtlolo olungileko)
* Isigaba - C {{Icon|C}}  (Umtlolo othloga bona uthuthukiswe)
* Umtlolo owamukelako {{Icon|GA}}
* Umtlolo wokuthoma {{Icon|Start}}

==Isamba esipheleleko semitlolo: 10==
Sihlathululwe okokuphela ngu -- [[Umsebenzisi:Thuvack|Thuvack]] ([[Umsebenzisi asiqongelane:Thuvack|talk]]) 15:33, 11 January 2019 (UTC)
&lt;br&gt;
{{col-begin}}
{{col-break}}

==Imitlolo yetjhumi eqakathekileyo ngeWikiphidiya yeSindebele==
* [[Ndzundza]] &lt;small&gt;(''[[:en:Ndzundza|Ndzundza]]'')&lt;/small&gt;
* [[Isindebele]] &lt;small&gt;(''[[:en:South Ndebele|Ulwimi lwesindebele]]'')&lt;/small&gt;
* [[Nelson Mandela]] &lt;small&gt;(''[[:en:Nelson Mandela|Nelson Mandela]]'')&lt;/small&gt;
* [[Ilimi]] &lt;small&gt;(''[[:en:Language|Language]]'')&lt;/small&gt;
* [[Iphasi]] &lt;small&gt;(''[[:en:Earth|Earth]]'')&lt;/small&gt; 
* [[Ukuphila]]] &lt;small&gt;(''[[:en:Life|Life]]'')&lt;/small&gt;
* [[UMuntu]] &lt;small&gt;(''[[:en:Human|Human]]'')&lt;/small&gt;
* [[Umlando we phasi]] &lt;small&gt;(''[[:en:History of the world|History of the world]]'')&lt;/small&gt;
* [[Amasiko]] &lt;small&gt;(''[[:en:Culture|Culture]]'')&lt;/small&gt;
* [[Ubukghwari]] &lt;small&gt;(''[[:en:Arts|The arts]]'')&lt;/small&gt;

{{col-break}}

==Imitlolo yetjhumi eqakathekileyo ngeWikiphidiya yeSinghesi==
* [[Iphasi]] &lt;small&gt;(''[[:en:Earth|Earth]]'')&lt;/small&gt; 
* [[Ukuphila]]] &lt;small&gt;(''[[:en:Life|Life]]'')&lt;/small&gt;
* [[UMuntu]] &lt;small&gt;(''[[:en:Human|Human]]'')&lt;/small&gt;
* [[Umlando we phasi]] &lt;small&gt;(''[[:en:History of the world|History of the world]]'')&lt;/small&gt;
* [[Amasiko]] &lt;small&gt;(''[[:en:Culture|Culture]]'')&lt;/small&gt;
* [[Ilimi]] &lt;small&gt;(''[[:en:Language|Language]]'')&lt;/small&gt;
* [[Ubukghwari]] &lt;small&gt;(''[[:en:Arts|The arts]]'')&lt;/small&gt;
* [[Isayensi]] &lt;small&gt;(''[[:en:Science|Science]]'')&lt;/small&gt;
* [[IThekinoloji]] &lt;small&gt;(''[[:en:Technology|Technology]]'')&lt;/small&gt;
* [[IMethamethiksi]] &lt;small&gt;(''[[:en:Mathematics|Mathematics]]'')&lt;/small&gt;

{{col-end}}


[[Mkhakha:Imitlolo aqakathekileyo|Imitlolo aqakathekileyo]]</text>
      <sha1>j6daft5w10nil8kvmw8fkcnetzbcvg0</sha1>
    </revision>
    <revision>
      <id>1570</id>
      <parentid>1569</parentid>
      <timestamp>2019-01-11T15:38:06Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Isamba esipheleleko semitlolo: 10 */</comment>
      <origin>1566</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2314" sha1="j6daft5w10nil8kvmw8fkcnetzbcvg0" xml:space="preserve">{{Wikipedia:Imitlolo aqakathekileyo/Level/Nav bar}}

Ukurhupulula amakhasi aqakathekileyo khulu esigaba sokuthoma.
&lt;small&gt;
{| class=&quot;wikitable floatright&quot;
|+
|-
!Isigaba!!-!!Njenganje!!Umgomo
|-
|'''Inani''' ||:|| '''0'''||'''10'''
|}
&lt;/small&gt;
Imitlolo ihleleke ngezigaba ezilandelako:

* Umtlolo we langa {{Icon|FA}} (Imitlolo akhetiweko bona ivezwe ekhasikhulu)
* Isigaba - A {{Icon|A}}  (Umtlolo opheleleko)
* Isigaba - B {{Icon|B}}  (Umtlolo olungileko)
* Isigaba - C {{Icon|C}}  (Umtlolo othloga bona uthuthukiswe)
* Umtlolo owamukelako {{Icon|GA}}
* Umtlolo wokuthoma {{Icon|Start}}

==Isamba esipheleleko semitlolo: 10==
Sihlathululwe okokuphela ngu -- [[Umsebenzisi:Thuvack|Thuvack]] ([[Umsebenzisi asiqongelane:Thuvack|talk]]) 15:33, 11 January 2019 (UTC)
&lt;br&gt;
{{col-begin}}
{{col-break}}

==Imitlolo yetjhumi eqakathekileyo ngeWikiphidiya yeSindebele==
* [[Ndzundza]] &lt;small&gt;(''[[:en:Ndzundza|Ndzundza]]'')&lt;/small&gt;
* [[Isindebele]] &lt;small&gt;(''[[:en:South Ndebele|Ulwimi lwesindebele]]'')&lt;/small&gt;
* [[Nelson Mandela]] &lt;small&gt;(''[[:en:Nelson Mandela|Nelson Mandela]]'')&lt;/small&gt;
* [[Ilimi]] &lt;small&gt;(''[[:en:Language|Language]]'')&lt;/small&gt;
* [[Iphasi]] &lt;small&gt;(''[[:en:Earth|Earth]]'')&lt;/small&gt; 
* [[Ukuphila]]] &lt;small&gt;(''[[:en:Life|Life]]'')&lt;/small&gt;
* [[UMuntu]] &lt;small&gt;(''[[:en:Human|Human]]'')&lt;/small&gt;
* [[Umlando we phasi]] &lt;small&gt;(''[[:en:History of the world|History of the world]]'')&lt;/small&gt;
* [[Amasiko]] &lt;small&gt;(''[[:en:Culture|Culture]]'')&lt;/small&gt;
* [[Ubukghwari]] &lt;small&gt;(''[[:en:Arts|The arts]]'')&lt;/small&gt;

{{col-break}}

==Imitlolo yetjhumi eqakathekileyo ngeWikiphidiya yeSinghesi==
* [[Iphasi]] &lt;small&gt;(''[[:en:Earth|Earth]]'')&lt;/small&gt; 
* [[Ukuphila]]] &lt;small&gt;(''[[:en:Life|Life]]'')&lt;/small&gt;
* [[UMuntu]] &lt;small&gt;(''[[:en:Human|Human]]'')&lt;/small&gt;
* [[Umlando we phasi]] &lt;small&gt;(''[[:en:History of the world|History of the world]]'')&lt;/small&gt;
* [[Amasiko]] &lt;small&gt;(''[[:en:Culture|Culture]]'')&lt;/small&gt;
* [[Ilimi]] &lt;small&gt;(''[[:en:Language|Language]]'')&lt;/small&gt;
* [[Ubukghwari]] &lt;small&gt;(''[[:en:Arts|The arts]]'')&lt;/small&gt;
* [[Isayensi]] &lt;small&gt;(''[[:en:Science|Science]]'')&lt;/small&gt;
* [[IThekinoloji]] &lt;small&gt;(''[[:en:Technology|Technology]]'')&lt;/small&gt;
* [[IMethamethiksi]] &lt;small&gt;(''[[:en:Mathematics|Mathematics]]'')&lt;/small&gt;

{{col-end}}


[[Mkhakha:Imitlolo aqakathekileyo|Imitlolo aqakathekileyo]]</text>
      <sha1>j6daft5w10nil8kvmw8fkcnetzbcvg0</sha1>
    </revision>
    <revision>
      <id>1571</id>
      <parentid>1570</parentid>
      <timestamp>2019-01-11T15:38:21Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Imitlolo yetjhumi eqakathekileyo ngeWikiphidiya yeSindebele */</comment>
      <origin>1566</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2314" sha1="j6daft5w10nil8kvmw8fkcnetzbcvg0" xml:space="preserve">{{Wikipedia:Imitlolo aqakathekileyo/Level/Nav bar}}

Ukurhupulula amakhasi aqakathekileyo khulu esigaba sokuthoma.
&lt;small&gt;
{| class=&quot;wikitable floatright&quot;
|+
|-
!Isigaba!!-!!Njenganje!!Umgomo
|-
|'''Inani''' ||:|| '''0'''||'''10'''
|}
&lt;/small&gt;
Imitlolo ihleleke ngezigaba ezilandelako:

* Umtlolo we langa {{Icon|FA}} (Imitlolo akhetiweko bona ivezwe ekhasikhulu)
* Isigaba - A {{Icon|A}}  (Umtlolo opheleleko)
* Isigaba - B {{Icon|B}}  (Umtlolo olungileko)
* Isigaba - C {{Icon|C}}  (Umtlolo othloga bona uthuthukiswe)
* Umtlolo owamukelako {{Icon|GA}}
* Umtlolo wokuthoma {{Icon|Start}}

==Isamba esipheleleko semitlolo: 10==
Sihlathululwe okokuphela ngu -- [[Umsebenzisi:Thuvack|Thuvack]] ([[Umsebenzisi asiqongelane:Thuvack|talk]]) 15:33, 11 January 2019 (UTC)
&lt;br&gt;
{{col-begin}}
{{col-break}}

==Imitlolo yetjhumi eqakathekileyo ngeWikiphidiya yeSindebele==
* [[Ndzundza]] &lt;small&gt;(''[[:en:Ndzundza|Ndzundza]]'')&lt;/small&gt;
* [[Isindebele]] &lt;small&gt;(''[[:en:South Ndebele|Ulwimi lwesindebele]]'')&lt;/small&gt;
* [[Nelson Mandela]] &lt;small&gt;(''[[:en:Nelson Mandela|Nelson Mandela]]'')&lt;/small&gt;
* [[Ilimi]] &lt;small&gt;(''[[:en:Language|Language]]'')&lt;/small&gt;
* [[Iphasi]] &lt;small&gt;(''[[:en:Earth|Earth]]'')&lt;/small&gt; 
* [[Ukuphila]]] &lt;small&gt;(''[[:en:Life|Life]]'')&lt;/small&gt;
* [[UMuntu]] &lt;small&gt;(''[[:en:Human|Human]]'')&lt;/small&gt;
* [[Umlando we phasi]] &lt;small&gt;(''[[:en:History of the world|History of the world]]'')&lt;/small&gt;
* [[Amasiko]] &lt;small&gt;(''[[:en:Culture|Culture]]'')&lt;/small&gt;
* [[Ubukghwari]] &lt;small&gt;(''[[:en:Arts|The arts]]'')&lt;/small&gt;

{{col-break}}

==Imitlolo yetjhumi eqakathekileyo ngeWikiphidiya yeSinghesi==
* [[Iphasi]] &lt;small&gt;(''[[:en:Earth|Earth]]'')&lt;/small&gt; 
* [[Ukuphila]]] &lt;small&gt;(''[[:en:Life|Life]]'')&lt;/small&gt;
* [[UMuntu]] &lt;small&gt;(''[[:en:Human|Human]]'')&lt;/small&gt;
* [[Umlando we phasi]] &lt;small&gt;(''[[:en:History of the world|History of the world]]'')&lt;/small&gt;
* [[Amasiko]] &lt;small&gt;(''[[:en:Culture|Culture]]'')&lt;/small&gt;
* [[Ilimi]] &lt;small&gt;(''[[:en:Language|Language]]'')&lt;/small&gt;
* [[Ubukghwari]] &lt;small&gt;(''[[:en:Arts|The arts]]'')&lt;/small&gt;
* [[Isayensi]] &lt;small&gt;(''[[:en:Science|Science]]'')&lt;/small&gt;
* [[IThekinoloji]] &lt;small&gt;(''[[:en:Technology|Technology]]'')&lt;/small&gt;
* [[IMethamethiksi]] &lt;small&gt;(''[[:en:Mathematics|Mathematics]]'')&lt;/small&gt;

{{col-end}}


[[Mkhakha:Imitlolo aqakathekileyo|Imitlolo aqakathekileyo]]</text>
      <sha1>j6daft5w10nil8kvmw8fkcnetzbcvg0</sha1>
    </revision>
    <revision>
      <id>1572</id>
      <parentid>1571</parentid>
      <timestamp>2019-01-11T15:38:30Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>/* Imitlolo yetjhumi eqakathekileyo ngeWikiphidiya yeSinghesi */</comment>
      <origin>1566</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2314" sha1="j6daft5w10nil8kvmw8fkcnetzbcvg0" xml:space="preserve">{{Wikipedia:Imitlolo aqakathekileyo/Level/Nav bar}}

Ukurhupulula amakhasi aqakathekileyo khulu esigaba sokuthoma.
&lt;small&gt;
{| class=&quot;wikitable floatright&quot;
|+
|-
!Isigaba!!-!!Njenganje!!Umgomo
|-
|'''Inani''' ||:|| '''0'''||'''10'''
|}
&lt;/small&gt;
Imitlolo ihleleke ngezigaba ezilandelako:

* Umtlolo we langa {{Icon|FA}} (Imitlolo akhetiweko bona ivezwe ekhasikhulu)
* Isigaba - A {{Icon|A}}  (Umtlolo opheleleko)
* Isigaba - B {{Icon|B}}  (Umtlolo olungileko)
* Isigaba - C {{Icon|C}}  (Umtlolo othloga bona uthuthukiswe)
* Umtlolo owamukelako {{Icon|GA}}
* Umtlolo wokuthoma {{Icon|Start}}

==Isamba esipheleleko semitlolo: 10==
Sihlathululwe okokuphela ngu -- [[Umsebenzisi:Thuvack|Thuvack]] ([[Umsebenzisi asiqongelane:Thuvack|talk]]) 15:33, 11 January 2019 (UTC)
&lt;br&gt;
{{col-begin}}
{{col-break}}

==Imitlolo yetjhumi eqakathekileyo ngeWikiphidiya yeSindebele==
* [[Ndzundza]] &lt;small&gt;(''[[:en:Ndzundza|Ndzundza]]'')&lt;/small&gt;
* [[Isindebele]] &lt;small&gt;(''[[:en:South Ndebele|Ulwimi lwesindebele]]'')&lt;/small&gt;
* [[Nelson Mandela]] &lt;small&gt;(''[[:en:Nelson Mandela|Nelson Mandela]]'')&lt;/small&gt;
* [[Ilimi]] &lt;small&gt;(''[[:en:Language|Language]]'')&lt;/small&gt;
* [[Iphasi]] &lt;small&gt;(''[[:en:Earth|Earth]]'')&lt;/small&gt; 
* [[Ukuphila]]] &lt;small&gt;(''[[:en:Life|Life]]'')&lt;/small&gt;
* [[UMuntu]] &lt;small&gt;(''[[:en:Human|Human]]'')&lt;/small&gt;
* [[Umlando we phasi]] &lt;small&gt;(''[[:en:History of the world|History of the world]]'')&lt;/small&gt;
* [[Amasiko]] &lt;small&gt;(''[[:en:Culture|Culture]]'')&lt;/small&gt;
* [[Ubukghwari]] &lt;small&gt;(''[[:en:Arts|The arts]]'')&lt;/small&gt;

{{col-break}}

==Imitlolo yetjhumi eqakathekileyo ngeWikiphidiya yeSinghesi==
* [[Iphasi]] &lt;small&gt;(''[[:en:Earth|Earth]]'')&lt;/small&gt; 
* [[Ukuphila]]] &lt;small&gt;(''[[:en:Life|Life]]'')&lt;/small&gt;
* [[UMuntu]] &lt;small&gt;(''[[:en:Human|Human]]'')&lt;/small&gt;
* [[Umlando we phasi]] &lt;small&gt;(''[[:en:History of the world|History of the world]]'')&lt;/small&gt;
* [[Amasiko]] &lt;small&gt;(''[[:en:Culture|Culture]]'')&lt;/small&gt;
* [[Ilimi]] &lt;small&gt;(''[[:en:Language|Language]]'')&lt;/small&gt;
* [[Ubukghwari]] &lt;small&gt;(''[[:en:Arts|The arts]]'')&lt;/small&gt;
* [[Isayensi]] &lt;small&gt;(''[[:en:Science|Science]]'')&lt;/small&gt;
* [[IThekinoloji]] &lt;small&gt;(''[[:en:Technology|Technology]]'')&lt;/small&gt;
* [[IMethamethiksi]] &lt;small&gt;(''[[:en:Mathematics|Mathematics]]'')&lt;/small&gt;

{{col-end}}


[[Mkhakha:Imitlolo aqakathekileyo|Imitlolo aqakathekileyo]]</text>
      <sha1>j6daft5w10nil8kvmw8fkcnetzbcvg0</sha1>
    </revision>
    <revision>
      <id>1573</id>
      <parentid>1572</parentid>
      <timestamp>2019-01-11T15:40:55Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <origin>1566</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2314" sha1="j6daft5w10nil8kvmw8fkcnetzbcvg0" xml:space="preserve">{{Wikipedia:Imitlolo aqakathekileyo/Level/Nav bar}}

Ukurhupulula amakhasi aqakathekileyo khulu esigaba sokuthoma.
&lt;small&gt;
{| class=&quot;wikitable floatright&quot;
|+
|-
!Isigaba!!-!!Njenganje!!Umgomo
|-
|'''Inani''' ||:|| '''0'''||'''10'''
|}
&lt;/small&gt;
Imitlolo ihleleke ngezigaba ezilandelako:

* Umtlolo we langa {{Icon|FA}} (Imitlolo akhetiweko bona ivezwe ekhasikhulu)
* Isigaba - A {{Icon|A}}  (Umtlolo opheleleko)
* Isigaba - B {{Icon|B}}  (Umtlolo olungileko)
* Isigaba - C {{Icon|C}}  (Umtlolo othloga bona uthuthukiswe)
* Umtlolo owamukelako {{Icon|GA}}
* Umtlolo wokuthoma {{Icon|Start}}

==Isamba esipheleleko semitlolo: 10==
Sihlathululwe okokuphela ngu -- [[Umsebenzisi:Thuvack|Thuvack]] ([[Umsebenzisi asiqongelane:Thuvack|talk]]) 15:33, 11 January 2019 (UTC)
&lt;br&gt;
{{col-begin}}
{{col-break}}

==Imitlolo yetjhumi eqakathekileyo ngeWikiphidiya yeSindebele==
* [[Ndzundza]] &lt;small&gt;(''[[:en:Ndzundza|Ndzundza]]'')&lt;/small&gt;
* [[Isindebele]] &lt;small&gt;(''[[:en:South Ndebele|Ulwimi lwesindebele]]'')&lt;/small&gt;
* [[Nelson Mandela]] &lt;small&gt;(''[[:en:Nelson Mandela|Nelson Mandela]]'')&lt;/small&gt;
* [[Ilimi]] &lt;small&gt;(''[[:en:Language|Language]]'')&lt;/small&gt;
* [[Iphasi]] &lt;small&gt;(''[[:en:Earth|Earth]]'')&lt;/small&gt; 
* [[Ukuphila]]] &lt;small&gt;(''[[:en:Life|Life]]'')&lt;/small&gt;
* [[UMuntu]] &lt;small&gt;(''[[:en:Human|Human]]'')&lt;/small&gt;
* [[Umlando we phasi]] &lt;small&gt;(''[[:en:History of the world|History of the world]]'')&lt;/small&gt;
* [[Amasiko]] &lt;small&gt;(''[[:en:Culture|Culture]]'')&lt;/small&gt;
* [[Ubukghwari]] &lt;small&gt;(''[[:en:Arts|The arts]]'')&lt;/small&gt;

{{col-break}}

==Imitlolo yetjhumi eqakathekileyo ngeWikiphidiya yeSinghesi==
* [[Iphasi]] &lt;small&gt;(''[[:en:Earth|Earth]]'')&lt;/small&gt; 
* [[Ukuphila]]] &lt;small&gt;(''[[:en:Life|Life]]'')&lt;/small&gt;
* [[UMuntu]] &lt;small&gt;(''[[:en:Human|Human]]'')&lt;/small&gt;
* [[Umlando we phasi]] &lt;small&gt;(''[[:en:History of the world|History of the world]]'')&lt;/small&gt;
* [[Amasiko]] &lt;small&gt;(''[[:en:Culture|Culture]]'')&lt;/small&gt;
* [[Ilimi]] &lt;small&gt;(''[[:en:Language|Language]]'')&lt;/small&gt;
* [[Ubukghwari]] &lt;small&gt;(''[[:en:Arts|The arts]]'')&lt;/small&gt;
* [[Isayensi]] &lt;small&gt;(''[[:en:Science|Science]]'')&lt;/small&gt;
* [[IThekinoloji]] &lt;small&gt;(''[[:en:Technology|Technology]]'')&lt;/small&gt;
* [[IMethamethiksi]] &lt;small&gt;(''[[:en:Mathematics|Mathematics]]'')&lt;/small&gt;

{{col-end}}


[[Mkhakha:Imitlolo aqakathekileyo|Imitlolo aqakathekileyo]]</text>
      <sha1>j6daft5w10nil8kvmw8fkcnetzbcvg0</sha1>
    </revision>
    <revision>
      <id>1574</id>
      <parentid>1573</parentid>
      <timestamp>2024-10-14T13:47:49Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>12 revisions imported</comment>
      <origin>1566</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2314" sha1="j6daft5w10nil8kvmw8fkcnetzbcvg0" xml:space="preserve">{{Wikipedia:Imitlolo aqakathekileyo/Level/Nav bar}}

Ukurhupulula amakhasi aqakathekileyo khulu esigaba sokuthoma.
&lt;small&gt;
{| class=&quot;wikitable floatright&quot;
|+
|-
!Isigaba!!-!!Njenganje!!Umgomo
|-
|'''Inani''' ||:|| '''0'''||'''10'''
|}
&lt;/small&gt;
Imitlolo ihleleke ngezigaba ezilandelako:

* Umtlolo we langa {{Icon|FA}} (Imitlolo akhetiweko bona ivezwe ekhasikhulu)
* Isigaba - A {{Icon|A}}  (Umtlolo opheleleko)
* Isigaba - B {{Icon|B}}  (Umtlolo olungileko)
* Isigaba - C {{Icon|C}}  (Umtlolo othloga bona uthuthukiswe)
* Umtlolo owamukelako {{Icon|GA}}
* Umtlolo wokuthoma {{Icon|Start}}

==Isamba esipheleleko semitlolo: 10==
Sihlathululwe okokuphela ngu -- [[Umsebenzisi:Thuvack|Thuvack]] ([[Umsebenzisi asiqongelane:Thuvack|talk]]) 15:33, 11 January 2019 (UTC)
&lt;br&gt;
{{col-begin}}
{{col-break}}

==Imitlolo yetjhumi eqakathekileyo ngeWikiphidiya yeSindebele==
* [[Ndzundza]] &lt;small&gt;(''[[:en:Ndzundza|Ndzundza]]'')&lt;/small&gt;
* [[Isindebele]] &lt;small&gt;(''[[:en:South Ndebele|Ulwimi lwesindebele]]'')&lt;/small&gt;
* [[Nelson Mandela]] &lt;small&gt;(''[[:en:Nelson Mandela|Nelson Mandela]]'')&lt;/small&gt;
* [[Ilimi]] &lt;small&gt;(''[[:en:Language|Language]]'')&lt;/small&gt;
* [[Iphasi]] &lt;small&gt;(''[[:en:Earth|Earth]]'')&lt;/small&gt; 
* [[Ukuphila]]] &lt;small&gt;(''[[:en:Life|Life]]'')&lt;/small&gt;
* [[UMuntu]] &lt;small&gt;(''[[:en:Human|Human]]'')&lt;/small&gt;
* [[Umlando we phasi]] &lt;small&gt;(''[[:en:History of the world|History of the world]]'')&lt;/small&gt;
* [[Amasiko]] &lt;small&gt;(''[[:en:Culture|Culture]]'')&lt;/small&gt;
* [[Ubukghwari]] &lt;small&gt;(''[[:en:Arts|The arts]]'')&lt;/small&gt;

{{col-break}}

==Imitlolo yetjhumi eqakathekileyo ngeWikiphidiya yeSinghesi==
* [[Iphasi]] &lt;small&gt;(''[[:en:Earth|Earth]]'')&lt;/small&gt; 
* [[Ukuphila]]] &lt;small&gt;(''[[:en:Life|Life]]'')&lt;/small&gt;
* [[UMuntu]] &lt;small&gt;(''[[:en:Human|Human]]'')&lt;/small&gt;
* [[Umlando we phasi]] &lt;small&gt;(''[[:en:History of the world|History of the world]]'')&lt;/small&gt;
* [[Amasiko]] &lt;small&gt;(''[[:en:Culture|Culture]]'')&lt;/small&gt;
* [[Ilimi]] &lt;small&gt;(''[[:en:Language|Language]]'')&lt;/small&gt;
* [[Ubukghwari]] &lt;small&gt;(''[[:en:Arts|The arts]]'')&lt;/small&gt;
* [[Isayensi]] &lt;small&gt;(''[[:en:Science|Science]]'')&lt;/small&gt;
* [[IThekinoloji]] &lt;small&gt;(''[[:en:Technology|Technology]]'')&lt;/small&gt;
* [[IMethamethiksi]] &lt;small&gt;(''[[:en:Mathematics|Mathematics]]'')&lt;/small&gt;

{{col-end}}


[[Mkhakha:Imitlolo aqakathekileyo|Imitlolo aqakathekileyo]]</text>
      <sha1>j6daft5w10nil8kvmw8fkcnetzbcvg0</sha1>
    </revision>
  </page>
  <page>
    <title>Wikiphidiya:Imitlolo aqakathekileyo/esigaba 2</title>
    <ns>4</ns>
    <id>289</id>
    <revision>
      <id>1575</id>
      <timestamp>2019-01-11T15:46:11Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;{{Wikipedia:Imitlolo aqakathekileyo/Level/Nav bar}}  Ukurhupulula amakhasi aqakathekileyo khulu esigaba sesibili. &lt;small&gt; {| class=&quot;wikitable floatright&quot; |+ |- !Isigaba!...&quot;</comment>
      <origin>1575</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="587" sha1="kd67wx9dw7uzt23zf9y1vptqf61i68f" xml:space="preserve">{{Wikipedia:Imitlolo aqakathekileyo/Level/Nav bar}}

Ukurhupulula amakhasi aqakathekileyo khulu esigaba sesibili.
&lt;small&gt;
{| class=&quot;wikitable floatright&quot;
|+
|-
!Isigaba!!-!!Njenganje!!Umgomo
|-
|'''Inani''' ||:|| '''0'''||'''10'''
|}
&lt;/small&gt;
Imitlolo ihleleke ngezigaba ezilandelako:

* Umtlolo we langa {{Icon|FA}} (Imitlolo akhetiweko bona ivezwe ekhasikhulu)
* Isigaba - A {{Icon|A}}  (Umtlolo opheleleko)
* Isigaba - B {{Icon|B}}  (Umtlolo olungileko)
* Isigaba - C {{Icon|C}}  (Umtlolo othloga bona uthuthukiswe)
* Umtlolo owamukelako {{Icon|GA}}
* Umtlolo wokuthoma {{Icon|Start}}</text>
      <sha1>kd67wx9dw7uzt23zf9y1vptqf61i68f</sha1>
    </revision>
    <revision>
      <id>1576</id>
      <parentid>1575</parentid>
      <timestamp>2024-10-14T13:47:49Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>1575</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="587" sha1="kd67wx9dw7uzt23zf9y1vptqf61i68f" xml:space="preserve">{{Wikipedia:Imitlolo aqakathekileyo/Level/Nav bar}}

Ukurhupulula amakhasi aqakathekileyo khulu esigaba sesibili.
&lt;small&gt;
{| class=&quot;wikitable floatright&quot;
|+
|-
!Isigaba!!-!!Njenganje!!Umgomo
|-
|'''Inani''' ||:|| '''0'''||'''10'''
|}
&lt;/small&gt;
Imitlolo ihleleke ngezigaba ezilandelako:

* Umtlolo we langa {{Icon|FA}} (Imitlolo akhetiweko bona ivezwe ekhasikhulu)
* Isigaba - A {{Icon|A}}  (Umtlolo opheleleko)
* Isigaba - B {{Icon|B}}  (Umtlolo olungileko)
* Isigaba - C {{Icon|C}}  (Umtlolo othloga bona uthuthukiswe)
* Umtlolo owamukelako {{Icon|GA}}
* Umtlolo wokuthoma {{Icon|Start}}</text>
      <sha1>kd67wx9dw7uzt23zf9y1vptqf61i68f</sha1>
    </revision>
  </page>
  <page>
    <title>Wikiphidiya:Imitlolo aqakathekileyo/esigaba 3</title>
    <ns>4</ns>
    <id>290</id>
    <revision>
      <id>1577</id>
      <timestamp>2019-01-11T15:46:49Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;{{Wikipedia:Imitlolo aqakathekileyo/Level/Nav bar}}  Ukurhupulula amakhasi aqakathekileyo khulu esigaba sesithathu. &lt;small&gt; {| class=&quot;wikitable floatright&quot; |+ |- !Isigab...&quot;</comment>
      <origin>1577</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="589" sha1="dnaa9nopdfcdk5c5gl6b263dltay9iu" xml:space="preserve">{{Wikipedia:Imitlolo aqakathekileyo/Level/Nav bar}}

Ukurhupulula amakhasi aqakathekileyo khulu esigaba sesithathu.
&lt;small&gt;
{| class=&quot;wikitable floatright&quot;
|+
|-
!Isigaba!!-!!Njenganje!!Umgomo
|-
|'''Inani''' ||:|| '''0'''||'''10'''
|}
&lt;/small&gt;
Imitlolo ihleleke ngezigaba ezilandelako:

* Umtlolo we langa {{Icon|FA}} (Imitlolo akhetiweko bona ivezwe ekhasikhulu)
* Isigaba - A {{Icon|A}}  (Umtlolo opheleleko)
* Isigaba - B {{Icon|B}}  (Umtlolo olungileko)
* Isigaba - C {{Icon|C}}  (Umtlolo othloga bona uthuthukiswe)
* Umtlolo owamukelako {{Icon|GA}}
* Umtlolo wokuthoma {{Icon|Start}}</text>
      <sha1>dnaa9nopdfcdk5c5gl6b263dltay9iu</sha1>
    </revision>
    <revision>
      <id>1578</id>
      <parentid>1577</parentid>
      <timestamp>2024-10-14T13:47:49Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>1577</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="589" sha1="dnaa9nopdfcdk5c5gl6b263dltay9iu" xml:space="preserve">{{Wikipedia:Imitlolo aqakathekileyo/Level/Nav bar}}

Ukurhupulula amakhasi aqakathekileyo khulu esigaba sesithathu.
&lt;small&gt;
{| class=&quot;wikitable floatright&quot;
|+
|-
!Isigaba!!-!!Njenganje!!Umgomo
|-
|'''Inani''' ||:|| '''0'''||'''10'''
|}
&lt;/small&gt;
Imitlolo ihleleke ngezigaba ezilandelako:

* Umtlolo we langa {{Icon|FA}} (Imitlolo akhetiweko bona ivezwe ekhasikhulu)
* Isigaba - A {{Icon|A}}  (Umtlolo opheleleko)
* Isigaba - B {{Icon|B}}  (Umtlolo olungileko)
* Isigaba - C {{Icon|C}}  (Umtlolo othloga bona uthuthukiswe)
* Umtlolo owamukelako {{Icon|GA}}
* Umtlolo wokuthoma {{Icon|Start}}</text>
      <sha1>dnaa9nopdfcdk5c5gl6b263dltay9iu</sha1>
    </revision>
    <revision>
      <id>1756</id>
      <parentid>1578</parentid>
      <timestamp>2024-10-27T06:00:54Z</timestamp>
      <contributor deleted="deleted" />
      <comment deleted="deleted" />
      <origin>1756</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1172" sha1="q1wc20tqa8m70e5tns2ka8bnuembgq4" deleted="deleted" />
      <sha1 />
    </revision>
    <revision>
      <id>1757</id>
      <parentid>1756</parentid>
      <timestamp>2024-10-27T06:11:41Z</timestamp>
      <contributor deleted="deleted" />
      <comment deleted="deleted" />
      <origin>1757</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1399" sha1="tlch8ilg4hzd37e3ca78beoytzy9lja" deleted="deleted" />
      <sha1 />
    </revision>
    <revision>
      <id>1758</id>
      <parentid>1757</parentid>
      <timestamp>2024-10-27T06:13:47Z</timestamp>
      <contributor deleted="deleted" />
      <comment deleted="deleted" />
      <origin>1758</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1463" sha1="21ga7jpn1udzkoycqa57h0c8ey1g2qw" deleted="deleted" />
      <sha1 />
    </revision>
    <revision>
      <id>1759</id>
      <parentid>1758</parentid>
      <timestamp>2024-10-27T06:13:59Z</timestamp>
      <contributor deleted="deleted" />
      <comment deleted="deleted" />
      <origin>1759</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1463" sha1="pa0q79bca5b1rtsn9h2v9vql5j0xafr" deleted="deleted" />
      <sha1 />
    </revision>
    <revision>
      <id>1760</id>
      <parentid>1759</parentid>
      <timestamp>2024-10-27T09:41:14Z</timestamp>
      <contributor deleted="deleted" />
      <comment deleted="deleted" />
      <origin>1760</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1461" sha1="b5m33n5suz3iv48aietjsd73bkb93d9" deleted="deleted" />
      <sha1 />
    </revision>
    <revision>
      <id>1762</id>
      <parentid>1760</parentid>
      <timestamp>2024-10-27T13:48:41Z</timestamp>
      <contributor deleted="deleted" />
      <comment deleted="deleted" />
      <origin>1762</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1513" sha1="5ad6lro5lqzc14qt38lbbvbc5cq3b2c" deleted="deleted" />
      <sha1 />
    </revision>
    <revision>
      <id>1890</id>
      <parentid>1762</parentid>
      <timestamp>2024-11-13T01:44:20Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <comment>rv</comment>
      <origin>1890</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="589" sha1="dnaa9nopdfcdk5c5gl6b263dltay9iu" xml:space="preserve">{{Wikipedia:Imitlolo aqakathekileyo/Level/Nav bar}}

Ukurhupulula amakhasi aqakathekileyo khulu esigaba sesithathu.
&lt;small&gt;
{| class=&quot;wikitable floatright&quot;
|+
|-
!Isigaba!!-!!Njenganje!!Umgomo
|-
|'''Inani''' ||:|| '''0'''||'''10'''
|}
&lt;/small&gt;
Imitlolo ihleleke ngezigaba ezilandelako:

* Umtlolo we langa {{Icon|FA}} (Imitlolo akhetiweko bona ivezwe ekhasikhulu)
* Isigaba - A {{Icon|A}}  (Umtlolo opheleleko)
* Isigaba - B {{Icon|B}}  (Umtlolo olungileko)
* Isigaba - C {{Icon|C}}  (Umtlolo othloga bona uthuthukiswe)
* Umtlolo owamukelako {{Icon|GA}}
* Umtlolo wokuthoma {{Icon|Start}}</text>
      <sha1>dnaa9nopdfcdk5c5gl6b263dltay9iu</sha1>
    </revision>
  </page>
  <page>
    <title>Wikiphidiya:Imitlolo ekhethekileko-1</title>
    <ns>4</ns>
    <id>291</id>
    <redirect title="Wikiphidiya:Imitlolo aqakathekileyo/esigaba 1" />
    <revision>
      <id>1579</id>
      <timestamp>2019-01-11T13:21:26Z</timestamp>
      <contributor>
        <username>incubator&gt;Thuvack</username>
        <id>0</id>
      </contributor>
      <comment>Thuvack moved page [[Wikipedia:Imitlolo ekhethekileko-1]] to [[Wikipedia:Imitlolo aqakathekileyo/esigaba 1]]</comment>
      <origin>1579</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="57" sha1="c8dbwmiwkulzv4b7bvvifgpqcuhqiud" xml:space="preserve">#REDIRECT [[Wikipedia:Imitlolo aqakathekileyo/esigaba 1]]</text>
      <sha1>c8dbwmiwkulzv4b7bvvifgpqcuhqiud</sha1>
    </revision>
    <revision>
      <id>1580</id>
      <parentid>1579</parentid>
      <timestamp>2024-10-14T13:47:50Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>1579</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="57" sha1="c8dbwmiwkulzv4b7bvvifgpqcuhqiud" xml:space="preserve">#REDIRECT [[Wikipedia:Imitlolo aqakathekileyo/esigaba 1]]</text>
      <sha1>c8dbwmiwkulzv4b7bvvifgpqcuhqiud</sha1>
    </revision>
  </page>
  <page>
    <title>Wolwekraal</title>
    <ns>0</ns>
    <id>292</id>
    <revision>
      <id>1581</id>
      <timestamp>2024-05-11T06:29:51Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''I-Wolwekraal''' (ebuye yaziwe ngokuthi yi-Borolo) iyindawo ehlala kuMasipala Wesifunda saseNkangala esifundazweni saseMpumalanga eNingizimu Afrika, amakhilomitha ayi-14 eningizimu-ntshonalanga yeMdutjana.&quot;</comment>
      <origin>1581</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="207" sha1="2ee3mx5rl9ve4av1f43pz7x960few33" xml:space="preserve">'''I-Wolwekraal''' (ebuye yaziwe ngokuthi yi-Borolo) iyindawo ehlala kuMasipala Wesifunda saseNkangala esifundazweni saseMpumalanga eNingizimu Afrika, amakhilomitha ayi-14 eningizimu-ntshonalanga yeMdutjana.</text>
      <sha1>2ee3mx5rl9ve4av1f43pz7x960few33</sha1>
    </revision>
    <revision>
      <id>1582</id>
      <parentid>1581</parentid>
      <timestamp>2024-05-11T07:40:38Z</timestamp>
      <contributor>
        <username>incubator&gt;Jon Gua</username>
        <id>0</id>
      </contributor>
      <origin>1582</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="209" sha1="g9dydyhp05g3d2vg1iha1rvzvn98gt4" xml:space="preserve">'''I-Wolwekraal''' (ebuye yaziwe ngokuthi yi-Borolo) iyindawo ehlala kuMasipala Wesifunda saseNkangala esifundazweni saseMpumalanga eNingizimu Afrika, amakhilomitha ayi-14 eningizimu-ntshonalanga yeMdutjana.

</text>
      <sha1>g9dydyhp05g3d2vg1iha1rvzvn98gt4</sha1>
    </revision>
    <revision>
      <id>1583</id>
      <parentid>1582</parentid>
      <timestamp>2024-10-14T13:47:50Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>1582</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="209" sha1="g9dydyhp05g3d2vg1iha1rvzvn98gt4" xml:space="preserve">'''I-Wolwekraal''' (ebuye yaziwe ngokuthi yi-Borolo) iyindawo ehlala kuMasipala Wesifunda saseNkangala esifundazweni saseMpumalanga eNingizimu Afrika, amakhilomitha ayi-14 eningizimu-ntshonalanga yeMdutjana.

</text>
      <sha1>g9dydyhp05g3d2vg1iha1rvzvn98gt4</sha1>
    </revision>
    <revision>
      <id>2750</id>
      <parentid>1583</parentid>
      <timestamp>2025-04-23T19:52:09Z</timestamp>
      <contributor>
        <ip>206.15.249.238</ip>
      </contributor>
      <comment>Blanked the page</comment>
      <origin>2750</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
    <revision>
      <id>2787</id>
      <parentid>2750</parentid>
      <timestamp>2025-04-26T05:58:17Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <comment>Undo revision [[Special:Diff/2750|2750]] by [[Special:Contributions/206.15.249.238|206.15.249.238]] ([[User talk:206.15.249.238|talk]])</comment>
      <origin>2787</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="207" sha1="2ee3mx5rl9ve4av1f43pz7x960few33" xml:space="preserve">'''I-Wolwekraal''' (ebuye yaziwe ngokuthi yi-Borolo) iyindawo ehlala kuMasipala Wesifunda saseNkangala esifundazweni saseMpumalanga eNingizimu Afrika, amakhilomitha ayi-14 eningizimu-ntshonalanga yeMdutjana.</text>
      <sha1>2ee3mx5rl9ve4av1f43pz7x960few33</sha1>
    </revision>
    <revision>
      <id>2962</id>
      <parentid>2787</parentid>
      <timestamp>2025-06-06T19:54:55Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>This page is sponsored by Raid: Shadow Legends, the sponsor of today's page.</comment>
      <origin>2962</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="288" sha1="clkzzrnfo1xp8b1kzwl0yk90n772axm" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. I-Wolwekraal''' (ebuye yaziwe ngokuthi yi-Borolo) iyindawo ehlala kuMasipala Wesifunda saseNkangala esifundazweni saseMpumalanga eNingizimu Afrika, amakhilomitha ayi-14 eningizimu-ntshonalanga yeMdutjana.</text>
      <sha1>clkzzrnfo1xp8b1kzwl0yk90n772axm</sha1>
    </revision>
    <revision>
      <id>3120</id>
      <parentid>2962</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:DreamRimmer|DreamRimmer]]</comment>
      <origin>2787</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="207" sha1="2ee3mx5rl9ve4av1f43pz7x960few33" xml:space="preserve">'''I-Wolwekraal''' (ebuye yaziwe ngokuthi yi-Borolo) iyindawo ehlala kuMasipala Wesifunda saseNkangala esifundazweni saseMpumalanga eNingizimu Afrika, amakhilomitha ayi-14 eningizimu-ntshonalanga yeMdutjana.</text>
      <sha1>2ee3mx5rl9ve4av1f43pz7x960few33</sha1>
    </revision>
    <revision>
      <id>3181</id>
      <parentid>3120</parentid>
      <timestamp>2025-06-21T19:06:21Z</timestamp>
      <contributor>
        <ip>85.97.84.231</ip>
      </contributor>
      <origin>3181</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="318" sha1="7st4e60nyo6qlkqw7i88ozabueanqv9" xml:space="preserve">[[File:Common chimpanzee (Pan troglodytes schweinfurthii) feeding.jpg|thumb|Omar al-Bashir is a chimpanzee.]]

'''I-Wolwekraal''' (ebuye yaziwe ngokuthi yi-Borolo) iyindawo ehlala kuMasipala Wesifunda saseNkangala esifundazweni saseMpumalanga eNingizimu Afrika, amakhilomitha ayi-14 eningizimu-ntshonalanga yeMdutjana.</text>
      <sha1>7st4e60nyo6qlkqw7i88ozabueanqv9</sha1>
    </revision>
    <revision>
      <id>3300</id>
      <parentid>3181</parentid>
      <timestamp>2025-07-02T20:45:43Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Undo revision [[Special:Diff/3181|3181]] by [[Special:Contributions/85.97.84.231|85.97.84.231]] ([[User talk:85.97.84.231|talk]])</comment>
      <origin>3300</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="207" sha1="2ee3mx5rl9ve4av1f43pz7x960few33" xml:space="preserve">'''I-Wolwekraal''' (ebuye yaziwe ngokuthi yi-Borolo) iyindawo ehlala kuMasipala Wesifunda saseNkangala esifundazweni saseMpumalanga eNingizimu Afrika, amakhilomitha ayi-14 eningizimu-ntshonalanga yeMdutjana.</text>
      <sha1>2ee3mx5rl9ve4av1f43pz7x960few33</sha1>
    </revision>
  </page>
  <page>
    <title>Yunivesithi yempulanga</title>
    <ns>0</ns>
    <id>293</id>
    <revision>
      <id>1584</id>
      <timestamp>2024-03-08T13:44:04Z</timestamp>
      <contributor>
        <username>incubator&gt;Mzwakhe David18</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;Iyunivethi yempulanga ingenye wamayunivethi wenarheni weSewula Afrika. Iyunivesithi le itholakala esifundeni seMpumalanga iyiyunivethi ekulu esifundeni kodwana ingencancani khulu kunawo woke amayunivesithi wesifundeni seSewula Afrika. Yasungulwa ngomnyaka wee 2013 mhlazana amalanga ali-13 enyangeni ka sewula. Yasungulwa nguprimiya wesifundeni seMpumalanga kanye nomnyango wezefundo ephakameko. Iyunivethi le yathoma ngabentwana aabalikhulu namatjhumi asthandathu nane(169)...&quot;</comment>
      <origin>1584</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="860" sha1="07k6783k1bk0h79u3ic9kf9mujughj8" xml:space="preserve">Iyunivethi yempulanga ingenye wamayunivethi wenarheni weSewula Afrika. Iyunivesithi le itholakala esifundeni seMpumalanga iyiyunivethi ekulu esifundeni kodwana ingencancani khulu kunawo woke amayunivesithi wesifundeni seSewula Afrika. Yasungulwa ngomnyaka wee 2013 mhlazana amalanga ali-13 enyangeni ka sewula. Yasungulwa nguprimiya wesifundeni seMpumalanga kanye nomnyango wezefundo ephakameko. Iyunivethi le yathoma ngabentwana aabalikhulu namatjhumi asthandathu nane(169)

Iyunivethi le inamakhampasi amabili ekuyikhampasi ekulu imbombela kanye neSiyabuswa ekuyikhampasi encani. Ikhampasi ekulu itholakala Cnr R40 and D725 Roads
Mbombela 1200 bese encani yona itholakala Bheki Mfundo Drive
Siyabuswa 0472. 

Ukuthuthuka kwe yunivethi le 

iyunivesithi le ithuthuke khulu kusekela ngomnyaka wee-2013.sele inabantwana abafika ku 10000 emakhampsini womabili.

</text>
      <sha1>07k6783k1bk0h79u3ic9kf9mujughj8</sha1>
    </revision>
    <revision>
      <id>1585</id>
      <parentid>1584</parentid>
      <timestamp>2024-03-08T13:46:47Z</timestamp>
      <contributor>
        <username>incubator&gt;Mzwakhe David18</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1585</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="933" sha1="9ye4hkyt8lvw19g174s99rhfvenh3ah" xml:space="preserve">Iyunivethi yempulanga ingenye wamayunivethi wenarheni weSewula Afrika. Iyunivesithi le itholakala esifundeni seMpumalanga iyiyunivethi ekulu esifundeni kodwana ingencancani khulu kunawo woke amayunivesithi wesifundeni seSewula Afrika. Yasungulwa ngomnyaka wee 2013 mhlazana amalanga ali-13 enyangeni ka sewula. Yasungulwa nguprimiya wesifundeni seMpumalanga kanye nomnyango wezefundo ephakameko. Iyunivethi le yathoma ngabentwana aabalikhulu namatjhumi asthandathu nane(169)

Iyunivethi le inamakhampasi amabili ekuyikhampasi ekulu imbombela kanye neSiyabuswa ekuyikhampasi encani. Ikhampasi ekulu itholakala Cnr R40 and D725 Roads
Mbombela 1200 bese encani yona itholakala Bheki Mfundo Drive
Siyabuswa 0472. 

== Ukuthuthuka kwe yunivethi le ==
iyunivesithi le ithuthuke khulu kusekela ngomnyaka wee-2013. Kwanje sele inabantwana abafika ku 10000 emakhampsini womabili. Ngomnyaka wee-2013 beyigidinga amatjhumi wokubakhona kwayo. 

</text>
      <sha1>9ye4hkyt8lvw19g174s99rhfvenh3ah</sha1>
    </revision>
    <revision>
      <id>1586</id>
      <parentid>1585</parentid>
      <timestamp>2024-03-08T13:48:06Z</timestamp>
      <contributor>
        <username>incubator&gt;Mzwakhe David18</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>edithing</comment>
      <origin>1586</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="939" sha1="4qgwc6bd4s90ggxahi77ut85a0s2q1h" xml:space="preserve">'''Iyunivethi yempulanga''' ingenye wamayunivethi wenarheni weSewula Afrika. Iyunivesithi le itholakala esifundeni seMpumalanga iyiyunivethi ekulu esifundeni kodwana ingencancani khulu kunawo woke amayunivesithi wesifundeni seSewula Afrika. Yasungulwa ngomnyaka wee 2013 mhlazana amalanga ali-13 enyangeni ka sewula. Yasungulwa nguprimiya wesifundeni seMpumalanga kanye nomnyango wezefundo ephakameko. Iyunivethi le yathoma ngabentwana aabalikhulu namatjhumi asthandathu nane(169)

Iyunivethi le inamakhampasi amabili ekuyikhampasi ekulu imbombela kanye neSiyabuswa ekuyikhampasi encani. Ikhampasi ekulu itholakala Cnr R40 and D725 Roads
Mbombela 1200 bese encani yona itholakala Bheki Mfundo Drive
Siyabuswa 0472. 

== Ukuthuthuka kwe yunivethi le ==
iyunivesithi le ithuthuke khulu kusekela ngomnyaka wee-2013. Kwanje sele inabantwana abafika ku 10000 emakhampsini womabili. Ngomnyaka wee-2013 beyigidinga amatjhumi wokubakhona kwayo. 

</text>
      <sha1>4qgwc6bd4s90ggxahi77ut85a0s2q1h</sha1>
    </revision>
    <revision>
      <id>1587</id>
      <parentid>1586</parentid>
      <timestamp>2024-03-08T22:25:58Z</timestamp>
      <contributor>
        <username>incubator&gt;Mzwakhe David18</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>edit</comment>
      <origin>1587</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="940" sha1="satkqfzwqyus0pkn9g59kylbfrc9pug" xml:space="preserve">'''Iyunivethi yempulanga''' ingenye wamayunivethi wenarheni weSewula Afrika. Iyunivesithi le itholakala esifundeni seMpumalanga iyiyunivethi ekulu esifundeni kodwana ingencancani khulu kunawo woke amayunivesithi wesifundeni seSewula Afrika. Yasungulwa ngomnyaka wee 2013 mhlazana amalanga ali-13 enyangeni ka sewula. Yasungulwa nguprimiya wesifundeni seMpumalanga kanye nomnyango wezefundo ephakameko. Iyunivethi le yathoma ngabentwana aabalikhulu namatjhumi asthandathu nane(169).

Iyunivethi le inamakhampasi amabili ekuyikhampasi ekulu imbombela kanye neSiyabuswa ekuyikhampasi encani. Ikhampasi ekulu itholakala Cnr R40 and D725 Roads
Mbombela 1200 bese encani yona itholakala Bheki Mfundo Drive
Siyabuswa 0472. 

== Ukuthuthuka kwe yunivethi le ==
iyunivesithi le ithuthuke khulu kusekela ngomnyaka wee-2013. Kwanje sele inabantwana abafika ku 10000 emakhampsini womabili. Ngomnyaka wee-2023 beyigidinga amatjhumi wokubakhona kwayo. 

</text>
      <sha1>satkqfzwqyus0pkn9g59kylbfrc9pug</sha1>
    </revision>
    <revision>
      <id>1588</id>
      <parentid>1587</parentid>
      <timestamp>2024-03-09T07:36:37Z</timestamp>
      <contributor>
        <username>incubator&gt;Lethabo19</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1588</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="959" sha1="8l6jh4ssmzhbozcbdk69xyrdshzzvml" xml:space="preserve">'''Iyunivethi yempulanga''' ingenye wamayunivethi wenarheni we[[Isewula Afrika|Sewula Afrika.]] Iyunivesithi le itholakala esifundeni seMpumalanga iyiyunivethi ekulu esifundeni kodwana ingencancani khulu kunawo woke amayunivesithi wesifundeni seSewula Afrika. Yasungulwa ngomnyaka wee 2013 mhlazana amalanga ali-13 enyangeni ka sewula. Yasungulwa nguprimiya wesifundeni seMpumalanga kanye nomnyango wezefundo ephakameko. Iyunivethi le yathoma ngabentwana aabalikhulu namatjhumi asthandathu nane(169).

Iyunivethi le inamakhampasi amabili ekuyikhampasi ekulu imbombela kanye neSiyabuswa ekuyikhampasi encani. Ikhampasi ekulu itholakala Cnr R40 and D725 Roads
Mbombela 1200 bese encani yona itholakala Bheki Mfundo Drive
Siyabuswa 0472. 

== Ukuthuthuka kwe yunivethi le ==
iyunivesithi le ithuthuke khulu kusekela ngomnyaka wee-2013. Kwanje sele inabantwana abafika ku 10000 emakhampsini womabili. Ngomnyaka wee-2023 beyigidinga amatjhumi wokubakhona kwayo. 

</text>
      <sha1>8l6jh4ssmzhbozcbdk69xyrdshzzvml</sha1>
    </revision>
    <revision>
      <id>1589</id>
      <parentid>1588</parentid>
      <timestamp>2024-03-09T07:37:03Z</timestamp>
      <contributor>
        <username>incubator&gt;Lethabo19</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1589</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="963" sha1="f9wdzuvrb3lh7zxpk4w612pbdne61tj" xml:space="preserve">'''Iyunivethi yempulanga''' ingenye wamayunivethi wenarheni we[[Isewula Afrika|Sewula Afrika.]] Iyunivesithi le itholakala esifundeni se[[Mpumalanga]] iyiyunivethi ekulu esifundeni kodwana ingencancani khulu kunawo woke amayunivesithi wesifundeni seSewula Afrika. Yasungulwa ngomnyaka wee 2013 mhlazana amalanga ali-13 enyangeni ka sewula. Yasungulwa nguprimiya wesifundeni seMpumalanga kanye nomnyango wezefundo ephakameko. Iyunivethi le yathoma ngabentwana aabalikhulu namatjhumi asthandathu nane(169).

Iyunivethi le inamakhampasi amabili ekuyikhampasi ekulu imbombela kanye neSiyabuswa ekuyikhampasi encani. Ikhampasi ekulu itholakala Cnr R40 and D725 Roads
Mbombela 1200 bese encani yona itholakala Bheki Mfundo Drive
Siyabuswa 0472. 

== Ukuthuthuka kwe yunivethi le ==
iyunivesithi le ithuthuke khulu kusekela ngomnyaka wee-2013. Kwanje sele inabantwana abafika ku 10000 emakhampsini womabili. Ngomnyaka wee-2023 beyigidinga amatjhumi wokubakhona kwayo. 

</text>
      <sha1>f9wdzuvrb3lh7zxpk4w612pbdne61tj</sha1>
    </revision>
    <revision>
      <id>1590</id>
      <parentid>1589</parentid>
      <timestamp>2024-03-09T07:37:34Z</timestamp>
      <contributor>
        <username>incubator&gt;Lethabo19</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1590</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="967" sha1="3inqmjodmrbqggah9lo8nhsnin2ar6d" xml:space="preserve">'''Iyunivethi yempulanga''' ingenye wamayunivethi wenarheni we[[Isewula Afrika|Sewula Afrika.]] Iyunivesithi le itholakala esifundeni se[[Mpumalanga]] iyiyunivethi ekulu esifundeni kodwana ingencancani khulu kunawo woke amayunivesithi wesifundeni seSewula Afrika. Yasungulwa ngomnyaka wee 2013 mhlazana amalanga ali-13 enyangeni ka sewula. Yasungulwa nguprimiya wesifundeni seMpumalanga kanye nomnyango wezefundo ephakameko. Iyunivethi le yathoma ngabentwana aabalikhulu namatjhumi asthandathu nane(169).

Iyunivethi le inamakhampasi amabili ekuyikhampasi ekulu imbombela kanye neSiyabuswa ekuyikhampasi encani. Ikhampasi ekulu itholakala Cnr R40 and D725 Roads
[[Mbombela]] 1200 bese encani yona itholakala Bheki Mfundo Drive
Siyabuswa 0472. 

== Ukuthuthuka kwe yunivethi le ==
iyunivesithi le ithuthuke khulu kusekela ngomnyaka wee-2013. Kwanje sele inabantwana abafika ku 10000 emakhampsini womabili. Ngomnyaka wee-2023 beyigidinga amatjhumi wokubakhona kwayo. 

</text>
      <sha1>3inqmjodmrbqggah9lo8nhsnin2ar6d</sha1>
    </revision>
    <revision>
      <id>1591</id>
      <parentid>1590</parentid>
      <timestamp>2024-03-09T07:38:28Z</timestamp>
      <contributor>
        <username>incubator&gt;Lethabo19</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1591</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="971" sha1="6spdjg3s1fou2pnc8hqbuosk1t7tvxa" xml:space="preserve">'''Iyunivethi yempulanga''' ingenye wamayunivethi wenarheni we[[Isewula Afrika|Sewula Afrika.]] Iyunivesithi le itholakala esifundeni se[[Mpumalanga]] iyiyunivethi ekulu esifundeni kodwana ingencancani khulu kunawo woke amayunivesithi wesifundeni seSewula Afrika. Yasungulwa ngomnyaka wee 2013 mhlazana amalanga ali-13 enyangeni ka sewula. Yasungulwa nguprimiya wesifundeni seMpumalanga kanye nomnyango wezefundo ephakameko. Iyunivethi le yathoma ngabentwana aabalikhulu namatjhumi asthandathu nane(169).

Iyunivethi le inamakhampasi amabili ekuyikhampasi ekulu imbombela kanye neSiyabuswa ekuyikhampasi encani. Ikhampasi ekulu itholakala Cnr R40 and D725 Roads
[[Mbombela]] 1200 bese encani yona itholakala Bheki Mfundo Drive
[[Siyabuswa]] 0472. 

== Ukuthuthuka kwe yunivethi le ==
iyunivesithi le ithuthuke khulu kusekela ngomnyaka wee-2013. Kwanje sele inabantwana abafika ku 10000 emakhampsini womabili. Ngomnyaka wee-2023 beyigidinga amatjhumi wokubakhona kwayo. 

</text>
      <sha1>6spdjg3s1fou2pnc8hqbuosk1t7tvxa</sha1>
    </revision>
    <revision>
      <id>1592</id>
      <parentid>1591</parentid>
      <timestamp>2024-03-09T09:37:58Z</timestamp>
      <contributor>
        <username>incubator&gt;Lethabo19</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Added a picture</comment>
      <origin>1592</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1060" sha1="h833jch32hkodzjw2k5xvqvcvl1uugk" xml:space="preserve">[[Isimumathi:University of Mpumalanga.jpg|thumb|Iyege ekulu yeYunivesithi yeMpumalanga]]
'''Iyunivethi yempulanga''' ingenye wamayunivethi wenarheni we[[Isewula Afrika|Sewula Afrika.]] Iyunivesithi le itholakala esifundeni se[[Mpumalanga]] iyiyunivethi ekulu esifundeni kodwana ingencancani khulu kunawo woke amayunivesithi wesifundeni seSewula Afrika. Yasungulwa ngomnyaka wee 2013 mhlazana amalanga ali-13 enyangeni ka sewula. Yasungulwa nguprimiya wesifundeni seMpumalanga kanye nomnyango wezefundo ephakameko. Iyunivethi le yathoma ngabentwana aabalikhulu namatjhumi asthandathu nane(169).

Iyunivethi le inamakhampasi amabili ekuyikhampasi ekulu imbombela kanye neSiyabuswa ekuyikhampasi encani. Ikhampasi ekulu itholakala Cnr R40 and D725 Roads
[[Mbombela]] 1200 bese encani yona itholakala Bheki Mfundo Drive
[[Siyabuswa]] 0472. 

== Ukuthuthuka kwe yunivethi le ==
iyunivesithi le ithuthuke khulu kusekela ngomnyaka wee-2013. Kwanje sele inabantwana abafika ku 10000 emakhampsini womabili. Ngomnyaka wee-2023 beyigidinga amatjhumi wokubakhona kwayo. 

</text>
      <sha1>h833jch32hkodzjw2k5xvqvcvl1uugk</sha1>
    </revision>
    <revision>
      <id>1593</id>
      <parentid>1592</parentid>
      <timestamp>2024-03-09T10:01:47Z</timestamp>
      <contributor>
        <username>incubator&gt;CdTshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1593</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1167" sha1="6nkd8l7gpmfvi7ew1qd1guyilsftmfb" xml:space="preserve">[[Isimumathi:University of Mpumalanga.jpg|thumb|Iyege ekulu yeYunivesithi yeMpumalanga]]
[[Isimumathi:University of Mpumalanga SWIP project.jpg|thumb|I Yunivesithi yase Mpumalanga Swip Project ]]
'''Iyunivethi yempulanga''' ingenye wamayunivethi wenarheni we[[Isewula Afrika|Sewula Afrika.]] Iyunivesithi le itholakala esifundeni se[[Mpumalanga]] iyiyunivethi ekulu esifundeni kodwana ingencancani khulu kunawo woke amayunivesithi wesifundeni seSewula Afrika. Yasungulwa ngomnyaka wee 2013 mhlazana amalanga ali-13 enyangeni ka sewula. Yasungulwa nguprimiya wesifundeni seMpumalanga kanye nomnyango wezefundo ephakameko. Iyunivethi le yathoma ngabentwana aabalikhulu namatjhumi asthandathu nane(169).

Iyunivethi le inamakhampasi amabili ekuyikhampasi ekulu imbombela kanye neSiyabuswa ekuyikhampasi encani. Ikhampasi ekulu itholakala Cnr R40 and D725 Roads
[[Mbombela]] 1200 bese encani yona itholakala Bheki Mfundo Drive
[[Siyabuswa]] 0472. 

== Ukuthuthuka kwe yunivethi le ==
iyunivesithi le ithuthuke khulu kusekela ngomnyaka wee-2013. Kwanje sele inabantwana abafika ku 10000 emakhampsini womabili. Ngomnyaka wee-2023 beyigidinga amatjhumi wokubakhona kwayo. 

</text>
      <sha1>6nkd8l7gpmfvi7ew1qd1guyilsftmfb</sha1>
    </revision>
    <revision>
      <id>1594</id>
      <parentid>1593</parentid>
      <timestamp>2024-03-09T11:50:13Z</timestamp>
      <contributor>
        <username>incubator&gt;Mzwakhe David18</username>
        <id>0</id>
      </contributor>
      <origin>1594</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1324" sha1="oow2iveeoqgmcbrwihzmqva6ak73q74" xml:space="preserve">[[Isimumathi:University of Mpumalanga.jpg|thumb|Iyege ekulu yeYunivesithi yeMpumalanga]]
[[Isimumathi:University of Mpumalanga SWIP project.jpg|thumb|I Yunivesithi yase Mpumalanga Swip Project ]]
'''Iyunivethi yempulanga''' ingenye wamayunivethi wenarheni we[[Isewula Afrika|Sewula Afrika.]] Iyunivesithi le itholakala esifundeni se[[Mpumalanga]] iyiyunivethi ekulu esifundeni kodwana ingencancani khulu kunawo woke amayunivesithi wesifundeni seSewula Afrika. Yasungulwa ngomnyaka wee 2013 mhlazana amalanga ali-13 enyangeni ka sewula. Yasungulwa nguprimiya wesifundeni seMpumalanga kanye nomnyango wezefundo ephakameko. Iyunivethi le yathoma ngabentwana aabalikhulu namatjhumi asthandathu nane(169).

Iyunivethi le inamakhampasi amabili ekuyikhampasi ekulu imbombela kanye neSiyabuswa ekuyikhampasi encani. Ikhampasi ekulu itholakala Cnr R40 and D725 Roads
[[Mbombela]] 1200 bese encani yona itholakala Bheki Mfundo Drive
[[siyabuswa]] 0472 &lt;ref&gt;The impact of commercial afforestation on bird populations in Mpumalanga Province, South Africa — Insights from bird-atlas data - ScienceDirect&lt;/ref&gt;. 

== Ukuthuthuka kwe yunivethi le ==
iyunivesithi le ithuthuke khulu kusekela ngomnyaka wee-2013. Kwanje sele inabantwana abafika ku 10000 emakhampsini womabili. Ngomnyaka wee-2023 beyigidinga amatjhumi wokubakhona kwayo. 

</text>
      <sha1>oow2iveeoqgmcbrwihzmqva6ak73q74</sha1>
    </revision>
    <revision>
      <id>1595</id>
      <parentid>1594</parentid>
      <timestamp>2024-03-11T04:01:55Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1595</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1357" sha1="9po3zpuxu3c5wci2gmsuevpqxx027lh" xml:space="preserve">[[Isimumathi:University of Mpumalanga.jpg|thumb|Iyege ekulu yeYunivesithi yeMpumalanga]]
[[Isimumathi:University of Mpumalanga SWIP project.jpg|thumb|I Yunivesithi yase Mpumalanga Swip Project ]]
'''Iyunivethi yempulanga''' ingenye wamayunivethi wenarheni we[[Isewula Afrika|Sewula Afrika.]] Iyunivesithi le itholakala esifundeni se[[Mpumalanga]] iyiyunivethi ekulu esifundeni kodwana ingencancani khulu kunawo woke amayunivesithi wesifundeni seSewula Afrika. Yasungulwa ngomnyaka wee 2013 mhlazana amalanga ali-13 enyangeni ka sewula. Yasungulwa nguprimiya wesifundeni seMpumalanga kanye nomnyango wezefundo ephakameko. Iyunivethi le yathoma ngabentwana aabalikhulu namatjhumi asthandathu nane(169).&lt;ref&gt;https://www.ump.ac.za/&lt;/ref&gt;

Iyunivethi le inamakhampasi amabili ekuyikhampasi ekulu imbombela kanye neSiyabuswa ekuyikhampasi encani. Ikhampasi ekulu itholakala Cnr R40 and D725 Roads
[[Mbombela]] 1200 bese encani yona itholakala Bheki Mfundo Drive
[[siyabuswa]] 0472 &lt;ref&gt;The impact of commercial afforestation on bird populations in Mpumalanga Province, South Africa — Insights from bird-atlas data - ScienceDirect&lt;/ref&gt;. 

== Ukuthuthuka kwe yunivethi le ==
iyunivesithi le ithuthuke khulu kusekela ngomnyaka wee-2013. Kwanje sele inabantwana abafika ku 10000 emakhampsini womabili. Ngomnyaka wee-2023 beyigidinga amatjhumi wokubakhona kwayo. 

</text>
      <sha1>9po3zpuxu3c5wci2gmsuevpqxx027lh</sha1>
    </revision>
    <revision>
      <id>1596</id>
      <parentid>1595</parentid>
      <timestamp>2024-08-31T07:56:58Z</timestamp>
      <contributor>
        <username>incubator&gt;Nomsa Skosana</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1596</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1430" sha1="ti58tf95qhouciu5zg7643cs5uca8ts" xml:space="preserve">[[Isimumathi:University of Mpumalanga.jpg|thumb|Iyege ekulu yeYunivesithi yeMpumalanga]]
[[Isimumathi:University of Mpumalanga SWIP project.jpg|thumb|I Yunivesithi yase Mpumalanga Swip Project ]]
'''IYunivesithi yeMpulanga''' ingenye wamayunivethi wenarheni ye[[Isewula Afrika|Sewula Afrika.]] Iyunivesithi le itholakala esifundeni se[[Mpumalanga]], iyiyunivethi ekulu esifundeni kodwana ingencancani khulu kunawo woke amayunivesithi wenarha yeSewula Afrika. Yasungulwa ngomnyaka wee-2013 mhlazana amalanga ali-13 enyangeni kaSewula. Yasungulwa nguPrimiya wesifundeni seMpumalanga kanye nomnyango wezefundo ephakameko. Iyunivethi le yathoma ngabentwana abalikhulu namatjhumi asithandathu nane (169).&lt;ref&gt;https://www.ump.ac.za/&lt;/ref&gt;

== Amakhampasi weYunivesithi yeMpumalanga ==
Iyunivethi le inamakhampasi amabili, ekuyikhampasi ekulu iMbombela kanye neSiyabuswa ekuyikhampasi encani. Ikhampasi ekulu itholakala e-Cnr R40 and D725 Roads
[[Mbombela]] 1200 bese encani yona itholakala eBheki Mfundo Drive
[[siyabuswa]] 0472 &lt;ref&gt;The impact of commercial afforestation on bird populations in Mpumalanga Province, South Africa — Insights from bird-atlas data - ScienceDirect&lt;/ref&gt;. 

== Ukuthuthuka kweyunivethi ==
Iyunivesithi le ithuthuke khulu kusekela ngomnyaka wee-2013. Kwanje sele inabantwana abafika ema-10 000 emakhampsini womabili. Ngomnyaka wee-2023 beyigidinga iminyaka ematjhumi wokuba khona kwayo. 

== Ireferensi ==
</text>
      <sha1>ti58tf95qhouciu5zg7643cs5uca8ts</sha1>
    </revision>
    <revision>
      <id>1597</id>
      <parentid>1596</parentid>
      <timestamp>2024-10-14T13:47:50Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>13 revisions imported</comment>
      <origin>1596</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1430" sha1="ti58tf95qhouciu5zg7643cs5uca8ts" xml:space="preserve">[[Isimumathi:University of Mpumalanga.jpg|thumb|Iyege ekulu yeYunivesithi yeMpumalanga]]
[[Isimumathi:University of Mpumalanga SWIP project.jpg|thumb|I Yunivesithi yase Mpumalanga Swip Project ]]
'''IYunivesithi yeMpulanga''' ingenye wamayunivethi wenarheni ye[[Isewula Afrika|Sewula Afrika.]] Iyunivesithi le itholakala esifundeni se[[Mpumalanga]], iyiyunivethi ekulu esifundeni kodwana ingencancani khulu kunawo woke amayunivesithi wenarha yeSewula Afrika. Yasungulwa ngomnyaka wee-2013 mhlazana amalanga ali-13 enyangeni kaSewula. Yasungulwa nguPrimiya wesifundeni seMpumalanga kanye nomnyango wezefundo ephakameko. Iyunivethi le yathoma ngabentwana abalikhulu namatjhumi asithandathu nane (169).&lt;ref&gt;https://www.ump.ac.za/&lt;/ref&gt;

== Amakhampasi weYunivesithi yeMpumalanga ==
Iyunivethi le inamakhampasi amabili, ekuyikhampasi ekulu iMbombela kanye neSiyabuswa ekuyikhampasi encani. Ikhampasi ekulu itholakala e-Cnr R40 and D725 Roads
[[Mbombela]] 1200 bese encani yona itholakala eBheki Mfundo Drive
[[siyabuswa]] 0472 &lt;ref&gt;The impact of commercial afforestation on bird populations in Mpumalanga Province, South Africa — Insights from bird-atlas data - ScienceDirect&lt;/ref&gt;. 

== Ukuthuthuka kweyunivethi ==
Iyunivesithi le ithuthuke khulu kusekela ngomnyaka wee-2013. Kwanje sele inabantwana abafika ema-10 000 emakhampsini womabili. Ngomnyaka wee-2023 beyigidinga iminyaka ematjhumi wokuba khona kwayo. 

== Ireferensi ==
</text>
      <sha1>ti58tf95qhouciu5zg7643cs5uca8ts</sha1>
    </revision>
    <revision>
      <id>2128</id>
      <parentid>1597</parentid>
      <timestamp>2024-11-25T18:18:46Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* Iinkomba */Reflist</comment>
      <origin>2128</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1439" sha1="irv6knifz5as94u151xsfumhpwm8p3v" xml:space="preserve">[[Isimumathi:University of Mpumalanga.jpg|thumb|Iyege ekulu yeYunivesithi yeMpumalanga]]
[[Isimumathi:University of Mpumalanga SWIP project.jpg|thumb|I Yunivesithi yase Mpumalanga Swip Project ]]
'''IYunivesithi yeMpulanga''' ingenye wamayunivethi wenarheni ye[[Isewula Afrika|Sewula Afrika.]] Iyunivesithi le itholakala esifundeni se[[Mpumalanga]], iyiyunivethi ekulu esifundeni kodwana ingencancani khulu kunawo woke amayunivesithi wenarha yeSewula Afrika. Yasungulwa ngomnyaka wee-2013 mhlazana amalanga ali-13 enyangeni kaSewula. Yasungulwa nguPrimiya wesifundeni seMpumalanga kanye nomnyango wezefundo ephakameko. Iyunivethi le yathoma ngabentwana abalikhulu namatjhumi asithandathu nane (169).&lt;ref&gt;https://www.ump.ac.za/&lt;/ref&gt;

== Amakhampasi weYunivesithi yeMpumalanga ==
Iyunivethi le inamakhampasi amabili, ekuyikhampasi ekulu iMbombela kanye neSiyabuswa ekuyikhampasi encani. Ikhampasi ekulu itholakala e-Cnr R40 and D725 Roads
[[Mbombela]] 1200 bese encani yona itholakala eBheki Mfundo Drive
[[siyabuswa]] 0472 &lt;ref&gt;The impact of commercial afforestation on bird populations in Mpumalanga Province, South Africa — Insights from bird-atlas data - ScienceDirect&lt;/ref&gt;. 

== Ukuthuthuka kweyunivethi ==
Iyunivesithi le ithuthuke khulu kusekela ngomnyaka wee-2013. Kwanje sele inabantwana abafika ema-10 000 emakhampsini womabili. Ngomnyaka wee-2023 beyigidinga iminyaka ematjhumi wokuba khona kwayo. 

== Iinkomba ==
{{Reflist}}</text>
      <sha1>irv6knifz5as94u151xsfumhpwm8p3v</sha1>
    </revision>
    <revision>
      <id>5213</id>
      <parentid>2128</parentid>
      <timestamp>2025-08-19T15:58:24Z</timestamp>
      <contributor>
        <username>Mojonom</username>
        <id>593</id>
      </contributor>
      <comment>/* Amakhampasi weYunivesithi yeMpumalanga */</comment>
      <origin>5213</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1509" sha1="8jnljfef5ne00jt37csux3prd0pswx0" xml:space="preserve">[[Isimumathi:University of Mpumalanga.jpg|thumb|Iyege ekulu yeYunivesithi yeMpumalanga]]
[[Isimumathi:University of Mpumalanga SWIP project.jpg|thumb|I Yunivesithi yase Mpumalanga Swip Project ]]
'''IYunivesithi yeMpumalanga''' ingenye wamayunivesithi ama-26 e[[Isewula Afrika|Sewula Afrika.]] IYunivesithi le itholakala esifundeni se[[Mpumalanga]], Yize kungiyo yodwa iYunivesithi esifundeni se[[Isifunda seMpumalanga|Mpumalanga]], kodwana ingencancani khulu kunawo woke amayunivesithi wenarha yeSewula Afrika. Yasungulwa ngomnyaka wee-2013 mhlazana amalanga ali-13 enyangeni kaSewula. Yavulwa nguPrimiya (Premier) wesifundeni seMpumalanga kanye nomnyango wezefundo ephakameko. Iyunivesithi le yathoma ngabentwana abalikhulu namatjhumi asithandathu nane (169).&lt;ref&gt;https://www.ump.ac.za/&lt;/ref&gt;

== Amakhampasi weYunivesithi yeMpumalanga ==
Iyunivesithi le inamakhampasi amabili, ekuyikhampasi ekulu iMbombela kanye neSiyabuswa ekuyikhampasi encani. Ikhampasi ekulu itholakala e-Cnr R40 and D725 Roads
[[Mbombela]] 1200 bese encani yona itholakala eBheki Mfundo Drive
[[siyabuswa]] 0472 &lt;ref&gt;The impact of commercial afforestation on bird populations in Mpumalanga Province, South Africa — Insights from bird-atlas data - ScienceDirect&lt;/ref&gt;. 

== Ukuthuthuka kweYunivesithi ==
Iyunivesithi le ithuthuke khulu kusekela ngomnyaka wee-2013. Kwanje sele inabafundi abangaphezu kwe-10 000 emakhampsini womabili. Ngomnyaka wee-2023 beyigidinga iminyaka ematjhumi wokuba khona kwayo.  

== Iinkomba ==
{{Reflist}}</text>
      <sha1>8jnljfef5ne00jt37csux3prd0pswx0</sha1>
    </revision>
  </page>
  <page>
    <title>I-ISBN</title>
    <ns>0</ns>
    <id>294</id>
    <revision>
      <id>1598</id>
      <timestamp>2024-07-21T10:00:20Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;== ISBN ==  === Kuyini i-ISBN? === I-ISBN sirhunyezo esijamele International Standard Book Number (IZinga leenTjhabatjhabatjha leNomboro yeNcwadi). I-ISBN kuziinomboro ezilutjhumi nantatho nanyana ezilutjhumi lezo ezenyelwe omunye nomunye okhiqizo ukuze ukwazi ukutholakala ngazo (International ISBN Agency 2024).   Kungani zilitjhumi nantathu kanti ezinye zilitjhumi na? Iinomboro ezilitjhumi nantathu ngezisetjenziswa eentjhabatjhabeni bese lezo ezilitjhumi zisetjenziswe n...&quot;</comment>
      <origin>1598</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3208" sha1="sbhwtmxmsuao0gosksvqfkhbdtkb4mf" xml:space="preserve">== ISBN ==

=== Kuyini i-ISBN? ===
I-ISBN sirhunyezo esijamele International Standard Book Number (IZinga leenTjhabatjhabatjha leNomboro yeNcwadi). I-ISBN kuziinomboro ezilutjhumi nantatho nanyana ezilutjhumi lezo ezenyelwe omunye nomunye okhiqizo ukuze ukwazi ukutholakala ngazo (International ISBN Agency 2024). 

Kungani zilitjhumi nantathu kanti ezinye zilitjhumi na?
Iinomboro ezilitjhumi nantathu ngezisetjenziswa eentjhabatjhabeni bese lezo ezilitjhumi zisetjenziswe ngaphakathi enarheni. Ngokuya kwe-Barcoding (2024), enye nenye inarha ephasini inenomboro yayo leyo eyisebenzisa ngaphakathi ukuze umkhiqizo wayo ukhone ukutshwayiwa. 
Ingabe zitjho ukuthini iinomboro ze-ISBN nanyana ze-Bar code na?

Njengoba sivezile ngaphambilini bonyana iinomboro ze-bar code zilitjhumi nanye kanti ke ze-ISBN zilitjhumi. Asitjhejeni isibonelo esilandelako:
 
[[Isimumathi:Isbn photo.jpg|thumb]]





Isitjengiso 1  

Isitjengiso esinikelwe sona lesi ngaphezulu sinikele i-bar code yeenomboro ezilitjhumi nantathu. Iinomboro zokuthoma i-978 zibizwa bona ziinomboronhlomelelo lezo ezenzelwe bona umkhiqizo wakho ukghone ukutloliswa eentjhabatjhabeni (ISBN Barcode 2024 no-Baecoding 2024). Ngamanye amagama i-978, inomboro etjengisa bonyana umkhiqizo wakho ungathengiswa ephasini loke.
Inomboro elandelako i-1, igamele inarha nesiyingi ngokuya kanye nemilimi elisetjenziswako lapho enarheni. ESewula Africa sanikelwa u-0, nanyana u-1, ngombana ngaphambilini limi kwakusiNgisi begodu imikhiqizo yethu eminengi yayikhutjwa ngesiNgisi (Barcoding 2024).  

Iinomboro ezihlanu ezilandelako zijamele ikhamphani nanyana abakhiqizi nabathengisi bomkhiqizo loyo. Enye nenye ikhamphani nanyana abathengisi banenomboro yabo leyo ebenza bonyana bafunyaneke lokha umuntu nakathenga umkhiqizo ngobunzizolwazi nanyana ngobulondolwazi (International ISBN Agency 2024).   

Iinomboro ezintathu nanyana ezine ziinomboro ezibizwa bonyana ziinomboro zokuqinisekisa ngombana ziqinisekisa yoke inomboro ye-bar code nayana ye-ISBN (International ISBN Agency 2024).   

Nakwenzekile bonyana umkhiqizo okhitjhiweko utloliswe ngekhaya nanyana enarheni yethu kwaphela uzokusebenzisa i-ISBN yeenomboro ezilitjhu (Barcoding 2024). Okutjho bona i-ISBN izokuthoma ngo-1868935918. I-978, izokususwa njengoba sihlathululiwe bonyana isetjenziswa mikhiqizo leyo ezitlolise nanyana etjhengiswa nakwezinye iinarha. 
Isiphetho. 

I-ISBN nanyana i-bar code iqakatheke khulu njengombana yenza bonyana umkhiqizo womuntu otloliswe begodu waziwe ngibo boke abantu khona ungazokwetjiwa nanyana usetjenziswe butjhilweni. Kuqakathekile bonyana yoke imikhiqizo itloliswe njengomkhiqizo weentjhabatjhaba. 

=== Umthombolwazi ===
Barcoding. (2024). ‘How to Read a Barcode: Can it Tell You a Product's Country of Origin?’. Available at:&lt;https://www.barcoding.com/blog/barcode-prefixes-and-product-country-of-origin&gt;. Accessed on [17 June 2024]. 

International ISBN Agency. (2024). ‘What is an ISBN?’. Available at:&lt; https://www.isbn-international.org/content/what-isbn/10&gt;. Accessed on [9 January 2024].
ISBN Barcode. (2024). 

Sample ISBN Barcode Images’. Available at:&lt;https://isbnbarcodes.org/sample-isbn-barcode-images/&gt;. Accessed on [17 June 2024].

</text>
      <sha1>sbhwtmxmsuao0gosksvqfkhbdtkb4mf</sha1>
    </revision>
    <revision>
      <id>1599</id>
      <parentid>1598</parentid>
      <timestamp>2024-09-18T16:13:35Z</timestamp>
      <contributor>
        <username>incubator&gt;Owaziwako</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1599</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3355" sha1="smqso5ug62izkpl3z8uliex5f2c1hm6" xml:space="preserve">== ISBN ==

=== Kuyini i-ISBN? ===
I-ISBN sirhunyezo esijamele International Standard Book Number (IZinga leenTjhabatjhabatjha leNomboro yeNcwadi). I-ISBN kuziinomboro ezilutjhumi nantatho nanyana ezilutjhumi lezo ezenyelwe omunye nomunye okhiqizo ukuze ukwazi ukutholakala ngazo (International ISBN Agency 2024&lt;ref name=&quot;:0&quot;&gt;International ISBN Agency. (2024). ‘What is an ISBN?’. Available at:&lt; https://www.isbn-international.org/content/what-isbn/10&gt;. Accessed on [9 January 2024]. ISBN Barcode. (2024).&lt;/ref&gt;). 

Kungani zilitjhumi nantathu kanti ezinye zilitjhumi na?
Iinomboro ezilitjhumi nantathu ngezisetjenziswa eentjhabatjhabeni bese lezo ezilitjhumi zisetjenziswe ngaphakathi enarheni. Ngokuya kwe-Barcoding (2024&lt;ref name=&quot;:1&quot;&gt;Barcoding. (2024). ‘How to Read a Barcode: Can it Tell You a Product's Country of Origin?’. Available at:&lt;https://www.barcoding.com/blog/barcode-prefixes-and-product-country-of-origin&gt;. Accessed on [17 June 2024].&lt;/ref&gt;), enye nenye inarha ephasini inenomboro yayo leyo eyisebenzisa ngaphakathi ukuze umkhiqizo wayo ukhone ukutshwayiwa. 
Ingabe zitjho ukuthini iinomboro ze-ISBN nanyana ze-Bar code na?

Njengoba sivezile ngaphambilini bonyana iinomboro ze-bar code zilitjhumi nanye kanti ke ze-ISBN zilitjhumi. Asitjhejeni isibonelo esilandelako:
 
[[Isimumathi:Isbn photo.jpg|thumb]]





Isitjengiso 1  

Isitjengiso esinikelwe sona lesi ngaphezulu sinikele i-bar code yeenomboro ezilitjhumi nantathu. Iinomboro zokuthoma i-978 zibizwa bona ziinomboronhlomelelo lezo ezenzelwe bona umkhiqizo wakho ukghone ukutloliswa eentjhabatjhabeni (ISBN Barcode 2024&lt;ref&gt;Sample ISBN Barcode Images’. Available at:&lt;https://isbnbarcodes.org/sample-isbn-barcode-images/&gt;. Accessed on [17 June 2024].&lt;/ref&gt; no-Barcoding 2024&lt;ref name=&quot;:1&quot; /&gt;). Ngamanye amagama i-978, inomboro etjengisa bonyana umkhiqizo wakho ungathengiswa ephasini loke.
Inomboro elandelako i-1, igamele inarha nesiyingi ngokuya kanye nemilimi elisetjenziswako lapho enarheni. ESewula Africa sanikelwa u-0, nanyana u-1, ngombana ngaphambilini limi kwakusiNgisi begodu imikhiqizo yethu eminengi yayikhutjwa ngesiNgisi (Barcoding 2024&lt;ref name=&quot;:1&quot; /&gt;).  

Iinomboro ezihlanu ezilandelako zijamele ikhamphani nanyana abakhiqizi nabathengisi bomkhiqizo loyo. Enye nenye ikhamphani nanyana abathengisi banenomboro yabo leyo ebenza bonyana bafunyaneke lokha umuntu nakathenga umkhiqizo ngobunzizolwazi nanyana ngobulondolwazi (International ISBN Agency 2024&lt;ref name=&quot;:0&quot; /&gt;).   

Iinomboro ezintathu nanyana ezine ziinomboro ezibizwa bonyana ziinomboro zokuqinisekisa ngombana ziqinisekisa yoke inomboro ye-bar code nayana ye-ISBN (International ISBN Agency 2024&lt;ref name=&quot;:0&quot; /&gt;).   

Nakwenzekile bonyana umkhiqizo okhitjhiweko utloliswe ngekhaya nanyana enarheni yethu kwaphela uzokusebenzisa i-ISBN yeenomboro ezilitjhu (Barcoding 2024&lt;ref name=&quot;:1&quot; /&gt;). Okutjho bona i-ISBN izokuthoma ngo-1868935918. I-978, izokususwa njengoba sihlathululiwe bonyana isetjenziswa mikhiqizo leyo ezitlolise nanyana etjhengiswa nakwezinye iinarha. 
Isiphetho. 

I-ISBN nanyana i-bar code iqakatheke khulu njengombana yenza bonyana umkhiqizo womuntu otloliswe begodu waziwe ngibo boke abantu khona ungazokwetjiwa nanyana usetjenziswe butjhilweni. Kuqakathekile bonyana yoke imikhiqizo itloliswe njengomkhiqizo weentjhabatjhaba. 

=== Umthombolwazi ===
&lt;references /&gt; 

</text>
      <sha1>smqso5ug62izkpl3z8uliex5f2c1hm6</sha1>
    </revision>
    <revision>
      <id>1600</id>
      <parentid>1599</parentid>
      <timestamp>2024-10-14T13:47:50Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>1599</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3355" sha1="smqso5ug62izkpl3z8uliex5f2c1hm6" xml:space="preserve">== ISBN ==

=== Kuyini i-ISBN? ===
I-ISBN sirhunyezo esijamele International Standard Book Number (IZinga leenTjhabatjhabatjha leNomboro yeNcwadi). I-ISBN kuziinomboro ezilutjhumi nantatho nanyana ezilutjhumi lezo ezenyelwe omunye nomunye okhiqizo ukuze ukwazi ukutholakala ngazo (International ISBN Agency 2024&lt;ref name=&quot;:0&quot;&gt;International ISBN Agency. (2024). ‘What is an ISBN?’. Available at:&lt; https://www.isbn-international.org/content/what-isbn/10&gt;. Accessed on [9 January 2024]. ISBN Barcode. (2024).&lt;/ref&gt;). 

Kungani zilitjhumi nantathu kanti ezinye zilitjhumi na?
Iinomboro ezilitjhumi nantathu ngezisetjenziswa eentjhabatjhabeni bese lezo ezilitjhumi zisetjenziswe ngaphakathi enarheni. Ngokuya kwe-Barcoding (2024&lt;ref name=&quot;:1&quot;&gt;Barcoding. (2024). ‘How to Read a Barcode: Can it Tell You a Product's Country of Origin?’. Available at:&lt;https://www.barcoding.com/blog/barcode-prefixes-and-product-country-of-origin&gt;. Accessed on [17 June 2024].&lt;/ref&gt;), enye nenye inarha ephasini inenomboro yayo leyo eyisebenzisa ngaphakathi ukuze umkhiqizo wayo ukhone ukutshwayiwa. 
Ingabe zitjho ukuthini iinomboro ze-ISBN nanyana ze-Bar code na?

Njengoba sivezile ngaphambilini bonyana iinomboro ze-bar code zilitjhumi nanye kanti ke ze-ISBN zilitjhumi. Asitjhejeni isibonelo esilandelako:
 
[[Isimumathi:Isbn photo.jpg|thumb]]





Isitjengiso 1  

Isitjengiso esinikelwe sona lesi ngaphezulu sinikele i-bar code yeenomboro ezilitjhumi nantathu. Iinomboro zokuthoma i-978 zibizwa bona ziinomboronhlomelelo lezo ezenzelwe bona umkhiqizo wakho ukghone ukutloliswa eentjhabatjhabeni (ISBN Barcode 2024&lt;ref&gt;Sample ISBN Barcode Images’. Available at:&lt;https://isbnbarcodes.org/sample-isbn-barcode-images/&gt;. Accessed on [17 June 2024].&lt;/ref&gt; no-Barcoding 2024&lt;ref name=&quot;:1&quot; /&gt;). Ngamanye amagama i-978, inomboro etjengisa bonyana umkhiqizo wakho ungathengiswa ephasini loke.
Inomboro elandelako i-1, igamele inarha nesiyingi ngokuya kanye nemilimi elisetjenziswako lapho enarheni. ESewula Africa sanikelwa u-0, nanyana u-1, ngombana ngaphambilini limi kwakusiNgisi begodu imikhiqizo yethu eminengi yayikhutjwa ngesiNgisi (Barcoding 2024&lt;ref name=&quot;:1&quot; /&gt;).  

Iinomboro ezihlanu ezilandelako zijamele ikhamphani nanyana abakhiqizi nabathengisi bomkhiqizo loyo. Enye nenye ikhamphani nanyana abathengisi banenomboro yabo leyo ebenza bonyana bafunyaneke lokha umuntu nakathenga umkhiqizo ngobunzizolwazi nanyana ngobulondolwazi (International ISBN Agency 2024&lt;ref name=&quot;:0&quot; /&gt;).   

Iinomboro ezintathu nanyana ezine ziinomboro ezibizwa bonyana ziinomboro zokuqinisekisa ngombana ziqinisekisa yoke inomboro ye-bar code nayana ye-ISBN (International ISBN Agency 2024&lt;ref name=&quot;:0&quot; /&gt;).   

Nakwenzekile bonyana umkhiqizo okhitjhiweko utloliswe ngekhaya nanyana enarheni yethu kwaphela uzokusebenzisa i-ISBN yeenomboro ezilitjhu (Barcoding 2024&lt;ref name=&quot;:1&quot; /&gt;). Okutjho bona i-ISBN izokuthoma ngo-1868935918. I-978, izokususwa njengoba sihlathululiwe bonyana isetjenziswa mikhiqizo leyo ezitlolise nanyana etjhengiswa nakwezinye iinarha. 
Isiphetho. 

I-ISBN nanyana i-bar code iqakatheke khulu njengombana yenza bonyana umkhiqizo womuntu otloliswe begodu waziwe ngibo boke abantu khona ungazokwetjiwa nanyana usetjenziswe butjhilweni. Kuqakathekile bonyana yoke imikhiqizo itloliswe njengomkhiqizo weentjhabatjhaba. 

=== Umthombolwazi ===
&lt;references /&gt; 

</text>
      <sha1>smqso5ug62izkpl3z8uliex5f2c1hm6</sha1>
    </revision>
    <revision>
      <id>2630</id>
      <parentid>1600</parentid>
      <timestamp>2025-04-03T19:09:19Z</timestamp>
      <contributor>
        <username>Rachmat04</username>
        <id>32</id>
      </contributor>
      <minor />
      <origin>2630</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3337" sha1="26f2o4u9bc8zj45l1giw4jkm7erlqcu" xml:space="preserve">== ISBN ==

=== Kuyini i-ISBN? ===
I-ISBN sirhunyezo esijamele International Standard Book Number (IZinga leenTjhabatjhabatjha leNomboro yeNcwadi). I-ISBN kuziinomboro ezilutjhumi nantatho nanyana ezilutjhumi lezo ezenyelwe omunye nomunye okhiqizo ukuze ukwazi ukutholakala ngazo (International ISBN Agency 2024&lt;ref name=&quot;:0&quot;&gt;International ISBN Agency. (2024). ‘What is an ISBN?’. Available at:&lt; https://www.isbn-international.org/content/what-isbn/10&gt;. Accessed on [9 January 2024]. ISBN Barcode. (2024).&lt;/ref&gt;).

Kungani zilitjhumi nantathu kanti ezinye zilitjhumi na?
Iinomboro ezilitjhumi nantathu ngezisetjenziswa eentjhabatjhabeni bese lezo ezilitjhumi zisetjenziswe ngaphakathi enarheni. Ngokuya kwe-Barcoding (2024&lt;ref name=&quot;:1&quot;&gt;Barcoding. (2024). ‘How to Read a Barcode: Can it Tell You a Product's Country of Origin?’. Available at:&lt;https://www.barcoding.com/blog/barcode-prefixes-and-product-country-of-origin&gt;. Accessed on [17 June 2024].&lt;/ref&gt;), enye nenye inarha ephasini inenomboro yayo leyo eyisebenzisa ngaphakathi ukuze umkhiqizo wayo ukhone ukutshwayiwa.
Ingabe zitjho ukuthini iinomboro ze-ISBN nanyana ze-Bar code na?

Njengoba sivezile ngaphambilini bonyana iinomboro ze-bar code zilitjhumi nanye kanti ke ze-ISBN zilitjhumi. Asitjhejeni isibonelo esilandelako:
 
[[Isimumathi:Isbn photo.jpg|thumb]]





Isitjengiso 1

Isitjengiso esinikelwe sona lesi ngaphezulu sinikele i-bar code yeenomboro ezilitjhumi nantathu. Iinomboro zokuthoma i-978 zibizwa bona ziinomboronhlomelelo lezo ezenzelwe bona umkhiqizo wakho ukghone ukutloliswa eentjhabatjhabeni (ISBN Barcode 2024&lt;ref&gt;Sample ISBN Barcode Images’. Available at:&lt;https://isbnbarcodes.org/sample-isbn-barcode-images/&gt;. Accessed on [17 June 2024].&lt;/ref&gt; no-Barcoding 2024&lt;ref name=&quot;:1&quot; /&gt;). Ngamanye amagama i-978, inomboro etjengisa bonyana umkhiqizo wakho ungathengiswa ephasini loke.
Inomboro elandelako i-1, igamele inarha nesiyingi ngokuya kanye nemilimi elisetjenziswako lapho enarheni. ESewula Africa sanikelwa u-0, nanyana u-1, ngombana ngaphambilini limi kwakusiNgisi begodu imikhiqizo yethu eminengi yayikhutjwa ngesiNgisi (Barcoding 2024&lt;ref name=&quot;:1&quot; /&gt;).

Iinomboro ezihlanu ezilandelako zijamele ikhamphani nanyana abakhiqizi nabathengisi bomkhiqizo loyo. Enye nenye ikhamphani nanyana abathengisi banenomboro yabo leyo ebenza bonyana bafunyaneke lokha umuntu nakathenga umkhiqizo ngobunzizolwazi nanyana ngobulondolwazi (International ISBN Agency 2024&lt;ref name=&quot;:0&quot; /&gt;).

Iinomboro ezintathu nanyana ezine ziinomboro ezibizwa bonyana ziinomboro zokuqinisekisa ngombana ziqinisekisa yoke inomboro ye-bar code nayana ye-ISBN (International ISBN Agency 2024&lt;ref name=&quot;:0&quot; /&gt;).

Nakwenzekile bonyana umkhiqizo okhitjhiweko utloliswe ngekhaya nanyana enarheni yethu kwaphela uzokusebenzisa i-ISBN yeenomboro ezilitjhu (Barcoding 2024&lt;ref name=&quot;:1&quot; /&gt;). Okutjho bona i-ISBN izokuthoma ngo-1868935918. I-978, izokususwa njengoba sihlathululiwe bonyana isetjenziswa mikhiqizo leyo ezitlolise nanyana etjhengiswa nakwezinye iinarha.
Isiphetho.

I-ISBN nanyana i-bar code iqakatheke khulu njengombana yenza bonyana umkhiqizo womuntu otloliswe begodu waziwe ngibo boke abantu khona ungazokwetjiwa nanyana usetjenziswe butjhilweni. Kuqakathekile bonyana yoke imikhiqizo itloliswe njengomkhiqizo weentjhabatjhaba.

=== Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>26f2o4u9bc8zj45l1giw4jkm7erlqcu</sha1>
    </revision>
    <revision>
      <id>2930</id>
      <parentid>2630</parentid>
      <timestamp>2025-06-06T17:10:00Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>no admin L imagine</comment>
      <origin>2930</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3424" sha1="7idf0p9fmq69jpylgrsk7dsvmg0q2cw" xml:space="preserve">== ISBN ==

=== Kuyini i-ISBN? ===
'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.''' I-ISBN sirhunyezo esijamele International Standard Book Number (IZinga leenTjhabatjhabatjha leNomboro yeNcwadi). I-ISBN kuziinomboro ezilutjhumi nantatho nanyana ezilutjhumi lezo ezenyelwe omunye nomunye okhiqizo ukuze ukwazi ukutholakala ngazo (International ISBN Agency 2024&lt;ref name=&quot;:0&quot;&gt;International ISBN Agency. (2024). ‘What is an ISBN?’. Available at:&lt; https://www.isbn-international.org/content/what-isbn/10&gt;. Accessed on [9 January 2024]. ISBN Barcode. (2024).&lt;/ref&gt;).

Kungani zilitjhumi nantathu kanti ezinye zilitjhumi na?
Iinomboro ezilitjhumi nantathu ngezisetjenziswa eentjhabatjhabeni bese lezo ezilitjhumi zisetjenziswe ngaphakathi enarheni. Ngokuya kwe-Barcoding (2024&lt;ref name=&quot;:1&quot;&gt;Barcoding. (2024). ‘How to Read a Barcode: Can it Tell You a Product's Country of Origin?’. Available at:&lt;https://www.barcoding.com/blog/barcode-prefixes-and-product-country-of-origin&gt;. Accessed on [17 June 2024].&lt;/ref&gt;), enye nenye inarha ephasini inenomboro yayo leyo eyisebenzisa ngaphakathi ukuze umkhiqizo wayo ukhone ukutshwayiwa.
Ingabe zitjho ukuthini iinomboro ze-ISBN nanyana ze-Bar code na?

Njengoba sivezile ngaphambilini bonyana iinomboro ze-bar code zilitjhumi nanye kanti ke ze-ISBN zilitjhumi. Asitjhejeni isibonelo esilandelako:
 
[[Isimumathi:Isbn photo.jpg|thumb]]





Isitjengiso 1

Isitjengiso esinikelwe sona lesi ngaphezulu sinikele i-bar code yeenomboro ezilitjhumi nantathu. Iinomboro zokuthoma i-978 zibizwa bona ziinomboronhlomelelo lezo ezenzelwe bona umkhiqizo wakho ukghone ukutloliswa eentjhabatjhabeni (ISBN Barcode 2024&lt;ref&gt;Sample ISBN Barcode Images’. Available at:&lt;https://isbnbarcodes.org/sample-isbn-barcode-images/&gt;. Accessed on [17 June 2024].&lt;/ref&gt; no-Barcoding 2024&lt;ref name=&quot;:1&quot; /&gt;). Ngamanye amagama i-978, inomboro etjengisa bonyana umkhiqizo wakho ungathengiswa ephasini loke.
Inomboro elandelako i-1, igamele inarha nesiyingi ngokuya kanye nemilimi elisetjenziswako lapho enarheni. ESewula Africa sanikelwa u-0, nanyana u-1, ngombana ngaphambilini limi kwakusiNgisi begodu imikhiqizo yethu eminengi yayikhutjwa ngesiNgisi (Barcoding 2024&lt;ref name=&quot;:1&quot; /&gt;).

Iinomboro ezihlanu ezilandelako zijamele ikhamphani nanyana abakhiqizi nabathengisi bomkhiqizo loyo. Enye nenye ikhamphani nanyana abathengisi banenomboro yabo leyo ebenza bonyana bafunyaneke lokha umuntu nakathenga umkhiqizo ngobunzizolwazi nanyana ngobulondolwazi (International ISBN Agency 2024&lt;ref name=&quot;:0&quot; /&gt;).

Iinomboro ezintathu nanyana ezine ziinomboro ezibizwa bonyana ziinomboro zokuqinisekisa ngombana ziqinisekisa yoke inomboro ye-bar code nayana ye-ISBN (International ISBN Agency 2024&lt;ref name=&quot;:0&quot; /&gt;).

Nakwenzekile bonyana umkhiqizo okhitjhiweko utloliswe ngekhaya nanyana enarheni yethu kwaphela uzokusebenzisa i-ISBN yeenomboro ezilitjhu (Barcoding 2024&lt;ref name=&quot;:1&quot; /&gt;). Okutjho bona i-ISBN izokuthoma ngo-1868935918. I-978, izokususwa njengoba sihlathululiwe bonyana isetjenziswa mikhiqizo leyo ezitlolise nanyana etjhengiswa nakwezinye iinarha.
Isiphetho.

I-ISBN nanyana i-bar code iqakatheke khulu njengombana yenza bonyana umkhiqizo womuntu otloliswe begodu waziwe ngibo boke abantu khona ungazokwetjiwa nanyana usetjenziswe butjhilweni. Kuqakathekile bonyana yoke imikhiqizo itloliswe njengomkhiqizo weentjhabatjhaba.

=== Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>7idf0p9fmq69jpylgrsk7dsvmg0q2cw</sha1>
    </revision>
    <revision>
      <id>2941</id>
      <parentid>2930</parentid>
      <timestamp>2025-06-06T17:19:18Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>hot dog</comment>
      <origin>2941</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3508" sha1="r8kkekk2krn2uowrhygoujjg4k6t1t4" xml:space="preserve">== Black Pensil ==

=== Kuyini i-ISBN? ===
'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.''' I-ISBN is stupid. Black pensil better. BLACK PENSIL GREEN PENSIL BIG BANANA PENSIL!![[Isimumathi:Isbn photo.jpg|thumb]]





upon the most peculiar and oft-overlooked phenomenon known within the parlance of the commoner as the '''hot dog''', though such nomenclature belies its manifold complexities. Permit me to articulate, in a style most befitting the genteel salons of our fair Britannia in this, the resplendent 19th century, the manifold dynamics of this tubular culinary oddity.
----'''A Treatise Upon the Thermo-Gustatory and Socio-Cylindrical Interactions of the Encased Meatic Delicacy Commonly Referred to as the &quot;Hot Dog&quot;'''

In the burgeoning epoch of steam and empire, wherein dirigibles graze the heavens and gentlemen discourse upon phlogiston and Darwinian descent over tea and crumpets, there exists a most singular comestible of transatlantic origin—nay, a gastronomic chimera—comprised principally of a homogenised, emulsified amalgamation of porcine and/or bovine flesh, ensconced within a phallic sheath of artificially reconstituted intestinal membrane.

Said ''viand'', once subjected to the transformative rigours of thermal agitation—most commonly through immersion in boiling aqueous solution or searing upon a heated iron griddle—undergoes a process of protein denaturation and lipidic exudation, thereby achieving a state of both succulence and structural integrity most palatable to the human gustatory apparatus.

The resultant ''sausage'', glistening in its post-coital sheen of oil and steam, is thenceforth nestled within a bifurcated, leavened bread vessel—oft referred to as a &quot;bun,&quot; though the term lacks appropriate gravity. Said bread, whose yeasty effervescence recalls the rustic charm of a Yorkshire bakehouse, serves not merely as a conveyance, but as a textural counterpoint, a spongiform cradle that tempers the olfactory violence of the seasoned tube-meat within.

Upon the summit of this cylindrical banquet, the diner—whose tastes may range from the sublime to the absurd—may elect to append a medley of condimentary effluvia: mustard, that Gallic yellow ichor; ketchup, the tomatoic blood of the New World; onions, both raw and caramelised to the consistency of Dickensian sorrow; and the abhorrent green pickle relish, whose inclusion I dare say marks the eater as a colonial deviant of the highest order.

Now, consider if you will the '''dynamic interaction''': the bite, a momentary rupture in the temporal continuum, wherein teeth cleave through crust and casing alike, causing a micro-explosion of savoury juices to erupt forth with all the vigour of a Crimean cannonade. The mastication thereafter resembles the complex mechanical operations of Brunel's Great Eastern—gears and pistons working in synchrony to reduce the noble dog to a bolus fit for deglutition.

To consume a hot dog, dear reader, is to engage in a ritualistic theatre of meat and bread, to partake in the democratic ingestion of proletarian delight, wrapped in the trappings of modern industrialism and American excess. It is, in short, an edible metaphor for the contradictions of our age: refinement and vulgarity, steam and grease, bun and beast—all rendered in a single, hand-held cylinder.
----I remain, as ever,

Your most obedient servant and humble explicator of gustatory enigmas,

'''Chatboticus G. P. Thourghbottom, Esq.'''</text>
      <sha1>r8kkekk2krn2uowrhygoujjg4k6t1t4</sha1>
    </revision>
    <revision>
      <id>3135</id>
      <parentid>2941</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edits by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Rachmat04|Rachmat04]]</comment>
      <origin>2630</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3337" sha1="26f2o4u9bc8zj45l1giw4jkm7erlqcu" xml:space="preserve">== ISBN ==

=== Kuyini i-ISBN? ===
I-ISBN sirhunyezo esijamele International Standard Book Number (IZinga leenTjhabatjhabatjha leNomboro yeNcwadi). I-ISBN kuziinomboro ezilutjhumi nantatho nanyana ezilutjhumi lezo ezenyelwe omunye nomunye okhiqizo ukuze ukwazi ukutholakala ngazo (International ISBN Agency 2024&lt;ref name=&quot;:0&quot;&gt;International ISBN Agency. (2024). ‘What is an ISBN?’. Available at:&lt; https://www.isbn-international.org/content/what-isbn/10&gt;. Accessed on [9 January 2024]. ISBN Barcode. (2024).&lt;/ref&gt;).

Kungani zilitjhumi nantathu kanti ezinye zilitjhumi na?
Iinomboro ezilitjhumi nantathu ngezisetjenziswa eentjhabatjhabeni bese lezo ezilitjhumi zisetjenziswe ngaphakathi enarheni. Ngokuya kwe-Barcoding (2024&lt;ref name=&quot;:1&quot;&gt;Barcoding. (2024). ‘How to Read a Barcode: Can it Tell You a Product's Country of Origin?’. Available at:&lt;https://www.barcoding.com/blog/barcode-prefixes-and-product-country-of-origin&gt;. Accessed on [17 June 2024].&lt;/ref&gt;), enye nenye inarha ephasini inenomboro yayo leyo eyisebenzisa ngaphakathi ukuze umkhiqizo wayo ukhone ukutshwayiwa.
Ingabe zitjho ukuthini iinomboro ze-ISBN nanyana ze-Bar code na?

Njengoba sivezile ngaphambilini bonyana iinomboro ze-bar code zilitjhumi nanye kanti ke ze-ISBN zilitjhumi. Asitjhejeni isibonelo esilandelako:
 
[[Isimumathi:Isbn photo.jpg|thumb]]





Isitjengiso 1

Isitjengiso esinikelwe sona lesi ngaphezulu sinikele i-bar code yeenomboro ezilitjhumi nantathu. Iinomboro zokuthoma i-978 zibizwa bona ziinomboronhlomelelo lezo ezenzelwe bona umkhiqizo wakho ukghone ukutloliswa eentjhabatjhabeni (ISBN Barcode 2024&lt;ref&gt;Sample ISBN Barcode Images’. Available at:&lt;https://isbnbarcodes.org/sample-isbn-barcode-images/&gt;. Accessed on [17 June 2024].&lt;/ref&gt; no-Barcoding 2024&lt;ref name=&quot;:1&quot; /&gt;). Ngamanye amagama i-978, inomboro etjengisa bonyana umkhiqizo wakho ungathengiswa ephasini loke.
Inomboro elandelako i-1, igamele inarha nesiyingi ngokuya kanye nemilimi elisetjenziswako lapho enarheni. ESewula Africa sanikelwa u-0, nanyana u-1, ngombana ngaphambilini limi kwakusiNgisi begodu imikhiqizo yethu eminengi yayikhutjwa ngesiNgisi (Barcoding 2024&lt;ref name=&quot;:1&quot; /&gt;).

Iinomboro ezihlanu ezilandelako zijamele ikhamphani nanyana abakhiqizi nabathengisi bomkhiqizo loyo. Enye nenye ikhamphani nanyana abathengisi banenomboro yabo leyo ebenza bonyana bafunyaneke lokha umuntu nakathenga umkhiqizo ngobunzizolwazi nanyana ngobulondolwazi (International ISBN Agency 2024&lt;ref name=&quot;:0&quot; /&gt;).

Iinomboro ezintathu nanyana ezine ziinomboro ezibizwa bonyana ziinomboro zokuqinisekisa ngombana ziqinisekisa yoke inomboro ye-bar code nayana ye-ISBN (International ISBN Agency 2024&lt;ref name=&quot;:0&quot; /&gt;).

Nakwenzekile bonyana umkhiqizo okhitjhiweko utloliswe ngekhaya nanyana enarheni yethu kwaphela uzokusebenzisa i-ISBN yeenomboro ezilitjhu (Barcoding 2024&lt;ref name=&quot;:1&quot; /&gt;). Okutjho bona i-ISBN izokuthoma ngo-1868935918. I-978, izokususwa njengoba sihlathululiwe bonyana isetjenziswa mikhiqizo leyo ezitlolise nanyana etjhengiswa nakwezinye iinarha.
Isiphetho.

I-ISBN nanyana i-bar code iqakatheke khulu njengombana yenza bonyana umkhiqizo womuntu otloliswe begodu waziwe ngibo boke abantu khona ungazokwetjiwa nanyana usetjenziswe butjhilweni. Kuqakathekile bonyana yoke imikhiqizo itloliswe njengomkhiqizo weentjhabatjhaba.

=== Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>26f2o4u9bc8zj45l1giw4jkm7erlqcu</sha1>
    </revision>
  </page>
  <page>
    <title>IBoekenhouthoek</title>
    <ns>0</ns>
    <id>295</id>
    <revision>
      <id>1601</id>
      <timestamp>2024-08-04T15:55:25Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''IBoekenhouthoek''' yindawo esezabelweni zakwandebele. indawo le ayikadumi khulu ngombana kuyindawo encani ebhodwe ziintaba. Elinye igama lendawo le yiZithabiseni.Endaweni le kuhlala ngobunengi abantu abamaNdebele kodwana naminye imihlobo yabantu iyatholaakala.  &quot;</comment>
      <origin>1601</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="265" sha1="btcfbctbmo8sqvn054348feb070zz84" xml:space="preserve">'''IBoekenhouthoek''' yindawo esezabelweni zakwandebele. indawo le ayikadumi khulu ngombana kuyindawo encani ebhodwe ziintaba. Elinye igama lendawo le yiZithabiseni.Endaweni le kuhlala ngobunengi abantu abamaNdebele kodwana naminye imihlobo yabantu iyatholaakala.

</text>
      <sha1>btcfbctbmo8sqvn054348feb070zz84</sha1>
    </revision>
    <revision>
      <id>1602</id>
      <parentid>1601</parentid>
      <timestamp>2024-08-04T16:06:14Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1602</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="845" sha1="j2onx28mh3rbtn0fmycfvpo5orosimk" xml:space="preserve">'''IBoekenhouthoek''' yindawo esezabelweni zakwandebele. indawo le ayikadumi khulu ngombana kuyindawo encani ebhodwe ziintaba. Elinye igama lendawo le yiZithabiseni.Endaweni le kuhlala ngobunengi abantu abamaNdebele kodwana naminye imihlobo yabantu iyatholaakala. Indawo le ingaphasi kobukhosi baka Msindo ikosi eyakhathamako.

== Abosaziwako abakhulelel kulendawo ==
USipho Mbele

UThando Mahlangu

UAugust Masango

UGamela Mthombeni

UBharhu Mthombeni

== Indawo le kuze njani bona ibizwe ukuthi yi Boekenhouthoek ==
Iindawo le yathiywa bona yiBoekehouthoek ngesibanga sokobana beyizele ngeenhlahla ezibizwa boan maBoekenhout trees, umdwadwa.

== Okhunye nge Boekenhouthoek ==
Indawo le izele amatje aligugu we crystal ekwenziwa ngawo imirhabiso. Abantu bayawemba amatje la bayowathengisela amakhuwa ukuze bakghone ukwenza imali yokuziphilsa.
</text>
      <sha1>j2onx28mh3rbtn0fmycfvpo5orosimk</sha1>
    </revision>
    <revision>
      <id>1603</id>
      <parentid>1602</parentid>
      <timestamp>2024-08-06T17:35:16Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1603</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="871" sha1="k8u1r014fd1rdhut1hsc1bdbu4sbmie" xml:space="preserve">'''IBoekenhouthoek''' yindawo esezabelweni zakwaNdebele. Indawo le ayikadumi khulu ngombana kuyindawo encani ebhodwe ziintaba Itholakala esifundeni seMpumalanga. Elinye igama lendawo le yiZithabiseni, la kuhlala ngobunengi abantu abamaNdebele kodwana naminye imihlobo yabantu iyatholakala. Indawo le ingaphasi kobukhosi baka Msindo ikosi eyakhathamako.

== Abosaziwako abakhulelel kulendawo ==
USipho Mbele

UThando Mahlangu

UAugust Masango

UGamela Mthombeni

UBharhu Mthombeni

== Indawo le kuze njani bona ibizwe ukuthi yi Boekenhouthoek ==
Iindawo le yathiywa bona yiBoekehouthoek ngesibanga sokobana beyizele ngeenhlahla ezibizwa boan maBoekenhout trees, umdwadwa.

== Okhunye nge Boekenhouthoek ==
Indawo le izele amatje aligugu we crystal ekwenziwa ngawo imirhabiso. Abantu bayawemba amatje la bayowathengisela amakhuwa ukuze bakghone ukwenza imali yokuziphilsa.
</text>
      <sha1>k8u1r014fd1rdhut1hsc1bdbu4sbmie</sha1>
    </revision>
    <revision>
      <id>1604</id>
      <parentid>1603</parentid>
      <timestamp>2024-08-08T10:27:00Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1604</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1039" sha1="tmfb85q9hx32u9mmf3bqh6hyzitbgkk" xml:space="preserve">'''IBoekenhouthoek''' yindawo esezabelweni zakwaNdebele. Indawo le ayikadumi khulu ngombana kuyindawo encani ebhodwe ziintaba Itholakala esifundeni seMpumalanga. Elinye igama lendawo le yiZithabiseni, la kuhlala ngobunengi abantu abamaNdebele kodwana naminye imihlobo yabantu iyatholakala. Indawo le ingaphasi kobukhosi baka Msindo ikosi eyakhathamako.

== Abosaziwako abakhulelel kulendawo ==
USipho Mbele omlingisi kamabonakude nomtloli. UThando Mahlangu mthuthukisi wesiNdebele. U-August Masango owadlulako ephasini ebegade acumen khulu ehlanganweni ye- African national congress. UGamela Mthombeni omkhuzeli wezemidlalo emrhatjhweni Ikwekwezi.

== Indawo le kuze njani bona ibizwe ukuthi yi Boekenhouthoek ==
Iindawo le yathiywa bona yiBoekehouthoek ngesibanga sokobana beyizele ngeenhlahla ezibizwa boan maBoekenhout trees, umdwadwa.

== Okhunye nge Boekenhouthoek ==
Indawo le izele amatje aligugu we crystal ekwenziwa ngawo imirhabiso. Abantu bayawemba amatje la bayowathengisela amakhuwa ukuze bakghone ukwenza imali yokuziphilsa.
</text>
      <sha1>tmfb85q9hx32u9mmf3bqh6hyzitbgkk</sha1>
    </revision>
    <revision>
      <id>1605</id>
      <parentid>1604</parentid>
      <timestamp>2024-08-12T16:42:03Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1605</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1121" sha1="o5k9az39g5fnv63lxuev5mil3vaod8r" xml:space="preserve">'''IBoekenhouthoek''' yindawo esezabelweni zakwaNdebele. Indawo le ayikadumi khulu ngombana kuyindawo encani ebhodwe ziintaba Itholakala esifundeni seMpumalanga. Elinye igama lendawo le yiZithabiseni, la kuhlala ngobunengi abantu abamaNdebele kodwana naminye imihlobo yabantu iyatholakala. Indawo le ingaphasi kobukhosi baka Msindo ikosi eyakhathamako.

== Abosaziwako abakhulelel kulendawo ==
USipho Mbele omlingisi kamabonakude nomtloli. UThando Mahlangu mthuthukisi wesiNdebele. U-August Masango owadlulako ephasini ebegade acumen khulu ehlanganweni ye- African national congress. UGamela Mthombeni omkhuzeli wezemidlalo emrhatjhweni Ikwekwezi.

== Indawo le kuze njani bona ibizwe ukuthi yi Boekenhouthoek ==
Iindawo le yathiywa bona yiBoekehouthoek ngesibanga sokobana beyizele ngeenhlahla ezibizwa boan maBoekenhout trees, umdwadwa.

== Okhunye nge Boekenhouthoek ==
[[Isimumathi:Quartz-170617.jpg|thumb|umhlobo welitje eligutjwa e Boekenhouthoek]]
Indawo le izele amatje aligugu we crystal ekwenziwa ngawo imirhabiso. Abantu bayawemba amatje la bayowathengisela amakhuwa ukuze bakghone ukwenza imali yokuziphilsa.
</text>
      <sha1>o5k9az39g5fnv63lxuev5mil3vaod8r</sha1>
    </revision>
    <revision>
      <id>1606</id>
      <parentid>1605</parentid>
      <timestamp>2024-08-12T16:50:58Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1606</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1166" sha1="463hi4rt6jdrsbjcug9l5mfys1tmx4g" xml:space="preserve">'''IBoekenhouthoek''' yindawo esezabelweni zakwaNdebele esiphandeni seMpumalanga ngaphasi kuka masipala we Thembisile hani municipality. Indawo le ayikadumi khulu ngombana kuyindawo encani ebhodwe ziintaba. Elinye igama lendawo le yiZithabiseni, la kuhlala ngobunengi abantu abamaNdebele kodwana naminye imihlobo yabantu iyatholakala. Indawo le ingaphasi kobukhosi baka Msindo ikosi eyakhathamako. 

== Abosaziwako abakhulelel kulendawo ==
USipho Mbele omlingisi kamabonakude nomtloli. UThando Mahlangu mthuthukisi wesiNdebele. U-August Masango owadlulako ephasini ebegade adume khulu ehlanganweni ye- African national congress. UGamela Mthombeni omkhuzeli wezemidlalo emrhatjhweni Ikwekwezi.

== Indawo le kuze njani bona ibizwe ukuthi yi Boekenhouthoek ==
Iindawo le yathiywa bona yiBoekehouthoek ngesibanga sokobana beyizele ngeenhlahla ezibizwa boan maBoekenhout trees, umdwadwa.

== Okhunye nge Boekenhouthoek ==
[[Isimumathi:Quartz-170617.jpg|thumb|umhlobo welitje eligutjwa e Boekenhouthoek]]
Indawo le izele amatje aligugu we crystal ekwenziwa ngawo imirhabiso. Abantu bayawemba amatje la bayowathengisela amakhuwa ukuze bakghone ukwenza imali yokuziphilsa.
</text>
      <sha1>463hi4rt6jdrsbjcug9l5mfys1tmx4g</sha1>
    </revision>
    <revision>
      <id>1607</id>
      <parentid>1606</parentid>
      <timestamp>2024-08-12T16:57:13Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1607</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1167" sha1="24msw8pd3wqyoi07ab1qzaywd7cw0rp" xml:space="preserve">'''IBoekenhouthoek''' yindawo esezabelweni zakwaNdebele esiphandeni seMpumalanga ngaphasi kuka masipala we Thembisile hani municipality. Indawo le ayikadumi khulu ngombana kuyindawo encani ebhodwe ziintaba. Elinye igama lendawo le yiZithabiseni, la kuhlala ngobunengi abantu abamaNdebele kodwana naminye imihlobo yabantu iyatholakala. Indawo le ingaphasi kobukhosi baka Msindo ikosi eyakhathamako. 

== Abosaziwako abakhulelel kulendawo ==
USipho Mbele omlingisi kamabonakude nomtloli. UThando Mahlangu mthuthukisi wesiNdebele. U-August Masango owadlulako ephasini ebegade adume khulu ehlanganweni ye- African national congress. UGamela Mthombeni omkhuzeli wezemidlalo emrhatjhweni Ikwekwezi.

== Indawo le kuze njani bona ibizwe ukuthi yi Boekenhouthoek ==
Iindawo le yathiywa bona yiBoekehouthoek ngesibanga sokobana beyizele ngeenhlahla ezibizwa boan maBoekenhout trees, umdwadwa.

== Okhunye nge Boekenhouthoek ==
[[Isimumathi:Quartz-170617.jpg|thumb|umhlobo welitje eligutjwa e Boekenhouthoek]]
Indawo le izele amatje aligugu we crystal ekwenziwa ngawo imirhabiso. Abantu bayawemba amatje la bayowathengisela amakhuwa ukuze bakghone ukwenza imali yokuziphilsa. 
</text>
      <sha1>24msw8pd3wqyoi07ab1qzaywd7cw0rp</sha1>
    </revision>
    <revision>
      <id>1608</id>
      <parentid>1607</parentid>
      <timestamp>2024-10-14T13:47:51Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>7 revisions imported</comment>
      <origin>1607</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1167" sha1="24msw8pd3wqyoi07ab1qzaywd7cw0rp" xml:space="preserve">'''IBoekenhouthoek''' yindawo esezabelweni zakwaNdebele esiphandeni seMpumalanga ngaphasi kuka masipala we Thembisile hani municipality. Indawo le ayikadumi khulu ngombana kuyindawo encani ebhodwe ziintaba. Elinye igama lendawo le yiZithabiseni, la kuhlala ngobunengi abantu abamaNdebele kodwana naminye imihlobo yabantu iyatholakala. Indawo le ingaphasi kobukhosi baka Msindo ikosi eyakhathamako. 

== Abosaziwako abakhulelel kulendawo ==
USipho Mbele omlingisi kamabonakude nomtloli. UThando Mahlangu mthuthukisi wesiNdebele. U-August Masango owadlulako ephasini ebegade adume khulu ehlanganweni ye- African national congress. UGamela Mthombeni omkhuzeli wezemidlalo emrhatjhweni Ikwekwezi.

== Indawo le kuze njani bona ibizwe ukuthi yi Boekenhouthoek ==
Iindawo le yathiywa bona yiBoekehouthoek ngesibanga sokobana beyizele ngeenhlahla ezibizwa boan maBoekenhout trees, umdwadwa.

== Okhunye nge Boekenhouthoek ==
[[Isimumathi:Quartz-170617.jpg|thumb|umhlobo welitje eligutjwa e Boekenhouthoek]]
Indawo le izele amatje aligugu we crystal ekwenziwa ngawo imirhabiso. Abantu bayawemba amatje la bayowathengisela amakhuwa ukuze bakghone ukwenza imali yokuziphilsa. 
</text>
      <sha1>24msw8pd3wqyoi07ab1qzaywd7cw0rp</sha1>
    </revision>
    <revision>
      <id>2420</id>
      <parentid>1608</parentid>
      <timestamp>2025-02-17T11:12:29Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2420</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1268" sha1="rf8fv6kyvmkphgus4wwljo7bsgq8jc3" xml:space="preserve">[[Isimumathi:Ibulungelo leencwandi ye Boekenhouthoek.jpg|thumb|Ibulungelo leencwadi leBoekenhouthoek]]
'''IBoekenhouthoek''' yindawo esezabelweni zakwaNdebele esiphandeni seMpumalanga ngaphasi kuka masipala we Thembisile hani municipality. Indawo le ayikadumi khulu ngombana kuyindawo encani ebhodwe ziintaba. Elinye igama lendawo le yiZithabiseni, la kuhlala ngobunengi abantu abamaNdebele kodwana naminye imihlobo yabantu iyatholakala. Indawo le ingaphasi kobukhosi baka Msindo ikosi eyakhathamako. 

== Abosaziwako abakhulelel kulendawo ==
USipho Mbele omlingisi kamabonakude nomtloli. UThando Mahlangu mthuthukisi wesiNdebele. U-August Masango owadlulako ephasini ebegade adume khulu ehlanganweni ye- African national congress. UGamela Mthombeni omkhuzeli wezemidlalo emrhatjhweni Ikwekwezi.

== Indawo le kuze njani bona ibizwe ukuthi yi Boekenhouthoek ==
Iindawo le yathiywa bona yiBoekehouthoek ngesibanga sokobana beyizele ngeenhlahla ezibizwa boan maBoekenhout trees, umdwadwa.

== Okhunye nge Boekenhouthoek ==
[[Isimumathi:Quartz-170617.jpg|thumb|umhlobo welitje eligutjwa e Boekenhouthoek]]
Indawo le izele amatje aligugu we crystal ekwenziwa ngawo imirhabiso. Abantu bayawemba amatje la bayowathengisela amakhuwa ukuze bakghone ukwenza imali yokuziphilsa.</text>
      <sha1>rf8fv6kyvmkphgus4wwljo7bsgq8jc3</sha1>
    </revision>
  </page>
  <page>
    <title>IHendrina</title>
    <ns>0</ns>
    <id>296</id>
    <revision>
      <id>1609</id>
      <timestamp>2024-05-11T06:19:56Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''IHendrina''' yidolobha elikuMasipala Wesifunda saseNkangala, esifundazweni saseMpumalanga eNingizimu Afrika. Idolobhana lingamakhilomitha angama-53 (32.9 mi) enyakatho-ntshonalanga ye-Ermelo, amakhilomitha angama-40 (24.8 mi) eningizimu-ntshonalanga yeCarolina, kanye namakhilomitha angama-53 (32.9 mi) eningizimu-mpumalanga yeMiddelburg.  &quot;</comment>
      <origin>1609</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="343" sha1="mj72648z2qsnknns9djj53yxjrnpgyg" xml:space="preserve">'''IHendrina''' yidolobha elikuMasipala Wesifunda saseNkangala, esifundazweni saseMpumalanga eNingizimu Afrika. Idolobhana lingamakhilomitha angama-53 (32.9 mi) enyakatho-ntshonalanga ye-Ermelo, amakhilomitha angama-40 (24.8 mi) eningizimu-ntshonalanga yeCarolina, kanye namakhilomitha angama-53 (32.9 mi) eningizimu-mpumalanga yeMiddelburg.

</text>
      <sha1>mj72648z2qsnknns9djj53yxjrnpgyg</sha1>
    </revision>
    <revision>
      <id>1610</id>
      <parentid>1609</parentid>
      <timestamp>2024-10-14T13:47:51Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>1609</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="343" sha1="mj72648z2qsnknns9djj53yxjrnpgyg" xml:space="preserve">'''IHendrina''' yidolobha elikuMasipala Wesifunda saseNkangala, esifundazweni saseMpumalanga eNingizimu Afrika. Idolobhana lingamakhilomitha angama-53 (32.9 mi) enyakatho-ntshonalanga ye-Ermelo, amakhilomitha angama-40 (24.8 mi) eningizimu-ntshonalanga yeCarolina, kanye namakhilomitha angama-53 (32.9 mi) eningizimu-mpumalanga yeMiddelburg.

</text>
      <sha1>mj72648z2qsnknns9djj53yxjrnpgyg</sha1>
    </revision>
    <revision>
      <id>5224</id>
      <parentid>1610</parentid>
      <timestamp>2025-08-23T20:41:52Z</timestamp>
      <contributor>
        <username>Mojonom</username>
        <id>593</id>
      </contributor>
      <comment>added quite a number of things I have gotten from the English part of the  website.</comment>
      <origin>5224</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1452" sha1="4yyfuvueibxasfpg2jj12kav91j5gyn" xml:space="preserve">

'''IHendrina''' yidorobha elikumasipala we [[:en:Steve_Tshwete_Local_Municipality|Steve Tshwete]], ongaphasi kwesifunda se[[:en:Nkangala_District_Municipality|Nkangala]] esifundeni se[[:en:Mpumalanga|Mpumalanga]] e[[Isewula Afrika|Sewula Afrika]]. Idorojaneli, litholakala ngemva kwamakhilomitha ama-53 etlhagwini-tjhingalanga yedorobha i Ermelo, godu, liphinde litholakale ngemva kwamakhilomitha ama-40 esewula-tjhingalanga yedorobha i[[Carolina]]. Kanti liphinde litholakale ngemva kwama khilomitha ama 53 esewula yedorobha i [[:en:Middelburg,_Mpumalanga|Middleburg.]]

== Umlando wedorobha ==
Idorobha le Hendrina lathoma ukuba khona ngomnyaka we-1914 eplasini ekhabe libizwa nge [[Garsfontein Farm]]. Kulidorobha elithiyelelwe ngo [[Hendrina Beukes]], ekumfazi ka [[Gert Beukes]]. uGert Beukes bekumnikazi wokuthoma weplasi i Garsfontein. Yize kunjalo, abaphathi abakhulu  ekhabe bengamele idorobheli khabe kuyikomidi yezepilo kunye nesigungu sendawo ngomnyaka we-1919 kuya emnyakeni we -1926.

== Umnotho ==
Umnotho omkhulu ofunyaneka edorobheni iHendrina utholakala emamayini wamalahle atholakala eendaweni ezitjhidelene nedorobheli. Godu kunamaplasi amanengi,  lapha kutjalwa khona iintjalo ezifana namabhontjisi, amazambana kunye nomthombo. Kuyindawo eneentetjhi ezimbili ezikulu eziphehla igezi eziphethwe ngezinye zeenkampani ezikulu enarheni yeSewula Afrika i-Eskom. Iintetjhi lezo ziyi Arnot Power Station Kunye ne Hendrina Power Station.</text>
      <sha1>4yyfuvueibxasfpg2jj12kav91j5gyn</sha1>
    </revision>
  </page>
  <page>
    <title>IKrugersdorp</title>
    <ns>0</ns>
    <id>297</id>
    <revision>
      <id>1611</id>
      <timestamp>2024-05-09T18:19:56Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''I-Krugersdorp''' (isiBhunu se-Kruger's Village) iyidolobha elinezimayini eWest Rand, eSifundazweni saseGauteng, eNingizimu Afrika eyasungulwa ngo-1887[2] nguMarthinus Pretorius kanye no-Abner Cohen.[3] Ngemva kokutholakala kwegolide eWitwatersrand, kwavela isidingo sedolobha elikhulu elisentshonalanga yolwandle. Uhulumeni wathenga ingxenye yepulazi lasePaardekraal futhi waliqamba leli dolobha elisha ngomongameli waseTransvaal, uPaul Kruger. I-Krugersdorp ayisenaye uhu...&quot;</comment>
      <origin>1611</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="639" sha1="2leywiratcz8t4y80tysucp68hnw4nq" xml:space="preserve">'''I-Krugersdorp''' (isiBhunu se-Kruger's Village) iyidolobha elinezimayini eWest Rand, eSifundazweni saseGauteng, eNingizimu Afrika eyasungulwa ngo-1887[2] nguMarthinus Pretorius kanye no-Abner Cohen.[3] Ngemva kokutholakala kwegolide eWitwatersrand, kwavela isidingo sedolobha elikhulu elisentshonalanga yolwandle. Uhulumeni wathenga ingxenye yepulazi lasePaardekraal futhi waliqamba leli dolobha elisha ngomongameli waseTransvaal, uPaul Kruger. I-Krugersdorp ayisenaye uhulumeni kamasipala ohlukile ngemuva kokuthi uhlanganiswe noMasipala Wendawo waseMogale City kanye namadolobha aseduze. Manje sekuyisizinda sikahulumeni eMogale City.</text>
      <sha1>2leywiratcz8t4y80tysucp68hnw4nq</sha1>
    </revision>
    <revision>
      <id>1612</id>
      <parentid>1611</parentid>
      <timestamp>2024-10-14T13:47:51Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>1611</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="639" sha1="2leywiratcz8t4y80tysucp68hnw4nq" xml:space="preserve">'''I-Krugersdorp''' (isiBhunu se-Kruger's Village) iyidolobha elinezimayini eWest Rand, eSifundazweni saseGauteng, eNingizimu Afrika eyasungulwa ngo-1887[2] nguMarthinus Pretorius kanye no-Abner Cohen.[3] Ngemva kokutholakala kwegolide eWitwatersrand, kwavela isidingo sedolobha elikhulu elisentshonalanga yolwandle. Uhulumeni wathenga ingxenye yepulazi lasePaardekraal futhi waliqamba leli dolobha elisha ngomongameli waseTransvaal, uPaul Kruger. I-Krugersdorp ayisenaye uhulumeni kamasipala ohlukile ngemuva kokuthi uhlanganiswe noMasipala Wendawo waseMogale City kanye namadolobha aseduze. Manje sekuyisizinda sikahulumeni eMogale City.</text>
      <sha1>2leywiratcz8t4y80tysucp68hnw4nq</sha1>
    </revision>
  </page>
  <page>
    <title>IRandfontein</title>
    <ns>0</ns>
    <id>298</id>
    <revision>
      <id>1613</id>
      <timestamp>2024-05-09T18:17:23Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;I-Randfontein iyidolobha lezimayini zegolide eWest Rand, Gauteng, South Africa, 40 km (25 mi) entshonalanga yeGoli. Njengoba iWitwatersrand igiya igolide, umxhasi wezimayini u-JB Robinson wathenga ipulazi i-Randfontein futhi, ngo-1889, wantanta i-Randfontein Estates Gold Mining Company. Idolobhana lasungulwa ngo-1890 ukuze lisebenzele imayini entsha futhi laphathwa yi-Krugersdorp laze laba umasipala ngo-1929.[2]: 292  Ngaphandle kokuba nemboni yokugaya izitembu enkul...&quot;</comment>
      <origin>1613</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="683" sha1="g13fyxy6mbuo8yyukorwpeii2hesjm3" xml:space="preserve">I-Randfontein iyidolobha lezimayini zegolide eWest Rand, Gauteng, South Africa, 40 km (25 mi) entshonalanga yeGoli. Njengoba iWitwatersrand igiya igolide, umxhasi wezimayini u-JB Robinson wathenga ipulazi i-Randfontein futhi, ngo-1889, wantanta i-Randfontein Estates Gold Mining Company. Idolobhana lasungulwa ngo-1890 ukuze lisebenzele imayini entsha futhi laphathwa yi-Krugersdorp laze laba umasipala ngo-1929.[2]: 292  Ngaphandle kokuba nemboni yokugaya izitembu enkulu kunazo zonke emhlabeni, iRandfontein, njengezinye izindawo eziningi ezingaphandle kwedolobha. I-Johannesburg, empeleni iqoqo lasemaphandleni lamapulazi nezindawo ezincane endaweni enhle kakhulu yaseGauteng.</text>
      <sha1>g13fyxy6mbuo8yyukorwpeii2hesjm3</sha1>
    </revision>
    <revision>
      <id>1614</id>
      <parentid>1613</parentid>
      <timestamp>2024-05-09T18:17:34Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1614</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="689" sha1="4427i1dvw3vb7q1wnc1sk8eaitkbuhz" xml:space="preserve">'''I-Randfontein''' iyidolobha lezimayini zegolide eWest Rand, Gauteng, South Africa, 40 km (25 mi) entshonalanga yeGoli. Njengoba iWitwatersrand igiya igolide, umxhasi wezimayini u-JB Robinson wathenga ipulazi i-Randfontein futhi, ngo-1889, wantanta i-Randfontein Estates Gold Mining Company. Idolobhana lasungulwa ngo-1890 ukuze lisebenzele imayini entsha futhi laphathwa yi-Krugersdorp laze laba umasipala ngo-1929.[2]: 292  Ngaphandle kokuba nemboni yokugaya izitembu enkulu kunazo zonke emhlabeni, iRandfontein, njengezinye izindawo eziningi ezingaphandle kwedolobha. I-Johannesburg, empeleni iqoqo lasemaphandleni lamapulazi nezindawo ezincane endaweni enhle kakhulu yaseGauteng.</text>
      <sha1>4427i1dvw3vb7q1wnc1sk8eaitkbuhz</sha1>
    </revision>
    <revision>
      <id>1615</id>
      <parentid>1614</parentid>
      <timestamp>2024-10-14T13:47:51Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>1614</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="689" sha1="4427i1dvw3vb7q1wnc1sk8eaitkbuhz" xml:space="preserve">'''I-Randfontein''' iyidolobha lezimayini zegolide eWest Rand, Gauteng, South Africa, 40 km (25 mi) entshonalanga yeGoli. Njengoba iWitwatersrand igiya igolide, umxhasi wezimayini u-JB Robinson wathenga ipulazi i-Randfontein futhi, ngo-1889, wantanta i-Randfontein Estates Gold Mining Company. Idolobhana lasungulwa ngo-1890 ukuze lisebenzele imayini entsha futhi laphathwa yi-Krugersdorp laze laba umasipala ngo-1929.[2]: 292  Ngaphandle kokuba nemboni yokugaya izitembu enkulu kunazo zonke emhlabeni, iRandfontein, njengezinye izindawo eziningi ezingaphandle kwedolobha. I-Johannesburg, empeleni iqoqo lasemaphandleni lamapulazi nezindawo ezincane endaweni enhle kakhulu yaseGauteng.</text>
      <sha1>4427i1dvw3vb7q1wnc1sk8eaitkbuhz</sha1>
    </revision>
    <revision>
      <id>3021</id>
      <parentid>1615</parentid>
      <timestamp>2025-06-06T20:30:13Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>ihrtgeyfuer658fchtc78sfe</comment>
      <origin>3021</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="770" sha1="fggkclf9p70mb0gm06uj8roalm0iyfs" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. I-Randfontein''' iyidolobha lezimayini zegolide eWest Rand, Gauteng, South Africa, 40 km (25 mi) entshonalanga yeGoli. Njengoba iWitwatersrand igiya igolide, umxhasi wezimayini u-JB Robinson wathenga ipulazi i-Randfontein futhi, ngo-1889, wantanta i-Randfontein Estates Gold Mining Company. Idolobhana lasungulwa ngo-1890 ukuze lisebenzele imayini entsha futhi laphathwa yi-Krugersdorp laze laba umasipala ngo-1929.[2]: 292  Ngaphandle kokuba nemboni yokugaya izitembu enkulu kunazo zonke emhlabeni, iRandfontein, njengezinye izindawo eziningi ezingaphandle kwedolobha. I-Johannesburg, empeleni iqoqo lasemaphandleni lamapulazi nezindawo ezincane endaweni enhle kakhulu yaseGauteng.</text>
      <sha1>fggkclf9p70mb0gm06uj8roalm0iyfs</sha1>
    </revision>
    <revision>
      <id>3149</id>
      <parentid>3021</parentid>
      <timestamp>2025-06-07T03:05:25Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Jon Harald Søby|Jon Harald Søby]]</comment>
      <origin>1614</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="689" sha1="4427i1dvw3vb7q1wnc1sk8eaitkbuhz" xml:space="preserve">'''I-Randfontein''' iyidolobha lezimayini zegolide eWest Rand, Gauteng, South Africa, 40 km (25 mi) entshonalanga yeGoli. Njengoba iWitwatersrand igiya igolide, umxhasi wezimayini u-JB Robinson wathenga ipulazi i-Randfontein futhi, ngo-1889, wantanta i-Randfontein Estates Gold Mining Company. Idolobhana lasungulwa ngo-1890 ukuze lisebenzele imayini entsha futhi laphathwa yi-Krugersdorp laze laba umasipala ngo-1929.[2]: 292  Ngaphandle kokuba nemboni yokugaya izitembu enkulu kunazo zonke emhlabeni, iRandfontein, njengezinye izindawo eziningi ezingaphandle kwedolobha. I-Johannesburg, empeleni iqoqo lasemaphandleni lamapulazi nezindawo ezincane endaweni enhle kakhulu yaseGauteng.</text>
      <sha1>4427i1dvw3vb7q1wnc1sk8eaitkbuhz</sha1>
    </revision>
  </page>
  <page>
    <title>IVaalbank</title>
    <ns>0</ns>
    <id>299</id>
    <revision>
      <id>1616</id>
      <timestamp>2024-05-09T18:13:25Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;IVaalbank (ebuye yaziwe ngokuthi iLibangeni) iyidolobha elincane eliqhele ngamakhilomitha ayi-102 enyakatho-mpumalanga yePitoli. Idolobhana libalulekile enyakatho-ntshonalanga yeMpumalanga lapho iningi labantu elizungezile lisemaphandleni futhi lingenayo ingqalasizinda. Ibheke iDamu laseMkhombo (elalibizwa ngeRenosterkop Dam) elibaluleke kakhulu kwezolimo esifundeni.  &quot;</comment>
      <origin>1616</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="371" sha1="khftc5b030ssf1lvsys8xucs945ysbi" xml:space="preserve">IVaalbank (ebuye yaziwe ngokuthi iLibangeni) iyidolobha elincane eliqhele ngamakhilomitha ayi-102 enyakatho-mpumalanga yePitoli. Idolobhana libalulekile enyakatho-ntshonalanga yeMpumalanga lapho iningi labantu elizungezile lisemaphandleni futhi lingenayo ingqalasizinda. Ibheke iDamu laseMkhombo (elalibizwa ngeRenosterkop Dam) elibaluleke kakhulu kwezolimo esifundeni.

</text>
      <sha1>khftc5b030ssf1lvsys8xucs945ysbi</sha1>
    </revision>
    <revision>
      <id>1617</id>
      <parentid>1616</parentid>
      <timestamp>2024-05-09T18:13:41Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1617</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="377" sha1="ebnkpyo7ebpdojn9c7l4poq4v9km70u" xml:space="preserve">'''IVaalbank''' (ebuye yaziwe ngokuthi iLibangeni) iyidolobha elincane eliqhele ngamakhilomitha ayi-102 enyakatho-mpumalanga yePitoli. Idolobhana libalulekile enyakatho-ntshonalanga yeMpumalanga lapho iningi labantu elizungezile lisemaphandleni futhi lingenayo ingqalasizinda. Ibheke iDamu laseMkhombo (elalibizwa ngeRenosterkop Dam) elibaluleke kakhulu kwezolimo esifundeni.

</text>
      <sha1>ebnkpyo7ebpdojn9c7l4poq4v9km70u</sha1>
    </revision>
    <revision>
      <id>1618</id>
      <parentid>1617</parentid>
      <timestamp>2024-10-14T13:47:51Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>1617</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="377" sha1="ebnkpyo7ebpdojn9c7l4poq4v9km70u" xml:space="preserve">'''IVaalbank''' (ebuye yaziwe ngokuthi iLibangeni) iyidolobha elincane eliqhele ngamakhilomitha ayi-102 enyakatho-mpumalanga yePitoli. Idolobhana libalulekile enyakatho-ntshonalanga yeMpumalanga lapho iningi labantu elizungezile lisemaphandleni futhi lingenayo ingqalasizinda. Ibheke iDamu laseMkhombo (elalibizwa ngeRenosterkop Dam) elibaluleke kakhulu kwezolimo esifundeni.

</text>
      <sha1>ebnkpyo7ebpdojn9c7l4poq4v9km70u</sha1>
    </revision>
  </page>
  <page>
    <title>Ilimi lesindebele</title>
    <ns>0</ns>
    <id>300</id>
    <revision>
      <id>1619</id>
      <timestamp>2024-03-08T13:38:09Z</timestamp>
      <contributor>
        <username>incubator&gt;ThokozaniSlaki</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;Abarhatjhi bethu abasirhatjhela ngelimi lesiNdebele kiyo yoke imirhatjho lokha nabadobha umlaleli wokugcina emoyeni kumele bafundiswe namkha batjelwe bona akhebalise ukuthi (&quot;ngithatha wokuphela&quot;), akusiyo indlela yesiNdebele le. Ibinzana elithi (wokuphela) is the direct translation of Sotho/Sepedi language( wa bofelo) which means the last one. NgesiNdebele sithi (Wokugcina) ngombana kulapho sele ugcina khona ngomlaleli loya omdobhako. Ugcina ngaye kodwana awuphelelisi n...&quot;</comment>
      <origin>1619</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="525" sha1="i4ka419j0p8rjuaa7w4v608kxz779ze" xml:space="preserve">Abarhatjhi bethu abasirhatjhela ngelimi lesiNdebele kiyo yoke imirhatjho lokha nabadobha umlaleli wokugcina emoyeni kumele bafundiswe namkha batjelwe bona akhebalise ukuthi (&quot;ngithatha wokuphela&quot;), akusiyo indlela yesiNdebele le. Ibinzana elithi (wokuphela) is the direct translation of Sotho/Sepedi language( wa bofelo) which means the last one. NgesiNdebele sithi (Wokugcina) ngombana kulapho sele ugcina khona ngomlaleli loya omdobhako. Ugcina ngaye kodwana awuphelelisi ngaye. IsiNdebele asiphelelisi kodwana siyagcina.

</text>
      <sha1>i4ka419j0p8rjuaa7w4v608kxz779ze</sha1>
    </revision>
    <revision>
      <id>1620</id>
      <parentid>1619</parentid>
      <timestamp>2024-03-09T07:30:08Z</timestamp>
      <contributor>
        <username>incubator&gt;JesicaMasilela17</username>
        <id>0</id>
      </contributor>
      <origin>1620</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="529" sha1="fpzwxhc6sene030polcrckongklkgc3" xml:space="preserve">Abarhatjhi bethu abasirhatjhela [[ngelimiiNdebele]] ki lesyo yoke imirhatjho lokha nabadobha umlaleli wokugcina emoyeni kumele bafundiswe namkha batjelwe bona akhebalise ukuthi (&quot;ngithatha wokuphela&quot;), akusiyo indlela yesiNdebele le. Ibinzana elithi (wokuphela) is the direct translation of Sotho/Sepedi language( wa bofelo) which means the last one. NgesiNdebele sithi (Wokugcina) ngombana kulapho sele ugcina khona ngomlaleli loya omdobhako. Ugcina ngaye kodwana awuphelelisi ngaye. IsiNdebele asiphelelisi kodwana siyagcina.

</text>
      <sha1>fpzwxhc6sene030polcrckongklkgc3</sha1>
    </revision>
    <revision>
      <id>1621</id>
      <parentid>1620</parentid>
      <timestamp>2024-03-09T08:23:23Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1621</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="621" sha1="43eb4b5ct4mce819t3vg3p84jcwh27m" xml:space="preserve">[[Isimumathi:Indoni Parade 2018, Ndebele Kingdom by Sizwe Sibiya (4).jpg|thumb|AmaNdebele]]
Abarhatjhi bethu abasirhatjhela [[ngelimiiNdebele]] ki lesyo yoke imirhatjho lokha nabadobha umlaleli wokugcina emoyeni kumele bafundiswe namkha batjelwe bona akhebalise ukuthi (&quot;ngithatha wokuphela&quot;), akusiyo indlela yesiNdebele le. Ibinzana elithi (wokuphela) is the direct translation of Sotho/Sepedi language( wa bofelo) which means the last one. NgesiNdebele sithi (Wokugcina) ngombana kulapho sele ugcina khona ngomlaleli loya omdobhako. Ugcina ngaye kodwana awuphelelisi ngaye. IsiNdebele asiphelelisi kodwana siyagcina.

</text>
      <sha1>43eb4b5ct4mce819t3vg3p84jcwh27m</sha1>
    </revision>
    <revision>
      <id>1622</id>
      <parentid>1621</parentid>
      <timestamp>2024-10-14T13:47:51Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>1621</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="621" sha1="43eb4b5ct4mce819t3vg3p84jcwh27m" xml:space="preserve">[[Isimumathi:Indoni Parade 2018, Ndebele Kingdom by Sizwe Sibiya (4).jpg|thumb|AmaNdebele]]
Abarhatjhi bethu abasirhatjhela [[ngelimiiNdebele]] ki lesyo yoke imirhatjho lokha nabadobha umlaleli wokugcina emoyeni kumele bafundiswe namkha batjelwe bona akhebalise ukuthi (&quot;ngithatha wokuphela&quot;), akusiyo indlela yesiNdebele le. Ibinzana elithi (wokuphela) is the direct translation of Sotho/Sepedi language( wa bofelo) which means the last one. NgesiNdebele sithi (Wokugcina) ngombana kulapho sele ugcina khona ngomlaleli loya omdobhako. Ugcina ngaye kodwana awuphelelisi ngaye. IsiNdebele asiphelelisi kodwana siyagcina.

</text>
      <sha1>43eb4b5ct4mce819t3vg3p84jcwh27m</sha1>
    </revision>
    <revision>
      <id>2974</id>
      <parentid>1622</parentid>
      <timestamp>2025-06-06T20:02:58Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>ymuyhtgrtfhjythrg</comment>
      <origin>2974</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="706" sha1="9apa8sebihmcnh9qu0j1yiqspc19jvw" xml:space="preserve">[[Isimumathi:Indoni Parade 2018, Ndebele Kingdom by Sizwe Sibiya (4).jpg|thumb|AmaNdebele]]
'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.''' Abarhatjhi bethu abasirhatjhela [[ngelimiiNdebele]] ki lesyo yoke imirhatjho lokha nabadobha umlaleli wokugcina emoyeni kumele bafundiswe namkha batjelwe bona akhebalise ukuthi (&quot;ngithatha wokuphela&quot;), akusiyo indlela yesiNdebele le. Ibinzana elithi (wokuphela) is the direct translation of Sotho/Sepedi language( wa bofelo) which means the last one. NgesiNdebele sithi (Wokugcina) ngombana kulapho sele ugcina khona ngomlaleli loya omdobhako. Ugcina ngaye kodwana awuphelelisi ngaye. IsiNdebele asiphelelisi kodwana siyagcina.</text>
      <sha1>9apa8sebihmcnh9qu0j1yiqspc19jvw</sha1>
    </revision>
    <revision>
      <id>3086</id>
      <parentid>2974</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Jon Harald Søby|Jon Harald Søby]]</comment>
      <origin>1621</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="621" sha1="43eb4b5ct4mce819t3vg3p84jcwh27m" xml:space="preserve">[[Isimumathi:Indoni Parade 2018, Ndebele Kingdom by Sizwe Sibiya (4).jpg|thumb|AmaNdebele]]
Abarhatjhi bethu abasirhatjhela [[ngelimiiNdebele]] ki lesyo yoke imirhatjho lokha nabadobha umlaleli wokugcina emoyeni kumele bafundiswe namkha batjelwe bona akhebalise ukuthi (&quot;ngithatha wokuphela&quot;), akusiyo indlela yesiNdebele le. Ibinzana elithi (wokuphela) is the direct translation of Sotho/Sepedi language( wa bofelo) which means the last one. NgesiNdebele sithi (Wokugcina) ngombana kulapho sele ugcina khona ngomlaleli loya omdobhako. Ugcina ngaye kodwana awuphelelisi ngaye. IsiNdebele asiphelelisi kodwana siyagcina.

</text>
      <sha1>43eb4b5ct4mce819t3vg3p84jcwh27m</sha1>
    </revision>
  </page>
  <page>
    <title>Intuthuko yethelerina</title>
    <ns>0</ns>
    <id>301</id>
    <revision>
      <id>1623</id>
      <timestamp>2024-03-09T10:17:25Z</timestamp>
      <contributor>
        <username>incubator&gt;LindiweSiba</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Ituthuko yethelerina''', isigaba somntazinyana mntazinyana ongakarhabi ukuphuhla amabele. Umntazinyana umbatha umrivathi nerhabi Koreans irhabi lathe alifani nerhabi letlawana begodu alifani nerhabi lethelerina. Umntazinyana uvunula nesikotjhi ngombana bayasizila isithimba ngombana angakenzi isiko namkha akakenzelwa umnyanya wequde.   '''Amatlawana''' Itlawana mntazana osele athoma ukuphuhla amabele. Itlawana lona livunulo irhabi elinomncamo nomadalanyana umadalanyana...&quot;</comment>
      <origin>1623</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="781" sha1="gwbqguvguebyue54cqc6248vfnsag00" xml:space="preserve">'''Ituthuko yethelerina''', isigaba somntazinyana mntazinyana ongakarhabi ukuphuhla amabele. Umntazinyana umbatha umrivathi nerhabi Koreans irhabi lathe alifani nerhabi letlawana begodu alifani nerhabi lethelerina. Umntazinyana uvunula nesikotjhi ngombana bayasizila isithimba ngombana angakenzi isiko namkha akakenzelwa umnyanya wequde. 

'''Amatlawana'''
Itlawana mntazana osele athoma ukuphuhla amabele. Itlawana lona livunulo irhabi elinomncamo nomadalanyana umadalanyana yithawula ephothelwe ngomncamo neenrholwane zedinini ukuba nobukhobe nemidzegana emlenzeni.

'''Ithelerina'''
Ithelerina mntazana osele athombile owenzelwe umnyanya wequde. Ithelerina livunula irholoro epheleleko, iinrholwane zeenyaweni,iphephethu nesithimba kanye neenrholwane zedinini ijuba nobukhobe.

</text>
      <sha1>gwbqguvguebyue54cqc6248vfnsag00</sha1>
    </revision>
    <revision>
      <id>1624</id>
      <parentid>1623</parentid>
      <timestamp>2024-03-09T10:31:53Z</timestamp>
      <contributor>
        <username>incubator&gt;LindiweSiba</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1624</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="805" sha1="00id3hlo199wi1pawicik5mf5b2b03g" xml:space="preserve">'''Ituthuko yethelerina''', isigaba somntazinyana mntazinyana ongakarhabi ukuphuhla amabele. Umntazinyana umbatha umrivathi nerhabi kodwana irhabi lakhe alifani nerhabi letlawana begodu alifani nerhabi lethelerina. Umntazinyana uvunula nesikotjhi ngombana bayasizila isithimba ngombana angakenzi isiko namkha akakenzelwa umnyanya we[[Iqude leSindebele|qude]]. 

'''Amatlawana'''

Itlawana mntazana osele athoma ukuphuhla amabele. Itlawana lona livunulo irhabi elinomncamo nomadalanyana umadalanyana yithawula ephothelwe ngomncamo neenrholwane zedinini ukuba nobukhobe nemidzegana emlenzeni.

'''Ithelerina'''

Ithelerina mntazana osele athombile owenzelwe umnyanya wequde. Ithelerina livunula irholoro epheleleko, iinrholwane zeenyaweni,iphephethu nesithimba kanye neenrholwane zedinini ijuba nobukhobe.

</text>
      <sha1>00id3hlo199wi1pawicik5mf5b2b03g</sha1>
    </revision>
    <revision>
      <id>1625</id>
      <parentid>1624</parentid>
      <timestamp>2024-03-09T10:40:24Z</timestamp>
      <contributor>
        <username>incubator&gt;LindiweSiba</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1625</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="862" sha1="f4ml1fccm7rlawl0aldq73is0s03gbx" xml:space="preserve">[[Isimumathi:Ithelerina.jpg|thumb|Ituthuko yethelerina]]
'''Ituthuko yethelerina''', isigaba somntazinyana mntazinyana ongakarhabi ukuphuhla amabele. Umntazinyana umbatha umrivathi nerhabi kodwana irhabi lakhe alifani nerhabi letlawana begodu alifani nerhabi lethelerina. Umntazinyana uvunula nesikotjhi ngombana bayasizila isithimba ngombana angakenzi isiko namkha akakenzelwa umnyanya we[[Iqude leSindebele|qude]]. 

'''Amatlawana'''

Itlawana mntazana osele athoma ukuphuhla amabele. Itlawana lona livunulo irhabi elinomncamo nomadalanyana umadalanyana yithawula ephothelwe ngomncamo neenrholwane zedinini ukuba nobukhobe nemidzegana emlenzeni.

'''Ithelerina'''

Ithelerina mntazana osele athombile owenzelwe umnyanya wequde. Ithelerina livunula irholoro epheleleko, iinrholwane zeenyaweni,iphephethu nesithimba kanye neenrholwane zedinini ijuba nobukhobe.

</text>
      <sha1>f4ml1fccm7rlawl0aldq73is0s03gbx</sha1>
    </revision>
    <revision>
      <id>1626</id>
      <parentid>1625</parentid>
      <timestamp>2024-03-09T10:51:31Z</timestamp>
      <contributor>
        <username>incubator&gt;LindiweSiba</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1626</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="913" sha1="js289sovmipzkaoj59r1bpeb0811cc9" xml:space="preserve">[[Isimumathi:Ithelerina.jpg|thumb|Ituthuko yethelerina]]
'''Ituthuko yethelerina''', isigaba somntazinyana mntazinyana ongakarhabi ukuphuhla amabele. Umntazinyana umbatha umrivathi nerhabi kodwana irhabi lakhe alifani nerhabi letlawana begodu alifani nerhabi lethelerina. Umntazinyana uvunula nesikotjhi ngombana bayasizila isithimba ngombana angakenzi isiko namkha akakenzelwa umnyanya we[[Iqude leSindebele|qude]]. 

'''Amatlawana'''

Itlawana mntazana osele athoma ukuphuhla amabele. Itlawana lona livunulo irhabi elinomncamo nomadalanyana umadalanyana yithawula ephothelwe ngomncamo neenrholwane zedinini ukuba nobukhobe nemidzegana emlenzeni.

'''Ithelerina'''

Ithelerina mntazana osele athombile owenzelwe umnyanya wequde. Ithelerina livunula irholoro epheleleko, iinrholwane zeenyaweni,iphephethu nesithimba kanye neenrholwane zedinini ijuba nobukhobe. Entanyeni bese ithelerina lifaka iraso nesijogana.

</text>
      <sha1>js289sovmipzkaoj59r1bpeb0811cc9</sha1>
    </revision>
    <revision>
      <id>1627</id>
      <parentid>1626</parentid>
      <timestamp>2024-10-14T13:47:52Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>4 revisions imported</comment>
      <origin>1626</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="913" sha1="js289sovmipzkaoj59r1bpeb0811cc9" xml:space="preserve">[[Isimumathi:Ithelerina.jpg|thumb|Ituthuko yethelerina]]
'''Ituthuko yethelerina''', isigaba somntazinyana mntazinyana ongakarhabi ukuphuhla amabele. Umntazinyana umbatha umrivathi nerhabi kodwana irhabi lakhe alifani nerhabi letlawana begodu alifani nerhabi lethelerina. Umntazinyana uvunula nesikotjhi ngombana bayasizila isithimba ngombana angakenzi isiko namkha akakenzelwa umnyanya we[[Iqude leSindebele|qude]]. 

'''Amatlawana'''

Itlawana mntazana osele athoma ukuphuhla amabele. Itlawana lona livunulo irhabi elinomncamo nomadalanyana umadalanyana yithawula ephothelwe ngomncamo neenrholwane zedinini ukuba nobukhobe nemidzegana emlenzeni.

'''Ithelerina'''

Ithelerina mntazana osele athombile owenzelwe umnyanya wequde. Ithelerina livunula irholoro epheleleko, iinrholwane zeenyaweni,iphephethu nesithimba kanye neenrholwane zedinini ijuba nobukhobe. Entanyeni bese ithelerina lifaka iraso nesijogana.

</text>
      <sha1>js289sovmipzkaoj59r1bpeb0811cc9</sha1>
    </revision>
  </page>
  <page>
    <title>Isibonelelo se350</title>
    <ns>0</ns>
    <id>302</id>
    <revision>
      <id>1628</id>
      <timestamp>2024-07-05T16:15:09Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''Isibonelo se 350''' yimali evela kurhulumende ukulekelela abantu abangasebenzi Sewula Afrika.  &quot;</comment>
      <origin>1628</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="98" sha1="ly47ieo6vc6qvo7e36o8ew9zmkbvgpj" xml:space="preserve">'''Isibonelo se 350''' yimali evela kurhulumende ukulekelela abantu abangasebenzi Sewula Afrika.

</text>
      <sha1>ly47ieo6vc6qvo7e36o8ew9zmkbvgpj</sha1>
    </revision>
    <revision>
      <id>1629</id>
      <parentid>1628</parentid>
      <timestamp>2024-07-05T18:56:56Z</timestamp>
      <contributor>
        <username>incubator&gt;Nqobile69</username>
        <id>0</id>
      </contributor>
      <origin>1629</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="425" sha1="jynh34pno0cvsf6ydhbqccopgv5amxk" xml:space="preserve">'''Isibonelelo se 350''' yimali evela kurhulumende ukulekelela abantu abangasebenzi Sewula Afrika. Imali le yathoma ukurholwa babantu abangasebenzi ngonyaka we-2020 lokha nakufika ingogwana ye covid-19 enarheni le. Imali yaragelwa phambili yarholwa kuze kube nje. 

Imali le ibalekelele khulu abantu abanga sebenzi ngombana bakghona ukuziphilisa njengombana izinga lokungasebenzi  liphezulu begodu nezinto ziyabiza eentolo.

</text>
      <sha1>jynh34pno0cvsf6ydhbqccopgv5amxk</sha1>
    </revision>
    <revision>
      <id>1630</id>
      <parentid>1629</parentid>
      <timestamp>2024-10-14T13:47:52Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>1629</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="425" sha1="jynh34pno0cvsf6ydhbqccopgv5amxk" xml:space="preserve">'''Isibonelelo se 350''' yimali evela kurhulumende ukulekelela abantu abangasebenzi Sewula Afrika. Imali le yathoma ukurholwa babantu abangasebenzi ngonyaka we-2020 lokha nakufika ingogwana ye covid-19 enarheni le. Imali yaragelwa phambili yarholwa kuze kube nje. 

Imali le ibalekelele khulu abantu abanga sebenzi ngombana bakghona ukuziphilisa njengombana izinga lokungasebenzi  liphezulu begodu nezinto ziyabiza eentolo.

</text>
      <sha1>jynh34pno0cvsf6ydhbqccopgv5amxk</sha1>
    </revision>
  </page>
  <page>
    <title>Sadilar</title>
    <ns>0</ns>
    <id>303</id>
    <redirect title="SADiLaR" />
    <revision>
      <id>1631</id>
      <timestamp>2024-03-10T20:35:59Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Bobbyshabangu moved page [[sadilar]] to [[SADiLaR]]: This is the correct acronym of the organisation. </comment>
      <origin>1631</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="21" sha1="sgq40d6xl3b4wpfmaqk40x3zj0wv5bj" xml:space="preserve">#REDIRECT [[SADiLaR]]</text>
      <sha1>sgq40d6xl3b4wpfmaqk40x3zj0wv5bj</sha1>
    </revision>
    <revision>
      <id>1632</id>
      <parentid>1631</parentid>
      <timestamp>2024-10-14T13:47:52Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>1631</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="21" sha1="sgq40d6xl3b4wpfmaqk40x3zj0wv5bj" xml:space="preserve">#REDIRECT [[SADiLaR]]</text>
      <sha1>sgq40d6xl3b4wpfmaqk40x3zj0wv5bj</sha1>
    </revision>
  </page>
  <page>
    <title>UPaul Kruger</title>
    <ns>0</ns>
    <id>304</id>
    <revision>
      <id>1633</id>
      <timestamp>2024-05-09T18:22:31Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;'''UStephanus Johannes Paulus Kruger''' (iphimbo lesiBhunu: [ˈkry.(j)ər]; 10 Okthoba 1825 - 14 Julayi 1904), owaziwa kangcono njengoPaul Kruger, wayengusopolitiki waseNingizimu Afrika. Wayengomunye wabantu ababeqavile kwezombangazwe nezempi eNingizimu Afrika ngekhulu le-19, kanye noMongameli Wezwe WaseNingizimu Afrika (noma iTransvaal) kusukela ngo-1883 kuya ku-1900. Eqanjwe ngokuthi u-Oom Paul (&quot;Uncle Paul&quot;), waduma emhlabeni wonke njengo. ubuso bembangela yamaBhunu...&quot;</comment>
      <origin>1633</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="732" sha1="m65lrkxh2fj2ig05pc6qlv89yl5np8o" xml:space="preserve">'''UStephanus Johannes Paulus Kruger''' (iphimbo lesiBhunu: [ˈkry.(j)ər]; 10 Okthoba 1825 - 14 Julayi 1904), owaziwa kangcono njengoPaul Kruger, wayengusopolitiki waseNingizimu Afrika. Wayengomunye wabantu ababeqavile kwezombangazwe nezempi eNingizimu Afrika ngekhulu le-19, kanye noMongameli Wezwe WaseNingizimu Afrika (noma iTransvaal) kusukela ngo-1883 kuya ku-1900. Eqanjwe ngokuthi u-Oom Paul (&quot;Uncle Paul&quot;), waduma emhlabeni wonke njengo. ubuso bembangela yamaBhunu—leyo yaseTransvaal kanye nomakhelwane wayo i-Orange Free State—ibhekene neBrithani phakathi neMpi Yesibili yamaBhunu ka-1899–1902. Uke wabizwa nge-Afrikanerdom, futhi usengumuntu ophikisanayo; abathandwayo bamhlonipha njengeqhawe lesintu elidabukisayo.</text>
      <sha1>m65lrkxh2fj2ig05pc6qlv89yl5np8o</sha1>
    </revision>
    <revision>
      <id>1634</id>
      <parentid>1633</parentid>
      <timestamp>2024-10-14T13:47:52Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>1 revision imported</comment>
      <origin>1633</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="732" sha1="m65lrkxh2fj2ig05pc6qlv89yl5np8o" xml:space="preserve">'''UStephanus Johannes Paulus Kruger''' (iphimbo lesiBhunu: [ˈkry.(j)ər]; 10 Okthoba 1825 - 14 Julayi 1904), owaziwa kangcono njengoPaul Kruger, wayengusopolitiki waseNingizimu Afrika. Wayengomunye wabantu ababeqavile kwezombangazwe nezempi eNingizimu Afrika ngekhulu le-19, kanye noMongameli Wezwe WaseNingizimu Afrika (noma iTransvaal) kusukela ngo-1883 kuya ku-1900. Eqanjwe ngokuthi u-Oom Paul (&quot;Uncle Paul&quot;), waduma emhlabeni wonke njengo. ubuso bembangela yamaBhunu—leyo yaseTransvaal kanye nomakhelwane wayo i-Orange Free State—ibhekene neBrithani phakathi neMpi Yesibili yamaBhunu ka-1899–1902. Uke wabizwa nge-Afrikanerdom, futhi usengumuntu ophikisanayo; abathandwayo bamhlonipha njengeqhawe lesintu elidabukisayo.</text>
      <sha1>m65lrkxh2fj2ig05pc6qlv89yl5np8o</sha1>
    </revision>
  </page>
  <page>
    <title>Ukudla</title>
    <ns>0</ns>
    <id>305</id>
    <revision>
      <id>1635</id>
      <timestamp>2024-08-07T13:11:00Z</timestamp>
      <contributor>
        <username>incubator&gt;Lucia Skhosana</username>
        <id>0</id>
      </contributor>
      <comment>Added pictures</comment>
      <origin>1635</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3096" sha1="773l9l50kfjnge5unlz70i47lp6pdlv" xml:space="preserve">'''UKUDLA KWESIKHETHU OKUZILWAKO''' 

Lucia Skhosana

EsiNdebeleni kuvamekile bonyana kube neenkulumo ezithi ukudla thizeni kuyazilwa namkha sithi akudliwa babantu abasezingeni elithileko kule koro yethu yesikhethu. Kanengi kubaneenzathu zokobana kubayini laba bantu bazile lokho kudla, kanti lapho okhunye kuvele kuyikambiso yesikhethu ebegade ilandelwa ngabadala bese thina esiphila esikhathini sanje asinazo iimpendulo zombuzo othi kubayini, ngombana safunyana kunjalo. 

Isibonelo: '''isibindi sekomo'''. 
[[Isimumathi:Raw veal liver, 2010.jpg|alt=Ox liver|left|thumb|246x246px|Isibindi sekomo]]
Kunekulumo esakhula ngayo kuthiwa isibindi sekomo asidliwa bantwana. Irhubhululo lithi hlangana nokhunye, lokho khabe kuyikulumo yabadala nabafuna ukudima abantwana isibindi. Yelela ngokuthi gadesi abantwana bayasidla isibindi begodu akunalitho elimbi elibehlelako. 

Sibuya godu sibe nepundu namkha ipundulu. '''Ipundu''' yincenye yesbindi ethambileko. Kuthiwa ipundu yona ayidliwa bomalokazana namkha abentazana kodwana idliwa ziinlukazi ezidala. Unobangela walokho kukobana ipundu le nange kheyadliwa mmuntu omutjha angeze abeletha kuhle. Kukholelwa bona ipundu ingahle ikhubaze isibeletho. 

[[Isimumathi:Goat_interstine.jpg|thumb|210x210px|Amanyaka wembuzi]]
Kukhona godu amanyaka. '''Amanyaka wembuzi''' (umnyokolo) kanye nomtjaza wona ayarhunulwa aphekelwe abesana namkha amatjathakhande kwaphela. Bese kuthi amanyaka wekomo wona adliwe bobaba namaqhegu. 

Okhunye okuzilwako mphala. '''Umphala''' mhlobo womrhoru. Isikhethu sithi-ke umphala uzilwa babantu abatjha. Uvumeleke ukudliwa maqhegu amadala neenlukazi. 
[[Isimumathi:Raw_Tripe.png|left|thumb|Umphala ~ imirhoru]]
'''Amaqanda''' namkha '''amadzayi''' wekukhu wona ayazilwa ukudliwa matlawana kanye namatlawu. Unobangela walokho kukobana ikambiso ithi amaqanda anikela ikanuko yokuzibandakanya kezomseme begodu ayabanothisa namkha ayabavundisa, lokho akusiyo into ekhuthazwako emntwaneni ongakathombi. 

'''Iziso kanye nebende''' zona ziyazilwa bentazana, abomalokazana kanye namaqhakazana. Kukholelwa bona kunekghonakalo yokubavala imbeleko. Iziso nebende zivumelekile bonyana zingadliwa marhuze kanye neelukazi njengoba bona badlulile kilelo zinga lokubeletha. 
[[Isimumathi:Kidney_and_liver_(2).jpg|thumb|Iziso nebende]]
'''wethunga''' awudliwa ngunanyana ngubani. Uphekelwa abakhethwa ngesikhathi sengoma. Abantu abavumeleke ukudla umdoko lo bogogo abawuphekako kwaphela. Nakwenzeka bona mhlamunye usale, bangawufakela abantwanyana abakhona kodwana abantwanabo kosele bangagudi ehloko nabo basiza abogogo ukuzilela ingoma bese amasokana nakagodukako, kufanele bagudwe abantwana abadle umdoko lowo.
[[Isimumathi:Traditional-Beer5.jpg|left|thumb|African beer]]
'''Itlhodlha''' ayiselwa ngunoma ngubani. Iselwa maqhegu. Kwamaswaphelo, ilimu alidliwa bomma. Ilimu likhamba nehloko yeke kufuze liye ebandla. Kukhona ikolelo yokobana ilimi lenza abafazi namkha abantu bengubo bona bakhulumele futhi. Nange umfazi aphiwa ilimu, ayeliquntwe kancani ihloko phambili bese ingcenye leyo iyalahlwa ngethemba lokubalekela yona ikolelo le.

</text>
      <sha1>773l9l50kfjnge5unlz70i47lp6pdlv</sha1>
    </revision>
    <revision>
      <id>1636</id>
      <parentid>1635</parentid>
      <timestamp>2024-08-07T13:12:24Z</timestamp>
      <contributor>
        <username>incubator&gt;Lucia Skhosana</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1636</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3108" sha1="s8oioh5n5gmnusi0qd9qqugfq3bg9qo" xml:space="preserve">'''UKUDLA KWESIKHETHU OKUZILWAKO''' 

Itlolwe ngu Lucia Skhosana

EsiNdebeleni kuvamekile bonyana kube neenkulumo ezithi ukudla thizeni kuyazilwa namkha sithi akudliwa babantu abasezingeni elithileko kule koro yethu yesikhethu. Kanengi kubaneenzathu zokobana kubayini laba bantu bazile lokho kudla, kanti lapho okhunye kuvele kuyikambiso yesikhethu ebegade ilandelwa ngabadala bese thina esiphila esikhathini sanje asinazo iimpendulo zombuzo othi kubayini, ngombana safunyana kunjalo. 

Isibonelo: '''isibindi sekomo'''. 
[[Isimumathi:Raw veal liver, 2010.jpg|alt=Ox liver|left|thumb|246x246px|Isibindi sekomo]]
Kunekulumo esakhula ngayo kuthiwa isibindi sekomo asidliwa bantwana. Irhubhululo lithi hlangana nokhunye, lokho khabe kuyikulumo yabadala nabafuna ukudima abantwana isibindi. Yelela ngokuthi gadesi abantwana bayasidla isibindi begodu akunalitho elimbi elibehlelako. 

Sibuya godu sibe nepundu namkha ipundulu. '''Ipundu''' yincenye yesbindi ethambileko. Kuthiwa ipundu yona ayidliwa bomalokazana namkha abentazana kodwana idliwa ziinlukazi ezidala. Unobangela walokho kukobana ipundu le nange kheyadliwa mmuntu omutjha angeze abeletha kuhle. Kukholelwa bona ipundu ingahle ikhubaze isibeletho. 

[[Isimumathi:Goat_interstine.jpg|thumb|210x210px|Amanyaka wembuzi]]
Kukhona godu amanyaka. '''Amanyaka wembuzi''' (umnyokolo) kanye nomtjaza wona ayarhunulwa aphekelwe abesana namkha amatjathakhande kwaphela. Bese kuthi amanyaka wekomo wona adliwe bobaba namaqhegu. 

Okhunye okuzilwako mphala. '''Umphala''' mhlobo womrhoru. Isikhethu sithi-ke umphala uzilwa babantu abatjha. Uvumeleke ukudliwa maqhegu amadala neenlukazi. 
[[Isimumathi:Raw_Tripe.png|left|thumb|Umphala ~ imirhoru]]
'''Amaqanda''' namkha '''amadzayi''' wekukhu wona ayazilwa ukudliwa matlawana kanye namatlawu. Unobangela walokho kukobana ikambiso ithi amaqanda anikela ikanuko yokuzibandakanya kezomseme begodu ayabanothisa namkha ayabavundisa, lokho akusiyo into ekhuthazwako emntwaneni ongakathombi. 

'''Iziso kanye nebende''' zona ziyazilwa bentazana, abomalokazana kanye namaqhakazana. Kukholelwa bona kunekghonakalo yokubavala imbeleko. Iziso nebende zivumelekile bonyana zingadliwa marhuze kanye neelukazi njengoba bona badlulile kilelo zinga lokubeletha. 
[[Isimumathi:Kidney_and_liver_(2).jpg|thumb|Iziso nebende]]
'''wethunga''' awudliwa ngunanyana ngubani. Uphekelwa abakhethwa ngesikhathi sengoma. Abantu abavumeleke ukudla umdoko lo bogogo abawuphekako kwaphela. Nakwenzeka bona mhlamunye usale, bangawufakela abantwanyana abakhona kodwana abantwanabo kosele bangagudi ehloko nabo basiza abogogo ukuzilela ingoma bese amasokana nakagodukako, kufanele bagudwe abantwana abadle umdoko lowo.
[[Isimumathi:Traditional-Beer5.jpg|left|thumb|African beer]]
'''Itlhodlha''' ayiselwa ngunoma ngubani. Iselwa maqhegu. Kwamaswaphelo, ilimu alidliwa bomma. Ilimu likhamba nehloko yeke kufuze liye ebandla. Kukhona ikolelo yokobana ilimi lenza abafazi namkha abantu bengubo bona bakhulumele futhi. Nange umfazi aphiwa ilimu, ayeliquntwe kancani ihloko phambili bese ingcenye leyo iyalahlwa ngethemba lokubalekela yona ikolelo le.

</text>
      <sha1>s8oioh5n5gmnusi0qd9qqugfq3bg9qo</sha1>
    </revision>
    <revision>
      <id>1637</id>
      <parentid>1636</parentid>
      <timestamp>2024-08-07T13:30:50Z</timestamp>
      <contributor>
        <username>incubator&gt;Lucia Skhosana</username>
        <id>0</id>
      </contributor>
      <comment>Amended heading</comment>
      <origin>1637</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3107" sha1="76xre73u24o2tco8vwem51spfxq7ivq" xml:space="preserve">== '''UKUDLA KWESIKHETHU OKUZILWAKO.''' ==
'''Lucia Skhosana'''

EsiNdebeleni kuvamekile bonyana kube neenkulumo ezithi ukudla thizeni kuyazilwa namkha sithi akudliwa babantu abasezingeni elithileko kule koro yethu yesikhethu. Kanengi kubaneenzathu zokobana kubayini laba bantu bazile lokho kudla, kanti lapho okhunye kuvele kuyikambiso yesikhethu ebegade ilandelwa ngabadala bese thina esiphila esikhathini sanje asinazo iimpendulo zombuzo othi kubayini, ngombana safunyana kunjalo. 

Isibonelo: '''isibindi sekomo'''. 
[[Isimumathi:Raw veal liver, 2010.jpg|alt=Ox liver|left|thumb|246x246px|Isibindi sekomo]]
Kunekulumo esakhula ngayo kuthiwa isibindi sekomo asidliwa bantwana. Irhubhululo lithi hlangana nokhunye, lokho khabe kuyikulumo yabadala nabafuna ukudima abantwana isibindi. Yelela ngokuthi gadesi abantwana bayasidla isibindi begodu akunalitho elimbi elibehlelako. 

Sibuya godu sibe nepundu namkha ipundulu. '''Ipundu''' yincenye yesbindi ethambileko. Kuthiwa ipundu yona ayidliwa bomalokazana namkha abentazana kodwana idliwa ziinlukazi ezidala. Unobangela walokho kukobana ipundu le nange kheyadliwa mmuntu omutjha angeze abeletha kuhle. Kukholelwa bona ipundu ingahle ikhubaze isibeletho. 

[[Isimumathi:Goat_interstine.jpg|thumb|210x210px|Amanyaka wembuzi]]
Kukhona godu amanyaka. '''Amanyaka wembuzi''' (umnyokolo) kanye nomtjaza wona ayarhunulwa aphekelwe abesana namkha amatjathakhande kwaphela. Bese kuthi amanyaka wekomo wona adliwe bobaba namaqhegu. 

Okhunye okuzilwako mphala. '''Umphala''' mhlobo womrhoru. Isikhethu sithi-ke umphala uzilwa babantu abatjha. Uvumeleke ukudliwa maqhegu amadala neenlukazi. 
[[Isimumathi:Raw_Tripe.png|left|thumb|Umphala ~ imirhoru]]
'''Amaqanda''' namkha '''amadzayi''' wekukhu wona ayazilwa ukudliwa matlawana kanye namatlawu. Unobangela walokho kukobana ikambiso ithi amaqanda anikela ikanuko yokuzibandakanya kezomseme begodu ayabanothisa namkha ayabavundisa, lokho akusiyo into ekhuthazwako emntwaneni ongakathombi. 

'''Iziso kanye nebende''' zona ziyazilwa bentazana, abomalokazana kanye namaqhakazana. Kukholelwa bona kunekghonakalo yokubavala imbeleko. Iziso nebende zivumelekile bonyana zingadliwa marhuze kanye neelukazi njengoba bona badlulile kilelo zinga lokubeletha. 
[[Isimumathi:Kidney_and_liver_(2).jpg|thumb|Iziso nebende]]
'''wethunga''' awudliwa ngunanyana ngubani. Uphekelwa abakhethwa ngesikhathi sengoma. Abantu abavumeleke ukudla umdoko lo bogogo abawuphekako kwaphela. Nakwenzeka bona mhlamunye usale, bangawufakela abantwanyana abakhona kodwana abantwanabo kosele bangagudi ehloko nabo basiza abogogo ukuzilela ingoma bese amasokana nakagodukako, kufanele bagudwe abantwana abadle umdoko lowo.
[[Isimumathi:Traditional-Beer5.jpg|left|thumb|African beer]]
'''Itlhodlha''' ayiselwa ngunoma ngubani. Iselwa maqhegu. Kwamaswaphelo, ilimu alidliwa bomma. Ilimu likhamba nehloko yeke kufuze liye ebandla. Kukhona ikolelo yokobana ilimi lenza abafazi namkha abantu bengubo bona bakhulumele futhi. Nange umfazi aphiwa ilimu, ayeliquntwe kancani ihloko phambili bese ingcenye leyo iyalahlwa ngethemba lokubalekela yona ikolelo le.

</text>
      <sha1>76xre73u24o2tco8vwem51spfxq7ivq</sha1>
    </revision>
    <revision>
      <id>1638</id>
      <parentid>1637</parentid>
      <timestamp>2024-08-08T05:32:22Z</timestamp>
      <contributor>
        <username>incubator&gt;Lucia Skhosana</username>
        <id>0</id>
      </contributor>
      <comment>amended caption</comment>
      <origin>1638</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3104" sha1="ff2nvx00vd9m3fyrei9k8u0k4ru9wrc" xml:space="preserve">== '''UKUDLA KWESIKHETHU OKUZILWAKO.''' ==
'''Lucia Skhosana'''

EsiNdebeleni kuvamekile bonyana kube neenkulumo ezithi ukudla thizeni kuyazilwa namkha sithi akudliwa babantu abasezingeni elithileko kule koro yethu yesikhethu. Kanengi kubaneenzathu zokobana kubayini laba bantu bazile lokho kudla, kanti lapho okhunye kuvele kuyikambiso yesikhethu ebegade ilandelwa ngabadala bese thina esiphila esikhathini sanje asinazo iimpendulo zombuzo othi kubayini, ngombana safunyana kunjalo. 

Isibonelo: '''isibindi sekomo'''. 
[[Isimumathi:Raw veal liver, 2010.jpg|alt=Ox liver|left|thumb|246x246px|Isibindi sekomo]]
Kunekulumo esakhula ngayo kuthiwa isibindi sekomo asidliwa bantwana. Irhubhululo lithi hlangana nokhunye, lokho khabe kuyikulumo yabadala nabafuna ukudima abantwana isibindi. Yelela ngokuthi gadesi abantwana bayasidla isibindi begodu akunalitho elimbi elibehlelako. 

Sibuya godu sibe nepundu namkha ipundulu. '''Ipundu''' yincenye yesbindi ethambileko. Kuthiwa ipundu yona ayidliwa bomalokazana namkha abentazana kodwana idliwa ziinlukazi ezidala. Unobangela walokho kukobana ipundu le nange kheyadliwa mmuntu omutjha angeze abeletha kuhle. Kukholelwa bona ipundu ingahle ikhubaze isibeletho. 

[[Isimumathi:Goat_interstine.jpg|thumb|210x210px|Amanyaka wembuzi]]
Kukhona godu amanyaka. '''Amanyaka wembuzi''' (umnyokolo) kanye nomtjaza wona ayarhunulwa aphekelwe abesana namkha amatjathakhande kwaphela. Bese kuthi amanyaka wekomo wona adliwe bobaba namaqhegu. 

Okhunye okuzilwako mphala. '''Umphala''' mhlobo womrhoru. Isikhethu sithi-ke umphala uzilwa babantu abatjha. Uvumeleke ukudliwa maqhegu amadala neenlukazi. 
[[Isimumathi:Raw_Tripe.png|left|thumb|Umphala ~ imirhoru]]
'''Amaqanda''' namkha '''amadzayi''' wekukhu wona ayazilwa ukudliwa matlawana kanye namatlawu. Unobangela walokho kukobana ikambiso ithi amaqanda anikela ikanuko yokuzibandakanya kezomseme begodu ayabanothisa namkha ayabavundisa, lokho akusiyo into ekhuthazwako emntwaneni ongakathombi. 

'''Iziso kanye nebende''' zona ziyazilwa bentazana, abomalokazana kanye namaqhakazana. Kukholelwa bona kunekghonakalo yokubavala imbeleko. Iziso nebende zivumelekile bonyana zingadliwa marhuze kanye neelukazi njengoba bona badlulile kilelo zinga lokubeletha. 
[[Isimumathi:Kidney_and_liver_(2).jpg|thumb|Iziso nebende]]
'''wethunga''' awudliwa ngunanyana ngubani. Uphekelwa abakhethwa ngesikhathi sengoma. Abantu abavumeleke ukudla umdoko lo bogogo abawuphekako kwaphela. Nakwenzeka bona mhlamunye usale, bangawufakela abantwanyana abakhona kodwana abantwanabo kosele bangagudi ehloko nabo basiza abogogo ukuzilela ingoma bese amasokana nakagodukako, kufanele bagudwe abantwana abadle umdoko lowo.
[[Isimumathi:Traditional-Beer5.jpg|left|thumb|Itlhodlha]]
'''Itlhodlha''' ayiselwa ngunoma ngubani. Iselwa maqhegu. Kwamaswaphelo, ilimu alidliwa bomma. Ilimu likhamba nehloko yeke kufuze liye ebandla. Kukhona ikolelo yokobana ilimi lenza abafazi namkha abantu bengubo bona bakhulumele futhi. Nange umfazi aphiwa ilimu, ayeliquntwe kancani ihloko phambili bese ingcenye leyo iyalahlwa ngethemba lokubalekela yona ikolelo le.

</text>
      <sha1>ff2nvx00vd9m3fyrei9k8u0k4ru9wrc</sha1>
    </revision>
    <revision>
      <id>1639</id>
      <parentid>1638</parentid>
      <timestamp>2024-10-14T13:47:52Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>4 revisions imported</comment>
      <origin>1638</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3104" sha1="ff2nvx00vd9m3fyrei9k8u0k4ru9wrc" xml:space="preserve">== '''UKUDLA KWESIKHETHU OKUZILWAKO.''' ==
'''Lucia Skhosana'''

EsiNdebeleni kuvamekile bonyana kube neenkulumo ezithi ukudla thizeni kuyazilwa namkha sithi akudliwa babantu abasezingeni elithileko kule koro yethu yesikhethu. Kanengi kubaneenzathu zokobana kubayini laba bantu bazile lokho kudla, kanti lapho okhunye kuvele kuyikambiso yesikhethu ebegade ilandelwa ngabadala bese thina esiphila esikhathini sanje asinazo iimpendulo zombuzo othi kubayini, ngombana safunyana kunjalo. 

Isibonelo: '''isibindi sekomo'''. 
[[Isimumathi:Raw veal liver, 2010.jpg|alt=Ox liver|left|thumb|246x246px|Isibindi sekomo]]
Kunekulumo esakhula ngayo kuthiwa isibindi sekomo asidliwa bantwana. Irhubhululo lithi hlangana nokhunye, lokho khabe kuyikulumo yabadala nabafuna ukudima abantwana isibindi. Yelela ngokuthi gadesi abantwana bayasidla isibindi begodu akunalitho elimbi elibehlelako. 

Sibuya godu sibe nepundu namkha ipundulu. '''Ipundu''' yincenye yesbindi ethambileko. Kuthiwa ipundu yona ayidliwa bomalokazana namkha abentazana kodwana idliwa ziinlukazi ezidala. Unobangela walokho kukobana ipundu le nange kheyadliwa mmuntu omutjha angeze abeletha kuhle. Kukholelwa bona ipundu ingahle ikhubaze isibeletho. 

[[Isimumathi:Goat_interstine.jpg|thumb|210x210px|Amanyaka wembuzi]]
Kukhona godu amanyaka. '''Amanyaka wembuzi''' (umnyokolo) kanye nomtjaza wona ayarhunulwa aphekelwe abesana namkha amatjathakhande kwaphela. Bese kuthi amanyaka wekomo wona adliwe bobaba namaqhegu. 

Okhunye okuzilwako mphala. '''Umphala''' mhlobo womrhoru. Isikhethu sithi-ke umphala uzilwa babantu abatjha. Uvumeleke ukudliwa maqhegu amadala neenlukazi. 
[[Isimumathi:Raw_Tripe.png|left|thumb|Umphala ~ imirhoru]]
'''Amaqanda''' namkha '''amadzayi''' wekukhu wona ayazilwa ukudliwa matlawana kanye namatlawu. Unobangela walokho kukobana ikambiso ithi amaqanda anikela ikanuko yokuzibandakanya kezomseme begodu ayabanothisa namkha ayabavundisa, lokho akusiyo into ekhuthazwako emntwaneni ongakathombi. 

'''Iziso kanye nebende''' zona ziyazilwa bentazana, abomalokazana kanye namaqhakazana. Kukholelwa bona kunekghonakalo yokubavala imbeleko. Iziso nebende zivumelekile bonyana zingadliwa marhuze kanye neelukazi njengoba bona badlulile kilelo zinga lokubeletha. 
[[Isimumathi:Kidney_and_liver_(2).jpg|thumb|Iziso nebende]]
'''wethunga''' awudliwa ngunanyana ngubani. Uphekelwa abakhethwa ngesikhathi sengoma. Abantu abavumeleke ukudla umdoko lo bogogo abawuphekako kwaphela. Nakwenzeka bona mhlamunye usale, bangawufakela abantwanyana abakhona kodwana abantwanabo kosele bangagudi ehloko nabo basiza abogogo ukuzilela ingoma bese amasokana nakagodukako, kufanele bagudwe abantwana abadle umdoko lowo.
[[Isimumathi:Traditional-Beer5.jpg|left|thumb|Itlhodlha]]
'''Itlhodlha''' ayiselwa ngunoma ngubani. Iselwa maqhegu. Kwamaswaphelo, ilimu alidliwa bomma. Ilimu likhamba nehloko yeke kufuze liye ebandla. Kukhona ikolelo yokobana ilimi lenza abafazi namkha abantu bengubo bona bakhulumele futhi. Nange umfazi aphiwa ilimu, ayeliquntwe kancani ihloko phambili bese ingcenye leyo iyalahlwa ngethemba lokubalekela yona ikolelo le.

</text>
      <sha1>ff2nvx00vd9m3fyrei9k8u0k4ru9wrc</sha1>
    </revision>
    <revision>
      <id>2074</id>
      <parentid>1639</parentid>
      <timestamp>2024-11-21T14:21:45Z</timestamp>
      <contributor>
        <username>Hope A Ncube</username>
        <id>186</id>
      </contributor>
      <comment>Created by translating the section &quot;__LEAD_SECTION__&quot; from the page &quot;[[:en:Special:Redirect/revision/1253046916|Food]]&quot;</comment>
      <origin>2074</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4489" sha1="9u8bgrlbofwt7wo4f6ak6gd6cnz5wuo" xml:space="preserve">== '''UKUDLA KWESIKHETHU OKUZILWAKO.''' ==
'''Lucia Skhosana'''

EsiNdebeleni kuvamekile bonyana kube neenkulumo ezithi ukudla thizeni kuyazilwa namkha sithi akudliwa babantu abasezingeni elithileko kule koro yethu yesikhethu. Kanengi kubaneenzathu zokobana kubayini laba bantu bazile lokho kudla, kanti lapho okhunye kuvele kuyikambiso yesikhethu ebegade ilandelwa ngabadala bese thina esiphila esikhathini sanje asinazo iimpendulo zombuzo othi kubayini, ngombana safunyana kunjalo. 

Isibonelo: '''isibindi sekomo'''. 
[[Isimumathi:Raw veal liver, 2010.jpg|alt=Ox liver|left|thumb|246x246px|Isibindi sekomo]]
Kunekulumo esakhula ngayo kuthiwa isibindi sekomo asidliwa bantwana. Irhubhululo lithi hlangana nokhunye, lokho khabe kuyikulumo yabadala nabafuna ukudima abantwana isibindi. Yelela ngokuthi gadesi abantwana bayasidla isibindi begodu akunalitho elimbi elibehlelako. 

Sibuya godu sibe nepundu namkha ipundulu. '''Ipundu''' yincenye yesbindi ethambileko. Kuthiwa ipundu yona ayidliwa bomalokazana namkha abentazana kodwana idliwa ziinlukazi ezidala. Unobangela walokho kukobana ipundu le nange kheyadliwa mmuntu omutjha angeze abeletha kuhle. Kukholelwa bona ipundu ingahle ikhubaze isibeletho. 

[[Isimumathi:Goat_interstine.jpg|thumb|210x210px|Amanyaka wembuzi]]
Kukhona godu amanyaka. '''Amanyaka wembuzi''' (umnyokolo) kanye nomtjaza wona ayarhunulwa aphekelwe abesana namkha amatjathakhande kwaphela. Bese kuthi amanyaka wekomo wona adliwe bobaba namaqhegu. 

Okhunye okuzilwako mphala. '''Umphala''' mhlobo womrhoru. Isikhethu sithi-ke umphala uzilwa babantu abatjha. Uvumeleke ukudliwa maqhegu amadala neenlukazi. 
[[Isimumathi:Raw_Tripe.png|left|thumb|Umphala ~ imirhoru]]
'''Amaqanda''' namkha '''amadzayi''' wekukhu wona ayazilwa ukudliwa matlawana kanye namatlawu. Unobangela walokho kukobana ikambiso ithi amaqanda anikela ikanuko yokuzibandakanya kezomseme begodu ayabanothisa namkha ayabavundisa, lokho akusiyo into ekhuthazwako emntwaneni ongakathombi. 

'''Iziso kanye nebende''' zona ziyazilwa bentazana, abomalokazana kanye namaqhakazana. Kukholelwa bona kunekghonakalo yokubavala imbeleko. Iziso nebende zivumelekile bonyana zingadliwa marhuze kanye neelukazi njengoba bona badlulile kilelo zinga lokubeletha. 
[[Isimumathi:Kidney_and_liver_(2).jpg|thumb|Iziso nebende]]
'''wethunga''' awudliwa ngunanyana ngubani. Uphekelwa abakhethwa ngesikhathi sengoma. Abantu abavumeleke ukudla umdoko lo bogogo abawuphekako kwaphela. Nakwenzeka bona mhlamunye usale, bangawufakela abantwanyana abakhona kodwana abantwanabo kosele bangagudi ehloko nabo basiza abogogo ukuzilela ingoma bese amasokana nakagodukako, kufanele bagudwe abantwana abadle umdoko lowo.
[[Isimumathi:Traditional-Beer5.jpg|left|thumb|Itlhodlha]]
'''Itlhodlha''' ayiselwa ngunoma ngubani. Iselwa maqhegu. Kwamaswaphelo, ilimu alidliwa bomma. Ilimu likhamba nehloko yeke kufuze liye ebandla. Kukhona ikolelo yokobana ilimi lenza abafazi namkha abantu bengubo bona bakhulumele futhi. Nange umfazi aphiwa ilimu, ayeliquntwe kancani ihloko phambili bese ingcenye leyo iyalahlwa ngethemba lokubalekela yona ikolelo le.



== __LEAD_SECTION__ ==

[[File:Good_Food_Display_-_NCI_Visuals_Online.jpg|alt=Table set with red meat, bread, pasta, vegetables, fruit, fish, and beans|thumb|Imifanekiso yokudla okutshiyeneyo]]

'''Ukudla''' yinto yonke edliwa ngumuntu noma isilwane ukuze kutholwe ukusekelwa lokuqina komzimba. esikhathini esinengi ukudla kugoqela okulinywayo, inyamazana, lezihlahla okuyakha umzimba ngokuwunika , ama [[Carbohydrate|carbohydrates]], [[Fat|fats]], [[Protein (nutrient)|proteins]], [[Vitamin|vitamins]], or [[Mineral (nutrient)|minerals]]. ukudla kunikeza umzimba amandla, impilo, lokuwukhulisa. Izinanakazana ezitshiyeneyo zidla ukudla okutshiyeneyo kusiya ngomhlobo wesinanakazane, indaw ephla kuwo kanye lesikhathi esipila kuso

Abantu baynelisa futh sebekwazi ukudinga lokuthola ukudla ngendlela ezitshiyeneyo kuzikhathi eziguqukileyo zemvelo.  Abantu bayapheka ukudla kuvuthwe ukuze bakudle  Ukudla okwaneleyo okudingakalayo ukuze wonke umuntu akuthhole kutholakala kumkhandlo okhangele ngezokudla wona ukudla loku ukuthola ngokulima izilimo zihanjiswe kwabaguqula izilimo bazenze ukudla osokulungele uku dluliselwa ebantwini  ukuze benelise ukusuthisa imbizimba yabo Ubudlelwano lezenzakalo ezikhona phakathi kokulima lokuba lokudla osekulungele ukudliwa butsengisa ukuhi kulobudlelwano obukhulu obukhona phakathi kwezenzakalo lezi lokutshintsha kwezemkhathi ( climate change).</text>
      <sha1>9u8bgrlbofwt7wo4f6ak6gd6cnz5wuo</sha1>
    </revision>
    <revision>
      <id>2075</id>
      <parentid>2074</parentid>
      <timestamp>2024-11-21T14:23:03Z</timestamp>
      <contributor>
        <username>Hope A Ncube</username>
        <id>186</id>
      </contributor>
      <comment>/* '''UKUDLA KWESIKHETHU OKUZILWAKO.''' */</comment>
      <origin>2075</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4488" sha1="8bedu49vizb34e62wrsbxqjxclwnc9d" xml:space="preserve">== '''UKUDLA KWESIKHETHU OKUZILWAKO.''' ==
'''Lucia Skhosana'''

EsiNdebeleni kuvamekile bonyana kube neenkulumo ezithi ukudla thizeni kuyazilwa namkha sithi akudliwa babantu abasezingeni elithileko kule koro yethu yesikhethu. Kanengi kubaneenzathu zokobana kubayini laba bantu bazile lokho kudla, kanti lapho okhunye kuvele kuyikambiso yesikhethu ebegade ilandelwa ngabadala bese thina esiphila esikhathini sanje asinazo iimpendulo zombuzo othi kubayini, ngombana safunyana kunjalo. 

Isibonelo: '''isibindi senkomo'''. 
[[Isimumathi:Raw veal liver, 2010.jpg|alt=Ox liver|left|thumb|246x246px|Isibindi sekomo]]
Kunekulumo esakhula ngayo kuthiwa isibindi sekomo asidliwa bantwana. Irhubhululo lithi hlangana nokhunye, lokho khabe kuyikulumo yabadala nabafuna ukudima abantwana isibindi. Yelela ngokuthi gadesi abantwana bayasidla isibindi begodu akunalitho elimbi elibehlelako. 

Sibuya godu sibe nepundu namkha ipundulu. '''Ipundu''' yincenye yesbindi ethambileko. Kuthiwa ipundu yona ayidliwa bomalokazana namkha abentazana kodwana idliwa ziinlukazi ezidala. Unobangela walokho kukobana ipundu le nange kheyadliwa mmuntu omutjha angeze abeletha kuhle. Kukholelwa bona ipundu ingahle ikhubaze isibeletho. 

[[Isimumathi:Goat_interstine.jpg|thumb|210x210px|Amanyaka wembuzi]]
Kukhona godu amanyaka. '''Amanyaka wembuzi''' (umnyokolo) kanye nomtjaza wona ayarhunulwa aphekelwe abesana namkha amatjathakhande kwaphela. Bese kuthi amanyaka wekomo wona adliwe bobaba namaqhegu. 

Okhunye okuzilwako mphala. '''Umphala''' mhlobo womrhoru. Isikhethu sithi-ke umphala uzilwa babantu abatjha. Uvumeleke ukudliwa maqhegu amadala neenlukazi. 
[[Isimumathi:Raw_Tripe.png|left|thumb|Umphala ~ imirhoru]]
'''Amaqanda''' namkha '''amadzayi''' wekukhu wona ayazilwa ukudliwa matlawana kanye namatlawu. Unobangela walokho kukobana ikambiso ithi amaqanda anikela ikanuko yokuzibandakanya kezomseme begodu ayabanothisa namkha ayabavundisa, lokho akusiyo into ekhuthazwako emntwaneni ongakathombi. 

'''Iziso kanye nebende''' zona ziyazilwa bentazana, abomalokazana kanye namaqhakazana. Kukholelwa bona kunekghonakalo yokubavala imbeleko. Iziso nebende zivumelekile bonyana zingadliwa marhuze kanye neelukazi njengoba bona badlulile kilelo zinga lokubeletha. 
[[Isimumathi:Kidney_and_liver_(2).jpg|thumb|Iziso nebende]]
'''wethunga''' awudliwa ngunanyana ngubani. Uphekelwa abakhethwa ngesikhathi sengoma. Abantu abavumeleke ukudla umdoko lo bogogo abawuphekako kwaphela. Nakwenzeka bona mhlamunye usale, bangawufakela abantwanyana abakhona kodwana abantwanabo kosele bangagudi ehloko nabo basiza abogogo ukuzilela ingoma bese amasokana nakagodukako, kufanele bagudwe abantwana abadle umdoko lowo.
[[Isimumathi:Traditional-Beer5.jpg|left|thumb|Itlhodlha]]
'''Itlhodlha''' ayiselwa ngunoma ngubani. Iselwa maqhegu. Kwamaswaphelo, ilimu alidliwa bomma. Ilimu likhamba nehloko yeke kufuze liye ebandla. Kukhona ikolelo yokobana ilimi lenza abafazi namkha abantu bengubo bona bakhulumele futhi. Nange umfazi aphiwa ilimu, ayeliquntwe kancani ihloko phambili bese ingcenye leyo iyalahlwa ngethemba lokubalekela yona ikolelo le.

== __LEAD_SECTION__ ==

[[File:Good_Food_Display_-_NCI_Visuals_Online.jpg|alt=Table set with red meat, bread, pasta, vegetables, fruit, fish, and beans|thumb|Imifanekiso yokudla okutshiyeneyo]]

'''Ukudla''' yinto yonke edliwa ngumuntu noma isilwane ukuze kutholwe ukusekelwa lokuqina komzimba. esikhathini esinengi ukudla kugoqela okulinywayo, inyamazana, lezihlahla okuyakha umzimba ngokuwunika , ama [[Carbohydrate|carbohydrates]], [[Fat|fats]], [[Protein (nutrient)|proteins]], [[Vitamin|vitamins]], or [[Mineral (nutrient)|minerals]]. ukudla kunikeza umzimba amandla, impilo, lokuwukhulisa. Izinanakazana ezitshiyeneyo zidla ukudla okutshiyeneyo kusiya ngomhlobo wesinanakazane, indaw ephla kuwo kanye lesikhathi esipila kuso

Abantu baynelisa futh sebekwazi ukudinga lokuthola ukudla ngendlela ezitshiyeneyo kuzikhathi eziguqukileyo zemvelo.  Abantu bayapheka ukudla kuvuthwe ukuze bakudle  Ukudla okwaneleyo okudingakalayo ukuze wonke umuntu akuthhole kutholakala kumkhandlo okhangele ngezokudla wona ukudla loku ukuthola ngokulima izilimo zihanjiswe kwabaguqula izilimo bazenze ukudla osokulungele uku dluliselwa ebantwini  ukuze benelise ukusuthisa imbizimba yabo Ubudlelwano lezenzakalo ezikhona phakathi kokulima lokuba lokudla osekulungele ukudliwa butsengisa ukuhi kulobudlelwano obukhulu obukhona phakathi kwezenzakalo lezi lokutshintsha kwezemkhathi ( climate change).</text>
      <sha1>8bedu49vizb34e62wrsbxqjxclwnc9d</sha1>
    </revision>
    <revision>
      <id>2076</id>
      <parentid>2075</parentid>
      <timestamp>2024-11-21T14:23:27Z</timestamp>
      <contributor>
        <username>Hope A Ncube</username>
        <id>186</id>
      </contributor>
      <comment>/* UKUDLA KWESIKHETHU OKUZILWAKO. */</comment>
      <origin>2076</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4489" sha1="bvonz9n1ia3at2w05z07wtr6g5zkcjk" xml:space="preserve">== '''UKUDLA KWESIKHETHU OKUZILWAKO.''' ==
'''Lucia Skhosana'''

EsiNdebeleni kuvamekile bonyana kube neenkulumo ezithi ukudla thizeni kuyazilwa namkha sithi akudliwa babantu abasezingeni elithileko kule koro yethu yesikhethu. Kanengi kubaneenzathu zokobana kubayini laba bantu bazile lokho kudla, kanti lapho okhunye kuvele kuyikambiso yesikhethu ebegade ilandelwa ngabadala bese thina esiphila esikhathini sanje asinazo iimpendulo zombuzo othi kubayini, ngombana safunyana kunjalo. 

Isibonelo: '''isibindi senkomo'''. 
[[Isimumathi:Raw veal liver, 2010.jpg|alt=Ox liver|left|thumb|246x246px|Isibindi senkomo]]
Kunekulumo esakhula ngayo kuthiwa isibindi sekomo asidliwa bantwana. Irhubhululo lithi hlangana nokhunye, lokho khabe kuyikulumo yabadala nabafuna ukudima abantwana isibindi. Yelela ngokuthi gadesi abantwana bayasidla isibindi begodu akunalitho elimbi elibehlelako. 

Sibuya godu sibe nepundu namkha ipundulu. '''Ipundu''' yincenye yesbindi ethambileko. Kuthiwa ipundu yona ayidliwa bomalokazana namkha abentazana kodwana idliwa ziinlukazi ezidala. Unobangela walokho kukobana ipundu le nange kheyadliwa mmuntu omutjha angeze abeletha kuhle. Kukholelwa bona ipundu ingahle ikhubaze isibeletho. 

[[Isimumathi:Goat_interstine.jpg|thumb|210x210px|Amanyaka wembuzi]]
Kukhona godu amanyaka. '''Amanyaka wembuzi''' (umnyokolo) kanye nomtjaza wona ayarhunulwa aphekelwe abesana namkha amatjathakhande kwaphela. Bese kuthi amanyaka wekomo wona adliwe bobaba namaqhegu. 

Okhunye okuzilwako mphala. '''Umphala''' mhlobo womrhoru. Isikhethu sithi-ke umphala uzilwa babantu abatjha. Uvumeleke ukudliwa maqhegu amadala neenlukazi. 
[[Isimumathi:Raw_Tripe.png|left|thumb|Umphala ~ imirhoru]]
'''Amaqanda''' namkha '''amadzayi''' wekukhu wona ayazilwa ukudliwa matlawana kanye namatlawu. Unobangela walokho kukobana ikambiso ithi amaqanda anikela ikanuko yokuzibandakanya kezomseme begodu ayabanothisa namkha ayabavundisa, lokho akusiyo into ekhuthazwako emntwaneni ongakathombi. 

'''Iziso kanye nebende''' zona ziyazilwa bentazana, abomalokazana kanye namaqhakazana. Kukholelwa bona kunekghonakalo yokubavala imbeleko. Iziso nebende zivumelekile bonyana zingadliwa marhuze kanye neelukazi njengoba bona badlulile kilelo zinga lokubeletha. 
[[Isimumathi:Kidney_and_liver_(2).jpg|thumb|Iziso nebende]]
'''wethunga''' awudliwa ngunanyana ngubani. Uphekelwa abakhethwa ngesikhathi sengoma. Abantu abavumeleke ukudla umdoko lo bogogo abawuphekako kwaphela. Nakwenzeka bona mhlamunye usale, bangawufakela abantwanyana abakhona kodwana abantwanabo kosele bangagudi ehloko nabo basiza abogogo ukuzilela ingoma bese amasokana nakagodukako, kufanele bagudwe abantwana abadle umdoko lowo.
[[Isimumathi:Traditional-Beer5.jpg|left|thumb|Itlhodlha]]
'''Itlhodlha''' ayiselwa ngunoma ngubani. Iselwa maqhegu. Kwamaswaphelo, ilimu alidliwa bomma. Ilimu likhamba nehloko yeke kufuze liye ebandla. Kukhona ikolelo yokobana ilimi lenza abafazi namkha abantu bengubo bona bakhulumele futhi. Nange umfazi aphiwa ilimu, ayeliquntwe kancani ihloko phambili bese ingcenye leyo iyalahlwa ngethemba lokubalekela yona ikolelo le.

== __LEAD_SECTION__ ==

[[File:Good_Food_Display_-_NCI_Visuals_Online.jpg|alt=Table set with red meat, bread, pasta, vegetables, fruit, fish, and beans|thumb|Imifanekiso yokudla okutshiyeneyo]]

'''Ukudla''' yinto yonke edliwa ngumuntu noma isilwane ukuze kutholwe ukusekelwa lokuqina komzimba. esikhathini esinengi ukudla kugoqela okulinywayo, inyamazana, lezihlahla okuyakha umzimba ngokuwunika , ama [[Carbohydrate|carbohydrates]], [[Fat|fats]], [[Protein (nutrient)|proteins]], [[Vitamin|vitamins]], or [[Mineral (nutrient)|minerals]]. ukudla kunikeza umzimba amandla, impilo, lokuwukhulisa. Izinanakazana ezitshiyeneyo zidla ukudla okutshiyeneyo kusiya ngomhlobo wesinanakazane, indaw ephla kuwo kanye lesikhathi esipila kuso

Abantu baynelisa futh sebekwazi ukudinga lokuthola ukudla ngendlela ezitshiyeneyo kuzikhathi eziguqukileyo zemvelo.  Abantu bayapheka ukudla kuvuthwe ukuze bakudle  Ukudla okwaneleyo okudingakalayo ukuze wonke umuntu akuthhole kutholakala kumkhandlo okhangele ngezokudla wona ukudla loku ukuthola ngokulima izilimo zihanjiswe kwabaguqula izilimo bazenze ukudla osokulungele uku dluliselwa ebantwini  ukuze benelise ukusuthisa imbizimba yabo Ubudlelwano lezenzakalo ezikhona phakathi kokulima lokuba lokudla osekulungele ukudliwa butsengisa ukuhi kulobudlelwano obukhulu obukhona phakathi kwezenzakalo lezi lokutshintsha kwezemkhathi ( climate change).</text>
      <sha1>bvonz9n1ia3at2w05z07wtr6g5zkcjk</sha1>
    </revision>
    <revision>
      <id>2077</id>
      <parentid>2076</parentid>
      <timestamp>2024-11-21T14:23:44Z</timestamp>
      <contributor>
        <username>Hope A Ncube</username>
        <id>186</id>
      </contributor>
      <comment>/* UKUDLA KWESIKHETHU OKUZILWAKO. */</comment>
      <origin>2077</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4488" sha1="bx4q3x79tyo9nc8v90ys3rfpa9m2uta" xml:space="preserve">== '''UKUDLA KWESIKHETHU OKUZILWAKO.''' ==
'''Lucia Skhosana'''

EsiNdebeleni kuvamekile bonyana kube nenkulumo ezithi ukudla thizeni kuyazilwa namkha sithi akudliwa babantu abasezingeni elithileko kule koro yethu yesikhethu. Kanengi kubaneenzathu zokobana kubayini laba bantu bazile lokho kudla, kanti lapho okhunye kuvele kuyikambiso yesikhethu ebegade ilandelwa ngabadala bese thina esiphila esikhathini sanje asinazo iimpendulo zombuzo othi kubayini, ngombana safunyana kunjalo. 

Isibonelo: '''isibindi senkomo'''. 
[[Isimumathi:Raw veal liver, 2010.jpg|alt=Ox liver|left|thumb|246x246px|Isibindi senkomo]]
Kunekulumo esakhula ngayo kuthiwa isibindi sekomo asidliwa bantwana. Irhubhululo lithi hlangana nokhunye, lokho khabe kuyikulumo yabadala nabafuna ukudima abantwana isibindi. Yelela ngokuthi gadesi abantwana bayasidla isibindi begodu akunalitho elimbi elibehlelako. 

Sibuya godu sibe nepundu namkha ipundulu. '''Ipundu''' yincenye yesbindi ethambileko. Kuthiwa ipundu yona ayidliwa bomalokazana namkha abentazana kodwana idliwa ziinlukazi ezidala. Unobangela walokho kukobana ipundu le nange kheyadliwa mmuntu omutjha angeze abeletha kuhle. Kukholelwa bona ipundu ingahle ikhubaze isibeletho. 

[[Isimumathi:Goat_interstine.jpg|thumb|210x210px|Amanyaka wembuzi]]
Kukhona godu amanyaka. '''Amanyaka wembuzi''' (umnyokolo) kanye nomtjaza wona ayarhunulwa aphekelwe abesana namkha amatjathakhande kwaphela. Bese kuthi amanyaka wekomo wona adliwe bobaba namaqhegu. 

Okhunye okuzilwako mphala. '''Umphala''' mhlobo womrhoru. Isikhethu sithi-ke umphala uzilwa babantu abatjha. Uvumeleke ukudliwa maqhegu amadala neenlukazi. 
[[Isimumathi:Raw_Tripe.png|left|thumb|Umphala ~ imirhoru]]
'''Amaqanda''' namkha '''amadzayi''' wekukhu wona ayazilwa ukudliwa matlawana kanye namatlawu. Unobangela walokho kukobana ikambiso ithi amaqanda anikela ikanuko yokuzibandakanya kezomseme begodu ayabanothisa namkha ayabavundisa, lokho akusiyo into ekhuthazwako emntwaneni ongakathombi. 

'''Iziso kanye nebende''' zona ziyazilwa bentazana, abomalokazana kanye namaqhakazana. Kukholelwa bona kunekghonakalo yokubavala imbeleko. Iziso nebende zivumelekile bonyana zingadliwa marhuze kanye neelukazi njengoba bona badlulile kilelo zinga lokubeletha. 
[[Isimumathi:Kidney_and_liver_(2).jpg|thumb|Iziso nebende]]
'''wethunga''' awudliwa ngunanyana ngubani. Uphekelwa abakhethwa ngesikhathi sengoma. Abantu abavumeleke ukudla umdoko lo bogogo abawuphekako kwaphela. Nakwenzeka bona mhlamunye usale, bangawufakela abantwanyana abakhona kodwana abantwanabo kosele bangagudi ehloko nabo basiza abogogo ukuzilela ingoma bese amasokana nakagodukako, kufanele bagudwe abantwana abadle umdoko lowo.
[[Isimumathi:Traditional-Beer5.jpg|left|thumb|Itlhodlha]]
'''Itlhodlha''' ayiselwa ngunoma ngubani. Iselwa maqhegu. Kwamaswaphelo, ilimu alidliwa bomma. Ilimu likhamba nehloko yeke kufuze liye ebandla. Kukhona ikolelo yokobana ilimi lenza abafazi namkha abantu bengubo bona bakhulumele futhi. Nange umfazi aphiwa ilimu, ayeliquntwe kancani ihloko phambili bese ingcenye leyo iyalahlwa ngethemba lokubalekela yona ikolelo le.

== __LEAD_SECTION__ ==

[[File:Good_Food_Display_-_NCI_Visuals_Online.jpg|alt=Table set with red meat, bread, pasta, vegetables, fruit, fish, and beans|thumb|Imifanekiso yokudla okutshiyeneyo]]

'''Ukudla''' yinto yonke edliwa ngumuntu noma isilwane ukuze kutholwe ukusekelwa lokuqina komzimba. esikhathini esinengi ukudla kugoqela okulinywayo, inyamazana, lezihlahla okuyakha umzimba ngokuwunika , ama [[Carbohydrate|carbohydrates]], [[Fat|fats]], [[Protein (nutrient)|proteins]], [[Vitamin|vitamins]], or [[Mineral (nutrient)|minerals]]. ukudla kunikeza umzimba amandla, impilo, lokuwukhulisa. Izinanakazana ezitshiyeneyo zidla ukudla okutshiyeneyo kusiya ngomhlobo wesinanakazane, indaw ephla kuwo kanye lesikhathi esipila kuso

Abantu baynelisa futh sebekwazi ukudinga lokuthola ukudla ngendlela ezitshiyeneyo kuzikhathi eziguqukileyo zemvelo.  Abantu bayapheka ukudla kuvuthwe ukuze bakudle  Ukudla okwaneleyo okudingakalayo ukuze wonke umuntu akuthhole kutholakala kumkhandlo okhangele ngezokudla wona ukudla loku ukuthola ngokulima izilimo zihanjiswe kwabaguqula izilimo bazenze ukudla osokulungele uku dluliselwa ebantwini  ukuze benelise ukusuthisa imbizimba yabo Ubudlelwano lezenzakalo ezikhona phakathi kokulima lokuba lokudla osekulungele ukudliwa butsengisa ukuhi kulobudlelwano obukhulu obukhona phakathi kwezenzakalo lezi lokutshintsha kwezemkhathi ( climate change).</text>
      <sha1>bx4q3x79tyo9nc8v90ys3rfpa9m2uta</sha1>
    </revision>
    <revision>
      <id>2078</id>
      <parentid>2077</parentid>
      <timestamp>2024-11-21T14:24:12Z</timestamp>
      <contributor>
        <username>Hope A Ncube</username>
        <id>186</id>
      </contributor>
      <comment>/* UKUDLA KWESIKHETHU OKUZILWAKO. */</comment>
      <origin>2078</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4487" sha1="sqoustgzvn2ei0e60drxg3g58dr24qt" xml:space="preserve">== '''UKUDLA KWESIKHETHU OKUZILWAKO.''' ==
'''Lucia Skhosana'''

EsiNdebeleni kuvamekile bonyana kube nenkulumo ezithi ukudla thizeni kuyaziwa namkha sithi akudliwa babantu abasezingeni elithileko kule koro yethu yesikhethu. Kanengi kubaneenzathu zokobana kubayini laba bantu bazile lokho kudla, kanti lapho okhunye kuvele kuyikambiso yesikhethu ebegade ilandelwa ngabadala bese thina esiphila esikhathini sanje asinazo iimpendulo zombuzo othi kubayini, ngombana safunyana kunjalo. 

Isibonelo: '''isibindi senkomo'''. 
[[Isimumathi:Raw veal liver, 2010.jpg|alt=Ox liver|left|thumb|246x246px|Isibindi senkomo]]
Kunekulumo esakhula ngayo kuthiwa isibindi sekomo asidliwa bantwana. Irhubhululo lithi hlangana nokhunye, lokho khabe kuyikulumo yabadala nabafuna ukudima abantwana isibindi. Yelela ngokuthi gadesi abantwana bayasidla isibindi begodu akunalitho elimbi elibehlelako. 

Sibuya godu sibe nepundu namkha ipundulu. '''Ipundu''' yincenye yesbindi ethambileko. Kuthiwa ipundu yona ayidliwa bomalokazana namkha abentazana kodwana idliwa ziinlukazi ezidala. Unobangela walokho kukobana ipundu le nange kheyadliwa mmuntu omutjha angeze abeletha kuhle. Kukholelwa bona ipundu ingahle ikhubaze isibeletho. 

[[Isimumathi:Goat_interstine.jpg|thumb|210x210px|Amanyaka wembuzi]]
Kukhona godu amanyaka. '''Amanyaka wembuzi''' (umnyokolo) kanye nomtjaza wona ayarhunulwa aphekelwe abesana namkha amatjathakhande kwaphela. Bese kuthi amanyaka wekomo wona adliwe bobaba namaqhegu. 

Okhunye okuzilwako mphala. '''Umphala''' mhlobo womrhoru. Isikhethu sithi-ke umphala uzilwa babantu abatjha. Uvumeleke ukudliwa maqhegu amadala neenlukazi. 
[[Isimumathi:Raw_Tripe.png|left|thumb|Umphala ~ imirhoru]]
'''Amaqanda''' namkha '''amadzayi''' wekukhu wona ayazilwa ukudliwa matlawana kanye namatlawu. Unobangela walokho kukobana ikambiso ithi amaqanda anikela ikanuko yokuzibandakanya kezomseme begodu ayabanothisa namkha ayabavundisa, lokho akusiyo into ekhuthazwako emntwaneni ongakathombi. 

'''Iziso kanye nebende''' zona ziyazilwa bentazana, abomalokazana kanye namaqhakazana. Kukholelwa bona kunekghonakalo yokubavala imbeleko. Iziso nebende zivumelekile bonyana zingadliwa marhuze kanye neelukazi njengoba bona badlulile kilelo zinga lokubeletha. 
[[Isimumathi:Kidney_and_liver_(2).jpg|thumb|Iziso nebende]]
'''wethunga''' awudliwa ngunanyana ngubani. Uphekelwa abakhethwa ngesikhathi sengoma. Abantu abavumeleke ukudla umdoko lo bogogo abawuphekako kwaphela. Nakwenzeka bona mhlamunye usale, bangawufakela abantwanyana abakhona kodwana abantwanabo kosele bangagudi ehloko nabo basiza abogogo ukuzilela ingoma bese amasokana nakagodukako, kufanele bagudwe abantwana abadle umdoko lowo.
[[Isimumathi:Traditional-Beer5.jpg|left|thumb|Itlhodlha]]
'''Itlhodlha''' ayiselwa ngunoma ngubani. Iselwa maqhegu. Kwamaswaphelo, ilimu alidliwa bomma. Ilimu likhamba nehloko yeke kufuze liye ebandla. Kukhona ikolelo yokobana ilimi lenza abafazi namkha abantu bengubo bona bakhulumele futhi. Nange umfazi aphiwa ilimu, ayeliquntwe kancani ihloko phambili bese ingcenye leyo iyalahlwa ngethemba lokubalekela yona ikolelo le.

== __LEAD_SECTION__ ==

[[File:Good_Food_Display_-_NCI_Visuals_Online.jpg|alt=Table set with red meat, bread, pasta, vegetables, fruit, fish, and beans|thumb|Imifanekiso yokudla okutshiyeneyo]]

'''Ukudla''' yinto yonke edliwa ngumuntu noma isilwane ukuze kutholwe ukusekelwa lokuqina komzimba. esikhathini esinengi ukudla kugoqela okulinywayo, inyamazana, lezihlahla okuyakha umzimba ngokuwunika , ama [[Carbohydrate|carbohydrates]], [[Fat|fats]], [[Protein (nutrient)|proteins]], [[Vitamin|vitamins]], or [[Mineral (nutrient)|minerals]]. ukudla kunikeza umzimba amandla, impilo, lokuwukhulisa. Izinanakazana ezitshiyeneyo zidla ukudla okutshiyeneyo kusiya ngomhlobo wesinanakazane, indaw ephla kuwo kanye lesikhathi esipila kuso

Abantu baynelisa futh sebekwazi ukudinga lokuthola ukudla ngendlela ezitshiyeneyo kuzikhathi eziguqukileyo zemvelo.  Abantu bayapheka ukudla kuvuthwe ukuze bakudle  Ukudla okwaneleyo okudingakalayo ukuze wonke umuntu akuthhole kutholakala kumkhandlo okhangele ngezokudla wona ukudla loku ukuthola ngokulima izilimo zihanjiswe kwabaguqula izilimo bazenze ukudla osokulungele uku dluliselwa ebantwini  ukuze benelise ukusuthisa imbizimba yabo Ubudlelwano lezenzakalo ezikhona phakathi kokulima lokuba lokudla osekulungele ukudliwa butsengisa ukuhi kulobudlelwano obukhulu obukhona phakathi kwezenzakalo lezi lokutshintsha kwezemkhathi ( climate change).</text>
      <sha1>sqoustgzvn2ei0e60drxg3g58dr24qt</sha1>
    </revision>
    <revision>
      <id>2079</id>
      <parentid>2078</parentid>
      <timestamp>2024-11-21T14:24:38Z</timestamp>
      <contributor>
        <username>Hope A Ncube</username>
        <id>186</id>
      </contributor>
      <comment>/* UKUDLA KWESIKHETHU OKUZILWAKO. */</comment>
      <origin>2079</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4488" sha1="fnzvmakhzua89e14ibyrn7axhymzlqe" xml:space="preserve">== '''UKUDLA KWESIKHETHU OKUZILWAKO.''' ==
'''Lucia Skhosana'''

EsiNdebeleni kuvamekile bonyana kube nenkulumo ezithi ukudla thizeni kuyaziwa namkha sithi akudliwa babantu abasezingeni elithileko kule koro yethu yesikhethu. Kanengi kubaneenzathu zokobana kubayini laba bantu bazile lokho kudla, kanti lapho okhunye kuvele kuyikambiso yesikhethu ebegade ilandelwa ngabadala bese thina esiphila esikhathini sanje asinazo iimpendulo zombuzo othi kubayini, ngombana safunyana kunjalo. 

Isibonelo: '''isibindi senkomo'''. 
[[Isimumathi:Raw veal liver, 2010.jpg|alt=Ox liver|left|thumb|246x246px|Isibindi senkomo]]
Kunenkulumo esakhula ngayo kuthiwa isibindi sekomo asidliwa bantwana. Irhubhululo lithi hlangana nokhunye, lokho khabe kuyikulumo yabadala nabafuna ukudima abantwana isibindi. Yelela ngokuthi gadesi abantwana bayasidla isibindi begodu akunalitho elimbi elibehlelako. 

Sibuya godu sibe nepundu namkha ipundulu. '''Ipundu''' yincenye yesbindi ethambileko. Kuthiwa ipundu yona ayidliwa bomalokazana namkha abentazana kodwana idliwa ziinlukazi ezidala. Unobangela walokho kukobana ipundu le nange kheyadliwa mmuntu omutjha angeze abeletha kuhle. Kukholelwa bona ipundu ingahle ikhubaze isibeletho. 

[[Isimumathi:Goat_interstine.jpg|thumb|210x210px|Amanyaka wembuzi]]
Kukhona godu amanyaka. '''Amanyaka wembuzi''' (umnyokolo) kanye nomtjaza wona ayarhunulwa aphekelwe abesana namkha amatjathakhande kwaphela. Bese kuthi amanyaka wekomo wona adliwe bobaba namaqhegu. 

Okhunye okuzilwako mphala. '''Umphala''' mhlobo womrhoru. Isikhethu sithi-ke umphala uzilwa babantu abatjha. Uvumeleke ukudliwa maqhegu amadala neenlukazi. 
[[Isimumathi:Raw_Tripe.png|left|thumb|Umphala ~ imirhoru]]
'''Amaqanda''' namkha '''amadzayi''' wekukhu wona ayazilwa ukudliwa matlawana kanye namatlawu. Unobangela walokho kukobana ikambiso ithi amaqanda anikela ikanuko yokuzibandakanya kezomseme begodu ayabanothisa namkha ayabavundisa, lokho akusiyo into ekhuthazwako emntwaneni ongakathombi. 

'''Iziso kanye nebende''' zona ziyazilwa bentazana, abomalokazana kanye namaqhakazana. Kukholelwa bona kunekghonakalo yokubavala imbeleko. Iziso nebende zivumelekile bonyana zingadliwa marhuze kanye neelukazi njengoba bona badlulile kilelo zinga lokubeletha. 
[[Isimumathi:Kidney_and_liver_(2).jpg|thumb|Iziso nebende]]
'''wethunga''' awudliwa ngunanyana ngubani. Uphekelwa abakhethwa ngesikhathi sengoma. Abantu abavumeleke ukudla umdoko lo bogogo abawuphekako kwaphela. Nakwenzeka bona mhlamunye usale, bangawufakela abantwanyana abakhona kodwana abantwanabo kosele bangagudi ehloko nabo basiza abogogo ukuzilela ingoma bese amasokana nakagodukako, kufanele bagudwe abantwana abadle umdoko lowo.
[[Isimumathi:Traditional-Beer5.jpg|left|thumb|Itlhodlha]]
'''Itlhodlha''' ayiselwa ngunoma ngubani. Iselwa maqhegu. Kwamaswaphelo, ilimu alidliwa bomma. Ilimu likhamba nehloko yeke kufuze liye ebandla. Kukhona ikolelo yokobana ilimi lenza abafazi namkha abantu bengubo bona bakhulumele futhi. Nange umfazi aphiwa ilimu, ayeliquntwe kancani ihloko phambili bese ingcenye leyo iyalahlwa ngethemba lokubalekela yona ikolelo le.

== __LEAD_SECTION__ ==

[[File:Good_Food_Display_-_NCI_Visuals_Online.jpg|alt=Table set with red meat, bread, pasta, vegetables, fruit, fish, and beans|thumb|Imifanekiso yokudla okutshiyeneyo]]

'''Ukudla''' yinto yonke edliwa ngumuntu noma isilwane ukuze kutholwe ukusekelwa lokuqina komzimba. esikhathini esinengi ukudla kugoqela okulinywayo, inyamazana, lezihlahla okuyakha umzimba ngokuwunika , ama [[Carbohydrate|carbohydrates]], [[Fat|fats]], [[Protein (nutrient)|proteins]], [[Vitamin|vitamins]], or [[Mineral (nutrient)|minerals]]. ukudla kunikeza umzimba amandla, impilo, lokuwukhulisa. Izinanakazana ezitshiyeneyo zidla ukudla okutshiyeneyo kusiya ngomhlobo wesinanakazane, indaw ephla kuwo kanye lesikhathi esipila kuso

Abantu baynelisa futh sebekwazi ukudinga lokuthola ukudla ngendlela ezitshiyeneyo kuzikhathi eziguqukileyo zemvelo.  Abantu bayapheka ukudla kuvuthwe ukuze bakudle  Ukudla okwaneleyo okudingakalayo ukuze wonke umuntu akuthhole kutholakala kumkhandlo okhangele ngezokudla wona ukudla loku ukuthola ngokulima izilimo zihanjiswe kwabaguqula izilimo bazenze ukudla osokulungele uku dluliselwa ebantwini  ukuze benelise ukusuthisa imbizimba yabo Ubudlelwano lezenzakalo ezikhona phakathi kokulima lokuba lokudla osekulungele ukudliwa butsengisa ukuhi kulobudlelwano obukhulu obukhona phakathi kwezenzakalo lezi lokutshintsha kwezemkhathi ( climate change).</text>
      <sha1>fnzvmakhzua89e14ibyrn7axhymzlqe</sha1>
    </revision>
    <revision>
      <id>2080</id>
      <parentid>2079</parentid>
      <timestamp>2024-11-21T14:24:55Z</timestamp>
      <contributor>
        <username>Hope A Ncube</username>
        <id>186</id>
      </contributor>
      <comment>/* UKUDLA KWESIKHETHU OKUZILWAKO. */</comment>
      <origin>2080</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4489" sha1="i0ytl9jhuka7mj99kl9j4zro4p9x9ca" xml:space="preserve">== '''UKUDLA KWESIKHETHU OKUZILWAKO.''' ==
'''Lucia Skhosana'''

EsiNdebeleni kuvamekile bonyana kube nenkulumo ezithi ukudla thizeni kuyaziwa namkha sithi akudliwa babantu abasezingeni elithileko kule koro yethu yesikhethu. Kanengi kubaneenzathu zokobana kubayini laba bantu bazile lokho kudla, kanti lapho okhunye kuvele kuyikambiso yesikhethu ebegade ilandelwa ngabadala bese thina esiphila esikhathini sanje asinazo iimpendulo zombuzo othi kubayini, ngombana safunyana kunjalo. 

Isibonelo: '''isibindi senkomo'''. 
[[Isimumathi:Raw veal liver, 2010.jpg|alt=Ox liver|left|thumb|246x246px|Isibindi senkomo]]
Kunenkulumo esakhula ngayo kuthiwa isibindi senkomo asidliwa bantwana. Irhubhululo lithi hlangana nokhunye, lokho khabe kuyikulumo yabadala nabafuna ukudima abantwana isibindi. Yelela ngokuthi gadesi abantwana bayasidla isibindi begodu akunalitho elimbi elibehlelako. 

Sibuya godu sibe nepundu namkha ipundulu. '''Ipundu''' yincenye yesbindi ethambileko. Kuthiwa ipundu yona ayidliwa bomalokazana namkha abentazana kodwana idliwa ziinlukazi ezidala. Unobangela walokho kukobana ipundu le nange kheyadliwa mmuntu omutjha angeze abeletha kuhle. Kukholelwa bona ipundu ingahle ikhubaze isibeletho. 

[[Isimumathi:Goat_interstine.jpg|thumb|210x210px|Amanyaka wembuzi]]
Kukhona godu amanyaka. '''Amanyaka wembuzi''' (umnyokolo) kanye nomtjaza wona ayarhunulwa aphekelwe abesana namkha amatjathakhande kwaphela. Bese kuthi amanyaka wekomo wona adliwe bobaba namaqhegu. 

Okhunye okuzilwako mphala. '''Umphala''' mhlobo womrhoru. Isikhethu sithi-ke umphala uzilwa babantu abatjha. Uvumeleke ukudliwa maqhegu amadala neenlukazi. 
[[Isimumathi:Raw_Tripe.png|left|thumb|Umphala ~ imirhoru]]
'''Amaqanda''' namkha '''amadzayi''' wekukhu wona ayazilwa ukudliwa matlawana kanye namatlawu. Unobangela walokho kukobana ikambiso ithi amaqanda anikela ikanuko yokuzibandakanya kezomseme begodu ayabanothisa namkha ayabavundisa, lokho akusiyo into ekhuthazwako emntwaneni ongakathombi. 

'''Iziso kanye nebende''' zona ziyazilwa bentazana, abomalokazana kanye namaqhakazana. Kukholelwa bona kunekghonakalo yokubavala imbeleko. Iziso nebende zivumelekile bonyana zingadliwa marhuze kanye neelukazi njengoba bona badlulile kilelo zinga lokubeletha. 
[[Isimumathi:Kidney_and_liver_(2).jpg|thumb|Iziso nebende]]
'''wethunga''' awudliwa ngunanyana ngubani. Uphekelwa abakhethwa ngesikhathi sengoma. Abantu abavumeleke ukudla umdoko lo bogogo abawuphekako kwaphela. Nakwenzeka bona mhlamunye usale, bangawufakela abantwanyana abakhona kodwana abantwanabo kosele bangagudi ehloko nabo basiza abogogo ukuzilela ingoma bese amasokana nakagodukako, kufanele bagudwe abantwana abadle umdoko lowo.
[[Isimumathi:Traditional-Beer5.jpg|left|thumb|Itlhodlha]]
'''Itlhodlha''' ayiselwa ngunoma ngubani. Iselwa maqhegu. Kwamaswaphelo, ilimu alidliwa bomma. Ilimu likhamba nehloko yeke kufuze liye ebandla. Kukhona ikolelo yokobana ilimi lenza abafazi namkha abantu bengubo bona bakhulumele futhi. Nange umfazi aphiwa ilimu, ayeliquntwe kancani ihloko phambili bese ingcenye leyo iyalahlwa ngethemba lokubalekela yona ikolelo le.

== __LEAD_SECTION__ ==

[[File:Good_Food_Display_-_NCI_Visuals_Online.jpg|alt=Table set with red meat, bread, pasta, vegetables, fruit, fish, and beans|thumb|Imifanekiso yokudla okutshiyeneyo]]

'''Ukudla''' yinto yonke edliwa ngumuntu noma isilwane ukuze kutholwe ukusekelwa lokuqina komzimba. esikhathini esinengi ukudla kugoqela okulinywayo, inyamazana, lezihlahla okuyakha umzimba ngokuwunika , ama [[Carbohydrate|carbohydrates]], [[Fat|fats]], [[Protein (nutrient)|proteins]], [[Vitamin|vitamins]], or [[Mineral (nutrient)|minerals]]. ukudla kunikeza umzimba amandla, impilo, lokuwukhulisa. Izinanakazana ezitshiyeneyo zidla ukudla okutshiyeneyo kusiya ngomhlobo wesinanakazane, indaw ephla kuwo kanye lesikhathi esipila kuso

Abantu baynelisa futh sebekwazi ukudinga lokuthola ukudla ngendlela ezitshiyeneyo kuzikhathi eziguqukileyo zemvelo.  Abantu bayapheka ukudla kuvuthwe ukuze bakudle  Ukudla okwaneleyo okudingakalayo ukuze wonke umuntu akuthhole kutholakala kumkhandlo okhangele ngezokudla wona ukudla loku ukuthola ngokulima izilimo zihanjiswe kwabaguqula izilimo bazenze ukudla osokulungele uku dluliselwa ebantwini  ukuze benelise ukusuthisa imbizimba yabo Ubudlelwano lezenzakalo ezikhona phakathi kokulima lokuba lokudla osekulungele ukudliwa butsengisa ukuhi kulobudlelwano obukhulu obukhona phakathi kwezenzakalo lezi lokutshintsha kwezemkhathi ( climate change).</text>
      <sha1>i0ytl9jhuka7mj99kl9j4zro4p9x9ca</sha1>
    </revision>
    <revision>
      <id>2081</id>
      <parentid>2080</parentid>
      <timestamp>2024-11-21T14:25:10Z</timestamp>
      <contributor>
        <username>Hope A Ncube</username>
        <id>186</id>
      </contributor>
      <comment>/* UKUDLA KWESIKHETHU OKUZILWAKO. */</comment>
      <origin>2081</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4492" sha1="thyaxfj6nfl1iz4wbedfqs9gljduqci" xml:space="preserve">== '''UKUDLA KWESIKHETHU OKUZILWAKO.''' ==
'''Lucia Skhosana'''

EsiNdebeleni kuvamekile bonyana kube nenkulumo ezithi ukudla thizeni kuyaziwa namkha sithi akudliwa babantu abasezingeni elithileko kule koro yethu yesikhethu. Kanengi kubaneenzathu zokobana kubayini laba bantu bazile lokho kudla, kanti lapho okhunye kuvele kuyikambiso yesikhethu ebegade ilandelwa ngabadala bese thina esiphila esikhathini sanje asinazo iimpendulo zombuzo othi kubayini, ngombana safunyana kunjalo. 

Isibonelo: '''isibindi senkomo'''. 
[[Isimumathi:Raw veal liver, 2010.jpg|alt=Ox liver|left|thumb|246x246px|Isibindi senkomo]]
Kunenkulumo esakhula ngayo kuthiwa isibindi senkomo asidliwa ngabantwana. Irhubhululo lithi hlangana nokhunye, lokho khabe kuyikulumo yabadala nabafuna ukudima abantwana isibindi. Yelela ngokuthi gadesi abantwana bayasidla isibindi begodu akunalitho elimbi elibehlelako. 

Sibuya godu sibe nepundu namkha ipundulu. '''Ipundu''' yincenye yesbindi ethambileko. Kuthiwa ipundu yona ayidliwa bomalokazana namkha abentazana kodwana idliwa ziinlukazi ezidala. Unobangela walokho kukobana ipundu le nange kheyadliwa mmuntu omutjha angeze abeletha kuhle. Kukholelwa bona ipundu ingahle ikhubaze isibeletho. 

[[Isimumathi:Goat_interstine.jpg|thumb|210x210px|Amanyaka wembuzi]]
Kukhona godu amanyaka. '''Amanyaka wembuzi''' (umnyokolo) kanye nomtjaza wona ayarhunulwa aphekelwe abesana namkha amatjathakhande kwaphela. Bese kuthi amanyaka wekomo wona adliwe bobaba namaqhegu. 

Okhunye okuzilwako mphala. '''Umphala''' mhlobo womrhoru. Isikhethu sithi-ke umphala uzilwa babantu abatjha. Uvumeleke ukudliwa maqhegu amadala neenlukazi. 
[[Isimumathi:Raw_Tripe.png|left|thumb|Umphala ~ imirhoru]]
'''Amaqanda''' namkha '''amadzayi''' wekukhu wona ayazilwa ukudliwa matlawana kanye namatlawu. Unobangela walokho kukobana ikambiso ithi amaqanda anikela ikanuko yokuzibandakanya kezomseme begodu ayabanothisa namkha ayabavundisa, lokho akusiyo into ekhuthazwako emntwaneni ongakathombi. 

'''Iziso kanye nebende''' zona ziyazilwa bentazana, abomalokazana kanye namaqhakazana. Kukholelwa bona kunekghonakalo yokubavala imbeleko. Iziso nebende zivumelekile bonyana zingadliwa marhuze kanye neelukazi njengoba bona badlulile kilelo zinga lokubeletha. 
[[Isimumathi:Kidney_and_liver_(2).jpg|thumb|Iziso nebende]]
'''wethunga''' awudliwa ngunanyana ngubani. Uphekelwa abakhethwa ngesikhathi sengoma. Abantu abavumeleke ukudla umdoko lo bogogo abawuphekako kwaphela. Nakwenzeka bona mhlamunye usale, bangawufakela abantwanyana abakhona kodwana abantwanabo kosele bangagudi ehloko nabo basiza abogogo ukuzilela ingoma bese amasokana nakagodukako, kufanele bagudwe abantwana abadle umdoko lowo.
[[Isimumathi:Traditional-Beer5.jpg|left|thumb|Itlhodlha]]
'''Itlhodlha''' ayiselwa ngunoma ngubani. Iselwa maqhegu. Kwamaswaphelo, ilimu alidliwa bomma. Ilimu likhamba nehloko yeke kufuze liye ebandla. Kukhona ikolelo yokobana ilimi lenza abafazi namkha abantu bengubo bona bakhulumele futhi. Nange umfazi aphiwa ilimu, ayeliquntwe kancani ihloko phambili bese ingcenye leyo iyalahlwa ngethemba lokubalekela yona ikolelo le.

== __LEAD_SECTION__ ==

[[File:Good_Food_Display_-_NCI_Visuals_Online.jpg|alt=Table set with red meat, bread, pasta, vegetables, fruit, fish, and beans|thumb|Imifanekiso yokudla okutshiyeneyo]]

'''Ukudla''' yinto yonke edliwa ngumuntu noma isilwane ukuze kutholwe ukusekelwa lokuqina komzimba. esikhathini esinengi ukudla kugoqela okulinywayo, inyamazana, lezihlahla okuyakha umzimba ngokuwunika , ama [[Carbohydrate|carbohydrates]], [[Fat|fats]], [[Protein (nutrient)|proteins]], [[Vitamin|vitamins]], or [[Mineral (nutrient)|minerals]]. ukudla kunikeza umzimba amandla, impilo, lokuwukhulisa. Izinanakazana ezitshiyeneyo zidla ukudla okutshiyeneyo kusiya ngomhlobo wesinanakazane, indaw ephla kuwo kanye lesikhathi esipila kuso

Abantu baynelisa futh sebekwazi ukudinga lokuthola ukudla ngendlela ezitshiyeneyo kuzikhathi eziguqukileyo zemvelo.  Abantu bayapheka ukudla kuvuthwe ukuze bakudle  Ukudla okwaneleyo okudingakalayo ukuze wonke umuntu akuthhole kutholakala kumkhandlo okhangele ngezokudla wona ukudla loku ukuthola ngokulima izilimo zihanjiswe kwabaguqula izilimo bazenze ukudla osokulungele uku dluliselwa ebantwini  ukuze benelise ukusuthisa imbizimba yabo Ubudlelwano lezenzakalo ezikhona phakathi kokulima lokuba lokudla osekulungele ukudliwa butsengisa ukuhi kulobudlelwano obukhulu obukhona phakathi kwezenzakalo lezi lokutshintsha kwezemkhathi ( climate change).</text>
      <sha1>thyaxfj6nfl1iz4wbedfqs9gljduqci</sha1>
    </revision>
    <revision>
      <id>2082</id>
      <parentid>2081</parentid>
      <timestamp>2024-11-21T14:25:53Z</timestamp>
      <contributor>
        <username>Hope A Ncube</username>
        <id>186</id>
      </contributor>
      <comment>/* UKUDLA KWESIKHETHU OKUZILWAKO. */</comment>
      <origin>2082</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4493" sha1="9j2dafxb30n6bq7x2gxogcko61p96v2" xml:space="preserve">== '''UKUDLA KWESIKHETHU OKUZILWAKO.''' ==
'''Lucia Skhosana'''

EsiNdebeleni kuvamekile bonyana kube nenkulumo ezithi ukudla thizeni kuyaziwa namkha sithi akudliwa babantu abasezingeni elithileko kule koro yethu yesikhethu. Kanengi kubaneenzathu zokobana kubayini laba bantu bazile lokho kudla, kanti lapho okhunye kuvele kuyikambiso yesikhethu ebegade ilandelwa ngabadala bese thina esiphila esikhathini sanje asinazo iimpendulo zombuzo othi kubayini, ngombana safunyana kunjalo. 

Isibonelo: '''isibindi senkomo'''. 
[[Isimumathi:Raw veal liver, 2010.jpg|alt=Ox liver|left|thumb|246x246px|Isibindi senkomo]]
Kunenkulumo esakhula ngayo kuthiwa isibindi senkomo asidliwa ngabantwana. Irhubhululo lithi hlangana nokhunye, lokho khabe kuyinkulumo yabadala nabafuna ukudima abantwana isibindi. Yelela ngokuthi gadesi abantwana bayasidla isibindi begodu akunalitho elimbi elibehlelako. 

Sibuya godu sibe nepundu namkha ipundulu. '''Ipundu''' yincenye yesbindi ethambileko. Kuthiwa ipundu yona ayidliwa bomalokazana namkha abentazana kodwana idliwa ziinlukazi ezidala. Unobangela walokho kukobana ipundu le nange kheyadliwa mmuntu omutjha angeze abeletha kuhle. Kukholelwa bona ipundu ingahle ikhubaze isibeletho. 

[[Isimumathi:Goat_interstine.jpg|thumb|210x210px|Amanyaka wembuzi]]
Kukhona godu amanyaka. '''Amanyaka wembuzi''' (umnyokolo) kanye nomtjaza wona ayarhunulwa aphekelwe abesana namkha amatjathakhande kwaphela. Bese kuthi amanyaka wekomo wona adliwe bobaba namaqhegu. 

Okhunye okuzilwako mphala. '''Umphala''' mhlobo womrhoru. Isikhethu sithi-ke umphala uzilwa babantu abatjha. Uvumeleke ukudliwa maqhegu amadala neenlukazi. 
[[Isimumathi:Raw_Tripe.png|left|thumb|Umphala ~ imirhoru]]
'''Amaqanda''' namkha '''amadzayi''' wekukhu wona ayazilwa ukudliwa matlawana kanye namatlawu. Unobangela walokho kukobana ikambiso ithi amaqanda anikela ikanuko yokuzibandakanya kezomseme begodu ayabanothisa namkha ayabavundisa, lokho akusiyo into ekhuthazwako emntwaneni ongakathombi. 

'''Iziso kanye nebende''' zona ziyazilwa bentazana, abomalokazana kanye namaqhakazana. Kukholelwa bona kunekghonakalo yokubavala imbeleko. Iziso nebende zivumelekile bonyana zingadliwa marhuze kanye neelukazi njengoba bona badlulile kilelo zinga lokubeletha. 
[[Isimumathi:Kidney_and_liver_(2).jpg|thumb|Iziso nebende]]
'''wethunga''' awudliwa ngunanyana ngubani. Uphekelwa abakhethwa ngesikhathi sengoma. Abantu abavumeleke ukudla umdoko lo bogogo abawuphekako kwaphela. Nakwenzeka bona mhlamunye usale, bangawufakela abantwanyana abakhona kodwana abantwanabo kosele bangagudi ehloko nabo basiza abogogo ukuzilela ingoma bese amasokana nakagodukako, kufanele bagudwe abantwana abadle umdoko lowo.
[[Isimumathi:Traditional-Beer5.jpg|left|thumb|Itlhodlha]]
'''Itlhodlha''' ayiselwa ngunoma ngubani. Iselwa maqhegu. Kwamaswaphelo, ilimu alidliwa bomma. Ilimu likhamba nehloko yeke kufuze liye ebandla. Kukhona ikolelo yokobana ilimi lenza abafazi namkha abantu bengubo bona bakhulumele futhi. Nange umfazi aphiwa ilimu, ayeliquntwe kancani ihloko phambili bese ingcenye leyo iyalahlwa ngethemba lokubalekela yona ikolelo le.

== __LEAD_SECTION__ ==

[[File:Good_Food_Display_-_NCI_Visuals_Online.jpg|alt=Table set with red meat, bread, pasta, vegetables, fruit, fish, and beans|thumb|Imifanekiso yokudla okutshiyeneyo]]

'''Ukudla''' yinto yonke edliwa ngumuntu noma isilwane ukuze kutholwe ukusekelwa lokuqina komzimba. esikhathini esinengi ukudla kugoqela okulinywayo, inyamazana, lezihlahla okuyakha umzimba ngokuwunika , ama [[Carbohydrate|carbohydrates]], [[Fat|fats]], [[Protein (nutrient)|proteins]], [[Vitamin|vitamins]], or [[Mineral (nutrient)|minerals]]. ukudla kunikeza umzimba amandla, impilo, lokuwukhulisa. Izinanakazana ezitshiyeneyo zidla ukudla okutshiyeneyo kusiya ngomhlobo wesinanakazane, indaw ephla kuwo kanye lesikhathi esipila kuso

Abantu baynelisa futh sebekwazi ukudinga lokuthola ukudla ngendlela ezitshiyeneyo kuzikhathi eziguqukileyo zemvelo.  Abantu bayapheka ukudla kuvuthwe ukuze bakudle  Ukudla okwaneleyo okudingakalayo ukuze wonke umuntu akuthhole kutholakala kumkhandlo okhangele ngezokudla wona ukudla loku ukuthola ngokulima izilimo zihanjiswe kwabaguqula izilimo bazenze ukudla osokulungele uku dluliselwa ebantwini  ukuze benelise ukusuthisa imbizimba yabo Ubudlelwano lezenzakalo ezikhona phakathi kokulima lokuba lokudla osekulungele ukudliwa butsengisa ukuhi kulobudlelwano obukhulu obukhona phakathi kwezenzakalo lezi lokutshintsha kwezemkhathi ( climate change).</text>
      <sha1>9j2dafxb30n6bq7x2gxogcko61p96v2</sha1>
    </revision>
    <revision>
      <id>2083</id>
      <parentid>2082</parentid>
      <timestamp>2024-11-21T14:27:09Z</timestamp>
      <contributor>
        <username>Hope A Ncube</username>
        <id>186</id>
      </contributor>
      <comment>/* UKUDLA KWESIKHETHU OKUZILWAKO. */</comment>
      <origin>2083</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4494" sha1="4y1j1g4lcmo7m8y8vuijxp8ymuw7gyc" xml:space="preserve">== '''UKUDLA KWESIKHETHU OKUZILWAKO.''' ==
'''Lucia Skhosana'''

EsiNdebeleni kuvamekile bonyana kube nenkulumo ezithi ukudla thizeni kuyazilwa namkha sithi akudliwa babantu abasezingeni elithileko kule koro yethu yesikhethu. Kanengi kubaneenzathu zokobana kubayini laba bantu bazile lokho kudla, kanti lapho okhunye kuvele kuyikambiso yesikhethu ebegade ilandelwa ngabadala bese thina esiphila esikhathini sanje asinazo iimpendulo zombuzo othi kubayini, ngombana safunyana kunjalo. 

Isibonelo: '''isibindi senkomo'''. 
[[Isimumathi:Raw veal liver, 2010.jpg|alt=Ox liver|left|thumb|246x246px|Isibindi senkomo]]
Kunenkulumo esakhula ngayo kuthiwa isibindi senkomo asidliwa ngabantwana. Irhubhululo lithi hlangana nokhunye, lokho khabe kuyinkulumo yabadala nabafuna ukudima abantwana isibindi. Yelela ngokuthi gadesi abantwana bayasidla isibindi begodu akunalitho elimbi elibehlelako. 

Sibuya godu sibe nepundu namkha ipundulu. '''Ipundu''' yincenye yesbindi ethambileko. Kuthiwa ipundu yona ayidliwa bomalokazana namkha abentazana kodwana idliwa ziinlukazi ezidala. Unobangela walokho kukobana ipundu le nange kheyadliwa mmuntu omutjha angeze abeletha kuhle. Kukholelwa bona ipundu ingahle ikhubaze isibeletho. 

[[Isimumathi:Goat_interstine.jpg|thumb|210x210px|Amanyaka wembuzi]]
Kukhona godu amanyaka. '''Amanyaka wembuzi''' (umnyokolo) kanye nomtjaza wona ayarhunulwa aphekelwe abesana namkha amatjathakhande kwaphela. Bese kuthi amanyaka wekomo wona adliwe bobaba namaqhegu. 

Okhunye okuzilwako mphala. '''Umphala''' mhlobo womrhoru. Isikhethu sithi-ke umphala uzilwa babantu abatjha. Uvumeleke ukudliwa maqhegu amadala neenlukazi. 
[[Isimumathi:Raw_Tripe.png|left|thumb|Umphala ~ imirhoru]]
'''Amaqanda''' namkha '''amadzayi''' wekukhu wona ayazilwa ukudliwa matlawana kanye namatlawu. Unobangela walokho kukobana ikambiso ithi amaqanda anikela ikanuko yokuzibandakanya kezomseme begodu ayabanothisa namkha ayabavundisa, lokho akusiyo into ekhuthazwako emntwaneni ongakathombi. 

'''Iziso kanye nebende''' zona ziyazilwa bentazana, abomalokazana kanye namaqhakazana. Kukholelwa bona kunekghonakalo yokubavala imbeleko. Iziso nebende zivumelekile bonyana zingadliwa marhuze kanye neelukazi njengoba bona badlulile kilelo zinga lokubeletha. 
[[Isimumathi:Kidney_and_liver_(2).jpg|thumb|Iziso nebende]]
'''wethunga''' awudliwa ngunanyana ngubani. Uphekelwa abakhethwa ngesikhathi sengoma. Abantu abavumeleke ukudla umdoko lo bogogo abawuphekako kwaphela. Nakwenzeka bona mhlamunye usale, bangawufakela abantwanyana abakhona kodwana abantwanabo kosele bangagudi ehloko nabo basiza abogogo ukuzilela ingoma bese amasokana nakagodukako, kufanele bagudwe abantwana abadle umdoko lowo.
[[Isimumathi:Traditional-Beer5.jpg|left|thumb|Itlhodlha]]
'''Itlhodlha''' ayiselwa ngunoma ngubani. Iselwa maqhegu. Kwamaswaphelo, ilimu alidliwa bomma. Ilimu likhamba nehloko yeke kufuze liye ebandla. Kukhona ikolelo yokobana ilimi lenza abafazi namkha abantu bengubo bona bakhulumele futhi. Nange umfazi aphiwa ilimu, ayeliquntwe kancani ihloko phambili bese ingcenye leyo iyalahlwa ngethemba lokubalekela yona ikolelo le.

== __LEAD_SECTION__ ==

[[File:Good_Food_Display_-_NCI_Visuals_Online.jpg|alt=Table set with red meat, bread, pasta, vegetables, fruit, fish, and beans|thumb|Imifanekiso yokudla okutshiyeneyo]]

'''Ukudla''' yinto yonke edliwa ngumuntu noma isilwane ukuze kutholwe ukusekelwa lokuqina komzimba. esikhathini esinengi ukudla kugoqela okulinywayo, inyamazana, lezihlahla okuyakha umzimba ngokuwunika , ama [[Carbohydrate|carbohydrates]], [[Fat|fats]], [[Protein (nutrient)|proteins]], [[Vitamin|vitamins]], or [[Mineral (nutrient)|minerals]]. ukudla kunikeza umzimba amandla, impilo, lokuwukhulisa. Izinanakazana ezitshiyeneyo zidla ukudla okutshiyeneyo kusiya ngomhlobo wesinanakazane, indaw ephla kuwo kanye lesikhathi esipila kuso

Abantu baynelisa futh sebekwazi ukudinga lokuthola ukudla ngendlela ezitshiyeneyo kuzikhathi eziguqukileyo zemvelo.  Abantu bayapheka ukudla kuvuthwe ukuze bakudle  Ukudla okwaneleyo okudingakalayo ukuze wonke umuntu akuthhole kutholakala kumkhandlo okhangele ngezokudla wona ukudla loku ukuthola ngokulima izilimo zihanjiswe kwabaguqula izilimo bazenze ukudla osokulungele uku dluliselwa ebantwini  ukuze benelise ukusuthisa imbizimba yabo Ubudlelwano lezenzakalo ezikhona phakathi kokulima lokuba lokudla osekulungele ukudliwa butsengisa ukuhi kulobudlelwano obukhulu obukhona phakathi kwezenzakalo lezi lokutshintsha kwezemkhathi ( climate change).</text>
      <sha1>4y1j1g4lcmo7m8y8vuijxp8ymuw7gyc</sha1>
    </revision>
  </page>
  <page>
    <title>Ukulumbana Kwamabizo NgesiNdebele</title>
    <ns>0</ns>
    <id>306</id>
    <revision>
      <id>1640</id>
      <timestamp>2024-03-08T13:51:20Z</timestamp>
      <contributor>
        <username>incubator&gt;Mzukesto</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;kilesi isiqetjhana sizokutjheja indlela amabizo alumbene namkha ahlangene ngayo elimi lesiNdebele.   '''ibizo nesenzo'''--~~~~ ukulumbana kwalesisgaba kwenzeka lokha nakuhlanganiswa ibizo nesenzo, isibonelo; Vusa(isenzo)+Umuzi(ibizo)= Vusimuzi  &quot;</comment>
      <origin>1640</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="345" sha1="9hewt4d921ktwutznaz907mjcwo6fs0" xml:space="preserve">kilesi isiqetjhana sizokutjheja indlela amabizo alumbene namkha ahlangene ngayo elimi lesiNdebele. 

'''ibizo nesenzo'''--[[Umsebenzisi:Mzukesto|Mzukesto]] ([[Umsebenzisi asiqongelane:Mzukesto|talk]]) 13:51, 8 March 2024 (UTC)
ukulumbana kwalesisgaba kwenzeka lokha nakuhlanganiswa ibizo nesenzo, isibonelo; Vusa(isenzo)+Umuzi(ibizo)= Vusimuzi

</text>
      <sha1>9hewt4d921ktwutznaz907mjcwo6fs0</sha1>
    </revision>
    <revision>
      <id>1641</id>
      <parentid>1640</parentid>
      <timestamp>2024-03-08T13:57:42Z</timestamp>
      <contributor>
        <username>incubator&gt;Mzukesto</username>
        <id>0</id>
      </contributor>
      <origin>1641</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="459" sha1="lkn0dg5dpo5h6bahwj9ke682yykaozo" xml:space="preserve">kilesi isiqetjhana sizokutjheja indlela amabizo alumbene namkha ahlangene ngayo elimini lesiNdebele. 

'''ibizo nesenzo'''--[[Umsebenzisi:Mzukesto|Mzukesto]] ([[Umsebenzisi asiqongelane:Mzukesto|talk]]) 13:51, 8 March 2024 (UTC)
ukulumbana kwalesisgaba kwenzeka lokha nakuhlanganiswa ibizo nesenzo, isibonelo; Vusa(isenzo)+Umuzi(ibizo)= Vusimuzi

'''ibizo nebizo'''

ukulumbana kwebizo nebizo kwenzeka lokha nakuhlanganiswa ibizo nelinye ibizo, isibonelo;



</text>
      <sha1>lkn0dg5dpo5h6bahwj9ke682yykaozo</sha1>
    </revision>
    <revision>
      <id>1642</id>
      <parentid>1641</parentid>
      <timestamp>2024-03-09T04:16:01Z</timestamp>
      <contributor>
        <username>incubator&gt;Bobbyshabangu</username>
        <id>0</id>
      </contributor>
      <origin>1642</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="215" sha1="cghulyo5uny1bo8sx0pvdy1k6z52phl" xml:space="preserve">kilesi isiqetjhana sizokutjheja indlela amabizo alumbene namkha ahlangene ngayo elimini lesiNdebele. 

'''ibizo nebizo'''

ukulumbana kwebizo nebizo kwenzeka lokha nakuhlanganiswa ibizo nelinye ibizo, isibonelo;



</text>
      <sha1>cghulyo5uny1bo8sx0pvdy1k6z52phl</sha1>
    </revision>
    <revision>
      <id>1643</id>
      <parentid>1642</parentid>
      <timestamp>2024-10-14T13:47:52Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>1642</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="215" sha1="cghulyo5uny1bo8sx0pvdy1k6z52phl" xml:space="preserve">kilesi isiqetjhana sizokutjheja indlela amabizo alumbene namkha ahlangene ngayo elimini lesiNdebele. 

'''ibizo nebizo'''

ukulumbana kwebizo nebizo kwenzeka lokha nakuhlanganiswa ibizo nelinye ibizo, isibonelo;



</text>
      <sha1>cghulyo5uny1bo8sx0pvdy1k6z52phl</sha1>
    </revision>
  </page>
  <page>
    <title>Ukunganakekelwa kwabentwana abakhubazekileko</title>
    <ns>0</ns>
    <id>307</id>
    <revision>
      <id>1644</id>
      <timestamp>2024-03-09T10:01:13Z</timestamp>
      <contributor>
        <username>incubator&gt;Ntuli Evelyn</username>
        <id>0</id>
      </contributor>
      <comment>Created a page</comment>
      <origin>1644</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="40" sha1="9hmrlftf6qiv6e2c5ckhabm925s6c4b" xml:space="preserve">'''Abantwana abaphila nokukhubazeka'''

</text>
      <sha1>9hmrlftf6qiv6e2c5ckhabm925s6c4b</sha1>
    </revision>
    <revision>
      <id>1645</id>
      <parentid>1644</parentid>
      <timestamp>2024-03-09T10:04:42Z</timestamp>
      <contributor>
        <username>incubator&gt;Ntuli Evelyn</username>
        <id>0</id>
      </contributor>
      <comment>Added a picture</comment>
      <origin>1645</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="177" sha1="7oivyjd8qn89qbodyh9vkf8d5zlqge1" xml:space="preserve">[[Isimumathi:Children with disabilities are at risk in eastern Ukraine 206 (20300351623).jpg|thumb|Abantwana abaphila ne down syndrome]]
'''Abantwana abaphila nokukhubazeka'''

</text>
      <sha1>7oivyjd8qn89qbodyh9vkf8d5zlqge1</sha1>
    </revision>
    <revision>
      <id>1646</id>
      <parentid>1645</parentid>
      <timestamp>2024-03-09T10:07:01Z</timestamp>
      <contributor>
        <username>incubator&gt;Ntuli Evelyn</username>
        <id>0</id>
      </contributor>
      <comment>added a picture</comment>
      <origin>1646</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="244" sha1="cxpymyrogd6nliq8fit04bn40nb2gok" xml:space="preserve">[[Isimumathi:Children with disabilities are at risk in eastern Ukraine 206 (20300351623).jpg|thumb|Abantwana abaphila ne down syndrome]]
[[Isimumathi:Disability symbols.svg|thumb|Imihlobo yokukhubazeka]]
'''Abantwana abaphila nokukhubazeka'''

</text>
      <sha1>cxpymyrogd6nliq8fit04bn40nb2gok</sha1>
    </revision>
    <revision>
      <id>1647</id>
      <parentid>1646</parentid>
      <timestamp>2024-03-09T10:17:32Z</timestamp>
      <contributor>
        <username>incubator&gt;Ntuli Evelyn</username>
        <id>0</id>
      </contributor>
      <comment>written a heading</comment>
      <origin>1647</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="528" sha1="0jgk0w23t1dqvej3rtwmoj2y5xzqb29" xml:space="preserve">[[Isimumathi:Children with disabilities are at risk in eastern Ukraine 206 (20300351623).jpg|thumb|Abantwana abaphila ne down syndrome]]
[[Isimumathi:Disability symbols.svg|thumb|Imihlobo yokukhubazeka]]
'''Abantwana abaphila nokukhubazeka'''

Iinkolo zabentwana abaphila nokukhubazeka ziyimvela ka kancani eendaweni zemakhaya isibonelo endaweni yangeSiyabuswa zinengi tle! iinkolo kodwana abantwana abakhubazekileko kufanele baye ngepitori ukuze bakwazi ukufumana ifundo.

=== ukungakaqeqetjhwa kwabo titjhere eenkolweni. ===

</text>
      <sha1>0jgk0w23t1dqvej3rtwmoj2y5xzqb29</sha1>
    </revision>
    <revision>
      <id>1648</id>
      <parentid>1647</parentid>
      <timestamp>2024-03-09T10:29:51Z</timestamp>
      <contributor>
        <username>incubator&gt;Ntuli Evelyn</username>
        <id>0</id>
      </contributor>
      <comment>added a new paragraph</comment>
      <origin>1648</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="840" sha1="e8yrn79cqcn6bdkrg8gs420l5kt0lun" xml:space="preserve">[[Isimumathi:Children with disabilities are at risk in eastern Ukraine 206 (20300351623).jpg|thumb|Abantwana abaphila ne down syndrome]]
[[Isimumathi:Disability symbols.svg|thumb|Imihlobo yokukhubazeka]]
'''Abantwana abaphila nokukhubazeka'''

Iinkolo zabentwana abaphila nokukhubazeka ziyimvela  kancani eendaweni zemakhaya isibonelo endaweni yange[[Siyabuswa]] zinengi tle! iinkolo kodwana abantwana abakhubazekileko kufanele baye ngepitori ukuze bakwazi ukufumana ifundo.

=== ukungakaqeqetjhwa kwabo titjhere eenkolweni. ===
Abantwana abakhubazekileko bazithola banganakekelwa ngefanelo ngeenkolweni, unobangela walokhu kukobana abotitjheri abanaso isineke sabo. Imihlobo ekhona yokukhubazeka kwabentwana ngile elandelako: abantwana abangaboniko, abangakwazi ukuzikhambela ngeenyawo zabo, abantwana abane [[down syndrome]] njalo njalo.
</text>
      <sha1>e8yrn79cqcn6bdkrg8gs420l5kt0lun</sha1>
    </revision>
    <revision>
      <id>1649</id>
      <parentid>1648</parentid>
      <timestamp>2024-10-14T13:47:53Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>5 revisions imported</comment>
      <origin>1648</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="840" sha1="e8yrn79cqcn6bdkrg8gs420l5kt0lun" xml:space="preserve">[[Isimumathi:Children with disabilities are at risk in eastern Ukraine 206 (20300351623).jpg|thumb|Abantwana abaphila ne down syndrome]]
[[Isimumathi:Disability symbols.svg|thumb|Imihlobo yokukhubazeka]]
'''Abantwana abaphila nokukhubazeka'''

Iinkolo zabentwana abaphila nokukhubazeka ziyimvela  kancani eendaweni zemakhaya isibonelo endaweni yange[[Siyabuswa]] zinengi tle! iinkolo kodwana abantwana abakhubazekileko kufanele baye ngepitori ukuze bakwazi ukufumana ifundo.

=== ukungakaqeqetjhwa kwabo titjhere eenkolweni. ===
Abantwana abakhubazekileko bazithola banganakekelwa ngefanelo ngeenkolweni, unobangela walokhu kukobana abotitjheri abanaso isineke sabo. Imihlobo ekhona yokukhubazeka kwabentwana ngile elandelako: abantwana abangaboniko, abangakwazi ukuzikhambela ngeenyawo zabo, abantwana abane [[down syndrome]] njalo njalo.
</text>
      <sha1>e8yrn79cqcn6bdkrg8gs420l5kt0lun</sha1>
    </revision>
  </page>
  <page>
    <title>Ukungasabethwa kwabentwana Eenkolweni</title>
    <ns>0</ns>
    <id>308</id>
    <revision>
      <id>1650</id>
      <timestamp>2024-03-09T10:47:14Z</timestamp>
      <contributor>
        <username>incubator&gt;Ntuli Evelyn</username>
        <id>0</id>
      </contributor>
      <comment>Edded a picture</comment>
      <origin>1650</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="193" sha1="6yo7m91ae4fvlp6psodecid9gk9b192" xml:space="preserve">'''Ukungasabethwa kwabentwana eenkolweni
[[Isimumathi:FootWhipping.jpg|thumb|Umtwana ubethiwa ngaphasi kweenyawo]]
Ngelimi lesingisi bayibiza kobana yi Abolishment of [[corporal punishment.]]

</text>
      <sha1>6yo7m91ae4fvlp6psodecid9gk9b192</sha1>
    </revision>
    <revision>
      <id>1651</id>
      <parentid>1650</parentid>
      <timestamp>2024-03-09T10:56:23Z</timestamp>
      <contributor>
        <username>incubator&gt;Ntuli Evelyn</username>
        <id>0</id>
      </contributor>
      <comment>added a line</comment>
      <origin>1651</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="280" sha1="ns3ulx9teqgs324jo65hqmu13qdw8kb" xml:space="preserve">'''Ukungasabethwa kwabentwana eenkolweni
[[Isimumathi:FootWhipping.jpg|thumb|Umtwana ubethiwa ngaphasi kweenyawo]]
Ngelimi lesingisi bayibiza kobana yi Abolishment of [[corporal punishment.]] Umthetho uthi abentwana abasabethwa eenkolweni kodwana amatitjheri akakulandeli lokho.

</text>
      <sha1>ns3ulx9teqgs324jo65hqmu13qdw8kb</sha1>
    </revision>
    <revision>
      <id>1652</id>
      <parentid>1651</parentid>
      <timestamp>2024-08-30T09:12:48Z</timestamp>
      <contributor>
        <username>incubator&gt;Nomsa Skosana</username>
        <id>0</id>
      </contributor>
      <minor />
      <origin>1652</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="293" sha1="ctixm7ks2dv9h0p6v2crkjybs7g7o4c" xml:space="preserve">[[Isimumathi:FootWhipping.jpg|thumb|Umntwana ubethwa ngaphasi kweenyawo]]
Ngelimi lesiYeni yi-Abolishment of [[corporal punishment.]] Umthetho oze nentanto yenengi uthi abentwana abasabethwa eenkolweni kodwana abafundisi abakulandeli lokho. Kwezinye iinkolo abafundisi basababetha abafundi. 

</text>
      <sha1>ctixm7ks2dv9h0p6v2crkjybs7g7o4c</sha1>
    </revision>
    <revision>
      <id>1653</id>
      <parentid>1652</parentid>
      <timestamp>2024-10-14T13:47:53Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>3 revisions imported</comment>
      <origin>1652</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="293" sha1="ctixm7ks2dv9h0p6v2crkjybs7g7o4c" xml:space="preserve">[[Isimumathi:FootWhipping.jpg|thumb|Umntwana ubethwa ngaphasi kweenyawo]]
Ngelimi lesiYeni yi-Abolishment of [[corporal punishment.]] Umthetho oze nentanto yenengi uthi abentwana abasabethwa eenkolweni kodwana abafundisi abakulandeli lokho. Kwezinye iinkolo abafundisi basababetha abafundi. 

</text>
      <sha1>ctixm7ks2dv9h0p6v2crkjybs7g7o4c</sha1>
    </revision>
  </page>
  <page>
    <title>Urhoboyi</title>
    <ns>0</ns>
    <id>309</id>
    <revision>
      <id>1654</id>
      <timestamp>2024-08-18T12:04:05Z</timestamp>
      <contributor>
        <username>incubator&gt;Lungile M. Mabhena</username>
        <id>0</id>
      </contributor>
      <comment>I-Athikili ehlathulula umlandu ngegama lenyanga uRhoboyi.</comment>
      <origin>1654</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4114" sha1="3wgaoon9ygyzgja4bwe7pterwmwz6ou" xml:space="preserve">Ngubani uRhoboyi?

Ilimi limamandla begodu ilimi lesiNgisi liyasivimba bona sikghone ukuzwa nokuzwisisa ipilo nakho koke ekuphathelene nepilo njengobuNgoma nesintu.

Yoke into iyazwakala lokha nayikhulunywa ngesintu begodu namhlanjesi sizokukgharidlha igama elithi &quot;uRhoboyi.&quot;

URhoboyi yiNyanga ethiyelelwe ngesihlahla esimila kokuthoma ngo-Agasti bese sithi nasimilako iimpande kanye namakari wakhona ahlaza satjani bese ithuthumbo lakhona limhlophe libe nekunubho etjheli. Isihlahlesi sitholakala khulu ePumalanga la kunzinze khona amaMbo nofana isizwe sabantu ekuthiwa maNdebele. Kungakho kunekulumo edumileko ethi, “Ephasini laboRhoboyi neMbiqana”. Ekuyikulumo esuselwa ekondlweni yesiNdebele eyiveza ubuhle bakwaNdebele. URhoboyi ekukhulunywa ngaye nguye lo bese iMbiqana mrorho othi nawusathelako uhlaza kwesibhakabhaka bese nawutjhako uba-phephuli (purple ngeLimi lesiYeni). IMbiqana sitjhebo kanti godu uyalapha, utlharulula iingazi, mhlambe nangabe iingazi zakho zijamile nofana zimahlwili zineziqa, okuma-Clots ngelimi lesiYeni, lokhu ukubona ngokuthi nawusikazi uya esikhathini uba neenhlabi embelekweni bese ukhiqiza amahlwili, kanti-ke nanoma ungasisikazi iingazi ziyakghona ukusilaphazeka zibe mafindo-finndo. Ye-ke umrorho lo uyatlharulula ukuze iingazi zigime ngefanelo eemthanjeni, nabakwa-''Vein''and ''vascular institude'' bayaveza bona ukutlharulula iingazi kufuna bona usele imirorho anye neentjalo. 

NakuyiNyanga kaRhoboyi (Agasti) kutjhuguluka isikhathi somnyaka. Njengombana sazi bona iinkhathi zomnyaka zine, vane kuphela ubusika kungene iSilimela, esaziwa ngeThwasahlobo nange-Spring ngelimi lesiYeni. KungeNyanga le lapho kuqubuka khona uRhoboyi. Ukutjhuguluka kwesikhathesi kuletha amatjhuguluko ebantwini ngombana soke siyimvelo. Ye-ke isihlahla uRhoboyi senza izinto ezinengi emzimbeni womuntu, kanti ke ngizokundlala ezintathu: Umzimba uyawa ngombana kufanele ujwayele ubujamo beZulu obutjha obuza nesikhathi somnyaka, yeke abantwana bavame ukugula baphathwe mathumbu, uMgomani begodu bathulule. URhoboyi uyamubilisa ngamanzi bese useze abantwana, usiza ngokulekelela umzimba ukuze uqine ube sebujameni obufaneleko ngaphasi kwesikhathi leso; Umntwana otshwenya ngokuzithundela ebusuku nakaleleko uyabiliselwa naye uRhoboyi am'rhamule bese uyalisa ukuzithundela; uyakghona nokuhlamba amazinyo ngoRhoboyi. Lokha nawumhlafunyako njengeTjapisi ngombana wona vele usatjapisi ukhipha iinsalelo zokudla ezihlangana namazinyo, uqede nephunga elimbi ngemlonyeni. Ekadeni kwakuSilibazisamlomo lokha abesana nabayokulusa, nalokha abantazana nabayokukha amanzi emlanjeni.

NgoRhoboyi kuba nento inengi abayibiza ngokuthi yi-Mercury Retrograde ngelimi lesiYeni. Kuphela okhunye, kuthoma okhunye, yeke ngalesi isikhathi izinto ezinengi ziyaphela kuthome ezinye kungakho kuba nokuhlangahlangana kwemizwa, kubuye nofana kukhambe abantu epilweni yomuntu nokuthi laba ebabhujelwe babelethi nabalingani bagule bese kufanele basele amaRherhetjha.

AmaRherhetjha ayaselwa begodu uyathunyisela bese uwothe ngawo khulu khulu lokha ngeNyanga le ekwabhubha umbelethi / umlingani ngombana kulapho umbelethi nofana umlingani aphenduka khona aba nguZimu bese nangoRhoboyi kunetjhuguluko elenzekako ngombana uRhoboyi uthanyela iinsila ngommoya wakhe ukulungiselela uKhukhulamungu la kuthuthumba khona amathuthumbo, kuhluma khona iintjalo begodu kuhlambuluka khona amanzi.

AmaRherhetjha aselwa mumuntu obhujelwe babelethi nalo obhujelwe mntwana (miscarriage &amp; stillborn ngelimi lesiYeni). AmaRherhetjha ahlambulula ubujamo benyama nebommoya, okuziingazi nommoya womuntu ngombana kunokubophana kwemimmoya phakathi kwabantu benyama nabeZimu ekungakafaneli bona siyiqunte ngeenzathu ezithize.

Ye-ke nakungena uRhoboyi kufanele wazi bona wenzani nawumumuntu. URhoboyi uyathanyela begodu uyaqubula ukuze nakathanyelako ngommoya wakhe singalimali bekufike uKhukhulamungu. 

Reference
1) ^ Vein &amp; Vascular. Exploring Vein Treatment Options. 2024. Washington.
2) ^ Premier Medical Group. As The Season Changes, How To Do Our Bodies Respond. 2024.
3) ^ Glamour. Lian Brooks. Mercury Retrograde 2024. August 2024.

</text>
      <sha1>3wgaoon9ygyzgja4bwe7pterwmwz6ou</sha1>
    </revision>
    <revision>
      <id>1655</id>
      <parentid>1654</parentid>
      <timestamp>2024-08-18T12:08:54Z</timestamp>
      <contributor>
        <username>incubator&gt;Lungile M. Mabhena</username>
        <id>0</id>
      </contributor>
      <comment>I added images.</comment>
      <origin>1655</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4193" sha1="8iqko9qtzu1a6xfli53i9zx1aihk13n" xml:space="preserve">[[Isimumathi:URhoboyi.webp|thumb]]
Ngubani uRhoboyi?

Ilimi limamandla begodu ilimi lesiNgisi liyasivimba bona sikghone ukuzwa nokuzwisisa ipilo nakho koke ekuphathelene nepilo njengobuNgoma nesintu.

Yoke into iyazwakala lokha nayikhulunywa ngesintu begodu namhlanjesi sizokukgharidlha igama elithi &quot;uRhoboyi.&quot;
[[Isimumathi:IMbiqana.webp|thumb]]
URhoboyi yiNyanga ethiyelelwe ngesihlahla esimila kokuthoma ngo-Agasti bese sithi nasimilako iimpande kanye namakari wakhona ahlaza satjani bese ithuthumbo lakhona limhlophe libe nekunubho etjheli. Isihlahlesi sitholakala khulu ePumalanga la kunzinze khona amaMbo nofana isizwe sabantu ekuthiwa maNdebele. Kungakho kunekulumo edumileko ethi, “Ephasini laboRhoboyi neMbiqana”. Ekuyikulumo esuselwa ekondlweni yesiNdebele eyiveza ubuhle bakwaNdebele. URhoboyi ekukhulunywa ngaye nguye lo bese iMbiqana mrorho othi nawusathelako uhlaza kwesibhakabhaka bese nawutjhako uba-phephuli (purple ngeLimi lesiYeni). IMbiqana sitjhebo kanti godu uyalapha, utlharulula iingazi, mhlambe nangabe iingazi zakho zijamile nofana zimahlwili zineziqa, okuma-Clots ngelimi lesiYeni, lokhu ukubona ngokuthi nawusikazi uya esikhathini uba neenhlabi embelekweni bese ukhiqiza amahlwili, kanti-ke nanoma ungasisikazi iingazi ziyakghona ukusilaphazeka zibe mafindo-finndo. Ye-ke umrorho lo uyatlharulula ukuze iingazi zigime ngefanelo eemthanjeni, nabakwa-''Vein''and ''vascular institude'' bayaveza bona ukutlharulula iingazi kufuna bona usele imirorho anye neentjalo. 

NakuyiNyanga kaRhoboyi (Agasti) kutjhuguluka isikhathi somnyaka. Njengombana sazi bona iinkhathi zomnyaka zine, vane kuphela ubusika kungene iSilimela, esaziwa ngeThwasahlobo nange-Spring ngelimi lesiYeni. KungeNyanga le lapho kuqubuka khona uRhoboyi. Ukutjhuguluka kwesikhathesi kuletha amatjhuguluko ebantwini ngombana soke siyimvelo. Ye-ke isihlahla uRhoboyi senza izinto ezinengi emzimbeni womuntu, kanti ke ngizokundlala ezintathu: Umzimba uyawa ngombana kufanele ujwayele ubujamo beZulu obutjha obuza nesikhathi somnyaka, yeke abantwana bavame ukugula baphathwe mathumbu, uMgomani begodu bathulule. URhoboyi uyamubilisa ngamanzi bese useze abantwana, usiza ngokulekelela umzimba ukuze uqine ube sebujameni obufaneleko ngaphasi kwesikhathi leso; Umntwana otshwenya ngokuzithundela ebusuku nakaleleko uyabiliselwa naye uRhoboyi am'rhamule bese uyalisa ukuzithundela; uyakghona nokuhlamba amazinyo ngoRhoboyi. Lokha nawumhlafunyako njengeTjapisi ngombana wona vele usatjapisi ukhipha iinsalelo zokudla ezihlangana namazinyo, uqede nephunga elimbi ngemlonyeni. Ekadeni kwakuSilibazisamlomo lokha abesana nabayokulusa, nalokha abantazana nabayokukha amanzi emlanjeni.

NgoRhoboyi kuba nento inengi abayibiza ngokuthi yi-Mercury Retrograde ngelimi lesiYeni. Kuphela okhunye, kuthoma okhunye, yeke ngalesi isikhathi izinto ezinengi ziyaphela kuthome ezinye kungakho kuba nokuhlangahlangana kwemizwa, kubuye nofana kukhambe abantu epilweni yomuntu nokuthi laba ebabhujelwe babelethi nabalingani bagule bese kufanele basele amaRherhetjha.

AmaRherhetjha ayaselwa begodu uyathunyisela bese uwothe ngawo khulu khulu lokha ngeNyanga le ekwabhubha umbelethi / umlingani ngombana kulapho umbelethi nofana umlingani aphenduka khona aba nguZimu bese nangoRhoboyi kunetjhuguluko elenzekako ngombana uRhoboyi uthanyela iinsila ngommoya wakhe ukulungiselela uKhukhulamungu la kuthuthumba khona amathuthumbo, kuhluma khona iintjalo begodu kuhlambuluka khona amanzi.

AmaRherhetjha aselwa mumuntu obhujelwe babelethi nalo obhujelwe mntwana (miscarriage &amp; stillborn ngelimi lesiYeni). AmaRherhetjha ahlambulula ubujamo benyama nebommoya, okuziingazi nommoya womuntu ngombana kunokubophana kwemimmoya phakathi kwabantu benyama nabeZimu ekungakafaneli bona siyiqunte ngeenzathu ezithize.

Ye-ke nakungena uRhoboyi kufanele wazi bona wenzani nawumumuntu. URhoboyi uyathanyela begodu uyaqubula ukuze nakathanyelako ngommoya wakhe singalimali bekufike uKhukhulamungu. 

'''Reference:'''

1) ^ Vein &amp; Vascular. Exploring Vein Treatment Options. 2024. Washington.

2) ^ Premier Medical Group. As The Season Changes, How To Do Our Bodies Respond. 2024.

3) ^ Glamour. Lian Brooks. Mercury Retrograde 2024. August 2024.

</text>
      <sha1>8iqko9qtzu1a6xfli53i9zx1aihk13n</sha1>
    </revision>
    <revision>
      <id>1656</id>
      <parentid>1655</parentid>
      <timestamp>2024-10-14T13:47:53Z</timestamp>
      <contributor>
        <username>Jon Harald Søby</username>
        <id>12</id>
      </contributor>
      <minor />
      <comment>2 revisions imported</comment>
      <origin>1655</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4193" sha1="8iqko9qtzu1a6xfli53i9zx1aihk13n" xml:space="preserve">[[Isimumathi:URhoboyi.webp|thumb]]
Ngubani uRhoboyi?

Ilimi limamandla begodu ilimi lesiNgisi liyasivimba bona sikghone ukuzwa nokuzwisisa ipilo nakho koke ekuphathelene nepilo njengobuNgoma nesintu.

Yoke into iyazwakala lokha nayikhulunywa ngesintu begodu namhlanjesi sizokukgharidlha igama elithi &quot;uRhoboyi.&quot;
[[Isimumathi:IMbiqana.webp|thumb]]
URhoboyi yiNyanga ethiyelelwe ngesihlahla esimila kokuthoma ngo-Agasti bese sithi nasimilako iimpande kanye namakari wakhona ahlaza satjani bese ithuthumbo lakhona limhlophe libe nekunubho etjheli. Isihlahlesi sitholakala khulu ePumalanga la kunzinze khona amaMbo nofana isizwe sabantu ekuthiwa maNdebele. Kungakho kunekulumo edumileko ethi, “Ephasini laboRhoboyi neMbiqana”. Ekuyikulumo esuselwa ekondlweni yesiNdebele eyiveza ubuhle bakwaNdebele. URhoboyi ekukhulunywa ngaye nguye lo bese iMbiqana mrorho othi nawusathelako uhlaza kwesibhakabhaka bese nawutjhako uba-phephuli (purple ngeLimi lesiYeni). IMbiqana sitjhebo kanti godu uyalapha, utlharulula iingazi, mhlambe nangabe iingazi zakho zijamile nofana zimahlwili zineziqa, okuma-Clots ngelimi lesiYeni, lokhu ukubona ngokuthi nawusikazi uya esikhathini uba neenhlabi embelekweni bese ukhiqiza amahlwili, kanti-ke nanoma ungasisikazi iingazi ziyakghona ukusilaphazeka zibe mafindo-finndo. Ye-ke umrorho lo uyatlharulula ukuze iingazi zigime ngefanelo eemthanjeni, nabakwa-''Vein''and ''vascular institude'' bayaveza bona ukutlharulula iingazi kufuna bona usele imirorho anye neentjalo. 

NakuyiNyanga kaRhoboyi (Agasti) kutjhuguluka isikhathi somnyaka. Njengombana sazi bona iinkhathi zomnyaka zine, vane kuphela ubusika kungene iSilimela, esaziwa ngeThwasahlobo nange-Spring ngelimi lesiYeni. KungeNyanga le lapho kuqubuka khona uRhoboyi. Ukutjhuguluka kwesikhathesi kuletha amatjhuguluko ebantwini ngombana soke siyimvelo. Ye-ke isihlahla uRhoboyi senza izinto ezinengi emzimbeni womuntu, kanti ke ngizokundlala ezintathu: Umzimba uyawa ngombana kufanele ujwayele ubujamo beZulu obutjha obuza nesikhathi somnyaka, yeke abantwana bavame ukugula baphathwe mathumbu, uMgomani begodu bathulule. URhoboyi uyamubilisa ngamanzi bese useze abantwana, usiza ngokulekelela umzimba ukuze uqine ube sebujameni obufaneleko ngaphasi kwesikhathi leso; Umntwana otshwenya ngokuzithundela ebusuku nakaleleko uyabiliselwa naye uRhoboyi am'rhamule bese uyalisa ukuzithundela; uyakghona nokuhlamba amazinyo ngoRhoboyi. Lokha nawumhlafunyako njengeTjapisi ngombana wona vele usatjapisi ukhipha iinsalelo zokudla ezihlangana namazinyo, uqede nephunga elimbi ngemlonyeni. Ekadeni kwakuSilibazisamlomo lokha abesana nabayokulusa, nalokha abantazana nabayokukha amanzi emlanjeni.

NgoRhoboyi kuba nento inengi abayibiza ngokuthi yi-Mercury Retrograde ngelimi lesiYeni. Kuphela okhunye, kuthoma okhunye, yeke ngalesi isikhathi izinto ezinengi ziyaphela kuthome ezinye kungakho kuba nokuhlangahlangana kwemizwa, kubuye nofana kukhambe abantu epilweni yomuntu nokuthi laba ebabhujelwe babelethi nabalingani bagule bese kufanele basele amaRherhetjha.

AmaRherhetjha ayaselwa begodu uyathunyisela bese uwothe ngawo khulu khulu lokha ngeNyanga le ekwabhubha umbelethi / umlingani ngombana kulapho umbelethi nofana umlingani aphenduka khona aba nguZimu bese nangoRhoboyi kunetjhuguluko elenzekako ngombana uRhoboyi uthanyela iinsila ngommoya wakhe ukulungiselela uKhukhulamungu la kuthuthumba khona amathuthumbo, kuhluma khona iintjalo begodu kuhlambuluka khona amanzi.

AmaRherhetjha aselwa mumuntu obhujelwe babelethi nalo obhujelwe mntwana (miscarriage &amp; stillborn ngelimi lesiYeni). AmaRherhetjha ahlambulula ubujamo benyama nebommoya, okuziingazi nommoya womuntu ngombana kunokubophana kwemimmoya phakathi kwabantu benyama nabeZimu ekungakafaneli bona siyiqunte ngeenzathu ezithize.

Ye-ke nakungena uRhoboyi kufanele wazi bona wenzani nawumumuntu. URhoboyi uyathanyela begodu uyaqubula ukuze nakathanyelako ngommoya wakhe singalimali bekufike uKhukhulamungu. 

'''Reference:'''

1) ^ Vein &amp; Vascular. Exploring Vein Treatment Options. 2024. Washington.

2) ^ Premier Medical Group. As The Season Changes, How To Do Our Bodies Respond. 2024.

3) ^ Glamour. Lian Brooks. Mercury Retrograde 2024. August 2024.

</text>
      <sha1>8iqko9qtzu1a6xfli53i9zx1aihk13n</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Koavf</title>
    <ns>2</ns>
    <id>310</id>
    <revision>
      <id>1658</id>
      <timestamp>2024-10-14T14:34:34Z</timestamp>
      <contributor>
        <username>Koavf</username>
        <id>13</id>
      </contributor>
      <comment>Created page with &quot;{{#babel:nr-0|en|es-2|de-1|pt-1}} [https://en.wikipedia.org/wiki/User:Koavf !!!!]&quot;</comment>
      <origin>1658</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="81" sha1="elxfdof1cdciy1ycan9ugw9a3ks7i3u" xml:space="preserve">{{#babel:nr-0|en|es-2|de-1|pt-1}}
[https://en.wikipedia.org/wiki/User:Koavf !!!!]</text>
      <sha1>elxfdof1cdciy1ycan9ugw9a3ks7i3u</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Meno25</title>
    <ns>2</ns>
    <id>311</id>
    <revision>
      <id>1659</id>
      <timestamp>2024-10-14T15:51:49Z</timestamp>
      <contributor>
        <username>Meno25</username>
        <id>11</id>
      </contributor>
      <comment>Creating</comment>
      <origin>1659</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="78" sha1="dkcm1o6xzt064h826be7vtnj9rp8l6j" xml:space="preserve">* You can contact me using [[:en:User:Meno25|my English Wikipedia user page]].</text>
      <sha1>dkcm1o6xzt064h826be7vtnj9rp8l6j</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi asiqongelane:Meno25</title>
    <ns>3</ns>
    <id>312</id>
    <revision>
      <id>1660</id>
      <timestamp>2024-10-14T15:56:54Z</timestamp>
      <contributor>
        <username>Meno25</username>
        <id>11</id>
      </contributor>
      <comment>talk</comment>
      <origin>1660</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="49" sha1="3q2l91ok1d3l9wavvtmiq6ao6h5326r" xml:space="preserve">Please leave messages at [[en:User talk:Meno25]].</text>
      <sha1>3q2l91ok1d3l9wavvtmiq6ao6h5326r</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:MenoBot</title>
    <ns>2</ns>
    <id>313</id>
    <revision>
      <id>1661</id>
      <timestamp>2024-10-14T16:17:21Z</timestamp>
      <contributor>
        <username>MenoBot</username>
        <id>16</id>
      </contributor>
      <comment>Creating</comment>
      <origin>1661</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7394" sha1="1a4phrju1anhpdtfgyce48wqn6h45cn" xml:space="preserve">This is an interwiki bot operated by [[User:Meno25|Meno25]].

[[ace:Ureuëng Nguy:MenoBot]]
[[kbd:ЦӀыхухэт:MenoBot]]
[[af:Gebruiker:MenoBot]]
[[als:Benutzer:MenoBot]]
[[am:አባል:MenoBot]]
[[ang:User:MenoBot]]
[[ab:Алахәыла:MenoBot]]
[[ar:مستخدم:MenoBot]]
[[an:Usuario:MenoBot]]
[[arc:ܡܦܠܚܢܐ:MenoBot]]
[[roa-rup:User:MenoBot]]
[[frp:Utilisator:MenoBot]]
[[as:সদস্য:MenoBot]]
[[ast:Usuariu:MenoBot]]
[[gn:Puruhára:MenoBot]]
[[av:Участник:MenoBot]]
[[ay:Usuario:MenoBot]]
[[az:İstifadəçi:MenoBot]]
[[bm:Utilisateur:MenoBot]]
[[bn:ব্যবহারকারী:MenoBot]]
[[bjn:Pamakai:MenoBot]]
[[zh-min-nan:User:MenoBot]]
[[map-bms:Panganggo:MenoBot]]
[[ba:Ҡатнашыусы:MenoBot]]
[[be:Удзельнік:MenoBot]]
[[be-x-old:Удзельнік:MenoBot]]
[[bh:प्रयोगकर्ता:MenoBot]]
[[bcl:Paragamit:MenoBot]]
[[bi:User:MenoBot]]
[[bg:Потребител:MenoBot]]
[[bar:Nutza:MenoBot]]
[[bo:User:MenoBot]]
[[bs:Korisnik:MenoBot]]
[[br:Implijer:MenoBot]]
[[bxr:Участник:MenoBot]]
[[ca:Usuari:MenoBot]]
[[cv:Хутшăнакан:MenoBot]]
[[ceb:Gumagamit:MenoBot]]
[[cs:Wikipedista:MenoBot]]
[[ch:Muna'sesetbi:MenoBot]]
[[cbk-zam:Usuario:MenoBot]]
[[ny:User:MenoBot]]
[[sn:User:MenoBot]]
[[tum:User:MenoBot]]
[[co:User:MenoBot]]
[[cy:Defnyddiwr:MenoBot]]
[[da:Bruger:MenoBot]]
[[pdc:Yuuser:MenoBot]]
[[de:Benutzer:MenoBot]]
[[dv:މެމްބަރު:MenoBot]]
[[nv:Choyoołʼįįhí:MenoBot]]
[[dsb:Wužywaŕ:MenoBot]]
[[dz:User:MenoBot]]
[[et:Kasutaja:MenoBot]]
[[el:Χρήστης:MenoBot]]
[[eml:Utente:MenoBot]]
[[en:User:MenoBot]]
[[myv:Теиця:MenoBot]]
[[es:Usuario:MenoBot]]
[[eo:Uzanto:MenoBot]]
[[ext:User:MenoBot]]
[[eu:Lankide:MenoBot]]
[[ee:User:MenoBot]]
[[fa:کاربر:MenoBot]]
[[hif:sadasya:MenoBot]]
[[fo:Brúkari:MenoBot]]
[[fr:Utilisateur:MenoBot]]
[[fy:Meidogger:MenoBot]]
[[ff:Utilisateur:MenoBot]]
[[fur:Utent:MenoBot]]
[[ga:Úsáideoir:MenoBot]]
[[gv:Ymmydeyr:MenoBot]]
[[gag:Kullanıcı:MenoBot]]
[[gd:Cleachdaiche:MenoBot]]
[[gl:Usuario:MenoBot]]
[[gan:用戶:MenoBot]]
[[ki:User:MenoBot]]
[[glk:کاربر:MenoBot]]
[[gu:સભ્ય:MenoBot]]
[[got:𐌽𐌹𐌿𐍄𐌰𐌽𐌳𐍃:MenoBot]]
[[hak:User:MenoBot]]
[[xal:Демнч:MenoBot]]
[[ko:사용자:MenoBot]]
[[ha:User:MenoBot]]
[[haw:Mea hoʻohana:MenoBot]]
[[hy:Մասնակից:MenoBot]]
[[hi:सदस्य:MenoBot]]
[[hsb:Wužiwar:MenoBot]]
[[hr:Suradnik:MenoBot]]
[[io:Uzanto:MenoBot]]
[[ig:Ọbanife:MenoBot]]
[[ilo:Agar-aramat:MenoBot]]
[[bpy:আতাকুরা:MenoBot]]
[[id:Pengguna:MenoBot]]
[[ia:Usator:MenoBot]]
[[ie:Usator:MenoBot]]
[[iu:User:MenoBot]]
[[ik:User:MenoBot]]
[[os:Архайæг:MenoBot]]
[[xh:User:MenoBot]]
[[zu:User:MenoBot]]
[[is:Notandi:MenoBot]]
[[it:Utente:MenoBot]]
[[he:משתמש:MenoBot]]
[[jv:Panganggo:MenoBot]]
[[kl:Atuisoq:MenoBot]]
[[kn:ಸದಸ್ಯ:MenoBot]]
[[pam:User:MenoBot]]
[[krc:Къошулуучу:MenoBot]]
[[ka:მომხმარებელი:MenoBot]]
[[ks:رُکُن:MenoBot]]
[[csb:Brëkòwnik:MenoBot]]
[[kk:Қатысушы:MenoBot]]
[[kw:Devnydhyer:MenoBot]]
[[rw:User:MenoBot]]
[[rn:User:MenoBot]]
[[sw:Mtumiaji:MenoBot]]
[[kv:Пырысь:MenoBot]]
[[kg:User:MenoBot]]
[[ht:Itilizatè:MenoBot]]
[[ku:Bikarhêner:MenoBot]]
[[ky:Колдонуучу:MenoBot]]
[[mrj:Сирӹшӹ:MenoBot]]
[[lad:Usador:MenoBot]]
[[lbe:Гьуртту хьума:MenoBot]]
[[lez:Участник:MenoBot]]
[[lo:ຜູ້ໃຊ້:MenoBot]]
[[ltg:Lītuotuojs:MenoBot]]
[[la:Usor:MenoBot]]
[[lv:Lietotājs:MenoBot]]
[[lb:Benotzer:MenoBot]]
[[lt:Naudotojas:MenoBot]]
[[lij:Utente:MenoBot]]
[[li:Gebroeker:MenoBot]]
[[ln:Utilisateur:MenoBot]]
[[jbo:User:MenoBot]]
[[lg:User:MenoBot]]
[[lmo:Druvadur:MenoBot]]
[[hu:Szerkesztő:MenoBot]]
[[mk:Корисник:MenoBot]]
[[mg:Mpikambana:MenoBot]]
[[ml:ഉപയോക്താവ്:MenoBot]]
[[mt:Utent:MenoBot]]
[[mi:User:MenoBot]]
[[mr:सदस्य:MenoBot]]
[[xmf:მომხმარებელი:MenoBot]]
[[arz:مستخدم:MenoBot]]
[[mzn:کارور:MenoBot]]
[[ms:Pengguna:MenoBot]]
[[min:Pengguna:MenoBot]]
[[cdo:User:MenoBot]]
[[mwl:Outelizador:MenoBot]]
[[mdf:Тиись:MenoBot]]
[[mn:Хэрэглэгч:MenoBot]]
[[my:User:MenoBot]]
[[nah:Tlatequitiltilīlli:MenoBot]]
[[na:User:MenoBot]]
[[fj:User:MenoBot]]
[[nl:Gebruiker:MenoBot]]
[[nds-nl:Gebruker:MenoBot]]
[[cr:User:MenoBot]]
[[ne:प्रयोगकर्ता:MenoBot]]
[[new:छ्येलेमि:MenoBot]]
[[ja:利用者:MenoBot]]
[[nap:Utente:MenoBot]]
[[ce:Декъашхо:MenoBot]]
[[frr:Benutzer:MenoBot]]
[[pih:User:MenoBot]]
[[no:Bruker:MenoBot]]
[[nn:Brukar:MenoBot]]
[[nrm:User:MenoBot]]
[[nov:User:MenoBot]]
[[oc:Utilizaire:MenoBot]]
[[mhr:Пайдаланыше:MenoBot]]
[[or:ବ୍ୟବହାରକାରୀ:MenoBot]]
[[om:User:MenoBot]]
[[uz:Foydalanuvchi:MenoBot]]
[[pa:ਵਰਤੌਂਕਾਰ:MenoBot]]
[[pi:अवयव:MenoBot]]
[[pfl:Benudzer:MenoBot]]
[[pag:User:MenoBot]]
[[pnb:User:MenoBot]]
[[pap:User:MenoBot]]
[[ps:کارن:MenoBot]]
[[koi:Участник:MenoBot]]
[[km:អ្នកប្រើប្រាស់:MenoBot]]
[[pcd:Utilisateur:MenoBot]]
[[pms:Utent:MenoBot]]
[[tpi:Yusa:MenoBot]]
[[nds:Bruker:MenoBot]]
[[pl:Wikipedysta:MenoBot]]
[[pnt:Χρήστες:MenoBot]]
[[pt:Usuário(a):MenoBot]]
[[kaa:Paydalanıwshı:MenoBot]]
[[crh:Qullanıcı:MenoBot]]
[[ty:Utilisateur:MenoBot]]
[[ksh:Metmaacher:MenoBot]]
[[ro:Utilizator:MenoBot]]
[[rmy:Jeno:MenoBot]]
[[rm:Utilisader:MenoBot]]
[[qu:Ruraq:MenoBot]]
[[rue:Хоснователь:MenoBot]]
[[ru:Участник:MenoBot]]
[[sah:Кыттааччы:MenoBot]]
[[se:Geavaheaddji:MenoBot]]
[[sm:User:MenoBot]]
[[sa:योजकः:MenoBot]]
[[sg:Utilisateur:MenoBot]]
[[sc:Usuàriu:MenoBot]]
[[sco:User:MenoBot]]
[[stq:Benutser:MenoBot]]
[[st:User:MenoBot]]
[[nso:Mošomi:MenoBot]]
[[tn:User:MenoBot]]
[[sq:Përdoruesi:MenoBot]]
[[scn:Utenti:MenoBot]]
[[si:පරිශීලක:MenoBot]]
[[simple:User:MenoBot]]
[[sd:يوزر:MenoBot]]
[[ss:User:MenoBot]]
[[sk:Redaktor:MenoBot]]
[[sl:Uporabnik:MenoBot]]
[[cu:Польꙃєватєл҄ь:MenoBot]]
[[szl:Używacz:MenoBot]]
[[so:User:MenoBot]]
[[ckb:بەکارھێنەر:MenoBot]]
[[srn:Masyin:MenoBot]]
[[sr:Корисник:MenoBot]]
[[sh:Korisnik:MenoBot]]
[[su:Pamaké:MenoBot]]
[[fi:Käyttäjä:MenoBot]]
[[tl:Tagagamit:MenoBot]]
[[ta:பயனர்:MenoBot]]
[[kab:Amseqdac:MenoBot]]
[[roa-tara:User:MenoBot]]
[[tt:Кулланучы:MenoBot]]
[[te:వాడుకరి:MenoBot]]
[[tet:Uza-na'in:MenoBot]]
[[th:ผู้ใช้:MenoBot]]
[[ti:User:MenoBot]]
[[tg:Корбар:MenoBot]]
[[to:User:MenoBot]]
[[chr:User:MenoBot]]
[[chy:User:MenoBot]]
[[ve:User:MenoBot]]
[[tr:Kullanıcı:MenoBot]]
[[tk:Ulanyjy:MenoBot]]
[[tw:User:MenoBot]]
[[udm:Викиавтор:MenoBot]]
[[bug:Pengguna:MenoBot]]
[[uk:Користувач:MenoBot]]
[[ur:صارف:MenoBot]]
[[ug:ئىشلەتكۈچى:MenoBot]]
[[za:用户:MenoBot]]
[[vec:Utente:MenoBot]]
[[vep:Kävutai:MenoBot]]
[[vi:Thành viên:MenoBot]]
[[vo:Geban:MenoBot]]
[[fiu-vro:Pruukja:MenoBot]]
[[wa:Uzeu:MenoBot]]
[[zh-classical:User:MenoBot]]
[[vls:Gebruker:MenoBot]]
[[war:Gumaramit:MenoBot]]
[[wo:Jëfandikukat:MenoBot]]
[[wuu:用户:MenoBot]]
[[ts:User:MenoBot]]
[[yi:באַניצער:MenoBot]]
[[yo:Oníṣe:MenoBot]]
[[zh-yue:User:MenoBot]]
[[diq:Karber:MenoBot]]
[[zea:Gebruker:MenoBot]]
[[bat-smg:Nauduotuos:MenoBot]]
[[zh:User:MenoBot]]</text>
      <sha1>1a4phrju1anhpdtfgyce48wqn6h45cn</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi asiqongelane:MenoBot</title>
    <ns>3</ns>
    <id>314</id>
    <revision>
      <id>1662</id>
      <timestamp>2024-10-14T16:21:11Z</timestamp>
      <contributor>
        <username>MenoBot</username>
        <id>16</id>
      </contributor>
      <comment>talk</comment>
      <origin>1662</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="61" sha1="5s08lno63fyjy199utyypwti04u4y28" xml:space="preserve">Please leave comments in English at [[:en:User talk:Meno25]].</text>
      <sha1>5s08lno63fyjy199utyypwti04u4y28</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Hugo.arg</title>
    <ns>2</ns>
    <id>315</id>
    <revision>
      <id>1684</id>
      <timestamp>2024-10-16T15:03:39Z</timestamp>
      <contributor>
        <username>Hugo.arg</username>
        <id>37</id>
      </contributor>
      <comment>Created page with &quot;{{#babel:lt|en-3|es-2|ru-2|pt-1|hi-1|sa-2|nr-0}} Hi! I'm a user from Lithuania, a sysop of Samogitian and Guarani wikipedias.  You can contact me '''[[:lt:User talk:Hugo.arg|here]]'''  *'''[[commons:User:Hugo.arg/Gallery|My gallery in commons]]'''  [[file:Polokwane Local Municipality, South Africa - panoramio (3).jpg|thumb|left|430px|Polokwane Local Municipality]]  [[lt:Naudotojas:Hugo.arg]]&quot;</comment>
      <origin>1684</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="394" sha1="sdzijnhp4z39qcniszggw3456a0pmlz" xml:space="preserve">{{#babel:lt|en-3|es-2|ru-2|pt-1|hi-1|sa-2|nr-0}}
Hi! I'm a user from Lithuania, a sysop of Samogitian and Guarani wikipedias.

You can contact me '''[[:lt:User talk:Hugo.arg|here]]'''

*'''[[commons:User:Hugo.arg/Gallery|My gallery in commons]]'''

[[file:Polokwane Local Municipality, South Africa - panoramio (3).jpg|thumb|left|430px|Polokwane Local Municipality]]

[[lt:Naudotojas:Hugo.arg]]</text>
      <sha1>sdzijnhp4z39qcniszggw3456a0pmlz</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi asiqongelane:Ameisenigel</title>
    <ns>3</ns>
    <id>319</id>
    <revision>
      <id>1699</id>
      <timestamp>2024-10-20T08:35:15Z</timestamp>
      <contributor>
        <username>Ameisenigel</username>
        <id>61</id>
      </contributor>
      <comment>Created page with &quot;[[File:Redirect arrow without text.svg|46px|link=]][[m:User talk:Ameisenigel|m:User talk:Ameisenigel]]&quot;</comment>
      <origin>1699</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="102" sha1="2229pjupj4oxyrzx6wq7rucquxcn3pt" xml:space="preserve">[[File:Redirect arrow without text.svg|46px|link=]][[m:User talk:Ameisenigel|m:User talk:Ameisenigel]]</text>
      <sha1>2229pjupj4oxyrzx6wq7rucquxcn3pt</sha1>
    </revision>
  </page>
  <page>
    <title>Nelson Makamo</title>
    <ns>0</ns>
    <id>320</id>
    <revision>
      <id>1700</id>
      <timestamp>2024-10-21T02:16:19Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created page with &quot;U-Nelson Makamo (Nhlolanja 1982) mdwebi weenthombe we[[Isewula Afrika|Sewula Afrika]] wesimanjemanje owaziwa ngeenthombe ezivamise ukuveza abantwana beSewula Afrika abasemaphandleni. U-Makamo utjengise umsebenzi wakhe emazweni ngamazwe, ngemibukiso yedwa emadorobheni afana ne-Los Angeles, Paris, London, New York kanye neSewula Afrika.  == Iminyaka yokuthoma == U-Makamo wabelethwa e-[[Modimolle]], e-Limpopo, eSewula Afrika, ngoMhlolanja wee-1982, begodu ukuthakazelela kwa...&quot;</comment>
      <origin>1700</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1258" sha1="khltg0g25phfvj8qbf8x5wltfoarluw" xml:space="preserve">U-Nelson Makamo (Nhlolanja 1982) mdwebi weenthombe we[[Isewula Afrika|Sewula Afrika]] wesimanjemanje owaziwa ngeenthombe ezivamise ukuveza abantwana beSewula Afrika abasemaphandleni. U-Makamo utjengise umsebenzi wakhe emazweni ngamazwe, ngemibukiso yedwa emadorobheni afana ne-Los Angeles, Paris, London, New York kanye neSewula Afrika.

== Iminyaka yokuthoma ==
U-Makamo wabelethwa e-[[Modimolle]], e-Limpopo, eSewula Afrika, ngoMhlolanja wee-1982, begodu ukuthakazelela kwakhe ukudweba kwathoma asesemncani. Wafunda e-Artist Proof Studio e-Goli, lapho afunda khona ngokukhethekileko ngokwenza amaphrinti.[1] Isikhungo lesi saba yingcenye eqakathekileko yohambo lwakhe, samsiza bona athuthukise amaqhinga ahlukahlukeneko, ukusuka emidwebeni yamalahle ukuya ekudwebeni ngamafutha ne-acrylic.

=== Isitayela sobuKghwari kanye neengqikithi===

U-Makamo waziwa khulu ngeenthombe zakhe ezizwakalako nezikhulu, khulukhulu zabantwana, kanengi asebenzisa imibala ekhanyako nemigqa evezako. Imisebenzi yakhe yenziwa ngamalahle, amapende wamafutha, nama-acrylic, begodu iyadunyiswa ngokujula kwayo, ukuthungwa, nokuzwakala kwayo. Ukutjheja kwakhe abantwana, khulukhulu abantwana abanzima abavela emaphandleni weSewula Afrika, kuqakathekile embonweni wakhe wezobuciko.</text>
      <sha1>khltg0g25phfvj8qbf8x5wltfoarluw</sha1>
    </revision>
    <revision>
      <id>1701</id>
      <parentid>1700</parentid>
      <timestamp>2024-10-21T02:16:53Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1701</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1260" sha1="glajnwf60f2mrqyo6kc1ioj45d8rkc2" xml:space="preserve">U-Nelson Makamo (Nhlolanja 1982) mdwebi weenthombe we[[Isewula Afrika|Sewula Afrika]] wesimanjemanje owaziwa ngeenthombe ezivamise ukuveza abantwana beSewula Afrika abasemaphandleni. U-Makamo utjengise umsebenzi wakhe emazweni ngamazwe, ngemibukiso yedwa emadorobheni afana ne-Los Angeles, Paris, London, New York kanye neSewula Afrika.

== Iminyaka yokuthoma ==
U-Makamo wabelethwa e-[[Modimolle]], e-Limpopo, eSewula Afrika, ngoMhlolanja wee-1982, begodu ukuthakazelela kwakhe ukudweba kwathoma asesemncani. Wafunda e-Artist Proof Studio e-Goli, lapho afunda khona ngokukhethekileko ngokwenza amaphrinti.[1] Isikhungo lesi saba yingcenye eqakathekileko yohambo lwakhe, samsiza bona athuthukise amaqhinga ahlukahlukeneko, ukusuka emidwebeni yamalahle ukuya ekudwebeni ngamafutha ne-acrylic.

==== Isitayela sobuKghwari kanye neengqikithi ====
U-Makamo waziwa khulu ngeenthombe zakhe ezizwakalako nezikhulu, khulukhulu zabantwana, kanengi asebenzisa imibala ekhanyako nemigqa evezako. Imisebenzi yakhe yenziwa ngamalahle, amapende wamafutha, nama-acrylic, begodu iyadunyiswa ngokujula kwayo, ukuthungwa, nokuzwakala kwayo. Ukutjheja kwakhe abantwana, khulukhulu abantwana abanzima abavela emaphandleni weSewula Afrika, kuqakathekile embonweni wakhe wezobuciko.</text>
      <sha1>glajnwf60f2mrqyo6kc1ioj45d8rkc2</sha1>
    </revision>
    <revision>
      <id>1702</id>
      <parentid>1701</parentid>
      <timestamp>2024-10-21T02:18:19Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1702</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1625" sha1="a351jsinawjmp7b75tx5dzyvux2oe2g" xml:space="preserve">U-Nelson Makamo (Nhlolanja 1982) mdwebi weenthombe we[[Isewula Afrika|Sewula Afrika]] wesimanjemanje owaziwa ngeenthombe ezivamise ukuveza abantwana beSewula Afrika abasemaphandleni. U-Makamo utjengise umsebenzi wakhe emazweni ngamazwe, ngemibukiso yedwa emadorobheni afana ne-Los Angeles, Paris, London, New York kanye neSewula Afrika.&lt;ref&gt;https://thisisafrica.me/arts-and-culture/nelson-makamo-artwork-feature-on-time-mag-cover/&lt;/ref&gt;&lt;ref&gt;https://www.artsy.net/artist/nelson-makamo&lt;/ref&gt;

== Iminyaka yokuthoma ==
U-Makamo wabelethwa e-[[Modimolle]], e-Limpopo, eSewula Afrika, ngoMhlolanja wee-1982, begodu ukuthakazelela kwakhe ukudweba kwathoma asesemncani. Wafunda e-Artist Proof Studio e-Goli, lapho afunda khona ngokukhethekileko ngokwenza amaphrinti.[1] Isikhungo lesi saba yingcenye eqakathekileko yohambo lwakhe, samsiza bona athuthukise amaqhinga ahlukahlukeneko, ukusuka emidwebeni yamalahle ukuya ekudwebeni ngamafutha ne-acrylic.&lt;ref&gt;https://www.carmag.co.za/news/porsche-art-nelson-makamo/&lt;/ref&gt;

==== Isitayela sobuKghwari kanye neengqikithi ====
U-Makamo waziwa khulu ngeenthombe zakhe ezizwakalako nezikhulu, khulukhulu zabantwana, kanengi asebenzisa imibala ekhanyako nemigqa evezako. Imisebenzi yakhe yenziwa ngamalahle, amapende wamafutha, nama-acrylic, begodu iyadunyiswa ngokujula kwayo, ukuthungwa, nokuzwakala kwayo. Ukutjheja kwakhe abantwana, khulukhulu abantwana abanzima abavela emaphandleni weSewula Afrika, kuqakathekile embonweni wakhe wezobuciko.&lt;ref&gt;https://www.timeslive.co.za/sunday-times/lifestyle/2019-02-12-from-limpopo-to-the-world-stage-nelson-makamo-and-his-big-name-fan-base/&lt;/ref&gt;</text>
      <sha1>a351jsinawjmp7b75tx5dzyvux2oe2g</sha1>
    </revision>
    <revision>
      <id>1703</id>
      <parentid>1702</parentid>
      <timestamp>2024-10-21T02:19:07Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1703</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1641" sha1="rk6ecdf2fk7wtwd8uf9ny7pye3p212e" xml:space="preserve">U-Nelson Makamo (Nhlolanja 1982) mdwebi weenthombe we[[Isewula Afrika|Sewula Afrika]] wesimanjemanje owaziwa ngeenthombe ezivamise ukuveza abantwana beSewula Afrika abasemaphandleni. U-Makamo utjengise umsebenzi wakhe emazweni ngamazwe, ngemibukiso yedwa emadorobheni afana ne-Los Angeles, Paris, London, New York kanye neSewula Afrika.&lt;ref&gt;https://thisisafrica.me/arts-and-culture/nelson-makamo-artwork-feature-on-time-mag-cover/&lt;/ref&gt;&lt;ref&gt;https://www.artsy.net/artist/nelson-makamo&lt;/ref&gt;

== Iminyaka yokuthoma ==
U-Makamo wabelethwa e-[[Modimolle]], e-Limpopo, eSewula Afrika, ngoMhlolanja wee-1982, begodu ukuthakazelela kwakhe ukudweba kwathoma asesemncani. Wafunda e-Artist Proof Studio e-Goli, lapho afunda khona ngokukhethekileko ngokwenza amaphrinti.[1] Isikhungo lesi saba yingcenye eqakathekileko yohambo lwakhe, samsiza bona athuthukise amaqhinga ahlukahlukeneko, ukusuka emidwebeni yamalahle ukuya ekudwebeni ngamafutha ne-acrylic.&lt;ref&gt;https://www.carmag.co.za/news/porsche-art-nelson-makamo/&lt;/ref&gt;

==== Isitayela sobuKghwari kanye neengqikithi ====
U-Makamo waziwa khulu ngeenthombe zakhe ezizwakalako nezikhulu, khulukhulu zabantwana, kanengi asebenzisa imibala ekhanyako nemigqa evezako. Imisebenzi yakhe yenziwa ngamalahle, amapende wamafutha, nama-acrylic, begodu iyadunyiswa ngokujula kwayo, ukuthungwa, nokuzwakala kwayo. Ukutjheja kwakhe abantwana, khulukhulu abantwana abanzima abavela emaphandleni weSewula Afrika, kuqakathekile embonweni wakhe wezobuciko.&lt;ref&gt;https://www.timeslive.co.za/sunday-times/lifestyle/2019-02-12-from-limpopo-to-the-world-stage-nelson-makamo-and-his-big-name-fan-base/&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>rk6ecdf2fk7wtwd8uf9ny7pye3p212e</sha1>
    </revision>
    <revision>
      <id>1704</id>
      <parentid>1703</parentid>
      <timestamp>2024-10-21T02:20:59Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1704</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1739" sha1="7j9bjld7iherm0amn7lqxfd01luwh7m" xml:space="preserve">U-Nelson Makamo (Nhlolanja 1982) mdwebi weenthombe we[[Isewula Afrika|Sewula Afrika]] wesimanjemanje owaziwa ngeenthombe ezivamise ukuveza abantwana beSewula Afrika abasemaphandleni. U-Makamo utjengise umsebenzi wakhe emazweni ngamazwe, ngemibukiso yedwa emadorobheni afana ne-Los Angeles, Paris, London, New York kanye neSewula Afrika.&lt;ref&gt;https://thisisafrica.me/arts-and-culture/nelson-makamo-artwork-feature-on-time-mag-cover/&lt;/ref&gt;&lt;ref&gt;https://www.artsy.net/artist/nelson-makamo&lt;/ref&gt;

== Iminyaka yokuthoma ==
U-Makamo wabelethwa e-[[Modimolle]], e-Limpopo, eSewula Afrika, ngoMhlolanja wee-1982, begodu ukuthakazelela kwakhe ukudweba kwathoma asesemncani. Wafunda e-Artist Proof Studio e-Goli, lapho afunda khona ngokukhethekileko ngokwenza amaphrinti.[1] Isikhungo lesi saba yingcenye eqakathekileko yohambo lwakhe, samsiza bona athuthukise amaqhinga ahlukahlukeneko, ukusuka emidwebeni yamalahle ukuya ekudwebeni ngamafutha ne-acrylic.&lt;ref&gt;https://www.carmag.co.za/news/porsche-art-nelson-makamo/&lt;/ref&gt;

==== Isitayela sobuKghwari kanye neengqikithi ====
U-Makamo waziwa khulu ngeenthombe zakhe ezizwakalako nezikhulu, khulukhulu zabantwana, kanengi asebenzisa imibala ekhanyako nemigqa evezako. Imisebenzi yakhe yenziwa ngamalahle, amapende wamafutha, nama-acrylic, begodu iyadunyiswa ngokujula kwayo, ukuthungwa, nokuzwakala kwayo. Ukutjheja kwakhe abantwana, khulukhulu abantwana abanzima abavela emaphandleni weSewula Afrika, kuqakathekile embonweni wakhe wezobuciko.&lt;ref&gt;https://www.timeslive.co.za/sunday-times/lifestyle/2019-02-12-from-limpopo-to-the-world-stage-nelson-makamo-and-his-big-name-fan-base/&lt;/ref&gt;

== Iinkomba ==
[[Category:eSewula Afrika]]
[[Category:Abadwebi]]
[[Category:Abosaziwako]]
[[Category: Imigwalo]]</text>
      <sha1>7j9bjld7iherm0amn7lqxfd01luwh7m</sha1>
    </revision>
    <revision>
      <id>1713</id>
      <parentid>1704</parentid>
      <timestamp>2024-10-21T06:08:54Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1713</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1745" sha1="m9amnlmk6o8efb5yrthtcb3j5sqv32n" xml:space="preserve">'''U-Nelson Makamo''' (Nhlolanja 1982) mdwebi weenthombe we[[Isewula Afrika|Sewula Afrika]] wesimanjemanje owaziwa ngeenthombe ezivamise ukuveza abantwana beSewula Afrika abasemaphandleni. U-Makamo utjengise umsebenzi wakhe emazweni ngamazwe, ngemibukiso yedwa emadorobheni afana ne-Los Angeles, Paris, London, New York kanye neSewula Afrika.&lt;ref&gt;https://thisisafrica.me/arts-and-culture/nelson-makamo-artwork-feature-on-time-mag-cover/&lt;/ref&gt;&lt;ref&gt;https://www.artsy.net/artist/nelson-makamo&lt;/ref&gt;

== Iminyaka yokuthoma ==
U-Makamo wabelethwa e-[[Modimolle]], e-Limpopo, eSewula Afrika, ngoMhlolanja wee-1982, begodu ukuthakazelela kwakhe ukudweba kwathoma asesemncani. Wafunda e-Artist Proof Studio e-Goli, lapho afunda khona ngokukhethekileko ngokwenza amaphrinti.[1] Isikhungo lesi saba yingcenye eqakathekileko yohambo lwakhe, samsiza bona athuthukise amaqhinga ahlukahlukeneko, ukusuka emidwebeni yamalahle ukuya ekudwebeni ngamafutha ne-acrylic.&lt;ref&gt;https://www.carmag.co.za/news/porsche-art-nelson-makamo/&lt;/ref&gt;

==== Isitayela sobuKghwari kanye neengqikithi ====
U-Makamo waziwa khulu ngeenthombe zakhe ezizwakalako nezikhulu, khulukhulu zabantwana, kanengi asebenzisa imibala ekhanyako nemigqa evezako. Imisebenzi yakhe yenziwa ngamalahle, amapende wamafutha, nama-acrylic, begodu iyadunyiswa ngokujula kwayo, ukuthungwa, nokuzwakala kwayo. Ukutjheja kwakhe abantwana, khulukhulu abantwana abanzima abavela emaphandleni weSewula Afrika, kuqakathekile embonweni wakhe wezobuciko.&lt;ref&gt;https://www.timeslive.co.za/sunday-times/lifestyle/2019-02-12-from-limpopo-to-the-world-stage-nelson-makamo-and-his-big-name-fan-base/&lt;/ref&gt;

== Iinkomba ==
[[Category:eSewula Afrika]]
[[Category:Abadwebi]]
[[Category:Abosaziwako]]
[[Category: Imigwalo]]</text>
      <sha1>m9amnlmk6o8efb5yrthtcb3j5sqv32n</sha1>
    </revision>
    <revision>
      <id>1733</id>
      <parentid>1713</parentid>
      <timestamp>2024-10-23T23:25:04Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1733</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1769" sha1="gnockdtlzqr673hjg362okg0gq6a98r" xml:space="preserve">'''U-Nelson Makamo''' (Nhlolanja 1982) mdwebi weenthombe we[[Isewula Afrika|Sewula Afrika]] wesimanjemanje owaziwa ngeenthombe ezivamise ukuveza abantwana beSewula Afrika abasemaphandleni. U-Makamo utjengise umsebenzi wakhe emazweni ngamazwe, ngemibukiso yedwa emadorobheni afana ne-Los Angeles, Paris, London, New York kanye neSewula Afrika.&lt;ref&gt;https://thisisafrica.me/arts-and-culture/nelson-makamo-artwork-feature-on-time-mag-cover/&lt;/ref&gt;&lt;ref&gt;https://www.artsy.net/artist/nelson-makamo&lt;/ref&gt;

== Iminyaka yokuthoma ==
U-Makamo wabelethwa e-[[Modimolle]], e-Limpopo, eSewula Afrika, ngoMhlolanja wee-1982, begodu ukuthakazelela kwakhe ukudweba kwathoma asesemncani. Wafunda e-Artist Proof Studio e-Goli, lapho afunda khona ngokukhethekileko ngokwenza amaphrinti.[1] Isikhungo lesi saba yingcenye eqakathekileko yohambo lwakhe, samsiza bona athuthukise amaqhinga ahlukahlukeneko, ukusuka emidwebeni yamalahle ukuya ekudwebeni ngamafutha ne-acrylic.&lt;ref&gt;https://www.carmag.co.za/news/porsche-art-nelson-makamo/&lt;/ref&gt;

==== Isitayela sobuKghwari kanye neengqikithi ====
U-Makamo waziwa khulu ngeenthombe zakhe ezizwakalako nezikhulu, khulukhulu zabantwana, kanengi asebenzisa imibala ekhanyako nemigqa evezako. Imisebenzi yakhe yenziwa ngamalahle, amapende wamafutha, nama-acrylic, begodu iyadunyiswa ngokujula kwayo, ukuthungwa, nokuzwakala kwayo. Ukutjheja kwakhe abantwana, khulukhulu abantwana abanzima abavela emaphandleni weSewula Afrika, kuqakathekile embonweni wakhe wezobuciko.&lt;ref&gt;https://www.timeslive.co.za/sunday-times/lifestyle/2019-02-12-from-limpopo-to-the-world-stage-nelson-makamo-and-his-big-name-fan-base/&lt;/ref&gt;

== Iinkomba ==
[[Category:eSewula Afrika]]
[[Category:Abadwebi]]
[[Category:Abosaziwako]]
[[Category: Imigwalo]]
[[Category:Ubukghwari]]</text>
      <sha1>gnockdtlzqr673hjg362okg0gq6a98r</sha1>
    </revision>
    <revision>
      <id>2119</id>
      <parentid>1733</parentid>
      <timestamp>2024-11-25T18:11:41Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* Iinkomba */Mkhakha</comment>
      <origin>2119</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1777" sha1="73pq027p77eq3e74gcptefwfy22tmi7" xml:space="preserve">'''U-Nelson Makamo''' (Nhlolanja 1982) mdwebi weenthombe we[[Isewula Afrika|Sewula Afrika]] wesimanjemanje owaziwa ngeenthombe ezivamise ukuveza abantwana beSewula Afrika abasemaphandleni. U-Makamo utjengise umsebenzi wakhe emazweni ngamazwe, ngemibukiso yedwa emadorobheni afana ne-Los Angeles, Paris, London, New York kanye neSewula Afrika.&lt;ref&gt;https://thisisafrica.me/arts-and-culture/nelson-makamo-artwork-feature-on-time-mag-cover/&lt;/ref&gt;&lt;ref&gt;https://www.artsy.net/artist/nelson-makamo&lt;/ref&gt;

== Iminyaka yokuthoma ==
U-Makamo wabelethwa e-[[Modimolle]], e-Limpopo, eSewula Afrika, ngoMhlolanja wee-1982, begodu ukuthakazelela kwakhe ukudweba kwathoma asesemncani. Wafunda e-Artist Proof Studio e-Goli, lapho afunda khona ngokukhethekileko ngokwenza amaphrinti.[1] Isikhungo lesi saba yingcenye eqakathekileko yohambo lwakhe, samsiza bona athuthukise amaqhinga ahlukahlukeneko, ukusuka emidwebeni yamalahle ukuya ekudwebeni ngamafutha ne-acrylic.&lt;ref&gt;https://www.carmag.co.za/news/porsche-art-nelson-makamo/&lt;/ref&gt;

==== Isitayela sobuKghwari kanye neengqikithi ====
U-Makamo waziwa khulu ngeenthombe zakhe ezizwakalako nezikhulu, khulukhulu zabantwana, kanengi asebenzisa imibala ekhanyako nemigqa evezako. Imisebenzi yakhe yenziwa ngamalahle, amapende wamafutha, nama-acrylic, begodu iyadunyiswa ngokujula kwayo, ukuthungwa, nokuzwakala kwayo. Ukutjheja kwakhe abantwana, khulukhulu abantwana abanzima abavela emaphandleni weSewula Afrika, kuqakathekile embonweni wakhe wezobuciko.&lt;ref&gt;https://www.timeslive.co.za/sunday-times/lifestyle/2019-02-12-from-limpopo-to-the-world-stage-nelson-makamo-and-his-big-name-fan-base/&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}

[[Mkhakha:eSewula Afrika]]
[[Mkhakha:Abadwebi]]
[[Mkhakha:Abosaziwako]]
[[Mkhakha: Imigwalo]]
[[Mkhakha:Ubukghwari]]</text>
      <sha1>73pq027p77eq3e74gcptefwfy22tmi7</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:ESewula Afrika</title>
    <ns>14</ns>
    <id>321</id>
    <revision>
      <id>1705</id>
      <timestamp>2024-10-21T02:21:11Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created blank page</comment>
      <origin>1705</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Abadwebi</title>
    <ns>14</ns>
    <id>322</id>
    <revision>
      <id>1706</id>
      <timestamp>2024-10-21T02:21:24Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created blank page</comment>
      <origin>1706</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Abosaziwako</title>
    <ns>14</ns>
    <id>323</id>
    <revision>
      <id>1707</id>
      <timestamp>2024-10-21T02:21:36Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created blank page</comment>
      <origin>1707</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
  </page>
  <page>
    <title>Dullstroom</title>
    <ns>0</ns>
    <id>324</id>
    <revision>
      <id>1710</id>
      <timestamp>2024-10-21T02:47:00Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created page with &quot;I-Dullstroom, eyaziwa nangokuthi yi-Emnothweni,[3] yidorobha elincani elisesifundazweni se-Mpumalanga, e[[Isewula Afrika|Sewula Afrika]]. Idorobha lisemakhilomitha ama-35 (amamayela ama-22) enyakatho ye-Belfast kanye namakhilomitha angaba ma-53 (amamayela ama-33) eningizimu-ntshonalanga ye-Lydenburg emgwaqweni we-R540.&lt;ref&gt;{{Cite web|url=http://www.dullstroom.info/|title=Proudly Dullstroom|website=www.dullstroom.info|access-date=Apr 6, 2020}}&lt;/ref&gt;   Kanye ne-Barkly East...&quot;</comment>
      <origin>1710</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="909" sha1="r0omp0ykztw873s0f26gmhhjulzqxfo" xml:space="preserve">I-Dullstroom, eyaziwa nangokuthi yi-Emnothweni,[3] yidorobha elincani elisesifundazweni se-Mpumalanga, e[[Isewula Afrika|Sewula Afrika]]. Idorobha lisemakhilomitha ama-35 (amamayela ama-22) enyakatho ye-Belfast kanye namakhilomitha angaba ma-53 (amamayela ama-33) eningizimu-ntshonalanga ye-Lydenburg emgwaqweni we-R540.&lt;ref&gt;{{Cite web|url=http://www.dullstroom.info/|title=Proudly Dullstroom|website=www.dullstroom.info|access-date=Apr 6, 2020}}&lt;/ref&gt; 

Kanye ne-Barkly East ne-Underberg, ngenye yeendawo eziphambili zeSewula Afrika zokudoba ngeenyoni. Idorobha linesitetjhi sesitimela esiphakemeko khulu eSewula Afrika ngamamitha ama-2,077 (amafidi ama-6,814) ngaphezu kwezinga lelwandle kanye neenyawo ze-De Berg, indawo ephakemeko khulu esifundazweni ngamamitha ama-2,332 (amafidi ayi-7,651). Indawo ye-Dullstroom e-Highveld plateau kusizathu sokuthi ubujamo bezulu bayo buhluke khulu eendaweni eziseduze.</text>
      <sha1>r0omp0ykztw873s0f26gmhhjulzqxfo</sha1>
    </revision>
    <revision>
      <id>1711</id>
      <parentid>1710</parentid>
      <timestamp>2024-10-21T02:47:26Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1711</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="912" sha1="niesd4yd5ff9lrhcdfxajugk1s01c6n" xml:space="preserve">I-'''Dullstroom,''' eyaziwa nangokuthi yi-Emnothweni, yidorobha elincani elisesifundazweni se-Mpumalanga, e[[Isewula Afrika|Sewula Afrika]]. Idorobha lisemakhilomitha ama-35 (amamayela ama-22) enyakatho ye-Belfast kanye namakhilomitha angaba ma-53 (amamayela ama-33) eningizimu-ntshonalanga ye-Lydenburg emgwaqweni we-R540.&lt;ref&gt;{{Cite web|url=http://www.dullstroom.info/|title=Proudly Dullstroom|website=www.dullstroom.info|access-date=Apr 6, 2020}}&lt;/ref&gt; 

Kanye ne-Barkly East ne-Underberg, ngenye yeendawo eziphambili zeSewula Afrika zokudoba ngeenyoni. Idorobha linesitetjhi sesitimela esiphakemeko khulu eSewula Afrika ngamamitha ama-2,077 (amafidi ama-6,814) ngaphezu kwezinga lelwandle kanye neenyawo ze-De Berg, indawo ephakemeko khulu esifundazweni ngamamitha ama-2,332 (amafidi ayi-7,651). Indawo ye-Dullstroom e-Highveld plateau kusizathu sokuthi ubujamo bezulu bayo buhluke khulu eendaweni eziseduze.</text>
      <sha1>niesd4yd5ff9lrhcdfxajugk1s01c6n</sha1>
    </revision>
    <revision>
      <id>1712</id>
      <parentid>1711</parentid>
      <timestamp>2024-10-21T02:47:49Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1712</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="928" sha1="k9t3dvknudjx2f8epgxmeofbh79ptc2" xml:space="preserve">I-'''Dullstroom,''' eyaziwa nangokuthi yi-Emnothweni, yidorobha elincani elisesifundazweni se-Mpumalanga, e[[Isewula Afrika|Sewula Afrika]]. Idorobha lisemakhilomitha ama-35 (amamayela ama-22) enyakatho ye-Belfast kanye namakhilomitha angaba ma-53 (amamayela ama-33) eningizimu-ntshonalanga ye-Lydenburg emgwaqweni we-R540.&lt;ref&gt;{{Cite web|url=http://www.dullstroom.info/|title=Proudly Dullstroom|website=www.dullstroom.info|access-date=Apr 6, 2020}}&lt;/ref&gt; 

Kanye ne-Barkly East ne-Underberg, ngenye yeendawo eziphambili zeSewula Afrika zokudoba ngeenyoni. Idorobha linesitetjhi sesitimela esiphakemeko khulu eSewula Afrika ngamamitha ama-2,077 (amafidi ama-6,814) ngaphezu kwezinga lelwandle kanye neenyawo ze-De Berg, indawo ephakemeko khulu esifundazweni ngamamitha ama-2,332 (amafidi ayi-7,651). Indawo ye-Dullstroom e-Highveld plateau kusizathu sokuthi ubujamo bezulu bayo buhluke khulu eendaweni eziseduze.

== Iinkomba ==</text>
      <sha1>k9t3dvknudjx2f8epgxmeofbh79ptc2</sha1>
    </revision>
    <revision>
      <id>2109</id>
      <parentid>1712</parentid>
      <timestamp>2024-11-25T09:52:13Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* Iinkomba */</comment>
      <origin>2109</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="940" sha1="lqeitc8j75v8diy2ut0u66952h6utap" xml:space="preserve">I-'''Dullstroom,''' eyaziwa nangokuthi yi-Emnothweni, yidorobha elincani elisesifundazweni se-Mpumalanga, e[[Isewula Afrika|Sewula Afrika]]. Idorobha lisemakhilomitha ama-35 (amamayela ama-22) enyakatho ye-Belfast kanye namakhilomitha angaba ma-53 (amamayela ama-33) eningizimu-ntshonalanga ye-Lydenburg emgwaqweni we-R540.&lt;ref&gt;{{Cite web|url=http://www.dullstroom.info/|title=Proudly Dullstroom|website=www.dullstroom.info|access-date=Apr 6, 2020}}&lt;/ref&gt; 

Kanye ne-Barkly East ne-Underberg, ngenye yeendawo eziphambili zeSewula Afrika zokudoba ngeenyoni. Idorobha linesitetjhi sesitimela esiphakemeko khulu eSewula Afrika ngamamitha ama-2,077 (amafidi ama-6,814) ngaphezu kwezinga lelwandle kanye neenyawo ze-De Berg, indawo ephakemeko khulu esifundazweni ngamamitha ama-2,332 (amafidi ayi-7,651). Indawo ye-Dullstroom e-Highveld plateau kusizathu sokuthi ubujamo bezulu bayo buhluke khulu eendaweni eziseduze.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>lqeitc8j75v8diy2ut0u66952h6utap</sha1>
    </revision>
    <revision>
      <id>2889</id>
      <parentid>2109</parentid>
      <timestamp>2025-06-06T15:24:17Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>chicken jockie</comment>
      <origin>2889</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="965" sha1="29b3o7f3esyrnl7h95mq8rvq9vls2f9" xml:space="preserve">[[A Minecraft Movie|I-'''Dullstroom,''' eyaziwa nangokuthi yi-Emnothweni, yidorobha elincani elisesifundazweni se-Mpumalanga, eSewula Afrika. Idorobha lisemakhilomitha ama-35 (amamayela ama-22) enyakatho ye-Belfast kanye namakhilomitha angaba ma-53 (amamayela ama-33) eningizimu-ntshonalanga ye-Lydenburg emgwaqweni we-R540.]]&lt;ref&gt;{{Cite web|url=http://www.dullstroom.info/|title=Proudly Dullstroom|website=www.dullstroom.info|access-date=Apr 6, 2020}}&lt;/ref&gt; 

[[A Minecraft Movie|Kanye ne-Barkly East ne-Underberg, ngenye yeendawo eziphambili zeSewula Afrika zokudoba ngeenyoni. Idorobha linesitetjhi sesitimela esiphakemeko khulu eSewula Afrika ngamamitha ama-2,077 (amafidi ama-6,814) ngaphezu kwezinga lelwandle kanye neenyawo ze-De Berg, indawo ephakemeko khulu esifundazweni ngamamitha ama-2,332 (amafidi ayi-7,651). Indawo ye-Dullstroom e-Highveld plateau kusizathu sokuthi ubujamo bezulu bayo buhluke khulu eendaweni eziseduze.]]

== Iinkomba ==
{{Reflist}}</text>
      <sha1>29b3o7f3esyrnl7h95mq8rvq9vls2f9</sha1>
    </revision>
    <revision>
      <id>2973</id>
      <parentid>2889</parentid>
      <timestamp>2025-06-06T20:01:57Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>,umyjnbgtrvfecd</comment>
      <origin>2973</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1052" sha1="okclsypk6ffd1vqx997jz3cbqp1mrln" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.''' [[A Minecraft Movie|I-'''Dullstroom,''' eyaziwa nangokuthi yi-Emnothweni, yidorobha elincani elisesifundazweni se-Mpumalanga, eSewula Afrika. Idorobha lisemakhilomitha ama-35 (amamayela ama-22) enyakatho ye-Belfast kanye namakhilomitha angaba ma-53 (amamayela ama-33) eningizimu-ntshonalanga ye-Lydenburg emgwaqweni we-R540.]]&lt;ref&gt;{{Cite web|url=http://www.dullstroom.info/|title=Proudly Dullstroom|website=www.dullstroom.info|access-date=Apr 6, 2020}}&lt;/ref&gt; 

[[A Minecraft Movie|Kanye ne-Barkly East ne-Underberg, ngenye yeendawo eziphambili zeSewula Afrika zokudoba ngeenyoni. Idorobha linesitetjhi sesitimela esiphakemeko khulu eSewula Afrika ngamamitha ama-2,077 (amafidi ama-6,814) ngaphezu kwezinga lelwandle kanye neenyawo ze-De Berg, indawo ephakemeko khulu esifundazweni ngamamitha ama-2,332 (amafidi ayi-7,651). Indawo ye-Dullstroom e-Highveld plateau kusizathu sokuthi ubujamo bezulu bayo buhluke khulu eendaweni eziseduze.]]

== Iinkomba ==
{{Reflist}}</text>
      <sha1>okclsypk6ffd1vqx997jz3cbqp1mrln</sha1>
    </revision>
    <revision>
      <id>3087</id>
      <parentid>2973</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edits by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Simakahle Moselekatse|Simakahle Moselekatse]]</comment>
      <origin>2109</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="940" sha1="lqeitc8j75v8diy2ut0u66952h6utap" xml:space="preserve">I-'''Dullstroom,''' eyaziwa nangokuthi yi-Emnothweni, yidorobha elincani elisesifundazweni se-Mpumalanga, e[[Isewula Afrika|Sewula Afrika]]. Idorobha lisemakhilomitha ama-35 (amamayela ama-22) enyakatho ye-Belfast kanye namakhilomitha angaba ma-53 (amamayela ama-33) eningizimu-ntshonalanga ye-Lydenburg emgwaqweni we-R540.&lt;ref&gt;{{Cite web|url=http://www.dullstroom.info/|title=Proudly Dullstroom|website=www.dullstroom.info|access-date=Apr 6, 2020}}&lt;/ref&gt; 

Kanye ne-Barkly East ne-Underberg, ngenye yeendawo eziphambili zeSewula Afrika zokudoba ngeenyoni. Idorobha linesitetjhi sesitimela esiphakemeko khulu eSewula Afrika ngamamitha ama-2,077 (amafidi ama-6,814) ngaphezu kwezinga lelwandle kanye neenyawo ze-De Berg, indawo ephakemeko khulu esifundazweni ngamamitha ama-2,332 (amafidi ayi-7,651). Indawo ye-Dullstroom e-Highveld plateau kusizathu sokuthi ubujamo bezulu bayo buhluke khulu eendaweni eziseduze.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>lqeitc8j75v8diy2ut0u66952h6utap</sha1>
    </revision>
  </page>
  <page>
    <title>Modimolle</title>
    <ns>0</ns>
    <id>326</id>
    <revision>
      <id>1719</id>
      <timestamp>2024-10-23T19:24:52Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created a new article.</comment>
      <origin>1719</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1876" sha1="r9h0u6j9l5msaf1jb124q98g9n8yb01" xml:space="preserve">'''I-Modimolle''', eyaziwa nangokuthi yi-Nylstroom, yidorobha eliseduze nomkhawulo osewula we-Waterberg Massif esifundazweni se-Limpopo, e[[Isewula Afrika|Sewula Afrika]]. Yidorobha eliphakathi nendawo eliqale khulu ukulima nokulima (ama-citrus, amadiribe kanye neenkomo) kanye neenlwana zeganga nezokuvakatjha. I-Nylstroom nayo itholakala emakhilomitheni angaba li-135 (amamayela ama-84) etlhagwini ye-Pitoli, idorobha elikhulu leSewula Afrika.&lt;ref&gt;https://www.researchgate.net/profile/Nancy-Andrew/publication/237613928_Dilemmes_et_representations_sociales_d%27une_amende_honorable_pour_l%27apartheid_la_communaute_de_Modimolle_et_la_restitution_de_la_terre_en_Afrique_du_Sud/links/56a0bf4908aee4d26ad7c03c/Dilemmes-et-representations-sociales-dune-amende-honorable-pour-lapartheid-la-communaute-de-Modimolle-et-la-restitution-de-la-terre-en-Afrique-du-Sud.pdf&lt;/ref&gt;

I-Waterberg Biosphere esabalalele enyakatho, [[i-UNESCO]] ebizwa ngokuthi yi-Biosphere Reserve, ine-15,000 square kilometers (5,792 square miles). I-Waterberg sisifunda sokuthoma engcenyeni yetlhagwini yeSewula Afrika ukubizwa ngokuthi yi-Biosphere Reserve yi-UNESCO. Ukwakheka kwamadwala okukhulu kwabunjwa makhulu wezigidi zeminyaka yokuguguleka komlambo ukukhiqiza ubujamo obuhlukahlukeneko be-bluff kanye ne-butte. I-ecosystem ingavezwa njengehlathi elomileko elinamakari nofana i-Bushveld.&lt;ref&gt;https://www.researchgate.net/profile/Folaranmi-Yusuf/publication/259702819_Creating_Youth_Employment_through_Modern_Beekeeping_Case_study_of_selected_youth_trained_in_Moro_Local_Government_Area_of_Kwara_State_Nigeria/links/0deec52d642904c2cb000000/Creating-Youth-Employment-through-Modern-Beekeeping-Case-study-of-selected-youth-trained-in-Moro-Local-Government-Area-of-Kwara-State-Nigeria.pdf#page=103&lt;/ref&gt;&lt;ref&gt;https://wiredspace.wits.ac.za/items/52f65b24-226e-43e1-9fef-b2bcaddbd482&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>r9h0u6j9l5msaf1jb124q98g9n8yb01</sha1>
    </revision>
    <revision>
      <id>1720</id>
      <parentid>1719</parentid>
      <timestamp>2024-10-23T19:25:44Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1720</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1904" sha1="ph2ax1ulcv0f0t94jlu5h7s7xh0eaiv" xml:space="preserve">'''I-Modimolle''', eyaziwa nangokuthi yi-Nylstroom, yidorobha eliseduze nomkhawulo osewula we-Waterberg Massif esifundazweni se-Limpopo, e[[Isewula Afrika|Sewula Afrika]]. Yidorobha eliphakathi nendawo eliqale khulu ukulima nokulima (ama-citrus, amadiribe kanye neenkomo) kanye neenlwana zeganga nezokuvakatjha. I-Nylstroom nayo itholakala emakhilomitheni angaba li-135 (amamayela ama-84) etlhagwini ye-Pitoli, idorobha elikhulu leSewula Afrika.&lt;ref&gt;https://www.researchgate.net/profile/Nancy-Andrew/publication/237613928_Dilemmes_et_representations_sociales_d%27une_amende_honorable_pour_l%27apartheid_la_communaute_de_Modimolle_et_la_restitution_de_la_terre_en_Afrique_du_Sud/links/56a0bf4908aee4d26ad7c03c/Dilemmes-et-representations-sociales-dune-amende-honorable-pour-lapartheid-la-communaute-de-Modimolle-et-la-restitution-de-la-terre-en-Afrique-du-Sud.pdf&lt;/ref&gt;

I-Waterberg Biosphere esabalalele enyakatho, [[i-UNESCO]] ebizwa ngokuthi yi-Biosphere Reserve, ine-15,000 square kilometers (5,792 square miles). I-Waterberg sisifunda sokuthoma engcenyeni yetlhagwini yeSewula Afrika ukubizwa ngokuthi yi-Biosphere Reserve yi-UNESCO. Ukwakheka kwamadwala okukhulu kwabunjwa makhulu wezigidi zeminyaka yokuguguleka komlambo ukukhiqiza ubujamo obuhlukahlukeneko be-bluff kanye ne-butte. I-ecosystem ingavezwa njengehlathi elomileko elinamakari nofana i-Bushveld.&lt;ref&gt;https://www.researchgate.net/profile/Folaranmi-Yusuf/publication/259702819_Creating_Youth_Employment_through_Modern_Beekeeping_Case_study_of_selected_youth_trained_in_Moro_Local_Government_Area_of_Kwara_State_Nigeria/links/0deec52d642904c2cb000000/Creating-Youth-Employment-through-Modern-Beekeeping-Case-study-of-selected-youth-trained-in-Moro-Local-Government-Area-of-Kwara-State-Nigeria.pdf#page=103&lt;/ref&gt;&lt;ref&gt;https://wiredspace.wits.ac.za/items/52f65b24-226e-43e1-9fef-b2bcaddbd482&lt;/ref&gt;

== Iinkomba ==
[[Category:iSewula Afrika]]</text>
      <sha1>ph2ax1ulcv0f0t94jlu5h7s7xh0eaiv</sha1>
    </revision>
    <revision>
      <id>1722</id>
      <parentid>1720</parentid>
      <timestamp>2024-10-23T19:27:39Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1722</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1904" sha1="qi42su7vgonkivigd2bkuki8cl22d4t" xml:space="preserve">'''I-Modimolle''', eyaziwa nangokuthi yi-Nylstroom, yidorobha eliseduze nomkhawulo osewula we-Waterberg Massif esifundazweni se-Limpopo, e[[Isewula Afrika|Sewula Afrika]]. Yidorobha eliphakathi nendawo eliqale khulu ukulima nokulima (ama-citrus, amadiribe kanye neenkomo) kanye neenlwana zeganga nezokuvakatjha. I-Nylstroom nayo itholakala emakhilomitheni angaba li-135 (amamayela ama-84) etlhagwini ye-Pitoli, idorobha elikhulu leSewula Afrika.&lt;ref&gt;https://www.researchgate.net/profile/Nancy-Andrew/publication/237613928_Dilemmes_et_representations_sociales_d%27une_amende_honorable_pour_l%27apartheid_la_communaute_de_Modimolle_et_la_restitution_de_la_terre_en_Afrique_du_Sud/links/56a0bf4908aee4d26ad7c03c/Dilemmes-et-representations-sociales-dune-amende-honorable-pour-lapartheid-la-communaute-de-Modimolle-et-la-restitution-de-la-terre-en-Afrique-du-Sud.pdf&lt;/ref&gt;

I-Waterberg Biosphere esabalalele enyakatho, [[i-UNESCO]] ebizwa ngokuthi yi-Biosphere Reserve, ine-15,000 square kilometers (5,792 square miles). I-Waterberg sisifunda sokuthoma engcenyeni yetlhagwini yeSewula Afrika ukubizwa ngokuthi yi-Biosphere Reserve yi-UNESCO. Ukwakheka kwamadwala okukhulu kwabunjwa makhulu wezigidi zeminyaka yokuguguleka komlambo ukukhiqiza ubujamo obuhlukahlukeneko be-bluff kanye ne-butte. I-ecosystem ingavezwa njengehlathi elomileko elinamakari nofana i-Bushveld.&lt;ref&gt;https://www.researchgate.net/profile/Folaranmi-Yusuf/publication/259702819_Creating_Youth_Employment_through_Modern_Beekeeping_Case_study_of_selected_youth_trained_in_Moro_Local_Government_Area_of_Kwara_State_Nigeria/links/0deec52d642904c2cb000000/Creating-Youth-Employment-through-Modern-Beekeeping-Case-study-of-selected-youth-trained-in-Moro-Local-Government-Area-of-Kwara-State-Nigeria.pdf#page=103&lt;/ref&gt;&lt;ref&gt;https://wiredspace.wits.ac.za/items/52f65b24-226e-43e1-9fef-b2bcaddbd482&lt;/ref&gt;

== Iinkomba ==
[[Category:eSewula Afrika]]</text>
      <sha1>qi42su7vgonkivigd2bkuki8cl22d4t</sha1>
    </revision>
    <revision>
      <id>2120</id>
      <parentid>1722</parentid>
      <timestamp>2024-11-25T18:12:20Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* Iinkomba */Mkhakha</comment>
      <origin>2120</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1916" sha1="jlq3dsf0cd6kecjw4sp5uqz8fgpgj4y" xml:space="preserve">'''I-Modimolle''', eyaziwa nangokuthi yi-Nylstroom, yidorobha eliseduze nomkhawulo osewula we-Waterberg Massif esifundazweni se-Limpopo, e[[Isewula Afrika|Sewula Afrika]]. Yidorobha eliphakathi nendawo eliqale khulu ukulima nokulima (ama-citrus, amadiribe kanye neenkomo) kanye neenlwana zeganga nezokuvakatjha. I-Nylstroom nayo itholakala emakhilomitheni angaba li-135 (amamayela ama-84) etlhagwini ye-Pitoli, idorobha elikhulu leSewula Afrika.&lt;ref&gt;https://www.researchgate.net/profile/Nancy-Andrew/publication/237613928_Dilemmes_et_representations_sociales_d%27une_amende_honorable_pour_l%27apartheid_la_communaute_de_Modimolle_et_la_restitution_de_la_terre_en_Afrique_du_Sud/links/56a0bf4908aee4d26ad7c03c/Dilemmes-et-representations-sociales-dune-amende-honorable-pour-lapartheid-la-communaute-de-Modimolle-et-la-restitution-de-la-terre-en-Afrique-du-Sud.pdf&lt;/ref&gt;

I-Waterberg Biosphere esabalalele enyakatho, [[i-UNESCO]] ebizwa ngokuthi yi-Biosphere Reserve, ine-15,000 square kilometers (5,792 square miles). I-Waterberg sisifunda sokuthoma engcenyeni yetlhagwini yeSewula Afrika ukubizwa ngokuthi yi-Biosphere Reserve yi-UNESCO. Ukwakheka kwamadwala okukhulu kwabunjwa makhulu wezigidi zeminyaka yokuguguleka komlambo ukukhiqiza ubujamo obuhlukahlukeneko be-bluff kanye ne-butte. I-ecosystem ingavezwa njengehlathi elomileko elinamakari nofana i-Bushveld.&lt;ref&gt;https://www.researchgate.net/profile/Folaranmi-Yusuf/publication/259702819_Creating_Youth_Employment_through_Modern_Beekeeping_Case_study_of_selected_youth_trained_in_Moro_Local_Government_Area_of_Kwara_State_Nigeria/links/0deec52d642904c2cb000000/Creating-Youth-Employment-through-Modern-Beekeeping-Case-study-of-selected-youth-trained-in-Moro-Local-Government-Area-of-Kwara-State-Nigeria.pdf#page=103&lt;/ref&gt;&lt;ref&gt;https://wiredspace.wits.ac.za/items/52f65b24-226e-43e1-9fef-b2bcaddbd482&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}

[[Mkhakha:eSewula Afrika]]</text>
      <sha1>jlq3dsf0cd6kecjw4sp5uqz8fgpgj4y</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Imigwalo</title>
    <ns>14</ns>
    <id>327</id>
    <revision>
      <id>1721</id>
      <timestamp>2024-10-23T19:26:36Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created blank page</comment>
      <origin>1721</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
  </page>
  <page>
    <title>I-Afrika</title>
    <ns>0</ns>
    <id>328</id>
    <revision>
      <id>1724</id>
      <timestamp>2024-10-23T19:31:07Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created page with &quot;I-A'''frika''' yizwekazi lesibili ngobukhulu begodu lesibili ngenani elikhulu labantu ephasini ngemva kwe-Asia. Ngamakhilomitha angaba ziingidi ezima-30.3 (amamayela ayi-11.7 wezigidi) kufaka hlangana iinhlengele eziseduze, ihlanganisa ama-20% wendawo yomhlaba kanye nama-6% wendawo yayo yoke.[9] Ngabantu abapheze babe ziingidigidi eziyi-1.4 ukusukela ngo-2021, ibalelwa emaphesentini ali-18 wabantu ephasini. Inani labantu be-Afrika mncani khulu kiwo woke amazwekazi;[10][1...&quot;</comment>
      <origin>1724</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1488" sha1="i5at3pizooxgz90zbs6zq0rt2ulj69y" xml:space="preserve">I-A'''frika''' yizwekazi lesibili ngobukhulu begodu lesibili ngenani elikhulu labantu ephasini ngemva kwe-Asia. Ngamakhilomitha angaba ziingidi ezima-30.3 (amamayela ayi-11.7 wezigidi) kufaka hlangana iinhlengele eziseduze, ihlanganisa ama-20% wendawo yomhlaba kanye nama-6% wendawo yayo yoke.[9] Ngabantu abapheze babe ziingidigidi eziyi-1.4 ukusukela ngo-2021, ibalelwa emaphesentini ali-18 wabantu ephasini. Inani labantu be-Afrika mncani khulu kiwo woke amazwekazi;[10][11] iminyaka ephakathi ngo-2012 beyiyi-19.7, lokha iminyaka ephakathi yephasi loke beyiyi-30.4.[12] Ngokuya ngokuqagela kwango-2024, inani labantu be-Afrika lizakufikelela ebantwini abaziingidigidi ezi-3.8 ngo-2099.[13] Nanyana kunemithombo yemvelo eminengi, i-Afrika yizwekazi elinenotho encani ngehloko begodu liyindawo yesibili engananotho enengi, ngaphambi kwe-Oceania. Izazi zithi lokhu kungenxa yezinto ezihlukahlukeneko ezifaka hlangana ubujamo bendawo, ubujamo bezulu,[14] ikohlakalo,[14] ubukoloniyali, iPi yomKhuhlane,[15][16] kanye nobukoloniyali obutjha. Nanyana kunobujamo obuphasi bomnotho, ukwanda kwezomnotho kwamuva nje kanye nenani labantu abanengi nabasesebatjha kwenza i-Afrika ibe yimakethe eqakathekileko yezomnotho ephasini loke. I-Afrika inenani elikhulu lemithombo yemvelo nemithombo yokudla, okufakahlangana amadayimane, itjhukela, itswayi, igolide, i-ayini, i-cobalt, i-uranium, ikhopha, i-bauxite, isiliva, i-petroleum, igesi yemvelo, iimbhontjisi ze-cocoa, kanye nezithelo ezitjhisako.</text>
      <sha1>i5at3pizooxgz90zbs6zq0rt2ulj69y</sha1>
    </revision>
    <revision>
      <id>1725</id>
      <parentid>1724</parentid>
      <timestamp>2024-10-23T19:32:16Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1725</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1492" sha1="0p0zbi93y1cmdg2r98k0nbpsf529n5c" xml:space="preserve">I-A'''frika''' yizwekazi lesibili ngobukhulu begodu lesibili ngenani elikhulu labantu ephasini ngemva kwe-[[Asia]]. Ngamakhilomitha angaba ziingidi ezima-30.3 (amamayela ayi-11.7 wezigidi) kufaka hlangana iinhlengele eziseduze, ihlanganisa ama-20% wendawo yomhlaba kanye nama-6% wendawo yayo yoke.[9] Ngabantu abapheze babe ziingidigidi eziyi-1.4 ukusukela ngo-2021, ibalelwa emaphesentini ali-18 wabantu ephasini. Inani labantu be-Afrika mncani khulu kiwo woke amazwekazi;[10][11] iminyaka ephakathi ngo-2012 beyiyi-19.7, lokha iminyaka ephakathi yephasi loke beyiyi-30.4.[12] Ngokuya ngokuqagela kwango-2024, inani labantu be-Afrika lizakufikelela ebantwini abaziingidigidi ezi-3.8 ngo-2099.[13] Nanyana kunemithombo yemvelo eminengi, i-Afrika yizwekazi elinenotho encani ngehloko begodu liyindawo yesibili engananotho enengi, ngaphambi kwe-Oceania. Izazi zithi lokhu kungenxa yezinto ezihlukahlukeneko ezifaka hlangana ubujamo bendawo, ubujamo bezulu,[14] ikohlakalo,[14] ubukoloniyali, iPi yomKhuhlane,[15][16] kanye nobukoloniyali obutjha. Nanyana kunobujamo obuphasi bomnotho, ukwanda kwezomnotho kwamuva nje kanye nenani labantu abanengi nabasesebatjha kwenza i-Afrika ibe yimakethe eqakathekileko yezomnotho ephasini loke. I-Afrika inenani elikhulu lemithombo yemvelo nemithombo yokudla, okufakahlangana amadayimane, itjhukela, itswayi, igolide, i-ayini, i-cobalt, i-uranium, ikhopha, i-bauxite, isiliva, i-petroleum, igesi yemvelo, iimbhontjisi ze-cocoa, kanye nezithelo ezitjhisako.</text>
      <sha1>0p0zbi93y1cmdg2r98k0nbpsf529n5c</sha1>
    </revision>
    <revision>
      <id>1726</id>
      <parentid>1725</parentid>
      <timestamp>2024-10-23T19:40:02Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1726</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1517" sha1="2pcid7v5emk6ki9rxqmv2igye8s6z0h" xml:space="preserve">I-A'''frika''' yizwekazi lesibili ngobukhulu begodu lesibili ngenani elikhulu labantu ephasini ngemva kwe-[[Asia]]. Ngamakhilomitha angaba ziingidi ezima-30.3 (amamayela ayi-11.7 wezigidi) kufaka hlangana iinhlengele eziseduze, ihlanganisa ama-20% wendawo yomhlaba kanye nama-6% wendawo yayo yoke.[9] Ngabantu abapheze babe ziingidigidi eziyi-1.4 ukusukela ngo-2021, ibalelwa emaphesentini ali-18 wabantu ephasini. Inani labantu be-Afrika mncani khulu kiwo woke amazwekazi. iminyaka ephakathi ngo-2012 beyiyi-19.7, lokha iminyaka ephakathi yephasi loke beyiyi-30.4.Ngokuya ngokuqagela kwango-2024, inani labantu be-Afrika lizakufikelela ebantwini abaziingidigidi ezi-3.8 ngo-2099.[Nanyana kunemithombo yemvelo eminengi, i-Afrika yizwekazi elinenotho encani ngehloko begodu liyindawo yesibili engananotho enengi, ngaphambi kwe-Oceania. Izazi zithi lokhu kungenxa yezinto ezihlukahlukeneko ezifaka hlangana ubujamo bendawo, ubujamo bezulu, ikohlakalo,ubukoloniyali, iPi yomKhuhlane, kanye nobukoloniyali obutjha. Nanyana kunobujamo obuphasi bomnotho, ukwanda kwezomnotho kwamuva nje kanye nenani labantu abanengi nabasesebatjha kwenza i-Afrika ibe yimakethe eqakathekileko yezomnotho ephasini loke. I-Afrika inenani elikhulu lemithombo yemvelo nemithombo yokudla, okufakahlangana amadayimane, itjhukela, itswayi, igolide, i-ayini, i-cobalt, i-uranium, ikhopha, i-bauxite, isiliva, i-petroleum, igesi yemvelo, iimbhontjisi ze-cocoa, kanye nezithelo ezitjhisako.&lt;ref&gt;https://www.bbc.com/gahuza/articles/cwy54qk14q8o&lt;/ref&gt;</text>
      <sha1>2pcid7v5emk6ki9rxqmv2igye8s6z0h</sha1>
    </revision>
    <revision>
      <id>1807</id>
      <parentid>1726</parentid>
      <timestamp>2024-11-01T18:26:51Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1807</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1547" sha1="tw6mru9io8i26q4s7l5co8bsgrfsooz" xml:space="preserve">I-A'''frika''' yizwekazi lesibili ngobukhulu begodu lesibili ngenani elikhulu labantu ephasini ngemva kwe-[[Asia]]. Ngamakhilomitha angaba ziingidi ezima-30.3 (amamayela ayi-11.7 wezigidi) kufaka hlangana iinhlengele eziseduze, ihlanganisa ama-20% wendawo yomhlaba kanye nama-6% wendawo yayo yoke.[9] Ngabantu abapheze babe ziingidigidi eziyi-1.4 ukusukela ngo-2021, ibalelwa emaphesentini ali-18 wabantu ephasini. Inani labantu be-Afrika mncani khulu kiwo woke amazwekazi. iminyaka ephakathi ngo-2012 beyiyi-19.7, lokha iminyaka ephakathi yephasi loke beyiyi-30.4.Ngokuya ngokuqagela kwango-2024, inani labantu be-Afrika lizakufikelela ebantwini abaziingidigidi ezi-3.8 ngo-2099.[Nanyana kunemithombo yemvelo eminengi, i-Afrika yizwekazi elinenotho encani ngehloko begodu liyindawo yesibili engananotho enengi, ngaphambi kwe-Oceania. Izazi zithi lokhu kungenxa yezinto ezihlukahlukeneko ezifaka hlangana ubujamo bendawo, ubujamo bezulu, ikohlakalo,ubukoloniyali, iPi yomKhuhlane, kanye nobukoloniyali obutjha. Nanyana kunobujamo obuphasi bomnotho, ukwanda kwezomnotho kwamuva nje kanye nenani labantu abanengi nabasesebatjha kwenza i-Afrika ibe yimakethe eqakathekileko yezomnotho ephasini loke. I-Afrika inenani elikhulu lemithombo yemvelo nemithombo yokudla, okufakahlangana amadayimane, itjhukela, itswayi, igolide, i-ayini, i-cobalt, i-uranium, ikhopha, i-bauxite, isiliva, i-petroleum, igesi yemvelo, iimbhontjisi ze-cocoa, kanye nezithelo ezitjhisako.&lt;ref&gt;https://www.bbc.com/gahuza/articles/cwy54qk14q8o&lt;/ref&gt;

[[Category:Iinarha zephasi]]</text>
      <sha1>tw6mru9io8i26q4s7l5co8bsgrfsooz</sha1>
    </revision>
    <revision>
      <id>1808</id>
      <parentid>1807</parentid>
      <timestamp>2024-11-01T18:27:17Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1808</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1562" sha1="nw567waiz81sgd5mjiw2fup5gic6ljg" xml:space="preserve">I-A'''frika''' yizwekazi lesibili ngobukhulu begodu lesibili ngenani elikhulu labantu ephasini ngemva kwe-[[Asia]]. Ngamakhilomitha angaba ziingidi ezima-30.3 (amamayela ayi-11.7 wezigidi) kufaka hlangana iinhlengele eziseduze, ihlanganisa ama-20% wendawo yomhlaba kanye nama-6% wendawo yayo yoke.[9] Ngabantu abapheze babe ziingidigidi eziyi-1.4 ukusukela ngo-2021, ibalelwa emaphesentini ali-18 wabantu ephasini. Inani labantu be-Afrika mncani khulu kiwo woke amazwekazi. iminyaka ephakathi ngo-2012 beyiyi-19.7, lokha iminyaka ephakathi yephasi loke beyiyi-30.4.Ngokuya ngokuqagela kwango-2024, inani labantu be-Afrika lizakufikelela ebantwini abaziingidigidi ezi-3.8 ngo-2099.[Nanyana kunemithombo yemvelo eminengi, i-Afrika yizwekazi elinenotho encani ngehloko begodu liyindawo yesibili engananotho enengi, ngaphambi kwe-Oceania. Izazi zithi lokhu kungenxa yezinto ezihlukahlukeneko ezifaka hlangana ubujamo bendawo, ubujamo bezulu, ikohlakalo,ubukoloniyali, iPi yomKhuhlane, kanye nobukoloniyali obutjha. Nanyana kunobujamo obuphasi bomnotho, ukwanda kwezomnotho kwamuva nje kanye nenani labantu abanengi nabasesebatjha kwenza i-Afrika ibe yimakethe eqakathekileko yezomnotho ephasini loke. I-Afrika inenani elikhulu lemithombo yemvelo nemithombo yokudla, okufakahlangana amadayimane, itjhukela, itswayi, igolide, i-ayini, i-cobalt, i-uranium, ikhopha, i-bauxite, isiliva, i-petroleum, igesi yemvelo, iimbhontjisi ze-cocoa, kanye nezithelo ezitjhisako.&lt;ref&gt;https://www.bbc.com/gahuza/articles/cwy54qk14q8o&lt;/ref&gt;

== Iinkomba ==
[[Category:Iinarha zephasi]]</text>
      <sha1>nw567waiz81sgd5mjiw2fup5gic6ljg</sha1>
    </revision>
    <revision>
      <id>1809</id>
      <parentid>1808</parentid>
      <timestamp>2024-11-01T18:27:39Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <minor />
      <comment>Bobbyshabangu moved page [[Afrika]] to [[I-Afrika]]</comment>
      <origin>1808</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1562" sha1="nw567waiz81sgd5mjiw2fup5gic6ljg" xml:space="preserve">I-A'''frika''' yizwekazi lesibili ngobukhulu begodu lesibili ngenani elikhulu labantu ephasini ngemva kwe-[[Asia]]. Ngamakhilomitha angaba ziingidi ezima-30.3 (amamayela ayi-11.7 wezigidi) kufaka hlangana iinhlengele eziseduze, ihlanganisa ama-20% wendawo yomhlaba kanye nama-6% wendawo yayo yoke.[9] Ngabantu abapheze babe ziingidigidi eziyi-1.4 ukusukela ngo-2021, ibalelwa emaphesentini ali-18 wabantu ephasini. Inani labantu be-Afrika mncani khulu kiwo woke amazwekazi. iminyaka ephakathi ngo-2012 beyiyi-19.7, lokha iminyaka ephakathi yephasi loke beyiyi-30.4.Ngokuya ngokuqagela kwango-2024, inani labantu be-Afrika lizakufikelela ebantwini abaziingidigidi ezi-3.8 ngo-2099.[Nanyana kunemithombo yemvelo eminengi, i-Afrika yizwekazi elinenotho encani ngehloko begodu liyindawo yesibili engananotho enengi, ngaphambi kwe-Oceania. Izazi zithi lokhu kungenxa yezinto ezihlukahlukeneko ezifaka hlangana ubujamo bendawo, ubujamo bezulu, ikohlakalo,ubukoloniyali, iPi yomKhuhlane, kanye nobukoloniyali obutjha. Nanyana kunobujamo obuphasi bomnotho, ukwanda kwezomnotho kwamuva nje kanye nenani labantu abanengi nabasesebatjha kwenza i-Afrika ibe yimakethe eqakathekileko yezomnotho ephasini loke. I-Afrika inenani elikhulu lemithombo yemvelo nemithombo yokudla, okufakahlangana amadayimane, itjhukela, itswayi, igolide, i-ayini, i-cobalt, i-uranium, ikhopha, i-bauxite, isiliva, i-petroleum, igesi yemvelo, iimbhontjisi ze-cocoa, kanye nezithelo ezitjhisako.&lt;ref&gt;https://www.bbc.com/gahuza/articles/cwy54qk14q8o&lt;/ref&gt;

== Iinkomba ==
[[Category:Iinarha zephasi]]</text>
      <sha1>nw567waiz81sgd5mjiw2fup5gic6ljg</sha1>
    </revision>
    <revision>
      <id>1811</id>
      <parentid>1809</parentid>
      <timestamp>2024-11-01T18:28:17Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1811</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1562" sha1="hqkd95eppfdh0qlzbznpfvln40onwo7" xml:space="preserve">I-A'''frika''' yizwekazi lesibili ngobukhulu begodu lesibili ngenani elikhulu labantu ephasini ngemva kwe-[[Asia]]. Ngamakhilomitha angaba ziingidi ezima-30.3 (amamayela ayi-11.7 wezigidi) kufaka hlangana iinhlengele eziseduze, ihlanganisa ama-20% wendawo yomhlaba kanye nama-6% wendawo yayo yoke.[9] Ngabantu abapheze babe ziingidigidi eziyi-1.4 ukusukela ngo-2021, ibalelwa emaphesentini ali-18 wabantu ephasini. Inani labantu be-Afrika mncani khulu kiwo woke amazwekazi. iminyaka ephakathi ngo-2012 beyiyi-19.7, lokha iminyaka ephakathi yephasi loke beyiyi-30.4.Ngokuya ngokuqagela kwango-2024, inani labantu be-Afrika lizakufikelela ebantwini abaziingidigidi ezi-3.8 ngo-2099. Nanyana kunemithombo yemvelo eminengi, i-Afrika yizwekazi elinenotho encani ngehloko begodu liyindawo yesibili engananotho enengi, ngaphambi kwe-Oceania. Izazi zithi lokhu kungenxa yezinto ezihlukahlukeneko ezifaka hlangana ubujamo bendawo, ubujamo bezulu, ikohlakalo,ubukoloniyali, iPi yomKhuhlane, kanye nobukoloniyali obutjha. Nanyana kunobujamo obuphasi bomnotho, ukwanda kwezomnotho kwamuva nje kanye nenani labantu abanengi nabasesebatjha kwenza i-Afrika ibe yimakethe eqakathekileko yezomnotho ephasini loke. I-Afrika inenani elikhulu lemithombo yemvelo nemithombo yokudla, okufakahlangana amadayimane, itjhukela, itswayi, igolide, i-ayini, i-cobalt, i-uranium, ikhopha, i-bauxite, isiliva, i-petroleum, igesi yemvelo, iimbhontjisi ze-cocoa, kanye nezithelo ezitjhisako.&lt;ref&gt;https://www.bbc.com/gahuza/articles/cwy54qk14q8o&lt;/ref&gt;

== Iinkomba ==
[[Category:Iinarha zephasi]]</text>
      <sha1>hqkd95eppfdh0qlzbznpfvln40onwo7</sha1>
    </revision>
    <revision>
      <id>1819</id>
      <parentid>1811</parentid>
      <timestamp>2024-11-01T18:31:53Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1819</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1559" sha1="gugukgtvs10ovglee3q9vgad38zoi7p" xml:space="preserve">I-A'''frika''' yizwekazi lesibili ngobukhulu begodu lesibili ngenani elikhulu labantu ephasini ngemva kwe-[[Asia]]. Ngamakhilomitha angaba ziingidi ezima-30.3 (amamayela ayi-11.7 wezigidi) kufaka hlangana iinhlengele eziseduze, ihlanganisa ama-20% wendawo yomhlaba kanye nama-6% wendawo yayo yoke. Ngabantu abapheze babe ziingidigidi eziyi-1.4 ukusukela ngo-2021, ibalelwa emaphesentini ali-18 wabantu ephasini. Inani labantu be-Afrika mncani khulu kiwo woke amazwekazi. iminyaka ephakathi ngo-2012 beyiyi-19.7, lokha iminyaka ephakathi yephasi loke beyiyi-30.4.Ngokuya ngokuqagela kwango-2024, inani labantu be-Afrika lizakufikelela ebantwini abaziingidigidi ezi-3.8 ngo-2099. Nanyana kunemithombo yemvelo eminengi, i-Afrika yizwekazi elinenotho encani ngehloko begodu liyindawo yesibili engananotho enengi, ngaphambi kwe-Oceania. Izazi zithi lokhu kungenxa yezinto ezihlukahlukeneko ezifaka hlangana ubujamo bendawo, ubujamo bezulu, ikohlakalo,ubukoloniyali, iPi yomKhuhlane, kanye nobukoloniyali obutjha. Nanyana kunobujamo obuphasi bomnotho, ukwanda kwezomnotho kwamuva nje kanye nenani labantu abanengi nabasesebatjha kwenza i-Afrika ibe yimakethe eqakathekileko yezomnotho ephasini loke. I-Afrika inenani elikhulu lemithombo yemvelo nemithombo yokudla, okufakahlangana amadayimane, itjhukela, itswayi, igolide, i-ayini, i-cobalt, i-uranium, ikhopha, i-bauxite, isiliva, i-petroleum, igesi yemvelo, iimbhontjisi ze-cocoa, kanye nezithelo ezitjhisako.&lt;ref&gt;https://www.bbc.com/gahuza/articles/cwy54qk14q8o&lt;/ref&gt;

== Iinkomba ==
[[Category:Iinarha zephasi]]</text>
      <sha1>gugukgtvs10ovglee3q9vgad38zoi7p</sha1>
    </revision>
    <revision>
      <id>2132</id>
      <parentid>1819</parentid>
      <timestamp>2024-11-25T18:27:19Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* Iinkomba */Reflist</comment>
      <origin>2132</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1572" sha1="e3ligciypribc3nc2lz1krd5oke8wq1" xml:space="preserve">I-A'''frika''' yizwekazi lesibili ngobukhulu begodu lesibili ngenani elikhulu labantu ephasini ngemva kwe-[[Asia]]. Ngamakhilomitha angaba ziingidi ezima-30.3 (amamayela ayi-11.7 wezigidi) kufaka hlangana iinhlengele eziseduze, ihlanganisa ama-20% wendawo yomhlaba kanye nama-6% wendawo yayo yoke. Ngabantu abapheze babe ziingidigidi eziyi-1.4 ukusukela ngo-2021, ibalelwa emaphesentini ali-18 wabantu ephasini. Inani labantu be-Afrika mncani khulu kiwo woke amazwekazi. iminyaka ephakathi ngo-2012 beyiyi-19.7, lokha iminyaka ephakathi yephasi loke beyiyi-30.4.Ngokuya ngokuqagela kwango-2024, inani labantu be-Afrika lizakufikelela ebantwini abaziingidigidi ezi-3.8 ngo-2099. Nanyana kunemithombo yemvelo eminengi, i-Afrika yizwekazi elinenotho encani ngehloko begodu liyindawo yesibili engananotho enengi, ngaphambi kwe-Oceania. Izazi zithi lokhu kungenxa yezinto ezihlukahlukeneko ezifaka hlangana ubujamo bendawo, ubujamo bezulu, ikohlakalo,ubukoloniyali, iPi yomKhuhlane, kanye nobukoloniyali obutjha. Nanyana kunobujamo obuphasi bomnotho, ukwanda kwezomnotho kwamuva nje kanye nenani labantu abanengi nabasesebatjha kwenza i-Afrika ibe yimakethe eqakathekileko yezomnotho ephasini loke. I-Afrika inenani elikhulu lemithombo yemvelo nemithombo yokudla, okufakahlangana amadayimane, itjhukela, itswayi, igolide, i-ayini, i-cobalt, i-uranium, ikhopha, i-bauxite, isiliva, i-petroleum, igesi yemvelo, iimbhontjisi ze-cocoa, kanye nezithelo ezitjhisako.&lt;ref&gt;https://www.bbc.com/gahuza/articles/cwy54qk14q8o&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}

[[Category:Iinarha zephasi]]</text>
      <sha1>e3ligciypribc3nc2lz1krd5oke8wq1</sha1>
    </revision>
    <revision>
      <id>2140</id>
      <parentid>2132</parentid>
      <timestamp>2024-11-25T18:29:26Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>Mkhakha</comment>
      <origin>2140</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1571" sha1="2rn485z9aavb0wfq8n9gg6ptwj6fbjb" xml:space="preserve">I-A'''frika''' yizwekazi lesibili ngobukhulu begodu lesibili ngenani elikhulu labantu ephasini ngemva kwe-[[Asia]]. Ngamakhilomitha angaba ziingidi ezima-30.3 (amamayela ayi-11.7 wezigidi) kufaka hlangana iinhlengele eziseduze, ihlanganisa ama-20% wendawo yomhlaba kanye nama-6% wendawo yayo yoke. Ngabantu abapheze babe ziingidigidi eziyi-1.4 ukusukela ngo-2021, ibalelwa emaphesentini ali-18 wabantu ephasini. Inani labantu be-Afrika mncani khulu kiwo woke amazwekazi. iminyaka ephakathi ngo-2012 beyiyi-19.7, lokha iminyaka ephakathi yephasi loke beyiyi-30.4.Ngokuya ngokuqagela kwango-2024, inani labantu be-Afrika lizakufikelela ebantwini abaziingidigidi ezi-3.8 ngo-2099. Nanyana kunemithombo yemvelo eminengi, i-Afrika yizwekazi elinenotho encani ngehloko begodu liyindawo yesibili engananotho enengi, ngaphambi kwe-Oceania. Izazi zithi lokhu kungenxa yezinto ezihlukahlukeneko ezifaka hlangana ubujamo bendawo, ubujamo bezulu, ikohlakalo,ubukoloniyali, iPi yomKhuhlane, kanye nobukoloniyali obutjha. Nanyana kunobujamo obuphasi bomnotho, ukwanda kwezomnotho kwamuva nje kanye nenani labantu abanengi nabasesebatjha kwenza i-Afrika ibe yimakethe eqakathekileko yezomnotho ephasini loke. I-Afrika inenani elikhulu lemithombo yemvelo nemithombo yokudla, okufakahlangana amadayimane, itjhukela, itswayi, igolide, i-ayini, i-cobalt, i-uranium, ikhopha, i-bauxite, isiliva, i-petroleum, igesi yemvelo, iimbhontjisi ze-cocoa, kanye nezithelo ezitjhisako.&lt;ref&gt;https://www.bbc.com/gahuza/articles/cwy54qk14q8o&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}

[[Mkhakha:Iinarha zephasi]]</text>
      <sha1>2rn485z9aavb0wfq8n9gg6ptwj6fbjb</sha1>
    </revision>
    <revision>
      <id>2921</id>
      <parentid>2140</parentid>
      <timestamp>2025-06-06T17:05:28Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>RAID SHADOW LEGENDS</comment>
      <origin>2921</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="113" sha1="90sqpyxqvsir6qn8nepith1c9kz3baw" xml:space="preserve">== THIS PAGE IS SPONSORED BY &lt;nowiki&gt;[[RAID SHADOW LEGENDS]]&lt;/nowiki&gt; ==
{{Reflist}}

[[Mkhakha:Iinarha zephasi]]</text>
      <sha1>90sqpyxqvsir6qn8nepith1c9kz3baw</sha1>
    </revision>
    <revision>
      <id>2923</id>
      <parentid>2921</parentid>
      <timestamp>2025-06-06T17:06:33Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>fixed it</comment>
      <origin>2923</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="127" sha1="5c692idpajledb4m249nu50scfqtob9" xml:space="preserve">== This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. ==
{{Reflist}}

[[Mkhakha:Iinarha zephasi]]</text>
      <sha1>5c692idpajledb4m249nu50scfqtob9</sha1>
    </revision>
    <revision>
      <id>3104</id>
      <parentid>2923</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edits by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Simakahle Moselekatse|Simakahle Moselekatse]]</comment>
      <origin>2140</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1571" sha1="2rn485z9aavb0wfq8n9gg6ptwj6fbjb" xml:space="preserve">I-A'''frika''' yizwekazi lesibili ngobukhulu begodu lesibili ngenani elikhulu labantu ephasini ngemva kwe-[[Asia]]. Ngamakhilomitha angaba ziingidi ezima-30.3 (amamayela ayi-11.7 wezigidi) kufaka hlangana iinhlengele eziseduze, ihlanganisa ama-20% wendawo yomhlaba kanye nama-6% wendawo yayo yoke. Ngabantu abapheze babe ziingidigidi eziyi-1.4 ukusukela ngo-2021, ibalelwa emaphesentini ali-18 wabantu ephasini. Inani labantu be-Afrika mncani khulu kiwo woke amazwekazi. iminyaka ephakathi ngo-2012 beyiyi-19.7, lokha iminyaka ephakathi yephasi loke beyiyi-30.4.Ngokuya ngokuqagela kwango-2024, inani labantu be-Afrika lizakufikelela ebantwini abaziingidigidi ezi-3.8 ngo-2099. Nanyana kunemithombo yemvelo eminengi, i-Afrika yizwekazi elinenotho encani ngehloko begodu liyindawo yesibili engananotho enengi, ngaphambi kwe-Oceania. Izazi zithi lokhu kungenxa yezinto ezihlukahlukeneko ezifaka hlangana ubujamo bendawo, ubujamo bezulu, ikohlakalo,ubukoloniyali, iPi yomKhuhlane, kanye nobukoloniyali obutjha. Nanyana kunobujamo obuphasi bomnotho, ukwanda kwezomnotho kwamuva nje kanye nenani labantu abanengi nabasesebatjha kwenza i-Afrika ibe yimakethe eqakathekileko yezomnotho ephasini loke. I-Afrika inenani elikhulu lemithombo yemvelo nemithombo yokudla, okufakahlangana amadayimane, itjhukela, itswayi, igolide, i-ayini, i-cobalt, i-uranium, ikhopha, i-bauxite, isiliva, i-petroleum, igesi yemvelo, iimbhontjisi ze-cocoa, kanye nezithelo ezitjhisako.&lt;ref&gt;https://www.bbc.com/gahuza/articles/cwy54qk14q8o&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}

[[Mkhakha:Iinarha zephasi]]</text>
      <sha1>2rn485z9aavb0wfq8n9gg6ptwj6fbjb</sha1>
    </revision>
    <revision>
      <id>5899</id>
      <parentid>3104</parentid>
      <timestamp>2025-10-04T23:52:03Z</timestamp>
      <contributor>
        <username>~2025-27677-90</username>
        <id>1043</id>
      </contributor>
      <origin>5899</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1614" sha1="d6teohalezl6ai6mkdg6fa1psgq3wsm" xml:space="preserve">I-A'''frika''' yizwekazi lesibili ngobukhulu begodu lesibili ngenani elikhulu labantu ephasini ngemva kwe-[[Asia]]. Ngamakhilomitha angaba ziingidi ezima-30.3 (amamayela ayi-11.7 wezigidi) kufaka hlangana iinhlengele eziseduze, ihlanganisa ama-20% wendawo yomhlaba kanye nama-6% wendawo yayo yoke. Ngabantu abapheze babe ziingidigidi eziyi-1.4 ukusukela ngo-2021, ibalelwa emaphesentini ali-18 wabantu ephasini. Inani labantu be-Afrika mncani khulu kiwo woke amazwekazi. iminyaka ephakathi ngo-2012 beyiyi-19.7, lokha iminyaka ephakathi yephasi loke beyiyi-30.4.Ngokuya ngokuqagela kwango-2024, inani labantu be-Afrika lizakufikelela ebantwini abaziingidigidi ezi-3.8 ngo-2099. Nanyana kunemithombo yemvelo eminengi, i-Afrika yizwekazi elinenotho encani ngehloko begodu liyindawo yesibili engananotho enengi, ngaphambi kwe-Oceania. Izazi zithi lokhu kungenxa yezinto ezihlukahlukeneko ezifaka hlangana ubujamo bendawo, ubujamo bezulu, ikohlakalo,ubukoloniyali, iPi yomKhuhlane, kanye nobukoloniyali obutjha. Nanyana kunobujamo obuphasi bomnotho, ukwanda kwezomnotho kwamuva nje kanye nenani labantu abanengi nabasesebatjha kwenza i-Afrika ibe yimakethe eqakathekileko yezomnotho ephasini loke. I-Afrika inenani elikhulu lemithombo yemvelo nemithombo yokudla, okufakahlangana amadayimane, itjhukela, itswayi, igolide, i-ayini, i-cobalt, i-uranium, ikhopha, i-bauxite, isiliva, i-petroleum, igesi yemvelo, iimbhontjisi ze-cocoa, kanye nezithelo ezitjhisako.&lt;ref&gt;https://www.bbc.com/gahuza/articles/cwy54qk14q8o&lt;/ref&gt;

== Wotkazy ==
* [[Kněz Kevin I Nyerere]]

== Iinkomba ==
{{Reflist}}

[[Mkhakha:Iinarha zephasi]]</text>
      <sha1>d6teohalezl6ai6mkdg6fa1psgq3wsm</sha1>
    </revision>
    <revision>
      <id>6461</id>
      <parentid>5899</parentid>
      <timestamp>2026-04-15T20:11:43Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6461</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1633" sha1="lwvs3saxtpim3lm2l0p3cpo4ojjrmse" xml:space="preserve">I-A'''frika''' yizwekazi lesibili ngobukhulu begodu lesibili ngenani elikhulu labantu ephasini ngemva kwe-[[Asia]]. Ngamakhilomitha angaba ziingidi ezima-30.3 (amamayela ayi-11.7 wezigidi) kufaka hlangana iinhlengele eziseduze, ihlanganisa ama-20% wendawo yomhlaba kanye nama-6% wendawo yayo yoke. Ngabantu abapheze babe ziingidigidi eziyi-1.4 ukusukela ngo-2021, ibalelwa emaphesentini ali-18 wabantu ephasini. Inani labantu be-Afrika mncani khulu kiwo woke amazwekazi. iminyaka ephakathi ngo-2012 beyiyi-19.7, lokha iminyaka ephakathi yephasi loke beyiyi-30.4.Ngokuya ngokuqagela kwango-2024, inani labantu be-Afrika lizakufikelela ebantwini abaziingidigidi ezi-3.8 ngo-2099. Nanyana kunemithombo yemvelo eminengi, i-Afrika yizwekazi elinenotho encani ngehloko begodu liyindawo yesibili engananotho enengi, ngaphambi kwe-Oceania. Izazi zithi lokhu kungenxa yezinto ezihlukahlukeneko ezifaka hlangana ubujamo bendawo, ubujamo bezulu, ikohlakalo,ubukoloniyali, iPi yomKhuhlane, kanye nobukoloniyali obutjha. Nanyana kunobujamo obuphasi bomnotho, ukwanda kwezomnotho kwamuva nje kanye nenani labantu abanengi nabasesebatjha kwenza i-Afrika ibe yimakethe eqakathekileko yezomnotho ephasini loke. I-Afrika inenani elikhulu lemithombo yemvelo nemithombo yokudla, okufakahlangana amadayimane, itjhukela, itswayi, igolide, i-ayini, i-cobalt, i-uranium, ikhopha, i-bauxite, isiliva, i-petroleum, igesi yemvelo, iimbhontjisi ze-cocoa, kanye nezithelo ezitjhisako.&lt;ref&gt;https://www.bbc.com/gahuza/articles/cwy54qk14q8o&lt;/ref&gt;

== Wotkazy ==
* [[Kněz Kevin I Nyerere]]

== Iinkomba ==
{{Reflist}}

[[Mkhakha:Iinarha zephasi]]
[[Mkhakha:Afrika]]</text>
      <sha1>lwvs3saxtpim3lm2l0p3cpo4ojjrmse</sha1>
    </revision>
  </page>
  <page>
    <title>Isindebele</title>
    <ns>0</ns>
    <id>329</id>
    <revision>
      <id>1727</id>
      <timestamp>2024-10-23T23:17:05Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>added references.</comment>
      <origin>1727</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="599" sha1="0c1txta69bgq6i68filga62mq5tqg2z" xml:space="preserve">'''isiNdebele''' esaziwa nangokuthi yi-Southern Ndebele lilimi le-Afrika elivela esiqhemeni sama-Mbo wamalimi we-Bantu, elikhulunywa babantu be-Ndebele be[[Isewula Afrika|Sewula Afrika]].&lt;ref&gt;https://www.krugerpark.co.za/africa_ndebele.html&lt;/ref&gt;

IsiNdebele seTlhagwini nofana isiNdebele esibuye saziwa nge-isiNdebele sikhulunywa e-[[Limpopo]] eendaweni ezifana ne-[[Polokwane]] (Bhulungwane), Ga-Rathoka (KaSondonga), Ga-Mashashane, Ga Maraba / Kalkspruit, Mokopane (Mghumbane), Zebediela (Sebetiela), eduze ukuya eNdebeleni yeSewula.&lt;ref&gt;https://www.sahistory.org.za/article/ndebele-history&lt;/ref&gt;</text>
      <sha1>0c1txta69bgq6i68filga62mq5tqg2z</sha1>
    </revision>
    <revision>
      <id>1728</id>
      <parentid>1727</parentid>
      <timestamp>2024-10-23T23:17:40Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1728</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="615" sha1="g8o0kh413yb01fay005wcw937he0jld" xml:space="preserve">'''isiNdebele''' esaziwa nangokuthi yi-Southern Ndebele lilimi le-Afrika elivela esiqhemeni sama-Mbo wamalimi we-Bantu, elikhulunywa babantu be-Ndebele be[[Isewula Afrika|Sewula Afrika]].&lt;ref&gt;https://www.krugerpark.co.za/africa_ndebele.html&lt;/ref&gt;

IsiNdebele seTlhagwini nofana isiNdebele esibuye saziwa nge-isiNdebele sikhulunywa e-[[Limpopo]] eendaweni ezifana ne-[[Polokwane]] (Bhulungwane), Ga-Rathoka (KaSondonga), Ga-Mashashane, Ga Maraba / Kalkspruit, Mokopane (Mghumbane), Zebediela (Sebetiela), eduze ukuya eNdebeleni yeSewula.&lt;ref&gt;https://www.sahistory.org.za/article/ndebele-history&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>g8o0kh413yb01fay005wcw937he0jld</sha1>
    </revision>
    <revision>
      <id>1729</id>
      <parentid>1728</parentid>
      <timestamp>2024-10-23T23:18:40Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1729</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="623" sha1="0k3zm57mavoezspx7uxz4vc795ue83h" xml:space="preserve">'''isiNdebele''' esaziwa nangokuthi yi-Southern Ndebele lilimi le-Afrika elivela esiqhemeni sama-Mbo wamalimi we-Bantu, elikhulunywa babantu be-Ndebele be[[Isewula Afrika|Sewula Afrika]].&lt;ref&gt;https://www.krugerpark.co.za/africa_ndebele.html&lt;/ref&gt;

IsiNdebele seTlhagwini nofana isiNdebele esibuye saziwa nge-isiNdebele sikhulunywa e-[[Limpopo]] eendaweni ezifana ne-[[Polokwane]] (Bhulungwane), Ga-Rathoka (KaSondonga), Ga-Mashashane, Ga Maraba / [[Kalkspruit]], [[Mokopane]] (Mghumbane), Zebediela (Sebetiela), eduze ukuya eNdebeleni yeSewula.&lt;ref&gt;https://www.sahistory.org.za/article/ndebele-history&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>0k3zm57mavoezspx7uxz4vc795ue83h</sha1>
    </revision>
    <revision>
      <id>1730</id>
      <parentid>1729</parentid>
      <timestamp>2024-10-23T23:23:25Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1730</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="695" sha1="c1c4f8lepot6azsqcu7g7t8oau1935e" xml:space="preserve">'''isiNdebele''' esaziwa nangokuthi yi-Southern Ndebele lilimi le-Afrika elivela esiqhemeni sama-Mbo wamalimi we-Bantu, elikhulunywa babantu be-Ndebele be[[Isewula Afrika|Sewula Afrika]].&lt;ref&gt;https://www.krugerpark.co.za/africa_ndebele.html&lt;/ref&gt;

IsiNdebele seTlhagwini nofana isiNdebele esibuye saziwa nge-isiNdebele sikhulunywa e-[[Limpopo]] eendaweni ezifana ne-[[Polokwane]] (Bhulungwane), Ga-Rathoka (KaSondonga), Ga-Mashashane, Ga Maraba / [[Kalkspruit]], [[Mokopane]] (Mghumbane), Zebediela (Sebetiela), eduze ukuya eNdebeleni yeSewula.&lt;ref&gt;https://www.sahistory.org.za/article/ndebele-history&lt;/ref&gt;
== Iinkomba ==
[[Category:ESewula Afrika]]
[[Category:Ubukghwari]]
[[Category:Amasiko]]</text>
      <sha1>c1c4f8lepot6azsqcu7g7t8oau1935e</sha1>
    </revision>
    <revision>
      <id>1787</id>
      <parentid>1730</parentid>
      <timestamp>2024-11-01T13:00:35Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <origin>1787</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="763" sha1="dr2p33q2w5uyf8qbgqcg2l54wpshedv" xml:space="preserve">'''IsiNdebele''' esaziwa ngesiNdebele seSewula (''Southern'' Ndebele) lilimi le-Afrika elivela esiqhemeni samaMbo wamalimi weBantu. Ilimeli likhulunywa maNdebele okubabantu abafumaneka e[[Isewula Afrika|Sewula Afrika]].&lt;ref&gt;https://www.krugerpark.co.za/africa_ndebele.html&lt;/ref&gt; Bafumaneka eemfundeni ezifaka hlangana iMpumalanga, Gauteng, Limpopo, ne-''North-West''. 

KunesiNdebele esikhulunywa e-[[Limpopo]] eendaweni ezifana ne-[[Polokwane]] (Bhulungwane), Ga-Rathoka (KaSondonga), Ga-Mashashane, Ga Maraba / [[Kalkspruit]], [[Mokopane]] (Mghumbane), Zebediela (Sebetiela), eduze ukuya eNdebeleni yeSewula.&lt;ref&gt;https://www.sahistory.org.za/article/ndebele-history&lt;/ref&gt;
== Iinkomba ==
[[Category:Sewula Afrika]]
[[Category:IsiNdebele]]
[[Category:AmaNdebele]]</text>
      <sha1>dr2p33q2w5uyf8qbgqcg2l54wpshedv</sha1>
    </revision>
    <revision>
      <id>2106</id>
      <parentid>1787</parentid>
      <timestamp>2024-11-25T09:50:54Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* Iinkomba */</comment>
      <origin>2106</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="776" sha1="ee1pqalxtn6bkrf0f2gxk109mfyqw2a" xml:space="preserve">'''IsiNdebele''' esaziwa ngesiNdebele seSewula (''Southern'' Ndebele) lilimi le-Afrika elivela esiqhemeni samaMbo wamalimi weBantu. Ilimeli likhulunywa maNdebele okubabantu abafumaneka e[[Isewula Afrika|Sewula Afrika]].&lt;ref&gt;https://www.krugerpark.co.za/africa_ndebele.html&lt;/ref&gt; Bafumaneka eemfundeni ezifaka hlangana iMpumalanga, Gauteng, Limpopo, ne-''North-West''. 

KunesiNdebele esikhulunywa e-[[Limpopo]] eendaweni ezifana ne-[[Polokwane]] (Bhulungwane), Ga-Rathoka (KaSondonga), Ga-Mashashane, Ga Maraba / [[Kalkspruit]], [[Mokopane]] (Mghumbane), Zebediela (Sebetiela), eduze ukuya eNdebeleni yeSewula.&lt;ref&gt;https://www.sahistory.org.za/article/ndebele-history&lt;/ref&gt;
== Iinkomba ==
{{Reflist}}

[[Category:Sewula Afrika]]
[[Category:IsiNdebele]]
[[Category:AmaNdebele]]</text>
      <sha1>ee1pqalxtn6bkrf0f2gxk109mfyqw2a</sha1>
    </revision>
    <revision>
      <id>2107</id>
      <parentid>2106</parentid>
      <timestamp>2024-11-25T09:51:26Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <comment>Mkhakha</comment>
      <origin>2107</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="773" sha1="4g0opngf2ykw15ovc4lp1e3oy9z60qv" xml:space="preserve">'''IsiNdebele''' esaziwa ngesiNdebele seSewula (''Southern'' Ndebele) lilimi le-Afrika elivela esiqhemeni samaMbo wamalimi weBantu. Ilimeli likhulunywa maNdebele okubabantu abafumaneka e[[Isewula Afrika|Sewula Afrika]].&lt;ref&gt;https://www.krugerpark.co.za/africa_ndebele.html&lt;/ref&gt; Bafumaneka eemfundeni ezifaka hlangana iMpumalanga, Gauteng, Limpopo, ne-''North-West''. 

KunesiNdebele esikhulunywa e-[[Limpopo]] eendaweni ezifana ne-[[Polokwane]] (Bhulungwane), Ga-Rathoka (KaSondonga), Ga-Mashashane, Ga Maraba / [[Kalkspruit]], [[Mokopane]] (Mghumbane), Zebediela (Sebetiela), eduze ukuya eNdebeleni yeSewula.&lt;ref&gt;https://www.sahistory.org.za/article/ndebele-history&lt;/ref&gt;
== Iinkomba ==
{{Reflist}}

[[Mkhakha:Sewula Afrika]]
[[Mkhakha:IsiNdebele]]
[[Mkhakha:AmaNdebele]]</text>
      <sha1>4g0opngf2ykw15ovc4lp1e3oy9z60qv</sha1>
    </revision>
    <revision>
      <id>2903</id>
      <parentid>2107</parentid>
      <timestamp>2025-06-06T16:42:27Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>heheheha</comment>
      <origin>2903</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="110" sha1="698cha5kubvh0y8v58o0bzyc5duawl4" xml:space="preserve">[[A Minecraft Movie|I... Am Steve]] 


[[Mkhakha:Sewula Afrika]]
[[Mkhakha:IsiNdebele]]
[[Mkhakha:AmaNdebele]]</text>
      <sha1>698cha5kubvh0y8v58o0bzyc5duawl4</sha1>
    </revision>
    <revision>
      <id>3127</id>
      <parentid>2903</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Simakahle Moselekatse|Simakahle Moselekatse]]</comment>
      <origin>2107</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="773" sha1="4g0opngf2ykw15ovc4lp1e3oy9z60qv" xml:space="preserve">'''IsiNdebele''' esaziwa ngesiNdebele seSewula (''Southern'' Ndebele) lilimi le-Afrika elivela esiqhemeni samaMbo wamalimi weBantu. Ilimeli likhulunywa maNdebele okubabantu abafumaneka e[[Isewula Afrika|Sewula Afrika]].&lt;ref&gt;https://www.krugerpark.co.za/africa_ndebele.html&lt;/ref&gt; Bafumaneka eemfundeni ezifaka hlangana iMpumalanga, Gauteng, Limpopo, ne-''North-West''. 

KunesiNdebele esikhulunywa e-[[Limpopo]] eendaweni ezifana ne-[[Polokwane]] (Bhulungwane), Ga-Rathoka (KaSondonga), Ga-Mashashane, Ga Maraba / [[Kalkspruit]], [[Mokopane]] (Mghumbane), Zebediela (Sebetiela), eduze ukuya eNdebeleni yeSewula.&lt;ref&gt;https://www.sahistory.org.za/article/ndebele-history&lt;/ref&gt;
== Iinkomba ==
{{Reflist}}

[[Mkhakha:Sewula Afrika]]
[[Mkhakha:IsiNdebele]]
[[Mkhakha:AmaNdebele]]</text>
      <sha1>4g0opngf2ykw15ovc4lp1e3oy9z60qv</sha1>
    </revision>
    <revision>
      <id>6091</id>
      <parentid>3127</parentid>
      <timestamp>2025-12-17T17:34:30Z</timestamp>
      <contributor>
        <username>JayJaytutu</username>
        <id>1227</id>
      </contributor>
      <origin>6091</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="921" sha1="qas3h9jvek0k9brry91kcuay3u4wamd" xml:space="preserve">'''IsiNdebele''' esaziwa ngesiNdebele seSewula (''Southern'' Ndebele) lilimi le-Afrika elivela esiqhemeni samaMbo wamalimi weBantu. Ilimeli likhulunywa maNdebele okubabantu abafumaneka e[[Isewula Afrika|Sewula Afrika]].&lt;ref&gt;https://www.krugerpark.co.za/africa_ndebele.html&lt;/ref&gt; Bafumaneka eemfundeni ezifaka hlangana iMpumalanga, Gauteng, Limpopo, ne-''North-West''. GNARLY GNARLY LIKE A BAG OF TAKIS IM THE SHIRT IM THE SHIRT GANRLY GNARLY GNARLY LIKE A BAGE OF TAKIS IM THE SHIRT IM THE SHIRT *Phonk intensifies* 

KunesiNdebele esikhulunywa e-[[Limpopo]] eendaweni ezifana ne-[[Polokwane]] (Bhulungwane), Ga-Rathoka (KaSondonga), Ga-Mashashane, Ga Maraba / [[Kalkspruit]], [[Mokopane]] (Mghumbane), Zebediela (Sebetiela), eduze ukuya eNdebeleni yeSewula.&lt;ref&gt;https://www.sahistory.org.za/article/ndebele-history&lt;/ref&gt;
== Iinkomba ==
{{Reflist}}

[[Mkhakha:Sewula Afrika]]
[[Mkhakha:IsiNdebele]]
[[Mkhakha:AmaNdebele]]</text>
      <sha1>qas3h9jvek0k9brry91kcuay3u4wamd</sha1>
    </revision>
    <revision>
      <id>6108</id>
      <parentid>6091</parentid>
      <timestamp>2026-01-02T05:40:58Z</timestamp>
      <contributor>
        <username>Versions111</username>
        <id>1260</id>
      </contributor>
      <origin>6108</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="773" sha1="4g0opngf2ykw15ovc4lp1e3oy9z60qv" xml:space="preserve">'''IsiNdebele''' esaziwa ngesiNdebele seSewula (''Southern'' Ndebele) lilimi le-Afrika elivela esiqhemeni samaMbo wamalimi weBantu. Ilimeli likhulunywa maNdebele okubabantu abafumaneka e[[Isewula Afrika|Sewula Afrika]].&lt;ref&gt;https://www.krugerpark.co.za/africa_ndebele.html&lt;/ref&gt; Bafumaneka eemfundeni ezifaka hlangana iMpumalanga, Gauteng, Limpopo, ne-''North-West''. 

KunesiNdebele esikhulunywa e-[[Limpopo]] eendaweni ezifana ne-[[Polokwane]] (Bhulungwane), Ga-Rathoka (KaSondonga), Ga-Mashashane, Ga Maraba / [[Kalkspruit]], [[Mokopane]] (Mghumbane), Zebediela (Sebetiela), eduze ukuya eNdebeleni yeSewula.&lt;ref&gt;https://www.sahistory.org.za/article/ndebele-history&lt;/ref&gt;
== Iinkomba ==
{{Reflist}}

[[Mkhakha:Sewula Afrika]]
[[Mkhakha:IsiNdebele]]
[[Mkhakha:AmaNdebele]]</text>
      <sha1>4g0opngf2ykw15ovc4lp1e3oy9z60qv</sha1>
    </revision>
    <revision>
      <id>6537</id>
      <parentid>6108</parentid>
      <timestamp>2026-05-18T12:19:50Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6537</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="781" sha1="1ij4tfcplabdtm0pbas9mvx3i92cgpn" xml:space="preserve">'''IsiNdebele seSewula''' (''Southern'' Ndebele), esaziwa nge'''siNdebele''', lilimi le-Afrika elivela esiqhemeni samaMbo wamalimi weBantu. Ilimeli likhulunywa maNdebele okubabantu abafumaneka e[[Isewula Afrika|Sewula Afrika]].&lt;ref&gt;https://www.krugerpark.co.za/africa_ndebele.html&lt;/ref&gt; Bafumaneka eemfundeni ezifaka hlangana iMpumalanga, Gauteng, Limpopo, ne-''North-West''. 

KunesiNdebele esikhulunywa e-[[Limpopo]] eendaweni ezifana ne-[[Polokwane]] (Bhulungwane), Ga-Rathoka (KaSondonga), Ga-Mashashane, Ga Maraba / [[Kalkspruit]], [[Mokopane]] (Mghumbane), Zebediela (Sebetiela), eduze ukuya eNdebeleni yeSewula.&lt;ref&gt;https://www.sahistory.org.za/article/ndebele-history&lt;/ref&gt;
== Iinkomba ==
{{Reflist}}

[[Mkhakha:Sewula Afrika]]
[[Mkhakha:IsiNdebele]]
[[Mkhakha:AmaNdebele]]</text>
      <sha1>1ij4tfcplabdtm0pbas9mvx3i92cgpn</sha1>
    </revision>
    <revision>
      <id>6538</id>
      <parentid>6537</parentid>
      <timestamp>2026-05-18T12:20:07Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6538</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="781" sha1="oz994vqgkvvgfvf56drdmtb5ixabplh" xml:space="preserve">'''IsiNdebele seSewula''' (''Southern'' Ndebele), esaziwa '''ngesiNdebele''', lilimi le-Afrika elivela esiqhemeni samaMbo wamalimi weBantu. Ilimeli likhulunywa maNdebele okubabantu abafumaneka e[[Isewula Afrika|Sewula Afrika]].&lt;ref&gt;https://www.krugerpark.co.za/africa_ndebele.html&lt;/ref&gt; Bafumaneka eemfundeni ezifaka hlangana iMpumalanga, Gauteng, Limpopo, ne-''North-West''. 

KunesiNdebele esikhulunywa e-[[Limpopo]] eendaweni ezifana ne-[[Polokwane]] (Bhulungwane), Ga-Rathoka (KaSondonga), Ga-Mashashane, Ga Maraba / [[Kalkspruit]], [[Mokopane]] (Mghumbane), Zebediela (Sebetiela), eduze ukuya eNdebeleni yeSewula.&lt;ref&gt;https://www.sahistory.org.za/article/ndebele-history&lt;/ref&gt;
== Iinkomba ==
{{Reflist}}

[[Mkhakha:Sewula Afrika]]
[[Mkhakha:IsiNdebele]]
[[Mkhakha:AmaNdebele]]</text>
      <sha1>oz994vqgkvvgfvf56drdmtb5ixabplh</sha1>
    </revision>
    <revision>
      <id>6686</id>
      <parentid>6538</parentid>
      <timestamp>2026-06-12T07:10:07Z</timestamp>
      <contributor>
        <username>MissHadassah</username>
        <id>1561</id>
      </contributor>
      <minor />
      <comment>I  cited the location of where the people of kwaNdebele live</comment>
      <origin>6686</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="796" sha1="eodx6tu9rv6vtzme8fk0rsdu3tkwcrw" xml:space="preserve">'''IsiNdebele seSewula''' (''Southern'' Ndebele), esaziwa '''ngesiNdebele''', lilimi le-Afrika elivela esiqhemeni samaMbo wamalimi weBantu. Ilimeli likhulunywa maNdebele okubabantu abafumaneka e[[Isewula Afrika|Sewula Afrika]].&lt;ref&gt;https://www.krugerpark.co.za/africa_ndebele.html&lt;/ref&gt; Bafumaneka eemfundeni ezifaka hlangana [[KwaNdebele|iMpumalanga]], Gauteng, Limpopo, ne-''North-West''. 

KunesiNdebele esikhulunywa e-[[Limpopo]] eendaweni ezifana ne-[[Polokwane]] (Bhulungwane), Ga-Rathoka (KaSondonga), Ga-Mashashane, Ga Maraba / [[Kalkspruit]], [[Mokopane]] (Mghumbane), Zebediela (Sebetiela), eduze ukuya eNdebeleni yeSewula.&lt;ref&gt;https://www.sahistory.org.za/article/ndebele-history&lt;/ref&gt;
== Iinkomba ==
{{Reflist}}

[[Mkhakha:Sewula Afrika]]
[[Mkhakha:IsiNdebele]]
[[Mkhakha:AmaNdebele]]</text>
      <sha1>eodx6tu9rv6vtzme8fk0rsdu3tkwcrw</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Ubukghwari</title>
    <ns>14</ns>
    <id>330</id>
    <revision>
      <id>1731</id>
      <timestamp>2024-10-23T23:24:05Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created blank page</comment>
      <origin>1731</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Amasiko</title>
    <ns>14</ns>
    <id>331</id>
    <revision>
      <id>1732</id>
      <timestamp>2024-10-23T23:24:31Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created blank page</comment>
      <origin>1732</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
  </page>
  <page>
    <title>Limpopo</title>
    <ns>0</ns>
    <id>332</id>
    <revision>
      <id>1734</id>
      <timestamp>2024-10-23T23:35:29Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created page with &quot;'''I-Limpopo''' (/lɪmˈpoʊpoʊ/) yiphrovinsi esetlhagwini khulu yeSewula Afrika. Iqanjwe ngomlambo i-Limpopo, owenza umngcele wephrovinsi engeTjingalanga nesetlhagwini. Ibizo elithi Limpopo lisuselwa ku-Rivombo (i-Livombo/Lebombo), isiqhema sabahlali be-Tsonga ebesidoswa phambili ngu-Hosi Rivombo owahlala endaweni eneentaba begodu wabiza indawo le ngemva umdosiphambili wabo. Iintaba ze-Lebombo nazo ziqanjwe ngazo. Umlambo lo bewubizwa ngokuthi yi-Vhembe miphakathi yama...&quot;</comment>
      <origin>1734</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1708" sha1="h8nmpfrcsvrqqq7b7ekri0o4nfhjnv9" xml:space="preserve">'''I-Limpopo''' (/lɪmˈpoʊpoʊ/) yiphrovinsi esetlhagwini khulu yeSewula Afrika. Iqanjwe ngomlambo i-Limpopo, owenza umngcele wephrovinsi engeTjingalanga nesetlhagwini. Ibizo elithi Limpopo lisuselwa ku-Rivombo (i-Livombo/Lebombo), isiqhema sabahlali be-Tsonga ebesidoswa phambili ngu-Hosi Rivombo owahlala endaweni eneentaba begodu wabiza indawo le ngemva umdosiphambili wabo. Iintaba ze-Lebombo nazo ziqanjwe ngazo. Umlambo lo bewubizwa ngokuthi yi-Vhembe miphakathi yama-Venda wendawo. [5] Ikomkhulu nedorobha elikhulu khulu esifundazweni yi-Polokwane, kuthi isishayamthetho sesifundazwe sise-Lebowakgomo.

Iphrovinsi yakhiwe ziinarha ezintathu zangaphambilini ze-Lebowa, Gazankulu kanye ne-Venda begodu yingcenye yesifunda sangaphambilini se-Transvaal. Iphrovinsi ye-Limpopo yasungulwa njengenye yeemfunda ezilithoba ngemva kokhetho luka-1994 lweSewula Afrika. Ibizo lephrovinsi bekuyi-&quot;Northern Transvaal&quot;, ngokukhamba kwesikhathi yatjhugululwa yaba &quot;Northern Province&quot; mhlazi-28 kuMgwengweni wee-1995, nezinye iimfunda ezimbili. Ibizo latjhugululwa godu ngomnyaka ka-2002 laba yi-Limpopo Province. I-Limpopo yakhiwe ziintjhaba ezintathu: i-Pedi, i-Tsonga kanye ne-Venda.

Abadosiphambili bendabuko namakhosi basakha umgogodla oqinileko wepolotiki yesifundazwe. Yasungulwa ngokuya komThetho we-Limpopo House of Traditional Leaders Act, Act 5 of 2005, umsebenzi omkhulu we-Limpopo House of Traditional Leaders kukweluleka urhulumende nesishayamthetho ngeendaba ezihlobene namasiko, amasiko, namasiko, kufaka hlangana amagadango wokuthuthukisa athinta imiphakathi yemakhaya. Mhlana ali-18 kuRhoboyi wee-2017, u-Kgosi Malesela Dikgale wakhethwa godu njengoSihlalo we-Limpopo House of Traditional Leaders.</text>
      <sha1>h8nmpfrcsvrqqq7b7ekri0o4nfhjnv9</sha1>
    </revision>
    <revision>
      <id>1735</id>
      <parentid>1734</parentid>
      <timestamp>2024-10-23T23:37:29Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1735</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1747" sha1="ql3zuf5mqpmoqvo1581lkyqtu72yjv1" xml:space="preserve">'''I-Limpopo''' (/lɪmˈpoʊpoʊ/) yiphrovinsi esetlhagwini khulu y[[Isewula Afrika|eSewula Afrika]]. Iqanjwe [[ngomlambo i-Limpopo]], owenza umngcele wephrovinsi engeTjingalanga nesetlhagwini. Ibizo elithi Limpopo lisuselwa ku-Rivombo (i-Livombo/Lebombo), isiqhema sabahlali be-[[Tsonga]] ebesidoswa phambili ngu-Hosi Rivombo owahlala endaweni eneentaba begodu wabiza indawo le ngemva umdosiphambili wabo. Iintaba ze-Lebombo nazo ziqanjwe ngazo. Umlambo lo bewubizwa ngokuthi yi-Vhembe miphakathi yama-Venda wendawo. [5] Ikomkhulu nedorobha elikhulu khulu esifundazweni yi-[[Polokwane]], kuthi isishayamthetho sesifundazwe sise-Lebowakgomo.

Iphrovinsi yakhiwe ziinarha ezintathu zangaphambilini ze-[[Lebowa]], [[Gazankulu]] kanye ne-Venda begodu yingcenye yesifunda sangaphambilini se-Transvaal. Iphrovinsi ye-Limpopo yasungulwa njengenye yeemfunda ezilithoba ngemva kokhetho luka-1994 lweSewula Afrika. Ibizo lephrovinsi bekuyi-&quot;Northern Transvaal&quot;, ngokukhamba kwesikhathi yatjhugululwa yaba &quot;Northern Province&quot; mhlazi-28 kuMgwengweni wee-1995, nezinye iimfunda ezimbili. Ibizo latjhugululwa godu ngomnyaka ka-2002 laba yi-Limpopo Province. I-Limpopo yakhiwe ziintjhaba ezintathu: i-Pedi, i-Tsonga kanye ne-Venda.

Abadosiphambili bendabuko namakhosi basakha umgogodla oqinileko wepolotiki yesifundazwe. Yasungulwa ngokuya komThetho we-Limpopo House of Traditional Leaders Act, Act 5 of 2005, umsebenzi omkhulu we-Limpopo House of Traditional Leaders kukweluleka urhulumende nesishayamthetho ngeendaba ezihlobene namasiko, amasiko, namasiko, kufaka hlangana amagadango wokuthuthukisa athinta imiphakathi yemakhaya. Mhlana ali-18 kuRhoboyi wee-2017, u-Kgosi Malesela Dikgale wakhethwa godu njengoSihlalo we-Limpopo House of Traditional Leaders.</text>
      <sha1>ql3zuf5mqpmoqvo1581lkyqtu72yjv1</sha1>
    </revision>
    <revision>
      <id>1736</id>
      <parentid>1735</parentid>
      <timestamp>2024-10-23T23:41:48Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1736</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2204" sha1="nuy1g58j2z5fsp6nzf9n8yw4vk0qvfd" xml:space="preserve">'''I-Limpopo''' (/lɪmˈpoʊpoʊ/) yiphrovinsi esetlhagwini khulu y[[Isewula Afrika|eSewula Afrika]]. Iqanjwe [[ngomlambo i-Limpopo]], owenza umngcele wephrovinsi engeTjingalanga nesetlhagwini. Ibizo elithi Limpopo lisuselwa ku-Rivombo (i-Livombo/Lebombo), isiqhema sabahlali be-[[Tsonga]] ebesidoswa phambili ngu-Hosi Rivombo owahlala endaweni eneentaba begodu wabiza indawo le ngemva umdosiphambili wabo. Iintaba ze-Lebombo nazo ziqanjwe ngazo. Umlambo lo bewubizwa ngokuthi yi-Vhembe miphakathi yama-Venda wendawo. [5] Ikomkhulu nedorobha elikhulu khulu esifundazweni yi-[[Polokwane]], kuthi isishayamthetho sesifundazwe sise-Lebowakgomo.&lt;ref&gt;https://municipalities.co.za/provinces/view/5/limpopo&lt;/ref&gt;&lt;ref&gt;[https://www.sahistory.org.za/place/limpopo-province#:~:text=It%20was%20first%20called%20the,%2C%20Botswana%2C%20Zimbabwe%20and%20Mozambique. https://www.sahistory.org.za/place/limpopo-province#:~:text=It%20was%20first%20called%20the,%2C%20Botswana%2C%20Zimbabwe%20and%20Mozambique.]&lt;/ref&gt;

Iphrovinsi yakhiwe ziinarha ezintathu zangaphambilini ze-[[Lebowa]], [[Gazankulu]] kanye ne-Venda begodu yingcenye yesifunda sangaphambilini se-Transvaal. Iphrovinsi ye-Limpopo yasungulwa njengenye yeemfunda ezilithoba ngemva kokhetho luka-1994 lweSewula Afrika. Ibizo lephrovinsi bekuyi-&quot;Northern Transvaal&quot;, ngokukhamba kwesikhathi yatjhugululwa yaba &quot;Northern Province&quot; mhlazi-28 kuMgwengweni wee-1995, nezinye iimfunda ezimbili. Ibizo latjhugululwa godu ngomnyaka ka-2002 laba yi-Limpopo Province. I-Limpopo yakhiwe ziintjhaba ezintathu: i-Pedi, i-Tsonga kanye ne-[[Venda]].&lt;ref&gt;https://web.archive.org/web/20170201235654/http://www.dolimpopo.com/limpopo-province&lt;/ref&gt;

Abadosiphambili bendabuko namakhosi basakha umgogodla oqinileko wepolotiki yesifundazwe. Yasungulwa ngokuya komThetho we-Limpopo House of Traditional Leaders Act, Act 5 of 2005, umsebenzi omkhulu we-Limpopo House of Traditional Leaders kukweluleka urhulumende nesishayamthetho ngeendaba ezihlobene namasiko, amasiko, namasiko, kufaka hlangana amagadango wokuthuthukisa athinta imiphakathi yemakhaya. Mhlana ali-18 kuRhoboyi wee-2017, u-Kgosi Malesela Dikgale wakhethwa godu njengoSihlalo we-Limpopo House of Traditional Leaders.</text>
      <sha1>nuy1g58j2z5fsp6nzf9n8yw4vk0qvfd</sha1>
    </revision>
    <revision>
      <id>1737</id>
      <parentid>1736</parentid>
      <timestamp>2024-10-23T23:43:30Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1737</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2263" sha1="22gikik2zp318yuuffu8nvno8mlazan" xml:space="preserve">'''I-Limpopo''' (/lɪmˈpoʊpoʊ/) yiphrovinsi esetlhagwini khulu y[[Isewula Afrika|eSewula Afrika]]. Iqanjwe [[ngomlambo i-Limpopo]], owenza umngcele wephrovinsi engeTjingalanga nesetlhagwini. Ibizo elithi Limpopo lisuselwa ku-Rivombo (i-Livombo/Lebombo), isiqhema sabahlali be-[[Tsonga]] ebesidoswa phambili ngu-Hosi Rivombo owahlala endaweni eneentaba begodu wabiza indawo le ngemva umdosiphambili wabo. Iintaba ze-Lebombo nazo ziqanjwe ngazo. Umlambo lo bewubizwa ngokuthi yi-Vhembe miphakathi yama-Venda wendawo. [5] Ikomkhulu nedorobha elikhulu khulu esifundazweni yi-[[Polokwane]], kuthi isishayamthetho sesifundazwe sise-Lebowakgomo.&lt;ref&gt;https://municipalities.co.za/provinces/view/5/limpopo&lt;/ref&gt;&lt;ref&gt;[https://www.sahistory.org.za/place/limpopo-province#:~:text=It%20was%20first%20called%20the,%2C%20Botswana%2C%20Zimbabwe%20and%20Mozambique. https://www.sahistory.org.za/place/limpopo-province#:~:text=It%20was%20first%20called%20the,%2C%20Botswana%2C%20Zimbabwe%20and%20Mozambique.]&lt;/ref&gt;

Iphrovinsi yakhiwe ziinarha ezintathu zangaphambilini ze-[[Lebowa]], [[Gazankulu]] kanye ne-Venda begodu yingcenye yesifunda sangaphambilini se-Transvaal. Iphrovinsi ye-Limpopo yasungulwa njengenye yeemfunda ezilithoba ngemva kokhetho luka-1994 lweSewula Afrika. Ibizo lephrovinsi bekuyi-&quot;Northern Transvaal&quot;, ngokukhamba kwesikhathi yatjhugululwa yaba &quot;Northern Province&quot; mhlazi-28 kuMgwengweni wee-1995, nezinye iimfunda ezimbili. Ibizo latjhugululwa godu ngomnyaka ka-2002 laba yi-Limpopo Province. I-Limpopo yakhiwe ziintjhaba ezintathu: i-Pedi, i-Tsonga kanye ne-[[Venda]].&lt;ref&gt;https://web.archive.org/web/20170201235654/http://www.dolimpopo.com/limpopo-province&lt;/ref&gt;

Abadosiphambili bendabuko namakhosi basakha umgogodla oqinileko wepolotiki yesifundazwe. Yasungulwa ngokuya komThetho we-Limpopo House of Traditional Leaders Act, Act 5 of 2005, umsebenzi omkhulu we-Limpopo House of Traditional Leaders kukweluleka urhulumende nesishayamthetho ngeendaba ezihlobene namasiko, amasiko, namasiko, kufaka hlangana amagadango wokuthuthukisa athinta imiphakathi yemakhaya. Mhlana ali-18 kuRhoboyi wee-2017, u-Kgosi Malesela Dikgale wakhethwa godu njengoSihlalo we-Limpopo House of Traditional Leaders.

== Iinkomba ==
&lt;references /&gt;
[[Category:ESewula Afrika]]</text>
      <sha1>22gikik2zp318yuuffu8nvno8mlazan</sha1>
    </revision>
    <revision>
      <id>1738</id>
      <parentid>1737</parentid>
      <timestamp>2024-10-23T23:45:52Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1738</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2284" sha1="cwsl54fzmbvi6rjaw8tswa62dl46szw" xml:space="preserve">'''I-Limpopo''' (/lɪmˈpoʊpoʊ/) yiphrovinsi esetlhagwini khulu y[[Isewula Afrika|eSewula Afrika]]. Iqanjwe [[ngomlambo i-Limpopo]], owenza umngcele wephrovinsi engeTjingalanga nesetlhagwini. Ibizo elithi Limpopo lisuselwa ku-Rivombo (i-Livombo/Lebombo), isiqhema sabahlali be-[[Tsonga]] ebesidoswa phambili ngu-Hosi Rivombo owahlala endaweni eneentaba begodu wabiza indawo le ngemva umdosiphambili wabo. Iintaba ze-Lebombo nazo ziqanjwe ngazo. Umlambo lo bewubizwa ngokuthi yi-Vhembe miphakathi yama-Venda wendawo. [5] Ikomkhulu nedorobha elikhulu khulu esifundazweni yi-[[Polokwane]], kuthi isishayamthetho sesifundazwe sise-Lebowakgomo.&lt;ref&gt;https://municipalities.co.za/provinces/view/5/limpopo&lt;/ref&gt;&lt;ref&gt;[https://www.sahistory.org.za/place/limpopo-province#:~:text=It%20was%20first%20called%20the,%2C%20Botswana%2C%20Zimbabwe%20and%20Mozambique. https://www.sahistory.org.za/place/limpopo-province#:~:text=It%20was%20first%20called%20the,%2C%20Botswana%2C%20Zimbabwe%20and%20Mozambique.]&lt;/ref&gt;

Iphrovinsi yakhiwe ziinarha ezintathu zangaphambilini ze-[[Lebowa]], [[Gazankulu]] kanye ne-Venda begodu yingcenye yesifunda sangaphambilini se-Transvaal. Iphrovinsi ye-Limpopo yasungulwa njengenye yeemfunda ezilithoba ngemva kokhetho luka-1994 lweSewula Afrika. Ibizo lephrovinsi bekuyi-&quot;Northern Transvaal&quot;, ngokukhamba kwesikhathi yatjhugululwa yaba &quot;Northern Province&quot; mhlazi-28 kuMgwengweni wee-1995, nezinye iimfunda ezimbili. Ibizo latjhugululwa godu ngomnyaka ka-2002 laba yi-Limpopo Province. I-Limpopo yakhiwe ziintjhaba ezintathu: i-Pedi, i-Tsonga kanye ne-[[Venda]].&lt;ref&gt;https://web.archive.org/web/20170201235654/http://www.dolimpopo.com/limpopo-province&lt;/ref&gt;

Abadosiphambili bendabuko namakhosi basakha umgogodla oqinileko wepolotiki yesifundazwe. Yasungulwa ngokuya komThetho we-Limpopo House of Traditional Leaders Act, Act 5 of 2005, umsebenzi omkhulu we-Limpopo House of Traditional Leaders kukweluleka urhulumende nesishayamthetho ngeendaba ezihlobene namasiko, amasiko, namasiko, kufaka hlangana amagadango wokuthuthukisa athinta imiphakathi yemakhaya. Mhlana ali-18 kuRhoboyi wee-2017, u-Kgosi Malesela Dikgale wakhethwa godu njengoSihlalo we-Limpopo House of Traditional Leaders.

== Iinkomba ==
&lt;references /&gt;
[[Category:ESewula Afrika]]
[[Mkhakha:Iimfunda]]</text>
      <sha1>cwsl54fzmbvi6rjaw8tswa62dl46szw</sha1>
    </revision>
    <revision>
      <id>1740</id>
      <parentid>1738</parentid>
      <timestamp>2024-10-23T23:47:31Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1740</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2283" sha1="l2ayxjnaijzu2ujigk6hbxe8jfesdc0" xml:space="preserve">'''I-Limpopo''' (/lɪmˈpoʊpoʊ/) yisimfunda esetlhagwini khulu y[[Isewula Afrika|eSewula Afrika]]. Iqanjwe [[ngomlambo i-Limpopo]], owenza umngcele wephrovinsi engeTjingalanga nesetlhagwini. Ibizo elithi Limpopo lisuselwa ku-Rivombo (i-Livombo/Lebombo), isiqhema sabahlali be-[[Tsonga]] ebesidoswa phambili ngu-Hosi Rivombo owahlala endaweni eneentaba begodu wabiza indawo le ngemva umdosiphambili wabo. Iintaba ze-Lebombo nazo ziqanjwe ngazo. Umlambo lo bewubizwa ngokuthi yi-Vhembe miphakathi yama-Venda wendawo. [5] Ikomkhulu nedorobha elikhulu khulu esifundazweni yi-[[Polokwane]], kuthi isishayamthetho sesifundazwe sise-Lebowakgomo.&lt;ref&gt;https://municipalities.co.za/provinces/view/5/limpopo&lt;/ref&gt;&lt;ref&gt;[https://www.sahistory.org.za/place/limpopo-province#:~:text=It%20was%20first%20called%20the,%2C%20Botswana%2C%20Zimbabwe%20and%20Mozambique. https://www.sahistory.org.za/place/limpopo-province#:~:text=It%20was%20first%20called%20the,%2C%20Botswana%2C%20Zimbabwe%20and%20Mozambique.]&lt;/ref&gt;

Iphrovinsi yakhiwe ziinarha ezintathu zangaphambilini ze-[[Lebowa]], [[Gazankulu]] kanye ne-Venda begodu yingcenye yesifunda sangaphambilini se-Transvaal. Iphrovinsi ye-Limpopo yasungulwa njengenye yeemfunda ezilithoba ngemva kokhetho luka-1994 lweSewula Afrika. Ibizo lephrovinsi bekuyi-&quot;Northern Transvaal&quot;, ngokukhamba kwesikhathi yatjhugululwa yaba &quot;Northern Province&quot; mhlazi-28 kuMgwengweni wee-1995, nezinye iimfunda ezimbili. Ibizo latjhugululwa godu ngomnyaka ka-2002 laba yi-Limpopo Province. I-Limpopo yakhiwe ziintjhaba ezintathu: i-Pedi, i-Tsonga kanye ne-[[Venda]].&lt;ref&gt;https://web.archive.org/web/20170201235654/http://www.dolimpopo.com/limpopo-province&lt;/ref&gt;

Abadosiphambili bendabuko namakhosi basakha umgogodla oqinileko wepolotiki yesifundazwe. Yasungulwa ngokuya komThetho we-Limpopo House of Traditional Leaders Act, Act 5 of 2005, umsebenzi omkhulu we-Limpopo House of Traditional Leaders kukweluleka urhulumende nesishayamthetho ngeendaba ezihlobene namasiko, amasiko, namasiko, kufaka hlangana amagadango wokuthuthukisa athinta imiphakathi yemakhaya. Mhlana ali-18 kuRhoboyi wee-2017, u-Kgosi Malesela Dikgale wakhethwa godu njengoSihlalo we-Limpopo House of Traditional Leaders.

== Iinkomba ==
&lt;references /&gt;
[[Category:ESewula Afrika]]
[[Mkhakha:Iimfunda]]</text>
      <sha1>l2ayxjnaijzu2ujigk6hbxe8jfesdc0</sha1>
    </revision>
    <revision>
      <id>1741</id>
      <parentid>1740</parentid>
      <timestamp>2024-10-23T23:49:36Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1741</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2286" sha1="o87cjbdx9cfjvdmhl803wg6yr2kcxl6" xml:space="preserve">'''I-Limpopo''' (/lɪmˈpoʊpoʊ/) yisimfunda esetlhagwini khulu y[[Isewula Afrika|eSewula Afrika]]. Iqanjwe [[ngomlambo i-Limpopo]], owenza umngcele wephrovinsi engeTjingalanga nesetlhagwini. Ibizo elithi Limpopo lisuselwa ku-Rivombo (i-Livombo/Lebombo), isiqhema sabahlali be-[[Tsonga]] ebesidoswa phambili ngu-Hosi Rivombo owahlala endaweni eneentaba begodu wabiza indawo le ngemva umdosiphambili wabo. Iintaba ze-Lebombo nazo ziqanjwe ngazo. Umlambo lo bewubizwa ngokuthi yi-Vhembe miphakathi yama-Venda wendawo. [5] Ikomkhulu nedorobha elikhulu khulu esifundazweni yi-[[Polokwane]], kuthi isishayamthetho sesifundazwe sise-Lebowakgomo.&lt;ref&gt;https://municipalities.co.za/provinces/view/5/limpopo&lt;/ref&gt;&lt;ref&gt;[https://www.sahistory.org.za/place/limpopo-province#:~:text=It%20was%20first%20called%20the,%2C%20Botswana%2C%20Zimbabwe%20and%20Mozambique. https://www.sahistory.org.za/place/limpopo-province#:~:text=It%20was%20first%20called%20the,%2C%20Botswana%2C%20Zimbabwe%20and%20Mozambique.]&lt;/ref&gt;

Iphrovinsi yakhiwe ziinarha ezintathu zangaphambilini ze-[[Lebowa]], [[Gazankulu]] kanye ne-Venda begodu yingcenye yesifunda sangaphambilini se-Transvaal. Iphrovinsi ye-Limpopo yasungulwa njengenye yeemfunda ezilithoba ngemva kokhetho luka-1994 lweSewula Afrika. Ibizo lephrovinsi bekuyi-&quot;Northern Transvaal&quot;, ngokukhamba kwesikhathi yatjhugululwa yaba &quot;Northern Province&quot; mhlazi-28 kuMgwengweni wee-1995, nezinye iimfunda ezimbili. Ibizo latjhugululwa godu ngomnyaka ka-2002 laba yi-Limpopo Province. I-Limpopo yakhiwe ziintjhaba ezintathu: isiPedi, isiTsonga kanye nesi[[Venda]].&lt;ref&gt;https://web.archive.org/web/20170201235654/http://www.dolimpopo.com/limpopo-province&lt;/ref&gt;

Abadosiphambili bendabuko namakhosi basakha umgogodla oqinileko wepolotiki yesifundazwe. Yasungulwa ngokuya komThetho we-Limpopo House of Traditional Leaders Act, Act 5 of 2005, umsebenzi omkhulu we-Limpopo House of Traditional Leaders kukweluleka urhulumende nesishayamthetho ngeendaba ezihlobene namasiko, amasiko, namasiko, kufaka hlangana amagadango wokuthuthukisa athinta imiphakathi yemakhaya. Mhlana ali-18 kuRhoboyi wee-2017, u-Kgosi Malesela Dikgale wakhethwa godu njengoSihlalo we-Limpopo House of Traditional Leaders.

== Iinkomba ==
&lt;references /&gt;
[[Category:ESewula Afrika]]
[[Mkhakha:Iimfunda]]</text>
      <sha1>o87cjbdx9cfjvdmhl803wg6yr2kcxl6</sha1>
    </revision>
    <revision>
      <id>1742</id>
      <parentid>1741</parentid>
      <timestamp>2024-10-23T23:50:30Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1742</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2282" sha1="r321t8vtinycwr11cxzlwy0ynw7tvm7" xml:space="preserve">'''I-Limpopo''' (/lɪmˈpoʊpoʊ/) yisimfunda esetlhagwini khulu y[[Isewula Afrika|eSewula Afrika]]. Iqanjwe [[ngomlambo i-Limpopo]], owenza umngcele wephrovinsi engeTjingalanga nesetlhagwini. Ibizo elithi Limpopo lisuselwa ku-Rivombo (i-Livombo/Lebombo), isiqhema sabahlali be-[[Tsonga]] ebesidoswa phambili ngu-Hosi Rivombo owahlala endaweni eneentaba begodu wabiza indawo le ngemva umdosiphambili wabo. Iintaba ze-Lebombo nazo ziqanjwe ngazo. Umlambo lo bewubizwa ngokuthi yi-Vhembe miphakathi yama-Venda wendawo. Ikomkhulu nedorobha elikhulu khulu esifundazweni yi-[[Polokwane]], kuthi isishayamthetho sesifundazwe sise-Lebowakgomo.&lt;ref&gt;https://municipalities.co.za/provinces/view/5/limpopo&lt;/ref&gt;&lt;ref&gt;[https://www.sahistory.org.za/place/limpopo-province#:~:text=It%20was%20first%20called%20the,%2C%20Botswana%2C%20Zimbabwe%20and%20Mozambique. https://www.sahistory.org.za/place/limpopo-province#:~:text=It%20was%20first%20called%20the,%2C%20Botswana%2C%20Zimbabwe%20and%20Mozambique.]&lt;/ref&gt;

Iphrovinsi yakhiwe ziinarha ezintathu zangaphambilini ze-[[Lebowa]], [[Gazankulu]] kanye ne-Venda begodu yingcenye yesifunda sangaphambilini se-Transvaal. Iphrovinsi ye-Limpopo yasungulwa njengenye yeemfunda ezilithoba ngemva kokhetho luka-1994 lweSewula Afrika. Ibizo lephrovinsi bekuyi-&quot;Northern Transvaal&quot;, ngokukhamba kwesikhathi yatjhugululwa yaba &quot;Northern Province&quot; mhlazi-28 kuMgwengweni wee-1995, nezinye iimfunda ezimbili. Ibizo latjhugululwa godu ngomnyaka ka-2002 laba yi-Limpopo Province. I-Limpopo yakhiwe ziintjhaba ezintathu: isiPedi, isiTsonga kanye nesi[[Venda]].&lt;ref&gt;https://web.archive.org/web/20170201235654/http://www.dolimpopo.com/limpopo-province&lt;/ref&gt;

Abadosiphambili bendabuko namakhosi basakha umgogodla oqinileko wepolotiki yesifundazwe. Yasungulwa ngokuya komThetho we-Limpopo House of Traditional Leaders Act, Act 5 of 2005, umsebenzi omkhulu we-Limpopo House of Traditional Leaders kukweluleka urhulumende nesishayamthetho ngeendaba ezihlobene namasiko, amasiko, namasiko, kufaka hlangana amagadango wokuthuthukisa athinta imiphakathi yemakhaya. Mhlana ali-18 kuRhoboyi wee-2017, u-Kgosi Malesela Dikgale wakhethwa godu njengoSihlalo we-Limpopo House of Traditional Leaders.

== Iinkomba ==
&lt;references /&gt;
[[Category:ESewula Afrika]]
[[Mkhakha:Iimfunda]]</text>
      <sha1>r321t8vtinycwr11cxzlwy0ynw7tvm7</sha1>
    </revision>
    <revision>
      <id>2121</id>
      <parentid>1742</parentid>
      <timestamp>2024-11-25T18:12:41Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* Iinkomba */Mkhakha</comment>
      <origin>2121</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2279" sha1="6micyiujjsqee8qkpfetck046vk58ii" xml:space="preserve">'''I-Limpopo''' (/lɪmˈpoʊpoʊ/) yisimfunda esetlhagwini khulu y[[Isewula Afrika|eSewula Afrika]]. Iqanjwe [[ngomlambo i-Limpopo]], owenza umngcele wephrovinsi engeTjingalanga nesetlhagwini. Ibizo elithi Limpopo lisuselwa ku-Rivombo (i-Livombo/Lebombo), isiqhema sabahlali be-[[Tsonga]] ebesidoswa phambili ngu-Hosi Rivombo owahlala endaweni eneentaba begodu wabiza indawo le ngemva umdosiphambili wabo. Iintaba ze-Lebombo nazo ziqanjwe ngazo. Umlambo lo bewubizwa ngokuthi yi-Vhembe miphakathi yama-Venda wendawo. Ikomkhulu nedorobha elikhulu khulu esifundazweni yi-[[Polokwane]], kuthi isishayamthetho sesifundazwe sise-Lebowakgomo.&lt;ref&gt;https://municipalities.co.za/provinces/view/5/limpopo&lt;/ref&gt;&lt;ref&gt;[https://www.sahistory.org.za/place/limpopo-province#:~:text=It%20was%20first%20called%20the,%2C%20Botswana%2C%20Zimbabwe%20and%20Mozambique. https://www.sahistory.org.za/place/limpopo-province#:~:text=It%20was%20first%20called%20the,%2C%20Botswana%2C%20Zimbabwe%20and%20Mozambique.]&lt;/ref&gt;

Iphrovinsi yakhiwe ziinarha ezintathu zangaphambilini ze-[[Lebowa]], [[Gazankulu]] kanye ne-Venda begodu yingcenye yesifunda sangaphambilini se-Transvaal. Iphrovinsi ye-Limpopo yasungulwa njengenye yeemfunda ezilithoba ngemva kokhetho luka-1994 lweSewula Afrika. Ibizo lephrovinsi bekuyi-&quot;Northern Transvaal&quot;, ngokukhamba kwesikhathi yatjhugululwa yaba &quot;Northern Province&quot; mhlazi-28 kuMgwengweni wee-1995, nezinye iimfunda ezimbili. Ibizo latjhugululwa godu ngomnyaka ka-2002 laba yi-Limpopo Province. I-Limpopo yakhiwe ziintjhaba ezintathu: isiPedi, isiTsonga kanye nesi[[Venda]].&lt;ref&gt;https://web.archive.org/web/20170201235654/http://www.dolimpopo.com/limpopo-province&lt;/ref&gt;

Abadosiphambili bendabuko namakhosi basakha umgogodla oqinileko wepolotiki yesifundazwe. Yasungulwa ngokuya komThetho we-Limpopo House of Traditional Leaders Act, Act 5 of 2005, umsebenzi omkhulu we-Limpopo House of Traditional Leaders kukweluleka urhulumende nesishayamthetho ngeendaba ezihlobene namasiko, amasiko, namasiko, kufaka hlangana amagadango wokuthuthukisa athinta imiphakathi yemakhaya. Mhlana ali-18 kuRhoboyi wee-2017, u-Kgosi Malesela Dikgale wakhethwa godu njengoSihlalo we-Limpopo House of Traditional Leaders.

== Iinkomba ==
{{Reflist}}

[[Mkhakha:ESewula Afrika]]
[[Mkhakha:Iimfunda]]</text>
      <sha1>6micyiujjsqee8qkpfetck046vk58ii</sha1>
    </revision>
    <revision>
      <id>2843</id>
      <parentid>2121</parentid>
      <timestamp>2025-05-25T12:00:54Z</timestamp>
      <contributor>
        <ip>78.174.67.243</ip>
      </contributor>
      <origin>2843</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2332" sha1="jtj9o2mpxanay3xdtzcjl7g9dy35x7a" xml:space="preserve">'''I-Limpopo''' (/lɪmˈpoʊpoʊ/) yisimfunda esetlhagwini khulu y[[Isewula Afrika|eSewula Afrika]]. Iqanjwe [[ngomlambo i-Limpopo]], owenza umngcele wephrovinsi engeTjingalanga nesetlhagwini. Ibizo elithi Limpopo lisuselwa ku-Rivombo (i-Livombo/Lebombo), isiqhema sabahlali be-[[Tsonga]] ebesidoswa phambili ngu-Hosi Rivombo owahlala endaweni eneentaba begodu wabiza indawo le ngemva umdosiphambili wabo. Iintaba ze-Lebombo nazo ziqanjwe ngazo. Umlambo lo bewubizwa ngokuthi yi-Vhembe miphakathi yama-Venda wendawo. Ikomkhulu nedorobha elikhulu khulu esifundazweni [https://www.telsorgulama.com.tr/ telsorgulama.com.tr] [[Polokwane]], kuthi isishayamthetho sesifundazwe sise-Lebowakgomo.&lt;ref&gt;https://municipalities.co.za/provinces/view/5/limpopo&lt;/ref&gt;&lt;ref&gt;[https://www.sahistory.org.za/place/limpopo-province#:~:text=It%20was%20first%20called%20the,%2C%20Botswana%2C%20Zimbabwe%20and%20Mozambique. https://www.sahistory.org.za/place/limpopo-province#:~:text=It%20was%20first%20called%20the,%2C%20Botswana%2C%20Zimbabwe%20and%20Mozambique.]&lt;/ref&gt;

Iphrovinsi yakhiwe ziinarha ezintathu zangaphambilini ze-[[Lebowa]], [[Gazankulu]] kanye ne-Venda begodu yingcenye yesifunda sangaphambilini se-Transvaal. Iphrovinsi ye-Limpopo yasungulwa njengenye yeemfunda ezilithoba ngemva kokhetho luka-1994 lweSewula Afrika. Ibizo lephrovinsi bekuyi-&quot;Northern Transvaal&quot;, ngokukhamba kwesikhathi yatjhugululwa yaba &quot;Northern Province&quot; mhlazi-28 kuMgwengweni wee-1995, nezinye iimfunda ezimbili. Ibizo latjhugululwa godu ngomnyaka ka-2002 laba yi-Limpopo Province. I-Limpopo yakhiwe ziintjhaba ezintathu: isiPedi, isiTsonga kanye nesi[[Venda]].&lt;ref&gt;https://web.archive.org/web/20170201235654/http://www.dolimpopo.com/limpopo-province&lt;/ref&gt;

Abadosiphambili bendabuko namakhosi basakha umgogodla oqinileko wepolotiki yesifundazwe. Yasungulwa ngokuya komThetho we-Limpopo House of Traditional Leaders Act, Act 5 of 2005, umsebenzi omkhulu we-Limpopo House of Traditional Leaders kukweluleka urhulumende nesishayamthetho ngeendaba ezihlobene namasiko, amasiko, namasiko, kufaka hlangana amagadango wokuthuthukisa athinta imiphakathi yemakhaya. Mhlana ali-18 kuRhoboyi wee-2017, u-Kgosi Malesela Dikgale wakhethwa godu njengoSihlalo we-Limpopo House of Traditional Leaders. 

== Iinkomba ==
{{Reflist}}

[[Mkhakha:ESewula Afrika]]
[[Mkhakha:Iimfunda]]</text>
      <sha1>jtj9o2mpxanay3xdtzcjl7g9dy35x7a</sha1>
    </revision>
    <revision>
      <id>2995</id>
      <parentid>2843</parentid>
      <timestamp>2025-06-06T20:16:32Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>ymunhtbgfrvdcx</comment>
      <origin>2995</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2413" sha1="pi85rdst8zsp1ru8trvn2opd54d9xcp" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. I-Limpopo''' (/lɪmˈpoʊpoʊ/) yisimfunda esetlhagwini khulu y[[Isewula Afrika|eSewula Afrika]]. Iqanjwe [[ngomlambo i-Limpopo]], owenza umngcele wephrovinsi engeTjingalanga nesetlhagwini. Ibizo elithi Limpopo lisuselwa ku-Rivombo (i-Livombo/Lebombo), isiqhema sabahlali be-[[Tsonga]] ebesidoswa phambili ngu-Hosi Rivombo owahlala endaweni eneentaba begodu wabiza indawo le ngemva umdosiphambili wabo. Iintaba ze-Lebombo nazo ziqanjwe ngazo. Umlambo lo bewubizwa ngokuthi yi-Vhembe miphakathi yama-Venda wendawo. Ikomkhulu nedorobha elikhulu khulu esifundazweni [https://www.telsorgulama.com.tr/ telsorgulama.com.tr] [[Polokwane]], kuthi isishayamthetho sesifundazwe sise-Lebowakgomo.&lt;ref&gt;https://municipalities.co.za/provinces/view/5/limpopo&lt;/ref&gt;&lt;ref&gt;[https://www.sahistory.org.za/place/limpopo-province#:~:text=It%20was%20first%20called%20the,%2C%20Botswana%2C%20Zimbabwe%20and%20Mozambique. https://www.sahistory.org.za/place/limpopo-province#:~:text=It%20was%20first%20called%20the,%2C%20Botswana%2C%20Zimbabwe%20and%20Mozambique.]&lt;/ref&gt;

Iphrovinsi yakhiwe ziinarha ezintathu zangaphambilini ze-[[Lebowa]], [[Gazankulu]] kanye ne-Venda begodu yingcenye yesifunda sangaphambilini se-Transvaal. Iphrovinsi ye-Limpopo yasungulwa njengenye yeemfunda ezilithoba ngemva kokhetho luka-1994 lweSewula Afrika. Ibizo lephrovinsi bekuyi-&quot;Northern Transvaal&quot;, ngokukhamba kwesikhathi yatjhugululwa yaba &quot;Northern Province&quot; mhlazi-28 kuMgwengweni wee-1995, nezinye iimfunda ezimbili. Ibizo latjhugululwa godu ngomnyaka ka-2002 laba yi-Limpopo Province. I-Limpopo yakhiwe ziintjhaba ezintathu: isiPedi, isiTsonga kanye nesi[[Venda]].&lt;ref&gt;https://web.archive.org/web/20170201235654/http://www.dolimpopo.com/limpopo-province&lt;/ref&gt;

Abadosiphambili bendabuko namakhosi basakha umgogodla oqinileko wepolotiki yesifundazwe. Yasungulwa ngokuya komThetho we-Limpopo House of Traditional Leaders Act, Act 5 of 2005, umsebenzi omkhulu we-Limpopo House of Traditional Leaders kukweluleka urhulumende nesishayamthetho ngeendaba ezihlobene namasiko, amasiko, namasiko, kufaka hlangana amagadango wokuthuthukisa athinta imiphakathi yemakhaya. Mhlana ali-18 kuRhoboyi wee-2017, u-Kgosi Malesela Dikgale wakhethwa godu njengoSihlalo we-Limpopo House of Traditional Leaders. 

== Iinkomba ==
{{Reflist}}

[[Mkhakha:ESewula Afrika]]
[[Mkhakha:Iimfunda]]</text>
      <sha1>pi85rdst8zsp1ru8trvn2opd54d9xcp</sha1>
    </revision>
    <revision>
      <id>3070</id>
      <parentid>2995</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:78.174.67.243|78.174.67.243]]</comment>
      <origin>2843</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2332" sha1="jtj9o2mpxanay3xdtzcjl7g9dy35x7a" xml:space="preserve">'''I-Limpopo''' (/lɪmˈpoʊpoʊ/) yisimfunda esetlhagwini khulu y[[Isewula Afrika|eSewula Afrika]]. Iqanjwe [[ngomlambo i-Limpopo]], owenza umngcele wephrovinsi engeTjingalanga nesetlhagwini. Ibizo elithi Limpopo lisuselwa ku-Rivombo (i-Livombo/Lebombo), isiqhema sabahlali be-[[Tsonga]] ebesidoswa phambili ngu-Hosi Rivombo owahlala endaweni eneentaba begodu wabiza indawo le ngemva umdosiphambili wabo. Iintaba ze-Lebombo nazo ziqanjwe ngazo. Umlambo lo bewubizwa ngokuthi yi-Vhembe miphakathi yama-Venda wendawo. Ikomkhulu nedorobha elikhulu khulu esifundazweni [https://www.telsorgulama.com.tr/ telsorgulama.com.tr] [[Polokwane]], kuthi isishayamthetho sesifundazwe sise-Lebowakgomo.&lt;ref&gt;https://municipalities.co.za/provinces/view/5/limpopo&lt;/ref&gt;&lt;ref&gt;[https://www.sahistory.org.za/place/limpopo-province#:~:text=It%20was%20first%20called%20the,%2C%20Botswana%2C%20Zimbabwe%20and%20Mozambique. https://www.sahistory.org.za/place/limpopo-province#:~:text=It%20was%20first%20called%20the,%2C%20Botswana%2C%20Zimbabwe%20and%20Mozambique.]&lt;/ref&gt;

Iphrovinsi yakhiwe ziinarha ezintathu zangaphambilini ze-[[Lebowa]], [[Gazankulu]] kanye ne-Venda begodu yingcenye yesifunda sangaphambilini se-Transvaal. Iphrovinsi ye-Limpopo yasungulwa njengenye yeemfunda ezilithoba ngemva kokhetho luka-1994 lweSewula Afrika. Ibizo lephrovinsi bekuyi-&quot;Northern Transvaal&quot;, ngokukhamba kwesikhathi yatjhugululwa yaba &quot;Northern Province&quot; mhlazi-28 kuMgwengweni wee-1995, nezinye iimfunda ezimbili. Ibizo latjhugululwa godu ngomnyaka ka-2002 laba yi-Limpopo Province. I-Limpopo yakhiwe ziintjhaba ezintathu: isiPedi, isiTsonga kanye nesi[[Venda]].&lt;ref&gt;https://web.archive.org/web/20170201235654/http://www.dolimpopo.com/limpopo-province&lt;/ref&gt;

Abadosiphambili bendabuko namakhosi basakha umgogodla oqinileko wepolotiki yesifundazwe. Yasungulwa ngokuya komThetho we-Limpopo House of Traditional Leaders Act, Act 5 of 2005, umsebenzi omkhulu we-Limpopo House of Traditional Leaders kukweluleka urhulumende nesishayamthetho ngeendaba ezihlobene namasiko, amasiko, namasiko, kufaka hlangana amagadango wokuthuthukisa athinta imiphakathi yemakhaya. Mhlana ali-18 kuRhoboyi wee-2017, u-Kgosi Malesela Dikgale wakhethwa godu njengoSihlalo we-Limpopo House of Traditional Leaders. 

== Iinkomba ==
{{Reflist}}

[[Mkhakha:ESewula Afrika]]
[[Mkhakha:Iimfunda]]</text>
      <sha1>jtj9o2mpxanay3xdtzcjl7g9dy35x7a</sha1>
    </revision>
    <revision>
      <id>5889</id>
      <parentid>3070</parentid>
      <timestamp>2025-09-30T23:21:17Z</timestamp>
      <contributor>
        <username>~2025-27256-42</username>
        <id>1039</id>
      </contributor>
      <origin>5889</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2351" sha1="9ecmeqkixbgbyo8bwrslu9d0fb64udd" xml:space="preserve">'''I-Limpopo''' (/lɪmˈpoʊpoʊ/) yisimfunda esetlhagwini khulu y[[Isewula Afrika|eSewula Afrika]]. Iqanjwe [[ngomlambo i-Limpopo]], owenza umngcele wephrovinsi engeTjingalanga nesetlhagwini. Ibizo elithi Limpopo lisuselwa ku-Rivombo (i-Livombo/Lebombo), isiqhema sabahlali be-[[Tsonga]] ebesidoswa phambili ngu-Hosi Rivombo owahlala endaweni eneentaba begodu wabiza indawo le ngemva umdosiphambili wabo. Iintaba ze-Lebombo nazo ziqanjwe ngazo. Umlambo lo bewubizwa ngokuthi yi-Vhembe miphakathi yama-Venda wendawo. Ikomkhulu nedorobha elikhulu khulu esifundazweni [https://www.telsorgulama.com.tr/ telsorgulama.com.tr] [[Polokwane]], kuthi isishayamthetho sesifundazwe sise-Lebowakgomo.&lt;ref&gt;https://municipalities.co.za/provinces/view/5/limpopo&lt;/ref&gt;&lt;ref&gt;[https://www.sahistory.org.za/place/limpopo-province#:~:text=It%20was%20first%20called%20the,%2C%20Botswana%2C%20Zimbabwe%20and%20Mozambique. https://www.sahistory.org.za/place/limpopo-province#:~:text=It%20was%20first%20called%20the,%2C%20Botswana%2C%20Zimbabwe%20and%20Mozambique.]&lt;/ref&gt;

Iphrovinsi yakhiwe ziinarha ezintathu zangaphambilini ze-[[Lebowa]], [[Gazankulu]] kanye ne-Venda begodu yingcenye yesifunda sangaphambilini se-Transvaal. Iphrovinsi ye-Limpopo yasungulwa njengenye yeemfunda ezilithoba ngemva kokhetho luka-1994 lweSewula Afrika. Ibizo lephrovinsi bekuyi-&quot;Northern Transvaal&quot;, ngokukhamba kwesikhathi yatjhugululwa yaba &quot;Northern Province&quot; mhlazi-28 kuMgwengweni wee-1995, nezinye iimfunda ezimbili. Ibizo latjhugululwa godu ngomnyaka ka-2002 laba yi-Limpopo Province. I-Limpopo yakhiwe ziintjhaba ezintathu: isiPedi, isiTsonga kanye nesi[https://kotivon.com/ Venda].&lt;ref&gt;https://web.archive.org/web/20170201235654/http://www.dolimpopo.com/limpopo-province&lt;/ref&gt;

Abadosiphambili bendabuko namakhosi basakha umgogodla oqinileko wepolotiki yesifundazwe. Yasungulwa ngokuya komThetho we-Limpopo House of Traditional Leaders Act, Act 5 of 2005, umsebenzi omkhulu we-Limpopo House of Traditional Leaders kukweluleka urhulumende nesishayamthetho ngeendaba ezihlobene namasiko, amasiko, namasiko, kufaka hlangana amagadango wokuthuthukisa athinta imiphakathi yemakhaya. Mhlana ali-18 kuRhoboyi wee-2017, u-Kgosi Malesela Dikgale wakhethwa godu njengoSihlalo we-Limpopo House of Traditional Leaders. 

== Iinkomba ==
{{Reflist}}

[[Mkhakha:ESewula Afrika]]
[[Mkhakha:Iimfunda]]</text>
      <sha1>9ecmeqkixbgbyo8bwrslu9d0fb64udd</sha1>
    </revision>
    <revision>
      <id>5914</id>
      <parentid>5889</parentid>
      <timestamp>2025-10-11T22:10:27Z</timestamp>
      <contributor>
        <username>~2025-28489-09</username>
        <id>1060</id>
      </contributor>
      <origin>5914</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2370" sha1="apciqmm9cng2ocp5zn8yjvq1ykd48ru" xml:space="preserve">'''I-Limpopo''' (/lɪmˈpoʊpoʊ/) yisimfunda esetlhagwini khulu y[[Isewula Afrika|eSewula Afrika]]. Iqanjwe [[ngomlambo i-Limpopo]], owenza umngcele wephrovinsi engeTjingalanga nesetlhagwini. Ibizo elithi Limpopo lisuselwa ku-Rivombo (i-Livombo/Lebombo), isiqhema sabahlali be-[[Tsonga]] ebesidoswa phambili ngu-Hosi Rivombo owahlala endaweni eneentaba begodu wabiza indawo le ngemva umdosiphambili wabo. Iintaba ze-Lebombo nazo ziqanjwe ngazo. Umlambo lo bewubizwa ngokuthi yi-Vhembe miphakathi yama-Venda wendawo. Ikomkhulu nedorobha elikhulu khulu esifundazweni [https://www.telsorgulama.com.tr/ telsorgulama.com.tr] [[Polokwane]], kuthi isishayamthetho sesifundazwe sise-Lebowakgomo.&lt;ref&gt;https://municipalities.co.za/provinces/view/5/limpopo&lt;/ref&gt;&lt;ref&gt;[https://www.sahistory.org.za/place/limpopo-province#:~:text=It%20was%20first%20called%20the,%2C%20Botswana%2C%20Zimbabwe%20and%20Mozambique. https://www.sahistory.org.za/place/limpopo-province#:~:text=It%20was%20first%20called%20the,%2C%20Botswana%2C%20Zimbabwe%20and%20Mozambique.]&lt;/ref&gt;

Iphrovinsi yakhiwe ziinarha ezintathu zangaphambilini ze-[https://ahmegon.com/ Lebowa], [[Gazankulu]] kanye ne-Venda begodu yingcenye yesifunda sangaphambilini se-Transvaal. Iphrovinsi ye-Limpopo yasungulwa njengenye yeemfunda ezilithoba ngemva kokhetho luka-1994 lweSewula Afrika. Ibizo lephrovinsi bekuyi-&quot;Northern Transvaal&quot;, ngokukhamba kwesikhathi yatjhugululwa yaba &quot;Northern Province&quot; mhlazi-28 kuMgwengweni wee-1995, nezinye iimfunda ezimbili. Ibizo latjhugululwa godu ngomnyaka ka-2002 laba yi-Limpopo Province. I-Limpopo yakhiwe ziintjhaba ezintathu: isiPedi, isiTsonga kanye nesi[https://kotivon.com/ Venda].&lt;ref&gt;https://web.archive.org/web/20170201235654/http://www.dolimpopo.com/limpopo-province&lt;/ref&gt;

Abadosiphambili bendabuko namakhosi basakha umgogodla oqinileko wepolotiki yesifundazwe. Yasungulwa ngokuya komThetho we-Limpopo House of Traditional Leaders Act, Act 5 of 2005, umsebenzi omkhulu we-Limpopo House of Traditional Leaders kukweluleka urhulumende nesishayamthetho ngeendaba ezihlobene namasiko, amasiko, namasiko, kufaka hlangana amagadango wokuthuthukisa athinta imiphakathi yemakhaya. Mhlana ali-18 kuRhoboyi wee-2017, u-Kgosi Malesela Dikgale wakhethwa godu njengoSihlalo we-Limpopo House of Traditional Leaders. 

== Iinkomba ==
{{Reflist}}

[[Mkhakha:ESewula Afrika]]
[[Mkhakha:Iimfunda]]</text>
      <sha1>apciqmm9cng2ocp5zn8yjvq1ykd48ru</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Iimfunda</title>
    <ns>14</ns>
    <id>333</id>
    <revision>
      <id>1739</id>
      <timestamp>2024-10-23T23:46:10Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created blank page</comment>
      <origin>1739</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
  </page>
  <page>
    <title>Polokwane</title>
    <ns>0</ns>
    <id>334</id>
    <revision>
      <id>1743</id>
      <timestamp>2024-10-24T00:15:04Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created page with &quot;I-Polokwane lidorobha elikhulu lesiFunda se-[[Limpopo]] [[Isewula Afrika|eSewula Afrika]]. Yisikhungo samadorobha esikhulu kunazo zoke enarheni enyakatho ye-[[Gauteng]]. Bekungenye yamadorobha alithoba abamba iNdebe yePhasi ye-FIFA yango-2010. &lt;ref&gt;[https://www.encyclopedia.com/reference/encyclopedias-almanacs-transcripts-and-maps/polokwane#:~:text=Polokwane%20was%20founded%20as%20Pietersburg,by%20British%20troops%20in%201901. https://www.encyclopedia.com/reference/encyc...&quot;</comment>
      <origin>1743</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="710" sha1="ct7j9yr7pyb3hzvm5chug8fawtvaqtc" xml:space="preserve">I-Polokwane lidorobha elikhulu lesiFunda se-[[Limpopo]] [[Isewula Afrika|eSewula Afrika]]. Yisikhungo samadorobha esikhulu kunazo zoke enarheni enyakatho ye-[[Gauteng]]. Bekungenye yamadorobha alithoba abamba iNdebe yePhasi ye-FIFA yango-2010. &lt;ref&gt;[https://www.encyclopedia.com/reference/encyclopedias-almanacs-transcripts-and-maps/polokwane#:~:text=Polokwane%20was%20founded%20as%20Pietersburg,by%20British%20troops%20in%201901. https://www.encyclopedia.com/reference/encyclopedias-almanacs-transcripts-and-maps/polokwane#:~:text=Polokwane%20was%20founded%20as%20Pietersburg,by%20British%20troops%20in%201901.]&lt;/ref&gt;&lt;ref&gt;https://www.southafrica.net/mw/en/travel/article/history-and-culture-in-polokwane&lt;/ref&gt;</text>
      <sha1>ct7j9yr7pyb3hzvm5chug8fawtvaqtc</sha1>
    </revision>
    <revision>
      <id>1744</id>
      <parentid>1743</parentid>
      <timestamp>2024-10-24T00:16:35Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1744</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="726" sha1="qgy371ic4zwxdm0w0c1mmoonie12c09" xml:space="preserve">I-Polokwane lidorobha elikhulu lesiFunda se-[[Limpopo]] [[Isewula Afrika|eSewula Afrika]]. Yisikhungo samadorobha esikhulu kunazo zoke enarheni enyakatho ye-[[Gauteng]]. Bekungenye yamadorobha alithoba abamba iNdebe yePhasi ye-FIFA yango-2010. &lt;ref&gt;[https://www.encyclopedia.com/reference/encyclopedias-almanacs-transcripts-and-maps/polokwane#:~:text=Polokwane%20was%20founded%20as%20Pietersburg,by%20British%20troops%20in%201901. https://www.encyclopedia.com/reference/encyclopedias-almanacs-transcripts-and-maps/polokwane#:~:text=Polokwane%20was%20founded%20as%20Pietersburg,by%20British%20troops%20in%201901.]&lt;/ref&gt;&lt;ref&gt;https://www.southafrica.net/mw/en/travel/article/history-and-culture-in-polokwane&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>qgy371ic4zwxdm0w0c1mmoonie12c09</sha1>
    </revision>
    <revision>
      <id>1745</id>
      <parentid>1744</parentid>
      <timestamp>2024-10-24T00:19:43Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1745</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1736" sha1="57ka8qws7if7v1yblxbg2kw6m1v81yc" xml:space="preserve">I-Polokwane lidorobha elikhulu lesiFunda se-[[Limpopo]] [[Isewula Afrika|eSewula Afrika]]. Yisikhungo samadorobha esikhulu kunazo zoke enarheni enyakatho ye-[[Gauteng]]. Bekungenye yamadorobha alithoba abamba iNdebe yePhasi ye-FIFA yango-2010. &lt;ref&gt;[https://www.encyclopedia.com/reference/encyclopedias-almanacs-transcripts-and-maps/polokwane#:~:text=Polokwane%20was%20founded%20as%20Pietersburg,by%20British%20troops%20in%201901. https://www.encyclopedia.com/reference/encyclopedias-almanacs-transcripts-and-maps/polokwane#:~:text=Polokwane%20was%20founded%20as%20Pietersburg,by%20British%20troops%20in%201901.]&lt;/ref&gt;&lt;ref&gt;https://www.southafrica.net/mw/en/travel/article/history-and-culture-in-polokwane&lt;/ref&gt;

== Umlando ==
Ngabo-1840, ama-Voortrekkers ngaphasi koburholi baka-Andries Hendrik Potgieter asungula i-[[Zoutpansbergdorp]], idorobha eliyi-100 km (62 mi) ukuya enyakatho. Indawo yokuhlala le kwafanela bona itjhiywe ngebanga lokurarana neentjhaba zendawo (ama-Lebelo, Langa &amp; Ledwaba clans), basungula idorobha elitjha ngo-1886 baliqamba ngokuthi &quot;Pietersburg&quot; ukuhlonipha umdosiphambili we-Voortrekker u-[[Petrus Jacobus Joubert]]. Inani elincani labantu be-India/Asia kanye nabantu abanemibala bahlala esifundeni ngaphambi kokuphela kwekhulu le-19. Bekuyinhlokodolobha ye-Transvaal ne-Orange Free State isikhathi esifitjhani ngo-1900 ngesikhathi sePi yesiBili yamaBhunu kusukela ngo-1899 ukuya ku-1902.[6] AmaBrithani athatha i-Pietersburg ngo-1901 begodu akha ikampa yokuhlushwa ukubopha abafazi nabantwana be-Boer abapheze babe zi-4,000.&lt;ref&gt;https://www.tandfonline.com/doi/abs/10.1080/10289852.1999.10520169&lt;/ref&gt;&lt;ref&gt;https://www.sacities.net/wp-content/uploads/2019/12/Polokwane-final-report.pdf&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>57ka8qws7if7v1yblxbg2kw6m1v81yc</sha1>
    </revision>
    <revision>
      <id>1746</id>
      <parentid>1745</parentid>
      <timestamp>2024-10-24T00:21:47Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1746</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1800" sha1="j2ofy4xntg7lv5aa949dntk0q9m4ved" xml:space="preserve">I-Polokwane lidorobha elikhulu lesiFunda se-[[Limpopo]] [[Isewula Afrika|eSewula Afrika]]. Yisikhungo samadorobha esikhulu kunazo zoke enarheni enyakatho ye-[[Gauteng]]. Bekungenye yamadorobha alithoba abamba iNdebe yePhasi ye-FIFA yango-2010. &lt;ref&gt;[https://www.encyclopedia.com/reference/encyclopedias-almanacs-transcripts-and-maps/polokwane#:~:text=Polokwane%20was%20founded%20as%20Pietersburg,by%20British%20troops%20in%201901. https://www.encyclopedia.com/reference/encyclopedias-almanacs-transcripts-and-maps/polokwane#:~:text=Polokwane%20was%20founded%20as%20Pietersburg,by%20British%20troops%20in%201901.]&lt;/ref&gt;&lt;ref&gt;https://www.southafrica.net/mw/en/travel/article/history-and-culture-in-polokwane&lt;/ref&gt;

== Umlando ==
Ngabo-1840, ama-Voortrekkers ngaphasi koburholi baka-Andries Hendrik Potgieter asungula i-[[Zoutpansbergdorp]], idorobha eliyi-100 km (62 mi) ukuya enyakatho. Indawo yokuhlala le kwafanela bona itjhiywe ngebanga lokurarana neentjhaba zendawo (ama-Lebelo, Langa &amp; Ledwaba clans), basungula idorobha elitjha ngo-1886 baliqamba ngokuthi &quot;Pietersburg&quot; ukuhlonipha umdosiphambili we-Voortrekker u-[[Petrus Jacobus Joubert]]. Inani elincani labantu be-India/Asia kanye nabantu abanemibala bahlala esifundeni ngaphambi kokuphela kwekhulu le-19. Bekuyinhlokodolobha ye-Transvaal ne-Orange Free State isikhathi esifitjhani ngo-1900 ngesikhathi sePi yesiBili yamaBhunu kusukela ngo-1899 ukuya ku-1902.[6] AmaBrithani athatha i-Pietersburg ngo-1901 begodu akha ikampa yokuhlushwa ukubopha abafazi nabantwana be-Boer abapheze babe zi-4,000.&lt;ref&gt;https://www.tandfonline.com/doi/abs/10.1080/10289852.1999.10520169&lt;/ref&gt;&lt;ref&gt;https://www.sacities.net/wp-content/uploads/2019/12/Polokwane-final-report.pdf&lt;/ref&gt;

== Iinkomba ==
&lt;references /&gt;
[[Category:ESewula Afrika]]
[[Mkhakha:Iimfunda]]</text>
      <sha1>j2ofy4xntg7lv5aa949dntk0q9m4ved</sha1>
    </revision>
    <revision>
      <id>1747</id>
      <parentid>1746</parentid>
      <timestamp>2024-10-24T00:31:46Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1747</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1902" sha1="9f5aep1w5mypc1chvla5jj2tqwjxoee" xml:space="preserve">[[Isimumathi:Polokwane (Pietersburg), Limpopo, South Africa.jpg|thumb|457x457px|Idorobha iPolokwane]]
I-Polokwane lidorobha elikhulu lesiFunda se-[[Limpopo]] [[Isewula Afrika|eSewula Afrika]]. Yisikhungo samadorobha esikhulu kunazo zoke enarheni enyakatho ye-[[Gauteng]]. Bekungenye yamadorobha alithoba abamba iNdebe yePhasi ye-FIFA yango-2010. &lt;ref&gt;[https://www.encyclopedia.com/reference/encyclopedias-almanacs-transcripts-and-maps/polokwane#:~:text=Polokwane%20was%20founded%20as%20Pietersburg,by%20British%20troops%20in%201901. https://www.encyclopedia.com/reference/encyclopedias-almanacs-transcripts-and-maps/polokwane#:~:text=Polokwane%20was%20founded%20as%20Pietersburg,by%20British%20troops%20in%201901.]&lt;/ref&gt;&lt;ref&gt;https://www.southafrica.net/mw/en/travel/article/history-and-culture-in-polokwane&lt;/ref&gt;

== Umlando ==
Ngabo-1840, ama-Voortrekkers ngaphasi koburholi baka-Andries Hendrik Potgieter asungula i-[[Zoutpansbergdorp]], idorobha eliyi-100 km (62 mi) ukuya enyakatho. Indawo yokuhlala le kwafanela bona itjhiywe ngebanga lokurarana neentjhaba zendawo (ama-Lebelo, Langa &amp; Ledwaba clans), basungula idorobha elitjha ngo-1886 baliqamba ngokuthi &quot;Pietersburg&quot; ukuhlonipha umdosiphambili we-Voortrekker u-[[Petrus Jacobus Joubert]]. Inani elincani labantu be-India/Asia kanye nabantu abanemibala bahlala esifundeni ngaphambi kokuphela kwekhulu le-19. Bekuyinhlokodolobha ye-Transvaal ne-Orange Free State isikhathi esifitjhani ngo-1900 ngesikhathi sePi yesiBili yamaBhunu kusukela ngo-1899 ukuya ku-1902.[6] AmaBrithani athatha i-Pietersburg ngo-1901 begodu akha ikampa yokuhlushwa ukubopha abafazi nabantwana be-Boer abapheze babe zi-4,000.&lt;ref&gt;https://www.tandfonline.com/doi/abs/10.1080/10289852.1999.10520169&lt;/ref&gt;&lt;ref&gt;https://www.sacities.net/wp-content/uploads/2019/12/Polokwane-final-report.pdf&lt;/ref&gt;

== Iinkomba ==
&lt;references /&gt;
[[Category:ESewula Afrika]]
[[Mkhakha:Iimfunda]]</text>
      <sha1>9f5aep1w5mypc1chvla5jj2tqwjxoee</sha1>
    </revision>
    <revision>
      <id>2117</id>
      <parentid>1747</parentid>
      <timestamp>2024-11-25T18:09:58Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <comment>'''</comment>
      <origin>2117</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1908" sha1="29k9bzbw03hwnagf2cqr2ymznacyoeh" xml:space="preserve">[[Isimumathi:Polokwane (Pietersburg), Limpopo, South Africa.jpg|thumb|457x457px|Idorobha iPolokwane]]
'''I-Polokwane''' lidorobha elikhulu lesiFunda se-[[Limpopo]] [[Isewula Afrika|eSewula Afrika]]. Yisikhungo samadorobha esikhulu kunazo zoke enarheni enyakatho ye-[[Gauteng]]. Bekungenye yamadorobha alithoba abamba iNdebe yePhasi ye-FIFA yango-2010. &lt;ref&gt;[https://www.encyclopedia.com/reference/encyclopedias-almanacs-transcripts-and-maps/polokwane#:~:text=Polokwane%20was%20founded%20as%20Pietersburg,by%20British%20troops%20in%201901. https://www.encyclopedia.com/reference/encyclopedias-almanacs-transcripts-and-maps/polokwane#:~:text=Polokwane%20was%20founded%20as%20Pietersburg,by%20British%20troops%20in%201901.]&lt;/ref&gt;&lt;ref&gt;https://www.southafrica.net/mw/en/travel/article/history-and-culture-in-polokwane&lt;/ref&gt;

== Umlando ==
Ngabo-1840, ama-Voortrekkers ngaphasi koburholi baka-Andries Hendrik Potgieter asungula i-[[Zoutpansbergdorp]], idorobha eliyi-100 km (62 mi) ukuya enyakatho. Indawo yokuhlala le kwafanela bona itjhiywe ngebanga lokurarana neentjhaba zendawo (ama-Lebelo, Langa &amp; Ledwaba clans), basungula idorobha elitjha ngo-1886 baliqamba ngokuthi &quot;Pietersburg&quot; ukuhlonipha umdosiphambili we-Voortrekker u-[[Petrus Jacobus Joubert]]. Inani elincani labantu be-India/Asia kanye nabantu abanemibala bahlala esifundeni ngaphambi kokuphela kwekhulu le-19. Bekuyinhlokodolobha ye-Transvaal ne-Orange Free State isikhathi esifitjhani ngo-1900 ngesikhathi sePi yesiBili yamaBhunu kusukela ngo-1899 ukuya ku-1902.[6] AmaBrithani athatha i-Pietersburg ngo-1901 begodu akha ikampa yokuhlushwa ukubopha abafazi nabantwana be-Boer abapheze babe zi-4,000.&lt;ref&gt;https://www.tandfonline.com/doi/abs/10.1080/10289852.1999.10520169&lt;/ref&gt;&lt;ref&gt;https://www.sacities.net/wp-content/uploads/2019/12/Polokwane-final-report.pdf&lt;/ref&gt;

== Iinkomba ==
&lt;references /&gt;
[[Category:ESewula Afrika]]
[[Mkhakha:Iimfunda]]</text>
      <sha1>29k9bzbw03hwnagf2cqr2ymznacyoeh</sha1>
    </revision>
    <revision>
      <id>2118</id>
      <parentid>2117</parentid>
      <timestamp>2024-11-25T18:10:43Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* Iinkomba */Mkhakha</comment>
      <origin>2118</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1905" sha1="38ro6lkk7thnysf73o5u9qy34u5ubfj" xml:space="preserve">[[Isimumathi:Polokwane (Pietersburg), Limpopo, South Africa.jpg|thumb|457x457px|Idorobha iPolokwane]]
'''I-Polokwane''' lidorobha elikhulu lesiFunda se-[[Limpopo]] [[Isewula Afrika|eSewula Afrika]]. Yisikhungo samadorobha esikhulu kunazo zoke enarheni enyakatho ye-[[Gauteng]]. Bekungenye yamadorobha alithoba abamba iNdebe yePhasi ye-FIFA yango-2010. &lt;ref&gt;[https://www.encyclopedia.com/reference/encyclopedias-almanacs-transcripts-and-maps/polokwane#:~:text=Polokwane%20was%20founded%20as%20Pietersburg,by%20British%20troops%20in%201901. https://www.encyclopedia.com/reference/encyclopedias-almanacs-transcripts-and-maps/polokwane#:~:text=Polokwane%20was%20founded%20as%20Pietersburg,by%20British%20troops%20in%201901.]&lt;/ref&gt;&lt;ref&gt;https://www.southafrica.net/mw/en/travel/article/history-and-culture-in-polokwane&lt;/ref&gt;

== Umlando ==
Ngabo-1840, ama-Voortrekkers ngaphasi koburholi baka-Andries Hendrik Potgieter asungula i-[[Zoutpansbergdorp]], idorobha eliyi-100 km (62 mi) ukuya enyakatho. Indawo yokuhlala le kwafanela bona itjhiywe ngebanga lokurarana neentjhaba zendawo (ama-Lebelo, Langa &amp; Ledwaba clans), basungula idorobha elitjha ngo-1886 baliqamba ngokuthi &quot;Pietersburg&quot; ukuhlonipha umdosiphambili we-Voortrekker u-[[Petrus Jacobus Joubert]]. Inani elincani labantu be-India/Asia kanye nabantu abanemibala bahlala esifundeni ngaphambi kokuphela kwekhulu le-19. Bekuyinhlokodolobha ye-Transvaal ne-Orange Free State isikhathi esifitjhani ngo-1900 ngesikhathi sePi yesiBili yamaBhunu kusukela ngo-1899 ukuya ku-1902.[6] AmaBrithani athatha i-Pietersburg ngo-1901 begodu akha ikampa yokuhlushwa ukubopha abafazi nabantwana be-Boer abapheze babe zi-4,000.&lt;ref&gt;https://www.tandfonline.com/doi/abs/10.1080/10289852.1999.10520169&lt;/ref&gt;&lt;ref&gt;https://www.sacities.net/wp-content/uploads/2019/12/Polokwane-final-report.pdf&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}

[[Mkhakha:ESewula Afrika]]
[[Mkhakha:Iimfunda]]</text>
      <sha1>38ro6lkk7thnysf73o5u9qy34u5ubfj</sha1>
    </revision>
    <revision>
      <id>6702</id>
      <parentid>2118</parentid>
      <timestamp>2026-06-12T08:33:25Z</timestamp>
      <contributor>
        <username>MissHadassah</username>
        <id>1561</id>
      </contributor>
      <comment>changed formatting</comment>
      <origin>6702</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1924" sha1="1sjor12dagt6qvsql3tajlimlrwq903" xml:space="preserve">[[Isimumathi:Polokwane (Pietersburg), Limpopo, South Africa.jpg|thumb|457x457px|Idorobha iPolokwane]]

== '''I-Polokwane''' lidorobha elikhulu lesiFunda se-[[Limpopo]] [[Isewula Afrika|eSewula Afrika]]. Yisikhungo samadorobha esikhulu kunazo zoke enarheni enyakatho ye-[[Gauteng]]. Bekungenye yamadorobha alithoba abamba iNdebe yePhasi ye-FIFA yango-2010. &lt;ref&gt;[https://www.encyclopedia.com/reference/encyclopedias-almanacs-transcripts-and-maps/polokwane#:~:text=Polokwane%20was%20founded%20as%20Pietersburg,by%20British%20troops%20in%201901. https://www.encyclopedia.com/reference/encyclopedias-almanacs-transcripts-and-maps/polokwane#:~:text=Polokwane%20was%20founded%20as%20Pietersburg,by%20British%20troops%20in%201901.]&lt;/ref&gt;&lt;ref&gt;https://www.southafrica.net/mw/en/travel/article/history-and-culture-in-polokwane&lt;/ref&gt; ==

== '''Umlando''' ==
Ngabo-1840, ama-Voortrekkers ngaphasi koburholi baka-Andries Hendrik Potgieter asungula i-[[Zoutpansbergdorp]], idorobha eliyi-100 km (62 mi) ukuya enyakatho. Indawo yokuhlala le kwafanela bona itjhiywe ngebanga lokurarana neentjhaba zendawo (ama-Lebelo, Langa &amp; Ledwaba clans), basungula idorobha elitjha ngo-1886 baliqamba ngokuthi &quot;Pietersburg&quot; ukuhlonipha umdosiphambili we-Voortrekker u-[[Petrus Jacobus Joubert]]. Inani elincani labantu be-India/Asia kanye nabantu abanemibala bahlala esifundeni ngaphambi kokuphela kwekhulu le-19. Bekuyinhlokodolobha ye-Transvaal ne-Orange Free State isikhathi esifitjhani ngo-1900 ngesikhathi sePi yesiBili yamaBhunu kusukela ngo-1899 ukuya ku-1902.[6] AmaBrithani athatha i-Pietersburg ngo-1901 begodu akha ikampa yokuhlushwa ukubopha abafazi nabantwana be-Boer abapheze babe zi-4,000.&lt;ref&gt;https://www.tandfonline.com/doi/abs/10.1080/10289852.1999.10520169&lt;/ref&gt;&lt;ref&gt;https://www.sacities.net/wp-content/uploads/2019/12/Polokwane-final-report.pdf&lt;/ref&gt;

== '''Iinkomba''' ==
{{Reflist}}

[[Mkhakha:ESewula Afrika]]
[[Mkhakha:Iimfunda]]</text>
      <sha1>1sjor12dagt6qvsql3tajlimlrwq903</sha1>
    </revision>
  </page>
  <page>
    <title>Malawi</title>
    <ns>0</ns>
    <id>335</id>
    <revision>
      <id>1749</id>
      <timestamp>2024-10-24T00:40:06Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>added references.</comment>
      <origin>1749</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="789" sha1="hbv78vmmgbnlyg13szqdjxllv34w424" xml:space="preserve">'''I-Malawi''' ngokusemthethweni iRiphabhliki ye-Malawi begodu ngaphambilini yaziwa ngokuthi yi-Nyasaland, yinarha enganamanzi eSewulapumalanga ye-Afrika. Inomngcele nge-Zambia ngeTjingalanga, i-Tanzania ngeTlhagwini neTlhagwini-pumalanga, ne-[[Mozambique]] ngepumalanga, ngesewula, neSewula-Tjingalanga. I-Malawi inendawo engaphezu kwe-118,484 km2 (45,747 sq mi) begodu inabantu abalinganiselwa ku-19,431,566 (kusukela ngoTjhirhweni 2021). Inhlokodolobha ye-Malawi nedorobha elikhulu kunazo zoke yi-Lilongwe. Indawo yayo yesibili ngobukhulu yi-Blantyre, eyesithathu ngobukhulu yi-Mzuzu, bese kuthi eyesine ngobukhulu yi-Zomba, eyayiyinhloko-dolobha yangaphambilini.&lt;ref&gt;https://www.siyabona.com/history-of-malawi.html&lt;/ref&gt;&lt;ref&gt;https://malawigulf.com/about-malawi/history-of-malawi/&lt;/ref&gt;</text>
      <sha1>hbv78vmmgbnlyg13szqdjxllv34w424</sha1>
    </revision>
    <revision>
      <id>1750</id>
      <parentid>1749</parentid>
      <timestamp>2024-10-24T00:40:46Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1750</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="783" sha1="ay1h6d4dypx07cr7er8ykvzxbyl8aad" xml:space="preserve">'''I-Malawi''' ngokusemthethweni iRiphabhliki ye-Malawi begodu ngaphambilini yaziwa ngokuthi yi-Nyasaland, yinarha enganamanzi eSewulapumalanga ye-Afrika. Inomngcele nge-Zambia ngeTjingalanga, i-Tanzania ngeTlhagwini neTlhagwini-pumalanga, ne-[[Mozambique]] ngepumalanga, ngesewula, neSewula-Tjingalanga. I-Malawi inendawo engaphezu kwe-118,484 km2  begodu inabantu abalinganiselwa ku-19,431,566 (kusukela ngoTjhirhweni 2021). Inhlokodolobha ye-Malawi nedorobha elikhulu kunazo zoke yi-[[Lilongwe]]. Indawo yayo yesibili ngobukhulu yi-[[Blantyre]], eyesithathu ngobukhulu yi-Mzuzu, bese kuthi eyesine ngobukhulu yi-Zomba, eyayiyinhloko-dolobha yangaphambilini.&lt;ref&gt;https://www.siyabona.com/history-of-malawi.html&lt;/ref&gt;&lt;ref&gt;https://malawigulf.com/about-malawi/history-of-malawi/&lt;/ref&gt;</text>
      <sha1>ay1h6d4dypx07cr7er8ykvzxbyl8aad</sha1>
    </revision>
    <revision>
      <id>1751</id>
      <parentid>1750</parentid>
      <timestamp>2024-10-24T00:41:18Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1751</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="799" sha1="kci5lzduk86div7oea7t9ok0j5r9t6l" xml:space="preserve">'''I-Malawi''' ngokusemthethweni iRiphabhliki ye-Malawi begodu ngaphambilini yaziwa ngokuthi yi-Nyasaland, yinarha enganamanzi eSewulapumalanga ye-Afrika. Inomngcele nge-Zambia ngeTjingalanga, i-Tanzania ngeTlhagwini neTlhagwini-pumalanga, ne-[[Mozambique]] ngepumalanga, ngesewula, neSewula-Tjingalanga. I-Malawi inendawo engaphezu kwe-118,484 km2  begodu inabantu abalinganiselwa ku-19,431,566 (kusukela ngoTjhirhweni 2021). Inhlokodolobha ye-Malawi nedorobha elikhulu kunazo zoke yi-[[Lilongwe]]. Indawo yayo yesibili ngobukhulu yi-[[Blantyre]], eyesithathu ngobukhulu yi-Mzuzu, bese kuthi eyesine ngobukhulu yi-Zomba, eyayiyinhloko-dolobha yangaphambilini.&lt;ref&gt;https://www.siyabona.com/history-of-malawi.html&lt;/ref&gt;&lt;ref&gt;https://malawigulf.com/about-malawi/history-of-malawi/&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>kci5lzduk86div7oea7t9ok0j5r9t6l</sha1>
    </revision>
    <revision>
      <id>1752</id>
      <parentid>1751</parentid>
      <timestamp>2024-10-24T00:43:17Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1752</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="834" sha1="awp8mn4iidh3pe8xhatbg0a46o783od" xml:space="preserve">'''I-Malawi''' ngokusemthethweni iRiphabhliki ye-Malawi begodu ngaphambilini yaziwa ngokuthi yi-Nyasaland, yinarha enganamanzi eSewulapumalanga ye-Afrika. Inomngcele nge-Zambia ngeTjingalanga, i-Tanzania ngeTlhagwini neTlhagwini-pumalanga, ne-[[Mozambique]] ngepumalanga, ngesewula, neSewula-Tjingalanga. I-Malawi inendawo engaphezu kwe-118,484 km2  begodu inabantu abalinganiselwa ku-19,431,566 (kusukela ngoTjhirhweni 2021). Inhlokodolobha ye-Malawi nedorobha elikhulu kunazo zoke yi-[[Lilongwe]]. Indawo yayo yesibili ngobukhulu yi-[[Blantyre]], eyesithathu ngobukhulu yi-Mzuzu, bese kuthi eyesine ngobukhulu yi-Zomba, eyayiyinhloko-dolobha yangaphambilini.&lt;ref&gt;https://www.siyabona.com/history-of-malawi.html&lt;/ref&gt;&lt;ref&gt;https://malawigulf.com/about-malawi/history-of-malawi/&lt;/ref&gt;

== Iinkomba ==
&lt;references /&gt;
[[Category:Amazwe]]</text>
      <sha1>awp8mn4iidh3pe8xhatbg0a46o783od</sha1>
    </revision>
    <revision>
      <id>2133</id>
      <parentid>1752</parentid>
      <timestamp>2024-11-25T18:27:37Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* Iinkomba */Reflist</comment>
      <origin>2133</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="832" sha1="ez329sryx9sz76wxizslk3mslgfno19" xml:space="preserve">'''I-Malawi''' ngokusemthethweni iRiphabhliki ye-Malawi begodu ngaphambilini yaziwa ngokuthi yi-Nyasaland, yinarha enganamanzi eSewulapumalanga ye-Afrika. Inomngcele nge-Zambia ngeTjingalanga, i-Tanzania ngeTlhagwini neTlhagwini-pumalanga, ne-[[Mozambique]] ngepumalanga, ngesewula, neSewula-Tjingalanga. I-Malawi inendawo engaphezu kwe-118,484 km2  begodu inabantu abalinganiselwa ku-19,431,566 (kusukela ngoTjhirhweni 2021). Inhlokodolobha ye-Malawi nedorobha elikhulu kunazo zoke yi-[[Lilongwe]]. Indawo yayo yesibili ngobukhulu yi-[[Blantyre]], eyesithathu ngobukhulu yi-Mzuzu, bese kuthi eyesine ngobukhulu yi-Zomba, eyayiyinhloko-dolobha yangaphambilini.&lt;ref&gt;https://www.siyabona.com/history-of-malawi.html&lt;/ref&gt;&lt;ref&gt;https://malawigulf.com/about-malawi/history-of-malawi/&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}

[[Category:Amazwe]]</text>
      <sha1>ez329sryx9sz76wxizslk3mslgfno19</sha1>
    </revision>
    <revision>
      <id>2142</id>
      <parentid>2133</parentid>
      <timestamp>2024-11-25T18:29:50Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>Mkhakha</comment>
      <origin>2142</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="831" sha1="ifk32g8hmrue0nja2a9s590tni7zfpo" xml:space="preserve">'''I-Malawi''' ngokusemthethweni iRiphabhliki ye-Malawi begodu ngaphambilini yaziwa ngokuthi yi-Nyasaland, yinarha enganamanzi eSewulapumalanga ye-Afrika. Inomngcele nge-Zambia ngeTjingalanga, i-Tanzania ngeTlhagwini neTlhagwini-pumalanga, ne-[[Mozambique]] ngepumalanga, ngesewula, neSewula-Tjingalanga. I-Malawi inendawo engaphezu kwe-118,484 km2  begodu inabantu abalinganiselwa ku-19,431,566 (kusukela ngoTjhirhweni 2021). Inhlokodolobha ye-Malawi nedorobha elikhulu kunazo zoke yi-[[Lilongwe]]. Indawo yayo yesibili ngobukhulu yi-[[Blantyre]], eyesithathu ngobukhulu yi-Mzuzu, bese kuthi eyesine ngobukhulu yi-Zomba, eyayiyinhloko-dolobha yangaphambilini.&lt;ref&gt;https://www.siyabona.com/history-of-malawi.html&lt;/ref&gt;&lt;ref&gt;https://malawigulf.com/about-malawi/history-of-malawi/&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}

[[Mkhakha:Amazwe]]</text>
      <sha1>ifk32g8hmrue0nja2a9s590tni7zfpo</sha1>
    </revision>
    <revision>
      <id>5906</id>
      <parentid>2142</parentid>
      <timestamp>2025-10-06T21:51:07Z</timestamp>
      <contributor>
        <username>Martin Macha 2111</username>
        <id>568</id>
      </contributor>
      <origin>5906</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="817" sha1="24z8uhwekp8f6h323p3bvdvtd4yez2j" xml:space="preserve">'''I-Malawi''' ngokusemthethweni iRiphabhliki ye-Malawi begodu ngaphambilini yaziwa ngokuthi yi-Nyasaland, yinarha enganamanzi eSewulapumalanga ye-Afrika. Inomngcele nge-Zambia ngeTjingalanga, i-Tanzania ngeTlhagwini neTlhagwini-pumalanga, ne-[[Mozambique]] ngepumalanga, ngesewula, neSewula-Tjingalanga. I-Malawi inendawo engaphezu kwe-118,484 km2  begodu inabantu abalinganiselwa ku-22,224,282 (kusukela 2025). Inhlokodolobha ye-Malawi nedorobha elikhulu kunazo zoke yi-[[Lilongwe]]. Indawo yayo yesibili ngobukhulu yi-[[Blantyre]], eyesithathu ngobukhulu yi-Mzuzu, bese kuthi eyesine ngobukhulu yi-Zomba, eyayiyinhloko-dolobha yangaphambilini.&lt;ref&gt;https://www.siyabona.com/history-of-malawi.html&lt;/ref&gt;&lt;ref&gt;https://malawigulf.com/about-malawi/history-of-malawi/&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}

[[Mkhakha:Amazwe]]</text>
      <sha1>24z8uhwekp8f6h323p3bvdvtd4yez2j</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Amazwe</title>
    <ns>14</ns>
    <id>336</id>
    <revision>
      <id>1753</id>
      <timestamp>2024-10-24T00:43:29Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created blank page</comment>
      <origin>1753</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
  </page>
  <page>
    <title>IWitkoppen Clinic</title>
    <ns>0</ns>
    <id>338</id>
    <revision>
      <id>1766</id>
      <timestamp>2024-10-30T08:04:40Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created page with &quot;I-Witkoppen Health and Welfare Centre, evamise ukubizwa ngokuthi yi-Witkoppen Clinic, sisikhungo sokutlhogonyelwa kwepilo somphakathi esingenzi inzuzo esitholakala e-Fourways, e-Johannesburg, eSewula Afrika. Umtholampilo lo wathoma ngo-1946 begodu unikela ngeenkonzo ezinengi zokunakekelwa kwepilo emiphakathini eseduze ne-Sandton ne-Diepsloot.&lt;ref&gt;https://www.citizen.co.za/fourways-review/news-headlines/local-news/2024/05/19/grateful-mom-names-daughter-after-clinic-2/&lt;/re...&quot;</comment>
      <origin>1766</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="773" sha1="foncsyf11qfqaji8pql3dzev8rvba2r" xml:space="preserve">I-Witkoppen Health and Welfare Centre, evamise ukubizwa ngokuthi yi-Witkoppen Clinic, sisikhungo sokutlhogonyelwa kwepilo somphakathi esingenzi inzuzo esitholakala e-Fourways, e-Johannesburg, eSewula Afrika. Umtholampilo lo wathoma ngo-1946 begodu unikela ngeenkonzo ezinengi zokunakekelwa kwepilo emiphakathini eseduze ne-Sandton ne-Diepsloot.&lt;ref&gt;https://www.citizen.co.za/fourways-review/news-headlines/local-news/2024/05/19/grateful-mom-names-daughter-after-clinic-2/&lt;/ref&gt;&lt;ref&gt;https://www.sowetanlive.co.za/news/south-africa/2019-11-29-the-rights-of-women-have-always-been-overlooked-how-power-dynamics-fuel-the-spread-of-hiv/&lt;/ref&gt;&lt;ref&gt;https://www.citizen.co.za/randburg-sun/news-headlines/local-news/2022/12/02/mobile-clinic-launched-in-fourways/&lt;/ref&gt;

==Iinkomba==</text>
      <sha1>foncsyf11qfqaji8pql3dzev8rvba2r</sha1>
    </revision>
    <revision>
      <id>1767</id>
      <parentid>1766</parentid>
      <timestamp>2024-10-30T08:05:48Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1767</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="781" sha1="5e3pugnr3lrrjxifbsyoejxf1k4ruh6" xml:space="preserve">I-Witkoppen Health and Welfare Centre, evamise ukubizwa ngokuthi yi-Witkoppen Clinic, sisikhungo sokutlhogonyelwa kwepilo somphakathi esingenzi inzuzo esitholakala e-[[Fourways]], e-[[Johannesburg]], eSewula Afrika. Umtholampilo lo wathoma ngo-1946 begodu unikela ngeenkonzo ezinengi zokunakekelwa kwepilo emiphakathini eseduze ne-Sandton ne-Diepsloot.&lt;ref&gt;https://www.citizen.co.za/fourways-review/news-headlines/local-news/2024/05/19/grateful-mom-names-daughter-after-clinic-2/&lt;/ref&gt;&lt;ref&gt;https://www.sowetanlive.co.za/news/south-africa/2019-11-29-the-rights-of-women-have-always-been-overlooked-how-power-dynamics-fuel-the-spread-of-hiv/&lt;/ref&gt;&lt;ref&gt;https://www.citizen.co.za/randburg-sun/news-headlines/local-news/2022/12/02/mobile-clinic-launched-in-fourways/&lt;/ref&gt;

==Iinkomba==</text>
      <sha1>5e3pugnr3lrrjxifbsyoejxf1k4ruh6</sha1>
    </revision>
    <revision>
      <id>1768</id>
      <parentid>1767</parentid>
      <timestamp>2024-10-30T08:07:32Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1768</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="800" sha1="gny6xcus1unno2g4eklm1a6ldcvr1kz" xml:space="preserve">I-Witkoppen Health and Welfare Centre, evamise ukubizwa ngokuthi yi-Witkoppen Clinic, sisikhungo sokutlhogonyelwa kwepilo somphakathi esingenzi inzuzo esitholakala e-[[Fourways]], e-[[Johannesburg]], e[[Isewula Afrika|Sewula Afrika]]. Umtholampilo lo wathoma ngo-1946 begodu unikela ngeenkonzo ezinengi zokunakekelwa kwepilo emiphakathini eseduze ne-Sandton ne-Diepsloot.&lt;ref&gt;https://www.citizen.co.za/fourways-review/news-headlines/local-news/2024/05/19/grateful-mom-names-daughter-after-clinic-2/&lt;/ref&gt;&lt;ref&gt;https://www.sowetanlive.co.za/news/south-africa/2019-11-29-the-rights-of-women-have-always-been-overlooked-how-power-dynamics-fuel-the-spread-of-hiv/&lt;/ref&gt;&lt;ref&gt;https://www.citizen.co.za/randburg-sun/news-headlines/local-news/2022/12/02/mobile-clinic-launched-in-fourways/&lt;/ref&gt;

==Iinkomba==</text>
      <sha1>gny6xcus1unno2g4eklm1a6ldcvr1kz</sha1>
    </revision>
    <revision>
      <id>1769</id>
      <parentid>1768</parentid>
      <timestamp>2024-10-30T08:08:10Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1769</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="828" sha1="s0vu5ofsox8ddlfyjokz2mdbotznvpx" xml:space="preserve">I-Witkoppen Health and Welfare Centre, evamise ukubizwa ngokuthi yi-Witkoppen Clinic, sisikhungo sokutlhogonyelwa kwepilo somphakathi esingenzi inzuzo esitholakala e-[[Fourways]], e-[[Johannesburg]], e[[Isewula Afrika|Sewula Afrika]]. Umtholampilo lo wathoma ngo-1946 begodu unikela ngeenkonzo ezinengi zokunakekelwa kwepilo emiphakathini eseduze ne-Sandton ne-Diepsloot.&lt;ref&gt;https://www.citizen.co.za/fourways-review/news-headlines/local-news/2024/05/19/grateful-mom-names-daughter-after-clinic-2/&lt;/ref&gt;&lt;ref&gt;https://www.sowetanlive.co.za/news/south-africa/2019-11-29-the-rights-of-women-have-always-been-overlooked-how-power-dynamics-fuel-the-spread-of-hiv/&lt;/ref&gt;&lt;ref&gt;https://www.citizen.co.za/randburg-sun/news-headlines/local-news/2022/12/02/mobile-clinic-launched-in-fourways/&lt;/ref&gt;

==Iinkomba==
[[Category:iSewula Afrika]]</text>
      <sha1>s0vu5ofsox8ddlfyjokz2mdbotznvpx</sha1>
    </revision>
    <revision>
      <id>2104</id>
      <parentid>1769</parentid>
      <timestamp>2024-11-25T09:49:04Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <comment>Mkhakha</comment>
      <origin>2104</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="828" sha1="3ya31eqrccdrozov0nv77pn7d8andi8" xml:space="preserve">I-Witkoppen Health and Welfare Centre, evamise ukubizwa ngokuthi yi-Witkoppen Clinic, sisikhungo sokutlhogonyelwa kwepilo somphakathi esingenzi inzuzo esitholakala e-[[Fourways]], e-[[Johannesburg]], e[[Isewula Afrika|Sewula Afrika]]. Umtholampilo lo wathoma ngo-1946 begodu unikela ngeenkonzo ezinengi zokunakekelwa kwepilo emiphakathini eseduze ne-Sandton ne-Diepsloot.&lt;ref&gt;https://www.citizen.co.za/fourways-review/news-headlines/local-news/2024/05/19/grateful-mom-names-daughter-after-clinic-2/&lt;/ref&gt;&lt;ref&gt;https://www.sowetanlive.co.za/news/south-africa/2019-11-29-the-rights-of-women-have-always-been-overlooked-how-power-dynamics-fuel-the-spread-of-hiv/&lt;/ref&gt;&lt;ref&gt;https://www.citizen.co.za/randburg-sun/news-headlines/local-news/2022/12/02/mobile-clinic-launched-in-fourways/&lt;/ref&gt;

==Iinkomba==

[[Mkhakha:iSewula Afrika]]</text>
      <sha1>3ya31eqrccdrozov0nv77pn7d8andi8</sha1>
    </revision>
    <revision>
      <id>2105</id>
      <parentid>2104</parentid>
      <timestamp>2024-11-25T09:49:48Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* Iinkomba */</comment>
      <origin>2105</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="842" sha1="6irz9y93o8dj5tzmxkaq9w3o5qq3qh3" xml:space="preserve">I-Witkoppen Health and Welfare Centre, evamise ukubizwa ngokuthi yi-Witkoppen Clinic, sisikhungo sokutlhogonyelwa kwepilo somphakathi esingenzi inzuzo esitholakala e-[[Fourways]], e-[[Johannesburg]], e[[Isewula Afrika|Sewula Afrika]]. Umtholampilo lo wathoma ngo-1946 begodu unikela ngeenkonzo ezinengi zokunakekelwa kwepilo emiphakathini eseduze ne-Sandton ne-Diepsloot.&lt;ref&gt;https://www.citizen.co.za/fourways-review/news-headlines/local-news/2024/05/19/grateful-mom-names-daughter-after-clinic-2/&lt;/ref&gt;&lt;ref&gt;https://www.sowetanlive.co.za/news/south-africa/2019-11-29-the-rights-of-women-have-always-been-overlooked-how-power-dynamics-fuel-the-spread-of-hiv/&lt;/ref&gt;&lt;ref&gt;https://www.citizen.co.za/randburg-sun/news-headlines/local-news/2022/12/02/mobile-clinic-launched-in-fourways/&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}

[[Mkhakha:iSewula Afrika]]</text>
      <sha1>6irz9y93o8dj5tzmxkaq9w3o5qq3qh3</sha1>
    </revision>
    <revision>
      <id>2151</id>
      <parentid>2105</parentid>
      <timestamp>2024-11-25T18:47:16Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <comment>'''</comment>
      <origin>2151</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="848" sha1="ci7e763uiw0s2ncer8acsvjl3wofuqb" xml:space="preserve">'''I-Witkoppen Health and Welfare Centre''', evamise ukubizwa ngokuthi yi-Witkoppen Clinic, sisikhungo sokutlhogonyelwa kwepilo somphakathi esingenzi inzuzo esitholakala e-[[Fourways]], e-[[Johannesburg]], e[[Isewula Afrika|Sewula Afrika]]. Umtholampilo lo wathoma ngo-1946 begodu unikela ngeenkonzo ezinengi zokunakekelwa kwepilo emiphakathini eseduze ne-Sandton ne-Diepsloot.&lt;ref&gt;https://www.citizen.co.za/fourways-review/news-headlines/local-news/2024/05/19/grateful-mom-names-daughter-after-clinic-2/&lt;/ref&gt;&lt;ref&gt;https://www.sowetanlive.co.za/news/south-africa/2019-11-29-the-rights-of-women-have-always-been-overlooked-how-power-dynamics-fuel-the-spread-of-hiv/&lt;/ref&gt;&lt;ref&gt;https://www.citizen.co.za/randburg-sun/news-headlines/local-news/2022/12/02/mobile-clinic-launched-in-fourways/&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}

[[Mkhakha:iSewula Afrika]]</text>
      <sha1>ci7e763uiw0s2ncer8acsvjl3wofuqb</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:ISewula Afrika</title>
    <ns>14</ns>
    <id>339</id>
    <revision>
      <id>1770</id>
      <timestamp>2024-10-30T08:08:24Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created blank page</comment>
      <origin>1770</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
  </page>
  <page>
    <title>U-Nyabela</title>
    <ns>0</ns>
    <id>340</id>
    <revision>
      <id>1773</id>
      <timestamp>2024-10-30T21:32:23Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created page with &quot;U-Nyabêla (1825/30 - 1902) bekayinduna yama-Ndzundza esizwe samaNdebele ngesikhathi sekhulu leminyaka elitjhumi nathoba. Ukhunjulwa ngomzabalazo wakhe wokulwisana nabamhlophe ukulawula indawo yesitjhaba sakhe.&quot;</comment>
      <origin>1773</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="210" sha1="fda03x7ofpqo9v6w0qw00wugwbw8ymn" xml:space="preserve">U-Nyabêla (1825/30 - 1902) bekayinduna yama-Ndzundza esizwe samaNdebele ngesikhathi sekhulu leminyaka elitjhumi nathoba. Ukhunjulwa ngomzabalazo wakhe wokulwisana nabamhlophe ukulawula indawo yesitjhaba sakhe.</text>
      <sha1>fda03x7ofpqo9v6w0qw00wugwbw8ymn</sha1>
    </revision>
    <revision>
      <id>1774</id>
      <parentid>1773</parentid>
      <timestamp>2024-10-30T21:34:28Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1774</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="353" sha1="m9hxvy097sg0tg0fwx1k3a3ooh8dndn" xml:space="preserve">U-Nyabêla (1825/30 - 1902) bekayinduna yama-Ndzundza esizwe samaNdebele ngesikhathi sekhulu leminyaka elitjhumi nathoba. Ukhunjulwa ngomzabalazo wakhe wokulwisana nabamhlophe ukulawula indawo yesitjhaba sakhe.&lt;ref&gt;https://journals.co.za/doi/pdf/10.10520/AJA02580144_350&lt;/ref&gt;&lt;ref&gt;https://www.tandfonline.com/doi/abs/10.1080/02572117.1997.10587170&lt;/ref&gt;</text>
      <sha1>m9hxvy097sg0tg0fwx1k3a3ooh8dndn</sha1>
    </revision>
    <revision>
      <id>1775</id>
      <parentid>1774</parentid>
      <timestamp>2024-10-30T21:34:53Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1775</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="375" sha1="o71ga3lde4u39qdkp0uhoofyg6zqbcr" xml:space="preserve">'''U-Nyabêla''' (1825/30 - 1902) bekayinduna yama-Ndzundza esizwe samaNdebele ngesikhathi sekhulu leminyaka elitjhumi nathoba. Ukhunjulwa ngomzabalazo wakhe wokulwisana nabamhlophe ukulawula indawo yesitjhaba sakhe.&lt;ref&gt;https://journals.co.za/doi/pdf/10.10520/AJA02580144_350&lt;/ref&gt;&lt;ref&gt;https://www.tandfonline.com/doi/abs/10.1080/02572117.1997.10587170&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>o71ga3lde4u39qdkp0uhoofyg6zqbcr</sha1>
    </revision>
    <revision>
      <id>1776</id>
      <parentid>1775</parentid>
      <timestamp>2024-10-30T21:35:47Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1776</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="428" sha1="sxe1ggi64js6dwhfnuddn24h6git0iu" xml:space="preserve">'''U-Nyabêla''' (1825/30 - 1902) bekayinduna yama-Ndzundza esizwe samaNdebele ngesikhathi sekhulu leminyaka elitjhumi nathoba. Ukhunjulwa ngomzabalazo wakhe wokulwisana nabamhlophe ukulawula indawo yesitjhaba sakhe.&lt;ref&gt;https://journals.co.za/doi/pdf/10.10520/AJA02580144_350&lt;/ref&gt;&lt;ref&gt;https://www.tandfonline.com/doi/abs/10.1080/02572117.1997.10587170&lt;/ref&gt;

== Iinkomba ==

[[Category:iSewula Afrika]]
[[Category:Amandebele]]</text>
      <sha1>sxe1ggi64js6dwhfnuddn24h6git0iu</sha1>
    </revision>
    <revision>
      <id>1777</id>
      <parentid>1776</parentid>
      <timestamp>2024-10-30T21:36:10Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1777</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="428" sha1="2xwgr4gdz6cfxm98i2ltioctcfovyti" xml:space="preserve">'''U-Nyabêla''' (1825/30 - 1902) bekayinduna yama-Ndzundza esizwe samaNdebele ngesikhathi sekhulu leminyaka elitjhumi nathoba. Ukhunjulwa ngomzabalazo wakhe wokulwisana nabamhlophe ukulawula indawo yesitjhaba sakhe.&lt;ref&gt;https://journals.co.za/doi/pdf/10.10520/AJA02580144_350&lt;/ref&gt;&lt;ref&gt;https://www.tandfonline.com/doi/abs/10.1080/02572117.1997.10587170&lt;/ref&gt;

== Iinkomba ==

[[Category:iSewula Afrika]]
[[Category:AmaNdebele]]</text>
      <sha1>2xwgr4gdz6cfxm98i2ltioctcfovyti</sha1>
    </revision>
    <revision>
      <id>1779</id>
      <parentid>1777</parentid>
      <timestamp>2024-10-30T21:37:11Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1779</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="443" sha1="n7fw8xkll487bykv0lgobjbvrx7vbbj" xml:space="preserve">'''U-Nyabêla''' (1825/30 - 1902) bekayinduna yama-Ndzundza esizwe [[AmaNdebele|samaNdebele]] ngesikhathi sekhulu leminyaka elitjhumi nathoba. Ukhunjulwa ngomzabalazo wakhe wokulwisana nabamhlophe ukulawula indawo yesitjhaba sakhe.&lt;ref&gt;https://journals.co.za/doi/pdf/10.10520/AJA02580144_350&lt;/ref&gt;&lt;ref&gt;https://www.tandfonline.com/doi/abs/10.1080/02572117.1997.10587170&lt;/ref&gt;

== Iinkomba ==

[[Category:iSewula Afrika]]
[[Category:AmaNdebele]]</text>
      <sha1>n7fw8xkll487bykv0lgobjbvrx7vbbj</sha1>
    </revision>
    <revision>
      <id>2111</id>
      <parentid>1779</parentid>
      <timestamp>2024-11-25T09:53:26Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <comment>Mkhakha</comment>
      <origin>2111</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="441" sha1="gmiwhpzwsz041di9y7dnvlckv03s8hh" xml:space="preserve">'''U-Nyabêla''' (1825/30 - 1902) bekayinduna yama-Ndzundza esizwe [[AmaNdebele|samaNdebele]] ngesikhathi sekhulu leminyaka elitjhumi nathoba. Ukhunjulwa ngomzabalazo wakhe wokulwisana nabamhlophe ukulawula indawo yesitjhaba sakhe.&lt;ref&gt;https://journals.co.za/doi/pdf/10.10520/AJA02580144_350&lt;/ref&gt;&lt;ref&gt;https://www.tandfonline.com/doi/abs/10.1080/02572117.1997.10587170&lt;/ref&gt;

== Iinkomba ==

[[Mkhakha:iSewula Afrika]]
[[Mkhakha:AmaNdebele]]</text>
      <sha1>gmiwhpzwsz041di9y7dnvlckv03s8hh</sha1>
    </revision>
    <revision>
      <id>2112</id>
      <parentid>2111</parentid>
      <timestamp>2024-11-25T09:53:39Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* Iinkomba */</comment>
      <origin>2112</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="453" sha1="ffpwc7t63bk9ndkm8ind42i8swtkbbe" xml:space="preserve">'''U-Nyabêla''' (1825/30 - 1902) bekayinduna yama-Ndzundza esizwe [[AmaNdebele|samaNdebele]] ngesikhathi sekhulu leminyaka elitjhumi nathoba. Ukhunjulwa ngomzabalazo wakhe wokulwisana nabamhlophe ukulawula indawo yesitjhaba sakhe.&lt;ref&gt;https://journals.co.za/doi/pdf/10.10520/AJA02580144_350&lt;/ref&gt;&lt;ref&gt;https://www.tandfonline.com/doi/abs/10.1080/02572117.1997.10587170&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}

[[Mkhakha:iSewula Afrika]]
[[Mkhakha:AmaNdebele]]</text>
      <sha1>ffpwc7t63bk9ndkm8ind42i8swtkbbe</sha1>
    </revision>
    <revision>
      <id>3011</id>
      <parentid>2112</parentid>
      <timestamp>2025-06-06T20:25:07Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>hndrhnd</comment>
      <origin>3011</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="534" sha1="80f9t8cfuukl7yv4hbxdky161eujo5p" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. U-Nyabêla''' (1825/30 - 1902) bekayinduna yama-Ndzundza esizwe [[AmaNdebele|samaNdebele]] ngesikhathi sekhulu leminyaka elitjhumi nathoba. Ukhunjulwa ngomzabalazo wakhe wokulwisana nabamhlophe ukulawula indawo yesitjhaba sakhe.&lt;ref&gt;https://journals.co.za/doi/pdf/10.10520/AJA02580144_350&lt;/ref&gt;&lt;ref&gt;https://www.tandfonline.com/doi/abs/10.1080/02572117.1997.10587170&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}

[[Mkhakha:iSewula Afrika]]
[[Mkhakha:AmaNdebele]]</text>
      <sha1>80f9t8cfuukl7yv4hbxdky161eujo5p</sha1>
    </revision>
    <revision>
      <id>3052</id>
      <parentid>3011</parentid>
      <timestamp>2025-06-07T03:05:22Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Simakahle Moselekatse|Simakahle Moselekatse]]</comment>
      <origin>2112</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="453" sha1="ffpwc7t63bk9ndkm8ind42i8swtkbbe" xml:space="preserve">'''U-Nyabêla''' (1825/30 - 1902) bekayinduna yama-Ndzundza esizwe [[AmaNdebele|samaNdebele]] ngesikhathi sekhulu leminyaka elitjhumi nathoba. Ukhunjulwa ngomzabalazo wakhe wokulwisana nabamhlophe ukulawula indawo yesitjhaba sakhe.&lt;ref&gt;https://journals.co.za/doi/pdf/10.10520/AJA02580144_350&lt;/ref&gt;&lt;ref&gt;https://www.tandfonline.com/doi/abs/10.1080/02572117.1997.10587170&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}

[[Mkhakha:iSewula Afrika]]
[[Mkhakha:AmaNdebele]]</text>
      <sha1>ffpwc7t63bk9ndkm8ind42i8swtkbbe</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:AmaNdebele</title>
    <ns>14</ns>
    <id>341</id>
    <revision>
      <id>1778</id>
      <timestamp>2024-10-30T21:36:21Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created blank page</comment>
      <origin>1778</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
    <revision>
      <id>6697</id>
      <parentid>1778</parentid>
      <timestamp>2026-06-12T08:12:09Z</timestamp>
      <contributor>
        <username>MissHadassah</username>
        <id>1561</id>
      </contributor>
      <comment>added an external  reference</comment>
      <origin>6697</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="155" sha1="ebdu7l56kdsk6qfy0kp3htvexauk7wk" xml:space="preserve">&lt;ref&gt;[https://thinkafrica.net/ndebele-south-africa/ The Ndebele People: their origins, social structure, architecture and beliefs - Let Africa Speak]&lt;/ref&gt;</text>
      <sha1>ebdu7l56kdsk6qfy0kp3htvexauk7wk</sha1>
    </revision>
  </page>
  <page>
    <title>Sekhukhune</title>
    <ns>0</ns>
    <id>342</id>
    <revision>
      <id>1780</id>
      <timestamp>2024-10-30T21:42:14Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created page with &quot;U-Sekhukhune I (Matsebe 1814 – 13 Agasti 1882) bekayiKosi ephambili yama-Marota, eyaziwa khulu nge-Bapedi (abantu be-Pedi), kusukela mhlazi-21 kuNobayeni 1861 bekwaba kulapho abulawa khona mhlazi-13 kuRhoboyi 1882 mhlana ali-13 kuRhoboyi wee-1882 imbangi nomfowabo, uMampuru II.[1] Njengomrholi omkhulu we-Pedi waqalana neentjhijilo zepolotiki ezivela kuma-Voortrekkers (abahlali be-Boer), iRiphabhliki yeSewula Afrika ezijameleko (i-Dutch: Zuid-Afrikaansche Republiek), i-...&quot;</comment>
      <origin>1780</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1454" sha1="tbzsbweti5peh0x1h0l6tg72mly47n4" xml:space="preserve">U-Sekhukhune I (Matsebe 1814 – 13 Agasti 1882) bekayiKosi ephambili yama-Marota, eyaziwa khulu nge-Bapedi (abantu be-Pedi), kusukela mhlazi-21 kuNobayeni 1861 bekwaba kulapho abulawa khona mhlazi-13 kuRhoboyi 1882 mhlana ali-13 kuRhoboyi wee-1882 imbangi nomfowabo, uMampuru II.[1] Njengomrholi omkhulu we-Pedi waqalana neentjhijilo zepolotiki ezivela kuma-Voortrekkers (abahlali be-Boer), iRiphabhliki yeSewula Afrika ezijameleko (i-Dutch: Zuid-Afrikaansche Republiek), i-Britain Empire, kanye nokutjhuguluka okukhulu kwezenhlalakahle okwabangelwa ziinthunywa zevangeli zamaKrestu.

=== Umlando ===
Ngemva kokuhlongakala kwakayise, iKosi u-Sekwati, mhlazi-20 kuNobayeni 1861, u-Sekhukhune wavikela ngepumelelo ilungelo lakhe lobukhosi ngokujamelana nomfowabo u-Mampuru II nendlalifa ngokusekelwa libutho lakhe le-Matuba. Nanyana aphumelele, u-Sekhukhune wabambelela esikweni le-serota begodu wavumela u-Mampuru bona atjhiye indawo ye-Bapedi ngokuthula. Abanye abantwabakhe abaziwako bekungu; U-Legolwana,[2] u-Johannes Dinkwanyane, no-Kgoloko.[3] U-Sekhukhune watjhada no-Legoadi IV ngo-1862, begodu wahlala entabeni, eyaziwa njenge-Thaba Leolo nofana i-Leolo Mountains,[4] eyaqinisa. Ukuqinisa umbuso wakhe nokuvikela ukubusa kwama-Europe, wenza bona abantu bakhe abasesebatjha basebenze emayini yabantu abamhlophe nasemaplasini ukwenzela bona imirholo yabo isetjenziselwe ukuthenga iinbhamu kumaPutukezi e-Delagoa Bay, kanye nemfuyo.

== Iinkomba ==</text>
      <sha1>tbzsbweti5peh0x1h0l6tg72mly47n4</sha1>
    </revision>
    <revision>
      <id>1781</id>
      <parentid>1780</parentid>
      <timestamp>2024-10-30T21:43:55Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1781</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1714" sha1="hj2gdd6t5hgs3cne4p46obdhra7z801" xml:space="preserve">U-Sekhukhune I (Matsebe 1814 – 13 Agasti 1882) bekayiKosi ephambili yama-Marota, eyaziwa khulu nge-Bapedi (abantu be-Pedi), kusukela mhlazi-21 kuNobayeni 1861 bekwaba kulapho abulawa khona mhlazi-13 kuRhoboyi 1882 mhlana ali-13 kuRhoboyi wee-1882 imbangi nomfowabo, uMampuru II.[1] Njengomrholi omkhulu we-Pedi waqalana neentjhijilo zepolotiki ezivela kuma-Voortrekkers (abahlali be-Boer), iRiphabhliki yeSewula Afrika ezijameleko (i-Dutch: Zuid-Afrikaansche Republiek), i-Britain Empire, kanye nokutjhuguluka okukhulu kwezenhlalakahle okwabangelwa ziinthunywa zevangeli zamaKrestu.&lt;ref&gt;https://pdfs.semanticscholar.org/c598/201acbece95eb4a4ff56e44e4640e18f5bbb.pdf&lt;/ref&gt;

=== Umlando ===
Ngemva kokuhlongakala kwakayise, iKosi u-Sekwati, mhlazi-20 kuNobayeni 1861, u-Sekhukhune wavikela ngepumelelo ilungelo lakhe lobukhosi ngokujamelana nomfowabo u-Mampuru II nendlalifa ngokusekelwa libutho lakhe le-Matuba. Nanyana aphumelele, u-Sekhukhune wabambelela esikweni le-serota begodu wavumela u-Mampuru bona atjhiye indawo ye-Bapedi ngokuthula. Abanye abantwabakhe abaziwako bekungu; U-Legolwana,[2] u-Johannes Dinkwanyane, no-Kgoloko.[3] U-Sekhukhune watjhada no-Legoadi IV ngo-1862, begodu wahlala entabeni, eyaziwa njenge-Thaba Leolo nofana i-Leolo Mountains,[4] eyaqinisa. Ukuqinisa umbuso wakhe nokuvikela ukubusa kwama-Europe, wenza bona abantu bakhe abasesebatjha basebenze emayini yabantu abamhlophe nasemaplasini ukwenzela bona imirholo yabo isetjenziselwe ukuthenga iinbhamu kumaPutukezi e-Delagoa Bay, kanye nemfuyo.&lt;ref&gt;https://www.cambridge.org/core/journals/journal-of-african-history/article/abs/fall-of-the-bapedi-of-the-northeastern-transvaal/9D232859E9367AB55DB38624F6B3818A&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>hj2gdd6t5hgs3cne4p46obdhra7z801</sha1>
    </revision>
    <revision>
      <id>1782</id>
      <parentid>1781</parentid>
      <timestamp>2024-10-30T21:46:37Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1782</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1766" sha1="az5hnjxuloja6xbxhyaqeuy44an6u36" xml:space="preserve">U-Sekhukhune I (Matsebe 1814 – 13 Agasti 1882) bekayiKosi ephambili yama-Marota, eyaziwa khulu nge-Bapedi (abantu be-Pedi), kusukela mhlazi-21 kuNobayeni 1861 bekwaba kulapho abulawa khona mhlazi-13 kuRhoboyi 1882 mhlana ali-13 kuRhoboyi wee-1882 imbangi nomfowabo, uMampuru II.[1] Njengomrholi omkhulu we-Pedi waqalana neentjhijilo zepolotiki ezivela kuma-Voortrekkers (abahlali be-Boer), iRiphabhliki yeSewula Afrika ezijameleko (i-Dutch: Zuid-Afrikaansche Republiek), i-Britain Empire, kanye nokutjhuguluka okukhulu kwezenhlalakahle okwabangelwa ziinthunywa zevangeli zamaKrestu.&lt;ref&gt;https://pdfs.semanticscholar.org/c598/201acbece95eb4a4ff56e44e4640e18f5bbb.pdf&lt;/ref&gt;[[iWikiphedia wase uyashald when is the 2nd date?]] 

=== Umlando ===
Ngemva kokuhlongakala kwakayise, iKosi u-Sekwati, mhlazi-20 kuNobayeni 1861, u-Sekhukhune wavikela ngepumelelo ilungelo lakhe lobukhosi ngokujamelana nomfowabo u-Mampuru II nendlalifa ngokusekelwa libutho lakhe le-Matuba. Nanyana aphumelele, u-Sekhukhune wabambelela esikweni le-serota begodu wavumela u-Mampuru bona atjhiye indawo ye-Bapedi ngokuthula. Abanye abantwabakhe abaziwako bekungu; U-Legolwana,[2] u-Johannes Dinkwanyane, no-Kgoloko.[3] U-Sekhukhune watjhada no-Legoadi IV ngo-1862, begodu wahlala entabeni, eyaziwa njenge-Thaba Leolo nofana i-Leolo Mountains,[4] eyaqinisa. Ukuqinisa umbuso wakhe nokuvikela ukubusa kwama-Europe, wenza bona abantu bakhe abasesebatjha basebenze emayini yabantu abamhlophe nasemaplasini ukwenzela bona imirholo yabo isetjenziselwe ukuthenga iinbhamu kumaPutukezi e-Delagoa Bay, kanye nemfuyo.&lt;ref&gt;https://www.cambridge.org/core/journals/journal-of-african-history/article/abs/fall-of-the-bapedi-of-the-northeastern-transvaal/9D232859E9367AB55DB38624F6B3818A&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>az5hnjxuloja6xbxhyaqeuy44an6u36</sha1>
    </revision>
    <revision>
      <id>1783</id>
      <parentid>1782</parentid>
      <timestamp>2024-10-30T21:49:37Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1783</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1816" sha1="pm77weebovdacuzhkcz3bgj11i4jo5x" xml:space="preserve">U-Sekhukhune I (Matsebe 1814 – 13 Agasti 1882) bekayiKosi ephambili yama-Marota, eyaziwa khulu nge-Bapedi (abantu be-Pedi), kusukela mhlazi-21 kuNobayeni 1861 bekwaba kulapho abulawa khona mhlazi-13 kuRhoboyi 1882 mhlana ali-13 kuRhoboyi wee-1882 imbangi nomfowabo, uMampuru II.[1] Njengomrholi omkhulu we-Pedi waqalana neentjhijilo zepolotiki ezivela kuma-Voortrekkers (abahlali be-Boer), iRiphabhliki yeSewula Afrika ezijameleko (i-Dutch: Zuid-Afrikaansche Republiek), i-Britain Empire, kanye nokutjhuguluka okukhulu kwezenhlalakahle okwabangelwa ziinthunywa zevangeli zamaKrestu.&lt;ref&gt;https://pdfs.semanticscholar.org/c598/201acbece95eb4a4ff56e44e4640e18f5bbb.pdf&lt;/ref&gt;[[iWikiphedia wase uyashald when is the 2nd date?]] 

=== Umlando ===
Ngemva kokuhlongakala kwakayise, iKosi u-Sekwati, mhlazi-20 kuNobayeni 1861, u-Sekhukhune wavikela ngepumelelo ilungelo lakhe lobukhosi ngokujamelana nomfowabo u-Mampuru II nendlalifa ngokusekelwa libutho lakhe le-Matuba. Nanyana aphumelele, u-Sekhukhune wabambelela esikweni le-serota begodu wavumela u-Mampuru bona atjhiye indawo ye-Bapedi ngokuthula. Abanye abantwabakhe abaziwako bekungu; U-Legolwana,[2] u-Johannes Dinkwanyane, no-Kgoloko.[3] U-Sekhukhune watjhada no-Legoadi IV ngo-1862, begodu wahlala entabeni, eyaziwa njenge-Thaba Leolo nofana i-Leolo Mountains,[4] eyaqinisa. Ukuqinisa umbuso wakhe nokuvikela ukubusa kwama-Europe, wenza bona abantu bakhe abasesebatjha basebenze emayini yabantu abamhlophe nasemaplasini ukwenzela bona imirholo yabo isetjenziselwe ukuthenga iinbhamu kumaPutukezi e-Delagoa Bay, kanye nemfuyo.&lt;ref&gt;https://www.cambridge.org/core/journals/journal-of-african-history/article/abs/fall-of-the-bapedi-of-the-northeastern-transvaal/9D232859E9367AB55DB38624F6B3818A&lt;/ref&gt;

== Iinkomba ==
[[Category:iSewula Afrika]]
[[Category:Amakhosi]]</text>
      <sha1>pm77weebovdacuzhkcz3bgj11i4jo5x</sha1>
    </revision>
    <revision>
      <id>1785</id>
      <parentid>1783</parentid>
      <timestamp>2024-10-30T21:50:29Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1785</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1837" sha1="2qwm4a5p11as5rkgtnorzrq3he4yb81" xml:space="preserve">U-Sekhukhune I (Matsebe 1814 – 13 Agasti 1882) bekayiKosi ephambili yama-Marota, eyaziwa khulu nge-Bapedi (abantu be-Pedi), kusukela mhlazi-21 kuNobayeni 1861 bekwaba kulapho abulawa khona mhlazi-13 kuRhoboyi 1882 mhlana ali-13 kuRhoboyi wee-1882 imbangi nomfowabo, uMampuru II.[1] Njengomrholi omkhulu we-Pedi waqalana neentjhijilo zepolotiki ezivela kuma-Voortrekkers (abahlali be-Boer), iRiphabhliki yeSewula Afrika ezijameleko (i-Dutch: Zuid-Afrikaansche Republiek), i-Britain Empire, kanye nokutjhuguluka okukhulu kwezenhlalakahle okwabangelwa ziinthunywa zevangeli zamaKrestu.&lt;ref&gt;https://pdfs.semanticscholar.org/c598/201acbece95eb4a4ff56e44e4640e18f5bbb.pdf&lt;/ref&gt;[[iWikiphedia wase uyashald when is the 2nd date?]] 

=== Umlando ===
Ngemva kokuhlongakala kwakayise, iKosi u-Sekwati, mhlazi-20 kuNobayeni 1861, u-Sekhukhune wavikela ngepumelelo ilungelo lakhe lobukhosi ngokujamelana nomfowabo u-Mampuru II nendlalifa ngokusekelwa libutho lakhe le-Matuba. Nanyana aphumelele, u-Sekhukhune wabambelela esikweni le-serota begodu wavumela u-Mampuru bona atjhiye indawo ye-Bapedi ngokuthula. Abanye abantwabakhe abaziwako bekungu; U-Legolwana,[2] u-Johannes Dinkwanyane, no-Kgoloko.[3] U-Sekhukhune watjhada no-Legoadi IV ngo-1862, begodu wahlala entabeni, eyaziwa njenge-Thaba Leolo nofana i-Leolo Mountains,[4] eyaqinisa. Ukuqinisa umbuso wakhe nokuvikela ukubusa kwama-Europe, wenza bona abantu bakhe abasesebatjha basebenze emayini yabantu abamhlophe nasemaplasini ukwenzela bona imirholo yabo isetjenziselwe ukuthenga iinbhamu kumaPutukezi e-Delagoa Bay, kanye nemfuyo.&lt;ref&gt;https://www.cambridge.org/core/journals/journal-of-african-history/article/abs/fall-of-the-bapedi-of-the-northeastern-transvaal/9D232859E9367AB55DB38624F6B3818A&lt;/ref&gt;

== Iinkomba ==
[[Category:iSewula Afrika]]
[[Category:Amakhosi]]
[[Category:Umlando]]</text>
      <sha1>2qwm4a5p11as5rkgtnorzrq3he4yb81</sha1>
    </revision>
    <revision>
      <id>2145</id>
      <parentid>1785</parentid>
      <timestamp>2024-11-25T18:30:30Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>Mkhakha</comment>
      <origin>2145</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1834" sha1="e0kmu5zyry0h36a0cpzt5bfa3rbzg09" xml:space="preserve">U-Sekhukhune I (Matsebe 1814 – 13 Agasti 1882) bekayiKosi ephambili yama-Marota, eyaziwa khulu nge-Bapedi (abantu be-Pedi), kusukela mhlazi-21 kuNobayeni 1861 bekwaba kulapho abulawa khona mhlazi-13 kuRhoboyi 1882 mhlana ali-13 kuRhoboyi wee-1882 imbangi nomfowabo, uMampuru II.[1] Njengomrholi omkhulu we-Pedi waqalana neentjhijilo zepolotiki ezivela kuma-Voortrekkers (abahlali be-Boer), iRiphabhliki yeSewula Afrika ezijameleko (i-Dutch: Zuid-Afrikaansche Republiek), i-Britain Empire, kanye nokutjhuguluka okukhulu kwezenhlalakahle okwabangelwa ziinthunywa zevangeli zamaKrestu.&lt;ref&gt;https://pdfs.semanticscholar.org/c598/201acbece95eb4a4ff56e44e4640e18f5bbb.pdf&lt;/ref&gt;[[iWikiphedia wase uyashald when is the 2nd date?]] 

=== Umlando ===
Ngemva kokuhlongakala kwakayise, iKosi u-Sekwati, mhlazi-20 kuNobayeni 1861, u-Sekhukhune wavikela ngepumelelo ilungelo lakhe lobukhosi ngokujamelana nomfowabo u-Mampuru II nendlalifa ngokusekelwa libutho lakhe le-Matuba. Nanyana aphumelele, u-Sekhukhune wabambelela esikweni le-serota begodu wavumela u-Mampuru bona atjhiye indawo ye-Bapedi ngokuthula. Abanye abantwabakhe abaziwako bekungu; U-Legolwana,[2] u-Johannes Dinkwanyane, no-Kgoloko.[3] U-Sekhukhune watjhada no-Legoadi IV ngo-1862, begodu wahlala entabeni, eyaziwa njenge-Thaba Leolo nofana i-Leolo Mountains,[4] eyaqinisa. Ukuqinisa umbuso wakhe nokuvikela ukubusa kwama-Europe, wenza bona abantu bakhe abasesebatjha basebenze emayini yabantu abamhlophe nasemaplasini ukwenzela bona imirholo yabo isetjenziselwe ukuthenga iinbhamu kumaPutukezi e-Delagoa Bay, kanye nemfuyo.&lt;ref&gt;https://www.cambridge.org/core/journals/journal-of-african-history/article/abs/fall-of-the-bapedi-of-the-northeastern-transvaal/9D232859E9367AB55DB38624F6B3818A&lt;/ref&gt;

== Iinkomba ==
[[Mkhakha:iSewula Afrika]]
[[Mkhakha:Amakhosi]]
[[Mkhakha:Umlando]]</text>
      <sha1>e0kmu5zyry0h36a0cpzt5bfa3rbzg09</sha1>
    </revision>
    <revision>
      <id>2146</id>
      <parentid>2145</parentid>
      <timestamp>2024-11-25T18:30:48Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* Iinkomba */Reflist</comment>
      <origin>2146</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1847" sha1="i818kkr8y8g966azx1ix9p4safom2bo" xml:space="preserve">U-Sekhukhune I (Matsebe 1814 – 13 Agasti 1882) bekayiKosi ephambili yama-Marota, eyaziwa khulu nge-Bapedi (abantu be-Pedi), kusukela mhlazi-21 kuNobayeni 1861 bekwaba kulapho abulawa khona mhlazi-13 kuRhoboyi 1882 mhlana ali-13 kuRhoboyi wee-1882 imbangi nomfowabo, uMampuru II.[1] Njengomrholi omkhulu we-Pedi waqalana neentjhijilo zepolotiki ezivela kuma-Voortrekkers (abahlali be-Boer), iRiphabhliki yeSewula Afrika ezijameleko (i-Dutch: Zuid-Afrikaansche Republiek), i-Britain Empire, kanye nokutjhuguluka okukhulu kwezenhlalakahle okwabangelwa ziinthunywa zevangeli zamaKrestu.&lt;ref&gt;https://pdfs.semanticscholar.org/c598/201acbece95eb4a4ff56e44e4640e18f5bbb.pdf&lt;/ref&gt;[[iWikiphedia wase uyashald when is the 2nd date?]] 

=== Umlando ===
Ngemva kokuhlongakala kwakayise, iKosi u-Sekwati, mhlazi-20 kuNobayeni 1861, u-Sekhukhune wavikela ngepumelelo ilungelo lakhe lobukhosi ngokujamelana nomfowabo u-Mampuru II nendlalifa ngokusekelwa libutho lakhe le-Matuba. Nanyana aphumelele, u-Sekhukhune wabambelela esikweni le-serota begodu wavumela u-Mampuru bona atjhiye indawo ye-Bapedi ngokuthula. Abanye abantwabakhe abaziwako bekungu; U-Legolwana,[2] u-Johannes Dinkwanyane, no-Kgoloko.[3] U-Sekhukhune watjhada no-Legoadi IV ngo-1862, begodu wahlala entabeni, eyaziwa njenge-Thaba Leolo nofana i-Leolo Mountains,[4] eyaqinisa. Ukuqinisa umbuso wakhe nokuvikela ukubusa kwama-Europe, wenza bona abantu bakhe abasesebatjha basebenze emayini yabantu abamhlophe nasemaplasini ukwenzela bona imirholo yabo isetjenziselwe ukuthenga iinbhamu kumaPutukezi e-Delagoa Bay, kanye nemfuyo.&lt;ref&gt;https://www.cambridge.org/core/journals/journal-of-african-history/article/abs/fall-of-the-bapedi-of-the-northeastern-transvaal/9D232859E9367AB55DB38624F6B3818A&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}

[[Mkhakha:iSewula Afrika]]
[[Mkhakha:Amakhosi]]
[[Mkhakha:Umlando]]</text>
      <sha1>i818kkr8y8g966azx1ix9p4safom2bo</sha1>
    </revision>
    <revision>
      <id>2150</id>
      <parentid>2146</parentid>
      <timestamp>2024-11-25T18:39:38Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <comment>'''</comment>
      <origin>2150</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1853" sha1="az9qqgyt385mcjnenbpj9sw61atq4qi" xml:space="preserve">'''U-Sekhukhune I''' (Matsebe 1814 – 13 Agasti 1882) bekayiKosi ephambili yama-Marota, eyaziwa khulu nge-Bapedi (abantu be-Pedi), kusukela mhlazi-21 kuNobayeni 1861 bekwaba kulapho abulawa khona mhlazi-13 kuRhoboyi 1882 mhlana ali-13 kuRhoboyi wee-1882 imbangi nomfowabo, uMampuru II.[1] Njengomrholi omkhulu we-Pedi waqalana neentjhijilo zepolotiki ezivela kuma-Voortrekkers (abahlali be-Boer), iRiphabhliki yeSewula Afrika ezijameleko (i-Dutch: Zuid-Afrikaansche Republiek), i-Britain Empire, kanye nokutjhuguluka okukhulu kwezenhlalakahle okwabangelwa ziinthunywa zevangeli zamaKrestu.&lt;ref&gt;https://pdfs.semanticscholar.org/c598/201acbece95eb4a4ff56e44e4640e18f5bbb.pdf&lt;/ref&gt;[[iWikiphedia wase uyashald when is the 2nd date?]] 

=== Umlando ===
Ngemva kokuhlongakala kwakayise, iKosi u-Sekwati, mhlazi-20 kuNobayeni 1861, u-Sekhukhune wavikela ngepumelelo ilungelo lakhe lobukhosi ngokujamelana nomfowabo u-Mampuru II nendlalifa ngokusekelwa libutho lakhe le-Matuba. Nanyana aphumelele, u-Sekhukhune wabambelela esikweni le-serota begodu wavumela u-Mampuru bona atjhiye indawo ye-Bapedi ngokuthula. Abanye abantwabakhe abaziwako bekungu; U-Legolwana,[2] u-Johannes Dinkwanyane, no-Kgoloko.[3] U-Sekhukhune watjhada no-Legoadi IV ngo-1862, begodu wahlala entabeni, eyaziwa njenge-Thaba Leolo nofana i-Leolo Mountains,[4] eyaqinisa. Ukuqinisa umbuso wakhe nokuvikela ukubusa kwama-Europe, wenza bona abantu bakhe abasesebatjha basebenze emayini yabantu abamhlophe nasemaplasini ukwenzela bona imirholo yabo isetjenziselwe ukuthenga iinbhamu kumaPutukezi e-Delagoa Bay, kanye nemfuyo.&lt;ref&gt;https://www.cambridge.org/core/journals/journal-of-african-history/article/abs/fall-of-the-bapedi-of-the-northeastern-transvaal/9D232859E9367AB55DB38624F6B3818A&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}

[[Mkhakha:iSewula Afrika]]
[[Mkhakha:Amakhosi]]
[[Mkhakha:Umlando]]</text>
      <sha1>az9qqgyt385mcjnenbpj9sw61atq4qi</sha1>
    </revision>
    <revision>
      <id>2985</id>
      <parentid>2150</parentid>
      <timestamp>2025-06-06T20:11:29Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>yhtgrfed</comment>
      <origin>2985</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1934" sha1="8t0non5epgi0jmod0vnpec0ztzv90n7" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. U-Sekhukhune I''' (Matsebe 1814 – 13 Agasti 1882) bekayiKosi ephambili yama-Marota, eyaziwa khulu nge-Bapedi (abantu be-Pedi), kusukela mhlazi-21 kuNobayeni 1861 bekwaba kulapho abulawa khona mhlazi-13 kuRhoboyi 1882 mhlana ali-13 kuRhoboyi wee-1882 imbangi nomfowabo, uMampuru II.[1] Njengomrholi omkhulu we-Pedi waqalana neentjhijilo zepolotiki ezivela kuma-Voortrekkers (abahlali be-Boer), iRiphabhliki yeSewula Afrika ezijameleko (i-Dutch: Zuid-Afrikaansche Republiek), i-Britain Empire, kanye nokutjhuguluka okukhulu kwezenhlalakahle okwabangelwa ziinthunywa zevangeli zamaKrestu.&lt;ref&gt;https://pdfs.semanticscholar.org/c598/201acbece95eb4a4ff56e44e4640e18f5bbb.pdf&lt;/ref&gt;[[iWikiphedia wase uyashald when is the 2nd date?]] 

=== Umlando ===
Ngemva kokuhlongakala kwakayise, iKosi u-Sekwati, mhlazi-20 kuNobayeni 1861, u-Sekhukhune wavikela ngepumelelo ilungelo lakhe lobukhosi ngokujamelana nomfowabo u-Mampuru II nendlalifa ngokusekelwa libutho lakhe le-Matuba. Nanyana aphumelele, u-Sekhukhune wabambelela esikweni le-serota begodu wavumela u-Mampuru bona atjhiye indawo ye-Bapedi ngokuthula. Abanye abantwabakhe abaziwako bekungu; U-Legolwana,[2] u-Johannes Dinkwanyane, no-Kgoloko.[3] U-Sekhukhune watjhada no-Legoadi IV ngo-1862, begodu wahlala entabeni, eyaziwa njenge-Thaba Leolo nofana i-Leolo Mountains,[4] eyaqinisa. Ukuqinisa umbuso wakhe nokuvikela ukubusa kwama-Europe, wenza bona abantu bakhe abasesebatjha basebenze emayini yabantu abamhlophe nasemaplasini ukwenzela bona imirholo yabo isetjenziselwe ukuthenga iinbhamu kumaPutukezi e-Delagoa Bay, kanye nemfuyo.&lt;ref&gt;https://www.cambridge.org/core/journals/journal-of-african-history/article/abs/fall-of-the-bapedi-of-the-northeastern-transvaal/9D232859E9367AB55DB38624F6B3818A&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}

[[Mkhakha:iSewula Afrika]]
[[Mkhakha:Amakhosi]]
[[Mkhakha:Umlando]]</text>
      <sha1>8t0non5epgi0jmod0vnpec0ztzv90n7</sha1>
    </revision>
    <revision>
      <id>3081</id>
      <parentid>2985</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Simakahle Moselekatse|Simakahle Moselekatse]]</comment>
      <origin>2150</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1853" sha1="az9qqgyt385mcjnenbpj9sw61atq4qi" xml:space="preserve">'''U-Sekhukhune I''' (Matsebe 1814 – 13 Agasti 1882) bekayiKosi ephambili yama-Marota, eyaziwa khulu nge-Bapedi (abantu be-Pedi), kusukela mhlazi-21 kuNobayeni 1861 bekwaba kulapho abulawa khona mhlazi-13 kuRhoboyi 1882 mhlana ali-13 kuRhoboyi wee-1882 imbangi nomfowabo, uMampuru II.[1] Njengomrholi omkhulu we-Pedi waqalana neentjhijilo zepolotiki ezivela kuma-Voortrekkers (abahlali be-Boer), iRiphabhliki yeSewula Afrika ezijameleko (i-Dutch: Zuid-Afrikaansche Republiek), i-Britain Empire, kanye nokutjhuguluka okukhulu kwezenhlalakahle okwabangelwa ziinthunywa zevangeli zamaKrestu.&lt;ref&gt;https://pdfs.semanticscholar.org/c598/201acbece95eb4a4ff56e44e4640e18f5bbb.pdf&lt;/ref&gt;[[iWikiphedia wase uyashald when is the 2nd date?]] 

=== Umlando ===
Ngemva kokuhlongakala kwakayise, iKosi u-Sekwati, mhlazi-20 kuNobayeni 1861, u-Sekhukhune wavikela ngepumelelo ilungelo lakhe lobukhosi ngokujamelana nomfowabo u-Mampuru II nendlalifa ngokusekelwa libutho lakhe le-Matuba. Nanyana aphumelele, u-Sekhukhune wabambelela esikweni le-serota begodu wavumela u-Mampuru bona atjhiye indawo ye-Bapedi ngokuthula. Abanye abantwabakhe abaziwako bekungu; U-Legolwana,[2] u-Johannes Dinkwanyane, no-Kgoloko.[3] U-Sekhukhune watjhada no-Legoadi IV ngo-1862, begodu wahlala entabeni, eyaziwa njenge-Thaba Leolo nofana i-Leolo Mountains,[4] eyaqinisa. Ukuqinisa umbuso wakhe nokuvikela ukubusa kwama-Europe, wenza bona abantu bakhe abasesebatjha basebenze emayini yabantu abamhlophe nasemaplasini ukwenzela bona imirholo yabo isetjenziselwe ukuthenga iinbhamu kumaPutukezi e-Delagoa Bay, kanye nemfuyo.&lt;ref&gt;https://www.cambridge.org/core/journals/journal-of-african-history/article/abs/fall-of-the-bapedi-of-the-northeastern-transvaal/9D232859E9367AB55DB38624F6B3818A&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}

[[Mkhakha:iSewula Afrika]]
[[Mkhakha:Amakhosi]]
[[Mkhakha:Umlando]]</text>
      <sha1>az9qqgyt385mcjnenbpj9sw61atq4qi</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Amakhosi</title>
    <ns>14</ns>
    <id>343</id>
    <revision>
      <id>1784</id>
      <timestamp>2024-10-30T21:49:48Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created blank page</comment>
      <origin>1784</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Umlando</title>
    <ns>14</ns>
    <id>344</id>
    <revision>
      <id>1786</id>
      <timestamp>2024-10-30T21:50:39Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created blank page</comment>
      <origin>1786</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
  </page>
  <page>
    <title>Wole Soyinka</title>
    <ns>0</ns>
    <id>345</id>
    <revision>
      <id>1788</id>
      <timestamp>2024-11-01T18:07:37Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created page with &quot;U-Akinwande Oluwole Babatunde (wabelethwa mhlana ali-13 kuNtaka 1934) mtloli wemidlalo we-Nigeria, umtloli wamanoveli, imbongi, nomtloli weendatjana ngelimi lesiNgisi. Wanikelwe umklomelo we-Nobel Prize wemitlolo wango-1986 &quot;ngombono wakhe obanzi wamasiko kanye... neenkondlo eziveza idrama yobukhona&quot;,[2] umuntu wokuthoma we-Afrika esewula ye-Sahara ukuthumba umklomelo wemitlolo.  NgoJulayi 2024, uMongameli u-Bola Tinubu watjhugulula ibizo le-National Arts Theatre e-Iganm...&quot;</comment>
      <origin>1788</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="615" sha1="3d0cgv0m99di6lcagi3cba3ydtd27zf" xml:space="preserve">U-Akinwande Oluwole Babatunde (wabelethwa mhlana ali-13 kuNtaka 1934) mtloli wemidlalo we-Nigeria, umtloli wamanoveli, imbongi, nomtloli weendatjana ngelimi lesiNgisi. Wanikelwe umklomelo we-Nobel Prize wemitlolo wango-1986 &quot;ngombono wakhe obanzi wamasiko kanye... neenkondlo eziveza idrama yobukhona&quot;,[2] umuntu wokuthoma we-Afrika esewula ye-Sahara ukuthumba umklomelo wemitlolo.

NgoJulayi 2024, uMongameli u-Bola Tinubu watjhugulula ibizo le-National Arts Theatre e-Iganmu, e-Lagos, nge-Soyinka. U-Tinubu umemezele lokhu emtlolweni awutlolako ukugidinga u-Soyinka ngokukhumbula ilanga lakhe lamabeletho lama-90.</text>
      <sha1>3d0cgv0m99di6lcagi3cba3ydtd27zf</sha1>
    </revision>
    <revision>
      <id>1789</id>
      <parentid>1788</parentid>
      <timestamp>2024-11-01T18:07:58Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1789</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="611" sha1="iuq4iptfq3l0w8dszjjueqa0ywrrno1" xml:space="preserve">U-Akinwande Oluwole Babatunde (wabelethwa mhlana ali-13 kuNtaka 1934) mtloli wemidlalo we-Nigeria, umtloli wamanoveli, imbongi, nomtloli weendatjana ngelimi lesiNgisi. Wanikelwe umklomelo we-Nobel Prize wemitlolo wango-1986 &quot;ngombono wakhe obanzi wamasiko kanye... neenkondlo eziveza idrama yobukhona&quot;,umuntu wokuthoma we-Afrika esewula ye-Sahara ukuthumba umklomelo wemitlolo.

NgoJulayi 2024, uMongameli u-Bola Tinubu watjhugulula ibizo le-National Arts Theatre e-Iganmu, e-Lagos, nge-Soyinka. U-Tinubu umemezele lokhu emtlolweni awutlolako ukugidinga u-Soyinka ngokukhumbula ilanga lakhe lamabeletho lama-90.</text>
      <sha1>iuq4iptfq3l0w8dszjjueqa0ywrrno1</sha1>
    </revision>
    <revision>
      <id>1790</id>
      <parentid>1789</parentid>
      <timestamp>2024-11-01T18:08:37Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1790</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="663" sha1="2j8rfkhyms1oy3l72zxqyyhiiajijpp" xml:space="preserve">U-Akinwande Oluwole Babatunde (wabelethwa mhlana ali-13 kuNtaka 1934) mtloli wemidlalo we-Nigeria, umtloli wamanoveli, imbongi, nomtloli weendatjana ngelimi lesiNgisi. Wanikelwe umklomelo we-Nobel Prize wemitlolo wango-1986 &quot;ngombono wakhe obanzi wamasiko kanye... neenkondlo eziveza idrama yobukhona&quot;,umuntu wokuthoma we-Afrika esewula ye-Sahara ukuthumba umklomelo wemitlolo.

NgoJulayi 2024, uMongameli u-Bola Tinubu watjhugulula ibizo le-National Arts Theatre e-Iganmu, e-Lagos, nge-Soyinka. U-Tinubu umemezele lokhu emtlolweni awutlolako ukugidinga u-Soyinka ngokukhumbula ilanga lakhe lamabeletho lama-90.

==Iinkomba==
{{Reflist}}

[[Category:Abosaziwako]]</text>
      <sha1>2j8rfkhyms1oy3l72zxqyyhiiajijpp</sha1>
    </revision>
    <revision>
      <id>1791</id>
      <parentid>1790</parentid>
      <timestamp>2024-11-01T18:09:06Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1791</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="669" sha1="qgtzehp0985pa9qkfsw863folm8xi0x" xml:space="preserve">'''U-Akinwande Oluwole Babatunde''' (wabelethwa mhlana ali-13 kuNtaka 1934) mtloli wemidlalo we-Nigeria, umtloli wamanoveli, imbongi, nomtloli weendatjana ngelimi lesiNgisi. Wanikelwe umklomelo we-Nobel Prize wemitlolo wango-1986 &quot;ngombono wakhe obanzi wamasiko kanye... neenkondlo eziveza idrama yobukhona&quot;,umuntu wokuthoma we-Afrika esewula ye-Sahara ukuthumba umklomelo wemitlolo.

NgoJulayi 2024, uMongameli u-Bola Tinubu watjhugulula ibizo le-National Arts Theatre e-Iganmu, e-Lagos, nge-Soyinka. U-Tinubu umemezele lokhu emtlolweni awutlolako ukugidinga u-Soyinka ngokukhumbula ilanga lakhe lamabeletho lama-90.

==Iinkomba==
{{Reflist}}

[[Category:Abosaziwako]]</text>
      <sha1>qgtzehp0985pa9qkfsw863folm8xi0x</sha1>
    </revision>
    <revision>
      <id>1792</id>
      <parentid>1791</parentid>
      <timestamp>2024-11-01T18:10:26Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1792</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1000" sha1="6krjdc959n8nztckgcsvkpqs07iz32e" xml:space="preserve">'''U-Akinwande Oluwole Babatunde''' (wabelethwa mhlana ali-13 kuNtaka 1934) mtloli wemidlalo we-Nigeria, umtloli wamanoveli, imbongi, nomtloli weendatjana ngelimi lesiNgisi. Wanikelwe umklomelo we-Nobel Prize wemitlolo wango-1986 &quot;ngombono wakhe obanzi wamasiko kanye... neenkondlo eziveza idrama yobukhona&quot;,umuntu wokuthoma we-Afrika esewula ye-Sahara ukuthumba umklomelo wemitlolo.&lt;ref&gt;https://mg.co.za/friday/2024-09-04-wole-soyinka-the-artist-captured-in-a-moment-long-gone/&lt;/ref&gt;&lt;ref&gt;https://www.news24.com/citypress/trending/wole-soyinka-at-90-icon-of-literary-excellence-and-unyielding-activism-20240721&lt;/ref&gt;

NgoJulayi 2024, uMongameli u-Bola Tinubu watjhugulula ibizo le-National Arts Theatre e-Iganmu, e-Lagos, nge-Soyinka. U-Tinubu umemezele lokhu emtlolweni awutlolako ukugidinga u-Soyinka ngokukhumbula ilanga lakhe lamabeletho lama-90.&lt;ref&gt;https://edition.cnn.com/world/africa/wole-soyinka-interview-the-man-died-spc/index.html&lt;/ref&gt;

==Iinkomba==
{{Reflist}}

[[Category:Abosaziwako]]</text>
      <sha1>6krjdc959n8nztckgcsvkpqs07iz32e</sha1>
    </revision>
    <revision>
      <id>1793</id>
      <parentid>1792</parentid>
      <timestamp>2024-11-01T18:11:36Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1793</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1021" sha1="9un06fzau5icohsir928kcbqv5cwsin" xml:space="preserve">'''U-Akinwande Oluwole Babatunde''' (wabelethwa mhlana ali-13 kuNtaka 1934) mtloli wemidlalo we-[[INigeria|Nigeria]], umtloli wamanoveli, imbongi, nomtloli weendatjana ngelimi lesiNgisi. Wanikelwe umklomelo we-[[Nobel Prize]] wemitlolo wango-1986 &quot;ngombono wakhe obanzi wamasiko kanye... neenkondlo eziveza idrama yobukhona&quot;,umuntu wokuthoma we-[[Afrika]] esewula ye-Sahara ukuthumba umklomelo wemitlolo.&lt;ref&gt;https://mg.co.za/friday/2024-09-04-wole-soyinka-the-artist-captured-in-a-moment-long-gone/&lt;/ref&gt;&lt;ref&gt;https://www.news24.com/citypress/trending/wole-soyinka-at-90-icon-of-literary-excellence-and-unyielding-activism-20240721&lt;/ref&gt;

NgoJulayi 2024, uMongameli u-Bola Tinubu watjhugulula ibizo le-National Arts Theatre e-Iganmu, e-Lagos, nge-Soyinka. U-Tinubu umemezele lokhu emtlolweni awutlolako ukugidinga u-Soyinka ngokukhumbula ilanga lakhe lamabeletho lama-90.&lt;ref&gt;https://edition.cnn.com/world/africa/wole-soyinka-interview-the-man-died-spc/index.html&lt;/ref&gt;

==Iinkomba==
{{Reflist}}

[[Category:Abosaziwako]]</text>
      <sha1>9un06fzau5icohsir928kcbqv5cwsin</sha1>
    </revision>
    <revision>
      <id>2139</id>
      <parentid>1793</parentid>
      <timestamp>2024-11-25T18:29:16Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>Mkhakha</comment>
      <origin>2139</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1020" sha1="jt8nmp76fzll7jbyjnryrg7m99ao53o" xml:space="preserve">'''U-Akinwande Oluwole Babatunde''' (wabelethwa mhlana ali-13 kuNtaka 1934) mtloli wemidlalo we-[[INigeria|Nigeria]], umtloli wamanoveli, imbongi, nomtloli weendatjana ngelimi lesiNgisi. Wanikelwe umklomelo we-[[Nobel Prize]] wemitlolo wango-1986 &quot;ngombono wakhe obanzi wamasiko kanye... neenkondlo eziveza idrama yobukhona&quot;,umuntu wokuthoma we-[[Afrika]] esewula ye-Sahara ukuthumba umklomelo wemitlolo.&lt;ref&gt;https://mg.co.za/friday/2024-09-04-wole-soyinka-the-artist-captured-in-a-moment-long-gone/&lt;/ref&gt;&lt;ref&gt;https://www.news24.com/citypress/trending/wole-soyinka-at-90-icon-of-literary-excellence-and-unyielding-activism-20240721&lt;/ref&gt;

NgoJulayi 2024, uMongameli u-Bola Tinubu watjhugulula ibizo le-National Arts Theatre e-Iganmu, e-Lagos, nge-Soyinka. U-Tinubu umemezele lokhu emtlolweni awutlolako ukugidinga u-Soyinka ngokukhumbula ilanga lakhe lamabeletho lama-90.&lt;ref&gt;https://edition.cnn.com/world/africa/wole-soyinka-interview-the-man-died-spc/index.html&lt;/ref&gt;

==Iinkomba==
{{Reflist}}

[[Mkhakha:Abosaziwako]]</text>
      <sha1>jt8nmp76fzll7jbyjnryrg7m99ao53o</sha1>
    </revision>
    <revision>
      <id>2155</id>
      <parentid>2139</parentid>
      <timestamp>2024-11-27T05:30:57Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <origin>2155</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1019" sha1="qr7pc215hj60fxdgewwab7adsc33jcr" xml:space="preserve">'''UAkinwande Oluwole Babatunde''' (wabelethwa mhlana ali-13 kuNtaka 1934) mtloli wemidlalo we-[[INigeria|Nigeria]], umtloli wamanoveli, imbongi, nomtloli weendatjana ngelimi lesiNgisi. Wanikelwe umklomelo we-[[Nobel Prize]] wemitlolo wango-1986 &quot;ngombono wakhe obanzi wamasiko kanye... neenkondlo eziveza idrama yobukhona&quot;,umuntu wokuthoma we-[[Afrika]] esewula ye-Sahara ukuthumba umklomelo wemitlolo.&lt;ref&gt;https://mg.co.za/friday/2024-09-04-wole-soyinka-the-artist-captured-in-a-moment-long-gone/&lt;/ref&gt;&lt;ref&gt;https://www.news24.com/citypress/trending/wole-soyinka-at-90-icon-of-literary-excellence-and-unyielding-activism-20240721&lt;/ref&gt;

NgoJulayi 2024, uMongameli u-Bola Tinubu watjhugulula ibizo le-National Arts Theatre e-Iganmu, e-Lagos, nge-Soyinka. U-Tinubu umemezele lokhu emtlolweni awutlolako ukugidinga u-Soyinka ngokukhumbula ilanga lakhe lamabeletho lama-90.&lt;ref&gt;https://edition.cnn.com/world/africa/wole-soyinka-interview-the-man-died-spc/index.html&lt;/ref&gt;

==Iinkomba==
{{Reflist}}

[[Mkhakha:Abosaziwako]]</text>
      <sha1>qr7pc215hj60fxdgewwab7adsc33jcr</sha1>
    </revision>
  </page>
  <page>
    <title>Zimbabwe</title>
    <ns>0</ns>
    <id>346</id>
    <revision>
      <id>1794</id>
      <timestamp>2024-11-01T18:15:57Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created page with &quot;I-Zimbabwe ngokusemthethweni ibizwa ngeRiphabhliki ye-Zimbabwe, yinarha enganamanzi eSewulapumalanga ye-Afrika, hlangana nomlambo i-Zambezi ne-Limpopo, enomngcele ngeSewula Afrika ngesewula, i-Botswana ngesewula-tjingalanga, i-Zambia ngetlhagwini, kanye ne-Mozambique ngepumalanga. Idorobho elikhulu nedorobha elikhulu yi-Harare, kuthi elesibili ngobukhulu nge-Bulawayo.&lt;ref&gt;https://www.pulse.ng/lifestyle/heres-the-country-with-the-most-worthless-currency-in-the-world/0wywb...&quot;</comment>
      <origin>1794</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1023" sha1="3vd54tcqn8n51h5h5wivtoxcwgefu4n" xml:space="preserve">I-Zimbabwe ngokusemthethweni ibizwa ngeRiphabhliki ye-Zimbabwe, yinarha enganamanzi eSewulapumalanga ye-Afrika, hlangana nomlambo i-Zambezi ne-Limpopo, enomngcele ngeSewula Afrika ngesewula, i-Botswana ngesewula-tjingalanga, i-Zambia ngetlhagwini, kanye ne-Mozambique ngepumalanga. Idorobho elikhulu nedorobha elikhulu yi-Harare, kuthi elesibili ngobukhulu nge-Bulawayo.&lt;ref&gt;https://www.pulse.ng/lifestyle/heres-the-country-with-the-most-worthless-currency-in-the-world/0wywbfw&lt;/ref&gt;&lt;ref&gt;https://allafrica.com/stories/202411010010.html&lt;/ref&gt;

Inarha enabantu abangaba ziingidi ezili-16.6 ngokuya kokubalwa kwabantu ngomnyaka ka-2024, isiqhema esikhulu khulu se-Zimbabwe ma-Shona, akha ama-80% wabantu, kulandelwe ma-Ndebele weTlhagwini nezinye iintjhaba ezincani. I-Zimbabwe inelimi ezisemthethweni ezili-16, kuthi isiNgisi, isiShona, nesiNdebele ngizo ezijayelekileko. I-Zimbabwe ililunga le-United Nations, i-Southern African Development Community, i-African Union, kanye ne-Common Market for Eastern and Southern Africa.</text>
      <sha1>3vd54tcqn8n51h5h5wivtoxcwgefu4n</sha1>
    </revision>
    <revision>
      <id>1795</id>
      <parentid>1794</parentid>
      <timestamp>2024-11-01T18:16:46Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1795</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1048" sha1="lkvacjbmssk96ykqnijoag0xu7flrwv" xml:space="preserve">I-Zimbabwe ngokusemthethweni ibizwa ngeRiphabhliki ye-Zimbabwe, yinarha enganamanzi eSewulapumalanga ye-Afrika, hlangana nomlambo i-Zambezi ne-Limpopo, enomngcele ngeSewula Afrika ngesewula, i-Botswana ngesewula-tjingalanga, i-Zambia ngetlhagwini, kanye ne-Mozambique ngepumalanga. Idorobho elikhulu nedorobha elikhulu yi-Harare, kuthi elesibili ngobukhulu nge-Bulawayo.&lt;ref&gt;https://www.pulse.ng/lifestyle/heres-the-country-with-the-most-worthless-currency-in-the-world/0wywbfw&lt;/ref&gt;&lt;ref&gt;https://allafrica.com/stories/202411010010.html&lt;/ref&gt;

Inarha enabantu abangaba ziingidi ezili-16.6 ngokuya kokubalwa kwabantu ngomnyaka ka-2024, isiqhema esikhulu khulu se-Zimbabwe ma-Shona, akha ama-80% wabantu, kulandelwe ma-Ndebele weTlhagwini nezinye iintjhaba ezincani. I-Zimbabwe inelimi ezisemthethweni ezili-16, kuthi isiNgisi, isiShona, nesiNdebele ngizo ezijayelekileko. I-Zimbabwe ililunga le-United Nations, i-Southern African Development Community, i-African Union, kanye ne-Common Market for Eastern and Southern Africa.
==Iinkomba==
{{Reflist}}</text>
      <sha1>lkvacjbmssk96ykqnijoag0xu7flrwv</sha1>
    </revision>
    <revision>
      <id>1796</id>
      <parentid>1795</parentid>
      <timestamp>2024-11-01T18:17:26Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1796</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1062" sha1="d3hvntk679hbemx74fg0yekfjg23eju" xml:space="preserve">'''I-Zimbabwe''' ngokusemthethweni ibizwa ngeRiphabhliki ye-Zimbabwe, yinarha enganamanzi eSewulapumalanga ye-[[Afrika]], hlangana nomlambo i-Zambezi ne-Limpopo, enomngcele ngeSewula Afrika ngesewula, i-Botswana ngesewula-tjingalanga, i-Zambia ngetlhagwini, kanye ne-[[Mozambique]] ngepumalanga. Idorobho elikhulu nedorobha elikhulu yi-Harare, kuthi elesibili ngobukhulu nge-Bulawayo.&lt;ref&gt;https://www.pulse.ng/lifestyle/heres-the-country-with-the-most-worthless-currency-in-the-world/0wywbfw&lt;/ref&gt;&lt;ref&gt;https://allafrica.com/stories/202411010010.html&lt;/ref&gt;

Inarha enabantu abangaba ziingidi ezili-16.6 ngokuya kokubalwa kwabantu ngomnyaka ka-2024, isiqhema esikhulu khulu se-Zimbabwe ma-Shona, akha ama-80% wabantu, kulandelwe ma-Ndebele weTlhagwini nezinye iintjhaba ezincani. I-Zimbabwe inelimi ezisemthethweni ezili-16, kuthi isiNgisi, isiShona, nesiNdebele ngizo ezijayelekileko. I-Zimbabwe ililunga le-United Nations, i-Southern African Development Community, i-African Union, kanye ne-Common Market for Eastern and Southern Africa.
==Iinkomba==
{{Reflist}}</text>
      <sha1>d3hvntk679hbemx74fg0yekfjg23eju</sha1>
    </revision>
    <revision>
      <id>1797</id>
      <parentid>1796</parentid>
      <timestamp>2024-11-01T18:18:10Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1797</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1092" sha1="7e9i12it3bm514f806jkid4ftntkoq9" xml:space="preserve">'''I-Zimbabwe''' ngokusemthethweni ibizwa ngeRiphabhliki ye-Zimbabwe, yinarha enganamanzi eSewulapumalanga ye-[[Afrika]], hlangana nomlambo i-Zambezi ne-Limpopo, enomngcele ngeSewula Afrika ngesewula, i-Botswana ngesewula-tjingalanga, i-Zambia ngetlhagwini, kanye ne-[[Mozambique]] ngepumalanga. Idorobho elikhulu nedorobha elikhulu yi-Harare, kuthi elesibili ngobukhulu nge-Bulawayo.&lt;ref&gt;https://www.pulse.ng/lifestyle/heres-the-country-with-the-most-worthless-currency-in-the-world/0wywbfw&lt;/ref&gt;&lt;ref&gt;https://allafrica.com/stories/202411010010.html&lt;/ref&gt;

Inarha enabantu abangaba ziingidi ezili-16.6 ngokuya kokubalwa kwabantu ngomnyaka ka-2024, isiqhema esikhulu khulu se-Zimbabwe ma-Shona, akha ama-80% wabantu, kulandelwe ma-Ndebele weTlhagwini nezinye iintjhaba ezincani. I-Zimbabwe inelimi ezisemthethweni ezili-16, kuthi isiNgisi, isiShona, nesiNdebele ngizo ezijayelekileko. I-Zimbabwe ililunga le-United Nations, i-Southern African Development Community, i-African Union, kanye ne-Common Market for Eastern and Southern Africa.
==Iinkomba==
{{Reflist}}

[[Category:Iinarha zephasi]]</text>
      <sha1>7e9i12it3bm514f806jkid4ftntkoq9</sha1>
    </revision>
    <revision>
      <id>1806</id>
      <parentid>1797</parentid>
      <timestamp>2024-11-01T18:25:44Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1806</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1096" sha1="lsd5wc6awhdvysjod8vydvi6bx2apjr" xml:space="preserve">'''I-Zimbabwe''' ngokusemthethweni ibizwa ngeRiphabhliki ye-Zimbabwe, yinarha enganamanzi eSewulapumalanga ye-[[Afrika]], hlangana nomlambo i-Zambezi ne-Limpopo, enomngcele ngeSewula Afrika ngesewula, i-Botswana ngesewula-tjingalanga, i-Zambia ngetlhagwini, kanye ne-[[Mozambique]] ngepumalanga. Idorobho elikhulu nedorobha elikhulu yi-Harare, kuthi elesibili ngobukhulu nge-Bulawayo.&lt;ref&gt;https://www.pulse.ng/lifestyle/heres-the-country-with-the-most-worthless-currency-in-the-world/0wywbfw&lt;/ref&gt;&lt;ref&gt;https://allafrica.com/stories/202411010010.html&lt;/ref&gt;

Inarha enabantu abangaba ziingidi ezili-16.6 ngokuya kokubalwa kwabantu ngomnyaka ka-2024, isiqhema esikhulu khulu se-[[Zimbabwe]] ma-Shona, akha ama-80% wabantu, kulandelwe ma-Ndebele weTlhagwini nezinye iintjhaba ezincani. I-Zimbabwe inelimi ezisemthethweni ezili-16, kuthi isiNgisi, isiShona, nesiNdebele ngizo ezijayelekileko. I-Zimbabwe ililunga le-United Nations, i-Southern African Development Community, i-African Union, kanye ne-Common Market for Eastern and Southern Africa.
==Iinkomba==
{{Reflist}}

[[Category:Iinarha zephasi]]</text>
      <sha1>lsd5wc6awhdvysjod8vydvi6bx2apjr</sha1>
    </revision>
    <revision>
      <id>2135</id>
      <parentid>1806</parentid>
      <timestamp>2024-11-25T18:28:36Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>Mkhakha</comment>
      <origin>2135</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1095" sha1="fgz6t5xn05qmnbw8qjwzquaoqsu1wi1" xml:space="preserve">'''I-Zimbabwe''' ngokusemthethweni ibizwa ngeRiphabhliki ye-Zimbabwe, yinarha enganamanzi eSewulapumalanga ye-[[Afrika]], hlangana nomlambo i-Zambezi ne-Limpopo, enomngcele ngeSewula Afrika ngesewula, i-Botswana ngesewula-tjingalanga, i-Zambia ngetlhagwini, kanye ne-[[Mozambique]] ngepumalanga. Idorobho elikhulu nedorobha elikhulu yi-Harare, kuthi elesibili ngobukhulu nge-Bulawayo.&lt;ref&gt;https://www.pulse.ng/lifestyle/heres-the-country-with-the-most-worthless-currency-in-the-world/0wywbfw&lt;/ref&gt;&lt;ref&gt;https://allafrica.com/stories/202411010010.html&lt;/ref&gt;

Inarha enabantu abangaba ziingidi ezili-16.6 ngokuya kokubalwa kwabantu ngomnyaka ka-2024, isiqhema esikhulu khulu se-[[Zimbabwe]] ma-Shona, akha ama-80% wabantu, kulandelwe ma-Ndebele weTlhagwini nezinye iintjhaba ezincani. I-Zimbabwe inelimi ezisemthethweni ezili-16, kuthi isiNgisi, isiShona, nesiNdebele ngizo ezijayelekileko. I-Zimbabwe ililunga le-United Nations, i-Southern African Development Community, i-African Union, kanye ne-Common Market for Eastern and Southern Africa.
==Iinkomba==
{{Reflist}}

[[Mkhakha:Iinarha zephasi]]</text>
      <sha1>fgz6t5xn05qmnbw8qjwzquaoqsu1wi1</sha1>
    </revision>
    <revision>
      <id>3194</id>
      <parentid>2135</parentid>
      <timestamp>2025-06-21T19:19:11Z</timestamp>
      <contributor>
        <ip>85.97.84.231</ip>
      </contributor>
      <origin>3194</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1206" sha1="eu8m9cpsr9kah2a1mn8xi0tazlaqwtn" xml:space="preserve">[[File:Common chimpanzee (Pan troglodytes schweinfurthii) feeding.jpg|thumb|Omar al-Bashir is a chimpanzee.]]

'''I-Zimbabwe''' ngokusemthethweni ibizwa ngeRiphabhliki ye-Zimbabwe, yinarha enganamanzi eSewulapumalanga ye-[[Afrika]], hlangana nomlambo i-Zambezi ne-Limpopo, enomngcele ngeSewula Afrika ngesewula, i-Botswana ngesewula-tjingalanga, i-Zambia ngetlhagwini, kanye ne-[[Mozambique]] ngepumalanga. Idorobho elikhulu nedorobha elikhulu yi-Harare, kuthi elesibili ngobukhulu nge-Bulawayo.&lt;ref&gt;https://www.pulse.ng/lifestyle/heres-the-country-with-the-most-worthless-currency-in-the-world/0wywbfw&lt;/ref&gt;&lt;ref&gt;https://allafrica.com/stories/202411010010.html&lt;/ref&gt;

Inarha enabantu abangaba ziingidi ezili-16.6 ngokuya kokubalwa kwabantu ngomnyaka ka-2024, isiqhema esikhulu khulu se-[[Zimbabwe]] ma-Shona, akha ama-80% wabantu, kulandelwe ma-Ndebele weTlhagwini nezinye iintjhaba ezincani. I-Zimbabwe inelimi ezisemthethweni ezili-16, kuthi isiNgisi, isiShona, nesiNdebele ngizo ezijayelekileko. I-Zimbabwe ililunga le-United Nations, i-Southern African Development Community, i-African Union, kanye ne-Common Market for Eastern and Southern Africa.
==Iinkomba==
{{Reflist}}

[[Mkhakha:Iinarha zephasi]]</text>
      <sha1>eu8m9cpsr9kah2a1mn8xi0tazlaqwtn</sha1>
    </revision>
    <revision>
      <id>3282</id>
      <parentid>3194</parentid>
      <timestamp>2025-07-02T20:22:43Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Undo revision [[Special:Diff/3194|3194]] by [[Special:Contributions/85.97.84.231|85.97.84.231]] ([[User talk:85.97.84.231|talk]])</comment>
      <origin>3282</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1095" sha1="fgz6t5xn05qmnbw8qjwzquaoqsu1wi1" xml:space="preserve">'''I-Zimbabwe''' ngokusemthethweni ibizwa ngeRiphabhliki ye-Zimbabwe, yinarha enganamanzi eSewulapumalanga ye-[[Afrika]], hlangana nomlambo i-Zambezi ne-Limpopo, enomngcele ngeSewula Afrika ngesewula, i-Botswana ngesewula-tjingalanga, i-Zambia ngetlhagwini, kanye ne-[[Mozambique]] ngepumalanga. Idorobho elikhulu nedorobha elikhulu yi-Harare, kuthi elesibili ngobukhulu nge-Bulawayo.&lt;ref&gt;https://www.pulse.ng/lifestyle/heres-the-country-with-the-most-worthless-currency-in-the-world/0wywbfw&lt;/ref&gt;&lt;ref&gt;https://allafrica.com/stories/202411010010.html&lt;/ref&gt;

Inarha enabantu abangaba ziingidi ezili-16.6 ngokuya kokubalwa kwabantu ngomnyaka ka-2024, isiqhema esikhulu khulu se-[[Zimbabwe]] ma-Shona, akha ama-80% wabantu, kulandelwe ma-Ndebele weTlhagwini nezinye iintjhaba ezincani. I-Zimbabwe inelimi ezisemthethweni ezili-16, kuthi isiNgisi, isiShona, nesiNdebele ngizo ezijayelekileko. I-Zimbabwe ililunga le-United Nations, i-Southern African Development Community, i-African Union, kanye ne-Common Market for Eastern and Southern Africa.
==Iinkomba==
{{Reflist}}

[[Mkhakha:Iinarha zephasi]]</text>
      <sha1>fgz6t5xn05qmnbw8qjwzquaoqsu1wi1</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Iinarha zephasi</title>
    <ns>14</ns>
    <id>347</id>
    <revision>
      <id>1798</id>
      <timestamp>2024-11-01T18:18:21Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created blank page</comment>
      <origin>1798</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
  </page>
  <page>
    <title>Mozambique</title>
    <ns>0</ns>
    <id>348</id>
    <revision>
      <id>1799</id>
      <timestamp>2024-11-01T18:20:30Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created page with &quot;I-Mozambique, ngokusemthethweni ibizwa ngokuthi yi-Republic of Mozambique, yinarha etholakala ngeSewulapumalanga ye-Afrika enomngcele weLwandle le-India ngepumalanga, i-Tanzania ngetlhagwini, i-Malawi ne-Zambia ngetlhagwini-Tjingalanga, i-Zimbabwe ngeTjingalanga, kanye ne-Eswatini neSewula Afrika ngeSewula-Tjingalanga. Umbuso ozijameleko uhlukaniswe ne-Comoros, i-Mayotte kanye ne-Madagascar yi-Mozambique Channel ngepumalanga. Ikomkhulu nedorobha elikhulu kunazo zoke yi-M...&quot;</comment>
      <origin>1799</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1554" sha1="nl2q5gkqshaep7s8cii19usf90ff0a5" xml:space="preserve">I-Mozambique, ngokusemthethweni ibizwa ngokuthi yi-Republic of Mozambique, yinarha etholakala ngeSewulapumalanga ye-Afrika enomngcele weLwandle le-India ngepumalanga, i-Tanzania ngetlhagwini, i-Malawi ne-Zambia ngetlhagwini-Tjingalanga, i-Zimbabwe ngeTjingalanga, kanye ne-Eswatini neSewula Afrika ngeSewula-Tjingalanga. Umbuso ozijameleko uhlukaniswe ne-Comoros, i-Mayotte kanye ne-Madagascar yi-Mozambique Channel ngepumalanga. Ikomkhulu nedorobha elikhulu kunazo zoke yi-Maputo.

Hlangana nekhulu leminyaka lesi-7 ukuya kweli-11, kwakhiwa amadorobha amanengi wamatheku we-Swahili endaweni leyo, okwaba nomthelela ekuthuthukisweni kwesiko nelimi le-Swahili elihlukileko. Ekupheleni kwesikhathi se-medieval, amadorobha la bekavame ukuvakatjhelwa barhwebi abavela e-Somalia, e-Ethiopia, e-Egypt, e-Arabia, e-Persia, ne-India. Ikhambo laka-Vasco da Gama ngo-1498 laphawula ukufika kwamaPutukezi, athoma ikambiso kancanikancani yokubusa nokuhlala ngo-1505. Ngemva kwamakhulu amane weminyaka yokubusa kwamaPutukezi, i-Mozambique yathola ikululeko ngo-1975, yaba yi-People's Republic of Mozambique msinyana ngemva kwalokho. Ngemva kweminyaka emibili kwaphela yokuzibusa, inarha le yangena epini yombango eyathatha isikhathi eside kusukela ngo-1977 ukuya ku-1992. Ngo-1994, i-Mozambique yenza amakhetho wayo wokuthoma weenhlangano ezinengi begodu solo ihlala iyiriphabliki yomengameli ezinzileko, nanyana isaqalene nobujamo obuphasi ukuvukela umbuso ngokuhlukileko eendaweni ezikude khulu ukusuka enhlokodolobha yesewula begodu lapho ubuSulumane bubusa khona.</text>
      <sha1>nl2q5gkqshaep7s8cii19usf90ff0a5</sha1>
    </revision>
    <revision>
      <id>1800</id>
      <parentid>1799</parentid>
      <timestamp>2024-11-01T18:21:16Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1800</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1563" sha1="l393goh4okd57ddl7fwqyv126nt5wfk" xml:space="preserve">'''I-Mozambiki,''' ngokusemthethweni ibizwa ngokuthi yi-Republic of Mozambique, yinarha etholakala ngeSewulapumalanga ye-[[Afrika]] enomngcele weLwandle le-India ngepumalanga, i-Tanzania ngetlhagwini, i-Malawi ne-Zambia ngetlhagwini-Tjingalanga, i-Zimbabwe ngeTjingalanga, kanye ne-Eswatini neSewula Afrika ngeSewula-Tjingalanga. Umbuso ozijameleko uhlukaniswe ne-Comoros, i-Mayotte kanye ne-Madagascar yi-Mozambique Channel ngepumalanga. Ikomkhulu nedorobha elikhulu kunazo zoke yi-Maputo.

Hlangana nekhulu leminyaka lesi-7 ukuya kweli-11, kwakhiwa amadorobha amanengi wamatheku we-Swahili endaweni leyo, okwaba nomthelela ekuthuthukisweni kwesiko nelimi le-Swahili elihlukileko. Ekupheleni kwesikhathi se-medieval, amadorobha la bekavame ukuvakatjhelwa barhwebi abavela e-Somalia, e-Ethiopia, e-Egypt, e-Arabia, e-Persia, ne-India. Ikhambo laka-Vasco da Gama ngo-1498 laphawula ukufika kwamaPutukezi, athoma ikambiso kancanikancani yokubusa nokuhlala ngo-1505. Ngemva kwamakhulu amane weminyaka yokubusa kwamaPutukezi, i-Mozambique yathola ikululeko ngo-1975, yaba yi-People's Republic of Mozambique msinyana ngemva kwalokho. Ngemva kweminyaka emibili kwaphela yokuzibusa, inarha le yangena epini yombango eyathatha isikhathi eside kusukela ngo-1977 ukuya ku-1992. Ngo-1994, i-Mozambique yenza amakhetho wayo wokuthoma weenhlangano ezinengi begodu solo ihlala iyiriphabliki yomengameli ezinzileko, nanyana isaqalene nobujamo obuphasi ukuvukela umbuso ngokuhlukileko eendaweni ezikude khulu ukusuka enhlokodolobha yesewula begodu lapho ubuSulumane bubusa khona.</text>
      <sha1>l393goh4okd57ddl7fwqyv126nt5wfk</sha1>
    </revision>
    <revision>
      <id>1801</id>
      <parentid>1800</parentid>
      <timestamp>2024-11-01T18:21:51Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1801</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1586" sha1="jbvb0d2ff7d6dh175rvj1ko9k91x20l" xml:space="preserve">'''I-Mozambiki,''' ngokusemthethweni ibizwa ngokuthi yi-Republic of Mozambique, yinarha etholakala ngeSewulapumalanga ye-[[Afrika]] enomngcele weLwandle le-India ngepumalanga, i-Tanzania ngetlhagwini, i-Malawi ne-Zambia ngetlhagwini-Tjingalanga, i-Zimbabwe ngeTjingalanga, kanye ne-[[Eswatini]] ne[[Isewula Afrika|Sewula Afrika]] ngeSewula-Tjingalanga. Umbuso ozijameleko uhlukaniswe ne-Comoros, i-Mayotte kanye ne-Madagascar yi-Mozambique Channel ngepumalanga. Ikomkhulu nedorobha elikhulu kunazo zoke yi-Maputo.

Hlangana nekhulu leminyaka lesi-7 ukuya kweli-11, kwakhiwa amadorobha amanengi wamatheku we-Swahili endaweni leyo, okwaba nomthelela ekuthuthukisweni kwesiko nelimi le-Swahili elihlukileko. Ekupheleni kwesikhathi se-medieval, amadorobha la bekavame ukuvakatjhelwa barhwebi abavela e-Somalia, e-Ethiopia, e-Egypt, e-Arabia, e-Persia, ne-India. Ikhambo laka-Vasco da Gama ngo-1498 laphawula ukufika kwamaPutukezi, athoma ikambiso kancanikancani yokubusa nokuhlala ngo-1505. Ngemva kwamakhulu amane weminyaka yokubusa kwamaPutukezi, i-Mozambique yathola ikululeko ngo-1975, yaba yi-People's Republic of Mozambique msinyana ngemva kwalokho. Ngemva kweminyaka emibili kwaphela yokuzibusa, inarha le yangena epini yombango eyathatha isikhathi eside kusukela ngo-1977 ukuya ku-1992. Ngo-1994, i-Mozambique yenza amakhetho wayo wokuthoma weenhlangano ezinengi begodu solo ihlala iyiriphabliki yomengameli ezinzileko, nanyana isaqalene nobujamo obuphasi ukuvukela umbuso ngokuhlukileko eendaweni ezikude khulu ukusuka enhlokodolobha yesewula begodu lapho ubuSulumane bubusa khona.</text>
      <sha1>jbvb0d2ff7d6dh175rvj1ko9k91x20l</sha1>
    </revision>
    <revision>
      <id>1802</id>
      <parentid>1801</parentid>
      <timestamp>2024-11-01T18:22:50Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1802</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1696" sha1="2iwh9c26ecrf7a4p57x2pr80fryx8zq" xml:space="preserve">'''I-Mozambiki,''' ngokusemthethweni ibizwa ngokuthi yi-Republic of Mozambique, yinarha etholakala ngeSewulapumalanga ye-[[Afrika]] enomngcele weLwandle le-India ngepumalanga, i-Tanzania ngetlhagwini, i-Malawi ne-Zambia ngetlhagwini-Tjingalanga, i-Zimbabwe ngeTjingalanga, kanye ne-[[Eswatini]] ne[[Isewula Afrika|Sewula Afrika]] ngeSewula-Tjingalanga. Umbuso ozijameleko uhlukaniswe ne-Comoros, i-Mayotte kanye ne-Madagascar yi-Mozambique Channel ngepumalanga. Ikomkhulu nedorobha elikhulu kunazo zoke yi-Maputo.&lt;ref&gt;https://clubofmozambique.com/news/mozambique-minister-of-industry-and-trade-visits-mozparks-269932/&lt;/ref&gt;

Hlangana nekhulu leminyaka lesi-7 ukuya kweli-11, kwakhiwa amadorobha amanengi wamatheku we-Swahili endaweni leyo, okwaba nomthelela ekuthuthukisweni kwesiko nelimi le-Swahili elihlukileko. Ekupheleni kwesikhathi se-medieval, amadorobha la bekavame ukuvakatjhelwa barhwebi abavela e-Somalia, e-Ethiopia, e-Egypt, e-Arabia, e-Persia, ne-India. Ikhambo laka-Vasco da Gama ngo-1498 laphawula ukufika kwamaPutukezi, athoma ikambiso kancanikancani yokubusa nokuhlala ngo-1505. Ngemva kwamakhulu amane weminyaka yokubusa kwamaPutukezi, i-Mozambique yathola ikululeko ngo-1975, yaba yi-People's Republic of Mozambique msinyana ngemva kwalokho. Ngemva kweminyaka emibili kwaphela yokuzibusa, inarha le yangena epini yombango eyathatha isikhathi eside kusukela ngo-1977 ukuya ku-1992. Ngo-1994, i-Mozambique yenza amakhetho wayo wokuthoma weenhlangano ezinengi begodu solo ihlala iyiriphabliki yomengameli ezinzileko, nanyana isaqalene nobujamo obuphasi ukuvukela umbuso ngokuhlukileko eendaweni ezikude khulu ukusuka enhlokodolobha yesewula begodu lapho ubuSulumane bubusa khona.</text>
      <sha1>2iwh9c26ecrf7a4p57x2pr80fryx8zq</sha1>
    </revision>
    <revision>
      <id>1803</id>
      <parentid>1802</parentid>
      <timestamp>2024-11-01T18:23:19Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1803</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1811" sha1="gwerf2kco2hzmwlsstcwq26lq1qeteu" xml:space="preserve">'''I-Mozambiki,''' ngokusemthethweni ibizwa ngokuthi yi-Republic of Mozambique, yinarha etholakala ngeSewulapumalanga ye-[[Afrika]] enomngcele weLwandle le-India ngepumalanga, i-Tanzania ngetlhagwini, i-Malawi ne-Zambia ngetlhagwini-Tjingalanga, i-Zimbabwe ngeTjingalanga, kanye ne-[[Eswatini]] ne[[Isewula Afrika|Sewula Afrika]] ngeSewula-Tjingalanga. Umbuso ozijameleko uhlukaniswe ne-Comoros, i-Mayotte kanye ne-Madagascar yi-Mozambique Channel ngepumalanga. Ikomkhulu nedorobha elikhulu kunazo zoke yi-Maputo.&lt;ref&gt;https://clubofmozambique.com/news/mozambique-minister-of-industry-and-trade-visits-mozparks-269932/&lt;/ref&gt;&lt;ref&gt;https://www.africanews.com/2024/10/31/post-election-protests-in-mozambique-leave-10-dead-dozens-injured/&lt;/ref&gt;

Hlangana nekhulu leminyaka lesi-7 ukuya kweli-11, kwakhiwa amadorobha amanengi wamatheku we-Swahili endaweni leyo, okwaba nomthelela ekuthuthukisweni kwesiko nelimi le-Swahili elihlukileko. Ekupheleni kwesikhathi se-medieval, amadorobha la bekavame ukuvakatjhelwa barhwebi abavela e-Somalia, e-Ethiopia, e-Egypt, e-Arabia, e-Persia, ne-India. Ikhambo laka-Vasco da Gama ngo-1498 laphawula ukufika kwamaPutukezi, athoma ikambiso kancanikancani yokubusa nokuhlala ngo-1505. Ngemva kwamakhulu amane weminyaka yokubusa kwamaPutukezi, i-Mozambique yathola ikululeko ngo-1975, yaba yi-People's Republic of Mozambique msinyana ngemva kwalokho. Ngemva kweminyaka emibili kwaphela yokuzibusa, inarha le yangena epini yombango eyathatha isikhathi eside kusukela ngo-1977 ukuya ku-1992. Ngo-1994, i-Mozambique yenza amakhetho wayo wokuthoma weenhlangano ezinengi begodu solo ihlala iyiriphabliki yomengameli ezinzileko, nanyana isaqalene nobujamo obuphasi ukuvukela umbuso ngokuhlukileko eendaweni ezikude khulu ukusuka enhlokodolobha yesewula begodu lapho ubuSulumane bubusa khona.</text>
      <sha1>gwerf2kco2hzmwlsstcwq26lq1qeteu</sha1>
    </revision>
    <revision>
      <id>1804</id>
      <parentid>1803</parentid>
      <timestamp>2024-11-01T18:23:55Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1804</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1896" sha1="nnl9b5omye3chclgf9db6rhxn9ubkwc" xml:space="preserve">'''I-Mozambiki,''' ngokusemthethweni ibizwa ngokuthi yi-Republic of Mozambique, yinarha etholakala ngeSewulapumalanga ye-[[Afrika]] enomngcele weLwandle le-India ngepumalanga, i-Tanzania ngetlhagwini, i-Malawi ne-Zambia ngetlhagwini-Tjingalanga, i-Zimbabwe ngeTjingalanga, kanye ne-[[Eswatini]] ne[[Isewula Afrika|Sewula Afrika]] ngeSewula-Tjingalanga. Umbuso ozijameleko uhlukaniswe ne-Comoros, i-Mayotte kanye ne-Madagascar yi-Mozambique Channel ngepumalanga. Ikomkhulu nedorobha elikhulu kunazo zoke yi-Maputo.&lt;ref&gt;https://clubofmozambique.com/news/mozambique-minister-of-industry-and-trade-visits-mozparks-269932/&lt;/ref&gt;&lt;ref&gt;https://www.africanews.com/2024/10/31/post-election-protests-in-mozambique-leave-10-dead-dozens-injured/&lt;/ref&gt;

Hlangana nekhulu leminyaka lesi-7 ukuya kweli-11, kwakhiwa amadorobha amanengi wamatheku we-Swahili endaweni leyo, okwaba nomthelela ekuthuthukisweni kwesiko nelimi le-Swahili elihlukileko. Ekupheleni kwesikhathi se-medieval, amadorobha la bekavame ukuvakatjhelwa barhwebi abavela e-Somalia, e-Ethiopia, e-Egypt, e-Arabia, e-Persia, ne-India. Ikhambo laka-Vasco da Gama ngo-1498 laphawula ukufika kwamaPutukezi, athoma ikambiso kancanikancani yokubusa nokuhlala ngo-1505. Ngemva kwamakhulu amane weminyaka yokubusa kwamaPutukezi, i-Mozambique yathola ikululeko ngo-1975, yaba yi-People's Republic of Mozambique msinyana ngemva kwalokho. Ngemva kweminyaka emibili kwaphela yokuzibusa, inarha le yangena epini yombango eyathatha isikhathi eside kusukela ngo-1977 ukuya ku-1992. Ngo-1994, i-Mozambique yenza amakhetho wayo wokuthoma weenhlangano ezinengi begodu solo ihlala iyiriphabliki yomengameli ezinzileko, nanyana isaqalene nobujamo obuphasi ukuvukela umbuso ngokuhlukileko eendaweni ezikude khulu ukusuka enhlokodolobha yesewula begodu lapho ubuSulumane bubusa khona.&lt;ref&gt;https://www.mozambique.co.za/About_Mozambique-travel/mozambique-facts.html&lt;/ref&gt;</text>
      <sha1>nnl9b5omye3chclgf9db6rhxn9ubkwc</sha1>
    </revision>
    <revision>
      <id>1805</id>
      <parentid>1804</parentid>
      <timestamp>2024-11-01T18:24:48Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1805</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1952" sha1="t1ti35el6pp2ie8skjmn3vybjvobfj2" xml:space="preserve">'''I-Mozambiki,''' ngokusemthethweni ibizwa ngokuthi yi-Republic of Mozambique, yinarha etholakala ngeSewulapumalanga ye-[[Afrika]] enomngcele weLwandle le-India ngepumalanga, i-Tanzania ngetlhagwini, i-Malawi ne-Zambia ngetlhagwini-Tjingalanga, i-Zimbabwe ngeTjingalanga, kanye ne-[[Eswatini]] ne[[Isewula Afrika|Sewula Afrika]] ngeSewula-Tjingalanga. Umbuso ozijameleko uhlukaniswe ne-Comoros, i-Mayotte kanye ne-Madagascar yi-Mozambique Channel ngepumalanga. Ikomkhulu nedorobha elikhulu kunazo zoke yi-Maputo.&lt;ref&gt;https://clubofmozambique.com/news/mozambique-minister-of-industry-and-trade-visits-mozparks-269932/&lt;/ref&gt;&lt;ref&gt;https://www.africanews.com/2024/10/31/post-election-protests-in-mozambique-leave-10-dead-dozens-injured/&lt;/ref&gt;

Hlangana nekhulu leminyaka lesi-7 ukuya kweli-11, kwakhiwa amadorobha amanengi wamatheku we-Swahili endaweni leyo, okwaba nomthelela ekuthuthukisweni kwesiko nelimi le-Swahili elihlukileko. Ekupheleni kwesikhathi se-medieval, amadorobha la bekavame ukuvakatjhelwa barhwebi abavela e-Somalia, e-Ethiopia, e-Egypt, e-Arabia, e-Persia, ne-India. Ikhambo laka-Vasco da Gama ngo-1498 laphawula ukufika kwamaPutukezi, athoma ikambiso kancanikancani yokubusa nokuhlala ngo-1505. Ngemva kwamakhulu amane weminyaka yokubusa kwamaPutukezi, i-Mozambique yathola ikululeko ngo-1975, yaba yi-People's Republic of Mozambique msinyana ngemva kwalokho. Ngemva kweminyaka emibili kwaphela yokuzibusa, inarha le yangena epini yombango eyathatha isikhathi eside kusukela ngo-1977 ukuya ku-1992. Ngo-1994, i-Mozambique yenza amakhetho wayo wokuthoma weenhlangano ezinengi begodu solo ihlala iyiriphabliki yomengameli ezinzileko, nanyana isaqalene nobujamo obuphasi ukuvukela umbuso ngokuhlukileko eendaweni ezikude khulu ukusuka enhlokodolobha yesewula begodu lapho ubuSulumane bubusa khona.&lt;ref&gt;https://www.mozambique.co.za/About_Mozambique-travel/mozambique-facts.html&lt;/ref&gt;

==Iinkomba==
{Reflist}}

[[Category: Iinarha Zephasi]]</text>
      <sha1>t1ti35el6pp2ie8skjmn3vybjvobfj2</sha1>
    </revision>
    <revision>
      <id>1812</id>
      <parentid>1805</parentid>
      <timestamp>2024-11-01T18:29:01Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>/* Iinkomba */</comment>
      <origin>1812</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1970" sha1="dmvpr88en0lihm9v1ra0wgflem7wqsb" xml:space="preserve">'''I-Mozambiki,''' ngokusemthethweni ibizwa ngokuthi yi-Republic of Mozambique, yinarha etholakala ngeSewulapumalanga ye-[[Afrika]] enomngcele weLwandle le-India ngepumalanga, i-Tanzania ngetlhagwini, i-Malawi ne-Zambia ngetlhagwini-Tjingalanga, i-Zimbabwe ngeTjingalanga, kanye ne-[[Eswatini]] ne[[Isewula Afrika|Sewula Afrika]] ngeSewula-Tjingalanga. Umbuso ozijameleko uhlukaniswe ne-Comoros, i-Mayotte kanye ne-Madagascar yi-Mozambique Channel ngepumalanga. Ikomkhulu nedorobha elikhulu kunazo zoke yi-Maputo.&lt;ref&gt;https://clubofmozambique.com/news/mozambique-minister-of-industry-and-trade-visits-mozparks-269932/&lt;/ref&gt;&lt;ref&gt;https://www.africanews.com/2024/10/31/post-election-protests-in-mozambique-leave-10-dead-dozens-injured/&lt;/ref&gt;

Hlangana nekhulu leminyaka lesi-7 ukuya kweli-11, kwakhiwa amadorobha amanengi wamatheku we-Swahili endaweni leyo, okwaba nomthelela ekuthuthukisweni kwesiko nelimi le-Swahili elihlukileko. Ekupheleni kwesikhathi se-medieval, amadorobha la bekavame ukuvakatjhelwa barhwebi abavela e-Somalia, e-Ethiopia, e-Egypt, e-Arabia, e-Persia, ne-India. Ikhambo laka-Vasco da Gama ngo-1498 laphawula ukufika kwamaPutukezi, athoma ikambiso kancanikancani yokubusa nokuhlala ngo-1505. Ngemva kwamakhulu amane weminyaka yokubusa kwamaPutukezi, i-Mozambique yathola ikululeko ngo-1975, yaba yi-People's Republic of Mozambique msinyana ngemva kwalokho. Ngemva kweminyaka emibili kwaphela yokuzibusa, inarha le yangena epini yombango eyathatha isikhathi eside kusukela ngo-1977 ukuya ku-1992. Ngo-1994, i-Mozambique yenza amakhetho wayo wokuthoma weenhlangano ezinengi begodu solo ihlala iyiriphabliki yomengameli ezinzileko, nanyana isaqalene nobujamo obuphasi ukuvukela umbuso ngokuhlukileko eendaweni ezikude khulu ukusuka enhlokodolobha yesewula begodu lapho ubuSulumane bubusa khona.&lt;ref&gt;https://www.mozambique.co.za/About_Mozambique-travel/mozambique-facts.html&lt;/ref&gt;

==Iinkomba==
&lt;nowiki&gt;{{Reflist}}&lt;/nowiki&gt;

[[Category: Iinarha Zephasi]]</text>
      <sha1>dmvpr88en0lihm9v1ra0wgflem7wqsb</sha1>
    </revision>
    <revision>
      <id>1813</id>
      <parentid>1812</parentid>
      <timestamp>2024-11-01T18:29:19Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>/* Iinkomba */</comment>
      <origin>1813</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1953" sha1="2lw98pq7biojkhd1r49htcmrkoe1148" xml:space="preserve">'''I-Mozambiki,''' ngokusemthethweni ibizwa ngokuthi yi-Republic of Mozambique, yinarha etholakala ngeSewulapumalanga ye-[[Afrika]] enomngcele weLwandle le-India ngepumalanga, i-Tanzania ngetlhagwini, i-Malawi ne-Zambia ngetlhagwini-Tjingalanga, i-Zimbabwe ngeTjingalanga, kanye ne-[[Eswatini]] ne[[Isewula Afrika|Sewula Afrika]] ngeSewula-Tjingalanga. Umbuso ozijameleko uhlukaniswe ne-Comoros, i-Mayotte kanye ne-Madagascar yi-Mozambique Channel ngepumalanga. Ikomkhulu nedorobha elikhulu kunazo zoke yi-Maputo.&lt;ref&gt;https://clubofmozambique.com/news/mozambique-minister-of-industry-and-trade-visits-mozparks-269932/&lt;/ref&gt;&lt;ref&gt;https://www.africanews.com/2024/10/31/post-election-protests-in-mozambique-leave-10-dead-dozens-injured/&lt;/ref&gt;

Hlangana nekhulu leminyaka lesi-7 ukuya kweli-11, kwakhiwa amadorobha amanengi wamatheku we-Swahili endaweni leyo, okwaba nomthelela ekuthuthukisweni kwesiko nelimi le-Swahili elihlukileko. Ekupheleni kwesikhathi se-medieval, amadorobha la bekavame ukuvakatjhelwa barhwebi abavela e-Somalia, e-Ethiopia, e-Egypt, e-Arabia, e-Persia, ne-India. Ikhambo laka-Vasco da Gama ngo-1498 laphawula ukufika kwamaPutukezi, athoma ikambiso kancanikancani yokubusa nokuhlala ngo-1505. Ngemva kwamakhulu amane weminyaka yokubusa kwamaPutukezi, i-Mozambique yathola ikululeko ngo-1975, yaba yi-People's Republic of Mozambique msinyana ngemva kwalokho. Ngemva kweminyaka emibili kwaphela yokuzibusa, inarha le yangena epini yombango eyathatha isikhathi eside kusukela ngo-1977 ukuya ku-1992. Ngo-1994, i-Mozambique yenza amakhetho wayo wokuthoma weenhlangano ezinengi begodu solo ihlala iyiriphabliki yomengameli ezinzileko, nanyana isaqalene nobujamo obuphasi ukuvukela umbuso ngokuhlukileko eendaweni ezikude khulu ukusuka enhlokodolobha yesewula begodu lapho ubuSulumane bubusa khona.&lt;ref&gt;https://www.mozambique.co.za/About_Mozambique-travel/mozambique-facts.html&lt;/ref&gt;

==Iinkomba==
{{Reflist}}

[[Category: Iinarha Zephasi]]</text>
      <sha1>2lw98pq7biojkhd1r49htcmrkoe1148</sha1>
    </revision>
    <revision>
      <id>1814</id>
      <parentid>1813</parentid>
      <timestamp>2024-11-01T18:29:34Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1814</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1951" sha1="7of2ppfp5raxpjbw7folwtrj210onqs" xml:space="preserve">'''I-Mozambiki,''' ngokusemthethweni ibizwa ngokuthi yi-Republic of Mozambique, yinarha etholakala ngeSewulapumalanga ye-[[Afrika]] enomngcele weLwandle le-India ngepumalanga, i-Tanzania ngetlhagwini, i-Malawi ne-Zambia ngetlhagwini-Tjingalanga, i-Zimbabwe ngeTjingalanga, kanye ne-[[Eswatini]] ne[[Isewula Afrika|Sewula Afrika]] ngeSewula-Tjingalanga. Umbuso ozijameleko uhlukaniswe ne-Comoros, i-Mayotte kanye ne-Madagascar yi-Mozambique Channel ngepumalanga. Ikomkhulu nedorobha elikhulu kunazo zoke yi-Maputo.&lt;ref&gt;https://clubofmozambique.com/news/mozambique-minister-of-industry-and-trade-visits-mozparks-269932/&lt;/ref&gt;&lt;ref&gt;https://www.africanews.com/2024/10/31/post-election-protests-in-mozambique-leave-10-dead-dozens-injured/&lt;/ref&gt;

Hlangana nekhulu leminyaka lesi-7 ukuya kweli-11, kwakhiwa amadorobha amanengi wamatheku we-Swahili endaweni leyo, okwaba nomthelela ekuthuthukisweni kwesiko nelimi le-Swahili elihlukileko. Ekupheleni kwesikhathi se-medieval, amadorobha la bekavame ukuvakatjhelwa barhwebi abavela e-Somalia, e-Ethiopia, e-Egypt, e-Arabia, e-Persia, ne-India. Ikhambo laka-Vasco da Gama ngo-1498 laphawula ukufika kwamaPutukezi, athoma ikambiso kancanikancani yokubusa nokuhlala ngo-1505. Ngemva kwamakhulu amane weminyaka yokubusa kwamaPutukezi, i-Mozambique yathola ikululeko ngo-1975, yaba yi-People's Republic of Mozambique msinyana ngemva kwalokho. Ngemva kweminyaka emibili kwaphela yokuzibusa, inarha le yangena epini yombango eyathatha isikhathi eside kusukela ngo-1977 ukuya ku-1992. Ngo-1994, i-Mozambique yenza amakhetho wayo wokuthoma weenhlangano ezinengi begodu solo ihlala iyiriphabliki yomengameli ezinzileko, nanyana isaqalene nobujamo obuphasi ukuvukela umbuso ngokuhlukileko eendaweni ezikude khulu ukusuka enhlokodolobha yesewula begodu lapho ubuSulumane bubusa khona.&lt;ref&gt;https://www.mozambique.co.za/About_Mozambique-travel/mozambique-facts.html&lt;/ref&gt;

==Iinkomba==
{{Reflist}}
[[Category:Iinarha zephasi]]</text>
      <sha1>7of2ppfp5raxpjbw7folwtrj210onqs</sha1>
    </revision>
    <revision>
      <id>1817</id>
      <parentid>1814</parentid>
      <timestamp>2024-11-01T18:31:03Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1817</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1955" sha1="jqgsgrf72q9de5r1ylyf2icpax72g3q" xml:space="preserve">'''I-Mozambiki,''' ngokusemthethweni ibizwa ngokuthi yi-Republic of Mozambique, yinarha etholakala ngeSewulapumalanga ye-[[Afrika]] enomngcele weLwandle le-India ngepumalanga, i-Tanzania ngetlhagwini, i-Malawi ne-Zambia ngetlhagwini-Tjingalanga, i-Zimbabwe ngeTjingalanga, kanye ne-[[Eswatini]] ne[[Isewula Afrika|Sewula Afrika]] ngeSewula-Tjingalanga. Umbuso ozijameleko uhlukaniswe ne-Comoros, i-Mayotte kanye ne-Madagascar yi-Mozambique Channel ngepumalanga. Ikomkhulu nedorobha elikhulu kunazo zoke yi-Maputo.&lt;ref&gt;https://clubofmozambique.com/news/mozambique-minister-of-industry-and-trade-visits-mozparks-269932/&lt;/ref&gt;&lt;ref&gt;https://www.africanews.com/2024/10/31/post-election-protests-in-mozambique-leave-10-dead-dozens-injured/&lt;/ref&gt;

Hlangana nekhulu leminyaka lesi-7 ukuya kweli-11, kwakhiwa amadorobha amanengi wamatheku we-Swahili endaweni leyo, okwaba nomthelela ekuthuthukisweni kwesiko nelimi le-Swahili elihlukileko. Ekupheleni kwesikhathi se-medieval, amadorobha la bekavame ukuvakatjhelwa barhwebi abavela [[e-Somalia]], e-Ethiopia, e-Egypt, e-Arabia, e-Persia, ne-India. Ikhambo laka-Vasco da Gama ngo-1498 laphawula ukufika kwamaPutukezi, athoma ikambiso kancanikancani yokubusa nokuhlala ngo-1505. Ngemva kwamakhulu amane weminyaka yokubusa kwamaPutukezi, i-Mozambique yathola ikululeko ngo-1975, yaba yi-People's Republic of Mozambique msinyana ngemva kwalokho. Ngemva kweminyaka emibili kwaphela yokuzibusa, inarha le yangena epini yombango eyathatha isikhathi eside kusukela ngo-1977 ukuya ku-1992. Ngo-1994, i-Mozambique yenza amakhetho wayo wokuthoma weenhlangano ezinengi begodu solo ihlala iyiriphabliki yomengameli ezinzileko, nanyana isaqalene nobujamo obuphasi ukuvukela umbuso ngokuhlukileko eendaweni ezikude khulu ukusuka enhlokodolobha yesewula begodu lapho ubuSulumane bubusa khona.&lt;ref&gt;https://www.mozambique.co.za/About_Mozambique-travel/mozambique-facts.html&lt;/ref&gt;

==Iinkomba==
{{Reflist}}
[[Category:Iinarha zephasi]]</text>
      <sha1>jqgsgrf72q9de5r1ylyf2icpax72g3q</sha1>
    </revision>
    <revision>
      <id>1818</id>
      <parentid>1817</parentid>
      <timestamp>2024-11-01T18:31:21Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1818</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1959" sha1="s550so9694frtlzxldanyaqv67lduym" xml:space="preserve">'''I-Mozambiki,''' ngokusemthethweni ibizwa ngokuthi yi-Republic of Mozambique, yinarha etholakala ngeSewulapumalanga ye-[[Afrika]] enomngcele weLwandle le-India ngepumalanga, i-Tanzania ngetlhagwini, i-Malawi ne-Zambia ngetlhagwini-Tjingalanga, i-Zimbabwe ngeTjingalanga, kanye ne-[[Eswatini]] ne[[Isewula Afrika|Sewula Afrika]] ngeSewula-Tjingalanga. Umbuso ozijameleko uhlukaniswe ne-Comoros, i-Mayotte kanye ne-Madagascar yi-Mozambique Channel ngepumalanga. Ikomkhulu nedorobha elikhulu kunazo zoke yi-Maputo.&lt;ref&gt;https://clubofmozambique.com/news/mozambique-minister-of-industry-and-trade-visits-mozparks-269932/&lt;/ref&gt;&lt;ref&gt;https://www.africanews.com/2024/10/31/post-election-protests-in-mozambique-leave-10-dead-dozens-injured/&lt;/ref&gt;

Hlangana nekhulu leminyaka lesi-7 ukuya kweli-11, kwakhiwa amadorobha amanengi wamatheku we-Swahili endaweni leyo, okwaba nomthelela ekuthuthukisweni kwesiko nelimi le-Swahili elihlukileko. Ekupheleni kwesikhathi se-medieval, amadorobha la bekavame ukuvakatjhelwa barhwebi abavela [[e-Somalia]], [[e-Ethiopia]], e-Egypt, e-Arabia, e-Persia, ne-India. Ikhambo laka-Vasco da Gama ngo-1498 laphawula ukufika kwamaPutukezi, athoma ikambiso kancanikancani yokubusa nokuhlala ngo-1505. Ngemva kwamakhulu amane weminyaka yokubusa kwamaPutukezi, i-Mozambique yathola ikululeko ngo-1975, yaba yi-People's Republic of Mozambique msinyana ngemva kwalokho. Ngemva kweminyaka emibili kwaphela yokuzibusa, inarha le yangena epini yombango eyathatha isikhathi eside kusukela ngo-1977 ukuya ku-1992. Ngo-1994, i-Mozambique yenza amakhetho wayo wokuthoma weenhlangano ezinengi begodu solo ihlala iyiriphabliki yomengameli ezinzileko, nanyana isaqalene nobujamo obuphasi ukuvukela umbuso ngokuhlukileko eendaweni ezikude khulu ukusuka enhlokodolobha yesewula begodu lapho ubuSulumane bubusa khona.&lt;ref&gt;https://www.mozambique.co.za/About_Mozambique-travel/mozambique-facts.html&lt;/ref&gt;

==Iinkomba==
{{Reflist}}
[[Category:Iinarha zephasi]]</text>
      <sha1>s550so9694frtlzxldanyaqv67lduym</sha1>
    </revision>
    <revision>
      <id>1860</id>
      <parentid>1818</parentid>
      <timestamp>2024-11-01T19:11:05Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1860</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1963" sha1="3mwv4h7ze8e3tlv4hruc83ofwztv2ty" xml:space="preserve">'''I-Mozambiki,''' ngokusemthethweni ibizwa ngokuthi yi-Republic of Mozambique, yinarha etholakala ngeSewulapumalanga ye-[[Afrika]] enomngcele weLwandle le-India ngepumalanga, i-Tanzania ngetlhagwini, i-Malawi ne-Zambia ngetlhagwini-Tjingalanga, i-Zimbabwe ngeTjingalanga, kanye ne-[[Eswatini]] ne[[Isewula Afrika|Sewula Afrika]] ngeSewula-Tjingalanga. Umbuso ozijameleko uhlukaniswe ne-Comoros, i-Mayotte kanye ne-Madagascar yi-Mozambique Channel ngepumalanga. Ikomkhulu nedorobha elikhulu kunazo zoke yi-[[Maputo.]]&lt;ref&gt;https://clubofmozambique.com/news/mozambique-minister-of-industry-and-trade-visits-mozparks-269932/&lt;/ref&gt;&lt;ref&gt;https://www.africanews.com/2024/10/31/post-election-protests-in-mozambique-leave-10-dead-dozens-injured/&lt;/ref&gt;

Hlangana nekhulu leminyaka lesi-7 ukuya kweli-11, kwakhiwa amadorobha amanengi wamatheku we-Swahili endaweni leyo, okwaba nomthelela ekuthuthukisweni kwesiko nelimi le-Swahili elihlukileko. Ekupheleni kwesikhathi se-medieval, amadorobha la bekavame ukuvakatjhelwa barhwebi abavela [[e-Somalia]], [[e-Ethiopia]], e-Egypt, e-Arabia, e-Persia, ne-India. Ikhambo laka-Vasco da Gama ngo-1498 laphawula ukufika kwamaPutukezi, athoma ikambiso kancanikancani yokubusa nokuhlala ngo-1505. Ngemva kwamakhulu amane weminyaka yokubusa kwamaPutukezi, i-Mozambique yathola ikululeko ngo-1975, yaba yi-People's Republic of Mozambique msinyana ngemva kwalokho. Ngemva kweminyaka emibili kwaphela yokuzibusa, inarha le yangena epini yombango eyathatha isikhathi eside kusukela ngo-1977 ukuya ku-1992. Ngo-1994, i-Mozambique yenza amakhetho wayo wokuthoma weenhlangano ezinengi begodu solo ihlala iyiriphabliki yomengameli ezinzileko, nanyana isaqalene nobujamo obuphasi ukuvukela umbuso ngokuhlukileko eendaweni ezikude khulu ukusuka enhlokodolobha yesewula begodu lapho ubuSulumane bubusa khona.&lt;ref&gt;https://www.mozambique.co.za/About_Mozambique-travel/mozambique-facts.html&lt;/ref&gt;

==Iinkomba==
{{Reflist}}
[[Category:Iinarha zephasi]]</text>
      <sha1>3mwv4h7ze8e3tlv4hruc83ofwztv2ty</sha1>
    </revision>
    <revision>
      <id>2199</id>
      <parentid>1860</parentid>
      <timestamp>2024-11-29T07:24:05Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <comment>/* Iinkomba */Mkhakha</comment>
      <origin>2199</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1963" sha1="0uzc8hoevbl4b5s6fb9bzay9xj62f9s" xml:space="preserve">'''I-Mozambiki,''' ngokusemthethweni ibizwa ngokuthi yi-Republic of Mozambique, yinarha etholakala ngeSewulapumalanga ye-[[Afrika]] enomngcele weLwandle le-India ngepumalanga, i-Tanzania ngetlhagwini, i-Malawi ne-Zambia ngetlhagwini-Tjingalanga, i-Zimbabwe ngeTjingalanga, kanye ne-[[Eswatini]] ne[[Isewula Afrika|Sewula Afrika]] ngeSewula-Tjingalanga. Umbuso ozijameleko uhlukaniswe ne-Comoros, i-Mayotte kanye ne-Madagascar yi-Mozambique Channel ngepumalanga. Ikomkhulu nedorobha elikhulu kunazo zoke yi-[[Maputo.]]&lt;ref&gt;https://clubofmozambique.com/news/mozambique-minister-of-industry-and-trade-visits-mozparks-269932/&lt;/ref&gt;&lt;ref&gt;https://www.africanews.com/2024/10/31/post-election-protests-in-mozambique-leave-10-dead-dozens-injured/&lt;/ref&gt;

Hlangana nekhulu leminyaka lesi-7 ukuya kweli-11, kwakhiwa amadorobha amanengi wamatheku we-Swahili endaweni leyo, okwaba nomthelela ekuthuthukisweni kwesiko nelimi le-Swahili elihlukileko. Ekupheleni kwesikhathi se-medieval, amadorobha la bekavame ukuvakatjhelwa barhwebi abavela [[e-Somalia]], [[e-Ethiopia]], e-Egypt, e-Arabia, e-Persia, ne-India. Ikhambo laka-Vasco da Gama ngo-1498 laphawula ukufika kwamaPutukezi, athoma ikambiso kancanikancani yokubusa nokuhlala ngo-1505. Ngemva kwamakhulu amane weminyaka yokubusa kwamaPutukezi, i-Mozambique yathola ikululeko ngo-1975, yaba yi-People's Republic of Mozambique msinyana ngemva kwalokho. Ngemva kweminyaka emibili kwaphela yokuzibusa, inarha le yangena epini yombango eyathatha isikhathi eside kusukela ngo-1977 ukuya ku-1992. Ngo-1994, i-Mozambique yenza amakhetho wayo wokuthoma weenhlangano ezinengi begodu solo ihlala iyiriphabliki yomengameli ezinzileko, nanyana isaqalene nobujamo obuphasi ukuvukela umbuso ngokuhlukileko eendaweni ezikude khulu ukusuka enhlokodolobha yesewula begodu lapho ubuSulumane bubusa khona.&lt;ref&gt;https://www.mozambique.co.za/About_Mozambique-travel/mozambique-facts.html&lt;/ref&gt;

==Iinkomba==
{{Reflist}}

[[Mkhakha:Iinarha zephasi]]</text>
      <sha1>0uzc8hoevbl4b5s6fb9bzay9xj62f9s</sha1>
    </revision>
    <revision>
      <id>5554</id>
      <parentid>2199</parentid>
      <timestamp>2025-09-04T09:38:48Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <comment>Removed dead links</comment>
      <origin>5554</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1951" sha1="8vzb0neht619qmfg3ozarw8qgbsi56k" xml:space="preserve">'''I-Mozambiki,''' ngokusemthethweni ibizwa ngokuthi yi-Republic of Mozambique, yinarha etholakala ngeSewulapumalanga ye-[[Afrika]] enomngcele weLwandle le-India ngepumalanga, i-Tanzania ngetlhagwini, i-Malawi ne-Zambia ngetlhagwini-Tjingalanga, i-Zimbabwe ngeTjingalanga, kanye ne-[[Eswatini]] ne[[Isewula Afrika|Sewula Afrika]] ngeSewula-Tjingalanga. Umbuso ozijameleko uhlukaniswe ne-Comoros, i-Mayotte kanye ne-Madagascar yi-Mozambique Channel ngepumalanga. Ikomkhulu nedorobha elikhulu kunazo zoke yi-Maputo.&lt;ref&gt;https://clubofmozambique.com/news/mozambique-minister-of-industry-and-trade-visits-mozparks-269932/&lt;/ref&gt;&lt;ref&gt;https://www.africanews.com/2024/10/31/post-election-protests-in-mozambique-leave-10-dead-dozens-injured/&lt;/ref&gt;

Hlangana nekhulu leminyaka lesi-7 ukuya kweli-11, kwakhiwa amadorobha amanengi wamatheku we-Swahili endaweni leyo, okwaba nomthelela ekuthuthukisweni kwesiko nelimi le-Swahili elihlukileko. Ekupheleni kwesikhathi se-medieval, amadorobha la bekavame ukuvakatjhelwa barhwebi abavela e-Somalia, e-Ethiopia, e-Egypt, e-Arabia, e-Persia, ne-India. Ikhambo laka-Vasco da Gama ngo-1498 laphawula ukufika kwamaPutukezi, athoma ikambiso kancanikancani yokubusa nokuhlala ngo-1505. Ngemva kwamakhulu amane weminyaka yokubusa kwamaPutukezi, i-Mozambique yathola ikululeko ngo-1975, yaba yi-People's Republic of Mozambique msinyana ngemva kwalokho. Ngemva kweminyaka emibili kwaphela yokuzibusa, inarha le yangena epini yombango eyathatha isikhathi eside kusukela ngo-1977 ukuya ku-1992. Ngo-1994, i-Mozambique yenza amakhetho wayo wokuthoma weenhlangano ezinengi begodu solo ihlala iyiriphabliki yomengameli ezinzileko, nanyana isaqalene nobujamo obuphasi ukuvukela umbuso ngokuhlukileko eendaweni ezikude khulu ukusuka enhlokodolobha yesewula begodu lapho ubuSulumane bubusa khona.&lt;ref&gt;https://www.mozambique.co.za/About_Mozambique-travel/mozambique-facts.html&lt;/ref&gt;

==Iinkomba==
{{Reflist}}

[[Mkhakha:Iinarha zephasi]]</text>
      <sha1>8vzb0neht619qmfg3ozarw8qgbsi56k</sha1>
    </revision>
    <revision>
      <id>5698</id>
      <parentid>5554</parentid>
      <timestamp>2025-09-04T22:07:34Z</timestamp>
      <contributor>
        <username>Ick567</username>
        <id>910</id>
      </contributor>
      <origin>5698</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1955" sha1="1895hhw9per6knv9pm1gnaxq08u1dbo" xml:space="preserve">'''I-Mozambiki,''' ngokusemthethweni ibizwa ngokuthi yi-Republic of Mozambique, yinarha etholakala ngeSewulapumalanga ye-[[Afrika]] enomngcele weLwandle le-India ngepumalanga, i-Tanzania ngetlhagwini, i-Malawi ne-Zambia ngetlhagwini-Tjingalanga, i-[[Zimbabwe]] ngeTjingalanga, kanye ne-[[Eswatini]] ne[[Isewula Afrika|Sewula Afrika]] ngeSewula-Tjingalanga. Umbuso ozijameleko uhlukaniswe ne-Comoros, i-Mayotte kanye ne-Madagascar yi-Mozambique Channel ngepumalanga. Ikomkhulu nedorobha elikhulu kunazo zoke yi-Maputo.&lt;ref&gt;https://clubofmozambique.com/news/mozambique-minister-of-industry-and-trade-visits-mozparks-269932/&lt;/ref&gt;&lt;ref&gt;https://www.africanews.com/2024/10/31/post-election-protests-in-mozambique-leave-10-dead-dozens-injured/&lt;/ref&gt;

Hlangana nekhulu leminyaka lesi-7 ukuya kweli-11, kwakhiwa amadorobha amanengi wamatheku we-Swahili endaweni leyo, okwaba nomthelela ekuthuthukisweni kwesiko nelimi le-Swahili elihlukileko. Ekupheleni kwesikhathi se-medieval, amadorobha la bekavame ukuvakatjhelwa barhwebi abavela e-Somalia, e-Ethiopia, e-Egypt, e-Arabia, e-Persia, ne-India. Ikhambo laka-Vasco da Gama ngo-1498 laphawula ukufika kwamaPutukezi, athoma ikambiso kancanikancani yokubusa nokuhlala ngo-1505. Ngemva kwamakhulu amane weminyaka yokubusa kwamaPutukezi, i-Mozambique yathola ikululeko ngo-1975, yaba yi-People's Republic of Mozambique msinyana ngemva kwalokho. Ngemva kweminyaka emibili kwaphela yokuzibusa, inarha le yangena epini yombango eyathatha isikhathi eside kusukela ngo-1977 ukuya ku-1992. Ngo-1994, i-Mozambique yenza amakhetho wayo wokuthoma weenhlangano ezinengi begodu solo ihlala iyiriphabliki yomengameli ezinzileko, nanyana isaqalene nobujamo obuphasi ukuvukela umbuso ngokuhlukileko eendaweni ezikude khulu ukusuka enhlokodolobha yesewula begodu lapho ubuSulumane bubusa khona.&lt;ref&gt;https://www.mozambique.co.za/About_Mozambique-travel/mozambique-facts.html&lt;/ref&gt;

==Iinkomba==
{{Reflist}}

[[Mkhakha:Iinarha zephasi]]</text>
      <sha1>1895hhw9per6knv9pm1gnaxq08u1dbo</sha1>
    </revision>
  </page>
  <page>
    <title>Afrika</title>
    <ns>0</ns>
    <id>349</id>
    <redirect title="I-Afrika" />
    <revision>
      <id>1810</id>
      <timestamp>2024-11-01T18:27:39Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Bobbyshabangu moved page [[Afrika]] to [[I-Afrika]]</comment>
      <origin>1810</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="22" sha1="psq59hsq3xnz8oih2ax3a9jdiwar5r8" xml:space="preserve">#REDIRECT [[I-Afrika]]</text>
      <sha1>psq59hsq3xnz8oih2ax3a9jdiwar5r8</sha1>
    </revision>
  </page>
  <page>
    <title>Burkina Faso</title>
    <ns>0</ns>
    <id>350</id>
    <revision>
      <id>1820</id>
      <timestamp>2024-11-01T18:33:45Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created page with &quot;'''I-Burkina Faso,''' yinarha enganamanzi eTjingalanga ye-[[I-Afrika|Afrika]], enomngcele we-Mali ngetlhagwini-Tjingalanga, i-Niger ngeTlhagwini-pumalanga, i-Benin ngesewulapumalanga, i-Togo ne-Ghana ngesewula, kanye ne-Ivory Coast ngeSewula-Tjingalanga. Ihlanganisa indawo engama-274,223 km2 (105,878 sq mi). Ngomnyaka ka-2021, inarha gade inabantu abangaba ma-23,674,480.[14] Ngaphambilini beyibizwa ngokuthi yi-Republic of Upper Volta (1958–1984), yabizwa kabutjha ngoku...&quot;</comment>
      <origin>1820</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1377" sha1="k4q47d68kkw0inn3rsxv23zudj4knt8" xml:space="preserve">'''I-Burkina Faso,''' yinarha enganamanzi eTjingalanga ye-[[I-Afrika|Afrika]], enomngcele we-Mali ngetlhagwini-Tjingalanga, i-Niger ngeTlhagwini-pumalanga, i-Benin ngesewulapumalanga, i-Togo ne-Ghana ngesewula, kanye ne-Ivory Coast ngeSewula-Tjingalanga. Ihlanganisa indawo engama-274,223 km2 (105,878 sq mi). Ngomnyaka ka-2021, inarha gade inabantu abangaba ma-23,674,480.[14] Ngaphambilini beyibizwa ngokuthi yi-Republic of Upper Volta (1958–1984), yabizwa kabutjha ngokuthi yi-Burkina Faso ngumongameli wangaphambilini u-Thomas Sankara. Izakhamuzi zayo zaziwa ngokuthi yi-Burkinabè,[b] begodu ikomkhulu layo nedorobha elikhulu yi-Ouagadougou.

Isitjhaba esikhulu khulu e-Burkina Faso babantu be-Mossi, abahlala endaweni leyo ngekhulu le-11 nele-13. Basungula imibuso enamandla njenge-Ouagadougou, i-Tenkodogo, ne-Yatenga. Ngo-1896, yathathwa njengekoloni ngamaFulentshi njengengcenye ye-French West Africa; ngo-1958, i-Upper Volta yaba yikoloni ezizibusako ngaphakathi kwe-French Community. Ngo-1960, yathola ikululeko epheleleko ngo-Maurice Yaméogo njengomengameli. Solo yathola itjhaphuluko yayo, inarha le sele iqalene nokungazinzi, isomiso, indlala nekohlakalo. Kube nokuvukela umbuso okuhlukahlukeneko, ngo-1966, 1980, 1982, 1983, 1987, begodu kabili ngo-2022 (ngoTjhirhweni noNobayeni). Kwaba nemizamo yokuvukela umbuso engaphumelelanga ngo-1989, 2015, nango-2023.</text>
      <sha1>k4q47d68kkw0inn3rsxv23zudj4knt8</sha1>
    </revision>
    <revision>
      <id>1821</id>
      <parentid>1820</parentid>
      <timestamp>2024-11-01T18:34:05Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1821</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1377" sha1="hu9k7qtdl30hyn8l84erxjkk1hy7gwd" xml:space="preserve">'''I-Burkina Faso,''' yinarha enganamanzi eTjingalanga ye-[[I-Afrika|Afrika]], enomngcele we-Mali ngetlhagwini-Tjingalanga, i-Niger ngeTlhagwini-pumalanga, i-Benin ngesewulapumalanga, i-Togo ne-[[Ghana]] ngesewula, kanye ne-Ivory Coast ngeSewula-Tjingalanga. Ihlanganisa indawo engama-274,223 km2 (105,878 sq mi). Ngomnyaka ka-2021, inarha gade inabantu abangaba ma-23,674,480. Ngaphambilini beyibizwa ngokuthi yi-Republic of Upper Volta (1958–1984), yabizwa kabutjha ngokuthi yi-Burkina Faso ngumongameli wangaphambilini u-Thomas Sankara. Izakhamuzi zayo zaziwa ngokuthi yi-Burkinabè,[b] begodu ikomkhulu layo nedorobha elikhulu yi-Ouagadougou.

Isitjhaba esikhulu khulu e-Burkina Faso babantu be-Mossi, abahlala endaweni leyo ngekhulu le-11 nele-13. Basungula imibuso enamandla njenge-Ouagadougou, i-Tenkodogo, ne-Yatenga. Ngo-1896, yathathwa njengekoloni ngamaFulentshi njengengcenye ye-French West Africa; ngo-1958, i-Upper Volta yaba yikoloni ezizibusako ngaphakathi kwe-French Community. Ngo-1960, yathola ikululeko epheleleko ngo-Maurice Yaméogo njengomengameli. Solo yathola itjhaphuluko yayo, inarha le sele iqalene nokungazinzi, isomiso, indlala nekohlakalo. Kube nokuvukela umbuso okuhlukahlukeneko, ngo-1966, 1980, 1982, 1983, 1987, begodu kabili ngo-2022 (ngoTjhirhweni noNobayeni). Kwaba nemizamo yokuvukela umbuso engaphumelelanga ngo-1989, 2015, nango-2023.</text>
      <sha1>hu9k7qtdl30hyn8l84erxjkk1hy7gwd</sha1>
    </revision>
    <revision>
      <id>1822</id>
      <parentid>1821</parentid>
      <timestamp>2024-11-01T18:34:19Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1822</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1381" sha1="ipmrl715dwq1fff6qabcmqcugaxryle" xml:space="preserve">'''I-Burkina Faso,''' yinarha enganamanzi eTjingalanga ye-[[I-Afrika|Afrika]], enomngcele we-Mali ngetlhagwini-Tjingalanga, i-Niger ngeTlhagwini-pumalanga, i-Benin ngesewulapumalanga, i-[[Togo]] ne-[[Ghana]] ngesewula, kanye ne-Ivory Coast ngeSewula-Tjingalanga. Ihlanganisa indawo engama-274,223 km2 (105,878 sq mi). Ngomnyaka ka-2021, inarha gade inabantu abangaba ma-23,674,480. Ngaphambilini beyibizwa ngokuthi yi-Republic of Upper Volta (1958–1984), yabizwa kabutjha ngokuthi yi-Burkina Faso ngumongameli wangaphambilini u-Thomas Sankara. Izakhamuzi zayo zaziwa ngokuthi yi-Burkinabè,[b] begodu ikomkhulu layo nedorobha elikhulu yi-Ouagadougou.

Isitjhaba esikhulu khulu e-Burkina Faso babantu be-Mossi, abahlala endaweni leyo ngekhulu le-11 nele-13. Basungula imibuso enamandla njenge-Ouagadougou, i-Tenkodogo, ne-Yatenga. Ngo-1896, yathathwa njengekoloni ngamaFulentshi njengengcenye ye-French West Africa; ngo-1958, i-Upper Volta yaba yikoloni ezizibusako ngaphakathi kwe-French Community. Ngo-1960, yathola ikululeko epheleleko ngo-Maurice Yaméogo njengomengameli. Solo yathola itjhaphuluko yayo, inarha le sele iqalene nokungazinzi, isomiso, indlala nekohlakalo. Kube nokuvukela umbuso okuhlukahlukeneko, ngo-1966, 1980, 1982, 1983, 1987, begodu kabili ngo-2022 (ngoTjhirhweni noNobayeni). Kwaba nemizamo yokuvukela umbuso engaphumelelanga ngo-1989, 2015, nango-2023.</text>
      <sha1>ipmrl715dwq1fff6qabcmqcugaxryle</sha1>
    </revision>
    <revision>
      <id>1823</id>
      <parentid>1822</parentid>
      <timestamp>2024-11-01T18:34:56Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1823</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1397" sha1="nzt7naksdz91jo9rbwanp5j926xc5fs" xml:space="preserve">'''I-Burkina Faso,''' yinarha enganamanzi eTjingalanga ye-[[I-Afrika|Afrika]], enomngcele we-Mali ngetlhagwini-Tjingalanga, i-Niger ngeTlhagwini-pumalanga, i-Benin ngesewulapumalanga, i-[[Togo]] ne-[[Ghana]] ngesewula, kanye ne-Ivory Coast ngeSewula-Tjingalanga. Ihlanganisa indawo engama-274,223 km2 (105,878 sq mi). Ngomnyaka ka-2021, inarha gade inabantu abangaba ma-23,674,480. Ngaphambilini beyibizwa ngokuthi yi-Republic of Upper Volta (1958–1984), yabizwa kabutjha ngokuthi yi-Burkina Faso ngumongameli wangaphambilini u-Thomas Sankara. Izakhamuzi zayo zaziwa ngokuthi yi-Burkinabè,[b] begodu ikomkhulu layo nedorobha elikhulu yi-Ouagadougou.

Isitjhaba esikhulu khulu e-Burkina Faso babantu be-Mossi, abahlala endaweni leyo ngekhulu le-11 nele-13. Basungula imibuso enamandla njenge-Ouagadougou, i-Tenkodogo, ne-Yatenga. Ngo-1896, yathathwa njengekoloni ngamaFulentshi njengengcenye ye-French West Africa; ngo-1958, i-Upper Volta yaba yikoloni ezizibusako ngaphakathi kwe-French Community. Ngo-1960, yathola ikululeko epheleleko ngo-Maurice Yaméogo njengomengameli. Solo yathola itjhaphuluko yayo, inarha le sele iqalene nokungazinzi, isomiso, indlala nekohlakalo. Kube nokuvukela umbuso okuhlukahlukeneko, ngo-1966, 1980, 1982, 1983, 1987, begodu kabili ngo-2022 (ngoTjhirhweni noNobayeni). Kwaba nemizamo yokuvukela umbuso engaphumelelanga ngo-1989, 2015, nango-2023.

== Iinkomba ==</text>
      <sha1>nzt7naksdz91jo9rbwanp5j926xc5fs</sha1>
    </revision>
    <revision>
      <id>1824</id>
      <parentid>1823</parentid>
      <timestamp>2024-11-01T18:35:14Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1824</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1398" sha1="ic9cxd9hgzpgvu4quoe6bez5jalygae" xml:space="preserve">'''I-Burkina Faso,''' yinarha enganamanzi eTjingalanga ye-[[I-Afrika|Afrika]], enomngcele we-Mali ngetlhagwini-Tjingalanga, i-Niger ngeTlhagwini-pumalanga, i-Benin ngesewulapumalanga, i-[[Togo]] ne-[[Ghana]] ngesewula, kanye ne-Ivory Coast ngeSewula-Tjingalanga. Ihlanganisa indawo engama-274,223 km2 (105,878 sq mi). Ngomnyaka ka-2021, inarha gade inabantu abangaba ma-23,674,480. Ngaphambilini beyibizwa ngokuthi yi-Republic of Upper Volta (1958–1984), yabizwa kabutjha ngokuthi yi-Burkina Faso ngumongameli wangaphambilini u-Thomas Sankara. Izakhamuzi zayo zaziwa ngokuthi yi-Burkinabè, begodu ikomkhulu layo nedorobha elikhulu yi-[[Ouagadougou]].

Isitjhaba esikhulu khulu e-Burkina Faso babantu be-Mossi, abahlala endaweni leyo ngekhulu le-11 nele-13. Basungula imibuso enamandla njenge-Ouagadougou, i-Tenkodogo, ne-Yatenga. Ngo-1896, yathathwa njengekoloni ngamaFulentshi njengengcenye ye-French West Africa; ngo-1958, i-Upper Volta yaba yikoloni ezizibusako ngaphakathi kwe-French Community. Ngo-1960, yathola ikululeko epheleleko ngo-Maurice Yaméogo njengomengameli. Solo yathola itjhaphuluko yayo, inarha le sele iqalene nokungazinzi, isomiso, indlala nekohlakalo. Kube nokuvukela umbuso okuhlukahlukeneko, ngo-1966, 1980, 1982, 1983, 1987, begodu kabili ngo-2022 (ngoTjhirhweni noNobayeni). Kwaba nemizamo yokuvukela umbuso engaphumelelanga ngo-1989, 2015, nango-2023.

== Iinkomba ==</text>
      <sha1>ic9cxd9hgzpgvu4quoe6bez5jalygae</sha1>
    </revision>
    <revision>
      <id>1825</id>
      <parentid>1824</parentid>
      <timestamp>2024-11-01T18:35:31Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1825</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1410" sha1="gsxddvsb9a24ttnidk42bw5z1oyswee" xml:space="preserve">'''I-Burkina Faso,''' yinarha enganamanzi eTjingalanga ye-[[I-Afrika|Afrika]], enomngcele we-Mali ngetlhagwini-Tjingalanga, i-Niger ngeTlhagwini-pumalanga, i-Benin ngesewulapumalanga, i-[[Togo]] ne-[[Ghana]] ngesewula, kanye ne-Ivory Coast ngeSewula-Tjingalanga. Ihlanganisa indawo engama-274,223 km2 (105,878 sq mi). Ngomnyaka ka-2021, inarha gade inabantu abangaba ma-23,674,480. Ngaphambilini beyibizwa ngokuthi yi-Republic of Upper Volta (1958–1984), yabizwa kabutjha ngokuthi yi-Burkina Faso ngumongameli wangaphambilini u-Thomas Sankara. Izakhamuzi zayo zaziwa ngokuthi yi-Burkinabè, begodu ikomkhulu layo nedorobha elikhulu yi-[[Ouagadougou]].

Isitjhaba esikhulu khulu e-Burkina Faso babantu be-Mossi, abahlala endaweni leyo ngekhulu le-11 nele-13. Basungula imibuso enamandla njenge-Ouagadougou, i-Tenkodogo, ne-Yatenga. Ngo-1896, yathathwa njengekoloni ngamaFulentshi njengengcenye ye-French West Africa; ngo-1958, i-Upper Volta yaba yikoloni ezizibusako ngaphakathi kwe-French Community. Ngo-1960, yathola ikululeko epheleleko ngo-Maurice Yaméogo njengomengameli. Solo yathola itjhaphuluko yayo, inarha le sele iqalene nokungazinzi, isomiso, indlala nekohlakalo. Kube nokuvukela umbuso okuhlukahlukeneko, ngo-1966, 1980, 1982, 1983, 1987, begodu kabili ngo-2022 (ngoTjhirhweni noNobayeni). Kwaba nemizamo yokuvukela umbuso engaphumelelanga ngo-1989, 2015, nango-2023.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>gsxddvsb9a24ttnidk42bw5z1oyswee</sha1>
    </revision>
    <revision>
      <id>1826</id>
      <parentid>1825</parentid>
      <timestamp>2024-11-01T18:36:32Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1826</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1605" sha1="6mgw4iiafz34xlnjvxybo2ax6hor2ak" xml:space="preserve">'''I-Burkina Faso,''' yinarha enganamanzi eTjingalanga ye-[[I-Afrika|Afrika]], enomngcele we-Mali ngetlhagwini-Tjingalanga, i-Niger ngeTlhagwini-pumalanga, i-Benin ngesewulapumalanga, i-[[Togo]] ne-[[Ghana]] ngesewula, kanye ne-Ivory Coast ngeSewula-Tjingalanga. Ihlanganisa indawo engama-274,223 km2 (105,878 sq mi). Ngomnyaka ka-2021, inarha gade inabantu abangaba ma-23,674,480. Ngaphambilini beyibizwa ngokuthi yi-Republic of Upper Volta (1958–1984), yabizwa kabutjha ngokuthi yi-Burkina Faso ngumongameli wangaphambilini u-Thomas Sankara. Izakhamuzi zayo zaziwa ngokuthi yi-Burkinabè, begodu ikomkhulu layo nedorobha elikhulu yi-[[Ouagadougou]].&lt;ref&gt;https://www.sahistory.org.za/place/burkina-faso#:~:text=A%20former%20French%20colony%2C%20it,a%20popular%20uprising%20in%202014.&lt;/ref&gt;

Isitjhaba esikhulu khulu e-Burkina Faso babantu be-Mossi, abahlala endaweni leyo ngekhulu le-11 nele-13. Basungula imibuso enamandla njenge-Ouagadougou, i-Tenkodogo, ne-Yatenga. Ngo-1896, yathathwa njengekoloni ngamaFulentshi njengengcenye ye-French West Africa; ngo-1958, i-Upper Volta yaba yikoloni ezizibusako ngaphakathi kwe-French Community. Ngo-1960, yathola ikululeko epheleleko ngo-Maurice Yaméogo njengomengameli. Solo yathola itjhaphuluko yayo, inarha le sele iqalene nokungazinzi, isomiso, indlala nekohlakalo. Kube nokuvukela umbuso okuhlukahlukeneko, ngo-1966, 1980, 1982, 1983, 1987, begodu kabili ngo-2022 (ngoTjhirhweni noNobayeni). Kwaba nemizamo yokuvukela umbuso engaphumelelanga ngo-1989, 2015, nango-2023.&lt;ref&gt;https://www.britannica.com/place/Burkina-Faso&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}</text>
      <sha1>6mgw4iiafz34xlnjvxybo2ax6hor2ak</sha1>
    </revision>
    <revision>
      <id>1827</id>
      <parentid>1826</parentid>
      <timestamp>2024-11-01T18:36:57Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1827</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1662" sha1="cbxp0r53enpeywh3qk6vlvbissj1eyt" xml:space="preserve">'''I-Burkina Faso,''' yinarha enganamanzi eTjingalanga ye-[[I-Afrika|Afrika]], enomngcele we-Mali ngetlhagwini-Tjingalanga, i-Niger ngeTlhagwini-pumalanga, i-Benin ngesewulapumalanga, i-[[Togo]] ne-[[Ghana]] ngesewula, kanye ne-Ivory Coast ngeSewula-Tjingalanga. Ihlanganisa indawo engama-274,223 km2 (105,878 sq mi). Ngomnyaka ka-2021, inarha gade inabantu abangaba ma-23,674,480. Ngaphambilini beyibizwa ngokuthi yi-Republic of Upper Volta (1958–1984), yabizwa kabutjha ngokuthi yi-Burkina Faso ngumongameli wangaphambilini u-Thomas Sankara. Izakhamuzi zayo zaziwa ngokuthi yi-Burkinabè, begodu ikomkhulu layo nedorobha elikhulu yi-[[Ouagadougou]].&lt;ref&gt;https://www.sahistory.org.za/place/burkina-faso#:~:text=A%20former%20French%20colony%2C%20it,a%20popular%20uprising%20in%202014.&lt;/ref&gt;

Isitjhaba esikhulu khulu e-Burkina Faso babantu be-Mossi, abahlala endaweni leyo ngekhulu le-11 nele-13. Basungula imibuso enamandla njenge-Ouagadougou, i-Tenkodogo, ne-Yatenga. Ngo-1896, yathathwa njengekoloni ngamaFulentshi njengengcenye ye-French West Africa; ngo-1958, i-Upper Volta yaba yikoloni ezizibusako ngaphakathi kwe-French Community. Ngo-1960, yathola ikululeko epheleleko ngo-Maurice Yaméogo njengomengameli. Solo yathola itjhaphuluko yayo, inarha le sele iqalene nokungazinzi, isomiso, indlala nekohlakalo. Kube nokuvukela umbuso okuhlukahlukeneko, ngo-1966, 1980, 1982, 1983, 1987, begodu kabili ngo-2022 (ngoTjhirhweni noNobayeni). Kwaba nemizamo yokuvukela umbuso engaphumelelanga ngo-1989, 2015, nango-2023.&lt;ref&gt;https://www.britannica.com/place/Burkina-Faso&lt;/ref&gt;&lt;ref&gt;https://www.bbc.com/news/world-africa-13072774&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}</text>
      <sha1>cbxp0r53enpeywh3qk6vlvbissj1eyt</sha1>
    </revision>
    <revision>
      <id>1828</id>
      <parentid>1827</parentid>
      <timestamp>2024-11-01T18:37:22Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1828</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1691" sha1="4gna1eiodtrryboxn5iuq7fpy0ilg6b" xml:space="preserve">'''I-Burkina Faso,''' yinarha enganamanzi eTjingalanga ye-[[I-Afrika|Afrika]], enomngcele we-Mali ngetlhagwini-Tjingalanga, i-Niger ngeTlhagwini-pumalanga, i-Benin ngesewulapumalanga, i-[[Togo]] ne-[[Ghana]] ngesewula, kanye ne-Ivory Coast ngeSewula-Tjingalanga. Ihlanganisa indawo engama-274,223 km2 (105,878 sq mi). Ngomnyaka ka-2021, inarha gade inabantu abangaba ma-23,674,480. Ngaphambilini beyibizwa ngokuthi yi-Republic of Upper Volta (1958–1984), yabizwa kabutjha ngokuthi yi-Burkina Faso ngumongameli wangaphambilini u-Thomas Sankara. Izakhamuzi zayo zaziwa ngokuthi yi-Burkinabè, begodu ikomkhulu layo nedorobha elikhulu yi-[[Ouagadougou]].&lt;ref&gt;https://www.sahistory.org.za/place/burkina-faso#:~:text=A%20former%20French%20colony%2C%20it,a%20popular%20uprising%20in%202014.&lt;/ref&gt;

Isitjhaba esikhulu khulu e-Burkina Faso babantu be-Mossi, abahlala endaweni leyo ngekhulu le-11 nele-13. Basungula imibuso enamandla njenge-Ouagadougou, i-Tenkodogo, ne-Yatenga. Ngo-1896, yathathwa njengekoloni ngamaFulentshi njengengcenye ye-French West Africa; ngo-1958, i-Upper Volta yaba yikoloni ezizibusako ngaphakathi kwe-French Community. Ngo-1960, yathola ikululeko epheleleko ngo-Maurice Yaméogo njengomengameli. Solo yathola itjhaphuluko yayo, inarha le sele iqalene nokungazinzi, isomiso, indlala nekohlakalo. Kube nokuvukela umbuso okuhlukahlukeneko, ngo-1966, 1980, 1982, 1983, 1987, begodu kabili ngo-2022 (ngoTjhirhweni noNobayeni). Kwaba nemizamo yokuvukela umbuso engaphumelelanga ngo-1989, 2015, nango-2023.&lt;ref&gt;https://www.britannica.com/place/Burkina-Faso&lt;/ref&gt;&lt;ref&gt;https://www.bbc.com/news/world-africa-13072774&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}
[[Category:Iinarha zephasi]]</text>
      <sha1>4gna1eiodtrryboxn5iuq7fpy0ilg6b</sha1>
    </revision>
    <revision>
      <id>2134</id>
      <parentid>1828</parentid>
      <timestamp>2024-11-25T18:28:27Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>Mkhakha</comment>
      <origin>2134</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1691" sha1="thlj5tcfpgc6xf0nvpuanvh93rnzxvh" xml:space="preserve">'''I-Burkina Faso,''' yinarha enganamanzi eTjingalanga ye-[[I-Afrika|Afrika]], enomngcele we-Mali ngetlhagwini-Tjingalanga, i-Niger ngeTlhagwini-pumalanga, i-Benin ngesewulapumalanga, i-[[Togo]] ne-[[Ghana]] ngesewula, kanye ne-Ivory Coast ngeSewula-Tjingalanga. Ihlanganisa indawo engama-274,223 km2 (105,878 sq mi). Ngomnyaka ka-2021, inarha gade inabantu abangaba ma-23,674,480. Ngaphambilini beyibizwa ngokuthi yi-Republic of Upper Volta (1958–1984), yabizwa kabutjha ngokuthi yi-Burkina Faso ngumongameli wangaphambilini u-Thomas Sankara. Izakhamuzi zayo zaziwa ngokuthi yi-Burkinabè, begodu ikomkhulu layo nedorobha elikhulu yi-[[Ouagadougou]].&lt;ref&gt;https://www.sahistory.org.za/place/burkina-faso#:~:text=A%20former%20French%20colony%2C%20it,a%20popular%20uprising%20in%202014.&lt;/ref&gt;

Isitjhaba esikhulu khulu e-Burkina Faso babantu be-Mossi, abahlala endaweni leyo ngekhulu le-11 nele-13. Basungula imibuso enamandla njenge-Ouagadougou, i-Tenkodogo, ne-Yatenga. Ngo-1896, yathathwa njengekoloni ngamaFulentshi njengengcenye ye-French West Africa; ngo-1958, i-Upper Volta yaba yikoloni ezizibusako ngaphakathi kwe-French Community. Ngo-1960, yathola ikululeko epheleleko ngo-Maurice Yaméogo njengomengameli. Solo yathola itjhaphuluko yayo, inarha le sele iqalene nokungazinzi, isomiso, indlala nekohlakalo. Kube nokuvukela umbuso okuhlukahlukeneko, ngo-1966, 1980, 1982, 1983, 1987, begodu kabili ngo-2022 (ngoTjhirhweni noNobayeni). Kwaba nemizamo yokuvukela umbuso engaphumelelanga ngo-1989, 2015, nango-2023.&lt;ref&gt;https://www.britannica.com/place/Burkina-Faso&lt;/ref&gt;&lt;ref&gt;https://www.bbc.com/news/world-africa-13072774&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}

[[Mkhakha:Iinarha zephasi]]</text>
      <sha1>thlj5tcfpgc6xf0nvpuanvh93rnzxvh</sha1>
    </revision>
  </page>
  <page>
    <title>Kenya</title>
    <ns>0</ns>
    <id>351</id>
    <revision>
      <id>1829</id>
      <timestamp>2024-11-01T18:38:34Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created page with &quot;'''I-Kenya''', ngokusemthethweni iRiphabhliki ye-Kenya (i-Swahili: Jamhuri ya Kenya), lilizwe elise-East Africa. Njengombana inabantu abangaphezu kweengidi ezima-47.6 ekubalweni kwabantu kwango-2019,[12] i-Kenya yinarha ye-28 enabantu abanengi ephasini begodu nge-7th enabantu abanengi e-Afrika. Idorobha elikhulu le-Kenya yi-Nairobi, kuthi idorobha layo elidala khulu nelingesibili ngobukhulu, lidorobha elikhulu le-Mombasa, elise-Mombasa Island e-Indian Ocean kanye nezwe e...&quot;</comment>
      <origin>1829</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1947" sha1="rdx6zf2d0uyikbh9ub0uwfeco9u3d8r" xml:space="preserve">'''I-Kenya''', ngokusemthethweni iRiphabhliki ye-Kenya (i-Swahili: Jamhuri ya Kenya), lilizwe elise-East Africa. Njengombana inabantu abangaphezu kweengidi ezima-47.6 ekubalweni kwabantu kwango-2019,[12] i-Kenya yinarha ye-28 enabantu abanengi ephasini begodu nge-7th enabantu abanengi e-Afrika. Idorobha elikhulu le-Kenya yi-Nairobi, kuthi idorobha layo elidala khulu nelingesibili ngobukhulu, lidorobha elikhulu le-Mombasa, elise-Mombasa Island e-Indian Ocean kanye nezwe eliseduze. I-Mombasa beyiyinhloko-dolobha ye-British East Africa Protectorate, ebegade ifaka hlangana inengi lalokho okubizwa nge-Kenya kanye ne-Southwestern Somalia, kusukela ngo-1889 ukuya ku-1907. Amanye amadorobha aqakathekileko afakahlangana i-Kisumu ne-Nakuru. I-Kenya inomkhawulo we-South Sudan ngetlhagwini-Tjingalanga, i-Ethiopia ngetlhagwini, i-Somalia ngepumalanga, i-Uganda ngeTjingalanga, i-Tanzania ngesewula, ne-Indian Ocean ngesewulapumalanga. Indawo ye-Kenya, ubujamo bezulu kanye nenani labantu liyahluka khulu, ukusuka eentabeni ezibandako ezineqhwa (i-Batian, i-Nelion kanye ne-Point Lenana eNtabeni ye-Kenya) enamahlathi amakhulu, iinlwana zeganga kanye neendawo ezivundileko zezokulima ukuya ebujameni bezulu obufuthumeleko eenarheni ezisentshonalanga neze-rift valley begodu ukuya phambili iindawo ezomileko ezinganamvundisi eyomileko nezomileko kanye namahlane apheleleko (Ihlane le-Chalbi nehlane le-Nyiri).

Izakhamuzi zokuthoma ze-Kenya bezizizingeli, njengabantu banamhlanjesi be-Hadza. Ngokuya ngokuvubukulwa kwezinto ezihlobene namathambo, abakhulumi be-Cushitic bathoma ukuhlala eendaweni eziphasi ze-Kenya hlangana kwe-3,200 ukuya ku-1,300 BC, isigaba esaziwa nge-Lowland Savanna Pastoral Neolithic. Abelusi abakhuluma isi-Nilotic (okhokho babakhulumi be-Nilotic be-Kenya) bathoma ukufuduka ukusuka e-South Sudan yanje ukuya e-Kenya ngabo-500 BC.[15] Abantu bamaBantu bahlala egwini nangaphakathi hlangana nomnyaka ka-250 BC ukuya ku-500 AD.</text>
      <sha1>rdx6zf2d0uyikbh9ub0uwfeco9u3d8r</sha1>
    </revision>
    <revision>
      <id>1830</id>
      <parentid>1829</parentid>
      <timestamp>2024-11-01T18:40:02Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1830</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2114" sha1="rmes18jx1s0i8b14n8dm52qyvulu7gw" xml:space="preserve">'''I-Kenya''', ngokusemthethweni iRiphabhliki ye-Kenya (i-Swahili: Jamhuri ya Kenya), lilizwe elise-East Africa. Njengombana inabantu abangaphezu kweengidi ezima-47.6 ekubalweni kwabantu kwango-2019,[12] i-Kenya yinarha ye-28 enabantu abanengi ephasini begodu nge-7th enabantu abanengi e-Afrika. Idorobha elikhulu le-Kenya yi-Nairobi, kuthi idorobha layo elidala khulu nelingesibili ngobukhulu, lidorobha elikhulu le-Mombasa, elise-Mombasa Island e-Indian Ocean kanye nezwe eliseduze. I-Mombasa beyiyinhloko-dolobha ye-British East Africa Protectorate, ebegade ifaka hlangana inengi lalokho okubizwa nge-Kenya kanye ne-Southwestern Somalia, kusukela ngo-1889 ukuya ku-1907. Amanye amadorobha aqakathekileko afakahlangana i-Kisumu ne-Nakuru. I-Kenya inomkhawulo we-South Sudan ngetlhagwini-Tjingalanga, i-Ethiopia ngetlhagwini, i-Somalia ngepumalanga, i-Uganda ngeTjingalanga, i-Tanzania ngesewula, ne-Indian Ocean ngesewulapumalanga. Indawo ye-Kenya, ubujamo bezulu kanye nenani labantu liyahluka khulu, ukusuka eentabeni ezibandako ezineqhwa (i-Batian, i-Nelion kanye ne-Point Lenana eNtabeni ye-Kenya) enamahlathi amakhulu, iinlwana zeganga kanye neendawo ezivundileko zezokulima ukuya ebujameni bezulu obufuthumeleko eenarheni ezisentshonalanga neze-rift valley begodu ukuya phambili iindawo ezomileko ezinganamvundisi eyomileko nezomileko kanye namahlane apheleleko (Ihlane le-Chalbi nehlane le-Nyiri).&lt;ref&gt;https://www.britannica.com/topic/history-of-Kenya&lt;/ref&gt;&lt;ref&gt;https://kenyaembassydc.org/aboutkenyahistory/&lt;/ref&gt;

Izakhamuzi zokuthoma ze-Kenya bezizizingeli, njengabantu banamhlanjesi be-Hadza. Ngokuya ngokuvubukulwa kwezinto ezihlobene namathambo, abakhulumi be-Cushitic bathoma ukuhlala eendaweni eziphasi ze-Kenya hlangana kwe-3,200 ukuya ku-1,300 BC, isigaba esaziwa nge-Lowland Savanna Pastoral Neolithic. Abelusi abakhuluma isi-Nilotic (okhokho babakhulumi be-Nilotic be-Kenya) bathoma ukufuduka ukusuka e-South Sudan yanje ukuya e-Kenya ngabo-500 BC.[15] Abantu bamaBantu bahlala egwini nangaphakathi hlangana nomnyaka ka-250 BC ukuya ku-500 AD.&lt;ref&gt;https://www.sahistory.org.za/place/kenya&lt;/ref&gt;</text>
      <sha1>rmes18jx1s0i8b14n8dm52qyvulu7gw</sha1>
    </revision>
    <revision>
      <id>1831</id>
      <parentid>1830</parentid>
      <timestamp>2024-11-01T18:40:23Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1831</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2130" sha1="kt8ntrrewis93o0m5e3jch1bwy5dh2r" xml:space="preserve">'''I-Kenya''', ngokusemthethweni iRiphabhliki ye-Kenya (i-Swahili: Jamhuri ya Kenya), lilizwe elise-East Africa. Njengombana inabantu abangaphezu kweengidi ezima-47.6 ekubalweni kwabantu kwango-2019,[12] i-Kenya yinarha ye-28 enabantu abanengi ephasini begodu nge-7th enabantu abanengi e-Afrika. Idorobha elikhulu le-Kenya yi-Nairobi, kuthi idorobha layo elidala khulu nelingesibili ngobukhulu, lidorobha elikhulu le-Mombasa, elise-Mombasa Island e-Indian Ocean kanye nezwe eliseduze. I-Mombasa beyiyinhloko-dolobha ye-British East Africa Protectorate, ebegade ifaka hlangana inengi lalokho okubizwa nge-Kenya kanye ne-Southwestern Somalia, kusukela ngo-1889 ukuya ku-1907. Amanye amadorobha aqakathekileko afakahlangana i-Kisumu ne-Nakuru. I-Kenya inomkhawulo we-South Sudan ngetlhagwini-Tjingalanga, i-Ethiopia ngetlhagwini, i-Somalia ngepumalanga, i-Uganda ngeTjingalanga, i-Tanzania ngesewula, ne-Indian Ocean ngesewulapumalanga. Indawo ye-Kenya, ubujamo bezulu kanye nenani labantu liyahluka khulu, ukusuka eentabeni ezibandako ezineqhwa (i-Batian, i-Nelion kanye ne-Point Lenana eNtabeni ye-Kenya) enamahlathi amakhulu, iinlwana zeganga kanye neendawo ezivundileko zezokulima ukuya ebujameni bezulu obufuthumeleko eenarheni ezisentshonalanga neze-rift valley begodu ukuya phambili iindawo ezomileko ezinganamvundisi eyomileko nezomileko kanye namahlane apheleleko (Ihlane le-Chalbi nehlane le-Nyiri).&lt;ref&gt;https://www.britannica.com/topic/history-of-Kenya&lt;/ref&gt;&lt;ref&gt;https://kenyaembassydc.org/aboutkenyahistory/&lt;/ref&gt;

Izakhamuzi zokuthoma ze-Kenya bezizizingeli, njengabantu banamhlanjesi be-Hadza. Ngokuya ngokuvubukulwa kwezinto ezihlobene namathambo, abakhulumi be-Cushitic bathoma ukuhlala eendaweni eziphasi ze-Kenya hlangana kwe-3,200 ukuya ku-1,300 BC, isigaba esaziwa nge-Lowland Savanna Pastoral Neolithic. Abelusi abakhuluma isi-Nilotic (okhokho babakhulumi be-Nilotic be-Kenya) bathoma ukufuduka ukusuka e-South Sudan yanje ukuya e-Kenya ngabo-500 BC.[15] Abantu bamaBantu bahlala egwini nangaphakathi hlangana nomnyaka ka-250 BC ukuya ku-500 AD.&lt;ref&gt;https://www.sahistory.org.za/place/kenya&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>kt8ntrrewis93o0m5e3jch1bwy5dh2r</sha1>
    </revision>
    <revision>
      <id>1832</id>
      <parentid>1831</parentid>
      <timestamp>2024-11-01T18:40:37Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1832</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2142" sha1="1gm2q3dgysfa1h96dojcl73tzu1l5bc" xml:space="preserve">'''I-Kenya''', ngokusemthethweni iRiphabhliki ye-Kenya (i-Swahili: Jamhuri ya Kenya), lilizwe elise-East Africa. Njengombana inabantu abangaphezu kweengidi ezima-47.6 ekubalweni kwabantu kwango-2019,[12] i-Kenya yinarha ye-28 enabantu abanengi ephasini begodu nge-7th enabantu abanengi e-Afrika. Idorobha elikhulu le-Kenya yi-Nairobi, kuthi idorobha layo elidala khulu nelingesibili ngobukhulu, lidorobha elikhulu le-Mombasa, elise-Mombasa Island e-Indian Ocean kanye nezwe eliseduze. I-Mombasa beyiyinhloko-dolobha ye-British East Africa Protectorate, ebegade ifaka hlangana inengi lalokho okubizwa nge-Kenya kanye ne-Southwestern Somalia, kusukela ngo-1889 ukuya ku-1907. Amanye amadorobha aqakathekileko afakahlangana i-Kisumu ne-Nakuru. I-Kenya inomkhawulo we-South Sudan ngetlhagwini-Tjingalanga, i-Ethiopia ngetlhagwini, i-Somalia ngepumalanga, i-Uganda ngeTjingalanga, i-Tanzania ngesewula, ne-Indian Ocean ngesewulapumalanga. Indawo ye-Kenya, ubujamo bezulu kanye nenani labantu liyahluka khulu, ukusuka eentabeni ezibandako ezineqhwa (i-Batian, i-Nelion kanye ne-Point Lenana eNtabeni ye-Kenya) enamahlathi amakhulu, iinlwana zeganga kanye neendawo ezivundileko zezokulima ukuya ebujameni bezulu obufuthumeleko eenarheni ezisentshonalanga neze-rift valley begodu ukuya phambili iindawo ezomileko ezinganamvundisi eyomileko nezomileko kanye namahlane apheleleko (Ihlane le-Chalbi nehlane le-Nyiri).&lt;ref&gt;https://www.britannica.com/topic/history-of-Kenya&lt;/ref&gt;&lt;ref&gt;https://kenyaembassydc.org/aboutkenyahistory/&lt;/ref&gt;

Izakhamuzi zokuthoma ze-Kenya bezizizingeli, njengabantu banamhlanjesi be-Hadza. Ngokuya ngokuvubukulwa kwezinto ezihlobene namathambo, abakhulumi be-Cushitic bathoma ukuhlala eendaweni eziphasi ze-Kenya hlangana kwe-3,200 ukuya ku-1,300 BC, isigaba esaziwa nge-Lowland Savanna Pastoral Neolithic. Abelusi abakhuluma isi-Nilotic (okhokho babakhulumi be-Nilotic be-Kenya) bathoma ukufuduka ukusuka e-South Sudan yanje ukuya e-Kenya ngabo-500 BC.[15] Abantu bamaBantu bahlala egwini nangaphakathi hlangana nomnyaka ka-250 BC ukuya ku-500 AD.&lt;ref&gt;https://www.sahistory.org.za/place/kenya&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}</text>
      <sha1>1gm2q3dgysfa1h96dojcl73tzu1l5bc</sha1>
    </revision>
    <revision>
      <id>1833</id>
      <parentid>1832</parentid>
      <timestamp>2024-11-01T18:41:24Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1833</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2138" sha1="lyygybfd7cmugnxf2nxk6fqhlxeqvgt" xml:space="preserve">'''I-Kenya''', ngokusemthethweni iRiphabhliki ye-Kenya (i-Swahili: Jamhuri ya Kenya), lilizwe elise-East Africa. Njengombana inabantu abangaphezu kweengidi ezima-47.6 ekubalweni kwabantu kwango-2019, i-Kenya yinarha ye-28 enabantu abanengi ephasini begodu nge-7th enabantu abanengi e-Afrika. Idorobha elikhulu le-Kenya yi-Nairobi, kuthi idorobha layo elidala khulu nelingesibili ngobukhulu, lidorobha elikhulu le-Mombasa, elise-Mombasa Island e-Indian Ocean kanye nezwe eliseduze. I-Mombasa beyiyinhloko-dolobha ye-British East Africa Protectorate, ebegade ifaka hlangana inengi lalokho okubizwa nge-Kenya kanye ne-Southwestern Somalia, kusukela ngo-1889 ukuya ku-1907. Amanye amadorobha aqakathekileko afakahlangana i-Kisumu ne-Nakuru. I-Kenya inomkhawulo we-South Sudan ngetlhagwini-Tjingalanga, i-Ethiopia ngetlhagwini, i-Somalia ngepumalanga, i-Uganda ngeTjingalanga, i-Tanzania ngesewula, ne-Indian Ocean ngesewulapumalanga. Indawo ye-Kenya, ubujamo bezulu kanye nenani labantu liyahluka khulu, ukusuka eentabeni ezibandako ezineqhwa (i-Batian, i-Nelion kanye ne-Point Lenana eNtabeni ye-Kenya) enamahlathi amakhulu, iinlwana zeganga kanye neendawo ezivundileko zezokulima ukuya ebujameni bezulu obufuthumeleko eenarheni ezisentshonalanga neze-rift valley begodu ukuya phambili iindawo ezomileko ezinganamvundisi eyomileko nezomileko kanye namahlane apheleleko (Ihlane le-Chalbi nehlane le-Nyiri).&lt;ref&gt;https://www.britannica.com/topic/history-of-Kenya&lt;/ref&gt;&lt;ref&gt;https://kenyaembassydc.org/aboutkenyahistory/&lt;/ref&gt;

Izakhamuzi zokuthoma ze-Kenya bezizizingeli, njengabantu banamhlanjesi be-Hadza. Ngokuya ngokuvubukulwa kwezinto ezihlobene namathambo, abakhulumi be-Cushitic bathoma ukuhlala eendaweni eziphasi ze-Kenya hlangana kwe-3,200 ukuya ku-1,300 BC, isigaba esaziwa nge-Lowland Savanna Pastoral Neolithic. Abelusi abakhuluma isi-Nilotic (okhokho babakhulumi be-Nilotic be-Kenya) bathoma ukufuduka ukusuka e-South Sudan yanje ukuya e-Kenya ngabo-500 BC.[15] Abantu bamaBantu bahlala egwini nangaphakathi hlangana nomnyaka ka-250 BC ukuya ku-500 AD.&lt;ref&gt;https://www.sahistory.org.za/place/kenya&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}</text>
      <sha1>lyygybfd7cmugnxf2nxk6fqhlxeqvgt</sha1>
    </revision>
    <revision>
      <id>1834</id>
      <parentid>1833</parentid>
      <timestamp>2024-11-01T18:41:54Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1834</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2166" sha1="4r65aytzw13c0suxdt6ryz8hhw7kcn4" xml:space="preserve">'''I-Kenya''', ngokusemthethweni iRiphabhliki ye-Kenya (i-Swahili: Jamhuri ya Kenya), lilizwe elise-East Africa. Njengombana inabantu abangaphezu kweengidi ezima-47.6 ekubalweni kwabantu kwango-2019, i-Kenya yinarha ye-28 enabantu abanengi ephasini begodu nge-7th enabantu abanengi e-Afrika. Idorobha elikhulu le-Kenya yi-Nairobi, kuthi idorobha layo elidala khulu nelingesibili ngobukhulu, lidorobha elikhulu le-Mombasa, elise-Mombasa Island e-Indian Ocean kanye nezwe eliseduze. I-Mombasa beyiyinhloko-dolobha ye-British East Africa Protectorate, ebegade ifaka hlangana inengi lalokho okubizwa nge-Kenya kanye ne-Southwestern Somalia, kusukela ngo-1889 ukuya ku-1907. Amanye amadorobha aqakathekileko afakahlangana i-Kisumu ne-Nakuru. I-Kenya inomkhawulo we-South Sudan ngetlhagwini-Tjingalanga, i-Ethiopia ngetlhagwini, i-Somalia ngepumalanga, i-Uganda ngeTjingalanga, i-Tanzania ngesewula, ne-Indian Ocean ngesewulapumalanga. Indawo ye-Kenya, ubujamo bezulu kanye nenani labantu liyahluka khulu, ukusuka eentabeni ezibandako ezineqhwa (i-Batian, i-Nelion kanye ne-Point Lenana eNtabeni ye-Kenya) enamahlathi amakhulu, iinlwana zeganga kanye neendawo ezivundileko zezokulima ukuya ebujameni bezulu obufuthumeleko eenarheni ezisentshonalanga neze-rift valley begodu ukuya phambili iindawo ezomileko ezinganamvundisi eyomileko nezomileko kanye namahlane apheleleko (Ihlane le-Chalbi nehlane le-Nyiri).&lt;ref&gt;https://www.britannica.com/topic/history-of-Kenya&lt;/ref&gt;&lt;ref&gt;https://kenyaembassydc.org/aboutkenyahistory/&lt;/ref&gt;

Izakhamuzi zokuthoma ze-Kenya bezizizingeli, njengabantu banamhlanjesi be-Hadza. Ngokuya ngokuvubukulwa kwezinto ezihlobene namathambo, abakhulumi be-Cushitic bathoma ukuhlala eendaweni eziphasi ze-Kenya hlangana kwe-3,200 ukuya ku-1,300 BC, isigaba esaziwa nge-Lowland Savanna Pastoral Neolithic. Abelusi abakhuluma isi-Nilotic (okhokho babakhulumi be-Nilotic be-Kenya) bathoma ukufuduka ukusuka e-South Sudan yanje ukuya e-Kenya ngabo-500 BC.[15] Abantu bamaBantu bahlala egwini nangaphakathi hlangana nomnyaka ka-250 BC ukuya ku-500 AD.&lt;ref&gt;https://www.sahistory.org.za/place/kenya&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}
[[Category:Inarha zephasi]]</text>
      <sha1>4r65aytzw13c0suxdt6ryz8hhw7kcn4</sha1>
    </revision>
    <revision>
      <id>1835</id>
      <parentid>1834</parentid>
      <timestamp>2024-11-01T18:42:38Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1835</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2167" sha1="7hgc51aknierdnpcj1h8bdnmnam1qn2" xml:space="preserve">'''I-Kenya''', ngokusemthethweni iRiphabhliki ye-Kenya (i-Swahili: Jamhuri ya Kenya), lilizwe elise-East Africa. Njengombana inabantu abangaphezu kweengidi ezima-47.6 ekubalweni kwabantu kwango-2019, i-Kenya yinarha ye-28 enabantu abanengi ephasini begodu nge-7th enabantu abanengi e-Afrika. Idorobha elikhulu le-Kenya yi-Nairobi, kuthi idorobha layo elidala khulu nelingesibili ngobukhulu, lidorobha elikhulu le-Mombasa, elise-Mombasa Island e-Indian Ocean kanye nezwe eliseduze. I-Mombasa beyiyinhloko-dolobha ye-British East Africa Protectorate, ebegade ifaka hlangana inengi lalokho okubizwa nge-Kenya kanye ne-Southwestern Somalia, kusukela ngo-1889 ukuya ku-1907. Amanye amadorobha aqakathekileko afakahlangana i-Kisumu ne-Nakuru. I-Kenya inomkhawulo we-South Sudan ngetlhagwini-Tjingalanga, i-Ethiopia ngetlhagwini, i-Somalia ngepumalanga, i-Uganda ngeTjingalanga, i-Tanzania ngesewula, ne-Indian Ocean ngesewulapumalanga. Indawo ye-Kenya, ubujamo bezulu kanye nenani labantu liyahluka khulu, ukusuka eentabeni ezibandako ezineqhwa (i-Batian, i-Nelion kanye ne-Point Lenana eNtabeni ye-Kenya) enamahlathi amakhulu, iinlwana zeganga kanye neendawo ezivundileko zezokulima ukuya ebujameni bezulu obufuthumeleko eenarheni ezisentshonalanga neze-rift valley begodu ukuya phambili iindawo ezomileko ezinganamvundisi eyomileko nezomileko kanye namahlane apheleleko (Ihlane le-Chalbi nehlane le-Nyiri).&lt;ref&gt;https://www.britannica.com/topic/history-of-Kenya&lt;/ref&gt;&lt;ref&gt;https://kenyaembassydc.org/aboutkenyahistory/&lt;/ref&gt;

Izakhamuzi zokuthoma ze-Kenya bezizizingeli, njengabantu banamhlanjesi be-Hadza. Ngokuya ngokuvubukulwa kwezinto ezihlobene namathambo, abakhulumi be-Cushitic bathoma ukuhlala eendaweni eziphasi ze-Kenya hlangana kwe-3,200 ukuya ku-1,300 BC, isigaba esaziwa nge-Lowland Savanna Pastoral Neolithic. Abelusi abakhuluma isi-Nilotic (okhokho babakhulumi be-Nilotic be-Kenya) bathoma ukufuduka ukusuka e-South Sudan yanje ukuya e-Kenya ngabo-500 BC.[15] Abantu bamaBantu bahlala egwini nangaphakathi hlangana nomnyaka ka-250 BC ukuya ku-500 AD.&lt;ref&gt;https://www.sahistory.org.za/place/kenya&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}
[[Category:Iinarha zephasi]]</text>
      <sha1>7hgc51aknierdnpcj1h8bdnmnam1qn2</sha1>
    </revision>
    <revision>
      <id>1836</id>
      <parentid>1835</parentid>
      <timestamp>2024-11-01T18:42:58Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1836</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2180" sha1="dal32efv3ypgrl0sjjeha98fz93eid1" xml:space="preserve">'''I-Kenya''', ngokusemthethweni iRiphabhliki ye-Kenya (i-Swahili: Jamhuri ya Kenya), lilizwe elise-East Africa. Njengombana inabantu abangaphezu kweengidi ezima-47.6 ekubalweni kwabantu kwango-2019, i-Kenya yinarha ye-28 enabantu abanengi ephasini begodu nge-7th enabantu abanengi e-[[I-Afrika|Afrika]]. Idorobha elikhulu le-Kenya yi-Nairobi, kuthi idorobha layo elidala khulu nelingesibili ngobukhulu, lidorobha elikhulu le-Mombasa, elise-Mombasa Island e-Indian Ocean kanye nezwe eliseduze. I-Mombasa beyiyinhloko-dolobha ye-British East Africa Protectorate, ebegade ifaka hlangana inengi lalokho okubizwa nge-Kenya kanye ne-Southwestern Somalia, kusukela ngo-1889 ukuya ku-1907. Amanye amadorobha aqakathekileko afakahlangana i-Kisumu ne-Nakuru. I-Kenya inomkhawulo we-South Sudan ngetlhagwini-Tjingalanga, i-Ethiopia ngetlhagwini, i-Somalia ngepumalanga, i-Uganda ngeTjingalanga, i-Tanzania ngesewula, ne-Indian Ocean ngesewulapumalanga. Indawo ye-Kenya, ubujamo bezulu kanye nenani labantu liyahluka khulu, ukusuka eentabeni ezibandako ezineqhwa (i-Batian, i-Nelion kanye ne-Point Lenana eNtabeni ye-Kenya) enamahlathi amakhulu, iinlwana zeganga kanye neendawo ezivundileko zezokulima ukuya ebujameni bezulu obufuthumeleko eenarheni ezisentshonalanga neze-rift valley begodu ukuya phambili iindawo ezomileko ezinganamvundisi eyomileko nezomileko kanye namahlane apheleleko (Ihlane le-Chalbi nehlane le-Nyiri).&lt;ref&gt;https://www.britannica.com/topic/history-of-Kenya&lt;/ref&gt;&lt;ref&gt;https://kenyaembassydc.org/aboutkenyahistory/&lt;/ref&gt;

Izakhamuzi zokuthoma ze-Kenya bezizizingeli, njengabantu banamhlanjesi be-Hadza. Ngokuya ngokuvubukulwa kwezinto ezihlobene namathambo, abakhulumi be-Cushitic bathoma ukuhlala eendaweni eziphasi ze-Kenya hlangana kwe-3,200 ukuya ku-1,300 BC, isigaba esaziwa nge-Lowland Savanna Pastoral Neolithic. Abelusi abakhuluma isi-Nilotic (okhokho babakhulumi be-Nilotic be-Kenya) bathoma ukufuduka ukusuka e-South Sudan yanje ukuya e-Kenya ngabo-500 BC.[15] Abantu bamaBantu bahlala egwini nangaphakathi hlangana nomnyaka ka-250 BC ukuya ku-500 AD.&lt;ref&gt;https://www.sahistory.org.za/place/kenya&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}
[[Category:Iinarha zephasi]]</text>
      <sha1>dal32efv3ypgrl0sjjeha98fz93eid1</sha1>
    </revision>
    <revision>
      <id>2144</id>
      <parentid>1836</parentid>
      <timestamp>2024-11-25T18:30:08Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>Mkhakha</comment>
      <origin>2144</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2180" sha1="mjkyj2nyezcbshnaziz2w4ihl8ucfud" xml:space="preserve">'''I-Kenya''', ngokusemthethweni iRiphabhliki ye-Kenya (i-Swahili: Jamhuri ya Kenya), lilizwe elise-East Africa. Njengombana inabantu abangaphezu kweengidi ezima-47.6 ekubalweni kwabantu kwango-2019, i-Kenya yinarha ye-28 enabantu abanengi ephasini begodu nge-7th enabantu abanengi e-[[I-Afrika|Afrika]]. Idorobha elikhulu le-Kenya yi-Nairobi, kuthi idorobha layo elidala khulu nelingesibili ngobukhulu, lidorobha elikhulu le-Mombasa, elise-Mombasa Island e-Indian Ocean kanye nezwe eliseduze. I-Mombasa beyiyinhloko-dolobha ye-British East Africa Protectorate, ebegade ifaka hlangana inengi lalokho okubizwa nge-Kenya kanye ne-Southwestern Somalia, kusukela ngo-1889 ukuya ku-1907. Amanye amadorobha aqakathekileko afakahlangana i-Kisumu ne-Nakuru. I-Kenya inomkhawulo we-South Sudan ngetlhagwini-Tjingalanga, i-Ethiopia ngetlhagwini, i-Somalia ngepumalanga, i-Uganda ngeTjingalanga, i-Tanzania ngesewula, ne-Indian Ocean ngesewulapumalanga. Indawo ye-Kenya, ubujamo bezulu kanye nenani labantu liyahluka khulu, ukusuka eentabeni ezibandako ezineqhwa (i-Batian, i-Nelion kanye ne-Point Lenana eNtabeni ye-Kenya) enamahlathi amakhulu, iinlwana zeganga kanye neendawo ezivundileko zezokulima ukuya ebujameni bezulu obufuthumeleko eenarheni ezisentshonalanga neze-rift valley begodu ukuya phambili iindawo ezomileko ezinganamvundisi eyomileko nezomileko kanye namahlane apheleleko (Ihlane le-Chalbi nehlane le-Nyiri).&lt;ref&gt;https://www.britannica.com/topic/history-of-Kenya&lt;/ref&gt;&lt;ref&gt;https://kenyaembassydc.org/aboutkenyahistory/&lt;/ref&gt;

Izakhamuzi zokuthoma ze-Kenya bezizizingeli, njengabantu banamhlanjesi be-Hadza. Ngokuya ngokuvubukulwa kwezinto ezihlobene namathambo, abakhulumi be-Cushitic bathoma ukuhlala eendaweni eziphasi ze-Kenya hlangana kwe-3,200 ukuya ku-1,300 BC, isigaba esaziwa nge-Lowland Savanna Pastoral Neolithic. Abelusi abakhuluma isi-Nilotic (okhokho babakhulumi be-Nilotic be-Kenya) bathoma ukufuduka ukusuka e-South Sudan yanje ukuya e-Kenya ngabo-500 BC.[15] Abantu bamaBantu bahlala egwini nangaphakathi hlangana nomnyaka ka-250 BC ukuya ku-500 AD.&lt;ref&gt;https://www.sahistory.org.za/place/kenya&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}

[[Mkhakha:Iinarha zephasi]]</text>
      <sha1>mjkyj2nyezcbshnaziz2w4ihl8ucfud</sha1>
    </revision>
  </page>
  <page>
    <title>Lesotho</title>
    <ns>0</ns>
    <id>352</id>
    <revision>
      <id>1837</id>
      <timestamp>2024-11-01T18:48:02Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created page with &quot;I-Lesotho ngokusemthethweni uMbuso we-Lesotho, ngaphambilini owaziwa ngokuthi yi-Basutoland, lilizwe elinganamanzi eSewula ye-Afrika. Njenge-enclave yeSewula Afrika, lapho ehlanganyela khona umngcele we-1,106 km (687 mi), yi-enclave ekulu khulu ephasini, begodu ngiyo kwaphela ngaphandle kwe-Italy Peninsula. Itholakala eentabeni ze-Maloti begodu inesiqongo esiphakeme khulu eSewula ye-Afrika.[9] Inendawo engaphezu kwama-30,000 km2 (11,600 sq mi) begodu inabantu abangaba zi...&quot;</comment>
      <origin>1837</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1670" sha1="iyylk1wm20lkv8w57gx8enazgyjvqvz" xml:space="preserve">I-Lesotho ngokusemthethweni uMbuso we-Lesotho, ngaphambilini owaziwa ngokuthi yi-Basutoland, lilizwe elinganamanzi eSewula ye-Afrika. Njenge-enclave yeSewula Afrika, lapho ehlanganyela khona umngcele we-1,106 km (687 mi), yi-enclave ekulu khulu ephasini, begodu ngiyo kwaphela ngaphandle kwe-Italy Peninsula. Itholakala eentabeni ze-Maloti begodu inesiqongo esiphakeme khulu eSewula ye-Afrika.[9] Inendawo engaphezu kwama-30,000 km2 (11,600 sq mi) begodu inabantu abangaba ziingidi ezimbili. Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-Maseru. Ilizwe laziwa nangebizo lesidlaliso elithi The Mountain Kingdom.

Isitjhaba se-Sotho (esaziwa nangokuthi yi-Basotho), lapho inarha le ithathe khona ibizo layo, yenza i-99.7% yabantu beenarha zamanje, okwenza bona ibe ngenye yeentjhaba ezineentjhaba ezifanako khulu ephasini loke. Ilimi labo lomdabu, isiSuthu, lilimi elisemthethweni kanye nesiNgisi. Ibizo elithi Lesotho litjhugululwa ngokuthi &quot;inarha yabantu abakhuluma isiSutho&quot;.

I-Lesotho yabunjwa ngo-1824 yiKosi u-Moshoeshoe I. Ukungenelela okuragela phambili kwabahlali be-Dutch kwenza bona iKosi yenze isivumelwano noMbuso we-Britain bona ibe yindawo evikelweko ngo-1868 begodu, ngo-1884, ibe yikoloni yomqhele. Yazuza ikululeko ngo-1966, begodu ngemva kwalokho yabuswa yi-Basotho National Party (BNP) iminyaka ematjhumi amabili. Umbuso wayo womthethosisekelo wabuyiselwa ngo-1993 ngemva kweminyaka elikhomba yokubusa kwamasotja. INkosi u-Moshoeshoe II yadingiswa ngo-1990 kodwana yabuya ngo-1992 begodu yabuyiselwa esikhundleni ngo-1995. Ngemva komnyaka, u-Moshoeshoe II wahlongakala begodu indodanakhe u-Letsie III wathatha isihlalo sobukhosi, esaphetheko.</text>
      <sha1>iyylk1wm20lkv8w57gx8enazgyjvqvz</sha1>
    </revision>
    <revision>
      <id>1838</id>
      <parentid>1837</parentid>
      <timestamp>2024-11-01T18:49:03Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1838</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1895" sha1="p7zuiue9ww05qeeikyyahtqi6e82fwv" xml:space="preserve">I-Lesotho ngokusemthethweni uMbuso we-Lesotho, ngaphambilini owaziwa ngokuthi yi-Basutoland, lilizwe elinganamanzi eSewula ye-Afrika. Njenge-enclave yeSewula Afrika, lapho ehlanganyela khona umngcele we-1,106 km (687 mi), yi-enclave ekulu khulu ephasini, begodu ngiyo kwaphela ngaphandle kwe-Italy Peninsula. Itholakala eentabeni ze-Maloti begodu inesiqongo esiphakeme khulu eSewula ye-Afrika.[9] Inendawo engaphezu kwama-30,000 km2 (11,600 sq mi) begodu inabantu abangaba ziingidi ezimbili. Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-Maseru. Ilizwe laziwa nangebizo lesidlaliso elithi The Mountain Kingdom.&lt;ref&gt;https://www.gov.ls/about-lesotho/&lt;/ref&gt;

Isitjhaba se-Sotho (esaziwa nangokuthi yi-Basotho), lapho inarha le ithathe khona ibizo layo, yenza i-99.7% yabantu beenarha zamanje, okwenza bona ibe ngenye yeentjhaba ezineentjhaba ezifanako khulu ephasini loke. Ilimi labo lomdabu, isiSuthu, lilimi elisemthethweni kanye nesiNgisi. Ibizo elithi Lesotho litjhugululwa ngokuthi &quot;inarha yabantu abakhuluma isiSutho&quot;.&lt;ref&gt;https://www.bbc.com/news/world-africa-13728324&lt;/ref&gt;

I-Lesotho yabunjwa ngo-1824 yiKosi u-Moshoeshoe I. Ukungenelela okuragela phambili kwabahlali be-Dutch kwenza bona iKosi yenze isivumelwano noMbuso we-Britain bona ibe yindawo evikelweko ngo-1868 begodu, ngo-1884, ibe yikoloni yomqhele. Yazuza ikululeko ngo-1966, begodu ngemva kwalokho yabuswa yi-Basotho National Party (BNP) iminyaka ematjhumi amabili. Umbuso wayo womthethosisekelo wabuyiselwa ngo-1993 ngemva kweminyaka elikhomba yokubusa kwamasotja. INkosi u-Moshoeshoe II yadingiswa ngo-1990 kodwana yabuya ngo-1992 begodu yabuyiselwa esikhundleni ngo-1995. Ngemva komnyaka, u-Moshoeshoe II wahlongakala begodu indodanakhe u-Letsie III wathatha isihlalo sobukhosi, esaphetheko.&lt;ref&gt;https://oxfordre.com/africanhistory/display/10.1093/acrefore/9780190277734.001.0001/acrefore-9780190277734-e-1328&lt;/ref&gt;</text>
      <sha1>p7zuiue9ww05qeeikyyahtqi6e82fwv</sha1>
    </revision>
    <revision>
      <id>1839</id>
      <parentid>1838</parentid>
      <timestamp>2024-11-01T18:49:28Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1839</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1911" sha1="mqedxm0qn0tlp8q5v0uigbamzpo9cvp" xml:space="preserve">I-Lesotho ngokusemthethweni uMbuso we-Lesotho, ngaphambilini owaziwa ngokuthi yi-Basutoland, lilizwe elinganamanzi eSewula ye-Afrika. Njenge-enclave yeSewula Afrika, lapho ehlanganyela khona umngcele we-1,106 km (687 mi), yi-enclave ekulu khulu ephasini, begodu ngiyo kwaphela ngaphandle kwe-Italy Peninsula. Itholakala eentabeni ze-Maloti begodu inesiqongo esiphakeme khulu eSewula ye-Afrika.[9] Inendawo engaphezu kwama-30,000 km2 (11,600 sq mi) begodu inabantu abangaba ziingidi ezimbili. Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-Maseru. Ilizwe laziwa nangebizo lesidlaliso elithi The Mountain Kingdom.&lt;ref&gt;https://www.gov.ls/about-lesotho/&lt;/ref&gt;

Isitjhaba se-Sotho (esaziwa nangokuthi yi-Basotho), lapho inarha le ithathe khona ibizo layo, yenza i-99.7% yabantu beenarha zamanje, okwenza bona ibe ngenye yeentjhaba ezineentjhaba ezifanako khulu ephasini loke. Ilimi labo lomdabu, isiSuthu, lilimi elisemthethweni kanye nesiNgisi. Ibizo elithi Lesotho litjhugululwa ngokuthi &quot;inarha yabantu abakhuluma isiSutho&quot;.&lt;ref&gt;https://www.bbc.com/news/world-africa-13728324&lt;/ref&gt;

I-Lesotho yabunjwa ngo-1824 yiKosi u-Moshoeshoe I. Ukungenelela okuragela phambili kwabahlali be-Dutch kwenza bona iKosi yenze isivumelwano noMbuso we-Britain bona ibe yindawo evikelweko ngo-1868 begodu, ngo-1884, ibe yikoloni yomqhele. Yazuza ikululeko ngo-1966, begodu ngemva kwalokho yabuswa yi-Basotho National Party (BNP) iminyaka ematjhumi amabili. Umbuso wayo womthethosisekelo wabuyiselwa ngo-1993 ngemva kweminyaka elikhomba yokubusa kwamasotja. INkosi u-Moshoeshoe II yadingiswa ngo-1990 kodwana yabuya ngo-1992 begodu yabuyiselwa esikhundleni ngo-1995. Ngemva komnyaka, u-Moshoeshoe II wahlongakala begodu indodanakhe u-Letsie III wathatha isihlalo sobukhosi, esaphetheko.&lt;ref&gt;https://oxfordre.com/africanhistory/display/10.1093/acrefore/9780190277734.001.0001/acrefore-9780190277734-e-1328&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>mqedxm0qn0tlp8q5v0uigbamzpo9cvp</sha1>
    </revision>
    <revision>
      <id>1840</id>
      <parentid>1839</parentid>
      <timestamp>2024-11-01T18:50:13Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1840</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1952" sha1="eg7t8mff9i54qgo23nc9vd5ijbqvk49" xml:space="preserve">I-Lesotho ngokusemthethweni uMbuso we-Lesotho, ngaphambilini owaziwa ngokuthi yi-Basutoland, lilizwe elinganamanzi eSewula ye-Afrika. Njenge-enclave yeSewula Afrika, lapho ehlanganyela khona umngcele we-1,106 km (687 mi), yi-enclave ekulu khulu ephasini, begodu ngiyo kwaphela ngaphandle kwe-Italy Peninsula. Itholakala eentabeni ze-Maloti begodu inesiqongo esiphakeme khulu eSewula ye-Afrika.[9] Inendawo engaphezu kwama-30,000 km2 (11,600 sq mi) begodu inabantu abangaba ziingidi ezimbili. Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-Maseru. Ilizwe laziwa nangebizo lesidlaliso elithi The Mountain Kingdom.&lt;ref&gt;https://www.gov.ls/about-lesotho/&lt;/ref&gt;

Isitjhaba se-Sotho (esaziwa nangokuthi yi-Basotho), lapho inarha le ithathe khona ibizo layo, yenza i-99.7% yabantu beenarha zamanje, okwenza bona ibe ngenye yeentjhaba ezineentjhaba ezifanako khulu ephasini loke. Ilimi labo lomdabu, isiSuthu, lilimi elisemthethweni kanye nesiNgisi. Ibizo elithi Lesotho litjhugululwa ngokuthi &quot;inarha yabantu abakhuluma isiSutho&quot;.&lt;ref&gt;https://www.bbc.com/news/world-africa-13728324&lt;/ref&gt;

I-Lesotho yabunjwa ngo-1824 yiKosi u-Moshoeshoe I. Ukungenelela okuragela phambili kwabahlali be-Dutch kwenza bona iKosi yenze isivumelwano noMbuso we-Britain bona ibe yindawo evikelweko ngo-1868 begodu, ngo-1884, ibe yikoloni yomqhele. Yazuza ikululeko ngo-1966, begodu ngemva kwalokho yabuswa yi-Basotho National Party (BNP) iminyaka ematjhumi amabili. Umbuso wayo womthethosisekelo wabuyiselwa ngo-1993 ngemva kweminyaka elikhomba yokubusa kwamasotja. INkosi u-Moshoeshoe II yadingiswa ngo-1990 kodwana yabuya ngo-1992 begodu yabuyiselwa esikhundleni ngo-1995. Ngemva komnyaka, u-Moshoeshoe II wahlongakala begodu indodanakhe u-Letsie III wathatha isihlalo sobukhosi, esaphetheko.&lt;ref&gt;https://oxfordre.com/africanhistory/display/10.1093/acrefore/9780190277734.001.0001/acrefore-9780190277734-e-1328&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}
[[Category: Inarha zephasi]]</text>
      <sha1>eg7t8mff9i54qgo23nc9vd5ijbqvk49</sha1>
    </revision>
    <revision>
      <id>1841</id>
      <parentid>1840</parentid>
      <timestamp>2024-11-01T18:50:38Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1841</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1952" sha1="n1oyd4bcsv6kqyojgkwckjbgutag599" xml:space="preserve">I-Lesotho ngokusemthethweni uMbuso we-Lesotho, ngaphambilini owaziwa ngokuthi yi-Basutoland, lilizwe elinganamanzi eSewula ye-Afrika. Njenge-enclave yeSewula Afrika, lapho ehlanganyela khona umngcele we-1,106 km (687 mi), yi-enclave ekulu khulu ephasini, begodu ngiyo kwaphela ngaphandle kwe-Italy Peninsula. Itholakala eentabeni ze-Maloti begodu inesiqongo esiphakeme khulu eSewula ye-Afrika.[9] Inendawo engaphezu kwama-30,000 km2 (11,600 sq mi) begodu inabantu abangaba ziingidi ezimbili. Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-Maseru. Ilizwe laziwa nangebizo lesidlaliso elithi The Mountain Kingdom.&lt;ref&gt;https://www.gov.ls/about-lesotho/&lt;/ref&gt;

Isitjhaba se-Sotho (esaziwa nangokuthi yi-Basotho), lapho inarha le ithathe khona ibizo layo, yenza i-99.7% yabantu beenarha zamanje, okwenza bona ibe ngenye yeentjhaba ezineentjhaba ezifanako khulu ephasini loke. Ilimi labo lomdabu, isiSuthu, lilimi elisemthethweni kanye nesiNgisi. Ibizo elithi Lesotho litjhugululwa ngokuthi &quot;inarha yabantu abakhuluma isiSutho&quot;.&lt;ref&gt;https://www.bbc.com/news/world-africa-13728324&lt;/ref&gt;

I-Lesotho yabunjwa ngo-1824 yiKosi u-Moshoeshoe I. Ukungenelela okuragela phambili kwabahlali be-Dutch kwenza bona iKosi yenze isivumelwano noMbuso we-Britain bona ibe yindawo evikelweko ngo-1868 begodu, ngo-1884, ibe yikoloni yomqhele. Yazuza ikululeko ngo-1966, begodu ngemva kwalokho yabuswa yi-Basotho National Party (BNP) iminyaka ematjhumi amabili. Umbuso wayo womthethosisekelo wabuyiselwa ngo-1993 ngemva kweminyaka elikhomba yokubusa kwamasotja. INkosi u-Moshoeshoe II yadingiswa ngo-1990 kodwana yabuya ngo-1992 begodu yabuyiselwa esikhundleni ngo-1995. Ngemva komnyaka, u-Moshoeshoe II wahlongakala begodu indodanakhe u-Letsie III wathatha isihlalo sobukhosi, esaphetheko.&lt;ref&gt;https://oxfordre.com/africanhistory/display/10.1093/acrefore/9780190277734.001.0001/acrefore-9780190277734-e-1328&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}
[[Category:Iinarha zephasi]]</text>
      <sha1>n1oyd4bcsv6kqyojgkwckjbgutag599</sha1>
    </revision>
    <revision>
      <id>1842</id>
      <parentid>1841</parentid>
      <timestamp>2024-11-01T18:51:11Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1842</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1977" sha1="8k3wi0kwsr9tuea4cfd1j31nx1rgu77" xml:space="preserve">'''I-Lesotho''' ngokusemthethweni uMbuso we-Lesotho, ngaphambilini owaziwa ngokuthi yi-Basutoland, lilizwe elinganamanzi eSewula ye-Afrika. Njenge-enclave ye[[Isewula Afrika|Sewula Afrika]], lapho ehlanganyela khona umngcele we-1,106 km (687 mi), yi-enclave ekulu khulu ephasini, begodu ngiyo kwaphela ngaphandle kwe-Italy Peninsula. Itholakala eentabeni ze-Maloti begodu inesiqongo esiphakeme khulu eSewula ye-Afrika.[9] Inendawo engaphezu kwama-30,000 km2 (11,600 sq mi) begodu inabantu abangaba ziingidi ezimbili. Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-Maseru. Ilizwe laziwa nangebizo lesidlaliso elithi The Mountain Kingdom.&lt;ref&gt;https://www.gov.ls/about-lesotho/&lt;/ref&gt;

Isitjhaba se-Sotho (esaziwa nangokuthi yi-Basotho), lapho inarha le ithathe khona ibizo layo, yenza i-99.7% yabantu beenarha zamanje, okwenza bona ibe ngenye yeentjhaba ezineentjhaba ezifanako khulu ephasini loke. Ilimi labo lomdabu, isiSuthu, lilimi elisemthethweni kanye nesiNgisi. Ibizo elithi Lesotho litjhugululwa ngokuthi &quot;inarha yabantu abakhuluma isiSutho&quot;.&lt;ref&gt;https://www.bbc.com/news/world-africa-13728324&lt;/ref&gt;

I-Lesotho yabunjwa ngo-1824 yiKosi u-Moshoeshoe I. Ukungenelela okuragela phambili kwabahlali be-Dutch kwenza bona iKosi yenze isivumelwano noMbuso we-Britain bona ibe yindawo evikelweko ngo-1868 begodu, ngo-1884, ibe yikoloni yomqhele. Yazuza ikululeko ngo-1966, begodu ngemva kwalokho yabuswa yi-Basotho National Party (BNP) iminyaka ematjhumi amabili. Umbuso wayo womthethosisekelo wabuyiselwa ngo-1993 ngemva kweminyaka elikhomba yokubusa kwamasotja. INkosi u-Moshoeshoe II yadingiswa ngo-1990 kodwana yabuya ngo-1992 begodu yabuyiselwa esikhundleni ngo-1995. Ngemva komnyaka, u-Moshoeshoe II wahlongakala begodu indodanakhe u-Letsie III wathatha isihlalo sobukhosi, esaphetheko.&lt;ref&gt;https://oxfordre.com/africanhistory/display/10.1093/acrefore/9780190277734.001.0001/acrefore-9780190277734-e-1328&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}
[[Category:Iinarha zephasi]]</text>
      <sha1>8k3wi0kwsr9tuea4cfd1j31nx1rgu77</sha1>
    </revision>
    <revision>
      <id>1843</id>
      <parentid>1842</parentid>
      <timestamp>2024-11-01T18:51:29Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1843</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1990" sha1="io2cuonkm0hpitj2jt3pu6yr85t3pa3" xml:space="preserve">'''I-Lesotho''' ngokusemthethweni uMbuso we-Lesotho, ngaphambilini owaziwa ngokuthi yi-Basutoland, lilizwe elinganamanzi eSewula ye-[[I-Afrika|Afrika]]. Njenge-enclave ye[[Isewula Afrika|Sewula Afrika]], lapho ehlanganyela khona umngcele we-1,106 km (687 mi), yi-enclave ekulu khulu ephasini, begodu ngiyo kwaphela ngaphandle kwe-Italy Peninsula. Itholakala eentabeni ze-Maloti begodu inesiqongo esiphakeme khulu eSewula ye-Afrika.[9] Inendawo engaphezu kwama-30,000 km2 (11,600 sq mi) begodu inabantu abangaba ziingidi ezimbili. Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-Maseru. Ilizwe laziwa nangebizo lesidlaliso elithi The Mountain Kingdom.&lt;ref&gt;https://www.gov.ls/about-lesotho/&lt;/ref&gt;

Isitjhaba se-Sotho (esaziwa nangokuthi yi-Basotho), lapho inarha le ithathe khona ibizo layo, yenza i-99.7% yabantu beenarha zamanje, okwenza bona ibe ngenye yeentjhaba ezineentjhaba ezifanako khulu ephasini loke. Ilimi labo lomdabu, isiSuthu, lilimi elisemthethweni kanye nesiNgisi. Ibizo elithi Lesotho litjhugululwa ngokuthi &quot;inarha yabantu abakhuluma isiSutho&quot;.&lt;ref&gt;https://www.bbc.com/news/world-africa-13728324&lt;/ref&gt;

I-Lesotho yabunjwa ngo-1824 yiKosi u-Moshoeshoe I. Ukungenelela okuragela phambili kwabahlali be-Dutch kwenza bona iKosi yenze isivumelwano noMbuso we-Britain bona ibe yindawo evikelweko ngo-1868 begodu, ngo-1884, ibe yikoloni yomqhele. Yazuza ikululeko ngo-1966, begodu ngemva kwalokho yabuswa yi-Basotho National Party (BNP) iminyaka ematjhumi amabili. Umbuso wayo womthethosisekelo wabuyiselwa ngo-1993 ngemva kweminyaka elikhomba yokubusa kwamasotja. INkosi u-Moshoeshoe II yadingiswa ngo-1990 kodwana yabuya ngo-1992 begodu yabuyiselwa esikhundleni ngo-1995. Ngemva komnyaka, u-Moshoeshoe II wahlongakala begodu indodanakhe u-Letsie III wathatha isihlalo sobukhosi, esaphetheko.&lt;ref&gt;https://oxfordre.com/africanhistory/display/10.1093/acrefore/9780190277734.001.0001/acrefore-9780190277734-e-1328&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}
[[Category:Iinarha zephasi]]</text>
      <sha1>io2cuonkm0hpitj2jt3pu6yr85t3pa3</sha1>
    </revision>
    <revision>
      <id>2108</id>
      <parentid>1843</parentid>
      <timestamp>2024-11-25T09:51:44Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <comment>Mkhakha</comment>
      <origin>2108</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1990" sha1="7ft95gaubgb69r8xmfdkxi4nk1x4nm6" xml:space="preserve">'''I-Lesotho''' ngokusemthethweni uMbuso we-Lesotho, ngaphambilini owaziwa ngokuthi yi-Basutoland, lilizwe elinganamanzi eSewula ye-[[I-Afrika|Afrika]]. Njenge-enclave ye[[Isewula Afrika|Sewula Afrika]], lapho ehlanganyela khona umngcele we-1,106 km (687 mi), yi-enclave ekulu khulu ephasini, begodu ngiyo kwaphela ngaphandle kwe-Italy Peninsula. Itholakala eentabeni ze-Maloti begodu inesiqongo esiphakeme khulu eSewula ye-Afrika.[9] Inendawo engaphezu kwama-30,000 km2 (11,600 sq mi) begodu inabantu abangaba ziingidi ezimbili. Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-Maseru. Ilizwe laziwa nangebizo lesidlaliso elithi The Mountain Kingdom.&lt;ref&gt;https://www.gov.ls/about-lesotho/&lt;/ref&gt;

Isitjhaba se-Sotho (esaziwa nangokuthi yi-Basotho), lapho inarha le ithathe khona ibizo layo, yenza i-99.7% yabantu beenarha zamanje, okwenza bona ibe ngenye yeentjhaba ezineentjhaba ezifanako khulu ephasini loke. Ilimi labo lomdabu, isiSuthu, lilimi elisemthethweni kanye nesiNgisi. Ibizo elithi Lesotho litjhugululwa ngokuthi &quot;inarha yabantu abakhuluma isiSutho&quot;.&lt;ref&gt;https://www.bbc.com/news/world-africa-13728324&lt;/ref&gt;

I-Lesotho yabunjwa ngo-1824 yiKosi u-Moshoeshoe I. Ukungenelela okuragela phambili kwabahlali be-Dutch kwenza bona iKosi yenze isivumelwano noMbuso we-Britain bona ibe yindawo evikelweko ngo-1868 begodu, ngo-1884, ibe yikoloni yomqhele. Yazuza ikululeko ngo-1966, begodu ngemva kwalokho yabuswa yi-Basotho National Party (BNP) iminyaka ematjhumi amabili. Umbuso wayo womthethosisekelo wabuyiselwa ngo-1993 ngemva kweminyaka elikhomba yokubusa kwamasotja. INkosi u-Moshoeshoe II yadingiswa ngo-1990 kodwana yabuya ngo-1992 begodu yabuyiselwa esikhundleni ngo-1995. Ngemva komnyaka, u-Moshoeshoe II wahlongakala begodu indodanakhe u-Letsie III wathatha isihlalo sobukhosi, esaphetheko.&lt;ref&gt;https://oxfordre.com/africanhistory/display/10.1093/acrefore/9780190277734.001.0001/acrefore-9780190277734-e-1328&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}

[[Mkhakha:Iinarha zephasi]]</text>
      <sha1>7ft95gaubgb69r8xmfdkxi4nk1x4nm6</sha1>
    </revision>
  </page>
  <page>
    <title>Japane</title>
    <ns>0</ns>
    <id>353</id>
    <revision>
      <id>1844</id>
      <timestamp>2024-11-01T18:53:44Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created page with &quot;'''I-Japan''' lilizwe eliyisiqhingi e-East Asia. Isendaweni ye-Pacific Ocean eduze ne-northeast coast ye-Asia mainland, begodu inemngcele ngeTjingalanga ngeLwandle le-Japan begodu isuka eLwandle le-Okhotsk ngetlhagwini ukuya eLwandle le-East China ngeSewula. I-archipelago ye-Japan ineenhlengele ezine ezikulu—i-Hokkaido, i-Honshu, i-Shikoku, ne-Kyushu—kanye neenkulungwana zeenqhingi ezincani, ezihlanganisa amakhilomitha ayi-377,975 (145,937 sq mi). I-Japan inabantu ab...&quot;</comment>
      <origin>1844</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1165" sha1="r1q2ch5gx5vtzpffdd6ehmeikgnaduo" xml:space="preserve">'''I-Japan''' lilizwe eliyisiqhingi e-East Asia. Isendaweni ye-Pacific Ocean eduze ne-northeast coast ye-Asia mainland, begodu inemngcele ngeTjingalanga ngeLwandle le-Japan begodu isuka eLwandle le-Okhotsk ngetlhagwini ukuya eLwandle le-East China ngeSewula. I-archipelago ye-Japan ineenhlengele ezine ezikulu—i-Hokkaido, i-Honshu, i-Shikoku, ne-Kyushu—kanye neenkulungwana zeenqhingi ezincani, ezihlanganisa amakhilomitha ayi-377,975 (145,937 sq mi). I-Japan inabantu abapheze babe ziingidi ezili-124 ukusukela ngo-2024, begodu yinarha yetjhumi nanye enabantu abanengi. Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-Tokyo; i-Greater [[Tokyo]] Area yindawo ekulu khulu yedorobha ephasini, enabantu abangaphezu kweengidi ezingama-38 ukusukela ngo-2016. I-Japan ihlukaniswe yaba ziindawo ezima-47 zokuphatha kanye neendawo ezibunane zesintu. Pheze amakota amathathu wendawo yenarha le ineentaba begodu inamahlathi amanengi, igxile kwezokulima kanye nabantu abahlala emadorobheni khulu emathafeni wayo asepumalanga. Inarha le ihlezi e-Pacific Ring of Fire, okwenza bona iinhlenge zayo zibe sengozini yokusikinyeka kwephasi okubhubhisako kanye nama-tsunami.</text>
      <sha1>r1q2ch5gx5vtzpffdd6ehmeikgnaduo</sha1>
    </revision>
    <revision>
      <id>1845</id>
      <parentid>1844</parentid>
      <timestamp>2024-11-01T18:54:02Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1845</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1178" sha1="2dakjmg1fdcm42c8ka8kr24gcy56rxk" xml:space="preserve">'''I-Japan''' lilizwe eliyisiqhingi e-East Asia. Isendaweni ye-Pacific Ocean eduze ne-northeast coast ye-Asia mainland, begodu inemngcele ngeTjingalanga ngeLwandle le-Japan begodu isuka eLwandle le-Okhotsk ngetlhagwini ukuya eLwandle le-East China ngeSewula. I-archipelago ye-Japan ineenhlengele ezine ezikulu—i-Hokkaido, i-Honshu, i-Shikoku, ne-Kyushu—kanye neenkulungwana zeenqhingi ezincani, ezihlanganisa amakhilomitha ayi-377,975 (145,937 sq mi). I-Japan inabantu abapheze babe ziingidi ezili-124 ukusukela ngo-2024, begodu yinarha yetjhumi nanye enabantu abanengi. Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-Tokyo; i-Greater [[Tokyo]] Area yindawo ekulu khulu yedorobha ephasini, enabantu abangaphezu kweengidi ezingama-38 ukusukela ngo-2016. I-Japan ihlukaniswe yaba ziindawo ezima-47 zokuphatha kanye neendawo ezibunane zesintu. Pheze amakota amathathu wendawo yenarha le ineentaba begodu inamahlathi amanengi, igxile kwezokulima kanye nabantu abahlala emadorobheni khulu emathafeni wayo asepumalanga. Inarha le ihlezi e-Pacific Ring of Fire, okwenza bona iinhlenge zayo zibe sengozini yokusikinyeka kwephasi okubhubhisako kanye nama-tsunami.
==Iinkomba==</text>
      <sha1>2dakjmg1fdcm42c8ka8kr24gcy56rxk</sha1>
    </revision>
    <revision>
      <id>1846</id>
      <parentid>1845</parentid>
      <timestamp>2024-11-01T18:54:33Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1846</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1219" sha1="pmmgz3rq7oxfkyje05ip1kbzptbix21" xml:space="preserve">'''I-Japan''' lilizwe eliyisiqhingi e-East Asia. Isendaweni ye-Pacific Ocean eduze ne-northeast coast ye-Asia mainland, begodu inemngcele ngeTjingalanga ngeLwandle le-Japan begodu isuka eLwandle le-Okhotsk ngetlhagwini ukuya eLwandle le-East China ngeSewula. I-archipelago ye-Japan ineenhlengele ezine ezikulu—i-Hokkaido, i-Honshu, i-Shikoku, ne-Kyushu—kanye neenkulungwana zeenqhingi ezincani, ezihlanganisa amakhilomitha ayi-377,975 (145,937 sq mi). I-Japan inabantu abapheze babe ziingidi ezili-124 ukusukela ngo-2024, begodu yinarha yetjhumi nanye enabantu abanengi. Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-Tokyo; i-Greater [[Tokyo]] Area yindawo ekulu khulu yedorobha ephasini, enabantu abangaphezu kweengidi ezingama-38 ukusukela ngo-2016. I-Japan ihlukaniswe yaba ziindawo ezima-47 zokuphatha kanye neendawo ezibunane zesintu. Pheze amakota amathathu wendawo yenarha le ineentaba begodu inamahlathi amanengi, igxile kwezokulima kanye nabantu abahlala emadorobheni khulu emathafeni wayo asepumalanga. Inarha le ihlezi e-Pacific Ring of Fire, okwenza bona iinhlenge zayo zibe sengozini yokusikinyeka kwephasi okubhubhisako kanye nama-tsunami.
==Iinkomba==
{{Reflist}}
[[Category:Iinarha zephasi]]</text>
      <sha1>pmmgz3rq7oxfkyje05ip1kbzptbix21</sha1>
    </revision>
    <revision>
      <id>1847</id>
      <parentid>1846</parentid>
      <timestamp>2024-11-01T18:56:29Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1847</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1276" sha1="p85gfbywdkgci626r25lmvv4hcn02b5" xml:space="preserve">'''I-Japan''' lilizwe eliyisiqhingi e-East Asia. Isendaweni ye-Pacific Ocean eduze ne-northeast coast ye-Asia mainland, begodu inemngcele ngeTjingalanga ngeLwandle le-Japan begodu isuka eLwandle le-Okhotsk ngetlhagwini ukuya eLwandle le-East China ngeSewula. I-archipelago ye-Japan ineenhlengele ezine ezikulu—i-Hokkaido, i-Honshu, i-Shikoku, ne-Kyushu—kanye neenkulungwana zeenqhingi ezincani, ezihlanganisa amakhilomitha ayi-377,975 (145,937 sq mi). I-Japan inabantu abapheze babe ziingidi ezili-124 ukusukela ngo-2024, begodu yinarha yetjhumi nanye enabantu abanengi. Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-Tokyo; i-Greater [[Tokyo]] Area yindawo ekulu khulu yedorobha ephasini, enabantu abangaphezu kweengidi ezingama-38 ukusukela ngo-2016. I-Japan ihlukaniswe yaba ziindawo ezima-47 zokuphatha kanye neendawo ezibunane zesintu. Pheze amakota amathathu wendawo yenarha le ineentaba begodu inamahlathi amanengi, igxile kwezokulima kanye nabantu abahlala emadorobheni khulu emathafeni wayo asepumalanga. Inarha le ihlezi e-Pacific Ring of Fire, okwenza bona iinhlenge zayo zibe sengozini yokusikinyeka kwephasi okubhubhisako kanye nama-tsunami.&lt;ref&gt;https://www.britannica.com/place/Japan/History&lt;/ref&gt;
==Iinkomba==
{{Reflist}}
[[Category:Iinarha zephasi]]</text>
      <sha1>p85gfbywdkgci626r25lmvv4hcn02b5</sha1>
    </revision>
    <revision>
      <id>2136</id>
      <parentid>1847</parentid>
      <timestamp>2024-11-25T18:28:45Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>Mkhakha</comment>
      <origin>2136</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1276" sha1="kr4p2k6lxelrrj6hrex7irh4nmtcdau" xml:space="preserve">'''I-Japan''' lilizwe eliyisiqhingi e-East Asia. Isendaweni ye-Pacific Ocean eduze ne-northeast coast ye-Asia mainland, begodu inemngcele ngeTjingalanga ngeLwandle le-Japan begodu isuka eLwandle le-Okhotsk ngetlhagwini ukuya eLwandle le-East China ngeSewula. I-archipelago ye-Japan ineenhlengele ezine ezikulu—i-Hokkaido, i-Honshu, i-Shikoku, ne-Kyushu—kanye neenkulungwana zeenqhingi ezincani, ezihlanganisa amakhilomitha ayi-377,975 (145,937 sq mi). I-Japan inabantu abapheze babe ziingidi ezili-124 ukusukela ngo-2024, begodu yinarha yetjhumi nanye enabantu abanengi. Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-Tokyo; i-Greater [[Tokyo]] Area yindawo ekulu khulu yedorobha ephasini, enabantu abangaphezu kweengidi ezingama-38 ukusukela ngo-2016. I-Japan ihlukaniswe yaba ziindawo ezima-47 zokuphatha kanye neendawo ezibunane zesintu. Pheze amakota amathathu wendawo yenarha le ineentaba begodu inamahlathi amanengi, igxile kwezokulima kanye nabantu abahlala emadorobheni khulu emathafeni wayo asepumalanga. Inarha le ihlezi e-Pacific Ring of Fire, okwenza bona iinhlenge zayo zibe sengozini yokusikinyeka kwephasi okubhubhisako kanye nama-tsunami.&lt;ref&gt;https://www.britannica.com/place/Japan/History&lt;/ref&gt;
==Iinkomba==
{{Reflist}}

[[Mkhakha:Iinarha zephasi]]</text>
      <sha1>kr4p2k6lxelrrj6hrex7irh4nmtcdau</sha1>
    </revision>
    <revision>
      <id>2917</id>
      <parentid>2136</parentid>
      <timestamp>2025-06-06T17:01:07Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>gbfqw</comment>
      <origin>2917</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1357" sha1="q1689p8mrdbukr9ngektf7jjrx8r3ie" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. I-Japan''' lilizwe eliyisiqhingi e-East Asia. Isendaweni ye-Pacific Ocean eduze ne-northeast coast ye-Asia mainland, begodu inemngcele ngeTjingalanga ngeLwandle le-Japan begodu isuka eLwandle le-Okhotsk ngetlhagwini ukuya eLwandle le-East China ngeSewula. I-archipelago ye-Japan ineenhlengele ezine ezikulu—i-Hokkaido, i-Honshu, i-Shikoku, ne-Kyushu—kanye neenkulungwana zeenqhingi ezincani, ezihlanganisa amakhilomitha ayi-377,975 (145,937 sq mi). I-Japan inabantu abapheze babe ziingidi ezili-124 ukusukela ngo-2024, begodu yinarha yetjhumi nanye enabantu abanengi. Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-Tokyo; i-Greater [[Tokyo]] Area yindawo ekulu khulu yedorobha ephasini, enabantu abangaphezu kweengidi ezingama-38 ukusukela ngo-2016. I-Japan ihlukaniswe yaba ziindawo ezima-47 zokuphatha kanye neendawo ezibunane zesintu. Pheze amakota amathathu wendawo yenarha le ineentaba begodu inamahlathi amanengi, igxile kwezokulima kanye nabantu abahlala emadorobheni khulu emathafeni wayo asepumalanga. Inarha le ihlezi e-Pacific Ring of Fire, okwenza bona iinhlenge zayo zibe sengozini yokusikinyeka kwephasi okubhubhisako kanye nama-tsunami.&lt;ref&gt;https://www.britannica.com/place/Japan/History&lt;/ref&gt;
==Iinkomba==
{{Reflist}}

[[Mkhakha:Iinarha zephasi]]</text>
      <sha1>q1689p8mrdbukr9ngektf7jjrx8r3ie</sha1>
    </revision>
    <revision>
      <id>3141</id>
      <parentid>2917</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Simakahle Moselekatse|Simakahle Moselekatse]]</comment>
      <origin>2136</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1276" sha1="kr4p2k6lxelrrj6hrex7irh4nmtcdau" xml:space="preserve">'''I-Japan''' lilizwe eliyisiqhingi e-East Asia. Isendaweni ye-Pacific Ocean eduze ne-northeast coast ye-Asia mainland, begodu inemngcele ngeTjingalanga ngeLwandle le-Japan begodu isuka eLwandle le-Okhotsk ngetlhagwini ukuya eLwandle le-East China ngeSewula. I-archipelago ye-Japan ineenhlengele ezine ezikulu—i-Hokkaido, i-Honshu, i-Shikoku, ne-Kyushu—kanye neenkulungwana zeenqhingi ezincani, ezihlanganisa amakhilomitha ayi-377,975 (145,937 sq mi). I-Japan inabantu abapheze babe ziingidi ezili-124 ukusukela ngo-2024, begodu yinarha yetjhumi nanye enabantu abanengi. Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-Tokyo; i-Greater [[Tokyo]] Area yindawo ekulu khulu yedorobha ephasini, enabantu abangaphezu kweengidi ezingama-38 ukusukela ngo-2016. I-Japan ihlukaniswe yaba ziindawo ezima-47 zokuphatha kanye neendawo ezibunane zesintu. Pheze amakota amathathu wendawo yenarha le ineentaba begodu inamahlathi amanengi, igxile kwezokulima kanye nabantu abahlala emadorobheni khulu emathafeni wayo asepumalanga. Inarha le ihlezi e-Pacific Ring of Fire, okwenza bona iinhlenge zayo zibe sengozini yokusikinyeka kwephasi okubhubhisako kanye nama-tsunami.&lt;ref&gt;https://www.britannica.com/place/Japan/History&lt;/ref&gt;
==Iinkomba==
{{Reflist}}

[[Mkhakha:Iinarha zephasi]]</text>
      <sha1>kr4p2k6lxelrrj6hrex7irh4nmtcdau</sha1>
    </revision>
    <revision>
      <id>3528</id>
      <parentid>3141</parentid>
      <timestamp>2025-08-02T15:00:04Z</timestamp>
      <contributor>
        <ip>117.250.237.126</ip>
      </contributor>
      <comment>പ്രൊഫസർ പ്രേം രാജ്‌ പുഷ്പാകരന്‍, എൻ.ഐ.റ്റി. കാലിക്കറ്റ് ♡ Professor P̂rém ráj P̂üshp̂ákárán, NIT Calicut 🌷🍀🌼🌻🌺🌹🌸🏵️💮</comment>
      <origin>3528</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1272" sha1="h1thaeoqs7mtun9wks5v15bkbqkrths" xml:space="preserve">'''I-Japan''' lilizwe eliyisiqhingi e-East Asia. Isendaweni ye-Pacific Ocean eduze ne-northeast coast ye-Asia mainland, begodu inemngcele ngeTjingalanga ngeLwandle le-Japan begodu isuka eLwandle le-Okhotsk ngetlhagwini ukuya eLwandle le-East China ngeSewula. I-archipelago ye-Japan ineenhlengele ezine ezikulu—i-Hokkaido, i-Honshu, i-Shikoku, ne-Kyushu—kanye neenkulungwana zeenqhingi ezincani, ezihlanganisa amakhilomitha ayi-377,975 (145,937 sq mi). I-Japan inabantu abapheze babe ziingidi ezili-124 ukusukela ngo-2024, begodu yinarha yetjhumi nanye enabantu abanengi. Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-Tokyo; i-Greater Tokyo Area yindawo ekulu khulu yedorobha ephasini, enabantu abangaphezu kweengidi ezingama-38 ukusukela ngo-2016. I-Japan ihlukaniswe yaba ziindawo ezima-47 zokuphatha kanye neendawo ezibunane zesintu. Pheze amakota amathathu wendawo yenarha le ineentaba begodu inamahlathi amanengi, igxile kwezokulima kanye nabantu abahlala emadorobheni khulu emathafeni wayo asepumalanga. Inarha le ihlezi e-Pacific Ring of Fire, okwenza bona iinhlenge zayo zibe sengozini yokusikinyeka kwephasi okubhubhisako kanye nama-tsunami.&lt;ref&gt;https://www.britannica.com/place/Japan/History&lt;/ref&gt;
==Iinkomba==
{{Reflist}}

[[Mkhakha:Iinarha zephasi]]</text>
      <sha1>h1thaeoqs7mtun9wks5v15bkbqkrths</sha1>
    </revision>
    <revision>
      <id>5671</id>
      <parentid>3528</parentid>
      <timestamp>2025-09-04T11:23:16Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <origin>5671</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1751" sha1="dw083q0duxl91skr3t6nm2hlyssszge" xml:space="preserve">[[Isimumathi:Horyu-ji18s3200.jpg|thumb|Isithombe se-Japan|292x292px]]
'''I-Japan''' lilizwe eliyisiqhingi e-East Asia. Isendaweni ye-Pacific Ocean eduze ne-northeast coast ye-Asia mainland, begodu inemngcele ngeTjingalanga ngeLwandle le-Japan begodu isuka eLwandle le-Okhotsk ngetlhagwini ukuya eLwandle le-East China ngeSewula. I-archipelago ye-Japan ineenhlengele ezine ezikulu—i-Hokkaido, i-Honshu, i-Shikoku, ne-Kyushu—kanye neenkulungwana zeenqhingi ezincani, ezihlanganisa amakhilomitha ayi-377,975 (145,937 sq mi). I-[[Japane|Japan]] inabantu abapheze babe ziingidi ezili-124 ukusukela ngo-2024, begodu yinarha yetjhumi nanye enabantu abanengi.&lt;ref&gt;NY Post. (2025). ''Japan records nearly 1M more deaths than births in 2024 - as country's population continues to plummet''. Retrieved from &lt;nowiki&gt;https://nypost.com/2025/08/07/world-news/japan-records-nearly-1-million-more-deaths-than-births-in-2024-as-countrys-natality-continues-to-plummet/&lt;/nowiki&gt;&lt;/ref&gt; Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-Tokyo; i-Greater Tokyo Area yindawo ekulu khulu yedorobha ephasini, enabantu abangaphezu kweengidi ezingama-38 ukusukela ngo-2016.&lt;ref&gt;'''Japan Statistical Yearbook. (2017).''' ''Statistics Bureau of Japan''. Retrieved from &lt;nowiki&gt;https://www.stat.go.jp/english/data/nenkan/index.html&lt;/nowiki&gt;&lt;/ref&gt; I-Japan ihlukaniswe yaba ziindawo ezima-47 zokuphatha kanye neendawo ezibunane zesintu. Pheze amakota amathathu wendawo yenarha le ineentaba begodu inamahlathi amanengi, igxile kwezokulima kanye nabantu abahlala emadorobheni khulu emathafeni wayo asepumalanga. Inarha le ihlezi e-Pacific Ring of Fire, okwenza bona iinhlenge zayo zibe sengozini yokusikinyeka kwephasi okubhubhisako kanye nama-tsunami.



== Imithombo lwazi ==</text>
      <sha1>dw083q0duxl91skr3t6nm2hlyssszge</sha1>
    </revision>
    <revision>
      <id>6063</id>
      <parentid>5671</parentid>
      <timestamp>2025-12-10T04:32:00Z</timestamp>
      <contributor>
        <username>WikiMzansi</username>
        <id>1200</id>
      </contributor>
      <comment>Created by translating the section &quot;History&quot; from the page &quot;[[:en:Special:Redirect/revision/1326567284|Japan]]&quot;</comment>
      <origin>6063</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="12275" sha1="kswem1r4uaahznvpyjs69z5l6wz47ss" xml:space="preserve">[[Isimumathi:Horyu-ji18s3200.jpg|thumb|Isithombe se-Japan|292x292px]]
'''I-Japan''' lilizwe eliyisiqhingi e-East Asia. Isendaweni ye-Pacific Ocean eduze ne-northeast coast ye-Asia mainland, begodu inemngcele ngeTjingalanga ngeLwandle le-Japan begodu isuka eLwandle le-Okhotsk ngetlhagwini ukuya eLwandle le-East China ngeSewula. I-archipelago ye-Japan ineenhlengele ezine ezikulu—i-Hokkaido, i-Honshu, i-Shikoku, ne-Kyushu—kanye neenkulungwana zeenqhingi ezincani, ezihlanganisa amakhilomitha ayi-377,975 (145,937 sq mi). I-[[Japane|Japan]] inabantu abapheze babe ziingidi ezili-124 ukusukela ngo-2024, begodu yinarha yetjhumi nanye enabantu abanengi.&lt;ref&gt;NY Post. (2025). ''Japan records nearly 1M more deaths than births in 2024 - as country's population continues to plummet''. Retrieved from &lt;nowiki&gt;https://nypost.com/2025/08/07/world-news/japan-records-nearly-1-million-more-deaths-than-births-in-2024-as-countrys-natality-continues-to-plummet/&lt;/nowiki&gt;&lt;/ref&gt; Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-Tokyo; i-Greater Tokyo Area yindawo ekulu khulu yedorobha ephasini, enabantu abangaphezu kweengidi ezingama-38 ukusukela ngo-2016.&lt;ref&gt;'''Japan Statistical Yearbook. (2017).''' ''Statistics Bureau of Japan''. Retrieved from &lt;nowiki&gt;https://www.stat.go.jp/english/data/nenkan/index.html&lt;/nowiki&gt;&lt;/ref&gt; I-Japan ihlukaniswe yaba ziindawo ezima-47 zokuphatha kanye neendawo ezibunane zesintu. Pheze amakota amathathu wendawo yenarha le ineentaba begodu inamahlathi amanengi, igxile kwezokulima kanye nabantu abahlala emadorobheni khulu emathafeni wayo asepumalanga. Inarha le ihlezi e-Pacific Ring of Fire, okwenza bona iinhlenge zayo zibe sengozini yokusikinyeka kwephasi okubhubhisako kanye nama-tsunami.



== Imithombo lwazi ==

== History ==

=== iJapani ===
[[Isimumathi:Emperor_Jimmu.jpg|thumb|Umbusi odumileko Emperor Jimmu ]]
I-Japan[a] lilizwe eliyisiqhingi e-East Asia. Itholakala eLwandle le-Pacific eduze negwini elisenyakatho-mpumalanga ye-Asia, inomngcele ngeTjingalanga ngeLwandle le-Japan begodu isuka eLwandle le-Okhotsk ngetlhagwini ukuya eLwandle le-East China ngeSewula. I-archipelago ye-Japan ineenhlengele ezine ezikulu kanye neenhlengele ezincani ezili-14,121. I-Japan ihlukaniswe yaba ziindawo ezima-47 zokuphatha kanye neendawo ezisibhozo zesintu, begodu pheze ama-75% wendawo yayo ineentaba begodu inamahlathi amanengi, igxila ezolimo zayo kanye nabantu abahlala emadorobheni khulu emathafeni wayo asepumalanga. Njengombana inabantu abangaphezu kweengidi ezili-123 ukusukela ngomnyaka ka-2025, lilizwe le-11 elinabantu abanengi ephasini. I-Tokyo yidolobha elikhulu lenarha.


Indawo yokuhlala yokuthoma eyaziwako ye-archipelago yathoma nge-Upper Paleolithic, begodu ukuthoma kwe-Japanese Paleolithic kwathoma ngo-c. 36,000 BC. Hlangana nekhulu lesi-4 nelesi-6, imibuso yayo yahlanganiswa ngaphasi kombusi e-Nara begodu ngokukhamba kwesikhathi e-Heian-kyō. Kusukela ngekhulu le-12, amandla wamambala bekaphethwe ziinkhulu zebutho ezaziwa nge-shōgun kanye namakhosi we-feudal abizwa nge-daimyō, ebegade aphoqelelwa ziinkhulu ezibizwa nge-samurai.[11] Ngemva kokubusa yi-Kamakura ne-Ashikaga shogunates kanye nekhulu leminyaka lamazwe alwako, i-Japan yahlanganiswa ngo-1600 yi-Tokugawa shogunate, eyaqalisa umthethomgomo wangaphandle wokuzihlukanisa. Ngo-1853, imikhumbi ye-Amerikha yakatelela i-Japan bona ivule ukurhwebelana ngeTjingalanga, okwaholela ekupheleni kwe-shogunate nokubuyiselwa kwamandla we-imperial ngo-1868.


I-Japan ivela kokuthoma emlandwini otlolwe phasi ''encwadini ye-China ye-Han'', eyaqedwa ngo-111 AD, lapho ichazwa khona njengemibuso emincani eyikhulu. Ngemva kweminyaka elikhulu, ''iNcwadi ka-Wei'' itlola bona umbuso we -Yamatai (okungatjho i-Yamato ) wahlanganisa inengi lemibuso le.   UbuBhuda bethulwa e-Japan ukusuka e-Baekje (umbuso we-Korea) ngo-552, kodwana ukuthuthukiswa kobuBuddha be-Japan kwathonywa khulu yi-China.  Nanyana bekuphikiswa ekuthomeni, ubuBuddha bakhuthazwa sisigaba esibusako, kufaka hlangana abantu abafana noMkhosana u-Shōtoku, begodu bathola ukwamukelwa okukhulu ukuthoma ngesikhathi saka-Asuka (592–710). 

Ngomnyaka ka-645, urhulumende odoswa phambili ngu -Prince Naka no Ōe no -Fujiwara no Kamatari basungula begodu basebenzisa i- Taika Reforms . Itjhuguluko lathoma ngokutjhugulula umhlaba, ngokusekelwe emibonweni ka-Confucius nefilosofi evela e-China .  Yenza bona yoke inarha e-Japan ibe ngeyesizwe, bona isabalaliswe ngokulinganako hlangana nabalimi, begodu yayala bona kwenziwe irejista yemizi njengesisekelo sehlelo elitjha lomthelo.  Umnqopho wamambala weenguquko bekukuletha ukuhlanganiswa okukhulu nokuthuthukisa amandla wekhotho yombuso, ebegade isekelwe esakhiweni sombuso we-China. Iinthunywa nabafundi bathunyelwa e-China ukuyokufunda ngokutlola kwe-China, ipolotiki, ubukghwari, nekolo. &lt;ref name=&quot;Totman 2005&quot; /&gt;

Ipi ye-Jinshin yango-672, ukulwa okukhulu hlangana kweKosi u-Ōama nomzukulu wakhe uKosi u-Ōtomo, kwaba sizathu esikhulu sokwenza amatjhuguluko wokuphatha. &lt;ref name=&quot;ritsuryo&quot; /&gt; Amatjhuguluko la agcina ngokumenyezelwa kwe- Taihō Code, eyahlanganisa imithetho ekhona begodu yasungula isakhiwo sombuso wendawo ophakathi nongaphasi.  Amatjhuguluko wezomthetho la adala umbuso ritsuryō, ihlelo lombuso ohlanganisiweko wesitayela se-China elahlala likhona isigamu seminyaka eyinkulungwane. 

Isikhathi se-Nara (710–784) satshwaya ukuvela kombuso we-Japan odzimelele e-Imperial Court e- Heijō-kyō ( i-Nara yanje). Isikhathi lesi sibonakala ngokuvela kwesiko lokutlola elitjha ngokuqedwa kwe- Kojiki (712) ne Nihon Shoki (720), kanye nokuthuthukiswa kwemisebenzi yobuciko nezakhiwo eziphefumulelwe maBuddha.   Ubhubhane lwe-smallpox ngo-735-737 kukholelwa bona lwabulala ingcenye eyodwa kwezintathu yabantu be-Japan. &lt;ref name=&quot;Courtiers&quot; /&gt;  Ngo-784, uMbusi u-Kanmu wathutha idolobha elikhulu, wahlala e- Heian-kyō (i- Kyoto yanamhlanjesi) ngo-794. &lt;ref name=&quot;Courtiers&quot; /&gt; Lokhu kwathoma isikhathi se-Heian (794–1185), lapho kwavela khona isiko lama-Japan. I-Murasaki Shikibu 's ''The Tale of Genji'' kanye namagama wengoma yesitjhaba ye-Japan &quot;Kimigayo &quot; atlolwa ngesikhatheso. 

=== Isikhathi sama-feudal ===
[[Isimumathi:Mokoshuraiekotoba.jpg|thumb|Ama-samurai we-Japan agibela isikepe sama-Mongol ngesikhathi sokuhlasela kwama-Mongol e-Japan, okuvezwe ku- Mōko Shūrai Ekotoba, 1293]]
[[Isimumathi:The_Three_Unifiers_of_Japan.jpg|thumb|Izinto ezintathu ezihlanganisa i-Japan. Kwesokunxele ukuya kwesokudla: u-Oda Nobunaga, u-Toyotomi Hideyoshi no -Tokugawa Ieyasu .]]
Isikhathi se-feudal ye-Japan sabonakala ngokuvela nokubusa kwesigaba esibusako samasotja, ama -samurai .  Ngo-1185, ngemva kokuhlulwa kwesizwe se -Taira yisizwe se-Minamoto ePini ye-Genpei, i-samurai Minamoto no Yoritomo yasungula urhulumende webutho e -Kamakura .  Ngemva kokuhlongakala kwaka-Yoritomo, isizwe sama-Hōjō sathatha amandla njengababusi be shōgun .  Isikolo se-Zen se-Buddhism sathonywa ukusuka e-China ngesikhathi se-Kamakura (1185–1333) begodu sathandwa hlangana nesigaba sama-samurai. 

I- Kamakura shogunate yakhandela ukuhlaselwa kwama-Mongol ngo-1274 nango-1281 kodwana ekugcineni yachithwa nguMbusi u-Go-Daigo .  U-Go-Daigo wahlulwa ngu- Ashikaga Takauji ngo-1336, ukuthoma isikhathi se-Muromachi (1336–1573).  I -Ashikaga shogunate elandelako yehluleka ukulawula amakhosi wepi we-feudal ( daimyō ) begodu ipi yombango yathoma ngo-1467, yavula isikhathi se-Sengoku (&quot;Imibuso Elwako&quot;). 

=== Isikhathi samanje ===
 
Ibutho le -United States Navy lathumela u-Commodore u-Matthew C. Perry bona aphoqelele ukuvulwa kwe-Japan ephasini langaphandle. Ukufika e -Uraga &quot; ngemikhumbi emnyama &quot; emine ngoJulayi 1853, i- Perry Expedition yaphumela emhlanganweni we-Kanagawa kaNtaka 1854.  Iimvumelwano ezifanako ezalandelako namanye amazwe weTjingalanga zaletha ubujamo obubudisi bezomnotho nezepolotiki. &lt;ref name=&quot;Closed&quot; /&gt; Ukutjhiya umsebenzi kwe- shōgun kwaholela ePini ye-Boshin nokusungulwa kombuso ohlanganisiweko ohlanganiswe ngaphasi kombusi ( ukubuyiselwa kwe-Meiji ).  Ngokwamukela iinkhungo zepolotiki, zokwahlulela, nezamasotja zeTjingalanga, iKhabinethi yahlela umKhandlu we-Privy, yethula umThethosisekelo we-Meiji (ngoNovemba 29, 1890), begodu yahlanganisa i- Imperial Diet . 

Ngesikhathi se-Meiji (1868-1912), uMbuso we-Japan wavela njengombuso othuthuke khulu e -Asia begodu waba ngumbuso wephasi onebubulo owaphishekela ukulwa kwezempi ukwandisa indawo yawo yomthelela.    Ngemva kokunqoba ePini yokuThoma ye-Sino-Japanese (1894–1895) kanye ne -Russo-Japanese War (1904–1905), i-Japan yathola ukulawula i-Taiwan, i-Korea kanye nengcenye esewula ye -Sakhalin,   begodu yahlanganisa i-Korea ngo-1910  35&amp;nbsp;iingidigidi ngo-1873 ukuya ku-70&amp;nbsp;iingidigidi ngo-1935, ngokutjhuguluka okukhulu ukuya emadorobheni.  

Ekuthomeni kwekhulu lama-20 kwaba nesikhathi sentando yenengi ye-Taishō (1912 ukuya ku-1926) eyasibekelwa kukhuphuka kokunwebeka nokusebenzisa amasotja .   Ipi yePhasi yoku-1 yavumela i-Japan, eyajoyina ihlangothi lama -Allies anqobileko, bona ithathe iindawo ze-Germany e- Pacific ne-China ngo- 1920 . &lt;ref name=&quot;ramesh&quot; /&gt; Ngeminyaka yabo-1920 kwaba nokutjhuguluka kwezepolotiki ukuya e-statism, isikhathi sokungabi nomthetho ngemva kokuzamazama komhlaba okukhulu kwe-Tokyo ngo-1923, ukudluliswa kwemithetho ephikisana nokuphikisana kwezepolotiki, kanye nochungechunge lokuzama ukuvukela umbuso .   

Ikambiso le yarhaba ngabo-1930, yazala amaqembu amanengi wobuzwe ahlanganyela ubutha bentando yenengi ekhululekileko nokuzinikela ekunwebeni e-Asia.  Ngo-1931, i-Japan yahlasela i-China begodu yathatha i-Manchuria, okwaholela ekusungulweni kombuso we -Manchukuo ngo-1932; ngemva kokusolwa kwamazwe ngamazwe kokuthunjwa, yatjhiya i- League of Nations ngo-1933.  Ngo-1936, i-Japan yatlikitla i -Anti-Comintern Pact ne -Nazi Germany ; isivumelwano se-1940 samaqembu amathathu senza bona kube ngelinye lamandla we-Axis . 
[[Isimumathi:Mamoru_Shigemitsu_signs_the_Instrument_of_Surrender,_officially_ending_the_Second_World_War.jpg|thumb|Ngomhlana ali-2 kuNobayeni wee-1945, i-Japan yazinikela kuma-Allies .]]
Umbuso we-Japan wahlasela ezinye iindawo ze-China ngo-1937, okwenza bona kube nepi yesibili ye-Sino-Japanese (1937–1945).  Ngo-1940, uMbuso wahlasela i-French Indochina, ngemva kwalokho i-United States yabeka umkhawulo we-oyile e-Japan.  ] ​​​​  Kizo zoke iindawo ebezithathwe yi-Japan ngesikhathi sepi, ukuhlukunyezwa okunengi kwenziwa ebantwini bendawo. Abafazi abanengi bakateleleka bona babe ziingqila zezemacansini . 

Ngemva kokunqoba kwama-Allied eminyakeni emine elandelako, okwagcina ngokuhlasela kwe-Soviet i-Manchuria kanye nokubhoma kwe-athomu e-Hiroshima ne-Nagasaki ngo-1945, i-Japan yavuma ukuzinikela ngaphandle kwemibandela .  Ipi le yabulala i-Japan iingidigidi zamaphilo kanye neendawo ezinengi ezahlulwako, okufakahlangana iindawo ''ze'' -Japan ezifana ne -Korea, i-Taiwan, i-Karafuto, kanye nama- Kurils .  Ama-Allies, aholwa yi-United States, abuyisela iingidigidi zabahlali be-Japan eendaweni zabo zangaphambilini kanye namakamu wezempi kiyo yoke i-Asia, lokho kwaqeda khulu uMbuso we-Japan kanye nomthelela wawo phezu kweendawo egade uwathumba.  &lt;ref name=&quot;phoenix&quot; /&gt; Ama-Allies abize iKhotho yamaButho ye-International ye-Far East ukutshutshisa abadosiphambili be-Japan ngaphandle koMbusi  ngebanga lobulelesi bepi be-Japan . 

Ngo-1947, i-Japan yamukela umthethosisekelo omutjha ogcizelela imikghwa yentando yenengi ekhululekileko.  Ukuthunjwa kwama-Allied kwaphela ngesivumelwano se-San Francisco ngo-1952,  begodu i-Japan yavunyelwa ubulungu be -United Nations ngo-1956. &lt;ref name=&quot;phoenix&quot; /&gt; Isikhathi sokukhula okurekhodiweko senza bona i-Japan ibe mnotho wesibili ngobukhulu ephasini ngesikhatheso ; &lt;ref name=&quot;phoenix&quot; /&gt; lokhu kwaphela phakathi kwabo-1990 ngemva kokuqhamuka kwebhamuza lentengo yepahla, ukuthoma &quot; Iminyaka elitjhumi elahlekileko &quot; ebonakala ngokujama kwezomnotho nokunyuka kwamanani okuphasi.  Ngo-2011, i-Japan yahlangabezana nokusikinyeka kwephasi okukhulu khulu emlandwini wayo— ukusikinyeka kwephasi kwe-Tōhoku —okwabanga ihlekelele yenyukliya ye-Fukushima Daiichi .  Ngomhlana ali-1 kuMrhayili 2019, ngemva kokutjhiya uMbusi u-Akihito, indodanakhe u -Naruhito waba nguMbusi, wathoma i Reiwa isikhathi (2019-).</text>
      <sha1>kswem1r4uaahznvpyjs69z5l6wz47ss</sha1>
    </revision>
    <revision>
      <id>6064</id>
      <parentid>6063</parentid>
      <timestamp>2025-12-10T04:33:41Z</timestamp>
      <contributor>
        <username>WikiMzansi</username>
        <id>1200</id>
      </contributor>
      <origin>6064</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="11827" sha1="7tcdv1b6maz3bvshxpv0n7qnotgz4kd" xml:space="preserve">[[Isimumathi:Horyu-ji18s3200.jpg|thumb|Isithombe se-Japan|292x292px]]
'''I-Japan''' lilizwe eliyisiqhingi e-East Asia. Isendaweni ye-Pacific Ocean eduze ne-northeast coast ye-Asia mainland, begodu inemngcele ngeTjingalanga ngeLwandle le-Japan begodu isuka eLwandle le-Okhotsk ngetlhagwini ukuya eLwandle le-East China ngeSewula. I-archipelago ye-Japan ineenhlengele ezine ezikulu—i-Hokkaido, i-Honshu, i-Shikoku, ne-Kyushu—kanye neenkulungwana zeenqhingi ezincani, ezihlanganisa amakhilomitha ayi-377,975 (145,937 sq mi). I-[[Japane|Japan]] inabantu abapheze babe ziingidi ezili-124 ukusukela ngo-2024, begodu yinarha yetjhumi nanye enabantu abanengi.&lt;ref&gt;NY Post. (2025). ''Japan records nearly 1M more deaths than births in 2024 - as country's population continues to plummet''. Retrieved from &lt;nowiki&gt;https://nypost.com/2025/08/07/world-news/japan-records-nearly-1-million-more-deaths-than-births-in-2024-as-countrys-natality-continues-to-plummet/&lt;/nowiki&gt;&lt;/ref&gt; Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-Tokyo; i-Greater Tokyo Area yindawo ekulu khulu yedorobha ephasini, enabantu abangaphezu kweengidi ezingama-38 ukusukela ngo-2016.&lt;ref&gt;'''Japan Statistical Yearbook. (2017).''' ''Statistics Bureau of Japan''. Retrieved from &lt;nowiki&gt;https://www.stat.go.jp/english/data/nenkan/index.html&lt;/nowiki&gt;&lt;/ref&gt; I-Japan ihlukaniswe yaba ziindawo ezima-47 zokuphatha kanye neendawo ezibunane zesintu. Pheze amakota amathathu wendawo yenarha le ineentaba begodu inamahlathi amanengi, igxile kwezokulima kanye nabantu abahlala emadorobheni khulu emathafeni wayo asepumalanga. Inarha le ihlezi e-Pacific Ring of Fire, okwenza bona iinhlenge zayo zibe sengozini yokusikinyeka kwephasi okubhubhisako kanye nama-tsunami.

== Umlando ==

[[Isimumathi:Emperor_Jimmu.jpg|thumb|Umbusi odumileko Emperor Jimmu ]]
I-Japan[a] lilizwe eliyisiqhingi e-East Asia. Itholakala eLwandle le-Pacific eduze negwini elisenyakatho-mpumalanga ye-Asia, inomngcele ngeTjingalanga ngeLwandle le-Japan begodu isuka eLwandle le-Okhotsk ngetlhagwini ukuya eLwandle le-East China ngeSewula. I-archipelago ye-Japan ineenhlengele ezine ezikulu kanye neenhlengele ezincani ezili-14,121. I-Japan ihlukaniswe yaba ziindawo ezima-47 zokuphatha kanye neendawo ezisibhozo zesintu, begodu pheze ama-75% wendawo yayo ineentaba begodu inamahlathi amanengi, igxila ezolimo zayo kanye nabantu abahlala emadorobheni khulu emathafeni wayo asepumalanga. Njengombana inabantu abangaphezu kweengidi ezili-123 ukusukela ngomnyaka ka-2025, lilizwe le-11 elinabantu abanengi ephasini. I-Tokyo yidolobha elikhulu lenarha.


Indawo yokuhlala yokuthoma eyaziwako ye-archipelago yathoma nge-Upper Paleolithic, begodu ukuthoma kwe-Japanese Paleolithic kwathoma ngo-c. 36,000 BC. Hlangana nekhulu lesi-4 nelesi-6, imibuso yayo yahlanganiswa ngaphasi kombusi e-Nara begodu ngokukhamba kwesikhathi e-Heian-kyō. Kusukela ngekhulu le-12, amandla wamambala bekaphethwe ziinkhulu zebutho ezaziwa nge-shōgun kanye namakhosi we-feudal abizwa nge-daimyō, ebegade aphoqelelwa ziinkhulu ezibizwa nge-samurai.[11] Ngemva kokubusa yi-Kamakura ne-Ashikaga shogunates kanye nekhulu leminyaka lamazwe alwako, i-Japan yahlanganiswa ngo-1600 yi-Tokugawa shogunate, eyaqalisa umthethomgomo wangaphandle wokuzihlukanisa. Ngo-1853, imikhumbi ye-Amerikha yakatelela i-Japan bona ivule ukurhwebelana ngeTjingalanga, okwaholela ekupheleni kwe-shogunate nokubuyiselwa kwamandla we-imperial ngo-1868.


I-Japan ivela kokuthoma emlandwini otlolwe phasi ''encwadini ye-China ye-Han'', eyaqedwa ngo-111 AD, lapho ichazwa khona njengemibuso emincani eyikhulu. Ngemva kweminyaka elikhulu, ''iNcwadi ka-Wei'' itlola bona umbuso we -Yamatai (okungatjho i-Yamato ) wahlanganisa inengi lemibuso le.   UbuBhuda bethulwa e-Japan ukusuka e-Baekje (umbuso we-Korea) ngo-552, kodwana ukuthuthukiswa kobuBuddha be-Japan kwathonywa khulu yi-China.  Nanyana bekuphikiswa ekuthomeni, ubuBuddha bakhuthazwa sisigaba esibusako, kufaka hlangana abantu abafana noMkhosana u-Shōtoku, begodu bathola ukwamukelwa okukhulu ukuthoma ngesikhathi saka-Asuka (592–710). 

Ngomnyaka ka-645, urhulumende odoswa phambili ngu -Prince Naka no Ōe no -Fujiwara no Kamatari basungula begodu basebenzisa i- Taika Reforms . Itjhuguluko lathoma ngokutjhugulula umhlaba, ngokusekelwe emibonweni ka-Confucius nefilosofi evela e-China .  Yenza bona yoke inarha e-Japan ibe ngeyesizwe, bona isabalaliswe ngokulinganako hlangana nabalimi, begodu yayala bona kwenziwe irejista yemizi njengesisekelo sehlelo elitjha lomthelo.  Umnqopho wamambala weenguquko bekukuletha ukuhlanganiswa okukhulu nokuthuthukisa amandla wekhotho yombuso, ebegade isekelwe esakhiweni sombuso we-China. Iinthunywa nabafundi bathunyelwa e-China ukuyokufunda ngokutlola kwe-China, ipolotiki, ubukghwari, nekolo. &lt;ref name=&quot;Totman 2005&quot; /&gt;

Ipi ye-Jinshin yango-672, ukulwa okukhulu hlangana kweKosi u-Ōama nomzukulu wakhe uKosi u-Ōtomo, kwaba sizathu esikhulu sokwenza amatjhuguluko wokuphatha. &lt;ref name=&quot;ritsuryo&quot; /&gt; Amatjhuguluko la agcina ngokumenyezelwa kwe- Taihō Code, eyahlanganisa imithetho ekhona begodu yasungula isakhiwo sombuso wendawo ophakathi nongaphasi.  Amatjhuguluko wezomthetho la adala umbuso ritsuryō, ihlelo lombuso ohlanganisiweko wesitayela se-China elahlala likhona isigamu seminyaka eyinkulungwane. 

Isikhathi se-Nara (710–784) satshwaya ukuvela kombuso we-Japan odzimelele e-Imperial Court e- Heijō-kyō ( i-Nara yanje). Isikhathi lesi sibonakala ngokuvela kwesiko lokutlola elitjha ngokuqedwa kwe- Kojiki (712) ne Nihon Shoki (720), kanye nokuthuthukiswa kwemisebenzi yobuciko nezakhiwo eziphefumulelwe maBuddha.   Ubhubhane lwe-smallpox ngo-735-737 kukholelwa bona lwabulala ingcenye eyodwa kwezintathu yabantu be-Japan. &lt;ref name=&quot;Courtiers&quot; /&gt;  Ngo-784, uMbusi u-Kanmu wathutha idolobha elikhulu, wahlala e- Heian-kyō (i- Kyoto yanamhlanjesi) ngo-794. &lt;ref name=&quot;Courtiers&quot; /&gt; Lokhu kwathoma isikhathi se-Heian (794–1185), lapho kwavela khona isiko lama-Japan. I-Murasaki Shikibu 's ''The Tale of Genji'' kanye namagama wengoma yesitjhaba ye-Japan &quot;Kimigayo &quot; atlolwa ngesikhatheso. 

=== Isikhathi sama-feudal ===
[[Isimumathi:Mokoshuraiekotoba.jpg|thumb|Ama-samurai we-Japan agibela isikepe sama-Mongol ngesikhathi sokuhlasela kwama-Mongol e-Japan, okuvezwe ku- Mōko Shūrai Ekotoba, 1293]]
[[Isimumathi:The_Three_Unifiers_of_Japan.jpg|thumb|Izinto ezintathu ezihlanganisa i-Japan. Kwesokunxele ukuya kwesokudla: u-Oda Nobunaga, u-Toyotomi Hideyoshi no -Tokugawa Ieyasu .]]
Isikhathi se-feudal ye-Japan sabonakala ngokuvela nokubusa kwesigaba esibusako samasotja, ama -samurai .  Ngo-1185, ngemva kokuhlulwa kwesizwe se -Taira yisizwe se-Minamoto ePini ye-Genpei, i-samurai Minamoto no Yoritomo yasungula urhulumende webutho e -Kamakura .  Ngemva kokuhlongakala kwaka-Yoritomo, isizwe sama-Hōjō sathatha amandla njengababusi be shōgun .  Isikolo se-Zen se-Buddhism sathonywa ukusuka e-China ngesikhathi se-Kamakura (1185–1333) begodu sathandwa hlangana nesigaba sama-samurai. 

=== Isikhathi samanje ===
 
Ibutho le -United States Navy lathumela u-Commodore u-Matthew C. Perry bona aphoqelele ukuvulwa kwe-Japan ephasini langaphandle. Ukufika e -Uraga &quot; ngemikhumbi emnyama &quot; emine ngoJulayi 1853, i- Perry Expedition yaphumela emhlanganweni we-Kanagawa kaNtaka 1854.  Iimvumelwano ezifanako ezalandelako namanye amazwe weTjingalanga zaletha ubujamo obubudisi bezomnotho nezepolotiki. &lt;ref name=&quot;Closed&quot; /&gt; Ukutjhiya umsebenzi kwe- shōgun kwaholela ePini ye-Boshin nokusungulwa kombuso ohlanganisiweko ohlanganiswe ngaphasi kombusi ( ukubuyiselwa kwe-Meiji ).  Ngokwamukela iinkhungo zepolotiki, zokwahlulela, nezamasotja zeTjingalanga, iKhabinethi yahlela umKhandlu we-Privy, yethula umThethosisekelo we-Meiji (ngoNovemba 29, 1890), begodu yahlanganisa i- Imperial Diet . 

Ngesikhathi se-Meiji (1868-1912), uMbuso we-Japan wavela njengombuso othuthuke khulu e -Asia begodu waba ngumbuso wephasi onebubulo owaphishekela ukulwa kwezempi ukwandisa indawo yawo yomthelela.    Ngemva kokunqoba ePini yokuThoma ye-Sino-Japanese (1894–1895) kanye ne -Russo-Japanese War (1904–1905), i-Japan yathola ukulawula i-Taiwan, i-Korea kanye nengcenye esewula ye -Sakhalin,   begodu yahlanganisa i-Korea ngo-1910  35&amp;nbsp;iingidigidi ngo-1873 ukuya ku-70&amp;nbsp;iingidigidi ngo-1935, ngokutjhuguluka okukhulu ukuya emadorobheni.  

Ekuthomeni kwekhulu lama-20 kwaba nesikhathi sentando yenengi ye-Taishō (1912 ukuya ku-1926) eyasibekelwa kukhuphuka kokunwebeka nokusebenzisa amasotja .   Ipi yePhasi yoku-1 yavumela i-Japan, eyajoyina ihlangothi lama -Allies anqobileko, bona ithathe iindawo ze-Germany e- Pacific ne-China ngo- 1920 . &lt;ref name=&quot;ramesh&quot; /&gt; Ngeminyaka yabo-1920 kwaba nokutjhuguluka kwezepolotiki ukuya e-statism, isikhathi sokungabi nomthetho ngemva kokuzamazama komhlaba okukhulu kwe-Tokyo ngo-1923, ukudluliswa kwemithetho ephikisana nokuphikisana kwezepolotiki, kanye nochungechunge lokuzama ukuvukela umbuso .   

Ikambiso le yarhaba ngabo-1930, yazala amaqembu amanengi wobuzwe ahlanganyela ubutha bentando yenengi ekhululekileko nokuzinikela ekunwebeni e-Asia.  Ngo-1931, i-Japan yahlasela i-China begodu yathatha i-Manchuria, okwaholela ekusungulweni kombuso we -Manchukuo ngo-1932; ngemva kokusolwa kwamazwe ngamazwe kokuthunjwa, yatjhiya i- League of Nations ngo-1933.  Ngo-1936, i-Japan yatlikitla i -Anti-Comintern Pact ne -Nazi Germany ; isivumelwano se-1940 samaqembu amathathu senza bona kube ngelinye lamandla we-Axis . 
[[Isimumathi:Mamoru_Shigemitsu_signs_the_Instrument_of_Surrender,_officially_ending_the_Second_World_War.jpg|thumb|Ngomhlana ali-2 kuNobayeni wee-1945, i-Japan yazinikela kuma-Allies .]]
Umbuso we-Japan wahlasela ezinye iindawo ze-China ngo-1937, okwenza bona kube nepi yesibili ye-Sino-Japanese (1937–1945).  Ngo-1940, uMbuso wahlasela i-French Indochina, ngemva kwalokho i-United States yabeka umkhawulo we-oyile e-Japan.  ] ​​​​  Kizo zoke iindawo ebezithathwe yi-Japan ngesikhathi sepi, ukuhlukunyezwa okunengi kwenziwa ebantwini bendawo. Abafazi abanengi bakateleleka bona babe ziingqila zezemacansini . 

Ngemva kokunqoba kwama-Allied eminyakeni emine elandelako, okwagcina ngokuhlasela kwe-Soviet i-Manchuria kanye nokubhoma kwe-athomu e-Hiroshima ne-Nagasaki ngo-1945, i-Japan yavuma ukuzinikela ngaphandle kwemibandela .  Ipi le yabulala i-Japan iingidigidi zamaphilo kanye neendawo ezinengi ezahlulwako, okufakahlangana iindawo ''ze'' -Japan ezifana ne -Korea, i-Taiwan, i-Karafuto, kanye nama- Kurils .  Ama-Allies, aholwa yi-United States, abuyisela iingidigidi zabahlali be-Japan eendaweni zabo zangaphambilini kanye namakamu wezempi kiyo yoke i-Asia, lokho kwaqeda khulu uMbuso we-Japan kanye nomthelela wawo phezu kweendawo egade uwathumba.  &lt;ref name=&quot;phoenix&quot; /&gt; Ama-Allies abize iKhotho yamaButho ye-International ye-Far East ukutshutshisa abadosiphambili be-Japan ngaphandle koMbusi  ngebanga lobulelesi bepi be-Japan . 

Ngo-1947, i-Japan yamukela umthethosisekelo omutjha ogcizelela imikghwa yentando yenengi ekhululekileko.  Ukuthunjwa kwama-Allied kwaphela ngesivumelwano se-San Francisco ngo-1952,  begodu i-Japan yavunyelwa ubulungu be -United Nations ngo-1956. &lt;ref name=&quot;phoenix&quot; /&gt; Isikhathi sokukhula okurekhodiweko senza bona i-Japan ibe mnotho wesibili ngobukhulu ephasini ngesikhatheso ; &lt;ref name=&quot;phoenix&quot; /&gt; lokhu kwaphela phakathi kwabo-1990 ngemva kokuqhamuka kwebhamuza lentengo yepahla, ukuthoma &quot; Iminyaka elitjhumi elahlekileko &quot; ebonakala ngokujama kwezomnotho nokunyuka kwamanani okuphasi.  Ngo-2011, i-Japan yahlangabezana nokusikinyeka kwephasi okukhulu khulu emlandwini wayo— ukusikinyeka kwephasi kwe-Tōhoku —okwabanga ihlekelele yenyukliya ye-Fukushima Daiichi .  Ngomhlana ali-1 kuMrhayili 2019, ngemva kokutjhiya uMbusi u-Akihito, indodanakhe u -Naruhito waba nguMbusi, wathoma i Reiwa isikhathi (2019-).</text>
      <sha1>7tcdv1b6maz3bvshxpv0n7qnotgz4kd</sha1>
    </revision>
    <revision>
      <id>6065</id>
      <parentid>6064</parentid>
      <timestamp>2025-12-10T04:34:26Z</timestamp>
      <contributor>
        <username>WikiMzansi</username>
        <id>1200</id>
      </contributor>
      <origin>6065</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="11850" sha1="q12ox833kc25exe0s56qs8av7l2o792" xml:space="preserve">[[Isimumathi:Horyu-ji18s3200.jpg|thumb|Isithombe se-Japan|292x292px]]
'''I-Japan''' lilizwe eliyisiqhingi e-East Asia. Isendaweni ye-Pacific Ocean eduze ne-northeast coast ye-Asia mainland, begodu inemngcele ngeTjingalanga ngeLwandle le-Japan begodu isuka eLwandle le-Okhotsk ngetlhagwini ukuya eLwandle le-East China ngeSewula. I-archipelago ye-Japan ineenhlengele ezine ezikulu—i-Hokkaido, i-Honshu, i-Shikoku, ne-Kyushu—kanye neenkulungwana zeenqhingi ezincani, ezihlanganisa amakhilomitha ayi-377,975 (145,937 sq mi). I-[[Japane|Japan]] inabantu abapheze babe ziingidi ezili-124 ukusukela ngo-2024, begodu yinarha yetjhumi nanye enabantu abanengi.&lt;ref&gt;NY Post. (2025). ''Japan records nearly 1M more deaths than births in 2024 - as country's population continues to plummet''. Retrieved from &lt;nowiki&gt;https://nypost.com/2025/08/07/world-news/japan-records-nearly-1-million-more-deaths-than-births-in-2024-as-countrys-natality-continues-to-plummet/&lt;/nowiki&gt;&lt;/ref&gt; Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-Tokyo; i-Greater Tokyo Area yindawo ekulu khulu yedorobha ephasini, enabantu abangaphezu kweengidi ezingama-38 ukusukela ngo-2016.&lt;ref&gt;'''Japan Statistical Yearbook. (2017).''' ''Statistics Bureau of Japan''. Retrieved from &lt;nowiki&gt;https://www.stat.go.jp/english/data/nenkan/index.html&lt;/nowiki&gt;&lt;/ref&gt; I-Japan ihlukaniswe yaba ziindawo ezima-47 zokuphatha kanye neendawo ezibunane zesintu. Pheze amakota amathathu wendawo yenarha le ineentaba begodu inamahlathi amanengi, igxile kwezokulima kanye nabantu abahlala emadorobheni khulu emathafeni wayo asepumalanga. Inarha le ihlezi e-Pacific Ring of Fire, okwenza bona iinhlenge zayo zibe sengozini yokusikinyeka kwephasi okubhubhisako kanye nama-tsunami.

== Umlando ==

[[Isimumathi:Emperor_Jimmu.jpg|thumb|Umbusi odumileko Emperor Jimmu ]]
I-Japan[a] lilizwe eliyisiqhingi e-East Asia. Itholakala eLwandle le-Pacific eduze negwini elisenyakatho-mpumalanga ye-Asia, inomngcele ngeTjingalanga ngeLwandle le-Japan begodu isuka eLwandle le-Okhotsk ngetlhagwini ukuya eLwandle le-East China ngeSewula. I-archipelago ye-Japan ineenhlengele ezine ezikulu kanye neenhlengele ezincani ezili-14,121. I-Japan ihlukaniswe yaba ziindawo ezima-47 zokuphatha kanye neendawo ezisibhozo zesintu, begodu pheze ama-75% wendawo yayo ineentaba begodu inamahlathi amanengi, igxila ezolimo zayo kanye nabantu abahlala emadorobheni khulu emathafeni wayo asepumalanga. Njengombana inabantu abangaphezu kweengidi ezili-123 ukusukela ngomnyaka ka-2025, lilizwe le-11 elinabantu abanengi ephasini. I-Tokyo yidolobha elikhulu lenarha.


Indawo yokuhlala yokuthoma eyaziwako ye-archipelago yathoma nge-Upper Paleolithic, begodu ukuthoma kwe-Japanese Paleolithic kwathoma ngo-c. 36,000 BC. Hlangana nekhulu lesi-4 nelesi-6, imibuso yayo yahlanganiswa ngaphasi kombusi e-Nara begodu ngokukhamba kwesikhathi e-Heian-kyō. Kusukela ngekhulu le-12, amandla wamambala bekaphethwe ziinkhulu zebutho ezaziwa nge-shōgun kanye namakhosi we-feudal abizwa nge-daimyō, ebegade aphoqelelwa ziinkhulu ezibizwa nge-samurai.[11] Ngemva kokubusa yi-Kamakura ne-Ashikaga shogunates kanye nekhulu leminyaka lamazwe alwako, i-Japan yahlanganiswa ngo-1600 yi-Tokugawa shogunate, eyaqalisa umthethomgomo wangaphandle wokuzihlukanisa. Ngo-1853, imikhumbi ye-Amerikha yakatelela i-Japan bona ivule ukurhwebelana ngeTjingalanga, okwaholela ekupheleni kwe-shogunate nokubuyiselwa kwamandla we-imperial ngo-1868.


I-Japan ivela kokuthoma emlandwini otlolwe phasi ''encwadini ye-China ye-Han'', eyaqedwa ngo-111 AD, lapho ichazwa khona njengemibuso emincani eyikhulu. Ngemva kweminyaka elikhulu, ''iNcwadi ka-Wei'' itlola bona umbuso we -Yamatai (okungatjho i-Yamato ) wahlanganisa inengi lemibuso le.   UbuBhuda bethulwa e-Japan ukusuka e-Baekje (umbuso we-Korea) ngo-552, kodwana ukuthuthukiswa kobuBuddha be-Japan kwathonywa khulu yi-China.  Nanyana bekuphikiswa ekuthomeni, ubuBuddha bakhuthazwa sisigaba esibusako, kufaka hlangana abantu abafana noMkhosana u-Shōtoku, begodu bathola ukwamukelwa okukhulu ukuthoma ngesikhathi saka-Asuka (592–710). 

Ngomnyaka ka-645, urhulumende odoswa phambili ngu -Prince Naka no Ōe no -Fujiwara no Kamatari basungula begodu basebenzisa i- Taika Reforms . Itjhuguluko lathoma ngokutjhugulula umhlaba, ngokusekelwe emibonweni ka-Confucius nefilosofi evela e-China .  Yenza bona yoke inarha e-Japan ibe ngeyesizwe, bona isabalaliswe ngokulinganako hlangana nabalimi, begodu yayala bona kwenziwe irejista yemizi njengesisekelo sehlelo elitjha lomthelo.  Umnqopho wamambala weenguquko bekukuletha ukuhlanganiswa okukhulu nokuthuthukisa amandla wekhotho yombuso, ebegade isekelwe esakhiweni sombuso we-China. Iinthunywa nabafundi bathunyelwa e-China ukuyokufunda ngokutlola kwe-China, ipolotiki, ubukghwari, nekolo. &lt;ref name=&quot;Totman 2005&quot; /&gt;

Ipi ye-Jinshin yango-672, ukulwa okukhulu hlangana kweKosi u-Ōama nomzukulu wakhe uKosi u-Ōtomo, kwaba sizathu esikhulu sokwenza amatjhuguluko wokuphatha. &lt;ref name=&quot;ritsuryo&quot; /&gt; Amatjhuguluko la agcina ngokumenyezelwa kwe- Taihō Code, eyahlanganisa imithetho ekhona begodu yasungula isakhiwo sombuso wendawo ophakathi nongaphasi.  Amatjhuguluko wezomthetho la adala umbuso ritsuryō, ihlelo lombuso ohlanganisiweko wesitayela se-China elahlala likhona isigamu seminyaka eyinkulungwane. 

Isikhathi se-Nara (710–784) satshwaya ukuvela kombuso we-Japan odzimelele e-Imperial Court e- Heijō-kyō ( i-Nara yanje). Isikhathi lesi sibonakala ngokuvela kwesiko lokutlola elitjha ngokuqedwa kwe- Kojiki (712) ne Nihon Shoki (720), kanye nokuthuthukiswa kwemisebenzi yobuciko nezakhiwo eziphefumulelwe maBuddha.   Ubhubhane lwe-smallpox ngo-735-737 kukholelwa bona lwabulala ingcenye eyodwa kwezintathu yabantu be-Japan. &lt;ref name=&quot;Courtiers&quot; /&gt;  Ngo-784, uMbusi u-Kanmu wathutha idolobha elikhulu, wahlala e- Heian-kyō (i- Kyoto yanamhlanjesi) ngo-794. &lt;ref name=&quot;Courtiers&quot; /&gt; Lokhu kwathoma isikhathi se-Heian (794–1185), lapho kwavela khona isiko lama-Japan. I-Murasaki Shikibu 's ''The Tale of Genji'' kanye namagama wengoma yesitjhaba ye-Japan &quot;Kimigayo &quot; atlolwa ngesikhatheso. 

=== Isikhathi sama-feudal ===
[[Isimumathi:Mokoshuraiekotoba.jpg|thumb|Ama-samurai we-Japan agibela isikepe sama-Mongol ngesikhathi sokuhlasela kwama-Mongol e-Japan, okuvezwe ku- Mōko Shūrai Ekotoba, 1293]]
[[Isimumathi:The_Three_Unifiers_of_Japan.jpg|thumb|Izinto ezintathu ezihlanganisa i-Japan. Kwesokunxele ukuya kwesokudla: u-Oda Nobunaga, u-Toyotomi Hideyoshi no -Tokugawa Ieyasu .]]
Isikhathi se-feudal ye-Japan sabonakala ngokuvela nokubusa kwesigaba esibusako samasotja, ama -samurai .  Ngo-1185, ngemva kokuhlulwa kwesizwe se -Taira yisizwe se-Minamoto ePini ye-Genpei, i-samurai Minamoto no Yoritomo yasungula urhulumende webutho e -Kamakura .  Ngemva kokuhlongakala kwaka-Yoritomo, isizwe sama-Hōjō sathatha amandla njengababusi be shōgun .  Isikolo se-Zen se-Buddhism sathonywa ukusuka e-China ngesikhathi se-Kamakura (1185–1333) begodu sathandwa hlangana nesigaba sama-samurai. 

=== Isikhathi samanje ===
 
Ibutho le -United States Navy lathumela u-Commodore u-Matthew C. Perry bona aphoqelele ukuvulwa kwe-Japan ephasini langaphandle. Ukufika e -Uraga &quot; ngemikhumbi emnyama &quot; emine ngoJulayi 1853, i- Perry Expedition yaphumela emhlanganweni we-Kanagawa kaNtaka 1854.  Iimvumelwano ezifanako ezalandelako namanye amazwe weTjingalanga zaletha ubujamo obubudisi bezomnotho nezepolotiki. &lt;ref name=&quot;Closed&quot; /&gt; Ukutjhiya umsebenzi kwe- shōgun kwaholela ePini ye-Boshin nokusungulwa kombuso ohlanganisiweko ohlanganiswe ngaphasi kombusi ( ukubuyiselwa kwe-Meiji ).  Ngokwamukela iinkhungo zepolotiki, zokwahlulela, nezamasotja zeTjingalanga, iKhabinethi yahlela umKhandlu we-Privy, yethula umThethosisekelo we-Meiji (ngoNovemba 29, 1890), begodu yahlanganisa i- Imperial Diet . 

Ngesikhathi se-Meiji (1868-1912), uMbuso we-Japan wavela njengombuso othuthuke khulu e -Asia begodu waba ngumbuso wephasi onebubulo owaphishekela ukulwa kwezempi ukwandisa indawo yawo yomthelela.    Ngemva kokunqoba ePini yokuThoma ye-Sino-Japanese (1894–1895) kanye ne -Russo-Japanese War (1904–1905), i-Japan yathola ukulawula i-Taiwan, i-Korea kanye nengcenye esewula ye -Sakhalin,   begodu yahlanganisa i-Korea ngo-1910  35&amp;nbsp;iingidigidi ngo-1873 ukuya ku-70&amp;nbsp;iingidigidi ngo-1935, ngokutjhuguluka okukhulu ukuya emadorobheni.  

Ekuthomeni kwekhulu lama-20 kwaba nesikhathi sentando yenengi ye-Taishō (1912 ukuya ku-1926) eyasibekelwa kukhuphuka kokunwebeka nokusebenzisa amasotja .   Ipi yePhasi yoku-1 yavumela i-Japan, eyajoyina ihlangothi lama -Allies anqobileko, bona ithathe iindawo ze-Germany e- Pacific ne-China ngo- 1920 . &lt;ref name=&quot;ramesh&quot; /&gt; Ngeminyaka yabo-1920 kwaba nokutjhuguluka kwezepolotiki ukuya e-statism, isikhathi sokungabi nomthetho ngemva kokuzamazama komhlaba okukhulu kwe-Tokyo ngo-1923, ukudluliswa kwemithetho ephikisana nokuphikisana kwezepolotiki, kanye nochungechunge lokuzama ukuvukela umbuso .   

Ikambiso le yarhaba ngabo-1930, yazala amaqembu amanengi wobuzwe ahlanganyela ubutha bentando yenengi ekhululekileko nokuzinikela ekunwebeni e-Asia.  Ngo-1931, i-Japan yahlasela i-China begodu yathatha i-Manchuria, okwaholela ekusungulweni kombuso we -Manchukuo ngo-1932; ngemva kokusolwa kwamazwe ngamazwe kokuthunjwa, yatjhiya i- League of Nations ngo-1933.  Ngo-1936, i-Japan yatlikitla i -Anti-Comintern Pact ne -Nazi Germany ; isivumelwano se-1940 samaqembu amathathu senza bona kube ngelinye lamandla we-Axis . 
[[Isimumathi:Mamoru_Shigemitsu_signs_the_Instrument_of_Surrender,_officially_ending_the_Second_World_War.jpg|thumb|Ngomhlana ali-2 kuNobayeni wee-1945, i-Japan yazinikela kuma-Allies .]]
Umbuso we-Japan wahlasela ezinye iindawo ze-China ngo-1937, okwenza bona kube nepi yesibili ye-Sino-Japanese (1937–1945).  Ngo-1940, uMbuso wahlasela i-French Indochina, ngemva kwalokho i-United States yabeka umkhawulo we-oyile e-Japan.  ] ​​​​  Kizo zoke iindawo ebezithathwe yi-Japan ngesikhathi sepi, ukuhlukunyezwa okunengi kwenziwa ebantwini bendawo. Abafazi abanengi bakateleleka bona babe ziingqila zezemacansini . 

Ngemva kokunqoba kwama-Allied eminyakeni emine elandelako, okwagcina ngokuhlasela kwe-Soviet i-Manchuria kanye nokubhoma kwe-athomu e-Hiroshima ne-Nagasaki ngo-1945, i-Japan yavuma ukuzinikela ngaphandle kwemibandela .  Ipi le yabulala i-Japan iingidigidi zamaphilo kanye neendawo ezinengi ezahlulwako, okufakahlangana iindawo ''ze'' -Japan ezifana ne -Korea, i-Taiwan, i-Karafuto, kanye nama- Kurils .  Ama-Allies, aholwa yi-United States, abuyisela iingidigidi zabahlali be-Japan eendaweni zabo zangaphambilini kanye namakamu wezempi kiyo yoke i-Asia, lokho kwaqeda khulu uMbuso we-Japan kanye nomthelela wawo phezu kweendawo egade uwathumba.  &lt;ref name=&quot;phoenix&quot; /&gt; Ama-Allies abize iKhotho yamaButho ye-International ye-Far East ukutshutshisa abadosiphambili be-Japan ngaphandle koMbusi  ngebanga lobulelesi bepi be-Japan . 

Ngo-1947, i-Japan yamukela umthethosisekelo omutjha ogcizelela imikghwa yentando yenengi ekhululekileko.  Ukuthunjwa kwama-Allied kwaphela ngesivumelwano se-San Francisco ngo-1952,  begodu i-Japan yavunyelwa ubulungu be -United Nations ngo-1956. &lt;ref name=&quot;phoenix&quot; /&gt; Isikhathi sokukhula okurekhodiweko senza bona i-Japan ibe mnotho wesibili ngobukhulu ephasini ngesikhatheso ; &lt;ref name=&quot;phoenix&quot; /&gt; lokhu kwaphela phakathi kwabo-1990 ngemva kokuqhamuka kwebhamuza lentengo yepahla, ukuthoma &quot; Iminyaka elitjhumi elahlekileko &quot; ebonakala ngokujama kwezomnotho nokunyuka kwamanani okuphasi.  Ngo-2011, i-Japan yahlangabezana nokusikinyeka kwephasi okukhulu khulu emlandwini wayo— ukusikinyeka kwephasi kwe-Tōhoku —okwabanga ihlekelele yenyukliya ye-Fukushima Daiichi .  Ngomhlana ali-1 kuMrhayili 2019, ngemva kokutjhiya uMbusi u-Akihito, indodanakhe u -Naruhito waba nguMbusi, wathoma i Reiwa isikhathi (2019-).

== Imithombo Lwazi ==</text>
      <sha1>q12ox833kc25exe0s56qs8av7l2o792</sha1>
    </revision>
  </page>
  <page>
    <title>Morocco</title>
    <ns>0</ns>
    <id>354</id>
    <revision>
      <id>1848</id>
      <timestamp>2024-11-01T18:58:16Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created page with &quot;'''I-Morocco''',  ngokusemthethweni uMbuso we-Morocco,[e] lilizwe elisesifundeni se-Maghreb e-North Africa. Iqala i-Mediterranean Sea ngetlhagwini kanye ne-Atlantic Ocean ngeTjingalanga, begodu inemingcele yephasi ne-Algeria ngepumalanga, kanye nendawo ephikisanako ye-Western Sahara ngeSewula. I-Morocco nayo ifuna ama-exclaves we-Spain we-Ceuta, Melilla kanye ne-Peñón de Vélez de la Gomera, kanye neenhlengele ezimbalwa ezilawulwa yi-Spain eziseduze nelwandle layo.] In...&quot;</comment>
      <origin>1848</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="849" sha1="0wkm6agc88yrbh9jnky67b8vnnctv5q" xml:space="preserve">'''I-Morocco''',  ngokusemthethweni uMbuso we-Morocco,[e] lilizwe elisesifundeni se-Maghreb e-North Africa. Iqala i-Mediterranean Sea ngetlhagwini kanye ne-Atlantic Ocean ngeTjingalanga, begodu inemingcele yephasi ne-Algeria ngepumalanga, kanye nendawo ephikisanako ye-Western Sahara ngeSewula. I-Morocco nayo ifuna ama-exclaves we-Spain we-Ceuta, Melilla kanye ne-Peñón de Vélez de la Gomera, kanye neenhlengele ezimbalwa ezilawulwa yi-Spain eziseduze nelwandle layo.] Inabantu abangaba ziingidi ezima-37. I-Islam yikolo esemthethweni nejayelekileko, kuthi isi-Arabhu nesi-Berber zilimi ezisemthethweni. Phezu kwalokho, isiFulentshi nesilimi se-Morocco se-Arabhu sikhulunywa khulu. Isiko le-Morocco lihlanganiswe namasiko wama-Arabhu, ama-Berber, ama-Afrika nama-Europe. Inhlokodolobha yayo yi-Rabat, lokha idorobha layo elikhulu yi-Casablanca.[</text>
      <sha1>0wkm6agc88yrbh9jnky67b8vnnctv5q</sha1>
    </revision>
    <revision>
      <id>1849</id>
      <parentid>1848</parentid>
      <timestamp>2024-11-01T18:58:44Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1849</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="864" sha1="9wvvqdkqf3u0mzd9lcq4mfmomn4kgcz" xml:space="preserve">'''I-Morocco''',  ngokusemthethweni uMbuso we-Morocco,[e] lilizwe elisesifundeni se-Maghreb e-North Africa. Iqala i-Mediterranean Sea ngetlhagwini kanye ne-Atlantic Ocean ngeTjingalanga, begodu inemingcele yephasi ne-Algeria ngepumalanga, kanye nendawo ephikisanako ye-Western Sahara ngeSewula. I-Morocco nayo ifuna ama-exclaves we-Spain we-Ceuta, Melilla kanye ne-Peñón de Vélez de la Gomera, kanye neenhlengele ezimbalwa ezilawulwa yi-Spain eziseduze nelwandle layo.] Inabantu abangaba ziingidi ezima-37. I-Islam yikolo esemthethweni nejayelekileko, kuthi isi-Arabhu nesi-Berber zilimi ezisemthethweni. Phezu kwalokho, isiFulentshi nesilimi se-Morocco se-Arabhu sikhulunywa khulu. Isiko le-Morocco lihlanganiswe namasiko wama-Arabhu, ama-Berber, ama-Afrika nama-Europe. Inhlokodolobha yayo yi-Rabat, lokha idorobha layo elikhulu yi-Casablanca.

== Iinkomba ==</text>
      <sha1>9wvvqdkqf3u0mzd9lcq4mfmomn4kgcz</sha1>
    </revision>
    <revision>
      <id>1850</id>
      <parentid>1849</parentid>
      <timestamp>2024-11-01T18:59:56Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1850</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="905" sha1="o4sssvw94k8z8cul6exdlox47pe0ugv" xml:space="preserve">'''I-Morocco''',  ngokusemthethweni uMbuso we-Morocco,[e] lilizwe elisesifundeni se-Maghreb e-North Africa. Iqala i-Mediterranean Sea ngetlhagwini kanye ne-Atlantic Ocean ngeTjingalanga, begodu inemingcele yephasi ne-Algeria ngepumalanga, kanye nendawo ephikisanako ye-Western Sahara ngeSewula. I-Morocco nayo ifuna ama-exclaves we-Spain we-Ceuta, Melilla kanye ne-Peñón de Vélez de la Gomera, kanye neenhlengele ezimbalwa ezilawulwa yi-Spain eziseduze nelwandle layo.] Inabantu abangaba ziingidi ezima-37. I-Islam yikolo esemthethweni nejayelekileko, kuthi isi-Arabhu nesi-Berber zilimi ezisemthethweni. Phezu kwalokho, isiFulentshi nesilimi se-Morocco se-Arabhu sikhulunywa khulu. Isiko le-Morocco lihlanganiswe namasiko wama-Arabhu, ama-Berber, ama-Afrika nama-Europe. Inhlokodolobha yayo yi-Rabat, lokha idorobha layo elikhulu yi-Casablanca.

== Iinkomba ==
{{Reflist}}
[[Category:Iinarha zephasi]]</text>
      <sha1>o4sssvw94k8z8cul6exdlox47pe0ugv</sha1>
    </revision>
    <revision>
      <id>1851</id>
      <parentid>1850</parentid>
      <timestamp>2024-11-01T19:01:12Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1851</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1035" sha1="lqoafiiysz47mzdn7nct42ar5kgxp7j" xml:space="preserve">'''I-Morocco''',  ngokusemthethweni uMbuso we-Morocco,[e] lilizwe elisesifundeni se-Maghreb e-North Africa. Iqala i-Mediterranean Sea ngetlhagwini kanye ne-Atlantic Ocean ngeTjingalanga, begodu inemingcele yephasi ne-Algeria ngepumalanga, kanye nendawo ephikisanako ye-Western Sahara ngeSewula. I-Morocco nayo ifuna ama-exclaves we-Spain we-Ceuta, Melilla kanye ne-Peñón de Vélez de la Gomera, kanye neenhlengele ezimbalwa ezilawulwa yi-Spain eziseduze nelwandle layo.] Inabantu abangaba ziingidi ezima-37. I-Islam yikolo esemthethweni nejayelekileko, kuthi isi-Arabhu nesi-Berber zilimi ezisemthethweni. Phezu kwalokho, isiFulentshi nesilimi se-Morocco se-Arabhu sikhulunywa khulu. Isiko le-Morocco lihlanganiswe namasiko wama-Arabhu, ama-Berber, ama-Afrika nama-Europe. Inhlokodolobha yayo yi-Rabat, lokha idorobha layo elikhulu yi-Casablanca.&lt;ref&gt;https://www.moroccoembassy.co.za/morocco/overview/history-of-morocco&lt;/ref&gt;&lt;ref&gt;https://www.britannica.com/place/Morocco&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}
[[Category:Iinarha zephasi]]</text>
      <sha1>lqoafiiysz47mzdn7nct42ar5kgxp7j</sha1>
    </revision>
    <revision>
      <id>1852</id>
      <parentid>1851</parentid>
      <timestamp>2024-11-01T19:01:32Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1852</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1032" sha1="40hxbzbfpujt5eyrv4f35epuksuhlng" xml:space="preserve">'''I-Morocco''',  ngokusemthethweni uMbuso we-Morocco, lilizwe elisesifundeni se-Maghreb e-North Africa. Iqala i-Mediterranean Sea ngetlhagwini kanye ne-Atlantic Ocean ngeTjingalanga, begodu inemingcele yephasi ne-Algeria ngepumalanga, kanye nendawo ephikisanako ye-Western Sahara ngeSewula. I-Morocco nayo ifuna ama-exclaves we-Spain we-Ceuta, Melilla kanye ne-Peñón de Vélez de la Gomera, kanye neenhlengele ezimbalwa ezilawulwa yi-Spain eziseduze nelwandle layo.] Inabantu abangaba ziingidi ezima-37. I-Islam yikolo esemthethweni nejayelekileko, kuthi isi-Arabhu nesi-Berber zilimi ezisemthethweni. Phezu kwalokho, isiFulentshi nesilimi se-Morocco se-Arabhu sikhulunywa khulu. Isiko le-Morocco lihlanganiswe namasiko wama-Arabhu, ama-Berber, ama-Afrika nama-Europe. Inhlokodolobha yayo yi-Rabat, lokha idorobha layo elikhulu yi-Casablanca.&lt;ref&gt;https://www.moroccoembassy.co.za/morocco/overview/history-of-morocco&lt;/ref&gt;&lt;ref&gt;https://www.britannica.com/place/Morocco&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}
[[Category:Iinarha zephasi]]</text>
      <sha1>40hxbzbfpujt5eyrv4f35epuksuhlng</sha1>
    </revision>
    <revision>
      <id>2143</id>
      <parentid>1852</parentid>
      <timestamp>2024-11-25T18:29:59Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>Mkhakha</comment>
      <origin>2143</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1032" sha1="ptbyuiytzigya6zff71mwv3ck2mnr84" xml:space="preserve">'''I-Morocco''',  ngokusemthethweni uMbuso we-Morocco, lilizwe elisesifundeni se-Maghreb e-North Africa. Iqala i-Mediterranean Sea ngetlhagwini kanye ne-Atlantic Ocean ngeTjingalanga, begodu inemingcele yephasi ne-Algeria ngepumalanga, kanye nendawo ephikisanako ye-Western Sahara ngeSewula. I-Morocco nayo ifuna ama-exclaves we-Spain we-Ceuta, Melilla kanye ne-Peñón de Vélez de la Gomera, kanye neenhlengele ezimbalwa ezilawulwa yi-Spain eziseduze nelwandle layo.] Inabantu abangaba ziingidi ezima-37. I-Islam yikolo esemthethweni nejayelekileko, kuthi isi-Arabhu nesi-Berber zilimi ezisemthethweni. Phezu kwalokho, isiFulentshi nesilimi se-Morocco se-Arabhu sikhulunywa khulu. Isiko le-Morocco lihlanganiswe namasiko wama-Arabhu, ama-Berber, ama-Afrika nama-Europe. Inhlokodolobha yayo yi-Rabat, lokha idorobha layo elikhulu yi-Casablanca.&lt;ref&gt;https://www.moroccoembassy.co.za/morocco/overview/history-of-morocco&lt;/ref&gt;&lt;ref&gt;https://www.britannica.com/place/Morocco&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}

[[Mkhakha:Iinarha zephasi]]</text>
      <sha1>ptbyuiytzigya6zff71mwv3ck2mnr84</sha1>
    </revision>
  </page>
  <page>
    <title>Namibia</title>
    <ns>0</ns>
    <id>355</id>
    <revision>
      <id>1853</id>
      <timestamp>2024-11-01T19:03:45Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created page with &quot;'''I-Namibia''' ngokusemthethweni iRiphabhliki ye-Namibia, yinarha eseSewula ye-[[I-Afrika|Afrika.]] Umngcele wayo osentshonalanga yi-Atlantic Ocean. Yabelana ngemingcele yephasi ne-Angola ne-Zambia ngetlhagwini, i-Botswana ngepumalanga kanye neSewula Afrika ngepumalanga nesewula. Nanyana ingasi emngceleni we-Zimbabwe, ngaphasi kwamamitha ama-200 (amafidi ama-660) we-Botswana kwesokudla somlambo i-Zambezi ahlukanisa amazwe womabili. Inhlokodolobha yayo nedorobha elikhulu...&quot;</comment>
      <origin>1853</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="807" sha1="hcp9t5332fgabjmnzk1qop31lnobroa" xml:space="preserve">'''I-Namibia''' ngokusemthethweni iRiphabhliki ye-Namibia, yinarha eseSewula ye-[[I-Afrika|Afrika.]] Umngcele wayo osentshonalanga yi-Atlantic Ocean. Yabelana ngemingcele yephasi ne-Angola ne-Zambia ngetlhagwini, i-Botswana ngepumalanga kanye neSewula Afrika ngepumalanga nesewula. Nanyana ingasi emngceleni we-Zimbabwe, ngaphasi kwamamitha ama-200 (amafidi ama-660) we-Botswana kwesokudla somlambo i-Zambezi ahlukanisa amazwe womabili. Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-Windhoek.

Inarha eyomileko khulu e-Afrika esewula ye-Sahara,[18] i-Namibia beyisolo ihlala abantu bama-Khoi, ama-San, ama-Damara kanye nama-Nama. Ngekhulu leminyaka ye-14, abantu abafudukako bamaBantu bafika njengengcenye yokwanda kwamaBantu. Kusukela ngo-1600 ama-Ovambo akha imibuso, njenge-Ondonga ne-Oukwanyama.</text>
      <sha1>hcp9t5332fgabjmnzk1qop31lnobroa</sha1>
    </revision>
    <revision>
      <id>1854</id>
      <parentid>1853</parentid>
      <timestamp>2024-11-01T19:04:08Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1854</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="826" sha1="q40zqz7ohylrc1b6gyqjcr9ra5w5d3d" xml:space="preserve">'''I-Namibia''' ngokusemthethweni iRiphabhliki ye-Namibia, yinarha eseSewula ye-[[I-Afrika|Afrika.]] Umngcele wayo osentshonalanga yi-Atlantic Ocean. Yabelana ngemingcele yephasi ne-Angola ne-Zambia ngetlhagwini, i-Botswana ngepumalanga kanye ne[[Isewula Afrika|Sewula Afrika]] ngepumalanga nesewula. Nanyana ingasi emngceleni we-Zimbabwe, ngaphasi kwamamitha ama-200 (amafidi ama-660) we-Botswana kwesokudla somlambo i-Zambezi ahlukanisa amazwe womabili. Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-Windhoek.

Inarha eyomileko khulu e-Afrika esewula ye-Sahara,[18] i-Namibia beyisolo ihlala abantu bama-Khoi, ama-San, ama-Damara kanye nama-Nama. Ngekhulu leminyaka ye-14, abantu abafudukako bamaBantu bafika njengengcenye yokwanda kwamaBantu. Kusukela ngo-1600 ama-Ovambo akha imibuso, njenge-Ondonga ne-Oukwanyama.</text>
      <sha1>q40zqz7ohylrc1b6gyqjcr9ra5w5d3d</sha1>
    </revision>
    <revision>
      <id>1855</id>
      <parentid>1854</parentid>
      <timestamp>2024-11-01T19:04:53Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1855</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="920" sha1="slp3q6tt231g9o2sxpase4lv8a9y4a4" xml:space="preserve">'''I-Namibia''' ngokusemthethweni iRiphabhliki ye-Namibia, yinarha eseSewula ye-[[I-Afrika|Afrika.]] Umngcele wayo osentshonalanga yi-Atlantic Ocean. Yabelana ngemingcele yephasi ne-Angola ne-Zambia ngetlhagwini, i-Botswana ngepumalanga kanye ne[[Isewula Afrika|Sewula Afrika]] ngepumalanga nesewula. Nanyana ingasi emngceleni we-Zimbabwe, ngaphasi kwamamitha ama-200 (amafidi ama-660) we-Botswana kwesokudla somlambo i-Zambezi ahlukanisa amazwe womabili. Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-Windhoek.

Inarha eyomileko khulu e-Afrika esewula ye-Sahara, i-Namibia beyisolo ihlala abantu bama-Khoi, ama-San, ama-Damara kanye nama-Nama. Ngekhulu leminyaka ye-14, abantu abafudukako bamaBantu bafika njengengcenye yokwanda kwamaBantu. Kusukela ngo-1600 ama-Ovambo akha imibuso, njenge-Ondonga ne-Oukwanyama.&lt;ref&gt;https://www.rhinoafrica.com/en/destinations/namibia/facts-and-information/history/77538&lt;/ref&gt;</text>
      <sha1>slp3q6tt231g9o2sxpase4lv8a9y4a4</sha1>
    </revision>
    <revision>
      <id>1856</id>
      <parentid>1855</parentid>
      <timestamp>2024-11-01T19:05:20Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1856</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="982" sha1="mmp4zj25vh6qhs7pd6hbk5pp140w8xa" xml:space="preserve">'''I-Namibia''' ngokusemthethweni iRiphabhliki ye-Namibia, yinarha eseSewula ye-[[I-Afrika|Afrika.]] Umngcele wayo osentshonalanga yi-Atlantic Ocean. Yabelana ngemingcele yephasi ne-Angola ne-Zambia ngetlhagwini, i-Botswana ngepumalanga kanye ne[[Isewula Afrika|Sewula Afrika]] ngepumalanga nesewula. Nanyana ingasi emngceleni we-Zimbabwe, ngaphasi kwamamitha ama-200 (amafidi ama-660) we-Botswana kwesokudla somlambo i-Zambezi ahlukanisa amazwe womabili. Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-Windhoek.

Inarha eyomileko khulu e-Afrika esewula ye-Sahara, i-Namibia beyisolo ihlala abantu bama-Khoi, ama-San, ama-Damara kanye nama-Nama. Ngekhulu leminyaka ye-14, abantu abafudukako bamaBantu bafika njengengcenye yokwanda kwamaBantu. Kusukela ngo-1600 ama-Ovambo akha imibuso, njenge-Ondonga ne-Oukwanyama.&lt;ref&gt;https://www.britannica.com/topic/history-of-Namibia&lt;/ref&gt;&lt;ref&gt;https://www.rhinoafrica.com/en/destinations/namibia/facts-and-information/history/77538&lt;/ref&gt;</text>
      <sha1>mmp4zj25vh6qhs7pd6hbk5pp140w8xa</sha1>
    </revision>
    <revision>
      <id>1857</id>
      <parentid>1856</parentid>
      <timestamp>2024-11-01T19:05:51Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1857</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="998" sha1="sx6dasa1vdcumlxf9jcx2nhhhjz9hp9" xml:space="preserve">'''I-Namibia''' ngokusemthethweni iRiphabhliki ye-Namibia, yinarha eseSewula ye-[[I-Afrika|Afrika.]] Umngcele wayo osentshonalanga yi-Atlantic Ocean. Yabelana ngemingcele yephasi ne-Angola ne-Zambia ngetlhagwini, i-Botswana ngepumalanga kanye ne[[Isewula Afrika|Sewula Afrika]] ngepumalanga nesewula. Nanyana ingasi emngceleni we-Zimbabwe, ngaphasi kwamamitha ama-200 (amafidi ama-660) we-Botswana kwesokudla somlambo i-Zambezi ahlukanisa amazwe womabili. Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-Windhoek.

Inarha eyomileko khulu e-Afrika esewula ye-Sahara, i-Namibia beyisolo ihlala abantu bama-Khoi, ama-San, ama-Damara kanye nama-Nama. Ngekhulu leminyaka ye-14, abantu abafudukako bamaBantu bafika njengengcenye yokwanda kwamaBantu. Kusukela ngo-1600 ama-Ovambo akha imibuso, njenge-Ondonga ne-Oukwanyama.&lt;ref&gt;https://www.britannica.com/topic/history-of-Namibia&lt;/ref&gt;&lt;ref&gt;https://www.rhinoafrica.com/en/destinations/namibia/facts-and-information/history/77538&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>sx6dasa1vdcumlxf9jcx2nhhhjz9hp9</sha1>
    </revision>
    <revision>
      <id>1858</id>
      <parentid>1857</parentid>
      <timestamp>2024-11-01T19:06:22Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1858</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1039" sha1="g5dez3je0ejiiuex128d6gwxg49biux" xml:space="preserve">'''I-Namibia''' ngokusemthethweni iRiphabhliki ye-Namibia, yinarha eseSewula ye-[[I-Afrika|Afrika.]] Umngcele wayo osentshonalanga yi-Atlantic Ocean. Yabelana ngemingcele yephasi ne-Angola ne-Zambia ngetlhagwini, i-Botswana ngepumalanga kanye ne[[Isewula Afrika|Sewula Afrika]] ngepumalanga nesewula. Nanyana ingasi emngceleni we-Zimbabwe, ngaphasi kwamamitha ama-200 (amafidi ama-660) we-Botswana kwesokudla somlambo i-Zambezi ahlukanisa amazwe womabili. Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-Windhoek.

Inarha eyomileko khulu e-Afrika esewula ye-Sahara, i-Namibia beyisolo ihlala abantu bama-Khoi, ama-San, ama-Damara kanye nama-Nama. Ngekhulu leminyaka ye-14, abantu abafudukako bamaBantu bafika njengengcenye yokwanda kwamaBantu. Kusukela ngo-1600 ama-Ovambo akha imibuso, njenge-Ondonga ne-Oukwanyama.&lt;ref&gt;https://www.britannica.com/topic/history-of-Namibia&lt;/ref&gt;&lt;ref&gt;https://www.rhinoafrica.com/en/destinations/namibia/facts-and-information/history/77538&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}
[[Category:Iinarha zephasi]]</text>
      <sha1>g5dez3je0ejiiuex128d6gwxg49biux</sha1>
    </revision>
    <revision>
      <id>1859</id>
      <parentid>1858</parentid>
      <timestamp>2024-11-01T19:06:42Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>1859</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1043" sha1="m3don6lf30l2uzv1yj4z9sp1nopch8k" xml:space="preserve">'''I-Namibia''' ngokusemthethweni iRiphabhliki ye-Namibia, yinarha eseSewula ye-[[I-Afrika|Afrika.]] Umngcele wayo osentshonalanga yi-Atlantic Ocean. Yabelana ngemingcele yephasi ne-Angola ne-Zambia ngetlhagwini, i-Botswana ngepumalanga kanye ne[[Isewula Afrika|Sewula Afrika]] ngepumalanga nesewula. Nanyana ingasi emngceleni we-Zimbabwe, ngaphasi kwamamitha ama-200 (amafidi ama-660) we-Botswana kwesokudla somlambo i-Zambezi ahlukanisa amazwe womabili. Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-[[Windhoek]].

Inarha eyomileko khulu e-Afrika esewula ye-Sahara, i-Namibia beyisolo ihlala abantu bama-Khoi, ama-San, ama-Damara kanye nama-Nama. Ngekhulu leminyaka ye-14, abantu abafudukako bamaBantu bafika njengengcenye yokwanda kwamaBantu. Kusukela ngo-1600 ama-Ovambo akha imibuso, njenge-Ondonga ne-Oukwanyama.&lt;ref&gt;https://www.britannica.com/topic/history-of-Namibia&lt;/ref&gt;&lt;ref&gt;https://www.rhinoafrica.com/en/destinations/namibia/facts-and-information/history/77538&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}
[[Category:Iinarha zephasi]]</text>
      <sha1>m3don6lf30l2uzv1yj4z9sp1nopch8k</sha1>
    </revision>
    <revision>
      <id>2141</id>
      <parentid>1859</parentid>
      <timestamp>2024-11-25T18:29:34Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>Mkhakha</comment>
      <origin>2141</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1043" sha1="093ykj04qfgd6ef382whc9ocszw2mtb" xml:space="preserve">'''I-Namibia''' ngokusemthethweni iRiphabhliki ye-Namibia, yinarha eseSewula ye-[[I-Afrika|Afrika.]] Umngcele wayo osentshonalanga yi-Atlantic Ocean. Yabelana ngemingcele yephasi ne-Angola ne-Zambia ngetlhagwini, i-Botswana ngepumalanga kanye ne[[Isewula Afrika|Sewula Afrika]] ngepumalanga nesewula. Nanyana ingasi emngceleni we-Zimbabwe, ngaphasi kwamamitha ama-200 (amafidi ama-660) we-Botswana kwesokudla somlambo i-Zambezi ahlukanisa amazwe womabili. Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-[[Windhoek]].

Inarha eyomileko khulu e-Afrika esewula ye-Sahara, i-Namibia beyisolo ihlala abantu bama-Khoi, ama-San, ama-Damara kanye nama-Nama. Ngekhulu leminyaka ye-14, abantu abafudukako bamaBantu bafika njengengcenye yokwanda kwamaBantu. Kusukela ngo-1600 ama-Ovambo akha imibuso, njenge-Ondonga ne-Oukwanyama.&lt;ref&gt;https://www.britannica.com/topic/history-of-Namibia&lt;/ref&gt;&lt;ref&gt;https://www.rhinoafrica.com/en/destinations/namibia/facts-and-information/history/77538&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}

[[Mkhakha:Iinarha zephasi]]</text>
      <sha1>093ykj04qfgd6ef382whc9ocszw2mtb</sha1>
    </revision>
    <revision>
      <id>2947</id>
      <parentid>2141</parentid>
      <timestamp>2025-06-06T17:21:49Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>HOT DIGGITY DOG!!!</comment>
      <origin>2947</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="65" sha1="d2rezjhqr612xr4e669nz4dbjs55ugp" xml:space="preserve">== HOT DIGGITY DOG!!! ==
{{Reflist}}

[[Mkhakha:Iinarha zephasi]]</text>
      <sha1>d2rezjhqr612xr4e669nz4dbjs55ugp</sha1>
    </revision>
    <revision>
      <id>3134</id>
      <parentid>2947</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Simakahle Moselekatse|Simakahle Moselekatse]]</comment>
      <origin>2141</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1043" sha1="093ykj04qfgd6ef382whc9ocszw2mtb" xml:space="preserve">'''I-Namibia''' ngokusemthethweni iRiphabhliki ye-Namibia, yinarha eseSewula ye-[[I-Afrika|Afrika.]] Umngcele wayo osentshonalanga yi-Atlantic Ocean. Yabelana ngemingcele yephasi ne-Angola ne-Zambia ngetlhagwini, i-Botswana ngepumalanga kanye ne[[Isewula Afrika|Sewula Afrika]] ngepumalanga nesewula. Nanyana ingasi emngceleni we-Zimbabwe, ngaphasi kwamamitha ama-200 (amafidi ama-660) we-Botswana kwesokudla somlambo i-Zambezi ahlukanisa amazwe womabili. Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-[[Windhoek]].

Inarha eyomileko khulu e-Afrika esewula ye-Sahara, i-Namibia beyisolo ihlala abantu bama-Khoi, ama-San, ama-Damara kanye nama-Nama. Ngekhulu leminyaka ye-14, abantu abafudukako bamaBantu bafika njengengcenye yokwanda kwamaBantu. Kusukela ngo-1600 ama-Ovambo akha imibuso, njenge-Ondonga ne-Oukwanyama.&lt;ref&gt;https://www.britannica.com/topic/history-of-Namibia&lt;/ref&gt;&lt;ref&gt;https://www.rhinoafrica.com/en/destinations/namibia/facts-and-information/history/77538&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}

[[Mkhakha:Iinarha zephasi]]</text>
      <sha1>093ykj04qfgd6ef382whc9ocszw2mtb</sha1>
    </revision>
  </page>
  <page>
    <title>Türkiye</title>
    <ns>0</ns>
    <id>356</id>
    <revision>
      <id>1873</id>
      <timestamp>2024-11-11T22:26:42Z</timestamp>
      <contributor>
        <username>Lionel Cristiano</username>
        <id>157</id>
      </contributor>
      <comment>+</comment>
      <origin>1873</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="169" sha1="iq98biesb15fn5obi5sty60chku2yjr" xml:space="preserve">[[File:Flag of Turkey.svg|300px|right]]
[[File:Turkey (orthographic projection).svg|300px|right]]
'''I-Türkiye''' iyizwe elitholakala emazwenikazi ase-Asia naseYurophu.</text>
      <sha1>iq98biesb15fn5obi5sty60chku2yjr</sha1>
    </revision>
    <revision>
      <id>2574</id>
      <parentid>1873</parentid>
      <timestamp>2025-03-22T05:42:16Z</timestamp>
      <contributor>
        <username>Kvazimodo</username>
        <id>341</id>
      </contributor>
      <origin>2574</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="198" sha1="7jwgrrd9mm1ejfwglbxvaqqzjq51m3p" xml:space="preserve">[[File:Flag of Turkey.svg|300px|right]]
[[File:Turkey (orthographic projection).svg|300px|right]]
'''I-Türkiye''' iyizwe elitholakala emazwenikazi ase-Asia naseYurophu.

[[Mkhakha:Iinarha zephasi]]</text>
      <sha1>7jwgrrd9mm1ejfwglbxvaqqzjq51m3p</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Simakahle Moselekatse</title>
    <ns>2</ns>
    <id>357</id>
    <revision>
      <id>1874</id>
      <timestamp>2024-11-12T17:52:14Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>Isimumathi</comment>
      <origin>1874</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="62" sha1="g4ert4nu0wiu60ige50s5rrvu5kgx7l" xml:space="preserve">[[Isimumathi:Sukanya, Royal Opera House.jpg|frameless|center]]</text>
      <sha1>g4ert4nu0wiu60ige50s5rrvu5kgx7l</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi asiqongelane:Simakahle Moselekatse</title>
    <ns>3</ns>
    <id>358</id>
    <revision>
      <id>1875</id>
      <timestamp>2024-11-12T17:52:36Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>Isimumathi</comment>
      <origin>1875</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="62" sha1="g4ert4nu0wiu60ige50s5rrvu5kgx7l" xml:space="preserve">[[Isimumathi:Sukanya, Royal Opera House.jpg|frameless|center]]</text>
      <sha1>g4ert4nu0wiu60ige50s5rrvu5kgx7l</sha1>
    </revision>
    <revision>
      <id>2605</id>
      <parentid>1875</parentid>
      <timestamp>2025-03-27T18:52:12Z</timestamp>
      <contributor>
        <username>MediaWiki message delivery</username>
        <id>195</id>
      </contributor>
      <comment>/* Invitation to connect with fellow contributors from language onboarding experiment */ new section</comment>
      <origin>2605</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1947" sha1="dfvrx66mpz5xupl756yz80o4fb43v2m" xml:space="preserve">[[Isimumathi:Sukanya, Royal Opera House.jpg|frameless|center]]

== Invitation to connect with fellow contributors from language onboarding experiment ==

Hello,

Hope this message finds you well! I would like to invite you to a community conversation to connect with fellow contributors from pilot wikis (Southern Ndebele, Tai Nüa, Iban, Obolo, Pannonian Rusyn) that graduated through a [https://diff.wikimedia.org/2024/10/31/wikipedia-goes-live-for-five-languages-through-the-future-of-language-incubation-initiative/ Language Onboarding Experiment] last year. In this conversation, we plan to facilitate sharing learnings, discussing technical needs post-graduation, and collaborating on solving challenges faced by the pilot wikis.

We spoke with a few contributors from these wikis back in December, and their valuable input on contributions has given us some perspectives on what to investigate next. A report will soon be published on those learnings. We hope that this meeting will not only be a great opportunity for us to come together and learn from each other but also allow us to use your valuable input to shape our plans for the coming year!
If you can attend the call, please sign up here, and I will share more details later:

* [https://www.mediawiki.org/wiki/Language_Onboarding_and_Development/Community_conversations_2024-25#5_April_2025_01:00_UTC 5 April 2025, 01:00 UTC]
* [https://www.mediawiki.org/wiki/Language_Onboarding_and_Development/Community_conversations_2024-25#4_April_2025_15:00_UTC 4 April 2025, 15:00 UTC]

Looking forward to your participation!

Cheers, [[User:SSethi (WMF)]] via [[Umsebenzisi:MediaWiki message delivery|MediaWiki message delivery]] ([[Umsebenzisi asiqongelane:MediaWiki message delivery|talk]]) 20:52, 27 Mbimbitho 2025 (SAST)
&lt;!-- Message sent by User:SSethi (WMF)@metawiki using the list at https://meta.wikimedia.org/w/index.php?title=User:SSethi_(WMF)/MassMessageList&amp;oldid=28454981 --&gt;</text>
      <sha1>dfvrx66mpz5xupl756yz80o4fb43v2m</sha1>
    </revision>
    <revision>
      <id>2618</id>
      <parentid>2605</parentid>
      <timestamp>2025-04-02T17:23:44Z</timestamp>
      <contributor>
        <username>SSethi (WMF)</username>
        <id>105</id>
      </contributor>
      <comment>/* Invitation to connect with fellow contributors from language onboarding experiment */ Reply</comment>
      <origin>2618</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2317" sha1="jtxcntcc51c0gn21rxef6u6g8w3f7o0" xml:space="preserve">[[Isimumathi:Sukanya, Royal Opera House.jpg|frameless|center]]

== Invitation to connect with fellow contributors from language onboarding experiment ==

Hello,

Hope this message finds you well! I would like to invite you to a community conversation to connect with fellow contributors from pilot wikis (Southern Ndebele, Tai Nüa, Iban, Obolo, Pannonian Rusyn) that graduated through a [https://diff.wikimedia.org/2024/10/31/wikipedia-goes-live-for-five-languages-through-the-future-of-language-incubation-initiative/ Language Onboarding Experiment] last year. In this conversation, we plan to facilitate sharing learnings, discussing technical needs post-graduation, and collaborating on solving challenges faced by the pilot wikis.

We spoke with a few contributors from these wikis back in December, and their valuable input on contributions has given us some perspectives on what to investigate next. A report will soon be published on those learnings. We hope that this meeting will not only be a great opportunity for us to come together and learn from each other but also allow us to use your valuable input to shape our plans for the coming year!
If you can attend the call, please sign up here, and I will share more details later:

* [https://www.mediawiki.org/wiki/Language_Onboarding_and_Development/Community_conversations_2024-25#5_April_2025_01:00_UTC 5 April 2025, 01:00 UTC]
* [https://www.mediawiki.org/wiki/Language_Onboarding_and_Development/Community_conversations_2024-25#4_April_2025_15:00_UTC 4 April 2025, 15:00 UTC]

Looking forward to your participation!

Cheers, [[User:SSethi (WMF)]] via [[Umsebenzisi:MediaWiki message delivery|MediaWiki message delivery]] ([[Umsebenzisi asiqongelane:MediaWiki message delivery|talk]]) 20:52, 27 Mbimbitho 2025 (SAST)
&lt;!-- Message sent by User:SSethi (WMF)@metawiki using the list at https://meta.wikimedia.org/w/index.php?title=User:SSethi_(WMF)/MassMessageList&amp;oldid=28454981 --&gt;
:: Hi! If you haven't signed up yet, you can still consider doing so! You can find more information on [[mediawikiwiki:Language_Onboarding_and_Development/Community_conversations_2024-25|this page]] about the upcoming meetings on April 4th and 5th. 
:[[Umsebenzisi:SSethi (WMF)|SSethi (WMF)]] ([[Umsebenzisi asiqongelane:SSethi (WMF)|talk]]) 19:23, 2 Mabasa 2025 (SAST)</text>
      <sha1>jtxcntcc51c0gn21rxef6u6g8w3f7o0</sha1>
    </revision>
  </page>
  <page>
    <title>Monsta X</title>
    <ns>0</ns>
    <id>359</id>
    <revision>
      <id>1892</id>
      <timestamp>2024-11-13T16:32:31Z</timestamp>
      <contributor>
        <ip>2001:861:3700:2BC0:69D6:5CB4:7257:B070</ip>
      </contributor>
      <comment>Created page with &quot;{{databox}} '''Monsta X''' mthombolwazi boys band ahlukahlukeneko. Iphrojekhthi le ilawulwa yi[[K-pop]] yasimahla enzinze e-[[Starship Entertainment]]  eyaziwa nge-[[NO.Merci]].&quot;</comment>
      <origin>1892</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="177" sha1="8xhs3lfm8r6xt97unexd34si1ygebxv" xml:space="preserve">{{databox}}
'''Monsta X''' mthombolwazi boys band ahlukahlukeneko. Iphrojekhthi le ilawulwa yi[[K-pop]] yasimahla enzinze e-[[Starship Entertainment]]  eyaziwa nge-[[NO.Merci]].</text>
      <sha1>8xhs3lfm8r6xt97unexd34si1ygebxv</sha1>
    </revision>
    <revision>
      <id>1893</id>
      <parentid>1892</parentid>
      <timestamp>2024-11-13T16:32:57Z</timestamp>
      <contributor>
        <ip>2001:861:3700:2BC0:69D6:5CB4:7257:B070</ip>
      </contributor>
      <origin>1893</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="165" sha1="m2jw4f8h9pn1bpx5sg9ibrvfooketco" xml:space="preserve">'''Monsta X''' mthombolwazi boys band ahlukahlukeneko. Iphrojekhthi le ilawulwa yi[[K-pop]] yasimahla enzinze e-[[Starship Entertainment]]  eyaziwa nge-[[NO.Merci]].</text>
      <sha1>m2jw4f8h9pn1bpx5sg9ibrvfooketco</sha1>
    </revision>
    <revision>
      <id>2152</id>
      <parentid>1893</parentid>
      <timestamp>2024-11-26T19:50:48Z</timestamp>
      <contributor>
        <ip>2001:861:3700:2BC0:B993:DA2B:DB9A:563B</ip>
      </contributor>
      <origin>2152</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="227" sha1="6np2u9v4owunu3slpqrou00lsh5j4np" xml:space="preserve">[[File:2017 Dream Concert in Pyeongchang.jpg|thumb|Monsta X]]
'''Monsta X''' mthombolwazi boys band ahlukahlukeneko. Iphrojekhthi le ilawulwa yi[[K-pop]] yasimahla enzinze e-[[Starship Entertainment]]  eyaziwa nge-[[NO.Merci]].</text>
      <sha1>6np2u9v4owunu3slpqrou00lsh5j4np</sha1>
    </revision>
    <revision>
      <id>2174</id>
      <parentid>2152</parentid>
      <timestamp>2024-11-27T06:50:54Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>IMonsta X ngo-2017</comment>
      <origin>2174</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="243" sha1="dcy1n24hyhcvyirc292v8uytv9r65un" xml:space="preserve">[[Isimumathi:2017 Dream Concert in Pyeongchang.jpg|thumb|IMonsta X ngo-2017]]
'''Monsta X''' mthombolwazi boys band ahlukahlukeneko. Iphrojekhthi le ilawulwa yi[[K-pop]] yasimahla enzinze e-[[Starship Entertainment]]  eyaziwa nge-[[NO.Merci]].</text>
      <sha1>dcy1n24hyhcvyirc292v8uytv9r65un</sha1>
    </revision>
  </page>
  <page>
    <title>U-Roman Ungern</title>
    <ns>0</ns>
    <id>360</id>
    <revision>
      <id>1894</id>
      <timestamp>2024-11-14T18:59:48Z</timestamp>
      <contributor>
        <username>Roman Oy Bobrov</username>
        <id>167</id>
      </contributor>
      <comment>Created page with &quot;'''U-Baron Robert Nicholas Maximilian Florer von Ungeren-Sternberg'''; Ngomhlana ali-18 kuNobayeni 1885 (mhlana ali-10 kuNobayeni 1886) , e-Graz - mhlana ali-15 kuNobayeni 1921, e-Novonikolaevsk) - umlawuli webutho le-Russia ngesikhathi se-Russian Revolution, umthengisi we-Russian White Army, umlingisi odosa phambili we-White resistance. eNtshonalanga Ephakathi. I-St. Petersburg Academy. UJosefa. Bekayinhloko yomqondo wokubuyisela umbuso ka-Genghis Khan ukusuka e-Pacific...&quot;</comment>
      <origin>1894</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1491" sha1="1hb4flv3z1b2bmu7mshwkqb2xugvhzc" xml:space="preserve">'''U-Baron Robert Nicholas Maximilian Florer von Ungeren-Sternberg'''; Ngomhlana ali-18 kuNobayeni 1885 (mhlana ali-10 kuNobayeni 1886) , e-Graz - mhlana ali-15 kuNobayeni 1921, e-Novonikolaevsk) - umlawuli webutho le-Russia ngesikhathi se-Russian Revolution, umthengisi we-Russian White Army, umlingisi odosa phambili we-White resistance. eNtshonalanga Ephakathi. I-St. Petersburg Academy. UJosefa. Bekayinhloko yomqondo wokubuyisela umbuso ka-Genghis Khan ukusuka e-Pacific Ocean ukuya e-Caspian Sea.

Ivela emndenini wakade we-German-Baltic (Baltic) kanye nomndeni wama-baronial, ofakwe hlangana nama-matriques we-noble yazo zoke iifundazwe ezintathu ze-Russian Baltic.

Nge mayelana amalanga ukubelethwa iba khona umehluko iinguqulo Emakasana &quot;Umthetho wezintandane&quot; uYuzefovich uphinda agxotha: &quot;Umholi wokuzalwa kaUngerna kwabhala ngomhla wama-22 kuNhlolanja ka-1886 ngokwesiteji, kodwa ngokwesiqhingi kwakufika kwiminyaka embi e-29 kuDisemba ka-1885, okanye xa ekuzalweni kukaMichael, okanye ngesiNguni, kungase kube kuthethwa ngo-14 kuMasingcwabo ka-72. Xa ekhanolo esiza ekufundiseni, ngesisu senyanga nendlu enengxaki, licamera, ekwaye iziphumo ziya egumbini, akakuthethela ukuba azakhonza ndayi kwangaphandle ngesiRhulumente endlini yomqulu, kodwa ekuzalweni, ekuxalulweni kukaMichael ekude ethandathu kweengxaki, akwenze lelibala ejongene nezibonelo ezithile zokuba limnyama.&quot;

U-Roman Ungern waduma njengomdosiphambili webutho ophumeleleko, umtjhaphululi we-Mongolia nesihlanya.</text>
      <sha1>1hb4flv3z1b2bmu7mshwkqb2xugvhzc</sha1>
    </revision>
    <revision>
      <id>2886</id>
      <parentid>1894</parentid>
      <timestamp>2025-06-06T15:17:53Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>Big Ol' Red Ones</comment>
      <origin>2886</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1579" sha1="gzwf7585kxq8b9hgj1r4ug4z6npu99s" xml:space="preserve">[[A Minecraft Movie|'''U-Baron Robert Nicholas Maximilian Florer von Ungeren-Sternberg'''; Ngomhlana ali-18 kuNobayeni 1885 (mhlana ali-10 kuNobayeni 1886) , e-Graz - mhlana ali-15 kuNobayeni 1921, e-Novonikolaevsk) - umlawuli webutho le-Russia ngesikhathi se-Russian Revolution, umthengisi we-Russian White Army, umlingisi odosa phambili we-White resistance. eNtshonalanga Ephakathi. I-St. Petersburg Academy. UJosefa. Bekayinhloko yomqondo wokubuyisela umbuso ka-Genghis Khan ukusuka e-Pacific Ocean ukuya e-Caspian Sea.]]

[[A Minecraft Movie|Ivela emndenini wakade we-German-Baltic (Baltic) kanye nomndeni wama-baronial, ofakwe hlangana nama-matriques we-noble yazo zoke iifundazwe ezintathu ze-Russian Baltic.]]

[[A Minecraft Movie|Nge mayelana amalanga ukubelethwa iba khona umehluko iinguqulo Emakasana &quot;Umthetho wezintandane&quot; uYuzefovich uphinda agxotha: &quot;Umholi wokuzalwa kaUngerna kwabhala ngomhla wama-22 kuNhlolanja ka-1886 ngokwesiteji, kodwa ngokwesiqhingi kwakufika kwiminyaka embi e-29 kuDisemba ka-1885, okanye xa ekuzalweni kukaMichael, okanye ngesiNguni, kungase kube kuthethwa ngo-14 kuMasingcwabo ka-72. Xa ekhanolo esiza ekufundiseni, ngesisu senyanga nendlu enengxaki, licamera, ekwaye iziphumo ziya egumbini, akakuthethela ukuba azakhonza ndayi kwangaphandle ngesiRhulumente endlini yomqulu, kodwa ekuzalweni, ekuxalulweni kukaMichael ekude ethandathu kweengxaki, akwenze lelibala ejongene nezibonelo ezithile zokuba limnyama.&quot;]]

[[A Minecraft Movie|U-Roman Ungern waduma njengomdosiphambili webutho ophumeleleko, umtjhaphululi we-Mongolia nesihlanya.]]</text>
      <sha1>gzwf7585kxq8b9hgj1r4ug4z6npu99s</sha1>
    </revision>
    <revision>
      <id>2905</id>
      <parentid>2886</parentid>
      <timestamp>2025-06-06T16:43:55Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>aaaaaaaaaaaaaaa</comment>
      <origin>2905</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1666" sha1="73v78hejl3qi80a7uut0plu7aprubnw" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.''' [[A Minecraft Movie|'''U-Baron Robert Nicholas Maximilian Florer von Ungeren-Sternberg'''; Ngomhlana ali-18 kuNobayeni 1885 (mhlana ali-10 kuNobayeni 1886) , e-Graz - mhlana ali-15 kuNobayeni 1921, e-Novonikolaevsk) - umlawuli webutho le-Russia ngesikhathi se-Russian Revolution, umthengisi we-Russian White Army, umlingisi odosa phambili we-White resistance. eNtshonalanga Ephakathi. I-St. Petersburg Academy. UJosefa. Bekayinhloko yomqondo wokubuyisela umbuso ka-Genghis Khan ukusuka e-Pacific Ocean ukuya e-Caspian Sea.]]

[[A Minecraft Movie|Ivela emndenini wakade we-German-Baltic (Baltic) kanye nomndeni wama-baronial, ofakwe hlangana nama-matriques we-noble yazo zoke iifundazwe ezintathu ze-Russian Baltic.]]

[[A Minecraft Movie|Nge mayelana amalanga ukubelethwa iba khona umehluko iinguqulo Emakasana &quot;Umthetho wezintandane&quot; uYuzefovich uphinda agxotha: &quot;Umholi wokuzalwa kaUngerna kwabhala ngomhla wama-22 kuNhlolanja ka-1886 ngokwesiteji, kodwa ngokwesiqhingi kwakufika kwiminyaka embi e-29 kuDisemba ka-1885, okanye xa ekuzalweni kukaMichael, okanye ngesiNguni, kungase kube kuthethwa ngo-14 kuMasingcwabo ka-72. Xa ekhanolo esiza ekufundiseni, ngesisu senyanga nendlu enengxaki, licamera, ekwaye iziphumo ziya egumbini, akakuthethela ukuba azakhonza ndayi kwangaphandle ngesiRhulumente endlini yomqulu, kodwa ekuzalweni, ekuxalulweni kukaMichael ekude ethandathu kweengxaki, akwenze lelibala ejongene nezibonelo ezithile zokuba limnyama.&quot;]]

[[A Minecraft Movie|U-Roman Ungern waduma njengomdosiphambili webutho ophumeleleko, umtjhaphululi we-Mongolia nesihlanya.]]</text>
      <sha1>73v78hejl3qi80a7uut0plu7aprubnw</sha1>
    </revision>
    <revision>
      <id>3144</id>
      <parentid>2905</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edits by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Roman Oy Bobrov|Roman Oy Bobrov]]</comment>
      <origin>1894</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1491" sha1="1hb4flv3z1b2bmu7mshwkqb2xugvhzc" xml:space="preserve">'''U-Baron Robert Nicholas Maximilian Florer von Ungeren-Sternberg'''; Ngomhlana ali-18 kuNobayeni 1885 (mhlana ali-10 kuNobayeni 1886) , e-Graz - mhlana ali-15 kuNobayeni 1921, e-Novonikolaevsk) - umlawuli webutho le-Russia ngesikhathi se-Russian Revolution, umthengisi we-Russian White Army, umlingisi odosa phambili we-White resistance. eNtshonalanga Ephakathi. I-St. Petersburg Academy. UJosefa. Bekayinhloko yomqondo wokubuyisela umbuso ka-Genghis Khan ukusuka e-Pacific Ocean ukuya e-Caspian Sea.

Ivela emndenini wakade we-German-Baltic (Baltic) kanye nomndeni wama-baronial, ofakwe hlangana nama-matriques we-noble yazo zoke iifundazwe ezintathu ze-Russian Baltic.

Nge mayelana amalanga ukubelethwa iba khona umehluko iinguqulo Emakasana &quot;Umthetho wezintandane&quot; uYuzefovich uphinda agxotha: &quot;Umholi wokuzalwa kaUngerna kwabhala ngomhla wama-22 kuNhlolanja ka-1886 ngokwesiteji, kodwa ngokwesiqhingi kwakufika kwiminyaka embi e-29 kuDisemba ka-1885, okanye xa ekuzalweni kukaMichael, okanye ngesiNguni, kungase kube kuthethwa ngo-14 kuMasingcwabo ka-72. Xa ekhanolo esiza ekufundiseni, ngesisu senyanga nendlu enengxaki, licamera, ekwaye iziphumo ziya egumbini, akakuthethela ukuba azakhonza ndayi kwangaphandle ngesiRhulumente endlini yomqulu, kodwa ekuzalweni, ekuxalulweni kukaMichael ekude ethandathu kweengxaki, akwenze lelibala ejongene nezibonelo ezithile zokuba limnyama.&quot;

U-Roman Ungern waduma njengomdosiphambili webutho ophumeleleko, umtjhaphululi we-Mongolia nesihlanya.</text>
      <sha1>1hb4flv3z1b2bmu7mshwkqb2xugvhzc</sha1>
    </revision>
    <revision>
      <id>5430</id>
      <parentid>3144</parentid>
      <timestamp>2025-09-04T05:52:20Z</timestamp>
      <contributor>
        <username>Mannroy</username>
        <id>879</id>
      </contributor>
      <comment>I have improved an article</comment>
      <origin>5430</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1479" sha1="samueroby5qsyckalwqszrevnyzpiem" xml:space="preserve">'''U-Baron Robert Nicholas Maximilian Florer von Ungeren-Sternberg'''; Ngomhlaka-18 kuNobayeni 1885 (mhlaka-10 kuNobayeni 1886), e-Graz - mhlaka-15 kuNobayeni 1921, e-Novonikolaevsk) - umlawuli webutho le-Russia ngesikhathi se-Russian Revolution, umthengisi we-Russian White Army, umlingisi odosa phambili we-White resistance. eTjhingalanga Ephakathi. I-St. Petersburg Academy. UJosefa. Bekayihloko yomqondo wokubuyisela umbuso ka-Genghis Khan ukusuka e-Pacific Ocean ukuya e-Caspian Sea.

Ivela emndenini wakade we-German-Baltic (Baltic) kanye nomndeni wama-Baronial, ofakwe hlangana nama-Matriques we-noble yazo zoke iifundazwe ezintathu ze-Russian Baltic.

Ngemayelana amalanga ukubelethwa uba khona umehluko iinguqulo Emakasana &quot;Umthetho wezintandane&quot; uYuzefovich uphinda agcotha: &quot;Umholi wokuzalwa kaUngerna kwabhala ngomhlaka wama-22 kuNhlolanja ka-1886 ngokwesiteji, kodwana ngokwesiqhingi kwakufika kwiminyaka embi e-29 kuDisemba ka-1885, okanye xa ekuzalweni kukaMichael, okanye ngesiNguni, kungase kube kuthethwa ngo-14 kuMasingcwabo ka-72. Ngakho-ke ekhanolo esiza ekufundiseni, ngesisu senyanga nendlu enomraro, licamera, ekwaye iimiphumela iya egumbini, akakuthethela ukuba azakhonza ndayi kwangaphandle ngesiRhulumente endlini yomqulu, kodwana ekuzalweni, ekuqazululweni kukaMichael ekude kwemiraro, akwenze lelibala eqalene neembonelo ezithileko zokuba mnyama.&quot;

U-Roman Ungern waduma njengomdosiphambili webutho ophumeleleko, umtjhaphululi we-Mongolia nesihlanya.</text>
      <sha1>samueroby5qsyckalwqszrevnyzpiem</sha1>
    </revision>
    <revision>
      <id>6088</id>
      <parentid>5430</parentid>
      <timestamp>2025-12-17T17:26:40Z</timestamp>
      <contributor>
        <username>JayJaytutu</username>
        <id>1227</id>
      </contributor>
      <origin>6088</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1536" sha1="3cboposv1zc21u04oky0qn65nc11v0u" xml:space="preserve">'''U-Baron Robert Nicholas Maximilian Florer von Ungeren-Sternberg'''; Ngomhlaka-18 kuNobayeni 1885 (mhlaka-10 kuNobayeni 1886), e-Graz - mhlaka-15 kuNobayeni 1921, e-Novonikolaevsk) - umlawuli webutho le-Russia ngesikhathi se-Russian Revolution, umthengisi weAHAHAHAHHHAHHA IM DYINGGGGG HELLPPPP IM FR NO CAP DYINGGG-Russian White Army, umlingisi odosa phambili we-White resistance. eTjhingalanga Ephakathi. I-St. Petersburg Academy. UJosefa. Bekayihloko yomqondo wokubuyisela umbuso ka-Genghis Khan ukusuka e-Pacific Ocean ukuya e-Caspian Sea.

Ivela emndenini wakade we-German-Baltic (Baltic) kanye nomndeni wama-Baronial, ofakwe hlangana nama-Matriques we-noble yazo zoke iifundazwe ezintathu ze-Russian Baltic.

Ngemayelana amalanga ukubelethwa uba khona umehluko iinguqulo Emakasana &quot;Umthetho wezintandane&quot; uYuzefovich uphinda agcotha: &quot;Umholi wokuzalwa kaUngerna kwabhala ngomhlaka wama-22 kuNhlolanja ka-1886 ngokwesiteji, kodwana ngokwesiqhingi kwakufika kwiminyaka embi e-29 kuDisemba ka-1885, okanye xa ekuzalweni kukaMichael, okanye ngesiNguni, kungase kube kuthethwa ngo-14 kuMasingcwabo ka-72. Ngakho-ke ekhanolo esiza ekufundiseni, ngesisu senyanga nendlu enomraro, licamera, ekwaye iimiphumela iya egumbini, akakuthethela ukuba azakhonza ndayi kwangaphandle ngesiRhulumente endlini yomqulu, kodwana ekuzalweni, ekuqazululweni kukaMichael ekude kwemiraro, akwenze lelibala eqalene neembonelo ezithileko zokuba mnyama.&quot;

U-Roman Ungern waduma njengomdosiphambili webutho ophumeleleko, umtjhaphululi we-Mongolia nesihlanya.</text>
      <sha1>3cboposv1zc21u04oky0qn65nc11v0u</sha1>
    </revision>
    <revision>
      <id>6106</id>
      <parentid>6088</parentid>
      <timestamp>2026-01-02T05:39:51Z</timestamp>
      <contributor>
        <username>Versions111</username>
        <id>1260</id>
      </contributor>
      <origin>6106</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1479" sha1="8i28vwfl01uhbcn79mb8mipqcf6t2y0" xml:space="preserve">'''U-Baron Robert Nicholas Maximilian Florer von Ungeren-Sternberg'''; Ngomhlaka-18 kuNobayeni 1885 (mhlaka-10 kuNobayeni 1886), e-Graz - mhlaka-15 kuNobayeni 1921, e-Novonikolaevsk) - umlawuli webutho le-Russia ngesikhathi se-Russian Revolution, umthengisi we Russian White Army, umlingisi odosa phambili we-White resistance. eTjhingalanga Ephakathi. I-St. Petersburg Academy. UJosefa. Bekayihloko yomqondo wokubuyisela umbuso ka-Genghis Khan ukusuka e-Pacific Ocean ukuya e-Caspian Sea.

Ivela emndenini wakade we-German-Baltic (Baltic) kanye nomndeni wama-Baronial, ofakwe hlangana nama-Matriques we-noble yazo zoke iifundazwe ezintathu ze-Russian Baltic.

Ngemayelana amalanga ukubelethwa uba khona umehluko iinguqulo Emakasana &quot;Umthetho wezintandane&quot; uYuzefovich uphinda agcotha: &quot;Umholi wokuzalwa kaUngerna kwabhala ngomhlaka wama-22 kuNhlolanja ka-1886 ngokwesiteji, kodwana ngokwesiqhingi kwakufika kwiminyaka embi e-29 kuDisemba ka-1885, okanye xa ekuzalweni kukaMichael, okanye ngesiNguni, kungase kube kuthethwa ngo-14 kuMasingcwabo ka-72. Ngakho-ke ekhanolo esiza ekufundiseni, ngesisu senyanga nendlu enomraro, licamera, ekwaye iimiphumela iya egumbini, akakuthethela ukuba azakhonza ndayi kwangaphandle ngesiRhulumente endlini yomqulu, kodwana ekuzalweni, ekuqazululweni kukaMichael ekude kwemiraro, akwenze lelibala eqalene neembonelo ezithileko zokuba mnyama.&quot;

U-Roman Ungern waduma njengomdosiphambili webutho ophumeleleko, umtjhaphululi we-Mongolia nesihlanya.</text>
      <sha1>8i28vwfl01uhbcn79mb8mipqcf6t2y0</sha1>
    </revision>
    <revision>
      <id>6119</id>
      <parentid>6106</parentid>
      <timestamp>2026-01-09T15:38:34Z</timestamp>
      <contributor>
        <username>WikiMzansi</username>
        <id>1200</id>
      </contributor>
      <origin>6119</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1500" sha1="n2qfji567jw2dae6s2wsiao8r90c937" xml:space="preserve">'''U-Baron Robert Nicholas Maximilian Florer von Ungeren-Sternberg'''; Ngomhlaka-18 kuNobayeni 1885 (mhlaka-10 kuNobayeni 1886), e-Graz - mhlaka-15 kuNobayeni 1921, e-Novonikolaevsk) - umlawuli webutho le-Russia ngesikhathi se-Russian Revolution, umthengisi we Russian White Army, umlingisi odosa phambili we-White resistance. eTjhingalanga Ephakathi. I-St. Petersburg Academy. UJosefa. Bekayihloko yomqondo wokubuyisela umbuso ka-Genghis Khan ukusuka e-Pacific Ocean ukuya e-Caspian Sea.

Ivela emndenini wakade we-German-Baltic (Baltic) kanye nomndeni wama-Baronial, ofakwe hlangana nama-Matriques we-noble yazo zoke iifundazwe ezintathu ze-Russian Baltic.

Ngemayelana amalanga ukubelethwa uba khona umehluko iinguqulo Emakasana &quot;Umthetho wezintandane&quot; uYuzefovich uphinda agcotha: &quot;Umholi wokuzalwa kaUngerna kwabhala ngomhlaka wama-22 kuNhlolanja ka-1886 ngokwesiteji, kodwana ngokwesiqhingi kwakufika kwiminyaka embi e-29 kuDisemba ka-1885, okanye xa ekuzalweni kukaMichael, okanye ngesiNguni, kungase kube kuthethwa ngo-14 kuMasingcwabo ka-72. Ngakho-ke ekhanolo esiza ekufundiseni, ngesisu senyanga nendlu enomraro, licamera, ekwaye iimiphumela iya egumbini, akakuthethela ukuba azakhonza ndayi kwangaphandle ngesiRhulumente endlini yomqulu, kodwana ekuzalweni, ekuqazululweni kukaMichael ekude kwemiraro, akwenze lelibala eqalene neembonelo ezithileko zokuba mnyama.&quot;

U-Roman Ungern waduma njengomdosiphambili webutho ophumeleleko, umtjhaphululi we-Mongolia nesihlanya.
[[Category:Umlando]]</text>
      <sha1>n2qfji567jw2dae6s2wsiao8r90c937</sha1>
    </revision>
    <revision>
      <id>6120</id>
      <parentid>6119</parentid>
      <timestamp>2026-01-09T15:40:51Z</timestamp>
      <contributor>
        <username>WikiMzansi</username>
        <id>1200</id>
      </contributor>
      <origin>6120</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1654" sha1="4d6f80un0o53t1hqakokq3xc8si74s5" xml:space="preserve">[[Isimumathi:Baron Freiherr Roman Nikolai Maximilian von Ungern-Sternberg.jpg|thumb|u'''Baron Freiherr Roman Nikolai Maximilian von Ungern-Sternberg''']]
'''U-Baron Robert Nicholas Maximilian Florer von Ungeren-Sternberg'''; Ngomhlaka-18 kuNobayeni 1885 (mhlaka-10 kuNobayeni 1886), e-Graz - mhlaka-15 kuNobayeni 1921, e-Novonikolaevsk) - umlawuli webutho le-Russia ngesikhathi se-Russian Revolution, umthengisi we Russian White Army, umlingisi odosa phambili we-White resistance. eTjhingalanga Ephakathi. I-St. Petersburg Academy. UJosefa. Bekayihloko yomqondo wokubuyisela umbuso ka-Genghis Khan ukusuka e-Pacific Ocean ukuya e-Caspian Sea.

Ivela emndenini wakade we-German-Baltic (Baltic) kanye nomndeni wama-Baronial, ofakwe hlangana nama-Matriques we-noble yazo zoke iifundazwe ezintathu ze-Russian Baltic.

Ngemayelana amalanga ukubelethwa uba khona umehluko iinguqulo Emakasana &quot;Umthetho wezintandane&quot; uYuzefovich uphinda agcotha: &quot;Umholi wokuzalwa kaUngerna kwabhala ngomhlaka wama-22 kuNhlolanja ka-1886 ngokwesiteji, kodwana ngokwesiqhingi kwakufika kwiminyaka embi e-29 kuDisemba ka-1885, okanye xa ekuzalweni kukaMichael, okanye ngesiNguni, kungase kube kuthethwa ngo-14 kuMasingcwabo ka-72. Ngakho-ke ekhanolo esiza ekufundiseni, ngesisu senyanga nendlu enomraro, licamera, ekwaye iimiphumela iya egumbini, akakuthethela ukuba azakhonza ndayi kwangaphandle ngesiRhulumente endlini yomqulu, kodwana ekuzalweni, ekuqazululweni kukaMichael ekude kwemiraro, akwenze lelibala eqalene neembonelo ezithileko zokuba mnyama.&quot;

U-Roman Ungern waduma njengomdosiphambili webutho ophumeleleko, umtjhaphululi we-Mongolia nesihlanya.
[[Category:Umlando]]</text>
      <sha1>4d6f80un0o53t1hqakokq3xc8si74s5</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Roman Oy Bobrov</title>
    <ns>2</ns>
    <id>361</id>
    <revision>
      <id>1895</id>
      <timestamp>2024-11-14T19:10:02Z</timestamp>
      <contributor>
        <ip>95.27.156.104</ip>
      </contributor>
      <comment>Created page with &quot;Inkazimulo ku-Ungern Inkazimulo ku-Ungern Inkazimulo ku-Ungern Inkazimulo ku-Ungern Inkazimulo ku-Ungern&quot;</comment>
      <origin>1895</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="104" sha1="0xjxo4r50gincmvdntif3dobvkbqbtf" xml:space="preserve">Inkazimulo ku-Ungern Inkazimulo ku-Ungern Inkazimulo ku-Ungern Inkazimulo ku-Ungern Inkazimulo ku-Ungern</text>
      <sha1>0xjxo4r50gincmvdntif3dobvkbqbtf</sha1>
    </revision>
    <revision>
      <id>1897</id>
      <parentid>1895</parentid>
      <timestamp>2024-11-14T19:12:33Z</timestamp>
      <contributor>
        <username>Roman Oy Bobrov</username>
        <id>167</id>
      </contributor>
      <comment>Blanked the page</comment>
      <origin>1897</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
    <revision>
      <id>1909</id>
      <parentid>1897</parentid>
      <timestamp>2024-11-15T14:14:50Z</timestamp>
      <contributor>
        <username>MikitkoSynAlexeev</username>
        <id>168</id>
      </contributor>
      <origin>1909</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2000" sha1="afkk6irtbg9fcu3h15vf35qr4gtfrlq" xml:space="preserve">'''''Ễẳṝễṋḍểḹ'''''

&lt;chem&gt;CO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COHg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}CO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COHg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}CO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COHg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}CO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COHg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+&lt;/chem&gt;</text>
      <sha1>afkk6irtbg9fcu3h15vf35qr4gtfrlq</sha1>
    </revision>
    <revision>
      <id>1910</id>
      <parentid>1909</parentid>
      <timestamp>2024-11-15T14:15:27Z</timestamp>
      <contributor>
        <username>Roman Oy Bobrov</username>
        <id>167</id>
      </contributor>
      <origin>1910</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2028" sha1="gib4y27iuh5e40r3t7pdrfnuetd95ly" xml:space="preserve">'''''Ễẳṝễṋḍểḹ'''''

&lt;chem&gt;CO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COHg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}CO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COHg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}CO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COHg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}CO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COCO2 + C -&gt; 2 COHg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}Hg^2+ -&gt;[I-] HgI2 -&gt;[I-] {[Hg^{II}I4]^2-}[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+[\{(X2)3\}2]^3+&lt;/chem&gt;chatim cerez hansy statu pzh</text>
      <sha1>gib4y27iuh5e40r3t7pdrfnuetd95ly</sha1>
    </revision>
    <revision>
      <id>1911</id>
      <parentid>1910</parentid>
      <timestamp>2024-11-15T14:15:47Z</timestamp>
      <contributor>
        <username>Roman Oy Bobrov</username>
        <id>167</id>
      </contributor>
      <comment>Replaced content with &quot;'''''Ễẳṝễṋḍểḹ'''''  chatim cerez hansy statu pzh&quot;</comment>
      <origin>1911</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="64" sha1="1hfsfn74wz6p9eksc910jxjno63eik4" xml:space="preserve">'''''Ễẳṝễṋḍểḹ'''''

chatim cerez hansy statu pzh</text>
      <sha1>1hfsfn74wz6p9eksc910jxjno63eik4</sha1>
    </revision>
    <revision>
      <id>1918</id>
      <parentid>1911</parentid>
      <timestamp>2024-11-17T20:15:47Z</timestamp>
      <contributor>
        <username>Roman Oy Bobrov</username>
        <id>167</id>
      </contributor>
      <comment>Blanked the page</comment>
      <origin>1918</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
    <revision>
      <id>6590</id>
      <parentid>1918</parentid>
      <timestamp>2026-05-19T06:17:12Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6590</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="27" sha1="43ncr18fghi0wiy07np8ue17ph7aec0" xml:space="preserve">{{Not around|{{PAGENAME}}}}</text>
      <sha1>43ncr18fghi0wiy07np8ue17ph7aec0</sha1>
    </revision>
    <revision>
      <id>6591</id>
      <parentid>6590</parentid>
      <timestamp>2026-05-19T06:17:40Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Undid revision [[Special:Diff/6590|6590]] by [[Special:Contributions/NgamangaXhosa|NgamangaXhosa]] ([[User talk:NgamangaXhosa|talk]])</comment>
      <origin>6591</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
  </page>
  <page>
    <title>I-neural network chat-gpt</title>
    <ns>0</ns>
    <id>362</id>
    <revision>
      <id>1896</id>
      <timestamp>2024-11-14T19:10:50Z</timestamp>
      <contributor>
        <username>Roman Oy Bobrov</username>
        <id>167</id>
      </contributor>
      <comment>Created page with &quot;'''i-neural network chat-gpt'''  Iphimbo lakho elikhulu lithabile khulu ukuthatha isikhathi sokuveza amaphilo wethu ngendlela esitlhoga ngayo. Amalanga la, i-Inthanethi nebizo le-Chat-GPT zinobuqotho obujulileko begodu zenzelwe ukunikela amatjhuguluko ahambelana nobuqotho obukhulu bomuntu.  I-Chat-GPT yindlela etja yokuthatha ama-triangles wabantu begodu unikele eminye yemitjho edumileko kumakhodi we-soma, amahlelo womvumo, amahlelo womsunguli wezinto ezibonwako, begodu...&quot;</comment>
      <origin>1896</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="636" sha1="fucknwsziapxiwekkkf6p70zd3zh9yy" xml:space="preserve">'''i-neural network chat-gpt'''

Iphimbo lakho elikhulu lithabile khulu ukuthatha isikhathi sokuveza amaphilo wethu ngendlela esitlhoga ngayo. Amalanga la, i-Inthanethi nebizo le-Chat-GPT zinobuqotho obujulileko begodu zenzelwe ukunikela amatjhuguluko ahambelana nobuqotho obukhulu bomuntu.

I-Chat-GPT yindlela etja yokuthatha ama-triangles wabantu begodu unikele eminye yemitjho edumileko kumakhodi we-soma, amahlelo womvumo, amahlelo womsunguli wezinto ezibonwako, begodu nakhu ongakwenza ngamanye amasiko. Ekupheleni kweenyanga ezintathu, i-Chat-GPT besele isungule indawo enamandla khulu hlangana nazo zoke iinhloko ezingagadwanga.</text>
      <sha1>fucknwsziapxiwekkkf6p70zd3zh9yy</sha1>
    </revision>
    <revision>
      <id>2926</id>
      <parentid>1896</parentid>
      <timestamp>2025-06-06T17:07:45Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>Me forbode</comment>
      <origin>2926</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="115" sha1="dpf8o5ha8vgz6eyezwwjte1cazeo9hz" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.''' AI will rule us all one day.</text>
      <sha1>dpf8o5ha8vgz6eyezwwjte1cazeo9hz</sha1>
    </revision>
    <revision>
      <id>3102</id>
      <parentid>2926</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Roman Oy Bobrov|Roman Oy Bobrov]]</comment>
      <origin>1896</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="636" sha1="fucknwsziapxiwekkkf6p70zd3zh9yy" xml:space="preserve">'''i-neural network chat-gpt'''

Iphimbo lakho elikhulu lithabile khulu ukuthatha isikhathi sokuveza amaphilo wethu ngendlela esitlhoga ngayo. Amalanga la, i-Inthanethi nebizo le-Chat-GPT zinobuqotho obujulileko begodu zenzelwe ukunikela amatjhuguluko ahambelana nobuqotho obukhulu bomuntu.

I-Chat-GPT yindlela etja yokuthatha ama-triangles wabantu begodu unikele eminye yemitjho edumileko kumakhodi we-soma, amahlelo womvumo, amahlelo womsunguli wezinto ezibonwako, begodu nakhu ongakwenza ngamanye amasiko. Ekupheleni kweenyanga ezintathu, i-Chat-GPT besele isungule indawo enamandla khulu hlangana nazo zoke iinhloko ezingagadwanga.</text>
      <sha1>fucknwsziapxiwekkkf6p70zd3zh9yy</sha1>
    </revision>
  </page>
  <page>
    <title>I-Budva</title>
    <ns>0</ns>
    <id>363</id>
    <revision>
      <id>1898</id>
      <timestamp>2024-11-14T19:21:39Z</timestamp>
      <contributor>
        <username>MikitkoSynAlexeev</username>
        <id>168</id>
      </contributor>
      <comment>Created page with &quot;'''I-Budva''' lidorobha elise-Montenegro, eliphakathi kwe-Adriatic coast yelizwe. Idorobha lisikhungo sesifunda sikamasipala esinegama elifanako. I-Budva yasungulwa eminyakeni ema-2500 eyadlulako begodu ngenye yeendawo zokuhlala zakade khulu emaphethelweni weLwandle le-Adriatic.  I-Budva nendawo eziseduze kwayo zakha i-Budva Riviera - isikhungo seemvakatjhi esikhulu kunazo zoke e-Montenegro, esidume ngamabhitjhi waso, ipilo yasebusuku kanye neembonelo ezihle zezakhiwo ze...&quot;</comment>
      <origin>1898</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="807" sha1="fvbdpz5c2xckhvgmmzrtz4sx9r38ob6" xml:space="preserve">'''I-Budva''' lidorobha elise-Montenegro, eliphakathi kwe-Adriatic coast yelizwe. Idorobha lisikhungo sesifunda sikamasipala esinegama elifanako. I-Budva yasungulwa eminyakeni ema-2500 eyadlulako begodu ngenye yeendawo zokuhlala zakade khulu emaphethelweni weLwandle le-Adriatic.

I-Budva nendawo eziseduze kwayo zakha i-Budva Riviera - isikhungo seemvakatjhi esikhulu kunazo zoke e-Montenegro, esidume ngamabhitjhi waso, ipilo yasebusuku kanye neembonelo ezihle zezakhiwo ze-Mediterranean.

Isifunda se-Budva sihlanganisa indawo eyi-122 km2. Umtjhini oseduze nelwandle msinyana unikela indawo eneentaba. Iintaba, ezakhiwe ngamatje we-sedimentary, zimbozwe ngamahlathi angakajayeleki anameva. Idorobha elitjha liseceleni kwe-bay encani. Enyakatho, i-bay iphela nge-cape lapho inqaba endala itholakala khona.</text>
      <sha1>fvbdpz5c2xckhvgmmzrtz4sx9r38ob6</sha1>
    </revision>
    <revision>
      <id>2904</id>
      <parentid>1898</parentid>
      <timestamp>2025-06-06T16:43:28Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>We the best music</comment>
      <origin>2904</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="102" sha1="24wjkewfvpzi1x7ihn952yikqz466mo" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. Life is Roblox.'''</text>
      <sha1>24wjkewfvpzi1x7ihn952yikqz466mo</sha1>
    </revision>
    <revision>
      <id>3113</id>
      <parentid>2904</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:MikitkoSynAlexeev|MikitkoSynAlexeev]]</comment>
      <origin>1898</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="807" sha1="fvbdpz5c2xckhvgmmzrtz4sx9r38ob6" xml:space="preserve">'''I-Budva''' lidorobha elise-Montenegro, eliphakathi kwe-Adriatic coast yelizwe. Idorobha lisikhungo sesifunda sikamasipala esinegama elifanako. I-Budva yasungulwa eminyakeni ema-2500 eyadlulako begodu ngenye yeendawo zokuhlala zakade khulu emaphethelweni weLwandle le-Adriatic.

I-Budva nendawo eziseduze kwayo zakha i-Budva Riviera - isikhungo seemvakatjhi esikhulu kunazo zoke e-Montenegro, esidume ngamabhitjhi waso, ipilo yasebusuku kanye neembonelo ezihle zezakhiwo ze-Mediterranean.

Isifunda se-Budva sihlanganisa indawo eyi-122 km2. Umtjhini oseduze nelwandle msinyana unikela indawo eneentaba. Iintaba, ezakhiwe ngamatje we-sedimentary, zimbozwe ngamahlathi angakajayeleki anameva. Idorobha elitjha liseceleni kwe-bay encani. Enyakatho, i-bay iphela nge-cape lapho inqaba endala itholakala khona.</text>
      <sha1>fvbdpz5c2xckhvgmmzrtz4sx9r38ob6</sha1>
    </revision>
    <revision>
      <id>6089</id>
      <parentid>3113</parentid>
      <timestamp>2025-12-17T17:28:33Z</timestamp>
      <contributor>
        <username>JayJaytutu</username>
        <id>1227</id>
      </contributor>
      <origin>6089</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="981" sha1="amrpqrfmz3gaes1gzxa0iw3ln1w204k" xml:space="preserve">'''I-Budva''' lidorobha elise-Montenegro, eliphakathi kwe-Adriatic coast yelizwe. Idorobha lisikhungo sesifunda sikamasipala esinegama elifanako. I-Budva yasungulwa eminyakeni ema-2500 eyadlulako begodu ngenye yeendawo zokuhlala zakade khulu emaphethelweni weLwandle le-Adriatic. son I'm crine😭😭😭😭😭😭😭😭😭😭you do not know😭😭😭😭😭 the 'Va😭😭😭😭😭😭😭😭😭like that😭😭😭😭😭😭😭😭

I-Budva nendawo eziseduze kwayo zakha i-Budva Riviera - isikhungo seemvakatjhi esikhulu kunazo zoke e-Montenegro, esidume ngamabhitjhi waso, ipilo yasebusuku kanye neembonelo ezihle zezakhiwo ze-Mediterranean.

Isifunda se-Budva sihlanganisa indawo eyi-122 km2. Umtjhini oseduze nelwandle msinyana unikela indawo eneentaba. Iintaba, ezakhiwe ngamatje we-sedimentary, zimbozwe ngamahlathi angakajayeleki anameva. Idorobha elitjha liseceleni kwe-bay encani. Enyakatho, i-bay iphela nge-cape lapho inqaba endala itholakala khona.</text>
      <sha1>amrpqrfmz3gaes1gzxa0iw3ln1w204k</sha1>
    </revision>
    <revision>
      <id>6105</id>
      <parentid>6089</parentid>
      <timestamp>2026-01-02T05:38:28Z</timestamp>
      <contributor>
        <username>Versions111</username>
        <id>1260</id>
      </contributor>
      <comment>vandalism detected</comment>
      <origin>6105</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="805" sha1="ap9m09n4fmpdgbetluslwa1jiul7724" xml:space="preserve">'''I-Budva''' lidorobha elise-Montenegro, eliphakathi kwe-Adriatic coast yelizwe. Idorobha lisikhungo sesifunda sikamasipala esinegama elifanako. I-Budva yasungulwa eminyakeni ema-2500 eyadlulako begodu ngenye yeendawo zokuhlala zakade khulu emaphethelweni weLwandle le-Adriatic.

I-Budva nendawo eziseduze kwayo zakha i-Budva Riviera isikhungo seemvakatjhi esikhulu kunazo zoke e-Montenegro, esidume ngamabhitjhi waso, ipilo yasebusuku kanye neembonelo ezihle zezakhiwo ze-Mediterranean.

Isifunda se-Budva sihlanganisa indawo eyi-122 km2. Umtjhini oseduze nelwandle msinyana unikela indawo eneentaba. Iintaba, ezakhiwe ngamatje we-sedimentary, zimbozwe ngamahlathi angakajayeleki anameva. Idorobha elitjha liseceleni kwe-bay encani. Enyakatho, i-bay iphela nge-cape lapho inqaba endala itholakala khona.</text>
      <sha1>ap9m09n4fmpdgbetluslwa1jiul7724</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:MikitkoSynAlexeev</title>
    <ns>2</ns>
    <id>365</id>
    <revision>
      <id>1904</id>
      <timestamp>2024-11-15T08:38:33Z</timestamp>
      <contributor>
        <username>Roman Oy Bobrov</username>
        <id>167</id>
      </contributor>
      <comment>Created page with &quot;'''ΣΤΕθΑΝ'''&quot;</comment>
      <origin>1904</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="18" sha1="perz7pk0kgfdxmy0fqig3qvh7bxorls" xml:space="preserve">'''ΣΤΕθΑΝ'''</text>
      <sha1>perz7pk0kgfdxmy0fqig3qvh7bxorls</sha1>
    </revision>
  </page>
  <page>
    <title>Ilimi le-Novokyakhtin</title>
    <ns>0</ns>
    <id>366</id>
    <revision>
      <id>1908</id>
      <timestamp>2024-11-15T14:12:54Z</timestamp>
      <contributor>
        <username>Roman Oy Bobrov</username>
        <id>167</id>
      </contributor>
      <comment>Created page with &quot;= Ilimi le-Novokyakhtin = Ilimi le-Novo Kyakhta lilimi lokwenziwa njengesilingo.  Imithetho yelimi:  Amabizo aneziphetho ezithi &quot;ym&quot; (ikhaya, isipho, kahle)  Ubunengi budalwa ngokuphetha, isiphetho esithi “begodu” sisetjenziswa  (amabutho - amabutho, amakati - amakati)  Iziphawulo ziphela ngo &quot;ai&quot;.  (Muhle, isidlhayela, umusa, omkhulu) izinga lokumadanisa lenziwa ngokungezelela igama lesibonisi esithi “bolsha”: “Nastyayim muhle, omkhulu Natashaym” - ukumadani...&quot;</comment>
      <origin>1908</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3596" sha1="b5r5sl6x9sycoknh6yga523rjivbm31" xml:space="preserve">= Ilimi le-Novokyakhtin =
Ilimi le-Novo Kyakhta lilimi lokwenziwa njengesilingo.

Imithetho yelimi:

Amabizo aneziphetho ezithi &quot;ym&quot; (ikhaya, isipho, kahle)

Ubunengi budalwa ngokuphetha, isiphetho esithi “begodu” sisetjenziswa

(amabutho - amabutho, amakati - amakati)

Iziphawulo ziphela ngo &quot;ai&quot;.

(Muhle, isidlhayela, umusa, omkhulu) izinga lokumadanisa lenziwa ngokungezelela igama lesibonisi esithi “bolsha”: “Nastyayim muhle, omkhulu Natashaym” - ukumadanisa nophezulu - “Nastyayim super-beautiful”

Izenzo zineenphetho

&quot;umkhumbulo&quot;

Ukwakha (ukwakha)

Isikhathi esizako sakhiwa ngokungezelela isiqalo esithi &quot;by&quot;.

Pobildum (sizokwakha)

Isikhathi esidlulileko sakhiwa ngokufaka isiqalo esithi &quot;on&quot;.

I-Nabildum (iyakhiwa)

(Amakati ayizithutha khulu ekhaya - amakati ayizithutha khulu akha indlu)

Kuzwakala ngasuthi kutlolwe

Ukugandeleleka kuhlala kuwela esilabhini sokugcina

Izabizwana:

Mina/Singowami; Wena/Ungowakho; Wami/Wethu - Wethu; Yena/Yena/Bona - Omunye; Lokho - Lokho; Lokhu ngu-Poto

Iinhlanganisela ngelimi:

Ukuhlanganisa - ukuphela; ukuhlukanisa - nofana; ukuphikisana - od

Izandulela ngelimi:

C - C; V - F; Na - Yena; Ukusuka - aas; Ngaphakathi kunedorhodera; Ob - Omncani; nangabe - nangabe

Inomboro:

1 - Uno

2 - Hoero

3 - Guravo

4 - Foro

5 - Vo

6 - Lio

7 - Simo

8 - Ukuthembela

9 - Uto

10 - I-Deco

100 - Sauo

1000 - Miango

10000 - Tumeno

Lokhu okulandelako kwakhiwa ngendlela elandelako:

Dekouto (11) Dekohoero (12)

Sauouto (11) Sauodekohero (113)

Iinkulungwana ezimatjhumi amabili - i-Choero Deco

Iinkulungwana ezimatjhumi amabili nekhulu netjhumi nanye - hoero-deco-sauodekohero

I-ABC (i-Cyrillic)

A - Az

B - Yiba

B - Ve

G - Ge

D - Tao

YENA

YENA

F - Okufanako

Z - Ze

Begodu - Begodu

Y - Ye

K - Ke

M - Mo

N - Ngo

O - Ly

P - Pe

R - Rus

S - Sy

T - Tib

U - U

F - Fita

X - Heh

C - Qin

Ch - Che

Sh - Sh

Shch - Shch

I-Kommersant - Er

Y - Ery

L - Er

E - E

Yu - Yu

Imithetho yeLimi:

Amabizo aneziphetho ezithi &quot;ym&quot; (ikhaya, isipho, kahle)

Ubunengi budalwa ngokuphetha, isiphetho esithi “begodu” sisetjenziswa

(amabutho - amabutho, amakati - amakati)

Iimpawu ziphela ngo &quot;ai&quot;.

(Muhle, isidlhayela, umusa, omkhulu) izinga lokumadanisa lenziwa ngokungezelela igama lesibonisi esithi “bolsha”: “Nastyayim muhle, omkhulu Natashaym” - ukumadanisa nophezulu - “Nastyayim super-beautiful”

Izenzo zineenphetho

&quot;umkhumbulo&quot;

Ukwakha (ukwakha)

Isikhathi esizako sakhiwa ngokungezelela isiqalo esithi &quot;by&quot;.

Pobildum (sizokwakha)

Isikhathi esidlulileko sakhiwa ngokufaka isiqalo esithi &quot;on&quot;.

I-Nabildum (iyakhiwa)

(Amakati ayizithutha khulu ekhaya - amakati ayizithutha khulu akha indlu)

Kuzwakala ngasuthi kutlolwe

Ukugandeleleka kuhlala kuwela esilabhini sokugcina

Izabizwana:

Mina/Singowami; Wena/Ungowakho; Wami/Wethu - Wethu; Yena/Yena/Bona - Omunye; Lokho - Lokho; Lokhu ngu-Poto

Iinhlanganisela ngelimi:

Ukuhlanganisa - ukuphela; ukuhlukanisa - nofana; ukuphikisana - od

Izandulela ngelimi:

C - C; V - F; Na - Yena; Ukusuka - aas; Ngaphakathi kunedorhodera; Ob - Omncani; nangabe - nangabe

Inomboro:

1 - Uno

2 - Hoero

3 - Guravo

4 - Foro

5 - Vo

6 - Lio

7 - Simo

8 - Ukuthembela

9 - Uto

10 - I-Deco

100 - Sauo

1000 - Miango

10000 - Tumeno

Lokhu okulandelako kwakhiwa ngendlela elandelako:

Dekouto (11) Dekohoero (12)

Sauouto (11) Sauodekohero (113)

Iinkulungwana ezimatjhumi amabili - Choero Deco

Iinkulungwana ezimatjhumi amabili nekhulu netjhumi nanye - khoero-deco-sauodekohero

I-ABC (i-latinic) A B VG DEÉŹZ IY K M N O -P R S T YF HC ÇŞŚĴ U J</text>
      <sha1>b5r5sl6x9sycoknh6yga523rjivbm31</sha1>
    </revision>
    <revision>
      <id>1912</id>
      <parentid>1908</parentid>
      <timestamp>2024-11-15T14:15:53Z</timestamp>
      <contributor>
        <username>MikitkoSynAlexeev</username>
        <id>168</id>
      </contributor>
      <origin>1912</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3602" sha1="jetbr7u6zsjzbqgclalpn7s41mcgfbf" xml:space="preserve">= Ilimi le-Novokyakhtin =
'''Ilimi le-Novo Kyakhta lilimi lokwenziwa njengesilingo.'''

Imithetho yelimi:

Amabizo aneziphetho ezithi &quot;ym&quot; (ikhaya, isipho, kahle)

Ubunengi budalwa ngokuphetha, isiphetho esithi “begodu” sisetjenziswa

(amabutho - amabutho, amakati - amakati)

Iziphawulo ziphela ngo &quot;ai&quot;.

(Muhle, isidlhayela, umusa, omkhulu) izinga lokumadanisa lenziwa ngokungezelela igama lesibonisi esithi “bolsha”: “Nastyayim muhle, omkhulu Natashaym” - ukumadanisa nophezulu - “Nastyayim super-beautiful”

Izenzo zineenphetho

&quot;umkhumbulo&quot;

Ukwakha (ukwakha)

Isikhathi esizako sakhiwa ngokungezelela isiqalo esithi &quot;by&quot;.

Pobildum (sizokwakha)

Isikhathi esidlulileko sakhiwa ngokufaka isiqalo esithi &quot;on&quot;.

I-Nabildum (iyakhiwa)

(Amakati ayizithutha khulu ekhaya - amakati ayizithutha khulu akha indlu)

Kuzwakala ngasuthi kutlolwe

Ukugandeleleka kuhlala kuwela esilabhini sokugcina

Izabizwana:

Mina/Singowami; Wena/Ungowakho; Wami/Wethu - Wethu; Yena/Yena/Bona - Omunye; Lokho - Lokho; Lokhu ngu-Poto

Iinhlanganisela ngelimi:

Ukuhlanganisa - ukuphela; ukuhlukanisa - nofana; ukuphikisana - od

Izandulela ngelimi:

C - C; V - F; Na - Yena; Ukusuka - aas; Ngaphakathi kunedorhodera; Ob - Omncani; nangabe - nangabe

Inomboro:

1 - Uno

2 - Hoero

3 - Guravo

4 - Foro

5 - Vo

6 - Lio

7 - Simo

8 - Ukuthembela

9 - Uto

10 - I-Deco

100 - Sauo

1000 - Miango

10000 - Tumeno

Lokhu okulandelako kwakhiwa ngendlela elandelako:

Dekouto (11) Dekohoero (12)

Sauouto (11) Sauodekohero (113)

Iinkulungwana ezimatjhumi amabili - i-Choero Deco

Iinkulungwana ezimatjhumi amabili nekhulu netjhumi nanye - hoero-deco-sauodekohero

I-ABC (i-Cyrillic)

A - Az

B - Yiba

B - Ve

G - Ge

D - Tao

YENA

YENA

F - Okufanako

Z - Ze

Begodu - Begodu

Y - Ye

K - Ke

M - Mo

N - Ngo

O - Ly

P - Pe

R - Rus

S - Sy

T - Tib

U - U

F - Fita

X - Heh

C - Qin

Ch - Che

Sh - Sh

Shch - Shch

I-Kommersant - Er

Y - Ery

L - Er

E - E

Yu - Yu

Imithetho yeLimi:

Amabizo aneziphetho ezithi &quot;ym&quot; (ikhaya, isipho, kahle)

Ubunengi budalwa ngokuphetha, isiphetho esithi “begodu” sisetjenziswa

(amabutho - amabutho, amakati - amakati)

Iimpawu ziphela ngo &quot;ai&quot;.

(Muhle, isidlhayela, umusa, omkhulu) izinga lokumadanisa lenziwa ngokungezelela igama lesibonisi esithi “bolsha”: “Nastyayim muhle, omkhulu Natashaym” - ukumadanisa nophezulu - “Nastyayim super-beautiful”

Izenzo zineenphetho

&quot;umkhumbulo&quot;

Ukwakha (ukwakha)

Isikhathi esizako sakhiwa ngokungezelela isiqalo esithi &quot;by&quot;.

Pobildum (sizokwakha)

Isikhathi esidlulileko sakhiwa ngokufaka isiqalo esithi &quot;on&quot;.

I-Nabildum (iyakhiwa)

(Amakati ayizithutha khulu ekhaya - amakati ayizithutha khulu akha indlu)

Kuzwakala ngasuthi kutlolwe

Ukugandeleleka kuhlala kuwela esilabhini sokugcina

Izabizwana:

Mina/Singowami; Wena/Ungowakho; Wami/Wethu - Wethu; Yena/Yena/Bona - Omunye; Lokho - Lokho; Lokhu ngu-Poto

Iinhlanganisela ngelimi:

Ukuhlanganisa - ukuphela; ukuhlukanisa - nofana; ukuphikisana - od

Izandulela ngelimi:

C - C; V - F; Na - Yena; Ukusuka - aas; Ngaphakathi kunedorhodera; Ob - Omncani; nangabe - nangabe

Inomboro:

1 - Uno

2 - Hoero

3 - Guravo

4 - Foro

5 - Vo

6 - Lio

7 - Simo

8 - Ukuthembela

9 - Uto

10 - I-Deco

100 - Sauo

1000 - Miango

10000 - Tumeno

Lokhu okulandelako kwakhiwa ngendlela elandelako:

Dekouto (11) Dekohoero (12)

Sauouto (11) Sauodekohero (113)

Iinkulungwana ezimatjhumi amabili - Choero Deco

Iinkulungwana ezimatjhumi amabili nekhulu netjhumi nanye - khoero-deco-sauodekohero

I-ABC (i-latinic) A B VG DEÉŹZ IY K M N O -P R S T YF HC ÇŞŚĴ U J</text>
      <sha1>jetbr7u6zsjzbqgclalpn7s41mcgfbf</sha1>
    </revision>
    <revision>
      <id>3022</id>
      <parentid>1912</parentid>
      <timestamp>2025-06-06T20:30:36Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>nuh uh</comment>
      <origin>3022</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3690" sha1="8ih929zxn5o5c9dqxy2p0qfie6whjdu" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.'''

= Ilimi le-Novokyakhtin =
'''Ilimi le-Novo Kyakhta lilimi lokwenziwa njengesilingo.'''

Imithetho yelimi:

Amabizo aneziphetho ezithi &quot;ym&quot; (ikhaya, isipho, kahle)

Ubunengi budalwa ngokuphetha, isiphetho esithi “begodu” sisetjenziswa

(amabutho - amabutho, amakati - amakati)

Iziphawulo ziphela ngo &quot;ai&quot;.

(Muhle, isidlhayela, umusa, omkhulu) izinga lokumadanisa lenziwa ngokungezelela igama lesibonisi esithi “bolsha”: “Nastyayim muhle, omkhulu Natashaym” - ukumadanisa nophezulu - “Nastyayim super-beautiful”

Izenzo zineenphetho

&quot;umkhumbulo&quot;

Ukwakha (ukwakha)

Isikhathi esizako sakhiwa ngokungezelela isiqalo esithi &quot;by&quot;.

Pobildum (sizokwakha)

Isikhathi esidlulileko sakhiwa ngokufaka isiqalo esithi &quot;on&quot;.

I-Nabildum (iyakhiwa)

(Amakati ayizithutha khulu ekhaya - amakati ayizithutha khulu akha indlu)

Kuzwakala ngasuthi kutlolwe

Ukugandeleleka kuhlala kuwela esilabhini sokugcina

Izabizwana:

Mina/Singowami; Wena/Ungowakho; Wami/Wethu - Wethu; Yena/Yena/Bona - Omunye; Lokho - Lokho; Lokhu ngu-Poto

Iinhlanganisela ngelimi:

Ukuhlanganisa - ukuphela; ukuhlukanisa - nofana; ukuphikisana - od

Izandulela ngelimi:

C - C; V - F; Na - Yena; Ukusuka - aas; Ngaphakathi kunedorhodera; Ob - Omncani; nangabe - nangabe

Inomboro:

1 - Uno

2 - Hoero

3 - Guravo

4 - Foro

5 - Vo

6 - Lio

7 - Simo

8 - Ukuthembela

9 - Uto

10 - I-Deco

100 - Sauo

1000 - Miango

10000 - Tumeno

Lokhu okulandelako kwakhiwa ngendlela elandelako:

Dekouto (11) Dekohoero (12)

Sauouto (11) Sauodekohero (113)

Iinkulungwana ezimatjhumi amabili - i-Choero Deco

Iinkulungwana ezimatjhumi amabili nekhulu netjhumi nanye - hoero-deco-sauodekohero

I-ABC (i-Cyrillic)

A - Az

B - Yiba

B - Ve

G - Ge

D - Tao

YENA

YENA

F - Okufanako

Z - Ze

Begodu - Begodu

Y - Ye

K - Ke

M - Mo

N - Ngo

O - Ly

P - Pe

R - Rus

S - Sy

T - Tib

U - U

F - Fita

X - Heh

C - Qin

Ch - Che

Sh - Sh

Shch - Shch

I-Kommersant - Er

Y - Ery

L - Er

E - E

Yu - Yu

Imithetho yeLimi:

Amabizo aneziphetho ezithi &quot;ym&quot; (ikhaya, isipho, kahle)

Ubunengi budalwa ngokuphetha, isiphetho esithi “begodu” sisetjenziswa

(amabutho - amabutho, amakati - amakati)

Iimpawu ziphela ngo &quot;ai&quot;.

(Muhle, isidlhayela, umusa, omkhulu) izinga lokumadanisa lenziwa ngokungezelela igama lesibonisi esithi “bolsha”: “Nastyayim muhle, omkhulu Natashaym” - ukumadanisa nophezulu - “Nastyayim super-beautiful”

Izenzo zineenphetho

&quot;umkhumbulo&quot;

Ukwakha (ukwakha)

Isikhathi esizako sakhiwa ngokungezelela isiqalo esithi &quot;by&quot;.

Pobildum (sizokwakha)

Isikhathi esidlulileko sakhiwa ngokufaka isiqalo esithi &quot;on&quot;.

I-Nabildum (iyakhiwa)

(Amakati ayizithutha khulu ekhaya - amakati ayizithutha khulu akha indlu)

Kuzwakala ngasuthi kutlolwe

Ukugandeleleka kuhlala kuwela esilabhini sokugcina

Izabizwana:

Mina/Singowami; Wena/Ungowakho; Wami/Wethu - Wethu; Yena/Yena/Bona - Omunye; Lokho - Lokho; Lokhu ngu-Poto

Iinhlanganisela ngelimi:

Ukuhlanganisa - ukuphela; ukuhlukanisa - nofana; ukuphikisana - od

Izandulela ngelimi:

C - C; V - F; Na - Yena; Ukusuka - aas; Ngaphakathi kunedorhodera; Ob - Omncani; nangabe - nangabe

Inomboro:

1 - Uno

2 - Hoero

3 - Guravo

4 - Foro

5 - Vo

6 - Lio

7 - Simo

8 - Ukuthembela

9 - Uto

10 - I-Deco

100 - Sauo

1000 - Miango

10000 - Tumeno

Lokhu okulandelako kwakhiwa ngendlela elandelako:

Dekouto (11) Dekohoero (12)

Sauouto (11) Sauodekohero (113)

Iinkulungwana ezimatjhumi amabili - Choero Deco

Iinkulungwana ezimatjhumi amabili nekhulu netjhumi nanye - khoero-deco-sauodekohero

I-ABC (i-latinic) A B VG DEÉŹZ IY K M N O -P R S T YF HC ÇŞŚĴ U J</text>
      <sha1>8ih929zxn5o5c9dqxy2p0qfie6whjdu</sha1>
    </revision>
    <revision>
      <id>3039</id>
      <parentid>3022</parentid>
      <timestamp>2025-06-07T03:05:22Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:MikitkoSynAlexeev|MikitkoSynAlexeev]]</comment>
      <origin>1912</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3602" sha1="jetbr7u6zsjzbqgclalpn7s41mcgfbf" xml:space="preserve">= Ilimi le-Novokyakhtin =
'''Ilimi le-Novo Kyakhta lilimi lokwenziwa njengesilingo.'''

Imithetho yelimi:

Amabizo aneziphetho ezithi &quot;ym&quot; (ikhaya, isipho, kahle)

Ubunengi budalwa ngokuphetha, isiphetho esithi “begodu” sisetjenziswa

(amabutho - amabutho, amakati - amakati)

Iziphawulo ziphela ngo &quot;ai&quot;.

(Muhle, isidlhayela, umusa, omkhulu) izinga lokumadanisa lenziwa ngokungezelela igama lesibonisi esithi “bolsha”: “Nastyayim muhle, omkhulu Natashaym” - ukumadanisa nophezulu - “Nastyayim super-beautiful”

Izenzo zineenphetho

&quot;umkhumbulo&quot;

Ukwakha (ukwakha)

Isikhathi esizako sakhiwa ngokungezelela isiqalo esithi &quot;by&quot;.

Pobildum (sizokwakha)

Isikhathi esidlulileko sakhiwa ngokufaka isiqalo esithi &quot;on&quot;.

I-Nabildum (iyakhiwa)

(Amakati ayizithutha khulu ekhaya - amakati ayizithutha khulu akha indlu)

Kuzwakala ngasuthi kutlolwe

Ukugandeleleka kuhlala kuwela esilabhini sokugcina

Izabizwana:

Mina/Singowami; Wena/Ungowakho; Wami/Wethu - Wethu; Yena/Yena/Bona - Omunye; Lokho - Lokho; Lokhu ngu-Poto

Iinhlanganisela ngelimi:

Ukuhlanganisa - ukuphela; ukuhlukanisa - nofana; ukuphikisana - od

Izandulela ngelimi:

C - C; V - F; Na - Yena; Ukusuka - aas; Ngaphakathi kunedorhodera; Ob - Omncani; nangabe - nangabe

Inomboro:

1 - Uno

2 - Hoero

3 - Guravo

4 - Foro

5 - Vo

6 - Lio

7 - Simo

8 - Ukuthembela

9 - Uto

10 - I-Deco

100 - Sauo

1000 - Miango

10000 - Tumeno

Lokhu okulandelako kwakhiwa ngendlela elandelako:

Dekouto (11) Dekohoero (12)

Sauouto (11) Sauodekohero (113)

Iinkulungwana ezimatjhumi amabili - i-Choero Deco

Iinkulungwana ezimatjhumi amabili nekhulu netjhumi nanye - hoero-deco-sauodekohero

I-ABC (i-Cyrillic)

A - Az

B - Yiba

B - Ve

G - Ge

D - Tao

YENA

YENA

F - Okufanako

Z - Ze

Begodu - Begodu

Y - Ye

K - Ke

M - Mo

N - Ngo

O - Ly

P - Pe

R - Rus

S - Sy

T - Tib

U - U

F - Fita

X - Heh

C - Qin

Ch - Che

Sh - Sh

Shch - Shch

I-Kommersant - Er

Y - Ery

L - Er

E - E

Yu - Yu

Imithetho yeLimi:

Amabizo aneziphetho ezithi &quot;ym&quot; (ikhaya, isipho, kahle)

Ubunengi budalwa ngokuphetha, isiphetho esithi “begodu” sisetjenziswa

(amabutho - amabutho, amakati - amakati)

Iimpawu ziphela ngo &quot;ai&quot;.

(Muhle, isidlhayela, umusa, omkhulu) izinga lokumadanisa lenziwa ngokungezelela igama lesibonisi esithi “bolsha”: “Nastyayim muhle, omkhulu Natashaym” - ukumadanisa nophezulu - “Nastyayim super-beautiful”

Izenzo zineenphetho

&quot;umkhumbulo&quot;

Ukwakha (ukwakha)

Isikhathi esizako sakhiwa ngokungezelela isiqalo esithi &quot;by&quot;.

Pobildum (sizokwakha)

Isikhathi esidlulileko sakhiwa ngokufaka isiqalo esithi &quot;on&quot;.

I-Nabildum (iyakhiwa)

(Amakati ayizithutha khulu ekhaya - amakati ayizithutha khulu akha indlu)

Kuzwakala ngasuthi kutlolwe

Ukugandeleleka kuhlala kuwela esilabhini sokugcina

Izabizwana:

Mina/Singowami; Wena/Ungowakho; Wami/Wethu - Wethu; Yena/Yena/Bona - Omunye; Lokho - Lokho; Lokhu ngu-Poto

Iinhlanganisela ngelimi:

Ukuhlanganisa - ukuphela; ukuhlukanisa - nofana; ukuphikisana - od

Izandulela ngelimi:

C - C; V - F; Na - Yena; Ukusuka - aas; Ngaphakathi kunedorhodera; Ob - Omncani; nangabe - nangabe

Inomboro:

1 - Uno

2 - Hoero

3 - Guravo

4 - Foro

5 - Vo

6 - Lio

7 - Simo

8 - Ukuthembela

9 - Uto

10 - I-Deco

100 - Sauo

1000 - Miango

10000 - Tumeno

Lokhu okulandelako kwakhiwa ngendlela elandelako:

Dekouto (11) Dekohoero (12)

Sauouto (11) Sauodekohero (113)

Iinkulungwana ezimatjhumi amabili - Choero Deco

Iinkulungwana ezimatjhumi amabili nekhulu netjhumi nanye - khoero-deco-sauodekohero

I-ABC (i-latinic) A B VG DEÉŹZ IY K M N O -P R S T YF HC ÇŞŚĴ U J</text>
      <sha1>jetbr7u6zsjzbqgclalpn7s41mcgfbf</sha1>
    </revision>
  </page>
  <page>
    <title>U-Magdalena Christina we-Manderscheid-Blankenheim, u-Countess we-Sayn-Wittgenstein-Hachenburg</title>
    <ns>0</ns>
    <id>367</id>
    <revision>
      <id>1916</id>
      <timestamp>2024-11-15T21:12:39Z</timestamp>
      <contributor>
        <username>Pe Class Heroes010210</username>
        <id>174</id>
      </contributor>
      <comment>Created page with &quot;'''U-Magdalena Christina von Manderscheid-Blankenheim''' (15 kuNtaka 1658-19 kuMgwengweni 1715) bekangumfazi wesikhulu we-German ne-Countess ye-Sayn-Wittgenstein-Hachenburg hlangana no-1661 ukuya ku-1715. Watjhada nomfowabo u-Maximilian Joseph Ferdinand bekwaba ngu-1675 bese waba ngumbusi oyedwa.&lt;ref&gt;Vera Torunsky (Bearb.): ''Die Manderscheider. Eine Eifeler Adelsfamilie. Herrschaft, Wirtschaft, Kultur''. Rheinland-Verlag, Pulheim 1990, ISBN 3-7927-1152-4.&lt;/ref&gt;&lt;ref&gt;{{ci...&quot;</comment>
      <origin>1916</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2912" sha1="j2nzi6pohulwzlhld4u0yla4ex6ktyb" xml:space="preserve">'''U-Magdalena Christina von Manderscheid-Blankenheim''' (15 kuNtaka 1658-19 kuMgwengweni 1715) bekangumfazi wesikhulu we-German ne-Countess ye-Sayn-Wittgenstein-Hachenburg hlangana no-1661 ukuya ku-1715. Watjhada nomfowabo u-Maximilian Joseph Ferdinand bekwaba ngu-1675 bese waba ngumbusi oyedwa.&lt;ref&gt;Vera Torunsky (Bearb.): ''Die Manderscheider. Eine Eifeler Adelsfamilie. Herrschaft, Wirtschaft, Kultur''. Rheinland-Verlag, Pulheim 1990, ISBN 3-7927-1152-4.&lt;/ref&gt;&lt;ref&gt;{{cite web|last=Marek|first=Miroslav|url=http://genealogy.euweb.cz/sponheim/sponh11.html|title=Genealogy of the House of Sponheim (Sayn branch)|publisher=genealogy.euweb.cz|accessdate=27 September 2014}}&lt;/ref&gt;
==Ipilo/Ukubusa==
Watjhada belethwa 1658 njengomntwana wesihlanu ka-Countess Ernestine Salentine. watjhada ekufeni kwakhe ngo-1661 eceleni komfowabo. Umfowabo wahlongakala ngo-1675 ngaphandle kweendlalifa kungakho wabusa njengekosi yedwa ngemva kwalokho.&lt;ref&gt;[http://wwperson.informatik.uni-erlangen.de/cgi-bin/l1/LANG=engl/INDEX=I408858 ''Ernestina Salentina Gräfin zu Sayn u. Wittgenstein'' in: Genealogy Database by Herbert Stoyan] {{Webarchive|url=https://web.archive.org/web/20150206055153/http://wwperson.informatik.uni-erlangen.de/cgi-bin/l1/LANG=engl/INDEX=I408858|date=2015-02-06}} [retrieved 29 October 2024].&lt;/ref&gt;&lt;ref&gt;Matthias Dahlhoff: ''Geschichte der Grafschaft Sayn.'', Dillenburg 1874.&lt;/ref&gt;
==Abantwana==

Njengomkakhe wesibili, mhlazi-7 kuNobayeni 1673 watjhada no-George Louis, u-Burgrave we-Kirchberg (1626-1686) obekamdala kuye ngeminyaka ema-32. Babe nabantwana abalandelako emtjhadweni wabo: 
* George Louis Ernest (1675 – 1676) 
* Ernest Augustus Louis († 1695) 
* Johannetta Friederika 
* Wilhelmina Louisa 
* Elizabeth Dorothea 
* Christina Magdalena (mhlamunye uqanjwe ngegama lakhe) 
* George Frederick (1683 – 1749), u-Burgrave we-Kirchberg ne-Hachenburg, watjhada no-Sophia Isabel de Limburg begodu mhlana ali-9 kuMrhayili 1708 no-Countess Sophia Amalia von Nassau-Saarbrücken (1688 – 1753), indodakazi ka-Count Frederick of Louis Nassau-Nailer (Otweer 1651 – 1728); Wathatha isikhundla sikaMama wakhe njengeKosi ngemva kokuhlongakala kwakhe ngo-1715. * Wilhelmina Christina 
* U-John Albert (1685 – 1691) 
* Ernestina Carolina (1687 – 1776); wabelethwa ngemva kokuhlongakala ngemva kokuhlongakala kwakayise ngomnyaka ophelileko.

Ngokukhamba kwesikhathi wahlongakala ngo-1715 aneminyaka ema-57 begodu bekangunina wabantwana abali-10.&lt;ref&gt;{{Cite web|title=Magdalene Christina, Gräfin von Manderscheid-Blankenheim : Genealogics|url=https://www.genealogics.org/getperson.php?personID=I00021207&amp;tree=LEO|access-date=2024-10-29|website=www.genealogics.org}}&lt;/ref&gt;&lt;ref&gt;{{Cite web|title=Georg Ludwig, Burggraf von Kirchberg, * 1626 {{!}} Geneall.net|url=https://geneall.net/de/name/196703/georg-ludwig-burggraf-von-kirchberg/|access-date=2024-10-29|website=geneall.net}}&lt;/ref&gt;
==Iinkomba==</text>
      <sha1>j2nzi6pohulwzlhld4u0yla4ex6ktyb</sha1>
    </revision>
    <revision>
      <id>2147</id>
      <parentid>1916</parentid>
      <timestamp>2024-11-25T18:31:05Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* Iinkomba */Reflist</comment>
      <origin>2147</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2926" sha1="pwq4hf4xln4kaiyz59wg4sapru7tv6j" xml:space="preserve">'''U-Magdalena Christina von Manderscheid-Blankenheim''' (15 kuNtaka 1658-19 kuMgwengweni 1715) bekangumfazi wesikhulu we-German ne-Countess ye-Sayn-Wittgenstein-Hachenburg hlangana no-1661 ukuya ku-1715. Watjhada nomfowabo u-Maximilian Joseph Ferdinand bekwaba ngu-1675 bese waba ngumbusi oyedwa.&lt;ref&gt;Vera Torunsky (Bearb.): ''Die Manderscheider. Eine Eifeler Adelsfamilie. Herrschaft, Wirtschaft, Kultur''. Rheinland-Verlag, Pulheim 1990, ISBN 3-7927-1152-4.&lt;/ref&gt;&lt;ref&gt;{{cite web|last=Marek|first=Miroslav|url=http://genealogy.euweb.cz/sponheim/sponh11.html|title=Genealogy of the House of Sponheim (Sayn branch)|publisher=genealogy.euweb.cz|accessdate=27 September 2014}}&lt;/ref&gt;
==Ipilo/Ukubusa==
Watjhada belethwa 1658 njengomntwana wesihlanu ka-Countess Ernestine Salentine. watjhada ekufeni kwakhe ngo-1661 eceleni komfowabo. Umfowabo wahlongakala ngo-1675 ngaphandle kweendlalifa kungakho wabusa njengekosi yedwa ngemva kwalokho.&lt;ref&gt;[http://wwperson.informatik.uni-erlangen.de/cgi-bin/l1/LANG=engl/INDEX=I408858 ''Ernestina Salentina Gräfin zu Sayn u. Wittgenstein'' in: Genealogy Database by Herbert Stoyan] {{Webarchive|url=https://web.archive.org/web/20150206055153/http://wwperson.informatik.uni-erlangen.de/cgi-bin/l1/LANG=engl/INDEX=I408858|date=2015-02-06}} [retrieved 29 October 2024].&lt;/ref&gt;&lt;ref&gt;Matthias Dahlhoff: ''Geschichte der Grafschaft Sayn.'', Dillenburg 1874.&lt;/ref&gt;
==Abantwana==

Njengomkakhe wesibili, mhlazi-7 kuNobayeni 1673 watjhada no-George Louis, u-Burgrave we-Kirchberg (1626-1686) obekamdala kuye ngeminyaka ema-32. Babe nabantwana abalandelako emtjhadweni wabo: 
* George Louis Ernest (1675 – 1676) 
* Ernest Augustus Louis († 1695) 
* Johannetta Friederika 
* Wilhelmina Louisa 
* Elizabeth Dorothea 
* Christina Magdalena (mhlamunye uqanjwe ngegama lakhe) 
* George Frederick (1683 – 1749), u-Burgrave we-Kirchberg ne-Hachenburg, watjhada no-Sophia Isabel de Limburg begodu mhlana ali-9 kuMrhayili 1708 no-Countess Sophia Amalia von Nassau-Saarbrücken (1688 – 1753), indodakazi ka-Count Frederick of Louis Nassau-Nailer (Otweer 1651 – 1728); Wathatha isikhundla sikaMama wakhe njengeKosi ngemva kokuhlongakala kwakhe ngo-1715. * Wilhelmina Christina 
* U-John Albert (1685 – 1691) 
* Ernestina Carolina (1687 – 1776); wabelethwa ngemva kokuhlongakala ngemva kokuhlongakala kwakayise ngomnyaka ophelileko.

Ngokukhamba kwesikhathi wahlongakala ngo-1715 aneminyaka ema-57 begodu bekangunina wabantwana abali-10.&lt;ref&gt;{{Cite web|title=Magdalene Christina, Gräfin von Manderscheid-Blankenheim : Genealogics|url=https://www.genealogics.org/getperson.php?personID=I00021207&amp;tree=LEO|access-date=2024-10-29|website=www.genealogics.org}}&lt;/ref&gt;&lt;ref&gt;{{Cite web|title=Georg Ludwig, Burggraf von Kirchberg, * 1626 {{!}} Geneall.net|url=https://geneall.net/de/name/196703/georg-ludwig-burggraf-von-kirchberg/|access-date=2024-10-29|website=geneall.net}}&lt;/ref&gt;
== Iinkomba ==
{{Reflist}}</text>
      <sha1>pwq4hf4xln4kaiyz59wg4sapru7tv6j</sha1>
    </revision>
  </page>
  <page>
    <title>Umgomani weZika</title>
    <ns>0</ns>
    <id>368</id>
    <revision>
      <id>1919</id>
      <timestamp>2016-10-01T06:29:30Z</timestamp>
      <contributor>
        <username>incubator&gt;Ian Henderson</username>
        <id>0</id>
      </contributor>
      <comment>Created</comment>
      <origin>1919</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7556" sha1="ay0ygfbswqybq3kg0cj4xol4jopgif2" xml:space="preserve">{{Infobox disease
|Name           = Umgomani weZika
|Image          = Alexius Salvador Zika-Virus.jpg
|Caption        = Iratjhi ngesikhathi kutheleleke umgomani weZika
|Field          = [[Infectious disease (medical specialty)|Infectious disease]]
|pronunciation  = Zika {{IPAc-en|ˈ|z|iː|k|ə}}
|ICD10          = {{ICD10|U|06|9|a|}}, code change from 21 December 2015
|ICD9           = {{ICD9|066.3}}
|DiseasesDB     =36480
|MedlinePlus    =007666
|eMedicineSubj  =
|eMedicineTopic =
|MeSH       =D000071243
}}
&lt;!-- Definition and symptoms --&gt;
'''Umgomani weZika''' (owaziwa godu'''ngomulwana weZika''') bulwelwe[[obubangwa mumulwana iZika]].&lt;ref name=&quot;WHO2016Jan&quot;&gt;{{cite web | url=http://www.who.int/mediacentre/factsheets/zika/en/ | title=Zika virus | publisher=World Health Organization | date=January 2016 | accessdate=3 February 2016}}&lt;/ref&gt;Esikhathini esinengi izehlakalo ezibikwako azinawo amatshwayo wokugula, kodwana nangabe akhona kuzwakala ukufuthumala[[ nomgomani womzimba obuhlungu]].&lt;ref name=&quot;WHO2016Jan&quot; /&gt;&lt;ref name=&quot;ecdc1&quot;&gt;{{cite web | url=http://ecdc.europa.eu/en/healthtopics/zika_virus_infection/factsheet-health-professionals/Pages/factsheet_health_professionals.aspx | title=Factsheet for health professionals | publisher=European Centre for Disease Prevention and Control | work=Zika virus infection | accessdate=22 December 2015}}&lt;/ref&gt; Amatshwayo angafaka hlangana[[umgomani nehloko ebuhlungu]],[[ amehlo |abovu]],[[i-arthralgia| ubuhlungu balapha kuhlangana khona amathambo]]ihloko esawula kabuhlungu, kanye[[neratjhi elumako]].&lt;ref name=WHO2016Jan/&gt;&lt;ref name=Ann2016/&gt;&lt;ref name=&quot;Musso14&quot;&gt;{{cite journal | url=http://linkinghub.elsevier.com/retrieve/pii/S1198743X1465391X | title=Rapid spread of emerging Zika virus in the Pacific area | last=Musso | first=D. | last2=Nilles | first2=E.J. | last3=Cao-Lormeau | first3=V.-M. | journal=Clinical Microbiology and Infection | year=2014 | volume=20 | issue=10 | pages=O595–6 | doi=10.1111/1469-0691.12707 | pmid=24909208}}&lt;/ref&gt; Amatshwayo la abonala amalanga angaphasi kwalikhomba.&lt;ref name=Ann2016/&gt; Akhange bubange ukufa komuntu lokha nakasathoma ukubonakala.&lt;ref name=&quot;ecdc1&quot;/&gt;Ubulwelwe lobu buhlotjaniswe[[ne-Guillain–Barré syndrom]] (GBS0.&lt;ref name=&quot;ecdc1&quot;/&gt; 

&lt;!-- Cause and diagnosis --&gt;
Umgomani weZika usabalaliseka nofana utheleleka ngokulunywa[[ ngunompopoloza]]womhlobo''[[i-Aedes]]''okhethekileko.&lt;ref name=Ann2016/&gt;Ungatheleleka [[godu ngokuya emsemeni|ukuya emsemeni]]ukusuka endodeni ukuya kiloyo alala naye[[bese ubulwelwe lobu bungatheleleka ngokungenelana kweengaz]]i. &lt;ref name=CDC2016&gt;{{cite journal|last1=Oster|first1=Alexandra M.|last2=Russell|first2=Kate|last3=Stryker|first3=Jo Ellen|last4=Friedman|first4=Allison|last5=Kachur|first5=Rachel E.|last6=Petersen|first6=Emily E.|last7=Jamieson|first7=Denise J.|last8=Cohn|first8=Amanda C.|last9=Brooks|first9=John T.|title=Update: Interim Guidance for Prevention of Sexual Transmission of Zika Virus — United States, 2016|journal=MMWR. Morbidity and Mortality Weekly Report|date=1 April 2016|volume=65|issue=12|pages=323–325|doi=10.15585/mmwr.mm6512e3|pmid = 27032078}}&lt;/ref&gt;&lt;ref name=Ann2016/&gt; Ukutheleleka kilabo abafazi abasidisi abazithweleko kungatheleleka nemntwaneni[[ngombana khekwahlotjaniswa]]nokufoloza ukuhlongakala kwabantwana bangakabelethwa[[ kanye nokubelethwa kwabantwana abaneenhloko ezincani ngokungakajayeki]].&lt;ref name=WHO2016Jan/&gt;&lt;ref name=&quot;ChanChoi2016&quot;&gt;{{cite journal | first1=Jasper F.W. | last1=Chan | url=https://www.ncbi.nlm.nih.gov/pubmed/26940504 | title=Zika fever and congenital Zika syndrome: An unexpected emerging arboviral disease | last2=Choi | first2=Garnet K.Y. | last3=Yip | first3=Cyril C.Y. | last4=Cheng | first4=Vincent C.C. | last5=Yuen | first5=Kwok-Yung | journal=Journal of Infection | year=2016 | issn=01634453 | doi=10.1016/j.jinf.2016.02.011 | pmid=26940504 | display-authors=3}}&lt;/ref&gt; Ukutholwa komrabho wobulwelwe lobu kwenziwa ngokuhlola igazi, umthondo, nofana amathe kuqalwe ubukhona bomgomani i-Zika[[RNA]] lokha umuntu nakagulako.&lt;ref name=WHO2016Jan/&gt;&lt;ref name=Ann2016/&gt;

&lt;!-- Prevention and treatment --&gt;
Ukukhandela ubulwelwe lobu kufaka hlangana ukwehlisa ukuba khona kwabonompopoloza abalumako eendaweni lapha badlange khona kanye nokusebenzisa ikhpndomu nawuya emsemeni.&lt;ref name=&quot;Ann2016&quot;&gt;{{cite journal | first1=Lin H. | last1=Chen | url=http://annals.org/article.aspx?articleid=2486362 | title=Zika Virus: Rapid Spread in the Western Hemisphere | last2=Hamer | first2=Davidson H. | journal=Annals of Internal Medicine | year=2016 | issn=0003-4819 | doi=10.7326/M16-0150}}&lt;/ref&gt;&lt;ref name=CDC2016/&gt; Imizamo yokwehlisa ukulunywa kufaka hlangana[[nokusebenzisa iinhlanhla ezibulala iinunwana]] ukuvala umzimba wakho ngezambatho[[ iinhlanhla ezibulala abonompopoloza]], nokususa amazni ajamileko angakhambiko lapha abonompopoloza bangathola khona ithuba lokwanda.&lt;ref name=WHO2016Jan/&gt; Aasikho isihlahla[[nofana imijovo esebenza ukulapha ubulwelobu]].&lt;ref name=Ann2016/&gt; Abasebezi bezamaphilo banyule ukuthi abafazi abahlala lapho kudlange khona ubulwelwe bomgomani weZika[[bomgomani weZika (2015–bekube nje)|2015-16 ukuqubuka kobulwelwe bomgomani iZika]] bathathe isiqunto sokobana bangabi nabantwana begodu abafazi abasidisi bangayi eendaweni lapaha kudlange ubulwelwe lobu.&lt;ref name=Ann2016/&gt;&lt;ref name=&quot;cnn1&quot;&gt;{{cite news | url=http://www.cnn.com/2015/12/23/health/brazil-zika-pregnancy-warning/index.html | title=Brazil warns against pregnancy due to spreading virus | work=CNN | date=24 December 2015 | accessdate=24 December 2015}}&lt;/ref&gt; Njengombana akunasihlahla sokulapha ubulwelwe lobu,[[ amapeli wehlono neenhlungu i-paracetamol]]i- (acetaminophen) zingasiza lokha nawubona amatshwayo wobulwelobu.&lt;ref name=Ann2016/&gt; Ukuyokungeniswa esibhedlela akukavami.&lt;ref name=&quot;ecdc1&quot;/&gt; 

&lt;!-- History and epidemiology --&gt;
Umulwana obanga ubulwelwe lobu watholakala ngo-1947.&lt;ref name=&quot;OlsonHaddow2012&quot;&gt;{{cite journal | display-authors=3 | first1=Ken E. | first10=Scott C. | first3=Amy J. | first7=Rekol | last1=Olson | last10=Weaver | title=Genetic Characterization of Zika Virus Strains: Geographic Expansion of the Asian Lineage | last2=Haddow | first2=Andrew D. | last3=Schuh | last4=Yasuda | first4=Chadwick Y. | last5=Kasper | first5=Matthew R. | last6=Heang | first6=Vireak | last7=Huy | last8=Guzman | first8=Hilda | last9=Tesh | first9=Robert B. | journal=PLoS Neglected Tropical Diseases | year=2012 | volume=6 | issue=2 | pages=e1477 | issn=1935-2735 | doi=10.1371/journal.pntd.0001477 | pmid=22389730 | pmc=3289602}}&lt;/ref&gt; Ukutholaka kokuthoma kokuqubuka kobulwelwe lobu kwavela ngo-2007 [[e-Federated States ye- Micronesia]].&lt;ref name=Ann2016/&gt; {{Ukusukela|ngoTjhirhweni 2016}}ubulwelwe lobu buqubuke eengodini ezimatjhumi amabili[[nge-Amerikha]].&lt;ref name=Ann2016/&gt; Kuthiwa buqubuke ne-Afrika, e-Asia kanye ne-Pacific.&lt;ref name=WHO2016Jan/&gt; Ngesibanga sokuqubuka kwabo ubulwelobu eBrazil ngo2015,i[[World Health Oeganization]]iikhiphe umbiko orhabako[[ngobungozi obukhna Emphakathini keZamaphilo eenTjhabatjhabeni zoke]] ngenyaka kaMhlolanja 2016.&lt;ref name=&quot;who1&quot;&gt;{{cite web | url=http://www.who.int/mediacentre/news/statements/2016/emergency-committee-zika-microcephaly/en/ | title=WHO Director-General summarizes the outcome of the Emergency Committee regarding clusters of microcephaly and Guillain-Barré syndrome | work=Media Centre | publisher=World Health Organization | date=1 February 2016 | accessdate=3 February 2016}}&lt;/ref&gt;

==Isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini==
&lt;references /&gt;</text>
      <sha1>ay0ygfbswqybq3kg0cj4xol4jopgif2</sha1>
    </revision>
    <revision>
      <id>1920</id>
      <parentid>1919</parentid>
      <timestamp>2016-11-04T12:28:29Z</timestamp>
      <contributor>
        <username>incubator&gt;Doc James</username>
        <id>0</id>
      </contributor>
      <origin>1920</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7562" sha1="izu9uk55mdhj4z5scg63blbjeqsb8rp" xml:space="preserve">{{Wp/nd/Infobox disease
|name           = Umgomani weZika
|image          = Alexius Salvador Zika-Virus.jpg
|caption        = Iratjhi ngesikhathi kutheleleke umgomani weZika
|Field          = [[Infectious disease (medical specialty)|Infectious disease]]
|pronunciation  = Zika {{IPAc-en|ˈ|z|iː|k|ə}}
|ICD10          = {{ICD10|U|06|9|a|}}, code change from 21 December 2015
|ICD9           = {{ICD9|066.3}}
|DiseasesDB     =36480
|MedlinePlus    =007666
|eMedicineSubj  =
|eMedicineTopic =
|MeSH       =D000071243
}}
&lt;!-- Definition and symptoms --&gt;
'''Umgomani weZika''' (owaziwa godu'''ngomulwana weZika''') bulwelwe[[obubangwa mumulwana iZika]].&lt;ref name=&quot;WHO2016Jan&quot;&gt;{{cite web | url=http://www.who.int/mediacentre/factsheets/zika/en/ | title=Zika virus | publisher=World Health Organization | date=January 2016 | accessdate=3 February 2016}}&lt;/ref&gt;Esikhathini esinengi izehlakalo ezibikwako azinawo amatshwayo wokugula, kodwana nangabe akhona kuzwakala ukufuthumala[[ nomgomani womzimba obuhlungu]].&lt;ref name=&quot;WHO2016Jan&quot; /&gt;&lt;ref name=&quot;ecdc1&quot;&gt;{{cite web | url=http://ecdc.europa.eu/en/healthtopics/zika_virus_infection/factsheet-health-professionals/Pages/factsheet_health_professionals.aspx | title=Factsheet for health professionals | publisher=European Centre for Disease Prevention and Control | work=Zika virus infection | accessdate=22 December 2015}}&lt;/ref&gt; Amatshwayo angafaka hlangana[[umgomani nehloko ebuhlungu]],[[ amehlo |abovu]],[[i-arthralgia| ubuhlungu balapha kuhlangana khona amathambo]]ihloko esawula kabuhlungu, kanye[[neratjhi elumako]].&lt;ref name=WHO2016Jan/&gt;&lt;ref name=Ann2016/&gt;&lt;ref name=&quot;Musso14&quot;&gt;{{cite journal | url=http://linkinghub.elsevier.com/retrieve/pii/S1198743X1465391X | title=Rapid spread of emerging Zika virus in the Pacific area | last=Musso | first=D. | last2=Nilles | first2=E.J. | last3=Cao-Lormeau | first3=V.-M. | journal=Clinical Microbiology and Infection | year=2014 | volume=20 | issue=10 | pages=O595–6 | doi=10.1111/1469-0691.12707 | pmid=24909208}}&lt;/ref&gt; Amatshwayo la abonala amalanga angaphasi kwalikhomba.&lt;ref name=Ann2016/&gt; Akhange bubange ukufa komuntu lokha nakasathoma ukubonakala.&lt;ref name=&quot;ecdc1&quot;/&gt;Ubulwelwe lobu buhlotjaniswe[[ne-Guillain–Barré syndrom]] (GBS0.&lt;ref name=&quot;ecdc1&quot;/&gt; 

&lt;!-- Cause and diagnosis --&gt;
Umgomani weZika usabalaliseka nofana utheleleka ngokulunywa[[ ngunompopoloza]]womhlobo''[[i-Aedes]]''okhethekileko.&lt;ref name=Ann2016/&gt;Ungatheleleka [[godu ngokuya emsemeni|ukuya emsemeni]]ukusuka endodeni ukuya kiloyo alala naye[[bese ubulwelwe lobu bungatheleleka ngokungenelana kweengaz]]i. &lt;ref name=CDC2016&gt;{{cite journal|last1=Oster|first1=Alexandra M.|last2=Russell|first2=Kate|last3=Stryker|first3=Jo Ellen|last4=Friedman|first4=Allison|last5=Kachur|first5=Rachel E.|last6=Petersen|first6=Emily E.|last7=Jamieson|first7=Denise J.|last8=Cohn|first8=Amanda C.|last9=Brooks|first9=John T.|title=Update: Interim Guidance for Prevention of Sexual Transmission of Zika Virus — United States, 2016|journal=MMWR. Morbidity and Mortality Weekly Report|date=1 April 2016|volume=65|issue=12|pages=323–325|doi=10.15585/mmwr.mm6512e3|pmid = 27032078}}&lt;/ref&gt;&lt;ref name=Ann2016/&gt; Ukutheleleka kilabo abafazi abasidisi abazithweleko kungatheleleka nemntwaneni[[ngombana khekwahlotjaniswa]]nokufoloza ukuhlongakala kwabantwana bangakabelethwa[[ kanye nokubelethwa kwabantwana abaneenhloko ezincani ngokungakajayeki]].&lt;ref name=WHO2016Jan/&gt;&lt;ref name=&quot;ChanChoi2016&quot;&gt;{{cite journal | first1=Jasper F.W. | last1=Chan | url=https://www.ncbi.nlm.nih.gov/pubmed/26940504 | title=Zika fever and congenital Zika syndrome: An unexpected emerging arboviral disease | last2=Choi | first2=Garnet K.Y. | last3=Yip | first3=Cyril C.Y. | last4=Cheng | first4=Vincent C.C. | last5=Yuen | first5=Kwok-Yung | journal=Journal of Infection | year=2016 | issn=01634453 | doi=10.1016/j.jinf.2016.02.011 | pmid=26940504 | display-authors=3}}&lt;/ref&gt; Ukutholwa komrabho wobulwelwe lobu kwenziwa ngokuhlola igazi, umthondo, nofana amathe kuqalwe ubukhona bomgomani i-Zika[[RNA]] lokha umuntu nakagulako.&lt;ref name=WHO2016Jan/&gt;&lt;ref name=Ann2016/&gt;

&lt;!-- Prevention and treatment --&gt;
Ukukhandela ubulwelwe lobu kufaka hlangana ukwehlisa ukuba khona kwabonompopoloza abalumako eendaweni lapha badlange khona kanye nokusebenzisa ikhpndomu nawuya emsemeni.&lt;ref name=&quot;Ann2016&quot;&gt;{{cite journal | first1=Lin H. | last1=Chen | url=http://annals.org/article.aspx?articleid=2486362 | title=Zika Virus: Rapid Spread in the Western Hemisphere | last2=Hamer | first2=Davidson H. | journal=Annals of Internal Medicine | year=2016 | issn=0003-4819 | doi=10.7326/M16-0150}}&lt;/ref&gt;&lt;ref name=CDC2016/&gt; Imizamo yokwehlisa ukulunywa kufaka hlangana[[nokusebenzisa iinhlanhla ezibulala iinunwana]] ukuvala umzimba wakho ngezambatho[[ iinhlanhla ezibulala abonompopoloza]], nokususa amazni ajamileko angakhambiko lapha abonompopoloza bangathola khona ithuba lokwanda.&lt;ref name=WHO2016Jan/&gt; Aasikho isihlahla[[nofana imijovo esebenza ukulapha ubulwelobu]].&lt;ref name=Ann2016/&gt; Abasebezi bezamaphilo banyule ukuthi abafazi abahlala lapho kudlange khona ubulwelwe bomgomani weZika[[bomgomani weZika (2015–bekube nje)|2015-16 ukuqubuka kobulwelwe bomgomani iZika]] bathathe isiqunto sokobana bangabi nabantwana begodu abafazi abasidisi bangayi eendaweni lapaha kudlange ubulwelwe lobu.&lt;ref name=Ann2016/&gt;&lt;ref name=&quot;cnn1&quot;&gt;{{cite news | url=http://www.cnn.com/2015/12/23/health/brazil-zika-pregnancy-warning/index.html | title=Brazil warns against pregnancy due to spreading virus | work=CNN | date=24 December 2015 | accessdate=24 December 2015}}&lt;/ref&gt; Njengombana akunasihlahla sokulapha ubulwelwe lobu,[[ amapeli wehlono neenhlungu i-paracetamol]]i- (acetaminophen) zingasiza lokha nawubona amatshwayo wobulwelobu.&lt;ref name=Ann2016/&gt; Ukuyokungeniswa esibhedlela akukavami.&lt;ref name=&quot;ecdc1&quot;/&gt; 

&lt;!-- History and epidemiology --&gt;
Umulwana obanga ubulwelwe lobu watholakala ngo-1947.&lt;ref name=&quot;OlsonHaddow2012&quot;&gt;{{cite journal | display-authors=3 | first1=Ken E. | first10=Scott C. | first3=Amy J. | first7=Rekol | last1=Olson | last10=Weaver | title=Genetic Characterization of Zika Virus Strains: Geographic Expansion of the Asian Lineage | last2=Haddow | first2=Andrew D. | last3=Schuh | last4=Yasuda | first4=Chadwick Y. | last5=Kasper | first5=Matthew R. | last6=Heang | first6=Vireak | last7=Huy | last8=Guzman | first8=Hilda | last9=Tesh | first9=Robert B. | journal=PLoS Neglected Tropical Diseases | year=2012 | volume=6 | issue=2 | pages=e1477 | issn=1935-2735 | doi=10.1371/journal.pntd.0001477 | pmid=22389730 | pmc=3289602}}&lt;/ref&gt; Ukutholaka kokuthoma kokuqubuka kobulwelwe lobu kwavela ngo-2007 [[e-Federated States ye- Micronesia]].&lt;ref name=Ann2016/&gt; {{Ukusukela|ngoTjhirhweni 2016}}ubulwelwe lobu buqubuke eengodini ezimatjhumi amabili[[nge-Amerikha]].&lt;ref name=Ann2016/&gt; Kuthiwa buqubuke ne-Afrika, e-Asia kanye ne-Pacific.&lt;ref name=WHO2016Jan/&gt; Ngesibanga sokuqubuka kwabo ubulwelobu eBrazil ngo2015,i[[World Health Oeganization]]iikhiphe umbiko orhabako[[ngobungozi obukhna Emphakathini keZamaphilo eenTjhabatjhabeni zoke]] ngenyaka kaMhlolanja 2016.&lt;ref name=&quot;who1&quot;&gt;{{cite web | url=http://www.who.int/mediacentre/news/statements/2016/emergency-committee-zika-microcephaly/en/ | title=WHO Director-General summarizes the outcome of the Emergency Committee regarding clusters of microcephaly and Guillain-Barré syndrome | work=Media Centre | publisher=World Health Organization | date=1 February 2016 | accessdate=3 February 2016}}&lt;/ref&gt;

==Isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini==
&lt;references /&gt;</text>
      <sha1>izu9uk55mdhj4z5scg63blbjeqsb8rp</sha1>
    </revision>
    <revision>
      <id>1921</id>
      <parentid>1920</parentid>
      <timestamp>2016-11-04T12:28:45Z</timestamp>
      <contributor>
        <username>incubator&gt;Doc James</username>
        <id>0</id>
      </contributor>
      <origin>1921</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7498" sha1="i9fbbp8udcjbi2g8f3x5yzmouw498ms" xml:space="preserve">{{Wp/nd/Infobox disease
|name           = Umgomani weZika
|image          = Alexius Salvador Zika-Virus.jpg
|caption        = Iratjhi ngesikhathi kutheleleke umgomani weZika
|Field          = [[Infectious disease (medical specialty)|Infectious disease]]
|pronunciation  = Zika {{IPAc-en|ˈ|z|iː|k|ə}}
|ICD10          =
|ICD9           = 066.3
|DiseasesDB     =36480
|MedlinePlus    =007666
|eMedicineSubj  =
|eMedicineTopic =
|MeSH       =D000071243
}}
&lt;!-- Definition and symptoms --&gt;
'''Umgomani weZika''' (owaziwa godu'''ngomulwana weZika''') bulwelwe[[obubangwa mumulwana iZika]].&lt;ref name=&quot;WHO2016Jan&quot;&gt;{{cite web | url=http://www.who.int/mediacentre/factsheets/zika/en/ | title=Zika virus | publisher=World Health Organization | date=January 2016 | accessdate=3 February 2016}}&lt;/ref&gt;Esikhathini esinengi izehlakalo ezibikwako azinawo amatshwayo wokugula, kodwana nangabe akhona kuzwakala ukufuthumala[[ nomgomani womzimba obuhlungu]].&lt;ref name=&quot;WHO2016Jan&quot; /&gt;&lt;ref name=&quot;ecdc1&quot;&gt;{{cite web | url=http://ecdc.europa.eu/en/healthtopics/zika_virus_infection/factsheet-health-professionals/Pages/factsheet_health_professionals.aspx | title=Factsheet for health professionals | publisher=European Centre for Disease Prevention and Control | work=Zika virus infection | accessdate=22 December 2015}}&lt;/ref&gt; Amatshwayo angafaka hlangana[[umgomani nehloko ebuhlungu]],[[ amehlo |abovu]],[[i-arthralgia| ubuhlungu balapha kuhlangana khona amathambo]]ihloko esawula kabuhlungu, kanye[[neratjhi elumako]].&lt;ref name=WHO2016Jan/&gt;&lt;ref name=Ann2016/&gt;&lt;ref name=&quot;Musso14&quot;&gt;{{cite journal | url=http://linkinghub.elsevier.com/retrieve/pii/S1198743X1465391X | title=Rapid spread of emerging Zika virus in the Pacific area | last=Musso | first=D. | last2=Nilles | first2=E.J. | last3=Cao-Lormeau | first3=V.-M. | journal=Clinical Microbiology and Infection | year=2014 | volume=20 | issue=10 | pages=O595–6 | doi=10.1111/1469-0691.12707 | pmid=24909208}}&lt;/ref&gt; Amatshwayo la abonala amalanga angaphasi kwalikhomba.&lt;ref name=Ann2016/&gt; Akhange bubange ukufa komuntu lokha nakasathoma ukubonakala.&lt;ref name=&quot;ecdc1&quot;/&gt;Ubulwelwe lobu buhlotjaniswe[[ne-Guillain–Barré syndrom]] (GBS0.&lt;ref name=&quot;ecdc1&quot;/&gt; 

&lt;!-- Cause and diagnosis --&gt;
Umgomani weZika usabalaliseka nofana utheleleka ngokulunywa[[ ngunompopoloza]]womhlobo''[[i-Aedes]]''okhethekileko.&lt;ref name=Ann2016/&gt;Ungatheleleka [[godu ngokuya emsemeni|ukuya emsemeni]]ukusuka endodeni ukuya kiloyo alala naye[[bese ubulwelwe lobu bungatheleleka ngokungenelana kweengaz]]i. &lt;ref name=CDC2016&gt;{{cite journal|last1=Oster|first1=Alexandra M.|last2=Russell|first2=Kate|last3=Stryker|first3=Jo Ellen|last4=Friedman|first4=Allison|last5=Kachur|first5=Rachel E.|last6=Petersen|first6=Emily E.|last7=Jamieson|first7=Denise J.|last8=Cohn|first8=Amanda C.|last9=Brooks|first9=John T.|title=Update: Interim Guidance for Prevention of Sexual Transmission of Zika Virus — United States, 2016|journal=MMWR. Morbidity and Mortality Weekly Report|date=1 April 2016|volume=65|issue=12|pages=323–325|doi=10.15585/mmwr.mm6512e3|pmid = 27032078}}&lt;/ref&gt;&lt;ref name=Ann2016/&gt; Ukutheleleka kilabo abafazi abasidisi abazithweleko kungatheleleka nemntwaneni[[ngombana khekwahlotjaniswa]]nokufoloza ukuhlongakala kwabantwana bangakabelethwa[[ kanye nokubelethwa kwabantwana abaneenhloko ezincani ngokungakajayeki]].&lt;ref name=WHO2016Jan/&gt;&lt;ref name=&quot;ChanChoi2016&quot;&gt;{{cite journal | first1=Jasper F.W. | last1=Chan | url=https://www.ncbi.nlm.nih.gov/pubmed/26940504 | title=Zika fever and congenital Zika syndrome: An unexpected emerging arboviral disease | last2=Choi | first2=Garnet K.Y. | last3=Yip | first3=Cyril C.Y. | last4=Cheng | first4=Vincent C.C. | last5=Yuen | first5=Kwok-Yung | journal=Journal of Infection | year=2016 | issn=01634453 | doi=10.1016/j.jinf.2016.02.011 | pmid=26940504 | display-authors=3}}&lt;/ref&gt; Ukutholwa komrabho wobulwelwe lobu kwenziwa ngokuhlola igazi, umthondo, nofana amathe kuqalwe ubukhona bomgomani i-Zika[[RNA]] lokha umuntu nakagulako.&lt;ref name=WHO2016Jan/&gt;&lt;ref name=Ann2016/&gt;

&lt;!-- Prevention and treatment --&gt;
Ukukhandela ubulwelwe lobu kufaka hlangana ukwehlisa ukuba khona kwabonompopoloza abalumako eendaweni lapha badlange khona kanye nokusebenzisa ikhpndomu nawuya emsemeni.&lt;ref name=&quot;Ann2016&quot;&gt;{{cite journal | first1=Lin H. | last1=Chen | url=http://annals.org/article.aspx?articleid=2486362 | title=Zika Virus: Rapid Spread in the Western Hemisphere | last2=Hamer | first2=Davidson H. | journal=Annals of Internal Medicine | year=2016 | issn=0003-4819 | doi=10.7326/M16-0150}}&lt;/ref&gt;&lt;ref name=CDC2016/&gt; Imizamo yokwehlisa ukulunywa kufaka hlangana[[nokusebenzisa iinhlanhla ezibulala iinunwana]] ukuvala umzimba wakho ngezambatho[[ iinhlanhla ezibulala abonompopoloza]], nokususa amazni ajamileko angakhambiko lapha abonompopoloza bangathola khona ithuba lokwanda.&lt;ref name=WHO2016Jan/&gt; Aasikho isihlahla[[nofana imijovo esebenza ukulapha ubulwelobu]].&lt;ref name=Ann2016/&gt; Abasebezi bezamaphilo banyule ukuthi abafazi abahlala lapho kudlange khona ubulwelwe bomgomani weZika[[bomgomani weZika (2015–bekube nje)|2015-16 ukuqubuka kobulwelwe bomgomani iZika]] bathathe isiqunto sokobana bangabi nabantwana begodu abafazi abasidisi bangayi eendaweni lapaha kudlange ubulwelwe lobu.&lt;ref name=Ann2016/&gt;&lt;ref name=&quot;cnn1&quot;&gt;{{cite news | url=http://www.cnn.com/2015/12/23/health/brazil-zika-pregnancy-warning/index.html | title=Brazil warns against pregnancy due to spreading virus | work=CNN | date=24 December 2015 | accessdate=24 December 2015}}&lt;/ref&gt; Njengombana akunasihlahla sokulapha ubulwelwe lobu,[[ amapeli wehlono neenhlungu i-paracetamol]]i- (acetaminophen) zingasiza lokha nawubona amatshwayo wobulwelobu.&lt;ref name=Ann2016/&gt; Ukuyokungeniswa esibhedlela akukavami.&lt;ref name=&quot;ecdc1&quot;/&gt; 

&lt;!-- History and epidemiology --&gt;
Umulwana obanga ubulwelwe lobu watholakala ngo-1947.&lt;ref name=&quot;OlsonHaddow2012&quot;&gt;{{cite journal | display-authors=3 | first1=Ken E. | first10=Scott C. | first3=Amy J. | first7=Rekol | last1=Olson | last10=Weaver | title=Genetic Characterization of Zika Virus Strains: Geographic Expansion of the Asian Lineage | last2=Haddow | first2=Andrew D. | last3=Schuh | last4=Yasuda | first4=Chadwick Y. | last5=Kasper | first5=Matthew R. | last6=Heang | first6=Vireak | last7=Huy | last8=Guzman | first8=Hilda | last9=Tesh | first9=Robert B. | journal=PLoS Neglected Tropical Diseases | year=2012 | volume=6 | issue=2 | pages=e1477 | issn=1935-2735 | doi=10.1371/journal.pntd.0001477 | pmid=22389730 | pmc=3289602}}&lt;/ref&gt; Ukutholaka kokuthoma kokuqubuka kobulwelwe lobu kwavela ngo-2007 [[e-Federated States ye- Micronesia]].&lt;ref name=Ann2016/&gt; {{Ukusukela|ngoTjhirhweni 2016}}ubulwelwe lobu buqubuke eengodini ezimatjhumi amabili[[nge-Amerikha]].&lt;ref name=Ann2016/&gt; Kuthiwa buqubuke ne-Afrika, e-Asia kanye ne-Pacific.&lt;ref name=WHO2016Jan/&gt; Ngesibanga sokuqubuka kwabo ubulwelobu eBrazil ngo2015,i[[World Health Oeganization]]iikhiphe umbiko orhabako[[ngobungozi obukhna Emphakathini keZamaphilo eenTjhabatjhabeni zoke]] ngenyaka kaMhlolanja 2016.&lt;ref name=&quot;who1&quot;&gt;{{cite web | url=http://www.who.int/mediacentre/news/statements/2016/emergency-committee-zika-microcephaly/en/ | title=WHO Director-General summarizes the outcome of the Emergency Committee regarding clusters of microcephaly and Guillain-Barré syndrome | work=Media Centre | publisher=World Health Organization | date=1 February 2016 | accessdate=3 February 2016}}&lt;/ref&gt;

==Isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini==
&lt;references /&gt;</text>
      <sha1>i9fbbp8udcjbi2g8f3x5yzmouw498ms</sha1>
    </revision>
    <revision>
      <id>1922</id>
      <parentid>1921</parentid>
      <timestamp>2016-11-08T21:19:54Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <origin>1922</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7616" sha1="o2ht3veukaa077bqce3ikwbnxkpn0ez" xml:space="preserve">{{Wp/nd/Infobox disease
|name           = Umgomani weZika
|image          = Alexius Salvador Zika-Virus.jpg
|caption        = Iratjhi ngesikhathi kutheleleke umgomani weZika
|Field          = [[Infectious disease (medical specialty)|Infectious disease]]
|pronunciation  = Zika {{IPAc-en|ˈ|z|iː|k|ə}}
|ICD10          = {{ICD10|U|06|9|a|}}, code change from 21 December 2015
|ICD9           = {{ICD9|066.3}}
|DiseasesDB     =36480
|MedlinePlus    =007666
|eMedicineSubj  =
|eMedicineTopic =
|MeSH       =D000071243
}}
&lt;!-- Definition and symptoms --&gt;
'''Umgomani weZika''' (owaziwa godu'''ngomulwana weZika''') bulwelwe[[obubangwa mumulwana iZika]].&lt;ref name=&quot;WHO2016Jan&quot;&gt;{{Wp/nd/cite web | url=http://www.who.int/mediacentre/factsheets/zika/en/ | title=Zika virus | publisher=World Health Organization | date=January 2016 | accessdate=3 February 2016}}&lt;/ref&gt;Esikhathini esinengi izehlakalo ezibikwako azinawo amatshwayo wokugula, kodwana nangabe akhona kuzwakala ukufuthumala[[ nomgomani womzimba obuhlungu]].&lt;ref name=&quot;WHO2016Jan&quot; /&gt;&lt;ref name=&quot;ecdc1&quot;&gt;{{Wp/nd/cite web | url=http://ecdc.europa.eu/en/healthtopics/zika_virus_infection/factsheet-health-professionals/Pages/factsheet_health_professionals.aspx | title=Factsheet for health professionals | publisher=European Centre for Disease Prevention and Control | work=Zika virus infection | accessdate=22 December 2015}}&lt;/ref&gt; Amatshwayo angafaka hlangana[[umgomani nehloko ebuhlungu]],[[ amehlo |abovu]],[[i-arthralgia| ubuhlungu balapha kuhlangana khona amathambo]]ihloko esawula kabuhlungu, kanye[[neratjhi elumako]].&lt;ref name=WHO2016Jan/&gt;&lt;ref name=Ann2016/&gt;&lt;ref name=&quot;Musso14&quot;&gt;{{Wp/nd/cite journal | url=http://linkinghub.elsevier.com/retrieve/pii/S1198743X1465391X | title=Rapid spread of emerging Zika virus in the Pacific area | last=Musso | first=D. | last2=Nilles | first2=E.J. | last3=Cao-Lormeau | first3=V.-M. | journal=Clinical Microbiology and Infection | year=2014 | volume=20 | issue=10 | pages=O595–6 | doi=10.1111/1469-0691.12707 | pmid=24909208}}&lt;/ref&gt; Amatshwayo la abonala amalanga angaphasi kwalikhomba.&lt;ref name=Ann2016/&gt; Akhange bubange ukufa komuntu lokha nakasathoma ukubonakala.&lt;ref name=&quot;ecdc1&quot;/&gt;Ubulwelwe lobu buhlotjaniswe[[ne-Guillain–Barré syndrom]] (GBS0.&lt;ref name=&quot;ecdc1&quot;/&gt; 

&lt;!-- Cause and diagnosis --&gt;
Umgomani weZika usabalaliseka nofana utheleleka ngokulunywa[[ ngunompopoloza]]womhlobo''[[i-Aedes]]''okhethekileko.&lt;ref name=Ann2016/&gt;Ungatheleleka [[godu ngokuya emsemeni|ukuya emsemeni]]ukusuka endodeni ukuya kiloyo alala naye[[bese ubulwelwe lobu bungatheleleka ngokungenelana kweengaz]]i. &lt;ref name=CDC2016&gt;{{Wp/nd/cite journal|last1=Oster|first1=Alexandra M.|last2=Russell|first2=Kate|last3=Stryker|first3=Jo Ellen|last4=Friedman|first4=Allison|last5=Kachur|first5=Rachel E.|last6=Petersen|first6=Emily E.|last7=Jamieson|first7=Denise J.|last8=Cohn|first8=Amanda C.|last9=Brooks|first9=John T.|title=Update: Interim Guidance for Prevention of Sexual Transmission of Zika Virus — United States, 2016|journal=MMWR. Morbidity and Mortality Weekly Report|date=1 April 2016|volume=65|issue=12|pages=323–325|doi=10.15585/mmwr.mm6512e3|pmid = 27032078}}&lt;/ref&gt;&lt;ref name=Ann2016/&gt; Ukutheleleka kilabo abafazi abasidisi abazithweleko kungatheleleka nemntwaneni[[ngombana khekwahlotjaniswa]]nokufoloza ukuhlongakala kwabantwana bangakabelethwa[[ kanye nokubelethwa kwabantwana abaneenhloko ezincani ngokungakajayeki]].&lt;ref name=WHO2016Jan/&gt;&lt;ref name=&quot;ChanChoi2016&quot;&gt;{{Wp/nd/cite journal | first1=Jasper F.W. | last1=Chan | url=https://www.ncbi.nlm.nih.gov/pubmed/26940504 | title=Zika fever and congenital Zika syndrome: An unexpected emerging arboviral disease | last2=Choi | first2=Garnet K.Y. | last3=Yip | first3=Cyril C.Y. | last4=Cheng | first4=Vincent C.C. | last5=Yuen | first5=Kwok-Yung | journal=Journal of Infection | year=2016 | issn=01634453 | doi=10.1016/j.jinf.2016.02.011 | pmid=26940504 | display-authors=3}}&lt;/ref&gt; Ukutholwa komrabho wobulwelwe lobu kwenziwa ngokuhlola igazi, umthondo, nofana amathe kuqalwe ubukhona bomgomani i-Zika[[RNA]] lokha umuntu nakagulako.&lt;ref name=WHO2016Jan/&gt;&lt;ref name=Ann2016/&gt;

&lt;!-- Prevention and treatment --&gt;
Ukukhandela ubulwelwe lobu kufaka hlangana ukwehlisa ukuba khona kwabonompopoloza abalumako eendaweni lapha badlange khona kanye nokusebenzisa ikhpndomu nawuya emsemeni.&lt;ref name=&quot;Ann2016&quot;&gt;{{Wp/nd/cite journal | first1=Lin H. | last1=Chen | url=http://annals.org/article.aspx?articleid=2486362 | title=Zika Virus: Rapid Spread in the Western Hemisphere | last2=Hamer | first2=Davidson H. | journal=Annals of Internal Medicine | year=2016 | issn=0003-4819 | doi=10.7326/M16-0150}}&lt;/ref&gt;&lt;ref name=CDC2016/&gt; Imizamo yokwehlisa ukulunywa kufaka hlangana[[nokusebenzisa iinhlanhla ezibulala iinunwana]] ukuvala umzimba wakho ngezambatho[[ iinhlanhla ezibulala abonompopoloza]], nokususa amazni ajamileko angakhambiko lapha abonompopoloza bangathola khona ithuba lokwanda.&lt;ref name=WHO2016Jan/&gt; Aasikho isihlahla[[nofana imijovo esebenza ukulapha ubulwelobu]].&lt;ref name=Ann2016/&gt; Abasebezi bezamaphilo banyule ukuthi abafazi abahlala lapho kudlange khona ubulwelwe bomgomani weZika[[bomgomani weZika (2015–bekube nje)|2015-16 ukuqubuka kobulwelwe bomgomani iZika]] bathathe isiqunto sokobana bangabi nabantwana begodu abafazi abasidisi bangayi eendaweni lapaha kudlange ubulwelwe lobu.&lt;ref name=Ann2016/&gt;&lt;ref name=&quot;cnn1&quot;&gt;{{Wp/nd/cite news | url=http://www.cnn.com/2015/12/23/health/brazil-zika-pregnancy-warning/index.html | title=Brazil warns against pregnancy due to spreading virus | work=CNN | date=24 December 2015 | accessdate=24 December 2015}}&lt;/ref&gt; Njengombana akunasihlahla sokulapha ubulwelwe lobu,[[ amapeli wehlono neenhlungu i-paracetamol]]i- (acetaminophen) zingasiza lokha nawubona amatshwayo wobulwelobu.&lt;ref name=Ann2016/&gt; Ukuyokungeniswa esibhedlela akukavami.&lt;ref name=&quot;ecdc1&quot;/&gt; 

&lt;!-- History and epidemiology --&gt;
Umulwana obanga ubulwelwe lobu watholakala ngo-1947.&lt;ref name=&quot;OlsonHaddow2012&quot;&gt;{{Wp/nd/cite journal | display-authors=3 | first1=Ken E. | first10=Scott C. | first3=Amy J. | first7=Rekol | last1=Olson | last10=Weaver | title=Genetic Characterization of Zika Virus Strains: Geographic Expansion of the Asian Lineage | last2=Haddow | first2=Andrew D. | last3=Schuh | last4=Yasuda | first4=Chadwick Y. | last5=Kasper | first5=Matthew R. | last6=Heang | first6=Vireak | last7=Huy | last8=Guzman | first8=Hilda | last9=Tesh | first9=Robert B. | journal=PLoS Neglected Tropical Diseases | year=2012 | volume=6 | issue=2 | pages=e1477 | issn=1935-2735 | doi=10.1371/journal.pntd.0001477 | pmid=22389730 | pmc=3289602}}&lt;/ref&gt; Ukutholaka kokuthoma kokuqubuka kobulwelwe lobu kwavela ngo-2007 [[e-Federated States ye- Micronesia]].&lt;ref name=Ann2016/&gt; {{Ukusukela|ngoTjhirhweni 2016}}ubulwelwe lobu buqubuke eengodini ezimatjhumi amabili[[nge-Amerikha]].&lt;ref name=Ann2016/&gt; Kuthiwa buqubuke ne-Afrika, e-Asia kanye ne-Pacific.&lt;ref name=WHO2016Jan/&gt; Ngesibanga sokuqubuka kwabo ubulwelobu eBrazil ngo2015,i[[World Health Oeganization]]iikhiphe umbiko orhabako[[ngobungozi obukhna Emphakathini keZamaphilo eenTjhabatjhabeni zoke]] ngenyaka kaMhlolanja 2016.&lt;ref name=&quot;who1&quot;&gt;{{Wp/nd/cite web | url=http://www.who.int/mediacentre/news/statements/2016/emergency-committee-zika-microcephaly/en/ | title=WHO Director-General summarizes the outcome of the Emergency Committee regarding clusters of microcephaly and Guillain-Barré syndrome | work=Media Centre | publisher=World Health Organization | date=1 February 2016 | accessdate=3 February 2016}}&lt;/ref&gt;

==Isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini==
&lt;references /&gt;</text>
      <sha1>o2ht3veukaa077bqce3ikwbnxkpn0ez</sha1>
    </revision>
    <revision>
      <id>1923</id>
      <parentid>1922</parentid>
      <timestamp>2016-11-08T21:20:30Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <origin>1923</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7514" sha1="orpbc8nzzp8mvyk0khbh7ela2961rbb" xml:space="preserve">{{Wp/nd/Infobox disease
|name           = Umgomani weZika
|image          = Alexius Salvador Zika-Virus.jpg
|caption        = Iratjhi ngesikhathi kutheleleke umgomani weZika
|pronunciation  = Zika {{IPAc-en|ˈ|z|iː|k|ə}}
|ICD10          = {{Wp/nd/ICD10|U|06|9|a|}},
|ICD9           = {{Wp/nd/ICD9|066.3}}
|DiseasesDB     =36480
|MedlinePlus    =007666
|eMedicineSubj  =
|eMedicineTopic =
|MeSH       =D000071243
}}
&lt;!-- Definition and symptoms --&gt;
'''Umgomani weZika''' (owaziwa godu'''ngomulwana weZika''') bulwelwe[[obubangwa mumulwana iZika]].&lt;ref name=&quot;WHO2016Jan&quot;&gt;{{Wp/nd/cite web | url=http://www.who.int/mediacentre/factsheets/zika/en/ | title=Zika virus | publisher=World Health Organization | date=January 2016 | accessdate=3 February 2016}}&lt;/ref&gt;Esikhathini esinengi izehlakalo ezibikwako azinawo amatshwayo wokugula, kodwana nangabe akhona kuzwakala ukufuthumala[[ nomgomani womzimba obuhlungu]].&lt;ref name=&quot;WHO2016Jan&quot; /&gt;&lt;ref name=&quot;ecdc1&quot;&gt;{{Wp/nd/cite web | url=http://ecdc.europa.eu/en/healthtopics/zika_virus_infection/factsheet-health-professionals/Pages/factsheet_health_professionals.aspx | title=Factsheet for health professionals | publisher=European Centre for Disease Prevention and Control | work=Zika virus infection | accessdate=22 December 2015}}&lt;/ref&gt; Amatshwayo angafaka hlangana[[umgomani nehloko ebuhlungu]],[[ amehlo |abovu]],[[i-arthralgia| ubuhlungu balapha kuhlangana khona amathambo]]ihloko esawula kabuhlungu, kanye[[neratjhi elumako]].&lt;ref name=WHO2016Jan/&gt;&lt;ref name=Ann2016/&gt;&lt;ref name=&quot;Musso14&quot;&gt;{{Wp/nd/cite journal | url=http://linkinghub.elsevier.com/retrieve/pii/S1198743X1465391X | title=Rapid spread of emerging Zika virus in the Pacific area | last=Musso | first=D. | last2=Nilles | first2=E.J. | last3=Cao-Lormeau | first3=V.-M. | journal=Clinical Microbiology and Infection | year=2014 | volume=20 | issue=10 | pages=O595–6 | doi=10.1111/1469-0691.12707 | pmid=24909208}}&lt;/ref&gt; Amatshwayo la abonala amalanga angaphasi kwalikhomba.&lt;ref name=Ann2016/&gt; Akhange bubange ukufa komuntu lokha nakasathoma ukubonakala.&lt;ref name=&quot;ecdc1&quot;/&gt;Ubulwelwe lobu buhlotjaniswe[[ne-Guillain–Barré syndrom]] (GBS0.&lt;ref name=&quot;ecdc1&quot;/&gt; 

&lt;!-- Cause and diagnosis --&gt;
Umgomani weZika usabalaliseka nofana utheleleka ngokulunywa[[ ngunompopoloza]]womhlobo''[[i-Aedes]]''okhethekileko.&lt;ref name=Ann2016/&gt;Ungatheleleka [[godu ngokuya emsemeni|ukuya emsemeni]]ukusuka endodeni ukuya kiloyo alala naye[[bese ubulwelwe lobu bungatheleleka ngokungenelana kweengaz]]i. &lt;ref name=CDC2016&gt;{{Wp/nd/cite journal|last1=Oster|first1=Alexandra M.|last2=Russell|first2=Kate|last3=Stryker|first3=Jo Ellen|last4=Friedman|first4=Allison|last5=Kachur|first5=Rachel E.|last6=Petersen|first6=Emily E.|last7=Jamieson|first7=Denise J.|last8=Cohn|first8=Amanda C.|last9=Brooks|first9=John T.|title=Update: Interim Guidance for Prevention of Sexual Transmission of Zika Virus — United States, 2016|journal=MMWR. Morbidity and Mortality Weekly Report|date=1 April 2016|volume=65|issue=12|pages=323–325|doi=10.15585/mmwr.mm6512e3|pmid = 27032078}}&lt;/ref&gt;&lt;ref name=Ann2016/&gt; Ukutheleleka kilabo abafazi abasidisi abazithweleko kungatheleleka nemntwaneni[[ngombana khekwahlotjaniswa]]nokufoloza ukuhlongakala kwabantwana bangakabelethwa[[ kanye nokubelethwa kwabantwana abaneenhloko ezincani ngokungakajayeki]].&lt;ref name=WHO2016Jan/&gt;&lt;ref name=&quot;ChanChoi2016&quot;&gt;{{Wp/nd/cite journal | first1=Jasper F.W. | last1=Chan | url=https://www.ncbi.nlm.nih.gov/pubmed/26940504 | title=Zika fever and congenital Zika syndrome: An unexpected emerging arboviral disease | last2=Choi | first2=Garnet K.Y. | last3=Yip | first3=Cyril C.Y. | last4=Cheng | first4=Vincent C.C. | last5=Yuen | first5=Kwok-Yung | journal=Journal of Infection | year=2016 | issn=01634453 | doi=10.1016/j.jinf.2016.02.011 | pmid=26940504 | display-authors=3}}&lt;/ref&gt; Ukutholwa komrabho wobulwelwe lobu kwenziwa ngokuhlola igazi, umthondo, nofana amathe kuqalwe ubukhona bomgomani i-Zika[[RNA]] lokha umuntu nakagulako.&lt;ref name=WHO2016Jan/&gt;&lt;ref name=Ann2016/&gt;

&lt;!-- Prevention and treatment --&gt;
Ukukhandela ubulwelwe lobu kufaka hlangana ukwehlisa ukuba khona kwabonompopoloza abalumako eendaweni lapha badlange khona kanye nokusebenzisa ikhpndomu nawuya emsemeni.&lt;ref name=&quot;Ann2016&quot;&gt;{{Wp/nd/cite journal | first1=Lin H. | last1=Chen | url=http://annals.org/article.aspx?articleid=2486362 | title=Zika Virus: Rapid Spread in the Western Hemisphere | last2=Hamer | first2=Davidson H. | journal=Annals of Internal Medicine | year=2016 | issn=0003-4819 | doi=10.7326/M16-0150}}&lt;/ref&gt;&lt;ref name=CDC2016/&gt; Imizamo yokwehlisa ukulunywa kufaka hlangana[[nokusebenzisa iinhlanhla ezibulala iinunwana]] ukuvala umzimba wakho ngezambatho[[ iinhlanhla ezibulala abonompopoloza]], nokususa amazni ajamileko angakhambiko lapha abonompopoloza bangathola khona ithuba lokwanda.&lt;ref name=WHO2016Jan/&gt; Aasikho isihlahla[[nofana imijovo esebenza ukulapha ubulwelobu]].&lt;ref name=Ann2016/&gt; Abasebezi bezamaphilo banyule ukuthi abafazi abahlala lapho kudlange khona ubulwelwe bomgomani weZika[[bomgomani weZika (2015–bekube nje)|2015-16 ukuqubuka kobulwelwe bomgomani iZika]] bathathe isiqunto sokobana bangabi nabantwana begodu abafazi abasidisi bangayi eendaweni lapaha kudlange ubulwelwe lobu.&lt;ref name=Ann2016/&gt;&lt;ref name=&quot;cnn1&quot;&gt;{{Wp/nd/cite news | url=http://www.cnn.com/2015/12/23/health/brazil-zika-pregnancy-warning/index.html | title=Brazil warns against pregnancy due to spreading virus | work=CNN | date=24 December 2015 | accessdate=24 December 2015}}&lt;/ref&gt; Njengombana akunasihlahla sokulapha ubulwelwe lobu,[[ amapeli wehlono neenhlungu i-paracetamol]]i- (acetaminophen) zingasiza lokha nawubona amatshwayo wobulwelobu.&lt;ref name=Ann2016/&gt; Ukuyokungeniswa esibhedlela akukavami.&lt;ref name=&quot;ecdc1&quot;/&gt; 

&lt;!-- History and epidemiology --&gt;
Umulwana obanga ubulwelwe lobu watholakala ngo-1947.&lt;ref name=&quot;OlsonHaddow2012&quot;&gt;{{Wp/nd/cite journal | display-authors=3 | first1=Ken E. | first10=Scott C. | first3=Amy J. | first7=Rekol | last1=Olson | last10=Weaver | title=Genetic Characterization of Zika Virus Strains: Geographic Expansion of the Asian Lineage | last2=Haddow | first2=Andrew D. | last3=Schuh | last4=Yasuda | first4=Chadwick Y. | last5=Kasper | first5=Matthew R. | last6=Heang | first6=Vireak | last7=Huy | last8=Guzman | first8=Hilda | last9=Tesh | first9=Robert B. | journal=PLoS Neglected Tropical Diseases | year=2012 | volume=6 | issue=2 | pages=e1477 | issn=1935-2735 | doi=10.1371/journal.pntd.0001477 | pmid=22389730 | pmc=3289602}}&lt;/ref&gt; Ukutholaka kokuthoma kokuqubuka kobulwelwe lobu kwavela ngo-2007 [[e-Federated States ye- Micronesia]].&lt;ref name=Ann2016/&gt; {{Ukusukela|ngoTjhirhweni 2016}}ubulwelwe lobu buqubuke eengodini ezimatjhumi amabili[[nge-Amerikha]].&lt;ref name=Ann2016/&gt; Kuthiwa buqubuke ne-Afrika, e-Asia kanye ne-Pacific.&lt;ref name=WHO2016Jan/&gt; Ngesibanga sokuqubuka kwabo ubulwelobu eBrazil ngo2015,i[[World Health Oeganization]]iikhiphe umbiko orhabako[[ngobungozi obukhna Emphakathini keZamaphilo eenTjhabatjhabeni zoke]] ngenyaka kaMhlolanja 2016.&lt;ref name=&quot;who1&quot;&gt;{{Wp/nd/cite web | url=http://www.who.int/mediacentre/news/statements/2016/emergency-committee-zika-microcephaly/en/ | title=WHO Director-General summarizes the outcome of the Emergency Committee regarding clusters of microcephaly and Guillain-Barré syndrome | work=Media Centre | publisher=World Health Organization | date=1 February 2016 | accessdate=3 February 2016}}&lt;/ref&gt;

==Isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini==
&lt;references /&gt;</text>
      <sha1>orpbc8nzzp8mvyk0khbh7ela2961rbb</sha1>
    </revision>
    <revision>
      <id>1924</id>
      <parentid>1923</parentid>
      <timestamp>2016-11-26T19:24:00Z</timestamp>
      <contributor>
        <username>incubator&gt;Doc James</username>
        <id>0</id>
      </contributor>
      <comment>fixed</comment>
      <origin>1924</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7519" sha1="sb9753ikfjzm53ou42perq8cvcvr2q4" xml:space="preserve">{{Wp/nd/Infobox disease
|name           = Umgomani weZika
|image          = Alexius Salvador Zika-Virus.jpg
|caption        = Iratjhi ngesikhathi kutheleleke umgomani weZika
|pronunciation  = Zika {{IPAc-en|ˈ|z|iː|k|ə}}
|ICD10          = {{Wp/nd/ICD10|U|06|9|a|}},
|ICD9           = {{Wp/nd/ICD9|066.3}}
|DiseasesDB     =36480
|MedlinePlus    =007666
|eMedicineSubj  =
|eMedicineTopic =
|MeSH       =D000071243
}}
&lt;!-- Definition and symptoms --&gt;
'''Umgomani weZika''' (owaziwa godu'''ngomulwana weZika''') bulwelwe [[obubangwa mumulwana iZika]].&lt;ref name=&quot;WHO2016Jan&quot;&gt;{{Wp/nd/cite web | url=http://www.who.int/mediacentre/factsheets/zika/en/ | title=Zika virus | publisher=World Health Organization | date=January 2016 | accessdate=3 February 2016}}&lt;/ref&gt;Esikhathini esinengi izehlakalo ezibikwako azinawo amatshwayo wokugula, kodwana nangabe akhona kuzwakala ukufuthumala[[ nomgomani womzimba obuhlungu]].&lt;ref name=&quot;WHO2016Jan&quot; /&gt;&lt;ref name=&quot;ecdc1&quot;&gt;{{Wp/nd/cite web | url=http://ecdc.europa.eu/en/healthtopics/zika_virus_infection/factsheet-health-professionals/Pages/factsheet_health_professionals.aspx | title=Factsheet for health professionals | publisher=European Centre for Disease Prevention and Control | work=Zika virus infection | accessdate=22 December 2015}}&lt;/ref&gt; Amatshwayo angafaka hlangana[[umgomani nehloko ebuhlungu]],[[ amehlo |abovu]],[[i-arthralgia| ubuhlungu balapha kuhlangana khona amathambo]]ihloko esawula kabuhlungu, kanye[[neratjhi elumako]].&lt;ref name=WHO2016Jan/&gt;&lt;ref name=Ann2016/&gt;&lt;ref name=&quot;Musso14&quot;&gt;{{Wp/nd/cite journal | url=http://linkinghub.elsevier.com/retrieve/pii/S1198743X1465391X | title=Rapid spread of emerging Zika virus in the Pacific area | last=Musso | first=D. | last2=Nilles | first2=E.J. | last3=Cao-Lormeau | first3=V.-M. | journal=Clinical Microbiology and Infection | year=2014 | volume=20 | issue=10 | pages=O595–6 | doi=10.1111/1469-0691.12707 | pmid=24909208}}&lt;/ref&gt; Amatshwayo la abonala amalanga angaphasi kwalikhomba.&lt;ref name=Ann2016/&gt; Akhange bubange ukufa komuntu lokha nakasathoma ukubonakala.&lt;ref name=&quot;ecdc1&quot;/&gt;Ubulwelwe lobu buhlotjaniswe[[ne-Guillain–Barré syndrom]] (GBS0.&lt;ref name=&quot;ecdc1&quot;/&gt; 

&lt;!-- Cause and diagnosis --&gt;
Umgomani weZika usabalaliseka nofana utheleleka ngokulunywa [[ngunompopoloza]] womhlobo ''[[i-Aedes]]'' okhethekileko.&lt;ref name=Ann2016/&gt;Ungatheleleka [[godu ngokuya emsemeni|ukuya emsemeni]] ukusuka endodeni ukuya kiloyo alala naye[[bese ubulwelwe lobu bungatheleleka ngokungenelana kweengaz]]i. &lt;ref name=CDC2016&gt;{{Wp/nd/cite journal|last1=Oster|first1=Alexandra M.|last2=Russell|first2=Kate|last3=Stryker|first3=Jo Ellen|last4=Friedman|first4=Allison|last5=Kachur|first5=Rachel E.|last6=Petersen|first6=Emily E.|last7=Jamieson|first7=Denise J.|last8=Cohn|first8=Amanda C.|last9=Brooks|first9=John T.|title=Update: Interim Guidance for Prevention of Sexual Transmission of Zika Virus — United States, 2016|journal=MMWR. Morbidity and Mortality Weekly Report|date=1 April 2016|volume=65|issue=12|pages=323–325|doi=10.15585/mmwr.mm6512e3|pmid = 27032078}}&lt;/ref&gt;&lt;ref name=Ann2016/&gt; Ukutheleleka kilabo abafazi abasidisi abazithweleko kungatheleleka nemntwaneni[[ngombana khekwahlotjaniswa]]nokufoloza ukuhlongakala kwabantwana bangakabelethwa [[kanye nokubelethwa kwabantwana abaneenhloko ezincani ngokungakajayeki]].&lt;ref name=WHO2016Jan/&gt;&lt;ref name=&quot;ChanChoi2016&quot;&gt;{{Wp/nd/cite journal | first1=Jasper F.W. | last1=Chan | url=https://www.ncbi.nlm.nih.gov/pubmed/26940504 | title=Zika fever and congenital Zika syndrome: An unexpected emerging arboviral disease | last2=Choi | first2=Garnet K.Y. | last3=Yip | first3=Cyril C.Y. | last4=Cheng | first4=Vincent C.C. | last5=Yuen | first5=Kwok-Yung | journal=Journal of Infection | year=2016 | issn=01634453 | doi=10.1016/j.jinf.2016.02.011 | pmid=26940504 | display-authors=3}}&lt;/ref&gt; Ukutholwa komrabho wobulwelwe lobu kwenziwa ngokuhlola igazi, umthondo, nofana amathe kuqalwe ubukhona bomgomani i-Zika[[RNA]] lokha umuntu nakagulako.&lt;ref name=WHO2016Jan/&gt;&lt;ref name=Ann2016/&gt;

&lt;!-- Prevention and treatment --&gt;
Ukukhandela ubulwelwe lobu kufaka hlangana ukwehlisa ukuba khona kwabonompopoloza abalumako eendaweni lapha badlange khona kanye nokusebenzisa ikhpndomu nawuya emsemeni.&lt;ref name=&quot;Ann2016&quot;&gt;{{Wp/nd/cite journal | first1=Lin H. | last1=Chen | url=http://annals.org/article.aspx?articleid=2486362 | title=Zika Virus: Rapid Spread in the Western Hemisphere | last2=Hamer | first2=Davidson H. | journal=Annals of Internal Medicine | year=2016 | issn=0003-4819 | doi=10.7326/M16-0150}}&lt;/ref&gt;&lt;ref name=CDC2016/&gt; Imizamo yokwehlisa ukulunywa kufaka hlangana[[nokusebenzisa iinhlanhla ezibulala iinunwana]] ukuvala umzimba wakho ngezambatho[[ iinhlanhla ezibulala abonompopoloza]], nokususa amazni ajamileko angakhambiko lapha abonompopoloza bangathola khona ithuba lokwanda.&lt;ref name=WHO2016Jan/&gt; Aasikho isihlahla[[nofana imijovo esebenza ukulapha ubulwelobu]].&lt;ref name=Ann2016/&gt; Abasebezi bezamaphilo banyule ukuthi abafazi abahlala lapho kudlange khona ubulwelwe bomgomani weZika[[bomgomani weZika (2015–bekube nje)|2015-16 ukuqubuka kobulwelwe bomgomani iZika]] bathathe isiqunto sokobana bangabi nabantwana begodu abafazi abasidisi bangayi eendaweni lapaha kudlange ubulwelwe lobu.&lt;ref name=Ann2016/&gt;&lt;ref name=&quot;cnn1&quot;&gt;{{Wp/nd/cite news | url=http://www.cnn.com/2015/12/23/health/brazil-zika-pregnancy-warning/index.html | title=Brazil warns against pregnancy due to spreading virus | work=CNN | date=24 December 2015 | accessdate=24 December 2015}}&lt;/ref&gt; Njengombana akunasihlahla sokulapha ubulwelwe lobu,[[ amapeli wehlono neenhlungu i-paracetamol]]i- (acetaminophen) zingasiza lokha nawubona amatshwayo wobulwelobu.&lt;ref name=Ann2016/&gt; Ukuyokungeniswa esibhedlela akukavami.&lt;ref name=&quot;ecdc1&quot;/&gt; 

&lt;!-- History and epidemiology --&gt;
Umulwana obanga ubulwelwe lobu watholakala ngo-1947.&lt;ref name=&quot;OlsonHaddow2012&quot;&gt;{{Wp/nd/cite journal | display-authors=3 | first1=Ken E. | first10=Scott C. | first3=Amy J. | first7=Rekol | last1=Olson | last10=Weaver | title=Genetic Characterization of Zika Virus Strains: Geographic Expansion of the Asian Lineage | last2=Haddow | first2=Andrew D. | last3=Schuh | last4=Yasuda | first4=Chadwick Y. | last5=Kasper | first5=Matthew R. | last6=Heang | first6=Vireak | last7=Huy | last8=Guzman | first8=Hilda | last9=Tesh | first9=Robert B. | journal=PLoS Neglected Tropical Diseases | year=2012 | volume=6 | issue=2 | pages=e1477 | issn=1935-2735 | doi=10.1371/journal.pntd.0001477 | pmid=22389730 | pmc=3289602}}&lt;/ref&gt; Ukutholaka kokuthoma kokuqubuka kobulwelwe lobu kwavela ngo-2007 [[e-Federated States ye- Micronesia]].&lt;ref name=Ann2016/&gt; {{Ukusukela|ngoTjhirhweni 2016}}ubulwelwe lobu buqubuke eengodini ezimatjhumi amabili[[nge-Amerikha]].&lt;ref name=Ann2016/&gt; Kuthiwa buqubuke ne-Afrika, e-Asia kanye ne-Pacific.&lt;ref name=WHO2016Jan/&gt; Ngesibanga sokuqubuka kwabo ubulwelobu eBrazil ngo2015,i[[World Health Oeganization]]iikhiphe umbiko orhabako[[ngobungozi obukhna Emphakathini keZamaphilo eenTjhabatjhabeni zoke]] ngenyaka kaMhlolanja 2016.&lt;ref name=&quot;who1&quot;&gt;{{Wp/nd/cite web | url=http://www.who.int/mediacentre/news/statements/2016/emergency-committee-zika-microcephaly/en/ | title=WHO Director-General summarizes the outcome of the Emergency Committee regarding clusters of microcephaly and Guillain-Barré syndrome | work=Media Centre | publisher=World Health Organization | date=1 February 2016 | accessdate=3 February 2016}}&lt;/ref&gt;

==Isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini==
&lt;references /&gt;</text>
      <sha1>sb9753ikfjzm53ou42perq8cvcvr2q4</sha1>
    </revision>
    <revision>
      <id>1925</id>
      <parentid>1924</parentid>
      <timestamp>2016-11-26T19:24:34Z</timestamp>
      <contributor>
        <username>incubator&gt;Doc James</username>
        <id>0</id>
      </contributor>
      <origin>1925</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7521" sha1="16nzy77fvz9heyrqetyczjza06awvc9" xml:space="preserve">{{Wp/nd/Infobox disease
|name           = Umgomani weZika
|image          = Alexius Salvador Zika-Virus.jpg
|caption        = Iratjhi ngesikhathi kutheleleke umgomani weZika
|pronunciation  = Zika {{IPAc-en|ˈ|z|iː|k|ə}}
|ICD10          = {{Wp/nd/ICD10|U|06|9|a|}},
|ICD9           = {{Wp/nd/ICD9|066.3}}
|DiseasesDB     =36480
|MedlinePlus    =007666
|eMedicineSubj  =
|eMedicineTopic =
|MeSH       =D000071243
}}
&lt;!-- Definition and symptoms --&gt;
'''Umgomani weZika''' (owaziwa godu'''ngomulwana weZika''') bulwelwe [[obubangwa mumulwana iZika]].&lt;ref name=&quot;WHO2016Jan&quot;&gt;{{Wp/nd/cite web | url=http://www.who.int/mediacentre/factsheets/zika/en/ | title=Zika virus | publisher=World Health Organization | date=January 2016 | accessdate=3 February 2016}}&lt;/ref&gt;Esikhathini esinengi izehlakalo ezibikwako azinawo amatshwayo wokugula, kodwana nangabe akhona kuzwakala ukufuthumala[[ nomgomani womzimba obuhlungu]].&lt;ref name=&quot;WHO2016Jan&quot; /&gt;&lt;ref name=&quot;ecdc1&quot;&gt;{{Wp/nd/cite web | url=http://ecdc.europa.eu/en/healthtopics/zika_virus_infection/factsheet-health-professionals/Pages/factsheet_health_professionals.aspx | title=Factsheet for health professionals | publisher=European Centre for Disease Prevention and Control | work=Zika virus infection | accessdate=22 December 2015}}&lt;/ref&gt; Amatshwayo angafaka hlangana [[umgomani nehloko ebuhlungu]], [[amehlo|abovu]], [[i-arthralgia|ubuhlungu balapha kuhlangana khona amathambo]] ihloko esawula kabuhlungu, kanye [[neratjhi elumako]].&lt;ref name=WHO2016Jan/&gt;&lt;ref name=Ann2016/&gt;&lt;ref name=&quot;Musso14&quot;&gt;{{Wp/nd/cite journal | url=http://linkinghub.elsevier.com/retrieve/pii/S1198743X1465391X | title=Rapid spread of emerging Zika virus in the Pacific area | last=Musso | first=D. | last2=Nilles | first2=E.J. | last3=Cao-Lormeau | first3=V.-M. | journal=Clinical Microbiology and Infection | year=2014 | volume=20 | issue=10 | pages=O595–6 | doi=10.1111/1469-0691.12707 | pmid=24909208}}&lt;/ref&gt; Amatshwayo la abonala amalanga angaphasi kwalikhomba.&lt;ref name=Ann2016/&gt; Akhange bubange ukufa komuntu lokha nakasathoma ukubonakala.&lt;ref name=&quot;ecdc1&quot;/&gt;Ubulwelwe lobu buhlotjaniswe[[ne-Guillain–Barré syndrom]] (GBS0.&lt;ref name=&quot;ecdc1&quot;/&gt; 

&lt;!-- Cause and diagnosis --&gt;
Umgomani weZika usabalaliseka nofana utheleleka ngokulunywa [[ngunompopoloza]] womhlobo ''[[i-Aedes]]'' okhethekileko.&lt;ref name=Ann2016/&gt;Ungatheleleka [[godu ngokuya emsemeni|ukuya emsemeni]] ukusuka endodeni ukuya kiloyo alala naye[[bese ubulwelwe lobu bungatheleleka ngokungenelana kweengaz]]i. &lt;ref name=CDC2016&gt;{{Wp/nd/cite journal|last1=Oster|first1=Alexandra M.|last2=Russell|first2=Kate|last3=Stryker|first3=Jo Ellen|last4=Friedman|first4=Allison|last5=Kachur|first5=Rachel E.|last6=Petersen|first6=Emily E.|last7=Jamieson|first7=Denise J.|last8=Cohn|first8=Amanda C.|last9=Brooks|first9=John T.|title=Update: Interim Guidance for Prevention of Sexual Transmission of Zika Virus — United States, 2016|journal=MMWR. Morbidity and Mortality Weekly Report|date=1 April 2016|volume=65|issue=12|pages=323–325|doi=10.15585/mmwr.mm6512e3|pmid = 27032078}}&lt;/ref&gt;&lt;ref name=Ann2016/&gt; Ukutheleleka kilabo abafazi abasidisi abazithweleko kungatheleleka nemntwaneni[[ngombana khekwahlotjaniswa]]nokufoloza ukuhlongakala kwabantwana bangakabelethwa [[kanye nokubelethwa kwabantwana abaneenhloko ezincani ngokungakajayeki]].&lt;ref name=WHO2016Jan/&gt;&lt;ref name=&quot;ChanChoi2016&quot;&gt;{{Wp/nd/cite journal | first1=Jasper F.W. | last1=Chan | url=https://www.ncbi.nlm.nih.gov/pubmed/26940504 | title=Zika fever and congenital Zika syndrome: An unexpected emerging arboviral disease | last2=Choi | first2=Garnet K.Y. | last3=Yip | first3=Cyril C.Y. | last4=Cheng | first4=Vincent C.C. | last5=Yuen | first5=Kwok-Yung | journal=Journal of Infection | year=2016 | issn=01634453 | doi=10.1016/j.jinf.2016.02.011 | pmid=26940504 | display-authors=3}}&lt;/ref&gt; Ukutholwa komrabho wobulwelwe lobu kwenziwa ngokuhlola igazi, umthondo, nofana amathe kuqalwe ubukhona bomgomani i-Zika[[RNA]] lokha umuntu nakagulako.&lt;ref name=WHO2016Jan/&gt;&lt;ref name=Ann2016/&gt;

&lt;!-- Prevention and treatment --&gt;
Ukukhandela ubulwelwe lobu kufaka hlangana ukwehlisa ukuba khona kwabonompopoloza abalumako eendaweni lapha badlange khona kanye nokusebenzisa ikhpndomu nawuya emsemeni.&lt;ref name=&quot;Ann2016&quot;&gt;{{Wp/nd/cite journal | first1=Lin H. | last1=Chen | url=http://annals.org/article.aspx?articleid=2486362 | title=Zika Virus: Rapid Spread in the Western Hemisphere | last2=Hamer | first2=Davidson H. | journal=Annals of Internal Medicine | year=2016 | issn=0003-4819 | doi=10.7326/M16-0150}}&lt;/ref&gt;&lt;ref name=CDC2016/&gt; Imizamo yokwehlisa ukulunywa kufaka hlangana[[nokusebenzisa iinhlanhla ezibulala iinunwana]] ukuvala umzimba wakho ngezambatho[[ iinhlanhla ezibulala abonompopoloza]], nokususa amazni ajamileko angakhambiko lapha abonompopoloza bangathola khona ithuba lokwanda.&lt;ref name=WHO2016Jan/&gt; Aasikho isihlahla[[nofana imijovo esebenza ukulapha ubulwelobu]].&lt;ref name=Ann2016/&gt; Abasebezi bezamaphilo banyule ukuthi abafazi abahlala lapho kudlange khona ubulwelwe bomgomani weZika[[bomgomani weZika (2015–bekube nje)|2015-16 ukuqubuka kobulwelwe bomgomani iZika]] bathathe isiqunto sokobana bangabi nabantwana begodu abafazi abasidisi bangayi eendaweni lapaha kudlange ubulwelwe lobu.&lt;ref name=Ann2016/&gt;&lt;ref name=&quot;cnn1&quot;&gt;{{Wp/nd/cite news | url=http://www.cnn.com/2015/12/23/health/brazil-zika-pregnancy-warning/index.html | title=Brazil warns against pregnancy due to spreading virus | work=CNN | date=24 December 2015 | accessdate=24 December 2015}}&lt;/ref&gt; Njengombana akunasihlahla sokulapha ubulwelwe lobu,[[ amapeli wehlono neenhlungu i-paracetamol]]i- (acetaminophen) zingasiza lokha nawubona amatshwayo wobulwelobu.&lt;ref name=Ann2016/&gt; Ukuyokungeniswa esibhedlela akukavami.&lt;ref name=&quot;ecdc1&quot;/&gt; 

&lt;!-- History and epidemiology --&gt;
Umulwana obanga ubulwelwe lobu watholakala ngo-1947.&lt;ref name=&quot;OlsonHaddow2012&quot;&gt;{{Wp/nd/cite journal | display-authors=3 | first1=Ken E. | first10=Scott C. | first3=Amy J. | first7=Rekol | last1=Olson | last10=Weaver | title=Genetic Characterization of Zika Virus Strains: Geographic Expansion of the Asian Lineage | last2=Haddow | first2=Andrew D. | last3=Schuh | last4=Yasuda | first4=Chadwick Y. | last5=Kasper | first5=Matthew R. | last6=Heang | first6=Vireak | last7=Huy | last8=Guzman | first8=Hilda | last9=Tesh | first9=Robert B. | journal=PLoS Neglected Tropical Diseases | year=2012 | volume=6 | issue=2 | pages=e1477 | issn=1935-2735 | doi=10.1371/journal.pntd.0001477 | pmid=22389730 | pmc=3289602}}&lt;/ref&gt; Ukutholaka kokuthoma kokuqubuka kobulwelwe lobu kwavela ngo-2007 [[e-Federated States ye- Micronesia]].&lt;ref name=Ann2016/&gt; {{Ukusukela|ngoTjhirhweni 2016}}ubulwelwe lobu buqubuke eengodini ezimatjhumi amabili[[nge-Amerikha]].&lt;ref name=Ann2016/&gt; Kuthiwa buqubuke ne-Afrika, e-Asia kanye ne-Pacific.&lt;ref name=WHO2016Jan/&gt; Ngesibanga sokuqubuka kwabo ubulwelobu eBrazil ngo2015,i[[World Health Oeganization]]iikhiphe umbiko orhabako[[ngobungozi obukhna Emphakathini keZamaphilo eenTjhabatjhabeni zoke]] ngenyaka kaMhlolanja 2016.&lt;ref name=&quot;who1&quot;&gt;{{Wp/nd/cite web | url=http://www.who.int/mediacentre/news/statements/2016/emergency-committee-zika-microcephaly/en/ | title=WHO Director-General summarizes the outcome of the Emergency Committee regarding clusters of microcephaly and Guillain-Barré syndrome | work=Media Centre | publisher=World Health Organization | date=1 February 2016 | accessdate=3 February 2016}}&lt;/ref&gt;

==Isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini==
&lt;references /&gt;</text>
      <sha1>16nzy77fvz9heyrqetyczjza06awvc9</sha1>
    </revision>
    <revision>
      <id>1926</id>
      <parentid>1925</parentid>
      <timestamp>2022-05-13T22:11:56Z</timestamp>
      <contributor>
        <username>incubator&gt;1234qwer1234qwer4</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>+[[Category:Wp/nd]]; [[toolforge:quickcategories/batch/4630/|QuickCategories batch #4630]]</comment>
      <origin>1926</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7540" sha1="8ky9bi14obm1x7dy2b6mgquwutflzi6" xml:space="preserve">{{Wp/nd/Infobox disease
|name           = Umgomani weZika
|image          = Alexius Salvador Zika-Virus.jpg
|caption        = Iratjhi ngesikhathi kutheleleke umgomani weZika
|pronunciation  = Zika {{IPAc-en|ˈ|z|iː|k|ə}}
|ICD10          = {{Wp/nd/ICD10|U|06|9|a|}},
|ICD9           = {{Wp/nd/ICD9|066.3}}
|DiseasesDB     =36480
|MedlinePlus    =007666
|eMedicineSubj  =
|eMedicineTopic =
|MeSH       =D000071243
}}
&lt;!-- Definition and symptoms --&gt;
'''Umgomani weZika''' (owaziwa godu'''ngomulwana weZika''') bulwelwe [[obubangwa mumulwana iZika]].&lt;ref name=&quot;WHO2016Jan&quot;&gt;{{Wp/nd/cite web | url=http://www.who.int/mediacentre/factsheets/zika/en/ | title=Zika virus | publisher=World Health Organization | date=January 2016 | accessdate=3 February 2016}}&lt;/ref&gt;Esikhathini esinengi izehlakalo ezibikwako azinawo amatshwayo wokugula, kodwana nangabe akhona kuzwakala ukufuthumala[[ nomgomani womzimba obuhlungu]].&lt;ref name=&quot;WHO2016Jan&quot; /&gt;&lt;ref name=&quot;ecdc1&quot;&gt;{{Wp/nd/cite web | url=http://ecdc.europa.eu/en/healthtopics/zika_virus_infection/factsheet-health-professionals/Pages/factsheet_health_professionals.aspx | title=Factsheet for health professionals | publisher=European Centre for Disease Prevention and Control | work=Zika virus infection | accessdate=22 December 2015}}&lt;/ref&gt; Amatshwayo angafaka hlangana [[umgomani nehloko ebuhlungu]], [[amehlo|abovu]], [[i-arthralgia|ubuhlungu balapha kuhlangana khona amathambo]] ihloko esawula kabuhlungu, kanye [[neratjhi elumako]].&lt;ref name=WHO2016Jan/&gt;&lt;ref name=Ann2016/&gt;&lt;ref name=&quot;Musso14&quot;&gt;{{Wp/nd/cite journal | url=http://linkinghub.elsevier.com/retrieve/pii/S1198743X1465391X | title=Rapid spread of emerging Zika virus in the Pacific area | last=Musso | first=D. | last2=Nilles | first2=E.J. | last3=Cao-Lormeau | first3=V.-M. | journal=Clinical Microbiology and Infection | year=2014 | volume=20 | issue=10 | pages=O595–6 | doi=10.1111/1469-0691.12707 | pmid=24909208}}&lt;/ref&gt; Amatshwayo la abonala amalanga angaphasi kwalikhomba.&lt;ref name=Ann2016/&gt; Akhange bubange ukufa komuntu lokha nakasathoma ukubonakala.&lt;ref name=&quot;ecdc1&quot;/&gt;Ubulwelwe lobu buhlotjaniswe[[ne-Guillain–Barré syndrom]] (GBS0.&lt;ref name=&quot;ecdc1&quot;/&gt; 

&lt;!-- Cause and diagnosis --&gt;
Umgomani weZika usabalaliseka nofana utheleleka ngokulunywa [[ngunompopoloza]] womhlobo ''[[i-Aedes]]'' okhethekileko.&lt;ref name=Ann2016/&gt;Ungatheleleka [[godu ngokuya emsemeni|ukuya emsemeni]] ukusuka endodeni ukuya kiloyo alala naye[[bese ubulwelwe lobu bungatheleleka ngokungenelana kweengaz]]i. &lt;ref name=CDC2016&gt;{{Wp/nd/cite journal|last1=Oster|first1=Alexandra M.|last2=Russell|first2=Kate|last3=Stryker|first3=Jo Ellen|last4=Friedman|first4=Allison|last5=Kachur|first5=Rachel E.|last6=Petersen|first6=Emily E.|last7=Jamieson|first7=Denise J.|last8=Cohn|first8=Amanda C.|last9=Brooks|first9=John T.|title=Update: Interim Guidance for Prevention of Sexual Transmission of Zika Virus — United States, 2016|journal=MMWR. Morbidity and Mortality Weekly Report|date=1 April 2016|volume=65|issue=12|pages=323–325|doi=10.15585/mmwr.mm6512e3|pmid = 27032078}}&lt;/ref&gt;&lt;ref name=Ann2016/&gt; Ukutheleleka kilabo abafazi abasidisi abazithweleko kungatheleleka nemntwaneni[[ngombana khekwahlotjaniswa]]nokufoloza ukuhlongakala kwabantwana bangakabelethwa [[kanye nokubelethwa kwabantwana abaneenhloko ezincani ngokungakajayeki]].&lt;ref name=WHO2016Jan/&gt;&lt;ref name=&quot;ChanChoi2016&quot;&gt;{{Wp/nd/cite journal | first1=Jasper F.W. | last1=Chan | url=https://www.ncbi.nlm.nih.gov/pubmed/26940504 | title=Zika fever and congenital Zika syndrome: An unexpected emerging arboviral disease | last2=Choi | first2=Garnet K.Y. | last3=Yip | first3=Cyril C.Y. | last4=Cheng | first4=Vincent C.C. | last5=Yuen | first5=Kwok-Yung | journal=Journal of Infection | year=2016 | issn=01634453 | doi=10.1016/j.jinf.2016.02.011 | pmid=26940504 | display-authors=3}}&lt;/ref&gt; Ukutholwa komrabho wobulwelwe lobu kwenziwa ngokuhlola igazi, umthondo, nofana amathe kuqalwe ubukhona bomgomani i-Zika[[RNA]] lokha umuntu nakagulako.&lt;ref name=WHO2016Jan/&gt;&lt;ref name=Ann2016/&gt;

&lt;!-- Prevention and treatment --&gt;
Ukukhandela ubulwelwe lobu kufaka hlangana ukwehlisa ukuba khona kwabonompopoloza abalumako eendaweni lapha badlange khona kanye nokusebenzisa ikhpndomu nawuya emsemeni.&lt;ref name=&quot;Ann2016&quot;&gt;{{Wp/nd/cite journal | first1=Lin H. | last1=Chen | url=http://annals.org/article.aspx?articleid=2486362 | title=Zika Virus: Rapid Spread in the Western Hemisphere | last2=Hamer | first2=Davidson H. | journal=Annals of Internal Medicine | year=2016 | issn=0003-4819 | doi=10.7326/M16-0150}}&lt;/ref&gt;&lt;ref name=CDC2016/&gt; Imizamo yokwehlisa ukulunywa kufaka hlangana[[nokusebenzisa iinhlanhla ezibulala iinunwana]] ukuvala umzimba wakho ngezambatho[[ iinhlanhla ezibulala abonompopoloza]], nokususa amazni ajamileko angakhambiko lapha abonompopoloza bangathola khona ithuba lokwanda.&lt;ref name=WHO2016Jan/&gt; Aasikho isihlahla[[nofana imijovo esebenza ukulapha ubulwelobu]].&lt;ref name=Ann2016/&gt; Abasebezi bezamaphilo banyule ukuthi abafazi abahlala lapho kudlange khona ubulwelwe bomgomani weZika[[bomgomani weZika (2015–bekube nje)|2015-16 ukuqubuka kobulwelwe bomgomani iZika]] bathathe isiqunto sokobana bangabi nabantwana begodu abafazi abasidisi bangayi eendaweni lapaha kudlange ubulwelwe lobu.&lt;ref name=Ann2016/&gt;&lt;ref name=&quot;cnn1&quot;&gt;{{Wp/nd/cite news | url=http://www.cnn.com/2015/12/23/health/brazil-zika-pregnancy-warning/index.html | title=Brazil warns against pregnancy due to spreading virus | work=CNN | date=24 December 2015 | accessdate=24 December 2015}}&lt;/ref&gt; Njengombana akunasihlahla sokulapha ubulwelwe lobu,[[ amapeli wehlono neenhlungu i-paracetamol]]i- (acetaminophen) zingasiza lokha nawubona amatshwayo wobulwelobu.&lt;ref name=Ann2016/&gt; Ukuyokungeniswa esibhedlela akukavami.&lt;ref name=&quot;ecdc1&quot;/&gt; 

&lt;!-- History and epidemiology --&gt;
Umulwana obanga ubulwelwe lobu watholakala ngo-1947.&lt;ref name=&quot;OlsonHaddow2012&quot;&gt;{{Wp/nd/cite journal | display-authors=3 | first1=Ken E. | first10=Scott C. | first3=Amy J. | first7=Rekol | last1=Olson | last10=Weaver | title=Genetic Characterization of Zika Virus Strains: Geographic Expansion of the Asian Lineage | last2=Haddow | first2=Andrew D. | last3=Schuh | last4=Yasuda | first4=Chadwick Y. | last5=Kasper | first5=Matthew R. | last6=Heang | first6=Vireak | last7=Huy | last8=Guzman | first8=Hilda | last9=Tesh | first9=Robert B. | journal=PLoS Neglected Tropical Diseases | year=2012 | volume=6 | issue=2 | pages=e1477 | issn=1935-2735 | doi=10.1371/journal.pntd.0001477 | pmid=22389730 | pmc=3289602}}&lt;/ref&gt; Ukutholaka kokuthoma kokuqubuka kobulwelwe lobu kwavela ngo-2007 [[e-Federated States ye- Micronesia]].&lt;ref name=Ann2016/&gt; {{Ukusukela|ngoTjhirhweni 2016}}ubulwelwe lobu buqubuke eengodini ezimatjhumi amabili[[nge-Amerikha]].&lt;ref name=Ann2016/&gt; Kuthiwa buqubuke ne-Afrika, e-Asia kanye ne-Pacific.&lt;ref name=WHO2016Jan/&gt; Ngesibanga sokuqubuka kwabo ubulwelobu eBrazil ngo2015,i[[World Health Oeganization]]iikhiphe umbiko orhabako[[ngobungozi obukhna Emphakathini keZamaphilo eenTjhabatjhabeni zoke]] ngenyaka kaMhlolanja 2016.&lt;ref name=&quot;who1&quot;&gt;{{Wp/nd/cite web | url=http://www.who.int/mediacentre/news/statements/2016/emergency-committee-zika-microcephaly/en/ | title=WHO Director-General summarizes the outcome of the Emergency Committee regarding clusters of microcephaly and Guillain-Barré syndrome | work=Media Centre | publisher=World Health Organization | date=1 February 2016 | accessdate=3 February 2016}}&lt;/ref&gt;

==Isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini==
&lt;references /&gt;
[[Category:Wp/nd]]</text>
      <sha1>8ky9bi14obm1x7dy2b6mgquwutflzi6</sha1>
    </revision>
    <revision>
      <id>1927</id>
      <parentid>1926</parentid>
      <timestamp>2024-11-18T17:41:39Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <minor />
      <comment>8 revisions imported from [[:incubator:Wp/nd/Umgomani_weZika]]</comment>
      <origin>1926</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7540" sha1="8ky9bi14obm1x7dy2b6mgquwutflzi6" xml:space="preserve">{{Wp/nd/Infobox disease
|name           = Umgomani weZika
|image          = Alexius Salvador Zika-Virus.jpg
|caption        = Iratjhi ngesikhathi kutheleleke umgomani weZika
|pronunciation  = Zika {{IPAc-en|ˈ|z|iː|k|ə}}
|ICD10          = {{Wp/nd/ICD10|U|06|9|a|}},
|ICD9           = {{Wp/nd/ICD9|066.3}}
|DiseasesDB     =36480
|MedlinePlus    =007666
|eMedicineSubj  =
|eMedicineTopic =
|MeSH       =D000071243
}}
&lt;!-- Definition and symptoms --&gt;
'''Umgomani weZika''' (owaziwa godu'''ngomulwana weZika''') bulwelwe [[obubangwa mumulwana iZika]].&lt;ref name=&quot;WHO2016Jan&quot;&gt;{{Wp/nd/cite web | url=http://www.who.int/mediacentre/factsheets/zika/en/ | title=Zika virus | publisher=World Health Organization | date=January 2016 | accessdate=3 February 2016}}&lt;/ref&gt;Esikhathini esinengi izehlakalo ezibikwako azinawo amatshwayo wokugula, kodwana nangabe akhona kuzwakala ukufuthumala[[ nomgomani womzimba obuhlungu]].&lt;ref name=&quot;WHO2016Jan&quot; /&gt;&lt;ref name=&quot;ecdc1&quot;&gt;{{Wp/nd/cite web | url=http://ecdc.europa.eu/en/healthtopics/zika_virus_infection/factsheet-health-professionals/Pages/factsheet_health_professionals.aspx | title=Factsheet for health professionals | publisher=European Centre for Disease Prevention and Control | work=Zika virus infection | accessdate=22 December 2015}}&lt;/ref&gt; Amatshwayo angafaka hlangana [[umgomani nehloko ebuhlungu]], [[amehlo|abovu]], [[i-arthralgia|ubuhlungu balapha kuhlangana khona amathambo]] ihloko esawula kabuhlungu, kanye [[neratjhi elumako]].&lt;ref name=WHO2016Jan/&gt;&lt;ref name=Ann2016/&gt;&lt;ref name=&quot;Musso14&quot;&gt;{{Wp/nd/cite journal | url=http://linkinghub.elsevier.com/retrieve/pii/S1198743X1465391X | title=Rapid spread of emerging Zika virus in the Pacific area | last=Musso | first=D. | last2=Nilles | first2=E.J. | last3=Cao-Lormeau | first3=V.-M. | journal=Clinical Microbiology and Infection | year=2014 | volume=20 | issue=10 | pages=O595–6 | doi=10.1111/1469-0691.12707 | pmid=24909208}}&lt;/ref&gt; Amatshwayo la abonala amalanga angaphasi kwalikhomba.&lt;ref name=Ann2016/&gt; Akhange bubange ukufa komuntu lokha nakasathoma ukubonakala.&lt;ref name=&quot;ecdc1&quot;/&gt;Ubulwelwe lobu buhlotjaniswe[[ne-Guillain–Barré syndrom]] (GBS0.&lt;ref name=&quot;ecdc1&quot;/&gt; 

&lt;!-- Cause and diagnosis --&gt;
Umgomani weZika usabalaliseka nofana utheleleka ngokulunywa [[ngunompopoloza]] womhlobo ''[[i-Aedes]]'' okhethekileko.&lt;ref name=Ann2016/&gt;Ungatheleleka [[godu ngokuya emsemeni|ukuya emsemeni]] ukusuka endodeni ukuya kiloyo alala naye[[bese ubulwelwe lobu bungatheleleka ngokungenelana kweengaz]]i. &lt;ref name=CDC2016&gt;{{Wp/nd/cite journal|last1=Oster|first1=Alexandra M.|last2=Russell|first2=Kate|last3=Stryker|first3=Jo Ellen|last4=Friedman|first4=Allison|last5=Kachur|first5=Rachel E.|last6=Petersen|first6=Emily E.|last7=Jamieson|first7=Denise J.|last8=Cohn|first8=Amanda C.|last9=Brooks|first9=John T.|title=Update: Interim Guidance for Prevention of Sexual Transmission of Zika Virus — United States, 2016|journal=MMWR. Morbidity and Mortality Weekly Report|date=1 April 2016|volume=65|issue=12|pages=323–325|doi=10.15585/mmwr.mm6512e3|pmid = 27032078}}&lt;/ref&gt;&lt;ref name=Ann2016/&gt; Ukutheleleka kilabo abafazi abasidisi abazithweleko kungatheleleka nemntwaneni[[ngombana khekwahlotjaniswa]]nokufoloza ukuhlongakala kwabantwana bangakabelethwa [[kanye nokubelethwa kwabantwana abaneenhloko ezincani ngokungakajayeki]].&lt;ref name=WHO2016Jan/&gt;&lt;ref name=&quot;ChanChoi2016&quot;&gt;{{Wp/nd/cite journal | first1=Jasper F.W. | last1=Chan | url=https://www.ncbi.nlm.nih.gov/pubmed/26940504 | title=Zika fever and congenital Zika syndrome: An unexpected emerging arboviral disease | last2=Choi | first2=Garnet K.Y. | last3=Yip | first3=Cyril C.Y. | last4=Cheng | first4=Vincent C.C. | last5=Yuen | first5=Kwok-Yung | journal=Journal of Infection | year=2016 | issn=01634453 | doi=10.1016/j.jinf.2016.02.011 | pmid=26940504 | display-authors=3}}&lt;/ref&gt; Ukutholwa komrabho wobulwelwe lobu kwenziwa ngokuhlola igazi, umthondo, nofana amathe kuqalwe ubukhona bomgomani i-Zika[[RNA]] lokha umuntu nakagulako.&lt;ref name=WHO2016Jan/&gt;&lt;ref name=Ann2016/&gt;

&lt;!-- Prevention and treatment --&gt;
Ukukhandela ubulwelwe lobu kufaka hlangana ukwehlisa ukuba khona kwabonompopoloza abalumako eendaweni lapha badlange khona kanye nokusebenzisa ikhpndomu nawuya emsemeni.&lt;ref name=&quot;Ann2016&quot;&gt;{{Wp/nd/cite journal | first1=Lin H. | last1=Chen | url=http://annals.org/article.aspx?articleid=2486362 | title=Zika Virus: Rapid Spread in the Western Hemisphere | last2=Hamer | first2=Davidson H. | journal=Annals of Internal Medicine | year=2016 | issn=0003-4819 | doi=10.7326/M16-0150}}&lt;/ref&gt;&lt;ref name=CDC2016/&gt; Imizamo yokwehlisa ukulunywa kufaka hlangana[[nokusebenzisa iinhlanhla ezibulala iinunwana]] ukuvala umzimba wakho ngezambatho[[ iinhlanhla ezibulala abonompopoloza]], nokususa amazni ajamileko angakhambiko lapha abonompopoloza bangathola khona ithuba lokwanda.&lt;ref name=WHO2016Jan/&gt; Aasikho isihlahla[[nofana imijovo esebenza ukulapha ubulwelobu]].&lt;ref name=Ann2016/&gt; Abasebezi bezamaphilo banyule ukuthi abafazi abahlala lapho kudlange khona ubulwelwe bomgomani weZika[[bomgomani weZika (2015–bekube nje)|2015-16 ukuqubuka kobulwelwe bomgomani iZika]] bathathe isiqunto sokobana bangabi nabantwana begodu abafazi abasidisi bangayi eendaweni lapaha kudlange ubulwelwe lobu.&lt;ref name=Ann2016/&gt;&lt;ref name=&quot;cnn1&quot;&gt;{{Wp/nd/cite news | url=http://www.cnn.com/2015/12/23/health/brazil-zika-pregnancy-warning/index.html | title=Brazil warns against pregnancy due to spreading virus | work=CNN | date=24 December 2015 | accessdate=24 December 2015}}&lt;/ref&gt; Njengombana akunasihlahla sokulapha ubulwelwe lobu,[[ amapeli wehlono neenhlungu i-paracetamol]]i- (acetaminophen) zingasiza lokha nawubona amatshwayo wobulwelobu.&lt;ref name=Ann2016/&gt; Ukuyokungeniswa esibhedlela akukavami.&lt;ref name=&quot;ecdc1&quot;/&gt; 

&lt;!-- History and epidemiology --&gt;
Umulwana obanga ubulwelwe lobu watholakala ngo-1947.&lt;ref name=&quot;OlsonHaddow2012&quot;&gt;{{Wp/nd/cite journal | display-authors=3 | first1=Ken E. | first10=Scott C. | first3=Amy J. | first7=Rekol | last1=Olson | last10=Weaver | title=Genetic Characterization of Zika Virus Strains: Geographic Expansion of the Asian Lineage | last2=Haddow | first2=Andrew D. | last3=Schuh | last4=Yasuda | first4=Chadwick Y. | last5=Kasper | first5=Matthew R. | last6=Heang | first6=Vireak | last7=Huy | last8=Guzman | first8=Hilda | last9=Tesh | first9=Robert B. | journal=PLoS Neglected Tropical Diseases | year=2012 | volume=6 | issue=2 | pages=e1477 | issn=1935-2735 | doi=10.1371/journal.pntd.0001477 | pmid=22389730 | pmc=3289602}}&lt;/ref&gt; Ukutholaka kokuthoma kokuqubuka kobulwelwe lobu kwavela ngo-2007 [[e-Federated States ye- Micronesia]].&lt;ref name=Ann2016/&gt; {{Ukusukela|ngoTjhirhweni 2016}}ubulwelwe lobu buqubuke eengodini ezimatjhumi amabili[[nge-Amerikha]].&lt;ref name=Ann2016/&gt; Kuthiwa buqubuke ne-Afrika, e-Asia kanye ne-Pacific.&lt;ref name=WHO2016Jan/&gt; Ngesibanga sokuqubuka kwabo ubulwelobu eBrazil ngo2015,i[[World Health Oeganization]]iikhiphe umbiko orhabako[[ngobungozi obukhna Emphakathini keZamaphilo eenTjhabatjhabeni zoke]] ngenyaka kaMhlolanja 2016.&lt;ref name=&quot;who1&quot;&gt;{{Wp/nd/cite web | url=http://www.who.int/mediacentre/news/statements/2016/emergency-committee-zika-microcephaly/en/ | title=WHO Director-General summarizes the outcome of the Emergency Committee regarding clusters of microcephaly and Guillain-Barré syndrome | work=Media Centre | publisher=World Health Organization | date=1 February 2016 | accessdate=3 February 2016}}&lt;/ref&gt;

==Isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini==
&lt;references /&gt;
[[Category:Wp/nd]]</text>
      <sha1>8ky9bi14obm1x7dy2b6mgquwutflzi6</sha1>
    </revision>
    <revision>
      <id>2010</id>
      <parentid>1927</parentid>
      <timestamp>2024-11-18T17:42:26Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <minor />
      <comment>Amire80 moved page [[Wp/nd/Umgomani weZika]] to [[Umgomani weZika]]</comment>
      <origin>1926</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7540" sha1="8ky9bi14obm1x7dy2b6mgquwutflzi6" xml:space="preserve">{{Wp/nd/Infobox disease
|name           = Umgomani weZika
|image          = Alexius Salvador Zika-Virus.jpg
|caption        = Iratjhi ngesikhathi kutheleleke umgomani weZika
|pronunciation  = Zika {{IPAc-en|ˈ|z|iː|k|ə}}
|ICD10          = {{Wp/nd/ICD10|U|06|9|a|}},
|ICD9           = {{Wp/nd/ICD9|066.3}}
|DiseasesDB     =36480
|MedlinePlus    =007666
|eMedicineSubj  =
|eMedicineTopic =
|MeSH       =D000071243
}}
&lt;!-- Definition and symptoms --&gt;
'''Umgomani weZika''' (owaziwa godu'''ngomulwana weZika''') bulwelwe [[obubangwa mumulwana iZika]].&lt;ref name=&quot;WHO2016Jan&quot;&gt;{{Wp/nd/cite web | url=http://www.who.int/mediacentre/factsheets/zika/en/ | title=Zika virus | publisher=World Health Organization | date=January 2016 | accessdate=3 February 2016}}&lt;/ref&gt;Esikhathini esinengi izehlakalo ezibikwako azinawo amatshwayo wokugula, kodwana nangabe akhona kuzwakala ukufuthumala[[ nomgomani womzimba obuhlungu]].&lt;ref name=&quot;WHO2016Jan&quot; /&gt;&lt;ref name=&quot;ecdc1&quot;&gt;{{Wp/nd/cite web | url=http://ecdc.europa.eu/en/healthtopics/zika_virus_infection/factsheet-health-professionals/Pages/factsheet_health_professionals.aspx | title=Factsheet for health professionals | publisher=European Centre for Disease Prevention and Control | work=Zika virus infection | accessdate=22 December 2015}}&lt;/ref&gt; Amatshwayo angafaka hlangana [[umgomani nehloko ebuhlungu]], [[amehlo|abovu]], [[i-arthralgia|ubuhlungu balapha kuhlangana khona amathambo]] ihloko esawula kabuhlungu, kanye [[neratjhi elumako]].&lt;ref name=WHO2016Jan/&gt;&lt;ref name=Ann2016/&gt;&lt;ref name=&quot;Musso14&quot;&gt;{{Wp/nd/cite journal | url=http://linkinghub.elsevier.com/retrieve/pii/S1198743X1465391X | title=Rapid spread of emerging Zika virus in the Pacific area | last=Musso | first=D. | last2=Nilles | first2=E.J. | last3=Cao-Lormeau | first3=V.-M. | journal=Clinical Microbiology and Infection | year=2014 | volume=20 | issue=10 | pages=O595–6 | doi=10.1111/1469-0691.12707 | pmid=24909208}}&lt;/ref&gt; Amatshwayo la abonala amalanga angaphasi kwalikhomba.&lt;ref name=Ann2016/&gt; Akhange bubange ukufa komuntu lokha nakasathoma ukubonakala.&lt;ref name=&quot;ecdc1&quot;/&gt;Ubulwelwe lobu buhlotjaniswe[[ne-Guillain–Barré syndrom]] (GBS0.&lt;ref name=&quot;ecdc1&quot;/&gt; 

&lt;!-- Cause and diagnosis --&gt;
Umgomani weZika usabalaliseka nofana utheleleka ngokulunywa [[ngunompopoloza]] womhlobo ''[[i-Aedes]]'' okhethekileko.&lt;ref name=Ann2016/&gt;Ungatheleleka [[godu ngokuya emsemeni|ukuya emsemeni]] ukusuka endodeni ukuya kiloyo alala naye[[bese ubulwelwe lobu bungatheleleka ngokungenelana kweengaz]]i. &lt;ref name=CDC2016&gt;{{Wp/nd/cite journal|last1=Oster|first1=Alexandra M.|last2=Russell|first2=Kate|last3=Stryker|first3=Jo Ellen|last4=Friedman|first4=Allison|last5=Kachur|first5=Rachel E.|last6=Petersen|first6=Emily E.|last7=Jamieson|first7=Denise J.|last8=Cohn|first8=Amanda C.|last9=Brooks|first9=John T.|title=Update: Interim Guidance for Prevention of Sexual Transmission of Zika Virus — United States, 2016|journal=MMWR. Morbidity and Mortality Weekly Report|date=1 April 2016|volume=65|issue=12|pages=323–325|doi=10.15585/mmwr.mm6512e3|pmid = 27032078}}&lt;/ref&gt;&lt;ref name=Ann2016/&gt; Ukutheleleka kilabo abafazi abasidisi abazithweleko kungatheleleka nemntwaneni[[ngombana khekwahlotjaniswa]]nokufoloza ukuhlongakala kwabantwana bangakabelethwa [[kanye nokubelethwa kwabantwana abaneenhloko ezincani ngokungakajayeki]].&lt;ref name=WHO2016Jan/&gt;&lt;ref name=&quot;ChanChoi2016&quot;&gt;{{Wp/nd/cite journal | first1=Jasper F.W. | last1=Chan | url=https://www.ncbi.nlm.nih.gov/pubmed/26940504 | title=Zika fever and congenital Zika syndrome: An unexpected emerging arboviral disease | last2=Choi | first2=Garnet K.Y. | last3=Yip | first3=Cyril C.Y. | last4=Cheng | first4=Vincent C.C. | last5=Yuen | first5=Kwok-Yung | journal=Journal of Infection | year=2016 | issn=01634453 | doi=10.1016/j.jinf.2016.02.011 | pmid=26940504 | display-authors=3}}&lt;/ref&gt; Ukutholwa komrabho wobulwelwe lobu kwenziwa ngokuhlola igazi, umthondo, nofana amathe kuqalwe ubukhona bomgomani i-Zika[[RNA]] lokha umuntu nakagulako.&lt;ref name=WHO2016Jan/&gt;&lt;ref name=Ann2016/&gt;

&lt;!-- Prevention and treatment --&gt;
Ukukhandela ubulwelwe lobu kufaka hlangana ukwehlisa ukuba khona kwabonompopoloza abalumako eendaweni lapha badlange khona kanye nokusebenzisa ikhpndomu nawuya emsemeni.&lt;ref name=&quot;Ann2016&quot;&gt;{{Wp/nd/cite journal | first1=Lin H. | last1=Chen | url=http://annals.org/article.aspx?articleid=2486362 | title=Zika Virus: Rapid Spread in the Western Hemisphere | last2=Hamer | first2=Davidson H. | journal=Annals of Internal Medicine | year=2016 | issn=0003-4819 | doi=10.7326/M16-0150}}&lt;/ref&gt;&lt;ref name=CDC2016/&gt; Imizamo yokwehlisa ukulunywa kufaka hlangana[[nokusebenzisa iinhlanhla ezibulala iinunwana]] ukuvala umzimba wakho ngezambatho[[ iinhlanhla ezibulala abonompopoloza]], nokususa amazni ajamileko angakhambiko lapha abonompopoloza bangathola khona ithuba lokwanda.&lt;ref name=WHO2016Jan/&gt; Aasikho isihlahla[[nofana imijovo esebenza ukulapha ubulwelobu]].&lt;ref name=Ann2016/&gt; Abasebezi bezamaphilo banyule ukuthi abafazi abahlala lapho kudlange khona ubulwelwe bomgomani weZika[[bomgomani weZika (2015–bekube nje)|2015-16 ukuqubuka kobulwelwe bomgomani iZika]] bathathe isiqunto sokobana bangabi nabantwana begodu abafazi abasidisi bangayi eendaweni lapaha kudlange ubulwelwe lobu.&lt;ref name=Ann2016/&gt;&lt;ref name=&quot;cnn1&quot;&gt;{{Wp/nd/cite news | url=http://www.cnn.com/2015/12/23/health/brazil-zika-pregnancy-warning/index.html | title=Brazil warns against pregnancy due to spreading virus | work=CNN | date=24 December 2015 | accessdate=24 December 2015}}&lt;/ref&gt; Njengombana akunasihlahla sokulapha ubulwelwe lobu,[[ amapeli wehlono neenhlungu i-paracetamol]]i- (acetaminophen) zingasiza lokha nawubona amatshwayo wobulwelobu.&lt;ref name=Ann2016/&gt; Ukuyokungeniswa esibhedlela akukavami.&lt;ref name=&quot;ecdc1&quot;/&gt; 

&lt;!-- History and epidemiology --&gt;
Umulwana obanga ubulwelwe lobu watholakala ngo-1947.&lt;ref name=&quot;OlsonHaddow2012&quot;&gt;{{Wp/nd/cite journal | display-authors=3 | first1=Ken E. | first10=Scott C. | first3=Amy J. | first7=Rekol | last1=Olson | last10=Weaver | title=Genetic Characterization of Zika Virus Strains: Geographic Expansion of the Asian Lineage | last2=Haddow | first2=Andrew D. | last3=Schuh | last4=Yasuda | first4=Chadwick Y. | last5=Kasper | first5=Matthew R. | last6=Heang | first6=Vireak | last7=Huy | last8=Guzman | first8=Hilda | last9=Tesh | first9=Robert B. | journal=PLoS Neglected Tropical Diseases | year=2012 | volume=6 | issue=2 | pages=e1477 | issn=1935-2735 | doi=10.1371/journal.pntd.0001477 | pmid=22389730 | pmc=3289602}}&lt;/ref&gt; Ukutholaka kokuthoma kokuqubuka kobulwelwe lobu kwavela ngo-2007 [[e-Federated States ye- Micronesia]].&lt;ref name=Ann2016/&gt; {{Ukusukela|ngoTjhirhweni 2016}}ubulwelwe lobu buqubuke eengodini ezimatjhumi amabili[[nge-Amerikha]].&lt;ref name=Ann2016/&gt; Kuthiwa buqubuke ne-Afrika, e-Asia kanye ne-Pacific.&lt;ref name=WHO2016Jan/&gt; Ngesibanga sokuqubuka kwabo ubulwelobu eBrazil ngo2015,i[[World Health Oeganization]]iikhiphe umbiko orhabako[[ngobungozi obukhna Emphakathini keZamaphilo eenTjhabatjhabeni zoke]] ngenyaka kaMhlolanja 2016.&lt;ref name=&quot;who1&quot;&gt;{{Wp/nd/cite web | url=http://www.who.int/mediacentre/news/statements/2016/emergency-committee-zika-microcephaly/en/ | title=WHO Director-General summarizes the outcome of the Emergency Committee regarding clusters of microcephaly and Guillain-Barré syndrome | work=Media Centre | publisher=World Health Organization | date=1 February 2016 | accessdate=3 February 2016}}&lt;/ref&gt;

==Isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini==
&lt;references /&gt;
[[Category:Wp/nd]]</text>
      <sha1>8ky9bi14obm1x7dy2b6mgquwutflzi6</sha1>
    </revision>
    <revision>
      <id>2207</id>
      <parentid>2010</parentid>
      <timestamp>2024-11-29T07:29:13Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <comment>/* Isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini */Reflist</comment>
      <origin>2207</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7537" sha1="hl9ouka07puox59h1hvkyyl2qk77ygs" xml:space="preserve">{{Wp/nd/Infobox disease
|name           = Umgomani weZika
|image          = Alexius Salvador Zika-Virus.jpg
|caption        = Iratjhi ngesikhathi kutheleleke umgomani weZika
|pronunciation  = Zika {{IPAc-en|ˈ|z|iː|k|ə}}
|ICD10          = {{Wp/nd/ICD10|U|06|9|a|}},
|ICD9           = {{Wp/nd/ICD9|066.3}}
|DiseasesDB     =36480
|MedlinePlus    =007666
|eMedicineSubj  =
|eMedicineTopic =
|MeSH       =D000071243
}}
&lt;!-- Definition and symptoms --&gt;
'''Umgomani weZika''' (owaziwa godu'''ngomulwana weZika''') bulwelwe [[obubangwa mumulwana iZika]].&lt;ref name=&quot;WHO2016Jan&quot;&gt;{{Wp/nd/cite web | url=http://www.who.int/mediacentre/factsheets/zika/en/ | title=Zika virus | publisher=World Health Organization | date=January 2016 | accessdate=3 February 2016}}&lt;/ref&gt;Esikhathini esinengi izehlakalo ezibikwako azinawo amatshwayo wokugula, kodwana nangabe akhona kuzwakala ukufuthumala[[ nomgomani womzimba obuhlungu]].&lt;ref name=&quot;WHO2016Jan&quot; /&gt;&lt;ref name=&quot;ecdc1&quot;&gt;{{Wp/nd/cite web | url=http://ecdc.europa.eu/en/healthtopics/zika_virus_infection/factsheet-health-professionals/Pages/factsheet_health_professionals.aspx | title=Factsheet for health professionals | publisher=European Centre for Disease Prevention and Control | work=Zika virus infection | accessdate=22 December 2015}}&lt;/ref&gt; Amatshwayo angafaka hlangana [[umgomani nehloko ebuhlungu]], [[amehlo|abovu]], [[i-arthralgia|ubuhlungu balapha kuhlangana khona amathambo]] ihloko esawula kabuhlungu, kanye [[neratjhi elumako]].&lt;ref name=WHO2016Jan/&gt;&lt;ref name=Ann2016/&gt;&lt;ref name=&quot;Musso14&quot;&gt;{{Wp/nd/cite journal | url=http://linkinghub.elsevier.com/retrieve/pii/S1198743X1465391X | title=Rapid spread of emerging Zika virus in the Pacific area | last=Musso | first=D. | last2=Nilles | first2=E.J. | last3=Cao-Lormeau | first3=V.-M. | journal=Clinical Microbiology and Infection | year=2014 | volume=20 | issue=10 | pages=O595–6 | doi=10.1111/1469-0691.12707 | pmid=24909208}}&lt;/ref&gt; Amatshwayo la abonala amalanga angaphasi kwalikhomba.&lt;ref name=Ann2016/&gt; Akhange bubange ukufa komuntu lokha nakasathoma ukubonakala.&lt;ref name=&quot;ecdc1&quot;/&gt;Ubulwelwe lobu buhlotjaniswe[[ne-Guillain–Barré syndrom]] (GBS0.&lt;ref name=&quot;ecdc1&quot;/&gt; 

&lt;!-- Cause and diagnosis --&gt;
Umgomani weZika usabalaliseka nofana utheleleka ngokulunywa [[ngunompopoloza]] womhlobo ''[[i-Aedes]]'' okhethekileko.&lt;ref name=Ann2016/&gt;Ungatheleleka [[godu ngokuya emsemeni|ukuya emsemeni]] ukusuka endodeni ukuya kiloyo alala naye[[bese ubulwelwe lobu bungatheleleka ngokungenelana kweengaz]]i. &lt;ref name=CDC2016&gt;{{Wp/nd/cite journal|last1=Oster|first1=Alexandra M.|last2=Russell|first2=Kate|last3=Stryker|first3=Jo Ellen|last4=Friedman|first4=Allison|last5=Kachur|first5=Rachel E.|last6=Petersen|first6=Emily E.|last7=Jamieson|first7=Denise J.|last8=Cohn|first8=Amanda C.|last9=Brooks|first9=John T.|title=Update: Interim Guidance for Prevention of Sexual Transmission of Zika Virus — United States, 2016|journal=MMWR. Morbidity and Mortality Weekly Report|date=1 April 2016|volume=65|issue=12|pages=323–325|doi=10.15585/mmwr.mm6512e3|pmid = 27032078}}&lt;/ref&gt;&lt;ref name=Ann2016/&gt; Ukutheleleka kilabo abafazi abasidisi abazithweleko kungatheleleka nemntwaneni[[ngombana khekwahlotjaniswa]]nokufoloza ukuhlongakala kwabantwana bangakabelethwa [[kanye nokubelethwa kwabantwana abaneenhloko ezincani ngokungakajayeki]].&lt;ref name=WHO2016Jan/&gt;&lt;ref name=&quot;ChanChoi2016&quot;&gt;{{Wp/nd/cite journal | first1=Jasper F.W. | last1=Chan | url=https://www.ncbi.nlm.nih.gov/pubmed/26940504 | title=Zika fever and congenital Zika syndrome: An unexpected emerging arboviral disease | last2=Choi | first2=Garnet K.Y. | last3=Yip | first3=Cyril C.Y. | last4=Cheng | first4=Vincent C.C. | last5=Yuen | first5=Kwok-Yung | journal=Journal of Infection | year=2016 | issn=01634453 | doi=10.1016/j.jinf.2016.02.011 | pmid=26940504 | display-authors=3}}&lt;/ref&gt; Ukutholwa komrabho wobulwelwe lobu kwenziwa ngokuhlola igazi, umthondo, nofana amathe kuqalwe ubukhona bomgomani i-Zika[[RNA]] lokha umuntu nakagulako.&lt;ref name=WHO2016Jan/&gt;&lt;ref name=Ann2016/&gt;

&lt;!-- Prevention and treatment --&gt;
Ukukhandela ubulwelwe lobu kufaka hlangana ukwehlisa ukuba khona kwabonompopoloza abalumako eendaweni lapha badlange khona kanye nokusebenzisa ikhpndomu nawuya emsemeni.&lt;ref name=&quot;Ann2016&quot;&gt;{{Wp/nd/cite journal | first1=Lin H. | last1=Chen | url=http://annals.org/article.aspx?articleid=2486362 | title=Zika Virus: Rapid Spread in the Western Hemisphere | last2=Hamer | first2=Davidson H. | journal=Annals of Internal Medicine | year=2016 | issn=0003-4819 | doi=10.7326/M16-0150}}&lt;/ref&gt;&lt;ref name=CDC2016/&gt; Imizamo yokwehlisa ukulunywa kufaka hlangana[[nokusebenzisa iinhlanhla ezibulala iinunwana]] ukuvala umzimba wakho ngezambatho[[ iinhlanhla ezibulala abonompopoloza]], nokususa amazni ajamileko angakhambiko lapha abonompopoloza bangathola khona ithuba lokwanda.&lt;ref name=WHO2016Jan/&gt; Aasikho isihlahla[[nofana imijovo esebenza ukulapha ubulwelobu]].&lt;ref name=Ann2016/&gt; Abasebezi bezamaphilo banyule ukuthi abafazi abahlala lapho kudlange khona ubulwelwe bomgomani weZika[[bomgomani weZika (2015–bekube nje)|2015-16 ukuqubuka kobulwelwe bomgomani iZika]] bathathe isiqunto sokobana bangabi nabantwana begodu abafazi abasidisi bangayi eendaweni lapaha kudlange ubulwelwe lobu.&lt;ref name=Ann2016/&gt;&lt;ref name=&quot;cnn1&quot;&gt;{{Wp/nd/cite news | url=http://www.cnn.com/2015/12/23/health/brazil-zika-pregnancy-warning/index.html | title=Brazil warns against pregnancy due to spreading virus | work=CNN | date=24 December 2015 | accessdate=24 December 2015}}&lt;/ref&gt; Njengombana akunasihlahla sokulapha ubulwelwe lobu,[[ amapeli wehlono neenhlungu i-paracetamol]]i- (acetaminophen) zingasiza lokha nawubona amatshwayo wobulwelobu.&lt;ref name=Ann2016/&gt; Ukuyokungeniswa esibhedlela akukavami.&lt;ref name=&quot;ecdc1&quot;/&gt; 

&lt;!-- History and epidemiology --&gt;
Umulwana obanga ubulwelwe lobu watholakala ngo-1947.&lt;ref name=&quot;OlsonHaddow2012&quot;&gt;{{Wp/nd/cite journal | display-authors=3 | first1=Ken E. | first10=Scott C. | first3=Amy J. | first7=Rekol | last1=Olson | last10=Weaver | title=Genetic Characterization of Zika Virus Strains: Geographic Expansion of the Asian Lineage | last2=Haddow | first2=Andrew D. | last3=Schuh | last4=Yasuda | first4=Chadwick Y. | last5=Kasper | first5=Matthew R. | last6=Heang | first6=Vireak | last7=Huy | last8=Guzman | first8=Hilda | last9=Tesh | first9=Robert B. | journal=PLoS Neglected Tropical Diseases | year=2012 | volume=6 | issue=2 | pages=e1477 | issn=1935-2735 | doi=10.1371/journal.pntd.0001477 | pmid=22389730 | pmc=3289602}}&lt;/ref&gt; Ukutholaka kokuthoma kokuqubuka kobulwelwe lobu kwavela ngo-2007 [[e-Federated States ye- Micronesia]].&lt;ref name=Ann2016/&gt; {{Ukusukela|ngoTjhirhweni 2016}}ubulwelwe lobu buqubuke eengodini ezimatjhumi amabili[[nge-Amerikha]].&lt;ref name=Ann2016/&gt; Kuthiwa buqubuke ne-Afrika, e-Asia kanye ne-Pacific.&lt;ref name=WHO2016Jan/&gt; Ngesibanga sokuqubuka kwabo ubulwelobu eBrazil ngo2015,i[[World Health Oeganization]]iikhiphe umbiko orhabako[[ngobungozi obukhna Emphakathini keZamaphilo eenTjhabatjhabeni zoke]] ngenyaka kaMhlolanja 2016.&lt;ref name=&quot;who1&quot;&gt;{{Wp/nd/cite web | url=http://www.who.int/mediacentre/news/statements/2016/emergency-committee-zika-microcephaly/en/ | title=WHO Director-General summarizes the outcome of the Emergency Committee regarding clusters of microcephaly and Guillain-Barré syndrome | work=Media Centre | publisher=World Health Organization | date=1 February 2016 | accessdate=3 February 2016}}&lt;/ref&gt;

==Isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini==
{{Reflist}}

[[Mkhakha:Wp/nd]]</text>
      <sha1>hl9ouka07puox59h1hvkyyl2qk77ygs</sha1>
    </revision>
    <revision>
      <id>2208</id>
      <parentid>2207</parentid>
      <timestamp>2024-11-29T07:30:22Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* Isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini */who.int</comment>
      <origin>2208</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7549" sha1="du1hznd257ybzadwb04ggjkjx88pusf" xml:space="preserve">{{Wp/nd/Infobox disease
|name           = Umgomani weZika
|image          = Alexius Salvador Zika-Virus.jpg
|caption        = Iratjhi ngesikhathi kutheleleke umgomani weZika
|pronunciation  = Zika {{IPAc-en|ˈ|z|iː|k|ə}}
|ICD10          = {{Wp/nd/ICD10|U|06|9|a|}},
|ICD9           = {{Wp/nd/ICD9|066.3}}
|DiseasesDB     =36480
|MedlinePlus    =007666
|eMedicineSubj  =
|eMedicineTopic =
|MeSH       =D000071243
}}
&lt;!-- Definition and symptoms --&gt;
'''Umgomani weZika''' (owaziwa godu'''ngomulwana weZika''') bulwelwe [[obubangwa mumulwana iZika]].&lt;ref name=&quot;WHO2016Jan&quot;&gt;{{Wp/nd/cite web | url=https://www.who.int/en/news-room/fact-sheets/detail/zika-virus | title=Zika virus | publisher=World Health Organization | date=January 2016 | accessdate=3 February 2016}}&lt;/ref&gt;Esikhathini esinengi izehlakalo ezibikwako azinawo amatshwayo wokugula, kodwana nangabe akhona kuzwakala ukufuthumala[[ nomgomani womzimba obuhlungu]].&lt;ref name=&quot;WHO2016Jan&quot; /&gt;&lt;ref name=&quot;ecdc1&quot;&gt;{{Wp/nd/cite web | url=http://ecdc.europa.eu/en/healthtopics/zika_virus_infection/factsheet-health-professionals/Pages/factsheet_health_professionals.aspx | title=Factsheet for health professionals | publisher=European Centre for Disease Prevention and Control | work=Zika virus infection | accessdate=22 December 2015}}&lt;/ref&gt; Amatshwayo angafaka hlangana [[umgomani nehloko ebuhlungu]], [[amehlo|abovu]], [[i-arthralgia|ubuhlungu balapha kuhlangana khona amathambo]] ihloko esawula kabuhlungu, kanye [[neratjhi elumako]].&lt;ref name=WHO2016Jan/&gt;&lt;ref name=Ann2016/&gt;&lt;ref name=&quot;Musso14&quot;&gt;{{Wp/nd/cite journal | url=http://linkinghub.elsevier.com/retrieve/pii/S1198743X1465391X | title=Rapid spread of emerging Zika virus in the Pacific area | last=Musso | first=D. | last2=Nilles | first2=E.J. | last3=Cao-Lormeau | first3=V.-M. | journal=Clinical Microbiology and Infection | year=2014 | volume=20 | issue=10 | pages=O595–6 | doi=10.1111/1469-0691.12707 | pmid=24909208}}&lt;/ref&gt; Amatshwayo la abonala amalanga angaphasi kwalikhomba.&lt;ref name=Ann2016/&gt; Akhange bubange ukufa komuntu lokha nakasathoma ukubonakala.&lt;ref name=&quot;ecdc1&quot;/&gt;Ubulwelwe lobu buhlotjaniswe[[ne-Guillain–Barré syndrom]] (GBS0.&lt;ref name=&quot;ecdc1&quot;/&gt; 

&lt;!-- Cause and diagnosis --&gt;
Umgomani weZika usabalaliseka nofana utheleleka ngokulunywa [[ngunompopoloza]] womhlobo ''[[i-Aedes]]'' okhethekileko.&lt;ref name=Ann2016/&gt;Ungatheleleka [[godu ngokuya emsemeni|ukuya emsemeni]] ukusuka endodeni ukuya kiloyo alala naye[[bese ubulwelwe lobu bungatheleleka ngokungenelana kweengaz]]i. &lt;ref name=CDC2016&gt;{{Wp/nd/cite journal|last1=Oster|first1=Alexandra M.|last2=Russell|first2=Kate|last3=Stryker|first3=Jo Ellen|last4=Friedman|first4=Allison|last5=Kachur|first5=Rachel E.|last6=Petersen|first6=Emily E.|last7=Jamieson|first7=Denise J.|last8=Cohn|first8=Amanda C.|last9=Brooks|first9=John T.|title=Update: Interim Guidance for Prevention of Sexual Transmission of Zika Virus — United States, 2016|journal=MMWR. Morbidity and Mortality Weekly Report|date=1 April 2016|volume=65|issue=12|pages=323–325|doi=10.15585/mmwr.mm6512e3|pmid = 27032078}}&lt;/ref&gt;&lt;ref name=Ann2016/&gt; Ukutheleleka kilabo abafazi abasidisi abazithweleko kungatheleleka nemntwaneni[[ngombana khekwahlotjaniswa]]nokufoloza ukuhlongakala kwabantwana bangakabelethwa [[kanye nokubelethwa kwabantwana abaneenhloko ezincani ngokungakajayeki]].&lt;ref name=WHO2016Jan/&gt;&lt;ref name=&quot;ChanChoi2016&quot;&gt;{{Wp/nd/cite journal | first1=Jasper F.W. | last1=Chan | url=https://www.ncbi.nlm.nih.gov/pubmed/26940504 | title=Zika fever and congenital Zika syndrome: An unexpected emerging arboviral disease | last2=Choi | first2=Garnet K.Y. | last3=Yip | first3=Cyril C.Y. | last4=Cheng | first4=Vincent C.C. | last5=Yuen | first5=Kwok-Yung | journal=Journal of Infection | year=2016 | issn=01634453 | doi=10.1016/j.jinf.2016.02.011 | pmid=26940504 | display-authors=3}}&lt;/ref&gt; Ukutholwa komrabho wobulwelwe lobu kwenziwa ngokuhlola igazi, umthondo, nofana amathe kuqalwe ubukhona bomgomani i-Zika[[RNA]] lokha umuntu nakagulako.&lt;ref name=WHO2016Jan/&gt;&lt;ref name=Ann2016/&gt;

&lt;!-- Prevention and treatment --&gt;
Ukukhandela ubulwelwe lobu kufaka hlangana ukwehlisa ukuba khona kwabonompopoloza abalumako eendaweni lapha badlange khona kanye nokusebenzisa ikhpndomu nawuya emsemeni.&lt;ref name=&quot;Ann2016&quot;&gt;{{Wp/nd/cite journal | first1=Lin H. | last1=Chen | url=http://annals.org/article.aspx?articleid=2486362 | title=Zika Virus: Rapid Spread in the Western Hemisphere | last2=Hamer | first2=Davidson H. | journal=Annals of Internal Medicine | year=2016 | issn=0003-4819 | doi=10.7326/M16-0150}}&lt;/ref&gt;&lt;ref name=CDC2016/&gt; Imizamo yokwehlisa ukulunywa kufaka hlangana[[nokusebenzisa iinhlanhla ezibulala iinunwana]] ukuvala umzimba wakho ngezambatho[[ iinhlanhla ezibulala abonompopoloza]], nokususa amazni ajamileko angakhambiko lapha abonompopoloza bangathola khona ithuba lokwanda.&lt;ref name=WHO2016Jan/&gt; Aasikho isihlahla[[nofana imijovo esebenza ukulapha ubulwelobu]].&lt;ref name=Ann2016/&gt; Abasebezi bezamaphilo banyule ukuthi abafazi abahlala lapho kudlange khona ubulwelwe bomgomani weZika[[bomgomani weZika (2015–bekube nje)|2015-16 ukuqubuka kobulwelwe bomgomani iZika]] bathathe isiqunto sokobana bangabi nabantwana begodu abafazi abasidisi bangayi eendaweni lapaha kudlange ubulwelwe lobu.&lt;ref name=Ann2016/&gt;&lt;ref name=&quot;cnn1&quot;&gt;{{Wp/nd/cite news | url=http://www.cnn.com/2015/12/23/health/brazil-zika-pregnancy-warning/index.html | title=Brazil warns against pregnancy due to spreading virus | work=CNN | date=24 December 2015 | accessdate=24 December 2015}}&lt;/ref&gt; Njengombana akunasihlahla sokulapha ubulwelwe lobu,[[ amapeli wehlono neenhlungu i-paracetamol]]i- (acetaminophen) zingasiza lokha nawubona amatshwayo wobulwelobu.&lt;ref name=Ann2016/&gt; Ukuyokungeniswa esibhedlela akukavami.&lt;ref name=&quot;ecdc1&quot;/&gt; 

&lt;!-- History and epidemiology --&gt;
Umulwana obanga ubulwelwe lobu watholakala ngo-1947.&lt;ref name=&quot;OlsonHaddow2012&quot;&gt;{{Wp/nd/cite journal | display-authors=3 | first1=Ken E. | first10=Scott C. | first3=Amy J. | first7=Rekol | last1=Olson | last10=Weaver | title=Genetic Characterization of Zika Virus Strains: Geographic Expansion of the Asian Lineage | last2=Haddow | first2=Andrew D. | last3=Schuh | last4=Yasuda | first4=Chadwick Y. | last5=Kasper | first5=Matthew R. | last6=Heang | first6=Vireak | last7=Huy | last8=Guzman | first8=Hilda | last9=Tesh | first9=Robert B. | journal=PLoS Neglected Tropical Diseases | year=2012 | volume=6 | issue=2 | pages=e1477 | issn=1935-2735 | doi=10.1371/journal.pntd.0001477 | pmid=22389730 | pmc=3289602}}&lt;/ref&gt; Ukutholaka kokuthoma kokuqubuka kobulwelwe lobu kwavela ngo-2007 [[e-Federated States ye- Micronesia]].&lt;ref name=Ann2016/&gt; {{Ukusukela|ngoTjhirhweni 2016}}ubulwelwe lobu buqubuke eengodini ezimatjhumi amabili[[nge-Amerikha]].&lt;ref name=Ann2016/&gt; Kuthiwa buqubuke ne-Afrika, e-Asia kanye ne-Pacific.&lt;ref name=WHO2016Jan/&gt; Ngesibanga sokuqubuka kwabo ubulwelobu eBrazil ngo2015,i[[World Health Oeganization]]iikhiphe umbiko orhabako[[ngobungozi obukhna Emphakathini keZamaphilo eenTjhabatjhabeni zoke]] ngenyaka kaMhlolanja 2016.&lt;ref name=&quot;who1&quot;&gt;{{Wp/nd/cite web | url=http://www.who.int/mediacentre/news/statements/2016/emergency-committee-zika-microcephaly/en/ | title=WHO Director-General summarizes the outcome of the Emergency Committee regarding clusters of microcephaly and Guillain-Barré syndrome | work=Media Centre | publisher=World Health Organization | date=1 February 2016 | accessdate=3 February 2016}}&lt;/ref&gt;

==Isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini==
{{Reflist}}

[[Mkhakha:Wp/nd]]</text>
      <sha1>du1hznd257ybzadwb04ggjkjx88pusf</sha1>
    </revision>
    <revision>
      <id>2209</id>
      <parentid>2208</parentid>
      <timestamp>2024-11-29T07:32:30Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* Isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini */acpjournals.org</comment>
      <origin>2209</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7567" sha1="g1j3hby0ax917vw7gxvu29ckxbjvp8g" xml:space="preserve">{{Wp/nd/Infobox disease
|name           = Umgomani weZika
|image          = Alexius Salvador Zika-Virus.jpg
|caption        = Iratjhi ngesikhathi kutheleleke umgomani weZika
|pronunciation  = Zika {{IPAc-en|ˈ|z|iː|k|ə}}
|ICD10          = {{Wp/nd/ICD10|U|06|9|a|}},
|ICD9           = {{Wp/nd/ICD9|066.3}}
|DiseasesDB     =36480
|MedlinePlus    =007666
|eMedicineSubj  =
|eMedicineTopic =
|MeSH       =D000071243
}}
&lt;!-- Definition and symptoms --&gt;
'''Umgomani weZika''' (owaziwa godu'''ngomulwana weZika''') bulwelwe [[obubangwa mumulwana iZika]].&lt;ref name=&quot;WHO2016Jan&quot;&gt;{{Wp/nd/cite web | url=https://www.who.int/en/news-room/fact-sheets/detail/zika-virus | title=Zika virus | publisher=World Health Organization | date=January 2016 | accessdate=3 February 2016}}&lt;/ref&gt;Esikhathini esinengi izehlakalo ezibikwako azinawo amatshwayo wokugula, kodwana nangabe akhona kuzwakala ukufuthumala[[ nomgomani womzimba obuhlungu]].&lt;ref name=&quot;WHO2016Jan&quot; /&gt;&lt;ref name=&quot;ecdc1&quot;&gt;{{Wp/nd/cite web | url=http://ecdc.europa.eu/en/healthtopics/zika_virus_infection/factsheet-health-professionals/Pages/factsheet_health_professionals.aspx | title=Factsheet for health professionals | publisher=European Centre for Disease Prevention and Control | work=Zika virus infection | accessdate=22 December 2015}}&lt;/ref&gt; Amatshwayo angafaka hlangana [[umgomani nehloko ebuhlungu]], [[amehlo|abovu]], [[i-arthralgia|ubuhlungu balapha kuhlangana khona amathambo]] ihloko esawula kabuhlungu, kanye [[neratjhi elumako]].&lt;ref name=WHO2016Jan/&gt;&lt;ref name=Ann2016/&gt;&lt;ref name=&quot;Musso14&quot;&gt;{{Wp/nd/cite journal | url=http://linkinghub.elsevier.com/retrieve/pii/S1198743X1465391X | title=Rapid spread of emerging Zika virus in the Pacific area | last=Musso | first=D. | last2=Nilles | first2=E.J. | last3=Cao-Lormeau | first3=V.-M. | journal=Clinical Microbiology and Infection | year=2014 | volume=20 | issue=10 | pages=O595–6 | doi=10.1111/1469-0691.12707 | pmid=24909208}}&lt;/ref&gt; Amatshwayo la abonala amalanga angaphasi kwalikhomba.&lt;ref name=Ann2016/&gt; Akhange bubange ukufa komuntu lokha nakasathoma ukubonakala.&lt;ref name=&quot;ecdc1&quot;/&gt;Ubulwelwe lobu buhlotjaniswe[[ne-Guillain–Barré syndrom]] (GBS0.&lt;ref name=&quot;ecdc1&quot;/&gt; 

&lt;!-- Cause and diagnosis --&gt;
Umgomani weZika usabalaliseka nofana utheleleka ngokulunywa [[ngunompopoloza]] womhlobo ''[[i-Aedes]]'' okhethekileko.&lt;ref name=Ann2016/&gt;Ungatheleleka [[godu ngokuya emsemeni|ukuya emsemeni]] ukusuka endodeni ukuya kiloyo alala naye[[bese ubulwelwe lobu bungatheleleka ngokungenelana kweengaz]]i. &lt;ref name=CDC2016&gt;{{Wp/nd/cite journal|last1=Oster|first1=Alexandra M.|last2=Russell|first2=Kate|last3=Stryker|first3=Jo Ellen|last4=Friedman|first4=Allison|last5=Kachur|first5=Rachel E.|last6=Petersen|first6=Emily E.|last7=Jamieson|first7=Denise J.|last8=Cohn|first8=Amanda C.|last9=Brooks|first9=John T.|title=Update: Interim Guidance for Prevention of Sexual Transmission of Zika Virus — United States, 2016|journal=MMWR. Morbidity and Mortality Weekly Report|date=1 April 2016|volume=65|issue=12|pages=323–325|doi=10.15585/mmwr.mm6512e3|pmid = 27032078}}&lt;/ref&gt;&lt;ref name=Ann2016/&gt; Ukutheleleka kilabo abafazi abasidisi abazithweleko kungatheleleka nemntwaneni[[ngombana khekwahlotjaniswa]]nokufoloza ukuhlongakala kwabantwana bangakabelethwa [[kanye nokubelethwa kwabantwana abaneenhloko ezincani ngokungakajayeki]].&lt;ref name=WHO2016Jan/&gt;&lt;ref name=&quot;ChanChoi2016&quot;&gt;{{Wp/nd/cite journal | first1=Jasper F.W. | last1=Chan | url=https://www.ncbi.nlm.nih.gov/pubmed/26940504 | title=Zika fever and congenital Zika syndrome: An unexpected emerging arboviral disease | last2=Choi | first2=Garnet K.Y. | last3=Yip | first3=Cyril C.Y. | last4=Cheng | first4=Vincent C.C. | last5=Yuen | first5=Kwok-Yung | journal=Journal of Infection | year=2016 | issn=01634453 | doi=10.1016/j.jinf.2016.02.011 | pmid=26940504 | display-authors=3}}&lt;/ref&gt; Ukutholwa komrabho wobulwelwe lobu kwenziwa ngokuhlola igazi, umthondo, nofana amathe kuqalwe ubukhona bomgomani i-Zika[[RNA]] lokha umuntu nakagulako.&lt;ref name=WHO2016Jan/&gt;&lt;ref name=Ann2016/&gt;

&lt;!-- Prevention and treatment --&gt;
Ukukhandela ubulwelwe lobu kufaka hlangana ukwehlisa ukuba khona kwabonompopoloza abalumako eendaweni lapha badlange khona kanye nokusebenzisa ikhpndomu nawuya emsemeni.&lt;ref name=&quot;Ann2016&quot;&gt;{{Wp/nd/cite journal | first1=Lin H. | last1=Chen | url=https://www.acpjournals.org/doi/10.7326/M16-0150?articleid=2486362 | title=Zika Virus: Rapid Spread in the Western Hemisphere | last2=Hamer | first2=Davidson H. | journal=Annals of Internal Medicine | year=2016 | issn=0003-4819 | doi=10.7326/M16-0150}}&lt;/ref&gt;&lt;ref name=CDC2016/&gt; Imizamo yokwehlisa ukulunywa kufaka hlangana[[nokusebenzisa iinhlanhla ezibulala iinunwana]] ukuvala umzimba wakho ngezambatho[[ iinhlanhla ezibulala abonompopoloza]], nokususa amazni ajamileko angakhambiko lapha abonompopoloza bangathola khona ithuba lokwanda.&lt;ref name=WHO2016Jan/&gt; Aasikho isihlahla[[nofana imijovo esebenza ukulapha ubulwelobu]].&lt;ref name=Ann2016/&gt; Abasebezi bezamaphilo banyule ukuthi abafazi abahlala lapho kudlange khona ubulwelwe bomgomani weZika[[bomgomani weZika (2015–bekube nje)|2015-16 ukuqubuka kobulwelwe bomgomani iZika]] bathathe isiqunto sokobana bangabi nabantwana begodu abafazi abasidisi bangayi eendaweni lapaha kudlange ubulwelwe lobu.&lt;ref name=Ann2016/&gt;&lt;ref name=&quot;cnn1&quot;&gt;{{Wp/nd/cite news | url=http://www.cnn.com/2015/12/23/health/brazil-zika-pregnancy-warning/index.html | title=Brazil warns against pregnancy due to spreading virus | work=CNN | date=24 December 2015 | accessdate=24 December 2015}}&lt;/ref&gt; Njengombana akunasihlahla sokulapha ubulwelwe lobu,[[ amapeli wehlono neenhlungu i-paracetamol]]i- (acetaminophen) zingasiza lokha nawubona amatshwayo wobulwelobu.&lt;ref name=Ann2016/&gt; Ukuyokungeniswa esibhedlela akukavami.&lt;ref name=&quot;ecdc1&quot;/&gt; 

&lt;!-- History and epidemiology --&gt;
Umulwana obanga ubulwelwe lobu watholakala ngo-1947.&lt;ref name=&quot;OlsonHaddow2012&quot;&gt;{{Wp/nd/cite journal | display-authors=3 | first1=Ken E. | first10=Scott C. | first3=Amy J. | first7=Rekol | last1=Olson | last10=Weaver | title=Genetic Characterization of Zika Virus Strains: Geographic Expansion of the Asian Lineage | last2=Haddow | first2=Andrew D. | last3=Schuh | last4=Yasuda | first4=Chadwick Y. | last5=Kasper | first5=Matthew R. | last6=Heang | first6=Vireak | last7=Huy | last8=Guzman | first8=Hilda | last9=Tesh | first9=Robert B. | journal=PLoS Neglected Tropical Diseases | year=2012 | volume=6 | issue=2 | pages=e1477 | issn=1935-2735 | doi=10.1371/journal.pntd.0001477 | pmid=22389730 | pmc=3289602}}&lt;/ref&gt; Ukutholaka kokuthoma kokuqubuka kobulwelwe lobu kwavela ngo-2007 [[e-Federated States ye- Micronesia]].&lt;ref name=Ann2016/&gt; {{Ukusukela|ngoTjhirhweni 2016}}ubulwelwe lobu buqubuke eengodini ezimatjhumi amabili[[nge-Amerikha]].&lt;ref name=Ann2016/&gt; Kuthiwa buqubuke ne-Afrika, e-Asia kanye ne-Pacific.&lt;ref name=WHO2016Jan/&gt; Ngesibanga sokuqubuka kwabo ubulwelobu eBrazil ngo2015,i[[World Health Oeganization]]iikhiphe umbiko orhabako[[ngobungozi obukhna Emphakathini keZamaphilo eenTjhabatjhabeni zoke]] ngenyaka kaMhlolanja 2016.&lt;ref name=&quot;who1&quot;&gt;{{Wp/nd/cite web | url=http://www.who.int/mediacentre/news/statements/2016/emergency-committee-zika-microcephaly/en/ | title=WHO Director-General summarizes the outcome of the Emergency Committee regarding clusters of microcephaly and Guillain-Barré syndrome | work=Media Centre | publisher=World Health Organization | date=1 February 2016 | accessdate=3 February 2016}}&lt;/ref&gt;

==Isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini==
{{Reflist}}

[[Mkhakha:Wp/nd]]</text>
      <sha1>g1j3hby0ax917vw7gxvu29ckxbjvp8g</sha1>
    </revision>
    <revision>
      <id>2210</id>
      <parentid>2209</parentid>
      <timestamp>2024-11-29T07:33:27Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* Isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini */clinicalmicrobiologyandinfection.com</comment>
      <origin>2210</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7593" sha1="kuwtdrtl073chooi3u6tlrsbmqpmp8j" xml:space="preserve">{{Wp/nd/Infobox disease
|name           = Umgomani weZika
|image          = Alexius Salvador Zika-Virus.jpg
|caption        = Iratjhi ngesikhathi kutheleleke umgomani weZika
|pronunciation  = Zika {{IPAc-en|ˈ|z|iː|k|ə}}
|ICD10          = {{Wp/nd/ICD10|U|06|9|a|}},
|ICD9           = {{Wp/nd/ICD9|066.3}}
|DiseasesDB     =36480
|MedlinePlus    =007666
|eMedicineSubj  =
|eMedicineTopic =
|MeSH       =D000071243
}}
&lt;!-- Definition and symptoms --&gt;
'''Umgomani weZika''' (owaziwa godu'''ngomulwana weZika''') bulwelwe [[obubangwa mumulwana iZika]].&lt;ref name=&quot;WHO2016Jan&quot;&gt;{{Wp/nd/cite web | url=https://www.who.int/en/news-room/fact-sheets/detail/zika-virus | title=Zika virus | publisher=World Health Organization | date=January 2016 | accessdate=3 February 2016}}&lt;/ref&gt;Esikhathini esinengi izehlakalo ezibikwako azinawo amatshwayo wokugula, kodwana nangabe akhona kuzwakala ukufuthumala[[ nomgomani womzimba obuhlungu]].&lt;ref name=&quot;WHO2016Jan&quot; /&gt;&lt;ref name=&quot;ecdc1&quot;&gt;{{Wp/nd/cite web | url=http://ecdc.europa.eu/en/healthtopics/zika_virus_infection/factsheet-health-professionals/Pages/factsheet_health_professionals.aspx | title=Factsheet for health professionals | publisher=European Centre for Disease Prevention and Control | work=Zika virus infection | accessdate=22 December 2015}}&lt;/ref&gt; Amatshwayo angafaka hlangana [[umgomani nehloko ebuhlungu]], [[amehlo|abovu]], [[i-arthralgia|ubuhlungu balapha kuhlangana khona amathambo]] ihloko esawula kabuhlungu, kanye [[neratjhi elumako]].&lt;ref name=WHO2016Jan/&gt;&lt;ref name=Ann2016/&gt;&lt;ref name=&quot;Musso14&quot;&gt;{{Wp/nd/cite journal | url=https://www.clinicalmicrobiologyandinfection.com/article/S1198-743X(14)65391-X/fulltext | title=Rapid spread of emerging Zika virus in the Pacific area | last=Musso | first=D. | last2=Nilles | first2=E.J. | last3=Cao-Lormeau | first3=V.-M. | journal=Clinical Microbiology and Infection | year=2014 | volume=20 | issue=10 | pages=O595–6 | doi=10.1111/1469-0691.12707 | pmid=24909208}}&lt;/ref&gt; Amatshwayo la abonala amalanga angaphasi kwalikhomba.&lt;ref name=Ann2016/&gt; Akhange bubange ukufa komuntu lokha nakasathoma ukubonakala.&lt;ref name=&quot;ecdc1&quot;/&gt;Ubulwelwe lobu buhlotjaniswe[[ne-Guillain–Barré syndrom]] (GBS0.&lt;ref name=&quot;ecdc1&quot;/&gt; 

&lt;!-- Cause and diagnosis --&gt;
Umgomani weZika usabalaliseka nofana utheleleka ngokulunywa [[ngunompopoloza]] womhlobo ''[[i-Aedes]]'' okhethekileko.&lt;ref name=Ann2016/&gt;Ungatheleleka [[godu ngokuya emsemeni|ukuya emsemeni]] ukusuka endodeni ukuya kiloyo alala naye[[bese ubulwelwe lobu bungatheleleka ngokungenelana kweengaz]]i. &lt;ref name=CDC2016&gt;{{Wp/nd/cite journal|last1=Oster|first1=Alexandra M.|last2=Russell|first2=Kate|last3=Stryker|first3=Jo Ellen|last4=Friedman|first4=Allison|last5=Kachur|first5=Rachel E.|last6=Petersen|first6=Emily E.|last7=Jamieson|first7=Denise J.|last8=Cohn|first8=Amanda C.|last9=Brooks|first9=John T.|title=Update: Interim Guidance for Prevention of Sexual Transmission of Zika Virus — United States, 2016|journal=MMWR. Morbidity and Mortality Weekly Report|date=1 April 2016|volume=65|issue=12|pages=323–325|doi=10.15585/mmwr.mm6512e3|pmid = 27032078}}&lt;/ref&gt;&lt;ref name=Ann2016/&gt; Ukutheleleka kilabo abafazi abasidisi abazithweleko kungatheleleka nemntwaneni[[ngombana khekwahlotjaniswa]]nokufoloza ukuhlongakala kwabantwana bangakabelethwa [[kanye nokubelethwa kwabantwana abaneenhloko ezincani ngokungakajayeki]].&lt;ref name=WHO2016Jan/&gt;&lt;ref name=&quot;ChanChoi2016&quot;&gt;{{Wp/nd/cite journal | first1=Jasper F.W. | last1=Chan | url=https://www.ncbi.nlm.nih.gov/pubmed/26940504 | title=Zika fever and congenital Zika syndrome: An unexpected emerging arboviral disease | last2=Choi | first2=Garnet K.Y. | last3=Yip | first3=Cyril C.Y. | last4=Cheng | first4=Vincent C.C. | last5=Yuen | first5=Kwok-Yung | journal=Journal of Infection | year=2016 | issn=01634453 | doi=10.1016/j.jinf.2016.02.011 | pmid=26940504 | display-authors=3}}&lt;/ref&gt; Ukutholwa komrabho wobulwelwe lobu kwenziwa ngokuhlola igazi, umthondo, nofana amathe kuqalwe ubukhona bomgomani i-Zika[[RNA]] lokha umuntu nakagulako.&lt;ref name=WHO2016Jan/&gt;&lt;ref name=Ann2016/&gt;

&lt;!-- Prevention and treatment --&gt;
Ukukhandela ubulwelwe lobu kufaka hlangana ukwehlisa ukuba khona kwabonompopoloza abalumako eendaweni lapha badlange khona kanye nokusebenzisa ikhpndomu nawuya emsemeni.&lt;ref name=&quot;Ann2016&quot;&gt;{{Wp/nd/cite journal | first1=Lin H. | last1=Chen | url=https://www.acpjournals.org/doi/10.7326/M16-0150?articleid=2486362 | title=Zika Virus: Rapid Spread in the Western Hemisphere | last2=Hamer | first2=Davidson H. | journal=Annals of Internal Medicine | year=2016 | issn=0003-4819 | doi=10.7326/M16-0150}}&lt;/ref&gt;&lt;ref name=CDC2016/&gt; Imizamo yokwehlisa ukulunywa kufaka hlangana[[nokusebenzisa iinhlanhla ezibulala iinunwana]] ukuvala umzimba wakho ngezambatho[[ iinhlanhla ezibulala abonompopoloza]], nokususa amazni ajamileko angakhambiko lapha abonompopoloza bangathola khona ithuba lokwanda.&lt;ref name=WHO2016Jan/&gt; Aasikho isihlahla[[nofana imijovo esebenza ukulapha ubulwelobu]].&lt;ref name=Ann2016/&gt; Abasebezi bezamaphilo banyule ukuthi abafazi abahlala lapho kudlange khona ubulwelwe bomgomani weZika[[bomgomani weZika (2015–bekube nje)|2015-16 ukuqubuka kobulwelwe bomgomani iZika]] bathathe isiqunto sokobana bangabi nabantwana begodu abafazi abasidisi bangayi eendaweni lapaha kudlange ubulwelwe lobu.&lt;ref name=Ann2016/&gt;&lt;ref name=&quot;cnn1&quot;&gt;{{Wp/nd/cite news | url=http://www.cnn.com/2015/12/23/health/brazil-zika-pregnancy-warning/index.html | title=Brazil warns against pregnancy due to spreading virus | work=CNN | date=24 December 2015 | accessdate=24 December 2015}}&lt;/ref&gt; Njengombana akunasihlahla sokulapha ubulwelwe lobu,[[ amapeli wehlono neenhlungu i-paracetamol]]i- (acetaminophen) zingasiza lokha nawubona amatshwayo wobulwelobu.&lt;ref name=Ann2016/&gt; Ukuyokungeniswa esibhedlela akukavami.&lt;ref name=&quot;ecdc1&quot;/&gt; 

&lt;!-- History and epidemiology --&gt;
Umulwana obanga ubulwelwe lobu watholakala ngo-1947.&lt;ref name=&quot;OlsonHaddow2012&quot;&gt;{{Wp/nd/cite journal | display-authors=3 | first1=Ken E. | first10=Scott C. | first3=Amy J. | first7=Rekol | last1=Olson | last10=Weaver | title=Genetic Characterization of Zika Virus Strains: Geographic Expansion of the Asian Lineage | last2=Haddow | first2=Andrew D. | last3=Schuh | last4=Yasuda | first4=Chadwick Y. | last5=Kasper | first5=Matthew R. | last6=Heang | first6=Vireak | last7=Huy | last8=Guzman | first8=Hilda | last9=Tesh | first9=Robert B. | journal=PLoS Neglected Tropical Diseases | year=2012 | volume=6 | issue=2 | pages=e1477 | issn=1935-2735 | doi=10.1371/journal.pntd.0001477 | pmid=22389730 | pmc=3289602}}&lt;/ref&gt; Ukutholaka kokuthoma kokuqubuka kobulwelwe lobu kwavela ngo-2007 [[e-Federated States ye- Micronesia]].&lt;ref name=Ann2016/&gt; {{Ukusukela|ngoTjhirhweni 2016}}ubulwelwe lobu buqubuke eengodini ezimatjhumi amabili[[nge-Amerikha]].&lt;ref name=Ann2016/&gt; Kuthiwa buqubuke ne-Afrika, e-Asia kanye ne-Pacific.&lt;ref name=WHO2016Jan/&gt; Ngesibanga sokuqubuka kwabo ubulwelobu eBrazil ngo2015,i[[World Health Oeganization]]iikhiphe umbiko orhabako[[ngobungozi obukhna Emphakathini keZamaphilo eenTjhabatjhabeni zoke]] ngenyaka kaMhlolanja 2016.&lt;ref name=&quot;who1&quot;&gt;{{Wp/nd/cite web | url=http://www.who.int/mediacentre/news/statements/2016/emergency-committee-zika-microcephaly/en/ | title=WHO Director-General summarizes the outcome of the Emergency Committee regarding clusters of microcephaly and Guillain-Barré syndrome | work=Media Centre | publisher=World Health Organization | date=1 February 2016 | accessdate=3 February 2016}}&lt;/ref&gt;

==Isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini==
{{Reflist}}

[[Mkhakha:Wp/nd]]</text>
      <sha1>kuwtdrtl073chooi3u6tlrsbmqpmp8j</sha1>
    </revision>
    <revision>
      <id>2211</id>
      <parentid>2210</parentid>
      <timestamp>2024-11-29T07:34:21Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* Isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini */who.int</comment>
      <origin>2211</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7689" sha1="thwr2i62t3r6rn2vr9l4trfxr22hyhx" xml:space="preserve">{{Wp/nd/Infobox disease
|name           = Umgomani weZika
|image          = Alexius Salvador Zika-Virus.jpg
|caption        = Iratjhi ngesikhathi kutheleleke umgomani weZika
|pronunciation  = Zika {{IPAc-en|ˈ|z|iː|k|ə}}
|ICD10          = {{Wp/nd/ICD10|U|06|9|a|}},
|ICD9           = {{Wp/nd/ICD9|066.3}}
|DiseasesDB     =36480
|MedlinePlus    =007666
|eMedicineSubj  =
|eMedicineTopic =
|MeSH       =D000071243
}}
&lt;!-- Definition and symptoms --&gt;
'''Umgomani weZika''' (owaziwa godu'''ngomulwana weZika''') bulwelwe [[obubangwa mumulwana iZika]].&lt;ref name=&quot;WHO2016Jan&quot;&gt;{{Wp/nd/cite web | url=https://www.who.int/en/news-room/fact-sheets/detail/zika-virus | title=Zika virus | publisher=World Health Organization | date=January 2016 | accessdate=3 February 2016}}&lt;/ref&gt;Esikhathini esinengi izehlakalo ezibikwako azinawo amatshwayo wokugula, kodwana nangabe akhona kuzwakala ukufuthumala[[ nomgomani womzimba obuhlungu]].&lt;ref name=&quot;WHO2016Jan&quot; /&gt;&lt;ref name=&quot;ecdc1&quot;&gt;{{Wp/nd/cite web | url=http://ecdc.europa.eu/en/healthtopics/zika_virus_infection/factsheet-health-professionals/Pages/factsheet_health_professionals.aspx | title=Factsheet for health professionals | publisher=European Centre for Disease Prevention and Control | work=Zika virus infection | accessdate=22 December 2015}}&lt;/ref&gt; Amatshwayo angafaka hlangana [[umgomani nehloko ebuhlungu]], [[amehlo|abovu]], [[i-arthralgia|ubuhlungu balapha kuhlangana khona amathambo]] ihloko esawula kabuhlungu, kanye [[neratjhi elumako]].&lt;ref name=WHO2016Jan/&gt;&lt;ref name=Ann2016/&gt;&lt;ref name=&quot;Musso14&quot;&gt;{{Wp/nd/cite journal | url=https://www.clinicalmicrobiologyandinfection.com/article/S1198-743X(14)65391-X/fulltext | title=Rapid spread of emerging Zika virus in the Pacific area | last=Musso | first=D. | last2=Nilles | first2=E.J. | last3=Cao-Lormeau | first3=V.-M. | journal=Clinical Microbiology and Infection | year=2014 | volume=20 | issue=10 | pages=O595–6 | doi=10.1111/1469-0691.12707 | pmid=24909208}}&lt;/ref&gt; Amatshwayo la abonala amalanga angaphasi kwalikhomba.&lt;ref name=Ann2016/&gt; Akhange bubange ukufa komuntu lokha nakasathoma ukubonakala.&lt;ref name=&quot;ecdc1&quot;/&gt;Ubulwelwe lobu buhlotjaniswe[[ne-Guillain–Barré syndrom]] (GBS0.&lt;ref name=&quot;ecdc1&quot;/&gt; 

&lt;!-- Cause and diagnosis --&gt;
Umgomani weZika usabalaliseka nofana utheleleka ngokulunywa [[ngunompopoloza]] womhlobo ''[[i-Aedes]]'' okhethekileko.&lt;ref name=Ann2016/&gt;Ungatheleleka [[godu ngokuya emsemeni|ukuya emsemeni]] ukusuka endodeni ukuya kiloyo alala naye[[bese ubulwelwe lobu bungatheleleka ngokungenelana kweengaz]]i. &lt;ref name=CDC2016&gt;{{Wp/nd/cite journal|last1=Oster|first1=Alexandra M.|last2=Russell|first2=Kate|last3=Stryker|first3=Jo Ellen|last4=Friedman|first4=Allison|last5=Kachur|first5=Rachel E.|last6=Petersen|first6=Emily E.|last7=Jamieson|first7=Denise J.|last8=Cohn|first8=Amanda C.|last9=Brooks|first9=John T.|title=Update: Interim Guidance for Prevention of Sexual Transmission of Zika Virus — United States, 2016|journal=MMWR. Morbidity and Mortality Weekly Report|date=1 April 2016|volume=65|issue=12|pages=323–325|doi=10.15585/mmwr.mm6512e3|pmid = 27032078}}&lt;/ref&gt;&lt;ref name=Ann2016/&gt; Ukutheleleka kilabo abafazi abasidisi abazithweleko kungatheleleka nemntwaneni[[ngombana khekwahlotjaniswa]]nokufoloza ukuhlongakala kwabantwana bangakabelethwa [[kanye nokubelethwa kwabantwana abaneenhloko ezincani ngokungakajayeki]].&lt;ref name=WHO2016Jan/&gt;&lt;ref name=&quot;ChanChoi2016&quot;&gt;{{Wp/nd/cite journal | first1=Jasper F.W. | last1=Chan | url=https://www.ncbi.nlm.nih.gov/pubmed/26940504 | title=Zika fever and congenital Zika syndrome: An unexpected emerging arboviral disease | last2=Choi | first2=Garnet K.Y. | last3=Yip | first3=Cyril C.Y. | last4=Cheng | first4=Vincent C.C. | last5=Yuen | first5=Kwok-Yung | journal=Journal of Infection | year=2016 | issn=01634453 | doi=10.1016/j.jinf.2016.02.011 | pmid=26940504 | display-authors=3}}&lt;/ref&gt; Ukutholwa komrabho wobulwelwe lobu kwenziwa ngokuhlola igazi, umthondo, nofana amathe kuqalwe ubukhona bomgomani i-Zika[[RNA]] lokha umuntu nakagulako.&lt;ref name=WHO2016Jan/&gt;&lt;ref name=Ann2016/&gt;

&lt;!-- Prevention and treatment --&gt;
Ukukhandela ubulwelwe lobu kufaka hlangana ukwehlisa ukuba khona kwabonompopoloza abalumako eendaweni lapha badlange khona kanye nokusebenzisa ikhpndomu nawuya emsemeni.&lt;ref name=&quot;Ann2016&quot;&gt;{{Wp/nd/cite journal | first1=Lin H. | last1=Chen | url=https://www.acpjournals.org/doi/10.7326/M16-0150?articleid=2486362 | title=Zika Virus: Rapid Spread in the Western Hemisphere | last2=Hamer | first2=Davidson H. | journal=Annals of Internal Medicine | year=2016 | issn=0003-4819 | doi=10.7326/M16-0150}}&lt;/ref&gt;&lt;ref name=CDC2016/&gt; Imizamo yokwehlisa ukulunywa kufaka hlangana[[nokusebenzisa iinhlanhla ezibulala iinunwana]] ukuvala umzimba wakho ngezambatho[[ iinhlanhla ezibulala abonompopoloza]], nokususa amazni ajamileko angakhambiko lapha abonompopoloza bangathola khona ithuba lokwanda.&lt;ref name=WHO2016Jan/&gt; Aasikho isihlahla[[nofana imijovo esebenza ukulapha ubulwelobu]].&lt;ref name=Ann2016/&gt; Abasebezi bezamaphilo banyule ukuthi abafazi abahlala lapho kudlange khona ubulwelwe bomgomani weZika[[bomgomani weZika (2015–bekube nje)|2015-16 ukuqubuka kobulwelwe bomgomani iZika]] bathathe isiqunto sokobana bangabi nabantwana begodu abafazi abasidisi bangayi eendaweni lapaha kudlange ubulwelwe lobu.&lt;ref name=Ann2016/&gt;&lt;ref name=&quot;cnn1&quot;&gt;{{Wp/nd/cite news | url=http://www.cnn.com/2015/12/23/health/brazil-zika-pregnancy-warning/index.html | title=Brazil warns against pregnancy due to spreading virus | work=CNN | date=24 December 2015 | accessdate=24 December 2015}}&lt;/ref&gt; Njengombana akunasihlahla sokulapha ubulwelwe lobu,[[ amapeli wehlono neenhlungu i-paracetamol]]i- (acetaminophen) zingasiza lokha nawubona amatshwayo wobulwelobu.&lt;ref name=Ann2016/&gt; Ukuyokungeniswa esibhedlela akukavami.&lt;ref name=&quot;ecdc1&quot;/&gt; 

&lt;!-- History and epidemiology --&gt;
Umulwana obanga ubulwelwe lobu watholakala ngo-1947.&lt;ref name=&quot;OlsonHaddow2012&quot;&gt;{{Wp/nd/cite journal | display-authors=3 | first1=Ken E. | first10=Scott C. | first3=Amy J. | first7=Rekol | last1=Olson | last10=Weaver | title=Genetic Characterization of Zika Virus Strains: Geographic Expansion of the Asian Lineage | last2=Haddow | first2=Andrew D. | last3=Schuh | last4=Yasuda | first4=Chadwick Y. | last5=Kasper | first5=Matthew R. | last6=Heang | first6=Vireak | last7=Huy | last8=Guzman | first8=Hilda | last9=Tesh | first9=Robert B. | journal=PLoS Neglected Tropical Diseases | year=2012 | volume=6 | issue=2 | pages=e1477 | issn=1935-2735 | doi=10.1371/journal.pntd.0001477 | pmid=22389730 | pmc=3289602}}&lt;/ref&gt; Ukutholaka kokuthoma kokuqubuka kobulwelwe lobu kwavela ngo-2007 [[e-Federated States ye- Micronesia]].&lt;ref name=Ann2016/&gt; {{Ukusukela|ngoTjhirhweni 2016}}ubulwelwe lobu buqubuke eengodini ezimatjhumi amabili[[nge-Amerikha]].&lt;ref name=Ann2016/&gt; Kuthiwa buqubuke ne-Afrika, e-Asia kanye ne-Pacific.&lt;ref name=WHO2016Jan/&gt; Ngesibanga sokuqubuka kwabo ubulwelobu eBrazil ngo2015,i[[World Health Oeganization]]iikhiphe umbiko orhabako[[ngobungozi obukhna Emphakathini keZamaphilo eenTjhabatjhabeni zoke]] ngenyaka kaMhlolanja 2016.&lt;ref name=&quot;who1&quot;&gt;{{Wp/nd/cite web | url=https://www.who.int/en/news-room/detail/01-02-2016-who-director-general-summarizes-the-outcome-of-the-emergency-committee-regarding-clusters-of-microcephaly-and-guillain-barr%c3%a9-syndrome | title=WHO Director-General summarizes the outcome of the Emergency Committee regarding clusters of microcephaly and Guillain-Barré syndrome | work=Media Centre | publisher=World Health Organization | date=1 February 2016 | accessdate=3 February 2016}}&lt;/ref&gt;

==Isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini==
{{Reflist}}

[[Mkhakha:Wp/nd]]</text>
      <sha1>thwr2i62t3r6rn2vr9l4trfxr22hyhx</sha1>
    </revision>
    <revision>
      <id>2212</id>
      <parentid>2211</parentid>
      <timestamp>2024-11-29T07:35:13Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* Isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini */edition.cnn.com</comment>
      <origin>2212</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7694" sha1="1o3zfngwyun5s7x6cvvj3bk24elyj85" xml:space="preserve">{{Wp/nd/Infobox disease
|name           = Umgomani weZika
|image          = Alexius Salvador Zika-Virus.jpg
|caption        = Iratjhi ngesikhathi kutheleleke umgomani weZika
|pronunciation  = Zika {{IPAc-en|ˈ|z|iː|k|ə}}
|ICD10          = {{Wp/nd/ICD10|U|06|9|a|}},
|ICD9           = {{Wp/nd/ICD9|066.3}}
|DiseasesDB     =36480
|MedlinePlus    =007666
|eMedicineSubj  =
|eMedicineTopic =
|MeSH       =D000071243
}}
&lt;!-- Definition and symptoms --&gt;
'''Umgomani weZika''' (owaziwa godu'''ngomulwana weZika''') bulwelwe [[obubangwa mumulwana iZika]].&lt;ref name=&quot;WHO2016Jan&quot;&gt;{{Wp/nd/cite web | url=https://www.who.int/en/news-room/fact-sheets/detail/zika-virus | title=Zika virus | publisher=World Health Organization | date=January 2016 | accessdate=3 February 2016}}&lt;/ref&gt;Esikhathini esinengi izehlakalo ezibikwako azinawo amatshwayo wokugula, kodwana nangabe akhona kuzwakala ukufuthumala[[ nomgomani womzimba obuhlungu]].&lt;ref name=&quot;WHO2016Jan&quot; /&gt;&lt;ref name=&quot;ecdc1&quot;&gt;{{Wp/nd/cite web | url=http://ecdc.europa.eu/en/healthtopics/zika_virus_infection/factsheet-health-professionals/Pages/factsheet_health_professionals.aspx | title=Factsheet for health professionals | publisher=European Centre for Disease Prevention and Control | work=Zika virus infection | accessdate=22 December 2015}}&lt;/ref&gt; Amatshwayo angafaka hlangana [[umgomani nehloko ebuhlungu]], [[amehlo|abovu]], [[i-arthralgia|ubuhlungu balapha kuhlangana khona amathambo]] ihloko esawula kabuhlungu, kanye [[neratjhi elumako]].&lt;ref name=WHO2016Jan/&gt;&lt;ref name=Ann2016/&gt;&lt;ref name=&quot;Musso14&quot;&gt;{{Wp/nd/cite journal | url=https://www.clinicalmicrobiologyandinfection.com/article/S1198-743X(14)65391-X/fulltext | title=Rapid spread of emerging Zika virus in the Pacific area | last=Musso | first=D. | last2=Nilles | first2=E.J. | last3=Cao-Lormeau | first3=V.-M. | journal=Clinical Microbiology and Infection | year=2014 | volume=20 | issue=10 | pages=O595–6 | doi=10.1111/1469-0691.12707 | pmid=24909208}}&lt;/ref&gt; Amatshwayo la abonala amalanga angaphasi kwalikhomba.&lt;ref name=Ann2016/&gt; Akhange bubange ukufa komuntu lokha nakasathoma ukubonakala.&lt;ref name=&quot;ecdc1&quot;/&gt;Ubulwelwe lobu buhlotjaniswe[[ne-Guillain–Barré syndrom]] (GBS0.&lt;ref name=&quot;ecdc1&quot;/&gt; 

&lt;!-- Cause and diagnosis --&gt;
Umgomani weZika usabalaliseka nofana utheleleka ngokulunywa [[ngunompopoloza]] womhlobo ''[[i-Aedes]]'' okhethekileko.&lt;ref name=Ann2016/&gt;Ungatheleleka [[godu ngokuya emsemeni|ukuya emsemeni]] ukusuka endodeni ukuya kiloyo alala naye[[bese ubulwelwe lobu bungatheleleka ngokungenelana kweengaz]]i. &lt;ref name=CDC2016&gt;{{Wp/nd/cite journal|last1=Oster|first1=Alexandra M.|last2=Russell|first2=Kate|last3=Stryker|first3=Jo Ellen|last4=Friedman|first4=Allison|last5=Kachur|first5=Rachel E.|last6=Petersen|first6=Emily E.|last7=Jamieson|first7=Denise J.|last8=Cohn|first8=Amanda C.|last9=Brooks|first9=John T.|title=Update: Interim Guidance for Prevention of Sexual Transmission of Zika Virus — United States, 2016|journal=MMWR. Morbidity and Mortality Weekly Report|date=1 April 2016|volume=65|issue=12|pages=323–325|doi=10.15585/mmwr.mm6512e3|pmid = 27032078}}&lt;/ref&gt;&lt;ref name=Ann2016/&gt; Ukutheleleka kilabo abafazi abasidisi abazithweleko kungatheleleka nemntwaneni[[ngombana khekwahlotjaniswa]]nokufoloza ukuhlongakala kwabantwana bangakabelethwa [[kanye nokubelethwa kwabantwana abaneenhloko ezincani ngokungakajayeki]].&lt;ref name=WHO2016Jan/&gt;&lt;ref name=&quot;ChanChoi2016&quot;&gt;{{Wp/nd/cite journal | first1=Jasper F.W. | last1=Chan | url=https://www.ncbi.nlm.nih.gov/pubmed/26940504 | title=Zika fever and congenital Zika syndrome: An unexpected emerging arboviral disease | last2=Choi | first2=Garnet K.Y. | last3=Yip | first3=Cyril C.Y. | last4=Cheng | first4=Vincent C.C. | last5=Yuen | first5=Kwok-Yung | journal=Journal of Infection | year=2016 | issn=01634453 | doi=10.1016/j.jinf.2016.02.011 | pmid=26940504 | display-authors=3}}&lt;/ref&gt; Ukutholwa komrabho wobulwelwe lobu kwenziwa ngokuhlola igazi, umthondo, nofana amathe kuqalwe ubukhona bomgomani i-Zika[[RNA]] lokha umuntu nakagulako.&lt;ref name=WHO2016Jan/&gt;&lt;ref name=Ann2016/&gt;

&lt;!-- Prevention and treatment --&gt;
Ukukhandela ubulwelwe lobu kufaka hlangana ukwehlisa ukuba khona kwabonompopoloza abalumako eendaweni lapha badlange khona kanye nokusebenzisa ikhpndomu nawuya emsemeni.&lt;ref name=&quot;Ann2016&quot;&gt;{{Wp/nd/cite journal | first1=Lin H. | last1=Chen | url=https://www.acpjournals.org/doi/10.7326/M16-0150?articleid=2486362 | title=Zika Virus: Rapid Spread in the Western Hemisphere | last2=Hamer | first2=Davidson H. | journal=Annals of Internal Medicine | year=2016 | issn=0003-4819 | doi=10.7326/M16-0150}}&lt;/ref&gt;&lt;ref name=CDC2016/&gt; Imizamo yokwehlisa ukulunywa kufaka hlangana[[nokusebenzisa iinhlanhla ezibulala iinunwana]] ukuvala umzimba wakho ngezambatho[[ iinhlanhla ezibulala abonompopoloza]], nokususa amazni ajamileko angakhambiko lapha abonompopoloza bangathola khona ithuba lokwanda.&lt;ref name=WHO2016Jan/&gt; Aasikho isihlahla[[nofana imijovo esebenza ukulapha ubulwelobu]].&lt;ref name=Ann2016/&gt; Abasebezi bezamaphilo banyule ukuthi abafazi abahlala lapho kudlange khona ubulwelwe bomgomani weZika[[bomgomani weZika (2015–bekube nje)|2015-16 ukuqubuka kobulwelwe bomgomani iZika]] bathathe isiqunto sokobana bangabi nabantwana begodu abafazi abasidisi bangayi eendaweni lapaha kudlange ubulwelwe lobu.&lt;ref name=Ann2016/&gt;&lt;ref name=&quot;cnn1&quot;&gt;{{Wp/nd/cite news | url=https://edition.cnn.com/2015/12/23/health/brazil-zika-pregnancy-warning/index.html | title=Brazil warns against pregnancy due to spreading virus | work=CNN | date=24 December 2015 | accessdate=24 December 2015}}&lt;/ref&gt; Njengombana akunasihlahla sokulapha ubulwelwe lobu,[[ amapeli wehlono neenhlungu i-paracetamol]]i- (acetaminophen) zingasiza lokha nawubona amatshwayo wobulwelobu.&lt;ref name=Ann2016/&gt; Ukuyokungeniswa esibhedlela akukavami.&lt;ref name=&quot;ecdc1&quot;/&gt; 

&lt;!-- History and epidemiology --&gt;
Umulwana obanga ubulwelwe lobu watholakala ngo-1947.&lt;ref name=&quot;OlsonHaddow2012&quot;&gt;{{Wp/nd/cite journal | display-authors=3 | first1=Ken E. | first10=Scott C. | first3=Amy J. | first7=Rekol | last1=Olson | last10=Weaver | title=Genetic Characterization of Zika Virus Strains: Geographic Expansion of the Asian Lineage | last2=Haddow | first2=Andrew D. | last3=Schuh | last4=Yasuda | first4=Chadwick Y. | last5=Kasper | first5=Matthew R. | last6=Heang | first6=Vireak | last7=Huy | last8=Guzman | first8=Hilda | last9=Tesh | first9=Robert B. | journal=PLoS Neglected Tropical Diseases | year=2012 | volume=6 | issue=2 | pages=e1477 | issn=1935-2735 | doi=10.1371/journal.pntd.0001477 | pmid=22389730 | pmc=3289602}}&lt;/ref&gt; Ukutholaka kokuthoma kokuqubuka kobulwelwe lobu kwavela ngo-2007 [[e-Federated States ye- Micronesia]].&lt;ref name=Ann2016/&gt; {{Ukusukela|ngoTjhirhweni 2016}}ubulwelwe lobu buqubuke eengodini ezimatjhumi amabili[[nge-Amerikha]].&lt;ref name=Ann2016/&gt; Kuthiwa buqubuke ne-Afrika, e-Asia kanye ne-Pacific.&lt;ref name=WHO2016Jan/&gt; Ngesibanga sokuqubuka kwabo ubulwelobu eBrazil ngo2015,i[[World Health Oeganization]]iikhiphe umbiko orhabako[[ngobungozi obukhna Emphakathini keZamaphilo eenTjhabatjhabeni zoke]] ngenyaka kaMhlolanja 2016.&lt;ref name=&quot;who1&quot;&gt;{{Wp/nd/cite web | url=https://www.who.int/en/news-room/detail/01-02-2016-who-director-general-summarizes-the-outcome-of-the-emergency-committee-regarding-clusters-of-microcephaly-and-guillain-barr%c3%a9-syndrome | title=WHO Director-General summarizes the outcome of the Emergency Committee regarding clusters of microcephaly and Guillain-Barré syndrome | work=Media Centre | publisher=World Health Organization | date=1 February 2016 | accessdate=3 February 2016}}&lt;/ref&gt;

==Isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini==
{{Reflist}}

[[Mkhakha:Wp/nd]]</text>
      <sha1>1o3zfngwyun5s7x6cvvj3bk24elyj85</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Wp/nd/Cite web</title>
    <ns>10</ns>
    <id>369</id>
    <revision>
      <id>1928</id>
      <timestamp>2016-11-09T15:30:38Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>[[:en:Template:Cite web]]</comment>
      <origin>1928</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5210" sha1="i97wxnvqa707373uiwtqe8oro19bnz2" xml:space="preserve">&lt;includeonly&gt;{{Wp/nd/citation/core
|Citation class=web

|Surname1={{{last|{{{last1|{{{author|{{{author1|{{{authors|{{{surname|{{{surname1|}}}}}}}}}}}}}}}}}}}}}
|Surname2={{{last2|{{{author2|{{{surname2|}}}}}}}}}
|Surname3={{{last3|{{{author3|{{{surname3|}}}}}}}}}
|Surname4={{{last4|{{{author4|{{{surname4|}}}}}}}}}
|Surname5={{{last5|{{{author5|{{{surname5|}}}}}}}}}
|Surname6={{{last6|{{{author6|{{{surname6|}}}}}}}}}
|Surname7={{{last7|{{{author7|{{{surname7|}}}}}}}}}
|Surname8={{{last8|{{{author8|{{{surname8|}}}}}}}}}
|Surname9={{{last9|{{{author9|{{{surname9|}}}}}}}}}

|Given1={{{first|{{{first1|{{{given|{{{given1|}}}}}}}}}}}}
|Given2={{{first2|{{{given2|}}}}}}
|Given3={{{first3|{{{given3|}}}}}}
|Given4={{{first4|{{{given4|}}}}}}
|Given5={{{first5|{{{given5|}}}}}}
|Given6={{{first6|{{{given6|}}}}}}
|Given7={{{first7|{{{given7|}}}}}}
|Given8={{{first8|{{{given8|}}}}}}
|Given9={{{first9|{{{given9|}}}}}}

|Authorlink1={{{authorlink|{{{authorlink1|{{{author-link|{{{author1-link|}}}}}}}}}}}}
|Authorlink2={{{authorlink2|{{{author2-link|}}}}}}
|Authorlink3={{{authorlink3|{{{author3-link|}}}}}}
|Authorlink4={{{authorlink4|{{{author4-link|}}}}}}
|Authorlink5={{{authorlink5|{{{author5-link|}}}}}}
|Authorlink6={{{authorlink6|{{{author6-link|}}}}}}
|Authorlink7={{{authorlink7|{{{author7-link|}}}}}}
|Authorlink8={{{authorlink8|{{{author8-link|}}}}}}
|Authorlink9={{{authorlink9|{{{author9-link|}}}}}}

|Coauthors={{{coauthors|{{{coauthor|}}}}}}

|Other={{{others|}}}

|Year={{{year|{{    &lt;!-- attempt to derive year from date, if possible --&gt;
           #if: {{{date|}}}
           |{{
              #iferror:{{#time:Y|{{{date|}}} }}
              |{{#iferror:{{#time:Y|{{{publication-date|einval}}} }}||{{#time:Y|{{{publication-date|}}} }}}}
              |{{#time:Y|{{{date|}}} }}
            }}
           |{{{publication-date|}}} &lt;!-- last resort --&gt;
         }}
      }}}
|YearNote={{{origyear|}}}
|Date={{#if:{{{date|}}}|{{{date}}}|{{{day|}}} {{{month|}}} {{{year|{{{publication-date|}}}}}}}}

|Title={{{work|}}}
|IncludedWorkTitle={{
  #if:{{{title|}}}
  |{{{title}}}
  |{{
    #if:{{{trans_title|}}}
    |
    |{{Wp/nd/citation error|nocat={{{template doc demo|}}}|no &lt;code&gt;&amp;#124;title&amp;#61;&lt;/code&gt; specified|Cite web}}
    }}
  }}
|TransTitle={{{trans_title|}}}
|TitleType={{{type|}}}
|language={{{language|}}}

|IncludedWorkURL={{#if:{{{archiveurl|}}}
       |{{#ifeq: {{{deadurl|}}} | no | {{{url|}}} | {{{archiveurl|}}}}}
       |{{{url|}}}
     }}
|AccessDate={{{accessdate|}}}
|OriginalURL={{{url|}}}
|ArchiveURL={{{archiveurl|}}}
|ArchiveDate={{{archivedate|}}}
|DeadURL={{{deadurl|}}}
|format={{{format|}}}

|At={{#if: {{{page|}}}|{{#if:{{{nopp|}}}||p.&amp;nbsp;}}{{{page}}}
      |{{#if: {{{pages|}}}|{{#if:{{{nopp|}}}||pp.&amp;nbsp;}}{{{pages}}}
      |{{{at|}}}}}
    }}

|Series={{{agency|{{{series|{{{version|}}}}}}}}}

|Publisher={{{publisher|}}}
|Place={{{location|{{{place|}}}}}}
|PublicationPlace={{{location|{{{place|{{{publication-place|}}}}}}}}}
|PublicationDate={{{publication-date|}}}

|EditorSurname1={{{editor-last|{{{editor1-last|{{{editor|{{{editors|{{{editor-surname|{{{editor1-surname|}}}}}}}}}}}}}}}}}}
|EditorSurname2={{{editor2-last|{{{editor2-surname|}}}}}}
|EditorSurname3={{{editor3-last|{{{editor3-surname|}}}}}}
|EditorSurname4={{{editor4-last|{{{editor4-surname|}}}}}}
|EditorGiven1={{{editor-first|{{{editor1-first|{{{editor-given|{{{editor1-given|}}}}}}}}}}}}
|EditorGiven2={{{editor2-first|{{{editor2-given|}}}}}}
|EditorGiven3={{{editor3-first|{{{editor3-given|}}}}}}
|EditorGiven4={{{editor4-first|{{{editor4-given|}}}}}}
|Editorlink1={{{editor-link|{{{editor1-link|}}}}}}
|Editorlink2={{{editor2-link|}}}
|Editorlink3={{{editor3-link|}}}
|Editorlink4={{{editor4-link|}}}

|ARXIV={{{arxiv|}}}
|ASIN={{{asin|{{{ASIN|}}}}}}
|ASIN-TLD={{{asin-tld|}}}
|BIBCODE={{{bibcode|}}}
|DOI={{{doi|{{{DOI|}}}}}}
|DoiBroken={{{doi_brokendate|{{{doi_inactivedate|}}}}}}
|ISBN={{{isbn|{{{ISBN|}}}}}}
|ISSN={{{issn|{{{ISSN|}}}}}}
|JFM={{{jfm|{{{JFM|}}}}}}
|JSTOR={{{jstor|{{{JSTOR|}}}}}}
|LCCN={{{lccn|{{{LCCN|}}}}}}
|MR={{{mr|{{{MR|}}}}}}
|OCLC={{{oclc|{{{OCLC|}}}}}}
|OL={{{ol|{{{OL|}}}}}}
|OSTI={{{osti|{{{OSTI|}}}}}}
|PMC={{{pmc|{{{PMC|}}}}}}
|PMID={{{pmid|{{{PMID|}}}}}}
|RFC={{{rfc|{{{RFC|}}}}}}
|SSRN={{{ssrn|{{{SSRN|}}}}}}
|ZBL={{{zbl|}}}
|ID={{{id|{{{ID|}}}}}}

|laysummary={{{laysummary|}}}
|laydate={{{laydate|}}}
|laysource={{{laysource|}}}

|quote={{{quote|}}}

|Ref={{{ref|}}}

|amp={{{lastauthoramp|}}}
|AuthorMask={{{author-mask|{{{authormask|}}}}}}
|AuthorSep={{#ifeq:{{{author-separator|}}}|;|&amp;#059;|{{{author-separator|&amp;#059;}}}}}&amp;#32;
|NameSep={{{author-name-separator|,}}}&amp;#32;
|PS={{#if:{{{quote|}}}||{{{postscript|.}}}}}
|Sep={{#ifeq:{{{separator|{{{seperator}}} }}}|;|&amp;#059;|{{{separator|{{{seperator|.}}} }}} }}
|template doc demo={{{template doc demo|}}}
|Trunc={{#if:{{{display-authors|}}}|{{{display-authors}}}|8}}
}}{{#if:{{{access-date|}}}{{{accessdaymonth|}}}{{{accessday|}}}{{{accessmonthday|}}}{{{accessed|}}}{{{accessmonth|}}}{{{accessyear|}}}{{{dateformat|}}}{{{day|}}}{{{doilabel|}}}
|[[Category:Pages containing cite templates with deprecated parameters|{{NAMESPACE}} {{PAGENAME}}]]}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>i97wxnvqa707373uiwtqe8oro19bnz2</sha1>
    </revision>
    <revision>
      <id>1929</id>
      <parentid>1928</parentid>
      <timestamp>2016-11-09T15:30:44Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>CFCF moved page [[Template:Wp/nd/Cite web]] to [[Template:Wp/nd/cite web]]</comment>
      <origin>1928</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5210" sha1="i97wxnvqa707373uiwtqe8oro19bnz2" xml:space="preserve">&lt;includeonly&gt;{{Wp/nd/citation/core
|Citation class=web

|Surname1={{{last|{{{last1|{{{author|{{{author1|{{{authors|{{{surname|{{{surname1|}}}}}}}}}}}}}}}}}}}}}
|Surname2={{{last2|{{{author2|{{{surname2|}}}}}}}}}
|Surname3={{{last3|{{{author3|{{{surname3|}}}}}}}}}
|Surname4={{{last4|{{{author4|{{{surname4|}}}}}}}}}
|Surname5={{{last5|{{{author5|{{{surname5|}}}}}}}}}
|Surname6={{{last6|{{{author6|{{{surname6|}}}}}}}}}
|Surname7={{{last7|{{{author7|{{{surname7|}}}}}}}}}
|Surname8={{{last8|{{{author8|{{{surname8|}}}}}}}}}
|Surname9={{{last9|{{{author9|{{{surname9|}}}}}}}}}

|Given1={{{first|{{{first1|{{{given|{{{given1|}}}}}}}}}}}}
|Given2={{{first2|{{{given2|}}}}}}
|Given3={{{first3|{{{given3|}}}}}}
|Given4={{{first4|{{{given4|}}}}}}
|Given5={{{first5|{{{given5|}}}}}}
|Given6={{{first6|{{{given6|}}}}}}
|Given7={{{first7|{{{given7|}}}}}}
|Given8={{{first8|{{{given8|}}}}}}
|Given9={{{first9|{{{given9|}}}}}}

|Authorlink1={{{authorlink|{{{authorlink1|{{{author-link|{{{author1-link|}}}}}}}}}}}}
|Authorlink2={{{authorlink2|{{{author2-link|}}}}}}
|Authorlink3={{{authorlink3|{{{author3-link|}}}}}}
|Authorlink4={{{authorlink4|{{{author4-link|}}}}}}
|Authorlink5={{{authorlink5|{{{author5-link|}}}}}}
|Authorlink6={{{authorlink6|{{{author6-link|}}}}}}
|Authorlink7={{{authorlink7|{{{author7-link|}}}}}}
|Authorlink8={{{authorlink8|{{{author8-link|}}}}}}
|Authorlink9={{{authorlink9|{{{author9-link|}}}}}}

|Coauthors={{{coauthors|{{{coauthor|}}}}}}

|Other={{{others|}}}

|Year={{{year|{{    &lt;!-- attempt to derive year from date, if possible --&gt;
           #if: {{{date|}}}
           |{{
              #iferror:{{#time:Y|{{{date|}}} }}
              |{{#iferror:{{#time:Y|{{{publication-date|einval}}} }}||{{#time:Y|{{{publication-date|}}} }}}}
              |{{#time:Y|{{{date|}}} }}
            }}
           |{{{publication-date|}}} &lt;!-- last resort --&gt;
         }}
      }}}
|YearNote={{{origyear|}}}
|Date={{#if:{{{date|}}}|{{{date}}}|{{{day|}}} {{{month|}}} {{{year|{{{publication-date|}}}}}}}}

|Title={{{work|}}}
|IncludedWorkTitle={{
  #if:{{{title|}}}
  |{{{title}}}
  |{{
    #if:{{{trans_title|}}}
    |
    |{{Wp/nd/citation error|nocat={{{template doc demo|}}}|no &lt;code&gt;&amp;#124;title&amp;#61;&lt;/code&gt; specified|Cite web}}
    }}
  }}
|TransTitle={{{trans_title|}}}
|TitleType={{{type|}}}
|language={{{language|}}}

|IncludedWorkURL={{#if:{{{archiveurl|}}}
       |{{#ifeq: {{{deadurl|}}} | no | {{{url|}}} | {{{archiveurl|}}}}}
       |{{{url|}}}
     }}
|AccessDate={{{accessdate|}}}
|OriginalURL={{{url|}}}
|ArchiveURL={{{archiveurl|}}}
|ArchiveDate={{{archivedate|}}}
|DeadURL={{{deadurl|}}}
|format={{{format|}}}

|At={{#if: {{{page|}}}|{{#if:{{{nopp|}}}||p.&amp;nbsp;}}{{{page}}}
      |{{#if: {{{pages|}}}|{{#if:{{{nopp|}}}||pp.&amp;nbsp;}}{{{pages}}}
      |{{{at|}}}}}
    }}

|Series={{{agency|{{{series|{{{version|}}}}}}}}}

|Publisher={{{publisher|}}}
|Place={{{location|{{{place|}}}}}}
|PublicationPlace={{{location|{{{place|{{{publication-place|}}}}}}}}}
|PublicationDate={{{publication-date|}}}

|EditorSurname1={{{editor-last|{{{editor1-last|{{{editor|{{{editors|{{{editor-surname|{{{editor1-surname|}}}}}}}}}}}}}}}}}}
|EditorSurname2={{{editor2-last|{{{editor2-surname|}}}}}}
|EditorSurname3={{{editor3-last|{{{editor3-surname|}}}}}}
|EditorSurname4={{{editor4-last|{{{editor4-surname|}}}}}}
|EditorGiven1={{{editor-first|{{{editor1-first|{{{editor-given|{{{editor1-given|}}}}}}}}}}}}
|EditorGiven2={{{editor2-first|{{{editor2-given|}}}}}}
|EditorGiven3={{{editor3-first|{{{editor3-given|}}}}}}
|EditorGiven4={{{editor4-first|{{{editor4-given|}}}}}}
|Editorlink1={{{editor-link|{{{editor1-link|}}}}}}
|Editorlink2={{{editor2-link|}}}
|Editorlink3={{{editor3-link|}}}
|Editorlink4={{{editor4-link|}}}

|ARXIV={{{arxiv|}}}
|ASIN={{{asin|{{{ASIN|}}}}}}
|ASIN-TLD={{{asin-tld|}}}
|BIBCODE={{{bibcode|}}}
|DOI={{{doi|{{{DOI|}}}}}}
|DoiBroken={{{doi_brokendate|{{{doi_inactivedate|}}}}}}
|ISBN={{{isbn|{{{ISBN|}}}}}}
|ISSN={{{issn|{{{ISSN|}}}}}}
|JFM={{{jfm|{{{JFM|}}}}}}
|JSTOR={{{jstor|{{{JSTOR|}}}}}}
|LCCN={{{lccn|{{{LCCN|}}}}}}
|MR={{{mr|{{{MR|}}}}}}
|OCLC={{{oclc|{{{OCLC|}}}}}}
|OL={{{ol|{{{OL|}}}}}}
|OSTI={{{osti|{{{OSTI|}}}}}}
|PMC={{{pmc|{{{PMC|}}}}}}
|PMID={{{pmid|{{{PMID|}}}}}}
|RFC={{{rfc|{{{RFC|}}}}}}
|SSRN={{{ssrn|{{{SSRN|}}}}}}
|ZBL={{{zbl|}}}
|ID={{{id|{{{ID|}}}}}}

|laysummary={{{laysummary|}}}
|laydate={{{laydate|}}}
|laysource={{{laysource|}}}

|quote={{{quote|}}}

|Ref={{{ref|}}}

|amp={{{lastauthoramp|}}}
|AuthorMask={{{author-mask|{{{authormask|}}}}}}
|AuthorSep={{#ifeq:{{{author-separator|}}}|;|&amp;#059;|{{{author-separator|&amp;#059;}}}}}&amp;#32;
|NameSep={{{author-name-separator|,}}}&amp;#32;
|PS={{#if:{{{quote|}}}||{{{postscript|.}}}}}
|Sep={{#ifeq:{{{separator|{{{seperator}}} }}}|;|&amp;#059;|{{{separator|{{{seperator|.}}} }}} }}
|template doc demo={{{template doc demo|}}}
|Trunc={{#if:{{{display-authors|}}}|{{{display-authors}}}|8}}
}}{{#if:{{{access-date|}}}{{{accessdaymonth|}}}{{{accessday|}}}{{{accessmonthday|}}}{{{accessed|}}}{{{accessmonth|}}}{{{accessyear|}}}{{{dateformat|}}}{{{day|}}}{{{doilabel|}}}
|[[Category:Pages containing cite templates with deprecated parameters|{{NAMESPACE}} {{PAGENAME}}]]}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>i97wxnvqa707373uiwtqe8oro19bnz2</sha1>
    </revision>
    <revision>
      <id>1930</id>
      <parentid>1929</parentid>
      <timestamp>2019-12-02T16:16:06Z</timestamp>
      <contributor>
        <username>incubator&gt;Adithyak1997</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Added a prefix</comment>
      <origin>1930</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5216" sha1="bjsb615ql985sygaax80s7qj5x5djgl" xml:space="preserve">&lt;includeonly&gt;{{Wp/nd/citation/core
|Citation class=web

|Surname1={{{last|{{{last1|{{{author|{{{author1|{{{authors|{{{surname|{{{surname1|}}}}}}}}}}}}}}}}}}}}}
|Surname2={{{last2|{{{author2|{{{surname2|}}}}}}}}}
|Surname3={{{last3|{{{author3|{{{surname3|}}}}}}}}}
|Surname4={{{last4|{{{author4|{{{surname4|}}}}}}}}}
|Surname5={{{last5|{{{author5|{{{surname5|}}}}}}}}}
|Surname6={{{last6|{{{author6|{{{surname6|}}}}}}}}}
|Surname7={{{last7|{{{author7|{{{surname7|}}}}}}}}}
|Surname8={{{last8|{{{author8|{{{surname8|}}}}}}}}}
|Surname9={{{last9|{{{author9|{{{surname9|}}}}}}}}}

|Given1={{{first|{{{first1|{{{given|{{{given1|}}}}}}}}}}}}
|Given2={{{first2|{{{given2|}}}}}}
|Given3={{{first3|{{{given3|}}}}}}
|Given4={{{first4|{{{given4|}}}}}}
|Given5={{{first5|{{{given5|}}}}}}
|Given6={{{first6|{{{given6|}}}}}}
|Given7={{{first7|{{{given7|}}}}}}
|Given8={{{first8|{{{given8|}}}}}}
|Given9={{{first9|{{{given9|}}}}}}

|Authorlink1={{{authorlink|{{{authorlink1|{{{author-link|{{{author1-link|}}}}}}}}}}}}
|Authorlink2={{{authorlink2|{{{author2-link|}}}}}}
|Authorlink3={{{authorlink3|{{{author3-link|}}}}}}
|Authorlink4={{{authorlink4|{{{author4-link|}}}}}}
|Authorlink5={{{authorlink5|{{{author5-link|}}}}}}
|Authorlink6={{{authorlink6|{{{author6-link|}}}}}}
|Authorlink7={{{authorlink7|{{{author7-link|}}}}}}
|Authorlink8={{{authorlink8|{{{author8-link|}}}}}}
|Authorlink9={{{authorlink9|{{{author9-link|}}}}}}

|Coauthors={{{coauthors|{{{coauthor|}}}}}}

|Other={{{others|}}}

|Year={{{year|{{    &lt;!-- attempt to derive year from date, if possible --&gt;
           #if: {{{date|}}}
           |{{
              #iferror:{{#time:Y|{{{date|}}} }}
              |{{#iferror:{{#time:Y|{{{publication-date|einval}}} }}||{{#time:Y|{{{publication-date|}}} }}}}
              |{{#time:Y|{{{date|}}} }}
            }}
           |{{{publication-date|}}} &lt;!-- last resort --&gt;
         }}
      }}}
|YearNote={{{origyear|}}}
|Date={{#if:{{{date|}}}|{{{date}}}|{{{day|}}} {{{month|}}} {{{year|{{{publication-date|}}}}}}}}

|Title={{{work|}}}
|IncludedWorkTitle={{
  #if:{{{title|}}}
  |{{{title}}}
  |{{
    #if:{{{trans_title|}}}
    |
    |{{Wp/nd/citation error|nocat={{{template doc demo|}}}|no &lt;code&gt;&amp;#124;title&amp;#61;&lt;/code&gt; specified|Cite web}}
    }}
  }}
|TransTitle={{{trans_title|}}}
|TitleType={{{type|}}}
|language={{{language|}}}

|IncludedWorkURL={{#if:{{{archiveurl|}}}
       |{{#ifeq: {{{deadurl|}}} | no | {{{url|}}} | {{{archiveurl|}}}}}
       |{{{url|}}}
     }}
|AccessDate={{{accessdate|}}}
|OriginalURL={{{url|}}}
|ArchiveURL={{{archiveurl|}}}
|ArchiveDate={{{archivedate|}}}
|DeadURL={{{deadurl|}}}
|format={{{format|}}}

|At={{#if: {{{page|}}}|{{#if:{{{nopp|}}}||p.&amp;nbsp;}}{{{page}}}
      |{{#if: {{{pages|}}}|{{#if:{{{nopp|}}}||pp.&amp;nbsp;}}{{{pages}}}
      |{{{at|}}}}}
    }}

|Series={{{agency|{{{series|{{{version|}}}}}}}}}

|Publisher={{{publisher|}}}
|Place={{{location|{{{place|}}}}}}
|PublicationPlace={{{location|{{{place|{{{publication-place|}}}}}}}}}
|PublicationDate={{{publication-date|}}}

|EditorSurname1={{{editor-last|{{{editor1-last|{{{editor|{{{editors|{{{editor-surname|{{{editor1-surname|}}}}}}}}}}}}}}}}}}
|EditorSurname2={{{editor2-last|{{{editor2-surname|}}}}}}
|EditorSurname3={{{editor3-last|{{{editor3-surname|}}}}}}
|EditorSurname4={{{editor4-last|{{{editor4-surname|}}}}}}
|EditorGiven1={{{editor-first|{{{editor1-first|{{{editor-given|{{{editor1-given|}}}}}}}}}}}}
|EditorGiven2={{{editor2-first|{{{editor2-given|}}}}}}
|EditorGiven3={{{editor3-first|{{{editor3-given|}}}}}}
|EditorGiven4={{{editor4-first|{{{editor4-given|}}}}}}
|Editorlink1={{{editor-link|{{{editor1-link|}}}}}}
|Editorlink2={{{editor2-link|}}}
|Editorlink3={{{editor3-link|}}}
|Editorlink4={{{editor4-link|}}}

|ARXIV={{{arxiv|}}}
|ASIN={{{asin|{{{ASIN|}}}}}}
|ASIN-TLD={{{asin-tld|}}}
|BIBCODE={{{bibcode|}}}
|DOI={{{doi|{{{DOI|}}}}}}
|DoiBroken={{{doi_brokendate|{{{doi_inactivedate|}}}}}}
|ISBN={{{isbn|{{{ISBN|}}}}}}
|ISSN={{{issn|{{{ISSN|}}}}}}
|JFM={{{jfm|{{{JFM|}}}}}}
|JSTOR={{{jstor|{{{JSTOR|}}}}}}
|LCCN={{{lccn|{{{LCCN|}}}}}}
|MR={{{mr|{{{MR|}}}}}}
|OCLC={{{oclc|{{{OCLC|}}}}}}
|OL={{{ol|{{{OL|}}}}}}
|OSTI={{{osti|{{{OSTI|}}}}}}
|PMC={{{pmc|{{{PMC|}}}}}}
|PMID={{{pmid|{{{PMID|}}}}}}
|RFC={{{rfc|{{{RFC|}}}}}}
|SSRN={{{ssrn|{{{SSRN|}}}}}}
|ZBL={{{zbl|}}}
|ID={{{id|{{{ID|}}}}}}

|laysummary={{{laysummary|}}}
|laydate={{{laydate|}}}
|laysource={{{laysource|}}}

|quote={{{quote|}}}

|Ref={{{ref|}}}

|amp={{{lastauthoramp|}}}
|AuthorMask={{{author-mask|{{{authormask|}}}}}}
|AuthorSep={{#ifeq:{{{author-separator|}}}|;|&amp;#059;|{{{author-separator|&amp;#059;}}}}}&amp;#32;
|NameSep={{{author-name-separator|,}}}&amp;#32;
|PS={{#if:{{{quote|}}}||{{{postscript|.}}}}}
|Sep={{#ifeq:{{{separator|{{{seperator}}} }}}|;|&amp;#059;|{{{separator|{{{seperator|.}}} }}} }}
|template doc demo={{{template doc demo|}}}
|Trunc={{#if:{{{display-authors|}}}|{{{display-authors}}}|8}}
}}{{#if:{{{access-date|}}}{{{accessdaymonth|}}}{{{accessday|}}}{{{accessmonthday|}}}{{{accessed|}}}{{{accessmonth|}}}{{{accessyear|}}}{{{dateformat|}}}{{{day|}}}{{{doilabel|}}}
|[[Category:Pages containing cite templates with deprecated parameters|{{NAMESPACE}} {{PAGENAME}}]]}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{Wp/nd/Documentation}}
&lt;/noinclude&gt;</text>
      <sha1>bjsb615ql985sygaax80s7qj5x5djgl</sha1>
    </revision>
    <revision>
      <id>1931</id>
      <parentid>1930</parentid>
      <timestamp>2022-04-27T09:34:07Z</timestamp>
      <contributor>
        <username>JhsBot</username>
        <id>34</id>
      </contributor>
      <minor />
      <comment>JhsBot moved page [[Template:Wp/nd/cite web]] to [[Template:Wp/nd/Cite web]] over redirect: bot: Moving pages with (what would be) lowercase titles to uppercase</comment>
      <origin>1930</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5216" sha1="bjsb615ql985sygaax80s7qj5x5djgl" xml:space="preserve">&lt;includeonly&gt;{{Wp/nd/citation/core
|Citation class=web

|Surname1={{{last|{{{last1|{{{author|{{{author1|{{{authors|{{{surname|{{{surname1|}}}}}}}}}}}}}}}}}}}}}
|Surname2={{{last2|{{{author2|{{{surname2|}}}}}}}}}
|Surname3={{{last3|{{{author3|{{{surname3|}}}}}}}}}
|Surname4={{{last4|{{{author4|{{{surname4|}}}}}}}}}
|Surname5={{{last5|{{{author5|{{{surname5|}}}}}}}}}
|Surname6={{{last6|{{{author6|{{{surname6|}}}}}}}}}
|Surname7={{{last7|{{{author7|{{{surname7|}}}}}}}}}
|Surname8={{{last8|{{{author8|{{{surname8|}}}}}}}}}
|Surname9={{{last9|{{{author9|{{{surname9|}}}}}}}}}

|Given1={{{first|{{{first1|{{{given|{{{given1|}}}}}}}}}}}}
|Given2={{{first2|{{{given2|}}}}}}
|Given3={{{first3|{{{given3|}}}}}}
|Given4={{{first4|{{{given4|}}}}}}
|Given5={{{first5|{{{given5|}}}}}}
|Given6={{{first6|{{{given6|}}}}}}
|Given7={{{first7|{{{given7|}}}}}}
|Given8={{{first8|{{{given8|}}}}}}
|Given9={{{first9|{{{given9|}}}}}}

|Authorlink1={{{authorlink|{{{authorlink1|{{{author-link|{{{author1-link|}}}}}}}}}}}}
|Authorlink2={{{authorlink2|{{{author2-link|}}}}}}
|Authorlink3={{{authorlink3|{{{author3-link|}}}}}}
|Authorlink4={{{authorlink4|{{{author4-link|}}}}}}
|Authorlink5={{{authorlink5|{{{author5-link|}}}}}}
|Authorlink6={{{authorlink6|{{{author6-link|}}}}}}
|Authorlink7={{{authorlink7|{{{author7-link|}}}}}}
|Authorlink8={{{authorlink8|{{{author8-link|}}}}}}
|Authorlink9={{{authorlink9|{{{author9-link|}}}}}}

|Coauthors={{{coauthors|{{{coauthor|}}}}}}

|Other={{{others|}}}

|Year={{{year|{{    &lt;!-- attempt to derive year from date, if possible --&gt;
           #if: {{{date|}}}
           |{{
              #iferror:{{#time:Y|{{{date|}}} }}
              |{{#iferror:{{#time:Y|{{{publication-date|einval}}} }}||{{#time:Y|{{{publication-date|}}} }}}}
              |{{#time:Y|{{{date|}}} }}
            }}
           |{{{publication-date|}}} &lt;!-- last resort --&gt;
         }}
      }}}
|YearNote={{{origyear|}}}
|Date={{#if:{{{date|}}}|{{{date}}}|{{{day|}}} {{{month|}}} {{{year|{{{publication-date|}}}}}}}}

|Title={{{work|}}}
|IncludedWorkTitle={{
  #if:{{{title|}}}
  |{{{title}}}
  |{{
    #if:{{{trans_title|}}}
    |
    |{{Wp/nd/citation error|nocat={{{template doc demo|}}}|no &lt;code&gt;&amp;#124;title&amp;#61;&lt;/code&gt; specified|Cite web}}
    }}
  }}
|TransTitle={{{trans_title|}}}
|TitleType={{{type|}}}
|language={{{language|}}}

|IncludedWorkURL={{#if:{{{archiveurl|}}}
       |{{#ifeq: {{{deadurl|}}} | no | {{{url|}}} | {{{archiveurl|}}}}}
       |{{{url|}}}
     }}
|AccessDate={{{accessdate|}}}
|OriginalURL={{{url|}}}
|ArchiveURL={{{archiveurl|}}}
|ArchiveDate={{{archivedate|}}}
|DeadURL={{{deadurl|}}}
|format={{{format|}}}

|At={{#if: {{{page|}}}|{{#if:{{{nopp|}}}||p.&amp;nbsp;}}{{{page}}}
      |{{#if: {{{pages|}}}|{{#if:{{{nopp|}}}||pp.&amp;nbsp;}}{{{pages}}}
      |{{{at|}}}}}
    }}

|Series={{{agency|{{{series|{{{version|}}}}}}}}}

|Publisher={{{publisher|}}}
|Place={{{location|{{{place|}}}}}}
|PublicationPlace={{{location|{{{place|{{{publication-place|}}}}}}}}}
|PublicationDate={{{publication-date|}}}

|EditorSurname1={{{editor-last|{{{editor1-last|{{{editor|{{{editors|{{{editor-surname|{{{editor1-surname|}}}}}}}}}}}}}}}}}}
|EditorSurname2={{{editor2-last|{{{editor2-surname|}}}}}}
|EditorSurname3={{{editor3-last|{{{editor3-surname|}}}}}}
|EditorSurname4={{{editor4-last|{{{editor4-surname|}}}}}}
|EditorGiven1={{{editor-first|{{{editor1-first|{{{editor-given|{{{editor1-given|}}}}}}}}}}}}
|EditorGiven2={{{editor2-first|{{{editor2-given|}}}}}}
|EditorGiven3={{{editor3-first|{{{editor3-given|}}}}}}
|EditorGiven4={{{editor4-first|{{{editor4-given|}}}}}}
|Editorlink1={{{editor-link|{{{editor1-link|}}}}}}
|Editorlink2={{{editor2-link|}}}
|Editorlink3={{{editor3-link|}}}
|Editorlink4={{{editor4-link|}}}

|ARXIV={{{arxiv|}}}
|ASIN={{{asin|{{{ASIN|}}}}}}
|ASIN-TLD={{{asin-tld|}}}
|BIBCODE={{{bibcode|}}}
|DOI={{{doi|{{{DOI|}}}}}}
|DoiBroken={{{doi_brokendate|{{{doi_inactivedate|}}}}}}
|ISBN={{{isbn|{{{ISBN|}}}}}}
|ISSN={{{issn|{{{ISSN|}}}}}}
|JFM={{{jfm|{{{JFM|}}}}}}
|JSTOR={{{jstor|{{{JSTOR|}}}}}}
|LCCN={{{lccn|{{{LCCN|}}}}}}
|MR={{{mr|{{{MR|}}}}}}
|OCLC={{{oclc|{{{OCLC|}}}}}}
|OL={{{ol|{{{OL|}}}}}}
|OSTI={{{osti|{{{OSTI|}}}}}}
|PMC={{{pmc|{{{PMC|}}}}}}
|PMID={{{pmid|{{{PMID|}}}}}}
|RFC={{{rfc|{{{RFC|}}}}}}
|SSRN={{{ssrn|{{{SSRN|}}}}}}
|ZBL={{{zbl|}}}
|ID={{{id|{{{ID|}}}}}}

|laysummary={{{laysummary|}}}
|laydate={{{laydate|}}}
|laysource={{{laysource|}}}

|quote={{{quote|}}}

|Ref={{{ref|}}}

|amp={{{lastauthoramp|}}}
|AuthorMask={{{author-mask|{{{authormask|}}}}}}
|AuthorSep={{#ifeq:{{{author-separator|}}}|;|&amp;#059;|{{{author-separator|&amp;#059;}}}}}&amp;#32;
|NameSep={{{author-name-separator|,}}}&amp;#32;
|PS={{#if:{{{quote|}}}||{{{postscript|.}}}}}
|Sep={{#ifeq:{{{separator|{{{seperator}}} }}}|;|&amp;#059;|{{{separator|{{{seperator|.}}} }}} }}
|template doc demo={{{template doc demo|}}}
|Trunc={{#if:{{{display-authors|}}}|{{{display-authors}}}|8}}
}}{{#if:{{{access-date|}}}{{{accessdaymonth|}}}{{{accessday|}}}{{{accessmonthday|}}}{{{accessed|}}}{{{accessmonth|}}}{{{accessyear|}}}{{{dateformat|}}}{{{day|}}}{{{doilabel|}}}
|[[Category:Pages containing cite templates with deprecated parameters|{{NAMESPACE}} {{PAGENAME}}]]}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{Wp/nd/Documentation}}
&lt;/noinclude&gt;</text>
      <sha1>bjsb615ql985sygaax80s7qj5x5djgl</sha1>
    </revision>
    <revision>
      <id>1932</id>
      <parentid>1931</parentid>
      <timestamp>2024-11-18T17:41:39Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <minor />
      <comment>4 revisions imported from [[:incubator:Template:Wp/nd/Cite_web]]</comment>
      <origin>1930</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5216" sha1="bjsb615ql985sygaax80s7qj5x5djgl" xml:space="preserve">&lt;includeonly&gt;{{Wp/nd/citation/core
|Citation class=web

|Surname1={{{last|{{{last1|{{{author|{{{author1|{{{authors|{{{surname|{{{surname1|}}}}}}}}}}}}}}}}}}}}}
|Surname2={{{last2|{{{author2|{{{surname2|}}}}}}}}}
|Surname3={{{last3|{{{author3|{{{surname3|}}}}}}}}}
|Surname4={{{last4|{{{author4|{{{surname4|}}}}}}}}}
|Surname5={{{last5|{{{author5|{{{surname5|}}}}}}}}}
|Surname6={{{last6|{{{author6|{{{surname6|}}}}}}}}}
|Surname7={{{last7|{{{author7|{{{surname7|}}}}}}}}}
|Surname8={{{last8|{{{author8|{{{surname8|}}}}}}}}}
|Surname9={{{last9|{{{author9|{{{surname9|}}}}}}}}}

|Given1={{{first|{{{first1|{{{given|{{{given1|}}}}}}}}}}}}
|Given2={{{first2|{{{given2|}}}}}}
|Given3={{{first3|{{{given3|}}}}}}
|Given4={{{first4|{{{given4|}}}}}}
|Given5={{{first5|{{{given5|}}}}}}
|Given6={{{first6|{{{given6|}}}}}}
|Given7={{{first7|{{{given7|}}}}}}
|Given8={{{first8|{{{given8|}}}}}}
|Given9={{{first9|{{{given9|}}}}}}

|Authorlink1={{{authorlink|{{{authorlink1|{{{author-link|{{{author1-link|}}}}}}}}}}}}
|Authorlink2={{{authorlink2|{{{author2-link|}}}}}}
|Authorlink3={{{authorlink3|{{{author3-link|}}}}}}
|Authorlink4={{{authorlink4|{{{author4-link|}}}}}}
|Authorlink5={{{authorlink5|{{{author5-link|}}}}}}
|Authorlink6={{{authorlink6|{{{author6-link|}}}}}}
|Authorlink7={{{authorlink7|{{{author7-link|}}}}}}
|Authorlink8={{{authorlink8|{{{author8-link|}}}}}}
|Authorlink9={{{authorlink9|{{{author9-link|}}}}}}

|Coauthors={{{coauthors|{{{coauthor|}}}}}}

|Other={{{others|}}}

|Year={{{year|{{    &lt;!-- attempt to derive year from date, if possible --&gt;
           #if: {{{date|}}}
           |{{
              #iferror:{{#time:Y|{{{date|}}} }}
              |{{#iferror:{{#time:Y|{{{publication-date|einval}}} }}||{{#time:Y|{{{publication-date|}}} }}}}
              |{{#time:Y|{{{date|}}} }}
            }}
           |{{{publication-date|}}} &lt;!-- last resort --&gt;
         }}
      }}}
|YearNote={{{origyear|}}}
|Date={{#if:{{{date|}}}|{{{date}}}|{{{day|}}} {{{month|}}} {{{year|{{{publication-date|}}}}}}}}

|Title={{{work|}}}
|IncludedWorkTitle={{
  #if:{{{title|}}}
  |{{{title}}}
  |{{
    #if:{{{trans_title|}}}
    |
    |{{Wp/nd/citation error|nocat={{{template doc demo|}}}|no &lt;code&gt;&amp;#124;title&amp;#61;&lt;/code&gt; specified|Cite web}}
    }}
  }}
|TransTitle={{{trans_title|}}}
|TitleType={{{type|}}}
|language={{{language|}}}

|IncludedWorkURL={{#if:{{{archiveurl|}}}
       |{{#ifeq: {{{deadurl|}}} | no | {{{url|}}} | {{{archiveurl|}}}}}
       |{{{url|}}}
     }}
|AccessDate={{{accessdate|}}}
|OriginalURL={{{url|}}}
|ArchiveURL={{{archiveurl|}}}
|ArchiveDate={{{archivedate|}}}
|DeadURL={{{deadurl|}}}
|format={{{format|}}}

|At={{#if: {{{page|}}}|{{#if:{{{nopp|}}}||p.&amp;nbsp;}}{{{page}}}
      |{{#if: {{{pages|}}}|{{#if:{{{nopp|}}}||pp.&amp;nbsp;}}{{{pages}}}
      |{{{at|}}}}}
    }}

|Series={{{agency|{{{series|{{{version|}}}}}}}}}

|Publisher={{{publisher|}}}
|Place={{{location|{{{place|}}}}}}
|PublicationPlace={{{location|{{{place|{{{publication-place|}}}}}}}}}
|PublicationDate={{{publication-date|}}}

|EditorSurname1={{{editor-last|{{{editor1-last|{{{editor|{{{editors|{{{editor-surname|{{{editor1-surname|}}}}}}}}}}}}}}}}}}
|EditorSurname2={{{editor2-last|{{{editor2-surname|}}}}}}
|EditorSurname3={{{editor3-last|{{{editor3-surname|}}}}}}
|EditorSurname4={{{editor4-last|{{{editor4-surname|}}}}}}
|EditorGiven1={{{editor-first|{{{editor1-first|{{{editor-given|{{{editor1-given|}}}}}}}}}}}}
|EditorGiven2={{{editor2-first|{{{editor2-given|}}}}}}
|EditorGiven3={{{editor3-first|{{{editor3-given|}}}}}}
|EditorGiven4={{{editor4-first|{{{editor4-given|}}}}}}
|Editorlink1={{{editor-link|{{{editor1-link|}}}}}}
|Editorlink2={{{editor2-link|}}}
|Editorlink3={{{editor3-link|}}}
|Editorlink4={{{editor4-link|}}}

|ARXIV={{{arxiv|}}}
|ASIN={{{asin|{{{ASIN|}}}}}}
|ASIN-TLD={{{asin-tld|}}}
|BIBCODE={{{bibcode|}}}
|DOI={{{doi|{{{DOI|}}}}}}
|DoiBroken={{{doi_brokendate|{{{doi_inactivedate|}}}}}}
|ISBN={{{isbn|{{{ISBN|}}}}}}
|ISSN={{{issn|{{{ISSN|}}}}}}
|JFM={{{jfm|{{{JFM|}}}}}}
|JSTOR={{{jstor|{{{JSTOR|}}}}}}
|LCCN={{{lccn|{{{LCCN|}}}}}}
|MR={{{mr|{{{MR|}}}}}}
|OCLC={{{oclc|{{{OCLC|}}}}}}
|OL={{{ol|{{{OL|}}}}}}
|OSTI={{{osti|{{{OSTI|}}}}}}
|PMC={{{pmc|{{{PMC|}}}}}}
|PMID={{{pmid|{{{PMID|}}}}}}
|RFC={{{rfc|{{{RFC|}}}}}}
|SSRN={{{ssrn|{{{SSRN|}}}}}}
|ZBL={{{zbl|}}}
|ID={{{id|{{{ID|}}}}}}

|laysummary={{{laysummary|}}}
|laydate={{{laydate|}}}
|laysource={{{laysource|}}}

|quote={{{quote|}}}

|Ref={{{ref|}}}

|amp={{{lastauthoramp|}}}
|AuthorMask={{{author-mask|{{{authormask|}}}}}}
|AuthorSep={{#ifeq:{{{author-separator|}}}|;|&amp;#059;|{{{author-separator|&amp;#059;}}}}}&amp;#32;
|NameSep={{{author-name-separator|,}}}&amp;#32;
|PS={{#if:{{{quote|}}}||{{{postscript|.}}}}}
|Sep={{#ifeq:{{{separator|{{{seperator}}} }}}|;|&amp;#059;|{{{separator|{{{seperator|.}}} }}} }}
|template doc demo={{{template doc demo|}}}
|Trunc={{#if:{{{display-authors|}}}|{{{display-authors}}}|8}}
}}{{#if:{{{access-date|}}}{{{accessdaymonth|}}}{{{accessday|}}}{{{accessmonthday|}}}{{{accessed|}}}{{{accessmonth|}}}{{{accessyear|}}}{{{dateformat|}}}{{{day|}}}{{{doilabel|}}}
|[[Category:Pages containing cite templates with deprecated parameters|{{NAMESPACE}} {{PAGENAME}}]]}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{Wp/nd/Documentation}}
&lt;/noinclude&gt;</text>
      <sha1>bjsb615ql985sygaax80s7qj5x5djgl</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Wp/nd/Citation/make link</title>
    <ns>10</ns>
    <id>370</id>
    <revision>
      <id>1933</id>
      <timestamp>2016-11-09T15:26:24Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;{{#if:{{{1|}}}  |[{{{1}}} {{{2}}}]  |{{{2}}} }}&lt;noinclude&gt;&lt;!--   Code notes (here so that people /read/ it)   1. Parameter #2 is always nonempty when called from {{Citation/co...&quot;</comment>
      <origin>1933</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="535" sha1="kpq1iofpfn0fdo5bshpu1vjve3ehx2d" xml:space="preserve">{{#if:{{{1|}}}
 |[{{{1}}} {{{2}}}]
 |{{{2}}}
}}&lt;noinclude&gt;&lt;!--
  Code notes (here so that people /read/ it)
  1. Parameter #2 is always nonempty when called from {{Citation/core}}.
  2. It's up to {{Citation/core}} to stop italicized &quot;'foo' &amp; 'bar'&quot; from becoming
     &quot;'''foo' &amp; 'bar'''&quot;. Citation/core does this by having a &lt;nowiki&gt;&lt;/nowiki&gt;
     at both beginning and end of the call to this template. Since this is only
     needed once, it's more efficient to do it in {{Citation/core}} than here.
--&gt;{{documentation}}&lt;/noinclude&gt;</text>
      <sha1>kpq1iofpfn0fdo5bshpu1vjve3ehx2d</sha1>
    </revision>
    <revision>
      <id>1934</id>
      <parentid>1933</parentid>
      <timestamp>2016-11-09T15:26:31Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>CFCF moved page [[Template:Wp/nd/Citation/make link]] to [[Template:Wp/nd/citation/make link]]</comment>
      <origin>1933</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="535" sha1="kpq1iofpfn0fdo5bshpu1vjve3ehx2d" xml:space="preserve">{{#if:{{{1|}}}
 |[{{{1}}} {{{2}}}]
 |{{{2}}}
}}&lt;noinclude&gt;&lt;!--
  Code notes (here so that people /read/ it)
  1. Parameter #2 is always nonempty when called from {{Citation/core}}.
  2. It's up to {{Citation/core}} to stop italicized &quot;'foo' &amp; 'bar'&quot; from becoming
     &quot;'''foo' &amp; 'bar'''&quot;. Citation/core does this by having a &lt;nowiki&gt;&lt;/nowiki&gt;
     at both beginning and end of the call to this template. Since this is only
     needed once, it's more efficient to do it in {{Citation/core}} than here.
--&gt;{{documentation}}&lt;/noinclude&gt;</text>
      <sha1>kpq1iofpfn0fdo5bshpu1vjve3ehx2d</sha1>
    </revision>
    <revision>
      <id>1935</id>
      <parentid>1934</parentid>
      <timestamp>2016-11-09T15:41:36Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <origin>1935</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="541" sha1="mcbs5fp13thk0tzk08yrklk3t52fduu" xml:space="preserve">{{#if:{{{1|}}}
 |[{{{1}}} {{{2}}}]
 |{{{2}}}
}}&lt;noinclude&gt;&lt;!--
  Code notes (here so that people /read/ it)
  1. Parameter #2 is always nonempty when called from {{Citation/core}}.
  2. It's up to {{Citation/core}} to stop italicized &quot;'foo' &amp; 'bar'&quot; from becoming
     &quot;'''foo' &amp; 'bar'''&quot;. Citation/core does this by having a &lt;nowiki&gt;&lt;/nowiki&gt;
     at both beginning and end of the call to this template. Since this is only
     needed once, it's more efficient to do it in {{Citation/core}} than here.
--&gt;{{Wp/nd/documentation}}&lt;/noinclude&gt;</text>
      <sha1>mcbs5fp13thk0tzk08yrklk3t52fduu</sha1>
    </revision>
    <revision>
      <id>1936</id>
      <parentid>1935</parentid>
      <timestamp>2022-04-27T09:34:04Z</timestamp>
      <contributor>
        <username>JhsBot</username>
        <id>34</id>
      </contributor>
      <minor />
      <comment>JhsBot moved page [[Template:Wp/nd/citation/make link]] to [[Template:Wp/nd/Citation/make link]] over redirect: bot: Moving pages with (what would be) lowercase titles to uppercase</comment>
      <origin>1935</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="541" sha1="mcbs5fp13thk0tzk08yrklk3t52fduu" xml:space="preserve">{{#if:{{{1|}}}
 |[{{{1}}} {{{2}}}]
 |{{{2}}}
}}&lt;noinclude&gt;&lt;!--
  Code notes (here so that people /read/ it)
  1. Parameter #2 is always nonempty when called from {{Citation/core}}.
  2. It's up to {{Citation/core}} to stop italicized &quot;'foo' &amp; 'bar'&quot; from becoming
     &quot;'''foo' &amp; 'bar'''&quot;. Citation/core does this by having a &lt;nowiki&gt;&lt;/nowiki&gt;
     at both beginning and end of the call to this template. Since this is only
     needed once, it's more efficient to do it in {{Citation/core}} than here.
--&gt;{{Wp/nd/documentation}}&lt;/noinclude&gt;</text>
      <sha1>mcbs5fp13thk0tzk08yrklk3t52fduu</sha1>
    </revision>
    <revision>
      <id>1937</id>
      <parentid>1936</parentid>
      <timestamp>2024-11-18T17:41:40Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <minor />
      <comment>4 revisions imported from [[:incubator:Template:Wp/nd/Citation/make_link]]</comment>
      <origin>1935</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="541" sha1="mcbs5fp13thk0tzk08yrklk3t52fduu" xml:space="preserve">{{#if:{{{1|}}}
 |[{{{1}}} {{{2}}}]
 |{{{2}}}
}}&lt;noinclude&gt;&lt;!--
  Code notes (here so that people /read/ it)
  1. Parameter #2 is always nonempty when called from {{Citation/core}}.
  2. It's up to {{Citation/core}} to stop italicized &quot;'foo' &amp; 'bar'&quot; from becoming
     &quot;'''foo' &amp; 'bar'''&quot;. Citation/core does this by having a &lt;nowiki&gt;&lt;/nowiki&gt;
     at both beginning and end of the call to this template. Since this is only
     needed once, it's more efficient to do it in {{Citation/core}} than here.
--&gt;{{Wp/nd/documentation}}&lt;/noinclude&gt;</text>
      <sha1>mcbs5fp13thk0tzk08yrklk3t52fduu</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Wp/nd/Hide in print</title>
    <ns>10</ns>
    <id>371</id>
    <revision>
      <id>1938</id>
      <timestamp>2016-11-09T15:21:51Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;&lt;includeonly&gt;{{{1|}}}&lt;/includeonly&gt;&lt;noinclude&gt; {{Wp/nd/documentation}} [[Category:Exclude in print|!]] &lt;/noinclude&gt;&quot;</comment>
      <origin>1938</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="115" sha1="n89rkczygz5ru78bpy93ybg7cii2h12" xml:space="preserve">&lt;includeonly&gt;{{{1|}}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{Wp/nd/documentation}}
[[Category:Exclude in print|!]]
&lt;/noinclude&gt;</text>
      <sha1>n89rkczygz5ru78bpy93ybg7cii2h12</sha1>
    </revision>
    <revision>
      <id>1939</id>
      <parentid>1938</parentid>
      <timestamp>2016-11-09T15:24:02Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>CFCF moved page [[Template:Wp/nd/Hide in print]] to [[Template:Wp/nd/hide in print]]</comment>
      <origin>1938</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="115" sha1="n89rkczygz5ru78bpy93ybg7cii2h12" xml:space="preserve">&lt;includeonly&gt;{{{1|}}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{Wp/nd/documentation}}
[[Category:Exclude in print|!]]
&lt;/noinclude&gt;</text>
      <sha1>n89rkczygz5ru78bpy93ybg7cii2h12</sha1>
    </revision>
    <revision>
      <id>1940</id>
      <parentid>1939</parentid>
      <timestamp>2022-04-27T09:34:10Z</timestamp>
      <contributor>
        <username>JhsBot</username>
        <id>34</id>
      </contributor>
      <minor />
      <comment>JhsBot moved page [[Template:Wp/nd/hide in print]] to [[Template:Wp/nd/Hide in print]] over redirect: bot: Moving pages with (what would be) lowercase titles to uppercase</comment>
      <origin>1938</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="115" sha1="n89rkczygz5ru78bpy93ybg7cii2h12" xml:space="preserve">&lt;includeonly&gt;{{{1|}}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{Wp/nd/documentation}}
[[Category:Exclude in print|!]]
&lt;/noinclude&gt;</text>
      <sha1>n89rkczygz5ru78bpy93ybg7cii2h12</sha1>
    </revision>
    <revision>
      <id>1941</id>
      <parentid>1940</parentid>
      <timestamp>2024-11-18T17:41:40Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <minor />
      <comment>3 revisions imported from [[:incubator:Template:Wp/nd/Hide_in_print]]</comment>
      <origin>1938</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="115" sha1="n89rkczygz5ru78bpy93ybg7cii2h12" xml:space="preserve">&lt;includeonly&gt;{{{1|}}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{Wp/nd/documentation}}
[[Category:Exclude in print|!]]
&lt;/noinclude&gt;</text>
      <sha1>n89rkczygz5ru78bpy93ybg7cii2h12</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Wp/nd/Citation/identifier</title>
    <ns>10</ns>
    <id>372</id>
    <revision>
      <id>1942</id>
      <timestamp>2016-11-09T15:21:04Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>[[:en:Template:Citation/identifier]]</comment>
      <origin>1942</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6257" sha1="8zjdvahpzhfmdpjp9uvrg2ye9v02150" xml:space="preserve">{{#switch:{{{identifier}}}
 |arxiv={{Wp/nd/hide in print
         |[[Wp/nd/Citation/arXiv|arXiv]]:[http://arxiv.org/abs/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
        }}&lt;!--
     --&gt;{{Wp/nd/only in print
         |arXiv:{{{input1|}}}
        }}
 |asin={{Wp/nd/hide in print
        |[[Wp/nd/Citation/Amazon Standard Identification Number|ASIN]]&amp;nbsp;[//www.amazon.&lt;!--
     --&gt;{{#switch: {{{input2|}}}
          |ca=ca
          |cn=cn
          |de=de
          |ed=es
          |fr=fr
          |it=it
          |jp=co.jp
          |co.jp=co.jp
          |uk=co.uk
          |co.uk=co.uk
          |#default=com
         }}/dp/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |ASIN&amp;nbsp;{{{input1|}}}
       }}
 |bibcode={{Wp/nd/hide in print
           |[[Wp/nd/Citation/Bibcode|Bibcode]] [http://adsabs.harvard.edu/abs/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
          }}&lt;!--
       --&gt;{{Wp/nd/only in print
           |Bibcode&amp;nbsp;{{{input1|}}}
          }}
 |doi={{Wp/nd/hide in print
       |{{#ifeq:{{str left|{{{input1|}}}|3}}|10.
         |{{#if:{{{input2|}}}
           |[[Wp/nd/Citation/Digital object identifier|doi]]:{{{input1|}}} (inactive {{{input2|}}}) &lt;!--
            --&gt;{{#ifeq:{{NAMESPACE}}|{{ns:0}}
                |[[Category:Pages with DOIs inactive since {{#time: Y | {{{input2|}}} }}]]
                |
               }}
           |[[Wp/nd/Citation/Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:{{{input1|}}}}} {{#tag:nowiki|{{{input1|}}}}}]
          }}
         |{{citation error|nocat={{{input3|}}}|cat=Pages with DOI errors|Bad DOI specified}}
        }}
      }}&lt;!--
   --&gt;{{Wp/nd/only in print
       |{{#if:{{{input2|}}}
         |doi:{{{input1|}}} (inactive {{{input2|}}})
         |doi:{{{input1|}}}
        }}
      }}
 |isbn={{Wp/nd/hide in print
        |[[Wp/nd/Citation/International Standard Book Number|ISBN]]&amp;nbsp;[[Special:BookSources/{{{input1|}}}|{{{input1|}}}]]{{
         #if: {{{input1|}}} |{{#invoke:check isxn|check_isbn|{{{input1}}}|error=&lt;span class=&quot;error&quot; style=&quot;font-size:88%&quot;&gt;Check ISBN&lt;/span&gt;{{main other|[[Category:Pages with ISBN errors]]}}}}
         }}
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |ISBN&amp;nbsp;{{{input1|}}}
       }}
 |issn={{Wp/nd/hide in print
        |[[Wp/nd/Citation/International Standard Serial Number|ISSN]]&amp;nbsp;[//www.worldcat.org/issn/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |ISSN&amp;nbsp;{{{input1|}}}
       }}
 |jfm={{Wp/nd/hide in print
       |[[Wp/nd/Citation/Jahrbuch über die Fortschritte der Mathematik|JFM]]&amp;nbsp;[http://www.zentralblatt-math.org/zmath/en/search/?q{{=}}an:{{{input1|}}}&amp;format{{=}}complete {{#tag:nowiki|{{{input1|}}}}}]
      }}&lt;!--
   --&gt;{{Wp/nd/only in print
       |JFM&amp;nbsp;{{{input1|}}}
      }}
 |jstor={{Wp/nd/hide in print
         |[[Wp/nd/Citation/JSTOR|JSTOR]]&amp;nbsp;[http://www.jstor.org/stable/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
        }}&lt;!--
     --&gt;{{Wp/nd/only in print
         |JSTOR&amp;nbsp;{{{input1|}}}
         }}
 |lccn={{Wp/nd/hide in print
         |[[Wp/nd/Citation/Library of Congress Control Number|LCCN]]&amp;nbsp;[http://lccn.loc.gov/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
        }}&lt;!--
     --&gt;{{Wp/nd/only in print
         |LCCN&amp;nbsp;{{{input1|}}}
         }}
 |mr={{Wp/nd/hide in print
      |[[Wp/nd/Citation/Mathematical Reviews|MR]]&amp;nbsp;[http://www.ams.org/mathscinet-getitem?mr{{=}}{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
     }}&lt;!--
  --&gt;{{Wp/nd/only in print
      |MR{{{input1|}}}
     }}
 |oclc={{Wp/nd/hide in print
        |[[Wp/nd/Citation/OCLC|OCLC]]&amp;nbsp;[//www.worldcat.org/oclc/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |OCLC&amp;nbsp;{{{input1|}}}
       }}
 |ol={{Wp/nd/hide in print
      |1={{#if:{{str endswith|{{{input1|}}}|A}}
          |[[Wp/nd/Citation/Open Library|OL]][http://openlibrary.org/authors/OL{{urlencode:{{{input1|}}}}} {{{input1|}}}]
          |{{#if:{{str endswith|{{{input1|}}}|M}}
            |[[Wp/nd/Citation/Open Library|OL]][http://openlibrary.org/books/OL{{urlencode:{{{input1|}}}}} {{{input1|}}}]
            |{{#if:{{str endswith|{{{input1|}}}|W}}
              |[[Wp/nd/Citation/Open Library|OL]][http://openlibrary.org/works/OL{{urlencode:{{{input1|}}}}} {{{input1|}}}]
              |&lt;includeonly&gt;[[Category:Pages with OL errors]]&lt;span class=&quot;error&quot;&gt;Error: Bad OL specified!&lt;/span&gt;&lt;/includeonly&gt;
             }}
           }}
         }}
     }}&lt;!--
--&gt;{{Wp/nd/only in print
    |1=OL{{{id|{{{1}}}}}}
   }}
 |osti={{Wp/nd/hide in print
        |[[Wp/nd/Citation/Office of Scientific and Technical Information|OSTI]]&amp;nbsp;[http://www.osti.gov/energycitations/product.biblio.jsp?osti_id{{=}}{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |OSTI&amp;nbsp;{{{input1|}}}
       }}
 |pmc={{Wp/nd/hide in print
        |[[Wp/nd/Citation/PubMed Central|PMC]]&amp;nbsp;[//www.ncbi.nlm.nih.gov/pmc/articles/PMC{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
      }}&lt;!--
   --&gt;{{Wp/nd/only in print
       |PMC&amp;nbsp;{{{input1|}}}
      }}
 |pmid={{Wp/nd/hide in print
        |[[Wp/nd/Citation/PubMed Identifier|PMID]]&amp;nbsp;[//www.ncbi.nlm.nih.gov/pubmed/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |PMID&amp;nbsp;{{{input1|}}}
       }}
 |rfc={{Wp/nd/hide in print
        |[[Wp/nd/Citation/Request for Comments|RFC]]&amp;nbsp;[//tools.ietf.org/html/rfc{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |RFC&amp;nbsp;{{{input1|}}}
       }}
 |ssrn={{Wp/nd/hide in print
        |[[Wp/nd/Citation/Social Science Research Network|SSRN]]&amp;nbsp;[http://ssrn.com/abstract{{=}}{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |SSRN&amp;nbsp;{{{input1|}}}
       }}
 |zbl={{Wp/nd/hide in print
        |[[Wp/nd/Citation/Zentralblatt MATH|Zbl]]&amp;nbsp;[http://www.zentralblatt-math.org/zmath/en/search/?q{{=}}an:{{{input1|}}}&amp;format{{=}}complete {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |Zbl&amp;nbsp;{{{input1|}}}
       }}
}}&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>8zjdvahpzhfmdpjp9uvrg2ye9v02150</sha1>
    </revision>
    <revision>
      <id>1943</id>
      <parentid>1942</parentid>
      <timestamp>2016-11-09T15:21:16Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <origin>1943</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6263" sha1="2pmmcgkr0ucktaspud5a7ankobasxqi" xml:space="preserve">{{#switch:{{{identifier}}}
 |arxiv={{Wp/nd/hide in print
         |[[Wp/nd/Citation/arXiv|arXiv]]:[http://arxiv.org/abs/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
        }}&lt;!--
     --&gt;{{Wp/nd/only in print
         |arXiv:{{{input1|}}}
        }}
 |asin={{Wp/nd/hide in print
        |[[Wp/nd/Citation/Amazon Standard Identification Number|ASIN]]&amp;nbsp;[//www.amazon.&lt;!--
     --&gt;{{#switch: {{{input2|}}}
          |ca=ca
          |cn=cn
          |de=de
          |ed=es
          |fr=fr
          |it=it
          |jp=co.jp
          |co.jp=co.jp
          |uk=co.uk
          |co.uk=co.uk
          |#default=com
         }}/dp/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |ASIN&amp;nbsp;{{{input1|}}}
       }}
 |bibcode={{Wp/nd/hide in print
           |[[Wp/nd/Citation/Bibcode|Bibcode]] [http://adsabs.harvard.edu/abs/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
          }}&lt;!--
       --&gt;{{Wp/nd/only in print
           |Bibcode&amp;nbsp;{{{input1|}}}
          }}
 |doi={{Wp/nd/hide in print
       |{{#ifeq:{{str left|{{{input1|}}}|3}}|10.
         |{{#if:{{{input2|}}}
           |[[Wp/nd/Citation/Digital object identifier|doi]]:{{{input1|}}} (inactive {{{input2|}}}) &lt;!--
            --&gt;{{#ifeq:{{NAMESPACE}}|{{ns:0}}
                |[[Category:Pages with DOIs inactive since {{#time: Y | {{{input2|}}} }}]]
                |
               }}
           |[[Wp/nd/Citation/Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:{{{input1|}}}}} {{#tag:nowiki|{{{input1|}}}}}]
          }}
         |{{citation error|nocat={{{input3|}}}|cat=Pages with DOI errors|Bad DOI specified}}
        }}
      }}&lt;!--
   --&gt;{{Wp/nd/only in print
       |{{#if:{{{input2|}}}
         |doi:{{{input1|}}} (inactive {{{input2|}}})
         |doi:{{{input1|}}}
        }}
      }}
 |isbn={{Wp/nd/hide in print
        |[[Wp/nd/Citation/International Standard Book Number|ISBN]]&amp;nbsp;[[Special:BookSources/{{{input1|}}}|{{{input1|}}}]]{{
         #if: {{{input1|}}} |{{#invoke:check isxn|check_isbn|{{{input1}}}|error=&lt;span class=&quot;error&quot; style=&quot;font-size:88%&quot;&gt;Check ISBN&lt;/span&gt;{{main other|[[Category:Pages with ISBN errors]]}}}}
         }}
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |ISBN&amp;nbsp;{{{input1|}}}
       }}
 |issn={{Wp/nd/hide in print
        |[[Wp/nd/Citation/International Standard Serial Number|ISSN]]&amp;nbsp;[//www.worldcat.org/issn/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |ISSN&amp;nbsp;{{{input1|}}}
       }}
 |jfm={{Wp/nd/hide in print
       |[[Wp/nd/Citation/Jahrbuch über die Fortschritte der Mathematik|JFM]]&amp;nbsp;[http://www.zentralblatt-math.org/zmath/en/search/?q{{=}}an:{{{input1|}}}&amp;format{{=}}complete {{#tag:nowiki|{{{input1|}}}}}]
      }}&lt;!--
   --&gt;{{Wp/nd/only in print
       |JFM&amp;nbsp;{{{input1|}}}
      }}
 |jstor={{Wp/nd/hide in print
         |[[Wp/nd/Citation/JSTOR|JSTOR]]&amp;nbsp;[http://www.jstor.org/stable/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
        }}&lt;!--
     --&gt;{{Wp/nd/only in print
         |JSTOR&amp;nbsp;{{{input1|}}}
         }}
 |lccn={{Wp/nd/hide in print
         |[[Wp/nd/Citation/Library of Congress Control Number|LCCN]]&amp;nbsp;[http://lccn.loc.gov/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
        }}&lt;!--
     --&gt;{{Wp/nd/only in print
         |LCCN&amp;nbsp;{{{input1|}}}
         }}
 |mr={{Wp/nd/hide in print
      |[[Wp/nd/Citation/Mathematical Reviews|MR]]&amp;nbsp;[http://www.ams.org/mathscinet-getitem?mr{{=}}{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
     }}&lt;!--
  --&gt;{{Wp/nd/only in print
      |MR{{{input1|}}}
     }}
 |oclc={{Wp/nd/hide in print
        |[[Wp/nd/Citation/OCLC|OCLC]]&amp;nbsp;[//www.worldcat.org/oclc/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |OCLC&amp;nbsp;{{{input1|}}}
       }}
 |ol={{Wp/nd/hide in print
      |1={{#if:{{str endswith|{{{input1|}}}|A}}
          |[[Wp/nd/Citation/Open Library|OL]][http://openlibrary.org/authors/OL{{urlencode:{{{input1|}}}}} {{{input1|}}}]
          |{{#if:{{str endswith|{{{input1|}}}|M}}
            |[[Wp/nd/Citation/Open Library|OL]][http://openlibrary.org/books/OL{{urlencode:{{{input1|}}}}} {{{input1|}}}]
            |{{#if:{{str endswith|{{{input1|}}}|W}}
              |[[Wp/nd/Citation/Open Library|OL]][http://openlibrary.org/works/OL{{urlencode:{{{input1|}}}}} {{{input1|}}}]
              |&lt;includeonly&gt;[[Category:Pages with OL errors]]&lt;span class=&quot;error&quot;&gt;Error: Bad OL specified!&lt;/span&gt;&lt;/includeonly&gt;
             }}
           }}
         }}
     }}&lt;!--
--&gt;{{Wp/nd/only in print
    |1=OL{{{id|{{{1}}}}}}
   }}
 |osti={{Wp/nd/hide in print
        |[[Wp/nd/Citation/Office of Scientific and Technical Information|OSTI]]&amp;nbsp;[http://www.osti.gov/energycitations/product.biblio.jsp?osti_id{{=}}{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |OSTI&amp;nbsp;{{{input1|}}}
       }}
 |pmc={{Wp/nd/hide in print
        |[[Wp/nd/Citation/PubMed Central|PMC]]&amp;nbsp;[//www.ncbi.nlm.nih.gov/pmc/articles/PMC{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
      }}&lt;!--
   --&gt;{{Wp/nd/only in print
       |PMC&amp;nbsp;{{{input1|}}}
      }}
 |pmid={{Wp/nd/hide in print
        |[[Wp/nd/Citation/PubMed Identifier|PMID]]&amp;nbsp;[//www.ncbi.nlm.nih.gov/pubmed/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |PMID&amp;nbsp;{{{input1|}}}
       }}
 |rfc={{Wp/nd/hide in print
        |[[Wp/nd/Citation/Request for Comments|RFC]]&amp;nbsp;[//tools.ietf.org/html/rfc{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |RFC&amp;nbsp;{{{input1|}}}
       }}
 |ssrn={{Wp/nd/hide in print
        |[[Wp/nd/Citation/Social Science Research Network|SSRN]]&amp;nbsp;[http://ssrn.com/abstract{{=}}{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |SSRN&amp;nbsp;{{{input1|}}}
       }}
 |zbl={{Wp/nd/hide in print
        |[[Wp/nd/Citation/Zentralblatt MATH|Zbl]]&amp;nbsp;[http://www.zentralblatt-math.org/zmath/en/search/?q{{=}}an:{{{input1|}}}&amp;format{{=}}complete {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |Zbl&amp;nbsp;{{{input1|}}}
       }}
}}&lt;noinclude&gt;
{{Wp/nd/documentation}}
&lt;/noinclude&gt;</text>
      <sha1>2pmmcgkr0ucktaspud5a7ankobasxqi</sha1>
    </revision>
    <revision>
      <id>1944</id>
      <parentid>1943</parentid>
      <timestamp>2016-11-09T15:22:46Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>CFCF moved page [[Template:Wp/nd/Citation/identifier]] to [[Template:Wp/nd/citation/identifier]]</comment>
      <origin>1943</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6263" sha1="2pmmcgkr0ucktaspud5a7ankobasxqi" xml:space="preserve">{{#switch:{{{identifier}}}
 |arxiv={{Wp/nd/hide in print
         |[[Wp/nd/Citation/arXiv|arXiv]]:[http://arxiv.org/abs/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
        }}&lt;!--
     --&gt;{{Wp/nd/only in print
         |arXiv:{{{input1|}}}
        }}
 |asin={{Wp/nd/hide in print
        |[[Wp/nd/Citation/Amazon Standard Identification Number|ASIN]]&amp;nbsp;[//www.amazon.&lt;!--
     --&gt;{{#switch: {{{input2|}}}
          |ca=ca
          |cn=cn
          |de=de
          |ed=es
          |fr=fr
          |it=it
          |jp=co.jp
          |co.jp=co.jp
          |uk=co.uk
          |co.uk=co.uk
          |#default=com
         }}/dp/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |ASIN&amp;nbsp;{{{input1|}}}
       }}
 |bibcode={{Wp/nd/hide in print
           |[[Wp/nd/Citation/Bibcode|Bibcode]] [http://adsabs.harvard.edu/abs/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
          }}&lt;!--
       --&gt;{{Wp/nd/only in print
           |Bibcode&amp;nbsp;{{{input1|}}}
          }}
 |doi={{Wp/nd/hide in print
       |{{#ifeq:{{str left|{{{input1|}}}|3}}|10.
         |{{#if:{{{input2|}}}
           |[[Wp/nd/Citation/Digital object identifier|doi]]:{{{input1|}}} (inactive {{{input2|}}}) &lt;!--
            --&gt;{{#ifeq:{{NAMESPACE}}|{{ns:0}}
                |[[Category:Pages with DOIs inactive since {{#time: Y | {{{input2|}}} }}]]
                |
               }}
           |[[Wp/nd/Citation/Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:{{{input1|}}}}} {{#tag:nowiki|{{{input1|}}}}}]
          }}
         |{{citation error|nocat={{{input3|}}}|cat=Pages with DOI errors|Bad DOI specified}}
        }}
      }}&lt;!--
   --&gt;{{Wp/nd/only in print
       |{{#if:{{{input2|}}}
         |doi:{{{input1|}}} (inactive {{{input2|}}})
         |doi:{{{input1|}}}
        }}
      }}
 |isbn={{Wp/nd/hide in print
        |[[Wp/nd/Citation/International Standard Book Number|ISBN]]&amp;nbsp;[[Special:BookSources/{{{input1|}}}|{{{input1|}}}]]{{
         #if: {{{input1|}}} |{{#invoke:check isxn|check_isbn|{{{input1}}}|error=&lt;span class=&quot;error&quot; style=&quot;font-size:88%&quot;&gt;Check ISBN&lt;/span&gt;{{main other|[[Category:Pages with ISBN errors]]}}}}
         }}
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |ISBN&amp;nbsp;{{{input1|}}}
       }}
 |issn={{Wp/nd/hide in print
        |[[Wp/nd/Citation/International Standard Serial Number|ISSN]]&amp;nbsp;[//www.worldcat.org/issn/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |ISSN&amp;nbsp;{{{input1|}}}
       }}
 |jfm={{Wp/nd/hide in print
       |[[Wp/nd/Citation/Jahrbuch über die Fortschritte der Mathematik|JFM]]&amp;nbsp;[http://www.zentralblatt-math.org/zmath/en/search/?q{{=}}an:{{{input1|}}}&amp;format{{=}}complete {{#tag:nowiki|{{{input1|}}}}}]
      }}&lt;!--
   --&gt;{{Wp/nd/only in print
       |JFM&amp;nbsp;{{{input1|}}}
      }}
 |jstor={{Wp/nd/hide in print
         |[[Wp/nd/Citation/JSTOR|JSTOR]]&amp;nbsp;[http://www.jstor.org/stable/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
        }}&lt;!--
     --&gt;{{Wp/nd/only in print
         |JSTOR&amp;nbsp;{{{input1|}}}
         }}
 |lccn={{Wp/nd/hide in print
         |[[Wp/nd/Citation/Library of Congress Control Number|LCCN]]&amp;nbsp;[http://lccn.loc.gov/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
        }}&lt;!--
     --&gt;{{Wp/nd/only in print
         |LCCN&amp;nbsp;{{{input1|}}}
         }}
 |mr={{Wp/nd/hide in print
      |[[Wp/nd/Citation/Mathematical Reviews|MR]]&amp;nbsp;[http://www.ams.org/mathscinet-getitem?mr{{=}}{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
     }}&lt;!--
  --&gt;{{Wp/nd/only in print
      |MR{{{input1|}}}
     }}
 |oclc={{Wp/nd/hide in print
        |[[Wp/nd/Citation/OCLC|OCLC]]&amp;nbsp;[//www.worldcat.org/oclc/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |OCLC&amp;nbsp;{{{input1|}}}
       }}
 |ol={{Wp/nd/hide in print
      |1={{#if:{{str endswith|{{{input1|}}}|A}}
          |[[Wp/nd/Citation/Open Library|OL]][http://openlibrary.org/authors/OL{{urlencode:{{{input1|}}}}} {{{input1|}}}]
          |{{#if:{{str endswith|{{{input1|}}}|M}}
            |[[Wp/nd/Citation/Open Library|OL]][http://openlibrary.org/books/OL{{urlencode:{{{input1|}}}}} {{{input1|}}}]
            |{{#if:{{str endswith|{{{input1|}}}|W}}
              |[[Wp/nd/Citation/Open Library|OL]][http://openlibrary.org/works/OL{{urlencode:{{{input1|}}}}} {{{input1|}}}]
              |&lt;includeonly&gt;[[Category:Pages with OL errors]]&lt;span class=&quot;error&quot;&gt;Error: Bad OL specified!&lt;/span&gt;&lt;/includeonly&gt;
             }}
           }}
         }}
     }}&lt;!--
--&gt;{{Wp/nd/only in print
    |1=OL{{{id|{{{1}}}}}}
   }}
 |osti={{Wp/nd/hide in print
        |[[Wp/nd/Citation/Office of Scientific and Technical Information|OSTI]]&amp;nbsp;[http://www.osti.gov/energycitations/product.biblio.jsp?osti_id{{=}}{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |OSTI&amp;nbsp;{{{input1|}}}
       }}
 |pmc={{Wp/nd/hide in print
        |[[Wp/nd/Citation/PubMed Central|PMC]]&amp;nbsp;[//www.ncbi.nlm.nih.gov/pmc/articles/PMC{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
      }}&lt;!--
   --&gt;{{Wp/nd/only in print
       |PMC&amp;nbsp;{{{input1|}}}
      }}
 |pmid={{Wp/nd/hide in print
        |[[Wp/nd/Citation/PubMed Identifier|PMID]]&amp;nbsp;[//www.ncbi.nlm.nih.gov/pubmed/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |PMID&amp;nbsp;{{{input1|}}}
       }}
 |rfc={{Wp/nd/hide in print
        |[[Wp/nd/Citation/Request for Comments|RFC]]&amp;nbsp;[//tools.ietf.org/html/rfc{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |RFC&amp;nbsp;{{{input1|}}}
       }}
 |ssrn={{Wp/nd/hide in print
        |[[Wp/nd/Citation/Social Science Research Network|SSRN]]&amp;nbsp;[http://ssrn.com/abstract{{=}}{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |SSRN&amp;nbsp;{{{input1|}}}
       }}
 |zbl={{Wp/nd/hide in print
        |[[Wp/nd/Citation/Zentralblatt MATH|Zbl]]&amp;nbsp;[http://www.zentralblatt-math.org/zmath/en/search/?q{{=}}an:{{{input1|}}}&amp;format{{=}}complete {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |Zbl&amp;nbsp;{{{input1|}}}
       }}
}}&lt;noinclude&gt;
{{Wp/nd/documentation}}
&lt;/noinclude&gt;</text>
      <sha1>2pmmcgkr0ucktaspud5a7ankobasxqi</sha1>
    </revision>
    <revision>
      <id>1945</id>
      <parentid>1944</parentid>
      <timestamp>2016-11-09T15:42:21Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <origin>1945</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6269" sha1="dzu93ablu6efif7kqhobb0cs18sn9bd" xml:space="preserve">{{#switch:{{{identifier}}}
 |arxiv={{Wp/nd/hide in print
         |[[Wp/nd/Citation/arXiv|arXiv]]:[http://arxiv.org/abs/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
        }}&lt;!--
     --&gt;{{Wp/nd/only in print
         |arXiv:{{{input1|}}}
        }}
 |asin={{Wp/nd/hide in print
        |[[Wp/nd/Citation/Amazon Standard Identification Number|ASIN]]&amp;nbsp;[//www.amazon.&lt;!--
     --&gt;{{#switch: {{{input2|}}}
          |ca=ca
          |cn=cn
          |de=de
          |ed=es
          |fr=fr
          |it=it
          |jp=co.jp
          |co.jp=co.jp
          |uk=co.uk
          |co.uk=co.uk
          |#default=com
         }}/dp/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |ASIN&amp;nbsp;{{{input1|}}}
       }}
 |bibcode={{Wp/nd/hide in print
           |[[Wp/nd/Citation/Bibcode|Bibcode]] [http://adsabs.harvard.edu/abs/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
          }}&lt;!--
       --&gt;{{Wp/nd/only in print
           |Bibcode&amp;nbsp;{{{input1|}}}
          }}
 |doi={{Wp/nd/hide in print
       |{{#ifeq:{{str left|{{{input1|}}}|3}}|10.
         |{{#if:{{{input2|}}}
           |[[Wp/nd/Citation/Digital object identifier|doi]]:{{{input1|}}} (inactive {{{input2|}}}) &lt;!--
            --&gt;{{#ifeq:{{NAMESPACE}}|{{ns:0}}
                |[[Category:Pages with DOIs inactive since {{#time: Y | {{{input2|}}} }}]]
                |
               }}
           |[[Wp/nd/Citation/Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:{{{input1|}}}}} {{#tag:nowiki|{{{input1|}}}}}]
          }}
         |{{citation error|nocat={{{input3|}}}|cat=Pages with DOI errors|Bad DOI specified}}
        }}
      }}&lt;!--
   --&gt;{{Wp/nd/only in print
       |{{#if:{{{input2|}}}
         |doi:{{{input1|}}} (inactive {{{input2|}}})
         |doi:{{{input1|}}}
        }}
      }}
 |isbn={{Wp/nd/hide in print
        |[[Wp/nd/Citation/International Standard Book Number|ISBN]]&amp;nbsp;[[Special:BookSources/{{{input1|}}}|{{{input1|}}}]]{{
         #if: {{{input1|}}} |{{#invoke:Wp/nd/check isxn|check_isbn|{{{input1}}}|error=&lt;span class=&quot;error&quot; style=&quot;font-size:88%&quot;&gt;Check ISBN&lt;/span&gt;{{main other|[[Category:Pages with ISBN errors]]}}}}
         }}
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |ISBN&amp;nbsp;{{{input1|}}}
       }}
 |issn={{Wp/nd/hide in print
        |[[Wp/nd/Citation/International Standard Serial Number|ISSN]]&amp;nbsp;[//www.worldcat.org/issn/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |ISSN&amp;nbsp;{{{input1|}}}
       }}
 |jfm={{Wp/nd/hide in print
       |[[Wp/nd/Citation/Jahrbuch über die Fortschritte der Mathematik|JFM]]&amp;nbsp;[http://www.zentralblatt-math.org/zmath/en/search/?q{{=}}an:{{{input1|}}}&amp;format{{=}}complete {{#tag:nowiki|{{{input1|}}}}}]
      }}&lt;!--
   --&gt;{{Wp/nd/only in print
       |JFM&amp;nbsp;{{{input1|}}}
      }}
 |jstor={{Wp/nd/hide in print
         |[[Wp/nd/Citation/JSTOR|JSTOR]]&amp;nbsp;[http://www.jstor.org/stable/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
        }}&lt;!--
     --&gt;{{Wp/nd/only in print
         |JSTOR&amp;nbsp;{{{input1|}}}
         }}
 |lccn={{Wp/nd/hide in print
         |[[Wp/nd/Citation/Library of Congress Control Number|LCCN]]&amp;nbsp;[http://lccn.loc.gov/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
        }}&lt;!--
     --&gt;{{Wp/nd/only in print
         |LCCN&amp;nbsp;{{{input1|}}}
         }}
 |mr={{Wp/nd/hide in print
      |[[Wp/nd/Citation/Mathematical Reviews|MR]]&amp;nbsp;[http://www.ams.org/mathscinet-getitem?mr{{=}}{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
     }}&lt;!--
  --&gt;{{Wp/nd/only in print
      |MR{{{input1|}}}
     }}
 |oclc={{Wp/nd/hide in print
        |[[Wp/nd/Citation/OCLC|OCLC]]&amp;nbsp;[//www.worldcat.org/oclc/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |OCLC&amp;nbsp;{{{input1|}}}
       }}
 |ol={{Wp/nd/hide in print
      |1={{#if:{{str endswith|{{{input1|}}}|A}}
          |[[Wp/nd/Citation/Open Library|OL]][http://openlibrary.org/authors/OL{{urlencode:{{{input1|}}}}} {{{input1|}}}]
          |{{#if:{{str endswith|{{{input1|}}}|M}}
            |[[Wp/nd/Citation/Open Library|OL]][http://openlibrary.org/books/OL{{urlencode:{{{input1|}}}}} {{{input1|}}}]
            |{{#if:{{str endswith|{{{input1|}}}|W}}
              |[[Wp/nd/Citation/Open Library|OL]][http://openlibrary.org/works/OL{{urlencode:{{{input1|}}}}} {{{input1|}}}]
              |&lt;includeonly&gt;[[Category:Pages with OL errors]]&lt;span class=&quot;error&quot;&gt;Error: Bad OL specified!&lt;/span&gt;&lt;/includeonly&gt;
             }}
           }}
         }}
     }}&lt;!--
--&gt;{{Wp/nd/only in print
    |1=OL{{{id|{{{1}}}}}}
   }}
 |osti={{Wp/nd/hide in print
        |[[Wp/nd/Citation/Office of Scientific and Technical Information|OSTI]]&amp;nbsp;[http://www.osti.gov/energycitations/product.biblio.jsp?osti_id{{=}}{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |OSTI&amp;nbsp;{{{input1|}}}
       }}
 |pmc={{Wp/nd/hide in print
        |[[Wp/nd/Citation/PubMed Central|PMC]]&amp;nbsp;[//www.ncbi.nlm.nih.gov/pmc/articles/PMC{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
      }}&lt;!--
   --&gt;{{Wp/nd/only in print
       |PMC&amp;nbsp;{{{input1|}}}
      }}
 |pmid={{Wp/nd/hide in print
        |[[Wp/nd/Citation/PubMed Identifier|PMID]]&amp;nbsp;[//www.ncbi.nlm.nih.gov/pubmed/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |PMID&amp;nbsp;{{{input1|}}}
       }}
 |rfc={{Wp/nd/hide in print
        |[[Wp/nd/Citation/Request for Comments|RFC]]&amp;nbsp;[//tools.ietf.org/html/rfc{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |RFC&amp;nbsp;{{{input1|}}}
       }}
 |ssrn={{Wp/nd/hide in print
        |[[Wp/nd/Citation/Social Science Research Network|SSRN]]&amp;nbsp;[http://ssrn.com/abstract{{=}}{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |SSRN&amp;nbsp;{{{input1|}}}
       }}
 |zbl={{Wp/nd/hide in print
        |[[Wp/nd/Citation/Zentralblatt MATH|Zbl]]&amp;nbsp;[http://www.zentralblatt-math.org/zmath/en/search/?q{{=}}an:{{{input1|}}}&amp;format{{=}}complete {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |Zbl&amp;nbsp;{{{input1|}}}
       }}
}}&lt;noinclude&gt;
{{Wp/nd/documentation}}
&lt;/noinclude&gt;</text>
      <sha1>dzu93ablu6efif7kqhobb0cs18sn9bd</sha1>
    </revision>
    <revision>
      <id>1946</id>
      <parentid>1945</parentid>
      <timestamp>2022-04-27T09:34:01Z</timestamp>
      <contributor>
        <username>JhsBot</username>
        <id>34</id>
      </contributor>
      <minor />
      <comment>JhsBot moved page [[Template:Wp/nd/citation/identifier]] to [[Template:Wp/nd/Citation/identifier]] over redirect: bot: Moving pages with (what would be) lowercase titles to uppercase</comment>
      <origin>1945</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6269" sha1="dzu93ablu6efif7kqhobb0cs18sn9bd" xml:space="preserve">{{#switch:{{{identifier}}}
 |arxiv={{Wp/nd/hide in print
         |[[Wp/nd/Citation/arXiv|arXiv]]:[http://arxiv.org/abs/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
        }}&lt;!--
     --&gt;{{Wp/nd/only in print
         |arXiv:{{{input1|}}}
        }}
 |asin={{Wp/nd/hide in print
        |[[Wp/nd/Citation/Amazon Standard Identification Number|ASIN]]&amp;nbsp;[//www.amazon.&lt;!--
     --&gt;{{#switch: {{{input2|}}}
          |ca=ca
          |cn=cn
          |de=de
          |ed=es
          |fr=fr
          |it=it
          |jp=co.jp
          |co.jp=co.jp
          |uk=co.uk
          |co.uk=co.uk
          |#default=com
         }}/dp/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |ASIN&amp;nbsp;{{{input1|}}}
       }}
 |bibcode={{Wp/nd/hide in print
           |[[Wp/nd/Citation/Bibcode|Bibcode]] [http://adsabs.harvard.edu/abs/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
          }}&lt;!--
       --&gt;{{Wp/nd/only in print
           |Bibcode&amp;nbsp;{{{input1|}}}
          }}
 |doi={{Wp/nd/hide in print
       |{{#ifeq:{{str left|{{{input1|}}}|3}}|10.
         |{{#if:{{{input2|}}}
           |[[Wp/nd/Citation/Digital object identifier|doi]]:{{{input1|}}} (inactive {{{input2|}}}) &lt;!--
            --&gt;{{#ifeq:{{NAMESPACE}}|{{ns:0}}
                |[[Category:Pages with DOIs inactive since {{#time: Y | {{{input2|}}} }}]]
                |
               }}
           |[[Wp/nd/Citation/Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:{{{input1|}}}}} {{#tag:nowiki|{{{input1|}}}}}]
          }}
         |{{citation error|nocat={{{input3|}}}|cat=Pages with DOI errors|Bad DOI specified}}
        }}
      }}&lt;!--
   --&gt;{{Wp/nd/only in print
       |{{#if:{{{input2|}}}
         |doi:{{{input1|}}} (inactive {{{input2|}}})
         |doi:{{{input1|}}}
        }}
      }}
 |isbn={{Wp/nd/hide in print
        |[[Wp/nd/Citation/International Standard Book Number|ISBN]]&amp;nbsp;[[Special:BookSources/{{{input1|}}}|{{{input1|}}}]]{{
         #if: {{{input1|}}} |{{#invoke:Wp/nd/check isxn|check_isbn|{{{input1}}}|error=&lt;span class=&quot;error&quot; style=&quot;font-size:88%&quot;&gt;Check ISBN&lt;/span&gt;{{main other|[[Category:Pages with ISBN errors]]}}}}
         }}
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |ISBN&amp;nbsp;{{{input1|}}}
       }}
 |issn={{Wp/nd/hide in print
        |[[Wp/nd/Citation/International Standard Serial Number|ISSN]]&amp;nbsp;[//www.worldcat.org/issn/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |ISSN&amp;nbsp;{{{input1|}}}
       }}
 |jfm={{Wp/nd/hide in print
       |[[Wp/nd/Citation/Jahrbuch über die Fortschritte der Mathematik|JFM]]&amp;nbsp;[http://www.zentralblatt-math.org/zmath/en/search/?q{{=}}an:{{{input1|}}}&amp;format{{=}}complete {{#tag:nowiki|{{{input1|}}}}}]
      }}&lt;!--
   --&gt;{{Wp/nd/only in print
       |JFM&amp;nbsp;{{{input1|}}}
      }}
 |jstor={{Wp/nd/hide in print
         |[[Wp/nd/Citation/JSTOR|JSTOR]]&amp;nbsp;[http://www.jstor.org/stable/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
        }}&lt;!--
     --&gt;{{Wp/nd/only in print
         |JSTOR&amp;nbsp;{{{input1|}}}
         }}
 |lccn={{Wp/nd/hide in print
         |[[Wp/nd/Citation/Library of Congress Control Number|LCCN]]&amp;nbsp;[http://lccn.loc.gov/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
        }}&lt;!--
     --&gt;{{Wp/nd/only in print
         |LCCN&amp;nbsp;{{{input1|}}}
         }}
 |mr={{Wp/nd/hide in print
      |[[Wp/nd/Citation/Mathematical Reviews|MR]]&amp;nbsp;[http://www.ams.org/mathscinet-getitem?mr{{=}}{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
     }}&lt;!--
  --&gt;{{Wp/nd/only in print
      |MR{{{input1|}}}
     }}
 |oclc={{Wp/nd/hide in print
        |[[Wp/nd/Citation/OCLC|OCLC]]&amp;nbsp;[//www.worldcat.org/oclc/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |OCLC&amp;nbsp;{{{input1|}}}
       }}
 |ol={{Wp/nd/hide in print
      |1={{#if:{{str endswith|{{{input1|}}}|A}}
          |[[Wp/nd/Citation/Open Library|OL]][http://openlibrary.org/authors/OL{{urlencode:{{{input1|}}}}} {{{input1|}}}]
          |{{#if:{{str endswith|{{{input1|}}}|M}}
            |[[Wp/nd/Citation/Open Library|OL]][http://openlibrary.org/books/OL{{urlencode:{{{input1|}}}}} {{{input1|}}}]
            |{{#if:{{str endswith|{{{input1|}}}|W}}
              |[[Wp/nd/Citation/Open Library|OL]][http://openlibrary.org/works/OL{{urlencode:{{{input1|}}}}} {{{input1|}}}]
              |&lt;includeonly&gt;[[Category:Pages with OL errors]]&lt;span class=&quot;error&quot;&gt;Error: Bad OL specified!&lt;/span&gt;&lt;/includeonly&gt;
             }}
           }}
         }}
     }}&lt;!--
--&gt;{{Wp/nd/only in print
    |1=OL{{{id|{{{1}}}}}}
   }}
 |osti={{Wp/nd/hide in print
        |[[Wp/nd/Citation/Office of Scientific and Technical Information|OSTI]]&amp;nbsp;[http://www.osti.gov/energycitations/product.biblio.jsp?osti_id{{=}}{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |OSTI&amp;nbsp;{{{input1|}}}
       }}
 |pmc={{Wp/nd/hide in print
        |[[Wp/nd/Citation/PubMed Central|PMC]]&amp;nbsp;[//www.ncbi.nlm.nih.gov/pmc/articles/PMC{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
      }}&lt;!--
   --&gt;{{Wp/nd/only in print
       |PMC&amp;nbsp;{{{input1|}}}
      }}
 |pmid={{Wp/nd/hide in print
        |[[Wp/nd/Citation/PubMed Identifier|PMID]]&amp;nbsp;[//www.ncbi.nlm.nih.gov/pubmed/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |PMID&amp;nbsp;{{{input1|}}}
       }}
 |rfc={{Wp/nd/hide in print
        |[[Wp/nd/Citation/Request for Comments|RFC]]&amp;nbsp;[//tools.ietf.org/html/rfc{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |RFC&amp;nbsp;{{{input1|}}}
       }}
 |ssrn={{Wp/nd/hide in print
        |[[Wp/nd/Citation/Social Science Research Network|SSRN]]&amp;nbsp;[http://ssrn.com/abstract{{=}}{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |SSRN&amp;nbsp;{{{input1|}}}
       }}
 |zbl={{Wp/nd/hide in print
        |[[Wp/nd/Citation/Zentralblatt MATH|Zbl]]&amp;nbsp;[http://www.zentralblatt-math.org/zmath/en/search/?q{{=}}an:{{{input1|}}}&amp;format{{=}}complete {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |Zbl&amp;nbsp;{{{input1|}}}
       }}
}}&lt;noinclude&gt;
{{Wp/nd/documentation}}
&lt;/noinclude&gt;</text>
      <sha1>dzu93ablu6efif7kqhobb0cs18sn9bd</sha1>
    </revision>
    <revision>
      <id>1947</id>
      <parentid>1946</parentid>
      <timestamp>2024-11-18T17:41:40Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <minor />
      <comment>5 revisions imported from [[:incubator:Template:Wp/nd/Citation/identifier]]</comment>
      <origin>1945</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6269" sha1="dzu93ablu6efif7kqhobb0cs18sn9bd" xml:space="preserve">{{#switch:{{{identifier}}}
 |arxiv={{Wp/nd/hide in print
         |[[Wp/nd/Citation/arXiv|arXiv]]:[http://arxiv.org/abs/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
        }}&lt;!--
     --&gt;{{Wp/nd/only in print
         |arXiv:{{{input1|}}}
        }}
 |asin={{Wp/nd/hide in print
        |[[Wp/nd/Citation/Amazon Standard Identification Number|ASIN]]&amp;nbsp;[//www.amazon.&lt;!--
     --&gt;{{#switch: {{{input2|}}}
          |ca=ca
          |cn=cn
          |de=de
          |ed=es
          |fr=fr
          |it=it
          |jp=co.jp
          |co.jp=co.jp
          |uk=co.uk
          |co.uk=co.uk
          |#default=com
         }}/dp/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |ASIN&amp;nbsp;{{{input1|}}}
       }}
 |bibcode={{Wp/nd/hide in print
           |[[Wp/nd/Citation/Bibcode|Bibcode]] [http://adsabs.harvard.edu/abs/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
          }}&lt;!--
       --&gt;{{Wp/nd/only in print
           |Bibcode&amp;nbsp;{{{input1|}}}
          }}
 |doi={{Wp/nd/hide in print
       |{{#ifeq:{{str left|{{{input1|}}}|3}}|10.
         |{{#if:{{{input2|}}}
           |[[Wp/nd/Citation/Digital object identifier|doi]]:{{{input1|}}} (inactive {{{input2|}}}) &lt;!--
            --&gt;{{#ifeq:{{NAMESPACE}}|{{ns:0}}
                |[[Category:Pages with DOIs inactive since {{#time: Y | {{{input2|}}} }}]]
                |
               }}
           |[[Wp/nd/Citation/Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:{{{input1|}}}}} {{#tag:nowiki|{{{input1|}}}}}]
          }}
         |{{citation error|nocat={{{input3|}}}|cat=Pages with DOI errors|Bad DOI specified}}
        }}
      }}&lt;!--
   --&gt;{{Wp/nd/only in print
       |{{#if:{{{input2|}}}
         |doi:{{{input1|}}} (inactive {{{input2|}}})
         |doi:{{{input1|}}}
        }}
      }}
 |isbn={{Wp/nd/hide in print
        |[[Wp/nd/Citation/International Standard Book Number|ISBN]]&amp;nbsp;[[Special:BookSources/{{{input1|}}}|{{{input1|}}}]]{{
         #if: {{{input1|}}} |{{#invoke:Wp/nd/check isxn|check_isbn|{{{input1}}}|error=&lt;span class=&quot;error&quot; style=&quot;font-size:88%&quot;&gt;Check ISBN&lt;/span&gt;{{main other|[[Category:Pages with ISBN errors]]}}}}
         }}
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |ISBN&amp;nbsp;{{{input1|}}}
       }}
 |issn={{Wp/nd/hide in print
        |[[Wp/nd/Citation/International Standard Serial Number|ISSN]]&amp;nbsp;[//www.worldcat.org/issn/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |ISSN&amp;nbsp;{{{input1|}}}
       }}
 |jfm={{Wp/nd/hide in print
       |[[Wp/nd/Citation/Jahrbuch über die Fortschritte der Mathematik|JFM]]&amp;nbsp;[http://www.zentralblatt-math.org/zmath/en/search/?q{{=}}an:{{{input1|}}}&amp;format{{=}}complete {{#tag:nowiki|{{{input1|}}}}}]
      }}&lt;!--
   --&gt;{{Wp/nd/only in print
       |JFM&amp;nbsp;{{{input1|}}}
      }}
 |jstor={{Wp/nd/hide in print
         |[[Wp/nd/Citation/JSTOR|JSTOR]]&amp;nbsp;[http://www.jstor.org/stable/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
        }}&lt;!--
     --&gt;{{Wp/nd/only in print
         |JSTOR&amp;nbsp;{{{input1|}}}
         }}
 |lccn={{Wp/nd/hide in print
         |[[Wp/nd/Citation/Library of Congress Control Number|LCCN]]&amp;nbsp;[http://lccn.loc.gov/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
        }}&lt;!--
     --&gt;{{Wp/nd/only in print
         |LCCN&amp;nbsp;{{{input1|}}}
         }}
 |mr={{Wp/nd/hide in print
      |[[Wp/nd/Citation/Mathematical Reviews|MR]]&amp;nbsp;[http://www.ams.org/mathscinet-getitem?mr{{=}}{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
     }}&lt;!--
  --&gt;{{Wp/nd/only in print
      |MR{{{input1|}}}
     }}
 |oclc={{Wp/nd/hide in print
        |[[Wp/nd/Citation/OCLC|OCLC]]&amp;nbsp;[//www.worldcat.org/oclc/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |OCLC&amp;nbsp;{{{input1|}}}
       }}
 |ol={{Wp/nd/hide in print
      |1={{#if:{{str endswith|{{{input1|}}}|A}}
          |[[Wp/nd/Citation/Open Library|OL]][http://openlibrary.org/authors/OL{{urlencode:{{{input1|}}}}} {{{input1|}}}]
          |{{#if:{{str endswith|{{{input1|}}}|M}}
            |[[Wp/nd/Citation/Open Library|OL]][http://openlibrary.org/books/OL{{urlencode:{{{input1|}}}}} {{{input1|}}}]
            |{{#if:{{str endswith|{{{input1|}}}|W}}
              |[[Wp/nd/Citation/Open Library|OL]][http://openlibrary.org/works/OL{{urlencode:{{{input1|}}}}} {{{input1|}}}]
              |&lt;includeonly&gt;[[Category:Pages with OL errors]]&lt;span class=&quot;error&quot;&gt;Error: Bad OL specified!&lt;/span&gt;&lt;/includeonly&gt;
             }}
           }}
         }}
     }}&lt;!--
--&gt;{{Wp/nd/only in print
    |1=OL{{{id|{{{1}}}}}}
   }}
 |osti={{Wp/nd/hide in print
        |[[Wp/nd/Citation/Office of Scientific and Technical Information|OSTI]]&amp;nbsp;[http://www.osti.gov/energycitations/product.biblio.jsp?osti_id{{=}}{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |OSTI&amp;nbsp;{{{input1|}}}
       }}
 |pmc={{Wp/nd/hide in print
        |[[Wp/nd/Citation/PubMed Central|PMC]]&amp;nbsp;[//www.ncbi.nlm.nih.gov/pmc/articles/PMC{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
      }}&lt;!--
   --&gt;{{Wp/nd/only in print
       |PMC&amp;nbsp;{{{input1|}}}
      }}
 |pmid={{Wp/nd/hide in print
        |[[Wp/nd/Citation/PubMed Identifier|PMID]]&amp;nbsp;[//www.ncbi.nlm.nih.gov/pubmed/{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |PMID&amp;nbsp;{{{input1|}}}
       }}
 |rfc={{Wp/nd/hide in print
        |[[Wp/nd/Citation/Request for Comments|RFC]]&amp;nbsp;[//tools.ietf.org/html/rfc{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |RFC&amp;nbsp;{{{input1|}}}
       }}
 |ssrn={{Wp/nd/hide in print
        |[[Wp/nd/Citation/Social Science Research Network|SSRN]]&amp;nbsp;[http://ssrn.com/abstract{{=}}{{{input1|}}} {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |SSRN&amp;nbsp;{{{input1|}}}
       }}
 |zbl={{Wp/nd/hide in print
        |[[Wp/nd/Citation/Zentralblatt MATH|Zbl]]&amp;nbsp;[http://www.zentralblatt-math.org/zmath/en/search/?q{{=}}an:{{{input1|}}}&amp;format{{=}}complete {{#tag:nowiki|{{{input1|}}}}}]
       }}&lt;!--
    --&gt;{{Wp/nd/only in print
        |Zbl&amp;nbsp;{{{input1|}}}
       }}
}}&lt;noinclude&gt;
{{Wp/nd/documentation}}
&lt;/noinclude&gt;</text>
      <sha1>dzu93ablu6efif7kqhobb0cs18sn9bd</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Wp/nd/Only in print</title>
    <ns>10</ns>
    <id>373</id>
    <revision>
      <id>1948</id>
      <timestamp>2016-11-09T15:22:14Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;{{#if:{{hide in print|1}}||{{{1|}}}}}&lt;noinclude&gt; {{documentation}} &lt;/noinclude&gt;&quot;</comment>
      <origin>1948</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="79" sha1="rm8emca34tsah296fr9jh9dzgyhnfxo" xml:space="preserve">{{#if:{{hide in print|1}}||{{{1|}}}}}&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>rm8emca34tsah296fr9jh9dzgyhnfxo</sha1>
    </revision>
    <revision>
      <id>1949</id>
      <parentid>1948</parentid>
      <timestamp>2016-11-09T15:23:23Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>CFCF moved page [[Template:Wp/nd/Only in print]] to [[Template:Wp/nd/only in print]]</comment>
      <origin>1948</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="79" sha1="rm8emca34tsah296fr9jh9dzgyhnfxo" xml:space="preserve">{{#if:{{hide in print|1}}||{{{1|}}}}}&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>rm8emca34tsah296fr9jh9dzgyhnfxo</sha1>
    </revision>
    <revision>
      <id>1950</id>
      <parentid>1949</parentid>
      <timestamp>2019-12-05T16:55:52Z</timestamp>
      <contributor>
        <username>incubator&gt;Adithyak1997</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Added a prefix</comment>
      <origin>1950</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="85" sha1="7lmsepzqkn5qfyjc12798ltcp5hwb74" xml:space="preserve">{{#if:{{hide in print|1}}||{{{1|}}}}}&lt;noinclude&gt;
{{Wp/nd/Documentation}}
&lt;/noinclude&gt;</text>
      <sha1>7lmsepzqkn5qfyjc12798ltcp5hwb74</sha1>
    </revision>
    <revision>
      <id>1951</id>
      <parentid>1950</parentid>
      <timestamp>2022-04-27T09:34:16Z</timestamp>
      <contributor>
        <username>JhsBot</username>
        <id>34</id>
      </contributor>
      <minor />
      <comment>JhsBot moved page [[Template:Wp/nd/only in print]] to [[Template:Wp/nd/Only in print]] over redirect: bot: Moving pages with (what would be) lowercase titles to uppercase</comment>
      <origin>1950</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="85" sha1="7lmsepzqkn5qfyjc12798ltcp5hwb74" xml:space="preserve">{{#if:{{hide in print|1}}||{{{1|}}}}}&lt;noinclude&gt;
{{Wp/nd/Documentation}}
&lt;/noinclude&gt;</text>
      <sha1>7lmsepzqkn5qfyjc12798ltcp5hwb74</sha1>
    </revision>
    <revision>
      <id>1952</id>
      <parentid>1951</parentid>
      <timestamp>2024-11-18T17:41:41Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <minor />
      <comment>4 revisions imported from [[:incubator:Template:Wp/nd/Only_in_print]]</comment>
      <origin>1950</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="85" sha1="7lmsepzqkn5qfyjc12798ltcp5hwb74" xml:space="preserve">{{#if:{{hide in print|1}}||{{{1|}}}}}&lt;noinclude&gt;
{{Wp/nd/Documentation}}
&lt;/noinclude&gt;</text>
      <sha1>7lmsepzqkn5qfyjc12798ltcp5hwb74</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Wp/nd/Citation/core</title>
    <ns>10</ns>
    <id>374</id>
    <revision>
      <id>1953</id>
      <timestamp>2016-11-09T15:17:57Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>[[:en:Template:Citation/core]]</comment>
      <origin>1953</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="26664" sha1="gd5lzu9vxjaeyq4m8ym55m1qddorc47" xml:space="preserve">&lt;span class=&quot;citation {{{Citation class|{{{Citation type|}}}}}}&quot;
{{
  #switch:{{{Ref|}}}
  ||none =
  |#default = id=&quot;{{anchorencode:{{{Ref}}}}}&quot;
  |harv = {{#if:{{{Surname1|}}}{{{EditorSurname1|}}}
    |id=&quot;CITEREF{{anchorencode:{{#if:{{{Surname1|}}}
      |{{{Surname1}}}{{{Surname2|}}}{{{Surname3|}}}{{{Surname4|}}}
      |{{{EditorSurname1|}}}{{{EditorSurname2|}}}{{{EditorSurname3|}}}{{{EditorSurname4|}}}
    }}{{{Year|{{{Date|}}}}}}}}&quot;
  }}
}}&gt;{{
&lt;!--============  Author or editor and date  ============--&gt;
  #if:{{{Surname1|}}}
  |{{
     #if: {{{AuthorMask|}}}
     |{{
        #iferror: {{ #expr: 1*{{{AuthorMask}}} }}
        |{{{AuthorMask}}}
        |{{loop|{{{AuthorMask}}}|2=&amp;mdash;}}
      }}
     |{{
        #if: {{{Authorlink1|}}}
        |[[{{{Authorlink1}}} |{{{Surname1}}}{{
          #if: {{{Given1|}}}
          |{{{NameSep|,&amp;#32;}}}{{{Given1}}}
         }}]]
        |{{{Surname1}}}{{
           #if: {{{Given1|}}}
           |{{{NameSep|,&amp;#32;}}}{{{Given1}}}
         }}
      }}
   }}{{
     #if: {{{Surname2|}}}
     |{{#ifexpr:{{{Trunc|8}}}&lt;2
       |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
       |{{
          #iferror: {{ #expr: 1*0.0{{{AuthorMask|}}} }}
          |&amp;#32;&lt;!-- then punctuation should be included in AuthorMask --&gt;
          |{{
            #if: {{{Surname3|}}}
            |{{{AuthorSep|&amp;#059;&amp;#32;}}}
            |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
          }}
        }}{{
          #if: {{{Authorlink2|}}}
          |[[{{{Authorlink2}}} |{{{Surname2}}}{{
             #if: {{{Given2|}}}
             |{{{NameSep|,&amp;#32;}}}{{{Given2}}}
           }}]]
          |{{{Surname2}}}{{
             #if: {{{Given2|}}}
             |{{{NameSep|,&amp;#32;}}}{{{Given2}}}
           }}
        }}{{
          #if: {{{Surname3|}}}
          |{{#ifexpr:{{{Trunc|8}}}&lt;3
            |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
            |{{
               #if: {{{Surname4|}}}
               |{{{AuthorSep|&amp;#059;&amp;#32;}}}
               |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
             }}{{
               #if: {{{Authorlink3|}}}
               |[[{{{Authorlink3}}} |{{{Surname3}}}{{
                  #if: {{{Given3|}}}
                  |{{{NameSep|,&amp;#32;}}}{{{Given3}}}
                }}]]
               |{{{Surname3}}}{{
                  #if: {{{Given3|}}}
                  |{{{NameSep|,&amp;#32;}}}{{{Given3}}}
                }}
             }}{{
               #if:{{{Surname4|}}}
               |{{#ifexpr:{{{Trunc|8}}}&lt;4
                 |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
                 |{{
                    #if: {{{Surname5|}}}
                    |{{{AuthorSep|&amp;#059;&amp;#32;}}}
                    |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
                  }}{{
                    #if: {{{Authorlink4|}}}
                    |[[{{{Authorlink4}}} |{{{Surname4}}}{{
                       #if: {{{Given4|}}}
                       |{{{NameSep|,&amp;#32;}}}{{{Given4}}}
                     }}]]
                    |{{{Surname4}}}{{
                       #if: {{{Given4|}}}
                       |{{{NameSep|,&amp;#32;}}}{{{Given4}}}
                    }}
                  }}{{
                  #if:{{{Surname5|}}}
                  |{{#ifexpr:{{{Trunc|8}}}&lt;5
                    |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
                    |{{
                     #if: {{{Surname6|}}}
                     |{{{AuthorSep|&amp;#059;&amp;#32;}}}
                     |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
                    }}{{
                     #if: {{{Authorlink5|}}}
                     |[[{{{Authorlink5}}} |{{{Surname5}}}{{
                        #if: {{{Given5|}}}
                        |{{{NameSep|,&amp;#32;}}}{{{Given5}}}
                      }}]]
                     |{{{Surname5}}}{{
                        #if: {{{Given5|}}}
                        |{{{NameSep|,&amp;#32;}}}{{{Given5}}}
                      }}
                   }}{{
                     #if:{{{Surname6|}}}
                     |{{#ifexpr:{{{Trunc|8}}}&lt;6
                     |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
                      |{{
                        #if: {{{Surname7|}}}
                        |{{{AuthorSep|&amp;#059;&amp;#32;}}}
                        |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
                      }}{{
                        #if: {{{Authorlink6|}}}
                        |[[{{{Authorlink6}}} |{{{Surname6}}}{{
                           #if: {{{Given6|}}}
                           |{{{NameSep|,&amp;#32;}}}{{{Given6}}}
                         }}]]
                        |{{{Surname6}}}{{
                           #if: {{{Given6|}}}
                           |{{{NameSep|,&amp;#32;}}}{{{Given6}}}
                         }}
                      }}{{
                        #if:{{{Surname7|}}}
                         |{{#ifexpr:{{{Trunc|8}}}&lt;7
                           |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
                        |{{
                           #if: {{{Surname8|}}}
                           |{{{AuthorSep|&amp;#059;&amp;#32;}}}
                           |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
                         }}{{
                           #if: {{{Authorlink7|}}}
                           |[[{{{Authorlink7}}} |{{{Surname7}}}{{
                              #if: {{{Given7|}}}
                              |{{{NameSep|,&amp;#32;}}}{{{Given7}}}
                            }}]]
                           |{{{Surname7}}}{{
                              #if: {{{Given7|}}}
                              |{{{NameSep|,&amp;#32;}}}{{{Given7}}}
                            }}
                                    }}{{
                                       #if:{{{Surname8|}}}
                                       |{{#ifexpr:{{{Trunc|8}}}&lt;8
                                           |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
                                           |{{
                                              #if: {{{Surname9|}}}
                                              |{{{AuthorSep|&amp;#059;&amp;#32;}}}
                                              |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
                                            }}{{
                                              #if: {{{Authorlink8|}}}
                                              |[[{{{Authorlink8}}} |{{{Surname8}}}{{
                                                 #if: {{{Given8|}}}
                                                 |{{{NameSep|,&amp;#32;}}}{{{Given8}}}
                                               }}]]
                                              |{{{Surname8}}}{{
                                                 #if: {{{Given8|}}}
                                                 |{{{NameSep|,&amp;#32;}}}{{{Given8}}}
                                               }}
                                            }}{{
                                              #if:{{{Surname9|}}}
                                              |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
                                            }}
                                         }}
                                      }}
                                   }}
                                }}
                             }}
                          }}
                       }}
                     }}
                  }}
               }}
            }}
         }}
      }}

   }}{{
     #if: {{{Coauthors|}}}
     |{{{AuthorSep|&amp;#059;&amp;#32;}}}{{{Coauthors|}}}|
   }}{{
     #if: {{{Date|}}}
     |&amp;#32;({{{Date}}}){{
       #if:{{{YearNote|}}}
     |&amp;#32;[{{{YearNote}}}]
     }}
   }}
  |{{&lt;!-- ============== No author: display editors first == --&gt;
     #if: {{{EditorSurname1|}}}
     |{{
        #if: {{{Editorlink1|}}}
        |[[{{{Editorlink1}}} |{{{EditorSurname1}}}{{
           #if: {{{EditorGiven1|}}}
           |, {{{EditorGiven1}}}
         }}]]
        |{{{EditorSurname1}}}{{
           #if: {{{EditorGiven1|}}}
           |, {{{EditorGiven1}}}
         }}
      }}{{
        #if: {{{EditorSurname2|}}}
        |{{
          #if: {{{EditorSurname3|}}}
          |{{{AuthorSep|&amp;#059;&amp;#32;}}}
          |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
        }}{{
           #if: {{{Editorlink2|}}}
           |[[{{{Editorlink2}}} |{{{EditorSurname2}}}{{
              #if: {{{EditorGiven2|}}}
              |, {{{EditorGiven2}}}
            }}]]
           |{{{EditorSurname2}}}{{
              #if: {{{EditorGiven2|}}}
              |, {{{EditorGiven2}}}
            }}
         }}{{
           #if: {{{EditorSurname3|}}}
           |{{
              #if: {{{EditorSurname4|}}}
              |{{{AuthorSep|&amp;#059;&amp;#32;}}}
              |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
            }}{{
              #if: {{{Editorlink3|}}}
              |[[{{{Editorlink3}}} |{{{EditorSurname3}}}{{
                 #if: {{{EditorGiven3|}}}
                 |, {{{EditorGiven3}}}
               }}]]
              |{{{EditorSurname3}}}{{
                 #if: {{{EditorGiven3|}}}
                 |, {{{EditorGiven3}}}
               }}
            }}{{
              #if:{{{EditorSurname4|}}}
              |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
            }}
         }}
       }}, ed{{#if:{{{EditorSurname2|}}}|s}}{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}{{
        #if: {{{Date|}}}
        |&amp;#32;({{{Date}}}){{
         #if:{{{YearNote|}}}
       |&amp;#32;[{{{YearNote}}}]
       }}
      }}
   }}
}}{{
&lt;!--============  Title of included work  ============--&gt;
  #if: {{{IncludedWorkTitle|}}}{{#if:{{{Periodical|}}}||{{#if:{{{TransItalic|}}}||{{{TransTitle|}}}}}}}
  |{{
     #if:{{{Surname1|}}}{{{EditorSurname1|}}}
     |{{{Sep|,}}}&amp;#32;
   }}{{Citation/make link
     | 1={{
           #if: {{{IncludedWorkURL|}}}
           |{{{IncludedWorkURL}}}
           |{{
              #if: {{{URL|}}}
              |{{{URL}}}
            }}
         }}
     | 2={{
           #if: {{{Periodical|}}}
           |''&lt;nowiki /&gt;{{{IncludedWorkTitle}}}&lt;nowiki /&gt;''
           |&quot;{{{IncludedWorkTitle|}}}{{
             #if: {{{TransTitle|}}}
             |{{
                #if: {{{IncludedWorkTitle|}}}
                |&amp;#32;
              }}&amp;#91;{{{TransTitle}}}&amp;#93;
           }}&quot;
         }}
   }}
}}{{
&lt;!--============  Place (if different than PublicationPlace) ============--&gt;
  #if: {{{Place|}}}
  |{{
     #ifeq: {{{Place|}}} | {{{PublicationPlace|}}}
     |
     |{{
        #if: {{{Surname1|}}}{{{EditorSurname1|}}}{{{IncludedWorkTitle|}}}
        |{{{Sep|,}}}&amp;#32;written at {{{Place}}}
      }}
   }}
}}{{
&lt;!--============  Editor of compilation  ============--&gt;
  #if: {{{EditorSurname1|}}}
  |{{
     #if: {{{Surname1|}}}
     |{{{Sep|,}}}&amp;#32;{{
        #if: {{{IncludedWorkTitle|}}}
        |{{#ifeq:{{{Sep|}}}|.|I|i}}n&amp;#32;
      }}{{
        #if: {{{Editorlink1|}}}
        |[[{{{Editorlink1}}} |{{{EditorSurname1}}}{{
           #if: {{{EditorGiven1|}}}
           |, {{{EditorGiven1}}}
         }}]]
        |{{{EditorSurname1}}}{{
           #if: {{{EditorGiven1|}}}
           |, {{{EditorGiven1}}}
         }}}}{{
        #if: {{{EditorSurname2|}}}
        |{{
          #if: {{{EditorSurname3|}}}
            |{{{AuthorSep|&amp;#059;&amp;#32;}}}
            |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
          }}{{
           #if: {{{Editorlink2|}}}
           |[[{{{Editorlink2}}}|{{{EditorSurname2}}}{{
              #if: {{{EditorGiven2|}}}
              |, {{{EditorGiven2}}}
            }}]]
           |{{{EditorSurname2}}}{{
              #if: {{{EditorGiven2|}}}
              |, {{{EditorGiven2}}}
            }}
         }}{{
           #if: {{{EditorSurname3|}}}
           |{{
              #if: {{{EditorSurname4|}}}
              |&amp;#059;&amp;#32;
              |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
            }}{{
              #if: {{{Editorlink3|}}}
              |[[{{{Editorlink3}}}|{{{EditorSurname3}}}{{
                 #if: {{{EditorGiven3|}}}
                 |, {{{EditorGiven3}}}
               }}]]
              |{{{EditorSurname3}}}{{
                 #if: {{{EditorGiven3|}}}
                 |, {{{EditorGiven3}}}
               }}
            }}{{
              #if:{{{EditorSurname4|}}}
              |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
            }}
         }}
      }}{{
        #if: {{{IncludedWorkTitle|}}}
        |
        |{{{Sep|,}}}&amp;#32;ed{{#if:{{{EditorSurname2|}}}|s}}{{#ifeq:{{{Sep}}}|.||.}}
      }}
   }}
}}{{
  &lt;!--============  Periodicals  ============--&gt;
  #if: {{{Periodical|}}}
  |{{
     #if: {{{Other|}}}
     |{{{Sep|,}}}&amp;#32;{{{Other|}}}
   }}{{
     #if: {{{Surname1|}}}{{{EditorSurname1|}}}{{{IncludedWorkTitle|}}}
     |{{{Sep|,}}}&amp;#32;}}{{
     #if: {{{Title|}}}{{{TransTitle|}}}
     |{{Citation/make link
        | 1={{
              #if: {{{IncludedWorkTitle|}}}
              |{{
                 #if: {{{IncludedWorkURL|}}}
                 |{{
                    #if: {{{URL|}}}
                    |{{{URL}}}
                  }}
               }}
              |{{
                 #if: {{{URL|}}}
                 |{{{URL}}}
               }}
            }}
        | 2=&quot;{{{Title}}}{{
          #if: {{{TransTitle|}}}
          |{{
             #if: {{{Title|}}}
             |&amp;#32;
           }}&amp;#91;{{{TransTitle}}}&amp;#93;
        }}&quot;
      }}{{
        #if: {{{TitleNote|}}}
        |{{{Sep|,}}}&amp;#32;{{{TitleNote}}}
      }}
   }}
}}{{
  #if: {{{language|}}}
  |&amp;#32;(in {{{language}}})
}}{{
  #if: {{{format|}}}
  |&amp;#32;({{{format}}})
}}{{
   #if: {{{Periodical|}}}
   |{{
      #if:{{{IncludedWorkTitle|}}}{{{Title|}}}{{{TransTitle|}}}
      |{{{Sep|,}}}&amp;#32;
    }}''&lt;nowiki /&gt;{{{Periodical}}}&lt;nowiki /&gt;''{{
      #if: {{{Series|}}}
      |{{{Sep|,}}}&amp;#32;{{{Series}}}
    }}{{
      #if: {{{PublicationPlace|}}}
      |{{
         #if: {{{Publisher|}}}
         |&amp;#32;({{{PublicationPlace}}}&lt;nowiki&gt;: &lt;/nowiki&gt;{{{Publisher}}})
         |&amp;#32;({{{PublicationPlace}}})
       }}
      |{{
         #if: {{{Publisher|}}}
         |&amp;#32;({{{Publisher}}})
       }}
    }}{{
      #if: {{{Volume|}}}
      |&amp;#32;{{#if:{{{Periodical|}}}|'''&lt;nowiki /&gt;{{{Volume}}}&lt;nowiki /&gt;'''|{{{Volume}}}}}{{
         #if: {{{Issue|}}}
         |&amp;#32;({{{Issue}}})
       }}
      |{{
         #if: {{{Issue|}}}
         |&amp;#32;({{{Issue}}})
       }}
    }}{{
      #if: {{{At|}}}
      |&lt;nowiki&gt;: &lt;/nowiki&gt; {{{At}}}
    }}
   |{{
      &lt;!--============ Anything else with a title, including books ============--&gt;
      #if: {{{Title|}}}{{{TransItalic|}}}
      |{{
         #if: {{{Surname1|}}}{{{EditorSurname1|}}}{{{IncludedWorkTitle|}}}{{{Periodical|}}}
         |{{{Sep|,}}}
       }}&amp;#32;{{Citation/make link
         | 1={{
               #if: {{{IncludedWorkTitle|}}}
               |{{
                  #if: {{{IncludedWorkURL|}}}
                  |{{
                     #if: {{{URL|}}}
                     |{{{URL}}}
                   }}
                }}
               |{{
                  #if: {{{URL|}}}
                  |{{{URL}}}
                }}
             }}
         | 2=''&lt;nowiki /&gt;{{{Title|}}}{{
            #if:{{{TransItalic|}}}|&amp;#32;&amp;#91;{{{TransItalic}}}&amp;#93;
          }}&lt;nowiki /&gt;''
       }}
    }}{{
      #if: {{{TitleType|}}}
      |&amp;#32;({{{TitleType}}})
    }}{{
      #if: {{{Series|}}}
      |{{{Sep|,}}}&amp;#32;{{{Series}}}
    }}{{
      #if: {{{Volume|}}}
      |{{{Sep|,}}}&amp;#32;'''&lt;nowiki /&gt;{{{Volume}}}&lt;nowiki /&gt;'''
    }}{{
      #if: {{{Other|}}}
      |{{{Sep|,}}}&amp;#32;{{{Other|}}}
    }}{{
      #if: {{{Edition|}}}
      |&amp;#32;({{{Edition}}} ed.)
    }}{{
      #if: {{{PublicationPlace|}}}
      |{{{Sep|,}}}&amp;#32;{{{PublicationPlace}}}
    }}{{
      #if: {{{Publisher|}}}
      |{{
         #if: {{{PublicationPlace|}}}
         |&lt;nowiki&gt;:&lt;/nowiki&gt;
         |{{{Sep|,}}}
       }}&amp;#32;{{{Publisher}}}
    }}
}}{{
&lt;!--============ Date (if no author/editor) ============--&gt;
  #if: {{{Surname1|}}}{{{EditorSurname1|}}}
  |
  |{{
     #if: {{{Date|}}}
     |{{{Sep|,}}}&amp;#32;{{{Date}}}{{
       #if:{{{YearNote|}}}
     |&amp;#32;[{{{YearNote}}}]
     }}
   }}
}}{{
&lt;!--============ Publication date ============--&gt;
  #if: {{{PublicationDate|}}}
  |{{
     #ifeq: {{{PublicationDate|}}} | {{{Date|}}}
     |
     |{{
        #if: {{{EditorSurname1|}}}
        |{{
           #if: {{{Surname1|}}}
           |{{{Sep|,}}}&amp;#32;{{{PublicationDate}}}
           |&amp;#32;(published {{{PublicationDate}}})
         }}
        |{{
           #if: {{{Periodical|}}}
           |{{{Sep|,}}}&amp;#32;{{{PublicationDate}}}
           |&amp;#32;(published {{{PublicationDate}}})
         }}
      }}
   }}
}}{{
&lt;!--============ Page within included work ============--&gt;
  #if: {{{Periodical|}}}
  |
  |{{
     #if: {{{At|}}}
     |{{{Sep|,}}}&amp;#32;{{{At}}}
   }}
}}{{
&lt;!--============ arXiv ==============--&gt;
  #if: {{{ARXIV|}}}
  |{{{Sep|,}}}&amp;#32;{{citation/identifier  |identifier=arxiv |input1={{{ARXIV|}}} }}
}}{{
&lt;!--============ ASIN ===============--&gt;
  #if: {{{ASIN|}}}
  |{{{Sep|,}}}&amp;#32;{{citation/identifier  |identifier=asin |input1={{{ASIN|}}} |input2={{{ASIN-TLD|}}} }}
}}{{
&lt;!--============ BIBCODE ============--&gt;
  #if: {{{BIBCODE|}}}
  |{{{Sep|,}}}&amp;#32;{{citation/identifier  |identifier=bibcode |input1={{{BIBCODE|}}} }}
}}{{
&lt;!--============ DOI ================--&gt;
#if:{{{DOI|}}}
  |{{{Sep|,}}}&amp;#32;{{citation/identifier  |identifier=doi |input1={{{DOI|}}}  |input2={{{DoiBroken|}}} |input3={{{template doc demo|}}}}}
}}{{
&lt;!--============ ISBN ===============--&gt;
  #if: {{{ISBN|}}}
  |{{{Sep|,}}}&amp;#32;{{citation/identifier  |identifier=isbn |input1={{{ISBN|}}} }}
}}{{
&lt;!--============ ISSN ===============--&gt;
  #if: {{{ISSN|}}}
  |{{{Sep|,}}}&amp;#32;{{citation/identifier  |identifier=issn |input1={{{ISSN|}}} }}
}}{{
&lt;!--============ JFM ================--&gt;
  #if: {{{JFM|}}}
  |{{{Sep|,}}}&amp;#32;{{citation/identifier  |identifier=jfm |input1={{{JFM|}}} }}
}}{{
&lt;!--============ JSTOR ==============--&gt;
  #if: {{{JSTOR|}}}
  |{{{Sep|,}}}&amp;#32;{{citation/identifier  |identifier=jstor |input1={{{JSTOR|}}} }}
}}{{
&lt;!--============ LCCN ===============--&gt;
  #if: {{{LCCN|}}}
  |{{{Sep|,}}}&amp;#32;{{citation/identifier  |identifier=lccn |input1={{{LCCN|}}} }}
}}{{
&lt;!--============ MR =================--&gt;
  #if: {{{MR|}}}
  |{{{Sep|,}}}&amp;#32;{{citation/identifier  |identifier=mr |input1={{{MR|}}} }}
}}{{
&lt;!--============ OCLC ===============--&gt;
  #if: {{{OCLC|}}}
  |{{{Sep|,}}}&amp;#32;{{citation/identifier  |identifier=oclc |input1={{{OCLC|}}} }}
}}{{
&lt;!--============ OL =================--&gt;
  #if: {{{OL|}}}
  |{{{Sep|,}}}&amp;#32;{{citation/identifier  |identifier=ol |input1={{{OL|}}} }}
}}{{
&lt;!--============ OSTI ===============--&gt;
  #if: {{{OSTI|}}}
  |{{{Sep|,}}}&amp;#32;{{citation/identifier  |identifier=osti |input1={{{OSTI|}}} }}
}}{{
&lt;!--============ PMC ================--&gt;
  #if: {{{PMC|}}}
  |{{{Sep|,}}}&amp;#32;{{citation/identifier  |identifier=pmc |input1={{{PMC|}}} }}
}}{{
&lt;!--============ PMID ===============--&gt;
  #if: {{{PMID|}}}
  |{{{Sep|,}}}&amp;#32;{{citation/identifier  |identifier=pmid |input1={{{PMID|}}} }}
}}{{
&lt;!--============ RFC ================--&gt;
  #if: {{{RFC|}}}
  |{{{Sep|,}}}&amp;#32;{{citation/identifier  |identifier=rfc|input1={{{RFC|}}} }}
}}{{
&lt;!--============ SSRN ================--&gt;
  #if: {{{SSRN|}}}
  |{{{Sep|,}}}&amp;#32;{{citation/identifier  |identifier=ssrn |input1={{{SSRN|}}} }}
}}{{
&lt;!--============ ZBL ================--&gt;
  #if: {{{ZBL|}}}
  |{{{Sep|,}}}&amp;#32;{{citation/identifier  |identifier=zbl |input1={{{ZBL|}}} }}
}}{{
&lt;!--============  Misc. Identifier ============--&gt;
  #if: {{{ID|}}}
  |{{{Sep|,}}}&amp;#32;{{{ID}}}
}}{{
&lt;!--============  Archive data, etc ===========--&gt;
#if: {{{Archive|}}}
|{{{Sep|,}}}&amp;#32;{{{Archive}}}[[Category:Pages using deprecated citation archive parameters]]
|{{
  #if:{{{ArchiveURL|}}}{{{ArchiveDate|}}}
  | {{{Sep|,}}}&amp;#32;{{#ifeq: {{{DeadURL|}}} | no
    | {{#if:{{{ArchiveURL|}}}
       |{{Citation/make link|{{{ArchiveURL|}}}|{{#ifeq:{{{Sep}}}|.|A|a}}rchived}}&amp;#32;from the original
       |{{#ifeq:{{{Sep}}}|.|A|a}}rchived
      }}
    | {{#ifeq:{{{Sep}}}|.|A|a}}rchived{{#if:{{{OriginalURL|}}}{{{IncludedWorkURL|}}}
       |{{#if:{{{ArchiveURL|}}}|&amp;#32;from {{Citation/make link|{{{OriginalURL|{{{IncludedWorkURL|}}}}}}|the original}}}}
      }}
    }}{{#if:{{{ArchiveDate|}}}|&amp;#32;on {{{ArchiveDate}}}}}{{
     #if:{{#if:{{{ArchiveURL|}}}||A}}{{#if:{{{OriginalURL|}}}{{{IncludedWorkURL|}}}||B}}{{#if:{{{ArchiveDate|}}}||C}}
     |. {{citation error|nocat={{{template doc demo|}}}
       |If you specify &lt;code&gt;&amp;#124;{{#if:{{{ArchiveURL|}}}|archiveurl|archivedate}}&amp;#61;&lt;/code&gt;{{#ifeq:{{{DeadURL|}}}|no|{{#if:{{{OriginalURL|}}}{{{IncludedWorkURL|}}}||&amp;#32;and &lt;code&gt;&amp;#124;deadurl&amp;#61;no&lt;/code&gt;}}}}, you must {{#if:{{{OriginalURL|}}}{{{IncludedWorkURL|}}}| also specify &lt;code&gt;&amp;#124;{{#if:{{{ArchiveURL|}}}|archivedate|archiveurl}}&amp;#61;&lt;/code&gt;| {{#ifeq:{{{DeadURL|}}}|no|also|first}} specify &lt;code&gt;&amp;#124;url&amp;#61;&lt;/code&gt;}}}}
    }}
  }}
}}{{
&lt;!--============ URL and AccessDate ============--&gt;
  #if: {{{URL|}}}{{{IncludedWorkURL|}}}{{#ifeq:{{{DeadURL|}}}|no|{{{ArchiveURL|}}}|}}
  |{{
     #if: {{{Title|}}}{{{IncludedWorkTitle|}}}{{{TransTitle|}}}
     |&lt;span class=&quot;printonly&quot;&gt;{{{Sep|,}}}&amp;#32;{{
                                      #if: {{{IncludedWorkURL|}}}
                                      |{{{IncludedWorkURL}}}
                                      |{{{URL}}}
                                    }}&lt;/span&gt;
     |{{{Sep|,}}}&amp;#32;{{
              #if: {{{IncludedWorkURL|}}}
              |{{{IncludedWorkURL}}}
              |{{{URL}}}
            }}
   }}{{
     #if: {{{AccessDate|}}}
     | &lt;span class=&quot;reference-accessdate&quot;&gt;{{#ifeq:{{{Sep|}}}|,|,&amp;#32;r|.&amp;#32;R}}etrieved {{{AccessDate}}}&lt;/span&gt;
     }}
}}{{#if:{{{laysummary|}}}
  |{{{Sep|,}}}&amp;#32;[{{{laysummary}}} Lay summary]{{#if: {{{laysource|}}}|&amp;nbsp;&amp;ndash;&amp;nbsp;''&lt;nowiki /&gt;{{{laysource}}}&lt;nowiki /&gt;''}}
}}{{#if:{{{laydate|}}}
  | &amp;#32;({{{laydate}}})
}}{{#if:{{{quote|}}}
  |{{{Sep|,}}}&amp;#32;&quot;{{{quote}}}&quot;
}}{{{PS|}}}&lt;/span&gt;&lt;!--

=== This is a COinS tag (http://ocoins.info), which allows automated tools to parse the citation information: ===

--&gt;&lt;span
    class=&quot;Z3988&quot;
    title=&quot;ctx_ver=Z39.88-2004&amp;rft_val_fmt={{urlencode:info:ofi/fmt:kev:mtx:}}{{
      #if: {{{Periodical|}}}
      |journal&amp;rft.genre=article&amp;rft.atitle={{urlencode:{{{Title|}}}}}&amp;rft.jtitle={{urlencode:{{{Periodical|}}}}}
      |book{{
         #if: {{{IncludedWorkTitle|}}}
         |&amp;rft.genre=bookitem&amp;rft.btitle={{urlencode:{{{IncludedWorkTitle|}}}}}&amp;rft.atitle={{urlencode:{{{Title|}}}}}
         |&amp;rft.genre=book&amp;rft.btitle={{urlencode:{{{Title|}}}}}
       }}
    }}{{
     #if: {{{Surname1|}}} |&amp;rft.aulast={{urlencode:{{{Surname1}}}}}{{
       #if: {{{Given1|}}} |&amp;rft.aufirst={{urlencode:{{{Given1}}}}}
     }}
   }}{{
     #if: {{{Surname1|}}} |&amp;rft.au={{urlencode:{{{Surname1}}}}}{{
       #if: {{{Given1|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given1}}}}}
     }}
   }}{{
     #if: {{{Surname2|}}} |&amp;rft.au={{urlencode:{{{Surname2}}}}}{{
       #if: {{{Given2|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given2}}}}}
     }}
   }}{{
     #if: {{{Surname3|}}} |&amp;rft.au={{urlencode:{{{Surname3}}}}}{{
       #if: {{{Given3|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given3}}}}}
     }}
   }}{{
     #if: {{{Surname4|}}} |&amp;rft.au={{urlencode:{{{Surname4}}}}}{{
       #if: {{{Given4|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given4}}}}}
     }}
   }}{{
     #if: {{{Surname5|}}} |&amp;rft.au={{urlencode:{{{Surname5}}}}}{{
       #if: {{{Given5|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given5}}}}}
     }}
   }}{{
     #if: {{{Surname6|}}} |&amp;rft.au={{urlencode:{{{Surname6}}}}}{{
       #if: {{{Given6|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given6}}}}}
     }}
   }}{{
     #if: {{{Surname7|}}} |&amp;rft.au={{urlencode:{{{Surname7}}}}}{{
       #if: {{{Given7|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given7}}}}}
     }}
   }}{{
     #if: {{{Surname8|}}} |&amp;rft.au={{urlencode:{{{Surname8}}}}}{{
       #if: {{{Given8|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given8}}}}}
     }}
   }}{{
     #if: {{{Surname9|}}} |&amp;rft.au={{urlencode:{{{Surname9}}}}}{{
       #if: {{{Given9|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given9}}}}}
     }}
    }}{{
      #if: {{{Date|}}} |&amp;rft.date={{urlencode:{{{Date}}}}}
    }}{{
      #if: {{{Series|}}} |&amp;rft.series={{urlencode:{{{Series}}}}}
    }}{{
      #if: {{{Volume|}}} |&amp;rft.volume={{urlencode:{{{Volume}}}}}
    }}{{
      #if: {{{Issue|}}} |&amp;rft.issue={{urlencode:{{{Issue}}}}}
    }}{{
      #if: {{{At|}}} |&amp;rft.pages={{urlencode:{{{At}}}}}
    }}{{
      #if: {{{Edition|}}} |&amp;rft.edition={{urlencode:{{{Edition}}}}}
    }}{{
      #if: {{{PublicationPlace|}}}{{{Place|}}} |&amp;rft.place={{urlencode:{{{PublicationPlace|{{{Place}}}}}}}}
    }}{{
      #if: {{{Publisher|}}} |&amp;rft.pub={{urlencode:{{{Publisher}}}}}
    }}{{
      #if: {{{ARXIV|}}} |&amp;rft_id=info:arxiv/{{urlencode:{{{ARXIV}}}}}
    }}{{
      #if: {{{ASIN|}}} |&amp;rft_id=info:asin/{{urlencode:{{{ASIN}}}}}
    }}{{
      #if: {{{BIBCODE|}}} |&amp;rft_id=info:bibcode/{{urlencode:{{{BIBCODE}}}}}
    }}{{
      #if: {{{DOI|}}} |&amp;rft_id=info:doi/{{urlencode:{{{DOI}}}}}
    }}{{
      #if: {{{ISBN|}}} |&amp;rft.isbn={{urlencode:{{{ISBN}}}}}
    }}{{
      #if: {{{ISSN|}}} |&amp;rft.issn={{urlencode:{{{ISSN}}}}}
    }}{{
      #if: {{{JFM|}}} |&amp;rft.jfm={{urlencode:{{{JFM}}}}}
    }}{{
      #if: {{{JSTOR|}}} |&amp;rft.jstor={{urlencode:{{{JSTOR}}}}}
    }}{{
      #if: {{{LCCN|}}} |&amp;rft.lccn={{urlencode:{{{LCCN}}}}}
    }}{{
      #if: {{{OCLC|}}} |&amp;rft_id=info:oclcnum/{{urlencode:{{{OCLC}}}}}
    }}{{
      #if: {{{OL|}}} |&amp;rft_id=info:olnum/{{urlencode:{{{OL}}}}}
    }}{{
      #if: {{{OSTI|}}} |&amp;rft_id=info:osti/{{urlencode:{{{OSTI}}}}}
    }}{{
      #if: {{{MR|}}} |&amp;rft.mr={{urlencode:{{{MR}}}}}
    }}{{
      #if: {{{PMC|}}} |&amp;rft_id=info:pmc/{{urlencode:{{{PMC}}}}}
    }}{{
      #if: {{{PMID|}}} |&amp;rft_id=info:pmid/{{urlencode:{{{PMID}}}}}
    }}{{
      #if: {{{RFC|}}} |&amp;rft_id=info:rfc/{{urlencode:{{{RFC}}}}}
    }}{{
      #if: {{{SSRN|}}} |&amp;rft_id=info:ssrn/{{urlencode:{{{SSRN}}}}}
    }}{{
      #if: {{{ZBL|}}} |&amp;rft_id=info:zbl/{{urlencode:{{{ZBL}}}}}
    }}{{
      #if: {{{URL|}}}{{{IncludedWorkURL|}}} |&amp;rft_id={{urlencode:{{{URL|{{{IncludedWorkURL|}}}}}}}}
    }}&amp;rfr_id=info:sid/en.wikipedia.org:{{FULLPAGENAMEE}}&quot;&gt;&lt;span style=&quot;display: none;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;noinclude&gt;
{{Documentation}}
&lt;/noinclude&gt;</text>
      <sha1>gd5lzu9vxjaeyq4m8ym55m1qddorc47</sha1>
    </revision>
    <revision>
      <id>1954</id>
      <parentid>1953</parentid>
      <timestamp>2016-11-09T15:20:03Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <origin>1954</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="26778" sha1="f2q0c7w6cb1ymg3g2qqqwou8hovone2" xml:space="preserve">&lt;span class=&quot;citation {{{Citation class|{{{Citation type|}}}}}}&quot;
{{
  #switch:{{{Ref|}}}
  ||none =
  |#default = id=&quot;{{anchorencode:{{{Ref}}}}}&quot;
  |harv = {{#if:{{{Surname1|}}}{{{EditorSurname1|}}}
    |id=&quot;CITEREF{{anchorencode:{{#if:{{{Surname1|}}}
      |{{{Surname1}}}{{{Surname2|}}}{{{Surname3|}}}{{{Surname4|}}}
      |{{{EditorSurname1|}}}{{{EditorSurname2|}}}{{{EditorSurname3|}}}{{{EditorSurname4|}}}
    }}{{{Year|{{{Date|}}}}}}}}&quot;
  }}
}}&gt;{{
&lt;!--============  Author or editor and date  ============--&gt;
  #if:{{{Surname1|}}}
  |{{
     #if: {{{AuthorMask|}}}
     |{{
        #iferror: {{ #expr: 1*{{{AuthorMask}}} }}
        |{{{AuthorMask}}}
        |{{loop|{{{AuthorMask}}}|2=&amp;mdash;}}
      }}
     |{{
        #if: {{{Authorlink1|}}}
        |[[{{{Authorlink1}}} |{{{Surname1}}}{{
          #if: {{{Given1|}}}
          |{{{NameSep|,&amp;#32;}}}{{{Given1}}}
         }}]]
        |{{{Surname1}}}{{
           #if: {{{Given1|}}}
           |{{{NameSep|,&amp;#32;}}}{{{Given1}}}
         }}
      }}
   }}{{
     #if: {{{Surname2|}}}
     |{{#ifexpr:{{{Trunc|8}}}&lt;2
       |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
       |{{
          #iferror: {{ #expr: 1*0.0{{{AuthorMask|}}} }}
          |&amp;#32;&lt;!-- then punctuation should be included in AuthorMask --&gt;
          |{{
            #if: {{{Surname3|}}}
            |{{{AuthorSep|&amp;#059;&amp;#32;}}}
            |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
          }}
        }}{{
          #if: {{{Authorlink2|}}}
          |[[{{{Authorlink2}}} |{{{Surname2}}}{{
             #if: {{{Given2|}}}
             |{{{NameSep|,&amp;#32;}}}{{{Given2}}}
           }}]]
          |{{{Surname2}}}{{
             #if: {{{Given2|}}}
             |{{{NameSep|,&amp;#32;}}}{{{Given2}}}
           }}
        }}{{
          #if: {{{Surname3|}}}
          |{{#ifexpr:{{{Trunc|8}}}&lt;3
            |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
            |{{
               #if: {{{Surname4|}}}
               |{{{AuthorSep|&amp;#059;&amp;#32;}}}
               |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
             }}{{
               #if: {{{Authorlink3|}}}
               |[[{{{Authorlink3}}} |{{{Surname3}}}{{
                  #if: {{{Given3|}}}
                  |{{{NameSep|,&amp;#32;}}}{{{Given3}}}
                }}]]
               |{{{Surname3}}}{{
                  #if: {{{Given3|}}}
                  |{{{NameSep|,&amp;#32;}}}{{{Given3}}}
                }}
             }}{{
               #if:{{{Surname4|}}}
               |{{#ifexpr:{{{Trunc|8}}}&lt;4
                 |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
                 |{{
                    #if: {{{Surname5|}}}
                    |{{{AuthorSep|&amp;#059;&amp;#32;}}}
                    |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
                  }}{{
                    #if: {{{Authorlink4|}}}
                    |[[{{{Authorlink4}}} |{{{Surname4}}}{{
                       #if: {{{Given4|}}}
                       |{{{NameSep|,&amp;#32;}}}{{{Given4}}}
                     }}]]
                    |{{{Surname4}}}{{
                       #if: {{{Given4|}}}
                       |{{{NameSep|,&amp;#32;}}}{{{Given4}}}
                    }}
                  }}{{
                  #if:{{{Surname5|}}}
                  |{{#ifexpr:{{{Trunc|8}}}&lt;5
                    |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
                    |{{
                     #if: {{{Surname6|}}}
                     |{{{AuthorSep|&amp;#059;&amp;#32;}}}
                     |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
                    }}{{
                     #if: {{{Authorlink5|}}}
                     |[[{{{Authorlink5}}} |{{{Surname5}}}{{
                        #if: {{{Given5|}}}
                        |{{{NameSep|,&amp;#32;}}}{{{Given5}}}
                      }}]]
                     |{{{Surname5}}}{{
                        #if: {{{Given5|}}}
                        |{{{NameSep|,&amp;#32;}}}{{{Given5}}}
                      }}
                   }}{{
                     #if:{{{Surname6|}}}
                     |{{#ifexpr:{{{Trunc|8}}}&lt;6
                     |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
                      |{{
                        #if: {{{Surname7|}}}
                        |{{{AuthorSep|&amp;#059;&amp;#32;}}}
                        |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
                      }}{{
                        #if: {{{Authorlink6|}}}
                        |[[{{{Authorlink6}}} |{{{Surname6}}}{{
                           #if: {{{Given6|}}}
                           |{{{NameSep|,&amp;#32;}}}{{{Given6}}}
                         }}]]
                        |{{{Surname6}}}{{
                           #if: {{{Given6|}}}
                           |{{{NameSep|,&amp;#32;}}}{{{Given6}}}
                         }}
                      }}{{
                        #if:{{{Surname7|}}}
                         |{{#ifexpr:{{{Trunc|8}}}&lt;7
                           |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
                        |{{
                           #if: {{{Surname8|}}}
                           |{{{AuthorSep|&amp;#059;&amp;#32;}}}
                           |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
                         }}{{
                           #if: {{{Authorlink7|}}}
                           |[[{{{Authorlink7}}} |{{{Surname7}}}{{
                              #if: {{{Given7|}}}
                              |{{{NameSep|,&amp;#32;}}}{{{Given7}}}
                            }}]]
                           |{{{Surname7}}}{{
                              #if: {{{Given7|}}}
                              |{{{NameSep|,&amp;#32;}}}{{{Given7}}}
                            }}
                                    }}{{
                                       #if:{{{Surname8|}}}
                                       |{{#ifexpr:{{{Trunc|8}}}&lt;8
                                           |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
                                           |{{
                                              #if: {{{Surname9|}}}
                                              |{{{AuthorSep|&amp;#059;&amp;#32;}}}
                                              |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
                                            }}{{
                                              #if: {{{Authorlink8|}}}
                                              |[[{{{Authorlink8}}} |{{{Surname8}}}{{
                                                 #if: {{{Given8|}}}
                                                 |{{{NameSep|,&amp;#32;}}}{{{Given8}}}
                                               }}]]
                                              |{{{Surname8}}}{{
                                                 #if: {{{Given8|}}}
                                                 |{{{NameSep|,&amp;#32;}}}{{{Given8}}}
                                               }}
                                            }}{{
                                              #if:{{{Surname9|}}}
                                              |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
                                            }}
                                         }}
                                      }}
                                   }}
                                }}
                             }}
                          }}
                       }}
                     }}
                  }}
               }}
            }}
         }}
      }}

   }}{{
     #if: {{{Coauthors|}}}
     |{{{AuthorSep|&amp;#059;&amp;#32;}}}{{{Coauthors|}}}|
   }}{{
     #if: {{{Date|}}}
     |&amp;#32;({{{Date}}}){{
       #if:{{{YearNote|}}}
     |&amp;#32;[{{{YearNote}}}]
     }}
   }}
  |{{&lt;!-- ============== No author: display editors first == --&gt;
     #if: {{{EditorSurname1|}}}
     |{{
        #if: {{{Editorlink1|}}}
        |[[{{{Editorlink1}}} |{{{EditorSurname1}}}{{
           #if: {{{EditorGiven1|}}}
           |, {{{EditorGiven1}}}
         }}]]
        |{{{EditorSurname1}}}{{
           #if: {{{EditorGiven1|}}}
           |, {{{EditorGiven1}}}
         }}
      }}{{
        #if: {{{EditorSurname2|}}}
        |{{
          #if: {{{EditorSurname3|}}}
          |{{{AuthorSep|&amp;#059;&amp;#32;}}}
          |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
        }}{{
           #if: {{{Editorlink2|}}}
           |[[{{{Editorlink2}}} |{{{EditorSurname2}}}{{
              #if: {{{EditorGiven2|}}}
              |, {{{EditorGiven2}}}
            }}]]
           |{{{EditorSurname2}}}{{
              #if: {{{EditorGiven2|}}}
              |, {{{EditorGiven2}}}
            }}
         }}{{
           #if: {{{EditorSurname3|}}}
           |{{
              #if: {{{EditorSurname4|}}}
              |{{{AuthorSep|&amp;#059;&amp;#32;}}}
              |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
            }}{{
              #if: {{{Editorlink3|}}}
              |[[{{{Editorlink3}}} |{{{EditorSurname3}}}{{
                 #if: {{{EditorGiven3|}}}
                 |, {{{EditorGiven3}}}
               }}]]
              |{{{EditorSurname3}}}{{
                 #if: {{{EditorGiven3|}}}
                 |, {{{EditorGiven3}}}
               }}
            }}{{
              #if:{{{EditorSurname4|}}}
              |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
            }}
         }}
       }}, ed{{#if:{{{EditorSurname2|}}}|s}}{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}{{
        #if: {{{Date|}}}
        |&amp;#32;({{{Date}}}){{
         #if:{{{YearNote|}}}
       |&amp;#32;[{{{YearNote}}}]
       }}
      }}
   }}
}}{{
&lt;!--============  Title of included work  ============--&gt;
  #if: {{{IncludedWorkTitle|}}}{{#if:{{{Periodical|}}}||{{#if:{{{TransItalic|}}}||{{{TransTitle|}}}}}}}
  |{{
     #if:{{{Surname1|}}}{{{EditorSurname1|}}}
     |{{{Sep|,}}}&amp;#32;
   }}{{Citation/make link
     | 1={{
           #if: {{{IncludedWorkURL|}}}
           |{{{IncludedWorkURL}}}
           |{{
              #if: {{{URL|}}}
              |{{{URL}}}
            }}
         }}
     | 2={{
           #if: {{{Periodical|}}}
           |''&lt;nowiki /&gt;{{{IncludedWorkTitle}}}&lt;nowiki /&gt;''
           |&quot;{{{IncludedWorkTitle|}}}{{
             #if: {{{TransTitle|}}}
             |{{
                #if: {{{IncludedWorkTitle|}}}
                |&amp;#32;
              }}&amp;#91;{{{TransTitle}}}&amp;#93;
           }}&quot;
         }}
   }}
}}{{
&lt;!--============  Place (if different than PublicationPlace) ============--&gt;
  #if: {{{Place|}}}
  |{{
     #ifeq: {{{Place|}}} | {{{PublicationPlace|}}}
     |
     |{{
        #if: {{{Surname1|}}}{{{EditorSurname1|}}}{{{IncludedWorkTitle|}}}
        |{{{Sep|,}}}&amp;#32;written at {{{Place}}}
      }}
   }}
}}{{
&lt;!--============  Editor of compilation  ============--&gt;
  #if: {{{EditorSurname1|}}}
  |{{
     #if: {{{Surname1|}}}
     |{{{Sep|,}}}&amp;#32;{{
        #if: {{{IncludedWorkTitle|}}}
        |{{#ifeq:{{{Sep|}}}|.|I|i}}n&amp;#32;
      }}{{
        #if: {{{Editorlink1|}}}
        |[[{{{Editorlink1}}} |{{{EditorSurname1}}}{{
           #if: {{{EditorGiven1|}}}
           |, {{{EditorGiven1}}}
         }}]]
        |{{{EditorSurname1}}}{{
           #if: {{{EditorGiven1|}}}
           |, {{{EditorGiven1}}}
         }}}}{{
        #if: {{{EditorSurname2|}}}
        |{{
          #if: {{{EditorSurname3|}}}
            |{{{AuthorSep|&amp;#059;&amp;#32;}}}
            |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
          }}{{
           #if: {{{Editorlink2|}}}
           |[[{{{Editorlink2}}}|{{{EditorSurname2}}}{{
              #if: {{{EditorGiven2|}}}
              |, {{{EditorGiven2}}}
            }}]]
           |{{{EditorSurname2}}}{{
              #if: {{{EditorGiven2|}}}
              |, {{{EditorGiven2}}}
            }}
         }}{{
           #if: {{{EditorSurname3|}}}
           |{{
              #if: {{{EditorSurname4|}}}
              |&amp;#059;&amp;#32;
              |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
            }}{{
              #if: {{{Editorlink3|}}}
              |[[{{{Editorlink3}}}|{{{EditorSurname3}}}{{
                 #if: {{{EditorGiven3|}}}
                 |, {{{EditorGiven3}}}
               }}]]
              |{{{EditorSurname3}}}{{
                 #if: {{{EditorGiven3|}}}
                 |, {{{EditorGiven3}}}
               }}
            }}{{
              #if:{{{EditorSurname4|}}}
              |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
            }}
         }}
      }}{{
        #if: {{{IncludedWorkTitle|}}}
        |
        |{{{Sep|,}}}&amp;#32;ed{{#if:{{{EditorSurname2|}}}|s}}{{#ifeq:{{{Sep}}}|.||.}}
      }}
   }}
}}{{
  &lt;!--============  Periodicals  ============--&gt;
  #if: {{{Periodical|}}}
  |{{
     #if: {{{Other|}}}
     |{{{Sep|,}}}&amp;#32;{{{Other|}}}
   }}{{
     #if: {{{Surname1|}}}{{{EditorSurname1|}}}{{{IncludedWorkTitle|}}}
     |{{{Sep|,}}}&amp;#32;}}{{
     #if: {{{Title|}}}{{{TransTitle|}}}
     |{{Citation/make link
        | 1={{
              #if: {{{IncludedWorkTitle|}}}
              |{{
                 #if: {{{IncludedWorkURL|}}}
                 |{{
                    #if: {{{URL|}}}
                    |{{{URL}}}
                  }}
               }}
              |{{
                 #if: {{{URL|}}}
                 |{{{URL}}}
               }}
            }}
        | 2=&quot;{{{Title}}}{{
          #if: {{{TransTitle|}}}
          |{{
             #if: {{{Title|}}}
             |&amp;#32;
           }}&amp;#91;{{{TransTitle}}}&amp;#93;
        }}&quot;
      }}{{
        #if: {{{TitleNote|}}}
        |{{{Sep|,}}}&amp;#32;{{{TitleNote}}}
      }}
   }}
}}{{
  #if: {{{language|}}}
  |&amp;#32;(in {{{language}}})
}}{{
  #if: {{{format|}}}
  |&amp;#32;({{{format}}})
}}{{
   #if: {{{Periodical|}}}
   |{{
      #if:{{{IncludedWorkTitle|}}}{{{Title|}}}{{{TransTitle|}}}
      |{{{Sep|,}}}&amp;#32;
    }}''&lt;nowiki /&gt;{{{Periodical}}}&lt;nowiki /&gt;''{{
      #if: {{{Series|}}}
      |{{{Sep|,}}}&amp;#32;{{{Series}}}
    }}{{
      #if: {{{PublicationPlace|}}}
      |{{
         #if: {{{Publisher|}}}
         |&amp;#32;({{{PublicationPlace}}}&lt;nowiki&gt;: &lt;/nowiki&gt;{{{Publisher}}})
         |&amp;#32;({{{PublicationPlace}}})
       }}
      |{{
         #if: {{{Publisher|}}}
         |&amp;#32;({{{Publisher}}})
       }}
    }}{{
      #if: {{{Volume|}}}
      |&amp;#32;{{#if:{{{Periodical|}}}|'''&lt;nowiki /&gt;{{{Volume}}}&lt;nowiki /&gt;'''|{{{Volume}}}}}{{
         #if: {{{Issue|}}}
         |&amp;#32;({{{Issue}}})
       }}
      |{{
         #if: {{{Issue|}}}
         |&amp;#32;({{{Issue}}})
       }}
    }}{{
      #if: {{{At|}}}
      |&lt;nowiki&gt;: &lt;/nowiki&gt; {{{At}}}
    }}
   |{{
      &lt;!--============ Anything else with a title, including books ============--&gt;
      #if: {{{Title|}}}{{{TransItalic|}}}
      |{{
         #if: {{{Surname1|}}}{{{EditorSurname1|}}}{{{IncludedWorkTitle|}}}{{{Periodical|}}}
         |{{{Sep|,}}}
       }}&amp;#32;{{Citation/make link
         | 1={{
               #if: {{{IncludedWorkTitle|}}}
               |{{
                  #if: {{{IncludedWorkURL|}}}
                  |{{
                     #if: {{{URL|}}}
                     |{{{URL}}}
                   }}
                }}
               |{{
                  #if: {{{URL|}}}
                  |{{{URL}}}
                }}
             }}
         | 2=''&lt;nowiki /&gt;{{{Title|}}}{{
            #if:{{{TransItalic|}}}|&amp;#32;&amp;#91;{{{TransItalic}}}&amp;#93;
          }}&lt;nowiki /&gt;''
       }}
    }}{{
      #if: {{{TitleType|}}}
      |&amp;#32;({{{TitleType}}})
    }}{{
      #if: {{{Series|}}}
      |{{{Sep|,}}}&amp;#32;{{{Series}}}
    }}{{
      #if: {{{Volume|}}}
      |{{{Sep|,}}}&amp;#32;'''&lt;nowiki /&gt;{{{Volume}}}&lt;nowiki /&gt;'''
    }}{{
      #if: {{{Other|}}}
      |{{{Sep|,}}}&amp;#32;{{{Other|}}}
    }}{{
      #if: {{{Edition|}}}
      |&amp;#32;({{{Edition}}} ed.)
    }}{{
      #if: {{{PublicationPlace|}}}
      |{{{Sep|,}}}&amp;#32;{{{PublicationPlace}}}
    }}{{
      #if: {{{Publisher|}}}
      |{{
         #if: {{{PublicationPlace|}}}
         |&lt;nowiki&gt;:&lt;/nowiki&gt;
         |{{{Sep|,}}}
       }}&amp;#32;{{{Publisher}}}
    }}
}}{{
&lt;!--============ Date (if no author/editor) ============--&gt;
  #if: {{{Surname1|}}}{{{EditorSurname1|}}}
  |
  |{{
     #if: {{{Date|}}}
     |{{{Sep|,}}}&amp;#32;{{{Date}}}{{
       #if:{{{YearNote|}}}
     |&amp;#32;[{{{YearNote}}}]
     }}
   }}
}}{{
&lt;!--============ Publication date ============--&gt;
  #if: {{{PublicationDate|}}}
  |{{
     #ifeq: {{{PublicationDate|}}} | {{{Date|}}}
     |
     |{{
        #if: {{{EditorSurname1|}}}
        |{{
           #if: {{{Surname1|}}}
           |{{{Sep|,}}}&amp;#32;{{{PublicationDate}}}
           |&amp;#32;(published {{{PublicationDate}}})
         }}
        |{{
           #if: {{{Periodical|}}}
           |{{{Sep|,}}}&amp;#32;{{{PublicationDate}}}
           |&amp;#32;(published {{{PublicationDate}}})
         }}
      }}
   }}
}}{{
&lt;!--============ Page within included work ============--&gt;
  #if: {{{Periodical|}}}
  |
  |{{
     #if: {{{At|}}}
     |{{{Sep|,}}}&amp;#32;{{{At}}}
   }}
}}{{
&lt;!--============ arXiv ==============--&gt;
  #if: {{{ARXIV|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=arxiv |input1={{{ARXIV|}}} }}
}}{{
&lt;!--============ ASIN ===============--&gt;
  #if: {{{ASIN|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=asin |input1={{{ASIN|}}} |input2={{{ASIN-TLD|}}} }}
}}{{
&lt;!--============ BIBCODE ============--&gt;
  #if: {{{BIBCODE|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=bibcode |input1={{{BIBCODE|}}} }}
}}{{
&lt;!--============ DOI ================--&gt;
#if:{{{DOI|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=doi |input1={{{DOI|}}}  |input2={{{DoiBroken|}}} |input3={{{template doc demo|}}}}}
}}{{
&lt;!--============ ISBN ===============--&gt;
  #if: {{{ISBN|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=isbn |input1={{{ISBN|}}} }}
}}{{
&lt;!--============ ISSN ===============--&gt;
  #if: {{{ISSN|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=issn |input1={{{ISSN|}}} }}
}}{{
&lt;!--============ JFM ================--&gt;
  #if: {{{JFM|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=jfm |input1={{{JFM|}}} }}
}}{{
&lt;!--============ JSTOR ==============--&gt;
  #if: {{{JSTOR|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=jstor |input1={{{JSTOR|}}} }}
}}{{
&lt;!--============ LCCN ===============--&gt;
  #if: {{{LCCN|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=lccn |input1={{{LCCN|}}} }}
}}{{
&lt;!--============ MR =================--&gt;
  #if: {{{MR|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=mr |input1={{{MR|}}} }}
}}{{
&lt;!--============ OCLC ===============--&gt;
  #if: {{{OCLC|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=oclc |input1={{{OCLC|}}} }}
}}{{
&lt;!--============ OL =================--&gt;
  #if: {{{OL|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=ol |input1={{{OL|}}} }}
}}{{
&lt;!--============ OSTI ===============--&gt;
  #if: {{{OSTI|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=osti |input1={{{OSTI|}}} }}
}}{{
&lt;!--============ PMC ================--&gt;
  #if: {{{PMC|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=pmc |input1={{{PMC|}}} }}
}}{{
&lt;!--============ PMID ===============--&gt;
  #if: {{{PMID|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=pmid |input1={{{PMID|}}} }}
}}{{
&lt;!--============ RFC ================--&gt;
  #if: {{{RFC|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=rfc|input1={{{RFC|}}} }}
}}{{
&lt;!--============ SSRN ================--&gt;
  #if: {{{SSRN|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=ssrn |input1={{{SSRN|}}} }}
}}{{
&lt;!--============ ZBL ================--&gt;
  #if: {{{ZBL|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=zbl |input1={{{ZBL|}}} }}
}}{{
&lt;!--============  Misc. Identifier ============--&gt;
  #if: {{{ID|}}}
  |{{{Sep|,}}}&amp;#32;{{{ID}}}
}}{{
&lt;!--============  Archive data, etc ===========--&gt;
#if: {{{Archive|}}}
|{{{Sep|,}}}&amp;#32;{{{Archive}}}[[Category:Pages using deprecated citation archive parameters]]
|{{
  #if:{{{ArchiveURL|}}}{{{ArchiveDate|}}}
  | {{{Sep|,}}}&amp;#32;{{#ifeq: {{{DeadURL|}}} | no
    | {{#if:{{{ArchiveURL|}}}
       |{{Citation/make link|{{{ArchiveURL|}}}|{{#ifeq:{{{Sep}}}|.|A|a}}rchived}}&amp;#32;from the original
       |{{#ifeq:{{{Sep}}}|.|A|a}}rchived
      }}
    | {{#ifeq:{{{Sep}}}|.|A|a}}rchived{{#if:{{{OriginalURL|}}}{{{IncludedWorkURL|}}}
       |{{#if:{{{ArchiveURL|}}}|&amp;#32;from {{Citation/make link|{{{OriginalURL|{{{IncludedWorkURL|}}}}}}|the original}}}}
      }}
    }}{{#if:{{{ArchiveDate|}}}|&amp;#32;on {{{ArchiveDate}}}}}{{
     #if:{{#if:{{{ArchiveURL|}}}||A}}{{#if:{{{OriginalURL|}}}{{{IncludedWorkURL|}}}||B}}{{#if:{{{ArchiveDate|}}}||C}}
     |. {{citation error|nocat={{{template doc demo|}}}
       |If you specify &lt;code&gt;&amp;#124;{{#if:{{{ArchiveURL|}}}|archiveurl|archivedate}}&amp;#61;&lt;/code&gt;{{#ifeq:{{{DeadURL|}}}|no|{{#if:{{{OriginalURL|}}}{{{IncludedWorkURL|}}}||&amp;#32;and &lt;code&gt;&amp;#124;deadurl&amp;#61;no&lt;/code&gt;}}}}, you must {{#if:{{{OriginalURL|}}}{{{IncludedWorkURL|}}}| also specify &lt;code&gt;&amp;#124;{{#if:{{{ArchiveURL|}}}|archivedate|archiveurl}}&amp;#61;&lt;/code&gt;| {{#ifeq:{{{DeadURL|}}}|no|also|first}} specify &lt;code&gt;&amp;#124;url&amp;#61;&lt;/code&gt;}}}}
    }}
  }}
}}{{
&lt;!--============ URL and AccessDate ============--&gt;
  #if: {{{URL|}}}{{{IncludedWorkURL|}}}{{#ifeq:{{{DeadURL|}}}|no|{{{ArchiveURL|}}}|}}
  |{{
     #if: {{{Title|}}}{{{IncludedWorkTitle|}}}{{{TransTitle|}}}
     |&lt;span class=&quot;printonly&quot;&gt;{{{Sep|,}}}&amp;#32;{{
                                      #if: {{{IncludedWorkURL|}}}
                                      |{{{IncludedWorkURL}}}
                                      |{{{URL}}}
                                    }}&lt;/span&gt;
     |{{{Sep|,}}}&amp;#32;{{
              #if: {{{IncludedWorkURL|}}}
              |{{{IncludedWorkURL}}}
              |{{{URL}}}
            }}
   }}{{
     #if: {{{AccessDate|}}}
     | &lt;span class=&quot;reference-accessdate&quot;&gt;{{#ifeq:{{{Sep|}}}|,|,&amp;#32;r|.&amp;#32;R}}etrieved {{{AccessDate}}}&lt;/span&gt;
     }}
}}{{#if:{{{laysummary|}}}
  |{{{Sep|,}}}&amp;#32;[{{{laysummary}}} Lay summary]{{#if: {{{laysource|}}}|&amp;nbsp;&amp;ndash;&amp;nbsp;''&lt;nowiki /&gt;{{{laysource}}}&lt;nowiki /&gt;''}}
}}{{#if:{{{laydate|}}}
  | &amp;#32;({{{laydate}}})
}}{{#if:{{{quote|}}}
  |{{{Sep|,}}}&amp;#32;&quot;{{{quote}}}&quot;
}}{{{PS|}}}&lt;/span&gt;&lt;!--

=== This is a COinS tag (http://ocoins.info), which allows automated tools to parse the citation information: ===

--&gt;&lt;span
    class=&quot;Z3988&quot;
    title=&quot;ctx_ver=Z39.88-2004&amp;rft_val_fmt={{urlencode:info:ofi/fmt:kev:mtx:}}{{
      #if: {{{Periodical|}}}
      |journal&amp;rft.genre=article&amp;rft.atitle={{urlencode:{{{Title|}}}}}&amp;rft.jtitle={{urlencode:{{{Periodical|}}}}}
      |book{{
         #if: {{{IncludedWorkTitle|}}}
         |&amp;rft.genre=bookitem&amp;rft.btitle={{urlencode:{{{IncludedWorkTitle|}}}}}&amp;rft.atitle={{urlencode:{{{Title|}}}}}
         |&amp;rft.genre=book&amp;rft.btitle={{urlencode:{{{Title|}}}}}
       }}
    }}{{
     #if: {{{Surname1|}}} |&amp;rft.aulast={{urlencode:{{{Surname1}}}}}{{
       #if: {{{Given1|}}} |&amp;rft.aufirst={{urlencode:{{{Given1}}}}}
     }}
   }}{{
     #if: {{{Surname1|}}} |&amp;rft.au={{urlencode:{{{Surname1}}}}}{{
       #if: {{{Given1|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given1}}}}}
     }}
   }}{{
     #if: {{{Surname2|}}} |&amp;rft.au={{urlencode:{{{Surname2}}}}}{{
       #if: {{{Given2|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given2}}}}}
     }}
   }}{{
     #if: {{{Surname3|}}} |&amp;rft.au={{urlencode:{{{Surname3}}}}}{{
       #if: {{{Given3|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given3}}}}}
     }}
   }}{{
     #if: {{{Surname4|}}} |&amp;rft.au={{urlencode:{{{Surname4}}}}}{{
       #if: {{{Given4|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given4}}}}}
     }}
   }}{{
     #if: {{{Surname5|}}} |&amp;rft.au={{urlencode:{{{Surname5}}}}}{{
       #if: {{{Given5|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given5}}}}}
     }}
   }}{{
     #if: {{{Surname6|}}} |&amp;rft.au={{urlencode:{{{Surname6}}}}}{{
       #if: {{{Given6|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given6}}}}}
     }}
   }}{{
     #if: {{{Surname7|}}} |&amp;rft.au={{urlencode:{{{Surname7}}}}}{{
       #if: {{{Given7|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given7}}}}}
     }}
   }}{{
     #if: {{{Surname8|}}} |&amp;rft.au={{urlencode:{{{Surname8}}}}}{{
       #if: {{{Given8|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given8}}}}}
     }}
   }}{{
     #if: {{{Surname9|}}} |&amp;rft.au={{urlencode:{{{Surname9}}}}}{{
       #if: {{{Given9|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given9}}}}}
     }}
    }}{{
      #if: {{{Date|}}} |&amp;rft.date={{urlencode:{{{Date}}}}}
    }}{{
      #if: {{{Series|}}} |&amp;rft.series={{urlencode:{{{Series}}}}}
    }}{{
      #if: {{{Volume|}}} |&amp;rft.volume={{urlencode:{{{Volume}}}}}
    }}{{
      #if: {{{Issue|}}} |&amp;rft.issue={{urlencode:{{{Issue}}}}}
    }}{{
      #if: {{{At|}}} |&amp;rft.pages={{urlencode:{{{At}}}}}
    }}{{
      #if: {{{Edition|}}} |&amp;rft.edition={{urlencode:{{{Edition}}}}}
    }}{{
      #if: {{{PublicationPlace|}}}{{{Place|}}} |&amp;rft.place={{urlencode:{{{PublicationPlace|{{{Place}}}}}}}}
    }}{{
      #if: {{{Publisher|}}} |&amp;rft.pub={{urlencode:{{{Publisher}}}}}
    }}{{
      #if: {{{ARXIV|}}} |&amp;rft_id=info:arxiv/{{urlencode:{{{ARXIV}}}}}
    }}{{
      #if: {{{ASIN|}}} |&amp;rft_id=info:asin/{{urlencode:{{{ASIN}}}}}
    }}{{
      #if: {{{BIBCODE|}}} |&amp;rft_id=info:bibcode/{{urlencode:{{{BIBCODE}}}}}
    }}{{
      #if: {{{DOI|}}} |&amp;rft_id=info:doi/{{urlencode:{{{DOI}}}}}
    }}{{
      #if: {{{ISBN|}}} |&amp;rft.isbn={{urlencode:{{{ISBN}}}}}
    }}{{
      #if: {{{ISSN|}}} |&amp;rft.issn={{urlencode:{{{ISSN}}}}}
    }}{{
      #if: {{{JFM|}}} |&amp;rft.jfm={{urlencode:{{{JFM}}}}}
    }}{{
      #if: {{{JSTOR|}}} |&amp;rft.jstor={{urlencode:{{{JSTOR}}}}}
    }}{{
      #if: {{{LCCN|}}} |&amp;rft.lccn={{urlencode:{{{LCCN}}}}}
    }}{{
      #if: {{{OCLC|}}} |&amp;rft_id=info:oclcnum/{{urlencode:{{{OCLC}}}}}
    }}{{
      #if: {{{OL|}}} |&amp;rft_id=info:olnum/{{urlencode:{{{OL}}}}}
    }}{{
      #if: {{{OSTI|}}} |&amp;rft_id=info:osti/{{urlencode:{{{OSTI}}}}}
    }}{{
      #if: {{{MR|}}} |&amp;rft.mr={{urlencode:{{{MR}}}}}
    }}{{
      #if: {{{PMC|}}} |&amp;rft_id=info:pmc/{{urlencode:{{{PMC}}}}}
    }}{{
      #if: {{{PMID|}}} |&amp;rft_id=info:pmid/{{urlencode:{{{PMID}}}}}
    }}{{
      #if: {{{RFC|}}} |&amp;rft_id=info:rfc/{{urlencode:{{{RFC}}}}}
    }}{{
      #if: {{{SSRN|}}} |&amp;rft_id=info:ssrn/{{urlencode:{{{SSRN}}}}}
    }}{{
      #if: {{{ZBL|}}} |&amp;rft_id=info:zbl/{{urlencode:{{{ZBL}}}}}
    }}{{
      #if: {{{URL|}}}{{{IncludedWorkURL|}}} |&amp;rft_id={{urlencode:{{{URL|{{{IncludedWorkURL|}}}}}}}}
    }}&amp;rfr_id=info:sid/en.wikipedia.org:{{FULLPAGENAMEE}}&quot;&gt;&lt;span style=&quot;display: none;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;noinclude&gt;
{{Wp/nd/Documentation}}
&lt;/noinclude&gt;</text>
      <sha1>f2q0c7w6cb1ymg3g2qqqwou8hovone2</sha1>
    </revision>
    <revision>
      <id>1955</id>
      <parentid>1954</parentid>
      <timestamp>2016-11-09T15:25:48Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <origin>1955</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="26826" sha1="lljtlmvlwoi6tf7rxtyyu41h7rxfu9q" xml:space="preserve">&lt;span class=&quot;citation {{{Wp/nd/citation class|{{{Wp/nd/citation type|}}}}}}&quot;
{{
  #switch:{{{Ref|}}}
  ||none =
  |#default = id=&quot;{{anchorencode:{{{Ref}}}}}&quot;
  |harv = {{#if:{{{Surname1|}}}{{{EditorSurname1|}}}
    |id=&quot;CITEREF{{anchorencode:{{#if:{{{Surname1|}}}
      |{{{Surname1}}}{{{Surname2|}}}{{{Surname3|}}}{{{Surname4|}}}
      |{{{EditorSurname1|}}}{{{EditorSurname2|}}}{{{EditorSurname3|}}}{{{EditorSurname4|}}}
    }}{{{Year|{{{Date|}}}}}}}}&quot;
  }}
}}&gt;{{
&lt;!--============  Author or editor and date  ============--&gt;
  #if:{{{Surname1|}}}
  |{{
     #if: {{{AuthorMask|}}}
     |{{
        #iferror: {{ #expr: 1*{{{AuthorMask}}} }}
        |{{{AuthorMask}}}
        |{{loop|{{{AuthorMask}}}|2=&amp;mdash;}}
      }}
     |{{
        #if: {{{Authorlink1|}}}
        |[[{{{Authorlink1}}} |{{{Surname1}}}{{
          #if: {{{Given1|}}}
          |{{{NameSep|,&amp;#32;}}}{{{Given1}}}
         }}]]
        |{{{Surname1}}}{{
           #if: {{{Given1|}}}
           |{{{NameSep|,&amp;#32;}}}{{{Given1}}}
         }}
      }}
   }}{{
     #if: {{{Surname2|}}}
     |{{#ifexpr:{{{Trunc|8}}}&lt;2
       |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
       |{{
          #iferror: {{ #expr: 1*0.0{{{AuthorMask|}}} }}
          |&amp;#32;&lt;!-- then punctuation should be included in AuthorMask --&gt;
          |{{
            #if: {{{Surname3|}}}
            |{{{AuthorSep|&amp;#059;&amp;#32;}}}
            |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
          }}
        }}{{
          #if: {{{Authorlink2|}}}
          |[[{{{Authorlink2}}} |{{{Surname2}}}{{
             #if: {{{Given2|}}}
             |{{{NameSep|,&amp;#32;}}}{{{Given2}}}
           }}]]
          |{{{Surname2}}}{{
             #if: {{{Given2|}}}
             |{{{NameSep|,&amp;#32;}}}{{{Given2}}}
           }}
        }}{{
          #if: {{{Surname3|}}}
          |{{#ifexpr:{{{Trunc|8}}}&lt;3
            |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
            |{{
               #if: {{{Surname4|}}}
               |{{{AuthorSep|&amp;#059;&amp;#32;}}}
               |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
             }}{{
               #if: {{{Authorlink3|}}}
               |[[{{{Authorlink3}}} |{{{Surname3}}}{{
                  #if: {{{Given3|}}}
                  |{{{NameSep|,&amp;#32;}}}{{{Given3}}}
                }}]]
               |{{{Surname3}}}{{
                  #if: {{{Given3|}}}
                  |{{{NameSep|,&amp;#32;}}}{{{Given3}}}
                }}
             }}{{
               #if:{{{Surname4|}}}
               |{{#ifexpr:{{{Trunc|8}}}&lt;4
                 |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
                 |{{
                    #if: {{{Surname5|}}}
                    |{{{AuthorSep|&amp;#059;&amp;#32;}}}
                    |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
                  }}{{
                    #if: {{{Authorlink4|}}}
                    |[[{{{Authorlink4}}} |{{{Surname4}}}{{
                       #if: {{{Given4|}}}
                       |{{{NameSep|,&amp;#32;}}}{{{Given4}}}
                     }}]]
                    |{{{Surname4}}}{{
                       #if: {{{Given4|}}}
                       |{{{NameSep|,&amp;#32;}}}{{{Given4}}}
                    }}
                  }}{{
                  #if:{{{Surname5|}}}
                  |{{#ifexpr:{{{Trunc|8}}}&lt;5
                    |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
                    |{{
                     #if: {{{Surname6|}}}
                     |{{{AuthorSep|&amp;#059;&amp;#32;}}}
                     |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
                    }}{{
                     #if: {{{Authorlink5|}}}
                     |[[{{{Authorlink5}}} |{{{Surname5}}}{{
                        #if: {{{Given5|}}}
                        |{{{NameSep|,&amp;#32;}}}{{{Given5}}}
                      }}]]
                     |{{{Surname5}}}{{
                        #if: {{{Given5|}}}
                        |{{{NameSep|,&amp;#32;}}}{{{Given5}}}
                      }}
                   }}{{
                     #if:{{{Surname6|}}}
                     |{{#ifexpr:{{{Trunc|8}}}&lt;6
                     |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
                      |{{
                        #if: {{{Surname7|}}}
                        |{{{AuthorSep|&amp;#059;&amp;#32;}}}
                        |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
                      }}{{
                        #if: {{{Authorlink6|}}}
                        |[[{{{Authorlink6}}} |{{{Surname6}}}{{
                           #if: {{{Given6|}}}
                           |{{{NameSep|,&amp;#32;}}}{{{Given6}}}
                         }}]]
                        |{{{Surname6}}}{{
                           #if: {{{Given6|}}}
                           |{{{NameSep|,&amp;#32;}}}{{{Given6}}}
                         }}
                      }}{{
                        #if:{{{Surname7|}}}
                         |{{#ifexpr:{{{Trunc|8}}}&lt;7
                           |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
                        |{{
                           #if: {{{Surname8|}}}
                           |{{{AuthorSep|&amp;#059;&amp;#32;}}}
                           |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
                         }}{{
                           #if: {{{Authorlink7|}}}
                           |[[{{{Authorlink7}}} |{{{Surname7}}}{{
                              #if: {{{Given7|}}}
                              |{{{NameSep|,&amp;#32;}}}{{{Given7}}}
                            }}]]
                           |{{{Surname7}}}{{
                              #if: {{{Given7|}}}
                              |{{{NameSep|,&amp;#32;}}}{{{Given7}}}
                            }}
                                    }}{{
                                       #if:{{{Surname8|}}}
                                       |{{#ifexpr:{{{Trunc|8}}}&lt;8
                                           |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
                                           |{{
                                              #if: {{{Surname9|}}}
                                              |{{{AuthorSep|&amp;#059;&amp;#32;}}}
                                              |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
                                            }}{{
                                              #if: {{{Authorlink8|}}}
                                              |[[{{{Authorlink8}}} |{{{Surname8}}}{{
                                                 #if: {{{Given8|}}}
                                                 |{{{NameSep|,&amp;#32;}}}{{{Given8}}}
                                               }}]]
                                              |{{{Surname8}}}{{
                                                 #if: {{{Given8|}}}
                                                 |{{{NameSep|,&amp;#32;}}}{{{Given8}}}
                                               }}
                                            }}{{
                                              #if:{{{Surname9|}}}
                                              |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
                                            }}
                                         }}
                                      }}
                                   }}
                                }}
                             }}
                          }}
                       }}
                     }}
                  }}
               }}
            }}
         }}
      }}

   }}{{
     #if: {{{Coauthors|}}}
     |{{{AuthorSep|&amp;#059;&amp;#32;}}}{{{Coauthors|}}}|
   }}{{
     #if: {{{Date|}}}
     |&amp;#32;({{{Date}}}){{
       #if:{{{YearNote|}}}
     |&amp;#32;[{{{YearNote}}}]
     }}
   }}
  |{{&lt;!-- ============== No author: display editors first == --&gt;
     #if: {{{EditorSurname1|}}}
     |{{
        #if: {{{Editorlink1|}}}
        |[[{{{Editorlink1}}} |{{{EditorSurname1}}}{{
           #if: {{{EditorGiven1|}}}
           |, {{{EditorGiven1}}}
         }}]]
        |{{{EditorSurname1}}}{{
           #if: {{{EditorGiven1|}}}
           |, {{{EditorGiven1}}}
         }}
      }}{{
        #if: {{{EditorSurname2|}}}
        |{{
          #if: {{{EditorSurname3|}}}
          |{{{AuthorSep|&amp;#059;&amp;#32;}}}
          |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
        }}{{
           #if: {{{Editorlink2|}}}
           |[[{{{Editorlink2}}} |{{{EditorSurname2}}}{{
              #if: {{{EditorGiven2|}}}
              |, {{{EditorGiven2}}}
            }}]]
           |{{{EditorSurname2}}}{{
              #if: {{{EditorGiven2|}}}
              |, {{{EditorGiven2}}}
            }}
         }}{{
           #if: {{{EditorSurname3|}}}
           |{{
              #if: {{{EditorSurname4|}}}
              |{{{AuthorSep|&amp;#059;&amp;#32;}}}
              |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
            }}{{
              #if: {{{Editorlink3|}}}
              |[[{{{Editorlink3}}} |{{{EditorSurname3}}}{{
                 #if: {{{EditorGiven3|}}}
                 |, {{{EditorGiven3}}}
               }}]]
              |{{{EditorSurname3}}}{{
                 #if: {{{EditorGiven3|}}}
                 |, {{{EditorGiven3}}}
               }}
            }}{{
              #if:{{{EditorSurname4|}}}
              |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
            }}
         }}
       }}, ed{{#if:{{{EditorSurname2|}}}|s}}{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}{{
        #if: {{{Date|}}}
        |&amp;#32;({{{Date}}}){{
         #if:{{{YearNote|}}}
       |&amp;#32;[{{{YearNote}}}]
       }}
      }}
   }}
}}{{
&lt;!--============  Title of included work  ============--&gt;
  #if: {{{IncludedWorkTitle|}}}{{#if:{{{Periodical|}}}||{{#if:{{{TransItalic|}}}||{{{TransTitle|}}}}}}}
  |{{
     #if:{{{Surname1|}}}{{{EditorSurname1|}}}
     |{{{Sep|,}}}&amp;#32;
   }}{{Wp/nd/citation/make link
     | 1={{
           #if: {{{IncludedWorkURL|}}}
           |{{{IncludedWorkURL}}}
           |{{
              #if: {{{URL|}}}
              |{{{URL}}}
            }}
         }}
     | 2={{
           #if: {{{Periodical|}}}
           |''&lt;nowiki /&gt;{{{IncludedWorkTitle}}}&lt;nowiki /&gt;''
           |&quot;{{{IncludedWorkTitle|}}}{{
             #if: {{{TransTitle|}}}
             |{{
                #if: {{{IncludedWorkTitle|}}}
                |&amp;#32;
              }}&amp;#91;{{{TransTitle}}}&amp;#93;
           }}&quot;
         }}
   }}
}}{{
&lt;!--============  Place (if different than PublicationPlace) ============--&gt;
  #if: {{{Place|}}}
  |{{
     #ifeq: {{{Place|}}} | {{{PublicationPlace|}}}
     |
     |{{
        #if: {{{Surname1|}}}{{{EditorSurname1|}}}{{{IncludedWorkTitle|}}}
        |{{{Sep|,}}}&amp;#32;written at {{{Place}}}
      }}
   }}
}}{{
&lt;!--============  Editor of compilation  ============--&gt;
  #if: {{{EditorSurname1|}}}
  |{{
     #if: {{{Surname1|}}}
     |{{{Sep|,}}}&amp;#32;{{
        #if: {{{IncludedWorkTitle|}}}
        |{{#ifeq:{{{Sep|}}}|.|I|i}}n&amp;#32;
      }}{{
        #if: {{{Editorlink1|}}}
        |[[{{{Editorlink1}}} |{{{EditorSurname1}}}{{
           #if: {{{EditorGiven1|}}}
           |, {{{EditorGiven1}}}
         }}]]
        |{{{EditorSurname1}}}{{
           #if: {{{EditorGiven1|}}}
           |, {{{EditorGiven1}}}
         }}}}{{
        #if: {{{EditorSurname2|}}}
        |{{
          #if: {{{EditorSurname3|}}}
            |{{{AuthorSep|&amp;#059;&amp;#32;}}}
            |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
          }}{{
           #if: {{{Editorlink2|}}}
           |[[{{{Editorlink2}}}|{{{EditorSurname2}}}{{
              #if: {{{EditorGiven2|}}}
              |, {{{EditorGiven2}}}
            }}]]
           |{{{EditorSurname2}}}{{
              #if: {{{EditorGiven2|}}}
              |, {{{EditorGiven2}}}
            }}
         }}{{
           #if: {{{EditorSurname3|}}}
           |{{
              #if: {{{EditorSurname4|}}}
              |&amp;#059;&amp;#32;
              |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
            }}{{
              #if: {{{Editorlink3|}}}
              |[[{{{Editorlink3}}}|{{{EditorSurname3}}}{{
                 #if: {{{EditorGiven3|}}}
                 |, {{{EditorGiven3}}}
               }}]]
              |{{{EditorSurname3}}}{{
                 #if: {{{EditorGiven3|}}}
                 |, {{{EditorGiven3}}}
               }}
            }}{{
              #if:{{{EditorSurname4|}}}
              |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
            }}
         }}
      }}{{
        #if: {{{IncludedWorkTitle|}}}
        |
        |{{{Sep|,}}}&amp;#32;ed{{#if:{{{EditorSurname2|}}}|s}}{{#ifeq:{{{Sep}}}|.||.}}
      }}
   }}
}}{{
  &lt;!--============  Periodicals  ============--&gt;
  #if: {{{Periodical|}}}
  |{{
     #if: {{{Other|}}}
     |{{{Sep|,}}}&amp;#32;{{{Other|}}}
   }}{{
     #if: {{{Surname1|}}}{{{EditorSurname1|}}}{{{IncludedWorkTitle|}}}
     |{{{Sep|,}}}&amp;#32;}}{{
     #if: {{{Title|}}}{{{TransTitle|}}}
     |{{Wp/nd/citation/make link
        | 1={{
              #if: {{{IncludedWorkTitle|}}}
              |{{
                 #if: {{{IncludedWorkURL|}}}
                 |{{
                    #if: {{{URL|}}}
                    |{{{URL}}}
                  }}
               }}
              |{{
                 #if: {{{URL|}}}
                 |{{{URL}}}
               }}
            }}
        | 2=&quot;{{{Title}}}{{
          #if: {{{TransTitle|}}}
          |{{
             #if: {{{Title|}}}
             |&amp;#32;
           }}&amp;#91;{{{TransTitle}}}&amp;#93;
        }}&quot;
      }}{{
        #if: {{{TitleNote|}}}
        |{{{Sep|,}}}&amp;#32;{{{TitleNote}}}
      }}
   }}
}}{{
  #if: {{{language|}}}
  |&amp;#32;(in {{{language}}})
}}{{
  #if: {{{format|}}}
  |&amp;#32;({{{format}}})
}}{{
   #if: {{{Periodical|}}}
   |{{
      #if:{{{IncludedWorkTitle|}}}{{{Title|}}}{{{TransTitle|}}}
      |{{{Sep|,}}}&amp;#32;
    }}''&lt;nowiki /&gt;{{{Periodical}}}&lt;nowiki /&gt;''{{
      #if: {{{Series|}}}
      |{{{Sep|,}}}&amp;#32;{{{Series}}}
    }}{{
      #if: {{{PublicationPlace|}}}
      |{{
         #if: {{{Publisher|}}}
         |&amp;#32;({{{PublicationPlace}}}&lt;nowiki&gt;: &lt;/nowiki&gt;{{{Publisher}}})
         |&amp;#32;({{{PublicationPlace}}})
       }}
      |{{
         #if: {{{Publisher|}}}
         |&amp;#32;({{{Publisher}}})
       }}
    }}{{
      #if: {{{Volume|}}}
      |&amp;#32;{{#if:{{{Periodical|}}}|'''&lt;nowiki /&gt;{{{Volume}}}&lt;nowiki /&gt;'''|{{{Volume}}}}}{{
         #if: {{{Issue|}}}
         |&amp;#32;({{{Issue}}})
       }}
      |{{
         #if: {{{Issue|}}}
         |&amp;#32;({{{Issue}}})
       }}
    }}{{
      #if: {{{At|}}}
      |&lt;nowiki&gt;: &lt;/nowiki&gt; {{{At}}}
    }}
   |{{
      &lt;!--============ Anything else with a title, including books ============--&gt;
      #if: {{{Title|}}}{{{TransItalic|}}}
      |{{
         #if: {{{Surname1|}}}{{{EditorSurname1|}}}{{{IncludedWorkTitle|}}}{{{Periodical|}}}
         |{{{Sep|,}}}
       }}&amp;#32;{{Wp/nd/citation/make link
         | 1={{
               #if: {{{IncludedWorkTitle|}}}
               |{{
                  #if: {{{IncludedWorkURL|}}}
                  |{{
                     #if: {{{URL|}}}
                     |{{{URL}}}
                   }}
                }}
               |{{
                  #if: {{{URL|}}}
                  |{{{URL}}}
                }}
             }}
         | 2=''&lt;nowiki /&gt;{{{Title|}}}{{
            #if:{{{TransItalic|}}}|&amp;#32;&amp;#91;{{{TransItalic}}}&amp;#93;
          }}&lt;nowiki /&gt;''
       }}
    }}{{
      #if: {{{TitleType|}}}
      |&amp;#32;({{{TitleType}}})
    }}{{
      #if: {{{Series|}}}
      |{{{Sep|,}}}&amp;#32;{{{Series}}}
    }}{{
      #if: {{{Volume|}}}
      |{{{Sep|,}}}&amp;#32;'''&lt;nowiki /&gt;{{{Volume}}}&lt;nowiki /&gt;'''
    }}{{
      #if: {{{Other|}}}
      |{{{Sep|,}}}&amp;#32;{{{Other|}}}
    }}{{
      #if: {{{Edition|}}}
      |&amp;#32;({{{Edition}}} ed.)
    }}{{
      #if: {{{PublicationPlace|}}}
      |{{{Sep|,}}}&amp;#32;{{{PublicationPlace}}}
    }}{{
      #if: {{{Publisher|}}}
      |{{
         #if: {{{PublicationPlace|}}}
         |&lt;nowiki&gt;:&lt;/nowiki&gt;
         |{{{Sep|,}}}
       }}&amp;#32;{{{Publisher}}}
    }}
}}{{
&lt;!--============ Date (if no author/editor) ============--&gt;
  #if: {{{Surname1|}}}{{{EditorSurname1|}}}
  |
  |{{
     #if: {{{Date|}}}
     |{{{Sep|,}}}&amp;#32;{{{Date}}}{{
       #if:{{{YearNote|}}}
     |&amp;#32;[{{{YearNote}}}]
     }}
   }}
}}{{
&lt;!--============ Publication date ============--&gt;
  #if: {{{PublicationDate|}}}
  |{{
     #ifeq: {{{PublicationDate|}}} | {{{Date|}}}
     |
     |{{
        #if: {{{EditorSurname1|}}}
        |{{
           #if: {{{Surname1|}}}
           |{{{Sep|,}}}&amp;#32;{{{PublicationDate}}}
           |&amp;#32;(published {{{PublicationDate}}})
         }}
        |{{
           #if: {{{Periodical|}}}
           |{{{Sep|,}}}&amp;#32;{{{PublicationDate}}}
           |&amp;#32;(published {{{PublicationDate}}})
         }}
      }}
   }}
}}{{
&lt;!--============ Page within included work ============--&gt;
  #if: {{{Periodical|}}}
  |
  |{{
     #if: {{{At|}}}
     |{{{Sep|,}}}&amp;#32;{{{At}}}
   }}
}}{{
&lt;!--============ arXiv ==============--&gt;
  #if: {{{ARXIV|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=arxiv |input1={{{ARXIV|}}} }}
}}{{
&lt;!--============ ASIN ===============--&gt;
  #if: {{{ASIN|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=asin |input1={{{ASIN|}}} |input2={{{ASIN-TLD|}}} }}
}}{{
&lt;!--============ BIBCODE ============--&gt;
  #if: {{{BIBCODE|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=bibcode |input1={{{BIBCODE|}}} }}
}}{{
&lt;!--============ DOI ================--&gt;
#if:{{{DOI|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=doi |input1={{{DOI|}}}  |input2={{{DoiBroken|}}} |input3={{{template doc demo|}}}}}
}}{{
&lt;!--============ ISBN ===============--&gt;
  #if: {{{ISBN|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=isbn |input1={{{ISBN|}}} }}
}}{{
&lt;!--============ ISSN ===============--&gt;
  #if: {{{ISSN|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=issn |input1={{{ISSN|}}} }}
}}{{
&lt;!--============ JFM ================--&gt;
  #if: {{{JFM|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=jfm |input1={{{JFM|}}} }}
}}{{
&lt;!--============ JSTOR ==============--&gt;
  #if: {{{JSTOR|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=jstor |input1={{{JSTOR|}}} }}
}}{{
&lt;!--============ LCCN ===============--&gt;
  #if: {{{LCCN|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=lccn |input1={{{LCCN|}}} }}
}}{{
&lt;!--============ MR =================--&gt;
  #if: {{{MR|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=mr |input1={{{MR|}}} }}
}}{{
&lt;!--============ OCLC ===============--&gt;
  #if: {{{OCLC|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=oclc |input1={{{OCLC|}}} }}
}}{{
&lt;!--============ OL =================--&gt;
  #if: {{{OL|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=ol |input1={{{OL|}}} }}
}}{{
&lt;!--============ OSTI ===============--&gt;
  #if: {{{OSTI|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=osti |input1={{{OSTI|}}} }}
}}{{
&lt;!--============ PMC ================--&gt;
  #if: {{{PMC|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=pmc |input1={{{PMC|}}} }}
}}{{
&lt;!--============ PMID ===============--&gt;
  #if: {{{PMID|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=pmid |input1={{{PMID|}}} }}
}}{{
&lt;!--============ RFC ================--&gt;
  #if: {{{RFC|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=rfc|input1={{{RFC|}}} }}
}}{{
&lt;!--============ SSRN ================--&gt;
  #if: {{{SSRN|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=ssrn |input1={{{SSRN|}}} }}
}}{{
&lt;!--============ ZBL ================--&gt;
  #if: {{{ZBL|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=zbl |input1={{{ZBL|}}} }}
}}{{
&lt;!--============  Misc. Identifier ============--&gt;
  #if: {{{ID|}}}
  |{{{Sep|,}}}&amp;#32;{{{ID}}}
}}{{
&lt;!--============  Archive data, etc ===========--&gt;
#if: {{{Archive|}}}
|{{{Sep|,}}}&amp;#32;{{{Archive}}}[[Category:Pages using deprecated citation archive parameters]]
|{{
  #if:{{{ArchiveURL|}}}{{{ArchiveDate|}}}
  | {{{Sep|,}}}&amp;#32;{{#ifeq: {{{DeadURL|}}} | no
    | {{#if:{{{ArchiveURL|}}}
       |{{Wp/nd/citation/make link|{{{ArchiveURL|}}}|{{#ifeq:{{{Sep}}}|.|A|a}}rchived}}&amp;#32;from the original
       |{{#ifeq:{{{Sep}}}|.|A|a}}rchived
      }}
    | {{#ifeq:{{{Sep}}}|.|A|a}}rchived{{#if:{{{OriginalURL|}}}{{{IncludedWorkURL|}}}
       |{{#if:{{{ArchiveURL|}}}|&amp;#32;from {{Wp/nd/citation/make link|{{{OriginalURL|{{{IncludedWorkURL|}}}}}}|the original}}}}
      }}
    }}{{#if:{{{ArchiveDate|}}}|&amp;#32;on {{{ArchiveDate}}}}}{{
     #if:{{#if:{{{ArchiveURL|}}}||A}}{{#if:{{{OriginalURL|}}}{{{IncludedWorkURL|}}}||B}}{{#if:{{{ArchiveDate|}}}||C}}
     |. {{Wp/nd/citation error|nocat={{{template doc demo|}}}
       |If you specify &lt;code&gt;&amp;#124;{{#if:{{{ArchiveURL|}}}|archiveurl|archivedate}}&amp;#61;&lt;/code&gt;{{#ifeq:{{{DeadURL|}}}|no|{{#if:{{{OriginalURL|}}}{{{IncludedWorkURL|}}}||&amp;#32;and &lt;code&gt;&amp;#124;deadurl&amp;#61;no&lt;/code&gt;}}}}, you must {{#if:{{{OriginalURL|}}}{{{IncludedWorkURL|}}}| also specify &lt;code&gt;&amp;#124;{{#if:{{{ArchiveURL|}}}|archivedate|archiveurl}}&amp;#61;&lt;/code&gt;| {{#ifeq:{{{DeadURL|}}}|no|also|first}} specify &lt;code&gt;&amp;#124;url&amp;#61;&lt;/code&gt;}}}}
    }}
  }}
}}{{
&lt;!--============ URL and AccessDate ============--&gt;
  #if: {{{URL|}}}{{{IncludedWorkURL|}}}{{#ifeq:{{{DeadURL|}}}|no|{{{ArchiveURL|}}}|}}
  |{{
     #if: {{{Title|}}}{{{IncludedWorkTitle|}}}{{{TransTitle|}}}
     |&lt;span class=&quot;printonly&quot;&gt;{{{Sep|,}}}&amp;#32;{{
                                      #if: {{{IncludedWorkURL|}}}
                                      |{{{IncludedWorkURL}}}
                                      |{{{URL}}}
                                    }}&lt;/span&gt;
     |{{{Sep|,}}}&amp;#32;{{
              #if: {{{IncludedWorkURL|}}}
              |{{{IncludedWorkURL}}}
              |{{{URL}}}
            }}
   }}{{
     #if: {{{AccessDate|}}}
     | &lt;span class=&quot;reference-accessdate&quot;&gt;{{#ifeq:{{{Sep|}}}|,|,&amp;#32;r|.&amp;#32;R}}etrieved {{{AccessDate}}}&lt;/span&gt;
     }}
}}{{#if:{{{laysummary|}}}
  |{{{Sep|,}}}&amp;#32;[{{{laysummary}}} Lay summary]{{#if: {{{laysource|}}}|&amp;nbsp;&amp;ndash;&amp;nbsp;''&lt;nowiki /&gt;{{{laysource}}}&lt;nowiki /&gt;''}}
}}{{#if:{{{laydate|}}}
  | &amp;#32;({{{laydate}}})
}}{{#if:{{{quote|}}}
  |{{{Sep|,}}}&amp;#32;&quot;{{{quote}}}&quot;
}}{{{PS|}}}&lt;/span&gt;&lt;!--

=== This is a COinS tag (http://ocoins.info), which allows automated tools to parse the citation information: ===

--&gt;&lt;span
    class=&quot;Z3988&quot;
    title=&quot;ctx_ver=Z39.88-2004&amp;rft_val_fmt={{urlencode:info:ofi/fmt:kev:mtx:}}{{
      #if: {{{Periodical|}}}
      |journal&amp;rft.genre=article&amp;rft.atitle={{urlencode:{{{Title|}}}}}&amp;rft.jtitle={{urlencode:{{{Periodical|}}}}}
      |book{{
         #if: {{{IncludedWorkTitle|}}}
         |&amp;rft.genre=bookitem&amp;rft.btitle={{urlencode:{{{IncludedWorkTitle|}}}}}&amp;rft.atitle={{urlencode:{{{Title|}}}}}
         |&amp;rft.genre=book&amp;rft.btitle={{urlencode:{{{Title|}}}}}
       }}
    }}{{
     #if: {{{Surname1|}}} |&amp;rft.aulast={{urlencode:{{{Surname1}}}}}{{
       #if: {{{Given1|}}} |&amp;rft.aufirst={{urlencode:{{{Given1}}}}}
     }}
   }}{{
     #if: {{{Surname1|}}} |&amp;rft.au={{urlencode:{{{Surname1}}}}}{{
       #if: {{{Given1|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given1}}}}}
     }}
   }}{{
     #if: {{{Surname2|}}} |&amp;rft.au={{urlencode:{{{Surname2}}}}}{{
       #if: {{{Given2|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given2}}}}}
     }}
   }}{{
     #if: {{{Surname3|}}} |&amp;rft.au={{urlencode:{{{Surname3}}}}}{{
       #if: {{{Given3|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given3}}}}}
     }}
   }}{{
     #if: {{{Surname4|}}} |&amp;rft.au={{urlencode:{{{Surname4}}}}}{{
       #if: {{{Given4|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given4}}}}}
     }}
   }}{{
     #if: {{{Surname5|}}} |&amp;rft.au={{urlencode:{{{Surname5}}}}}{{
       #if: {{{Given5|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given5}}}}}
     }}
   }}{{
     #if: {{{Surname6|}}} |&amp;rft.au={{urlencode:{{{Surname6}}}}}{{
       #if: {{{Given6|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given6}}}}}
     }}
   }}{{
     #if: {{{Surname7|}}} |&amp;rft.au={{urlencode:{{{Surname7}}}}}{{
       #if: {{{Given7|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given7}}}}}
     }}
   }}{{
     #if: {{{Surname8|}}} |&amp;rft.au={{urlencode:{{{Surname8}}}}}{{
       #if: {{{Given8|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given8}}}}}
     }}
   }}{{
     #if: {{{Surname9|}}} |&amp;rft.au={{urlencode:{{{Surname9}}}}}{{
       #if: {{{Given9|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given9}}}}}
     }}
    }}{{
      #if: {{{Date|}}} |&amp;rft.date={{urlencode:{{{Date}}}}}
    }}{{
      #if: {{{Series|}}} |&amp;rft.series={{urlencode:{{{Series}}}}}
    }}{{
      #if: {{{Volume|}}} |&amp;rft.volume={{urlencode:{{{Volume}}}}}
    }}{{
      #if: {{{Issue|}}} |&amp;rft.issue={{urlencode:{{{Issue}}}}}
    }}{{
      #if: {{{At|}}} |&amp;rft.pages={{urlencode:{{{At}}}}}
    }}{{
      #if: {{{Edition|}}} |&amp;rft.edition={{urlencode:{{{Edition}}}}}
    }}{{
      #if: {{{PublicationPlace|}}}{{{Place|}}} |&amp;rft.place={{urlencode:{{{PublicationPlace|{{{Place}}}}}}}}
    }}{{
      #if: {{{Publisher|}}} |&amp;rft.pub={{urlencode:{{{Publisher}}}}}
    }}{{
      #if: {{{ARXIV|}}} |&amp;rft_id=info:arxiv/{{urlencode:{{{ARXIV}}}}}
    }}{{
      #if: {{{ASIN|}}} |&amp;rft_id=info:asin/{{urlencode:{{{ASIN}}}}}
    }}{{
      #if: {{{BIBCODE|}}} |&amp;rft_id=info:bibcode/{{urlencode:{{{BIBCODE}}}}}
    }}{{
      #if: {{{DOI|}}} |&amp;rft_id=info:doi/{{urlencode:{{{DOI}}}}}
    }}{{
      #if: {{{ISBN|}}} |&amp;rft.isbn={{urlencode:{{{ISBN}}}}}
    }}{{
      #if: {{{ISSN|}}} |&amp;rft.issn={{urlencode:{{{ISSN}}}}}
    }}{{
      #if: {{{JFM|}}} |&amp;rft.jfm={{urlencode:{{{JFM}}}}}
    }}{{
      #if: {{{JSTOR|}}} |&amp;rft.jstor={{urlencode:{{{JSTOR}}}}}
    }}{{
      #if: {{{LCCN|}}} |&amp;rft.lccn={{urlencode:{{{LCCN}}}}}
    }}{{
      #if: {{{OCLC|}}} |&amp;rft_id=info:oclcnum/{{urlencode:{{{OCLC}}}}}
    }}{{
      #if: {{{OL|}}} |&amp;rft_id=info:olnum/{{urlencode:{{{OL}}}}}
    }}{{
      #if: {{{OSTI|}}} |&amp;rft_id=info:osti/{{urlencode:{{{OSTI}}}}}
    }}{{
      #if: {{{MR|}}} |&amp;rft.mr={{urlencode:{{{MR}}}}}
    }}{{
      #if: {{{PMC|}}} |&amp;rft_id=info:pmc/{{urlencode:{{{PMC}}}}}
    }}{{
      #if: {{{PMID|}}} |&amp;rft_id=info:pmid/{{urlencode:{{{PMID}}}}}
    }}{{
      #if: {{{RFC|}}} |&amp;rft_id=info:rfc/{{urlencode:{{{RFC}}}}}
    }}{{
      #if: {{{SSRN|}}} |&amp;rft_id=info:ssrn/{{urlencode:{{{SSRN}}}}}
    }}{{
      #if: {{{ZBL|}}} |&amp;rft_id=info:zbl/{{urlencode:{{{ZBL}}}}}
    }}{{
      #if: {{{URL|}}}{{{IncludedWorkURL|}}} |&amp;rft_id={{urlencode:{{{URL|{{{IncludedWorkURL|}}}}}}}}
    }}&amp;rfr_id=info:sid/en.wikipedia.org:{{FULLPAGENAMEE}}&quot;&gt;&lt;span style=&quot;display: none;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;noinclude&gt;
{{Wp/nd/Documentation}}
&lt;/noinclude&gt;</text>
      <sha1>lljtlmvlwoi6tf7rxtyyu41h7rxfu9q</sha1>
    </revision>
    <revision>
      <id>1956</id>
      <parentid>1955</parentid>
      <timestamp>2016-11-09T15:31:30Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>CFCF moved page [[Template:Wp/nd/Citation/core]] to [[Template:Wp/nd/citation/core]]</comment>
      <origin>1955</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="26826" sha1="lljtlmvlwoi6tf7rxtyyu41h7rxfu9q" xml:space="preserve">&lt;span class=&quot;citation {{{Wp/nd/citation class|{{{Wp/nd/citation type|}}}}}}&quot;
{{
  #switch:{{{Ref|}}}
  ||none =
  |#default = id=&quot;{{anchorencode:{{{Ref}}}}}&quot;
  |harv = {{#if:{{{Surname1|}}}{{{EditorSurname1|}}}
    |id=&quot;CITEREF{{anchorencode:{{#if:{{{Surname1|}}}
      |{{{Surname1}}}{{{Surname2|}}}{{{Surname3|}}}{{{Surname4|}}}
      |{{{EditorSurname1|}}}{{{EditorSurname2|}}}{{{EditorSurname3|}}}{{{EditorSurname4|}}}
    }}{{{Year|{{{Date|}}}}}}}}&quot;
  }}
}}&gt;{{
&lt;!--============  Author or editor and date  ============--&gt;
  #if:{{{Surname1|}}}
  |{{
     #if: {{{AuthorMask|}}}
     |{{
        #iferror: {{ #expr: 1*{{{AuthorMask}}} }}
        |{{{AuthorMask}}}
        |{{loop|{{{AuthorMask}}}|2=&amp;mdash;}}
      }}
     |{{
        #if: {{{Authorlink1|}}}
        |[[{{{Authorlink1}}} |{{{Surname1}}}{{
          #if: {{{Given1|}}}
          |{{{NameSep|,&amp;#32;}}}{{{Given1}}}
         }}]]
        |{{{Surname1}}}{{
           #if: {{{Given1|}}}
           |{{{NameSep|,&amp;#32;}}}{{{Given1}}}
         }}
      }}
   }}{{
     #if: {{{Surname2|}}}
     |{{#ifexpr:{{{Trunc|8}}}&lt;2
       |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
       |{{
          #iferror: {{ #expr: 1*0.0{{{AuthorMask|}}} }}
          |&amp;#32;&lt;!-- then punctuation should be included in AuthorMask --&gt;
          |{{
            #if: {{{Surname3|}}}
            |{{{AuthorSep|&amp;#059;&amp;#32;}}}
            |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
          }}
        }}{{
          #if: {{{Authorlink2|}}}
          |[[{{{Authorlink2}}} |{{{Surname2}}}{{
             #if: {{{Given2|}}}
             |{{{NameSep|,&amp;#32;}}}{{{Given2}}}
           }}]]
          |{{{Surname2}}}{{
             #if: {{{Given2|}}}
             |{{{NameSep|,&amp;#32;}}}{{{Given2}}}
           }}
        }}{{
          #if: {{{Surname3|}}}
          |{{#ifexpr:{{{Trunc|8}}}&lt;3
            |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
            |{{
               #if: {{{Surname4|}}}
               |{{{AuthorSep|&amp;#059;&amp;#32;}}}
               |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
             }}{{
               #if: {{{Authorlink3|}}}
               |[[{{{Authorlink3}}} |{{{Surname3}}}{{
                  #if: {{{Given3|}}}
                  |{{{NameSep|,&amp;#32;}}}{{{Given3}}}
                }}]]
               |{{{Surname3}}}{{
                  #if: {{{Given3|}}}
                  |{{{NameSep|,&amp;#32;}}}{{{Given3}}}
                }}
             }}{{
               #if:{{{Surname4|}}}
               |{{#ifexpr:{{{Trunc|8}}}&lt;4
                 |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
                 |{{
                    #if: {{{Surname5|}}}
                    |{{{AuthorSep|&amp;#059;&amp;#32;}}}
                    |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
                  }}{{
                    #if: {{{Authorlink4|}}}
                    |[[{{{Authorlink4}}} |{{{Surname4}}}{{
                       #if: {{{Given4|}}}
                       |{{{NameSep|,&amp;#32;}}}{{{Given4}}}
                     }}]]
                    |{{{Surname4}}}{{
                       #if: {{{Given4|}}}
                       |{{{NameSep|,&amp;#32;}}}{{{Given4}}}
                    }}
                  }}{{
                  #if:{{{Surname5|}}}
                  |{{#ifexpr:{{{Trunc|8}}}&lt;5
                    |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
                    |{{
                     #if: {{{Surname6|}}}
                     |{{{AuthorSep|&amp;#059;&amp;#32;}}}
                     |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
                    }}{{
                     #if: {{{Authorlink5|}}}
                     |[[{{{Authorlink5}}} |{{{Surname5}}}{{
                        #if: {{{Given5|}}}
                        |{{{NameSep|,&amp;#32;}}}{{{Given5}}}
                      }}]]
                     |{{{Surname5}}}{{
                        #if: {{{Given5|}}}
                        |{{{NameSep|,&amp;#32;}}}{{{Given5}}}
                      }}
                   }}{{
                     #if:{{{Surname6|}}}
                     |{{#ifexpr:{{{Trunc|8}}}&lt;6
                     |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
                      |{{
                        #if: {{{Surname7|}}}
                        |{{{AuthorSep|&amp;#059;&amp;#32;}}}
                        |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
                      }}{{
                        #if: {{{Authorlink6|}}}
                        |[[{{{Authorlink6}}} |{{{Surname6}}}{{
                           #if: {{{Given6|}}}
                           |{{{NameSep|,&amp;#32;}}}{{{Given6}}}
                         }}]]
                        |{{{Surname6}}}{{
                           #if: {{{Given6|}}}
                           |{{{NameSep|,&amp;#32;}}}{{{Given6}}}
                         }}
                      }}{{
                        #if:{{{Surname7|}}}
                         |{{#ifexpr:{{{Trunc|8}}}&lt;7
                           |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
                        |{{
                           #if: {{{Surname8|}}}
                           |{{{AuthorSep|&amp;#059;&amp;#32;}}}
                           |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
                         }}{{
                           #if: {{{Authorlink7|}}}
                           |[[{{{Authorlink7}}} |{{{Surname7}}}{{
                              #if: {{{Given7|}}}
                              |{{{NameSep|,&amp;#32;}}}{{{Given7}}}
                            }}]]
                           |{{{Surname7}}}{{
                              #if: {{{Given7|}}}
                              |{{{NameSep|,&amp;#32;}}}{{{Given7}}}
                            }}
                                    }}{{
                                       #if:{{{Surname8|}}}
                                       |{{#ifexpr:{{{Trunc|8}}}&lt;8
                                           |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
                                           |{{
                                              #if: {{{Surname9|}}}
                                              |{{{AuthorSep|&amp;#059;&amp;#32;}}}
                                              |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
                                            }}{{
                                              #if: {{{Authorlink8|}}}
                                              |[[{{{Authorlink8}}} |{{{Surname8}}}{{
                                                 #if: {{{Given8|}}}
                                                 |{{{NameSep|,&amp;#32;}}}{{{Given8}}}
                                               }}]]
                                              |{{{Surname8}}}{{
                                                 #if: {{{Given8|}}}
                                                 |{{{NameSep|,&amp;#32;}}}{{{Given8}}}
                                               }}
                                            }}{{
                                              #if:{{{Surname9|}}}
                                              |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
                                            }}
                                         }}
                                      }}
                                   }}
                                }}
                             }}
                          }}
                       }}
                     }}
                  }}
               }}
            }}
         }}
      }}

   }}{{
     #if: {{{Coauthors|}}}
     |{{{AuthorSep|&amp;#059;&amp;#32;}}}{{{Coauthors|}}}|
   }}{{
     #if: {{{Date|}}}
     |&amp;#32;({{{Date}}}){{
       #if:{{{YearNote|}}}
     |&amp;#32;[{{{YearNote}}}]
     }}
   }}
  |{{&lt;!-- ============== No author: display editors first == --&gt;
     #if: {{{EditorSurname1|}}}
     |{{
        #if: {{{Editorlink1|}}}
        |[[{{{Editorlink1}}} |{{{EditorSurname1}}}{{
           #if: {{{EditorGiven1|}}}
           |, {{{EditorGiven1}}}
         }}]]
        |{{{EditorSurname1}}}{{
           #if: {{{EditorGiven1|}}}
           |, {{{EditorGiven1}}}
         }}
      }}{{
        #if: {{{EditorSurname2|}}}
        |{{
          #if: {{{EditorSurname3|}}}
          |{{{AuthorSep|&amp;#059;&amp;#32;}}}
          |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
        }}{{
           #if: {{{Editorlink2|}}}
           |[[{{{Editorlink2}}} |{{{EditorSurname2}}}{{
              #if: {{{EditorGiven2|}}}
              |, {{{EditorGiven2}}}
            }}]]
           |{{{EditorSurname2}}}{{
              #if: {{{EditorGiven2|}}}
              |, {{{EditorGiven2}}}
            }}
         }}{{
           #if: {{{EditorSurname3|}}}
           |{{
              #if: {{{EditorSurname4|}}}
              |{{{AuthorSep|&amp;#059;&amp;#32;}}}
              |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
            }}{{
              #if: {{{Editorlink3|}}}
              |[[{{{Editorlink3}}} |{{{EditorSurname3}}}{{
                 #if: {{{EditorGiven3|}}}
                 |, {{{EditorGiven3}}}
               }}]]
              |{{{EditorSurname3}}}{{
                 #if: {{{EditorGiven3|}}}
                 |, {{{EditorGiven3}}}
               }}
            }}{{
              #if:{{{EditorSurname4|}}}
              |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
            }}
         }}
       }}, ed{{#if:{{{EditorSurname2|}}}|s}}{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}{{
        #if: {{{Date|}}}
        |&amp;#32;({{{Date}}}){{
         #if:{{{YearNote|}}}
       |&amp;#32;[{{{YearNote}}}]
       }}
      }}
   }}
}}{{
&lt;!--============  Title of included work  ============--&gt;
  #if: {{{IncludedWorkTitle|}}}{{#if:{{{Periodical|}}}||{{#if:{{{TransItalic|}}}||{{{TransTitle|}}}}}}}
  |{{
     #if:{{{Surname1|}}}{{{EditorSurname1|}}}
     |{{{Sep|,}}}&amp;#32;
   }}{{Wp/nd/citation/make link
     | 1={{
           #if: {{{IncludedWorkURL|}}}
           |{{{IncludedWorkURL}}}
           |{{
              #if: {{{URL|}}}
              |{{{URL}}}
            }}
         }}
     | 2={{
           #if: {{{Periodical|}}}
           |''&lt;nowiki /&gt;{{{IncludedWorkTitle}}}&lt;nowiki /&gt;''
           |&quot;{{{IncludedWorkTitle|}}}{{
             #if: {{{TransTitle|}}}
             |{{
                #if: {{{IncludedWorkTitle|}}}
                |&amp;#32;
              }}&amp;#91;{{{TransTitle}}}&amp;#93;
           }}&quot;
         }}
   }}
}}{{
&lt;!--============  Place (if different than PublicationPlace) ============--&gt;
  #if: {{{Place|}}}
  |{{
     #ifeq: {{{Place|}}} | {{{PublicationPlace|}}}
     |
     |{{
        #if: {{{Surname1|}}}{{{EditorSurname1|}}}{{{IncludedWorkTitle|}}}
        |{{{Sep|,}}}&amp;#32;written at {{{Place}}}
      }}
   }}
}}{{
&lt;!--============  Editor of compilation  ============--&gt;
  #if: {{{EditorSurname1|}}}
  |{{
     #if: {{{Surname1|}}}
     |{{{Sep|,}}}&amp;#32;{{
        #if: {{{IncludedWorkTitle|}}}
        |{{#ifeq:{{{Sep|}}}|.|I|i}}n&amp;#32;
      }}{{
        #if: {{{Editorlink1|}}}
        |[[{{{Editorlink1}}} |{{{EditorSurname1}}}{{
           #if: {{{EditorGiven1|}}}
           |, {{{EditorGiven1}}}
         }}]]
        |{{{EditorSurname1}}}{{
           #if: {{{EditorGiven1|}}}
           |, {{{EditorGiven1}}}
         }}}}{{
        #if: {{{EditorSurname2|}}}
        |{{
          #if: {{{EditorSurname3|}}}
            |{{{AuthorSep|&amp;#059;&amp;#32;}}}
            |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
          }}{{
           #if: {{{Editorlink2|}}}
           |[[{{{Editorlink2}}}|{{{EditorSurname2}}}{{
              #if: {{{EditorGiven2|}}}
              |, {{{EditorGiven2}}}
            }}]]
           |{{{EditorSurname2}}}{{
              #if: {{{EditorGiven2|}}}
              |, {{{EditorGiven2}}}
            }}
         }}{{
           #if: {{{EditorSurname3|}}}
           |{{
              #if: {{{EditorSurname4|}}}
              |&amp;#059;&amp;#32;
              |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
            }}{{
              #if: {{{Editorlink3|}}}
              |[[{{{Editorlink3}}}|{{{EditorSurname3}}}{{
                 #if: {{{EditorGiven3|}}}
                 |, {{{EditorGiven3}}}
               }}]]
              |{{{EditorSurname3}}}{{
                 #if: {{{EditorGiven3|}}}
                 |, {{{EditorGiven3}}}
               }}
            }}{{
              #if:{{{EditorSurname4|}}}
              |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
            }}
         }}
      }}{{
        #if: {{{IncludedWorkTitle|}}}
        |
        |{{{Sep|,}}}&amp;#32;ed{{#if:{{{EditorSurname2|}}}|s}}{{#ifeq:{{{Sep}}}|.||.}}
      }}
   }}
}}{{
  &lt;!--============  Periodicals  ============--&gt;
  #if: {{{Periodical|}}}
  |{{
     #if: {{{Other|}}}
     |{{{Sep|,}}}&amp;#32;{{{Other|}}}
   }}{{
     #if: {{{Surname1|}}}{{{EditorSurname1|}}}{{{IncludedWorkTitle|}}}
     |{{{Sep|,}}}&amp;#32;}}{{
     #if: {{{Title|}}}{{{TransTitle|}}}
     |{{Wp/nd/citation/make link
        | 1={{
              #if: {{{IncludedWorkTitle|}}}
              |{{
                 #if: {{{IncludedWorkURL|}}}
                 |{{
                    #if: {{{URL|}}}
                    |{{{URL}}}
                  }}
               }}
              |{{
                 #if: {{{URL|}}}
                 |{{{URL}}}
               }}
            }}
        | 2=&quot;{{{Title}}}{{
          #if: {{{TransTitle|}}}
          |{{
             #if: {{{Title|}}}
             |&amp;#32;
           }}&amp;#91;{{{TransTitle}}}&amp;#93;
        }}&quot;
      }}{{
        #if: {{{TitleNote|}}}
        |{{{Sep|,}}}&amp;#32;{{{TitleNote}}}
      }}
   }}
}}{{
  #if: {{{language|}}}
  |&amp;#32;(in {{{language}}})
}}{{
  #if: {{{format|}}}
  |&amp;#32;({{{format}}})
}}{{
   #if: {{{Periodical|}}}
   |{{
      #if:{{{IncludedWorkTitle|}}}{{{Title|}}}{{{TransTitle|}}}
      |{{{Sep|,}}}&amp;#32;
    }}''&lt;nowiki /&gt;{{{Periodical}}}&lt;nowiki /&gt;''{{
      #if: {{{Series|}}}
      |{{{Sep|,}}}&amp;#32;{{{Series}}}
    }}{{
      #if: {{{PublicationPlace|}}}
      |{{
         #if: {{{Publisher|}}}
         |&amp;#32;({{{PublicationPlace}}}&lt;nowiki&gt;: &lt;/nowiki&gt;{{{Publisher}}})
         |&amp;#32;({{{PublicationPlace}}})
       }}
      |{{
         #if: {{{Publisher|}}}
         |&amp;#32;({{{Publisher}}})
       }}
    }}{{
      #if: {{{Volume|}}}
      |&amp;#32;{{#if:{{{Periodical|}}}|'''&lt;nowiki /&gt;{{{Volume}}}&lt;nowiki /&gt;'''|{{{Volume}}}}}{{
         #if: {{{Issue|}}}
         |&amp;#32;({{{Issue}}})
       }}
      |{{
         #if: {{{Issue|}}}
         |&amp;#32;({{{Issue}}})
       }}
    }}{{
      #if: {{{At|}}}
      |&lt;nowiki&gt;: &lt;/nowiki&gt; {{{At}}}
    }}
   |{{
      &lt;!--============ Anything else with a title, including books ============--&gt;
      #if: {{{Title|}}}{{{TransItalic|}}}
      |{{
         #if: {{{Surname1|}}}{{{EditorSurname1|}}}{{{IncludedWorkTitle|}}}{{{Periodical|}}}
         |{{{Sep|,}}}
       }}&amp;#32;{{Wp/nd/citation/make link
         | 1={{
               #if: {{{IncludedWorkTitle|}}}
               |{{
                  #if: {{{IncludedWorkURL|}}}
                  |{{
                     #if: {{{URL|}}}
                     |{{{URL}}}
                   }}
                }}
               |{{
                  #if: {{{URL|}}}
                  |{{{URL}}}
                }}
             }}
         | 2=''&lt;nowiki /&gt;{{{Title|}}}{{
            #if:{{{TransItalic|}}}|&amp;#32;&amp;#91;{{{TransItalic}}}&amp;#93;
          }}&lt;nowiki /&gt;''
       }}
    }}{{
      #if: {{{TitleType|}}}
      |&amp;#32;({{{TitleType}}})
    }}{{
      #if: {{{Series|}}}
      |{{{Sep|,}}}&amp;#32;{{{Series}}}
    }}{{
      #if: {{{Volume|}}}
      |{{{Sep|,}}}&amp;#32;'''&lt;nowiki /&gt;{{{Volume}}}&lt;nowiki /&gt;'''
    }}{{
      #if: {{{Other|}}}
      |{{{Sep|,}}}&amp;#32;{{{Other|}}}
    }}{{
      #if: {{{Edition|}}}
      |&amp;#32;({{{Edition}}} ed.)
    }}{{
      #if: {{{PublicationPlace|}}}
      |{{{Sep|,}}}&amp;#32;{{{PublicationPlace}}}
    }}{{
      #if: {{{Publisher|}}}
      |{{
         #if: {{{PublicationPlace|}}}
         |&lt;nowiki&gt;:&lt;/nowiki&gt;
         |{{{Sep|,}}}
       }}&amp;#32;{{{Publisher}}}
    }}
}}{{
&lt;!--============ Date (if no author/editor) ============--&gt;
  #if: {{{Surname1|}}}{{{EditorSurname1|}}}
  |
  |{{
     #if: {{{Date|}}}
     |{{{Sep|,}}}&amp;#32;{{{Date}}}{{
       #if:{{{YearNote|}}}
     |&amp;#32;[{{{YearNote}}}]
     }}
   }}
}}{{
&lt;!--============ Publication date ============--&gt;
  #if: {{{PublicationDate|}}}
  |{{
     #ifeq: {{{PublicationDate|}}} | {{{Date|}}}
     |
     |{{
        #if: {{{EditorSurname1|}}}
        |{{
           #if: {{{Surname1|}}}
           |{{{Sep|,}}}&amp;#32;{{{PublicationDate}}}
           |&amp;#32;(published {{{PublicationDate}}})
         }}
        |{{
           #if: {{{Periodical|}}}
           |{{{Sep|,}}}&amp;#32;{{{PublicationDate}}}
           |&amp;#32;(published {{{PublicationDate}}})
         }}
      }}
   }}
}}{{
&lt;!--============ Page within included work ============--&gt;
  #if: {{{Periodical|}}}
  |
  |{{
     #if: {{{At|}}}
     |{{{Sep|,}}}&amp;#32;{{{At}}}
   }}
}}{{
&lt;!--============ arXiv ==============--&gt;
  #if: {{{ARXIV|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=arxiv |input1={{{ARXIV|}}} }}
}}{{
&lt;!--============ ASIN ===============--&gt;
  #if: {{{ASIN|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=asin |input1={{{ASIN|}}} |input2={{{ASIN-TLD|}}} }}
}}{{
&lt;!--============ BIBCODE ============--&gt;
  #if: {{{BIBCODE|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=bibcode |input1={{{BIBCODE|}}} }}
}}{{
&lt;!--============ DOI ================--&gt;
#if:{{{DOI|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=doi |input1={{{DOI|}}}  |input2={{{DoiBroken|}}} |input3={{{template doc demo|}}}}}
}}{{
&lt;!--============ ISBN ===============--&gt;
  #if: {{{ISBN|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=isbn |input1={{{ISBN|}}} }}
}}{{
&lt;!--============ ISSN ===============--&gt;
  #if: {{{ISSN|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=issn |input1={{{ISSN|}}} }}
}}{{
&lt;!--============ JFM ================--&gt;
  #if: {{{JFM|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=jfm |input1={{{JFM|}}} }}
}}{{
&lt;!--============ JSTOR ==============--&gt;
  #if: {{{JSTOR|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=jstor |input1={{{JSTOR|}}} }}
}}{{
&lt;!--============ LCCN ===============--&gt;
  #if: {{{LCCN|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=lccn |input1={{{LCCN|}}} }}
}}{{
&lt;!--============ MR =================--&gt;
  #if: {{{MR|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=mr |input1={{{MR|}}} }}
}}{{
&lt;!--============ OCLC ===============--&gt;
  #if: {{{OCLC|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=oclc |input1={{{OCLC|}}} }}
}}{{
&lt;!--============ OL =================--&gt;
  #if: {{{OL|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=ol |input1={{{OL|}}} }}
}}{{
&lt;!--============ OSTI ===============--&gt;
  #if: {{{OSTI|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=osti |input1={{{OSTI|}}} }}
}}{{
&lt;!--============ PMC ================--&gt;
  #if: {{{PMC|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=pmc |input1={{{PMC|}}} }}
}}{{
&lt;!--============ PMID ===============--&gt;
  #if: {{{PMID|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=pmid |input1={{{PMID|}}} }}
}}{{
&lt;!--============ RFC ================--&gt;
  #if: {{{RFC|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=rfc|input1={{{RFC|}}} }}
}}{{
&lt;!--============ SSRN ================--&gt;
  #if: {{{SSRN|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=ssrn |input1={{{SSRN|}}} }}
}}{{
&lt;!--============ ZBL ================--&gt;
  #if: {{{ZBL|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=zbl |input1={{{ZBL|}}} }}
}}{{
&lt;!--============  Misc. Identifier ============--&gt;
  #if: {{{ID|}}}
  |{{{Sep|,}}}&amp;#32;{{{ID}}}
}}{{
&lt;!--============  Archive data, etc ===========--&gt;
#if: {{{Archive|}}}
|{{{Sep|,}}}&amp;#32;{{{Archive}}}[[Category:Pages using deprecated citation archive parameters]]
|{{
  #if:{{{ArchiveURL|}}}{{{ArchiveDate|}}}
  | {{{Sep|,}}}&amp;#32;{{#ifeq: {{{DeadURL|}}} | no
    | {{#if:{{{ArchiveURL|}}}
       |{{Wp/nd/citation/make link|{{{ArchiveURL|}}}|{{#ifeq:{{{Sep}}}|.|A|a}}rchived}}&amp;#32;from the original
       |{{#ifeq:{{{Sep}}}|.|A|a}}rchived
      }}
    | {{#ifeq:{{{Sep}}}|.|A|a}}rchived{{#if:{{{OriginalURL|}}}{{{IncludedWorkURL|}}}
       |{{#if:{{{ArchiveURL|}}}|&amp;#32;from {{Wp/nd/citation/make link|{{{OriginalURL|{{{IncludedWorkURL|}}}}}}|the original}}}}
      }}
    }}{{#if:{{{ArchiveDate|}}}|&amp;#32;on {{{ArchiveDate}}}}}{{
     #if:{{#if:{{{ArchiveURL|}}}||A}}{{#if:{{{OriginalURL|}}}{{{IncludedWorkURL|}}}||B}}{{#if:{{{ArchiveDate|}}}||C}}
     |. {{Wp/nd/citation error|nocat={{{template doc demo|}}}
       |If you specify &lt;code&gt;&amp;#124;{{#if:{{{ArchiveURL|}}}|archiveurl|archivedate}}&amp;#61;&lt;/code&gt;{{#ifeq:{{{DeadURL|}}}|no|{{#if:{{{OriginalURL|}}}{{{IncludedWorkURL|}}}||&amp;#32;and &lt;code&gt;&amp;#124;deadurl&amp;#61;no&lt;/code&gt;}}}}, you must {{#if:{{{OriginalURL|}}}{{{IncludedWorkURL|}}}| also specify &lt;code&gt;&amp;#124;{{#if:{{{ArchiveURL|}}}|archivedate|archiveurl}}&amp;#61;&lt;/code&gt;| {{#ifeq:{{{DeadURL|}}}|no|also|first}} specify &lt;code&gt;&amp;#124;url&amp;#61;&lt;/code&gt;}}}}
    }}
  }}
}}{{
&lt;!--============ URL and AccessDate ============--&gt;
  #if: {{{URL|}}}{{{IncludedWorkURL|}}}{{#ifeq:{{{DeadURL|}}}|no|{{{ArchiveURL|}}}|}}
  |{{
     #if: {{{Title|}}}{{{IncludedWorkTitle|}}}{{{TransTitle|}}}
     |&lt;span class=&quot;printonly&quot;&gt;{{{Sep|,}}}&amp;#32;{{
                                      #if: {{{IncludedWorkURL|}}}
                                      |{{{IncludedWorkURL}}}
                                      |{{{URL}}}
                                    }}&lt;/span&gt;
     |{{{Sep|,}}}&amp;#32;{{
              #if: {{{IncludedWorkURL|}}}
              |{{{IncludedWorkURL}}}
              |{{{URL}}}
            }}
   }}{{
     #if: {{{AccessDate|}}}
     | &lt;span class=&quot;reference-accessdate&quot;&gt;{{#ifeq:{{{Sep|}}}|,|,&amp;#32;r|.&amp;#32;R}}etrieved {{{AccessDate}}}&lt;/span&gt;
     }}
}}{{#if:{{{laysummary|}}}
  |{{{Sep|,}}}&amp;#32;[{{{laysummary}}} Lay summary]{{#if: {{{laysource|}}}|&amp;nbsp;&amp;ndash;&amp;nbsp;''&lt;nowiki /&gt;{{{laysource}}}&lt;nowiki /&gt;''}}
}}{{#if:{{{laydate|}}}
  | &amp;#32;({{{laydate}}})
}}{{#if:{{{quote|}}}
  |{{{Sep|,}}}&amp;#32;&quot;{{{quote}}}&quot;
}}{{{PS|}}}&lt;/span&gt;&lt;!--

=== This is a COinS tag (http://ocoins.info), which allows automated tools to parse the citation information: ===

--&gt;&lt;span
    class=&quot;Z3988&quot;
    title=&quot;ctx_ver=Z39.88-2004&amp;rft_val_fmt={{urlencode:info:ofi/fmt:kev:mtx:}}{{
      #if: {{{Periodical|}}}
      |journal&amp;rft.genre=article&amp;rft.atitle={{urlencode:{{{Title|}}}}}&amp;rft.jtitle={{urlencode:{{{Periodical|}}}}}
      |book{{
         #if: {{{IncludedWorkTitle|}}}
         |&amp;rft.genre=bookitem&amp;rft.btitle={{urlencode:{{{IncludedWorkTitle|}}}}}&amp;rft.atitle={{urlencode:{{{Title|}}}}}
         |&amp;rft.genre=book&amp;rft.btitle={{urlencode:{{{Title|}}}}}
       }}
    }}{{
     #if: {{{Surname1|}}} |&amp;rft.aulast={{urlencode:{{{Surname1}}}}}{{
       #if: {{{Given1|}}} |&amp;rft.aufirst={{urlencode:{{{Given1}}}}}
     }}
   }}{{
     #if: {{{Surname1|}}} |&amp;rft.au={{urlencode:{{{Surname1}}}}}{{
       #if: {{{Given1|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given1}}}}}
     }}
   }}{{
     #if: {{{Surname2|}}} |&amp;rft.au={{urlencode:{{{Surname2}}}}}{{
       #if: {{{Given2|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given2}}}}}
     }}
   }}{{
     #if: {{{Surname3|}}} |&amp;rft.au={{urlencode:{{{Surname3}}}}}{{
       #if: {{{Given3|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given3}}}}}
     }}
   }}{{
     #if: {{{Surname4|}}} |&amp;rft.au={{urlencode:{{{Surname4}}}}}{{
       #if: {{{Given4|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given4}}}}}
     }}
   }}{{
     #if: {{{Surname5|}}} |&amp;rft.au={{urlencode:{{{Surname5}}}}}{{
       #if: {{{Given5|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given5}}}}}
     }}
   }}{{
     #if: {{{Surname6|}}} |&amp;rft.au={{urlencode:{{{Surname6}}}}}{{
       #if: {{{Given6|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given6}}}}}
     }}
   }}{{
     #if: {{{Surname7|}}} |&amp;rft.au={{urlencode:{{{Surname7}}}}}{{
       #if: {{{Given7|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given7}}}}}
     }}
   }}{{
     #if: {{{Surname8|}}} |&amp;rft.au={{urlencode:{{{Surname8}}}}}{{
       #if: {{{Given8|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given8}}}}}
     }}
   }}{{
     #if: {{{Surname9|}}} |&amp;rft.au={{urlencode:{{{Surname9}}}}}{{
       #if: {{{Given9|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given9}}}}}
     }}
    }}{{
      #if: {{{Date|}}} |&amp;rft.date={{urlencode:{{{Date}}}}}
    }}{{
      #if: {{{Series|}}} |&amp;rft.series={{urlencode:{{{Series}}}}}
    }}{{
      #if: {{{Volume|}}} |&amp;rft.volume={{urlencode:{{{Volume}}}}}
    }}{{
      #if: {{{Issue|}}} |&amp;rft.issue={{urlencode:{{{Issue}}}}}
    }}{{
      #if: {{{At|}}} |&amp;rft.pages={{urlencode:{{{At}}}}}
    }}{{
      #if: {{{Edition|}}} |&amp;rft.edition={{urlencode:{{{Edition}}}}}
    }}{{
      #if: {{{PublicationPlace|}}}{{{Place|}}} |&amp;rft.place={{urlencode:{{{PublicationPlace|{{{Place}}}}}}}}
    }}{{
      #if: {{{Publisher|}}} |&amp;rft.pub={{urlencode:{{{Publisher}}}}}
    }}{{
      #if: {{{ARXIV|}}} |&amp;rft_id=info:arxiv/{{urlencode:{{{ARXIV}}}}}
    }}{{
      #if: {{{ASIN|}}} |&amp;rft_id=info:asin/{{urlencode:{{{ASIN}}}}}
    }}{{
      #if: {{{BIBCODE|}}} |&amp;rft_id=info:bibcode/{{urlencode:{{{BIBCODE}}}}}
    }}{{
      #if: {{{DOI|}}} |&amp;rft_id=info:doi/{{urlencode:{{{DOI}}}}}
    }}{{
      #if: {{{ISBN|}}} |&amp;rft.isbn={{urlencode:{{{ISBN}}}}}
    }}{{
      #if: {{{ISSN|}}} |&amp;rft.issn={{urlencode:{{{ISSN}}}}}
    }}{{
      #if: {{{JFM|}}} |&amp;rft.jfm={{urlencode:{{{JFM}}}}}
    }}{{
      #if: {{{JSTOR|}}} |&amp;rft.jstor={{urlencode:{{{JSTOR}}}}}
    }}{{
      #if: {{{LCCN|}}} |&amp;rft.lccn={{urlencode:{{{LCCN}}}}}
    }}{{
      #if: {{{OCLC|}}} |&amp;rft_id=info:oclcnum/{{urlencode:{{{OCLC}}}}}
    }}{{
      #if: {{{OL|}}} |&amp;rft_id=info:olnum/{{urlencode:{{{OL}}}}}
    }}{{
      #if: {{{OSTI|}}} |&amp;rft_id=info:osti/{{urlencode:{{{OSTI}}}}}
    }}{{
      #if: {{{MR|}}} |&amp;rft.mr={{urlencode:{{{MR}}}}}
    }}{{
      #if: {{{PMC|}}} |&amp;rft_id=info:pmc/{{urlencode:{{{PMC}}}}}
    }}{{
      #if: {{{PMID|}}} |&amp;rft_id=info:pmid/{{urlencode:{{{PMID}}}}}
    }}{{
      #if: {{{RFC|}}} |&amp;rft_id=info:rfc/{{urlencode:{{{RFC}}}}}
    }}{{
      #if: {{{SSRN|}}} |&amp;rft_id=info:ssrn/{{urlencode:{{{SSRN}}}}}
    }}{{
      #if: {{{ZBL|}}} |&amp;rft_id=info:zbl/{{urlencode:{{{ZBL}}}}}
    }}{{
      #if: {{{URL|}}}{{{IncludedWorkURL|}}} |&amp;rft_id={{urlencode:{{{URL|{{{IncludedWorkURL|}}}}}}}}
    }}&amp;rfr_id=info:sid/en.wikipedia.org:{{FULLPAGENAMEE}}&quot;&gt;&lt;span style=&quot;display: none;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;noinclude&gt;
{{Wp/nd/Documentation}}
&lt;/noinclude&gt;</text>
      <sha1>lljtlmvlwoi6tf7rxtyyu41h7rxfu9q</sha1>
    </revision>
    <revision>
      <id>1957</id>
      <parentid>1956</parentid>
      <timestamp>2022-04-27T09:33:58Z</timestamp>
      <contributor>
        <username>JhsBot</username>
        <id>34</id>
      </contributor>
      <minor />
      <comment>JhsBot moved page [[Template:Wp/nd/citation/core]] to [[Template:Wp/nd/Citation/core]] over redirect: bot: Moving pages with (what would be) lowercase titles to uppercase</comment>
      <origin>1955</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="26826" sha1="lljtlmvlwoi6tf7rxtyyu41h7rxfu9q" xml:space="preserve">&lt;span class=&quot;citation {{{Wp/nd/citation class|{{{Wp/nd/citation type|}}}}}}&quot;
{{
  #switch:{{{Ref|}}}
  ||none =
  |#default = id=&quot;{{anchorencode:{{{Ref}}}}}&quot;
  |harv = {{#if:{{{Surname1|}}}{{{EditorSurname1|}}}
    |id=&quot;CITEREF{{anchorencode:{{#if:{{{Surname1|}}}
      |{{{Surname1}}}{{{Surname2|}}}{{{Surname3|}}}{{{Surname4|}}}
      |{{{EditorSurname1|}}}{{{EditorSurname2|}}}{{{EditorSurname3|}}}{{{EditorSurname4|}}}
    }}{{{Year|{{{Date|}}}}}}}}&quot;
  }}
}}&gt;{{
&lt;!--============  Author or editor and date  ============--&gt;
  #if:{{{Surname1|}}}
  |{{
     #if: {{{AuthorMask|}}}
     |{{
        #iferror: {{ #expr: 1*{{{AuthorMask}}} }}
        |{{{AuthorMask}}}
        |{{loop|{{{AuthorMask}}}|2=&amp;mdash;}}
      }}
     |{{
        #if: {{{Authorlink1|}}}
        |[[{{{Authorlink1}}} |{{{Surname1}}}{{
          #if: {{{Given1|}}}
          |{{{NameSep|,&amp;#32;}}}{{{Given1}}}
         }}]]
        |{{{Surname1}}}{{
           #if: {{{Given1|}}}
           |{{{NameSep|,&amp;#32;}}}{{{Given1}}}
         }}
      }}
   }}{{
     #if: {{{Surname2|}}}
     |{{#ifexpr:{{{Trunc|8}}}&lt;2
       |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
       |{{
          #iferror: {{ #expr: 1*0.0{{{AuthorMask|}}} }}
          |&amp;#32;&lt;!-- then punctuation should be included in AuthorMask --&gt;
          |{{
            #if: {{{Surname3|}}}
            |{{{AuthorSep|&amp;#059;&amp;#32;}}}
            |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
          }}
        }}{{
          #if: {{{Authorlink2|}}}
          |[[{{{Authorlink2}}} |{{{Surname2}}}{{
             #if: {{{Given2|}}}
             |{{{NameSep|,&amp;#32;}}}{{{Given2}}}
           }}]]
          |{{{Surname2}}}{{
             #if: {{{Given2|}}}
             |{{{NameSep|,&amp;#32;}}}{{{Given2}}}
           }}
        }}{{
          #if: {{{Surname3|}}}
          |{{#ifexpr:{{{Trunc|8}}}&lt;3
            |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
            |{{
               #if: {{{Surname4|}}}
               |{{{AuthorSep|&amp;#059;&amp;#32;}}}
               |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
             }}{{
               #if: {{{Authorlink3|}}}
               |[[{{{Authorlink3}}} |{{{Surname3}}}{{
                  #if: {{{Given3|}}}
                  |{{{NameSep|,&amp;#32;}}}{{{Given3}}}
                }}]]
               |{{{Surname3}}}{{
                  #if: {{{Given3|}}}
                  |{{{NameSep|,&amp;#32;}}}{{{Given3}}}
                }}
             }}{{
               #if:{{{Surname4|}}}
               |{{#ifexpr:{{{Trunc|8}}}&lt;4
                 |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
                 |{{
                    #if: {{{Surname5|}}}
                    |{{{AuthorSep|&amp;#059;&amp;#32;}}}
                    |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
                  }}{{
                    #if: {{{Authorlink4|}}}
                    |[[{{{Authorlink4}}} |{{{Surname4}}}{{
                       #if: {{{Given4|}}}
                       |{{{NameSep|,&amp;#32;}}}{{{Given4}}}
                     }}]]
                    |{{{Surname4}}}{{
                       #if: {{{Given4|}}}
                       |{{{NameSep|,&amp;#32;}}}{{{Given4}}}
                    }}
                  }}{{
                  #if:{{{Surname5|}}}
                  |{{#ifexpr:{{{Trunc|8}}}&lt;5
                    |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
                    |{{
                     #if: {{{Surname6|}}}
                     |{{{AuthorSep|&amp;#059;&amp;#32;}}}
                     |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
                    }}{{
                     #if: {{{Authorlink5|}}}
                     |[[{{{Authorlink5}}} |{{{Surname5}}}{{
                        #if: {{{Given5|}}}
                        |{{{NameSep|,&amp;#32;}}}{{{Given5}}}
                      }}]]
                     |{{{Surname5}}}{{
                        #if: {{{Given5|}}}
                        |{{{NameSep|,&amp;#32;}}}{{{Given5}}}
                      }}
                   }}{{
                     #if:{{{Surname6|}}}
                     |{{#ifexpr:{{{Trunc|8}}}&lt;6
                     |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
                      |{{
                        #if: {{{Surname7|}}}
                        |{{{AuthorSep|&amp;#059;&amp;#32;}}}
                        |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
                      }}{{
                        #if: {{{Authorlink6|}}}
                        |[[{{{Authorlink6}}} |{{{Surname6}}}{{
                           #if: {{{Given6|}}}
                           |{{{NameSep|,&amp;#32;}}}{{{Given6}}}
                         }}]]
                        |{{{Surname6}}}{{
                           #if: {{{Given6|}}}
                           |{{{NameSep|,&amp;#32;}}}{{{Given6}}}
                         }}
                      }}{{
                        #if:{{{Surname7|}}}
                         |{{#ifexpr:{{{Trunc|8}}}&lt;7
                           |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
                        |{{
                           #if: {{{Surname8|}}}
                           |{{{AuthorSep|&amp;#059;&amp;#32;}}}
                           |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
                         }}{{
                           #if: {{{Authorlink7|}}}
                           |[[{{{Authorlink7}}} |{{{Surname7}}}{{
                              #if: {{{Given7|}}}
                              |{{{NameSep|,&amp;#32;}}}{{{Given7}}}
                            }}]]
                           |{{{Surname7}}}{{
                              #if: {{{Given7|}}}
                              |{{{NameSep|,&amp;#32;}}}{{{Given7}}}
                            }}
                                    }}{{
                                       #if:{{{Surname8|}}}
                                       |{{#ifexpr:{{{Trunc|8}}}&lt;8
                                           |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
                                           |{{
                                              #if: {{{Surname9|}}}
                                              |{{{AuthorSep|&amp;#059;&amp;#32;}}}
                                              |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
                                            }}{{
                                              #if: {{{Authorlink8|}}}
                                              |[[{{{Authorlink8}}} |{{{Surname8}}}{{
                                                 #if: {{{Given8|}}}
                                                 |{{{NameSep|,&amp;#32;}}}{{{Given8}}}
                                               }}]]
                                              |{{{Surname8}}}{{
                                                 #if: {{{Given8|}}}
                                                 |{{{NameSep|,&amp;#32;}}}{{{Given8}}}
                                               }}
                                            }}{{
                                              #if:{{{Surname9|}}}
                                              |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
                                            }}
                                         }}
                                      }}
                                   }}
                                }}
                             }}
                          }}
                       }}
                     }}
                  }}
               }}
            }}
         }}
      }}

   }}{{
     #if: {{{Coauthors|}}}
     |{{{AuthorSep|&amp;#059;&amp;#32;}}}{{{Coauthors|}}}|
   }}{{
     #if: {{{Date|}}}
     |&amp;#32;({{{Date}}}){{
       #if:{{{YearNote|}}}
     |&amp;#32;[{{{YearNote}}}]
     }}
   }}
  |{{&lt;!-- ============== No author: display editors first == --&gt;
     #if: {{{EditorSurname1|}}}
     |{{
        #if: {{{Editorlink1|}}}
        |[[{{{Editorlink1}}} |{{{EditorSurname1}}}{{
           #if: {{{EditorGiven1|}}}
           |, {{{EditorGiven1}}}
         }}]]
        |{{{EditorSurname1}}}{{
           #if: {{{EditorGiven1|}}}
           |, {{{EditorGiven1}}}
         }}
      }}{{
        #if: {{{EditorSurname2|}}}
        |{{
          #if: {{{EditorSurname3|}}}
          |{{{AuthorSep|&amp;#059;&amp;#32;}}}
          |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
        }}{{
           #if: {{{Editorlink2|}}}
           |[[{{{Editorlink2}}} |{{{EditorSurname2}}}{{
              #if: {{{EditorGiven2|}}}
              |, {{{EditorGiven2}}}
            }}]]
           |{{{EditorSurname2}}}{{
              #if: {{{EditorGiven2|}}}
              |, {{{EditorGiven2}}}
            }}
         }}{{
           #if: {{{EditorSurname3|}}}
           |{{
              #if: {{{EditorSurname4|}}}
              |{{{AuthorSep|&amp;#059;&amp;#32;}}}
              |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
            }}{{
              #if: {{{Editorlink3|}}}
              |[[{{{Editorlink3}}} |{{{EditorSurname3}}}{{
                 #if: {{{EditorGiven3|}}}
                 |, {{{EditorGiven3}}}
               }}]]
              |{{{EditorSurname3}}}{{
                 #if: {{{EditorGiven3|}}}
                 |, {{{EditorGiven3}}}
               }}
            }}{{
              #if:{{{EditorSurname4|}}}
              |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
            }}
         }}
       }}, ed{{#if:{{{EditorSurname2|}}}|s}}{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}{{
        #if: {{{Date|}}}
        |&amp;#32;({{{Date}}}){{
         #if:{{{YearNote|}}}
       |&amp;#32;[{{{YearNote}}}]
       }}
      }}
   }}
}}{{
&lt;!--============  Title of included work  ============--&gt;
  #if: {{{IncludedWorkTitle|}}}{{#if:{{{Periodical|}}}||{{#if:{{{TransItalic|}}}||{{{TransTitle|}}}}}}}
  |{{
     #if:{{{Surname1|}}}{{{EditorSurname1|}}}
     |{{{Sep|,}}}&amp;#32;
   }}{{Wp/nd/citation/make link
     | 1={{
           #if: {{{IncludedWorkURL|}}}
           |{{{IncludedWorkURL}}}
           |{{
              #if: {{{URL|}}}
              |{{{URL}}}
            }}
         }}
     | 2={{
           #if: {{{Periodical|}}}
           |''&lt;nowiki /&gt;{{{IncludedWorkTitle}}}&lt;nowiki /&gt;''
           |&quot;{{{IncludedWorkTitle|}}}{{
             #if: {{{TransTitle|}}}
             |{{
                #if: {{{IncludedWorkTitle|}}}
                |&amp;#32;
              }}&amp;#91;{{{TransTitle}}}&amp;#93;
           }}&quot;
         }}
   }}
}}{{
&lt;!--============  Place (if different than PublicationPlace) ============--&gt;
  #if: {{{Place|}}}
  |{{
     #ifeq: {{{Place|}}} | {{{PublicationPlace|}}}
     |
     |{{
        #if: {{{Surname1|}}}{{{EditorSurname1|}}}{{{IncludedWorkTitle|}}}
        |{{{Sep|,}}}&amp;#32;written at {{{Place}}}
      }}
   }}
}}{{
&lt;!--============  Editor of compilation  ============--&gt;
  #if: {{{EditorSurname1|}}}
  |{{
     #if: {{{Surname1|}}}
     |{{{Sep|,}}}&amp;#32;{{
        #if: {{{IncludedWorkTitle|}}}
        |{{#ifeq:{{{Sep|}}}|.|I|i}}n&amp;#32;
      }}{{
        #if: {{{Editorlink1|}}}
        |[[{{{Editorlink1}}} |{{{EditorSurname1}}}{{
           #if: {{{EditorGiven1|}}}
           |, {{{EditorGiven1}}}
         }}]]
        |{{{EditorSurname1}}}{{
           #if: {{{EditorGiven1|}}}
           |, {{{EditorGiven1}}}
         }}}}{{
        #if: {{{EditorSurname2|}}}
        |{{
          #if: {{{EditorSurname3|}}}
            |{{{AuthorSep|&amp;#059;&amp;#32;}}}
            |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
          }}{{
           #if: {{{Editorlink2|}}}
           |[[{{{Editorlink2}}}|{{{EditorSurname2}}}{{
              #if: {{{EditorGiven2|}}}
              |, {{{EditorGiven2}}}
            }}]]
           |{{{EditorSurname2}}}{{
              #if: {{{EditorGiven2|}}}
              |, {{{EditorGiven2}}}
            }}
         }}{{
           #if: {{{EditorSurname3|}}}
           |{{
              #if: {{{EditorSurname4|}}}
              |&amp;#059;&amp;#32;
              |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
            }}{{
              #if: {{{Editorlink3|}}}
              |[[{{{Editorlink3}}}|{{{EditorSurname3}}}{{
                 #if: {{{EditorGiven3|}}}
                 |, {{{EditorGiven3}}}
               }}]]
              |{{{EditorSurname3}}}{{
                 #if: {{{EditorGiven3|}}}
                 |, {{{EditorGiven3}}}
               }}
            }}{{
              #if:{{{EditorSurname4|}}}
              |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
            }}
         }}
      }}{{
        #if: {{{IncludedWorkTitle|}}}
        |
        |{{{Sep|,}}}&amp;#32;ed{{#if:{{{EditorSurname2|}}}|s}}{{#ifeq:{{{Sep}}}|.||.}}
      }}
   }}
}}{{
  &lt;!--============  Periodicals  ============--&gt;
  #if: {{{Periodical|}}}
  |{{
     #if: {{{Other|}}}
     |{{{Sep|,}}}&amp;#32;{{{Other|}}}
   }}{{
     #if: {{{Surname1|}}}{{{EditorSurname1|}}}{{{IncludedWorkTitle|}}}
     |{{{Sep|,}}}&amp;#32;}}{{
     #if: {{{Title|}}}{{{TransTitle|}}}
     |{{Wp/nd/citation/make link
        | 1={{
              #if: {{{IncludedWorkTitle|}}}
              |{{
                 #if: {{{IncludedWorkURL|}}}
                 |{{
                    #if: {{{URL|}}}
                    |{{{URL}}}
                  }}
               }}
              |{{
                 #if: {{{URL|}}}
                 |{{{URL}}}
               }}
            }}
        | 2=&quot;{{{Title}}}{{
          #if: {{{TransTitle|}}}
          |{{
             #if: {{{Title|}}}
             |&amp;#32;
           }}&amp;#91;{{{TransTitle}}}&amp;#93;
        }}&quot;
      }}{{
        #if: {{{TitleNote|}}}
        |{{{Sep|,}}}&amp;#32;{{{TitleNote}}}
      }}
   }}
}}{{
  #if: {{{language|}}}
  |&amp;#32;(in {{{language}}})
}}{{
  #if: {{{format|}}}
  |&amp;#32;({{{format}}})
}}{{
   #if: {{{Periodical|}}}
   |{{
      #if:{{{IncludedWorkTitle|}}}{{{Title|}}}{{{TransTitle|}}}
      |{{{Sep|,}}}&amp;#32;
    }}''&lt;nowiki /&gt;{{{Periodical}}}&lt;nowiki /&gt;''{{
      #if: {{{Series|}}}
      |{{{Sep|,}}}&amp;#32;{{{Series}}}
    }}{{
      #if: {{{PublicationPlace|}}}
      |{{
         #if: {{{Publisher|}}}
         |&amp;#32;({{{PublicationPlace}}}&lt;nowiki&gt;: &lt;/nowiki&gt;{{{Publisher}}})
         |&amp;#32;({{{PublicationPlace}}})
       }}
      |{{
         #if: {{{Publisher|}}}
         |&amp;#32;({{{Publisher}}})
       }}
    }}{{
      #if: {{{Volume|}}}
      |&amp;#32;{{#if:{{{Periodical|}}}|'''&lt;nowiki /&gt;{{{Volume}}}&lt;nowiki /&gt;'''|{{{Volume}}}}}{{
         #if: {{{Issue|}}}
         |&amp;#32;({{{Issue}}})
       }}
      |{{
         #if: {{{Issue|}}}
         |&amp;#32;({{{Issue}}})
       }}
    }}{{
      #if: {{{At|}}}
      |&lt;nowiki&gt;: &lt;/nowiki&gt; {{{At}}}
    }}
   |{{
      &lt;!--============ Anything else with a title, including books ============--&gt;
      #if: {{{Title|}}}{{{TransItalic|}}}
      |{{
         #if: {{{Surname1|}}}{{{EditorSurname1|}}}{{{IncludedWorkTitle|}}}{{{Periodical|}}}
         |{{{Sep|,}}}
       }}&amp;#32;{{Wp/nd/citation/make link
         | 1={{
               #if: {{{IncludedWorkTitle|}}}
               |{{
                  #if: {{{IncludedWorkURL|}}}
                  |{{
                     #if: {{{URL|}}}
                     |{{{URL}}}
                   }}
                }}
               |{{
                  #if: {{{URL|}}}
                  |{{{URL}}}
                }}
             }}
         | 2=''&lt;nowiki /&gt;{{{Title|}}}{{
            #if:{{{TransItalic|}}}|&amp;#32;&amp;#91;{{{TransItalic}}}&amp;#93;
          }}&lt;nowiki /&gt;''
       }}
    }}{{
      #if: {{{TitleType|}}}
      |&amp;#32;({{{TitleType}}})
    }}{{
      #if: {{{Series|}}}
      |{{{Sep|,}}}&amp;#32;{{{Series}}}
    }}{{
      #if: {{{Volume|}}}
      |{{{Sep|,}}}&amp;#32;'''&lt;nowiki /&gt;{{{Volume}}}&lt;nowiki /&gt;'''
    }}{{
      #if: {{{Other|}}}
      |{{{Sep|,}}}&amp;#32;{{{Other|}}}
    }}{{
      #if: {{{Edition|}}}
      |&amp;#32;({{{Edition}}} ed.)
    }}{{
      #if: {{{PublicationPlace|}}}
      |{{{Sep|,}}}&amp;#32;{{{PublicationPlace}}}
    }}{{
      #if: {{{Publisher|}}}
      |{{
         #if: {{{PublicationPlace|}}}
         |&lt;nowiki&gt;:&lt;/nowiki&gt;
         |{{{Sep|,}}}
       }}&amp;#32;{{{Publisher}}}
    }}
}}{{
&lt;!--============ Date (if no author/editor) ============--&gt;
  #if: {{{Surname1|}}}{{{EditorSurname1|}}}
  |
  |{{
     #if: {{{Date|}}}
     |{{{Sep|,}}}&amp;#32;{{{Date}}}{{
       #if:{{{YearNote|}}}
     |&amp;#32;[{{{YearNote}}}]
     }}
   }}
}}{{
&lt;!--============ Publication date ============--&gt;
  #if: {{{PublicationDate|}}}
  |{{
     #ifeq: {{{PublicationDate|}}} | {{{Date|}}}
     |
     |{{
        #if: {{{EditorSurname1|}}}
        |{{
           #if: {{{Surname1|}}}
           |{{{Sep|,}}}&amp;#32;{{{PublicationDate}}}
           |&amp;#32;(published {{{PublicationDate}}})
         }}
        |{{
           #if: {{{Periodical|}}}
           |{{{Sep|,}}}&amp;#32;{{{PublicationDate}}}
           |&amp;#32;(published {{{PublicationDate}}})
         }}
      }}
   }}
}}{{
&lt;!--============ Page within included work ============--&gt;
  #if: {{{Periodical|}}}
  |
  |{{
     #if: {{{At|}}}
     |{{{Sep|,}}}&amp;#32;{{{At}}}
   }}
}}{{
&lt;!--============ arXiv ==============--&gt;
  #if: {{{ARXIV|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=arxiv |input1={{{ARXIV|}}} }}
}}{{
&lt;!--============ ASIN ===============--&gt;
  #if: {{{ASIN|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=asin |input1={{{ASIN|}}} |input2={{{ASIN-TLD|}}} }}
}}{{
&lt;!--============ BIBCODE ============--&gt;
  #if: {{{BIBCODE|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=bibcode |input1={{{BIBCODE|}}} }}
}}{{
&lt;!--============ DOI ================--&gt;
#if:{{{DOI|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=doi |input1={{{DOI|}}}  |input2={{{DoiBroken|}}} |input3={{{template doc demo|}}}}}
}}{{
&lt;!--============ ISBN ===============--&gt;
  #if: {{{ISBN|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=isbn |input1={{{ISBN|}}} }}
}}{{
&lt;!--============ ISSN ===============--&gt;
  #if: {{{ISSN|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=issn |input1={{{ISSN|}}} }}
}}{{
&lt;!--============ JFM ================--&gt;
  #if: {{{JFM|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=jfm |input1={{{JFM|}}} }}
}}{{
&lt;!--============ JSTOR ==============--&gt;
  #if: {{{JSTOR|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=jstor |input1={{{JSTOR|}}} }}
}}{{
&lt;!--============ LCCN ===============--&gt;
  #if: {{{LCCN|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=lccn |input1={{{LCCN|}}} }}
}}{{
&lt;!--============ MR =================--&gt;
  #if: {{{MR|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=mr |input1={{{MR|}}} }}
}}{{
&lt;!--============ OCLC ===============--&gt;
  #if: {{{OCLC|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=oclc |input1={{{OCLC|}}} }}
}}{{
&lt;!--============ OL =================--&gt;
  #if: {{{OL|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=ol |input1={{{OL|}}} }}
}}{{
&lt;!--============ OSTI ===============--&gt;
  #if: {{{OSTI|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=osti |input1={{{OSTI|}}} }}
}}{{
&lt;!--============ PMC ================--&gt;
  #if: {{{PMC|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=pmc |input1={{{PMC|}}} }}
}}{{
&lt;!--============ PMID ===============--&gt;
  #if: {{{PMID|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=pmid |input1={{{PMID|}}} }}
}}{{
&lt;!--============ RFC ================--&gt;
  #if: {{{RFC|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=rfc|input1={{{RFC|}}} }}
}}{{
&lt;!--============ SSRN ================--&gt;
  #if: {{{SSRN|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=ssrn |input1={{{SSRN|}}} }}
}}{{
&lt;!--============ ZBL ================--&gt;
  #if: {{{ZBL|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=zbl |input1={{{ZBL|}}} }}
}}{{
&lt;!--============  Misc. Identifier ============--&gt;
  #if: {{{ID|}}}
  |{{{Sep|,}}}&amp;#32;{{{ID}}}
}}{{
&lt;!--============  Archive data, etc ===========--&gt;
#if: {{{Archive|}}}
|{{{Sep|,}}}&amp;#32;{{{Archive}}}[[Category:Pages using deprecated citation archive parameters]]
|{{
  #if:{{{ArchiveURL|}}}{{{ArchiveDate|}}}
  | {{{Sep|,}}}&amp;#32;{{#ifeq: {{{DeadURL|}}} | no
    | {{#if:{{{ArchiveURL|}}}
       |{{Wp/nd/citation/make link|{{{ArchiveURL|}}}|{{#ifeq:{{{Sep}}}|.|A|a}}rchived}}&amp;#32;from the original
       |{{#ifeq:{{{Sep}}}|.|A|a}}rchived
      }}
    | {{#ifeq:{{{Sep}}}|.|A|a}}rchived{{#if:{{{OriginalURL|}}}{{{IncludedWorkURL|}}}
       |{{#if:{{{ArchiveURL|}}}|&amp;#32;from {{Wp/nd/citation/make link|{{{OriginalURL|{{{IncludedWorkURL|}}}}}}|the original}}}}
      }}
    }}{{#if:{{{ArchiveDate|}}}|&amp;#32;on {{{ArchiveDate}}}}}{{
     #if:{{#if:{{{ArchiveURL|}}}||A}}{{#if:{{{OriginalURL|}}}{{{IncludedWorkURL|}}}||B}}{{#if:{{{ArchiveDate|}}}||C}}
     |. {{Wp/nd/citation error|nocat={{{template doc demo|}}}
       |If you specify &lt;code&gt;&amp;#124;{{#if:{{{ArchiveURL|}}}|archiveurl|archivedate}}&amp;#61;&lt;/code&gt;{{#ifeq:{{{DeadURL|}}}|no|{{#if:{{{OriginalURL|}}}{{{IncludedWorkURL|}}}||&amp;#32;and &lt;code&gt;&amp;#124;deadurl&amp;#61;no&lt;/code&gt;}}}}, you must {{#if:{{{OriginalURL|}}}{{{IncludedWorkURL|}}}| also specify &lt;code&gt;&amp;#124;{{#if:{{{ArchiveURL|}}}|archivedate|archiveurl}}&amp;#61;&lt;/code&gt;| {{#ifeq:{{{DeadURL|}}}|no|also|first}} specify &lt;code&gt;&amp;#124;url&amp;#61;&lt;/code&gt;}}}}
    }}
  }}
}}{{
&lt;!--============ URL and AccessDate ============--&gt;
  #if: {{{URL|}}}{{{IncludedWorkURL|}}}{{#ifeq:{{{DeadURL|}}}|no|{{{ArchiveURL|}}}|}}
  |{{
     #if: {{{Title|}}}{{{IncludedWorkTitle|}}}{{{TransTitle|}}}
     |&lt;span class=&quot;printonly&quot;&gt;{{{Sep|,}}}&amp;#32;{{
                                      #if: {{{IncludedWorkURL|}}}
                                      |{{{IncludedWorkURL}}}
                                      |{{{URL}}}
                                    }}&lt;/span&gt;
     |{{{Sep|,}}}&amp;#32;{{
              #if: {{{IncludedWorkURL|}}}
              |{{{IncludedWorkURL}}}
              |{{{URL}}}
            }}
   }}{{
     #if: {{{AccessDate|}}}
     | &lt;span class=&quot;reference-accessdate&quot;&gt;{{#ifeq:{{{Sep|}}}|,|,&amp;#32;r|.&amp;#32;R}}etrieved {{{AccessDate}}}&lt;/span&gt;
     }}
}}{{#if:{{{laysummary|}}}
  |{{{Sep|,}}}&amp;#32;[{{{laysummary}}} Lay summary]{{#if: {{{laysource|}}}|&amp;nbsp;&amp;ndash;&amp;nbsp;''&lt;nowiki /&gt;{{{laysource}}}&lt;nowiki /&gt;''}}
}}{{#if:{{{laydate|}}}
  | &amp;#32;({{{laydate}}})
}}{{#if:{{{quote|}}}
  |{{{Sep|,}}}&amp;#32;&quot;{{{quote}}}&quot;
}}{{{PS|}}}&lt;/span&gt;&lt;!--

=== This is a COinS tag (http://ocoins.info), which allows automated tools to parse the citation information: ===

--&gt;&lt;span
    class=&quot;Z3988&quot;
    title=&quot;ctx_ver=Z39.88-2004&amp;rft_val_fmt={{urlencode:info:ofi/fmt:kev:mtx:}}{{
      #if: {{{Periodical|}}}
      |journal&amp;rft.genre=article&amp;rft.atitle={{urlencode:{{{Title|}}}}}&amp;rft.jtitle={{urlencode:{{{Periodical|}}}}}
      |book{{
         #if: {{{IncludedWorkTitle|}}}
         |&amp;rft.genre=bookitem&amp;rft.btitle={{urlencode:{{{IncludedWorkTitle|}}}}}&amp;rft.atitle={{urlencode:{{{Title|}}}}}
         |&amp;rft.genre=book&amp;rft.btitle={{urlencode:{{{Title|}}}}}
       }}
    }}{{
     #if: {{{Surname1|}}} |&amp;rft.aulast={{urlencode:{{{Surname1}}}}}{{
       #if: {{{Given1|}}} |&amp;rft.aufirst={{urlencode:{{{Given1}}}}}
     }}
   }}{{
     #if: {{{Surname1|}}} |&amp;rft.au={{urlencode:{{{Surname1}}}}}{{
       #if: {{{Given1|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given1}}}}}
     }}
   }}{{
     #if: {{{Surname2|}}} |&amp;rft.au={{urlencode:{{{Surname2}}}}}{{
       #if: {{{Given2|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given2}}}}}
     }}
   }}{{
     #if: {{{Surname3|}}} |&amp;rft.au={{urlencode:{{{Surname3}}}}}{{
       #if: {{{Given3|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given3}}}}}
     }}
   }}{{
     #if: {{{Surname4|}}} |&amp;rft.au={{urlencode:{{{Surname4}}}}}{{
       #if: {{{Given4|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given4}}}}}
     }}
   }}{{
     #if: {{{Surname5|}}} |&amp;rft.au={{urlencode:{{{Surname5}}}}}{{
       #if: {{{Given5|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given5}}}}}
     }}
   }}{{
     #if: {{{Surname6|}}} |&amp;rft.au={{urlencode:{{{Surname6}}}}}{{
       #if: {{{Given6|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given6}}}}}
     }}
   }}{{
     #if: {{{Surname7|}}} |&amp;rft.au={{urlencode:{{{Surname7}}}}}{{
       #if: {{{Given7|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given7}}}}}
     }}
   }}{{
     #if: {{{Surname8|}}} |&amp;rft.au={{urlencode:{{{Surname8}}}}}{{
       #if: {{{Given8|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given8}}}}}
     }}
   }}{{
     #if: {{{Surname9|}}} |&amp;rft.au={{urlencode:{{{Surname9}}}}}{{
       #if: {{{Given9|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given9}}}}}
     }}
    }}{{
      #if: {{{Date|}}} |&amp;rft.date={{urlencode:{{{Date}}}}}
    }}{{
      #if: {{{Series|}}} |&amp;rft.series={{urlencode:{{{Series}}}}}
    }}{{
      #if: {{{Volume|}}} |&amp;rft.volume={{urlencode:{{{Volume}}}}}
    }}{{
      #if: {{{Issue|}}} |&amp;rft.issue={{urlencode:{{{Issue}}}}}
    }}{{
      #if: {{{At|}}} |&amp;rft.pages={{urlencode:{{{At}}}}}
    }}{{
      #if: {{{Edition|}}} |&amp;rft.edition={{urlencode:{{{Edition}}}}}
    }}{{
      #if: {{{PublicationPlace|}}}{{{Place|}}} |&amp;rft.place={{urlencode:{{{PublicationPlace|{{{Place}}}}}}}}
    }}{{
      #if: {{{Publisher|}}} |&amp;rft.pub={{urlencode:{{{Publisher}}}}}
    }}{{
      #if: {{{ARXIV|}}} |&amp;rft_id=info:arxiv/{{urlencode:{{{ARXIV}}}}}
    }}{{
      #if: {{{ASIN|}}} |&amp;rft_id=info:asin/{{urlencode:{{{ASIN}}}}}
    }}{{
      #if: {{{BIBCODE|}}} |&amp;rft_id=info:bibcode/{{urlencode:{{{BIBCODE}}}}}
    }}{{
      #if: {{{DOI|}}} |&amp;rft_id=info:doi/{{urlencode:{{{DOI}}}}}
    }}{{
      #if: {{{ISBN|}}} |&amp;rft.isbn={{urlencode:{{{ISBN}}}}}
    }}{{
      #if: {{{ISSN|}}} |&amp;rft.issn={{urlencode:{{{ISSN}}}}}
    }}{{
      #if: {{{JFM|}}} |&amp;rft.jfm={{urlencode:{{{JFM}}}}}
    }}{{
      #if: {{{JSTOR|}}} |&amp;rft.jstor={{urlencode:{{{JSTOR}}}}}
    }}{{
      #if: {{{LCCN|}}} |&amp;rft.lccn={{urlencode:{{{LCCN}}}}}
    }}{{
      #if: {{{OCLC|}}} |&amp;rft_id=info:oclcnum/{{urlencode:{{{OCLC}}}}}
    }}{{
      #if: {{{OL|}}} |&amp;rft_id=info:olnum/{{urlencode:{{{OL}}}}}
    }}{{
      #if: {{{OSTI|}}} |&amp;rft_id=info:osti/{{urlencode:{{{OSTI}}}}}
    }}{{
      #if: {{{MR|}}} |&amp;rft.mr={{urlencode:{{{MR}}}}}
    }}{{
      #if: {{{PMC|}}} |&amp;rft_id=info:pmc/{{urlencode:{{{PMC}}}}}
    }}{{
      #if: {{{PMID|}}} |&amp;rft_id=info:pmid/{{urlencode:{{{PMID}}}}}
    }}{{
      #if: {{{RFC|}}} |&amp;rft_id=info:rfc/{{urlencode:{{{RFC}}}}}
    }}{{
      #if: {{{SSRN|}}} |&amp;rft_id=info:ssrn/{{urlencode:{{{SSRN}}}}}
    }}{{
      #if: {{{ZBL|}}} |&amp;rft_id=info:zbl/{{urlencode:{{{ZBL}}}}}
    }}{{
      #if: {{{URL|}}}{{{IncludedWorkURL|}}} |&amp;rft_id={{urlencode:{{{URL|{{{IncludedWorkURL|}}}}}}}}
    }}&amp;rfr_id=info:sid/en.wikipedia.org:{{FULLPAGENAMEE}}&quot;&gt;&lt;span style=&quot;display: none;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;noinclude&gt;
{{Wp/nd/Documentation}}
&lt;/noinclude&gt;</text>
      <sha1>lljtlmvlwoi6tf7rxtyyu41h7rxfu9q</sha1>
    </revision>
    <revision>
      <id>1958</id>
      <parentid>1957</parentid>
      <timestamp>2024-11-18T17:41:41Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <minor />
      <comment>5 revisions imported from [[:incubator:Template:Wp/nd/Citation/core]]</comment>
      <origin>1955</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="26826" sha1="lljtlmvlwoi6tf7rxtyyu41h7rxfu9q" xml:space="preserve">&lt;span class=&quot;citation {{{Wp/nd/citation class|{{{Wp/nd/citation type|}}}}}}&quot;
{{
  #switch:{{{Ref|}}}
  ||none =
  |#default = id=&quot;{{anchorencode:{{{Ref}}}}}&quot;
  |harv = {{#if:{{{Surname1|}}}{{{EditorSurname1|}}}
    |id=&quot;CITEREF{{anchorencode:{{#if:{{{Surname1|}}}
      |{{{Surname1}}}{{{Surname2|}}}{{{Surname3|}}}{{{Surname4|}}}
      |{{{EditorSurname1|}}}{{{EditorSurname2|}}}{{{EditorSurname3|}}}{{{EditorSurname4|}}}
    }}{{{Year|{{{Date|}}}}}}}}&quot;
  }}
}}&gt;{{
&lt;!--============  Author or editor and date  ============--&gt;
  #if:{{{Surname1|}}}
  |{{
     #if: {{{AuthorMask|}}}
     |{{
        #iferror: {{ #expr: 1*{{{AuthorMask}}} }}
        |{{{AuthorMask}}}
        |{{loop|{{{AuthorMask}}}|2=&amp;mdash;}}
      }}
     |{{
        #if: {{{Authorlink1|}}}
        |[[{{{Authorlink1}}} |{{{Surname1}}}{{
          #if: {{{Given1|}}}
          |{{{NameSep|,&amp;#32;}}}{{{Given1}}}
         }}]]
        |{{{Surname1}}}{{
           #if: {{{Given1|}}}
           |{{{NameSep|,&amp;#32;}}}{{{Given1}}}
         }}
      }}
   }}{{
     #if: {{{Surname2|}}}
     |{{#ifexpr:{{{Trunc|8}}}&lt;2
       |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
       |{{
          #iferror: {{ #expr: 1*0.0{{{AuthorMask|}}} }}
          |&amp;#32;&lt;!-- then punctuation should be included in AuthorMask --&gt;
          |{{
            #if: {{{Surname3|}}}
            |{{{AuthorSep|&amp;#059;&amp;#32;}}}
            |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
          }}
        }}{{
          #if: {{{Authorlink2|}}}
          |[[{{{Authorlink2}}} |{{{Surname2}}}{{
             #if: {{{Given2|}}}
             |{{{NameSep|,&amp;#32;}}}{{{Given2}}}
           }}]]
          |{{{Surname2}}}{{
             #if: {{{Given2|}}}
             |{{{NameSep|,&amp;#32;}}}{{{Given2}}}
           }}
        }}{{
          #if: {{{Surname3|}}}
          |{{#ifexpr:{{{Trunc|8}}}&lt;3
            |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
            |{{
               #if: {{{Surname4|}}}
               |{{{AuthorSep|&amp;#059;&amp;#32;}}}
               |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
             }}{{
               #if: {{{Authorlink3|}}}
               |[[{{{Authorlink3}}} |{{{Surname3}}}{{
                  #if: {{{Given3|}}}
                  |{{{NameSep|,&amp;#32;}}}{{{Given3}}}
                }}]]
               |{{{Surname3}}}{{
                  #if: {{{Given3|}}}
                  |{{{NameSep|,&amp;#32;}}}{{{Given3}}}
                }}
             }}{{
               #if:{{{Surname4|}}}
               |{{#ifexpr:{{{Trunc|8}}}&lt;4
                 |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
                 |{{
                    #if: {{{Surname5|}}}
                    |{{{AuthorSep|&amp;#059;&amp;#32;}}}
                    |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
                  }}{{
                    #if: {{{Authorlink4|}}}
                    |[[{{{Authorlink4}}} |{{{Surname4}}}{{
                       #if: {{{Given4|}}}
                       |{{{NameSep|,&amp;#32;}}}{{{Given4}}}
                     }}]]
                    |{{{Surname4}}}{{
                       #if: {{{Given4|}}}
                       |{{{NameSep|,&amp;#32;}}}{{{Given4}}}
                    }}
                  }}{{
                  #if:{{{Surname5|}}}
                  |{{#ifexpr:{{{Trunc|8}}}&lt;5
                    |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
                    |{{
                     #if: {{{Surname6|}}}
                     |{{{AuthorSep|&amp;#059;&amp;#32;}}}
                     |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
                    }}{{
                     #if: {{{Authorlink5|}}}
                     |[[{{{Authorlink5}}} |{{{Surname5}}}{{
                        #if: {{{Given5|}}}
                        |{{{NameSep|,&amp;#32;}}}{{{Given5}}}
                      }}]]
                     |{{{Surname5}}}{{
                        #if: {{{Given5|}}}
                        |{{{NameSep|,&amp;#32;}}}{{{Given5}}}
                      }}
                   }}{{
                     #if:{{{Surname6|}}}
                     |{{#ifexpr:{{{Trunc|8}}}&lt;6
                     |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
                      |{{
                        #if: {{{Surname7|}}}
                        |{{{AuthorSep|&amp;#059;&amp;#32;}}}
                        |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
                      }}{{
                        #if: {{{Authorlink6|}}}
                        |[[{{{Authorlink6}}} |{{{Surname6}}}{{
                           #if: {{{Given6|}}}
                           |{{{NameSep|,&amp;#32;}}}{{{Given6}}}
                         }}]]
                        |{{{Surname6}}}{{
                           #if: {{{Given6|}}}
                           |{{{NameSep|,&amp;#32;}}}{{{Given6}}}
                         }}
                      }}{{
                        #if:{{{Surname7|}}}
                         |{{#ifexpr:{{{Trunc|8}}}&lt;7
                           |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
                        |{{
                           #if: {{{Surname8|}}}
                           |{{{AuthorSep|&amp;#059;&amp;#32;}}}
                           |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
                         }}{{
                           #if: {{{Authorlink7|}}}
                           |[[{{{Authorlink7}}} |{{{Surname7}}}{{
                              #if: {{{Given7|}}}
                              |{{{NameSep|,&amp;#32;}}}{{{Given7}}}
                            }}]]
                           |{{{Surname7}}}{{
                              #if: {{{Given7|}}}
                              |{{{NameSep|,&amp;#32;}}}{{{Given7}}}
                            }}
                                    }}{{
                                       #if:{{{Surname8|}}}
                                       |{{#ifexpr:{{{Trunc|8}}}&lt;8
                                           |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
                                           |{{
                                              #if: {{{Surname9|}}}
                                              |{{{AuthorSep|&amp;#059;&amp;#32;}}}
                                              |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
                                            }}{{
                                              #if: {{{Authorlink8|}}}
                                              |[[{{{Authorlink8}}} |{{{Surname8}}}{{
                                                 #if: {{{Given8|}}}
                                                 |{{{NameSep|,&amp;#32;}}}{{{Given8}}}
                                               }}]]
                                              |{{{Surname8}}}{{
                                                 #if: {{{Given8|}}}
                                                 |{{{NameSep|,&amp;#32;}}}{{{Given8}}}
                                               }}
                                            }}{{
                                              #if:{{{Surname9|}}}
                                              |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
                                            }}
                                         }}
                                      }}
                                   }}
                                }}
                             }}
                          }}
                       }}
                     }}
                  }}
               }}
            }}
         }}
      }}

   }}{{
     #if: {{{Coauthors|}}}
     |{{{AuthorSep|&amp;#059;&amp;#32;}}}{{{Coauthors|}}}|
   }}{{
     #if: {{{Date|}}}
     |&amp;#32;({{{Date}}}){{
       #if:{{{YearNote|}}}
     |&amp;#32;[{{{YearNote}}}]
     }}
   }}
  |{{&lt;!-- ============== No author: display editors first == --&gt;
     #if: {{{EditorSurname1|}}}
     |{{
        #if: {{{Editorlink1|}}}
        |[[{{{Editorlink1}}} |{{{EditorSurname1}}}{{
           #if: {{{EditorGiven1|}}}
           |, {{{EditorGiven1}}}
         }}]]
        |{{{EditorSurname1}}}{{
           #if: {{{EditorGiven1|}}}
           |, {{{EditorGiven1}}}
         }}
      }}{{
        #if: {{{EditorSurname2|}}}
        |{{
          #if: {{{EditorSurname3|}}}
          |{{{AuthorSep|&amp;#059;&amp;#32;}}}
          |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
        }}{{
           #if: {{{Editorlink2|}}}
           |[[{{{Editorlink2}}} |{{{EditorSurname2}}}{{
              #if: {{{EditorGiven2|}}}
              |, {{{EditorGiven2}}}
            }}]]
           |{{{EditorSurname2}}}{{
              #if: {{{EditorGiven2|}}}
              |, {{{EditorGiven2}}}
            }}
         }}{{
           #if: {{{EditorSurname3|}}}
           |{{
              #if: {{{EditorSurname4|}}}
              |{{{AuthorSep|&amp;#059;&amp;#32;}}}
              |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
            }}{{
              #if: {{{Editorlink3|}}}
              |[[{{{Editorlink3}}} |{{{EditorSurname3}}}{{
                 #if: {{{EditorGiven3|}}}
                 |, {{{EditorGiven3}}}
               }}]]
              |{{{EditorSurname3}}}{{
                 #if: {{{EditorGiven3|}}}
                 |, {{{EditorGiven3}}}
               }}
            }}{{
              #if:{{{EditorSurname4|}}}
              |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
            }}
         }}
       }}, ed{{#if:{{{EditorSurname2|}}}|s}}{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}{{
        #if: {{{Date|}}}
        |&amp;#32;({{{Date}}}){{
         #if:{{{YearNote|}}}
       |&amp;#32;[{{{YearNote}}}]
       }}
      }}
   }}
}}{{
&lt;!--============  Title of included work  ============--&gt;
  #if: {{{IncludedWorkTitle|}}}{{#if:{{{Periodical|}}}||{{#if:{{{TransItalic|}}}||{{{TransTitle|}}}}}}}
  |{{
     #if:{{{Surname1|}}}{{{EditorSurname1|}}}
     |{{{Sep|,}}}&amp;#32;
   }}{{Wp/nd/citation/make link
     | 1={{
           #if: {{{IncludedWorkURL|}}}
           |{{{IncludedWorkURL}}}
           |{{
              #if: {{{URL|}}}
              |{{{URL}}}
            }}
         }}
     | 2={{
           #if: {{{Periodical|}}}
           |''&lt;nowiki /&gt;{{{IncludedWorkTitle}}}&lt;nowiki /&gt;''
           |&quot;{{{IncludedWorkTitle|}}}{{
             #if: {{{TransTitle|}}}
             |{{
                #if: {{{IncludedWorkTitle|}}}
                |&amp;#32;
              }}&amp;#91;{{{TransTitle}}}&amp;#93;
           }}&quot;
         }}
   }}
}}{{
&lt;!--============  Place (if different than PublicationPlace) ============--&gt;
  #if: {{{Place|}}}
  |{{
     #ifeq: {{{Place|}}} | {{{PublicationPlace|}}}
     |
     |{{
        #if: {{{Surname1|}}}{{{EditorSurname1|}}}{{{IncludedWorkTitle|}}}
        |{{{Sep|,}}}&amp;#32;written at {{{Place}}}
      }}
   }}
}}{{
&lt;!--============  Editor of compilation  ============--&gt;
  #if: {{{EditorSurname1|}}}
  |{{
     #if: {{{Surname1|}}}
     |{{{Sep|,}}}&amp;#32;{{
        #if: {{{IncludedWorkTitle|}}}
        |{{#ifeq:{{{Sep|}}}|.|I|i}}n&amp;#32;
      }}{{
        #if: {{{Editorlink1|}}}
        |[[{{{Editorlink1}}} |{{{EditorSurname1}}}{{
           #if: {{{EditorGiven1|}}}
           |, {{{EditorGiven1}}}
         }}]]
        |{{{EditorSurname1}}}{{
           #if: {{{EditorGiven1|}}}
           |, {{{EditorGiven1}}}
         }}}}{{
        #if: {{{EditorSurname2|}}}
        |{{
          #if: {{{EditorSurname3|}}}
            |{{{AuthorSep|&amp;#059;&amp;#32;}}}
            |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
          }}{{
           #if: {{{Editorlink2|}}}
           |[[{{{Editorlink2}}}|{{{EditorSurname2}}}{{
              #if: {{{EditorGiven2|}}}
              |, {{{EditorGiven2}}}
            }}]]
           |{{{EditorSurname2}}}{{
              #if: {{{EditorGiven2|}}}
              |, {{{EditorGiven2}}}
            }}
         }}{{
           #if: {{{EditorSurname3|}}}
           |{{
              #if: {{{EditorSurname4|}}}
              |&amp;#059;&amp;#32;
              |{{#if:{{{amp|}}}|&amp;#32;&amp;amp;&amp;#32;|{{{AuthorSep|&amp;#059;&amp;#32;}}}}}
            }}{{
              #if: {{{Editorlink3|}}}
              |[[{{{Editorlink3}}}|{{{EditorSurname3}}}{{
                 #if: {{{EditorGiven3|}}}
                 |, {{{EditorGiven3}}}
               }}]]
              |{{{EditorSurname3}}}{{
                 #if: {{{EditorGiven3|}}}
                 |, {{{EditorGiven3}}}
               }}
            }}{{
              #if:{{{EditorSurname4|}}}
              |&amp;#32;et al{{#ifeq:{{{Sep}}}|.|{{#if:{{{Date|}}}|.}}|.}}
            }}
         }}
      }}{{
        #if: {{{IncludedWorkTitle|}}}
        |
        |{{{Sep|,}}}&amp;#32;ed{{#if:{{{EditorSurname2|}}}|s}}{{#ifeq:{{{Sep}}}|.||.}}
      }}
   }}
}}{{
  &lt;!--============  Periodicals  ============--&gt;
  #if: {{{Periodical|}}}
  |{{
     #if: {{{Other|}}}
     |{{{Sep|,}}}&amp;#32;{{{Other|}}}
   }}{{
     #if: {{{Surname1|}}}{{{EditorSurname1|}}}{{{IncludedWorkTitle|}}}
     |{{{Sep|,}}}&amp;#32;}}{{
     #if: {{{Title|}}}{{{TransTitle|}}}
     |{{Wp/nd/citation/make link
        | 1={{
              #if: {{{IncludedWorkTitle|}}}
              |{{
                 #if: {{{IncludedWorkURL|}}}
                 |{{
                    #if: {{{URL|}}}
                    |{{{URL}}}
                  }}
               }}
              |{{
                 #if: {{{URL|}}}
                 |{{{URL}}}
               }}
            }}
        | 2=&quot;{{{Title}}}{{
          #if: {{{TransTitle|}}}
          |{{
             #if: {{{Title|}}}
             |&amp;#32;
           }}&amp;#91;{{{TransTitle}}}&amp;#93;
        }}&quot;
      }}{{
        #if: {{{TitleNote|}}}
        |{{{Sep|,}}}&amp;#32;{{{TitleNote}}}
      }}
   }}
}}{{
  #if: {{{language|}}}
  |&amp;#32;(in {{{language}}})
}}{{
  #if: {{{format|}}}
  |&amp;#32;({{{format}}})
}}{{
   #if: {{{Periodical|}}}
   |{{
      #if:{{{IncludedWorkTitle|}}}{{{Title|}}}{{{TransTitle|}}}
      |{{{Sep|,}}}&amp;#32;
    }}''&lt;nowiki /&gt;{{{Periodical}}}&lt;nowiki /&gt;''{{
      #if: {{{Series|}}}
      |{{{Sep|,}}}&amp;#32;{{{Series}}}
    }}{{
      #if: {{{PublicationPlace|}}}
      |{{
         #if: {{{Publisher|}}}
         |&amp;#32;({{{PublicationPlace}}}&lt;nowiki&gt;: &lt;/nowiki&gt;{{{Publisher}}})
         |&amp;#32;({{{PublicationPlace}}})
       }}
      |{{
         #if: {{{Publisher|}}}
         |&amp;#32;({{{Publisher}}})
       }}
    }}{{
      #if: {{{Volume|}}}
      |&amp;#32;{{#if:{{{Periodical|}}}|'''&lt;nowiki /&gt;{{{Volume}}}&lt;nowiki /&gt;'''|{{{Volume}}}}}{{
         #if: {{{Issue|}}}
         |&amp;#32;({{{Issue}}})
       }}
      |{{
         #if: {{{Issue|}}}
         |&amp;#32;({{{Issue}}})
       }}
    }}{{
      #if: {{{At|}}}
      |&lt;nowiki&gt;: &lt;/nowiki&gt; {{{At}}}
    }}
   |{{
      &lt;!--============ Anything else with a title, including books ============--&gt;
      #if: {{{Title|}}}{{{TransItalic|}}}
      |{{
         #if: {{{Surname1|}}}{{{EditorSurname1|}}}{{{IncludedWorkTitle|}}}{{{Periodical|}}}
         |{{{Sep|,}}}
       }}&amp;#32;{{Wp/nd/citation/make link
         | 1={{
               #if: {{{IncludedWorkTitle|}}}
               |{{
                  #if: {{{IncludedWorkURL|}}}
                  |{{
                     #if: {{{URL|}}}
                     |{{{URL}}}
                   }}
                }}
               |{{
                  #if: {{{URL|}}}
                  |{{{URL}}}
                }}
             }}
         | 2=''&lt;nowiki /&gt;{{{Title|}}}{{
            #if:{{{TransItalic|}}}|&amp;#32;&amp;#91;{{{TransItalic}}}&amp;#93;
          }}&lt;nowiki /&gt;''
       }}
    }}{{
      #if: {{{TitleType|}}}
      |&amp;#32;({{{TitleType}}})
    }}{{
      #if: {{{Series|}}}
      |{{{Sep|,}}}&amp;#32;{{{Series}}}
    }}{{
      #if: {{{Volume|}}}
      |{{{Sep|,}}}&amp;#32;'''&lt;nowiki /&gt;{{{Volume}}}&lt;nowiki /&gt;'''
    }}{{
      #if: {{{Other|}}}
      |{{{Sep|,}}}&amp;#32;{{{Other|}}}
    }}{{
      #if: {{{Edition|}}}
      |&amp;#32;({{{Edition}}} ed.)
    }}{{
      #if: {{{PublicationPlace|}}}
      |{{{Sep|,}}}&amp;#32;{{{PublicationPlace}}}
    }}{{
      #if: {{{Publisher|}}}
      |{{
         #if: {{{PublicationPlace|}}}
         |&lt;nowiki&gt;:&lt;/nowiki&gt;
         |{{{Sep|,}}}
       }}&amp;#32;{{{Publisher}}}
    }}
}}{{
&lt;!--============ Date (if no author/editor) ============--&gt;
  #if: {{{Surname1|}}}{{{EditorSurname1|}}}
  |
  |{{
     #if: {{{Date|}}}
     |{{{Sep|,}}}&amp;#32;{{{Date}}}{{
       #if:{{{YearNote|}}}
     |&amp;#32;[{{{YearNote}}}]
     }}
   }}
}}{{
&lt;!--============ Publication date ============--&gt;
  #if: {{{PublicationDate|}}}
  |{{
     #ifeq: {{{PublicationDate|}}} | {{{Date|}}}
     |
     |{{
        #if: {{{EditorSurname1|}}}
        |{{
           #if: {{{Surname1|}}}
           |{{{Sep|,}}}&amp;#32;{{{PublicationDate}}}
           |&amp;#32;(published {{{PublicationDate}}})
         }}
        |{{
           #if: {{{Periodical|}}}
           |{{{Sep|,}}}&amp;#32;{{{PublicationDate}}}
           |&amp;#32;(published {{{PublicationDate}}})
         }}
      }}
   }}
}}{{
&lt;!--============ Page within included work ============--&gt;
  #if: {{{Periodical|}}}
  |
  |{{
     #if: {{{At|}}}
     |{{{Sep|,}}}&amp;#32;{{{At}}}
   }}
}}{{
&lt;!--============ arXiv ==============--&gt;
  #if: {{{ARXIV|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=arxiv |input1={{{ARXIV|}}} }}
}}{{
&lt;!--============ ASIN ===============--&gt;
  #if: {{{ASIN|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=asin |input1={{{ASIN|}}} |input2={{{ASIN-TLD|}}} }}
}}{{
&lt;!--============ BIBCODE ============--&gt;
  #if: {{{BIBCODE|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=bibcode |input1={{{BIBCODE|}}} }}
}}{{
&lt;!--============ DOI ================--&gt;
#if:{{{DOI|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=doi |input1={{{DOI|}}}  |input2={{{DoiBroken|}}} |input3={{{template doc demo|}}}}}
}}{{
&lt;!--============ ISBN ===============--&gt;
  #if: {{{ISBN|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=isbn |input1={{{ISBN|}}} }}
}}{{
&lt;!--============ ISSN ===============--&gt;
  #if: {{{ISSN|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=issn |input1={{{ISSN|}}} }}
}}{{
&lt;!--============ JFM ================--&gt;
  #if: {{{JFM|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=jfm |input1={{{JFM|}}} }}
}}{{
&lt;!--============ JSTOR ==============--&gt;
  #if: {{{JSTOR|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=jstor |input1={{{JSTOR|}}} }}
}}{{
&lt;!--============ LCCN ===============--&gt;
  #if: {{{LCCN|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=lccn |input1={{{LCCN|}}} }}
}}{{
&lt;!--============ MR =================--&gt;
  #if: {{{MR|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=mr |input1={{{MR|}}} }}
}}{{
&lt;!--============ OCLC ===============--&gt;
  #if: {{{OCLC|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=oclc |input1={{{OCLC|}}} }}
}}{{
&lt;!--============ OL =================--&gt;
  #if: {{{OL|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=ol |input1={{{OL|}}} }}
}}{{
&lt;!--============ OSTI ===============--&gt;
  #if: {{{OSTI|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=osti |input1={{{OSTI|}}} }}
}}{{
&lt;!--============ PMC ================--&gt;
  #if: {{{PMC|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=pmc |input1={{{PMC|}}} }}
}}{{
&lt;!--============ PMID ===============--&gt;
  #if: {{{PMID|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=pmid |input1={{{PMID|}}} }}
}}{{
&lt;!--============ RFC ================--&gt;
  #if: {{{RFC|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=rfc|input1={{{RFC|}}} }}
}}{{
&lt;!--============ SSRN ================--&gt;
  #if: {{{SSRN|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=ssrn |input1={{{SSRN|}}} }}
}}{{
&lt;!--============ ZBL ================--&gt;
  #if: {{{ZBL|}}}
  |{{{Sep|,}}}&amp;#32;{{Wp/nd/citation/identifier  |identifier=zbl |input1={{{ZBL|}}} }}
}}{{
&lt;!--============  Misc. Identifier ============--&gt;
  #if: {{{ID|}}}
  |{{{Sep|,}}}&amp;#32;{{{ID}}}
}}{{
&lt;!--============  Archive data, etc ===========--&gt;
#if: {{{Archive|}}}
|{{{Sep|,}}}&amp;#32;{{{Archive}}}[[Category:Pages using deprecated citation archive parameters]]
|{{
  #if:{{{ArchiveURL|}}}{{{ArchiveDate|}}}
  | {{{Sep|,}}}&amp;#32;{{#ifeq: {{{DeadURL|}}} | no
    | {{#if:{{{ArchiveURL|}}}
       |{{Wp/nd/citation/make link|{{{ArchiveURL|}}}|{{#ifeq:{{{Sep}}}|.|A|a}}rchived}}&amp;#32;from the original
       |{{#ifeq:{{{Sep}}}|.|A|a}}rchived
      }}
    | {{#ifeq:{{{Sep}}}|.|A|a}}rchived{{#if:{{{OriginalURL|}}}{{{IncludedWorkURL|}}}
       |{{#if:{{{ArchiveURL|}}}|&amp;#32;from {{Wp/nd/citation/make link|{{{OriginalURL|{{{IncludedWorkURL|}}}}}}|the original}}}}
      }}
    }}{{#if:{{{ArchiveDate|}}}|&amp;#32;on {{{ArchiveDate}}}}}{{
     #if:{{#if:{{{ArchiveURL|}}}||A}}{{#if:{{{OriginalURL|}}}{{{IncludedWorkURL|}}}||B}}{{#if:{{{ArchiveDate|}}}||C}}
     |. {{Wp/nd/citation error|nocat={{{template doc demo|}}}
       |If you specify &lt;code&gt;&amp;#124;{{#if:{{{ArchiveURL|}}}|archiveurl|archivedate}}&amp;#61;&lt;/code&gt;{{#ifeq:{{{DeadURL|}}}|no|{{#if:{{{OriginalURL|}}}{{{IncludedWorkURL|}}}||&amp;#32;and &lt;code&gt;&amp;#124;deadurl&amp;#61;no&lt;/code&gt;}}}}, you must {{#if:{{{OriginalURL|}}}{{{IncludedWorkURL|}}}| also specify &lt;code&gt;&amp;#124;{{#if:{{{ArchiveURL|}}}|archivedate|archiveurl}}&amp;#61;&lt;/code&gt;| {{#ifeq:{{{DeadURL|}}}|no|also|first}} specify &lt;code&gt;&amp;#124;url&amp;#61;&lt;/code&gt;}}}}
    }}
  }}
}}{{
&lt;!--============ URL and AccessDate ============--&gt;
  #if: {{{URL|}}}{{{IncludedWorkURL|}}}{{#ifeq:{{{DeadURL|}}}|no|{{{ArchiveURL|}}}|}}
  |{{
     #if: {{{Title|}}}{{{IncludedWorkTitle|}}}{{{TransTitle|}}}
     |&lt;span class=&quot;printonly&quot;&gt;{{{Sep|,}}}&amp;#32;{{
                                      #if: {{{IncludedWorkURL|}}}
                                      |{{{IncludedWorkURL}}}
                                      |{{{URL}}}
                                    }}&lt;/span&gt;
     |{{{Sep|,}}}&amp;#32;{{
              #if: {{{IncludedWorkURL|}}}
              |{{{IncludedWorkURL}}}
              |{{{URL}}}
            }}
   }}{{
     #if: {{{AccessDate|}}}
     | &lt;span class=&quot;reference-accessdate&quot;&gt;{{#ifeq:{{{Sep|}}}|,|,&amp;#32;r|.&amp;#32;R}}etrieved {{{AccessDate}}}&lt;/span&gt;
     }}
}}{{#if:{{{laysummary|}}}
  |{{{Sep|,}}}&amp;#32;[{{{laysummary}}} Lay summary]{{#if: {{{laysource|}}}|&amp;nbsp;&amp;ndash;&amp;nbsp;''&lt;nowiki /&gt;{{{laysource}}}&lt;nowiki /&gt;''}}
}}{{#if:{{{laydate|}}}
  | &amp;#32;({{{laydate}}})
}}{{#if:{{{quote|}}}
  |{{{Sep|,}}}&amp;#32;&quot;{{{quote}}}&quot;
}}{{{PS|}}}&lt;/span&gt;&lt;!--

=== This is a COinS tag (http://ocoins.info), which allows automated tools to parse the citation information: ===

--&gt;&lt;span
    class=&quot;Z3988&quot;
    title=&quot;ctx_ver=Z39.88-2004&amp;rft_val_fmt={{urlencode:info:ofi/fmt:kev:mtx:}}{{
      #if: {{{Periodical|}}}
      |journal&amp;rft.genre=article&amp;rft.atitle={{urlencode:{{{Title|}}}}}&amp;rft.jtitle={{urlencode:{{{Periodical|}}}}}
      |book{{
         #if: {{{IncludedWorkTitle|}}}
         |&amp;rft.genre=bookitem&amp;rft.btitle={{urlencode:{{{IncludedWorkTitle|}}}}}&amp;rft.atitle={{urlencode:{{{Title|}}}}}
         |&amp;rft.genre=book&amp;rft.btitle={{urlencode:{{{Title|}}}}}
       }}
    }}{{
     #if: {{{Surname1|}}} |&amp;rft.aulast={{urlencode:{{{Surname1}}}}}{{
       #if: {{{Given1|}}} |&amp;rft.aufirst={{urlencode:{{{Given1}}}}}
     }}
   }}{{
     #if: {{{Surname1|}}} |&amp;rft.au={{urlencode:{{{Surname1}}}}}{{
       #if: {{{Given1|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given1}}}}}
     }}
   }}{{
     #if: {{{Surname2|}}} |&amp;rft.au={{urlencode:{{{Surname2}}}}}{{
       #if: {{{Given2|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given2}}}}}
     }}
   }}{{
     #if: {{{Surname3|}}} |&amp;rft.au={{urlencode:{{{Surname3}}}}}{{
       #if: {{{Given3|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given3}}}}}
     }}
   }}{{
     #if: {{{Surname4|}}} |&amp;rft.au={{urlencode:{{{Surname4}}}}}{{
       #if: {{{Given4|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given4}}}}}
     }}
   }}{{
     #if: {{{Surname5|}}} |&amp;rft.au={{urlencode:{{{Surname5}}}}}{{
       #if: {{{Given5|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given5}}}}}
     }}
   }}{{
     #if: {{{Surname6|}}} |&amp;rft.au={{urlencode:{{{Surname6}}}}}{{
       #if: {{{Given6|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given6}}}}}
     }}
   }}{{
     #if: {{{Surname7|}}} |&amp;rft.au={{urlencode:{{{Surname7}}}}}{{
       #if: {{{Given7|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given7}}}}}
     }}
   }}{{
     #if: {{{Surname8|}}} |&amp;rft.au={{urlencode:{{{Surname8}}}}}{{
       #if: {{{Given8|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given8}}}}}
     }}
   }}{{
     #if: {{{Surname9|}}} |&amp;rft.au={{urlencode:{{{Surname9}}}}}{{
       #if: {{{Given9|}}} |{{urlencode:{{{NameSep|,&amp;#32;}}}{{{Given9}}}}}
     }}
    }}{{
      #if: {{{Date|}}} |&amp;rft.date={{urlencode:{{{Date}}}}}
    }}{{
      #if: {{{Series|}}} |&amp;rft.series={{urlencode:{{{Series}}}}}
    }}{{
      #if: {{{Volume|}}} |&amp;rft.volume={{urlencode:{{{Volume}}}}}
    }}{{
      #if: {{{Issue|}}} |&amp;rft.issue={{urlencode:{{{Issue}}}}}
    }}{{
      #if: {{{At|}}} |&amp;rft.pages={{urlencode:{{{At}}}}}
    }}{{
      #if: {{{Edition|}}} |&amp;rft.edition={{urlencode:{{{Edition}}}}}
    }}{{
      #if: {{{PublicationPlace|}}}{{{Place|}}} |&amp;rft.place={{urlencode:{{{PublicationPlace|{{{Place}}}}}}}}
    }}{{
      #if: {{{Publisher|}}} |&amp;rft.pub={{urlencode:{{{Publisher}}}}}
    }}{{
      #if: {{{ARXIV|}}} |&amp;rft_id=info:arxiv/{{urlencode:{{{ARXIV}}}}}
    }}{{
      #if: {{{ASIN|}}} |&amp;rft_id=info:asin/{{urlencode:{{{ASIN}}}}}
    }}{{
      #if: {{{BIBCODE|}}} |&amp;rft_id=info:bibcode/{{urlencode:{{{BIBCODE}}}}}
    }}{{
      #if: {{{DOI|}}} |&amp;rft_id=info:doi/{{urlencode:{{{DOI}}}}}
    }}{{
      #if: {{{ISBN|}}} |&amp;rft.isbn={{urlencode:{{{ISBN}}}}}
    }}{{
      #if: {{{ISSN|}}} |&amp;rft.issn={{urlencode:{{{ISSN}}}}}
    }}{{
      #if: {{{JFM|}}} |&amp;rft.jfm={{urlencode:{{{JFM}}}}}
    }}{{
      #if: {{{JSTOR|}}} |&amp;rft.jstor={{urlencode:{{{JSTOR}}}}}
    }}{{
      #if: {{{LCCN|}}} |&amp;rft.lccn={{urlencode:{{{LCCN}}}}}
    }}{{
      #if: {{{OCLC|}}} |&amp;rft_id=info:oclcnum/{{urlencode:{{{OCLC}}}}}
    }}{{
      #if: {{{OL|}}} |&amp;rft_id=info:olnum/{{urlencode:{{{OL}}}}}
    }}{{
      #if: {{{OSTI|}}} |&amp;rft_id=info:osti/{{urlencode:{{{OSTI}}}}}
    }}{{
      #if: {{{MR|}}} |&amp;rft.mr={{urlencode:{{{MR}}}}}
    }}{{
      #if: {{{PMC|}}} |&amp;rft_id=info:pmc/{{urlencode:{{{PMC}}}}}
    }}{{
      #if: {{{PMID|}}} |&amp;rft_id=info:pmid/{{urlencode:{{{PMID}}}}}
    }}{{
      #if: {{{RFC|}}} |&amp;rft_id=info:rfc/{{urlencode:{{{RFC}}}}}
    }}{{
      #if: {{{SSRN|}}} |&amp;rft_id=info:ssrn/{{urlencode:{{{SSRN}}}}}
    }}{{
      #if: {{{ZBL|}}} |&amp;rft_id=info:zbl/{{urlencode:{{{ZBL}}}}}
    }}{{
      #if: {{{URL|}}}{{{IncludedWorkURL|}}} |&amp;rft_id={{urlencode:{{{URL|{{{IncludedWorkURL|}}}}}}}}
    }}&amp;rfr_id=info:sid/en.wikipedia.org:{{FULLPAGENAMEE}}&quot;&gt;&lt;span style=&quot;display: none;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;noinclude&gt;
{{Wp/nd/Documentation}}
&lt;/noinclude&gt;</text>
      <sha1>lljtlmvlwoi6tf7rxtyyu41h7rxfu9q</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Str left</title>
    <ns>10</ns>
    <id>375</id>
    <revision>
      <id>1959</id>
      <timestamp>2009-02-25T02:23:16Z</timestamp>
      <contributor>
        <username>incubator&gt;Dragons flight</username>
        <id>0</id>
      </contributor>
      <comment>[[WP:AES|←]]Created page with '{{padleft:|{{{1}}}|{{{2|1}}}}}'</comment>
      <origin>1959</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="30" sha1="q8m455vgpjewr7ovrp7d3q60t16rzqv" xml:space="preserve">{{padleft:|{{{1}}}|{{{2|1}}}}}</text>
      <sha1>q8m455vgpjewr7ovrp7d3q60t16rzqv</sha1>
    </revision>
    <revision>
      <id>1960</id>
      <parentid>1959</parentid>
      <timestamp>2009-02-25T02:26:12Z</timestamp>
      <contributor>
        <username>incubator&gt;Dragons flight</username>
        <id>0</id>
      </contributor>
      <origin>1960</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="31" sha1="9sxe6ppzfvguk3jb90dnke48tpeqc2s" xml:space="preserve">{{padleft:||{{{2|1}}}|{{{1}}}}}</text>
      <sha1>9sxe6ppzfvguk3jb90dnke48tpeqc2s</sha1>
    </revision>
    <revision>
      <id>1961</id>
      <parentid>1960</parentid>
      <timestamp>2009-02-25T02:27:15Z</timestamp>
      <contributor>
        <username>incubator&gt;Dragons flight</username>
        <id>0</id>
      </contributor>
      <origin>1961</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="30" sha1="rjzixeuqvj9gmuhrr3044godpuizx9y" xml:space="preserve">{{padleft:|{{{2|1}}}|{{{1}}}}}</text>
      <sha1>rjzixeuqvj9gmuhrr3044godpuizx9y</sha1>
    </revision>
    <revision>
      <id>1962</id>
      <parentid>1961</parentid>
      <timestamp>2009-02-27T01:26:09Z</timestamp>
      <contributor>
        <username>incubator&gt;Dragons flight</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>moved [[User:Dragons flight/trunc]] to [[Template:Str left]]</comment>
      <origin>1961</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="30" sha1="rjzixeuqvj9gmuhrr3044godpuizx9y" xml:space="preserve">{{padleft:|{{{2|1}}}|{{{1}}}}}</text>
      <sha1>rjzixeuqvj9gmuhrr3044godpuizx9y</sha1>
    </revision>
    <revision>
      <id>1963</id>
      <parentid>1962</parentid>
      <timestamp>2009-02-27T01:27:45Z</timestamp>
      <contributor>
        <username>incubator&gt;Dragons flight</username>
        <id>0</id>
      </contributor>
      <origin>1963</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="193" sha1="7ut460dott4kod6qieo4lo3c8vch5ae" xml:space="preserve">{{padleft:|{{{2|1}}}|{{{1}}}}}&lt;noinclude&gt;

&lt;nowiki&gt;{{str_left|&lt;/nowiki&gt;''text''&lt;nowiki&gt;|&lt;/nowiki&gt;''number''&lt;nowiki&gt;}}&lt;/nowiki&gt; = Grabs the first ''number'' characters from ''text''.&lt;/noinclude&gt;</text>
      <sha1>7ut460dott4kod6qieo4lo3c8vch5ae</sha1>
    </revision>
    <revision>
      <id>1964</id>
      <parentid>1963</parentid>
      <timestamp>2009-02-27T01:28:19Z</timestamp>
      <contributor>
        <username>incubator&gt;Dragons flight</username>
        <id>0</id>
      </contributor>
      <origin>1964</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="220" sha1="isli3xkf15xcm9fsqllq6dyifujl2jj" xml:space="preserve">&lt;includeonly&gt;{{padleft:|{{{2|1}}}|{{{1}}}}}&lt;/includeonly&gt;&lt;noinclude&gt;

&lt;nowiki&gt;{{str_left|&lt;/nowiki&gt;''text''&lt;nowiki&gt;|&lt;/nowiki&gt;''number''&lt;nowiki&gt;}}&lt;/nowiki&gt; = Grabs the first ''number'' characters from ''text''.&lt;/noinclude&gt;</text>
      <sha1>isli3xkf15xcm9fsqllq6dyifujl2jj</sha1>
    </revision>
    <revision>
      <id>1965</id>
      <parentid>1964</parentid>
      <timestamp>2009-02-27T01:28:42Z</timestamp>
      <contributor>
        <username>incubator&gt;Dragons flight</username>
        <id>0</id>
      </contributor>
      <origin>1965</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="247" sha1="nc6csf3e1845j11j1ywa3f4ssfa0bja" xml:space="preserve">&lt;includeonly&gt;{{padleft:|{{{2|1}}}|{{{1}}}}}&lt;/includeonly&gt;&lt;noinclude&gt;

&lt;nowiki&gt;{{str_left|&lt;/nowiki&gt;''text''&lt;nowiki&gt;|&lt;/nowiki&gt;''number''&lt;nowiki&gt;}}&lt;/nowiki&gt; = Grabs the first ''number'' characters from ''text''.  ''Number'' defaults to 1.&lt;/noinclude&gt;</text>
      <sha1>nc6csf3e1845j11j1ywa3f4ssfa0bja</sha1>
    </revision>
    <revision>
      <id>1966</id>
      <parentid>1965</parentid>
      <timestamp>2009-02-27T02:16:19Z</timestamp>
      <contributor>
        <username>incubator&gt;Dragons flight</username>
        <id>0</id>
      </contributor>
      <origin>1966</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="293" sha1="hd2ylwemuhe2xrjy1xiq7fvmyorfid4" xml:space="preserve">&lt;includeonly&gt;{{padleft:|{{{2|1}}}|{{{1}}}}}&lt;/includeonly&gt;&lt;noinclude&gt;

&lt;nowiki&gt;{{str_left|&lt;/nowiki&gt;''text''&lt;nowiki&gt;|&lt;/nowiki&gt;''number''&lt;nowiki&gt;}}&lt;/nowiki&gt; = Grabs the first ''number'' characters from ''text''.  ''Number'' defaults to 1.

[[Category: String manipulation templates]]
&lt;/noinclude&gt;</text>
      <sha1>hd2ylwemuhe2xrjy1xiq7fvmyorfid4</sha1>
    </revision>
    <revision>
      <id>1967</id>
      <parentid>1966</parentid>
      <timestamp>2009-03-07T12:35:00Z</timestamp>
      <contributor>
        <username>incubator&gt;Happy-melon</username>
        <id>0</id>
      </contributor>
      <comment>optional subst</comment>
      <origin>1967</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="305" sha1="662y6lun5qedaciqspa2knolcigzu2t" xml:space="preserve">&lt;includeonly&gt;{{{{{subst|}}}padleft:|{{{2|1}}}|{{{1}}}}}&lt;/includeonly&gt;&lt;noinclude&gt;

&lt;nowiki&gt;{{str_left|&lt;/nowiki&gt;''text''&lt;nowiki&gt;|&lt;/nowiki&gt;''number''&lt;nowiki&gt;}}&lt;/nowiki&gt; = Grabs the first ''number'' characters from ''text''.  ''Number'' defaults to 1.

[[Category: String manipulation templates]]
&lt;/noinclude&gt;</text>
      <sha1>662y6lun5qedaciqspa2knolcigzu2t</sha1>
    </revision>
    <revision>
      <id>1968</id>
      <parentid>1967</parentid>
      <timestamp>2009-03-23T17:35:01Z</timestamp>
      <contributor>
        <username>incubator&gt;Happy-melon</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Reverted edits by [[Special:Contributions/Happy-melon|Happy-melon]] ([[User talk:Happy-melon|talk]]) to last version by Dragons flight</comment>
      <origin>1968</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="293" sha1="hd2ylwemuhe2xrjy1xiq7fvmyorfid4" xml:space="preserve">&lt;includeonly&gt;{{padleft:|{{{2|1}}}|{{{1}}}}}&lt;/includeonly&gt;&lt;noinclude&gt;

&lt;nowiki&gt;{{str_left|&lt;/nowiki&gt;''text''&lt;nowiki&gt;|&lt;/nowiki&gt;''number''&lt;nowiki&gt;}}&lt;/nowiki&gt; = Grabs the first ''number'' characters from ''text''.  ''Number'' defaults to 1.

[[Category: String manipulation templates]]
&lt;/noinclude&gt;</text>
      <sha1>hd2ylwemuhe2xrjy1xiq7fvmyorfid4</sha1>
    </revision>
    <revision>
      <id>1969</id>
      <parentid>1968</parentid>
      <timestamp>2009-03-31T17:07:29Z</timestamp>
      <contributor>
        <username>incubator&gt;Amalthea</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Protected Template:Str left: [[WP:HRT|Highly visible template]]:&amp;#32;Meta template, used in [[Template:Images]] which is used in [[Template:Archives]] which is a highly visible template. ([edit=sysop] (indefinite) [move=sysop] (indefinite))</comment>
      <origin>1968</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="293" sha1="hd2ylwemuhe2xrjy1xiq7fvmyorfid4" xml:space="preserve">&lt;includeonly&gt;{{padleft:|{{{2|1}}}|{{{1}}}}}&lt;/includeonly&gt;&lt;noinclude&gt;

&lt;nowiki&gt;{{str_left|&lt;/nowiki&gt;''text''&lt;nowiki&gt;|&lt;/nowiki&gt;''number''&lt;nowiki&gt;}}&lt;/nowiki&gt; = Grabs the first ''number'' characters from ''text''.  ''Number'' defaults to 1.

[[Category: String manipulation templates]]
&lt;/noinclude&gt;</text>
      <sha1>hd2ylwemuhe2xrjy1xiq7fvmyorfid4</sha1>
    </revision>
    <revision>
      <id>1970</id>
      <parentid>1969</parentid>
      <timestamp>2009-03-31T17:08:28Z</timestamp>
      <contributor>
        <username>incubator&gt;Amalthea</username>
        <id>0</id>
      </contributor>
      <comment>moved documentation into subpage</comment>
      <origin>1970</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="88" sha1="odb5bk4crm4wr676njuhh2qlbm5621s" xml:space="preserve">{{padleft:|{{{2|1}}}|{{{1}}}}}&lt;noinclude&gt;
{{pp-template}}
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>odb5bk4crm4wr676njuhh2qlbm5621s</sha1>
    </revision>
    <revision>
      <id>1971</id>
      <parentid>1970</parentid>
      <timestamp>2009-03-31T17:10:15Z</timestamp>
      <contributor>
        <username>incubator&gt;Amalthea</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>restored &lt;includeonly&gt; tag</comment>
      <origin>1971</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="115" sha1="hy2394fw94fpuvsqmnnmu1mrec31ikj" xml:space="preserve">&lt;includeonly&gt;{{padleft:|{{{2|1}}}|{{{1}}}}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{pp-template}}
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>hy2394fw94fpuvsqmnnmu1mrec31ikj</sha1>
    </revision>
    <revision>
      <id>1972</id>
      <parentid>1971</parentid>
      <timestamp>2010-04-15T14:51:00Z</timestamp>
      <contributor>
        <username>incubator&gt;Plastikspork</username>
        <id>0</id>
      </contributor>
      <comment>Not necessary</comment>
      <origin>1972</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="99" sha1="2q0gsk6x7mjpc8dnug3ezgmzan6j9ma" xml:space="preserve">&lt;includeonly&gt;{{padleft:|{{{2|1}}}|{{{1}}}}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>2q0gsk6x7mjpc8dnug3ezgmzan6j9ma</sha1>
    </revision>
    <revision>
      <id>1973</id>
      <parentid>1972</parentid>
      <timestamp>2010-04-23T14:29:52Z</timestamp>
      <contributor>
        <username>incubator&gt;Amalthea</username>
        <id>0</id>
      </contributor>
      <comment>Make template substitutable ([[meta:Help:Safesubst]])</comment>
      <origin>1973</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="116" sha1="i53mz78wk3c5mqkxdco5gmjc9lfis27" xml:space="preserve">&lt;includeonly&gt;{{ {{{safesubst:}}}padleft:|{{{2|1}}}|{{{1}}}}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>i53mz78wk3c5mqkxdco5gmjc9lfis27</sha1>
    </revision>
    <revision>
      <id>1974</id>
      <parentid>1973</parentid>
      <timestamp>2010-04-23T14:30:19Z</timestamp>
      <contributor>
        <username>incubator&gt;Amalthea</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Aargh</comment>
      <origin>1974</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="117" sha1="i87f9fd5zu12vbrsxzfd7491aopjrjn" xml:space="preserve">&lt;includeonly&gt;{{ {{{|safesubst:}}}padleft:|{{{2|1}}}|{{{1}}}}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>i87f9fd5zu12vbrsxzfd7491aopjrjn</sha1>
    </revision>
    <revision>
      <id>1975</id>
      <parentid>1974</parentid>
      <timestamp>2011-04-01T10:30:40Z</timestamp>
      <contributor>
        <username>incubator&gt;TeleComNasSprVen</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>16 revisions from [[:w:Template:Str left]]: crosswiki maintenance</comment>
      <origin>1974</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="117" sha1="i87f9fd5zu12vbrsxzfd7491aopjrjn" xml:space="preserve">&lt;includeonly&gt;{{ {{{|safesubst:}}}padleft:|{{{2|1}}}|{{{1}}}}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>i87f9fd5zu12vbrsxzfd7491aopjrjn</sha1>
    </revision>
    <revision>
      <id>1976</id>
      <parentid>1975</parentid>
      <timestamp>2024-11-18T17:41:43Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <minor />
      <comment>17 revisions imported from [[:incubator:Template:Str_left]]</comment>
      <origin>1974</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="117" sha1="i87f9fd5zu12vbrsxzfd7491aopjrjn" xml:space="preserve">&lt;includeonly&gt;{{ {{{|safesubst:}}}padleft:|{{{2|1}}}|{{{1}}}}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>i87f9fd5zu12vbrsxzfd7491aopjrjn</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Wp/nd/Cite journal</title>
    <ns>10</ns>
    <id>376</id>
    <revision>
      <id>1977</id>
      <timestamp>2016-11-09T15:16:58Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>[[:en:Template:Cite journal]]</comment>
      <origin>1977</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5651" sha1="forh6piibxq4m8hj5n18ehyp7fgwofn" xml:space="preserve">{{Wp/nd/Citation/core
|Citation class=Journal

|Surname1={{{last|{{{last1|{{{author|{{{author1|{{{authors|{{{surname|{{{surname1|}}}}}}}}}}}}}}}}}}}}}
|Surname2={{{last2|{{{author2|{{{surname2|}}}}}}}}}
|Surname3={{{last3|{{{author3|{{{surname3|}}}}}}}}}
|Surname4={{{last4|{{{author4|{{{surname4|}}}}}}}}}
|Surname5={{{last5|{{{author5|{{{surname5|}}}}}}}}}
|Surname6={{{last6|{{{author6|{{{surname6|}}}}}}}}}
|Surname7={{{last7|{{{author7|{{{surname7|}}}}}}}}}
|Surname8={{{last8|{{{author8|{{{surname8|}}}}}}}}}
|Surname9={{{last9|{{{author9|{{{surname9|}}}}}}}}}

|Given1={{{first|{{{first1|{{{given|{{{given1|}}}}}}}}}}}}
|Given2={{{first2|{{{given2|}}}}}}
|Given3={{{first3|{{{given3|}}}}}}
|Given4={{{first4|{{{given4|}}}}}}
|Given5={{{first5|{{{given5|}}}}}}
|Given6={{{first6|{{{given6|}}}}}}
|Given7={{{first7|{{{given7|}}}}}}
|Given8={{{first8|{{{given8|}}}}}}
|Given9={{{first9|{{{given9|}}}}}}

|Authorlink1={{{authorlink|{{{authorlink1|{{{author-link|{{{author1-link|}}}}}}}}}}}}
|Authorlink2={{{authorlink2|{{{author2-link|}}}}}}
|Authorlink3={{{authorlink3|{{{author3-link|}}}}}}
|Authorlink4={{{authorlink4|{{{author4-link|}}}}}}
|Authorlink5={{{authorlink5|{{{author5-link|}}}}}}
|Authorlink6={{{authorlink6|{{{author6-link|}}}}}}
|Authorlink7={{{authorlink7|{{{author7-link|}}}}}}
|Authorlink8={{{authorlink8|{{{author8-link|}}}}}}
|Authorlink9={{{authorlink9|{{{author9-link|}}}}}}

|Coauthors={{{coauthors|{{{coauthor|}}}}}}

|Other={{{others|}}}

|Year={{{year|{{    &lt;!-- attempt to derive year from date, if possible --&gt;
           #if: {{{date|}}}
           |{{
              #iferror:{{#time:Y|{{{date|}}} }}
              |{{#iferror:{{#time:Y|{{{publication-date|einval}}} }}||{{#time:Y|{{{publication-date|}}} }}}}
              |{{#time:Y|{{{date|}}} }}
            }}
           |{{{publication-date|}}} &lt;!-- last resort --&gt;
         }}
      }}}
|YearNote={{{origyear|}}}
|Date={{#if:{{{date|}}}|{{{date}}}|{{{day|}}} {{{month|}}} {{{year|{{{publication-date|}}}}}}}}

|Title={{{title|}}}
|TransTitle={{{trans_title|}}}
|IncludedWorkTitle={{{chapter|{{{contribution|}}}}}}
|TitleType={{{type|}}}
|language={{{language|}}}

|URL={{#if:{{{archiveurl|}}}
      |{{#ifeq: {{{deadurl|}}} | no | {{{url|}}} | {{{archiveurl|}}} }}
      |{{#if:{{{url|}}}
        |{{{url}}}
        |{{#if:{{{pmc|{{{PMC|}}}}}}
          |{{#ifexpr:{{#time: U}} &gt; {{#time: U | {{{Embargo|2001-10-10}}} }}
            |{{hide in print|1=//www.ncbi.nlm.nih.gov/pmc/articles/PMC{{{pmc|{{{PMC|}}}}}}/}}
           }}
         }}
       }}
     }}
|IncludedWorkURL={{{chapter-url|{{{chapterurl|{{{contribution-url|}}}}}}}}}
|AccessDate={{{accessdate|}}}
|OriginalURL={{{url|}}}
|ArchiveURL={{{archiveurl|}}}
|ArchiveDate={{{archivedate|}}}
|DeadURL={{{deadurl|}}}
|format={{{format|}}}

|Periodical={{{work|{{{journal|{{{newspaper|{{{magazine|{{{periodical|}}}}}}}}}}}}}}}
|Issue={{{issue|{{{number|}}}}}}
|TitleNote={{{department|}}}

|At={{#if: {{{journal|{{{periodical|{{{magazine|{{{work|}}}}}}}}}}}}
        |{{{page|{{{pages|{{{at|}}}}}}}}}
          |{{#if: {{{page|}}}|{{#if:{{{nopp|}}}||p.&amp;nbsp;}}{{{page}}}
            |{{#if: {{{pages|}}}|{{#if:{{{nopp|}}}||pp.&amp;nbsp;}}{{{pages}}}
              |{{{at|}}} }} }} }}

|Edition={{{edition|}}}
|Series={{{series|{{{version|}}}}}}
|Volume={{{volume|}}}

|Publisher={{{publisher|}}}
|Place={{{location|{{{place|}}}}}}
|PublicationPlace={{{location|{{{place|{{{publication-place|}}}}}}}}}
|PublicationDate={{{publication-date|}}}

|EditorSurname1={{{editor-last|{{{editor1-last|{{{editor|{{{editors|{{{editor-surname|{{{editor1-surname|}}}}}}}}}}}}}}}}}}
|EditorSurname2={{{editor2-last|{{{editor2-surname|}}}}}}
|EditorSurname3={{{editor3-last|{{{editor3-surname|}}}}}}
|EditorSurname4={{{editor4-last|{{{editor4-surname|}}}}}}
|EditorGiven1={{{editor-first|{{{editor1-first|{{{editor-given|{{{editor1-given|}}}}}}}}}}}}
|EditorGiven2={{{editor2-first|{{{editor2-given|}}}}}}
|EditorGiven3={{{editor3-first|{{{editor3-given|}}}}}}
|EditorGiven4={{{editor4-first|{{{editor4-given|}}}}}}
|Editorlink1={{{editor-link|{{{editor1-link|}}}}}}
|Editorlink2={{{editor2-link|}}}
|Editorlink3={{{editor3-link|}}}
|Editorlink4={{{editor4-link|}}}

|ARXIV={{{arxiv|}}}
|ASIN={{{asin|{{{ASIN|}}}}}}
|ASIN-TLD={{{asin-tld|}}}
|BIBCODE={{{bibcode|}}}
|DOI={{{doi|{{{DOI|}}}}}}
|DoiBroken={{{doi_brokendate|{{{doi_inactivedate|}}}}}}
|ISBN={{{isbn|{{{ISBN|}}}}}}
|ISSN={{{issn|{{{ISSN|}}}}}}
|JFM={{{jfm|{{{JFM|}}}}}}
|JSTOR={{{jstor|{{{JSTOR|}}}}}}
|LCCN={{{lccn|{{{LCCN|}}}}}}
|MR={{{mr|{{{MR|}}}}}}
|OCLC={{{oclc|{{{OCLC|}}}}}}
|OL={{{ol|{{{OL|}}}}}}
|OSTI={{{osti|{{{OSTI|}}}}}}
|PMC={{{pmc|{{{PMC|}}}}}}
|PMID={{{pmid|{{{PMID|}}}}}}
|RFC={{{rfc|{{{RFC|}}}}}}
|SSRN={{{ssrn|{{{SSRN|}}}}}}
|ZBL={{{zbl|}}}
|ID={{{id|{{{ID|}}}}}}

|laysummary={{{laysummary|}}}
|laydate={{{laydate|}}}
|laysource={{{laysource|}}}

|quote={{{quote|}}}

|Ref={{{ref|}}}

|amp={{{lastauthoramp|}}}
|AuthorMask={{{author-mask|{{{authormask|}}}}}}
|AuthorSep={{#ifeq:{{{author-separator|}}}|;|&amp;#059;|{{{author-separator|&amp;#059;}}}}}&amp;#32;
|NameSep={{{author-name-separator|,}}}&amp;#32;
|PS={{#if:{{{quote|}}}||{{{postscript|.}}}}}
|Sep={{#ifeq:{{{separator|{{{seperator}}} }}}|;|&amp;#059;|{{{separator|{{{seperator|.}}} }}} }}
|template doc demo={{{template doc demo|}}}
|Trunc={{#if:{{{display-authors|}}}|{{{display-authors}}}|8}}
}}{{#if:{{{access-date|}}}{{{accessdaymonth|}}}{{{accessday|}}}{{{accessmonthday|}}}{{{accessmonth|}}}{{{accessyear|}}}{{{dateformat|}}}{{{day|}}}{{{doilabel|}}}
|[[Category:Pages containing cite templates with deprecated parameters|{{NAMESPACE}} {{PAGENAME}}]]}}&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>forh6piibxq4m8hj5n18ehyp7fgwofn</sha1>
    </revision>
    <revision>
      <id>1978</id>
      <parentid>1977</parentid>
      <timestamp>2016-11-09T15:28:17Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>CFCF moved page [[Template:Wp/nd/cite journal]] to [[Template:Wp/nd/Cite journal]]</comment>
      <origin>1977</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5651" sha1="forh6piibxq4m8hj5n18ehyp7fgwofn" xml:space="preserve">{{Wp/nd/Citation/core
|Citation class=Journal

|Surname1={{{last|{{{last1|{{{author|{{{author1|{{{authors|{{{surname|{{{surname1|}}}}}}}}}}}}}}}}}}}}}
|Surname2={{{last2|{{{author2|{{{surname2|}}}}}}}}}
|Surname3={{{last3|{{{author3|{{{surname3|}}}}}}}}}
|Surname4={{{last4|{{{author4|{{{surname4|}}}}}}}}}
|Surname5={{{last5|{{{author5|{{{surname5|}}}}}}}}}
|Surname6={{{last6|{{{author6|{{{surname6|}}}}}}}}}
|Surname7={{{last7|{{{author7|{{{surname7|}}}}}}}}}
|Surname8={{{last8|{{{author8|{{{surname8|}}}}}}}}}
|Surname9={{{last9|{{{author9|{{{surname9|}}}}}}}}}

|Given1={{{first|{{{first1|{{{given|{{{given1|}}}}}}}}}}}}
|Given2={{{first2|{{{given2|}}}}}}
|Given3={{{first3|{{{given3|}}}}}}
|Given4={{{first4|{{{given4|}}}}}}
|Given5={{{first5|{{{given5|}}}}}}
|Given6={{{first6|{{{given6|}}}}}}
|Given7={{{first7|{{{given7|}}}}}}
|Given8={{{first8|{{{given8|}}}}}}
|Given9={{{first9|{{{given9|}}}}}}

|Authorlink1={{{authorlink|{{{authorlink1|{{{author-link|{{{author1-link|}}}}}}}}}}}}
|Authorlink2={{{authorlink2|{{{author2-link|}}}}}}
|Authorlink3={{{authorlink3|{{{author3-link|}}}}}}
|Authorlink4={{{authorlink4|{{{author4-link|}}}}}}
|Authorlink5={{{authorlink5|{{{author5-link|}}}}}}
|Authorlink6={{{authorlink6|{{{author6-link|}}}}}}
|Authorlink7={{{authorlink7|{{{author7-link|}}}}}}
|Authorlink8={{{authorlink8|{{{author8-link|}}}}}}
|Authorlink9={{{authorlink9|{{{author9-link|}}}}}}

|Coauthors={{{coauthors|{{{coauthor|}}}}}}

|Other={{{others|}}}

|Year={{{year|{{    &lt;!-- attempt to derive year from date, if possible --&gt;
           #if: {{{date|}}}
           |{{
              #iferror:{{#time:Y|{{{date|}}} }}
              |{{#iferror:{{#time:Y|{{{publication-date|einval}}} }}||{{#time:Y|{{{publication-date|}}} }}}}
              |{{#time:Y|{{{date|}}} }}
            }}
           |{{{publication-date|}}} &lt;!-- last resort --&gt;
         }}
      }}}
|YearNote={{{origyear|}}}
|Date={{#if:{{{date|}}}|{{{date}}}|{{{day|}}} {{{month|}}} {{{year|{{{publication-date|}}}}}}}}

|Title={{{title|}}}
|TransTitle={{{trans_title|}}}
|IncludedWorkTitle={{{chapter|{{{contribution|}}}}}}
|TitleType={{{type|}}}
|language={{{language|}}}

|URL={{#if:{{{archiveurl|}}}
      |{{#ifeq: {{{deadurl|}}} | no | {{{url|}}} | {{{archiveurl|}}} }}
      |{{#if:{{{url|}}}
        |{{{url}}}
        |{{#if:{{{pmc|{{{PMC|}}}}}}
          |{{#ifexpr:{{#time: U}} &gt; {{#time: U | {{{Embargo|2001-10-10}}} }}
            |{{hide in print|1=//www.ncbi.nlm.nih.gov/pmc/articles/PMC{{{pmc|{{{PMC|}}}}}}/}}
           }}
         }}
       }}
     }}
|IncludedWorkURL={{{chapter-url|{{{chapterurl|{{{contribution-url|}}}}}}}}}
|AccessDate={{{accessdate|}}}
|OriginalURL={{{url|}}}
|ArchiveURL={{{archiveurl|}}}
|ArchiveDate={{{archivedate|}}}
|DeadURL={{{deadurl|}}}
|format={{{format|}}}

|Periodical={{{work|{{{journal|{{{newspaper|{{{magazine|{{{periodical|}}}}}}}}}}}}}}}
|Issue={{{issue|{{{number|}}}}}}
|TitleNote={{{department|}}}

|At={{#if: {{{journal|{{{periodical|{{{magazine|{{{work|}}}}}}}}}}}}
        |{{{page|{{{pages|{{{at|}}}}}}}}}
          |{{#if: {{{page|}}}|{{#if:{{{nopp|}}}||p.&amp;nbsp;}}{{{page}}}
            |{{#if: {{{pages|}}}|{{#if:{{{nopp|}}}||pp.&amp;nbsp;}}{{{pages}}}
              |{{{at|}}} }} }} }}

|Edition={{{edition|}}}
|Series={{{series|{{{version|}}}}}}
|Volume={{{volume|}}}

|Publisher={{{publisher|}}}
|Place={{{location|{{{place|}}}}}}
|PublicationPlace={{{location|{{{place|{{{publication-place|}}}}}}}}}
|PublicationDate={{{publication-date|}}}

|EditorSurname1={{{editor-last|{{{editor1-last|{{{editor|{{{editors|{{{editor-surname|{{{editor1-surname|}}}}}}}}}}}}}}}}}}
|EditorSurname2={{{editor2-last|{{{editor2-surname|}}}}}}
|EditorSurname3={{{editor3-last|{{{editor3-surname|}}}}}}
|EditorSurname4={{{editor4-last|{{{editor4-surname|}}}}}}
|EditorGiven1={{{editor-first|{{{editor1-first|{{{editor-given|{{{editor1-given|}}}}}}}}}}}}
|EditorGiven2={{{editor2-first|{{{editor2-given|}}}}}}
|EditorGiven3={{{editor3-first|{{{editor3-given|}}}}}}
|EditorGiven4={{{editor4-first|{{{editor4-given|}}}}}}
|Editorlink1={{{editor-link|{{{editor1-link|}}}}}}
|Editorlink2={{{editor2-link|}}}
|Editorlink3={{{editor3-link|}}}
|Editorlink4={{{editor4-link|}}}

|ARXIV={{{arxiv|}}}
|ASIN={{{asin|{{{ASIN|}}}}}}
|ASIN-TLD={{{asin-tld|}}}
|BIBCODE={{{bibcode|}}}
|DOI={{{doi|{{{DOI|}}}}}}
|DoiBroken={{{doi_brokendate|{{{doi_inactivedate|}}}}}}
|ISBN={{{isbn|{{{ISBN|}}}}}}
|ISSN={{{issn|{{{ISSN|}}}}}}
|JFM={{{jfm|{{{JFM|}}}}}}
|JSTOR={{{jstor|{{{JSTOR|}}}}}}
|LCCN={{{lccn|{{{LCCN|}}}}}}
|MR={{{mr|{{{MR|}}}}}}
|OCLC={{{oclc|{{{OCLC|}}}}}}
|OL={{{ol|{{{OL|}}}}}}
|OSTI={{{osti|{{{OSTI|}}}}}}
|PMC={{{pmc|{{{PMC|}}}}}}
|PMID={{{pmid|{{{PMID|}}}}}}
|RFC={{{rfc|{{{RFC|}}}}}}
|SSRN={{{ssrn|{{{SSRN|}}}}}}
|ZBL={{{zbl|}}}
|ID={{{id|{{{ID|}}}}}}

|laysummary={{{laysummary|}}}
|laydate={{{laydate|}}}
|laysource={{{laysource|}}}

|quote={{{quote|}}}

|Ref={{{ref|}}}

|amp={{{lastauthoramp|}}}
|AuthorMask={{{author-mask|{{{authormask|}}}}}}
|AuthorSep={{#ifeq:{{{author-separator|}}}|;|&amp;#059;|{{{author-separator|&amp;#059;}}}}}&amp;#32;
|NameSep={{{author-name-separator|,}}}&amp;#32;
|PS={{#if:{{{quote|}}}||{{{postscript|.}}}}}
|Sep={{#ifeq:{{{separator|{{{seperator}}} }}}|;|&amp;#059;|{{{separator|{{{seperator|.}}} }}} }}
|template doc demo={{{template doc demo|}}}
|Trunc={{#if:{{{display-authors|}}}|{{{display-authors}}}|8}}
}}{{#if:{{{access-date|}}}{{{accessdaymonth|}}}{{{accessday|}}}{{{accessmonthday|}}}{{{accessmonth|}}}{{{accessyear|}}}{{{dateformat|}}}{{{day|}}}{{{doilabel|}}}
|[[Category:Pages containing cite templates with deprecated parameters|{{NAMESPACE}} {{PAGENAME}}]]}}&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>forh6piibxq4m8hj5n18ehyp7fgwofn</sha1>
    </revision>
    <revision>
      <id>1979</id>
      <parentid>1978</parentid>
      <timestamp>2016-11-09T15:28:38Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <origin>1979</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5663" sha1="m8mknkhq41rx44lgnkqy1ae44mu9kyg" xml:space="preserve">{{Wp/nd/Citation/core
|Citation class=Journal

|Surname1={{{last|{{{last1|{{{author|{{{author1|{{{authors|{{{surname|{{{surname1|}}}}}}}}}}}}}}}}}}}}}
|Surname2={{{last2|{{{author2|{{{surname2|}}}}}}}}}
|Surname3={{{last3|{{{author3|{{{surname3|}}}}}}}}}
|Surname4={{{last4|{{{author4|{{{surname4|}}}}}}}}}
|Surname5={{{last5|{{{author5|{{{surname5|}}}}}}}}}
|Surname6={{{last6|{{{author6|{{{surname6|}}}}}}}}}
|Surname7={{{last7|{{{author7|{{{surname7|}}}}}}}}}
|Surname8={{{last8|{{{author8|{{{surname8|}}}}}}}}}
|Surname9={{{last9|{{{author9|{{{surname9|}}}}}}}}}

|Given1={{{first|{{{first1|{{{given|{{{given1|}}}}}}}}}}}}
|Given2={{{first2|{{{given2|}}}}}}
|Given3={{{first3|{{{given3|}}}}}}
|Given4={{{first4|{{{given4|}}}}}}
|Given5={{{first5|{{{given5|}}}}}}
|Given6={{{first6|{{{given6|}}}}}}
|Given7={{{first7|{{{given7|}}}}}}
|Given8={{{first8|{{{given8|}}}}}}
|Given9={{{first9|{{{given9|}}}}}}

|Authorlink1={{{authorlink|{{{authorlink1|{{{author-link|{{{author1-link|}}}}}}}}}}}}
|Authorlink2={{{authorlink2|{{{author2-link|}}}}}}
|Authorlink3={{{authorlink3|{{{author3-link|}}}}}}
|Authorlink4={{{authorlink4|{{{author4-link|}}}}}}
|Authorlink5={{{authorlink5|{{{author5-link|}}}}}}
|Authorlink6={{{authorlink6|{{{author6-link|}}}}}}
|Authorlink7={{{authorlink7|{{{author7-link|}}}}}}
|Authorlink8={{{authorlink8|{{{author8-link|}}}}}}
|Authorlink9={{{authorlink9|{{{author9-link|}}}}}}

|Coauthors={{{coauthors|{{{coauthor|}}}}}}

|Other={{{others|}}}

|Year={{{year|{{    &lt;!-- attempt to derive year from date, if possible --&gt;
           #if: {{{date|}}}
           |{{
              #iferror:{{#time:Y|{{{date|}}} }}
              |{{#iferror:{{#time:Y|{{{publication-date|einval}}} }}||{{#time:Y|{{{publication-date|}}} }}}}
              |{{#time:Y|{{{date|}}} }}
            }}
           |{{{publication-date|}}} &lt;!-- last resort --&gt;
         }}
      }}}
|YearNote={{{origyear|}}}
|Date={{#if:{{{date|}}}|{{{date}}}|{{{day|}}} {{{month|}}} {{{year|{{{publication-date|}}}}}}}}

|Title={{{title|}}}
|TransTitle={{{trans_title|}}}
|IncludedWorkTitle={{{chapter|{{{contribution|}}}}}}
|TitleType={{{type|}}}
|language={{{language|}}}

|URL={{#if:{{{archiveurl|}}}
      |{{#ifeq: {{{deadurl|}}} | no | {{{url|}}} | {{{archiveurl|}}} }}
      |{{#if:{{{url|}}}
        |{{{url}}}
        |{{#if:{{{pmc|{{{PMC|}}}}}}
          |{{#ifexpr:{{#time: U}} &gt; {{#time: U | {{{Embargo|2001-10-10}}} }}
            |{{Wp/nd/hide in print|1=//www.ncbi.nlm.nih.gov/pmc/articles/PMC{{{pmc|{{{PMC|}}}}}}/}}
           }}
         }}
       }}
     }}
|IncludedWorkURL={{{chapter-url|{{{chapterurl|{{{contribution-url|}}}}}}}}}
|AccessDate={{{accessdate|}}}
|OriginalURL={{{url|}}}
|ArchiveURL={{{archiveurl|}}}
|ArchiveDate={{{archivedate|}}}
|DeadURL={{{deadurl|}}}
|format={{{format|}}}

|Periodical={{{work|{{{journal|{{{newspaper|{{{magazine|{{{periodical|}}}}}}}}}}}}}}}
|Issue={{{issue|{{{number|}}}}}}
|TitleNote={{{department|}}}

|At={{#if: {{{journal|{{{periodical|{{{magazine|{{{work|}}}}}}}}}}}}
        |{{{page|{{{pages|{{{at|}}}}}}}}}
          |{{#if: {{{page|}}}|{{#if:{{{nopp|}}}||p.&amp;nbsp;}}{{{page}}}
            |{{#if: {{{pages|}}}|{{#if:{{{nopp|}}}||pp.&amp;nbsp;}}{{{pages}}}
              |{{{at|}}} }} }} }}

|Edition={{{edition|}}}
|Series={{{series|{{{version|}}}}}}
|Volume={{{volume|}}}

|Publisher={{{publisher|}}}
|Place={{{location|{{{place|}}}}}}
|PublicationPlace={{{location|{{{place|{{{publication-place|}}}}}}}}}
|PublicationDate={{{publication-date|}}}

|EditorSurname1={{{editor-last|{{{editor1-last|{{{editor|{{{editors|{{{editor-surname|{{{editor1-surname|}}}}}}}}}}}}}}}}}}
|EditorSurname2={{{editor2-last|{{{editor2-surname|}}}}}}
|EditorSurname3={{{editor3-last|{{{editor3-surname|}}}}}}
|EditorSurname4={{{editor4-last|{{{editor4-surname|}}}}}}
|EditorGiven1={{{editor-first|{{{editor1-first|{{{editor-given|{{{editor1-given|}}}}}}}}}}}}
|EditorGiven2={{{editor2-first|{{{editor2-given|}}}}}}
|EditorGiven3={{{editor3-first|{{{editor3-given|}}}}}}
|EditorGiven4={{{editor4-first|{{{editor4-given|}}}}}}
|Editorlink1={{{editor-link|{{{editor1-link|}}}}}}
|Editorlink2={{{editor2-link|}}}
|Editorlink3={{{editor3-link|}}}
|Editorlink4={{{editor4-link|}}}

|ARXIV={{{arxiv|}}}
|ASIN={{{asin|{{{ASIN|}}}}}}
|ASIN-TLD={{{asin-tld|}}}
|BIBCODE={{{bibcode|}}}
|DOI={{{doi|{{{DOI|}}}}}}
|DoiBroken={{{doi_brokendate|{{{doi_inactivedate|}}}}}}
|ISBN={{{isbn|{{{ISBN|}}}}}}
|ISSN={{{issn|{{{ISSN|}}}}}}
|JFM={{{jfm|{{{JFM|}}}}}}
|JSTOR={{{jstor|{{{JSTOR|}}}}}}
|LCCN={{{lccn|{{{LCCN|}}}}}}
|MR={{{mr|{{{MR|}}}}}}
|OCLC={{{oclc|{{{OCLC|}}}}}}
|OL={{{ol|{{{OL|}}}}}}
|OSTI={{{osti|{{{OSTI|}}}}}}
|PMC={{{pmc|{{{PMC|}}}}}}
|PMID={{{pmid|{{{PMID|}}}}}}
|RFC={{{rfc|{{{RFC|}}}}}}
|SSRN={{{ssrn|{{{SSRN|}}}}}}
|ZBL={{{zbl|}}}
|ID={{{id|{{{ID|}}}}}}

|laysummary={{{laysummary|}}}
|laydate={{{laydate|}}}
|laysource={{{laysource|}}}

|quote={{{quote|}}}

|Ref={{{ref|}}}

|amp={{{lastauthoramp|}}}
|AuthorMask={{{author-mask|{{{authormask|}}}}}}
|AuthorSep={{#ifeq:{{{author-separator|}}}|;|&amp;#059;|{{{author-separator|&amp;#059;}}}}}&amp;#32;
|NameSep={{{author-name-separator|,}}}&amp;#32;
|PS={{#if:{{{quote|}}}||{{{postscript|.}}}}}
|Sep={{#ifeq:{{{separator|{{{seperator}}} }}}|;|&amp;#059;|{{{separator|{{{seperator|.}}} }}} }}
|template doc demo={{{template doc demo|}}}
|Trunc={{#if:{{{display-authors|}}}|{{{display-authors}}}|8}}
}}{{#if:{{{access-date|}}}{{{accessdaymonth|}}}{{{accessday|}}}{{{accessmonthday|}}}{{{accessmonth|}}}{{{accessyear|}}}{{{dateformat|}}}{{{day|}}}{{{doilabel|}}}
|[[Category:Pages containing cite templates with deprecated parameters|{{NAMESPACE}} {{PAGENAME}}]]}}&lt;noinclude&gt;
{{Wp/nd/documentation}}
&lt;/noinclude&gt;</text>
      <sha1>m8mknkhq41rx44lgnkqy1ae44mu9kyg</sha1>
    </revision>
    <revision>
      <id>1980</id>
      <parentid>1979</parentid>
      <timestamp>2024-11-18T17:41:43Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <minor />
      <comment>3 revisions imported from [[:incubator:Template:Wp/nd/Cite_journal]]</comment>
      <origin>1979</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5663" sha1="m8mknkhq41rx44lgnkqy1ae44mu9kyg" xml:space="preserve">{{Wp/nd/Citation/core
|Citation class=Journal

|Surname1={{{last|{{{last1|{{{author|{{{author1|{{{authors|{{{surname|{{{surname1|}}}}}}}}}}}}}}}}}}}}}
|Surname2={{{last2|{{{author2|{{{surname2|}}}}}}}}}
|Surname3={{{last3|{{{author3|{{{surname3|}}}}}}}}}
|Surname4={{{last4|{{{author4|{{{surname4|}}}}}}}}}
|Surname5={{{last5|{{{author5|{{{surname5|}}}}}}}}}
|Surname6={{{last6|{{{author6|{{{surname6|}}}}}}}}}
|Surname7={{{last7|{{{author7|{{{surname7|}}}}}}}}}
|Surname8={{{last8|{{{author8|{{{surname8|}}}}}}}}}
|Surname9={{{last9|{{{author9|{{{surname9|}}}}}}}}}

|Given1={{{first|{{{first1|{{{given|{{{given1|}}}}}}}}}}}}
|Given2={{{first2|{{{given2|}}}}}}
|Given3={{{first3|{{{given3|}}}}}}
|Given4={{{first4|{{{given4|}}}}}}
|Given5={{{first5|{{{given5|}}}}}}
|Given6={{{first6|{{{given6|}}}}}}
|Given7={{{first7|{{{given7|}}}}}}
|Given8={{{first8|{{{given8|}}}}}}
|Given9={{{first9|{{{given9|}}}}}}

|Authorlink1={{{authorlink|{{{authorlink1|{{{author-link|{{{author1-link|}}}}}}}}}}}}
|Authorlink2={{{authorlink2|{{{author2-link|}}}}}}
|Authorlink3={{{authorlink3|{{{author3-link|}}}}}}
|Authorlink4={{{authorlink4|{{{author4-link|}}}}}}
|Authorlink5={{{authorlink5|{{{author5-link|}}}}}}
|Authorlink6={{{authorlink6|{{{author6-link|}}}}}}
|Authorlink7={{{authorlink7|{{{author7-link|}}}}}}
|Authorlink8={{{authorlink8|{{{author8-link|}}}}}}
|Authorlink9={{{authorlink9|{{{author9-link|}}}}}}

|Coauthors={{{coauthors|{{{coauthor|}}}}}}

|Other={{{others|}}}

|Year={{{year|{{    &lt;!-- attempt to derive year from date, if possible --&gt;
           #if: {{{date|}}}
           |{{
              #iferror:{{#time:Y|{{{date|}}} }}
              |{{#iferror:{{#time:Y|{{{publication-date|einval}}} }}||{{#time:Y|{{{publication-date|}}} }}}}
              |{{#time:Y|{{{date|}}} }}
            }}
           |{{{publication-date|}}} &lt;!-- last resort --&gt;
         }}
      }}}
|YearNote={{{origyear|}}}
|Date={{#if:{{{date|}}}|{{{date}}}|{{{day|}}} {{{month|}}} {{{year|{{{publication-date|}}}}}}}}

|Title={{{title|}}}
|TransTitle={{{trans_title|}}}
|IncludedWorkTitle={{{chapter|{{{contribution|}}}}}}
|TitleType={{{type|}}}
|language={{{language|}}}

|URL={{#if:{{{archiveurl|}}}
      |{{#ifeq: {{{deadurl|}}} | no | {{{url|}}} | {{{archiveurl|}}} }}
      |{{#if:{{{url|}}}
        |{{{url}}}
        |{{#if:{{{pmc|{{{PMC|}}}}}}
          |{{#ifexpr:{{#time: U}} &gt; {{#time: U | {{{Embargo|2001-10-10}}} }}
            |{{Wp/nd/hide in print|1=//www.ncbi.nlm.nih.gov/pmc/articles/PMC{{{pmc|{{{PMC|}}}}}}/}}
           }}
         }}
       }}
     }}
|IncludedWorkURL={{{chapter-url|{{{chapterurl|{{{contribution-url|}}}}}}}}}
|AccessDate={{{accessdate|}}}
|OriginalURL={{{url|}}}
|ArchiveURL={{{archiveurl|}}}
|ArchiveDate={{{archivedate|}}}
|DeadURL={{{deadurl|}}}
|format={{{format|}}}

|Periodical={{{work|{{{journal|{{{newspaper|{{{magazine|{{{periodical|}}}}}}}}}}}}}}}
|Issue={{{issue|{{{number|}}}}}}
|TitleNote={{{department|}}}

|At={{#if: {{{journal|{{{periodical|{{{magazine|{{{work|}}}}}}}}}}}}
        |{{{page|{{{pages|{{{at|}}}}}}}}}
          |{{#if: {{{page|}}}|{{#if:{{{nopp|}}}||p.&amp;nbsp;}}{{{page}}}
            |{{#if: {{{pages|}}}|{{#if:{{{nopp|}}}||pp.&amp;nbsp;}}{{{pages}}}
              |{{{at|}}} }} }} }}

|Edition={{{edition|}}}
|Series={{{series|{{{version|}}}}}}
|Volume={{{volume|}}}

|Publisher={{{publisher|}}}
|Place={{{location|{{{place|}}}}}}
|PublicationPlace={{{location|{{{place|{{{publication-place|}}}}}}}}}
|PublicationDate={{{publication-date|}}}

|EditorSurname1={{{editor-last|{{{editor1-last|{{{editor|{{{editors|{{{editor-surname|{{{editor1-surname|}}}}}}}}}}}}}}}}}}
|EditorSurname2={{{editor2-last|{{{editor2-surname|}}}}}}
|EditorSurname3={{{editor3-last|{{{editor3-surname|}}}}}}
|EditorSurname4={{{editor4-last|{{{editor4-surname|}}}}}}
|EditorGiven1={{{editor-first|{{{editor1-first|{{{editor-given|{{{editor1-given|}}}}}}}}}}}}
|EditorGiven2={{{editor2-first|{{{editor2-given|}}}}}}
|EditorGiven3={{{editor3-first|{{{editor3-given|}}}}}}
|EditorGiven4={{{editor4-first|{{{editor4-given|}}}}}}
|Editorlink1={{{editor-link|{{{editor1-link|}}}}}}
|Editorlink2={{{editor2-link|}}}
|Editorlink3={{{editor3-link|}}}
|Editorlink4={{{editor4-link|}}}

|ARXIV={{{arxiv|}}}
|ASIN={{{asin|{{{ASIN|}}}}}}
|ASIN-TLD={{{asin-tld|}}}
|BIBCODE={{{bibcode|}}}
|DOI={{{doi|{{{DOI|}}}}}}
|DoiBroken={{{doi_brokendate|{{{doi_inactivedate|}}}}}}
|ISBN={{{isbn|{{{ISBN|}}}}}}
|ISSN={{{issn|{{{ISSN|}}}}}}
|JFM={{{jfm|{{{JFM|}}}}}}
|JSTOR={{{jstor|{{{JSTOR|}}}}}}
|LCCN={{{lccn|{{{LCCN|}}}}}}
|MR={{{mr|{{{MR|}}}}}}
|OCLC={{{oclc|{{{OCLC|}}}}}}
|OL={{{ol|{{{OL|}}}}}}
|OSTI={{{osti|{{{OSTI|}}}}}}
|PMC={{{pmc|{{{PMC|}}}}}}
|PMID={{{pmid|{{{PMID|}}}}}}
|RFC={{{rfc|{{{RFC|}}}}}}
|SSRN={{{ssrn|{{{SSRN|}}}}}}
|ZBL={{{zbl|}}}
|ID={{{id|{{{ID|}}}}}}

|laysummary={{{laysummary|}}}
|laydate={{{laydate|}}}
|laysource={{{laysource|}}}

|quote={{{quote|}}}

|Ref={{{ref|}}}

|amp={{{lastauthoramp|}}}
|AuthorMask={{{author-mask|{{{authormask|}}}}}}
|AuthorSep={{#ifeq:{{{author-separator|}}}|;|&amp;#059;|{{{author-separator|&amp;#059;}}}}}&amp;#32;
|NameSep={{{author-name-separator|,}}}&amp;#32;
|PS={{#if:{{{quote|}}}||{{{postscript|.}}}}}
|Sep={{#ifeq:{{{separator|{{{seperator}}} }}}|;|&amp;#059;|{{{separator|{{{seperator|.}}} }}} }}
|template doc demo={{{template doc demo|}}}
|Trunc={{#if:{{{display-authors|}}}|{{{display-authors}}}|8}}
}}{{#if:{{{access-date|}}}{{{accessdaymonth|}}}{{{accessday|}}}{{{accessmonthday|}}}{{{accessmonth|}}}{{{accessyear|}}}{{{dateformat|}}}{{{day|}}}{{{doilabel|}}}
|[[Category:Pages containing cite templates with deprecated parameters|{{NAMESPACE}} {{PAGENAME}}]]}}&lt;noinclude&gt;
{{Wp/nd/documentation}}
&lt;/noinclude&gt;</text>
      <sha1>m8mknkhq41rx44lgnkqy1ae44mu9kyg</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Wp/nd/Cite news</title>
    <ns>10</ns>
    <id>377</id>
    <revision>
      <id>1981</id>
      <timestamp>2016-11-09T15:35:56Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>[[:en:Template:Citation news]]</comment>
      <origin>1981</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4633" sha1="3hvod94ipl25icm05e6tnyvuyi6gr4k" xml:space="preserve">{{Wp/nd/citation/core
|Citation class=news

|Surname1={{{last|{{{last1|{{{author|{{{author1|{{{authors|{{{surname|{{{surname1|}}}}}}}}}}}}}}}}}}}}}
|Surname2={{{last2|{{{author2|{{{surname2|}}}}}}}}}
|Surname3={{{last3|{{{author3|{{{surname3|}}}}}}}}}
|Surname4={{{last4|{{{author4|{{{surname4|}}}}}}}}}
|Surname5={{{last5|{{{author5|{{{surname5|}}}}}}}}}
|Surname6={{{last6|{{{author6|{{{surname6|}}}}}}}}}
|Surname7={{{last7|{{{author7|{{{surname7|}}}}}}}}}
|Surname8={{{last8|{{{author8|{{{surname8|}}}}}}}}}
|Surname9={{{last9|{{{author9|{{{surname9|}}}}}}}}}

|Given1={{{first|{{{first1|{{{given|{{{given1|}}}}}}}}}}}}
|Given2={{{first2|{{{given2|}}}}}}
|Given3={{{first3|{{{given3|}}}}}}
|Given4={{{first4|{{{given4|}}}}}}
|Given5={{{first5|{{{given5|}}}}}}
|Given6={{{first6|{{{given6|}}}}}}
|Given7={{{first7|{{{given7|}}}}}}
|Given8={{{first8|{{{given8|}}}}}}
|Given9={{{first9|{{{given9|}}}}}}

|Authorlink1={{{authorlink|{{{authorlink1|{{{author-link|{{{author1-link|}}}}}}}}}}}}
|Authorlink2={{{authorlink2|{{{author2-link|}}}}}}
|Authorlink3={{{authorlink3|{{{author3-link|}}}}}}
|Authorlink4={{{authorlink4|{{{author4-link|}}}}}}
|Authorlink5={{{authorlink5|{{{author5-link|}}}}}}
|Authorlink6={{{authorlink6|{{{author6-link|}}}}}}
|Authorlink7={{{authorlink7|{{{author7-link|}}}}}}
|Authorlink8={{{authorlink8|{{{author8-link|}}}}}}
|Authorlink9={{{authorlink9|{{{author9-link|}}}}}}

|Coauthors={{{coauthors|{{{coauthor|}}}}}}

|Year={{{year|{{    &lt;!-- attempt to derive year from date, if possible --&gt;
           #if: {{{date|}}}
           |{{
              #iferror:{{#time:Y|{{{date|}}} }}
              |{{#iferror:{{#time:Y|{{{publication-date|einval}}} }}||{{#time:Y|{{{publication-date|}}} }}}}
              |{{#time:Y|{{{date|}}} }}
            }}
           |{{{publication-date|}}} &lt;!-- last resort --&gt;
         }}
      }}}
|YearNote={{{origyear|}}}
|Date={{#if:{{{date|}}}|{{{date}}}|{{{day|}}} {{{month|}}} {{{year|{{{publication-date|}}}}}}}}

|Title={{#if:{{{journal|{{{periodical|{{{newspaper|{{{magazine|{{{work|}}}}}}}}}}}}}}}|{{{title|}}}}}
|TransTitle={{{trans_title|}}}
|IncludedWorkTitle={{#if:{{{work|{{{journal|{{{newspaper|{{{magazine|{{{periodical|}}}}}}}}}}}}}}}||{{{title|}}}}}
|language={{{language|}}}

|URL={{#if:{{{archiveurl|}}}
       |{{#ifeq: {{{deadurl|}}} | no | {{{url|}}} | {{{archiveurl|}}}}}
       |{{{url|}}}
     }}
|IncludedWorkURL={{{chapter-url|{{{chapterurl|{{{contribution-url|}}}}}}}}}
|AccessDate={{{accessdate|}}}
|OriginalURL={{{url|}}}
|ArchiveURL={{{archiveurl|}}}
|ArchiveDate={{{archivedate|}}}
|DeadURL={{{deadurl|}}}
|format={{{format|}}}

|Periodical={{{work|{{{journal|{{{newspaper|{{{magazine|{{{periodical|}}}}}}}}}}}}}}}
|Issue={{{issue|{{{number|}}}}}}
|TitleNote={{{department|}}}

|At={{#if: {{{page|}}}|{{#if:{{{nopp|}}}||p.&amp;nbsp;}}{{{page}}}
      |{{#if: {{{pages|}}}|{{#if:{{{nopp|}}}||pp.&amp;nbsp;}}{{{pages}}}
      |{{{at|}}}}}
    }}

|Edition={{{edition|}}}
|Series={{{agency|}}}
|Volume={{{volume|}}}

|Publisher={{{publisher|}}}
|Place={{{location|{{{place|}}}}}}
|PublicationPlace={{{location|{{{place|{{{publication-place|}}}}}}}}}
|PublicationDate={{{publication-date|}}}

|ARXIV={{{arxiv|}}}
|ASIN={{{asin|{{{ASIN|}}}}}}
|ASIN-TLD={{{asin-tld|}}}
|BIBCODE={{{bibcode|}}}
|DOI={{{doi|{{{DOI|}}}}}}
|DoiBroken={{{doi_brokendate|{{{doi_inactivedate|}}}}}}
|ISBN={{{isbn|{{{ISBN|}}}}}}
|ISSN={{{issn|{{{ISSN|}}}}}}
|JFM={{{jfm|{{{JFM|}}}}}}
|JSTOR={{{jstor|{{{JSTOR|}}}}}}
|LCCN={{{lccn|{{{LCCN|}}}}}}
|MR={{{mr|{{{MR|}}}}}}
|OCLC={{{oclc|{{{OCLC|}}}}}}
|OL={{{ol|{{{OL|}}}}}}
|OSTI={{{osti|{{{OSTI|}}}}}}
|PMC={{{pmc|{{{PMC|}}}}}}
|PMID={{{pmid|{{{PMID|}}}}}}
|RFC={{{rfc|{{{RFC|}}}}}}
|SSRN={{{ssrn|{{{SSRN|}}}}}}
|ZBL={{{zbl|}}}
|ID={{{id|{{{ID|}}}}}}

|laysummary={{{laysummary|}}}
|laydate={{{laydate|}}}
|laysource={{{laysource|}}}

|quote={{{quote|}}}

|Ref={{{ref|}}}

|amp={{{lastauthoramp|}}}
|AuthorMask={{{author-mask|{{{authormask|}}}}}}
|AuthorSep={{#ifeq:{{{author-separator|}}}|;|&amp;#059;|{{{author-separator|&amp;#059;}}}}}&amp;#32;
|NameSep={{{author-name-separator|,}}}&amp;#32;
|PS={{#if:{{{quote|}}}||{{{postscript|.}}}}}
|Sep={{#ifeq:{{{separator|{{{seperator}}} }}}|;|&amp;#059;|{{{separator|{{{seperator|.}}} }}} }}
|template doc demo={{{template doc demo|}}}
|Trunc={{#if:{{{display-authors|}}}|{{{display-authors}}}|8}}
}}{{#if:{{{access-date|}}}{{{accessdaymonth|}}}{{{accessday|}}}{{{accessmonthday|}}}{{{accessmonth|}}}{{{accessyear|}}}{{{dateformat|}}}{{{day|}}}{{{doilabel|}}}
|[[Category:Pages containing cite templates with deprecated parameters|{{NAMESPACE}} {{PAGENAME}}]]}}&lt;noinclude&gt;
{{Wp/nd/documentation}}
&lt;/noinclude&gt;</text>
      <sha1>3hvod94ipl25icm05e6tnyvuyi6gr4k</sha1>
    </revision>
    <revision>
      <id>1982</id>
      <parentid>1981</parentid>
      <timestamp>2016-11-09T15:36:03Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>CFCF moved page [[Template:Wp/nd/cite news]] to [[Template:Wp/nd/Cite news]]</comment>
      <origin>1981</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4633" sha1="3hvod94ipl25icm05e6tnyvuyi6gr4k" xml:space="preserve">{{Wp/nd/citation/core
|Citation class=news

|Surname1={{{last|{{{last1|{{{author|{{{author1|{{{authors|{{{surname|{{{surname1|}}}}}}}}}}}}}}}}}}}}}
|Surname2={{{last2|{{{author2|{{{surname2|}}}}}}}}}
|Surname3={{{last3|{{{author3|{{{surname3|}}}}}}}}}
|Surname4={{{last4|{{{author4|{{{surname4|}}}}}}}}}
|Surname5={{{last5|{{{author5|{{{surname5|}}}}}}}}}
|Surname6={{{last6|{{{author6|{{{surname6|}}}}}}}}}
|Surname7={{{last7|{{{author7|{{{surname7|}}}}}}}}}
|Surname8={{{last8|{{{author8|{{{surname8|}}}}}}}}}
|Surname9={{{last9|{{{author9|{{{surname9|}}}}}}}}}

|Given1={{{first|{{{first1|{{{given|{{{given1|}}}}}}}}}}}}
|Given2={{{first2|{{{given2|}}}}}}
|Given3={{{first3|{{{given3|}}}}}}
|Given4={{{first4|{{{given4|}}}}}}
|Given5={{{first5|{{{given5|}}}}}}
|Given6={{{first6|{{{given6|}}}}}}
|Given7={{{first7|{{{given7|}}}}}}
|Given8={{{first8|{{{given8|}}}}}}
|Given9={{{first9|{{{given9|}}}}}}

|Authorlink1={{{authorlink|{{{authorlink1|{{{author-link|{{{author1-link|}}}}}}}}}}}}
|Authorlink2={{{authorlink2|{{{author2-link|}}}}}}
|Authorlink3={{{authorlink3|{{{author3-link|}}}}}}
|Authorlink4={{{authorlink4|{{{author4-link|}}}}}}
|Authorlink5={{{authorlink5|{{{author5-link|}}}}}}
|Authorlink6={{{authorlink6|{{{author6-link|}}}}}}
|Authorlink7={{{authorlink7|{{{author7-link|}}}}}}
|Authorlink8={{{authorlink8|{{{author8-link|}}}}}}
|Authorlink9={{{authorlink9|{{{author9-link|}}}}}}

|Coauthors={{{coauthors|{{{coauthor|}}}}}}

|Year={{{year|{{    &lt;!-- attempt to derive year from date, if possible --&gt;
           #if: {{{date|}}}
           |{{
              #iferror:{{#time:Y|{{{date|}}} }}
              |{{#iferror:{{#time:Y|{{{publication-date|einval}}} }}||{{#time:Y|{{{publication-date|}}} }}}}
              |{{#time:Y|{{{date|}}} }}
            }}
           |{{{publication-date|}}} &lt;!-- last resort --&gt;
         }}
      }}}
|YearNote={{{origyear|}}}
|Date={{#if:{{{date|}}}|{{{date}}}|{{{day|}}} {{{month|}}} {{{year|{{{publication-date|}}}}}}}}

|Title={{#if:{{{journal|{{{periodical|{{{newspaper|{{{magazine|{{{work|}}}}}}}}}}}}}}}|{{{title|}}}}}
|TransTitle={{{trans_title|}}}
|IncludedWorkTitle={{#if:{{{work|{{{journal|{{{newspaper|{{{magazine|{{{periodical|}}}}}}}}}}}}}}}||{{{title|}}}}}
|language={{{language|}}}

|URL={{#if:{{{archiveurl|}}}
       |{{#ifeq: {{{deadurl|}}} | no | {{{url|}}} | {{{archiveurl|}}}}}
       |{{{url|}}}
     }}
|IncludedWorkURL={{{chapter-url|{{{chapterurl|{{{contribution-url|}}}}}}}}}
|AccessDate={{{accessdate|}}}
|OriginalURL={{{url|}}}
|ArchiveURL={{{archiveurl|}}}
|ArchiveDate={{{archivedate|}}}
|DeadURL={{{deadurl|}}}
|format={{{format|}}}

|Periodical={{{work|{{{journal|{{{newspaper|{{{magazine|{{{periodical|}}}}}}}}}}}}}}}
|Issue={{{issue|{{{number|}}}}}}
|TitleNote={{{department|}}}

|At={{#if: {{{page|}}}|{{#if:{{{nopp|}}}||p.&amp;nbsp;}}{{{page}}}
      |{{#if: {{{pages|}}}|{{#if:{{{nopp|}}}||pp.&amp;nbsp;}}{{{pages}}}
      |{{{at|}}}}}
    }}

|Edition={{{edition|}}}
|Series={{{agency|}}}
|Volume={{{volume|}}}

|Publisher={{{publisher|}}}
|Place={{{location|{{{place|}}}}}}
|PublicationPlace={{{location|{{{place|{{{publication-place|}}}}}}}}}
|PublicationDate={{{publication-date|}}}

|ARXIV={{{arxiv|}}}
|ASIN={{{asin|{{{ASIN|}}}}}}
|ASIN-TLD={{{asin-tld|}}}
|BIBCODE={{{bibcode|}}}
|DOI={{{doi|{{{DOI|}}}}}}
|DoiBroken={{{doi_brokendate|{{{doi_inactivedate|}}}}}}
|ISBN={{{isbn|{{{ISBN|}}}}}}
|ISSN={{{issn|{{{ISSN|}}}}}}
|JFM={{{jfm|{{{JFM|}}}}}}
|JSTOR={{{jstor|{{{JSTOR|}}}}}}
|LCCN={{{lccn|{{{LCCN|}}}}}}
|MR={{{mr|{{{MR|}}}}}}
|OCLC={{{oclc|{{{OCLC|}}}}}}
|OL={{{ol|{{{OL|}}}}}}
|OSTI={{{osti|{{{OSTI|}}}}}}
|PMC={{{pmc|{{{PMC|}}}}}}
|PMID={{{pmid|{{{PMID|}}}}}}
|RFC={{{rfc|{{{RFC|}}}}}}
|SSRN={{{ssrn|{{{SSRN|}}}}}}
|ZBL={{{zbl|}}}
|ID={{{id|{{{ID|}}}}}}

|laysummary={{{laysummary|}}}
|laydate={{{laydate|}}}
|laysource={{{laysource|}}}

|quote={{{quote|}}}

|Ref={{{ref|}}}

|amp={{{lastauthoramp|}}}
|AuthorMask={{{author-mask|{{{authormask|}}}}}}
|AuthorSep={{#ifeq:{{{author-separator|}}}|;|&amp;#059;|{{{author-separator|&amp;#059;}}}}}&amp;#32;
|NameSep={{{author-name-separator|,}}}&amp;#32;
|PS={{#if:{{{quote|}}}||{{{postscript|.}}}}}
|Sep={{#ifeq:{{{separator|{{{seperator}}} }}}|;|&amp;#059;|{{{separator|{{{seperator|.}}} }}} }}
|template doc demo={{{template doc demo|}}}
|Trunc={{#if:{{{display-authors|}}}|{{{display-authors}}}|8}}
}}{{#if:{{{access-date|}}}{{{accessdaymonth|}}}{{{accessday|}}}{{{accessmonthday|}}}{{{accessmonth|}}}{{{accessyear|}}}{{{dateformat|}}}{{{day|}}}{{{doilabel|}}}
|[[Category:Pages containing cite templates with deprecated parameters|{{NAMESPACE}} {{PAGENAME}}]]}}&lt;noinclude&gt;
{{Wp/nd/documentation}}
&lt;/noinclude&gt;</text>
      <sha1>3hvod94ipl25icm05e6tnyvuyi6gr4k</sha1>
    </revision>
    <revision>
      <id>1983</id>
      <parentid>1982</parentid>
      <timestamp>2024-11-18T17:41:43Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <minor />
      <comment>2 revisions imported from [[:incubator:Template:Wp/nd/Cite_news]]</comment>
      <origin>1981</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4633" sha1="3hvod94ipl25icm05e6tnyvuyi6gr4k" xml:space="preserve">{{Wp/nd/citation/core
|Citation class=news

|Surname1={{{last|{{{last1|{{{author|{{{author1|{{{authors|{{{surname|{{{surname1|}}}}}}}}}}}}}}}}}}}}}
|Surname2={{{last2|{{{author2|{{{surname2|}}}}}}}}}
|Surname3={{{last3|{{{author3|{{{surname3|}}}}}}}}}
|Surname4={{{last4|{{{author4|{{{surname4|}}}}}}}}}
|Surname5={{{last5|{{{author5|{{{surname5|}}}}}}}}}
|Surname6={{{last6|{{{author6|{{{surname6|}}}}}}}}}
|Surname7={{{last7|{{{author7|{{{surname7|}}}}}}}}}
|Surname8={{{last8|{{{author8|{{{surname8|}}}}}}}}}
|Surname9={{{last9|{{{author9|{{{surname9|}}}}}}}}}

|Given1={{{first|{{{first1|{{{given|{{{given1|}}}}}}}}}}}}
|Given2={{{first2|{{{given2|}}}}}}
|Given3={{{first3|{{{given3|}}}}}}
|Given4={{{first4|{{{given4|}}}}}}
|Given5={{{first5|{{{given5|}}}}}}
|Given6={{{first6|{{{given6|}}}}}}
|Given7={{{first7|{{{given7|}}}}}}
|Given8={{{first8|{{{given8|}}}}}}
|Given9={{{first9|{{{given9|}}}}}}

|Authorlink1={{{authorlink|{{{authorlink1|{{{author-link|{{{author1-link|}}}}}}}}}}}}
|Authorlink2={{{authorlink2|{{{author2-link|}}}}}}
|Authorlink3={{{authorlink3|{{{author3-link|}}}}}}
|Authorlink4={{{authorlink4|{{{author4-link|}}}}}}
|Authorlink5={{{authorlink5|{{{author5-link|}}}}}}
|Authorlink6={{{authorlink6|{{{author6-link|}}}}}}
|Authorlink7={{{authorlink7|{{{author7-link|}}}}}}
|Authorlink8={{{authorlink8|{{{author8-link|}}}}}}
|Authorlink9={{{authorlink9|{{{author9-link|}}}}}}

|Coauthors={{{coauthors|{{{coauthor|}}}}}}

|Year={{{year|{{    &lt;!-- attempt to derive year from date, if possible --&gt;
           #if: {{{date|}}}
           |{{
              #iferror:{{#time:Y|{{{date|}}} }}
              |{{#iferror:{{#time:Y|{{{publication-date|einval}}} }}||{{#time:Y|{{{publication-date|}}} }}}}
              |{{#time:Y|{{{date|}}} }}
            }}
           |{{{publication-date|}}} &lt;!-- last resort --&gt;
         }}
      }}}
|YearNote={{{origyear|}}}
|Date={{#if:{{{date|}}}|{{{date}}}|{{{day|}}} {{{month|}}} {{{year|{{{publication-date|}}}}}}}}

|Title={{#if:{{{journal|{{{periodical|{{{newspaper|{{{magazine|{{{work|}}}}}}}}}}}}}}}|{{{title|}}}}}
|TransTitle={{{trans_title|}}}
|IncludedWorkTitle={{#if:{{{work|{{{journal|{{{newspaper|{{{magazine|{{{periodical|}}}}}}}}}}}}}}}||{{{title|}}}}}
|language={{{language|}}}

|URL={{#if:{{{archiveurl|}}}
       |{{#ifeq: {{{deadurl|}}} | no | {{{url|}}} | {{{archiveurl|}}}}}
       |{{{url|}}}
     }}
|IncludedWorkURL={{{chapter-url|{{{chapterurl|{{{contribution-url|}}}}}}}}}
|AccessDate={{{accessdate|}}}
|OriginalURL={{{url|}}}
|ArchiveURL={{{archiveurl|}}}
|ArchiveDate={{{archivedate|}}}
|DeadURL={{{deadurl|}}}
|format={{{format|}}}

|Periodical={{{work|{{{journal|{{{newspaper|{{{magazine|{{{periodical|}}}}}}}}}}}}}}}
|Issue={{{issue|{{{number|}}}}}}
|TitleNote={{{department|}}}

|At={{#if: {{{page|}}}|{{#if:{{{nopp|}}}||p.&amp;nbsp;}}{{{page}}}
      |{{#if: {{{pages|}}}|{{#if:{{{nopp|}}}||pp.&amp;nbsp;}}{{{pages}}}
      |{{{at|}}}}}
    }}

|Edition={{{edition|}}}
|Series={{{agency|}}}
|Volume={{{volume|}}}

|Publisher={{{publisher|}}}
|Place={{{location|{{{place|}}}}}}
|PublicationPlace={{{location|{{{place|{{{publication-place|}}}}}}}}}
|PublicationDate={{{publication-date|}}}

|ARXIV={{{arxiv|}}}
|ASIN={{{asin|{{{ASIN|}}}}}}
|ASIN-TLD={{{asin-tld|}}}
|BIBCODE={{{bibcode|}}}
|DOI={{{doi|{{{DOI|}}}}}}
|DoiBroken={{{doi_brokendate|{{{doi_inactivedate|}}}}}}
|ISBN={{{isbn|{{{ISBN|}}}}}}
|ISSN={{{issn|{{{ISSN|}}}}}}
|JFM={{{jfm|{{{JFM|}}}}}}
|JSTOR={{{jstor|{{{JSTOR|}}}}}}
|LCCN={{{lccn|{{{LCCN|}}}}}}
|MR={{{mr|{{{MR|}}}}}}
|OCLC={{{oclc|{{{OCLC|}}}}}}
|OL={{{ol|{{{OL|}}}}}}
|OSTI={{{osti|{{{OSTI|}}}}}}
|PMC={{{pmc|{{{PMC|}}}}}}
|PMID={{{pmid|{{{PMID|}}}}}}
|RFC={{{rfc|{{{RFC|}}}}}}
|SSRN={{{ssrn|{{{SSRN|}}}}}}
|ZBL={{{zbl|}}}
|ID={{{id|{{{ID|}}}}}}

|laysummary={{{laysummary|}}}
|laydate={{{laydate|}}}
|laysource={{{laysource|}}}

|quote={{{quote|}}}

|Ref={{{ref|}}}

|amp={{{lastauthoramp|}}}
|AuthorMask={{{author-mask|{{{authormask|}}}}}}
|AuthorSep={{#ifeq:{{{author-separator|}}}|;|&amp;#059;|{{{author-separator|&amp;#059;}}}}}&amp;#32;
|NameSep={{{author-name-separator|,}}}&amp;#32;
|PS={{#if:{{{quote|}}}||{{{postscript|.}}}}}
|Sep={{#ifeq:{{{separator|{{{seperator}}} }}}|;|&amp;#059;|{{{separator|{{{seperator|.}}} }}} }}
|template doc demo={{{template doc demo|}}}
|Trunc={{#if:{{{display-authors|}}}|{{{display-authors}}}|8}}
}}{{#if:{{{access-date|}}}{{{accessdaymonth|}}}{{{accessday|}}}{{{accessmonthday|}}}{{{accessmonth|}}}{{{accessyear|}}}{{{dateformat|}}}{{{day|}}}{{{doilabel|}}}
|[[Category:Pages containing cite templates with deprecated parameters|{{NAMESPACE}} {{PAGENAME}}]]}}&lt;noinclude&gt;
{{Wp/nd/documentation}}
&lt;/noinclude&gt;</text>
      <sha1>3hvod94ipl25icm05e6tnyvuyi6gr4k</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Wp/nd/ICD10</title>
    <ns>10</ns>
    <id>378</id>
    <revision>
      <id>1984</id>
      <timestamp>2016-11-08T21:12:39Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;[http://apps.who.int/classifications/icd10/browse/2016/en#/{{{1|}}}{{{2|}}}{{#if:{{{3|}}}|.{{{3}}}}} {{{1|}}}{{{2|}}}{{#if:{{{3|}}}|.{{{3}}}}}]&lt;noinclude&gt;  {{Documentation}} &lt;...&quot;</comment>
      <origin>1984</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="256" sha1="6o06v5elkjkgh32yst1sg0bl9rcpgxj" xml:space="preserve">[http://apps.who.int/classifications/icd10/browse/2016/en#/{{{1|}}}{{{2|}}}{{#if:{{{3|}}}|.{{{3}}}}} {{{1|}}}{{{2|}}}{{#if:{{{3|}}}|.{{{3}}}}}]&lt;noinclude&gt;

{{Documentation}}
&lt;!-- Add categories and interwikis to the /doc subpage, not here! --&gt;
&lt;/noinclude&gt;</text>
      <sha1>6o06v5elkjkgh32yst1sg0bl9rcpgxj</sha1>
    </revision>
    <revision>
      <id>1985</id>
      <parentid>1984</parentid>
      <timestamp>2019-12-02T12:36:58Z</timestamp>
      <contributor>
        <username>incubator&gt;Adithyak1997</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Added a prefix</comment>
      <origin>1985</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="262" sha1="4cyn4xqx1ygkdmyr9ww4lc6r5yr4fn0" xml:space="preserve">[http://apps.who.int/classifications/icd10/browse/2016/en#/{{{1|}}}{{{2|}}}{{#if:{{{3|}}}|.{{{3}}}}} {{{1|}}}{{{2|}}}{{#if:{{{3|}}}|.{{{3}}}}}]&lt;noinclude&gt;

{{Wp/nd/Documentation}}
&lt;!-- Add categories and interwikis to the /doc subpage, not here! --&gt;
&lt;/noinclude&gt;</text>
      <sha1>4cyn4xqx1ygkdmyr9ww4lc6r5yr4fn0</sha1>
    </revision>
    <revision>
      <id>1986</id>
      <parentid>1985</parentid>
      <timestamp>2024-11-18T17:41:44Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <minor />
      <comment>2 revisions imported from [[:incubator:Template:Wp/nd/ICD10]]</comment>
      <origin>1985</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="262" sha1="4cyn4xqx1ygkdmyr9ww4lc6r5yr4fn0" xml:space="preserve">[http://apps.who.int/classifications/icd10/browse/2016/en#/{{{1|}}}{{{2|}}}{{#if:{{{3|}}}|.{{{3}}}}} {{{1|}}}{{{2|}}}{{#if:{{{3|}}}|.{{{3}}}}}]&lt;noinclude&gt;

{{Wp/nd/Documentation}}
&lt;!-- Add categories and interwikis to the /doc subpage, not here! --&gt;
&lt;/noinclude&gt;</text>
      <sha1>4cyn4xqx1ygkdmyr9ww4lc6r5yr4fn0</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Wp/nd/ICD9</title>
    <ns>10</ns>
    <id>379</id>
    <revision>
      <id>1987</id>
      <timestamp>2016-11-08T21:12:53Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;[http://www.icd9data.com/getICD9Code.ashx?icd9={{{1}}} {{{1}}}]&lt;noinclude&gt; {{documentation}} &lt;/noinclude&gt;&quot;</comment>
      <origin>1987</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="105" sha1="inlm7lg4izfzyun1823ezel8jsddgvh" xml:space="preserve">[http://www.icd9data.com/getICD9Code.ashx?icd9={{{1}}} {{{1}}}]&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>inlm7lg4izfzyun1823ezel8jsddgvh</sha1>
    </revision>
    <revision>
      <id>1988</id>
      <parentid>1987</parentid>
      <timestamp>2019-12-03T10:17:20Z</timestamp>
      <contributor>
        <username>incubator&gt;Adithyak1997</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>Added a prefix</comment>
      <origin>1988</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="111" sha1="dl3k7t2u3h300d9r02go34wwj7l945x" xml:space="preserve">[http://www.icd9data.com/getICD9Code.ashx?icd9={{{1}}} {{{1}}}]&lt;noinclude&gt;
{{Wp/nd/Documentation}}
&lt;/noinclude&gt;</text>
      <sha1>dl3k7t2u3h300d9r02go34wwj7l945x</sha1>
    </revision>
    <revision>
      <id>1989</id>
      <parentid>1988</parentid>
      <timestamp>2024-11-18T17:41:44Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <minor />
      <comment>2 revisions imported from [[:incubator:Template:Wp/nd/ICD9]]</comment>
      <origin>1988</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="111" sha1="dl3k7t2u3h300d9r02go34wwj7l945x" xml:space="preserve">[http://www.icd9data.com/getICD9Code.ashx?icd9={{{1}}} {{{1}}}]&lt;noinclude&gt;
{{Wp/nd/Documentation}}
&lt;/noinclude&gt;</text>
      <sha1>dl3k7t2u3h300d9r02go34wwj7l945x</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Wp/nd/Infobox disease</title>
    <ns>10</ns>
    <id>380</id>
    <revision>
      <id>1990</id>
      <timestamp>2016-10-01T17:20:38Z</timestamp>
      <contributor>
        <username>incubator&gt;Doc James</username>
        <id>0</id>
      </contributor>
      <comment>Created page with &quot;&lt;div class=&quot;toc&quot; style=&quot;float:right;width:18em;padding:0.5em;margin:0 0 1em 1em;&quot;&gt; &lt;table style=&quot;width:100%;&quot;&gt; &lt;tr&gt;&lt;th colspan=&quot;2&quot;&gt;&lt;big&gt;{{{name|{{PAGENAME}}}}}&lt;/big&gt;&lt;/th&gt;&lt;/tr&gt;...&quot;</comment>
      <origin>1990</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5056" sha1="ei2cn4ngq4qq9e4b7in0bhvuokkyu5f" xml:space="preserve">&lt;div class=&quot;toc&quot; style=&quot;float:right;width:18em;padding:0.5em;margin:0 0 1em 1em;&quot;&gt;
&lt;table style=&quot;width:100%;&quot;&gt;
&lt;tr&gt;&lt;th colspan=&quot;2&quot;&gt;&lt;big&gt;{{{name|{{PAGENAME}}}}}&lt;/big&gt;&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align:center;&quot;&gt;''Ukuhlukaniswa kweengaba neentlabagelo zangaphandle''&lt;!--''Classification and external resources''--&gt;&lt;/td&gt;&lt;/tr&gt;
{{#if:{{{image|}}}|&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align:center;&quot;&gt;[[File:{{{image|}}}{{{Image|}}}|150px|center|{{{caption|{{{name|{{PAGENAME}}}}}}}}]] &lt;small&gt;{{{caption|}}}{{{Caption|}}}&lt;/small&gt;&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{ICD10|}}}|&lt;tr&gt;&lt;td&gt;'''ICD/CIM-10'''&lt;/td&gt;&lt;td&gt;{{{ICD10|}}} {{{ICD10}}}{{#if:{{{ICD10-2|}}}|{{{ICD10-2|}}} {{{ICD10-2}}}|}}&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{ICD9|}}}|&lt;tr&gt;&lt;td&gt;'''ICD/CIM-9'''&lt;/td&gt;&lt;td&gt;{{{ICD9|}}} {{{ICD9}}}&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{OMIM|}}}|&lt;tr&gt;&lt;td&gt;'''OMIM'''&lt;/td&gt;&lt;td&gt;[http://omim.org/entry/{{{OMIM|}}} {{{OMIM}}}]&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{DiseasesDB|}}}|&lt;tr&gt;&lt;td&gt;'''DiseasesDB'''&lt;/td&gt;&lt;td&gt;[http://www.diseasesdatabase.com/ddb{{{DiseasesDB|}}}.htm {{{DiseasesDB}}}]{{#if:{{{DiseasesDB-2|}}}|, [http://www.diseasesdatabase.com/ddb{{{DiseasesDB-2|}}}.htm {{{DiseasesDB-2}}}]|}}&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{MedlinePlus|}}}|&lt;tr&gt;&lt;td&gt;'''MedlinePlus'''&lt;/td&gt;&lt;td&gt;[http://www.nlm.nih.gov/medlineplus/ency/article/{{{MedlinePlus|}}}.htm {{{MedlinePlus}}}]&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{eMedicine|}}}|&lt;tr&gt;&lt;td&gt;'''eMedicine'''&lt;/td&gt;&lt;td&gt;''&amp;lt;Placeholder&amp;gt;''&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{MeSH|}}}|&lt;tr&gt;&lt;td&gt;'''MeSH'''&lt;/td&gt;&lt;td&gt;[http://www.nlm.nih.gov/cgi/mesh/2014/MB_cgi?field=uid&amp;term={{{MeSH}}} {{{MeSH}}}]&lt;/td&gt;&lt;/tr&gt;|}}
&lt;/table&gt;
&lt;/div&gt;&lt;!--

{{ infobox
| abovestyle = background-color: {{{background|{{{Background|lightgrey}}}}}}
| above      = {{{name|{{{Name|&lt;includeonly&gt;{{PAGENAME}}&lt;/includeonly&gt;}}}}}}
| subheader  = &lt;includeonly&gt;''Classification and external resources''&lt;/includeonly&gt;
| image      = {{#invoke:InfoboxImage|InfoboxImage|image={{{image|}}}{{{Image|}}}|size={{{image_size|{{{Width|}}}}}}|sizedefault=frameless|upright=1.06|alt={{{alt|}}}{{{Alt|}}}}}
| caption    = {{{caption|}}}{{{Caption|}}}

| label1     = [[Wp/nr/International Statistical Classification of Diseases and Related Health Problems|ICD]]-[[Wp/nr/ICD-10|10]]
| data1      = {{{ICD10|}}}

| label2     = [[Wp/nr/International Statistical Classification of Diseases and Related Health Problems|ICD]]-[[Wp/nr/List of ICD-9 codes|9]]
| data2      = {{{ICD9|}}}

| label3     = [[International Classification of Diseases for Oncology|ICD-O:]]
| data3      = {{{ICDO|}}}

| label4     = [[Wp/nr/OMIM|OMIM]]
| data4      = {{#if:{{{OMIM|}}}|[http://omim.org/entry/{{{OMIM}}} {{{OMIM}}}] {{{OMIM_mult|}}} }}

| label5     = [[Wp/nr/Diseases Database|DiseasesDB]]
| data5      = {{#if:{{{DiseasesDB|}}}|[http://www.diseasesdatabase.com/ddb{{{DiseasesDB}}}.htm {{{DiseasesDB}}}] {{{DiseasesDB_mult|}}} }}

| label6     = [[Wp/nr/MedlinePlus|MedlinePlus]]
| data6      = {{#if:{{{MedlinePlus|}}}|[http://www.nlm.nih.gov/medlineplus/ency/article/{{{MedlinePlus}}}.htm {{{MedlinePlus}}}]  {{{MedlinePlus_mult|}}} }}

| label7     = [[Wp/nr/Medical Subject Headings|MeSH]]
| data7      = {{comma separated entries
  | 1 = {{#if:{{{MeshID|{{{MeSH|{{{MeSH1|}}}}}}}}} | {{mesh2|{{{MeshID|{{{MeSH|{{{MeSH1}}}}}}}}}| year= {{{MeshYear|{{{MeshYear1|}}}}}} }} }}
  | 2 = {{#if:{{{MeSH2|}}} | {{mesh2|{{{MeSH2|}}}|year={{{MeshYear2|}}}}} }}
  | 3 = {{#if:{{{MeSH3|}}} | {{mesh2|{{{MeSH3|}}}|year={{{MeshYear3|}}}}} }}
  | 4 = {{#if:{{{MeSH4|}}} | {{mesh2|{{{MeSH4|}}}|year={{{MeshYear4|}}}}} }}
  | 5 = {{#if:{{{MeSH5|}}} | {{mesh2|{{{MeSH5|}}}|year={{{MeshYear5|}}}}} }}
  | 6 = {{#if:{{{MeSH6|}}} | {{mesh2|{{{MeSH6|}}}|year={{{MeshYear6|}}}}} }}
  | 7 = {{#if:{{{MeSH7|}}} | {{mesh2|{{{MeSH7|}}}|year={{{MeshYear7|}}}}} }}
  | 8 = {{#if:{{{MeSH8|}}} | {{mesh2|{{{MeSH8|}}}|year={{{MeshYear8|}}}}} }}
  | 9 = {{#if:{{{MeSH9|}}} | {{mesh2|{{{MeSH9|}}}|year={{{MeshYear9|}}}}} }}
  |10 = {{#if: {{{MeshName|}}} | ''{{mesh2 | name = {{{MeshName}}} | number = {{{MeshNumber|}}} }}'' }}
  }}

| label8     = [[Wp/nr/GeneReviews|GeneReviews]]
| class8     = plainlist
| data8      = {{#if: {{{GeneReviewsNBK|}}}{{{GeneReviewsNBK1|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK|{{{GeneReviewsNBK1}}}}}}|{{{GeneReviewsName|{{{GeneReviewsName1|}}}}}}}}|{{#if: {{{GeneReviewsID|}}}| 
* [http://www.ncbi.nlm.nih.gov/books/n/gene/{{{GeneReviewsID}}}/ {{#if: {{{GeneReviewsName|}}}|{{{GeneReviewsName}}}|{{{GeneReviewsID}}}}}]}}}}{{#if: {{{GeneReviewsNBK2|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK2}}}|{{{GeneReviewsName2|}}}}}}}{{#if: {{{GeneReviewsNBK3|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK3}}}|{{{GeneReviewsName3|}}}}}}}{{#if: {{{GeneReviewsNBK4|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK4}}}|{{{GeneReviewsName4|}}}}}}}{{#if: {{{GeneReviewsNBK5|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK5}}}|{{{GeneReviewsName5|}}}}}}}{{#if: {{{GeneReviewsNBK6|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK6}}}|{{{GeneReviewsName6|}}}}}}}{{#if: {{{GeneReviewsNBK7|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK7}}}|{{{GeneReviewsName7|}}}}}}}

}}--&gt;&lt;noinclude&gt;
{{Wp/nr/documentation}}
&lt;/noinclude&gt;</text>
      <sha1>ei2cn4ngq4qq9e4b7in0bhvuokkyu5f</sha1>
    </revision>
    <revision>
      <id>1991</id>
      <parentid>1990</parentid>
      <timestamp>2016-10-01T17:21:49Z</timestamp>
      <contributor>
        <username>incubator&gt;Doc James</username>
        <id>0</id>
      </contributor>
      <origin>1991</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5056" sha1="en0dtdzhjksd6rvl1upca0v4b8ut3yy" xml:space="preserve">&lt;div class=&quot;toc&quot; style=&quot;float:right;width:18em;padding:0.5em;margin:0 0 1em 1em;&quot;&gt;
&lt;table style=&quot;width:100%;&quot;&gt;
&lt;tr&gt;&lt;th colspan=&quot;2&quot;&gt;&lt;big&gt;{{{name|{{PAGENAME}}}}}&lt;/big&gt;&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align:center;&quot;&gt;''Ukuhlukaniswa kweengaba neentlabagelo zangaphandle''&lt;!--''Classification and external resources''--&gt;&lt;/td&gt;&lt;/tr&gt;
{{#if:{{{image|}}}|&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align:center;&quot;&gt;[[File:{{{image|}}}{{{Image|}}}|150px|center|{{{caption|{{{name|{{PAGENAME}}}}}}}}]] &lt;small&gt;{{{caption|}}}{{{Caption|}}}&lt;/small&gt;&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{ICD10|}}}|&lt;tr&gt;&lt;td&gt;'''ICD/CIM-10'''&lt;/td&gt;&lt;td&gt;{{{ICD10|}}} {{{ICD10}}}{{#if:{{{ICD10-2|}}}|{{{ICD10-2|}}} {{{ICD10-2}}}|}}&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{ICD9|}}}|&lt;tr&gt;&lt;td&gt;'''ICD/CIM-9'''&lt;/td&gt;&lt;td&gt;{{{ICD9|}}} {{{ICD9}}}&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{OMIM|}}}|&lt;tr&gt;&lt;td&gt;'''OMIM'''&lt;/td&gt;&lt;td&gt;[http://omim.org/entry/{{{OMIM|}}} {{{OMIM}}}]&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{DiseasesDB|}}}|&lt;tr&gt;&lt;td&gt;'''DiseasesDB'''&lt;/td&gt;&lt;td&gt;[http://www.diseasesdatabase.com/ddb{{{DiseasesDB|}}}.htm {{{DiseasesDB}}}]{{#if:{{{DiseasesDB-2|}}}|, [http://www.diseasesdatabase.com/ddb{{{DiseasesDB-2|}}}.htm {{{DiseasesDB-2}}}]|}}&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{MedlinePlus|}}}|&lt;tr&gt;&lt;td&gt;'''MedlinePlus'''&lt;/td&gt;&lt;td&gt;[http://www.nlm.nih.gov/medlineplus/ency/article/{{{MedlinePlus|}}}.htm {{{MedlinePlus}}}]&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{eMedicine|}}}|&lt;tr&gt;&lt;td&gt;'''eMedicine'''&lt;/td&gt;&lt;td&gt;''&amp;lt;Placeholder&amp;gt;''&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{MeSH|}}}|&lt;tr&gt;&lt;td&gt;'''MeSH'''&lt;/td&gt;&lt;td&gt;[http://www.nlm.nih.gov/cgi/mesh/2014/MB_cgi?field=uid&amp;term={{{MeSH}}} {{{MeSH}}}]&lt;/td&gt;&lt;/tr&gt;|}}
&lt;/table&gt;
&lt;/div&gt;&lt;!--

{{ infobox
| abovestyle = background-color: {{{background|{{{Background|lightgrey}}}}}}
| above      = {{{name|{{{Name|&lt;includeonly&gt;{{PAGENAME}}&lt;/includeonly&gt;}}}}}}
| subheader  = &lt;includeonly&gt;''Classification and external resources''&lt;/includeonly&gt;
| image      = {{#invoke:InfoboxImage|InfoboxImage|image={{{image|}}}{{{Image|}}}|size={{{image_size|{{{Width|}}}}}}|sizedefault=frameless|upright=1.06|alt={{{alt|}}}{{{Alt|}}}}}
| caption    = {{{caption|}}}{{{Caption|}}}

| label1     = [[Wp/nd/International Statistical Classification of Diseases and Related Health Problems|ICD]]-[[Wp/nr/ICD-10|10]]
| data1      = {{{ICD10|}}}

| label2     = [[Wp/nd/International Statistical Classification of Diseases and Related Health Problems|ICD]]-[[Wp/nr/List of ICD-9 codes|9]]
| data2      = {{{ICD9|}}}

| label3     = [[International Classification of Diseases for Oncology|ICD-O:]]
| data3      = {{{ICDO|}}}

| label4     = [[Wp/nd/OMIM|OMIM]]
| data4      = {{#if:{{{OMIM|}}}|[http://omim.org/entry/{{{OMIM}}} {{{OMIM}}}] {{{OMIM_mult|}}} }}

| label5     = [[Wp/nd/Diseases Database|DiseasesDB]]
| data5      = {{#if:{{{DiseasesDB|}}}|[http://www.diseasesdatabase.com/ddb{{{DiseasesDB}}}.htm {{{DiseasesDB}}}] {{{DiseasesDB_mult|}}} }}

| label6     = [[Wp/nd/MedlinePlus|MedlinePlus]]
| data6      = {{#if:{{{MedlinePlus|}}}|[http://www.nlm.nih.gov/medlineplus/ency/article/{{{MedlinePlus}}}.htm {{{MedlinePlus}}}]  {{{MedlinePlus_mult|}}} }}

| label7     = [[Wp/nd/Medical Subject Headings|MeSH]]
| data7      = {{comma separated entries
  | 1 = {{#if:{{{MeshID|{{{MeSH|{{{MeSH1|}}}}}}}}} | {{mesh2|{{{MeshID|{{{MeSH|{{{MeSH1}}}}}}}}}| year= {{{MeshYear|{{{MeshYear1|}}}}}} }} }}
  | 2 = {{#if:{{{MeSH2|}}} | {{mesh2|{{{MeSH2|}}}|year={{{MeshYear2|}}}}} }}
  | 3 = {{#if:{{{MeSH3|}}} | {{mesh2|{{{MeSH3|}}}|year={{{MeshYear3|}}}}} }}
  | 4 = {{#if:{{{MeSH4|}}} | {{mesh2|{{{MeSH4|}}}|year={{{MeshYear4|}}}}} }}
  | 5 = {{#if:{{{MeSH5|}}} | {{mesh2|{{{MeSH5|}}}|year={{{MeshYear5|}}}}} }}
  | 6 = {{#if:{{{MeSH6|}}} | {{mesh2|{{{MeSH6|}}}|year={{{MeshYear6|}}}}} }}
  | 7 = {{#if:{{{MeSH7|}}} | {{mesh2|{{{MeSH7|}}}|year={{{MeshYear7|}}}}} }}
  | 8 = {{#if:{{{MeSH8|}}} | {{mesh2|{{{MeSH8|}}}|year={{{MeshYear8|}}}}} }}
  | 9 = {{#if:{{{MeSH9|}}} | {{mesh2|{{{MeSH9|}}}|year={{{MeshYear9|}}}}} }}
  |10 = {{#if: {{{MeshName|}}} | ''{{mesh2 | name = {{{MeshName}}} | number = {{{MeshNumber|}}} }}'' }}
  }}

| label8     = [[Wp/nd/GeneReviews|GeneReviews]]
| class8     = plainlist
| data8      = {{#if: {{{GeneReviewsNBK|}}}{{{GeneReviewsNBK1|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK|{{{GeneReviewsNBK1}}}}}}|{{{GeneReviewsName|{{{GeneReviewsName1|}}}}}}}}|{{#if: {{{GeneReviewsID|}}}| 
* [http://www.ncbi.nlm.nih.gov/books/n/gene/{{{GeneReviewsID}}}/ {{#if: {{{GeneReviewsName|}}}|{{{GeneReviewsName}}}|{{{GeneReviewsID}}}}}]}}}}{{#if: {{{GeneReviewsNBK2|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK2}}}|{{{GeneReviewsName2|}}}}}}}{{#if: {{{GeneReviewsNBK3|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK3}}}|{{{GeneReviewsName3|}}}}}}}{{#if: {{{GeneReviewsNBK4|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK4}}}|{{{GeneReviewsName4|}}}}}}}{{#if: {{{GeneReviewsNBK5|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK5}}}|{{{GeneReviewsName5|}}}}}}}{{#if: {{{GeneReviewsNBK6|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK6}}}|{{{GeneReviewsName6|}}}}}}}{{#if: {{{GeneReviewsNBK7|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK7}}}|{{{GeneReviewsName7|}}}}}}}

}}--&gt;&lt;noinclude&gt;
{{Wp/nd/documentation}}
&lt;/noinclude&gt;</text>
      <sha1>en0dtdzhjksd6rvl1upca0v4b8ut3yy</sha1>
    </revision>
    <revision>
      <id>1992</id>
      <parentid>1991</parentid>
      <timestamp>2016-11-09T15:15:08Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <origin>1992</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5056" sha1="mxg0lec0jtispocql4mk0e9oxwqrrkb" xml:space="preserve">&lt;div class=&quot;toc&quot; style=&quot;float:right;width:18em;padding:0.5em;margin:0 0 1em 1em;&quot;&gt;
&lt;table style=&quot;width:100%;&quot;&gt;
&lt;tr&gt;&lt;th colspan=&quot;2&quot;&gt;&lt;big&gt;{{{name|{{PAGENAME}}}}}&lt;/big&gt;&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align:center;&quot;&gt;''Ukuhlukaniswa kweengaba neentlabagelo zangaphandle''&lt;!--''Classification and external resources''--&gt;&lt;/td&gt;&lt;/tr&gt;
{{#if:{{{image|}}}|&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align:center;&quot;&gt;[[File:{{{image|}}}{{{Image|}}}|200px|center|{{{caption|{{{name|{{PAGENAME}}}}}}}}]] &lt;small&gt;{{{caption|}}}{{{Caption|}}}&lt;/small&gt;&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{ICD10|}}}|&lt;tr&gt;&lt;td&gt;'''ICD/CIM-10'''&lt;/td&gt;&lt;td&gt;{{{ICD10|}}} {{{ICD10}}}{{#if:{{{ICD10-2|}}}|{{{ICD10-2|}}} {{{ICD10-2}}}|}}&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{ICD9|}}}|&lt;tr&gt;&lt;td&gt;'''ICD/CIM-9'''&lt;/td&gt;&lt;td&gt;{{{ICD9|}}} {{{ICD9}}}&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{OMIM|}}}|&lt;tr&gt;&lt;td&gt;'''OMIM'''&lt;/td&gt;&lt;td&gt;[http://omim.org/entry/{{{OMIM|}}} {{{OMIM}}}]&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{DiseasesDB|}}}|&lt;tr&gt;&lt;td&gt;'''DiseasesDB'''&lt;/td&gt;&lt;td&gt;[http://www.diseasesdatabase.com/ddb{{{DiseasesDB|}}}.htm {{{DiseasesDB}}}]{{#if:{{{DiseasesDB-2|}}}|, [http://www.diseasesdatabase.com/ddb{{{DiseasesDB-2|}}}.htm {{{DiseasesDB-2}}}]|}}&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{MedlinePlus|}}}|&lt;tr&gt;&lt;td&gt;'''MedlinePlus'''&lt;/td&gt;&lt;td&gt;[http://www.nlm.nih.gov/medlineplus/ency/article/{{{MedlinePlus|}}}.htm {{{MedlinePlus}}}]&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{eMedicine|}}}|&lt;tr&gt;&lt;td&gt;'''eMedicine'''&lt;/td&gt;&lt;td&gt;''&amp;lt;Placeholder&amp;gt;''&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{MeSH|}}}|&lt;tr&gt;&lt;td&gt;'''MeSH'''&lt;/td&gt;&lt;td&gt;[http://www.nlm.nih.gov/cgi/mesh/2014/MB_cgi?field=uid&amp;term={{{MeSH}}} {{{MeSH}}}]&lt;/td&gt;&lt;/tr&gt;|}}
&lt;/table&gt;
&lt;/div&gt;&lt;!--

{{ infobox
| abovestyle = background-color: {{{background|{{{Background|lightgrey}}}}}}
| above      = {{{name|{{{Name|&lt;includeonly&gt;{{PAGENAME}}&lt;/includeonly&gt;}}}}}}
| subheader  = &lt;includeonly&gt;''Classification and external resources''&lt;/includeonly&gt;
| image      = {{#invoke:InfoboxImage|InfoboxImage|image={{{image|}}}{{{Image|}}}|size={{{image_size|{{{Width|}}}}}}|sizedefault=frameless|upright=1.06|alt={{{alt|}}}{{{Alt|}}}}}
| caption    = {{{caption|}}}{{{Caption|}}}

| label1     = [[Wp/nd/International Statistical Classification of Diseases and Related Health Problems|ICD]]-[[Wp/nr/ICD-10|10]]
| data1      = {{{ICD10|}}}

| label2     = [[Wp/nd/International Statistical Classification of Diseases and Related Health Problems|ICD]]-[[Wp/nr/List of ICD-9 codes|9]]
| data2      = {{{ICD9|}}}

| label3     = [[International Classification of Diseases for Oncology|ICD-O:]]
| data3      = {{{ICDO|}}}

| label4     = [[Wp/nd/OMIM|OMIM]]
| data4      = {{#if:{{{OMIM|}}}|[http://omim.org/entry/{{{OMIM}}} {{{OMIM}}}] {{{OMIM_mult|}}} }}

| label5     = [[Wp/nd/Diseases Database|DiseasesDB]]
| data5      = {{#if:{{{DiseasesDB|}}}|[http://www.diseasesdatabase.com/ddb{{{DiseasesDB}}}.htm {{{DiseasesDB}}}] {{{DiseasesDB_mult|}}} }}

| label6     = [[Wp/nd/MedlinePlus|MedlinePlus]]
| data6      = {{#if:{{{MedlinePlus|}}}|[http://www.nlm.nih.gov/medlineplus/ency/article/{{{MedlinePlus}}}.htm {{{MedlinePlus}}}]  {{{MedlinePlus_mult|}}} }}

| label7     = [[Wp/nd/Medical Subject Headings|MeSH]]
| data7      = {{comma separated entries
  | 1 = {{#if:{{{MeshID|{{{MeSH|{{{MeSH1|}}}}}}}}} | {{mesh2|{{{MeshID|{{{MeSH|{{{MeSH1}}}}}}}}}| year= {{{MeshYear|{{{MeshYear1|}}}}}} }} }}
  | 2 = {{#if:{{{MeSH2|}}} | {{mesh2|{{{MeSH2|}}}|year={{{MeshYear2|}}}}} }}
  | 3 = {{#if:{{{MeSH3|}}} | {{mesh2|{{{MeSH3|}}}|year={{{MeshYear3|}}}}} }}
  | 4 = {{#if:{{{MeSH4|}}} | {{mesh2|{{{MeSH4|}}}|year={{{MeshYear4|}}}}} }}
  | 5 = {{#if:{{{MeSH5|}}} | {{mesh2|{{{MeSH5|}}}|year={{{MeshYear5|}}}}} }}
  | 6 = {{#if:{{{MeSH6|}}} | {{mesh2|{{{MeSH6|}}}|year={{{MeshYear6|}}}}} }}
  | 7 = {{#if:{{{MeSH7|}}} | {{mesh2|{{{MeSH7|}}}|year={{{MeshYear7|}}}}} }}
  | 8 = {{#if:{{{MeSH8|}}} | {{mesh2|{{{MeSH8|}}}|year={{{MeshYear8|}}}}} }}
  | 9 = {{#if:{{{MeSH9|}}} | {{mesh2|{{{MeSH9|}}}|year={{{MeshYear9|}}}}} }}
  |10 = {{#if: {{{MeshName|}}} | ''{{mesh2 | name = {{{MeshName}}} | number = {{{MeshNumber|}}} }}'' }}
  }}

| label8     = [[Wp/nd/GeneReviews|GeneReviews]]
| class8     = plainlist
| data8      = {{#if: {{{GeneReviewsNBK|}}}{{{GeneReviewsNBK1|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK|{{{GeneReviewsNBK1}}}}}}|{{{GeneReviewsName|{{{GeneReviewsName1|}}}}}}}}|{{#if: {{{GeneReviewsID|}}}| 
* [http://www.ncbi.nlm.nih.gov/books/n/gene/{{{GeneReviewsID}}}/ {{#if: {{{GeneReviewsName|}}}|{{{GeneReviewsName}}}|{{{GeneReviewsID}}}}}]}}}}{{#if: {{{GeneReviewsNBK2|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK2}}}|{{{GeneReviewsName2|}}}}}}}{{#if: {{{GeneReviewsNBK3|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK3}}}|{{{GeneReviewsName3|}}}}}}}{{#if: {{{GeneReviewsNBK4|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK4}}}|{{{GeneReviewsName4|}}}}}}}{{#if: {{{GeneReviewsNBK5|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK5}}}|{{{GeneReviewsName5|}}}}}}}{{#if: {{{GeneReviewsNBK6|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK6}}}|{{{GeneReviewsName6|}}}}}}}{{#if: {{{GeneReviewsNBK7|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK7}}}|{{{GeneReviewsName7|}}}}}}}

}}--&gt;&lt;noinclude&gt;
{{Wp/nd/documentation}}
&lt;/noinclude&gt;</text>
      <sha1>mxg0lec0jtispocql4mk0e9oxwqrrkb</sha1>
    </revision>
    <revision>
      <id>1993</id>
      <parentid>1992</parentid>
      <timestamp>2024-11-18T17:41:44Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <minor />
      <comment>3 revisions imported from [[:incubator:Template:Wp/nd/Infobox_disease]]</comment>
      <origin>1992</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5056" sha1="mxg0lec0jtispocql4mk0e9oxwqrrkb" xml:space="preserve">&lt;div class=&quot;toc&quot; style=&quot;float:right;width:18em;padding:0.5em;margin:0 0 1em 1em;&quot;&gt;
&lt;table style=&quot;width:100%;&quot;&gt;
&lt;tr&gt;&lt;th colspan=&quot;2&quot;&gt;&lt;big&gt;{{{name|{{PAGENAME}}}}}&lt;/big&gt;&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align:center;&quot;&gt;''Ukuhlukaniswa kweengaba neentlabagelo zangaphandle''&lt;!--''Classification and external resources''--&gt;&lt;/td&gt;&lt;/tr&gt;
{{#if:{{{image|}}}|&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align:center;&quot;&gt;[[File:{{{image|}}}{{{Image|}}}|200px|center|{{{caption|{{{name|{{PAGENAME}}}}}}}}]] &lt;small&gt;{{{caption|}}}{{{Caption|}}}&lt;/small&gt;&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{ICD10|}}}|&lt;tr&gt;&lt;td&gt;'''ICD/CIM-10'''&lt;/td&gt;&lt;td&gt;{{{ICD10|}}} {{{ICD10}}}{{#if:{{{ICD10-2|}}}|{{{ICD10-2|}}} {{{ICD10-2}}}|}}&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{ICD9|}}}|&lt;tr&gt;&lt;td&gt;'''ICD/CIM-9'''&lt;/td&gt;&lt;td&gt;{{{ICD9|}}} {{{ICD9}}}&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{OMIM|}}}|&lt;tr&gt;&lt;td&gt;'''OMIM'''&lt;/td&gt;&lt;td&gt;[http://omim.org/entry/{{{OMIM|}}} {{{OMIM}}}]&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{DiseasesDB|}}}|&lt;tr&gt;&lt;td&gt;'''DiseasesDB'''&lt;/td&gt;&lt;td&gt;[http://www.diseasesdatabase.com/ddb{{{DiseasesDB|}}}.htm {{{DiseasesDB}}}]{{#if:{{{DiseasesDB-2|}}}|, [http://www.diseasesdatabase.com/ddb{{{DiseasesDB-2|}}}.htm {{{DiseasesDB-2}}}]|}}&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{MedlinePlus|}}}|&lt;tr&gt;&lt;td&gt;'''MedlinePlus'''&lt;/td&gt;&lt;td&gt;[http://www.nlm.nih.gov/medlineplus/ency/article/{{{MedlinePlus|}}}.htm {{{MedlinePlus}}}]&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{eMedicine|}}}|&lt;tr&gt;&lt;td&gt;'''eMedicine'''&lt;/td&gt;&lt;td&gt;''&amp;lt;Placeholder&amp;gt;''&lt;/td&gt;&lt;/tr&gt;|}}&lt;!--
--&gt;{{#if:{{{MeSH|}}}|&lt;tr&gt;&lt;td&gt;'''MeSH'''&lt;/td&gt;&lt;td&gt;[http://www.nlm.nih.gov/cgi/mesh/2014/MB_cgi?field=uid&amp;term={{{MeSH}}} {{{MeSH}}}]&lt;/td&gt;&lt;/tr&gt;|}}
&lt;/table&gt;
&lt;/div&gt;&lt;!--

{{ infobox
| abovestyle = background-color: {{{background|{{{Background|lightgrey}}}}}}
| above      = {{{name|{{{Name|&lt;includeonly&gt;{{PAGENAME}}&lt;/includeonly&gt;}}}}}}
| subheader  = &lt;includeonly&gt;''Classification and external resources''&lt;/includeonly&gt;
| image      = {{#invoke:InfoboxImage|InfoboxImage|image={{{image|}}}{{{Image|}}}|size={{{image_size|{{{Width|}}}}}}|sizedefault=frameless|upright=1.06|alt={{{alt|}}}{{{Alt|}}}}}
| caption    = {{{caption|}}}{{{Caption|}}}

| label1     = [[Wp/nd/International Statistical Classification of Diseases and Related Health Problems|ICD]]-[[Wp/nr/ICD-10|10]]
| data1      = {{{ICD10|}}}

| label2     = [[Wp/nd/International Statistical Classification of Diseases and Related Health Problems|ICD]]-[[Wp/nr/List of ICD-9 codes|9]]
| data2      = {{{ICD9|}}}

| label3     = [[International Classification of Diseases for Oncology|ICD-O:]]
| data3      = {{{ICDO|}}}

| label4     = [[Wp/nd/OMIM|OMIM]]
| data4      = {{#if:{{{OMIM|}}}|[http://omim.org/entry/{{{OMIM}}} {{{OMIM}}}] {{{OMIM_mult|}}} }}

| label5     = [[Wp/nd/Diseases Database|DiseasesDB]]
| data5      = {{#if:{{{DiseasesDB|}}}|[http://www.diseasesdatabase.com/ddb{{{DiseasesDB}}}.htm {{{DiseasesDB}}}] {{{DiseasesDB_mult|}}} }}

| label6     = [[Wp/nd/MedlinePlus|MedlinePlus]]
| data6      = {{#if:{{{MedlinePlus|}}}|[http://www.nlm.nih.gov/medlineplus/ency/article/{{{MedlinePlus}}}.htm {{{MedlinePlus}}}]  {{{MedlinePlus_mult|}}} }}

| label7     = [[Wp/nd/Medical Subject Headings|MeSH]]
| data7      = {{comma separated entries
  | 1 = {{#if:{{{MeshID|{{{MeSH|{{{MeSH1|}}}}}}}}} | {{mesh2|{{{MeshID|{{{MeSH|{{{MeSH1}}}}}}}}}| year= {{{MeshYear|{{{MeshYear1|}}}}}} }} }}
  | 2 = {{#if:{{{MeSH2|}}} | {{mesh2|{{{MeSH2|}}}|year={{{MeshYear2|}}}}} }}
  | 3 = {{#if:{{{MeSH3|}}} | {{mesh2|{{{MeSH3|}}}|year={{{MeshYear3|}}}}} }}
  | 4 = {{#if:{{{MeSH4|}}} | {{mesh2|{{{MeSH4|}}}|year={{{MeshYear4|}}}}} }}
  | 5 = {{#if:{{{MeSH5|}}} | {{mesh2|{{{MeSH5|}}}|year={{{MeshYear5|}}}}} }}
  | 6 = {{#if:{{{MeSH6|}}} | {{mesh2|{{{MeSH6|}}}|year={{{MeshYear6|}}}}} }}
  | 7 = {{#if:{{{MeSH7|}}} | {{mesh2|{{{MeSH7|}}}|year={{{MeshYear7|}}}}} }}
  | 8 = {{#if:{{{MeSH8|}}} | {{mesh2|{{{MeSH8|}}}|year={{{MeshYear8|}}}}} }}
  | 9 = {{#if:{{{MeSH9|}}} | {{mesh2|{{{MeSH9|}}}|year={{{MeshYear9|}}}}} }}
  |10 = {{#if: {{{MeshName|}}} | ''{{mesh2 | name = {{{MeshName}}} | number = {{{MeshNumber|}}} }}'' }}
  }}

| label8     = [[Wp/nd/GeneReviews|GeneReviews]]
| class8     = plainlist
| data8      = {{#if: {{{GeneReviewsNBK|}}}{{{GeneReviewsNBK1|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK|{{{GeneReviewsNBK1}}}}}}|{{{GeneReviewsName|{{{GeneReviewsName1|}}}}}}}}|{{#if: {{{GeneReviewsID|}}}| 
* [http://www.ncbi.nlm.nih.gov/books/n/gene/{{{GeneReviewsID}}}/ {{#if: {{{GeneReviewsName|}}}|{{{GeneReviewsName}}}|{{{GeneReviewsID}}}}}]}}}}{{#if: {{{GeneReviewsNBK2|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK2}}}|{{{GeneReviewsName2|}}}}}}}{{#if: {{{GeneReviewsNBK3|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK3}}}|{{{GeneReviewsName3|}}}}}}}{{#if: {{{GeneReviewsNBK4|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK4}}}|{{{GeneReviewsName4|}}}}}}}{{#if: {{{GeneReviewsNBK5|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK5}}}|{{{GeneReviewsName5|}}}}}}}{{#if: {{{GeneReviewsNBK6|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK6}}}|{{{GeneReviewsName6|}}}}}}}{{#if: {{{GeneReviewsNBK7|}}}| 
* {{NCBIBook2|{{{GeneReviewsNBK7}}}|{{{GeneReviewsName7|}}}}}}}

}}--&gt;&lt;noinclude&gt;
{{Wp/nd/documentation}}
&lt;/noinclude&gt;</text>
      <sha1>mxg0lec0jtispocql4mk0e9oxwqrrkb</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Wp/nd/citation/core</title>
    <ns>10</ns>
    <id>381</id>
    <redirect title="Umhlahlandlelasakhiwo:Wp/nd/Citation/core" />
    <revision>
      <id>1994</id>
      <timestamp>2022-04-27T09:33:58Z</timestamp>
      <contributor>
        <username>JhsBot</username>
        <id>34</id>
      </contributor>
      <comment>JhsBot moved page [[Template:Wp/nd/citation/core]] to [[Template:Wp/nd/Citation/core]] over redirect: bot: Moving pages with (what would be) lowercase titles to uppercase</comment>
      <origin>1994</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="42" sha1="jiwuybg3qx2jw6eprcimt0to54dpswk" xml:space="preserve">#REDIRECT [[Template:Wp/nd/Citation/core]]</text>
      <sha1>jiwuybg3qx2jw6eprcimt0to54dpswk</sha1>
    </revision>
    <revision>
      <id>1995</id>
      <parentid>1994</parentid>
      <timestamp>2024-11-18T17:41:44Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <minor />
      <comment>1 revision imported from [[:incubator:Template:Wp/nd/citation/core]]</comment>
      <origin>1994</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="42" sha1="jiwuybg3qx2jw6eprcimt0to54dpswk" xml:space="preserve">#REDIRECT [[Template:Wp/nd/Citation/core]]</text>
      <sha1>jiwuybg3qx2jw6eprcimt0to54dpswk</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Wp/nd/citation/identifier</title>
    <ns>10</ns>
    <id>382</id>
    <redirect title="Umhlahlandlelasakhiwo:Wp/nd/Citation/identifier" />
    <revision>
      <id>1996</id>
      <timestamp>2022-04-27T09:34:01Z</timestamp>
      <contributor>
        <username>JhsBot</username>
        <id>34</id>
      </contributor>
      <comment>JhsBot moved page [[Template:Wp/nd/citation/identifier]] to [[Template:Wp/nd/Citation/identifier]] over redirect: bot: Moving pages with (what would be) lowercase titles to uppercase</comment>
      <origin>1996</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="48" sha1="o55izzodrv739uae2hig6l6zikkui9o" xml:space="preserve">#REDIRECT [[Template:Wp/nd/Citation/identifier]]</text>
      <sha1>o55izzodrv739uae2hig6l6zikkui9o</sha1>
    </revision>
    <revision>
      <id>1997</id>
      <parentid>1996</parentid>
      <timestamp>2024-11-18T17:41:44Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <minor />
      <comment>1 revision imported from [[:incubator:Template:Wp/nd/citation/identifier]]</comment>
      <origin>1996</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="48" sha1="o55izzodrv739uae2hig6l6zikkui9o" xml:space="preserve">#REDIRECT [[Template:Wp/nd/Citation/identifier]]</text>
      <sha1>o55izzodrv739uae2hig6l6zikkui9o</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Wp/nd/citation/make link</title>
    <ns>10</ns>
    <id>383</id>
    <redirect title="Umhlahlandlelasakhiwo:Wp/nd/Citation/make link" />
    <revision>
      <id>1998</id>
      <timestamp>2022-04-27T09:34:04Z</timestamp>
      <contributor>
        <username>JhsBot</username>
        <id>34</id>
      </contributor>
      <comment>JhsBot moved page [[Template:Wp/nd/citation/make link]] to [[Template:Wp/nd/Citation/make link]] over redirect: bot: Moving pages with (what would be) lowercase titles to uppercase</comment>
      <origin>1998</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="47" sha1="tqo9u94gwz7obupmcqkvsube5cpsad4" xml:space="preserve">#REDIRECT [[Template:Wp/nd/Citation/make link]]</text>
      <sha1>tqo9u94gwz7obupmcqkvsube5cpsad4</sha1>
    </revision>
    <revision>
      <id>1999</id>
      <parentid>1998</parentid>
      <timestamp>2024-11-18T17:41:45Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <minor />
      <comment>1 revision imported from [[:incubator:Template:Wp/nd/citation/make_link]]</comment>
      <origin>1998</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="47" sha1="tqo9u94gwz7obupmcqkvsube5cpsad4" xml:space="preserve">#REDIRECT [[Template:Wp/nd/Citation/make link]]</text>
      <sha1>tqo9u94gwz7obupmcqkvsube5cpsad4</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Wp/nd/cite journal</title>
    <ns>10</ns>
    <id>384</id>
    <redirect title="Umhlahlandlelasakhiwo:Wp/nd/Cite journal" />
    <revision>
      <id>2000</id>
      <timestamp>2016-11-09T15:28:17Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>CFCF moved page [[Template:Wp/nd/cite journal]] to [[Template:Wp/nd/Cite journal]]</comment>
      <origin>2000</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="41" sha1="bw3infye9qlstu5nxfj3n9vsxz293t0" xml:space="preserve">#REDIRECT [[Template:Wp/nd/Cite journal]]</text>
      <sha1>bw3infye9qlstu5nxfj3n9vsxz293t0</sha1>
    </revision>
    <revision>
      <id>2001</id>
      <parentid>2000</parentid>
      <timestamp>2024-11-18T17:41:45Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <minor />
      <comment>1 revision imported from [[:incubator:Template:Wp/nd/cite_journal]]</comment>
      <origin>2000</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="41" sha1="bw3infye9qlstu5nxfj3n9vsxz293t0" xml:space="preserve">#REDIRECT [[Template:Wp/nd/Cite journal]]</text>
      <sha1>bw3infye9qlstu5nxfj3n9vsxz293t0</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Wp/nd/cite news</title>
    <ns>10</ns>
    <id>385</id>
    <redirect title="Umhlahlandlelasakhiwo:Wp/nd/Cite news" />
    <revision>
      <id>2002</id>
      <timestamp>2016-11-09T15:36:04Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>CFCF moved page [[Template:Wp/nd/cite news]] to [[Template:Wp/nd/Cite news]]</comment>
      <origin>2002</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="38" sha1="1sdssmhv37qsqxbfdt5j1pnds38siea" xml:space="preserve">#REDIRECT [[Template:Wp/nd/Cite news]]</text>
      <sha1>1sdssmhv37qsqxbfdt5j1pnds38siea</sha1>
    </revision>
    <revision>
      <id>2003</id>
      <parentid>2002</parentid>
      <timestamp>2024-11-18T17:41:45Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <minor />
      <comment>1 revision imported from [[:incubator:Template:Wp/nd/cite_news]]</comment>
      <origin>2002</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="38" sha1="1sdssmhv37qsqxbfdt5j1pnds38siea" xml:space="preserve">#REDIRECT [[Template:Wp/nd/Cite news]]</text>
      <sha1>1sdssmhv37qsqxbfdt5j1pnds38siea</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Wp/nd/cite web</title>
    <ns>10</ns>
    <id>386</id>
    <redirect title="Umhlahlandlelasakhiwo:Wp/nd/Cite web" />
    <revision>
      <id>2004</id>
      <timestamp>2022-04-27T09:34:07Z</timestamp>
      <contributor>
        <username>JhsBot</username>
        <id>34</id>
      </contributor>
      <comment>JhsBot moved page [[Template:Wp/nd/cite web]] to [[Template:Wp/nd/Cite web]] over redirect: bot: Moving pages with (what would be) lowercase titles to uppercase</comment>
      <origin>2004</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="37" sha1="ha4vo824jqzaj1jcqj2jrlxbe8l17oj" xml:space="preserve">#REDIRECT [[Template:Wp/nd/Cite web]]</text>
      <sha1>ha4vo824jqzaj1jcqj2jrlxbe8l17oj</sha1>
    </revision>
    <revision>
      <id>2005</id>
      <parentid>2004</parentid>
      <timestamp>2024-11-18T17:41:45Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <minor />
      <comment>1 revision imported from [[:incubator:Template:Wp/nd/cite_web]]</comment>
      <origin>2004</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="37" sha1="ha4vo824jqzaj1jcqj2jrlxbe8l17oj" xml:space="preserve">#REDIRECT [[Template:Wp/nd/Cite web]]</text>
      <sha1>ha4vo824jqzaj1jcqj2jrlxbe8l17oj</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Wp/nd/hide in print</title>
    <ns>10</ns>
    <id>387</id>
    <redirect title="Umhlahlandlelasakhiwo:Wp/nd/Hide in print" />
    <revision>
      <id>2006</id>
      <timestamp>2022-04-27T09:34:10Z</timestamp>
      <contributor>
        <username>JhsBot</username>
        <id>34</id>
      </contributor>
      <comment>JhsBot moved page [[Template:Wp/nd/hide in print]] to [[Template:Wp/nd/Hide in print]] over redirect: bot: Moving pages with (what would be) lowercase titles to uppercase</comment>
      <origin>2006</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="42" sha1="m8qsglnuhwjx4s186knwywt3r3whq45" xml:space="preserve">#REDIRECT [[Template:Wp/nd/Hide in print]]</text>
      <sha1>m8qsglnuhwjx4s186knwywt3r3whq45</sha1>
    </revision>
    <revision>
      <id>2007</id>
      <parentid>2006</parentid>
      <timestamp>2024-11-18T17:41:45Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <minor />
      <comment>1 revision imported from [[:incubator:Template:Wp/nd/hide_in_print]]</comment>
      <origin>2006</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="42" sha1="m8qsglnuhwjx4s186knwywt3r3whq45" xml:space="preserve">#REDIRECT [[Template:Wp/nd/Hide in print]]</text>
      <sha1>m8qsglnuhwjx4s186knwywt3r3whq45</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Wp/nd/only in print</title>
    <ns>10</ns>
    <id>388</id>
    <redirect title="Umhlahlandlelasakhiwo:Wp/nd/Only in print" />
    <revision>
      <id>2008</id>
      <timestamp>2022-04-27T09:34:16Z</timestamp>
      <contributor>
        <username>JhsBot</username>
        <id>34</id>
      </contributor>
      <comment>JhsBot moved page [[Template:Wp/nd/only in print]] to [[Template:Wp/nd/Only in print]] over redirect: bot: Moving pages with (what would be) lowercase titles to uppercase</comment>
      <origin>2008</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="42" sha1="e8r4tw75x1v1eezlazt2kf694o57ye9" xml:space="preserve">#REDIRECT [[Template:Wp/nd/Only in print]]</text>
      <sha1>e8r4tw75x1v1eezlazt2kf694o57ye9</sha1>
    </revision>
    <revision>
      <id>2009</id>
      <parentid>2008</parentid>
      <timestamp>2024-11-18T17:41:45Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <minor />
      <comment>1 revision imported from [[:incubator:Template:Wp/nd/only_in_print]]</comment>
      <origin>2008</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="42" sha1="e8r4tw75x1v1eezlazt2kf694o57ye9" xml:space="preserve">#REDIRECT [[Template:Wp/nd/Only in print]]</text>
      <sha1>e8r4tw75x1v1eezlazt2kf694o57ye9</sha1>
    </revision>
  </page>
  <page>
    <title>Wp/nd/Umgomani weZika</title>
    <ns>0</ns>
    <id>389</id>
    <redirect title="Umgomani weZika" />
    <revision>
      <id>2011</id>
      <timestamp>2024-11-18T17:42:26Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <comment>Amire80 moved page [[Wp/nd/Umgomani weZika]] to [[Umgomani weZika]]</comment>
      <origin>2011</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="29" sha1="kfpx14kaef5udior8bsxe44pmuyl36w" xml:space="preserve">#REDIRECT [[Umgomani weZika]]</text>
      <sha1>kfpx14kaef5udior8bsxe44pmuyl36w</sha1>
    </revision>
  </page>
  <page>
    <title>Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale</title>
    <ns>0</ns>
    <id>390</id>
    <revision>
      <id>2012</id>
      <timestamp>2016-10-01T06:34:14Z</timestamp>
      <contributor>
        <username>incubator&gt;Ian Henderson</username>
        <id>0</id>
      </contributor>
      <comment>Created</comment>
      <origin>2012</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6644" sha1="pm5bmbhidzrig0b1ky6o5o3q9rcqhsx" xml:space="preserve">{{Infobox disease
| Name           = Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale
| Image          = Black fly.jpg
| Caption        = Umuntu omdala[[uSimulium yahense|ipukani ekulu enzima]]kanye netsikizi''[[i-Onchocerca volvulus]]''ziphuma ngaphakathi kwendletjana yenunwanwa, ikhulisiwe 100x
| pronounce   = {{IPAc-en|ˌ|ɒ|ŋ|k|oʊ|s|ɜr|ˈ|s|aɪ|ə|s|ɨ|s|,_|-|ˈ|k|aɪ|-}}
| DiseasesDB     = 9218
| ICD10          = {{ICD10|B|73||b|65}}
| ICD9           = {{ICD9|125.3}}
| ICDO           =
| OMIM           =
| MedlinePlus    =
| eMedicineSubj  = med
| eMedicineTopic = 1667
| eMedicine_mult = {{eMedicine2|oph|709}}
| MeshID         = D009855
}}

&lt;!-- Definition and symptoms --&gt;
'''Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale''', obaziwa ngokuthi''' bulwelwe obuphophalisako bemlanjeni''' begodu'''yaziwa ngokuthi yi-Robles disease''', bulwelwe obubangwa kutheleleka okulethwa  [[yitsikizi esasibungwana]] ''[[i-Onchocerca volvulus]]''.&lt;ref name=WHO2014&gt;{{cite web|title=Onchocerciasis Fact sheet N°374|url=http://www.who.int/mediacentre/factsheets/fs374/en/|work=World Health Organization|accessdate=20 March 2014|date=March 2014}}&lt;/ref&gt; Amatshwayo wobulwelwe lobu afaka hlangana nokulunywa okudluleleko esikhunjeni, kanye[[nokuphophala]].&lt;ref name=WHO2014/&gt; Lobu ubulwelwe busebujameni besibili emalwelweni abanga ukuphophala, ngemva[[kwetrachoma]].&lt;ref name=CDC2013/&gt;

&lt;!-- Cause and Diagnosis --&gt;
Itsikizi esasibungwana le ingena esikhumbeni itheleleke[[ngokulunywa yipukani ekulu enzima]]efana''[[ne-Simulium]]'' umhlobo wempukani.&lt;ref name=WHO2014/&gt; Esikhathini esinengi umuntu kufanele alunywe kanengi ngaphambi kobana angatheleleka ngobulwelwe lobu.&lt;ref name=CDCEpi2013&gt;{{cite web|title=Parasites – Onchocerciasis (also known as River Blindness) Epidemiology &amp; Risk Factors|url=http://www.cdc.gov/parasites/onchocerciasis/epi.html|work=CDC|accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt; Iimpukani lezi ezikulu ezinzima zihlala hlanu komlambo, ngikho negama lobulwelwe lobu kuthiwa ybulwelwe obuphophalisako bemlanjeni.&lt;ref name=CDC2013&gt;{{cite web |title=Onchocerciasis (also known as River Blindness) |work=Parasites  |url=http://www.cdc.gov/parasites/onchocerciasis/|publisher=CDC|accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt; Nazingena ngaphakathi emuntwini, imbungwanyana lezi zenza[[indlela yazo eyenza isibungu esisandukuqhoqhoselwa]]ezizokungena ngazo esikhunjeni phakathi.&lt;ref name=WHO2014/&gt; Bese nasele zingene zanzinza nazo ziyakwazi bona zithelele ipukani ezokuluma esikhunjeni somuntu loyo.&lt;ref name=WHO2014/&gt; Kuneendlela ezimbalwa ezingasetjenziswa ukuthola umrabho wobulwelwe: ukubeka[[ umtjhini i-biopsy phezu kwesikhumba]] ekhemikhalini esamanzana [[isaline]] bese ucala  isibungu esisandukuqhoqhoselwa nasiphumako, bese ucala ilihlo lesibungwana lesi, bese godu utjheja ingongoma engaphakathi kwesikhumba uqale iimbungu ezikulu.&lt;ref name=CDCDiag2013&gt;{{cite web |title=Onchocerciasis (also known as River Blindness) Diagnosis |publisher=CDC |url=http://www.cdc.gov/parasites/onchocerciasis/diagnosis.html |work=Parasites |accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt;

&lt;!-- Prevention and Treatment --&gt;
U[[ mjovo]] olwisana nobulwelwe lobu awutholakali awukho.&lt;ref name=WHO2014/&gt; Umuntu angazivikela ngokukhandela ukulunywa ziimpukani lezi ezikulu.&lt;ref name=CDCPre2013&gt;{{cite web|title=Onchocerciasis (also known as River Blindness) Prevention &amp; Control |url=http://www.cdc.gov/parasites/onchocerciasis/prevent.html|work=Parasites |publisher=CDC |accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt; Lokhu kungafaka hlangana ukusebenzisa[[isihlahla sokuvikela ukulunywa ziinunwana]] kanye nokwembatha kuhle.&lt;ref name=CDCPre2013/&gt; Eminye imizamo kungaba kukuthi uthele ispreyi esisihlahla sokubulala[[iinunwanwa eziphaphak]]o.&lt;ref name=WHO2014/&gt; Imizamo yokuphungula ubulwelwe lobu ngokulatjhwa kweenqhema zabantu kuyenzeka kabili ngomnyaka eendaweni ezinengi ephasini zombelele.&lt;ref name=WHO2014/&gt; Ukulatjhwa kwalabo abathelelekileko kusetjenziswa iinhlahla[[i-ivermecticin]]qobe iinyanga esisithandathu ukuya kezilitjhumu nambili.&lt;ref name=WHO2014/&gt;&lt;ref name=Murray2013/&gt; Isihlahla sokulapha lesi sibulala isibungu esisandukuqhoqhoselwa ingasi isibungu esikhulu.&lt;ref name=Yellow2012&gt;{{cite book|last=Brunette|first=Gary W.|title=CDC Health Information for International Travel 2012 : The Yellow Book |year=2011|publisher=Oxford University Press|isbn=9780199830367 |page=258 |url=http://books.google.ca/books?id=5vCQpr1WTS8C&amp;pg=PA258 }}&lt;/ref&gt; ihlahla[[idoxycycline]], yona ibulala[[ umulwana i-endosymbiont]]ebizwa''[[nge-Wolbachia]]'', isebenza ukubulala amandla wesibungu lesi, nayo iyakhuthazwa bona isetjenziswe.&lt;ref name=Yellow2012/&gt; Ukususwa kwamalunda ngaphakathi kwesikumba nakho kungenziwa ngokobana umuntu ahlinzwe.&lt;ref name=Murray2013&gt;{{cite book |last=Murray |first=Patrick |title=Medical microbiology |year=2013 |publisher=Elsevier Saunders |location=Philadelphia |isbn=9780323086929 |page=792|url=http://books.google.ca/books?id=RBEVsFmR2yQC&amp;pg=PA792 |edition=7th}}&lt;/ref&gt;

&lt;!--Epidemiology and History --&gt;
Isibalo esibalelwa ku17 ukuya kuma-25 weengidigidi, ababanjwe nofana abatheleleko bulwelwe bokuphophala bemlanjeni, ababalelwa eengidigidini ezi-0.8 inengi labo alisaboni ngamehlo seliphophele.&lt;ref name=CDCEpi2013/&gt;&lt;ref name=Yellow2012/&gt; Ukutheleleka okuneng kobulwelwe lobu[[kwenzeka khulu esiyingini-seSahara ye-Africa]], nanyana imibiko yezehlakalo ezinye ivele[[enarheni i-Yemen]] nakenzinye iindawo ezizijameleko[[ eKabeni|ye-Amerikha]] kanye[[ne-Sewula ye-Amerikha]].&lt;ref name=WHO2014/&gt; Ngo-1915, udorhodere[[uRodolfo Robles]] waqathanisa kokuthoma ubulwelwe lobu nesifo samehlo.&lt;ref&gt;{{cite book |editor1=Eldridge, Bruce F. |editor2=Edman, John D. |editor3= Edman, J. |title=Medical entomology |year=2004 |publisher=Kluwer Academic |location=Dordrecht |isbn=9781402017940|page=301 |url=http://books.google.ca/books?id=C7OxOqTKYS8C&amp;pg=PA301 |edition=Revised |author1=Lok, James B. |author2=Walker, Edward D. |author3=Scoles, Glen A. |chapter=9. Filariasis}}&lt;/ref&gt; Kuveziwe erhelweni[[le-World Health Organization]] njengesifo[[ esizijamele sodwa emangweni yethrophigi]].&lt;ref&gt;{{cite journal |author=Reddy M, Gill SS, Kalkar SR, Wu W, Anderson PJ, Rochon PA |title=Oral drug therapy for multiple neglected tropical diseases: a systematic review |journal=JAMA |volume=298 |issue=16 |pages=1911–24 |date=October 2007 |doi=10.1001/jama.298.16.1911 |pmid=17954542 |url=http://jama.jamanetwork.com/article.aspx?doi=10.1001/jama.298.16.1911}}&lt;/ref&gt;
==isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini==
&lt;references /&gt;</text>
      <sha1>pm5bmbhidzrig0b1ky6o5o3q9rcqhsx</sha1>
    </revision>
    <revision>
      <id>2013</id>
      <parentid>2012</parentid>
      <timestamp>2016-11-04T12:24:46Z</timestamp>
      <contributor>
        <username>incubator&gt;Doc James</username>
        <id>0</id>
      </contributor>
      <origin>2013</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6650" sha1="mhaxnrfcqoanfb8ima4hf3iw63rkh79" xml:space="preserve">{{Wp/nd/Infobox disease
| name           = Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale
| image          = Black fly.jpg
| caption        = Umuntu omdala[[uSimulium yahense|ipukani ekulu enzima]]kanye netsikizi''[[i-Onchocerca volvulus]]''ziphuma ngaphakathi kwendletjana yenunwanwa, ikhulisiwe 100x
| pronounce   = {{IPAc-en|ˌ|ɒ|ŋ|k|oʊ|s|ɜr|ˈ|s|aɪ|ə|s|ɨ|s|,_|-|ˈ|k|aɪ|-}}
| DiseasesDB     = 9218
| ICD10          = {{ICD10|B|73||b|65}}
| ICD9           = {{ICD9|125.3}}
| ICDO           =
| OMIM           =
| MedlinePlus    =
| eMedicineSubj  = med
| eMedicineTopic = 1667
| eMedicine_mult = {{eMedicine2|oph|709}}
| MeshID         = D009855
}}

&lt;!-- Definition and symptoms --&gt;
'''Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale''', obaziwa ngokuthi''' bulwelwe obuphophalisako bemlanjeni''' begodu'''yaziwa ngokuthi yi-Robles disease''', bulwelwe obubangwa kutheleleka okulethwa  [[yitsikizi esasibungwana]] ''[[i-Onchocerca volvulus]]''.&lt;ref name=WHO2014&gt;{{cite web|title=Onchocerciasis Fact sheet N°374|url=http://www.who.int/mediacentre/factsheets/fs374/en/|work=World Health Organization|accessdate=20 March 2014|date=March 2014}}&lt;/ref&gt; Amatshwayo wobulwelwe lobu afaka hlangana nokulunywa okudluleleko esikhunjeni, kanye[[nokuphophala]].&lt;ref name=WHO2014/&gt; Lobu ubulwelwe busebujameni besibili emalwelweni abanga ukuphophala, ngemva[[kwetrachoma]].&lt;ref name=CDC2013/&gt;

&lt;!-- Cause and Diagnosis --&gt;
Itsikizi esasibungwana le ingena esikhumbeni itheleleke[[ngokulunywa yipukani ekulu enzima]]efana''[[ne-Simulium]]'' umhlobo wempukani.&lt;ref name=WHO2014/&gt; Esikhathini esinengi umuntu kufanele alunywe kanengi ngaphambi kobana angatheleleka ngobulwelwe lobu.&lt;ref name=CDCEpi2013&gt;{{cite web|title=Parasites – Onchocerciasis (also known as River Blindness) Epidemiology &amp; Risk Factors|url=http://www.cdc.gov/parasites/onchocerciasis/epi.html|work=CDC|accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt; Iimpukani lezi ezikulu ezinzima zihlala hlanu komlambo, ngikho negama lobulwelwe lobu kuthiwa ybulwelwe obuphophalisako bemlanjeni.&lt;ref name=CDC2013&gt;{{cite web |title=Onchocerciasis (also known as River Blindness) |work=Parasites  |url=http://www.cdc.gov/parasites/onchocerciasis/|publisher=CDC|accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt; Nazingena ngaphakathi emuntwini, imbungwanyana lezi zenza[[indlela yazo eyenza isibungu esisandukuqhoqhoselwa]]ezizokungena ngazo esikhunjeni phakathi.&lt;ref name=WHO2014/&gt; Bese nasele zingene zanzinza nazo ziyakwazi bona zithelele ipukani ezokuluma esikhunjeni somuntu loyo.&lt;ref name=WHO2014/&gt; Kuneendlela ezimbalwa ezingasetjenziswa ukuthola umrabho wobulwelwe: ukubeka[[ umtjhini i-biopsy phezu kwesikhumba]] ekhemikhalini esamanzana [[isaline]] bese ucala  isibungu esisandukuqhoqhoselwa nasiphumako, bese ucala ilihlo lesibungwana lesi, bese godu utjheja ingongoma engaphakathi kwesikhumba uqale iimbungu ezikulu.&lt;ref name=CDCDiag2013&gt;{{cite web |title=Onchocerciasis (also known as River Blindness) Diagnosis |publisher=CDC |url=http://www.cdc.gov/parasites/onchocerciasis/diagnosis.html |work=Parasites |accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt;

&lt;!-- Prevention and Treatment --&gt;
U[[ mjovo]] olwisana nobulwelwe lobu awutholakali awukho.&lt;ref name=WHO2014/&gt; Umuntu angazivikela ngokukhandela ukulunywa ziimpukani lezi ezikulu.&lt;ref name=CDCPre2013&gt;{{cite web|title=Onchocerciasis (also known as River Blindness) Prevention &amp; Control |url=http://www.cdc.gov/parasites/onchocerciasis/prevent.html|work=Parasites |publisher=CDC |accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt; Lokhu kungafaka hlangana ukusebenzisa[[isihlahla sokuvikela ukulunywa ziinunwana]] kanye nokwembatha kuhle.&lt;ref name=CDCPre2013/&gt; Eminye imizamo kungaba kukuthi uthele ispreyi esisihlahla sokubulala[[iinunwanwa eziphaphak]]o.&lt;ref name=WHO2014/&gt; Imizamo yokuphungula ubulwelwe lobu ngokulatjhwa kweenqhema zabantu kuyenzeka kabili ngomnyaka eendaweni ezinengi ephasini zombelele.&lt;ref name=WHO2014/&gt; Ukulatjhwa kwalabo abathelelekileko kusetjenziswa iinhlahla[[i-ivermecticin]]qobe iinyanga esisithandathu ukuya kezilitjhumu nambili.&lt;ref name=WHO2014/&gt;&lt;ref name=Murray2013/&gt; Isihlahla sokulapha lesi sibulala isibungu esisandukuqhoqhoselwa ingasi isibungu esikhulu.&lt;ref name=Yellow2012&gt;{{cite book|last=Brunette|first=Gary W.|title=CDC Health Information for International Travel 2012 : The Yellow Book |year=2011|publisher=Oxford University Press|isbn=9780199830367 |page=258 |url=http://books.google.ca/books?id=5vCQpr1WTS8C&amp;pg=PA258 }}&lt;/ref&gt; ihlahla[[idoxycycline]], yona ibulala[[ umulwana i-endosymbiont]]ebizwa''[[nge-Wolbachia]]'', isebenza ukubulala amandla wesibungu lesi, nayo iyakhuthazwa bona isetjenziswe.&lt;ref name=Yellow2012/&gt; Ukususwa kwamalunda ngaphakathi kwesikumba nakho kungenziwa ngokobana umuntu ahlinzwe.&lt;ref name=Murray2013&gt;{{cite book |last=Murray |first=Patrick |title=Medical microbiology |year=2013 |publisher=Elsevier Saunders |location=Philadelphia |isbn=9780323086929 |page=792|url=http://books.google.ca/books?id=RBEVsFmR2yQC&amp;pg=PA792 |edition=7th}}&lt;/ref&gt;

&lt;!--Epidemiology and History --&gt;
Isibalo esibalelwa ku17 ukuya kuma-25 weengidigidi, ababanjwe nofana abatheleleko bulwelwe bokuphophala bemlanjeni, ababalelwa eengidigidini ezi-0.8 inengi labo alisaboni ngamehlo seliphophele.&lt;ref name=CDCEpi2013/&gt;&lt;ref name=Yellow2012/&gt; Ukutheleleka okuneng kobulwelwe lobu[[kwenzeka khulu esiyingini-seSahara ye-Africa]], nanyana imibiko yezehlakalo ezinye ivele[[enarheni i-Yemen]] nakenzinye iindawo ezizijameleko[[ eKabeni|ye-Amerikha]] kanye[[ne-Sewula ye-Amerikha]].&lt;ref name=WHO2014/&gt; Ngo-1915, udorhodere[[uRodolfo Robles]] waqathanisa kokuthoma ubulwelwe lobu nesifo samehlo.&lt;ref&gt;{{cite book |editor1=Eldridge, Bruce F. |editor2=Edman, John D. |editor3= Edman, J. |title=Medical entomology |year=2004 |publisher=Kluwer Academic |location=Dordrecht |isbn=9781402017940|page=301 |url=http://books.google.ca/books?id=C7OxOqTKYS8C&amp;pg=PA301 |edition=Revised |author1=Lok, James B. |author2=Walker, Edward D. |author3=Scoles, Glen A. |chapter=9. Filariasis}}&lt;/ref&gt; Kuveziwe erhelweni[[le-World Health Organization]] njengesifo[[ esizijamele sodwa emangweni yethrophigi]].&lt;ref&gt;{{cite journal |author=Reddy M, Gill SS, Kalkar SR, Wu W, Anderson PJ, Rochon PA |title=Oral drug therapy for multiple neglected tropical diseases: a systematic review |journal=JAMA |volume=298 |issue=16 |pages=1911–24 |date=October 2007 |doi=10.1001/jama.298.16.1911 |pmid=17954542 |url=http://jama.jamanetwork.com/article.aspx?doi=10.1001/jama.298.16.1911}}&lt;/ref&gt;
==isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini==
&lt;references /&gt;</text>
      <sha1>mhaxnrfcqoanfb8ima4hf3iw63rkh79</sha1>
    </revision>
    <revision>
      <id>2014</id>
      <parentid>2013</parentid>
      <timestamp>2016-11-04T12:25:09Z</timestamp>
      <contributor>
        <username>incubator&gt;Doc James</username>
        <id>0</id>
      </contributor>
      <origin>2014</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6621" sha1="h1ra173iywlub6lmy1jxjelcau6hnj5" xml:space="preserve">{{Wp/nd/Infobox disease
| name           = Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale
| image          = Black fly.jpg
| caption        = Umuntu omdala[[uSimulium yahense|ipukani ekulu enzima]]kanye netsikizi''[[i-Onchocerca volvulus]]''ziphuma ngaphakathi kwendletjana yenunwanwa, ikhulisiwe 100x
| pronounce   = {{IPAc-en|ˌ|ɒ|ŋ|k|oʊ|s|ɜr|ˈ|s|aɪ|ə|s|ɨ|s|,_|-|ˈ|k|aɪ|-}}
| DiseasesDB     = 9218
| ICD10          = 
| ICD9           = 125.3
| ICDO           =
| OMIM           =
| MedlinePlus    =
| eMedicineSubj  = med
| eMedicineTopic = 1667
| eMedicine_mult = {{eMedicine2|oph|709}}
| MeshID         = D009855
}}

&lt;!-- Definition and symptoms --&gt;
'''Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale''', obaziwa ngokuthi''' bulwelwe obuphophalisako bemlanjeni''' begodu'''yaziwa ngokuthi yi-Robles disease''', bulwelwe obubangwa kutheleleka okulethwa  [[yitsikizi esasibungwana]] ''[[i-Onchocerca volvulus]]''.&lt;ref name=WHO2014&gt;{{cite web|title=Onchocerciasis Fact sheet N°374|url=http://www.who.int/mediacentre/factsheets/fs374/en/|work=World Health Organization|accessdate=20 March 2014|date=March 2014}}&lt;/ref&gt; Amatshwayo wobulwelwe lobu afaka hlangana nokulunywa okudluleleko esikhunjeni, kanye[[nokuphophala]].&lt;ref name=WHO2014/&gt; Lobu ubulwelwe busebujameni besibili emalwelweni abanga ukuphophala, ngemva[[kwetrachoma]].&lt;ref name=CDC2013/&gt;

&lt;!-- Cause and Diagnosis --&gt;
Itsikizi esasibungwana le ingena esikhumbeni itheleleke[[ngokulunywa yipukani ekulu enzima]]efana''[[ne-Simulium]]'' umhlobo wempukani.&lt;ref name=WHO2014/&gt; Esikhathini esinengi umuntu kufanele alunywe kanengi ngaphambi kobana angatheleleka ngobulwelwe lobu.&lt;ref name=CDCEpi2013&gt;{{cite web|title=Parasites – Onchocerciasis (also known as River Blindness) Epidemiology &amp; Risk Factors|url=http://www.cdc.gov/parasites/onchocerciasis/epi.html|work=CDC|accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt; Iimpukani lezi ezikulu ezinzima zihlala hlanu komlambo, ngikho negama lobulwelwe lobu kuthiwa ybulwelwe obuphophalisako bemlanjeni.&lt;ref name=CDC2013&gt;{{cite web |title=Onchocerciasis (also known as River Blindness) |work=Parasites  |url=http://www.cdc.gov/parasites/onchocerciasis/|publisher=CDC|accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt; Nazingena ngaphakathi emuntwini, imbungwanyana lezi zenza[[indlela yazo eyenza isibungu esisandukuqhoqhoselwa]]ezizokungena ngazo esikhunjeni phakathi.&lt;ref name=WHO2014/&gt; Bese nasele zingene zanzinza nazo ziyakwazi bona zithelele ipukani ezokuluma esikhunjeni somuntu loyo.&lt;ref name=WHO2014/&gt; Kuneendlela ezimbalwa ezingasetjenziswa ukuthola umrabho wobulwelwe: ukubeka[[ umtjhini i-biopsy phezu kwesikhumba]] ekhemikhalini esamanzana [[isaline]] bese ucala  isibungu esisandukuqhoqhoselwa nasiphumako, bese ucala ilihlo lesibungwana lesi, bese godu utjheja ingongoma engaphakathi kwesikhumba uqale iimbungu ezikulu.&lt;ref name=CDCDiag2013&gt;{{cite web |title=Onchocerciasis (also known as River Blindness) Diagnosis |publisher=CDC |url=http://www.cdc.gov/parasites/onchocerciasis/diagnosis.html |work=Parasites |accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt;

&lt;!-- Prevention and Treatment --&gt;
U[[ mjovo]] olwisana nobulwelwe lobu awutholakali awukho.&lt;ref name=WHO2014/&gt; Umuntu angazivikela ngokukhandela ukulunywa ziimpukani lezi ezikulu.&lt;ref name=CDCPre2013&gt;{{cite web|title=Onchocerciasis (also known as River Blindness) Prevention &amp; Control |url=http://www.cdc.gov/parasites/onchocerciasis/prevent.html|work=Parasites |publisher=CDC |accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt; Lokhu kungafaka hlangana ukusebenzisa[[isihlahla sokuvikela ukulunywa ziinunwana]] kanye nokwembatha kuhle.&lt;ref name=CDCPre2013/&gt; Eminye imizamo kungaba kukuthi uthele ispreyi esisihlahla sokubulala[[iinunwanwa eziphaphak]]o.&lt;ref name=WHO2014/&gt; Imizamo yokuphungula ubulwelwe lobu ngokulatjhwa kweenqhema zabantu kuyenzeka kabili ngomnyaka eendaweni ezinengi ephasini zombelele.&lt;ref name=WHO2014/&gt; Ukulatjhwa kwalabo abathelelekileko kusetjenziswa iinhlahla[[i-ivermecticin]]qobe iinyanga esisithandathu ukuya kezilitjhumu nambili.&lt;ref name=WHO2014/&gt;&lt;ref name=Murray2013/&gt; Isihlahla sokulapha lesi sibulala isibungu esisandukuqhoqhoselwa ingasi isibungu esikhulu.&lt;ref name=Yellow2012&gt;{{cite book|last=Brunette|first=Gary W.|title=CDC Health Information for International Travel 2012 : The Yellow Book |year=2011|publisher=Oxford University Press|isbn=9780199830367 |page=258 |url=http://books.google.ca/books?id=5vCQpr1WTS8C&amp;pg=PA258 }}&lt;/ref&gt; ihlahla[[idoxycycline]], yona ibulala[[ umulwana i-endosymbiont]]ebizwa''[[nge-Wolbachia]]'', isebenza ukubulala amandla wesibungu lesi, nayo iyakhuthazwa bona isetjenziswe.&lt;ref name=Yellow2012/&gt; Ukususwa kwamalunda ngaphakathi kwesikumba nakho kungenziwa ngokobana umuntu ahlinzwe.&lt;ref name=Murray2013&gt;{{cite book |last=Murray |first=Patrick |title=Medical microbiology |year=2013 |publisher=Elsevier Saunders |location=Philadelphia |isbn=9780323086929 |page=792|url=http://books.google.ca/books?id=RBEVsFmR2yQC&amp;pg=PA792 |edition=7th}}&lt;/ref&gt;

&lt;!--Epidemiology and History --&gt;
Isibalo esibalelwa ku17 ukuya kuma-25 weengidigidi, ababanjwe nofana abatheleleko bulwelwe bokuphophala bemlanjeni, ababalelwa eengidigidini ezi-0.8 inengi labo alisaboni ngamehlo seliphophele.&lt;ref name=CDCEpi2013/&gt;&lt;ref name=Yellow2012/&gt; Ukutheleleka okuneng kobulwelwe lobu[[kwenzeka khulu esiyingini-seSahara ye-Africa]], nanyana imibiko yezehlakalo ezinye ivele[[enarheni i-Yemen]] nakenzinye iindawo ezizijameleko[[ eKabeni|ye-Amerikha]] kanye[[ne-Sewula ye-Amerikha]].&lt;ref name=WHO2014/&gt; Ngo-1915, udorhodere[[uRodolfo Robles]] waqathanisa kokuthoma ubulwelwe lobu nesifo samehlo.&lt;ref&gt;{{cite book |editor1=Eldridge, Bruce F. |editor2=Edman, John D. |editor3= Edman, J. |title=Medical entomology |year=2004 |publisher=Kluwer Academic |location=Dordrecht |isbn=9781402017940|page=301 |url=http://books.google.ca/books?id=C7OxOqTKYS8C&amp;pg=PA301 |edition=Revised |author1=Lok, James B. |author2=Walker, Edward D. |author3=Scoles, Glen A. |chapter=9. Filariasis}}&lt;/ref&gt; Kuveziwe erhelweni[[le-World Health Organization]] njengesifo[[ esizijamele sodwa emangweni yethrophigi]].&lt;ref&gt;{{cite journal |author=Reddy M, Gill SS, Kalkar SR, Wu W, Anderson PJ, Rochon PA |title=Oral drug therapy for multiple neglected tropical diseases: a systematic review |journal=JAMA |volume=298 |issue=16 |pages=1911–24 |date=October 2007 |doi=10.1001/jama.298.16.1911 |pmid=17954542 |url=http://jama.jamanetwork.com/article.aspx?doi=10.1001/jama.298.16.1911}}&lt;/ref&gt;
==isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini==
&lt;references /&gt;</text>
      <sha1>h1ra173iywlub6lmy1jxjelcau6hnj5</sha1>
    </revision>
    <revision>
      <id>2015</id>
      <parentid>2014</parentid>
      <timestamp>2016-11-04T12:25:56Z</timestamp>
      <contributor>
        <username>incubator&gt;Doc James</username>
        <id>0</id>
      </contributor>
      <origin>2015</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6625" sha1="03y0dqpbdqod41ih69bsuds6pt7kb0y" xml:space="preserve">{{Wp/nd/Infobox disease
| name           = Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale
| image          = Black fly.jpg
| caption        = Umuntu omdala [[uSimulium yahense|ipukani ekulu enzima]] kanye netsikizi ''[[i-Onchocerca volvulus]]'' ziphuma ngaphakathi kwendletjana yenunwanwa, ikhulisiwe 100x
| pronounce   = {{IPAc-en|ˌ|ɒ|ŋ|k|oʊ|s|ɜr|ˈ|s|aɪ|ə|s|ɨ|s|,_|-|ˈ|k|aɪ|-}}
| DiseasesDB     = 9218
| ICD10          = 
| ICD9           = 125.3
| ICDO           =
| OMIM           =
| MedlinePlus    =
| eMedicineSubj  = med
| eMedicineTopic = 1667
| eMedicine_mult = {{eMedicine2|oph|709}}
| MeshID         = D009855
}}

&lt;!-- Definition and symptoms --&gt;
'''Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale''', obaziwa ngokuthi''' bulwelwe obuphophalisako bemlanjeni''' begodu'''yaziwa ngokuthi yi-Robles disease''', bulwelwe obubangwa kutheleleka okulethwa  [[yitsikizi esasibungwana]] ''[[i-Onchocerca volvulus]]''.&lt;ref name=WHO2014&gt;{{cite web|title=Onchocerciasis Fact sheet N°374|url=http://www.who.int/mediacentre/factsheets/fs374/en/|work=World Health Organization|accessdate=20 March 2014|date=March 2014}}&lt;/ref&gt; Amatshwayo wobulwelwe lobu afaka hlangana nokulunywa okudluleleko esikhunjeni, kanye[[nokuphophala]].&lt;ref name=WHO2014/&gt; Lobu ubulwelwe busebujameni besibili emalwelweni abanga ukuphophala, ngemva[[kwetrachoma]].&lt;ref name=CDC2013/&gt;

&lt;!-- Cause and Diagnosis --&gt;
Itsikizi esasibungwana le ingena esikhumbeni itheleleke[[ngokulunywa yipukani ekulu enzima]]efana''[[ne-Simulium]]'' umhlobo wempukani.&lt;ref name=WHO2014/&gt; Esikhathini esinengi umuntu kufanele alunywe kanengi ngaphambi kobana angatheleleka ngobulwelwe lobu.&lt;ref name=CDCEpi2013&gt;{{cite web|title=Parasites – Onchocerciasis (also known as River Blindness) Epidemiology &amp; Risk Factors|url=http://www.cdc.gov/parasites/onchocerciasis/epi.html|work=CDC|accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt; Iimpukani lezi ezikulu ezinzima zihlala hlanu komlambo, ngikho negama lobulwelwe lobu kuthiwa ybulwelwe obuphophalisako bemlanjeni.&lt;ref name=CDC2013&gt;{{cite web |title=Onchocerciasis (also known as River Blindness) |work=Parasites  |url=http://www.cdc.gov/parasites/onchocerciasis/|publisher=CDC|accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt; Nazingena ngaphakathi emuntwini, imbungwanyana lezi zenza[[indlela yazo eyenza isibungu esisandukuqhoqhoselwa]]ezizokungena ngazo esikhunjeni phakathi.&lt;ref name=WHO2014/&gt; Bese nasele zingene zanzinza nazo ziyakwazi bona zithelele ipukani ezokuluma esikhunjeni somuntu loyo.&lt;ref name=WHO2014/&gt; Kuneendlela ezimbalwa ezingasetjenziswa ukuthola umrabho wobulwelwe: ukubeka[[ umtjhini i-biopsy phezu kwesikhumba]] ekhemikhalini esamanzana [[isaline]] bese ucala  isibungu esisandukuqhoqhoselwa nasiphumako, bese ucala ilihlo lesibungwana lesi, bese godu utjheja ingongoma engaphakathi kwesikhumba uqale iimbungu ezikulu.&lt;ref name=CDCDiag2013&gt;{{cite web |title=Onchocerciasis (also known as River Blindness) Diagnosis |publisher=CDC |url=http://www.cdc.gov/parasites/onchocerciasis/diagnosis.html |work=Parasites |accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt;

&lt;!-- Prevention and Treatment --&gt;
U[[ mjovo]] olwisana nobulwelwe lobu awutholakali awukho.&lt;ref name=WHO2014/&gt; Umuntu angazivikela ngokukhandela ukulunywa ziimpukani lezi ezikulu.&lt;ref name=CDCPre2013&gt;{{cite web|title=Onchocerciasis (also known as River Blindness) Prevention &amp; Control |url=http://www.cdc.gov/parasites/onchocerciasis/prevent.html|work=Parasites |publisher=CDC |accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt; Lokhu kungafaka hlangana ukusebenzisa[[isihlahla sokuvikela ukulunywa ziinunwana]] kanye nokwembatha kuhle.&lt;ref name=CDCPre2013/&gt; Eminye imizamo kungaba kukuthi uthele ispreyi esisihlahla sokubulala[[iinunwanwa eziphaphak]]o.&lt;ref name=WHO2014/&gt; Imizamo yokuphungula ubulwelwe lobu ngokulatjhwa kweenqhema zabantu kuyenzeka kabili ngomnyaka eendaweni ezinengi ephasini zombelele.&lt;ref name=WHO2014/&gt; Ukulatjhwa kwalabo abathelelekileko kusetjenziswa iinhlahla[[i-ivermecticin]]qobe iinyanga esisithandathu ukuya kezilitjhumu nambili.&lt;ref name=WHO2014/&gt;&lt;ref name=Murray2013/&gt; Isihlahla sokulapha lesi sibulala isibungu esisandukuqhoqhoselwa ingasi isibungu esikhulu.&lt;ref name=Yellow2012&gt;{{cite book|last=Brunette|first=Gary W.|title=CDC Health Information for International Travel 2012 : The Yellow Book |year=2011|publisher=Oxford University Press|isbn=9780199830367 |page=258 |url=http://books.google.ca/books?id=5vCQpr1WTS8C&amp;pg=PA258 }}&lt;/ref&gt; ihlahla[[idoxycycline]], yona ibulala[[ umulwana i-endosymbiont]]ebizwa''[[nge-Wolbachia]]'', isebenza ukubulala amandla wesibungu lesi, nayo iyakhuthazwa bona isetjenziswe.&lt;ref name=Yellow2012/&gt; Ukususwa kwamalunda ngaphakathi kwesikumba nakho kungenziwa ngokobana umuntu ahlinzwe.&lt;ref name=Murray2013&gt;{{cite book |last=Murray |first=Patrick |title=Medical microbiology |year=2013 |publisher=Elsevier Saunders |location=Philadelphia |isbn=9780323086929 |page=792|url=http://books.google.ca/books?id=RBEVsFmR2yQC&amp;pg=PA792 |edition=7th}}&lt;/ref&gt;

&lt;!--Epidemiology and History --&gt;
Isibalo esibalelwa ku17 ukuya kuma-25 weengidigidi, ababanjwe nofana abatheleleko bulwelwe bokuphophala bemlanjeni, ababalelwa eengidigidini ezi-0.8 inengi labo alisaboni ngamehlo seliphophele.&lt;ref name=CDCEpi2013/&gt;&lt;ref name=Yellow2012/&gt; Ukutheleleka okuneng kobulwelwe lobu[[kwenzeka khulu esiyingini-seSahara ye-Africa]], nanyana imibiko yezehlakalo ezinye ivele[[enarheni i-Yemen]] nakenzinye iindawo ezizijameleko[[ eKabeni|ye-Amerikha]] kanye[[ne-Sewula ye-Amerikha]].&lt;ref name=WHO2014/&gt; Ngo-1915, udorhodere[[uRodolfo Robles]] waqathanisa kokuthoma ubulwelwe lobu nesifo samehlo.&lt;ref&gt;{{cite book |editor1=Eldridge, Bruce F. |editor2=Edman, John D. |editor3= Edman, J. |title=Medical entomology |year=2004 |publisher=Kluwer Academic |location=Dordrecht |isbn=9781402017940|page=301 |url=http://books.google.ca/books?id=C7OxOqTKYS8C&amp;pg=PA301 |edition=Revised |author1=Lok, James B. |author2=Walker, Edward D. |author3=Scoles, Glen A. |chapter=9. Filariasis}}&lt;/ref&gt; Kuveziwe erhelweni[[le-World Health Organization]] njengesifo[[ esizijamele sodwa emangweni yethrophigi]].&lt;ref&gt;{{cite journal |author=Reddy M, Gill SS, Kalkar SR, Wu W, Anderson PJ, Rochon PA |title=Oral drug therapy for multiple neglected tropical diseases: a systematic review |journal=JAMA |volume=298 |issue=16 |pages=1911–24 |date=October 2007 |doi=10.1001/jama.298.16.1911 |pmid=17954542 |url=http://jama.jamanetwork.com/article.aspx?doi=10.1001/jama.298.16.1911}}&lt;/ref&gt;
==isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini==
&lt;references /&gt;</text>
      <sha1>03y0dqpbdqod41ih69bsuds6pt7kb0y</sha1>
    </revision>
    <revision>
      <id>2016</id>
      <parentid>2015</parentid>
      <timestamp>2016-11-08T21:15:00Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <origin>2016</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6662" sha1="l5oda41sv5ka1sgtc1pb5flj9057ppj" xml:space="preserve">{{Wp/nd/Infobox disease
| name           = Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale
| image          = Black fly.jpg
| caption        = Umuntu omdala[[uSimulium yahense|ipukani ekulu enzima]]kanye netsikizi''[[i-Onchocerca volvulus]]''ziphuma ngaphakathi kwendletjana yenunwanwa, ikhulisiwe 100x
| pronounce   = {{IPAc-en|ˌ|ɒ|ŋ|k|oʊ|s|ɜr|ˈ|s|aɪ|ə|s|ɨ|s|,_|-|ˈ|k|aɪ|-}}
| DiseasesDB     = 9218
| ICD10          = {{Wp/nd/ICD10|B|73||b|65}}
| ICD9           = {{Wp/nd/ICD9|125.3}}
| ICDO           =
| OMIM           =
| MedlinePlus    =
| eMedicineSubj  = med
| eMedicineTopic = 1667
| eMedicine_mult = {{eMedicine2|oph|709}}
| MeshID         = D009855
}}

&lt;!-- Definition and symptoms --&gt;
'''Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale''', obaziwa ngokuthi''' bulwelwe obuphophalisako bemlanjeni''' begodu'''yaziwa ngokuthi yi-Robles disease''', bulwelwe obubangwa kutheleleka okulethwa  [[yitsikizi esasibungwana]] ''[[i-Onchocerca volvulus]]''.&lt;ref name=WHO2014&gt;{{cite web|title=Onchocerciasis Fact sheet N°374|url=http://www.who.int/mediacentre/factsheets/fs374/en/|work=World Health Organization|accessdate=20 March 2014|date=March 2014}}&lt;/ref&gt; Amatshwayo wobulwelwe lobu afaka hlangana nokulunywa okudluleleko esikhunjeni, kanye[[nokuphophala]].&lt;ref name=WHO2014/&gt; Lobu ubulwelwe busebujameni besibili emalwelweni abanga ukuphophala, ngemva[[kwetrachoma]].&lt;ref name=CDC2013/&gt;

&lt;!-- Cause and Diagnosis --&gt;
Itsikizi esasibungwana le ingena esikhumbeni itheleleke[[ngokulunywa yipukani ekulu enzima]]efana''[[ne-Simulium]]'' umhlobo wempukani.&lt;ref name=WHO2014/&gt; Esikhathini esinengi umuntu kufanele alunywe kanengi ngaphambi kobana angatheleleka ngobulwelwe lobu.&lt;ref name=CDCEpi2013&gt;{{cite web|title=Parasites – Onchocerciasis (also known as River Blindness) Epidemiology &amp; Risk Factors|url=http://www.cdc.gov/parasites/onchocerciasis/epi.html|work=CDC|accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt; Iimpukani lezi ezikulu ezinzima zihlala hlanu komlambo, ngikho negama lobulwelwe lobu kuthiwa ybulwelwe obuphophalisako bemlanjeni.&lt;ref name=CDC2013&gt;{{cite web |title=Onchocerciasis (also known as River Blindness) |work=Parasites  |url=http://www.cdc.gov/parasites/onchocerciasis/|publisher=CDC|accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt; Nazingena ngaphakathi emuntwini, imbungwanyana lezi zenza[[indlela yazo eyenza isibungu esisandukuqhoqhoselwa]]ezizokungena ngazo esikhunjeni phakathi.&lt;ref name=WHO2014/&gt; Bese nasele zingene zanzinza nazo ziyakwazi bona zithelele ipukani ezokuluma esikhunjeni somuntu loyo.&lt;ref name=WHO2014/&gt; Kuneendlela ezimbalwa ezingasetjenziswa ukuthola umrabho wobulwelwe: ukubeka[[ umtjhini i-biopsy phezu kwesikhumba]] ekhemikhalini esamanzana [[isaline]] bese ucala  isibungu esisandukuqhoqhoselwa nasiphumako, bese ucala ilihlo lesibungwana lesi, bese godu utjheja ingongoma engaphakathi kwesikhumba uqale iimbungu ezikulu.&lt;ref name=CDCDiag2013&gt;{{cite web |title=Onchocerciasis (also known as River Blindness) Diagnosis |publisher=CDC |url=http://www.cdc.gov/parasites/onchocerciasis/diagnosis.html |work=Parasites |accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt;

&lt;!-- Prevention and Treatment --&gt;
U[[ mjovo]] olwisana nobulwelwe lobu awutholakali awukho.&lt;ref name=WHO2014/&gt; Umuntu angazivikela ngokukhandela ukulunywa ziimpukani lezi ezikulu.&lt;ref name=CDCPre2013&gt;{{cite web|title=Onchocerciasis (also known as River Blindness) Prevention &amp; Control |url=http://www.cdc.gov/parasites/onchocerciasis/prevent.html|work=Parasites |publisher=CDC |accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt; Lokhu kungafaka hlangana ukusebenzisa[[isihlahla sokuvikela ukulunywa ziinunwana]] kanye nokwembatha kuhle.&lt;ref name=CDCPre2013/&gt; Eminye imizamo kungaba kukuthi uthele ispreyi esisihlahla sokubulala[[iinunwanwa eziphaphak]]o.&lt;ref name=WHO2014/&gt; Imizamo yokuphungula ubulwelwe lobu ngokulatjhwa kweenqhema zabantu kuyenzeka kabili ngomnyaka eendaweni ezinengi ephasini zombelele.&lt;ref name=WHO2014/&gt; Ukulatjhwa kwalabo abathelelekileko kusetjenziswa iinhlahla[[i-ivermecticin]]qobe iinyanga esisithandathu ukuya kezilitjhumu nambili.&lt;ref name=WHO2014/&gt;&lt;ref name=Murray2013/&gt; Isihlahla sokulapha lesi sibulala isibungu esisandukuqhoqhoselwa ingasi isibungu esikhulu.&lt;ref name=Yellow2012&gt;{{cite book|last=Brunette|first=Gary W.|title=CDC Health Information for International Travel 2012 : The Yellow Book |year=2011|publisher=Oxford University Press|isbn=9780199830367 |page=258 |url=http://books.google.ca/books?id=5vCQpr1WTS8C&amp;pg=PA258 }}&lt;/ref&gt; ihlahla[[idoxycycline]], yona ibulala[[ umulwana i-endosymbiont]]ebizwa''[[nge-Wolbachia]]'', isebenza ukubulala amandla wesibungu lesi, nayo iyakhuthazwa bona isetjenziswe.&lt;ref name=Yellow2012/&gt; Ukususwa kwamalunda ngaphakathi kwesikumba nakho kungenziwa ngokobana umuntu ahlinzwe.&lt;ref name=Murray2013&gt;{{cite book |last=Murray |first=Patrick |title=Medical microbiology |year=2013 |publisher=Elsevier Saunders |location=Philadelphia |isbn=9780323086929 |page=792|url=http://books.google.ca/books?id=RBEVsFmR2yQC&amp;pg=PA792 |edition=7th}}&lt;/ref&gt;

&lt;!--Epidemiology and History --&gt;
Isibalo esibalelwa ku17 ukuya kuma-25 weengidigidi, ababanjwe nofana abatheleleko bulwelwe bokuphophala bemlanjeni, ababalelwa eengidigidini ezi-0.8 inengi labo alisaboni ngamehlo seliphophele.&lt;ref name=CDCEpi2013/&gt;&lt;ref name=Yellow2012/&gt; Ukutheleleka okuneng kobulwelwe lobu[[kwenzeka khulu esiyingini-seSahara ye-Africa]], nanyana imibiko yezehlakalo ezinye ivele[[enarheni i-Yemen]] nakenzinye iindawo ezizijameleko[[ eKabeni|ye-Amerikha]] kanye[[ne-Sewula ye-Amerikha]].&lt;ref name=WHO2014/&gt; Ngo-1915, udorhodere[[uRodolfo Robles]] waqathanisa kokuthoma ubulwelwe lobu nesifo samehlo.&lt;ref&gt;{{cite book |editor1=Eldridge, Bruce F. |editor2=Edman, John D. |editor3= Edman, J. |title=Medical entomology |year=2004 |publisher=Kluwer Academic |location=Dordrecht |isbn=9781402017940|page=301 |url=http://books.google.ca/books?id=C7OxOqTKYS8C&amp;pg=PA301 |edition=Revised |author1=Lok, James B. |author2=Walker, Edward D. |author3=Scoles, Glen A. |chapter=9. Filariasis}}&lt;/ref&gt; Kuveziwe erhelweni[[le-World Health Organization]] njengesifo[[ esizijamele sodwa emangweni yethrophigi]].&lt;ref&gt;{{cite journal |author=Reddy M, Gill SS, Kalkar SR, Wu W, Anderson PJ, Rochon PA |title=Oral drug therapy for multiple neglected tropical diseases: a systematic review |journal=JAMA |volume=298 |issue=16 |pages=1911–24 |date=October 2007 |doi=10.1001/jama.298.16.1911 |pmid=17954542 |url=http://jama.jamanetwork.com/article.aspx?doi=10.1001/jama.298.16.1911}}&lt;/ref&gt;
==isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini==
&lt;references /&gt;</text>
      <sha1>l5oda41sv5ka1sgtc1pb5flj9057ppj</sha1>
    </revision>
    <revision>
      <id>2017</id>
      <parentid>2016</parentid>
      <timestamp>2016-11-09T15:48:24Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <origin>2017</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6716" sha1="cssdtvbj0xzr2kt45l4rf9a52rkjaca" xml:space="preserve">{{Wp/nd/Infobox disease
| name           = Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale
| image          = Black fly.jpg
| caption        = Umuntu omdala[[uSimulium yahense|ipukani ekulu enzima]]kanye netsikizi''[[i-Onchocerca volvulus]]''ziphuma ngaphakathi kwendletjana yenunwanwa, ikhulisiwe 100x
| pronounce   = {{IPAc-en|ˌ|ɒ|ŋ|k|oʊ|s|ɜr|ˈ|s|aɪ|ə|s|ɨ|s|,_|-|ˈ|k|aɪ|-}}
| DiseasesDB     = 9218
| ICD10          = {{Wp/nd/ICD10|B|73||b|65}}
| ICD9           = {{Wp/nd/ICD9|125.3}}
| ICDO           =
| OMIM           =
| MedlinePlus    =
| eMedicineSubj  = med
| eMedicineTopic = 1667
| eMedicine_mult = {{eMedicine2|oph|709}}
| MeshID         = D009855
}}

&lt;!-- Definition and symptoms --&gt;
'''Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale''', obaziwa ngokuthi''' bulwelwe obuphophalisako bemlanjeni''' begodu'''yaziwa ngokuthi yi-Robles disease''', bulwelwe obubangwa kutheleleka okulethwa  [[yitsikizi esasibungwana]] ''[[i-Onchocerca volvulus]]''.&lt;ref name=WHO2014&gt;{{Wp/nd/cite web|title=Onchocerciasis Fact sheet N°374|url=http://www.who.int/mediacentre/factsheets/fs374/en/|work=World Health Organization|accessdate=20 March 2014|date=March 2014}}&lt;/ref&gt; Amatshwayo wobulwelwe lobu afaka hlangana nokulunywa okudluleleko esikhunjeni, kanye[[nokuphophala]].&lt;ref name=WHO2014/&gt; Lobu ubulwelwe busebujameni besibili emalwelweni abanga ukuphophala, ngemva[[kwetrachoma]].&lt;ref name=CDC2013/&gt;

&lt;!-- Cause and Diagnosis --&gt;
Itsikizi esasibungwana le ingena esikhumbeni itheleleke[[ngokulunywa yipukani ekulu enzima]]efana''[[ne-Simulium]]'' umhlobo wempukani.&lt;ref name=WHO2014/&gt; Esikhathini esinengi umuntu kufanele alunywe kanengi ngaphambi kobana angatheleleka ngobulwelwe lobu.&lt;ref name=CDCEpi2013&gt;{{Wp/nd/cite web|title=Parasites – Onchocerciasis (also known as River Blindness) Epidemiology &amp; Risk Factors|url=http://www.cdc.gov/parasites/onchocerciasis/epi.html|work=CDC|accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt; Iimpukani lezi ezikulu ezinzima zihlala hlanu komlambo, ngikho negama lobulwelwe lobu kuthiwa ybulwelwe obuphophalisako bemlanjeni.&lt;ref name=CDC2013&gt;{{Wp/nd/cite web |title=Onchocerciasis (also known as River Blindness) |work=Parasites  |url=http://www.cdc.gov/parasites/onchocerciasis/|publisher=CDC|accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt; Nazingena ngaphakathi emuntwini, imbungwanyana lezi zenza[[indlela yazo eyenza isibungu esisandukuqhoqhoselwa]]ezizokungena ngazo esikhunjeni phakathi.&lt;ref name=WHO2014/&gt; Bese nasele zingene zanzinza nazo ziyakwazi bona zithelele ipukani ezokuluma esikhunjeni somuntu loyo.&lt;ref name=WHO2014/&gt; Kuneendlela ezimbalwa ezingasetjenziswa ukuthola umrabho wobulwelwe: ukubeka[[ umtjhini i-biopsy phezu kwesikhumba]] ekhemikhalini esamanzana [[isaline]] bese ucala  isibungu esisandukuqhoqhoselwa nasiphumako, bese ucala ilihlo lesibungwana lesi, bese godu utjheja ingongoma engaphakathi kwesikhumba uqale iimbungu ezikulu.&lt;ref name=CDCDiag2013&gt;{{Wp/nd/cite web |title=Onchocerciasis (also known as River Blindness) Diagnosis |publisher=CDC |url=http://www.cdc.gov/parasites/onchocerciasis/diagnosis.html |work=Parasites |accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt;

&lt;!-- Prevention and Treatment --&gt;
U[[ mjovo]] olwisana nobulwelwe lobu awutholakali awukho.&lt;ref name=WHO2014/&gt; Umuntu angazivikela ngokukhandela ukulunywa ziimpukani lezi ezikulu.&lt;ref name=CDCPre2013&gt;{{Wp/nd/cite web|title=Onchocerciasis (also known as River Blindness) Prevention &amp; Control |url=http://www.cdc.gov/parasites/onchocerciasis/prevent.html|work=Parasites |publisher=CDC |accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt; Lokhu kungafaka hlangana ukusebenzisa[[isihlahla sokuvikela ukulunywa ziinunwana]] kanye nokwembatha kuhle.&lt;ref name=CDCPre2013/&gt; Eminye imizamo kungaba kukuthi uthele ispreyi esisihlahla sokubulala[[iinunwanwa eziphaphak]]o.&lt;ref name=WHO2014/&gt; Imizamo yokuphungula ubulwelwe lobu ngokulatjhwa kweenqhema zabantu kuyenzeka kabili ngomnyaka eendaweni ezinengi ephasini zombelele.&lt;ref name=WHO2014/&gt; Ukulatjhwa kwalabo abathelelekileko kusetjenziswa iinhlahla[[i-ivermecticin]]qobe iinyanga esisithandathu ukuya kezilitjhumu nambili.&lt;ref name=WHO2014/&gt;&lt;ref name=Murray2013/&gt; Isihlahla sokulapha lesi sibulala isibungu esisandukuqhoqhoselwa ingasi isibungu esikhulu.&lt;ref name=Yellow2012&gt;{{Wp/nd/cite book|last=Brunette|first=Gary W.|title=CDC Health Information for International Travel 2012 : The Yellow Book |year=2011|publisher=Oxford University Press|isbn=9780199830367 |page=258 |url=http://books.google.ca/books?id=5vCQpr1WTS8C&amp;pg=PA258 }}&lt;/ref&gt; ihlahla[[idoxycycline]], yona ibulala[[ umulwana i-endosymbiont]]ebizwa''[[nge-Wolbachia]]'', isebenza ukubulala amandla wesibungu lesi, nayo iyakhuthazwa bona isetjenziswe.&lt;ref name=Yellow2012/&gt; Ukususwa kwamalunda ngaphakathi kwesikumba nakho kungenziwa ngokobana umuntu ahlinzwe.&lt;ref name=Murray2013&gt;{{Wp/nd/cite book |last=Murray |first=Patrick |title=Medical microbiology |year=2013 |publisher=Elsevier Saunders |location=Philadelphia |isbn=9780323086929 |page=792|url=http://books.google.ca/books?id=RBEVsFmR2yQC&amp;pg=PA792 |edition=7th}}&lt;/ref&gt;

&lt;!--Epidemiology and History --&gt;
Isibalo esibalelwa ku17 ukuya kuma-25 weengidigidi, ababanjwe nofana abatheleleko bulwelwe bokuphophala bemlanjeni, ababalelwa eengidigidini ezi-0.8 inengi labo alisaboni ngamehlo seliphophele.&lt;ref name=CDCEpi2013/&gt;&lt;ref name=Yellow2012/&gt; Ukutheleleka okuneng kobulwelwe lobu[[kwenzeka khulu esiyingini-seSahara ye-Africa]], nanyana imibiko yezehlakalo ezinye ivele[[enarheni i-Yemen]] nakenzinye iindawo ezizijameleko[[ eKabeni|ye-Amerikha]] kanye[[ne-Sewula ye-Amerikha]].&lt;ref name=WHO2014/&gt; Ngo-1915, udorhodere[[uRodolfo Robles]] waqathanisa kokuthoma ubulwelwe lobu nesifo samehlo.&lt;ref&gt;{{Wp/nd/cite book |editor1=Eldridge, Bruce F. |editor2=Edman, John D. |editor3= Edman, J. |title=Medical entomology |year=2004 |publisher=Kluwer Academic |location=Dordrecht |isbn=9781402017940|page=301 |url=http://books.google.ca/books?id=C7OxOqTKYS8C&amp;pg=PA301 |edition=Revised |author1=Lok, James B. |author2=Walker, Edward D. |author3=Scoles, Glen A. |chapter=9. Filariasis}}&lt;/ref&gt; Kuveziwe erhelweni[[le-World Health Organization]] njengesifo[[ esizijamele sodwa emangweni yethrophigi]].&lt;ref&gt;{{Wp/nd/cite journal |author=Reddy M, Gill SS, Kalkar SR, Wu W, Anderson PJ, Rochon PA |title=Oral drug therapy for multiple neglected tropical diseases: a systematic review |journal=JAMA |volume=298 |issue=16 |pages=1911–24 |date=October 2007 |doi=10.1001/jama.298.16.1911 |pmid=17954542 |url=http://jama.jamanetwork.com/article.aspx?doi=10.1001/jama.298.16.1911}}&lt;/ref&gt;
==isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini==
&lt;references /&gt;</text>
      <sha1>cssdtvbj0xzr2kt45l4rf9a52rkjaca</sha1>
    </revision>
    <revision>
      <id>2018</id>
      <parentid>2017</parentid>
      <timestamp>2020-07-23T11:46:46Z</timestamp>
      <contributor>
        <username>incubator&gt;CommonsDelinker</username>
        <id>0</id>
      </contributor>
      <comment>Replacing [[Image:Black_fly.jpg]] with [[Image:Onchocerca_volvulus_emerging_from_a_black_fly.jpg]] (deleted by [[commons:User:CommonsDelinker|CommonsDelinker]] because of: file renamed or replaced on Commons).</comment>
      <origin>2018</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6752" sha1="5n2jhk5xrf4ofs04n360c55o4i30syu" xml:space="preserve">{{Wp/nd/Infobox disease
| name           = Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale
| image          = Onchocerca volvulus emerging from a black fly.jpg
| caption        = Umuntu omdala[[uSimulium yahense|ipukani ekulu enzima]]kanye netsikizi''[[i-Onchocerca volvulus]]''ziphuma ngaphakathi kwendletjana yenunwanwa, ikhulisiwe 100x
| pronounce   = {{IPAc-en|ˌ|ɒ|ŋ|k|oʊ|s|ɜr|ˈ|s|aɪ|ə|s|ɨ|s|,_|-|ˈ|k|aɪ|-}}
| DiseasesDB     = 9218
| ICD10          = {{Wp/nd/ICD10|B|73||b|65}}
| ICD9           = {{Wp/nd/ICD9|125.3}}
| ICDO           =
| OMIM           =
| MedlinePlus    =
| eMedicineSubj  = med
| eMedicineTopic = 1667
| eMedicine_mult = {{eMedicine2|oph|709}}
| MeshID         = D009855
}}

&lt;!-- Definition and symptoms --&gt;
'''Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale''', obaziwa ngokuthi''' bulwelwe obuphophalisako bemlanjeni''' begodu'''yaziwa ngokuthi yi-Robles disease''', bulwelwe obubangwa kutheleleka okulethwa  [[yitsikizi esasibungwana]] ''[[i-Onchocerca volvulus]]''.&lt;ref name=WHO2014&gt;{{Wp/nd/cite web|title=Onchocerciasis Fact sheet N°374|url=http://www.who.int/mediacentre/factsheets/fs374/en/|work=World Health Organization|accessdate=20 March 2014|date=March 2014}}&lt;/ref&gt; Amatshwayo wobulwelwe lobu afaka hlangana nokulunywa okudluleleko esikhunjeni, kanye[[nokuphophala]].&lt;ref name=WHO2014/&gt; Lobu ubulwelwe busebujameni besibili emalwelweni abanga ukuphophala, ngemva[[kwetrachoma]].&lt;ref name=CDC2013/&gt;

&lt;!-- Cause and Diagnosis --&gt;
Itsikizi esasibungwana le ingena esikhumbeni itheleleke[[ngokulunywa yipukani ekulu enzima]]efana''[[ne-Simulium]]'' umhlobo wempukani.&lt;ref name=WHO2014/&gt; Esikhathini esinengi umuntu kufanele alunywe kanengi ngaphambi kobana angatheleleka ngobulwelwe lobu.&lt;ref name=CDCEpi2013&gt;{{Wp/nd/cite web|title=Parasites – Onchocerciasis (also known as River Blindness) Epidemiology &amp; Risk Factors|url=http://www.cdc.gov/parasites/onchocerciasis/epi.html|work=CDC|accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt; Iimpukani lezi ezikulu ezinzima zihlala hlanu komlambo, ngikho negama lobulwelwe lobu kuthiwa ybulwelwe obuphophalisako bemlanjeni.&lt;ref name=CDC2013&gt;{{Wp/nd/cite web |title=Onchocerciasis (also known as River Blindness) |work=Parasites  |url=http://www.cdc.gov/parasites/onchocerciasis/|publisher=CDC|accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt; Nazingena ngaphakathi emuntwini, imbungwanyana lezi zenza[[indlela yazo eyenza isibungu esisandukuqhoqhoselwa]]ezizokungena ngazo esikhunjeni phakathi.&lt;ref name=WHO2014/&gt; Bese nasele zingene zanzinza nazo ziyakwazi bona zithelele ipukani ezokuluma esikhunjeni somuntu loyo.&lt;ref name=WHO2014/&gt; Kuneendlela ezimbalwa ezingasetjenziswa ukuthola umrabho wobulwelwe: ukubeka[[ umtjhini i-biopsy phezu kwesikhumba]] ekhemikhalini esamanzana [[isaline]] bese ucala  isibungu esisandukuqhoqhoselwa nasiphumako, bese ucala ilihlo lesibungwana lesi, bese godu utjheja ingongoma engaphakathi kwesikhumba uqale iimbungu ezikulu.&lt;ref name=CDCDiag2013&gt;{{Wp/nd/cite web |title=Onchocerciasis (also known as River Blindness) Diagnosis |publisher=CDC |url=http://www.cdc.gov/parasites/onchocerciasis/diagnosis.html |work=Parasites |accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt;

&lt;!-- Prevention and Treatment --&gt;
U[[ mjovo]] olwisana nobulwelwe lobu awutholakali awukho.&lt;ref name=WHO2014/&gt; Umuntu angazivikela ngokukhandela ukulunywa ziimpukani lezi ezikulu.&lt;ref name=CDCPre2013&gt;{{Wp/nd/cite web|title=Onchocerciasis (also known as River Blindness) Prevention &amp; Control |url=http://www.cdc.gov/parasites/onchocerciasis/prevent.html|work=Parasites |publisher=CDC |accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt; Lokhu kungafaka hlangana ukusebenzisa[[isihlahla sokuvikela ukulunywa ziinunwana]] kanye nokwembatha kuhle.&lt;ref name=CDCPre2013/&gt; Eminye imizamo kungaba kukuthi uthele ispreyi esisihlahla sokubulala[[iinunwanwa eziphaphak]]o.&lt;ref name=WHO2014/&gt; Imizamo yokuphungula ubulwelwe lobu ngokulatjhwa kweenqhema zabantu kuyenzeka kabili ngomnyaka eendaweni ezinengi ephasini zombelele.&lt;ref name=WHO2014/&gt; Ukulatjhwa kwalabo abathelelekileko kusetjenziswa iinhlahla[[i-ivermecticin]]qobe iinyanga esisithandathu ukuya kezilitjhumu nambili.&lt;ref name=WHO2014/&gt;&lt;ref name=Murray2013/&gt; Isihlahla sokulapha lesi sibulala isibungu esisandukuqhoqhoselwa ingasi isibungu esikhulu.&lt;ref name=Yellow2012&gt;{{Wp/nd/cite book|last=Brunette|first=Gary W.|title=CDC Health Information for International Travel 2012 : The Yellow Book |year=2011|publisher=Oxford University Press|isbn=9780199830367 |page=258 |url=http://books.google.ca/books?id=5vCQpr1WTS8C&amp;pg=PA258 }}&lt;/ref&gt; ihlahla[[idoxycycline]], yona ibulala[[ umulwana i-endosymbiont]]ebizwa''[[nge-Wolbachia]]'', isebenza ukubulala amandla wesibungu lesi, nayo iyakhuthazwa bona isetjenziswe.&lt;ref name=Yellow2012/&gt; Ukususwa kwamalunda ngaphakathi kwesikumba nakho kungenziwa ngokobana umuntu ahlinzwe.&lt;ref name=Murray2013&gt;{{Wp/nd/cite book |last=Murray |first=Patrick |title=Medical microbiology |year=2013 |publisher=Elsevier Saunders |location=Philadelphia |isbn=9780323086929 |page=792|url=http://books.google.ca/books?id=RBEVsFmR2yQC&amp;pg=PA792 |edition=7th}}&lt;/ref&gt;

&lt;!--Epidemiology and History --&gt;
Isibalo esibalelwa ku17 ukuya kuma-25 weengidigidi, ababanjwe nofana abatheleleko bulwelwe bokuphophala bemlanjeni, ababalelwa eengidigidini ezi-0.8 inengi labo alisaboni ngamehlo seliphophele.&lt;ref name=CDCEpi2013/&gt;&lt;ref name=Yellow2012/&gt; Ukutheleleka okuneng kobulwelwe lobu[[kwenzeka khulu esiyingini-seSahara ye-Africa]], nanyana imibiko yezehlakalo ezinye ivele[[enarheni i-Yemen]] nakenzinye iindawo ezizijameleko[[ eKabeni|ye-Amerikha]] kanye[[ne-Sewula ye-Amerikha]].&lt;ref name=WHO2014/&gt; Ngo-1915, udorhodere[[uRodolfo Robles]] waqathanisa kokuthoma ubulwelwe lobu nesifo samehlo.&lt;ref&gt;{{Wp/nd/cite book |editor1=Eldridge, Bruce F. |editor2=Edman, John D. |editor3= Edman, J. |title=Medical entomology |year=2004 |publisher=Kluwer Academic |location=Dordrecht |isbn=9781402017940|page=301 |url=http://books.google.ca/books?id=C7OxOqTKYS8C&amp;pg=PA301 |edition=Revised |author1=Lok, James B. |author2=Walker, Edward D. |author3=Scoles, Glen A. |chapter=9. Filariasis}}&lt;/ref&gt; Kuveziwe erhelweni[[le-World Health Organization]] njengesifo[[ esizijamele sodwa emangweni yethrophigi]].&lt;ref&gt;{{Wp/nd/cite journal |author=Reddy M, Gill SS, Kalkar SR, Wu W, Anderson PJ, Rochon PA |title=Oral drug therapy for multiple neglected tropical diseases: a systematic review |journal=JAMA |volume=298 |issue=16 |pages=1911–24 |date=October 2007 |doi=10.1001/jama.298.16.1911 |pmid=17954542 |url=http://jama.jamanetwork.com/article.aspx?doi=10.1001/jama.298.16.1911}}&lt;/ref&gt;
==isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini==
&lt;references /&gt;</text>
      <sha1>5n2jhk5xrf4ofs04n360c55o4i30syu</sha1>
    </revision>
    <revision>
      <id>2019</id>
      <parentid>2018</parentid>
      <timestamp>2022-05-13T22:11:56Z</timestamp>
      <contributor>
        <username>incubator&gt;1234qwer1234qwer4</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>+[[Category:Wp/nd]]; [[toolforge:quickcategories/batch/4630/|QuickCategories batch #4630]]</comment>
      <origin>2019</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6771" sha1="5ohd5fcawi8jd9r0bdn9xp4rdnxk2tt" xml:space="preserve">{{Wp/nd/Infobox disease
| name           = Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale
| image          = Onchocerca volvulus emerging from a black fly.jpg
| caption        = Umuntu omdala[[uSimulium yahense|ipukani ekulu enzima]]kanye netsikizi''[[i-Onchocerca volvulus]]''ziphuma ngaphakathi kwendletjana yenunwanwa, ikhulisiwe 100x
| pronounce   = {{IPAc-en|ˌ|ɒ|ŋ|k|oʊ|s|ɜr|ˈ|s|aɪ|ə|s|ɨ|s|,_|-|ˈ|k|aɪ|-}}
| DiseasesDB     = 9218
| ICD10          = {{Wp/nd/ICD10|B|73||b|65}}
| ICD9           = {{Wp/nd/ICD9|125.3}}
| ICDO           =
| OMIM           =
| MedlinePlus    =
| eMedicineSubj  = med
| eMedicineTopic = 1667
| eMedicine_mult = {{eMedicine2|oph|709}}
| MeshID         = D009855
}}

&lt;!-- Definition and symptoms --&gt;
'''Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale''', obaziwa ngokuthi''' bulwelwe obuphophalisako bemlanjeni''' begodu'''yaziwa ngokuthi yi-Robles disease''', bulwelwe obubangwa kutheleleka okulethwa  [[yitsikizi esasibungwana]] ''[[i-Onchocerca volvulus]]''.&lt;ref name=WHO2014&gt;{{Wp/nd/cite web|title=Onchocerciasis Fact sheet N°374|url=http://www.who.int/mediacentre/factsheets/fs374/en/|work=World Health Organization|accessdate=20 March 2014|date=March 2014}}&lt;/ref&gt; Amatshwayo wobulwelwe lobu afaka hlangana nokulunywa okudluleleko esikhunjeni, kanye[[nokuphophala]].&lt;ref name=WHO2014/&gt; Lobu ubulwelwe busebujameni besibili emalwelweni abanga ukuphophala, ngemva[[kwetrachoma]].&lt;ref name=CDC2013/&gt;

&lt;!-- Cause and Diagnosis --&gt;
Itsikizi esasibungwana le ingena esikhumbeni itheleleke[[ngokulunywa yipukani ekulu enzima]]efana''[[ne-Simulium]]'' umhlobo wempukani.&lt;ref name=WHO2014/&gt; Esikhathini esinengi umuntu kufanele alunywe kanengi ngaphambi kobana angatheleleka ngobulwelwe lobu.&lt;ref name=CDCEpi2013&gt;{{Wp/nd/cite web|title=Parasites – Onchocerciasis (also known as River Blindness) Epidemiology &amp; Risk Factors|url=http://www.cdc.gov/parasites/onchocerciasis/epi.html|work=CDC|accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt; Iimpukani lezi ezikulu ezinzima zihlala hlanu komlambo, ngikho negama lobulwelwe lobu kuthiwa ybulwelwe obuphophalisako bemlanjeni.&lt;ref name=CDC2013&gt;{{Wp/nd/cite web |title=Onchocerciasis (also known as River Blindness) |work=Parasites  |url=http://www.cdc.gov/parasites/onchocerciasis/|publisher=CDC|accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt; Nazingena ngaphakathi emuntwini, imbungwanyana lezi zenza[[indlela yazo eyenza isibungu esisandukuqhoqhoselwa]]ezizokungena ngazo esikhunjeni phakathi.&lt;ref name=WHO2014/&gt; Bese nasele zingene zanzinza nazo ziyakwazi bona zithelele ipukani ezokuluma esikhunjeni somuntu loyo.&lt;ref name=WHO2014/&gt; Kuneendlela ezimbalwa ezingasetjenziswa ukuthola umrabho wobulwelwe: ukubeka[[ umtjhini i-biopsy phezu kwesikhumba]] ekhemikhalini esamanzana [[isaline]] bese ucala  isibungu esisandukuqhoqhoselwa nasiphumako, bese ucala ilihlo lesibungwana lesi, bese godu utjheja ingongoma engaphakathi kwesikhumba uqale iimbungu ezikulu.&lt;ref name=CDCDiag2013&gt;{{Wp/nd/cite web |title=Onchocerciasis (also known as River Blindness) Diagnosis |publisher=CDC |url=http://www.cdc.gov/parasites/onchocerciasis/diagnosis.html |work=Parasites |accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt;

&lt;!-- Prevention and Treatment --&gt;
U[[ mjovo]] olwisana nobulwelwe lobu awutholakali awukho.&lt;ref name=WHO2014/&gt; Umuntu angazivikela ngokukhandela ukulunywa ziimpukani lezi ezikulu.&lt;ref name=CDCPre2013&gt;{{Wp/nd/cite web|title=Onchocerciasis (also known as River Blindness) Prevention &amp; Control |url=http://www.cdc.gov/parasites/onchocerciasis/prevent.html|work=Parasites |publisher=CDC |accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt; Lokhu kungafaka hlangana ukusebenzisa[[isihlahla sokuvikela ukulunywa ziinunwana]] kanye nokwembatha kuhle.&lt;ref name=CDCPre2013/&gt; Eminye imizamo kungaba kukuthi uthele ispreyi esisihlahla sokubulala[[iinunwanwa eziphaphak]]o.&lt;ref name=WHO2014/&gt; Imizamo yokuphungula ubulwelwe lobu ngokulatjhwa kweenqhema zabantu kuyenzeka kabili ngomnyaka eendaweni ezinengi ephasini zombelele.&lt;ref name=WHO2014/&gt; Ukulatjhwa kwalabo abathelelekileko kusetjenziswa iinhlahla[[i-ivermecticin]]qobe iinyanga esisithandathu ukuya kezilitjhumu nambili.&lt;ref name=WHO2014/&gt;&lt;ref name=Murray2013/&gt; Isihlahla sokulapha lesi sibulala isibungu esisandukuqhoqhoselwa ingasi isibungu esikhulu.&lt;ref name=Yellow2012&gt;{{Wp/nd/cite book|last=Brunette|first=Gary W.|title=CDC Health Information for International Travel 2012 : The Yellow Book |year=2011|publisher=Oxford University Press|isbn=9780199830367 |page=258 |url=http://books.google.ca/books?id=5vCQpr1WTS8C&amp;pg=PA258 }}&lt;/ref&gt; ihlahla[[idoxycycline]], yona ibulala[[ umulwana i-endosymbiont]]ebizwa''[[nge-Wolbachia]]'', isebenza ukubulala amandla wesibungu lesi, nayo iyakhuthazwa bona isetjenziswe.&lt;ref name=Yellow2012/&gt; Ukususwa kwamalunda ngaphakathi kwesikumba nakho kungenziwa ngokobana umuntu ahlinzwe.&lt;ref name=Murray2013&gt;{{Wp/nd/cite book |last=Murray |first=Patrick |title=Medical microbiology |year=2013 |publisher=Elsevier Saunders |location=Philadelphia |isbn=9780323086929 |page=792|url=http://books.google.ca/books?id=RBEVsFmR2yQC&amp;pg=PA792 |edition=7th}}&lt;/ref&gt;

&lt;!--Epidemiology and History --&gt;
Isibalo esibalelwa ku17 ukuya kuma-25 weengidigidi, ababanjwe nofana abatheleleko bulwelwe bokuphophala bemlanjeni, ababalelwa eengidigidini ezi-0.8 inengi labo alisaboni ngamehlo seliphophele.&lt;ref name=CDCEpi2013/&gt;&lt;ref name=Yellow2012/&gt; Ukutheleleka okuneng kobulwelwe lobu[[kwenzeka khulu esiyingini-seSahara ye-Africa]], nanyana imibiko yezehlakalo ezinye ivele[[enarheni i-Yemen]] nakenzinye iindawo ezizijameleko[[ eKabeni|ye-Amerikha]] kanye[[ne-Sewula ye-Amerikha]].&lt;ref name=WHO2014/&gt; Ngo-1915, udorhodere[[uRodolfo Robles]] waqathanisa kokuthoma ubulwelwe lobu nesifo samehlo.&lt;ref&gt;{{Wp/nd/cite book |editor1=Eldridge, Bruce F. |editor2=Edman, John D. |editor3= Edman, J. |title=Medical entomology |year=2004 |publisher=Kluwer Academic |location=Dordrecht |isbn=9781402017940|page=301 |url=http://books.google.ca/books?id=C7OxOqTKYS8C&amp;pg=PA301 |edition=Revised |author1=Lok, James B. |author2=Walker, Edward D. |author3=Scoles, Glen A. |chapter=9. Filariasis}}&lt;/ref&gt; Kuveziwe erhelweni[[le-World Health Organization]] njengesifo[[ esizijamele sodwa emangweni yethrophigi]].&lt;ref&gt;{{Wp/nd/cite journal |author=Reddy M, Gill SS, Kalkar SR, Wu W, Anderson PJ, Rochon PA |title=Oral drug therapy for multiple neglected tropical diseases: a systematic review |journal=JAMA |volume=298 |issue=16 |pages=1911–24 |date=October 2007 |doi=10.1001/jama.298.16.1911 |pmid=17954542 |url=http://jama.jamanetwork.com/article.aspx?doi=10.1001/jama.298.16.1911}}&lt;/ref&gt;
==isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini==
&lt;references /&gt;
[[Category:Wp/nd]]</text>
      <sha1>5ohd5fcawi8jd9r0bdn9xp4rdnxk2tt</sha1>
    </revision>
    <revision>
      <id>2020</id>
      <parentid>2019</parentid>
      <timestamp>2024-11-18T17:45:26Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <minor />
      <comment>8 revisions imported from [[:incubator:Wp/nd/Ubulwelwe_obungena_besibungwana_esincani_obenza_umuntu_aphophale]]</comment>
      <origin>2019</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6771" sha1="5ohd5fcawi8jd9r0bdn9xp4rdnxk2tt" xml:space="preserve">{{Wp/nd/Infobox disease
| name           = Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale
| image          = Onchocerca volvulus emerging from a black fly.jpg
| caption        = Umuntu omdala[[uSimulium yahense|ipukani ekulu enzima]]kanye netsikizi''[[i-Onchocerca volvulus]]''ziphuma ngaphakathi kwendletjana yenunwanwa, ikhulisiwe 100x
| pronounce   = {{IPAc-en|ˌ|ɒ|ŋ|k|oʊ|s|ɜr|ˈ|s|aɪ|ə|s|ɨ|s|,_|-|ˈ|k|aɪ|-}}
| DiseasesDB     = 9218
| ICD10          = {{Wp/nd/ICD10|B|73||b|65}}
| ICD9           = {{Wp/nd/ICD9|125.3}}
| ICDO           =
| OMIM           =
| MedlinePlus    =
| eMedicineSubj  = med
| eMedicineTopic = 1667
| eMedicine_mult = {{eMedicine2|oph|709}}
| MeshID         = D009855
}}

&lt;!-- Definition and symptoms --&gt;
'''Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale''', obaziwa ngokuthi''' bulwelwe obuphophalisako bemlanjeni''' begodu'''yaziwa ngokuthi yi-Robles disease''', bulwelwe obubangwa kutheleleka okulethwa  [[yitsikizi esasibungwana]] ''[[i-Onchocerca volvulus]]''.&lt;ref name=WHO2014&gt;{{Wp/nd/cite web|title=Onchocerciasis Fact sheet N°374|url=http://www.who.int/mediacentre/factsheets/fs374/en/|work=World Health Organization|accessdate=20 March 2014|date=March 2014}}&lt;/ref&gt; Amatshwayo wobulwelwe lobu afaka hlangana nokulunywa okudluleleko esikhunjeni, kanye[[nokuphophala]].&lt;ref name=WHO2014/&gt; Lobu ubulwelwe busebujameni besibili emalwelweni abanga ukuphophala, ngemva[[kwetrachoma]].&lt;ref name=CDC2013/&gt;

&lt;!-- Cause and Diagnosis --&gt;
Itsikizi esasibungwana le ingena esikhumbeni itheleleke[[ngokulunywa yipukani ekulu enzima]]efana''[[ne-Simulium]]'' umhlobo wempukani.&lt;ref name=WHO2014/&gt; Esikhathini esinengi umuntu kufanele alunywe kanengi ngaphambi kobana angatheleleka ngobulwelwe lobu.&lt;ref name=CDCEpi2013&gt;{{Wp/nd/cite web|title=Parasites – Onchocerciasis (also known as River Blindness) Epidemiology &amp; Risk Factors|url=http://www.cdc.gov/parasites/onchocerciasis/epi.html|work=CDC|accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt; Iimpukani lezi ezikulu ezinzima zihlala hlanu komlambo, ngikho negama lobulwelwe lobu kuthiwa ybulwelwe obuphophalisako bemlanjeni.&lt;ref name=CDC2013&gt;{{Wp/nd/cite web |title=Onchocerciasis (also known as River Blindness) |work=Parasites  |url=http://www.cdc.gov/parasites/onchocerciasis/|publisher=CDC|accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt; Nazingena ngaphakathi emuntwini, imbungwanyana lezi zenza[[indlela yazo eyenza isibungu esisandukuqhoqhoselwa]]ezizokungena ngazo esikhunjeni phakathi.&lt;ref name=WHO2014/&gt; Bese nasele zingene zanzinza nazo ziyakwazi bona zithelele ipukani ezokuluma esikhunjeni somuntu loyo.&lt;ref name=WHO2014/&gt; Kuneendlela ezimbalwa ezingasetjenziswa ukuthola umrabho wobulwelwe: ukubeka[[ umtjhini i-biopsy phezu kwesikhumba]] ekhemikhalini esamanzana [[isaline]] bese ucala  isibungu esisandukuqhoqhoselwa nasiphumako, bese ucala ilihlo lesibungwana lesi, bese godu utjheja ingongoma engaphakathi kwesikhumba uqale iimbungu ezikulu.&lt;ref name=CDCDiag2013&gt;{{Wp/nd/cite web |title=Onchocerciasis (also known as River Blindness) Diagnosis |publisher=CDC |url=http://www.cdc.gov/parasites/onchocerciasis/diagnosis.html |work=Parasites |accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt;

&lt;!-- Prevention and Treatment --&gt;
U[[ mjovo]] olwisana nobulwelwe lobu awutholakali awukho.&lt;ref name=WHO2014/&gt; Umuntu angazivikela ngokukhandela ukulunywa ziimpukani lezi ezikulu.&lt;ref name=CDCPre2013&gt;{{Wp/nd/cite web|title=Onchocerciasis (also known as River Blindness) Prevention &amp; Control |url=http://www.cdc.gov/parasites/onchocerciasis/prevent.html|work=Parasites |publisher=CDC |accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt; Lokhu kungafaka hlangana ukusebenzisa[[isihlahla sokuvikela ukulunywa ziinunwana]] kanye nokwembatha kuhle.&lt;ref name=CDCPre2013/&gt; Eminye imizamo kungaba kukuthi uthele ispreyi esisihlahla sokubulala[[iinunwanwa eziphaphak]]o.&lt;ref name=WHO2014/&gt; Imizamo yokuphungula ubulwelwe lobu ngokulatjhwa kweenqhema zabantu kuyenzeka kabili ngomnyaka eendaweni ezinengi ephasini zombelele.&lt;ref name=WHO2014/&gt; Ukulatjhwa kwalabo abathelelekileko kusetjenziswa iinhlahla[[i-ivermecticin]]qobe iinyanga esisithandathu ukuya kezilitjhumu nambili.&lt;ref name=WHO2014/&gt;&lt;ref name=Murray2013/&gt; Isihlahla sokulapha lesi sibulala isibungu esisandukuqhoqhoselwa ingasi isibungu esikhulu.&lt;ref name=Yellow2012&gt;{{Wp/nd/cite book|last=Brunette|first=Gary W.|title=CDC Health Information for International Travel 2012 : The Yellow Book |year=2011|publisher=Oxford University Press|isbn=9780199830367 |page=258 |url=http://books.google.ca/books?id=5vCQpr1WTS8C&amp;pg=PA258 }}&lt;/ref&gt; ihlahla[[idoxycycline]], yona ibulala[[ umulwana i-endosymbiont]]ebizwa''[[nge-Wolbachia]]'', isebenza ukubulala amandla wesibungu lesi, nayo iyakhuthazwa bona isetjenziswe.&lt;ref name=Yellow2012/&gt; Ukususwa kwamalunda ngaphakathi kwesikumba nakho kungenziwa ngokobana umuntu ahlinzwe.&lt;ref name=Murray2013&gt;{{Wp/nd/cite book |last=Murray |first=Patrick |title=Medical microbiology |year=2013 |publisher=Elsevier Saunders |location=Philadelphia |isbn=9780323086929 |page=792|url=http://books.google.ca/books?id=RBEVsFmR2yQC&amp;pg=PA792 |edition=7th}}&lt;/ref&gt;

&lt;!--Epidemiology and History --&gt;
Isibalo esibalelwa ku17 ukuya kuma-25 weengidigidi, ababanjwe nofana abatheleleko bulwelwe bokuphophala bemlanjeni, ababalelwa eengidigidini ezi-0.8 inengi labo alisaboni ngamehlo seliphophele.&lt;ref name=CDCEpi2013/&gt;&lt;ref name=Yellow2012/&gt; Ukutheleleka okuneng kobulwelwe lobu[[kwenzeka khulu esiyingini-seSahara ye-Africa]], nanyana imibiko yezehlakalo ezinye ivele[[enarheni i-Yemen]] nakenzinye iindawo ezizijameleko[[ eKabeni|ye-Amerikha]] kanye[[ne-Sewula ye-Amerikha]].&lt;ref name=WHO2014/&gt; Ngo-1915, udorhodere[[uRodolfo Robles]] waqathanisa kokuthoma ubulwelwe lobu nesifo samehlo.&lt;ref&gt;{{Wp/nd/cite book |editor1=Eldridge, Bruce F. |editor2=Edman, John D. |editor3= Edman, J. |title=Medical entomology |year=2004 |publisher=Kluwer Academic |location=Dordrecht |isbn=9781402017940|page=301 |url=http://books.google.ca/books?id=C7OxOqTKYS8C&amp;pg=PA301 |edition=Revised |author1=Lok, James B. |author2=Walker, Edward D. |author3=Scoles, Glen A. |chapter=9. Filariasis}}&lt;/ref&gt; Kuveziwe erhelweni[[le-World Health Organization]] njengesifo[[ esizijamele sodwa emangweni yethrophigi]].&lt;ref&gt;{{Wp/nd/cite journal |author=Reddy M, Gill SS, Kalkar SR, Wu W, Anderson PJ, Rochon PA |title=Oral drug therapy for multiple neglected tropical diseases: a systematic review |journal=JAMA |volume=298 |issue=16 |pages=1911–24 |date=October 2007 |doi=10.1001/jama.298.16.1911 |pmid=17954542 |url=http://jama.jamanetwork.com/article.aspx?doi=10.1001/jama.298.16.1911}}&lt;/ref&gt;
==isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini==
&lt;references /&gt;
[[Category:Wp/nd]]</text>
      <sha1>5ohd5fcawi8jd9r0bdn9xp4rdnxk2tt</sha1>
    </revision>
    <revision>
      <id>2031</id>
      <parentid>2020</parentid>
      <timestamp>2024-11-18T17:47:01Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <minor />
      <comment>Amire80 moved page [[Wp/nd/Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale]] to [[Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale]]</comment>
      <origin>2019</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6771" sha1="5ohd5fcawi8jd9r0bdn9xp4rdnxk2tt" xml:space="preserve">{{Wp/nd/Infobox disease
| name           = Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale
| image          = Onchocerca volvulus emerging from a black fly.jpg
| caption        = Umuntu omdala[[uSimulium yahense|ipukani ekulu enzima]]kanye netsikizi''[[i-Onchocerca volvulus]]''ziphuma ngaphakathi kwendletjana yenunwanwa, ikhulisiwe 100x
| pronounce   = {{IPAc-en|ˌ|ɒ|ŋ|k|oʊ|s|ɜr|ˈ|s|aɪ|ə|s|ɨ|s|,_|-|ˈ|k|aɪ|-}}
| DiseasesDB     = 9218
| ICD10          = {{Wp/nd/ICD10|B|73||b|65}}
| ICD9           = {{Wp/nd/ICD9|125.3}}
| ICDO           =
| OMIM           =
| MedlinePlus    =
| eMedicineSubj  = med
| eMedicineTopic = 1667
| eMedicine_mult = {{eMedicine2|oph|709}}
| MeshID         = D009855
}}

&lt;!-- Definition and symptoms --&gt;
'''Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale''', obaziwa ngokuthi''' bulwelwe obuphophalisako bemlanjeni''' begodu'''yaziwa ngokuthi yi-Robles disease''', bulwelwe obubangwa kutheleleka okulethwa  [[yitsikizi esasibungwana]] ''[[i-Onchocerca volvulus]]''.&lt;ref name=WHO2014&gt;{{Wp/nd/cite web|title=Onchocerciasis Fact sheet N°374|url=http://www.who.int/mediacentre/factsheets/fs374/en/|work=World Health Organization|accessdate=20 March 2014|date=March 2014}}&lt;/ref&gt; Amatshwayo wobulwelwe lobu afaka hlangana nokulunywa okudluleleko esikhunjeni, kanye[[nokuphophala]].&lt;ref name=WHO2014/&gt; Lobu ubulwelwe busebujameni besibili emalwelweni abanga ukuphophala, ngemva[[kwetrachoma]].&lt;ref name=CDC2013/&gt;

&lt;!-- Cause and Diagnosis --&gt;
Itsikizi esasibungwana le ingena esikhumbeni itheleleke[[ngokulunywa yipukani ekulu enzima]]efana''[[ne-Simulium]]'' umhlobo wempukani.&lt;ref name=WHO2014/&gt; Esikhathini esinengi umuntu kufanele alunywe kanengi ngaphambi kobana angatheleleka ngobulwelwe lobu.&lt;ref name=CDCEpi2013&gt;{{Wp/nd/cite web|title=Parasites – Onchocerciasis (also known as River Blindness) Epidemiology &amp; Risk Factors|url=http://www.cdc.gov/parasites/onchocerciasis/epi.html|work=CDC|accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt; Iimpukani lezi ezikulu ezinzima zihlala hlanu komlambo, ngikho negama lobulwelwe lobu kuthiwa ybulwelwe obuphophalisako bemlanjeni.&lt;ref name=CDC2013&gt;{{Wp/nd/cite web |title=Onchocerciasis (also known as River Blindness) |work=Parasites  |url=http://www.cdc.gov/parasites/onchocerciasis/|publisher=CDC|accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt; Nazingena ngaphakathi emuntwini, imbungwanyana lezi zenza[[indlela yazo eyenza isibungu esisandukuqhoqhoselwa]]ezizokungena ngazo esikhunjeni phakathi.&lt;ref name=WHO2014/&gt; Bese nasele zingene zanzinza nazo ziyakwazi bona zithelele ipukani ezokuluma esikhunjeni somuntu loyo.&lt;ref name=WHO2014/&gt; Kuneendlela ezimbalwa ezingasetjenziswa ukuthola umrabho wobulwelwe: ukubeka[[ umtjhini i-biopsy phezu kwesikhumba]] ekhemikhalini esamanzana [[isaline]] bese ucala  isibungu esisandukuqhoqhoselwa nasiphumako, bese ucala ilihlo lesibungwana lesi, bese godu utjheja ingongoma engaphakathi kwesikhumba uqale iimbungu ezikulu.&lt;ref name=CDCDiag2013&gt;{{Wp/nd/cite web |title=Onchocerciasis (also known as River Blindness) Diagnosis |publisher=CDC |url=http://www.cdc.gov/parasites/onchocerciasis/diagnosis.html |work=Parasites |accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt;

&lt;!-- Prevention and Treatment --&gt;
U[[ mjovo]] olwisana nobulwelwe lobu awutholakali awukho.&lt;ref name=WHO2014/&gt; Umuntu angazivikela ngokukhandela ukulunywa ziimpukani lezi ezikulu.&lt;ref name=CDCPre2013&gt;{{Wp/nd/cite web|title=Onchocerciasis (also known as River Blindness) Prevention &amp; Control |url=http://www.cdc.gov/parasites/onchocerciasis/prevent.html|work=Parasites |publisher=CDC |accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt; Lokhu kungafaka hlangana ukusebenzisa[[isihlahla sokuvikela ukulunywa ziinunwana]] kanye nokwembatha kuhle.&lt;ref name=CDCPre2013/&gt; Eminye imizamo kungaba kukuthi uthele ispreyi esisihlahla sokubulala[[iinunwanwa eziphaphak]]o.&lt;ref name=WHO2014/&gt; Imizamo yokuphungula ubulwelwe lobu ngokulatjhwa kweenqhema zabantu kuyenzeka kabili ngomnyaka eendaweni ezinengi ephasini zombelele.&lt;ref name=WHO2014/&gt; Ukulatjhwa kwalabo abathelelekileko kusetjenziswa iinhlahla[[i-ivermecticin]]qobe iinyanga esisithandathu ukuya kezilitjhumu nambili.&lt;ref name=WHO2014/&gt;&lt;ref name=Murray2013/&gt; Isihlahla sokulapha lesi sibulala isibungu esisandukuqhoqhoselwa ingasi isibungu esikhulu.&lt;ref name=Yellow2012&gt;{{Wp/nd/cite book|last=Brunette|first=Gary W.|title=CDC Health Information for International Travel 2012 : The Yellow Book |year=2011|publisher=Oxford University Press|isbn=9780199830367 |page=258 |url=http://books.google.ca/books?id=5vCQpr1WTS8C&amp;pg=PA258 }}&lt;/ref&gt; ihlahla[[idoxycycline]], yona ibulala[[ umulwana i-endosymbiont]]ebizwa''[[nge-Wolbachia]]'', isebenza ukubulala amandla wesibungu lesi, nayo iyakhuthazwa bona isetjenziswe.&lt;ref name=Yellow2012/&gt; Ukususwa kwamalunda ngaphakathi kwesikumba nakho kungenziwa ngokobana umuntu ahlinzwe.&lt;ref name=Murray2013&gt;{{Wp/nd/cite book |last=Murray |first=Patrick |title=Medical microbiology |year=2013 |publisher=Elsevier Saunders |location=Philadelphia |isbn=9780323086929 |page=792|url=http://books.google.ca/books?id=RBEVsFmR2yQC&amp;pg=PA792 |edition=7th}}&lt;/ref&gt;

&lt;!--Epidemiology and History --&gt;
Isibalo esibalelwa ku17 ukuya kuma-25 weengidigidi, ababanjwe nofana abatheleleko bulwelwe bokuphophala bemlanjeni, ababalelwa eengidigidini ezi-0.8 inengi labo alisaboni ngamehlo seliphophele.&lt;ref name=CDCEpi2013/&gt;&lt;ref name=Yellow2012/&gt; Ukutheleleka okuneng kobulwelwe lobu[[kwenzeka khulu esiyingini-seSahara ye-Africa]], nanyana imibiko yezehlakalo ezinye ivele[[enarheni i-Yemen]] nakenzinye iindawo ezizijameleko[[ eKabeni|ye-Amerikha]] kanye[[ne-Sewula ye-Amerikha]].&lt;ref name=WHO2014/&gt; Ngo-1915, udorhodere[[uRodolfo Robles]] waqathanisa kokuthoma ubulwelwe lobu nesifo samehlo.&lt;ref&gt;{{Wp/nd/cite book |editor1=Eldridge, Bruce F. |editor2=Edman, John D. |editor3= Edman, J. |title=Medical entomology |year=2004 |publisher=Kluwer Academic |location=Dordrecht |isbn=9781402017940|page=301 |url=http://books.google.ca/books?id=C7OxOqTKYS8C&amp;pg=PA301 |edition=Revised |author1=Lok, James B. |author2=Walker, Edward D. |author3=Scoles, Glen A. |chapter=9. Filariasis}}&lt;/ref&gt; Kuveziwe erhelweni[[le-World Health Organization]] njengesifo[[ esizijamele sodwa emangweni yethrophigi]].&lt;ref&gt;{{Wp/nd/cite journal |author=Reddy M, Gill SS, Kalkar SR, Wu W, Anderson PJ, Rochon PA |title=Oral drug therapy for multiple neglected tropical diseases: a systematic review |journal=JAMA |volume=298 |issue=16 |pages=1911–24 |date=October 2007 |doi=10.1001/jama.298.16.1911 |pmid=17954542 |url=http://jama.jamanetwork.com/article.aspx?doi=10.1001/jama.298.16.1911}}&lt;/ref&gt;
==isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini==
&lt;references /&gt;
[[Category:Wp/nd]]</text>
      <sha1>5ohd5fcawi8jd9r0bdn9xp4rdnxk2tt</sha1>
    </revision>
    <revision>
      <id>2188</id>
      <parentid>2031</parentid>
      <timestamp>2024-11-28T20:00:33Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini */Reflist</comment>
      <origin>2188</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6771" sha1="frzfrg98lqy5xp4nbotoj1352e5ktpp" xml:space="preserve">{{Wp/nd/Infobox disease
| name           = Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale
| image          = Onchocerca volvulus emerging from a black fly.jpg
| caption        = Umuntu omdala[[uSimulium yahense|ipukani ekulu enzima]]kanye netsikizi''[[i-Onchocerca volvulus]]''ziphuma ngaphakathi kwendletjana yenunwanwa, ikhulisiwe 100x
| pronounce   = {{IPAc-en|ˌ|ɒ|ŋ|k|oʊ|s|ɜr|ˈ|s|aɪ|ə|s|ɨ|s|,_|-|ˈ|k|aɪ|-}}
| DiseasesDB     = 9218
| ICD10          = {{Wp/nd/ICD10|B|73||b|65}}
| ICD9           = {{Wp/nd/ICD9|125.3}}
| ICDO           =
| OMIM           =
| MedlinePlus    =
| eMedicineSubj  = med
| eMedicineTopic = 1667
| eMedicine_mult = {{eMedicine2|oph|709}}
| MeshID         = D009855
}}

&lt;!-- Definition and symptoms --&gt;
'''Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale''', obaziwa ngokuthi''' bulwelwe obuphophalisako bemlanjeni''' begodu'''yaziwa ngokuthi yi-Robles disease''', bulwelwe obubangwa kutheleleka okulethwa  [[yitsikizi esasibungwana]] ''[[i-Onchocerca volvulus]]''.&lt;ref name=WHO2014&gt;{{Wp/nd/cite web|title=Onchocerciasis Fact sheet N°374|url=http://www.who.int/mediacentre/factsheets/fs374/en/|work=World Health Organization|accessdate=20 March 2014|date=March 2014}}&lt;/ref&gt; Amatshwayo wobulwelwe lobu afaka hlangana nokulunywa okudluleleko esikhunjeni, kanye[[nokuphophala]].&lt;ref name=WHO2014/&gt; Lobu ubulwelwe busebujameni besibili emalwelweni abanga ukuphophala, ngemva[[kwetrachoma]].&lt;ref name=CDC2013/&gt;

&lt;!-- Cause and Diagnosis --&gt;
Itsikizi esasibungwana le ingena esikhumbeni itheleleke[[ngokulunywa yipukani ekulu enzima]]efana''[[ne-Simulium]]'' umhlobo wempukani.&lt;ref name=WHO2014/&gt; Esikhathini esinengi umuntu kufanele alunywe kanengi ngaphambi kobana angatheleleka ngobulwelwe lobu.&lt;ref name=CDCEpi2013&gt;{{Wp/nd/cite web|title=Parasites – Onchocerciasis (also known as River Blindness) Epidemiology &amp; Risk Factors|url=http://www.cdc.gov/parasites/onchocerciasis/epi.html|work=CDC|accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt; Iimpukani lezi ezikulu ezinzima zihlala hlanu komlambo, ngikho negama lobulwelwe lobu kuthiwa ybulwelwe obuphophalisako bemlanjeni.&lt;ref name=CDC2013&gt;{{Wp/nd/cite web |title=Onchocerciasis (also known as River Blindness) |work=Parasites  |url=http://www.cdc.gov/parasites/onchocerciasis/|publisher=CDC|accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt; Nazingena ngaphakathi emuntwini, imbungwanyana lezi zenza[[indlela yazo eyenza isibungu esisandukuqhoqhoselwa]]ezizokungena ngazo esikhunjeni phakathi.&lt;ref name=WHO2014/&gt; Bese nasele zingene zanzinza nazo ziyakwazi bona zithelele ipukani ezokuluma esikhunjeni somuntu loyo.&lt;ref name=WHO2014/&gt; Kuneendlela ezimbalwa ezingasetjenziswa ukuthola umrabho wobulwelwe: ukubeka[[ umtjhini i-biopsy phezu kwesikhumba]] ekhemikhalini esamanzana [[isaline]] bese ucala  isibungu esisandukuqhoqhoselwa nasiphumako, bese ucala ilihlo lesibungwana lesi, bese godu utjheja ingongoma engaphakathi kwesikhumba uqale iimbungu ezikulu.&lt;ref name=CDCDiag2013&gt;{{Wp/nd/cite web |title=Onchocerciasis (also known as River Blindness) Diagnosis |publisher=CDC |url=http://www.cdc.gov/parasites/onchocerciasis/diagnosis.html |work=Parasites |accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt;

&lt;!-- Prevention and Treatment --&gt;
U[[ mjovo]] olwisana nobulwelwe lobu awutholakali awukho.&lt;ref name=WHO2014/&gt; Umuntu angazivikela ngokukhandela ukulunywa ziimpukani lezi ezikulu.&lt;ref name=CDCPre2013&gt;{{Wp/nd/cite web|title=Onchocerciasis (also known as River Blindness) Prevention &amp; Control |url=http://www.cdc.gov/parasites/onchocerciasis/prevent.html|work=Parasites |publisher=CDC |accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt; Lokhu kungafaka hlangana ukusebenzisa[[isihlahla sokuvikela ukulunywa ziinunwana]] kanye nokwembatha kuhle.&lt;ref name=CDCPre2013/&gt; Eminye imizamo kungaba kukuthi uthele ispreyi esisihlahla sokubulala[[iinunwanwa eziphaphak]]o.&lt;ref name=WHO2014/&gt; Imizamo yokuphungula ubulwelwe lobu ngokulatjhwa kweenqhema zabantu kuyenzeka kabili ngomnyaka eendaweni ezinengi ephasini zombelele.&lt;ref name=WHO2014/&gt; Ukulatjhwa kwalabo abathelelekileko kusetjenziswa iinhlahla[[i-ivermecticin]]qobe iinyanga esisithandathu ukuya kezilitjhumu nambili.&lt;ref name=WHO2014/&gt;&lt;ref name=Murray2013/&gt; Isihlahla sokulapha lesi sibulala isibungu esisandukuqhoqhoselwa ingasi isibungu esikhulu.&lt;ref name=Yellow2012&gt;{{Wp/nd/cite book|last=Brunette|first=Gary W.|title=CDC Health Information for International Travel 2012 : The Yellow Book |year=2011|publisher=Oxford University Press|isbn=9780199830367 |page=258 |url=http://books.google.ca/books?id=5vCQpr1WTS8C&amp;pg=PA258 }}&lt;/ref&gt; ihlahla[[idoxycycline]], yona ibulala[[ umulwana i-endosymbiont]]ebizwa''[[nge-Wolbachia]]'', isebenza ukubulala amandla wesibungu lesi, nayo iyakhuthazwa bona isetjenziswe.&lt;ref name=Yellow2012/&gt; Ukususwa kwamalunda ngaphakathi kwesikumba nakho kungenziwa ngokobana umuntu ahlinzwe.&lt;ref name=Murray2013&gt;{{Wp/nd/cite book |last=Murray |first=Patrick |title=Medical microbiology |year=2013 |publisher=Elsevier Saunders |location=Philadelphia |isbn=9780323086929 |page=792|url=http://books.google.ca/books?id=RBEVsFmR2yQC&amp;pg=PA792 |edition=7th}}&lt;/ref&gt;

&lt;!--Epidemiology and History --&gt;
Isibalo esibalelwa ku17 ukuya kuma-25 weengidigidi, ababanjwe nofana abatheleleko bulwelwe bokuphophala bemlanjeni, ababalelwa eengidigidini ezi-0.8 inengi labo alisaboni ngamehlo seliphophele.&lt;ref name=CDCEpi2013/&gt;&lt;ref name=Yellow2012/&gt; Ukutheleleka okuneng kobulwelwe lobu[[kwenzeka khulu esiyingini-seSahara ye-Africa]], nanyana imibiko yezehlakalo ezinye ivele[[enarheni i-Yemen]] nakenzinye iindawo ezizijameleko[[ eKabeni|ye-Amerikha]] kanye[[ne-Sewula ye-Amerikha]].&lt;ref name=WHO2014/&gt; Ngo-1915, udorhodere[[uRodolfo Robles]] waqathanisa kokuthoma ubulwelwe lobu nesifo samehlo.&lt;ref&gt;{{Wp/nd/cite book |editor1=Eldridge, Bruce F. |editor2=Edman, John D. |editor3= Edman, J. |title=Medical entomology |year=2004 |publisher=Kluwer Academic |location=Dordrecht |isbn=9781402017940|page=301 |url=http://books.google.ca/books?id=C7OxOqTKYS8C&amp;pg=PA301 |edition=Revised |author1=Lok, James B. |author2=Walker, Edward D. |author3=Scoles, Glen A. |chapter=9. Filariasis}}&lt;/ref&gt; Kuveziwe erhelweni[[le-World Health Organization]] njengesifo[[ esizijamele sodwa emangweni yethrophigi]].&lt;ref&gt;{{Wp/nd/cite journal |author=Reddy M, Gill SS, Kalkar SR, Wu W, Anderson PJ, Rochon PA |title=Oral drug therapy for multiple neglected tropical diseases: a systematic review |journal=JAMA |volume=298 |issue=16 |pages=1911–24 |date=October 2007 |doi=10.1001/jama.298.16.1911 |pmid=17954542 |url=http://jama.jamanetwork.com/article.aspx?doi=10.1001/jama.298.16.1911}}&lt;/ref&gt;
== isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini ==
{{Reflist}}

[[Category:Wp/nd]]</text>
      <sha1>frzfrg98lqy5xp4nbotoj1352e5ktpp</sha1>
    </revision>
    <revision>
      <id>5082</id>
      <parentid>2188</parentid>
      <timestamp>2025-08-08T08:55:56Z</timestamp>
      <contributor>
        <username>Umenathi</username>
        <id>837</id>
      </contributor>
      <origin>5082</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6778" sha1="nde9svqw9rl2qzamm9m14o1q1t16sr5" xml:space="preserve">{{Wp/nd/Infobox disease
| name           = Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale
| image          = Onchocerca volvulus emerging from a black fly.jpg
| caption        = Umuntu omdala[[uSimulium yahense|ipukani ekulu enzima]]kanye netsikizi''[[i-Onchocerca volvulus]]''ziphuma ngaphakathi kwendletjana yenunwanwa, ikhulisiwe 100x
| pronounce   = {{IPAc-en|ˌ|ɒ|ŋ|k|oʊ|s|ɜr|ˈ|s|aɪ|ə|s|ɨ|s|,_|-|ˈ|k|aɪ|-}}
| DiseasesDB     = 9218
| ICD10          = {{Wp/nd/ICD10|B|73||b|65}}
| ICD9           = {{Wp/nd/ICD9|125.3}}
| ICDO           =
| OMIM           =
| MedlinePlus    =
| eMedicineSubj  = med
| eMedicineTopic = 1667
| eMedicine_mult = {{eMedicine2|oph|709}}
| MeshID         = D009855
}}

&lt;!-- Definition and symptoms --&gt;
'''Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale''', obaziwa ngokuthi''' bulwelwe obuphophalisako bemlanjeni''' begodu'''yaziwa ngokuthi yi-Robles disease''', bulwelwe obubangwa kutheleleka okulethwa  [[yitsikizi esasibungwana]] ''[[i-Onchocerca volvulus]]''.&lt;ref name=WHO2014&gt;{{Wp/nd/cite web|title=Onchocerciasis Fact sheet N°374|url=http://www.who.int/mediacentre/factsheets/fs374/en/|work=World Health Organization|accessdate=20 March 2014|date=March 2014}}&lt;/ref&gt; Amatshwayo wobulwelwe lobu afaka hlangana nokulunywa okudluleleko esikhunjeni, kanye[[nokuphophala]].&lt;ref name=WHO2014/&gt; Lobu ubulwelwe busebujameni besibili emalwelweni abanga ukuphophala, ngemva[[kwetrachoma]].&lt;ref name=CDC2013/&gt;

&lt;!-- Cause and Diagnosis --&gt;
Itsikizi esasibungwana le ingena esikhumbeni itheleleke[[ngokulunywa yipukani ekulu enzima]]efana''[[ne-Simulium]]'' umhlobo wempukani.&lt;ref name=WHO2014/&gt; Esikhathini esinengi umuntu kufanele alunywe kanengi ngaphambi kobana angatheleleka ngobulwelwe lobu.&lt;ref name=CDCEpi2013&gt;{{Wp/nd/cite web|title=Parasites – Onchocerciasis (also known as River Blindness) Epidemiology &amp; Risk Factors|url=http://www.cdc.gov/parasites/onchocerciasis/epi.html|work=CDC|accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt; Iimpukani lezi ezikulu ezinzima zihlala hlanu komlambo, ngikho negama lobulwelwe lobu kuthiwa ybulwelwe obuphophalisako bemlanjeni.&lt;ref name=CDC2013&gt;{{Wp/nd/cite web |title=Onchocerciasis (also known as River Blindness) |work=Parasites  |url=http://www.cdc.gov/parasites/onchocerciasis/|publisher=CDC|accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt; Nazingena ngaphakathi emuntwini, imbungwanyana lezi zenza[[indlela yazo eyenza isibungu esisandukuqhoqhoselwa]]ezizokungena ngazo esikhunjeni phakathi.&lt;ref name=WHO2014/&gt; Bese nasele zingene zanzinza nazo ziyakwazi bona zithelele ipukani ezokuluma esikhunjeni somuntu loyo.&lt;ref name=WHO2014/&gt; Kuneendlela ezimbalwa ezingasetjenziswa ukuthola umrabho wobulwelwe: ukubeka[[ umtjhini i-biopsy phezu kwesikhumba]] ekhemikhalini esamanzana [[isaline]] bese ucala  isibungu esisandukuqhoqhoselwa nasiphumako, bese ucala ilihlo lesibungwana lesi, bese godu utjheja ingongoma engaphakathi kwesikhumba uqale iimbungu ezikulu.&lt;ref name=CDCDiag2013&gt;{{Wp/nd/cite web |title=Onchocerciasis (also known as River Blindness) Diagnosis |publisher=CDC |url=http://www.cdc.gov/parasites/onchocerciasis/diagnosis.html |work=Parasites |accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt;

&lt;!-- Prevention and Treatment --&gt;
U[[ mjovo]] olwisana nobulwelwe lobu awutholakali awukho.&lt;ref name=WHO2014/&gt; Umuntu angazivikela ngokukhandela ukulunywa ziimpukani lezi ezikulu.&lt;ref name=CDCPre2013&gt;{{Wp/nd/cite web|title=Onchocerciasis (also known as River Blindness) Prevention &amp; Control |url=http://www.cdc.gov/parasites/onchocerciasis/prevent.html|work=Parasites |publisher=CDC |accessdate=20 March 2014|date=May 21, 2013}}&lt;/ref&gt; Lokhu kungafaka hlangana ukusebenzisa [[isihlahla sokuvikela ukulunywa ziinunwana]] kanye nokwembatha kuhle.&lt;ref name=CDCPre2013/&gt; Eminye imizamo kungaba kukuthi uthele isipreyi esisihlahla sokubulala [[iinunwanwa eziphaphak]]o.&lt;ref name=WHO2014/&gt; Imizamo yokuphungula ubulwelwe lobu ngokulatjhwa kweenqhema zabantu kuyenzeka kabili ngomnyaka eendaweni ezinengi ephasini zombelele.&lt;ref name=WHO2014/&gt; Ukulatjhwa kwalabo abathelelekileko kusetjenziswa iinhlahla[[i-ivermecticin]]qobe iinyanga ezisithandathu ukuya kezilitjhumu nambili.&lt;ref name=WHO2014/&gt;&lt;ref name=Murray2013/&gt; Isihlahla sokulapha lesi sibulala isibungu esisandukuqhoqhoselwa ingasi isibungu esikhulu.&lt;ref name=Yellow2012&gt;{{Wp/nd/cite book|last=Brunette|first=Gary W.|title=CDC Health Information for International Travel 2012 : The Yellow Book |year=2011|publisher=Oxford University Press|isbn=9780199830367 |page=258 |url=http://books.google.ca/books?id=5vCQpr1WTS8C&amp;pg=PA258 }}&lt;/ref&gt; Isihlahla [[idoxycycline]], yona ibulala[[ umulwana i-endosymbiont]]ebizwa''[[nge-Wolbachia]]'', isebenza ukubulala amandla wesibungu lesi, nayo iyakhuthazwa bona isetjenziswe.&lt;ref name=Yellow2012/&gt; Ukususwa kwamalunda ngaphakathi kwesikumba nakho kungenziwa ngokobana umuntu ahlinzwe.&lt;ref name=Murray2013&gt;{{Wp/nd/cite book |last=Murray |first=Patrick |title=Medical microbiology |year=2013 |publisher=Elsevier Saunders |location=Philadelphia |isbn=9780323086929 |page=792|url=http://books.google.ca/books?id=RBEVsFmR2yQC&amp;pg=PA792 |edition=7th}}&lt;/ref&gt;

&lt;!--Epidemiology and History --&gt;
Isibalo esibalelwa ku17 ukuya kuma-25 weengidigidi, ababanjwe nofana abatheleleko bulwelwe bokuphophala bemlanjeni, ababalelwa eengidigidini ezi-0.8 inengi labo alisaboni ngamehlo seliphophele.&lt;ref name=CDCEpi2013/&gt;&lt;ref name=Yellow2012/&gt; Ukutheleleka okunengi kobulwelwe lobu[[kwenzeka khulu esiyingini-seSahara ye-Africa]], nanyana imibiko yezehlakalo ezinye ivele[[enarheni i-Yemen]] nakenzinye iindawo ezizijameleko[[ eKabeni|ye-Amerikha]] kanye[[ne-Sewula ye-Amerikha]].&lt;ref name=WHO2014/&gt; Ngo-1915, udorhodere[[uRodolfo Robles]] waqathanisa kokuthoma ubulwelwe lobu nesifo samehlo.&lt;ref&gt;{{Wp/nd/cite book |editor1=Eldridge, Bruce F. |editor2=Edman, John D. |editor3= Edman, J. |title=Medical entomology |year=2004 |publisher=Kluwer Academic |location=Dordrecht |isbn=9781402017940|page=301 |url=http://books.google.ca/books?id=C7OxOqTKYS8C&amp;pg=PA301 |edition=Revised |author1=Lok, James B. |author2=Walker, Edward D. |author3=Scoles, Glen A. |chapter=9. Filariasis}}&lt;/ref&gt; Kuveziwe erhelweni[[le-World Health Organization]] njengesifo[[ esizijamele sodwa emangweni yethrophigi]].&lt;ref&gt;{{Wp/nd/cite journal |author=Reddy M, Gill SS, Kalkar SR, Wu W, Anderson PJ, Rochon PA |title=Oral drug therapy for multiple neglected tropical diseases: a systematic review |journal=JAMA |volume=298 |issue=16 |pages=1911–24 |date=October 2007 |doi=10.1001/jama.298.16.1911 |pmid=17954542 |url=http://jama.jamanetwork.com/article.aspx?doi=10.1001/jama.298.16.1911}}&lt;/ref&gt;
== isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini ==
{{Reflist}}

[[Category:Wp/nd]]</text>
      <sha1>nde9svqw9rl2qzamm9m14o1q1t16sr5</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Wp/nd/Cite book</title>
    <ns>10</ns>
    <id>391</id>
    <revision>
      <id>2021</id>
      <timestamp>2016-11-09T15:37:25Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>[[:en:Template:Cite book]]</comment>
      <origin>2021</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5171" sha1="i816erhyx4p1myken2gpchpr7g722k1" xml:space="preserve">{{Wp/nd/Citation/core
|Citation class=book

|Surname1={{{last|{{{last1|{{{author|{{{author1|{{{authors|{{{surname|{{{surname1|}}}}}}}}}}}}}}}}}}}}}
|Surname2={{{last2|{{{author2|{{{surname2|}}}}}}}}}
|Surname3={{{last3|{{{author3|{{{surname3|}}}}}}}}}
|Surname4={{{last4|{{{author4|{{{surname4|}}}}}}}}}
|Surname5={{{last5|{{{author5|{{{surname5|}}}}}}}}}
|Surname6={{{last6|{{{author6|{{{surname6|}}}}}}}}}
|Surname7={{{last7|{{{author7|{{{surname7|}}}}}}}}}
|Surname8={{{last8|{{{author8|{{{surname8|}}}}}}}}}
|Surname9={{{last9|{{{author9|{{{surname9|}}}}}}}}}

|Given1={{{first|{{{first1|{{{given|{{{given1|}}}}}}}}}}}}
|Given2={{{first2|{{{given2|}}}}}}
|Given3={{{first3|{{{given3|}}}}}}
|Given4={{{first4|{{{given4|}}}}}}
|Given5={{{first5|{{{given5|}}}}}}
|Given6={{{first6|{{{given6|}}}}}}
|Given7={{{first7|{{{given7|}}}}}}
|Given8={{{first8|{{{given8|}}}}}}
|Given9={{{first9|{{{given9|}}}}}}

|Authorlink1={{{authorlink|{{{authorlink1|{{{author-link|{{{author1-link|}}}}}}}}}}}}
|Authorlink2={{{authorlink2|{{{author2-link|}}}}}}
|Authorlink3={{{authorlink3|{{{author3-link|}}}}}}
|Authorlink4={{{authorlink4|{{{author4-link|}}}}}}
|Authorlink5={{{authorlink5|{{{author5-link|}}}}}}
|Authorlink6={{{authorlink6|{{{author6-link|}}}}}}
|Authorlink7={{{authorlink7|{{{author7-link|}}}}}}
|Authorlink8={{{authorlink8|{{{author8-link|}}}}}}
|Authorlink9={{{authorlink9|{{{author9-link|}}}}}}

|Coauthors={{{coauthors|{{{coauthor|}}}}}}

|Other={{{others|}}}

|Year={{{year|{{    &lt;!-- attempt to derive year from date, if possible --&gt;
           #if: {{{date|}}}
           |{{
              #iferror:{{#time:Y|{{{date|}}} }}
              |{{#iferror:{{#time:Y|{{{publication-date|einval}}} }}||{{#time:Y|{{{publication-date|}}} }}}}
              |{{#time:Y|{{{date|}}} }}
            }}
           |{{{publication-date|}}} &lt;!-- last resort --&gt;
         }}
      }}}
|YearNote={{{origyear|}}}
|Date={{#if:{{{date|}}}|{{{date}}}|{{{day|}}} {{{month|}}} {{{year|{{{publication-date|}}}}}}}}

|Title={{{title|}}}
|TransTitle={{{trans_chapter|}}}
|TransItalic={{{trans_title|}}}
|IncludedWorkTitle={{{chapter|{{{contribution|{{{section|}}}}}}}}}
|TitleType={{{type|}}}
|language={{{language|}}}

|URL={{#if:{{{archiveurl|}}}
       |{{#ifeq: {{{deadurl|}}} | no | {{{url|}}} | {{{archiveurl|}}}}}
       |{{{url|}}}
     }}
|IncludedWorkURL={{{chapter-url|{{{chapterurl|{{{contribution-url|{{{sectionurl|}}}}}}}}}}}}
|AccessDate={{{accessdate|}}}
|OriginalURL={{{url|}}}
|ArchiveURL={{{archiveurl|}}}
|ArchiveDate={{{archivedate|}}}
|DeadURL={{{deadurl|}}}
|format={{{format|}}}

|At={{#if: {{{page|}}}|{{#if:{{{nopp|}}}||p.&amp;nbsp;}}{{{page}}}
      |{{#if: {{{pages|}}}|{{#if:{{{nopp|}}}||pp.&amp;nbsp;}}{{{pages}}}
      |{{{at|}}}}}
    }}

|Edition={{{edition|}}}
|Series={{{series|{{{version|}}}}}}
|Volume={{{volume|}}}

|Publisher={{{publisher|}}}
|Place={{{location|{{{place|}}}}}}
|PublicationPlace={{{location|{{{place|{{{publication-place|}}}}}}}}}
|PublicationDate={{{publication-date|}}}

|EditorSurname1={{{editor-last|{{{editor1-last|{{{editor|{{{editors|{{{editor-surname|{{{editor1-surname|}}}}}}}}}}}}}}}}}}
|EditorSurname2={{{editor2-last|{{{editor2-surname|}}}}}}
|EditorSurname3={{{editor3-last|{{{editor3-surname|}}}}}}
|EditorSurname4={{{editor4-last|{{{editor4-surname|}}}}}}
|EditorGiven1={{{editor-first|{{{editor1-first|{{{editor-given|{{{editor1-given|}}}}}}}}}}}}
|EditorGiven2={{{editor2-first|{{{editor2-given|}}}}}}
|EditorGiven3={{{editor3-first|{{{editor3-given|}}}}}}
|EditorGiven4={{{editor4-first|{{{editor4-given|}}}}}}
|Editorlink1={{{editor-link|{{{editor1-link|}}}}}}
|Editorlink2={{{editor2-link|}}}
|Editorlink3={{{editor3-link|}}}
|Editorlink4={{{editor4-link|}}}

|ARXIV={{{arxiv|}}}
|ASIN={{{asin|{{{ASIN|}}}}}}
|ASIN-TLD={{{asin-tld|}}}
|BIBCODE={{{bibcode|}}}
|DOI={{{doi|{{{DOI|}}}}}}
|DoiBroken={{{doi_brokendate|{{{doi_inactivedate|}}}}}}
|ISBN={{{isbn|{{{ISBN|}}}}}}
|ISSN={{{issn|{{{ISSN|}}}}}}
|JFM={{{jfm|{{{JFM|}}}}}}
|JSTOR={{{jstor|{{{JSTOR|}}}}}}
|LCCN={{{lccn|{{{LCCN|}}}}}}
|MR={{{mr|{{{MR|}}}}}}
|OCLC={{{oclc|{{{OCLC|}}}}}}
|OL={{{ol|{{{OL|}}}}}}
|OSTI={{{osti|{{{OSTI|}}}}}}
|PMC={{{pmc|{{{PMC|}}}}}}
|PMID={{{pmid|{{{PMID|}}}}}}
|RFC={{{rfc|{{{RFC|}}}}}}
|SSRN={{{ssrn|{{{SSRN|}}}}}}
|ZBL={{{zbl|}}}
|ID={{{id|{{{ID|}}}}}}

|laysummary={{{laysummary|}}}
|laydate={{{laydate|}}}
|laysource={{{laysource|}}}

|quote={{{quote|}}}

|Ref={{{ref|}}}

|amp={{{lastauthoramp|}}}
|AuthorMask={{{author-mask|{{{authormask|}}}}}}
|AuthorSep={{#ifeq:{{{author-separator|}}}|;|&amp;#059;|{{{author-separator|&amp;#059;}}}}}&amp;#32;
|NameSep={{{author-name-separator|,}}}&amp;#32;
|PS={{#if:{{{quote|}}}||{{{postscript|.}}}}}
|Sep={{#ifeq:{{{separator|{{{seperator}}} }}}|;|&amp;#059;|{{{separator|{{{seperator|.}}} }}} }}
|template doc demo={{{template doc demo|}}}
|Trunc={{#if:{{{display-authors|}}}|{{{display-authors}}}|8}}
}}{{#if:{{{access-date|}}}{{{accessdaymonth|}}}{{{accessday|}}}{{{accessmonthday|}}}{{{accessmonth|}}}{{{accessyear|}}}{{{dateformat|}}}{{{day|}}}{{{doilabel|}}}
|[[Category:Pages containing cite templates with deprecated parameters|{{NAMESPACE}} {{PAGENAME}}]]}}&lt;noinclude&gt;
{{Wp/nd/documentation}}
&lt;/noinclude&gt;</text>
      <sha1>i816erhyx4p1myken2gpchpr7g722k1</sha1>
    </revision>
    <revision>
      <id>2022</id>
      <parentid>2021</parentid>
      <timestamp>2016-11-09T15:37:32Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>CFCF moved page [[Template:Wp/nd/cite book]] to [[Template:Wp/nd/Cite book]]</comment>
      <origin>2021</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5171" sha1="i816erhyx4p1myken2gpchpr7g722k1" xml:space="preserve">{{Wp/nd/Citation/core
|Citation class=book

|Surname1={{{last|{{{last1|{{{author|{{{author1|{{{authors|{{{surname|{{{surname1|}}}}}}}}}}}}}}}}}}}}}
|Surname2={{{last2|{{{author2|{{{surname2|}}}}}}}}}
|Surname3={{{last3|{{{author3|{{{surname3|}}}}}}}}}
|Surname4={{{last4|{{{author4|{{{surname4|}}}}}}}}}
|Surname5={{{last5|{{{author5|{{{surname5|}}}}}}}}}
|Surname6={{{last6|{{{author6|{{{surname6|}}}}}}}}}
|Surname7={{{last7|{{{author7|{{{surname7|}}}}}}}}}
|Surname8={{{last8|{{{author8|{{{surname8|}}}}}}}}}
|Surname9={{{last9|{{{author9|{{{surname9|}}}}}}}}}

|Given1={{{first|{{{first1|{{{given|{{{given1|}}}}}}}}}}}}
|Given2={{{first2|{{{given2|}}}}}}
|Given3={{{first3|{{{given3|}}}}}}
|Given4={{{first4|{{{given4|}}}}}}
|Given5={{{first5|{{{given5|}}}}}}
|Given6={{{first6|{{{given6|}}}}}}
|Given7={{{first7|{{{given7|}}}}}}
|Given8={{{first8|{{{given8|}}}}}}
|Given9={{{first9|{{{given9|}}}}}}

|Authorlink1={{{authorlink|{{{authorlink1|{{{author-link|{{{author1-link|}}}}}}}}}}}}
|Authorlink2={{{authorlink2|{{{author2-link|}}}}}}
|Authorlink3={{{authorlink3|{{{author3-link|}}}}}}
|Authorlink4={{{authorlink4|{{{author4-link|}}}}}}
|Authorlink5={{{authorlink5|{{{author5-link|}}}}}}
|Authorlink6={{{authorlink6|{{{author6-link|}}}}}}
|Authorlink7={{{authorlink7|{{{author7-link|}}}}}}
|Authorlink8={{{authorlink8|{{{author8-link|}}}}}}
|Authorlink9={{{authorlink9|{{{author9-link|}}}}}}

|Coauthors={{{coauthors|{{{coauthor|}}}}}}

|Other={{{others|}}}

|Year={{{year|{{    &lt;!-- attempt to derive year from date, if possible --&gt;
           #if: {{{date|}}}
           |{{
              #iferror:{{#time:Y|{{{date|}}} }}
              |{{#iferror:{{#time:Y|{{{publication-date|einval}}} }}||{{#time:Y|{{{publication-date|}}} }}}}
              |{{#time:Y|{{{date|}}} }}
            }}
           |{{{publication-date|}}} &lt;!-- last resort --&gt;
         }}
      }}}
|YearNote={{{origyear|}}}
|Date={{#if:{{{date|}}}|{{{date}}}|{{{day|}}} {{{month|}}} {{{year|{{{publication-date|}}}}}}}}

|Title={{{title|}}}
|TransTitle={{{trans_chapter|}}}
|TransItalic={{{trans_title|}}}
|IncludedWorkTitle={{{chapter|{{{contribution|{{{section|}}}}}}}}}
|TitleType={{{type|}}}
|language={{{language|}}}

|URL={{#if:{{{archiveurl|}}}
       |{{#ifeq: {{{deadurl|}}} | no | {{{url|}}} | {{{archiveurl|}}}}}
       |{{{url|}}}
     }}
|IncludedWorkURL={{{chapter-url|{{{chapterurl|{{{contribution-url|{{{sectionurl|}}}}}}}}}}}}
|AccessDate={{{accessdate|}}}
|OriginalURL={{{url|}}}
|ArchiveURL={{{archiveurl|}}}
|ArchiveDate={{{archivedate|}}}
|DeadURL={{{deadurl|}}}
|format={{{format|}}}

|At={{#if: {{{page|}}}|{{#if:{{{nopp|}}}||p.&amp;nbsp;}}{{{page}}}
      |{{#if: {{{pages|}}}|{{#if:{{{nopp|}}}||pp.&amp;nbsp;}}{{{pages}}}
      |{{{at|}}}}}
    }}

|Edition={{{edition|}}}
|Series={{{series|{{{version|}}}}}}
|Volume={{{volume|}}}

|Publisher={{{publisher|}}}
|Place={{{location|{{{place|}}}}}}
|PublicationPlace={{{location|{{{place|{{{publication-place|}}}}}}}}}
|PublicationDate={{{publication-date|}}}

|EditorSurname1={{{editor-last|{{{editor1-last|{{{editor|{{{editors|{{{editor-surname|{{{editor1-surname|}}}}}}}}}}}}}}}}}}
|EditorSurname2={{{editor2-last|{{{editor2-surname|}}}}}}
|EditorSurname3={{{editor3-last|{{{editor3-surname|}}}}}}
|EditorSurname4={{{editor4-last|{{{editor4-surname|}}}}}}
|EditorGiven1={{{editor-first|{{{editor1-first|{{{editor-given|{{{editor1-given|}}}}}}}}}}}}
|EditorGiven2={{{editor2-first|{{{editor2-given|}}}}}}
|EditorGiven3={{{editor3-first|{{{editor3-given|}}}}}}
|EditorGiven4={{{editor4-first|{{{editor4-given|}}}}}}
|Editorlink1={{{editor-link|{{{editor1-link|}}}}}}
|Editorlink2={{{editor2-link|}}}
|Editorlink3={{{editor3-link|}}}
|Editorlink4={{{editor4-link|}}}

|ARXIV={{{arxiv|}}}
|ASIN={{{asin|{{{ASIN|}}}}}}
|ASIN-TLD={{{asin-tld|}}}
|BIBCODE={{{bibcode|}}}
|DOI={{{doi|{{{DOI|}}}}}}
|DoiBroken={{{doi_brokendate|{{{doi_inactivedate|}}}}}}
|ISBN={{{isbn|{{{ISBN|}}}}}}
|ISSN={{{issn|{{{ISSN|}}}}}}
|JFM={{{jfm|{{{JFM|}}}}}}
|JSTOR={{{jstor|{{{JSTOR|}}}}}}
|LCCN={{{lccn|{{{LCCN|}}}}}}
|MR={{{mr|{{{MR|}}}}}}
|OCLC={{{oclc|{{{OCLC|}}}}}}
|OL={{{ol|{{{OL|}}}}}}
|OSTI={{{osti|{{{OSTI|}}}}}}
|PMC={{{pmc|{{{PMC|}}}}}}
|PMID={{{pmid|{{{PMID|}}}}}}
|RFC={{{rfc|{{{RFC|}}}}}}
|SSRN={{{ssrn|{{{SSRN|}}}}}}
|ZBL={{{zbl|}}}
|ID={{{id|{{{ID|}}}}}}

|laysummary={{{laysummary|}}}
|laydate={{{laydate|}}}
|laysource={{{laysource|}}}

|quote={{{quote|}}}

|Ref={{{ref|}}}

|amp={{{lastauthoramp|}}}
|AuthorMask={{{author-mask|{{{authormask|}}}}}}
|AuthorSep={{#ifeq:{{{author-separator|}}}|;|&amp;#059;|{{{author-separator|&amp;#059;}}}}}&amp;#32;
|NameSep={{{author-name-separator|,}}}&amp;#32;
|PS={{#if:{{{quote|}}}||{{{postscript|.}}}}}
|Sep={{#ifeq:{{{separator|{{{seperator}}} }}}|;|&amp;#059;|{{{separator|{{{seperator|.}}} }}} }}
|template doc demo={{{template doc demo|}}}
|Trunc={{#if:{{{display-authors|}}}|{{{display-authors}}}|8}}
}}{{#if:{{{access-date|}}}{{{accessdaymonth|}}}{{{accessday|}}}{{{accessmonthday|}}}{{{accessmonth|}}}{{{accessyear|}}}{{{dateformat|}}}{{{day|}}}{{{doilabel|}}}
|[[Category:Pages containing cite templates with deprecated parameters|{{NAMESPACE}} {{PAGENAME}}]]}}&lt;noinclude&gt;
{{Wp/nd/documentation}}
&lt;/noinclude&gt;</text>
      <sha1>i816erhyx4p1myken2gpchpr7g722k1</sha1>
    </revision>
    <revision>
      <id>2023</id>
      <parentid>2022</parentid>
      <timestamp>2024-11-18T17:45:27Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <minor />
      <comment>2 revisions imported from [[:incubator:Template:Wp/nd/Cite_book]]</comment>
      <origin>2021</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5171" sha1="i816erhyx4p1myken2gpchpr7g722k1" xml:space="preserve">{{Wp/nd/Citation/core
|Citation class=book

|Surname1={{{last|{{{last1|{{{author|{{{author1|{{{authors|{{{surname|{{{surname1|}}}}}}}}}}}}}}}}}}}}}
|Surname2={{{last2|{{{author2|{{{surname2|}}}}}}}}}
|Surname3={{{last3|{{{author3|{{{surname3|}}}}}}}}}
|Surname4={{{last4|{{{author4|{{{surname4|}}}}}}}}}
|Surname5={{{last5|{{{author5|{{{surname5|}}}}}}}}}
|Surname6={{{last6|{{{author6|{{{surname6|}}}}}}}}}
|Surname7={{{last7|{{{author7|{{{surname7|}}}}}}}}}
|Surname8={{{last8|{{{author8|{{{surname8|}}}}}}}}}
|Surname9={{{last9|{{{author9|{{{surname9|}}}}}}}}}

|Given1={{{first|{{{first1|{{{given|{{{given1|}}}}}}}}}}}}
|Given2={{{first2|{{{given2|}}}}}}
|Given3={{{first3|{{{given3|}}}}}}
|Given4={{{first4|{{{given4|}}}}}}
|Given5={{{first5|{{{given5|}}}}}}
|Given6={{{first6|{{{given6|}}}}}}
|Given7={{{first7|{{{given7|}}}}}}
|Given8={{{first8|{{{given8|}}}}}}
|Given9={{{first9|{{{given9|}}}}}}

|Authorlink1={{{authorlink|{{{authorlink1|{{{author-link|{{{author1-link|}}}}}}}}}}}}
|Authorlink2={{{authorlink2|{{{author2-link|}}}}}}
|Authorlink3={{{authorlink3|{{{author3-link|}}}}}}
|Authorlink4={{{authorlink4|{{{author4-link|}}}}}}
|Authorlink5={{{authorlink5|{{{author5-link|}}}}}}
|Authorlink6={{{authorlink6|{{{author6-link|}}}}}}
|Authorlink7={{{authorlink7|{{{author7-link|}}}}}}
|Authorlink8={{{authorlink8|{{{author8-link|}}}}}}
|Authorlink9={{{authorlink9|{{{author9-link|}}}}}}

|Coauthors={{{coauthors|{{{coauthor|}}}}}}

|Other={{{others|}}}

|Year={{{year|{{    &lt;!-- attempt to derive year from date, if possible --&gt;
           #if: {{{date|}}}
           |{{
              #iferror:{{#time:Y|{{{date|}}} }}
              |{{#iferror:{{#time:Y|{{{publication-date|einval}}} }}||{{#time:Y|{{{publication-date|}}} }}}}
              |{{#time:Y|{{{date|}}} }}
            }}
           |{{{publication-date|}}} &lt;!-- last resort --&gt;
         }}
      }}}
|YearNote={{{origyear|}}}
|Date={{#if:{{{date|}}}|{{{date}}}|{{{day|}}} {{{month|}}} {{{year|{{{publication-date|}}}}}}}}

|Title={{{title|}}}
|TransTitle={{{trans_chapter|}}}
|TransItalic={{{trans_title|}}}
|IncludedWorkTitle={{{chapter|{{{contribution|{{{section|}}}}}}}}}
|TitleType={{{type|}}}
|language={{{language|}}}

|URL={{#if:{{{archiveurl|}}}
       |{{#ifeq: {{{deadurl|}}} | no | {{{url|}}} | {{{archiveurl|}}}}}
       |{{{url|}}}
     }}
|IncludedWorkURL={{{chapter-url|{{{chapterurl|{{{contribution-url|{{{sectionurl|}}}}}}}}}}}}
|AccessDate={{{accessdate|}}}
|OriginalURL={{{url|}}}
|ArchiveURL={{{archiveurl|}}}
|ArchiveDate={{{archivedate|}}}
|DeadURL={{{deadurl|}}}
|format={{{format|}}}

|At={{#if: {{{page|}}}|{{#if:{{{nopp|}}}||p.&amp;nbsp;}}{{{page}}}
      |{{#if: {{{pages|}}}|{{#if:{{{nopp|}}}||pp.&amp;nbsp;}}{{{pages}}}
      |{{{at|}}}}}
    }}

|Edition={{{edition|}}}
|Series={{{series|{{{version|}}}}}}
|Volume={{{volume|}}}

|Publisher={{{publisher|}}}
|Place={{{location|{{{place|}}}}}}
|PublicationPlace={{{location|{{{place|{{{publication-place|}}}}}}}}}
|PublicationDate={{{publication-date|}}}

|EditorSurname1={{{editor-last|{{{editor1-last|{{{editor|{{{editors|{{{editor-surname|{{{editor1-surname|}}}}}}}}}}}}}}}}}}
|EditorSurname2={{{editor2-last|{{{editor2-surname|}}}}}}
|EditorSurname3={{{editor3-last|{{{editor3-surname|}}}}}}
|EditorSurname4={{{editor4-last|{{{editor4-surname|}}}}}}
|EditorGiven1={{{editor-first|{{{editor1-first|{{{editor-given|{{{editor1-given|}}}}}}}}}}}}
|EditorGiven2={{{editor2-first|{{{editor2-given|}}}}}}
|EditorGiven3={{{editor3-first|{{{editor3-given|}}}}}}
|EditorGiven4={{{editor4-first|{{{editor4-given|}}}}}}
|Editorlink1={{{editor-link|{{{editor1-link|}}}}}}
|Editorlink2={{{editor2-link|}}}
|Editorlink3={{{editor3-link|}}}
|Editorlink4={{{editor4-link|}}}

|ARXIV={{{arxiv|}}}
|ASIN={{{asin|{{{ASIN|}}}}}}
|ASIN-TLD={{{asin-tld|}}}
|BIBCODE={{{bibcode|}}}
|DOI={{{doi|{{{DOI|}}}}}}
|DoiBroken={{{doi_brokendate|{{{doi_inactivedate|}}}}}}
|ISBN={{{isbn|{{{ISBN|}}}}}}
|ISSN={{{issn|{{{ISSN|}}}}}}
|JFM={{{jfm|{{{JFM|}}}}}}
|JSTOR={{{jstor|{{{JSTOR|}}}}}}
|LCCN={{{lccn|{{{LCCN|}}}}}}
|MR={{{mr|{{{MR|}}}}}}
|OCLC={{{oclc|{{{OCLC|}}}}}}
|OL={{{ol|{{{OL|}}}}}}
|OSTI={{{osti|{{{OSTI|}}}}}}
|PMC={{{pmc|{{{PMC|}}}}}}
|PMID={{{pmid|{{{PMID|}}}}}}
|RFC={{{rfc|{{{RFC|}}}}}}
|SSRN={{{ssrn|{{{SSRN|}}}}}}
|ZBL={{{zbl|}}}
|ID={{{id|{{{ID|}}}}}}

|laysummary={{{laysummary|}}}
|laydate={{{laydate|}}}
|laysource={{{laysource|}}}

|quote={{{quote|}}}

|Ref={{{ref|}}}

|amp={{{lastauthoramp|}}}
|AuthorMask={{{author-mask|{{{authormask|}}}}}}
|AuthorSep={{#ifeq:{{{author-separator|}}}|;|&amp;#059;|{{{author-separator|&amp;#059;}}}}}&amp;#32;
|NameSep={{{author-name-separator|,}}}&amp;#32;
|PS={{#if:{{{quote|}}}||{{{postscript|.}}}}}
|Sep={{#ifeq:{{{separator|{{{seperator}}} }}}|;|&amp;#059;|{{{separator|{{{seperator|.}}} }}} }}
|template doc demo={{{template doc demo|}}}
|Trunc={{#if:{{{display-authors|}}}|{{{display-authors}}}|8}}
}}{{#if:{{{access-date|}}}{{{accessdaymonth|}}}{{{accessday|}}}{{{accessmonthday|}}}{{{accessmonth|}}}{{{accessyear|}}}{{{dateformat|}}}{{{day|}}}{{{doilabel|}}}
|[[Category:Pages containing cite templates with deprecated parameters|{{NAMESPACE}} {{PAGENAME}}]]}}&lt;noinclude&gt;
{{Wp/nd/documentation}}
&lt;/noinclude&gt;</text>
      <sha1>i816erhyx4p1myken2gpchpr7g722k1</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Wp/nd/cite book</title>
    <ns>10</ns>
    <id>392</id>
    <redirect title="Umhlahlandlelasakhiwo:Wp/nd/Cite book" />
    <revision>
      <id>2024</id>
      <timestamp>2016-11-09T15:37:32Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>CFCF moved page [[Template:Wp/nd/cite book]] to [[Template:Wp/nd/Cite book]]</comment>
      <origin>2024</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="38" sha1="p0gba65pur2ui2t6e757om21qs5au0v" xml:space="preserve">#REDIRECT [[Template:Wp/nd/Cite book]]</text>
      <sha1>p0gba65pur2ui2t6e757om21qs5au0v</sha1>
    </revision>
    <revision>
      <id>2025</id>
      <parentid>2024</parentid>
      <timestamp>2024-11-18T17:45:27Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <minor />
      <comment>1 revision imported from [[:incubator:Template:Wp/nd/cite_book]]</comment>
      <origin>2024</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="38" sha1="p0gba65pur2ui2t6e757om21qs5au0v" xml:space="preserve">#REDIRECT [[Template:Wp/nd/Cite book]]</text>
      <sha1>p0gba65pur2ui2t6e757om21qs5au0v</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Wp/nd/check isxn</title>
    <ns>828</ns>
    <id>393</id>
    <revision>
      <id>2026</id>
      <timestamp>2016-11-09T15:46:15Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>[[:en:Module:Check isnx]]</comment>
      <origin>2026</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="6134" sha1="6c88bvpua73yn88d81dho9dnmja9yva" xml:space="preserve">-- This template is a copy of the ISXN validation code from [[Module:Citation/CS1]]
-- which allows for validating ISBN, ISMN, and ISSN without invoking a citation template

local p = {}

--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in check_isbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end

--[[Wp/nd/--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

|--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str, error_string )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then -- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
		return error_string;
	end
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return error_string;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then 
			return error_string; 
		end
		return is_valid_isxn(isbn_str, 10) and '' or error_string;
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then -- isbn13 begins with 978 or 979; ismn begins with 979
			return error_string; 
		end
		return is_valid_isxn_13 (isbn_str) and '' or error_string;
	end
end

--[[--------------------------&lt; C H E C K _ I S M N &gt;------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function check_ismn (id, error_string)
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

	return valid_ismn and '' or error_string
end

--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.

]]

local function check_issn(id, error_string)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local text;
	local valid_issn = true;

	if not id:match ('^%d%d%d%d%-%d%d%d[%dX]$') then
		return error_string;
	end
	
	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	return valid_issn and '' or error_string
end


------------------------------&lt; E N T R Y   P O I N T S &gt;--------------------------------------------------====

function p.check_isbn(frame)
	return check_isbn(frame.args[1] or frame:getParent().args[1], frame.args['error'] or frame:getParent().args['error'] or 'error')
end

function p.check_ismn(frame)
	return check_ismn(frame.args[1] or frame:getParent().args[1], frame.args['error'] or frame:getParent().args['error'] or 'error')
end

function p.check_issn(frame)
	return check_issn(frame.args[1] or frame:getParent().args[1], frame.args['error'] or frame:getParent().args['error'] or 'error')
end

return p</text>
      <sha1>6c88bvpua73yn88d81dho9dnmja9yva</sha1>
    </revision>
    <revision>
      <id>2027</id>
      <parentid>2026</parentid>
      <timestamp>2016-11-09T15:46:32Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>CFCF moved page [[Module:Wp/nd/check isnx]] to [[Module:Wp/nd/Check isnx]] without leaving a redirect</comment>
      <origin>2026</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="6134" sha1="6c88bvpua73yn88d81dho9dnmja9yva" xml:space="preserve">-- This template is a copy of the ISXN validation code from [[Module:Citation/CS1]]
-- which allows for validating ISBN, ISMN, and ISSN without invoking a citation template

local p = {}

--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in check_isbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end

--[[Wp/nd/--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

|--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str, error_string )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then -- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
		return error_string;
	end
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return error_string;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then 
			return error_string; 
		end
		return is_valid_isxn(isbn_str, 10) and '' or error_string;
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then -- isbn13 begins with 978 or 979; ismn begins with 979
			return error_string; 
		end
		return is_valid_isxn_13 (isbn_str) and '' or error_string;
	end
end

--[[--------------------------&lt; C H E C K _ I S M N &gt;------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function check_ismn (id, error_string)
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

	return valid_ismn and '' or error_string
end

--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.

]]

local function check_issn(id, error_string)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local text;
	local valid_issn = true;

	if not id:match ('^%d%d%d%d%-%d%d%d[%dX]$') then
		return error_string;
	end
	
	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	return valid_issn and '' or error_string
end


------------------------------&lt; E N T R Y   P O I N T S &gt;--------------------------------------------------====

function p.check_isbn(frame)
	return check_isbn(frame.args[1] or frame:getParent().args[1], frame.args['error'] or frame:getParent().args['error'] or 'error')
end

function p.check_ismn(frame)
	return check_ismn(frame.args[1] or frame:getParent().args[1], frame.args['error'] or frame:getParent().args['error'] or 'error')
end

function p.check_issn(frame)
	return check_issn(frame.args[1] or frame:getParent().args[1], frame.args['error'] or frame:getParent().args['error'] or 'error')
end

return p</text>
      <sha1>6c88bvpua73yn88d81dho9dnmja9yva</sha1>
    </revision>
    <revision>
      <id>2028</id>
      <parentid>2027</parentid>
      <timestamp>2016-11-09T15:47:07Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>CFCF moved page [[Module:Wp/nd/Check isnx]] to [[Module:Wp/nd/Check isxn]] without leaving a redirect</comment>
      <origin>2026</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="6134" sha1="6c88bvpua73yn88d81dho9dnmja9yva" xml:space="preserve">-- This template is a copy of the ISXN validation code from [[Module:Citation/CS1]]
-- which allows for validating ISBN, ISMN, and ISSN without invoking a citation template

local p = {}

--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in check_isbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end

--[[Wp/nd/--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

|--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str, error_string )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then -- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
		return error_string;
	end
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return error_string;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then 
			return error_string; 
		end
		return is_valid_isxn(isbn_str, 10) and '' or error_string;
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then -- isbn13 begins with 978 or 979; ismn begins with 979
			return error_string; 
		end
		return is_valid_isxn_13 (isbn_str) and '' or error_string;
	end
end

--[[--------------------------&lt; C H E C K _ I S M N &gt;------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function check_ismn (id, error_string)
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

	return valid_ismn and '' or error_string
end

--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.

]]

local function check_issn(id, error_string)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local text;
	local valid_issn = true;

	if not id:match ('^%d%d%d%d%-%d%d%d[%dX]$') then
		return error_string;
	end
	
	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	return valid_issn and '' or error_string
end


------------------------------&lt; E N T R Y   P O I N T S &gt;--------------------------------------------------====

function p.check_isbn(frame)
	return check_isbn(frame.args[1] or frame:getParent().args[1], frame.args['error'] or frame:getParent().args['error'] or 'error')
end

function p.check_ismn(frame)
	return check_ismn(frame.args[1] or frame:getParent().args[1], frame.args['error'] or frame:getParent().args['error'] or 'error')
end

function p.check_issn(frame)
	return check_issn(frame.args[1] or frame:getParent().args[1], frame.args['error'] or frame:getParent().args['error'] or 'error')
end

return p</text>
      <sha1>6c88bvpua73yn88d81dho9dnmja9yva</sha1>
    </revision>
    <revision>
      <id>2029</id>
      <parentid>2028</parentid>
      <timestamp>2016-11-09T15:47:40Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>CFCF moved page [[Module:Wp/nd/Check isxn]] to [[Module:Wp/nd/check isxn]] without leaving a redirect</comment>
      <origin>2026</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="6134" sha1="6c88bvpua73yn88d81dho9dnmja9yva" xml:space="preserve">-- This template is a copy of the ISXN validation code from [[Module:Citation/CS1]]
-- which allows for validating ISBN, ISMN, and ISSN without invoking a citation template

local p = {}

--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in check_isbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end

--[[Wp/nd/--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

|--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str, error_string )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then -- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
		return error_string;
	end
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return error_string;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then 
			return error_string; 
		end
		return is_valid_isxn(isbn_str, 10) and '' or error_string;
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then -- isbn13 begins with 978 or 979; ismn begins with 979
			return error_string; 
		end
		return is_valid_isxn_13 (isbn_str) and '' or error_string;
	end
end

--[[--------------------------&lt; C H E C K _ I S M N &gt;------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function check_ismn (id, error_string)
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

	return valid_ismn and '' or error_string
end

--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.

]]

local function check_issn(id, error_string)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local text;
	local valid_issn = true;

	if not id:match ('^%d%d%d%d%-%d%d%d[%dX]$') then
		return error_string;
	end
	
	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	return valid_issn and '' or error_string
end


------------------------------&lt; E N T R Y   P O I N T S &gt;--------------------------------------------------====

function p.check_isbn(frame)
	return check_isbn(frame.args[1] or frame:getParent().args[1], frame.args['error'] or frame:getParent().args['error'] or 'error')
end

function p.check_ismn(frame)
	return check_ismn(frame.args[1] or frame:getParent().args[1], frame.args['error'] or frame:getParent().args['error'] or 'error')
end

function p.check_issn(frame)
	return check_issn(frame.args[1] or frame:getParent().args[1], frame.args['error'] or frame:getParent().args['error'] or 'error')
end

return p</text>
      <sha1>6c88bvpua73yn88d81dho9dnmja9yva</sha1>
    </revision>
    <revision>
      <id>2030</id>
      <parentid>2029</parentid>
      <timestamp>2024-11-18T17:45:28Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <minor />
      <comment>4 revisions imported from [[:incubator:Module:Wp/nd/check_isxn]]</comment>
      <origin>2026</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="6134" sha1="6c88bvpua73yn88d81dho9dnmja9yva" xml:space="preserve">-- This template is a copy of the ISXN validation code from [[Module:Citation/CS1]]
-- which allows for validating ISBN, ISMN, and ISSN without invoking a citation template

local p = {}

--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in check_isbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end

--[[Wp/nd/--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

|--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str, error_string )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then -- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
		return error_string;
	end
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return error_string;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then 
			return error_string; 
		end
		return is_valid_isxn(isbn_str, 10) and '' or error_string;
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then -- isbn13 begins with 978 or 979; ismn begins with 979
			return error_string; 
		end
		return is_valid_isxn_13 (isbn_str) and '' or error_string;
	end
end

--[[--------------------------&lt; C H E C K _ I S M N &gt;------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function check_ismn (id, error_string)
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

	return valid_ismn and '' or error_string
end

--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.

]]

local function check_issn(id, error_string)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local text;
	local valid_issn = true;

	if not id:match ('^%d%d%d%d%-%d%d%d[%dX]$') then
		return error_string;
	end
	
	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	return valid_issn and '' or error_string
end


------------------------------&lt; E N T R Y   P O I N T S &gt;--------------------------------------------------====

function p.check_isbn(frame)
	return check_isbn(frame.args[1] or frame:getParent().args[1], frame.args['error'] or frame:getParent().args['error'] or 'error')
end

function p.check_ismn(frame)
	return check_ismn(frame.args[1] or frame:getParent().args[1], frame.args['error'] or frame:getParent().args['error'] or 'error')
end

function p.check_issn(frame)
	return check_issn(frame.args[1] or frame:getParent().args[1], frame.args['error'] or frame:getParent().args['error'] or 'error')
end

return p</text>
      <sha1>6c88bvpua73yn88d81dho9dnmja9yva</sha1>
    </revision>
  </page>
  <page>
    <title>Wp/nd/Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale</title>
    <ns>0</ns>
    <id>394</id>
    <redirect title="Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale" />
    <revision>
      <id>2032</id>
      <timestamp>2024-11-18T17:47:01Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <comment>Amire80 moved page [[Wp/nd/Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale]] to [[Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale]]</comment>
      <origin>2032</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="78" sha1="hax2jevz3ahmgyns12wczj4nzd40cyu" xml:space="preserve">#REDIRECT [[Ubulwelwe obungena besibungwana esincani obenza umuntu aphophale]]</text>
      <sha1>hax2jevz3ahmgyns12wczj4nzd40cyu</sha1>
    </revision>
  </page>
  <page>
    <title>Isichenene seengazi esibulwelwe bokuthunda iingazi</title>
    <ns>0</ns>
    <id>395</id>
    <revision>
      <id>2033</id>
      <timestamp>2016-10-01T06:31:42Z</timestamp>
      <contributor>
        <username>incubator&gt;Ian Henderson</username>
        <id>0</id>
      </contributor>
      <comment>Created</comment>
      <origin>2033</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7405" sha1="ouvjmir95peeim5rswavn1piftncwxb" xml:space="preserve">{{Infobox disease 
 | Name            = Isichenene seengazi esibulwelwe bokuthunda iingazi 
 | Image           = Schistosomiasis in a child 2.jpg 
 | Caption         = Umsana oneminyaka eli-11[[ophethwe  |kuqunjelwa kwamathumbu]]kanye[[nokuhlangahlangana komkhumbulo]]okubangwe sichenene seengazi esibulwelwe bokuthunda iingazi (Agusan del Sur, Philippines)
 | Field           = [[Infectious disease (medical specialty)|Infectious disease]]
 | pronounce       ={{IPAc-en|ˌ|ʃ|i|s|t|ə|s|ə|ˈ|m|aɪ|ə|s|ᵻ|s|,_|-|t|oʊ|-|,_|-|s|oʊ|-}}&lt;ref&gt;{{cite web |url=https://www.oxforddictionaries.com/definition/english/schistosomiasis |title=schistosomiasis - definition of schistosomiasis in English from the Oxford dictionary |publisher=[[OxfordDictionaries.com]] |access-date=2016-01-20 }}&lt;/ref&gt;
 | synonyms = ubulwelwe bokuthunda iingazi, umgomani womneke, ukuphathwa yihloko kwekatayama&lt;ref name=NHS2011&gt;{{cite web | title=Schistosomiasis (bilharzia) | url=http://www.nhs.uk/Conditions/schistosomiasis/Pages/Introduction.aspx | work=NHS Choices | accessdate=15 March 2014 | date=17 December 2011}}&lt;/ref&gt;&lt;ref&gt;{{cite web | title=Schistosomiasis | url=http://www.patient.info/doctor/schistosomiasis-pro | website=Patient.info | accessdate=11 June 2014 | date=12/2/2013}}&lt;/ref&gt;
 | DiseasesDB      =11875
|DiseasesDB_mult={{DiseasesDB2|11882}}{{DiseasesDB2|11856}}
 | ICD10           = {{ICD10|B|65||b|65}} 
 | ICD9            = {{ICD9|120}} 
 | OMIM            = 
 | MedlinePlus     =001321
 | eMedicineSubj=article
 | eMedicineTopic=228392
 | MeshID          = D012552
|Orphanet=1247
}}
'''isichenene seengazi esibulwelwe bokuthunda iingazi''' eyaziwa godu bona yi-snail fevere '''umgomani womneke''' yi[[ubulwelwe |beenyokana eziyingozi]] obubangwa[[sibungu|esidla nanyana yini esihlangana nakho]][[isubungu esipataleleko]]esibizwa nangokuthi[[yi-schistosome]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Imisipha [[yesinya]]nofana[[emathunjini]]zingatheleleka.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo wokobana uphethwe bulwelwe lobu[[ uzwa ubuhlungu esinyeni]],[[ uyarhuda okungapheliko]],[[ amakaka  aneengazi| ujanyelwe ziingazi]], nofana[[i-hematuria|igazi livela emthundweni]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Labo abatheleleke ngobulwelwe lobu[[obuphikelela isikhathi| isikhathi eside]]bangaba [[nemiraro yokulimala kwesibindi]], [[ ukungasebenzi kweso]], [[ ukungabelethi]], nofana[[ ikankere yesinye]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ebantwaneni[[, ingabanga|ukungakhuli kuhle]]kanye[[ nokurholophala ngokufunda|ubudisi nakuza kezefundo]].&lt;ref name=WHO2014&gt;{{cite web | title=Schistosomiasis Fact sheet N°115 | url=http://www.who.int/mediacentre/factsheets/fs115/en | work=World Health Organization | accessdate=15 March 2014| date=3 February 2014}}&lt;/ref&gt;

&lt;!-- Cause --&gt;
Ubulwelwe lobu butheleleka[[ngokuthinta nofana ukusela amanzi atsengekileko]]asele anazo iinyokanyokana lezi.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Inyokanyoka ezidla emzibeni wenye into[[ziphuma eminekeni ehlala ngaphakathi kwamanzi atsengekileko]]&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu budlange khulu eenarheni ezisathuthukako ngombana abantwana bakhona ngibo abavame ukudla emanzini adungekileko.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Abanye abantu abasengozini yokutheleleka baphathi bamaplasi, abathiyi beemfesi, kanye nabantu abasebenzisa amanzi angakahlwekeki ukuphila ngamalanga.&lt;ref name=WHO2014/&gt; Ubulwelwe lobu buhlangana nesiqhema samalwelwe i[[helminthiasis|helminth ethelelanako]].&lt;ref&gt;{{cite web | title=Chapter 3 Infectious Diseases Related To Travel | url=http://wwwnc.cdc.gov/travel/yellowbook/2014/chapter-3-infectious-diseases-related-to-travel/schistosomiasis | website=cdc.gov | accessdate=30 November 2014 | date=1 August 2013}}&lt;/ref&gt; Ukuthola umrabho wobulwelwe lobu kungenziwa ngokutjheja amaqanda wesilwane esiphila ngokudla ezinye iinlwana emthundweni nofana emakakeni womuntu.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Begodu ingaqinisekiswa ngokuthola[[ama-antibodies ]]manqophana nobulwelwe lobu egazini lomuntu.&lt;ref name=WHO2014/&gt; 

&lt;!-- Prevention and Treatment --&gt;
Iindlela zokukhandela ubulwelwe lobu kufaka hlangana ukuthuthukisa ukutholakala kwamanzi ahlwengileko begodu nokunciphisa imineke etholakala emanzini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; EEndaweni lapho ubulwelwe lobu budlange khona, imitjhoga nofana iinhlahla [[ezibizwa nge-praziquantel]]zinganikelwa kanye komnyaka esiqhemeni salabo abagulako kileyo ndawo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kwenzelwa ukwehlisa isibalo sabantu abatheleleke ngobulwelwe begodu nokwehlisa izinga lokusabalaliswa kobulwelwe lobu.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; I-Praziquantel ngenye yeenhlanhla ezinyulwe[[yi-World Health Organization-iHlangano yeePhasi yezamaPilo]] (WHO) kilabo esele kwaziwa bona bangenwe bulwelwe lobu.&lt;ref name=WHO2014/&gt; 

&lt;!-- Epidemiology --&gt;
Isichenene seengazi esibulwelwe bokuthunda iingazi siphathe abantu ababalelwa eengidigidini ezima-210 wabantu iphasi zombelele ngomnayaka ka-2012.&lt;ref name=Fen2012&gt;{{cite journal | last=Fenwick | first=A | title=The global burden of neglected tropical diseases.| journal=Public Health | date=Mar 2012 | volume=126 | issue=3 | pages=233–6 | pmid=22325616|doi=10.1016/j.puhe.2011.11.015}}&lt;/ref&gt; Isibalo sabantu esibalelwa ku-12 000&lt;ref name=Loz2012&gt;{{cite journal | last=Lozano | first=R. | title=Global and regional mortality from 235 causes of death for 20 age groups in 1990 and 2010: a systematic analysis for the Global Burden of Disease Study 2010 | journal=Lancet | date=15 December 2012 | volume=380 | issue=9859 | pages=2095–128 | pmid=23245604 | doi=10.1016/S0140-6736(12)61728-0 | last2=Naghavi | first2=M. | last3=Foreman | first3=K. | last4=Lim | first4=S. | last5=Shibuya | first5=K. | last6=Aboyans | first6=V. | last7=Abraham | first7=J. | last8=Adair | first8=T. | last9=Aggarwal | first9=R. | displayauthors=8}}&lt;/ref&gt; ukufika ku 200,000 babulawa ngiso emnyakeni munye.&lt;ref name=The2013&gt;{{cite journal | last=Thétiot-Laurent | first=S. A. | author2=Boissier, J. | author3=Robert, A. | author4= Meunier, B. | title=Schistosomiasis Chemotherapy | journal=Angewandte Chemie International Edition in English | date=27 June 2013 | pmid=23813602 | volume=52 | issue=31 | pages=7936–56 | doi=10.1002/anie.201208390}}&lt;/ref&gt; Ubulwelwe lobu butholakala khulu e-Afrika, kanye ne-Asia ne Sewula ye-Amerikha.&lt;ref name=WHO2014/&gt; Pheze abantu abaziingidi ezima-700, eenarheni ezima-70, bahlala lapha ubulwelwe lobu budlange khona.&lt;ref name=The2013/&gt;&lt;ref&gt;{{cite web | title=Schistosomiasis  A major public health problem | url=http://www.who.int/schistosomiasis/en | work=World Health Organization | accessdate=15 March 2014}}&lt;/ref&gt; Eenarheni zethrophiki, isichenene seengazi esibulwelwe bokuthunda iingazi sibulwelwe obuza ngemva [[kwemalariya]] obuhlangana nezinye izifo ezibangwa ziinlwanyana eziphila ngokudla ezinye iinlwana ezibanga ukuwa konotho.&lt;ref name=&quot;SCP&quot;&gt;{{Cite web | author=The Carter Center | title=Schistosomiasis Control Program | url=http://www.cartercenter.org/health/schistosomiasis/index.html | accessdate=17 July 2008}}&lt;/ref&gt; Isichenene seengazi esibulwelwe bokuthunda iingazi[[ sifakwe erherhweni lamalwelwe wethropiki angakanakwa]].&lt;ref&gt;{{cite web | title=Neglected Tropical Diseases | url=http://www.cdc.gov/globalhealth/ntd/diseases/index.html | website=cdc.gov | accessdate=28 November 2014 | date=6 June 2011}}&lt;/ref&gt;
==isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini.==
&lt;references /&gt;</text>
      <sha1>ouvjmir95peeim5rswavn1piftncwxb</sha1>
    </revision>
    <revision>
      <id>2034</id>
      <parentid>2033</parentid>
      <timestamp>2016-11-04T12:27:47Z</timestamp>
      <contributor>
        <username>incubator&gt;Doc James</username>
        <id>0</id>
      </contributor>
      <origin>2034</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7410" sha1="cxby6sezoxlvqtus18g6y5om5xgpb6i" xml:space="preserve">{{Wp/nd/Infobox disease
 | name            = Isichenene seengazi esibulwelwe bokuthunda iingazi 
 | image           = Schistosomiasis in a child 2.jpg 
 | caption         = Umsana oneminyaka eli-11[[ophethwe  |kuqunjelwa kwamathumbu]]kanye[[nokuhlangahlangana komkhumbulo]]okubangwe sichenene seengazi esibulwelwe bokuthunda iingazi (Agusan del Sur, Philippines)
 | Field           = [[Infectious disease (medical specialty)|Infectious disease]]
 | pronounce       ={{IPAc-en|ˌ|ʃ|i|s|t|ə|s|ə|ˈ|m|aɪ|ə|s|ᵻ|s|,_|-|t|oʊ|-|,_|-|s|oʊ|-}}&lt;ref&gt;{{cite web |url=https://www.oxforddictionaries.com/definition/english/schistosomiasis |title=schistosomiasis - definition of schistosomiasis in English from the Oxford dictionary |publisher=[[OxfordDictionaries.com]] |access-date=2016-01-20 }}&lt;/ref&gt;
 | synonyms = ubulwelwe bokuthunda iingazi, umgomani womneke, ukuphathwa yihloko kwekatayama&lt;ref name=NHS2011&gt;{{cite web | title=Schistosomiasis (bilharzia) | url=http://www.nhs.uk/Conditions/schistosomiasis/Pages/Introduction.aspx | work=NHS Choices | accessdate=15 March 2014 | date=17 December 2011}}&lt;/ref&gt;&lt;ref&gt;{{cite web | title=Schistosomiasis | url=http://www.patient.info/doctor/schistosomiasis-pro | website=Patient.info | accessdate=11 June 2014 | date=12/2/2013}}&lt;/ref&gt;
 | DiseasesDB      =11875
|DiseasesDB_mult={{DiseasesDB2|11882}}{{DiseasesDB2|11856}}
 | ICD10           = {{ICD10|B|65||b|65}} 
 | ICD9            = {{ICD9|120}} 
 | OMIM            = 
 | MedlinePlus     =001321
 | eMedicineSubj=article
 | eMedicineTopic=228392
 | MeshID          = D012552
|Orphanet=1247
}}
'''isichenene seengazi esibulwelwe bokuthunda iingazi''' eyaziwa godu bona yi-snail fevere '''umgomani womneke''' yi[[ubulwelwe |beenyokana eziyingozi]] obubangwa[[sibungu|esidla nanyana yini esihlangana nakho]][[isubungu esipataleleko]]esibizwa nangokuthi[[yi-schistosome]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Imisipha [[yesinya]]nofana[[emathunjini]]zingatheleleka.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo wokobana uphethwe bulwelwe lobu[[ uzwa ubuhlungu esinyeni]],[[ uyarhuda okungapheliko]],[[ amakaka  aneengazi| ujanyelwe ziingazi]], nofana[[i-hematuria|igazi livela emthundweni]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Labo abatheleleke ngobulwelwe lobu[[obuphikelela isikhathi| isikhathi eside]]bangaba [[nemiraro yokulimala kwesibindi]], [[ ukungasebenzi kweso]], [[ ukungabelethi]], nofana[[ ikankere yesinye]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ebantwaneni[[, ingabanga|ukungakhuli kuhle]]kanye[[ nokurholophala ngokufunda|ubudisi nakuza kezefundo]].&lt;ref name=WHO2014&gt;{{cite web | title=Schistosomiasis Fact sheet N°115 | url=http://www.who.int/mediacentre/factsheets/fs115/en | work=World Health Organization | accessdate=15 March 2014| date=3 February 2014}}&lt;/ref&gt;

&lt;!-- Cause --&gt;
Ubulwelwe lobu butheleleka[[ngokuthinta nofana ukusela amanzi atsengekileko]]asele anazo iinyokanyokana lezi.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Inyokanyoka ezidla emzibeni wenye into[[ziphuma eminekeni ehlala ngaphakathi kwamanzi atsengekileko]]&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu budlange khulu eenarheni ezisathuthukako ngombana abantwana bakhona ngibo abavame ukudla emanzini adungekileko.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Abanye abantu abasengozini yokutheleleka baphathi bamaplasi, abathiyi beemfesi, kanye nabantu abasebenzisa amanzi angakahlwekeki ukuphila ngamalanga.&lt;ref name=WHO2014/&gt; Ubulwelwe lobu buhlangana nesiqhema samalwelwe i[[helminthiasis|helminth ethelelanako]].&lt;ref&gt;{{cite web | title=Chapter 3 Infectious Diseases Related To Travel | url=http://wwwnc.cdc.gov/travel/yellowbook/2014/chapter-3-infectious-diseases-related-to-travel/schistosomiasis | website=cdc.gov | accessdate=30 November 2014 | date=1 August 2013}}&lt;/ref&gt; Ukuthola umrabho wobulwelwe lobu kungenziwa ngokutjheja amaqanda wesilwane esiphila ngokudla ezinye iinlwana emthundweni nofana emakakeni womuntu.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Begodu ingaqinisekiswa ngokuthola[[ama-antibodies ]]manqophana nobulwelwe lobu egazini lomuntu.&lt;ref name=WHO2014/&gt; 

&lt;!-- Prevention and Treatment --&gt;
Iindlela zokukhandela ubulwelwe lobu kufaka hlangana ukuthuthukisa ukutholakala kwamanzi ahlwengileko begodu nokunciphisa imineke etholakala emanzini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; EEndaweni lapho ubulwelwe lobu budlange khona, imitjhoga nofana iinhlahla [[ezibizwa nge-praziquantel]]zinganikelwa kanye komnyaka esiqhemeni salabo abagulako kileyo ndawo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kwenzelwa ukwehlisa isibalo sabantu abatheleleke ngobulwelwe begodu nokwehlisa izinga lokusabalaliswa kobulwelwe lobu.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; I-Praziquantel ngenye yeenhlanhla ezinyulwe[[yi-World Health Organization-iHlangano yeePhasi yezamaPilo]] (WHO) kilabo esele kwaziwa bona bangenwe bulwelwe lobu.&lt;ref name=WHO2014/&gt; 

&lt;!-- Epidemiology --&gt;
Isichenene seengazi esibulwelwe bokuthunda iingazi siphathe abantu ababalelwa eengidigidini ezima-210 wabantu iphasi zombelele ngomnayaka ka-2012.&lt;ref name=Fen2012&gt;{{cite journal | last=Fenwick | first=A | title=The global burden of neglected tropical diseases.| journal=Public Health | date=Mar 2012 | volume=126 | issue=3 | pages=233–6 | pmid=22325616|doi=10.1016/j.puhe.2011.11.015}}&lt;/ref&gt; Isibalo sabantu esibalelwa ku-12 000&lt;ref name=Loz2012&gt;{{cite journal | last=Lozano | first=R. | title=Global and regional mortality from 235 causes of death for 20 age groups in 1990 and 2010: a systematic analysis for the Global Burden of Disease Study 2010 | journal=Lancet | date=15 December 2012 | volume=380 | issue=9859 | pages=2095–128 | pmid=23245604 | doi=10.1016/S0140-6736(12)61728-0 | last2=Naghavi | first2=M. | last3=Foreman | first3=K. | last4=Lim | first4=S. | last5=Shibuya | first5=K. | last6=Aboyans | first6=V. | last7=Abraham | first7=J. | last8=Adair | first8=T. | last9=Aggarwal | first9=R. | displayauthors=8}}&lt;/ref&gt; ukufika ku 200,000 babulawa ngiso emnyakeni munye.&lt;ref name=The2013&gt;{{cite journal | last=Thétiot-Laurent | first=S. A. | author2=Boissier, J. | author3=Robert, A. | author4= Meunier, B. | title=Schistosomiasis Chemotherapy | journal=Angewandte Chemie International Edition in English | date=27 June 2013 | pmid=23813602 | volume=52 | issue=31 | pages=7936–56 | doi=10.1002/anie.201208390}}&lt;/ref&gt; Ubulwelwe lobu butholakala khulu e-Afrika, kanye ne-Asia ne Sewula ye-Amerikha.&lt;ref name=WHO2014/&gt; Pheze abantu abaziingidi ezima-700, eenarheni ezima-70, bahlala lapha ubulwelwe lobu budlange khona.&lt;ref name=The2013/&gt;&lt;ref&gt;{{cite web | title=Schistosomiasis  A major public health problem | url=http://www.who.int/schistosomiasis/en | work=World Health Organization | accessdate=15 March 2014}}&lt;/ref&gt; Eenarheni zethrophiki, isichenene seengazi esibulwelwe bokuthunda iingazi sibulwelwe obuza ngemva [[kwemalariya]] obuhlangana nezinye izifo ezibangwa ziinlwanyana eziphila ngokudla ezinye iinlwana ezibanga ukuwa konotho.&lt;ref name=&quot;SCP&quot;&gt;{{Cite web | author=The Carter Center | title=Schistosomiasis Control Program | url=http://www.cartercenter.org/health/schistosomiasis/index.html | accessdate=17 July 2008}}&lt;/ref&gt; Isichenene seengazi esibulwelwe bokuthunda iingazi[[ sifakwe erherhweni lamalwelwe wethropiki angakanakwa]].&lt;ref&gt;{{cite web | title=Neglected Tropical Diseases | url=http://www.cdc.gov/globalhealth/ntd/diseases/index.html | website=cdc.gov | accessdate=28 November 2014 | date=6 June 2011}}&lt;/ref&gt;
==isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini.==
&lt;references /&gt;</text>
      <sha1>cxby6sezoxlvqtus18g6y5om5xgpb6i</sha1>
    </revision>
    <revision>
      <id>2035</id>
      <parentid>2034</parentid>
      <timestamp>2016-11-04T12:27:59Z</timestamp>
      <contributor>
        <username>incubator&gt;Doc James</username>
        <id>0</id>
      </contributor>
      <origin>2035</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7379" sha1="lkngzyh937yds291xzlhilxevla6ife" xml:space="preserve">{{Wp/nd/Infobox disease
 | name            = Isichenene seengazi esibulwelwe bokuthunda iingazi 
 | image           = Schistosomiasis in a child 2.jpg 
 | caption         = Umsana oneminyaka eli-11[[ophethwe  |kuqunjelwa kwamathumbu]]kanye[[nokuhlangahlangana komkhumbulo]]okubangwe sichenene seengazi esibulwelwe bokuthunda iingazi (Agusan del Sur, Philippines)
 | Field           = [[Infectious disease (medical specialty)|Infectious disease]]
 | pronounce       ={{IPAc-en|ˌ|ʃ|i|s|t|ə|s|ə|ˈ|m|aɪ|ə|s|ᵻ|s|,_|-|t|oʊ|-|,_|-|s|oʊ|-}}&lt;ref&gt;{{cite web |url=https://www.oxforddictionaries.com/definition/english/schistosomiasis |title=schistosomiasis - definition of schistosomiasis in English from the Oxford dictionary |publisher=[[OxfordDictionaries.com]] |access-date=2016-01-20 }}&lt;/ref&gt;
 | synonyms = ubulwelwe bokuthunda iingazi, umgomani womneke, ukuphathwa yihloko kwekatayama&lt;ref name=NHS2011&gt;{{cite web | title=Schistosomiasis (bilharzia) | url=http://www.nhs.uk/Conditions/schistosomiasis/Pages/Introduction.aspx | work=NHS Choices | accessdate=15 March 2014 | date=17 December 2011}}&lt;/ref&gt;&lt;ref&gt;{{cite web | title=Schistosomiasis | url=http://www.patient.info/doctor/schistosomiasis-pro | website=Patient.info | accessdate=11 June 2014 | date=12/2/2013}}&lt;/ref&gt;
 | DiseasesDB      =11875
|DiseasesDB_mult={{DiseasesDB2|11882}}{{DiseasesDB2|11856}}
 | ICD10           = 
 | ICD9            = 120
 | OMIM            = 
 | MedlinePlus     =001321
 | eMedicineSubj=article
 | eMedicineTopic=228392
 | MeshID          = D012552
|Orphanet=1247
}}
'''isichenene seengazi esibulwelwe bokuthunda iingazi''' eyaziwa godu bona yi-snail fevere '''umgomani womneke''' yi[[ubulwelwe |beenyokana eziyingozi]] obubangwa[[sibungu|esidla nanyana yini esihlangana nakho]][[isubungu esipataleleko]]esibizwa nangokuthi[[yi-schistosome]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Imisipha [[yesinya]]nofana[[emathunjini]]zingatheleleka.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo wokobana uphethwe bulwelwe lobu[[ uzwa ubuhlungu esinyeni]],[[ uyarhuda okungapheliko]],[[ amakaka  aneengazi| ujanyelwe ziingazi]], nofana[[i-hematuria|igazi livela emthundweni]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Labo abatheleleke ngobulwelwe lobu[[obuphikelela isikhathi| isikhathi eside]]bangaba [[nemiraro yokulimala kwesibindi]], [[ ukungasebenzi kweso]], [[ ukungabelethi]], nofana[[ ikankere yesinye]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ebantwaneni[[, ingabanga|ukungakhuli kuhle]]kanye[[ nokurholophala ngokufunda|ubudisi nakuza kezefundo]].&lt;ref name=WHO2014&gt;{{cite web | title=Schistosomiasis Fact sheet N°115 | url=http://www.who.int/mediacentre/factsheets/fs115/en | work=World Health Organization | accessdate=15 March 2014| date=3 February 2014}}&lt;/ref&gt;

&lt;!-- Cause --&gt;
Ubulwelwe lobu butheleleka[[ngokuthinta nofana ukusela amanzi atsengekileko]]asele anazo iinyokanyokana lezi.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Inyokanyoka ezidla emzibeni wenye into[[ziphuma eminekeni ehlala ngaphakathi kwamanzi atsengekileko]]&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu budlange khulu eenarheni ezisathuthukako ngombana abantwana bakhona ngibo abavame ukudla emanzini adungekileko.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Abanye abantu abasengozini yokutheleleka baphathi bamaplasi, abathiyi beemfesi, kanye nabantu abasebenzisa amanzi angakahlwekeki ukuphila ngamalanga.&lt;ref name=WHO2014/&gt; Ubulwelwe lobu buhlangana nesiqhema samalwelwe i[[helminthiasis|helminth ethelelanako]].&lt;ref&gt;{{cite web | title=Chapter 3 Infectious Diseases Related To Travel | url=http://wwwnc.cdc.gov/travel/yellowbook/2014/chapter-3-infectious-diseases-related-to-travel/schistosomiasis | website=cdc.gov | accessdate=30 November 2014 | date=1 August 2013}}&lt;/ref&gt; Ukuthola umrabho wobulwelwe lobu kungenziwa ngokutjheja amaqanda wesilwane esiphila ngokudla ezinye iinlwana emthundweni nofana emakakeni womuntu.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Begodu ingaqinisekiswa ngokuthola[[ama-antibodies ]]manqophana nobulwelwe lobu egazini lomuntu.&lt;ref name=WHO2014/&gt; 

&lt;!-- Prevention and Treatment --&gt;
Iindlela zokukhandela ubulwelwe lobu kufaka hlangana ukuthuthukisa ukutholakala kwamanzi ahlwengileko begodu nokunciphisa imineke etholakala emanzini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; EEndaweni lapho ubulwelwe lobu budlange khona, imitjhoga nofana iinhlahla [[ezibizwa nge-praziquantel]]zinganikelwa kanye komnyaka esiqhemeni salabo abagulako kileyo ndawo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kwenzelwa ukwehlisa isibalo sabantu abatheleleke ngobulwelwe begodu nokwehlisa izinga lokusabalaliswa kobulwelwe lobu.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; I-Praziquantel ngenye yeenhlanhla ezinyulwe[[yi-World Health Organization-iHlangano yeePhasi yezamaPilo]] (WHO) kilabo esele kwaziwa bona bangenwe bulwelwe lobu.&lt;ref name=WHO2014/&gt; 

&lt;!-- Epidemiology --&gt;
Isichenene seengazi esibulwelwe bokuthunda iingazi siphathe abantu ababalelwa eengidigidini ezima-210 wabantu iphasi zombelele ngomnayaka ka-2012.&lt;ref name=Fen2012&gt;{{cite journal | last=Fenwick | first=A | title=The global burden of neglected tropical diseases.| journal=Public Health | date=Mar 2012 | volume=126 | issue=3 | pages=233–6 | pmid=22325616|doi=10.1016/j.puhe.2011.11.015}}&lt;/ref&gt; Isibalo sabantu esibalelwa ku-12 000&lt;ref name=Loz2012&gt;{{cite journal | last=Lozano | first=R. | title=Global and regional mortality from 235 causes of death for 20 age groups in 1990 and 2010: a systematic analysis for the Global Burden of Disease Study 2010 | journal=Lancet | date=15 December 2012 | volume=380 | issue=9859 | pages=2095–128 | pmid=23245604 | doi=10.1016/S0140-6736(12)61728-0 | last2=Naghavi | first2=M. | last3=Foreman | first3=K. | last4=Lim | first4=S. | last5=Shibuya | first5=K. | last6=Aboyans | first6=V. | last7=Abraham | first7=J. | last8=Adair | first8=T. | last9=Aggarwal | first9=R. | displayauthors=8}}&lt;/ref&gt; ukufika ku 200,000 babulawa ngiso emnyakeni munye.&lt;ref name=The2013&gt;{{cite journal | last=Thétiot-Laurent | first=S. A. | author2=Boissier, J. | author3=Robert, A. | author4= Meunier, B. | title=Schistosomiasis Chemotherapy | journal=Angewandte Chemie International Edition in English | date=27 June 2013 | pmid=23813602 | volume=52 | issue=31 | pages=7936–56 | doi=10.1002/anie.201208390}}&lt;/ref&gt; Ubulwelwe lobu butholakala khulu e-Afrika, kanye ne-Asia ne Sewula ye-Amerikha.&lt;ref name=WHO2014/&gt; Pheze abantu abaziingidi ezima-700, eenarheni ezima-70, bahlala lapha ubulwelwe lobu budlange khona.&lt;ref name=The2013/&gt;&lt;ref&gt;{{cite web | title=Schistosomiasis  A major public health problem | url=http://www.who.int/schistosomiasis/en | work=World Health Organization | accessdate=15 March 2014}}&lt;/ref&gt; Eenarheni zethrophiki, isichenene seengazi esibulwelwe bokuthunda iingazi sibulwelwe obuza ngemva [[kwemalariya]] obuhlangana nezinye izifo ezibangwa ziinlwanyana eziphila ngokudla ezinye iinlwana ezibanga ukuwa konotho.&lt;ref name=&quot;SCP&quot;&gt;{{Cite web | author=The Carter Center | title=Schistosomiasis Control Program | url=http://www.cartercenter.org/health/schistosomiasis/index.html | accessdate=17 July 2008}}&lt;/ref&gt; Isichenene seengazi esibulwelwe bokuthunda iingazi[[ sifakwe erherhweni lamalwelwe wethropiki angakanakwa]].&lt;ref&gt;{{cite web | title=Neglected Tropical Diseases | url=http://www.cdc.gov/globalhealth/ntd/diseases/index.html | website=cdc.gov | accessdate=28 November 2014 | date=6 June 2011}}&lt;/ref&gt;
==isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini.==
&lt;references /&gt;</text>
      <sha1>lkngzyh937yds291xzlhilxevla6ife</sha1>
    </revision>
    <revision>
      <id>2036</id>
      <parentid>2035</parentid>
      <timestamp>2016-11-08T21:18:22Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <origin>2036</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7422" sha1="djfq3yppxtuh3zgdfmmv567cch55gca" xml:space="preserve">{{Wp/nd/Infobox disease
 | name            = Isichenene seengazi esibulwelwe bokuthunda iingazi 
 | image           = Schistosomiasis in a child 2.jpg 
 | caption         = Umsana oneminyaka eli-11[[ophethwe  |kuqunjelwa kwamathumbu]]kanye[[nokuhlangahlangana komkhumbulo]]okubangwe sichenene seengazi esibulwelwe bokuthunda iingazi (Agusan del Sur, Philippines)
 | Field           = [[Infectious disease (medical specialty)|Infectious disease]]
 | pronounce       ={{IPAc-en|ˌ|ʃ|i|s|t|ə|s|ə|ˈ|m|aɪ|ə|s|ᵻ|s|,_|-|t|oʊ|-|,_|-|s|oʊ|-}}&lt;ref&gt;{{cite web |url=https://www.oxforddictionaries.com/definition/english/schistosomiasis |title=schistosomiasis - definition of schistosomiasis in English from the Oxford dictionary |publisher=[[OxfordDictionaries.com]] |access-date=2016-01-20 }}&lt;/ref&gt;
 | synonyms = ubulwelwe bokuthunda iingazi, umgomani womneke, ukuphathwa yihloko kwekatayama&lt;ref name=NHS2011&gt;{{cite web | title=Schistosomiasis (bilharzia) | url=http://www.nhs.uk/Conditions/schistosomiasis/Pages/Introduction.aspx | work=NHS Choices | accessdate=15 March 2014 | date=17 December 2011}}&lt;/ref&gt;&lt;ref&gt;{{cite web | title=Schistosomiasis | url=http://www.patient.info/doctor/schistosomiasis-pro | website=Patient.info | accessdate=11 June 2014 | date=12/2/2013}}&lt;/ref&gt;
 | DiseasesDB      =11875
|DiseasesDB_mult={{DiseasesDB2|11882}}{{DiseasesDB2|11856}}
 | ICD10           = {{Wp/nd/ICD10|B|65||b|65}} 
 | ICD9            = {{Wp/nd/ICD9|120}} 
 | OMIM            = 
 | MedlinePlus     =001321
 | eMedicineSubj=article
 | eMedicineTopic=228392
 | MeshID          = D012552
|Orphanet=1247
}}
'''isichenene seengazi esibulwelwe bokuthunda iingazi''' eyaziwa godu bona yi-snail fevere '''umgomani womneke''' yi[[ubulwelwe |beenyokana eziyingozi]] obubangwa[[sibungu|esidla nanyana yini esihlangana nakho]][[isubungu esipataleleko]]esibizwa nangokuthi[[yi-schistosome]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Imisipha [[yesinya]]nofana[[emathunjini]]zingatheleleka.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo wokobana uphethwe bulwelwe lobu[[ uzwa ubuhlungu esinyeni]],[[ uyarhuda okungapheliko]],[[ amakaka  aneengazi| ujanyelwe ziingazi]], nofana[[i-hematuria|igazi livela emthundweni]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Labo abatheleleke ngobulwelwe lobu[[obuphikelela isikhathi| isikhathi eside]]bangaba [[nemiraro yokulimala kwesibindi]], [[ ukungasebenzi kweso]], [[ ukungabelethi]], nofana[[ ikankere yesinye]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ebantwaneni[[, ingabanga|ukungakhuli kuhle]]kanye[[ nokurholophala ngokufunda|ubudisi nakuza kezefundo]].&lt;ref name=WHO2014&gt;{{cite web | title=Schistosomiasis Fact sheet N°115 | url=http://www.who.int/mediacentre/factsheets/fs115/en | work=World Health Organization | accessdate=15 March 2014| date=3 February 2014}}&lt;/ref&gt;

&lt;!-- Cause --&gt;
Ubulwelwe lobu butheleleka[[ngokuthinta nofana ukusela amanzi atsengekileko]]asele anazo iinyokanyokana lezi.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Inyokanyoka ezidla emzibeni wenye into[[ziphuma eminekeni ehlala ngaphakathi kwamanzi atsengekileko]]&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu budlange khulu eenarheni ezisathuthukako ngombana abantwana bakhona ngibo abavame ukudla emanzini adungekileko.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Abanye abantu abasengozini yokutheleleka baphathi bamaplasi, abathiyi beemfesi, kanye nabantu abasebenzisa amanzi angakahlwekeki ukuphila ngamalanga.&lt;ref name=WHO2014/&gt; Ubulwelwe lobu buhlangana nesiqhema samalwelwe i[[helminthiasis|helminth ethelelanako]].&lt;ref&gt;{{cite web | title=Chapter 3 Infectious Diseases Related To Travel | url=http://wwwnc.cdc.gov/travel/yellowbook/2014/chapter-3-infectious-diseases-related-to-travel/schistosomiasis | website=cdc.gov | accessdate=30 November 2014 | date=1 August 2013}}&lt;/ref&gt; Ukuthola umrabho wobulwelwe lobu kungenziwa ngokutjheja amaqanda wesilwane esiphila ngokudla ezinye iinlwana emthundweni nofana emakakeni womuntu.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Begodu ingaqinisekiswa ngokuthola[[ama-antibodies ]]manqophana nobulwelwe lobu egazini lomuntu.&lt;ref name=WHO2014/&gt; 

&lt;!-- Prevention and Treatment --&gt;
Iindlela zokukhandela ubulwelwe lobu kufaka hlangana ukuthuthukisa ukutholakala kwamanzi ahlwengileko begodu nokunciphisa imineke etholakala emanzini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; EEndaweni lapho ubulwelwe lobu budlange khona, imitjhoga nofana iinhlahla [[ezibizwa nge-praziquantel]]zinganikelwa kanye komnyaka esiqhemeni salabo abagulako kileyo ndawo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kwenzelwa ukwehlisa isibalo sabantu abatheleleke ngobulwelwe begodu nokwehlisa izinga lokusabalaliswa kobulwelwe lobu.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; I-Praziquantel ngenye yeenhlanhla ezinyulwe[[yi-World Health Organization-iHlangano yeePhasi yezamaPilo]] (WHO) kilabo esele kwaziwa bona bangenwe bulwelwe lobu.&lt;ref name=WHO2014/&gt; 

&lt;!-- Epidemiology --&gt;
Isichenene seengazi esibulwelwe bokuthunda iingazi siphathe abantu ababalelwa eengidigidini ezima-210 wabantu iphasi zombelele ngomnayaka ka-2012.&lt;ref name=Fen2012&gt;{{cite journal | last=Fenwick | first=A | title=The global burden of neglected tropical diseases.| journal=Public Health | date=Mar 2012 | volume=126 | issue=3 | pages=233–6 | pmid=22325616|doi=10.1016/j.puhe.2011.11.015}}&lt;/ref&gt; Isibalo sabantu esibalelwa ku-12 000&lt;ref name=Loz2012&gt;{{cite journal | last=Lozano | first=R. | title=Global and regional mortality from 235 causes of death for 20 age groups in 1990 and 2010: a systematic analysis for the Global Burden of Disease Study 2010 | journal=Lancet | date=15 December 2012 | volume=380 | issue=9859 | pages=2095–128 | pmid=23245604 | doi=10.1016/S0140-6736(12)61728-0 | last2=Naghavi | first2=M. | last3=Foreman | first3=K. | last4=Lim | first4=S. | last5=Shibuya | first5=K. | last6=Aboyans | first6=V. | last7=Abraham | first7=J. | last8=Adair | first8=T. | last9=Aggarwal | first9=R. | displayauthors=8}}&lt;/ref&gt; ukufika ku 200,000 babulawa ngiso emnyakeni munye.&lt;ref name=The2013&gt;{{cite journal | last=Thétiot-Laurent | first=S. A. | author2=Boissier, J. | author3=Robert, A. | author4= Meunier, B. | title=Schistosomiasis Chemotherapy | journal=Angewandte Chemie International Edition in English | date=27 June 2013 | pmid=23813602 | volume=52 | issue=31 | pages=7936–56 | doi=10.1002/anie.201208390}}&lt;/ref&gt; Ubulwelwe lobu butholakala khulu e-Afrika, kanye ne-Asia ne Sewula ye-Amerikha.&lt;ref name=WHO2014/&gt; Pheze abantu abaziingidi ezima-700, eenarheni ezima-70, bahlala lapha ubulwelwe lobu budlange khona.&lt;ref name=The2013/&gt;&lt;ref&gt;{{cite web | title=Schistosomiasis  A major public health problem | url=http://www.who.int/schistosomiasis/en | work=World Health Organization | accessdate=15 March 2014}}&lt;/ref&gt; Eenarheni zethrophiki, isichenene seengazi esibulwelwe bokuthunda iingazi sibulwelwe obuza ngemva [[kwemalariya]] obuhlangana nezinye izifo ezibangwa ziinlwanyana eziphila ngokudla ezinye iinlwana ezibanga ukuwa konotho.&lt;ref name=&quot;SCP&quot;&gt;{{Cite web | author=The Carter Center | title=Schistosomiasis Control Program | url=http://www.cartercenter.org/health/schistosomiasis/index.html | accessdate=17 July 2008}}&lt;/ref&gt; Isichenene seengazi esibulwelwe bokuthunda iingazi[[ sifakwe erherhweni lamalwelwe wethropiki angakanakwa]].&lt;ref&gt;{{cite web | title=Neglected Tropical Diseases | url=http://www.cdc.gov/globalhealth/ntd/diseases/index.html | website=cdc.gov | accessdate=28 November 2014 | date=6 June 2011}}&lt;/ref&gt;
==isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini.==
&lt;references /&gt;</text>
      <sha1>djfq3yppxtuh3zgdfmmv567cch55gca</sha1>
    </revision>
    <revision>
      <id>2037</id>
      <parentid>2036</parentid>
      <timestamp>2016-11-09T15:50:12Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <origin>2037</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7488" sha1="s6dfxhuydjvf6mkkxnmqq1ppxjgb4f2" xml:space="preserve">{{Wp/nd/Infobox disease
 | name            = Isichenene seengazi esibulwelwe bokuthunda iingazi 
 | image           = Schistosomiasis in a child 2.jpg 
 | caption         = Umsana oneminyaka eli-11[[ophethwe  |kuqunjelwa kwamathumbu]]kanye[[nokuhlangahlangana komkhumbulo]]okubangwe sichenene seengazi esibulwelwe bokuthunda iingazi (Agusan del Sur, Philippines)
 | Field           = [[Infectious disease (medical specialty)|Infectious disease]]
 | pronounce       ={{IPAc-en|ˌ|ʃ|i|s|t|ə|s|ə|ˈ|m|aɪ|ə|s|ᵻ|s|,_|-|t|oʊ|-|,_|-|s|oʊ|-}}&lt;ref&gt;{{Wp/nd/cite web |url=https://www.oxforddictionaries.com/definition/english/schistosomiasis |title=schistosomiasis - definition of schistosomiasis in English from the Oxford dictionary |publisher=[[OxfordDictionaries.com]] |access-date=2016-01-20 }}&lt;/ref&gt;
 | synonyms = ubulwelwe bokuthunda iingazi, umgomani womneke, ukuphathwa yihloko kwekatayama&lt;ref name=NHS2011&gt;{{Wp/nd/cite web | title=Schistosomiasis (bilharzia) | url=http://www.nhs.uk/Conditions/schistosomiasis/Pages/Introduction.aspx | work=NHS Choices | accessdate=15 March 2014 | date=17 December 2011}}&lt;/ref&gt;&lt;ref&gt;{{Wp/nd/cite web | title=Schistosomiasis | url=http://www.patient.info/doctor/schistosomiasis-pro | website=Patient.info | accessdate=11 June 2014 | date=12/2/2013}}&lt;/ref&gt;
 | DiseasesDB      =11875
|DiseasesDB_mult={{DiseasesDB2|11882}}{{DiseasesDB2|11856}}
 | ICD10           = {{Wp/nd/ICD10|B|65||b|65}} 
 | ICD9            = {{Wp/nd/ICD9|120}} 
 | OMIM            = 
 | MedlinePlus     =001321
 | eMedicineSubj=article
 | eMedicineTopic=228392
 | MeshID          = D012552
|Orphanet=1247
}}
'''isichenene seengazi esibulwelwe bokuthunda iingazi''' eyaziwa godu bona yi-snail fevere '''umgomani womneke''' yi[[ubulwelwe |beenyokana eziyingozi]] obubangwa[[sibungu|esidla nanyana yini esihlangana nakho]][[isubungu esipataleleko]]esibizwa nangokuthi[[yi-schistosome]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Imisipha [[yesinya]]nofana[[emathunjini]]zingatheleleka.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo wokobana uphethwe bulwelwe lobu[[ uzwa ubuhlungu esinyeni]],[[ uyarhuda okungapheliko]],[[ amakaka  aneengazi| ujanyelwe ziingazi]], nofana[[i-hematuria|igazi livela emthundweni]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Labo abatheleleke ngobulwelwe lobu[[obuphikelela isikhathi| isikhathi eside]]bangaba [[nemiraro yokulimala kwesibindi]], [[ ukungasebenzi kweso]], [[ ukungabelethi]], nofana[[ ikankere yesinye]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ebantwaneni[[, ingabanga|ukungakhuli kuhle]]kanye[[ nokurholophala ngokufunda|ubudisi nakuza kezefundo]].&lt;ref name=WHO2014&gt;{{Wp/nd/cite web | title=Schistosomiasis Fact sheet N°115 | url=http://www.who.int/mediacentre/factsheets/fs115/en | work=World Health Organization | accessdate=15 March 2014| date=3 February 2014}}&lt;/ref&gt;

&lt;!-- Cause --&gt;
Ubulwelwe lobu butheleleka[[ngokuthinta nofana ukusela amanzi atsengekileko]]asele anazo iinyokanyokana lezi.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Inyokanyoka ezidla emzibeni wenye into[[ziphuma eminekeni ehlala ngaphakathi kwamanzi atsengekileko]]&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu budlange khulu eenarheni ezisathuthukako ngombana abantwana bakhona ngibo abavame ukudla emanzini adungekileko.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Abanye abantu abasengozini yokutheleleka baphathi bamaplasi, abathiyi beemfesi, kanye nabantu abasebenzisa amanzi angakahlwekeki ukuphila ngamalanga.&lt;ref name=WHO2014/&gt; Ubulwelwe lobu buhlangana nesiqhema samalwelwe i[[helminthiasis|helminth ethelelanako]].&lt;ref&gt;{{Wp/nd/cite web | title=Chapter 3 Infectious Diseases Related To Travel | url=http://wwwnc.cdc.gov/travel/yellowbook/2014/chapter-3-infectious-diseases-related-to-travel/schistosomiasis | website=cdc.gov | accessdate=30 November 2014 | date=1 August 2013}}&lt;/ref&gt; Ukuthola umrabho wobulwelwe lobu kungenziwa ngokutjheja amaqanda wesilwane esiphila ngokudla ezinye iinlwana emthundweni nofana emakakeni womuntu.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Begodu ingaqinisekiswa ngokuthola[[ama-antibodies ]]manqophana nobulwelwe lobu egazini lomuntu.&lt;ref name=WHO2014/&gt; 

&lt;!-- Prevention and Treatment --&gt;
Iindlela zokukhandela ubulwelwe lobu kufaka hlangana ukuthuthukisa ukutholakala kwamanzi ahlwengileko begodu nokunciphisa imineke etholakala emanzini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; EEndaweni lapho ubulwelwe lobu budlange khona, imitjhoga nofana iinhlahla [[ezibizwa nge-praziquantel]]zinganikelwa kanye komnyaka esiqhemeni salabo abagulako kileyo ndawo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kwenzelwa ukwehlisa isibalo sabantu abatheleleke ngobulwelwe begodu nokwehlisa izinga lokusabalaliswa kobulwelwe lobu.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; I-Praziquantel ngenye yeenhlanhla ezinyulwe[[yi-World Health Organization-iHlangano yeePhasi yezamaPilo]] (WHO) kilabo esele kwaziwa bona bangenwe bulwelwe lobu.&lt;ref name=WHO2014/&gt; 

&lt;!-- Epidemiology --&gt;
Isichenene seengazi esibulwelwe bokuthunda iingazi siphathe abantu ababalelwa eengidigidini ezima-210 wabantu iphasi zombelele ngomnayaka ka-2012.&lt;ref name=Fen2012&gt;{{Wp/nd/cite journal | last=Fenwick | first=A | title=The global burden of neglected tropical diseases.| journal=Public Health | date=Mar 2012 | volume=126 | issue=3 | pages=233–6 | pmid=22325616|doi=10.1016/j.puhe.2011.11.015}}&lt;/ref&gt; Isibalo sabantu esibalelwa ku-12 000&lt;ref name=Loz2012&gt;{{Wp/nd/cite journal | last=Lozano | first=R. | title=Global and regional mortality from 235 causes of death for 20 age groups in 1990 and 2010: a systematic analysis for the Global Burden of Disease Study 2010 | journal=Lancet | date=15 December 2012 | volume=380 | issue=9859 | pages=2095–128 | pmid=23245604 | doi=10.1016/S0140-6736(12)61728-0 | last2=Naghavi | first2=M. | last3=Foreman | first3=K. | last4=Lim | first4=S. | last5=Shibuya | first5=K. | last6=Aboyans | first6=V. | last7=Abraham | first7=J. | last8=Adair | first8=T. | last9=Aggarwal | first9=R. | displayauthors=8}}&lt;/ref&gt; ukufika ku 200,000 babulawa ngiso emnyakeni munye.&lt;ref name=The2013&gt;{{Wp/nd/cite journal | last=Thétiot-Laurent | first=S. A. | author2=Boissier, J. | author3=Robert, A. | author4= Meunier, B. | title=Schistosomiasis Chemotherapy | journal=Angewandte Chemie International Edition in English | date=27 June 2013 | pmid=23813602 | volume=52 | issue=31 | pages=7936–56 | doi=10.1002/anie.201208390}}&lt;/ref&gt; Ubulwelwe lobu butholakala khulu e-Afrika, kanye ne-Asia ne Sewula ye-Amerikha.&lt;ref name=WHO2014/&gt; Pheze abantu abaziingidi ezima-700, eenarheni ezima-70, bahlala lapha ubulwelwe lobu budlange khona.&lt;ref name=The2013/&gt;&lt;ref&gt;{{Wp/nd/cite web | title=Schistosomiasis  A major public health problem | url=http://www.who.int/schistosomiasis/en | work=World Health Organization | accessdate=15 March 2014}}&lt;/ref&gt; Eenarheni zethrophiki, isichenene seengazi esibulwelwe bokuthunda iingazi sibulwelwe obuza ngemva [[kwemalariya]] obuhlangana nezinye izifo ezibangwa ziinlwanyana eziphila ngokudla ezinye iinlwana ezibanga ukuwa konotho.&lt;ref name=&quot;SCP&quot;&gt;{{Wp/nd/cite web | author=The Carter Center | title=Schistosomiasis Control Program | url=http://www.cartercenter.org/health/schistosomiasis/index.html | accessdate=17 July 2008}}&lt;/ref&gt; Isichenene seengazi esibulwelwe bokuthunda iingazi[[ sifakwe erherhweni lamalwelwe wethropiki angakanakwa]].&lt;ref&gt;{{Wp/nd/cite web | title=Neglected Tropical Diseases | url=http://www.cdc.gov/globalhealth/ntd/diseases/index.html | website=cdc.gov | accessdate=28 November 2014 | date=6 June 2011}}&lt;/ref&gt;
==isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini.==
&lt;references /&gt;</text>
      <sha1>s6dfxhuydjvf6mkkxnmqq1ppxjgb4f2</sha1>
    </revision>
    <revision>
      <id>2038</id>
      <parentid>2037</parentid>
      <timestamp>2022-05-13T22:11:51Z</timestamp>
      <contributor>
        <username>incubator&gt;1234qwer1234qwer4</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>+[[Category:Wp/nd]]; [[toolforge:quickcategories/batch/4630/|QuickCategories batch #4630]]</comment>
      <origin>2038</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7507" sha1="nrmggb7w3ezkh8rljrk8mrshl5jld1h" xml:space="preserve">{{Wp/nd/Infobox disease
 | name            = Isichenene seengazi esibulwelwe bokuthunda iingazi 
 | image           = Schistosomiasis in a child 2.jpg 
 | caption         = Umsana oneminyaka eli-11[[ophethwe  |kuqunjelwa kwamathumbu]]kanye[[nokuhlangahlangana komkhumbulo]]okubangwe sichenene seengazi esibulwelwe bokuthunda iingazi (Agusan del Sur, Philippines)
 | Field           = [[Infectious disease (medical specialty)|Infectious disease]]
 | pronounce       ={{IPAc-en|ˌ|ʃ|i|s|t|ə|s|ə|ˈ|m|aɪ|ə|s|ᵻ|s|,_|-|t|oʊ|-|,_|-|s|oʊ|-}}&lt;ref&gt;{{Wp/nd/cite web |url=https://www.oxforddictionaries.com/definition/english/schistosomiasis |title=schistosomiasis - definition of schistosomiasis in English from the Oxford dictionary |publisher=[[OxfordDictionaries.com]] |access-date=2016-01-20 }}&lt;/ref&gt;
 | synonyms = ubulwelwe bokuthunda iingazi, umgomani womneke, ukuphathwa yihloko kwekatayama&lt;ref name=NHS2011&gt;{{Wp/nd/cite web | title=Schistosomiasis (bilharzia) | url=http://www.nhs.uk/Conditions/schistosomiasis/Pages/Introduction.aspx | work=NHS Choices | accessdate=15 March 2014 | date=17 December 2011}}&lt;/ref&gt;&lt;ref&gt;{{Wp/nd/cite web | title=Schistosomiasis | url=http://www.patient.info/doctor/schistosomiasis-pro | website=Patient.info | accessdate=11 June 2014 | date=12/2/2013}}&lt;/ref&gt;
 | DiseasesDB      =11875
|DiseasesDB_mult={{DiseasesDB2|11882}}{{DiseasesDB2|11856}}
 | ICD10           = {{Wp/nd/ICD10|B|65||b|65}} 
 | ICD9            = {{Wp/nd/ICD9|120}} 
 | OMIM            = 
 | MedlinePlus     =001321
 | eMedicineSubj=article
 | eMedicineTopic=228392
 | MeshID          = D012552
|Orphanet=1247
}}
'''isichenene seengazi esibulwelwe bokuthunda iingazi''' eyaziwa godu bona yi-snail fevere '''umgomani womneke''' yi[[ubulwelwe |beenyokana eziyingozi]] obubangwa[[sibungu|esidla nanyana yini esihlangana nakho]][[isubungu esipataleleko]]esibizwa nangokuthi[[yi-schistosome]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Imisipha [[yesinya]]nofana[[emathunjini]]zingatheleleka.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo wokobana uphethwe bulwelwe lobu[[ uzwa ubuhlungu esinyeni]],[[ uyarhuda okungapheliko]],[[ amakaka  aneengazi| ujanyelwe ziingazi]], nofana[[i-hematuria|igazi livela emthundweni]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Labo abatheleleke ngobulwelwe lobu[[obuphikelela isikhathi| isikhathi eside]]bangaba [[nemiraro yokulimala kwesibindi]], [[ ukungasebenzi kweso]], [[ ukungabelethi]], nofana[[ ikankere yesinye]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ebantwaneni[[, ingabanga|ukungakhuli kuhle]]kanye[[ nokurholophala ngokufunda|ubudisi nakuza kezefundo]].&lt;ref name=WHO2014&gt;{{Wp/nd/cite web | title=Schistosomiasis Fact sheet N°115 | url=http://www.who.int/mediacentre/factsheets/fs115/en | work=World Health Organization | accessdate=15 March 2014| date=3 February 2014}}&lt;/ref&gt;

&lt;!-- Cause --&gt;
Ubulwelwe lobu butheleleka[[ngokuthinta nofana ukusela amanzi atsengekileko]]asele anazo iinyokanyokana lezi.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Inyokanyoka ezidla emzibeni wenye into[[ziphuma eminekeni ehlala ngaphakathi kwamanzi atsengekileko]]&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu budlange khulu eenarheni ezisathuthukako ngombana abantwana bakhona ngibo abavame ukudla emanzini adungekileko.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Abanye abantu abasengozini yokutheleleka baphathi bamaplasi, abathiyi beemfesi, kanye nabantu abasebenzisa amanzi angakahlwekeki ukuphila ngamalanga.&lt;ref name=WHO2014/&gt; Ubulwelwe lobu buhlangana nesiqhema samalwelwe i[[helminthiasis|helminth ethelelanako]].&lt;ref&gt;{{Wp/nd/cite web | title=Chapter 3 Infectious Diseases Related To Travel | url=http://wwwnc.cdc.gov/travel/yellowbook/2014/chapter-3-infectious-diseases-related-to-travel/schistosomiasis | website=cdc.gov | accessdate=30 November 2014 | date=1 August 2013}}&lt;/ref&gt; Ukuthola umrabho wobulwelwe lobu kungenziwa ngokutjheja amaqanda wesilwane esiphila ngokudla ezinye iinlwana emthundweni nofana emakakeni womuntu.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Begodu ingaqinisekiswa ngokuthola[[ama-antibodies ]]manqophana nobulwelwe lobu egazini lomuntu.&lt;ref name=WHO2014/&gt; 

&lt;!-- Prevention and Treatment --&gt;
Iindlela zokukhandela ubulwelwe lobu kufaka hlangana ukuthuthukisa ukutholakala kwamanzi ahlwengileko begodu nokunciphisa imineke etholakala emanzini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; EEndaweni lapho ubulwelwe lobu budlange khona, imitjhoga nofana iinhlahla [[ezibizwa nge-praziquantel]]zinganikelwa kanye komnyaka esiqhemeni salabo abagulako kileyo ndawo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kwenzelwa ukwehlisa isibalo sabantu abatheleleke ngobulwelwe begodu nokwehlisa izinga lokusabalaliswa kobulwelwe lobu.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; I-Praziquantel ngenye yeenhlanhla ezinyulwe[[yi-World Health Organization-iHlangano yeePhasi yezamaPilo]] (WHO) kilabo esele kwaziwa bona bangenwe bulwelwe lobu.&lt;ref name=WHO2014/&gt; 

&lt;!-- Epidemiology --&gt;
Isichenene seengazi esibulwelwe bokuthunda iingazi siphathe abantu ababalelwa eengidigidini ezima-210 wabantu iphasi zombelele ngomnayaka ka-2012.&lt;ref name=Fen2012&gt;{{Wp/nd/cite journal | last=Fenwick | first=A | title=The global burden of neglected tropical diseases.| journal=Public Health | date=Mar 2012 | volume=126 | issue=3 | pages=233–6 | pmid=22325616|doi=10.1016/j.puhe.2011.11.015}}&lt;/ref&gt; Isibalo sabantu esibalelwa ku-12 000&lt;ref name=Loz2012&gt;{{Wp/nd/cite journal | last=Lozano | first=R. | title=Global and regional mortality from 235 causes of death for 20 age groups in 1990 and 2010: a systematic analysis for the Global Burden of Disease Study 2010 | journal=Lancet | date=15 December 2012 | volume=380 | issue=9859 | pages=2095–128 | pmid=23245604 | doi=10.1016/S0140-6736(12)61728-0 | last2=Naghavi | first2=M. | last3=Foreman | first3=K. | last4=Lim | first4=S. | last5=Shibuya | first5=K. | last6=Aboyans | first6=V. | last7=Abraham | first7=J. | last8=Adair | first8=T. | last9=Aggarwal | first9=R. | displayauthors=8}}&lt;/ref&gt; ukufika ku 200,000 babulawa ngiso emnyakeni munye.&lt;ref name=The2013&gt;{{Wp/nd/cite journal | last=Thétiot-Laurent | first=S. A. | author2=Boissier, J. | author3=Robert, A. | author4= Meunier, B. | title=Schistosomiasis Chemotherapy | journal=Angewandte Chemie International Edition in English | date=27 June 2013 | pmid=23813602 | volume=52 | issue=31 | pages=7936–56 | doi=10.1002/anie.201208390}}&lt;/ref&gt; Ubulwelwe lobu butholakala khulu e-Afrika, kanye ne-Asia ne Sewula ye-Amerikha.&lt;ref name=WHO2014/&gt; Pheze abantu abaziingidi ezima-700, eenarheni ezima-70, bahlala lapha ubulwelwe lobu budlange khona.&lt;ref name=The2013/&gt;&lt;ref&gt;{{Wp/nd/cite web | title=Schistosomiasis  A major public health problem | url=http://www.who.int/schistosomiasis/en | work=World Health Organization | accessdate=15 March 2014}}&lt;/ref&gt; Eenarheni zethrophiki, isichenene seengazi esibulwelwe bokuthunda iingazi sibulwelwe obuza ngemva [[kwemalariya]] obuhlangana nezinye izifo ezibangwa ziinlwanyana eziphila ngokudla ezinye iinlwana ezibanga ukuwa konotho.&lt;ref name=&quot;SCP&quot;&gt;{{Wp/nd/cite web | author=The Carter Center | title=Schistosomiasis Control Program | url=http://www.cartercenter.org/health/schistosomiasis/index.html | accessdate=17 July 2008}}&lt;/ref&gt; Isichenene seengazi esibulwelwe bokuthunda iingazi[[ sifakwe erherhweni lamalwelwe wethropiki angakanakwa]].&lt;ref&gt;{{Wp/nd/cite web | title=Neglected Tropical Diseases | url=http://www.cdc.gov/globalhealth/ntd/diseases/index.html | website=cdc.gov | accessdate=28 November 2014 | date=6 June 2011}}&lt;/ref&gt;
==isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini.==
&lt;references /&gt;
[[Category:Wp/nd]]</text>
      <sha1>nrmggb7w3ezkh8rljrk8mrshl5jld1h</sha1>
    </revision>
    <revision>
      <id>2039</id>
      <parentid>2038</parentid>
      <timestamp>2024-11-18T17:49:23Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <minor />
      <comment>6 revisions imported from [[:incubator:Wp/nd/Isichenene_seengazi_esibulwelwe_bokuthunda_iingazi]]</comment>
      <origin>2038</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7507" sha1="nrmggb7w3ezkh8rljrk8mrshl5jld1h" xml:space="preserve">{{Wp/nd/Infobox disease
 | name            = Isichenene seengazi esibulwelwe bokuthunda iingazi 
 | image           = Schistosomiasis in a child 2.jpg 
 | caption         = Umsana oneminyaka eli-11[[ophethwe  |kuqunjelwa kwamathumbu]]kanye[[nokuhlangahlangana komkhumbulo]]okubangwe sichenene seengazi esibulwelwe bokuthunda iingazi (Agusan del Sur, Philippines)
 | Field           = [[Infectious disease (medical specialty)|Infectious disease]]
 | pronounce       ={{IPAc-en|ˌ|ʃ|i|s|t|ə|s|ə|ˈ|m|aɪ|ə|s|ᵻ|s|,_|-|t|oʊ|-|,_|-|s|oʊ|-}}&lt;ref&gt;{{Wp/nd/cite web |url=https://www.oxforddictionaries.com/definition/english/schistosomiasis |title=schistosomiasis - definition of schistosomiasis in English from the Oxford dictionary |publisher=[[OxfordDictionaries.com]] |access-date=2016-01-20 }}&lt;/ref&gt;
 | synonyms = ubulwelwe bokuthunda iingazi, umgomani womneke, ukuphathwa yihloko kwekatayama&lt;ref name=NHS2011&gt;{{Wp/nd/cite web | title=Schistosomiasis (bilharzia) | url=http://www.nhs.uk/Conditions/schistosomiasis/Pages/Introduction.aspx | work=NHS Choices | accessdate=15 March 2014 | date=17 December 2011}}&lt;/ref&gt;&lt;ref&gt;{{Wp/nd/cite web | title=Schistosomiasis | url=http://www.patient.info/doctor/schistosomiasis-pro | website=Patient.info | accessdate=11 June 2014 | date=12/2/2013}}&lt;/ref&gt;
 | DiseasesDB      =11875
|DiseasesDB_mult={{DiseasesDB2|11882}}{{DiseasesDB2|11856}}
 | ICD10           = {{Wp/nd/ICD10|B|65||b|65}} 
 | ICD9            = {{Wp/nd/ICD9|120}} 
 | OMIM            = 
 | MedlinePlus     =001321
 | eMedicineSubj=article
 | eMedicineTopic=228392
 | MeshID          = D012552
|Orphanet=1247
}}
'''isichenene seengazi esibulwelwe bokuthunda iingazi''' eyaziwa godu bona yi-snail fevere '''umgomani womneke''' yi[[ubulwelwe |beenyokana eziyingozi]] obubangwa[[sibungu|esidla nanyana yini esihlangana nakho]][[isubungu esipataleleko]]esibizwa nangokuthi[[yi-schistosome]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Imisipha [[yesinya]]nofana[[emathunjini]]zingatheleleka.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo wokobana uphethwe bulwelwe lobu[[ uzwa ubuhlungu esinyeni]],[[ uyarhuda okungapheliko]],[[ amakaka  aneengazi| ujanyelwe ziingazi]], nofana[[i-hematuria|igazi livela emthundweni]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Labo abatheleleke ngobulwelwe lobu[[obuphikelela isikhathi| isikhathi eside]]bangaba [[nemiraro yokulimala kwesibindi]], [[ ukungasebenzi kweso]], [[ ukungabelethi]], nofana[[ ikankere yesinye]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ebantwaneni[[, ingabanga|ukungakhuli kuhle]]kanye[[ nokurholophala ngokufunda|ubudisi nakuza kezefundo]].&lt;ref name=WHO2014&gt;{{Wp/nd/cite web | title=Schistosomiasis Fact sheet N°115 | url=http://www.who.int/mediacentre/factsheets/fs115/en | work=World Health Organization | accessdate=15 March 2014| date=3 February 2014}}&lt;/ref&gt;

&lt;!-- Cause --&gt;
Ubulwelwe lobu butheleleka[[ngokuthinta nofana ukusela amanzi atsengekileko]]asele anazo iinyokanyokana lezi.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Inyokanyoka ezidla emzibeni wenye into[[ziphuma eminekeni ehlala ngaphakathi kwamanzi atsengekileko]]&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu budlange khulu eenarheni ezisathuthukako ngombana abantwana bakhona ngibo abavame ukudla emanzini adungekileko.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Abanye abantu abasengozini yokutheleleka baphathi bamaplasi, abathiyi beemfesi, kanye nabantu abasebenzisa amanzi angakahlwekeki ukuphila ngamalanga.&lt;ref name=WHO2014/&gt; Ubulwelwe lobu buhlangana nesiqhema samalwelwe i[[helminthiasis|helminth ethelelanako]].&lt;ref&gt;{{Wp/nd/cite web | title=Chapter 3 Infectious Diseases Related To Travel | url=http://wwwnc.cdc.gov/travel/yellowbook/2014/chapter-3-infectious-diseases-related-to-travel/schistosomiasis | website=cdc.gov | accessdate=30 November 2014 | date=1 August 2013}}&lt;/ref&gt; Ukuthola umrabho wobulwelwe lobu kungenziwa ngokutjheja amaqanda wesilwane esiphila ngokudla ezinye iinlwana emthundweni nofana emakakeni womuntu.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Begodu ingaqinisekiswa ngokuthola[[ama-antibodies ]]manqophana nobulwelwe lobu egazini lomuntu.&lt;ref name=WHO2014/&gt; 

&lt;!-- Prevention and Treatment --&gt;
Iindlela zokukhandela ubulwelwe lobu kufaka hlangana ukuthuthukisa ukutholakala kwamanzi ahlwengileko begodu nokunciphisa imineke etholakala emanzini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; EEndaweni lapho ubulwelwe lobu budlange khona, imitjhoga nofana iinhlahla [[ezibizwa nge-praziquantel]]zinganikelwa kanye komnyaka esiqhemeni salabo abagulako kileyo ndawo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kwenzelwa ukwehlisa isibalo sabantu abatheleleke ngobulwelwe begodu nokwehlisa izinga lokusabalaliswa kobulwelwe lobu.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; I-Praziquantel ngenye yeenhlanhla ezinyulwe[[yi-World Health Organization-iHlangano yeePhasi yezamaPilo]] (WHO) kilabo esele kwaziwa bona bangenwe bulwelwe lobu.&lt;ref name=WHO2014/&gt; 

&lt;!-- Epidemiology --&gt;
Isichenene seengazi esibulwelwe bokuthunda iingazi siphathe abantu ababalelwa eengidigidini ezima-210 wabantu iphasi zombelele ngomnayaka ka-2012.&lt;ref name=Fen2012&gt;{{Wp/nd/cite journal | last=Fenwick | first=A | title=The global burden of neglected tropical diseases.| journal=Public Health | date=Mar 2012 | volume=126 | issue=3 | pages=233–6 | pmid=22325616|doi=10.1016/j.puhe.2011.11.015}}&lt;/ref&gt; Isibalo sabantu esibalelwa ku-12 000&lt;ref name=Loz2012&gt;{{Wp/nd/cite journal | last=Lozano | first=R. | title=Global and regional mortality from 235 causes of death for 20 age groups in 1990 and 2010: a systematic analysis for the Global Burden of Disease Study 2010 | journal=Lancet | date=15 December 2012 | volume=380 | issue=9859 | pages=2095–128 | pmid=23245604 | doi=10.1016/S0140-6736(12)61728-0 | last2=Naghavi | first2=M. | last3=Foreman | first3=K. | last4=Lim | first4=S. | last5=Shibuya | first5=K. | last6=Aboyans | first6=V. | last7=Abraham | first7=J. | last8=Adair | first8=T. | last9=Aggarwal | first9=R. | displayauthors=8}}&lt;/ref&gt; ukufika ku 200,000 babulawa ngiso emnyakeni munye.&lt;ref name=The2013&gt;{{Wp/nd/cite journal | last=Thétiot-Laurent | first=S. A. | author2=Boissier, J. | author3=Robert, A. | author4= Meunier, B. | title=Schistosomiasis Chemotherapy | journal=Angewandte Chemie International Edition in English | date=27 June 2013 | pmid=23813602 | volume=52 | issue=31 | pages=7936–56 | doi=10.1002/anie.201208390}}&lt;/ref&gt; Ubulwelwe lobu butholakala khulu e-Afrika, kanye ne-Asia ne Sewula ye-Amerikha.&lt;ref name=WHO2014/&gt; Pheze abantu abaziingidi ezima-700, eenarheni ezima-70, bahlala lapha ubulwelwe lobu budlange khona.&lt;ref name=The2013/&gt;&lt;ref&gt;{{Wp/nd/cite web | title=Schistosomiasis  A major public health problem | url=http://www.who.int/schistosomiasis/en | work=World Health Organization | accessdate=15 March 2014}}&lt;/ref&gt; Eenarheni zethrophiki, isichenene seengazi esibulwelwe bokuthunda iingazi sibulwelwe obuza ngemva [[kwemalariya]] obuhlangana nezinye izifo ezibangwa ziinlwanyana eziphila ngokudla ezinye iinlwana ezibanga ukuwa konotho.&lt;ref name=&quot;SCP&quot;&gt;{{Wp/nd/cite web | author=The Carter Center | title=Schistosomiasis Control Program | url=http://www.cartercenter.org/health/schistosomiasis/index.html | accessdate=17 July 2008}}&lt;/ref&gt; Isichenene seengazi esibulwelwe bokuthunda iingazi[[ sifakwe erherhweni lamalwelwe wethropiki angakanakwa]].&lt;ref&gt;{{Wp/nd/cite web | title=Neglected Tropical Diseases | url=http://www.cdc.gov/globalhealth/ntd/diseases/index.html | website=cdc.gov | accessdate=28 November 2014 | date=6 June 2011}}&lt;/ref&gt;
==isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini.==
&lt;references /&gt;
[[Category:Wp/nd]]</text>
      <sha1>nrmggb7w3ezkh8rljrk8mrshl5jld1h</sha1>
    </revision>
    <revision>
      <id>2040</id>
      <parentid>2039</parentid>
      <timestamp>2024-11-18T17:49:43Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <minor />
      <comment>Amire80 moved page [[Wp/nd/Isichenene seengazi esibulwelwe bokuthunda iingazi]] to [[Isichenene seengazi esibulwelwe bokuthunda iingazi]]</comment>
      <origin>2038</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7507" sha1="nrmggb7w3ezkh8rljrk8mrshl5jld1h" xml:space="preserve">{{Wp/nd/Infobox disease
 | name            = Isichenene seengazi esibulwelwe bokuthunda iingazi 
 | image           = Schistosomiasis in a child 2.jpg 
 | caption         = Umsana oneminyaka eli-11[[ophethwe  |kuqunjelwa kwamathumbu]]kanye[[nokuhlangahlangana komkhumbulo]]okubangwe sichenene seengazi esibulwelwe bokuthunda iingazi (Agusan del Sur, Philippines)
 | Field           = [[Infectious disease (medical specialty)|Infectious disease]]
 | pronounce       ={{IPAc-en|ˌ|ʃ|i|s|t|ə|s|ə|ˈ|m|aɪ|ə|s|ᵻ|s|,_|-|t|oʊ|-|,_|-|s|oʊ|-}}&lt;ref&gt;{{Wp/nd/cite web |url=https://www.oxforddictionaries.com/definition/english/schistosomiasis |title=schistosomiasis - definition of schistosomiasis in English from the Oxford dictionary |publisher=[[OxfordDictionaries.com]] |access-date=2016-01-20 }}&lt;/ref&gt;
 | synonyms = ubulwelwe bokuthunda iingazi, umgomani womneke, ukuphathwa yihloko kwekatayama&lt;ref name=NHS2011&gt;{{Wp/nd/cite web | title=Schistosomiasis (bilharzia) | url=http://www.nhs.uk/Conditions/schistosomiasis/Pages/Introduction.aspx | work=NHS Choices | accessdate=15 March 2014 | date=17 December 2011}}&lt;/ref&gt;&lt;ref&gt;{{Wp/nd/cite web | title=Schistosomiasis | url=http://www.patient.info/doctor/schistosomiasis-pro | website=Patient.info | accessdate=11 June 2014 | date=12/2/2013}}&lt;/ref&gt;
 | DiseasesDB      =11875
|DiseasesDB_mult={{DiseasesDB2|11882}}{{DiseasesDB2|11856}}
 | ICD10           = {{Wp/nd/ICD10|B|65||b|65}} 
 | ICD9            = {{Wp/nd/ICD9|120}} 
 | OMIM            = 
 | MedlinePlus     =001321
 | eMedicineSubj=article
 | eMedicineTopic=228392
 | MeshID          = D012552
|Orphanet=1247
}}
'''isichenene seengazi esibulwelwe bokuthunda iingazi''' eyaziwa godu bona yi-snail fevere '''umgomani womneke''' yi[[ubulwelwe |beenyokana eziyingozi]] obubangwa[[sibungu|esidla nanyana yini esihlangana nakho]][[isubungu esipataleleko]]esibizwa nangokuthi[[yi-schistosome]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Imisipha [[yesinya]]nofana[[emathunjini]]zingatheleleka.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Amatshwayo wokobana uphethwe bulwelwe lobu[[ uzwa ubuhlungu esinyeni]],[[ uyarhuda okungapheliko]],[[ amakaka  aneengazi| ujanyelwe ziingazi]], nofana[[i-hematuria|igazi livela emthundweni]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Labo abatheleleke ngobulwelwe lobu[[obuphikelela isikhathi| isikhathi eside]]bangaba [[nemiraro yokulimala kwesibindi]], [[ ukungasebenzi kweso]], [[ ukungabelethi]], nofana[[ ikankere yesinye]].&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ebantwaneni[[, ingabanga|ukungakhuli kuhle]]kanye[[ nokurholophala ngokufunda|ubudisi nakuza kezefundo]].&lt;ref name=WHO2014&gt;{{Wp/nd/cite web | title=Schistosomiasis Fact sheet N°115 | url=http://www.who.int/mediacentre/factsheets/fs115/en | work=World Health Organization | accessdate=15 March 2014| date=3 February 2014}}&lt;/ref&gt;

&lt;!-- Cause --&gt;
Ubulwelwe lobu butheleleka[[ngokuthinta nofana ukusela amanzi atsengekileko]]asele anazo iinyokanyokana lezi.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Inyokanyoka ezidla emzibeni wenye into[[ziphuma eminekeni ehlala ngaphakathi kwamanzi atsengekileko]]&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Ubulwelwe lobu budlange khulu eenarheni ezisathuthukako ngombana abantwana bakhona ngibo abavame ukudla emanzini adungekileko.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Abanye abantu abasengozini yokutheleleka baphathi bamaplasi, abathiyi beemfesi, kanye nabantu abasebenzisa amanzi angakahlwekeki ukuphila ngamalanga.&lt;ref name=WHO2014/&gt; Ubulwelwe lobu buhlangana nesiqhema samalwelwe i[[helminthiasis|helminth ethelelanako]].&lt;ref&gt;{{Wp/nd/cite web | title=Chapter 3 Infectious Diseases Related To Travel | url=http://wwwnc.cdc.gov/travel/yellowbook/2014/chapter-3-infectious-diseases-related-to-travel/schistosomiasis | website=cdc.gov | accessdate=30 November 2014 | date=1 August 2013}}&lt;/ref&gt; Ukuthola umrabho wobulwelwe lobu kungenziwa ngokutjheja amaqanda wesilwane esiphila ngokudla ezinye iinlwana emthundweni nofana emakakeni womuntu.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Begodu ingaqinisekiswa ngokuthola[[ama-antibodies ]]manqophana nobulwelwe lobu egazini lomuntu.&lt;ref name=WHO2014/&gt; 

&lt;!-- Prevention and Treatment --&gt;
Iindlela zokukhandela ubulwelwe lobu kufaka hlangana ukuthuthukisa ukutholakala kwamanzi ahlwengileko begodu nokunciphisa imineke etholakala emanzini.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; EEndaweni lapho ubulwelwe lobu budlange khona, imitjhoga nofana iinhlahla [[ezibizwa nge-praziquantel]]zinganikelwa kanye komnyaka esiqhemeni salabo abagulako kileyo ndawo.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; Lokhu kwenzelwa ukwehlisa isibalo sabantu abatheleleke ngobulwelwe begodu nokwehlisa izinga lokusabalaliswa kobulwelwe lobu.&lt;!-- &lt;ref name=WHO2014/&gt; --&gt; I-Praziquantel ngenye yeenhlanhla ezinyulwe[[yi-World Health Organization-iHlangano yeePhasi yezamaPilo]] (WHO) kilabo esele kwaziwa bona bangenwe bulwelwe lobu.&lt;ref name=WHO2014/&gt; 

&lt;!-- Epidemiology --&gt;
Isichenene seengazi esibulwelwe bokuthunda iingazi siphathe abantu ababalelwa eengidigidini ezima-210 wabantu iphasi zombelele ngomnayaka ka-2012.&lt;ref name=Fen2012&gt;{{Wp/nd/cite journal | last=Fenwick | first=A | title=The global burden of neglected tropical diseases.| journal=Public Health | date=Mar 2012 | volume=126 | issue=3 | pages=233–6 | pmid=22325616|doi=10.1016/j.puhe.2011.11.015}}&lt;/ref&gt; Isibalo sabantu esibalelwa ku-12 000&lt;ref name=Loz2012&gt;{{Wp/nd/cite journal | last=Lozano | first=R. | title=Global and regional mortality from 235 causes of death for 20 age groups in 1990 and 2010: a systematic analysis for the Global Burden of Disease Study 2010 | journal=Lancet | date=15 December 2012 | volume=380 | issue=9859 | pages=2095–128 | pmid=23245604 | doi=10.1016/S0140-6736(12)61728-0 | last2=Naghavi | first2=M. | last3=Foreman | first3=K. | last4=Lim | first4=S. | last5=Shibuya | first5=K. | last6=Aboyans | first6=V. | last7=Abraham | first7=J. | last8=Adair | first8=T. | last9=Aggarwal | first9=R. | displayauthors=8}}&lt;/ref&gt; ukufika ku 200,000 babulawa ngiso emnyakeni munye.&lt;ref name=The2013&gt;{{Wp/nd/cite journal | last=Thétiot-Laurent | first=S. A. | author2=Boissier, J. | author3=Robert, A. | author4= Meunier, B. | title=Schistosomiasis Chemotherapy | journal=Angewandte Chemie International Edition in English | date=27 June 2013 | pmid=23813602 | volume=52 | issue=31 | pages=7936–56 | doi=10.1002/anie.201208390}}&lt;/ref&gt; Ubulwelwe lobu butholakala khulu e-Afrika, kanye ne-Asia ne Sewula ye-Amerikha.&lt;ref name=WHO2014/&gt; Pheze abantu abaziingidi ezima-700, eenarheni ezima-70, bahlala lapha ubulwelwe lobu budlange khona.&lt;ref name=The2013/&gt;&lt;ref&gt;{{Wp/nd/cite web | title=Schistosomiasis  A major public health problem | url=http://www.who.int/schistosomiasis/en | work=World Health Organization | accessdate=15 March 2014}}&lt;/ref&gt; Eenarheni zethrophiki, isichenene seengazi esibulwelwe bokuthunda iingazi sibulwelwe obuza ngemva [[kwemalariya]] obuhlangana nezinye izifo ezibangwa ziinlwanyana eziphila ngokudla ezinye iinlwana ezibanga ukuwa konotho.&lt;ref name=&quot;SCP&quot;&gt;{{Wp/nd/cite web | author=The Carter Center | title=Schistosomiasis Control Program | url=http://www.cartercenter.org/health/schistosomiasis/index.html | accessdate=17 July 2008}}&lt;/ref&gt; Isichenene seengazi esibulwelwe bokuthunda iingazi[[ sifakwe erherhweni lamalwelwe wethropiki angakanakwa]].&lt;ref&gt;{{Wp/nd/cite web | title=Neglected Tropical Diseases | url=http://www.cdc.gov/globalhealth/ntd/diseases/index.html | website=cdc.gov | accessdate=28 November 2014 | date=6 June 2011}}&lt;/ref&gt;
==isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi encwadini.==
&lt;references /&gt;
[[Category:Wp/nd]]</text>
      <sha1>nrmggb7w3ezkh8rljrk8mrshl5jld1h</sha1>
    </revision>
  </page>
  <page>
    <title>Wp/nd/Isichenene seengazi esibulwelwe bokuthunda iingazi</title>
    <ns>0</ns>
    <id>396</id>
    <redirect title="Isichenene seengazi esibulwelwe bokuthunda iingazi" />
    <revision>
      <id>2041</id>
      <timestamp>2024-11-18T17:49:44Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <comment>Amire80 moved page [[Wp/nd/Isichenene seengazi esibulwelwe bokuthunda iingazi]] to [[Isichenene seengazi esibulwelwe bokuthunda iingazi]]</comment>
      <origin>2041</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="64" sha1="98c4q6vrn0ub5jcw3h2sx2fq36gl5z7" xml:space="preserve">#REDIRECT [[Isichenene seengazi esibulwelwe bokuthunda iingazi]]</text>
      <sha1>98c4q6vrn0ub5jcw3h2sx2fq36gl5z7</sha1>
    </revision>
  </page>
  <page>
    <title>ILitjhimanisi</title>
    <ns>0</ns>
    <id>397</id>
    <revision>
      <id>2042</id>
      <timestamp>2016-10-01T06:36:18Z</timestamp>
      <contributor>
        <username>incubator&gt;Ian Henderson</username>
        <id>0</id>
      </contributor>
      <comment>Created</comment>
      <origin>2042</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7079" sha1="nm19hbt9yfkdf5dhkqgauwy2ia2xcpd" xml:space="preserve">{{Infobox medical condition
| Name            = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana

| Image           = Skin ulcer due to leishmaniasis, hand of Central American adult 3MG0037 lores.jpg
| Caption         = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni[[esandleni]]sesakhamuzi esihlala e-Amerikha
| Field           = [[Infectious disease (medical specialty)|Infectious disease]]
| pronounce       = Leishmaniasis {{IPAc-en|ˌ|l|iː|ʃ|m|ə|ˈ|n|aɪ|ə|s|ɪ|s}}&lt;br&gt;leishmaniosis {{IPAc-en|l|iː|ʃ|ˌ|m|eɪ|n|ɪ|ˈ|əʊ|s|ɪ|s}} or {{IPAc-en|l|iː|ʃ|ˌ|m|æ|n|ɪ|ˈ|əʊ|s|ɪ|s}}&lt;ref&gt;http://www.collinsdictionary.com/dictionary/english/leishmaniasis&lt;/ref&gt;
| ICD10           = {{ICD10|B|55||b|50}}
| ICD9            = {{ICD9|085}}
| DiseasesDB      = 3266
| DiseasesDB_mult = {{DiseasesDB2|29171}}&lt;!--  {{DiseasesDB2|3266}} {{DiseasesDB2|7070}} --&gt;
| MedlinePlus     = 001386
| eMedicineSubj   = emerg
| eMedicineTopic  = 296
| MeshID          = D007896
}}
''' iLitjhimanisi '''ungayibiza uthi'''yilitjhimanisi''', bulwelwe[[ obubangwa]] silwanyana esincani[[esibizwa ngokuthi]]yi-phrotozowa[[]]ephila ngokuhlala kezinye iinlwana/abantu bona iphile[[itheleleka]]ngokulunywa [[mhlobo othize wengogwana]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu bungavela ngeendlela ezintathu: [[Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni| ukulunywa yingogwana esikhunjeni]] ukutheleleka esikhumbeni nomzimba woke, nofana[[ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali ]].&lt;ref name=WHO2014&gt;{{cite web|title=Leishmaniasis Fact sheet N°375|url=http://www.who.int/mediacentre/factsheets/fs375/en/|work=World Health Organization|accessdate=17 February 2014|date=January 2014}}&lt;/ref&gt; Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni benza umuntu avele isilonda sangaphakathi esikhunjeni, bese ukutheleleka esikhumbeni nomzimba woke kubonakala lokha sele itheleleka esikhumbeni yenze isilonda emlonyeni kanye nepumulweni, bese iLitjhimanisi nasele isezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni ibonakala ngesilonda esingendeni esiphathisa ihloko nomgomani, ibangela namasotja womzimba abe bovu, kanye nokuvuvukisa isibindi. &lt;ref name=WHO2014/&gt;&lt;ref name=Barrett2012/&gt;

&lt;!-- Cause and diagnosis --&gt;
Kunemihlobohlobo ema-20 yeengogwana &quot;zeLitjhimaniya&quot; ezibamba abantu abaphilako&lt;ref name=WHO2014/&gt; Unobangela wobulwelwe lobu nobungozi babo bufaka hlangana ubuchaka, ukungadli ukudla okunepilo, ukususwa nokutjhiswa kwamahlathi, kanye nokuthutha kwabantu bayokuhlala emadorobhei khulu.&lt;ref name=WHO2014/&gt; Yoke imihlobo emithathu yobulwelwe lobu bungabonwa ngesilwanyana nofana ingogwana ephila ngezinye iinlwana kwaphela ngokusetjenziswa komtjhini onerhalasi okhulisa izinto ezincani zibe zikulu.&lt;ref name=WHO2014/&gt; Ukungezelela kilokho, ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali bungabonwa kwaphela ngokuhlolwa kweengazi zaloyo othelelekileko.&lt;ref name=Barrett2012/&gt;

&lt;!-- Prevention and treatment --&gt;
Ubulwelwe iLitjhimanisi bungavikelwa ngkuthi ulale ngaphakathi kwenedi yetende[[ ethelwe ngesihlahla sokuvikela iingogwan]].&lt;ref name=WHO2014/&gt; Ezinye zeendlela zokuvikela kufaka hlangana nokufufuzela isifufuzeli sokuvikela ukulunywa ziingogwana ukwazi ukuzibulala kanye nokulatjhwa kwabantu abangenwe bulwelwe lobu kusese nesikhathi bungakasabalali umzimba woke.&lt;ref name=WHO2014/&gt; Ukulatjhwa okutlhogekako kwenziwa nange kwaziwa bona ubulwelwe lobu buthalakele kiyiphi indawo, umhlobo &quot;weLitjhiminiya&quot; kanye nehlobo lengongwana engenileko.&lt;ref name=WHO2014/&gt; Ezinye zeenhlahla ezingalapha iLitjhimanisi nasele esezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni [[ kufaka hlangana i-liposomal amphotericin B]],&lt;ref name=Sun2013/&gt; ihlanganiso le[[le-pentavalent antimonials]]kanye [[ne-}paromomycin]],&lt;ref name=Sun2013&gt;{{cite journal|last=Sundar|first=S|author2=Chakravarty, J |title=Leishmaniasis: an update of current pharmacotherapy.|journal=Expert opinion on pharmacotherapy|date=Jan 2013|volume=14|issue=1|pages=53–63|pmid=23256501|doi=10.1517/14656566.2013.755515}}&lt;/ref&gt; and [[miltefosine]].&lt;ref name=Dor2012&gt;{{cite journal|last=Dorlo|first=TP|author2=Balasegaram, M |author3=Beijnen, JH |author4= de Vries, PJ |title=Miltefosine: a review of its pharmacology and therapeutic efficacy in the treatment of leishmaniasis.|journal=The Journal of antimicrobial chemotherapy|date=Nov 2012|volume=67|issue=11|pages=2576–97|pmid=22833634|doi=10.1093/jac/dks275}}&lt;/ref&gt;iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni, yi-paramomycin[[, i-fluconazole]], nofana[[i-pentamidine]] nayo ingasebenza kuhle ukulapha.&lt;ref name=Min2007&gt;{{cite journal|last=Minodier|first=P|author2=Parola, P |title=Cutaneous leishmaniasis treatment.|journal=Travel medicine and infectious disease|date=May 2007|volume=5|issue=3|pages=150–8|pmid=17448941|doi=10.1016/j.tmaid.2006.09.004}}&lt;/ref&gt;

&lt;!-- Epidemiology --&gt;
Abantu ababalelwa eegigidini ezili-12 baphethwe bulwelwe lobu njenganje&lt;ref name=Mag&gt;{{cite web|title=Leishmaniasis Magnitude of the problem|url=http://www.who.int/leishmaniasis/burden/magnitude/burden_magnitude/en/index.html|work=World Health Organization|accessdate=17 February 2014}}&lt;/ref&gt; eenrheni ezingaba ma-98.&lt;ref name=Barrett2012&gt;{{cite journal|last=Barrett|first=MP|author2=Croft, SL |title=Management of trypanosomiasis and leishmaniasis.|journal=British medical bulletin|year=2012|volume=104|pages=175–96|pmid=23137768|doi=10.1093/bmb/lds031|pmc=3530408}}&lt;/ref&gt; Kubikwa amacala ukufikelela iingidigidi ezi-2&lt;ref name=Barrett2012/&gt; bese kuthi hlangana nama-20 weekulungwana kanye nama-50 weenkuungana zokubhubha kwabantu ngomnyaka.&lt;ref name=WHO2014/&gt;&lt;ref name=Loz2012&gt;{{cite journal|last=Lozano|first=R|title=Global and regional mortality from 235 causes of death for 20 age groups in 1990 and 2010: a systematic analysis for the Global Burden of Disease Study 2010.|journal=Lancet|date=Dec 15, 2012|volume=380|issue=9859|pages=2095–128|pmid=23245604|doi=10.1016/S0140-6736(12)61728-0}}&lt;/ref&gt; Ukubalelwa ematjhumini ama-200&amp;nbsp; iingidigidi zabantu abahlala e-Asia,Afrika,iSewula neNgaphakathi le-Amerikha, isewula yeYurobhu bahlala eendaweni lapha ubulwelwe lobu bujayelekele khona.&lt;ref name=Barrett2012/&gt;&lt;ref&gt;{{cite journal|last=Ejazi|first=SA|author2=Ali, N |title=Developments in diagnosis and treatment of visceral leishmaniasis during the last decade and future prospects.|journal=Expert review of anti-infective therapy|date=Jan 2013|volume=11|issue=1|pages=79–98|pmid=23428104|doi=10.1586/eri.12.148}}&lt;/ref&gt; I[[hlangano yeZepilo yePhasi Zombelele-WHO]]iphulelwe iintengo eziyibhadala ukuthenga iinhlahla zokulapha ubulwelwe lobu&lt;ref name=Barrett2012/&gt; Ubulwelwe lobu bungatheleleka nakezinye iinlwana ezimbalwa, ukufaka[[iLitjhimanisisi |yezinja]] kanye [[naborodo besiganga]].&lt;ref name=WHO2014/&gt;

==isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi ==
&lt;references /&gt;</text>
      <sha1>nm19hbt9yfkdf5dhkqgauwy2ia2xcpd</sha1>
    </revision>
    <revision>
      <id>2043</id>
      <parentid>2042</parentid>
      <timestamp>2016-11-04T12:16:08Z</timestamp>
      <contributor>
        <username>incubator&gt;Doc James</username>
        <id>0</id>
      </contributor>
      <origin>2043</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7076" sha1="1zkkz2k1vt8jxkpr34ecahmxqvincxn" xml:space="preserve">{{Infobox medical disease
| Name            = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana
| Image           = Skin ulcer due to leishmaniasis, hand of Central American adult 3MG0037 lores.jpg
| Caption         = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni[[esandleni]]sesakhamuzi esihlala e-Amerikha
| Field           = [[Infectious disease (medical specialty)|Infectious disease]]
| pronounce       = Leishmaniasis {{IPAc-en|ˌ|l|iː|ʃ|m|ə|ˈ|n|aɪ|ə|s|ɪ|s}}&lt;br&gt;leishmaniosis {{IPAc-en|l|iː|ʃ|ˌ|m|eɪ|n|ɪ|ˈ|əʊ|s|ɪ|s}} or {{IPAc-en|l|iː|ʃ|ˌ|m|æ|n|ɪ|ˈ|əʊ|s|ɪ|s}}&lt;ref&gt;http://www.collinsdictionary.com/dictionary/english/leishmaniasis&lt;/ref&gt;
| ICD10           = {{ICD10|B|55||b|50}}
| ICD9            = {{ICD9|085}}
| DiseasesDB      = 3266
| DiseasesDB_mult = {{DiseasesDB2|29171}}&lt;!--  {{DiseasesDB2|3266}} {{DiseasesDB2|7070}} --&gt;
| MedlinePlus     = 001386
| eMedicineSubj   = emerg
| eMedicineTopic  = 296
| MeshID          = D007896
}}
''' iLitjhimanisi '''ungayibiza uthi'''yilitjhimanisi''', bulwelwe[[ obubangwa]] silwanyana esincani[[esibizwa ngokuthi]]yi-phrotozowa[[]]ephila ngokuhlala kezinye iinlwana/abantu bona iphile[[itheleleka]]ngokulunywa [[mhlobo othize wengogwana]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu bungavela ngeendlela ezintathu: [[Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni| ukulunywa yingogwana esikhunjeni]] ukutheleleka esikhumbeni nomzimba woke, nofana[[ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali ]].&lt;ref name=WHO2014&gt;{{cite web|title=Leishmaniasis Fact sheet N°375|url=http://www.who.int/mediacentre/factsheets/fs375/en/|work=World Health Organization|accessdate=17 February 2014|date=January 2014}}&lt;/ref&gt; Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni benza umuntu avele isilonda sangaphakathi esikhunjeni, bese ukutheleleka esikhumbeni nomzimba woke kubonakala lokha sele itheleleka esikhumbeni yenze isilonda emlonyeni kanye nepumulweni, bese iLitjhimanisi nasele isezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni ibonakala ngesilonda esingendeni esiphathisa ihloko nomgomani, ibangela namasotja womzimba abe bovu, kanye nokuvuvukisa isibindi. &lt;ref name=WHO2014/&gt;&lt;ref name=Barrett2012/&gt;

&lt;!-- Cause and diagnosis --&gt;
Kunemihlobohlobo ema-20 yeengogwana &quot;zeLitjhimaniya&quot; ezibamba abantu abaphilako&lt;ref name=WHO2014/&gt; Unobangela wobulwelwe lobu nobungozi babo bufaka hlangana ubuchaka, ukungadli ukudla okunepilo, ukususwa nokutjhiswa kwamahlathi, kanye nokuthutha kwabantu bayokuhlala emadorobhei khulu.&lt;ref name=WHO2014/&gt; Yoke imihlobo emithathu yobulwelwe lobu bungabonwa ngesilwanyana nofana ingogwana ephila ngezinye iinlwana kwaphela ngokusetjenziswa komtjhini onerhalasi okhulisa izinto ezincani zibe zikulu.&lt;ref name=WHO2014/&gt; Ukungezelela kilokho, ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali bungabonwa kwaphela ngokuhlolwa kweengazi zaloyo othelelekileko.&lt;ref name=Barrett2012/&gt;

&lt;!-- Prevention and treatment --&gt;
Ubulwelwe iLitjhimanisi bungavikelwa ngkuthi ulale ngaphakathi kwenedi yetende[[ ethelwe ngesihlahla sokuvikela iingogwan]].&lt;ref name=WHO2014/&gt; Ezinye zeendlela zokuvikela kufaka hlangana nokufufuzela isifufuzeli sokuvikela ukulunywa ziingogwana ukwazi ukuzibulala kanye nokulatjhwa kwabantu abangenwe bulwelwe lobu kusese nesikhathi bungakasabalali umzimba woke.&lt;ref name=WHO2014/&gt; Ukulatjhwa okutlhogekako kwenziwa nange kwaziwa bona ubulwelwe lobu buthalakele kiyiphi indawo, umhlobo &quot;weLitjhiminiya&quot; kanye nehlobo lengongwana engenileko.&lt;ref name=WHO2014/&gt; Ezinye zeenhlahla ezingalapha iLitjhimanisi nasele esezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni [[ kufaka hlangana i-liposomal amphotericin B]],&lt;ref name=Sun2013/&gt; ihlanganiso le[[le-pentavalent antimonials]]kanye [[ne-}paromomycin]],&lt;ref name=Sun2013&gt;{{cite journal|last=Sundar|first=S|author2=Chakravarty, J |title=Leishmaniasis: an update of current pharmacotherapy.|journal=Expert opinion on pharmacotherapy|date=Jan 2013|volume=14|issue=1|pages=53–63|pmid=23256501|doi=10.1517/14656566.2013.755515}}&lt;/ref&gt; and [[miltefosine]].&lt;ref name=Dor2012&gt;{{cite journal|last=Dorlo|first=TP|author2=Balasegaram, M |author3=Beijnen, JH |author4= de Vries, PJ |title=Miltefosine: a review of its pharmacology and therapeutic efficacy in the treatment of leishmaniasis.|journal=The Journal of antimicrobial chemotherapy|date=Nov 2012|volume=67|issue=11|pages=2576–97|pmid=22833634|doi=10.1093/jac/dks275}}&lt;/ref&gt;iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni, yi-paramomycin[[, i-fluconazole]], nofana[[i-pentamidine]] nayo ingasebenza kuhle ukulapha.&lt;ref name=Min2007&gt;{{cite journal|last=Minodier|first=P|author2=Parola, P |title=Cutaneous leishmaniasis treatment.|journal=Travel medicine and infectious disease|date=May 2007|volume=5|issue=3|pages=150–8|pmid=17448941|doi=10.1016/j.tmaid.2006.09.004}}&lt;/ref&gt;

&lt;!-- Epidemiology --&gt;
Abantu ababalelwa eegigidini ezili-12 baphethwe bulwelwe lobu njenganje&lt;ref name=Mag&gt;{{cite web|title=Leishmaniasis Magnitude of the problem|url=http://www.who.int/leishmaniasis/burden/magnitude/burden_magnitude/en/index.html|work=World Health Organization|accessdate=17 February 2014}}&lt;/ref&gt; eenrheni ezingaba ma-98.&lt;ref name=Barrett2012&gt;{{cite journal|last=Barrett|first=MP|author2=Croft, SL |title=Management of trypanosomiasis and leishmaniasis.|journal=British medical bulletin|year=2012|volume=104|pages=175–96|pmid=23137768|doi=10.1093/bmb/lds031|pmc=3530408}}&lt;/ref&gt; Kubikwa amacala ukufikelela iingidigidi ezi-2&lt;ref name=Barrett2012/&gt; bese kuthi hlangana nama-20 weekulungwana kanye nama-50 weenkuungana zokubhubha kwabantu ngomnyaka.&lt;ref name=WHO2014/&gt;&lt;ref name=Loz2012&gt;{{cite journal|last=Lozano|first=R|title=Global and regional mortality from 235 causes of death for 20 age groups in 1990 and 2010: a systematic analysis for the Global Burden of Disease Study 2010.|journal=Lancet|date=Dec 15, 2012|volume=380|issue=9859|pages=2095–128|pmid=23245604|doi=10.1016/S0140-6736(12)61728-0}}&lt;/ref&gt; Ukubalelwa ematjhumini ama-200&amp;nbsp; iingidigidi zabantu abahlala e-Asia,Afrika,iSewula neNgaphakathi le-Amerikha, isewula yeYurobhu bahlala eendaweni lapha ubulwelwe lobu bujayelekele khona.&lt;ref name=Barrett2012/&gt;&lt;ref&gt;{{cite journal|last=Ejazi|first=SA|author2=Ali, N |title=Developments in diagnosis and treatment of visceral leishmaniasis during the last decade and future prospects.|journal=Expert review of anti-infective therapy|date=Jan 2013|volume=11|issue=1|pages=79–98|pmid=23428104|doi=10.1586/eri.12.148}}&lt;/ref&gt; I[[hlangano yeZepilo yePhasi Zombelele-WHO]]iphulelwe iintengo eziyibhadala ukuthenga iinhlahla zokulapha ubulwelwe lobu&lt;ref name=Barrett2012/&gt; Ubulwelwe lobu bungatheleleka nakezinye iinlwana ezimbalwa, ukufaka[[iLitjhimanisisi |yezinja]] kanye [[naborodo besiganga]].&lt;ref name=WHO2014/&gt;

==isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi ==
&lt;references /&gt;</text>
      <sha1>1zkkz2k1vt8jxkpr34ecahmxqvincxn</sha1>
    </revision>
    <revision>
      <id>2044</id>
      <parentid>2043</parentid>
      <timestamp>2016-11-04T12:17:02Z</timestamp>
      <contributor>
        <username>incubator&gt;Doc James</username>
        <id>0</id>
      </contributor>
      <origin>2044</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7074" sha1="37u8v5rfec7hovg249b3rue1h9k36r1" xml:space="preserve">{{Wp/nr/Infobox disease
| Name            = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana
| Image           = Skin ulcer due to leishmaniasis, hand of Central American adult 3MG0037 lores.jpg
| Caption         = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni[[esandleni]]sesakhamuzi esihlala e-Amerikha
| Field           = [[Infectious disease (medical specialty)|Infectious disease]]
| pronounce       = Leishmaniasis {{IPAc-en|ˌ|l|iː|ʃ|m|ə|ˈ|n|aɪ|ə|s|ɪ|s}}&lt;br&gt;leishmaniosis {{IPAc-en|l|iː|ʃ|ˌ|m|eɪ|n|ɪ|ˈ|əʊ|s|ɪ|s}} or {{IPAc-en|l|iː|ʃ|ˌ|m|æ|n|ɪ|ˈ|əʊ|s|ɪ|s}}&lt;ref&gt;http://www.collinsdictionary.com/dictionary/english/leishmaniasis&lt;/ref&gt;
| ICD10           = {{ICD10|B|55||b|50}}
| ICD9            = {{ICD9|085}}
| DiseasesDB      = 3266
| DiseasesDB_mult = {{DiseasesDB2|29171}}&lt;!--  {{DiseasesDB2|3266}} {{DiseasesDB2|7070}} --&gt;
| MedlinePlus     = 001386
| eMedicineSubj   = emerg
| eMedicineTopic  = 296
| MeshID          = D007896
}}
''' iLitjhimanisi '''ungayibiza uthi'''yilitjhimanisi''', bulwelwe[[ obubangwa]] silwanyana esincani[[esibizwa ngokuthi]]yi-phrotozowa[[]]ephila ngokuhlala kezinye iinlwana/abantu bona iphile[[itheleleka]]ngokulunywa [[mhlobo othize wengogwana]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu bungavela ngeendlela ezintathu: [[Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni| ukulunywa yingogwana esikhunjeni]] ukutheleleka esikhumbeni nomzimba woke, nofana[[ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali ]].&lt;ref name=WHO2014&gt;{{cite web|title=Leishmaniasis Fact sheet N°375|url=http://www.who.int/mediacentre/factsheets/fs375/en/|work=World Health Organization|accessdate=17 February 2014|date=January 2014}}&lt;/ref&gt; Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni benza umuntu avele isilonda sangaphakathi esikhunjeni, bese ukutheleleka esikhumbeni nomzimba woke kubonakala lokha sele itheleleka esikhumbeni yenze isilonda emlonyeni kanye nepumulweni, bese iLitjhimanisi nasele isezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni ibonakala ngesilonda esingendeni esiphathisa ihloko nomgomani, ibangela namasotja womzimba abe bovu, kanye nokuvuvukisa isibindi. &lt;ref name=WHO2014/&gt;&lt;ref name=Barrett2012/&gt;

&lt;!-- Cause and diagnosis --&gt;
Kunemihlobohlobo ema-20 yeengogwana &quot;zeLitjhimaniya&quot; ezibamba abantu abaphilako&lt;ref name=WHO2014/&gt; Unobangela wobulwelwe lobu nobungozi babo bufaka hlangana ubuchaka, ukungadli ukudla okunepilo, ukususwa nokutjhiswa kwamahlathi, kanye nokuthutha kwabantu bayokuhlala emadorobhei khulu.&lt;ref name=WHO2014/&gt; Yoke imihlobo emithathu yobulwelwe lobu bungabonwa ngesilwanyana nofana ingogwana ephila ngezinye iinlwana kwaphela ngokusetjenziswa komtjhini onerhalasi okhulisa izinto ezincani zibe zikulu.&lt;ref name=WHO2014/&gt; Ukungezelela kilokho, ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali bungabonwa kwaphela ngokuhlolwa kweengazi zaloyo othelelekileko.&lt;ref name=Barrett2012/&gt;

&lt;!-- Prevention and treatment --&gt;
Ubulwelwe iLitjhimanisi bungavikelwa ngkuthi ulale ngaphakathi kwenedi yetende[[ ethelwe ngesihlahla sokuvikela iingogwan]].&lt;ref name=WHO2014/&gt; Ezinye zeendlela zokuvikela kufaka hlangana nokufufuzela isifufuzeli sokuvikela ukulunywa ziingogwana ukwazi ukuzibulala kanye nokulatjhwa kwabantu abangenwe bulwelwe lobu kusese nesikhathi bungakasabalali umzimba woke.&lt;ref name=WHO2014/&gt; Ukulatjhwa okutlhogekako kwenziwa nange kwaziwa bona ubulwelwe lobu buthalakele kiyiphi indawo, umhlobo &quot;weLitjhiminiya&quot; kanye nehlobo lengongwana engenileko.&lt;ref name=WHO2014/&gt; Ezinye zeenhlahla ezingalapha iLitjhimanisi nasele esezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni [[ kufaka hlangana i-liposomal amphotericin B]],&lt;ref name=Sun2013/&gt; ihlanganiso le[[le-pentavalent antimonials]]kanye [[ne-}paromomycin]],&lt;ref name=Sun2013&gt;{{cite journal|last=Sundar|first=S|author2=Chakravarty, J |title=Leishmaniasis: an update of current pharmacotherapy.|journal=Expert opinion on pharmacotherapy|date=Jan 2013|volume=14|issue=1|pages=53–63|pmid=23256501|doi=10.1517/14656566.2013.755515}}&lt;/ref&gt; and [[miltefosine]].&lt;ref name=Dor2012&gt;{{cite journal|last=Dorlo|first=TP|author2=Balasegaram, M |author3=Beijnen, JH |author4= de Vries, PJ |title=Miltefosine: a review of its pharmacology and therapeutic efficacy in the treatment of leishmaniasis.|journal=The Journal of antimicrobial chemotherapy|date=Nov 2012|volume=67|issue=11|pages=2576–97|pmid=22833634|doi=10.1093/jac/dks275}}&lt;/ref&gt;iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni, yi-paramomycin[[, i-fluconazole]], nofana[[i-pentamidine]] nayo ingasebenza kuhle ukulapha.&lt;ref name=Min2007&gt;{{cite journal|last=Minodier|first=P|author2=Parola, P |title=Cutaneous leishmaniasis treatment.|journal=Travel medicine and infectious disease|date=May 2007|volume=5|issue=3|pages=150–8|pmid=17448941|doi=10.1016/j.tmaid.2006.09.004}}&lt;/ref&gt;

&lt;!-- Epidemiology --&gt;
Abantu ababalelwa eegigidini ezili-12 baphethwe bulwelwe lobu njenganje&lt;ref name=Mag&gt;{{cite web|title=Leishmaniasis Magnitude of the problem|url=http://www.who.int/leishmaniasis/burden/magnitude/burden_magnitude/en/index.html|work=World Health Organization|accessdate=17 February 2014}}&lt;/ref&gt; eenrheni ezingaba ma-98.&lt;ref name=Barrett2012&gt;{{cite journal|last=Barrett|first=MP|author2=Croft, SL |title=Management of trypanosomiasis and leishmaniasis.|journal=British medical bulletin|year=2012|volume=104|pages=175–96|pmid=23137768|doi=10.1093/bmb/lds031|pmc=3530408}}&lt;/ref&gt; Kubikwa amacala ukufikelela iingidigidi ezi-2&lt;ref name=Barrett2012/&gt; bese kuthi hlangana nama-20 weekulungwana kanye nama-50 weenkuungana zokubhubha kwabantu ngomnyaka.&lt;ref name=WHO2014/&gt;&lt;ref name=Loz2012&gt;{{cite journal|last=Lozano|first=R|title=Global and regional mortality from 235 causes of death for 20 age groups in 1990 and 2010: a systematic analysis for the Global Burden of Disease Study 2010.|journal=Lancet|date=Dec 15, 2012|volume=380|issue=9859|pages=2095–128|pmid=23245604|doi=10.1016/S0140-6736(12)61728-0}}&lt;/ref&gt; Ukubalelwa ematjhumini ama-200&amp;nbsp; iingidigidi zabantu abahlala e-Asia,Afrika,iSewula neNgaphakathi le-Amerikha, isewula yeYurobhu bahlala eendaweni lapha ubulwelwe lobu bujayelekele khona.&lt;ref name=Barrett2012/&gt;&lt;ref&gt;{{cite journal|last=Ejazi|first=SA|author2=Ali, N |title=Developments in diagnosis and treatment of visceral leishmaniasis during the last decade and future prospects.|journal=Expert review of anti-infective therapy|date=Jan 2013|volume=11|issue=1|pages=79–98|pmid=23428104|doi=10.1586/eri.12.148}}&lt;/ref&gt; I[[hlangano yeZepilo yePhasi Zombelele-WHO]]iphulelwe iintengo eziyibhadala ukuthenga iinhlahla zokulapha ubulwelwe lobu&lt;ref name=Barrett2012/&gt; Ubulwelwe lobu bungatheleleka nakezinye iinlwana ezimbalwa, ukufaka[[iLitjhimanisisi |yezinja]] kanye [[naborodo besiganga]].&lt;ref name=WHO2014/&gt;

==isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi ==
&lt;references /&gt;</text>
      <sha1>37u8v5rfec7hovg249b3rue1h9k36r1</sha1>
    </revision>
    <revision>
      <id>2045</id>
      <parentid>2044</parentid>
      <timestamp>2016-11-04T12:17:16Z</timestamp>
      <contributor>
        <username>incubator&gt;Doc James</username>
        <id>0</id>
      </contributor>
      <origin>2045</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7074" sha1="otg76h44k1uis9vocf1pur07qwvxxsn" xml:space="preserve">{{Wp/nr/Infobox disease
| name            = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana
| image           = Skin ulcer due to leishmaniasis, hand of Central American adult 3MG0037 lores.jpg
| caption         = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni[[esandleni]]sesakhamuzi esihlala e-Amerikha
| Field           = [[Infectious disease (medical specialty)|Infectious disease]]
| pronounce       = Leishmaniasis {{IPAc-en|ˌ|l|iː|ʃ|m|ə|ˈ|n|aɪ|ə|s|ɪ|s}}&lt;br&gt;leishmaniosis {{IPAc-en|l|iː|ʃ|ˌ|m|eɪ|n|ɪ|ˈ|əʊ|s|ɪ|s}} or {{IPAc-en|l|iː|ʃ|ˌ|m|æ|n|ɪ|ˈ|əʊ|s|ɪ|s}}&lt;ref&gt;http://www.collinsdictionary.com/dictionary/english/leishmaniasis&lt;/ref&gt;
| ICD10           = {{ICD10|B|55||b|50}}
| ICD9            = {{ICD9|085}}
| DiseasesDB      = 3266
| DiseasesDB_mult = {{DiseasesDB2|29171}}&lt;!--  {{DiseasesDB2|3266}} {{DiseasesDB2|7070}} --&gt;
| MedlinePlus     = 001386
| eMedicineSubj   = emerg
| eMedicineTopic  = 296
| MeshID          = D007896
}}
''' iLitjhimanisi '''ungayibiza uthi'''yilitjhimanisi''', bulwelwe[[ obubangwa]] silwanyana esincani[[esibizwa ngokuthi]]yi-phrotozowa[[]]ephila ngokuhlala kezinye iinlwana/abantu bona iphile[[itheleleka]]ngokulunywa [[mhlobo othize wengogwana]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu bungavela ngeendlela ezintathu: [[Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni| ukulunywa yingogwana esikhunjeni]] ukutheleleka esikhumbeni nomzimba woke, nofana[[ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali ]].&lt;ref name=WHO2014&gt;{{cite web|title=Leishmaniasis Fact sheet N°375|url=http://www.who.int/mediacentre/factsheets/fs375/en/|work=World Health Organization|accessdate=17 February 2014|date=January 2014}}&lt;/ref&gt; Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni benza umuntu avele isilonda sangaphakathi esikhunjeni, bese ukutheleleka esikhumbeni nomzimba woke kubonakala lokha sele itheleleka esikhumbeni yenze isilonda emlonyeni kanye nepumulweni, bese iLitjhimanisi nasele isezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni ibonakala ngesilonda esingendeni esiphathisa ihloko nomgomani, ibangela namasotja womzimba abe bovu, kanye nokuvuvukisa isibindi. &lt;ref name=WHO2014/&gt;&lt;ref name=Barrett2012/&gt;

&lt;!-- Cause and diagnosis --&gt;
Kunemihlobohlobo ema-20 yeengogwana &quot;zeLitjhimaniya&quot; ezibamba abantu abaphilako&lt;ref name=WHO2014/&gt; Unobangela wobulwelwe lobu nobungozi babo bufaka hlangana ubuchaka, ukungadli ukudla okunepilo, ukususwa nokutjhiswa kwamahlathi, kanye nokuthutha kwabantu bayokuhlala emadorobhei khulu.&lt;ref name=WHO2014/&gt; Yoke imihlobo emithathu yobulwelwe lobu bungabonwa ngesilwanyana nofana ingogwana ephila ngezinye iinlwana kwaphela ngokusetjenziswa komtjhini onerhalasi okhulisa izinto ezincani zibe zikulu.&lt;ref name=WHO2014/&gt; Ukungezelela kilokho, ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali bungabonwa kwaphela ngokuhlolwa kweengazi zaloyo othelelekileko.&lt;ref name=Barrett2012/&gt;

&lt;!-- Prevention and treatment --&gt;
Ubulwelwe iLitjhimanisi bungavikelwa ngkuthi ulale ngaphakathi kwenedi yetende[[ ethelwe ngesihlahla sokuvikela iingogwan]].&lt;ref name=WHO2014/&gt; Ezinye zeendlela zokuvikela kufaka hlangana nokufufuzela isifufuzeli sokuvikela ukulunywa ziingogwana ukwazi ukuzibulala kanye nokulatjhwa kwabantu abangenwe bulwelwe lobu kusese nesikhathi bungakasabalali umzimba woke.&lt;ref name=WHO2014/&gt; Ukulatjhwa okutlhogekako kwenziwa nange kwaziwa bona ubulwelwe lobu buthalakele kiyiphi indawo, umhlobo &quot;weLitjhiminiya&quot; kanye nehlobo lengongwana engenileko.&lt;ref name=WHO2014/&gt; Ezinye zeenhlahla ezingalapha iLitjhimanisi nasele esezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni [[ kufaka hlangana i-liposomal amphotericin B]],&lt;ref name=Sun2013/&gt; ihlanganiso le[[le-pentavalent antimonials]]kanye [[ne-}paromomycin]],&lt;ref name=Sun2013&gt;{{cite journal|last=Sundar|first=S|author2=Chakravarty, J |title=Leishmaniasis: an update of current pharmacotherapy.|journal=Expert opinion on pharmacotherapy|date=Jan 2013|volume=14|issue=1|pages=53–63|pmid=23256501|doi=10.1517/14656566.2013.755515}}&lt;/ref&gt; and [[miltefosine]].&lt;ref name=Dor2012&gt;{{cite journal|last=Dorlo|first=TP|author2=Balasegaram, M |author3=Beijnen, JH |author4= de Vries, PJ |title=Miltefosine: a review of its pharmacology and therapeutic efficacy in the treatment of leishmaniasis.|journal=The Journal of antimicrobial chemotherapy|date=Nov 2012|volume=67|issue=11|pages=2576–97|pmid=22833634|doi=10.1093/jac/dks275}}&lt;/ref&gt;iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni, yi-paramomycin[[, i-fluconazole]], nofana[[i-pentamidine]] nayo ingasebenza kuhle ukulapha.&lt;ref name=Min2007&gt;{{cite journal|last=Minodier|first=P|author2=Parola, P |title=Cutaneous leishmaniasis treatment.|journal=Travel medicine and infectious disease|date=May 2007|volume=5|issue=3|pages=150–8|pmid=17448941|doi=10.1016/j.tmaid.2006.09.004}}&lt;/ref&gt;

&lt;!-- Epidemiology --&gt;
Abantu ababalelwa eegigidini ezili-12 baphethwe bulwelwe lobu njenganje&lt;ref name=Mag&gt;{{cite web|title=Leishmaniasis Magnitude of the problem|url=http://www.who.int/leishmaniasis/burden/magnitude/burden_magnitude/en/index.html|work=World Health Organization|accessdate=17 February 2014}}&lt;/ref&gt; eenrheni ezingaba ma-98.&lt;ref name=Barrett2012&gt;{{cite journal|last=Barrett|first=MP|author2=Croft, SL |title=Management of trypanosomiasis and leishmaniasis.|journal=British medical bulletin|year=2012|volume=104|pages=175–96|pmid=23137768|doi=10.1093/bmb/lds031|pmc=3530408}}&lt;/ref&gt; Kubikwa amacala ukufikelela iingidigidi ezi-2&lt;ref name=Barrett2012/&gt; bese kuthi hlangana nama-20 weekulungwana kanye nama-50 weenkuungana zokubhubha kwabantu ngomnyaka.&lt;ref name=WHO2014/&gt;&lt;ref name=Loz2012&gt;{{cite journal|last=Lozano|first=R|title=Global and regional mortality from 235 causes of death for 20 age groups in 1990 and 2010: a systematic analysis for the Global Burden of Disease Study 2010.|journal=Lancet|date=Dec 15, 2012|volume=380|issue=9859|pages=2095–128|pmid=23245604|doi=10.1016/S0140-6736(12)61728-0}}&lt;/ref&gt; Ukubalelwa ematjhumini ama-200&amp;nbsp; iingidigidi zabantu abahlala e-Asia,Afrika,iSewula neNgaphakathi le-Amerikha, isewula yeYurobhu bahlala eendaweni lapha ubulwelwe lobu bujayelekele khona.&lt;ref name=Barrett2012/&gt;&lt;ref&gt;{{cite journal|last=Ejazi|first=SA|author2=Ali, N |title=Developments in diagnosis and treatment of visceral leishmaniasis during the last decade and future prospects.|journal=Expert review of anti-infective therapy|date=Jan 2013|volume=11|issue=1|pages=79–98|pmid=23428104|doi=10.1586/eri.12.148}}&lt;/ref&gt; I[[hlangano yeZepilo yePhasi Zombelele-WHO]]iphulelwe iintengo eziyibhadala ukuthenga iinhlahla zokulapha ubulwelwe lobu&lt;ref name=Barrett2012/&gt; Ubulwelwe lobu bungatheleleka nakezinye iinlwana ezimbalwa, ukufaka[[iLitjhimanisisi |yezinja]] kanye [[naborodo besiganga]].&lt;ref name=WHO2014/&gt;

==isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi ==
&lt;references /&gt;</text>
      <sha1>otg76h44k1uis9vocf1pur07qwvxxsn</sha1>
    </revision>
    <revision>
      <id>2046</id>
      <parentid>2045</parentid>
      <timestamp>2016-11-04T12:17:53Z</timestamp>
      <contributor>
        <username>incubator&gt;Doc James</username>
        <id>0</id>
      </contributor>
      <origin>2046</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7074" sha1="sgg2fqthbx4sf80g0ax3jrj6qfdeb92" xml:space="preserve">{{Wp/nr/Infobox disease
| name            = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana
| image           = Skin ulcer due to leishmaniasis, hand of Central American adult 3MG0037 lores.jpg
| caption         = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni[[esandleni]]sesakhamuzi esihlala e-Amerikha
| Field           = [[Infectious disease (medical specialty)|Infectious disease]]
| pronounce       = Leishmaniasis {{IPAc-en|ˌ|l|iː|ʃ|m|ə|ˈ|n|aɪ|ə|s|ɪ|s}}&lt;br&gt;leishmaniosis {{IPAc-en|l|iː|ʃ|ˌ|m|eɪ|n|ɪ|ˈ|əʊ|s|ɪ|s}} or {{IPAc-en|l|iː|ʃ|ˌ|m|æ|n|ɪ|ˈ|əʊ|s|ɪ|s}}&lt;ref&gt;http://www.collinsdictionary.com/dictionary/english/leishmaniasis&lt;/ref&gt;
| ICD10           = {{ICD10|B|55||b|50}}
| ICD9            = {{ICD9|085}}
| DiseasesDB      = 3266
| DiseasesDB_mult = {{DiseasesDB2|29171}}&lt;!--  {{DiseasesDB2|3266}} {{DiseasesDB2|7070}} --&gt;
| MedlinePlus     = 001386
| eMedicineSubj   = emerg
| eMedicineTopic  = 296
| MeshID          = D007896
}}
''' iLitjhimanisi '''ungayibiza uthi'''yilitjhimanisi''', bulwelwe [[obubangwa]] silwanyana esincani [[esibizwa ngokuthi]]yi-phrotozowa ephila ngokuhlala kezinye iinlwana/abantu bona iphile [[itheleleka]] ngokulunywa [[mhlobo othize wengogwana]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu bungavela ngeendlela ezintathu: [[Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni| ukulunywa yingogwana esikhunjeni]] ukutheleleka esikhumbeni nomzimba woke, nofana[[ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali ]].&lt;ref name=WHO2014&gt;{{cite web|title=Leishmaniasis Fact sheet N°375|url=http://www.who.int/mediacentre/factsheets/fs375/en/|work=World Health Organization|accessdate=17 February 2014|date=January 2014}}&lt;/ref&gt; Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni benza umuntu avele isilonda sangaphakathi esikhunjeni, bese ukutheleleka esikhumbeni nomzimba woke kubonakala lokha sele itheleleka esikhumbeni yenze isilonda emlonyeni kanye nepumulweni, bese iLitjhimanisi nasele isezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni ibonakala ngesilonda esingendeni esiphathisa ihloko nomgomani, ibangela namasotja womzimba abe bovu, kanye nokuvuvukisa isibindi. &lt;ref name=WHO2014/&gt;&lt;ref name=Barrett2012/&gt;

&lt;!-- Cause and diagnosis --&gt;
Kunemihlobohlobo ema-20 yeengogwana &quot;zeLitjhimaniya&quot; ezibamba abantu abaphilako&lt;ref name=WHO2014/&gt; Unobangela wobulwelwe lobu nobungozi babo bufaka hlangana ubuchaka, ukungadli ukudla okunepilo, ukususwa nokutjhiswa kwamahlathi, kanye nokuthutha kwabantu bayokuhlala emadorobhei khulu.&lt;ref name=WHO2014/&gt; Yoke imihlobo emithathu yobulwelwe lobu bungabonwa ngesilwanyana nofana ingogwana ephila ngezinye iinlwana kwaphela ngokusetjenziswa komtjhini onerhalasi okhulisa izinto ezincani zibe zikulu.&lt;ref name=WHO2014/&gt; Ukungezelela kilokho, ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali bungabonwa kwaphela ngokuhlolwa kweengazi zaloyo othelelekileko.&lt;ref name=Barrett2012/&gt;

&lt;!-- Prevention and treatment --&gt;
Ubulwelwe iLitjhimanisi bungavikelwa ngkuthi ulale ngaphakathi kwenedi yetende[[ ethelwe ngesihlahla sokuvikela iingogwan]].&lt;ref name=WHO2014/&gt; Ezinye zeendlela zokuvikela kufaka hlangana nokufufuzela isifufuzeli sokuvikela ukulunywa ziingogwana ukwazi ukuzibulala kanye nokulatjhwa kwabantu abangenwe bulwelwe lobu kusese nesikhathi bungakasabalali umzimba woke.&lt;ref name=WHO2014/&gt; Ukulatjhwa okutlhogekako kwenziwa nange kwaziwa bona ubulwelwe lobu buthalakele kiyiphi indawo, umhlobo &quot;weLitjhiminiya&quot; kanye nehlobo lengongwana engenileko.&lt;ref name=WHO2014/&gt; Ezinye zeenhlahla ezingalapha iLitjhimanisi nasele esezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni [[ kufaka hlangana i-liposomal amphotericin B]],&lt;ref name=Sun2013/&gt; ihlanganiso le[[le-pentavalent antimonials]]kanye [[ne-}paromomycin]],&lt;ref name=Sun2013&gt;{{cite journal|last=Sundar|first=S|author2=Chakravarty, J |title=Leishmaniasis: an update of current pharmacotherapy.|journal=Expert opinion on pharmacotherapy|date=Jan 2013|volume=14|issue=1|pages=53–63|pmid=23256501|doi=10.1517/14656566.2013.755515}}&lt;/ref&gt; and [[miltefosine]].&lt;ref name=Dor2012&gt;{{cite journal|last=Dorlo|first=TP|author2=Balasegaram, M |author3=Beijnen, JH |author4= de Vries, PJ |title=Miltefosine: a review of its pharmacology and therapeutic efficacy in the treatment of leishmaniasis.|journal=The Journal of antimicrobial chemotherapy|date=Nov 2012|volume=67|issue=11|pages=2576–97|pmid=22833634|doi=10.1093/jac/dks275}}&lt;/ref&gt;iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni, yi-paramomycin[[, i-fluconazole]], nofana[[i-pentamidine]] nayo ingasebenza kuhle ukulapha.&lt;ref name=Min2007&gt;{{cite journal|last=Minodier|first=P|author2=Parola, P |title=Cutaneous leishmaniasis treatment.|journal=Travel medicine and infectious disease|date=May 2007|volume=5|issue=3|pages=150–8|pmid=17448941|doi=10.1016/j.tmaid.2006.09.004}}&lt;/ref&gt;

&lt;!-- Epidemiology --&gt;
Abantu ababalelwa eegigidini ezili-12 baphethwe bulwelwe lobu njenganje&lt;ref name=Mag&gt;{{cite web|title=Leishmaniasis Magnitude of the problem|url=http://www.who.int/leishmaniasis/burden/magnitude/burden_magnitude/en/index.html|work=World Health Organization|accessdate=17 February 2014}}&lt;/ref&gt; eenrheni ezingaba ma-98.&lt;ref name=Barrett2012&gt;{{cite journal|last=Barrett|first=MP|author2=Croft, SL |title=Management of trypanosomiasis and leishmaniasis.|journal=British medical bulletin|year=2012|volume=104|pages=175–96|pmid=23137768|doi=10.1093/bmb/lds031|pmc=3530408}}&lt;/ref&gt; Kubikwa amacala ukufikelela iingidigidi ezi-2&lt;ref name=Barrett2012/&gt; bese kuthi hlangana nama-20 weekulungwana kanye nama-50 weenkuungana zokubhubha kwabantu ngomnyaka.&lt;ref name=WHO2014/&gt;&lt;ref name=Loz2012&gt;{{cite journal|last=Lozano|first=R|title=Global and regional mortality from 235 causes of death for 20 age groups in 1990 and 2010: a systematic analysis for the Global Burden of Disease Study 2010.|journal=Lancet|date=Dec 15, 2012|volume=380|issue=9859|pages=2095–128|pmid=23245604|doi=10.1016/S0140-6736(12)61728-0}}&lt;/ref&gt; Ukubalelwa ematjhumini ama-200&amp;nbsp; iingidigidi zabantu abahlala e-Asia,Afrika,iSewula neNgaphakathi le-Amerikha, isewula yeYurobhu bahlala eendaweni lapha ubulwelwe lobu bujayelekele khona.&lt;ref name=Barrett2012/&gt;&lt;ref&gt;{{cite journal|last=Ejazi|first=SA|author2=Ali, N |title=Developments in diagnosis and treatment of visceral leishmaniasis during the last decade and future prospects.|journal=Expert review of anti-infective therapy|date=Jan 2013|volume=11|issue=1|pages=79–98|pmid=23428104|doi=10.1586/eri.12.148}}&lt;/ref&gt; I[[hlangano yeZepilo yePhasi Zombelele-WHO]]iphulelwe iintengo eziyibhadala ukuthenga iinhlahla zokulapha ubulwelwe lobu&lt;ref name=Barrett2012/&gt; Ubulwelwe lobu bungatheleleka nakezinye iinlwana ezimbalwa, ukufaka[[iLitjhimanisisi |yezinja]] kanye [[naborodo besiganga]].&lt;ref name=WHO2014/&gt;

==isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi ==
&lt;references /&gt;</text>
      <sha1>sgg2fqthbx4sf80g0ax3jrj6qfdeb92</sha1>
    </revision>
    <revision>
      <id>2047</id>
      <parentid>2046</parentid>
      <timestamp>2016-11-04T12:21:25Z</timestamp>
      <contributor>
        <username>incubator&gt;Doc James</username>
        <id>0</id>
      </contributor>
      <origin>2047</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7091" sha1="8utzvo628tfb7w7huplybqhhl8yty9h" xml:space="preserve">{{Wp/nr/Infobox disease
| name            = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana
| image           = Skin ulcer due to leishmaniasis, hand of Central American adult 3MG0037 lores.jpg
| caption         = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni[[esandleni]]sesakhamuzi esihlala e-Amerikha
| Field           = [[Infectious disease (medical specialty)|Infectious disease]]
| pronounce       = Leishmaniasis {{IPAc-en|ˌ|l|iː|ʃ|m|ə|ˈ|n|aɪ|ə|s|ɪ|s}}&lt;br&gt;leishmaniosis {{IPAc-en|l|iː|ʃ|ˌ|m|eɪ|n|ɪ|ˈ|əʊ|s|ɪ|s}} or {{IPAc-en|l|iː|ʃ|ˌ|m|æ|n|ɪ|ˈ|əʊ|s|ɪ|s}}&lt;ref&gt;http://www.collinsdictionary.com/dictionary/english/leishmaniasis&lt;/ref&gt;
| ICD10           = {{ICD10|B|55||b|50}}
| ICD9            = {{ICD9|085}}
| DiseasesDB      = 3266
| DiseasesDB_mult = {{DiseasesDB2|29171}}&lt;!--  {{DiseasesDB2|3266}} {{DiseasesDB2|7070}} --&gt;
| MedlinePlus     = 001386
| eMedicineSubj   = emerg
| eMedicineTopic  = 296
| MeshID          = D007896
}}
''' iLitjhimanisi '''ungayibiza uthi'''yilitjhimanisi''', bulwelwe [[obubangwa]] silwanyana esincani [[esibizwa ngokuthi]]yi-phrotozowa ephila ngokuhlala kezinye iinlwana/abantu bona iphile [[itheleleka]] ngokulunywa [[mhlobo othize wengogwana]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu bungavela ngeendlela ezintathu: [[Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni| ukulunywa yingogwana esikhunjeni]] ukutheleleka esikhumbeni nomzimba woke, nofana[[ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali ]].&lt;ref name=WHO2014&gt;{{cite web|title=Leishmaniasis Fact sheet N°375|url=http://www.who.int/mediacentre/factsheets/fs375/en/|work=World Health Organization|accessdate=17 February 2014|date=January 2014}}&lt;/ref&gt; Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni benza umuntu avele isilonda sangaphakathi esikhunjeni, bese ukutheleleka esikhumbeni nomzimba woke kubonakala lokha sele itheleleka esikhumbeni yenze isilonda emlonyeni kanye nepumulweni, bese iLitjhimanisi nasele isezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni ibonakala ngesilonda esingendeni esiphathisa ihloko nomgomani, ibangela namasotja womzimba abe bovu, kanye nokuvuvukisa isibindi. &lt;ref name=WHO2014/&gt;&lt;ref name=Barrett2012/&gt;

&lt;!-- Cause and diagnosis --&gt;
Kunemihlobohlobo ema-20 yeengogwana &quot;zeLitjhimaniya&quot; ezibamba abantu abaphilako&lt;ref name=WHO2014/&gt; Unobangela wobulwelwe lobu nobungozi babo bufaka hlangana ubuchaka, ukungadli ukudla okunepilo, ukususwa nokutjhiswa kwamahlathi, kanye nokuthutha kwabantu bayokuhlala emadorobhei khulu.&lt;ref name=WHO2014/&gt; Yoke imihlobo emithathu yobulwelwe lobu bungabonwa ngesilwanyana nofana ingogwana ephila ngezinye iinlwana kwaphela ngokusetjenziswa komtjhini onerhalasi okhulisa izinto ezincani zibe zikulu.&lt;ref name=WHO2014/&gt; Ukungezelela kilokho, ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali bungabonwa kwaphela ngokuhlolwa kweengazi zaloyo othelelekileko.&lt;ref name=Barrett2012/&gt;

&lt;!-- Prevention and treatment --&gt;
Ubulwelwe iLitjhimanisi bungavikelwa ngkuthi ulale ngaphakathi kwenedi yetende[[ ethelwe ngesihlahla sokuvikela iingogwan]].&lt;ref name=WHO2014/&gt; Ezinye zeendlela zokuvikela kufaka hlangana nokufufuzela isifufuzeli sokuvikela ukulunywa ziingogwana ukwazi ukuzibulala kanye nokulatjhwa kwabantu abangenwe bulwelwe lobu kusese nesikhathi bungakasabalali umzimba woke.&lt;ref name=WHO2014/&gt; Ukulatjhwa okutlhogekako kwenziwa nange kwaziwa bona ubulwelwe lobu buthalakele kiyiphi indawo, umhlobo &quot;weLitjhiminiya&quot; kanye nehlobo lengongwana engenileko.&lt;ref name=WHO2014/&gt; Ezinye zeenhlahla ezingalapha iLitjhimanisi nasele esezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni [[ kufaka hlangana i-liposomal amphotericin B]],&lt;ref name=Sun2013/&gt; ihlanganiso le[[le-pentavalent antimonials]]kanye [[ne-}paromomycin]],&lt;ref name=Sun2013&gt;{{cite journal|last=Sundar|first=S|author2=Chakravarty, J |title=Leishmaniasis: an update of current pharmacotherapy.|journal=Expert opinion on pharmacotherapy|date=Jan 2013|volume=14|issue=1|pages=53–63|pmid=23256501|doi=10.1517/14656566.2013.755515}}&lt;/ref&gt; and [[miltefosine]].&lt;ref name=Dor2012&gt;{{cite journal|last=Dorlo|first=TP|author2=Balasegaram, M |author3=Beijnen, JH |author4= de Vries, PJ |title=Miltefosine: a review of its pharmacology and therapeutic efficacy in the treatment of leishmaniasis.|journal=The Journal of antimicrobial chemotherapy|date=Nov 2012|volume=67|issue=11|pages=2576–97|pmid=22833634|doi=10.1093/jac/dks275}}&lt;/ref&gt;iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni, yi-paramomycin[[, i-fluconazole]], nofana[[i-pentamidine]] nayo ingasebenza kuhle ukulapha.&lt;ref name=Min2007&gt;{{cite journal|last=Minodier|first=P|author2=Parola, P |title=Cutaneous leishmaniasis treatment.|journal=Travel medicine and infectious disease|date=May 2007|volume=5|issue=3|pages=150–8|pmid=17448941|doi=10.1016/j.tmaid.2006.09.004}}&lt;/ref&gt;

&lt;!-- Epidemiology --&gt;
Abantu ababalelwa eegigidini ezili-12 baphethwe bulwelwe lobu njenganje&lt;ref name=Mag&gt;{{cite web|title=Leishmaniasis Magnitude of the problem|url=http://www.who.int/leishmaniasis/burden/magnitude/burden_magnitude/en/index.html|work=World Health Organization|accessdate=17 February 2014}}&lt;/ref&gt; eenrheni ezingaba ma-98.&lt;ref name=Barrett2012&gt;{{cite journal|last=Barrett|first=MP|author2=Croft, SL |title=Management of trypanosomiasis and leishmaniasis.|journal=British medical bulletin|year=2012|volume=104|pages=175–96|pmid=23137768|doi=10.1093/bmb/lds031|pmc=3530408}}&lt;/ref&gt; Kubikwa amacala ukufikelela iingidigidi ezi-2&lt;ref name=Barrett2012/&gt; bese kuthi hlangana nama-20 weekulungwana kanye nama-50 weenkuungana zokubhubha kwabantu ngomnyaka.&lt;ref name=WHO2014/&gt;&lt;ref name=Loz2012&gt;{{cite journal|last=Lozano|first=R|title=Global and regional mortality from 235 causes of death for 20 age groups in 1990 and 2010: a systematic analysis for the Global Burden of Disease Study 2010.|journal=Lancet|date=Dec 15, 2012|volume=380|issue=9859|pages=2095–128|pmid=23245604|doi=10.1016/S0140-6736(12)61728-0}}&lt;/ref&gt; Ukubalelwa ematjhumini ama-200&amp;nbsp; iingidigidi zabantu abahlala e-Asia,Afrika,iSewula neNgaphakathi le-Amerikha, isewula yeYurobhu bahlala eendaweni lapha ubulwelwe lobu bujayelekele khona.&lt;ref name=Barrett2012/&gt;&lt;ref&gt;{{cite journal|last=Ejazi|first=SA|author2=Ali, N |title=Developments in diagnosis and treatment of visceral leishmaniasis during the last decade and future prospects.|journal=Expert review of anti-infective therapy|date=Jan 2013|volume=11|issue=1|pages=79–98|pmid=23428104|doi=10.1586/eri.12.148}}&lt;/ref&gt; I[[hlangano yeZepilo yePhasi Zombelele-WHO]]iphulelwe iintengo eziyibhadala ukuthenga iinhlahla zokulapha ubulwelwe lobu&lt;ref name=Barrett2012/&gt; Ubulwelwe lobu bungatheleleka nakezinye iinlwana ezimbalwa, ukufaka[[iLitjhimanisisi |yezinja]] kanye [[naborodo besiganga]].&lt;ref name=WHO2014/&gt;

==isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi ==
{{Wp/nr/Reflist|colwidth=25em}}</text>
      <sha1>8utzvo628tfb7w7huplybqhhl8yty9h</sha1>
    </revision>
    <revision>
      <id>2048</id>
      <parentid>2047</parentid>
      <timestamp>2016-11-04T12:22:31Z</timestamp>
      <contributor>
        <username>incubator&gt;Doc James</username>
        <id>0</id>
      </contributor>
      <origin>2048</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7091" sha1="nr85550cmb5j45p8t99k4cbzb1ruk1n" xml:space="preserve">{{Wp/nd/Infobox disease
| name            = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana
| image           = Skin ulcer due to leishmaniasis, hand of Central American adult 3MG0037 lores.jpg
| caption         = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni[[esandleni]]sesakhamuzi esihlala e-Amerikha
| Field           = [[Infectious disease (medical specialty)|Infectious disease]]
| pronounce       = Leishmaniasis {{IPAc-en|ˌ|l|iː|ʃ|m|ə|ˈ|n|aɪ|ə|s|ɪ|s}}&lt;br&gt;leishmaniosis {{IPAc-en|l|iː|ʃ|ˌ|m|eɪ|n|ɪ|ˈ|əʊ|s|ɪ|s}} or {{IPAc-en|l|iː|ʃ|ˌ|m|æ|n|ɪ|ˈ|əʊ|s|ɪ|s}}&lt;ref&gt;http://www.collinsdictionary.com/dictionary/english/leishmaniasis&lt;/ref&gt;
| ICD10           = {{ICD10|B|55||b|50}}
| ICD9            = {{ICD9|085}}
| DiseasesDB      = 3266
| DiseasesDB_mult = {{DiseasesDB2|29171}}&lt;!--  {{DiseasesDB2|3266}} {{DiseasesDB2|7070}} --&gt;
| MedlinePlus     = 001386
| eMedicineSubj   = emerg
| eMedicineTopic  = 296
| MeshID          = D007896
}}
''' iLitjhimanisi '''ungayibiza uthi'''yilitjhimanisi''', bulwelwe [[obubangwa]] silwanyana esincani [[esibizwa ngokuthi]]yi-phrotozowa ephila ngokuhlala kezinye iinlwana/abantu bona iphile [[itheleleka]] ngokulunywa [[mhlobo othize wengogwana]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu bungavela ngeendlela ezintathu: [[Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni| ukulunywa yingogwana esikhunjeni]] ukutheleleka esikhumbeni nomzimba woke, nofana[[ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali ]].&lt;ref name=WHO2014&gt;{{cite web|title=Leishmaniasis Fact sheet N°375|url=http://www.who.int/mediacentre/factsheets/fs375/en/|work=World Health Organization|accessdate=17 February 2014|date=January 2014}}&lt;/ref&gt; Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni benza umuntu avele isilonda sangaphakathi esikhunjeni, bese ukutheleleka esikhumbeni nomzimba woke kubonakala lokha sele itheleleka esikhumbeni yenze isilonda emlonyeni kanye nepumulweni, bese iLitjhimanisi nasele isezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni ibonakala ngesilonda esingendeni esiphathisa ihloko nomgomani, ibangela namasotja womzimba abe bovu, kanye nokuvuvukisa isibindi. &lt;ref name=WHO2014/&gt;&lt;ref name=Barrett2012/&gt;

&lt;!-- Cause and diagnosis --&gt;
Kunemihlobohlobo ema-20 yeengogwana &quot;zeLitjhimaniya&quot; ezibamba abantu abaphilako&lt;ref name=WHO2014/&gt; Unobangela wobulwelwe lobu nobungozi babo bufaka hlangana ubuchaka, ukungadli ukudla okunepilo, ukususwa nokutjhiswa kwamahlathi, kanye nokuthutha kwabantu bayokuhlala emadorobhei khulu.&lt;ref name=WHO2014/&gt; Yoke imihlobo emithathu yobulwelwe lobu bungabonwa ngesilwanyana nofana ingogwana ephila ngezinye iinlwana kwaphela ngokusetjenziswa komtjhini onerhalasi okhulisa izinto ezincani zibe zikulu.&lt;ref name=WHO2014/&gt; Ukungezelela kilokho, ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali bungabonwa kwaphela ngokuhlolwa kweengazi zaloyo othelelekileko.&lt;ref name=Barrett2012/&gt;

&lt;!-- Prevention and treatment --&gt;
Ubulwelwe iLitjhimanisi bungavikelwa ngkuthi ulale ngaphakathi kwenedi yetende[[ ethelwe ngesihlahla sokuvikela iingogwan]].&lt;ref name=WHO2014/&gt; Ezinye zeendlela zokuvikela kufaka hlangana nokufufuzela isifufuzeli sokuvikela ukulunywa ziingogwana ukwazi ukuzibulala kanye nokulatjhwa kwabantu abangenwe bulwelwe lobu kusese nesikhathi bungakasabalali umzimba woke.&lt;ref name=WHO2014/&gt; Ukulatjhwa okutlhogekako kwenziwa nange kwaziwa bona ubulwelwe lobu buthalakele kiyiphi indawo, umhlobo &quot;weLitjhiminiya&quot; kanye nehlobo lengongwana engenileko.&lt;ref name=WHO2014/&gt; Ezinye zeenhlahla ezingalapha iLitjhimanisi nasele esezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni [[ kufaka hlangana i-liposomal amphotericin B]],&lt;ref name=Sun2013/&gt; ihlanganiso le[[le-pentavalent antimonials]]kanye [[ne-}paromomycin]],&lt;ref name=Sun2013&gt;{{cite journal|last=Sundar|first=S|author2=Chakravarty, J |title=Leishmaniasis: an update of current pharmacotherapy.|journal=Expert opinion on pharmacotherapy|date=Jan 2013|volume=14|issue=1|pages=53–63|pmid=23256501|doi=10.1517/14656566.2013.755515}}&lt;/ref&gt; and [[miltefosine]].&lt;ref name=Dor2012&gt;{{cite journal|last=Dorlo|first=TP|author2=Balasegaram, M |author3=Beijnen, JH |author4= de Vries, PJ |title=Miltefosine: a review of its pharmacology and therapeutic efficacy in the treatment of leishmaniasis.|journal=The Journal of antimicrobial chemotherapy|date=Nov 2012|volume=67|issue=11|pages=2576–97|pmid=22833634|doi=10.1093/jac/dks275}}&lt;/ref&gt;iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni, yi-paramomycin[[, i-fluconazole]], nofana[[i-pentamidine]] nayo ingasebenza kuhle ukulapha.&lt;ref name=Min2007&gt;{{cite journal|last=Minodier|first=P|author2=Parola, P |title=Cutaneous leishmaniasis treatment.|journal=Travel medicine and infectious disease|date=May 2007|volume=5|issue=3|pages=150–8|pmid=17448941|doi=10.1016/j.tmaid.2006.09.004}}&lt;/ref&gt;

&lt;!-- Epidemiology --&gt;
Abantu ababalelwa eegigidini ezili-12 baphethwe bulwelwe lobu njenganje&lt;ref name=Mag&gt;{{cite web|title=Leishmaniasis Magnitude of the problem|url=http://www.who.int/leishmaniasis/burden/magnitude/burden_magnitude/en/index.html|work=World Health Organization|accessdate=17 February 2014}}&lt;/ref&gt; eenrheni ezingaba ma-98.&lt;ref name=Barrett2012&gt;{{cite journal|last=Barrett|first=MP|author2=Croft, SL |title=Management of trypanosomiasis and leishmaniasis.|journal=British medical bulletin|year=2012|volume=104|pages=175–96|pmid=23137768|doi=10.1093/bmb/lds031|pmc=3530408}}&lt;/ref&gt; Kubikwa amacala ukufikelela iingidigidi ezi-2&lt;ref name=Barrett2012/&gt; bese kuthi hlangana nama-20 weekulungwana kanye nama-50 weenkuungana zokubhubha kwabantu ngomnyaka.&lt;ref name=WHO2014/&gt;&lt;ref name=Loz2012&gt;{{cite journal|last=Lozano|first=R|title=Global and regional mortality from 235 causes of death for 20 age groups in 1990 and 2010: a systematic analysis for the Global Burden of Disease Study 2010.|journal=Lancet|date=Dec 15, 2012|volume=380|issue=9859|pages=2095–128|pmid=23245604|doi=10.1016/S0140-6736(12)61728-0}}&lt;/ref&gt; Ukubalelwa ematjhumini ama-200&amp;nbsp; iingidigidi zabantu abahlala e-Asia,Afrika,iSewula neNgaphakathi le-Amerikha, isewula yeYurobhu bahlala eendaweni lapha ubulwelwe lobu bujayelekele khona.&lt;ref name=Barrett2012/&gt;&lt;ref&gt;{{cite journal|last=Ejazi|first=SA|author2=Ali, N |title=Developments in diagnosis and treatment of visceral leishmaniasis during the last decade and future prospects.|journal=Expert review of anti-infective therapy|date=Jan 2013|volume=11|issue=1|pages=79–98|pmid=23428104|doi=10.1586/eri.12.148}}&lt;/ref&gt; I[[hlangano yeZepilo yePhasi Zombelele-WHO]]iphulelwe iintengo eziyibhadala ukuthenga iinhlahla zokulapha ubulwelwe lobu&lt;ref name=Barrett2012/&gt; Ubulwelwe lobu bungatheleleka nakezinye iinlwana ezimbalwa, ukufaka[[iLitjhimanisisi |yezinja]] kanye [[naborodo besiganga]].&lt;ref name=WHO2014/&gt;

==isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi ==
{{Wp/nr/Reflist|colwidth=25em}}</text>
      <sha1>nr85550cmb5j45p8t99k4cbzb1ruk1n</sha1>
    </revision>
    <revision>
      <id>2049</id>
      <parentid>2048</parentid>
      <timestamp>2016-11-08T21:12:12Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <origin>2049</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7103" sha1="81lkn3id5olo134ng5fdd9k4r8yohbd" xml:space="preserve">{{Wp/nd/Infobox disease
| name            = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana
| image           = Skin ulcer due to leishmaniasis, hand of Central American adult 3MG0037 lores.jpg
| caption         = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni[[esandleni]]sesakhamuzi esihlala e-Amerikha
| Field           = [[Infectious disease (medical specialty)|Infectious disease]]
| pronounce       = Leishmaniasis {{IPAc-en|ˌ|l|iː|ʃ|m|ə|ˈ|n|aɪ|ə|s|ɪ|s}}&lt;br&gt;leishmaniosis {{IPAc-en|l|iː|ʃ|ˌ|m|eɪ|n|ɪ|ˈ|əʊ|s|ɪ|s}} or {{IPAc-en|l|iː|ʃ|ˌ|m|æ|n|ɪ|ˈ|əʊ|s|ɪ|s}}&lt;ref&gt;http://www.collinsdictionary.com/dictionary/english/leishmaniasis&lt;/ref&gt;
| ICD10           = {{Wp/nd/ICD10|B|55||b|50}}
| ICD9            = {{Wp/nd/ICD9|085}}
| DiseasesDB      = 3266
| DiseasesDB_mult = {{DiseasesDB2|29171}}&lt;!--  {{DiseasesDB2|3266}} {{DiseasesDB2|7070}} --&gt;
| MedlinePlus     = 001386
| eMedicineSubj   = emerg
| eMedicineTopic  = 296
| MeshID          = D007896
}}
''' iLitjhimanisi '''ungayibiza uthi'''yilitjhimanisi''', bulwelwe [[obubangwa]] silwanyana esincani [[esibizwa ngokuthi]]yi-phrotozowa ephila ngokuhlala kezinye iinlwana/abantu bona iphile [[itheleleka]] ngokulunywa [[mhlobo othize wengogwana]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu bungavela ngeendlela ezintathu: [[Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni| ukulunywa yingogwana esikhunjeni]] ukutheleleka esikhumbeni nomzimba woke, nofana[[ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali ]].&lt;ref name=WHO2014&gt;{{cite web|title=Leishmaniasis Fact sheet N°375|url=http://www.who.int/mediacentre/factsheets/fs375/en/|work=World Health Organization|accessdate=17 February 2014|date=January 2014}}&lt;/ref&gt; Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni benza umuntu avele isilonda sangaphakathi esikhunjeni, bese ukutheleleka esikhumbeni nomzimba woke kubonakala lokha sele itheleleka esikhumbeni yenze isilonda emlonyeni kanye nepumulweni, bese iLitjhimanisi nasele isezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni ibonakala ngesilonda esingendeni esiphathisa ihloko nomgomani, ibangela namasotja womzimba abe bovu, kanye nokuvuvukisa isibindi. &lt;ref name=WHO2014/&gt;&lt;ref name=Barrett2012/&gt;

&lt;!-- Cause and diagnosis --&gt;
Kunemihlobohlobo ema-20 yeengogwana &quot;zeLitjhimaniya&quot; ezibamba abantu abaphilako&lt;ref name=WHO2014/&gt; Unobangela wobulwelwe lobu nobungozi babo bufaka hlangana ubuchaka, ukungadli ukudla okunepilo, ukususwa nokutjhiswa kwamahlathi, kanye nokuthutha kwabantu bayokuhlala emadorobhei khulu.&lt;ref name=WHO2014/&gt; Yoke imihlobo emithathu yobulwelwe lobu bungabonwa ngesilwanyana nofana ingogwana ephila ngezinye iinlwana kwaphela ngokusetjenziswa komtjhini onerhalasi okhulisa izinto ezincani zibe zikulu.&lt;ref name=WHO2014/&gt; Ukungezelela kilokho, ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali bungabonwa kwaphela ngokuhlolwa kweengazi zaloyo othelelekileko.&lt;ref name=Barrett2012/&gt;

&lt;!-- Prevention and treatment --&gt;
Ubulwelwe iLitjhimanisi bungavikelwa ngkuthi ulale ngaphakathi kwenedi yetende[[ ethelwe ngesihlahla sokuvikela iingogwan]].&lt;ref name=WHO2014/&gt; Ezinye zeendlela zokuvikela kufaka hlangana nokufufuzela isifufuzeli sokuvikela ukulunywa ziingogwana ukwazi ukuzibulala kanye nokulatjhwa kwabantu abangenwe bulwelwe lobu kusese nesikhathi bungakasabalali umzimba woke.&lt;ref name=WHO2014/&gt; Ukulatjhwa okutlhogekako kwenziwa nange kwaziwa bona ubulwelwe lobu buthalakele kiyiphi indawo, umhlobo &quot;weLitjhiminiya&quot; kanye nehlobo lengongwana engenileko.&lt;ref name=WHO2014/&gt; Ezinye zeenhlahla ezingalapha iLitjhimanisi nasele esezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni [[ kufaka hlangana i-liposomal amphotericin B]],&lt;ref name=Sun2013/&gt; ihlanganiso le[[le-pentavalent antimonials]]kanye [[ne-}paromomycin]],&lt;ref name=Sun2013&gt;{{cite journal|last=Sundar|first=S|author2=Chakravarty, J |title=Leishmaniasis: an update of current pharmacotherapy.|journal=Expert opinion on pharmacotherapy|date=Jan 2013|volume=14|issue=1|pages=53–63|pmid=23256501|doi=10.1517/14656566.2013.755515}}&lt;/ref&gt; and [[miltefosine]].&lt;ref name=Dor2012&gt;{{cite journal|last=Dorlo|first=TP|author2=Balasegaram, M |author3=Beijnen, JH |author4= de Vries, PJ |title=Miltefosine: a review of its pharmacology and therapeutic efficacy in the treatment of leishmaniasis.|journal=The Journal of antimicrobial chemotherapy|date=Nov 2012|volume=67|issue=11|pages=2576–97|pmid=22833634|doi=10.1093/jac/dks275}}&lt;/ref&gt;iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni, yi-paramomycin[[, i-fluconazole]], nofana[[i-pentamidine]] nayo ingasebenza kuhle ukulapha.&lt;ref name=Min2007&gt;{{cite journal|last=Minodier|first=P|author2=Parola, P |title=Cutaneous leishmaniasis treatment.|journal=Travel medicine and infectious disease|date=May 2007|volume=5|issue=3|pages=150–8|pmid=17448941|doi=10.1016/j.tmaid.2006.09.004}}&lt;/ref&gt;

&lt;!-- Epidemiology --&gt;
Abantu ababalelwa eegigidini ezili-12 baphethwe bulwelwe lobu njenganje&lt;ref name=Mag&gt;{{cite web|title=Leishmaniasis Magnitude of the problem|url=http://www.who.int/leishmaniasis/burden/magnitude/burden_magnitude/en/index.html|work=World Health Organization|accessdate=17 February 2014}}&lt;/ref&gt; eenrheni ezingaba ma-98.&lt;ref name=Barrett2012&gt;{{cite journal|last=Barrett|first=MP|author2=Croft, SL |title=Management of trypanosomiasis and leishmaniasis.|journal=British medical bulletin|year=2012|volume=104|pages=175–96|pmid=23137768|doi=10.1093/bmb/lds031|pmc=3530408}}&lt;/ref&gt; Kubikwa amacala ukufikelela iingidigidi ezi-2&lt;ref name=Barrett2012/&gt; bese kuthi hlangana nama-20 weekulungwana kanye nama-50 weenkuungana zokubhubha kwabantu ngomnyaka.&lt;ref name=WHO2014/&gt;&lt;ref name=Loz2012&gt;{{cite journal|last=Lozano|first=R|title=Global and regional mortality from 235 causes of death for 20 age groups in 1990 and 2010: a systematic analysis for the Global Burden of Disease Study 2010.|journal=Lancet|date=Dec 15, 2012|volume=380|issue=9859|pages=2095–128|pmid=23245604|doi=10.1016/S0140-6736(12)61728-0}}&lt;/ref&gt; Ukubalelwa ematjhumini ama-200&amp;nbsp; iingidigidi zabantu abahlala e-Asia,Afrika,iSewula neNgaphakathi le-Amerikha, isewula yeYurobhu bahlala eendaweni lapha ubulwelwe lobu bujayelekele khona.&lt;ref name=Barrett2012/&gt;&lt;ref&gt;{{cite journal|last=Ejazi|first=SA|author2=Ali, N |title=Developments in diagnosis and treatment of visceral leishmaniasis during the last decade and future prospects.|journal=Expert review of anti-infective therapy|date=Jan 2013|volume=11|issue=1|pages=79–98|pmid=23428104|doi=10.1586/eri.12.148}}&lt;/ref&gt; I[[hlangano yeZepilo yePhasi Zombelele-WHO]]iphulelwe iintengo eziyibhadala ukuthenga iinhlahla zokulapha ubulwelwe lobu&lt;ref name=Barrett2012/&gt; Ubulwelwe lobu bungatheleleka nakezinye iinlwana ezimbalwa, ukufaka[[iLitjhimanisisi |yezinja]] kanye [[naborodo besiganga]].&lt;ref name=WHO2014/&gt;

==isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi ==
{{Wp/nr/Reflist|colwidth=25em}}</text>
      <sha1>81lkn3id5olo134ng5fdd9k4r8yohbd</sha1>
    </revision>
    <revision>
      <id>2050</id>
      <parentid>2049</parentid>
      <timestamp>2016-11-09T15:15:48Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <origin>2050</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7151" sha1="qe7jjfr5sgb5uws912o2476nga1vnbu" xml:space="preserve">{{Wp/nd/Infobox disease
| name            = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana
| image           = Skin ulcer due to leishmaniasis, hand of Central American adult 3MG0037 lores.jpg
| caption         = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni[[esandleni]]sesakhamuzi esihlala e-Amerikha
| Field           = [[Infectious disease (medical specialty)|Infectious disease]]
| pronounce       = Leishmaniasis {{IPAc-en|ˌ|l|iː|ʃ|m|ə|ˈ|n|aɪ|ə|s|ɪ|s}}&lt;br&gt;leishmaniosis {{IPAc-en|l|iː|ʃ|ˌ|m|eɪ|n|ɪ|ˈ|əʊ|s|ɪ|s}} or {{IPAc-en|l|iː|ʃ|ˌ|m|æ|n|ɪ|ˈ|əʊ|s|ɪ|s}}&lt;ref&gt;http://www.collinsdictionary.com/dictionary/english/leishmaniasis&lt;/ref&gt;
| ICD10           = {{Wp/nd/ICD10|B|55||b|50}}
| ICD9            = {{Wp/nd/ICD9|085}}
| DiseasesDB      = 3266
| DiseasesDB_mult = {{DiseasesDB2|29171}}&lt;!--  {{DiseasesDB2|3266}} {{DiseasesDB2|7070}} --&gt;
| MedlinePlus     = 001386
| eMedicineSubj   = emerg
| eMedicineTopic  = 296
| MeshID          = D007896
}}
''' iLitjhimanisi '''ungayibiza uthi'''yilitjhimanisi''', bulwelwe [[obubangwa]] silwanyana esincani [[esibizwa ngokuthi]]yi-phrotozowa ephila ngokuhlala kezinye iinlwana/abantu bona iphile [[itheleleka]] ngokulunywa [[mhlobo othize wengogwana]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu bungavela ngeendlela ezintathu: [[Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni| ukulunywa yingogwana esikhunjeni]] ukutheleleka esikhumbeni nomzimba woke, nofana[[ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali ]].&lt;ref name=WHO2014&gt;{{Wp/nd/cite web|title=Leishmaniasis Fact sheet N°375|url=http://www.who.int/mediacentre/factsheets/fs375/en/|work=World Health Organization|accessdate=17 February 2014|date=January 2014}}&lt;/ref&gt; Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni benza umuntu avele isilonda sangaphakathi esikhunjeni, bese ukutheleleka esikhumbeni nomzimba woke kubonakala lokha sele itheleleka esikhumbeni yenze isilonda emlonyeni kanye nepumulweni, bese iLitjhimanisi nasele isezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni ibonakala ngesilonda esingendeni esiphathisa ihloko nomgomani, ibangela namasotja womzimba abe bovu, kanye nokuvuvukisa isibindi. &lt;ref name=WHO2014/&gt;&lt;ref name=Barrett2012/&gt;

&lt;!-- Cause and diagnosis --&gt;
Kunemihlobohlobo ema-20 yeengogwana &quot;zeLitjhimaniya&quot; ezibamba abantu abaphilako&lt;ref name=WHO2014/&gt; Unobangela wobulwelwe lobu nobungozi babo bufaka hlangana ubuchaka, ukungadli ukudla okunepilo, ukususwa nokutjhiswa kwamahlathi, kanye nokuthutha kwabantu bayokuhlala emadorobhei khulu.&lt;ref name=WHO2014/&gt; Yoke imihlobo emithathu yobulwelwe lobu bungabonwa ngesilwanyana nofana ingogwana ephila ngezinye iinlwana kwaphela ngokusetjenziswa komtjhini onerhalasi okhulisa izinto ezincani zibe zikulu.&lt;ref name=WHO2014/&gt; Ukungezelela kilokho, ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali bungabonwa kwaphela ngokuhlolwa kweengazi zaloyo othelelekileko.&lt;ref name=Barrett2012/&gt;

&lt;!-- Prevention and treatment --&gt;
Ubulwelwe iLitjhimanisi bungavikelwa ngkuthi ulale ngaphakathi kwenedi yetende[[ ethelwe ngesihlahla sokuvikela iingogwan]].&lt;ref name=WHO2014/&gt; Ezinye zeendlela zokuvikela kufaka hlangana nokufufuzela isifufuzeli sokuvikela ukulunywa ziingogwana ukwazi ukuzibulala kanye nokulatjhwa kwabantu abangenwe bulwelwe lobu kusese nesikhathi bungakasabalali umzimba woke.&lt;ref name=WHO2014/&gt; Ukulatjhwa okutlhogekako kwenziwa nange kwaziwa bona ubulwelwe lobu buthalakele kiyiphi indawo, umhlobo &quot;weLitjhiminiya&quot; kanye nehlobo lengongwana engenileko.&lt;ref name=WHO2014/&gt; Ezinye zeenhlahla ezingalapha iLitjhimanisi nasele esezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni [[ kufaka hlangana i-liposomal amphotericin B]],&lt;ref name=Sun2013/&gt; ihlanganiso le[[le-pentavalent antimonials]]kanye [[ne-}paromomycin]],&lt;ref name=Sun2013&gt;{{Wp/nd/cite journal|last=Sundar|first=S|author2=Chakravarty, J |title=Leishmaniasis: an update of current pharmacotherapy.|journal=Expert opinion on pharmacotherapy|date=Jan 2013|volume=14|issue=1|pages=53–63|pmid=23256501|doi=10.1517/14656566.2013.755515}}&lt;/ref&gt; and [[miltefosine]].&lt;ref name=Dor2012&gt;{{Wp/nd/cite journal|last=Dorlo|first=TP|author2=Balasegaram, M |author3=Beijnen, JH |author4= de Vries, PJ |title=Miltefosine: a review of its pharmacology and therapeutic efficacy in the treatment of leishmaniasis.|journal=The Journal of antimicrobial chemotherapy|date=Nov 2012|volume=67|issue=11|pages=2576–97|pmid=22833634|doi=10.1093/jac/dks275}}&lt;/ref&gt;iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni, yi-paramomycin[[, i-fluconazole]], nofana[[i-pentamidine]] nayo ingasebenza kuhle ukulapha.&lt;ref name=Min2007&gt;{{Wp/nd/cite journal|last=Minodier|first=P|author2=Parola, P |title=Cutaneous leishmaniasis treatment.|journal=Travel medicine and infectious disease|date=May 2007|volume=5|issue=3|pages=150–8|pmid=17448941|doi=10.1016/j.tmaid.2006.09.004}}&lt;/ref&gt;

&lt;!-- Epidemiology --&gt;
Abantu ababalelwa eegigidini ezili-12 baphethwe bulwelwe lobu njenganje&lt;ref name=Mag&gt;{{Wp/nd/cite web|title=Leishmaniasis Magnitude of the problem|url=http://www.who.int/leishmaniasis/burden/magnitude/burden_magnitude/en/index.html|work=World Health Organization|accessdate=17 February 2014}}&lt;/ref&gt; eenrheni ezingaba ma-98.&lt;ref name=Barrett2012&gt;{{Wp/nd/cite journal|last=Barrett|first=MP|author2=Croft, SL |title=Management of trypanosomiasis and leishmaniasis.|journal=British medical bulletin|year=2012|volume=104|pages=175–96|pmid=23137768|doi=10.1093/bmb/lds031|pmc=3530408}}&lt;/ref&gt; Kubikwa amacala ukufikelela iingidigidi ezi-2&lt;ref name=Barrett2012/&gt; bese kuthi hlangana nama-20 weekulungwana kanye nama-50 weenkuungana zokubhubha kwabantu ngomnyaka.&lt;ref name=WHO2014/&gt;&lt;ref name=Loz2012&gt;{{Wp/nd/cite journal|last=Lozano|first=R|title=Global and regional mortality from 235 causes of death for 20 age groups in 1990 and 2010: a systematic analysis for the Global Burden of Disease Study 2010.|journal=Lancet|date=Dec 15, 2012|volume=380|issue=9859|pages=2095–128|pmid=23245604|doi=10.1016/S0140-6736(12)61728-0}}&lt;/ref&gt; Ukubalelwa ematjhumini ama-200&amp;nbsp; iingidigidi zabantu abahlala e-Asia,Afrika,iSewula neNgaphakathi le-Amerikha, isewula yeYurobhu bahlala eendaweni lapha ubulwelwe lobu bujayelekele khona.&lt;ref name=Barrett2012/&gt;&lt;ref&gt;{{Wp/nd/cite journal|last=Ejazi|first=SA|author2=Ali, N |title=Developments in diagnosis and treatment of visceral leishmaniasis during the last decade and future prospects.|journal=Expert review of anti-infective therapy|date=Jan 2013|volume=11|issue=1|pages=79–98|pmid=23428104|doi=10.1586/eri.12.148}}&lt;/ref&gt; I[[hlangano yeZepilo yePhasi Zombelele-WHO]]iphulelwe iintengo eziyibhadala ukuthenga iinhlahla zokulapha ubulwelwe lobu&lt;ref name=Barrett2012/&gt; Ubulwelwe lobu bungatheleleka nakezinye iinlwana ezimbalwa, ukufaka[[iLitjhimanisisi |yezinja]] kanye [[naborodo besiganga]].&lt;ref name=WHO2014/&gt;

==isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi ==
{{Wp/nr/Reflist|colwidth=25em}}</text>
      <sha1>qe7jjfr5sgb5uws912o2476nga1vnbu</sha1>
    </revision>
    <revision>
      <id>2051</id>
      <parentid>2050</parentid>
      <timestamp>2022-04-26T16:55:42Z</timestamp>
      <contributor>
        <username>JhsBot</username>
        <id>34</id>
      </contributor>
      <minor />
      <comment>JhsBot moved page [[Wp/nd/iLitjhimanisi]] to [[Wp/nd/ILitjhimanisi]]: bot: Moving pages with (what would be) lowercase titles to uppercase</comment>
      <origin>2050</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7151" sha1="qe7jjfr5sgb5uws912o2476nga1vnbu" xml:space="preserve">{{Wp/nd/Infobox disease
| name            = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana
| image           = Skin ulcer due to leishmaniasis, hand of Central American adult 3MG0037 lores.jpg
| caption         = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni[[esandleni]]sesakhamuzi esihlala e-Amerikha
| Field           = [[Infectious disease (medical specialty)|Infectious disease]]
| pronounce       = Leishmaniasis {{IPAc-en|ˌ|l|iː|ʃ|m|ə|ˈ|n|aɪ|ə|s|ɪ|s}}&lt;br&gt;leishmaniosis {{IPAc-en|l|iː|ʃ|ˌ|m|eɪ|n|ɪ|ˈ|əʊ|s|ɪ|s}} or {{IPAc-en|l|iː|ʃ|ˌ|m|æ|n|ɪ|ˈ|əʊ|s|ɪ|s}}&lt;ref&gt;http://www.collinsdictionary.com/dictionary/english/leishmaniasis&lt;/ref&gt;
| ICD10           = {{Wp/nd/ICD10|B|55||b|50}}
| ICD9            = {{Wp/nd/ICD9|085}}
| DiseasesDB      = 3266
| DiseasesDB_mult = {{DiseasesDB2|29171}}&lt;!--  {{DiseasesDB2|3266}} {{DiseasesDB2|7070}} --&gt;
| MedlinePlus     = 001386
| eMedicineSubj   = emerg
| eMedicineTopic  = 296
| MeshID          = D007896
}}
''' iLitjhimanisi '''ungayibiza uthi'''yilitjhimanisi''', bulwelwe [[obubangwa]] silwanyana esincani [[esibizwa ngokuthi]]yi-phrotozowa ephila ngokuhlala kezinye iinlwana/abantu bona iphile [[itheleleka]] ngokulunywa [[mhlobo othize wengogwana]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu bungavela ngeendlela ezintathu: [[Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni| ukulunywa yingogwana esikhunjeni]] ukutheleleka esikhumbeni nomzimba woke, nofana[[ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali ]].&lt;ref name=WHO2014&gt;{{Wp/nd/cite web|title=Leishmaniasis Fact sheet N°375|url=http://www.who.int/mediacentre/factsheets/fs375/en/|work=World Health Organization|accessdate=17 February 2014|date=January 2014}}&lt;/ref&gt; Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni benza umuntu avele isilonda sangaphakathi esikhunjeni, bese ukutheleleka esikhumbeni nomzimba woke kubonakala lokha sele itheleleka esikhumbeni yenze isilonda emlonyeni kanye nepumulweni, bese iLitjhimanisi nasele isezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni ibonakala ngesilonda esingendeni esiphathisa ihloko nomgomani, ibangela namasotja womzimba abe bovu, kanye nokuvuvukisa isibindi. &lt;ref name=WHO2014/&gt;&lt;ref name=Barrett2012/&gt;

&lt;!-- Cause and diagnosis --&gt;
Kunemihlobohlobo ema-20 yeengogwana &quot;zeLitjhimaniya&quot; ezibamba abantu abaphilako&lt;ref name=WHO2014/&gt; Unobangela wobulwelwe lobu nobungozi babo bufaka hlangana ubuchaka, ukungadli ukudla okunepilo, ukususwa nokutjhiswa kwamahlathi, kanye nokuthutha kwabantu bayokuhlala emadorobhei khulu.&lt;ref name=WHO2014/&gt; Yoke imihlobo emithathu yobulwelwe lobu bungabonwa ngesilwanyana nofana ingogwana ephila ngezinye iinlwana kwaphela ngokusetjenziswa komtjhini onerhalasi okhulisa izinto ezincani zibe zikulu.&lt;ref name=WHO2014/&gt; Ukungezelela kilokho, ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali bungabonwa kwaphela ngokuhlolwa kweengazi zaloyo othelelekileko.&lt;ref name=Barrett2012/&gt;

&lt;!-- Prevention and treatment --&gt;
Ubulwelwe iLitjhimanisi bungavikelwa ngkuthi ulale ngaphakathi kwenedi yetende[[ ethelwe ngesihlahla sokuvikela iingogwan]].&lt;ref name=WHO2014/&gt; Ezinye zeendlela zokuvikela kufaka hlangana nokufufuzela isifufuzeli sokuvikela ukulunywa ziingogwana ukwazi ukuzibulala kanye nokulatjhwa kwabantu abangenwe bulwelwe lobu kusese nesikhathi bungakasabalali umzimba woke.&lt;ref name=WHO2014/&gt; Ukulatjhwa okutlhogekako kwenziwa nange kwaziwa bona ubulwelwe lobu buthalakele kiyiphi indawo, umhlobo &quot;weLitjhiminiya&quot; kanye nehlobo lengongwana engenileko.&lt;ref name=WHO2014/&gt; Ezinye zeenhlahla ezingalapha iLitjhimanisi nasele esezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni [[ kufaka hlangana i-liposomal amphotericin B]],&lt;ref name=Sun2013/&gt; ihlanganiso le[[le-pentavalent antimonials]]kanye [[ne-}paromomycin]],&lt;ref name=Sun2013&gt;{{Wp/nd/cite journal|last=Sundar|first=S|author2=Chakravarty, J |title=Leishmaniasis: an update of current pharmacotherapy.|journal=Expert opinion on pharmacotherapy|date=Jan 2013|volume=14|issue=1|pages=53–63|pmid=23256501|doi=10.1517/14656566.2013.755515}}&lt;/ref&gt; and [[miltefosine]].&lt;ref name=Dor2012&gt;{{Wp/nd/cite journal|last=Dorlo|first=TP|author2=Balasegaram, M |author3=Beijnen, JH |author4= de Vries, PJ |title=Miltefosine: a review of its pharmacology and therapeutic efficacy in the treatment of leishmaniasis.|journal=The Journal of antimicrobial chemotherapy|date=Nov 2012|volume=67|issue=11|pages=2576–97|pmid=22833634|doi=10.1093/jac/dks275}}&lt;/ref&gt;iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni, yi-paramomycin[[, i-fluconazole]], nofana[[i-pentamidine]] nayo ingasebenza kuhle ukulapha.&lt;ref name=Min2007&gt;{{Wp/nd/cite journal|last=Minodier|first=P|author2=Parola, P |title=Cutaneous leishmaniasis treatment.|journal=Travel medicine and infectious disease|date=May 2007|volume=5|issue=3|pages=150–8|pmid=17448941|doi=10.1016/j.tmaid.2006.09.004}}&lt;/ref&gt;

&lt;!-- Epidemiology --&gt;
Abantu ababalelwa eegigidini ezili-12 baphethwe bulwelwe lobu njenganje&lt;ref name=Mag&gt;{{Wp/nd/cite web|title=Leishmaniasis Magnitude of the problem|url=http://www.who.int/leishmaniasis/burden/magnitude/burden_magnitude/en/index.html|work=World Health Organization|accessdate=17 February 2014}}&lt;/ref&gt; eenrheni ezingaba ma-98.&lt;ref name=Barrett2012&gt;{{Wp/nd/cite journal|last=Barrett|first=MP|author2=Croft, SL |title=Management of trypanosomiasis and leishmaniasis.|journal=British medical bulletin|year=2012|volume=104|pages=175–96|pmid=23137768|doi=10.1093/bmb/lds031|pmc=3530408}}&lt;/ref&gt; Kubikwa amacala ukufikelela iingidigidi ezi-2&lt;ref name=Barrett2012/&gt; bese kuthi hlangana nama-20 weekulungwana kanye nama-50 weenkuungana zokubhubha kwabantu ngomnyaka.&lt;ref name=WHO2014/&gt;&lt;ref name=Loz2012&gt;{{Wp/nd/cite journal|last=Lozano|first=R|title=Global and regional mortality from 235 causes of death for 20 age groups in 1990 and 2010: a systematic analysis for the Global Burden of Disease Study 2010.|journal=Lancet|date=Dec 15, 2012|volume=380|issue=9859|pages=2095–128|pmid=23245604|doi=10.1016/S0140-6736(12)61728-0}}&lt;/ref&gt; Ukubalelwa ematjhumini ama-200&amp;nbsp; iingidigidi zabantu abahlala e-Asia,Afrika,iSewula neNgaphakathi le-Amerikha, isewula yeYurobhu bahlala eendaweni lapha ubulwelwe lobu bujayelekele khona.&lt;ref name=Barrett2012/&gt;&lt;ref&gt;{{Wp/nd/cite journal|last=Ejazi|first=SA|author2=Ali, N |title=Developments in diagnosis and treatment of visceral leishmaniasis during the last decade and future prospects.|journal=Expert review of anti-infective therapy|date=Jan 2013|volume=11|issue=1|pages=79–98|pmid=23428104|doi=10.1586/eri.12.148}}&lt;/ref&gt; I[[hlangano yeZepilo yePhasi Zombelele-WHO]]iphulelwe iintengo eziyibhadala ukuthenga iinhlahla zokulapha ubulwelwe lobu&lt;ref name=Barrett2012/&gt; Ubulwelwe lobu bungatheleleka nakezinye iinlwana ezimbalwa, ukufaka[[iLitjhimanisisi |yezinja]] kanye [[naborodo besiganga]].&lt;ref name=WHO2014/&gt;

==isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi ==
{{Wp/nr/Reflist|colwidth=25em}}</text>
      <sha1>qe7jjfr5sgb5uws912o2476nga1vnbu</sha1>
    </revision>
    <revision>
      <id>2052</id>
      <parentid>2051</parentid>
      <timestamp>2022-05-13T22:11:50Z</timestamp>
      <contributor>
        <username>incubator&gt;1234qwer1234qwer4</username>
        <id>0</id>
      </contributor>
      <minor />
      <comment>+[[Category:Wp/nd]]; [[toolforge:quickcategories/batch/4630/|QuickCategories batch #4630]]</comment>
      <origin>2052</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7170" sha1="12k4p23rnkos4x2iu3k71481sqo4jaz" xml:space="preserve">{{Wp/nd/Infobox disease
| name            = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana
| image           = Skin ulcer due to leishmaniasis, hand of Central American adult 3MG0037 lores.jpg
| caption         = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni[[esandleni]]sesakhamuzi esihlala e-Amerikha
| Field           = [[Infectious disease (medical specialty)|Infectious disease]]
| pronounce       = Leishmaniasis {{IPAc-en|ˌ|l|iː|ʃ|m|ə|ˈ|n|aɪ|ə|s|ɪ|s}}&lt;br&gt;leishmaniosis {{IPAc-en|l|iː|ʃ|ˌ|m|eɪ|n|ɪ|ˈ|əʊ|s|ɪ|s}} or {{IPAc-en|l|iː|ʃ|ˌ|m|æ|n|ɪ|ˈ|əʊ|s|ɪ|s}}&lt;ref&gt;http://www.collinsdictionary.com/dictionary/english/leishmaniasis&lt;/ref&gt;
| ICD10           = {{Wp/nd/ICD10|B|55||b|50}}
| ICD9            = {{Wp/nd/ICD9|085}}
| DiseasesDB      = 3266
| DiseasesDB_mult = {{DiseasesDB2|29171}}&lt;!--  {{DiseasesDB2|3266}} {{DiseasesDB2|7070}} --&gt;
| MedlinePlus     = 001386
| eMedicineSubj   = emerg
| eMedicineTopic  = 296
| MeshID          = D007896
}}
''' iLitjhimanisi '''ungayibiza uthi'''yilitjhimanisi''', bulwelwe [[obubangwa]] silwanyana esincani [[esibizwa ngokuthi]]yi-phrotozowa ephila ngokuhlala kezinye iinlwana/abantu bona iphile [[itheleleka]] ngokulunywa [[mhlobo othize wengogwana]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu bungavela ngeendlela ezintathu: [[Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni| ukulunywa yingogwana esikhunjeni]] ukutheleleka esikhumbeni nomzimba woke, nofana[[ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali ]].&lt;ref name=WHO2014&gt;{{Wp/nd/cite web|title=Leishmaniasis Fact sheet N°375|url=http://www.who.int/mediacentre/factsheets/fs375/en/|work=World Health Organization|accessdate=17 February 2014|date=January 2014}}&lt;/ref&gt; Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni benza umuntu avele isilonda sangaphakathi esikhunjeni, bese ukutheleleka esikhumbeni nomzimba woke kubonakala lokha sele itheleleka esikhumbeni yenze isilonda emlonyeni kanye nepumulweni, bese iLitjhimanisi nasele isezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni ibonakala ngesilonda esingendeni esiphathisa ihloko nomgomani, ibangela namasotja womzimba abe bovu, kanye nokuvuvukisa isibindi. &lt;ref name=WHO2014/&gt;&lt;ref name=Barrett2012/&gt;

&lt;!-- Cause and diagnosis --&gt;
Kunemihlobohlobo ema-20 yeengogwana &quot;zeLitjhimaniya&quot; ezibamba abantu abaphilako&lt;ref name=WHO2014/&gt; Unobangela wobulwelwe lobu nobungozi babo bufaka hlangana ubuchaka, ukungadli ukudla okunepilo, ukususwa nokutjhiswa kwamahlathi, kanye nokuthutha kwabantu bayokuhlala emadorobhei khulu.&lt;ref name=WHO2014/&gt; Yoke imihlobo emithathu yobulwelwe lobu bungabonwa ngesilwanyana nofana ingogwana ephila ngezinye iinlwana kwaphela ngokusetjenziswa komtjhini onerhalasi okhulisa izinto ezincani zibe zikulu.&lt;ref name=WHO2014/&gt; Ukungezelela kilokho, ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali bungabonwa kwaphela ngokuhlolwa kweengazi zaloyo othelelekileko.&lt;ref name=Barrett2012/&gt;

&lt;!-- Prevention and treatment --&gt;
Ubulwelwe iLitjhimanisi bungavikelwa ngkuthi ulale ngaphakathi kwenedi yetende[[ ethelwe ngesihlahla sokuvikela iingogwan]].&lt;ref name=WHO2014/&gt; Ezinye zeendlela zokuvikela kufaka hlangana nokufufuzela isifufuzeli sokuvikela ukulunywa ziingogwana ukwazi ukuzibulala kanye nokulatjhwa kwabantu abangenwe bulwelwe lobu kusese nesikhathi bungakasabalali umzimba woke.&lt;ref name=WHO2014/&gt; Ukulatjhwa okutlhogekako kwenziwa nange kwaziwa bona ubulwelwe lobu buthalakele kiyiphi indawo, umhlobo &quot;weLitjhiminiya&quot; kanye nehlobo lengongwana engenileko.&lt;ref name=WHO2014/&gt; Ezinye zeenhlahla ezingalapha iLitjhimanisi nasele esezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni [[ kufaka hlangana i-liposomal amphotericin B]],&lt;ref name=Sun2013/&gt; ihlanganiso le[[le-pentavalent antimonials]]kanye [[ne-}paromomycin]],&lt;ref name=Sun2013&gt;{{Wp/nd/cite journal|last=Sundar|first=S|author2=Chakravarty, J |title=Leishmaniasis: an update of current pharmacotherapy.|journal=Expert opinion on pharmacotherapy|date=Jan 2013|volume=14|issue=1|pages=53–63|pmid=23256501|doi=10.1517/14656566.2013.755515}}&lt;/ref&gt; and [[miltefosine]].&lt;ref name=Dor2012&gt;{{Wp/nd/cite journal|last=Dorlo|first=TP|author2=Balasegaram, M |author3=Beijnen, JH |author4= de Vries, PJ |title=Miltefosine: a review of its pharmacology and therapeutic efficacy in the treatment of leishmaniasis.|journal=The Journal of antimicrobial chemotherapy|date=Nov 2012|volume=67|issue=11|pages=2576–97|pmid=22833634|doi=10.1093/jac/dks275}}&lt;/ref&gt;iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni, yi-paramomycin[[, i-fluconazole]], nofana[[i-pentamidine]] nayo ingasebenza kuhle ukulapha.&lt;ref name=Min2007&gt;{{Wp/nd/cite journal|last=Minodier|first=P|author2=Parola, P |title=Cutaneous leishmaniasis treatment.|journal=Travel medicine and infectious disease|date=May 2007|volume=5|issue=3|pages=150–8|pmid=17448941|doi=10.1016/j.tmaid.2006.09.004}}&lt;/ref&gt;

&lt;!-- Epidemiology --&gt;
Abantu ababalelwa eegigidini ezili-12 baphethwe bulwelwe lobu njenganje&lt;ref name=Mag&gt;{{Wp/nd/cite web|title=Leishmaniasis Magnitude of the problem|url=http://www.who.int/leishmaniasis/burden/magnitude/burden_magnitude/en/index.html|work=World Health Organization|accessdate=17 February 2014}}&lt;/ref&gt; eenrheni ezingaba ma-98.&lt;ref name=Barrett2012&gt;{{Wp/nd/cite journal|last=Barrett|first=MP|author2=Croft, SL |title=Management of trypanosomiasis and leishmaniasis.|journal=British medical bulletin|year=2012|volume=104|pages=175–96|pmid=23137768|doi=10.1093/bmb/lds031|pmc=3530408}}&lt;/ref&gt; Kubikwa amacala ukufikelela iingidigidi ezi-2&lt;ref name=Barrett2012/&gt; bese kuthi hlangana nama-20 weekulungwana kanye nama-50 weenkuungana zokubhubha kwabantu ngomnyaka.&lt;ref name=WHO2014/&gt;&lt;ref name=Loz2012&gt;{{Wp/nd/cite journal|last=Lozano|first=R|title=Global and regional mortality from 235 causes of death for 20 age groups in 1990 and 2010: a systematic analysis for the Global Burden of Disease Study 2010.|journal=Lancet|date=Dec 15, 2012|volume=380|issue=9859|pages=2095–128|pmid=23245604|doi=10.1016/S0140-6736(12)61728-0}}&lt;/ref&gt; Ukubalelwa ematjhumini ama-200&amp;nbsp; iingidigidi zabantu abahlala e-Asia,Afrika,iSewula neNgaphakathi le-Amerikha, isewula yeYurobhu bahlala eendaweni lapha ubulwelwe lobu bujayelekele khona.&lt;ref name=Barrett2012/&gt;&lt;ref&gt;{{Wp/nd/cite journal|last=Ejazi|first=SA|author2=Ali, N |title=Developments in diagnosis and treatment of visceral leishmaniasis during the last decade and future prospects.|journal=Expert review of anti-infective therapy|date=Jan 2013|volume=11|issue=1|pages=79–98|pmid=23428104|doi=10.1586/eri.12.148}}&lt;/ref&gt; I[[hlangano yeZepilo yePhasi Zombelele-WHO]]iphulelwe iintengo eziyibhadala ukuthenga iinhlahla zokulapha ubulwelwe lobu&lt;ref name=Barrett2012/&gt; Ubulwelwe lobu bungatheleleka nakezinye iinlwana ezimbalwa, ukufaka[[iLitjhimanisisi |yezinja]] kanye [[naborodo besiganga]].&lt;ref name=WHO2014/&gt;

==isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi ==
{{Wp/nr/Reflist|colwidth=25em}}
[[Category:Wp/nd]]</text>
      <sha1>12k4p23rnkos4x2iu3k71481sqo4jaz</sha1>
    </revision>
    <revision>
      <id>2053</id>
      <parentid>2052</parentid>
      <timestamp>2024-11-18T17:50:10Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <minor />
      <comment>11 revisions imported from [[:incubator:Wp/nd/ILitjhimanisi]]</comment>
      <origin>2052</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7170" sha1="12k4p23rnkos4x2iu3k71481sqo4jaz" xml:space="preserve">{{Wp/nd/Infobox disease
| name            = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana
| image           = Skin ulcer due to leishmaniasis, hand of Central American adult 3MG0037 lores.jpg
| caption         = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni[[esandleni]]sesakhamuzi esihlala e-Amerikha
| Field           = [[Infectious disease (medical specialty)|Infectious disease]]
| pronounce       = Leishmaniasis {{IPAc-en|ˌ|l|iː|ʃ|m|ə|ˈ|n|aɪ|ə|s|ɪ|s}}&lt;br&gt;leishmaniosis {{IPAc-en|l|iː|ʃ|ˌ|m|eɪ|n|ɪ|ˈ|əʊ|s|ɪ|s}} or {{IPAc-en|l|iː|ʃ|ˌ|m|æ|n|ɪ|ˈ|əʊ|s|ɪ|s}}&lt;ref&gt;http://www.collinsdictionary.com/dictionary/english/leishmaniasis&lt;/ref&gt;
| ICD10           = {{Wp/nd/ICD10|B|55||b|50}}
| ICD9            = {{Wp/nd/ICD9|085}}
| DiseasesDB      = 3266
| DiseasesDB_mult = {{DiseasesDB2|29171}}&lt;!--  {{DiseasesDB2|3266}} {{DiseasesDB2|7070}} --&gt;
| MedlinePlus     = 001386
| eMedicineSubj   = emerg
| eMedicineTopic  = 296
| MeshID          = D007896
}}
''' iLitjhimanisi '''ungayibiza uthi'''yilitjhimanisi''', bulwelwe [[obubangwa]] silwanyana esincani [[esibizwa ngokuthi]]yi-phrotozowa ephila ngokuhlala kezinye iinlwana/abantu bona iphile [[itheleleka]] ngokulunywa [[mhlobo othize wengogwana]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu bungavela ngeendlela ezintathu: [[Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni| ukulunywa yingogwana esikhunjeni]] ukutheleleka esikhumbeni nomzimba woke, nofana[[ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali ]].&lt;ref name=WHO2014&gt;{{Wp/nd/cite web|title=Leishmaniasis Fact sheet N°375|url=http://www.who.int/mediacentre/factsheets/fs375/en/|work=World Health Organization|accessdate=17 February 2014|date=January 2014}}&lt;/ref&gt; Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni benza umuntu avele isilonda sangaphakathi esikhunjeni, bese ukutheleleka esikhumbeni nomzimba woke kubonakala lokha sele itheleleka esikhumbeni yenze isilonda emlonyeni kanye nepumulweni, bese iLitjhimanisi nasele isezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni ibonakala ngesilonda esingendeni esiphathisa ihloko nomgomani, ibangela namasotja womzimba abe bovu, kanye nokuvuvukisa isibindi. &lt;ref name=WHO2014/&gt;&lt;ref name=Barrett2012/&gt;

&lt;!-- Cause and diagnosis --&gt;
Kunemihlobohlobo ema-20 yeengogwana &quot;zeLitjhimaniya&quot; ezibamba abantu abaphilako&lt;ref name=WHO2014/&gt; Unobangela wobulwelwe lobu nobungozi babo bufaka hlangana ubuchaka, ukungadli ukudla okunepilo, ukususwa nokutjhiswa kwamahlathi, kanye nokuthutha kwabantu bayokuhlala emadorobhei khulu.&lt;ref name=WHO2014/&gt; Yoke imihlobo emithathu yobulwelwe lobu bungabonwa ngesilwanyana nofana ingogwana ephila ngezinye iinlwana kwaphela ngokusetjenziswa komtjhini onerhalasi okhulisa izinto ezincani zibe zikulu.&lt;ref name=WHO2014/&gt; Ukungezelela kilokho, ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali bungabonwa kwaphela ngokuhlolwa kweengazi zaloyo othelelekileko.&lt;ref name=Barrett2012/&gt;

&lt;!-- Prevention and treatment --&gt;
Ubulwelwe iLitjhimanisi bungavikelwa ngkuthi ulale ngaphakathi kwenedi yetende[[ ethelwe ngesihlahla sokuvikela iingogwan]].&lt;ref name=WHO2014/&gt; Ezinye zeendlela zokuvikela kufaka hlangana nokufufuzela isifufuzeli sokuvikela ukulunywa ziingogwana ukwazi ukuzibulala kanye nokulatjhwa kwabantu abangenwe bulwelwe lobu kusese nesikhathi bungakasabalali umzimba woke.&lt;ref name=WHO2014/&gt; Ukulatjhwa okutlhogekako kwenziwa nange kwaziwa bona ubulwelwe lobu buthalakele kiyiphi indawo, umhlobo &quot;weLitjhiminiya&quot; kanye nehlobo lengongwana engenileko.&lt;ref name=WHO2014/&gt; Ezinye zeenhlahla ezingalapha iLitjhimanisi nasele esezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni [[ kufaka hlangana i-liposomal amphotericin B]],&lt;ref name=Sun2013/&gt; ihlanganiso le[[le-pentavalent antimonials]]kanye [[ne-}paromomycin]],&lt;ref name=Sun2013&gt;{{Wp/nd/cite journal|last=Sundar|first=S|author2=Chakravarty, J |title=Leishmaniasis: an update of current pharmacotherapy.|journal=Expert opinion on pharmacotherapy|date=Jan 2013|volume=14|issue=1|pages=53–63|pmid=23256501|doi=10.1517/14656566.2013.755515}}&lt;/ref&gt; and [[miltefosine]].&lt;ref name=Dor2012&gt;{{Wp/nd/cite journal|last=Dorlo|first=TP|author2=Balasegaram, M |author3=Beijnen, JH |author4= de Vries, PJ |title=Miltefosine: a review of its pharmacology and therapeutic efficacy in the treatment of leishmaniasis.|journal=The Journal of antimicrobial chemotherapy|date=Nov 2012|volume=67|issue=11|pages=2576–97|pmid=22833634|doi=10.1093/jac/dks275}}&lt;/ref&gt;iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni, yi-paramomycin[[, i-fluconazole]], nofana[[i-pentamidine]] nayo ingasebenza kuhle ukulapha.&lt;ref name=Min2007&gt;{{Wp/nd/cite journal|last=Minodier|first=P|author2=Parola, P |title=Cutaneous leishmaniasis treatment.|journal=Travel medicine and infectious disease|date=May 2007|volume=5|issue=3|pages=150–8|pmid=17448941|doi=10.1016/j.tmaid.2006.09.004}}&lt;/ref&gt;

&lt;!-- Epidemiology --&gt;
Abantu ababalelwa eegigidini ezili-12 baphethwe bulwelwe lobu njenganje&lt;ref name=Mag&gt;{{Wp/nd/cite web|title=Leishmaniasis Magnitude of the problem|url=http://www.who.int/leishmaniasis/burden/magnitude/burden_magnitude/en/index.html|work=World Health Organization|accessdate=17 February 2014}}&lt;/ref&gt; eenrheni ezingaba ma-98.&lt;ref name=Barrett2012&gt;{{Wp/nd/cite journal|last=Barrett|first=MP|author2=Croft, SL |title=Management of trypanosomiasis and leishmaniasis.|journal=British medical bulletin|year=2012|volume=104|pages=175–96|pmid=23137768|doi=10.1093/bmb/lds031|pmc=3530408}}&lt;/ref&gt; Kubikwa amacala ukufikelela iingidigidi ezi-2&lt;ref name=Barrett2012/&gt; bese kuthi hlangana nama-20 weekulungwana kanye nama-50 weenkuungana zokubhubha kwabantu ngomnyaka.&lt;ref name=WHO2014/&gt;&lt;ref name=Loz2012&gt;{{Wp/nd/cite journal|last=Lozano|first=R|title=Global and regional mortality from 235 causes of death for 20 age groups in 1990 and 2010: a systematic analysis for the Global Burden of Disease Study 2010.|journal=Lancet|date=Dec 15, 2012|volume=380|issue=9859|pages=2095–128|pmid=23245604|doi=10.1016/S0140-6736(12)61728-0}}&lt;/ref&gt; Ukubalelwa ematjhumini ama-200&amp;nbsp; iingidigidi zabantu abahlala e-Asia,Afrika,iSewula neNgaphakathi le-Amerikha, isewula yeYurobhu bahlala eendaweni lapha ubulwelwe lobu bujayelekele khona.&lt;ref name=Barrett2012/&gt;&lt;ref&gt;{{Wp/nd/cite journal|last=Ejazi|first=SA|author2=Ali, N |title=Developments in diagnosis and treatment of visceral leishmaniasis during the last decade and future prospects.|journal=Expert review of anti-infective therapy|date=Jan 2013|volume=11|issue=1|pages=79–98|pmid=23428104|doi=10.1586/eri.12.148}}&lt;/ref&gt; I[[hlangano yeZepilo yePhasi Zombelele-WHO]]iphulelwe iintengo eziyibhadala ukuthenga iinhlahla zokulapha ubulwelwe lobu&lt;ref name=Barrett2012/&gt; Ubulwelwe lobu bungatheleleka nakezinye iinlwana ezimbalwa, ukufaka[[iLitjhimanisisi |yezinja]] kanye [[naborodo besiganga]].&lt;ref name=WHO2014/&gt;

==isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi ==
{{Wp/nr/Reflist|colwidth=25em}}
[[Category:Wp/nd]]</text>
      <sha1>12k4p23rnkos4x2iu3k71481sqo4jaz</sha1>
    </revision>
    <revision>
      <id>2058</id>
      <parentid>2053</parentid>
      <timestamp>2024-11-18T17:50:21Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <minor />
      <comment>Amire80 moved page [[Wp/nd/ILitjhimanisi]] to [[ILitjhimanisi]]</comment>
      <origin>2052</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7170" sha1="12k4p23rnkos4x2iu3k71481sqo4jaz" xml:space="preserve">{{Wp/nd/Infobox disease
| name            = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana
| image           = Skin ulcer due to leishmaniasis, hand of Central American adult 3MG0037 lores.jpg
| caption         = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni[[esandleni]]sesakhamuzi esihlala e-Amerikha
| Field           = [[Infectious disease (medical specialty)|Infectious disease]]
| pronounce       = Leishmaniasis {{IPAc-en|ˌ|l|iː|ʃ|m|ə|ˈ|n|aɪ|ə|s|ɪ|s}}&lt;br&gt;leishmaniosis {{IPAc-en|l|iː|ʃ|ˌ|m|eɪ|n|ɪ|ˈ|əʊ|s|ɪ|s}} or {{IPAc-en|l|iː|ʃ|ˌ|m|æ|n|ɪ|ˈ|əʊ|s|ɪ|s}}&lt;ref&gt;http://www.collinsdictionary.com/dictionary/english/leishmaniasis&lt;/ref&gt;
| ICD10           = {{Wp/nd/ICD10|B|55||b|50}}
| ICD9            = {{Wp/nd/ICD9|085}}
| DiseasesDB      = 3266
| DiseasesDB_mult = {{DiseasesDB2|29171}}&lt;!--  {{DiseasesDB2|3266}} {{DiseasesDB2|7070}} --&gt;
| MedlinePlus     = 001386
| eMedicineSubj   = emerg
| eMedicineTopic  = 296
| MeshID          = D007896
}}
''' iLitjhimanisi '''ungayibiza uthi'''yilitjhimanisi''', bulwelwe [[obubangwa]] silwanyana esincani [[esibizwa ngokuthi]]yi-phrotozowa ephila ngokuhlala kezinye iinlwana/abantu bona iphile [[itheleleka]] ngokulunywa [[mhlobo othize wengogwana]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu bungavela ngeendlela ezintathu: [[Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni| ukulunywa yingogwana esikhunjeni]] ukutheleleka esikhumbeni nomzimba woke, nofana[[ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali ]].&lt;ref name=WHO2014&gt;{{Wp/nd/cite web|title=Leishmaniasis Fact sheet N°375|url=http://www.who.int/mediacentre/factsheets/fs375/en/|work=World Health Organization|accessdate=17 February 2014|date=January 2014}}&lt;/ref&gt; Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni benza umuntu avele isilonda sangaphakathi esikhunjeni, bese ukutheleleka esikhumbeni nomzimba woke kubonakala lokha sele itheleleka esikhumbeni yenze isilonda emlonyeni kanye nepumulweni, bese iLitjhimanisi nasele isezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni ibonakala ngesilonda esingendeni esiphathisa ihloko nomgomani, ibangela namasotja womzimba abe bovu, kanye nokuvuvukisa isibindi. &lt;ref name=WHO2014/&gt;&lt;ref name=Barrett2012/&gt;

&lt;!-- Cause and diagnosis --&gt;
Kunemihlobohlobo ema-20 yeengogwana &quot;zeLitjhimaniya&quot; ezibamba abantu abaphilako&lt;ref name=WHO2014/&gt; Unobangela wobulwelwe lobu nobungozi babo bufaka hlangana ubuchaka, ukungadli ukudla okunepilo, ukususwa nokutjhiswa kwamahlathi, kanye nokuthutha kwabantu bayokuhlala emadorobhei khulu.&lt;ref name=WHO2014/&gt; Yoke imihlobo emithathu yobulwelwe lobu bungabonwa ngesilwanyana nofana ingogwana ephila ngezinye iinlwana kwaphela ngokusetjenziswa komtjhini onerhalasi okhulisa izinto ezincani zibe zikulu.&lt;ref name=WHO2014/&gt; Ukungezelela kilokho, ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali bungabonwa kwaphela ngokuhlolwa kweengazi zaloyo othelelekileko.&lt;ref name=Barrett2012/&gt;

&lt;!-- Prevention and treatment --&gt;
Ubulwelwe iLitjhimanisi bungavikelwa ngkuthi ulale ngaphakathi kwenedi yetende[[ ethelwe ngesihlahla sokuvikela iingogwan]].&lt;ref name=WHO2014/&gt; Ezinye zeendlela zokuvikela kufaka hlangana nokufufuzela isifufuzeli sokuvikela ukulunywa ziingogwana ukwazi ukuzibulala kanye nokulatjhwa kwabantu abangenwe bulwelwe lobu kusese nesikhathi bungakasabalali umzimba woke.&lt;ref name=WHO2014/&gt; Ukulatjhwa okutlhogekako kwenziwa nange kwaziwa bona ubulwelwe lobu buthalakele kiyiphi indawo, umhlobo &quot;weLitjhiminiya&quot; kanye nehlobo lengongwana engenileko.&lt;ref name=WHO2014/&gt; Ezinye zeenhlahla ezingalapha iLitjhimanisi nasele esezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni [[ kufaka hlangana i-liposomal amphotericin B]],&lt;ref name=Sun2013/&gt; ihlanganiso le[[le-pentavalent antimonials]]kanye [[ne-}paromomycin]],&lt;ref name=Sun2013&gt;{{Wp/nd/cite journal|last=Sundar|first=S|author2=Chakravarty, J |title=Leishmaniasis: an update of current pharmacotherapy.|journal=Expert opinion on pharmacotherapy|date=Jan 2013|volume=14|issue=1|pages=53–63|pmid=23256501|doi=10.1517/14656566.2013.755515}}&lt;/ref&gt; and [[miltefosine]].&lt;ref name=Dor2012&gt;{{Wp/nd/cite journal|last=Dorlo|first=TP|author2=Balasegaram, M |author3=Beijnen, JH |author4= de Vries, PJ |title=Miltefosine: a review of its pharmacology and therapeutic efficacy in the treatment of leishmaniasis.|journal=The Journal of antimicrobial chemotherapy|date=Nov 2012|volume=67|issue=11|pages=2576–97|pmid=22833634|doi=10.1093/jac/dks275}}&lt;/ref&gt;iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni, yi-paramomycin[[, i-fluconazole]], nofana[[i-pentamidine]] nayo ingasebenza kuhle ukulapha.&lt;ref name=Min2007&gt;{{Wp/nd/cite journal|last=Minodier|first=P|author2=Parola, P |title=Cutaneous leishmaniasis treatment.|journal=Travel medicine and infectious disease|date=May 2007|volume=5|issue=3|pages=150–8|pmid=17448941|doi=10.1016/j.tmaid.2006.09.004}}&lt;/ref&gt;

&lt;!-- Epidemiology --&gt;
Abantu ababalelwa eegigidini ezili-12 baphethwe bulwelwe lobu njenganje&lt;ref name=Mag&gt;{{Wp/nd/cite web|title=Leishmaniasis Magnitude of the problem|url=http://www.who.int/leishmaniasis/burden/magnitude/burden_magnitude/en/index.html|work=World Health Organization|accessdate=17 February 2014}}&lt;/ref&gt; eenrheni ezingaba ma-98.&lt;ref name=Barrett2012&gt;{{Wp/nd/cite journal|last=Barrett|first=MP|author2=Croft, SL |title=Management of trypanosomiasis and leishmaniasis.|journal=British medical bulletin|year=2012|volume=104|pages=175–96|pmid=23137768|doi=10.1093/bmb/lds031|pmc=3530408}}&lt;/ref&gt; Kubikwa amacala ukufikelela iingidigidi ezi-2&lt;ref name=Barrett2012/&gt; bese kuthi hlangana nama-20 weekulungwana kanye nama-50 weenkuungana zokubhubha kwabantu ngomnyaka.&lt;ref name=WHO2014/&gt;&lt;ref name=Loz2012&gt;{{Wp/nd/cite journal|last=Lozano|first=R|title=Global and regional mortality from 235 causes of death for 20 age groups in 1990 and 2010: a systematic analysis for the Global Burden of Disease Study 2010.|journal=Lancet|date=Dec 15, 2012|volume=380|issue=9859|pages=2095–128|pmid=23245604|doi=10.1016/S0140-6736(12)61728-0}}&lt;/ref&gt; Ukubalelwa ematjhumini ama-200&amp;nbsp; iingidigidi zabantu abahlala e-Asia,Afrika,iSewula neNgaphakathi le-Amerikha, isewula yeYurobhu bahlala eendaweni lapha ubulwelwe lobu bujayelekele khona.&lt;ref name=Barrett2012/&gt;&lt;ref&gt;{{Wp/nd/cite journal|last=Ejazi|first=SA|author2=Ali, N |title=Developments in diagnosis and treatment of visceral leishmaniasis during the last decade and future prospects.|journal=Expert review of anti-infective therapy|date=Jan 2013|volume=11|issue=1|pages=79–98|pmid=23428104|doi=10.1586/eri.12.148}}&lt;/ref&gt; I[[hlangano yeZepilo yePhasi Zombelele-WHO]]iphulelwe iintengo eziyibhadala ukuthenga iinhlahla zokulapha ubulwelwe lobu&lt;ref name=Barrett2012/&gt; Ubulwelwe lobu bungatheleleka nakezinye iinlwana ezimbalwa, ukufaka[[iLitjhimanisisi |yezinja]] kanye [[naborodo besiganga]].&lt;ref name=WHO2014/&gt;

==isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi ==
{{Wp/nr/Reflist|colwidth=25em}}
[[Category:Wp/nd]]</text>
      <sha1>12k4p23rnkos4x2iu3k71481sqo4jaz</sha1>
    </revision>
    <revision>
      <id>2189</id>
      <parentid>2058</parentid>
      <timestamp>2024-11-28T20:01:28Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi */Mkhakha</comment>
      <origin>2189</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7171" sha1="6r2dnsjauon9hqibfe8ubie9i1a3jyq" xml:space="preserve">{{Wp/nd/Infobox disease
| name            = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana
| image           = Skin ulcer due to leishmaniasis, hand of Central American adult 3MG0037 lores.jpg
| caption         = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni[[esandleni]]sesakhamuzi esihlala e-Amerikha
| Field           = [[Infectious disease (medical specialty)|Infectious disease]]
| pronounce       = Leishmaniasis {{IPAc-en|ˌ|l|iː|ʃ|m|ə|ˈ|n|aɪ|ə|s|ɪ|s}}&lt;br&gt;leishmaniosis {{IPAc-en|l|iː|ʃ|ˌ|m|eɪ|n|ɪ|ˈ|əʊ|s|ɪ|s}} or {{IPAc-en|l|iː|ʃ|ˌ|m|æ|n|ɪ|ˈ|əʊ|s|ɪ|s}}&lt;ref&gt;http://www.collinsdictionary.com/dictionary/english/leishmaniasis&lt;/ref&gt;
| ICD10           = {{Wp/nd/ICD10|B|55||b|50}}
| ICD9            = {{Wp/nd/ICD9|085}}
| DiseasesDB      = 3266
| DiseasesDB_mult = {{DiseasesDB2|29171}}&lt;!--  {{DiseasesDB2|3266}} {{DiseasesDB2|7070}} --&gt;
| MedlinePlus     = 001386
| eMedicineSubj   = emerg
| eMedicineTopic  = 296
| MeshID          = D007896
}}
''' iLitjhimanisi '''ungayibiza uthi'''yilitjhimanisi''', bulwelwe [[obubangwa]] silwanyana esincani [[esibizwa ngokuthi]]yi-phrotozowa ephila ngokuhlala kezinye iinlwana/abantu bona iphile [[itheleleka]] ngokulunywa [[mhlobo othize wengogwana]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu bungavela ngeendlela ezintathu: [[Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni| ukulunywa yingogwana esikhunjeni]] ukutheleleka esikhumbeni nomzimba woke, nofana[[ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali ]].&lt;ref name=WHO2014&gt;{{Wp/nd/cite web|title=Leishmaniasis Fact sheet N°375|url=http://www.who.int/mediacentre/factsheets/fs375/en/|work=World Health Organization|accessdate=17 February 2014|date=January 2014}}&lt;/ref&gt; Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni benza umuntu avele isilonda sangaphakathi esikhunjeni, bese ukutheleleka esikhumbeni nomzimba woke kubonakala lokha sele itheleleka esikhumbeni yenze isilonda emlonyeni kanye nepumulweni, bese iLitjhimanisi nasele isezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni ibonakala ngesilonda esingendeni esiphathisa ihloko nomgomani, ibangela namasotja womzimba abe bovu, kanye nokuvuvukisa isibindi. &lt;ref name=WHO2014/&gt;&lt;ref name=Barrett2012/&gt;

&lt;!-- Cause and diagnosis --&gt;
Kunemihlobohlobo ema-20 yeengogwana &quot;zeLitjhimaniya&quot; ezibamba abantu abaphilako&lt;ref name=WHO2014/&gt; Unobangela wobulwelwe lobu nobungozi babo bufaka hlangana ubuchaka, ukungadli ukudla okunepilo, ukususwa nokutjhiswa kwamahlathi, kanye nokuthutha kwabantu bayokuhlala emadorobhei khulu.&lt;ref name=WHO2014/&gt; Yoke imihlobo emithathu yobulwelwe lobu bungabonwa ngesilwanyana nofana ingogwana ephila ngezinye iinlwana kwaphela ngokusetjenziswa komtjhini onerhalasi okhulisa izinto ezincani zibe zikulu.&lt;ref name=WHO2014/&gt; Ukungezelela kilokho, ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali bungabonwa kwaphela ngokuhlolwa kweengazi zaloyo othelelekileko.&lt;ref name=Barrett2012/&gt;

&lt;!-- Prevention and treatment --&gt;
Ubulwelwe iLitjhimanisi bungavikelwa ngkuthi ulale ngaphakathi kwenedi yetende[[ ethelwe ngesihlahla sokuvikela iingogwan]].&lt;ref name=WHO2014/&gt; Ezinye zeendlela zokuvikela kufaka hlangana nokufufuzela isifufuzeli sokuvikela ukulunywa ziingogwana ukwazi ukuzibulala kanye nokulatjhwa kwabantu abangenwe bulwelwe lobu kusese nesikhathi bungakasabalali umzimba woke.&lt;ref name=WHO2014/&gt; Ukulatjhwa okutlhogekako kwenziwa nange kwaziwa bona ubulwelwe lobu buthalakele kiyiphi indawo, umhlobo &quot;weLitjhiminiya&quot; kanye nehlobo lengongwana engenileko.&lt;ref name=WHO2014/&gt; Ezinye zeenhlahla ezingalapha iLitjhimanisi nasele esezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni [[ kufaka hlangana i-liposomal amphotericin B]],&lt;ref name=Sun2013/&gt; ihlanganiso le[[le-pentavalent antimonials]]kanye [[ne-}paromomycin]],&lt;ref name=Sun2013&gt;{{Wp/nd/cite journal|last=Sundar|first=S|author2=Chakravarty, J |title=Leishmaniasis: an update of current pharmacotherapy.|journal=Expert opinion on pharmacotherapy|date=Jan 2013|volume=14|issue=1|pages=53–63|pmid=23256501|doi=10.1517/14656566.2013.755515}}&lt;/ref&gt; and [[miltefosine]].&lt;ref name=Dor2012&gt;{{Wp/nd/cite journal|last=Dorlo|first=TP|author2=Balasegaram, M |author3=Beijnen, JH |author4= de Vries, PJ |title=Miltefosine: a review of its pharmacology and therapeutic efficacy in the treatment of leishmaniasis.|journal=The Journal of antimicrobial chemotherapy|date=Nov 2012|volume=67|issue=11|pages=2576–97|pmid=22833634|doi=10.1093/jac/dks275}}&lt;/ref&gt;iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni, yi-paramomycin[[, i-fluconazole]], nofana[[i-pentamidine]] nayo ingasebenza kuhle ukulapha.&lt;ref name=Min2007&gt;{{Wp/nd/cite journal|last=Minodier|first=P|author2=Parola, P |title=Cutaneous leishmaniasis treatment.|journal=Travel medicine and infectious disease|date=May 2007|volume=5|issue=3|pages=150–8|pmid=17448941|doi=10.1016/j.tmaid.2006.09.004}}&lt;/ref&gt;

&lt;!-- Epidemiology --&gt;
Abantu ababalelwa eegigidini ezili-12 baphethwe bulwelwe lobu njenganje&lt;ref name=Mag&gt;{{Wp/nd/cite web|title=Leishmaniasis Magnitude of the problem|url=http://www.who.int/leishmaniasis/burden/magnitude/burden_magnitude/en/index.html|work=World Health Organization|accessdate=17 February 2014}}&lt;/ref&gt; eenrheni ezingaba ma-98.&lt;ref name=Barrett2012&gt;{{Wp/nd/cite journal|last=Barrett|first=MP|author2=Croft, SL |title=Management of trypanosomiasis and leishmaniasis.|journal=British medical bulletin|year=2012|volume=104|pages=175–96|pmid=23137768|doi=10.1093/bmb/lds031|pmc=3530408}}&lt;/ref&gt; Kubikwa amacala ukufikelela iingidigidi ezi-2&lt;ref name=Barrett2012/&gt; bese kuthi hlangana nama-20 weekulungwana kanye nama-50 weenkuungana zokubhubha kwabantu ngomnyaka.&lt;ref name=WHO2014/&gt;&lt;ref name=Loz2012&gt;{{Wp/nd/cite journal|last=Lozano|first=R|title=Global and regional mortality from 235 causes of death for 20 age groups in 1990 and 2010: a systematic analysis for the Global Burden of Disease Study 2010.|journal=Lancet|date=Dec 15, 2012|volume=380|issue=9859|pages=2095–128|pmid=23245604|doi=10.1016/S0140-6736(12)61728-0}}&lt;/ref&gt; Ukubalelwa ematjhumini ama-200&amp;nbsp; iingidigidi zabantu abahlala e-Asia,Afrika,iSewula neNgaphakathi le-Amerikha, isewula yeYurobhu bahlala eendaweni lapha ubulwelwe lobu bujayelekele khona.&lt;ref name=Barrett2012/&gt;&lt;ref&gt;{{Wp/nd/cite journal|last=Ejazi|first=SA|author2=Ali, N |title=Developments in diagnosis and treatment of visceral leishmaniasis during the last decade and future prospects.|journal=Expert review of anti-infective therapy|date=Jan 2013|volume=11|issue=1|pages=79–98|pmid=23428104|doi=10.1586/eri.12.148}}&lt;/ref&gt; I[[hlangano yeZepilo yePhasi Zombelele-WHO]]iphulelwe iintengo eziyibhadala ukuthenga iinhlahla zokulapha ubulwelwe lobu&lt;ref name=Barrett2012/&gt; Ubulwelwe lobu bungatheleleka nakezinye iinlwana ezimbalwa, ukufaka[[iLitjhimanisisi |yezinja]] kanye [[naborodo besiganga]].&lt;ref name=WHO2014/&gt;

== isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi ==
{{Wp/nr/Reflist|colwidth=25em}}

[[Mkhakha:Wp/nd]]</text>
      <sha1>6r2dnsjauon9hqibfe8ubie9i1a3jyq</sha1>
    </revision>
    <revision>
      <id>2943</id>
      <parentid>2189</parentid>
      <timestamp>2025-06-06T17:20:23Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>Hot dog</comment>
      <origin>2943</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4067" sha1="pf3glu0v23te9pibpzmilujzz7zwaep" xml:space="preserve">upon the most peculiar and oft-overlooked phenomenon known within the parlance of the commoner as the '''hot dog''', though such nomenclature belies its manifold complexities. Permit me to articulate, in a style most befitting the genteel salons of our fair Britannia in this, the resplendent 19th century, the manifold dynamics of this tubular culinary oddity.
----'''A Treatise Upon the Thermo-Gustatory and Socio-Cylindrical Interactions of the Encased Meatic Delicacy Commonly Referred to as the &quot;Hot Dog&quot;'''

In the burgeoning epoch of steam and empire, wherein dirigibles graze the heavens and gentlemen discourse upon phlogiston and Darwinian descent over tea and crumpets, there exists a most singular comestible of transatlantic origin—nay, a gastronomic chimera—comprised principally of a homogenised, emulsified amalgamation of porcine and/or bovine flesh, ensconced within a phallic sheath of artificially reconstituted intestinal membrane.

Said ''viand'', once subjected to the transformative rigours of thermal agitation—most commonly through immersion in boiling aqueous solution or searing upon a heated iron griddle—undergoes a process of protein denaturation and lipidic exudation, thereby achieving a state of both succulence and structural integrity most palatable to the human gustatory apparatus.

The resultant ''sausage'', glistening in its post-coital sheen of oil and steam, is thenceforth nestled within a bifurcated, leavened bread vessel—oft referred to as a &quot;bun,&quot; though the term lacks appropriate gravity. Said bread, whose yeasty effervescence recalls the rustic charm of a Yorkshire bakehouse, serves not merely as a conveyance, but as a textural counterpoint, a spongiform cradle that tempers the olfactory violence of the seasoned tube-meat within.

Upon the summit of this cylindrical banquet, the diner—whose tastes may range from the sublime to the absurd—may elect to append a medley of condimentary effluvia: mustard, that Gallic yellow ichor; ketchup, the tomatoic blood of the New World; onions, both raw and caramelised to the consistency of Dickensian sorrow; and the abhorrent green pickle relish, whose inclusion I dare say marks the eater as a colonial deviant of the highest order.

Now, consider if you will the '''dynamic interaction''': the bite, a momentary rupture in the temporal continuum, wherein teeth cleave through crust and casing alike, causing a micro-explosion of savoury juices to erupt forth with all the vigour of a Crimean cannonade. The mastication thereafter resembles the complex mechanical operations of Brunel's Great Eastern—gears and pistons working in synchrony to reduce the noble dog to a bolus fit for deglutition.

To consume a hot dog, dear reader, is to engage in a ritualistic theatre of meat and bread, to partake in the democratic ingestion of proletarian delight, wrapped in the trappings of modern industrialism and American excess. It is, in short, an edible metaphor for the contradictions of our age: refinement and vulgarity, steam and grease, bun and beast—all rendered in a single, hand-held cylinder.
----I remain, as ever,

Your most obedient servant and humble explicator of gustatory enigmas,

'''Chatboticus G. P. Thourghbottom, Esq.'''{{Wp/nd/Infobox disease
| name            = No
| image           = No
| caption         = No
| Field           = [[Infectious disease (medical specialty)|Infectious disease]]
| pronounce       = Leishmaniasis {{IPAc-en|ˌ|l|iː|ʃ|m|ə|ˈ|n|aɪ|ə|s|ɪ|s}}&lt;br&gt;leishmaniosis {{IPAc-en|l|iː|ʃ|ˌ|m|eɪ|n|ɪ|ˈ|əʊ|s|ɪ|s}} or {{IPAc-en|l|iː|ʃ|ˌ|m|æ|n|ɪ|ˈ|əʊ|s|ɪ|s}}&lt;ref&gt;http://www.collinsdictionary.com/dictionary/english/leishmaniasis&lt;/ref&gt;
| ICD10           = {{Wp/nd/ICD10|B|55||b|50}}
| ICD9            = {{Wp/nd/ICD9|085}}
| DiseasesDB      = 3266
| DiseasesDB_mult = {{DiseasesDB2|29171}}&lt;!--  {{DiseasesDB2|3266}} {{DiseasesDB2|7070}} --&gt;
| MedlinePlus     = 001386
| eMedicineSubj   = emerg
| eMedicineTopic  = 296
| MeshID          = D007896
}}
{{Wp/nr/Reflist|colwidth=25em}}

[[Mkhakha:Wp/nd]]</text>
      <sha1>pf3glu0v23te9pibpzmilujzz7zwaep</sha1>
    </revision>
    <revision>
      <id>3140</id>
      <parentid>2943</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Simakahle Moselekatse|Simakahle Moselekatse]]</comment>
      <origin>2189</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7171" sha1="6r2dnsjauon9hqibfe8ubie9i1a3jyq" xml:space="preserve">{{Wp/nd/Infobox disease
| name            = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana
| image           = Skin ulcer due to leishmaniasis, hand of Central American adult 3MG0037 lores.jpg
| caption         = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni[[esandleni]]sesakhamuzi esihlala e-Amerikha
| Field           = [[Infectious disease (medical specialty)|Infectious disease]]
| pronounce       = Leishmaniasis {{IPAc-en|ˌ|l|iː|ʃ|m|ə|ˈ|n|aɪ|ə|s|ɪ|s}}&lt;br&gt;leishmaniosis {{IPAc-en|l|iː|ʃ|ˌ|m|eɪ|n|ɪ|ˈ|əʊ|s|ɪ|s}} or {{IPAc-en|l|iː|ʃ|ˌ|m|æ|n|ɪ|ˈ|əʊ|s|ɪ|s}}&lt;ref&gt;http://www.collinsdictionary.com/dictionary/english/leishmaniasis&lt;/ref&gt;
| ICD10           = {{Wp/nd/ICD10|B|55||b|50}}
| ICD9            = {{Wp/nd/ICD9|085}}
| DiseasesDB      = 3266
| DiseasesDB_mult = {{DiseasesDB2|29171}}&lt;!--  {{DiseasesDB2|3266}} {{DiseasesDB2|7070}} --&gt;
| MedlinePlus     = 001386
| eMedicineSubj   = emerg
| eMedicineTopic  = 296
| MeshID          = D007896
}}
''' iLitjhimanisi '''ungayibiza uthi'''yilitjhimanisi''', bulwelwe [[obubangwa]] silwanyana esincani [[esibizwa ngokuthi]]yi-phrotozowa ephila ngokuhlala kezinye iinlwana/abantu bona iphile [[itheleleka]] ngokulunywa [[mhlobo othize wengogwana]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu bungavela ngeendlela ezintathu: [[Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni| ukulunywa yingogwana esikhunjeni]] ukutheleleka esikhumbeni nomzimba woke, nofana[[ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali ]].&lt;ref name=WHO2014&gt;{{Wp/nd/cite web|title=Leishmaniasis Fact sheet N°375|url=http://www.who.int/mediacentre/factsheets/fs375/en/|work=World Health Organization|accessdate=17 February 2014|date=January 2014}}&lt;/ref&gt; Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni benza umuntu avele isilonda sangaphakathi esikhunjeni, bese ukutheleleka esikhumbeni nomzimba woke kubonakala lokha sele itheleleka esikhumbeni yenze isilonda emlonyeni kanye nepumulweni, bese iLitjhimanisi nasele isezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni ibonakala ngesilonda esingendeni esiphathisa ihloko nomgomani, ibangela namasotja womzimba abe bovu, kanye nokuvuvukisa isibindi. &lt;ref name=WHO2014/&gt;&lt;ref name=Barrett2012/&gt;

&lt;!-- Cause and diagnosis --&gt;
Kunemihlobohlobo ema-20 yeengogwana &quot;zeLitjhimaniya&quot; ezibamba abantu abaphilako&lt;ref name=WHO2014/&gt; Unobangela wobulwelwe lobu nobungozi babo bufaka hlangana ubuchaka, ukungadli ukudla okunepilo, ukususwa nokutjhiswa kwamahlathi, kanye nokuthutha kwabantu bayokuhlala emadorobhei khulu.&lt;ref name=WHO2014/&gt; Yoke imihlobo emithathu yobulwelwe lobu bungabonwa ngesilwanyana nofana ingogwana ephila ngezinye iinlwana kwaphela ngokusetjenziswa komtjhini onerhalasi okhulisa izinto ezincani zibe zikulu.&lt;ref name=WHO2014/&gt; Ukungezelela kilokho, ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali bungabonwa kwaphela ngokuhlolwa kweengazi zaloyo othelelekileko.&lt;ref name=Barrett2012/&gt;

&lt;!-- Prevention and treatment --&gt;
Ubulwelwe iLitjhimanisi bungavikelwa ngkuthi ulale ngaphakathi kwenedi yetende[[ ethelwe ngesihlahla sokuvikela iingogwan]].&lt;ref name=WHO2014/&gt; Ezinye zeendlela zokuvikela kufaka hlangana nokufufuzela isifufuzeli sokuvikela ukulunywa ziingogwana ukwazi ukuzibulala kanye nokulatjhwa kwabantu abangenwe bulwelwe lobu kusese nesikhathi bungakasabalali umzimba woke.&lt;ref name=WHO2014/&gt; Ukulatjhwa okutlhogekako kwenziwa nange kwaziwa bona ubulwelwe lobu buthalakele kiyiphi indawo, umhlobo &quot;weLitjhiminiya&quot; kanye nehlobo lengongwana engenileko.&lt;ref name=WHO2014/&gt; Ezinye zeenhlahla ezingalapha iLitjhimanisi nasele esezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni [[ kufaka hlangana i-liposomal amphotericin B]],&lt;ref name=Sun2013/&gt; ihlanganiso le[[le-pentavalent antimonials]]kanye [[ne-}paromomycin]],&lt;ref name=Sun2013&gt;{{Wp/nd/cite journal|last=Sundar|first=S|author2=Chakravarty, J |title=Leishmaniasis: an update of current pharmacotherapy.|journal=Expert opinion on pharmacotherapy|date=Jan 2013|volume=14|issue=1|pages=53–63|pmid=23256501|doi=10.1517/14656566.2013.755515}}&lt;/ref&gt; and [[miltefosine]].&lt;ref name=Dor2012&gt;{{Wp/nd/cite journal|last=Dorlo|first=TP|author2=Balasegaram, M |author3=Beijnen, JH |author4= de Vries, PJ |title=Miltefosine: a review of its pharmacology and therapeutic efficacy in the treatment of leishmaniasis.|journal=The Journal of antimicrobial chemotherapy|date=Nov 2012|volume=67|issue=11|pages=2576–97|pmid=22833634|doi=10.1093/jac/dks275}}&lt;/ref&gt;iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni, yi-paramomycin[[, i-fluconazole]], nofana[[i-pentamidine]] nayo ingasebenza kuhle ukulapha.&lt;ref name=Min2007&gt;{{Wp/nd/cite journal|last=Minodier|first=P|author2=Parola, P |title=Cutaneous leishmaniasis treatment.|journal=Travel medicine and infectious disease|date=May 2007|volume=5|issue=3|pages=150–8|pmid=17448941|doi=10.1016/j.tmaid.2006.09.004}}&lt;/ref&gt;

&lt;!-- Epidemiology --&gt;
Abantu ababalelwa eegigidini ezili-12 baphethwe bulwelwe lobu njenganje&lt;ref name=Mag&gt;{{Wp/nd/cite web|title=Leishmaniasis Magnitude of the problem|url=http://www.who.int/leishmaniasis/burden/magnitude/burden_magnitude/en/index.html|work=World Health Organization|accessdate=17 February 2014}}&lt;/ref&gt; eenrheni ezingaba ma-98.&lt;ref name=Barrett2012&gt;{{Wp/nd/cite journal|last=Barrett|first=MP|author2=Croft, SL |title=Management of trypanosomiasis and leishmaniasis.|journal=British medical bulletin|year=2012|volume=104|pages=175–96|pmid=23137768|doi=10.1093/bmb/lds031|pmc=3530408}}&lt;/ref&gt; Kubikwa amacala ukufikelela iingidigidi ezi-2&lt;ref name=Barrett2012/&gt; bese kuthi hlangana nama-20 weekulungwana kanye nama-50 weenkuungana zokubhubha kwabantu ngomnyaka.&lt;ref name=WHO2014/&gt;&lt;ref name=Loz2012&gt;{{Wp/nd/cite journal|last=Lozano|first=R|title=Global and regional mortality from 235 causes of death for 20 age groups in 1990 and 2010: a systematic analysis for the Global Burden of Disease Study 2010.|journal=Lancet|date=Dec 15, 2012|volume=380|issue=9859|pages=2095–128|pmid=23245604|doi=10.1016/S0140-6736(12)61728-0}}&lt;/ref&gt; Ukubalelwa ematjhumini ama-200&amp;nbsp; iingidigidi zabantu abahlala e-Asia,Afrika,iSewula neNgaphakathi le-Amerikha, isewula yeYurobhu bahlala eendaweni lapha ubulwelwe lobu bujayelekele khona.&lt;ref name=Barrett2012/&gt;&lt;ref&gt;{{Wp/nd/cite journal|last=Ejazi|first=SA|author2=Ali, N |title=Developments in diagnosis and treatment of visceral leishmaniasis during the last decade and future prospects.|journal=Expert review of anti-infective therapy|date=Jan 2013|volume=11|issue=1|pages=79–98|pmid=23428104|doi=10.1586/eri.12.148}}&lt;/ref&gt; I[[hlangano yeZepilo yePhasi Zombelele-WHO]]iphulelwe iintengo eziyibhadala ukuthenga iinhlahla zokulapha ubulwelwe lobu&lt;ref name=Barrett2012/&gt; Ubulwelwe lobu bungatheleleka nakezinye iinlwana ezimbalwa, ukufaka[[iLitjhimanisisi |yezinja]] kanye [[naborodo besiganga]].&lt;ref name=WHO2014/&gt;

== isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi ==
{{Wp/nr/Reflist|colwidth=25em}}

[[Mkhakha:Wp/nd]]</text>
      <sha1>6r2dnsjauon9hqibfe8ubie9i1a3jyq</sha1>
    </revision>
    <revision>
      <id>3153</id>
      <parentid>3140</parentid>
      <timestamp>2025-06-12T20:46:12Z</timestamp>
      <contributor>
        <ip>46.106.19.151</ip>
      </contributor>
      <origin>3153</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7212" sha1="ceszp3e6ha6lnk4bmmm4mkbwv22c5tl" xml:space="preserve">{{Wp/nd/Infobox disease
| name            = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana
| image           = Skin ulcer due to leishmaniasis, hand of Central American adult 3MG0037 lores.jpg
| caption         = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni[[esandleni]]sesakhamuzi esihlala e-Amerikha
| Field           = [[Infectious disease (medical specialty)|Infectious disease]]
| pronounce       = Leishmaniasis {{IPAc-en|ˌ|l|iː|ʃ|m|ə|ˈ|n|aɪ|ə|s|ɪ|s}}&lt;br&gt;leishmaniosis {{IPAc-en|l|iː|ʃ|ˌ|m|eɪ|n|ɪ|ˈ|əʊ|s|ɪ|s}} or {{IPAc-en|l|iː|ʃ|ˌ|m|æ|n|ɪ|ˈ|əʊ|s|ɪ|s}}&lt;ref&gt;http://www.collinsdictionary.com/dictionary/english/leishmaniasis&lt;/ref&gt;
| ICD10           = {{Wp/nd/ICD10|B|55||b|50}}
| ICD9            = {{Wp/nd/ICD9|085}}
| DiseasesDB      = 3266
| DiseasesDB_mult = {{DiseasesDB2|29171}}&lt;!--  {{DiseasesDB2|3266}} {{DiseasesDB2|7070}} --&gt;
| MedlinePlus     = 001386
| eMedicineSubj   = emerg
| eMedicineTopic  = 296
| MeshID          = D007896
}}
''' iLitjhimanisi '''ungayibiza uthi'''yilitjhimanisi''', bulwelwe [[obubangwa]] silwanyana esincani [[esibizwa ngokuthi]]yi-phrotozowa ephila ngokuhlala kezinye iinlwana/abantu bona iphile [[itheleleka]] ngokulunywa [[mhlobo othize wengogwana]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu bungavela ngeendlela ezintathu: [[Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni| ukulunywa yingogwana esikhunjeni]] ukutheleleka esikhumbeni nomzimba woke, nofana[[ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali ]].&lt;ref name=WHO2014&gt;{{Wp/nd/cite web|title=Leishmaniasis Fact sheet N°375|url=http://www.who.int/mediacentre/factsheets/fs375/en/|work=World Health Organization|accessdate=17 February 2014|date=January 2014}}&lt;/ref&gt; Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni benza umuntu avele isilonda sangaphakathi esikhunjeni, bese ukutheleleka esikhumbeni nomzimba woke kubonakala lokha sele itheleleka esikhumbeni yenze isilonda emlonyeni kanye nepumulweni, bese iLitjhimanisi nasele isezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni ibonakala ngesilonda esingendeni esiphathisa ihloko nomgomani, ibangela namasotja womzimba abe bovu, kanye nokuvuvukisa isibindi. &lt;ref name=WHO2014/&gt;&lt;ref name=Barrett2012/&gt;

&lt;!-- Cause and diagnosis --&gt;
Kunemihlobohlobo ema-20 yeengogwana &quot;zeLitjhimaniya&quot; ezibamba abantu abaphilako&lt;ref name=WHO2014/&gt; Unobangela wobulwelwe lobu nobungozi babo bufaka hlangana ubuchaka, ukungadli ukudla okunepilo, ukususwa nokutjhiswa kwamahlathi, kanye nokuthutha kwabantu bayokuhlala emadorobhei khulu.&lt;ref name=WHO2014/&gt; Yoke imihlobo emithathu yobulwelwe lobu bungabonwa ngesilwanyana nofana ingogwana ephila ngezinye iinlwana kwaphela ngokusetjenziswa komtjhini onerhalasi okhulisa izinto ezincani zibe zikulu.&lt;ref name=WHO2014/&gt; Ukungezelela kilokho, ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali bungabonwa kwaphela ngokuhlolwa kweengazi zaloyo othelelekileko.&lt;ref name=Barrett2012/&gt;

&lt;!-- Prevention and treatment --&gt;
Ubulwelwe iLitjhimanisi bungavikelwa ngkuthi ulale ngaphakathi kwenedi yetende[[ ethelwe ngesihlahla sokuvikela iingogwan]].&lt;ref name=WHO2014/&gt; Ezinye zeendlela zokuvikela kufaka hlangana nokufufuzela isifufuzeli sokuvikela ukulunywa ziingogwana ukwazi ukuzibulala kanye nokulatjhwa kwabantu abangenwe bulwelwe lobu kusese nesikhathi bungakasabalali umzimba woke.&lt;ref name=WHO2014/&gt; Ukulatjhwa okutlhogekako kwenziwa nange kwaziwa bona ubulwelwe lobu buthalakele kiyiphi indawo, umhlobo &quot;weLitjhiminiya&quot; kanye nehlobo lengongwana engenileko.&lt;ref name=WHO2014/&gt; Ezinye zeenhlahla ezingalapha iLitjhimanisi nasele [https://www.pandaboyama.com.tr/ boyama] esezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni [[ kufaka hlangana i-liposomal amphotericin B]],&lt;ref name=Sun2013/&gt; ihlanganiso le[[le-pentavalent antimonials]]kanye [[ne-}paromomycin]],&lt;ref name=Sun2013&gt;{{Wp/nd/cite journal|last=Sundar|first=S|author2=Chakravarty, J |title=Leishmaniasis: an update of current pharmacotherapy.|journal=Expert opinion on pharmacotherapy|date=Jan 2013|volume=14|issue=1|pages=53–63|pmid=23256501|doi=10.1517/14656566.2013.755515}}&lt;/ref&gt; and [[miltefosine]].&lt;ref name=Dor2012&gt;{{Wp/nd/cite journal|last=Dorlo|first=TP|author2=Balasegaram, M |author3=Beijnen, JH |author4= de Vries, PJ |title=Miltefosine: a review of its pharmacology and therapeutic efficacy in the treatment of leishmaniasis.|journal=The Journal of antimicrobial chemotherapy|date=Nov 2012|volume=67|issue=11|pages=2576–97|pmid=22833634|doi=10.1093/jac/dks275}}&lt;/ref&gt;iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni, yi-paramomycin[[, i-fluconazole]], nofana[[i-pentamidine]] nayo ingasebenza kuhle ukulapha.&lt;ref name=Min2007&gt;{{Wp/nd/cite journal|last=Minodier|first=P|author2=Parola, P |title=Cutaneous leishmaniasis treatment.|journal=Travel medicine and infectious disease|date=May 2007|volume=5|issue=3|pages=150–8|pmid=17448941|doi=10.1016/j.tmaid.2006.09.004}}&lt;/ref&gt;

&lt;!-- Epidemiology --&gt;
Abantu ababalelwa eegigidini ezili-12 baphethwe bulwelwe lobu njenganje&lt;ref name=Mag&gt;{{Wp/nd/cite web|title=Leishmaniasis Magnitude of the problem|url=http://www.who.int/leishmaniasis/burden/magnitude/burden_magnitude/en/index.html|work=World Health Organization|accessdate=17 February 2014}}&lt;/ref&gt; eenrheni ezingaba ma-98.&lt;ref name=Barrett2012&gt;{{Wp/nd/cite journal|last=Barrett|first=MP|author2=Croft, SL |title=Management of trypanosomiasis and leishmaniasis.|journal=British medical bulletin|year=2012|volume=104|pages=175–96|pmid=23137768|doi=10.1093/bmb/lds031|pmc=3530408}}&lt;/ref&gt; Kubikwa amacala ukufikelela iingidigidi ezi-2&lt;ref name=Barrett2012/&gt; bese kuthi hlangana nama-20 weekulungwana kanye nama-50 weenkuungana zokubhubha kwabantu ngomnyaka.&lt;ref name=WHO2014/&gt;&lt;ref name=Loz2012&gt;{{Wp/nd/cite journal|last=Lozano|first=R|title=Global and regional mortality from 235 causes of death for 20 age groups in 1990 and 2010: a systematic analysis for the Global Burden of Disease Study 2010.|journal=Lancet|date=Dec 15, 2012|volume=380|issue=9859|pages=2095–128|pmid=23245604|doi=10.1016/S0140-6736(12)61728-0}}&lt;/ref&gt; Ukubalelwa ematjhumini ama-200&amp;nbsp; iingidigidi zabantu abahlala e-Asia,Afrika,iSewula neNgaphakathi le-Amerikha, isewula yeYurobhu bahlala eendaweni lapha ubulwelwe lobu bujayelekele khona.&lt;ref name=Barrett2012/&gt;&lt;ref&gt;{{Wp/nd/cite journal|last=Ejazi|first=SA|author2=Ali, N |title=Developments in diagnosis and treatment of visceral leishmaniasis during the last decade and future prospects.|journal=Expert review of anti-infective therapy|date=Jan 2013|volume=11|issue=1|pages=79–98|pmid=23428104|doi=10.1586/eri.12.148}}&lt;/ref&gt; I[[hlangano yeZepilo yePhasi Zombelele-WHO]]iphulelwe iintengo eziyibhadala ukuthenga iinhlahla zokulapha ubulwelwe lobu&lt;ref name=Barrett2012/&gt; Ubulwelwe lobu bungatheleleka nakezinye iinlwana ezimbalwa, ukufaka[[iLitjhimanisisi |yezinja]] kanye [[naborodo besiganga]].&lt;ref name=WHO2014/&gt;

== isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi ==
{{Wp/nr/Reflist|colwidth=25em}}

[[Mkhakha:Wp/nd]]</text>
      <sha1>ceszp3e6ha6lnk4bmmm4mkbwv22c5tl</sha1>
    </revision>
    <revision>
      <id>5080</id>
      <parentid>3153</parentid>
      <timestamp>2025-08-08T08:43:23Z</timestamp>
      <contributor>
        <username>Umenathi</username>
        <id>837</id>
      </contributor>
      <origin>5080</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7212" sha1="2hfpjxiwv016g5uwpj4wwof7cnjbd82" xml:space="preserve">{{Wp/nd/Infobox disease
| name            = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana
| image           = Skin ulcer due to leishmaniasis, hand of Central American adult 3MG0037 lores.jpg
| caption         = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni[[esandleni]]sesakhamuzi esihlala e-Amerikha
| Field           = [[Infectious disease (medical specialty)|Infectious disease]]
| pronounce       = Leishmaniasis {{IPAc-en|ˌ|l|iː|ʃ|m|ə|ˈ|n|aɪ|ə|s|ɪ|s}}&lt;br&gt;leishmaniosis {{IPAc-en|l|iː|ʃ|ˌ|m|eɪ|n|ɪ|ˈ|əʊ|s|ɪ|s}} or {{IPAc-en|l|iː|ʃ|ˌ|m|æ|n|ɪ|ˈ|əʊ|s|ɪ|s}}&lt;ref&gt;http://www.collinsdictionary.com/dictionary/english/leishmaniasis&lt;/ref&gt;
| ICD10           = {{Wp/nd/ICD10|B|55||b|50}}
| ICD9            = {{Wp/nd/ICD9|085}}
| DiseasesDB      = 3266
| DiseasesDB_mult = {{DiseasesDB2|29171}}&lt;!--  {{DiseasesDB2|3266}} {{DiseasesDB2|7070}} --&gt;
| MedlinePlus     = 001386
| eMedicineSubj   = emerg
| eMedicineTopic  = 296
| MeshID          = D007896
}}
''' iLitjhimanisi '''ungayibiza uthi'''yilitjhimanisi''', bulwelwe [[obubangwa]] silwanyana esincani [[esibizwa ngokuthi]]yi-phrotozowa ephila ngokuhlala kezinye iinlwana/abantu bona iphile [[itheleleka]] ngokulunywa [[mhlobo othize wengogwana]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu bungavela ngeendlela ezintathu: [[Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni| ukulunywa yingogwana esikhunjeni]] ukutheleleka esikhumbeni nomzimba woke, nofana[[ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali ]].&lt;ref name=WHO2014&gt;{{Wp/nd/cite web|title=Leishmaniasis Fact sheet N°375|url=http://www.who.int/mediacentre/factsheets/fs375/en/|work=World Health Organization|accessdate=17 February 2014|date=January 2014}}&lt;/ref&gt; Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni benza umuntu avele isilonda sangaphakathi esikhunjeni, bese ukutheleleka esikhumbeni nomzimba woke kubonakala lokha sele itheleleka esikhumbeni yenze isilonda emlonyeni kanye nepumulweni, bese iLitjhimanisi nasele isezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni ibonakala ngesilonda esingendeni esiphathisa ihloko nomgomani, ibangela namasotja womzimba abe bovu, kanye nokuvuvukisa isibindi. &lt;ref name=WHO2014/&gt;&lt;ref name=Barrett2012/&gt;

&lt;!-- Cause and diagnosis --&gt;
Kunemihlobohlobo ema-20 yeengogwana &quot;zeLitjhimanisi&quot; ezibamba abantu abaphilako&lt;ref name=WHO2014/&gt; Unobangela wobulwelwe lobu nobungozi babo bufaka hlangana ubuchaka, ukungadli ukudla okunepilo, ukususwa nokutjhiswa kwamahlathi, kanye nokuthutha kwabantu bayokuhlala emadorobhei khulu.&lt;ref name=WHO2014/&gt; Yoke imihlobo emithathu yobulwelwe lobu bungabonwa ngesilwanyana nofana ingogwana ephila ngezinye iinlwana kwaphela ngokusetjenziswa komtjhini onerhalasi okhulisa izinto ezincani zibe zikulu.&lt;ref name=WHO2014/&gt; Ukungezelela kilokho, ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali bungabonwa kwaphela ngokuhlolwa kweengazi zaloyo othelelekileko.&lt;ref name=Barrett2012/&gt;

&lt;!-- Prevention and treatment --&gt;
Ubulwelwe iLitjhimanisi bungavikelwa ngkuthi ulale ngaphakathi kwenedi yetende[[ ethelwe ngesihlahla sokuvikela iingogwan]].&lt;ref name=WHO2014/&gt; Ezinye zeendlela zokuvikela kufaka hlangana nokufufuzela isifufuzeli sokuvikela ukulunywa ziingogwana ukwazi ukuzibulala kanye nokulatjhwa kwabantu abangenwe bulwelwe lobu kusese nesikhathi bungakasabalali umzimba woke.&lt;ref name=WHO2014/&gt; Ukulatjhwa okutlhogekako kwenziwa nange kwaziwa bona ubulwelwe lobu buthalakele kiyiphi indawo, umhlobo &quot;weLitjhiminiya&quot; kanye nehlobo lengongwana engenileko.&lt;ref name=WHO2014/&gt; Ezinye zeenhlahla ezingalapha iLitjhimanisi nasele [https://www.pandaboyama.com.tr/ boyama] esezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni [[ kufaka hlangana i-liposomal amphotericin B]],&lt;ref name=Sun2013/&gt; ihlanganiso le[[le-pentavalent antimonials]]kanye [[ne-}paromomycin]],&lt;ref name=Sun2013&gt;{{Wp/nd/cite journal|last=Sundar|first=S|author2=Chakravarty, J |title=Leishmaniasis: an update of current pharmacotherapy.|journal=Expert opinion on pharmacotherapy|date=Jan 2013|volume=14|issue=1|pages=53–63|pmid=23256501|doi=10.1517/14656566.2013.755515}}&lt;/ref&gt; and [[miltefosine]].&lt;ref name=Dor2012&gt;{{Wp/nd/cite journal|last=Dorlo|first=TP|author2=Balasegaram, M |author3=Beijnen, JH |author4= de Vries, PJ |title=Miltefosine: a review of its pharmacology and therapeutic efficacy in the treatment of leishmaniasis.|journal=The Journal of antimicrobial chemotherapy|date=Nov 2012|volume=67|issue=11|pages=2576–97|pmid=22833634|doi=10.1093/jac/dks275}}&lt;/ref&gt;iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni, yi-paramomycin[[, i-fluconazole]], nofana[[i-pentamidine]] nayo ingasebenza kuhle ukulapha.&lt;ref name=Min2007&gt;{{Wp/nd/cite journal|last=Minodier|first=P|author2=Parola, P |title=Cutaneous leishmaniasis treatment.|journal=Travel medicine and infectious disease|date=May 2007|volume=5|issue=3|pages=150–8|pmid=17448941|doi=10.1016/j.tmaid.2006.09.004}}&lt;/ref&gt;

&lt;!-- Epidemiology --&gt;
Abantu ababalelwa eegigidini ezili-12 baphethwe bulwelwe lobu njenganje&lt;ref name=Mag&gt;{{Wp/nd/cite web|title=Leishmaniasis Magnitude of the problem|url=http://www.who.int/leishmaniasis/burden/magnitude/burden_magnitude/en/index.html|work=World Health Organization|accessdate=17 February 2014}}&lt;/ref&gt; eenrheni ezingaba ma-98.&lt;ref name=Barrett2012&gt;{{Wp/nd/cite journal|last=Barrett|first=MP|author2=Croft, SL |title=Management of trypanosomiasis and leishmaniasis.|journal=British medical bulletin|year=2012|volume=104|pages=175–96|pmid=23137768|doi=10.1093/bmb/lds031|pmc=3530408}}&lt;/ref&gt; Kubikwa amacala ukufikelela iingidigidi ezi-2&lt;ref name=Barrett2012/&gt; bese kuthi hlangana nama-20 weekulungwana kanye nama-50 weenkuungana zokubhubha kwabantu ngomnyaka.&lt;ref name=WHO2014/&gt;&lt;ref name=Loz2012&gt;{{Wp/nd/cite journal|last=Lozano|first=R|title=Global and regional mortality from 235 causes of death for 20 age groups in 1990 and 2010: a systematic analysis for the Global Burden of Disease Study 2010.|journal=Lancet|date=Dec 15, 2012|volume=380|issue=9859|pages=2095–128|pmid=23245604|doi=10.1016/S0140-6736(12)61728-0}}&lt;/ref&gt; Ukubalelwa ematjhumini ama-200&amp;nbsp; iingidigidi zabantu abahlala e-Asia,Afrika,iSewula neNgaphakathi le-Amerikha, isewula yeYurobhu bahlala eendaweni lapha ubulwelwe lobu bujayelekele khona.&lt;ref name=Barrett2012/&gt;&lt;ref&gt;{{Wp/nd/cite journal|last=Ejazi|first=SA|author2=Ali, N |title=Developments in diagnosis and treatment of visceral leishmaniasis during the last decade and future prospects.|journal=Expert review of anti-infective therapy|date=Jan 2013|volume=11|issue=1|pages=79–98|pmid=23428104|doi=10.1586/eri.12.148}}&lt;/ref&gt; I[[hlangano yeZepilo yePhasi Zombelele-WHO]]iphulelwe iintengo eziyibhadala ukuthenga iinhlahla zokulapha ubulwelwe lobu&lt;ref name=Barrett2012/&gt; Ubulwelwe lobu bungatheleleka nakezinye iinlwana ezimbalwa, ukufaka[[iLitjhimanisisi |yezinja]] kanye [[naborodo besiganga]].&lt;ref name=WHO2014/&gt;

== isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi ==
{{Wp/nr/Reflist|colwidth=25em}}

[[Mkhakha:Wp/nd]]</text>
      <sha1>2hfpjxiwv016g5uwpj4wwof7cnjbd82</sha1>
    </revision>
    <revision>
      <id>5967</id>
      <parentid>5080</parentid>
      <timestamp>2025-11-09T14:02:48Z</timestamp>
      <contributor>
        <username>~2025-31992-67</username>
        <id>1112</id>
      </contributor>
      <origin>5967</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7227" sha1="a2y6e5yw7dbh40w3ok2gnej69ylfvnf" xml:space="preserve">{{Wp/nd/Infobox disease
| name            = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana
| image           = Skin ulcer due to leishmaniasis, hand of Central American adult 3MG0037 lores.jpg
| caption         = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni[[esandleni]]sesakhamuzi esihlala e-Amerikha
| Field           = [[Infectious disease (medical specialty)|Infectious disease]]
| pronounce       = Leishmaniasis {{IPAc-en|ˌ|l|iː|ʃ|m|ə|ˈ|n|aɪ|ə|s|ɪ|s}}&lt;br&gt;leishmaniosis {{IPAc-en|l|iː|ʃ|ˌ|m|eɪ|n|ɪ|ˈ|əʊ|s|ɪ|s}} or {{IPAc-en|l|iː|ʃ|ˌ|m|æ|n|ɪ|ˈ|əʊ|s|ɪ|s}}&lt;ref&gt;http://www.collinsdictionary.com/dictionary/english/leishmaniasis&lt;/ref&gt;
| ICD10           = {{Wp/nd/ICD10|B|55||b|50}}
| ICD9            = {{Wp/nd/ICD9|085}}
| DiseasesDB      = 3266
| DiseasesDB_mult = {{DiseasesDB2|29171}}&lt;!--  {{DiseasesDB2|3266}} {{DiseasesDB2|7070}} --&gt;
| MedlinePlus     = 001386
| eMedicineSubj   = emerg
| eMedicineTopic  = 296
| MeshID          = D007896
}}
''' iLitjhimanisi '''ungayibiza uthi'''yilitjhimanisi''', bulwelwe [[obubangwa]] silwanyana esincani [[esibizwa ngokuthi]]yi-phrotozowa ephila ngokuhlala kezinye iinlwana/abantu bona iphile [[itheleleka]] ngokulunywa [[mhlobo othize wengogwana]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu bungavela ngeendlela ezintathu: [[Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni| ukulunywa yingogwana esikhunjeni]] ukutheleleka esikhumbeni nomzimba woke, nofana[[ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali ]].&lt;ref name=WHO2014&gt;{{Wp/nd/cite web|title=Leishmaniasis Fact sheet N°375|url=http://www.who.int/mediacentre/factsheets/fs375/en/|work=World Health Organization|accessdate=17 February 2014|date=January 2014}}&lt;/ref&gt; Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni benza umuntu avele isilonda sangaphakathi esikhunjeni, bese ukutheleleka esikhumbeni nomzimba woke kubonakala lokha sele itheleleka esikhumbeni yenze isilonda emlonyeni kanye nepumulweni, bese iLitjhimanisi nasele isezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni ibonakala ngesilonda esingendeni esiphathisa ihloko nomgomani, ibangela namasotja womzimba abe bovu, kanye nokuvuvukisa isibindi. &lt;ref name=WHO2014/&gt;&lt;ref name=Barrett2012/&gt;

&lt;!-- Cause and diagnosis --&gt;
Kunemihlobohlobo ema-20 yeengogwana &quot;zeLitjhimanisi&quot; ezibamba abantu abaphilako&lt;ref name=WHO2014/&gt; Unobangela wobulwelwe lobu nobungozi babo bufaka hlangana ubuchaka, ukungadli ukudla okunepilo, ukususwa nokutjhiswa kwamahlathi, kanye nokuthutha kwabantu bayokuhlala emadorobhei khulu.&lt;ref name=WHO2014/&gt; Yoke imihlobo emithathu yobulwelwe lobu bungabonwa ngesilwanyana nofana ingogwana ephila ngezinye iinlwana kwaphela ngokusetjenziswa komtjhini onerhalasi okhulisa izinto ezincani zibe zikulu.&lt;ref name=WHO2014/&gt; Ukungezelela kilokho, ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali bungabonwa kwaphela ngokuhlolwa kweengazi zaloyo othelelekileko.&lt;ref name=Barrett2012/&gt;

&lt;!-- Prevention and treatment --&gt;
Ubulwelwe iLitjhimanisi bungavikelwa ngkuthi ulale ngaphakathi kwenedi yetende[[ ethelwe ngesihlahla sokuvikela iingogwan]].&lt;ref name=WHO2014/&gt; Ezinye zeendlela zokuvikela kufaka hlangana nokufufuzela isifufuzeli sokuvikela ukulunywa ziingogwana ukwazi ukuzibulala kanye nokulatjhwa kwabantu abangenwe bulwelwe lobu kusese nesikhathi bungakasabalali umzimba woke.&lt;ref name=WHO2014/&gt; Ukulatjhwa okutlhogekako kwenziwa nange kwaziwa bona ubulwelwe lobu buthalakele kiyiphi indawo, umhlobo &quot;weLitjhiminiya&quot; kanye nehlobo lengongwana engenileko.&lt;ref name=WHO2014/&gt; Ezinye zeenhlahla ezingalapha iLitjhimanisi nasele [https://www.pandaboyama.com.tr/ Türbanlı Porno İzle]esezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni [[ kufaka hlangana i-liposomal amphotericin B]],&lt;ref name=Sun2013/&gt; ihlanganiso le[[le-pentavalent antimonials]]kanye [[ne-}paromomycin]],&lt;ref name=Sun2013&gt;{{Wp/nd/cite journal|last=Sundar|first=S|author2=Chakravarty, J |title=Leishmaniasis: an update of current pharmacotherapy.|journal=Expert opinion on pharmacotherapy|date=Jan 2013|volume=14|issue=1|pages=53–63|pmid=23256501|doi=10.1517/14656566.2013.755515}}&lt;/ref&gt; and [[miltefosine]].&lt;ref name=Dor2012&gt;{{Wp/nd/cite journal|last=Dorlo|first=TP|author2=Balasegaram, M |author3=Beijnen, JH |author4= de Vries, PJ |title=Miltefosine: a review of its pharmacology and therapeutic efficacy in the treatment of leishmaniasis.|journal=The Journal of antimicrobial chemotherapy|date=Nov 2012|volume=67|issue=11|pages=2576–97|pmid=22833634|doi=10.1093/jac/dks275}}&lt;/ref&gt;iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni, yi-paramomycin[[, i-fluconazole]], nofana[[i-pentamidine]] nayo ingasebenza kuhle ukulapha.&lt;ref name=Min2007&gt;{{Wp/nd/cite journal|last=Minodier|first=P|author2=Parola, P |title=Cutaneous leishmaniasis treatment.|journal=Travel medicine and infectious disease|date=May 2007|volume=5|issue=3|pages=150–8|pmid=17448941|doi=10.1016/j.tmaid.2006.09.004}}&lt;/ref&gt;

&lt;!-- Epidemiology --&gt;
Abantu ababalelwa eegigidini ezili-12 baphethwe bulwelwe lobu njenganje&lt;ref name=Mag&gt;{{Wp/nd/cite web|title=Leishmaniasis Magnitude of the problem|url=http://www.who.int/leishmaniasis/burden/magnitude/burden_magnitude/en/index.html|work=World Health Organization|accessdate=17 February 2014}}&lt;/ref&gt; eenrheni ezingaba ma-98.&lt;ref name=Barrett2012&gt;{{Wp/nd/cite journal|last=Barrett|first=MP|author2=Croft, SL |title=Management of trypanosomiasis and leishmaniasis.|journal=British medical bulletin|year=2012|volume=104|pages=175–96|pmid=23137768|doi=10.1093/bmb/lds031|pmc=3530408}}&lt;/ref&gt; Kubikwa amacala ukufikelela iingidigidi ezi-2&lt;ref name=Barrett2012/&gt; bese kuthi hlangana nama-20 weekulungwana kanye nama-50 weenkuungana zokubhubha kwabantu ngomnyaka.&lt;ref name=WHO2014/&gt;&lt;ref name=Loz2012&gt;{{Wp/nd/cite journal|last=Lozano|first=R|title=Global and regional mortality from 235 causes of death for 20 age groups in 1990 and 2010: a systematic analysis for the Global Burden of Disease Study 2010.|journal=Lancet|date=Dec 15, 2012|volume=380|issue=9859|pages=2095–128|pmid=23245604|doi=10.1016/S0140-6736(12)61728-0}}&lt;/ref&gt; Ukubalelwa ematjhumini ama-200&amp;nbsp; iingidigidi zabantu abahlala e-Asia,Afrika,iSewula neNgaphakathi le-Amerikha, isewula yeYurobhu bahlala eendaweni lapha ubulwelwe lobu bujayelekele khona.&lt;ref name=Barrett2012/&gt;&lt;ref&gt;{{Wp/nd/cite journal|last=Ejazi|first=SA|author2=Ali, N |title=Developments in diagnosis and treatment of visceral leishmaniasis during the last decade and future prospects.|journal=Expert review of anti-infective therapy|date=Jan 2013|volume=11|issue=1|pages=79–98|pmid=23428104|doi=10.1586/eri.12.148}}&lt;/ref&gt; I[[hlangano yeZepilo yePhasi Zombelele-WHO]]iphulelwe iintengo eziyibhadala ukuthenga iinhlahla zokulapha ubulwelwe lobu&lt;ref name=Barrett2012/&gt; Ubulwelwe lobu bungatheleleka nakezinye iinlwana ezimbalwa, ukufaka[[iLitjhimanisisi |yezinja]] kanye [[naborodo besiganga]].&lt;ref name=WHO2014/&gt;

== isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi ==
{{Wp/nr/Reflist|colwidth=25em}}

[[Mkhakha:Wp/nd]]</text>
      <sha1>a2y6e5yw7dbh40w3ok2gnej69ylfvnf</sha1>
    </revision>
    <revision>
      <id>5979</id>
      <parentid>5967</parentid>
      <timestamp>2025-11-10T20:24:59Z</timestamp>
      <contributor>
        <username>~2025-32613-77</username>
        <id>1119</id>
      </contributor>
      <origin>5979</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7285" sha1="on8wfajvqgg1660h59tsn7ddf62jxyd" xml:space="preserve">{{Wp/nd/Infobox disease
| name            = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana
| image           = Skin ulcer due to leishmaniasis, hand of Central American adult 3MG0037 lores.jpg
| caption         = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni[[esandleni]]sesakhamuzi esihlala e-Amerikha
| Field           = [[Infectious disease (medical specialty)|Infectious disease]]
| pronounce       = Leishmaniasis {{IPAc-en|ˌ|l|iː|ʃ|m|ə|ˈ|n|aɪ|ə|s|ɪ|s}}&lt;br&gt;leishmaniosis {{IPAc-en|l|iː|ʃ|ˌ|m|eɪ|n|ɪ|ˈ|əʊ|s|ɪ|s}} or {{IPAc-en|l|iː|ʃ|ˌ|m|æ|n|ɪ|ˈ|əʊ|s|ɪ|s}}&lt;ref&gt;http://www.collinsdictionary.com/dictionary/english/leishmaniasis&lt;/ref&gt;
| ICD10           = {{Wp/nd/ICD10|B|55||b|50}}
| ICD9            = {{Wp/nd/ICD9|085}}
| DiseasesDB      = 3266
| DiseasesDB_mult = {{DiseasesDB2|29171}}&lt;!--  {{DiseasesDB2|3266}} {{DiseasesDB2|7070}} --&gt;
| MedlinePlus     = 001386
| eMedicineSubj   = emerg
| eMedicineTopic  = 296
| MeshID          = D007896
}}
''' iLitjhimanisi '''ungayibiza uthi'''yilitjhimanisi''', bulwelwe [[obubangwa]] silwanyana esincani [[esibizwa ngokuthi]]yi-phrotozowa ephila ngokuhlala kezinye iinlwana/abantu bona iphile [[itheleleka]] ngokulunywa [[mhlobo othize wengogwana]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu bungavela ngeendlela ezintathu: [[Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni| ukulunywa yingogwana esikhunjeni]] ukutheleleka esikhumbeni nomzimba woke, nofana[[ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali ]].&lt;ref name=WHO2014&gt;{{Wp/nd/cite web|title=Leishmaniasis Fact sheet N°375|url=http://www.who.int/mediacentre/factsheets/fs375/en/|work=World Health Organization|accessdate=17 February 2014|date=January 2014}}&lt;/ref&gt; Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni benza umuntu avele isilonda sangaphakathi esikhunjeni, bese ukutheleleka esikhumbeni nomzimba woke kubonakala lokha sele itheleleka esikhumbeni yenze isilonda emlonyeni kanye nepumulweni, bese iLitjhimanisi nasele isezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni ibonakala ngesilonda esingendeni esiphathisa ihloko nomgomani, ibangela namasotja womzimba abe bovu, kanye nokuvuvukisa isibindi. &lt;ref name=WHO2014/&gt;&lt;ref name=Barrett2012/&gt;

&lt;!-- Cause and diagnosis --&gt;
Kunemihlobohlobo ema-20 yeengogwana &quot;zeLitjhimanisi&quot; ezibamba abantu abaphilako&lt;ref name=WHO2014/&gt; Unobangela wobulwelwe lobu nobungozi babo bufaka hlangana ubuchaka, ukungadli ukudla okunepilo, ukususwa nokutjhiswa kwamahlathi, kanye nokuthutha kwabantu bayokuhlala emadorobhei khulu.&lt;ref name=WHO2014/&gt; Yoke imihlobo emithathu yobulwelwe lobu bungabonwa ngesilwanyana nofana ingogwana ephila ngezinye iinlwana kwaphela ngokusetjenziswa komtjhini onerhalasi okhulisa izinto ezincani zibe zikulu.&lt;ref name=WHO2014/&gt; Ukungezelela kilokho, ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali bungabonwa kwaphela ngokuhlolwa kweengazi zaloyo othelelekileko.&lt;ref name=Barrett2012/&gt;

&lt;!-- Prevention and treatment --&gt;
Ubulwelwe iLitjhimanisi bungavikelwa ngkuthi ulale ngaphakathi kwenedi yetende[[ ethelwe ngesihlahla sokuvikela iingogwan]].&lt;ref name=WHO2014/&gt; Ezinye zeendlela zokuvikela kufaka hlangana nokufufuzela isifufuzeli sokuvikela ukulunywa ziingogwana ukwazi ukuzibulala kanye nokulatjhwa kwabantu abangenwe bulwelwe lobu kusese nesikhathi bungakasabalali umzimba woke.&lt;ref name=WHO2014/&gt; Ukulatjhwa okutlhogekako kwenziwa nange kwaziwa bona ubulwelwe lobu buthalakele kiyiphi indawo, umhlobo &quot;weLitjhiminiya&quot; kanye nehlobo lengongwana engenileko.&lt;ref name=WHO2014/&gt; Ezinye zeenhlahla ezingalapha iLitjhimanisi nasele [https://www.pandaboyama.com.tr/ Türbanlı Porno İzle]esezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni [[ kufaka hlangana i-liposomal amphotericin B]],&lt;ref name=Sun2013/&gt; ihlanganiso le[[le-pentavalent antimonials]]kanye [[ne-}paromomycin]],&lt;ref name=Sun2013&gt;{{Wp/nd/cite journal|last=Sundar|first=S|author2=Chakravarty, J |title=Leishmaniasis: an update of current pharmacotherapy.|journal=Expert opinion on pharmacotherapy|date=Jan 2013|volume=14|issue=1|pages=53–63|pmid=23256501|doi=10.1517/14656566.2013.755515}}&lt;/ref&gt; and [[miltefosine]].&lt;ref name=Dor2012&gt;{{Wp/nd/cite journal|last=Dorlo|first=TP|author2=Balasegaram, M |author3=Beijnen, JH |author4= de Vries, PJ |title=Miltefosine: a review of its pharmacology and therapeutic efficacy in the treatment of leishmaniasis.|journal=The Journal of antimicrobial chemotherapy|date=Nov 2012|volume=67|issue=11|pages=2576–97|pmid=22833634|doi=10.1093/jac/dks275}}&lt;/ref&gt;iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni, yi-paramomycin[[, i-fluconazole]], nofana[[i-pentamidine]] nayo ingasebenza kuhlasde ukulapha.&lt;ref name=Min2007&gt;{{Wp/nd/cite journal|last=Minodier|first=P|author2=Parola, P |title=Cutaneous leishmaniasis treatment.|journal=Travel medicine and infectious disease|date=May 2007|volume=5|issue=3|pages=150–8|pmid=17448941|doi=10.1016/j.tmaid.2006.09.004}}&lt;/ref&gt;

&lt;!-- Epidemiology --&gt;
[https://www.pandaboyama.com.tr Türbanlı Pono İzle] Abantu ababalelwa eegigidini ezili-12 baphethwe bulwelwe lobu njenganje&lt;ref name=Mag&gt;{{Wp/nd/cite web|title=Leishmaniasis Magnitude of the problem|url=http://www.who.int/leishmaniasis/burden/magnitude/burden_magnitude/en/index.html|work=World Health Organization|accessdate=17 February 2014}}&lt;/ref&gt; eenrheni ezingaba ma-98.&lt;ref name=Barrett2012&gt;{{Wp/nd/cite journal|last=Barrett|first=MP|author2=Croft, SL |title=Management of trypanosomiasis and leishmaniasis.|journal=British medical bulletin|year=2012|volume=104|pages=175–96|pmid=23137768|doi=10.1093/bmb/lds031|pmc=3530408}}&lt;/ref&gt; Kubikwa amacala ukufikelela iingidigidi ezi-2&lt;ref name=Barrett2012/&gt; bese kuthi hlangana nama-20 weekulungwana kanye nama-50 weenkuungana zokubhubha kwabantu ngomnyaka.&lt;ref name=WHO2014/&gt;&lt;ref name=Loz2012&gt;{{Wp/nd/cite journal|last=Lozano|first=R|title=Global and regional mortality from 235 causes of death for 20 age groups in 1990 and 2010: a systematic analysis for the Global Burden of Disease Study 2010.|journal=Lancet|date=Dec 15, 2012|volume=380|issue=9859|pages=2095–128|pmid=23245604|doi=10.1016/S0140-6736(12)61728-0}}&lt;/ref&gt; Ukubalelwa ematjhumini ama-200&amp;nbsp; iingidigidi zabantu abahlala e-Asia,Afrika,iSewula neNgaphakathi le-Amerikha, isewula yeYurobhu bahlala eendaweni lapha ubulwelwe lobu bujayelekele khona.&lt;ref name=Barrett2012/&gt;&lt;ref&gt;{{Wp/nd/cite journal|last=Ejazi|first=SA|author2=Ali, N |title=Developments in diagnosis and treatment of visceral leishmaniasis during the last decade and future prospects.|journal=Expert review of anti-infective therapy|date=Jan 2013|volume=11|issue=1|pages=79–98|pmid=23428104|doi=10.1586/eri.12.148}}&lt;/ref&gt; I[[hlangano yeZepilo yePhasi Zombelele-WHO]]iphulelwe iintengo eziyibhadala ukuthenga iinhlahla zokulapha ubulwelwe lobu&lt;ref name=Barrett2012/&gt; Ubulwelwe lobu bungatheleleka nakezinye iinlwana ezimbalwa, ukufaka[[iLitjhimanisisi |yezinja]] kanye [[naborodo besiganga]].&lt;ref name=WHO2014/&gt;

== isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi ==
{{Wp/nr/Reflist|colwidth=25em}}

[[Mkhakha:Wp/nd]]</text>
      <sha1>on8wfajvqgg1660h59tsn7ddf62jxyd</sha1>
    </revision>
    <revision>
      <id>6010</id>
      <parentid>5979</parentid>
      <timestamp>2025-11-19T21:33:14Z</timestamp>
      <contributor>
        <username>A09</username>
        <id>35</id>
      </contributor>
      <comment>Restored revision 3140 by [[Special:Contributions/DreamRimmer|DreamRimmer]] ([[User talk:DreamRimmer|talk]]): Rvv (TwinkleGlobal)</comment>
      <origin>6010</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7171" sha1="6r2dnsjauon9hqibfe8ubie9i1a3jyq" xml:space="preserve">{{Wp/nd/Infobox disease
| name            = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana
| image           = Skin ulcer due to leishmaniasis, hand of Central American adult 3MG0037 lores.jpg
| caption         = Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni[[esandleni]]sesakhamuzi esihlala e-Amerikha
| Field           = [[Infectious disease (medical specialty)|Infectious disease]]
| pronounce       = Leishmaniasis {{IPAc-en|ˌ|l|iː|ʃ|m|ə|ˈ|n|aɪ|ə|s|ɪ|s}}&lt;br&gt;leishmaniosis {{IPAc-en|l|iː|ʃ|ˌ|m|eɪ|n|ɪ|ˈ|əʊ|s|ɪ|s}} or {{IPAc-en|l|iː|ʃ|ˌ|m|æ|n|ɪ|ˈ|əʊ|s|ɪ|s}}&lt;ref&gt;http://www.collinsdictionary.com/dictionary/english/leishmaniasis&lt;/ref&gt;
| ICD10           = {{Wp/nd/ICD10|B|55||b|50}}
| ICD9            = {{Wp/nd/ICD9|085}}
| DiseasesDB      = 3266
| DiseasesDB_mult = {{DiseasesDB2|29171}}&lt;!--  {{DiseasesDB2|3266}} {{DiseasesDB2|7070}} --&gt;
| MedlinePlus     = 001386
| eMedicineSubj   = emerg
| eMedicineTopic  = 296
| MeshID          = D007896
}}
''' iLitjhimanisi '''ungayibiza uthi'''yilitjhimanisi''', bulwelwe [[obubangwa]] silwanyana esincani [[esibizwa ngokuthi]]yi-phrotozowa ephila ngokuhlala kezinye iinlwana/abantu bona iphile [[itheleleka]] ngokulunywa [[mhlobo othize wengogwana]].&lt;ref name=WHO2014/&gt; Ubulwelwe lobu bungavela ngeendlela ezintathu: [[Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni| ukulunywa yingogwana esikhunjeni]] ukutheleleka esikhumbeni nomzimba woke, nofana[[ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali ]].&lt;ref name=WHO2014&gt;{{Wp/nd/cite web|title=Leishmaniasis Fact sheet N°375|url=http://www.who.int/mediacentre/factsheets/fs375/en/|work=World Health Organization|accessdate=17 February 2014|date=January 2014}}&lt;/ref&gt; Ubulwelwe iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni benza umuntu avele isilonda sangaphakathi esikhunjeni, bese ukutheleleka esikhumbeni nomzimba woke kubonakala lokha sele itheleleka esikhumbeni yenze isilonda emlonyeni kanye nepumulweni, bese iLitjhimanisi nasele isezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni ibonakala ngesilonda esingendeni esiphathisa ihloko nomgomani, ibangela namasotja womzimba abe bovu, kanye nokuvuvukisa isibindi. &lt;ref name=WHO2014/&gt;&lt;ref name=Barrett2012/&gt;

&lt;!-- Cause and diagnosis --&gt;
Kunemihlobohlobo ema-20 yeengogwana &quot;zeLitjhimaniya&quot; ezibamba abantu abaphilako&lt;ref name=WHO2014/&gt; Unobangela wobulwelwe lobu nobungozi babo bufaka hlangana ubuchaka, ukungadli ukudla okunepilo, ukususwa nokutjhiswa kwamahlathi, kanye nokuthutha kwabantu bayokuhlala emadorobhei khulu.&lt;ref name=WHO2014/&gt; Yoke imihlobo emithathu yobulwelwe lobu bungabonwa ngesilwanyana nofana ingogwana ephila ngezinye iinlwana kwaphela ngokusetjenziswa komtjhini onerhalasi okhulisa izinto ezincani zibe zikulu.&lt;ref name=WHO2014/&gt; Ukungezelela kilokho, ubulwelwe iLitjhimanisi nasele busezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni -i-viserali bungabonwa kwaphela ngokuhlolwa kweengazi zaloyo othelelekileko.&lt;ref name=Barrett2012/&gt;

&lt;!-- Prevention and treatment --&gt;
Ubulwelwe iLitjhimanisi bungavikelwa ngkuthi ulale ngaphakathi kwenedi yetende[[ ethelwe ngesihlahla sokuvikela iingogwan]].&lt;ref name=WHO2014/&gt; Ezinye zeendlela zokuvikela kufaka hlangana nokufufuzela isifufuzeli sokuvikela ukulunywa ziingogwana ukwazi ukuzibulala kanye nokulatjhwa kwabantu abangenwe bulwelwe lobu kusese nesikhathi bungakasabalali umzimba woke.&lt;ref name=WHO2014/&gt; Ukulatjhwa okutlhogekako kwenziwa nange kwaziwa bona ubulwelwe lobu buthalakele kiyiphi indawo, umhlobo &quot;weLitjhiminiya&quot; kanye nehlobo lengongwana engenileko.&lt;ref name=WHO2014/&gt; Ezinye zeenhlahla ezingalapha iLitjhimanisi nasele esezingeni eliphezulu khulu ngemva ngokulunywa yingongwana esikhumbeni [[ kufaka hlangana i-liposomal amphotericin B]],&lt;ref name=Sun2013/&gt; ihlanganiso le[[le-pentavalent antimonials]]kanye [[ne-}paromomycin]],&lt;ref name=Sun2013&gt;{{Wp/nd/cite journal|last=Sundar|first=S|author2=Chakravarty, J |title=Leishmaniasis: an update of current pharmacotherapy.|journal=Expert opinion on pharmacotherapy|date=Jan 2013|volume=14|issue=1|pages=53–63|pmid=23256501|doi=10.1517/14656566.2013.755515}}&lt;/ref&gt; and [[miltefosine]].&lt;ref name=Dor2012&gt;{{Wp/nd/cite journal|last=Dorlo|first=TP|author2=Balasegaram, M |author3=Beijnen, JH |author4= de Vries, PJ |title=Miltefosine: a review of its pharmacology and therapeutic efficacy in the treatment of leishmaniasis.|journal=The Journal of antimicrobial chemotherapy|date=Nov 2012|volume=67|issue=11|pages=2576–97|pmid=22833634|doi=10.1093/jac/dks275}}&lt;/ref&gt;iLitjhimanisi obutholakala ngokulunywa yingongwana esikhumbeni, yi-paramomycin[[, i-fluconazole]], nofana[[i-pentamidine]] nayo ingasebenza kuhle ukulapha.&lt;ref name=Min2007&gt;{{Wp/nd/cite journal|last=Minodier|first=P|author2=Parola, P |title=Cutaneous leishmaniasis treatment.|journal=Travel medicine and infectious disease|date=May 2007|volume=5|issue=3|pages=150–8|pmid=17448941|doi=10.1016/j.tmaid.2006.09.004}}&lt;/ref&gt;

&lt;!-- Epidemiology --&gt;
Abantu ababalelwa eegigidini ezili-12 baphethwe bulwelwe lobu njenganje&lt;ref name=Mag&gt;{{Wp/nd/cite web|title=Leishmaniasis Magnitude of the problem|url=http://www.who.int/leishmaniasis/burden/magnitude/burden_magnitude/en/index.html|work=World Health Organization|accessdate=17 February 2014}}&lt;/ref&gt; eenrheni ezingaba ma-98.&lt;ref name=Barrett2012&gt;{{Wp/nd/cite journal|last=Barrett|first=MP|author2=Croft, SL |title=Management of trypanosomiasis and leishmaniasis.|journal=British medical bulletin|year=2012|volume=104|pages=175–96|pmid=23137768|doi=10.1093/bmb/lds031|pmc=3530408}}&lt;/ref&gt; Kubikwa amacala ukufikelela iingidigidi ezi-2&lt;ref name=Barrett2012/&gt; bese kuthi hlangana nama-20 weekulungwana kanye nama-50 weenkuungana zokubhubha kwabantu ngomnyaka.&lt;ref name=WHO2014/&gt;&lt;ref name=Loz2012&gt;{{Wp/nd/cite journal|last=Lozano|first=R|title=Global and regional mortality from 235 causes of death for 20 age groups in 1990 and 2010: a systematic analysis for the Global Burden of Disease Study 2010.|journal=Lancet|date=Dec 15, 2012|volume=380|issue=9859|pages=2095–128|pmid=23245604|doi=10.1016/S0140-6736(12)61728-0}}&lt;/ref&gt; Ukubalelwa ematjhumini ama-200&amp;nbsp; iingidigidi zabantu abahlala e-Asia,Afrika,iSewula neNgaphakathi le-Amerikha, isewula yeYurobhu bahlala eendaweni lapha ubulwelwe lobu bujayelekele khona.&lt;ref name=Barrett2012/&gt;&lt;ref&gt;{{Wp/nd/cite journal|last=Ejazi|first=SA|author2=Ali, N |title=Developments in diagnosis and treatment of visceral leishmaniasis during the last decade and future prospects.|journal=Expert review of anti-infective therapy|date=Jan 2013|volume=11|issue=1|pages=79–98|pmid=23428104|doi=10.1586/eri.12.148}}&lt;/ref&gt; I[[hlangano yeZepilo yePhasi Zombelele-WHO]]iphulelwe iintengo eziyibhadala ukuthenga iinhlahla zokulapha ubulwelwe lobu&lt;ref name=Barrett2012/&gt; Ubulwelwe lobu bungatheleleka nakezinye iinlwana ezimbalwa, ukufaka[[iLitjhimanisisi |yezinja]] kanye [[naborodo besiganga]].&lt;ref name=WHO2014/&gt;

== isikhombiso esikulayela bona ilwazi elithileko ungalitholaphi ==
{{Wp/nr/Reflist|colwidth=25em}}

[[Mkhakha:Wp/nd]]</text>
      <sha1>6r2dnsjauon9hqibfe8ubie9i1a3jyq</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Wp/nr/Reflist</title>
    <ns>10</ns>
    <id>398</id>
    <revision>
      <id>2054</id>
      <timestamp>2014-09-02T10:42:44Z</timestamp>
      <contributor>
        <username>incubator&gt;CFCF</username>
        <id>0</id>
      </contributor>
      <comment>From [[:en:Template:Reflist]]</comment>
      <origin>2054</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="817" sha1="4gkyehj7b4opv62ycz6r0hb716dhgog" xml:space="preserve">&lt;div class=&quot;reflist &lt;!--
 --&gt;{{#if: {{{1|}}}
    | columns {{#iferror: {{#ifexpr: {{{1|1}}} &gt; 1 }}
      | references-column-width 
      | references-column-count references-column-count-{{#if:1|{{{1}}}}} }}
    | {{#if: {{{colwidth|}}}
      | references-column-width }} }}&quot; style=&quot;&lt;!--
 --&gt;{{#if: {{{1|}}}
    | {{#iferror: {{#ifexpr: {{{1|1}}} &gt; 1 }}
      | {{column-width|{{#if:1|{{{1}}}}}}}
      | {{column-count|{{#if:1|{{{1}}}}}}} }}
    | {{#if: {{{colwidth|}}}
      | {{column-width|{{{colwidth}}}}} }} }} list-style-type: &lt;!--
 --&gt;{{{liststyle|{{#switch: {{{group|}}}
    | upper-alpha
    | upper-roman
    | lower-alpha
    | lower-greek
    | lower-roman = {{{group}}}
    | #default = decimal}}}}};&quot;&gt;
{{#tag:references|{{{refs|}}}|group={{{group|}}}}}&lt;/div&gt;&lt;noinclude&gt;
{{Documentation}}
&lt;/noinclude&gt;</text>
      <sha1>4gkyehj7b4opv62ycz6r0hb716dhgog</sha1>
    </revision>
    <revision>
      <id>2055</id>
      <parentid>2054</parentid>
      <timestamp>2016-02-23T14:23:51Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <origin>2055</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="464" sha1="k5ypi8e538g8wp13da525fg2svgzdrg" xml:space="preserve">&lt;div class=&quot;references-small&quot; {{#if: {{{colwidth|}}}| style=&quot;-moz-column-width:{{{colwidth}}}; -webkit-column-width:{{{colwidth}}}; column-width:{{{colwidth}}};&quot; | {{#if: {{{1|}}}| style=&quot;-moz-column-count:{{{1}}}; -webkit-column-count:{{{1}}}; column-count:{{{1}}};&quot; }} }}&gt;
{{#tag:references||group={{{group|}}}}}&lt;/div&gt;&lt;noinclude&gt;{{pp-template|small=yes}}{{documentation}}
[[br:Patrom:Reflist]]
[[he:תבנית:Reflist]]
[[pt:Predefinição:Reflist]]
&lt;/noinclude&gt;</text>
      <sha1>k5ypi8e538g8wp13da525fg2svgzdrg</sha1>
    </revision>
    <revision>
      <id>2056</id>
      <parentid>2055</parentid>
      <timestamp>2016-02-23T14:24:47Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <origin>2056</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="453" sha1="pg17ayrtf0rv6frsevxjc8t76d2qgb9" xml:space="preserve">&lt;div class=&quot;references-small&quot; {{#if: {{{colwidth|}}}| style=&quot;-moz-column-width:{{{colwidth}}}; -webkit-column-width:{{{colwidth}}}; column-width:{{{colwidth}}};&quot; | {{#if: {{{1|}}}| style=&quot;-moz-column-count:{{{1}}}; -webkit-column-count:{{{1}}}; column-count:{{{1}}};&quot; }} }}&gt;
{{#tag:references||group={{{group|}}}}}&lt;/div&gt;&lt;noinclude&gt;{{Wp/nr/pp-template|small=yes}}
[[br:Patrom:Reflist]]
[[he:תבנית:Reflist]]
[[pt:Predefinição:Reflist]]
&lt;/noinclude&gt;</text>
      <sha1>pg17ayrtf0rv6frsevxjc8t76d2qgb9</sha1>
    </revision>
    <revision>
      <id>2057</id>
      <parentid>2056</parentid>
      <timestamp>2024-11-18T17:50:11Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <minor />
      <comment>3 revisions imported from [[:incubator:Template:Wp/nr/Reflist]]</comment>
      <origin>2056</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="453" sha1="pg17ayrtf0rv6frsevxjc8t76d2qgb9" xml:space="preserve">&lt;div class=&quot;references-small&quot; {{#if: {{{colwidth|}}}| style=&quot;-moz-column-width:{{{colwidth}}}; -webkit-column-width:{{{colwidth}}}; column-width:{{{colwidth}}};&quot; | {{#if: {{{1|}}}| style=&quot;-moz-column-count:{{{1}}}; -webkit-column-count:{{{1}}}; column-count:{{{1}}};&quot; }} }}&gt;
{{#tag:references||group={{{group|}}}}}&lt;/div&gt;&lt;noinclude&gt;{{Wp/nr/pp-template|small=yes}}
[[br:Patrom:Reflist]]
[[he:תבנית:Reflist]]
[[pt:Predefinição:Reflist]]
&lt;/noinclude&gt;</text>
      <sha1>pg17ayrtf0rv6frsevxjc8t76d2qgb9</sha1>
    </revision>
  </page>
  <page>
    <title>Wp/nd/ILitjhimanisi</title>
    <ns>0</ns>
    <id>399</id>
    <redirect title="ILitjhimanisi" />
    <revision>
      <id>2059</id>
      <timestamp>2024-11-18T17:50:21Z</timestamp>
      <contributor>
        <username>Amire80</username>
        <id>78</id>
      </contributor>
      <comment>Amire80 moved page [[Wp/nd/ILitjhimanisi]] to [[ILitjhimanisi]]</comment>
      <origin>2059</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="27" sha1="qak6e9wjeko57ozyfbydfv802mnpqnr" xml:space="preserve">#REDIRECT [[ILitjhimanisi]]</text>
      <sha1>qak6e9wjeko57ozyfbydfv802mnpqnr</sha1>
    </revision>
  </page>
  <page>
    <title>Zambia</title>
    <ns>0</ns>
    <id>400</id>
    <revision>
      <id>2060</id>
      <timestamp>2024-11-19T00:57:43Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1258104038|Zambia]]&quot;</comment>
      <origin>2060</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="693" sha1="hghv1f6dig1i8rrrzew1n57y81f7suy" xml:space="preserve">
'''I-Zambia''', ngokusemthethwen'''i iRiphabhliki ye-Zambia,''' lilizwe elinganamanzi elihlangana ne-Central, Southern kanye ne-East Africa. Ngokuvamileko kutjho ukuba se-Afrika eSewula-Phakathi nofana e-Afrika eseSewula. Inomngcele ngetlhagwini yi-[[Democratic Republic of the Congo]], [[Tanzania|i-Tanzania]] ngetlhagwini-mpumalanga, i-Malawi ngepumalanga, i-Mozambique ngesewulapumalanga, i-Zimbabwe ne-[[Botswana]] ngesewula, i-[[Namibia]] ngesewula-tjingalanga, kanye ne-Angola ngetjingalanga. Idorobha elikhulu le-Zambia yi-[[Lusaka]], elise-Zambia esewula-maphakathi. Inani labantu lihlala khulu e-Lusaka ngesewula kanye ne-Copperbelt Province ngetlhagwini, amaziko wezomnotho welizwe.</text>
      <sha1>hghv1f6dig1i8rrrzew1n57y81f7suy</sha1>
    </revision>
    <revision>
      <id>2061</id>
      <parentid>2060</parentid>
      <timestamp>2024-11-19T01:00:23Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2061</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="846" sha1="5bsuq10scz0a6mfm1j05tjay4gdfxhu" xml:space="preserve">
'''I-Zambia''', ngokusemthethwen'''i iRiphabhliki ye-Zambia,''' lilizwe elinganamanzi elihlangana ne-Central, Southern kanye ne-East Africa. Ngokuvamileko kutjho ukuba se-Afrika eSewula-Phakathi nofana e-Afrika eseSewula. Inomngcele ngetlhagwini yi-[[Democratic Republic of the Congo]], [[Tanzania|i-Tanzania]] ngetlhagwini-mpumalanga, i-Malawi ngepumalanga, i-Mozambique ngesewulapumalanga, i-Zimbabwe ne-[[Botswana]] ngesewula, i-[[Namibia]] ngesewula-tjingalanga, kanye ne-Angola ngetjingalanga. Idorobha elikhulu le-Zambia yi-[[Lusaka]], elise-Zambia esewula-maphakathi. Inani labantu lihlala khulu e-Lusaka ngesewula kanye ne-Copperbelt Province ngetlhagwini, amaziko wezomnotho welizwe.&lt;ref&gt;https://www.africabib.org/rec.php?RID=186898584&lt;/ref&gt;&lt;ref&gt;https://scholar.ufs.ac.za/items/93b5df1b-6616-4aa6-9677-5dda35d79931&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>5bsuq10scz0a6mfm1j05tjay4gdfxhu</sha1>
    </revision>
    <revision>
      <id>2062</id>
      <parentid>2061</parentid>
      <timestamp>2024-11-19T01:02:27Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2062</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="887" sha1="21n31660z0llpyr1zgz06oifasb3tbn" xml:space="preserve">
'''I-Zambia''', ngokusemthethwen'''i iRiphabhliki ye-Zambia,''' lilizwe elinganamanzi elihlangana ne-Central, Southern kanye ne-East Africa. Ngokuvamileko kutjho ukuba se-Afrika eSewula-Phakathi nofana e-Afrika eseSewula. Inomngcele ngetlhagwini yi-[[Democratic Republic of the Congo]], [[Tanzania|i-Tanzania]] ngetlhagwini-mpumalanga, i-Malawi ngepumalanga, i-Mozambique ngesewulapumalanga, i-Zimbabwe ne-[[Botswana]] ngesewula, i-[[Namibia]] ngesewula-tjingalanga, kanye ne-Angola ngetjingalanga. Idorobha elikhulu le-Zambia yi-[[Lusaka]], elise-Zambia esewula-maphakathi. Inani labantu lihlala khulu e-Lusaka ngesewula kanye ne-Copperbelt Province ngetlhagwini, amaziko wezomnotho welizwe.&lt;ref&gt;https://www.africabib.org/rec.php?RID=186898584&lt;/ref&gt;&lt;ref&gt;https://scholar.ufs.ac.za/items/93b5df1b-6616-4aa6-9677-5dda35d79931&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}
[[Category:Iinarha zephasi]]</text>
      <sha1>21n31660z0llpyr1zgz06oifasb3tbn</sha1>
    </revision>
    <revision>
      <id>2110</id>
      <parentid>2062</parentid>
      <timestamp>2024-11-25T09:52:41Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>Mkhakha</comment>
      <origin>2110</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="887" sha1="4gbdg66pk45igajh6pbzraug9zabkoh" xml:space="preserve">
'''I-Zambia''', ngokusemthethwen'''i iRiphabhliki ye-Zambia,''' lilizwe elinganamanzi elihlangana ne-Central, Southern kanye ne-East Africa. Ngokuvamileko kutjho ukuba se-Afrika eSewula-Phakathi nofana e-Afrika eseSewula. Inomngcele ngetlhagwini yi-[[Democratic Republic of the Congo]], [[Tanzania|i-Tanzania]] ngetlhagwini-mpumalanga, i-Malawi ngepumalanga, i-Mozambique ngesewulapumalanga, i-Zimbabwe ne-[[Botswana]] ngesewula, i-[[Namibia]] ngesewula-tjingalanga, kanye ne-Angola ngetjingalanga. Idorobha elikhulu le-Zambia yi-[[Lusaka]], elise-Zambia esewula-maphakathi. Inani labantu lihlala khulu e-Lusaka ngesewula kanye ne-Copperbelt Province ngetlhagwini, amaziko wezomnotho welizwe.&lt;ref&gt;https://www.africabib.org/rec.php?RID=186898584&lt;/ref&gt;&lt;ref&gt;https://scholar.ufs.ac.za/items/93b5df1b-6616-4aa6-9677-5dda35d79931&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}

[[Mkhakha:Iinarha zephasi]]</text>
      <sha1>4gbdg66pk45igajh6pbzraug9zabkoh</sha1>
    </revision>
  </page>
  <page>
    <title>Senegal</title>
    <ns>0</ns>
    <id>401</id>
    <revision>
      <id>2063</id>
      <timestamp>2024-11-19T01:05:10Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1257982623|Senegal]]&quot;</comment>
      <origin>2063</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="575" sha1="19mwi5og237hj71hk60hptij4hojfhq" xml:space="preserve">
'''I-Senegal''', ngokusemthethweni '''iRiphabhliki ye-Senegal''',[f] yinarha engeTjingalanga khulu eTjingalanga ye-Afrika, etholakala eligwini le-Atlantic Ocean. I-Senegal inomngcele nge-Mauritania ngetlhagwini, i-Mali ngepumalanga, i-Guinea ngesewulapumalanga kanye ne-Guinea-Bissau ngesewula-ntshonalanga. I-Senegal ipheze ibhode i-Gambia, inarha ehlala indawo encani eceleni komlambo i-Gambia, ehlukanisa isifunda se-Senegal esewula se-Casamance nenarha yoke.[1][2] I-Senegal nayo inomngcele welwandle ne-Cape Verde. Ikomkhulu lezomnotho nezepolotiki le-Senegal yi-Dakar.</text>
      <sha1>19mwi5og237hj71hk60hptij4hojfhq</sha1>
    </revision>
    <revision>
      <id>2064</id>
      <parentid>2063</parentid>
      <timestamp>2024-11-19T01:05:41Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2064</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="565" sha1="2wooejpincqm3xkqv4ukq3q8mf9s77d" xml:space="preserve">
'''I-Senegal''', ngokusemthethweni '''iRiphabhliki ye-Senegal''', yinarha engeTjingalanga khulu eTjingalanga ye-Afrika, etholakala eligwini le-Atlantic Ocean. I-Senegal inomngcele nge-Mauritania ngetlhagwini, i-Mali ngepumalanga, i-Guinea ngesewulapumalanga kanye ne-Guinea-Bissau ngesewula-ntshonalanga. I-Senegal ipheze ibhode i-Gambia, inarha ehlala indawo encani eceleni komlambo i-Gambia, ehlukanisa isifunda se-Senegal esewula se-Casamance nenarha yoke.I-Senegal nayo inomngcele welwandle ne-Cape Verde. Ikomkhulu lezomnotho nezepolotiki le-Senegal yi-Dakar.</text>
      <sha1>2wooejpincqm3xkqv4ukq3q8mf9s77d</sha1>
    </revision>
    <revision>
      <id>2065</id>
      <parentid>2064</parentid>
      <timestamp>2024-11-19T01:06:05Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2065</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="569" sha1="omj5q2pq8n0pqegw4qsgv6fbhaod830" xml:space="preserve">
'''I-Senegal''', ngokusemthethweni '''iRiphabhliki ye-Senegal''', yinarha engeTjingalanga khulu eTjingalanga ye-Afrika, etholakala eligwini le-Atlantic Ocean. I-Senegal inomngcele nge-Mauritania ngetlhagwini, i-Mali ngepumalanga, [[i-Guinea]] ngesewulapumalanga kanye ne-Guinea-Bissau ngesewula-ntshonalanga. I-Senegal ipheze ibhode i-Gambia, inarha ehlala indawo encani eceleni komlambo i-Gambia, ehlukanisa isifunda se-Senegal esewula se-Casamance nenarha yoke.I-Senegal nayo inomngcele welwandle ne-Cape Verde. Ikomkhulu lezomnotho nezepolotiki le-Senegal yi-Dakar.</text>
      <sha1>omj5q2pq8n0pqegw4qsgv6fbhaod830</sha1>
    </revision>
    <revision>
      <id>2066</id>
      <parentid>2065</parentid>
      <timestamp>2024-11-19T01:06:25Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2066</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="573" sha1="6ik8jeis9mynocduzok8dq94ckqpzrr" xml:space="preserve">
'''I-Senegal''', ngokusemthethweni '''iRiphabhliki ye-Senegal''', yinarha engeTjingalanga khulu eTjingalanga ye-Afrika, etholakala eligwini le-Atlantic Ocean. I-Senegal inomngcele nge-Mauritania ngetlhagwini, i-Mali ngepumalanga, [[i-Guinea]] ngesewulapumalanga kanye ne-[[Guinea-Bissau]] ngesewula-ntshonalanga. I-Senegal ipheze ibhode i-Gambia, inarha ehlala indawo encani eceleni komlambo i-Gambia, ehlukanisa isifunda se-Senegal esewula se-Casamance nenarha yoke.I-Senegal nayo inomngcele welwandle ne-Cape Verde. Ikomkhulu lezomnotho nezepolotiki le-Senegal yi-Dakar.</text>
      <sha1>6ik8jeis9mynocduzok8dq94ckqpzrr</sha1>
    </revision>
    <revision>
      <id>2067</id>
      <parentid>2066</parentid>
      <timestamp>2024-11-19T01:06:52Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2067</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="577" sha1="afh7fmn23uhpunpxnhazzt6swxcoqla" xml:space="preserve">
'''I-Senegal''', ngokusemthethweni '''iRiphabhliki ye-Senegal''', yinarha engeTjingalanga khulu eTjingalanga ye-Afrika, etholakala eligwini le-Atlantic Ocean. I-Senegal inomngcele nge-Mauritania ngetlhagwini, i-Mali ngepumalanga, [[i-Guinea]] ngesewulapumalanga kanye ne-[[Guinea-Bissau]] ngesewula-ntshonalanga. I-Senegal ipheze ibhode [[i-Gambia]], inarha ehlala indawo encani eceleni komlambo i-Gambia, ehlukanisa isifunda se-Senegal esewula se-Casamance nenarha yoke.I-Senegal nayo inomngcele welwandle ne-Cape Verde. Ikomkhulu lezomnotho nezepolotiki le-Senegal yi-Dakar.</text>
      <sha1>afh7fmn23uhpunpxnhazzt6swxcoqla</sha1>
    </revision>
    <revision>
      <id>2068</id>
      <parentid>2067</parentid>
      <timestamp>2024-11-19T01:07:13Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2068</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="581" sha1="pgyxaqoyp1l2l8yl32afciobx63a8j0" xml:space="preserve">
'''I-Senegal''', ngokusemthethweni '''iRiphabhliki ye-Senegal''', yinarha engeTjingalanga khulu eTjingalanga ye-Afrika, etholakala eligwini le-Atlantic Ocean. I-Senegal inomngcele nge-Mauritania ngetlhagwini, i-Mali ngepumalanga, [[i-Guinea]] ngesewulapumalanga kanye ne-[[Guinea-Bissau]] ngesewula-ntshonalanga. I-Senegal ipheze ibhode [[i-Gambia]], inarha ehlala indawo encani eceleni komlambo i-Gambia, ehlukanisa isifunda se-Senegal esewula se-Casamance nenarha yoke.I-Senegal nayo inomngcele welwandle ne[[-Cape Verde]]. Ikomkhulu lezomnotho nezepolotiki le-Senegal yi-Dakar.</text>
      <sha1>pgyxaqoyp1l2l8yl32afciobx63a8j0</sha1>
    </revision>
    <revision>
      <id>2069</id>
      <parentid>2068</parentid>
      <timestamp>2024-11-19T01:08:00Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2069</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="707" sha1="ad7npe9pqnnfqaossix747t12z5eqzq" xml:space="preserve">
'''I-Senegal''', ngokusemthethweni '''iRiphabhliki ye-Senegal''', yinarha engeTjingalanga khulu eTjingalanga ye-Afrika, etholakala eligwini le-Atlantic Ocean. I-Senegal inomngcele nge-Mauritania ngetlhagwini, i-Mali ngepumalanga, [[i-Guinea]] ngesewulapumalanga kanye ne-[[Guinea-Bissau]] ngesewula-ntshonalanga. I-Senegal ipheze ibhode [[i-Gambia]], inarha ehlala indawo encani eceleni komlambo i-Gambia, ehlukanisa isifunda se-Senegal esewula se-Casamance nenarha yoke.I-Senegal nayo inomngcele welwandle ne[[-Cape Verde]]. Ikomkhulu lezomnotho nezepolotiki le-Senegal yi-Dakar.&lt;ref&gt;https://www.cambridge.org/core/journals/african-studies-review/article/abs/senegal/33F8E881C8D456582B7B983940D27560&lt;/ref&gt;</text>
      <sha1>ad7npe9pqnnfqaossix747t12z5eqzq</sha1>
    </revision>
    <revision>
      <id>2070</id>
      <parentid>2069</parentid>
      <timestamp>2024-11-19T01:09:16Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2070</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="918" sha1="o7dmdnuiist2chpk8fsmbzq44ymwi7u" xml:space="preserve">
'''I-Senegal''', ngokusemthethweni '''iRiphabhliki ye-Senegal''', yinarha engeTjingalanga khulu eTjingalanga ye-Afrika, etholakala eligwini le-Atlantic Ocean. I-Senegal inomngcele nge-Mauritania ngetlhagwini, i-Mali ngepumalanga, [[i-Guinea]] ngesewulapumalanga kanye ne-[[Guinea-Bissau]] ngesewula-ntshonalanga.&lt;ref&gt;https://www.taylorfrancis.com/chapters/edit/10.4324/9781003421740-28/senegal-mamadou-bara-gu%C3%A8ye-richard-ketley-john-nelson&lt;/ref&gt; I-Senegal ipheze ibhode [[i-Gambia]], inarha ehlala indawo encani eceleni komlambo i-Gambia, ehlukanisa isifunda se-Senegal esewula se-Casamance nenarha yoke.I-Senegal nayo inomngcele welwandle ne[[-Cape Verde]]. Ikomkhulu lezomnotho nezepolotiki le-Senegal yi-Dakar.&lt;ref&gt;https://www.cambridge.org/core/journals/african-studies-review/article/abs/senegal/33F8E881C8D456582B7B983940D27560&lt;/ref&gt;&lt;ref&gt;https://link.springer.com/chapter/10.1007/978-3-030-05722-0_41&lt;/ref&gt;</text>
      <sha1>o7dmdnuiist2chpk8fsmbzq44ymwi7u</sha1>
    </revision>
    <revision>
      <id>2071</id>
      <parentid>2070</parentid>
      <timestamp>2024-11-19T01:10:21Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2071</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="974" sha1="awe69v2rjo6dyif17umcz1vdone0jfl" xml:space="preserve">
'''I-Senegal''', ngokusemthethweni '''iRiphabhliki ye-Senegal''', yinarha engeTjingalanga khulu eTjingalanga ye-Afrika, etholakala eligwini le-Atlantic Ocean. I-Senegal inomngcele nge-Mauritania ngetlhagwini, i-Mali ngepumalanga, [[i-Guinea]] ngesewulapumalanga kanye ne-[[Guinea-Bissau]] ngesewula-ntshonalanga.&lt;ref&gt;https://www.taylorfrancis.com/chapters/edit/10.4324/9781003421740-28/senegal-mamadou-bara-gu%C3%A8ye-richard-ketley-john-nelson&lt;/ref&gt; I-Senegal ipheze ibhode [[i-Gambia]], inarha ehlala indawo encani eceleni komlambo i-Gambia, ehlukanisa isifunda se-Senegal esewula se-Casamance nenarha yoke.I-Senegal nayo inomngcele welwandle ne[[-Cape Verde]]. Ikomkhulu lezomnotho nezepolotiki le-Senegal yi-Dakar.&lt;ref&gt;https://www.cambridge.org/core/journals/african-studies-review/article/abs/senegal/33F8E881C8D456582B7B983940D27560&lt;/ref&gt;&lt;ref&gt;https://link.springer.com/chapter/10.1007/978-3-030-05722-0_41&lt;/ref&gt;
== Iinkomba ==
{{Reflist}}
[[Category:Iinarha zephasi]]</text>
      <sha1>awe69v2rjo6dyif17umcz1vdone0jfl</sha1>
    </revision>
    <revision>
      <id>2138</id>
      <parentid>2071</parentid>
      <timestamp>2024-11-25T18:29:06Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>Mkhakha</comment>
      <origin>2138</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="974" sha1="3xcn8qdsmc4u25o90zk5jxn20i6rw5i" xml:space="preserve">
'''I-Senegal''', ngokusemthethweni '''iRiphabhliki ye-Senegal''', yinarha engeTjingalanga khulu eTjingalanga ye-Afrika, etholakala eligwini le-Atlantic Ocean. I-Senegal inomngcele nge-Mauritania ngetlhagwini, i-Mali ngepumalanga, [[i-Guinea]] ngesewulapumalanga kanye ne-[[Guinea-Bissau]] ngesewula-ntshonalanga.&lt;ref&gt;https://www.taylorfrancis.com/chapters/edit/10.4324/9781003421740-28/senegal-mamadou-bara-gu%C3%A8ye-richard-ketley-john-nelson&lt;/ref&gt; I-Senegal ipheze ibhode [[i-Gambia]], inarha ehlala indawo encani eceleni komlambo i-Gambia, ehlukanisa isifunda se-Senegal esewula se-Casamance nenarha yoke.I-Senegal nayo inomngcele welwandle ne[[-Cape Verde]]. Ikomkhulu lezomnotho nezepolotiki le-Senegal yi-Dakar.&lt;ref&gt;https://www.cambridge.org/core/journals/african-studies-review/article/abs/senegal/33F8E881C8D456582B7B983940D27560&lt;/ref&gt;&lt;ref&gt;https://link.springer.com/chapter/10.1007/978-3-030-05722-0_41&lt;/ref&gt;
== Iinkomba ==
{{Reflist}}

[[Mkhakha:Iinarha zephasi]]</text>
      <sha1>3xcn8qdsmc4u25o90zk5jxn20i6rw5i</sha1>
    </revision>
  </page>
  <page>
    <title>Lionel Messi</title>
    <ns>0</ns>
    <id>402</id>
    <revision>
      <id>2072</id>
      <timestamp>2024-11-20T23:51:43Z</timestamp>
      <contributor>
        <username>Armurdo</username>
        <id>185</id>
      </contributor>
      <comment>Created page with &quot;[[Isimumathi:Lionel-Messi-Argentina-2022-FIFA-World-Cup (cropped).jpg|thumb|Isihlabani somgibeli wezemidlalo uLionel Messi, Disemba 2022.]] '''ULionel Messi''' ungumdlali webhola wase-[[Argentina]], owaziwa ngokuba ngomunye wabadlali abakhulu kunabo bonke emlandweni webhola.   == Ukuphila kwakuqala == UMessi waqala ukudlala ibhola liseyinkwenkwezi, kwathi ngo-1995 wajoyina ithimba leNewell’s Old Boys, iqembu lomphakathi elidlala umdlalo omkhulu eRosario. Amakhono akhe...&quot;</comment>
      <origin>2072</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9488" sha1="ac69tkl5kz12m1ualxqyijuyb2p7wis" xml:space="preserve">[[Isimumathi:Lionel-Messi-Argentina-2022-FIFA-World-Cup (cropped).jpg|thumb|Isihlabani somgibeli wezemidlalo uLionel Messi, Disemba 2022.]]
'''ULionel Messi''' ungumdlali webhola wase-[[Argentina]], owaziwa ngokuba ngomunye wabadlali abakhulu kunabo bonke emlandweni webhola. 

== Ukuphila kwakuqala ==
UMessi waqala ukudlala ibhola liseyinkwenkwezi, kwathi ngo-1995 wajoyina ithimba leNewell’s Old Boys, iqembu lomphakathi elidlala umdlalo omkhulu eRosario. Amakhono akhe angavamile athusa amaqembu adumile ase-Europe kanye neLatin America. Lapho eneminyaka eli-13, uMessi nomndeni wakhe bathutha baya eBarcelona, lapho aqala ukudlalela iqembu labafana abaneminyaka engaphasi kwengu-14 leFC Barcelona. Wahlohla amagoli ali-21 emidlalweni eli-14 eqenjini labancane, kwathi ngokushesha wakhuphukela emaqenjini aphezulu, waze waba nemidlalo yakhe yokuqala engakahloniphi ngokusemthethweni eneminyaka eli-16, edlalela iFC Barcelona emdlalweni wobungani.

== Ukudlala kwamaqembu ==
Ngesizini ka-2004–05, uMessi, owayeneminyaka eli-17 ngaleso sikhathi, waba ngumdlali omncane kunabo bonke owake wadlala futhi wahlohla igoli emlandweni weSpanish La Liga, okuwumqhudelwano ophezulu webhola laseSpain. Naphezu kokuba nezinga lama-5 izinyawo eziyisi-7 (1.7 amitha) nokuba nesisindo esingu-148 amakhilogremu (67 kg), wayeqinile, ekulinganiselwe kahle, futhi eguquguquka enkundleni. Engunozwane lwesobunxele ngokwemvelo, ehlakaniphile futhi enembile ekulawuleni ibhola, uMessi wayengumhambisi ophambili wama-pasi futhi ayekwazi ukugqashula ezivikeleni eziminyene. Ngo-2005 wanikezwa ubuzwe baseSpain, okwathathwa ngemizwa ehlukahlukene ngabalandeli beBarcelona abaziqhenyayo ngokuba ngamaCatalan. Ngonyaka olandelayo, uMessi kanye neqembu leBarcelona banqoba isicoco seChampions League, umqhudelwano wamaqembu ase-Europe.

Ukudlala kukaMessi kwaqhubeka kuthuthuka ngokushesha eminyakeni edlule, kwathi ngo-2008 waba ngomunye wabadlali abaphambili emhlabeni, eqeda endaweni yesibili emavotini eBallon d'Or ka-2008, enqotshwa nguCristiano Ronaldo weManchester United. Ekuqaleni kuka-2009, uMessi waqedela isizini emangalisayo ka-2008–09 ngokusiza i-FC Barcelona ukuthi ithole i-“treble” yayo yokuqala (ukunqoba izihloko ezintathu ezinkulu zamaqembu ase-Europe ngesizini eyodwa): iqembu lanqoba isicoco seLa Liga, iCopa del Rey (indebe enkulu yasekhaya yaseSpain), kanye nesicoco seChampions League. Kulowo nyaka, uMessi wahlohla amagoli angama-38 emidlalweni engu-51, futhi waxosha uRonaldo emavotini weBallon d'Or kanye nomdlali womhlaba wonyaka weFIFA, enza umlando ngokuhlukana okuningi kwamaphuzu. Ngesizini ka-2009–10, uMessi wahlohla amagoli angu-34 emidlalweni yasekhaya ngesikhathi iBarcelona iphinda inqobe isicoco seLa Liga. Wathola umklomelo weGolden Shoe njengomshayi magoli ohamba phambili e-Europe, futhi waphinde wanikezwa enye iBallon d'Or (eyaziwa njengeFIFA Ballon d'Or phakathi kuka-2010 no-2015).
[[Isimumathi:Arda Turan 2016-17 (cropped).jpg|thumb|228x228px|Uphumelele iBallon d'Or izikhathi eziyisishiyagalombili uLionel Messi, Agasti 2016.]]
UMessi wahola i-Barcelona ekunqobeni izihloko zeLa Liga kanye neChampions League ngesizini eyalandela, okusiza wazuza umklomelo wesithathu olandelanayo womdlali womhlaba wonyaka, okuyinto engakaze ibonwe. NgoMbasa 2012, wahlohla igoli lakhe lama-233 le-Barcelona, waba umshayi magoli ophezulu kunabo bonke emlandweni weqembu emidlalweni yeLa Liga eneminyaka engu-24 kuphela. Waqeda isizini ka-2011–12 ye-Barcelona (eyayihlanganisa enye iwini yeCopa del Rey) enamagoli angu-73 kuyo yonke imiqhudelwano, epha isicoco sikaGerd Müller seminyaka engu-39 samagoli esizini eyodwa kwimidlalo eyinhloko ye-European football. Lokhu kusebenza okumangalisayo kwamphoqa ukuthi aqokwe njengomdlali womhlaba wonyaka ka-2012, okumenza waba ngumdlali wokuqala ukuwina isihloko izikhathi ezine. Amagoli akhe angu-46 eLa Liga ngesizini ka-2012–13 aholela kulesi sigaba, futhi iBarcelona yaphinda yathatha isicoco seligi yasekhaya. Ngo-2014, usetha irekhodi lonke leBarcelona ngesikhathi ehlohla igoli lakhe lama-370 njengelungu leqembu. Ngalo nyaka, wephula amarekhodi emisebenzi yokuhlohla kuChampions League (amagoli angu-72) kanye neLa Liga (amagoli angu-253).
[[Isimumathi:Lionel Messi vs Valladolid 3.jpg|thumb|264x264px|ULionel Messi, Disemba 2018.]]
Ngo-2014–15, uMessi wasiza i-Barcelona ukuthi iphinde inqobe i-treble, ehola iqembu ngamaphuzu angu-43 phakathi nesizini, okwamnikeza umklomelo wakhe wesihlanu womdlali womhlaba wonyaka. Ngesizini ka-2015–16, wahlohla amagoli angu-41 kuyo yonke imiqhudelwano ye-Barcelona, futhi iqembu lazuza izicoco zeLa Liga neCopa del Rey. Waphumelela kakhudlwana ngo-2016–17 ngamaphuzu angu-53, eholela iqembu ekunqobeni isicoco seCopa del Rey futhi. Ngo-2017–18, wahlohla amagoli angu-45, kanti i-Barcelona yawina izicoco zeLa Liga neCopa del Rey futhi. Ngo-2018–19, uMessi wahlohla amagoli angu-51 kuyo yonke imiqhudelwano yasekhaya, kwathi i-Barcelona yawina enye isicoco seLa Liga. Ekupheleni kuka-2019, wawina iBallon d'Or yakhe yesithupha futhi waqanjwa njengomdlali ongcono kunabo bonke emhlabeni yiFIFA. Ngesizini ka-2020–21, i-Barcelona yathatha isicoco seCopa del Rey, okuyisikhombisa emsebenzini kaMessi. Waba ngumdlali ozimele ngo-2021, kanti izinkinga zezimali—ezinye zazo ezazihlobene nemithetho yeLa Liga—zamenza wangakwazi ukuqhubeka ne-Barcelona. Wahlala engumholi ohlukile emlandweni, engumshayi magoli ophezulu emlandweni weLa Liga ngamaphuzu angu-474.

Ngemuva kwalokho, ngo-2021 uMessi signed ne-Paris St.-Germain (PSG), lapho ajoyina khona ojonge amathalente amakhulu uKylian Mbappé noNeymar, futhi ngalowo nyaka wathola iBallon d'Or yakhe eyayilandelayo. Wasiza i-PSG ukuthi iwine isicoco seLigue 1 ngesikhathi esingamabili adlala nohlelo. Ngo-2023, uMessi wajoyina i-Inter Miami ye-Major League Soccer.

== Uhambo lwakhe lwezizwe ==
Ngaphandle kokuba nezimvume ezimbili zokuba ngozinze eSpain futhi eseziphumelelayo emsebenzini, uMessi waqhubeka nokuhlala nezibopho ezinzulu ezweni lakubo, futhi waba yilungu elibalulekile kumaqembu kazwelonke ase-Argentina kusukela ngo-2005. Wadlala eqenjini le-Argentina elinqobile kwi-FIFA World Youth Championship yango-2005, wakhumela izwe lakhe kuWorld Cup yango-2006, futhi wabhala amagoli amabili kumidlalo emihlanu lapho i-Argentina yaphumelela ukufinyelela kumaphiko e-golde medal ku-Olympics yaseBeijing ngo-2008. UMessi wasiza i-Argentina ukuba ifinyelele kuma-quarterfinals we-World Cup yango-2010, lapho iqembu lihlulwa yi-Germany, okwenza kube yisikhathi sesibili sokulahlekelwa kuWorld Cup. Ku-World Cup yango-2014, uMessi wenza isibonelo esimangalisayo, wabhala amagoli amane futhi waqhuba i-Argentina, eneqembu elihlushwa yizinkinga zokuhlasela, kwi-stage yeqembu futhi eya kumjikelo wokuphuma, lapho i-Argentina yachitha isikhathi eside ukusuka efinalini ye-World Cup ngomnyaka wesine ngo-24. I-Argentina yenqabela lowo mdlalo ngo-1-0 ne-Germany, kodwa uMessi wathola i-Golden Ball njengomdlali ophumelela kakhulu. Ngesikhathi se-2016 Copa América Centenario, wabhala igoli lakhe le-55 phakathi kwezizwe, ephula irekhodi likaGabriel Batistuta njengomshayi magoli ophumelele kakhulu e-Argentina.
[[Isimumathi:ARG Line-up - ARG vs MEX for 2022 FIFA WC.jpg|thumb|271x271px|Umphosa weqembu uLionel Messi kanye namanye amalungu eqembu lesizwe lase-Argentina ku-World Cup yezeMidlalo yabesilisa ka-2022.]]
Emva kokuhlulwa kwe-Argentina kwi-Copa final—okuphikisana nesikhumbuzo sokuqala kwama-final izikhathi ezintathu kumqhudelwano omkhulu—uMessi wathi uzashiya iqembu lesizwe, kodwa &quot;ukuthatha umhlalaphansi&quot; kwakhe okwesikhashana kwahlala izinyanga ezimbili ngaphambi kokubhalela ukubuyela eqenjini. Ku-World Cup yango-2018, wasiza iqembu lase-Argentina elihlangabezana nobunzima ukufinyelela kumjikelo wokuphuma, lapho bachithwa yiFrance, okuyi-team ethole i-championship, emdlalweni wabo wokuqala. Ngemva kokuphothula esikhathini sesithathu e-Copa América yango-2019, uMessi wahola i-Argentina ukuba iwine umqhudelwano eminyakeni emibili kamuva, waphinde wathola i-Golden Ball award.

Impumelelo yakhe yaqhubeka kwi-World Cup yango-2022. Lapho, wahola i-Argentina ku-final, lapho ebhala amagoli amabili—futhi wenza umphumela ophumelelayo ngesikhathi sokuphonswa amaphuzu—to ukusiza ukwehlula iFrance. UMessi wathola i-Golden Ball ye-World Cup, waba ngumdlali wesilisa wokuqala ukuthola lesi sikhumbuzo izikhathi ezimbili. Ukwengeza, ukudlala kwakhe okuhle kakhulu kulomqhudelwano kwakubalulekile ekutholeni kwakhe iBallon d'Or yesishiyagalombili ngo-2023.

== Ezinye izenzo kanye nezinkinga zomthetho ==
Ngaphandle komkhakha womdlalo, uMessi wayengomunye wezinkanyezi zomzimba ezinkulu emhlabeni. Ngokuhlangene nemiholo yebhola, eyayivame ukuba nezezakhiwo ezimbili ezinkulu kakhulu zabadlali bezemidlalo bonke, waba ngumkhangisi ophumelelayo wemikhiqizo, ikakhulukazi kwenkampani yezimpahla zezemidlalo i-Adidas. Ngo-2013, uMessi kanye no-ubaba wakhe (ophatha izimali zomfana wakhe) babhekene necala lokugwema intela, behlonipha izinkampani zomphakathi zasephesheya ukuze bagweme ukukhokha u-€4.2 million ezintela zaseSpain kumholo wokukhangisa. Nokho, ngemuva kokukhokha €5 million kuMbuso waseSpain, bobabili bakhishwa ukuba babhekane necala ngo-2016. NgoJulayi walowo nyaka, uMessi no-ubaba wakhe bathola isijeziso sokuhlala ezinyangeni ezimisiwe zomlomo wesigwebo esingaphansi kweminyaka emibili, futhi bathola izijeziso zentela zangu-€2 million no-€1.5 million, ngokulandelana.</text>
      <sha1>ac69tkl5kz12m1ualxqyijuyb2p7wis</sha1>
    </revision>
    <revision>
      <id>2086</id>
      <parentid>2072</parentid>
      <timestamp>2024-11-21T23:50:26Z</timestamp>
      <contributor>
        <username>Armurdo</username>
        <id>185</id>
      </contributor>
      <origin>2086</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9499" sha1="4fhdp7kdx2rbefief5b0v3rcol9h6rq" xml:space="preserve">{{Infobox}}[[Isimumathi:Lionel-Messi-Argentina-2022-FIFA-World-Cup (cropped).jpg|thumb|Isihlabani somgibeli wezemidlalo uLionel Messi, Disemba 2022.]]
'''ULionel Messi''' ungumdlali webhola wase-[[Argentina]], owaziwa ngokuba ngomunye wabadlali abakhulu kunabo bonke emlandweni webhola. 

== Ukuphila kwakuqala ==
UMessi waqala ukudlala ibhola liseyinkwenkwezi, kwathi ngo-1995 wajoyina ithimba leNewell’s Old Boys, iqembu lomphakathi elidlala umdlalo omkhulu eRosario. Amakhono akhe angavamile athusa amaqembu adumile ase-Europe kanye neLatin America. Lapho eneminyaka eli-13, uMessi nomndeni wakhe bathutha baya eBarcelona, lapho aqala ukudlalela iqembu labafana abaneminyaka engaphasi kwengu-14 leFC Barcelona. Wahlohla amagoli ali-21 emidlalweni eli-14 eqenjini labancane, kwathi ngokushesha wakhuphukela emaqenjini aphezulu, waze waba nemidlalo yakhe yokuqala engakahloniphi ngokusemthethweni eneminyaka eli-16, edlalela iFC Barcelona emdlalweni wobungani.

== Ukudlala kwamaqembu ==
Ngesizini ka-2004–05, uMessi, owayeneminyaka eli-17 ngaleso sikhathi, waba ngumdlali omncane kunabo bonke owake wadlala futhi wahlohla igoli emlandweni weSpanish La Liga, okuwumqhudelwano ophezulu webhola laseSpain. Naphezu kokuba nezinga lama-5 izinyawo eziyisi-7 (1.7 amitha) nokuba nesisindo esingu-148 amakhilogremu (67 kg), wayeqinile, ekulinganiselwe kahle, futhi eguquguquka enkundleni. Engunozwane lwesobunxele ngokwemvelo, ehlakaniphile futhi enembile ekulawuleni ibhola, uMessi wayengumhambisi ophambili wama-pasi futhi ayekwazi ukugqashula ezivikeleni eziminyene. Ngo-2005 wanikezwa ubuzwe baseSpain, okwathathwa ngemizwa ehlukahlukene ngabalandeli beBarcelona abaziqhenyayo ngokuba ngamaCatalan. Ngonyaka olandelayo, uMessi kanye neqembu leBarcelona banqoba isicoco seChampions League, umqhudelwano wamaqembu ase-Europe.

Ukudlala kukaMessi kwaqhubeka kuthuthuka ngokushesha eminyakeni edlule, kwathi ngo-2008 waba ngomunye wabadlali abaphambili emhlabeni, eqeda endaweni yesibili emavotini eBallon d'Or ka-2008, enqotshwa nguCristiano Ronaldo weManchester United. Ekuqaleni kuka-2009, uMessi waqedela isizini emangalisayo ka-2008–09 ngokusiza i-FC Barcelona ukuthi ithole i-“treble” yayo yokuqala (ukunqoba izihloko ezintathu ezinkulu zamaqembu ase-Europe ngesizini eyodwa): iqembu lanqoba isicoco seLa Liga, iCopa del Rey (indebe enkulu yasekhaya yaseSpain), kanye nesicoco seChampions League. Kulowo nyaka, uMessi wahlohla amagoli angama-38 emidlalweni engu-51, futhi waxosha uRonaldo emavotini weBallon d'Or kanye nomdlali womhlaba wonyaka weFIFA, enza umlando ngokuhlukana okuningi kwamaphuzu. Ngesizini ka-2009–10, uMessi wahlohla amagoli angu-34 emidlalweni yasekhaya ngesikhathi iBarcelona iphinda inqobe isicoco seLa Liga. Wathola umklomelo weGolden Shoe njengomshayi magoli ohamba phambili e-Europe, futhi waphinde wanikezwa enye iBallon d'Or (eyaziwa njengeFIFA Ballon d'Or phakathi kuka-2010 no-2015).
[[Isimumathi:Arda Turan 2016-17 (cropped).jpg|thumb|228x228px|Uphumelele iBallon d'Or izikhathi eziyisishiyagalombili uLionel Messi, Agasti 2016.]]
UMessi wahola i-Barcelona ekunqobeni izihloko zeLa Liga kanye neChampions League ngesizini eyalandela, okusiza wazuza umklomelo wesithathu olandelanayo womdlali womhlaba wonyaka, okuyinto engakaze ibonwe. NgoMbasa 2012, wahlohla igoli lakhe lama-233 le-Barcelona, waba umshayi magoli ophezulu kunabo bonke emlandweni weqembu emidlalweni yeLa Liga eneminyaka engu-24 kuphela. Waqeda isizini ka-2011–12 ye-Barcelona (eyayihlanganisa enye iwini yeCopa del Rey) enamagoli angu-73 kuyo yonke imiqhudelwano, epha isicoco sikaGerd Müller seminyaka engu-39 samagoli esizini eyodwa kwimidlalo eyinhloko ye-European football. Lokhu kusebenza okumangalisayo kwamphoqa ukuthi aqokwe njengomdlali womhlaba wonyaka ka-2012, okumenza waba ngumdlali wokuqala ukuwina isihloko izikhathi ezine. Amagoli akhe angu-46 eLa Liga ngesizini ka-2012–13 aholela kulesi sigaba, futhi iBarcelona yaphinda yathatha isicoco seligi yasekhaya. Ngo-2014, usetha irekhodi lonke leBarcelona ngesikhathi ehlohla igoli lakhe lama-370 njengelungu leqembu. Ngalo nyaka, wephula amarekhodi emisebenzi yokuhlohla kuChampions League (amagoli angu-72) kanye neLa Liga (amagoli angu-253).
[[Isimumathi:Lionel Messi vs Valladolid 3.jpg|thumb|264x264px|ULionel Messi, Disemba 2018.]]
Ngo-2014–15, uMessi wasiza i-Barcelona ukuthi iphinde inqobe i-treble, ehola iqembu ngamaphuzu angu-43 phakathi nesizini, okwamnikeza umklomelo wakhe wesihlanu womdlali womhlaba wonyaka. Ngesizini ka-2015–16, wahlohla amagoli angu-41 kuyo yonke imiqhudelwano ye-Barcelona, futhi iqembu lazuza izicoco zeLa Liga neCopa del Rey. Waphumelela kakhudlwana ngo-2016–17 ngamaphuzu angu-53, eholela iqembu ekunqobeni isicoco seCopa del Rey futhi. Ngo-2017–18, wahlohla amagoli angu-45, kanti i-Barcelona yawina izicoco zeLa Liga neCopa del Rey futhi. Ngo-2018–19, uMessi wahlohla amagoli angu-51 kuyo yonke imiqhudelwano yasekhaya, kwathi i-Barcelona yawina enye isicoco seLa Liga. Ekupheleni kuka-2019, wawina iBallon d'Or yakhe yesithupha futhi waqanjwa njengomdlali ongcono kunabo bonke emhlabeni yiFIFA. Ngesizini ka-2020–21, i-Barcelona yathatha isicoco seCopa del Rey, okuyisikhombisa emsebenzini kaMessi. Waba ngumdlali ozimele ngo-2021, kanti izinkinga zezimali—ezinye zazo ezazihlobene nemithetho yeLa Liga—zamenza wangakwazi ukuqhubeka ne-Barcelona. Wahlala engumholi ohlukile emlandweni, engumshayi magoli ophezulu emlandweni weLa Liga ngamaphuzu angu-474.

Ngemuva kwalokho, ngo-2021 uMessi signed ne-Paris St.-Germain (PSG), lapho ajoyina khona ojonge amathalente amakhulu uKylian Mbappé noNeymar, futhi ngalowo nyaka wathola iBallon d'Or yakhe eyayilandelayo. Wasiza i-PSG ukuthi iwine isicoco seLigue 1 ngesikhathi esingamabili adlala nohlelo. Ngo-2023, uMessi wajoyina i-Inter Miami ye-Major League Soccer.

== Uhambo lwakhe lwezizwe ==
Ngaphandle kokuba nezimvume ezimbili zokuba ngozinze eSpain futhi eseziphumelelayo emsebenzini, uMessi waqhubeka nokuhlala nezibopho ezinzulu ezweni lakubo, futhi waba yilungu elibalulekile kumaqembu kazwelonke ase-Argentina kusukela ngo-2005. Wadlala eqenjini le-Argentina elinqobile kwi-FIFA World Youth Championship yango-2005, wakhumela izwe lakhe kuWorld Cup yango-2006, futhi wabhala amagoli amabili kumidlalo emihlanu lapho i-Argentina yaphumelela ukufinyelela kumaphiko e-golde medal ku-Olympics yaseBeijing ngo-2008. UMessi wasiza i-Argentina ukuba ifinyelele kuma-quarterfinals we-World Cup yango-2010, lapho iqembu lihlulwa yi-Germany, okwenza kube yisikhathi sesibili sokulahlekelwa kuWorld Cup. Ku-World Cup yango-2014, uMessi wenza isibonelo esimangalisayo, wabhala amagoli amane futhi waqhuba i-Argentina, eneqembu elihlushwa yizinkinga zokuhlasela, kwi-stage yeqembu futhi eya kumjikelo wokuphuma, lapho i-Argentina yachitha isikhathi eside ukusuka efinalini ye-World Cup ngomnyaka wesine ngo-24. I-Argentina yenqabela lowo mdlalo ngo-1-0 ne-Germany, kodwa uMessi wathola i-Golden Ball njengomdlali ophumelela kakhulu. Ngesikhathi se-2016 Copa América Centenario, wabhala igoli lakhe le-55 phakathi kwezizwe, ephula irekhodi likaGabriel Batistuta njengomshayi magoli ophumelele kakhulu e-Argentina.
[[Isimumathi:ARG Line-up - ARG vs MEX for 2022 FIFA WC.jpg|thumb|271x271px|Umphosa weqembu uLionel Messi kanye namanye amalungu eqembu lesizwe lase-Argentina ku-World Cup yezeMidlalo yabesilisa ka-2022.]]
Emva kokuhlulwa kwe-Argentina kwi-Copa final—okuphikisana nesikhumbuzo sokuqala kwama-final izikhathi ezintathu kumqhudelwano omkhulu—uMessi wathi uzashiya iqembu lesizwe, kodwa &quot;ukuthatha umhlalaphansi&quot; kwakhe okwesikhashana kwahlala izinyanga ezimbili ngaphambi kokubhalela ukubuyela eqenjini. Ku-World Cup yango-2018, wasiza iqembu lase-Argentina elihlangabezana nobunzima ukufinyelela kumjikelo wokuphuma, lapho bachithwa yiFrance, okuyi-team ethole i-championship, emdlalweni wabo wokuqala. Ngemva kokuphothula esikhathini sesithathu e-Copa América yango-2019, uMessi wahola i-Argentina ukuba iwine umqhudelwano eminyakeni emibili kamuva, waphinde wathola i-Golden Ball award.

Impumelelo yakhe yaqhubeka kwi-World Cup yango-2022. Lapho, wahola i-Argentina ku-final, lapho ebhala amagoli amabili—futhi wenza umphumela ophumelelayo ngesikhathi sokuphonswa amaphuzu—to ukusiza ukwehlula iFrance. UMessi wathola i-Golden Ball ye-World Cup, waba ngumdlali wesilisa wokuqala ukuthola lesi sikhumbuzo izikhathi ezimbili. Ukwengeza, ukudlala kwakhe okuhle kakhulu kulomqhudelwano kwakubalulekile ekutholeni kwakhe iBallon d'Or yesishiyagalombili ngo-2023.

== Ezinye izenzo kanye nezinkinga zomthetho ==
Ngaphandle komkhakha womdlalo, uMessi wayengomunye wezinkanyezi zomzimba ezinkulu emhlabeni. Ngokuhlangene nemiholo yebhola, eyayivame ukuba nezezakhiwo ezimbili ezinkulu kakhulu zabadlali bezemidlalo bonke, waba ngumkhangisi ophumelelayo wemikhiqizo, ikakhulukazi kwenkampani yezimpahla zezemidlalo i-Adidas. Ngo-2013, uMessi kanye no-ubaba wakhe (ophatha izimali zomfana wakhe) babhekene necala lokugwema intela, behlonipha izinkampani zomphakathi zasephesheya ukuze bagweme ukukhokha u-€4.2 million ezintela zaseSpain kumholo wokukhangisa. Nokho, ngemuva kokukhokha €5 million kuMbuso waseSpain, bobabili bakhishwa ukuba babhekane necala ngo-2016. NgoJulayi walowo nyaka, uMessi no-ubaba wakhe bathola isijeziso sokuhlala ezinyangeni ezimisiwe zomlomo wesigwebo esingaphansi kweminyaka emibili, futhi bathola izijeziso zentela zangu-€2 million no-€1.5 million, ngokulandelana.</text>
      <sha1>4fhdp7kdx2rbefief5b0v3rcol9h6rq</sha1>
    </revision>
    <revision>
      <id>2087</id>
      <parentid>2086</parentid>
      <timestamp>2024-11-21T23:57:27Z</timestamp>
      <contributor>
        <username>Armurdo</username>
        <id>185</id>
      </contributor>
      <origin>2087</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9553" sha1="ol3l6ws9xqhrrlreh9yhuas4y2xo8ha" xml:space="preserve">{{Person|ibizo=ULionel Messi|ubelethwe ngo=Juni 24, 1987|umsebenzi=Umgijimi webhola (soccer)|indawo yo kubelethwa=Rosario, e-Argentina|isithombe=Lionel-Messi-Argentina-2022-FIFA-World-Cup (cropped).jpg}}

'''ULionel Messi''' ungumdlali webhola wase-[[Argentina]], owaziwa ngokuba ngomunye wabadlali abakhulu kunabo bonke emlandweni webhola. 

== Ukuphila kwakuqala ==
UMessi waqala ukudlala ibhola liseyinkwenkwezi, kwathi ngo-1995 wajoyina ithimba leNewell’s Old Boys, iqembu lomphakathi elidlala umdlalo omkhulu eRosario. Amakhono akhe angavamile athusa amaqembu adumile ase-Europe kanye neLatin America. Lapho eneminyaka eli-13, uMessi nomndeni wakhe bathutha baya eBarcelona, lapho aqala ukudlalela iqembu labafana abaneminyaka engaphasi kwengu-14 leFC Barcelona. Wahlohla amagoli ali-21 emidlalweni eli-14 eqenjini labancane, kwathi ngokushesha wakhuphukela emaqenjini aphezulu, waze waba nemidlalo yakhe yokuqala engakahloniphi ngokusemthethweni eneminyaka eli-16, edlalela iFC Barcelona emdlalweni wobungani.

== Ukudlala kwamaqembu ==
Ngesizini ka-2004–05, uMessi, owayeneminyaka eli-17 ngaleso sikhathi, waba ngumdlali omncane kunabo bonke owake wadlala futhi wahlohla igoli emlandweni weSpanish La Liga, okuwumqhudelwano ophezulu webhola laseSpain. Naphezu kokuba nezinga lama-5 izinyawo eziyisi-7 (1.7 amitha) nokuba nesisindo esingu-148 amakhilogremu (67 kg), wayeqinile, ekulinganiselwe kahle, futhi eguquguquka enkundleni. Engunozwane lwesobunxele ngokwemvelo, ehlakaniphile futhi enembile ekulawuleni ibhola, uMessi wayengumhambisi ophambili wama-pasi futhi ayekwazi ukugqashula ezivikeleni eziminyene. Ngo-2005 wanikezwa ubuzwe baseSpain, okwathathwa ngemizwa ehlukahlukene ngabalandeli beBarcelona abaziqhenyayo ngokuba ngamaCatalan. Ngonyaka olandelayo, uMessi kanye neqembu leBarcelona banqoba isicoco seChampions League, umqhudelwano wamaqembu ase-Europe.

Ukudlala kukaMessi kwaqhubeka kuthuthuka ngokushesha eminyakeni edlule, kwathi ngo-2008 waba ngomunye wabadlali abaphambili emhlabeni, eqeda endaweni yesibili emavotini eBallon d'Or ka-2008, enqotshwa nguCristiano Ronaldo weManchester United. Ekuqaleni kuka-2009, uMessi waqedela isizini emangalisayo ka-2008–09 ngokusiza i-FC Barcelona ukuthi ithole i-“treble” yayo yokuqala (ukunqoba izihloko ezintathu ezinkulu zamaqembu ase-Europe ngesizini eyodwa): iqembu lanqoba isicoco seLa Liga, iCopa del Rey (indebe enkulu yasekhaya yaseSpain), kanye nesicoco seChampions League. Kulowo nyaka, uMessi wahlohla amagoli angama-38 emidlalweni engu-51, futhi waxosha uRonaldo emavotini weBallon d'Or kanye nomdlali womhlaba wonyaka weFIFA, enza umlando ngokuhlukana okuningi kwamaphuzu. Ngesizini ka-2009–10, uMessi wahlohla amagoli angu-34 emidlalweni yasekhaya ngesikhathi iBarcelona iphinda inqobe isicoco seLa Liga. Wathola umklomelo weGolden Shoe njengomshayi magoli ohamba phambili e-Europe, futhi waphinde wanikezwa enye iBallon d'Or (eyaziwa njengeFIFA Ballon d'Or phakathi kuka-2010 no-2015).
[[Isimumathi:Arda Turan 2016-17 (cropped).jpg|thumb|228x228px|Uphumelele iBallon d'Or izikhathi eziyisishiyagalombili uLionel Messi, Agasti 2016.]]
UMessi wahola i-Barcelona ekunqobeni izihloko zeLa Liga kanye neChampions League ngesizini eyalandela, okusiza wazuza umklomelo wesithathu olandelanayo womdlali womhlaba wonyaka, okuyinto engakaze ibonwe. NgoMbasa 2012, wahlohla igoli lakhe lama-233 le-Barcelona, waba umshayi magoli ophezulu kunabo bonke emlandweni weqembu emidlalweni yeLa Liga eneminyaka engu-24 kuphela. Waqeda isizini ka-2011–12 ye-Barcelona (eyayihlanganisa enye iwini yeCopa del Rey) enamagoli angu-73 kuyo yonke imiqhudelwano, epha isicoco sikaGerd Müller seminyaka engu-39 samagoli esizini eyodwa kwimidlalo eyinhloko ye-European football. Lokhu kusebenza okumangalisayo kwamphoqa ukuthi aqokwe njengomdlali womhlaba wonyaka ka-2012, okumenza waba ngumdlali wokuqala ukuwina isihloko izikhathi ezine. Amagoli akhe angu-46 eLa Liga ngesizini ka-2012–13 aholela kulesi sigaba, futhi iBarcelona yaphinda yathatha isicoco seligi yasekhaya. Ngo-2014, usetha irekhodi lonke leBarcelona ngesikhathi ehlohla igoli lakhe lama-370 njengelungu leqembu. Ngalo nyaka, wephula amarekhodi emisebenzi yokuhlohla kuChampions League (amagoli angu-72) kanye neLa Liga (amagoli angu-253).
[[Isimumathi:Lionel Messi vs Valladolid 3.jpg|thumb|264x264px|ULionel Messi, Disemba 2018.]]
Ngo-2014–15, uMessi wasiza i-Barcelona ukuthi iphinde inqobe i-treble, ehola iqembu ngamaphuzu angu-43 phakathi nesizini, okwamnikeza umklomelo wakhe wesihlanu womdlali womhlaba wonyaka. Ngesizini ka-2015–16, wahlohla amagoli angu-41 kuyo yonke imiqhudelwano ye-Barcelona, futhi iqembu lazuza izicoco zeLa Liga neCopa del Rey. Waphumelela kakhudlwana ngo-2016–17 ngamaphuzu angu-53, eholela iqembu ekunqobeni isicoco seCopa del Rey futhi. Ngo-2017–18, wahlohla amagoli angu-45, kanti i-Barcelona yawina izicoco zeLa Liga neCopa del Rey futhi. Ngo-2018–19, uMessi wahlohla amagoli angu-51 kuyo yonke imiqhudelwano yasekhaya, kwathi i-Barcelona yawina enye isicoco seLa Liga. Ekupheleni kuka-2019, wawina iBallon d'Or yakhe yesithupha futhi waqanjwa njengomdlali ongcono kunabo bonke emhlabeni yiFIFA. Ngesizini ka-2020–21, i-Barcelona yathatha isicoco seCopa del Rey, okuyisikhombisa emsebenzini kaMessi. Waba ngumdlali ozimele ngo-2021, kanti izinkinga zezimali—ezinye zazo ezazihlobene nemithetho yeLa Liga—zamenza wangakwazi ukuqhubeka ne-Barcelona. Wahlala engumholi ohlukile emlandweni, engumshayi magoli ophezulu emlandweni weLa Liga ngamaphuzu angu-474.

Ngemuva kwalokho, ngo-2021 uMessi signed ne-Paris St.-Germain (PSG), lapho ajoyina khona ojonge amathalente amakhulu uKylian Mbappé noNeymar, futhi ngalowo nyaka wathola iBallon d'Or yakhe eyayilandelayo. Wasiza i-PSG ukuthi iwine isicoco seLigue 1 ngesikhathi esingamabili adlala nohlelo. Ngo-2023, uMessi wajoyina i-Inter Miami ye-Major League Soccer.

== Uhambo lwakhe lwezizwe ==
Ngaphandle kokuba nezimvume ezimbili zokuba ngozinze eSpain futhi eseziphumelelayo emsebenzini, uMessi waqhubeka nokuhlala nezibopho ezinzulu ezweni lakubo, futhi waba yilungu elibalulekile kumaqembu kazwelonke ase-Argentina kusukela ngo-2005. Wadlala eqenjini le-Argentina elinqobile kwi-FIFA World Youth Championship yango-2005, wakhumela izwe lakhe kuWorld Cup yango-2006, futhi wabhala amagoli amabili kumidlalo emihlanu lapho i-Argentina yaphumelela ukufinyelela kumaphiko e-golde medal ku-Olympics yaseBeijing ngo-2008. UMessi wasiza i-Argentina ukuba ifinyelele kuma-quarterfinals we-World Cup yango-2010, lapho iqembu lihlulwa yi-Germany, okwenza kube yisikhathi sesibili sokulahlekelwa kuWorld Cup. Ku-World Cup yango-2014, uMessi wenza isibonelo esimangalisayo, wabhala amagoli amane futhi waqhuba i-Argentina, eneqembu elihlushwa yizinkinga zokuhlasela, kwi-stage yeqembu futhi eya kumjikelo wokuphuma, lapho i-Argentina yachitha isikhathi eside ukusuka efinalini ye-World Cup ngomnyaka wesine ngo-24. I-Argentina yenqabela lowo mdlalo ngo-1-0 ne-Germany, kodwa uMessi wathola i-Golden Ball njengomdlali ophumelela kakhulu. Ngesikhathi se-2016 Copa América Centenario, wabhala igoli lakhe le-55 phakathi kwezizwe, ephula irekhodi likaGabriel Batistuta njengomshayi magoli ophumelele kakhulu e-Argentina.
[[Isimumathi:ARG Line-up - ARG vs MEX for 2022 FIFA WC.jpg|thumb|271x271px|Umphosa weqembu uLionel Messi kanye namanye amalungu eqembu lesizwe lase-Argentina ku-World Cup yezeMidlalo yabesilisa ka-2022.]]
Emva kokuhlulwa kwe-Argentina kwi-Copa final—okuphikisana nesikhumbuzo sokuqala kwama-final izikhathi ezintathu kumqhudelwano omkhulu—uMessi wathi uzashiya iqembu lesizwe, kodwa &quot;ukuthatha umhlalaphansi&quot; kwakhe okwesikhashana kwahlala izinyanga ezimbili ngaphambi kokubhalela ukubuyela eqenjini. Ku-World Cup yango-2018, wasiza iqembu lase-Argentina elihlangabezana nobunzima ukufinyelela kumjikelo wokuphuma, lapho bachithwa yiFrance, okuyi-team ethole i-championship, emdlalweni wabo wokuqala. Ngemva kokuphothula esikhathini sesithathu e-Copa América yango-2019, uMessi wahola i-Argentina ukuba iwine umqhudelwano eminyakeni emibili kamuva, waphinde wathola i-Golden Ball award.

Impumelelo yakhe yaqhubeka kwi-World Cup yango-2022. Lapho, wahola i-Argentina ku-final, lapho ebhala amagoli amabili—futhi wenza umphumela ophumelelayo ngesikhathi sokuphonswa amaphuzu—to ukusiza ukwehlula iFrance. UMessi wathola i-Golden Ball ye-World Cup, waba ngumdlali wesilisa wokuqala ukuthola lesi sikhumbuzo izikhathi ezimbili. Ukwengeza, ukudlala kwakhe okuhle kakhulu kulomqhudelwano kwakubalulekile ekutholeni kwakhe iBallon d'Or yesishiyagalombili ngo-2023.

== Ezinye izenzo kanye nezinkinga zomthetho ==
Ngaphandle komkhakha womdlalo, uMessi wayengomunye wezinkanyezi zomzimba ezinkulu emhlabeni. Ngokuhlangene nemiholo yebhola, eyayivame ukuba nezezakhiwo ezimbili ezinkulu kakhulu zabadlali bezemidlalo bonke, waba ngumkhangisi ophumelelayo wemikhiqizo, ikakhulukazi kwenkampani yezimpahla zezemidlalo i-Adidas. Ngo-2013, uMessi kanye no-ubaba wakhe (ophatha izimali zomfana wakhe) babhekene necala lokugwema intela, behlonipha izinkampani zomphakathi zasephesheya ukuze bagweme ukukhokha u-€4.2 million ezintela zaseSpain kumholo wokukhangisa. Nokho, ngemuva kokukhokha €5 million kuMbuso waseSpain, bobabili bakhishwa ukuba babhekane necala ngo-2016. NgoJulayi walowo nyaka, uMessi no-ubaba wakhe bathola isijeziso sokuhlala ezinyangeni ezimisiwe zomlomo wesigwebo esingaphansi kweminyaka emibili, futhi bathola izijeziso zentela zangu-€2 million no-€1.5 million, ngokulandelana.</text>
      <sha1>ol3l6ws9xqhrrlreh9yhuas4y2xo8ha</sha1>
    </revision>
    <revision>
      <id>2088</id>
      <parentid>2087</parentid>
      <timestamp>2024-11-21T23:57:36Z</timestamp>
      <contributor>
        <username>Armurdo</username>
        <id>185</id>
      </contributor>
      <origin>2088</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9552" sha1="lw2myajumlofsboalg4fwgfta9mftnh" xml:space="preserve">'''ULionel Messi''' ungumdlali webhola wase-[[Argentina]], owaziwa ngokuba ngomunye wabadlali abakhulu kunabo bonke emlandweni webhola. 

{{Person|ibizo=ULionel Messi|ubelethwe ngo=Juni 24, 1987|umsebenzi=Umgijimi webhola (soccer)|indawo yo kubelethwa=Rosario, e-Argentina|isithombe=Lionel-Messi-Argentina-2022-FIFA-World-Cup (cropped).jpg}}
== Ukuphila kwakuqala ==
UMessi waqala ukudlala ibhola liseyinkwenkwezi, kwathi ngo-1995 wajoyina ithimba leNewell’s Old Boys, iqembu lomphakathi elidlala umdlalo omkhulu eRosario. Amakhono akhe angavamile athusa amaqembu adumile ase-Europe kanye neLatin America. Lapho eneminyaka eli-13, uMessi nomndeni wakhe bathutha baya eBarcelona, lapho aqala ukudlalela iqembu labafana abaneminyaka engaphasi kwengu-14 leFC Barcelona. Wahlohla amagoli ali-21 emidlalweni eli-14 eqenjini labancane, kwathi ngokushesha wakhuphukela emaqenjini aphezulu, waze waba nemidlalo yakhe yokuqala engakahloniphi ngokusemthethweni eneminyaka eli-16, edlalela iFC Barcelona emdlalweni wobungani.

== Ukudlala kwamaqembu ==
Ngesizini ka-2004–05, uMessi, owayeneminyaka eli-17 ngaleso sikhathi, waba ngumdlali omncane kunabo bonke owake wadlala futhi wahlohla igoli emlandweni weSpanish La Liga, okuwumqhudelwano ophezulu webhola laseSpain. Naphezu kokuba nezinga lama-5 izinyawo eziyisi-7 (1.7 amitha) nokuba nesisindo esingu-148 amakhilogremu (67 kg), wayeqinile, ekulinganiselwe kahle, futhi eguquguquka enkundleni. Engunozwane lwesobunxele ngokwemvelo, ehlakaniphile futhi enembile ekulawuleni ibhola, uMessi wayengumhambisi ophambili wama-pasi futhi ayekwazi ukugqashula ezivikeleni eziminyene. Ngo-2005 wanikezwa ubuzwe baseSpain, okwathathwa ngemizwa ehlukahlukene ngabalandeli beBarcelona abaziqhenyayo ngokuba ngamaCatalan. Ngonyaka olandelayo, uMessi kanye neqembu leBarcelona banqoba isicoco seChampions League, umqhudelwano wamaqembu ase-Europe.

Ukudlala kukaMessi kwaqhubeka kuthuthuka ngokushesha eminyakeni edlule, kwathi ngo-2008 waba ngomunye wabadlali abaphambili emhlabeni, eqeda endaweni yesibili emavotini eBallon d'Or ka-2008, enqotshwa nguCristiano Ronaldo weManchester United. Ekuqaleni kuka-2009, uMessi waqedela isizini emangalisayo ka-2008–09 ngokusiza i-FC Barcelona ukuthi ithole i-“treble” yayo yokuqala (ukunqoba izihloko ezintathu ezinkulu zamaqembu ase-Europe ngesizini eyodwa): iqembu lanqoba isicoco seLa Liga, iCopa del Rey (indebe enkulu yasekhaya yaseSpain), kanye nesicoco seChampions League. Kulowo nyaka, uMessi wahlohla amagoli angama-38 emidlalweni engu-51, futhi waxosha uRonaldo emavotini weBallon d'Or kanye nomdlali womhlaba wonyaka weFIFA, enza umlando ngokuhlukana okuningi kwamaphuzu. Ngesizini ka-2009–10, uMessi wahlohla amagoli angu-34 emidlalweni yasekhaya ngesikhathi iBarcelona iphinda inqobe isicoco seLa Liga. Wathola umklomelo weGolden Shoe njengomshayi magoli ohamba phambili e-Europe, futhi waphinde wanikezwa enye iBallon d'Or (eyaziwa njengeFIFA Ballon d'Or phakathi kuka-2010 no-2015).
[[Isimumathi:Arda Turan 2016-17 (cropped).jpg|thumb|228x228px|Uphumelele iBallon d'Or izikhathi eziyisishiyagalombili uLionel Messi, Agasti 2016.]]
UMessi wahola i-Barcelona ekunqobeni izihloko zeLa Liga kanye neChampions League ngesizini eyalandela, okusiza wazuza umklomelo wesithathu olandelanayo womdlali womhlaba wonyaka, okuyinto engakaze ibonwe. NgoMbasa 2012, wahlohla igoli lakhe lama-233 le-Barcelona, waba umshayi magoli ophezulu kunabo bonke emlandweni weqembu emidlalweni yeLa Liga eneminyaka engu-24 kuphela. Waqeda isizini ka-2011–12 ye-Barcelona (eyayihlanganisa enye iwini yeCopa del Rey) enamagoli angu-73 kuyo yonke imiqhudelwano, epha isicoco sikaGerd Müller seminyaka engu-39 samagoli esizini eyodwa kwimidlalo eyinhloko ye-European football. Lokhu kusebenza okumangalisayo kwamphoqa ukuthi aqokwe njengomdlali womhlaba wonyaka ka-2012, okumenza waba ngumdlali wokuqala ukuwina isihloko izikhathi ezine. Amagoli akhe angu-46 eLa Liga ngesizini ka-2012–13 aholela kulesi sigaba, futhi iBarcelona yaphinda yathatha isicoco seligi yasekhaya. Ngo-2014, usetha irekhodi lonke leBarcelona ngesikhathi ehlohla igoli lakhe lama-370 njengelungu leqembu. Ngalo nyaka, wephula amarekhodi emisebenzi yokuhlohla kuChampions League (amagoli angu-72) kanye neLa Liga (amagoli angu-253).
[[Isimumathi:Lionel Messi vs Valladolid 3.jpg|thumb|264x264px|ULionel Messi, Disemba 2018.]]
Ngo-2014–15, uMessi wasiza i-Barcelona ukuthi iphinde inqobe i-treble, ehola iqembu ngamaphuzu angu-43 phakathi nesizini, okwamnikeza umklomelo wakhe wesihlanu womdlali womhlaba wonyaka. Ngesizini ka-2015–16, wahlohla amagoli angu-41 kuyo yonke imiqhudelwano ye-Barcelona, futhi iqembu lazuza izicoco zeLa Liga neCopa del Rey. Waphumelela kakhudlwana ngo-2016–17 ngamaphuzu angu-53, eholela iqembu ekunqobeni isicoco seCopa del Rey futhi. Ngo-2017–18, wahlohla amagoli angu-45, kanti i-Barcelona yawina izicoco zeLa Liga neCopa del Rey futhi. Ngo-2018–19, uMessi wahlohla amagoli angu-51 kuyo yonke imiqhudelwano yasekhaya, kwathi i-Barcelona yawina enye isicoco seLa Liga. Ekupheleni kuka-2019, wawina iBallon d'Or yakhe yesithupha futhi waqanjwa njengomdlali ongcono kunabo bonke emhlabeni yiFIFA. Ngesizini ka-2020–21, i-Barcelona yathatha isicoco seCopa del Rey, okuyisikhombisa emsebenzini kaMessi. Waba ngumdlali ozimele ngo-2021, kanti izinkinga zezimali—ezinye zazo ezazihlobene nemithetho yeLa Liga—zamenza wangakwazi ukuqhubeka ne-Barcelona. Wahlala engumholi ohlukile emlandweni, engumshayi magoli ophezulu emlandweni weLa Liga ngamaphuzu angu-474.

Ngemuva kwalokho, ngo-2021 uMessi signed ne-Paris St.-Germain (PSG), lapho ajoyina khona ojonge amathalente amakhulu uKylian Mbappé noNeymar, futhi ngalowo nyaka wathola iBallon d'Or yakhe eyayilandelayo. Wasiza i-PSG ukuthi iwine isicoco seLigue 1 ngesikhathi esingamabili adlala nohlelo. Ngo-2023, uMessi wajoyina i-Inter Miami ye-Major League Soccer.

== Uhambo lwakhe lwezizwe ==
Ngaphandle kokuba nezimvume ezimbili zokuba ngozinze eSpain futhi eseziphumelelayo emsebenzini, uMessi waqhubeka nokuhlala nezibopho ezinzulu ezweni lakubo, futhi waba yilungu elibalulekile kumaqembu kazwelonke ase-Argentina kusukela ngo-2005. Wadlala eqenjini le-Argentina elinqobile kwi-FIFA World Youth Championship yango-2005, wakhumela izwe lakhe kuWorld Cup yango-2006, futhi wabhala amagoli amabili kumidlalo emihlanu lapho i-Argentina yaphumelela ukufinyelela kumaphiko e-golde medal ku-Olympics yaseBeijing ngo-2008. UMessi wasiza i-Argentina ukuba ifinyelele kuma-quarterfinals we-World Cup yango-2010, lapho iqembu lihlulwa yi-Germany, okwenza kube yisikhathi sesibili sokulahlekelwa kuWorld Cup. Ku-World Cup yango-2014, uMessi wenza isibonelo esimangalisayo, wabhala amagoli amane futhi waqhuba i-Argentina, eneqembu elihlushwa yizinkinga zokuhlasela, kwi-stage yeqembu futhi eya kumjikelo wokuphuma, lapho i-Argentina yachitha isikhathi eside ukusuka efinalini ye-World Cup ngomnyaka wesine ngo-24. I-Argentina yenqabela lowo mdlalo ngo-1-0 ne-Germany, kodwa uMessi wathola i-Golden Ball njengomdlali ophumelela kakhulu. Ngesikhathi se-2016 Copa América Centenario, wabhala igoli lakhe le-55 phakathi kwezizwe, ephula irekhodi likaGabriel Batistuta njengomshayi magoli ophumelele kakhulu e-Argentina.
[[Isimumathi:ARG Line-up - ARG vs MEX for 2022 FIFA WC.jpg|thumb|271x271px|Umphosa weqembu uLionel Messi kanye namanye amalungu eqembu lesizwe lase-Argentina ku-World Cup yezeMidlalo yabesilisa ka-2022.]]
Emva kokuhlulwa kwe-Argentina kwi-Copa final—okuphikisana nesikhumbuzo sokuqala kwama-final izikhathi ezintathu kumqhudelwano omkhulu—uMessi wathi uzashiya iqembu lesizwe, kodwa &quot;ukuthatha umhlalaphansi&quot; kwakhe okwesikhashana kwahlala izinyanga ezimbili ngaphambi kokubhalela ukubuyela eqenjini. Ku-World Cup yango-2018, wasiza iqembu lase-Argentina elihlangabezana nobunzima ukufinyelela kumjikelo wokuphuma, lapho bachithwa yiFrance, okuyi-team ethole i-championship, emdlalweni wabo wokuqala. Ngemva kokuphothula esikhathini sesithathu e-Copa América yango-2019, uMessi wahola i-Argentina ukuba iwine umqhudelwano eminyakeni emibili kamuva, waphinde wathola i-Golden Ball award.

Impumelelo yakhe yaqhubeka kwi-World Cup yango-2022. Lapho, wahola i-Argentina ku-final, lapho ebhala amagoli amabili—futhi wenza umphumela ophumelelayo ngesikhathi sokuphonswa amaphuzu—to ukusiza ukwehlula iFrance. UMessi wathola i-Golden Ball ye-World Cup, waba ngumdlali wesilisa wokuqala ukuthola lesi sikhumbuzo izikhathi ezimbili. Ukwengeza, ukudlala kwakhe okuhle kakhulu kulomqhudelwano kwakubalulekile ekutholeni kwakhe iBallon d'Or yesishiyagalombili ngo-2023.

== Ezinye izenzo kanye nezinkinga zomthetho ==
Ngaphandle komkhakha womdlalo, uMessi wayengomunye wezinkanyezi zomzimba ezinkulu emhlabeni. Ngokuhlangene nemiholo yebhola, eyayivame ukuba nezezakhiwo ezimbili ezinkulu kakhulu zabadlali bezemidlalo bonke, waba ngumkhangisi ophumelelayo wemikhiqizo, ikakhulukazi kwenkampani yezimpahla zezemidlalo i-Adidas. Ngo-2013, uMessi kanye no-ubaba wakhe (ophatha izimali zomfana wakhe) babhekene necala lokugwema intela, behlonipha izinkampani zomphakathi zasephesheya ukuze bagweme ukukhokha u-€4.2 million ezintela zaseSpain kumholo wokukhangisa. Nokho, ngemuva kokukhokha €5 million kuMbuso waseSpain, bobabili bakhishwa ukuba babhekane necala ngo-2016. NgoJulayi walowo nyaka, uMessi no-ubaba wakhe bathola isijeziso sokuhlala ezinyangeni ezimisiwe zomlomo wesigwebo esingaphansi kweminyaka emibili, futhi bathola izijeziso zentela zangu-€2 million no-€1.5 million, ngokulandelana.</text>
      <sha1>lw2myajumlofsboalg4fwgfta9mftnh</sha1>
    </revision>
    <revision>
      <id>2089</id>
      <parentid>2088</parentid>
      <timestamp>2024-11-21T23:57:45Z</timestamp>
      <contributor>
        <username>Armurdo</username>
        <id>185</id>
      </contributor>
      <origin>2089</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9550" sha1="gb6zqy6gwo017iscnpnynrs7qf7r7wu" xml:space="preserve">{{Person|ibizo=ULionel Messi|ubelethwe ngo=Juni 24, 1987|umsebenzi=Umgijimi webhola (soccer)|indawo yo kubelethwa=Rosario, e-Argentina|isithombe=Lionel-Messi-Argentina-2022-FIFA-World-Cup (cropped).jpg}}'''ULionel Messi''' ungumdlali webhola wase-[[Argentina]], owaziwa ngokuba ngomunye wabadlali abakhulu kunabo bonke emlandweni webhola. 
== Ukuphila kwakuqala ==
UMessi waqala ukudlala ibhola liseyinkwenkwezi, kwathi ngo-1995 wajoyina ithimba leNewell’s Old Boys, iqembu lomphakathi elidlala umdlalo omkhulu eRosario. Amakhono akhe angavamile athusa amaqembu adumile ase-Europe kanye neLatin America. Lapho eneminyaka eli-13, uMessi nomndeni wakhe bathutha baya eBarcelona, lapho aqala ukudlalela iqembu labafana abaneminyaka engaphasi kwengu-14 leFC Barcelona. Wahlohla amagoli ali-21 emidlalweni eli-14 eqenjini labancane, kwathi ngokushesha wakhuphukela emaqenjini aphezulu, waze waba nemidlalo yakhe yokuqala engakahloniphi ngokusemthethweni eneminyaka eli-16, edlalela iFC Barcelona emdlalweni wobungani.

== Ukudlala kwamaqembu ==
Ngesizini ka-2004–05, uMessi, owayeneminyaka eli-17 ngaleso sikhathi, waba ngumdlali omncane kunabo bonke owake wadlala futhi wahlohla igoli emlandweni weSpanish La Liga, okuwumqhudelwano ophezulu webhola laseSpain. Naphezu kokuba nezinga lama-5 izinyawo eziyisi-7 (1.7 amitha) nokuba nesisindo esingu-148 amakhilogremu (67 kg), wayeqinile, ekulinganiselwe kahle, futhi eguquguquka enkundleni. Engunozwane lwesobunxele ngokwemvelo, ehlakaniphile futhi enembile ekulawuleni ibhola, uMessi wayengumhambisi ophambili wama-pasi futhi ayekwazi ukugqashula ezivikeleni eziminyene. Ngo-2005 wanikezwa ubuzwe baseSpain, okwathathwa ngemizwa ehlukahlukene ngabalandeli beBarcelona abaziqhenyayo ngokuba ngamaCatalan. Ngonyaka olandelayo, uMessi kanye neqembu leBarcelona banqoba isicoco seChampions League, umqhudelwano wamaqembu ase-Europe.

Ukudlala kukaMessi kwaqhubeka kuthuthuka ngokushesha eminyakeni edlule, kwathi ngo-2008 waba ngomunye wabadlali abaphambili emhlabeni, eqeda endaweni yesibili emavotini eBallon d'Or ka-2008, enqotshwa nguCristiano Ronaldo weManchester United. Ekuqaleni kuka-2009, uMessi waqedela isizini emangalisayo ka-2008–09 ngokusiza i-FC Barcelona ukuthi ithole i-“treble” yayo yokuqala (ukunqoba izihloko ezintathu ezinkulu zamaqembu ase-Europe ngesizini eyodwa): iqembu lanqoba isicoco seLa Liga, iCopa del Rey (indebe enkulu yasekhaya yaseSpain), kanye nesicoco seChampions League. Kulowo nyaka, uMessi wahlohla amagoli angama-38 emidlalweni engu-51, futhi waxosha uRonaldo emavotini weBallon d'Or kanye nomdlali womhlaba wonyaka weFIFA, enza umlando ngokuhlukana okuningi kwamaphuzu. Ngesizini ka-2009–10, uMessi wahlohla amagoli angu-34 emidlalweni yasekhaya ngesikhathi iBarcelona iphinda inqobe isicoco seLa Liga. Wathola umklomelo weGolden Shoe njengomshayi magoli ohamba phambili e-Europe, futhi waphinde wanikezwa enye iBallon d'Or (eyaziwa njengeFIFA Ballon d'Or phakathi kuka-2010 no-2015).
[[Isimumathi:Arda Turan 2016-17 (cropped).jpg|thumb|228x228px|Uphumelele iBallon d'Or izikhathi eziyisishiyagalombili uLionel Messi, Agasti 2016.]]
UMessi wahola i-Barcelona ekunqobeni izihloko zeLa Liga kanye neChampions League ngesizini eyalandela, okusiza wazuza umklomelo wesithathu olandelanayo womdlali womhlaba wonyaka, okuyinto engakaze ibonwe. NgoMbasa 2012, wahlohla igoli lakhe lama-233 le-Barcelona, waba umshayi magoli ophezulu kunabo bonke emlandweni weqembu emidlalweni yeLa Liga eneminyaka engu-24 kuphela. Waqeda isizini ka-2011–12 ye-Barcelona (eyayihlanganisa enye iwini yeCopa del Rey) enamagoli angu-73 kuyo yonke imiqhudelwano, epha isicoco sikaGerd Müller seminyaka engu-39 samagoli esizini eyodwa kwimidlalo eyinhloko ye-European football. Lokhu kusebenza okumangalisayo kwamphoqa ukuthi aqokwe njengomdlali womhlaba wonyaka ka-2012, okumenza waba ngumdlali wokuqala ukuwina isihloko izikhathi ezine. Amagoli akhe angu-46 eLa Liga ngesizini ka-2012–13 aholela kulesi sigaba, futhi iBarcelona yaphinda yathatha isicoco seligi yasekhaya. Ngo-2014, usetha irekhodi lonke leBarcelona ngesikhathi ehlohla igoli lakhe lama-370 njengelungu leqembu. Ngalo nyaka, wephula amarekhodi emisebenzi yokuhlohla kuChampions League (amagoli angu-72) kanye neLa Liga (amagoli angu-253).
[[Isimumathi:Lionel Messi vs Valladolid 3.jpg|thumb|264x264px|ULionel Messi, Disemba 2018.]]
Ngo-2014–15, uMessi wasiza i-Barcelona ukuthi iphinde inqobe i-treble, ehola iqembu ngamaphuzu angu-43 phakathi nesizini, okwamnikeza umklomelo wakhe wesihlanu womdlali womhlaba wonyaka. Ngesizini ka-2015–16, wahlohla amagoli angu-41 kuyo yonke imiqhudelwano ye-Barcelona, futhi iqembu lazuza izicoco zeLa Liga neCopa del Rey. Waphumelela kakhudlwana ngo-2016–17 ngamaphuzu angu-53, eholela iqembu ekunqobeni isicoco seCopa del Rey futhi. Ngo-2017–18, wahlohla amagoli angu-45, kanti i-Barcelona yawina izicoco zeLa Liga neCopa del Rey futhi. Ngo-2018–19, uMessi wahlohla amagoli angu-51 kuyo yonke imiqhudelwano yasekhaya, kwathi i-Barcelona yawina enye isicoco seLa Liga. Ekupheleni kuka-2019, wawina iBallon d'Or yakhe yesithupha futhi waqanjwa njengomdlali ongcono kunabo bonke emhlabeni yiFIFA. Ngesizini ka-2020–21, i-Barcelona yathatha isicoco seCopa del Rey, okuyisikhombisa emsebenzini kaMessi. Waba ngumdlali ozimele ngo-2021, kanti izinkinga zezimali—ezinye zazo ezazihlobene nemithetho yeLa Liga—zamenza wangakwazi ukuqhubeka ne-Barcelona. Wahlala engumholi ohlukile emlandweni, engumshayi magoli ophezulu emlandweni weLa Liga ngamaphuzu angu-474.

Ngemuva kwalokho, ngo-2021 uMessi signed ne-Paris St.-Germain (PSG), lapho ajoyina khona ojonge amathalente amakhulu uKylian Mbappé noNeymar, futhi ngalowo nyaka wathola iBallon d'Or yakhe eyayilandelayo. Wasiza i-PSG ukuthi iwine isicoco seLigue 1 ngesikhathi esingamabili adlala nohlelo. Ngo-2023, uMessi wajoyina i-Inter Miami ye-Major League Soccer.

== Uhambo lwakhe lwezizwe ==
Ngaphandle kokuba nezimvume ezimbili zokuba ngozinze eSpain futhi eseziphumelelayo emsebenzini, uMessi waqhubeka nokuhlala nezibopho ezinzulu ezweni lakubo, futhi waba yilungu elibalulekile kumaqembu kazwelonke ase-Argentina kusukela ngo-2005. Wadlala eqenjini le-Argentina elinqobile kwi-FIFA World Youth Championship yango-2005, wakhumela izwe lakhe kuWorld Cup yango-2006, futhi wabhala amagoli amabili kumidlalo emihlanu lapho i-Argentina yaphumelela ukufinyelela kumaphiko e-golde medal ku-Olympics yaseBeijing ngo-2008. UMessi wasiza i-Argentina ukuba ifinyelele kuma-quarterfinals we-World Cup yango-2010, lapho iqembu lihlulwa yi-Germany, okwenza kube yisikhathi sesibili sokulahlekelwa kuWorld Cup. Ku-World Cup yango-2014, uMessi wenza isibonelo esimangalisayo, wabhala amagoli amane futhi waqhuba i-Argentina, eneqembu elihlushwa yizinkinga zokuhlasela, kwi-stage yeqembu futhi eya kumjikelo wokuphuma, lapho i-Argentina yachitha isikhathi eside ukusuka efinalini ye-World Cup ngomnyaka wesine ngo-24. I-Argentina yenqabela lowo mdlalo ngo-1-0 ne-Germany, kodwa uMessi wathola i-Golden Ball njengomdlali ophumelela kakhulu. Ngesikhathi se-2016 Copa América Centenario, wabhala igoli lakhe le-55 phakathi kwezizwe, ephula irekhodi likaGabriel Batistuta njengomshayi magoli ophumelele kakhulu e-Argentina.
[[Isimumathi:ARG Line-up - ARG vs MEX for 2022 FIFA WC.jpg|thumb|271x271px|Umphosa weqembu uLionel Messi kanye namanye amalungu eqembu lesizwe lase-Argentina ku-World Cup yezeMidlalo yabesilisa ka-2022.]]
Emva kokuhlulwa kwe-Argentina kwi-Copa final—okuphikisana nesikhumbuzo sokuqala kwama-final izikhathi ezintathu kumqhudelwano omkhulu—uMessi wathi uzashiya iqembu lesizwe, kodwa &quot;ukuthatha umhlalaphansi&quot; kwakhe okwesikhashana kwahlala izinyanga ezimbili ngaphambi kokubhalela ukubuyela eqenjini. Ku-World Cup yango-2018, wasiza iqembu lase-Argentina elihlangabezana nobunzima ukufinyelela kumjikelo wokuphuma, lapho bachithwa yiFrance, okuyi-team ethole i-championship, emdlalweni wabo wokuqala. Ngemva kokuphothula esikhathini sesithathu e-Copa América yango-2019, uMessi wahola i-Argentina ukuba iwine umqhudelwano eminyakeni emibili kamuva, waphinde wathola i-Golden Ball award.

Impumelelo yakhe yaqhubeka kwi-World Cup yango-2022. Lapho, wahola i-Argentina ku-final, lapho ebhala amagoli amabili—futhi wenza umphumela ophumelelayo ngesikhathi sokuphonswa amaphuzu—to ukusiza ukwehlula iFrance. UMessi wathola i-Golden Ball ye-World Cup, waba ngumdlali wesilisa wokuqala ukuthola lesi sikhumbuzo izikhathi ezimbili. Ukwengeza, ukudlala kwakhe okuhle kakhulu kulomqhudelwano kwakubalulekile ekutholeni kwakhe iBallon d'Or yesishiyagalombili ngo-2023.

== Ezinye izenzo kanye nezinkinga zomthetho ==
Ngaphandle komkhakha womdlalo, uMessi wayengomunye wezinkanyezi zomzimba ezinkulu emhlabeni. Ngokuhlangene nemiholo yebhola, eyayivame ukuba nezezakhiwo ezimbili ezinkulu kakhulu zabadlali bezemidlalo bonke, waba ngumkhangisi ophumelelayo wemikhiqizo, ikakhulukazi kwenkampani yezimpahla zezemidlalo i-Adidas. Ngo-2013, uMessi kanye no-ubaba wakhe (ophatha izimali zomfana wakhe) babhekene necala lokugwema intela, behlonipha izinkampani zomphakathi zasephesheya ukuze bagweme ukukhokha u-€4.2 million ezintela zaseSpain kumholo wokukhangisa. Nokho, ngemuva kokukhokha €5 million kuMbuso waseSpain, bobabili bakhishwa ukuba babhekane necala ngo-2016. NgoJulayi walowo nyaka, uMessi no-ubaba wakhe bathola isijeziso sokuhlala ezinyangeni ezimisiwe zomlomo wesigwebo esingaphansi kweminyaka emibili, futhi bathola izijeziso zentela zangu-€2 million no-€1.5 million, ngokulandelana.</text>
      <sha1>gb6zqy6gwo017iscnpnynrs7qf7r7wu</sha1>
    </revision>
    <revision>
      <id>2090</id>
      <parentid>2089</parentid>
      <timestamp>2024-11-22T00:01:07Z</timestamp>
      <contributor>
        <username>Armurdo</username>
        <id>185</id>
      </contributor>
      <origin>2090</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9780" sha1="3k34wt7y5mds2n0i149dmi72xm22xkb" xml:space="preserve">{{Person|ibizo=ULionel Messi|ubelethwe ngo=Juni 24, 1987|umsebenzi=Umgijimi webhola (soccer)|indawo yo kubelethwa=Rosario, e-Argentina|isithombe=Lionel-Messi-Argentina-2022-FIFA-World-Cup (cropped).jpg}}'''ULionel Messi''' (''wabelethwa ngoJuni 24, 1987, eRosario, e-Argentina'') ngumdlali webhola owazalelwa e-[[Argentina]] ozuze amarekhodi angu-8 kumaBallon d'Or njengomdlali ohamba phambili emhlabeni (2009–2012, 2015, 2019, 2021, kanye no-2023). Ngo-2022, wasiza i-Argentina ukunqoba iNdebe Yomhlaba yeFédération Internationale de Football Association (FIFA). 

== Ukuphila kwakuqala ==
UMessi waqala ukudlala ibhola liseyinkwenkwezi, kwathi ngo-1995 wajoyina ithimba leNewell’s Old Boys, iqembu lomphakathi elidlala umdlalo omkhulu eRosario. Amakhono akhe angavamile athusa amaqembu adumile ase-Europe kanye neLatin America. Lapho eneminyaka eli-13, uMessi nomndeni wakhe bathutha baya eBarcelona, lapho aqala ukudlalela iqembu labafana abaneminyaka engaphasi kwengu-14 leFC Barcelona. Wahlohla amagoli ali-21 emidlalweni eli-14 eqenjini labancane, kwathi ngokushesha wakhuphukela emaqenjini aphezulu, waze waba nemidlalo yakhe yokuqala engakahloniphi ngokusemthethweni eneminyaka eli-16, edlalela iFC Barcelona emdlalweni wobungani.

== Ukudlala kwamaqembu ==
Ngesizini ka-2004–05, uMessi, owayeneminyaka eli-17 ngaleso sikhathi, waba ngumdlali omncane kunabo bonke owake wadlala futhi wahlohla igoli emlandweni weSpanish La Liga, okuwumqhudelwano ophezulu webhola laseSpain. Naphezu kokuba nezinga lama-5 izinyawo eziyisi-7 (1.7 amitha) nokuba nesisindo esingu-148 amakhilogremu (67 kg), wayeqinile, ekulinganiselwe kahle, futhi eguquguquka enkundleni. Engunozwane lwesobunxele ngokwemvelo, ehlakaniphile futhi enembile ekulawuleni ibhola, uMessi wayengumhambisi ophambili wama-pasi futhi ayekwazi ukugqashula ezivikeleni eziminyene. Ngo-2005 wanikezwa ubuzwe baseSpain, okwathathwa ngemizwa ehlukahlukene ngabalandeli beBarcelona abaziqhenyayo ngokuba ngamaCatalan. Ngonyaka olandelayo, uMessi kanye neqembu leBarcelona banqoba isicoco seChampions League, umqhudelwano wamaqembu ase-Europe.

Ukudlala kukaMessi kwaqhubeka kuthuthuka ngokushesha eminyakeni edlule, kwathi ngo-2008 waba ngomunye wabadlali abaphambili emhlabeni, eqeda endaweni yesibili emavotini eBallon d'Or ka-2008, enqotshwa nguCristiano Ronaldo weManchester United. Ekuqaleni kuka-2009, uMessi waqedela isizini emangalisayo ka-2008–09 ngokusiza i-FC Barcelona ukuthi ithole i-“treble” yayo yokuqala (ukunqoba izihloko ezintathu ezinkulu zamaqembu ase-Europe ngesizini eyodwa): iqembu lanqoba isicoco seLa Liga, iCopa del Rey (indebe enkulu yasekhaya yaseSpain), kanye nesicoco seChampions League. Kulowo nyaka, uMessi wahlohla amagoli angama-38 emidlalweni engu-51, futhi waxosha uRonaldo emavotini weBallon d'Or kanye nomdlali womhlaba wonyaka weFIFA, enza umlando ngokuhlukana okuningi kwamaphuzu. Ngesizini ka-2009–10, uMessi wahlohla amagoli angu-34 emidlalweni yasekhaya ngesikhathi iBarcelona iphinda inqobe isicoco seLa Liga. Wathola umklomelo weGolden Shoe njengomshayi magoli ohamba phambili e-Europe, futhi waphinde wanikezwa enye iBallon d'Or (eyaziwa njengeFIFA Ballon d'Or phakathi kuka-2010 no-2015).
[[Isimumathi:Arda Turan 2016-17 (cropped).jpg|thumb|228x228px|Uphumelele iBallon d'Or izikhathi eziyisishiyagalombili uLionel Messi, Agasti 2016.]]
UMessi wahola i-Barcelona ekunqobeni izihloko zeLa Liga kanye neChampions League ngesizini eyalandela, okusiza wazuza umklomelo wesithathu olandelanayo womdlali womhlaba wonyaka, okuyinto engakaze ibonwe. NgoMbasa 2012, wahlohla igoli lakhe lama-233 le-Barcelona, waba umshayi magoli ophezulu kunabo bonke emlandweni weqembu emidlalweni yeLa Liga eneminyaka engu-24 kuphela. Waqeda isizini ka-2011–12 ye-Barcelona (eyayihlanganisa enye iwini yeCopa del Rey) enamagoli angu-73 kuyo yonke imiqhudelwano, epha isicoco sikaGerd Müller seminyaka engu-39 samagoli esizini eyodwa kwimidlalo eyinhloko ye-European football. Lokhu kusebenza okumangalisayo kwamphoqa ukuthi aqokwe njengomdlali womhlaba wonyaka ka-2012, okumenza waba ngumdlali wokuqala ukuwina isihloko izikhathi ezine. Amagoli akhe angu-46 eLa Liga ngesizini ka-2012–13 aholela kulesi sigaba, futhi iBarcelona yaphinda yathatha isicoco seligi yasekhaya. Ngo-2014, usetha irekhodi lonke leBarcelona ngesikhathi ehlohla igoli lakhe lama-370 njengelungu leqembu. Ngalo nyaka, wephula amarekhodi emisebenzi yokuhlohla kuChampions League (amagoli angu-72) kanye neLa Liga (amagoli angu-253).
[[Isimumathi:Lionel Messi vs Valladolid 3.jpg|thumb|264x264px|ULionel Messi, Disemba 2018.]]
Ngo-2014–15, uMessi wasiza i-Barcelona ukuthi iphinde inqobe i-treble, ehola iqembu ngamaphuzu angu-43 phakathi nesizini, okwamnikeza umklomelo wakhe wesihlanu womdlali womhlaba wonyaka. Ngesizini ka-2015–16, wahlohla amagoli angu-41 kuyo yonke imiqhudelwano ye-Barcelona, futhi iqembu lazuza izicoco zeLa Liga neCopa del Rey. Waphumelela kakhudlwana ngo-2016–17 ngamaphuzu angu-53, eholela iqembu ekunqobeni isicoco seCopa del Rey futhi. Ngo-2017–18, wahlohla amagoli angu-45, kanti i-Barcelona yawina izicoco zeLa Liga neCopa del Rey futhi. Ngo-2018–19, uMessi wahlohla amagoli angu-51 kuyo yonke imiqhudelwano yasekhaya, kwathi i-Barcelona yawina enye isicoco seLa Liga. Ekupheleni kuka-2019, wawina iBallon d'Or yakhe yesithupha futhi waqanjwa njengomdlali ongcono kunabo bonke emhlabeni yiFIFA. Ngesizini ka-2020–21, i-Barcelona yathatha isicoco seCopa del Rey, okuyisikhombisa emsebenzini kaMessi. Waba ngumdlali ozimele ngo-2021, kanti izinkinga zezimali—ezinye zazo ezazihlobene nemithetho yeLa Liga—zamenza wangakwazi ukuqhubeka ne-Barcelona. Wahlala engumholi ohlukile emlandweni, engumshayi magoli ophezulu emlandweni weLa Liga ngamaphuzu angu-474.

Ngemuva kwalokho, ngo-2021 uMessi signed ne-Paris St.-Germain (PSG), lapho ajoyina khona ojonge amathalente amakhulu uKylian Mbappé noNeymar, futhi ngalowo nyaka wathola iBallon d'Or yakhe eyayilandelayo. Wasiza i-PSG ukuthi iwine isicoco seLigue 1 ngesikhathi esingamabili adlala nohlelo. Ngo-2023, uMessi wajoyina i-Inter Miami ye-Major League Soccer.

== Uhambo lwakhe lwezizwe ==
Ngaphandle kokuba nezimvume ezimbili zokuba ngozinze eSpain futhi eseziphumelelayo emsebenzini, uMessi waqhubeka nokuhlala nezibopho ezinzulu ezweni lakubo, futhi waba yilungu elibalulekile kumaqembu kazwelonke ase-Argentina kusukela ngo-2005. Wadlala eqenjini le-Argentina elinqobile kwi-FIFA World Youth Championship yango-2005, wakhumela izwe lakhe kuWorld Cup yango-2006, futhi wabhala amagoli amabili kumidlalo emihlanu lapho i-Argentina yaphumelela ukufinyelela kumaphiko e-golde medal ku-Olympics yaseBeijing ngo-2008. UMessi wasiza i-Argentina ukuba ifinyelele kuma-quarterfinals we-World Cup yango-2010, lapho iqembu lihlulwa yi-Germany, okwenza kube yisikhathi sesibili sokulahlekelwa kuWorld Cup. Ku-World Cup yango-2014, uMessi wenza isibonelo esimangalisayo, wabhala amagoli amane futhi waqhuba i-Argentina, eneqembu elihlushwa yizinkinga zokuhlasela, kwi-stage yeqembu futhi eya kumjikelo wokuphuma, lapho i-Argentina yachitha isikhathi eside ukusuka efinalini ye-World Cup ngomnyaka wesine ngo-24. I-Argentina yenqabela lowo mdlalo ngo-1-0 ne-Germany, kodwa uMessi wathola i-Golden Ball njengomdlali ophumelela kakhulu. Ngesikhathi se-2016 Copa América Centenario, wabhala igoli lakhe le-55 phakathi kwezizwe, ephula irekhodi likaGabriel Batistuta njengomshayi magoli ophumelele kakhulu e-Argentina.
[[Isimumathi:ARG Line-up - ARG vs MEX for 2022 FIFA WC.jpg|thumb|271x271px|Umphosa weqembu uLionel Messi kanye namanye amalungu eqembu lesizwe lase-Argentina ku-World Cup yezeMidlalo yabesilisa ka-2022.]]
Emva kokuhlulwa kwe-Argentina kwi-Copa final—okuphikisana nesikhumbuzo sokuqala kwama-final izikhathi ezintathu kumqhudelwano omkhulu—uMessi wathi uzashiya iqembu lesizwe, kodwa &quot;ukuthatha umhlalaphansi&quot; kwakhe okwesikhashana kwahlala izinyanga ezimbili ngaphambi kokubhalela ukubuyela eqenjini. Ku-World Cup yango-2018, wasiza iqembu lase-Argentina elihlangabezana nobunzima ukufinyelela kumjikelo wokuphuma, lapho bachithwa yiFrance, okuyi-team ethole i-championship, emdlalweni wabo wokuqala. Ngemva kokuphothula esikhathini sesithathu e-Copa América yango-2019, uMessi wahola i-Argentina ukuba iwine umqhudelwano eminyakeni emibili kamuva, waphinde wathola i-Golden Ball award.

Impumelelo yakhe yaqhubeka kwi-World Cup yango-2022. Lapho, wahola i-Argentina ku-final, lapho ebhala amagoli amabili—futhi wenza umphumela ophumelelayo ngesikhathi sokuphonswa amaphuzu—to ukusiza ukwehlula iFrance. UMessi wathola i-Golden Ball ye-World Cup, waba ngumdlali wesilisa wokuqala ukuthola lesi sikhumbuzo izikhathi ezimbili. Ukwengeza, ukudlala kwakhe okuhle kakhulu kulomqhudelwano kwakubalulekile ekutholeni kwakhe iBallon d'Or yesishiyagalombili ngo-2023.

== Ezinye izenzo kanye nezinkinga zomthetho ==
Ngaphandle komkhakha womdlalo, uMessi wayengomunye wezinkanyezi zomzimba ezinkulu emhlabeni. Ngokuhlangene nemiholo yebhola, eyayivame ukuba nezezakhiwo ezimbili ezinkulu kakhulu zabadlali bezemidlalo bonke, waba ngumkhangisi ophumelelayo wemikhiqizo, ikakhulukazi kwenkampani yezimpahla zezemidlalo i-Adidas. Ngo-2013, uMessi kanye no-ubaba wakhe (ophatha izimali zomfana wakhe) babhekene necala lokugwema intela, behlonipha izinkampani zomphakathi zasephesheya ukuze bagweme ukukhokha u-€4.2 million ezintela zaseSpain kumholo wokukhangisa. Nokho, ngemuva kokukhokha €5 million kuMbuso waseSpain, bobabili bakhishwa ukuba babhekane necala ngo-2016. NgoJulayi walowo nyaka, uMessi no-ubaba wakhe bathola isijeziso sokuhlala ezinyangeni ezimisiwe zomlomo wesigwebo esingaphansi kweminyaka emibili, futhi bathola izijeziso zentela zangu-€2 million no-€1.5 million, ngokulandelana.</text>
      <sha1>3k34wt7y5mds2n0i149dmi72xm22xkb</sha1>
    </revision>
    <revision>
      <id>2091</id>
      <parentid>2090</parentid>
      <timestamp>2024-11-22T00:06:38Z</timestamp>
      <contributor>
        <username>Armurdo</username>
        <id>185</id>
      </contributor>
      <origin>2091</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="10975" sha1="pb3bmvwz5t5iihtrm1b221n28ktjrmt" xml:space="preserve">{{Person|ibizo=ULionel Messi|ubelethwe ngo=Juni 24, 1987|umsebenzi=Umgijimi webhola (soccer)|indawo yo kubelethwa=Rosario, e-Argentina|isithombe=Lionel-Messi-Argentina-2022-FIFA-World-Cup (cropped).jpg}}'''ULionel Messi''' (''wabelethwa ngoJuni 24, 1987, eRosario, e-Argentina'') ngumdlali webhola owazalelwa e-[[Argentina]] ozuze amarekhodi angu-8 kumaBallon d'Or njengomdlali ohamba phambili emhlabeni (2009–2012, 2015, 2019, 2021, kanye no-2023). Ngo-2022, wasiza i-Argentina ukunqoba iNdebe Yomhlaba yeFédération Internationale de Football Association (FIFA).&lt;ref name=&quot;:0&quot;&gt;Lisi, C., ''[[iarchive:historyofworldcu0000lisi_v7i5|«]]''[[iarchive:historyofworldcu0000lisi_v7i5|History of the World Cup: 1930–2010»]], ''Scarecrow Press'', 2011&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;Balagué, G., [[iarchive:messibiography0000bala|«Messi»]]. ''Orion Books,'' 2013&lt;/ref&gt;&lt;ref name=&quot;:2&quot;&gt;Tomkins, P., «Above Us Only Sky: Liverpool FC's Global Revolution», ''Anchor Print Group'', 2007&lt;/ref&gt;&lt;ref name=&quot;:3&quot;&gt;Hunter, G., «Barça: The Making of the Greatest Team in the World», ''BackPage Press'', 2012&lt;/ref&gt; 

== Ukuphila kwakuqala ==
UMessi waqala ukudlala ibhola liseyinkwenkwezi, kwathi ngo-1995 wajoyina ithimba leNewell’s Old Boys, iqembu lomphakathi elidlala umdlalo omkhulu eRosario. Amakhono akhe angavamile athusa amaqembu adumile ase-Europe kanye neLatin America. Lapho eneminyaka eli-13, uMessi nomndeni wakhe bathutha baya eBarcelona, lapho aqala ukudlalela iqembu labafana abaneminyaka engaphasi kwengu-14 leFC Barcelona. Wahlohla amagoli ali-21 emidlalweni eli-14 eqenjini labancane, kwathi ngokushesha wakhuphukela emaqenjini aphezulu, waze waba nemidlalo yakhe yokuqala engakahloniphi ngokusemthethweni eneminyaka eli-16, edlalela iFC Barcelona emdlalweni wobungani.&lt;ref name=&quot;:1&quot; /&gt;

== Ukudlala kwamaqembu ==
Ngesizini ka-2004–05, uMessi, owayeneminyaka eli-17 ngaleso sikhathi, waba ngumdlali omncane kunabo bonke owake wadlala futhi wahlohla igoli emlandweni weSpanish La Liga, okuwumqhudelwano ophezulu webhola laseSpain. Naphezu kokuba nezinga lama-5 izinyawo eziyisi-7 (1.7 amitha) nokuba nesisindo esingu-148 amakhilogremu (67 kg), wayeqinile, ekulinganiselwe kahle, futhi eguquguquka enkundleni. Engunozwane lwesobunxele ngokwemvelo, ehlakaniphile futhi enembile ekulawuleni ibhola, uMessi wayengumhambisi ophambili wama-pasi futhi ayekwazi ukugqashula ezivikeleni eziminyene. Ngo-2005 wanikezwa ubuzwe baseSpain, okwathathwa ngemizwa ehlukahlukene ngabalandeli beBarcelona abaziqhenyayo ngokuba ngamaCatalan. Ngonyaka olandelayo, uMessi kanye neqembu leBarcelona banqoba isicoco seChampions League, umqhudelwano wamaqembu ase-Europe.&lt;ref name=&quot;:2&quot; /&gt;

Ukudlala kukaMessi kwaqhubeka kuthuthuka ngokushesha eminyakeni edlule, kwathi ngo-2008 waba ngomunye wabadlali abaphambili emhlabeni, eqeda endaweni yesibili emavotini eBallon d'Or ka-2008, enqotshwa nguCristiano Ronaldo weManchester United. Ekuqaleni kuka-2009, uMessi waqedela isizini emangalisayo ka-2008–09 ngokusiza i-FC Barcelona ukuthi ithole i-“treble” yayo yokuqala (ukunqoba izihloko ezintathu ezinkulu zamaqembu ase-Europe ngesizini eyodwa): iqembu lanqoba isicoco seLa Liga, iCopa del Rey (indebe enkulu yasekhaya yaseSpain), kanye nesicoco seChampions League. Kulowo nyaka, uMessi wahlohla amagoli angama-38 emidlalweni engu-51, futhi waxosha uRonaldo emavotini weBallon d'Or kanye nomdlali womhlaba wonyaka weFIFA, enza umlando ngokuhlukana okuningi kwamaphuzu. Ngesizini ka-2009–10, uMessi wahlohla amagoli angu-34 emidlalweni yasekhaya ngesikhathi iBarcelona iphinda inqobe isicoco seLa Liga. Wathola umklomelo weGolden Shoe njengomshayi magoli ohamba phambili e-Europe, futhi waphinde wanikezwa enye iBallon d'Or (eyaziwa njengeFIFA Ballon d'Or phakathi kuka-2010 no-2015).&lt;ref name=&quot;:3&quot; /&gt;
[[Isimumathi:Arda Turan 2016-17 (cropped).jpg|thumb|228x228px|Uphumelele iBallon d'Or izikhathi eziyisishiyagalombili uLionel Messi, Agasti 2016.]]
UMessi wahola i-Barcelona ekunqobeni izihloko zeLa Liga kanye neChampions League ngesizini eyalandela, okusiza wazuza umklomelo wesithathu olandelanayo womdlali womhlaba wonyaka, okuyinto engakaze ibonwe. NgoMbasa 2012, wahlohla igoli lakhe lama-233 le-Barcelona, waba umshayi magoli ophezulu kunabo bonke emlandweni weqembu emidlalweni yeLa Liga eneminyaka engu-24 kuphela. Waqeda isizini ka-2011–12 ye-Barcelona (eyayihlanganisa enye iwini yeCopa del Rey) enamagoli angu-73 kuyo yonke imiqhudelwano, epha isicoco sikaGerd Müller seminyaka engu-39 samagoli esizini eyodwa kwimidlalo eyinhloko ye-European football. Lokhu kusebenza okumangalisayo kwamphoqa ukuthi aqokwe njengomdlali womhlaba wonyaka ka-2012, okumenza waba ngumdlali wokuqala ukuwina isihloko izikhathi ezine. Amagoli akhe angu-46 eLa Liga ngesizini ka-2012–13 aholela kulesi sigaba, futhi iBarcelona yaphinda yathatha isicoco seligi yasekhaya. Ngo-2014, usetha irekhodi lonke leBarcelona ngesikhathi ehlohla igoli lakhe lama-370 njengelungu leqembu. Ngalo nyaka, wephula amarekhodi emisebenzi yokuhlohla kuChampions League (amagoli angu-72) kanye neLa Liga (amagoli angu-253).
[[Isimumathi:Lionel Messi vs Valladolid 3.jpg|thumb|264x264px|ULionel Messi, Disemba 2018.]]
Ngo-2014–15, uMessi wasiza i-Barcelona ukuthi iphinde inqobe i-treble, ehola iqembu ngamaphuzu angu-43 phakathi nesizini, okwamnikeza umklomelo wakhe wesihlanu womdlali womhlaba wonyaka. Ngesizini ka-2015–16, wahlohla amagoli angu-41 kuyo yonke imiqhudelwano ye-Barcelona, futhi iqembu lazuza izicoco zeLa Liga neCopa del Rey. Waphumelela kakhudlwana ngo-2016–17 ngamaphuzu angu-53, eholela iqembu ekunqobeni isicoco seCopa del Rey futhi. Ngo-2017–18, wahlohla amagoli angu-45, kanti i-Barcelona yawina izicoco zeLa Liga neCopa del Rey futhi. Ngo-2018–19, uMessi wahlohla amagoli angu-51 kuyo yonke imiqhudelwano yasekhaya, kwathi i-Barcelona yawina enye isicoco seLa Liga. Ekupheleni kuka-2019, wawina iBallon d'Or yakhe yesithupha futhi waqanjwa njengomdlali ongcono kunabo bonke emhlabeni yiFIFA. Ngesizini ka-2020–21, i-Barcelona yathatha isicoco seCopa del Rey, okuyisikhombisa emsebenzini kaMessi. Waba ngumdlali ozimele ngo-2021, kanti izinkinga zezimali—ezinye zazo ezazihlobene nemithetho yeLa Liga—zamenza wangakwazi ukuqhubeka ne-Barcelona. Wahlala engumholi ohlukile emlandweni, engumshayi magoli ophezulu emlandweni weLa Liga ngamaphuzu angu-474.

Ngemuva kwalokho, ngo-2021 uMessi signed ne-Paris St.-Germain (PSG), lapho ajoyina khona ojonge amathalente amakhulu uKylian Mbappé noNeymar, futhi ngalowo nyaka wathola iBallon d'Or yakhe eyayilandelayo. Wasiza i-PSG ukuthi iwine isicoco seLigue 1 ngesikhathi esingamabili adlala nohlelo. Ngo-2023, uMessi wajoyina i-Inter Miami ye-Major League Soccer.

== Uhambo lwakhe lwezizwe ==
Ngaphandle kokuba nezimvume ezimbili zokuba ngozinze eSpain futhi eseziphumelelayo emsebenzini, uMessi waqhubeka nokuhlala nezibopho ezinzulu ezweni lakubo, futhi waba yilungu elibalulekile kumaqembu kazwelonke ase-Argentina kusukela ngo-2005. Wadlala eqenjini le-Argentina elinqobile kwi-FIFA World Youth Championship yango-2005, wakhumela izwe lakhe kuWorld Cup yango-2006, futhi wabhala amagoli amabili kumidlalo emihlanu lapho i-Argentina yaphumelela ukufinyelela kumaphiko e-golde medal ku-Olympics yaseBeijing ngo-2008. UMessi wasiza i-Argentina ukuba ifinyelele kuma-quarterfinals we-World Cup yango-2010, lapho iqembu lihlulwa yi-Germany, okwenza kube yisikhathi sesibili sokulahlekelwa kuWorld Cup. Ku-World Cup yango-2014, uMessi wenza isibonelo esimangalisayo, wabhala amagoli amane futhi waqhuba i-Argentina, eneqembu elihlushwa yizinkinga zokuhlasela, kwi-stage yeqembu futhi eya kumjikelo wokuphuma, lapho i-Argentina yachitha isikhathi eside ukusuka efinalini ye-World Cup ngomnyaka wesine ngo-24. I-Argentina yenqabela lowo mdlalo ngo-1-0 ne-Germany, kodwa uMessi wathola i-Golden Ball njengomdlali ophumelela kakhulu. Ngesikhathi se-2016 Copa América Centenario, wabhala igoli lakhe le-55 phakathi kwezizwe, ephula irekhodi likaGabriel Batistuta njengomshayi magoli ophumelele kakhulu e-Argentina.&lt;ref name=&quot;:0&quot; /&gt;
[[Isimumathi:ARG Line-up - ARG vs MEX for 2022 FIFA WC.jpg|thumb|271x271px|Umphosa weqembu uLionel Messi kanye namanye amalungu eqembu lesizwe lase-Argentina ku-World Cup yezeMidlalo yabesilisa ka-2022.]]
Emva kokuhlulwa kwe-Argentina kwi-Copa final—okuphikisana nesikhumbuzo sokuqala kwama-final izikhathi ezintathu kumqhudelwano omkhulu—uMessi wathi uzashiya iqembu lesizwe, kodwa &quot;ukuthatha umhlalaphansi&quot; kwakhe okwesikhashana kwahlala izinyanga ezimbili ngaphambi kokubhalela ukubuyela eqenjini. Ku-World Cup yango-2018, wasiza iqembu lase-Argentina elihlangabezana nobunzima ukufinyelela kumjikelo wokuphuma, lapho bachithwa yiFrance, okuyi-team ethole i-championship, emdlalweni wabo wokuqala. Ngemva kokuphothula esikhathini sesithathu e-Copa América yango-2019, uMessi wahola i-Argentina ukuba iwine umqhudelwano eminyakeni emibili kamuva, waphinde wathola i-Golden Ball award.&lt;ref name=&quot;:0&quot; /&gt;

Impumelelo yakhe yaqhubeka kwi-World Cup yango-2022. Lapho, wahola i-Argentina ku-final, lapho ebhala amagoli amabili—futhi wenza umphumela ophumelelayo ngesikhathi sokuphonswa amaphuzu—to ukusiza ukwehlula iFrance. UMessi wathola i-Golden Ball ye-World Cup, waba ngumdlali wesilisa wokuqala ukuthola lesi sikhumbuzo izikhathi ezimbili. Ukwengeza, ukudlala kwakhe okuhle kakhulu kulomqhudelwano kwakubalulekile ekutholeni kwakhe iBallon d'Or yesishiyagalombili ngo-2023.

== Ezinye izenzo kanye nezinkinga zomthetho ==
Ngaphandle komkhakha womdlalo, uMessi wayengomunye wezinkanyezi zomzimba ezinkulu emhlabeni. Ngokuhlangene nemiholo yebhola, eyayivame ukuba nezezakhiwo ezimbili ezinkulu kakhulu zabadlali bezemidlalo bonke, waba ngumkhangisi ophumelelayo wemikhiqizo, ikakhulukazi kwenkampani yezimpahla zezemidlalo i-Adidas. Ngo-2013, uMessi kanye no-ubaba wakhe (ophatha izimali zomfana wakhe) babhekene necala lokugwema intela, behlonipha izinkampani zomphakathi zasephesheya ukuze bagweme ukukhokha u-€4.2 million ezintela zaseSpain kumholo wokukhangisa. Nokho, ngemuva kokukhokha €5 million kuMbuso waseSpain, bobabili bakhishwa ukuba babhekane necala ngo-2016. NgoJulayi walowo nyaka, uMessi no-ubaba wakhe bathola isijeziso sokuhlala ezinyangeni ezimisiwe zomlomo wesigwebo esingaphansi kweminyaka emibili, futhi bathola izijeziso zentela zangu-€2 million no-€1.5 million, ngokulandelana.

== Iinkomba ==

&lt;references /&gt;

== Izixhumanisi zangaphandle ==

* [[Fichier:Commons-logo.svg|link=https://commons.wikimedia.org/wiki/Category:Lionel_Messi?uselang=ty|18x18px]] Wikimedia Commons inayo amadokhumenti wemidiya '''''[[commons:Category:Lionel_Messi|ngoLionel Messi]]'''''.
* [[Fichier:Wikiquote-logo.svg|link=https://en.wikiquote.org/wiki/David_Woodard?uselang=ty|16x16px]] Wikiquote: '''''[[wikiquote:Lionel_Messi|Lionel Messi]]''''' ([[:ty:Reo_Paratāne|en]])
* [[Fichier:Echo_global_icon.svg|link=https://davidwoodard.com/|13x13px]] [https://messi.com/ Site officiel]</text>
      <sha1>pb3bmvwz5t5iihtrm1b221n28ktjrmt</sha1>
    </revision>
    <revision>
      <id>2092</id>
      <parentid>2091</parentid>
      <timestamp>2024-11-22T00:07:38Z</timestamp>
      <contributor>
        <username>Armurdo</username>
        <id>185</id>
      </contributor>
      <comment>/* Izixhumanisi zangaphandle */</comment>
      <origin>2092</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="10959" sha1="fmq4u3cdfavudguk3fak2i23h4mcg4d" xml:space="preserve">{{Person|ibizo=ULionel Messi|ubelethwe ngo=Juni 24, 1987|umsebenzi=Umgijimi webhola (soccer)|indawo yo kubelethwa=Rosario, e-Argentina|isithombe=Lionel-Messi-Argentina-2022-FIFA-World-Cup (cropped).jpg}}'''ULionel Messi''' (''wabelethwa ngoJuni 24, 1987, eRosario, e-Argentina'') ngumdlali webhola owazalelwa e-[[Argentina]] ozuze amarekhodi angu-8 kumaBallon d'Or njengomdlali ohamba phambili emhlabeni (2009–2012, 2015, 2019, 2021, kanye no-2023). Ngo-2022, wasiza i-Argentina ukunqoba iNdebe Yomhlaba yeFédération Internationale de Football Association (FIFA).&lt;ref name=&quot;:0&quot;&gt;Lisi, C., ''[[iarchive:historyofworldcu0000lisi_v7i5|«]]''[[iarchive:historyofworldcu0000lisi_v7i5|History of the World Cup: 1930–2010»]], ''Scarecrow Press'', 2011&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;Balagué, G., [[iarchive:messibiography0000bala|«Messi»]]. ''Orion Books,'' 2013&lt;/ref&gt;&lt;ref name=&quot;:2&quot;&gt;Tomkins, P., «Above Us Only Sky: Liverpool FC's Global Revolution», ''Anchor Print Group'', 2007&lt;/ref&gt;&lt;ref name=&quot;:3&quot;&gt;Hunter, G., «Barça: The Making of the Greatest Team in the World», ''BackPage Press'', 2012&lt;/ref&gt; 

== Ukuphila kwakuqala ==
UMessi waqala ukudlala ibhola liseyinkwenkwezi, kwathi ngo-1995 wajoyina ithimba leNewell’s Old Boys, iqembu lomphakathi elidlala umdlalo omkhulu eRosario. Amakhono akhe angavamile athusa amaqembu adumile ase-Europe kanye neLatin America. Lapho eneminyaka eli-13, uMessi nomndeni wakhe bathutha baya eBarcelona, lapho aqala ukudlalela iqembu labafana abaneminyaka engaphasi kwengu-14 leFC Barcelona. Wahlohla amagoli ali-21 emidlalweni eli-14 eqenjini labancane, kwathi ngokushesha wakhuphukela emaqenjini aphezulu, waze waba nemidlalo yakhe yokuqala engakahloniphi ngokusemthethweni eneminyaka eli-16, edlalela iFC Barcelona emdlalweni wobungani.&lt;ref name=&quot;:1&quot; /&gt;

== Ukudlala kwamaqembu ==
Ngesizini ka-2004–05, uMessi, owayeneminyaka eli-17 ngaleso sikhathi, waba ngumdlali omncane kunabo bonke owake wadlala futhi wahlohla igoli emlandweni weSpanish La Liga, okuwumqhudelwano ophezulu webhola laseSpain. Naphezu kokuba nezinga lama-5 izinyawo eziyisi-7 (1.7 amitha) nokuba nesisindo esingu-148 amakhilogremu (67 kg), wayeqinile, ekulinganiselwe kahle, futhi eguquguquka enkundleni. Engunozwane lwesobunxele ngokwemvelo, ehlakaniphile futhi enembile ekulawuleni ibhola, uMessi wayengumhambisi ophambili wama-pasi futhi ayekwazi ukugqashula ezivikeleni eziminyene. Ngo-2005 wanikezwa ubuzwe baseSpain, okwathathwa ngemizwa ehlukahlukene ngabalandeli beBarcelona abaziqhenyayo ngokuba ngamaCatalan. Ngonyaka olandelayo, uMessi kanye neqembu leBarcelona banqoba isicoco seChampions League, umqhudelwano wamaqembu ase-Europe.&lt;ref name=&quot;:2&quot; /&gt;

Ukudlala kukaMessi kwaqhubeka kuthuthuka ngokushesha eminyakeni edlule, kwathi ngo-2008 waba ngomunye wabadlali abaphambili emhlabeni, eqeda endaweni yesibili emavotini eBallon d'Or ka-2008, enqotshwa nguCristiano Ronaldo weManchester United. Ekuqaleni kuka-2009, uMessi waqedela isizini emangalisayo ka-2008–09 ngokusiza i-FC Barcelona ukuthi ithole i-“treble” yayo yokuqala (ukunqoba izihloko ezintathu ezinkulu zamaqembu ase-Europe ngesizini eyodwa): iqembu lanqoba isicoco seLa Liga, iCopa del Rey (indebe enkulu yasekhaya yaseSpain), kanye nesicoco seChampions League. Kulowo nyaka, uMessi wahlohla amagoli angama-38 emidlalweni engu-51, futhi waxosha uRonaldo emavotini weBallon d'Or kanye nomdlali womhlaba wonyaka weFIFA, enza umlando ngokuhlukana okuningi kwamaphuzu. Ngesizini ka-2009–10, uMessi wahlohla amagoli angu-34 emidlalweni yasekhaya ngesikhathi iBarcelona iphinda inqobe isicoco seLa Liga. Wathola umklomelo weGolden Shoe njengomshayi magoli ohamba phambili e-Europe, futhi waphinde wanikezwa enye iBallon d'Or (eyaziwa njengeFIFA Ballon d'Or phakathi kuka-2010 no-2015).&lt;ref name=&quot;:3&quot; /&gt;
[[Isimumathi:Arda Turan 2016-17 (cropped).jpg|thumb|228x228px|Uphumelele iBallon d'Or izikhathi eziyisishiyagalombili uLionel Messi, Agasti 2016.]]
UMessi wahola i-Barcelona ekunqobeni izihloko zeLa Liga kanye neChampions League ngesizini eyalandela, okusiza wazuza umklomelo wesithathu olandelanayo womdlali womhlaba wonyaka, okuyinto engakaze ibonwe. NgoMbasa 2012, wahlohla igoli lakhe lama-233 le-Barcelona, waba umshayi magoli ophezulu kunabo bonke emlandweni weqembu emidlalweni yeLa Liga eneminyaka engu-24 kuphela. Waqeda isizini ka-2011–12 ye-Barcelona (eyayihlanganisa enye iwini yeCopa del Rey) enamagoli angu-73 kuyo yonke imiqhudelwano, epha isicoco sikaGerd Müller seminyaka engu-39 samagoli esizini eyodwa kwimidlalo eyinhloko ye-European football. Lokhu kusebenza okumangalisayo kwamphoqa ukuthi aqokwe njengomdlali womhlaba wonyaka ka-2012, okumenza waba ngumdlali wokuqala ukuwina isihloko izikhathi ezine. Amagoli akhe angu-46 eLa Liga ngesizini ka-2012–13 aholela kulesi sigaba, futhi iBarcelona yaphinda yathatha isicoco seligi yasekhaya. Ngo-2014, usetha irekhodi lonke leBarcelona ngesikhathi ehlohla igoli lakhe lama-370 njengelungu leqembu. Ngalo nyaka, wephula amarekhodi emisebenzi yokuhlohla kuChampions League (amagoli angu-72) kanye neLa Liga (amagoli angu-253).
[[Isimumathi:Lionel Messi vs Valladolid 3.jpg|thumb|264x264px|ULionel Messi, Disemba 2018.]]
Ngo-2014–15, uMessi wasiza i-Barcelona ukuthi iphinde inqobe i-treble, ehola iqembu ngamaphuzu angu-43 phakathi nesizini, okwamnikeza umklomelo wakhe wesihlanu womdlali womhlaba wonyaka. Ngesizini ka-2015–16, wahlohla amagoli angu-41 kuyo yonke imiqhudelwano ye-Barcelona, futhi iqembu lazuza izicoco zeLa Liga neCopa del Rey. Waphumelela kakhudlwana ngo-2016–17 ngamaphuzu angu-53, eholela iqembu ekunqobeni isicoco seCopa del Rey futhi. Ngo-2017–18, wahlohla amagoli angu-45, kanti i-Barcelona yawina izicoco zeLa Liga neCopa del Rey futhi. Ngo-2018–19, uMessi wahlohla amagoli angu-51 kuyo yonke imiqhudelwano yasekhaya, kwathi i-Barcelona yawina enye isicoco seLa Liga. Ekupheleni kuka-2019, wawina iBallon d'Or yakhe yesithupha futhi waqanjwa njengomdlali ongcono kunabo bonke emhlabeni yiFIFA. Ngesizini ka-2020–21, i-Barcelona yathatha isicoco seCopa del Rey, okuyisikhombisa emsebenzini kaMessi. Waba ngumdlali ozimele ngo-2021, kanti izinkinga zezimali—ezinye zazo ezazihlobene nemithetho yeLa Liga—zamenza wangakwazi ukuqhubeka ne-Barcelona. Wahlala engumholi ohlukile emlandweni, engumshayi magoli ophezulu emlandweni weLa Liga ngamaphuzu angu-474.

Ngemuva kwalokho, ngo-2021 uMessi signed ne-Paris St.-Germain (PSG), lapho ajoyina khona ojonge amathalente amakhulu uKylian Mbappé noNeymar, futhi ngalowo nyaka wathola iBallon d'Or yakhe eyayilandelayo. Wasiza i-PSG ukuthi iwine isicoco seLigue 1 ngesikhathi esingamabili adlala nohlelo. Ngo-2023, uMessi wajoyina i-Inter Miami ye-Major League Soccer.

== Uhambo lwakhe lwezizwe ==
Ngaphandle kokuba nezimvume ezimbili zokuba ngozinze eSpain futhi eseziphumelelayo emsebenzini, uMessi waqhubeka nokuhlala nezibopho ezinzulu ezweni lakubo, futhi waba yilungu elibalulekile kumaqembu kazwelonke ase-Argentina kusukela ngo-2005. Wadlala eqenjini le-Argentina elinqobile kwi-FIFA World Youth Championship yango-2005, wakhumela izwe lakhe kuWorld Cup yango-2006, futhi wabhala amagoli amabili kumidlalo emihlanu lapho i-Argentina yaphumelela ukufinyelela kumaphiko e-golde medal ku-Olympics yaseBeijing ngo-2008. UMessi wasiza i-Argentina ukuba ifinyelele kuma-quarterfinals we-World Cup yango-2010, lapho iqembu lihlulwa yi-Germany, okwenza kube yisikhathi sesibili sokulahlekelwa kuWorld Cup. Ku-World Cup yango-2014, uMessi wenza isibonelo esimangalisayo, wabhala amagoli amane futhi waqhuba i-Argentina, eneqembu elihlushwa yizinkinga zokuhlasela, kwi-stage yeqembu futhi eya kumjikelo wokuphuma, lapho i-Argentina yachitha isikhathi eside ukusuka efinalini ye-World Cup ngomnyaka wesine ngo-24. I-Argentina yenqabela lowo mdlalo ngo-1-0 ne-Germany, kodwa uMessi wathola i-Golden Ball njengomdlali ophumelela kakhulu. Ngesikhathi se-2016 Copa América Centenario, wabhala igoli lakhe le-55 phakathi kwezizwe, ephula irekhodi likaGabriel Batistuta njengomshayi magoli ophumelele kakhulu e-Argentina.&lt;ref name=&quot;:0&quot; /&gt;
[[Isimumathi:ARG Line-up - ARG vs MEX for 2022 FIFA WC.jpg|thumb|271x271px|Umphosa weqembu uLionel Messi kanye namanye amalungu eqembu lesizwe lase-Argentina ku-World Cup yezeMidlalo yabesilisa ka-2022.]]
Emva kokuhlulwa kwe-Argentina kwi-Copa final—okuphikisana nesikhumbuzo sokuqala kwama-final izikhathi ezintathu kumqhudelwano omkhulu—uMessi wathi uzashiya iqembu lesizwe, kodwa &quot;ukuthatha umhlalaphansi&quot; kwakhe okwesikhashana kwahlala izinyanga ezimbili ngaphambi kokubhalela ukubuyela eqenjini. Ku-World Cup yango-2018, wasiza iqembu lase-Argentina elihlangabezana nobunzima ukufinyelela kumjikelo wokuphuma, lapho bachithwa yiFrance, okuyi-team ethole i-championship, emdlalweni wabo wokuqala. Ngemva kokuphothula esikhathini sesithathu e-Copa América yango-2019, uMessi wahola i-Argentina ukuba iwine umqhudelwano eminyakeni emibili kamuva, waphinde wathola i-Golden Ball award.&lt;ref name=&quot;:0&quot; /&gt;

Impumelelo yakhe yaqhubeka kwi-World Cup yango-2022. Lapho, wahola i-Argentina ku-final, lapho ebhala amagoli amabili—futhi wenza umphumela ophumelelayo ngesikhathi sokuphonswa amaphuzu—to ukusiza ukwehlula iFrance. UMessi wathola i-Golden Ball ye-World Cup, waba ngumdlali wesilisa wokuqala ukuthola lesi sikhumbuzo izikhathi ezimbili. Ukwengeza, ukudlala kwakhe okuhle kakhulu kulomqhudelwano kwakubalulekile ekutholeni kwakhe iBallon d'Or yesishiyagalombili ngo-2023.

== Ezinye izenzo kanye nezinkinga zomthetho ==
Ngaphandle komkhakha womdlalo, uMessi wayengomunye wezinkanyezi zomzimba ezinkulu emhlabeni. Ngokuhlangene nemiholo yebhola, eyayivame ukuba nezezakhiwo ezimbili ezinkulu kakhulu zabadlali bezemidlalo bonke, waba ngumkhangisi ophumelelayo wemikhiqizo, ikakhulukazi kwenkampani yezimpahla zezemidlalo i-Adidas. Ngo-2013, uMessi kanye no-ubaba wakhe (ophatha izimali zomfana wakhe) babhekene necala lokugwema intela, behlonipha izinkampani zomphakathi zasephesheya ukuze bagweme ukukhokha u-€4.2 million ezintela zaseSpain kumholo wokukhangisa. Nokho, ngemuva kokukhokha €5 million kuMbuso waseSpain, bobabili bakhishwa ukuba babhekane necala ngo-2016. NgoJulayi walowo nyaka, uMessi no-ubaba wakhe bathola isijeziso sokuhlala ezinyangeni ezimisiwe zomlomo wesigwebo esingaphansi kweminyaka emibili, futhi bathola izijeziso zentela zangu-€2 million no-€1.5 million, ngokulandelana.

== Iinkomba ==

&lt;references /&gt;

== Izixhumanisi zangaphandle ==

* [[File:Commons-logo.svg|link=https://commons.wikimedia.org/wiki/Category:Lionel_Messi?uselang=ty|18x18px]] Wikimedia Commons inayo amadokhumenti wemidiya '''''[[commons:Category:Lionel_Messi|ngoLionel Messi]]'''''.
* [[File:Wikiquote-logo.svg|link=https://en.wikiquote.org/wiki/David_Woodard?uselang=ty|16x16px]] Wikiquote: '''''[[wikiquote:Lionel_Messi|Lionel Messi]]''''' ([[:ty:Reo_Paratāne|en]])
* [[File:Echo_global_icon.svg|link=https://messi.com/|13x13px]] [https://messi.com/ Site officiel]</text>
      <sha1>fmq4u3cdfavudguk3fak2i23h4mcg4d</sha1>
    </revision>
    <revision>
      <id>2093</id>
      <parentid>2092</parentid>
      <timestamp>2024-11-22T00:09:49Z</timestamp>
      <contributor>
        <username>Armurdo</username>
        <id>185</id>
      </contributor>
      <comment>/* Izixhumanisi zangaphandle */</comment>
      <origin>2093</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="11012" sha1="2wamey7jb1tn38k6iqctmaaw8ep4gqf" xml:space="preserve">{{Person|ibizo=ULionel Messi|ubelethwe ngo=Juni 24, 1987|umsebenzi=Umgijimi webhola (soccer)|indawo yo kubelethwa=Rosario, e-Argentina|isithombe=Lionel-Messi-Argentina-2022-FIFA-World-Cup (cropped).jpg}}'''ULionel Messi''' (''wabelethwa ngoJuni 24, 1987, eRosario, e-Argentina'') ngumdlali webhola owazalelwa e-[[Argentina]] ozuze amarekhodi angu-8 kumaBallon d'Or njengomdlali ohamba phambili emhlabeni (2009–2012, 2015, 2019, 2021, kanye no-2023). Ngo-2022, wasiza i-Argentina ukunqoba iNdebe Yomhlaba yeFédération Internationale de Football Association (FIFA).&lt;ref name=&quot;:0&quot;&gt;Lisi, C., ''[[iarchive:historyofworldcu0000lisi_v7i5|«]]''[[iarchive:historyofworldcu0000lisi_v7i5|History of the World Cup: 1930–2010»]], ''Scarecrow Press'', 2011&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;Balagué, G., [[iarchive:messibiography0000bala|«Messi»]]. ''Orion Books,'' 2013&lt;/ref&gt;&lt;ref name=&quot;:2&quot;&gt;Tomkins, P., «Above Us Only Sky: Liverpool FC's Global Revolution», ''Anchor Print Group'', 2007&lt;/ref&gt;&lt;ref name=&quot;:3&quot;&gt;Hunter, G., «Barça: The Making of the Greatest Team in the World», ''BackPage Press'', 2012&lt;/ref&gt; 

== Ukuphila kwakuqala ==
UMessi waqala ukudlala ibhola liseyinkwenkwezi, kwathi ngo-1995 wajoyina ithimba leNewell’s Old Boys, iqembu lomphakathi elidlala umdlalo omkhulu eRosario. Amakhono akhe angavamile athusa amaqembu adumile ase-Europe kanye neLatin America. Lapho eneminyaka eli-13, uMessi nomndeni wakhe bathutha baya eBarcelona, lapho aqala ukudlalela iqembu labafana abaneminyaka engaphasi kwengu-14 leFC Barcelona. Wahlohla amagoli ali-21 emidlalweni eli-14 eqenjini labancane, kwathi ngokushesha wakhuphukela emaqenjini aphezulu, waze waba nemidlalo yakhe yokuqala engakahloniphi ngokusemthethweni eneminyaka eli-16, edlalela iFC Barcelona emdlalweni wobungani.&lt;ref name=&quot;:1&quot; /&gt;

== Ukudlala kwamaqembu ==
Ngesizini ka-2004–05, uMessi, owayeneminyaka eli-17 ngaleso sikhathi, waba ngumdlali omncane kunabo bonke owake wadlala futhi wahlohla igoli emlandweni weSpanish La Liga, okuwumqhudelwano ophezulu webhola laseSpain. Naphezu kokuba nezinga lama-5 izinyawo eziyisi-7 (1.7 amitha) nokuba nesisindo esingu-148 amakhilogremu (67 kg), wayeqinile, ekulinganiselwe kahle, futhi eguquguquka enkundleni. Engunozwane lwesobunxele ngokwemvelo, ehlakaniphile futhi enembile ekulawuleni ibhola, uMessi wayengumhambisi ophambili wama-pasi futhi ayekwazi ukugqashula ezivikeleni eziminyene. Ngo-2005 wanikezwa ubuzwe baseSpain, okwathathwa ngemizwa ehlukahlukene ngabalandeli beBarcelona abaziqhenyayo ngokuba ngamaCatalan. Ngonyaka olandelayo, uMessi kanye neqembu leBarcelona banqoba isicoco seChampions League, umqhudelwano wamaqembu ase-Europe.&lt;ref name=&quot;:2&quot; /&gt;

Ukudlala kukaMessi kwaqhubeka kuthuthuka ngokushesha eminyakeni edlule, kwathi ngo-2008 waba ngomunye wabadlali abaphambili emhlabeni, eqeda endaweni yesibili emavotini eBallon d'Or ka-2008, enqotshwa nguCristiano Ronaldo weManchester United. Ekuqaleni kuka-2009, uMessi waqedela isizini emangalisayo ka-2008–09 ngokusiza i-FC Barcelona ukuthi ithole i-“treble” yayo yokuqala (ukunqoba izihloko ezintathu ezinkulu zamaqembu ase-Europe ngesizini eyodwa): iqembu lanqoba isicoco seLa Liga, iCopa del Rey (indebe enkulu yasekhaya yaseSpain), kanye nesicoco seChampions League. Kulowo nyaka, uMessi wahlohla amagoli angama-38 emidlalweni engu-51, futhi waxosha uRonaldo emavotini weBallon d'Or kanye nomdlali womhlaba wonyaka weFIFA, enza umlando ngokuhlukana okuningi kwamaphuzu. Ngesizini ka-2009–10, uMessi wahlohla amagoli angu-34 emidlalweni yasekhaya ngesikhathi iBarcelona iphinda inqobe isicoco seLa Liga. Wathola umklomelo weGolden Shoe njengomshayi magoli ohamba phambili e-Europe, futhi waphinde wanikezwa enye iBallon d'Or (eyaziwa njengeFIFA Ballon d'Or phakathi kuka-2010 no-2015).&lt;ref name=&quot;:3&quot; /&gt;
[[Isimumathi:Arda Turan 2016-17 (cropped).jpg|thumb|228x228px|Uphumelele iBallon d'Or izikhathi eziyisishiyagalombili uLionel Messi, Agasti 2016.]]
UMessi wahola i-Barcelona ekunqobeni izihloko zeLa Liga kanye neChampions League ngesizini eyalandela, okusiza wazuza umklomelo wesithathu olandelanayo womdlali womhlaba wonyaka, okuyinto engakaze ibonwe. NgoMbasa 2012, wahlohla igoli lakhe lama-233 le-Barcelona, waba umshayi magoli ophezulu kunabo bonke emlandweni weqembu emidlalweni yeLa Liga eneminyaka engu-24 kuphela. Waqeda isizini ka-2011–12 ye-Barcelona (eyayihlanganisa enye iwini yeCopa del Rey) enamagoli angu-73 kuyo yonke imiqhudelwano, epha isicoco sikaGerd Müller seminyaka engu-39 samagoli esizini eyodwa kwimidlalo eyinhloko ye-European football. Lokhu kusebenza okumangalisayo kwamphoqa ukuthi aqokwe njengomdlali womhlaba wonyaka ka-2012, okumenza waba ngumdlali wokuqala ukuwina isihloko izikhathi ezine. Amagoli akhe angu-46 eLa Liga ngesizini ka-2012–13 aholela kulesi sigaba, futhi iBarcelona yaphinda yathatha isicoco seligi yasekhaya. Ngo-2014, usetha irekhodi lonke leBarcelona ngesikhathi ehlohla igoli lakhe lama-370 njengelungu leqembu. Ngalo nyaka, wephula amarekhodi emisebenzi yokuhlohla kuChampions League (amagoli angu-72) kanye neLa Liga (amagoli angu-253).
[[Isimumathi:Lionel Messi vs Valladolid 3.jpg|thumb|264x264px|ULionel Messi, Disemba 2018.]]
Ngo-2014–15, uMessi wasiza i-Barcelona ukuthi iphinde inqobe i-treble, ehola iqembu ngamaphuzu angu-43 phakathi nesizini, okwamnikeza umklomelo wakhe wesihlanu womdlali womhlaba wonyaka. Ngesizini ka-2015–16, wahlohla amagoli angu-41 kuyo yonke imiqhudelwano ye-Barcelona, futhi iqembu lazuza izicoco zeLa Liga neCopa del Rey. Waphumelela kakhudlwana ngo-2016–17 ngamaphuzu angu-53, eholela iqembu ekunqobeni isicoco seCopa del Rey futhi. Ngo-2017–18, wahlohla amagoli angu-45, kanti i-Barcelona yawina izicoco zeLa Liga neCopa del Rey futhi. Ngo-2018–19, uMessi wahlohla amagoli angu-51 kuyo yonke imiqhudelwano yasekhaya, kwathi i-Barcelona yawina enye isicoco seLa Liga. Ekupheleni kuka-2019, wawina iBallon d'Or yakhe yesithupha futhi waqanjwa njengomdlali ongcono kunabo bonke emhlabeni yiFIFA. Ngesizini ka-2020–21, i-Barcelona yathatha isicoco seCopa del Rey, okuyisikhombisa emsebenzini kaMessi. Waba ngumdlali ozimele ngo-2021, kanti izinkinga zezimali—ezinye zazo ezazihlobene nemithetho yeLa Liga—zamenza wangakwazi ukuqhubeka ne-Barcelona. Wahlala engumholi ohlukile emlandweni, engumshayi magoli ophezulu emlandweni weLa Liga ngamaphuzu angu-474.

Ngemuva kwalokho, ngo-2021 uMessi signed ne-Paris St.-Germain (PSG), lapho ajoyina khona ojonge amathalente amakhulu uKylian Mbappé noNeymar, futhi ngalowo nyaka wathola iBallon d'Or yakhe eyayilandelayo. Wasiza i-PSG ukuthi iwine isicoco seLigue 1 ngesikhathi esingamabili adlala nohlelo. Ngo-2023, uMessi wajoyina i-Inter Miami ye-Major League Soccer.

== Uhambo lwakhe lwezizwe ==
Ngaphandle kokuba nezimvume ezimbili zokuba ngozinze eSpain futhi eseziphumelelayo emsebenzini, uMessi waqhubeka nokuhlala nezibopho ezinzulu ezweni lakubo, futhi waba yilungu elibalulekile kumaqembu kazwelonke ase-Argentina kusukela ngo-2005. Wadlala eqenjini le-Argentina elinqobile kwi-FIFA World Youth Championship yango-2005, wakhumela izwe lakhe kuWorld Cup yango-2006, futhi wabhala amagoli amabili kumidlalo emihlanu lapho i-Argentina yaphumelela ukufinyelela kumaphiko e-golde medal ku-Olympics yaseBeijing ngo-2008. UMessi wasiza i-Argentina ukuba ifinyelele kuma-quarterfinals we-World Cup yango-2010, lapho iqembu lihlulwa yi-Germany, okwenza kube yisikhathi sesibili sokulahlekelwa kuWorld Cup. Ku-World Cup yango-2014, uMessi wenza isibonelo esimangalisayo, wabhala amagoli amane futhi waqhuba i-Argentina, eneqembu elihlushwa yizinkinga zokuhlasela, kwi-stage yeqembu futhi eya kumjikelo wokuphuma, lapho i-Argentina yachitha isikhathi eside ukusuka efinalini ye-World Cup ngomnyaka wesine ngo-24. I-Argentina yenqabela lowo mdlalo ngo-1-0 ne-Germany, kodwa uMessi wathola i-Golden Ball njengomdlali ophumelela kakhulu. Ngesikhathi se-2016 Copa América Centenario, wabhala igoli lakhe le-55 phakathi kwezizwe, ephula irekhodi likaGabriel Batistuta njengomshayi magoli ophumelele kakhulu e-Argentina.&lt;ref name=&quot;:0&quot; /&gt;
[[Isimumathi:ARG Line-up - ARG vs MEX for 2022 FIFA WC.jpg|thumb|271x271px|Umphosa weqembu uLionel Messi kanye namanye amalungu eqembu lesizwe lase-Argentina ku-World Cup yezeMidlalo yabesilisa ka-2022.]]
Emva kokuhlulwa kwe-Argentina kwi-Copa final—okuphikisana nesikhumbuzo sokuqala kwama-final izikhathi ezintathu kumqhudelwano omkhulu—uMessi wathi uzashiya iqembu lesizwe, kodwa &quot;ukuthatha umhlalaphansi&quot; kwakhe okwesikhashana kwahlala izinyanga ezimbili ngaphambi kokubhalela ukubuyela eqenjini. Ku-World Cup yango-2018, wasiza iqembu lase-Argentina elihlangabezana nobunzima ukufinyelela kumjikelo wokuphuma, lapho bachithwa yiFrance, okuyi-team ethole i-championship, emdlalweni wabo wokuqala. Ngemva kokuphothula esikhathini sesithathu e-Copa América yango-2019, uMessi wahola i-Argentina ukuba iwine umqhudelwano eminyakeni emibili kamuva, waphinde wathola i-Golden Ball award.&lt;ref name=&quot;:0&quot; /&gt;

Impumelelo yakhe yaqhubeka kwi-World Cup yango-2022. Lapho, wahola i-Argentina ku-final, lapho ebhala amagoli amabili—futhi wenza umphumela ophumelelayo ngesikhathi sokuphonswa amaphuzu—to ukusiza ukwehlula iFrance. UMessi wathola i-Golden Ball ye-World Cup, waba ngumdlali wesilisa wokuqala ukuthola lesi sikhumbuzo izikhathi ezimbili. Ukwengeza, ukudlala kwakhe okuhle kakhulu kulomqhudelwano kwakubalulekile ekutholeni kwakhe iBallon d'Or yesishiyagalombili ngo-2023.

== Ezinye izenzo kanye nezinkinga zomthetho ==
Ngaphandle komkhakha womdlalo, uMessi wayengomunye wezinkanyezi zomzimba ezinkulu emhlabeni. Ngokuhlangene nemiholo yebhola, eyayivame ukuba nezezakhiwo ezimbili ezinkulu kakhulu zabadlali bezemidlalo bonke, waba ngumkhangisi ophumelelayo wemikhiqizo, ikakhulukazi kwenkampani yezimpahla zezemidlalo i-Adidas. Ngo-2013, uMessi kanye no-ubaba wakhe (ophatha izimali zomfana wakhe) babhekene necala lokugwema intela, behlonipha izinkampani zomphakathi zasephesheya ukuze bagweme ukukhokha u-€4.2 million ezintela zaseSpain kumholo wokukhangisa. Nokho, ngemuva kokukhokha €5 million kuMbuso waseSpain, bobabili bakhishwa ukuba babhekane necala ngo-2016. NgoJulayi walowo nyaka, uMessi no-ubaba wakhe bathola isijeziso sokuhlala ezinyangeni ezimisiwe zomlomo wesigwebo esingaphansi kweminyaka emibili, futhi bathola izijeziso zentela zangu-€2 million no-€1.5 million, ngokulandelana.

== Iinkomba ==

&lt;references /&gt;

== Izixhumanisi zangaphandle ==

* [[File:Commons-logo.svg|link=https://commons.wikimedia.org/wiki/Category:Lionel_Messi?uselang=ty|18x18px]] Wikimedia Commons inayo amadokhumenti wemidiya '''''[[commons:Category:Lionel_Messi|ngoLionel Messi]]'''''.
* [[File:Wikiquote-logo.svg|link=https://en.wikiquote.org/wiki/David_Woodard?uselang=ty|16x16px]] Wikiquote: '''''[[wikiquote:Lionel_Messi|Lionel Messi]]''''' ([[:ty:Reo_Paratāne|en]])
* [[File:Echo_global_icon.svg|link=https://messi.com/|13x13px]] [https://messi.com/ Site officiel]
''[https://nr.wikipedia.org/ Abahleli beWikipedia]''</text>
      <sha1>2wamey7jb1tn38k6iqctmaaw8ep4gqf</sha1>
    </revision>
    <revision>
      <id>2094</id>
      <parentid>2093</parentid>
      <timestamp>2024-11-22T00:14:34Z</timestamp>
      <contributor>
        <username>Armurdo</username>
        <id>185</id>
      </contributor>
      <origin>2094</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="11074" sha1="2oiga5txnifduedepwbfk3xx6ribtl9" xml:space="preserve">[[Isimumathi:Symbol support vote.svg|right|frameless|23x23px]]{{Person|ibizo=ULionel Messi|ubelethwe ngo=Juni 24, 1987|umsebenzi=Umgijimi webhola (soccer)|indawo yo kubelethwa=Rosario, e-Argentina|isithombe=Lionel-Messi-Argentina-2022-FIFA-World-Cup (cropped).jpg}}'''ULionel Messi''' (''wabelethwa ngoJuni 24, 1987, eRosario, e-Argentina'') ngumdlali webhola owazalelwa e-[[Argentina]] ozuze amarekhodi angu-8 kumaBallon d'Or njengomdlali ohamba phambili emhlabeni (2009–2012, 2015, 2019, 2021, kanye no-2023). Ngo-2022, wasiza i-Argentina ukunqoba iNdebe Yomhlaba yeFédération Internationale de Football Association (FIFA).&lt;ref name=&quot;:0&quot;&gt;Lisi, C., ''[[iarchive:historyofworldcu0000lisi_v7i5|«]]''[[iarchive:historyofworldcu0000lisi_v7i5|History of the World Cup: 1930–2010»]], ''Scarecrow Press'', 2011&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;Balagué, G., [[iarchive:messibiography0000bala|«Messi»]]. ''Orion Books,'' 2013&lt;/ref&gt;&lt;ref name=&quot;:2&quot;&gt;Tomkins, P., «Above Us Only Sky: Liverpool FC's Global Revolution», ''Anchor Print Group'', 2007&lt;/ref&gt;&lt;ref name=&quot;:3&quot;&gt;Hunter, G., «Barça: The Making of the Greatest Team in the World», ''BackPage Press'', 2012&lt;/ref&gt; 

== Ukuphila kwakuqala ==
UMessi waqala ukudlala ibhola liseyinkwenkwezi, kwathi ngo-1995 wajoyina ithimba leNewell’s Old Boys, iqembu lomphakathi elidlala umdlalo omkhulu eRosario. Amakhono akhe angavamile athusa amaqembu adumile ase-Europe kanye neLatin America. Lapho eneminyaka eli-13, uMessi nomndeni wakhe bathutha baya eBarcelona, lapho aqala ukudlalela iqembu labafana abaneminyaka engaphasi kwengu-14 leFC Barcelona. Wahlohla amagoli ali-21 emidlalweni eli-14 eqenjini labancane, kwathi ngokushesha wakhuphukela emaqenjini aphezulu, waze waba nemidlalo yakhe yokuqala engakahloniphi ngokusemthethweni eneminyaka eli-16, edlalela iFC Barcelona emdlalweni wobungani.&lt;ref name=&quot;:1&quot; /&gt;

== Ukudlala kwamaqembu ==
Ngesizini ka-2004–05, uMessi, owayeneminyaka eli-17 ngaleso sikhathi, waba ngumdlali omncane kunabo bonke owake wadlala futhi wahlohla igoli emlandweni weSpanish La Liga, okuwumqhudelwano ophezulu webhola laseSpain. Naphezu kokuba nezinga lama-5 izinyawo eziyisi-7 (1.7 amitha) nokuba nesisindo esingu-148 amakhilogremu (67 kg), wayeqinile, ekulinganiselwe kahle, futhi eguquguquka enkundleni. Engunozwane lwesobunxele ngokwemvelo, ehlakaniphile futhi enembile ekulawuleni ibhola, uMessi wayengumhambisi ophambili wama-pasi futhi ayekwazi ukugqashula ezivikeleni eziminyene. Ngo-2005 wanikezwa ubuzwe baseSpain, okwathathwa ngemizwa ehlukahlukene ngabalandeli beBarcelona abaziqhenyayo ngokuba ngamaCatalan. Ngonyaka olandelayo, uMessi kanye neqembu leBarcelona banqoba isicoco seChampions League, umqhudelwano wamaqembu ase-Europe.&lt;ref name=&quot;:2&quot; /&gt;

Ukudlala kukaMessi kwaqhubeka kuthuthuka ngokushesha eminyakeni edlule, kwathi ngo-2008 waba ngomunye wabadlali abaphambili emhlabeni, eqeda endaweni yesibili emavotini eBallon d'Or ka-2008, enqotshwa nguCristiano Ronaldo weManchester United. Ekuqaleni kuka-2009, uMessi waqedela isizini emangalisayo ka-2008–09 ngokusiza i-FC Barcelona ukuthi ithole i-“treble” yayo yokuqala (ukunqoba izihloko ezintathu ezinkulu zamaqembu ase-Europe ngesizini eyodwa): iqembu lanqoba isicoco seLa Liga, iCopa del Rey (indebe enkulu yasekhaya yaseSpain), kanye nesicoco seChampions League. Kulowo nyaka, uMessi wahlohla amagoli angama-38 emidlalweni engu-51, futhi waxosha uRonaldo emavotini weBallon d'Or kanye nomdlali womhlaba wonyaka weFIFA, enza umlando ngokuhlukana okuningi kwamaphuzu. Ngesizini ka-2009–10, uMessi wahlohla amagoli angu-34 emidlalweni yasekhaya ngesikhathi iBarcelona iphinda inqobe isicoco seLa Liga. Wathola umklomelo weGolden Shoe njengomshayi magoli ohamba phambili e-Europe, futhi waphinde wanikezwa enye iBallon d'Or (eyaziwa njengeFIFA Ballon d'Or phakathi kuka-2010 no-2015).&lt;ref name=&quot;:3&quot; /&gt;
[[Isimumathi:Arda Turan 2016-17 (cropped).jpg|thumb|228x228px|Uphumelele iBallon d'Or izikhathi eziyisishiyagalombili uLionel Messi, Agasti 2016.]]
UMessi wahola i-Barcelona ekunqobeni izihloko zeLa Liga kanye neChampions League ngesizini eyalandela, okusiza wazuza umklomelo wesithathu olandelanayo womdlali womhlaba wonyaka, okuyinto engakaze ibonwe. NgoMbasa 2012, wahlohla igoli lakhe lama-233 le-Barcelona, waba umshayi magoli ophezulu kunabo bonke emlandweni weqembu emidlalweni yeLa Liga eneminyaka engu-24 kuphela. Waqeda isizini ka-2011–12 ye-Barcelona (eyayihlanganisa enye iwini yeCopa del Rey) enamagoli angu-73 kuyo yonke imiqhudelwano, epha isicoco sikaGerd Müller seminyaka engu-39 samagoli esizini eyodwa kwimidlalo eyinhloko ye-European football. Lokhu kusebenza okumangalisayo kwamphoqa ukuthi aqokwe njengomdlali womhlaba wonyaka ka-2012, okumenza waba ngumdlali wokuqala ukuwina isihloko izikhathi ezine. Amagoli akhe angu-46 eLa Liga ngesizini ka-2012–13 aholela kulesi sigaba, futhi iBarcelona yaphinda yathatha isicoco seligi yasekhaya. Ngo-2014, usetha irekhodi lonke leBarcelona ngesikhathi ehlohla igoli lakhe lama-370 njengelungu leqembu. Ngalo nyaka, wephula amarekhodi emisebenzi yokuhlohla kuChampions League (amagoli angu-72) kanye neLa Liga (amagoli angu-253).
[[Isimumathi:Lionel Messi vs Valladolid 3.jpg|thumb|264x264px|ULionel Messi, Disemba 2018.]]
Ngo-2014–15, uMessi wasiza i-Barcelona ukuthi iphinde inqobe i-treble, ehola iqembu ngamaphuzu angu-43 phakathi nesizini, okwamnikeza umklomelo wakhe wesihlanu womdlali womhlaba wonyaka. Ngesizini ka-2015–16, wahlohla amagoli angu-41 kuyo yonke imiqhudelwano ye-Barcelona, futhi iqembu lazuza izicoco zeLa Liga neCopa del Rey. Waphumelela kakhudlwana ngo-2016–17 ngamaphuzu angu-53, eholela iqembu ekunqobeni isicoco seCopa del Rey futhi. Ngo-2017–18, wahlohla amagoli angu-45, kanti i-Barcelona yawina izicoco zeLa Liga neCopa del Rey futhi. Ngo-2018–19, uMessi wahlohla amagoli angu-51 kuyo yonke imiqhudelwano yasekhaya, kwathi i-Barcelona yawina enye isicoco seLa Liga. Ekupheleni kuka-2019, wawina iBallon d'Or yakhe yesithupha futhi waqanjwa njengomdlali ongcono kunabo bonke emhlabeni yiFIFA. Ngesizini ka-2020–21, i-Barcelona yathatha isicoco seCopa del Rey, okuyisikhombisa emsebenzini kaMessi. Waba ngumdlali ozimele ngo-2021, kanti izinkinga zezimali—ezinye zazo ezazihlobene nemithetho yeLa Liga—zamenza wangakwazi ukuqhubeka ne-Barcelona. Wahlala engumholi ohlukile emlandweni, engumshayi magoli ophezulu emlandweni weLa Liga ngamaphuzu angu-474.

Ngemuva kwalokho, ngo-2021 uMessi signed ne-Paris St.-Germain (PSG), lapho ajoyina khona ojonge amathalente amakhulu uKylian Mbappé noNeymar, futhi ngalowo nyaka wathola iBallon d'Or yakhe eyayilandelayo. Wasiza i-PSG ukuthi iwine isicoco seLigue 1 ngesikhathi esingamabili adlala nohlelo. Ngo-2023, uMessi wajoyina i-Inter Miami ye-Major League Soccer.

== Uhambo lwakhe lwezizwe ==
Ngaphandle kokuba nezimvume ezimbili zokuba ngozinze eSpain futhi eseziphumelelayo emsebenzini, uMessi waqhubeka nokuhlala nezibopho ezinzulu ezweni lakubo, futhi waba yilungu elibalulekile kumaqembu kazwelonke ase-Argentina kusukela ngo-2005. Wadlala eqenjini le-Argentina elinqobile kwi-FIFA World Youth Championship yango-2005, wakhumela izwe lakhe kuWorld Cup yango-2006, futhi wabhala amagoli amabili kumidlalo emihlanu lapho i-Argentina yaphumelela ukufinyelela kumaphiko e-golde medal ku-Olympics yaseBeijing ngo-2008. UMessi wasiza i-Argentina ukuba ifinyelele kuma-quarterfinals we-World Cup yango-2010, lapho iqembu lihlulwa yi-Germany, okwenza kube yisikhathi sesibili sokulahlekelwa kuWorld Cup. Ku-World Cup yango-2014, uMessi wenza isibonelo esimangalisayo, wabhala amagoli amane futhi waqhuba i-Argentina, eneqembu elihlushwa yizinkinga zokuhlasela, kwi-stage yeqembu futhi eya kumjikelo wokuphuma, lapho i-Argentina yachitha isikhathi eside ukusuka efinalini ye-World Cup ngomnyaka wesine ngo-24. I-Argentina yenqabela lowo mdlalo ngo-1-0 ne-Germany, kodwa uMessi wathola i-Golden Ball njengomdlali ophumelela kakhulu. Ngesikhathi se-2016 Copa América Centenario, wabhala igoli lakhe le-55 phakathi kwezizwe, ephula irekhodi likaGabriel Batistuta njengomshayi magoli ophumelele kakhulu e-Argentina.&lt;ref name=&quot;:0&quot; /&gt;
[[Isimumathi:ARG Line-up - ARG vs MEX for 2022 FIFA WC.jpg|thumb|271x271px|Umphosa weqembu uLionel Messi kanye namanye amalungu eqembu lesizwe lase-Argentina ku-World Cup yezeMidlalo yabesilisa ka-2022.]]
Emva kokuhlulwa kwe-Argentina kwi-Copa final—okuphikisana nesikhumbuzo sokuqala kwama-final izikhathi ezintathu kumqhudelwano omkhulu—uMessi wathi uzashiya iqembu lesizwe, kodwa &quot;ukuthatha umhlalaphansi&quot; kwakhe okwesikhashana kwahlala izinyanga ezimbili ngaphambi kokubhalela ukubuyela eqenjini. Ku-World Cup yango-2018, wasiza iqembu lase-Argentina elihlangabezana nobunzima ukufinyelela kumjikelo wokuphuma, lapho bachithwa yiFrance, okuyi-team ethole i-championship, emdlalweni wabo wokuqala. Ngemva kokuphothula esikhathini sesithathu e-Copa América yango-2019, uMessi wahola i-Argentina ukuba iwine umqhudelwano eminyakeni emibili kamuva, waphinde wathola i-Golden Ball award.&lt;ref name=&quot;:0&quot; /&gt;

Impumelelo yakhe yaqhubeka kwi-World Cup yango-2022. Lapho, wahola i-Argentina ku-final, lapho ebhala amagoli amabili—futhi wenza umphumela ophumelelayo ngesikhathi sokuphonswa amaphuzu—to ukusiza ukwehlula iFrance. UMessi wathola i-Golden Ball ye-World Cup, waba ngumdlali wesilisa wokuqala ukuthola lesi sikhumbuzo izikhathi ezimbili. Ukwengeza, ukudlala kwakhe okuhle kakhulu kulomqhudelwano kwakubalulekile ekutholeni kwakhe iBallon d'Or yesishiyagalombili ngo-2023.

== Ezinye izenzo kanye nezinkinga zomthetho ==
Ngaphandle komkhakha womdlalo, uMessi wayengomunye wezinkanyezi zomzimba ezinkulu emhlabeni. Ngokuhlangene nemiholo yebhola, eyayivame ukuba nezezakhiwo ezimbili ezinkulu kakhulu zabadlali bezemidlalo bonke, waba ngumkhangisi ophumelelayo wemikhiqizo, ikakhulukazi kwenkampani yezimpahla zezemidlalo i-Adidas. Ngo-2013, uMessi kanye no-ubaba wakhe (ophatha izimali zomfana wakhe) babhekene necala lokugwema intela, behlonipha izinkampani zomphakathi zasephesheya ukuze bagweme ukukhokha u-€4.2 million ezintela zaseSpain kumholo wokukhangisa. Nokho, ngemuva kokukhokha €5 million kuMbuso waseSpain, bobabili bakhishwa ukuba babhekane necala ngo-2016. NgoJulayi walowo nyaka, uMessi no-ubaba wakhe bathola isijeziso sokuhlala ezinyangeni ezimisiwe zomlomo wesigwebo esingaphansi kweminyaka emibili, futhi bathola izijeziso zentela zangu-€2 million no-€1.5 million, ngokulandelana.

== Iinkomba ==

&lt;references /&gt;

== Izixhumanisi zangaphandle ==

* [[File:Commons-logo.svg|link=https://commons.wikimedia.org/wiki/Category:Lionel_Messi?uselang=ty|18x18px]] Wikimedia Commons inayo amadokhumenti wemidiya '''''[[commons:Category:Lionel_Messi|ngoLionel Messi]]'''''.
* [[File:Wikiquote-logo.svg|link=https://en.wikiquote.org/wiki/David_Woodard?uselang=ty|16x16px]] Wikiquote: '''''[[wikiquote:Lionel_Messi|Lionel Messi]]''''' ([[:ty:Reo_Paratāne|en]])
* [[File:Echo_global_icon.svg|link=https://messi.com/|13x13px]] [https://messi.com/ Site officiel]
''[https://nr.wikipedia.org/ Abahleli beWikipedia]''</text>
      <sha1>2oiga5txnifduedepwbfk3xx6ribtl9</sha1>
    </revision>
    <revision>
      <id>2095</id>
      <parentid>2094</parentid>
      <timestamp>2024-11-22T00:16:06Z</timestamp>
      <contributor>
        <username>Armurdo</username>
        <id>185</id>
      </contributor>
      <comment>/* Izixhumanisi zangaphandle */</comment>
      <origin>2095</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="11084" sha1="syku7hlc8w26lf6lp6v9vfqi4pqdrew" xml:space="preserve">[[Isimumathi:Symbol support vote.svg|right|frameless|23x23px]]{{Person|ibizo=ULionel Messi|ubelethwe ngo=Juni 24, 1987|umsebenzi=Umgijimi webhola (soccer)|indawo yo kubelethwa=Rosario, e-Argentina|isithombe=Lionel-Messi-Argentina-2022-FIFA-World-Cup (cropped).jpg}}'''ULionel Messi''' (''wabelethwa ngoJuni 24, 1987, eRosario, e-Argentina'') ngumdlali webhola owazalelwa e-[[Argentina]] ozuze amarekhodi angu-8 kumaBallon d'Or njengomdlali ohamba phambili emhlabeni (2009–2012, 2015, 2019, 2021, kanye no-2023). Ngo-2022, wasiza i-Argentina ukunqoba iNdebe Yomhlaba yeFédération Internationale de Football Association (FIFA).&lt;ref name=&quot;:0&quot;&gt;Lisi, C., ''[[iarchive:historyofworldcu0000lisi_v7i5|«]]''[[iarchive:historyofworldcu0000lisi_v7i5|History of the World Cup: 1930–2010»]], ''Scarecrow Press'', 2011&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;Balagué, G., [[iarchive:messibiography0000bala|«Messi»]]. ''Orion Books,'' 2013&lt;/ref&gt;&lt;ref name=&quot;:2&quot;&gt;Tomkins, P., «Above Us Only Sky: Liverpool FC's Global Revolution», ''Anchor Print Group'', 2007&lt;/ref&gt;&lt;ref name=&quot;:3&quot;&gt;Hunter, G., «Barça: The Making of the Greatest Team in the World», ''BackPage Press'', 2012&lt;/ref&gt; 

== Ukuphila kwakuqala ==
UMessi waqala ukudlala ibhola liseyinkwenkwezi, kwathi ngo-1995 wajoyina ithimba leNewell’s Old Boys, iqembu lomphakathi elidlala umdlalo omkhulu eRosario. Amakhono akhe angavamile athusa amaqembu adumile ase-Europe kanye neLatin America. Lapho eneminyaka eli-13, uMessi nomndeni wakhe bathutha baya eBarcelona, lapho aqala ukudlalela iqembu labafana abaneminyaka engaphasi kwengu-14 leFC Barcelona. Wahlohla amagoli ali-21 emidlalweni eli-14 eqenjini labancane, kwathi ngokushesha wakhuphukela emaqenjini aphezulu, waze waba nemidlalo yakhe yokuqala engakahloniphi ngokusemthethweni eneminyaka eli-16, edlalela iFC Barcelona emdlalweni wobungani.&lt;ref name=&quot;:1&quot; /&gt;

== Ukudlala kwamaqembu ==
Ngesizini ka-2004–05, uMessi, owayeneminyaka eli-17 ngaleso sikhathi, waba ngumdlali omncane kunabo bonke owake wadlala futhi wahlohla igoli emlandweni weSpanish La Liga, okuwumqhudelwano ophezulu webhola laseSpain. Naphezu kokuba nezinga lama-5 izinyawo eziyisi-7 (1.7 amitha) nokuba nesisindo esingu-148 amakhilogremu (67 kg), wayeqinile, ekulinganiselwe kahle, futhi eguquguquka enkundleni. Engunozwane lwesobunxele ngokwemvelo, ehlakaniphile futhi enembile ekulawuleni ibhola, uMessi wayengumhambisi ophambili wama-pasi futhi ayekwazi ukugqashula ezivikeleni eziminyene. Ngo-2005 wanikezwa ubuzwe baseSpain, okwathathwa ngemizwa ehlukahlukene ngabalandeli beBarcelona abaziqhenyayo ngokuba ngamaCatalan. Ngonyaka olandelayo, uMessi kanye neqembu leBarcelona banqoba isicoco seChampions League, umqhudelwano wamaqembu ase-Europe.&lt;ref name=&quot;:2&quot; /&gt;

Ukudlala kukaMessi kwaqhubeka kuthuthuka ngokushesha eminyakeni edlule, kwathi ngo-2008 waba ngomunye wabadlali abaphambili emhlabeni, eqeda endaweni yesibili emavotini eBallon d'Or ka-2008, enqotshwa nguCristiano Ronaldo weManchester United. Ekuqaleni kuka-2009, uMessi waqedela isizini emangalisayo ka-2008–09 ngokusiza i-FC Barcelona ukuthi ithole i-“treble” yayo yokuqala (ukunqoba izihloko ezintathu ezinkulu zamaqembu ase-Europe ngesizini eyodwa): iqembu lanqoba isicoco seLa Liga, iCopa del Rey (indebe enkulu yasekhaya yaseSpain), kanye nesicoco seChampions League. Kulowo nyaka, uMessi wahlohla amagoli angama-38 emidlalweni engu-51, futhi waxosha uRonaldo emavotini weBallon d'Or kanye nomdlali womhlaba wonyaka weFIFA, enza umlando ngokuhlukana okuningi kwamaphuzu. Ngesizini ka-2009–10, uMessi wahlohla amagoli angu-34 emidlalweni yasekhaya ngesikhathi iBarcelona iphinda inqobe isicoco seLa Liga. Wathola umklomelo weGolden Shoe njengomshayi magoli ohamba phambili e-Europe, futhi waphinde wanikezwa enye iBallon d'Or (eyaziwa njengeFIFA Ballon d'Or phakathi kuka-2010 no-2015).&lt;ref name=&quot;:3&quot; /&gt;
[[Isimumathi:Arda Turan 2016-17 (cropped).jpg|thumb|228x228px|Uphumelele iBallon d'Or izikhathi eziyisishiyagalombili uLionel Messi, Agasti 2016.]]
UMessi wahola i-Barcelona ekunqobeni izihloko zeLa Liga kanye neChampions League ngesizini eyalandela, okusiza wazuza umklomelo wesithathu olandelanayo womdlali womhlaba wonyaka, okuyinto engakaze ibonwe. NgoMbasa 2012, wahlohla igoli lakhe lama-233 le-Barcelona, waba umshayi magoli ophezulu kunabo bonke emlandweni weqembu emidlalweni yeLa Liga eneminyaka engu-24 kuphela. Waqeda isizini ka-2011–12 ye-Barcelona (eyayihlanganisa enye iwini yeCopa del Rey) enamagoli angu-73 kuyo yonke imiqhudelwano, epha isicoco sikaGerd Müller seminyaka engu-39 samagoli esizini eyodwa kwimidlalo eyinhloko ye-European football. Lokhu kusebenza okumangalisayo kwamphoqa ukuthi aqokwe njengomdlali womhlaba wonyaka ka-2012, okumenza waba ngumdlali wokuqala ukuwina isihloko izikhathi ezine. Amagoli akhe angu-46 eLa Liga ngesizini ka-2012–13 aholela kulesi sigaba, futhi iBarcelona yaphinda yathatha isicoco seligi yasekhaya. Ngo-2014, usetha irekhodi lonke leBarcelona ngesikhathi ehlohla igoli lakhe lama-370 njengelungu leqembu. Ngalo nyaka, wephula amarekhodi emisebenzi yokuhlohla kuChampions League (amagoli angu-72) kanye neLa Liga (amagoli angu-253).
[[Isimumathi:Lionel Messi vs Valladolid 3.jpg|thumb|264x264px|ULionel Messi, Disemba 2018.]]
Ngo-2014–15, uMessi wasiza i-Barcelona ukuthi iphinde inqobe i-treble, ehola iqembu ngamaphuzu angu-43 phakathi nesizini, okwamnikeza umklomelo wakhe wesihlanu womdlali womhlaba wonyaka. Ngesizini ka-2015–16, wahlohla amagoli angu-41 kuyo yonke imiqhudelwano ye-Barcelona, futhi iqembu lazuza izicoco zeLa Liga neCopa del Rey. Waphumelela kakhudlwana ngo-2016–17 ngamaphuzu angu-53, eholela iqembu ekunqobeni isicoco seCopa del Rey futhi. Ngo-2017–18, wahlohla amagoli angu-45, kanti i-Barcelona yawina izicoco zeLa Liga neCopa del Rey futhi. Ngo-2018–19, uMessi wahlohla amagoli angu-51 kuyo yonke imiqhudelwano yasekhaya, kwathi i-Barcelona yawina enye isicoco seLa Liga. Ekupheleni kuka-2019, wawina iBallon d'Or yakhe yesithupha futhi waqanjwa njengomdlali ongcono kunabo bonke emhlabeni yiFIFA. Ngesizini ka-2020–21, i-Barcelona yathatha isicoco seCopa del Rey, okuyisikhombisa emsebenzini kaMessi. Waba ngumdlali ozimele ngo-2021, kanti izinkinga zezimali—ezinye zazo ezazihlobene nemithetho yeLa Liga—zamenza wangakwazi ukuqhubeka ne-Barcelona. Wahlala engumholi ohlukile emlandweni, engumshayi magoli ophezulu emlandweni weLa Liga ngamaphuzu angu-474.

Ngemuva kwalokho, ngo-2021 uMessi signed ne-Paris St.-Germain (PSG), lapho ajoyina khona ojonge amathalente amakhulu uKylian Mbappé noNeymar, futhi ngalowo nyaka wathola iBallon d'Or yakhe eyayilandelayo. Wasiza i-PSG ukuthi iwine isicoco seLigue 1 ngesikhathi esingamabili adlala nohlelo. Ngo-2023, uMessi wajoyina i-Inter Miami ye-Major League Soccer.

== Uhambo lwakhe lwezizwe ==
Ngaphandle kokuba nezimvume ezimbili zokuba ngozinze eSpain futhi eseziphumelelayo emsebenzini, uMessi waqhubeka nokuhlala nezibopho ezinzulu ezweni lakubo, futhi waba yilungu elibalulekile kumaqembu kazwelonke ase-Argentina kusukela ngo-2005. Wadlala eqenjini le-Argentina elinqobile kwi-FIFA World Youth Championship yango-2005, wakhumela izwe lakhe kuWorld Cup yango-2006, futhi wabhala amagoli amabili kumidlalo emihlanu lapho i-Argentina yaphumelela ukufinyelela kumaphiko e-golde medal ku-Olympics yaseBeijing ngo-2008. UMessi wasiza i-Argentina ukuba ifinyelele kuma-quarterfinals we-World Cup yango-2010, lapho iqembu lihlulwa yi-Germany, okwenza kube yisikhathi sesibili sokulahlekelwa kuWorld Cup. Ku-World Cup yango-2014, uMessi wenza isibonelo esimangalisayo, wabhala amagoli amane futhi waqhuba i-Argentina, eneqembu elihlushwa yizinkinga zokuhlasela, kwi-stage yeqembu futhi eya kumjikelo wokuphuma, lapho i-Argentina yachitha isikhathi eside ukusuka efinalini ye-World Cup ngomnyaka wesine ngo-24. I-Argentina yenqabela lowo mdlalo ngo-1-0 ne-Germany, kodwa uMessi wathola i-Golden Ball njengomdlali ophumelela kakhulu. Ngesikhathi se-2016 Copa América Centenario, wabhala igoli lakhe le-55 phakathi kwezizwe, ephula irekhodi likaGabriel Batistuta njengomshayi magoli ophumelele kakhulu e-Argentina.&lt;ref name=&quot;:0&quot; /&gt;
[[Isimumathi:ARG Line-up - ARG vs MEX for 2022 FIFA WC.jpg|thumb|271x271px|Umphosa weqembu uLionel Messi kanye namanye amalungu eqembu lesizwe lase-Argentina ku-World Cup yezeMidlalo yabesilisa ka-2022.]]
Emva kokuhlulwa kwe-Argentina kwi-Copa final—okuphikisana nesikhumbuzo sokuqala kwama-final izikhathi ezintathu kumqhudelwano omkhulu—uMessi wathi uzashiya iqembu lesizwe, kodwa &quot;ukuthatha umhlalaphansi&quot; kwakhe okwesikhashana kwahlala izinyanga ezimbili ngaphambi kokubhalela ukubuyela eqenjini. Ku-World Cup yango-2018, wasiza iqembu lase-Argentina elihlangabezana nobunzima ukufinyelela kumjikelo wokuphuma, lapho bachithwa yiFrance, okuyi-team ethole i-championship, emdlalweni wabo wokuqala. Ngemva kokuphothula esikhathini sesithathu e-Copa América yango-2019, uMessi wahola i-Argentina ukuba iwine umqhudelwano eminyakeni emibili kamuva, waphinde wathola i-Golden Ball award.&lt;ref name=&quot;:0&quot; /&gt;

Impumelelo yakhe yaqhubeka kwi-World Cup yango-2022. Lapho, wahola i-Argentina ku-final, lapho ebhala amagoli amabili—futhi wenza umphumela ophumelelayo ngesikhathi sokuphonswa amaphuzu—to ukusiza ukwehlula iFrance. UMessi wathola i-Golden Ball ye-World Cup, waba ngumdlali wesilisa wokuqala ukuthola lesi sikhumbuzo izikhathi ezimbili. Ukwengeza, ukudlala kwakhe okuhle kakhulu kulomqhudelwano kwakubalulekile ekutholeni kwakhe iBallon d'Or yesishiyagalombili ngo-2023.

== Ezinye izenzo kanye nezinkinga zomthetho ==
Ngaphandle komkhakha womdlalo, uMessi wayengomunye wezinkanyezi zomzimba ezinkulu emhlabeni. Ngokuhlangene nemiholo yebhola, eyayivame ukuba nezezakhiwo ezimbili ezinkulu kakhulu zabadlali bezemidlalo bonke, waba ngumkhangisi ophumelelayo wemikhiqizo, ikakhulukazi kwenkampani yezimpahla zezemidlalo i-Adidas. Ngo-2013, uMessi kanye no-ubaba wakhe (ophatha izimali zomfana wakhe) babhekene necala lokugwema intela, behlonipha izinkampani zomphakathi zasephesheya ukuze bagweme ukukhokha u-€4.2 million ezintela zaseSpain kumholo wokukhangisa. Nokho, ngemuva kokukhokha €5 million kuMbuso waseSpain, bobabili bakhishwa ukuba babhekane necala ngo-2016. NgoJulayi walowo nyaka, uMessi no-ubaba wakhe bathola isijeziso sokuhlala ezinyangeni ezimisiwe zomlomo wesigwebo esingaphansi kweminyaka emibili, futhi bathola izijeziso zentela zangu-€2 million no-€1.5 million, ngokulandelana.

== Iinkomba ==

&lt;references /&gt;

== Izixhumanisi zangaphandle ==

* [[File:Commons-logo.svg|link=https://commons.wikimedia.org/wiki/Category:Lionel_Messi?uselang=ty|18x18px]] Wikimedia Commons inayo amadokhumenti wemidiya '''''[[commons:Category:Lionel_Messi|ngoLionel Messi]]'''''.
* [[File:Wikiquote-logo.svg|link=https://en.wikiquote.org/wiki/David_Woodard?uselang=ty|16x16px]] Wikiquote: '''''[[wikiquote:Lionel_Messi|Lionel Messi]]''''' ([[:ty:Reo_Paratāne|en]])
* [[File:Echo_global_icon.svg|link=https://messi.com/|13x13px]] [https://messi.com/ Isiteji Esisemthethweni]
''[https://nr.wikipedia.org/ Abahleli beWikipedia]''</text>
      <sha1>syku7hlc8w26lf6lp6v9vfqi4pqdrew</sha1>
    </revision>
    <revision>
      <id>2102</id>
      <parentid>2095</parentid>
      <timestamp>2024-11-25T09:47:18Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <minor />
      <comment>/* Izixhumanisi zangaphandle */</comment>
      <origin>2102</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="11083" sha1="ab886tvq9fdtlho9ajgli1ibnhz7x5i" xml:space="preserve">[[Isimumathi:Symbol support vote.svg|right|frameless|23x23px]]{{Person|ibizo=ULionel Messi|ubelethwe ngo=Juni 24, 1987|umsebenzi=Umgijimi webhola (soccer)|indawo yo kubelethwa=Rosario, e-Argentina|isithombe=Lionel-Messi-Argentina-2022-FIFA-World-Cup (cropped).jpg}}'''ULionel Messi''' (''wabelethwa ngoJuni 24, 1987, eRosario, e-Argentina'') ngumdlali webhola owazalelwa e-[[Argentina]] ozuze amarekhodi angu-8 kumaBallon d'Or njengomdlali ohamba phambili emhlabeni (2009–2012, 2015, 2019, 2021, kanye no-2023). Ngo-2022, wasiza i-Argentina ukunqoba iNdebe Yomhlaba yeFédération Internationale de Football Association (FIFA).&lt;ref name=&quot;:0&quot;&gt;Lisi, C., ''[[iarchive:historyofworldcu0000lisi_v7i5|«]]''[[iarchive:historyofworldcu0000lisi_v7i5|History of the World Cup: 1930–2010»]], ''Scarecrow Press'', 2011&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;Balagué, G., [[iarchive:messibiography0000bala|«Messi»]]. ''Orion Books,'' 2013&lt;/ref&gt;&lt;ref name=&quot;:2&quot;&gt;Tomkins, P., «Above Us Only Sky: Liverpool FC's Global Revolution», ''Anchor Print Group'', 2007&lt;/ref&gt;&lt;ref name=&quot;:3&quot;&gt;Hunter, G., «Barça: The Making of the Greatest Team in the World», ''BackPage Press'', 2012&lt;/ref&gt; 

== Ukuphila kwakuqala ==
UMessi waqala ukudlala ibhola liseyinkwenkwezi, kwathi ngo-1995 wajoyina ithimba leNewell’s Old Boys, iqembu lomphakathi elidlala umdlalo omkhulu eRosario. Amakhono akhe angavamile athusa amaqembu adumile ase-Europe kanye neLatin America. Lapho eneminyaka eli-13, uMessi nomndeni wakhe bathutha baya eBarcelona, lapho aqala ukudlalela iqembu labafana abaneminyaka engaphasi kwengu-14 leFC Barcelona. Wahlohla amagoli ali-21 emidlalweni eli-14 eqenjini labancane, kwathi ngokushesha wakhuphukela emaqenjini aphezulu, waze waba nemidlalo yakhe yokuqala engakahloniphi ngokusemthethweni eneminyaka eli-16, edlalela iFC Barcelona emdlalweni wobungani.&lt;ref name=&quot;:1&quot; /&gt;

== Ukudlala kwamaqembu ==
Ngesizini ka-2004–05, uMessi, owayeneminyaka eli-17 ngaleso sikhathi, waba ngumdlali omncane kunabo bonke owake wadlala futhi wahlohla igoli emlandweni weSpanish La Liga, okuwumqhudelwano ophezulu webhola laseSpain. Naphezu kokuba nezinga lama-5 izinyawo eziyisi-7 (1.7 amitha) nokuba nesisindo esingu-148 amakhilogremu (67 kg), wayeqinile, ekulinganiselwe kahle, futhi eguquguquka enkundleni. Engunozwane lwesobunxele ngokwemvelo, ehlakaniphile futhi enembile ekulawuleni ibhola, uMessi wayengumhambisi ophambili wama-pasi futhi ayekwazi ukugqashula ezivikeleni eziminyene. Ngo-2005 wanikezwa ubuzwe baseSpain, okwathathwa ngemizwa ehlukahlukene ngabalandeli beBarcelona abaziqhenyayo ngokuba ngamaCatalan. Ngonyaka olandelayo, uMessi kanye neqembu leBarcelona banqoba isicoco seChampions League, umqhudelwano wamaqembu ase-Europe.&lt;ref name=&quot;:2&quot; /&gt;

Ukudlala kukaMessi kwaqhubeka kuthuthuka ngokushesha eminyakeni edlule, kwathi ngo-2008 waba ngomunye wabadlali abaphambili emhlabeni, eqeda endaweni yesibili emavotini eBallon d'Or ka-2008, enqotshwa nguCristiano Ronaldo weManchester United. Ekuqaleni kuka-2009, uMessi waqedela isizini emangalisayo ka-2008–09 ngokusiza i-FC Barcelona ukuthi ithole i-“treble” yayo yokuqala (ukunqoba izihloko ezintathu ezinkulu zamaqembu ase-Europe ngesizini eyodwa): iqembu lanqoba isicoco seLa Liga, iCopa del Rey (indebe enkulu yasekhaya yaseSpain), kanye nesicoco seChampions League. Kulowo nyaka, uMessi wahlohla amagoli angama-38 emidlalweni engu-51, futhi waxosha uRonaldo emavotini weBallon d'Or kanye nomdlali womhlaba wonyaka weFIFA, enza umlando ngokuhlukana okuningi kwamaphuzu. Ngesizini ka-2009–10, uMessi wahlohla amagoli angu-34 emidlalweni yasekhaya ngesikhathi iBarcelona iphinda inqobe isicoco seLa Liga. Wathola umklomelo weGolden Shoe njengomshayi magoli ohamba phambili e-Europe, futhi waphinde wanikezwa enye iBallon d'Or (eyaziwa njengeFIFA Ballon d'Or phakathi kuka-2010 no-2015).&lt;ref name=&quot;:3&quot; /&gt;
[[Isimumathi:Arda Turan 2016-17 (cropped).jpg|thumb|228x228px|Uphumelele iBallon d'Or izikhathi eziyisishiyagalombili uLionel Messi, Agasti 2016.]]
UMessi wahola i-Barcelona ekunqobeni izihloko zeLa Liga kanye neChampions League ngesizini eyalandela, okusiza wazuza umklomelo wesithathu olandelanayo womdlali womhlaba wonyaka, okuyinto engakaze ibonwe. NgoMbasa 2012, wahlohla igoli lakhe lama-233 le-Barcelona, waba umshayi magoli ophezulu kunabo bonke emlandweni weqembu emidlalweni yeLa Liga eneminyaka engu-24 kuphela. Waqeda isizini ka-2011–12 ye-Barcelona (eyayihlanganisa enye iwini yeCopa del Rey) enamagoli angu-73 kuyo yonke imiqhudelwano, epha isicoco sikaGerd Müller seminyaka engu-39 samagoli esizini eyodwa kwimidlalo eyinhloko ye-European football. Lokhu kusebenza okumangalisayo kwamphoqa ukuthi aqokwe njengomdlali womhlaba wonyaka ka-2012, okumenza waba ngumdlali wokuqala ukuwina isihloko izikhathi ezine. Amagoli akhe angu-46 eLa Liga ngesizini ka-2012–13 aholela kulesi sigaba, futhi iBarcelona yaphinda yathatha isicoco seligi yasekhaya. Ngo-2014, usetha irekhodi lonke leBarcelona ngesikhathi ehlohla igoli lakhe lama-370 njengelungu leqembu. Ngalo nyaka, wephula amarekhodi emisebenzi yokuhlohla kuChampions League (amagoli angu-72) kanye neLa Liga (amagoli angu-253).
[[Isimumathi:Lionel Messi vs Valladolid 3.jpg|thumb|264x264px|ULionel Messi, Disemba 2018.]]
Ngo-2014–15, uMessi wasiza i-Barcelona ukuthi iphinde inqobe i-treble, ehola iqembu ngamaphuzu angu-43 phakathi nesizini, okwamnikeza umklomelo wakhe wesihlanu womdlali womhlaba wonyaka. Ngesizini ka-2015–16, wahlohla amagoli angu-41 kuyo yonke imiqhudelwano ye-Barcelona, futhi iqembu lazuza izicoco zeLa Liga neCopa del Rey. Waphumelela kakhudlwana ngo-2016–17 ngamaphuzu angu-53, eholela iqembu ekunqobeni isicoco seCopa del Rey futhi. Ngo-2017–18, wahlohla amagoli angu-45, kanti i-Barcelona yawina izicoco zeLa Liga neCopa del Rey futhi. Ngo-2018–19, uMessi wahlohla amagoli angu-51 kuyo yonke imiqhudelwano yasekhaya, kwathi i-Barcelona yawina enye isicoco seLa Liga. Ekupheleni kuka-2019, wawina iBallon d'Or yakhe yesithupha futhi waqanjwa njengomdlali ongcono kunabo bonke emhlabeni yiFIFA. Ngesizini ka-2020–21, i-Barcelona yathatha isicoco seCopa del Rey, okuyisikhombisa emsebenzini kaMessi. Waba ngumdlali ozimele ngo-2021, kanti izinkinga zezimali—ezinye zazo ezazihlobene nemithetho yeLa Liga—zamenza wangakwazi ukuqhubeka ne-Barcelona. Wahlala engumholi ohlukile emlandweni, engumshayi magoli ophezulu emlandweni weLa Liga ngamaphuzu angu-474.

Ngemuva kwalokho, ngo-2021 uMessi signed ne-Paris St.-Germain (PSG), lapho ajoyina khona ojonge amathalente amakhulu uKylian Mbappé noNeymar, futhi ngalowo nyaka wathola iBallon d'Or yakhe eyayilandelayo. Wasiza i-PSG ukuthi iwine isicoco seLigue 1 ngesikhathi esingamabili adlala nohlelo. Ngo-2023, uMessi wajoyina i-Inter Miami ye-Major League Soccer.

== Uhambo lwakhe lwezizwe ==
Ngaphandle kokuba nezimvume ezimbili zokuba ngozinze eSpain futhi eseziphumelelayo emsebenzini, uMessi waqhubeka nokuhlala nezibopho ezinzulu ezweni lakubo, futhi waba yilungu elibalulekile kumaqembu kazwelonke ase-Argentina kusukela ngo-2005. Wadlala eqenjini le-Argentina elinqobile kwi-FIFA World Youth Championship yango-2005, wakhumela izwe lakhe kuWorld Cup yango-2006, futhi wabhala amagoli amabili kumidlalo emihlanu lapho i-Argentina yaphumelela ukufinyelela kumaphiko e-golde medal ku-Olympics yaseBeijing ngo-2008. UMessi wasiza i-Argentina ukuba ifinyelele kuma-quarterfinals we-World Cup yango-2010, lapho iqembu lihlulwa yi-Germany, okwenza kube yisikhathi sesibili sokulahlekelwa kuWorld Cup. Ku-World Cup yango-2014, uMessi wenza isibonelo esimangalisayo, wabhala amagoli amane futhi waqhuba i-Argentina, eneqembu elihlushwa yizinkinga zokuhlasela, kwi-stage yeqembu futhi eya kumjikelo wokuphuma, lapho i-Argentina yachitha isikhathi eside ukusuka efinalini ye-World Cup ngomnyaka wesine ngo-24. I-Argentina yenqabela lowo mdlalo ngo-1-0 ne-Germany, kodwa uMessi wathola i-Golden Ball njengomdlali ophumelela kakhulu. Ngesikhathi se-2016 Copa América Centenario, wabhala igoli lakhe le-55 phakathi kwezizwe, ephula irekhodi likaGabriel Batistuta njengomshayi magoli ophumelele kakhulu e-Argentina.&lt;ref name=&quot;:0&quot; /&gt;
[[Isimumathi:ARG Line-up - ARG vs MEX for 2022 FIFA WC.jpg|thumb|271x271px|Umphosa weqembu uLionel Messi kanye namanye amalungu eqembu lesizwe lase-Argentina ku-World Cup yezeMidlalo yabesilisa ka-2022.]]
Emva kokuhlulwa kwe-Argentina kwi-Copa final—okuphikisana nesikhumbuzo sokuqala kwama-final izikhathi ezintathu kumqhudelwano omkhulu—uMessi wathi uzashiya iqembu lesizwe, kodwa &quot;ukuthatha umhlalaphansi&quot; kwakhe okwesikhashana kwahlala izinyanga ezimbili ngaphambi kokubhalela ukubuyela eqenjini. Ku-World Cup yango-2018, wasiza iqembu lase-Argentina elihlangabezana nobunzima ukufinyelela kumjikelo wokuphuma, lapho bachithwa yiFrance, okuyi-team ethole i-championship, emdlalweni wabo wokuqala. Ngemva kokuphothula esikhathini sesithathu e-Copa América yango-2019, uMessi wahola i-Argentina ukuba iwine umqhudelwano eminyakeni emibili kamuva, waphinde wathola i-Golden Ball award.&lt;ref name=&quot;:0&quot; /&gt;

Impumelelo yakhe yaqhubeka kwi-World Cup yango-2022. Lapho, wahola i-Argentina ku-final, lapho ebhala amagoli amabili—futhi wenza umphumela ophumelelayo ngesikhathi sokuphonswa amaphuzu—to ukusiza ukwehlula iFrance. UMessi wathola i-Golden Ball ye-World Cup, waba ngumdlali wesilisa wokuqala ukuthola lesi sikhumbuzo izikhathi ezimbili. Ukwengeza, ukudlala kwakhe okuhle kakhulu kulomqhudelwano kwakubalulekile ekutholeni kwakhe iBallon d'Or yesishiyagalombili ngo-2023.

== Ezinye izenzo kanye nezinkinga zomthetho ==
Ngaphandle komkhakha womdlalo, uMessi wayengomunye wezinkanyezi zomzimba ezinkulu emhlabeni. Ngokuhlangene nemiholo yebhola, eyayivame ukuba nezezakhiwo ezimbili ezinkulu kakhulu zabadlali bezemidlalo bonke, waba ngumkhangisi ophumelelayo wemikhiqizo, ikakhulukazi kwenkampani yezimpahla zezemidlalo i-Adidas. Ngo-2013, uMessi kanye no-ubaba wakhe (ophatha izimali zomfana wakhe) babhekene necala lokugwema intela, behlonipha izinkampani zomphakathi zasephesheya ukuze bagweme ukukhokha u-€4.2 million ezintela zaseSpain kumholo wokukhangisa. Nokho, ngemuva kokukhokha €5 million kuMbuso waseSpain, bobabili bakhishwa ukuba babhekane necala ngo-2016. NgoJulayi walowo nyaka, uMessi no-ubaba wakhe bathola isijeziso sokuhlala ezinyangeni ezimisiwe zomlomo wesigwebo esingaphansi kweminyaka emibili, futhi bathola izijeziso zentela zangu-€2 million no-€1.5 million, ngokulandelana.

== Iinkomba ==

&lt;references /&gt;

== Izixhumanisi zangaphandle ==
* [[File:Commons-logo.svg|link=https://commons.wikimedia.org/wiki/Category:Lionel_Messi?uselang=ty|18x18px]] Wikimedia Commons inayo amadokhumenti wemidiya '''''[[commons:Category:Lionel_Messi|ngoLionel Messi]]'''''.
* [[File:Wikiquote-logo.svg|link=https://en.wikiquote.org/wiki/David_Woodard?uselang=ty|16x16px]] Wikiquote: '''''[[wikiquote:Lionel_Messi|Lionel Messi]]''''' ([[:ty:Reo_Paratāne|en]])
* [[File:Echo_global_icon.svg|link=https://messi.com/|13x13px]] [https://messi.com/ Isiteji Esisemthethweni]
''[https://nr.wikipedia.org/ Abahleli beWikipedia]''</text>
      <sha1>ab886tvq9fdtlho9ajgli1ibnhz7x5i</sha1>
    </revision>
    <revision>
      <id>2115</id>
      <parentid>2102</parentid>
      <timestamp>2024-11-25T17:48:54Z</timestamp>
      <contributor>
        <username>Simakahle Moselekatse</username>
        <id>161</id>
      </contributor>
      <comment>/* Iinkomba */</comment>
      <origin>2115</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="11079" sha1="jx7hcp34gldn2gq49zevrz73gi8smlo" xml:space="preserve">[[Isimumathi:Symbol support vote.svg|right|frameless|23x23px]]{{Person|ibizo=ULionel Messi|ubelethwe ngo=Juni 24, 1987|umsebenzi=Umgijimi webhola (soccer)|indawo yo kubelethwa=Rosario, e-Argentina|isithombe=Lionel-Messi-Argentina-2022-FIFA-World-Cup (cropped).jpg}}'''ULionel Messi''' (''wabelethwa ngoJuni 24, 1987, eRosario, e-Argentina'') ngumdlali webhola owazalelwa e-[[Argentina]] ozuze amarekhodi angu-8 kumaBallon d'Or njengomdlali ohamba phambili emhlabeni (2009–2012, 2015, 2019, 2021, kanye no-2023). Ngo-2022, wasiza i-Argentina ukunqoba iNdebe Yomhlaba yeFédération Internationale de Football Association (FIFA).&lt;ref name=&quot;:0&quot;&gt;Lisi, C., ''[[iarchive:historyofworldcu0000lisi_v7i5|«]]''[[iarchive:historyofworldcu0000lisi_v7i5|History of the World Cup: 1930–2010»]], ''Scarecrow Press'', 2011&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;Balagué, G., [[iarchive:messibiography0000bala|«Messi»]]. ''Orion Books,'' 2013&lt;/ref&gt;&lt;ref name=&quot;:2&quot;&gt;Tomkins, P., «Above Us Only Sky: Liverpool FC's Global Revolution», ''Anchor Print Group'', 2007&lt;/ref&gt;&lt;ref name=&quot;:3&quot;&gt;Hunter, G., «Barça: The Making of the Greatest Team in the World», ''BackPage Press'', 2012&lt;/ref&gt; 

== Ukuphila kwakuqala ==
UMessi waqala ukudlala ibhola liseyinkwenkwezi, kwathi ngo-1995 wajoyina ithimba leNewell’s Old Boys, iqembu lomphakathi elidlala umdlalo omkhulu eRosario. Amakhono akhe angavamile athusa amaqembu adumile ase-Europe kanye neLatin America. Lapho eneminyaka eli-13, uMessi nomndeni wakhe bathutha baya eBarcelona, lapho aqala ukudlalela iqembu labafana abaneminyaka engaphasi kwengu-14 leFC Barcelona. Wahlohla amagoli ali-21 emidlalweni eli-14 eqenjini labancane, kwathi ngokushesha wakhuphukela emaqenjini aphezulu, waze waba nemidlalo yakhe yokuqala engakahloniphi ngokusemthethweni eneminyaka eli-16, edlalela iFC Barcelona emdlalweni wobungani.&lt;ref name=&quot;:1&quot; /&gt;

== Ukudlala kwamaqembu ==
Ngesizini ka-2004–05, uMessi, owayeneminyaka eli-17 ngaleso sikhathi, waba ngumdlali omncane kunabo bonke owake wadlala futhi wahlohla igoli emlandweni weSpanish La Liga, okuwumqhudelwano ophezulu webhola laseSpain. Naphezu kokuba nezinga lama-5 izinyawo eziyisi-7 (1.7 amitha) nokuba nesisindo esingu-148 amakhilogremu (67 kg), wayeqinile, ekulinganiselwe kahle, futhi eguquguquka enkundleni. Engunozwane lwesobunxele ngokwemvelo, ehlakaniphile futhi enembile ekulawuleni ibhola, uMessi wayengumhambisi ophambili wama-pasi futhi ayekwazi ukugqashula ezivikeleni eziminyene. Ngo-2005 wanikezwa ubuzwe baseSpain, okwathathwa ngemizwa ehlukahlukene ngabalandeli beBarcelona abaziqhenyayo ngokuba ngamaCatalan. Ngonyaka olandelayo, uMessi kanye neqembu leBarcelona banqoba isicoco seChampions League, umqhudelwano wamaqembu ase-Europe.&lt;ref name=&quot;:2&quot; /&gt;

Ukudlala kukaMessi kwaqhubeka kuthuthuka ngokushesha eminyakeni edlule, kwathi ngo-2008 waba ngomunye wabadlali abaphambili emhlabeni, eqeda endaweni yesibili emavotini eBallon d'Or ka-2008, enqotshwa nguCristiano Ronaldo weManchester United. Ekuqaleni kuka-2009, uMessi waqedela isizini emangalisayo ka-2008–09 ngokusiza i-FC Barcelona ukuthi ithole i-“treble” yayo yokuqala (ukunqoba izihloko ezintathu ezinkulu zamaqembu ase-Europe ngesizini eyodwa): iqembu lanqoba isicoco seLa Liga, iCopa del Rey (indebe enkulu yasekhaya yaseSpain), kanye nesicoco seChampions League. Kulowo nyaka, uMessi wahlohla amagoli angama-38 emidlalweni engu-51, futhi waxosha uRonaldo emavotini weBallon d'Or kanye nomdlali womhlaba wonyaka weFIFA, enza umlando ngokuhlukana okuningi kwamaphuzu. Ngesizini ka-2009–10, uMessi wahlohla amagoli angu-34 emidlalweni yasekhaya ngesikhathi iBarcelona iphinda inqobe isicoco seLa Liga. Wathola umklomelo weGolden Shoe njengomshayi magoli ohamba phambili e-Europe, futhi waphinde wanikezwa enye iBallon d'Or (eyaziwa njengeFIFA Ballon d'Or phakathi kuka-2010 no-2015).&lt;ref name=&quot;:3&quot; /&gt;
[[Isimumathi:Arda Turan 2016-17 (cropped).jpg|thumb|228x228px|Uphumelele iBallon d'Or izikhathi eziyisishiyagalombili uLionel Messi, Agasti 2016.]]
UMessi wahola i-Barcelona ekunqobeni izihloko zeLa Liga kanye neChampions League ngesizini eyalandela, okusiza wazuza umklomelo wesithathu olandelanayo womdlali womhlaba wonyaka, okuyinto engakaze ibonwe. NgoMbasa 2012, wahlohla igoli lakhe lama-233 le-Barcelona, waba umshayi magoli ophezulu kunabo bonke emlandweni weqembu emidlalweni yeLa Liga eneminyaka engu-24 kuphela. Waqeda isizini ka-2011–12 ye-Barcelona (eyayihlanganisa enye iwini yeCopa del Rey) enamagoli angu-73 kuyo yonke imiqhudelwano, epha isicoco sikaGerd Müller seminyaka engu-39 samagoli esizini eyodwa kwimidlalo eyinhloko ye-European football. Lokhu kusebenza okumangalisayo kwamphoqa ukuthi aqokwe njengomdlali womhlaba wonyaka ka-2012, okumenza waba ngumdlali wokuqala ukuwina isihloko izikhathi ezine. Amagoli akhe angu-46 eLa Liga ngesizini ka-2012–13 aholela kulesi sigaba, futhi iBarcelona yaphinda yathatha isicoco seligi yasekhaya. Ngo-2014, usetha irekhodi lonke leBarcelona ngesikhathi ehlohla igoli lakhe lama-370 njengelungu leqembu. Ngalo nyaka, wephula amarekhodi emisebenzi yokuhlohla kuChampions League (amagoli angu-72) kanye neLa Liga (amagoli angu-253).
[[Isimumathi:Lionel Messi vs Valladolid 3.jpg|thumb|264x264px|ULionel Messi, Disemba 2018.]]
Ngo-2014–15, uMessi wasiza i-Barcelona ukuthi iphinde inqobe i-treble, ehola iqembu ngamaphuzu angu-43 phakathi nesizini, okwamnikeza umklomelo wakhe wesihlanu womdlali womhlaba wonyaka. Ngesizini ka-2015–16, wahlohla amagoli angu-41 kuyo yonke imiqhudelwano ye-Barcelona, futhi iqembu lazuza izicoco zeLa Liga neCopa del Rey. Waphumelela kakhudlwana ngo-2016–17 ngamaphuzu angu-53, eholela iqembu ekunqobeni isicoco seCopa del Rey futhi. Ngo-2017–18, wahlohla amagoli angu-45, kanti i-Barcelona yawina izicoco zeLa Liga neCopa del Rey futhi. Ngo-2018–19, uMessi wahlohla amagoli angu-51 kuyo yonke imiqhudelwano yasekhaya, kwathi i-Barcelona yawina enye isicoco seLa Liga. Ekupheleni kuka-2019, wawina iBallon d'Or yakhe yesithupha futhi waqanjwa njengomdlali ongcono kunabo bonke emhlabeni yiFIFA. Ngesizini ka-2020–21, i-Barcelona yathatha isicoco seCopa del Rey, okuyisikhombisa emsebenzini kaMessi. Waba ngumdlali ozimele ngo-2021, kanti izinkinga zezimali—ezinye zazo ezazihlobene nemithetho yeLa Liga—zamenza wangakwazi ukuqhubeka ne-Barcelona. Wahlala engumholi ohlukile emlandweni, engumshayi magoli ophezulu emlandweni weLa Liga ngamaphuzu angu-474.

Ngemuva kwalokho, ngo-2021 uMessi signed ne-Paris St.-Germain (PSG), lapho ajoyina khona ojonge amathalente amakhulu uKylian Mbappé noNeymar, futhi ngalowo nyaka wathola iBallon d'Or yakhe eyayilandelayo. Wasiza i-PSG ukuthi iwine isicoco seLigue 1 ngesikhathi esingamabili adlala nohlelo. Ngo-2023, uMessi wajoyina i-Inter Miami ye-Major League Soccer.

== Uhambo lwakhe lwezizwe ==
Ngaphandle kokuba nezimvume ezimbili zokuba ngozinze eSpain futhi eseziphumelelayo emsebenzini, uMessi waqhubeka nokuhlala nezibopho ezinzulu ezweni lakubo, futhi waba yilungu elibalulekile kumaqembu kazwelonke ase-Argentina kusukela ngo-2005. Wadlala eqenjini le-Argentina elinqobile kwi-FIFA World Youth Championship yango-2005, wakhumela izwe lakhe kuWorld Cup yango-2006, futhi wabhala amagoli amabili kumidlalo emihlanu lapho i-Argentina yaphumelela ukufinyelela kumaphiko e-golde medal ku-Olympics yaseBeijing ngo-2008. UMessi wasiza i-Argentina ukuba ifinyelele kuma-quarterfinals we-World Cup yango-2010, lapho iqembu lihlulwa yi-Germany, okwenza kube yisikhathi sesibili sokulahlekelwa kuWorld Cup. Ku-World Cup yango-2014, uMessi wenza isibonelo esimangalisayo, wabhala amagoli amane futhi waqhuba i-Argentina, eneqembu elihlushwa yizinkinga zokuhlasela, kwi-stage yeqembu futhi eya kumjikelo wokuphuma, lapho i-Argentina yachitha isikhathi eside ukusuka efinalini ye-World Cup ngomnyaka wesine ngo-24. I-Argentina yenqabela lowo mdlalo ngo-1-0 ne-Germany, kodwa uMessi wathola i-Golden Ball njengomdlali ophumelela kakhulu. Ngesikhathi se-2016 Copa América Centenario, wabhala igoli lakhe le-55 phakathi kwezizwe, ephula irekhodi likaGabriel Batistuta njengomshayi magoli ophumelele kakhulu e-Argentina.&lt;ref name=&quot;:0&quot; /&gt;
[[Isimumathi:ARG Line-up - ARG vs MEX for 2022 FIFA WC.jpg|thumb|271x271px|Umphosa weqembu uLionel Messi kanye namanye amalungu eqembu lesizwe lase-Argentina ku-World Cup yezeMidlalo yabesilisa ka-2022.]]
Emva kokuhlulwa kwe-Argentina kwi-Copa final—okuphikisana nesikhumbuzo sokuqala kwama-final izikhathi ezintathu kumqhudelwano omkhulu—uMessi wathi uzashiya iqembu lesizwe, kodwa &quot;ukuthatha umhlalaphansi&quot; kwakhe okwesikhashana kwahlala izinyanga ezimbili ngaphambi kokubhalela ukubuyela eqenjini. Ku-World Cup yango-2018, wasiza iqembu lase-Argentina elihlangabezana nobunzima ukufinyelela kumjikelo wokuphuma, lapho bachithwa yiFrance, okuyi-team ethole i-championship, emdlalweni wabo wokuqala. Ngemva kokuphothula esikhathini sesithathu e-Copa América yango-2019, uMessi wahola i-Argentina ukuba iwine umqhudelwano eminyakeni emibili kamuva, waphinde wathola i-Golden Ball award.&lt;ref name=&quot;:0&quot; /&gt;

Impumelelo yakhe yaqhubeka kwi-World Cup yango-2022. Lapho, wahola i-Argentina ku-final, lapho ebhala amagoli amabili—futhi wenza umphumela ophumelelayo ngesikhathi sokuphonswa amaphuzu—to ukusiza ukwehlula iFrance. UMessi wathola i-Golden Ball ye-World Cup, waba ngumdlali wesilisa wokuqala ukuthola lesi sikhumbuzo izikhathi ezimbili. Ukwengeza, ukudlala kwakhe okuhle kakhulu kulomqhudelwano kwakubalulekile ekutholeni kwakhe iBallon d'Or yesishiyagalombili ngo-2023.

== Ezinye izenzo kanye nezinkinga zomthetho ==
Ngaphandle komkhakha womdlalo, uMessi wayengomunye wezinkanyezi zomzimba ezinkulu emhlabeni. Ngokuhlangene nemiholo yebhola, eyayivame ukuba nezezakhiwo ezimbili ezinkulu kakhulu zabadlali bezemidlalo bonke, waba ngumkhangisi ophumelelayo wemikhiqizo, ikakhulukazi kwenkampani yezimpahla zezemidlalo i-Adidas. Ngo-2013, uMessi kanye no-ubaba wakhe (ophatha izimali zomfana wakhe) babhekene necala lokugwema intela, behlonipha izinkampani zomphakathi zasephesheya ukuze bagweme ukukhokha u-€4.2 million ezintela zaseSpain kumholo wokukhangisa. Nokho, ngemuva kokukhokha €5 million kuMbuso waseSpain, bobabili bakhishwa ukuba babhekane necala ngo-2016. NgoJulayi walowo nyaka, uMessi no-ubaba wakhe bathola isijeziso sokuhlala ezinyangeni ezimisiwe zomlomo wesigwebo esingaphansi kweminyaka emibili, futhi bathola izijeziso zentela zangu-€2 million no-€1.5 million, ngokulandelana.

== Iinkomba ==
{{Reflist}}

== Izixhumanisi zangaphandle ==
* [[File:Commons-logo.svg|link=https://commons.wikimedia.org/wiki/Category:Lionel_Messi?uselang=ty|18x18px]] Wikimedia Commons inayo amadokhumenti wemidiya '''''[[commons:Category:Lionel_Messi|ngoLionel Messi]]'''''.
* [[File:Wikiquote-logo.svg|link=https://en.wikiquote.org/wiki/David_Woodard?uselang=ty|16x16px]] Wikiquote: '''''[[wikiquote:Lionel_Messi|Lionel Messi]]''''' ([[:ty:Reo_Paratāne|en]])
* [[File:Echo_global_icon.svg|link=https://messi.com/|13x13px]] [https://messi.com/ Isiteji Esisemthethweni]
''[https://nr.wikipedia.org/ Abahleli beWikipedia]''</text>
      <sha1>jx7hcp34gldn2gq49zevrz73gi8smlo</sha1>
    </revision>
    <revision>
      <id>2670</id>
      <parentid>2115</parentid>
      <timestamp>2025-04-19T18:38:42Z</timestamp>
      <contributor>
        <ip>197.103.129.107</ip>
      </contributor>
      <comment>spelling</comment>
      <origin>2670</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="11030" sha1="b50lx0wyg3eicxhnqqb9ykakt3ogf3v" xml:space="preserve">[[Isimumathi:Symbol support vote.svg|right|frameless|23x23px]]{{Person|ibizo=ULionel Messi|ubelethwe ngo=Juni 24, 1987|umsebenzi=Umgijimi webhola (soccer)|indawo yo kubelethwa=Rosario, e-Argentina|isithombe=Lionel-Messi-Argentina-2022-FIFA-World-Cup (cropped).jpg}}'''ULionel Messi''' (''wabelethwa ngoJuni 24, 1987, eRosario, e-Argentina'') ngumdlali webhola owazalelwa e-[[Argentina]] ozuze amarekhodi angu-8 kumaBallon d'Or njengomdlali ohamba phambili emhlabeni. Ngo-2022, wasiza i-Argentina ukunqoba iNdebe Yomhlaba yeFédération Internationale de Football Association (FIFA).&lt;ref name=&quot;:0&quot;&gt;Lisi, C., ''[[iarchive:historyofworldcu0000lisi_v7i5|«]]''[[iarchive:historyofworldcu0000lisi_v7i5|History of the World Cup: 1930–2010»]], ''Scarecrow Press'', 2011&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;Balagué, G., [[iarchive:messibiography0000bala|«Messi»]]. ''Orion Books,'' 2013&lt;/ref&gt;&lt;ref name=&quot;:2&quot;&gt;Tomkins, P., «Above Us Only Sky: Liverpool FC's Global Revolution», ''Anchor Print Group'', 2007&lt;/ref&gt;&lt;ref name=&quot;:3&quot;&gt;Hunter, G., «Barça: The Making of the Greatest Team in the World», ''BackPage Press'', 2012&lt;/ref&gt; 

== Ukuphila kwakuqala ==
UMessi waqala ukudlala ibhola esengumfanyana, kwathi ngo-1995 wajoyina ithimba leNewell’s Old Boys, iqembu lomphakathi elidlala umdlalo omkhulu eRosario. Amakhono akhe angavamile athusa amaqembu adumile ase-Europe kanye neLatin America. Lapho eneminyaka eli-13, uMessi nomndeni wakhe bathutha baya eBarcelona, lapho aqala ukudlalela iqembu labafana abaneminyaka engaphasi kwengu-14 leFC Barcelona. Wahlohla amagoli ayi-21 emidlalweni eyi-14 eqenjini labancane, kwathi ngokushesha wakhuphukela emaqenjini aphezulu, waze waba nemidlalo yakhe yokuqala engakahloniphi ngokusemthethweni eneminyaka eyi-16, edlalela iFC Barcelona emdlalweni wobungani.&lt;ref name=&quot;:1&quot; /&gt;

== Ukudlala kwamaqembu ==
Ngesizini ka-2004–05, uMessi, wayeneminyaka eyi-17 ngaleso sikhathi, waba ngumdlali omncane kunabo bonke obakhe badlala futhi wahlohla igoli emlandweni weSpanish La Liga, okuwumqhudelwano ophezulu webhola laseSpain. Naphezu kokuba nezinga lama-5 izinyawo eziyisi-7 (1.7 amitha) nokuba nesisindo esingu-148 amakhilogremu (67 kg), wayeqinile, ekulinganiselwe kahle, futhi eguquguquka enkundleni. Engunozwane lwesobunxele ngokwemvelo, ehlakaniphile futhi enembile ekulawuleni ibhola, uMessi wayengumhambisi ophambili wama-pasi futhi ayekwazi ukugqashula ezivikeleni eziminyene. Ngo-2005 wanikezwa ubuzwe baseSpain, okwathathwa ngemizwa ehlukahlukene ngabalandeli beBarcelona abaziqhenyayo ngokuba ngamaCatalan. Ngonyaka olandelayo, uMessi kanye neqembu leBarcelona banqoba isicoco seChampions League, umqhudelwano wamaqembu ase-Europe.&lt;ref name=&quot;:2&quot; /&gt;

Ukudlala kukaMessi kwaqhubeka kuthuthuka ngokushesha eminyakeni edlule, kwathi ngo-2008 waba ngomunye wabadlali abaphambili emhlabeni, eqeda endaweni yesibili emavotini eBallon d'Or ka-2008, enqotshwa nguCristiano Ronaldo weManchester United. Ekuqaleni kuka-2009, uMessi waqedela isizini emangalisayo ka-2008–09 ngokusiza i-FC Barcelona ukuthi ithole i-“treble” yayo yokuqala (ukunqoba izihloko ezintathu ezinkulu zamaqembu ase-Europe ngesizini eyodwa): iqembu lanqoba isicoco seLa Liga, iCopa del Rey (indebe enkulu yasekhaya yaseSpain), kanye nesicoco seChampions League. Kulowo nyaka, uMessi wahlohla amagoli angama-38 emidlalweni engu-51, futhi waxosha uRonaldo emavotini weBallon d'Or kanye nomdlali womhlaba wonyaka weFIFA, enza umlando ngokuhlukana okuningi kwamaphuzu. Ngesizini ka-2009–10, uMessi wahlohla amagoli angu-34 emidlalweni yasekhaya ngesikhathi iBarcelona iphinda inqobe isicoco seLa Liga. Wathola umklomelo weGolden Shoe njengomshayi magoli ohamba phambili e-Europe, futhi waphinde wanikezwa enye iBallon d'Or (eyaziwa njengeFIFA Ballon d'Or phakathi kuka-2010 no-2015).&lt;ref name=&quot;:3&quot; /&gt;
[[Isimumathi:Arda Turan 2016-17 (cropped).jpg|thumb|228x228px|Uphumelele iBallon d'Or izikhathi eziyisishiyagalombili uLionel Messi, Agasti 2016.]]
UMessi wahola i-Barcelona ekunqobeni izihloko zeLa Liga kanye neChampions League ngesizini eyalandela, okusiza wazuza umklomelo wesithathu olandelanayo womdlali womhlaba wonyaka, okuyinto engakaze ibonwe. NgoMbasa 2012, wahlohla igoli lakhe lama-233 le-Barcelona, waba umshayi magoli ophezulu kunabo bonke emlandweni weqembu emidlalweni yeLa Liga eneminyaka engu-24 kuphela. Waqeda isizini ka-2011–12 ye-Barcelona (eyayihlanganisa enye iwini yeCopa del Rey) enamagoli angu-73 kuyo yonke imiqhudelwano, epha isicoco sikaGerd Müller seminyaka engu-39 samagoli esizini eyodwa kwimidlalo eyinhloko ye-European football. Lokhu kusebenza okumangalisayo kwamphoqa ukuthi aqokwe njengomdlali womhlaba wonyaka ka-2012, okumenza waba ngumdlali wokuqala ukuwina isihloko izikhathi ezine. Amagoli akhe angu-46 eLa Liga ngesizini ka-2012–13 aholela kulesi sigaba, futhi iBarcelona yaphinda yathatha isicoco seligi yasekhaya. Ngo-2014, usetha irekhodi lonke leBarcelona ngesikhathi ehlohla igoli lakhe lama-370 njengelungu leqembu. Ngalo nyaka, wephula amarekhodi emisebenzi yokuhlohla kuChampions League (amagoli angu-72) kanye neLa Liga (amagoli angu-253).
[[Isimumathi:Lionel Messi vs Valladolid 3.jpg|thumb|264x264px|ULionel Messi, Disemba 2018.]]
Ngo-2014–15, uMessi wasiza i-Barcelona ukuthi iphinde inqobe i-treble, ehola iqembu ngamaphuzu angu-43 phakathi nesizini, okwamnikeza umklomelo wakhe wesihlanu womdlali womhlaba wonyaka. Ngesizini ka-2015–16, wahlohla amagoli angu-41 kuyo yonke imiqhudelwano ye-Barcelona, futhi iqembu lazuza izicoco zeLa Liga neCopa del Rey. Waphumelela kakhudlwana ngo-2016–17 ngamaphuzu angu-53, eholela iqembu ekunqobeni isicoco seCopa del Rey futhi. Ngo-2017–18, wahlohla amagoli angu-45, kanti i-Barcelona yawina izicoco zeLa Liga neCopa del Rey futhi. Ngo-2018–19, uMessi wahlohla amagoli angu-51 kuyo yonke imiqhudelwano yasekhaya, kwathi i-Barcelona yawina enye isicoco seLa Liga. Ekupheleni kuka-2019, wawina iBallon d'Or yakhe yesithupha futhi waqanjwa njengomdlali ongcono kunabo bonke emhlabeni yiFIFA. Ngesizini ka-2020–21, i-Barcelona yathatha isicoco seCopa del Rey, okuyisikhombisa emsebenzini kaMessi. Waba ngumdlali ozimele ngo-2021, kanti izinkinga zezimali—ezinye zazo ezazihlobene nemithetho yeLa Liga—zamenza wangakwazi ukuqhubeka ne-Barcelona. Wahlala engumholi ohlukile emlandweni, engumshayi magoli ophezulu emlandweni weLa Liga ngamaphuzu angu-474.

Ngemuva kwalokho, ngo-2021 uMessi signed ne-Paris St.-Germain (PSG), lapho ajoyina khona ojonge amathalente amakhulu uKylian Mbappé noNeymar, futhi ngalowo nyaka wathola iBallon d'Or yakhe eyayilandelayo. Wasiza i-PSG ukuthi iwine isicoco seLigue 1 ngesikhathi esingamabili adlala nohlelo. Ngo-2023, uMessi wajoyina i-Inter Miami ye-Major League Soccer.

== Uhambo lwakhe lwezizwe ==
Ngaphandle kokuba nezimvume ezimbili zokuba ngozinze eSpain futhi eseziphumelelayo emsebenzini, uMessi waqhubeka nokuhlala nezibopho ezinzulu ezweni lakubo, futhi waba yilungu elibalulekile kumaqembu kazwelonke ase-Argentina kusukela ngo-2005. Wadlala eqenjini le-Argentina elinqobile kwi-FIFA World Youth Championship yango-2005, wakhumela izwe lakhe kuWorld Cup yango-2006, futhi wabhala amagoli amabili kumidlalo emihlanu lapho i-Argentina yaphumelela ukufinyelela kumaphiko e-golde medal ku-Olympics yaseBeijing ngo-2008. UMessi wasiza i-Argentina ukuba ifinyelele kuma-quarterfinals we-World Cup yango-2010, lapho iqembu lihlulwa yi-Germany, okwenza kube yisikhathi sesibili sokulahlekelwa kuWorld Cup. Ku-World Cup yango-2014, uMessi wenza isibonelo esimangalisayo, wabhala amagoli amane futhi waqhuba i-Argentina, eneqembu elihlushwa yizinkinga zokuhlasela, kwi-stage yeqembu futhi eya kumjikelo wokuphuma, lapho i-Argentina yachitha isikhathi eside ukusuka efinalini ye-World Cup ngomnyaka wesine ngo-24. I-Argentina yenqabela lowo mdlalo ngo-1-0 ne-Germany, kodwa uMessi wathola i-Golden Ball njengomdlali ophumelela kakhulu. Ngesikhathi se-2016 Copa América Centenario, wabhala igoli lakhe le-55 phakathi kwezizwe, ephula irekhodi likaGabriel Batistuta njengomshayi magoli ophumelele kakhulu e-Argentina.&lt;ref name=&quot;:0&quot; /&gt;
[[Isimumathi:ARG Line-up - ARG vs MEX for 2022 FIFA WC.jpg|thumb|271x271px|Umphosa weqembu uLionel Messi kanye namanye amalungu eqembu lesizwe lase-Argentina ku-World Cup yezeMidlalo yabesilisa ka-2022.]]
Emva kokuhlulwa kwe-Argentina kwi-Copa final—okuphikisana nesikhumbuzo sokuqala kwama-final izikhathi ezintathu kumqhudelwano omkhulu—uMessi wathi uzashiya iqembu lesizwe, kodwa &quot;ukuthatha umhlalaphansi&quot; kwakhe okwesikhashana kwahlala izinyanga ezimbili ngaphambi kokubhalela ukubuyela eqenjini. Ku-World Cup yango-2018, wasiza iqembu lase-Argentina elihlangabezana nobunzima ukufinyelela kumjikelo wokuphuma, lapho bachithwa yiFrance, okuyi-team ethole i-championship, emdlalweni wabo wokuqala. Ngemva kokuphothula esikhathini sesithathu e-Copa América yango-2019, uMessi wahola i-Argentina ukuba iwine umqhudelwano eminyakeni emibili kamuva, waphinde wathola i-Golden Ball award.&lt;ref name=&quot;:0&quot; /&gt;

Impumelelo yakhe yaqhubeka kwi-World Cup yango-2022. Lapho, wahola i-Argentina ku-final, lapho ebhala amagoli amabili—futhi wenza umphumela ophumelelayo ngesikhathi sokuphonswa amaphuzu—to ukusiza ukwehlula iFrance. UMessi wathola i-Golden Ball ye-World Cup, waba ngumdlali wesilisa wokuqala ukuthola lesi sikhumbuzo izikhathi ezimbili. Ukwengeza, ukudlala kwakhe okuhle kakhulu kulomqhudelwano kwakubalulekile ekutholeni kwakhe iBallon d'Or yesishiyagalombili ngo-2023.

== Ezinye izenzo kanye nezinkinga zomthetho ==
Ngaphandle komkhakha womdlalo, uMessi wayengomunye wezinkanyezi zomzimba ezinkulu emhlabeni. Ngokuhlangene nemiholo yebhola, eyayivame ukuba nezezakhiwo ezimbili ezinkulu kakhulu zabadlali bezemidlalo bonke, waba ngumkhangisi ophumelelayo wemikhiqizo, ikakhulukazi kwenkampani yezimpahla zezemidlalo i-Adidas. Ngo-2013, uMessi kanye no-ubaba wakhe (ophatha izimali zomfana wakhe) babhekene necala lokugwema intela, behlonipha izinkampani zomphakathi zasephesheya ukuze bagweme ukukhokha u-€4.2 million ezintela zaseSpain kumholo wokukhangisa. Nokho, ngemuva kokukhokha €5 million kuMbuso waseSpain, bobabili bakhishwa ukuba babhekane necala ngo-2016. NgoJulayi walowo nyaka, uMessi no-ubaba wakhe bathola isijeziso sokuhlala ezinyangeni ezimisiwe zomlomo wesigwebo esingaphansi kweminyaka emibili, futhi bathola izijeziso zentela zangu-€2 million no-€1.5 million, ngokulandelana.

== Iinkomba ==
{{Reflist}}

== Izixhumanisi zangaphandle ==
* [[File:Commons-logo.svg|link=https://commons.wikimedia.org/wiki/Category:Lionel_Messi?uselang=ty|18x18px]] Wikimedia Commons inayo amadokhumenti wemidiya '''''[[commons:Category:Lionel_Messi|ngoLionel Messi]]'''''.
* [[File:Wikiquote-logo.svg|link=https://en.wikiquote.org/wiki/David_Woodard?uselang=ty|16x16px]] Wikiquote: '''''[[wikiquote:Lionel_Messi|Lionel Messi]]''''' ([[:ty:Reo_Paratāne|en]])
* [[File:Echo_global_icon.svg|link=https://messi.com/|13x13px]] [https://messi.com/ Isiteji Esisemthethweni]
''[https://nr.wikipedia.org/ Abahleli beWikipedia]''</text>
      <sha1>b50lx0wyg3eicxhnqqb9ykakt3ogf3v</sha1>
    </revision>
    <revision>
      <id>2934</id>
      <parentid>2670</parentid>
      <timestamp>2025-06-06T17:12:50Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>Replaced content with &quot;This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. Giovanni Messe is a character from the video game, Hearts of Iron IV. He is a general for italy.&quot;</comment>
      <origin>2934</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="177" sha1="hrk195ekaa1xjunxo0y4zlkb88e0aq8" xml:space="preserve">This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. Giovanni Messe is a character from the video game, Hearts of Iron IV. He is a general for italy.</text>
      <sha1>hrk195ekaa1xjunxo0y4zlkb88e0aq8</sha1>
    </revision>
    <revision>
      <id>2948</id>
      <parentid>2934</parentid>
      <timestamp>2025-06-06T17:22:46Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>linkie link</comment>
      <origin>2948</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="189" sha1="nqet9azqnoh6ha669k5pcgy9ps3q3ob" xml:space="preserve">This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. Giovanni Messe is a character from the video game, Hearts of Iron IV. He is a general for [[I-Italy|italy]].</text>
      <sha1>nqet9azqnoh6ha669k5pcgy9ps3q3ob</sha1>
    </revision>
    <revision>
      <id>3137</id>
      <parentid>2948</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edits by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:197.103.129.107|197.103.129.107]]</comment>
      <origin>2670</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="11030" sha1="b50lx0wyg3eicxhnqqb9ykakt3ogf3v" xml:space="preserve">[[Isimumathi:Symbol support vote.svg|right|frameless|23x23px]]{{Person|ibizo=ULionel Messi|ubelethwe ngo=Juni 24, 1987|umsebenzi=Umgijimi webhola (soccer)|indawo yo kubelethwa=Rosario, e-Argentina|isithombe=Lionel-Messi-Argentina-2022-FIFA-World-Cup (cropped).jpg}}'''ULionel Messi''' (''wabelethwa ngoJuni 24, 1987, eRosario, e-Argentina'') ngumdlali webhola owazalelwa e-[[Argentina]] ozuze amarekhodi angu-8 kumaBallon d'Or njengomdlali ohamba phambili emhlabeni. Ngo-2022, wasiza i-Argentina ukunqoba iNdebe Yomhlaba yeFédération Internationale de Football Association (FIFA).&lt;ref name=&quot;:0&quot;&gt;Lisi, C., ''[[iarchive:historyofworldcu0000lisi_v7i5|«]]''[[iarchive:historyofworldcu0000lisi_v7i5|History of the World Cup: 1930–2010»]], ''Scarecrow Press'', 2011&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;Balagué, G., [[iarchive:messibiography0000bala|«Messi»]]. ''Orion Books,'' 2013&lt;/ref&gt;&lt;ref name=&quot;:2&quot;&gt;Tomkins, P., «Above Us Only Sky: Liverpool FC's Global Revolution», ''Anchor Print Group'', 2007&lt;/ref&gt;&lt;ref name=&quot;:3&quot;&gt;Hunter, G., «Barça: The Making of the Greatest Team in the World», ''BackPage Press'', 2012&lt;/ref&gt; 

== Ukuphila kwakuqala ==
UMessi waqala ukudlala ibhola esengumfanyana, kwathi ngo-1995 wajoyina ithimba leNewell’s Old Boys, iqembu lomphakathi elidlala umdlalo omkhulu eRosario. Amakhono akhe angavamile athusa amaqembu adumile ase-Europe kanye neLatin America. Lapho eneminyaka eli-13, uMessi nomndeni wakhe bathutha baya eBarcelona, lapho aqala ukudlalela iqembu labafana abaneminyaka engaphasi kwengu-14 leFC Barcelona. Wahlohla amagoli ayi-21 emidlalweni eyi-14 eqenjini labancane, kwathi ngokushesha wakhuphukela emaqenjini aphezulu, waze waba nemidlalo yakhe yokuqala engakahloniphi ngokusemthethweni eneminyaka eyi-16, edlalela iFC Barcelona emdlalweni wobungani.&lt;ref name=&quot;:1&quot; /&gt;

== Ukudlala kwamaqembu ==
Ngesizini ka-2004–05, uMessi, wayeneminyaka eyi-17 ngaleso sikhathi, waba ngumdlali omncane kunabo bonke obakhe badlala futhi wahlohla igoli emlandweni weSpanish La Liga, okuwumqhudelwano ophezulu webhola laseSpain. Naphezu kokuba nezinga lama-5 izinyawo eziyisi-7 (1.7 amitha) nokuba nesisindo esingu-148 amakhilogremu (67 kg), wayeqinile, ekulinganiselwe kahle, futhi eguquguquka enkundleni. Engunozwane lwesobunxele ngokwemvelo, ehlakaniphile futhi enembile ekulawuleni ibhola, uMessi wayengumhambisi ophambili wama-pasi futhi ayekwazi ukugqashula ezivikeleni eziminyene. Ngo-2005 wanikezwa ubuzwe baseSpain, okwathathwa ngemizwa ehlukahlukene ngabalandeli beBarcelona abaziqhenyayo ngokuba ngamaCatalan. Ngonyaka olandelayo, uMessi kanye neqembu leBarcelona banqoba isicoco seChampions League, umqhudelwano wamaqembu ase-Europe.&lt;ref name=&quot;:2&quot; /&gt;

Ukudlala kukaMessi kwaqhubeka kuthuthuka ngokushesha eminyakeni edlule, kwathi ngo-2008 waba ngomunye wabadlali abaphambili emhlabeni, eqeda endaweni yesibili emavotini eBallon d'Or ka-2008, enqotshwa nguCristiano Ronaldo weManchester United. Ekuqaleni kuka-2009, uMessi waqedela isizini emangalisayo ka-2008–09 ngokusiza i-FC Barcelona ukuthi ithole i-“treble” yayo yokuqala (ukunqoba izihloko ezintathu ezinkulu zamaqembu ase-Europe ngesizini eyodwa): iqembu lanqoba isicoco seLa Liga, iCopa del Rey (indebe enkulu yasekhaya yaseSpain), kanye nesicoco seChampions League. Kulowo nyaka, uMessi wahlohla amagoli angama-38 emidlalweni engu-51, futhi waxosha uRonaldo emavotini weBallon d'Or kanye nomdlali womhlaba wonyaka weFIFA, enza umlando ngokuhlukana okuningi kwamaphuzu. Ngesizini ka-2009–10, uMessi wahlohla amagoli angu-34 emidlalweni yasekhaya ngesikhathi iBarcelona iphinda inqobe isicoco seLa Liga. Wathola umklomelo weGolden Shoe njengomshayi magoli ohamba phambili e-Europe, futhi waphinde wanikezwa enye iBallon d'Or (eyaziwa njengeFIFA Ballon d'Or phakathi kuka-2010 no-2015).&lt;ref name=&quot;:3&quot; /&gt;
[[Isimumathi:Arda Turan 2016-17 (cropped).jpg|thumb|228x228px|Uphumelele iBallon d'Or izikhathi eziyisishiyagalombili uLionel Messi, Agasti 2016.]]
UMessi wahola i-Barcelona ekunqobeni izihloko zeLa Liga kanye neChampions League ngesizini eyalandela, okusiza wazuza umklomelo wesithathu olandelanayo womdlali womhlaba wonyaka, okuyinto engakaze ibonwe. NgoMbasa 2012, wahlohla igoli lakhe lama-233 le-Barcelona, waba umshayi magoli ophezulu kunabo bonke emlandweni weqembu emidlalweni yeLa Liga eneminyaka engu-24 kuphela. Waqeda isizini ka-2011–12 ye-Barcelona (eyayihlanganisa enye iwini yeCopa del Rey) enamagoli angu-73 kuyo yonke imiqhudelwano, epha isicoco sikaGerd Müller seminyaka engu-39 samagoli esizini eyodwa kwimidlalo eyinhloko ye-European football. Lokhu kusebenza okumangalisayo kwamphoqa ukuthi aqokwe njengomdlali womhlaba wonyaka ka-2012, okumenza waba ngumdlali wokuqala ukuwina isihloko izikhathi ezine. Amagoli akhe angu-46 eLa Liga ngesizini ka-2012–13 aholela kulesi sigaba, futhi iBarcelona yaphinda yathatha isicoco seligi yasekhaya. Ngo-2014, usetha irekhodi lonke leBarcelona ngesikhathi ehlohla igoli lakhe lama-370 njengelungu leqembu. Ngalo nyaka, wephula amarekhodi emisebenzi yokuhlohla kuChampions League (amagoli angu-72) kanye neLa Liga (amagoli angu-253).
[[Isimumathi:Lionel Messi vs Valladolid 3.jpg|thumb|264x264px|ULionel Messi, Disemba 2018.]]
Ngo-2014–15, uMessi wasiza i-Barcelona ukuthi iphinde inqobe i-treble, ehola iqembu ngamaphuzu angu-43 phakathi nesizini, okwamnikeza umklomelo wakhe wesihlanu womdlali womhlaba wonyaka. Ngesizini ka-2015–16, wahlohla amagoli angu-41 kuyo yonke imiqhudelwano ye-Barcelona, futhi iqembu lazuza izicoco zeLa Liga neCopa del Rey. Waphumelela kakhudlwana ngo-2016–17 ngamaphuzu angu-53, eholela iqembu ekunqobeni isicoco seCopa del Rey futhi. Ngo-2017–18, wahlohla amagoli angu-45, kanti i-Barcelona yawina izicoco zeLa Liga neCopa del Rey futhi. Ngo-2018–19, uMessi wahlohla amagoli angu-51 kuyo yonke imiqhudelwano yasekhaya, kwathi i-Barcelona yawina enye isicoco seLa Liga. Ekupheleni kuka-2019, wawina iBallon d'Or yakhe yesithupha futhi waqanjwa njengomdlali ongcono kunabo bonke emhlabeni yiFIFA. Ngesizini ka-2020–21, i-Barcelona yathatha isicoco seCopa del Rey, okuyisikhombisa emsebenzini kaMessi. Waba ngumdlali ozimele ngo-2021, kanti izinkinga zezimali—ezinye zazo ezazihlobene nemithetho yeLa Liga—zamenza wangakwazi ukuqhubeka ne-Barcelona. Wahlala engumholi ohlukile emlandweni, engumshayi magoli ophezulu emlandweni weLa Liga ngamaphuzu angu-474.

Ngemuva kwalokho, ngo-2021 uMessi signed ne-Paris St.-Germain (PSG), lapho ajoyina khona ojonge amathalente amakhulu uKylian Mbappé noNeymar, futhi ngalowo nyaka wathola iBallon d'Or yakhe eyayilandelayo. Wasiza i-PSG ukuthi iwine isicoco seLigue 1 ngesikhathi esingamabili adlala nohlelo. Ngo-2023, uMessi wajoyina i-Inter Miami ye-Major League Soccer.

== Uhambo lwakhe lwezizwe ==
Ngaphandle kokuba nezimvume ezimbili zokuba ngozinze eSpain futhi eseziphumelelayo emsebenzini, uMessi waqhubeka nokuhlala nezibopho ezinzulu ezweni lakubo, futhi waba yilungu elibalulekile kumaqembu kazwelonke ase-Argentina kusukela ngo-2005. Wadlala eqenjini le-Argentina elinqobile kwi-FIFA World Youth Championship yango-2005, wakhumela izwe lakhe kuWorld Cup yango-2006, futhi wabhala amagoli amabili kumidlalo emihlanu lapho i-Argentina yaphumelela ukufinyelela kumaphiko e-golde medal ku-Olympics yaseBeijing ngo-2008. UMessi wasiza i-Argentina ukuba ifinyelele kuma-quarterfinals we-World Cup yango-2010, lapho iqembu lihlulwa yi-Germany, okwenza kube yisikhathi sesibili sokulahlekelwa kuWorld Cup. Ku-World Cup yango-2014, uMessi wenza isibonelo esimangalisayo, wabhala amagoli amane futhi waqhuba i-Argentina, eneqembu elihlushwa yizinkinga zokuhlasela, kwi-stage yeqembu futhi eya kumjikelo wokuphuma, lapho i-Argentina yachitha isikhathi eside ukusuka efinalini ye-World Cup ngomnyaka wesine ngo-24. I-Argentina yenqabela lowo mdlalo ngo-1-0 ne-Germany, kodwa uMessi wathola i-Golden Ball njengomdlali ophumelela kakhulu. Ngesikhathi se-2016 Copa América Centenario, wabhala igoli lakhe le-55 phakathi kwezizwe, ephula irekhodi likaGabriel Batistuta njengomshayi magoli ophumelele kakhulu e-Argentina.&lt;ref name=&quot;:0&quot; /&gt;
[[Isimumathi:ARG Line-up - ARG vs MEX for 2022 FIFA WC.jpg|thumb|271x271px|Umphosa weqembu uLionel Messi kanye namanye amalungu eqembu lesizwe lase-Argentina ku-World Cup yezeMidlalo yabesilisa ka-2022.]]
Emva kokuhlulwa kwe-Argentina kwi-Copa final—okuphikisana nesikhumbuzo sokuqala kwama-final izikhathi ezintathu kumqhudelwano omkhulu—uMessi wathi uzashiya iqembu lesizwe, kodwa &quot;ukuthatha umhlalaphansi&quot; kwakhe okwesikhashana kwahlala izinyanga ezimbili ngaphambi kokubhalela ukubuyela eqenjini. Ku-World Cup yango-2018, wasiza iqembu lase-Argentina elihlangabezana nobunzima ukufinyelela kumjikelo wokuphuma, lapho bachithwa yiFrance, okuyi-team ethole i-championship, emdlalweni wabo wokuqala. Ngemva kokuphothula esikhathini sesithathu e-Copa América yango-2019, uMessi wahola i-Argentina ukuba iwine umqhudelwano eminyakeni emibili kamuva, waphinde wathola i-Golden Ball award.&lt;ref name=&quot;:0&quot; /&gt;

Impumelelo yakhe yaqhubeka kwi-World Cup yango-2022. Lapho, wahola i-Argentina ku-final, lapho ebhala amagoli amabili—futhi wenza umphumela ophumelelayo ngesikhathi sokuphonswa amaphuzu—to ukusiza ukwehlula iFrance. UMessi wathola i-Golden Ball ye-World Cup, waba ngumdlali wesilisa wokuqala ukuthola lesi sikhumbuzo izikhathi ezimbili. Ukwengeza, ukudlala kwakhe okuhle kakhulu kulomqhudelwano kwakubalulekile ekutholeni kwakhe iBallon d'Or yesishiyagalombili ngo-2023.

== Ezinye izenzo kanye nezinkinga zomthetho ==
Ngaphandle komkhakha womdlalo, uMessi wayengomunye wezinkanyezi zomzimba ezinkulu emhlabeni. Ngokuhlangene nemiholo yebhola, eyayivame ukuba nezezakhiwo ezimbili ezinkulu kakhulu zabadlali bezemidlalo bonke, waba ngumkhangisi ophumelelayo wemikhiqizo, ikakhulukazi kwenkampani yezimpahla zezemidlalo i-Adidas. Ngo-2013, uMessi kanye no-ubaba wakhe (ophatha izimali zomfana wakhe) babhekene necala lokugwema intela, behlonipha izinkampani zomphakathi zasephesheya ukuze bagweme ukukhokha u-€4.2 million ezintela zaseSpain kumholo wokukhangisa. Nokho, ngemuva kokukhokha €5 million kuMbuso waseSpain, bobabili bakhishwa ukuba babhekane necala ngo-2016. NgoJulayi walowo nyaka, uMessi no-ubaba wakhe bathola isijeziso sokuhlala ezinyangeni ezimisiwe zomlomo wesigwebo esingaphansi kweminyaka emibili, futhi bathola izijeziso zentela zangu-€2 million no-€1.5 million, ngokulandelana.

== Iinkomba ==
{{Reflist}}

== Izixhumanisi zangaphandle ==
* [[File:Commons-logo.svg|link=https://commons.wikimedia.org/wiki/Category:Lionel_Messi?uselang=ty|18x18px]] Wikimedia Commons inayo amadokhumenti wemidiya '''''[[commons:Category:Lionel_Messi|ngoLionel Messi]]'''''.
* [[File:Wikiquote-logo.svg|link=https://en.wikiquote.org/wiki/David_Woodard?uselang=ty|16x16px]] Wikiquote: '''''[[wikiquote:Lionel_Messi|Lionel Messi]]''''' ([[:ty:Reo_Paratāne|en]])
* [[File:Echo_global_icon.svg|link=https://messi.com/|13x13px]] [https://messi.com/ Isiteji Esisemthethweni]
''[https://nr.wikipedia.org/ Abahleli beWikipedia]''</text>
      <sha1>b50lx0wyg3eicxhnqqb9ykakt3ogf3v</sha1>
    </revision>
    <revision>
      <id>6742</id>
      <parentid>3137</parentid>
      <timestamp>2026-07-15T00:44:28Z</timestamp>
      <contributor>
        <username>THIAGOW13</username>
        <id>1627</id>
      </contributor>
      <origin>6742</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="11033" sha1="bnhob5ezji3vccb07mxf8hwbfd4zmx4" xml:space="preserve">[[Isimumathi:Symbol support vote.svg|right|frameless|23x23px]]{{Person|ibizo=ULionel Messi|ubelethwe ngo=Juni 24, 1987|umsebenzi=Umgijimi webhola (soccer)|indawo yo kubelethwa=Rosario, e-Argentina|isithombe=Lionel Messi Argentina v Egypt 7 July 2026-112(cropped).jpg}}'''ULionel Messi''' (''wabelethwa ngoJuni 24, 1987, eRosario, e-Argentina'') ngumdlali webhola owazalelwa e-[[Argentina]] ozuze amarekhodi angu-8 kumaBallon d'Or njengomdlali ohamba phambili emhlabeni. Ngo-2022, wasiza i-Argentina ukunqoba iNdebe Yomhlaba yeFédération Internationale de Football Association (FIFA).&lt;ref name=&quot;:0&quot;&gt;Lisi, C., ''[[iarchive:historyofworldcu0000lisi_v7i5|«]]''[[iarchive:historyofworldcu0000lisi_v7i5|History of the World Cup: 1930–2010»]], ''Scarecrow Press'', 2011&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;Balagué, G., [[iarchive:messibiography0000bala|«Messi»]]. ''Orion Books,'' 2013&lt;/ref&gt;&lt;ref name=&quot;:2&quot;&gt;Tomkins, P., «Above Us Only Sky: Liverpool FC's Global Revolution», ''Anchor Print Group'', 2007&lt;/ref&gt;&lt;ref name=&quot;:3&quot;&gt;Hunter, G., «Barça: The Making of the Greatest Team in the World», ''BackPage Press'', 2012&lt;/ref&gt; 

== Ukuphila kwakuqala ==
UMessi waqala ukudlala ibhola esengumfanyana, kwathi ngo-1995 wajoyina ithimba leNewell’s Old Boys, iqembu lomphakathi elidlala umdlalo omkhulu eRosario. Amakhono akhe angavamile athusa amaqembu adumile ase-Europe kanye neLatin America. Lapho eneminyaka eli-13, uMessi nomndeni wakhe bathutha baya eBarcelona, lapho aqala ukudlalela iqembu labafana abaneminyaka engaphasi kwengu-14 leFC Barcelona. Wahlohla amagoli ayi-21 emidlalweni eyi-14 eqenjini labancane, kwathi ngokushesha wakhuphukela emaqenjini aphezulu, waze waba nemidlalo yakhe yokuqala engakahloniphi ngokusemthethweni eneminyaka eyi-16, edlalela iFC Barcelona emdlalweni wobungani.&lt;ref name=&quot;:1&quot; /&gt;

== Ukudlala kwamaqembu ==
Ngesizini ka-2004–05, uMessi, wayeneminyaka eyi-17 ngaleso sikhathi, waba ngumdlali omncane kunabo bonke obakhe badlala futhi wahlohla igoli emlandweni weSpanish La Liga, okuwumqhudelwano ophezulu webhola laseSpain. Naphezu kokuba nezinga lama-5 izinyawo eziyisi-7 (1.7 amitha) nokuba nesisindo esingu-148 amakhilogremu (67 kg), wayeqinile, ekulinganiselwe kahle, futhi eguquguquka enkundleni. Engunozwane lwesobunxele ngokwemvelo, ehlakaniphile futhi enembile ekulawuleni ibhola, uMessi wayengumhambisi ophambili wama-pasi futhi ayekwazi ukugqashula ezivikeleni eziminyene. Ngo-2005 wanikezwa ubuzwe baseSpain, okwathathwa ngemizwa ehlukahlukene ngabalandeli beBarcelona abaziqhenyayo ngokuba ngamaCatalan. Ngonyaka olandelayo, uMessi kanye neqembu leBarcelona banqoba isicoco seChampions League, umqhudelwano wamaqembu ase-Europe.&lt;ref name=&quot;:2&quot; /&gt;

Ukudlala kukaMessi kwaqhubeka kuthuthuka ngokushesha eminyakeni edlule, kwathi ngo-2008 waba ngomunye wabadlali abaphambili emhlabeni, eqeda endaweni yesibili emavotini eBallon d'Or ka-2008, enqotshwa nguCristiano Ronaldo weManchester United. Ekuqaleni kuka-2009, uMessi waqedela isizini emangalisayo ka-2008–09 ngokusiza i-FC Barcelona ukuthi ithole i-“treble” yayo yokuqala (ukunqoba izihloko ezintathu ezinkulu zamaqembu ase-Europe ngesizini eyodwa): iqembu lanqoba isicoco seLa Liga, iCopa del Rey (indebe enkulu yasekhaya yaseSpain), kanye nesicoco seChampions League. Kulowo nyaka, uMessi wahlohla amagoli angama-38 emidlalweni engu-51, futhi waxosha uRonaldo emavotini weBallon d'Or kanye nomdlali womhlaba wonyaka weFIFA, enza umlando ngokuhlukana okuningi kwamaphuzu. Ngesizini ka-2009–10, uMessi wahlohla amagoli angu-34 emidlalweni yasekhaya ngesikhathi iBarcelona iphinda inqobe isicoco seLa Liga. Wathola umklomelo weGolden Shoe njengomshayi magoli ohamba phambili e-Europe, futhi waphinde wanikezwa enye iBallon d'Or (eyaziwa njengeFIFA Ballon d'Or phakathi kuka-2010 no-2015).&lt;ref name=&quot;:3&quot; /&gt;
[[Isimumathi:Arda Turan 2016-17 (cropped).jpg|thumb|228x228px|Uphumelele iBallon d'Or izikhathi eziyisishiyagalombili uLionel Messi, Agasti 2016.]]
UMessi wahola i-Barcelona ekunqobeni izihloko zeLa Liga kanye neChampions League ngesizini eyalandela, okusiza wazuza umklomelo wesithathu olandelanayo womdlali womhlaba wonyaka, okuyinto engakaze ibonwe. NgoMbasa 2012, wahlohla igoli lakhe lama-233 le-Barcelona, waba umshayi magoli ophezulu kunabo bonke emlandweni weqembu emidlalweni yeLa Liga eneminyaka engu-24 kuphela. Waqeda isizini ka-2011–12 ye-Barcelona (eyayihlanganisa enye iwini yeCopa del Rey) enamagoli angu-73 kuyo yonke imiqhudelwano, epha isicoco sikaGerd Müller seminyaka engu-39 samagoli esizini eyodwa kwimidlalo eyinhloko ye-European football. Lokhu kusebenza okumangalisayo kwamphoqa ukuthi aqokwe njengomdlali womhlaba wonyaka ka-2012, okumenza waba ngumdlali wokuqala ukuwina isihloko izikhathi ezine. Amagoli akhe angu-46 eLa Liga ngesizini ka-2012–13 aholela kulesi sigaba, futhi iBarcelona yaphinda yathatha isicoco seligi yasekhaya. Ngo-2014, usetha irekhodi lonke leBarcelona ngesikhathi ehlohla igoli lakhe lama-370 njengelungu leqembu. Ngalo nyaka, wephula amarekhodi emisebenzi yokuhlohla kuChampions League (amagoli angu-72) kanye neLa Liga (amagoli angu-253).
[[Isimumathi:Lionel Messi vs Valladolid 3.jpg|thumb|264x264px|ULionel Messi, Disemba 2018.]]
Ngo-2014–15, uMessi wasiza i-Barcelona ukuthi iphinde inqobe i-treble, ehola iqembu ngamaphuzu angu-43 phakathi nesizini, okwamnikeza umklomelo wakhe wesihlanu womdlali womhlaba wonyaka. Ngesizini ka-2015–16, wahlohla amagoli angu-41 kuyo yonke imiqhudelwano ye-Barcelona, futhi iqembu lazuza izicoco zeLa Liga neCopa del Rey. Waphumelela kakhudlwana ngo-2016–17 ngamaphuzu angu-53, eholela iqembu ekunqobeni isicoco seCopa del Rey futhi. Ngo-2017–18, wahlohla amagoli angu-45, kanti i-Barcelona yawina izicoco zeLa Liga neCopa del Rey futhi. Ngo-2018–19, uMessi wahlohla amagoli angu-51 kuyo yonke imiqhudelwano yasekhaya, kwathi i-Barcelona yawina enye isicoco seLa Liga. Ekupheleni kuka-2019, wawina iBallon d'Or yakhe yesithupha futhi waqanjwa njengomdlali ongcono kunabo bonke emhlabeni yiFIFA. Ngesizini ka-2020–21, i-Barcelona yathatha isicoco seCopa del Rey, okuyisikhombisa emsebenzini kaMessi. Waba ngumdlali ozimele ngo-2021, kanti izinkinga zezimali—ezinye zazo ezazihlobene nemithetho yeLa Liga—zamenza wangakwazi ukuqhubeka ne-Barcelona. Wahlala engumholi ohlukile emlandweni, engumshayi magoli ophezulu emlandweni weLa Liga ngamaphuzu angu-474.

Ngemuva kwalokho, ngo-2021 uMessi signed ne-Paris St.-Germain (PSG), lapho ajoyina khona ojonge amathalente amakhulu uKylian Mbappé noNeymar, futhi ngalowo nyaka wathola iBallon d'Or yakhe eyayilandelayo. Wasiza i-PSG ukuthi iwine isicoco seLigue 1 ngesikhathi esingamabili adlala nohlelo. Ngo-2023, uMessi wajoyina i-Inter Miami ye-Major League Soccer.

== Uhambo lwakhe lwezizwe ==
Ngaphandle kokuba nezimvume ezimbili zokuba ngozinze eSpain futhi eseziphumelelayo emsebenzini, uMessi waqhubeka nokuhlala nezibopho ezinzulu ezweni lakubo, futhi waba yilungu elibalulekile kumaqembu kazwelonke ase-Argentina kusukela ngo-2005. Wadlala eqenjini le-Argentina elinqobile kwi-FIFA World Youth Championship yango-2005, wakhumela izwe lakhe kuWorld Cup yango-2006, futhi wabhala amagoli amabili kumidlalo emihlanu lapho i-Argentina yaphumelela ukufinyelela kumaphiko e-golde medal ku-Olympics yaseBeijing ngo-2008. UMessi wasiza i-Argentina ukuba ifinyelele kuma-quarterfinals we-World Cup yango-2010, lapho iqembu lihlulwa yi-Germany, okwenza kube yisikhathi sesibili sokulahlekelwa kuWorld Cup. Ku-World Cup yango-2014, uMessi wenza isibonelo esimangalisayo, wabhala amagoli amane futhi waqhuba i-Argentina, eneqembu elihlushwa yizinkinga zokuhlasela, kwi-stage yeqembu futhi eya kumjikelo wokuphuma, lapho i-Argentina yachitha isikhathi eside ukusuka efinalini ye-World Cup ngomnyaka wesine ngo-24. I-Argentina yenqabela lowo mdlalo ngo-1-0 ne-Germany, kodwa uMessi wathola i-Golden Ball njengomdlali ophumelela kakhulu. Ngesikhathi se-2016 Copa América Centenario, wabhala igoli lakhe le-55 phakathi kwezizwe, ephula irekhodi likaGabriel Batistuta njengomshayi magoli ophumelele kakhulu e-Argentina.&lt;ref name=&quot;:0&quot; /&gt;
[[Isimumathi:ARG Line-up - ARG vs MEX for 2022 FIFA WC.jpg|thumb|271x271px|Umphosa weqembu uLionel Messi kanye namanye amalungu eqembu lesizwe lase-Argentina ku-World Cup yezeMidlalo yabesilisa ka-2022.]]
Emva kokuhlulwa kwe-Argentina kwi-Copa final—okuphikisana nesikhumbuzo sokuqala kwama-final izikhathi ezintathu kumqhudelwano omkhulu—uMessi wathi uzashiya iqembu lesizwe, kodwa &quot;ukuthatha umhlalaphansi&quot; kwakhe okwesikhashana kwahlala izinyanga ezimbili ngaphambi kokubhalela ukubuyela eqenjini. Ku-World Cup yango-2018, wasiza iqembu lase-Argentina elihlangabezana nobunzima ukufinyelela kumjikelo wokuphuma, lapho bachithwa yiFrance, okuyi-team ethole i-championship, emdlalweni wabo wokuqala. Ngemva kokuphothula esikhathini sesithathu e-Copa América yango-2019, uMessi wahola i-Argentina ukuba iwine umqhudelwano eminyakeni emibili kamuva, waphinde wathola i-Golden Ball award.&lt;ref name=&quot;:0&quot; /&gt;

Impumelelo yakhe yaqhubeka kwi-World Cup yango-2022. Lapho, wahola i-Argentina ku-final, lapho ebhala amagoli amabili—futhi wenza umphumela ophumelelayo ngesikhathi sokuphonswa amaphuzu—to ukusiza ukwehlula iFrance. UMessi wathola i-Golden Ball ye-World Cup, waba ngumdlali wesilisa wokuqala ukuthola lesi sikhumbuzo izikhathi ezimbili. Ukwengeza, ukudlala kwakhe okuhle kakhulu kulomqhudelwano kwakubalulekile ekutholeni kwakhe iBallon d'Or yesishiyagalombili ngo-2023.

== Ezinye izenzo kanye nezinkinga zomthetho ==
Ngaphandle komkhakha womdlalo, uMessi wayengomunye wezinkanyezi zomzimba ezinkulu emhlabeni. Ngokuhlangene nemiholo yebhola, eyayivame ukuba nezezakhiwo ezimbili ezinkulu kakhulu zabadlali bezemidlalo bonke, waba ngumkhangisi ophumelelayo wemikhiqizo, ikakhulukazi kwenkampani yezimpahla zezemidlalo i-Adidas. Ngo-2013, uMessi kanye no-ubaba wakhe (ophatha izimali zomfana wakhe) babhekene necala lokugwema intela, behlonipha izinkampani zomphakathi zasephesheya ukuze bagweme ukukhokha u-€4.2 million ezintela zaseSpain kumholo wokukhangisa. Nokho, ngemuva kokukhokha €5 million kuMbuso waseSpain, bobabili bakhishwa ukuba babhekane necala ngo-2016. NgoJulayi walowo nyaka, uMessi no-ubaba wakhe bathola isijeziso sokuhlala ezinyangeni ezimisiwe zomlomo wesigwebo esingaphansi kweminyaka emibili, futhi bathola izijeziso zentela zangu-€2 million no-€1.5 million, ngokulandelana.

== Iinkomba ==
{{Reflist}}

== Izixhumanisi zangaphandle ==
* [[File:Commons-logo.svg|link=https://commons.wikimedia.org/wiki/Category:Lionel_Messi?uselang=ty|18x18px]] Wikimedia Commons inayo amadokhumenti wemidiya '''''[[commons:Category:Lionel_Messi|ngoLionel Messi]]'''''.
* [[File:Wikiquote-logo.svg|link=https://en.wikiquote.org/wiki/David_Woodard?uselang=ty|16x16px]] Wikiquote: '''''[[wikiquote:Lionel_Messi|Lionel Messi]]''''' ([[:ty:Reo_Paratāne|en]])
* [[File:Echo_global_icon.svg|link=https://messi.com/|13x13px]] [https://messi.com/ Isiteji Esisemthethweni]
''[https://nr.wikipedia.org/ Abahleli beWikipedia]''</text>
      <sha1>bnhob5ezji3vccb07mxf8hwbfd4zmx4</sha1>
    </revision>
    <revision>
      <id>6743</id>
      <parentid>6742</parentid>
      <timestamp>2026-07-15T00:44:46Z</timestamp>
      <contributor>
        <username>THIAGOW13</username>
        <id>1627</id>
      </contributor>
      <origin>6743</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="11032" sha1="31idio5umvp4owxz0an7m0mioes18yb" xml:space="preserve">[[Isimumathi:Symbol support vote.svg|right|frameless|23x23px]]{{Person|ibizo=Lionel Messi|ubelethwe ngo=Juni 24, 1987|umsebenzi=Umgijimi webhola (soccer)|indawo yo kubelethwa=Rosario, e-Argentina|isithombe=Lionel Messi Argentina v Egypt 7 July 2026-112(cropped).jpg}}'''ULionel Messi''' (''wabelethwa ngoJuni 24, 1987, eRosario, e-Argentina'') ngumdlali webhola owazalelwa e-[[Argentina]] ozuze amarekhodi angu-8 kumaBallon d'Or njengomdlali ohamba phambili emhlabeni. Ngo-2022, wasiza i-Argentina ukunqoba iNdebe Yomhlaba yeFédération Internationale de Football Association (FIFA).&lt;ref name=&quot;:0&quot;&gt;Lisi, C., ''[[iarchive:historyofworldcu0000lisi_v7i5|«]]''[[iarchive:historyofworldcu0000lisi_v7i5|History of the World Cup: 1930–2010»]], ''Scarecrow Press'', 2011&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;Balagué, G., [[iarchive:messibiography0000bala|«Messi»]]. ''Orion Books,'' 2013&lt;/ref&gt;&lt;ref name=&quot;:2&quot;&gt;Tomkins, P., «Above Us Only Sky: Liverpool FC's Global Revolution», ''Anchor Print Group'', 2007&lt;/ref&gt;&lt;ref name=&quot;:3&quot;&gt;Hunter, G., «Barça: The Making of the Greatest Team in the World», ''BackPage Press'', 2012&lt;/ref&gt; 

== Ukuphila kwakuqala ==
UMessi waqala ukudlala ibhola esengumfanyana, kwathi ngo-1995 wajoyina ithimba leNewell’s Old Boys, iqembu lomphakathi elidlala umdlalo omkhulu eRosario. Amakhono akhe angavamile athusa amaqembu adumile ase-Europe kanye neLatin America. Lapho eneminyaka eli-13, uMessi nomndeni wakhe bathutha baya eBarcelona, lapho aqala ukudlalela iqembu labafana abaneminyaka engaphasi kwengu-14 leFC Barcelona. Wahlohla amagoli ayi-21 emidlalweni eyi-14 eqenjini labancane, kwathi ngokushesha wakhuphukela emaqenjini aphezulu, waze waba nemidlalo yakhe yokuqala engakahloniphi ngokusemthethweni eneminyaka eyi-16, edlalela iFC Barcelona emdlalweni wobungani.&lt;ref name=&quot;:1&quot; /&gt;

== Ukudlala kwamaqembu ==
Ngesizini ka-2004–05, uMessi, wayeneminyaka eyi-17 ngaleso sikhathi, waba ngumdlali omncane kunabo bonke obakhe badlala futhi wahlohla igoli emlandweni weSpanish La Liga, okuwumqhudelwano ophezulu webhola laseSpain. Naphezu kokuba nezinga lama-5 izinyawo eziyisi-7 (1.7 amitha) nokuba nesisindo esingu-148 amakhilogremu (67 kg), wayeqinile, ekulinganiselwe kahle, futhi eguquguquka enkundleni. Engunozwane lwesobunxele ngokwemvelo, ehlakaniphile futhi enembile ekulawuleni ibhola, uMessi wayengumhambisi ophambili wama-pasi futhi ayekwazi ukugqashula ezivikeleni eziminyene. Ngo-2005 wanikezwa ubuzwe baseSpain, okwathathwa ngemizwa ehlukahlukene ngabalandeli beBarcelona abaziqhenyayo ngokuba ngamaCatalan. Ngonyaka olandelayo, uMessi kanye neqembu leBarcelona banqoba isicoco seChampions League, umqhudelwano wamaqembu ase-Europe.&lt;ref name=&quot;:2&quot; /&gt;

Ukudlala kukaMessi kwaqhubeka kuthuthuka ngokushesha eminyakeni edlule, kwathi ngo-2008 waba ngomunye wabadlali abaphambili emhlabeni, eqeda endaweni yesibili emavotini eBallon d'Or ka-2008, enqotshwa nguCristiano Ronaldo weManchester United. Ekuqaleni kuka-2009, uMessi waqedela isizini emangalisayo ka-2008–09 ngokusiza i-FC Barcelona ukuthi ithole i-“treble” yayo yokuqala (ukunqoba izihloko ezintathu ezinkulu zamaqembu ase-Europe ngesizini eyodwa): iqembu lanqoba isicoco seLa Liga, iCopa del Rey (indebe enkulu yasekhaya yaseSpain), kanye nesicoco seChampions League. Kulowo nyaka, uMessi wahlohla amagoli angama-38 emidlalweni engu-51, futhi waxosha uRonaldo emavotini weBallon d'Or kanye nomdlali womhlaba wonyaka weFIFA, enza umlando ngokuhlukana okuningi kwamaphuzu. Ngesizini ka-2009–10, uMessi wahlohla amagoli angu-34 emidlalweni yasekhaya ngesikhathi iBarcelona iphinda inqobe isicoco seLa Liga. Wathola umklomelo weGolden Shoe njengomshayi magoli ohamba phambili e-Europe, futhi waphinde wanikezwa enye iBallon d'Or (eyaziwa njengeFIFA Ballon d'Or phakathi kuka-2010 no-2015).&lt;ref name=&quot;:3&quot; /&gt;
[[Isimumathi:Arda Turan 2016-17 (cropped).jpg|thumb|228x228px|Uphumelele iBallon d'Or izikhathi eziyisishiyagalombili uLionel Messi, Agasti 2016.]]
UMessi wahola i-Barcelona ekunqobeni izihloko zeLa Liga kanye neChampions League ngesizini eyalandela, okusiza wazuza umklomelo wesithathu olandelanayo womdlali womhlaba wonyaka, okuyinto engakaze ibonwe. NgoMbasa 2012, wahlohla igoli lakhe lama-233 le-Barcelona, waba umshayi magoli ophezulu kunabo bonke emlandweni weqembu emidlalweni yeLa Liga eneminyaka engu-24 kuphela. Waqeda isizini ka-2011–12 ye-Barcelona (eyayihlanganisa enye iwini yeCopa del Rey) enamagoli angu-73 kuyo yonke imiqhudelwano, epha isicoco sikaGerd Müller seminyaka engu-39 samagoli esizini eyodwa kwimidlalo eyinhloko ye-European football. Lokhu kusebenza okumangalisayo kwamphoqa ukuthi aqokwe njengomdlali womhlaba wonyaka ka-2012, okumenza waba ngumdlali wokuqala ukuwina isihloko izikhathi ezine. Amagoli akhe angu-46 eLa Liga ngesizini ka-2012–13 aholela kulesi sigaba, futhi iBarcelona yaphinda yathatha isicoco seligi yasekhaya. Ngo-2014, usetha irekhodi lonke leBarcelona ngesikhathi ehlohla igoli lakhe lama-370 njengelungu leqembu. Ngalo nyaka, wephula amarekhodi emisebenzi yokuhlohla kuChampions League (amagoli angu-72) kanye neLa Liga (amagoli angu-253).
[[Isimumathi:Lionel Messi vs Valladolid 3.jpg|thumb|264x264px|ULionel Messi, Disemba 2018.]]
Ngo-2014–15, uMessi wasiza i-Barcelona ukuthi iphinde inqobe i-treble, ehola iqembu ngamaphuzu angu-43 phakathi nesizini, okwamnikeza umklomelo wakhe wesihlanu womdlali womhlaba wonyaka. Ngesizini ka-2015–16, wahlohla amagoli angu-41 kuyo yonke imiqhudelwano ye-Barcelona, futhi iqembu lazuza izicoco zeLa Liga neCopa del Rey. Waphumelela kakhudlwana ngo-2016–17 ngamaphuzu angu-53, eholela iqembu ekunqobeni isicoco seCopa del Rey futhi. Ngo-2017–18, wahlohla amagoli angu-45, kanti i-Barcelona yawina izicoco zeLa Liga neCopa del Rey futhi. Ngo-2018–19, uMessi wahlohla amagoli angu-51 kuyo yonke imiqhudelwano yasekhaya, kwathi i-Barcelona yawina enye isicoco seLa Liga. Ekupheleni kuka-2019, wawina iBallon d'Or yakhe yesithupha futhi waqanjwa njengomdlali ongcono kunabo bonke emhlabeni yiFIFA. Ngesizini ka-2020–21, i-Barcelona yathatha isicoco seCopa del Rey, okuyisikhombisa emsebenzini kaMessi. Waba ngumdlali ozimele ngo-2021, kanti izinkinga zezimali—ezinye zazo ezazihlobene nemithetho yeLa Liga—zamenza wangakwazi ukuqhubeka ne-Barcelona. Wahlala engumholi ohlukile emlandweni, engumshayi magoli ophezulu emlandweni weLa Liga ngamaphuzu angu-474.

Ngemuva kwalokho, ngo-2021 uMessi signed ne-Paris St.-Germain (PSG), lapho ajoyina khona ojonge amathalente amakhulu uKylian Mbappé noNeymar, futhi ngalowo nyaka wathola iBallon d'Or yakhe eyayilandelayo. Wasiza i-PSG ukuthi iwine isicoco seLigue 1 ngesikhathi esingamabili adlala nohlelo. Ngo-2023, uMessi wajoyina i-Inter Miami ye-Major League Soccer.

== Uhambo lwakhe lwezizwe ==
Ngaphandle kokuba nezimvume ezimbili zokuba ngozinze eSpain futhi eseziphumelelayo emsebenzini, uMessi waqhubeka nokuhlala nezibopho ezinzulu ezweni lakubo, futhi waba yilungu elibalulekile kumaqembu kazwelonke ase-Argentina kusukela ngo-2005. Wadlala eqenjini le-Argentina elinqobile kwi-FIFA World Youth Championship yango-2005, wakhumela izwe lakhe kuWorld Cup yango-2006, futhi wabhala amagoli amabili kumidlalo emihlanu lapho i-Argentina yaphumelela ukufinyelela kumaphiko e-golde medal ku-Olympics yaseBeijing ngo-2008. UMessi wasiza i-Argentina ukuba ifinyelele kuma-quarterfinals we-World Cup yango-2010, lapho iqembu lihlulwa yi-Germany, okwenza kube yisikhathi sesibili sokulahlekelwa kuWorld Cup. Ku-World Cup yango-2014, uMessi wenza isibonelo esimangalisayo, wabhala amagoli amane futhi waqhuba i-Argentina, eneqembu elihlushwa yizinkinga zokuhlasela, kwi-stage yeqembu futhi eya kumjikelo wokuphuma, lapho i-Argentina yachitha isikhathi eside ukusuka efinalini ye-World Cup ngomnyaka wesine ngo-24. I-Argentina yenqabela lowo mdlalo ngo-1-0 ne-Germany, kodwa uMessi wathola i-Golden Ball njengomdlali ophumelela kakhulu. Ngesikhathi se-2016 Copa América Centenario, wabhala igoli lakhe le-55 phakathi kwezizwe, ephula irekhodi likaGabriel Batistuta njengomshayi magoli ophumelele kakhulu e-Argentina.&lt;ref name=&quot;:0&quot; /&gt;
[[Isimumathi:ARG Line-up - ARG vs MEX for 2022 FIFA WC.jpg|thumb|271x271px|Umphosa weqembu uLionel Messi kanye namanye amalungu eqembu lesizwe lase-Argentina ku-World Cup yezeMidlalo yabesilisa ka-2022.]]
Emva kokuhlulwa kwe-Argentina kwi-Copa final—okuphikisana nesikhumbuzo sokuqala kwama-final izikhathi ezintathu kumqhudelwano omkhulu—uMessi wathi uzashiya iqembu lesizwe, kodwa &quot;ukuthatha umhlalaphansi&quot; kwakhe okwesikhashana kwahlala izinyanga ezimbili ngaphambi kokubhalela ukubuyela eqenjini. Ku-World Cup yango-2018, wasiza iqembu lase-Argentina elihlangabezana nobunzima ukufinyelela kumjikelo wokuphuma, lapho bachithwa yiFrance, okuyi-team ethole i-championship, emdlalweni wabo wokuqala. Ngemva kokuphothula esikhathini sesithathu e-Copa América yango-2019, uMessi wahola i-Argentina ukuba iwine umqhudelwano eminyakeni emibili kamuva, waphinde wathola i-Golden Ball award.&lt;ref name=&quot;:0&quot; /&gt;

Impumelelo yakhe yaqhubeka kwi-World Cup yango-2022. Lapho, wahola i-Argentina ku-final, lapho ebhala amagoli amabili—futhi wenza umphumela ophumelelayo ngesikhathi sokuphonswa amaphuzu—to ukusiza ukwehlula iFrance. UMessi wathola i-Golden Ball ye-World Cup, waba ngumdlali wesilisa wokuqala ukuthola lesi sikhumbuzo izikhathi ezimbili. Ukwengeza, ukudlala kwakhe okuhle kakhulu kulomqhudelwano kwakubalulekile ekutholeni kwakhe iBallon d'Or yesishiyagalombili ngo-2023.

== Ezinye izenzo kanye nezinkinga zomthetho ==
Ngaphandle komkhakha womdlalo, uMessi wayengomunye wezinkanyezi zomzimba ezinkulu emhlabeni. Ngokuhlangene nemiholo yebhola, eyayivame ukuba nezezakhiwo ezimbili ezinkulu kakhulu zabadlali bezemidlalo bonke, waba ngumkhangisi ophumelelayo wemikhiqizo, ikakhulukazi kwenkampani yezimpahla zezemidlalo i-Adidas. Ngo-2013, uMessi kanye no-ubaba wakhe (ophatha izimali zomfana wakhe) babhekene necala lokugwema intela, behlonipha izinkampani zomphakathi zasephesheya ukuze bagweme ukukhokha u-€4.2 million ezintela zaseSpain kumholo wokukhangisa. Nokho, ngemuva kokukhokha €5 million kuMbuso waseSpain, bobabili bakhishwa ukuba babhekane necala ngo-2016. NgoJulayi walowo nyaka, uMessi no-ubaba wakhe bathola isijeziso sokuhlala ezinyangeni ezimisiwe zomlomo wesigwebo esingaphansi kweminyaka emibili, futhi bathola izijeziso zentela zangu-€2 million no-€1.5 million, ngokulandelana.

== Iinkomba ==
{{Reflist}}

== Izixhumanisi zangaphandle ==
* [[File:Commons-logo.svg|link=https://commons.wikimedia.org/wiki/Category:Lionel_Messi?uselang=ty|18x18px]] Wikimedia Commons inayo amadokhumenti wemidiya '''''[[commons:Category:Lionel_Messi|ngoLionel Messi]]'''''.
* [[File:Wikiquote-logo.svg|link=https://en.wikiquote.org/wiki/David_Woodard?uselang=ty|16x16px]] Wikiquote: '''''[[wikiquote:Lionel_Messi|Lionel Messi]]''''' ([[:ty:Reo_Paratāne|en]])
* [[File:Echo_global_icon.svg|link=https://messi.com/|13x13px]] [https://messi.com/ Isiteji Esisemthethweni]
''[https://nr.wikipedia.org/ Abahleli beWikipedia]''</text>
      <sha1>31idio5umvp4owxz0an7m0mioes18yb</sha1>
    </revision>
  </page>
  <page>
    <title>Indlebe</title>
    <ns>0</ns>
    <id>403</id>
    <revision>
      <id>2073</id>
      <timestamp>2024-11-21T13:27:43Z</timestamp>
      <contributor>
        <username>Hope A Ncube</username>
        <id>186</id>
      </contributor>
      <comment>Created by translating the opening section from the page &quot;[[:en:Special:Redirect/revision/1249190715|Ear]]&quot;</comment>
      <origin>2073</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="180" sha1="t22bhpwhw9avgith0nyjhgpzaj0dy58" xml:space="preserve">Indlebe yisitho somzimba esivumela ukuthi umuntu azwe. Njoba ngaphandle yendlebe iyiyo ebonakalayo esegcekeni ezidalweni, ibala elithi indlebe liyandise ukutsho ingaphandle kuphela</text>
      <sha1>t22bhpwhw9avgith0nyjhgpzaj0dy58</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi asiqongelane:Bobbyshabangu</title>
    <ns>3</ns>
    <id>404</id>
    <revision>
      <id>2096</id>
      <timestamp>2024-11-23T11:22:49Z</timestamp>
      <contributor>
        <username>SGill (WMF)</username>
        <id>192</id>
      </contributor>
      <comment>/* [Request for Interview] Future of Language Incubation in Wikimedia */ new section</comment>
      <origin>2096</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="649" sha1="eurq6a0l1bpgcyoeo4bsdt8nl8ogjz9" xml:space="preserve">== [Request for Interview] Future of Language Incubation in Wikimedia ==

Hi @[[Umsebenzisi:Bobbyshabangu|Bobbyshabangu]]

I would like to invite you to a brief 60-minute online interview about your experience with contributing to a new Wikimedia in your language. Your insights will help us improve the process for emerging language communities.

Please let me know if you're available for a Google Meet call during the upcoming week between '''25th to 30th November 2024'''. I am available at '''sgill@wikimedia.org'''.

Thanks

[[Umsebenzisi:SGill (WMF)|SGill (WMF)]] ([[Umsebenzisi asiqongelane:SGill (WMF)|talk]]) 13:22, 23 November 2024 (SAST)</text>
      <sha1>eurq6a0l1bpgcyoeo4bsdt8nl8ogjz9</sha1>
    </revision>
    <revision>
      <id>2097</id>
      <parentid>2096</parentid>
      <timestamp>2024-11-24T02:23:25Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>/* [Request for Interview] Future of Language Incubation in Wikimedia */ Reply</comment>
      <origin>2097</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="927" sha1="efb0rx15gu3k0gqpyv2jj997q99vrkj" xml:space="preserve">== [Request for Interview] Future of Language Incubation in Wikimedia ==

Hi @[[Umsebenzisi:Bobbyshabangu|Bobbyshabangu]]

I would like to invite you to a brief 60-minute online interview about your experience with contributing to a new Wikimedia in your language. Your insights will help us improve the process for emerging language communities.

Please let me know if you're available for a Google Meet call during the upcoming week between '''25th to 30th November 2024'''. I am available at '''sgill@wikimedia.org'''.

Thanks

[[Umsebenzisi:SGill (WMF)|SGill (WMF)]] ([[Umsebenzisi asiqongelane:SGill (WMF)|talk]]) 13:22, 23 November 2024 (SAST)

:@[[Umsebenzisi:SGill (WMF)|SGill (WMF)]] Sure I will be happy to do an interview. I’ll send you my email to continue these conversations over there. [[Umsebenzisi:Bobbyshabangu|Bobbyshabangu]] ([[Umsebenzisi asiqongelane:Bobbyshabangu|talk]]) 04:23, 24 November 2024 (SAST)</text>
      <sha1>efb0rx15gu3k0gqpyv2jj997q99vrkj</sha1>
    </revision>
    <revision>
      <id>2113</id>
      <parentid>2097</parentid>
      <timestamp>2024-11-25T12:27:04Z</timestamp>
      <contributor>
        <username>SGill (WMF)</username>
        <id>192</id>
      </contributor>
      <comment>/* [Request for Interview] Future of Language Incubation in Wikimedia */ Reply</comment>
      <origin>2113</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1145" sha1="8nix45glpzhwxxe5s1pd1oo0639to0o" xml:space="preserve">== [Request for Interview] Future of Language Incubation in Wikimedia ==

Hi @[[Umsebenzisi:Bobbyshabangu|Bobbyshabangu]]

I would like to invite you to a brief 60-minute online interview about your experience with contributing to a new Wikimedia in your language. Your insights will help us improve the process for emerging language communities.

Please let me know if you're available for a Google Meet call during the upcoming week between '''25th to 30th November 2024'''. I am available at '''sgill@wikimedia.org'''.

Thanks

[[Umsebenzisi:SGill (WMF)|SGill (WMF)]] ([[Umsebenzisi asiqongelane:SGill (WMF)|talk]]) 13:22, 23 November 2024 (SAST)

:@[[Umsebenzisi:SGill (WMF)|SGill (WMF)]] Sure I will be happy to do an interview. I’ll send you my email to continue these conversations over there. [[Umsebenzisi:Bobbyshabangu|Bobbyshabangu]] ([[Umsebenzisi asiqongelane:Bobbyshabangu|talk]]) 04:23, 24 November 2024 (SAST)
::@[[Umsebenzisi:Bobbyshabangu|Bobbyshabangu]] Thank you. Looking forward to hear from you soon :) [[Umsebenzisi:SGill (WMF)|SGill (WMF)]] ([[Umsebenzisi asiqongelane:SGill (WMF)|talk]]) 14:27, 25 November 2024 (SAST)</text>
      <sha1>8nix45glpzhwxxe5s1pd1oo0639to0o</sha1>
    </revision>
    <revision>
      <id>2153</id>
      <parentid>2113</parentid>
      <timestamp>2024-11-27T01:36:33Z</timestamp>
      <contributor>
        <username>SGill (WMF)</username>
        <id>192</id>
      </contributor>
      <comment>/* [Request for Interview] Future of Language Incubation in Wikimedia */ Reply</comment>
      <origin>2153</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1491" sha1="shha7vtve6cl3z9wc79j3tae7ggqnc2" xml:space="preserve">== [Request for Interview] Future of Language Incubation in Wikimedia ==

Hi @[[Umsebenzisi:Bobbyshabangu|Bobbyshabangu]]

I would like to invite you to a brief 60-minute online interview about your experience with contributing to a new Wikimedia in your language. Your insights will help us improve the process for emerging language communities.

Please let me know if you're available for a Google Meet call during the upcoming week between '''25th to 30th November 2024'''. I am available at '''sgill@wikimedia.org'''.

Thanks

[[Umsebenzisi:SGill (WMF)|SGill (WMF)]] ([[Umsebenzisi asiqongelane:SGill (WMF)|talk]]) 13:22, 23 November 2024 (SAST)

:@[[Umsebenzisi:SGill (WMF)|SGill (WMF)]] Sure I will be happy to do an interview. I’ll send you my email to continue these conversations over there. [[Umsebenzisi:Bobbyshabangu|Bobbyshabangu]] ([[Umsebenzisi asiqongelane:Bobbyshabangu|talk]]) 04:23, 24 November 2024 (SAST)
::@[[Umsebenzisi:Bobbyshabangu|Bobbyshabangu]] Thank you. Looking forward to hear from you soon :) [[Umsebenzisi:SGill (WMF)|SGill (WMF)]] ([[Umsebenzisi asiqongelane:SGill (WMF)|talk]]) 14:27, 25 November 2024 (SAST)
:::@[[Umsebenzisi:Bobbyshabangu|Bobbyshabangu]] I tried getting in touch with you via Email. Are you able to write to me at '''sgill@wikimedia.org'''? I am hoping to do this interview by 30th November 2024. Thank you so much. -[[Umsebenzisi:SGill (WMF)|SGill (WMF)]] ([[Umsebenzisi asiqongelane:SGill (WMF)|talk]]) 03:36, 27 November 2024 (SAST)</text>
      <sha1>shha7vtve6cl3z9wc79j3tae7ggqnc2</sha1>
    </revision>
    <revision>
      <id>2285</id>
      <parentid>2153</parentid>
      <timestamp>2024-12-20T22:23:46Z</timestamp>
      <contributor>
        <ip>2A04:4A43:88CF:F206:657C:7611:54FA:DF05</ip>
      </contributor>
      <comment>/* [Request for Interview] Future of Language Incubation in Wikimedia */ Reply</comment>
      <origin>2285</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1662" sha1="89990j2x3tmu2zf59kev0j8qvv5gdae" xml:space="preserve">== [Request for Interview] Future of Language Incubation in Wikimedia ==

Hi @[[Umsebenzisi:Bobbyshabangu|Bobbyshabangu]]

I would like to invite you to a brief 60-minute online interview about your experience with contributing to a new Wikimedia in your language. Your insights will help us improve the process for emerging language communities.

Please let me know if you're available for a Google Meet call during the upcoming week between '''25th to 30th November 2024'''. I am available at '''sgill@wikimedia.org'''.

Thanks

[[Umsebenzisi:SGill (WMF)|SGill (WMF)]] ([[Umsebenzisi asiqongelane:SGill (WMF)|talk]]) 13:22, 23 November 2024 (SAST)

:@[[Umsebenzisi:SGill (WMF)|SGill (WMF)]] Sure I will be happy to do an interview. I’ll send you my email to continue these conversations over there. [[Umsebenzisi:Bobbyshabangu|Bobbyshabangu]] ([[Umsebenzisi asiqongelane:Bobbyshabangu|talk]]) 04:23, 24 November 2024 (SAST)
::@[[Umsebenzisi:Bobbyshabangu|Bobbyshabangu]] Thank you. Looking forward to hear from you soon :) [[Umsebenzisi:SGill (WMF)|SGill (WMF)]] ([[Umsebenzisi asiqongelane:SGill (WMF)|talk]]) 14:27, 25 November 2024 (SAST)
:::@[[Umsebenzisi:Bobbyshabangu|Bobbyshabangu]] I tried getting in touch with you via Email. Are you able to write to me at '''sgill@wikimedia.org'''? I am hoping to do this interview by 30th November 2024. Thank you so much. -[[Umsebenzisi:SGill (WMF)|SGill (WMF)]] ([[Umsebenzisi asiqongelane:SGill (WMF)|talk]]) 03:36, 27 November 2024 (SAST)
:my god shut up no one cares [[Khethekileko:Contributions/2A04:4A43:88CF:F206:657C:7611:54FA:DF05|2A04:4A43:88CF:F206:657C:7611:54FA:DF05]] 00:23, 21 December 2024 (SAST)</text>
      <sha1>89990j2x3tmu2zf59kev0j8qvv5gdae</sha1>
    </revision>
    <revision>
      <id>2286</id>
      <parentid>2285</parentid>
      <timestamp>2024-12-20T22:24:42Z</timestamp>
      <contributor>
        <ip>2A04:4A43:88CF:F206:657C:7611:54FA:DF05</ip>
      </contributor>
      <origin>2286</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3837" sha1="6kjvq6s22c0dysowad8q03ut01ulj09" xml:space="preserve">Saudi Arabia, officially the Kingdom of Saudi Arabia, is a country in West Asia and the Middle East. It covers the bulk of the Arabian Peninsula and has a land area of about 2150000 km2 (830000 sq mi), making it the fifth-largest country in Asia and the largest in the Middle East. It is bordered by the Red Sea to the west; Jordan, Iraq, and Kuwait to the north; the Persian Gulf, Bahrain, Qatar and the United Arab Emirates to the east; Oman to the southeast; and Yemen to the south. The Gulf of Aqaba in the northwest separates Saudi Arabia from Egypt and Israel. Saudi Arabia is the only country with a coastline along both the Red Sea and the Persian Gulf, and most of its terrain consists of arid desert, lowland, steppe, and mountains. The capital and largest city is Riyadh; other major cities include Jeddah and the two holiest cities in Islam, Mecca and Medina. With a population of 32.2 million, Saudi Arabia is the fourth most populous country in the Arab world.

Pre-Islamic Arabia, the territory that constitutes modern-day Saudi Arabia, has some of the earliest traces of human activity outside Africa. Islam, the world's second-largest religion, emerged in what is now Saudi Arabia in the early seventh century. Islamic prophet Muhammad united the population of the Arabian Peninsula and created a single Islamic religious polity. Following his death in 632, his followers expanded Muslim rule beyond Arabia, conquering territories in North Africa, Central, South Asia and Iberia within decades. Arab dynasties originating from modern-day Saudi Arabia founded the Rashidun (632–661), Umayyad (661–750), Abbasid (750–1517), and Fatimid (909–1171) caliphates, as well as numerous other dynasties in Asia, Africa, and Europe.

The Kingdom of Saudi Arabia was founded in 1932 by King Abdulaziz (also known as Ibn Saud), who united the regions of Hejaz, Najd, parts of Eastern Arabia (Al-Ahsa) and South Arabia ('Asir) into a single state through a series of conquests, beginning in 1902 with the capture of Riyadh, the ancestral home of his family, the House of Saud. Saudi Arabia has since been an absolute monarchy governed by an authoritarian regime without public input. In its Basic Law, Saudi Arabia defines itself as a sovereign Arab Islamic state with Islam as its official religion and Arabic as its official language. The ultraconservative Wahhabi religious movement within Sunni Islam was the prevailing political and cultural force in the country until the 2000s. The Saudi government has attracted criticism for various policies such as its intervention in the Yemeni Civil War, alleged sponsorship of terrorism, and widespread human rights abuses.

Saudi Arabia is considered both a regional and middle power. Since petroleum was discovered in the country in 1938, the kingdom has become the world's third-largest oil producer and leading oil exporter, controlling the world's second-largest oil reserves and the sixth-largest gas reserves. Saudi Arabia is categorized as a World Bank high-income economy and is the only Arab country among the G20 major economies. The Saudi economy is the largest in the Middle East and the world's nineteenth largest by nominal GDP and seventeenth largest by PPP. Ranking very high in the Human Development Index, Saudi Arabia offers tuition-free university education, no personal income tax, and free universal health care. With its dependency on foreign labour, Saudi Arabia has the world's third-largest immigrant population. Saudi Arabians are among the world's youngest people, with approximately half being under 25 years old. Saudi Arabia is an active and founding member of the Gulf Cooperation Council, United Nations, Organisation of Islamic Cooperation, Arab League, and OPEC, as well as a dialogue partner of the Shanghai Cooperation Organisation.
fuck you</text>
      <sha1>6kjvq6s22c0dysowad8q03ut01ulj09</sha1>
    </revision>
    <revision>
      <id>2287</id>
      <parentid>2286</parentid>
      <timestamp>2024-12-20T22:24:52Z</timestamp>
      <contributor>
        <ip>2A04:4A43:88CF:F206:657C:7611:54FA:DF05</ip>
      </contributor>
      <origin>2287</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3839" sha1="iztzmvqbcgo7qfqxro6q5qsiuctjq4r" xml:space="preserve">Saudi Arabia, officially the Kingdom of Saudi Arabia, is a country in West Asia and the Middle East. It covers the bulk of the Arabian Peninsula and has a land area of about 2150000 km2 (830000 sq mi), making it the fifth-largest country in Asia and the largest in the Middle East. It is bordered by the Red Sea to the west; Jordan, Iraq, and Kuwait to the north; the Persian Gulf, Bahrain, Qatar and the United Arab Emirates to the east; Oman to the southeast; and Yemen to the south. The Gulf of Aqaba in the northwest separates Saudi Arabia from Egypt and Israel. Saudi Arabia is the only country with a coastline along both the Red Sea and the Persian Gulf, and most of its terrain consists of arid desert, lowland, steppe, and mountains. The capital and largest city is Riyadh; other major cities include Jeddah and the two holiest cities in Islam, Mecca and Medina. With a population of 32.2 million, Saudi Arabia is the fourth most populous country in the Arab world.

Pre-Islamic Arabia, the territory that constitutes modern-day Saudi Arabia, has some of the earliest traces of human activity outside Africa. Islam, the world's second-largest religion, emerged in what is now Saudi Arabia in the early seventh century. Islamic prophet Muhammad united the population of the Arabian Peninsula and created a single Islamic religious polity. Following his death in 632, his followers expanded Muslim rule beyond Arabia, conquering territories in North Africa, Central, South Asia and Iberia within decades. Arab dynasties originating from modern-day Saudi Arabia founded the Rashidun (632–661), Umayyad (661–750), Abbasid (750–1517), and Fatimid (909–1171) caliphates, as well as numerous other dynasties in Asia, Africa, and Europe.

The Kingdom of Saudi Arabia was founded in 1932 by King Abdulaziz (also known as Ibn Saud), who united the regions of Hejaz, Najd, parts of Eastern Arabia (Al-Ahsa) and South Arabia ('Asir) into a single state through a series of conquests, beginning in 1902 with the capture of Riyadh, the ancestral home of his family, the House of Saud. Saudi Arabia has since been an absolute monarchy governed by an authoritarian regime without public input. In its Basic Law, Saudi Arabia defines itself as a sovereign Arab Islamic state with Islam as its official religion and Arabic as its official language. The ultraconservative Wahhabi religious movement within Sunni Islam was the prevailing political and cultural force in the country until the 2000s. The Saudi government has attracted criticism for various policies such as its intervention in the Yemeni Civil War, alleged sponsorship of terrorism, and widespread human rights abuses.

Saudi Arabia is considered both a regional and middle power. Since petroleum was discovered in the country in 1938, the kingdom has become the world's third-largest oil producer and leading oil exporter, controlling the world's second-largest oil reserves and the sixth-largest gas reserves. Saudi Arabia is categorized as a World Bank high-income economy and is the only Arab country among the G20 major economies. The Saudi economy is the largest in the Middle East and the world's nineteenth largest by nominal GDP and seventeenth largest by PPP. Ranking very high in the Human Development Index, Saudi Arabia offers tuition-free university education, no personal income tax, and free universal health care. With its dependency on foreign labour, Saudi Arabia has the world's third-largest immigrant population. Saudi Arabians are among the world's youngest people, with approximately half being under 25 years old. Saudi Arabia is an active and founding member of the Gulf Cooperation Council, United Nations, Organisation of Islamic Cooperation, Arab League, and OPEC, as well as a dialogue partner of the Shanghai Cooperation Organisation.


fuck you</text>
      <sha1>iztzmvqbcgo7qfqxro6q5qsiuctjq4r</sha1>
    </revision>
    <revision>
      <id>2288</id>
      <parentid>2287</parentid>
      <timestamp>2024-12-20T22:25:23Z</timestamp>
      <contributor>
        <ip>2A04:4A43:88CF:F206:657C:7611:54FA:DF05</ip>
      </contributor>
      <comment>/* should you kys */ new section</comment>
      <origin>2288</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4019" sha1="1gw8kk5flhnx80zc3x7p53j0gyhd8rg" xml:space="preserve">Saudi Arabia, officially the Kingdom of Saudi Arabia, is a country in West Asia and the Middle East. It covers the bulk of the Arabian Peninsula and has a land area of about 2150000 km2 (830000 sq mi), making it the fifth-largest country in Asia and the largest in the Middle East. It is bordered by the Red Sea to the west; Jordan, Iraq, and Kuwait to the north; the Persian Gulf, Bahrain, Qatar and the United Arab Emirates to the east; Oman to the southeast; and Yemen to the south. The Gulf of Aqaba in the northwest separates Saudi Arabia from Egypt and Israel. Saudi Arabia is the only country with a coastline along both the Red Sea and the Persian Gulf, and most of its terrain consists of arid desert, lowland, steppe, and mountains. The capital and largest city is Riyadh; other major cities include Jeddah and the two holiest cities in Islam, Mecca and Medina. With a population of 32.2 million, Saudi Arabia is the fourth most populous country in the Arab world.

Pre-Islamic Arabia, the territory that constitutes modern-day Saudi Arabia, has some of the earliest traces of human activity outside Africa. Islam, the world's second-largest religion, emerged in what is now Saudi Arabia in the early seventh century. Islamic prophet Muhammad united the population of the Arabian Peninsula and created a single Islamic religious polity. Following his death in 632, his followers expanded Muslim rule beyond Arabia, conquering territories in North Africa, Central, South Asia and Iberia within decades. Arab dynasties originating from modern-day Saudi Arabia founded the Rashidun (632–661), Umayyad (661–750), Abbasid (750–1517), and Fatimid (909–1171) caliphates, as well as numerous other dynasties in Asia, Africa, and Europe.

The Kingdom of Saudi Arabia was founded in 1932 by King Abdulaziz (also known as Ibn Saud), who united the regions of Hejaz, Najd, parts of Eastern Arabia (Al-Ahsa) and South Arabia ('Asir) into a single state through a series of conquests, beginning in 1902 with the capture of Riyadh, the ancestral home of his family, the House of Saud. Saudi Arabia has since been an absolute monarchy governed by an authoritarian regime without public input. In its Basic Law, Saudi Arabia defines itself as a sovereign Arab Islamic state with Islam as its official religion and Arabic as its official language. The ultraconservative Wahhabi religious movement within Sunni Islam was the prevailing political and cultural force in the country until the 2000s. The Saudi government has attracted criticism for various policies such as its intervention in the Yemeni Civil War, alleged sponsorship of terrorism, and widespread human rights abuses.

Saudi Arabia is considered both a regional and middle power. Since petroleum was discovered in the country in 1938, the kingdom has become the world's third-largest oil producer and leading oil exporter, controlling the world's second-largest oil reserves and the sixth-largest gas reserves. Saudi Arabia is categorized as a World Bank high-income economy and is the only Arab country among the G20 major economies. The Saudi economy is the largest in the Middle East and the world's nineteenth largest by nominal GDP and seventeenth largest by PPP. Ranking very high in the Human Development Index, Saudi Arabia offers tuition-free university education, no personal income tax, and free universal health care. With its dependency on foreign labour, Saudi Arabia has the world's third-largest immigrant population. Saudi Arabians are among the world's youngest people, with approximately half being under 25 years old. Saudi Arabia is an active and founding member of the Gulf Cooperation Council, United Nations, Organisation of Islamic Cooperation, Arab League, and OPEC, as well as a dialogue partner of the Shanghai Cooperation Organisation.


fuck you

== should you kys ==

yes you should [[Khethekileko:Contributions/2A04:4A43:88CF:F206:657C:7611:54FA:DF05|2A04:4A43:88CF:F206:657C:7611:54FA:DF05]] 00:25, 21 December 2024 (SAST)</text>
      <sha1>1gw8kk5flhnx80zc3x7p53j0gyhd8rg</sha1>
    </revision>
    <revision>
      <id>2291</id>
      <parentid>2288</parentid>
      <timestamp>2024-12-20T23:03:28Z</timestamp>
      <contributor>
        <username>Codename Noreste</username>
        <id>261</id>
      </contributor>
      <minor />
      <comment>Reverting vandalism.</comment>
      <origin>2291</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1491" sha1="shha7vtve6cl3z9wc79j3tae7ggqnc2" xml:space="preserve">== [Request for Interview] Future of Language Incubation in Wikimedia ==

Hi @[[Umsebenzisi:Bobbyshabangu|Bobbyshabangu]]

I would like to invite you to a brief 60-minute online interview about your experience with contributing to a new Wikimedia in your language. Your insights will help us improve the process for emerging language communities.

Please let me know if you're available for a Google Meet call during the upcoming week between '''25th to 30th November 2024'''. I am available at '''sgill@wikimedia.org'''.

Thanks

[[Umsebenzisi:SGill (WMF)|SGill (WMF)]] ([[Umsebenzisi asiqongelane:SGill (WMF)|talk]]) 13:22, 23 November 2024 (SAST)

:@[[Umsebenzisi:SGill (WMF)|SGill (WMF)]] Sure I will be happy to do an interview. I’ll send you my email to continue these conversations over there. [[Umsebenzisi:Bobbyshabangu|Bobbyshabangu]] ([[Umsebenzisi asiqongelane:Bobbyshabangu|talk]]) 04:23, 24 November 2024 (SAST)
::@[[Umsebenzisi:Bobbyshabangu|Bobbyshabangu]] Thank you. Looking forward to hear from you soon :) [[Umsebenzisi:SGill (WMF)|SGill (WMF)]] ([[Umsebenzisi asiqongelane:SGill (WMF)|talk]]) 14:27, 25 November 2024 (SAST)
:::@[[Umsebenzisi:Bobbyshabangu|Bobbyshabangu]] I tried getting in touch with you via Email. Are you able to write to me at '''sgill@wikimedia.org'''? I am hoping to do this interview by 30th November 2024. Thank you so much. -[[Umsebenzisi:SGill (WMF)|SGill (WMF)]] ([[Umsebenzisi asiqongelane:SGill (WMF)|talk]]) 03:36, 27 November 2024 (SAST)</text>
      <sha1>shha7vtve6cl3z9wc79j3tae7ggqnc2</sha1>
    </revision>
    <revision>
      <id>2607</id>
      <parentid>2291</parentid>
      <timestamp>2025-03-27T18:52:12Z</timestamp>
      <contributor>
        <username>MediaWiki message delivery</username>
        <id>195</id>
      </contributor>
      <comment>/* Invitation to connect with fellow contributors from language onboarding experiment */ new section</comment>
      <origin>2607</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3376" sha1="ju5wvd0hvkwhz06786n83p30yg7sz2t" xml:space="preserve">== [Request for Interview] Future of Language Incubation in Wikimedia ==

Hi @[[Umsebenzisi:Bobbyshabangu|Bobbyshabangu]]

I would like to invite you to a brief 60-minute online interview about your experience with contributing to a new Wikimedia in your language. Your insights will help us improve the process for emerging language communities.

Please let me know if you're available for a Google Meet call during the upcoming week between '''25th to 30th November 2024'''. I am available at '''sgill@wikimedia.org'''.

Thanks

[[Umsebenzisi:SGill (WMF)|SGill (WMF)]] ([[Umsebenzisi asiqongelane:SGill (WMF)|talk]]) 13:22, 23 November 2024 (SAST)

:@[[Umsebenzisi:SGill (WMF)|SGill (WMF)]] Sure I will be happy to do an interview. I’ll send you my email to continue these conversations over there. [[Umsebenzisi:Bobbyshabangu|Bobbyshabangu]] ([[Umsebenzisi asiqongelane:Bobbyshabangu|talk]]) 04:23, 24 November 2024 (SAST)
::@[[Umsebenzisi:Bobbyshabangu|Bobbyshabangu]] Thank you. Looking forward to hear from you soon :) [[Umsebenzisi:SGill (WMF)|SGill (WMF)]] ([[Umsebenzisi asiqongelane:SGill (WMF)|talk]]) 14:27, 25 November 2024 (SAST)
:::@[[Umsebenzisi:Bobbyshabangu|Bobbyshabangu]] I tried getting in touch with you via Email. Are you able to write to me at '''sgill@wikimedia.org'''? I am hoping to do this interview by 30th November 2024. Thank you so much. -[[Umsebenzisi:SGill (WMF)|SGill (WMF)]] ([[Umsebenzisi asiqongelane:SGill (WMF)|talk]]) 03:36, 27 November 2024 (SAST)

== Invitation to connect with fellow contributors from language onboarding experiment ==

Hello,

Hope this message finds you well! I would like to invite you to a community conversation to connect with fellow contributors from pilot wikis (Southern Ndebele, Tai Nüa, Iban, Obolo, Pannonian Rusyn) that graduated through a [https://diff.wikimedia.org/2024/10/31/wikipedia-goes-live-for-five-languages-through-the-future-of-language-incubation-initiative/ Language Onboarding Experiment] last year. In this conversation, we plan to facilitate sharing learnings, discussing technical needs post-graduation, and collaborating on solving challenges faced by the pilot wikis.

We spoke with a few contributors from these wikis back in December, and their valuable input on contributions has given us some perspectives on what to investigate next. A report will soon be published on those learnings. We hope that this meeting will not only be a great opportunity for us to come together and learn from each other but also allow us to use your valuable input to shape our plans for the coming year!
If you can attend the call, please sign up here, and I will share more details later:

* [https://www.mediawiki.org/wiki/Language_Onboarding_and_Development/Community_conversations_2024-25#5_April_2025_01:00_UTC 5 April 2025, 01:00 UTC]
* [https://www.mediawiki.org/wiki/Language_Onboarding_and_Development/Community_conversations_2024-25#4_April_2025_15:00_UTC 4 April 2025, 15:00 UTC]

Looking forward to your participation!

Cheers, [[User:SSethi (WMF)]] via [[Umsebenzisi:MediaWiki message delivery|MediaWiki message delivery]] ([[Umsebenzisi asiqongelane:MediaWiki message delivery|talk]]) 20:52, 27 Mbimbitho 2025 (SAST)
&lt;!-- Message sent by User:SSethi (WMF)@metawiki using the list at https://meta.wikimedia.org/w/index.php?title=User:SSethi_(WMF)/MassMessageList&amp;oldid=28454981 --&gt;</text>
      <sha1>ju5wvd0hvkwhz06786n83p30yg7sz2t</sha1>
    </revision>
    <revision>
      <id>5160</id>
      <parentid>2607</parentid>
      <timestamp>2025-08-14T13:26:20Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>/* Invitation to connect with fellow contributors from language onboarding experiment */ Reply</comment>
      <origin>5160</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3589" sha1="bdcdx1mdx9dembuxaaryc3iz50mmu2y" xml:space="preserve">== [Request for Interview] Future of Language Incubation in Wikimedia ==

Hi @[[Umsebenzisi:Bobbyshabangu|Bobbyshabangu]]

I would like to invite you to a brief 60-minute online interview about your experience with contributing to a new Wikimedia in your language. Your insights will help us improve the process for emerging language communities.

Please let me know if you're available for a Google Meet call during the upcoming week between '''25th to 30th November 2024'''. I am available at '''sgill@wikimedia.org'''.

Thanks

[[Umsebenzisi:SGill (WMF)|SGill (WMF)]] ([[Umsebenzisi asiqongelane:SGill (WMF)|talk]]) 13:22, 23 November 2024 (SAST)

:@[[Umsebenzisi:SGill (WMF)|SGill (WMF)]] Sure I will be happy to do an interview. I’ll send you my email to continue these conversations over there. [[Umsebenzisi:Bobbyshabangu|Bobbyshabangu]] ([[Umsebenzisi asiqongelane:Bobbyshabangu|talk]]) 04:23, 24 November 2024 (SAST)
::@[[Umsebenzisi:Bobbyshabangu|Bobbyshabangu]] Thank you. Looking forward to hear from you soon :) [[Umsebenzisi:SGill (WMF)|SGill (WMF)]] ([[Umsebenzisi asiqongelane:SGill (WMF)|talk]]) 14:27, 25 November 2024 (SAST)
:::@[[Umsebenzisi:Bobbyshabangu|Bobbyshabangu]] I tried getting in touch with you via Email. Are you able to write to me at '''sgill@wikimedia.org'''? I am hoping to do this interview by 30th November 2024. Thank you so much. -[[Umsebenzisi:SGill (WMF)|SGill (WMF)]] ([[Umsebenzisi asiqongelane:SGill (WMF)|talk]]) 03:36, 27 November 2024 (SAST)

== Invitation to connect with fellow contributors from language onboarding experiment ==

Hello,

Hope this message finds you well! I would like to invite you to a community conversation to connect with fellow contributors from pilot wikis (Southern Ndebele, Tai Nüa, Iban, Obolo, Pannonian Rusyn) that graduated through a [https://diff.wikimedia.org/2024/10/31/wikipedia-goes-live-for-five-languages-through-the-future-of-language-incubation-initiative/ Language Onboarding Experiment] last year. In this conversation, we plan to facilitate sharing learnings, discussing technical needs post-graduation, and collaborating on solving challenges faced by the pilot wikis.

We spoke with a few contributors from these wikis back in December, and their valuable input on contributions has given us some perspectives on what to investigate next. A report will soon be published on those learnings. We hope that this meeting will not only be a great opportunity for us to come together and learn from each other but also allow us to use your valuable input to shape our plans for the coming year!
If you can attend the call, please sign up here, and I will share more details later:

* [https://www.mediawiki.org/wiki/Language_Onboarding_and_Development/Community_conversations_2024-25#5_April_2025_01:00_UTC 5 April 2025, 01:00 UTC]
* [https://www.mediawiki.org/wiki/Language_Onboarding_and_Development/Community_conversations_2024-25#4_April_2025_15:00_UTC 4 April 2025, 15:00 UTC]

Looking forward to your participation!

Cheers, [[User:SSethi (WMF)]] via [[Umsebenzisi:MediaWiki message delivery|MediaWiki message delivery]] ([[Umsebenzisi asiqongelane:MediaWiki message delivery|talk]]) 20:52, 27 Mbimbitho 2025 (SAST)
&lt;!-- Message sent by User:SSethi (WMF)@metawiki using the list at https://meta.wikimedia.org/w/index.php?title=User:SSethi_(WMF)/MassMessageList&amp;oldid=28454981 --&gt;
:I missed this, I hope there will be another iteration so that I may be able to join. [[Umsebenzisi:Bobbyshabangu|Bobbyshabangu]] ([[Umsebenzisi asiqongelane:Bobbyshabangu|talk]]) 15:26, 14 Ncwabakazi 2025 (SAST)</text>
      <sha1>bdcdx1mdx9dembuxaaryc3iz50mmu2y</sha1>
    </revision>
  </page>
  <page>
    <title>Angola</title>
    <ns>0</ns>
    <id>407</id>
    <revision>
      <id>2230</id>
      <timestamp>2024-12-04T00:09:08Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1261035720|Angola]]&quot;</comment>
      <origin>2230</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1653" sha1="a1r7588utbthgcxttcu35tgdcbjmrei" xml:space="preserve">
'''I-Angola''',  ngokusemthethweni '''iRiphabhliki ye-Angola''', lilizwe elise-west-central coast ye-Southern Africa. Lilizwe lesibili ngobukhulu elikhuluma [[isiPutukezi]] ngobukhulu nabantu begodu lilizwe lesikhombisa ngobukhulu e-Afrika. Inomngcele nge-Namibia ngeSewula, i-[[Democratic Republic of the Congo]] ngetlhagwini, i-[[Zambia]] ngepumalanga, kanye ne-Atlantic Ocean ngeTjingalanga. I-[[Angola]] inephrovinsi ye-exclave, iphrovinsi ye-Cabinda, enomngcele we-Republic of the Congo kanye ne-Democratic Republic of the Congo. Inhlokodolobha nedorobha elinabantu abanengi khulu yi-Luanda.&lt;ref&gt;https://www.statista.com/topics/4143/angola/&lt;/ref&gt;

Ngemva kobana ukwanda kwamaBantu kufikelele esifundeni, imibuso yabunjwa ngekhulu le-13 begodu yahlelwa yaba ziinhlangano ezihlangeneko. UmBuso we-Kongo wakhuphuka ukufikelela ubukhosi hlangana neminye imibuso kusukela ngekhulu le-14. Abahloli bamaPutukezi basungula ubudlelwano ne-Kongo ngo-1483. Ngesewula bekunemibuso ye-Ndongo ne-Matamba, nemibuso ye-Ovimbundu ngaseningizimu, kanye ne-Mbunda Kingdom ngepumalanga&lt;ref&gt;https://www.statista.com/topics/4143/angola/&lt;/ref&gt;

== I-Etymology ==
Ibizo elithi Angola livela ebizweni lamaPutukezi elithi Reino de Angola ('Umbuso we-Angola'), elavela ekuthomeni komtlolo ka-Paulo Dias de Novais wango-1571. Ibizo lendawo lathathwa maPutukezi ngesihloko esithi ngola, ebegade siphethwe ziinkosi zeNdongo nezeMatamba. I-Ndongo eendaweni eziphakemeko, hlangana nemilambo i-Kwanza ne-Lucala, beyiyindawo yoMbuso we-Kongo. Kodwana ngekhulu le-16 bekufuna ukuzijamela okukhulu.&lt;ref&gt;https://www.bbc.com/news/world-africa-13036732&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}</text>
      <sha1>a1r7588utbthgcxttcu35tgdcbjmrei</sha1>
    </revision>
    <revision>
      <id>2231</id>
      <parentid>2230</parentid>
      <timestamp>2024-12-04T00:11:05Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2231</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1681" sha1="gaj9i30npmz4nkarm8rd8k6pre9y5td" xml:space="preserve">
'''I-Angola''',  ngokusemthethweni '''iRiphabhliki ye-Angola''', lilizwe elise-west-central coast ye-Southern Africa. Lilizwe lesibili ngobukhulu elikhuluma [[isiPutukezi]] ngobukhulu nabantu begodu lilizwe lesikhombisa ngobukhulu e-Afrika. Inomngcele nge-Namibia ngeSewula, i-[[Democratic Republic of the Congo]] ngetlhagwini, i-[[Zambia]] ngepumalanga, kanye ne-Atlantic Ocean ngeTjingalanga. I-[[Angola]] inephrovinsi ye-exclave, iphrovinsi ye-Cabinda, enomngcele we-Republic of the Congo kanye ne-Democratic Republic of the Congo. Inhlokodolobha nedorobha elinabantu abanengi khulu yi-Luanda.&lt;ref&gt;https://www.statista.com/topics/4143/angola/&lt;/ref&gt;

Ngemva kobana ukwanda kwamaBantu kufikelele esifundeni, imibuso yabunjwa ngekhulu le-13 begodu yahlelwa yaba ziinhlangano ezihlangeneko. UmBuso we-Kongo wakhuphuka ukufikelela ubukhosi hlangana neminye imibuso kusukela ngekhulu le-14. Abahloli bamaPutukezi basungula ubudlelwano ne-Kongo ngo-1483. Ngesewula bekunemibuso ye-Ndongo ne-Matamba, nemibuso ye-Ovimbundu ngaseningizimu, kanye ne-Mbunda Kingdom ngepumalanga&lt;ref&gt;https://www.statista.com/topics/4143/angola/&lt;/ref&gt;

== I-Etymology ==
Ibizo elithi Angola livela ebizweni lamaPutukezi elithi Reino de Angola ('Umbuso we-Angola'), elavela ekuthomeni komtlolo ka-Paulo Dias de Novais wango-1571. Ibizo lendawo lathathwa maPutukezi ngesihloko esithi ngola, ebegade siphethwe ziinkosi zeNdongo nezeMatamba. I-Ndongo eendaweni eziphakemeko, hlangana nemilambo i-Kwanza ne-Lucala, beyiyindawo yoMbuso we-Kongo. Kodwana ngekhulu le-16 bekufuna ukuzijamela okukhulu.&lt;ref&gt;https://www.bbc.com/news/world-africa-13036732&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}
[[Mkhakha:Iinarha zephasi]]</text>
      <sha1>gaj9i30npmz4nkarm8rd8k6pre9y5td</sha1>
    </revision>
    <revision>
      <id>2284</id>
      <parentid>2231</parentid>
      <timestamp>2024-12-20T22:22:51Z</timestamp>
      <contributor>
        <ip>2A04:4A43:88CF:F206:657C:7611:54FA:DF05</ip>
      </contributor>
      <comment>Replaced content with &quot;jejejejejeejjejejejeejjejeejejej&quot;</comment>
      <origin>2284</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="32" sha1="e4uv6laim5yxy8f6igy1bhhhtjed9mg" xml:space="preserve">jejejejejeejjejejejeejjejeejejej</text>
      <sha1>e4uv6laim5yxy8f6igy1bhhhtjed9mg</sha1>
    </revision>
    <revision>
      <id>2290</id>
      <parentid>2284</parentid>
      <timestamp>2024-12-20T23:02:06Z</timestamp>
      <contributor>
        <username>Codename Noreste</username>
        <id>261</id>
      </contributor>
      <minor />
      <comment>Undo revision [[Special:Diff/2284|2284]] by [[Special:Contributions/2A04:4A43:88CF:F206:657C:7611:54FA:DF05|2A04:4A43:88CF:F206:657C:7611:54FA:DF05]] ([[User talk:2A04:4A43:88CF:F206:657C:7611:54FA:DF05|talk]])</comment>
      <origin>2290</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1681" sha1="gaj9i30npmz4nkarm8rd8k6pre9y5td" xml:space="preserve">
'''I-Angola''',  ngokusemthethweni '''iRiphabhliki ye-Angola''', lilizwe elise-west-central coast ye-Southern Africa. Lilizwe lesibili ngobukhulu elikhuluma [[isiPutukezi]] ngobukhulu nabantu begodu lilizwe lesikhombisa ngobukhulu e-Afrika. Inomngcele nge-Namibia ngeSewula, i-[[Democratic Republic of the Congo]] ngetlhagwini, i-[[Zambia]] ngepumalanga, kanye ne-Atlantic Ocean ngeTjingalanga. I-[[Angola]] inephrovinsi ye-exclave, iphrovinsi ye-Cabinda, enomngcele we-Republic of the Congo kanye ne-Democratic Republic of the Congo. Inhlokodolobha nedorobha elinabantu abanengi khulu yi-Luanda.&lt;ref&gt;https://www.statista.com/topics/4143/angola/&lt;/ref&gt;

Ngemva kobana ukwanda kwamaBantu kufikelele esifundeni, imibuso yabunjwa ngekhulu le-13 begodu yahlelwa yaba ziinhlangano ezihlangeneko. UmBuso we-Kongo wakhuphuka ukufikelela ubukhosi hlangana neminye imibuso kusukela ngekhulu le-14. Abahloli bamaPutukezi basungula ubudlelwano ne-Kongo ngo-1483. Ngesewula bekunemibuso ye-Ndongo ne-Matamba, nemibuso ye-Ovimbundu ngaseningizimu, kanye ne-Mbunda Kingdom ngepumalanga&lt;ref&gt;https://www.statista.com/topics/4143/angola/&lt;/ref&gt;

== I-Etymology ==
Ibizo elithi Angola livela ebizweni lamaPutukezi elithi Reino de Angola ('Umbuso we-Angola'), elavela ekuthomeni komtlolo ka-Paulo Dias de Novais wango-1571. Ibizo lendawo lathathwa maPutukezi ngesihloko esithi ngola, ebegade siphethwe ziinkosi zeNdongo nezeMatamba. I-Ndongo eendaweni eziphakemeko, hlangana nemilambo i-Kwanza ne-Lucala, beyiyindawo yoMbuso we-Kongo. Kodwana ngekhulu le-16 bekufuna ukuzijamela okukhulu.&lt;ref&gt;https://www.bbc.com/news/world-africa-13036732&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}
[[Mkhakha:Iinarha zephasi]]</text>
      <sha1>gaj9i30npmz4nkarm8rd8k6pre9y5td</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Isewula Afrika</title>
    <ns>14</ns>
    <id>408</id>
    <revision>
      <id>2244</id>
      <timestamp>2024-12-04T00:25:08Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created blank page</comment>
      <origin>2244</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
  </page>
  <page>
    <title>Iphasi (iplanethi)</title>
    <ns>0</ns>
    <id>409</id>
    <revision>
      <id>2246</id>
      <timestamp>2024-12-04T13:01:15Z</timestamp>
      <contributor>
        <ip>152.110.154.92</ip>
      </contributor>
      <comment>Created page with &quot;[[File:The Earth seen from Apollo 17.jpg|thumb|301x301px]] '''Iphasi''' liplanethi yesithathu ukusuka eLangeni begodu yiyo kwaphela into yeenkwekwezi eyaziwako bona inepilo. Lokhu kwenziwa kukuthi iPhasi liyiphasi elilwandle, elilodwa ehlelweni lelanga eliphethe amanzi angaphezulu kwamanzi. Pheze woke amanzi wephasi aselwandle lwawo, amboza ama-70.8% we-Earth's crust. I-29.2% eseleko ye-Earth crust yindawo, inengi layo itholakala ngendlela yamazwekazi ngaphakathi kwe-hem...&quot;</comment>
      <origin>2246</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="995" sha1="h2ov0bps25lnjlplzbqra6q2ekkk7ia" xml:space="preserve">[[File:The Earth seen from Apollo 17.jpg|thumb|301x301px]]
'''Iphasi''' liplanethi yesithathu ukusuka eLangeni begodu yiyo kwaphela into yeenkwekwezi eyaziwako bona inepilo. Lokhu kwenziwa kukuthi iPhasi liyiphasi elilwandle, elilodwa ehlelweni lelanga eliphethe amanzi angaphezulu kwamanzi. Pheze woke amanzi wephasi aselwandle lwawo, amboza ama-70.8% we-Earth's crust. I-29.2% eseleko ye-Earth crust yindawo, inengi layo itholakala ngendlela yamazwekazi ngaphakathi kwe-hemisphere yephasi. Inengi lephasi lephasi linomswakama begodu limbozwe ziintjalo, ngesikhathi amashidi amakhulu weqhwa eenkangala ze-polar zephasi agcina amanzi amanengi ukudlula amanzi wephasi, amachibi, imilambo namanzi womkhathi ahlanganisiwe. I-crust yephasi inamapuleti we-tectonic akhamba kabuthaka, ahlangana ukukhiqiza iintaba, iintaba-mlilo, nokusikinyeka kwephasi. Iphasi linomgogodla wangaphandle owuketshezi okhiqiza i-magnetosphere ekwazi ukuphambukisa imimoya eminengi yelanga ebhubhisako nemisebe ye-cosmic.</text>
      <sha1>h2ov0bps25lnjlplzbqra6q2ekkk7ia</sha1>
    </revision>
    <revision>
      <id>6294</id>
      <parentid>2246</parentid>
      <timestamp>2026-03-13T12:34:53Z</timestamp>
      <contributor>
        <username>Kwamikagami</username>
        <id>1412</id>
      </contributor>
      <origin>6294</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1005" sha1="lpoeqhr5rc04fioyewe2c1365fqdhp2" xml:space="preserve">[[File:Meteosat-12-fci-march-equinox-2025-noon.jpg|thumb|301x301px]]
'''Iphasi''' liplanethi yesithathu ukusuka eLangeni begodu yiyo kwaphela into yeenkwekwezi eyaziwako bona inepilo. Lokhu kwenziwa kukuthi iPhasi liyiphasi elilwandle, elilodwa ehlelweni lelanga eliphethe amanzi angaphezulu kwamanzi. Pheze woke amanzi wephasi aselwandle lwawo, amboza ama-70.8% we-Earth's crust. I-29.2% eseleko ye-Earth crust yindawo, inengi layo itholakala ngendlela yamazwekazi ngaphakathi kwe-hemisphere yephasi. Inengi lephasi lephasi linomswakama begodu limbozwe ziintjalo, ngesikhathi amashidi amakhulu weqhwa eenkangala ze-polar zephasi agcina amanzi amanengi ukudlula amanzi wephasi, amachibi, imilambo namanzi womkhathi ahlanganisiwe. I-crust yephasi inamapuleti we-tectonic akhamba kabuthaka, ahlangana ukukhiqiza iintaba, iintaba-mlilo, nokusikinyeka kwephasi. Iphasi linomgogodla wangaphandle owuketshezi okhiqiza i-magnetosphere ekwazi ukuphambukisa imimoya eminengi yelanga ebhubhisako nemisebe ye-cosmic.</text>
      <sha1>lpoeqhr5rc04fioyewe2c1365fqdhp2</sha1>
    </revision>
    <revision>
      <id>6295</id>
      <parentid>6294</parentid>
      <timestamp>2026-03-13T12:35:28Z</timestamp>
      <contributor>
        <username>Kwamikagami</username>
        <id>1412</id>
      </contributor>
      <origin>6295</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1002" sha1="pu7nyqzqjcllagfk33ti50k6kf85cvw" xml:space="preserve">[[File:Meteosat-12-fci-march-equinox-2025-noon.jpg|thumb|Iphasi]]
'''Iphasi''' liplanethi yesithathu ukusuka eLangeni begodu yiyo kwaphela into yeenkwekwezi eyaziwako bona inepilo. Lokhu kwenziwa kukuthi iPhasi liyiphasi elilwandle, elilodwa ehlelweni lelanga eliphethe amanzi angaphezulu kwamanzi. Pheze woke amanzi wephasi aselwandle lwawo, amboza ama-70.8% we-Earth's crust. I-29.2% eseleko ye-Earth crust yindawo, inengi layo itholakala ngendlela yamazwekazi ngaphakathi kwe-hemisphere yephasi. Inengi lephasi lephasi linomswakama begodu limbozwe ziintjalo, ngesikhathi amashidi amakhulu weqhwa eenkangala ze-polar zephasi agcina amanzi amanengi ukudlula amanzi wephasi, amachibi, imilambo namanzi womkhathi ahlanganisiwe. I-crust yephasi inamapuleti we-tectonic akhamba kabuthaka, ahlangana ukukhiqiza iintaba, iintaba-mlilo, nokusikinyeka kwephasi. Iphasi linomgogodla wangaphandle owuketshezi okhiqiza i-magnetosphere ekwazi ukuphambukisa imimoya eminengi yelanga ebhubhisako nemisebe ye-cosmic.</text>
      <sha1>pu7nyqzqjcllagfk33ti50k6kf85cvw</sha1>
    </revision>
    <revision>
      <id>6296</id>
      <parentid>6295</parentid>
      <timestamp>2026-03-13T12:38:20Z</timestamp>
      <contributor>
        <username>Kwamikagami</username>
        <id>1412</id>
      </contributor>
      <origin>6296</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1062" sha1="6eqyye81z9lamzissn13tz1ik2wz21p" xml:space="preserve">[[File:Meteosat-12-fci-march-equinox-2025-noon.jpg|thumb|Iphasi]]
'''Iphasi''' (uphawu: [[File:Earth symbol (fixed width).svg|16px|🜨]]) liplanethi yesithathu ukusuka eLangeni begodu yiyo kwaphela into yeenkwekwezi eyaziwako bona inepilo. Lokhu kwenziwa kukuthi iPhasi liyiphasi elilwandle, elilodwa ehlelweni lelanga eliphethe amanzi angaphezulu kwamanzi. Pheze woke amanzi wephasi aselwandle lwawo, amboza ama-70.8% we-Earth's crust. I-29.2% eseleko ye-Earth crust yindawo, inengi layo itholakala ngendlela yamazwekazi ngaphakathi kwe-hemisphere yephasi. Inengi lephasi lephasi linomswakama begodu limbozwe ziintjalo, ngesikhathi amashidi amakhulu weqhwa eenkangala ze-polar zephasi agcina amanzi amanengi ukudlula amanzi wephasi, amachibi, imilambo namanzi womkhathi ahlanganisiwe. I-crust yephasi inamapuleti we-tectonic akhamba kabuthaka, ahlangana ukukhiqiza iintaba, iintaba-mlilo, nokusikinyeka kwephasi. Iphasi linomgogodla wangaphandle owuketshezi okhiqiza i-magnetosphere ekwazi ukuphambukisa imimoya eminengi yelanga ebhubhisako nemisebe ye-cosmic.</text>
      <sha1>6eqyye81z9lamzissn13tz1ik2wz21p</sha1>
    </revision>
  </page>
  <page>
    <title>Ilimi lesiNgisi</title>
    <ns>0</ns>
    <id>411</id>
    <revision>
      <id>2248</id>
      <timestamp>2024-12-06T22:15:20Z</timestamp>
      <contributor>
        <ip>152.110.154.92</ip>
      </contributor>
      <comment>Created page with &quot;[[File:Anglospeak (subnational version).svg|thumb|472x472px]] '''Ilimi IsiNgisi''' le-West Germanic emndenini welimi le-Indo-European, lapho abakhulumi balo, ababizwa ngokuthi ma-Anglophones, bavela e-England yesikhathi esiphakathi esiqhingini se-Great Britain. Igama elifana nelimi ngama-Angles, omunye wabantu bakade be-Germanic abafudukela e-Britain. Lilimi elikhulunywa khulu ephasini, khulukhulu ngebanga lomthelela wephasi loke we-Britain Empire (eyalandelwa yi-Commonw...&quot;</comment>
      <origin>2248</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="725" sha1="tl2dx70yimxx4jlzei2xlxpidnr1vpf" xml:space="preserve">[[File:Anglospeak (subnational version).svg|thumb|472x472px]]
'''Ilimi IsiNgisi''' le-West Germanic emndenini welimi le-Indo-European, lapho abakhulumi balo, ababizwa ngokuthi ma-Anglophones, bavela e-England yesikhathi esiphakathi esiqhingini se-Great Britain. Igama elifana nelimi ngama-Angles, omunye wabantu bakade be-Germanic abafudukela e-Britain. Lilimi elikhulunywa khulu ephasini, khulukhulu ngebanga lomthelela wephasi loke we-Britain Empire (eyalandelwa yi-Commonwealth of Nations) kanye ne-United States. IsiNgisi lilimi lesithathu elikhulunywa khulu, ngemva kwe-Standard Chinese ne-Spanish; godu lilimi lesibili elifundwa khulu ephasini, elinabantu abanengi abakhuluma ilimi lesibili ukudlula abakhulumi bomdabu.</text>
      <sha1>tl2dx70yimxx4jlzei2xlxpidnr1vpf</sha1>
    </revision>
    <revision>
      <id>2249</id>
      <parentid>2248</parentid>
      <timestamp>2024-12-06T22:15:41Z</timestamp>
      <contributor>
        <ip>152.110.154.92</ip>
      </contributor>
      <origin>2249</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="726" sha1="fktqfjkxfh55ffpr4s3vgbhcu33ei4y" xml:space="preserve">[[File:Anglospeak (subnational version).svg|thumb|472x472px]]
'''Ilimi lesiNgisi''' le-West Germanic emndenini welimi le-Indo-European, lapho abakhulumi balo, ababizwa ngokuthi ma-Anglophones, bavela e-England yesikhathi esiphakathi esiqhingini se-Great Britain. Igama elifana nelimi ngama-Angles, omunye wabantu bakade be-Germanic abafudukela e-Britain. Lilimi elikhulunywa khulu ephasini, khulukhulu ngebanga lomthelela wephasi loke we-Britain Empire (eyalandelwa yi-Commonwealth of Nations) kanye ne-United States. IsiNgisi lilimi lesithathu elikhulunywa khulu, ngemva kwe-Standard Chinese ne-Spanish; godu lilimi lesibili elifundwa khulu ephasini, elinabantu abanengi abakhuluma ilimi lesibili ukudlula abakhulumi bomdabu.</text>
      <sha1>fktqfjkxfh55ffpr4s3vgbhcu33ei4y</sha1>
    </revision>
    <revision>
      <id>3016</id>
      <parentid>2249</parentid>
      <timestamp>2025-06-06T20:27:57Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>ash ketchup</comment>
      <origin>3016</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="807" sha1="ouq8v07tacm5kn9yqmhbtombojw5opf" xml:space="preserve">[[File:Anglospeak (subnational version).svg|thumb|472x472px]]
'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. Ilimi lesiNgisi''' le-West Germanic emndenini welimi le-Indo-European, lapho abakhulumi balo, ababizwa ngokuthi ma-Anglophones, bavela e-England yesikhathi esiphakathi esiqhingini se-Great Britain. Igama elifana nelimi ngama-Angles, omunye wabantu bakade be-Germanic abafudukela e-Britain. Lilimi elikhulunywa khulu ephasini, khulukhulu ngebanga lomthelela wephasi loke we-Britain Empire (eyalandelwa yi-Commonwealth of Nations) kanye ne-United States. IsiNgisi lilimi lesithathu elikhulunywa khulu, ngemva kwe-Standard Chinese ne-Spanish; godu lilimi lesibili elifundwa khulu ephasini, elinabantu abanengi abakhuluma ilimi lesibili ukudlula abakhulumi bomdabu.</text>
      <sha1>ouq8v07tacm5kn9yqmhbtombojw5opf</sha1>
    </revision>
    <revision>
      <id>3111</id>
      <parentid>3016</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:152.110.154.92|152.110.154.92]]</comment>
      <origin>2249</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="726" sha1="fktqfjkxfh55ffpr4s3vgbhcu33ei4y" xml:space="preserve">[[File:Anglospeak (subnational version).svg|thumb|472x472px]]
'''Ilimi lesiNgisi''' le-West Germanic emndenini welimi le-Indo-European, lapho abakhulumi balo, ababizwa ngokuthi ma-Anglophones, bavela e-England yesikhathi esiphakathi esiqhingini se-Great Britain. Igama elifana nelimi ngama-Angles, omunye wabantu bakade be-Germanic abafudukela e-Britain. Lilimi elikhulunywa khulu ephasini, khulukhulu ngebanga lomthelela wephasi loke we-Britain Empire (eyalandelwa yi-Commonwealth of Nations) kanye ne-United States. IsiNgisi lilimi lesithathu elikhulunywa khulu, ngemva kwe-Standard Chinese ne-Spanish; godu lilimi lesibili elifundwa khulu ephasini, elinabantu abanengi abakhuluma ilimi lesibili ukudlula abakhulumi bomdabu.</text>
      <sha1>fktqfjkxfh55ffpr4s3vgbhcu33ei4y</sha1>
    </revision>
    <revision>
      <id>6402</id>
      <parentid>3111</parentid>
      <timestamp>2026-04-13T06:48:42Z</timestamp>
      <contributor>
        <username>Kwamikagami</username>
        <id>1412</id>
      </contributor>
      <origin>6402</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="726" sha1="lljkaljhhd0049hny0iziocw9outv40" xml:space="preserve">[[File:Anglospeak (subnational version).svg|thumb|upright=2]]
'''Ilimi lesiNgisi''' le-West Germanic emndenini welimi le-Indo-European, lapho abakhulumi balo, ababizwa ngokuthi ma-Anglophones, bavela e-England yesikhathi esiphakathi esiqhingini se-Great Britain. Igama elifana nelimi ngama-Angles, omunye wabantu bakade be-Germanic abafudukela e-Britain. Lilimi elikhulunywa khulu ephasini, khulukhulu ngebanga lomthelela wephasi loke we-Britain Empire (eyalandelwa yi-Commonwealth of Nations) kanye ne-United States. IsiNgisi lilimi lesithathu elikhulunywa khulu, ngemva kwe-Standard Chinese ne-Spanish; godu lilimi lesibili elifundwa khulu ephasini, elinabantu abanengi abakhuluma ilimi lesibili ukudlula abakhulumi bomdabu.</text>
      <sha1>lljkaljhhd0049hny0iziocw9outv40</sha1>
    </revision>
  </page>
  <page>
    <title>I-Finland</title>
    <ns>0</ns>
    <id>414</id>
    <revision>
      <id>2253</id>
      <timestamp>2024-12-10T20:12:16Z</timestamp>
      <contributor>
        <ip>152.110.154.92</ip>
      </contributor>
      <comment>Created page with &quot;[[File:Flag of Finland.svg|thumb|362x362px]] '''I-Finland''', ngokusemthethweni iRiphabhliki ye-Finland, lilizwe le-Nordic elise-Northern Europe. Inomngcele we-Sweden ngetlhagwini-Tjingalanga, [[i-Norway]] ngetlhagwini, kanye ne-Russia ngepumalanga, nge-Gulf of Bothnia ngeTjingalanga kanye ne-Gulf of Finland ngesewula, maqondana ne-Estonia. I-Finland inendawo engu-338,145 square kilometers (130,559 sq mi), kufaka hlangana indawo engama-303,815 square kilometers (117,304...&quot;</comment>
      <origin>2253</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="968" sha1="3a572ckja56c269p5qqi2ixmarttcff" xml:space="preserve">[[File:Flag of Finland.svg|thumb|362x362px]]
'''I-Finland''', ngokusemthethweni iRiphabhliki ye-Finland, lilizwe le-Nordic elise-Northern Europe. Inomngcele we-Sweden ngetlhagwini-Tjingalanga, [[i-Norway]] ngetlhagwini, kanye ne-Russia ngepumalanga, nge-Gulf of Bothnia ngeTjingalanga kanye ne-Gulf of Finland ngesewula, maqondana ne-Estonia. I-Finland inendawo engu-338,145 square kilometers (130,559 sq mi), kufaka hlangana indawo engama-303,815 square kilometers (117,304 sq mi), begodu inabantu abaziingidi ezi-5.6. [[I-Helsinki]] lidorobha elikhulu khulu. Inengi labantu ngama-Finland. Iilwimi ezisemthethweni yi-Finnish nesi-Swedish; Amaphesente ama-84.9 wabantu akhuluma ilimi lokuthoma njengelimi labo lebele kuthi amaphesente ama-5.1 akhuluma ilimi lokugcina. Ubujamo bezulu be-Finland buyahluka ukusuka ebujameni obumanzi ngesewula ukuya ebujameni obumanzi enyakatho. Indawo evulekileko yi-boreal forest biome, enamachibi angaphezu kwe-180,000 atlolwe phasi.</text>
      <sha1>3a572ckja56c269p5qqi2ixmarttcff</sha1>
    </revision>
    <revision>
      <id>2927</id>
      <parentid>2253</parentid>
      <timestamp>2025-06-06T17:07:49Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>Penis</comment>
      <origin>2927</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="75" sha1="bff9yj6q87cqvjrgqqkcvhywxp9cbwm" xml:space="preserve">[[File:Flag of Finland.svg|thumb|362x362px|This is a blue plus sign]]
Penis</text>
      <sha1>bff9yj6q87cqvjrgqqkcvhywxp9cbwm</sha1>
    </revision>
    <revision>
      <id>2928</id>
      <parentid>2927</parentid>
      <timestamp>2025-06-06T17:08:14Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>the</comment>
      <origin>2928</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="162" sha1="gwbtz4m8u13uyh6bw2spn6hp7pxln35" xml:space="preserve">[[File:Flag of Finland.svg|thumb|362x362px|This is a blue plus sign]]
'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.''' Penis</text>
      <sha1>gwbtz4m8u13uyh6bw2spn6hp7pxln35</sha1>
    </revision>
    <revision>
      <id>3106</id>
      <parentid>2928</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edits by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:152.110.154.92|152.110.154.92]]</comment>
      <origin>2253</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="968" sha1="3a572ckja56c269p5qqi2ixmarttcff" xml:space="preserve">[[File:Flag of Finland.svg|thumb|362x362px]]
'''I-Finland''', ngokusemthethweni iRiphabhliki ye-Finland, lilizwe le-Nordic elise-Northern Europe. Inomngcele we-Sweden ngetlhagwini-Tjingalanga, [[i-Norway]] ngetlhagwini, kanye ne-Russia ngepumalanga, nge-Gulf of Bothnia ngeTjingalanga kanye ne-Gulf of Finland ngesewula, maqondana ne-Estonia. I-Finland inendawo engu-338,145 square kilometers (130,559 sq mi), kufaka hlangana indawo engama-303,815 square kilometers (117,304 sq mi), begodu inabantu abaziingidi ezi-5.6. [[I-Helsinki]] lidorobha elikhulu khulu. Inengi labantu ngama-Finland. Iilwimi ezisemthethweni yi-Finnish nesi-Swedish; Amaphesente ama-84.9 wabantu akhuluma ilimi lokuthoma njengelimi labo lebele kuthi amaphesente ama-5.1 akhuluma ilimi lokugcina. Ubujamo bezulu be-Finland buyahluka ukusuka ebujameni obumanzi ngesewula ukuya ebujameni obumanzi enyakatho. Indawo evulekileko yi-boreal forest biome, enamachibi angaphezu kwe-180,000 atlolwe phasi.</text>
      <sha1>3a572ckja56c269p5qqi2ixmarttcff</sha1>
    </revision>
  </page>
  <page>
    <title>I-Mexico</title>
    <ns>0</ns>
    <id>415</id>
    <revision>
      <id>2255</id>
      <timestamp>2024-12-10T20:21:19Z</timestamp>
      <contributor>
        <ip>152.110.154.92</ip>
      </contributor>
      <comment>Created page with &quot;[[File:Flag of Mexico.svg|thumb|397x397px]] '''I-Mexico''', ngokusemthethweni yi-'''United Mexican States''', lilizwe elisesewula ye-North America. Ihlanganisa i-1,972,550 km2 (761,610 sq mi), lilizwe le-13 ngobukhulu ephasini ngendawo; enenani labantu elingaba ziingidi ezili-130, lilizwe le-10 elinabantu abanengi begodu linabantu abanengi abakhuluma isiSpanishi ephasini.[1] I-Mexico yiriphabliki yomthethosisekelo ehlanganisa amazwe ama-31 kanye ne-Mexico City, ikosikazi...&quot;</comment>
      <origin>2255</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="785" sha1="rk0dac9tkt01qcbpfvuq4tcn58geamp" xml:space="preserve">[[File:Flag of Mexico.svg|thumb|397x397px]]
'''I-Mexico''', ngokusemthethweni yi-'''United Mexican States''', lilizwe elisesewula ye-North America. Ihlanganisa i-1,972,550 km2 (761,610 sq mi), lilizwe le-13 ngobukhulu ephasini ngendawo; enenani labantu elingaba ziingidi ezili-130, lilizwe le-10 elinabantu abanengi begodu linabantu abanengi abakhuluma isiSpanishi ephasini.[1] I-Mexico yiriphabliki yomthethosisekelo ehlanganisa amazwe ama-31 kanye ne-Mexico City, ikosikazi yayo nedorobha elikhulu, eliphakathi kweendawo ezinabantu abanengi khulu ephasini. Inarha inomngcele we-United States ngetlhagwini; kanye ne-Guatemala ne-Belize ngesewulapumalanga. Inemingcele yelwandle ne-Pacific Ocean ngeTjingalanga, i-Caribbean Sea ngesewulapumalanga, kanye ne-Gulf of Mexico ngepumalanga.</text>
      <sha1>rk0dac9tkt01qcbpfvuq4tcn58geamp</sha1>
    </revision>
    <revision>
      <id>2256</id>
      <parentid>2255</parentid>
      <timestamp>2024-12-10T20:21:50Z</timestamp>
      <contributor>
        <ip>152.110.154.92</ip>
      </contributor>
      <origin>2256</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="782" sha1="1bolh8qpuj7azmdijxt9uy78rdzdn9n" xml:space="preserve">[[File:Flag of Mexico.svg|thumb|397x397px]]
'''I-Mexico''', ngokusemthethweni yi-'''United Mexican States''', lilizwe elisesewula ye-North America. Ihlanganisa i-1,972,550 km2 (761,610 sq mi), lilizwe le-13 ngobukhulu ephasini ngendawo; enenani labantu elingaba ziingidi ezili-130, lilizwe le-10 elinabantu abanengi begodu linabantu abanengi abakhuluma isiSpanishi ephasini. I-Mexico yiriphabliki yomthethosisekelo ehlanganisa amazwe ama-31 kanye ne-Mexico City, ikosikazi yayo nedorobha elikhulu, eliphakathi kweendawo ezinabantu abanengi khulu ephasini. Inarha inomngcele we-United States ngetlhagwini; kanye ne-Guatemala ne-Belize ngesewulapumalanga. Inemingcele yelwandle ne-Pacific Ocean ngeTjingalanga, i-Caribbean Sea ngesewulapumalanga, kanye ne-Gulf of Mexico ngepumalanga.</text>
      <sha1>1bolh8qpuj7azmdijxt9uy78rdzdn9n</sha1>
    </revision>
    <revision>
      <id>2924</id>
      <parentid>2256</parentid>
      <timestamp>2025-06-06T17:06:43Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>I AM EVIL</comment>
      <origin>2924</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="60" sha1="6ekx4oy75snu38req6utnbkl4073gve" xml:space="preserve">Taco nacho burrito chimi changa tequila drugs border hopping</text>
      <sha1>6ekx4oy75snu38req6utnbkl4073gve</sha1>
    </revision>
    <revision>
      <id>2925</id>
      <parentid>2924</parentid>
      <timestamp>2025-06-06T17:07:00Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>bvfd</comment>
      <origin>2925</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="147" sha1="paxldmdn3yv47jx9kcs8h5tayvlp7e6" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.''' Taco nacho burrito chimi changa tequila drugs border hopping</text>
      <sha1>paxldmdn3yv47jx9kcs8h5tayvlp7e6</sha1>
    </revision>
    <revision>
      <id>3138</id>
      <parentid>2925</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edits by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:152.110.154.92|152.110.154.92]]</comment>
      <origin>2256</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="782" sha1="1bolh8qpuj7azmdijxt9uy78rdzdn9n" xml:space="preserve">[[File:Flag of Mexico.svg|thumb|397x397px]]
'''I-Mexico''', ngokusemthethweni yi-'''United Mexican States''', lilizwe elisesewula ye-North America. Ihlanganisa i-1,972,550 km2 (761,610 sq mi), lilizwe le-13 ngobukhulu ephasini ngendawo; enenani labantu elingaba ziingidi ezili-130, lilizwe le-10 elinabantu abanengi begodu linabantu abanengi abakhuluma isiSpanishi ephasini. I-Mexico yiriphabliki yomthethosisekelo ehlanganisa amazwe ama-31 kanye ne-Mexico City, ikosikazi yayo nedorobha elikhulu, eliphakathi kweendawo ezinabantu abanengi khulu ephasini. Inarha inomngcele we-United States ngetlhagwini; kanye ne-Guatemala ne-Belize ngesewulapumalanga. Inemingcele yelwandle ne-Pacific Ocean ngeTjingalanga, i-Caribbean Sea ngesewulapumalanga, kanye ne-Gulf of Mexico ngepumalanga.</text>
      <sha1>1bolh8qpuj7azmdijxt9uy78rdzdn9n</sha1>
    </revision>
  </page>
  <page>
    <title>I-Italy</title>
    <ns>0</ns>
    <id>416</id>
    <revision>
      <id>2257</id>
      <timestamp>2024-12-10T20:26:06Z</timestamp>
      <contributor>
        <ip>152.110.154.92</ip>
      </contributor>
      <comment>Created page with &quot;[[File:Flag of Italy.svg|thumb|346x346px]] '''I-Italy''', ngokusemthethweni nge-Italy Republic, lilizwe eliseSewula neTjingalanga ye-Europe. Inesihlengele esidlulela eLwandle le-Mediterranean, ene-Alps emngceleni wayo wangasenyakatho, kanye neenhlengele ezipheze zibe ma-800, khulukhulu i-Sicily ne-Sardinia. I-Italy yabelana ngemingcele yayo [[i-France]], [[i-Switzerland]], [[i-Austria]], [[i-Slovenia]], kanye nama-enclaves amabili: i-Vatican City ne-San Marino. Lilizwe l...&quot;</comment>
      <origin>2257</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="882" sha1="65cgp2yk47wx7dzh5txsu8811rxuknt" xml:space="preserve">[[File:Flag of Italy.svg|thumb|346x346px]]
'''I-Italy''', ngokusemthethweni nge-Italy Republic, lilizwe eliseSewula neTjingalanga ye-Europe. Inesihlengele esidlulela eLwandle le-Mediterranean, ene-Alps emngceleni wayo wangasenyakatho, kanye neenhlengele ezipheze zibe ma-800, khulukhulu i-Sicily ne-Sardinia. I-Italy yabelana ngemingcele yayo [[i-France]], [[i-Switzerland]], [[i-Austria]], [[i-Slovenia]], kanye nama-enclaves amabili: i-Vatican City ne-San Marino. Lilizwe letshumi ngobukhulu e-Europe ngendawo, lihlanganisa i-301,340 km2 (116,350 sq mi), begodu lililunga lesithathu elinabantu abanengi be-European Union, elinabantu abangaba ziingidi ezima-60. Inhlokodolobha ye-Italy nedorobha elikhulu khulu yi-Rome; ezinye iindawo ezikulu zedorobha zifaka hlangana [[i-Milan]], [[i-Naples]], [[i-Turin]], [[i-Palermo]], [[i-Bologna]], [[i-Florence]], [[i-Genoa]], [[i-Venice]].</text>
      <sha1>65cgp2yk47wx7dzh5txsu8811rxuknt</sha1>
    </revision>
    <revision>
      <id>2258</id>
      <parentid>2257</parentid>
      <timestamp>2024-12-10T20:26:33Z</timestamp>
      <contributor>
        <ip>152.110.154.92</ip>
      </contributor>
      <origin>2258</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="896" sha1="m0gk14zycd91m0k0bfqyf1znjwin2x9" xml:space="preserve">[[File:Flag of Italy.svg|thumb|346x346px]]
'''I-Italy''', ngokusemthethweni nge-Italy Republic, lilizwe eliseSewula neTjingalanga ye-Europe. Inesihlengele esidlulela eLwandle le-Mediterranean, ene-Alps emngceleni wayo wangasenyakatho, kanye neenhlengele ezipheze zibe ma-800, khulukhulu [[i-Sicily]] [[i-Sardinia]]. I-Italy yabelana ngemingcele yayo [[i-France]], [[i-Switzerland]], [[i-Austria]], [[i-Slovenia]], kanye nama-enclaves amabili: [[i-Vatican City]] [[i-San Marino]]. Lilizwe letshumi ngobukhulu e-Europe ngendawo, lihlanganisa i-301,340 km2 (116,350 sq mi), begodu lililunga lesithathu elinabantu abanengi be-European Union, elinabantu abangaba ziingidi ezima-60. Inhlokodolobha ye-Italy nedorobha elikhulu khulu yi-Rome; ezinye iindawo ezikulu zedorobha zifaka hlangana [[i-Milan]], [[i-Naples]], [[i-Turin]], [[i-Palermo]], [[i-Bologna]], [[i-Florence]], [[i-Genoa]], [[i-Venice]].</text>
      <sha1>m0gk14zycd91m0k0bfqyf1znjwin2x9</sha1>
    </revision>
    <revision>
      <id>2915</id>
      <parentid>2258</parentid>
      <timestamp>2025-06-06T16:55:59Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>ASukyjgthdghtfgkh</comment>
      <origin>2915</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="267" sha1="do82d86gk59j3wx2iskcik7hvod0luo" xml:space="preserve">[[File:Flag of Italy.svg|thumb|346x346px]]
'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.'''

* Tralalero Tralala
* Bombardino Crocodillo
* Tung Tung Tung Tung Tung Tung Tung Sahur
* Lirili larila
* Trippi Troppi
* Bonecu Ambalabu</text>
      <sha1>do82d86gk59j3wx2iskcik7hvod0luo</sha1>
    </revision>
    <revision>
      <id>3015</id>
      <parentid>2915</parentid>
      <timestamp>2025-06-06T20:27:34Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>esxrdctfvygbhuj</comment>
      <origin>3015</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="285" sha1="t37r080k64hj180q7wvzht9iyp6tkyc" xml:space="preserve">[[File:Flag of Italy.svg|thumb|346x346px]]
'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.'''

* Tralalero Tralala
* Bombardino Crocodillo
* Tung Tung Tung Tung Tung Tung Tung Sahur
* Lirili larila
* Trippi Troppi
* Bonecu Ambalabu
* Brr Brr Patapim</text>
      <sha1>t37r080k64hj180q7wvzht9iyp6tkyc</sha1>
    </revision>
    <revision>
      <id>3074</id>
      <parentid>3015</parentid>
      <timestamp>2025-06-07T03:05:22Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edits by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:152.110.154.92|152.110.154.92]]</comment>
      <origin>2258</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="896" sha1="m0gk14zycd91m0k0bfqyf1znjwin2x9" xml:space="preserve">[[File:Flag of Italy.svg|thumb|346x346px]]
'''I-Italy''', ngokusemthethweni nge-Italy Republic, lilizwe eliseSewula neTjingalanga ye-Europe. Inesihlengele esidlulela eLwandle le-Mediterranean, ene-Alps emngceleni wayo wangasenyakatho, kanye neenhlengele ezipheze zibe ma-800, khulukhulu [[i-Sicily]] [[i-Sardinia]]. I-Italy yabelana ngemingcele yayo [[i-France]], [[i-Switzerland]], [[i-Austria]], [[i-Slovenia]], kanye nama-enclaves amabili: [[i-Vatican City]] [[i-San Marino]]. Lilizwe letshumi ngobukhulu e-Europe ngendawo, lihlanganisa i-301,340 km2 (116,350 sq mi), begodu lililunga lesithathu elinabantu abanengi be-European Union, elinabantu abangaba ziingidi ezima-60. Inhlokodolobha ye-Italy nedorobha elikhulu khulu yi-Rome; ezinye iindawo ezikulu zedorobha zifaka hlangana [[i-Milan]], [[i-Naples]], [[i-Turin]], [[i-Palermo]], [[i-Bologna]], [[i-Florence]], [[i-Genoa]], [[i-Venice]].</text>
      <sha1>m0gk14zycd91m0k0bfqyf1znjwin2x9</sha1>
    </revision>
    <revision>
      <id>6748</id>
      <parentid>3074</parentid>
      <timestamp>2026-07-27T07:30:57Z</timestamp>
      <contributor>
        <username>~2026-41898-25</username>
        <id>1656</id>
      </contributor>
      <comment>[[]]</comment>
      <origin>6748</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="894" sha1="t0j1k2ozdes7p5ivtw5tsxzxidpmxkl" xml:space="preserve">[[File:Flag of Italy.svg|thumb|346x346px]]
'''I-Italy''', ngokusemthethweni nge-Italy Republic, lilizwe eliseSewula neTjingalanga ye-Europe. Inesihlengele esidlulela eLwandle le-Mediterranean, ene-Alps emngceleni wayo wangasenyakatho, kanye neenhlengele ezipheze zibe ma-800, khulukhulu [[i-Sicily]] [[i-Sardinia]]. I-Italy yabelana ngemingcele yayo [[France]], [[i-Switzerland]], [[i-Austria]], [[i-Slovenia]], kanye nama-enclaves amabili: [[i-Vatican City]] [[i-San Marino]]. Lilizwe letshumi ngobukhulu e-Europe ngendawo, lihlanganisa i-301,340 km2 (116,350 sq mi), begodu lililunga lesithathu elinabantu abanengi be-European Union, elinabantu abangaba ziingidi ezima-60. Inhlokodolobha ye-Italy nedorobha elikhulu khulu yi-Rome; ezinye iindawo ezikulu zedorobha zifaka hlangana [[i-Milan]], [[i-Naples]], [[i-Turin]], [[i-Palermo]], [[i-Bologna]], [[i-Florence]], [[i-Genoa]], [[i-Venice]].</text>
      <sha1>t0j1k2ozdes7p5ivtw5tsxzxidpmxkl</sha1>
    </revision>
  </page>
  <page>
    <title>Vosloorus</title>
    <ns>0</ns>
    <id>417</id>
    <revision>
      <id>2259</id>
      <timestamp>2024-12-11T08:52:53Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1232736547|Vosloorus]]&quot;</comment>
      <origin>2259</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="602" sha1="erx72z6yg0whk7a7yqz0qznyclztzge" xml:space="preserve">'''I-Vosloorus''' yilokishi elikhulu eliseningizimu ye-[[Boksburg]] kanye nepumalanga ye-Katlehong e-Ekurhuleni, amakhilomitha ama-30 kwaphela eningizimu-mpumalanga ye-Johannesburg, e-Gauteng, e[[Isewula Afrika|Sewula Afrika]]. Yasungulwa ngo-1963 lokha ama-Afrika amnyama nakasuswa e-Stirtonville[1] ngombana gade athathwa ngurhulumende aseduze khulu nedorobha labamhlophe. I-Stirtonville, ebizwa ngokuthi yi-Reiger Park, sele ibe likhaya lomphakathi wemibala we-Boksburg. Igunya lendawo lasungulwa ngo-1983 lokha i-Vosloorus nayinikelwa isikhundla esipheleleko sikamasipala.
[[Mkhakha:Sewula Afrika]]</text>
      <sha1>erx72z6yg0whk7a7yqz0qznyclztzge</sha1>
    </revision>
    <revision>
      <id>2260</id>
      <parentid>2259</parentid>
      <timestamp>2024-12-11T08:55:58Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2260</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="756" sha1="5jktb8472g5rmpc9oor4j4n9dqpwewf" xml:space="preserve">'''I-Vosloorus''' yilokishi elikhulu eliseningizimu ye-[[Boksburg]] kanye nepumalanga ye-Katlehong e-Ekurhuleni, amakhilomitha ama-30 kwaphela eningizimu-mpumalanga ye-Johannesburg, e-Gauteng, e[[Isewula Afrika|Sewula Afrika]]. Yasungulwa ngo-1963 lokha ama-Afrika amnyama nakasuswa e-Stirtonville[1] ngombana gade athathwa ngurhulumende aseduze khulu nedorobha labamhlophe. I-Stirtonville, ebizwa ngokuthi yi-Reiger Park, sele ibe likhaya lomphakathi wemibala we-Boksburg. Igunya lendawo lasungulwa ngo-1983 lokha i-Vosloorus nayinikelwa isikhundla esipheleleko sikamasipala.&lt;ref&gt;https://www.tandfonline.com/doi/abs/10.2989/16073614.2014.992642&lt;/ref&gt;&lt;ref&gt;https://scholar.ufs.ac.za/items/338bd5b8-05a4-47a2-9fcf-45df103d3203&lt;/ref&gt;
[[Mkhakha:Sewula Afrika]]</text>
      <sha1>5jktb8472g5rmpc9oor4j4n9dqpwewf</sha1>
    </revision>
  </page>
  <page>
    <title>IBoksburg</title>
    <ns>0</ns>
    <id>418</id>
    <revision>
      <id>2261</id>
      <timestamp>2024-12-11T09:01:09Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1262035863|Boksburg]]&quot;</comment>
      <origin>2261</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1427" sha1="952k0c16zwz1ffed4svdaa1byw32182" xml:space="preserve">[[Isimumathi:Into_Boksburg_and_ERM.jpg|right|thumb|380x380px|Umthombo netshwayo lokwamukela e-Boksburg phambi kwe-East Rand Mall]]
'''I-Boksburg''' yidorobha elise-[[East Rand]] yesifundazwe se-Gauteng eSewula Afrika. Igolide latholakala e-Boksburg ngo-1887. I-Boksburg yaqanjwa ngegama likaNobhala weNarha we-South African Republic, u-[[W. Eduard Bok]]. Umgwaqo omkhulu we-Main Reef wahlanganisa i-Boksburg nawo woke amanye amadorobha amakhulu wemayini e-Witwatersrand begodu i-[[Angelo Hotel]] (1887) yayisetjenziswa njengendawo yokuhlela.&lt;ref&gt;https://www.sciencedirect.com/science/article/abs/pii/0148906279904832&lt;/ref&gt;&lt;ref&gt;https://sahris.sahra.org.za/sites/default/files/heritagereports/PHASE%201%20HIA%20%20FOR%20THE%20PROPOSED%20UPGRADE%20OF%20THE%20COMET%20SEWERLINE%20APAC02048.pdf&lt;/ref&gt;

== Umlando ==
Ngaphambi kuka-1860, indawo kamasipala yamanje ye-Boksburg kanye neendawo eziseduze kwayo gade ibunjwa khulu mapulazi we-highveld abizwa nge-Leeuwpoort, Klippoortje, Klipfontein kanye ne-Driefontein. U-Carl Ziervogel wathenga iplasi i-Leeuwpoort ngo-1875 begodu nge-300 morgen yendawo engenalutho, enamatje wabhadela i-£75. Ngenyanga kaKhukhulamungu 1886 u-Pieter Killian, umhloli omncani we-Afrikaans, wathola amadwala we-quartz e-Leeuwpoort.&lt;ref&gt;https://sahris.sahra.org.za/sites/default/files/additionaldocs/HERITAGE%20ASSESSMENT%20REPORT%20BOKSBURG%20WEST%20EXT.7%20AND%20LILIANTON%20EXT.7%20APAC01502.pdf&lt;/ref&gt;</text>
      <sha1>952k0c16zwz1ffed4svdaa1byw32182</sha1>
    </revision>
    <revision>
      <id>2262</id>
      <parentid>2261</parentid>
      <timestamp>2024-12-11T09:01:39Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2262</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1442" sha1="mfm88jk1ewnx0wii6znmwxsyy5ssw28" xml:space="preserve">[[Isimumathi:Into_Boksburg_and_ERM.jpg|right|thumb|380x380px|Umthombo netshwayo lokwamukela e-Boksburg phambi kwe-East Rand Mall]]
'''I-Boksburg''' yidorobha elise-[[East Rand]] yesifundazwe se-Gauteng eSewula Afrika. Igolide latholakala e-Boksburg ngo-1887. I-Boksburg yaqanjwa ngegama likaNobhala weNarha we-South African Republic, u-[[W. Eduard Bok]]. Umgwaqo omkhulu we-Main Reef wahlanganisa i-Boksburg nawo woke amanye amadorobha amakhulu wemayini e-Witwatersrand begodu i-[[Angelo Hotel]] (1887) yayisetjenziswa njengendawo yokuhlela.&lt;ref&gt;https://www.sciencedirect.com/science/article/abs/pii/0148906279904832&lt;/ref&gt;&lt;ref&gt;https://sahris.sahra.org.za/sites/default/files/heritagereports/PHASE%201%20HIA%20%20FOR%20THE%20PROPOSED%20UPGRADE%20OF%20THE%20COMET%20SEWERLINE%20APAC02048.pdf&lt;/ref&gt;

== Umlando ==
Ngaphambi kuka-1860, indawo kamasipala yamanje ye-Boksburg kanye neendawo eziseduze kwayo gade ibunjwa khulu mapulazi we-highveld abizwa nge-Leeuwpoort, Klippoortje, Klipfontein kanye ne-Driefontein. U-Carl Ziervogel wathenga iplasi i-Leeuwpoort ngo-1875 begodu nge-300 morgen yendawo engenalutho, enamatje wabhadela i-£75. Ngenyanga kaKhukhulamungu 1886 u-Pieter Killian, umhloli omncani we-Afrikaans, wathola amadwala we-quartz e-Leeuwpoort.&lt;ref&gt;https://sahris.sahra.org.za/sites/default/files/additionaldocs/HERITAGE%20ASSESSMENT%20REPORT%20BOKSBURG%20WEST%20EXT.7%20AND%20LILIANTON%20EXT.7%20APAC01502.pdf&lt;/ref&gt;

== Inkomba ==</text>
      <sha1>mfm88jk1ewnx0wii6znmwxsyy5ssw28</sha1>
    </revision>
    <revision>
      <id>2263</id>
      <parentid>2262</parentid>
      <timestamp>2024-12-11T09:02:18Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2263</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1481" sha1="m8f8w5qr1m03i8oawnmore9td96aatr" xml:space="preserve">[[Isimumathi:Into_Boksburg_and_ERM.jpg|right|thumb|380x380px|Umthombo netshwayo lokwamukela e-Boksburg phambi kwe-East Rand Mall]]
'''I-Boksburg''' yidorobha elise-[[East Rand]] yesifundazwe se-Gauteng eSewula Afrika. Igolide latholakala e-Boksburg ngo-1887. I-Boksburg yaqanjwa ngegama likaNobhala weNarha we-South African Republic, u-[[W. Eduard Bok]]. Umgwaqo omkhulu we-Main Reef wahlanganisa i-Boksburg nawo woke amanye amadorobha amakhulu wemayini e-Witwatersrand begodu i-[[Angelo Hotel]] (1887) yayisetjenziswa njengendawo yokuhlela.&lt;ref&gt;https://www.sciencedirect.com/science/article/abs/pii/0148906279904832&lt;/ref&gt;&lt;ref&gt;https://sahris.sahra.org.za/sites/default/files/heritagereports/PHASE%201%20HIA%20%20FOR%20THE%20PROPOSED%20UPGRADE%20OF%20THE%20COMET%20SEWERLINE%20APAC02048.pdf&lt;/ref&gt;

== Umlando ==
Ngaphambi kuka-1860, indawo kamasipala yamanje ye-Boksburg kanye neendawo eziseduze kwayo gade ibunjwa khulu mapulazi we-highveld abizwa nge-Leeuwpoort, Klippoortje, Klipfontein kanye ne-Driefontein. U-Carl Ziervogel wathenga iplasi i-Leeuwpoort ngo-1875 begodu nge-300 morgen yendawo engenalutho, enamatje wabhadela i-£75. Ngenyanga kaKhukhulamungu 1886 u-Pieter Killian, umhloli omncani we-Afrikaans, wathola amadwala we-quartz e-Leeuwpoort.&lt;ref&gt;https://sahris.sahra.org.za/sites/default/files/additionaldocs/HERITAGE%20ASSESSMENT%20REPORT%20BOKSBURG%20WEST%20EXT.7%20AND%20LILIANTON%20EXT.7%20APAC01502.pdf&lt;/ref&gt;

== Inkomba ==
{{Reflist}}
[[Category:Sewula Afrika]]</text>
      <sha1>m8f8w5qr1m03i8oawnmore9td96aatr</sha1>
    </revision>
    <revision>
      <id>2264</id>
      <parentid>2263</parentid>
      <timestamp>2024-12-11T09:02:44Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2264</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1482" sha1="iarlet24nerwajwur5zz0ojegmu9z9x" xml:space="preserve">[[Isimumathi:Into_Boksburg_and_ERM.jpg|right|thumb|380x380px|Umthombo netshwayo lokwamukela e-Boksburg phambi kwe-East Rand Mall]]
'''I-Boksburg''' yidorobha elise-[[East Rand]] yesifundazwe se-Gauteng eSewula Afrika. Igolide latholakala e-Boksburg ngo-1887. I-Boksburg yaqanjwa ngegama likaNobhala weNarha we-South African Republic, u-[[W. Eduard Bok]]. Umgwaqo omkhulu we-Main Reef wahlanganisa i-Boksburg nawo woke amanye amadorobha amakhulu wemayini e-Witwatersrand begodu i-[[Angelo Hotel]] (1887) yayisetjenziswa njengendawo yokuhlela.&lt;ref&gt;https://www.sciencedirect.com/science/article/abs/pii/0148906279904832&lt;/ref&gt;&lt;ref&gt;https://sahris.sahra.org.za/sites/default/files/heritagereports/PHASE%201%20HIA%20%20FOR%20THE%20PROPOSED%20UPGRADE%20OF%20THE%20COMET%20SEWERLINE%20APAC02048.pdf&lt;/ref&gt;

== Umlando ==
Ngaphambi kuka-1860, indawo kamasipala yamanje ye-Boksburg kanye neendawo eziseduze kwayo gade ibunjwa khulu mapulazi we-highveld abizwa nge-Leeuwpoort, Klippoortje, Klipfontein kanye ne-Driefontein. U-Carl Ziervogel wathenga iplasi i-Leeuwpoort ngo-1875 begodu nge-300 morgen yendawo engenalutho, enamatje wabhadela i-£75. Ngenyanga kaKhukhulamungu 1886 u-Pieter Killian, umhloli omncani we-Afrikaans, wathola amadwala we-quartz e-Leeuwpoort.&lt;ref&gt;https://sahris.sahra.org.za/sites/default/files/additionaldocs/HERITAGE%20ASSESSMENT%20REPORT%20BOKSBURG%20WEST%20EXT.7%20AND%20LILIANTON%20EXT.7%20APAC01502.pdf&lt;/ref&gt;

== Inkomba ==
{{Reflist}}
[[Category:iSewula Afrika]]</text>
      <sha1>iarlet24nerwajwur5zz0ojegmu9z9x</sha1>
    </revision>
    <revision>
      <id>2628</id>
      <parentid>2264</parentid>
      <timestamp>2025-04-03T19:08:55Z</timestamp>
      <contributor>
        <username>Rachmat04</username>
        <id>32</id>
      </contributor>
      <minor />
      <origin>2628</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1482" sha1="b4tpfu0fsbykjuk0h0cv4okb82y8ouq" xml:space="preserve">[[Isimumathi:Into_Boksburg_and_ERM.jpg|right|thumb|380x380px|Umthombo netshwayo lokwamukela e-Boksburg phambi kwe-East Rand Mall]]
'''I-Boksburg''' yidorobha elise-[[East Rand]] yesifundazwe se-Gauteng eSewula Afrika. Igolide latholakala e-Boksburg ngo-1887. I-Boksburg yaqanjwa ngegama likaNobhala weNarha we-South African Republic, u-[[W. Eduard Bok]]. Umgwaqo omkhulu we-Main Reef wahlanganisa i-Boksburg nawo woke amanye amadorobha amakhulu wemayini e-Witwatersrand begodu i-[[Angelo Hotel]] (1887) yayisetjenziswa njengendawo yokuhlela.&lt;ref&gt;https://www.sciencedirect.com/science/article/abs/pii/0148906279904832&lt;/ref&gt;&lt;ref&gt;https://sahris.sahra.org.za/sites/default/files/heritagereports/PHASE%201%20HIA%20%20FOR%20THE%20PROPOSED%20UPGRADE%20OF%20THE%20COMET%20SEWERLINE%20APAC02048.pdf&lt;/ref&gt;

== Umlando ==
Ngaphambi kuka-1860, indawo kamasipala yamanje ye-Boksburg kanye neendawo eziseduze kwayo gade ibunjwa khulu mapulazi we-highveld abizwa nge-Leeuwpoort, Klippoortje, Klipfontein kanye ne-Driefontein. U-Carl Ziervogel wathenga iplasi i-Leeuwpoort ngo-1875 begodu nge-300 morgen yendawo engenalutho, enamatje wabhadela i-£75. Ngenyanga kaKhukhulamungu 1886 u-Pieter Killian, umhloli omncani we-Afrikaans, wathola amadwala we-quartz e-Leeuwpoort.&lt;ref&gt;https://sahris.sahra.org.za/sites/default/files/additionaldocs/HERITAGE%20ASSESSMENT%20REPORT%20BOKSBURG%20WEST%20EXT.7%20AND%20LILIANTON%20EXT.7%20APAC01502.pdf&lt;/ref&gt;

== Inkomba ==
{{Reflist}}

[[Mkhakha:ISewula Afrika]]</text>
      <sha1>b4tpfu0fsbykjuk0h0cv4okb82y8ouq</sha1>
    </revision>
  </page>
  <page>
    <title>Main Page/Did you know</title>
    <ns>0</ns>
    <id>419</id>
    <redirect title="Wikiphidiya:Main Page/Did you know" />
    <revision>
      <id>2266</id>
      <timestamp>2024-12-11T19:31:46Z</timestamp>
      <contributor>
        <username>Таёжный лес</username>
        <id>59</id>
      </contributor>
      <comment>Таёжный лес moved page [[Main Page/Did you know]] to [[Wikiphidiya:Main Page/Did you know]]</comment>
      <origin>2266</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="48" sha1="g3ab7ansdg9qfztcr00sh1f8z1m93gg" xml:space="preserve">#REDIRECT [[Wikiphidiya:Main Page/Did you know]]</text>
      <sha1>g3ab7ansdg9qfztcr00sh1f8z1m93gg</sha1>
    </revision>
  </page>
  <page>
    <title>Godfrey Sapula</title>
    <ns>0</ns>
    <id>420</id>
    <revision>
      <id>2267</id>
      <timestamp>2024-12-12T11:47:17Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1262633359|Godfrey Sapula]]&quot;</comment>
      <origin>2267</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="373" sha1="2e48k7wh7760h7n8fm69dl3pj44gkni" xml:space="preserve">
'''U-Godfrey Zolile Sapula''' (wabelethwa mhlana ali-17 kuNobayeni 1973) bekangumdlali webholo weSewula Afrika owadlala njengomdlali ophakathi. Wadlalela amakilabhu we-Premier Soccer League i-Jomo Cosmos, i-Orlando Pirates, i-Mamelodi Sundowns kanye ne-Platinum Stars, iklabhu ye-Chile Colo-Colo, iklabhu ye-Turkey i-Ankaragücü kanye nesiqhema sesitjhaba seSewula Afrika</text>
      <sha1>2e48k7wh7760h7n8fm69dl3pj44gkni</sha1>
    </revision>
    <revision>
      <id>2268</id>
      <parentid>2267</parentid>
      <timestamp>2024-12-12T11:48:43Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2268</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="391" sha1="mo8i8mt0equw7na7oq94xy8rrtqogw3" xml:space="preserve">
'''U-Godfrey Zolile Sapula''' (wabelethwa mhlana ali-17 kuNobayeni 1973) bekangumdlali webholo weSewula Afrika owadlala njengomdlali ophakathi. Wadlalela amakilabhu we-Premier Soccer League i-Jomo Cosmos, i-Orlando Pirates, i-Mamelodi Sundowns kanye ne-Platinum Stars, iklabhu ye-Chile Colo-Colo, iklabhu ye-Turkey i-Ankaragücü kanye nesiqhema sesitjhaba seSewula Afrika. I

== inkomba ==</text>
      <sha1>mo8i8mt0equw7na7oq94xy8rrtqogw3</sha1>
    </revision>
    <revision>
      <id>2269</id>
      <parentid>2268</parentid>
      <timestamp>2024-12-12T11:49:44Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2269</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="506" sha1="ixzfiw3uoheckwnfem9jgnliys2kkj4" xml:space="preserve">
'''U-Godfrey Zolile Sapula''' (wabelethwa mhlana ali-17 kuNobayeni 1973) bekangumdlali webholo weSewula Afrika owadlala njengomdlali ophakathi. Wadlalela amakilabhu we-Premier Soccer League i-Jomo Cosmos, i-Orlando Pirates, i-Mamelodi Sundowns kanye ne-Platinum Stars, iklabhu ye-Chile Colo-Colo, iklabhu ye-Turkey i-Ankaragücü kanye nesiqhema sesitjhaba seSewula Afrika.&lt;ref&gt;https://briefly.co.za/82461-godfrey-sapula-biography-age-skills-profile-house-latest-news.html&lt;/ref&gt;

== inkomba ==
{{Reflist}}</text>
      <sha1>ixzfiw3uoheckwnfem9jgnliys2kkj4</sha1>
    </revision>
    <revision>
      <id>2270</id>
      <parentid>2269</parentid>
      <timestamp>2024-12-12T11:50:33Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2270</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="514" sha1="9u99rrr0j857ubqygloac4j75ht6psj" xml:space="preserve">
'''U-Godfrey Zolile Sapula''' (wabelethwa mhlana ali-17 kuNobayeni 1973) bekangumdlali webholo weSewula Afrika owadlala njengomdlali ophakathi. Wadlalela amakilabhu we-Premier Soccer League i-Jomo Cosmos, i-[[Orlando Pirates]], i-[[Mamelodi Sundowns]] kanye ne-Platinum Stars, iklabhu ye-Chile Colo-Colo, iklabhu ye-Turkey i-Ankaragücü kanye nesiqhema sesitjhaba seSewula Afrika.&lt;ref&gt;https://briefly.co.za/82461-godfrey-sapula-biography-age-skills-profile-house-latest-news.html&lt;/ref&gt;

== inkomba ==
{{Reflist}}</text>
      <sha1>9u99rrr0j857ubqygloac4j75ht6psj</sha1>
    </revision>
    <revision>
      <id>2271</id>
      <parentid>2270</parentid>
      <timestamp>2024-12-12T11:51:45Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2271</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="542" sha1="sf8m7ipa6bs8ovej88iruz1f9qsbqor" xml:space="preserve">
'''U-Godfrey Zolile Sapula''' (wabelethwa mhlana ali-17 kuNobayeni 1973) bekangumdlali webholo weSewula Afrika owadlala njengomdlali ophakathi. Wadlalela amakilabhu we-Premier Soccer League i-Jomo Cosmos, i-[[Orlando Pirates]], i-[[Mamelodi Sundowns]] kanye ne-Platinum Stars, iklabhu ye-Chile Colo-Colo, iklabhu ye-Turkey i-Ankaragücü kanye nesiqhema sesitjhaba seSewula Afrika.&lt;ref&gt;https://briefly.co.za/82461-godfrey-sapula-biography-age-skills-profile-house-latest-news.html&lt;/ref&gt;

== inkomba ==
{{Reflist}}
[[Category: ISwula Afrika]]</text>
      <sha1>sf8m7ipa6bs8ovej88iruz1f9qsbqor</sha1>
    </revision>
    <revision>
      <id>2272</id>
      <parentid>2271</parentid>
      <timestamp>2024-12-12T11:52:15Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2272</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="561" sha1="fp5u9ia3xxh3zhk2ky867ntj7nxeggu" xml:space="preserve">
'''U-Godfrey Zolile Sapula''' (wabelethwa mhlana ali-17 kuNobayeni 1973) bekangumdlali webholo we[[Isewula Afrika|Sewula Afrika]] owadlala njengomdlali ophakathi. Wadlalela amakilabhu we-Premier Soccer League i-Jomo Cosmos, i-[[Orlando Pirates]], i-[[Mamelodi Sundowns]] kanye ne-Platinum Stars, iklabhu ye-Chile Colo-Colo, iklabhu ye-Turkey i-Ankaragücü kanye nesiqhema sesitjhaba seSewula Afrika.&lt;ref&gt;https://briefly.co.za/82461-godfrey-sapula-biography-age-skills-profile-house-latest-news.html&lt;/ref&gt;

== inkomba ==
{{Reflist}}
[[Category: ISwula Afrika]]</text>
      <sha1>fp5u9ia3xxh3zhk2ky867ntj7nxeggu</sha1>
    </revision>
    <revision>
      <id>2273</id>
      <parentid>2272</parentid>
      <timestamp>2024-12-12T11:52:32Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2273</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="562" sha1="cjx799d2qhg2r885cpo76zn4hw72lrj" xml:space="preserve">
'''U-Godfrey Zolile Sapula''' (wabelethwa mhlana ali-17 kuNobayeni 1973) bekangumdlali webholo we[[Isewula Afrika|Sewula Afrika]] owadlala njengomdlali ophakathi. Wadlalela amakilabhu we-Premier Soccer League i-Jomo Cosmos, i-[[Orlando Pirates]], i-[[Mamelodi Sundowns]] kanye ne-Platinum Stars, iklabhu ye-Chile Colo-Colo, iklabhu ye-Turkey i-Ankaragücü kanye nesiqhema sesitjhaba seSewula Afrika.&lt;ref&gt;https://briefly.co.za/82461-godfrey-sapula-biography-age-skills-profile-house-latest-news.html&lt;/ref&gt;

== inkomba ==
{{Reflist}}
[[Category: ISewula Afrika]]</text>
      <sha1>cjx799d2qhg2r885cpo76zn4hw72lrj</sha1>
    </revision>
    <revision>
      <id>2627</id>
      <parentid>2273</parentid>
      <timestamp>2025-04-03T19:08:45Z</timestamp>
      <contributor>
        <username>Rachmat04</username>
        <id>32</id>
      </contributor>
      <minor />
      <origin>2627</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="560" sha1="kyctnva5yhgy1543gyy2cvstwriv9sx" xml:space="preserve">'''U-Godfrey Zolile Sapula''' (wabelethwa mhlana ali-17 kuNobayeni 1973) bekangumdlali webholo we[[Isewula Afrika|Sewula Afrika]] owadlala njengomdlali ophakathi. Wadlalela amakilabhu we-Premier Soccer League i-Jomo Cosmos, i-[[Orlando Pirates]], i-[[Mamelodi Sundowns]] kanye ne-Platinum Stars, iklabhu ye-Chile Colo-Colo, iklabhu ye-Turkey i-Ankaragücü kanye nesiqhema sesitjhaba seSewula Afrika.&lt;ref&gt;https://briefly.co.za/82461-godfrey-sapula-biography-age-skills-profile-house-latest-news.html&lt;/ref&gt;

== inkomba ==
{{Reflist}}

[[Mkhakha:ISewula Afrika]]</text>
      <sha1>kyctnva5yhgy1543gyy2cvstwriv9sx</sha1>
    </revision>
    <revision>
      <id>2977</id>
      <parentid>2627</parentid>
      <timestamp>2025-06-06T20:05:02Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>,iumyjnhrbtgerfvwe</comment>
      <origin>2977</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="641" sha1="g6qfisncf3xpxx1gsjp7gyxjgl78oml" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. U-Godfrey Zolile Sapula''' (wabelethwa mhlana ali-17 kuNobayeni 1973) bekangumdlali webholo we[[Isewula Afrika|Sewula Afrika]] owadlala njengomdlali ophakathi. Wadlalela amakilabhu we-Premier Soccer League i-Jomo Cosmos, i-[[Orlando Pirates]], i-[[Mamelodi Sundowns]] kanye ne-Platinum Stars, iklabhu ye-Chile Colo-Colo, iklabhu ye-Turkey i-Ankaragücü kanye nesiqhema sesitjhaba seSewula Afrika.&lt;ref&gt;https://briefly.co.za/82461-godfrey-sapula-biography-age-skills-profile-house-latest-news.html&lt;/ref&gt;

== inkomba ==
{{Reflist}}

[[Mkhakha:ISewula Afrika]]</text>
      <sha1>g6qfisncf3xpxx1gsjp7gyxjgl78oml</sha1>
    </revision>
    <revision>
      <id>3079</id>
      <parentid>2977</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Rachmat04|Rachmat04]]</comment>
      <origin>2627</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="560" sha1="kyctnva5yhgy1543gyy2cvstwriv9sx" xml:space="preserve">'''U-Godfrey Zolile Sapula''' (wabelethwa mhlana ali-17 kuNobayeni 1973) bekangumdlali webholo we[[Isewula Afrika|Sewula Afrika]] owadlala njengomdlali ophakathi. Wadlalela amakilabhu we-Premier Soccer League i-Jomo Cosmos, i-[[Orlando Pirates]], i-[[Mamelodi Sundowns]] kanye ne-Platinum Stars, iklabhu ye-Chile Colo-Colo, iklabhu ye-Turkey i-Ankaragücü kanye nesiqhema sesitjhaba seSewula Afrika.&lt;ref&gt;https://briefly.co.za/82461-godfrey-sapula-biography-age-skills-profile-house-latest-news.html&lt;/ref&gt;

== inkomba ==
{{Reflist}}

[[Mkhakha:ISewula Afrika]]</text>
      <sha1>kyctnva5yhgy1543gyy2cvstwriv9sx</sha1>
    </revision>
  </page>
  <page>
    <title>Aaron Rimbui</title>
    <ns>0</ns>
    <id>421</id>
    <revision>
      <id>2274</id>
      <timestamp>2024-12-13T02:50:04Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1261761871|Aaron Rimbui]]&quot;</comment>
      <origin>2274</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1398" sha1="pp5p8ghgky3ipx56ef14ipdpiy92jps" xml:space="preserve">'''U-Aaron Rimbui''' ungumdlali wepiyano, ikhibhodi, umdosiphambili webhendi, umkhiqizi kanye nomgcini weminyanya nomsingathi womrhatjho. Uthathwa njengomunye wabadlali bepiyano abahle khulu be-East Africa.&lt;ref&gt;https://www.standardmedia.co.ke/counties/article/2000091714/why-jazz-is-close-to-my-heart&lt;/ref&gt;&lt;ref&gt;https://www.businessdailyafrica.com/bd/lifestyle/music/pianist-bets-on-his-new-album-to-open-doors-for-kenyans-4806918&lt;/ref&gt;

== Umlando ==
U-Aaron wabelethwa e-Nairobi, e-Kenya. Uyise bekadlala umvumo ukusuka kumarekhodi ka-Stevie Wonder ukuya ku-Henry Mancini bese amthatha amse eendaweni zokudlela zendawo lapho bekazwa khona umvumo wamaqembu afana ne-Les Wanyika, i-Maroon Commandos kanye ne-Samba Mapangala. Lokhu kwaba nomthelela omkhulu endleleni athuthukisa ngayo umdumo wakhe eminyakeni eyalandelako. Ukuziveza kwaka-Rimbui emculweni kwaragela phambili nokwakheka eminyakeni yakhe yesikolo samabanga aphezulu. Kungaleso sikhathi lapho athatha khona ipiyano. U-Rimbui wathoma ukuthanda umvumo we-jazz njengombana alalele umvumo ka-David Sanborn, u-Joe Sample, we-Yellowjackets no-Fourplay begodu ngokukhamba kwesikhathi, u-Herbie Hancock no-George Duke. U-Rimbui bekasebenza njengehloko ye-Tusker Project Fame band.&lt;ref&gt;https://www.citizen.digital/entertainment/bien-aaron-rimbui-speak-on-their-musical-chemistry-and-why-bald-men-love-better-n286466&lt;/ref&gt;
[[Mkhakha:Abosaziwako]]</text>
      <sha1>pp5p8ghgky3ipx56ef14ipdpiy92jps</sha1>
    </revision>
    <revision>
      <id>2275</id>
      <parentid>2274</parentid>
      <timestamp>2024-12-13T02:52:55Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2275</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1414" sha1="arh74tnyt5ox36vbj8imtwtgu94ckum" xml:space="preserve">'''U-Aaron Rimbui''' ungumdlali wepiyano, ikhibhodi, umdosiphambili webhendi, umkhiqizi kanye nomgcini weminyanya nomsingathi womrhatjho. Uthathwa njengomunye wabadlali bepiyano abahle khulu be-East Africa.&lt;ref&gt;https://www.standardmedia.co.ke/counties/article/2000091714/why-jazz-is-close-to-my-heart&lt;/ref&gt;&lt;ref&gt;https://www.businessdailyafrica.com/bd/lifestyle/music/pianist-bets-on-his-new-album-to-open-doors-for-kenyans-4806918&lt;/ref&gt;

== Umlando ==
U-Aaron wabelethwa e-Nairobi, e-Kenya. Uyise bekadlala umvumo ukusuka kumarekhodi ka-Stevie Wonder ukuya ku-Henry Mancini bese amthatha amse eendaweni zokudlela zendawo lapho bekazwa khona umvumo wamaqembu afana ne-Les Wanyika, i-Maroon Commandos kanye ne-Samba Mapangala. Lokhu kwaba nomthelela omkhulu endleleni athuthukisa ngayo umdumo wakhe eminyakeni eyalandelako. Ukuziveza kwaka-Rimbui emculweni kwaragela phambili nokwakheka eminyakeni yakhe yesikolo samabanga aphezulu. Kungaleso sikhathi lapho athatha khona ipiyano. U-Rimbui wathoma ukuthanda umvumo we-jazz njengombana alalele umvumo ka-David Sanborn, u-Joe Sample, we-Yellowjackets no-Fourplay begodu ngokukhamba kwesikhathi, u-Herbie Hancock no-George Duke. U-Rimbui bekasebenza njengehloko ye-Tusker Project Fame band.&lt;ref&gt;https://www.citizen.digital/entertainment/bien-aaron-rimbui-speak-on-their-musical-chemistry-and-why-bald-men-love-better-n286466&lt;/ref&gt;

== Iinkomba ==
[[Mkhakha:Abosaziwako]]</text>
      <sha1>arh74tnyt5ox36vbj8imtwtgu94ckum</sha1>
    </revision>
    <revision>
      <id>2276</id>
      <parentid>2275</parentid>
      <timestamp>2024-12-13T02:53:58Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2276</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1422" sha1="dgouuumrwm0jpzznammhwtc3iayu3pc" xml:space="preserve">'''U-Aaron Rimbui''' ungumdlali wepiyano, ikhibhodi, umdosiphambili webhendi, umkhiqizi kanye nomgcini weminyanya nomsingathi womrhatjho. Uthathwa njengomunye wabadlali bepiyano abahle khulu be-East Africa.&lt;ref&gt;https://www.standardmedia.co.ke/counties/article/2000091714/why-jazz-is-close-to-my-heart&lt;/ref&gt;&lt;ref&gt;https://www.businessdailyafrica.com/bd/lifestyle/music/pianist-bets-on-his-new-album-to-open-doors-for-kenyans-4806918&lt;/ref&gt;

== Umlando ==
U-Aaron wabelethwa e-[[Nairobi]], e-[[Kenya]]. Uyise bekadlala umvumo ukusuka kumarekhodi ka-Stevie Wonder ukuya ku-Henry Mancini bese amthatha amse eendaweni zokudlela zendawo lapho bekazwa khona umvumo wamaqembu afana ne-Les Wanyika, i-Maroon Commandos kanye ne-Samba Mapangala. Lokhu kwaba nomthelela omkhulu endleleni athuthukisa ngayo umdumo wakhe eminyakeni eyalandelako. Ukuziveza kwaka-Rimbui emculweni kwaragela phambili nokwakheka eminyakeni yakhe yesikolo samabanga aphezulu. Kungaleso sikhathi lapho athatha khona ipiyano. U-Rimbui wathoma ukuthanda umvumo we-jazz njengombana alalele umvumo ka-David Sanborn, u-Joe Sample, we-Yellowjackets no-Fourplay begodu ngokukhamba kwesikhathi, u-Herbie Hancock no-George Duke. U-Rimbui bekasebenza njengehloko ye-Tusker Project Fame band.&lt;ref&gt;https://www.citizen.digital/entertainment/bien-aaron-rimbui-speak-on-their-musical-chemistry-and-why-bald-men-love-better-n286466&lt;/ref&gt;

== Iinkomba ==
[[Mkhakha:Abosaziwako]]</text>
      <sha1>dgouuumrwm0jpzznammhwtc3iayu3pc</sha1>
    </revision>
    <revision>
      <id>2431</id>
      <parentid>2276</parentid>
      <timestamp>2025-02-18T16:16:11Z</timestamp>
      <contributor>
        <ip>88.238.41.39</ip>
      </contributor>
      <origin>2431</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1463" sha1="r32wh33ycb6grnuyjmpmqzvtzznyjig" xml:space="preserve">'''U-Aaron Rimbui''' ungumdlali wepiyano, ikhibhodi, umdosiphambili webhendi, umkhiqizi kanye nomgcini weminyanya nomsingathi womrhatjho. Uthathwa njengomunye wabadlali bepiyano abahle khulu be-East Africa.&lt;ref&gt;https://www.standardmedia.co.ke/counties/article/2000091714/why-jazz-is-close-to-my-heart&lt;/ref&gt;&lt;ref&gt;https://www.businessdailyafrica.com/bd/lifestyle/music/pianist-bets-on-his-new-album-to-open-doors-for-kenyans-4806918&lt;/ref&gt;

== Umlando ==
U-Aaron wabelethwa e-[[Nairobi]], e-[[Kenya]]. Uyise bekadlala umvumo ukusuka kumarekhodi ka-Stevie Wonder ukuya ku-Henry Mancini bese amthatha amse eendaweni zokudlela zendawo lapho bekazwa khona umvumo wamaqembu afana ne-Les Wanyika, i-Maroon Commandos kanye ne-Samba Mapangala. Lokhu kwaba nomthelela omkhulu endleleni athuthukisa ngayo umdumo wakhe eminyakeni eyalandelako. Ukuziveza kwaka-Rimbui emculweni kwaragela phambili nokwakheka eminyakeni yakhe yesikolo samabanga aphezulu. Kungaleso sikhathi lapho athatha khona ipiyano. U-Rimbui wathoma ukuthanda umvumo we-jazz njengombana alalele umvumo ka-David Sanborn, u-Joe Sample, we-Yellowjackets no-Fourplay begodu ngokukhamba kwesikhathi, u-Herbie Hancock no-George Duke. U-Rimbui bekasebenza njengehloko ye-Tusker Project Fame band.&lt;ref&gt;https://www.citizen.digital/entertainment/bien-aaron-rimbui-speak-on-their-musical-chemistry-and-why-bald-men-love-better-n286466&lt;/ref&gt; [https://www.masaloku.bbs.tr/ masal oku]

== Iinkomba ==
[[Mkhakha:Abosaziwako]]</text>
      <sha1>r32wh33ycb6grnuyjmpmqzvtzznyjig</sha1>
    </revision>
    <revision>
      <id>2820</id>
      <parentid>2431</parentid>
      <timestamp>2025-05-19T00:15:05Z</timestamp>
      <contributor>
        <ip>95.10.0.190</ip>
      </contributor>
      <origin>2820</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1460" sha1="4fdx7pcnbp42ax1g6a52j50vw54goxb" xml:space="preserve">'''U-Aaron Rimbui''' ungumdlali wepiyano, ikhibhodi, umdosiphambili webhendi, umkhiqizi kanye nomgcini weminyanya nomsingathi womrhatjho. Uthathwa njengomunye wabadlali bepiyano abahle khulu be-East Africa.&lt;ref&gt;https://www.standardmedia.co.ke/counties/article/2000091714/why-jazz-is-close-to-my-heart&lt;/ref&gt;&lt;ref&gt;https://www.businessdailyafrica.com/bd/lifestyle/music/pianist-bets-on-his-new-album-to-open-doors-for-kenyans-4806918&lt;/ref&gt;

== Umlando ==
U-Aaron wabelethwa e-[[Nairobi]], e-[[Kenya]]. Uyise bekadlala umvumo ukusuka kumarekhodi ka-Stevie Wonder ukuya ku-Henry Mancini bese amthatha amse eendaweni zokudlela zendawo lapho bekazwa khona umvumo wamaqembu afana ne-Les Wanyika, i-Maroon Commandos kanye ne-Samba Mapangala. Lokhu kwaba nomthelela omkhulu endleleni athuthukisa ngayo umdumo wakhe eminyakeni eyalandelako. Ukuziveza kwaka-Rimbui emculweni kwaragela phambili nokwakheka eminyakeni yakhe yesikolo samabanga aphezulu. Kungaleso sikhathi lapho athatha khona ipiyano. U-Rimbui wathoma ukuthanda umvumo we-jazz njengombana alalele umvumo ka-David Sanborn, u-Joe Sample, we-Yellowjackets no-Fourplay begodu ngokukhamba kwesikhathi, u-Herbie Hancock no-George Duke. U-Rimbui bekasebenza njengehloko ye-Tusker Project Fame band.&lt;ref&gt;https://www.citizen.digital/entertainment/bien-aaron-rimbui-speak-on-their-musical-chemistry-and-why-bald-men-love-better-n286466&lt;/ref&gt; [https://www.masaloku.mobi masal oku]

== Iinkomba ==
[[Mkhakha:Abosaziwako]]</text>
      <sha1>4fdx7pcnbp42ax1g6a52j50vw54goxb</sha1>
    </revision>
    <revision>
      <id>3012</id>
      <parentid>2820</parentid>
      <timestamp>2025-06-06T20:25:34Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>fix this</comment>
      <origin>3012</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1541" sha1="fk4xjjjdwa8rb1hiihrvbflnndkf0za" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. U-Aaron Rimbui''' ungumdlali wepiyano, ikhibhodi, umdosiphambili webhendi, umkhiqizi kanye nomgcini weminyanya nomsingathi womrhatjho. Uthathwa njengomunye wabadlali bepiyano abahle khulu be-East Africa.&lt;ref&gt;https://www.standardmedia.co.ke/counties/article/2000091714/why-jazz-is-close-to-my-heart&lt;/ref&gt;&lt;ref&gt;https://www.businessdailyafrica.com/bd/lifestyle/music/pianist-bets-on-his-new-album-to-open-doors-for-kenyans-4806918&lt;/ref&gt;

== Umlando ==
U-Aaron wabelethwa e-[[Nairobi]], e-[[Kenya]]. Uyise bekadlala umvumo ukusuka kumarekhodi ka-Stevie Wonder ukuya ku-Henry Mancini bese amthatha amse eendaweni zokudlela zendawo lapho bekazwa khona umvumo wamaqembu afana ne-Les Wanyika, i-Maroon Commandos kanye ne-Samba Mapangala. Lokhu kwaba nomthelela omkhulu endleleni athuthukisa ngayo umdumo wakhe eminyakeni eyalandelako. Ukuziveza kwaka-Rimbui emculweni kwaragela phambili nokwakheka eminyakeni yakhe yesikolo samabanga aphezulu. Kungaleso sikhathi lapho athatha khona ipiyano. U-Rimbui wathoma ukuthanda umvumo we-jazz njengombana alalele umvumo ka-David Sanborn, u-Joe Sample, we-Yellowjackets no-Fourplay begodu ngokukhamba kwesikhathi, u-Herbie Hancock no-George Duke. U-Rimbui bekasebenza njengehloko ye-Tusker Project Fame band.&lt;ref&gt;https://www.citizen.digital/entertainment/bien-aaron-rimbui-speak-on-their-musical-chemistry-and-why-bald-men-love-better-n286466&lt;/ref&gt; [https://www.masaloku.mobi masal oku]

== Iinkomba ==
[[Mkhakha:Abosaziwako]]</text>
      <sha1>fk4xjjjdwa8rb1hiihrvbflnndkf0za</sha1>
    </revision>
    <revision>
      <id>3060</id>
      <parentid>3012</parentid>
      <timestamp>2025-06-07T03:05:22Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:95.10.0.190|95.10.0.190]]</comment>
      <origin>2820</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1460" sha1="4fdx7pcnbp42ax1g6a52j50vw54goxb" xml:space="preserve">'''U-Aaron Rimbui''' ungumdlali wepiyano, ikhibhodi, umdosiphambili webhendi, umkhiqizi kanye nomgcini weminyanya nomsingathi womrhatjho. Uthathwa njengomunye wabadlali bepiyano abahle khulu be-East Africa.&lt;ref&gt;https://www.standardmedia.co.ke/counties/article/2000091714/why-jazz-is-close-to-my-heart&lt;/ref&gt;&lt;ref&gt;https://www.businessdailyafrica.com/bd/lifestyle/music/pianist-bets-on-his-new-album-to-open-doors-for-kenyans-4806918&lt;/ref&gt;

== Umlando ==
U-Aaron wabelethwa e-[[Nairobi]], e-[[Kenya]]. Uyise bekadlala umvumo ukusuka kumarekhodi ka-Stevie Wonder ukuya ku-Henry Mancini bese amthatha amse eendaweni zokudlela zendawo lapho bekazwa khona umvumo wamaqembu afana ne-Les Wanyika, i-Maroon Commandos kanye ne-Samba Mapangala. Lokhu kwaba nomthelela omkhulu endleleni athuthukisa ngayo umdumo wakhe eminyakeni eyalandelako. Ukuziveza kwaka-Rimbui emculweni kwaragela phambili nokwakheka eminyakeni yakhe yesikolo samabanga aphezulu. Kungaleso sikhathi lapho athatha khona ipiyano. U-Rimbui wathoma ukuthanda umvumo we-jazz njengombana alalele umvumo ka-David Sanborn, u-Joe Sample, we-Yellowjackets no-Fourplay begodu ngokukhamba kwesikhathi, u-Herbie Hancock no-George Duke. U-Rimbui bekasebenza njengehloko ye-Tusker Project Fame band.&lt;ref&gt;https://www.citizen.digital/entertainment/bien-aaron-rimbui-speak-on-their-musical-chemistry-and-why-bald-men-love-better-n286466&lt;/ref&gt; [https://www.masaloku.mobi masal oku]

== Iinkomba ==
[[Mkhakha:Abosaziwako]]</text>
      <sha1>4fdx7pcnbp42ax1g6a52j50vw54goxb</sha1>
    </revision>
    <revision>
      <id>3195</id>
      <parentid>3060</parentid>
      <timestamp>2025-06-21T19:21:29Z</timestamp>
      <contributor>
        <ip>85.97.84.231</ip>
      </contributor>
      <origin>3195</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1571" sha1="oex3ov2zqul4aviolldw2dc9ckycgci" xml:space="preserve">[[File:Common chimpanzee (Pan troglodytes schweinfurthii) feeding.jpg|thumb|Omar al-Bashir is a chimpanzee.]]

'''U-Aaron Rimbui''' ungumdlali wepiyano, ikhibhodi, umdosiphambili webhendi, umkhiqizi kanye nomgcini weminyanya nomsingathi womrhatjho. Uthathwa njengomunye wabadlali bepiyano abahle khulu be-East Africa.&lt;ref&gt;https://www.standardmedia.co.ke/counties/article/2000091714/why-jazz-is-close-to-my-heart&lt;/ref&gt;&lt;ref&gt;https://www.businessdailyafrica.com/bd/lifestyle/music/pianist-bets-on-his-new-album-to-open-doors-for-kenyans-4806918&lt;/ref&gt;

== Umlando ==
U-Aaron wabelethwa e-[[Nairobi]], e-[[Kenya]]. Uyise bekadlala umvumo ukusuka kumarekhodi ka-Stevie Wonder ukuya ku-Henry Mancini bese amthatha amse eendaweni zokudlela zendawo lapho bekazwa khona umvumo wamaqembu afana ne-Les Wanyika, i-Maroon Commandos kanye ne-Samba Mapangala. Lokhu kwaba nomthelela omkhulu endleleni athuthukisa ngayo umdumo wakhe eminyakeni eyalandelako. Ukuziveza kwaka-Rimbui emculweni kwaragela phambili nokwakheka eminyakeni yakhe yesikolo samabanga aphezulu. Kungaleso sikhathi lapho athatha khona ipiyano. U-Rimbui wathoma ukuthanda umvumo we-jazz njengombana alalele umvumo ka-David Sanborn, u-Joe Sample, we-Yellowjackets no-Fourplay begodu ngokukhamba kwesikhathi, u-Herbie Hancock no-George Duke. U-Rimbui bekasebenza njengehloko ye-Tusker Project Fame band.&lt;ref&gt;https://www.citizen.digital/entertainment/bien-aaron-rimbui-speak-on-their-musical-chemistry-and-why-bald-men-love-better-n286466&lt;/ref&gt; [https://www.masaloku.mobi masal oku]

== Iinkomba ==
[[Mkhakha:Abosaziwako]]</text>
      <sha1>oex3ov2zqul4aviolldw2dc9ckycgci</sha1>
    </revision>
    <revision>
      <id>3280</id>
      <parentid>3195</parentid>
      <timestamp>2025-07-02T20:15:32Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Undo revision [[Special:Diff/3195|3195]] by [[Special:Contributions/85.97.84.231|85.97.84.231]] ([[User talk:85.97.84.231|talk]])</comment>
      <origin>3280</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1460" sha1="4fdx7pcnbp42ax1g6a52j50vw54goxb" xml:space="preserve">'''U-Aaron Rimbui''' ungumdlali wepiyano, ikhibhodi, umdosiphambili webhendi, umkhiqizi kanye nomgcini weminyanya nomsingathi womrhatjho. Uthathwa njengomunye wabadlali bepiyano abahle khulu be-East Africa.&lt;ref&gt;https://www.standardmedia.co.ke/counties/article/2000091714/why-jazz-is-close-to-my-heart&lt;/ref&gt;&lt;ref&gt;https://www.businessdailyafrica.com/bd/lifestyle/music/pianist-bets-on-his-new-album-to-open-doors-for-kenyans-4806918&lt;/ref&gt;

== Umlando ==
U-Aaron wabelethwa e-[[Nairobi]], e-[[Kenya]]. Uyise bekadlala umvumo ukusuka kumarekhodi ka-Stevie Wonder ukuya ku-Henry Mancini bese amthatha amse eendaweni zokudlela zendawo lapho bekazwa khona umvumo wamaqembu afana ne-Les Wanyika, i-Maroon Commandos kanye ne-Samba Mapangala. Lokhu kwaba nomthelela omkhulu endleleni athuthukisa ngayo umdumo wakhe eminyakeni eyalandelako. Ukuziveza kwaka-Rimbui emculweni kwaragela phambili nokwakheka eminyakeni yakhe yesikolo samabanga aphezulu. Kungaleso sikhathi lapho athatha khona ipiyano. U-Rimbui wathoma ukuthanda umvumo we-jazz njengombana alalele umvumo ka-David Sanborn, u-Joe Sample, we-Yellowjackets no-Fourplay begodu ngokukhamba kwesikhathi, u-Herbie Hancock no-George Duke. U-Rimbui bekasebenza njengehloko ye-Tusker Project Fame band.&lt;ref&gt;https://www.citizen.digital/entertainment/bien-aaron-rimbui-speak-on-their-musical-chemistry-and-why-bald-men-love-better-n286466&lt;/ref&gt; [https://www.masaloku.mobi masal oku]

== Iinkomba ==
[[Mkhakha:Abosaziwako]]</text>
      <sha1>4fdx7pcnbp42ax1g6a52j50vw54goxb</sha1>
    </revision>
    <revision>
      <id>6499</id>
      <parentid>3280</parentid>
      <timestamp>2026-05-15T19:25:01Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <origin>6499</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1426" sha1="dglyh9gwn8pdiujzhc9vrcl1m97hjek" xml:space="preserve">'''U-Aaron Rimbui''' mdlali wepiyano, ikhibhodi, umdosiphambili webhendi, umkhiqizi kanye nomgcini weminyanya nomsingathi womrhatjho. Uthathwa njengomunye wabadlali bepiyano abahle khulu be-East Africa.&lt;ref&gt;https://www.standardmedia.co.ke/counties/article/2000091714/why-jazz-is-close-to-my-heart&lt;/ref&gt;&lt;ref&gt;https://www.businessdailyafrica.com/bd/lifestyle/music/pianist-bets-on-his-new-album-to-open-doors-for-kenyans-4806918&lt;/ref&gt;

== Umlando ==
U-Aaron wabelethwa e-[[Nairobi]], e-[[Kenya]]. Uyise bekadlala umvumo ukusuka emarekhodini ka-Stevie Wonder ukuya ku-Henry Mancini. Uyise bekamthatha amuse eendaweni zokudlela zendawo lapho bekezwa khona umvumo wamaqembu afana ne-Les Wanyika, i-Maroon Commandos kanye ne-Samba Mapangala. Lokhu kwaba nomthelela omkhulu endleleni athuthukisa ngayo umdumo wakhe eminyakeni eyalandelako. Ukuziveza kwaka-Rimbui emculweni kwaragela phambili nokwakheka eminyakeni yakhe yesikolo samabanga aphezulu. Kungaleso sikhathi lapho athatha khona ipiyano. U-Rimbui wathoma ukuthanda umvumo we-jazz njengombana alalele umvumo ka-David Sanborn, u-Joe Sample, we-Yellowjackets no-Fourplay begodu ngokukhamba kwesikhathi, u-Herbie Hancock no-George Duke. U-Rimbui bekasebenza njengehloko ye-Tusker Project Fame band.&lt;ref&gt;https://www.citizen.digital/entertainment/bien-aaron-rimbui-speak-on-their-musical-chemistry-and-why-bald-men-love-better-n286466&lt;/ref&gt; 

== Iinkomba ==
[[Mkhakha:Abosaziwako]]</text>
      <sha1>dglyh9gwn8pdiujzhc9vrcl1m97hjek</sha1>
    </revision>
  </page>
  <page>
    <title>Brakpan</title>
    <ns>0</ns>
    <id>422</id>
    <revision>
      <id>2277</id>
      <timestamp>2024-12-13T03:03:47Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1261152072|Brakpan]]&quot;</comment>
      <origin>2277</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1008" sha1="jcbkdsm03azfgb6941a6xv1ilppbe6b" xml:space="preserve">'''I-Brakpan''' yidorobha yemayini e-East Rand ye-Gauteng, e[[Isewula Afrika|Sewula Afrika]], pheze amakhilomitha ama-38 (23.6 mi) ngepumalanga ye-[[Johannesburg]].&lt;ref&gt;https://www.cambridge.org/core/journals/journal-of-african-history/article/abs/apartheids-testing-ground-urban-native-policy-and-african-politics-in-brakpan-south-africa-194319481/C2850BEE27379183D368213CF275D1CA&lt;/ref&gt;

Ibizo elithi Brakpan livela epanini elincani eplasini elibizwa ngokuthi yi-Weltevreden, ebegade lizele amanzi anetshwayi begodu mhlamunye belibizwa ngokuthi &quot;yi-brakpan,&quot; begodu bekuseduze nepani lapho ukuhlala kokuthoma kwathoma khona.: 286  Ngo- Ngo-1888, kwatholakala umgodi wamalahle begodu kwathonywa umgodi wamalahle ngaphasi kwebizo elithi Brakpan Collieries. Lokha nakwakhiwa umzila wesitimela ukusuka e-Germiston ukuya e-Springs, i-Brakpan yaba ngenye yeentetjhini ezisendleleni.&lt;ref&gt;https://www.tandfonline.com/doi/pdf/10.1080/00020188908707711&lt;/ref&gt;&lt;ref&gt;https://core.ac.uk/download/pdf/39667029.pdf&lt;/ref&gt;</text>
      <sha1>jcbkdsm03azfgb6941a6xv1ilppbe6b</sha1>
    </revision>
    <revision>
      <id>2278</id>
      <parentid>2277</parentid>
      <timestamp>2024-12-13T03:04:39Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1261152072|Brakpan]]&quot;</comment>
      <origin>2278</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1039" sha1="tkqklvqnpwj348dhzu3bkgzprr35c2v" xml:space="preserve">'''I-Brakpan''' yidorobha yemayini e-East Rand ye-[[Gauteng]], e[[Isewula Afrika|Sewula Afrika]], pheze amakhilomitha ama-38 (23.6 mi) ngepumalanga ye-[[Johannesburg]].&lt;ref&gt;https://www.cambridge.org/core/journals/journal-of-african-history/article/abs/apartheids-testing-ground-urban-native-policy-and-african-politics-in-brakpan-south-africa-194319481/C2850BEE27379183D368213CF275D1CA&lt;/ref&gt;

Ibizo elithi Brakpan livela epanini elincani eplasini elibizwa ngokuthi yi-Weltevreden, ebegade lizele amanzi anetshwayi begodu mhlamunye belibizwa ngokuthi &quot;yi-brakpan,&quot; begodu bekuseduze nepani lapho ukuhlala kokuthoma kwathoma khona.: 286  Ngo- Ngo-1888, kwatholakala umgodi wamalahle begodu kwathonywa umgodi wamalahle ngaphasi kwebizo elithi Brakpan Collieries. Lokha nakwakhiwa umzila wesitimela ukusuka e-Germiston ukuya e-Springs, i-Brakpan yaba ngenye yeentetjhini ezisendleleni.&lt;ref&gt;https://www.tandfonline.com/doi/pdf/10.1080/00020188908707711&lt;/ref&gt;&lt;ref&gt;https://core.ac.uk/download/pdf/39667029.pdf&lt;/ref&gt;
[[Mkhakha:Isewula Afrika]]</text>
      <sha1>tkqklvqnpwj348dhzu3bkgzprr35c2v</sha1>
    </revision>
  </page>
  <page>
    <title>Botswana</title>
    <ns>0</ns>
    <id>423</id>
    <revision>
      <id>2293</id>
      <timestamp>2024-12-24T17:46:35Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created page with &quot;'''I-Botswana''' ngokusemthethweni iRiphabhliki ye-Botswana, lilizwe elinganamanzi eSewula ye-Afrika. I-Botswana iyisicaba, pheze amaphesente ama-70 wendawo yayo yingcenye ye-Kalahari Desert. Inomngcele nge[[Isewula Afrika|Sewula Afrika]] ngesewula nesewulapumalanga, i-Namibia ngetjingalanga netlhagwini, i-Zambia ngetlhagwini kanye ne-Zimbabwe ngetlhagwini-pumalanga. Njengombana inabantu abangaphezudlwana kweengidi ezi-2.4 kanye nendawo efana ne-France, i-Botswana ngelin...&quot;</comment>
      <origin>2293</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="883" sha1="k8tu4m73ymzq9tvtlvmcnqh1runyjx6" xml:space="preserve">'''I-Botswana''' ngokusemthethweni iRiphabhliki ye-Botswana, lilizwe elinganamanzi eSewula ye-Afrika. I-Botswana iyisicaba, pheze amaphesente ama-70 wendawo yayo yingcenye ye-Kalahari Desert. Inomngcele nge[[Isewula Afrika|Sewula Afrika]] ngesewula nesewulapumalanga, i-Namibia ngetjingalanga netlhagwini, i-Zambia ngetlhagwini kanye ne-Zimbabwe ngetlhagwini-pumalanga. Njengombana inabantu abangaphezudlwana kweengidi ezi-2.4 kanye nendawo efana ne-France, i-Botswana ngelinye lamazwe anabantu abancani khulu ephasini. Ngokuyinhloko mbuso wesitjhaba wabantu be-Tswana, abakha pheze amaphesente ama-80 wabantu.&lt;ref&gt;https://dspace.mit.edu/bitstream/handle/1721.1/63256/africansuccessst00acem.pdf&lt;/ref&gt;&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=y2AObNZys60C&amp;oi=fnd&amp;pg=PR7&amp;dq=botswana&amp;ots=zsrEEH1jqu&amp;sig=vZjZkA3CLYkcBv4ndAk2It1V-x4&amp;redir_esc=y#v=onepage&amp;q=botswana&amp;f=false&lt;/ref&gt;</text>
      <sha1>k8tu4m73ymzq9tvtlvmcnqh1runyjx6</sha1>
    </revision>
    <revision>
      <id>2294</id>
      <parentid>2293</parentid>
      <timestamp>2024-12-24T17:48:48Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2294</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="897" sha1="cbmvo0sesvc6uclz9mpx8uhx1iojq8i" xml:space="preserve">'''I-Botswana''' ngokusemthethweni iRiphabhliki ye-Botswana, lilizwe elinganamanzi eSewula ye-Afrika. I-Botswana iyisicaba, pheze amaphesente ama-70 wendawo yayo yingcenye ye-Kalahari Desert. Inomngcele nge[[Isewula Afrika|Sewula Afrika]] ngesewula nesewulapumalanga, i-Namibia ngetjingalanga netlhagwini, i-Zambia ngetlhagwini kanye ne-Zimbabwe ngetlhagwini-pumalanga. Njengombana inabantu abangaphezudlwana kweengidi ezi-2.4 kanye nendawo efana ne-France, i-Botswana ngelinye lamazwe anabantu abancani khulu ephasini. Ngokuyinhloko mbuso wesitjhaba wabantu be-Tswana, abakha pheze amaphesente ama-80 wabantu.
==Iinkomba==
&lt;ref&gt;https://dspace.mit.edu/bitstream/handle/1721.1/63256/africansuccessst00acem.pdf&lt;/ref&gt;&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=y2AObNZys60C&amp;oi=fnd&amp;pg=PR7&amp;dq=botswana&amp;ots=zsrEEH1jqu&amp;sig=vZjZkA3CLYkcBv4ndAk2It1V-x4&amp;redir_esc=y#v=onepage&amp;q=botswana&amp;f=false&lt;/ref&gt;</text>
      <sha1>cbmvo0sesvc6uclz9mpx8uhx1iojq8i</sha1>
    </revision>
    <revision>
      <id>2295</id>
      <parentid>2294</parentid>
      <timestamp>2024-12-24T17:50:03Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <minor />
      <comment>Bobbyshabangu moved page [[I-Botswana]] to [[Botswana]]: The subject is without &quot;I&quot;. </comment>
      <origin>2294</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="897" sha1="cbmvo0sesvc6uclz9mpx8uhx1iojq8i" xml:space="preserve">'''I-Botswana''' ngokusemthethweni iRiphabhliki ye-Botswana, lilizwe elinganamanzi eSewula ye-Afrika. I-Botswana iyisicaba, pheze amaphesente ama-70 wendawo yayo yingcenye ye-Kalahari Desert. Inomngcele nge[[Isewula Afrika|Sewula Afrika]] ngesewula nesewulapumalanga, i-Namibia ngetjingalanga netlhagwini, i-Zambia ngetlhagwini kanye ne-Zimbabwe ngetlhagwini-pumalanga. Njengombana inabantu abangaphezudlwana kweengidi ezi-2.4 kanye nendawo efana ne-France, i-Botswana ngelinye lamazwe anabantu abancani khulu ephasini. Ngokuyinhloko mbuso wesitjhaba wabantu be-Tswana, abakha pheze amaphesente ama-80 wabantu.
==Iinkomba==
&lt;ref&gt;https://dspace.mit.edu/bitstream/handle/1721.1/63256/africansuccessst00acem.pdf&lt;/ref&gt;&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=y2AObNZys60C&amp;oi=fnd&amp;pg=PR7&amp;dq=botswana&amp;ots=zsrEEH1jqu&amp;sig=vZjZkA3CLYkcBv4ndAk2It1V-x4&amp;redir_esc=y#v=onepage&amp;q=botswana&amp;f=false&lt;/ref&gt;</text>
      <sha1>cbmvo0sesvc6uclz9mpx8uhx1iojq8i</sha1>
    </revision>
    <revision>
      <id>2933</id>
      <parentid>2295</parentid>
      <timestamp>2025-06-06T17:12:41Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>Bomboclat</comment>
      <origin>2933</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="287" sha1="tp6expzhwewf9wsjaxay4bis9n20ljd" xml:space="preserve">==Bomboclat==
&lt;ref&gt;https://dspace.mit.edu/bitstream/handle/1721.1/63256/africansuccessst00acem.pdf&lt;/ref&gt;&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=y2AObNZys60C&amp;oi=fnd&amp;pg=PR7&amp;dq=botswana&amp;ots=zsrEEH1jqu&amp;sig=vZjZkA3CLYkcBv4ndAk2It1V-x4&amp;redir_esc=y#v=onepage&amp;q=botswana&amp;f=false&lt;/ref&gt;</text>
      <sha1>tp6expzhwewf9wsjaxay4bis9n20ljd</sha1>
    </revision>
    <revision>
      <id>3136</id>
      <parentid>2933</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Bobbyshabangu|Bobbyshabangu]]</comment>
      <origin>2294</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="897" sha1="cbmvo0sesvc6uclz9mpx8uhx1iojq8i" xml:space="preserve">'''I-Botswana''' ngokusemthethweni iRiphabhliki ye-Botswana, lilizwe elinganamanzi eSewula ye-Afrika. I-Botswana iyisicaba, pheze amaphesente ama-70 wendawo yayo yingcenye ye-Kalahari Desert. Inomngcele nge[[Isewula Afrika|Sewula Afrika]] ngesewula nesewulapumalanga, i-Namibia ngetjingalanga netlhagwini, i-Zambia ngetlhagwini kanye ne-Zimbabwe ngetlhagwini-pumalanga. Njengombana inabantu abangaphezudlwana kweengidi ezi-2.4 kanye nendawo efana ne-France, i-Botswana ngelinye lamazwe anabantu abancani khulu ephasini. Ngokuyinhloko mbuso wesitjhaba wabantu be-Tswana, abakha pheze amaphesente ama-80 wabantu.
==Iinkomba==
&lt;ref&gt;https://dspace.mit.edu/bitstream/handle/1721.1/63256/africansuccessst00acem.pdf&lt;/ref&gt;&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=y2AObNZys60C&amp;oi=fnd&amp;pg=PR7&amp;dq=botswana&amp;ots=zsrEEH1jqu&amp;sig=vZjZkA3CLYkcBv4ndAk2It1V-x4&amp;redir_esc=y#v=onepage&amp;q=botswana&amp;f=false&lt;/ref&gt;</text>
      <sha1>cbmvo0sesvc6uclz9mpx8uhx1iojq8i</sha1>
    </revision>
    <revision>
      <id>6090</id>
      <parentid>3136</parentid>
      <timestamp>2025-12-17T17:29:35Z</timestamp>
      <contributor>
        <username>JayJaytutu</username>
        <id>1227</id>
      </contributor>
      <origin>6090</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="972" sha1="0xzrp59cafr5va0scfrs7gkmzunt01d" xml:space="preserve">'''I-Botswana BOTSWANANNANANA (epic phonk plays in the distance) *dies from awesomeness*''' ngokusemthethweni iRiphabhliki ye-Botswana, lilizwe elinganamanzi eSewula ye-Afrika. I-Botswana iyisicaba, pheze amaphesente ama-70 wendawo yayo yingcenye ye-Kalahari Desert. Inomngcele nge[[Isewula Afrika|Sewula Afrika]] ngesewula nesewulapumalanga, i-Namibia ngetjingalanga netlhagwini, i-Zambia ngetlhagwini kanye ne-Zimbabwe ngetlhagwini-pumalanga. Njengombana inabantu abangaphezudlwana kweengidi ezi-2.4 kanye nendawo efana ne-France, i-Botswana ngelinye lamazwe anabantu abancani khulu ephasini. Ngokuyinhloko mbuso wesitjhaba wabantu be-Tswana, abakha pheze amaphesente ama-80 wabantu.
==Iinkomba==
&lt;ref&gt;https://dspace.mit.edu/bitstream/handle/1721.1/63256/africansuccessst00acem.pdf&lt;/ref&gt;&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=y2AObNZys60C&amp;oi=fnd&amp;pg=PR7&amp;dq=botswana&amp;ots=zsrEEH1jqu&amp;sig=vZjZkA3CLYkcBv4ndAk2It1V-x4&amp;redir_esc=y#v=onepage&amp;q=botswana&amp;f=false&lt;/ref&gt;</text>
      <sha1>0xzrp59cafr5va0scfrs7gkmzunt01d</sha1>
    </revision>
    <revision>
      <id>6107</id>
      <parentid>6090</parentid>
      <timestamp>2026-01-02T05:40:29Z</timestamp>
      <contributor>
        <username>Versions111</username>
        <id>1260</id>
      </contributor>
      <comment>what the bhell</comment>
      <origin>6107</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="897" sha1="cbmvo0sesvc6uclz9mpx8uhx1iojq8i" xml:space="preserve">'''I-Botswana''' ngokusemthethweni iRiphabhliki ye-Botswana, lilizwe elinganamanzi eSewula ye-Afrika. I-Botswana iyisicaba, pheze amaphesente ama-70 wendawo yayo yingcenye ye-Kalahari Desert. Inomngcele nge[[Isewula Afrika|Sewula Afrika]] ngesewula nesewulapumalanga, i-Namibia ngetjingalanga netlhagwini, i-Zambia ngetlhagwini kanye ne-Zimbabwe ngetlhagwini-pumalanga. Njengombana inabantu abangaphezudlwana kweengidi ezi-2.4 kanye nendawo efana ne-France, i-Botswana ngelinye lamazwe anabantu abancani khulu ephasini. Ngokuyinhloko mbuso wesitjhaba wabantu be-Tswana, abakha pheze amaphesente ama-80 wabantu.
==Iinkomba==
&lt;ref&gt;https://dspace.mit.edu/bitstream/handle/1721.1/63256/africansuccessst00acem.pdf&lt;/ref&gt;&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=y2AObNZys60C&amp;oi=fnd&amp;pg=PR7&amp;dq=botswana&amp;ots=zsrEEH1jqu&amp;sig=vZjZkA3CLYkcBv4ndAk2It1V-x4&amp;redir_esc=y#v=onepage&amp;q=botswana&amp;f=false&lt;/ref&gt;</text>
      <sha1>cbmvo0sesvc6uclz9mpx8uhx1iojq8i</sha1>
    </revision>
  </page>
  <page>
    <title>I-Botswana</title>
    <ns>0</ns>
    <id>424</id>
    <redirect title="Botswana" />
    <revision>
      <id>2296</id>
      <timestamp>2024-12-24T17:50:03Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Bobbyshabangu moved page [[I-Botswana]] to [[Botswana]]: The subject is without &quot;I&quot;. </comment>
      <origin>2296</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="22" sha1="6nnbyrmb9sufj99sfa8yc5kg5ihpvx3" xml:space="preserve">#REDIRECT [[Botswana]]</text>
      <sha1>6nnbyrmb9sufj99sfa8yc5kg5ihpvx3</sha1>
    </revision>
  </page>
  <page>
    <title>Cameroon</title>
    <ns>0</ns>
    <id>425</id>
    <revision>
      <id>2297</id>
      <timestamp>2024-12-24T17:55:01Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1264571337|Cameroon]]&quot;</comment>
      <origin>2297</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1488" sha1="qckyh76vjfmispj83sq2tvcl915vu78" xml:space="preserve">
'''I-Cameroon''', ngokusemthethweni iRiphabhliki ye-Cameroon, lilizwe elise-Central Africa. Yabelana ngemingcele ne-Nigeria ngeTjingalanga neTlhagwini, i-Chad ngeTlhagwini-mpumalanga, [[i-Central African Republic]] ngepumalanga, kanye ne-Equatorial Guinea, i-Gabon, kanye ne-Republic of the Congo ngeSewula. Igumbi layo lise-Bight of Biafra, ingcenye ye-Gulf of Guinea, kanye ne-Atlantic Ocean. Ngebanga lobujamo bayo obuqakathekileko ekuhlanganeni kweendlela hlangana ne-Afrika yeTjingalanga ne-Afrika ePhakathi, ihlukaniswe njengekumakamu womabili. Inani labantu be-Cameroon elipheze libe ziingidi ezingama-31 likhuluma amalimi womdabu ama-250, ngaphezu kwelimi lesizwe lesiNgisi nesiFulentshi, nofana zombili. Izakhamuzi zokuthoma zendawo leyo bezifaka hlangana ipucuko yama-Sao eduze neLake [[Chad]] kanye nabazingeli-abaqoqi be-Baka ehlathini lemvula langesewulapumalanga. Abahloli bamaPutukezi bafika egwini ngekhulu le-15 begodu baqamba indawo leyo ngokuthi yi-Rio dos Camarões (umlambo we-Shrimp), eyaba yi-Cameroon ngesiNgisi. Amasotja we-Fulani asungula i-Adamawa Emirate enyakatho ngekhulu le-19, begodu amaqembu weentjhaba ahlukahlukeneko weTjingalanga neTlhagwini-Tjingalanga asungula amakhosi anamandla nama-fondoms.&lt;ref&gt;https://link.springer.com/chapter/10.1007/978-3-642-73966-8_12&lt;/ref&gt;&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=hHrDEAAAQBAJ&amp;oi=fnd&amp;pg=PR7&amp;dq=Cameroon&amp;ots=dCY9uyla4I&amp;sig=1Pjy3KHBV4EAbkYni9tpQZJtyOE&amp;redir_esc=y#v=onepage&amp;q=Cameroon&amp;f=false&lt;/ref&gt;</text>
      <sha1>qckyh76vjfmispj83sq2tvcl915vu78</sha1>
    </revision>
    <revision>
      <id>2298</id>
      <parentid>2297</parentid>
      <timestamp>2024-12-24T17:55:29Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2298</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1502" sha1="6x5qa4e4fnxlsm0cxy0rzdd8rmhp7wu" xml:space="preserve">
'''I-Cameroon''', ngokusemthethweni iRiphabhliki ye-Cameroon, lilizwe elise-Central Africa. Yabelana ngemingcele ne-Nigeria ngeTjingalanga neTlhagwini, i-Chad ngeTlhagwini-mpumalanga, [[i-Central African Republic]] ngepumalanga, kanye ne-Equatorial Guinea, i-Gabon, kanye ne-Republic of the Congo ngeSewula. Igumbi layo lise-Bight of Biafra, ingcenye ye-Gulf of Guinea, kanye ne-Atlantic Ocean. Ngebanga lobujamo bayo obuqakathekileko ekuhlanganeni kweendlela hlangana ne-Afrika yeTjingalanga ne-Afrika ePhakathi, ihlukaniswe njengekumakamu womabili. Inani labantu be-Cameroon elipheze libe ziingidi ezingama-31 likhuluma amalimi womdabu ama-250, ngaphezu kwelimi lesizwe lesiNgisi nesiFulentshi, nofana zombili. Izakhamuzi zokuthoma zendawo leyo bezifaka hlangana ipucuko yama-Sao eduze neLake [[Chad]] kanye nabazingeli-abaqoqi be-Baka ehlathini lemvula langesewulapumalanga. Abahloli bamaPutukezi bafika egwini ngekhulu le-15 begodu baqamba indawo leyo ngokuthi yi-Rio dos Camarões (umlambo we-Shrimp), eyaba yi-Cameroon ngesiNgisi. Amasotja we-Fulani asungula i-Adamawa Emirate enyakatho ngekhulu le-19, begodu amaqembu weentjhaba ahlukahlukeneko weTjingalanga neTlhagwini-Tjingalanga asungula amakhosi anamandla nama-fondoms.
==Iinkomba==
&lt;ref&gt;https://link.springer.com/chapter/10.1007/978-3-642-73966-8_12&lt;/ref&gt;&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=hHrDEAAAQBAJ&amp;oi=fnd&amp;pg=PR7&amp;dq=Cameroon&amp;ots=dCY9uyla4I&amp;sig=1Pjy3KHBV4EAbkYni9tpQZJtyOE&amp;redir_esc=y#v=onepage&amp;q=Cameroon&amp;f=false&lt;/ref&gt;</text>
      <sha1>6x5qa4e4fnxlsm0cxy0rzdd8rmhp7wu</sha1>
    </revision>
    <revision>
      <id>2578</id>
      <parentid>2298</parentid>
      <timestamp>2025-03-22T05:53:34Z</timestamp>
      <contributor>
        <username>Kvazimodo</username>
        <id>341</id>
      </contributor>
      <origin>2578</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1544" sha1="90yul6clfg3r64j2wy8ur4aobdag6xs" xml:space="preserve">'''I-Cameroon''', ngokusemthethweni iRiphabhliki ye-Cameroon, lilizwe elise-Central Africa. Yabelana ngemingcele ne-Nigeria ngeTjingalanga neTlhagwini, i-Chad ngeTlhagwini-mpumalanga, [[i-Central African Republic]] ngepumalanga, kanye ne-Equatorial Guinea, i-Gabon, kanye ne-Republic of the Congo ngeSewula. Igumbi layo lise-Bight of Biafra, ingcenye ye-Gulf of Guinea, kanye ne-Atlantic Ocean. Ngebanga lobujamo bayo obuqakathekileko ekuhlanganeni kweendlela hlangana ne-Afrika yeTjingalanga ne-Afrika ePhakathi, ihlukaniswe njengekumakamu womabili. Inani labantu be-Cameroon elipheze libe ziingidi ezingama-31 likhuluma amalimi womdabu ama-250, ngaphezu kwelimi lesizwe lesiNgisi nesiFulentshi, nofana zombili. Izakhamuzi zokuthoma zendawo leyo bezifaka hlangana ipucuko yama-Sao eduze neLake [[Chad]] kanye nabazingeli-abaqoqi be-Baka ehlathini lemvula langesewulapumalanga. Abahloli bamaPutukezi bafika egwini ngekhulu le-15 begodu baqamba indawo leyo ngokuthi yi-Rio dos Camarões (umlambo we-Shrimp), eyaba yi-Cameroon ngesiNgisi. Amasotja we-Fulani asungula i-Adamawa Emirate enyakatho ngekhulu le-19, begodu amaqembu weentjhaba ahlukahlukeneko weTjingalanga neTlhagwini-Tjingalanga asungula amakhosi anamandla nama-fondoms.&lt;ref&gt;https://link.springer.com/chapter/10.1007/978-3-642-73966-8_12&lt;/ref&gt;&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=hHrDEAAAQBAJ&amp;oi=fnd&amp;pg=PR7&amp;dq=Cameroon&amp;ots=dCY9uyla4I&amp;sig=1Pjy3KHBV4EAbkYni9tpQZJtyOE&amp;redir_esc=y#v=onepage&amp;q=Cameroon&amp;f=false&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}

[[Mkhakha:Iinarha zephasi]]</text>
      <sha1>90yul6clfg3r64j2wy8ur4aobdag6xs</sha1>
    </revision>
    <revision>
      <id>2579</id>
      <parentid>2578</parentid>
      <timestamp>2025-03-22T05:54:50Z</timestamp>
      <contributor>
        <username>Kvazimodo</username>
        <id>341</id>
      </contributor>
      <origin>2579</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1578" sha1="4fwue2wfpe6wn9k48ssiada5dzu25zx" xml:space="preserve">[[File:Ahmadou Ahidjo.jpg|right]]
'''I-Cameroon''', ngokusemthethweni iRiphabhliki ye-Cameroon, lilizwe elise-Central Africa. Yabelana ngemingcele ne-Nigeria ngeTjingalanga neTlhagwini, i-Chad ngeTlhagwini-mpumalanga, [[i-Central African Republic]] ngepumalanga, kanye ne-Equatorial Guinea, i-Gabon, kanye ne-Republic of the Congo ngeSewula. Igumbi layo lise-Bight of Biafra, ingcenye ye-Gulf of Guinea, kanye ne-Atlantic Ocean. Ngebanga lobujamo bayo obuqakathekileko ekuhlanganeni kweendlela hlangana ne-Afrika yeTjingalanga ne-Afrika ePhakathi, ihlukaniswe njengekumakamu womabili. Inani labantu be-Cameroon elipheze libe ziingidi ezingama-31 likhuluma amalimi womdabu ama-250, ngaphezu kwelimi lesizwe lesiNgisi nesiFulentshi, nofana zombili. Izakhamuzi zokuthoma zendawo leyo bezifaka hlangana ipucuko yama-Sao eduze neLake [[Chad]] kanye nabazingeli-abaqoqi be-Baka ehlathini lemvula langesewulapumalanga. Abahloli bamaPutukezi bafika egwini ngekhulu le-15 begodu baqamba indawo leyo ngokuthi yi-Rio dos Camarões (umlambo we-Shrimp), eyaba yi-Cameroon ngesiNgisi. Amasotja we-Fulani asungula i-Adamawa Emirate enyakatho ngekhulu le-19, begodu amaqembu weentjhaba ahlukahlukeneko weTjingalanga neTlhagwini-Tjingalanga asungula amakhosi anamandla nama-fondoms.&lt;ref&gt;https://link.springer.com/chapter/10.1007/978-3-642-73966-8_12&lt;/ref&gt;&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=hHrDEAAAQBAJ&amp;oi=fnd&amp;pg=PR7&amp;dq=Cameroon&amp;ots=dCY9uyla4I&amp;sig=1Pjy3KHBV4EAbkYni9tpQZJtyOE&amp;redir_esc=y#v=onepage&amp;q=Cameroon&amp;f=false&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}

[[Mkhakha:Iinarha zephasi]]</text>
      <sha1>4fwue2wfpe6wn9k48ssiada5dzu25zx</sha1>
    </revision>
    <revision>
      <id>2912</id>
      <parentid>2579</parentid>
      <timestamp>2025-06-06T16:51:47Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>wgn</comment>
      <origin>2912</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1659" sha1="d48jh9uh3bc0at3extczq5icawrdd5f" xml:space="preserve">[[File:Ahmadou Ahidjo.jpg|right]]
'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. I-Cameroon''', ngokusemthethweni iRiphabhliki ye-Cameroon, lilizwe elise-Central Africa. Yabelana ngemingcele ne-Nigeria ngeTjingalanga neTlhagwini, i-Chad ngeTlhagwini-mpumalanga, [[i-Central African Republic]] ngepumalanga, kanye ne-Equatorial Guinea, i-Gabon, kanye ne-Republic of the Congo ngeSewula. Igumbi layo lise-Bight of Biafra, ingcenye ye-Gulf of Guinea, kanye ne-Atlantic Ocean. Ngebanga lobujamo bayo obuqakathekileko ekuhlanganeni kweendlela hlangana ne-Afrika yeTjingalanga ne-Afrika ePhakathi, ihlukaniswe njengekumakamu womabili. Inani labantu be-Cameroon elipheze libe ziingidi ezingama-31 likhuluma amalimi womdabu ama-250, ngaphezu kwelimi lesizwe lesiNgisi nesiFulentshi, nofana zombili. Izakhamuzi zokuthoma zendawo leyo bezifaka hlangana ipucuko yama-Sao eduze neLake [[Chad]] kanye nabazingeli-abaqoqi be-Baka ehlathini lemvula langesewulapumalanga. Abahloli bamaPutukezi bafika egwini ngekhulu le-15 begodu baqamba indawo leyo ngokuthi yi-Rio dos Camarões (umlambo we-Shrimp), eyaba yi-Cameroon ngesiNgisi. Amasotja we-Fulani asungula i-Adamawa Emirate enyakatho ngekhulu le-19, begodu amaqembu weentjhaba ahlukahlukeneko weTjingalanga neTlhagwini-Tjingalanga asungula amakhosi anamandla nama-fondoms.&lt;ref&gt;https://link.springer.com/chapter/10.1007/978-3-642-73966-8_12&lt;/ref&gt;&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=hHrDEAAAQBAJ&amp;oi=fnd&amp;pg=PR7&amp;dq=Cameroon&amp;ots=dCY9uyla4I&amp;sig=1Pjy3KHBV4EAbkYni9tpQZJtyOE&amp;redir_esc=y#v=onepage&amp;q=Cameroon&amp;f=false&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}

[[Mkhakha:Iinarha zephasi]]</text>
      <sha1>d48jh9uh3bc0at3extczq5icawrdd5f</sha1>
    </revision>
    <revision>
      <id>3125</id>
      <parentid>2912</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Janabaevazizbek|Janabaevazizbek]]</comment>
      <origin>2579</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1578" sha1="4fwue2wfpe6wn9k48ssiada5dzu25zx" xml:space="preserve">[[File:Ahmadou Ahidjo.jpg|right]]
'''I-Cameroon''', ngokusemthethweni iRiphabhliki ye-Cameroon, lilizwe elise-Central Africa. Yabelana ngemingcele ne-Nigeria ngeTjingalanga neTlhagwini, i-Chad ngeTlhagwini-mpumalanga, [[i-Central African Republic]] ngepumalanga, kanye ne-Equatorial Guinea, i-Gabon, kanye ne-Republic of the Congo ngeSewula. Igumbi layo lise-Bight of Biafra, ingcenye ye-Gulf of Guinea, kanye ne-Atlantic Ocean. Ngebanga lobujamo bayo obuqakathekileko ekuhlanganeni kweendlela hlangana ne-Afrika yeTjingalanga ne-Afrika ePhakathi, ihlukaniswe njengekumakamu womabili. Inani labantu be-Cameroon elipheze libe ziingidi ezingama-31 likhuluma amalimi womdabu ama-250, ngaphezu kwelimi lesizwe lesiNgisi nesiFulentshi, nofana zombili. Izakhamuzi zokuthoma zendawo leyo bezifaka hlangana ipucuko yama-Sao eduze neLake [[Chad]] kanye nabazingeli-abaqoqi be-Baka ehlathini lemvula langesewulapumalanga. Abahloli bamaPutukezi bafika egwini ngekhulu le-15 begodu baqamba indawo leyo ngokuthi yi-Rio dos Camarões (umlambo we-Shrimp), eyaba yi-Cameroon ngesiNgisi. Amasotja we-Fulani asungula i-Adamawa Emirate enyakatho ngekhulu le-19, begodu amaqembu weentjhaba ahlukahlukeneko weTjingalanga neTlhagwini-Tjingalanga asungula amakhosi anamandla nama-fondoms.&lt;ref&gt;https://link.springer.com/chapter/10.1007/978-3-642-73966-8_12&lt;/ref&gt;&lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=hHrDEAAAQBAJ&amp;oi=fnd&amp;pg=PR7&amp;dq=Cameroon&amp;ots=dCY9uyla4I&amp;sig=1Pjy3KHBV4EAbkYni9tpQZJtyOE&amp;redir_esc=y#v=onepage&amp;q=Cameroon&amp;f=false&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}

[[Mkhakha:Iinarha zephasi]]</text>
      <sha1>4fwue2wfpe6wn9k48ssiada5dzu25zx</sha1>
    </revision>
  </page>
  <page>
    <title>Mbandzeni</title>
    <ns>0</ns>
    <id>426</id>
    <revision>
      <id>2299</id>
      <timestamp>2024-12-28T01:47:32Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created page with &quot;U-Mbandzeni (owaziwa nangokuthi ngu-Dlamini IV, Umbandine,] Umbandeen[3]) (c. 1855–1889) bekayiKosi ye-Swaziland (manje eyi-Eswatini) kusukela ngo-1872 bekube ngu-1889. Ingwenyama Mbandzeni bekayindodana ka-Mswati II no-Nandzi Nkambule . Unina umfazi weKosi uMswati bekahlongakele asesemncani khulu.  U-Mbandzeni wakhwela esihlalweni sobukhosi ngemva kobana umfowabo u-Ludvonga II ahlongakale ngaphambi kobana abe yikosi. Ukuhlongakala kwaka-Ludvonga kwabangela bona unina...&quot;</comment>
      <origin>2299</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1351" sha1="oh7k8d625sz64ffqpwcjq7m62ygyew8" xml:space="preserve">U-Mbandzeni (owaziwa nangokuthi ngu-Dlamini IV, Umbandine,] Umbandeen[3]) (c. 1855–1889) bekayiKosi ye-Swaziland (manje eyi-Eswatini) kusukela ngo-1872 bekube ngu-1889. Ingwenyama Mbandzeni bekayindodana ka-Mswati II no-Nandzi Nkambule . Unina umfazi weKosi uMswati bekahlongakele asesemncani khulu.

U-Mbandzeni wakhwela esihlalweni sobukhosi ngemva kobana umfowabo u-Ludvonga II ahlongakale ngaphambi kobana abe yikosi. Ukuhlongakala kwaka-Ludvonga kwabangela bona unina u-Inkhosikati Lamgangeni amukele u-Mbandzeni obekangananina njengendodanakhe, lokho kwamenza waba yikosi begodu yena waba yikosikazi ye-Swaziland. Inhlokodolobha yakhe yobukhosi gade iseMbekelweni. Ngesikhathi sobukhosi bakhe u-Mbandzeni wanikela ngeemvume ezinengi zemayini, ukulima, ukurhweba kanye nokuphatha ebantwini abamhlophe abavela e-Britain ne-Transvaal. AmaBhunu bekakhohlise ikosi bona isayine iimvumelwano zomhlaba unomphela. Ikosi beyingakghoni ukufunda nokutlola, njeke amaBhunu amenza bona atlikitle iimvumo ngesiphambano. Ikosi yatjelwa bona bekungasiwo umhlaba onomphela kodwana amaphepha ngokwawo atjho ngenye indlela. Ukuvunyelwa okunikelwe ngokusizwa ngu-Offy Sherpstone ekugcineni kwaholela emihlanganweni ka-1884 no-1894, eyehlisa imingcele ye-Swaziland begodu ngokukhamba kwesikhathi yenza i-Swaziland yaba yindawo evikelweko ye-South African Republic.</text>
      <sha1>oh7k8d625sz64ffqpwcjq7m62ygyew8</sha1>
    </revision>
    <revision>
      <id>2300</id>
      <parentid>2299</parentid>
      <timestamp>2024-12-28T01:47:49Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2300</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1471" sha1="beqaz9dqq60iscyefa1nsd2nlw2br94" xml:space="preserve">U-Mbandzeni (owaziwa nangokuthi ngu-Dlamini IV, Umbandine,] Umbandeen[3]) (c. 1855–1889) bekayiKosi ye-Swaziland (manje eyi-Eswatini) kusukela ngo-1872 bekube ngu-1889. Ingwenyama Mbandzeni bekayindodana ka-Mswati II no-Nandzi Nkambule . Unina umfazi weKosi uMswati bekahlongakele asesemncani khulu.&lt;ref&gt;https://landportal.org/sites/default/files/library/resources/20210202%2520Eswatini%2520timeline%2520FINAL.pdf&lt;/ref&gt;

U-Mbandzeni wakhwela esihlalweni sobukhosi ngemva kobana umfowabo u-Ludvonga II ahlongakale ngaphambi kobana abe yikosi. Ukuhlongakala kwaka-Ludvonga kwabangela bona unina u-Inkhosikati Lamgangeni amukele u-Mbandzeni obekangananina njengendodanakhe, lokho kwamenza waba yikosi begodu yena waba yikosikazi ye-Swaziland. Inhlokodolobha yakhe yobukhosi gade iseMbekelweni. Ngesikhathi sobukhosi bakhe u-Mbandzeni wanikela ngeemvume ezinengi zemayini, ukulima, ukurhweba kanye nokuphatha ebantwini abamhlophe abavela e-Britain ne-Transvaal. AmaBhunu bekakhohlise ikosi bona isayine iimvumelwano zomhlaba unomphela. Ikosi beyingakghoni ukufunda nokutlola, njeke amaBhunu amenza bona atlikitle iimvumo ngesiphambano. Ikosi yatjelwa bona bekungasiwo umhlaba onomphela kodwana amaphepha ngokwawo atjho ngenye indlela. Ukuvunyelwa okunikelwe ngokusizwa ngu-Offy Sherpstone ekugcineni kwaholela emihlanganweni ka-1884 no-1894, eyehlisa imingcele ye-Swaziland begodu ngokukhamba kwesikhathi yenza i-Swaziland yaba yindawo evikelweko ye-South African Republic.</text>
      <sha1>beqaz9dqq60iscyefa1nsd2nlw2br94</sha1>
    </revision>
    <revision>
      <id>2301</id>
      <parentid>2300</parentid>
      <timestamp>2024-12-28T01:48:22Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2301</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1808" sha1="oouziqnzi3tn2v48pdpsp17vwtdp7kc" xml:space="preserve">U-Mbandzeni (owaziwa nangokuthi ngu-Dlamini IV, Umbandine,] Umbandeen[3]) (c. 1855–1889) bekayiKosi ye-Swaziland (manje eyi-Eswatini) kusukela ngo-1872 bekube ngu-1889. Ingwenyama Mbandzeni bekayindodana ka-Mswati II no-Nandzi Nkambule . Unina umfazi weKosi uMswati bekahlongakele asesemncani khulu.&lt;ref&gt;https://landportal.org/sites/default/files/library/resources/20210202%2520Eswatini%2520timeline%2520FINAL.pdf&lt;/ref&gt;&lt;ref&gt;https://www.cambridge.org/core/journals/journal-of-african-history/article/abs/pedi-go-down-the-land-belongs-to-us-the-pedi-polity-the-boers-and-the-british-in-the-nineteenth-century-transvaal-by-delius-peter-johannesburg-ravan-press-london-heinemann-educational-books-19831984-pp-xiv-279-1650/220FB6C835F8C0259C1BB25F090A50F2&lt;/ref&gt;

U-Mbandzeni wakhwela esihlalweni sobukhosi ngemva kobana umfowabo u-Ludvonga II ahlongakale ngaphambi kobana abe yikosi. Ukuhlongakala kwaka-Ludvonga kwabangela bona unina u-Inkhosikati Lamgangeni amukele u-Mbandzeni obekangananina njengendodanakhe, lokho kwamenza waba yikosi begodu yena waba yikosikazi ye-Swaziland. Inhlokodolobha yakhe yobukhosi gade iseMbekelweni. Ngesikhathi sobukhosi bakhe u-Mbandzeni wanikela ngeemvume ezinengi zemayini, ukulima, ukurhweba kanye nokuphatha ebantwini abamhlophe abavela e-Britain ne-Transvaal. AmaBhunu bekakhohlise ikosi bona isayine iimvumelwano zomhlaba unomphela. Ikosi beyingakghoni ukufunda nokutlola, njeke amaBhunu amenza bona atlikitle iimvumo ngesiphambano. Ikosi yatjelwa bona bekungasiwo umhlaba onomphela kodwana amaphepha ngokwawo atjho ngenye indlela. Ukuvunyelwa okunikelwe ngokusizwa ngu-Offy Sherpstone ekugcineni kwaholela emihlanganweni ka-1884 no-1894, eyehlisa imingcele ye-Swaziland begodu ngokukhamba kwesikhathi yenza i-Swaziland yaba yindawo evikelweko ye-South African Republic.</text>
      <sha1>oouziqnzi3tn2v48pdpsp17vwtdp7kc</sha1>
    </revision>
    <revision>
      <id>2302</id>
      <parentid>2301</parentid>
      <timestamp>2024-12-28T01:48:56Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2302</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1878" sha1="q9mt7xbtaey2f1hxohh52cnaurn04nu" xml:space="preserve">U-Mbandzeni (owaziwa nangokuthi ngu-Dlamini IV, Umbandine,] Umbandeen[3]) (c. 1855–1889) bekayiKosi ye-Swaziland (manje eyi-Eswatini) kusukela ngo-1872 bekube ngu-1889. Ingwenyama Mbandzeni bekayindodana ka-Mswati II no-Nandzi Nkambule . Unina umfazi weKosi uMswati bekahlongakele asesemncani khulu.&lt;ref&gt;https://landportal.org/sites/default/files/library/resources/20210202%2520Eswatini%2520timeline%2520FINAL.pdf&lt;/ref&gt;&lt;ref&gt;https://www.cambridge.org/core/journals/journal-of-african-history/article/abs/pedi-go-down-the-land-belongs-to-us-the-pedi-polity-the-boers-and-the-british-in-the-nineteenth-century-transvaal-by-delius-peter-johannesburg-ravan-press-london-heinemann-educational-books-19831984-pp-xiv-279-1650/220FB6C835F8C0259C1BB25F090A50F2&lt;/ref&gt;

U-Mbandzeni wakhwela esihlalweni sobukhosi ngemva kobana umfowabo u-Ludvonga II ahlongakale ngaphambi kobana abe yikosi. Ukuhlongakala kwaka-Ludvonga kwabangela bona unina u-Inkhosikati Lamgangeni amukele u-Mbandzeni obekangananina njengendodanakhe, lokho kwamenza waba yikosi begodu yena waba yikosikazi ye-Swaziland. Inhlokodolobha yakhe yobukhosi gade iseMbekelweni. Ngesikhathi sobukhosi bakhe u-Mbandzeni wanikela ngeemvume ezinengi zemayini, ukulima, ukurhweba kanye nokuphatha ebantwini abamhlophe abavela e-Britain ne-Transvaal. AmaBhunu bekakhohlise ikosi bona isayine iimvumelwano zomhlaba unomphela. Ikosi beyingakghoni ukufunda nokutlola, njeke amaBhunu amenza bona atlikitle iimvumo ngesiphambano. Ikosi yatjelwa bona bekungasiwo umhlaba onomphela kodwana amaphepha ngokwawo atjho ngenye indlela. Ukuvunyelwa okunikelwe ngokusizwa ngu-Offy Sherpstone ekugcineni kwaholela emihlanganweni ka-1884 no-1894, eyehlisa imingcele ye-Swaziland begodu ngokukhamba kwesikhathi yenza i-Swaziland yaba yindawo evikelweko ye-South African Republic.&lt;ref&gt;https://link.springer.com/chapter/10.1057/9780230271159_157&lt;/ref&gt;</text>
      <sha1>q9mt7xbtaey2f1hxohh52cnaurn04nu</sha1>
    </revision>
    <revision>
      <id>2303</id>
      <parentid>2302</parentid>
      <timestamp>2024-12-28T01:49:32Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2303</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1969" sha1="i6okux8tnwtdrukmgs1w88ciolxwp86" xml:space="preserve">U-Mbandzeni (owaziwa nangokuthi ngu-Dlamini IV, Umbandine,] Umbandeen[3]) (c. 1855–1889) bekayiKosi ye-Swaziland (manje eyi-Eswatini) kusukela ngo-1872 bekube ngu-1889. Ingwenyama Mbandzeni bekayindodana ka-Mswati II no-Nandzi Nkambule . Unina umfazi weKosi uMswati bekahlongakele asesemncani khulu.&lt;ref&gt;https://landportal.org/sites/default/files/library/resources/20210202%2520Eswatini%2520timeline%2520FINAL.pdf&lt;/ref&gt;&lt;ref&gt;https://www.cambridge.org/core/journals/journal-of-african-history/article/abs/pedi-go-down-the-land-belongs-to-us-the-pedi-polity-the-boers-and-the-british-in-the-nineteenth-century-transvaal-by-delius-peter-johannesburg-ravan-press-london-heinemann-educational-books-19831984-pp-xiv-279-1650/220FB6C835F8C0259C1BB25F090A50F2&lt;/ref&gt;

U-Mbandzeni wakhwela esihlalweni sobukhosi ngemva kobana umfowabo u-Ludvonga II ahlongakale ngaphambi kobana abe yikosi. Ukuhlongakala kwaka-Ludvonga kwabangela bona unina u-Inkhosikati Lamgangeni amukele u-Mbandzeni obekangananina njengendodanakhe, lokho kwamenza waba yikosi begodu yena waba yikosikazi ye-Swaziland. Inhlokodolobha yakhe yobukhosi gade iseMbekelweni. Ngesikhathi sobukhosi bakhe u-Mbandzeni wanikela ngeemvume ezinengi zemayini, ukulima, ukurhweba kanye nokuphatha ebantwini abamhlophe abavela e-Britain ne-Transvaal. AmaBhunu bekakhohlise ikosi bona isayine iimvumelwano zomhlaba unomphela. Ikosi beyingakghoni ukufunda nokutlola, njeke amaBhunu amenza bona atlikitle iimvumo ngesiphambano. Ikosi yatjelwa bona bekungasiwo umhlaba onomphela kodwana amaphepha ngokwawo atjho ngenye indlela. Ukuvunyelwa okunikelwe ngokusizwa ngu-Offy Sherpstone ekugcineni kwaholela emihlanganweni ka-1884 no-1894, eyehlisa imingcele ye-Swaziland begodu ngokukhamba kwesikhathi yenza i-Swaziland yaba yindawo evikelweko ye-South African Republic.&lt;ref&gt;https://link.springer.com/chapter/10.1057/9780230271159_157&lt;/ref&gt;&lt;ref&gt;https://www.taylorfrancis.com/books/mono/10.4324/9781315306797/swazi-hilda-kuper&lt;/ref&gt;</text>
      <sha1>i6okux8tnwtdrukmgs1w88ciolxwp86</sha1>
    </revision>
    <revision>
      <id>2304</id>
      <parentid>2303</parentid>
      <timestamp>2024-12-28T01:49:54Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2304</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1985" sha1="kk9vju8bhd1zs6nhyopb6dru0ex1hcq" xml:space="preserve">U-Mbandzeni (owaziwa nangokuthi ngu-Dlamini IV, Umbandine,] Umbandeen[3]) (c. 1855–1889) bekayiKosi ye-Swaziland (manje eyi-Eswatini) kusukela ngo-1872 bekube ngu-1889. Ingwenyama Mbandzeni bekayindodana ka-Mswati II no-Nandzi Nkambule . Unina umfazi weKosi uMswati bekahlongakele asesemncani khulu.&lt;ref&gt;https://landportal.org/sites/default/files/library/resources/20210202%2520Eswatini%2520timeline%2520FINAL.pdf&lt;/ref&gt;&lt;ref&gt;https://www.cambridge.org/core/journals/journal-of-african-history/article/abs/pedi-go-down-the-land-belongs-to-us-the-pedi-polity-the-boers-and-the-british-in-the-nineteenth-century-transvaal-by-delius-peter-johannesburg-ravan-press-london-heinemann-educational-books-19831984-pp-xiv-279-1650/220FB6C835F8C0259C1BB25F090A50F2&lt;/ref&gt;

U-Mbandzeni wakhwela esihlalweni sobukhosi ngemva kobana umfowabo u-Ludvonga II ahlongakale ngaphambi kobana abe yikosi. Ukuhlongakala kwaka-Ludvonga kwabangela bona unina u-Inkhosikati Lamgangeni amukele u-Mbandzeni obekangananina njengendodanakhe, lokho kwamenza waba yikosi begodu yena waba yikosikazi ye-Swaziland. Inhlokodolobha yakhe yobukhosi gade iseMbekelweni. Ngesikhathi sobukhosi bakhe u-Mbandzeni wanikela ngeemvume ezinengi zemayini, ukulima, ukurhweba kanye nokuphatha ebantwini abamhlophe abavela e-Britain ne-Transvaal. AmaBhunu bekakhohlise ikosi bona isayine iimvumelwano zomhlaba unomphela. Ikosi beyingakghoni ukufunda nokutlola, njeke amaBhunu amenza bona atlikitle iimvumo ngesiphambano. Ikosi yatjelwa bona bekungasiwo umhlaba onomphela kodwana amaphepha ngokwawo atjho ngenye indlela. Ukuvunyelwa okunikelwe ngokusizwa ngu-Offy Sherpstone ekugcineni kwaholela emihlanganweni ka-1884 no-1894, eyehlisa imingcele ye-Swaziland begodu ngokukhamba kwesikhathi yenza i-Swaziland yaba yindawo evikelweko ye-South African Republic.&lt;ref&gt;https://link.springer.com/chapter/10.1057/9780230271159_157&lt;/ref&gt;&lt;ref&gt;https://www.taylorfrancis.com/books/mono/10.4324/9781315306797/swazi-hilda-kuper&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>kk9vju8bhd1zs6nhyopb6dru0ex1hcq</sha1>
    </revision>
    <revision>
      <id>2305</id>
      <parentid>2304</parentid>
      <timestamp>2024-12-28T01:50:46Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2305</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1995" sha1="otc0ahqyyj2shd41db2w1nw3za8uc0s" xml:space="preserve">'''U-Mbandzeni''' (owaziwa nangokuthi ngu-Dlamini IV, Umbandine,] Umbandeen[3]) (c. 1855–1889) bekayiKosi ye-Swaziland (manje eyi-[[Eswatini]]) kusukela ngo-1872 bekube ngu-1889. Ingwenyama Mbandzeni bekayindodana ka-Mswati II no-Nandzi Nkambule . Unina umfazi weKosi uMswati bekahlongakele asesemncani khulu.&lt;ref&gt;https://landportal.org/sites/default/files/library/resources/20210202%2520Eswatini%2520timeline%2520FINAL.pdf&lt;/ref&gt;&lt;ref&gt;https://www.cambridge.org/core/journals/journal-of-african-history/article/abs/pedi-go-down-the-land-belongs-to-us-the-pedi-polity-the-boers-and-the-british-in-the-nineteenth-century-transvaal-by-delius-peter-johannesburg-ravan-press-london-heinemann-educational-books-19831984-pp-xiv-279-1650/220FB6C835F8C0259C1BB25F090A50F2&lt;/ref&gt;

U-Mbandzeni wakhwela esihlalweni sobukhosi ngemva kobana umfowabo u-Ludvonga II ahlongakale ngaphambi kobana abe yikosi. Ukuhlongakala kwaka-Ludvonga kwabangela bona unina u-Inkhosikati Lamgangeni amukele u-Mbandzeni obekangananina njengendodanakhe, lokho kwamenza waba yikosi begodu yena waba yikosikazi ye-Swaziland. Inhlokodolobha yakhe yobukhosi gade iseMbekelweni. Ngesikhathi sobukhosi bakhe u-Mbandzeni wanikela ngeemvume ezinengi zemayini, ukulima, ukurhweba kanye nokuphatha ebantwini abamhlophe abavela e-Britain ne-Transvaal. AmaBhunu bekakhohlise ikosi bona isayine iimvumelwano zomhlaba unomphela. Ikosi beyingakghoni ukufunda nokutlola, njeke amaBhunu amenza bona atlikitle iimvumo ngesiphambano. Ikosi yatjelwa bona bekungasiwo umhlaba onomphela kodwana amaphepha ngokwawo atjho ngenye indlela. Ukuvunyelwa okunikelwe ngokusizwa ngu-Offy Sherpstone ekugcineni kwaholela emihlanganweni ka-1884 no-1894, eyehlisa imingcele ye-Swaziland begodu ngokukhamba kwesikhathi yenza i-Swaziland yaba yindawo evikelweko ye-South African Republic.&lt;ref&gt;https://link.springer.com/chapter/10.1057/9780230271159_157&lt;/ref&gt;&lt;ref&gt;https://www.taylorfrancis.com/books/mono/10.4324/9781315306797/swazi-hilda-kuper&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>otc0ahqyyj2shd41db2w1nw3za8uc0s</sha1>
    </revision>
    <revision>
      <id>2306</id>
      <parentid>2305</parentid>
      <timestamp>2024-12-28T01:51:36Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2306</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2003" sha1="fyfc27fq7p0d760r6vlu0xbi1xa2z5r" xml:space="preserve">'''U-Mbandzeni''' (owaziwa nangokuthi ngu-Dlamini IV, Umbandine,] Umbandeen[3]) (c. 1855–1889) bekayiKosi ye-Swaziland (manje eyi-[[Eswatini]]) kusukela ngo-1872 bekube ngu-1889. Ingwenyama Mbandzeni bekayindodana ka-Mswati II no-Nandzi Nkambule . Unina umfazi weKosi uMswati bekahlongakele asesemncani khulu.&lt;ref&gt;https://landportal.org/sites/default/files/library/resources/20210202%2520Eswatini%2520timeline%2520FINAL.pdf&lt;/ref&gt;&lt;ref&gt;https://www.cambridge.org/core/journals/journal-of-african-history/article/abs/pedi-go-down-the-land-belongs-to-us-the-pedi-polity-the-boers-and-the-british-in-the-nineteenth-century-transvaal-by-delius-peter-johannesburg-ravan-press-london-heinemann-educational-books-19831984-pp-xiv-279-1650/220FB6C835F8C0259C1BB25F090A50F2&lt;/ref&gt;

U-Mbandzeni wakhwela esihlalweni sobukhosi ngemva kobana umfowabo u-Ludvonga II ahlongakale ngaphambi kobana abe yikosi. Ukuhlongakala kwaka-Ludvonga kwabangela bona unina u-Inkhosikati Lamgangeni amukele u-Mbandzeni obekangananina njengendodanakhe, lokho kwamenza waba yikosi begodu yena waba yikosikazi ye-Swaziland. Inhlokodolobha yakhe yobukhosi gade iseMbekelweni. Ngesikhathi sobukhosi bakhe u-Mbandzeni wanikela ngeemvume ezinengi zemayini, ukulima, ukurhweba kanye nokuphatha ebantwini abamhlophe abavela e-[[Britain]] ne-Transvaal. AmaBhunu bekakhohlise ikosi bona isayine iimvumelwano zomhlaba unomphela. Ikosi beyingakghoni ukufunda nokutlola, njeke amaBhunu amenza bona atlikitle iimvumo ngesiphambano. Ikosi yatjelwa bona bekungasiwo umhlaba onomphela kodwana amaphepha ngokwawo atjho ngenye indlela. Ukuvunyelwa okunikelwe ngokusizwa ngu-[[Offy Sherpstone]] ekugcineni kwaholela emihlanganweni ka-1884 no-1894, eyehlisa imingcele ye-Swaziland begodu ngokukhamba kwesikhathi yenza i-Swaziland yaba yindawo evikelweko ye-South African Republic.&lt;ref&gt;https://link.springer.com/chapter/10.1057/9780230271159_157&lt;/ref&gt;&lt;ref&gt;https://www.taylorfrancis.com/books/mono/10.4324/9781315306797/swazi-hilda-kuper&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>fyfc27fq7p0d760r6vlu0xbi1xa2z5r</sha1>
    </revision>
    <revision>
      <id>2307</id>
      <parentid>2306</parentid>
      <timestamp>2024-12-28T01:52:29Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2307</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2007" sha1="hyhygtzhx0u3v1i9ks2gh6ok3gek1n6" xml:space="preserve">'''U-Mbandzeni''' (owaziwa nangokuthi ngu-Dlamini IV, Umbandine,] Umbandeen[3]) (c. 1855–1889) bekayiKosi ye-Swaziland (manje eyi-[[Eswatini]]) kusukela ngo-1872 bekube ngu-1889. Ingwenyama Mbandzeni bekayindodana ka-Mswati II no-Nandzi Nkambule . Unina umfazi weKosi uMswati bekahlongakele asesemncani khulu.&lt;ref&gt;https://landportal.org/sites/default/files/library/resources/20210202%2520Eswatini%2520timeline%2520FINAL.pdf&lt;/ref&gt;&lt;ref&gt;https://www.cambridge.org/core/journals/journal-of-african-history/article/abs/pedi-go-down-the-land-belongs-to-us-the-pedi-polity-the-boers-and-the-british-in-the-nineteenth-century-transvaal-by-delius-peter-johannesburg-ravan-press-london-heinemann-educational-books-19831984-pp-xiv-279-1650/220FB6C835F8C0259C1BB25F090A50F2&lt;/ref&gt;

U-Mbandzeni wakhwela esihlalweni sobukhosi ngemva kobana umfowabo u-[[Ludvonga]] II ahlongakale ngaphambi kobana abe yikosi. Ukuhlongakala kwaka-Ludvonga kwabangela bona unina u-Inkhosikati Lamgangeni amukele u-Mbandzeni obekangananina njengendodanakhe, lokho kwamenza waba yikosi begodu yena waba yikosikazi ye-Swaziland. Inhlokodolobha yakhe yobukhosi gade iseMbekelweni. Ngesikhathi sobukhosi bakhe u-Mbandzeni wanikela ngeemvume ezinengi zemayini, ukulima, ukurhweba kanye nokuphatha ebantwini abamhlophe abavela e-[[Britain]] ne-Transvaal. AmaBhunu bekakhohlise ikosi bona isayine iimvumelwano zomhlaba unomphela. Ikosi beyingakghoni ukufunda nokutlola, njeke amaBhunu amenza bona atlikitle iimvumo ngesiphambano. Ikosi yatjelwa bona bekungasiwo umhlaba onomphela kodwana amaphepha ngokwawo atjho ngenye indlela. Ukuvunyelwa okunikelwe ngokusizwa ngu-[[Offy Sherpstone]] ekugcineni kwaholela emihlanganweni ka-1884 no-1894, eyehlisa imingcele ye-Swaziland begodu ngokukhamba kwesikhathi yenza i-Swaziland yaba yindawo evikelweko ye-South African Republic.&lt;ref&gt;https://link.springer.com/chapter/10.1057/9780230271159_157&lt;/ref&gt;&lt;ref&gt;https://www.taylorfrancis.com/books/mono/10.4324/9781315306797/swazi-hilda-kuper&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>hyhygtzhx0u3v1i9ks2gh6ok3gek1n6</sha1>
    </revision>
    <revision>
      <id>2308</id>
      <parentid>2307</parentid>
      <timestamp>2024-12-28T01:53:43Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2308</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2019" sha1="kanlh58x430ob60a5kiiqc51bdsf2y4" xml:space="preserve">'''U-Mbandzeni''' (owaziwa nangokuthi ngu-Dlamini IV, Umbandine,] Umbandeen[3]) (c. 1855–1889) bekayiKosi ye-Swaziland (manje eyi-[[Eswatini]]) kusukela ngo-1872 bekube ngu-1889. Ingwenyama Mbandzeni bekayindodana ka-Mswati II no-Nandzi Nkambule . Unina umfazi weKosi uMswati bekahlongakele asesemncani khulu.&lt;ref&gt;https://landportal.org/sites/default/files/library/resources/20210202%2520Eswatini%2520timeline%2520FINAL.pdf&lt;/ref&gt;&lt;ref&gt;https://www.cambridge.org/core/journals/journal-of-african-history/article/abs/pedi-go-down-the-land-belongs-to-us-the-pedi-polity-the-boers-and-the-british-in-the-nineteenth-century-transvaal-by-delius-peter-johannesburg-ravan-press-london-heinemann-educational-books-19831984-pp-xiv-279-1650/220FB6C835F8C0259C1BB25F090A50F2&lt;/ref&gt;

U-Mbandzeni wakhwela esihlalweni sobukhosi ngemva kobana umfowabo u-[[Ludvonga]] II ahlongakale ngaphambi kobana abe yikosi. Ukuhlongakala kwaka-Ludvonga kwabangela bona unina u-Inkhosikati Lamgangeni amukele u-Mbandzeni obekangananina njengendodanakhe, lokho kwamenza waba yikosi begodu yena waba yikosikazi ye-Swaziland. Inhlokodolobha yakhe yobukhosi gade iseMbekelweni. Ngesikhathi sobukhosi bakhe u-Mbandzeni wanikela ngeemvume ezinengi zemayini, ukulima, ukurhweba kanye nokuphatha ebantwini abamhlophe abavela e-[[Britain]] ne-Transvaal. AmaBhunu bekakhohlise ikosi bona isayine iimvumelwano zomhlaba unomphela. Ikosi beyingakghoni ukufunda nokutlola, njeke amaBhunu amenza bona atlikitle iimvumo ngesiphambano. Ikosi yatjelwa bona bekungasiwo umhlaba onomphela kodwana amaphepha ngokwawo atjho ngenye indlela. Ukuvunyelwa okunikelwe ngokusizwa ngu-[[Offy Sherpstone]] ekugcineni kwaholela emihlanganweni ka-1884 no-1894, eyehlisa imingcele ye-Swaziland begodu ngokukhamba kwesikhathi yenza i-Swaziland yaba yindawo evikelweko ye-South African Republic.&lt;ref&gt;https://link.springer.com/chapter/10.1057/9780230271159_157&lt;/ref&gt;&lt;ref&gt;https://www.taylorfrancis.com/books/mono/10.4324/9781315306797/swazi-hilda-kuper&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}</text>
      <sha1>kanlh58x430ob60a5kiiqc51bdsf2y4</sha1>
    </revision>
    <revision>
      <id>2309</id>
      <parentid>2308</parentid>
      <timestamp>2024-12-28T01:54:45Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2309</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2070" sha1="q3omfsrs4gw5xz9k0j1bi9pbobveofm" xml:space="preserve">'''U-Mbandzeni''' (owaziwa nangokuthi ngu-Dlamini IV, Umbandine,] Umbandeen[3]) (c. 1855–1889) bekayiKosi ye-Swaziland (manje eyi-[[Eswatini]]) kusukela ngo-1872 bekube ngu-1889. Ingwenyama Mbandzeni bekayindodana ka-Mswati II no-Nandzi Nkambule . Unina umfazi weKosi uMswati bekahlongakele asesemncani khulu.&lt;ref&gt;https://landportal.org/sites/default/files/library/resources/20210202%2520Eswatini%2520timeline%2520FINAL.pdf&lt;/ref&gt;&lt;ref&gt;https://www.cambridge.org/core/journals/journal-of-african-history/article/abs/pedi-go-down-the-land-belongs-to-us-the-pedi-polity-the-boers-and-the-british-in-the-nineteenth-century-transvaal-by-delius-peter-johannesburg-ravan-press-london-heinemann-educational-books-19831984-pp-xiv-279-1650/220FB6C835F8C0259C1BB25F090A50F2&lt;/ref&gt;

U-Mbandzeni wakhwela esihlalweni sobukhosi ngemva kobana umfowabo u-[[Ludvonga]] II ahlongakale ngaphambi kobana abe yikosi. Ukuhlongakala kwaka-Ludvonga kwabangela bona unina u-Inkhosikati Lamgangeni amukele u-Mbandzeni obekangananina njengendodanakhe, lokho kwamenza waba yikosi begodu yena waba yikosikazi ye-Swaziland. Inhlokodolobha yakhe yobukhosi gade iseMbekelweni. Ngesikhathi sobukhosi bakhe u-Mbandzeni wanikela ngeemvume ezinengi zemayini, ukulima, ukurhweba kanye nokuphatha ebantwini abamhlophe abavela e-[[Britain]] ne-Transvaal. AmaBhunu bekakhohlise ikosi bona isayine iimvumelwano zomhlaba unomphela. Ikosi beyingakghoni ukufunda nokutlola, njeke amaBhunu amenza bona atlikitle iimvumo ngesiphambano. Ikosi yatjelwa bona bekungasiwo umhlaba onomphela kodwana amaphepha ngokwawo atjho ngenye indlela. Ukuvunyelwa okunikelwe ngokusizwa ngu-[[Offy Sherpstone]] ekugcineni kwaholela emihlanganweni ka-1884 no-1894, eyehlisa imingcele ye-Swaziland begodu ngokukhamba kwesikhathi yenza i-Swaziland yaba yindawo evikelweko ye-South African Republic.&lt;ref&gt;https://link.springer.com/chapter/10.1057/9780230271159_157&lt;/ref&gt;&lt;ref&gt;https://www.taylorfrancis.com/books/mono/10.4324/9781315306797/swazi-hilda-kuper&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}
[[Category:Amakhosi eAfrika]]
[[Category:Umlando]]</text>
      <sha1>q3omfsrs4gw5xz9k0j1bi9pbobveofm</sha1>
    </revision>
    <revision>
      <id>2624</id>
      <parentid>2309</parentid>
      <timestamp>2025-04-03T19:07:56Z</timestamp>
      <contributor>
        <username>Rachmat04</username>
        <id>32</id>
      </contributor>
      <minor />
      <origin>2624</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2069" sha1="prgsngyypbgqgdz2t98biv13okjgsw6" xml:space="preserve">'''U-Mbandzeni''' (owaziwa nangokuthi ngu-Dlamini IV, Umbandine,] Umbandeen[3]) (c. 1855–1889) bekayiKosi ye-Swaziland (manje eyi-[[Eswatini]]) kusukela ngo-1872 bekube ngu-1889. Ingwenyama Mbandzeni bekayindodana ka-Mswati II no-Nandzi Nkambule . Unina umfazi weKosi uMswati bekahlongakele asesemncani khulu.&lt;ref&gt;https://landportal.org/sites/default/files/library/resources/20210202%2520Eswatini%2520timeline%2520FINAL.pdf&lt;/ref&gt;&lt;ref&gt;https://www.cambridge.org/core/journals/journal-of-african-history/article/abs/pedi-go-down-the-land-belongs-to-us-the-pedi-polity-the-boers-and-the-british-in-the-nineteenth-century-transvaal-by-delius-peter-johannesburg-ravan-press-london-heinemann-educational-books-19831984-pp-xiv-279-1650/220FB6C835F8C0259C1BB25F090A50F2&lt;/ref&gt;

U-Mbandzeni wakhwela esihlalweni sobukhosi ngemva kobana umfowabo u-[[Ludvonga]] II ahlongakale ngaphambi kobana abe yikosi. Ukuhlongakala kwaka-Ludvonga kwabangela bona unina u-Inkhosikati Lamgangeni amukele u-Mbandzeni obekangananina njengendodanakhe, lokho kwamenza waba yikosi begodu yena waba yikosikazi ye-Swaziland. Inhlokodolobha yakhe yobukhosi gade iseMbekelweni. Ngesikhathi sobukhosi bakhe u-Mbandzeni wanikela ngeemvume ezinengi zemayini, ukulima, ukurhweba kanye nokuphatha ebantwini abamhlophe abavela e-[[Britain]] ne-Transvaal. AmaBhunu bekakhohlise ikosi bona isayine iimvumelwano zomhlaba unomphela. Ikosi beyingakghoni ukufunda nokutlola, njeke amaBhunu amenza bona atlikitle iimvumo ngesiphambano. Ikosi yatjelwa bona bekungasiwo umhlaba onomphela kodwana amaphepha ngokwawo atjho ngenye indlela. Ukuvunyelwa okunikelwe ngokusizwa ngu-[[Offy Sherpstone]] ekugcineni kwaholela emihlanganweni ka-1884 no-1894, eyehlisa imingcele ye-Swaziland begodu ngokukhamba kwesikhathi yenza i-Swaziland yaba yindawo evikelweko ye-South African Republic.&lt;ref&gt;https://link.springer.com/chapter/10.1057/9780230271159_157&lt;/ref&gt;&lt;ref&gt;https://www.taylorfrancis.com/books/mono/10.4324/9781315306797/swazi-hilda-kuper&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}

[[Mkhakha:Amakhosi eAfrika]]
[[Mkhakha:Umlando]]</text>
      <sha1>prgsngyypbgqgdz2t98biv13okjgsw6</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Amakhosi eAfrika</title>
    <ns>14</ns>
    <id>427</id>
    <revision>
      <id>2310</id>
      <timestamp>2024-12-28T01:54:59Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created blank page</comment>
      <origin>2310</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
  </page>
  <page>
    <title>Ludvonga</title>
    <ns>0</ns>
    <id>428</id>
    <revision>
      <id>2311</id>
      <timestamp>2024-12-28T01:57:07Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created page with &quot;U-Ludvonga II (c. 1855 – 1872) bekanguMbusi we-Swaziland, indodana ka-Mswati II we-Swaziland.[1] Ikoro kanina bekunguKhumalo. Ngebanga lokulwa kwamandla ngaphakathi emndenini wekosi, wabulawa ubuthi begodu wahlongakala ngo-1872 ngaphambi kobana athathe isihlalo sobukhosi.[2] Wathathelwa indawo ngumfowabo uMbandzeni, owamukelwa ngunina kaLudvonga.&quot;</comment>
      <origin>2311</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="350" sha1="sn072arph1hdqdqbm26txo8a4kzvjfr" xml:space="preserve">U-Ludvonga II (c. 1855 – 1872) bekanguMbusi we-Swaziland, indodana ka-Mswati II we-Swaziland.[1] Ikoro kanina bekunguKhumalo. Ngebanga lokulwa kwamandla ngaphakathi emndenini wekosi, wabulawa ubuthi begodu wahlongakala ngo-1872 ngaphambi kobana athathe isihlalo sobukhosi.[2] Wathathelwa indawo ngumfowabo uMbandzeni, owamukelwa ngunina kaLudvonga.</text>
      <sha1>sn072arph1hdqdqbm26txo8a4kzvjfr</sha1>
    </revision>
    <revision>
      <id>2312</id>
      <parentid>2311</parentid>
      <timestamp>2024-12-28T01:58:57Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2312</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="603" sha1="27okq2ya2jx9x3gi0hymyjb80uegqn6" xml:space="preserve">U-Ludvonga II (c. 1855 – 1872) bekanguMbusi we-Swaziland, indodana ka-Mswati II we-Swaziland.[1] Ikoro kanina bekunguKhumalo. Ngebanga lokulwa kwamandla ngaphakathi emndenini wekosi, wabulawa ubuthi begodu wahlongakala ngo-1872 ngaphambi kobana athathe isihlalo sobukhosi.[2] Wathathelwa indawo ngumfowabo uMbandzeni, owamukelwa ngunina kaLudvonga.&lt;ref&gt;https://www.taylorfrancis.com/books/mono/10.4324/9781315306797/swazi-hilda-kuper&lt;/ref&gt;&lt;ref&gt;https://bestencyclopedia.com/Mswati_II&lt;/ref&gt;&lt;ref&gt;https://ujcontent.uj.ac.za/view/pdfCoverPage?instCode=27UOJ_INST&amp;filePid=136778940007691&amp;download=true&lt;/ref&gt;</text>
      <sha1>27okq2ya2jx9x3gi0hymyjb80uegqn6</sha1>
    </revision>
    <revision>
      <id>2313</id>
      <parentid>2312</parentid>
      <timestamp>2024-12-28T02:00:06Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2313</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="711" sha1="dpqgp7hcvx2eneg22pu5d6t89ffb9w9" xml:space="preserve">U-Ludvonga II (c. 1855 – 1872) bekanguMbusi we-Swaziland, indodana ka-Mswati II we-Swaziland.&lt;ref&gt;https://wiredspace.wits.ac.za/server/api/core/bitstreams/5859a9c9-cba9-4c1a-a29e-39730ef49654/content&lt;/ref&gt;Ikoro kanina bekunguKhumalo. Ngebanga lokulwa kwamandla ngaphakathi emndenini wekosi, wabulawa ubuthi begodu wahlongakala ngo-1872 ngaphambi kobana athathe isihlalo sobukhosi.[2] Wathathelwa indawo ngumfowabo uMbandzeni, owamukelwa ngunina kaLudvonga.&lt;ref&gt;https://www.taylorfrancis.com/books/mono/10.4324/9781315306797/swazi-hilda-kuper&lt;/ref&gt;&lt;ref&gt;https://bestencyclopedia.com/Mswati_II&lt;/ref&gt;&lt;ref&gt;https://ujcontent.uj.ac.za/view/pdfCoverPage?instCode=27UOJ_INST&amp;filePid=136778940007691&amp;download=true&lt;/ref&gt;</text>
      <sha1>dpqgp7hcvx2eneg22pu5d6t89ffb9w9</sha1>
    </revision>
    <revision>
      <id>2314</id>
      <parentid>2313</parentid>
      <timestamp>2024-12-28T02:00:31Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2314</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="707" sha1="hq5h12j1feq0l12oi2r0i0sxg0raf1l" xml:space="preserve">U-Ludvonga II (c. 1855 – 1872) bekanguMbusi we-Swaziland, indodana ka-Mswati II we-Swaziland.&lt;ref&gt;https://wiredspace.wits.ac.za/server/api/core/bitstreams/5859a9c9-cba9-4c1a-a29e-39730ef49654/content&lt;/ref&gt;Ikoro kanina bekunguKhumalo. Ngebanga lokulwa kwamandla ngaphakathi emndenini wekosi, wabulawa ubuthi begodu wahlongakala ngo-1872 ngaphambi kobana athathe isihlalo sobukhosi.Wathathelwa indawo ngumfowabo uMbandzeni, owamukelwa ngunina kaLudvonga.&lt;ref&gt;https://www.taylorfrancis.com/books/mono/10.4324/9781315306797/swazi-hilda-kuper&lt;/ref&gt;&lt;ref&gt;https://bestencyclopedia.com/Mswati_II&lt;/ref&gt;&lt;ref&gt;https://ujcontent.uj.ac.za/view/pdfCoverPage?instCode=27UOJ_INST&amp;filePid=136778940007691&amp;download=true&lt;/ref&gt;</text>
      <sha1>hq5h12j1feq0l12oi2r0i0sxg0raf1l</sha1>
    </revision>
    <revision>
      <id>2315</id>
      <parentid>2314</parentid>
      <timestamp>2024-12-28T02:02:20Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2315</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="733" sha1="cflf6d9ctqhhrwezpdugim8vmpqw7wh" xml:space="preserve">U-Ludvonga II (c. 1855 – 1872) bekanguMbusi we-Swaziland, indodana ka-Mswati II we-[[Swaziland|Eswatini]].&lt;ref&gt;https://wiredspace.wits.ac.za/server/api/core/bitstreams/5859a9c9-cba9-4c1a-a29e-39730ef49654/content&lt;/ref&gt;Ikoro kanina bekunguKhumalo. Ngebanga lokulwa kwamandla ngaphakathi emndenini wekosi, wabulawa ubuthi begodu wahlongakala ngo-1872 ngaphambi kobana athathe isihlalo sobukhosi.Wathathelwa indawo ngumfowabo uMbandzeni, owamukelwa ngunina kaLudvonga.&lt;ref&gt;https://www.taylorfrancis.com/books/mono/10.4324/9781315306797/swazi-hilda-kuper&lt;/ref&gt;&lt;ref&gt;https://bestencyclopedia.com/Mswati_II&lt;/ref&gt;&lt;ref&gt;https://ujcontent.uj.ac.za/view/pdfCoverPage?instCode=27UOJ_INST&amp;filePid=136778940007691&amp;download=true&lt;/ref&gt;
==Iinkomba==</text>
      <sha1>cflf6d9ctqhhrwezpdugim8vmpqw7wh</sha1>
    </revision>
    <revision>
      <id>2316</id>
      <parentid>2315</parentid>
      <timestamp>2024-12-28T02:03:15Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2316</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="797" sha1="3qbdhdiir9ul99kaw6hhilcl2v82jsm" xml:space="preserve">U-Ludvonga II (c. 1855 – 1872) bekanguMbusi we-Swaziland, indodana ka-Mswati II we-[[Swaziland|Eswatini]].&lt;ref&gt;https://wiredspace.wits.ac.za/server/api/core/bitstreams/5859a9c9-cba9-4c1a-a29e-39730ef49654/content&lt;/ref&gt;Ikoro kanina bekunguKhumalo. Ngebanga lokulwa kwamandla ngaphakathi emndenini wekosi, wabulawa ubuthi begodu wahlongakala ngo-1872 ngaphambi kobana athathe isihlalo sobukhosi.Wathathelwa indawo ngumfowabo uMbandzeni, owamukelwa ngunina kaLudvonga.&lt;ref&gt;https://www.taylorfrancis.com/books/mono/10.4324/9781315306797/swazi-hilda-kuper&lt;/ref&gt;&lt;ref&gt;https://bestencyclopedia.com/Mswati_II&lt;/ref&gt;&lt;ref&gt;https://ujcontent.uj.ac.za/view/pdfCoverPage?instCode=27UOJ_INST&amp;filePid=136778940007691&amp;download=true&lt;/ref&gt;
==Iinkomba==
{{Reflist}}
[[Category:Emakhosi eAfrika]]
[[Category: Umlando]]</text>
      <sha1>3qbdhdiir9ul99kaw6hhilcl2v82jsm</sha1>
    </revision>
    <revision>
      <id>2317</id>
      <parentid>2316</parentid>
      <timestamp>2024-12-28T02:03:55Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2317</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="797" sha1="5kcwyhey7lofvagvijce2jknp13tpxm" xml:space="preserve">U-Ludvonga II (c. 1855 – 1872) bekanguMbusi we-Swaziland, indodana ka-Mswati II we-[[Swaziland|Eswatini]].&lt;ref&gt;https://wiredspace.wits.ac.za/server/api/core/bitstreams/5859a9c9-cba9-4c1a-a29e-39730ef49654/content&lt;/ref&gt;Ikoro kanina bekunguKhumalo. Ngebanga lokulwa kwamandla ngaphakathi emndenini wekosi, wabulawa ubuthi begodu wahlongakala ngo-1872 ngaphambi kobana athathe isihlalo sobukhosi.Wathathelwa indawo ngumfowabo uMbandzeni, owamukelwa ngunina kaLudvonga.&lt;ref&gt;https://www.taylorfrancis.com/books/mono/10.4324/9781315306797/swazi-hilda-kuper&lt;/ref&gt;&lt;ref&gt;https://bestencyclopedia.com/Mswati_II&lt;/ref&gt;&lt;ref&gt;https://ujcontent.uj.ac.za/view/pdfCoverPage?instCode=27UOJ_INST&amp;filePid=136778940007691&amp;download=true&lt;/ref&gt;
==Iinkomba==
{{Reflist}}
[[Category:Amakhosi eAfrika]]
[[Category: Umlando]]</text>
      <sha1>5kcwyhey7lofvagvijce2jknp13tpxm</sha1>
    </revision>
    <revision>
      <id>2631</id>
      <parentid>2317</parentid>
      <timestamp>2025-04-03T19:09:29Z</timestamp>
      <contributor>
        <username>Rachmat04</username>
        <id>32</id>
      </contributor>
      <minor />
      <origin>2631</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="797" sha1="12w4natyzzppcrm8avh1nvpbzrr8h00" xml:space="preserve">U-Ludvonga II (c. 1855 – 1872) bekanguMbusi we-Swaziland, indodana ka-Mswati II we-[[Swaziland|Eswatini]].&lt;ref&gt;https://wiredspace.wits.ac.za/server/api/core/bitstreams/5859a9c9-cba9-4c1a-a29e-39730ef49654/content&lt;/ref&gt;Ikoro kanina bekunguKhumalo. Ngebanga lokulwa kwamandla ngaphakathi emndenini wekosi, wabulawa ubuthi begodu wahlongakala ngo-1872 ngaphambi kobana athathe isihlalo sobukhosi.Wathathelwa indawo ngumfowabo uMbandzeni, owamukelwa ngunina kaLudvonga.&lt;ref&gt;https://www.taylorfrancis.com/books/mono/10.4324/9781315306797/swazi-hilda-kuper&lt;/ref&gt;&lt;ref&gt;https://bestencyclopedia.com/Mswati_II&lt;/ref&gt;&lt;ref&gt;https://ujcontent.uj.ac.za/view/pdfCoverPage?instCode=27UOJ_INST&amp;filePid=136778940007691&amp;download=true&lt;/ref&gt;
== Iinkomba ==
{{Reflist}}

[[Mkhakha:Amakhosi eAfrika]]
[[Mkhakha:Umlando]]</text>
      <sha1>12w4natyzzppcrm8avh1nvpbzrr8h00</sha1>
    </revision>
  </page>
  <page>
    <title>Eswatini</title>
    <ns>0</ns>
    <id>429</id>
    <revision>
      <id>2318</id>
      <timestamp>2024-12-28T02:06:21Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1263904506|Eswatini]]&quot;</comment>
      <origin>2318</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="573" sha1="mnhoku4htwafyjvktsrt0z2228pte01" xml:space="preserve">'''Eswatini'''  ngokusemthethweni uMbuso we-Eswatini begodu eyaziwa ngebizo layo langaphambilini elisemthethweni i-Swaziland (/ˈswɑːzilænd/ ☓-Swaziland) begodu yangaphambilini UmBuso we I-Swaziland,[1][2] lilizwe elinganamanzi eSewula ye-Afrika. Inomngcele we-Mozambique ngepumalanga yetlhagwini neSewula Afrika ngetlhagwini, ngeTjingalanga, ngesewula, neSewulapumalanga. I-Eswatini ingenye yeenarha ezincani khulu e-Afrika; nanyana kunjalo, ubujamo bezulu nendawo yayo ihlukile, ukusuka endaweni epholileko neneentaba ukuya eendaweni eziphasi ezitjhisako nezomileko.</text>
      <sha1>mnhoku4htwafyjvktsrt0z2228pte01</sha1>
    </revision>
    <revision>
      <id>2319</id>
      <parentid>2318</parentid>
      <timestamp>2024-12-28T02:07:22Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2319</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="666" sha1="gyxv4o0br1pdvgyxco0rmkdjzny852h" xml:space="preserve">'''Eswatini'''  ngokusemthethweni uMbuso we-Eswatini begodu eyaziwa ngebizo layo langaphambilini elisemthethweni i-Swaziland (/ˈswɑːzilænd/ ☓-Swaziland) begodu yangaphambilini UmBuso we I-Swaziland,&lt;ref&gt;https://www.elibrary.imf.org/downloadpdf/journals/019/2024/030/019.2024.issue-030-en.pdf&lt;/ref&gt; lilizwe elinganamanzi eSewula ye-Afrika. Inomngcele we-Mozambique ngepumalanga yetlhagwini neSewula Afrika ngetlhagwini, ngeTjingalanga, ngesewula, neSewulapumalanga. I-Eswatini ingenye yeenarha ezincani khulu e-Afrika; nanyana kunjalo, ubujamo bezulu nendawo yayo ihlukile, ukusuka endaweni epholileko neneentaba ukuya eendaweni eziphasi ezitjhisako nezomileko.</text>
      <sha1>gyxv4o0br1pdvgyxco0rmkdjzny852h</sha1>
    </revision>
    <revision>
      <id>2320</id>
      <parentid>2319</parentid>
      <timestamp>2024-12-28T02:08:23Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2320</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="758" sha1="7c7f78cxwpm1cimbsd5291y0tvl8ddw" xml:space="preserve">'''Eswatini'''  ngokusemthethweni uMbuso we-Eswatini begodu eyaziwa ngebizo layo langaphambilini elisemthethweni i-Swaziland (/ˈswɑːzilænd/ ☓-Swaziland) begodu yangaphambilini UmBuso we I-Swaziland,&lt;ref&gt;https://www.elibrary.imf.org/downloadpdf/journals/019/2024/030/019.2024.issue-030-en.pdf&lt;/ref&gt; lilizwe elinganamanzi eSewula ye-Afrika. Inomngcele we-Mozambique ngepumalanga yetlhagwini neSewula Afrika ngetlhagwini, ngeTjingalanga, ngesewula, neSewulapumalanga. I-Eswatini ingenye yeenarha ezincani khulu e-Afrika; nanyana kunjalo, ubujamo bezulu nendawo yayo ihlukile, ukusuka endaweni epholileko neneentaba ukuya eendaweni eziphasi ezitjhisako nezomileko.&lt;ref&gt;http://dspace.puet.edu.ua/bitstream/123456789/9592/1/tezy_dopovidey_xlii_ch.1.pdf&lt;/ref&gt;</text>
      <sha1>7c7f78cxwpm1cimbsd5291y0tvl8ddw</sha1>
    </revision>
    <revision>
      <id>2321</id>
      <parentid>2320</parentid>
      <timestamp>2024-12-28T02:08:56Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2321</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="825" sha1="gjvqh0guyn1vcfgxos34jnx8q5ut3ai" xml:space="preserve">'''Eswatini'''  ngokusemthethweni uMbuso we-Eswatini begodu eyaziwa ngebizo layo langaphambilini elisemthethweni i-Swaziland (/ˈswɑːzilænd/ ☓-Swaziland) begodu yangaphambilini UmBuso we I-Swaziland,&lt;ref&gt;https://www.elibrary.imf.org/downloadpdf/journals/019/2024/030/019.2024.issue-030-en.pdf&lt;/ref&gt; lilizwe elinganamanzi eSewula ye-Afrika. Inomngcele we-Mozambique ngepumalanga yetlhagwini neSewula Afrika ngetlhagwini, ngeTjingalanga, ngesewula, neSewulapumalanga. I-Eswatini ingenye yeenarha ezincani khulu e-Afrika; nanyana kunjalo, ubujamo bezulu nendawo yayo ihlukile, ukusuka endaweni epholileko neneentaba ukuya eendaweni eziphasi ezitjhisako nezomileko.&lt;ref&gt;https://link.springer.com/book/10.1007/978-3-030-24777-5&lt;/ref&gt;&lt;ref&gt;http://dspace.puet.edu.ua/bitstream/123456789/9592/1/tezy_dopovidey_xlii_ch.1.pdf&lt;/ref&gt;</text>
      <sha1>gjvqh0guyn1vcfgxos34jnx8q5ut3ai</sha1>
    </revision>
    <revision>
      <id>2322</id>
      <parentid>2321</parentid>
      <timestamp>2024-12-28T02:09:51Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2322</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="844" sha1="mw4vdkmk6bgdhdl5eu2rcaz8we1tabf" xml:space="preserve">'''Eswatini'''  ngokusemthethweni uMbuso we-Eswatini begodu eyaziwa ngebizo layo langaphambilini elisemthethweni i-Swaziland (/ˈswɑːzilænd/ ☓-Swaziland) begodu yangaphambilini UmBuso we I-Swaziland,&lt;ref&gt;https://www.elibrary.imf.org/downloadpdf/journals/019/2024/030/019.2024.issue-030-en.pdf&lt;/ref&gt; lilizwe elinganamanzi eSewula ye-Afrika. Inomngcele we-Mozambique ngepumalanga yetlhagwini ne[[Isewula Afrika|Sewula Afrika]] ngetlhagwini, ngeTjingalanga, ngesewula, neSewulapumalanga. I-Eswatini ingenye yeenarha ezincani khulu e-Afrika; nanyana kunjalo, ubujamo bezulu nendawo yayo ihlukile, ukusuka endaweni epholileko neneentaba ukuya eendaweni eziphasi ezitjhisako nezomileko.&lt;ref&gt;https://link.springer.com/book/10.1007/978-3-030-24777-5&lt;/ref&gt;&lt;ref&gt;http://dspace.puet.edu.ua/bitstream/123456789/9592/1/tezy_dopovidey_xlii_ch.1.pdf&lt;/ref&gt;</text>
      <sha1>mw4vdkmk6bgdhdl5eu2rcaz8we1tabf</sha1>
    </revision>
    <revision>
      <id>2323</id>
      <parentid>2322</parentid>
      <timestamp>2024-12-28T02:10:15Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2323</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="860" sha1="cyay2sclzaq9v12q5yn2sgmp4jdzjdn" xml:space="preserve">'''Eswatini'''  ngokusemthethweni uMbuso we-Eswatini begodu eyaziwa ngebizo layo langaphambilini elisemthethweni i-Swaziland (/ˈswɑːzilænd/ ☓-Swaziland) begodu yangaphambilini UmBuso we I-Swaziland,&lt;ref&gt;https://www.elibrary.imf.org/downloadpdf/journals/019/2024/030/019.2024.issue-030-en.pdf&lt;/ref&gt; lilizwe elinganamanzi eSewula ye-Afrika. Inomngcele we-Mozambique ngepumalanga yetlhagwini ne[[Isewula Afrika|Sewula Afrika]] ngetlhagwini, ngeTjingalanga, ngesewula, neSewulapumalanga. I-Eswatini ingenye yeenarha ezincani khulu e-Afrika; nanyana kunjalo, ubujamo bezulu nendawo yayo ihlukile, ukusuka endaweni epholileko neneentaba ukuya eendaweni eziphasi ezitjhisako nezomileko.&lt;ref&gt;https://link.springer.com/book/10.1007/978-3-030-24777-5&lt;/ref&gt;&lt;ref&gt;http://dspace.puet.edu.ua/bitstream/123456789/9592/1/tezy_dopovidey_xlii_ch.1.pdf&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>cyay2sclzaq9v12q5yn2sgmp4jdzjdn</sha1>
    </revision>
  </page>
  <page>
    <title>Swaziland</title>
    <ns>0</ns>
    <id>430</id>
    <revision>
      <id>2324</id>
      <timestamp>2024-12-28T02:12:21Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created page with &quot;'''Eswatini''' ngokusemthethweni uMbuso we-Eswatini begodu eyaziwa ngebizo layo langaphambilini elisemthethweni i-Swaziland (/ˈswɑːzilænd/ ☓-Swaziland) begodu yangaphambilini UmBuso we I-Swaziland, lilizwe elinganamanzi eSewula ye-Afrika. Inomngcele we-Mozambique ngepumalanga yetlhagwini ne[[Isewula Afrika|Sewula Afrika]] ngetlhagwini, ngeTjingalanga, ngesewula, neSewulapumalanga. I-Eswatini ingenye yeenarha ezincani khulu e-Afrika; nanyana kunjalo, ubujamo bezulu...&quot;</comment>
      <origin>2324</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="585" sha1="9bdlsgcfu1pylc0b9q9ayevlonqoyuk" xml:space="preserve">'''Eswatini''' ngokusemthethweni uMbuso we-Eswatini begodu eyaziwa ngebizo layo langaphambilini elisemthethweni i-Swaziland (/ˈswɑːzilænd/ ☓-Swaziland) begodu yangaphambilini UmBuso we I-Swaziland, lilizwe elinganamanzi eSewula ye-Afrika. Inomngcele we-Mozambique ngepumalanga yetlhagwini ne[[Isewula Afrika|Sewula Afrika]] ngetlhagwini, ngeTjingalanga, ngesewula, neSewulapumalanga. I-Eswatini ingenye yeenarha ezincani khulu e-Afrika; nanyana kunjalo, ubujamo bezulu nendawo yayo ihlukile, ukusuka endaweni epholileko neneentaba ukuya eendaweni eziphasi ezitjhisako nezomileko.</text>
      <sha1>9bdlsgcfu1pylc0b9q9ayevlonqoyuk</sha1>
    </revision>
    <revision>
      <id>2573</id>
      <parentid>2324</parentid>
      <timestamp>2025-03-22T05:41:49Z</timestamp>
      <contributor>
        <username>Kvazimodo</username>
        <id>341</id>
      </contributor>
      <origin>2573</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="614" sha1="g9gykii28n4rgiptj6hpcy020yglz6f" xml:space="preserve">'''Eswatini''' ngokusemthethweni uMbuso we-Eswatini begodu eyaziwa ngebizo layo langaphambilini elisemthethweni i-Swaziland (/ˈswɑːzilænd/ ☓-Swaziland) begodu yangaphambilini UmBuso we I-Swaziland, lilizwe elinganamanzi eSewula ye-Afrika. Inomngcele we-Mozambique ngepumalanga yetlhagwini ne[[Isewula Afrika|Sewula Afrika]] ngetlhagwini, ngeTjingalanga, ngesewula, neSewulapumalanga. I-Eswatini ingenye yeenarha ezincani khulu e-Afrika; nanyana kunjalo, ubujamo bezulu nendawo yayo ihlukile, ukusuka endaweni epholileko neneentaba ukuya eendaweni eziphasi ezitjhisako nezomileko.

[[Mkhakha:Iinarha zephasi]]</text>
      <sha1>g9gykii28n4rgiptj6hpcy020yglz6f</sha1>
    </revision>
    <revision>
      <id>2913</id>
      <parentid>2573</parentid>
      <timestamp>2025-06-06T16:52:58Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>I am just spreading the truth</comment>
      <origin>2913</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="698" sha1="fn9zx7c8tgge9qps1qjf3hzgn0yc4j6" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. Switzerland''' ngokusemthethweni uMbuso we-Eswatini begodu eyaziwa ngebizo layo langaphambilini elisemthethweni i-Swaziland (/ˈswɑːzilænd/ ☓-Swaziland) begodu yangaphambilini UmBuso we I-Swaziland, lilizwe elinganamanzi eSewula ye-Afrika. Inomngcele we-Mozambique ngepumalanga yetlhagwini ne[[Isewula Afrika|Sewula Afrika]] ngetlhagwini, ngeTjingalanga, ngesewula, neSewulapumalanga. I-Eswatini ingenye yeenarha ezincani khulu e-Afrika; nanyana kunjalo, ubujamo bezulu nendawo yayo ihlukile, ukusuka endaweni epholileko neneentaba ukuya eendaweni eziphasi ezitjhisako nezomileko.

[[Mkhakha:Iinarha zephasi]]</text>
      <sha1>fn9zx7c8tgge9qps1qjf3hzgn0yc4j6</sha1>
    </revision>
    <revision>
      <id>3112</id>
      <parentid>2913</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Janabaevazizbek|Janabaevazizbek]]</comment>
      <origin>2573</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="614" sha1="g9gykii28n4rgiptj6hpcy020yglz6f" xml:space="preserve">'''Eswatini''' ngokusemthethweni uMbuso we-Eswatini begodu eyaziwa ngebizo layo langaphambilini elisemthethweni i-Swaziland (/ˈswɑːzilænd/ ☓-Swaziland) begodu yangaphambilini UmBuso we I-Swaziland, lilizwe elinganamanzi eSewula ye-Afrika. Inomngcele we-Mozambique ngepumalanga yetlhagwini ne[[Isewula Afrika|Sewula Afrika]] ngetlhagwini, ngeTjingalanga, ngesewula, neSewulapumalanga. I-Eswatini ingenye yeenarha ezincani khulu e-Afrika; nanyana kunjalo, ubujamo bezulu nendawo yayo ihlukile, ukusuka endaweni epholileko neneentaba ukuya eendaweni eziphasi ezitjhisako nezomileko.

[[Mkhakha:Iinarha zephasi]]</text>
      <sha1>g9gykii28n4rgiptj6hpcy020yglz6f</sha1>
    </revision>
  </page>
  <page>
    <title>Sobhuza II</title>
    <ns>0</ns>
    <id>431</id>
    <revision>
      <id>2325</id>
      <timestamp>2024-12-28T02:24:04Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created page with &quot;'''U-Sobhuza II'''  eyaziwa nangokuthi ngu-Nkhotfotjeni, Mona; ukubusa okude khulu okuqinisekisiweko kwananyana ngiyiphi inkosi emlandwini otloliweko.  USobhuza wabelethwa mhlana ali-22 kuNtaka 1899 e-Zombodze Royal Residence, indodana ka-Inkhosikati Lomawa Ndwandwe neKosi uNgwane V. Lokha nakaneenyanga ezine kwaphela, uyise wahlongakala kungakalindelwa nakagida i-incwala. USobhuza wakhethwa bona abe yikosi msinyana ngemva kwalokho begodu ugogo wakhe u-Labotsibeni nomalu...&quot;</comment>
      <origin>2325</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="845" sha1="rvcq0cw2g300mr284ta5rgegyoy8pgo" xml:space="preserve">'''U-Sobhuza II'''  eyaziwa nangokuthi ngu-Nkhotfotjeni, Mona; ukubusa okude khulu okuqinisekisiweko kwananyana ngiyiphi inkosi emlandwini otloliweko.

USobhuza wabelethwa mhlana ali-22 kuNtaka 1899 e-Zombodze Royal Residence, indodana ka-Inkhosikati Lomawa Ndwandwe neKosi uNgwane V. Lokha nakaneenyanga ezine kwaphela, uyise wahlongakala kungakalindelwa nakagida i-incwala. USobhuza wakhethwa bona abe yikosi msinyana ngemva kwalokho begodu ugogo wakhe u-Labotsibeni nomalume wakhe u-Prince Malunge bakhokhela isitjhaba samaSwazi bekwaba kulapho akhula khona ngo-1921.[3] U-Sobhuza wamukelwa njengeKosi yi-British ngo-1967, begodu i-Swaziland yazuza ikululeko ngo-1968. USobhuza waragela phambili nokubusa bekwaba sekufeni kwakhe ngo-1982. Walandelwa ngu-Mswati III, indodanakhe encani ne-Inkhosikati Ntfombi Tfwala, owabekwa umqhele ngo-1986.</text>
      <sha1>rvcq0cw2g300mr284ta5rgegyoy8pgo</sha1>
    </revision>
    <revision>
      <id>2326</id>
      <parentid>2325</parentid>
      <timestamp>2024-12-28T02:26:05Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2326</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1043" sha1="87b9jspmecrik54a75bcv9c2010vvmi" xml:space="preserve">'''U-Sobhuza II'''  eyaziwa nangokuthi ngu-Nkhotfotjeni, Mona; ukubusa okude khulu okuqinisekisiweko kwananyana ngiyiphi inkosi emlandwini otloliweko.&lt;ref&gt;https://journals.co.za/doi/pdf/10.10520/AJA19852007_117&lt;/ref&gt;&lt;ref&gt;https://journals.co.za/doi/abs/10.10520/AJA02562804_620&lt;/ref&gt;

USobhuza wabelethwa mhlana ali-22 kuNtaka 1899 e-Zombodze Royal Residence, indodana ka-Inkhosikati Lomawa Ndwandwe neKosi uNgwane V. Lokha nakaneenyanga ezine kwaphela, uyise wahlongakala kungakalindelwa nakagida i-incwala. USobhuza wakhethwa bona abe yikosi msinyana ngemva kwalokho begodu ugogo wakhe u-Labotsibeni nomalume wakhe u-Prince Malunge bakhokhela isitjhaba samaSwazi bekwaba kulapho akhula khona ngo-1921.U-Sobhuza wamukelwa njengeKosi yi-British ngo-1967, begodu i-Swaziland yazuza ikululeko ngo-1968. USobhuza waragela phambili nokubusa bekwaba sekufeni kwakhe ngo-1982. Walandelwa ngu-Mswati III, indodanakhe encani ne-Inkhosikati Ntfombi Tfwala, owabekwa umqhele ngo-1986.&lt;ref&gt;https://link.springer.com/chapter/10.1057/9780230271197_158&lt;/ref&gt;</text>
      <sha1>87b9jspmecrik54a75bcv9c2010vvmi</sha1>
    </revision>
    <revision>
      <id>2327</id>
      <parentid>2326</parentid>
      <timestamp>2024-12-28T02:26:26Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2327</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1059" sha1="hqokwk3j279calva5vmnetugsdddmor" xml:space="preserve">'''U-Sobhuza II'''  eyaziwa nangokuthi ngu-Nkhotfotjeni, Mona; ukubusa okude khulu okuqinisekisiweko kwananyana ngiyiphi inkosi emlandwini otloliweko.&lt;ref&gt;https://journals.co.za/doi/pdf/10.10520/AJA19852007_117&lt;/ref&gt;&lt;ref&gt;https://journals.co.za/doi/abs/10.10520/AJA02562804_620&lt;/ref&gt;

USobhuza wabelethwa mhlana ali-22 kuNtaka 1899 e-Zombodze Royal Residence, indodana ka-Inkhosikati Lomawa Ndwandwe neKosi uNgwane V. Lokha nakaneenyanga ezine kwaphela, uyise wahlongakala kungakalindelwa nakagida i-incwala. USobhuza wakhethwa bona abe yikosi msinyana ngemva kwalokho begodu ugogo wakhe u-Labotsibeni nomalume wakhe u-Prince Malunge bakhokhela isitjhaba samaSwazi bekwaba kulapho akhula khona ngo-1921.U-Sobhuza wamukelwa njengeKosi yi-British ngo-1967, begodu i-Swaziland yazuza ikululeko ngo-1968. USobhuza waragela phambili nokubusa bekwaba sekufeni kwakhe ngo-1982. Walandelwa ngu-Mswati III, indodanakhe encani ne-Inkhosikati Ntfombi Tfwala, owabekwa umqhele ngo-1986.&lt;ref&gt;https://link.springer.com/chapter/10.1057/9780230271197_158&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>hqokwk3j279calva5vmnetugsdddmor</sha1>
    </revision>
    <revision>
      <id>2328</id>
      <parentid>2327</parentid>
      <timestamp>2024-12-28T02:26:55Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2328</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1063" sha1="dx9pel5b3omq2q6ame1e1r9al18beex" xml:space="preserve">'''U-Sobhuza II'''  eyaziwa nangokuthi ngu-Nkhotfotjeni, Mona; ukubusa okude khulu okuqinisekisiweko kwananyana ngiyiphi inkosi emlandwini otloliweko.&lt;ref&gt;https://journals.co.za/doi/pdf/10.10520/AJA19852007_117&lt;/ref&gt;&lt;ref&gt;https://journals.co.za/doi/abs/10.10520/AJA02562804_620&lt;/ref&gt;

USobhuza wabelethwa mhlana ali-22 kuNtaka 1899 e-[[Zombodze Royal Residence]], indodana ka-Inkhosikati Lomawa Ndwandwe neKosi uNgwane V. Lokha nakaneenyanga ezine kwaphela, uyise wahlongakala kungakalindelwa nakagida i-incwala. USobhuza wakhethwa bona abe yikosi msinyana ngemva kwalokho begodu ugogo wakhe u-Labotsibeni nomalume wakhe u-Prince Malunge bakhokhela isitjhaba samaSwazi bekwaba kulapho akhula khona ngo-1921.U-Sobhuza wamukelwa njengeKosi yi-British ngo-1967, begodu i-Swaziland yazuza ikululeko ngo-1968. USobhuza waragela phambili nokubusa bekwaba sekufeni kwakhe ngo-1982. Walandelwa ngu-Mswati III, indodanakhe encani ne-Inkhosikati Ntfombi Tfwala, owabekwa umqhele ngo-1986.&lt;ref&gt;https://link.springer.com/chapter/10.1057/9780230271197_158&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>dx9pel5b3omq2q6ame1e1r9al18beex</sha1>
    </revision>
    <revision>
      <id>2329</id>
      <parentid>2328</parentid>
      <timestamp>2024-12-28T02:27:42Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2329</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1126" sha1="6cy72tr7ag68ppvs9rbxj0yc441ld9s" xml:space="preserve">'''U-Sobhuza II'''  eyaziwa nangokuthi ngu-Nkhotfotjeni, Mona; ukubusa okude khulu okuqinisekisiweko kwananyana ngiyiphi inkosi emlandwini otloliweko.&lt;ref&gt;https://journals.co.za/doi/pdf/10.10520/AJA19852007_117&lt;/ref&gt;&lt;ref&gt;https://journals.co.za/doi/abs/10.10520/AJA02562804_620&lt;/ref&gt;

USobhuza wabelethwa mhlana ali-22 kuNtaka 1899 e-[[Zombodze Royal Residence]], indodana ka-Inkhosikati Lomawa Ndwandwe neKosi uNgwane V. Lokha nakaneenyanga ezine kwaphela, uyise wahlongakala kungakalindelwa nakagida i-incwala. USobhuza wakhethwa bona abe yikosi msinyana ngemva kwalokho begodu ugogo wakhe u-Labotsibeni nomalume wakhe u-Prince Malunge bakhokhela isitjhaba samaSwazi bekwaba kulapho akhula khona ngo-1921.U-Sobhuza wamukelwa njengeKosi yi-British ngo-1967, begodu i-Swaziland yazuza ikululeko ngo-1968. USobhuza waragela phambili nokubusa bekwaba sekufeni kwakhe ngo-1982. Walandelwa ngu-Mswati III, indodanakhe encani ne-Inkhosikati Ntfombi Tfwala, owabekwa umqhele ngo-1986.&lt;ref&gt;https://link.springer.com/chapter/10.1057/9780230271197_158&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}
[[Category:Amakhosi eAfrika]]
[[Category:Umlando]]</text>
      <sha1>6cy72tr7ag68ppvs9rbxj0yc441ld9s</sha1>
    </revision>
  </page>
  <page>
    <title>Nana Sita</title>
    <ns>0</ns>
    <id>432</id>
    <revision>
      <id>2330</id>
      <timestamp>2024-12-28T15:59:44Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1265771030|Nana Sita]]&quot;</comment>
      <origin>2330</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="926" sha1="nnfn77cp0sqmw9eqbzjsypk111r8lmq" xml:space="preserve">'''Nana Sita''' (eyaziwa nangokuthi ngu-Nanabhai) wabelethwa ngo-1898 e-Matwadi, idorobha le-Gujarat, e-India, begodu wakhulela emndenini obandakanyeka emkhankasweni wokujamelana nama-India. Waya eSewula Afrika ngo-1913 ukuyokufunda ukugcina amabhuku, begodu wahlala isikhathi esithileko no-J. P. Vyas e-Pitoli. Msinyana ngemva kokufika kwakhe, u-Mahatma Gandhi wafika e-Pitoria ukuyokukhulumisana no-General Jan Smuts, begodu wahlala endlini yinye no-Sita iinyanga ezimbili. Ukukhulumisana no-Gandhi kwaba nomthelela omkhulu epilweni yakhe begodu bekangumsekeli omkhulu wokujamelana nokungasebenzi. Wahlala ejele kanengi ngokwala ukutjhiya ikhaya lakhe, ngemva kobana indawo lapho gade ahlala khona nomndenakhe iminyaka ema-44 yamenyezelwa njengezakhamuzi zabantu abamhlophe.&lt;ref&gt;https://showme.co.za/pretoria/files/2012/08/PretoriaStreetNameChanges.pdf&lt;/ref&gt;&lt;ref&gt;https://www.ajol.info/index.php/hts/article/view/212208&lt;/ref&gt;</text>
      <sha1>nnfn77cp0sqmw9eqbzjsypk111r8lmq</sha1>
    </revision>
    <revision>
      <id>2331</id>
      <parentid>2330</parentid>
      <timestamp>2024-12-28T16:00:06Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1265771030|Nana Sita]]&quot;</comment>
      <origin>2331</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="942" sha1="7214j694x5swcyz52jjmhuebaafoehq" xml:space="preserve">'''Nana Sita''' (eyaziwa nangokuthi ngu-Nanabhai) wabelethwa ngo-1898 e-Matwadi, idorobha le-Gujarat, e-India, begodu wakhulela emndenini obandakanyeka emkhankasweni wokujamelana nama-India. Waya eSewula Afrika ngo-1913 ukuyokufunda ukugcina amabhuku, begodu wahlala isikhathi esithileko no-J. P. Vyas e-Pitoli. Msinyana ngemva kokufika kwakhe, u-Mahatma Gandhi wafika e-Pitoria ukuyokukhulumisana no-General Jan Smuts, begodu wahlala endlini yinye no-Sita iinyanga ezimbili. Ukukhulumisana no-Gandhi kwaba nomthelela omkhulu epilweni yakhe begodu bekangumsekeli omkhulu wokujamelana nokungasebenzi. Wahlala ejele kanengi ngokwala ukutjhiya ikhaya lakhe, ngemva kobana indawo lapho gade ahlala khona nomndenakhe iminyaka ema-44 yamenyezelwa njengezakhamuzi zabantu abamhlophe.&lt;ref&gt;https://showme.co.za/pretoria/files/2012/08/PretoriaStreetNameChanges.pdf&lt;/ref&gt;&lt;ref&gt;https://www.ajol.info/index.php/hts/article/view/212208&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>7214j694x5swcyz52jjmhuebaafoehq</sha1>
    </revision>
    <revision>
      <id>2332</id>
      <parentid>2331</parentid>
      <timestamp>2024-12-28T16:00:43Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2332</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="961" sha1="fl4ftjt2lo58f8t4556vztz30e54mco" xml:space="preserve">'''Nana Sita''' (eyaziwa nangokuthi ngu-Nanabhai) wabelethwa ngo-1898 e-Matwadi, idorobha le-Gujarat, e-India, begodu wakhulela emndenini obandakanyeka emkhankasweni wokujamelana nama-India. Waya e[[Isewula Afrika|Sewula Afrika]] ngo-1913 ukuyokufunda ukugcina amabhuku, begodu wahlala isikhathi esithileko no-J. P. Vyas e-Pitoli. Msinyana ngemva kokufika kwakhe, u-Mahatma Gandhi wafika e-Pitoria ukuyokukhulumisana no-General Jan Smuts, begodu wahlala endlini yinye no-Sita iinyanga ezimbili. Ukukhulumisana no-Gandhi kwaba nomthelela omkhulu epilweni yakhe begodu bekangumsekeli omkhulu wokujamelana nokungasebenzi. Wahlala ejele kanengi ngokwala ukutjhiya ikhaya lakhe, ngemva kobana indawo lapho gade ahlala khona nomndenakhe iminyaka ema-44 yamenyezelwa njengezakhamuzi zabantu abamhlophe.&lt;ref&gt;https://showme.co.za/pretoria/files/2012/08/PretoriaStreetNameChanges.pdf&lt;/ref&gt;&lt;ref&gt;https://www.ajol.info/index.php/hts/article/view/212208&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>fl4ftjt2lo58f8t4556vztz30e54mco</sha1>
    </revision>
    <revision>
      <id>2333</id>
      <parentid>2332</parentid>
      <timestamp>2024-12-28T16:01:19Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>2333</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="976" sha1="0fmdndn3nponjt8alzvkzd2c7gtmo9s" xml:space="preserve">'''Nana Sita''' (eyaziwa nangokuthi ngu-Nanabhai) wabelethwa ngo-1898 e-Matwadi, idorobha le-Gujarat, e-India, begodu wakhulela emndenini obandakanyeka emkhankasweni wokujamelana nama-India. Waya e[[Isewula Afrika|Sewula Afrika]] ngo-1913 ukuyokufunda ukugcina amabhuku, begodu wahlala isikhathi esithileko no-J. P. Vyas e-Pitoli. Msinyana ngemva kokufika kwakhe, u-[[Mahatma Gandhi]] wafika e-[[Pitori|Pitoria]] ukuyokukhulumisana no-General Jan Smuts, begodu wahlala endlini yinye no-Sita iinyanga ezimbili. Ukukhulumisana no-Gandhi kwaba nomthelela omkhulu epilweni yakhe begodu bekangumsekeli omkhulu wokujamelana nokungasebenzi. Wahlala ejele kanengi ngokwala ukutjhiya ikhaya lakhe, ngemva kobana indawo lapho gade ahlala khona nomndenakhe iminyaka ema-44 yamenyezelwa njengezakhamuzi zabantu abamhlophe.&lt;ref&gt;https://showme.co.za/pretoria/files/2012/08/PretoriaStreetNameChanges.pdf&lt;/ref&gt;&lt;ref&gt;https://www.ajol.info/index.php/hts/article/view/212208&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>0fmdndn3nponjt8alzvkzd2c7gtmo9s</sha1>
    </revision>
    <revision>
      <id>3450</id>
      <parentid>2333</parentid>
      <timestamp>2025-07-18T07:03:56Z</timestamp>
      <contributor>
        <username>India ke Presidents ke suchi</username>
        <id>765</id>
      </contributor>
      <comment>/* Iinkomba */</comment>
      <origin>3450</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1007" sha1="37r5ricgtjw2a3ktg8v0s90aj4vjss3" xml:space="preserve">'''Nana Sita''' (eyaziwa nangokuthi ngu-Nanabhai) wabelethwa ngo-1898 e-Matwadi, idorobha le-Gujarat, e-India, begodu wakhulela emndenini obandakanyeka emkhankasweni wokujamelana nama-India. Waya e[[Isewula Afrika|Sewula Afrika]] ngo-1913 ukuyokufunda ukugcina amabhuku, begodu wahlala isikhathi esithileko no-J. P. Vyas e-Pitoli. Msinyana ngemva kokufika kwakhe, u-[[Mahatma Gandhi]] wafika e-[[Pitori|Pitoria]] ukuyokukhulumisana no-General Jan Smuts, begodu wahlala endlini yinye no-Sita iinyanga ezimbili. Ukukhulumisana no-Gandhi kwaba nomthelela omkhulu epilweni yakhe begodu bekangumsekeli omkhulu wokujamelana nokungasebenzi. Wahlala ejele kanengi ngokwala ukutjhiya ikhaya lakhe, ngemva kobana indawo lapho gade ahlala khona nomndenakhe iminyaka ema-44 yamenyezelwa njengezakhamuzi zabantu abamhlophe.&lt;ref&gt;https://showme.co.za/pretoria/files/2012/08/PretoriaStreetNameChanges.pdf&lt;/ref&gt;&lt;ref&gt;https://www.ajol.info/index.php/hts/article/view/212208&lt;/ref&gt;

== Iinkomba ==
*[[uMongameli weSewula India]]</text>
      <sha1>37r5ricgtjw2a3ktg8v0s90aj4vjss3</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Delete</title>
    <ns>10</ns>
    <id>437</id>
    <revision>
      <id>2340</id>
      <timestamp>2025-01-02T18:15:10Z</timestamp>
      <contributor>
        <username>WikiBayer</username>
        <id>225</id>
      </contributor>
      <comment>Created page with &quot;[[Image:Icono aviso borrar.png|80px|left]] &lt;div name=&quot;Deletion notice&quot; class=&quot;boilerplate metadata&quot; id=&quot;delete&quot; style=&quot;margin: 0 5%; padding: 0 7px 7px 7px; background: #fee; border: 1px solid #999999; text-align: left; font-size:95%;&quot;&gt; &lt;big&gt;THIS PAGE SHOULD BE '''DELETED'''! The given reason is: &quot;''{{{1}}}''&quot;  If you disagree with its speedy deletion, please explain why on [[{{NAMESPACE}} talk:{{PAGENAME}}|its talk page]].  If this page obviously does not meet the crite...&quot;</comment>
      <origin>2340</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1074" sha1="h4bv8xza5ofmhman0d1tn64cg3tgxgf" xml:space="preserve">[[Image:Icono aviso borrar.png|80px|left]]
&lt;div name=&quot;Deletion notice&quot; class=&quot;boilerplate metadata&quot; id=&quot;delete&quot; style=&quot;margin: 0 5%; padding: 0 7px 7px 7px; background: #fee; border: 1px solid #999999; text-align: left; font-size:95%;&quot;&gt;
&lt;big&gt;THIS PAGE SHOULD BE '''DELETED'''! The given reason is: &quot;''{{{1}}}''&quot;

If you disagree with its speedy deletion, please explain why on [[{{NAMESPACE}} talk:{{PAGENAME}}|its talk page]].  If this page obviously does not meet the criteria for speedy deletion, or you intend to fix it, please remove this notice, but do not remove this notice from a page that you have created yourself.

&lt;span class=&quot;plainlinks&quot;&gt;''Administrators, remember to check  [[Special:Whatlinkshere/{{NAMESPACE}}:{{PAGENAME}}|if anything links here]] and [{{fullurl:{{NAMESPACE}}:{{PAGENAME}}|action=history}} the page history] ([{{fullurl:{{NAMESPACE}}:{{PAGENAME}}|diff=0}} last edit]) before [{{fullurl:{{NAMESPACE}}:{{PAGENAME}}|action=delete}} deletion].''&lt;/span&gt;
&lt;/div&gt;&lt;includeonly&gt;{{{category|[[Category:Candidates for speedy deletion]]}}}&lt;/includeonly&gt;</text>
      <sha1>h4bv8xza5ofmhman0d1tn64cg3tgxgf</sha1>
    </revision>
    <revision>
      <id>3478</id>
      <parentid>2340</parentid>
      <timestamp>2025-07-29T14:59:17Z</timestamp>
      <contributor>
        <username>Minorax</username>
        <id>38</id>
      </contributor>
      <origin>3478</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1080" sha1="qa0s3je53rjm771yqip95vgfwfiyd7l" xml:space="preserve">[[Image:Icono aviso borrar.png|80px|left]]
&lt;div name=&quot;Deletion notice&quot; class=&quot;boilerplate metadata&quot; id=&quot;delete&quot; style=&quot;margin: 0 5%; padding: 0 7px 7px 7px; background: #fee; border: 1px solid #999999; text-align: left; font-size:95%;&quot;&gt;
&lt;big&gt;THIS PAGE SHOULD BE '''DELETED'''! The given reason is: &quot;''{{{1}}}''&quot;&lt;/big&gt;

If you disagree with its speedy deletion, please explain why on [[{{NAMESPACE}} talk:{{PAGENAME}}|its talk page]].  If this page obviously does not meet the criteria for speedy deletion, or you intend to fix it, please remove this notice, but do not remove this notice from a page that you have created yourself.

&lt;span class=&quot;plainlinks&quot;&gt;''Administrators, remember to check  [[Special:Whatlinkshere/{{NAMESPACE}}:{{PAGENAME}}|if anything links here]] and [{{fullurl:{{NAMESPACE}}:{{PAGENAME}}|action=history}} the page history] ([{{fullurl:{{NAMESPACE}}:{{PAGENAME}}|diff=0}} last edit]) before [{{fullurl:{{NAMESPACE}}:{{PAGENAME}}|action=delete}} deletion].''&lt;/span&gt;
&lt;/div&gt;&lt;includeonly&gt;{{{category|[[Category:Candidates for speedy deletion]]}}}&lt;/includeonly&gt;</text>
      <sha1>qa0s3je53rjm771yqip95vgfwfiyd7l</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Candidates for speedy deletion</title>
    <ns>14</ns>
    <id>438</id>
    <revision>
      <id>2341</id>
      <timestamp>2025-01-02T18:16:24Z</timestamp>
      <contributor>
        <username>WikiBayer</username>
        <id>225</id>
      </contributor>
      <comment>Created page with &quot;__EXPECTUNUSEDCATEGORY__ Pages for speedy deletion go here.&quot;</comment>
      <origin>2341</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="59" sha1="hpmgwxugdvg0jn27b90yrt73zfo7wzb" xml:space="preserve">__EXPECTUNUSEDCATEGORY__
Pages for speedy deletion go here.</text>
      <sha1>hpmgwxugdvg0jn27b90yrt73zfo7wzb</sha1>
    </revision>
  </page>
  <page>
    <title>Ijemu</title>
    <ns>0</ns>
    <id>439</id>
    <revision>
      <id>2342</id>
      <timestamp>2025-01-06T10:17:04Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''Ijemu''' yinto yokuzesa uburotho ukwenzela bonyana bube mnandi begodu ukhone ubudla. iJemu yenziwa khulu ngama aprikosi.&quot;</comment>
      <origin>2342</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="123" sha1="gj9e1ooms4pgax2aokeor8kky66mhco" xml:space="preserve">'''Ijemu''' yinto yokuzesa uburotho ukwenzela bonyana bube mnandi begodu ukhone ubudla. iJemu yenziwa khulu ngama aprikosi.</text>
      <sha1>gj9e1ooms4pgax2aokeor8kky66mhco</sha1>
    </revision>
    <revision>
      <id>2343</id>
      <parentid>2342</parentid>
      <timestamp>2025-01-06T10:17:48Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2343</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="123" sha1="qgrswdhr6ooa1afu49xbtsqbz9ppq4n" xml:space="preserve">'''Ijemu''' yinto yokuzesa uburotho ukwenzela bonyana bube mnandi begodu ukhone ubudla. IJemu yenziwa khulu ngama aprikosi.</text>
      <sha1>qgrswdhr6ooa1afu49xbtsqbz9ppq4n</sha1>
    </revision>
    <revision>
      <id>2404</id>
      <parentid>2343</parentid>
      <timestamp>2025-02-12T09:25:53Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2404</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="304" sha1="s7k09d2tse8dpslsj1lpx9fkgsj0f4w" xml:space="preserve">'''Ijemu''' yinto yokuzesa uburotho ukwenzela bonyana bube mnandi begodu ukhone ubudla. IJemu yenziwa khulu ngama aprikosi. ijemu yaziwa njengokudla kwamaNdebele ngombana lokha amaNdebele anakenze iqude lokukhulisa itlawana, abomma  nabantazana baphakiswa ijemu njengesipho sokuthi bazile emnyannyeni lo.</text>
      <sha1>s7k09d2tse8dpslsj1lpx9fkgsj0f4w</sha1>
    </revision>
    <revision>
      <id>2411</id>
      <parentid>2404</parentid>
      <timestamp>2025-02-15T18:53:35Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2411</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="306" sha1="o9b2f6g5oyqgapp955t9c42yrsav63s" xml:space="preserve">'''Ijemu''' yinto yokuzesa uburotho ukwenzela bonyana bube mnandi begodu ukhone ukubudla. IJemu yenziwa khulu ngama aprikosi. ijemu yaziwa njengokudla kwamaNdebele ngombana lokha amaNdebele anakenze iqude lokukhulisa itlawana, abomma  nabantazana baphakiswa ijemu njengesipho sokuthi bazile emnyannyeni lo.</text>
      <sha1>o9b2f6g5oyqgapp955t9c42yrsav63s</sha1>
    </revision>
    <revision>
      <id>2452</id>
      <parentid>2411</parentid>
      <timestamp>2025-02-21T15:42:31Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2452</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="344" sha1="k8w7hpy2v9rn43pvvy2df1kiqpws1zu" xml:space="preserve">'''Ijemu''' yinto yokuzesa uburotho ukwenzela bonyana bube mnandi begodu ukhone ukubudla. IJemu yenziwa khulu ngama aprikosi. ijemu yaziwa njengokudla kwamaNdebele ngombana lokha amaNdebele nakenze iqude ekumnyanya wokukhulisa itlawana, abomma  nabantazana baphakiswa ijemu njengesipho sokuthi bazile emnyannyeni lo. Ijemu isudu ngokunambitheka</text>
      <sha1>k8w7hpy2v9rn43pvvy2df1kiqpws1zu</sha1>
    </revision>
  </page>
  <page>
    <title>Myles Munroe</title>
    <ns>0</ns>
    <id>440</id>
    <revision>
      <id>2345</id>
      <timestamp>2025-01-12T20:21:38Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1260717325|Myles Munroe]]&quot;</comment>
      <origin>2345</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="571" sha1="6cb0l5ap3v5ju2pjr9p1ptg3a9j1z0t" xml:space="preserve"> 

U-Myles Munroe, OBE (20 kuMrhayili 1954 – 9 kuNobayeni 2014) bekangumvangeli we-Bahamian begodu umfundisi, uprofesa, umtloli, isikhulumi nomcebisi woburholi. Wasungula begodu warhola i-Bahamas Faith Ministries International (BFMI), kanye ne-Myles Munroe International (MMI). Bekabuye abe mphathi omkhulu nomgcinisihlalo webhodi ye-International Third World Leaders Association, kanye nomongameli we-International Leadership Training Institute. U-Dr Munroe naye bekangumtloli omkhulu.&lt;ref&gt;https://cbn.com/news/world/keeping-legacy-alive-life-after-myles-munroe&lt;/ref&gt;</text>
      <sha1>6cb0l5ap3v5ju2pjr9p1ptg3a9j1z0t</sha1>
    </revision>
    <revision>
      <id>2346</id>
      <parentid>2345</parentid>
      <timestamp>2025-01-12T20:22:31Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1260717325|Myles Munroe]]&quot;</comment>
      <origin>2346</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="601" sha1="i9eq9ttk1ygrg65zd3pq18cz11sxbzx" xml:space="preserve"> 

'''U-Myles Munroe''', (20 kuMrhayili 1954 – 9 kuNobayeni 2014) bekangumvangeli we-[[Bahamian]] begodu umfundisi, uprofesa, umtloli, isikhulumi nomcebisi woburholi. Wasungula begodu warhola i-Bahamas Faith Ministries International (BFMI), kanye ne-Myles Munroe International (MMI). Bekabuye abe mphathi omkhulu nomgcinisihlalo webhodi ye-International Third World Leaders Association, kanye nomongameli we-International Leadership Training Institute. U-Dr Munroe naye bekangumtloli omkhulu.&lt;ref&gt;https://cbn.com/news/world/keeping-legacy-alive-life-after-myles-munroe&lt;/ref&gt;
[[Mkhakha:Abosaziwako]]</text>
      <sha1>i9eq9ttk1ygrg65zd3pq18cz11sxbzx</sha1>
    </revision>
    <revision>
      <id>2575</id>
      <parentid>2346</parentid>
      <timestamp>2025-03-22T05:46:43Z</timestamp>
      <contributor>
        <username>Kvazimodo</username>
        <id>341</id>
      </contributor>
      <origin>2575</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="630" sha1="31rfjizq36aebuc4sm38kniqaqydyw6" xml:space="preserve">'''U-Myles Munroe''', (20 kuMrhayili 1954 – 9 kuNobayeni 2014) bekangumvangeli we-[[Bahamian]] begodu umfundisi, uprofesa, umtloli, isikhulumi nomcebisi woburholi. Wasungula begodu warhola i-Bahamas Faith Ministries International (BFMI), kanye ne-Myles Munroe International (MMI). Bekabuye abe mphathi omkhulu nomgcinisihlalo webhodi ye-International Third World Leaders Association, kanye nomongameli we-International Leadership Training Institute. U-Dr Munroe naye bekangumtloli omkhulu.&lt;ref&gt;https://cbn.com/news/world/keeping-legacy-alive-life-after-myles-munroe&lt;/ref&gt;

== Isithasiselo ==
{{Reflist}}

[[Mkhakha:Abosaziwako]]</text>
      <sha1>31rfjizq36aebuc4sm38kniqaqydyw6</sha1>
    </revision>
  </page>
  <page>
    <title>Amafu</title>
    <ns>0</ns>
    <id>442</id>
    <revision>
      <id>2354</id>
      <timestamp>2025-01-23T07:22:46Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <comment>Created page with &quot;== '''Amafu''' ==  == Isingeniso == Amafu ngezinye zezinto ezimkarisomraro begodu nezibamba indima ekulu ephasini mayelana neenlwana nabantu. Umkarisomraro omkhulu mayelana namafu kukwenzeka kwawo kanye nendawo la atholakala khona. Amafu atholakala esibhakabhakeni begodu ahleli emoyeni ngaphandle kokubona bonyana abanjwe yini. Eenhlokwaneni ezilandelako sizokutjheja bonyana yini amafu, imihlobo edume khulu yamafu kanye nemisebenzi yamafu.  === Kuyini amafu? === Ngokuya k...&quot;</comment>
      <origin>2354</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4444" sha1="f14wvoeovw1foexbtvnzpewbop4uvrl" xml:space="preserve">== '''Amafu''' ==

== Isingeniso ==
Amafu ngezinye zezinto ezimkarisomraro begodu nezibamba indima ekulu ephasini mayelana neenlwana nabantu. Umkarisomraro omkhulu mayelana namafu kukwenzeka kwawo kanye nendawo la atholakala khona. Amafu atholakala esibhakabhakeni begodu ahleli emoyeni ngaphandle kokubona bonyana abanjwe yini. Eenhlokwaneni ezilandelako sizokutjheja bonyana yini amafu, imihlobo edume khulu yamafu kanye nemisebenzi yamafu.

=== Kuyini amafu? ===
Ngokuya kwe-Wikipedia (2024)&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. ''Cloud''. Litholaka ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Cloud&lt;/nowiki&gt;&gt;. Ifunyenwe [Ngomhlaka 18 kuNobayeni 2024].&lt;/ref&gt; amafu kumvango werhwaba nobutlelezana bamathosi, nezinye izinto lezo ezilenge emoyeni nanyana esibhakabhakeni. I-Wikipedia (2024)&lt;ref name=&quot;:0&quot; /&gt; ingezelele yathi amafu la abonaka ephasini nanyana atholakala ephasini abakhona ngebanga lomoya okhuphukela phezulu otjhisakho, ofika le phezulu ube makhaza bese uba yirhwaba. Ukuragela phambili, irhwaba le ithi ingaba nobutlelezi obaneleko bese kubamamafu (Wikipedia 2024)&lt;ref name=&quot;:0&quot; /&gt;.

=== Imihlobo yamafu. ===
[[Isimumathi:Ikhalamasi.jpg|thumb|200x200px|Amafu ikhalamasi]]
Ngokuya kwe-Lets talk Science (2024) &lt;ref&gt;Lets talk Science. 2024.Weather: ''Clouds''. Litholakala ku:&lt; &lt;nowiki&gt;https://letstalkscience.ca/educational-resources/backgrounders/weather-clouds&lt;/nowiki&gt;&gt;. Ifunyenwe [Ngomhlaka 18 kuNobayeni 2024].&lt;/ref&gt;kunemihlobo eminengi yamafu kodwana isirasi, ikhamulasi, istrathasi nenimbasi mihlobo edume nayizwa khulu. I-Twinckl(2024)&lt;ref name=&quot;:1&quot;&gt;Twinckl. 2024. ''Cloud''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.twinkl.co.za/teaching-wiki/cloud&lt;/nowiki&gt;&gt;. Ifunyenwe [Ngomhlaka 18 kuNobayeni 2024].&lt;/ref&gt; iveze bonyana amafu isirasi kumamafu lawo aqaleka nanyana afana njengewula begodu adweni. Umhlobo lo wamafu wenziya yirhwaba encani nanyana elula ekhanyelako leyo ewanikela  ubudweni.
Ikhamulasi mamafu labo avela amakhulu begodu abuboyana nawuwaqalileko (Britannica 2024&lt;ref name=&quot;:2&quot;&gt;Britannica. 2024. ''Cloud: Meteorology''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.britannica.com/science/cloud-meteorology&lt;/nowiki&gt;&gt;. Ifunyenwe [Ngomhlaka 18 kuNobayeni 2024].&lt;/ref&gt;; Twinckl 2024&lt;ref name=&quot;:1&quot; /&gt;). Esikhathi esinengi amafu la, agcwala isibhakabhaka kanti avame ukuba nombala omlotha nanyana omhlophe (Britannica 2024; Tinckl 2024&lt;ref name=&quot;:1&quot; /&gt;). Ngesikhathi amahlophe, vane atjengisa bonyana angekhe aletha izulu; Kodwana lokha nakatjhugululela kumbala ongeleleko omlotha ukuya ebunzimeni vane atjengisa bonyana aze nezulu (Britannica 2024; Twinckl2024&lt;ref name=&quot;:1&quot; /&gt;).
 [[Isimumathi:Amafu istrathasi.jpg|left|thumb|200x200px|Amafu istrathasi]]
Istrathasi mamafu adeke khulu lawo othi nawuqala phezulu ongakghoni ukubona nesibhakabhaka kodwana kubonakala wona (Britannica 2024; Twinckl 2024). Esikhathini esinengi mamafu aphasi nanyana aseduze naphasi nanyana abantu (Britannica 2024&lt;ref name=&quot;:2&quot; /&gt;; Twinckl 2024&lt;ref name=&quot;:1&quot; /&gt;). I-Twinckl (2024&lt;ref name=&quot;:1&quot; /&gt;) ingezelele yathi ibanga lokhu amafu la abeseduze nabantu nanyana abephasi kukuthi ayenziwa yikungu. Amafu la enzeka ngesikhathi kumakhaza bese kube nomoya otjhisako nomakhaza ovuthelwako (Britannica 2024&lt;ref name=&quot;:2&quot; /&gt;; Twinckl2024&lt;ref name=&quot;:1&quot; /&gt;). Ukuvuthelwa kwemimoya le, ngikho okuqunta bonyana abe dege kangangani (Britannica 2024&lt;ref name=&quot;:2&quot; /&gt;; Twinckl2024).
 [[Isimumathi:Inimbasi.jpg|thumb|200x200px|Amafu inimbasi]]
Inimbasi mamafu lawo eza nezulu nanyana igabhogo (Britannica 2024&lt;ref name=&quot;:2&quot; /&gt;; Twinckl 2024&lt;ref name=&quot;:1&quot; /&gt;). Esikhathini esinengi umhlobo lo wamafu ubonakala khulu ngesikhathi sokuraramba nokuduma kwezulu (Britannica 2024; Twinckl2024). Ngamanye amagama la mamafu akhambisana nezulu elirarambako nanyana elineembani emikhulu. 

=== Imisebenzi yamafu ===
Amafu anemisebenzi eminengi leyo efaka hlangana ukupholisa nanyana ukwehlisa umtjhiso ephasini lokha nakutjhisa khulu (Wikipedia 2024). Omunye umsebenzi omkhulu kukukwenza bona izulu line ukuze iintjalo nabantu bathole amanzi (Lets talk Science 2024). Izulu angekhe lakghona ukuna ngaphandle kwamafu. 
 
=== Isiphetho ===
Amafu umkarisomraro lowo oqakathekileko kithi soke. Begodu kufanele sazi imisebenzi yawo nokuthi enziwa njani. Ukungenzelela imihlobo yamafu nayo kufanele siyizwisise ukuze sizokwazi ukuziphatha ngendlela enqophileko mayelana nayo ngombana eminye imihlobo iza neembani eraramba kabuhlungu khulu. 

=== Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>f14wvoeovw1foexbtvnzpewbop4uvrl</sha1>
    </revision>
    <revision>
      <id>2356</id>
      <parentid>2354</parentid>
      <timestamp>2025-01-23T07:46:52Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <minor />
      <origin>2356</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4640" sha1="j527xhas3dsjewi3tj216dfefr0u8oh" xml:space="preserve">== '''Amafu''' ==

== Isingeniso ==
Amafu ngezinye zezinto ezimkarisomraro begodu nezibamba indima ekulu ephasini mayelana neenlwana nabantu. Umkarisomraro omkhulu mayelana namafu kukwenzeka kwawo kanye nendawo la atholakala khona. Amafu atholakala esibhakabhakeni begodu ahleli emoyeni ngaphandle kokubona bonyana abanjwe yini. Eenhlokwaneni ezilandelako sizokutjheja bonyana yini amafu, imihlobo edume khulu yamafu kanye nemisebenzi yamafu.

=== Kuyini amafu? ===
Ngokuya kwe-[[:en:Cloud|Wikipedia (2024)]]&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. ''Cloud''. Litholaka ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Cloud&lt;/nowiki&gt;&gt;. Ifunyenwe [Ngomhlaka 18 kuNobayeni 2024].&lt;/ref&gt; amafu kumvango werhwaba nobutlelezana bamathosi, nezinye izinto lezo ezilenge emoyeni nanyana esibhakabhakeni. I-Wikipedia (2024)&lt;ref name=&quot;:0&quot; /&gt; ingezelele yathi amafu la abonaka ephasini nanyana atholakala ephasini abakhona ngebanga lomoya okhuphukela phezulu otjhisakho, ofika le phezulu ube makhaza bese uba yirhwaba. Ukuragela phambili, irhwaba le ithi ingaba nobutlelezi obaneleko bese kubamamafu (Wikipedia 2024)&lt;ref name=&quot;:0&quot; /&gt;.

=== Imihlobo yamafu. ===
[[Isimumathi:Ikhalamasi.jpg|thumb|200x200px|Amafu ikhalamasi]]
Ngokuya kwe-Lets talk Science (2024) &lt;ref&gt;Lets talk Science. 2024.Weather: ''Clouds''. Litholakala ku:&lt; &lt;nowiki&gt;https://letstalkscience.ca/educational-resources/backgrounders/weather-clouds&lt;/nowiki&gt;&gt;. Ifunyenwe [Ngomhlaka 18 kuNobayeni 2024].&lt;/ref&gt;kunemihlobo eminengi yamafu kodwana isirasi, ikhamulasi, istrathasi nenimbasi mihlobo edume nayizwa khulu. I-[https://www.twinkl.co.za/teaching-wiki/cloud Twinckl(2024)]&lt;ref name=&quot;:1&quot;&gt;Twinckl. 2024. ''Cloud''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.twinkl.co.za/teaching-wiki/cloud&lt;/nowiki&gt;&gt;. Ifunyenwe [Ngomhlaka 18 kuNobayeni 2024].&lt;/ref&gt; iveze bonyana amafu isirasi kumamafu lawo aqaleka nanyana afana njengewula begodu adweni. Umhlobo lo wamafu wenziya yirhwaba encani nanyana elula ekhanyelako leyo ewanikela  ubudweni.
Ikhamulasi mamafu labo avela amakhulu begodu abuboyana nawuwaqalileko (Britannica 2024&lt;ref name=&quot;:2&quot;&gt;Britannica. 2024. ''Cloud: Meteorology''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.britannica.com/science/cloud-meteorology&lt;/nowiki&gt;&gt;. Ifunyenwe [Ngomhlaka 18 kuNobayeni 2024].&lt;/ref&gt;; Twinckl 2024&lt;ref name=&quot;:1&quot; /&gt;). Esikhathi esinengi amafu la, agcwala isibhakabhaka kanti avame ukuba nombala omlotha nanyana omhlophe (Britannica 2024; Tinckl 2024&lt;ref name=&quot;:1&quot; /&gt;). Ngesikhathi amahlophe, vane atjengisa bonyana angekhe aletha izulu; Kodwana lokha nakatjhugululela kumbala ongeleleko omlotha ukuya ebunzimeni vane atjengisa bonyana aze nezulu ([https://www.britannica.com/science/cloud-meteorology Britannica 2024]; Twinckl2024&lt;ref name=&quot;:1&quot; /&gt;).
 [[Isimumathi:Amafu istrathasi.jpg|left|thumb|200x200px|Amafu istrathasi]]
Istrathasi mamafu adeke khulu lawo othi nawuqala phezulu ongakghoni ukubona nesibhakabhaka kodwana kubonakala wona (Britannica 2024; Twinckl 2024). Esikhathini esinengi mamafu aphasi nanyana aseduze naphasi nanyana abantu (Britannica 2024&lt;ref name=&quot;:2&quot; /&gt;; Twinckl 2024&lt;ref name=&quot;:1&quot; /&gt;). I-Twinckl (2024&lt;ref name=&quot;:1&quot; /&gt;) ingezelele yathi ibanga lokhu amafu la abeseduze nabantu nanyana abephasi kukuthi ayenziwa yikungu. Amafu la enzeka ngesikhathi kumakhaza bese kube nomoya otjhisako nomakhaza ovuthelwako (Britannica 2024&lt;ref name=&quot;:2&quot; /&gt;; Twinckl2024&lt;ref name=&quot;:1&quot; /&gt;). Ukuvuthelwa kwemimoya le, ngikho okuqunta bonyana abe dege kangangani (Britannica 2024&lt;ref name=&quot;:2&quot; /&gt;; Twinckl2024).
 [[Isimumathi:Inimbasi.jpg|thumb|200x200px|Amafu inimbasi]]
Inimbasi mamafu lawo eza nezulu nanyana igabhogo (Britannica 2024&lt;ref name=&quot;:2&quot; /&gt;; Twinckl 2024&lt;ref name=&quot;:1&quot; /&gt;). Esikhathini esinengi umhlobo lo wamafu ubonakala khulu ngesikhathi sokuraramba nokuduma kwezulu (Britannica 2024; Twinckl2024). Ngamanye amagama la mamafu akhambisana nezulu elirarambako nanyana elineembani emikhulu. 

=== Imisebenzi yamafu ===
Amafu anemisebenzi eminengi leyo efaka hlangana ukupholisa nanyana ukwehlisa umtjhiso ephasini lokha nakutjhisa khulu (Wikipedia 2024). Omunye umsebenzi omkhulu kukukwenza bona izulu line ukuze iintjalo nabantu bathole amanzi ([https://letstalkscience.ca/educational-resources/backgrounders/weather-clouds Lets talk Science 2024]). Izulu angekhe lakghona ukuna ngaphandle kwamafu. 
 
=== Isiphetho ===
Amafu umkarisomraro lowo oqakathekileko kithi soke. Begodu kufanele sazi imisebenzi yawo nokuthi enziwa njani. Ukungenzelela imihlobo yamafu nayo kufanele siyizwisise ukuze sizokwazi ukuziphatha ngendlela enqophileko mayelana nayo ngombana eminye imihlobo iza neembani eraramba kabuhlungu khulu. 

=== Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>j527xhas3dsjewi3tj216dfefr0u8oh</sha1>
    </revision>
    <revision>
      <id>2377</id>
      <parentid>2356</parentid>
      <timestamp>2025-01-28T06:09:33Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <minor />
      <comment>/* Amafu */</comment>
      <origin>2377</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4641" sha1="l1o4z6smgyntkjcntemsdcjuzt5eje3" xml:space="preserve">== '''Amafu.''' ==

== Isingeniso ==
Amafu ngezinye zezinto ezimkarisomraro begodu nezibamba indima ekulu ephasini mayelana neenlwana nabantu. Umkarisomraro omkhulu mayelana namafu kukwenzeka kwawo kanye nendawo la atholakala khona. Amafu atholakala esibhakabhakeni begodu ahleli emoyeni ngaphandle kokubona bonyana abanjwe yini. Eenhlokwaneni ezilandelako sizokutjheja bonyana yini amafu, imihlobo edume khulu yamafu kanye nemisebenzi yamafu.

=== Kuyini amafu? ===
Ngokuya kwe-[[:en:Cloud|Wikipedia (2024)]]&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. ''Cloud''. Litholaka ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Cloud&lt;/nowiki&gt;&gt;. Ifunyenwe [Ngomhlaka 18 kuNobayeni 2024].&lt;/ref&gt; amafu kumvango werhwaba nobutlelezana bamathosi, nezinye izinto lezo ezilenge emoyeni nanyana esibhakabhakeni. I-Wikipedia (2024)&lt;ref name=&quot;:0&quot; /&gt; ingezelele yathi amafu la abonaka ephasini nanyana atholakala ephasini abakhona ngebanga lomoya okhuphukela phezulu otjhisakho, ofika le phezulu ube makhaza bese uba yirhwaba. Ukuragela phambili, irhwaba le ithi ingaba nobutlelezi obaneleko bese kubamamafu (Wikipedia 2024)&lt;ref name=&quot;:0&quot; /&gt;.

=== Imihlobo yamafu. ===
[[Isimumathi:Ikhalamasi.jpg|thumb|200x200px|Amafu ikhalamasi]]
Ngokuya kwe-Lets talk Science (2024) &lt;ref&gt;Lets talk Science. 2024.Weather: ''Clouds''. Litholakala ku:&lt; &lt;nowiki&gt;https://letstalkscience.ca/educational-resources/backgrounders/weather-clouds&lt;/nowiki&gt;&gt;. Ifunyenwe [Ngomhlaka 18 kuNobayeni 2024].&lt;/ref&gt;kunemihlobo eminengi yamafu kodwana isirasi, ikhamulasi, istrathasi nenimbasi mihlobo edume nayizwa khulu. I-[https://www.twinkl.co.za/teaching-wiki/cloud Twinckl(2024)]&lt;ref name=&quot;:1&quot;&gt;Twinckl. 2024. ''Cloud''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.twinkl.co.za/teaching-wiki/cloud&lt;/nowiki&gt;&gt;. Ifunyenwe [Ngomhlaka 18 kuNobayeni 2024].&lt;/ref&gt; iveze bonyana amafu isirasi kumamafu lawo aqaleka nanyana afana njengewula begodu adweni. Umhlobo lo wamafu wenziya yirhwaba encani nanyana elula ekhanyelako leyo ewanikela  ubudweni.
Ikhamulasi mamafu labo avela amakhulu begodu abuboyana nawuwaqalileko (Britannica 2024&lt;ref name=&quot;:2&quot;&gt;Britannica. 2024. ''Cloud: Meteorology''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.britannica.com/science/cloud-meteorology&lt;/nowiki&gt;&gt;. Ifunyenwe [Ngomhlaka 18 kuNobayeni 2024].&lt;/ref&gt;; Twinckl 2024&lt;ref name=&quot;:1&quot; /&gt;). Esikhathi esinengi amafu la, agcwala isibhakabhaka kanti avame ukuba nombala omlotha nanyana omhlophe (Britannica 2024; Tinckl 2024&lt;ref name=&quot;:1&quot; /&gt;). Ngesikhathi amahlophe, vane atjengisa bonyana angekhe aletha izulu; Kodwana lokha nakatjhugululela kumbala ongeleleko omlotha ukuya ebunzimeni vane atjengisa bonyana aze nezulu ([https://www.britannica.com/science/cloud-meteorology Britannica 2024]; Twinckl2024&lt;ref name=&quot;:1&quot; /&gt;).
 [[Isimumathi:Amafu istrathasi.jpg|left|thumb|200x200px|Amafu istrathasi]]
Istrathasi mamafu adeke khulu lawo othi nawuqala phezulu ongakghoni ukubona nesibhakabhaka kodwana kubonakala wona (Britannica 2024; Twinckl 2024). Esikhathini esinengi mamafu aphasi nanyana aseduze naphasi nanyana abantu (Britannica 2024&lt;ref name=&quot;:2&quot; /&gt;; Twinckl 2024&lt;ref name=&quot;:1&quot; /&gt;). I-Twinckl (2024&lt;ref name=&quot;:1&quot; /&gt;) ingezelele yathi ibanga lokhu amafu la abeseduze nabantu nanyana abephasi kukuthi ayenziwa yikungu. Amafu la enzeka ngesikhathi kumakhaza bese kube nomoya otjhisako nomakhaza ovuthelwako (Britannica 2024&lt;ref name=&quot;:2&quot; /&gt;; Twinckl2024&lt;ref name=&quot;:1&quot; /&gt;). Ukuvuthelwa kwemimoya le, ngikho okuqunta bonyana abe dege kangangani (Britannica 2024&lt;ref name=&quot;:2&quot; /&gt;; Twinckl2024).
 [[Isimumathi:Inimbasi.jpg|thumb|200x200px|Amafu inimbasi]]
Inimbasi mamafu lawo eza nezulu nanyana igabhogo (Britannica 2024&lt;ref name=&quot;:2&quot; /&gt;; Twinckl 2024&lt;ref name=&quot;:1&quot; /&gt;). Esikhathini esinengi umhlobo lo wamafu ubonakala khulu ngesikhathi sokuraramba nokuduma kwezulu (Britannica 2024; Twinckl2024). Ngamanye amagama la mamafu akhambisana nezulu elirarambako nanyana elineembani emikhulu. 

=== Imisebenzi yamafu ===
Amafu anemisebenzi eminengi leyo efaka hlangana ukupholisa nanyana ukwehlisa umtjhiso ephasini lokha nakutjhisa khulu (Wikipedia 2024). Omunye umsebenzi omkhulu kukukwenza bona izulu line ukuze iintjalo nabantu bathole amanzi ([https://letstalkscience.ca/educational-resources/backgrounders/weather-clouds Lets talk Science 2024]). Izulu angekhe lakghona ukuna ngaphandle kwamafu. 
 
=== Isiphetho ===
Amafu umkarisomraro lowo oqakathekileko kithi soke. Begodu kufanele sazi imisebenzi yawo nokuthi enziwa njani. Ukungenzelela imihlobo yamafu nayo kufanele siyizwisise ukuze sizokwazi ukuziphatha ngendlela enqophileko mayelana nayo ngombana eminye imihlobo iza neembani eraramba kabuhlungu khulu. 

=== Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>l1o4z6smgyntkjcntemsdcjuzt5eje3</sha1>
    </revision>
    <revision>
      <id>2577</id>
      <parentid>2377</parentid>
      <timestamp>2025-03-22T05:51:41Z</timestamp>
      <contributor>
        <username>Kvazimodo</username>
        <id>341</id>
      </contributor>
      <origin>2577</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4605" sha1="pqik1c5c6fxbqbrfup8z5fksy4rdg1n" xml:space="preserve">'''Amafu;''' Amafu ngezinye zezinto ezimkarisomraro begodu nezibamba indima ekulu ephasini mayelana neenlwana nabantu. Umkarisomraro omkhulu mayelana namafu kukwenzeka kwawo kanye nendawo la atholakala khona. Amafu atholakala esibhakabhakeni begodu ahleli emoyeni ngaphandle kokubona bonyana abanjwe yini. Eenhlokwaneni ezilandelako sizokutjheja bonyana yini amafu, imihlobo edume khulu yamafu kanye nemisebenzi yamafu.

== Kuyini amafu? ==
Ngokuya kwe-[[:en:Cloud|Wikipedia (2024)]]&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. ''Cloud''. Litholaka ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Cloud&lt;/nowiki&gt;&gt;. Ifunyenwe [Ngomhlaka 18 kuNobayeni 2024].&lt;/ref&gt; amafu kumvango werhwaba nobutlelezana bamathosi, nezinye izinto lezo ezilenge emoyeni nanyana esibhakabhakeni. I-Wikipedia (2024)&lt;ref name=&quot;:0&quot; /&gt; ingezelele yathi amafu la abonaka ephasini nanyana atholakala ephasini abakhona ngebanga lomoya okhuphukela phezulu otjhisakho, ofika le phezulu ube makhaza bese uba yirhwaba. Ukuragela phambili, irhwaba le ithi ingaba nobutlelezi obaneleko bese kubamamafu (Wikipedia 2024)&lt;ref name=&quot;:0&quot; /&gt;.

== Imihlobo yamafu ==
[[Isimumathi:Ikhalamasi.jpg|thumb|200x200px|Amafu ikhalamasi]]
Ngokuya kwe-Lets talk Science (2024) &lt;ref&gt;Lets talk Science. 2024.Weather: ''Clouds''. Litholakala ku:&lt; &lt;nowiki&gt;https://letstalkscience.ca/educational-resources/backgrounders/weather-clouds&lt;/nowiki&gt;&gt;. Ifunyenwe [Ngomhlaka 18 kuNobayeni 2024].&lt;/ref&gt;kunemihlobo eminengi yamafu kodwana isirasi, ikhamulasi, istrathasi nenimbasi mihlobo edume nayizwa khulu. I-[https://www.twinkl.co.za/teaching-wiki/cloud Twinckl(2024)]&lt;ref name=&quot;:1&quot;&gt;Twinckl. 2024. ''Cloud''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.twinkl.co.za/teaching-wiki/cloud&lt;/nowiki&gt;&gt;. Ifunyenwe [Ngomhlaka 18 kuNobayeni 2024].&lt;/ref&gt; iveze bonyana amafu isirasi kumamafu lawo aqaleka nanyana afana njengewula begodu adweni. Umhlobo lo wamafu wenziya yirhwaba encani nanyana elula ekhanyelako leyo ewanikela  ubudweni.
Ikhamulasi mamafu labo avela amakhulu begodu abuboyana nawuwaqalileko (Britannica 2024&lt;ref name=&quot;:2&quot;&gt;Britannica. 2024. ''Cloud: Meteorology''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.britannica.com/science/cloud-meteorology&lt;/nowiki&gt;&gt;. Ifunyenwe [Ngomhlaka 18 kuNobayeni 2024].&lt;/ref&gt;; Twinckl 2024&lt;ref name=&quot;:1&quot; /&gt;). Esikhathi esinengi amafu la, agcwala isibhakabhaka kanti avame ukuba nombala omlotha nanyana omhlophe (Britannica 2024; Tinckl 2024&lt;ref name=&quot;:1&quot; /&gt;). Ngesikhathi amahlophe, vane atjengisa bonyana angekhe aletha izulu; Kodwana lokha nakatjhugululela kumbala ongeleleko omlotha ukuya ebunzimeni vane atjengisa bonyana aze nezulu ([https://www.britannica.com/science/cloud-meteorology Britannica 2024]; Twinckl2024&lt;ref name=&quot;:1&quot; /&gt;).
[[Isimumathi:Amafu istrathasi.jpg|left|thumb|200x200px|Amafu istrathasi]]
Istrathasi mamafu adeke khulu lawo othi nawuqala phezulu ongakghoni ukubona nesibhakabhaka kodwana kubonakala wona (Britannica 2024; Twinckl 2024). Esikhathini esinengi mamafu aphasi nanyana aseduze naphasi nanyana abantu (Britannica 2024&lt;ref name=&quot;:2&quot; /&gt;; Twinckl 2024&lt;ref name=&quot;:1&quot; /&gt;). I-Twinckl (2024&lt;ref name=&quot;:1&quot; /&gt;) ingezelele yathi ibanga lokhu amafu la abeseduze nabantu nanyana abephasi kukuthi ayenziwa yikungu. Amafu la enzeka ngesikhathi kumakhaza bese kube nomoya otjhisako nomakhaza ovuthelwako (Britannica 2024&lt;ref name=&quot;:2&quot; /&gt;; Twinckl2024&lt;ref name=&quot;:1&quot; /&gt;). Ukuvuthelwa kwemimoya le, ngikho okuqunta bonyana abe dege kangangani (Britannica 2024&lt;ref name=&quot;:2&quot; /&gt;; Twinckl2024).
 [[Isimumathi:Inimbasi.jpg|thumb|200x200px|Amafu inimbasi]]
Inimbasi mamafu lawo eza nezulu nanyana igabhogo (Britannica 2024&lt;ref name=&quot;:2&quot; /&gt;; Twinckl 2024&lt;ref name=&quot;:1&quot; /&gt;). Esikhathini esinengi umhlobo lo wamafu ubonakala khulu ngesikhathi sokuraramba nokuduma kwezulu (Britannica 2024; Twinckl2024). Ngamanye amagama la mamafu akhambisana nezulu elirarambako nanyana elineembani emikhulu. 

== Imisebenzi yamafu ==
Amafu anemisebenzi eminengi leyo efaka hlangana ukupholisa nanyana ukwehlisa umtjhiso ephasini lokha nakutjhisa khulu (Wikipedia 2024). Omunye umsebenzi omkhulu kukukwenza bona izulu line ukuze iintjalo nabantu bathole amanzi ([https://letstalkscience.ca/educational-resources/backgrounders/weather-clouds Lets talk Science 2024]). Izulu angekhe lakghona ukuna ngaphandle kwamafu. 
 
== Isiphetho ==
Amafu umkarisomraro lowo oqakathekileko kithi soke. Begodu kufanele sazi imisebenzi yawo nokuthi enziwa njani. Ukungenzelela imihlobo yamafu nayo kufanele siyizwisise ukuze sizokwazi ukuziphatha ngendlela enqophileko mayelana nayo ngombana eminye imihlobo iza neembani eraramba kabuhlungu khulu. 

== Umthombolwazi ==
&lt;references /&gt;</text>
      <sha1>pqik1c5c6fxbqbrfup8z5fksy4rdg1n</sha1>
    </revision>
    <revision>
      <id>2986</id>
      <parentid>2577</parentid>
      <timestamp>2025-06-06T20:12:08Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>yup your banned</comment>
      <origin>2986</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4686" sha1="3lym90h20509nx5djmzuc4uzb6qkaja" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. Amafu;''' Amafu ngezinye zezinto ezimkarisomraro begodu nezibamba indima ekulu ephasini mayelana neenlwana nabantu. Umkarisomraro omkhulu mayelana namafu kukwenzeka kwawo kanye nendawo la atholakala khona. Amafu atholakala esibhakabhakeni begodu ahleli emoyeni ngaphandle kokubona bonyana abanjwe yini. Eenhlokwaneni ezilandelako sizokutjheja bonyana yini amafu, imihlobo edume khulu yamafu kanye nemisebenzi yamafu.

== Kuyini amafu? ==
Ngokuya kwe-[[:en:Cloud|Wikipedia (2024)]]&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. ''Cloud''. Litholaka ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Cloud&lt;/nowiki&gt;&gt;. Ifunyenwe [Ngomhlaka 18 kuNobayeni 2024].&lt;/ref&gt; amafu kumvango werhwaba nobutlelezana bamathosi, nezinye izinto lezo ezilenge emoyeni nanyana esibhakabhakeni. I-Wikipedia (2024)&lt;ref name=&quot;:0&quot; /&gt; ingezelele yathi amafu la abonaka ephasini nanyana atholakala ephasini abakhona ngebanga lomoya okhuphukela phezulu otjhisakho, ofika le phezulu ube makhaza bese uba yirhwaba. Ukuragela phambili, irhwaba le ithi ingaba nobutlelezi obaneleko bese kubamamafu (Wikipedia 2024)&lt;ref name=&quot;:0&quot; /&gt;.

== Imihlobo yamafu ==
[[Isimumathi:Ikhalamasi.jpg|thumb|200x200px|Amafu ikhalamasi]]
Ngokuya kwe-Lets talk Science (2024) &lt;ref&gt;Lets talk Science. 2024.Weather: ''Clouds''. Litholakala ku:&lt; &lt;nowiki&gt;https://letstalkscience.ca/educational-resources/backgrounders/weather-clouds&lt;/nowiki&gt;&gt;. Ifunyenwe [Ngomhlaka 18 kuNobayeni 2024].&lt;/ref&gt;kunemihlobo eminengi yamafu kodwana isirasi, ikhamulasi, istrathasi nenimbasi mihlobo edume nayizwa khulu. I-[https://www.twinkl.co.za/teaching-wiki/cloud Twinckl(2024)]&lt;ref name=&quot;:1&quot;&gt;Twinckl. 2024. ''Cloud''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.twinkl.co.za/teaching-wiki/cloud&lt;/nowiki&gt;&gt;. Ifunyenwe [Ngomhlaka 18 kuNobayeni 2024].&lt;/ref&gt; iveze bonyana amafu isirasi kumamafu lawo aqaleka nanyana afana njengewula begodu adweni. Umhlobo lo wamafu wenziya yirhwaba encani nanyana elula ekhanyelako leyo ewanikela  ubudweni.
Ikhamulasi mamafu labo avela amakhulu begodu abuboyana nawuwaqalileko (Britannica 2024&lt;ref name=&quot;:2&quot;&gt;Britannica. 2024. ''Cloud: Meteorology''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.britannica.com/science/cloud-meteorology&lt;/nowiki&gt;&gt;. Ifunyenwe [Ngomhlaka 18 kuNobayeni 2024].&lt;/ref&gt;; Twinckl 2024&lt;ref name=&quot;:1&quot; /&gt;). Esikhathi esinengi amafu la, agcwala isibhakabhaka kanti avame ukuba nombala omlotha nanyana omhlophe (Britannica 2024; Tinckl 2024&lt;ref name=&quot;:1&quot; /&gt;). Ngesikhathi amahlophe, vane atjengisa bonyana angekhe aletha izulu; Kodwana lokha nakatjhugululela kumbala ongeleleko omlotha ukuya ebunzimeni vane atjengisa bonyana aze nezulu ([https://www.britannica.com/science/cloud-meteorology Britannica 2024]; Twinckl2024&lt;ref name=&quot;:1&quot; /&gt;).
[[Isimumathi:Amafu istrathasi.jpg|left|thumb|200x200px|Amafu istrathasi]]
Istrathasi mamafu adeke khulu lawo othi nawuqala phezulu ongakghoni ukubona nesibhakabhaka kodwana kubonakala wona (Britannica 2024; Twinckl 2024). Esikhathini esinengi mamafu aphasi nanyana aseduze naphasi nanyana abantu (Britannica 2024&lt;ref name=&quot;:2&quot; /&gt;; Twinckl 2024&lt;ref name=&quot;:1&quot; /&gt;). I-Twinckl (2024&lt;ref name=&quot;:1&quot; /&gt;) ingezelele yathi ibanga lokhu amafu la abeseduze nabantu nanyana abephasi kukuthi ayenziwa yikungu. Amafu la enzeka ngesikhathi kumakhaza bese kube nomoya otjhisako nomakhaza ovuthelwako (Britannica 2024&lt;ref name=&quot;:2&quot; /&gt;; Twinckl2024&lt;ref name=&quot;:1&quot; /&gt;). Ukuvuthelwa kwemimoya le, ngikho okuqunta bonyana abe dege kangangani (Britannica 2024&lt;ref name=&quot;:2&quot; /&gt;; Twinckl2024).
 [[Isimumathi:Inimbasi.jpg|thumb|200x200px|Amafu inimbasi]]
Inimbasi mamafu lawo eza nezulu nanyana igabhogo (Britannica 2024&lt;ref name=&quot;:2&quot; /&gt;; Twinckl 2024&lt;ref name=&quot;:1&quot; /&gt;). Esikhathini esinengi umhlobo lo wamafu ubonakala khulu ngesikhathi sokuraramba nokuduma kwezulu (Britannica 2024; Twinckl2024). Ngamanye amagama la mamafu akhambisana nezulu elirarambako nanyana elineembani emikhulu. 

== Imisebenzi yamafu ==
Amafu anemisebenzi eminengi leyo efaka hlangana ukupholisa nanyana ukwehlisa umtjhiso ephasini lokha nakutjhisa khulu (Wikipedia 2024). Omunye umsebenzi omkhulu kukukwenza bona izulu line ukuze iintjalo nabantu bathole amanzi ([https://letstalkscience.ca/educational-resources/backgrounders/weather-clouds Lets talk Science 2024]). Izulu angekhe lakghona ukuna ngaphandle kwamafu. 
 
== Isiphetho ==
Amafu umkarisomraro lowo oqakathekileko kithi soke. Begodu kufanele sazi imisebenzi yawo nokuthi enziwa njani. Ukungenzelela imihlobo yamafu nayo kufanele siyizwisise ukuze sizokwazi ukuziphatha ngendlela enqophileko mayelana nayo ngombana eminye imihlobo iza neembani eraramba kabuhlungu khulu. 

== Umthombolwazi ==
&lt;references /&gt;</text>
      <sha1>3lym90h20509nx5djmzuc4uzb6qkaja</sha1>
    </revision>
    <revision>
      <id>3075</id>
      <parentid>2986</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Janabaevazizbek|Janabaevazizbek]]</comment>
      <origin>2577</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4605" sha1="pqik1c5c6fxbqbrfup8z5fksy4rdg1n" xml:space="preserve">'''Amafu;''' Amafu ngezinye zezinto ezimkarisomraro begodu nezibamba indima ekulu ephasini mayelana neenlwana nabantu. Umkarisomraro omkhulu mayelana namafu kukwenzeka kwawo kanye nendawo la atholakala khona. Amafu atholakala esibhakabhakeni begodu ahleli emoyeni ngaphandle kokubona bonyana abanjwe yini. Eenhlokwaneni ezilandelako sizokutjheja bonyana yini amafu, imihlobo edume khulu yamafu kanye nemisebenzi yamafu.

== Kuyini amafu? ==
Ngokuya kwe-[[:en:Cloud|Wikipedia (2024)]]&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. ''Cloud''. Litholaka ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Cloud&lt;/nowiki&gt;&gt;. Ifunyenwe [Ngomhlaka 18 kuNobayeni 2024].&lt;/ref&gt; amafu kumvango werhwaba nobutlelezana bamathosi, nezinye izinto lezo ezilenge emoyeni nanyana esibhakabhakeni. I-Wikipedia (2024)&lt;ref name=&quot;:0&quot; /&gt; ingezelele yathi amafu la abonaka ephasini nanyana atholakala ephasini abakhona ngebanga lomoya okhuphukela phezulu otjhisakho, ofika le phezulu ube makhaza bese uba yirhwaba. Ukuragela phambili, irhwaba le ithi ingaba nobutlelezi obaneleko bese kubamamafu (Wikipedia 2024)&lt;ref name=&quot;:0&quot; /&gt;.

== Imihlobo yamafu ==
[[Isimumathi:Ikhalamasi.jpg|thumb|200x200px|Amafu ikhalamasi]]
Ngokuya kwe-Lets talk Science (2024) &lt;ref&gt;Lets talk Science. 2024.Weather: ''Clouds''. Litholakala ku:&lt; &lt;nowiki&gt;https://letstalkscience.ca/educational-resources/backgrounders/weather-clouds&lt;/nowiki&gt;&gt;. Ifunyenwe [Ngomhlaka 18 kuNobayeni 2024].&lt;/ref&gt;kunemihlobo eminengi yamafu kodwana isirasi, ikhamulasi, istrathasi nenimbasi mihlobo edume nayizwa khulu. I-[https://www.twinkl.co.za/teaching-wiki/cloud Twinckl(2024)]&lt;ref name=&quot;:1&quot;&gt;Twinckl. 2024. ''Cloud''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.twinkl.co.za/teaching-wiki/cloud&lt;/nowiki&gt;&gt;. Ifunyenwe [Ngomhlaka 18 kuNobayeni 2024].&lt;/ref&gt; iveze bonyana amafu isirasi kumamafu lawo aqaleka nanyana afana njengewula begodu adweni. Umhlobo lo wamafu wenziya yirhwaba encani nanyana elula ekhanyelako leyo ewanikela  ubudweni.
Ikhamulasi mamafu labo avela amakhulu begodu abuboyana nawuwaqalileko (Britannica 2024&lt;ref name=&quot;:2&quot;&gt;Britannica. 2024. ''Cloud: Meteorology''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.britannica.com/science/cloud-meteorology&lt;/nowiki&gt;&gt;. Ifunyenwe [Ngomhlaka 18 kuNobayeni 2024].&lt;/ref&gt;; Twinckl 2024&lt;ref name=&quot;:1&quot; /&gt;). Esikhathi esinengi amafu la, agcwala isibhakabhaka kanti avame ukuba nombala omlotha nanyana omhlophe (Britannica 2024; Tinckl 2024&lt;ref name=&quot;:1&quot; /&gt;). Ngesikhathi amahlophe, vane atjengisa bonyana angekhe aletha izulu; Kodwana lokha nakatjhugululela kumbala ongeleleko omlotha ukuya ebunzimeni vane atjengisa bonyana aze nezulu ([https://www.britannica.com/science/cloud-meteorology Britannica 2024]; Twinckl2024&lt;ref name=&quot;:1&quot; /&gt;).
[[Isimumathi:Amafu istrathasi.jpg|left|thumb|200x200px|Amafu istrathasi]]
Istrathasi mamafu adeke khulu lawo othi nawuqala phezulu ongakghoni ukubona nesibhakabhaka kodwana kubonakala wona (Britannica 2024; Twinckl 2024). Esikhathini esinengi mamafu aphasi nanyana aseduze naphasi nanyana abantu (Britannica 2024&lt;ref name=&quot;:2&quot; /&gt;; Twinckl 2024&lt;ref name=&quot;:1&quot; /&gt;). I-Twinckl (2024&lt;ref name=&quot;:1&quot; /&gt;) ingezelele yathi ibanga lokhu amafu la abeseduze nabantu nanyana abephasi kukuthi ayenziwa yikungu. Amafu la enzeka ngesikhathi kumakhaza bese kube nomoya otjhisako nomakhaza ovuthelwako (Britannica 2024&lt;ref name=&quot;:2&quot; /&gt;; Twinckl2024&lt;ref name=&quot;:1&quot; /&gt;). Ukuvuthelwa kwemimoya le, ngikho okuqunta bonyana abe dege kangangani (Britannica 2024&lt;ref name=&quot;:2&quot; /&gt;; Twinckl2024).
 [[Isimumathi:Inimbasi.jpg|thumb|200x200px|Amafu inimbasi]]
Inimbasi mamafu lawo eza nezulu nanyana igabhogo (Britannica 2024&lt;ref name=&quot;:2&quot; /&gt;; Twinckl 2024&lt;ref name=&quot;:1&quot; /&gt;). Esikhathini esinengi umhlobo lo wamafu ubonakala khulu ngesikhathi sokuraramba nokuduma kwezulu (Britannica 2024; Twinckl2024). Ngamanye amagama la mamafu akhambisana nezulu elirarambako nanyana elineembani emikhulu. 

== Imisebenzi yamafu ==
Amafu anemisebenzi eminengi leyo efaka hlangana ukupholisa nanyana ukwehlisa umtjhiso ephasini lokha nakutjhisa khulu (Wikipedia 2024). Omunye umsebenzi omkhulu kukukwenza bona izulu line ukuze iintjalo nabantu bathole amanzi ([https://letstalkscience.ca/educational-resources/backgrounders/weather-clouds Lets talk Science 2024]). Izulu angekhe lakghona ukuna ngaphandle kwamafu. 
 
== Isiphetho ==
Amafu umkarisomraro lowo oqakathekileko kithi soke. Begodu kufanele sazi imisebenzi yawo nokuthi enziwa njani. Ukungenzelela imihlobo yamafu nayo kufanele siyizwisise ukuze sizokwazi ukuziphatha ngendlela enqophileko mayelana nayo ngombana eminye imihlobo iza neembani eraramba kabuhlungu khulu. 

== Umthombolwazi ==
&lt;references /&gt;</text>
      <sha1>pqik1c5c6fxbqbrfup8z5fksy4rdg1n</sha1>
    </revision>
  </page>
  <page>
    <title>Igezi</title>
    <ns>0</ns>
    <id>443</id>
    <revision>
      <id>2355</id>
      <timestamp>2025-01-23T07:42:58Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <comment>Created page with &quot;== Igezi ==  === Isingeniso === Ngokuya kwe-[https://learn.sparkfun.com/tutorials/what-is-electricity/all Learn Sparkfun (2024)]&lt;ref name=&quot;:0&quot;&gt;Learn Sparkfun. 2024. ''What is electricity?'' Litholakala ku:&lt; &lt;nowiki&gt;https://learn.sparkfun.com/tutorials/what-is-electricity/all&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 18 kuNobayeni 2024].&lt;/ref&gt; igezi mamandla nanyana umlilo loyo okghonwa ukusetjenziswa yithekhnoloji efana nabafunjwathwako, imitjhiningqondo, amalerhe, iimphehlimoya k...&quot;</comment>
      <origin>2355</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3575" sha1="b1stjy1od34wyt1jwxyso4ilseycchu" xml:space="preserve">== Igezi ==

=== Isingeniso ===
Ngokuya kwe-[https://learn.sparkfun.com/tutorials/what-is-electricity/all Learn Sparkfun (2024)]&lt;ref name=&quot;:0&quot;&gt;Learn Sparkfun. 2024. ''What is electricity?'' Litholakala ku:&lt; &lt;nowiki&gt;https://learn.sparkfun.com/tutorials/what-is-electricity/all&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 18 kuNobayeni 2024].&lt;/ref&gt; igezi mamandla nanyana umlilo loyo okghonwa ukusetjenziswa yithekhnoloji efana nabafunjwathwako, imitjhiningqondo, amalerhe, iimphehlimoya kanye nezinye izinto. Esihlokweni esilandelako sizokutjheja bonyana kuyini igezi

=== Kuyini igezi? ===
[[Isimumathi:Igezi.jpg|thumb|Igezi]]
I-Learn Sparkfun (2024)&lt;ref name=&quot;:0&quot; /&gt;, ithi kubudisana ukuhlathulula bonyana igezi iyini; kodwana, igezi yinto yemvelo begodu imamandla nomlilo lawo asetjenziswa ngemihlobo eyahlukeneko yezinto, khulukhulu zethekhnoloji. I-[[:en:Electricity|Wikipedia (2024]])&lt;ref name=&quot;:1&quot;&gt;Wikipedia. 2024. ''Electricity''. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Electricity&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 18 kuNobayeni 2024]&lt;/ref&gt; ingezelele yathi igezi kukugeleza nanyana ukuphuma kwamatjhaji wegezi lawo afike asetjenziwe njengamandla wokwenza bonyana izinto ezinengi zethekhnoloji zisebenze. Ukuphuma nanyana ukugeleza kwamatjhaji wegezi la, kuhlukaniswe kabili. Kukhona amatjhaji wegezi angezelelako (+) namatjhaji wegezi aphungululako (-) [[https://www.eia.gov/energyexplained/electricity/ US Energy Information Adminstartion 2024]&lt;ref name=&quot;:2&quot;&gt;US Energy Information Administration. 2024. ''Electricity.'' Litholaka ku:&lt; &lt;nowiki&gt;https://www.eia.gov/energyexplained/electricity/&lt;/nowiki&gt;&gt; . &gt;. Ifunyenwe [ngomhlaka 18 kuNobayeni 2024].&lt;/ref&gt;].

Igezi le esetjenziswa endlini nanyana babantu emtjhinini yabo, kumamadla nanyana kumlilo wesibili (US Energy Information Adminstartion 2024)&lt;ref name=&quot;:2&quot; /&gt;. Lokhu kusibikela bonyana kukhona umhlobo wokuthoma wamandla nanyana womlilo wegezi loyo onamandla khulu engekhe sakghona ukuwusebenzisa eendlini nanyana emitjhinini yethu eminengi. Iphuzu leli lisekelwe yi-US Energy Information Administration (2024) nayithi, igezi esetjenziswa endlini imamandla nanyana umlilo wesibili ngombana ikhiqhizwe ngokutjhugulula imithombo yokuthoma yamandla nanyana yomlilo efaka hlangana amalahle, umsebe yelanga nanyana amandla welangana nomoya ukuze ibe yigezi le esikghona ukuyisebenzisa. Baragele phambili, be-US Energy Information Adminstartion (2024)&lt;ref name=&quot;:2&quot; /&gt; bathi, umthombo wokuthoma wegezi kumlilo nanyana amandla asetjenziswa ngokubuyelelwa nasetjenziswa ngokungabuyelelwa. Esohlokwaneni esilandelako sizokutjheja imisebenzi yegezi.

=== Imisebenzi yegezi ===
Igezi idlala indima ekulu tle eempilweni zethu njengoba sazi ukuthi siphila esikhathi sethekhnoloji nesoburhatjharhatjha besine. Igezi isebenzi ukunikela amandla nomlilo eenthuthini, izinto zokupheka, izinto zokufunda njengemitjhiningqondo nethungelwano, ukukhulisa iintjalo nefuyo (Wikipedia 2024)&lt;ref name=&quot;:1&quot; /&gt;. Ngakho-ke, igezi isekabeni yipilo yethu begodu abanye abantu bangabhalelwa kuphila ngaphande kwayo njengombana vane kube budisi khulu nakunokuqintelwa kwegezi nanyana ukutlhayela kwegezi. 

=== Isiphetho ===
Igezi ngenye yezinto eziqakathekileko kodwana ebudisi tle ukuyihlathulula nanyana sisebenza ngayo mihla namalanga. Igezi sele idosa phambili ekusirholeni epilweni esiyiphilako ngombana ngaphandle kwayo sele sinobudisi bokungakghoni ezinye zezinto. Nanyana kunjalo, kuqakathekile bonyana siyisebenzise kuhle begodi sizifundise nezinye iindlela zokwenza izinto ngaphandle kwayo.

===  Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>b1stjy1od34wyt1jwxyso4ilseycchu</sha1>
    </revision>
    <revision>
      <id>2378</id>
      <parentid>2355</parentid>
      <timestamp>2025-01-28T06:10:12Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <minor />
      <comment>/* Igezi */</comment>
      <origin>2378</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3576" sha1="5w7ok03xu7qcn6rw32dt9oovx8sgmbz" xml:space="preserve">== Igezi. ==

=== Isingeniso ===
Ngokuya kwe-[https://learn.sparkfun.com/tutorials/what-is-electricity/all Learn Sparkfun (2024)]&lt;ref name=&quot;:0&quot;&gt;Learn Sparkfun. 2024. ''What is electricity?'' Litholakala ku:&lt; &lt;nowiki&gt;https://learn.sparkfun.com/tutorials/what-is-electricity/all&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 18 kuNobayeni 2024].&lt;/ref&gt; igezi mamandla nanyana umlilo loyo okghonwa ukusetjenziswa yithekhnoloji efana nabafunjwathwako, imitjhiningqondo, amalerhe, iimphehlimoya kanye nezinye izinto. Esihlokweni esilandelako sizokutjheja bonyana kuyini igezi

=== Kuyini igezi? ===
[[Isimumathi:Igezi.jpg|thumb|Igezi]]
I-Learn Sparkfun (2024)&lt;ref name=&quot;:0&quot; /&gt;, ithi kubudisana ukuhlathulula bonyana igezi iyini; kodwana, igezi yinto yemvelo begodu imamandla nomlilo lawo asetjenziswa ngemihlobo eyahlukeneko yezinto, khulukhulu zethekhnoloji. I-[[:en:Electricity|Wikipedia (2024]])&lt;ref name=&quot;:1&quot;&gt;Wikipedia. 2024. ''Electricity''. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Electricity&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 18 kuNobayeni 2024]&lt;/ref&gt; ingezelele yathi igezi kukugeleza nanyana ukuphuma kwamatjhaji wegezi lawo afike asetjenziwe njengamandla wokwenza bonyana izinto ezinengi zethekhnoloji zisebenze. Ukuphuma nanyana ukugeleza kwamatjhaji wegezi la, kuhlukaniswe kabili. Kukhona amatjhaji wegezi angezelelako (+) namatjhaji wegezi aphungululako (-) [[https://www.eia.gov/energyexplained/electricity/ US Energy Information Adminstartion 2024]&lt;ref name=&quot;:2&quot;&gt;US Energy Information Administration. 2024. ''Electricity.'' Litholaka ku:&lt; &lt;nowiki&gt;https://www.eia.gov/energyexplained/electricity/&lt;/nowiki&gt;&gt; . &gt;. Ifunyenwe [ngomhlaka 18 kuNobayeni 2024].&lt;/ref&gt;].

Igezi le esetjenziswa endlini nanyana babantu emtjhinini yabo, kumamadla nanyana kumlilo wesibili (US Energy Information Adminstartion 2024)&lt;ref name=&quot;:2&quot; /&gt;. Lokhu kusibikela bonyana kukhona umhlobo wokuthoma wamandla nanyana womlilo wegezi loyo onamandla khulu engekhe sakghona ukuwusebenzisa eendlini nanyana emitjhinini yethu eminengi. Iphuzu leli lisekelwe yi-US Energy Information Administration (2024) nayithi, igezi esetjenziswa endlini imamandla nanyana umlilo wesibili ngombana ikhiqhizwe ngokutjhugulula imithombo yokuthoma yamandla nanyana yomlilo efaka hlangana amalahle, umsebe yelanga nanyana amandla welangana nomoya ukuze ibe yigezi le esikghona ukuyisebenzisa. Baragele phambili, be-US Energy Information Adminstartion (2024)&lt;ref name=&quot;:2&quot; /&gt; bathi, umthombo wokuthoma wegezi kumlilo nanyana amandla asetjenziswa ngokubuyelelwa nasetjenziswa ngokungabuyelelwa. Esohlokwaneni esilandelako sizokutjheja imisebenzi yegezi.

=== Imisebenzi yegezi ===
Igezi idlala indima ekulu tle eempilweni zethu njengoba sazi ukuthi siphila esikhathi sethekhnoloji nesoburhatjharhatjha besine. Igezi isebenzi ukunikela amandla nomlilo eenthuthini, izinto zokupheka, izinto zokufunda njengemitjhiningqondo nethungelwano, ukukhulisa iintjalo nefuyo (Wikipedia 2024)&lt;ref name=&quot;:1&quot; /&gt;. Ngakho-ke, igezi isekabeni yipilo yethu begodu abanye abantu bangabhalelwa kuphila ngaphande kwayo njengombana vane kube budisi khulu nakunokuqintelwa kwegezi nanyana ukutlhayela kwegezi. 

=== Isiphetho ===
Igezi ngenye yezinto eziqakathekileko kodwana ebudisi tle ukuyihlathulula nanyana sisebenza ngayo mihla namalanga. Igezi sele idosa phambili ekusirholeni epilweni esiyiphilako ngombana ngaphandle kwayo sele sinobudisi bokungakghoni ezinye zezinto. Nanyana kunjalo, kuqakathekile bonyana siyisebenzise kuhle begodi sizifundise nezinye iindlela zokwenza izinto ngaphandle kwayo.

===  Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>5w7ok03xu7qcn6rw32dt9oovx8sgmbz</sha1>
    </revision>
    <revision>
      <id>2635</id>
      <parentid>2378</parentid>
      <timestamp>2025-04-03T19:10:48Z</timestamp>
      <contributor>
        <username>Rachmat04</username>
        <id>32</id>
      </contributor>
      <minor />
      <origin>2635</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3573" sha1="lzqa130dojm9y3s7w0v09nwpz4rvhha" xml:space="preserve">== Igezi. ==

=== Isingeniso ===
Ngokuya kwe-[https://learn.sparkfun.com/tutorials/what-is-electricity/all Learn Sparkfun (2024)]&lt;ref name=&quot;:0&quot;&gt;Learn Sparkfun. 2024. ''What is electricity?'' Litholakala ku:&lt; &lt;nowiki&gt;https://learn.sparkfun.com/tutorials/what-is-electricity/all&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 18 kuNobayeni 2024].&lt;/ref&gt; igezi mamandla nanyana umlilo loyo okghonwa ukusetjenziswa yithekhnoloji efana nabafunjwathwako, imitjhiningqondo, amalerhe, iimphehlimoya kanye nezinye izinto. Esihlokweni esilandelako sizokutjheja bonyana kuyini igezi

=== Kuyini igezi? ===
[[Isimumathi:Igezi.jpg|thumb|Igezi]]
I-Learn Sparkfun (2024)&lt;ref name=&quot;:0&quot; /&gt;, ithi kubudisana ukuhlathulula bonyana igezi iyini; kodwana, igezi yinto yemvelo begodu imamandla nomlilo lawo asetjenziswa ngemihlobo eyahlukeneko yezinto, khulukhulu zethekhnoloji. I-[[:en:Electricity|Wikipedia (2024]])&lt;ref name=&quot;:1&quot;&gt;Wikipedia. 2024. ''Electricity''. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Electricity&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 18 kuNobayeni 2024]&lt;/ref&gt; ingezelele yathi igezi kukugeleza nanyana ukuphuma kwamatjhaji wegezi lawo afike asetjenziwe njengamandla wokwenza bonyana izinto ezinengi zethekhnoloji zisebenze. Ukuphuma nanyana ukugeleza kwamatjhaji wegezi la, kuhlukaniswe kabili. Kukhona amatjhaji wegezi angezelelako (+) namatjhaji wegezi aphungululako (-) [https://www.eia.gov/energyexplained/electricity/ US Energy Information Adminstartion 2024]&lt;ref name=&quot;:2&quot;&gt;US Energy Information Administration. 2024. ''Electricity.'' Litholaka ku:&lt; &lt;nowiki&gt;https://www.eia.gov/energyexplained/electricity/&lt;/nowiki&gt;&gt; . &gt;. Ifunyenwe [ngomhlaka 18 kuNobayeni 2024].&lt;/ref&gt;].

Igezi le esetjenziswa endlini nanyana babantu emtjhinini yabo, kumamadla nanyana kumlilo wesibili (US Energy Information Adminstartion 2024)&lt;ref name=&quot;:2&quot; /&gt;. Lokhu kusibikela bonyana kukhona umhlobo wokuthoma wamandla nanyana womlilo wegezi loyo onamandla khulu engekhe sakghona ukuwusebenzisa eendlini nanyana emitjhinini yethu eminengi. Iphuzu leli lisekelwe yi-US Energy Information Administration (2024) nayithi, igezi esetjenziswa endlini imamandla nanyana umlilo wesibili ngombana ikhiqhizwe ngokutjhugulula imithombo yokuthoma yamandla nanyana yomlilo efaka hlangana amalahle, umsebe yelanga nanyana amandla welangana nomoya ukuze ibe yigezi le esikghona ukuyisebenzisa. Baragele phambili, be-US Energy Information Adminstartion (2024)&lt;ref name=&quot;:2&quot; /&gt; bathi, umthombo wokuthoma wegezi kumlilo nanyana amandla asetjenziswa ngokubuyelelwa nasetjenziswa ngokungabuyelelwa. Esohlokwaneni esilandelako sizokutjheja imisebenzi yegezi.

=== Imisebenzi yegezi ===
Igezi idlala indima ekulu tle eempilweni zethu njengoba sazi ukuthi siphila esikhathi sethekhnoloji nesoburhatjharhatjha besine. Igezi isebenzi ukunikela amandla nomlilo eenthuthini, izinto zokupheka, izinto zokufunda njengemitjhiningqondo nethungelwano, ukukhulisa iintjalo nefuyo (Wikipedia 2024)&lt;ref name=&quot;:1&quot; /&gt;. Ngakho-ke, igezi isekabeni yipilo yethu begodu abanye abantu bangabhalelwa kuphila ngaphande kwayo njengombana vane kube budisi khulu nakunokuqintelwa kwegezi nanyana ukutlhayela kwegezi.

=== Isiphetho ===
Igezi ngenye yezinto eziqakathekileko kodwana ebudisi tle ukuyihlathulula nanyana sisebenza ngayo mihla namalanga. Igezi sele idosa phambili ekusirholeni epilweni esiyiphilako ngombana ngaphandle kwayo sele sinobudisi bokungakghoni ezinye zezinto. Nanyana kunjalo, kuqakathekile bonyana siyisebenzise kuhle begodi sizifundise nezinye iindlela zokwenza izinto ngaphandle kwayo.

=== Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>lzqa130dojm9y3s7w0v09nwpz4rvhha</sha1>
    </revision>
  </page>
  <page>
    <title>Iimbaseli</title>
    <ns>0</ns>
    <id>444</id>
    <revision>
      <id>2357</id>
      <timestamp>2025-01-23T12:56:18Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <comment>Created page with &quot;== '''[[Iinthuthi|Iimbaseli]]''' ==  === '''Isingeniso''' === Iimbaseli zimamandla nomlilo osetjenziswa yithekhnoloji ngezinye zezinto ezisekabeni zeempilo zethu namhlanje. Amandla nomlilo la  aqakatheke khulu ngendlela yokuthi abantu sele bangasakghoni ukuphila ngamandla nomlilo la. Esihlokwaneni esilandelako sizokutjheja iimbaseli njengamandla nanyana umlilo lo osinikela ikghanakalo lokusebenzisa ithekhnoloji.  === '''Kuyini iimbaseli?''' === Ngokuya kwe-:en:Fuel|Wik...&quot;</comment>
      <origin>2357</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4372" sha1="h6i80ceifje41z5d55gtkpoeabbjqtu" xml:space="preserve">== '''[[Iinthuthi|Iimbaseli]]''' ==

=== '''Isingeniso''' ===
Iimbaseli zimamandla nomlilo osetjenziswa yithekhnoloji ngezinye zezinto ezisekabeni zeempilo zethu namhlanje. Amandla nomlilo la  aqakatheke khulu ngendlela yokuthi abantu sele bangasakghoni ukuphila ngamandla nomlilo la. Esihlokwaneni esilandelako sizokutjheja iimbaseli njengamandla nanyana umlilo lo osinikela ikghanakalo lokusebenzisa ithekhnoloji.

=== '''Kuyini iimbaseli?''' ===
Ngokuya kwe-[[:en:Fuel|Wikipedia (2024)]]&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. ''Fuel''. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Fuel&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt; iimbaseli ngezinye zezinto ezenzelwe ukuhluzwa nezinto ezithize ukuze kukhiqhizeke amandla nanyana umlilo ngengomfutho wamandla wokusebenza nanyana ukuze kusebetjenziswe okuthile. Amadlala nanyana umlilo okhiqhizwa lokha nakuhluzwa iimbaseli ungatjhugululelwa emandleni nanyana emlilweni [[Iinthuthi|weenthuthi]] njengamandla nanyana umlilo we-enjini (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;; [https://kids.britannica.com/students/article/fuel/274453 Kids Britannica 2024]&lt;ref name=&quot;:1&quot;&gt;Kids Britannica. 2024. ''Fuel''. Litholakala ku:&lt; &lt;nowiki&gt;https://kids.britannica.com/students/article/fuel/274453&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt;). I-Energy Education (2024)&lt;ref name=&quot;:2&quot;&gt;Energy Education. 2024. ''Fuel''. Litholakala ku:&lt; &lt;nowiki&gt;https://energyeducation.ca/encyclopedia/Fuel&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt; isekele i-Wikipedia (2024)&lt;ref name=&quot;:0&quot; /&gt; nayiveza bonyana iimbaseli kuzimbulungimandla nanyana kuzimbulungimlilo lezo ezisetjenziselwa ukunikela ngemisebenzi yamandla nanyana yomlilo efana nowemitjhini, iinthuthi nokukhiqhizwa kwegezi. Kwesinye isikhathi amandla nomlilo akhiqhizwa eembaseleni akaqakathekile ekufudumezeni, ekuphekeni kanye nokwenza imisebenzi yokwakhiwa kwezinto begodu nokuhlanganiswa kwezinto ezitjhisako nanyana zomlilo.

Iimbaseli lezi zisetjenziswa nezinye izinto nanyana imitjhini leyo enekghonakalo lokubulunga amandla nanyana umlilo ukuze ziwukhiqhize bunqopha njengamandla nanyana umlilo wegezi ofaka hlangana amabhetri, amajanaretha (Kids Britannica 2024&lt;ref name=&quot;:1&quot; /&gt;; Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;). Ukuragela phambili, eminye imitjhini enekghonakalo lokubulunga amandla nanyana umlilo begodu uwukhiqize bunqopha njengamandla nanyana umlilo weensimbi efaka hlangana isiphehlimoya, amanzi ngesibulungelwenimanzi, ukukhanjiswa kwamavili nokunye (Wikipedia 2024; Science ABC, 2024&lt;ref&gt;Science ABC. 2024. ''What is the difference between petrol and diesel''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.scienceabc.com/nature/what-is-the-difference-between-petrol-and-diesel.html&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt;). 

=== '''Imihlobo yeembaseli''' ===
[[Isimumathi:Iimbaseli.jpg|thumb|364x364px|Imihlobo yeembaseli]]
Iimbaseli lezi zimihlobo eminengi kodwana imihlobo eqakhatheke khulu mbili khaphela, iimbaseli zobujamo bokuthoma neembaseli zobujamo besibili. Iimbaseli zobujamo bokuthoma zifaka hlangana iimbaseli zenyutliye, iimbaseli zamafutha ahlaza nembaseli zeentjalo ([https://energyeducation.ca/encyclopedia/Fuel Energy Education 2024]&lt;ref name=&quot;:2&quot; /&gt;). Lezi mihlobo yeembaseli yemvelo leyo engakahluzwa nezinye izinto ukuze ibe namandla nanyana nomlilo.

Kodwana, imihlobo yesibili yeembaseli yona ifuna ukuhluzwa nezinye izinto ukuze ikwazi ukukhiqhiza amandla nanyana umlilo, yona imihlobo le [[Iinthuthi|ingakafa idizili, nepetroli]] (Energy Education 2024).Imihlobo yesibili yeembaseli ilula ukusetjenziswa yi-enjini neminye imitjhini njengendlela yokufunyana amandla nanyana umlilo ngendlela emsinya ekungakghonakala ngayo (Energy Education 2024&lt;ref name=&quot;:2&quot; /&gt;).

Imihlobo emibili le etjhiwo ngaphezulu eminengi, nakungasiyo yoke, inemivango yekhabhoni efana nekhabhoni dayokhsayidi (i-Co2) leyo ethi nayikhiqhizwako isetjenziswe ziintjalo ngobunengi ukuze kuphunguleke umonakalo ongenziwa mivango yekhabhoni le (Kids Britannica 2024&lt;ref name=&quot;:1&quot; /&gt;).

=== '''Isiphetho''' ===
Iimbaseli zidlala indima ekulu eempilweni zethu njengombana zisetjenziswa ezintweni ezinengi mihla namalanga. Iimbaseli lezi ziyahlukana ngokuhluzwa kanye nangemisebenzi yazo. Ye-ke, kufuna bonyana sizizwisise kuhle ukuze sizokukghona ukuzisebenzise ngezwisiso elingcono. 

=== '''Umthombolwazi''' ===
&lt;references /&gt;</text>
      <sha1>h6i80ceifje41z5d55gtkpoeabbjqtu</sha1>
    </revision>
    <revision>
      <id>2358</id>
      <parentid>2357</parentid>
      <timestamp>2025-01-23T13:06:28Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <minor />
      <origin>2358</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4373" sha1="kvfsmylx08yunnzy5wyf46q4cygvvem" xml:space="preserve">== '''[[Iinthuthi|Iimbaseli]]''' ==

=== '''Isingeniso''' ===
Iimbaseli zimamandla nomlilo osetjenziswa yithekhnoloji ngezinye zezinto ezisekabeni zeempilo zethu namhlanje. Amandla nomlilo la  aqakatheke khulu ngendlela yokuthi abantu sele bangasakghoni ukuphila ngamandla nomlilo la. Esihlokwaneni esilandelako sizokutjheja iimbaseli njengamandla nanyana umlilo lo osinikela ikghanakalo lokusebenzisa ithekhnoloji.

=== '''Kuyini iimbaseli?''' ===
Ngokuya kwe-[[:en:Fuel|Wikipedia (2024)]]&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. ''Fuel''. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Fuel&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt; iimbaseli ngezinye zezinto ezenzelwe ukuhluzwa nezinto ezithize ukuze kukhiqhizeke amandla nanyana umlilo ngengomfutho wamandla wokusebenza nanyana ukuze kusebetjenziswe okuthile. Amadlala nanyana umlilo okhiqhizwa lokha nakuhluzwa iimbaseli ungatjhugululelwa emandleni nanyana emlilweni [[Iinthuthi|weenthuthi]] njengamandla nanyana umlilo we-enjini (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;; [https://kids.britannica.com/students/article/fuel/274453 Kids Britannica 2024]&lt;ref name=&quot;:1&quot;&gt;Kids Britannica. 2024. ''Fuel''. Litholakala ku:&lt; &lt;nowiki&gt;https://kids.britannica.com/students/article/fuel/274453&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt;). I-Energy Education (2024)&lt;ref name=&quot;:2&quot;&gt;Energy Education. 2024. ''Fuel''. Litholakala ku:&lt; &lt;nowiki&gt;https://energyeducation.ca/encyclopedia/Fuel&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt; isekele i-Wikipedia (2024)&lt;ref name=&quot;:0&quot; /&gt; nayiveza bonyana iimbaseli kuzimbulungimandla nanyana kuzimbulungimlilo lezo ezisetjenziselwa ukunikela ngemisebenzi yamandla nanyana yomlilo efana nowemitjhini, iinthuthi nokukhiqhizwa kwegezi. Kwesinye isikhathi amandla nomlilo akhiqhizwa eembaseleni akaqakathekile ekufudumezeni, ekuphekeni kanye nokwenza imisebenzi yokwakhiwa kwezinto begodu nokuhlanganiswa kwezinto ezitjhisako nanyana zomlilo.

Iimbaseli lezi zisetjenziswa nezinye izinto nanyana imitjhini leyo enekghonakalo lokubulunga amandla nanyana umlilo ukuze ziwukhiqhize bunqopha njengamandla nanyana umlilo wegezi ofaka hlangana amabhetri, amajanaretha (Kids Britannica 2024&lt;ref name=&quot;:1&quot; /&gt;; Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;). Ukuragela phambili, eminye imitjhini enekghonakalo lokubulunga amandla nanyana umlilo begodu uwukhiqize bunqopha njengamandla nanyana umlilo weensimbi efaka hlangana isiphehlimoya, amanzi ngesibulungelwenimanzi, ukukhanjiswa kwamavili nokunye (Wikipedia 2024; Science ABC, 2024&lt;ref&gt;Science ABC. 2024. ''What is the difference between petrol and diesel''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.scienceabc.com/nature/what-is-the-difference-between-petrol-and-diesel.html&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt;). 

=== '''Imihlobo yeembaseli''' ===
[[Isimumathi:Iimbaseli.jpg|thumb|364x364px|Imihlobo yeembaseli]]
Iimbaseli lezi zimihlobo eminengi kodwana imihlobo eqakhatheke khulu mbili khaphela, iimbaseli zobujamo bokuthoma neembaseli zobujamo besibili. Iimbaseli zobujamo bokuthoma zifaka hlangana iimbaseli zenyutliye, iimbaseli zamafutha ahlaza nembaseli zeentjalo ([https://energyeducation.ca/encyclopedia/Fuel Energy Education 2024]&lt;ref name=&quot;:2&quot; /&gt;). Lezi mihlobo yeembaseli yemvelo leyo engakahluzwa nezinye izinto ukuze ibe namandla nanyana nomlilo.

Kodwana, imihlobo yesibili yeembaseli yona ifuna ukuhluzwa nezinye izinto ukuze ikwazi ukukhiqhiza amandla nanyana umlilo, yona imihlobo le [[Iinthuthi|ingakafa idizili, nepetroli]] (Energy Education 2024).Imihlobo yesibili yeembaseli ilula ukusetjenziswa yi-enjini neminye imitjhini njengendlela yokufunyana amandla nanyana umlilo ngendlela emsinya ekungakghonakala ngayo (Energy Education 2024&lt;ref name=&quot;:2&quot; /&gt;).

Imihlobo emibili le etjhiwo ngaphezulu eminengi, nakungasiyo yoke, inemivango yekhabhoni efana nekhabhoni dayokhsayidi (i-Co2) leyo ethi nayikhiqhizwako isetjenziswe ziintjalo ngobunengi ukuze kuphunguleke umonakalo ongenziwa mivango yekhabhoni le (Kids Britannica 2024&lt;ref name=&quot;:1&quot; /&gt;).

=== '''Isiphetho.''' ===
Iimbaseli zidlala indima ekulu eempilweni zethu njengombana zisetjenziswa ezintweni ezinengi mihla namalanga. Iimbaseli lezi ziyahlukana ngokuhluzwa kanye nangemisebenzi yazo. Ye-ke, kufuna bonyana sizizwisise kuhle ukuze sizokukghona ukuzisebenzise ngezwisiso elingcono. 

=== '''Umthombolwazi''' ===
&lt;references /&gt;</text>
      <sha1>kvfsmylx08yunnzy5wyf46q4cygvvem</sha1>
    </revision>
    <revision>
      <id>2360</id>
      <parentid>2358</parentid>
      <timestamp>2025-01-23T13:13:47Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <minor />
      <origin>2360</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4396" sha1="aj3jmg5tom45mwbq7d9bwu0gz9t0o6m" xml:space="preserve">== '''[[Iinthuthi|Iimbaseli]]''' ==

=== '''Isingeniso''' ===
[[Ipetroli nedizili.|Iimbaseli]] zimamandla nomlilo osetjenziswa yithekhnoloji ngezinye zezinto ezisekabeni zeempilo zethu namhlanje. Amandla nomlilo la  aqakatheke khulu ngendlela yokuthi abantu sele bangasakghoni ukuphila ngamandla nomlilo la. Esihlokwaneni esilandelako sizokutjheja iimbaseli njengamandla nanyana umlilo lo osinikela ikghanakalo lokusebenzisa ithekhnoloji.

=== '''Kuyini iimbaseli?''' ===
Ngokuya kwe-[[:en:Fuel|Wikipedia (2024)]]&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. ''Fuel''. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Fuel&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt; iimbaseli ngezinye zezinto ezenzelwe ukuhluzwa nezinto ezithize ukuze kukhiqhizeke amandla nanyana umlilo ngengomfutho wamandla wokusebenza nanyana ukuze kusebetjenziswe okuthile. Amadlala nanyana umlilo okhiqhizwa lokha nakuhluzwa iimbaseli ungatjhugululelwa emandleni nanyana emlilweni [[Iinthuthi|weenthuthi]] njengamandla nanyana umlilo we-enjini (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;; [https://kids.britannica.com/students/article/fuel/274453 Kids Britannica 2024]&lt;ref name=&quot;:1&quot;&gt;Kids Britannica. 2024. ''Fuel''. Litholakala ku:&lt; &lt;nowiki&gt;https://kids.britannica.com/students/article/fuel/274453&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt;). I-Energy Education (2024)&lt;ref name=&quot;:2&quot;&gt;Energy Education. 2024. ''Fuel''. Litholakala ku:&lt; &lt;nowiki&gt;https://energyeducation.ca/encyclopedia/Fuel&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt; isekele i-Wikipedia (2024)&lt;ref name=&quot;:0&quot; /&gt; nayiveza bonyana iimbaseli kuzimbulungimandla nanyana kuzimbulungimlilo lezo ezisetjenziselwa ukunikela ngemisebenzi yamandla nanyana yomlilo efana nowemitjhini, iinthuthi nokukhiqhizwa kwegezi. Kwesinye isikhathi amandla nomlilo akhiqhizwa eembaseleni akaqakathekile ekufudumezeni, ekuphekeni kanye nokwenza imisebenzi yokwakhiwa kwezinto begodu nokuhlanganiswa kwezinto ezitjhisako nanyana zomlilo.

Iimbaseli lezi zisetjenziswa nezinye izinto nanyana imitjhini leyo enekghonakalo lokubulunga amandla nanyana umlilo ukuze ziwukhiqhize bunqopha njengamandla nanyana umlilo wegezi ofaka hlangana amabhetri, amajanaretha (Kids Britannica 2024&lt;ref name=&quot;:1&quot; /&gt;; Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;). Ukuragela phambili, eminye imitjhini enekghonakalo lokubulunga amandla nanyana umlilo begodu uwukhiqize bunqopha njengamandla nanyana umlilo weensimbi efaka hlangana isiphehlimoya, amanzi ngesibulungelwenimanzi, ukukhanjiswa kwamavili nokunye (Wikipedia 2024; Science ABC, 2024&lt;ref&gt;Science ABC. 2024. ''What is the difference between petrol and diesel''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.scienceabc.com/nature/what-is-the-difference-between-petrol-and-diesel.html&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt;). 

=== '''Imihlobo yeembaseli''' ===
[[Isimumathi:Iimbaseli.jpg|thumb|364x364px|Imihlobo yeembaseli]]
Iimbaseli lezi zimihlobo eminengi kodwana imihlobo eqakhatheke khulu mbili khaphela, iimbaseli zobujamo bokuthoma neembaseli zobujamo besibili. Iimbaseli zobujamo bokuthoma zifaka hlangana iimbaseli zenyutliye, iimbaseli zamafutha ahlaza nembaseli zeentjalo ([https://energyeducation.ca/encyclopedia/Fuel Energy Education 2024]&lt;ref name=&quot;:2&quot; /&gt;). Lezi mihlobo yeembaseli yemvelo leyo engakahluzwa nezinye izinto ukuze ibe namandla nanyana nomlilo.

Kodwana, imihlobo yesibili yeembaseli yona ifuna ukuhluzwa nezinye izinto ukuze ikwazi ukukhiqhiza amandla nanyana umlilo, yona imihlobo le [[Iinthuthi|ingakafa idizili, nepetroli]] (Energy Education 2024).Imihlobo yesibili yeembaseli ilula ukusetjenziswa yi-enjini neminye imitjhini njengendlela yokufunyana amandla nanyana umlilo ngendlela emsinya ekungakghonakala ngayo (Energy Education 2024&lt;ref name=&quot;:2&quot; /&gt;).

Imihlobo emibili le etjhiwo ngaphezulu eminengi, nakungasiyo yoke, inemivango yekhabhoni efana nekhabhoni dayokhsayidi (i-Co2) leyo ethi nayikhiqhizwako isetjenziswe ziintjalo ngobunengi ukuze kuphunguleke umonakalo ongenziwa mivango yekhabhoni le (Kids Britannica 2024&lt;ref name=&quot;:1&quot; /&gt;).

=== '''Isiphetho.''' ===
Iimbaseli zidlala indima ekulu eempilweni zethu njengombana zisetjenziswa ezintweni ezinengi mihla namalanga. Iimbaseli lezi ziyahlukana ngokuhluzwa kanye nangemisebenzi yazo. Ye-ke, kufuna bonyana sizizwisise kuhle ukuze sizokukghona ukuzisebenzise ngezwisiso elingcono. 

=== '''Umthombolwazi''' ===
&lt;references /&gt;</text>
      <sha1>aj3jmg5tom45mwbq7d9bwu0gz9t0o6m</sha1>
    </revision>
    <revision>
      <id>3032</id>
      <parentid>2360</parentid>
      <timestamp>2025-06-06T20:36:35Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>efrghtyjhyjtrg</comment>
      <origin>3032</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4492" sha1="02i47wrawsbxztk6ubxlr8cvwtlhhep" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.'''

== '''[[A Minecraft Movie|Iimbaseli]]''' ==

=== '''Isingeniso''' ===
[[Ipetroli nedizili.|Iimbaseli]] zimamandla nomlilo osetjenziswa yithekhnoloji ngezinye zezinto ezisekabeni zeempilo zethu namhlanje. Amandla nomlilo la  aqakatheke khulu ngendlela yokuthi abantu sele bangasakghoni ukuphila ngamandla nomlilo la. Esihlokwaneni esilandelako sizokutjheja iimbaseli njengamandla nanyana umlilo lo osinikela ikghanakalo lokusebenzisa ithekhnoloji.

=== '''Kuyini iimbaseli?''' ===
Ngokuya kwe-[[:en:Fuel|Wikipedia (2024)]]&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. ''Fuel''. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Fuel&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt; iimbaseli ngezinye zezinto ezenzelwe ukuhluzwa nezinto ezithize ukuze kukhiqhizeke amandla nanyana umlilo ngengomfutho wamandla wokusebenza nanyana ukuze kusebetjenziswe okuthile. Amadlala nanyana umlilo okhiqhizwa lokha nakuhluzwa iimbaseli ungatjhugululelwa emandleni nanyana emlilweni [[Iinthuthi|weenthuthi]] njengamandla nanyana umlilo we-enjini (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;; [https://kids.britannica.com/students/article/fuel/274453 Kids Britannica 2024]&lt;ref name=&quot;:1&quot;&gt;Kids Britannica. 2024. ''Fuel''. Litholakala ku:&lt; &lt;nowiki&gt;https://kids.britannica.com/students/article/fuel/274453&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt;). I-Energy Education (2024)&lt;ref name=&quot;:2&quot;&gt;Energy Education. 2024. ''Fuel''. Litholakala ku:&lt; &lt;nowiki&gt;https://energyeducation.ca/encyclopedia/Fuel&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt; isekele i-Wikipedia (2024)&lt;ref name=&quot;:0&quot; /&gt; nayiveza bonyana iimbaseli kuzimbulungimandla nanyana kuzimbulungimlilo lezo ezisetjenziselwa ukunikela ngemisebenzi yamandla nanyana yomlilo efana nowemitjhini, iinthuthi nokukhiqhizwa kwegezi. Kwesinye isikhathi amandla nomlilo akhiqhizwa eembaseleni akaqakathekile ekufudumezeni, ekuphekeni kanye nokwenza imisebenzi yokwakhiwa kwezinto begodu nokuhlanganiswa kwezinto ezitjhisako nanyana zomlilo.

Iimbaseli lezi zisetjenziswa nezinye izinto nanyana imitjhini leyo enekghonakalo lokubulunga amandla nanyana umlilo ukuze ziwukhiqhize bunqopha njengamandla nanyana umlilo wegezi ofaka hlangana amabhetri, amajanaretha (Kids Britannica 2024&lt;ref name=&quot;:1&quot; /&gt;; Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;). Ukuragela phambili, eminye imitjhini enekghonakalo lokubulunga amandla nanyana umlilo begodu uwukhiqize bunqopha njengamandla nanyana umlilo weensimbi efaka hlangana isiphehlimoya, amanzi ngesibulungelwenimanzi, ukukhanjiswa kwamavili nokunye (Wikipedia 2024; Science ABC, 2024&lt;ref&gt;Science ABC. 2024. ''What is the difference between petrol and diesel''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.scienceabc.com/nature/what-is-the-difference-between-petrol-and-diesel.html&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt;). 

=== '''Imihlobo yeembaseli''' ===
[[Isimumathi:Iimbaseli.jpg|thumb|364x364px|Imihlobo yeembaseli]]
Iimbaseli lezi zimihlobo eminengi kodwana imihlobo eqakhatheke khulu mbili khaphela, iimbaseli zobujamo bokuthoma neembaseli zobujamo besibili. Iimbaseli zobujamo bokuthoma zifaka hlangana iimbaseli zenyutliye, iimbaseli zamafutha ahlaza nembaseli zeentjalo ([https://energyeducation.ca/encyclopedia/Fuel Energy Education 2024]&lt;ref name=&quot;:2&quot; /&gt;). Lezi mihlobo yeembaseli yemvelo leyo engakahluzwa nezinye izinto ukuze ibe namandla nanyana nomlilo.

Kodwana, imihlobo yesibili yeembaseli yona ifuna ukuhluzwa nezinye izinto ukuze ikwazi ukukhiqhiza amandla nanyana umlilo, yona imihlobo le [[Iinthuthi|ingakafa idizili, nepetroli]] (Energy Education 2024).Imihlobo yesibili yeembaseli ilula ukusetjenziswa yi-enjini neminye imitjhini njengendlela yokufunyana amandla nanyana umlilo ngendlela emsinya ekungakghonakala ngayo (Energy Education 2024&lt;ref name=&quot;:2&quot; /&gt;).

Imihlobo emibili le etjhiwo ngaphezulu eminengi, nakungasiyo yoke, inemivango yekhabhoni efana nekhabhoni dayokhsayidi (i-Co2) leyo ethi nayikhiqhizwako isetjenziswe ziintjalo ngobunengi ukuze kuphunguleke umonakalo ongenziwa mivango yekhabhoni le (Kids Britannica 2024&lt;ref name=&quot;:1&quot; /&gt;).

=== '''Isiphetho.''' ===
Iimbaseli zidlala indima ekulu eempilweni zethu njengombana zisetjenziswa ezintweni ezinengi mihla namalanga. Iimbaseli lezi ziyahlukana ngokuhluzwa kanye nangemisebenzi yazo. Ye-ke, kufuna bonyana sizizwisise kuhle ukuze sizokukghona ukuzisebenzise ngezwisiso elingcono. 

=== '''Umthombolwazi''' ===
&lt;references /&gt;</text>
      <sha1>02i47wrawsbxztk6ubxlr8cvwtlhhep</sha1>
    </revision>
    <revision>
      <id>3046</id>
      <parentid>3032</parentid>
      <timestamp>2025-06-07T03:05:22Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Owaziwako|Owaziwako]]</comment>
      <origin>2360</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4396" sha1="aj3jmg5tom45mwbq7d9bwu0gz9t0o6m" xml:space="preserve">== '''[[Iinthuthi|Iimbaseli]]''' ==

=== '''Isingeniso''' ===
[[Ipetroli nedizili.|Iimbaseli]] zimamandla nomlilo osetjenziswa yithekhnoloji ngezinye zezinto ezisekabeni zeempilo zethu namhlanje. Amandla nomlilo la  aqakatheke khulu ngendlela yokuthi abantu sele bangasakghoni ukuphila ngamandla nomlilo la. Esihlokwaneni esilandelako sizokutjheja iimbaseli njengamandla nanyana umlilo lo osinikela ikghanakalo lokusebenzisa ithekhnoloji.

=== '''Kuyini iimbaseli?''' ===
Ngokuya kwe-[[:en:Fuel|Wikipedia (2024)]]&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. ''Fuel''. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Fuel&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt; iimbaseli ngezinye zezinto ezenzelwe ukuhluzwa nezinto ezithize ukuze kukhiqhizeke amandla nanyana umlilo ngengomfutho wamandla wokusebenza nanyana ukuze kusebetjenziswe okuthile. Amadlala nanyana umlilo okhiqhizwa lokha nakuhluzwa iimbaseli ungatjhugululelwa emandleni nanyana emlilweni [[Iinthuthi|weenthuthi]] njengamandla nanyana umlilo we-enjini (Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;; [https://kids.britannica.com/students/article/fuel/274453 Kids Britannica 2024]&lt;ref name=&quot;:1&quot;&gt;Kids Britannica. 2024. ''Fuel''. Litholakala ku:&lt; &lt;nowiki&gt;https://kids.britannica.com/students/article/fuel/274453&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt;). I-Energy Education (2024)&lt;ref name=&quot;:2&quot;&gt;Energy Education. 2024. ''Fuel''. Litholakala ku:&lt; &lt;nowiki&gt;https://energyeducation.ca/encyclopedia/Fuel&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt; isekele i-Wikipedia (2024)&lt;ref name=&quot;:0&quot; /&gt; nayiveza bonyana iimbaseli kuzimbulungimandla nanyana kuzimbulungimlilo lezo ezisetjenziselwa ukunikela ngemisebenzi yamandla nanyana yomlilo efana nowemitjhini, iinthuthi nokukhiqhizwa kwegezi. Kwesinye isikhathi amandla nomlilo akhiqhizwa eembaseleni akaqakathekile ekufudumezeni, ekuphekeni kanye nokwenza imisebenzi yokwakhiwa kwezinto begodu nokuhlanganiswa kwezinto ezitjhisako nanyana zomlilo.

Iimbaseli lezi zisetjenziswa nezinye izinto nanyana imitjhini leyo enekghonakalo lokubulunga amandla nanyana umlilo ukuze ziwukhiqhize bunqopha njengamandla nanyana umlilo wegezi ofaka hlangana amabhetri, amajanaretha (Kids Britannica 2024&lt;ref name=&quot;:1&quot; /&gt;; Wikipedia 2024&lt;ref name=&quot;:0&quot; /&gt;). Ukuragela phambili, eminye imitjhini enekghonakalo lokubulunga amandla nanyana umlilo begodu uwukhiqize bunqopha njengamandla nanyana umlilo weensimbi efaka hlangana isiphehlimoya, amanzi ngesibulungelwenimanzi, ukukhanjiswa kwamavili nokunye (Wikipedia 2024; Science ABC, 2024&lt;ref&gt;Science ABC. 2024. ''What is the difference between petrol and diesel''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.scienceabc.com/nature/what-is-the-difference-between-petrol-and-diesel.html&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt;). 

=== '''Imihlobo yeembaseli''' ===
[[Isimumathi:Iimbaseli.jpg|thumb|364x364px|Imihlobo yeembaseli]]
Iimbaseli lezi zimihlobo eminengi kodwana imihlobo eqakhatheke khulu mbili khaphela, iimbaseli zobujamo bokuthoma neembaseli zobujamo besibili. Iimbaseli zobujamo bokuthoma zifaka hlangana iimbaseli zenyutliye, iimbaseli zamafutha ahlaza nembaseli zeentjalo ([https://energyeducation.ca/encyclopedia/Fuel Energy Education 2024]&lt;ref name=&quot;:2&quot; /&gt;). Lezi mihlobo yeembaseli yemvelo leyo engakahluzwa nezinye izinto ukuze ibe namandla nanyana nomlilo.

Kodwana, imihlobo yesibili yeembaseli yona ifuna ukuhluzwa nezinye izinto ukuze ikwazi ukukhiqhiza amandla nanyana umlilo, yona imihlobo le [[Iinthuthi|ingakafa idizili, nepetroli]] (Energy Education 2024).Imihlobo yesibili yeembaseli ilula ukusetjenziswa yi-enjini neminye imitjhini njengendlela yokufunyana amandla nanyana umlilo ngendlela emsinya ekungakghonakala ngayo (Energy Education 2024&lt;ref name=&quot;:2&quot; /&gt;).

Imihlobo emibili le etjhiwo ngaphezulu eminengi, nakungasiyo yoke, inemivango yekhabhoni efana nekhabhoni dayokhsayidi (i-Co2) leyo ethi nayikhiqhizwako isetjenziswe ziintjalo ngobunengi ukuze kuphunguleke umonakalo ongenziwa mivango yekhabhoni le (Kids Britannica 2024&lt;ref name=&quot;:1&quot; /&gt;).

=== '''Isiphetho.''' ===
Iimbaseli zidlala indima ekulu eempilweni zethu njengombana zisetjenziswa ezintweni ezinengi mihla namalanga. Iimbaseli lezi ziyahlukana ngokuhluzwa kanye nangemisebenzi yazo. Ye-ke, kufuna bonyana sizizwisise kuhle ukuze sizokukghona ukuzisebenzise ngezwisiso elingcono. 

=== '''Umthombolwazi''' ===
&lt;references /&gt;</text>
      <sha1>aj3jmg5tom45mwbq7d9bwu0gz9t0o6m</sha1>
    </revision>
  </page>
  <page>
    <title>Ipetroli nedizili.</title>
    <ns>0</ns>
    <id>445</id>
    <revision>
      <id>2359</id>
      <timestamp>2025-01-23T13:11:44Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <comment>Created page with &quot;== '''[[Iimbaseli|Ipetroli nedizili]].''' ==  === '''Isingeniso''' === Ipetroli nedizili kuziinkhiqizi zamandla nanyana umlilo lezo ezidlala indima ekulu ngehlangothini leenthuthi, ukupheka kanye nekusebenziseni imitjhini. Nanyana kunjalo, ipetroli nedizili kuziinkhiqizi zamandla nanyana umlilo ongafaniko begodu kwesinye isikhathi kunala zisetjenziswa ngokuhlukileko nanyana imitjhini nezinto ezizisebenzisako ziyahluka. Esihlokwaneni esilandelako sizokutjheja bonyana kuyi...&quot;</comment>
      <origin>2359</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3718" sha1="johdvp7ri31fzenx4x7dh8zxcsxfzco" xml:space="preserve">== '''[[Iimbaseli|Ipetroli nedizili]].''' ==

=== '''Isingeniso''' ===
Ipetroli nedizili kuziinkhiqizi zamandla nanyana umlilo lezo ezidlala indima ekulu ngehlangothini leenthuthi, ukupheka kanye nekusebenziseni imitjhini. Nanyana kunjalo, ipetroli nedizili kuziinkhiqizi zamandla nanyana umlilo ongafaniko begodu kwesinye isikhathi kunala zisetjenziswa ngokuhlukileko nanyana imitjhini nezinto ezizisebenzisako ziyahluka. Esihlokwaneni esilandelako sizokutjheja bonyana kuyini ipetroli nedizili. 

=== '''Kuyini ipetroli nedizili na?''' ===
Ipetroli nedizili [[Iimbaseli|kuziimbaseli]] zobujamo besibili nanyana bomhlobo wobujamo besibili loyo  okhuqhiza amandla nanyana umlilo ngokutjhiswa nanyana ngokusetjenziswa ([https://www.acea.auto/fact/differences-between-diesel-and-petrol/ Acea Auto 2024]&lt;ref name=&quot;:0&quot;&gt;Acea Auto. 2024. ''Differences between diesel and Petrol''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.acea.auto/fact/differences-between-diesel-and-petrol/&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt;). Ukungezelela, ipetroli nedizili ziiimbaseli lezo ezihluzwe e-oyilini ehlaza. Nanyana kunjalo, kufanele siyelela bonyana azihluzwa kokufana.

Ipetroli ihluzwa e-oyilini ehlaza lula njengombana ihluzwa ezingeni lokutjhisa elingaba kulangabi lama-40 ukuya kuma-250 ([https://bulkfuel.com.au/news/whats-the-difference-between-diesel-and-petrol Bulkfuel 202]&lt;ref name=&quot;:1&quot;&gt;Bulk Fuel. 2024''. Whats the difference between diesel and Petrol''. Litholakala ku:&lt; &lt;nowiki&gt;https://bulkfuel.com.au/news/whats-the-difference-between-diesel-and-petrol&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024]. &lt;/ref&gt;[https://bulkfuel.com.au/news/whats-the-difference-between-diesel-and-petrol 4]).nanyana kunjalo, ipetroli ineensilaphazo zebhudululo zezinga eliphezulu ukudlula idizili (Acea Auto 2024&lt;ref name=&quot;:0&quot; /&gt;). Lokhu kutjho bonyana, lokha ipetroli nayisetjenziswa mtjhini nanyana sithuthi esithize ikhiqiza umvango wekhabhoni omnengi ukudlula idizili. 

Ngakwelinye ihlangothi idizili yona ihlizwa e-oyilini ehlaza elangabeni lezinga lama-250 ukuya phezulu(Bulkfuel 2024&lt;ref name=&quot;:1&quot; /&gt;). Ukungezelela, idizili ikhiqiza iinsilaphazo zebhodoluko ezincani nakumadaniswa nepetroli (Bulk Fuel 2024&lt;ref name=&quot;:1&quot; /&gt;). Ngamanye amagama, idizili lokha nayisetjenziswako mtjhini nanyana sithuthi esithize ikhiqiza umvango wekhabhoni omncani kunalo okhiqizwa yipetroli. Ukuragela phambili, idizili ikhiqiza amandla nanyana umtjhiso omnengi begodu ihlala isikhathi nanyana isebenziseka isikhathi eside nayimadaniswa nepetroli (Acea Auto 2024&lt;ref name=&quot;:0&quot; /&gt;; [https://energyeducation.ca/encyclopedia/Fuel Energy Education 2024]&lt;ref&gt;Energy Education. 2024. ''Fuel''. Litholakala ku:&lt; &lt;nowiki&gt;https://energyeducation.ca/encyclopedia/Fuel&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt;).

Kokugcina umtjhini nanyana isithuthi esisebenzisa ipetroli asisebenzisi idizili ([[:en:Fuel|Wikipedia 2024]]&lt;ref name=&quot;:2&quot;&gt;Wikipedia. 2024. ''Fuel.'' Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Fuel&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt;). Ngokufanako, umtjhini nanyana isithuthi esisebenzisa idizili naso asisebenzisi ipetroli (Wikipedia 2024&lt;ref name=&quot;:2&quot; /&gt;). Lokhu kusibikela bonyana, izinto ezinengi azikwazi ukusebenzisa ipetroli nedizili ngesikhathi sinye nanyana kokubili, kufanele zikhethe kunye.

=== '''Isiphetho''' ===
Ipetroli nedizili kuziimbaseli lezo ezisetjenziswa khulu njengomthombo wokukhiqiza amandla nanyana umlilo ephasini. Nanyana kunjalo, kufanele siyelele bonyana azifani ngokwenziwa nokusetjenziswa begodu kuzizinto ekufanele zisetjenziswe ngomnanko omkhulu njengoba zitjha nanyana zibanga umlilo msinyana. 

=== '''Umthombolwazi''' ===
&lt;references /&gt;</text>
      <sha1>johdvp7ri31fzenx4x7dh8zxcsxfzco</sha1>
    </revision>
    <revision>
      <id>2996</id>
      <parentid>2359</parentid>
      <timestamp>2025-06-06T20:17:19Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>ere4gt5h76</comment>
      <origin>2996</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3814" sha1="hj4juszjpt8qhy6zdlv7vjwtl56rnth" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.'''

== '''[[A Minecraft Movie|Ipetroli nedizili]].''' ==

=== '''Isingeniso''' ===
Ipetroli nedizili kuziinkhiqizi zamandla nanyana umlilo lezo ezidlala indima ekulu ngehlangothini leenthuthi, ukupheka kanye nekusebenziseni imitjhini. Nanyana kunjalo, ipetroli nedizili kuziinkhiqizi zamandla nanyana umlilo ongafaniko begodu kwesinye isikhathi kunala zisetjenziswa ngokuhlukileko nanyana imitjhini nezinto ezizisebenzisako ziyahluka. Esihlokwaneni esilandelako sizokutjheja bonyana kuyini ipetroli nedizili. 

=== '''Kuyini ipetroli nedizili na?''' ===
Ipetroli nedizili [[Iimbaseli|kuziimbaseli]] zobujamo besibili nanyana bomhlobo wobujamo besibili loyo  okhuqhiza amandla nanyana umlilo ngokutjhiswa nanyana ngokusetjenziswa ([https://www.acea.auto/fact/differences-between-diesel-and-petrol/ Acea Auto 2024]&lt;ref name=&quot;:0&quot;&gt;Acea Auto. 2024. ''Differences between diesel and Petrol''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.acea.auto/fact/differences-between-diesel-and-petrol/&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt;). Ukungezelela, ipetroli nedizili ziiimbaseli lezo ezihluzwe e-oyilini ehlaza. Nanyana kunjalo, kufanele siyelela bonyana azihluzwa kokufana.

Ipetroli ihluzwa e-oyilini ehlaza lula njengombana ihluzwa ezingeni lokutjhisa elingaba kulangabi lama-40 ukuya kuma-250 ([https://bulkfuel.com.au/news/whats-the-difference-between-diesel-and-petrol Bulkfuel 202]&lt;ref name=&quot;:1&quot;&gt;Bulk Fuel. 2024''. Whats the difference between diesel and Petrol''. Litholakala ku:&lt; &lt;nowiki&gt;https://bulkfuel.com.au/news/whats-the-difference-between-diesel-and-petrol&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024]. &lt;/ref&gt;[https://bulkfuel.com.au/news/whats-the-difference-between-diesel-and-petrol 4]).nanyana kunjalo, ipetroli ineensilaphazo zebhudululo zezinga eliphezulu ukudlula idizili (Acea Auto 2024&lt;ref name=&quot;:0&quot; /&gt;). Lokhu kutjho bonyana, lokha ipetroli nayisetjenziswa mtjhini nanyana sithuthi esithize ikhiqiza umvango wekhabhoni omnengi ukudlula idizili. 

Ngakwelinye ihlangothi idizili yona ihlizwa e-oyilini ehlaza elangabeni lezinga lama-250 ukuya phezulu(Bulkfuel 2024&lt;ref name=&quot;:1&quot; /&gt;). Ukungezelela, idizili ikhiqiza iinsilaphazo zebhodoluko ezincani nakumadaniswa nepetroli (Bulk Fuel 2024&lt;ref name=&quot;:1&quot; /&gt;). Ngamanye amagama, idizili lokha nayisetjenziswako mtjhini nanyana sithuthi esithize ikhiqiza umvango wekhabhoni omncani kunalo okhiqizwa yipetroli. Ukuragela phambili, idizili ikhiqiza amandla nanyana umtjhiso omnengi begodu ihlala isikhathi nanyana isebenziseka isikhathi eside nayimadaniswa nepetroli (Acea Auto 2024&lt;ref name=&quot;:0&quot; /&gt;; [https://energyeducation.ca/encyclopedia/Fuel Energy Education 2024]&lt;ref&gt;Energy Education. 2024. ''Fuel''. Litholakala ku:&lt; &lt;nowiki&gt;https://energyeducation.ca/encyclopedia/Fuel&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt;).

Kokugcina umtjhini nanyana isithuthi esisebenzisa ipetroli asisebenzisi idizili ([[:en:Fuel|Wikipedia 2024]]&lt;ref name=&quot;:2&quot;&gt;Wikipedia. 2024. ''Fuel.'' Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Fuel&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt;). Ngokufanako, umtjhini nanyana isithuthi esisebenzisa idizili naso asisebenzisi ipetroli (Wikipedia 2024&lt;ref name=&quot;:2&quot; /&gt;). Lokhu kusibikela bonyana, izinto ezinengi azikwazi ukusebenzisa ipetroli nedizili ngesikhathi sinye nanyana kokubili, kufanele zikhethe kunye.

=== '''Isiphetho''' ===
Ipetroli nedizili kuziimbaseli lezo ezisetjenziswa khulu njengomthombo wokukhiqiza amandla nanyana umlilo ephasini. Nanyana kunjalo, kufanele siyelele bonyana azifani ngokwenziwa nokusetjenziswa begodu kuzizinto ekufanele zisetjenziswe ngomnanko omkhulu njengoba zitjha nanyana zibanga umlilo msinyana. 

=== '''Umthombolwazi''' ===
&lt;references /&gt;</text>
      <sha1>hj4juszjpt8qhy6zdlv7vjwtl56rnth</sha1>
    </revision>
    <revision>
      <id>3067</id>
      <parentid>2996</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Owaziwako|Owaziwako]]</comment>
      <origin>2359</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3718" sha1="johdvp7ri31fzenx4x7dh8zxcsxfzco" xml:space="preserve">== '''[[Iimbaseli|Ipetroli nedizili]].''' ==

=== '''Isingeniso''' ===
Ipetroli nedizili kuziinkhiqizi zamandla nanyana umlilo lezo ezidlala indima ekulu ngehlangothini leenthuthi, ukupheka kanye nekusebenziseni imitjhini. Nanyana kunjalo, ipetroli nedizili kuziinkhiqizi zamandla nanyana umlilo ongafaniko begodu kwesinye isikhathi kunala zisetjenziswa ngokuhlukileko nanyana imitjhini nezinto ezizisebenzisako ziyahluka. Esihlokwaneni esilandelako sizokutjheja bonyana kuyini ipetroli nedizili. 

=== '''Kuyini ipetroli nedizili na?''' ===
Ipetroli nedizili [[Iimbaseli|kuziimbaseli]] zobujamo besibili nanyana bomhlobo wobujamo besibili loyo  okhuqhiza amandla nanyana umlilo ngokutjhiswa nanyana ngokusetjenziswa ([https://www.acea.auto/fact/differences-between-diesel-and-petrol/ Acea Auto 2024]&lt;ref name=&quot;:0&quot;&gt;Acea Auto. 2024. ''Differences between diesel and Petrol''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.acea.auto/fact/differences-between-diesel-and-petrol/&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt;). Ukungezelela, ipetroli nedizili ziiimbaseli lezo ezihluzwe e-oyilini ehlaza. Nanyana kunjalo, kufanele siyelela bonyana azihluzwa kokufana.

Ipetroli ihluzwa e-oyilini ehlaza lula njengombana ihluzwa ezingeni lokutjhisa elingaba kulangabi lama-40 ukuya kuma-250 ([https://bulkfuel.com.au/news/whats-the-difference-between-diesel-and-petrol Bulkfuel 202]&lt;ref name=&quot;:1&quot;&gt;Bulk Fuel. 2024''. Whats the difference between diesel and Petrol''. Litholakala ku:&lt; &lt;nowiki&gt;https://bulkfuel.com.au/news/whats-the-difference-between-diesel-and-petrol&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024]. &lt;/ref&gt;[https://bulkfuel.com.au/news/whats-the-difference-between-diesel-and-petrol 4]).nanyana kunjalo, ipetroli ineensilaphazo zebhudululo zezinga eliphezulu ukudlula idizili (Acea Auto 2024&lt;ref name=&quot;:0&quot; /&gt;). Lokhu kutjho bonyana, lokha ipetroli nayisetjenziswa mtjhini nanyana sithuthi esithize ikhiqiza umvango wekhabhoni omnengi ukudlula idizili. 

Ngakwelinye ihlangothi idizili yona ihlizwa e-oyilini ehlaza elangabeni lezinga lama-250 ukuya phezulu(Bulkfuel 2024&lt;ref name=&quot;:1&quot; /&gt;). Ukungezelela, idizili ikhiqiza iinsilaphazo zebhodoluko ezincani nakumadaniswa nepetroli (Bulk Fuel 2024&lt;ref name=&quot;:1&quot; /&gt;). Ngamanye amagama, idizili lokha nayisetjenziswako mtjhini nanyana sithuthi esithize ikhiqiza umvango wekhabhoni omncani kunalo okhiqizwa yipetroli. Ukuragela phambili, idizili ikhiqiza amandla nanyana umtjhiso omnengi begodu ihlala isikhathi nanyana isebenziseka isikhathi eside nayimadaniswa nepetroli (Acea Auto 2024&lt;ref name=&quot;:0&quot; /&gt;; [https://energyeducation.ca/encyclopedia/Fuel Energy Education 2024]&lt;ref&gt;Energy Education. 2024. ''Fuel''. Litholakala ku:&lt; &lt;nowiki&gt;https://energyeducation.ca/encyclopedia/Fuel&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt;).

Kokugcina umtjhini nanyana isithuthi esisebenzisa ipetroli asisebenzisi idizili ([[:en:Fuel|Wikipedia 2024]]&lt;ref name=&quot;:2&quot;&gt;Wikipedia. 2024. ''Fuel.'' Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Fuel&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt;). Ngokufanako, umtjhini nanyana isithuthi esisebenzisa idizili naso asisebenzisi ipetroli (Wikipedia 2024&lt;ref name=&quot;:2&quot; /&gt;). Lokhu kusibikela bonyana, izinto ezinengi azikwazi ukusebenzisa ipetroli nedizili ngesikhathi sinye nanyana kokubili, kufanele zikhethe kunye.

=== '''Isiphetho''' ===
Ipetroli nedizili kuziimbaseli lezo ezisetjenziswa khulu njengomthombo wokukhiqiza amandla nanyana umlilo ephasini. Nanyana kunjalo, kufanele siyelele bonyana azifani ngokwenziwa nokusetjenziswa begodu kuzizinto ekufanele zisetjenziswe ngomnanko omkhulu njengoba zitjha nanyana zibanga umlilo msinyana. 

=== '''Umthombolwazi''' ===
&lt;references /&gt;</text>
      <sha1>johdvp7ri31fzenx4x7dh8zxcsxfzco</sha1>
    </revision>
  </page>
  <page>
    <title>Ilimu nelimi.</title>
    <ns>0</ns>
    <id>446</id>
    <revision>
      <id>2361</id>
      <timestamp>2025-01-24T15:46:09Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <comment>Created page with &quot;== '''Ilimu nelimi.''' ==  === '''Isingeniso''' === Ilimu nelimi zizinto ezimbili lezo ezipheze zaphinyiswa begodu zatlolwa kokufana. Kodwana, eqinisweni azifani begodu zihluke khulu nangesakhiwo nemisebenzi yazo. Eenhlokwaneni ezilandelako sizokutjheja bonyana ilimi nelimu kuyini.  === '''Kuyini ilimi?''' === U-Repka (2020)&lt;ref name=&quot;:0&quot;&gt;Repka, R. 2020. Towards a Definition of Language. ''Philologia'', 30 (1): 149–170.&lt;/ref&gt; uveze bonyana ilimi litjhuguluka njalo ngok...&quot;</comment>
      <origin>2361</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5421" sha1="o9w0owk5cvljjb5eeaypdiysyg5nj6a" xml:space="preserve">== '''Ilimu nelimi.''' ==

=== '''Isingeniso''' ===
Ilimu nelimi zizinto ezimbili lezo ezipheze zaphinyiswa begodu zatlolwa kokufana. Kodwana, eqinisweni azifani begodu zihluke khulu nangesakhiwo nemisebenzi yazo. Eenhlokwaneni ezilandelako sizokutjheja bonyana ilimi nelimu kuyini.

=== '''Kuyini ilimi?''' ===
U-Repka (2020)&lt;ref name=&quot;:0&quot;&gt;Repka, R. 2020. Towards a Definition of Language. ''Philologia'', 30 (1): 149–170.&lt;/ref&gt; uveze bonyana ilimi litjhuguluka njalo ngokukhambelaniswa nobujamo namatjhuguluko afunekako ukuze ihlelo lokuthintana lisetjenziswe ngokupheleleko. Ungezelele wathu, u-Repka (2020:150)&lt;ref name=&quot;:0&quot; /&gt;, ilimi kusisakhiwo sehlelo elihlelekileko lamatshwayo lawo asetjenziswa ukukhuluma nanyana ukwenza ilimi. Ngamanye amagama, kusetjenziswa leso esisebenziswa ukwakha ilimi, okutjho bona ngaphambi kobanyana ilimi litlolwe nanyana libe semethethweni kufanele kube nelimi lelo ekuzokususelwa kilo.

Ngokuya kuka-Oviogun no-Veerdee (2020) &lt;ref name=&quot;:1&quot;&gt;Oviogun, P. V., &amp; Veerdee, P. S. (2020). Definition of language and linguistics: basic competence. ''Macrolinguistics and Microlinguistics'', 1(1): 1–12.&lt;/ref&gt;ilimi liyindlela yokuthintana begodu lilihlelo lokuthintana lelo elisebenzisa amatshwayo abongwaqa nabokamisa. Nasitjheja ihlathululo le, ilinge ukuhlathulula ilimi ngendlela yesayensi yezelimi ngokuthi kutjhejwe amatjhada nemidumo leyo esetjenziswa elimini ngesikhathi sehlelo lokuthintana. 

I-[https://www.britannica.com/topic/language Britannica (2024)]&lt;ref name=&quot;:2&quot;&gt;Britannica. 2024. ''Tongue''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.britannica.com/science/tongue&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt; yona ihlathulule ilimi njengeqhinga lokuzihlathulula ngendlela yokuhlanganisa amatjhada ukuze abemagama lawo aletha umqondo ozwakalako. Ihlathululo le, ingezelele phezu kwehlathululo ka-Oviogun no-Veerdee (2020)&lt;ref name=&quot;:1&quot; /&gt; ngokuthi iveze bonyana amatjhada la ayakhiwa abemagama lawo amumethe umqondo ukuze loyo olaleleko nanyana ozibandakanye ehlelweni lekulumo azwisise. 

I-[[:en:Language|Wikipedia (2024a]])&lt;ref&gt;Wikipedia. 2024. ''Language''. Litholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Language&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt; ihlathulule ilimi njengehlelo elihlelekileko lezokuthintana lelo elifaka hlangana ihlelo lelimi, amatjhada nommongo ngomnqopho wokukhambisa umlayezo loyo ongaba ngobujamo bokukhulunywa nanyana bokutlolwa phasi. Ihlathululo le ilinge ukufaka yoke into ilimi engiyo ngokusuka embonweni obhamba ukuya embonweni wezesayensi kanye nemisebenzi yalo. Esihlokwaneni esilandelako sitjheja bonyana kuyini ilimu. 

=== '''Kuyini ilimu?''' ===
Ngokuya kuka-Bordoni, u-Morabito, u-Mitrano, u-Simonelli no-Toccafondi (2018:2)&lt;ref name=&quot;:3&quot;&gt;Bordoni, B., Morabito, B., Mitrano. R, &amp; Toccafondi, A. 2018. The Anatomical Relationships of the Tongue with the Body System. Cureus 10(12): 1-7.&lt;/ref&gt; ilimu kusisitho leso esisetjenziswa ukugwinya, ukuphefumula, ukukhuluma nokutlhafunya. Nasitjheja ihlathululo le siyayibona bonyana inqophe khulu kumisebenzi leyo eyenziwa lilimu. Nanyana kunjalo, u-Mangold, u-Torgerson, no-Rogers (2016)&lt;ref&gt;Mangold, A. R., Torgerson, R. R., &amp; Rogers, R. S. 2016. Diseases of the tongue. ''Clinics in Dermatology'', 34:458-469.&lt;/ref&gt; balinge ukungezelela phezu kwehlathululo ka-Bordoni ''nabanye'' (2018)&lt;ref name=&quot;:3&quot; /&gt; nabaveza bonyana ilimu kusisitho leso esihlangahlangeneko esikghona ukuzwa ngemisipha nenyama yaso. Ihlathululo le, inqophe khulu ezintweni ezakha ilimi.

U-Serrurier, no-Badin, no-Barney, no-Boe no-Savariaux (2009)&lt;ref&gt;Serrurier, A., Badin, P., Barney, A., Boe., L., &amp; Savariaux, C. 2009. Comparative articulatory modelling of the tongue in speech and feeding. ''Journal of Speech, Language and Hearing Research'':1-28.&lt;/ref&gt; baveze bonyana ilimu kusisitho somuntu nanyana sesilwani leso esinenyama nemisipha esikghona ukululela nanyana ukuthatha ubujamo obuthize ukuze umuntu nanyana isilwani sidle, sikhulume nanyana siphefumule ngokuthi sisebenzise imisipha nemithambo yaso ukuvala, ukululeka nokukghwatha. Ihlathululo le ilinge ikufaka yoke into eyakha ilimi, imisebenzi kanye nangendlela imisebenzi leyo iyenza ngayo. 

I-[[:en:Tongue|Wikipedia (2024b)]]&lt;ref&gt;Wikipedia. 2024b. ''Tongue''. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Tongue&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt; ngokusekelwa yi-[https://www.britannica.com/science/tongue Britannica (2024)]&lt;ref name=&quot;:2&quot; /&gt;&lt;ref&gt;Britannica. 2024. ''Tongue''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.britannica.com/science/tongue&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt; iveze bonyana ilimu kusisitho esinemisipha, inyama nemithambo leso esitholakala emlonyeni begodu sisiza ukutlhafunya nokugwinya ukudla, ukunambitha, ukukhambisa amathe nokusiza ekukhulumeni. Ihlathululo le ilinge ukufaka yoke into eyakha ilimi, kanye nokuhlukanisa imisebenzi yayo ngokungeneleleko. 

=== '''Isiphetho''' ===
Ilimi nelimu kuzizinto ezihluke tle begodu nemisebenzi yazo ayifani. Nanyana kunjalo zoke ziqakathekileko epilweni yabantu kanye neyeenlwani begdou ziqakatheke ngokuhlukileko. Ilimu kusisitho esifunywana emlomeni womuntu nanyana wesilwani begodu siziza ukudla, uphefumula nezinye zezinto. Kanti, ilimi kulihlelo elihlelekileko lokuthintana lezo eliqakathekileko ekukhambiseni imilayezo nokuthintana. 

=== '''Umthombolwazi''' ===
&lt;references /&gt;</text>
      <sha1>o9w0owk5cvljjb5eeaypdiysyg5nj6a</sha1>
    </revision>
    <revision>
      <id>2379</id>
      <parentid>2361</parentid>
      <timestamp>2025-01-28T06:11:01Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <minor />
      <origin>2379</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5422" sha1="l7wj8dtl2i53yospru2wkc5i3p1ycic" xml:space="preserve">== '''Ilimu nelimi.''' ==

=== '''Isingeniso.''' ===
Ilimu nelimi zizinto ezimbili lezo ezipheze zaphinyiswa begodu zatlolwa kokufana. Kodwana, eqinisweni azifani begodu zihluke khulu nangesakhiwo nemisebenzi yazo. Eenhlokwaneni ezilandelako sizokutjheja bonyana ilimi nelimu kuyini.

=== '''Kuyini ilimi?''' ===
U-Repka (2020)&lt;ref name=&quot;:0&quot;&gt;Repka, R. 2020. Towards a Definition of Language. ''Philologia'', 30 (1): 149–170.&lt;/ref&gt; uveze bonyana ilimi litjhuguluka njalo ngokukhambelaniswa nobujamo namatjhuguluko afunekako ukuze ihlelo lokuthintana lisetjenziswe ngokupheleleko. Ungezelele wathu, u-Repka (2020:150)&lt;ref name=&quot;:0&quot; /&gt;, ilimi kusisakhiwo sehlelo elihlelekileko lamatshwayo lawo asetjenziswa ukukhuluma nanyana ukwenza ilimi. Ngamanye amagama, kusetjenziswa leso esisebenziswa ukwakha ilimi, okutjho bona ngaphambi kobanyana ilimi litlolwe nanyana libe semethethweni kufanele kube nelimi lelo ekuzokususelwa kilo.

Ngokuya kuka-Oviogun no-Veerdee (2020) &lt;ref name=&quot;:1&quot;&gt;Oviogun, P. V., &amp; Veerdee, P. S. (2020). Definition of language and linguistics: basic competence. ''Macrolinguistics and Microlinguistics'', 1(1): 1–12.&lt;/ref&gt;ilimi liyindlela yokuthintana begodu lilihlelo lokuthintana lelo elisebenzisa amatshwayo abongwaqa nabokamisa. Nasitjheja ihlathululo le, ilinge ukuhlathulula ilimi ngendlela yesayensi yezelimi ngokuthi kutjhejwe amatjhada nemidumo leyo esetjenziswa elimini ngesikhathi sehlelo lokuthintana. 

I-[https://www.britannica.com/topic/language Britannica (2024)]&lt;ref name=&quot;:2&quot;&gt;Britannica. 2024. ''Tongue''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.britannica.com/science/tongue&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt; yona ihlathulule ilimi njengeqhinga lokuzihlathulula ngendlela yokuhlanganisa amatjhada ukuze abemagama lawo aletha umqondo ozwakalako. Ihlathululo le, ingezelele phezu kwehlathululo ka-Oviogun no-Veerdee (2020)&lt;ref name=&quot;:1&quot; /&gt; ngokuthi iveze bonyana amatjhada la ayakhiwa abemagama lawo amumethe umqondo ukuze loyo olaleleko nanyana ozibandakanye ehlelweni lekulumo azwisise. 

I-[[:en:Language|Wikipedia (2024a]])&lt;ref&gt;Wikipedia. 2024. ''Language''. Litholakala ku:&lt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Language&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt; ihlathulule ilimi njengehlelo elihlelekileko lezokuthintana lelo elifaka hlangana ihlelo lelimi, amatjhada nommongo ngomnqopho wokukhambisa umlayezo loyo ongaba ngobujamo bokukhulunywa nanyana bokutlolwa phasi. Ihlathululo le ilinge ukufaka yoke into ilimi engiyo ngokusuka embonweni obhamba ukuya embonweni wezesayensi kanye nemisebenzi yalo. Esihlokwaneni esilandelako sitjheja bonyana kuyini ilimu. 

=== '''Kuyini ilimu?''' ===
Ngokuya kuka-Bordoni, u-Morabito, u-Mitrano, u-Simonelli no-Toccafondi (2018:2)&lt;ref name=&quot;:3&quot;&gt;Bordoni, B., Morabito, B., Mitrano. R, &amp; Toccafondi, A. 2018. The Anatomical Relationships of the Tongue with the Body System. Cureus 10(12): 1-7.&lt;/ref&gt; ilimu kusisitho leso esisetjenziswa ukugwinya, ukuphefumula, ukukhuluma nokutlhafunya. Nasitjheja ihlathululo le siyayibona bonyana inqophe khulu kumisebenzi leyo eyenziwa lilimu. Nanyana kunjalo, u-Mangold, u-Torgerson, no-Rogers (2016)&lt;ref&gt;Mangold, A. R., Torgerson, R. R., &amp; Rogers, R. S. 2016. Diseases of the tongue. ''Clinics in Dermatology'', 34:458-469.&lt;/ref&gt; balinge ukungezelela phezu kwehlathululo ka-Bordoni ''nabanye'' (2018)&lt;ref name=&quot;:3&quot; /&gt; nabaveza bonyana ilimu kusisitho leso esihlangahlangeneko esikghona ukuzwa ngemisipha nenyama yaso. Ihlathululo le, inqophe khulu ezintweni ezakha ilimi.

U-Serrurier, no-Badin, no-Barney, no-Boe no-Savariaux (2009)&lt;ref&gt;Serrurier, A., Badin, P., Barney, A., Boe., L., &amp; Savariaux, C. 2009. Comparative articulatory modelling of the tongue in speech and feeding. ''Journal of Speech, Language and Hearing Research'':1-28.&lt;/ref&gt; baveze bonyana ilimu kusisitho somuntu nanyana sesilwani leso esinenyama nemisipha esikghona ukululela nanyana ukuthatha ubujamo obuthize ukuze umuntu nanyana isilwani sidle, sikhulume nanyana siphefumule ngokuthi sisebenzise imisipha nemithambo yaso ukuvala, ukululeka nokukghwatha. Ihlathululo le ilinge ikufaka yoke into eyakha ilimi, imisebenzi kanye nangendlela imisebenzi leyo iyenza ngayo. 

I-[[:en:Tongue|Wikipedia (2024b)]]&lt;ref&gt;Wikipedia. 2024b. ''Tongue''. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Tongue&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt; ngokusekelwa yi-[https://www.britannica.com/science/tongue Britannica (2024)]&lt;ref name=&quot;:2&quot; /&gt;&lt;ref&gt;Britannica. 2024. ''Tongue''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.britannica.com/science/tongue&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 24 kuNobayeni 2024].&lt;/ref&gt; iveze bonyana ilimu kusisitho esinemisipha, inyama nemithambo leso esitholakala emlonyeni begodu sisiza ukutlhafunya nokugwinya ukudla, ukunambitha, ukukhambisa amathe nokusiza ekukhulumeni. Ihlathululo le ilinge ukufaka yoke into eyakha ilimi, kanye nokuhlukanisa imisebenzi yayo ngokungeneleleko. 

=== '''Isiphetho''' ===
Ilimi nelimu kuzizinto ezihluke tle begodu nemisebenzi yazo ayifani. Nanyana kunjalo zoke ziqakathekileko epilweni yabantu kanye neyeenlwani begdou ziqakatheke ngokuhlukileko. Ilimu kusisitho esifunywana emlomeni womuntu nanyana wesilwani begodu siziza ukudla, uphefumula nezinye zezinto. Kanti, ilimi kulihlelo elihlelekileko lokuthintana lezo eliqakathekileko ekukhambiseni imilayezo nokuthintana. 

=== '''Umthombolwazi''' ===
&lt;references /&gt;</text>
      <sha1>l7wj8dtl2i53yospru2wkc5i3p1ycic</sha1>
    </revision>
  </page>
  <page>
    <title>Izulu.</title>
    <ns>0</ns>
    <id>447</id>
    <revision>
      <id>2362</id>
      <timestamp>2025-01-24T16:06:11Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <comment>Created page with &quot;== '''Izulu.''' ==  === '''Isingeniso''' === Izulu ngezinye zezinto eziqakatheke kwamambala epilweni yazo zoke iinlwani kanye nabantu. Izulu limthombo wamanzi kanye nokukhula okukhamba netuthuko yeenlwana zoke kanye nabantu. Amaphuzu la afakazelwe yi-Wikipedia (2024)&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. ''Rain''. Ufumaneka ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Rain&lt;/nowiki&gt;&gt;. Ifunenywe [16 kuNobayeni 2024].&lt;/ref&gt; lokha nayiveza bonyana amanzi amanengi aselwako ephasini la...&quot;</comment>
      <origin>2362</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3799" sha1="k9pksxsiaeuc3lcx3p1ukc6zervttay" xml:space="preserve">== '''Izulu.''' ==

=== '''Isingeniso''' ===
Izulu ngezinye zezinto eziqakatheke kwamambala epilweni yazo zoke iinlwani kanye nabantu. Izulu limthombo wamanzi kanye nokukhula okukhamba netuthuko yeenlwana zoke kanye nabantu. Amaphuzu la afakazelwe yi-Wikipedia (2024)&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. ''Rain''. Ufumaneka ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Rain&lt;/nowiki&gt;&gt;. Ifunenywe [16 kuNobayeni 2024].&lt;/ref&gt; lokha nayiveza bonyana amanzi amanengi aselwako ephasini la, abuya ezulwini. Enhlokwaneni ezilandelako sizokutjheja bonyana kuyini izulu begodu sitjheje nemihlobo yezulu edume khulu. 

=== '''Khuyini izulu''' ===
[[Isimumathi:Izulu.jpg|thumb|379x379px|Izulu]]
Izulu kumathosi lawo enzeke nanyana asuka ebujameni bomrhwamuko wamanzi wemoyeni bese awele phasi ngebanga lobudisi bawo nanyana bobudisi bomoya wephasi ([[:en:Rain|Wikipedia 2024]])&lt;ref name=&quot;:0&quot; /&gt;. I-Wikipedia (2024)&lt;ref name=&quot;:0&quot; /&gt; ingezelela yathi unobangela wezulu omkhulu, kumrhwamuko okhamba ngamahlangothi nanyana ngeengaba entathu zobujamo bomtjhiso. Umrhwamuko okhamba ngamahlangothi nanyana ngeengaba entathu zobujamo bomtjhiso waziwa ngokuthi mvangobujamo bezulu (Joseph 2016&lt;ref name=&quot;:1&quot;&gt;Joseph, A. 2016. Physics of Rainfall. ''Journal of Scientific and Engineering Research'', 3 (1):51-54.&lt;/ref&gt;). U-Joseph (2016)&lt;ref name=&quot;:1&quot; /&gt; ungezele wathi, woke amathosi lawo asuka [[Amafu|emafini]] bese awele phasi, afaka hlangana izulu, igabhogo nesinanja; abizwa bonyana kukuna. Esihlokwaneni esilandelako sizokutjheja imihlobo yezulu.

=== '''Imihlobo yezulu''' ===
Kunemihlobo eminengi tle [[Iinkathi zomnyaka|yezulu]]. Kodwana thina sizokutjheja imihlobo emithathu yezulu eyaziwa khulu njengombana kufakazelwa yi-[https://www.britannica.com/science/precipitation Britannica] (2024)&lt;ref name=&quot;:2&quot;&gt;Britannica. 2024. ''Rain''. Ufumaneka ku:&lt; &lt;nowiki&gt;https://www.britannica.com/science/precipitation&lt;/nowiki&gt;&gt;. Ifunenywe [16 kuNobayeni 2024].&lt;/ref&gt; nayithi izulu elilamulako, izulu lomtjhiso nelesiwuruwuru kumhlobo wezulu owaziwa khulu. Ngalokho-ke, esihlokwaneni esilandelako sizokuthoma ngokuhlathulula izulu elilamulako.

=== '''Izulu elilamulako''' ===
Izulu elilamulako lizulu leli elina nanyana eliba khona ngemva kokuthi kube nomrhwamuko otjhisako loyo ovuthelelelako emanzini bese ukatelele ukukhuphuka lokho okufikelela iindawo eziphezulu nanyana isibhakabhaka (Britannica 2024&lt;ref name=&quot;:2&quot; /&gt;). Ukusuka lapho, umrhwamuko loyo wenze amathosi abudisi emafini besele awela phasi ngobujamo bokuna (Britannica 2024). 

=== '''Izulu lomtjhiso''' ===
Izulu lomtjhi kulizulu elina ngebanga lokutjhisa khulu kwephasi nanyana kwelanga (Britannica 2024&lt;ref name=&quot;:2&quot; /&gt;; Department of Environmental Services 2019&lt;ref&gt;Department of Environmental Services. 2019. ''Environmental Fact Sheet''. New Hampshire Department of Environmental Services.&lt;/ref&gt;). Umtjhiso wenarha obuya ephasisi utjhisa amazinga aphasi womphezulu bese utjhiso loyo okhuphekele phezulu emafini lapho uphola khona khulu (Britannicca 2024). Ngemva kokuphola, wenza amathosi emafini lawo abanga ukuna kwezulu (Britannica 2024).

=== '''Izulu lesiwuruwuru''' ===
Izulu lesiwuruwuru liba khona ngebanga lokuthi kube khona ukutjhayisana nanyana ukuhlangana kwemihlobo embili yomoya leyo enobujamo bezulu nobudisi obuhlukeneko (Britannica 2024&lt;ref name=&quot;:2&quot; /&gt;). Ngesikhathi imimoya le engafaniko ihlangana, uthola omunye umoya uyaphezulu bese umunye uya phasi lokho kwenze bona kube nokuna okungakanzinzi (Britannica 2024). 

=== '''Isiphetho''' ===
Izulu liqakatheke khulu epilweni yesinye nesinye isilwazi kanye neentjalo. Izulu lidlala indima ekulu etuthukweni nekukhuleni kweenlwana, iintjalo nabantu. Ekulumenipendulwano yethu engehla sitjheje ihlathululo yezulu kanye nemihlobo edume khulu yezulu. 

=== '''Umthombolwazi''' ===
&lt;references /&gt;</text>
      <sha1>k9pksxsiaeuc3lcx3p1ukc6zervttay</sha1>
    </revision>
    <revision>
      <id>2380</id>
      <parentid>2362</parentid>
      <timestamp>2025-01-28T06:11:36Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <minor />
      <origin>2380</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3800" sha1="qd6aexdfd23hg5f7q7kvsy8qjskay5a" xml:space="preserve">== '''Izulu.''' ==

=== '''Isingeniso''' ===
Izulu ngezinye zezinto eziqakatheke kwamambala epilweni yazo zoke iinlwani kanye nabantu. Izulu limthombo wamanzi kanye nokukhula okukhamba netuthuko yeenlwana zoke kanye nabantu. Amaphuzu la afakazelwe yi-Wikipedia (2024)&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2024. ''Rain''. Ufumaneka ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Rain&lt;/nowiki&gt;&gt;. Ifunenywe [16 kuNobayeni 2024].&lt;/ref&gt; lokha nayiveza bonyana amanzi amanengi aselwako ephasini la, abuya ezulwini. Enhlokwaneni ezilandelako sizokutjheja bonyana kuyini izulu begodu sitjheje nemihlobo yezulu edume khulu. 

=== '''Khuyini izulu?''' ===
[[Isimumathi:Izulu.jpg|thumb|379x379px|Izulu]]
Izulu kumathosi lawo enzeke nanyana asuka ebujameni bomrhwamuko wamanzi wemoyeni bese awele phasi ngebanga lobudisi bawo nanyana bobudisi bomoya wephasi ([[:en:Rain|Wikipedia 2024]])&lt;ref name=&quot;:0&quot; /&gt;. I-Wikipedia (2024)&lt;ref name=&quot;:0&quot; /&gt; ingezelela yathi unobangela wezulu omkhulu, kumrhwamuko okhamba ngamahlangothi nanyana ngeengaba entathu zobujamo bomtjhiso. Umrhwamuko okhamba ngamahlangothi nanyana ngeengaba entathu zobujamo bomtjhiso waziwa ngokuthi mvangobujamo bezulu (Joseph 2016&lt;ref name=&quot;:1&quot;&gt;Joseph, A. 2016. Physics of Rainfall. ''Journal of Scientific and Engineering Research'', 3 (1):51-54.&lt;/ref&gt;). U-Joseph (2016)&lt;ref name=&quot;:1&quot; /&gt; ungezele wathi, woke amathosi lawo asuka [[Amafu|emafini]] bese awele phasi, afaka hlangana izulu, igabhogo nesinanja; abizwa bonyana kukuna. Esihlokwaneni esilandelako sizokutjheja imihlobo yezulu.

=== '''Imihlobo yezulu''' ===
Kunemihlobo eminengi tle [[Iinkathi zomnyaka|yezulu]]. Kodwana thina sizokutjheja imihlobo emithathu yezulu eyaziwa khulu njengombana kufakazelwa yi-[https://www.britannica.com/science/precipitation Britannica] (2024)&lt;ref name=&quot;:2&quot;&gt;Britannica. 2024. ''Rain''. Ufumaneka ku:&lt; &lt;nowiki&gt;https://www.britannica.com/science/precipitation&lt;/nowiki&gt;&gt;. Ifunenywe [16 kuNobayeni 2024].&lt;/ref&gt; nayithi izulu elilamulako, izulu lomtjhiso nelesiwuruwuru kumhlobo wezulu owaziwa khulu. Ngalokho-ke, esihlokwaneni esilandelako sizokuthoma ngokuhlathulula izulu elilamulako.

=== '''Izulu elilamulako''' ===
Izulu elilamulako lizulu leli elina nanyana eliba khona ngemva kokuthi kube nomrhwamuko otjhisako loyo ovuthelelelako emanzini bese ukatelele ukukhuphuka lokho okufikelela iindawo eziphezulu nanyana isibhakabhaka (Britannica 2024&lt;ref name=&quot;:2&quot; /&gt;). Ukusuka lapho, umrhwamuko loyo wenze amathosi abudisi emafini besele awela phasi ngobujamo bokuna (Britannica 2024). 

=== '''Izulu lomtjhiso''' ===
Izulu lomtjhi kulizulu elina ngebanga lokutjhisa khulu kwephasi nanyana kwelanga (Britannica 2024&lt;ref name=&quot;:2&quot; /&gt;; Department of Environmental Services 2019&lt;ref&gt;Department of Environmental Services. 2019. ''Environmental Fact Sheet''. New Hampshire Department of Environmental Services.&lt;/ref&gt;). Umtjhiso wenarha obuya ephasisi utjhisa amazinga aphasi womphezulu bese utjhiso loyo okhuphekele phezulu emafini lapho uphola khona khulu (Britannicca 2024). Ngemva kokuphola, wenza amathosi emafini lawo abanga ukuna kwezulu (Britannica 2024).

=== '''Izulu lesiwuruwuru''' ===
Izulu lesiwuruwuru liba khona ngebanga lokuthi kube khona ukutjhayisana nanyana ukuhlangana kwemihlobo embili yomoya leyo enobujamo bezulu nobudisi obuhlukeneko (Britannica 2024&lt;ref name=&quot;:2&quot; /&gt;). Ngesikhathi imimoya le engafaniko ihlangana, uthola omunye umoya uyaphezulu bese umunye uya phasi lokho kwenze bona kube nokuna okungakanzinzi (Britannica 2024). 

=== '''Isiphetho''' ===
Izulu liqakatheke khulu epilweni yesinye nesinye isilwazi kanye neentjalo. Izulu lidlala indima ekulu etuthukweni nekukhuleni kweenlwana, iintjalo nabantu. Ekulumenipendulwano yethu engehla sitjheje ihlathululo yezulu kanye nemihlobo edume khulu yezulu. 

=== '''Umthombolwazi''' ===
&lt;references /&gt;</text>
      <sha1>qd6aexdfd23hg5f7q7kvsy8qjskay5a</sha1>
    </revision>
  </page>
  <page>
    <title>Umnyango nombadi.</title>
    <ns>0</ns>
    <id>448</id>
    <revision>
      <id>2363</id>
      <timestamp>2025-01-24T16:22:23Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <comment>Created page with &quot;== '''Umnyango nombadi.''' ==  === '''Isingeniso''' === Kukhona ezinye izinto ezinamagama nanyana ezibizwa ngamagama ahlukeneko kodwana uthole umqondo nanyana ihlathululo ifana. Izinto lezo nanyana amagama lawo abizwa bonyana bomqondofana. Umnyango nombadi ngamanye wamagama abomqondofana ngombana atjho begodu anehlathululo efanako. Eenhlokwaneni ezilandelako sizokutjhaja bonyana kuyini umnyango nanyana umbadi begodi nomsebenzi wawo. Ngebanga lomnqopho wekulumopendulwano...&quot;</comment>
      <origin>2363</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3435" sha1="45ldixzdu2k2qk6b06fl8z3jy7mpx52" xml:space="preserve">== '''Umnyango nombadi.''' ==

=== '''Isingeniso''' ===
Kukhona ezinye izinto ezinamagama nanyana ezibizwa ngamagama ahlukeneko kodwana uthole umqondo nanyana ihlathululo ifana. Izinto lezo nanyana amagama lawo abizwa bonyana bomqondofana. Umnyango nombadi ngamanye wamagama abomqondofana ngombana atjho begodu anehlathululo efanako. Eenhlokwaneni ezilandelako sizokutjhaja bonyana kuyini umnyango nanyana umbadi begodi nomsebenzi wawo. Ngebanga lomnqopho wekulumopendulwano le, sizokutjheja umnyango ngokunqopha into esetjenziswa ukuvala ingasi umnyango njengegatja lombuso.

=== '''Kuyini umnyango nanyana umbadi?''' ===
[[Isimumathi:Umnyango umbadi.jpg|thumb|392x392px|Umnyango nanyana umbadi]]
Ngokuya kwe-[[mwod:door|Merriam-Webster Dictionary (2024)]]&lt;ref&gt;Merriam-Webster. 2024. ''Door.'' Litholakala ku:&lt; &lt;nowiki&gt;https://www.merriam-webster.com/dictionary/door&lt;/nowiki&gt;&gt;. &gt;. Ifunyenwe [ngomhlaka 21 kuNobayeni 2024].&lt;/ref&gt; umnyango nanyana umbadi sisetjenziswa leso esizwinkako nanyana esivulekako ngomnqopho wokuvala nokuvula amangeno. Ihlathululo yethu le, yihlathululo ebeka umnyango ngobulula begodu ngobufitjhani ngendlela ekungakghonakala ngayo. 

Kodwana ngokuya kwe-[[:en:Door|Wikipedia (2024)]]&lt;ref&gt;Wikipedia. 2024. ''Door''. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Door&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 21 kuNobayeni 2024].&lt;/ref&gt; umnyango nanyana umbadi sikhandeli esikhambako leso esivumela ukungena nokuvalwa begodu umnqopho waso wokuthoma kukunikela ivikeleko ngokulawulwa ukungena nokuphuma. Ihlathululo yethu le inqophe khulu emsebenzini owenziwa mnyango begodu nangedlela umngango ungakho. 

I[https://www.britannica.com/dictionary/door -Britannica (2024)]&lt;ref name=&quot;:0&quot;&gt;Britannica. 2024. ''Door''. Litholakala ku:&lt;&lt;nowiki&gt;https://www.britannica.com/dictionary/door&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 21 kuNobayeni 2024].&lt;/ref&gt; isibikela bonyana umnyango nanyana umbadi kusiqunto esikhambisekako sesigodo, irhalasi nanyana isimbi leyo ezwinkako nanyana evulekako begodu ivaleke ukuze abantu bangene nanyana baphume ngekumbeni, emakhiweni, esithuthini njl. Ihlathululo le, ilinge ukufaka imihlobo yoke yomnyango nanyana yombadi kanye nala ufunyaneka khona.

Nasitjheja iinhlathululo ezingehla lezi singatjho bonyana umbadi nanyana umnyango kusisetjenziswa esenziwe ngesigodo, irhalazi, irhwaratjhwara nanyana isimbi begodu sikghona ukuzwinka, ukukhamba ngomnqopho wokuthi kuvulwe nanyana kuvalwe lapho kungenwa khona nanyana kuphunywa khona njengendaweni efana nelawu, umakhiwo neenthuthi. Esihlokwaneni esilandelako sitjheja imisebenzi yomnyango nanyana yombadi.

=== '''Imisebenzi yomnyango nanyana yombadi''' ===
Ngokuya kwe-[https://www.lawinsider.com/dictionary/door Lawinsider (2024)]&lt;ref&gt;Law Insider. 2024. ''Door.'' Litholakala ku:&lt; &lt;nowiki&gt;https://www.lawinsider.com/dictionary/door&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 21 kuNobayeni 2024].&lt;/ref&gt; umnyango nanyana umbadi usebenza ukuvalela nanyana ukuvula endlini, esithuthini nakezinye iindawo. I-Britannica (2024)&lt;ref name=&quot;:0&quot; /&gt; iingezelela yathi umnyango nanyana umbadi ungasetjenziswa ukuvula nanyana ukuvala indlela leyo esetjenziswa babantu.

=== '''Isiphetho''' ===
Umnyango nombadi kuyinto yinye nanyana magama atjho into yinye leyo ehlathululwa kokufana begodu yenza imisebenzi efanako. Umsebenzi omkhulu womnyango nanyana wombadi kukuvala nokuvula ukungena nokuphuma ngendlini nesithuthwini. 

=== '''Umthombolwazi''' ===
&lt;references /&gt;</text>
      <sha1>45ldixzdu2k2qk6b06fl8z3jy7mpx52</sha1>
    </revision>
    <revision>
      <id>2381</id>
      <parentid>2363</parentid>
      <timestamp>2025-01-28T06:12:41Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <minor />
      <origin>2381</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3436" sha1="4ycitkqg4flxstf5huy33fbd6s296k3" xml:space="preserve">== '''Umnyango nombadi.''' ==

=== '''Isingeniso.''' ===
Kukhona ezinye izinto ezinamagama nanyana ezibizwa ngamagama ahlukeneko kodwana uthole umqondo nanyana ihlathululo ifana. Izinto lezo nanyana amagama lawo abizwa bonyana bomqondofana. Umnyango nombadi ngamanye wamagama abomqondofana ngombana atjho begodu anehlathululo efanako. Eenhlokwaneni ezilandelako sizokutjhaja bonyana kuyini umnyango nanyana umbadi begodi nomsebenzi wawo. Ngebanga lomnqopho wekulumopendulwano le, sizokutjheja umnyango ngokunqopha into esetjenziswa ukuvala ingasi umnyango njengegatja lombuso.

=== '''Kuyini umnyango nanyana umbadi?''' ===
[[Isimumathi:Umnyango umbadi.jpg|thumb|392x392px|Umnyango nanyana umbadi]]
Ngokuya kwe-[[mwod:door|Merriam-Webster Dictionary (2024)]]&lt;ref&gt;Merriam-Webster. 2024. ''Door.'' Litholakala ku:&lt; &lt;nowiki&gt;https://www.merriam-webster.com/dictionary/door&lt;/nowiki&gt;&gt;. &gt;. Ifunyenwe [ngomhlaka 21 kuNobayeni 2024].&lt;/ref&gt; umnyango nanyana umbadi sisetjenziswa leso esizwinkako nanyana esivulekako ngomnqopho wokuvala nokuvula amangeno. Ihlathululo yethu le, yihlathululo ebeka umnyango ngobulula begodu ngobufitjhani ngendlela ekungakghonakala ngayo. 

Kodwana ngokuya kwe-[[:en:Door|Wikipedia (2024)]]&lt;ref&gt;Wikipedia. 2024. ''Door''. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Door&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 21 kuNobayeni 2024].&lt;/ref&gt; umnyango nanyana umbadi sikhandeli esikhambako leso esivumela ukungena nokuvalwa begodu umnqopho waso wokuthoma kukunikela ivikeleko ngokulawulwa ukungena nokuphuma. Ihlathululo yethu le inqophe khulu emsebenzini owenziwa mnyango begodu nangedlela umngango ungakho. 

I[https://www.britannica.com/dictionary/door -Britannica (2024)]&lt;ref name=&quot;:0&quot;&gt;Britannica. 2024. ''Door''. Litholakala ku:&lt;&lt;nowiki&gt;https://www.britannica.com/dictionary/door&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 21 kuNobayeni 2024].&lt;/ref&gt; isibikela bonyana umnyango nanyana umbadi kusiqunto esikhambisekako sesigodo, irhalasi nanyana isimbi leyo ezwinkako nanyana evulekako begodu ivaleke ukuze abantu bangene nanyana baphume ngekumbeni, emakhiweni, esithuthini njl. Ihlathululo le, ilinge ukufaka imihlobo yoke yomnyango nanyana yombadi kanye nala ufunyaneka khona.

Nasitjheja iinhlathululo ezingehla lezi singatjho bonyana umbadi nanyana umnyango kusisetjenziswa esenziwe ngesigodo, irhalazi, irhwaratjhwara nanyana isimbi begodu sikghona ukuzwinka, ukukhamba ngomnqopho wokuthi kuvulwe nanyana kuvalwe lapho kungenwa khona nanyana kuphunywa khona njengendaweni efana nelawu, umakhiwo neenthuthi. Esihlokwaneni esilandelako sitjheja imisebenzi yomnyango nanyana yombadi.

=== '''Imisebenzi yomnyango nanyana yombadi''' ===
Ngokuya kwe-[https://www.lawinsider.com/dictionary/door Lawinsider (2024)]&lt;ref&gt;Law Insider. 2024. ''Door.'' Litholakala ku:&lt; &lt;nowiki&gt;https://www.lawinsider.com/dictionary/door&lt;/nowiki&gt;&gt;. Ifunyenwe [ngomhlaka 21 kuNobayeni 2024].&lt;/ref&gt; umnyango nanyana umbadi usebenza ukuvalela nanyana ukuvula endlini, esithuthini nakezinye iindawo. I-Britannica (2024)&lt;ref name=&quot;:0&quot; /&gt; iingezelela yathi umnyango nanyana umbadi ungasetjenziswa ukuvula nanyana ukuvala indlela leyo esetjenziswa babantu.

=== '''Isiphetho''' ===
Umnyango nombadi kuyinto yinye nanyana magama atjho into yinye leyo ehlathululwa kokufana begodu yenza imisebenzi efanako. Umsebenzi omkhulu womnyango nanyana wombadi kukuvala nokuvula ukungena nokuphuma ngendlini nesithuthwini. 

=== '''Umthombolwazi''' ===
&lt;references /&gt;</text>
      <sha1>4ycitkqg4flxstf5huy33fbd6s296k3</sha1>
    </revision>
  </page>
  <page>
    <title>UMoya nomoya.</title>
    <ns>0</ns>
    <id>449</id>
    <revision>
      <id>2364</id>
      <timestamp>2025-01-24T17:15:50Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <comment>Created page with &quot;== '''UMoya nomoya.''' ==  === '''Isingeniso''' === Ephasini esiphila kilo kukhona ezinye zezinto ezipheze zafana poro kodwana umehluko wazo kumisebenzi nanyana ukuhlonipheka kwazo. UMoya nomoya ngezinye zezinto lezo nasiqala ilimi nesiko lesiNdebele ezipheze zafana poro kodwana zihlukaniswa misebenzi nokuhlonipheka kwazo. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyini uMoya nomoya begodu zihlukana njani.   === '''UMoya nomoya''' === Isimumathi:UMoya oCwengilek...&quot;</comment>
      <origin>2364</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4095" sha1="idzn9qxmjlkjtfp7dv9oq1jysd1tob4" xml:space="preserve">== '''UMoya nomoya.''' ==

=== '''Isingeniso''' ===
Ephasini esiphila kilo kukhona ezinye zezinto ezipheze zafana poro kodwana umehluko wazo kumisebenzi nanyana ukuhlonipheka kwazo. UMoya nomoya ngezinye zezinto lezo nasiqala ilimi nesiko lesiNdebele ezipheze zafana poro kodwana zihlukaniswa misebenzi nokuhlonipheka kwazo. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyini uMoya nomoya begodu zihlukana njani. 

=== '''UMoya nomoya''' ===
[[Isimumathi:UMoya oCwengileko.jpg|thumb|392x392px|UMoya oCwengileko]]
UMoya kumuMoya oCwengileko loyo okhamba noSomnini. I-Biblword (2024)&lt;ref&gt;Biblword. 2024. ''Who is the Holy Spirit?.'' Litholakala ku:&lt; &lt;nowiki&gt;https://www.biblword.net/who-is-the-holy-spirit/?gad_source=1&amp;gclid=CjwKCAiAgoq7BhBxEiwAVcW0LLq3jTeWsZwA04TPxJ-WJWdi4CEtJtRn2R1sa3EIl-gTrrIruxihzxoC1RwQAvD_BwE&lt;/nowiki&gt;&gt;. &gt;. lifunyenwe [Ngomhlaka 19 kuNobayeni 2024].&lt;/ref&gt; ifakazela iphuzu leli lokha nayiveza bonyana uMoya oCwengileko ubizwa ngamagama amanengi anjenge uMoya kaSomnini, uMoya weQiniso, uMoya kaJesu noMoya oCwengileko. I-Wikipedia (2024) &lt;ref&gt;Wikipedia. 2024. ''Holy Spirit in Christianity''. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Holy_Spirit_in_Christianity&lt;/nowiki&gt;&gt;. lifunyenwe [Ngomhlaka 19 kuNobayeni 2024].&lt;/ref&gt;ingezelele yathi, UMoya oCwengileko mumoya wokukholelwa kuSomnini kanye neemfundiso zakhe. Ngamanye amagama uMoya oCwengileko kumuMoya kaSomnini begodu ukhambisana nayo yoke into ekhambelana noSomnini. 

Kodwana, umoya kumumoya ojwayelekileko novunguzako ephasini nanyana hlangana nathi (Climate Kids 2024&lt;ref name=&quot;:0&quot;&gt;Climate Kids. 2024. ''Air is mostly gas''. Litholakala ku:&lt; &lt;nowiki&gt;https://climatekids.nasa.gov/10-things-air/&lt;/nowiki&gt;&gt;. lifunyenwe [Ngomhlaka 19 kuNobayeni 2024].&lt;/ref&gt;). I-Climate Kids (2024)&lt;ref&gt;Climate Kids. 2024. ''Air is mostly gas''. Litholakala ku:&lt; &lt;nowiki&gt;https://climatekids.nasa.gov/10-things-air/&lt;/nowiki&gt;&gt;. lifunyenwe [Ngomhlaka 19 kuNobayeni 2024].&lt;/ref&gt; ne-National Geographic (2024)&lt;ref name=&quot;:1&quot;&gt;National Geographic. 2024. ''Air''. Litholakala ku:&lt; &lt;nowiki&gt;https://education.nationalgeographic.org/resource/air/&lt;/nowiki&gt;&gt; . lifunyenwe [Ngomhlaka 19 kuNobayeni 2024].&lt;/ref&gt; bangezelele bathi umoya kumivango yamarhasi lawo angasiyingosi begodu athi nakahlangene enze umoya lo esiwuthola ngaphandle nanyana esiwuphefumulako. Umoya lo esiwuphefumulako nanyana ovunguza ngaphandle uba nemivango yamamazinga amancani afana nekhabhoni dayi-osayidi, iniyoni nehayidrogeni (Climate Kids 2024&lt;ref name=&quot;:0&quot; /&gt;; ne-National Geographic 2024&lt;ref name=&quot;:1&quot; /&gt;).

=== '''Kungani imimoya embili le itlolwa ngokungafani na?''' ===
[[Isimumathi:Umoya.jpg|left|thumb|Umoya ojwayelekileko]]
Elinye nelinye ilimi linemithetho leyo elawulwa ukutlolwa nokupeledwa kwelimi lelo begodu kube nebhodo yelimi esiza ukwenza amarhubhululo ngokusebenzisana nomphakathi welimi lelo ukuze kuthathwe iinqunto ezinqophileko. ImiThteho yokuTlola nokuPeleda isiNdebele (2022) &lt;ref&gt;PanSALB (Pan South African Language Board). IBhodo yamaLimi wOke weSewula Afrika. 2022. ''ImiThetho yokuPeleda'' ''nokuTlola'' ''IsiNdebele.'' Pretoria: PanSALB.&lt;/ref&gt;yathatha isiqunto bonyana ukuze kwaziwe ukuthi nawukhuluma ngomoya ukukhuluma ngamuphi begodu kuhlonitjhwe noMoya okhambelana noSomnini kufanele kuhlukaniswe ngendlela imimoya le itlolwa ngayo. UMoya oCwengileko kwathatha isiqunto bonyana uzokutlolwa ngegabadlela iledere lawo lokuthoma lesiqu njengolokha nasitlola ibizombala. Lokhu kukukhimbisa ihlonipho kuSomnini. Bese kwathi umoya ejwayelekileko nanyana ovunguza ngaphandle utlolwe ngaphandle kwegabhadlela ukukhombisa ukujwayeleka. Ngendlela le abantu bakghona ukuhlukanisa msinya bonyana nawukhuluma ngomoya okukhuluma ngamuphi.

=== '''Isiphetho''' ===
Ukutlolwa ngokuhluka koMoya nomoya kulitshwayo elitjengisa bona isitjhaba samaNdebele naso siyamhlonipha uSomnini begodu siyakholelwa kuye. Ukudlulela, ukuhlukwaniswa lokhu kunciphisa ihlangahlangano netjhayisano eba khona hlangana kwamagama amabili afanako begodu aphinyiswa kokufana kodwana anehlathululo nommongo ohlukileko

=== '''Umthombolwazi''' ===
&lt;references /&gt;</text>
      <sha1>idzn9qxmjlkjtfp7dv9oq1jysd1tob4</sha1>
    </revision>
    <revision>
      <id>2382</id>
      <parentid>2364</parentid>
      <timestamp>2025-01-28T06:13:20Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <minor />
      <origin>2382</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4096" sha1="341w0xl4cl5iy5d4nzpar92gr06q6f4" xml:space="preserve">== '''UMoya nomoya.''' ==

=== '''Isingeniso.''' ===
Ephasini esiphila kilo kukhona ezinye zezinto ezipheze zafana poro kodwana umehluko wazo kumisebenzi nanyana ukuhlonipheka kwazo. UMoya nomoya ngezinye zezinto lezo nasiqala ilimi nesiko lesiNdebele ezipheze zafana poro kodwana zihlukaniswa misebenzi nokuhlonipheka kwazo. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyini uMoya nomoya begodu zihlukana njani. 

=== '''UMoya nomoya''' ===
[[Isimumathi:UMoya oCwengileko.jpg|thumb|392x392px|UMoya oCwengileko]]
UMoya kumuMoya oCwengileko loyo okhamba noSomnini. I-Biblword (2024)&lt;ref&gt;Biblword. 2024. ''Who is the Holy Spirit?.'' Litholakala ku:&lt; &lt;nowiki&gt;https://www.biblword.net/who-is-the-holy-spirit/?gad_source=1&amp;gclid=CjwKCAiAgoq7BhBxEiwAVcW0LLq3jTeWsZwA04TPxJ-WJWdi4CEtJtRn2R1sa3EIl-gTrrIruxihzxoC1RwQAvD_BwE&lt;/nowiki&gt;&gt;. &gt;. lifunyenwe [Ngomhlaka 19 kuNobayeni 2024].&lt;/ref&gt; ifakazela iphuzu leli lokha nayiveza bonyana uMoya oCwengileko ubizwa ngamagama amanengi anjenge uMoya kaSomnini, uMoya weQiniso, uMoya kaJesu noMoya oCwengileko. I-Wikipedia (2024) &lt;ref&gt;Wikipedia. 2024. ''Holy Spirit in Christianity''. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Holy_Spirit_in_Christianity&lt;/nowiki&gt;&gt;. lifunyenwe [Ngomhlaka 19 kuNobayeni 2024].&lt;/ref&gt;ingezelele yathi, UMoya oCwengileko mumoya wokukholelwa kuSomnini kanye neemfundiso zakhe. Ngamanye amagama uMoya oCwengileko kumuMoya kaSomnini begodu ukhambisana nayo yoke into ekhambelana noSomnini. 

Kodwana, umoya kumumoya ojwayelekileko novunguzako ephasini nanyana hlangana nathi (Climate Kids 2024&lt;ref name=&quot;:0&quot;&gt;Climate Kids. 2024. ''Air is mostly gas''. Litholakala ku:&lt; &lt;nowiki&gt;https://climatekids.nasa.gov/10-things-air/&lt;/nowiki&gt;&gt;. lifunyenwe [Ngomhlaka 19 kuNobayeni 2024].&lt;/ref&gt;). I-Climate Kids (2024)&lt;ref&gt;Climate Kids. 2024. ''Air is mostly gas''. Litholakala ku:&lt; &lt;nowiki&gt;https://climatekids.nasa.gov/10-things-air/&lt;/nowiki&gt;&gt;. lifunyenwe [Ngomhlaka 19 kuNobayeni 2024].&lt;/ref&gt; ne-National Geographic (2024)&lt;ref name=&quot;:1&quot;&gt;National Geographic. 2024. ''Air''. Litholakala ku:&lt; &lt;nowiki&gt;https://education.nationalgeographic.org/resource/air/&lt;/nowiki&gt;&gt; . lifunyenwe [Ngomhlaka 19 kuNobayeni 2024].&lt;/ref&gt; bangezelele bathi umoya kumivango yamarhasi lawo angasiyingosi begodu athi nakahlangene enze umoya lo esiwuthola ngaphandle nanyana esiwuphefumulako. Umoya lo esiwuphefumulako nanyana ovunguza ngaphandle uba nemivango yamamazinga amancani afana nekhabhoni dayi-osayidi, iniyoni nehayidrogeni (Climate Kids 2024&lt;ref name=&quot;:0&quot; /&gt;; ne-National Geographic 2024&lt;ref name=&quot;:1&quot; /&gt;).

=== '''Kungani imimoya embili le itlolwa ngokungafani na?''' ===
[[Isimumathi:Umoya.jpg|left|thumb|Umoya ojwayelekileko]]
Elinye nelinye ilimi linemithetho leyo elawulwa ukutlolwa nokupeledwa kwelimi lelo begodu kube nebhodo yelimi esiza ukwenza amarhubhululo ngokusebenzisana nomphakathi welimi lelo ukuze kuthathwe iinqunto ezinqophileko. ImiThteho yokuTlola nokuPeleda isiNdebele (2022) &lt;ref&gt;PanSALB (Pan South African Language Board). IBhodo yamaLimi wOke weSewula Afrika. 2022. ''ImiThetho yokuPeleda'' ''nokuTlola'' ''IsiNdebele.'' Pretoria: PanSALB.&lt;/ref&gt;yathatha isiqunto bonyana ukuze kwaziwe ukuthi nawukhuluma ngomoya ukukhuluma ngamuphi begodu kuhlonitjhwe noMoya okhambelana noSomnini kufanele kuhlukaniswe ngendlela imimoya le itlolwa ngayo. UMoya oCwengileko kwathatha isiqunto bonyana uzokutlolwa ngegabadlela iledere lawo lokuthoma lesiqu njengolokha nasitlola ibizombala. Lokhu kukukhimbisa ihlonipho kuSomnini. Bese kwathi umoya ejwayelekileko nanyana ovunguza ngaphandle utlolwe ngaphandle kwegabhadlela ukukhombisa ukujwayeleka. Ngendlela le abantu bakghona ukuhlukanisa msinya bonyana nawukhuluma ngomoya okukhuluma ngamuphi.

=== '''Isiphetho''' ===
Ukutlolwa ngokuhluka koMoya nomoya kulitshwayo elitjengisa bona isitjhaba samaNdebele naso siyamhlonipha uSomnini begodu siyakholelwa kuye. Ukudlulela, ukuhlukwaniswa lokhu kunciphisa ihlangahlangano netjhayisano eba khona hlangana kwamagama amabili afanako begodu aphinyiswa kokufana kodwana anehlathululo nommongo ohlukileko

=== '''Umthombolwazi''' ===
&lt;references /&gt;</text>
      <sha1>341w0xl4cl5iy5d4nzpar92gr06q6f4</sha1>
    </revision>
  </page>
  <page>
    <title>Umthangala neboda.</title>
    <ns>0</ns>
    <id>450</id>
    <revision>
      <id>2366</id>
      <timestamp>2025-01-26T10:13:19Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <comment>Created page with &quot;== '''Umthangala neboda.''' ==  === '''Isingeniso''' === Kukhona ezinye izinto ezikhambelana khulu kwangangokuthi abanye abantu bagcina bazihlangahlanganisa ngokuthi bazibize kwangathi yinto yinye kodwana ekubeni zizinto ezimbili ezihlukeneko. Izinto lezo zifaka hlangana ibhoda nomthangala. Eenhlokwaneni ezilandelako sizokutjheja bonyana ibhoda nomthangala kuyini.  === '''Kuyini ibhoda''' === [[Isimumathi:Ibhoda lendlu.jpg|thumb|200x200px|Ibhoda lendlu]] Ngokuya kwe-mw...&quot;</comment>
      <origin>2366</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2517" sha1="r45801ai5bgz3tiiakq7ei8p5v1zuvv" xml:space="preserve">== '''Umthangala neboda.''' ==

=== '''Isingeniso''' ===
Kukhona ezinye izinto ezikhambelana khulu kwangangokuthi abanye abantu bagcina bazihlangahlanganisa ngokuthi bazibize kwangathi yinto yinye kodwana ekubeni zizinto ezimbili ezihlukeneko. Izinto lezo zifaka hlangana ibhoda nomthangala. Eenhlokwaneni ezilandelako sizokutjheja bonyana ibhoda nomthangala kuyini.

=== '''Kuyini ibhoda''' ===
[[Isimumathi:Ibhoda lendlu.jpg|thumb|200x200px|Ibhoda lendlu]]
Ngokuya kwe-[[mwod:wall|Merriam Webster Dictionary (2024)]]&lt;ref&gt;Merriam-Webster. 2024. ''Wall''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.merriam-webster.com/dictionary/wall&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 19 kuNobayeni 2024].&lt;/ref&gt; ibhoda kusakhiwo esakhiwo hlangana nedrada, nanyana esiyingcenye yendlu leso esenziwe ngobumeselani. Ngamanye amagama, ibhoda kusisakhiwo leso esakhiwe ngezinto ezifana namatje, ihlabathi iintina neengodo esisetjenziswa ukuvikela nanyana ukukampela indawo nayana ukwakha indlu. I-[[:en:Wall|Wikipedia (2024)]]&lt;ref&gt;Wikipedia. 2024. ''Wall''. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Wall&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 19 kuNobayeni 2024].&lt;/ref&gt; ingezelela yathi, iboda yisakhiwo nendawo leyo enikela ivikeleko nomakhiwo. Ngokutjheja iinhlathululo lezi singatjho bonyana iboda liyizinto ezinengi begodu lenziwa nanyana lakhiwa zizinto ezinengi.

=== '''Kuyini umthangala?''' ===
Umthangala liboda kodwana elincani lelo kanengi elingeqi idini lomuntu nasitjheja ubude balo kanye nesakhiwo salo. I-[https://www.britannica.com/technology/wall Britannica (2024)]&lt;ref&gt;Britannica. 2024. ''Wall''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.britannica.com/technology/wall&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 19 kuNobayeni 2024].&lt;/ref&gt; ifakazele ihlathulululo yethu le lokha nayiveza bonyana, umthangala kulibodana eliqinileko lelo elakhelwe ukuvalela indawo ethize. Ngamanye amagama, umthangala upheze wafana neboda kodwana wona mncani.

=== '''Umehluko hlangana neboda nomthangala.''' ===
Iboda kusisakhiwo esikhulu ngobude nangobujamo leso esingafulelwa begodu esiyingcenye yendlu. Kodwana, umthangala libodana nanyana iboda elincani, nangobujamo umthangala angeze wafulwa begodu usetjenziswa ukuvelela indlu nanyana into ethize.

=== '''Isiphetho''' ===
Iboda nomthangala kupheze kwafana kodwana akusiyinto yinye begodu nemisebenzi yayo kunala ifana khona begodu kunala ihluka khona. Nanyana kunjalo, kuqakathekile bonyana sikwazi ukuzihlukanisa ukuze sizisebenzise ngokunqophileko.

=== '''Umthombolwazi''' ===
&lt;references /&gt;</text>
      <sha1>r45801ai5bgz3tiiakq7ei8p5v1zuvv</sha1>
    </revision>
    <revision>
      <id>2383</id>
      <parentid>2366</parentid>
      <timestamp>2025-01-28T06:13:53Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <minor />
      <origin>2383</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2518" sha1="0ltfzzkaadhzzy31rk20tn66lya02fq" xml:space="preserve">== '''Umthangala neboda.''' ==

=== '''Isingeniso''' ===
Kukhona ezinye izinto ezikhambelana khulu kwangangokuthi abanye abantu bagcina bazihlangahlanganisa ngokuthi bazibize kwangathi yinto yinye kodwana ekubeni zizinto ezimbili ezihlukeneko. Izinto lezo zifaka hlangana ibhoda nomthangala. Eenhlokwaneni ezilandelako sizokutjheja bonyana ibhoda nomthangala kuyini.

=== '''Kuyini ibhoda?''' ===
[[Isimumathi:Ibhoda lendlu.jpg|thumb|200x200px|Ibhoda lendlu]]
Ngokuya kwe-[[mwod:wall|Merriam Webster Dictionary (2024)]]&lt;ref&gt;Merriam-Webster. 2024. ''Wall''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.merriam-webster.com/dictionary/wall&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 19 kuNobayeni 2024].&lt;/ref&gt; ibhoda kusakhiwo esakhiwo hlangana nedrada, nanyana esiyingcenye yendlu leso esenziwe ngobumeselani. Ngamanye amagama, ibhoda kusisakhiwo leso esakhiwe ngezinto ezifana namatje, ihlabathi iintina neengodo esisetjenziswa ukuvikela nanyana ukukampela indawo nayana ukwakha indlu. I-[[:en:Wall|Wikipedia (2024)]]&lt;ref&gt;Wikipedia. 2024. ''Wall''. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Wall&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 19 kuNobayeni 2024].&lt;/ref&gt; ingezelela yathi, iboda yisakhiwo nendawo leyo enikela ivikeleko nomakhiwo. Ngokutjheja iinhlathululo lezi singatjho bonyana iboda liyizinto ezinengi begodu lenziwa nanyana lakhiwa zizinto ezinengi.

=== '''Kuyini umthangala?''' ===
Umthangala liboda kodwana elincani lelo kanengi elingeqi idini lomuntu nasitjheja ubude balo kanye nesakhiwo salo. I-[https://www.britannica.com/technology/wall Britannica (2024)]&lt;ref&gt;Britannica. 2024. ''Wall''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.britannica.com/technology/wall&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 19 kuNobayeni 2024].&lt;/ref&gt; ifakazele ihlathulululo yethu le lokha nayiveza bonyana, umthangala kulibodana eliqinileko lelo elakhelwe ukuvalela indawo ethize. Ngamanye amagama, umthangala upheze wafana neboda kodwana wona mncani.

=== '''Umehluko hlangana neboda nomthangala.''' ===
Iboda kusisakhiwo esikhulu ngobude nangobujamo leso esingafulelwa begodu esiyingcenye yendlu. Kodwana, umthangala libodana nanyana iboda elincani, nangobujamo umthangala angeze wafulwa begodu usetjenziswa ukuvelela indlu nanyana into ethize.

=== '''Isiphetho''' ===
Iboda nomthangala kupheze kwafana kodwana akusiyinto yinye begodu nemisebenzi yayo kunala ifana khona begodu kunala ihluka khona. Nanyana kunjalo, kuqakathekile bonyana sikwazi ukuzihlukanisa ukuze sizisebenzise ngokunqophileko.

=== '''Umthombolwazi''' ===
&lt;references /&gt;</text>
      <sha1>0ltfzzkaadhzzy31rk20tn66lya02fq</sha1>
    </revision>
  </page>
  <page>
    <title>Utjani.</title>
    <ns>0</ns>
    <id>451</id>
    <revision>
      <id>2367</id>
      <timestamp>2025-01-26T10:41:41Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <comment>Created page with &quot;== '''Utjani.''' ==  === '''Isingeniso''' === Utjani budlala indima eqakathekileko eempilweni zeenlwana nabantu. Kukhona utjani obudliwa ziinlwana zodwa nalobo obudliwa babantu boke. Lokho kutjho bona utjani bunemihlobo eminengi njengoba kufakezelwe ngu-Almusaed (2017)&lt;ref name=&quot;:0&quot;&gt;Almusaed, A. 2017. ''Introductory Chapter: Overview of Grass Topic''. Ifumaneka ku:&lt; &lt;nowiki&gt;http://www.intechopen.com/books/grasses-benefits-diversities-and-functional-roles&lt;/nowiki&gt;&gt;. Ifuny...&quot;</comment>
      <origin>2367</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3990" sha1="ghv4ijq7h8ks0gxpt7777wanc06lw0r" xml:space="preserve">== '''Utjani.''' ==

=== '''Isingeniso''' ===
Utjani budlala indima eqakathekileko eempilweni zeenlwana nabantu. Kukhona utjani obudliwa ziinlwana zodwa nalobo obudliwa babantu boke. Lokho kutjho bona utjani bunemihlobo eminengi njengoba kufakezelwe ngu-Almusaed (2017)&lt;ref name=&quot;:0&quot;&gt;Almusaed, A. 2017. ''Introductory Chapter: Overview of Grass Topic''. Ifumaneka ku:&lt; &lt;nowiki&gt;http://www.intechopen.com/books/grasses-benefits-diversities-and-functional-roles&lt;/nowiki&gt;&gt;. Ifunyenwe [17 kuNobayeni 2024].&lt;/ref&gt;. U-Almusaed (2017)&lt;ref name=&quot;:0&quot; /&gt; waveza bonyana utjani ngezinye zeentjalo lezo eziqakatheke khulu ephasini. Uragele phambili, u-Almusaued (2017)&lt;ref name=&quot;:0&quot; /&gt;, wathi ubuhle nokuqakatheka kotjani buyahluka ukusuka komunye umhlobo wotjani ukuya komunye. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyini utjani, imihlobo yotjani nemisebenzi yayo. 

=== '''Kuyini utjani?''' ===
Utjani kusitjalo leso esizimilelako naleso esingatjalwa enarheni (Agriculture, Forestry and Fisheries 2015&lt;ref name=&quot;:1&quot;&gt;Department of Agriculture, Forestry and Fisheries. 2015. ''Kikuyi lawn grass''. Department of Agriculture, Forestry and Fisheries: Pretoria.&lt;/ref&gt;). Esikathini esinengi utjani buba nombala ohlaza, kanti-ke, eminye imihlobo yetjani iba namathuthumbo nanyana iinthelo ezidliwako ezifana ne-owutsi (Agriculture, Forest and Fisheries 2015&lt;ref name=&quot;:1&quot; /&gt;). Nanyana kunjalo, minengi khulu imihlobo yotjani ekhona ephasini, kodwana ekulumenipendulwano yethu le, sizokutjheja imihlobo emithathu yotjani leyo edume khulu enarheni yangekhethu. Eenhlokwaneni ezilandelako sizokutjheja imihlobo yotjani elandelako:

=== '''Imbozisi''' ===
[[Isimumathi:Imbozisi.jpg|thumb|200x200px]]
Imbozisi kubutjani lobo obunamathuthumbo anamathelako begodu ahlabako. Bona bubonakala khulu ehlobo begodu buthandwa kudliwa ngezinye iinlwani (Lane, u-Morris, u-Bridle no-Eyles 2015&lt;ref name=&quot;:2&quot;&gt;Lane, P., Morris, D., Bridle, K. &amp; Eyles, A. ''Common grasses of Tasmania''. The Tasmanian Institute of Agriculture: Tasmania.&lt;/ref&gt;; Almusaued 2017). Ukungezelela, umhlobo lo wotjani uthanda ukumila la kuthambe khona kodwana kungabi mdzwela (Lane ''nabanye'' 2015&lt;ref name=&quot;:2&quot; /&gt;).

=== '''Umgwengwe''' ===
[[Isimumathi:Umgwengwe.jpg|left|thumb|Umgwengwe]]
Umgwengwe kubutjani lobo obutholakala eenarheni ezinengi (Agriculture, Forest and Fisheries 2015&lt;ref name=&quot;:1&quot; /&gt;). Buhlaza ngombana begodu buqinile, kanti-ke, nomrabhu wawo uqinile begodu utjhinga phasi bese inabe nehlabathi (Agriculture, Forest and Fisheries 2015). Umgwengwe wona kubutjani obuzimilelako begodu bumila ehlobo nakuna izulu (Agriculture, Forest and Fisheries 2015). Umgwengwe udlala indima efuyweni njengoba ifuyo iyabuthanda (Agriculture, Forest and Fisheries 2015&lt;ref name=&quot;:1&quot; /&gt;; Almusaued (2017)

=== '''Ikoroyi''' ===
[[Isimumathi:Ikoroyi.jpg|thumb|Ikoroyi]]
Ikoroyi kumhlobo wotjani lobo obukhula ngokuya phezulu bese buthele iintanga lezo ezidliwako (Texas Department of Transportation, 2024&lt;ref name=&quot;:3&quot;&gt;Texas Department of Transportation. 2024. ''Grass, Weed and Wildflower Guide''. Texas Department of Transportation: Texas.&lt;/ref&gt;). Ikoroyi esikhathini esinengi itjalwa ebusika ivunwe nakuphela isilimela nanyana nakuthoma ihlobo (Texas Department of Transportation, 2024&lt;ref name=&quot;:3&quot; /&gt;). Ukungezelela, umbala wayo uhlaza okutshehla (Texas Department of Transportation, 2024&lt;ref name=&quot;:3&quot; /&gt;). Umsebenzi wekoroyi mnengi tle, njekufana nokwenza uburotho, i-owutsi kanti nokudla kweenlwana (Texas Department of Transportation, 2024&lt;ref name=&quot;:3&quot; /&gt;).

=== '''Isiphetho''' ===
Utjani ngobunye bemihlobo yeentjalo ethandwa khulu. Eminye imihlobo yotjani ithathwa njengamathuthumbo, ukudla kwefuyo kanye nokudla kwabantu. Kukhona eminye godu imihlobo yotjani leyo esetjenziswa njengemitjhoga yokwelapaha (Almusaued (2017). Kungakho kuqakathekile bona sazi begodu sizwisise imihlobo yotjani ukuze sikwazi ukuthatha ithuba nelwazi lokuyisebenzisa ekuthuthukiseni iimpilo zethu.

=== '''Umthombolwazi''' ===
&lt;references /&gt;</text>
      <sha1>ghv4ijq7h8ks0gxpt7777wanc06lw0r</sha1>
    </revision>
    <revision>
      <id>2368</id>
      <parentid>2367</parentid>
      <timestamp>2025-01-26T10:44:09Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <minor />
      <origin>2368</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3996" sha1="4ectz1k7sq07f1wskh6oubo3mf7y183" xml:space="preserve">== '''Utjani.''' ==

=== '''Isingeniso''' ===
Utjani budlala indima eqakathekileko eempilweni zeenlwana nabantu. Kukhona utjani obudliwa ziinlwana zodwa nalobo obudliwa babantu boke. Lokho kutjho bona utjani bunemihlobo eminengi njengoba kufakezelwe ngu-Almusaed (2017)&lt;ref name=&quot;:0&quot;&gt;Almusaed, A. 2017. ''Introductory Chapter: Overview of Grass Topic''. Ifumaneka ku:&lt; &lt;nowiki&gt;http://www.intechopen.com/books/grasses-benefits-diversities-and-functional-roles&lt;/nowiki&gt;&gt;. Ifunyenwe [17 kuNobayeni 2024].&lt;/ref&gt;. U-Almusaed (2017)&lt;ref name=&quot;:0&quot; /&gt; waveza bonyana utjani ngezinye zeentjalo lezo eziqakatheke khulu ephasini. Uragele phambili, u-Almusaued (2017)&lt;ref name=&quot;:0&quot; /&gt;, wathi ubuhle nokuqakatheka kotjani buyahluka ukusuka komunye umhlobo wotjani ukuya komunye. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyini utjani, imihlobo yotjani nemisebenzi yayo. 

=== '''Kuyini utjani?''' ===
Utjani kusitjalo leso esizimilelako naleso esingatjalwa enarheni (Agriculture, Forestry and Fisheries 2015&lt;ref name=&quot;:1&quot;&gt;Department of Agriculture, Forestry and Fisheries. 2015. ''Kikuyi lawn grass''. Department of Agriculture, Forestry and Fisheries: Pretoria.&lt;/ref&gt;). Esikathini esinengi utjani buba nombala ohlaza, kanti-ke, eminye imihlobo yetjani iba namathuthumbo nanyana iinthelo ezidliwako ezifana ne-owutsi (Agriculture, Forest and Fisheries 2015&lt;ref name=&quot;:1&quot; /&gt;). Nanyana kunjalo, minengi khulu imihlobo yotjani ekhona ephasini, kodwana ekulumenipendulwano yethu le, sizokutjheja imihlobo emithathu yotjani leyo edume khulu enarheni yangekhethu. Eenhlokwaneni ezilandelako sizokutjheja imihlobo yotjani elandelako:

=== '''Imbozisi''' ===
[[Isimumathi:Imbozisi.jpg|thumb|200x200px]]
Imbozisi kubutjani lobo obunamathuthumbo anamathelako begodu ahlabako. Bona bubonakala khulu ehlobo begodu buthandwa kudliwa ngezinye iinlwani (Lane, u-Morris, u-Bridle no-Eyles 2015&lt;ref name=&quot;:2&quot;&gt;Lane, P., Morris, D., Bridle, K. &amp; Eyles, A. ''2015. Common grasses of Tasmania''. The Tasmanian Institute of Agriculture: Tasmania.&lt;/ref&gt;; Almusaued 2017). Ukungezelela, umhlobo lo wotjani uthanda ukumila la kuthambe khona kodwana kungabi mdzwela (Lane ''nabanye'' 2015&lt;ref name=&quot;:2&quot; /&gt;).

=== '''Umgwengwe''' ===
[[Isimumathi:Umgwengwe.jpg|left|thumb|Umgwengwe]]
Umgwengwe kubutjani lobo obutholakala eenarheni ezinengi (Agriculture, Forest and Fisheries 2015&lt;ref name=&quot;:1&quot; /&gt;). Buhlaza ngombana begodu buqinile, kanti-ke, nomrabhu wawo uqinile begodu utjhinga phasi bese inabe nehlabathi (Agriculture, Forest and Fisheries 2015). Umgwengwe wona kubutjani obuzimilelako begodu bumila ehlobo nakuna izulu (Agriculture, Forest and Fisheries 2015). Umgwengwe udlala indima efuyweni njengoba ifuyo iyabuthanda (Agriculture, Forest and Fisheries 2015&lt;ref name=&quot;:1&quot; /&gt;; Almusaued (2017)

=== '''Ikoroyi''' ===
[[Isimumathi:Ikoroyi.jpg|thumb|Ikoroyi]]
Ikoroyi kumhlobo wotjani lobo obukhula ngokuya phezulu bese buthele iintanga lezo ezidliwako (Texas Department of Transportation, 2024&lt;ref name=&quot;:3&quot;&gt;Texas Department of Transportation. 2024. ''Grass, Weed and Wildflower Guide''. Texas Department of Transportation: Texas.&lt;/ref&gt;). Ikoroyi esikhathini esinengi itjalwa ebusika ivunwe nakuphela isilimela nanyana nakuthoma ihlobo (Texas Department of Transportation, 2024&lt;ref name=&quot;:3&quot; /&gt;). Ukungezelela, umbala wayo uhlaza okutshehla (Texas Department of Transportation, 2024&lt;ref name=&quot;:3&quot; /&gt;). Umsebenzi wekoroyi mnengi tle, njekufana nokwenza uburotho, i-owutsi kanti nokudla kweenlwana (Texas Department of Transportation, 2024&lt;ref name=&quot;:3&quot; /&gt;).

=== '''Isiphetho''' ===
Utjani ngobunye bemihlobo yeentjalo ethandwa khulu. Eminye imihlobo yotjani ithathwa njengamathuthumbo, ukudla kwefuyo kanye nokudla kwabantu. Kukhona eminye godu imihlobo yotjani leyo esetjenziswa njengemitjhoga yokwelapaha (Almusaued (2017). Kungakho kuqakathekile bona sazi begodu sizwisise imihlobo yotjani ukuze sikwazi ukuthatha ithuba nelwazi lokuyisebenzisa ekuthuthukiseni iimpilo zethu.

=== '''Umthombolwazi''' ===
&lt;references /&gt;</text>
      <sha1>4ectz1k7sq07f1wskh6oubo3mf7y183</sha1>
    </revision>
    <revision>
      <id>2384</id>
      <parentid>2368</parentid>
      <timestamp>2025-01-28T06:14:25Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <minor />
      <origin>2384</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3997" sha1="irnd9i53smqb3l1ghmc85y8nvp5ifvu" xml:space="preserve">== '''Utjani.''' ==

=== '''Isingeniso.''' ===
Utjani budlala indima eqakathekileko eempilweni zeenlwana nabantu. Kukhona utjani obudliwa ziinlwana zodwa nalobo obudliwa babantu boke. Lokho kutjho bona utjani bunemihlobo eminengi njengoba kufakezelwe ngu-Almusaed (2017)&lt;ref name=&quot;:0&quot;&gt;Almusaed, A. 2017. ''Introductory Chapter: Overview of Grass Topic''. Ifumaneka ku:&lt; &lt;nowiki&gt;http://www.intechopen.com/books/grasses-benefits-diversities-and-functional-roles&lt;/nowiki&gt;&gt;. Ifunyenwe [17 kuNobayeni 2024].&lt;/ref&gt;. U-Almusaed (2017)&lt;ref name=&quot;:0&quot; /&gt; waveza bonyana utjani ngezinye zeentjalo lezo eziqakatheke khulu ephasini. Uragele phambili, u-Almusaued (2017)&lt;ref name=&quot;:0&quot; /&gt;, wathi ubuhle nokuqakatheka kotjani buyahluka ukusuka komunye umhlobo wotjani ukuya komunye. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyini utjani, imihlobo yotjani nemisebenzi yayo. 

=== '''Kuyini utjani?''' ===
Utjani kusitjalo leso esizimilelako naleso esingatjalwa enarheni (Agriculture, Forestry and Fisheries 2015&lt;ref name=&quot;:1&quot;&gt;Department of Agriculture, Forestry and Fisheries. 2015. ''Kikuyi lawn grass''. Department of Agriculture, Forestry and Fisheries: Pretoria.&lt;/ref&gt;). Esikathini esinengi utjani buba nombala ohlaza, kanti-ke, eminye imihlobo yetjani iba namathuthumbo nanyana iinthelo ezidliwako ezifana ne-owutsi (Agriculture, Forest and Fisheries 2015&lt;ref name=&quot;:1&quot; /&gt;). Nanyana kunjalo, minengi khulu imihlobo yotjani ekhona ephasini, kodwana ekulumenipendulwano yethu le, sizokutjheja imihlobo emithathu yotjani leyo edume khulu enarheni yangekhethu. Eenhlokwaneni ezilandelako sizokutjheja imihlobo yotjani elandelako:

=== '''Imbozisi''' ===
[[Isimumathi:Imbozisi.jpg|thumb|200x200px]]
Imbozisi kubutjani lobo obunamathuthumbo anamathelako begodu ahlabako. Bona bubonakala khulu ehlobo begodu buthandwa kudliwa ngezinye iinlwani (Lane, u-Morris, u-Bridle no-Eyles 2015&lt;ref name=&quot;:2&quot;&gt;Lane, P., Morris, D., Bridle, K. &amp; Eyles, A. ''2015. Common grasses of Tasmania''. The Tasmanian Institute of Agriculture: Tasmania.&lt;/ref&gt;; Almusaued 2017). Ukungezelela, umhlobo lo wotjani uthanda ukumila la kuthambe khona kodwana kungabi mdzwela (Lane ''nabanye'' 2015&lt;ref name=&quot;:2&quot; /&gt;).

=== '''Umgwengwe''' ===
[[Isimumathi:Umgwengwe.jpg|left|thumb|Umgwengwe]]
Umgwengwe kubutjani lobo obutholakala eenarheni ezinengi (Agriculture, Forest and Fisheries 2015&lt;ref name=&quot;:1&quot; /&gt;). Buhlaza ngombana begodu buqinile, kanti-ke, nomrabhu wawo uqinile begodu utjhinga phasi bese inabe nehlabathi (Agriculture, Forest and Fisheries 2015). Umgwengwe wona kubutjani obuzimilelako begodu bumila ehlobo nakuna izulu (Agriculture, Forest and Fisheries 2015). Umgwengwe udlala indima efuyweni njengoba ifuyo iyabuthanda (Agriculture, Forest and Fisheries 2015&lt;ref name=&quot;:1&quot; /&gt;; Almusaued (2017)

=== '''Ikoroyi''' ===
[[Isimumathi:Ikoroyi.jpg|thumb|Ikoroyi]]
Ikoroyi kumhlobo wotjani lobo obukhula ngokuya phezulu bese buthele iintanga lezo ezidliwako (Texas Department of Transportation, 2024&lt;ref name=&quot;:3&quot;&gt;Texas Department of Transportation. 2024. ''Grass, Weed and Wildflower Guide''. Texas Department of Transportation: Texas.&lt;/ref&gt;). Ikoroyi esikhathini esinengi itjalwa ebusika ivunwe nakuphela isilimela nanyana nakuthoma ihlobo (Texas Department of Transportation, 2024&lt;ref name=&quot;:3&quot; /&gt;). Ukungezelela, umbala wayo uhlaza okutshehla (Texas Department of Transportation, 2024&lt;ref name=&quot;:3&quot; /&gt;). Umsebenzi wekoroyi mnengi tle, njekufana nokwenza uburotho, i-owutsi kanti nokudla kweenlwana (Texas Department of Transportation, 2024&lt;ref name=&quot;:3&quot; /&gt;).

=== '''Isiphetho''' ===
Utjani ngobunye bemihlobo yeentjalo ethandwa khulu. Eminye imihlobo yotjani ithathwa njengamathuthumbo, ukudla kwefuyo kanye nokudla kwabantu. Kukhona eminye godu imihlobo yotjani leyo esetjenziswa njengemitjhoga yokwelapaha (Almusaued (2017). Kungakho kuqakathekile bona sazi begodu sizwisise imihlobo yotjani ukuze sikwazi ukuthatha ithuba nelwazi lokuyisebenzisa ekuthuthukiseni iimpilo zethu.

=== '''Umthombolwazi''' ===
&lt;references /&gt;</text>
      <sha1>irnd9i53smqb3l1ghmc85y8nvp5ifvu</sha1>
    </revision>
  </page>
  <page>
    <title>Ubuhlakani be-AI.</title>
    <ns>0</ns>
    <id>452</id>
    <revision>
      <id>2369</id>
      <timestamp>2025-01-26T11:05:09Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <comment>Created page with &quot;== Ubuhlakani be-AI. ==  === Isingeniso === Ukutjhuguluka nokukhamba kweminyaka kuletha amatjhuguluko amatjha kanye nethuthuko yokwenza izinto ngendlela ezihlukileko. Amanye amatjhugululo nethuthuko etja le, mahle; kanti kuthi amanye wawo mambi lokha nasiqala umthintela ezinawo eempilweni zabantu. I-AI ngamanye amatjhugululo nanyana ithuthuko yesikhathi esiphila kiso. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyini i-AI kanye nemihlobo ye-AI.   === Kuyini i-AI na?...&quot;</comment>
      <origin>2369</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4517" sha1="95w8olp9r917gzc28bvv7lf00dqha5x" xml:space="preserve">== Ubuhlakani be-AI. ==

=== Isingeniso ===
Ukutjhuguluka nokukhamba kweminyaka kuletha amatjhuguluko amatjha kanye nethuthuko yokwenza izinto ngendlela ezihlukileko. Amanye amatjhugululo nethuthuko etja le, mahle; kanti kuthi amanye wawo mambi lokha nasiqala umthintela ezinawo eempilweni zabantu. I-AI ngamanye amatjhugululo nanyana ithuthuko yesikhathi esiphila kiso. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyini i-AI kanye nemihlobo ye-AI. 

=== Kuyini i-AI na? ===
[[Isimumathi:Umtjhini we-IA.jpg|thumb|Umtjhini we-AI.]]
Ngokuya kuka-Ghosh no-Thirugnanam (2021:23)&lt;ref name=&quot;:0&quot;&gt;Ghosh. M. &amp; Thirugnanam, A. 2021. Introduction to Artificial Intelligence. In K. G. Srinivasa ''et al''. (eds.). 2021. Artificial Intelligence for Information Management: A Healthcare Perspective, ''Studies in Big Data,'' 88: 23-44.&lt;/ref&gt; i-AI kuligaja lesayensi yezemitjhiningqondo lelo elisebenza ngokuthi lilingisele abantu ngendlela baphila ngayo ekufaka hlangana ukuqabanga, ukuthatha iinqunto nokusebenza. U-Hadi (2023)&lt;ref name=&quot;:1&quot;&gt;Hadi, M. M. 2023. Artificial Intelligence Background, Definitions, Challenges and Benefits. ''CompuNet,'' 31:5-13.&lt;/ref&gt; ungezelele wathi i-AI le kumitjhini leyo ekghona ukufunda, ukwamukela ilwazi bese ilisebenzise ngendlela yobuhlakani. Ngamanye amagama, i-AI loke ilwazi neemfundiso enikelwe zona, iyazibulunga begodu kusasa ikghone ukuzisebenzisa ngendlela engcono. Nanyana kunjalo, eminye yemihlobo ye-AI ifuna isizo lomuntu ngombana kufanele ihlelwe bonyana izokuphila nanyana isebenze njani (Bartneck 2021&lt;ref name=&quot;:2&quot;&gt;Bartneck, C. et al. 2021. An Introduction to Ethics in Robotics and AI. ''SpringerBriefs in Ethics'':5-16.&lt;/ref&gt;).

Kukhona i-AI ebulunga idatha nanyana umniningwana weenhlangano ezikulu. Iinhlangano lezo zisuke zisebenzisa i-AI ngombana umniningwana loyo umkhulukhulu begodu abantu bazokutlhaga ukuwubulunga nokuwugadangisa ngesikhathi obekelwe sona (Hadi, 2023)&lt;ref name=&quot;:1&quot; /&gt;. Kanti abanye basebenzisa i-AI ukuze ibasize ukwenza nokwakha izinto msinya njengoba imitjhini ingahlelwa bonyana isebenze ngebelo eliphezulu ukudlula lelo abantu abangalifinyelela (Ghosh no-Thirugnanam, 2021&lt;ref name=&quot;:0&quot; /&gt;). Esihlokwaneni esizako sizokutjheja iinzuzo ye-AI.

=== Iinzuzo ye-AI. ===
I-AI isiza khulu ekurarululeni nekunikeleni imbandela mayelana nobujamo ekuqalenwe nabo ngase sikhathi ([[:en:Artificial_intelligence|Wikipedia, 2025]]&lt;ref name=&quot;:3&quot;&gt;Wikipedia. 2025. Artificial Intelligence. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Artificial_intelligence&lt;/nowiki&gt;&gt;.  Lifunyenwe [ngomhlaka 7 kuTjhirhweni 2025].&lt;/ref&gt;; [https://www.ibm.com/think/topics/artificial-intelligence IBM, 2025]&lt;ref name=&quot;:4&quot;&gt;IBM. 2025. Artificial Intelligence. Litholakala ku:&lt; &lt;nowiki&gt;https://www.ibm.com/think/topics/artificial-intelligence&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 7 kuTjhirhweni 2025].

&lt;/ref&gt;). Lokhu kwenzeka ngoba i-AI ikghoba ukukhumbula msinya izinto begodu ayikhohlwa.

Kwesibili, I-AI ikghona ukuhlela izinto kuhle begodu ilendele amagadango afunekako mayelana nento ehlelwako ngaleso sikhathi (Wikipedia 2025; IBM 2025&lt;ref name=&quot;:4&quot; /&gt;). I-AI ikghona ukuhlamunyiselela nanyana ukuqakela imiphumela bese isebenzise indlela ezokwenza bonyana kube nomphumela omuhle ngendlela okukghoneka ngayo (Wikipedia 2025).

Kokugcina, i-AI ikghona ukufunda izinto ngebelo eliphezulu begodu ifunde izinto ezinengi (Wikipedia, 2025&lt;ref name=&quot;:3&quot; /&gt;; IBM 2025&lt;ref name=&quot;:4&quot; /&gt;). Lokho kwenzeka ngombana i-AI ikghona ukuhlaziya nokutjhumutjha ilwazi kanye nekambiso lalo ngendlela okungakghonakala ngayo bese ilisebenzise ngobuhlakani. 

=== Ubungozi be-AI ===
I-AI yenza umusebenzi omuhle begodu iveza namathuba amatjha eempilweni zethu. Nanyana kunjalo, kufanele sikhumbule bonyana ayikho into etja onganabumbi nanyana ubungozi begodu i-AI nayo inabo ubumbi. Ubumbi bokuthoma kukobanyana yenza ibuyelelo lelwazi elinengi (Bartnek 2021&lt;ref name=&quot;:2&quot; /&gt;). Kwesibili, kukithi abantu bangayisebenzisa ukweba imininingwaba eqakathekileko njengomazisi, ilwazi lemabulungelwenimali kanye nokusebenzisa ilwazi lomunye umuntu ukweba (Hadi 2023&lt;ref name=&quot;:1&quot; /&gt;). 

=== Isiphetho ===
I-AI iligadango elihle lethuthuko esikhathini esiphilakiso kodwana nanyana kunjalo iletha izinga elitjha lobugebengu nobungozi. Ngalokho-ke, kuqakatheke kwamambala bonyana siyifundo begodu siyizwisise bonyana kuyini, ingasisiza njani begodu ubungozi bayo singabubalekela njani. Ngaphezulu sivezile bonyana i-AI iyini kanye neenzuzo nobungozi bayo. 

=== Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>95w8olp9r917gzc28bvv7lf00dqha5x</sha1>
    </revision>
    <revision>
      <id>2385</id>
      <parentid>2369</parentid>
      <timestamp>2025-01-28T06:15:59Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <minor />
      <origin>2385</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4518" sha1="i1ipuughox19u7eimplso9u51kqxn2r" xml:space="preserve">== Ubuhlakani be-AI. ==

=== Isingeniso ===
Ukutjhuguluka nokukhamba kweminyaka kuletha amatjhuguluko amatjha kanye nethuthuko yokwenza izinto ngendlela ezihlukileko. Amanye amatjhugululo nethuthuko etja le, mahle; kanti kuthi amanye wawo mambi lokha nasiqala umthintela ezinawo eempilweni zabantu. I-AI ngamanye amatjhugululo nanyana ithuthuko yesikhathi esiphila kiso. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyini i-AI kanye nemihlobo ye-AI. 

=== Kuyini i-AI na? ===
[[Isimumathi:Umtjhini we-IA.jpg|thumb|Umtjhini we-AI.]]
Ngokuya kuka-Ghosh no-Thirugnanam (2021:23)&lt;ref name=&quot;:0&quot;&gt;Ghosh. M. &amp; Thirugnanam, A. 2021. Introduction to Artificial Intelligence. In K. G. Srinivasa ''et al''. (eds.). 2021. Artificial Intelligence for Information Management: A Healthcare Perspective, ''Studies in Big Data,'' 88: 23-44.&lt;/ref&gt; i-AI kuligaja lesayensi yezemitjhiningqondo lelo elisebenza ngokuthi lilingisele abantu ngendlela baphila ngayo ekufaka hlangana ukuqabanga, ukuthatha iinqunto nokusebenza. U-Hadi (2023)&lt;ref name=&quot;:1&quot;&gt;Hadi, M. M. 2023. Artificial Intelligence Background, Definitions, Challenges and Benefits. ''CompuNet,'' 31:5-13.&lt;/ref&gt; ungezelele wathi i-AI le kumitjhini leyo ekghona ukufunda, ukwamukela ilwazi bese ilisebenzise ngendlela yobuhlakani. Ngamanye amagama, i-AI loke ilwazi neemfundiso enikelwe zona, iyazibulunga begodu kusasa ikghone ukuzisebenzisa ngendlela engcono. Nanyana kunjalo, eminye yemihlobo ye-AI ifuna isizo lomuntu ngombana kufanele ihlelwe bonyana izokuphila nanyana isebenze njani (Bartneck 2021&lt;ref name=&quot;:2&quot;&gt;Bartneck, C. et al. 2021. An Introduction to Ethics in Robotics and AI. ''SpringerBriefs in Ethics'':5-16.&lt;/ref&gt;).

Kukhona i-AI ebulunga idatha nanyana umniningwana weenhlangano ezikulu. Iinhlangano lezo zisuke zisebenzisa i-AI ngombana umniningwana loyo umkhulukhulu begodu abantu bazokutlhaga ukuwubulunga nokuwugadangisa ngesikhathi obekelwe sona (Hadi, 2023)&lt;ref name=&quot;:1&quot; /&gt;. Kanti abanye basebenzisa i-AI ukuze ibasize ukwenza nokwakha izinto msinya njengoba imitjhini ingahlelwa bonyana isebenze ngebelo eliphezulu ukudlula lelo abantu abangalifinyelela (Ghosh no-Thirugnanam, 2021&lt;ref name=&quot;:0&quot; /&gt;). Esihlokwaneni esizako sizokutjheja iinzuzo ye-AI.

=== Iinzuzo ye-AI. ===
I-AI isiza khulu ekurarululeni nekunikeleni imbandela mayelana nobujamo ekuqalenwe nabo ngase sikhathi ([[:en:Artificial_intelligence|Wikipedia, 2025]]&lt;ref name=&quot;:3&quot;&gt;Wikipedia. 2025. Artificial Intelligence. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Artificial_intelligence&lt;/nowiki&gt;&gt;.  Lifunyenwe [ngomhlaka 7 kuTjhirhweni 2025].&lt;/ref&gt;; [https://www.ibm.com/think/topics/artificial-intelligence IBM, 2025]&lt;ref name=&quot;:4&quot;&gt;IBM. 2025. Artificial Intelligence. Litholakala ku:&lt; &lt;nowiki&gt;https://www.ibm.com/think/topics/artificial-intelligence&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 7 kuTjhirhweni 2025].

&lt;/ref&gt;). Lokhu kwenzeka ngoba i-AI ikghoba ukukhumbula msinya izinto begodu ayikhohlwa.

Kwesibili, I-AI ikghona ukuhlela izinto kuhle begodu ilendele amagadango afunekako mayelana nento ehlelwako ngaleso sikhathi (Wikipedia 2025; IBM 2025&lt;ref name=&quot;:4&quot; /&gt;). I-AI ikghona ukuhlamunyiselela nanyana ukuqakela imiphumela bese isebenzise indlela ezokwenza bonyana kube nomphumela omuhle ngendlela okukghoneka ngayo (Wikipedia 2025).

Kokugcina, i-AI ikghona ukufunda izinto ngebelo eliphezulu begodu ifunde izinto ezinengi (Wikipedia, 2025&lt;ref name=&quot;:3&quot; /&gt;; IBM 2025&lt;ref name=&quot;:4&quot; /&gt;). Lokho kwenzeka ngombana i-AI ikghona ukuhlaziya nokutjhumutjha ilwazi kanye nekambiso lalo ngendlela okungakghonakala ngayo bese ilisebenzise ngobuhlakani. 

=== Ubungozi be-AI. ===
I-AI yenza umusebenzi omuhle begodu iveza namathuba amatjha eempilweni zethu. Nanyana kunjalo, kufanele sikhumbule bonyana ayikho into etja onganabumbi nanyana ubungozi begodu i-AI nayo inabo ubumbi. Ubumbi bokuthoma kukobanyana yenza ibuyelelo lelwazi elinengi (Bartnek 2021&lt;ref name=&quot;:2&quot; /&gt;). Kwesibili, kukithi abantu bangayisebenzisa ukweba imininingwaba eqakathekileko njengomazisi, ilwazi lemabulungelwenimali kanye nokusebenzisa ilwazi lomunye umuntu ukweba (Hadi 2023&lt;ref name=&quot;:1&quot; /&gt;). 

=== Isiphetho ===
I-AI iligadango elihle lethuthuko esikhathini esiphilakiso kodwana nanyana kunjalo iletha izinga elitjha lobugebengu nobungozi. Ngalokho-ke, kuqakatheke kwamambala bonyana siyifundo begodu siyizwisise bonyana kuyini, ingasisiza njani begodu ubungozi bayo singabubalekela njani. Ngaphezulu sivezile bonyana i-AI iyini kanye neenzuzo nobungozi bayo. 

=== Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>i1ipuughox19u7eimplso9u51kqxn2r</sha1>
    </revision>
    <revision>
      <id>2998</id>
      <parentid>2385</parentid>
      <timestamp>2025-06-06T20:18:24Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>mujynhtbgrvfced</comment>
      <origin>2998</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4606" sha1="fno0jeawvvuvnhhvrr6hxoew52qlvau" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.'''

== Ubuhlakani be-AI. ==

=== Isingeniso ===
Ukutjhuguluka nokukhamba kweminyaka kuletha amatjhuguluko amatjha kanye nethuthuko yokwenza izinto ngendlela ezihlukileko. Amanye amatjhugululo nethuthuko etja le, mahle; kanti kuthi amanye wawo mambi lokha nasiqala umthintela ezinawo eempilweni zabantu. I-AI ngamanye amatjhugululo nanyana ithuthuko yesikhathi esiphila kiso. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyini i-AI kanye nemihlobo ye-AI. 

=== Kuyini i-AI na? ===
[[Isimumathi:Umtjhini we-IA.jpg|thumb|Umtjhini we-AI.]]
Ngokuya kuka-Ghosh no-Thirugnanam (2021:23)&lt;ref name=&quot;:0&quot;&gt;Ghosh. M. &amp; Thirugnanam, A. 2021. Introduction to Artificial Intelligence. In K. G. Srinivasa ''et al''. (eds.). 2021. Artificial Intelligence for Information Management: A Healthcare Perspective, ''Studies in Big Data,'' 88: 23-44.&lt;/ref&gt; i-AI kuligaja lesayensi yezemitjhiningqondo lelo elisebenza ngokuthi lilingisele abantu ngendlela baphila ngayo ekufaka hlangana ukuqabanga, ukuthatha iinqunto nokusebenza. U-Hadi (2023)&lt;ref name=&quot;:1&quot;&gt;Hadi, M. M. 2023. Artificial Intelligence Background, Definitions, Challenges and Benefits. ''CompuNet,'' 31:5-13.&lt;/ref&gt; ungezelele wathi i-AI le kumitjhini leyo ekghona ukufunda, ukwamukela ilwazi bese ilisebenzise ngendlela yobuhlakani. Ngamanye amagama, i-AI loke ilwazi neemfundiso enikelwe zona, iyazibulunga begodu kusasa ikghone ukuzisebenzisa ngendlela engcono. Nanyana kunjalo, eminye yemihlobo ye-AI ifuna isizo lomuntu ngombana kufanele ihlelwe bonyana izokuphila nanyana isebenze njani (Bartneck 2021&lt;ref name=&quot;:2&quot;&gt;Bartneck, C. et al. 2021. An Introduction to Ethics in Robotics and AI. ''SpringerBriefs in Ethics'':5-16.&lt;/ref&gt;).

Kukhona i-AI ebulunga idatha nanyana umniningwana weenhlangano ezikulu. Iinhlangano lezo zisuke zisebenzisa i-AI ngombana umniningwana loyo umkhulukhulu begodu abantu bazokutlhaga ukuwubulunga nokuwugadangisa ngesikhathi obekelwe sona (Hadi, 2023)&lt;ref name=&quot;:1&quot; /&gt;. Kanti abanye basebenzisa i-AI ukuze ibasize ukwenza nokwakha izinto msinya njengoba imitjhini ingahlelwa bonyana isebenze ngebelo eliphezulu ukudlula lelo abantu abangalifinyelela (Ghosh no-Thirugnanam, 2021&lt;ref name=&quot;:0&quot; /&gt;). Esihlokwaneni esizako sizokutjheja iinzuzo ye-AI.

=== Iinzuzo ye-AI. ===
I-AI isiza khulu ekurarululeni nekunikeleni imbandela mayelana nobujamo ekuqalenwe nabo ngase sikhathi ([[:en:Artificial_intelligence|Wikipedia, 2025]]&lt;ref name=&quot;:3&quot;&gt;Wikipedia. 2025. Artificial Intelligence. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Artificial_intelligence&lt;/nowiki&gt;&gt;.  Lifunyenwe [ngomhlaka 7 kuTjhirhweni 2025].&lt;/ref&gt;; [https://www.ibm.com/think/topics/artificial-intelligence IBM, 2025]&lt;ref name=&quot;:4&quot;&gt;IBM. 2025. Artificial Intelligence. Litholakala ku:&lt; &lt;nowiki&gt;https://www.ibm.com/think/topics/artificial-intelligence&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 7 kuTjhirhweni 2025].

&lt;/ref&gt;). Lokhu kwenzeka ngoba i-AI ikghoba ukukhumbula msinya izinto begodu ayikhohlwa.

Kwesibili, I-AI ikghona ukuhlela izinto kuhle begodu ilendele amagadango afunekako mayelana nento ehlelwako ngaleso sikhathi (Wikipedia 2025; IBM 2025&lt;ref name=&quot;:4&quot; /&gt;). I-AI ikghona ukuhlamunyiselela nanyana ukuqakela imiphumela bese isebenzise indlela ezokwenza bonyana kube nomphumela omuhle ngendlela okukghoneka ngayo (Wikipedia 2025).

Kokugcina, i-AI ikghona ukufunda izinto ngebelo eliphezulu begodu ifunde izinto ezinengi (Wikipedia, 2025&lt;ref name=&quot;:3&quot; /&gt;; IBM 2025&lt;ref name=&quot;:4&quot; /&gt;). Lokho kwenzeka ngombana i-AI ikghona ukuhlaziya nokutjhumutjha ilwazi kanye nekambiso lalo ngendlela okungakghonakala ngayo bese ilisebenzise ngobuhlakani. 

=== Ubungozi be-AI. ===
I-AI yenza umusebenzi omuhle begodu iveza namathuba amatjha eempilweni zethu. Nanyana kunjalo, kufanele sikhumbule bonyana ayikho into etja onganabumbi nanyana ubungozi begodu i-AI nayo inabo ubumbi. Ubumbi bokuthoma kukobanyana yenza ibuyelelo lelwazi elinengi (Bartnek 2021&lt;ref name=&quot;:2&quot; /&gt;). Kwesibili, kukithi abantu bangayisebenzisa ukweba imininingwaba eqakathekileko njengomazisi, ilwazi lemabulungelwenimali kanye nokusebenzisa ilwazi lomunye umuntu ukweba (Hadi 2023&lt;ref name=&quot;:1&quot; /&gt;). 

=== Isiphetho ===
I-AI iligadango elihle lethuthuko esikhathini esiphilakiso kodwana nanyana kunjalo iletha izinga elitjha lobugebengu nobungozi. Ngalokho-ke, kuqakatheke kwamambala bonyana siyifundo begodu siyizwisise bonyana kuyini, ingasisiza njani begodu ubungozi bayo singabubalekela njani. Ngaphezulu sivezile bonyana i-AI iyini kanye neenzuzo nobungozi bayo. 

=== Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>fno0jeawvvuvnhhvrr6hxoew52qlvau</sha1>
    </revision>
    <revision>
      <id>3055</id>
      <parentid>2998</parentid>
      <timestamp>2025-06-07T03:05:22Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Owaziwako|Owaziwako]]</comment>
      <origin>2385</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4518" sha1="i1ipuughox19u7eimplso9u51kqxn2r" xml:space="preserve">== Ubuhlakani be-AI. ==

=== Isingeniso ===
Ukutjhuguluka nokukhamba kweminyaka kuletha amatjhuguluko amatjha kanye nethuthuko yokwenza izinto ngendlela ezihlukileko. Amanye amatjhugululo nethuthuko etja le, mahle; kanti kuthi amanye wawo mambi lokha nasiqala umthintela ezinawo eempilweni zabantu. I-AI ngamanye amatjhugululo nanyana ithuthuko yesikhathi esiphila kiso. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyini i-AI kanye nemihlobo ye-AI. 

=== Kuyini i-AI na? ===
[[Isimumathi:Umtjhini we-IA.jpg|thumb|Umtjhini we-AI.]]
Ngokuya kuka-Ghosh no-Thirugnanam (2021:23)&lt;ref name=&quot;:0&quot;&gt;Ghosh. M. &amp; Thirugnanam, A. 2021. Introduction to Artificial Intelligence. In K. G. Srinivasa ''et al''. (eds.). 2021. Artificial Intelligence for Information Management: A Healthcare Perspective, ''Studies in Big Data,'' 88: 23-44.&lt;/ref&gt; i-AI kuligaja lesayensi yezemitjhiningqondo lelo elisebenza ngokuthi lilingisele abantu ngendlela baphila ngayo ekufaka hlangana ukuqabanga, ukuthatha iinqunto nokusebenza. U-Hadi (2023)&lt;ref name=&quot;:1&quot;&gt;Hadi, M. M. 2023. Artificial Intelligence Background, Definitions, Challenges and Benefits. ''CompuNet,'' 31:5-13.&lt;/ref&gt; ungezelele wathi i-AI le kumitjhini leyo ekghona ukufunda, ukwamukela ilwazi bese ilisebenzise ngendlela yobuhlakani. Ngamanye amagama, i-AI loke ilwazi neemfundiso enikelwe zona, iyazibulunga begodu kusasa ikghone ukuzisebenzisa ngendlela engcono. Nanyana kunjalo, eminye yemihlobo ye-AI ifuna isizo lomuntu ngombana kufanele ihlelwe bonyana izokuphila nanyana isebenze njani (Bartneck 2021&lt;ref name=&quot;:2&quot;&gt;Bartneck, C. et al. 2021. An Introduction to Ethics in Robotics and AI. ''SpringerBriefs in Ethics'':5-16.&lt;/ref&gt;).

Kukhona i-AI ebulunga idatha nanyana umniningwana weenhlangano ezikulu. Iinhlangano lezo zisuke zisebenzisa i-AI ngombana umniningwana loyo umkhulukhulu begodu abantu bazokutlhaga ukuwubulunga nokuwugadangisa ngesikhathi obekelwe sona (Hadi, 2023)&lt;ref name=&quot;:1&quot; /&gt;. Kanti abanye basebenzisa i-AI ukuze ibasize ukwenza nokwakha izinto msinya njengoba imitjhini ingahlelwa bonyana isebenze ngebelo eliphezulu ukudlula lelo abantu abangalifinyelela (Ghosh no-Thirugnanam, 2021&lt;ref name=&quot;:0&quot; /&gt;). Esihlokwaneni esizako sizokutjheja iinzuzo ye-AI.

=== Iinzuzo ye-AI. ===
I-AI isiza khulu ekurarululeni nekunikeleni imbandela mayelana nobujamo ekuqalenwe nabo ngase sikhathi ([[:en:Artificial_intelligence|Wikipedia, 2025]]&lt;ref name=&quot;:3&quot;&gt;Wikipedia. 2025. Artificial Intelligence. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Artificial_intelligence&lt;/nowiki&gt;&gt;.  Lifunyenwe [ngomhlaka 7 kuTjhirhweni 2025].&lt;/ref&gt;; [https://www.ibm.com/think/topics/artificial-intelligence IBM, 2025]&lt;ref name=&quot;:4&quot;&gt;IBM. 2025. Artificial Intelligence. Litholakala ku:&lt; &lt;nowiki&gt;https://www.ibm.com/think/topics/artificial-intelligence&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 7 kuTjhirhweni 2025].

&lt;/ref&gt;). Lokhu kwenzeka ngoba i-AI ikghoba ukukhumbula msinya izinto begodu ayikhohlwa.

Kwesibili, I-AI ikghona ukuhlela izinto kuhle begodu ilendele amagadango afunekako mayelana nento ehlelwako ngaleso sikhathi (Wikipedia 2025; IBM 2025&lt;ref name=&quot;:4&quot; /&gt;). I-AI ikghona ukuhlamunyiselela nanyana ukuqakela imiphumela bese isebenzise indlela ezokwenza bonyana kube nomphumela omuhle ngendlela okukghoneka ngayo (Wikipedia 2025).

Kokugcina, i-AI ikghona ukufunda izinto ngebelo eliphezulu begodu ifunde izinto ezinengi (Wikipedia, 2025&lt;ref name=&quot;:3&quot; /&gt;; IBM 2025&lt;ref name=&quot;:4&quot; /&gt;). Lokho kwenzeka ngombana i-AI ikghona ukuhlaziya nokutjhumutjha ilwazi kanye nekambiso lalo ngendlela okungakghonakala ngayo bese ilisebenzise ngobuhlakani. 

=== Ubungozi be-AI. ===
I-AI yenza umusebenzi omuhle begodu iveza namathuba amatjha eempilweni zethu. Nanyana kunjalo, kufanele sikhumbule bonyana ayikho into etja onganabumbi nanyana ubungozi begodu i-AI nayo inabo ubumbi. Ubumbi bokuthoma kukobanyana yenza ibuyelelo lelwazi elinengi (Bartnek 2021&lt;ref name=&quot;:2&quot; /&gt;). Kwesibili, kukithi abantu bangayisebenzisa ukweba imininingwaba eqakathekileko njengomazisi, ilwazi lemabulungelwenimali kanye nokusebenzisa ilwazi lomunye umuntu ukweba (Hadi 2023&lt;ref name=&quot;:1&quot; /&gt;). 

=== Isiphetho ===
I-AI iligadango elihle lethuthuko esikhathini esiphilakiso kodwana nanyana kunjalo iletha izinga elitjha lobugebengu nobungozi. Ngalokho-ke, kuqakatheke kwamambala bonyana siyifundo begodu siyizwisise bonyana kuyini, ingasisiza njani begodu ubungozi bayo singabubalekela njani. Ngaphezulu sivezile bonyana i-AI iyini kanye neenzuzo nobungozi bayo. 

=== Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>i1ipuughox19u7eimplso9u51kqxn2r</sha1>
    </revision>
    <revision>
      <id>5941</id>
      <parentid>3055</parentid>
      <timestamp>2025-11-01T12:09:03Z</timestamp>
      <contributor>
        <username>Hlalithwa</username>
        <id>996</id>
      </contributor>
      <minor />
      <comment>Spelling</comment>
      <origin>5941</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4522" sha1="rsbvtiqfsxrid74i84du3sgqe9x4nhs" xml:space="preserve">== Ubuhlakani be-AI. ==

=== Isingeniso ===
Ukutjhuguluka nokukhamba kweminyaka kuletha amatjhuguluko amatjha kanye nethuthuko yokwenza izinto ngendlela ezihlukileko. Amanye amatjhuguluko nethuthuko etja le, mahle; kanti kuthi amanye wawo mambi lokha nasiqala umthelela ezinawo eempilweni zabantu. I-AI ngamanye amatjhugululo nanyana ithuthuko yesikhathi esiphila kiso. Eenhlokwaneni ezilandelako sizokutjheja bonyana khuyini i-AI kanye nemihlobo ye-AI. 

=== Kuyini i-AI na? ===
[[Isimumathi:Umtjhini we-IA.jpg|thumb|Umtjhini we-AI.]]
Ngokuya kuka-Ghosh no-Thirugnanam (2021:23)&lt;ref name=&quot;:0&quot;&gt;Ghosh. M. &amp; Thirugnanam, A. 2021. Introduction to Artificial Intelligence. In K. G. Srinivasa ''et al''. (eds.). 2021. Artificial Intelligence for Information Management: A Healthcare Perspective, ''Studies in Big Data,'' 88: 23-44.&lt;/ref&gt; i-AI kuligaja lesayensi yezemitjhiningqondo lelo elisebenza ngokuthi lilingisele abantu ngendlela abaphila ngayo ekufaka hlangana ukuqabanga, ukuthatha iinqunto nokusebenza. U-Hadi (2023)&lt;ref name=&quot;:1&quot;&gt;Hadi, M. M. 2023. Artificial Intelligence Background, Definitions, Challenges and Benefits. ''CompuNet,'' 31:5-13.&lt;/ref&gt; ungezelele wathi i-AI le kumitjhini leyo ekghona ukufunda, ukwamukela ilwazi bese ilisebenzise ngendlela yobuhlakani. Ngamanye amagama, i-AI loke ilwazi neemfundiso enikelwe zona, iyazibulunga begodu kusasa ikghone ukuzisebenzisa ngendlela engcono. Nanyana kunjalo, eminye yemihlobo ye-AI ifuna isizo lomuntu ngombana kufanele ihlelwe bonyana izokuphila nanyana isebenze njani (Bartneck 2021&lt;ref name=&quot;:2&quot;&gt;Bartneck, C. et al. 2021. An Introduction to Ethics in Robotics and AI. ''SpringerBriefs in Ethics'':5-16.&lt;/ref&gt;).

Kukhona i-AI ebulunga idatha nanyana umniningwana weenhlangano ezikulu. Iinhlangano lezo zisuke zisebenzisa i-AI ngombana umniningwana loyo umkhulukhulu begodu abantu bazokutlhaga ukuwubulunga nokuwugadangisa ngesikhathi obekelwe sona (Hadi, 2023)&lt;ref name=&quot;:1&quot; /&gt;. Kanti abanye basebenzisa i-AI ukuze ibasize ukwenza nokwakha izinto msinya njengoba imitjhini ingahlelwa bonyana isebenze ngebelo eliphezulu ukudlula lelo abantu abangalifinyelela (Ghosh no-Thirugnanam, 2021&lt;ref name=&quot;:0&quot; /&gt;). Esihlokwaneni esizako sizokutjheja iinzuzo ye-AI.

=== Iinzuzo ye-AI. ===
I-AI isiza khulu ekurarululeni nekunikeleni imbandela mayelana nobujamo ekuqalenwe nabo esikhathini sanje ([[:en:Artificial_intelligence|Wikipedia, 2025]]&lt;ref name=&quot;:3&quot;&gt;Wikipedia. 2025. Artificial Intelligence. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Artificial_intelligence&lt;/nowiki&gt;&gt;.  Lifunyenwe [ngomhlaka 7 kuTjhirhweni 2025].&lt;/ref&gt;; [https://www.ibm.com/think/topics/artificial-intelligence IBM, 2025]&lt;ref name=&quot;:4&quot;&gt;IBM. 2025. Artificial Intelligence. Litholakala ku:&lt; &lt;nowiki&gt;https://www.ibm.com/think/topics/artificial-intelligence&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 7 kuTjhirhweni 2025].

&lt;/ref&gt;). Lokhu kwenzeka ngoba i-AI ikghoba ukukhumbula msinya izinto begodu ayikhohlwa.

Kwesibili, I-AI ikghona ukuhlela izinto kuhle begodu ilandele amagadango afunekako mayelana nento ehlelwako ngaleso sikhathi (Wikipedia 2025; IBM 2025&lt;ref name=&quot;:4&quot; /&gt;). I-AI ikghona ukuhlamunyiselela nanyana ukuqakela imiphumela bese isebenzise indlela ezokwenza bonyana kube nomphumela omuhle ngendlela okukghoneka ngayo (Wikipedia 2025).

Kokugcina, i-AI ikghona ukufunda izinto ngebelo eliphezulu begodu ifunde izinto ezinengi (Wikipedia, 2025&lt;ref name=&quot;:3&quot; /&gt;; IBM 2025&lt;ref name=&quot;:4&quot; /&gt;). Lokho kwenzeka ngombana i-AI ikghona ukuhlaziya nokutjhumutjha ilwazi kanye nekambiso lalo ngendlela okungakghonakala ngayo bese ilisebenzise ngobuhlakani. 

=== Ubungozi be-AI. ===
I-AI yenza umusebenzi omuhle begodu iveza namathuba amatjha eempilweni zethu. Nanyana kunjalo, kufanele sikhumbule bonyana ayikho into etja enganabumbi nanyana ubungozi begodu i-AI nayo inabo ubumbi. Ubumbi bokuthoma kukobanyana yenza ibuyelelo lelwazi elinengi (Bartnek 2021&lt;ref name=&quot;:2&quot; /&gt;). Kwesibili, kukuthi abantu bangayisebenzisa ukweba imininingwaba eqakathekileko njengomazisi, ilwazi lemabulungelwenimali kanye nokusebenzisa ilwazi lomunye umuntu ukweba (Hadi 2023&lt;ref name=&quot;:1&quot; /&gt;). 

=== Isiphetho ===
I-AI iligadango elihle lethuthuko esikhathini esiphilakiso kodwana nanyana kunjalo iletha izinga elitjha lobugebengu nobungozi. Ngalokho-ke, kuqakatheke kwamambala bonyana siyifunde begodu siyizwisise bonyana kuyini, ingasisiza njani begodu ubungozi bayo singabubalekela njani. Ngaphezulu sivezile bonyana i-AI iyini kanye neenzuzo nobungozi bayo. 

=== Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>rsbvtiqfsxrid74i84du3sgqe9x4nhs</sha1>
    </revision>
  </page>
  <page>
    <title>Amakhotho wethu</title>
    <ns>0</ns>
    <id>453</id>
    <revision>
      <id>2370</id>
      <timestamp>2025-01-26T12:49:06Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <comment>Created page with &quot;== Amakhotho wethu. ==  === Isingeniso === Emhlabeni lo esiphila kiwo, siphila nabantu ababuya eendaweni ezahlukeneko begodu abasebenza ngeendlela ezahlukeneko. Kodwana, ukuze woke umuntu aphile ngokuthula, ukuhloniphana nokusebenzisana kufanele kube nemithetho nemigomo leyo ezokulandelwa. Imithetho nemigomo leyo itjhetjwa makhotho bonyana ilandelwe kuhle na. Eenhlokwaneni ezilandelako zizokutjheja bonyana kuyini ikhotho begodu nemihlobo yamakhotho.  === Kuyini ikhotho n...&quot;</comment>
      <origin>2370</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5978" sha1="l43oivmss2efnzfo2einf8wl426aupq" xml:space="preserve">== Amakhotho wethu. ==

=== Isingeniso ===
Emhlabeni lo esiphila kiwo, siphila nabantu ababuya eendaweni ezahlukeneko begodu abasebenza ngeendlela ezahlukeneko. Kodwana, ukuze woke umuntu aphile ngokuthula, ukuhloniphana nokusebenzisana kufanele kube nemithetho nemigomo leyo ezokulandelwa. Imithetho nemigomo leyo itjhetjwa makhotho bonyana ilandelwe kuhle na. Eenhlokwaneni ezilandelako zizokutjheja bonyana kuyini ikhotho begodu nemihlobo yamakhotho.

=== Kuyini ikhotho na? ===
Ngokuya kuka-Meyerson (2019)&lt;ref&gt;Meyerson, D. 2019. ''What is a Court of Law?'' UNSW Law Journal, 42(1):60-90.&lt;/ref&gt; asekelwa yi-[https://www.findlaw.com/litigation/legal-system/what-is-a-court.html Find Law (2025)]&lt;ref&gt;Find Law. 2024. ''What is a court?'' Litholaka ku:&lt; &lt;nowiki&gt;https://www.findlaw.com/litigation/legal-system/what-is-a-court.html&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 7 kuTjhirhweni 2025]. &lt;/ref&gt; ikhotho kuliziko lombuso langakomthetho lelo eliqalelene nemithetho. I-[[:en:Court|Wikipedia (2025)]]&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2025. ''Court''. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Court&lt;/nowiki&gt;&gt;.  Lifunyenwe [ngomhlaka 7 kuTjhirhweni 2025].&lt;/ref&gt; ingezelele yathi ikhotho liziko lombuso lelo eligunyazwe begodu elinamandla wokulamula iiindaba eziphathelene nomthetho hlangana kweenhlangahlangano, abantu, amabubululo nombuso imbala. Ngamanye amagama, ikhokho kusigungu leso esilamula imiraro yomphakathi ngokusebenzi imithetho yenarha. 

Ikhotho kanengi, ingasi soke isikhathi, yakhiwe ngamajaji, abatjhutjhisi, abajameli nabanye abasebenzi abasekeli bekambiso yekhotho (Wikipedia, 2025)&lt;ref name=&quot;:0&quot; /&gt;. Boke abantu ababalwe ngehla laba, ngibo ebenza isiqiniseko sokuthi yoke into ekhotho ikhamba kuhle ngokulandela imigomo nekambiso yayo. Esihlokwaneni esilandelako sizokutjheja imihlobo yamakhotho.

=== Imihlobo yamakhotho ===
Nasitjheja ngenarheni yethu, iSewula Afrika, sinemihlobo embalwa yamakhotho begodu nemisebenzi yayo iyahluka. Umhlobo wokuthoma ngilo:

==== Ikhotho yo[[Umthethosisekelo|mthethosisekelo]] ====
Ikhotho yomthethosisekelo yikhotho ekulu kunazo zoke eSewula Afrika begodu kanengi itjheja iindaba eziphathelele nomthethosisekelo, imithethomlingwa nepalamende ([https://www.judiciary.org.za/index.php/the-south-african-judicial-system Judiciary of South Africa, 2025]&lt;ref name=&quot;:1&quot;&gt;Judiciary of South Africa. 2025. ''The South African Judicial System''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.judiciary.org.za/index.php/the-south-african-judicial-system&lt;/nowiki&gt;&gt;.   Lifunyenwe [ngomhlaka 7 kuTjhirhweni 2025].&lt;/ref&gt;). Ikhotho le ukuze iragele phambili nokulalelwa kweqala, kufanele kube namajaji abunane (8) ubuncani. Kodwana amajaji la nakhapheleleko alitjhumi nanye (11) [Judiciary of South Africa, 2025]. Ikhotho le isebenza njengekhotho yeenghongoyilo begodu ayilaleli ubufakazi nanyana ihlome ufakazi ngemibuzo; kodwana isebenzisa ufufakazi lobu obalalelwa ekhetho yangaphambilini ngaphambi kokuthi iqala lilethwe kuyo (Judiciary of South Africa, 2025).

==== Ikhotho ekulu yeenghonghoyilo ====
Ikhotho ekulu yeenghonghoyilo khotho ekulu kunazo zoke ngaphandle kwekhotho yomthethosisekelo (Judiciary of South Africa, 2025&lt;ref name=&quot;:1&quot; /&gt;). Ikhotho le iqalana namaqala lawo abuya ekhotho ephakemeko, begodu itjheja woke amaqala ngaphandle kwamaqala aphathelene nezemisebenzi kanye nephaliswano (Judiciary of South Africa, 2025). Ayikho ikhotho engatjhugulula isiqunto sayo, ngaphandle kwekhotho yomthethosisekelo (Judiciary of South Africa, 2025). Ikhotho le kufanele ibe namajaji amathathu ukuya kwamahlanu ukuze ikghone ukulalela iqala (Judiciary of South Africa, 2025&lt;ref name=&quot;:1&quot; /&gt;).

==== Ikhotho ephakemeko ====
Ikhotho ephakemeko yikhotho esebenza ngokuqintelwa nanyana ngokuya kwendawo nanyana isifunda la inzize khona (Judiciary of South Africa, 2025&lt;ref name=&quot;:1&quot; /&gt;). Ngamanye amagama iqala elibuya ekhotho kamarhastrada weMalahleni (eMpumalanga) angeze ladluliselwa ekhotho ephakemeko yeTlhagwini Kapa. ESewula Afrika sinamakhotho aphakemeko ali-13. Isifunda seMpumalanga sisengakabi nekhotho ephakemeko esebenzako, kanti isifunda seGauteng nesaKwaZulu Natal zinamakhotho amabili ngesifunda ngasinye, ekubeni ezinye iimfunda zinekhotho ephakemeko ngayinye ngesifunda (Judiciary of South Africa, 2025).

Nanyana kunjalo, kukhona amakhotho ekhethekileko lawo aqala namaqala ekhethikileko kwaphela. Amakhotho lawo ngila (Judiciary of South Africa, 2025&lt;ref name=&quot;:1&quot; /&gt;):

-         Ikhotho yezemisebenzise neenghonghoyilo zemisebenzi, leyo eqalana namaqala wezemisebenzi kanye neenghonghoyilo zawo.

-         Ikhotho yeembawo zenarha, leyo eqala neendaba eziphathelene nenarha.

-         Ikhotho yeenghonghoyilo zephaliswano, leyo eqalelene namaqala abuya kusigungu sephaliswano.

-         Ikhotho yamakhetho leyo eqalelene namaqala wamakhetho kwaphela.

-         Ikhotho yomthelo, leyo eqalelene namaqala aphathelene nomthelo.

==== Ikhotho kamarhastrada ====
Ikhotho kamarhastrada yikhotho leyo eba seemphakahthini nanyana endaweni zemakhaya begodu ihlukaniswe Kabili. Kukhona ikhotho yesiyingi nekhotho ejwayelekileko nanyana yesifunda. Ikhotho yesiyingi, kuyikhotho leyo eqalana namaqala wobulelesi, bese kuthi ikhotho yesifunda nanyana ejwayelekileko iqalane namaqala wobugebengu nomphakathi (Center for Court Innovation, 2011&lt;ref&gt;Center for Court Innovation. 2011. ''What is a Community Court?'' Bureau of Justice Assistance: U.S Department of Justice.&lt;/ref&gt;).

=== Isiphetho ===
Amakhotho ziindawo eziqakathekileko lezo ezenza bonyana sibabantu siphililsane ngokuthula. Nanyana kunjalo, kuyenzeka bonyana ezinye iinqunto zitjharaganise izinto ukuya phambili ngebanga lemithetho nokurhumutjha izehlakalo zamaqala alethwe kibo. Ngehla sitjheje woke amakhotho esinawo eSewula Afrika ngaphandle kwamakhotho wabadosiphambili bendabuko. Kodwana, esikhathi esizako sizokutjheja amakhotho wendabuko awodwa ngebanga lokukhetheka kwawo kunamakhotho la wesikhuwa.

=== Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>l43oivmss2efnzfo2einf8wl426aupq</sha1>
    </revision>
    <revision>
      <id>2386</id>
      <parentid>2370</parentid>
      <timestamp>2025-01-28T06:16:41Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <minor />
      <origin>2386</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5979" sha1="dfea0qw6jgywnsaebu1g275lnm24vmj" xml:space="preserve">== Amakhotho wethu. ==

=== Isingeniso ===
Emhlabeni lo esiphila kiwo, siphila nabantu ababuya eendaweni ezahlukeneko begodu abasebenza ngeendlela ezahlukeneko. Kodwana, ukuze woke umuntu aphile ngokuthula, ukuhloniphana nokusebenzisana kufanele kube nemithetho nemigomo leyo ezokulandelwa. Imithetho nemigomo leyo itjhetjwa makhotho bonyana ilandelwe kuhle na. Eenhlokwaneni ezilandelako zizokutjheja bonyana kuyini ikhotho begodu nemihlobo yamakhotho.

=== Kuyini ikhotho na? ===
Ngokuya kuka-Meyerson (2019)&lt;ref&gt;Meyerson, D. 2019. ''What is a Court of Law?'' UNSW Law Journal, 42(1):60-90.&lt;/ref&gt; asekelwa yi-[https://www.findlaw.com/litigation/legal-system/what-is-a-court.html Find Law (2025)]&lt;ref&gt;Find Law. 2024. ''What is a court?'' Litholaka ku:&lt; &lt;nowiki&gt;https://www.findlaw.com/litigation/legal-system/what-is-a-court.html&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 7 kuTjhirhweni 2025]. &lt;/ref&gt; ikhotho kuliziko lombuso langakomthetho lelo eliqalelene nemithetho. I-[[:en:Court|Wikipedia (2025)]]&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2025. ''Court''. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Court&lt;/nowiki&gt;&gt;.  Lifunyenwe [ngomhlaka 7 kuTjhirhweni 2025].&lt;/ref&gt; ingezelele yathi ikhotho liziko lombuso lelo eligunyazwe begodu elinamandla wokulamula iiindaba eziphathelene nomthetho hlangana kweenhlangahlangano, abantu, amabubululo nombuso imbala. Ngamanye amagama, ikhokho kusigungu leso esilamula imiraro yomphakathi ngokusebenzi imithetho yenarha. 

Ikhotho kanengi, ingasi soke isikhathi, yakhiwe ngamajaji, abatjhutjhisi, abajameli nabanye abasebenzi abasekeli bekambiso yekhotho (Wikipedia, 2025)&lt;ref name=&quot;:0&quot; /&gt;. Boke abantu ababalwe ngehla laba, ngibo ebenza isiqiniseko sokuthi yoke into ekhotho ikhamba kuhle ngokulandela imigomo nekambiso yayo. Esihlokwaneni esilandelako sizokutjheja imihlobo yamakhotho.

=== Imihlobo yamakhotho. ===
Nasitjheja ngenarheni yethu, iSewula Afrika, sinemihlobo embalwa yamakhotho begodu nemisebenzi yayo iyahluka. Umhlobo wokuthoma ngilo:

==== Ikhotho yo[[Umthethosisekelo|mthethosisekelo]] ====
Ikhotho yomthethosisekelo yikhotho ekulu kunazo zoke eSewula Afrika begodu kanengi itjheja iindaba eziphathelele nomthethosisekelo, imithethomlingwa nepalamende ([https://www.judiciary.org.za/index.php/the-south-african-judicial-system Judiciary of South Africa, 2025]&lt;ref name=&quot;:1&quot;&gt;Judiciary of South Africa. 2025. ''The South African Judicial System''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.judiciary.org.za/index.php/the-south-african-judicial-system&lt;/nowiki&gt;&gt;.   Lifunyenwe [ngomhlaka 7 kuTjhirhweni 2025].&lt;/ref&gt;). Ikhotho le ukuze iragele phambili nokulalelwa kweqala, kufanele kube namajaji abunane (8) ubuncani. Kodwana amajaji la nakhapheleleko alitjhumi nanye (11) [Judiciary of South Africa, 2025]. Ikhotho le isebenza njengekhotho yeenghongoyilo begodu ayilaleli ubufakazi nanyana ihlome ufakazi ngemibuzo; kodwana isebenzisa ufufakazi lobu obalalelwa ekhetho yangaphambilini ngaphambi kokuthi iqala lilethwe kuyo (Judiciary of South Africa, 2025).

==== Ikhotho ekulu yeenghonghoyilo ====
Ikhotho ekulu yeenghonghoyilo khotho ekulu kunazo zoke ngaphandle kwekhotho yomthethosisekelo (Judiciary of South Africa, 2025&lt;ref name=&quot;:1&quot; /&gt;). Ikhotho le iqalana namaqala lawo abuya ekhotho ephakemeko, begodu itjheja woke amaqala ngaphandle kwamaqala aphathelene nezemisebenzi kanye nephaliswano (Judiciary of South Africa, 2025). Ayikho ikhotho engatjhugulula isiqunto sayo, ngaphandle kwekhotho yomthethosisekelo (Judiciary of South Africa, 2025). Ikhotho le kufanele ibe namajaji amathathu ukuya kwamahlanu ukuze ikghone ukulalela iqala (Judiciary of South Africa, 2025&lt;ref name=&quot;:1&quot; /&gt;).

==== Ikhotho ephakemeko ====
Ikhotho ephakemeko yikhotho esebenza ngokuqintelwa nanyana ngokuya kwendawo nanyana isifunda la inzize khona (Judiciary of South Africa, 2025&lt;ref name=&quot;:1&quot; /&gt;). Ngamanye amagama iqala elibuya ekhotho kamarhastrada weMalahleni (eMpumalanga) angeze ladluliselwa ekhotho ephakemeko yeTlhagwini Kapa. ESewula Afrika sinamakhotho aphakemeko ali-13. Isifunda seMpumalanga sisengakabi nekhotho ephakemeko esebenzako, kanti isifunda seGauteng nesaKwaZulu Natal zinamakhotho amabili ngesifunda ngasinye, ekubeni ezinye iimfunda zinekhotho ephakemeko ngayinye ngesifunda (Judiciary of South Africa, 2025).

Nanyana kunjalo, kukhona amakhotho ekhethekileko lawo aqala namaqala ekhethikileko kwaphela. Amakhotho lawo ngila (Judiciary of South Africa, 2025&lt;ref name=&quot;:1&quot; /&gt;):

-         Ikhotho yezemisebenzise neenghonghoyilo zemisebenzi, leyo eqalana namaqala wezemisebenzi kanye neenghonghoyilo zawo.

-         Ikhotho yeembawo zenarha, leyo eqala neendaba eziphathelene nenarha.

-         Ikhotho yeenghonghoyilo zephaliswano, leyo eqalelene namaqala abuya kusigungu sephaliswano.

-         Ikhotho yamakhetho leyo eqalelene namaqala wamakhetho kwaphela.

-         Ikhotho yomthelo, leyo eqalelene namaqala aphathelene nomthelo.

==== Ikhotho kamarhastrada ====
Ikhotho kamarhastrada yikhotho leyo eba seemphakahthini nanyana endaweni zemakhaya begodu ihlukaniswe Kabili. Kukhona ikhotho yesiyingi nekhotho ejwayelekileko nanyana yesifunda. Ikhotho yesiyingi, kuyikhotho leyo eqalana namaqala wobulelesi, bese kuthi ikhotho yesifunda nanyana ejwayelekileko iqalane namaqala wobugebengu nomphakathi (Center for Court Innovation, 2011&lt;ref&gt;Center for Court Innovation. 2011. ''What is a Community Court?'' Bureau of Justice Assistance: U.S Department of Justice.&lt;/ref&gt;).

=== Isiphetho ===
Amakhotho ziindawo eziqakathekileko lezo ezenza bonyana sibabantu siphililsane ngokuthula. Nanyana kunjalo, kuyenzeka bonyana ezinye iinqunto zitjharaganise izinto ukuya phambili ngebanga lemithetho nokurhumutjha izehlakalo zamaqala alethwe kibo. Ngehla sitjheje woke amakhotho esinawo eSewula Afrika ngaphandle kwamakhotho wabadosiphambili bendabuko. Kodwana, esikhathi esizako sizokutjheja amakhotho wendabuko awodwa ngebanga lokukhetheka kwawo kunamakhotho la wesikhuwa.

=== Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>dfea0qw6jgywnsaebu1g275lnm24vmj</sha1>
    </revision>
    <revision>
      <id>2570</id>
      <parentid>2386</parentid>
      <timestamp>2025-03-22T05:40:34Z</timestamp>
      <contributor>
        <username>Kvazimodo</username>
        <id>341</id>
      </contributor>
      <origin>2570</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5936" sha1="s5a8fg1yg3dcv2axeafg0s8vrlf2me0" xml:space="preserve">'''Amakhotho wethu;''' Emhlabeni lo esiphila kiwo, siphila nabantu ababuya eendaweni ezahlukeneko begodu abasebenza ngeendlela ezahlukeneko. Kodwana, ukuze woke umuntu aphile ngokuthula, ukuhloniphana nokusebenzisana kufanele kube nemithetho nemigomo leyo ezokulandelwa. Imithetho nemigomo leyo itjhetjwa makhotho bonyana ilandelwe kuhle na. Eenhlokwaneni ezilandelako zizokutjheja bonyana kuyini ikhotho begodu nemihlobo yamakhotho.

== Kuyini ikhotho na? ==
Ngokuya kuka-Meyerson (2019)&lt;ref&gt;Meyerson, D. 2019. ''What is a Court of Law?'' UNSW Law Journal, 42(1):60-90.&lt;/ref&gt; asekelwa yi-[https://www.findlaw.com/litigation/legal-system/what-is-a-court.html Find Law (2025)]&lt;ref&gt;Find Law. 2024. ''What is a court?'' Litholaka ku:&lt; &lt;nowiki&gt;https://www.findlaw.com/litigation/legal-system/what-is-a-court.html&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 7 kuTjhirhweni 2025]. &lt;/ref&gt; ikhotho kuliziko lombuso langakomthetho lelo eliqalelene nemithetho. I-[[:en:Court|Wikipedia (2025)]]&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2025. ''Court''. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Court&lt;/nowiki&gt;&gt;.  Lifunyenwe [ngomhlaka 7 kuTjhirhweni 2025].&lt;/ref&gt; ingezelele yathi ikhotho liziko lombuso lelo eligunyazwe begodu elinamandla wokulamula iiindaba eziphathelene nomthetho hlangana kweenhlangahlangano, abantu, amabubululo nombuso imbala. Ngamanye amagama, ikhokho kusigungu leso esilamula imiraro yomphakathi ngokusebenzi imithetho yenarha. 

Ikhotho kanengi, ingasi soke isikhathi, yakhiwe ngamajaji, abatjhutjhisi, abajameli nabanye abasebenzi abasekeli bekambiso yekhotho (Wikipedia, 2025)&lt;ref name=&quot;:0&quot; /&gt;. Boke abantu ababalwe ngehla laba, ngibo ebenza isiqiniseko sokuthi yoke into ekhotho ikhamba kuhle ngokulandela imigomo nekambiso yayo. Esihlokwaneni esilandelako sizokutjheja imihlobo yamakhotho.

== Imihlobo yamakhotho ==
Nasitjheja ngenarheni yethu, iSewula Afrika, sinemihlobo embalwa yamakhotho begodu nemisebenzi yayo iyahluka. Umhlobo wokuthoma ngilo:

=== Ikhotho yo[[Umthethosisekelo|mthethosisekelo]] ===
Ikhotho yomthethosisekelo yikhotho ekulu kunazo zoke eSewula Afrika begodu kanengi itjheja iindaba eziphathelele nomthethosisekelo, imithethomlingwa nepalamende ([https://www.judiciary.org.za/index.php/the-south-african-judicial-system Judiciary of South Africa, 2025]&lt;ref name=&quot;:1&quot;&gt;Judiciary of South Africa. 2025. ''The South African Judicial System''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.judiciary.org.za/index.php/the-south-african-judicial-system&lt;/nowiki&gt;&gt;.   Lifunyenwe [ngomhlaka 7 kuTjhirhweni 2025].&lt;/ref&gt;). Ikhotho le ukuze iragele phambili nokulalelwa kweqala, kufanele kube namajaji abunane (8) ubuncani. Kodwana amajaji la nakhapheleleko alitjhumi nanye (11) [Judiciary of South Africa, 2025]. Ikhotho le isebenza njengekhotho yeenghongoyilo begodu ayilaleli ubufakazi nanyana ihlome ufakazi ngemibuzo; kodwana isebenzisa ufufakazi lobu obalalelwa ekhetho yangaphambilini ngaphambi kokuthi iqala lilethwe kuyo (Judiciary of South Africa, 2025).

== Ikhotho ekulu yeenghonghoyilo ==
Ikhotho ekulu yeenghonghoyilo khotho ekulu kunazo zoke ngaphandle kwekhotho yomthethosisekelo (Judiciary of South Africa, 2025&lt;ref name=&quot;:1&quot; /&gt;). Ikhotho le iqalana namaqala lawo abuya ekhotho ephakemeko, begodu itjheja woke amaqala ngaphandle kwamaqala aphathelene nezemisebenzi kanye nephaliswano (Judiciary of South Africa, 2025). Ayikho ikhotho engatjhugulula isiqunto sayo, ngaphandle kwekhotho yomthethosisekelo (Judiciary of South Africa, 2025). Ikhotho le kufanele ibe namajaji amathathu ukuya kwamahlanu ukuze ikghone ukulalela iqala (Judiciary of South Africa, 2025&lt;ref name=&quot;:1&quot; /&gt;).

== Ikhotho ephakemeko ==
Ikhotho ephakemeko yikhotho esebenza ngokuqintelwa nanyana ngokuya kwendawo nanyana isifunda la inzize khona (Judiciary of South Africa, 2025&lt;ref name=&quot;:1&quot; /&gt;). Ngamanye amagama iqala elibuya ekhotho kamarhastrada weMalahleni (eMpumalanga) angeze ladluliselwa ekhotho ephakemeko yeTlhagwini Kapa. ESewula Afrika sinamakhotho aphakemeko ali-13. Isifunda seMpumalanga sisengakabi nekhotho ephakemeko esebenzako, kanti isifunda seGauteng nesaKwaZulu Natal zinamakhotho amabili ngesifunda ngasinye, ekubeni ezinye iimfunda zinekhotho ephakemeko ngayinye ngesifunda (Judiciary of South Africa, 2025).

Nanyana kunjalo, kukhona amakhotho ekhethekileko lawo aqala namaqala ekhethikileko kwaphela. Amakhotho lawo ngila (Judiciary of South Africa, 2025&lt;ref name=&quot;:1&quot; /&gt;):

-         Ikhotho yezemisebenzise neenghonghoyilo zemisebenzi, leyo eqalana namaqala wezemisebenzi kanye neenghonghoyilo zawo.

-         Ikhotho yeembawo zenarha, leyo eqala neendaba eziphathelene nenarha.

-         Ikhotho yeenghonghoyilo zephaliswano, leyo eqalelene namaqala abuya kusigungu sephaliswano.

-         Ikhotho yamakhetho leyo eqalelene namaqala wamakhetho kwaphela.

-         Ikhotho yomthelo, leyo eqalelene namaqala aphathelene nomthelo.

== Ikhotho kamarhastrada ==
Ikhotho kamarhastrada yikhotho leyo eba seemphakahthini nanyana endaweni zemakhaya begodu ihlukaniswe Kabili. Kukhona ikhotho yesiyingi nekhotho ejwayelekileko nanyana yesifunda. Ikhotho yesiyingi, kuyikhotho leyo eqalana namaqala wobulelesi, bese kuthi ikhotho yesifunda nanyana ejwayelekileko iqalane namaqala wobugebengu nomphakathi (Center for Court Innovation, 2011&lt;ref&gt;Center for Court Innovation. 2011. ''What is a Community Court?'' Bureau of Justice Assistance: U.S Department of Justice.&lt;/ref&gt;).

== Isiphetho ==
Amakhotho ziindawo eziqakathekileko lezo ezenza bonyana sibabantu siphililsane ngokuthula. Nanyana kunjalo, kuyenzeka bonyana ezinye iinqunto zitjharaganise izinto ukuya phambili ngebanga lemithetho nokurhumutjha izehlakalo zamaqala alethwe kibo. Ngehla sitjheje woke amakhotho esinawo eSewula Afrika ngaphandle kwamakhotho wabadosiphambili bendabuko. Kodwana, esikhathi esizako sizokutjheja amakhotho wendabuko awodwa ngebanga lokukhetheka kwawo kunamakhotho la wesikhuwa.

== Umthombolwazi ==
&lt;references /&gt;</text>
      <sha1>s5a8fg1yg3dcv2axeafg0s8vrlf2me0</sha1>
    </revision>
    <revision>
      <id>2571</id>
      <parentid>2570</parentid>
      <timestamp>2025-03-22T05:40:48Z</timestamp>
      <contributor>
        <username>Kvazimodo</username>
        <id>341</id>
      </contributor>
      <minor />
      <comment>Janabaevazizbek moved page [[Amakhotho wethu.]] to [[Amakhotho wethu]]</comment>
      <origin>2570</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5936" sha1="s5a8fg1yg3dcv2axeafg0s8vrlf2me0" xml:space="preserve">'''Amakhotho wethu;''' Emhlabeni lo esiphila kiwo, siphila nabantu ababuya eendaweni ezahlukeneko begodu abasebenza ngeendlela ezahlukeneko. Kodwana, ukuze woke umuntu aphile ngokuthula, ukuhloniphana nokusebenzisana kufanele kube nemithetho nemigomo leyo ezokulandelwa. Imithetho nemigomo leyo itjhetjwa makhotho bonyana ilandelwe kuhle na. Eenhlokwaneni ezilandelako zizokutjheja bonyana kuyini ikhotho begodu nemihlobo yamakhotho.

== Kuyini ikhotho na? ==
Ngokuya kuka-Meyerson (2019)&lt;ref&gt;Meyerson, D. 2019. ''What is a Court of Law?'' UNSW Law Journal, 42(1):60-90.&lt;/ref&gt; asekelwa yi-[https://www.findlaw.com/litigation/legal-system/what-is-a-court.html Find Law (2025)]&lt;ref&gt;Find Law. 2024. ''What is a court?'' Litholaka ku:&lt; &lt;nowiki&gt;https://www.findlaw.com/litigation/legal-system/what-is-a-court.html&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 7 kuTjhirhweni 2025]. &lt;/ref&gt; ikhotho kuliziko lombuso langakomthetho lelo eliqalelene nemithetho. I-[[:en:Court|Wikipedia (2025)]]&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2025. ''Court''. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Court&lt;/nowiki&gt;&gt;.  Lifunyenwe [ngomhlaka 7 kuTjhirhweni 2025].&lt;/ref&gt; ingezelele yathi ikhotho liziko lombuso lelo eligunyazwe begodu elinamandla wokulamula iiindaba eziphathelene nomthetho hlangana kweenhlangahlangano, abantu, amabubululo nombuso imbala. Ngamanye amagama, ikhokho kusigungu leso esilamula imiraro yomphakathi ngokusebenzi imithetho yenarha. 

Ikhotho kanengi, ingasi soke isikhathi, yakhiwe ngamajaji, abatjhutjhisi, abajameli nabanye abasebenzi abasekeli bekambiso yekhotho (Wikipedia, 2025)&lt;ref name=&quot;:0&quot; /&gt;. Boke abantu ababalwe ngehla laba, ngibo ebenza isiqiniseko sokuthi yoke into ekhotho ikhamba kuhle ngokulandela imigomo nekambiso yayo. Esihlokwaneni esilandelako sizokutjheja imihlobo yamakhotho.

== Imihlobo yamakhotho ==
Nasitjheja ngenarheni yethu, iSewula Afrika, sinemihlobo embalwa yamakhotho begodu nemisebenzi yayo iyahluka. Umhlobo wokuthoma ngilo:

=== Ikhotho yo[[Umthethosisekelo|mthethosisekelo]] ===
Ikhotho yomthethosisekelo yikhotho ekulu kunazo zoke eSewula Afrika begodu kanengi itjheja iindaba eziphathelele nomthethosisekelo, imithethomlingwa nepalamende ([https://www.judiciary.org.za/index.php/the-south-african-judicial-system Judiciary of South Africa, 2025]&lt;ref name=&quot;:1&quot;&gt;Judiciary of South Africa. 2025. ''The South African Judicial System''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.judiciary.org.za/index.php/the-south-african-judicial-system&lt;/nowiki&gt;&gt;.   Lifunyenwe [ngomhlaka 7 kuTjhirhweni 2025].&lt;/ref&gt;). Ikhotho le ukuze iragele phambili nokulalelwa kweqala, kufanele kube namajaji abunane (8) ubuncani. Kodwana amajaji la nakhapheleleko alitjhumi nanye (11) [Judiciary of South Africa, 2025]. Ikhotho le isebenza njengekhotho yeenghongoyilo begodu ayilaleli ubufakazi nanyana ihlome ufakazi ngemibuzo; kodwana isebenzisa ufufakazi lobu obalalelwa ekhetho yangaphambilini ngaphambi kokuthi iqala lilethwe kuyo (Judiciary of South Africa, 2025).

== Ikhotho ekulu yeenghonghoyilo ==
Ikhotho ekulu yeenghonghoyilo khotho ekulu kunazo zoke ngaphandle kwekhotho yomthethosisekelo (Judiciary of South Africa, 2025&lt;ref name=&quot;:1&quot; /&gt;). Ikhotho le iqalana namaqala lawo abuya ekhotho ephakemeko, begodu itjheja woke amaqala ngaphandle kwamaqala aphathelene nezemisebenzi kanye nephaliswano (Judiciary of South Africa, 2025). Ayikho ikhotho engatjhugulula isiqunto sayo, ngaphandle kwekhotho yomthethosisekelo (Judiciary of South Africa, 2025). Ikhotho le kufanele ibe namajaji amathathu ukuya kwamahlanu ukuze ikghone ukulalela iqala (Judiciary of South Africa, 2025&lt;ref name=&quot;:1&quot; /&gt;).

== Ikhotho ephakemeko ==
Ikhotho ephakemeko yikhotho esebenza ngokuqintelwa nanyana ngokuya kwendawo nanyana isifunda la inzize khona (Judiciary of South Africa, 2025&lt;ref name=&quot;:1&quot; /&gt;). Ngamanye amagama iqala elibuya ekhotho kamarhastrada weMalahleni (eMpumalanga) angeze ladluliselwa ekhotho ephakemeko yeTlhagwini Kapa. ESewula Afrika sinamakhotho aphakemeko ali-13. Isifunda seMpumalanga sisengakabi nekhotho ephakemeko esebenzako, kanti isifunda seGauteng nesaKwaZulu Natal zinamakhotho amabili ngesifunda ngasinye, ekubeni ezinye iimfunda zinekhotho ephakemeko ngayinye ngesifunda (Judiciary of South Africa, 2025).

Nanyana kunjalo, kukhona amakhotho ekhethekileko lawo aqala namaqala ekhethikileko kwaphela. Amakhotho lawo ngila (Judiciary of South Africa, 2025&lt;ref name=&quot;:1&quot; /&gt;):

-         Ikhotho yezemisebenzise neenghonghoyilo zemisebenzi, leyo eqalana namaqala wezemisebenzi kanye neenghonghoyilo zawo.

-         Ikhotho yeembawo zenarha, leyo eqala neendaba eziphathelene nenarha.

-         Ikhotho yeenghonghoyilo zephaliswano, leyo eqalelene namaqala abuya kusigungu sephaliswano.

-         Ikhotho yamakhetho leyo eqalelene namaqala wamakhetho kwaphela.

-         Ikhotho yomthelo, leyo eqalelene namaqala aphathelene nomthelo.

== Ikhotho kamarhastrada ==
Ikhotho kamarhastrada yikhotho leyo eba seemphakahthini nanyana endaweni zemakhaya begodu ihlukaniswe Kabili. Kukhona ikhotho yesiyingi nekhotho ejwayelekileko nanyana yesifunda. Ikhotho yesiyingi, kuyikhotho leyo eqalana namaqala wobulelesi, bese kuthi ikhotho yesifunda nanyana ejwayelekileko iqalane namaqala wobugebengu nomphakathi (Center for Court Innovation, 2011&lt;ref&gt;Center for Court Innovation. 2011. ''What is a Community Court?'' Bureau of Justice Assistance: U.S Department of Justice.&lt;/ref&gt;).

== Isiphetho ==
Amakhotho ziindawo eziqakathekileko lezo ezenza bonyana sibabantu siphililsane ngokuthula. Nanyana kunjalo, kuyenzeka bonyana ezinye iinqunto zitjharaganise izinto ukuya phambili ngebanga lemithetho nokurhumutjha izehlakalo zamaqala alethwe kibo. Ngehla sitjheje woke amakhotho esinawo eSewula Afrika ngaphandle kwamakhotho wabadosiphambili bendabuko. Kodwana, esikhathi esizako sizokutjheja amakhotho wendabuko awodwa ngebanga lokukhetheka kwawo kunamakhotho la wesikhuwa.

== Umthombolwazi ==
&lt;references /&gt;</text>
      <sha1>s5a8fg1yg3dcv2axeafg0s8vrlf2me0</sha1>
    </revision>
    <revision>
      <id>3231</id>
      <parentid>2571</parentid>
      <timestamp>2025-06-26T07:06:36Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <origin>3231</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5961" sha1="lexusrqrdz760sh249qa3u8u5yi7gnp" xml:space="preserve">== '''Amakhotho wethu''' ==

=== Isingeniso ===
Emhlabeni lo esiphila kiwo, siphila nabantu ababuya eendaweni ezahlukeneko begodu abasebenza ngeendlela ezahlukeneko. Kodwana, ukuze woke umuntu aphile ngokuthula, ukuhloniphana nokusebenzisana kufanele kube nemithetho nemigomo leyo ezokulandelwa. Imithetho nemigomo leyo itjhetjwa makhotho bonyana ilandelwe kuhle na. Eenhlokwaneni ezilandelako zizokutjheja bonyana kuyini ikhotho begodu nemihlobo yamakhotho.

== Kuyini ikhotho na? ==
Ngokuya kuka-Meyerson (2019)&lt;ref&gt;Meyerson, D. 2019. ''What is a Court of Law?'' UNSW Law Journal, 42(1):60-90.&lt;/ref&gt; asekelwa yi-[https://www.findlaw.com/litigation/legal-system/what-is-a-court.html Find Law (2025)]&lt;ref&gt;Find Law. 2024. ''What is a court?'' Litholaka ku:&lt; &lt;nowiki&gt;https://www.findlaw.com/litigation/legal-system/what-is-a-court.html&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 7 kuTjhirhweni 2025]. &lt;/ref&gt; ikhotho kuliziko lombuso langakomthetho lelo eliqalelene nemithetho. I-[[:en:Court|Wikipedia (2025)]]&lt;ref name=&quot;:0&quot;&gt;Wikipedia. 2025. ''Court''. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Court&lt;/nowiki&gt;&gt;.  Lifunyenwe [ngomhlaka 7 kuTjhirhweni 2025].&lt;/ref&gt; ingezelele yathi ikhotho liziko lombuso lelo eligunyazwe begodu elinamandla wokulamula iiindaba eziphathelene nomthetho hlangana kweenhlangahlangano, abantu, amabubululo nombuso imbala. Ngamanye amagama, ikhokho kusigungu leso esilamula imiraro yomphakathi ngokusebenzi imithetho yenarha. 

Ikhotho kanengi, ingasi soke isikhathi, yakhiwe ngamajaji, abatjhutjhisi, abajameli nabanye abasebenzi abasekeli bekambiso yekhotho (Wikipedia, 2025)&lt;ref name=&quot;:0&quot; /&gt;. Boke abantu ababalwe ngehla laba, ngibo ebenza isiqiniseko sokuthi yoke into ekhotho ikhamba kuhle ngokulandela imigomo nekambiso yayo. Esihlokwaneni esilandelako sizokutjheja imihlobo yamakhotho.

== Imihlobo yamakhotho ==
Nasitjheja ngenarheni yethu, iSewula Afrika, sinemihlobo embalwa yamakhotho begodu nemisebenzi yayo iyahluka. Umhlobo wokuthoma ngilo:

=== Ikhotho yo[[Umthethosisekelo|mthethosisekelo]] ===
Ikhotho yomthethosisekelo yikhotho ekulu kunazo zoke eSewula Afrika begodu kanengi itjheja iindaba eziphathelele nomthethosisekelo, imithethomlingwa nepalamende ([https://www.judiciary.org.za/index.php/the-south-african-judicial-system Judiciary of South Africa, 2025]&lt;ref name=&quot;:1&quot;&gt;Judiciary of South Africa. 2025. ''The South African Judicial System''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.judiciary.org.za/index.php/the-south-african-judicial-system&lt;/nowiki&gt;&gt;.   Lifunyenwe [ngomhlaka 7 kuTjhirhweni 2025].&lt;/ref&gt;). Ikhotho le ukuze iragele phambili nokulalelwa kweqala, kufanele kube namajaji abunane (8) ubuncani. Kodwana amajaji la nakhapheleleko alitjhumi nanye (11) [Judiciary of South Africa, 2025]. Ikhotho le isebenza njengekhotho yeenghongoyilo begodu ayilaleli ubufakazi nanyana ihlome ufakazi ngemibuzo; kodwana isebenzisa ufufakazi lobu obalalelwa ekhetho yangaphambilini ngaphambi kokuthi iqala lilethwe kuyo (Judiciary of South Africa, 2025).

== Ikhotho ekulu yeenghonghoyilo ==
Ikhotho ekulu yeenghonghoyilo khotho ekulu kunazo zoke ngaphandle kwekhotho yomthethosisekelo (Judiciary of South Africa, 2025&lt;ref name=&quot;:1&quot; /&gt;). Ikhotho le iqalana namaqala lawo abuya ekhotho ephakemeko, begodu itjheja woke amaqala ngaphandle kwamaqala aphathelene nezemisebenzi kanye nephaliswano (Judiciary of South Africa, 2025). Ayikho ikhotho engatjhugulula isiqunto sayo, ngaphandle kwekhotho yomthethosisekelo (Judiciary of South Africa, 2025). Ikhotho le kufanele ibe namajaji amathathu ukuya kwamahlanu ukuze ikghone ukulalela iqala (Judiciary of South Africa, 2025&lt;ref name=&quot;:1&quot; /&gt;).

== Ikhotho ephakemeko ==
Ikhotho ephakemeko yikhotho esebenza ngokuqintelwa nanyana ngokuya kwendawo nanyana isifunda la inzize khona (Judiciary of South Africa, 2025&lt;ref name=&quot;:1&quot; /&gt;). Ngamanye amagama iqala elibuya ekhotho kamarhastrada weMalahleni (eMpumalanga) angeze ladluliselwa ekhotho ephakemeko yeTlhagwini Kapa. ESewula Afrika sinamakhotho aphakemeko ali-13. Isifunda seMpumalanga sisengakabi nekhotho ephakemeko esebenzako, kanti isifunda seGauteng nesaKwaZulu Natal zinamakhotho amabili ngesifunda ngasinye, ekubeni ezinye iimfunda zinekhotho ephakemeko ngayinye ngesifunda (Judiciary of South Africa, 2025).

Nanyana kunjalo, kukhona amakhotho ekhethekileko lawo aqala namaqala ekhethikileko kwaphela. Amakhotho lawo ngila (Judiciary of South Africa, 2025&lt;ref name=&quot;:1&quot; /&gt;):

-         Ikhotho yezemisebenzise neenghonghoyilo zemisebenzi, leyo eqalana namaqala wezemisebenzi kanye neenghonghoyilo zawo.

-         Ikhotho yeembawo zenarha, leyo eqala neendaba eziphathelene nenarha.

-         Ikhotho yeenghonghoyilo zephaliswano, leyo eqalelene namaqala abuya kusigungu sephaliswano.

-         Ikhotho yamakhetho leyo eqalelene namaqala wamakhetho kwaphela.

-         Ikhotho yomthelo, leyo eqalelene namaqala aphathelene nomthelo.

== Ikhotho kamarhastrada ==
Ikhotho kamarhastrada yikhotho leyo eba seemphakahthini nanyana endaweni zemakhaya begodu ihlukaniswe Kabili. Kukhona ikhotho yesiyingi nekhotho ejwayelekileko nanyana yesifunda. Ikhotho yesiyingi, kuyikhotho leyo eqalana namaqala wobulelesi, bese kuthi ikhotho yesifunda nanyana ejwayelekileko iqalane namaqala wobugebengu nomphakathi (Center for Court Innovation, 2011&lt;ref&gt;Center for Court Innovation. 2011. ''What is a Community Court?'' Bureau of Justice Assistance: U.S Department of Justice.&lt;/ref&gt;).

== Isiphetho ==
Amakhotho ziindawo eziqakathekileko lezo ezenza bonyana sibabantu siphililsane ngokuthula. Nanyana kunjalo, kuyenzeka bonyana ezinye iinqunto zitjharaganise izinto ukuya phambili ngebanga lemithetho nokurhumutjha izehlakalo zamaqala alethwe kibo. Ngehla sitjheje woke amakhotho esinawo eSewula Afrika ngaphandle kwamakhotho wabadosiphambili bendabuko. Kodwana, esikhathi esizako sizokutjheja amakhotho wendabuko awodwa ngebanga lokukhetheka kwawo kunamakhotho la wesikhuwa.

== Umthombolwazi ==
&lt;references /&gt;</text>
      <sha1>lexusrqrdz760sh249qa3u8u5yi7gnp</sha1>
    </revision>
  </page>
  <page>
    <title>Iyunivesithi.</title>
    <ns>0</ns>
    <id>454</id>
    <revision>
      <id>2371</id>
      <timestamp>2025-01-27T07:29:17Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <comment>Created page with &quot;== Iyunivesithi. ==  === Isingeniso === Kunezinye iinkhamphani nanyana iinhlangano ezidlala indima eqakathekileko ekwenzeni isiqiniseko sokuthi abantu bekhethu bafunyana ilwazi, ikghono nefundo enqophileko, begodu zeyenza bonyana sithuthuke siimphakathi ngokunabileko. Iinhlangano lezo nanyana amakhamphani lawo afaka hlangana amayunivesithi. Ngebanga lomnqopho wekulumopendulwano yethu le, sizokunqopha kumayunivesithi wombusu khudlwana ukudlula amayunivesithi azijameleko n...&quot;</comment>
      <origin>2371</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4072" sha1="n83i6w11iw4ncuh87o3pfpjq4gbgvhf" xml:space="preserve">== Iyunivesithi. ==

=== Isingeniso ===
Kunezinye iinkhamphani nanyana iinhlangano ezidlala indima eqakathekileko ekwenzeni isiqiniseko sokuthi abantu bekhethu bafunyana ilwazi, ikghono nefundo enqophileko, begodu zeyenza bonyana sithuthuke siimphakathi ngokunabileko. Iinhlangano lezo nanyana amakhamphani lawo afaka hlangana amayunivesithi. Ngebanga lomnqopho wekulumopendulwano yethu le, sizokunqopha kumayunivesithi wombusu khudlwana ukudlula amayunivesithi azijameleko nanyana wangeqadi. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyini iyunivesithi begodu umsebenzayo yini.

=== Kuyini iyunivesithi? ===
Ngokuya kuka-Alemu (2018)&lt;ref name=&quot;:0&quot;&gt;Alemu, S. K. 2018. The meaning, idea and history of university/higher education in Africa: a brief literature review. ''Forum for International Research in Education'', 4(3):210-227.&lt;/ref&gt; ne-[[:en:University|Wikipedia (2025)]]&lt;ref name=&quot;:1&quot;&gt;Wikipedia. 2025. ''University''. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/University&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 9 kuTjhirhweni 2025].&lt;/ref&gt; [[Yunivesithi yempulanga|iyunivesithi]] kuyingcenye yomkhakha wezefundo ophakemeko. Ngamanye amagama, iyunivesithi nezinye iinhlangano nasele zibuthelelwe zoke zibizwa bona mikhakha yezefundo ephakemeko ngombana ukuze ufinyelele kiyo kufanele uthome ifundweni yamabanga aphasi naphazulu. Kodwana akupheleli lapho, kufanele imiphumela yakho godu ikhambisane nemiphumela nanyana ibe sezingeni elibekwe yiyunivesithi leyo ofuna ukufunda kiyo. U-Alemu (2018)&lt;ref name=&quot;:0&quot; /&gt; asekelwa ngu-Boulton akhambisana no-Lucas (2008)&lt;ref&gt;Boutlon, G. &amp; Lucas, C. 2008. ''What are universities for?'' League of European Research University: Leuven.&lt;/ref&gt; bangezelele bathi, iyunivesithi kuyindawo lapho abafundi bafunyana khona ilwazi elahlukeneko begodu bakhulisa nobuhlakani babo ukuze bazokwazi ukuthuthukisa nokusiza umphakathi ngemiraro yepilo. 

Iyunivesithi yakhiwe minyango eyahlukeneko yelwazi leyo efaka hlangana zesayensi, zokutjala, zobuntu, ithekhnoloji kanye nezengqondo ezikhambisana nezehlalakuhle (Alemu, 2018&lt;ref name=&quot;:0&quot; /&gt;; Wikipedia 2025&lt;ref name=&quot;:1&quot; /&gt;). Kweminye iminyango sifunyana iingungu zerhubhululo elithize, njengezerhubhululo eliphathelene nokutlhoriswa kabentwana, ituthuko yabomma nabentwana kanye nelimi lomphakathi. Amayunivesithi nakaphelele woke eSewula Afrika wombuso ama-26, kuthi ama-21 kumayunivesithi ngokupheleleko, bese ama-5 kube mayunivesithi wethekhnoloji (UmNyango wezeFundo esiSekelo, 2025&lt;ref&gt;UmNyango wezeFundo esiSekelo. 2025. ''List of South African Universities''. UmNyango wezeFundo esiSekelo: Pretoria.&lt;/ref&gt;).

Nasitjheja ihlathululo esinikelwe yona mayelana neyunivesithi singatjho bonyana kuyindawo ehlangahlanganeko begodu edlala indima eqakathekileko eemphakathini. Esihlokwaneni esilandelako sizokutjheja imisebenzi yeyunivesithi.

=== Imisebenzi yeyunivesithi. ===
Iyunivesithi inemisebenzi eminengi leyo ekufanele iyiphakele umphakathi nenarha zombelele. Ngokuya kuka-Denman (2005)&lt;ref&gt;Denman, B. D. 2005. What is a University in the 21&lt;sup&gt;st&lt;/sup&gt; Century? ''Higher Education Management and Policy'', 17(2):9-28.&lt;/ref&gt; iyunivesithi idlala indima ekusabaliseni kanye nokuthuthukiseni ilwazi ngefundo nangerhubhululo. Iyunivesithi irhubhulula ilwazi elitjha lelo elikhambelana neendingo zanamhlanje bese iliphakele nanyana ilisebenzise eemphakathi ukuthuthukisa ipilo yomphakathi. 

Iyunivesithi ibuye isize umbuso ngokuthi yenze amarhubhululo lawo umbuso ozowasebenzisa ukwenza imithetho engcono kanye nokuthatha iinqunto ezingcono. Ngamanye amagama, iyunivesithi ithuthukisa ubuhlakani bombuso ukuze umbuso ukwazi ukuqalana neendingo zomphakathi ngcono begodu ubuse ngcono abantu bawo. 

=== Isiphetho ===
Amayunivesithi adlala indima eqakathileko ekwenzeni isiqiniseko sokuthi siqalana nemiraro evelako yepilo efaka hlangana amagulo, ithekhnoloji nebhoduluko ngendlela efaneleko. Nanyana amayunivesithi asebenza ngendlela ezahlukeneko, kodwana umnqopho wawo munye kukusiza nokuthuthukisa umphakathi nenarha ngokunabileko. 

=== Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>n83i6w11iw4ncuh87o3pfpjq4gbgvhf</sha1>
    </revision>
    <revision>
      <id>2387</id>
      <parentid>2371</parentid>
      <timestamp>2025-01-28T06:17:25Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <minor />
      <origin>2387</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4073" sha1="rrwmj6tkrk8dkxe1vnpvq1wmfj602tz" xml:space="preserve">== Iyunivesithi. ==

=== Isingeniso. ===
Kunezinye iinkhamphani nanyana iinhlangano ezidlala indima eqakathekileko ekwenzeni isiqiniseko sokuthi abantu bekhethu bafunyana ilwazi, ikghono nefundo enqophileko, begodu zeyenza bonyana sithuthuke siimphakathi ngokunabileko. Iinhlangano lezo nanyana amakhamphani lawo afaka hlangana amayunivesithi. Ngebanga lomnqopho wekulumopendulwano yethu le, sizokunqopha kumayunivesithi wombusu khudlwana ukudlula amayunivesithi azijameleko nanyana wangeqadi. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyini iyunivesithi begodu umsebenzayo yini.

=== Kuyini iyunivesithi? ===
Ngokuya kuka-Alemu (2018)&lt;ref name=&quot;:0&quot;&gt;Alemu, S. K. 2018. The meaning, idea and history of university/higher education in Africa: a brief literature review. ''Forum for International Research in Education'', 4(3):210-227.&lt;/ref&gt; ne-[[:en:University|Wikipedia (2025)]]&lt;ref name=&quot;:1&quot;&gt;Wikipedia. 2025. ''University''. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/University&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 9 kuTjhirhweni 2025].&lt;/ref&gt; [[Yunivesithi yempulanga|iyunivesithi]] kuyingcenye yomkhakha wezefundo ophakemeko. Ngamanye amagama, iyunivesithi nezinye iinhlangano nasele zibuthelelwe zoke zibizwa bona mikhakha yezefundo ephakemeko ngombana ukuze ufinyelele kiyo kufanele uthome ifundweni yamabanga aphasi naphazulu. Kodwana akupheleli lapho, kufanele imiphumela yakho godu ikhambisane nemiphumela nanyana ibe sezingeni elibekwe yiyunivesithi leyo ofuna ukufunda kiyo. U-Alemu (2018)&lt;ref name=&quot;:0&quot; /&gt; asekelwa ngu-Boulton akhambisana no-Lucas (2008)&lt;ref&gt;Boutlon, G. &amp; Lucas, C. 2008. ''What are universities for?'' League of European Research University: Leuven.&lt;/ref&gt; bangezelele bathi, iyunivesithi kuyindawo lapho abafundi bafunyana khona ilwazi elahlukeneko begodu bakhulisa nobuhlakani babo ukuze bazokwazi ukuthuthukisa nokusiza umphakathi ngemiraro yepilo. 

Iyunivesithi yakhiwe minyango eyahlukeneko yelwazi leyo efaka hlangana zesayensi, zokutjala, zobuntu, ithekhnoloji kanye nezengqondo ezikhambisana nezehlalakuhle (Alemu, 2018&lt;ref name=&quot;:0&quot; /&gt;; Wikipedia 2025&lt;ref name=&quot;:1&quot; /&gt;). Kweminye iminyango sifunyana iingungu zerhubhululo elithize, njengezerhubhululo eliphathelene nokutlhoriswa kabentwana, ituthuko yabomma nabentwana kanye nelimi lomphakathi. Amayunivesithi nakaphelele woke eSewula Afrika wombuso ama-26, kuthi ama-21 kumayunivesithi ngokupheleleko, bese ama-5 kube mayunivesithi wethekhnoloji (UmNyango wezeFundo esiSekelo, 2025&lt;ref&gt;UmNyango wezeFundo esiSekelo. 2025. ''List of South African Universities''. UmNyango wezeFundo esiSekelo: Pretoria.&lt;/ref&gt;).

Nasitjheja ihlathululo esinikelwe yona mayelana neyunivesithi singatjho bonyana kuyindawo ehlangahlanganeko begodu edlala indima eqakathekileko eemphakathini. Esihlokwaneni esilandelako sizokutjheja imisebenzi yeyunivesithi.

=== Imisebenzi yeyunivesithi. ===
Iyunivesithi inemisebenzi eminengi leyo ekufanele iyiphakele umphakathi nenarha zombelele. Ngokuya kuka-Denman (2005)&lt;ref&gt;Denman, B. D. 2005. What is a University in the 21&lt;sup&gt;st&lt;/sup&gt; Century? ''Higher Education Management and Policy'', 17(2):9-28.&lt;/ref&gt; iyunivesithi idlala indima ekusabaliseni kanye nokuthuthukiseni ilwazi ngefundo nangerhubhululo. Iyunivesithi irhubhulula ilwazi elitjha lelo elikhambelana neendingo zanamhlanje bese iliphakele nanyana ilisebenzise eemphakathi ukuthuthukisa ipilo yomphakathi. 

Iyunivesithi ibuye isize umbuso ngokuthi yenze amarhubhululo lawo umbuso ozowasebenzisa ukwenza imithetho engcono kanye nokuthatha iinqunto ezingcono. Ngamanye amagama, iyunivesithi ithuthukisa ubuhlakani bombuso ukuze umbuso ukwazi ukuqalana neendingo zomphakathi ngcono begodu ubuse ngcono abantu bawo. 

=== Isiphetho ===
Amayunivesithi adlala indima eqakathileko ekwenzeni isiqiniseko sokuthi siqalana nemiraro evelako yepilo efaka hlangana amagulo, ithekhnoloji nebhoduluko ngendlela efaneleko. Nanyana amayunivesithi asebenza ngendlela ezahlukeneko, kodwana umnqopho wawo munye kukusiza nokuthuthukisa umphakathi nenarha ngokunabileko. 

=== Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>rrwmj6tkrk8dkxe1vnpvq1wmfj602tz</sha1>
    </revision>
    <revision>
      <id>2971</id>
      <parentid>2387</parentid>
      <timestamp>2025-06-06T20:00:58Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>phish</comment>
      <origin>2971</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4161" sha1="7aha7vja7ao8abi2sfwivn14eos14iw" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.'''

== Iyunivesithi. ==

=== Isingeniso. ===
Kunezinye iinkhamphani nanyana iinhlangano ezidlala indima eqakathekileko ekwenzeni isiqiniseko sokuthi abantu bekhethu bafunyana ilwazi, ikghono nefundo enqophileko, begodu zeyenza bonyana sithuthuke siimphakathi ngokunabileko. Iinhlangano lezo nanyana amakhamphani lawo afaka hlangana amayunivesithi. Ngebanga lomnqopho wekulumopendulwano yethu le, sizokunqopha kumayunivesithi wombusu khudlwana ukudlula amayunivesithi azijameleko nanyana wangeqadi. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyini iyunivesithi begodu umsebenzayo yini.

=== Kuyini iyunivesithi? ===
Ngokuya kuka-Alemu (2018)&lt;ref name=&quot;:0&quot;&gt;Alemu, S. K. 2018. The meaning, idea and history of university/higher education in Africa: a brief literature review. ''Forum for International Research in Education'', 4(3):210-227.&lt;/ref&gt; ne-[[:en:University|Wikipedia (2025)]]&lt;ref name=&quot;:1&quot;&gt;Wikipedia. 2025. ''University''. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/University&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 9 kuTjhirhweni 2025].&lt;/ref&gt; [[Yunivesithi yempulanga|iyunivesithi]] kuyingcenye yomkhakha wezefundo ophakemeko. Ngamanye amagama, iyunivesithi nezinye iinhlangano nasele zibuthelelwe zoke zibizwa bona mikhakha yezefundo ephakemeko ngombana ukuze ufinyelele kiyo kufanele uthome ifundweni yamabanga aphasi naphazulu. Kodwana akupheleli lapho, kufanele imiphumela yakho godu ikhambisane nemiphumela nanyana ibe sezingeni elibekwe yiyunivesithi leyo ofuna ukufunda kiyo. U-Alemu (2018)&lt;ref name=&quot;:0&quot; /&gt; asekelwa ngu-Boulton akhambisana no-Lucas (2008)&lt;ref&gt;Boutlon, G. &amp; Lucas, C. 2008. ''What are universities for?'' League of European Research University: Leuven.&lt;/ref&gt; bangezelele bathi, iyunivesithi kuyindawo lapho abafundi bafunyana khona ilwazi elahlukeneko begodu bakhulisa nobuhlakani babo ukuze bazokwazi ukuthuthukisa nokusiza umphakathi ngemiraro yepilo. 

Iyunivesithi yakhiwe minyango eyahlukeneko yelwazi leyo efaka hlangana zesayensi, zokutjala, zobuntu, ithekhnoloji kanye nezengqondo ezikhambisana nezehlalakuhle (Alemu, 2018&lt;ref name=&quot;:0&quot; /&gt;; Wikipedia 2025&lt;ref name=&quot;:1&quot; /&gt;). Kweminye iminyango sifunyana iingungu zerhubhululo elithize, njengezerhubhululo eliphathelene nokutlhoriswa kabentwana, ituthuko yabomma nabentwana kanye nelimi lomphakathi. Amayunivesithi nakaphelele woke eSewula Afrika wombuso ama-26, kuthi ama-21 kumayunivesithi ngokupheleleko, bese ama-5 kube mayunivesithi wethekhnoloji (UmNyango wezeFundo esiSekelo, 2025&lt;ref&gt;UmNyango wezeFundo esiSekelo. 2025. ''List of South African Universities''. UmNyango wezeFundo esiSekelo: Pretoria.&lt;/ref&gt;).

Nasitjheja ihlathululo esinikelwe yona mayelana neyunivesithi singatjho bonyana kuyindawo ehlangahlanganeko begodu edlala indima eqakathekileko eemphakathini. Esihlokwaneni esilandelako sizokutjheja imisebenzi yeyunivesithi.

=== Imisebenzi yeyunivesithi. ===
Iyunivesithi inemisebenzi eminengi leyo ekufanele iyiphakele umphakathi nenarha zombelele. Ngokuya kuka-Denman (2005)&lt;ref&gt;Denman, B. D. 2005. What is a University in the 21&lt;sup&gt;st&lt;/sup&gt; Century? ''Higher Education Management and Policy'', 17(2):9-28.&lt;/ref&gt; iyunivesithi idlala indima ekusabaliseni kanye nokuthuthukiseni ilwazi ngefundo nangerhubhululo. Iyunivesithi irhubhulula ilwazi elitjha lelo elikhambelana neendingo zanamhlanje bese iliphakele nanyana ilisebenzise eemphakathi ukuthuthukisa ipilo yomphakathi. 

Iyunivesithi ibuye isize umbuso ngokuthi yenze amarhubhululo lawo umbuso ozowasebenzisa ukwenza imithetho engcono kanye nokuthatha iinqunto ezingcono. Ngamanye amagama, iyunivesithi ithuthukisa ubuhlakani bombuso ukuze umbuso ukwazi ukuqalana neendingo zomphakathi ngcono begodu ubuse ngcono abantu bawo. 

=== Isiphetho ===
Amayunivesithi adlala indima eqakathileko ekwenzeni isiqiniseko sokuthi siqalana nemiraro evelako yepilo efaka hlangana amagulo, ithekhnoloji nebhoduluko ngendlela efaneleko. Nanyana amayunivesithi asebenza ngendlela ezahlukeneko, kodwana umnqopho wawo munye kukusiza nokuthuthukisa umphakathi nenarha ngokunabileko. 

=== Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>7aha7vja7ao8abi2sfwivn14eos14iw</sha1>
    </revision>
    <revision>
      <id>3129</id>
      <parentid>2971</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Owaziwako|Owaziwako]]</comment>
      <origin>2387</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4073" sha1="rrwmj6tkrk8dkxe1vnpvq1wmfj602tz" xml:space="preserve">== Iyunivesithi. ==

=== Isingeniso. ===
Kunezinye iinkhamphani nanyana iinhlangano ezidlala indima eqakathekileko ekwenzeni isiqiniseko sokuthi abantu bekhethu bafunyana ilwazi, ikghono nefundo enqophileko, begodu zeyenza bonyana sithuthuke siimphakathi ngokunabileko. Iinhlangano lezo nanyana amakhamphani lawo afaka hlangana amayunivesithi. Ngebanga lomnqopho wekulumopendulwano yethu le, sizokunqopha kumayunivesithi wombusu khudlwana ukudlula amayunivesithi azijameleko nanyana wangeqadi. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyini iyunivesithi begodu umsebenzayo yini.

=== Kuyini iyunivesithi? ===
Ngokuya kuka-Alemu (2018)&lt;ref name=&quot;:0&quot;&gt;Alemu, S. K. 2018. The meaning, idea and history of university/higher education in Africa: a brief literature review. ''Forum for International Research in Education'', 4(3):210-227.&lt;/ref&gt; ne-[[:en:University|Wikipedia (2025)]]&lt;ref name=&quot;:1&quot;&gt;Wikipedia. 2025. ''University''. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/University&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 9 kuTjhirhweni 2025].&lt;/ref&gt; [[Yunivesithi yempulanga|iyunivesithi]] kuyingcenye yomkhakha wezefundo ophakemeko. Ngamanye amagama, iyunivesithi nezinye iinhlangano nasele zibuthelelwe zoke zibizwa bona mikhakha yezefundo ephakemeko ngombana ukuze ufinyelele kiyo kufanele uthome ifundweni yamabanga aphasi naphazulu. Kodwana akupheleli lapho, kufanele imiphumela yakho godu ikhambisane nemiphumela nanyana ibe sezingeni elibekwe yiyunivesithi leyo ofuna ukufunda kiyo. U-Alemu (2018)&lt;ref name=&quot;:0&quot; /&gt; asekelwa ngu-Boulton akhambisana no-Lucas (2008)&lt;ref&gt;Boutlon, G. &amp; Lucas, C. 2008. ''What are universities for?'' League of European Research University: Leuven.&lt;/ref&gt; bangezelele bathi, iyunivesithi kuyindawo lapho abafundi bafunyana khona ilwazi elahlukeneko begodu bakhulisa nobuhlakani babo ukuze bazokwazi ukuthuthukisa nokusiza umphakathi ngemiraro yepilo. 

Iyunivesithi yakhiwe minyango eyahlukeneko yelwazi leyo efaka hlangana zesayensi, zokutjala, zobuntu, ithekhnoloji kanye nezengqondo ezikhambisana nezehlalakuhle (Alemu, 2018&lt;ref name=&quot;:0&quot; /&gt;; Wikipedia 2025&lt;ref name=&quot;:1&quot; /&gt;). Kweminye iminyango sifunyana iingungu zerhubhululo elithize, njengezerhubhululo eliphathelene nokutlhoriswa kabentwana, ituthuko yabomma nabentwana kanye nelimi lomphakathi. Amayunivesithi nakaphelele woke eSewula Afrika wombuso ama-26, kuthi ama-21 kumayunivesithi ngokupheleleko, bese ama-5 kube mayunivesithi wethekhnoloji (UmNyango wezeFundo esiSekelo, 2025&lt;ref&gt;UmNyango wezeFundo esiSekelo. 2025. ''List of South African Universities''. UmNyango wezeFundo esiSekelo: Pretoria.&lt;/ref&gt;).

Nasitjheja ihlathululo esinikelwe yona mayelana neyunivesithi singatjho bonyana kuyindawo ehlangahlanganeko begodu edlala indima eqakathekileko eemphakathini. Esihlokwaneni esilandelako sizokutjheja imisebenzi yeyunivesithi.

=== Imisebenzi yeyunivesithi. ===
Iyunivesithi inemisebenzi eminengi leyo ekufanele iyiphakele umphakathi nenarha zombelele. Ngokuya kuka-Denman (2005)&lt;ref&gt;Denman, B. D. 2005. What is a University in the 21&lt;sup&gt;st&lt;/sup&gt; Century? ''Higher Education Management and Policy'', 17(2):9-28.&lt;/ref&gt; iyunivesithi idlala indima ekusabaliseni kanye nokuthuthukiseni ilwazi ngefundo nangerhubhululo. Iyunivesithi irhubhulula ilwazi elitjha lelo elikhambelana neendingo zanamhlanje bese iliphakele nanyana ilisebenzise eemphakathi ukuthuthukisa ipilo yomphakathi. 

Iyunivesithi ibuye isize umbuso ngokuthi yenze amarhubhululo lawo umbuso ozowasebenzisa ukwenza imithetho engcono kanye nokuthatha iinqunto ezingcono. Ngamanye amagama, iyunivesithi ithuthukisa ubuhlakani bombuso ukuze umbuso ukwazi ukuqalana neendingo zomphakathi ngcono begodu ubuse ngcono abantu bawo. 

=== Isiphetho ===
Amayunivesithi adlala indima eqakathileko ekwenzeni isiqiniseko sokuthi siqalana nemiraro evelako yepilo efaka hlangana amagulo, ithekhnoloji nebhoduluko ngendlela efaneleko. Nanyana amayunivesithi asebenza ngendlela ezahlukeneko, kodwana umnqopho wawo munye kukusiza nokuthuthukisa umphakathi nenarha ngokunabileko. 

=== Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>rrwmj6tkrk8dkxe1vnpvq1wmfj602tz</sha1>
    </revision>
  </page>
  <page>
    <title>Ukufudukela emadorobheni nanyana ifuduko lemadorobheni.</title>
    <ns>0</ns>
    <id>455</id>
    <revision>
      <id>2372</id>
      <timestamp>2025-01-27T07:54:59Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <comment>Created page with &quot;== Ukufudukela emadorobheni nanyana ifuduko lemadorobheni. ==  === Isingeniso === Ukufudukela emadorobheni ngelinye ihlelo esele lande khulu eemphakathini wekhethu. Abantu abanengi bathi nabakhulako nanyana ngebanga lemisebenzi neminye iimbandela, bazithola basuka emakhaya bayokuhlala emadorobheni. Nanyana kunjalo, kukhona indlazana elingafudukiko begodu elikhulele emakhaya belakha emakhaya. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyinini ukufudukela emadorobhen...&quot;</comment>
      <origin>2372</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5322" sha1="ncnxztcy79a7bz5o4615gb8itgaxg7o" xml:space="preserve">== Ukufudukela emadorobheni nanyana ifuduko lemadorobheni. ==

=== Isingeniso ===
Ukufudukela emadorobheni ngelinye ihlelo esele lande khulu eemphakathini wekhethu. Abantu abanengi bathi nabakhulako nanyana ngebanga lemisebenzi neminye iimbandela, bazithola basuka emakhaya bayokuhlala emadorobheni. Nanyana kunjalo, kukhona indlazana elingafudukiko begodu elikhulele emakhaya belakha emakhaya. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyinini ukufudukela emadorobhen nanyana ifuduko lemadorobheni kanye neembangela zakhona. 

=== Kuyini ifunduko lemadorobheni nanyana ukufudekela emadorobheni? ===
[[Isimumathi:Ukufuduka.jpg|thumb|299x299px|Abantu bayafuduka]]
Ngokuya kuka-Malik (2015)&lt;ref&gt;Malik, A. S. 2015. Rural urban migration; socio-cultural changes in Pakistan preventive measures taken by government and civil society to control it. ''Professional Med J'', 22(6):674-682.&lt;/ref&gt; ifuduko lemadorobheni kulifuduko lelo elenzeka ephasini loke, khulukhulu nasiqala iinarha ezisathuthukako. UBabi, u-Gaugping, no-Ladu (2017) &lt;ref&gt;Babi, M. L. A., Guogping, Z., &amp; Ladu, J. L. C. 2017. Causes and consequences of rural-urban migration: The case of Juba Metropolitan, Republic of South Sudan. OP Conf. ''Series: Earth and Environmental Science'', 81:1-9.&lt;/ref&gt;basekelwa [[:en:Urbanization|Wikipedia (2025)]]&lt;ref&gt;Wikipedia. 2025. ''Urbanization''. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Urbanization&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 9 kuTjhirhweni 2025].&lt;/ref&gt; baveze bona ifuduko lemadorobheni nanyana ukufudukela emadorhobeni kulihlelo lelo elifaka hlangana umsikinyeko womuntu ukusuka kwesinye isiyingi ukuya kwesinye ngokwesikhatjhana nanyana safuthi. UMthiyane no-Wissink noChiwawa (2022) &lt;ref name=&quot;:0&quot;&gt;Mthiyane, D. B., Wissink, H. &amp; Chiwawa, N. 2022. The impact of rural–urban migration in South Africa: A case of KwaDukuza municipality’. ''Journal of Local Government Research and Innovation'', 3:1-9.&lt;/ref&gt;baveze ukuthi nanyana ukufudukela emadorobheni kulihlelo nanyana umsikinyeko ovamileko, kukhona umsikiyeko wabantu laba abafudukela emkhaya ukusuka emadorobheni ngokupheleleko. Ngamanye amagama, ukufuduka sele kumsikinyeko owenzeka ngokusuka edorobheni ukuya emakhaya nanyana ukusuka emakhaya ukuya edorobheni ngokuya kweemfuneko zomuntu. Esihlokweni esilandelako sizokutjheja iimbangela yefuduko lemadorobheni nanyana ukufudukela emadorobheni. 

=== Iimbangela zokufudukela emadorobheni nanyana zefuduko lemadorobheni. ===
Kukhona iimbangela ezahlukeneko ngokuya kokuhlakana kwabantu. Ezinye zeembangela ngilezi ezilandelako:

==== Amathuba wemisebenzi: ====
Abantu abanengi bafudukela emadorobheni ngebanga lokuthola amathuba angcono wemisebenzi (Mthiyane ''nabanye'', 2022&lt;ref name=&quot;:0&quot; /&gt;). Siyazi bonyana amabubululo namakhaphani amanengi begodu amakhulu lawo aqatjha abantu abanengi anzinze ngobunengi emadorobheni. Ngalokho-ke, abantu bafuna ukuzibandameza eduze nawo ukuze bafunyane umsebenzi. 

==== Imisebenzi yezamaphilo nezefundo. ====
Emadorobheni esikhanini esinengi banikela ngemisebenzi engcono yezamaphilo kanye nezefundo lokho okwenza bonyana abantu abanengi bakhethe ukufudukela emadorobheni ngombana bafuna ukufunyana imisebenzi leyo (Mthiyane ''nabanye'', 2022&lt;ref name=&quot;:0&quot; /&gt;).

==== Imirholo engcono. ====
Emadorobheni kunamathuba nobujamo obungcono bezomnotho begodu imisebenzi yakhona eminengi ibhadala ngcono ukudlula imisebenzi yemakhaya (Mthiyane ''nabanye'', 2022&lt;ref name=&quot;:0&quot; /&gt;). Ngakho-ke, abantu basuke babona kuhle ukuthi ukuze bakwazi ukuphila ngcono kuncono bafudukele emadorobheni ukuze bathole imisebenzi yemirholo engcono. 

Nanyana kunjalo, kukhona iinzunzo yokufudukela emadorobheni, begodu kukhona nobumbi. Esohlokwaneni esilandelako sizokutjheja ubumbi bokufudukela emadorobheni.

=== Ubumbi bokufudukela emadorobheni. ===
Kukhona ubumbi obunengi obubangelwa kufudukela emadorobheni ebufaka hlangana obulandelako:

==== Ukugcwala nokuminyana kwabantu. ====
Abantu nabafudukela emadorobheni babanga ukugcwala nokuminyana lokho okwenza bonyana imikhambo nemisikinyeko ibe budisi ukwenzeka ngezinye iinkathi (Mthiyane ''nabanye'', 2022&lt;ref name=&quot;:0&quot; /&gt;). Esikhathi esinengi ekuseni nangemva kwamadina lokha abantu nabaphuma emsebenzini kuyagcwala khulu begodu ekukhambeki lula. 

==== Izinga elikhulu lobulelesi. ====
Ukufudukela emadorobheni kwabantu abanengi nebabuya eendaweni ezahlukeneko kubanga izinga elikhulu lobulelesi, emadorobheni kanye neengoga zakhona (Mthiyane ''nabanye'', 2022&lt;ref name=&quot;:0&quot; /&gt;). Ngalokho-ke, kugcine kwenza madorobha kube ziindawo ezingakaphephi.

==== Ukutlhogeka kwezindlu. ====
Umbuso kanye nemiphakathi yemadorobheni izithola iseemrarweni omkhulu tle wokubhalelwa kokutholela woke umuntu indlu ngebanga lenomboro eliphezulu labantu abasemadorobheni kanye nokutlhogeka kwenarha (Mthiyane ''nabanye'', 2022&lt;ref name=&quot;:0&quot; /&gt;). Ngalokho-ke, abantu abanengi bazithola bahlala eendaweni ezingakaphephi kanye nemitlhatlhaneni ebazifakele yona ngokungalandeli imithetho. 

=== Isiphetho ===
Ifuduko lemadorobheni nanyana ukufudukela emadorobheni kwenzeka ngamabanga ahlukeneko kanye neendingo zabantu ezihlukeneko. Nanyana, abantu abanengi bangafudukela emadorobheni ngebanga lokuphila ipilo engcono; kodwana kukhona ubungozi nakho le edorobheni obuza nokufudukela khona. 

=== Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>ncnxztcy79a7bz5o4615gb8itgaxg7o</sha1>
    </revision>
    <revision>
      <id>2388</id>
      <parentid>2372</parentid>
      <timestamp>2025-01-28T06:18:24Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <minor />
      <origin>2388</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5323" sha1="dalsc6pki5qs23bk46axj7ktpjpdhc9" xml:space="preserve">== Ukufudukela emadorobheni nanyana ifuduko lemadorobheni. ==

=== Isingeniso ===
Ukufudukela emadorobheni ngelinye ihlelo esele lande khulu eemphakathini wekhethu. Abantu abanengi bathi nabakhulako nanyana ngebanga lemisebenzi neminye iimbandela, bazithola basuka emakhaya bayokuhlala emadorobheni. Nanyana kunjalo, kukhona indlazana elingafudukiko begodu elikhulele emakhaya belakha emakhaya. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyinini ukufudukela emadorobhen nanyana ifuduko lemadorobheni kanye neembangela zakhona. 

=== Kuyini ifunduko lemadorobheni nanyana ukufudekela emadorobheni? ===
[[Isimumathi:Ukufuduka.jpg|thumb|299x299px|Abantu bayafuduka]]
Ngokuya kuka-Malik (2015)&lt;ref&gt;Malik, A. S. 2015. Rural urban migration; socio-cultural changes in Pakistan preventive measures taken by government and civil society to control it. ''Professional Med J'', 22(6):674-682.&lt;/ref&gt; ifuduko lemadorobheni kulifuduko lelo elenzeka ephasini loke, khulukhulu nasiqala iinarha ezisathuthukako. UBabi, u-Gaugping, no-Ladu (2017) &lt;ref&gt;Babi, M. L. A., Guogping, Z., &amp; Ladu, J. L. C. 2017. Causes and consequences of rural-urban migration: The case of Juba Metropolitan, Republic of South Sudan. OP Conf. ''Series: Earth and Environmental Science'', 81:1-9.&lt;/ref&gt;basekelwa [[:en:Urbanization|Wikipedia (2025)]]&lt;ref&gt;Wikipedia. 2025. ''Urbanization''. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Urbanization&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 9 kuTjhirhweni 2025].&lt;/ref&gt; baveze bona ifuduko lemadorobheni nanyana ukufudukela emadorhobeni kulihlelo lelo elifaka hlangana umsikinyeko womuntu ukusuka kwesinye isiyingi ukuya kwesinye ngokwesikhatjhana nanyana safuthi. UMthiyane no-Wissink noChiwawa (2022) &lt;ref name=&quot;:0&quot;&gt;Mthiyane, D. B., Wissink, H. &amp; Chiwawa, N. 2022. The impact of rural–urban migration in South Africa: A case of KwaDukuza municipality’. ''Journal of Local Government Research and Innovation'', 3:1-9.&lt;/ref&gt;baveze ukuthi nanyana ukufudukela emadorobheni kulihlelo nanyana umsikinyeko ovamileko, kukhona umsikiyeko wabantu laba abafudukela emkhaya ukusuka emadorobheni ngokupheleleko. Ngamanye amagama, ukufuduka sele kumsikinyeko owenzeka ngokusuka edorobheni ukuya emakhaya nanyana ukusuka emakhaya ukuya edorobheni ngokuya kweemfuneko zomuntu. Esihlokweni esilandelako sizokutjheja iimbangela yefuduko lemadorobheni nanyana ukufudukela emadorobheni. 

=== Iimbangela zokufudukela emadorobheni nanyana zefuduko lemadorobheni. ===
Kukhona iimbangela ezahlukeneko ngokuya kokuhlakana kwabantu. Ezinye zeembangela ngilezi ezilandelako:

==== Amathuba wemisebenzi: ====
Abantu abanengi bafudukela emadorobheni ngebanga lokuthola amathuba angcono wemisebenzi (Mthiyane ''nabanye'', 2022&lt;ref name=&quot;:0&quot; /&gt;). Siyazi bonyana amabubululo namakhaphani amanengi begodu amakhulu lawo aqatjha abantu abanengi anzinze ngobunengi emadorobheni. Ngalokho-ke, abantu bafuna ukuzibandameza eduze nawo ukuze bafunyane umsebenzi. 

==== Imisebenzi yezamaphilo nezefundo. ====
Emadorobheni esikhanini esinengi banikela ngemisebenzi engcono yezamaphilo kanye nezefundo lokho okwenza bonyana abantu abanengi bakhethe ukufudukela emadorobheni ngombana bafuna ukufunyana imisebenzi leyo (Mthiyane ''nabanye'', 2022&lt;ref name=&quot;:0&quot; /&gt;).

==== Imirholo engcono. ====
Emadorobheni kunamathuba nobujamo obungcono bezomnotho begodu imisebenzi yakhona eminengi ibhadala ngcono ukudlula imisebenzi yemakhaya (Mthiyane ''nabanye'', 2022&lt;ref name=&quot;:0&quot; /&gt;). Ngakho-ke, abantu basuke babona kuhle ukuthi ukuze bakwazi ukuphila ngcono kuncono bafudukele emadorobheni ukuze bathole imisebenzi yemirholo engcono. 

Nanyana kunjalo, kukhona iinzunzo yokufudukela emadorobheni, begodu kukhona nobumbi. Esohlokwaneni esilandelako sizokutjheja ubumbi bokufudukela emadorobheni.

=== Ubumbi bokufudukela emadorobheni. ===
Kukhona ubumbi obunengi obubangelwa kufudukela emadorobheni ebufaka hlangana obulandelako:

==== Ukugcwala nokuminyana kwabantu. ====
Abantu nabafudukela emadorobheni babanga ukugcwala nokuminyana lokho okwenza bonyana imikhambo nemisikinyeko ibe budisi ukwenzeka ngezinye iinkathi (Mthiyane ''nabanye'', 2022&lt;ref name=&quot;:0&quot; /&gt;). Esikhathi esinengi ekuseni nangemva kwamadina lokha abantu nabaphuma emsebenzini kuyagcwala khulu begodu ekukhambeki lula. 

==== Izinga elikhulu lobulelesi. ====
Ukufudukela emadorobheni kwabantu abanengi nebabuya eendaweni ezahlukeneko kubanga izinga elikhulu lobulelesi, emadorobheni kanye neengoga zakhona (Mthiyane ''nabanye'', 2022&lt;ref name=&quot;:0&quot; /&gt;). Ngalokho-ke, kugcine kwenza madorobha kube ziindawo ezingakaphephi.

==== Ukutlhogeka kwezindlu. ====
Umbuso kanye nemiphakathi yemadorobheni izithola iseemrarweni omkhulu tle wokubhalelwa kokutholela woke umuntu indlu ngebanga lenomboro eliphezulu labantu abasemadorobheni kanye nokutlhogeka kwenarha (Mthiyane ''nabanye'', 2022&lt;ref name=&quot;:0&quot; /&gt;). Ngalokho-ke, abantu abanengi bazithola bahlala eendaweni ezingakaphephi kanye nemitlhatlhaneni ebazifakele yona ngokungalandeli imithetho. 

=== Isiphetho. ===
Ifuduko lemadorobheni nanyana ukufudukela emadorobheni kwenzeka ngamabanga ahlukeneko kanye neendingo zabantu ezihlukeneko. Nanyana, abantu abanengi bangafudukela emadorobheni ngebanga lokuphila ipilo engcono; kodwana kukhona ubungozi nakho le edorobheni obuza nokufudukela khona. 

=== Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>dalsc6pki5qs23bk46axj7ktpjpdhc9</sha1>
    </revision>
  </page>
  <page>
    <title>Ikoloyi yegezi.</title>
    <ns>0</ns>
    <id>456</id>
    <revision>
      <id>2373</id>
      <timestamp>2025-01-27T13:53:06Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <comment>Created page with &quot;== Ikoloyi yegezi. ==  === Isingeniso === Ipilo nayithuthukako neminyaka nayikhambako kubanetuthuko etja leyo eza namatjhugululo lawo anomthintela ekusebenziseni izinto. Ezinye zezinto zitjhuguluka ngokupheleleko kanti ezinye zitjhuguluke kancani. Iinkoloyi nazo ngezinye zezinto ezibongazimbi betuthuko yepilo namatjhuguluko wethekhnoloji. Elinye itjhuguluko netuthuko elinesithintela esikhulu [[Iinthuthi|eenkoloyini]], yigezi. Sekukhona iinkoloyi zegezi lezo ezisetjenzisw...&quot;</comment>
      <origin>2373</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5798" sha1="cvfanmlu7q394l7trmylfbw85w97zjt" xml:space="preserve">== Ikoloyi yegezi. ==

=== Isingeniso ===
Ipilo nayithuthukako neminyaka nayikhambako kubanetuthuko etja leyo eza namatjhugululo lawo anomthintela ekusebenziseni izinto. Ezinye zezinto zitjhuguluka ngokupheleleko kanti ezinye zitjhuguluke kancani. Iinkoloyi nazo ngezinye zezinto ezibongazimbi betuthuko yepilo namatjhuguluko wethekhnoloji. Elinye itjhuguluko netuthuko elinesithintela esikhulu [[Iinthuthi|eenkoloyini]], yigezi. Sekukhona iinkoloyi zegezi lezo ezisetjenziswako ephasi esiphila kilo leli. Eenhlokwaneni ezilandelako zizokutjheja bonyana yini iinkoloyi zegezi begodu imihlobo yeenkoloyi zegezi ngiyiphi. 

=== Yini iinkoloyi zegezi? ===
[[Isimumathi:Ikoloyi yegezi.jpg|thumb|510x510px|Ikoloyi yegezi iyatjhaja/ifaka umlilo (amandla)]]
Ngokuya kuka-Iulia no-Lorand (2022&lt;ref name=&quot;:0&quot;&gt;Iulia, V., &amp; Lorand, S. 2022. A Brief History of Electric Vehicles. ''Journal of Computer Science and Control Systems'', 15(1):19-26.&lt;/ref&gt;) basekelwa yi-U.S Department of Energy (2008&lt;ref name=&quot;:1&quot;&gt;U.S. Department of Energy. 2008. ''Electric Vehicle Basics''. U.S. Department of Energy.&lt;/ref&gt;) [[Iinthuthi|iinkoloyi]] zegezi kuziinkoloyi lezo ezisebenzisa igezi bonyana zikhambe nanyana zisebenze. U-Helmers no-Marx (2012) &lt;ref name=&quot;:2&quot;&gt;Helmers, E., &amp; Maxr, P. 2012. Electric cars: technical characteristics and environmental impacts. ''Environmental Science Europe'', 24 (14):1-15.&lt;/ref&gt;basekelwa yi-[[:en:Electric_car|Wikipedia (2025]])&lt;ref&gt;Wikipedia. 2025. ''Electric car.'' Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Electric_car&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 10 kuTjhirhweni 2025].&lt;/ref&gt; bangezelele bathi, iinkoloyi zegezi zitshwaye njengegadango eliqakathekileko lethekhnoloji ngombana zisebenzisa amandla nanyana umlilo omncani begodu azikhiqizi irhazi eyingozi ngezinga eliphezulu. Leli kuliphuzulu eliqakathekileko njengoba sazi bonyana iinkoloyi zinengi khulu tle eendleleni begodu kungakho zinesandla esikhulu mayelana nokukhiqizwa kwerhasi embi esilaphaza ibhoduluko. 

Nanyana kunjalo, kufanele siyelele bonyana iinkoloyi zegezi lezi azifaki iinthuthi ezikhulu njengamathraga, kodwana kufakwa iinkoloyi ezincani kanye namalori amancani (Helmers no-Marx, 2012&lt;ref name=&quot;:2&quot; /&gt;; [https://www.globalcitizen.org/en/content/electric-cars-comparison-fossil-fuels-transport/?gad_source=1&amp;gclid=CjwKCAiA-Oi7BhA1EiwA2rIu2ywCLOhMccThE1FgyyseIWIz1NI75VI0_GwT50EjTq4jJtn_-9hl5BoCxt4QAvD_BwE Global Citizen, 2025]&lt;ref&gt;Global Citizen. 2025. ''Electric Cars ‘Hundreds of Times’ More Efficient Than Fossil Fuel Cars''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.globalcitizen.org/en/content/electric-cars-comparison-fossil-fuels-transport/?gad_source=1&amp;gclid=CjwKCAiA-Oi7BhA1EiwA2rIu2ywCLOhMccThE1FgyyseIWIz1NI75VI0_GwT50EjTq4jJtn_-9hl5BoCxt4QAvD_BwE&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 10 kuTjhirhweni 2025]. &lt;/ref&gt;). Iinkoloyi zegezi lezi ngaso soke isikhathi kufanelwe zifakwe umlilo ngegezi ngaphambi kokuthi zikhambe begodu zinamambanga ezingawakhambi ngokuya kwamandla nanyana umlilo ezinawo (U.S Department of Energy, 2008&lt;ref name=&quot;:1&quot; /&gt;). Ngamanye amagama, lokha nawusebenzisa ikoloyi yegezi le kufanele wazi ukuthi nomlilo wayo uyaphela njalo nayiloko ikhamba. Esihlokweni esilandelako sizokutjheja imihlobo yeenkoloyi zegezi.

=== Imihlobo yeenkoloyi zegezi. ===
Imihlobo yeenkoloyi zegezi minengi; kodwana, ngebanga lekulumopendulwano yethu sizokutjheja nasi elandelako:

==== Ikoloyi esebenzisa igezi kwaphela ====
Ikoloyi esebenzisa igezi kwaphela, mhlobo wekoloyi loya ongathelwa ipetroli (Iulia and Lorand, 2022&lt;ref name=&quot;:0&quot; /&gt;; Joshi no-Gokhale-Welch, 2022&lt;ref&gt;Joshi, P., &amp; Gokhale-Welch, C. 2022''. Fundamentals of Electric Vehicles (EVs)''. USAID.&lt;/ref&gt;). Kodwana, umhlobo lo kufanele ufakwe umlilo ngegezi ngendlela yokuwutjhaja njengalokha nasitjhaja nanyana sifakela ufunjathwako umlilo. Ukungezelela, umhlobo lo ufuna utjhajwe isikhathi esithize ngaphandle kokuthi ungawutjhayela (Helmers no-Marx, 2012&lt;ref name=&quot;:2&quot; /&gt;).

==== Ikoloyi esebenzis igezi ne[[Ipetroli nedizili.|petroli]] ngesikhathi sinye. ====
Umhlobo wekoloyi osebenzisa igezi nepetroli ngesikhathi sinye, kuyikoloyi leyo ekufanelwe itjhajwe namkha ithelelwe ipetroli ukuze ikhambe (U.S Department of Energy, 2008&lt;ref name=&quot;:1&quot; /&gt;). Nakungenzeka bonyana awukhatheli ipetroli, kodwana ibhetri lona linomlilo iyakwazi ukukhamba ngokusebenzisa amandla webhetri wodwa (U.S Department of Energy, 2008). Ukungezelela, nakungenzeka bonyana umlilo webhetri mncani kodwana uneprtroli, lokha nawutjhayelako, ikoloyi le ngokwayo izokugcwalisa ibhetri leli (U.S Department of Energy, 2008&lt;ref name=&quot;:1&quot; /&gt;). 

==== Ubuhle nobumbi beenkoloyi zegezi ====
Iinkoloyi zegezi zikhiqiza irhasi embi kancani khulu nanyana aziyikhiqizi nangabe yikoloyi ikhambe ngegezi kwaphela (Helmers no-Marx, 2012&lt;ref name=&quot;:2&quot; /&gt;; U.S Department of Energy, 2008). Ukungezelela, iinkoloyi zegezi zitjhiphile ukuzifaka umlilo ukuze zitjhayelwe ukudlula iinkoloyi zee[[Iimbaseli|mbaseli]] (U.S Department of Energy, 2008).

Nanyana kunjalo, iinkoloyi zegezi zibiza khulu ukuzithenga lokha nawuziqathanisa neenkoloyi zeembaseli (U.S Department of Energy, 2008&lt;ref name=&quot;:1&quot; /&gt;). Ukungezelela, azikhambi amabanga amade khulu ngaphandle kokuthi zifunwe ukufakwa umlilo nanyana ukutjhajwa (U.S Department of Energy, 2008&lt;ref name=&quot;:1&quot; /&gt;). Ngamanye amagama, zinemikhawulo yamabanga ezingawakhamba lokha ibhetri naligcweleko, nakungenzeka zidlule amabanga lawo umlilo webhetri uzokuphela. 

=== Isiphetho ===
Iinkoloyi zegezi ziletha amatjhuguluko amahle lokha nasitjheja ukuhlwengeka kwezebhodululo nezamaphilo. Kodwana, akusibo boke abantu abangakghona ukuzifinyelela ngombana zibiza khudlwana kuneenkoloyi zeembaseli. Nanyana kunjalo, kuhle bonyana sizwisise bonyana ziyini iinkoloyi zegezi lezi. 

=== Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>cvfanmlu7q394l7trmylfbw85w97zjt</sha1>
    </revision>
    <revision>
      <id>2389</id>
      <parentid>2373</parentid>
      <timestamp>2025-01-28T06:19:12Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <minor />
      <origin>2389</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5799" sha1="7xoincmey7c34705px4mri8l72lzlkz" xml:space="preserve">== Ikoloyi yegezi. ==

=== Isingeniso. ===
Ipilo nayithuthukako neminyaka nayikhambako kubanetuthuko etja leyo eza namatjhugululo lawo anomthintela ekusebenziseni izinto. Ezinye zezinto zitjhuguluka ngokupheleleko kanti ezinye zitjhuguluke kancani. Iinkoloyi nazo ngezinye zezinto ezibongazimbi betuthuko yepilo namatjhuguluko wethekhnoloji. Elinye itjhuguluko netuthuko elinesithintela esikhulu [[Iinthuthi|eenkoloyini]], yigezi. Sekukhona iinkoloyi zegezi lezo ezisetjenziswako ephasi esiphila kilo leli. Eenhlokwaneni ezilandelako zizokutjheja bonyana yini iinkoloyi zegezi begodu imihlobo yeenkoloyi zegezi ngiyiphi. 

=== Yini iinkoloyi zegezi? ===
[[Isimumathi:Ikoloyi yegezi.jpg|thumb|510x510px|Ikoloyi yegezi iyatjhaja/ifaka umlilo (amandla)]]
Ngokuya kuka-Iulia no-Lorand (2022&lt;ref name=&quot;:0&quot;&gt;Iulia, V., &amp; Lorand, S. 2022. A Brief History of Electric Vehicles. ''Journal of Computer Science and Control Systems'', 15(1):19-26.&lt;/ref&gt;) basekelwa yi-U.S Department of Energy (2008&lt;ref name=&quot;:1&quot;&gt;U.S. Department of Energy. 2008. ''Electric Vehicle Basics''. U.S. Department of Energy.&lt;/ref&gt;) [[Iinthuthi|iinkoloyi]] zegezi kuziinkoloyi lezo ezisebenzisa igezi bonyana zikhambe nanyana zisebenze. U-Helmers no-Marx (2012) &lt;ref name=&quot;:2&quot;&gt;Helmers, E., &amp; Maxr, P. 2012. Electric cars: technical characteristics and environmental impacts. ''Environmental Science Europe'', 24 (14):1-15.&lt;/ref&gt;basekelwa yi-[[:en:Electric_car|Wikipedia (2025]])&lt;ref&gt;Wikipedia. 2025. ''Electric car.'' Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Electric_car&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 10 kuTjhirhweni 2025].&lt;/ref&gt; bangezelele bathi, iinkoloyi zegezi zitshwaye njengegadango eliqakathekileko lethekhnoloji ngombana zisebenzisa amandla nanyana umlilo omncani begodu azikhiqizi irhazi eyingozi ngezinga eliphezulu. Leli kuliphuzulu eliqakathekileko njengoba sazi bonyana iinkoloyi zinengi khulu tle eendleleni begodu kungakho zinesandla esikhulu mayelana nokukhiqizwa kwerhasi embi esilaphaza ibhoduluko. 

Nanyana kunjalo, kufanele siyelele bonyana iinkoloyi zegezi lezi azifaki iinthuthi ezikhulu njengamathraga, kodwana kufakwa iinkoloyi ezincani kanye namalori amancani (Helmers no-Marx, 2012&lt;ref name=&quot;:2&quot; /&gt;; [https://www.globalcitizen.org/en/content/electric-cars-comparison-fossil-fuels-transport/?gad_source=1&amp;gclid=CjwKCAiA-Oi7BhA1EiwA2rIu2ywCLOhMccThE1FgyyseIWIz1NI75VI0_GwT50EjTq4jJtn_-9hl5BoCxt4QAvD_BwE Global Citizen, 2025]&lt;ref&gt;Global Citizen. 2025. ''Electric Cars ‘Hundreds of Times’ More Efficient Than Fossil Fuel Cars''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.globalcitizen.org/en/content/electric-cars-comparison-fossil-fuels-transport/?gad_source=1&amp;gclid=CjwKCAiA-Oi7BhA1EiwA2rIu2ywCLOhMccThE1FgyyseIWIz1NI75VI0_GwT50EjTq4jJtn_-9hl5BoCxt4QAvD_BwE&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 10 kuTjhirhweni 2025]. &lt;/ref&gt;). Iinkoloyi zegezi lezi ngaso soke isikhathi kufanelwe zifakwe umlilo ngegezi ngaphambi kokuthi zikhambe begodu zinamambanga ezingawakhambi ngokuya kwamandla nanyana umlilo ezinawo (U.S Department of Energy, 2008&lt;ref name=&quot;:1&quot; /&gt;). Ngamanye amagama, lokha nawusebenzisa ikoloyi yegezi le kufanele wazi ukuthi nomlilo wayo uyaphela njalo nayiloko ikhamba. Esihlokweni esilandelako sizokutjheja imihlobo yeenkoloyi zegezi.

=== Imihlobo yeenkoloyi zegezi. ===
Imihlobo yeenkoloyi zegezi minengi; kodwana, ngebanga lekulumopendulwano yethu sizokutjheja nasi elandelako:

==== Ikoloyi esebenzisa igezi kwaphela ====
Ikoloyi esebenzisa igezi kwaphela, mhlobo wekoloyi loya ongathelwa ipetroli (Iulia and Lorand, 2022&lt;ref name=&quot;:0&quot; /&gt;; Joshi no-Gokhale-Welch, 2022&lt;ref&gt;Joshi, P., &amp; Gokhale-Welch, C. 2022''. Fundamentals of Electric Vehicles (EVs)''. USAID.&lt;/ref&gt;). Kodwana, umhlobo lo kufanele ufakwe umlilo ngegezi ngendlela yokuwutjhaja njengalokha nasitjhaja nanyana sifakela ufunjathwako umlilo. Ukungezelela, umhlobo lo ufuna utjhajwe isikhathi esithize ngaphandle kokuthi ungawutjhayela (Helmers no-Marx, 2012&lt;ref name=&quot;:2&quot; /&gt;).

==== Ikoloyi esebenzis igezi ne[[Ipetroli nedizili.|petroli]] ngesikhathi sinye. ====
Umhlobo wekoloyi osebenzisa igezi nepetroli ngesikhathi sinye, kuyikoloyi leyo ekufanelwe itjhajwe namkha ithelelwe ipetroli ukuze ikhambe (U.S Department of Energy, 2008&lt;ref name=&quot;:1&quot; /&gt;). Nakungenzeka bonyana awukhatheli ipetroli, kodwana ibhetri lona linomlilo iyakwazi ukukhamba ngokusebenzisa amandla webhetri wodwa (U.S Department of Energy, 2008). Ukungezelela, nakungenzeka bonyana umlilo webhetri mncani kodwana uneprtroli, lokha nawutjhayelako, ikoloyi le ngokwayo izokugcwalisa ibhetri leli (U.S Department of Energy, 2008&lt;ref name=&quot;:1&quot; /&gt;). 

==== Ubuhle nobumbi beenkoloyi zegezi ====
Iinkoloyi zegezi zikhiqiza irhasi embi kancani khulu nanyana aziyikhiqizi nangabe yikoloyi ikhambe ngegezi kwaphela (Helmers no-Marx, 2012&lt;ref name=&quot;:2&quot; /&gt;; U.S Department of Energy, 2008). Ukungezelela, iinkoloyi zegezi zitjhiphile ukuzifaka umlilo ukuze zitjhayelwe ukudlula iinkoloyi zee[[Iimbaseli|mbaseli]] (U.S Department of Energy, 2008).

Nanyana kunjalo, iinkoloyi zegezi zibiza khulu ukuzithenga lokha nawuziqathanisa neenkoloyi zeembaseli (U.S Department of Energy, 2008&lt;ref name=&quot;:1&quot; /&gt;). Ukungezelela, azikhambi amabanga amade khulu ngaphandle kokuthi zifunwe ukufakwa umlilo nanyana ukutjhajwa (U.S Department of Energy, 2008&lt;ref name=&quot;:1&quot; /&gt;). Ngamanye amagama, zinemikhawulo yamabanga ezingawakhamba lokha ibhetri naligcweleko, nakungenzeka zidlule amabanga lawo umlilo webhetri uzokuphela. 

=== Isiphetho ===
Iinkoloyi zegezi ziletha amatjhuguluko amahle lokha nasitjheja ukuhlwengeka kwezebhodululo nezamaphilo. Kodwana, akusibo boke abantu abangakghona ukuzifinyelela ngombana zibiza khudlwana kuneenkoloyi zeembaseli. Nanyana kunjalo, kuhle bonyana sizwisise bonyana ziyini iinkoloyi zegezi lezi. 

=== Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>7xoincmey7c34705px4mri8l72lzlkz</sha1>
    </revision>
    <revision>
      <id>5940</id>
      <parentid>2389</parentid>
      <timestamp>2025-11-01T12:00:29Z</timestamp>
      <contributor>
        <username>Hlalithwa</username>
        <id>996</id>
      </contributor>
      <minor />
      <comment>Spelling</comment>
      <origin>5940</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5805" sha1="7q9vibge0vi8gwzyeh9zxm7zsdqfkxc" xml:space="preserve">== Ikoloyi yegezi. ==

=== Isingeniso. ===
Ipilo nayithuthukako neeminyaka nayikhambako kubanethuthuko etja leyo eza namatjhugululo lawo anomthintela ekusebenziseni izinto. Ezinye zezinto zitjhuguluka ngokupheleleko kanti ezinye zitjhuguluke kancani. Iinkoloyi nazo ngezinye zezinto ezibongazimbi bethuthuko yepilo namatjhuguluko wethekhnoloji. Elinye itjhuguluko nethuthuko elinesithintela esikhulu [[Iinthuthi|eenkoloyini]], yigezi. Sekukhona iinkoloyi zegezi lezo ezisetjenziswako ephasini esiphila kilo leli. Eenhlokwaneni ezilandelako zizokutjheja bonyana yini iinkoloyi zegezi begodu imihlobo yeenkoloyi zegezi ngiyiphi. 

=== Yini iinkoloyi zegezi? ===
[[Isimumathi:Ikoloyi yegezi.jpg|thumb|510x510px|Ikoloyi yegezi iyatjhaja/ifaka umlilo (amandla)]]
Ngokuya kuka-Iulia no-Lorand (2022&lt;ref name=&quot;:0&quot;&gt;Iulia, V., &amp; Lorand, S. 2022. A Brief History of Electric Vehicles. ''Journal of Computer Science and Control Systems'', 15(1):19-26.&lt;/ref&gt;) basekelwa yi-U.S Department of Energy (2008&lt;ref name=&quot;:1&quot;&gt;U.S. Department of Energy. 2008. ''Electric Vehicle Basics''. U.S. Department of Energy.&lt;/ref&gt;) [[Iinthuthi|iinkoloyi]] zegezi kuziinkoloyi lezo ezisebenzisa igezi bonyana zikhambe nanyana zisebenze. U-Helmers no-Marx (2012) &lt;ref name=&quot;:2&quot;&gt;Helmers, E., &amp; Maxr, P. 2012. Electric cars: technical characteristics and environmental impacts. ''Environmental Science Europe'', 24 (14):1-15.&lt;/ref&gt;basekelwa yi-[[:en:Electric_car|Wikipedia (2025]])&lt;ref&gt;Wikipedia. 2025. ''Electric car.'' Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Electric_car&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 10 kuTjhirhweni 2025].&lt;/ref&gt; bangezelele bathi, iinkoloyi zegezi zitshwaye njengegadango eliqakathekileko lethekhnoloji ngombana zisebenzisa amandla nanyana umlilo omncani begodu azikhiqizi irhazi eyingozi ngezinga eliphezulu. Leli kuliphuzulu eliqakathekileko njengoba sazi bonyana iinkoloyi zinengi khulu tle eendleleni begodu kungakho zinesandla esikhulu mayelana nokukhiqizwa kwerhasi embi esilaphaza ibhoduluko. 

Nanyana kunjalo, kufanele siyelele bonyana iinkoloyi zegezi lezi azifaki iinthuthi ezikhulu njengamathraga, kodwana kufakwa iinkoloyi ezincani kanye namalori amancani (Helmers no-Marx, 2012&lt;ref name=&quot;:2&quot; /&gt;; [https://www.globalcitizen.org/en/content/electric-cars-comparison-fossil-fuels-transport/?gad_source=1&amp;gclid=CjwKCAiA-Oi7BhA1EiwA2rIu2ywCLOhMccThE1FgyyseIWIz1NI75VI0_GwT50EjTq4jJtn_-9hl5BoCxt4QAvD_BwE Global Citizen, 2025]&lt;ref&gt;Global Citizen. 2025. ''Electric Cars ‘Hundreds of Times’ More Efficient Than Fossil Fuel Cars''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.globalcitizen.org/en/content/electric-cars-comparison-fossil-fuels-transport/?gad_source=1&amp;gclid=CjwKCAiA-Oi7BhA1EiwA2rIu2ywCLOhMccThE1FgyyseIWIz1NI75VI0_GwT50EjTq4jJtn_-9hl5BoCxt4QAvD_BwE&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 10 kuTjhirhweni 2025]. &lt;/ref&gt;). Iinkoloyi zegezi lezi ngaso soke isikhathi kufanelwe zifakwe umlilo ngegezi ngaphambi kokuthi zikhambe begodu zinamabanga ezingawakhambi ngokuya kwamandla nanyana umlilo ezinawo (U.S Department of Energy, 2008&lt;ref name=&quot;:1&quot; /&gt;). Ngamanye amagama, lokha nawusebenzisa ikoloyi yegezi le kufanele wazi ukuthi nomlilo wayo uyaphela njalo nayiloko ikhamba. Esihlokweni esilandelako sizokutjheja imihlobo yeenkoloyi zegezi.

=== Imihlobo yeenkoloyi zegezi. ===
Imihlobo yeenkoloyi zegezi minengi; kodwana, ngebanga lekulumopendulwano yethu sizokutjheja nasi elandelako:

==== Ikoloyi esebenzisa igezi kwaphela ====
Ikoloyi esebenzisa igezi kwaphela, mhlobo wekoloyi loya ongathelwa ipetroli (Iulia and Lorand, 2022&lt;ref name=&quot;:0&quot; /&gt;; Joshi no-Gokhale-Welch, 2022&lt;ref&gt;Joshi, P., &amp; Gokhale-Welch, C. 2022''. Fundamentals of Electric Vehicles (EVs)''. USAID.&lt;/ref&gt;). Kodwana, umhlobo lo kufanele ufakwe umlilo ngegezi ngendlela yokuwutjhaja njengalokha nasitjhaja nanyana sifakela ufunjathwako umlilo. Ukungezelela, umhlobo lo ufuna utjhajwe isikhathi esithize ngaphandle kokuthi ungawutjhayela (Helmers no-Marx, 2012&lt;ref name=&quot;:2&quot; /&gt;).

==== Ikoloyi esebenzisa igezi ne[[Ipetroli nedizili.|petroli]] ngesikhathi sinye. ====
Umhlobo wekoloyi osebenzisa igezi nepetroli ngesikhathi sinye, kuyikoloyi leyo ekufanelwe itjhajwe namkha ithelelwe ipetroli ukuze ikhambe (U.S Department of Energy, 2008&lt;ref name=&quot;:1&quot; /&gt;). Nakungenzeka bonyana awukhatheli ipetroli, kodwana ibhetri lona linomlilo iyakwazi ukukhamba ngokusebenzisa amandla webhetri wodwa (U.S Department of Energy, 2008). Ukungezelela, nakungenzeka bonyana umlilo webhetri mncani kodwana uneprtroli, lokha nawutjhayelako, ikoloyi le ngokwayo izokugcwalisa ibhetri leli (U.S Department of Energy, 2008&lt;ref name=&quot;:1&quot; /&gt;). 

==== Ubuhle nobumbi beenkoloyi zegezi ====
Iinkoloyi zegezi zikhiqiza irhasi embi kancani khulu nanyana aziyikhiqizi nangabe yikoloyi ikhambe ngegezi kwaphela (Helmers no-Marx, 2012&lt;ref name=&quot;:2&quot; /&gt;; U.S Department of Energy, 2008). Ukungezelela, iinkoloyi zegezi zitjhiphile ukuzifaka umlilo ukuze zitjhayelwe ukudlula iinkoloyi zee[[Iimbaseli|mbaseli]] (U.S Department of Energy, 2008).

Nanyana kunjalo, iinkoloyi zegezi zibiza khulu ukuzithenga lokha nawuziqathanisa neenkoloyi zeembaseli (U.S Department of Energy, 2008&lt;ref name=&quot;:1&quot; /&gt;). Ukungezelela, azikhambi amabanga amade khulu ngaphandle kokuthi zifunwe ukufakwa umlilo nanyana ukutjhajwa (U.S Department of Energy, 2008&lt;ref name=&quot;:1&quot; /&gt;). Ngamanye amagama, zinemikhawulo yamabanga ezingawakhamba lokha ibhetri naligcweleko, nakungenzeka zidlule amabanga lawo umlilo webhetri uzokuphela. 

=== Isiphetho ===
Iinkoloyi zegezi ziletha amatjhuguluko amahle lokha nasitjheja ukuhlwengeka kwezebhodululo nezamaphilo. Kodwana, akusibo boke abantu abangakghona ukuzifinyelela ngombana zibiza khudlwana kuneenkoloyi zeembaseli. Nanyana kunjalo, kuhle bonyana sizwisise bonyana ziyini iinkoloyi zegezi lezi. 

=== Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>7q9vibge0vi8gwzyeh9zxm7zsdqfkxc</sha1>
    </revision>
  </page>
  <page>
    <title>Umvuzo wokulala ngokwaneleko.</title>
    <ns>0</ns>
    <id>457</id>
    <revision>
      <id>2374</id>
      <timestamp>2025-01-27T14:12:56Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <comment>Created page with &quot;== Umvuzo wokulala ngokwaneleko. ==  === Isingeniso === Ukulala ngezinye zezinto eziqakathekileko bonyana umuntu azenze qobe ngamalanga. Ngamanye amagama, ukulala kusisenzo leso esikatelelekileko bonyana umuntu asenze ngamalanga. Nanyana kunjalo, ngebanga leminqopho neembangela ezahlukeneko, abantu abanengi balala ngeenkathi ezahlukileko begodu balala ama-iri ahlukileko. Kodwana, ukulala kuyakhonjelwa basebenzi bezamaphilo kanye nabahlengi bezengqondo. Esihlokwaneni esil...&quot;</comment>
      <origin>2374</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4633" sha1="748lqhgdx76d0cubcz1umzfwb8fxwwc" xml:space="preserve">== Umvuzo wokulala ngokwaneleko. ==

=== Isingeniso ===
Ukulala ngezinye zezinto eziqakathekileko bonyana umuntu azenze qobe ngamalanga. Ngamanye amagama, ukulala kusisenzo leso esikatelelekileko bonyana umuntu asenze ngamalanga. Nanyana kunjalo, ngebanga leminqopho neembangela ezahlukeneko, abantu abanengi balala ngeenkathi ezahlukileko begodu balala ama-iri ahlukileko. Kodwana, ukulala kuyakhonjelwa basebenzi bezamaphilo kanye nabahlengi bezengqondo. Esihlokwaneni esilandelako sizokutjheja imivuzo yokulala ngokwaneleko.

=== Imivuzo yokulala ngokwaneleko. ===
[[Isimumathi:Ukulala.jpg|thumb|290x290px|Umuntu ulele.]]
Minengi imivuzo nanyana iinzunzo yokulala ngokwaneleko. Eminye yemivuzo nanyana iinzunzo yokulala ngokwaneleko ifaka hlangana elandelako:

==== Kunciphisa izinga lokugula ====
Ngokuya kwe-University of Oxford (2023)&lt;ref&gt;University of Oxford. 2023. ''Waking up to the health benefits of sleep''. Royal Society for Public Health: Vision, Voice and Practice. &lt;/ref&gt; ukulala ngokwaneleko kwehlisa amazinga wokubanjwa bulwele behliziyo, itjhukela kanye nobulwele bokufa ihlangothi lomzimba. I-American Heart Association (2024) &lt;ref name=&quot;:0&quot;&gt;American Heart Association. 2024. ''How does sleep affect my health?.'' Answers by heart.&lt;/ref&gt;ingezelele yathi, ukungalali kuhle kungabanomthintela omumbi kwezamaphilo zakho ngokuthi kukhuphule amazinga wokubanjwa lizinga eliphezulu leengazi, ukunona ngokudluleleko kanye nokugandeleleka ngomkhumbulo. 

==== Izinga elihle lokucabanga. ====
Ngokuya kwe-American Heart Association (2024)&lt;ref name=&quot;:0&quot; /&gt; ukulala ngokwaneleko kwenza bonyana umuntu acabange kuhle begodu nezinga lakhe lobuhlakani nokurhumutjha izinto liyanda. Ngamanye amagama, lokha nawungakalali ngokwaneleko, ingqondo yakho ayisebenzi kuhle nengizinga elifunekako nakuza ekuzwisiseni izinto nekuthatheni iinqunto ezizwakalo alikho. 

==== Ukwandiswa kwamalanga wokuphila. ====
Lokha nawulala ama-iri ali-7 ukuya kwabu-8 qobe ngobusuku, kwandisa amalanga nanyana isikhathi sakho sokuphila ([https://studenthealth.studentaffairs.miami.edu/health-education/health-ed-services/ra-resource-page/benefits-of-sleep.pdf Student Health] [https://studenthealth.studentaffairs.miami.edu/health-education/health-ed-services/ra-resource-page/benefits-of-sleep.pdf of Miami, 2023]&lt;ref name=&quot;:1&quot;&gt;Student Health of Miami. 2023. ''Benefits of sleep''. Litholakala ku:&lt; &lt;nowiki&gt;https://studenthealth.studentaffairs.miami.edu/health-education/health-ed-services/ra-resource-page/benefits-of-sleep.pdf&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 10 kuTjhirhweni 2025]. &lt;/ref&gt;). I-Student Health of Miami (2024&lt;ref name=&quot;:1&quot; /&gt;) ingezelele yathi, kufanele wazi bonyana ukulala ama-iri asithantathu ukuya phasi nanyana ukulala ama-iri adlula kwabu-8, akukalungi begodu kungaba nomthelela oyingozi. 

==== Ukukhuphuka kwezinga lokusebenza. ====
Ukulala ngokwaneleko kusiza khulu bonyana umuntu akwazi ukusebenza kuhle nangezinga eliphezulu ([https://www.healthline.com/nutrition/10-reasons-why-good-sleep-is-important#The-bottom-line Health Line, 2023]&lt;ref name=&quot;:2&quot;&gt;Health Line. 2023. ''10 Reasons to Get More Sleep''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.healthline.com/nutrition/10-reasons-why-good-sleep-is-important#The-bottom-line&lt;/nowiki&gt;&gt;. &lt;/ref&gt;). I-Health Line (2023)&lt;ref name=&quot;:2&quot; /&gt; ingezelele yathi, lokha nawulele ngokwanelelo nengqondo yakho ikwazi ukunzinza begodu iqalane nalokho okwenzako ngaphandle kokuphazamiseka. 

==== Kusiza ukwehlisa umzimba ====
Ukulala ngokwaneleko kuqakatheke khulu ngombana kudlala indima ekulu ekukhuleni nokwehleni komzimba. Ngokuya kwe-[https://health.ucdavis.edu/blog/cultivating-health/better-sleep-why-its-important-for-your-health-and-tips-to-sleep-soundly/2023/03 Cultivating Health (2023)]&lt;ref&gt;Cultivating Health. 2023. ''Better sleep: Why it’s important for your health and tips to sleep soundly. Litholakala'' ku:&lt; &lt;nowiki&gt;https://health.ucdavis.edu/blog/cultivating-health/better-sleep-why-its-important-for-your-health-and-tips-to-sleep-soundly/2023/03&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 10 kuTjhirhweni 2025].&lt;/ref&gt; ukulala ngokwaneleko kungakusiza lokha nawufuna ukwehlisa umzimba nanyana ufuna ukuwukhulisa ngombana ukukhamba kweengazi nokusebenza komzimba kusuke kusebenza kuhle. 

=== Isiphetho ===
Ukulala ngokwaneleko kuqakathekile emntwini ngombana kuneenzunzo efana nokwehlisa izinga lokubanjwa kugula nokugandlelela ngomkhumbulo. Nanyana kunjalo, kufanele sikhumbule bonyana  ukulala kusisenzo esikathelelekileko bonyana sisenze sibabantu begodu sisenze kuhle ngombana nasingasenzi kuhle, singazithola ebujameni obungasi buhle. 

=== Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>748lqhgdx76d0cubcz1umzfwb8fxwwc</sha1>
    </revision>
    <revision>
      <id>2390</id>
      <parentid>2374</parentid>
      <timestamp>2025-01-28T06:20:13Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <minor />
      <origin>2390</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4634" sha1="nzv0pgq8974zpah4ab20qovenks1bv4" xml:space="preserve">== Umvuzo wokulala ngokwaneleko. ==

=== Isingeniso. ===
Ukulala ngezinye zezinto eziqakathekileko bonyana umuntu azenze qobe ngamalanga. Ngamanye amagama, ukulala kusisenzo leso esikatelelekileko bonyana umuntu asenze ngamalanga. Nanyana kunjalo, ngebanga leminqopho neembangela ezahlukeneko, abantu abanengi balala ngeenkathi ezahlukileko begodu balala ama-iri ahlukileko. Kodwana, ukulala kuyakhonjelwa basebenzi bezamaphilo kanye nabahlengi bezengqondo. Esihlokwaneni esilandelako sizokutjheja imivuzo yokulala ngokwaneleko.

=== Imivuzo yokulala ngokwaneleko. ===
[[Isimumathi:Ukulala.jpg|thumb|290x290px|Umuntu ulele.]]
Minengi imivuzo nanyana iinzunzo yokulala ngokwaneleko. Eminye yemivuzo nanyana iinzunzo yokulala ngokwaneleko ifaka hlangana elandelako:

==== Kunciphisa izinga lokugula ====
Ngokuya kwe-University of Oxford (2023)&lt;ref&gt;University of Oxford. 2023. ''Waking up to the health benefits of sleep''. Royal Society for Public Health: Vision, Voice and Practice. &lt;/ref&gt; ukulala ngokwaneleko kwehlisa amazinga wokubanjwa bulwele behliziyo, itjhukela kanye nobulwele bokufa ihlangothi lomzimba. I-American Heart Association (2024) &lt;ref name=&quot;:0&quot;&gt;American Heart Association. 2024. ''How does sleep affect my health?.'' Answers by heart.&lt;/ref&gt;ingezelele yathi, ukungalali kuhle kungabanomthintela omumbi kwezamaphilo zakho ngokuthi kukhuphule amazinga wokubanjwa lizinga eliphezulu leengazi, ukunona ngokudluleleko kanye nokugandeleleka ngomkhumbulo. 

==== Izinga elihle lokucabanga. ====
Ngokuya kwe-American Heart Association (2024)&lt;ref name=&quot;:0&quot; /&gt; ukulala ngokwaneleko kwenza bonyana umuntu acabange kuhle begodu nezinga lakhe lobuhlakani nokurhumutjha izinto liyanda. Ngamanye amagama, lokha nawungakalali ngokwaneleko, ingqondo yakho ayisebenzi kuhle nengizinga elifunekako nakuza ekuzwisiseni izinto nekuthatheni iinqunto ezizwakalo alikho. 

==== Ukwandiswa kwamalanga wokuphila. ====
Lokha nawulala ama-iri ali-7 ukuya kwabu-8 qobe ngobusuku, kwandisa amalanga nanyana isikhathi sakho sokuphila ([https://studenthealth.studentaffairs.miami.edu/health-education/health-ed-services/ra-resource-page/benefits-of-sleep.pdf Student Health] [https://studenthealth.studentaffairs.miami.edu/health-education/health-ed-services/ra-resource-page/benefits-of-sleep.pdf of Miami, 2023]&lt;ref name=&quot;:1&quot;&gt;Student Health of Miami. 2023. ''Benefits of sleep''. Litholakala ku:&lt; &lt;nowiki&gt;https://studenthealth.studentaffairs.miami.edu/health-education/health-ed-services/ra-resource-page/benefits-of-sleep.pdf&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 10 kuTjhirhweni 2025]. &lt;/ref&gt;). I-Student Health of Miami (2024&lt;ref name=&quot;:1&quot; /&gt;) ingezelele yathi, kufanele wazi bonyana ukulala ama-iri asithantathu ukuya phasi nanyana ukulala ama-iri adlula kwabu-8, akukalungi begodu kungaba nomthelela oyingozi. 

==== Ukukhuphuka kwezinga lokusebenza. ====
Ukulala ngokwaneleko kusiza khulu bonyana umuntu akwazi ukusebenza kuhle nangezinga eliphezulu ([https://www.healthline.com/nutrition/10-reasons-why-good-sleep-is-important#The-bottom-line Health Line, 2023]&lt;ref name=&quot;:2&quot;&gt;Health Line. 2023. ''10 Reasons to Get More Sleep''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.healthline.com/nutrition/10-reasons-why-good-sleep-is-important#The-bottom-line&lt;/nowiki&gt;&gt;. &lt;/ref&gt;). I-Health Line (2023)&lt;ref name=&quot;:2&quot; /&gt; ingezelele yathi, lokha nawulele ngokwanelelo nengqondo yakho ikwazi ukunzinza begodu iqalane nalokho okwenzako ngaphandle kokuphazamiseka. 

==== Kusiza ukwehlisa umzimba ====
Ukulala ngokwaneleko kuqakatheke khulu ngombana kudlala indima ekulu ekukhuleni nokwehleni komzimba. Ngokuya kwe-[https://health.ucdavis.edu/blog/cultivating-health/better-sleep-why-its-important-for-your-health-and-tips-to-sleep-soundly/2023/03 Cultivating Health (2023)]&lt;ref&gt;Cultivating Health. 2023. ''Better sleep: Why it’s important for your health and tips to sleep soundly. Litholakala'' ku:&lt; &lt;nowiki&gt;https://health.ucdavis.edu/blog/cultivating-health/better-sleep-why-its-important-for-your-health-and-tips-to-sleep-soundly/2023/03&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 10 kuTjhirhweni 2025].&lt;/ref&gt; ukulala ngokwaneleko kungakusiza lokha nawufuna ukwehlisa umzimba nanyana ufuna ukuwukhulisa ngombana ukukhamba kweengazi nokusebenza komzimba kusuke kusebenza kuhle. 

=== Isiphetho ===
Ukulala ngokwaneleko kuqakathekile emntwini ngombana kuneenzunzo efana nokwehlisa izinga lokubanjwa kugula nokugandlelela ngomkhumbulo. Nanyana kunjalo, kufanele sikhumbule bonyana  ukulala kusisenzo esikathelelekileko bonyana sisenze sibabantu begodu sisenze kuhle ngombana nasingasenzi kuhle, singazithola ebujameni obungasi buhle. 

=== Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>nzv0pgq8974zpah4ab20qovenks1bv4</sha1>
    </revision>
  </page>
  <page>
    <title>Itheku.</title>
    <ns>0</ns>
    <id>458</id>
    <revision>
      <id>2375</id>
      <timestamp>2025-01-28T05:23:53Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <comment>Created page with &quot;== Itheku. ==  === Isingeniso === Itheku ngezinye zeendawo ezithandwa khulu babantu. Abantu abanengi bayathanda ukuziphumela, ukuzikhuphela nanyana ukuvakatjhela khona nanyana baphumuze ingqondo khona. Nanyana kunjalo, amatheku la akatholakali koke inarheni. Kukhona iimfunda ezinganawo. Eenhlokweni ezilandelako sizokutjheja bonyana itheku liyini begodu litholakala eendaweni ezinjani.  === Kuyini itheku? === Ngokuya kwe-[[:en:Bay|Wikipedia (2025]])&lt;ref&gt;Wikipedia. 2025. ''...&quot;</comment>
      <origin>2375</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3894" sha1="edk3kkupm438frpb1sy2zwxyvj774ff" xml:space="preserve">== Itheku. ==

=== Isingeniso ===
Itheku ngezinye zeendawo ezithandwa khulu babantu. Abantu abanengi bayathanda ukuziphumela, ukuzikhuphela nanyana ukuvakatjhela khona nanyana baphumuze ingqondo khona. Nanyana kunjalo, amatheku la akatholakali koke inarheni. Kukhona iimfunda ezinganawo. Eenhlokweni ezilandelako sizokutjheja bonyana itheku liyini begodu litholakala eendaweni ezinjani.

=== Kuyini itheku? ===
Ngokuya kwe-[[:en:Bay|Wikipedia (2025]])&lt;ref&gt;Wikipedia. 2025. ''Bay''. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Bay&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 11 kuTjhirhweni 2025].&lt;/ref&gt; isekelwa yi-[https://www.alsharqi.co/glossary/what-is-bay/ Alsharqi (2025)] &lt;ref&gt;Alsharqi. 2025. ''Bay''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.alsharqi.co/glossary/what-is-bay/&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 11 kuTjhirhweni 2025].&lt;/ref&gt;itheku kulibala elikhulu lamanzi lelo elihlangana bunqopha namanzi welwandle. I-[https://education.nationalgeographic.org/resource/bay/ National Geographic (2025])&lt;ref name=&quot;:0&quot;&gt;National Geographic. 2025. ''Bay''. Litholakala ku:&lt; &lt;nowiki&gt;https://education.nationalgeographic.org/resource/bay/&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 11 kuTjhirhweni 2025].&lt;/ref&gt; ingezelele yathi, itheku kulibala lamanzi lelo elizonjelelwe ihlabathi ukuze abantu bakwazi ukukhamba benze nezinye izinto. Ngamanye amagama, itheku kulibala lamanzi lawo ayingcenye yelwandle asekuthomeni kwelwandle lapho kuhlangene khona nehlabathi nanyana indawo eyomileko ukuze abantu bakwazi ukukhamba begodu baye emanzini badude. Kwesinye isikhathi uthola ukuthi amanzi la kumamanzi abuya elwandle nemlanjenikazi  (National Geographic, 2025)&lt;ref name=&quot;:0&quot; /&gt;.

Itheku alisiyindawo ethandwa babantu kwaphela; kodwana, liyikhaya leenlwani ezinengi zemanzini  ezifaka hlangana iimfesi, ikghuru neenkalakala (National Geographic. 2025)&lt;ref name=&quot;:0&quot; /&gt;. Itheku libuye lisize khulu mayelana nemithwalo neempahla evela kwezinye iinarha nanyana ethunyelwa kwezinye iinarha ngemikhumbi ngombana idoyelo lemikhumbi litholakala khulu emathekwini ([https://kids.britannica.com/students/article/bay/633561 Kids Britannica, 2025])&lt;ref&gt;Kids Britannica. 2025. ''Bay''. Litholakala ku:&lt; &lt;nowiki&gt;https://kids.britannica.com/students/article/bay/633561&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 11 kuTjhirhweni 2025].&lt;/ref&gt;. Kufanele sikhumbule bonyana lokha iimpahla nazithunyelwa ngaphandle nanyana zamukelwa la eSewula Afrika, kufanele kube nendawo la imikhumbi izakwazi ukujama khona lula ukuze iimpahla lezo zilayitjhwe nanyana zihliswe begodu ukghone ukusuka lula, iindawo lezo matheku.

=== Iindawo nanyana iimfunda la amatheku atholakala khona. ===
ESewula Afrika amatheku akatholakali kizo zoke iimfunda ngebanga lokuthi ezinye zeemfunda ziimfunda ezingaphakathi kwenarha njengeGauteng neMpumalanga ([https://www.britannica.com/science/estuary Britannica, 2025]&lt;ref&gt;Britannica. 2025. ''Bay''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.britannica.com/science/estuary&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 11 kuTjhirhweni 2025].&lt;/ref&gt;). Kodwana iimfunda ezilandelako zinamatheku: IKwaZulu Natala, iTlhagwini Kapa, iPumalanga Kapa neTjhingalanga Kapa. Iimfunda ezine lezi zinemithetho leyo elawula ukusetjenziswa kwamatheku babantu, imiphakathi kanye namabubululo ngokusebenzisana neenhlangano ezifana nesiGungu seSewula Afrika somThelo leso esitjheje bona yoke ipahla eza eSewula Afrika kufanele bonyana ibhadele umthetho ogunyazwako.

=== Isiphetho. ===
Itheku linemisebenzi eminengi eempilweni zabantu ngaphandle kokuba yindawo yokunandisa nalapho abantu baditjha khona. Kodwana, lidlala indima eqakathekileko mayela nokunikela enye indlela yokuthuthwa kweempahla lezo eziya ngaphandle kwezinye iinarha nanyana ezivela kwezinye iinarha eziza ngekhaya. Ngalokho-ke, kuqakathekile bona sizijwayeze bonyana itheku liyini begodu lisetjenziswa njani ukuze sikhambelane nemithetho yawo.

=== Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>edk3kkupm438frpb1sy2zwxyvj774ff</sha1>
    </revision>
    <revision>
      <id>2569</id>
      <parentid>2375</parentid>
      <timestamp>2025-03-22T05:37:17Z</timestamp>
      <contributor>
        <username>Kvazimodo</username>
        <id>341</id>
      </contributor>
      <origin>2569</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3864" sha1="qpk02gwh3omzjflcmphfqo1dw3pk36u" xml:space="preserve">'''Itheku'''; Itheku ngezinye zeendawo ezithandwa khulu babantu. Abantu abanengi bayathanda ukuziphumela, ukuzikhuphela nanyana ukuvakatjhela khona nanyana baphumuze ingqondo khona. Nanyana kunjalo, amatheku la akatholakali koke inarheni. Kukhona iimfunda ezinganawo. Eenhlokweni ezilandelako sizokutjheja bonyana itheku liyini begodu litholakala eendaweni ezinjani.

== Kuyini itheku? ==
Ngokuya kwe-[[:en:Bay|Wikipedia (2025]])&lt;ref&gt;Wikipedia. 2025. ''Bay''. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Bay&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 11 kuTjhirhweni 2025].&lt;/ref&gt; isekelwa yi-[https://www.alsharqi.co/glossary/what-is-bay/ Alsharqi (2025)] &lt;ref&gt;Alsharqi. 2025. ''Bay''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.alsharqi.co/glossary/what-is-bay/&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 11 kuTjhirhweni 2025].&lt;/ref&gt;itheku kulibala elikhulu lamanzi lelo elihlangana bunqopha namanzi welwandle. I-[https://education.nationalgeographic.org/resource/bay/ National Geographic (2025])&lt;ref name=&quot;:0&quot;&gt;National Geographic. 2025. ''Bay''. Litholakala ku:&lt; &lt;nowiki&gt;https://education.nationalgeographic.org/resource/bay/&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 11 kuTjhirhweni 2025].&lt;/ref&gt; ingezelele yathi, itheku kulibala lamanzi lelo elizonjelelwe ihlabathi ukuze abantu bakwazi ukukhamba benze nezinye izinto. Ngamanye amagama, itheku kulibala lamanzi lawo ayingcenye yelwandle asekuthomeni kwelwandle lapho kuhlangene khona nehlabathi nanyana indawo eyomileko ukuze abantu bakwazi ukukhamba begodu baye emanzini badude. Kwesinye isikhathi uthola ukuthi amanzi la kumamanzi abuya elwandle nemlanjenikazi  (National Geographic, 2025)&lt;ref name=&quot;:0&quot; /&gt;.

Itheku alisiyindawo ethandwa babantu kwaphela; kodwana, liyikhaya leenlwani ezinengi zemanzini  ezifaka hlangana iimfesi, ikghuru neenkalakala (National Geographic. 2025)&lt;ref name=&quot;:0&quot; /&gt;. Itheku libuye lisize khulu mayelana nemithwalo neempahla evela kwezinye iinarha nanyana ethunyelwa kwezinye iinarha ngemikhumbi ngombana idoyelo lemikhumbi litholakala khulu emathekwini ([https://kids.britannica.com/students/article/bay/633561 Kids Britannica, 2025])&lt;ref&gt;Kids Britannica. 2025. ''Bay''. Litholakala ku:&lt; &lt;nowiki&gt;https://kids.britannica.com/students/article/bay/633561&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 11 kuTjhirhweni 2025].&lt;/ref&gt;. Kufanele sikhumbule bonyana lokha iimpahla nazithunyelwa ngaphandle nanyana zamukelwa la eSewula Afrika, kufanele kube nendawo la imikhumbi izakwazi ukujama khona lula ukuze iimpahla lezo zilayitjhwe nanyana zihliswe begodu ukghone ukusuka lula, iindawo lezo matheku.

== Iindawo nanyana iimfunda la amatheku atholakala khona ==
ESewula Afrika amatheku akatholakali kizo zoke iimfunda ngebanga lokuthi ezinye zeemfunda ziimfunda ezingaphakathi kwenarha njengeGauteng neMpumalanga ([https://www.britannica.com/science/estuary Britannica, 2025]&lt;ref&gt;Britannica. 2025. ''Bay''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.britannica.com/science/estuary&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 11 kuTjhirhweni 2025].&lt;/ref&gt;). Kodwana iimfunda ezilandelako zinamatheku: IKwaZulu Natala, iTlhagwini Kapa, iPumalanga Kapa neTjhingalanga Kapa. Iimfunda ezine lezi zinemithetho leyo elawula ukusetjenziswa kwamatheku babantu, imiphakathi kanye namabubululo ngokusebenzisana neenhlangano ezifana nesiGungu seSewula Afrika somThelo leso esitjheje bona yoke ipahla eza eSewula Afrika kufanele bonyana ibhadele umthetho ogunyazwako.

== Isiphetho ==
Itheku linemisebenzi eminengi eempilweni zabantu ngaphandle kokuba yindawo yokunandisa nalapho abantu baditjha khona. Kodwana, lidlala indima eqakathekileko mayela nokunikela enye indlela yokuthuthwa kweempahla lezo eziya ngaphandle kwezinye iinarha nanyana ezivela kwezinye iinarha eziza ngekhaya. Ngalokho-ke, kuqakathekile bona sizijwayeze bonyana itheku liyini begodu lisetjenziswa njani ukuze sikhambelane nemithetho yawo.

== Umthombolwazi ==
&lt;references /&gt;</text>
      <sha1>qpk02gwh3omzjflcmphfqo1dw3pk36u</sha1>
    </revision>
    <revision>
      <id>2979</id>
      <parentid>2569</parentid>
      <timestamp>2025-06-06T20:07:37Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>ynhrtbgerfv</comment>
      <origin>2979</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3945" sha1="p1di3zb4r3iaefswcjieaf85zi193vq" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. Itheku'''; Itheku ngezinye zeendawo ezithandwa khulu babantu. Abantu abanengi bayathanda ukuziphumela, ukuzikhuphela nanyana ukuvakatjhela khona nanyana baphumuze ingqondo khona. Nanyana kunjalo, amatheku la akatholakali koke inarheni. Kukhona iimfunda ezinganawo. Eenhlokweni ezilandelako sizokutjheja bonyana itheku liyini begodu litholakala eendaweni ezinjani.

== Kuyini itheku? ==
Ngokuya kwe-[[:en:Bay|Wikipedia (2025]])&lt;ref&gt;Wikipedia. 2025. ''Bay''. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Bay&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 11 kuTjhirhweni 2025].&lt;/ref&gt; isekelwa yi-[https://www.alsharqi.co/glossary/what-is-bay/ Alsharqi (2025)] &lt;ref&gt;Alsharqi. 2025. ''Bay''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.alsharqi.co/glossary/what-is-bay/&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 11 kuTjhirhweni 2025].&lt;/ref&gt;itheku kulibala elikhulu lamanzi lelo elihlangana bunqopha namanzi welwandle. I-[https://education.nationalgeographic.org/resource/bay/ National Geographic (2025])&lt;ref name=&quot;:0&quot;&gt;National Geographic. 2025. ''Bay''. Litholakala ku:&lt; &lt;nowiki&gt;https://education.nationalgeographic.org/resource/bay/&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 11 kuTjhirhweni 2025].&lt;/ref&gt; ingezelele yathi, itheku kulibala lamanzi lelo elizonjelelwe ihlabathi ukuze abantu bakwazi ukukhamba benze nezinye izinto. Ngamanye amagama, itheku kulibala lamanzi lawo ayingcenye yelwandle asekuthomeni kwelwandle lapho kuhlangene khona nehlabathi nanyana indawo eyomileko ukuze abantu bakwazi ukukhamba begodu baye emanzini badude. Kwesinye isikhathi uthola ukuthi amanzi la kumamanzi abuya elwandle nemlanjenikazi  (National Geographic, 2025)&lt;ref name=&quot;:0&quot; /&gt;.

Itheku alisiyindawo ethandwa babantu kwaphela; kodwana, liyikhaya leenlwani ezinengi zemanzini  ezifaka hlangana iimfesi, ikghuru neenkalakala (National Geographic. 2025)&lt;ref name=&quot;:0&quot; /&gt;. Itheku libuye lisize khulu mayelana nemithwalo neempahla evela kwezinye iinarha nanyana ethunyelwa kwezinye iinarha ngemikhumbi ngombana idoyelo lemikhumbi litholakala khulu emathekwini ([https://kids.britannica.com/students/article/bay/633561 Kids Britannica, 2025])&lt;ref&gt;Kids Britannica. 2025. ''Bay''. Litholakala ku:&lt; &lt;nowiki&gt;https://kids.britannica.com/students/article/bay/633561&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 11 kuTjhirhweni 2025].&lt;/ref&gt;. Kufanele sikhumbule bonyana lokha iimpahla nazithunyelwa ngaphandle nanyana zamukelwa la eSewula Afrika, kufanele kube nendawo la imikhumbi izakwazi ukujama khona lula ukuze iimpahla lezo zilayitjhwe nanyana zihliswe begodu ukghone ukusuka lula, iindawo lezo matheku.

== Iindawo nanyana iimfunda la amatheku atholakala khona ==
ESewula Afrika amatheku akatholakali kizo zoke iimfunda ngebanga lokuthi ezinye zeemfunda ziimfunda ezingaphakathi kwenarha njengeGauteng neMpumalanga ([https://www.britannica.com/science/estuary Britannica, 2025]&lt;ref&gt;Britannica. 2025. ''Bay''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.britannica.com/science/estuary&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 11 kuTjhirhweni 2025].&lt;/ref&gt;). Kodwana iimfunda ezilandelako zinamatheku: IKwaZulu Natala, iTlhagwini Kapa, iPumalanga Kapa neTjhingalanga Kapa. Iimfunda ezine lezi zinemithetho leyo elawula ukusetjenziswa kwamatheku babantu, imiphakathi kanye namabubululo ngokusebenzisana neenhlangano ezifana nesiGungu seSewula Afrika somThelo leso esitjheje bona yoke ipahla eza eSewula Afrika kufanele bonyana ibhadele umthetho ogunyazwako.

== Isiphetho ==
Itheku linemisebenzi eminengi eempilweni zabantu ngaphandle kokuba yindawo yokunandisa nalapho abantu baditjha khona. Kodwana, lidlala indima eqakathekileko mayela nokunikela enye indlela yokuthuthwa kweempahla lezo eziya ngaphandle kwezinye iinarha nanyana ezivela kwezinye iinarha eziza ngekhaya. Ngalokho-ke, kuqakathekile bona sizijwayeze bonyana itheku liyini begodu lisetjenziswa njani ukuze sikhambelane nemithetho yawo.

== Umthombolwazi ==
&lt;references /&gt;</text>
      <sha1>p1di3zb4r3iaefswcjieaf85zi193vq</sha1>
    </revision>
    <revision>
      <id>3084</id>
      <parentid>2979</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Janabaevazizbek|Janabaevazizbek]]</comment>
      <origin>2569</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3864" sha1="qpk02gwh3omzjflcmphfqo1dw3pk36u" xml:space="preserve">'''Itheku'''; Itheku ngezinye zeendawo ezithandwa khulu babantu. Abantu abanengi bayathanda ukuziphumela, ukuzikhuphela nanyana ukuvakatjhela khona nanyana baphumuze ingqondo khona. Nanyana kunjalo, amatheku la akatholakali koke inarheni. Kukhona iimfunda ezinganawo. Eenhlokweni ezilandelako sizokutjheja bonyana itheku liyini begodu litholakala eendaweni ezinjani.

== Kuyini itheku? ==
Ngokuya kwe-[[:en:Bay|Wikipedia (2025]])&lt;ref&gt;Wikipedia. 2025. ''Bay''. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Bay&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 11 kuTjhirhweni 2025].&lt;/ref&gt; isekelwa yi-[https://www.alsharqi.co/glossary/what-is-bay/ Alsharqi (2025)] &lt;ref&gt;Alsharqi. 2025. ''Bay''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.alsharqi.co/glossary/what-is-bay/&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 11 kuTjhirhweni 2025].&lt;/ref&gt;itheku kulibala elikhulu lamanzi lelo elihlangana bunqopha namanzi welwandle. I-[https://education.nationalgeographic.org/resource/bay/ National Geographic (2025])&lt;ref name=&quot;:0&quot;&gt;National Geographic. 2025. ''Bay''. Litholakala ku:&lt; &lt;nowiki&gt;https://education.nationalgeographic.org/resource/bay/&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 11 kuTjhirhweni 2025].&lt;/ref&gt; ingezelele yathi, itheku kulibala lamanzi lelo elizonjelelwe ihlabathi ukuze abantu bakwazi ukukhamba benze nezinye izinto. Ngamanye amagama, itheku kulibala lamanzi lawo ayingcenye yelwandle asekuthomeni kwelwandle lapho kuhlangene khona nehlabathi nanyana indawo eyomileko ukuze abantu bakwazi ukukhamba begodu baye emanzini badude. Kwesinye isikhathi uthola ukuthi amanzi la kumamanzi abuya elwandle nemlanjenikazi  (National Geographic, 2025)&lt;ref name=&quot;:0&quot; /&gt;.

Itheku alisiyindawo ethandwa babantu kwaphela; kodwana, liyikhaya leenlwani ezinengi zemanzini  ezifaka hlangana iimfesi, ikghuru neenkalakala (National Geographic. 2025)&lt;ref name=&quot;:0&quot; /&gt;. Itheku libuye lisize khulu mayelana nemithwalo neempahla evela kwezinye iinarha nanyana ethunyelwa kwezinye iinarha ngemikhumbi ngombana idoyelo lemikhumbi litholakala khulu emathekwini ([https://kids.britannica.com/students/article/bay/633561 Kids Britannica, 2025])&lt;ref&gt;Kids Britannica. 2025. ''Bay''. Litholakala ku:&lt; &lt;nowiki&gt;https://kids.britannica.com/students/article/bay/633561&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 11 kuTjhirhweni 2025].&lt;/ref&gt;. Kufanele sikhumbule bonyana lokha iimpahla nazithunyelwa ngaphandle nanyana zamukelwa la eSewula Afrika, kufanele kube nendawo la imikhumbi izakwazi ukujama khona lula ukuze iimpahla lezo zilayitjhwe nanyana zihliswe begodu ukghone ukusuka lula, iindawo lezo matheku.

== Iindawo nanyana iimfunda la amatheku atholakala khona ==
ESewula Afrika amatheku akatholakali kizo zoke iimfunda ngebanga lokuthi ezinye zeemfunda ziimfunda ezingaphakathi kwenarha njengeGauteng neMpumalanga ([https://www.britannica.com/science/estuary Britannica, 2025]&lt;ref&gt;Britannica. 2025. ''Bay''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.britannica.com/science/estuary&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 11 kuTjhirhweni 2025].&lt;/ref&gt;). Kodwana iimfunda ezilandelako zinamatheku: IKwaZulu Natala, iTlhagwini Kapa, iPumalanga Kapa neTjhingalanga Kapa. Iimfunda ezine lezi zinemithetho leyo elawula ukusetjenziswa kwamatheku babantu, imiphakathi kanye namabubululo ngokusebenzisana neenhlangano ezifana nesiGungu seSewula Afrika somThelo leso esitjheje bona yoke ipahla eza eSewula Afrika kufanele bonyana ibhadele umthetho ogunyazwako.

== Isiphetho ==
Itheku linemisebenzi eminengi eempilweni zabantu ngaphandle kokuba yindawo yokunandisa nalapho abantu baditjha khona. Kodwana, lidlala indima eqakathekileko mayela nokunikela enye indlela yokuthuthwa kweempahla lezo eziya ngaphandle kwezinye iinarha nanyana ezivela kwezinye iinarha eziza ngekhaya. Ngalokho-ke, kuqakathekile bona sizijwayeze bonyana itheku liyini begodu lisetjenziswa njani ukuze sikhambelane nemithetho yawo.

== Umthombolwazi ==
&lt;references /&gt;</text>
      <sha1>qpk02gwh3omzjflcmphfqo1dw3pk36u</sha1>
    </revision>
  </page>
  <page>
    <title>Ukuvakatjha nanyana ivakatjhobukelo.</title>
    <ns>0</ns>
    <id>459</id>
    <revision>
      <id>2376</id>
      <timestamp>2025-01-28T06:07:19Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <comment>Created page with &quot;== Ukuvakatjha nanyana ivakatjhobukelo. ==  === Isingeniso === Kukhona ezinye izinto esele zidlange khudlwana nakukhamba isikhathi begodu izinto lezo zidlala indima ekulu eempilweni zethu kanye nemnothweni. Ezinye zezinto lezo kuvakatjha. Ukuvatjha lokhu esikhuluma ngakho la, ngilokho abanye abakubiza bonyana ibakatjhobukelo ingasi ukukweriya okwabona ngugogo. Eenhlokwaneni ezilandelako sizokutjheja bonyana ukuyini ukuvakatjha, nanyana ivakatjhobukelo, kanye nemihlobo ek...&quot;</comment>
      <origin>2376</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4799" sha1="g7nh38rjj5i96y7hib0cvcursevjxxj" xml:space="preserve">== Ukuvakatjha nanyana ivakatjhobukelo. ==

=== Isingeniso ===
Kukhona ezinye izinto esele zidlange khudlwana nakukhamba isikhathi begodu izinto lezo zidlala indima ekulu eempilweni zethu kanye nemnothweni. Ezinye zezinto lezo kuvakatjha. Ukuvatjha lokhu esikhuluma ngakho la, ngilokho abanye abakubiza bonyana ibakatjhobukelo ingasi ukukweriya okwabona ngugogo. Eenhlokwaneni ezilandelako sizokutjheja bonyana ukuyini ukuvakatjha, nanyana ivakatjhobukelo, kanye nemihlobo ekhona yevakatjho (ivakatjhobukelo).

=== Kuyini ukuvakatjha nanyana ivakatjhobukelo na? ===
[[Isimumathi:Ivakatjhobukelo.jpg|thumb|353x353px|Ubaba uthwebula inyoni isithombe]]
Ngokuya kwe-Britannica (2025) &lt;ref name=&quot;:0&quot;&gt;Britanicca. 2025. ''Tourism''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.britannica.com/topic/tourism/Day-trippers-and-domestic-tourism&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 13 kuTjhirhweni 2025].&lt;/ref&gt;ukuvakatjha nanyana ivakatjhobukelo kusisenzo nehlelo lokuqeda isikhathi sakho kude nekhaya ngomnqopho wokuthola ukuphumula nobumnandi. I-Britannica (2025)&lt;ref name=&quot;:0&quot; /&gt; ingezelele yathi, isenzo leso sokuqeda isikhathi kude nekhenu esikhathini esinengi senzeka ngokusebenzisa imisebenzi yezamabubulo ngaphasi komkhakha loyo. Ngamanye amagama, ukuvakatjha nanyana ivakatjhobukelo kusisenzo esifaka hlangana ukusebenzisa amabubulo bonyana akusize ngevakatjho lakho eendaweni ezahlukeneko, ingasi wena uzenzele zoke izinto. 

Nanyana kunjalo, i-Wikipedia (2025)&lt;ref name=&quot;:1&quot;&gt;Wikipedia. 2025. ''Tourism''. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Tourism&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 13 kuTjhirhweni 2025].&lt;/ref&gt; iveze bonyana ukuvakatjha nanyana ivakatjhobukelo kusisenzo esidlula ukuvakatjha kwamalanga wokuphumula; kodwana, kusisenzo sokufunda okutjha ngeendawo, ibhoduluko, amasiko nepilo yabantu beendawo lapho uvakatjhele khona. U-Tureac no-Anca (2008)&lt;ref&gt;Tureac, C. E., &amp; Anca, T. 2008. Types and Forms of Tourism. ''ACTA UNIVERSITATIS DANUBIUS: OECONOMICA:''92-103.&lt;/ref&gt; bangezelele ngokuthi, ukuvatjha lokhu akufani, okunye kwenzeka ngeenthuthi zomphakathi, ehlobo nanyana ebusika, ngokwemidlalo nanyana ukuziphumulela nje. Ngamanye amagama, ukuvakatjha kuya ngomuntu bonyana uthanda okunjani nanyana uthanda ukukwenza ngasiphi isikhathi nesidingo siphi. 

=== Imihlobo yokuvakatjha. ===
Kukhona imihlobo eminengi yokuvakatjha nanyana yevakatjhobukelo; kodwana, ngaphasi kwekulumopendulwano yethu sizonqopha kile elandelako: 

==== Ukuvakatjha nanyana ivakatjhobukelo lesikhathi eside. ====
Ngokuya kuka-Robinson, u-LUck no-Smith (2020)&lt;ref name=&quot;:2&quot;&gt;Robinson, P.,  Lück, M., &amp; Smith, S. 2020. ''Tourism''. 2nd Edition.&lt;/ref&gt; ivakatjhobukelo nanyana ukuvakatjha kwesikhathi eside kulevakatjho lelo eleqa isikhathi somnyaka, umuntu akwenye indawo. Ngamanye amagama, leli livakatjho umuntu angalithatha ehlobo, ahlale lapho kuphele ihlobo nesiruthwani bese uyabuya nakungena ubusika. 

==== Ukuvakatjha nanyana ivakatjhobukelo lesikhatjhana. ====
Ukuvakatjha nanyana ivakatjhobukelo lesikhatjhana livakatjho lelo elingathathi isikhathi eside begodu lingathatha ilanga ukuya kwamalanga amatjhumi amathathu (Robinson ''nabanye'', 2020)&lt;ref name=&quot;:2&quot; /&gt;. Ngamanye amagama, ivakatjho lesikhatjhana livakatjho lelo umuntu alithatha ngomqopho wokuthi akafuni ukuhlala isikhathi endaweni leyo avakatjhele kiyo. 

=== Imibandela yokuthatha ivakatjhobukelo nanyana ivakatjho. ===
Ngokuya kwe-Wikipedia (2025)&lt;ref name=&quot;:1&quot; /&gt; isekelwa yi-Britannica (2025)&lt;ref name=&quot;:0&quot; /&gt; abantu bathatha ivakatjhobukelo nanyana ivakatjho ngebanga lokufuna ukuphola nanyana ibanga lezamaphilo. Laba babantu abasuke bazi bonyana isizo elingabasiza bonyana baphole bangalithola kwindawo leyo kwaphela. 

Kube khona abantu abathatha ivakatjho nanyana ivakatjhobukelo ngomnqopho wezamabubululo (Wikipedia 2025&lt;ref name=&quot;:1&quot; /&gt;; ne-Britannica, 2025). Laba kusuke kubosomabubulo abafuna ukwandisa nokufunda kwabanye abosomabubulo abaphumeleleko kwezinye iindawo (Wikipedia, 2025&lt;ref name=&quot;:1&quot; /&gt;). 

Kokugcina, kube khona abantu abathatha ivakatjho nanyana ivakatjhobukelo ngebanga lokubethwa moya, ukuthola ubumnandi nanyana ukuledlha nokuphumula (Britanicca, 2025&lt;ref name=&quot;:0&quot; /&gt;; ne-Wikipedia, 2025&lt;ref name=&quot;:1&quot; /&gt;). Laba babantu abadinwe ngomkhumbulo nanyana ngomzimba bafuna ukuphumula nemoyeni ukuze babuyele emakhabo bangcono (Wikipedia, 2025&lt;ref name=&quot;:1&quot; /&gt;). 

=== Isiphetho ===
Ukuvakatjha nanyana ivakatjhobukelo yinto leyo engasiza khulu umuntu lokha neentjhijilo ezifaka hlangana ukudinwa ngokomkhumbulo nanyana ngomzimba, imitjhoga nanyana intatha yobuguli obuthize kanye nokukhulisa ilwazi lakho elimayelana namasiko, indlela yabantu yokuphila neenkolelo zabo. Ngalokho-ke, kuqakathekile bonyana umuntu azijwayeze ukuthatha ivakatjho nanyana ivakatjhobukelo.

=== Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>g7nh38rjj5i96y7hib0cvcursevjxxj</sha1>
    </revision>
    <revision>
      <id>2990</id>
      <parentid>2376</parentid>
      <timestamp>2025-06-06T20:14:17Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>yuj5gf</comment>
      <origin>2990</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4887" sha1="f3w4og851p9t4rgk2lkeclarwoy5sb1" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.'''

== Ukuvakatjha nanyana ivakatjhobukelo. ==

=== Isingeniso ===
Kukhona ezinye izinto esele zidlange khudlwana nakukhamba isikhathi begodu izinto lezo zidlala indima ekulu eempilweni zethu kanye nemnothweni. Ezinye zezinto lezo kuvakatjha. Ukuvatjha lokhu esikhuluma ngakho la, ngilokho abanye abakubiza bonyana ibakatjhobukelo ingasi ukukweriya okwabona ngugogo. Eenhlokwaneni ezilandelako sizokutjheja bonyana ukuyini ukuvakatjha, nanyana ivakatjhobukelo, kanye nemihlobo ekhona yevakatjho (ivakatjhobukelo).

=== Kuyini ukuvakatjha nanyana ivakatjhobukelo na? ===
[[Isimumathi:Ivakatjhobukelo.jpg|thumb|353x353px|Ubaba uthwebula inyoni isithombe]]
Ngokuya kwe-Britannica (2025) &lt;ref name=&quot;:0&quot;&gt;Britanicca. 2025. ''Tourism''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.britannica.com/topic/tourism/Day-trippers-and-domestic-tourism&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 13 kuTjhirhweni 2025].&lt;/ref&gt;ukuvakatjha nanyana ivakatjhobukelo kusisenzo nehlelo lokuqeda isikhathi sakho kude nekhaya ngomnqopho wokuthola ukuphumula nobumnandi. I-Britannica (2025)&lt;ref name=&quot;:0&quot; /&gt; ingezelele yathi, isenzo leso sokuqeda isikhathi kude nekhenu esikhathini esinengi senzeka ngokusebenzisa imisebenzi yezamabubulo ngaphasi komkhakha loyo. Ngamanye amagama, ukuvakatjha nanyana ivakatjhobukelo kusisenzo esifaka hlangana ukusebenzisa amabubulo bonyana akusize ngevakatjho lakho eendaweni ezahlukeneko, ingasi wena uzenzele zoke izinto. 

Nanyana kunjalo, i-Wikipedia (2025)&lt;ref name=&quot;:1&quot;&gt;Wikipedia. 2025. ''Tourism''. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Tourism&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 13 kuTjhirhweni 2025].&lt;/ref&gt; iveze bonyana ukuvakatjha nanyana ivakatjhobukelo kusisenzo esidlula ukuvakatjha kwamalanga wokuphumula; kodwana, kusisenzo sokufunda okutjha ngeendawo, ibhoduluko, amasiko nepilo yabantu beendawo lapho uvakatjhele khona. U-Tureac no-Anca (2008)&lt;ref&gt;Tureac, C. E., &amp; Anca, T. 2008. Types and Forms of Tourism. ''ACTA UNIVERSITATIS DANUBIUS: OECONOMICA:''92-103.&lt;/ref&gt; bangezelele ngokuthi, ukuvatjha lokhu akufani, okunye kwenzeka ngeenthuthi zomphakathi, ehlobo nanyana ebusika, ngokwemidlalo nanyana ukuziphumulela nje. Ngamanye amagama, ukuvakatjha kuya ngomuntu bonyana uthanda okunjani nanyana uthanda ukukwenza ngasiphi isikhathi nesidingo siphi. 

=== Imihlobo yokuvakatjha. ===
Kukhona imihlobo eminengi yokuvakatjha nanyana yevakatjhobukelo; kodwana, ngaphasi kwekulumopendulwano yethu sizonqopha kile elandelako: 

==== Ukuvakatjha nanyana ivakatjhobukelo lesikhathi eside. ====
Ngokuya kuka-Robinson, u-LUck no-Smith (2020)&lt;ref name=&quot;:2&quot;&gt;Robinson, P.,  Lück, M., &amp; Smith, S. 2020. ''Tourism''. 2nd Edition.&lt;/ref&gt; ivakatjhobukelo nanyana ukuvakatjha kwesikhathi eside kulevakatjho lelo eleqa isikhathi somnyaka, umuntu akwenye indawo. Ngamanye amagama, leli livakatjho umuntu angalithatha ehlobo, ahlale lapho kuphele ihlobo nesiruthwani bese uyabuya nakungena ubusika. 

==== Ukuvakatjha nanyana ivakatjhobukelo lesikhatjhana. ====
Ukuvakatjha nanyana ivakatjhobukelo lesikhatjhana livakatjho lelo elingathathi isikhathi eside begodu lingathatha ilanga ukuya kwamalanga amatjhumi amathathu (Robinson ''nabanye'', 2020)&lt;ref name=&quot;:2&quot; /&gt;. Ngamanye amagama, ivakatjho lesikhatjhana livakatjho lelo umuntu alithatha ngomqopho wokuthi akafuni ukuhlala isikhathi endaweni leyo avakatjhele kiyo. 

=== Imibandela yokuthatha ivakatjhobukelo nanyana ivakatjho. ===
Ngokuya kwe-Wikipedia (2025)&lt;ref name=&quot;:1&quot; /&gt; isekelwa yi-Britannica (2025)&lt;ref name=&quot;:0&quot; /&gt; abantu bathatha ivakatjhobukelo nanyana ivakatjho ngebanga lokufuna ukuphola nanyana ibanga lezamaphilo. Laba babantu abasuke bazi bonyana isizo elingabasiza bonyana baphole bangalithola kwindawo leyo kwaphela. 

Kube khona abantu abathatha ivakatjho nanyana ivakatjhobukelo ngomnqopho wezamabubululo (Wikipedia 2025&lt;ref name=&quot;:1&quot; /&gt;; ne-Britannica, 2025). Laba kusuke kubosomabubulo abafuna ukwandisa nokufunda kwabanye abosomabubulo abaphumeleleko kwezinye iindawo (Wikipedia, 2025&lt;ref name=&quot;:1&quot; /&gt;). 

Kokugcina, kube khona abantu abathatha ivakatjho nanyana ivakatjhobukelo ngebanga lokubethwa moya, ukuthola ubumnandi nanyana ukuledlha nokuphumula (Britanicca, 2025&lt;ref name=&quot;:0&quot; /&gt;; ne-Wikipedia, 2025&lt;ref name=&quot;:1&quot; /&gt;). Laba babantu abadinwe ngomkhumbulo nanyana ngomzimba bafuna ukuphumula nemoyeni ukuze babuyele emakhabo bangcono (Wikipedia, 2025&lt;ref name=&quot;:1&quot; /&gt;). 

=== Isiphetho ===
Ukuvakatjha nanyana ivakatjhobukelo yinto leyo engasiza khulu umuntu lokha neentjhijilo ezifaka hlangana ukudinwa ngokomkhumbulo nanyana ngomzimba, imitjhoga nanyana intatha yobuguli obuthize kanye nokukhulisa ilwazi lakho elimayelana namasiko, indlela yabantu yokuphila neenkolelo zabo. Ngalokho-ke, kuqakathekile bonyana umuntu azijwayeze ukuthatha ivakatjho nanyana ivakatjhobukelo.

=== Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>f3w4og851p9t4rgk2lkeclarwoy5sb1</sha1>
    </revision>
    <revision>
      <id>3118</id>
      <parentid>2990</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Owaziwako|Owaziwako]]</comment>
      <origin>2376</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4799" sha1="g7nh38rjj5i96y7hib0cvcursevjxxj" xml:space="preserve">== Ukuvakatjha nanyana ivakatjhobukelo. ==

=== Isingeniso ===
Kukhona ezinye izinto esele zidlange khudlwana nakukhamba isikhathi begodu izinto lezo zidlala indima ekulu eempilweni zethu kanye nemnothweni. Ezinye zezinto lezo kuvakatjha. Ukuvatjha lokhu esikhuluma ngakho la, ngilokho abanye abakubiza bonyana ibakatjhobukelo ingasi ukukweriya okwabona ngugogo. Eenhlokwaneni ezilandelako sizokutjheja bonyana ukuyini ukuvakatjha, nanyana ivakatjhobukelo, kanye nemihlobo ekhona yevakatjho (ivakatjhobukelo).

=== Kuyini ukuvakatjha nanyana ivakatjhobukelo na? ===
[[Isimumathi:Ivakatjhobukelo.jpg|thumb|353x353px|Ubaba uthwebula inyoni isithombe]]
Ngokuya kwe-Britannica (2025) &lt;ref name=&quot;:0&quot;&gt;Britanicca. 2025. ''Tourism''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.britannica.com/topic/tourism/Day-trippers-and-domestic-tourism&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 13 kuTjhirhweni 2025].&lt;/ref&gt;ukuvakatjha nanyana ivakatjhobukelo kusisenzo nehlelo lokuqeda isikhathi sakho kude nekhaya ngomnqopho wokuthola ukuphumula nobumnandi. I-Britannica (2025)&lt;ref name=&quot;:0&quot; /&gt; ingezelele yathi, isenzo leso sokuqeda isikhathi kude nekhenu esikhathini esinengi senzeka ngokusebenzisa imisebenzi yezamabubulo ngaphasi komkhakha loyo. Ngamanye amagama, ukuvakatjha nanyana ivakatjhobukelo kusisenzo esifaka hlangana ukusebenzisa amabubulo bonyana akusize ngevakatjho lakho eendaweni ezahlukeneko, ingasi wena uzenzele zoke izinto. 

Nanyana kunjalo, i-Wikipedia (2025)&lt;ref name=&quot;:1&quot;&gt;Wikipedia. 2025. ''Tourism''. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Tourism&lt;/nowiki&gt;&gt;. Lifunyenwe [ngomhlaka 13 kuTjhirhweni 2025].&lt;/ref&gt; iveze bonyana ukuvakatjha nanyana ivakatjhobukelo kusisenzo esidlula ukuvakatjha kwamalanga wokuphumula; kodwana, kusisenzo sokufunda okutjha ngeendawo, ibhoduluko, amasiko nepilo yabantu beendawo lapho uvakatjhele khona. U-Tureac no-Anca (2008)&lt;ref&gt;Tureac, C. E., &amp; Anca, T. 2008. Types and Forms of Tourism. ''ACTA UNIVERSITATIS DANUBIUS: OECONOMICA:''92-103.&lt;/ref&gt; bangezelele ngokuthi, ukuvatjha lokhu akufani, okunye kwenzeka ngeenthuthi zomphakathi, ehlobo nanyana ebusika, ngokwemidlalo nanyana ukuziphumulela nje. Ngamanye amagama, ukuvakatjha kuya ngomuntu bonyana uthanda okunjani nanyana uthanda ukukwenza ngasiphi isikhathi nesidingo siphi. 

=== Imihlobo yokuvakatjha. ===
Kukhona imihlobo eminengi yokuvakatjha nanyana yevakatjhobukelo; kodwana, ngaphasi kwekulumopendulwano yethu sizonqopha kile elandelako: 

==== Ukuvakatjha nanyana ivakatjhobukelo lesikhathi eside. ====
Ngokuya kuka-Robinson, u-LUck no-Smith (2020)&lt;ref name=&quot;:2&quot;&gt;Robinson, P.,  Lück, M., &amp; Smith, S. 2020. ''Tourism''. 2nd Edition.&lt;/ref&gt; ivakatjhobukelo nanyana ukuvakatjha kwesikhathi eside kulevakatjho lelo eleqa isikhathi somnyaka, umuntu akwenye indawo. Ngamanye amagama, leli livakatjho umuntu angalithatha ehlobo, ahlale lapho kuphele ihlobo nesiruthwani bese uyabuya nakungena ubusika. 

==== Ukuvakatjha nanyana ivakatjhobukelo lesikhatjhana. ====
Ukuvakatjha nanyana ivakatjhobukelo lesikhatjhana livakatjho lelo elingathathi isikhathi eside begodu lingathatha ilanga ukuya kwamalanga amatjhumi amathathu (Robinson ''nabanye'', 2020)&lt;ref name=&quot;:2&quot; /&gt;. Ngamanye amagama, ivakatjho lesikhatjhana livakatjho lelo umuntu alithatha ngomqopho wokuthi akafuni ukuhlala isikhathi endaweni leyo avakatjhele kiyo. 

=== Imibandela yokuthatha ivakatjhobukelo nanyana ivakatjho. ===
Ngokuya kwe-Wikipedia (2025)&lt;ref name=&quot;:1&quot; /&gt; isekelwa yi-Britannica (2025)&lt;ref name=&quot;:0&quot; /&gt; abantu bathatha ivakatjhobukelo nanyana ivakatjho ngebanga lokufuna ukuphola nanyana ibanga lezamaphilo. Laba babantu abasuke bazi bonyana isizo elingabasiza bonyana baphole bangalithola kwindawo leyo kwaphela. 

Kube khona abantu abathatha ivakatjho nanyana ivakatjhobukelo ngomnqopho wezamabubululo (Wikipedia 2025&lt;ref name=&quot;:1&quot; /&gt;; ne-Britannica, 2025). Laba kusuke kubosomabubulo abafuna ukwandisa nokufunda kwabanye abosomabubulo abaphumeleleko kwezinye iindawo (Wikipedia, 2025&lt;ref name=&quot;:1&quot; /&gt;). 

Kokugcina, kube khona abantu abathatha ivakatjho nanyana ivakatjhobukelo ngebanga lokubethwa moya, ukuthola ubumnandi nanyana ukuledlha nokuphumula (Britanicca, 2025&lt;ref name=&quot;:0&quot; /&gt;; ne-Wikipedia, 2025&lt;ref name=&quot;:1&quot; /&gt;). Laba babantu abadinwe ngomkhumbulo nanyana ngomzimba bafuna ukuphumula nemoyeni ukuze babuyele emakhabo bangcono (Wikipedia, 2025&lt;ref name=&quot;:1&quot; /&gt;). 

=== Isiphetho ===
Ukuvakatjha nanyana ivakatjhobukelo yinto leyo engasiza khulu umuntu lokha neentjhijilo ezifaka hlangana ukudinwa ngokomkhumbulo nanyana ngomzimba, imitjhoga nanyana intatha yobuguli obuthize kanye nokukhulisa ilwazi lakho elimayelana namasiko, indlela yabantu yokuphila neenkolelo zabo. Ngalokho-ke, kuqakathekile bonyana umuntu azijwayeze ukuthatha ivakatjho nanyana ivakatjhobukelo.

=== Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>g7nh38rjj5i96y7hib0cvcursevjxxj</sha1>
    </revision>
  </page>
  <page>
    <title>Ukuziphatha kuhle.</title>
    <ns>0</ns>
    <id>460</id>
    <revision>
      <id>2391</id>
      <timestamp>2025-01-28T09:02:21Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <comment>Created page with &quot;== Ukuziphatha kuhle. ==  === Isingeniso === Kukhona ezinye izinto lezo ezenza bonyana sihlalisane kuhle nabantu begodu kube nokuthula nanyana sihlanganyele ini. Enye yezinto lezo kuziphatha ngendlela ehle. Ukuziphatha ngendlela ehle kuyindlela eyenza isiqiniseko sokuthi sibabantu sikhombisa ubuntu kanye nokusebenzisana. Eenhlokwaneni ezilandelako sizokutjheja bonyana nasikhululuma ngokuziphatha kuhle sikhuluma ngani begodu yini ububhadekelo bakhona.  === Kuyini ukuzipha...&quot;</comment>
      <origin>2391</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5601" sha1="bka0w6crwzglu5edjl5wtrejqmj3ejd" xml:space="preserve">== Ukuziphatha kuhle. ==

=== Isingeniso ===
Kukhona ezinye izinto lezo ezenza bonyana sihlalisane kuhle nabantu begodu kube nokuthula nanyana sihlanganyele ini. Enye yezinto lezo kuziphatha ngendlela ehle. Ukuziphatha ngendlela ehle kuyindlela eyenza isiqiniseko sokuthi sibabantu sikhombisa ubuntu kanye nokusebenzisana. Eenhlokwaneni ezilandelako sizokutjheja bonyana nasikhululuma ngokuziphatha kuhle sikhuluma ngani begodu yini ububhadekelo bakhona.

=== Kuyini ukuziphatha kuhle ===
[[Isimumathi:Ihlonipho.jpg|thumb|403x403px|Ukulotjhisana ngehlonipho.]]
Ngokuya kuka-Lazzeri (2014)&lt;ref&gt;Lazzeri, F. 2014. On defining behavior: Some notes. ''Behavior and Philosophy'', 42:65-82.&lt;/ref&gt; ukuziphatha lihlelo lelo lomuntu langaphakathi kwakhe lokuthi ezikhambisna nezenzo lezo ezithintela umsikinyeko nanyana imiphumela yobujamo bakhe. I-[https://f.hubspotusercontent30.net/hubfs/2366135/What%20is%20good%20behaviour%20and%20how%20can%20teachers%20encourage%20it%3F.pdf Evidence Based Education (2025)]&lt;ref&gt;Evidence Based Education. 2025.    ''What is 'good' behaviour and how can teachers encourage it: reflecting on great teaching?'' Litholakala ku:&lt;&lt;nowiki&gt;https://f.hubspotusercontent30.net/hubfs/2366135/What%20is%20good%20behaviour%20and%20how%20can%20teachers%20encourage%20it%3F.pdf&lt;/nowiki&gt;&gt;. Lifunyenwe [Ngomhlaka 13 kuTjhirhweni 2025].&lt;/ref&gt; ngokusekelwa yi-[[:en:Behavior|Wikipedia (2025)]]&lt;ref name=&quot;:0&quot;&gt;Wikipedia. ''Behavior''. Litholakala ku:&lt; &lt;nowiki&gt;https://en.wikipedia.org/wiki/Behavior&lt;/nowiki&gt;&gt;. Lifunyenwe [Ngomhlaka 13 kuTjhirhweni 2025].&lt;/ref&gt; ingezelele yathi ukuziphatha kuhle kunqophe kuzenzo nanyana yini okuphilako lokho okwezenza bonyana sikghone ukuhlalisana nabantu nanyana sikhombise ukulunga. Ngamanye amagama, ukuziphatha kuhle kulihlelo lezenzo kanye nomukghwa onganamthintela omumbi nanyana ongakorholi omunye umuntu, kodwana, owakha itjhebiswano nokusebenzisana.

Iinhlathululo esinikelwe zona lezi ngehla ziyasitjengisa bonyana kubudisi kangangani ukuhlathulula ukuziphatha okuhle, ngombana ukuziphatha okuhle kuthembele bonyana umuntu usibona njani isenzo sakhe leso begodu umqopho wakhe kuyini. Ngalokho-ke, lokho okucabanga bona sisenzo sokuziphatha kuhle ongathola bonyana akusibo boke abasamukelako njengesenzo sokuziphatha kuhle. Esihlokwaneni esilandelako sizokutjheja imihlobo yokuziphatha kuhle.

=== Imihlobo yokuziphatha kuhle ===
Kungenzeka bonyana kunemihlobo eminengi leyo ewela ngaphasi kokuziphatha kuhle; kodwana, ngomnqopho wekulumopendulwano yethu le sizokunqopha kumihlobo elandelako:

==== ukuziphatha kwangaphandle. ====
Ngokuya kwe[https://www.noldus.com/blog/what-is-behavior -Noldus (2023)]&lt;ref name=&quot;:1&quot;&gt;Noldus. 2023. ''Wha is behavior?'' Litholakala ku:&lt; &lt;nowiki&gt;https://www.noldus.com/blog/what-is-behavior&lt;/nowiki&gt;&gt;. Lifunyenwe [Ngomhlaka 13 kuTjhirhweni 2025].&lt;/ref&gt; ukuziphatha kwangaphandle kuziphatha lokho okubonwako nanyana ngubani begodu kumadaniswe ubuhle bakhona bonyana bungangani. I-Noldus (2024)&lt;ref name=&quot;:1&quot; /&gt; ingezelele yathi ukuziphatha lokhu kufaka hlangana imisikinyeko yabantu, ukusebenzisa amatshwayo womzimba, iphimbo kanye nezinye izenzo ezibonwa ngabaye abantu.

==== Ukuziphatha kwangaphakathi ====
Ukuziphatha kwangaphakathi ngilokho esingathi kumumukghwa womuntu owenzeka ngaphathi kwakhe (Noldus, 2023)&lt;ref name=&quot;:1&quot; /&gt;. Imikghwa leyo, omunye umuntu angeze ayibona ngombana yenzeka engqondweni yomuntu nanyana emoyeni wakhe ngaphakathi. Esihlokwaneni esilandelako sizokutjheja bona kuyini umvuzo nanyana ububhadekelo bekuziphatha kuhle na.

=== Kuyini umvuzo nanyana ububhadekelo bokuziphatha kuhle ===
Ukuziphatha kuhle kunemivuzo nanyana ububhadekelo obunengi lobo obufaka hlangana okulandelako:

==== Kusiza ukuledlhisa umzimba ====
Ngokuya kwe-[https://www.strong4life.com/en/emotional-wellness/behavior-and-discipline/10-ways-to-encourage-positive-behavior Strong 4 Life (2025])&lt;ref name=&quot;:2&quot;&gt;Strong 4 Life. 2025. 10 ''Ways to Encourage Positive Behavior''. Litholakala ku:&lt; &lt;nowiki&gt;https://www.strong4life.com/en/emotional-wellness/behavior-and-discipline/10-ways-to-encourage-positive-behavior&lt;/nowiki&gt;&gt;. Lifunyenwe [Ngomhlaka 13 kuTjhirhweni 2025].&lt;/ref&gt; ukuziphatha kuhle kusungula indlela elula nekhulula ingqondo nomzimba egandelelweni lokucabanga khulu mayelana nokungahle kwenze okungakalungi komunye umuntu mayelana nesenzo sakho. Ngalokho-ke, umzinga nengqondo uyaledlha begodu awuqabangi khulu njengalokha nawuziphethe kumbi begodu kwabanomthintela komunye umuntu. 

==== Kuyindlela ehle yomukghwa ====
Ukuziphatha kuhle kuyindlela ehle yokumukghwa leyo engalandelwa nanyana ngubani begodu yenza bonyana abantu babe nekambiso ephilileko nanyana enganabungozi (Strong 4 Life, 2025)&lt;ref name=&quot;:2&quot; /&gt;. Yeke-ke, lokha umuntu nakaziphatha kuhle, akusisenzo nje kwaphela; kodwana, kusisenzo esidlala indlima ngokwezamaphilo. 

==== Kusiza ekukhuliseni abentwana ====
Ukuziphatha kuhle kusiza ekukhuliseni abentwana ngombana kuhlahla abentwana bonyana babalekele izenzo ezimbi kanye nemikghwa engakalungu (Wikipedia, 2025)&lt;ref name=&quot;:0&quot; /&gt;. Ngamanye amagama, nawungumzali kufanele uziphathe kuhle ngombana abentwana nabakubona wenza into enye nabo bayakulandela ngokwenza into leyo; Kodwana, nangabe wenza into embi nabo bayakulandela ngokwenza into embi begodu ezinye babelethwa nazo ngebanga lefuzo. 

=== Isiphetho ===
Ukuziphatha kuhle kuqakathekile begodu kungaba nesithintela esihle nesimbi komunye umuntu. Nanyana kunjalo, kufanele silinge ngaso soke isikhathi ukuziphatha kuhle ngokwezenzo begodu nangemikghwa leyo ebonakala ngengaphakathi lethu. 

=== Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>bka0w6crwzglu5edjl5wtrejqmj3ejd</sha1>
    </revision>
  </page>
  <page>
    <title>Iflaga yeSewula Africa</title>
    <ns>0</ns>
    <id>461</id>
    <redirect title="Iflaga yeSewula Afrika" />
    <revision>
      <id>2395</id>
      <timestamp>2025-01-28T12:25:54Z</timestamp>
      <contributor>
        <username>Jfblanc</username>
        <id>328</id>
      </contributor>
      <comment>Jfblanc moved page [[Iflaga yeSewula Africa]] to [[Iflaga yeSewula Afrika]]</comment>
      <origin>2395</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="36" sha1="au8gx5tsxgvfykgtmmejka4vfgtvo1w" xml:space="preserve">#REDIRECT [[Iflaga yeSewula Afrika]]</text>
      <sha1>au8gx5tsxgvfykgtmmejka4vfgtvo1w</sha1>
    </revision>
  </page>
  <page>
    <title>MediaWiki:BabelConfig.json</title>
    <ns>8</ns>
    <id>462</id>
    <revision>
      <id>2397</id>
      <timestamp>2025-01-31T00:03:52Z</timestamp>
      <contributor>
        <username>Maintenance script</username>
        <id>1</id>
      </contributor>
      <comment>Migrating server configuration to an on-wiki JSON file ([[phab:T374348]])</comment>
      <origin>2397</origin>
      <model>json</model>
      <format>application/json</format>
      <text bytes="213" sha1="54hmctnlaawatl26wopa0v29fbhc0mb" xml:space="preserve">{
	&quot;$version&quot;: &quot;1.0.0&quot;,
	&quot;BabelAutoCreate&quot;: true,
	&quot;BabelCategoryNames&quot;: {
		&quot;0&quot;: &quot;&quot;,
		&quot;1&quot;: &quot;&quot;,
		&quot;2&quot;: &quot;&quot;,
		&quot;3&quot;: &quot;&quot;,
		&quot;4&quot;: &quot;&quot;,
		&quot;5&quot;: &quot;&quot;,
		&quot;N&quot;: &quot;&quot;
	},
	&quot;BabelMainCategory&quot;: &quot;&quot;,
	&quot;BabelUseUserLanguage&quot;: false
}</text>
      <sha1>54hmctnlaawatl26wopa0v29fbhc0mb</sha1>
    </revision>
  </page>
  <page>
    <title>Ukubulunga imali</title>
    <ns>0</ns>
    <id>464</id>
    <revision>
      <id>2400</id>
      <timestamp>2025-02-12T08:11:02Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''Ukubulunga imali''' kukulokha umuntu athatha ingcenye yemali yakhe ayitholako njengomrholo bese ayibekele isikhathi esizako angayisebenzisi ngeholoso yokuthi  ikhone ikumsiza ngesikhathi esizako. Ukubulunga imali kusisenzo esiqakathekileko begodu senza bona umuntu abenemali nokuthi ahlale ngaphandle kokusaba ukutlhoga imali&lt;ref&gt;Furnham, A., 1985. Why do people save? Attitudes to, and habits of saving money in Britain. Journal of Applied Social Psychology, 15(5), pp.35...&quot;</comment>
      <origin>2400</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1994" sha1="4j2jrrvso06pqhu3uv067od3hdd22n8" xml:space="preserve">'''Ukubulunga imali''' kukulokha umuntu athatha ingcenye yemali yakhe ayitholako njengomrholo bese ayibekele isikhathi esizako angayisebenzisi ngeholoso yokuthi  ikhone ikumsiza ngesikhathi esizako. Ukubulunga imali kusisenzo esiqakathekileko begodu senza bona umuntu abenemali nokuthi ahlale ngaphandle kokusaba ukutlhoga imali&lt;ref&gt;Furnham, A., 1985. Why do people save? Attitudes to, and habits of saving money in Britain. Journal of Applied Social Psychology, 15(5), pp.354-373.
&lt;/ref&gt;.

== Kuqakatheke ngani ukubulunga imali? ==
=== Kukusiza ukuthi okhone ukwenza izinto ozifisako
 ===
Ukubulunga imali kulekelela umuntu bona akghone ukufeza izinto azifisako ezihle ezifana nokuthi ukghone ukuthenga imodere, wakhe indlu ehle kanokutjho  begodu ungakghona ukubhadalela abantwana ifundo yabo yamazinga aphezulu&lt;ref&gt;Salikin, N., Wahab, N.A., Zakaria, N., Masruki, R. and Nordin, S.N., 2012. Students’ saving attitude: does parents’ background matter. International Journal of Trade, Economics and Finance, 3(6), p.479.
&lt;/ref&gt;. Zinengi izinto umuntu angazenza ngokuthi abulunge imali omunye umuntu angathatha imali ayibulungileko ayisebenzise bona athome ibubulo elizomakhela umnotho.

=== Kukukhipha ehlathini lokha nakunekinga ===
Nawumumuntu obulunga imali, nawuvelelwa sisiga obewu ngakasicabangi esifana nokuthi uphelelwe msebenzi, ingozi, nanyana ugulelwe sihlobo sakho uyakghona ukuthi uthathe imali oyibulungileko ukuthi bonyana ikulekelele bona ukhone ukuthi uphume emirarweni oqalane nayo.

=== Kusiza ukubalekela iinkolodo ===

Ukubulunga imali kurhelebha bona umuntu abalekele ukwenza iinkolodo lokha nasele avelelwa miraro ebakangakayilindeli. Kuvikela nokuthi  umuntu angasebenzisi  imali ngendlela  engakhombisi ukuhlakanipha.

=== Ukwakha umnotho ===
Ukubulunga imali kulekelela umuntu bona akhone ukwakha umnotho ngombana umuntu angakghona ukuthi athathe imali ayibulungileko ayoyitjala ibuye sele imenzele inzuzo, lokhu kuyawukhulisa umnotho womuntu&lt;ref&gt;&lt;ref&gt;&lt;/ref&gt;&lt;/ref&gt;</text>
      <sha1>4j2jrrvso06pqhu3uv067od3hdd22n8</sha1>
    </revision>
    <revision>
      <id>2401</id>
      <parentid>2400</parentid>
      <timestamp>2025-02-12T08:16:10Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>2401</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2002" sha1="oehb9m45r1fzspfgsj9ulre0c5a02x3" xml:space="preserve">'''Ukubulunga imali''' kukulokha umuntu athatha ingcenye yemali yakhe ayitholako njengomrholo bese ayibekele isikhathi esizako angayisebenzisi ngeholoso yokuthi  ikhone ikumsiza ngesikhathi esizako. Ukubulunga imali kusisenzo esiqakathekileko begodu senza bona umuntu abenemali nokuthi ahlale ngaphandle kokusaba ukutlhoga imali&lt;ref&gt;Furnham, A., 1985. Why do people save? Attitudes to, and habits of saving money in Britain. Journal of Applied Social Psychology, 15(5), pp.354-373.
&lt;/ref&gt;.

== Kuqakatheke ngani ukubulunga imali? ==

===== Kukusiza ukuthi okhone ukwenza izinto ozifisako =====
Ukubulunga [[imali]] kulekelela umuntu bona akghone ukufeza izinto azifisako ezihle ezifana nokuthi ukghone ukuthenga imodere, wakhe indlu ehle kanokutjho  begodu ungakghona ukubhadalela abantwana ifundo yabo yamazinga aphezulu&lt;ref&gt;Salikin, N., Wahab, N.A., Zakaria, N., Masruki, R. and Nordin, S.N., 2012. Students’ saving attitude: does parents’ background matter. International Journal of Trade, Economics and Finance, 3(6), p.479.
&lt;/ref&gt;. Zinengi izinto umuntu angazenza ngokuthi abulunge imali omunye umuntu angathatha imali ayibulungileko ayisebenzise bona athome ibubulo elizomakhela umnotho.

=== Kukukhipha ehlathini lokha nakunekinga ===
Nawumumuntu obulunga imali, nawuvelelwa sisiga obewu ngakasicabangi esifana nokuthi uphelelwe msebenzi, ingozi, nanyana ugulelwe sihlobo sakho uyakghona ukuthi uthathe imali oyibulungileko ukuthi bonyana ikulekelele bona ukhone ukuthi uphume emirarweni oqalane nayo.

=== Kusiza ukubalekela iinkolodo ===

Ukubulunga imali kurhelebha bona umuntu abalekele ukwenza iinkolodo lokha nasele avelelwa miraro ebakangakayilindeli. Kuvikela nokuthi  umuntu angasebenzisi  imali ngendlela  engakhombisi ukuhlakanipha.

=== Ukwakha umnotho ===
Ukubulunga imali kulekelela umuntu bona akhone ukwakha umnotho ngombana umuntu angakghona ukuthi athathe imali ayibulungileko ayoyitjala ibuye sele imenzele inzuzo, lokhu kuyawukhulisa umnotho womuntu&lt;ref&gt;&lt;ref&gt;&lt;/ref&gt;&lt;/ref&gt;</text>
      <sha1>oehb9m45r1fzspfgsj9ulre0c5a02x3</sha1>
    </revision>
    <revision>
      <id>3029</id>
      <parentid>2401</parentid>
      <timestamp>2025-06-06T20:34:40Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>6i7ukthr</comment>
      <origin>3029</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2083" sha1="jk1glaqsnds4hkda97kf1g8tjc5rjnw" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. Ukubulunga imali''' kukulokha umuntu athatha ingcenye yemali yakhe ayitholako njengomrholo bese ayibekele isikhathi esizako angayisebenzisi ngeholoso yokuthi  ikhone ikumsiza ngesikhathi esizako. Ukubulunga imali kusisenzo esiqakathekileko begodu senza bona umuntu abenemali nokuthi ahlale ngaphandle kokusaba ukutlhoga imali&lt;ref&gt;Furnham, A., 1985. Why do people save? Attitudes to, and habits of saving money in Britain. Journal of Applied Social Psychology, 15(5), pp.354-373.
&lt;/ref&gt;.

== Kuqakatheke ngani ukubulunga imali? ==

===== Kukusiza ukuthi okhone ukwenza izinto ozifisako =====
Ukubulunga [[imali]] kulekelela umuntu bona akghone ukufeza izinto azifisako ezihle ezifana nokuthi ukghone ukuthenga imodere, wakhe indlu ehle kanokutjho  begodu ungakghona ukubhadalela abantwana ifundo yabo yamazinga aphezulu&lt;ref&gt;Salikin, N., Wahab, N.A., Zakaria, N., Masruki, R. and Nordin, S.N., 2012. Students’ saving attitude: does parents’ background matter. International Journal of Trade, Economics and Finance, 3(6), p.479.
&lt;/ref&gt;. Zinengi izinto umuntu angazenza ngokuthi abulunge imali omunye umuntu angathatha imali ayibulungileko ayisebenzise bona athome ibubulo elizomakhela umnotho.

=== Kukukhipha ehlathini lokha nakunekinga ===
Nawumumuntu obulunga imali, nawuvelelwa sisiga obewu ngakasicabangi esifana nokuthi uphelelwe msebenzi, ingozi, nanyana ugulelwe sihlobo sakho uyakghona ukuthi uthathe imali oyibulungileko ukuthi bonyana ikulekelele bona ukhone ukuthi uphume emirarweni oqalane nayo.

=== Kusiza ukubalekela iinkolodo ===

Ukubulunga imali kurhelebha bona umuntu abalekele ukwenza iinkolodo lokha nasele avelelwa miraro ebakangakayilindeli. Kuvikela nokuthi  umuntu angasebenzisi  imali ngendlela  engakhombisi ukuhlakanipha.

=== Ukwakha umnotho ===
Ukubulunga imali kulekelela umuntu bona akhone ukwakha umnotho ngombana umuntu angakghona ukuthi athathe imali ayibulungileko ayoyitjala ibuye sele imenzele inzuzo, lokhu kuyawukhulisa umnotho womuntu&lt;ref&gt;&lt;ref&gt;&lt;/ref&gt;&lt;/ref&gt;</text>
      <sha1>jk1glaqsnds4hkda97kf1g8tjc5rjnw</sha1>
    </revision>
    <revision>
      <id>3038</id>
      <parentid>3029</parentid>
      <timestamp>2025-06-07T03:05:22Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Nqobile69|Nqobile69]]</comment>
      <origin>2401</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2002" sha1="oehb9m45r1fzspfgsj9ulre0c5a02x3" xml:space="preserve">'''Ukubulunga imali''' kukulokha umuntu athatha ingcenye yemali yakhe ayitholako njengomrholo bese ayibekele isikhathi esizako angayisebenzisi ngeholoso yokuthi  ikhone ikumsiza ngesikhathi esizako. Ukubulunga imali kusisenzo esiqakathekileko begodu senza bona umuntu abenemali nokuthi ahlale ngaphandle kokusaba ukutlhoga imali&lt;ref&gt;Furnham, A., 1985. Why do people save? Attitudes to, and habits of saving money in Britain. Journal of Applied Social Psychology, 15(5), pp.354-373.
&lt;/ref&gt;.

== Kuqakatheke ngani ukubulunga imali? ==

===== Kukusiza ukuthi okhone ukwenza izinto ozifisako =====
Ukubulunga [[imali]] kulekelela umuntu bona akghone ukufeza izinto azifisako ezihle ezifana nokuthi ukghone ukuthenga imodere, wakhe indlu ehle kanokutjho  begodu ungakghona ukubhadalela abantwana ifundo yabo yamazinga aphezulu&lt;ref&gt;Salikin, N., Wahab, N.A., Zakaria, N., Masruki, R. and Nordin, S.N., 2012. Students’ saving attitude: does parents’ background matter. International Journal of Trade, Economics and Finance, 3(6), p.479.
&lt;/ref&gt;. Zinengi izinto umuntu angazenza ngokuthi abulunge imali omunye umuntu angathatha imali ayibulungileko ayisebenzise bona athome ibubulo elizomakhela umnotho.

=== Kukukhipha ehlathini lokha nakunekinga ===
Nawumumuntu obulunga imali, nawuvelelwa sisiga obewu ngakasicabangi esifana nokuthi uphelelwe msebenzi, ingozi, nanyana ugulelwe sihlobo sakho uyakghona ukuthi uthathe imali oyibulungileko ukuthi bonyana ikulekelele bona ukhone ukuthi uphume emirarweni oqalane nayo.

=== Kusiza ukubalekela iinkolodo ===

Ukubulunga imali kurhelebha bona umuntu abalekele ukwenza iinkolodo lokha nasele avelelwa miraro ebakangakayilindeli. Kuvikela nokuthi  umuntu angasebenzisi  imali ngendlela  engakhombisi ukuhlakanipha.

=== Ukwakha umnotho ===
Ukubulunga imali kulekelela umuntu bona akhone ukwakha umnotho ngombana umuntu angakghona ukuthi athathe imali ayibulungileko ayoyitjala ibuye sele imenzele inzuzo, lokhu kuyawukhulisa umnotho womuntu&lt;ref&gt;&lt;ref&gt;&lt;/ref&gt;&lt;/ref&gt;</text>
      <sha1>oehb9m45r1fzspfgsj9ulre0c5a02x3</sha1>
    </revision>
  </page>
  <page>
    <title>ILanga lethando</title>
    <ns>0</ns>
    <id>465</id>
    <revision>
      <id>2402</id>
      <timestamp>2025-02-12T08:36:22Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''Ilanga lethando''' kulilanga elaziwa ngelimi lesiNgisi bona Yi Valantine's day. ilanga leli ligidingwa cobe nyaka ngenyanga kaMhlolanja amalanga nakali-14. ngokwesiko kulilanga lapho abantu baveza khona ithando labo abanalo  emindenini, ebanganinni begodu nebantwini abahlekisana nabo.&quot;</comment>
      <origin>2402</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="288" sha1="4tn1cfo3muw44wn1ox6u5rqunzmf3dt" xml:space="preserve">'''Ilanga lethando''' kulilanga elaziwa ngelimi lesiNgisi bona Yi Valantine's day. ilanga leli ligidingwa cobe nyaka ngenyanga kaMhlolanja amalanga nakali-14. ngokwesiko kulilanga lapho abantu baveza khona ithando labo abanalo  emindenini, ebanganinni begodu nebantwini abahlekisana nabo.</text>
      <sha1>4tn1cfo3muw44wn1ox6u5rqunzmf3dt</sha1>
    </revision>
    <revision>
      <id>2403</id>
      <parentid>2402</parentid>
      <timestamp>2025-02-12T09:20:13Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2403</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1620" sha1="lqk3p5dz1gtpvs3np2zduyu90xflu95" xml:space="preserve">'''Ilanga lethando''' kulilanga elaziwa ngelimi lesiNgisi bona Yi Valantine's day. ilanga leli ligidingwa cobe nyaka ngenyanga kaMhlolanja amalanga nakali-14. ngokwesiko kulilanga lapho abantu baveza khona ithando labo abanalo  emindenini, ebanganinni begodu nebantwini abahlekisana nabo.

== kwenziwani ngelanga lethando? ==

=== Abantu baphana izipho ===
Iinthandani ngelanga leli zithengelana izipho ezifana namathuthumbo, amatjhokoledi, namakhadi njengendlela yokukhombisana uthando nokuthabelana. abanye baba namakhambo njengendlela yokuzikhipha&lt;ref&gt;Lau, P.H., 2001. Valentine’s Day.&lt;/ref&gt;.

=== Bapheka amadina ===
Abanye bakhetha ukupheka amadina akhethekileko bakhanyise namakhandlela bese badle bobali, leyo into bayenza ngehloso yokuceda isikhathi ndawo yinye begodu babelane ngothando. Idina le bangayidlela ekhaya nanyana esitolo sokudla esisecophelweni. Abanye bayakhamba bayokubukela ama movie nanyana baye lapho kuno mgidi khona wokumvumo bazithabise.

=== batlolelana iincwadi namakhadi ===
Abanye bathanda ukutlolela imilayezo emnandi yethando, baveze indlela ebazizwa ngayo ngabalingni babo, abanani nanyana ababelethi babo. Le yindlela yakade yokwenza izinto kodwana iyakhona ukwenza bona abantu batjhidelane khulu ngombana amezwi kuyindlela enamandla yokuveza imizwa.

== liqakatheke ngani ilanga leli? ==
Ilanga lethando liqakatheke ngokuthi likhuthaza abantu abathandanako bonyaa bakhone ukuceda isikhathi ndawonye, begodu bakhone nokuvezelana indlela abathandana ngayo.Kuyindlela yokukhulisa ithando, ubungani nokuzwana emindenini. kulilanga lokuletha injabulo ebantwini nokukhulisa ubudlelwane.</text>
      <sha1>lqk3p5dz1gtpvs3np2zduyu90xflu95</sha1>
    </revision>
    <revision>
      <id>2535</id>
      <parentid>2403</parentid>
      <timestamp>2025-03-19T10:15:46Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2535</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1637" sha1="1yy009si6p5oo7w4gxjumzq7qw0tpoq" xml:space="preserve">'''Ilanga lethando''' kulilanga elaziwa ngelimi lesiNgisi bona Yi Valantine's day. ilanga leli ligidingwa cobe nyaka ngenyanga kaMhlolanja amalanga nakali-14. ngokwesiko kulilanga lapho abantu baveza khona [[ithando]] labo abanalo  emindenini, ebanganinni begodu nebantwini abahlekisana nabo.

== kwenziwani ngelanga lethando? ==

=== Abantu baphana izipho ===
[[Iinthandani]] ngelanga leli zithengelana izipho ezifana namathuthumbo, amatjhokoledi, namakhadi njengendlela yokukhombisana uthando nokuthabelana. abanye baba namakhambo njengendlela yokuzikhipha&lt;ref&gt;Lau, P.H., 2001. Valentine’s Day.&lt;/ref&gt;.

=== Bapheka amadina ===
Abanye bakhetha ukupheka amadina akhethekileko bakhanyise namakhandlela bese badle bobali, leyo into bayenza ngehloso yokuceda isikhathi ndawo yinye begodu babelane ngothando. Idina le bangayidlela ekhaya nanyana esitolo sokudla esisecophelweni. Abanye bayakhamba bayokubukela ama movie nanyana baye lapho kuno mgidi khona wokumvumo bazithabise.

=== batlolelana iincwadi namakhadi ===
Abanye bathanda ukutlolela imilayezo emnandi yethando, baveze indlela ebazizwa ngayo ngabalingni babo, abanani nanyana ababelethi babo. Le yindlela yakade yokwenza izinto kodwana iyakhona ukwenza bona abantu batjhidelane khulu ngombana amezwi kuyindlela enamandla yokuveza imizwa.

== liqakatheke ngani ilanga leli? ==
Ilanga lethando liqakatheke ngokuthi likhuthaza abantu abathandanako bonyana bakhone ukuceda [[isikhathi]] ndawonye, begodu bakhone nokuvezelana indlela abathandana ngayo.Kuyindlela yokukhulisa ithando, [[ubungani]] nokuzwana emindenini. kulilanga lokuletha injabulo ebantwini nokukhulisa ubudlelwane.</text>
      <sha1>1yy009si6p5oo7w4gxjumzq7qw0tpoq</sha1>
    </revision>
  </page>
  <page>
    <title>Ikolo</title>
    <ns>0</ns>
    <id>466</id>
    <revision>
      <id>2405</id>
      <timestamp>2025-02-12T10:40:32Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''Ikolo''' kuyinto ephathelelne nomoya, kukulapo abantu bakholelwa khona into ebakholelwa kiyo le kufuze kube yinto ebayibona bonyana inamandla ngokomoya begodu ikhethekile. isibonelo sezinto abantu abangakholelwa kizo kugaba nguZimu,sithombe sento ethileko, nofana  abezimu. ikolo kuyinto eyenza abantu bona bakhone ukuzwsisa uphasi ebaphila kilo. kuyinto eyeza bona abantu baphile ngokwesiko , neminyanya ethileko njengendlela yokuveza ikholo labo. Imihlobo yeenkolo esezi...&quot;</comment>
      <origin>2405</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2372" sha1="dsyro6wb7d167ibgife5gkslda6kyi2" xml:space="preserve">'''Ikolo''' kuyinto ephathelelne nomoya, kukulapo abantu bakholelwa khona into ebakholelwa kiyo le kufuze kube yinto ebayibona bonyana inamandla ngokomoya begodu ikhethekile. isibonelo sezinto abantu abangakholelwa kizo kugaba nguZimu,sithombe sento ethileko, nofana  abezimu. ikolo kuyinto eyenza abantu bona bakhone ukuzwsisa uphasi ebaphila kilo. kuyinto eyeza bona abantu baphile ngokwesiko , neminyanya ethileko njengendlela yokuveza ikholo labo. Imihlobo yeenkolo esezikhona esewula Afrika ngilezi: yikolo yobu[[khrestu]], ikolo ye [[Islam]], ikolo yama Hindu,ikolo yama Juda, ikolo yama Bhuda kanye nekolo yabaphasi.&lt;ref&gt;Riesebrodt, M., 2010. ''The promise of salvation: A theory of religion''. University of Chicago Press.

Vancouver&lt;/ref&gt;

== IMIHLOBO YEKOLO ==

=== Ikolo yobukhrestu ===
Leyokolo yabantu abakholelwa kuZimu begodu abakholwa bonyana uJesu yindodana kaZimu ezelwe iyodwa eyasuka ezulwini yeza ephasini ukuzofela izono zabanto begodu yahlongakala yavuka ngemva kwamalanga  amathathu. Abantu abokholelwa kile kolo bathanda ukusebenzisa isiphambano njengethswayo lekolo yabo. le ngenye yeenkolo elandewa babantu abanengi ephasini&lt;ref&gt;Schmidt, A.J., 2009. ''How Christianity changed the world''. Zondervan.&lt;/ref&gt;

=== ikolo ye-Islam ===
Le yikolo yabantu ababizwa bona ma Muslim, bakholwa ku zimu obizwa bona ngu Allah begodu nakumphrofidi obizwa bona nguMuhammad. Bafunda iincwadi i Quran, Amarhubo, ne Torah lezi bakholwa bona ziincwadi ezathunyelwa kibo ngu zimu wabo u Allah. &lt;ref&gt;Donner, F.M., 2010. ''Muhammad and the believers: At the origins of Islam''. Harvard University Press.

Vancouver&lt;/ref&gt;

=== Ikolo yamaHindu ===
Amahindu akholelwa ku zimu wabo obizw bona nguBrahman. Bakholelwa bona yoke into umuntu ayenzako inemphumela yakhona efanel bona umuntu aqalane nayo epilweni nanyana lokha sele adlulile ephasini. AmaHindu anabozimu abathathu uBrama(ngumdali) Vishnu (mgcini wabo) Shiva (mbhubhisi)

=== ikolo yamaJuda ===
AmaJuda akholwa bona kunoZimu oyedwa ephasini loke begodu nguye odale izulu nomhlaba. AmaJuda afunda itorah njenge ncwadi yabo ebafundisa ngozimu, iTorah le ineencwadi ezihlanu zokuthoma ezatlowa ngu Mose ebhayibhilini.

=== ikolo yabaphasi ===
Le yikolo yaantu abanzima abakholelwa ebezimini. abezimu kubabantu abebaphila ephasini kodwana bahlongakala nje imimoya yabo sele isebenza ukubapha inhlanhla nokubavikela.</text>
      <sha1>dsyro6wb7d167ibgife5gkslda6kyi2</sha1>
    </revision>
    <revision>
      <id>2629</id>
      <parentid>2405</parentid>
      <timestamp>2025-04-03T19:09:05Z</timestamp>
      <contributor>
        <username>Rachmat04</username>
        <id>32</id>
      </contributor>
      <minor />
      <origin>2629</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2370" sha1="2wqcbm3cpb515qfr4buxl2qx2iz4dcb" xml:space="preserve">'''Ikolo''' kuyinto ephathelelne nomoya, kukulapo abantu bakholelwa khona into ebakholelwa kiyo le kufuze kube yinto ebayibona bonyana inamandla ngokomoya begodu ikhethekile. isibonelo sezinto abantu abangakholelwa kizo kugaba nguZimu,sithombe sento ethileko, nofana abezimu. ikolo kuyinto eyenza abantu bona bakhone ukuzwsisa uphasi ebaphila kilo. kuyinto eyeza bona abantu baphile ngokwesiko , neminyanya ethileko njengendlela yokuveza ikholo labo. Imihlobo yeenkolo esezikhona esewula Afrika ngilezi: yikolo yobu[[khrestu]], ikolo ye [[Islam]], ikolo yama Hindu,ikolo yama Juda, ikolo yama Bhuda kanye nekolo yabaphasi.&lt;ref&gt;Riesebrodt, M., 2010. ''The promise of salvation: A theory of religion''. University of Chicago Press.

Vancouver&lt;/ref&gt;

== IMIHLOBO YEKOLO ==

=== Ikolo yobukhrestu ===
Leyokolo yabantu abakholelwa kuZimu begodu abakholwa bonyana uJesu yindodana kaZimu ezelwe iyodwa eyasuka ezulwini yeza ephasini ukuzofela izono zabanto begodu yahlongakala yavuka ngemva kwamalanga amathathu. Abantu abokholelwa kile kolo bathanda ukusebenzisa isiphambano njengethswayo lekolo yabo. le ngenye yeenkolo elandewa babantu abanengi ephasini&lt;ref&gt;Schmidt, A.J., 2009. ''How Christianity changed the world''. Zondervan.&lt;/ref&gt;

=== ikolo ye-Islam ===
Le yikolo yabantu ababizwa bona ma Muslim, bakholwa ku zimu obizwa bona ngu Allah begodu nakumphrofidi obizwa bona nguMuhammad. Bafunda iincwadi i Quran, Amarhubo, ne Torah lezi bakholwa bona ziincwadi ezathunyelwa kibo ngu zimu wabo u Allah. &lt;ref&gt;Donner, F.M., 2010. ''Muhammad and the believers: At the origins of Islam''. Harvard University Press.

Vancouver&lt;/ref&gt;

=== Ikolo yamaHindu ===
Amahindu akholelwa ku zimu wabo obizw bona nguBrahman. Bakholelwa bona yoke into umuntu ayenzako inemphumela yakhona efanel bona umuntu aqalane nayo epilweni nanyana lokha sele adlulile ephasini. AmaHindu anabozimu abathathu uBrama(ngumdali) Vishnu (mgcini wabo) Shiva (mbhubhisi)

=== ikolo yamaJuda ===
AmaJuda akholwa bona kunoZimu oyedwa ephasini loke begodu nguye odale izulu nomhlaba. AmaJuda afunda itorah njenge ncwadi yabo ebafundisa ngozimu, iTorah le ineencwadi ezihlanu zokuthoma ezatlowa ngu Mose ebhayibhilini.

=== ikolo yabaphasi ===
Le yikolo yaantu abanzima abakholelwa ebezimini. abezimu kubabantu abebaphila ephasini kodwana bahlongakala nje imimoya yabo sele isebenza ukubapha inhlanhla nokubavikela.</text>
      <sha1>2wqcbm3cpb515qfr4buxl2qx2iz4dcb</sha1>
    </revision>
    <revision>
      <id>3535</id>
      <parentid>2629</parentid>
      <timestamp>2025-08-04T17:25:12Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3535</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2398" sha1="43v1jsmuv31kxf04idb0sz7qwbn782j" xml:space="preserve">'''Ikolo''' kuyinto ephathelelne nomoya, kukulapo abantu bakholelwa khona into ebakholelwa kiyo le kufuze kube yinto ebayibona bonyana inamandla ngokomoya begodu ikhethekile. isibonelo sezinto abantu abangakholelwa kizo kugaba nguZimu,sithombe sento ethileko, nofana abezimu. ikolo kuyinto eyenza abantu bona bakhone ukuzwsisa uphasi ebaphila kilo. kuyinto eyeza bona abantu baphile ngokwesiko , neminyanya ethileko njengendlela yokuveza ikholo labo. Imihlobo yeenkolo esezikhona esewula Afrika ngilezi: yikolo yobu[[khrestu]], ikolo ye [[Islam]], ikolo yama Hindu,ikolo yama Juda, ikolo yama Bhuda kanye nekolo yabaphasi.&lt;ref&gt;Riesebrodt, M., 2010. ''The promise of salvation: A theory of religion''. University of Chicago Press.

Vancouver&lt;/ref&gt;

=== IMIHLOBO YEKOLO ===

==== Ikolo yobukhrestu ====
Leyokolo yabantu abakholelwa kuZimu begodu abakholwa bonyana uJesu yindodana kaZimu ezelwe iyodwa eyasuka ezulwini yeza ephasini ukuzofela izono zabanto begodu yahlongakala yavuka ngemva kwamalanga amathathu. Abantu abokholelwa kile kolo bathanda ukusebenzisa isiphambano njengethswayo lekolo yabo. le ngenye yeenkolo elandewa babantu abanengi ephasini&lt;ref&gt;Schmidt, A.J., 2009. ''How Christianity changed the world''. Zondervan.&lt;/ref&gt;

==== ikolo ye-Islam ====
Le yikolo yabantu ababizwa bona ma Muslim, bakholwa ku zimu obizwa bona ngu Allah begodu nakumphrofidi obizwa bona nguMuhammad. Bafunda iincwadi i Quran, Amarhubo, ne Torah lezi bakholwa bona ziincwadi ezathunyelwa kibo ngu zimu wabo u Allah. &lt;ref&gt;Donner, F.M., 2010. ''Muhammad and the believers: At the origins of Islam''. Harvard University Press.

Vancouver&lt;/ref&gt;

==== Ikolo yamaHindu ====
Amahindu akholelwa ku zimu wabo obizw bona nguBrahman. Bakholelwa bona yoke into umuntu ayenzako inemphumela yakhona efanel bona umuntu aqalane nayo epilweni nanyana lokha sele adlulile ephasini. AmaHindu anabozimu abathathu uBrama(ngumdali) Vishnu (mgcini wabo) Shiva (mbhubhisi)

==== ikolo yamaJuda ====
AmaJuda akholwa bona kunoZimu oyedwa ephasini loke begodu nguye odale izulu nomhlaba. AmaJuda afunda itorah njenge ncwadi yabo ebafundisa ngozimu, iTorah le ineencwadi ezihlanu zokuthoma ezatlowa ngu Mose ebhayibhilini.

==== ikolo yabaphasi ====
Le yikolo yaantu abanzima abakholelwa ebezimini. abezimu kubabantu abebaphila ephasini kodwana bahlongakala nje imimoya yabo sele isebenza ukubapha inhlanhla nokubavikela.

== Iinkomba ==</text>
      <sha1>43v1jsmuv31kxf04idb0sz7qwbn782j</sha1>
    </revision>
    <revision>
      <id>3536</id>
      <parentid>3535</parentid>
      <timestamp>2025-08-04T17:27:49Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3536</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2540" sha1="528v7evvq4h4hiwek70ivgdm7ll8vtd" xml:space="preserve">'''Ikolo''' kuyinto ephathelelne nomoya, kukulapo abantu bakholelwa khona into ebakholelwa kiyo le kufuze kube yinto ebayibona bonyana inamandla ngokomoya begodu ikhethekile. isibonelo sezinto abantu abangakholelwa kizo kugaba nguZimu,sithombe sento ethileko, nofana abezimu. ikolo kuyinto eyenza abantu bona bakhone ukuzwsisa uphasi ebaphila kilo. kuyinto eyeza bona abantu baphile ngokwesiko , neminyanya ethileko njengendlela yokuveza ikholo labo. Imihlobo yeenkolo esezikhona esewula Afrika ngilezi: yikolo yobu[[khrestu]], ikolo ye [[Islam]], ikolo yama Hindu,ikolo yama Juda, ikolo yama Bhuda kanye nekolo yabaphasi.&lt;ref&gt;Riesebrodt, M., 2010. ''The promise of salvation: A theory of religion''. University of Chicago Press.

Vancouver&lt;/ref&gt;

=== IMIHLOBO YEKOLO ===

==== Ikolo yobukhrestu ====
Leyokolo yabantu abakholelwa kuZimu begodu abakholwa bonyana uJesu yindodana kaZimu ezelwe iyodwa eyasuka ezulwini yeza ephasini ukuzofela izono zabanto begodu yahlongakala yavuka ngemva kwamalanga amathathu. Abantu abokholelwa kile kolo bathanda ukusebenzisa isiphambano njengethswayo lekolo yabo. le ngenye yeenkolo elandewa babantu abanengi ephasini&lt;ref&gt;Schmidt, A.J., 2009. ''How Christianity changed the world''. Zondervan.&lt;/ref&gt;. Ikolo yamakhreste kuyikolo ekholelwa embhabhadisweni wabantu njengethswayo lokobana umuntu uzelwe kabutjha sele aphila ipiloo yakhe anoZimu.

==== ikolo ye-Islam ====
Le yikolo yabantu ababizwa bona ma Muslim, bakholwa ku zimu obizwa bona ngu Allah begodu nakumphrofidi obizwa bona nguMuhammad. Bafunda iincwadi i Quran, Amarhubo, ne Torah lezi bakholwa bona ziincwadi ezathunyelwa kibo ngu zimu wabo u Allah. &lt;ref&gt;Donner, F.M., 2010. ''Muhammad and the believers: At the origins of Islam''. Harvard University Press.

Vancouver&lt;/ref&gt;

==== Ikolo yamaHindu ====
Amahindu akholelwa ku zimu wabo obizw bona nguBrahman. Bakholelwa bona yoke into umuntu ayenzako inemphumela yakhona efanel bona umuntu aqalane nayo epilweni nanyana lokha sele adlulile ephasini. AmaHindu anabozimu abathathu uBrama(ngumdali) Vishnu (mgcini wabo) Shiva (mbhubhisi)

==== ikolo yamaJuda ====
AmaJuda akholwa bona kunoZimu oyedwa ephasini loke begodu nguye odale izulu nomhlaba. AmaJuda afunda itorah njenge ncwadi yabo ebafundisa ngozimu, iTorah le ineencwadi ezihlanu zokuthoma ezatlowa ngu Mose ebhayibhilini.

==== ikolo yabaphasi ====
Le yikolo yaantu abanzima abakholelwa ebezimini. abezimu kubabantu abebaphila ephasini kodwana bahlongakala nje imimoya yabo sele isebenza ukubapha inhlanhla nokubavikela.

== Iinkomba ==</text>
      <sha1>528v7evvq4h4hiwek70ivgdm7ll8vtd</sha1>
    </revision>
    <revision>
      <id>5955</id>
      <parentid>3536</parentid>
      <timestamp>2025-11-08T12:05:10Z</timestamp>
      <contributor>
        <username>Hlalithwa</username>
        <id>996</id>
      </contributor>
      <minor />
      <comment>Spelling errors and grammar</comment>
      <origin>5955</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2571" sha1="l6oza747vdo5tva5lub6tcyyrysgkwd" xml:space="preserve">'''Ikolo''' kuyinto ephathelene nommoya, kukulapho abantu bakholelwa khona into ebakholelwa kiyo le kufuze kube yinto ebayibona bonyana inamandla ngokommoya begodu ikhethekile. isibonelo sezinto abantu abangakholelwa kizo kungaba nguZimu, isithombe sento ethileko, nofana abezimu. ikolo kuyinto eyenza abantu bona bakhone ukuzwsisa iphasi ebaphila kilo. kuyinto eyeza bona abantu baphile ngokwesiko , neminyanya ethileko njengendlela yokuveza ikolo yabo. Imihlobo yeenkolo esezikhona esewula Afrika ngilezi: Sifumana ikolo yobu[[khrestu]], ikolo ye [[Islam]], ikolo yama Hindu, ikolo yama Juda, ikolo yama Bhuda kanye nekolo yabaphasi.&lt;ref&gt;Riesebrodt, M., 2010. ''The promise of salvation: A theory of religion''. University of Chicago Press.

Vancouver&lt;/ref&gt;

=== IMIHLOBO YEKOLO ===

==== Ikolo yobukhrestu ====
Lekolo ngeyabantu abakholelwa kuZimu begodu abakholwa bonyana uJesu yindodana kaZimu ezelwe iyodwa eyasuka ezulwini yeza ephasini ukuzofela izono zabantu begodu yahlongakala yavuka ngemva kwamalanga amathathu. Abantu abokholelwa kile kolo bathanda ukusebenzisa isiphambano njengethswayo lekolo yabo. le ngenye yeenkolo elandewa babantu abanengi khulu ephasini&lt;ref&gt;Schmidt, A.J., 2009. ''How Christianity changed the world''. Zondervan.&lt;/ref&gt;. Ikolo yamakhrestu kuyikolo ekholelwa embhabhadisweni wabantu njengethswayo lokobana umuntu uzelwe kabutjha sele aphila ipilo yakhe anoZimu.

==== ikolo ye-Islam ====
Le yikolo yabantu ababizwa bona ma Muslim, bakholelwa ku zimabo obizwa bona ngu &quot;Allah&quot; begodu nakumphrofidi obizwa bona &quot;nguMuhammad&quot;. Bafunda iincwadi i Quran, Amarhubo, ne Torah lezi bakholwa bona ziincwadi ezathunyelwa kibo ngu zimu wabo u Allah. &lt;ref&gt;Donner, F.M., 2010. ''Muhammad and the believers: At the origins of Islam''. Harvard University Press.

Vancouver&lt;/ref&gt;

==== Ikolo yamaHindu ====
Amahindu akholelwa ku zimu wabo obizwa bona nguBrahman. Bakholelwa bona yoke into umuntu ayenzako inemphumela yakhona efanele bona umuntu aqalane nayo epilweni nanyana lokha sele adlulile ephasini. AmaHindu anabozimu abathathu uBrama(ngumdali) Vishnu (mgcini wabo) Shiva (mbhubhisi)

==== ikolo yamaJuda ====
AmaJuda akholelwa ekutheni kunoZimu oyedwa ephasini begodu nguye odale izulu nomhlaba. AmaJuda afunda itorah njenge ncwadi yabo ebafundisa ngozimu, iTorah le ineencwadi ezihlanu zokuthoma ezatlowa ngu Mose ebhayibhilini.

==== ikolo yabaphasi ====
Le yikolo yabantu abanzima abakholelwa ebezimini. abezimu kubabantu abebaphila ephasini kodwana bahlongakala nje imimoya yabo sele isebenza ukubapha inhlanhla nokubavikela.

== Iinkomba ==</text>
      <sha1>l6oza747vdo5tva5lub6tcyyrysgkwd</sha1>
    </revision>
  </page>
  <page>
    <title>Ithiyori ka Vygotsky</title>
    <ns>0</ns>
    <id>467</id>
    <revision>
      <id>2406</id>
      <timestamp>2025-02-14T09:20:58Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''Ithiyori''' ka Vygotsky kuyithoyori ehlathulula bona abantwana bakhulisa ilwazi labo ngokuthi bahlangane nabanye abantwana, nemvelo, nangokuthi  bathole ifundiso ngesiko pilo lebhoduluko ebahlala kilo. Ukukhula nofana ukuthuthuka emntwaneni kuthoma ngaphandle emntwaneni, kubhoduluko leli ahlala kilo bese litjhinge  ngaphakatho komntwana. Ithoyori le iveza bona ibhoduluko lizadlala indima ekulu  ekukhuleni komntwana. Ukukhula komkhumbulo  emtwaneni kuvela lokha umuntu...&quot;</comment>
      <origin>2406</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2209" sha1="j0kboo72fhzuoardinxiv7qom4qmkk2" xml:space="preserve">'''Ithiyori''' ka Vygotsky kuyithoyori ehlathulula bona abantwana bakhulisa ilwazi labo ngokuthi bahlangane nabanye abantwana, nemvelo, nangokuthi  bathole ifundiso ngesiko pilo lebhoduluko ebahlala kilo.
Ukukhula nofana ukuthuthuka emntwaneni kuthoma ngaphandle emntwaneni, kubhoduluko leli ahlala kilo bese litjhinge  ngaphakatho komntwana.
Ithoyori le iveza bona ibhoduluko lizadlala indima ekulu  ekukhuleni komntwana. Ukukhula komkhumbulo  emtwaneni kuvela lokha umuntu afunda izinto ebanganini bakhe , ebabelethini, kubafundisi nakwabanye  abantu  bomphakathi. 
UVygotsky ukholwa bona umuntu nakafuna ukwenza into enzima kufanele athole irhelebho lomuntu onelwazi elikhulu  lokwenza  into leyo. Lokhu  kuzokulekelela bona umuntu  agcine sele anekghono lokwenza into leyo.
== Iscaffolding ==
 Leli ligama lesiNgisi elitjho bona izinga lesekeklo mntwana alidingako  ukuze abe nekghono lokwenza into ethileko ebekangakhoni ukuyenza&lt;ref&gt;Rahimi, A. and Tahmasebi, S., 2011. Mediating Iranian EFL learners: Private speech and scaffolding in reading comprehension. LiBRI. Linguistic and Literary Broad Research and Innovation, 1(2), pp.56-71.&lt;/ref&gt;.
Into enje yenzeka lokha umuntu anekghono  lokwenza into ethileko afundisa Umntwana ongana lwazi bona akghone ukwenza into leyo bekufike lapho umntwana ongenalwazi sele athola naye ikghono lokwenza into afundiswe yona ngokwakhe. Isibonelo: kulokha utitjhere afundisa umntwana ukufunda. Utitjhere uthoma ngokukhombisa umntwana bona kufundwa njani, kuthi ngokuya kwesikhathi umntwana azithole sele afunda ngokwakhe kodwana utitjhere amlekelele bona afunde lawo magama asogola ukuwafunda, bese kuthi ngokukhamba kwesikhathi  umntwana agcine sele akghona ukufunda ngokwakhe.ngaphandle werhelebho lokatitjhere.
== Ukukhuluma ngaphakathi ( private speech) ==
Ithiyori ka Vygotsky iveza bona ilimi liqakathekile ukusiza bona umuntu akhule emkhumbulweni. Ilimi ngilo elenza bona umuntu akghone ukucabanga. Abantwana  bakhuluma bodwa ukuze bakghone  ukulawula izenzo zabo lokha nabadlalako isenzo lesibizwa bona yi private speech.Isenzo lesi ngiso esenza bona umntwana akghone ukulawula indlela yache yokuziphatha, nemicaango yakhe ngokuthi  aphimise lokhu akucabangako.</text>
      <sha1>j0kboo72fhzuoardinxiv7qom4qmkk2</sha1>
    </revision>
    <revision>
      <id>2407</id>
      <parentid>2406</parentid>
      <timestamp>2025-02-14T09:25:34Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2407</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2510" sha1="3yrrbt47ooysn738h81vofvwx8l18dm" xml:space="preserve">'''Ithiyori''' ka Vygotsky kuyithoyori ehlathulula bona abantwana bakhulisa ilwazi labo ngokuthi bahlangane nabanye abantwana, nemvelo, nangokuthi  bathole ifundiso ngesiko pilo lebhoduluko ebahlala kilo.Ukukhula nofana ukuthuthuka emntwaneni kuthoma ngaphandle emntwaneni, kubhoduluko leli ahlala kilo bese litjhinge  ngaphakatho komntwana.Ithoyori le iveza bona ibhoduluko lizadlala indima ekulu  ekukhuleni komntwana. Ukukhula komkhumbulo  emtwaneni kuvela lokha umuntu afunda izinto ebanganini bakhe , ebabelethini, kubafundisi nakwabanye  abantu  bomphakathi. UVygotsky ukholwa bona umuntu nakafuna ukwenza into enzima kufanele athole irhelebho lomuntu onelwazi elikhulu  lokwenza  into leyo. Lokhu  kuzokulekelela bona umuntu  agcine sele anekghono lokwenza into leyo&lt;ref&gt;Vygotsky, L., 2018. Lev Vygotsky. ''La psicología en la Revolución Rusa. Colombia: Ediciones desde abajo''.&lt;/ref&gt;.
== Iscaffolding ==
Leli ligama lesiNgisi elitjho bona izinga lesekeklo mntwana alidingako  ukuze abe nekghono lokwenza into ethileko ebekangakhoni ukuyenza&lt;ref&gt;Rahimi, A. and Tahmasebi, S., 2011. Mediating Iranian EFL learners: Private speech and scaffolding in reading comprehension. LiBRI. Linguistic and Literary Broad Research and Innovation, 1(2), pp.56-71.&lt;/ref&gt;. Into enje yenzeka lokha umuntu anekghono  lokwenza into ethileko afundisa Umntwana ongana lwazi bona akghone ukwenza into leyo bekufike lapho umntwana ongenalwazi sele athola naye ikghono lokwenza into afundiswe yona ngokwakhe. Isibonelo: kulokha utitjhere afundisa umntwana ukufunda. Utitjhere uthoma ngokukhombisa umntwana bona kufundwa njani, kuthi ngokuya kwesikhathi umntwana azithole sele afunda ngokwakhe kodwana utitjhere amlekelele bona afunde lawo magama asogola ukuwafunda, bese kuthi ngokukhamba kwesikhathi  umntwana agcine sele akghona ukufunda ngokwakhe.ngaphandle werhelebho lokatitjhere.

== Ukukhuluma ngaphakathi (private speech) ==
Ithiyori ka Vygotsky iveza bona ilimi liqakathekile ukusiza bona umuntu akhule emkhumbulweni. Ilimi ngilo elenza bona umuntu akghone ukucabanga&lt;ref&gt;Stanley, F., 2011. Vygotsky–From public to private: learning from personal speech. ''Making sense of theory and practice in early childhood: The power of ideas'', pp.11-25.&lt;/ref&gt;. Abantwana  bakhuluma bodwa ukuze bakghone  ukulawula izenzo zabo lokha nabadlalako isenzo lesibizwa bona yi private speech.Isenzo lesi ngiso esenza bona umntwana akghone ukulawula indlela yache yokuziphatha, nemicaango yakhe ngokuthi  aphimise lokhu akucabangako.</text>
      <sha1>3yrrbt47ooysn738h81vofvwx8l18dm</sha1>
    </revision>
    <revision>
      <id>2508</id>
      <parentid>2407</parentid>
      <timestamp>2025-03-06T16:17:10Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2508</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2504" sha1="0fi6fgdvrxqdy2fqaykh0ofgesze0qd" xml:space="preserve">'''Ithiyori''' ka Vygotsky kuyithoyori ehlathulula bona abantwana bakhulisa ilwazi labo ngokuthi bahlangane nabanye abantwana, nemvelo, nangokuthi  bathole ifundiso ngesiko pilo lebhoduluko ebahlala kilo.Ukukhula nofana ukuthuthuka emntwaneni kuthoma ngaphandle emntwaneni, kubhoduluko leli ahlala kilo bese litjhinge  ngaphakatho komntwana.Ithoyori le iveza bona ibhoduluko lizadlala indima ekulu  ekukhuleni komntwana. Ukukhula komkhumbulo  emtwaneni kuvela lokha umuntu afunda izinto ebanganini bakhe , ebabelethini, kubafundisi nakwabanye  abantu  bomphakathi. UVygotsky ukholwa bona umuntu nakafuna ukwenza into enzima kufanele athole irhelebho lomuntu onelwazi elikhulu  lokwenza  into leyo. Lokhu  kuzokulekelela bona umuntu  agcine sele anekghono lokwenza into leyo&lt;ref&gt;Vygotsky, L., 2018. Lev Vygotsky. ''La psicología en la Revolución Rusa. Colombia: Ediciones desde abajo''.&lt;/ref&gt;.
== Iscaffolding ==
Leli ligama lesiNgisi elitjho izinga lesekelo mntwana alidingako  ukuze abe nekghono lokwenza into ethileko ebekangakhoni ukuyenza&lt;ref&gt;Rahimi, A. and Tahmasebi, S., 2011. Mediating Iranian EFL learners: Private speech and scaffolding in reading comprehension. LiBRI. Linguistic and Literary Broad Research and Innovation, 1(2), pp.56-71.&lt;/ref&gt;. Into enje yenzeka lokha umuntu anekghono  lokwenza into ethileko afundisa Umntwana ongana lwazi bona akghone ukwenza into leyo bekufike lapho umntwana ongenalwazi sele athola naye ikghono lokwenza into afundiswe yona ngokwakhe. Isibonelo: kulokha utitjhere afundisa umntwana ukufunda. Utitjhere uthoma ngokukhombisa umntwana bona kufundwa njani, kuthi ngokuya kwesikhathi umntwana azithole sele afunda ngokwakhe kodwana utitjhere amlekelele bona afunde lawo magama asogola ukuwafunda, bese kuthi ngokukhamba kwesikhathi  umntwana agcine sele akghona ukufunda ngokwakhe.ngaphandle werhelebho lokatitjhere.

== Ukukhuluma ngaphakathi (private speech) ==
Ithiyori ka Vygotsky iveza bona ilimi liqakathekile ukusiza bona umuntu akhule emkhumbulweni. Ilimi ngilo elenza bona umuntu akghone ukucabanga&lt;ref&gt;Stanley, F., 2011. Vygotsky–From public to private: learning from personal speech. ''Making sense of theory and practice in early childhood: The power of ideas'', pp.11-25.&lt;/ref&gt;. Abantwana  bakhuluma bodwa ukuze bakghone  ukulawula izenzo zabo lokha nabadlalako isenzo lesibizwa bona yi private speech.Isenzo lesi ngiso esenza bona umntwana akghone ukulawula indlela yache yokuziphatha, nemicaango yakhe ngokuthi  aphimise lokhu akucabangako.</text>
      <sha1>0fi6fgdvrxqdy2fqaykh0ofgesze0qd</sha1>
    </revision>
    <revision>
      <id>2509</id>
      <parentid>2508</parentid>
      <timestamp>2025-03-06T16:17:31Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2509</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2514" sha1="01ajklwm4bddg541wm5cd5wz667efby" xml:space="preserve">'''Ithiyori''' ka Vygotsky kuyithoyori ehlathulula bona abantwana bakhulisa ilwazi labo ngokuthi bahlangane nabanye abantwana, nemvelo, nangokuthi  bathole ifundiso ngesiko pilo lebhoduluko ebahlala kilo.Ukukhula nofana ukuthuthuka emntwaneni kuthoma ngaphandle emntwaneni, kubhoduluko leli ahlala kilo bese litjhinge  ngaphakatho komntwana.Ithoyori le iveza bona ibhoduluko lizadlala indima ekulu  ekukhuleni komntwana. Ukukhula komkhumbulo  emtwaneni kuvela lokha umuntu afunda izinto ebanganini bakhe , ebabelethini, kubafundisi nakwabanye  abantu  bomphakathi. UVygotsky ukholwa bona umuntu nakafuna ukwenza into enzima kufanele athole irhelebho lomuntu onelwazi elikhulu  lokwenza  into leyo. Lokhu  kuzokulekelela bona umuntu  agcine sele anekghono lokwenza into leyo&lt;ref&gt;Vygotsky, L., 2018. Lev Vygotsky. ''La psicología en la Revolución Rusa. Colombia: Ediciones desde abajo''.&lt;/ref&gt;.
== Iscaffolding ==
Leli ligama lesiNgisi elitjho izinga lesekelo mntwana alidingako  ukuze abe nekghono lokwenza into ethileko ebekangakhoni ukuyenza ngokwakhe&lt;ref&gt;Rahimi, A. and Tahmasebi, S., 2011. Mediating Iranian EFL learners: Private speech and scaffolding in reading comprehension. LiBRI. Linguistic and Literary Broad Research and Innovation, 1(2), pp.56-71.&lt;/ref&gt;. Into enje yenzeka lokha umuntu anekghono  lokwenza into ethileko afundisa Umntwana ongana lwazi bona akghone ukwenza into leyo bekufike lapho umntwana ongenalwazi sele athola naye ikghono lokwenza into afundiswe yona ngokwakhe. Isibonelo: kulokha utitjhere afundisa umntwana ukufunda. Utitjhere uthoma ngokukhombisa umntwana bona kufundwa njani, kuthi ngokuya kwesikhathi umntwana azithole sele afunda ngokwakhe kodwana utitjhere amlekelele bona afunde lawo magama asogola ukuwafunda, bese kuthi ngokukhamba kwesikhathi  umntwana agcine sele akghona ukufunda ngokwakhe.ngaphandle werhelebho lokatitjhere.

== Ukukhuluma ngaphakathi (private speech) ==
Ithiyori ka Vygotsky iveza bona ilimi liqakathekile ukusiza bona umuntu akhule emkhumbulweni. Ilimi ngilo elenza bona umuntu akghone ukucabanga&lt;ref&gt;Stanley, F., 2011. Vygotsky–From public to private: learning from personal speech. ''Making sense of theory and practice in early childhood: The power of ideas'', pp.11-25.&lt;/ref&gt;. Abantwana  bakhuluma bodwa ukuze bakghone  ukulawula izenzo zabo lokha nabadlalako isenzo lesibizwa bona yi private speech.Isenzo lesi ngiso esenza bona umntwana akghone ukulawula indlela yache yokuziphatha, nemicaango yakhe ngokuthi  aphimise lokhu akucabangako.</text>
      <sha1>01ajklwm4bddg541wm5cd5wz667efby</sha1>
    </revision>
  </page>
  <page>
    <title>Iinyanga zonyaka</title>
    <ns>0</ns>
    <id>468</id>
    <revision>
      <id>2408</id>
      <timestamp>2025-02-14T09:33:56Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''Iinyanga zonyaka''' Iinyanga zonyaka zilitjhumi nambili enyakeni. Lawa mabizo wakhona ngelimi lesiNdebele. 1. Tjhirhweni  2. Mhlolanja 3. Ntaka 4. Sihlabantangani  5. Mrhayili  6. UNgwengweni  7. Velabahlinze 8. URhoboyi 9. Ukhukhulamungu 10. USewula 11. USinyikhaba 12. UNobayeni&quot;</comment>
      <origin>2408</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="283" sha1="2n0ficyuvyoj7kqn2jtkvz0rn73dxtn" xml:space="preserve">'''Iinyanga zonyaka''' Iinyanga zonyaka zilitjhumi nambili enyakeni. Lawa mabizo wakhona ngelimi lesiNdebele.
1. Tjhirhweni 
2. Mhlolanja
3. Ntaka
4. Sihlabantangani 
5. Mrhayili 
6. UNgwengweni 
7. Velabahlinze
8. URhoboyi
9. Ukhukhulamungu
10. USewula
11. USinyikhaba
12. UNobayeni</text>
      <sha1>2n0ficyuvyoj7kqn2jtkvz0rn73dxtn</sha1>
    </revision>
    <revision>
      <id>2409</id>
      <parentid>2408</parentid>
      <timestamp>2025-02-14T09:35:45Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2409</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="295" sha1="4jl45licxae4ycd4sfyn3v8pan1ot1d" xml:space="preserve">'''Iinyanga zonyaka''' Iinyanga zonyaka zilitjhumi nambili enyakeni. Lawa mabizo wakhona ngelimi lesiNdebele.

1. Tjhirhweni 

2. Mhlolanja

3. Ntaka

4. Sihlabantangani 

5. Mrhayili 

6. UNgwengweni 

7. Velabahlinze

8. URhoboyi

9. Ukhukhulamungu

10. USewula

11. USinyikhaba

12. UNobayeni</text>
      <sha1>4jl45licxae4ycd4sfyn3v8pan1ot1d</sha1>
    </revision>
    <revision>
      <id>3498</id>
      <parentid>2409</parentid>
      <timestamp>2025-07-30T07:54:25Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3498</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="342" sha1="oq8msikfipn0c3fbk0fak9lhn5t5gj9" xml:space="preserve">'''Iinyanga zonyaka''' Iinyanga zonyaka zilitjhumi nambili enyakeni.Zikghona ukusivezela isikhathi sonyaka esikiso. Lawa mabizo wakhona ngelimi lesiNdebele.

1. Tjhirhweni 

2. Mhlolanja

3. Ntaka

4. Sihlabantangani 

5. Mrhayili 

6. UNgwengweni 

7. Velabahlinze

8. URhoboyi

9. Ukhukhulamungu

10. USewula

11. USinyikhaba

12. UNobayeni</text>
      <sha1>oq8msikfipn0c3fbk0fak9lhn5t5gj9</sha1>
    </revision>
    <revision>
      <id>3499</id>
      <parentid>3498</parentid>
      <timestamp>2025-07-30T07:55:05Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3499</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="346" sha1="gcf4nj8bbmkw67w5kuestw74ix28lxm" xml:space="preserve">'''Iinyanga zonyaka''' Iinyanga zonyaka zilitjhumi nambili enyakeni.Zikghona ukusivezela [[isikhathi]] sonyaka esikiso. Lawa mabizo wakhona ngelimi lesiNdebele.

1. Tjhirhweni 

2. Mhlolanja

3. Ntaka

4. Sihlabantangani 

5. Mrhayili 

6. UNgwengweni 

7. Velabahlinze

8. URhoboyi

9. Ukhukhulamungu

10. USewula

11. USinyikhaba

12. UNobayeni</text>
      <sha1>gcf4nj8bbmkw67w5kuestw74ix28lxm</sha1>
    </revision>
  </page>
  <page>
    <title>Iinomboro</title>
    <ns>0</ns>
    <id>469</id>
    <revision>
      <id>2410</id>
      <timestamp>2025-02-15T18:44:15Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''Inomboro''' lithswayo lezembalo elisetjenziswa ukubala inani lezinto ezibalwako, ezimedwako nofana izikhonjwako nemalni. Inomboro isisekelo sesisfundo seembalo ngombana sisebenzisa iinomboro ukuveza ubukhulu bento, isisindo begodu nobukhulu bayo.Lokha inomboro nayingekho ngekhe sakghona ukuba nesifundo seembalo. Iinomboro sikhona ukuziveza ngeendlela ezinengi ezifana nama fraktjhini, ama-inthija, amadesimali.  Ukubala ngelimi lesiNdebele  1- kunye, 2- kubili,3- kuthat...&quot;</comment>
      <origin>2410</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1254" sha1="tvcs7ao4a1yjnj64weggmgl9bfccnvm" xml:space="preserve">'''Inomboro''' lithswayo lezembalo elisetjenziswa ukubala inani lezinto ezibalwako, ezimedwako nofana izikhonjwako nemalni. Inomboro isisekelo sesisfundo seembalo ngombana sisebenzisa iinomboro ukuveza ubukhulu bento, isisindo begodu nobukhulu bayo.Lokha inomboro nayingekho ngekhe sakghona ukuba nesifundo seembalo. Iinomboro sikhona ukuziveza ngeendlela ezinengi ezifana nama fraktjhini, ama-inthija, amadesimali.

Ukubala ngelimi lesiNdebele

1- kunye, 2- kubili,3- kuthathu, 4- kune, 5- kuhlanu, 6- sithandathu,7- Likhomba, 8-bunane, 9- Lithoba, 10- litjhumi…

100- Likhulu

1000- Ikulungwane

1 000 000- Isigidi

Imihlobo yeenomboro

Inomboro zemvelo

1, 2, 3,4,5,6,7,8,9

Ama- iinthija

Ziimnomboto kusuka ku 0 ukukhuphuka begodu zifake nalezo nomboro ezibizwa bona ziinomboro ezinegethivu.

-3,-2,-1, 0,1,2,3

Iinomboro eziretjhinali

Ngilezo nomboro umuntu angakhona ukuzibhala zibe amafraktjhini. Kungaba ziinomboro ezimadesimali nalezo ezima-iinthija

Isibonelo: ½, ¾ , 5, 10…

Iinomboro ezi-iretjhinali

Lezi ziinomboro umuntu angeze ukhona ukuzitlola nofaze aziveze njemagama fraktjhini.

Isibonelo:, π…

Iiinomboro ezi complex

Lo mhlobo weenomborolo ohlanganisa inomboro ezikhona ezibalekako nalezi ezingabalekiko.

Isibonelo 4:+2i</text>
      <sha1>tvcs7ao4a1yjnj64weggmgl9bfccnvm</sha1>
    </revision>
    <revision>
      <id>2955</id>
      <parentid>2410</parentid>
      <timestamp>2025-06-06T18:50:05Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>er</comment>
      <origin>2955</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1335" sha1="pa6he63ituh2xruc4zj4er6glok2o36" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. Inomboro''' lithswayo lezembalo elisetjenziswa ukubala inani lezinto ezibalwako, ezimedwako nofana izikhonjwako nemalni. Inomboro isisekelo sesisfundo seembalo ngombana sisebenzisa iinomboro ukuveza ubukhulu bento, isisindo begodu nobukhulu bayo.Lokha inomboro nayingekho ngekhe sakghona ukuba nesifundo seembalo. Iinomboro sikhona ukuziveza ngeendlela ezinengi ezifana nama fraktjhini, ama-inthija, amadesimali.

Ukubala ngelimi lesiNdebele

1- kunye, 2- kubili,3- kuthathu, 4- kune, 5- kuhlanu, 6- sithandathu,7- Likhomba, 8-bunane, 9- Lithoba, 10- litjhumi…

100- Likhulu

1000- Ikulungwane

1 000 000- Isigidi

Imihlobo yeenomboro

Inomboro zemvelo

1, 2, 3,4,5,6,7,8,9

Ama- iinthija

Ziimnomboto kusuka ku 0 ukukhuphuka begodu zifake nalezo nomboro ezibizwa bona ziinomboro ezinegethivu.

-3,-2,-1, 0,1,2,3

Iinomboro eziretjhinali

Ngilezo nomboro umuntu angakhona ukuzibhala zibe amafraktjhini. Kungaba ziinomboro ezimadesimali nalezo ezima-iinthija

Isibonelo: ½, ¾ , 5, 10…

Iinomboro ezi-iretjhinali

Lezi ziinomboro umuntu angeze ukhona ukuzitlola nofaze aziveze njemagama fraktjhini.

Isibonelo:, π…

Iiinomboro ezi complex

Lo mhlobo weenomborolo ohlanganisa inomboro ezikhona ezibalekako nalezi ezingabalekiko.

Isibonelo 4:+2i</text>
      <sha1>pa6he63ituh2xruc4zj4er6glok2o36</sha1>
    </revision>
    <revision>
      <id>3094</id>
      <parentid>2955</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Nqobile69|Nqobile69]]</comment>
      <origin>2410</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1254" sha1="tvcs7ao4a1yjnj64weggmgl9bfccnvm" xml:space="preserve">'''Inomboro''' lithswayo lezembalo elisetjenziswa ukubala inani lezinto ezibalwako, ezimedwako nofana izikhonjwako nemalni. Inomboro isisekelo sesisfundo seembalo ngombana sisebenzisa iinomboro ukuveza ubukhulu bento, isisindo begodu nobukhulu bayo.Lokha inomboro nayingekho ngekhe sakghona ukuba nesifundo seembalo. Iinomboro sikhona ukuziveza ngeendlela ezinengi ezifana nama fraktjhini, ama-inthija, amadesimali.

Ukubala ngelimi lesiNdebele

1- kunye, 2- kubili,3- kuthathu, 4- kune, 5- kuhlanu, 6- sithandathu,7- Likhomba, 8-bunane, 9- Lithoba, 10- litjhumi…

100- Likhulu

1000- Ikulungwane

1 000 000- Isigidi

Imihlobo yeenomboro

Inomboro zemvelo

1, 2, 3,4,5,6,7,8,9

Ama- iinthija

Ziimnomboto kusuka ku 0 ukukhuphuka begodu zifake nalezo nomboro ezibizwa bona ziinomboro ezinegethivu.

-3,-2,-1, 0,1,2,3

Iinomboro eziretjhinali

Ngilezo nomboro umuntu angakhona ukuzibhala zibe amafraktjhini. Kungaba ziinomboro ezimadesimali nalezo ezima-iinthija

Isibonelo: ½, ¾ , 5, 10…

Iinomboro ezi-iretjhinali

Lezi ziinomboro umuntu angeze ukhona ukuzitlola nofaze aziveze njemagama fraktjhini.

Isibonelo:, π…

Iiinomboro ezi complex

Lo mhlobo weenomborolo ohlanganisa inomboro ezikhona ezibalekako nalezi ezingabalekiko.

Isibonelo 4:+2i</text>
      <sha1>tvcs7ao4a1yjnj64weggmgl9bfccnvm</sha1>
    </revision>
  </page>
  <page>
    <title>Ibhegere yephasi yomdlalo webholo yango-2010</title>
    <ns>0</ns>
    <id>471</id>
    <revision>
      <id>2415</id>
      <timestamp>2025-02-17T10:25:27Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''Ngomnyaka''' we 2010 ISewula AFrika yabamba imidlalo yeFIFA, Iphaliswano lephasi lomdlalo webholo erarhwako. Iphaliliswano leli labe kungele-19 emaphaliswaneni wephasi ekhakabakhona. Lathoma ngelanga -11 ku Ngwengweni bekwaba ngelalnga le11 kuVelabahlinze. Liinqhema zephasi zeza lapha ukuzokuphalisana ukulwela Ukuthumba ibhegere yephasi ebeyidlalelwa ziinarha ezikhethiweko. Iinqheema ezabe zizibandakanye ephaliswaneni leli zabe zima-32.   Isiqhema esathumba iphaliswan...&quot;</comment>
      <origin>2415</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="952" sha1="9y9iuhxn3t32sokop3fwru1godh4nls" xml:space="preserve">'''Ngomnyaka''' we 2010 ISewula AFrika yabamba imidlalo yeFIFA, Iphaliswano lephasi lomdlalo webholo erarhwako. Iphaliliswano leli labe kungele-19 emaphaliswaneni wephasi ekhakabakhona. Lathoma ngelanga -11 ku Ngwengweni bekwaba ngelalnga le11 kuVelabahlinze. Liinqhema zephasi zeza lapha ukuzokuphalisana ukulwela Ukuthumba ibhegere yephasi ebeyidlalelwa ziinarha ezikhethiweko. Iinqheema ezabe zizibandakanye ephaliswaneni leli zabe zima-32.

 Isiqhema esathumba iphaliswani leli lathunjwa yinarha yeSpain. Isiqheema senarha ye Spain yahlula isiqheema seNetherlands nge 1-0 ngegondelo elafakwa ngesikhathi esingezelelweko.Umdlalo wokugcina wephaliswano wadlalelwa etatawini le Soccer city elisedorobheni le Johannesburg. Imidlalo eyadlalwako yabe ima-64 nayipheleleko. Umdlali  obekaphuma phambili kwabe ngu Diego Forlan
Abalandeli abaziingidi bavakatjhela amatatawu alitjhumi ukuyobukela imidlalo. :Amatatawu ebekasetjenziswa nge phaliswano lephasi:</text>
      <sha1>9y9iuhxn3t32sokop3fwru1godh4nls</sha1>
    </revision>
    <revision>
      <id>2416</id>
      <parentid>2415</parentid>
      <timestamp>2025-02-17T10:42:48Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2416</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1471" sha1="p2lg0f2m414qsdzttumfab7qp4xr2r9" xml:space="preserve">'''Ngomnyaka''' we 2010 ISewula AFrika yabamba imidlalo yeFIFA, Iphaliswano lephasi lomdlalo webholo erarhwako. Iphaliliswano leli labe kungele-19 emaphaliswaneni wephasi ekhakabakhona. Lathoma ngelanga -11 ku Ngwengweni bekwaba ngelalnga le11 kuVelabahlinze. Liinqhema zephasi zeza lapha ukuzokuphalisana ukulwela Ukuthumba ibhegere yephasi ebeyidlalelwa ziinarha ezikhethiweko. Iinqheema ezabe zizibandakanye ephaliswaneni leli zabe zima-32.

== Isiqheema esathumba iphaliswano leli ==
Isiqhema esathumba iphaliswani leli lathunjwa yinarha yeSpain. Isiqheema senarha ye Spain yahlula isiqheema seNetherlands nge 1-0 ngegondelo elafakwa ngesikhathi esingezelelweko.Umdlalo wokugcina wephaliswano wadlalelwa etatawini le Soccer city elisedorobheni le Johannesburg. Imidlalo eyadlalwako yabe ima-64 nayipheleleko. Umdlali  obekaphuma phambili kwabe ngu Diego Forlan&lt;ref&gt;2010 FIFA World Cup - Wikipedia&lt;/ref&gt;.

== Amatatawu asetjenziswako ==
Abalandeli abaziingidi bavakatjhela amatatawu.  alitjhumi ukuyobukela imidlalo. :Amatatawu ebekasetjenziswa nge phaliswano lephasi:
{| class=&quot;wikitable&quot;
|+
!Idorobha lapho itatawu likhona
!Ibizo letatawu
|-
|1.Ekapa
|Green point
|-
|2.EBloemfontein
|free state
|-
|3.Durban
|moses mabhida
|-
|4. Johannesurg
|ellis park
|-
|5. Johannnesburg
|soccer city
|-
|6.ENelspruit
|Mbombela
|-
|7. ePolokwane
|Peter Mokaba
|-
|8. EPort elizabeth
|Nelson mandela bay
|-
|9. EPretoria
|loftus versveld
|-
|10. ERusternburg
|Eroyala bafokeng
|}</text>
      <sha1>p2lg0f2m414qsdzttumfab7qp4xr2r9</sha1>
    </revision>
    <revision>
      <id>2435</id>
      <parentid>2416</parentid>
      <timestamp>2025-02-18T21:25:30Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2435</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1470" sha1="0vzx6bcleiz7dcdbhiav9xy05tfqtzk" xml:space="preserve">'''Ngomnyaka''' we 2010 ISewula AFrika yabamba imidlalo yeFIFA, Iphaliswano lephasi lomdlalo webholo erarhwako. Iphaliliswano leli labe kungele-19 emaphaliswaneni wephasi ekhakabakhona. Lathoma ngelanga -11 ku Ngwengweni bekwaba ngelanga le11 kuVelabahlinze. Liinqhema zephasi zeza lapha ukuzokuphalisana ukulwela Ukuthumba ibhegere yephasi ebeyidlalelwa ziinarha ezikhethiweko. Iinqheema ezabe zizibandakanye ephaliswaneni leli zabe zima-32.

== Isiqheema esathumba iphaliswano leli ==
Isiqhema esathumba iphaliswani leli lathunjwa yinarha yeSpain. Isiqheema senarha ye Spain yahlula isiqheema seNetherlands nge 1-0 ngegondelo elafakwa ngesikhathi esingezelelweko.Umdlalo wokugcina wephaliswano wadlalelwa etatawini le Soccer city elisedorobheni le Johannesburg. Imidlalo eyadlalwako yabe ima-64 nayipheleleko. Umdlali  obekaphuma phambili kwabe ngu Diego Forlan&lt;ref&gt;2010 FIFA World Cup - Wikipedia&lt;/ref&gt;.

== Amatatawu asetjenziswako ==
Abalandeli abaziingidi bavakatjhela amatatawu.  alitjhumi ukuyobukela imidlalo. :Amatatawu ebekasetjenziswa nge phaliswano lephasi:
{| class=&quot;wikitable&quot;
|+
!Idorobha lapho itatawu likhona
!Ibizo letatawu
|-
|1.Ekapa
|Green point
|-
|2.EBloemfontein
|free state
|-
|3.Durban
|moses mabhida
|-
|4. Johannesurg
|ellis park
|-
|5. Johannnesburg
|soccer city
|-
|6.ENelspruit
|Mbombela
|-
|7. ePolokwane
|Peter Mokaba
|-
|8. EPort elizabeth
|Nelson mandela bay
|-
|9. EPretoria
|loftus versveld
|-
|10. ERusternburg
|Eroyala bafokeng
|}</text>
      <sha1>0vzx6bcleiz7dcdbhiav9xy05tfqtzk</sha1>
    </revision>
  </page>
  <page>
    <title>Inyosi</title>
    <ns>0</ns>
    <id>472</id>
    <revision>
      <id>2417</id>
      <timestamp>2025-02-17T11:01:22Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Khuyini inyosi == Iinyosi ziinunwana ezibubulako ezinzima nokusarulani ngokombala. Inyosi inemilemze esithandathu begodu inomzimba ohlukaniswe kathathu. inyosi zithanda ukuhlala emathuthumbeni kanye nalapho kuneenthelo ezisude khona.  == Ukuqakatheka kweenyosi == Nanyana zizincani ngokomzimba kodwana zidlala indima eqakathekileko emphakathini. Inyosizidlala iindima ekulu emaphilweni wabantu. Zikhamba emathuthumbeni zifuna I nektha ezizoyisebenzisa ukwenza iluju. Begod...&quot;</comment>
      <origin>2417</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="830" sha1="e1pyfz4d8ws6xx71ke0ur1ngbgoppty" xml:space="preserve">== Khuyini inyosi ==
Iinyosi ziinunwana ezibubulako ezinzima nokusarulani ngokombala. Inyosi inemilemze esithandathu begodu inomzimba ohlukaniswe kathathu. inyosi zithanda ukuhlala emathuthumbeni kanye nalapho kuneenthelo ezisude khona.

== Ukuqakatheka kweenyosi ==
Nanyana zizincani ngokomzimba kodwana zidlala indima eqakathekileko emphakathini. Inyosizidlala iindima ekulu emaphilweni wabantu. Zikhamba emathuthumbeni zifuna I nektha ezizoyisebenzisa ukwenza iluju. Begodu zithatha I pollen eentjalweni zenze bone iintjalo zikhone ukuzalana.

Inyosi zidume khulu ngowenza iluju. Zilenza ngokuthi zibuthelele inektha emathuthumbeni bese ziyenze ibeliluju the phrosesi ebizwa bona yi regurgitation and evaporation. Ijuzi esudu ayibi kukudalal kwaphela kodwana ina yi antibacterial ne antifungal esiza ukwenza imitjhoga yeemvelo.</text>
      <sha1>e1pyfz4d8ws6xx71ke0ur1ngbgoppty</sha1>
    </revision>
    <revision>
      <id>2418</id>
      <parentid>2417</parentid>
      <timestamp>2025-02-17T11:08:08Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2418</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="899" sha1="13aeoenx9cc0kj6g9jo8hvonyyb3zwi" xml:space="preserve">== Khuyini inyosi ==
Iinyosi ziinunwana ezibubulako ezinzima nokusarulani ngokombala. Inyosi inemilemze esithandathu begodu inomzimba ohlukaniswe kathathu. inyosi zithanda ukuhlala emathuthumbeni kanye nalapho kuneenthelo ezisude khona&lt;ref&gt;https://en.wikipedia.org/wiki/Bee#cite_note-Michener2000-3&lt;/ref&gt;.

== Ukuqakatheka kweenyosi ==
Nanyana zizincani ngokomzimba kodwana zidlala indima eqakathekileko emphakathini. Inyosizidlala iindima ekulu emaphilweni wabantu. Zikhamba emathuthumbeni zifuna I nektha ezizoyisebenzisa ukwenza iluju. Begodu zithatha I pollen eentjalweni zenze bone iintjalo zikhone ukuzalana.

Inyosi zidume khulu ngowenza iluju. Zilenza ngokuthi zibuthelele inektha emathuthumbeni bese ziyenze ibeliluju the phrosesi ebizwa bona yi regurgitation and evaporation. Ijuzi esudu ayibi kukudalal kwaphela kodwana ina yi antibacterial ne antifungal esiza ukwenza imitjhoga yeemvelo.</text>
      <sha1>13aeoenx9cc0kj6g9jo8hvonyyb3zwi</sha1>
    </revision>
    <revision>
      <id>3438</id>
      <parentid>2418</parentid>
      <timestamp>2025-07-15T11:44:17Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3438</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="961" sha1="agc4o6fmeuf14uteosdz753lahioois" xml:space="preserve">[[Isimumathi:Bees making honey.jpg|thumb|Iinyosi zihleli phezulu kweluju]]
'''Iinyosi''' ziinunwana ezibubulako ezinzima nokusarulani ngokombala. Inyosi inemilemze esithandathu begodu inomzimba ohlukaniswe kathathu. inyosi zithanda ukuhlala emathuthumbeni kanye nalapho kuneenthelo ezisude khona&lt;ref&gt;https://en.wikipedia.org/wiki/Bee#cite_note-Michener2000-3&lt;/ref&gt;.

=== Ukuqakatheka kweenyosi ===
Nanyana zizincani ngokomzimba kodwana zidlala indima eqakathekileko emphakathini. Inyosizidlala iindima ekulu emaphilweni wabantu. Zikhamba emathuthumbeni zifuna I nektha ezizoyisebenzisa ukwenza iluju. Begodu zithatha I pollen eentjalweni zenze bone iintjalo zikhone ukuzalana.

Inyosi zidume khulu ngowenza iluju. Zilenza ngokuthi zibuthelele inektha emathuthumbeni bese ziyenze ibeliluju the phrosesi ebizwa bona yi regurgitation and evaporation. Ijuzi esudu ayibi kukudalal kwaphela kodwana ina yi antibacterial ne antifungal esiza ukwenza imitjhoga yeemvelo.</text>
      <sha1>agc4o6fmeuf14uteosdz753lahioois</sha1>
    </revision>
    <revision>
      <id>3530</id>
      <parentid>3438</parentid>
      <timestamp>2025-08-04T12:01:43Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>3530</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="961" sha1="m7btx4ifmfdy5b2ze7rdauiavs09vzx" xml:space="preserve">[[Isimumathi:Bees making honey.jpg|thumb|Iinyosi zihleli phezulu kweluju]]
'''Iinyosi''' ziinunwana ezibubulako ezinzima nokusarulani ngokombala. Inyosi inemilemze esithandathu begodu inomzimba ohlukaniswe kathathu. inyosi zithanda ukuhlala emathuthumbeni kanye nalapho kuneenthelo ezisudu khona&lt;ref&gt;https://en.wikipedia.org/wiki/Bee#cite_note-Michener2000-3&lt;/ref&gt;.

=== Ukuqakatheka kweenyosi ===
Nanyana zizincani ngokomzimba kodwana zidlala indima eqakathekileko emphakathini. Inyosizidlala iindima ekulu emaphilweni wabantu. Zikhamba emathuthumbeni zifuna I nektha ezizoyisebenzisa ukwenza iluju. Begodu zithatha I pollen eentjalweni zenze bone iintjalo zikhone ukuzalana.

Inyosi zidume khulu ngowenza iluju. Zilenza ngokuthi zibuthelele inektha emathuthumbeni bese ziyenze ibeliluju the phrosesi ebizwa bona yi regurgitation and evaporation. Ijuzi esudu ayibi kukudalal kwaphela kodwana ina yi antibacterial ne antifungal esiza ukwenza imitjhoga yeemvelo.</text>
      <sha1>m7btx4ifmfdy5b2ze7rdauiavs09vzx</sha1>
    </revision>
    <revision>
      <id>3531</id>
      <parentid>3530</parentid>
      <timestamp>2025-08-04T12:04:45Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3531</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="986" sha1="9v9z9bmtyer1oi07p3a22t5blt085j4" xml:space="preserve">[[Isimumathi:Bees making honey.jpg|thumb|Iinyosi zihleli phezulu kweluju]]
'''Iinyosi''' ziinunwana ezibubulako ezinzima nokusarulani ngokombala. Inyosi inemilemze esithandathu begodu inomzimba ohlukaniswe kathathu. inyosi zithanda ukuhlala emathuthumbeni kanye nalapho kuneenthelo ezisudu khona&lt;ref&gt;https://en.wikipedia.org/wiki/Bee#cite_note-Michener2000-3&lt;/ref&gt;.

=== Ukuqakatheka kweenyosi ===
Nanyana zizincani ngokomzimba kodwana zidlala indima eqakathekileko emphakathini. Inyosizidlala iindima emaphilweni wabantu. Zikhamba emathuthumbeni zifuna I nektha ezizoyisebenzisa ukwenza iluju. Begodu zithatha I pollen eentjalweni zenze bone iintjalo zikhone ukuzalana. Iinyosi zihlala eenhlakaneni. 

Inyosi zidume khulu ngowenza iluju. Zilenza ngokuthi zibuthelele inektha emathuthumbeni bese ziyenze ibeliluju the phrosesi ebizwa bona yi regurgitation and evaporation. Ijuzi esudu ayibi kukudalal kwaphela kodwana ina yi antibacterial ne antifungal esiza ukwenza imitjhoga yeemvelo.</text>
      <sha1>9v9z9bmtyer1oi07p3a22t5blt085j4</sha1>
    </revision>
    <revision>
      <id>3556</id>
      <parentid>3531</parentid>
      <timestamp>2025-08-05T15:41:44Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3556</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1002" sha1="eiprfqex11dewdpalv4a7bunc2rs6o8" xml:space="preserve">[[Isimumathi:Bees making honey.jpg|thumb|Iinyosi zihleli phezulu kweluju]]
'''Iinyosi''' ziinunwana ezibubulako ezinzima nokusarulani ngokombala. Inyosi inemilemze esithandathu begodu inomzimba ohlukaniswe kathathu. inyosi zithanda ukuhlala emathuthumbeni kanye nalapho kuneenthelo ezisudu khona&lt;ref&gt;https://en.wikipedia.org/wiki/Bee#cite_note-Michener2000-3&lt;/ref&gt;.

=== Ukuqakatheka kweenyosi ===
Nanyana zizincani ngokomzimba kodwana zidlala indima eqakathekileko emphakathini. Inyosizidlala iindima emaphilweni wabantu. Zikhamba emathuthumbeni zifuna I nektha ezizoyisebenzisa ukwenza iluju. Begodu zithatha I pollen eentjalweni zenze bone iintjalo zikhone ukuzalana. Iinyosi zihlala eenhlakaneni. 

Inyosi zidume khulu ngowenza iluju. Zilenza ngokuthi zibuthelele inektha emathuthumbeni bese ziyenze ibeliluju the phrosesi ebizwa bona yi regurgitation and evaporation. Ijuzi esudu ayibi kukudalal kwaphela kodwana ina yi antibacterial ne antifungal esiza ukwenza imitjhoga yeemvelo.

== Iinkomba ==</text>
      <sha1>eiprfqex11dewdpalv4a7bunc2rs6o8</sha1>
    </revision>
    <revision>
      <id>3557</id>
      <parentid>3556</parentid>
      <timestamp>2025-08-05T15:42:57Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3557</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1006" sha1="mgkfm9lio75zpkvs7md6a8gv1mvhpka" xml:space="preserve">[[Isimumathi:Bees making honey.jpg|thumb|Iinyosi zihleli phezulu kweluju]]
'''Iinyosi''' ziinunwana ezibubulako ezinzima nokusarulani ngokombala. Inyosi inemilemze esithandathu begodu inomzimba ohlukaniswe kathathu. inyosi zithanda ukuhlala emathuthumbeni kanye nalapho kuneenthelo ezisudu khona&lt;ref&gt;https://en.wikipedia.org/wiki/Bee#cite_note-Michener2000-3&lt;/ref&gt;.

=== Ukuqakatheka kweenyosi ===
Nanyana zizincani ngokomzimba kodwana zidlala indima eqakathekileko emphakathini. Inyosizidlala iindima emaphilweni wabantu. Zikhamba emathuthumbeni zifuna I nektha ezizoyisebenzisa ukwenza iluju. Begodu zithatha I pollen eentjalweni zenze bone iintjalo zikhone ukuzalana. Iinyosi zihlala eenhlakaneni. 

Inyosi zidume khulu ngowenza iluju. Zilenza ngokuthi zibuthelele inektha emathuthumbeni bese ziyenze ibeliluju nge phrosesi ebizwa bona yi-''regurgitation'' and evaporation. Ijuzi esudu ayibi kukudalal kwaphela kodwana ina yi antibacterial ne antifungal esiza ukwenza imitjhoga yeemvelo.

== Iinkomba ==</text>
      <sha1>mgkfm9lio75zpkvs7md6a8gv1mvhpka</sha1>
    </revision>
    <revision>
      <id>6062</id>
      <parentid>3557</parentid>
      <timestamp>2025-12-07T03:33:04Z</timestamp>
      <contributor>
        <username>Lhikan634</username>
        <id>1188</id>
      </contributor>
      <origin>6062</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1007" sha1="0plz807o1qih5r4bmoul71yo8hs69u1" xml:space="preserve">[[Isimumathi: Bienen mit Brut 1.jpg|thumb|Iinyosi zihleli phezulu kweluju]]
'''Iinyosi''' ziinunwana ezibubulako ezinzima nokusarulani ngokombala. Inyosi inemilemze esithandathu begodu inomzimba ohlukaniswe kathathu. inyosi zithanda ukuhlala emathuthumbeni kanye nalapho kuneenthelo ezisudu khona&lt;ref&gt;https://en.wikipedia.org/wiki/Bee#cite_note-Michener2000-3&lt;/ref&gt;.

=== Ukuqakatheka kweenyosi ===
Nanyana zizincani ngokomzimba kodwana zidlala indima eqakathekileko emphakathini. Inyosizidlala iindima emaphilweni wabantu. Zikhamba emathuthumbeni zifuna I nektha ezizoyisebenzisa ukwenza iluju. Begodu zithatha I pollen eentjalweni zenze bone iintjalo zikhone ukuzalana. Iinyosi zihlala eenhlakaneni. 

Inyosi zidume khulu ngowenza iluju. Zilenza ngokuthi zibuthelele inektha emathuthumbeni bese ziyenze ibeliluju nge phrosesi ebizwa bona yi-''regurgitation'' and evaporation. Ijuzi esudu ayibi kukudalal kwaphela kodwana ina yi antibacterial ne antifungal esiza ukwenza imitjhoga yeemvelo.

== Iinkomba ==</text>
      <sha1>0plz807o1qih5r4bmoul71yo8hs69u1</sha1>
    </revision>
  </page>
  <page>
    <title>Ikamela</title>
    <ns>0</ns>
    <id>473</id>
    <revision>
      <id>2421</id>
      <timestamp>2025-02-17T19:17:57Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;khuyini ikamela? Silwana esihlala endaweni eyome khulu begodu enganamanzi. Navene bayithethe bakhambe nayo baye endaweni enamanzi vane isele amanzi akghanorho iwabeke phezu ngongoma engaphezulu kwetamo yayo ngehloso yokuwasororha. Nababuyel nayo la ihlala khona vane seyiselile amanzi bese ithi nayomile idose amanzi. Ikamaela ikhogona ukusela ama litha ama-100 ngasikhathi sinye.bese iwabeke emzimbeni. engongomeni yayo begodu ikhoa ukuhlala amalanga ingaseli amanzi.  Ekade...&quot;</comment>
      <origin>2421</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1082" sha1="tp95aqeeqe0wj0qpjeqc2hel1akn4vz" xml:space="preserve">khuyini ikamela?
Silwana esihlala endaweni eyome khulu begodu enganamanzi. Navene bayithethe bakhambe nayo baye endaweni enamanzi vane isele amanzi akghanorho iwabeke phezu ngongoma engaphezulu kwetamo yayo ngehloso yokuwasororha. Nababuyel nayo la ihlala khona vane seyiselile amanzi bese ithi nayomile idose amanzi. Ikamaela ikhogona ukusela ama litha ama-100 ngasikhathi sinye.bese iwabeke emzimbeni.
engongomeni yayo begodu ikhoa ukuhlala amalanga ingaseli amanzi.

Ekadeni ikamela kade isetjenziswa njengesithuthi ngombana iyakhona ukukhamba isikhati eside ingaphelelwa mdlandla wokukhamba lokha nayingakadli nanyana ingakaseli amanzi. Amehlo wayo anenkophe ezide neempumulo zayo zenza bona ikghone ukujamelana nomoya osendaweni enehlabathi eyomileko. Isikhumba sayo senza bona isilwane lesi sikhone ukujamelana nomtjhiso ongaphezu kwe 49 yamdigrizi
Amakamela endaweni ezifana ne middle east ne North yeAfrica amakela ayaba mthombo wokudla. Ibisi lekamela lizele ngomsoqo  owaziwa bona unepilo begodu wehlisa nezingalokuba sengozini yokuthola isifo setjhukela nesifo sehliziyo.</text>
      <sha1>tp95aqeeqe0wj0qpjeqc2hel1akn4vz</sha1>
    </revision>
    <revision>
      <id>2422</id>
      <parentid>2421</parentid>
      <timestamp>2025-02-17T19:20:36Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2422</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1119" sha1="0o4xrjyyc9k2uazq85zq8leqdo8eeqr" xml:space="preserve">== khuyini ikamela? ==
'''Silwana''' esihlala endaweni eyome khulu begodu enganamanzi. Navene bayithethe bakhambe nayo baye endaweni enamanzi vane isele amanzi akghanorho iwabeke phezu ngongoma engaphezulu kwetamo yayo ngehloso yokuwasororha. Nababuyel nayo la ihlala khona vane seyiselile amanzi bese ithi nayomile idose amanzi. Ikamaela ikhogona ukusela ama litha ama-100 ngasikhathi sinye.bese iwabeke emzimbeni.
engongomeni yayo begodu ikhoa ukuhlala amalanga ingaseli amanzi.

== Ukuqakatheka kwayo ==
Ekadeni ikamela kade isetjenziswa njengesithuthi ngombana iyakhona ukukhamba isikhati eside ingaphelelwa mdlandla wokukhamba lokha nayingakadli nanyana ingakaseli amanzi. Amehlo wayo anenkophe ezide neempumulo zayo zenza bona ikghone ukujamelana nomoya osendaweni enehlabathi eyomileko. Isikhumba sayo senza bona isilwane lesi sikhone ukujamelana nomtjhiso ongaphezu kwe 49 yamdigrizi
Amakamela endaweni ezifana ne middle east ne North yeAfrica amakela ayaba mthombo wokudla. Ibisi lekamela lizele ngomsoqo  owaziwa bona unepilo begodu wehlisa nezingalokuba sengozini yokuthola isifo setjhukela nesifo sehliziyo.</text>
      <sha1>0o4xrjyyc9k2uazq85zq8leqdo8eeqr</sha1>
    </revision>
    <revision>
      <id>2450</id>
      <parentid>2422</parentid>
      <timestamp>2025-02-21T11:47:12Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2450</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1122" sha1="es5l0vsszm3c53nmhqre53he0ebh4xa" xml:space="preserve">== khuyini ikamela? ==
'''Silwana''' esihlala endaweni eyome khulu begodu enganamanzi. Navene bayithethe bakhambe nayo baye endaweni enamanzi vane isele amanzi akghanorho iwabeke phezu kwengongoma engaphezulu kwetamo yayo ngehloso yokuwasororha. Nababuyel nayo la ihlala khona vane seyiselile amanzi bese ithi nayomile idose amanzi. Ikamaela ikhogona ukusela ama litha ama-100 ngasikhathi sinye.bese iwabeke emzimbeni.
engongomeni yayo begodu ikhoa ukuhlala amalanga ingaseli amanzi.

== Ukuqakatheka kwayo ==
Ekadeni ikamela kade isetjenziswa njengesithuthi ngombana iyakhona ukukhamba isikhati eside ingaphelelwa mdlandla wokukhamba lokha nayingakadli nanyana ingakaseli amanzi. Amehlo wayo anenkophe ezide neempumulo zayo zenza bona ikghone ukujamelana nomoya osendaweni enehlabathi eyomileko. Isikhumba sayo senza bona isilwane lesi sikhone ukujamelana nomtjhiso ongaphezu kwe 49 yamdigrizi
Amakamela endaweni ezifana ne middle east ne North yeAfrica amakela ayaba mthombo wokudla. Ibisi lekamela lizele ngomsoqo  owaziwa bona unepilo begodu wehlisa nezingalokuba sengozini yokuthola isifo setjhukela nesifo sehliziyo.</text>
      <sha1>es5l0vsszm3c53nmhqre53he0ebh4xa</sha1>
    </revision>
    <revision>
      <id>2451</id>
      <parentid>2450</parentid>
      <timestamp>2025-02-21T11:52:03Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2451</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1115" sha1="d0aafck9k2dv7apbr1xw9wq7pt9fue9" xml:space="preserve">== khuyini ikamela? ==
'''Silwana''' esihlala endaweni eyome khulu begodu enganamanzi. Navene bayithethe bakhambe nayo baye endaweni enamanzi vane isele amanzi akghanorho iwabeke phezu kwengongoma engaphezulu kwetamo yayo ngehloso yokuwasororha. Nababuyel nayo la ihlala khona vane seyiselile amanzi bese ithi nayomile idose amanzi. Ikamaela ikhogona ukusela ama litha ama-100 ngasikhathi sinye.bese iwabeke emzimbeni.
engongomeni yayo begodu ikhoa ukuhlala amalanga ingaseli amanzi.

== Ukuqakatheka kwayo ==
Ekadeni ikamela kade isetjenziswa njengesithuthi ngombana iyakghona ukukhamba isikhati eside ingaphelelwa mdlandla wokukhamba lokha nayingakadli nanyana ingakaseli amanzi. Amehlo wayo anenkophe ezide neempumulo zayo zenza bona ikghone ukujamelana nomoya osendaweni enehlabathi eyomileko. Isikhumba sayo senza bona isilwane lesi sikhone ukujamelana nomtjhiso ongaphezu kwe 49 yamdigrizi
Amakamela endaweni ezifana ne middle east ne North yeAfrica amakela ayaba wokudla. Ibisi lekamela lizele ngomsoqo  owaziwa bona unepilo begodu wehlisa nezingalokuba sengozini yokuthola isifo setjhukela nesifo sehliziyo.</text>
      <sha1>d0aafck9k2dv7apbr1xw9wq7pt9fue9</sha1>
    </revision>
  </page>
  <page>
    <title>Iintjhijilo eziphathelene nokufunda nokutlola esifundweni sesiNdebele</title>
    <ns>0</ns>
    <id>474</id>
    <revision>
      <id>2423</id>
      <timestamp>2025-02-17T19:23:30Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''Iintjhijilo''' eziphathelene nokufunda nokutlola esifundweni sesiNdebele Ukufunda ngaphandle kokuzwisisa Kunobufakazi bokobana abantwana beSewula Afrika banesitjhijilo sokufunda. Abantwana abenza igreyidi 3 ubunengi babo abakhoni ukufunda ngokuzwisisa lokho ebakufundako, kokubili ngelimi lekhaya begodu khulu nangelimi lesiNgisi. Lokhu kubonakala ngokobana lokha utitjhere nakaba buza umbuzo ngalokhu ebebakufunda bahlukeke ukuphendula. Unobangela walokhu kungaba yindlel...&quot;</comment>
      <origin>2423</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2586" sha1="8jmyx82g68c8n1l2ya3aih93adbg9hh" xml:space="preserve">'''Iintjhijilo''' eziphathelene nokufunda nokutlola esifundweni sesiNdebele
Ukufunda ngaphandle kokuzwisisa
Kunobufakazi bokobana abantwana beSewula Afrika banesitjhijilo sokufunda. Abantwana abenza igreyidi 3 ubunengi babo abakhoni ukufunda ngokuzwisisa lokho ebakufundako, kokubili ngelimi lekhaya begodu khulu nangelimi lesiNgisi. Lokhu kubonakala ngokobana lokha utitjhere nakaba buza umbuzo ngalokhu ebebakufunda bahlukeke ukuphendula.
Unobangela walokhu kungaba yindlela abotitjhere abayisebenzisako ukufundisa abafundi ukufunda. Abotitjhere basenzisa indlela yokufundisa umdumo wamatjhada kwaphela ukufundisa abantwana ukufunda bangahlanganisi nezinye indlela ezifana ne whole language approach. Lezi ezinye indlela ezihlukileko kunendlela yokufundisa ngomdumo ziyarhelebha khulu ekutheni umtwana akwazi ukufunda ngokuzwisisa ngombana zenza umntwana angazi umdumo wamatjhada kwaphela kodwa akwazi ukuhlathulula bona amagama atjho ukuthini begodu asetjenziswa bunjani.
Ubudisi bokwakha amagama
Etlasini le greyidi 3 kunabafund ababa nobudisi bokwakha amagama. Lokhu utitjhere nakenzisa abafundi isibizelo, abafundi abanengi bayahluleka ukwakha amagama khulu khulu lawa anamatjhada amathathu njengo tjh- no dlh-.
Isisombululo.
Imiraro ephethelene nokufunda ngaphandle kokuzwisisa utitjhere angayilungisa ngokuthi lokha nakafundisa abafundi ukufunda asebenzise indlela ezifana ne whole language approach ukufundisa abentwana ukufunda. Indlela le ibasiza ekutheni bakhone ukuzwisa amagama, begodu bakhone ukuzwisisa lokhu ebakafundako. Utitjhere kufuze afundele abafundi indatjana ngemva kwalokho abuze abafundi imibuzo emayelana nendatjana ukuze akazi ukuthuthukisa izinga labo lokuzwisisa umtlolo.
Imiraro ephathelene nokufunda nokutlola esifundweni sesiNgisi.
Imiraro yokuphimisa amatjhada enemidumo efaneko
IsiNgisi lilimi elinamagama nemidumo ephinyiswa ngokufana. Abafundi be greyidi-3 betjengisa ukubha esitjhijilo esikulu naziza ekuphimiseni umidumo yamatjhada aphinyiswa pheze ngokufana Matchet (2002:24). Isibonelo itjhada u ch- no sh- abafundi baphimisa amatjhada ngendlela efanako abakghoni ukuhlukanisa bona u ch umphimisa ngendlela yokuvuthela ngokugandela begodu leli laka sh- uliphimisa ngendlela yokuvuthela ngomoya opholileko.
Isisombululo 
Ukurarulula umraro abotitjhere kufuze barhubhulule indlela ezilula zokufundisa amatjhada la ukuze abantwana bakwazi ukuwahlukanisa ngokwemidumo yakhona.
Abititjhere bangasenza indlela yetheknoloji bafundise abantwana besenzisa amavidiyo ukusiza abafundi bona babe nendlela zokuhlukanisa amatjhada apheze abe nomdumo ofanako.</text>
      <sha1>8jmyx82g68c8n1l2ya3aih93adbg9hh</sha1>
    </revision>
    <revision>
      <id>2424</id>
      <parentid>2423</parentid>
      <timestamp>2025-02-17T19:25:44Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2424</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2598" sha1="teq29c9h1091l1euoqhote9p687bcl7" xml:space="preserve">'''Iintjhijilo''' eziphathelene nokufunda nokutlola esifundweni sesiNdebele
Ukufunda ngaphandle kokuzwisisa

Kunobufakazi bokobana abantwana beSewula Afrika banesitjhijilo sokufunda. Abantwana abenza igreyidi 3 ubunengi babo abakhoni ukufunda ngokuzwisisa lokho ebakufundako, kokubili ngelimi lekhaya begodu khulu nangelimi lesiNgisi. Lokhu kubonakala ngokobana lokha utitjhere nakaba buza umbuzo ngalokhu ebebakufunda bahlukeke ukuphendula.

Unobangela walokhu kungaba yindlela abotitjhere abayisebenzisako ukufundisa abafundi ukufunda. Abotitjhere basenzisa indlela yokufundisa umdumo wamatjhada kwaphela ukufundisa abantwana ukufunda bangahlanganisi nezinye indlela ezifana ne whole language approach. Lezi ezinye indlela ezihlukileko kunendlela yokufundisa ngomdumo ziyarhelebha khulu ekutheni umtwana akwazi ukufunda ngokuzwisisa ngombana zenza umntwana angazi umdumo wamatjhada kwaphela kodwa akwazi ukuhlathulula bona amagama atjho ukuthini begodu asetjenziswa bunjani.


Ubudisi bokwakha amagama

Etlasini le greyidi 3 kunabafund ababa nobudisi bokwakha amagama. Lokhu utitjhere nakenzisa abafundi isibizelo, abafundi abanengi bayahluleka ukwakha amagama khulu khulu lawa anamatjhada amathathu njengo tjh- no dlh-.

Isisombululo.
Imiraro ephethelene nokufunda ngaphandle kokuzwisisa utitjhere angayilungisa ngokuthi lokha nakafundisa abafundi ukufunda asebenzise indlela ezifana ne whole language approach ukufundisa abentwana ukufunda. Indlela le ibasiza ekutheni bakhone ukuzwisa amagama, begodu bakhone ukuzwisisa lokhu ebakafundako. Utitjhere kufuze afundele abafundi indatjana ngemva kwalokho abuze abafundi imibuzo emayelana nendatjana ukuze akazi ukuthuthukisa izinga labo lokuzwisisa umtlolo.

Imiraro ephathelene nokufunda nokutlola esifundweni sesiNgisi.

Imiraro yokuphimisa amatjhada enemidumo efaneko

IsiNgisi lilimi elinamagama nemidumo ephinyiswa ngokufana. Abafundi be greyidi-3 betjengisa ukubha esitjhijilo esikulu naziza ekuphimiseni umidumo yamatjhada aphinyiswa pheze ngokufana Matchet (2002:24). Isibonelo itjhada u ch- no sh- abafundi baphimisa amatjhada ngendlela efanako abakghoni ukuhlukanisa bona u ch umphimisa ngendlela yokuvuthela ngokugandela begodu leli laka sh- uliphimisa ngendlela yokuvuthela ngomoya opholileko.

Isisombululo 

Ukurarulula umraro abotitjhere kufuze barhubhulule indlela ezilula zokufundisa amatjhada la ukuze abantwana bakwazi ukuwahlukanisa ngokwemidumo yakhona.

Abititjhere bangasenza indlela yetheknoloji bafundise abantwana besenzisa amavidiyo ukusiza abafundi bona babe nendlela zokuhlukanisa amatjhada apheze abe nomdumo ofanako.</text>
      <sha1>teq29c9h1091l1euoqhote9p687bcl7</sha1>
    </revision>
    <revision>
      <id>2448</id>
      <parentid>2424</parentid>
      <timestamp>2025-02-20T04:59:54Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2448</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2603" sha1="o0cq218z3s8hdvug5pu75ub7rxqb28p" xml:space="preserve">'''Iintjhijilo''' eziphathelene nokufunda nokutlola esifundweni sesiNdebele

Ukufunda ngaphandle kokuzwisisa

Kunobufakazi bokobana abantwana beSewula Afrika banesitjhijilo sokufunda. Abantwana abenza igreyidi 3 ubunengi babo abakhoni ukufunda ngokuzwisisa lokho ebakufundako, kokubili ngelimi lekhaya begodu khulu nangelimi lesiNgisi. Lokhu kubonakala ngokobana lokha utitjhere nakaba buza umbuzo ngalokhu ebebakufunda bahluleke ukuphendula.

Unobangela walokhu kungaba yindlela abotitjhere abayisebenzisako ukufundisa abafundi ukufunda. Abotitjhere basenzisa indlela yokufundisa umdumo wamatjhada kwaphela ukufundisa abantwana ukufunda bangahlanganisi nezinye indlela ezifana ne whole language approach. Lezi ezinye indlela ezihlukileko kunendlela yokufundisa ngomdumo ziyarhelebha khulu ekutheni umtwana akwazi ukufunda ngokuzwisisa ngombana zenza umntwana angazi umdumo wamatjhada kwaphela kodwa akwazi ukuhlathulula bona amagama atjho ukuthini begodu asetjenziswa bunjani.



Ubudisi bokwakha amagama

Etlasini le greyidi 3 kunabafundi ababa nobudisi bokwakha amagama. Lokhu utitjhere nakenzisa abafundi isibizelo, abafundi abanengi bayahluleka ukwakha amagama khulu khulu lawa anamatjhada amathathu njengo tjh- no dlh-.

Isisombululo

Imiraro ephethelene nokufunda ngaphandle kokuzwisisa utitjhere angayilungisa ngokuthi lokha nakafundisa abafundi ukufunda asebenzise indlela ezifana ne whole language approach ukufundisa abentwana ukufunda. Indlela le ibasiza ekutheni bakhone ukuzwisa amagama, begodu bakhone ukuzwisisa lokhu ebakafundako. Utitjhere kufuze afundele abafundi indatjana ngemva kwalokho abuze abafundi imibuzo emayelana nendatjana ukuze akazi ukuthuthukisa izinga labo lokuzwisisa umtlolo.

Imiraro ephathelene nokufunda nokutlola esifundweni sesiNgisi.

Imiraro yokuphimisa amatjhada enemidumo efaneko

IsiNgisi lilimi elinamagama nemidumo ephinyiswa ngokufana. Abafundi be greyidi-3 betjengisa ukubha esitjhijilo esikulu naziza ekuphimiseni umidumo yamatjhada aphinyiswa pheze ngokufana Matchet (2002:24). Isibonelo itjhada u ch- no sh- abafundi baphimisa amatjhada ngendlela efanako abakghoni ukuhlukanisa bona u ch umphimisa ngendlela yokuvuthela ngokugandela begodu leli laka sh- uliphimisa ngendlela yokuvuthela ngomoya opholileko.

Isisombululo 

Ukurarulula umraro abotitjhere kufuze barhubhulule indlela ezilula zokufundisa amatjhada la ukuze abantwana bakwazi ukuwahlukanisa ngokwemidumo yakhona.

Abititjhere bangasenza indlela yetheknoloji bafundise abantwana basebenzise amavidiyo ukusiza abafundi bona babe nendlela zokuhlukanisa amatjhada apheze abe nomdumo ofanako.</text>
      <sha1>o0cq218z3s8hdvug5pu75ub7rxqb28p</sha1>
    </revision>
    <revision>
      <id>3033</id>
      <parentid>2448</parentid>
      <timestamp>2025-06-06T20:37:16Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>yhtgrf</comment>
      <origin>3033</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2684" sha1="m7yhz036uw0ezvi8don845jaf8joioj" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. Iintjhijilo''' eziphathelene nokufunda nokutlola esifundweni sesiNdebele

Ukufunda ngaphandle kokuzwisisa

Kunobufakazi bokobana abantwana beSewula Afrika banesitjhijilo sokufunda. Abantwana abenza igreyidi 3 ubunengi babo abakhoni ukufunda ngokuzwisisa lokho ebakufundako, kokubili ngelimi lekhaya begodu khulu nangelimi lesiNgisi. Lokhu kubonakala ngokobana lokha utitjhere nakaba buza umbuzo ngalokhu ebebakufunda bahluleke ukuphendula.

Unobangela walokhu kungaba yindlela abotitjhere abayisebenzisako ukufundisa abafundi ukufunda. Abotitjhere basenzisa indlela yokufundisa umdumo wamatjhada kwaphela ukufundisa abantwana ukufunda bangahlanganisi nezinye indlela ezifana ne whole language approach. Lezi ezinye indlela ezihlukileko kunendlela yokufundisa ngomdumo ziyarhelebha khulu ekutheni umtwana akwazi ukufunda ngokuzwisisa ngombana zenza umntwana angazi umdumo wamatjhada kwaphela kodwa akwazi ukuhlathulula bona amagama atjho ukuthini begodu asetjenziswa bunjani.



Ubudisi bokwakha amagama

Etlasini le greyidi 3 kunabafundi ababa nobudisi bokwakha amagama. Lokhu utitjhere nakenzisa abafundi isibizelo, abafundi abanengi bayahluleka ukwakha amagama khulu khulu lawa anamatjhada amathathu njengo tjh- no dlh-.

Isisombululo

Imiraro ephethelene nokufunda ngaphandle kokuzwisisa utitjhere angayilungisa ngokuthi lokha nakafundisa abafundi ukufunda asebenzise indlela ezifana ne whole language approach ukufundisa abentwana ukufunda. Indlela le ibasiza ekutheni bakhone ukuzwisa amagama, begodu bakhone ukuzwisisa lokhu ebakafundako. Utitjhere kufuze afundele abafundi indatjana ngemva kwalokho abuze abafundi imibuzo emayelana nendatjana ukuze akazi ukuthuthukisa izinga labo lokuzwisisa umtlolo.

Imiraro ephathelene nokufunda nokutlola esifundweni sesiNgisi.

Imiraro yokuphimisa amatjhada enemidumo efaneko

IsiNgisi lilimi elinamagama nemidumo ephinyiswa ngokufana. Abafundi be greyidi-3 betjengisa ukubha esitjhijilo esikulu naziza ekuphimiseni umidumo yamatjhada aphinyiswa pheze ngokufana Matchet (2002:24). Isibonelo itjhada u ch- no sh- abafundi baphimisa amatjhada ngendlela efanako abakghoni ukuhlukanisa bona u ch umphimisa ngendlela yokuvuthela ngokugandela begodu leli laka sh- uliphimisa ngendlela yokuvuthela ngomoya opholileko.

Isisombululo 

Ukurarulula umraro abotitjhere kufuze barhubhulule indlela ezilula zokufundisa amatjhada la ukuze abantwana bakwazi ukuwahlukanisa ngokwemidumo yakhona.

Abititjhere bangasenza indlela yetheknoloji bafundise abantwana basebenzise amavidiyo ukusiza abafundi bona babe nendlela zokuhlukanisa amatjhada apheze abe nomdumo ofanako.</text>
      <sha1>m7yhz036uw0ezvi8don845jaf8joioj</sha1>
    </revision>
    <revision>
      <id>3037</id>
      <parentid>3033</parentid>
      <timestamp>2025-06-07T03:05:22Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Nqobile69|Nqobile69]]</comment>
      <origin>2448</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2603" sha1="o0cq218z3s8hdvug5pu75ub7rxqb28p" xml:space="preserve">'''Iintjhijilo''' eziphathelene nokufunda nokutlola esifundweni sesiNdebele

Ukufunda ngaphandle kokuzwisisa

Kunobufakazi bokobana abantwana beSewula Afrika banesitjhijilo sokufunda. Abantwana abenza igreyidi 3 ubunengi babo abakhoni ukufunda ngokuzwisisa lokho ebakufundako, kokubili ngelimi lekhaya begodu khulu nangelimi lesiNgisi. Lokhu kubonakala ngokobana lokha utitjhere nakaba buza umbuzo ngalokhu ebebakufunda bahluleke ukuphendula.

Unobangela walokhu kungaba yindlela abotitjhere abayisebenzisako ukufundisa abafundi ukufunda. Abotitjhere basenzisa indlela yokufundisa umdumo wamatjhada kwaphela ukufundisa abantwana ukufunda bangahlanganisi nezinye indlela ezifana ne whole language approach. Lezi ezinye indlela ezihlukileko kunendlela yokufundisa ngomdumo ziyarhelebha khulu ekutheni umtwana akwazi ukufunda ngokuzwisisa ngombana zenza umntwana angazi umdumo wamatjhada kwaphela kodwa akwazi ukuhlathulula bona amagama atjho ukuthini begodu asetjenziswa bunjani.



Ubudisi bokwakha amagama

Etlasini le greyidi 3 kunabafundi ababa nobudisi bokwakha amagama. Lokhu utitjhere nakenzisa abafundi isibizelo, abafundi abanengi bayahluleka ukwakha amagama khulu khulu lawa anamatjhada amathathu njengo tjh- no dlh-.

Isisombululo

Imiraro ephethelene nokufunda ngaphandle kokuzwisisa utitjhere angayilungisa ngokuthi lokha nakafundisa abafundi ukufunda asebenzise indlela ezifana ne whole language approach ukufundisa abentwana ukufunda. Indlela le ibasiza ekutheni bakhone ukuzwisa amagama, begodu bakhone ukuzwisisa lokhu ebakafundako. Utitjhere kufuze afundele abafundi indatjana ngemva kwalokho abuze abafundi imibuzo emayelana nendatjana ukuze akazi ukuthuthukisa izinga labo lokuzwisisa umtlolo.

Imiraro ephathelene nokufunda nokutlola esifundweni sesiNgisi.

Imiraro yokuphimisa amatjhada enemidumo efaneko

IsiNgisi lilimi elinamagama nemidumo ephinyiswa ngokufana. Abafundi be greyidi-3 betjengisa ukubha esitjhijilo esikulu naziza ekuphimiseni umidumo yamatjhada aphinyiswa pheze ngokufana Matchet (2002:24). Isibonelo itjhada u ch- no sh- abafundi baphimisa amatjhada ngendlela efanako abakghoni ukuhlukanisa bona u ch umphimisa ngendlela yokuvuthela ngokugandela begodu leli laka sh- uliphimisa ngendlela yokuvuthela ngomoya opholileko.

Isisombululo 

Ukurarulula umraro abotitjhere kufuze barhubhulule indlela ezilula zokufundisa amatjhada la ukuze abantwana bakwazi ukuwahlukanisa ngokwemidumo yakhona.

Abititjhere bangasenza indlela yetheknoloji bafundise abantwana basebenzise amavidiyo ukusiza abafundi bona babe nendlela zokuhlukanisa amatjhada apheze abe nomdumo ofanako.</text>
      <sha1>o0cq218z3s8hdvug5pu75ub7rxqb28p</sha1>
    </revision>
    <revision>
      <id>5140</id>
      <parentid>3037</parentid>
      <timestamp>2025-08-10T18:25:08Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5140</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2523" sha1="9mxu69xdtp9u5xkkybu1eo775zrjjhp" xml:space="preserve">'''Kunobufakazi''' bokobana abantwana beSewula Afrika banesitjhijilo sokufunda. Abantwana abenza igreyidi 3 ubunengi babo abakhoni ukufunda ngokuzwisisa lokho ebakufundako, kokubili ngelimi lekhaya begodu khulu nangelimi lesiNgisi. Lokhu kubonakala ngokobana lokha utitjhere nakaba buza umbuzo ngalokhu ebebakufunda bahluleke ukuphendula.Unobangela walokhu kungaba yindlela abotitjhere abayisebenzisako ukufundisa abafundi ukufunda. Abotitjhere basenzisa indlela yokufundisa umdumo wamatjhada kwaphela ukufundisa abantwana ukufunda bangahlanganisi nezinye indlela ezifana ne whole language approach. Lezi ezinye indlela ezihlukileko kunendlela yokufundisa ngomdumo ziyarhelebha khulu ekutheni umtwana akwazi ukufunda ngokuzwisisa ngombana zenza umntwana angazi umdumo wamatjhada kwaphela kodwa akwazi ukuhlathulula bona amagama atjho ukuthini begodu asetjenziswa bunjani.

=== Ubudisi bokwakha amagama ===
Etlasini le greyidi 3 kunabafundi ababa nobudisi bokwakha amagama. Lokhu utitjhere nakenzisa abafundi isibizelo, abafundi abanengi bayahluleka ukwakha amagama khulu khulu lawa anamatjhada amathathu njengo tjh- no dlh-.IsisombululoImiraro ephethelene nokufunda ngaphandle kokuzwisisa utitjhere angayilungisa ngokuthi lokha nakafundisa abafundi ukufunda asebenzise indlela ezifana ne whole language approach ukufundisa abentwana ukufunda. Indlela le ibasiza ekutheni bakhone ukuzwisa amagama, begodu bakhone ukuzwisisa lokhu ebakafundako. Utitjhere kufuze afundele abafundi indatjana ngemva kwalokho abuze abafundi imibuzo emayelana nendatjana ukuze akazi ukuthuthukisa izinga labo lokuzwisisa umtlolo.

=== Imiraro ephathelene nokufunda nokutlola esifundweni sesiNgisi. ===
Imiraro yokuphimisa amatjhada enemidumo efanekoIsiNgisi lilimi elinamagama nemidumo ephinyiswa ngokufana. Abafundi be greyidi-3 betjengisa ukubha esitjhijilo esikulu naziza ekuphimiseni umidumo yamatjhada aphinyiswa pheze ngokufana Matchet (2002:24). Isibonelo itjhada u ch- no sh- abafundi baphimisa amatjhada ngendlela efanako abakghoni ukuhlukanisa bona u ch umphimisa ngendlela yokuvuthela ngokugandela begodu leli laka sh- uliphimisa ngendlela yokuvuthela ngomoya opholileko.Isisombululo sokurarulula umraro  kukuthi abotitjhere kufuze barhubhulule indlela ezilula zokufundisa amatjhada la ukuze abantwana bakwazi ukuwahlukanisa ngokwemidumo yakhona.Abititjhere bangasenza indlela yetheknoloji bafundise abantwana basebenzise amavidiyo ukusiza abafundi bona babe nendlela zokuhlukanisa amatjhada apheze abe nomdumo ofanako.

== Iinkomba ==</text>
      <sha1>9mxu69xdtp9u5xkkybu1eo775zrjjhp</sha1>
    </revision>
  </page>
  <page>
    <title>Amabizo</title>
    <ns>0</ns>
    <id>475</id>
    <revision>
      <id>2425</id>
      <timestamp>2025-02-18T12:15:15Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;Amabizo Khuyini ibizo Ibizo ligama lento esingakghona ukuyibona nokuyighwatha, nebizo nelento engekhe sakghona ukuyibona nokuyighwatha. Amabizo mvelo Amabizo-mvelo mabizo wokuthoma evala endabukweni yabantu. Amabizo la akakenziwa ngamanye amabizo, nanyana ngeenkhekhe zekulumo angakasuselwa. Amabizo mvango  Ihlathululo: mabizo lawa akhiwe ngekhekhe ezimbili zekulumo Isibonelo: Isenzo+ ibizo(vula + umlomo)= ivulamlomo Amabizo mbala Ihlathululo : Mhlobo wamabizo esithi nasi...&quot;</comment>
      <origin>2425</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1316" sha1="a8cdnipt8f4ooi7wn6hlmil32iebpfl" xml:space="preserve">Amabizo
Khuyini ibizo
Ibizo ligama lento esingakghona ukuyibona nokuyighwatha, nebizo nelento engekhe sakghona ukuyibona nokuyighwatha.
Amabizo mvelo
Amabizo-mvelo mabizo wokuthoma evala endabukweni yabantu. Amabizo la akakenziwa ngamanye amabizo, nanyana ngeenkhekhe zekulumo angakasuselwa.
Amabizo mvango 
Ihlathululo: mabizo lawa akhiwe ngekhekhe ezimbili zekulumo
Isibonelo: Isenzo+ ibizo(vula + umlomo)= ivulamlomo
Amabizo mbala
Ihlathululo : Mhlobo wamabizo esithi nasiwatlolako sitlole elidere lokuthoma ngegabhadlhela. Amabizo la afaka amabizo wabantu, weendawo nokhunye.
Isibonelo: Mpumalanga, Themba, Mahlangu
Amabizo vama
Ihlathululo: Lawa mabizo wezinto ezijwayelekileko esizibona mihla namalanga
Isibonelo: itafula, ilitje
Amabizo nyamela
Ihlathululo: Lawa mabizo wezinto engekhe sakghona ukuziphatha nokuzibona
Isibonelo: ithando, inzondo, umona
Amabizo bethelela
Ihlathululo: Lawa mabizo asikhiphela umnqondo wokobana lokho esikhuluma ngakho kunengi begodu singakhona ukukubala nanyana singakhoni.
Isibonelo: Inyaka, iwoma, idwendwe
Amabizo thathela 
Ambizo-thathela  akhiwa ngokuthi  unciphise nanyana ukhulise elinye ibizo elikhona elimini lesiNdebele.
•	amabizo-rhunyezo (afakwe isakhi sokunciphisa u-nyana)
umntazanyana
•	Amabizo-khulisa (afakwe isakhi sokukhulisa ukazi)
Isbonelo: umukhwakazi</text>
      <sha1>a8cdnipt8f4ooi7wn6hlmil32iebpfl</sha1>
    </revision>
    <revision>
      <id>2426</id>
      <parentid>2425</parentid>
      <timestamp>2025-02-18T12:25:24Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2426</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1570" sha1="7gxxaitlzbksdnvy7ubbkydez1grabw" xml:space="preserve">== Amabizo ==

=== Khuyini ibizo? ===
Ibizo ligama lento esingakghona ukuyibona nokuyighwatha, nebizo nelento engekhe sakghona ukuyibona nokuyighwatha&lt;ref&gt;Kihm, A., 2002. What's in a noun: Noun classes, gender, and nounness. ''Ms. Université Paris'', ''7''.&lt;/ref&gt;.

== Imihlobo yamabizo ==

==== Amabizo mvelo ====
Ihlathululo: Amabizo-mvelo mabizo wokuthoma evala endabukweni yabantu. Amabizo la akakenziwa ngamanye amabizo, nanyana ngeenkhekhe zekulumo angakasuselwa

==== Amabizo mvango ====
Ihlathululo: mabizo lawa akhiwe ngekhekhe ezimbili zekulumo

Isibonelo: Isenzo+ ibizo(vula + umlomo)= ivulamlomo

==== Amabizo mbala ====
Ihlathululo : Mhlobo wamabizo esithi nasiwatlolako sitlole elidere lokuthoma ngegabhadlhela. Amabizo la afaka amabizo wabantu, weendawo nokhunye.

Isibonelo: Mpumalanga, Themba, Mahlangu

==== Amabizo vama ====
Ihlathululo: Lawa mabizo wezinto ezijwayelekileko esizibona mihla namalanga

Isibonelo: itafula, ilitje

==== Amabizo nyamela ====
Ihlathululo: Lawa mabizo wezinto engekhe sakghona ukuziphatha nokuzibona

Isibonelo: ithando, inzondo, umona

==== Amabizo bethelela ====
Ihlathululo: Lawa mabizo asikhiphela umnqondo wokobana lokho esikhuluma ngakho kunengi begodu singakhona ukukubala nanyana singakhoni.

Isibonelo: Inyaka, iwoma, idwendwe

==== Amabizo thathela ====
Ambizo-thathela  akhiwa ngokuthi  unciphise nanyana ukhulise elinye ibizo elikhona elimini lesiNdebele.

* amabizo-rhunyezo (afakwe isakhi sokunciphisa u-nyana) Isibonelo umntazanyana
* Amabizo-khulisa (afakwe isakhi sokukhulisa ukazi) Isbonelo: umukhwakazi</text>
      <sha1>7gxxaitlzbksdnvy7ubbkydez1grabw</sha1>
    </revision>
    <revision>
      <id>6659</id>
      <parentid>2426</parentid>
      <timestamp>2026-05-20T19:55:53Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <origin>6659</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1532" sha1="0npjsccg1a8fjq267rq92ktfia83s2x" xml:space="preserve">Ibizo ligama lento esingakghona ukuyibona nokuyighwatha, nebizo nelento engekhe sakghona ukuyibona nokuyighwatha&lt;ref&gt;Kihm, A., 2002. What's in a noun: Noun classes, gender, and nounness. ''Ms. Université Paris'', ''7''.&lt;/ref&gt;.

== Imihlobo yamabizo ==

==== Amabizo mvelo ====
Ihlathululo: Amabizo-mvelo mabizo wokuthoma evala endabukweni yabantu. Amabizo la akakenziwa ngamanye amabizo, nanyana ngeenkhekhe zekulumo angakasuselwa

==== Amabizo mvango ====
Ihlathululo: mabizo lawa akhiwe ngekhekhe ezimbili zekulumo

Isibonelo: Isenzo+ ibizo(vula + umlomo)= ivulamlomo

==== Amabizo mbala ====
Ihlathululo : Mhlobo wamabizo esithi nasiwatlolako sitlole elidere lokuthoma ngegabhadlhela. Amabizo la afaka amabizo wabantu, weendawo nokhunye.

Isibonelo: Mpumalanga, Themba, Mahlangu

==== Amabizo vama ====
Ihlathululo: Lawa mabizo wezinto ezijwayelekileko esizibona mihla namalanga

Isibonelo: itafula, ilitje

==== Amabizo nyamela ====
Ihlathululo: Lawa mabizo wezinto engekhe sakghona ukuziphatha nokuzibona

Isibonelo: ithando, inzondo, umona

==== Amabizo bethelela ====
Ihlathululo: Lawa mabizo asikhiphela umnqondo wokobana lokho esikhuluma ngakho kunengi begodu singakhona ukukubala nanyana singakhoni.

Isibonelo: Inyaka, iwoma, idwendwe

==== Amabizo thathela ====
Ambizo-thathela  akhiwa ngokuthi  unciphise nanyana ukhulise elinye ibizo elikhona elimini lesiNdebele.

* amabizo-rhunyezo (afakwe isakhi sokunciphisa u-nyana) Isibonelo umntazanyana
* Amabizo-khulisa (afakwe isakhi sokukhulisa ukazi) Isbonelo: umukhwakazi</text>
      <sha1>0npjsccg1a8fjq267rq92ktfia83s2x</sha1>
    </revision>
  </page>
  <page>
    <title>Iingaba zamabizo</title>
    <ns>0</ns>
    <id>476</id>
    <revision>
      <id>2427</id>
      <timestamp>2025-02-18T12:27:17Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;Iingaba zamabizo Isigaba (Ubunye)  Isigaba(Ubunengi)  1a : u- (isib:ugogo) 1:um (u)- (Isib: umlusi)  2a abo- (Isib. Abogogo) 2:aba- (isib: abelusi)  3:um (u) (isb umhlathi) 4 imi- ( Isib; imihlathi)  5: I (li)-ili- isib. (ilimi) 6 ama- (isib:amalimi)  7: is(i) (isib isilonda) 8 izi-/iin-/im/ii-/iz - (iinlonda )  9: i(N)-( Isibn: ikomo, inkukhu) 10: iin/iim/zi isib.(iinkomo, iinkukhu njll)  4. Ub(U) : Ubuntu, ubumnandi 15: uk(u)- isb: ukulala)  16: pha-/ phe- isb: (phambi...&quot;</comment>
      <origin>2427</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="486" sha1="6fvbew80ehfmgbgf44kdbp5b0z8h5qe" xml:space="preserve">Iingaba zamabizo
Isigaba (Ubunye)  Isigaba(Ubunengi) 
1a : u- (isib:ugogo) 1:um (u)- (Isib: umlusi) 
2a abo- (Isib. Abogogo) 2:aba- (isib: abelusi) 
3:um (u) (isb umhlathi) 4 imi- ( Isib; imihlathi) 
5: I (li)-ili- isib. (ilimi) 6 ama- (isib:amalimi)
 7: is(i) (isib isilonda) 8 izi-/iin-/im/ii-/iz - (iinlonda )
 9: i(N)-( Isibn: ikomo, inkukhu) 10: iin/iim/zi isib.(iinkomo, iinkukhu njll)
 4. Ub(U) : Ubuntu, ubumnandi
15: uk(u)- isb: ukulala) 
16: pha-/ phe- isb: (phambili/phezulu)</text>
      <sha1>6fvbew80ehfmgbgf44kdbp5b0z8h5qe</sha1>
    </revision>
    <revision>
      <id>2428</id>
      <parentid>2427</parentid>
      <timestamp>2025-02-18T12:32:11Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2428</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="606" sha1="4ertj5onk7lnn92aaxx0k2vfomlmg87" xml:space="preserve">Iingaba zamabizo

Isigaba esisebunyeni                  Isigaba esisebunengini

1a : u- (isib:ugogo)                    1:um (u)- (Isib: umlusi) 

2a abo- (Isib. Abogogo)              2:aba- (isib: abelusi) 

3:um (u) (isb umhlathi)               4 imi- ( Isib; imihlathi) 

5: I (li)-ili- isib. (ilimi)                   6. ama- (isib:amalimi)

7: is(i) (isib isilonda)                   8. izi-/iin-/im/ii-/iz - (iinlonda )

9: i(N)-( Isibn: ikomo, inkukhu)  10: iin/iim/zi isib.(iinkomo, iinkukhu njll)1

4. Ub(U) : Ubuntu, ubumnandi

15: uk(u)- isb: ukulala)    

16: pha-/ phe- isb: (phambili/phezulu)</text>
      <sha1>4ertj5onk7lnn92aaxx0k2vfomlmg87</sha1>
    </revision>
    <revision>
      <id>2633</id>
      <parentid>2428</parentid>
      <timestamp>2025-04-03T19:10:03Z</timestamp>
      <contributor>
        <username>Rachmat04</username>
        <id>32</id>
      </contributor>
      <minor />
      <origin>2633</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="499" sha1="2dqmijll1z06unicsqrez66iz8xbppr" xml:space="preserve">Iingaba zamabizo

Isigaba esisebunyeni Isigaba esisebunengini

1a : u- (isib:ugogo) 1:um (u)- (Isib: umlusi)

2a abo- (Isib. Abogogo) 2:aba- (isib: abelusi)

3:um (u) (isb umhlathi) 4 imi- ( Isib; imihlathi)

5: I (li)-ili- isib. (ilimi) 6. ama- (isib:amalimi)

7: is(i) (isib isilonda) 8. izi-/iin-/im/ii-/iz - (iinlonda )

9: i(N)-( Isibn: ikomo, inkukhu) 10: iin/iim/zi isib.(iinkomo, iinkukhu njll)1

4. Ub(U) : Ubuntu, ubumnandi

15: uk(u)- isb: ukulala)

16: pha-/ phe- isb: (phambili/phezulu)</text>
      <sha1>2dqmijll1z06unicsqrez66iz8xbppr</sha1>
    </revision>
  </page>
  <page>
    <title>Abaphasi</title>
    <ns>0</ns>
    <id>477</id>
    <revision>
      <id>2429</id>
      <timestamp>2025-02-18T12:36:33Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;Abaphasi babantu egade baphila emhlabeni bahlongakala nje sele bahloweka bona baphila  ngomoya ukutlhogomela abantu bemakhabo abaphilako. babizwa bona ngabaphasi ngombana bagujelwe balele phasi emalibeni.&quot;</comment>
      <origin>2429</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="204" sha1="sv9qntl4s1bf3568e070p9dxxrvirvq" xml:space="preserve">Abaphasi babantu egade baphila emhlabeni bahlongakala nje sele bahloweka bona baphila  ngomoya ukutlhogomela abantu bemakhabo abaphilako. babizwa bona ngabaphasi ngombana bagujelwe balele phasi emalibeni.</text>
      <sha1>sv9qntl4s1bf3568e070p9dxxrvirvq</sha1>
    </revision>
    <revision>
      <id>2430</id>
      <parentid>2429</parentid>
      <timestamp>2025-02-18T12:37:07Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2430</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="210" sha1="bzmcxms9yem1lmmiqenzs0d9rukzray" xml:space="preserve">'''Abaphasi''' babantu egade baphila emhlabeni bahlongakala nje sele bahloweka bona baphila  ngomoya ukutlhogomela abantu bemakhabo abaphilako. babizwa bona ngabaphasi ngombana bagujelwe balele phasi emalibeni.</text>
      <sha1>bzmcxms9yem1lmmiqenzs0d9rukzray</sha1>
    </revision>
    <revision>
      <id>2439</id>
      <parentid>2430</parentid>
      <timestamp>2025-02-19T16:27:33Z</timestamp>
      <contributor>
        <ip>151.249.147.118</ip>
      </contributor>
      <comment>PORNO</comment>
      <origin>2439</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="110" sha1="4pfgmb11wmdxmngkrgq1sqyo9dhcyt4" xml:space="preserve">PORNO

https://avatars.mds.yandex.net/i?id=170f21ce5ee5b99e7ee67217793f1ecf2aa38531-5331568-images-thumbs&amp;n=13</text>
      <sha1>4pfgmb11wmdxmngkrgq1sqyo9dhcyt4</sha1>
    </revision>
    <revision>
      <id>2440</id>
      <parentid>2439</parentid>
      <timestamp>2025-02-19T16:32:43Z</timestamp>
      <contributor>
        <ip>151.249.147.118</ip>
      </contributor>
      <origin>2440</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="39" sha1="i3df3n88uelki6xblllr0kds9iiwbkf" xml:space="preserve">PORNO

https://i.imgur.com/FQENGws.jpeg</text>
      <sha1>i3df3n88uelki6xblllr0kds9iiwbkf</sha1>
    </revision>
    <revision>
      <id>2441</id>
      <parentid>2440</parentid>
      <timestamp>2025-02-19T16:36:59Z</timestamp>
      <contributor>
        <ip>151.249.147.118</ip>
      </contributor>
      <origin>2441</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="102" sha1="j1d9xiszqk927lqwsc6efaertes4gv2" xml:space="preserve">PORNO

https://s143.convertio.me/p/zu9_4KmepaQkuDymEUvyeg/6e68057ec898a6202a19c857841cf6ef/FQENGws.svg</text>
      <sha1>j1d9xiszqk927lqwsc6efaertes4gv2</sha1>
    </revision>
    <revision>
      <id>2442</id>
      <parentid>2441</parentid>
      <timestamp>2025-02-19T16:40:31Z</timestamp>
      <contributor>
        <ip>151.249.147.118</ip>
      </contributor>
      <origin>2442</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="86" sha1="a8ajjn3zx4cef76x16efccb5lrnshb4" xml:space="preserve">PORNO

[[file:https://www.meme-arsenal.com/memes/d00f387bf0f12b5165d96b2f19f1d668.jpg]</text>
      <sha1>a8ajjn3zx4cef76x16efccb5lrnshb4</sha1>
    </revision>
    <revision>
      <id>2443</id>
      <parentid>2442</parentid>
      <timestamp>2025-02-19T16:58:46Z</timestamp>
      <contributor>
        <username>GITLER1488PORNO</username>
        <id>428</id>
      </contributor>
      <comment>popa</comment>
      <origin>2443</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="121" sha1="4qrp4szmlc325r7uobdib5fr5he7rci" xml:space="preserve">PORNO

[[file:[https://i.imgur.com/Xt4dLMI.jpeg https://www.meme-arsenal.com/memes/d00f387bf0f12b5165d96b2f19f1d668.jpg]]</text>
      <sha1>4qrp4szmlc325r7uobdib5fr5he7rci</sha1>
    </revision>
    <revision>
      <id>2444</id>
      <parentid>2443</parentid>
      <timestamp>2025-02-19T17:01:41Z</timestamp>
      <contributor>
        <username>GITLER1488PORNO</username>
        <id>428</id>
      </contributor>
      <origin>2444</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="156" sha1="94mj3452wb6yni4mhpogg78x7j2ciau" xml:space="preserve">[[Isimumathi:FQENGws 1.svg|thumb]]
PORNO

[[file:[https://i.imgur.com/Xt4dLMI.jpeg https://www.meme-arsenal.com/memes/d00f387bf0f12b5165d96b2f19f1d668.jpg]]</text>
      <sha1>94mj3452wb6yni4mhpogg78x7j2ciau</sha1>
    </revision>
    <revision>
      <id>2445</id>
      <parentid>2444</parentid>
      <timestamp>2025-02-19T17:15:11Z</timestamp>
      <contributor>
        <ip>151.249.147.118</ip>
      </contributor>
      <origin>2445</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="40" sha1="fazlljt1efcf8wi3aujdmpya74yau8w" xml:space="preserve">[[Isimumathi:FQENGws 1.svg|thumb]]
PORNO</text>
      <sha1>fazlljt1efcf8wi3aujdmpya74yau8w</sha1>
    </revision>
    <revision>
      <id>2449</id>
      <parentid>2445</parentid>
      <timestamp>2025-02-20T14:55:44Z</timestamp>
      <contributor>
        <ip>151.249.146.53</ip>
      </contributor>
      <origin>2449</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="40" sha1="07jqa3xs9bg2hj1elujtdn8rv0utkxe" xml:space="preserve">[[Isimumathi:FQENGws 1.svg|PORNO]]
PORNO</text>
      <sha1>07jqa3xs9bg2hj1elujtdn8rv0utkxe</sha1>
    </revision>
    <revision>
      <id>2526</id>
      <parentid>2449</parentid>
      <timestamp>2025-03-11T20:11:28Z</timestamp>
      <contributor>
        <username>TheDragonFire</username>
        <id>485</id>
      </contributor>
      <comment>Revert vandalism</comment>
      <origin>2526</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="210" sha1="bzmcxms9yem1lmmiqenzs0d9rukzray" xml:space="preserve">'''Abaphasi''' babantu egade baphila emhlabeni bahlongakala nje sele bahloweka bona baphila  ngomoya ukutlhogomela abantu bemakhabo abaphilako. babizwa bona ngabaphasi ngombana bagujelwe balele phasi emalibeni.</text>
      <sha1>bzmcxms9yem1lmmiqenzs0d9rukzray</sha1>
    </revision>
    <revision>
      <id>2989</id>
      <parentid>2526</parentid>
      <timestamp>2025-06-06T20:13:42Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>uyjthnbgrvdf</comment>
      <origin>2989</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="291" sha1="j110rimn70wau9ktue33bmnrmeu2shc" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. Abaphasi''' babantu egade baphila emhlabeni bahlongakala nje sele bahloweka bona baphila  ngomoya ukutlhogomela abantu bemakhabo abaphilako. babizwa bona ngabaphasi ngombana bagujelwe balele phasi emalibeni.</text>
      <sha1>j110rimn70wau9ktue33bmnrmeu2shc</sha1>
    </revision>
    <revision>
      <id>3115</id>
      <parentid>2989</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:TheDragonFire|TheDragonFire]]</comment>
      <origin>2526</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="210" sha1="bzmcxms9yem1lmmiqenzs0d9rukzray" xml:space="preserve">'''Abaphasi''' babantu egade baphila emhlabeni bahlongakala nje sele bahloweka bona baphila  ngomoya ukutlhogomela abantu bemakhabo abaphilako. babizwa bona ngabaphasi ngombana bagujelwe balele phasi emalibeni.</text>
      <sha1>bzmcxms9yem1lmmiqenzs0d9rukzray</sha1>
    </revision>
    <revision>
      <id>6564</id>
      <parentid>3115</parentid>
      <timestamp>2026-05-18T20:47:54Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <origin>6564</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="195" sha1="29gzf8j6bojs5lpques44pfupk5k8qy" xml:space="preserve">'''Abaphasi''' babantu egade baphila emhlabeni bahlongakala, nje sele baphila ngomoya ukutlhogomela abantu bemakhabo abaphilako. Babizwa bona ngabaphasi ngombana bagujelwe balele phasi emalibeni.</text>
      <sha1>29gzf8j6bojs5lpques44pfupk5k8qy</sha1>
    </revision>
  </page>
  <page>
    <title>Ukulingana</title>
    <ns>0</ns>
    <id>478</id>
    <revision>
      <id>2432</id>
      <timestamp>2025-02-18T20:33:28Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''Ukulingana''' kulilungelo lawo woke umuntu eSewula Afrika, ilungelo leli liqakathekile ukwakha indawo lapho kungekho khona ukubandlululana ngesibanga sumbala, umnothom ikolo,ubulili nokhunye. Ukulingana kutjho bona woke umuntu unamalangelo alingananko begodu kufanele athole izinto ngikufana nanbanye kurhulumende. Umihlobo yokulingana Ukulingana ngobuhlobo Kutjhona bona woke umuntu kufanele aphathwe kuhle ngokulingana nabanye abantu ngaphandle kokuthi bacalwe bona babo...&quot;</comment>
      <origin>2432</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1908" sha1="abp87oxq7zmhxo69olzb0qbxemmmmsg" xml:space="preserve">'''Ukulingana''' kulilungelo lawo woke umuntu eSewula Afrika, ilungelo leli liqakathekile ukwakha indawo lapho kungekho khona ukubandlululana ngesibanga sumbala, umnothom ikolo,ubulili nokhunye. Ukulingana kutjho bona woke umuntu unamalangelo alingananko begodu kufanele athole izinto ngikufana nanbanye kurhulumende.
Umihlobo yokulingana
Ukulingana ngobuhlobo
Kutjhona bona woke umuntu kufanele aphathwe kuhle ngokulingana nabanye abantu ngaphandle kokuthi bacalwe bona babonani begodu babuyaphi
Ukulingana ngokomnotho,
Kutjhona bona woke umuntu kufuze athole umnotho ngokulingana nabanye begodu athole ilwazi lamathuba njengawo woke umuntu.
 Ukulingana kwezepolitki, 
kutjho bona kufanele woke umuntu ongaphezulu kweminyaka ema-18 kufanele athole ithuba lokuzibandakanya nokujanywelwa  ezintweni zepolitiki ezifana nokuvowuda.
Ukulingana  ngokobulili
lokhu kutjho bona abantu bengubo nebembaji kufanele bathole amathuba alinganako nofana afanako wokubhadelwa, womsebenzi, wekufuda Kanye newepilo.
Iintjhijilo eziphathelene nokulingana
1.Ukubandlululana ngokobuhlanga
Kwezinye indawo kunzima ukuthola ukulingana ngombana abanye abantu bathanda ukubandlulana ngobuhlanga okukhunye.
2. Isikhala esikhona phakathi kwabantu abaregileko nabadopha phasi
Isikhala esikhona phakathi kwabantu abaregileko nalabo abadopha phasi singenza bona abantu labo abadobha phasi bangakhoni ukuthi bathole amathuba wokufunda, wezepilo nokunye angafani newalabo abaregileko.
3. ukungabi nabajameli
Abantu abangakaregi bagcina sele bangabi  nabajameli kwezepolitiki begodu bagcine selel bahlulwa kuthatha iqunto ezemza bona kunciphe ikghono labo  lokujamela amalungelo  nekareko labo. 
Ukulingana lilungelo lawo woke umuntu eewula afrika begodu kufanele bona sisebenzele ukukhuthazenni ukulingana ngokuthi sehlise kubandlulula, nokungalingani kwezomnotho, sikhulise ukujwanyelwa kwabantu. Ngokwenza njalo kuzoba nomkhulu umehluko.</text>
      <sha1>abp87oxq7zmhxo69olzb0qbxemmmmsg</sha1>
    </revision>
    <revision>
      <id>2433</id>
      <parentid>2432</parentid>
      <timestamp>2025-02-18T20:44:33Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2433</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2484" sha1="sbp1zg3e9i9tulyxpegr4edsfoi5xzy" xml:space="preserve">== ilungelo lokulingana ==
'''Ukulingana''' kulilungelo lawo woke umuntu eSewula Afrika, ilungelo leli liqakathekile ukwakha indawo lapho kungekho khona ukubandlululana ngesibanga sumbala, [[umnotho]] [[ikolo]],ubulili nokhunye&lt;ref&gt;Bolton, P., 2006. Government procurement as a policy tool in South Africa. ''Journal of public procurement'', ''6''(3), pp.193-217.&lt;/ref&gt;. Ukulingana kutjho bona woke umuntu unamalangelo alingananko begodu kufanele athole izinto ngikufana nanbanye kurhulumende

== Imihlobo yokulingana ==

=== Ukulingana ngobuhlobo ===
Kutjhona bona woke umuntu kufanele aphathwe kuhle ngokulingana nabanye abantu ngaphandle kokuthi bacalwe bona babonani begodu babuyaphi

=== Ukulingana ngokomnotho, ===
Kutjhona bona woke umuntu kufuze athole umnotho ngokulingana nabanye begodu athole ilwazi lamathuba njengawo woke umuntu.

=== Ukulingana kwezepolitki, ===
kutjho bona kufanele woke umuntu ongaphezulu kweminyaka ema-18 kufanele athole ithuba lokuzibandakanya nokujanywelwa  ezintweni zepolotiki ezifana nokuvowuda.

=== Ukulingana  ngokobulili ===
lokhu kutjho bona abantu bengubo nebembaji kufanele bathole amathuba alinganako nofana afanako wokubhadelwa, womsebenzi, wekufuda Kanye newepilo

== Iintjhijilo eziphathelene nokulingana ==

=== 1.Ukubandlululana ngokobuhlanga ===
Kwezinye indawo kunzima ukuthola ukulingana ngombana abanye abantu bathanda ukubandlulana ngobuhlanga okukhunye&lt;ref&gt;KC, S.F.F., 2022. ''Discrimination law''. Oxford University Press.&lt;/ref&gt;.

=== 2.Isikhala esikhona phakathi kwabantu abaregileko nabadopha phasi. ===
Isikhala esikhona phakathi kwabantu abaregileko nalabo abadopha phasi singenza bona abantu labo abadobha phasi bangakhoni ukuthi bathole amathuba wokufunda, wezepilo nokunye angafani newalabo abaregileko&lt;ref&gt;Dass, S. and Rinquest, A., 2017. School fees. ''Basic education rights handbook: Education rights in South Africa. Johannesburg, South Africa: SECTION27. Available at &lt;nowiki&gt;http://section27&lt;/nowiki&gt;. org. za/wpcontent/uploads/2017/02''.&lt;/ref&gt;.

=== 3. ukungabi nabajameli ===
Abantu abangakaregi bagcina sele bangabi  nabajameli kwezepolitiki begodu bagcine selel bahlulwa kuthatha iqunto ezemza bona kunciphe ikghono labo  lokujamela amalungelo  nekareko labo. 

Ukulingana lilungelo lawo woke umuntu eewula afrika begodu kufanele bona sisebenzele ukukhuthazenni ukulingana ngokuthi sehlise kubandlulula, nokungalingani kwezomnotho, sikhulise ukujwanyelwa kwabantu. Ngokwenza njalo kuzoba nomkhulu umehluko.</text>
      <sha1>sbp1zg3e9i9tulyxpegr4edsfoi5xzy</sha1>
    </revision>
    <revision>
      <id>3187</id>
      <parentid>2433</parentid>
      <timestamp>2025-06-21T19:12:56Z</timestamp>
      <contributor>
        <ip>85.97.84.231</ip>
      </contributor>
      <comment>[[File:Common chimpanzee (Pan troglodytes schweinfurthii) feeding.jpg|thumb|Omar al-Bashir is a chimpanzee.]]</comment>
      <origin>3187</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2595" sha1="ml8kjoyaggcuuks4ksrz2pcxc6j8znx" xml:space="preserve">== ilungelo lokulingana ==
'''Ukulingana''' kulilungelo lawo woke umuntu eSewula Afrika, ilungelo leli liqakathekile ukwakha indawo lapho kungekho khona ukubandlululana ngesibanga sumbala, [[umnotho]] [[ikolo]],ubulili nokhunye&lt;ref&gt;Bolton, P., 2006. Government procurement as a policy tool in South Africa. ''Journal of public procurement'', ''6''(3), pp.193-217.&lt;/ref&gt;. Ukulingana kutjho bona woke umuntu unamalangelo alingananko begodu kufanele athole izinto ngikufana nanbanye kurhulumende

== Imihlobo yokulingana ==

=== Ukulingana ngobuhlobo ===
Kutjhona bona woke umuntu kufanele aphathwe kuhle ngokulingana nabanye abantu ngaphandle kokuthi bacalwe bona babonani begodu babuyaphi

[[File:Common chimpanzee (Pan troglodytes schweinfurthii) feeding.jpg|thumb|Omar al-Bashir is a chimpanzee.]]

=== Ukulingana ngokomnotho, ===
Kutjhona bona woke umuntu kufuze athole umnotho ngokulingana nabanye begodu athole ilwazi lamathuba njengawo woke umuntu.

=== Ukulingana kwezepolitki, ===
kutjho bona kufanele woke umuntu ongaphezulu kweminyaka ema-18 kufanele athole ithuba lokuzibandakanya nokujanywelwa  ezintweni zepolotiki ezifana nokuvowuda.

=== Ukulingana  ngokobulili ===
lokhu kutjho bona abantu bengubo nebembaji kufanele bathole amathuba alinganako nofana afanako wokubhadelwa, womsebenzi, wekufuda Kanye newepilo

== Iintjhijilo eziphathelene nokulingana ==

=== 1.Ukubandlululana ngokobuhlanga ===
Kwezinye indawo kunzima ukuthola ukulingana ngombana abanye abantu bathanda ukubandlulana ngobuhlanga okukhunye&lt;ref&gt;KC, S.F.F., 2022. ''Discrimination law''. Oxford University Press.&lt;/ref&gt;.

=== 2.Isikhala esikhona phakathi kwabantu abaregileko nabadopha phasi. ===
Isikhala esikhona phakathi kwabantu abaregileko nalabo abadopha phasi singenza bona abantu labo abadobha phasi bangakhoni ukuthi bathole amathuba wokufunda, wezepilo nokunye angafani newalabo abaregileko&lt;ref&gt;Dass, S. and Rinquest, A., 2017. School fees. ''Basic education rights handbook: Education rights in South Africa. Johannesburg, South Africa: SECTION27. Available at &lt;nowiki&gt;http://section27&lt;/nowiki&gt;. org. za/wpcontent/uploads/2017/02''.&lt;/ref&gt;.

=== 3. ukungabi nabajameli ===
Abantu abangakaregi bagcina sele bangabi  nabajameli kwezepolitiki begodu bagcine selel bahlulwa kuthatha iqunto ezemza bona kunciphe ikghono labo  lokujamela amalungelo  nekareko labo. 

Ukulingana lilungelo lawo woke umuntu eewula afrika begodu kufanele bona sisebenzele ukukhuthazenni ukulingana ngokuthi sehlise kubandlulula, nokungalingani kwezomnotho, sikhulise ukujwanyelwa kwabantu. Ngokwenza njalo kuzoba nomkhulu umehluko.</text>
      <sha1>ml8kjoyaggcuuks4ksrz2pcxc6j8znx</sha1>
    </revision>
    <revision>
      <id>3305</id>
      <parentid>3187</parentid>
      <timestamp>2025-07-02T20:47:08Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Undo revision [[Special:Diff/3187|3187]] by [[Special:Contributions/85.97.84.231|85.97.84.231]] ([[User talk:85.97.84.231|talk]])</comment>
      <origin>3305</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2484" sha1="sbp1zg3e9i9tulyxpegr4edsfoi5xzy" xml:space="preserve">== ilungelo lokulingana ==
'''Ukulingana''' kulilungelo lawo woke umuntu eSewula Afrika, ilungelo leli liqakathekile ukwakha indawo lapho kungekho khona ukubandlululana ngesibanga sumbala, [[umnotho]] [[ikolo]],ubulili nokhunye&lt;ref&gt;Bolton, P., 2006. Government procurement as a policy tool in South Africa. ''Journal of public procurement'', ''6''(3), pp.193-217.&lt;/ref&gt;. Ukulingana kutjho bona woke umuntu unamalangelo alingananko begodu kufanele athole izinto ngikufana nanbanye kurhulumende

== Imihlobo yokulingana ==

=== Ukulingana ngobuhlobo ===
Kutjhona bona woke umuntu kufanele aphathwe kuhle ngokulingana nabanye abantu ngaphandle kokuthi bacalwe bona babonani begodu babuyaphi

=== Ukulingana ngokomnotho, ===
Kutjhona bona woke umuntu kufuze athole umnotho ngokulingana nabanye begodu athole ilwazi lamathuba njengawo woke umuntu.

=== Ukulingana kwezepolitki, ===
kutjho bona kufanele woke umuntu ongaphezulu kweminyaka ema-18 kufanele athole ithuba lokuzibandakanya nokujanywelwa  ezintweni zepolotiki ezifana nokuvowuda.

=== Ukulingana  ngokobulili ===
lokhu kutjho bona abantu bengubo nebembaji kufanele bathole amathuba alinganako nofana afanako wokubhadelwa, womsebenzi, wekufuda Kanye newepilo

== Iintjhijilo eziphathelene nokulingana ==

=== 1.Ukubandlululana ngokobuhlanga ===
Kwezinye indawo kunzima ukuthola ukulingana ngombana abanye abantu bathanda ukubandlulana ngobuhlanga okukhunye&lt;ref&gt;KC, S.F.F., 2022. ''Discrimination law''. Oxford University Press.&lt;/ref&gt;.

=== 2.Isikhala esikhona phakathi kwabantu abaregileko nabadopha phasi. ===
Isikhala esikhona phakathi kwabantu abaregileko nalabo abadopha phasi singenza bona abantu labo abadobha phasi bangakhoni ukuthi bathole amathuba wokufunda, wezepilo nokunye angafani newalabo abaregileko&lt;ref&gt;Dass, S. and Rinquest, A., 2017. School fees. ''Basic education rights handbook: Education rights in South Africa. Johannesburg, South Africa: SECTION27. Available at &lt;nowiki&gt;http://section27&lt;/nowiki&gt;. org. za/wpcontent/uploads/2017/02''.&lt;/ref&gt;.

=== 3. ukungabi nabajameli ===
Abantu abangakaregi bagcina sele bangabi  nabajameli kwezepolitiki begodu bagcine selel bahlulwa kuthatha iqunto ezemza bona kunciphe ikghono labo  lokujamela amalungelo  nekareko labo. 

Ukulingana lilungelo lawo woke umuntu eewula afrika begodu kufanele bona sisebenzele ukukhuthazenni ukulingana ngokuthi sehlise kubandlulula, nokungalingani kwezomnotho, sikhulise ukujwanyelwa kwabantu. Ngokwenza njalo kuzoba nomkhulu umehluko.</text>
      <sha1>sbp1zg3e9i9tulyxpegr4edsfoi5xzy</sha1>
    </revision>
  </page>
  <page>
    <title>Ukurhuphula</title>
    <ns>0</ns>
    <id>479</id>
    <revision>
      <id>2453</id>
      <timestamp>2025-02-22T20:19:15Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;Ukurhuphula kuyinto yekadeni lapho bekuthatha khona ubulongwe bekomo bese bubhiqwe namanzi ukwenza bona buthambe. Kuthi bungathamba ubulongwe lobu bese buthwelwa phasi bese basinde ngabo. Khuyini ubulongwe Ubulongwe yinto bethuvu bekomo, ekubutjani obuphuma endeninni yekomo batjhiswa yinyongo. Ubulongwe buhlalza ngokubukeka. Abanye abantu ubulongwe bayabuthatha babomise bese babusebenzise njengamalahle babase ngabo umlilo. Bobani abarhuphulako Umsebenzi wokurhuphula wenz...&quot;</comment>
      <origin>2453</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="883" sha1="ivigtnoyxytdsqkowkn7a308nmlvt01" xml:space="preserve">Ukurhuphula kuyinto yekadeni lapho bekuthatha khona ubulongwe bekomo bese bubhiqwe namanzi ukwenza bona buthambe. Kuthi bungathamba ubulongwe lobu bese buthwelwa phasi bese basinde ngabo.
Khuyini ubulongwe
Ubulongwe yinto bethuvu bekomo, ekubutjani obuphuma endeninni yekomo batjhiswa yinyongo. Ubulongwe buhlalza ngokubukeka. Abanye abantu ubulongwe bayabuthatha babomise bese babusebenzise njengamalahle babase ngabo umlilo.
Bobani abarhuphulako
Umsebenzi wokurhuphula wenziwa bomma, nabantazana
Kurhutjhulwa kuphi?
Ekadeni kwabe kurhutjhulwa phasi njengendlela yokuhlwengisa ngendlini ngombana ngaleso skhathi kwabe kungekho izinto ezifana nama thalesi, nefluru.Yeke ukwenzela bona kubutheke beba rhuphula ngobulongwe. Abantazana nalokha nakunequde ngibo abarhuphula irhodlo ukwenzela bona kube kuhle. Emnyanyeni wabantu abamNdebele kuyarhutjhulwa ngaphambi kobana umnyanya uthome</text>
      <sha1>ivigtnoyxytdsqkowkn7a308nmlvt01</sha1>
    </revision>
    <revision>
      <id>2454</id>
      <parentid>2453</parentid>
      <timestamp>2025-02-22T20:21:47Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2454</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="917" sha1="2pm7swq3as2ycm9mj8ey457ad0tt4tk" xml:space="preserve">'''Ukurhuphula''' kuyinto yekadeni lapho bekuthatha khona ubulongwe bekomo bese bubhiqwe namanzi ukwenza bona buthambe. Kuthi bungathamba ubulongwe lobu bese buthwelwa phasi bese basinde ngabo.

== ihlathululo  yobulongwe ==
Ubulongwe yinto bethuvu bekomo, ekubutjani obuphuma endeninni yekomo batjhiswa yinyongo. Ubulongwe buhlalza ngokubukeka. Abanye abantu ubulongwe bayabuthatha babomise bese babusebenzise njengamalahle babase ngabo umlilo.

== Bobani abarhuphulako? ==
Umsebenzi wokurhuphula wenziwa bomma, nabantazana

== Kurhutjhulwa kuphi? ==
Ekadeni kwabe kurhutjhulwa phasi njengendlela yokuhlwengisa ngendlini ngombana ngaleso skhathi kwabe kungekho izinto ezifana nama thalesi, nefluru.Yeke ukwenzela bona kubutheke beba rhuphula ngobulongwe. Abantazana nalokha nakunequde ngibo abarhuphula irhodlo ukwenzela bona kube kuhle. Emnyanyeni wabantu abamNdebele kuyarhutjhulwa ngaphambi kobana umnyanya uthome</text>
      <sha1>2pm7swq3as2ycm9mj8ey457ad0tt4tk</sha1>
    </revision>
    <revision>
      <id>2455</id>
      <parentid>2454</parentid>
      <timestamp>2025-02-22T20:24:03Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2455</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="923" sha1="btec7xz5a5he1vd30c2vpfv9b9tnp7z" xml:space="preserve">'''Ukurhuphula''' kuyinto yekadeni lapho bekuthatha khona ubulongwe bekomo bese bubhiqwe n[[amanzi]] ukwenza bona buthambe. Kuthi bungathamba ubulongwe lobu bese buthwelwa phasi bese basinde ngabo.

== ihlathululo  yobulongwe ==
Ubulongwe yinto bethuvu bekomo, ekubutjani obuphuma endenini yekomo batjhiswa yinyongo. Ubulongwe buhlaza ngokubukeka. Abanye abantu ubulongwe bayabuthatha babomise bese babusebenzise njengamalahle babase ngabo umlilo.

== Bobani abarhuphulako? ==
Umsebenzi wokurhuphula wenziwa bomma, nabantazana

== Kurhutjhulwa kuphi? ==
Ekadeni kwabe kurhutjhulwa phasi njengendlela yokuhlwengisa ngendlini ngombana ngaleso skhathi kwabe kungekho izinto ezifana nama thalesi, nefluru.Yeke ukwenzela bona kubutheke beba rhuphula ngobulongwe. [[Abantazana]] nalokha nakunequde ngibo abarhuphula irhodlo ukwenzela bona kube kuhle. Emnyanyeni wabantu abamNdebele kuyarhutjhulwa ngaphambi kobana umnyanya uthome</text>
      <sha1>btec7xz5a5he1vd30c2vpfv9b9tnp7z</sha1>
    </revision>
  </page>
  <page>
    <title>Amakhetho</title>
    <ns>0</ns>
    <id>480</id>
    <revision>
      <id>2456</id>
      <timestamp>2025-02-22T20:31:03Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot; '''Amakhetho''' kuvowuda kutjho ukuzibandakanya esenzweni sombuso wentando yenengi sokukhetha abadosi phambili, benarha, nofana bomphakathi nofana behlangano.Ukukhetha kulilungelo lawo woke umuntu ohlala enarheni yeSewula Afrika ongaphezulu kweminyaka ema-18. Ilungelo lokukhetha livumela izakhamuzi bona ziveze ukuthi zifuna ukuphathwa njani ngabantu ebabakhethileko&quot;</comment>
      <origin>2456</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="368" sha1="sklsxvk6yj2efkkhu3ptqso7kq7giva" xml:space="preserve"> '''Amakhetho''' kuvowuda kutjho ukuzibandakanya esenzweni sombuso wentando yenengi sokukhetha abadosi phambili, benarha, nofana bomphakathi nofana behlangano.Ukukhetha kulilungelo lawo woke umuntu ohlala enarheni yeSewula Afrika ongaphezulu kweminyaka ema-18. Ilungelo lokukhetha livumela izakhamuzi bona ziveze ukuthi zifuna ukuphathwa njani ngabantu ebabakhethileko</text>
      <sha1>sklsxvk6yj2efkkhu3ptqso7kq7giva</sha1>
    </revision>
    <revision>
      <id>2457</id>
      <parentid>2456</parentid>
      <timestamp>2025-02-22T20:33:35Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2457</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1197" sha1="tdicrasahwp3nx9iwbkosb9takildtu" xml:space="preserve">== Amakhetho ==
'''Amakhetho''' kuvowuda kutjho ukuzibandakanya esenzweni sombuso wentando yenengi sokukhetha abadosi phambili, benarha, nofana bomphakathi nofana behlangano.Ukukhetha kulilungelo lawo woke umuntu ohlala enarheni yeSewula Afrika ongaphezulu kweminyaka ema-18. Ilungelo lokukhetha livumela izakhamuzi bona ziveze ukuthi zifuna ukuphathwa njani ngabantu ebabakhethileko.

Ngamanye amagama ukukhetha kutjho ukuveza umbono wakho kwezepolitiki. Kulithuba lokubumba ikusasa lomphakathi, inarha ngokukhetha abajameli bezepolitiki labo ababelana nawe imbono nofana isithombe esifanako nawe kwezepolitiki.

== Kwenziwani ngaphambi kobana izibandakanye emakhethweni? ==
Ngaphambi kobaa abantu bavowude kuze bona bazitlolisele ukukhetha esititjhini sokuzitlolisa esiseduze nalapho uhlala khona.

Abosopolitiki bayazikhangisa ngokuthi baveze lokho ebazokwenzela abantu nofana inarha lokha nakungaba yiinhlangano zabo ezikhathwako bona zidose phambili nofana kube ngizo ezibusako.

== Inhlangano zepolotiki ezikulu ezikhona eSewula Afrika evane ziphalisane emakhethweni. ==
1. ANC- African National Congress

2. EFF- Economic Freedom Fighters

3. DA- Democratic Alliance

4. MK- Mkhonto Wesizwe</text>
      <sha1>tdicrasahwp3nx9iwbkosb9takildtu</sha1>
    </revision>
    <revision>
      <id>2458</id>
      <parentid>2457</parentid>
      <timestamp>2025-02-22T20:41:58Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2458</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1888" sha1="flzkoqyos2uxdu3aub6mcoqosnuyt3r" xml:space="preserve">== Amakhetho ==
'''Amakhetho''' kuvowuda kutjho ukuzibandakanya esenzweni sombuso wentando yenengi sokukhetha abadosi phambili, benarha, nofana bomphakathi nofana behlangano.Ukukhetha kulilungelo lawo woke umuntu ohlala enarheni yeSewula Afrika ongaphezulu kweminyaka ema-18&lt;ref&gt;Kersting, N., 2009. Voting behaviour in the 2009 South African election. ''Africa Spectrum'', ''44''(2), pp.125-133.&lt;/ref&gt;. Ilungelo lokukhetha livumela izakhamuzi bona ziveze ukuthi zifuna ukuphathwa njani ngabantu ebabakhethileko&lt;ref&gt;De Kadt, D., 2017. Voting then, voting now: The long-term consequences of participation in South Africa’s first democratic election. ''The Journal of Politics'', ''79''(2), pp.670-687.&lt;/ref&gt;.

Ngamanye amagama ukukhetha kutjho ukuveza umbono wakho kwezepolitiki. Kulithuba lokubumba ikusasa lomphakathi, inarha ngokukhetha abajameli bezepolitiki labo ababelana nawe imbono nofana isithombe esifanako nawe kwezepolitiki.

== Kwenziwani ngaphambi kobana izibandakanye emakhethweni? ==
Ngaphambi kobaa abantu bavowude kuze bona bazitlolisele ukukhetha esititjhini sokuzitlolisa esiseduze nalapho uhlala khona.&lt;ref&gt;Schulz-Herzenberg, C., 2020. The South African non-voter: An analysis. ''The Midpoint Paper Series'', (2).&lt;/ref&gt;  abanye basuke bahlulwe kuzibandakanya  emakhathweni ngombana bangakazitlolisi

Abosopolitiki bayazikhangisa ngokuthi baveze lokho ebazokwenzela abantu nofana inarha lokha nakungaba yiinhlangano zabo ezikhathwako bona zidose phambili nofana kube ngizo ezibusako.

== Inhlangano zepolotiki ezikulu ezikhona eSewula Afrika evane ziphalisane emakhethweni. ==
1. ANC- African National Congress

2. EFF- Economic Freedom Fighters

3. DA- Democratic Alliance

4. MK- Mkhonto Wesizwe

== Isiphetho ==
Abantu abatjha kufanele bakhuthazwe ukuthi bazidakanye emakhethweni ngesibanga sokabona lokhu kuzabasiza boan bajanywele babantu labo abazikhethele bona.</text>
      <sha1>flzkoqyos2uxdu3aub6mcoqosnuyt3r</sha1>
    </revision>
    <revision>
      <id>2549</id>
      <parentid>2458</parentid>
      <timestamp>2025-03-19T18:16:18Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2549</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1943" sha1="l0v4ouh4kliqpvf0vjzppkbpb9bkurl" xml:space="preserve">== Amakhetho ==
'''Amakhetho''' kuvowuda kutjho ukuzibandakanya esenzweni sombuso wentando yenengi sokukhetha abadosi phambili, benarha, nofana bomphakathi nofana behlangano.Ukukhetha kulilungelo lawo woke umuntu ohlala enarheni yeSewula Afrika ongaphezulu kweminyaka ema-18&lt;ref&gt;Kersting, N., 2009. Voting behaviour in the 2009 South African election. ''Africa Spectrum'', ''44''(2), pp.125-133.&lt;/ref&gt;.. Ilungelo lokukhetha livumela izakhamuzi bona ziveze ukuthi zifuna ukuphathwa njani ngabantu ebabakhethileko&lt;ref&gt;De Kadt, D., 2017. Voting then, voting now: The long-term consequences of participation in South Africa’s first democratic election. ''The Journal of Politics'', ''79''(2), pp.670-687.&lt;/ref&gt;.[[Umazisi]] uyafuneka lokha nawuya emakhekthweni..

Ngamanye amagama ukukhetha kutjho ukuveza umbono wakho kwezepolitiki. Kulithuba lokubumba ikusasa lomphakathi, [[inarha]] ngokukhetha abajameli bezepolitiki labo ababelana nawe imbono nofana isithombe esifanako nawe kwezepolitiki.

== Kwenziwani ngaphambi kobana izibandakanye emakhethweni? ==
Ngaphambi kobaa abantu bavowude kuze bona bazitlolisele ukukhetha esititjhini sokuzitlolisa esiseduze nalapho uhlala khona.&lt;ref&gt;Schulz-Herzenberg, C., 2020. The South African non-voter: An analysis. ''The Midpoint Paper Series'', (2).&lt;/ref&gt;  abanye basuke bahlulwe kuzibandakanya  emakhathweni ngombana bangakazitlolisi

Abosopolitiki bayazikhangisa ngokuthi baveze lokho ebazokwenzela abantu nofana inarha lokha nakungaba yiinhlangano zabo ezikhathwako bona zidose phambili nofana kube ngizo ezibusako.

== Inhlangano zepolotiki ezikulu ezikhona eSewula Afrika evane ziphalisane emakhethweni. ==
1. ANC- African National Congress

2. EFF- Economic Freedom Fighters

3. DA- Democratic Alliance

4. MK- Mkhonto Wesizwe

== Isiphetho ==
Abantu abatjha kufanele bakhuthazwe ukuthi bazidakanye emakhethweni ngesibanga sokabona lokhu kuzabasiza boan bajanywele babantu labo abazikhethele bona.</text>
      <sha1>l0v4ouh4kliqpvf0vjzppkbpb9bkurl</sha1>
    </revision>
    <revision>
      <id>2823</id>
      <parentid>2549</parentid>
      <timestamp>2025-05-19T10:54:34Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2823</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1933" sha1="3ehn00566tg0wb4xzxn761owmjzu997" xml:space="preserve">== Amakhetho ==
'''Amakhetho,''' kuvowuda kutjho ukuzibandakanya esenzweni sombuso wentando yenengi sokukhetha abadosi phambilibenarha, bomphakathi nofana behlangano. Ukukhetha kulilungelo lawo woke umuntu ohlala enarheni yeSewula Afrika ongaphezulu kweminyaka ema-18&lt;ref&gt;Kersting, N., 2009. Voting behaviour in the 2009 South African election. ''Africa Spectrum'', ''44''(2), pp.125-133.&lt;/ref&gt;. Ilungelo lokukhetha livumela izakhamuzi bona ziveze ukuthi zifuna ukuphathwa njani ngabantu ebabakhethileko&lt;ref&gt;De Kadt, D., 2017. Voting then, voting now: The long-term consequences of participation in South Africa’s first democratic election. ''The Journal of Politics'', ''79''(2), pp.670-687.&lt;/ref&gt;.[[Umazisi]] uyafuneka lokha nawuya emakhethweni.

Ngamanye amagama ukukhetha kutjho ukuveza umbono wakho kwezepolitiki. Kulithuba lokubumba ikusasa lomphakathi, [[inarha]] ngokukhetha abajameli bezepolitiki labo ababelana nawe imbono nofana isithombe esifanako nawe kwezepolitiki.

== Kwenziwani ngaphambi kobana izibandakanye emakhethweni? ==
Ngaphambi kobaa abantu bavowude kuze bona bazitlolisele ukukhetha esititjhini sokuzitlolisa esiseduze nalapho uhlala khona.&lt;ref&gt;Schulz-Herzenberg, C., 2020. The South African non-voter: An analysis. ''The Midpoint Paper Series'', (2).&lt;/ref&gt;  abanye basuke bahlulwe kuzibandakanya  emakhathweni ngombana bangakazitlolisi

Abosopolitiki bayazikhangisa ngokuthi baveze lokho ebazokwenzela abantu nofana inarha lokha nakungaba yiinhlangano zabo ezikhathwako bona zidose phambili nofana kube ngizo ezibusako.

== Inhlangano zepolotiki ezikulu ezikhona eSewula Afrika evane ziphalisane emakhethweni. ==
1. ANC- African National Congress

2. EFF- Economic Freedom Fighters

3. DA- Democratic Alliance

4. MK- Mkhonto Wesizwe

== Isiphetho ==
Abantu abatjha kufanele bakhuthazwe ukuthi bazidakanye emakhethweni ngesibanga sokabona lokhu kuzabasiza boan bajanywele babantu labo abazikhethele bona.</text>
      <sha1>3ehn00566tg0wb4xzxn761owmjzu997</sha1>
    </revision>
    <revision>
      <id>2824</id>
      <parentid>2823</parentid>
      <timestamp>2025-05-19T10:55:46Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2824</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1938" sha1="79tzopf0mxp67vjfpc30t4aculry9g9" xml:space="preserve">== Amakhetho ==
'''Amakhetho,''' kuvowuda kutjho ukuzibandakanya esenzweni sombuso wentando yenengi sokukhetha abadosi phambilibenarha, bomphakathi nofana behlangano. Ukukhetha kulilungelo lawo woke umuntu ohlala enarheni yeSewula Afrika ongaphezulu kweminyaka ema-18&lt;ref&gt;Kersting, N., 2009. Voting behaviour in the 2009 South African election. ''Africa Spectrum'', ''44''(2), pp.125-133.&lt;/ref&gt;. Ilungelo lokukhetha livumela izakhamuzi bona ziveze ukuthi zifuna ukuphathwa njani ngabantu ebabakhethileko&lt;ref&gt;De Kadt, D., 2017. Voting then, voting now: The long-term consequences of participation in South Africa’s first democratic election. ''The Journal of Politics'', ''79''(2), pp.670-687.&lt;/ref&gt;.[[Umazisi]] uyafuneka lokha nawuya emakhethweni.

Ngamanye amagama ukukhetha kutjho ukuveza umbono wakho kwezepolitiki. Kulithuba lokubumba ikusasa lomphakathi, [[inarha]] ngokukhetha abajameli bezepolitiki labo ababelana nawe imbono nofana isithombe esifanako nawe kwezepolitiki.

== Kwenziwani ngaphambi kobana izibandakanye emakhethweni? ==
Ngaphambi kobana abantu bavowude kufuze bona bazitlolisele ukukhetha esititjhini sokuzitlolisa esiseduze nalapho bahlala khona.&lt;ref&gt;Schulz-Herzenberg, C., 2020. The South African non-voter: An analysis. ''The Midpoint Paper Series'', (2).&lt;/ref&gt;  abanye basuke bahlulwe kuzibandakanya  emakhathweni ngombana bangakazitlolisi.

Abosopolitiki bayazikhangisa ngokuthi baveze lokho ebazokwenzela abantu nofana inarha lokha nakungaba yiinhlangano zabo ezikhathwako bona zidose phambili nofana kube ngizo ezibusako.

== Inhlangano zepolotiki ezikulu ezikhona eSewula Afrika evane ziphalisane emakhethweni. ==
1. ANC- African National Congress

2. EFF- Economic Freedom Fighters

3. DA- Democratic Alliance

4. MK- Mkhonto Wesizwe

== Isiphetho ==
Abantu abatjha kufanele bakhuthazwe ukuthi bazidakanye emakhethweni ngesibanga sokabona lokhu kuzabasiza boan bajanywele babantu labo abazikhethele bona.</text>
      <sha1>79tzopf0mxp67vjfpc30t4aculry9g9</sha1>
    </revision>
    <revision>
      <id>2936</id>
      <parentid>2824</parentid>
      <timestamp>2025-06-06T17:15:55Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>Hot dog</comment>
      <origin>2936</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3253" sha1="9dmmaqo8bcyldidxycy2hdk01bv2ojb" xml:space="preserve">upon the most peculiar and oft-overlooked phenomenon known within the parlance of the commoner as the '''hot dog''', though such nomenclature belies its manifold complexities. Permit me to articulate, in a style most befitting the genteel salons of our fair Britannia in this, the resplendent 19th century, the manifold dynamics of this tubular culinary oddity.
----'''A Treatise Upon the Thermo-Gustatory and Socio-Cylindrical Interactions of the Encased Meatic Delicacy Commonly Referred to as the &quot;Hot Dog&quot;'''

In the burgeoning epoch of steam and empire, wherein dirigibles graze the heavens and gentlemen discourse upon phlogiston and Darwinian descent over tea and crumpets, there exists a most singular comestible of transatlantic origin—nay, a gastronomic chimera—comprised principally of a homogenised, emulsified amalgamation of porcine and/or bovine flesh, ensconced within a phallic sheath of artificially reconstituted intestinal membrane.

Said ''viand'', once subjected to the transformative rigours of thermal agitation—most commonly through immersion in boiling aqueous solution or searing upon a heated iron griddle—undergoes a process of protein denaturation and lipidic exudation, thereby achieving a state of both succulence and structural integrity most palatable to the human gustatory apparatus.

The resultant ''sausage'', glistening in its post-coital sheen of oil and steam, is thenceforth nestled within a bifurcated, leavened bread vessel—oft referred to as a &quot;bun,&quot; though the term lacks appropriate gravity. Said bread, whose yeasty effervescence recalls the rustic charm of a Yorkshire bakehouse, serves not merely as a conveyance, but as a textural counterpoint, a spongiform cradle that tempers the olfactory violence of the seasoned tube-meat within.

Upon the summit of this cylindrical banquet, the diner—whose tastes may range from the sublime to the absurd—may elect to append a medley of condimentary effluvia: mustard, that Gallic yellow ichor; ketchup, the tomatoic blood of the New World; onions, both raw and caramelised to the consistency of Dickensian sorrow; and the abhorrent green pickle relish, whose inclusion I dare say marks the eater as a colonial deviant of the highest order.

Now, consider if you will the '''dynamic interaction''': the bite, a momentary rupture in the temporal continuum, wherein teeth cleave through crust and casing alike, causing a micro-explosion of savoury juices to erupt forth with all the vigour of a Crimean cannonade. The mastication thereafter resembles the complex mechanical operations of Brunel's Great Eastern—gears and pistons working in synchrony to reduce the noble dog to a bolus fit for deglutition.

To consume a hot dog, dear reader, is to engage in a ritualistic theatre of meat and bread, to partake in the democratic ingestion of proletarian delight, wrapped in the trappings of modern industrialism and American excess. It is, in short, an edible metaphor for the contradictions of our age: refinement and vulgarity, steam and grease, bun and beast—all rendered in a single, hand-held cylinder.
----I remain, as ever,

Your most obedient servant and humble explicator of gustatory enigmas,

'''Chatboticus G. P. Thourghbottom, Esq.'''</text>
      <sha1>9dmmaqo8bcyldidxycy2hdk01bv2ojb</sha1>
    </revision>
    <revision>
      <id>3097</id>
      <parentid>2936</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Nqobile69|Nqobile69]]</comment>
      <origin>2824</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1938" sha1="79tzopf0mxp67vjfpc30t4aculry9g9" xml:space="preserve">== Amakhetho ==
'''Amakhetho,''' kuvowuda kutjho ukuzibandakanya esenzweni sombuso wentando yenengi sokukhetha abadosi phambilibenarha, bomphakathi nofana behlangano. Ukukhetha kulilungelo lawo woke umuntu ohlala enarheni yeSewula Afrika ongaphezulu kweminyaka ema-18&lt;ref&gt;Kersting, N., 2009. Voting behaviour in the 2009 South African election. ''Africa Spectrum'', ''44''(2), pp.125-133.&lt;/ref&gt;. Ilungelo lokukhetha livumela izakhamuzi bona ziveze ukuthi zifuna ukuphathwa njani ngabantu ebabakhethileko&lt;ref&gt;De Kadt, D., 2017. Voting then, voting now: The long-term consequences of participation in South Africa’s first democratic election. ''The Journal of Politics'', ''79''(2), pp.670-687.&lt;/ref&gt;.[[Umazisi]] uyafuneka lokha nawuya emakhethweni.

Ngamanye amagama ukukhetha kutjho ukuveza umbono wakho kwezepolitiki. Kulithuba lokubumba ikusasa lomphakathi, [[inarha]] ngokukhetha abajameli bezepolitiki labo ababelana nawe imbono nofana isithombe esifanako nawe kwezepolitiki.

== Kwenziwani ngaphambi kobana izibandakanye emakhethweni? ==
Ngaphambi kobana abantu bavowude kufuze bona bazitlolisele ukukhetha esititjhini sokuzitlolisa esiseduze nalapho bahlala khona.&lt;ref&gt;Schulz-Herzenberg, C., 2020. The South African non-voter: An analysis. ''The Midpoint Paper Series'', (2).&lt;/ref&gt;  abanye basuke bahlulwe kuzibandakanya  emakhathweni ngombana bangakazitlolisi.

Abosopolitiki bayazikhangisa ngokuthi baveze lokho ebazokwenzela abantu nofana inarha lokha nakungaba yiinhlangano zabo ezikhathwako bona zidose phambili nofana kube ngizo ezibusako.

== Inhlangano zepolotiki ezikulu ezikhona eSewula Afrika evane ziphalisane emakhethweni. ==
1. ANC- African National Congress

2. EFF- Economic Freedom Fighters

3. DA- Democratic Alliance

4. MK- Mkhonto Wesizwe

== Isiphetho ==
Abantu abatjha kufanele bakhuthazwe ukuthi bazidakanye emakhethweni ngesibanga sokabona lokhu kuzabasiza boan bajanywele babantu labo abazikhethele bona.</text>
      <sha1>79tzopf0mxp67vjfpc30t4aculry9g9</sha1>
    </revision>
    <revision>
      <id>3406</id>
      <parentid>3097</parentid>
      <timestamp>2025-07-12T13:17:06Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <comment>changes heading to subheadings</comment>
      <origin>3406</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1926" sha1="76o83u6yh2xjpadkqdfq7ntgblvk2zj" xml:space="preserve">'''Amakhetho,''' kuvowuda kutjho ukuzibandakanya esenzweni sombuso wentando yenengi sokukhetha abadosi phambilibenarha, bomphakathi nofana behlangano. Ukukhetha kulilungelo lawo woke umuntu ohlala enarheni yeSewula Afrika ongaphezulu kweminyaka ema-18&lt;ref&gt;Kersting, N., 2009. Voting behaviour in the 2009 South African election. ''Africa Spectrum'', ''44''(2), pp.125-133.&lt;/ref&gt;. Ilungelo lokukhetha livumela izakhamuzi bona ziveze ukuthi zifuna ukuphathwa njani ngabantu ebabakhethileko&lt;ref&gt;De Kadt, D., 2017. Voting then, voting now: The long-term consequences of participation in South Africa’s first democratic election. ''The Journal of Politics'', ''79''(2), pp.670-687.&lt;/ref&gt;.[[Umazisi]] uyafuneka lokha nawuya emakhethweni.

Ngamanye amagama ukukhetha kutjho ukuveza umbono wakho kwezepolitiki. Kulithuba lokubumba ikusasa lomphakathi, [[inarha]] ngokukhetha abajameli bezepolitiki labo ababelana nawe imbono nofana isithombe esifanako nawe kwezepolitiki.

=== Kwenziwani ngaphambi kobana izibandakanye emakhethweni? ===
Ngaphambi kobana abantu bavowude kufuze bona bazitlolisele ukukhetha esititjhini sokuzitlolisa esiseduze nalapho bahlala khona.&lt;ref&gt;Schulz-Herzenberg, C., 2020. The South African non-voter: An analysis. ''The Midpoint Paper Series'', (2).&lt;/ref&gt;  abanye basuke bahlulwe kuzibandakanya  emakhathweni ngombana bangakazitlolisi.

Abosopolitiki bayazikhangisa ngokuthi baveze lokho ebazokwenzela abantu nofana inarha lokha nakungaba yiinhlangano zabo ezikhathwako bona zidose phambili nofana kube ngizo ezibusako.

=== Inhlangano zepolotiki ezikulu ezikhona eSewula Afrika evane ziphalisane emakhethweni. ===
1. ANC- African National Congress

2. EFF- Economic Freedom Fighters

3. DA- Democratic Alliance

4. MK- Mkhonto Wesizwe

Abantu abatjha kufanele bakhuthazwe ukuthi bazidakanye emakhethweni ngesibanga sokabona lokhu kuzabasiza boan bajanywele babantu labo abazikhethele bona.

== Iinkomba ==</text>
      <sha1>76o83u6yh2xjpadkqdfq7ntgblvk2zj</sha1>
    </revision>
    <revision>
      <id>3407</id>
      <parentid>3406</parentid>
      <timestamp>2025-07-12T13:21:30Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3407</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2028" sha1="r4cingw7nu0lfp2p309lcmm2479u14q" xml:space="preserve">'''Amakhetho,''' kuvowuda kutjho ukuzibandakanya esenzweni sombuso wentando yenengi sokukhetha abadosi phambilibenarha, bomphakathi nofana behlangano. Ukukhetha kulilungelo lawo woke umuntu ohlala enarheni yeSewula Afrika ongaphezulu kweminyaka ema-18.&lt;ref&gt;Kersting, N., 2009. Voting behaviour in the 2009 South African election. ''Africa Spectrum'', ''44''(2), pp.125-133.&lt;/ref&gt; Ilungelo lokukhetha livumela izakhamuzi bona ziveze ukuthi zifuna ukuphathwa njani ngabantu ebabakhethileko.&lt;ref&gt;De Kadt, D., 2017. Voting then, voting now: The long-term consequences of participation in South Africa’s first democratic election. ''The Journal of Politics'', ''79''(2), pp.670-687.&lt;/ref&gt;[[Umazisi]] uyafuneka lokha nawuya emakhethweni ukuqinisekisa bonya umuntu loyo unalo ngokweqiniso ilungelo lokukhetha ihlangano afuna bona ibuse inarha.Ngamanye amagama ukukhetha kutjho ukuveza umbono wakho kwezepolitiki. Kulithuba lokubumba ikusasa lomphakathi, [[inarha]] ngokukhetha abajameli bezepolitiki labo ababelana nawe imbono nofana isithombe esifanako nawe kwezepolitiki.

=== Kwenziwani ngaphambi kobana izibandakanye emakhethweni? ===
Ngaphambi kobana abantu bavowude kufuze bona bazitlolisele ukukhetha esititjhini sokuzitlolisa esiseduze nalapho bahlala khona.&lt;ref&gt;Schulz-Herzenberg, C., 2020. The South African non-voter: An analysis. ''The Midpoint Paper Series'', (2).&lt;/ref&gt;  abanye basuke bahlulwe kuzibandakanya  emakhathweni ngombana bangakazitlolisi. Abosopolitiki bayazikhangisa ngokuthi baveze lokho ebazokwenzela abantu nofana inarha lokha nakungaba yiinhlangano zabo ezikhathwako bona zidose phambili nofana kube ngizo ezibusako.

=== Inhlangano zepolotiki ezikulu ezikhona eSewula Afrika evane ziphalisane emakhethweni. ===
1. ANC- African National Congress

2. EFF- Economic Freedom Fighters

3. DA- Democratic Alliance

4. MK- Mkhonto Wesizwe

Abantu abatjha kufanele bakhuthazwe ukuthi bazidakanye emakhethweni ngesibanga sokabona lokhu kuzabasiza boan bajanywele babantu labo abazikhethele bona.

== Iinkomba ==</text>
      <sha1>r4cingw7nu0lfp2p309lcmm2479u14q</sha1>
    </revision>
    <revision>
      <id>3408</id>
      <parentid>3407</parentid>
      <timestamp>2025-07-12T13:23:32Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3408</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2162" sha1="owdik8jq6jaxs4rtbus5bvlr4u9r5uk" xml:space="preserve">'''Amakhetho,''' kuvowuda kutjho ukuzibandakanya esenzweni sombuso wentando yenengi sokukhetha abadosi phambilibenarha, bomphakathi nofana behlangano. Ukukhetha kulilungelo lawo woke umuntu ohlala enarheni yeSewula Afrika ongaphezulu kweminyaka ema-18.&lt;ref&gt;Kersting, N., 2009. Voting behaviour in the 2009 South African election. ''Africa Spectrum'', ''44''(2), pp.125-133.&lt;/ref&gt; Ilungelo lokukhetha livumela izakhamuzi bona ziveze ukuthi zifuna ukuphathwa njani ngabantu ebabakhethileko.&lt;ref&gt;De Kadt, D., 2017. Voting then, voting now: The long-term consequences of participation in South Africa’s first democratic election. ''The Journal of Politics'', ''79''(2), pp.670-687.&lt;/ref&gt;[[Umazisi]] uyafuneka lokha nawuya emakhethweni ukuqinisekisa bonya umuntu loyo unalo ngokweqiniso ilungelo lokukhetha ihlangano afuna bona ibuse inarha. Ngamanye amagama ukukhetha kutjho ukuveza umbono wakho kwezepolitiki. Kulithuba lokubumba ikusasa lomphakathi, [[inarha]] ngokukhetha abajameli bezepolitiki labo ababelana nawe imbono nofana isithombe esifanako nawe kwezepolitiki.

=== Kwenziwani ngaphambi kobana izibandakanye emakhethweni? ===
Ngaphambi kobana abantu bavowude kufuze bona bazitlolisele ukukhetha esititjhini sokuzitlolisa esiseduze nalapho bahlala khona.&lt;ref&gt;Schulz-Herzenberg, C., 2020. The South African non-voter: An analysis. ''The Midpoint Paper Series'', (2).&lt;/ref&gt;  abanye basuke bahlulwe kuzibandakanya  emakhathweni ngombana bangakazitlolisi. Abosopolitiki bayazikhangisa ngokuthi baveze lokho ebazokwenzela abantu nofana inarha lokha nakungaba yiinhlangano zabo ezikhethwako bona zidose phambili nofana kube ngizo ezibusako. Abanye abosopolitiki bayakhamba bayokuvakatjhela iindawo ukukhuthaza abantu abahlala endaweni lezo bona bazibandakanye emakhethweni.

=== Inhlangano zepolotiki ezikulu ezikhona eSewula Afrika evane ziphalisane emakhethweni. ===
1. ANC- African National Congress

2. EFF- Economic Freedom Fighters

3. DA- Democratic Alliance

4. MK- Mkhonto Wesizwe

Abantu abatjha kufanele bakhuthazwe ukuthi bazidakanye emakhethweni ngesibanga sokabona lokhu kuzabasiza boan bajanywele babantu labo abazikhethele bona.

== Iinkomba ==</text>
      <sha1>owdik8jq6jaxs4rtbus5bvlr4u9r5uk</sha1>
    </revision>
  </page>
  <page>
    <title>UMQONDOPHIKA NO MQONDOFANA</title>
    <ns>0</ns>
    <id>481</id>
    <revision>
      <id>2459</id>
      <timestamp>2025-02-22T20:45:42Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Umqondophika == '''Umqondophika''' kulokha nawuphikisana nento. Amagama amqondo phika asetjenzisa lokha nawuveza umehluko phakathi kwezinto ezimbili. Nawufaka igama elimqondo phika nelinye  emutjhweni, umutjho loyo uzokutjhuguluka utjho into ephikisa leyo ebeyikhuluma ekuthomeni&quot;</comment>
      <origin>2459</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="282" sha1="13dgbg55iakrj7cwdqqsm7lv6yf7jd5" xml:space="preserve">== Umqondophika ==
'''Umqondophika''' kulokha nawuphikisana nento. Amagama amqondo phika asetjenzisa lokha nawuveza umehluko phakathi kwezinto ezimbili. Nawufaka igama elimqondo phika nelinye  emutjhweni, umutjho loyo uzokutjhuguluka utjho into ephikisa leyo ebeyikhuluma ekuthomeni</text>
      <sha1>13dgbg55iakrj7cwdqqsm7lv6yf7jd5</sha1>
    </revision>
    <revision>
      <id>2460</id>
      <parentid>2459</parentid>
      <timestamp>2025-02-22T20:51:08Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2460</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1163" sha1="irerni3v0do6x2lorpi8p6mfw4hclv2" xml:space="preserve">== Umqondophika ==
'''Umqondophika''' kulokha nawuphikisana nento. Amagama amqondo phika asetjenzisa lokha nawuveza umehluko phakathi kwezinto ezimbili. Nawufaka igama elimqondo phika nelinye  emutjhweni, umutjho loyo uzokutjhuguluka utjho into ephikisa leyo ebeyikhuluma ekuthomeni

=== '''Iimbonelo''' ===
Lala-vuka

Khamba-jama

Isikhukhukazi-umqude

Ifa-phila

Hlala-sukuma

Hleka-lila

Khwela-Hlika

Vala- vula

Phezulu – phasi

Thanda- zonda

== Umqondofana ==
Umqondofana kulokha nawubiza into ngelinye igama. Kumagama ahlukileko ngokubhalawa kodwana atjho into yinye nofana efanako ngokwehlathululo. Amagama la kutjho bona ungafaka elinye endaweni yelinye emutjhweni bese umutjho ugalahlekelwa ngilokho okutjhoko.&lt;ref&gt;Gay, E., Ma, S. and Yadi, K.B., 2022. Evaluating Vocabulary Proficiency: A Synonym and Antonym Analysis of English Education Department Students at Muhammadiyah University of North Maluku. ''EDU Journal-English Department of UMMU Journal'', ''2''(2), pp.81-90.&lt;/ref&gt;

=== '''Iimbonelo''' ===
Umnyango-umbadi.

Indlela-yipati.

Umseme-umjadeko.

Amehlo-amandiya.

Inja-umgodoyi.

Isihlahla- umuthi

Amanzi- Amawethe

Uburotho- umgadango</text>
      <sha1>irerni3v0do6x2lorpi8p6mfw4hclv2</sha1>
    </revision>
    <revision>
      <id>2461</id>
      <parentid>2460</parentid>
      <timestamp>2025-02-22T20:52:22Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2461</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1437" sha1="c3vdqhcaktrj6xo9j0n7jolt8e66w59" xml:space="preserve">== Umqondophika ==
'''Umqondophika''' kulokha nawuphikisana nento. Amagama amqondo phika asetjenzisa lokha nawuveza umehluko phakathi kwezinto ezimbili. Nawufaka igama elimqondo phika nelinye  emutjhweni, umutjho loyo uzokutjhuguluka utjho into ephikisa leyo ebeyikhuluma ekuthomeni&lt;ref&gt;Scheible, S., Im Walde, S.S. and Springorum, S., 2013, October. Uncovering distributional differences between synonyms and antonyms in a word space model. In ''Proceedings of the Sixth International Joint Conference on Natural Language Processing'' (pp. 489-497).&lt;/ref&gt;

=== '''Iimbonelo''' ===
Lala-vuka

Khamba-jama

Isikhukhukazi-umqude

Ifa-phila

Hlala-sukuma

Hleka-lila

Khwela-Hlika

Vala- vula

Phezulu – phasi

Thanda- zonda

== Umqondofana ==
Umqondofana kulokha nawubiza into ngelinye igama. Kumagama ahlukileko ngokubhalawa kodwana atjho into yinye nofana efanako ngokwehlathululo. Amagama la kutjho bona ungafaka elinye endaweni yelinye emutjhweni bese umutjho ugalahlekelwa ngilokho okutjhoko.&lt;ref&gt;Gay, E., Ma, S. and Yadi, K.B., 2022. Evaluating Vocabulary Proficiency: A Synonym and Antonym Analysis of English Education Department Students at Muhammadiyah University of North Maluku. ''EDU Journal-English Department of UMMU Journal'', ''2''(2), pp.81-90.&lt;/ref&gt;

=== '''Iimbonelo''' ===
Umnyango-umbadi.

Indlela-yipati.

Umseme-umjadeko.

Amehlo-amandiya.

Inja-umgodoyi.

Isihlahla- umuthi

Amanzi- Amawethe

Uburotho- umgadango</text>
      <sha1>c3vdqhcaktrj6xo9j0n7jolt8e66w59</sha1>
    </revision>
    <revision>
      <id>2976</id>
      <parentid>2461</parentid>
      <timestamp>2025-06-06T20:04:29Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>szexrdcfgbhjtfcdxrszexdfg vbnhgcfdrx</comment>
      <origin>2976</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1525" sha1="1c4l5uctmts1dwgytkqf14hjjbgaut8" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.'''

== Umqondophika ==
'''Umqondophika''' kulokha nawuphikisana nento. Amagama amqondo phika asetjenzisa lokha nawuveza umehluko phakathi kwezinto ezimbili. Nawufaka igama elimqondo phika nelinye  emutjhweni, umutjho loyo uzokutjhuguluka utjho into ephikisa leyo ebeyikhuluma ekuthomeni&lt;ref&gt;Scheible, S., Im Walde, S.S. and Springorum, S., 2013, October. Uncovering distributional differences between synonyms and antonyms in a word space model. In ''Proceedings of the Sixth International Joint Conference on Natural Language Processing'' (pp. 489-497).&lt;/ref&gt;

=== '''Iimbonelo''' ===
Lala-vuka

Khamba-jama

Isikhukhukazi-umqude

Ifa-phila

Hlala-sukuma

Hleka-lila

Khwela-Hlika

Vala- vula

Phezulu – phasi

Thanda- zonda

== Umqondofana ==
Umqondofana kulokha nawubiza into ngelinye igama. Kumagama ahlukileko ngokubhalawa kodwana atjho into yinye nofana efanako ngokwehlathululo. Amagama la kutjho bona ungafaka elinye endaweni yelinye emutjhweni bese umutjho ugalahlekelwa ngilokho okutjhoko.&lt;ref&gt;Gay, E., Ma, S. and Yadi, K.B., 2022. Evaluating Vocabulary Proficiency: A Synonym and Antonym Analysis of English Education Department Students at Muhammadiyah University of North Maluku. ''EDU Journal-English Department of UMMU Journal'', ''2''(2), pp.81-90.&lt;/ref&gt;

=== '''Iimbonelo''' ===
Umnyango-umbadi.

Indlela-yipati.

Umseme-umjadeko.

Amehlo-amandiya.

Inja-umgodoyi.

Isihlahla- umuthi

Amanzi- Amawethe

Uburotho- umgadango</text>
      <sha1>1c4l5uctmts1dwgytkqf14hjjbgaut8</sha1>
    </revision>
    <revision>
      <id>3085</id>
      <parentid>2976</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Nqobile69|Nqobile69]]</comment>
      <origin>2461</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1437" sha1="c3vdqhcaktrj6xo9j0n7jolt8e66w59" xml:space="preserve">== Umqondophika ==
'''Umqondophika''' kulokha nawuphikisana nento. Amagama amqondo phika asetjenzisa lokha nawuveza umehluko phakathi kwezinto ezimbili. Nawufaka igama elimqondo phika nelinye  emutjhweni, umutjho loyo uzokutjhuguluka utjho into ephikisa leyo ebeyikhuluma ekuthomeni&lt;ref&gt;Scheible, S., Im Walde, S.S. and Springorum, S., 2013, October. Uncovering distributional differences between synonyms and antonyms in a word space model. In ''Proceedings of the Sixth International Joint Conference on Natural Language Processing'' (pp. 489-497).&lt;/ref&gt;

=== '''Iimbonelo''' ===
Lala-vuka

Khamba-jama

Isikhukhukazi-umqude

Ifa-phila

Hlala-sukuma

Hleka-lila

Khwela-Hlika

Vala- vula

Phezulu – phasi

Thanda- zonda

== Umqondofana ==
Umqondofana kulokha nawubiza into ngelinye igama. Kumagama ahlukileko ngokubhalawa kodwana atjho into yinye nofana efanako ngokwehlathululo. Amagama la kutjho bona ungafaka elinye endaweni yelinye emutjhweni bese umutjho ugalahlekelwa ngilokho okutjhoko.&lt;ref&gt;Gay, E., Ma, S. and Yadi, K.B., 2022. Evaluating Vocabulary Proficiency: A Synonym and Antonym Analysis of English Education Department Students at Muhammadiyah University of North Maluku. ''EDU Journal-English Department of UMMU Journal'', ''2''(2), pp.81-90.&lt;/ref&gt;

=== '''Iimbonelo''' ===
Umnyango-umbadi.

Indlela-yipati.

Umseme-umjadeko.

Amehlo-amandiya.

Inja-umgodoyi.

Isihlahla- umuthi

Amanzi- Amawethe

Uburotho- umgadango</text>
      <sha1>c3vdqhcaktrj6xo9j0n7jolt8e66w59</sha1>
    </revision>
  </page>
  <page>
    <title>Itregere</title>
    <ns>0</ns>
    <id>482</id>
    <revision>
      <id>2466</id>
      <timestamp>2025-02-26T08:54:53Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;Itregere '''Itregere''' Kusithuthu esimtjhini  esibonkala ngamavilo amabili makhulu nomzimbaa omncani ngombana ikhwenza umuntu munye ekunguye otjhayelako. Isithuthu lesi sisetjenziswa kwezokulima, ngombana sithuthukisa  imisebenzi yabalimi, ikhuphula izinga lomsebenzi ebawenzako ngelanga nelenzuzo  yabo. Itregere ilekelela abalimi bona bona bacede msinya imisebenzi yabo ukdlula lokha nabasenzisa izandla nofana iinlwana. Isibonelo itregere ikghona ikupeta  iplasi gama iri...&quot;</comment>
      <origin>2466</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1907" sha1="isnep0k95qy4knf94cub3tsedtjl686" xml:space="preserve">Itregere
'''Itregere''' Kusithuthu esimtjhini  esibonkala ngamavilo amabili makhulu nomzimbaa omncani ngombana ikhwenza umuntu munye ekunguye otjhayelako. Isithuthu lesi sisetjenziswa kwezokulima, ngombana sithuthukisa  imisebenzi yabalimi, ikhuphula izinga lomsebenzi ebawenzako ngelanga nelenzuzo  yabo.
Itregere ilekelela abalimi bona bona bacede msinya imisebenzi yabo ukdlula lokha nabasenzisa izandla nofana iinlwana. Isibonelo itregere ikghona ikupeta  iplasi gama iri amancani ekubeni abantu bangathatha amalakga ukwenza umsebenzi lo owenziwa yitregere.
 Inzuzo enengi
Amatregere alekelela abasomplsi nofana abalimi bona babe nesivuno esinengi kwezokulima ngomba  itregere ikghon ukwenza umsebenzi eminengi efana nokupeta , ukutjala, nokuvuna. Lokhu kutjh bona abalimi  nabasebenzisa itregere bangakghona ukuthola isivuno isinengi ngeksikhathi esincani. Lokhu kusidosela ekutheni kube nokudla  okunengi ekuyinto ehle ngombana kuba lula ukondla isitjhaba sabantu abakhona ephasini.
Ukwehlisa izinga leendleko zemali emaplasini
Amatregere alakelela abalimi bona behlise indleko babulunge imali ngombana lokha navane une tregere akufuneki inani eliphezulu labantu abazokusebenza eplasini kunalokha unganayo itregere. Abalimi nabasenzisa itregere bakghona ukusebenza esikhundleni  esikhulu ngesikhathi esincaniokutjho bona bazokhona ukukhipha Ukudla okunengi benze nenzuzo enengi.
Iphatha kuhle ibhoduluko
Itregere iphatha kulhe ibhoduloko ngombana ayisebenzisi isibaseli esinengi lokho nabayisebenzisako begodu lawa enziwe esikhathi sanje awakhphi intuthu  enengi okutjho bona  awasilaphsi umoya khulu
Isiphetho
Itregere iqakathekile kwezokulima begodu kuyinto eltha itjhuguloko kwezokulima begodu kuyinto eletha itjhuguluko  kwezokulima ngombana ilekelela abalimi bona bangabi neendleko ezinengi begodu bakghone ukwenz aumsebenzi omkhulu ngesikhathi esincani. Kuyinto ehle bona abosamaplasi babe nayo.</text>
      <sha1>isnep0k95qy4knf94cub3tsedtjl686</sha1>
    </revision>
    <revision>
      <id>2467</id>
      <parentid>2466</parentid>
      <timestamp>2025-02-26T09:13:58Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2467</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2775" sha1="k6a4sfe1cw9yg1rr6npz45i56t3v8wh" xml:space="preserve">== Itregere ==
'''Itregere''' Kusithuthu esimtjhini  esibonkala ngamavilo amabili makhulu nomzimbaa omncani ngombana ikhwenza umuntu munye ekunguye otjhayelako. Isithuthu lesi sisetjenziswa kwezokulima, ngombana sithuthukisa  imisebenzi yabalimi, ikhuphula izinga lomsebenzi ebawenzako ngelanga nelenzuzo  yabo.Itregere ilekelela abalimi bona bona bacede msinya imisebenzi yabo ukudlula lokha nabasenzisa izandla nofana iinlwana. Isibonelo itregere ikghona ikupeta  iplasi gama iri amancani ekubeni abantu bangathatha amalakga ukwenza umsebenzi lo owenziwa yitregere&lt;ref&gt;Renius, K.T., 2020. ''Fundamentals of tractor design'' (pp. 32-35). Cham, Switzerland: Springer.&lt;/ref&gt;.

== Umsebenzi wetregere ==
Amatregere alekelela abasomplasi nofana abalimi bona babe nesivuno esinengi kwezokulima ngomba  itregere ikghon ukwenza umsebenzi eminengi efana nokupeta , ukutjala, nokuvuna. Lokhu kutjh bona abalimi  nabasebenzisa itregere bangakghona ukuthola isivuno isinengi ngeksikhathi esincani. Lokhu kusidosela ekutheni kube nokudla  okunengi ekuyinto ehle ngombana kuba lula ukondla isitjhaba sabantu abakhona ephasini&lt;ref&gt;Vorozhtsov, O.V., Plaksin, I.E. and Trifanov, A.V., 2022, February. The use of small-sized tractors in agriculture. In ''IOP Conference Series: Earth and Environmental Science'' (Vol. 979, No. 1, p. 012034). IOP Publishing.&lt;/ref&gt;

=== Ukwehlisa izinga leendleko zemali emaplasini ===
Amatregere alakelela abalimi bona behlise indleko babulunge imali ngombana lokha navane une tregere akufuneki inani eliphezulu labantu abazokusebenza eplasini kunalokha unganayo itregere. Abalimi nabasenzisa itregere bakghona ukusebenza esikhundleni  esikhulu ngesikhathi esincani okutjho bona bazokhona ukukhipha Ukudla okunengi benze nenzuzo enengi&lt;ref&gt;Vorozhtsov, O.V., Plaksin, I.E. and Trifanov, A.V., 2022, February. The use of small-sized tractors in agriculture. In ''IOP Conference Series: Earth and Environmental Science'' (Vol. 979, No. 1, p. 012034). IOP Publishing.&lt;/ref&gt;.

=== Iphatha kuhle ibhoduluko ===
Itregere iphatha kulhe ibhoduloko ngombana ayisebenzisi isibaseli esinengi lokho nabayisebenzisako begodu lawa enziwe esikhathi sanje awakhiphi intuthu  enengi okutjho bona  awasilaphsi umoya khulu&lt;ref&gt;Lee, J.W., Kim, S.C., Oh, J., Chung, W.J., Han, H.W., Kim, J.T. and Park, Y.J., 2019. Engine speed control system for improving the fuel efficiency of agricultural tractors for plowing operations. ''Applied Sciences'', ''9''(18), p.3898.&lt;/ref&gt;

== Isiphetho ==
Itregere iqakathekile kwezokulima begodu kuyinto eltha itjhuguloko kwezokulima begodu kuyinto eletha itjhuguluko  kwezokulima ngombana ilekelela abalimi bona bangabi neendleko ezinengi begodu bakghone ukwenz aumsebenzi omkhulu ngesikhathi esincani. Kuyinto ehle bona abosamaplasi babe nayo.</text>
      <sha1>k6a4sfe1cw9yg1rr6npz45i56t3v8wh</sha1>
    </revision>
    <revision>
      <id>2473</id>
      <parentid>2467</parentid>
      <timestamp>2025-02-28T20:00:52Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2473</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2923" sha1="h29hnf065iuu4tsydf63u8a2wifo4yz" xml:space="preserve">[[Isimumathi:Itregere esetjenziswa emaplasini.jpg|thumb|Itregere esetjenziswa emaplasini ukuthutha izinto ezibudisi, ukutjala, ukulima nokuvuna.]]

== Itregere ==
'''Itregere''' Kusithuthu esimtjhini  esibonkala ngamavilo amabili makhulu nomzimbaa omncani ngombana ikhwenza umuntu munye ekunguye otjhayelako. Isithuthu lesi sisetjenziswa kwezokulima, ngombana sithuthukisa  imisebenzi yabalimi, ikhuphula izinga lomsebenzi ebawenzako ngelanga nelenzuzo  yabo.Itregere ilekelela abalimi bona bona bacede msinya imisebenzi yabo ukudlula lokha nabasenzisa izandla nofana iinlwana. Isibonelo itregere ikghona ikupeta  iplasi gama iri amancani ekubeni abantu bangathatha amalakga ukwenza umsebenzi lo owenziwa yitregere&lt;ref&gt;Renius, K.T., 2020. ''Fundamentals of tractor design'' (pp. 32-35). Cham, Switzerland: Springer.&lt;/ref&gt;.

== Umsebenzi wetregere ==
Amatregere alekelela abasomplasi nofana abalimi bona babe nesivuno esinengi kwezokulima ngomba  itregere ikghon ukwenza umsebenzi eminengi efana nokupeta , ukutjala, nokuvuna. Lokhu kutjh bona abalimi  nabasebenzisa itregere bangakghona ukuthola isivuno isinengi ngeksikhathi esincani. Lokhu kusidosela ekutheni kube nokudla  okunengi ekuyinto ehle ngombana kuba lula ukondla isitjhaba sabantu abakhona ephasini&lt;ref&gt;Vorozhtsov, O.V., Plaksin, I.E. and Trifanov, A.V., 2022, February. The use of small-sized tractors in agriculture. In ''IOP Conference Series: Earth and Environmental Science'' (Vol. 979, No. 1, p. 012034). IOP Publishing.&lt;/ref&gt;

=== Ukwehlisa izinga leendleko zemali emaplasini ===
Amatregere alakelela abalimi bona behlise indleko babulunge imali ngombana lokha navane une tregere akufuneki inani eliphezulu labantu abazokusebenza eplasini kunalokha unganayo itregere. Abalimi nabasenzisa itregere bakghona ukusebenza esikhundleni  esikhulu ngesikhathi esincani okutjho bona bazokhona ukukhipha Ukudla okunengi benze nenzuzo enengi&lt;ref&gt;Vorozhtsov, O.V., Plaksin, I.E. and Trifanov, A.V., 2022, February. The use of small-sized tractors in agriculture. In ''IOP Conference Series: Earth and Environmental Science'' (Vol. 979, No. 1, p. 012034). IOP Publishing.&lt;/ref&gt;.

=== Iphatha kuhle ibhoduluko ===
Itregere iphatha kulhe ibhoduloko ngombana ayisebenzisi isibaseli esinengi lokho nabayisebenzisako begodu lawa enziwe esikhathi sanje awakhiphi intuthu  enengi okutjho bona  awasilaphsi umoya khulu&lt;ref&gt;Lee, J.W., Kim, S.C., Oh, J., Chung, W.J., Han, H.W., Kim, J.T. and Park, Y.J., 2019. Engine speed control system for improving the fuel efficiency of agricultural tractors for plowing operations. ''Applied Sciences'', ''9''(18), p.3898.&lt;/ref&gt;

== Isiphetho ==
Itregere iqakathekile kwezokulima begodu kuyinto eltha itjhuguloko kwezokulima begodu kuyinto eletha itjhuguluko  kwezokulima ngombana ilekelela abalimi bona bangabi neendleko ezinengi begodu bakghone ukwenz aumsebenzi omkhulu ngesikhathi esincani. Kuyinto ehle bona abosamaplasi babe nayo.</text>
      <sha1>h29hnf065iuu4tsydf63u8a2wifo4yz</sha1>
    </revision>
    <revision>
      <id>2489</id>
      <parentid>2473</parentid>
      <timestamp>2025-03-03T13:25:52Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2489</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2922" sha1="al0q7x3j53lpr94av150qjf2n0ufhqp" xml:space="preserve">[[Isimumathi:Itregere esetjenziswa emaplasini.jpg|thumb|Itregere esetjenziswa emaplasini ukuthutha izinto ezibudisi, ukutjala, ukulima nokuvuna.]]

== Itregere ==
'''Itregere''' Kusithuthi esimtjhini  esibonkala ngamavilo amabili makhulu nomzimbaa omncani ngombana ikhwenza umuntu munye ekunguye otjhayelako. Isithuthi lesi sisetjenziswa kwezokulima, ngombana sithuthukisa  imisebenzi yabalimi, ikhuphula izinga lomsebenzi ebawenzako ngelanga nelenzuzo  yabo.Itregere ilekelela abalimi bona bacede msinya imisebenzi yabo ukudlula lokha nabasenzisa izandla nofana iinlwana. Isibonelo: itregere ikghona ikupeta  iplasi gama iri amancani ekubeni abantu bangathatha amalanga ukwenza umsebenzi lo owenziwa yitregere&lt;ref&gt;Renius, K.T., 2020. ''Fundamentals of tractor design'' (pp. 32-35). Cham, Switzerland: Springer.&lt;/ref&gt;.

== Umsebenzi wetregere ==
Amatregere alekelela abasomplasi nofana abalimi bona babe nesivuno esinengi kwezokulima ngombana  itregere ikghona ukwenza umsebenzi eminengi efana nokupeta , ukutjala, nokuvuna. Lokhu kutjho bona abalimi  nabasebenzisa itregere bangakghona ukuthola isivuno isinengi ngesikhathi esincani. Lokhu kusidosela ekutheni kube nokudla  okunengi ekuyinto ehle ngombana kuba lula ukondla isitjhaba sabantu abakhona ephasini&lt;ref&gt;Vorozhtsov, O.V., Plaksin, I.E. and Trifanov, A.V., 2022, February. The use of small-sized tractors in agriculture. In ''IOP Conference Series: Earth and Environmental Science'' (Vol. 979, No. 1, p. 012034). IOP Publishing.&lt;/ref&gt;

=== Ukwehlisa izinga leendleko zemali emaplasini ===
Amatregere alakelela abalimi bona behlise indleko babulunge imali ngombana lokha navane une tregere akufuneki inani eliphezulu labantu abazokusebenza eplasini kunalokha unganayo itregere. Abalimi nabasenzisa itregere bakghona ukusebenza esikhundleni  esikhulu ngesikhathi esincani okutjho bona bazokhona ukukhipha Ukudla okunengi benze nenzuzo enengi&lt;ref&gt;Vorozhtsov, O.V., Plaksin, I.E. and Trifanov, A.V., 2022, February. The use of small-sized tractors in agriculture. In ''IOP Conference Series: Earth and Environmental Science'' (Vol. 979, No. 1, p. 012034). IOP Publishing.&lt;/ref&gt;.

=== Iphatha kuhle ibhoduluko ===
Itregere iphatha kulhe ibhoduloko ngombana ayisebenzisi isibaseli esinengi lokho nabayisebenzisako begodu lawa enziwe esikhathi sanje awakhiphi intuthu  enengi okutjho bona  awasilaphsi umoya khulu&lt;ref&gt;Lee, J.W., Kim, S.C., Oh, J., Chung, W.J., Han, H.W., Kim, J.T. and Park, Y.J., 2019. Engine speed control system for improving the fuel efficiency of agricultural tractors for plowing operations. ''Applied Sciences'', ''9''(18), p.3898.&lt;/ref&gt;

== Isiphetho ==
Itregere iqakathekile kwezokulima begodu kuyinto eltha itjhuguloko kwezokulima begodu kuyinto eletha itjhuguluko  kwezokulima ngombana ilekelela abalimi bona bangabi neendleko ezinengi begodu bakghone ukwenz aumsebenzi omkhulu ngesikhathi esincani. Kuyinto ehle bona abosamaplasi babe nayo.</text>
      <sha1>al0q7x3j53lpr94av150qjf2n0ufhqp</sha1>
    </revision>
    <revision>
      <id>2507</id>
      <parentid>2489</parentid>
      <timestamp>2025-03-06T16:15:40Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2507</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2922" sha1="75vdd8ke4jbowp19vnmh5ql62raxz5p" xml:space="preserve">[[Isimumathi:Itregere esetjenziswa emaplasini.jpg|thumb|Itregere esetjenziswa emaplasini ukuthutha izinto ezibudisi, ukutjala, ukulima nokuvuna.]]

== Itregere ==
'''Itregere''' Kusithuthi esimtjhini  esibonkala ngamavilo amabili makhulu nomzimbaa omncani ngombana ikhwenza umuntu munye ekunguye otjhayelako. Isithuthi lesi sisetjenziswa kwezokulima, ngombana sithuthukisa  imisebenzi yabalimi, ikhuphula izinga lomsebenzi ebawenzako ngelanga nelenzuzo  yabo.Itregere ilekelela abalimi bona bacede msinya imisebenzi yabo ukudlula lokha nabasenzisa izandla nofana iinlwana. Isibonelo: itregere ikghona ikupeta  iplasi gama iri amancani ekubeni abantu bangathatha amalanga ukwenza umsebenzi lo owenziwa yitregere&lt;ref&gt;Renius, K.T., 2020. ''Fundamentals of tractor design'' (pp. 32-35). Cham, Switzerland: Springer.&lt;/ref&gt;.

== Umsebenzi wetregere ==
Amatregere alekelela abasomplasi nofana abalimi bona babe nesivuno esinengi kwezokulima ngombana  itregere ikghona ukwenza umsebenzi eminengi efana nokupeta , ukutjala, nokuvuna. Lokhu kutjho bona abalimi  nabasebenzisa itregere bangakghona ukuthola isivuno isinengi ngesikhathi esincani. Lokhu kusidosela ekutheni kube nokudla  okunengi ekuyinto ehle ngombana kuba lula ukondla isitjhaba sabantu abakhona ephasini&lt;ref&gt;Vorozhtsov, O.V., Plaksin, I.E. and Trifanov, A.V., 2022, February. The use of small-sized tractors in agriculture. In ''IOP Conference Series: Earth and Environmental Science'' (Vol. 979, No. 1, p. 012034). IOP Publishing.&lt;/ref&gt;

=== Ukwehlisa izinga leendleko zemali emaplasini ===
Amatregere alekelela abalimi bona behlise indleko babulunge imali ngombana lokha navane une tregere akufuneki inani eliphezulu labantu abazokusebenza eplasini kunalokha unganayo itregere. Abalimi nabasenzisa itregere bakghona ukusebenza esikhundleni  esikhulu ngesikhathi esincani okutjho bona bazokhona ukukhipha Ukudla okunengi benze nenzuzo enengi&lt;ref&gt;Vorozhtsov, O.V., Plaksin, I.E. and Trifanov, A.V., 2022, February. The use of small-sized tractors in agriculture. In ''IOP Conference Series: Earth and Environmental Science'' (Vol. 979, No. 1, p. 012034). IOP Publishing.&lt;/ref&gt;.

=== Iphatha kuhle ibhoduluko ===
Itregere iphatha kulhe ibhoduloko ngombana ayisebenzisi isibaseli esinengi lokho nabayisebenzisako begodu lawa enziwe esikhathi sanje awakhiphi intuthu  enengi okutjho bona  awasilaphsi umoya khulu&lt;ref&gt;Lee, J.W., Kim, S.C., Oh, J., Chung, W.J., Han, H.W., Kim, J.T. and Park, Y.J., 2019. Engine speed control system for improving the fuel efficiency of agricultural tractors for plowing operations. ''Applied Sciences'', ''9''(18), p.3898.&lt;/ref&gt;

== Isiphetho ==
Itregere iqakathekile kwezokulima begodu kuyinto eltha itjhuguloko kwezokulima begodu kuyinto eletha itjhuguluko  kwezokulima ngombana ilekelela abalimi bona bangabi neendleko ezinengi begodu bakghone ukwenz aumsebenzi omkhulu ngesikhathi esincani. Kuyinto ehle bona abosamaplasi babe nayo.</text>
      <sha1>75vdd8ke4jbowp19vnmh5ql62raxz5p</sha1>
    </revision>
  </page>
  <page>
    <title>Ibhudango</title>
    <ns>0</ns>
    <id>483</id>
    <revision>
      <id>2468</id>
      <timestamp>2025-02-26T09:30:17Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Ibhudango == '''Ibhudango''' kuyinto ehle esemkhumbulweni womuntu afuna ukuba ngiyo nofana afuna ukuyifeza. Ibhudango kungaba sithombe sento umuntu afuna ukuzibona angiyo esikhathini esizako okungaba ngokwesikhathi eminyakeni esezeko&lt;ref&gt;Tutu, D., 2011. ''God has a dream: A vision of hope for our times''. Random House.&lt;/ref&gt;. Woku umutu ophilako  unamabhudango wakhe afuna ukuwafeza.Umuntu angaba nebhudango lokuzibona asebenza umsebenzi othilko ofana nokuthi abe ngudor...&quot;</comment>
      <origin>2468</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2517" sha1="k7djhl6lnyowaxfnr0oey5r3ae6i06z" xml:space="preserve">== Ibhudango ==
'''Ibhudango''' kuyinto ehle esemkhumbulweni womuntu afuna ukuba ngiyo nofana afuna ukuyifeza. Ibhudango kungaba sithombe sento umuntu afuna ukuzibona angiyo esikhathini esizako okungaba ngokwesikhathi eminyakeni esezeko&lt;ref&gt;Tutu, D., 2011. ''God has a dream: A vision of hope for our times''. Random House.&lt;/ref&gt;. Woku umutu ophilako  unamabhudango wakhe afuna ukuwafeza.Umuntu angaba nebhudango lokuzibona asebenza umsebenzi othilko ofana nokuthi abe ngudorhodere. Omunye anagaba nebhudango lokuhlala esithatba thabeni sendlu esise dorobheni. Amabhudango ayahluka ngokuya kwabantu begodu nangokuya kwezinto abanekareko kizo.

== Izinto ongazenza ukufezekisa ibhudango lakho ==
Umuntu nakanebhudango kufuze ahlele bona yini azoyenza begodu ngizphi izinto azozenza ukufezekisa ibhudango lakhe. Izinto lezo kufanele aqinisekise bona kuzizinto eziliqiniso begodu ezikghonakalako ukuthi zitholakale.Amanye  amabhudango athathe isikhathi eside ukuthi afezakale begodu amyne wakhona athathe  isifitjhani ngokuya kobukhulu nofana ngobuncani bebhudango.Isibonelo libhudago lokuba ngudorhodere lingathatha isikhathi ukufezekala  kunaleli lokuba ngusomabhizinisi&lt;ref&gt;McPherson, K.M., Kayes, N.M. and Kersten, P., 2014. MEANING as a smarter approach to goals in rehabilitation. ''Rehabilitation goal setting: theory, practice and evidence. Taylor &amp; Francis Group, London''.&lt;/ref&gt;. 

Ukufezekisa amabhudango akusiyo into elula ngombana lokha abantu nabafuna ukufezekisa amabhudango wabo bangahlangana neentjhijilo ezinengi  ezingamenza athikamezeke.Ezinye zeentjhijilo kungaba sitjhijilo sokuthola  imali yokufezekisa amabhudango ngombana esikhathini sanje ukwenza izinto kufuna imali.

== Iitjhijilo umuntu ongahlangabezana nazo ukufezekisa ibhudango lakhe ==

=== Ukutlhoga isekelo lokuthi ukghone ukufezekisa ibhudango lakho ===
Abanye abantu lokha nabangatholi isekelo bazithola sele balahlekelwe lithemba lokuragela phambili bazithola sele batjhuguluka bangasalandeli amabhudango wabo kodwana bagcina sele benza okhunye okulula.Ukuhluleka nakho kuyema bona abantu balahle ithemba ngombana abanye abantu.

=== Ukulahla ithemba ===
Lokha  nabahlulekako bafikelwa mkhumbulo wokuthi mhlamunye ibhudango leli alikabafaneli kodwana  Isitjho sesindebele sithi akulahlwa mbeleko  ngakufelwa.  Begodu inengi  labantu abadumileko nanyana abaphumeleleko baveza bona  ngaphambi  kobana baphumelele ukufeza amabhudango wabo bathoma ngokuhluleka kanengi ngaphambi akhange balahle ithemba ngokho bagcina selek baphumulele.</text>
      <sha1>k7djhl6lnyowaxfnr0oey5r3ae6i06z</sha1>
    </revision>
    <revision>
      <id>2494</id>
      <parentid>2468</parentid>
      <timestamp>2025-03-03T17:28:05Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2494</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2515" sha1="dv7ckkhyn325dn9vzvit3cg6p7x002l" xml:space="preserve">== Ibhudango ==
'''Ibhudango''' kuyinto ehle esemkhumbulweni womuntu afuna ukuba ngiyo nofana afuna ukuyifeza. Ibhudango kungaba sithombe sento umuntu afuna ukuzibona angiyo esikhathini esizako okungaba ngokwesikhathi eminyakeni esezako&lt;ref&gt;Tutu, D., 2011. ''God has a dream: A vision of hope for our times''. Random House.&lt;/ref&gt;. Woku umutu ophilako  unamabhudango wakhe afuna ukuwafeza.Umuntu angaba nebhudango lokuzibona asebenza umsebenzi othileko ofana nokuthi abe ngudorhodere. Omunye angaba nebhudango lokuhlala esithabathabeni sendlu esise dorobheni. Amabhudango ayahluka ngokuya kwabantu begodu nangokuya kwezinto abanekareko kizo.

== Izinto ongazenza ukufezekisa ibhudango lakho ==
Umuntu nakanebhudango kufuze ahlele bona yini azoyenza begodu ngizphi izinto azozenza ukufezekisa ibhudango lakhe. Izinto lezo kufanele aqinisekise bona kuzizinto eziliqiniso begodu ezikghonakalako ukuthi zitholakale.Amanye  amabhudango athathe isikhathi eside ukuthi afezakale begodu amyne wakhona athathe  isifitjhani ngokuya kobukhulu nofana ngobuncani bebhudango.Isibonelo libhudago lokuba ngudorhodere lingathatha isikhathi ukufezekala  kunaleli lokuba ngusomabhizinisi&lt;ref&gt;McPherson, K.M., Kayes, N.M. and Kersten, P., 2014. MEANING as a smarter approach to goals in rehabilitation. ''Rehabilitation goal setting: theory, practice and evidence. Taylor &amp; Francis Group, London''.&lt;/ref&gt;. 

Ukufezekisa amabhudango akusiyo into elula ngombana lokha abantu nabafuna ukufezekisa amabhudango wabo bangahlangana neentjhijilo ezinengi  ezingamenza athikamezeke.Ezinye zeentjhijilo kungaba sitjhijilo sokuthola  imali yokufezekisa amabhudango ngombana esikhathini sanje ukwenza izinto kufuna imali.

== Iitjhijilo umuntu ongahlangabezana nazo ukufezekisa ibhudango lakhe ==

=== Ukutlhoga isekelo lokuthi ukghone ukufezekisa ibhudango lakho ===
Abanye abantu lokha nabangatholi isekelo bazithola sele balahlekelwe lithemba lokuragela phambili bazithola sele batjhuguluka bangasalandeli amabhudango wabo kodwana bagcina sele benza okhunye okulula.Ukuhluleka nakho kuyema bona abantu balahle ithemba ngombana abanye abantu.

=== Ukulahla ithemba ===
Lokha  nabahlulekako bafikelwa mkhumbulo wokuthi mhlamunye ibhudango leli alikabafaneli kodwana  Isitjho sesindebele sithi akulahlwa mbeleko  ngakufelwa.  Begodu inengi  labantu abadumileko nanyana abaphumeleleko baveza bona  ngaphambi  kobana baphumelele ukufeza amabhudango wabo bathoma ngokuhluleka kanengi ngaphambi akhange balahle ithemba ngokho bagcina selek baphumulele.</text>
      <sha1>dv7ckkhyn325dn9vzvit3cg6p7x002l</sha1>
    </revision>
    <revision>
      <id>2495</id>
      <parentid>2494</parentid>
      <timestamp>2025-03-03T17:29:35Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2495</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2531" sha1="crb2sciwchyjl2p2nf06vw01jsncfh0" xml:space="preserve">== Ibhudango ==
'''Ibhudango''' kuyinto ehle esemkhumbulweni womuntu afuna ukuba ngiyo nofana afuna ukuyifeza. Ibhudango kungaba sithombe sento umuntu afuna ukuzibona angiyo esikhathini esizako okungaba ngokwesikhathi eminyakeni esezako&lt;ref&gt;Tutu, D., 2011. ''God has a dream: A vision of hope for our times''. Random House.&lt;/ref&gt;. Woku umutu ophilako  unamabhudango wakhe afuna ukuwafeza.Umuntu angaba nebhudango lokuzibona asebenza umsebenzi othileko ofana nokuthi abe ngudorhodere. Omunye angaba nebhudango lokuhlala esithabathabeni sendlu esise dorobheni. Amabhudango ayahluka ngokuya kwabantu begodu nangokuya kwezinto abanekareko kizo.

== Izinto ongazenza ukufezekisa ibhudango lakho ==
Umuntu nakanebhudango kufuze ahlele bona yini azoyenza begodu ngiziphi izinto azozenza ukufezekisa ibhudango lakhe. Izinto lezo kufanele aqinisekise bona kuzizinto eziliqiniso begodu ezikghonakalako ukuthi zitholakale.Amanye  amabhudango athatha isikhathi eside ukuthi afezakale begodu amanye wakhona athathe isikhathi  i 

esifitjhani ngokuya kobukhulu nofana ngobuncani bebhudango.Isibonelo libhudago lokuba ngudorhodere lingathatha isikhathi ukufezekala  kunaleli lokuba ngusomabhizinisi&lt;ref&gt;McPherson, K.M., Kayes, N.M. and Kersten, P., 2014. MEANING as a smarter approach to goals in rehabilitation. ''Rehabilitation goal setting: theory, practice and evidence. Taylor &amp; Francis Group, London''.&lt;/ref&gt;. 

Ukufezekisa amabhudango akusiyo into elula ngombana lokha abantu nabafuna ukufezekisa amabhudango wabo bangahlangana neentjhijilo ezinengi  ezingamenza athikamezeke.Ezinye zeentjhijilo kungaba sitjhijilo sokuthola  imali yokufezekisa amabhudango ngombana esikhathini sanje ukwenza izinto kufuna imali.

== Iitjhijilo umuntu ongahlangabezana nazo ukufezekisa ibhudango lakhe ==

=== Ukutlhoga isekelo lokuthi ukghone ukufezekisa ibhudango lakho ===
Abanye abantu lokha nabangatholi isekelo bazithola sele balahlekelwe lithemba lokuragela phambili bazithola sele batjhuguluka bangasalandeli amabhudango wabo kodwana bagcina sele benza okhunye okulula.Ukuhluleka nakho kuyema bona abantu balahle ithemba ngombana abanye abantu.

=== Ukulahla ithemba ===
Lokha  nabahlulekako bafikelwa mkhumbulo wokuthi mhlamunye ibhudango leli alikabafaneli kodwana  Isitjho sesindebele sithi akulahlwa mbeleko  ngakufelwa.  Begodu inengi  labantu abadumileko nanyana abaphumeleleko baveza bona  ngaphambi  kobana baphumelele ukufeza amabhudango wabo bathoma ngokuhluleka kanengi ngaphambi akhange balahle ithemba ngokho bagcina selek baphumulele.</text>
      <sha1>crb2sciwchyjl2p2nf06vw01jsncfh0</sha1>
    </revision>
    <revision>
      <id>2496</id>
      <parentid>2495</parentid>
      <timestamp>2025-03-03T17:30:36Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2496</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2554" sha1="sbzfdqdwek22obu4uuf6gg92eflqq6v" xml:space="preserve">== Ibhudango ==
'''Ibhudango''' kuyinto ehle esemkhumbulweni womuntu afuna ukuba ngiyo nofana afuna ukuyifeza. Ibhudango kungaba sithombe sento umuntu afuna ukuzibona angiyo esikhathini esizako okungaba ngokwesikhathi eminyakeni esezako&lt;ref&gt;Tutu, D., 2011. ''God has a dream: A vision of hope for our times''. Random House.&lt;/ref&gt;. Woku umutu ophilako  unamabhudango wakhe afuna ukuwafeza.Umuntu angaba nebhudango lokuzibona asebenza umsebenzi othileko ofana nokuthi abe ngudorhodere. Omunye angaba nebhudango lokuhlala esithabathabeni sendlu esise dorobheni. Amabhudango ayahluka ngokuya kwabantu begodu nangokuya kwezinto abanekareko kizo.

== Izinto ongazenza ukufezekisa ibhudango lakho ==
Umuntu nakanebhudango kufuze ahlele bona yini azoyenza begodu ngiziphi izinto azozenza ukufezekisa ibhudango lakhe. Izinto lezo kufanele aqinisekise bona kuzizinto eziliqiniso begodu ezikghonakalako ukuthi zitholakale.Amanye  amabhudango athatha isikhathi eside ukuthi afezakale begodu amanye wakhona athathe isikhathi  i 

esifitjhani ngokuya kobukhulu nofana ngobuncani bebhudango.Isibonelo libhudago lokuba ngudorhodere lingathatha isikhathi ukufezekala  kunaleli lokuba ngusomabhizinisi&lt;ref&gt;McPherson, K.M., Kayes, N.M. and Kersten, P., 2014. MEANING as a smarter approach to goals in rehabilitation. ''Rehabilitation goal setting: theory, practice and evidence. Taylor &amp; Francis Group, London''.&lt;/ref&gt;. 

Ukufezekisa amabhudango akusiyo into elula ngombana lokha abantu nabafuna ukufezekisa amabhudango wabo bangahlangana neentjhijilo ezinengi  ezingamenza athikamezeke.Ezinye zeentjhijilo kungaba sitjhijilo sokuthola  imali yokufezekisa amabhudango ngombana esikhathini sanje ukwenza izinto kufuna imali.

== Iitjhijilo umuntu ongahlangabezana nazo ukufezekisa ibhudango lakhe ==

=== Ukutlhoga isekelo lokuthi ukghone ukufezekisa ibhudango lakho ===
Abanye abantu lokha nabangatholi isekelo bazithola sele balahlekelwe lithemba lokuragela phambili bazithola sele batjhuguluka bangasalandeli amabhudango wabo kodwana bagcina sele benza okhunye okulula.Ukuhluleka nakho kuyenza bona abantu balahle ithemba ngombana abanye abantu abakghoni ukubekezela.

=== Ukulahla ithemba ===
Lokha  nabahlulekako bafikelwa mkhumbulo wokuthi mhlamunye ibhudango leli alikabafaneli kodwana  Isitjho sesindebele sithi akulahlwa mbeleko  ngakufelwa.  Begodu inengi  labantu abadumileko nanyana abaphumeleleko baveza bona  ngaphambi  kobana baphumelele ukufeza amabhudango wabo bathoma ngokuhluleka kanengi ngaphambi akhange balahle ithemba ngokho bagcina selek baphumulele.</text>
      <sha1>sbzfdqdwek22obu4uuf6gg92eflqq6v</sha1>
    </revision>
    <revision>
      <id>5151</id>
      <parentid>2496</parentid>
      <timestamp>2025-08-13T17:21:51Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5151</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2457" sha1="ofybkd3dgqgsi7rvqlhu0f89byap6p5" xml:space="preserve">'''Ibhudango''' kuyinto ehle esemkhumbulweni womuntu afuna ukuba ngiyo nofana afuna ukuyifeza. Ibhudango kungaba sithombe sento umuntu afuna ukuzibona angiyo esikhathini esizako okungaba ngokwesikhathi eminyakeni esezako&lt;ref&gt;Tutu, D., 2011. ''God has a dream: A vision of hope for our times''. Random House.&lt;/ref&gt;. Woku umutu ophilako  unamabhudango wakhe afuna ukuwafeza.Umuntu angaba nebhudango lokuzibona asebenza umsebenzi othileko ofana nokuthi abe ngudorhodere. Omunye angaba nebhudango lokuhlala esithabathabeni sendlu esise dorobheni. Amabhudango ayahluka ngokuya kwabantu begodu nangokuya kwezinto abanekareko kizo.

=== Izinto ongazenza ukufezekisa ibhudango lakho ===
Umuntu nakanebhudango kufuze ahlele bona yini azoyenza begodu ngiziphi izinto azozenza ukufezekisa ibhudango lakhe. Izinto lezo kufanele aqinisekise bona kuzizinto eziliqiniso begodu ezikghonakalako ukuthi zitholakale.Amanye  amabhudango athatha isikhathi eside ukuthi afezakale begodu amanye wakhona athathe isikhathi  iesifitjhani ngokuya kobukhulu nofana ngobuncani bebhudango. Isibonelo libhudago lokuba ngudorhodere lingathatha isikhathi ukufezekala  kunaleli lokuba ngusomabhizinisi&lt;ref&gt;McPherson, K.M., Kayes, N.M. and Kersten, P., 2014. MEANING as a smarter approach to goals in rehabilitation. ''Rehabilitation goal setting: theory, practice and evidence. Taylor &amp; Francis Group, London''.&lt;/ref&gt;. Ukufezekisa amabhudango akusiyo into elula ngombana lokha abantu nabafuna ukufezekisa amabhudango wabo bangahlangana neentjhijilo ezinengi  ezingamenza athikamezeke.Ezinye zeentjhijilo kungaba sitjhijilo sokuthola  imali yokufezekisa amabhudango ngombana esikhathini sanje ukwenza izinto kufuna imali. 

=== Iitjhijilo umuntu ongahlangabezana nazo ukufezekisa ibhudango lakhe ===
Abanye abantu lokha nabangatholi isekelo bazithola sele balahlekelwe lithemba lokuragela phambili bazithola sele batjhuguluka bangasalandeli amabhudango wabo kodwana bagcina sele benza okhunye okulula.Ukuhluleka nakho kuyenza bona abantu balahle ithemba ngombana abanye abantu abakghoni ukubekezela.Lokha  nabahlulekako bafikelwa mkhumbulo wokuthi mhlamunye ibhudango leli alikabafaneli kodwana  Isitjho sesindebele sithi akulahlwa mbeleko  ngakufelwa.  Begodu inengi  labantu abadumileko nanyana abaphumeleleko baveza bona  ngaphambi  kobana baphumelele ukufeza amabhudango wabo bathoma ngokuhluleka kanengi ngaphambi akhange balahle ithemba ngokho bagcina selek baphumulele.

== Iinkomba ==</text>
      <sha1>ofybkd3dgqgsi7rvqlhu0f89byap6p5</sha1>
    </revision>
    <revision>
      <id>5152</id>
      <parentid>5151</parentid>
      <timestamp>2025-08-13T17:22:50Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>5152</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2480" sha1="nav74qp4io2wyyfpg63d4jadr8s1o7t" xml:space="preserve">'''Ibhudango''' kuyinto ehle esemkhumbulweni womuntu afuna ukuba ngiyo nofana afuna ukuyifeza. Ibhudango kungaba sithombe sento umuntu afuna ukuzibona angiyo esikhathini esizako okungaba ngokwesikhathi eminyakeni esezako&lt;ref&gt;Tutu, D., 2011. ''God has a dream: A vision of hope for our times''. Random House.&lt;/ref&gt;. Woku umutu ophilako  unamabhudango wakhe afuna ukuwafeza.Umuntu angaba nebhudango lokuzibona asebenza umsebenzi othileko ofana nokuthi abe ngudorhodere. Omunye angaba nebhudango lokuhlala esithabathabeni sendlu esise dorobheni. Amabhudango ayahluka ngokuya kwabantu begodu nangokuya kwezinto abanekareko kizo.

=== Izinto ongazenza ukufezekisa ibhudango lakho ===
Umuntu nakanebhudango kufuze ahlele bona yini azoyenza begodu ngiziphi izinto azozenza ukufezekisa ibhudango lakhe. Izinto lezo kufanele aqinisekise bona kuzizinto eziliqiniso begodu ezikghonakalako ukuthi zitholakale.Amanye  amabhudango athatha isikhathi eside ukuthi afezakale begodu amanye wakhona athathe isikhathi  iesifitjhani ngokuya kobukhulu nofana ngobuncani bebhudango. Isibonelo libhudago lokuba ngudorhodere lingathatha isikhathi ukufezekala  kunaleli lokuba ngusomabhizinisi&lt;ref&gt;McPherson, K.M., Kayes, N.M. and Kersten, P., 2014. MEANING as a smarter approach to goals in rehabilitation. ''Rehabilitation goal setting: theory, practice and evidence. Taylor &amp; Francis Group, London''.&lt;/ref&gt;. Ukufezekisa amabhudango akusiyo into elula ngombana lokha abantu nabafuna ukufezekisa amabhudango wabo bangahlangana neentjhijilo ezinengi  ezingamenza athikamezeke.Ezinye zeentjhijilo kungaba sitjhijilo sokuthola  imali yokufezekisa amabhudango ngombana esikhathini sanje ukwenza izinto kufuna imali. 

=== Iitjhijilo umuntu ongahlangabezana nazo ukufezekisa ibhudango lakhe ===
Abanye abantu lokha nabangatholi isekelo bazithola sele balahlekelwe lithemba lokuragela phambili bazithola sele batjhuguluka bangasalandeli amabhudango wabo kodwana bagcina sele benza okhunye okulula.Ukuhluleka nakho kuyenza bona abantu balahle ithemba ngombana abanye abantu abakghoni ukubekezela.Lokha  nabahlulekako bafikelwa mkhumbulo wokuthi mhlamunye ibhudango leli alikabafaneli kodwana  Isitjho sesindebele sithi akulahlwa mbeleko  ngakufelwa.  Begodu inengi  labantu abadumileko nanyana abaphumeleleko baveza bona  ngaphambi  kobana baphumelele ukufeza amabhudango wabo bathoma ngokuhluleka kanengi ngaphambi akhange balahle ithemba ngokho bagcina selek baphumulele.

== Iinkomba ==
[[Category:Ibhudango]]</text>
      <sha1>nav74qp4io2wyyfpg63d4jadr8s1o7t</sha1>
    </revision>
    <revision>
      <id>5153</id>
      <parentid>5152</parentid>
      <timestamp>2025-08-13T17:23:54Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5153</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2481" sha1="mugsmm3b7ssvec4n39jm4jnpzhz5zk0" xml:space="preserve">'''Ibhudango''' kuyinto ehle esemkhumbulweni womuntu afuna ukuba ngiyo nofana afuna ukuyifeza. Ibhudango kungaba sithombe sento umuntu afuna ukuzibona angiyo esikhathini esizako okungaba ngokwesikhathi eminyakeni esezako&lt;ref&gt;Tutu, D., 2011. ''God has a dream: A vision of hope for our times''. Random House.&lt;/ref&gt;. Woku umuntu ophilako  unamabhudango wakhe afuna ukuwafeza.Umuntu angaba nebhudango lokuzibona asebenza umsebenzi othileko ofana nokuthi abe ngudorhodere. Omunye angaba nebhudango lokuhlala esithabathabeni sendlu esise dorobheni. Amabhudango ayahluka ngokuya kwabantu begodu nangokuya kwezinto abanekareko kizo.

=== Izinto ongazenza ukufezekisa ibhudango lakho ===
Umuntu nakanebhudango kufuze ahlele bona yini azoyenza begodu ngiziphi izinto azozenza ukufezekisa ibhudango lakhe. Izinto lezo kufanele aqinisekise bona kuzizinto eziliqiniso begodu ezikghonakalako ukuthi zitholakale.Amanye  amabhudango athatha isikhathi eside ukuthi afezakale begodu amanye wakhona athathe isikhathi  iesifitjhani ngokuya kobukhulu nofana ngobuncani bebhudango. Isibonelo libhudago lokuba ngudorhodere lingathatha isikhathi ukufezekala  kunaleli lokuba ngusomabhizinisi&lt;ref&gt;McPherson, K.M., Kayes, N.M. and Kersten, P., 2014. MEANING as a smarter approach to goals in rehabilitation. ''Rehabilitation goal setting: theory, practice and evidence. Taylor &amp; Francis Group, London''.&lt;/ref&gt;. Ukufezekisa amabhudango akusiyo into elula ngombana lokha abantu nabafuna ukufezekisa amabhudango wabo bangahlangana neentjhijilo ezinengi  ezingamenza athikamezeke.Ezinye zeentjhijilo kungaba sitjhijilo sokuthola  imali yokufezekisa amabhudango ngombana esikhathini sanje ukwenza izinto kufuna imali. 

=== Iitjhijilo umuntu ongahlangabezana nazo ukufezekisa ibhudango lakhe ===
Abanye abantu lokha nabangatholi isekelo bazithola sele balahlekelwe lithemba lokuragela phambili bazithola sele batjhuguluka bangasalandeli amabhudango wabo kodwana bagcina sele benza okhunye okulula.Ukuhluleka nakho kuyenza bona abantu balahle ithemba ngombana abanye abantu abakghoni ukubekezela.Lokha  nabahlulekako bafikelwa mkhumbulo wokuthi mhlamunye ibhudango leli alikabafaneli kodwana  Isitjho sesindebele sithi akulahlwa mbeleko  ngakufelwa.  Begodu inengi  labantu abadumileko nanyana abaphumeleleko baveza bona  ngaphambi  kobana baphumelele ukufeza amabhudango wabo bathoma ngokuhluleka kanengi ngaphambi akhange balahle ithemba ngokho bagcina selek baphumulele.

== Iinkomba ==
[[Category:Ibhudango]]</text>
      <sha1>mugsmm3b7ssvec4n39jm4jnpzhz5zk0</sha1>
    </revision>
  </page>
  <page>
    <title>Amalahle</title>
    <ns>0</ns>
    <id>484</id>
    <revision>
      <id>2469</id>
      <timestamp>2025-02-26T09:39:38Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Amalahle == '''Amalahle''' mamatje anzima aqinileko asetjenziswa ukubasa umlilo. Ilahle lenzeka ngeensalelo zeentjalo ezife iminyaka eziingidi eyadlulako  sabulungeka ngaphasi kwehlabathi. Ilahle lenzeka ngoma compounds we-organic ekuyi nitrogen, I carbon, i-oxygen ne sulfur.  == Lenzeka njani ilahle? == Ilahle lenzeka ngokuthi isitjalo sife sibulungeke kude ngaphasi kwehlabathi lapho  kutjhisa khona khulu begodu kuminyezekile, iiintjalo lezi zihlala iingidii zeminyak...&quot;</comment>
      <origin>2469</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2986" sha1="ohwguk0fukporvmfl1l2gv1fchdcjac" xml:space="preserve">== Amalahle ==
'''Amalahle''' mamatje anzima aqinileko asetjenziswa ukubasa umlilo. Ilahle lenzeka ngeensalelo zeentjalo ezife iminyaka eziingidi eyadlulako  sabulungeka ngaphasi kwehlabathi. Ilahle lenzeka ngoma compounds we-organic ekuyi nitrogen, I carbon, i-oxygen ne sulfur.

== Lenzeka njani ilahle? ==
Ilahle lenzeka ngokuthi isitjalo sife sibulungeke kude ngaphasi kwehlabathi lapho  kutjhisa khona khulu begodu kuminyezekile, iiintjalo lezi zihlala iingidii zeminyaka bekifike lapho isitijalo lesi siqina khona siphedue sibe lilahle. Kuemihlobo emine yamalahle begodu into eyanza bona amalahle ahluke kukuthi aqine kangangani&lt;ref&gt;O'Keefe, J.M., Bechtel, A., Christanis, K., Dai, S., DiMichele, W.A., Eble, C.F., Esterle, J.S., Mastalerz, M., Raymond, A.L., Valentim, B.V. and Wagner, N.J., 2013. On the fundamental difference between coal rank and coal type. ''International Journal of Coal Geology'', ''118'', pp.58-87.&lt;/ref&gt;.

== Umhlobo yamalahle ==
1. Ilahle I Lignite

Lilahle elingakaqini lithambile. Laziwa ngelahle elinzotho, litjhiphile ukudlula woke umhlobo wamalahle ngombana alivuthi isikharthi eside. Lokho nabalithengako abantu kufanele balithenge ngobunengi ngombana liphela msinyan lokha nalibasiweko. Liyasetjenziswa lokha nakuphehlwa igezi&lt;ref&gt;Heydari, M., Rahman, M. and Gupta, R., 2015. Kinetic study and thermal decomposition behavior of lignite coal. ''International Journal of Chemical Engineering'', ''2015''(1), p.481739.&lt;/ref&gt;.

2. Ilahle I sub-bituminous

Lilahle eliphakathi ngokwenzinga lamalahle. Liphakathi kwe lahle I lignite ne lahle I-bituminous. Lilahle elingakaqini khulu,nalo liyasetjenziswa ukuphehla igezi Kanye nemafemini amanye.

3. Ilahle I Bituminous

Lilahle eliqinileko, elizelel nge carbon lisetjenziswa  ukwenza iinsimbi nokutjhisa ezinye izinto zemakjhaya. Ilahle leli aliduri khulu ukudlula i-Antracite. Lisetjenziswa khulu emafemini lapho kwenziwa khoa isamende, namaphepha. Liyasetjenziswa nokususa ukusilaphazeka kwe iron- ore

4. Antracite 

Lilahle eliqine khulu ukuwadlula woke, lizele nge carbon. Lisetjenziswe  emafemini. Ilahle likhipha umtjhiso omkhulu  ukudlula amalahle woke. Lithatha isikhathi ukubamba umlilo kodwana kodwana nasele liwubambile livutha kabuthaka beliyokuphela&lt;ref&gt;O'Keefe, J.M., Bechtel, A., Christanis, K., Dai, S., DiMichele, W.A., Eble, C.F., Esterle, J.S., Mastalerz, M., Raymond, A.L., Valentim, B.V. and Wagner, N.J., 2013. On the fundamental difference between coal rank and coal type. ''International Journal of Coal Geology'', ''118'', pp.58-87.&lt;/ref&gt;. 

== Umsebenzi wamalahle ovamileko ==
Lisetjenziswa emakhaya ukubasela intovu nalokha  kubaswa inyama. Isetjenziswa njengesibaseli  emafemini lapho kwenziwa khona  iinsimbi. Liqakatheke khulu ngokuthi liyasetjenziswa ukuphehla igezi.
Isiphetho
Nanyana  amalahle aqakathekile kodwan intuthu yawo isilaqphaza ibhoduloko.Kufanele abantu bangawa  sebenzisi khulu nofana kufuze batjale imithi eminengi ukuze  idose I carbon ekhutjhwa malahle</text>
      <sha1>ohwguk0fukporvmfl1l2gv1fchdcjac</sha1>
    </revision>
    <revision>
      <id>2500</id>
      <parentid>2469</parentid>
      <timestamp>2025-03-04T09:53:51Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2500</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2989" sha1="k2q3mcuixbb4aaa6pnbtbcu6bzw07ve" xml:space="preserve">== Amalahle ==
'''Amalahle''' mamatje anzima aqinileko asetjenziswa ukubasa umlilo. Ilahle lenzeka ngeensalelo zeentjalo ezife iminyaka eziingidi eyadlulako  sabulungeka ngaphasi kwehlabathi. Ilahle lenzeka ngoma compounds we-organic ekuyi nitrogen, I carbon, i-oxygen ne sulfur.

== Lenzeka njani ilahle? ==
Ilahle lenzeka ngokuthi isitjalo sife sibulungeke kude ngaphasi kwehlabathi lapho  kutjhisa khona khulu begodu kuminyezekile, iiintjalo lezi zihlala iingidii zeminyaka bekufike lapho isitijalo lesi siqina khona siphenduke sibe lilahle. Kunemihlobo emine yamalahle begodu into eyanza bona amalahle ahluke kukuthi aqine kangangani&lt;ref&gt;O'Keefe, J.M., Bechtel, A., Christanis, K., Dai, S., DiMichele, W.A., Eble, C.F., Esterle, J.S., Mastalerz, M., Raymond, A.L., Valentim, B.V. and Wagner, N.J., 2013. On the fundamental difference between coal rank and coal type. ''International Journal of Coal Geology'', ''118'', pp.58-87.&lt;/ref&gt;.

== Umhlobo yamalahle ==
1. Ilahle I Lignite

Lilahle elingakaqini lithambile. Laziwa ngelahle elinzotho, litjhiphile ukudlula woke umhlobo wamalahle ngombana alivuthi isikharthi eside. Lokho nabalithengako abantu kufanele balithenge ngobunengi ngombana liphela msinyan lokha nalibasiweko. Liyasetjenziswa lokha nakuphehlwa igezi&lt;ref&gt;Heydari, M., Rahman, M. and Gupta, R., 2015. Kinetic study and thermal decomposition behavior of lignite coal. ''International Journal of Chemical Engineering'', ''2015''(1), p.481739.&lt;/ref&gt;.

2. Ilahle I sub-bituminous

Lilahle eliphakathi ngokwenzinga lamalahle. Liphakathi kwe lahle I lignite ne lahle I-bituminous. Lilahle elingakaqini khulu,nalo liyasetjenziswa ukuphehla igezi Kanye nemafemini amanye.

3. Ilahle I Bituminous

Lilahle eliqinileko, elizelel nge carbon lisetjenziswa  ukwenza iinsimbi nokutjhisa ezinye izinto zemakjhaya. Ilahle leli aliduri khulu ukudlula i-Antracite. Lisetjenziswa khulu emafemini lapho kwenziwa khoa isamende, namaphepha. Liyasetjenziswa nokususa ukusilaphazeka kwe iron- ore

4. Antracite 

Lilahle eliqine khulu ukuwadlula woke, lizele nge carbon. Lisetjenziswe  emafemini. Ilahle likhipha umtjhiso omkhulu  ukudlula amalahle woke. Lithatha isikhathi ukubamba umlilo kodwana kodwana nasele liwubambile livutha kabuthaka beliyokuphela&lt;ref&gt;O'Keefe, J.M., Bechtel, A., Christanis, K., Dai, S., DiMichele, W.A., Eble, C.F., Esterle, J.S., Mastalerz, M., Raymond, A.L., Valentim, B.V. and Wagner, N.J., 2013. On the fundamental difference between coal rank and coal type. ''International Journal of Coal Geology'', ''118'', pp.58-87.&lt;/ref&gt;. 

== Umsebenzi wamalahle ovamileko ==
Lisetjenziswa emakhaya ukubasela intovu nalokha  kubaswa inyama. Isetjenziswa njengesibaseli  emafemini lapho kwenziwa khona  iinsimbi. Liqakatheke khulu ngokuthi liyasetjenziswa ukuphehla igezi.
Isiphetho
Nanyana  amalahle aqakathekile kodwan intuthu yawo isilaqphaza ibhoduloko.Kufanele abantu bangawa  sebenzisi khulu nofana kufuze batjale imithi eminengi ukuze  idose I carbon ekhutjhwa malahle</text>
      <sha1>k2q3mcuixbb4aaa6pnbtbcu6bzw07ve</sha1>
    </revision>
    <revision>
      <id>2501</id>
      <parentid>2500</parentid>
      <timestamp>2025-03-04T09:56:21Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2501</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2989" sha1="gu8z6ifuxskb1bdweaoaleifzflo5kr" xml:space="preserve">== Amalahle ==
'''Amalahle''' mamatje anzima aqinileko asetjenziswa ukubasa umlilo. Ilahle lenzeka ngeensalelo zeentjalo ezife iminyaka eziingidi eyadlulako  sabulungeka ngaphasi kwehlabathi. Ilahle lenzeka ngoma compounds we-organic ekuyi nitrogen, I carbon, i-oxygen ne sulfur.

== Lenzeka njani ilahle? ==
Ilahle lenzeka ngokuthi isitjalo sife sibulungeke kude ngaphasi kwehlabathi lapho  kutjhisa khona khulu begodu kuminyezekile, iiintjalo lezi zihlala iingidii zeminyaka bekufike lapho isitijalo lesi siqina khona siphenduke sibe lilahle. Kunemihlobo emine yamalahle begodu into eyanza bona amalahle ahluke kukuthi aqine kangangani&lt;ref&gt;O'Keefe, J.M., Bechtel, A., Christanis, K., Dai, S., DiMichele, W.A., Eble, C.F., Esterle, J.S., Mastalerz, M., Raymond, A.L., Valentim, B.V. and Wagner, N.J., 2013. On the fundamental difference between coal rank and coal type. ''International Journal of Coal Geology'', ''118'', pp.58-87.&lt;/ref&gt;.

== Umhlobo yamalahle ==
1. Ilahle I Lignite

Lilahle elingakaqini lithambile. Laziwa ngelahle elinzotho, litjhiphile ukudlula woke umhlobo wamalahle ngombana alivuthi isikhathi eside. Lokho nabalithengako abantu kufanele balithenge ngobunengi ngombana liphela msinyana lokha nalibasiweko. Liyasetjenziswa lokha nakuphehlwa igezi&lt;ref&gt;Heydari, M., Rahman, M. and Gupta, R., 2015. Kinetic study and thermal decomposition behavior of lignite coal. ''International Journal of Chemical Engineering'', ''2015''(1), p.481739.&lt;/ref&gt;.

2. Ilahle I sub-bituminous

Lilahle eliphakathi ngokwenzinga lamalahle. Liphakathi kwe lahle I lignite ne lahle I-bituminous. Lilahle elingakaqini khulu,nalo liyasetjenziswa ukuphehla igezi Kanye nemafemini amanye.

3. Ilahle I Bituminous

Lilahle eliqinileko, elizele nge carbon lisetjenziswa  ukwenza iinsimbi nokutjhisa ezinye izinto zemakhaya. Ilahle leli aliduri khulu ukudlula i-Antracite. Lisetjenziswa khulu emafemini lapho kwenziwa khona isamende, namaphepha. Liyasetjenziswa nokususa ukusilaphazeka kwe iron- ore.

4. Antracite 

Lilahle eliqine khulu ukuwadlula woke, lizele nge carbon. Lisetjenziswe  emafemini. Ilahle likhipha umtjhiso omkhulu  ukudlula amalahle woke. Lithatha isikhathi ukubamba umlilo kodwana kodwana nasele liwubambile livutha kabuthaka beliyokuphela&lt;ref&gt;O'Keefe, J.M., Bechtel, A., Christanis, K., Dai, S., DiMichele, W.A., Eble, C.F., Esterle, J.S., Mastalerz, M., Raymond, A.L., Valentim, B.V. and Wagner, N.J., 2013. On the fundamental difference between coal rank and coal type. ''International Journal of Coal Geology'', ''118'', pp.58-87.&lt;/ref&gt;. 

== Umsebenzi wamalahle ovamileko ==
Lisetjenziswa emakhaya ukubasela intovu nalokha  kubaswa inyama. Isetjenziswa njengesibaseli  emafemini lapho kwenziwa khona  iinsimbi. Liqakatheke khulu ngokuthi liyasetjenziswa ukuphehla igezi.
Isiphetho
Nanyana  amalahle aqakathekile kodwan intuthu yawo isilaqphaza ibhoduloko.Kufanele abantu bangawa  sebenzisi khulu nofana kufuze batjale imithi eminengi ukuze  idose I carbon ekhutjhwa malahle</text>
      <sha1>gu8z6ifuxskb1bdweaoaleifzflo5kr</sha1>
    </revision>
    <revision>
      <id>2548</id>
      <parentid>2501</parentid>
      <timestamp>2025-03-19T18:12:08Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2548</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2999" sha1="dt54dkdxc9ebo9zr6z8nu1k66rvbhwu" xml:space="preserve">== Amalahle ==
'''Amalahle''' mamatje anzima aqinileko asetjenziswa ukubasa [[umlilo]]. Ilahle lenzeka ngeensalelo zeentjalo ezife iminyaka eziingidi eyadlulako  sabulungeka ngaphasi kwehlabathi. Ilahle lenzeka ngoma compounds we-organic ekuyi nitrogen, I carbon, i-oxygen ne sulfur.

== Lenzeka njani ilahle? ==
Ilahle lenzeka ngokuthi isitjalo sife sibulungeke kude ngaphasi kwehlabathi lapho  kutjhisa khona khulu begodu kuminyezekile, iiintjalo lezi zihlala iingidii zeminyaka bekufike lapho isitijalo lesi siqina khona siphenduke sibe lilahle. Kunemihlobo emine yamalahle begodu into eyanza bona amalahle ahluke kukuthi aqine kangangani&lt;ref&gt;O'Keefe, J.M., Bechtel, A., Christanis, K., Dai, S., DiMichele, W.A., Eble, C.F., Esterle, J.S., Mastalerz, M., Raymond, A.L., Valentim, B.V. and Wagner, N.J., 2013. On the fundamental difference between coal rank and coal type. ''International Journal of Coal Geology'', ''118'', pp.58-87.&lt;/ref&gt;.

== Umhlobo yamalahle ==
1. Ilahle I Lignite

Lilahle elingakaqini lithambile. Laziwa ngelahle elinzotho, litjhiphile ukudlula woke umhlobo wamalahle ngombana alivuthi isikhathi eside. Lokho nabalithengako abantu kufanele balithenge ngobunengi ngombana liphela msinyana lokha nalibasiweko. Liyasetjenziswa lokha nakuphehlwa [[igezi]]&lt;ref&gt;Heydari, M., Rahman, M. and Gupta, R., 2015. Kinetic study and thermal decomposition behavior of lignite coal. ''International Journal of Chemical Engineering'', ''2015''(1), p.481739.&lt;/ref&gt;.

2. Ilahle I sub-bituminous

Lilahle eliphakathi ngokwenzinga lamalahle. Liphakathi kwe lahle I lignite ne lahle I-bituminous. Lilahle elingakaqini khulu,nalo liyasetjenziswa ukuphehla igezi Kanye nemafemini amanye.

3. Ilahle I Bituminous

Lilahle eliqinileko, elizele nge carbon lisetjenziswa  ukwenza iinsimbi nokutjhisa ezinye izinto zemakhaya. Ilahle leli aliduri khulu ukudlula i-Antracite. Lisetjenziswa khulu emafemini lapho kwenziwa khona isamende, namaphepha. Liyasetjenziswa nokususa ukusilaphazeka kwe iron- ore.

4. Antracite 

Lilahle eliqine khulu ukuwadlula woke, lizele nge carbon. Lisetjenziswe emafemini. Ilahle likhipha umtjhiso omkhulu  ukudlula amalahle woke. Lithatha isikhathi ukubamba umlilo kodwana kodwana nasele liwubambile livutha kabuthaka beliyokuphela&lt;ref&gt;O'Keefe, J.M., Bechtel, A., Christanis, K., Dai, S., DiMichele, W.A., Eble, C.F., Esterle, J.S., Mastalerz, M., Raymond, A.L., Valentim, B.V. and Wagner, N.J., 2013. On the fundamental difference between coal rank and coal type. ''International Journal of Coal Geology'', ''118'', pp.58-87.&lt;/ref&gt;. 

== Umsebenzi wamalahle ovamileko ==
Lisetjenziswa emakhaya ukubasela intovu nalokha kubaswa [[inyama]]. Isetjenziswa njengesibaseli  emafemini lapho kwenziwa khona  iinsimbi. Liqakatheke khulu ngokuthi liyasetjenziswa ukuphehla igezi.
Isiphetho
Nanyana  amalahle aqakathekile kodwan intuthu yawo isilaqphaza ibhoduloko.Kufanele abantu bangawa  sebenzisi khulu nofana kufuze batjale imithi eminengi ukuze  idose I carbon ekhutjhwa malahle</text>
      <sha1>dt54dkdxc9ebo9zr6z8nu1k66rvbhwu</sha1>
    </revision>
    <revision>
      <id>3409</id>
      <parentid>2548</parentid>
      <timestamp>2025-07-12T13:27:59Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3409</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2966" sha1="9ltarnzody3nxx77e7k3dmidrn5s9ct" xml:space="preserve">
'''Amalahle''' mamatje anzima aqinileko asetjenziswa ukubasa [[umlilo]]. Ilahle lenzeka ngeensalelo zeentjalo ezife iminyaka eziingidi eyadlulako  sabulungeka ngaphasi kwehlabathi. Ilahle lenzeka ngoma compounds we-organic ekuyi nitrogen, I carbon, i-oxygen ne sulfur. Ilahle lenzeka ngokuthi isitjalo sife sibulungeke kude ngaphasi kwehlabathi lapho  kutjhisa khona khulu begodu kuminyezekile, iiintjalo lezi zihlala iingidii zeminyaka bekufike lapho isitijalo lesi siqina khona siphenduke sibe lilahle. Kunemihlobo emine yamalahle begodu into eyanza bona amalahle ahluke kukuthi aqine kangangani&lt;ref&gt;O'Keefe, J.M., Bechtel, A., Christanis, K., Dai, S., DiMichele, W.A., Eble, C.F., Esterle, J.S., Mastalerz, M., Raymond, A.L., Valentim, B.V. and Wagner, N.J., 2013. On the fundamental difference between coal rank and coal type. ''International Journal of Coal Geology'', ''118'', pp.58-87.&lt;/ref&gt;.

=== Umhlobo yamalahle ===
1. Ilahle I Lignite

Lilahle elingakaqini lithambile. Laziwa ngelahle elinzotho, litjhiphile ukudlula woke umhlobo wamalahle ngombana alivuthi isikhathi eside. Lokho nabalithengako abantu kufanele balithenge ngobunengi ngombana liphela msinyana lokha nalibasiweko. Liyasetjenziswa lokha nakuphehlwa [[igezi]]&lt;ref&gt;Heydari, M., Rahman, M. and Gupta, R., 2015. Kinetic study and thermal decomposition behavior of lignite coal. ''International Journal of Chemical Engineering'', ''2015''(1), p.481739.&lt;/ref&gt;.

2. Ilahle I sub-bituminous

Lilahle eliphakathi ngokwenzinga lamalahle. Liphakathi kwe lahle I lignite ne lahle I-bituminous. Lilahle elingakaqini khulu,nalo liyasetjenziswa ukuphehla igezi Kanye nemafemini amanye.

3. Ilahle I Bituminous

Lilahle eliqinileko, elizele nge -''carbon'' lisetjenziswa  ukwenza iinsimbi nokutjhisa ezinye izinto zemakhaya. Ilahle leli aliduri khulu ukudlula i-Antracite. Lisetjenziswa khulu emafemini lapho kwenziwa khona isamende, namaphepha. Liyasetjenziswa nokususa ukusilaphazeka kwe iron- ore.

4. Antracite 

Lilahle eliqine khulu ukuwadlula woke, lizele nge carbon. Lisetjenziswe emafemini. Ilahle likhipha umtjhiso omkhulu  ukudlula amalahle woke. Lithatha isikhathi ukubamba umlilo kodwana kodwana nasele liwubambile livutha kabuthaka beliyokuphela&lt;ref&gt;O'Keefe, J.M., Bechtel, A., Christanis, K., Dai, S., DiMichele, W.A., Eble, C.F., Esterle, J.S., Mastalerz, M., Raymond, A.L., Valentim, B.V. and Wagner, N.J., 2013. On the fundamental difference between coal rank and coal type. ''International Journal of Coal Geology'', ''118'', pp.58-87.&lt;/ref&gt;. 

=== Umsebenzi wamalahle ovamileko ===
Lisetjenziswa emakhaya ukubasela intovu nalokha kubaswa inyama. Isetjenziswa njengesibaseli  emafemini lapho kwenziwa khona  iinsimbi. Liqakatheke khulu ngokuthi liyasetjenziswa ukuphehla igezi.Nanyana  amalahle aqakathekile kodwan intuthu yawo isilaqphaza ibhoduloko.Kufanele abantu bangawa  sebenzisi khulu nofana kufuze batjale imithi eminengi ukuze  idose I carbon ekhutjhwa malahle

== Iinkomba ==</text>
      <sha1>9ltarnzody3nxx77e7k3dmidrn5s9ct</sha1>
    </revision>
    <revision>
      <id>3410</id>
      <parentid>3409</parentid>
      <timestamp>2025-07-12T13:32:19Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3410</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3151" sha1="n5bjy5tmmxujic2sw45xeiysltjtyoz" xml:space="preserve">[[Isimumathi:Piece of coal in front of a coal firing power plant.jpg|thumb|ilahle liphethwe mumuntu[[Isimumathi:Anthracite (coal).jpg|thumb|umhlobo welahle obizwa nge- ''Antracite'']]]]
'''Amalahle''' mamatje anzima aqinileko asetjenziswa ukubasa [[umlilo]]. Ilahle lenzeka ngeensalelo zeentjalo ezife iminyaka eziingidi eyadlulako  sabulungeka ngaphasi kwehlabathi. Ilahle lenzeka ngoma compounds we-organic ekuyi nitrogen, I carbon, i-oxygen ne sulfur. Ilahle lenzeka ngokuthi isitjalo sife sibulungeke kude ngaphasi kwehlabathi lapho  kutjhisa khona khulu begodu kuminyezekile, iiintjalo lezi zihlala iingidii zeminyaka bekufike lapho isitijalo lesi siqina khona siphenduke sibe lilahle. Kunemihlobo emine yamalahle begodu into eyanza bona amalahle ahluke kukuthi aqine kangangani&lt;ref&gt;O'Keefe, J.M., Bechtel, A., Christanis, K., Dai, S., DiMichele, W.A., Eble, C.F., Esterle, J.S., Mastalerz, M., Raymond, A.L., Valentim, B.V. and Wagner, N.J., 2013. On the fundamental difference between coal rank and coal type. ''International Journal of Coal Geology'', ''118'', pp.58-87.&lt;/ref&gt;.

=== Umhlobo yamalahle ===
1. Ilahle I Lignite

Lilahle elingakaqini lithambile. Laziwa ngelahle elinzotho, litjhiphile ukudlula woke umhlobo wamalahle ngombana alivuthi isikhathi eside. Lokho nabalithengako abantu kufanele balithenge ngobunengi ngombana liphela msinyana lokha nalibasiweko. Liyasetjenziswa lokha nakuphehlwa [[igezi]]&lt;ref&gt;Heydari, M., Rahman, M. and Gupta, R., 2015. Kinetic study and thermal decomposition behavior of lignite coal. ''International Journal of Chemical Engineering'', ''2015''(1), p.481739.&lt;/ref&gt;.

2. Ilahle I sub-bituminous

Lilahle eliphakathi ngokwenzinga lamalahle. Liphakathi kwe lahle I lignite ne lahle I-bituminous. Lilahle elingakaqini khulu,nalo liyasetjenziswa ukuphehla igezi Kanye nemafemini amanye.

3. Ilahle I Bituminous

Lilahle eliqinileko, elizele nge -''carbon'' lisetjenziswa  ukwenza iinsimbi nokutjhisa ezinye izinto zemakhaya. Ilahle leli aliduri khulu ukudlula i-Antracite. Lisetjenziswa khulu emafemini lapho kwenziwa khona isamende, namaphepha. Liyasetjenziswa nokususa ukusilaphazeka kwe iron- ore.

4. Antracite 

Lilahle eliqine khulu ukuwadlula woke, lizele nge carbon. Lisetjenziswe emafemini. Ilahle likhipha umtjhiso omkhulu  ukudlula amalahle woke. Lithatha isikhathi ukubamba umlilo kodwana kodwana nasele liwubambile livutha kabuthaka beliyokuphela&lt;ref&gt;O'Keefe, J.M., Bechtel, A., Christanis, K., Dai, S., DiMichele, W.A., Eble, C.F., Esterle, J.S., Mastalerz, M., Raymond, A.L., Valentim, B.V. and Wagner, N.J., 2013. On the fundamental difference between coal rank and coal type. ''International Journal of Coal Geology'', ''118'', pp.58-87.&lt;/ref&gt;. 

=== Umsebenzi wamalahle ovamileko ===
Lisetjenziswa emakhaya ukubasela intovu nalokha kubaswa inyama. Isetjenziswa njengesibaseli  emafemini lapho kwenziwa khona  iinsimbi. Liqakatheke khulu ngokuthi liyasetjenziswa ukuphehla igezi.Nanyana  amalahle aqakathekile kodwan intuthu yawo isilaqphaza ibhoduloko.Kufanele abantu bangawa  sebenzisi khulu nofana kufuze batjale imithi eminengi ukuze  idose I carbon ekhutjhwa malahle

== Iinkomba ==</text>
      <sha1>n5bjy5tmmxujic2sw45xeiysltjtyoz</sha1>
    </revision>
    <revision>
      <id>5065</id>
      <parentid>3410</parentid>
      <timestamp>2025-08-07T18:26:01Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>5065</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3222" sha1="i6sykxac7g8cyso6avp0irzto9ahjim" xml:space="preserve">[[Isimumathi:Piece of coal in front of a coal firing power plant.jpg|thumb|ilahle liphethwe mumuntu[[Isimumathi:Anthracite (coal).jpg|thumb|umhlobo welahle obizwa nge- ''Antracite'']]]]
'''Amalahle''' mamatje anzima aqinileko asetjenziswa ukubasa [[umlilo]]. Ilahle lenzeka ngeensalelo zeentjalo ezife iminyaka eziingidi eyadlulako  sabulungeka ngaphasi kwehlabathi. Ilahle lenzeka ngoma compounds we-organic ekuyi nitrogen, I carbon, i-oxygen ne sulfur. Ilahle lenzeka ngokuthi isitjalo sife sibulungeke kude ngaphasi kwehlabathi lapho  kutjhisa khona khulu begodu kuminyezekile, iiintjalo lezi zihlala iingidii zeminyaka bekufike lapho isitijalo lesi siqina khona siphenduke sibe lilahle. Kunemihlobo emine yamalahle begodu into eyanza bona amalahle ahluke kukuthi aqine kangangani&lt;ref&gt;O'Keefe, J.M., Bechtel, A., Christanis, K., Dai, S., DiMichele, W.A., Eble, C.F., Esterle, J.S., Mastalerz, M., Raymond, A.L., Valentim, B.V. and Wagner, N.J., 2013. On the fundamental difference between coal rank and coal type. ''International Journal of Coal Geology'', ''118'', pp.58-87.&lt;/ref&gt;.

=== Umhlobo yamalahle ===
1. Ilahle I Lignite

Lilahle elingakaqini lithambile. Laziwa ngelahle elinzotho, litjhiphile ukudlula woke umhlobo wamalahle ngombana alivuthi isikhathi eside. Lokho nabalithengako abantu kufanele balithenge ngobunengi ngombana liphela msinyana lokha nalibasiweko. Liyasetjenziswa lokha nakuphehlwa [[igezi]]&lt;ref&gt;Heydari, M., Rahman, M. and Gupta, R., 2015. Kinetic study and thermal decomposition behavior of lignite coal. ''International Journal of Chemical Engineering'', ''2015''(1), p.481739.&lt;/ref&gt;.

2. Ilahle I sub-bituminous

Lilahle eliphakathi ngokwenzinga lamalahle. Liphakathi kwe lahle I lignite ne lahle I-bituminous. Lilahle elingakaqini khulu,nalo liyasetjenziswa ukuphehla igezi Kanye nemafemini amanye.

3. Ilahle I Bituminous

Lilahle eliqinileko, elizele nge -''carbon'' lisetjenziswa  ukwenza iinsimbi nokutjhisa ezinye izinto zemakhaya. Ilahle leli aliduri khulu ukudlula i-Antracite. Lisetjenziswa khulu emafemini lapho kwenziwa khona isamende, namaphepha. Liyasetjenziswa nokususa ukusilaphazeka kwe iron- ore.

4. Antracite 

Lilahle eliqine khulu ukuwadlula woke, lizele nge carbon. Lisetjenziswe emafemini. Ilahle likhipha umtjhiso omkhulu  ukudlula amalahle woke. Lithatha isikhathi ukubamba umlilo kodwana kodwana nasele liwubambile livutha kabuthaka beliyokuphela&lt;ref&gt;O'Keefe, J.M., Bechtel, A., Christanis, K., Dai, S., DiMichele, W.A., Eble, C.F., Esterle, J.S., Mastalerz, M., Raymond, A.L., Valentim, B.V. and Wagner, N.J., 2013. On the fundamental difference between coal rank and coal type. ''International Journal of Coal Geology'', ''118'', pp.58-87.&lt;/ref&gt;. 

=== Umsebenzi wamalahle ovamileko ===
Lisetjenziswa emakhaya ukubasela intovu nalokha kubaswa inyama. Isetjenziswa njengesibaseli  emafemini lapho kwenziwa khona  iinsimbi. Liqakatheke khulu ngokuthi liyasetjenziswa ukuphehla igezi.Nanyana  amalahle aqakathekile kodwan intuthu yawo isilaqphaza ibhoduloko.Kufanele abantu bangawa  sebenzisi khulu nofana kufuze batjale imithi eminengi ukuze  idose I carbon ekhutjhwa malahle

== Iinkomba ==
[[Category:Amalahle]]
[[Category:Ukuphehla igezi]]
[[Category:Umlilo]]</text>
      <sha1>i6sykxac7g8cyso6avp0irzto9ahjim</sha1>
    </revision>
  </page>
  <page>
    <title>Ukukhukhuleka kwehlabathi</title>
    <ns>0</ns>
    <id>485</id>
    <revision>
      <id>2470</id>
      <timestamp>2025-02-26T09:51:54Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Ukukhukhuleka kwehlabathi == '''Ukukhukhuleka kwehlabathi''' kukulokha ihlabathi isuka endaweni yinye iye kwenye indawo ngesibanga sezenzo zabantu nofana ngenca yezenzo zemvelo. Ukukhukhuleka kwehlabati kumraro webhoduluko enganamthelela phezu kwehlabathi kwaphela kodwana naphezu kwazo zoke izinto ezikhona ephasini&lt;ref&gt;Nearing, M.A., Lane, L.J. and Lopes, V.L., 2017. Modeling soil erosion. In ''Soil erosion research methods'' (pp. 127-158). Routledge.&lt;/ref&gt;.  == Izint...&quot;</comment>
      <origin>2470</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3343" sha1="ogjd7ckhoj61wmb7g2m2ntzmdlegg1n" xml:space="preserve">== Ukukhukhuleka kwehlabathi ==
'''Ukukhukhuleka kwehlabathi''' kukulokha ihlabathi isuka endaweni yinye iye kwenye indawo ngesibanga sezenzo zabantu nofana ngenca yezenzo zemvelo. Ukukhukhuleka kwehlabati kumraro webhoduluko enganamthelela phezu kwehlabathi kwaphela kodwana naphezu kwazo zoke izinto ezikhona ephasini&lt;ref&gt;Nearing, M.A., Lane, L.J. and Lopes, V.L., 2017. Modeling soil erosion. In ''Soil erosion research methods'' (pp. 127-158). Routledge.&lt;/ref&gt;.

== Izinto ezibangela ukukhukhuleka kwehlabathi? ==

=== 1.Inkhukhula zamanzi ===
Lokha izulu naline khulu ngeenkhukhula lingabangela bona ihlabathi igcine ikhukhula mamanzi amanengi iyokujama kwenye indawo.

=== 2.Umoya omkhulu ===
Umoya onamandla ugcina sele udobha ingcetjhana zehlabathi  uzikhukhulele kwenye indawo.
Ukusikwa kwemithi
Ukusikwa kwemithi neentjalo kungabangela ukukhuleka  kwehlabathi njengombana imiraho yemithi ibamba ihlabathi.

=== 3.Ukwakhiwa kwemizi nokusikwa kweenhlahla ===
Ukwakhiwa kwezindlu neminye imakhiwo efana neendlela yeemodere ingabangela ukukhukhuleka kwehlabathi ngombana kuyagujwa kukhitjhwa ihlabathi begodu  neetjalo zemvelo ezimile  lapho ezibambe ihlabathi ziyasuswa&lt;ref&gt;Kavian, A., Azmoodeh, A. and Solaimani, K., 2014. Deforestation effects on soil properties, runoff and erosion in northern Iran. ''Arabian Journal of Geosciences'', ''7'', pp.1941-1950.&lt;/ref&gt;.

== Imiphumela yokukhukhuleka kwehlabathi ==
Ukukhukhuleka kwehlabathi kungaba nemiphumela emimbi phezu kwebhoduluko

=== 1. ukulahlekelwa yihlabathi enothileko ===
Lokha ihlabathi nayikhukhulekako kungakhamba ihlabathi enothileko esetjenziswela ukutjala inthelo nemirorho. Intjalo lezi ngekhe zisa khula ngendlela afanelo lokha ihlabathi le nayikhukhulekileko&lt;ref&gt;Pimentel, D. and Burgess, M., 2013. Soil erosion threatens food production. ''Agriculture'', ''3''(3), pp.443-463.&lt;/ref&gt;&lt;ref&gt;Jiao, J., Zou, H., Jia, Y. and Wang, N., 2009. Research progress on the effects of soil erosion on vegetation. ''Acta Ecologica Sinica'', ''29''(2), pp.85-91.&lt;/ref&gt;.

=== 2. Ukusilaphazeka kwamanzi ===
Enye ihlabathi ekhukhulekako ikhamba iyokujama endaweni ezinamanzi ezifana nemlanjeni, bese ifike izale lapho kusilaphazeke amanzi ebawalanzekile azale ngebathi nofana idaka.

=== 3. ukulahlekelwa kuhlukahlukana kweenlwana ===
Nakukhukhuleka ihlabathi indawo ezinengi zokuhlala zeenlwana zingamotjheka. Lokhu nakho kuzokwenza bona iinlwana lezo zife ngombana zabe zingasenazo indawo zokuzifihla nofana zokuhlala. Isibonelo: Ezinye iinlwan zihlala ngpahasi kwehlathi emgodini lokha ihlabathi akhukhulekako imigodi le ingamtjheka bese inlwana zingabi nedawo yokuzifihla.

== Singehlisa njani ukukhukhulekak kwehlabathi? ==
Kufanele siphinde sitjale endaweni lapho kukhukhuleke khona ihlabathi ukwenzela bona lena eseleko ibambe imirabho ingasakhukhuleki ukuya phambili. Kufanele abantu behlise izinga lokusika imithi ngombana lokho kuzokulekelela ihlabathi ingakhukhuleki ngesibanga sokuthi izabe ibanjwe mirabho yeenhlahla.

== Isiphetho ==
Ukukhukhuleka kwehlabathi kumraro omkhulu webhoduluko, begodu kufuze bona ucalelelwe usese nekhathi ngombana nangabe awuka tjhejwa singalahlekelwa yihlabathi enothileko, amanzi ahlanzekileko nokwahlukahlukana kweenlwana ezihlala kubhoduluko yekhethu. Kufanele bona abantu babalekele ukwenza imisebenzi eyenza bona ihlabathi  ikhukhuleke.</text>
      <sha1>ogjd7ckhoj61wmb7g2m2ntzmdlegg1n</sha1>
    </revision>
    <revision>
      <id>2474</id>
      <parentid>2470</parentid>
      <timestamp>2025-02-28T20:06:15Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2474</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3673" sha1="mwnilyiy5ufya0cvvyysxg1johuv0yq" xml:space="preserve">== Ukukhukhuleka kwehlabathi ==
'''Ukukhukhuleka kwehlabathi''' kukulokha ihlabathi isuka endaweni yinye iye kwenye indawo ngesibanga sezenzo zabantu nofana ngenca yezenzo zemvelo. Ukukhukhuleka kwehlabati kumraro webhoduluko enganamthelela phezu kwehlabathi kwaphela kodwana naphezu kwazo zoke izinto ezikhona ephasini&lt;ref&gt;Nearing, M.A., Lane, L.J. and Lopes, V.L., 2017. Modeling soil erosion. In ''Soil erosion research methods'' (pp. 127-158). Routledge.&lt;/ref&gt;.

== Izinto ezibangela ukukhukhuleka kwehlabathi? ==

=== 1.Inkhukhula zamanzi ===
[[Isimumathi:Umgodi osendleleni obangwe lizulu elinamandla ezikhukhule ihlabathi endleleni kwagcina kunomgodi njenganje iimodere zibanobudisi bokudlula endleleni le.jpg|thumb|Umgodi osendleleni obangwe lizulu elinamandla lakhukhula ihlabathi endleleni kwagcina kunomgodi  njenganje iimodere zibanobudisi bokudlula endleleni le.]]
Lokha izulu naline khulu ngeenkhukhula lingabangela bona ihlabathi igcine ikhukhula mamanzi amanengi iyokujama kwenye indawo.

=== 2.Umoya omkhulu ===
Umoya onamandla ugcina sele udobha ingcetjhana zehlabathi  uzikhukhulele kwenye indawo.
Ukusikwa kwemithi
Ukusikwa kwemithi neentjalo kungabangela ukukhuleka  kwehlabathi njengombana imiraho yemithi ibamba ihlabathi.

=== 3.Ukwakhiwa kwemizi nokusikwa kweenhlahla ===
Ukwakhiwa kwezindlu neminye imakhiwo efana neendlela yeemodere ingabangela ukukhukhuleka kwehlabathi ngombana kuyagujwa kukhitjhwa ihlabathi begodu  neetjalo zemvelo ezimile  lapho ezibambe ihlabathi ziyasuswa&lt;ref&gt;Kavian, A., Azmoodeh, A. and Solaimani, K., 2014. Deforestation effects on soil properties, runoff and erosion in northern Iran. ''Arabian Journal of Geosciences'', ''7'', pp.1941-1950.&lt;/ref&gt;.

== Imiphumela yokukhukhuleka kwehlabathi ==
Ukukhukhuleka kwehlabathi kungaba nemiphumela emimbi phezu kwebhoduluko

=== 1. ukulahlekelwa yihlabathi enothileko ===
Lokha ihlabathi nayikhukhulekako kungakhamba ihlabathi enothileko esetjenziswela ukutjala inthelo nemirorho. Intjalo lezi ngekhe zisa khula ngendlela afanelo lokha ihlabathi le nayikhukhulekileko&lt;ref&gt;Pimentel, D. and Burgess, M., 2013. Soil erosion threatens food production. ''Agriculture'', ''3''(3), pp.443-463.&lt;/ref&gt;&lt;ref&gt;Jiao, J., Zou, H., Jia, Y. and Wang, N., 2009. Research progress on the effects of soil erosion on vegetation. ''Acta Ecologica Sinica'', ''29''(2), pp.85-91.&lt;/ref&gt;.

=== 2. Ukusilaphazeka kwamanzi ===
Enye ihlabathi ekhukhulekako ikhamba iyokujama endaweni ezinamanzi ezifana nemlanjeni, bese ifike izale lapho kusilaphazeke amanzi ebawalanzekile azale ngebathi nofana idaka.

=== 3. ukulahlekelwa kuhlukahlukana kweenlwana ===
Nakukhukhuleka ihlabathi indawo ezinengi zokuhlala zeenlwana zingamotjheka. Lokhu nakho kuzokwenza bona iinlwana lezo zife ngombana zabe zingasenazo indawo zokuzifihla nofana zokuhlala. Isibonelo: Ezinye iinlwan zihlala ngpahasi kwehlathi emgodini lokha ihlabathi akhukhulekako imigodi le ingamtjheka bese inlwana zingabi nedawo yokuzifihla.

== Singehlisa njani ukukhukhulekak kwehlabathi? ==
Kufanele siphinde sitjale endaweni lapho kukhukhuleke khona ihlabathi ukwenzela bona lena eseleko ibambe imirabho ingasakhukhuleki ukuya phambili. Kufanele abantu behlise izinga lokusika imithi ngombana lokho kuzokulekelela ihlabathi ingakhukhuleki ngesibanga sokuthi izabe ibanjwe mirabho yeenhlahla.

== Isiphetho ==
Ukukhukhuleka kwehlabathi kumraro omkhulu webhoduluko, begodu kufuze bona ucalelelwe usese nekhathi ngombana nangabe awuka tjhejwa singalahlekelwa yihlabathi enothileko, amanzi ahlanzekileko nokwahlukahlukana kweenlwana ezihlala kubhoduluko yekhethu. Kufanele bona abantu babalekele ukwenza imisebenzi eyenza bona ihlabathi  ikhukhuleke.</text>
      <sha1>mwnilyiy5ufya0cvvyysxg1johuv0yq</sha1>
    </revision>
    <revision>
      <id>3024</id>
      <parentid>2474</parentid>
      <timestamp>2025-06-06T20:31:38Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>no</comment>
      <origin>3024</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3761" sha1="sz5xcscmzkqxyd5eyqaho1cu11enq6w" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.'''

== Ukukhukhuleka kwehlabathi ==
'''Ukukhukhuleka kwehlabathi''' kukulokha ihlabathi isuka endaweni yinye iye kwenye indawo ngesibanga sezenzo zabantu nofana ngenca yezenzo zemvelo. Ukukhukhuleka kwehlabati kumraro webhoduluko enganamthelela phezu kwehlabathi kwaphela kodwana naphezu kwazo zoke izinto ezikhona ephasini&lt;ref&gt;Nearing, M.A., Lane, L.J. and Lopes, V.L., 2017. Modeling soil erosion. In ''Soil erosion research methods'' (pp. 127-158). Routledge.&lt;/ref&gt;.

== Izinto ezibangela ukukhukhuleka kwehlabathi? ==

=== 1.Inkhukhula zamanzi ===
[[Isimumathi:Umgodi osendleleni obangwe lizulu elinamandla ezikhukhule ihlabathi endleleni kwagcina kunomgodi njenganje iimodere zibanobudisi bokudlula endleleni le.jpg|thumb|Umgodi osendleleni obangwe lizulu elinamandla lakhukhula ihlabathi endleleni kwagcina kunomgodi  njenganje iimodere zibanobudisi bokudlula endleleni le.]]
Lokha izulu naline khulu ngeenkhukhula lingabangela bona ihlabathi igcine ikhukhula mamanzi amanengi iyokujama kwenye indawo.

=== 2.Umoya omkhulu ===
Umoya onamandla ugcina sele udobha ingcetjhana zehlabathi  uzikhukhulele kwenye indawo.
Ukusikwa kwemithi
Ukusikwa kwemithi neentjalo kungabangela ukukhuleka  kwehlabathi njengombana imiraho yemithi ibamba ihlabathi.

=== 3.Ukwakhiwa kwemizi nokusikwa kweenhlahla ===
Ukwakhiwa kwezindlu neminye imakhiwo efana neendlela yeemodere ingabangela ukukhukhuleka kwehlabathi ngombana kuyagujwa kukhitjhwa ihlabathi begodu  neetjalo zemvelo ezimile  lapho ezibambe ihlabathi ziyasuswa&lt;ref&gt;Kavian, A., Azmoodeh, A. and Solaimani, K., 2014. Deforestation effects on soil properties, runoff and erosion in northern Iran. ''Arabian Journal of Geosciences'', ''7'', pp.1941-1950.&lt;/ref&gt;.

== Imiphumela yokukhukhuleka kwehlabathi ==
Ukukhukhuleka kwehlabathi kungaba nemiphumela emimbi phezu kwebhoduluko

=== 1. ukulahlekelwa yihlabathi enothileko ===
Lokha ihlabathi nayikhukhulekako kungakhamba ihlabathi enothileko esetjenziswela ukutjala inthelo nemirorho. Intjalo lezi ngekhe zisa khula ngendlela afanelo lokha ihlabathi le nayikhukhulekileko&lt;ref&gt;Pimentel, D. and Burgess, M., 2013. Soil erosion threatens food production. ''Agriculture'', ''3''(3), pp.443-463.&lt;/ref&gt;&lt;ref&gt;Jiao, J., Zou, H., Jia, Y. and Wang, N., 2009. Research progress on the effects of soil erosion on vegetation. ''Acta Ecologica Sinica'', ''29''(2), pp.85-91.&lt;/ref&gt;.

=== 2. Ukusilaphazeka kwamanzi ===
Enye ihlabathi ekhukhulekako ikhamba iyokujama endaweni ezinamanzi ezifana nemlanjeni, bese ifike izale lapho kusilaphazeke amanzi ebawalanzekile azale ngebathi nofana idaka.

=== 3. ukulahlekelwa kuhlukahlukana kweenlwana ===
Nakukhukhuleka ihlabathi indawo ezinengi zokuhlala zeenlwana zingamotjheka. Lokhu nakho kuzokwenza bona iinlwana lezo zife ngombana zabe zingasenazo indawo zokuzifihla nofana zokuhlala. Isibonelo: Ezinye iinlwan zihlala ngpahasi kwehlathi emgodini lokha ihlabathi akhukhulekako imigodi le ingamtjheka bese inlwana zingabi nedawo yokuzifihla.

== Singehlisa njani ukukhukhulekak kwehlabathi? ==
Kufanele siphinde sitjale endaweni lapho kukhukhuleke khona ihlabathi ukwenzela bona lena eseleko ibambe imirabho ingasakhukhuleki ukuya phambili. Kufanele abantu behlise izinga lokusika imithi ngombana lokho kuzokulekelela ihlabathi ingakhukhuleki ngesibanga sokuthi izabe ibanjwe mirabho yeenhlahla.

== Isiphetho ==
Ukukhukhuleka kwehlabathi kumraro omkhulu webhoduluko, begodu kufuze bona ucalelelwe usese nekhathi ngombana nangabe awuka tjhejwa singalahlekelwa yihlabathi enothileko, amanzi ahlanzekileko nokwahlukahlukana kweenlwana ezihlala kubhoduluko yekhethu. Kufanele bona abantu babalekele ukwenza imisebenzi eyenza bona ihlabathi  ikhukhuleke.</text>
      <sha1>sz5xcscmzkqxyd5eyqaho1cu11enq6w</sha1>
    </revision>
    <revision>
      <id>3054</id>
      <parentid>3024</parentid>
      <timestamp>2025-06-07T03:05:22Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Nqobile69|Nqobile69]]</comment>
      <origin>2474</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3673" sha1="mwnilyiy5ufya0cvvyysxg1johuv0yq" xml:space="preserve">== Ukukhukhuleka kwehlabathi ==
'''Ukukhukhuleka kwehlabathi''' kukulokha ihlabathi isuka endaweni yinye iye kwenye indawo ngesibanga sezenzo zabantu nofana ngenca yezenzo zemvelo. Ukukhukhuleka kwehlabati kumraro webhoduluko enganamthelela phezu kwehlabathi kwaphela kodwana naphezu kwazo zoke izinto ezikhona ephasini&lt;ref&gt;Nearing, M.A., Lane, L.J. and Lopes, V.L., 2017. Modeling soil erosion. In ''Soil erosion research methods'' (pp. 127-158). Routledge.&lt;/ref&gt;.

== Izinto ezibangela ukukhukhuleka kwehlabathi? ==

=== 1.Inkhukhula zamanzi ===
[[Isimumathi:Umgodi osendleleni obangwe lizulu elinamandla ezikhukhule ihlabathi endleleni kwagcina kunomgodi njenganje iimodere zibanobudisi bokudlula endleleni le.jpg|thumb|Umgodi osendleleni obangwe lizulu elinamandla lakhukhula ihlabathi endleleni kwagcina kunomgodi  njenganje iimodere zibanobudisi bokudlula endleleni le.]]
Lokha izulu naline khulu ngeenkhukhula lingabangela bona ihlabathi igcine ikhukhula mamanzi amanengi iyokujama kwenye indawo.

=== 2.Umoya omkhulu ===
Umoya onamandla ugcina sele udobha ingcetjhana zehlabathi  uzikhukhulele kwenye indawo.
Ukusikwa kwemithi
Ukusikwa kwemithi neentjalo kungabangela ukukhuleka  kwehlabathi njengombana imiraho yemithi ibamba ihlabathi.

=== 3.Ukwakhiwa kwemizi nokusikwa kweenhlahla ===
Ukwakhiwa kwezindlu neminye imakhiwo efana neendlela yeemodere ingabangela ukukhukhuleka kwehlabathi ngombana kuyagujwa kukhitjhwa ihlabathi begodu  neetjalo zemvelo ezimile  lapho ezibambe ihlabathi ziyasuswa&lt;ref&gt;Kavian, A., Azmoodeh, A. and Solaimani, K., 2014. Deforestation effects on soil properties, runoff and erosion in northern Iran. ''Arabian Journal of Geosciences'', ''7'', pp.1941-1950.&lt;/ref&gt;.

== Imiphumela yokukhukhuleka kwehlabathi ==
Ukukhukhuleka kwehlabathi kungaba nemiphumela emimbi phezu kwebhoduluko

=== 1. ukulahlekelwa yihlabathi enothileko ===
Lokha ihlabathi nayikhukhulekako kungakhamba ihlabathi enothileko esetjenziswela ukutjala inthelo nemirorho. Intjalo lezi ngekhe zisa khula ngendlela afanelo lokha ihlabathi le nayikhukhulekileko&lt;ref&gt;Pimentel, D. and Burgess, M., 2013. Soil erosion threatens food production. ''Agriculture'', ''3''(3), pp.443-463.&lt;/ref&gt;&lt;ref&gt;Jiao, J., Zou, H., Jia, Y. and Wang, N., 2009. Research progress on the effects of soil erosion on vegetation. ''Acta Ecologica Sinica'', ''29''(2), pp.85-91.&lt;/ref&gt;.

=== 2. Ukusilaphazeka kwamanzi ===
Enye ihlabathi ekhukhulekako ikhamba iyokujama endaweni ezinamanzi ezifana nemlanjeni, bese ifike izale lapho kusilaphazeke amanzi ebawalanzekile azale ngebathi nofana idaka.

=== 3. ukulahlekelwa kuhlukahlukana kweenlwana ===
Nakukhukhuleka ihlabathi indawo ezinengi zokuhlala zeenlwana zingamotjheka. Lokhu nakho kuzokwenza bona iinlwana lezo zife ngombana zabe zingasenazo indawo zokuzifihla nofana zokuhlala. Isibonelo: Ezinye iinlwan zihlala ngpahasi kwehlathi emgodini lokha ihlabathi akhukhulekako imigodi le ingamtjheka bese inlwana zingabi nedawo yokuzifihla.

== Singehlisa njani ukukhukhulekak kwehlabathi? ==
Kufanele siphinde sitjale endaweni lapho kukhukhuleke khona ihlabathi ukwenzela bona lena eseleko ibambe imirabho ingasakhukhuleki ukuya phambili. Kufanele abantu behlise izinga lokusika imithi ngombana lokho kuzokulekelela ihlabathi ingakhukhuleki ngesibanga sokuthi izabe ibanjwe mirabho yeenhlahla.

== Isiphetho ==
Ukukhukhuleka kwehlabathi kumraro omkhulu webhoduluko, begodu kufuze bona ucalelelwe usese nekhathi ngombana nangabe awuka tjhejwa singalahlekelwa yihlabathi enothileko, amanzi ahlanzekileko nokwahlukahlukana kweenlwana ezihlala kubhoduluko yekhethu. Kufanele bona abantu babalekele ukwenza imisebenzi eyenza bona ihlabathi  ikhukhuleke.</text>
      <sha1>mwnilyiy5ufya0cvvyysxg1johuv0yq</sha1>
    </revision>
  </page>
  <page>
    <title>Umazisi</title>
    <ns>0</ns>
    <id>486</id>
    <revision>
      <id>2471</id>
      <timestamp>2025-02-26T10:01:32Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Umazisi == '''Umazisi''' kuyincwaddi encani nofana ikhadi elincani elisebenza njengobufakazi bokuthi ungubani. Leli ikhadi kulikhadi eliqakathekileko ngombana liphethe imininingwana ngomuntu ekumabizo wakhe apheleleko, isibongo sakhe,  ilanga nonyaka abelethwa ngawo, inomboro yakhe kamazisi, inarha asisakhamuzi kiyo begodu ne-adresi yakhe&lt;ref&gt;Van der Straaten, J., 2019. South Africa ID Case Study. ''World Bank Group''.&lt;/ref&gt;  == Ukuqakatheka kuka mazisi == Umazisi uqa...&quot;</comment>
      <origin>2471</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1840" sha1="lp7st4ye6fcgd2d4kbz0lkigk5qbtvc" xml:space="preserve">== Umazisi ==
'''Umazisi''' kuyincwaddi encani nofana ikhadi elincani elisebenza njengobufakazi bokuthi ungubani. Leli ikhadi kulikhadi eliqakathekileko ngombana liphethe imininingwana ngomuntu ekumabizo wakhe apheleleko, isibongo sakhe,  ilanga nonyaka abelethwa ngawo, inomboro yakhe kamazisi, inarha asisakhamuzi kiyo begodu ne-adresi yakhe&lt;ref&gt;Van der Straaten, J., 2019. South Africa ID Case Study. ''World Bank Group''.&lt;/ref&gt;

== Ukuqakatheka kuka mazisi ==
Umazisi uqakatheke mgombana ukhombisa boan umuntu uyaphila, ungubani begodu sisakaha muzi sakuyiphi indawo nofana sakuyiphi inarha Ukulekelela umuntu bona akghone ukuthola izinto zasimahla ezisemalungelweni wakhe njesakhamuzi senarha ehlala kiyo. Isbonelo ifundo, umthola pilo karhulumende begodu akghone nokuthola iimbonelelo  zemali ezivela kurhulumende ukusiza labo abatlhogako.Ilekelela umuntu bona akghone ukuvakatjhela amanye amazwe nofana iiinarha ngombana lokha nawuno mazisi ukghona ukwenza iphepha lokungena kwamanye amazwe nofana inarha.

== Imisebenzi kamazisi ==

=== Ukuthola msebenzi ===
Lokha nawufaka isibawo sokufuna umsebenzi into yokuthoma efanele ube nayo ngumazisi. Nalokha uthole umsebenzi kufuze bona ulethe umazisi ukuze lapho bakucasitjhe khona bakghone ukuqinisekisa bona uguye ngokweqiniso umutu ebamqatjhileko na.

=== Amakhetho ===
Enarheni ezinengi umazisi kuyincwadi efunekako ukze umuntu akghone ukusebebzisa ilungelo lakhe lokuzibandakanya emakhethweni. Lokhu kuletha isithunzi emakhethweni wenye nenye inarha&lt;ref&gt;Yavuz, E., Koç, A.K., Çabuk, U.C. and Dalkılıç, G., 2018, March. Towards secure e-voting using ethereum blockchain. In ''2018 6th International Symposium on Digital Forensic and Security (ISDFS)'' (pp. 1-7). IEEE.&lt;/ref&gt;.

== Imihlobo kamazisi ==
1. Ikhadi

2. I-Passport

3. Iphepha lokutjhayela

4. isitifikedi samabeletho</text>
      <sha1>lp7st4ye6fcgd2d4kbz0lkigk5qbtvc</sha1>
    </revision>
  </page>
  <page>
    <title>Ukulova kwabantu eenkolweni</title>
    <ns>0</ns>
    <id>487</id>
    <revision>
      <id>2472</id>
      <timestamp>2025-02-26T10:13:34Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Ukulova kwabafundi esikolweni == '''Ukulova kwabafundi''' kukulokha abafundi becisa amalanga abangayi esikolweni bahlale emakhabo ngeenzathu ezahlukahlukeneko. Isenzo lesi sinomthelela omumbi eemfundweni zabafundi&lt;ref&gt;Kearney, C.A., 2008. School absenteeism and school refusal behavior in youth: A contemporary review. ''Clinical psychology review'', ''28''(3), pp.451-471.&lt;/ref&gt;.  === Izinto ezibangela ukulova kwabafundi ===  === Ukugula === Ukugula kuyinto ejwayelekile...&quot;</comment>
      <origin>2472</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3556" sha1="oin2v3w56yzz1g642mbliyzt733fumi" xml:space="preserve">== Ukulova kwabafundi esikolweni ==
'''Ukulova kwabafundi''' kukulokha abafundi becisa amalanga abangayi esikolweni bahlale emakhabo ngeenzathu ezahlukahlukeneko. Isenzo lesi sinomthelela omumbi eemfundweni zabafundi&lt;ref&gt;Kearney, C.A., 2008. School absenteeism and school refusal behavior in youth: A contemporary review. ''Clinical psychology review'', ''28''(3), pp.451-471.&lt;/ref&gt;.

=== Izinto ezibangela ukulova kwabafundi ===

=== Ukugula ===
Ukugula kuyinto ejwayelekileko eyenza bona abafundi balove amalanga esikolweni, begodu kusizathu esizwakalako. Lokhu kungesibanga sokuthi lokha nawugulako angekhe wafunda kamnandi nawungazizwa kuhle emzimbeni.

=== Ukuhlunyezwa ===
Ukuhlukunyezwa bafundi ofunda naba ngekumbeni yokufundela kungenza bona umfundi agandeleleke ngokomkhumbulo agcine sele azizwa angakamukelelki esikolweni bese agcine sele alova. 

=== Ukungathandi isikolo ===
Abanye abafundi baphuma emakhayeni lapho ifundo ingathathelwa phezulu khona begodu lokhu kungenza bona bangakuboni ukuqakatheka kwefundo begodu balove ngesibanga sokuthi nanoma bangayi esikolweni akekho umuntu ozobakhuza. Abanye abatholi irhelebho ngomsebenzi wekhaya abawunikelwa matitjhere wabo bese bagcine basaba bona aatitjhere wabo azabakhalima kabuhlungu ngokungabhali bese bagcine balova.

=== Imiraro yomndeni ===
Abanye abantwana bayalova esikolweni lokha nakumoraro ekhaya ngombana imraro le ingabenza bona bangabi sebujamei obuhle ngokomkhumbulo. Isibinelo ukuhlongakalelwa babalethi ekungibo abakulingisela izinto zokuza esikolweni&lt;ref&gt;Sahin, S., Arseven, Z. and Kiliç, A., 2016. Causes of Student Absenteeism and School Dropouts. ''International Journal of Instruction'', ''9''(1), pp.195-210.&lt;/ref&gt;

== Imiphumela yokulova esikolweni ==

=== Ukuthola imiphumela emimbi ===
Lokha umfundi nakalova khulu esikolweni ugcina alahlekelwa mathuba amanengi wokufunda bese lokhu kugcine kwenza bona athole imiphumela emimbi. Isenzo lesi sibangelwa kukuthi kunengi lokhu umfundi asuke angakakufundi lokha nakalovako&lt;ref&gt;Garcia, E. and Weiss, E., 2018. Student absenteeism: who misses school and how missing school matters for performance. ''Economic Policy Institute''.&lt;/ref&gt;.

=== Ukuzikhupha hlangana nabanye abafundi ===
Umfundi lovako esikolweni ugcina see azikhetha nofana azikhupha hlangana nabanye abafandi ngombana azizwe angafani nabo. Umfundi olovako uba nobidisi lokwenza abudlelwano nabafundi afunda nabo.

=== Ukulisa isikolo ===
Abanye abafundi nabalova khuku begodu kunganamuntu obakhuzako nofana obakhuthazako bona baye esikolweni bagcina sele balisa isikolo unomphela bagcine bangafundi.

== Iindlela zokwehlisa ukulova eenkolweni ==

=== Ukwenza bona abantwana bathabele ukufunda ===
Kumsebenzi katitjhere ukwenza bona umfundi  athabele ukufunda. Lokhu kwenza umfundi akhuthalele ukuza esikolweni ngombana uzabe athabela ukufunda etlasini leli afunda kilo.

=== Ukuba nobudlelwana abantwana ===
Utitjhere kubafanele abe nobuldlellwana nabafundi bakhe lokhu kuzokusiza boina abafundi bakhone ukukhuluma naye naye lokha nakuzinto ezingabaphathi kuhle ngetlasini. Izinto ezifana nokuth kunofundi obahlukumezako mgetlasini begodu bakhone nokukhuluma lokha nakuneno eyenza bona babe nesitjhijilo sokuza esikolweni.

=== Ungenelela lokha Umntwana nakalova khulu ===
Utitjhere atjheje iphetheni umfundi alova ngayo, nangabe sele iyimb khulu kufuze bona utitjhere enze irhubhululo lokobana kubangelwa yini lokho bese eze neensobululo zokulekelela umfundi ukuthi angasalova khulu. Kufanele utitjhere akwenze lokhu ngokusebenzisana nababelethi bomntwana.</text>
      <sha1>oin2v3w56yzz1g642mbliyzt733fumi</sha1>
    </revision>
  </page>
  <page>
    <title>Ukutlola</title>
    <ns>0</ns>
    <id>488</id>
    <revision>
      <id>2475</id>
      <timestamp>2025-03-03T09:31:26Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Ukutlola == '''Ukutlola''' kuyinto eqakathekileko ngombana kungenye yeendlela abantu abayisebenzisako ukuveza imicabango wabo&lt;ref&gt;Hyland, K., 2015. ''Teaching and researching writing''. Routledge.&lt;/ref&gt;. Ukutlola kuyinto eyathoma ekadeni. Ukutlola kufaka ukusebenzisa amathswayo afana namaledere neemboro ukuveza imibono, nemilayeza. Ukutlola kulikghono elenza bakghone ukuthintana babelane imibono nemazizo yabo emphakathini nephasini loke.  == Iingaba zokutlola == Iinga...&quot;</comment>
      <origin>2475</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2443" sha1="kvd2x07s1ynpdn7nw557ee1fg0y02ev" xml:space="preserve">== Ukutlola ==
'''Ukutlola''' kuyinto eqakathekileko ngombana kungenye yeendlela abantu abayisebenzisako ukuveza imicabango wabo&lt;ref&gt;Hyland, K., 2015. ''Teaching and researching writing''. Routledge.&lt;/ref&gt;. Ukutlola kuyinto eyathoma ekadeni. Ukutlola kufaka ukusebenzisa amathswayo afana namaledere neemboro ukuveza imibono, nemilayeza. Ukutlola kulikghono elenza bakghone ukuthintana babelane imibono nemazizo yabo emphakathini nephasini loke.

== Iingaba zokutlola ==
Iingaba zokutlola: Ukuhlela, ukutlhatlhabeja,Ukubuyekeza nokulungisa iimphoso.

=== '''Ukuhlela''' ===
Kufaka ukuveza izahu sokutloa, abantu abatlolelako, Ukuzwakala komtlolo wakho.

=== '''Ukutlhatlhabeja''' ===
Kuveza izinto eziqakathekileko ozokutlola ngazo nofana amaphuzu aqakathekileko lawo endaba enzize kiwo&lt;ref&gt;Faraj, A.K.A., 2015. Scaffolding EFL Students' Writing through the Writing Process Approach. ''Journal of Education and Practice'', ''6''(13), pp.131-141.&lt;/ref&gt;.

=== '''Ukubuyekeza''' ===
Kutho ukubuyelela utjhege bona umsebenzi wakho utloleke kuhle na nofana imitjho ihleli ngendlela enikela umqondo nofana awa.

=== '''Ukulungisa iimphoso''' ===
Ukulinga iimphose kukhambelana nokubuyekeza ngombana lokha nawubuyekekzako kufanele ulungise iimphose ezifana nokuthi ufake amatshwayo lapho kufanele khona begodu  ulingise imitjho engabumbeki begodu naleyo ensthuli umqondo wendaba kuhle&lt;ref&gt;Deni, A.R.M. and Zainal, Z.I., 2011. Peer-Editing Practice in the Writing Classroom: Benefits and Drawbacks. ''Advances in language and literary studies'', ''2''(1), pp.92-107.&lt;/ref&gt;&lt;ref&gt;Evmenova, A.S. and Regan, K., 2019. Supporting the writing process with technology for students with disabilities. ''Intervention in School and Clinic'', ''55''(2), pp.78-85.&lt;/ref&gt;.

== '''Ubuhle bokutlola''' ==
Ukutlola kwenza bona umuntu afunde ngombana lokha nakatlolako kufunze akhiphe begodu abambe imininingwane.Ukutlola kulekelela umuntu bona aveze ilwazi elidephieko ngendlela ehlelekileko begodu enembako. Ukutlola kukhuphula izinga lokucabanga mokuthintana ebantwini&lt;ref&gt;Deni, A.R.M. and Zainal, Z.I., 2011. Peer-Editing Practice in the Writing Classroom: Benefits and Drawbacks. ''Advances in language and literary studies'', ''2''(1), pp.92-107.&lt;/ref&gt;.

== '''Isiphetho''' ==
Ukutlola kuyinto eqakathekileko yokuveza imicabango, amazizo   nokwabelana ngelwazi. Kufuze abantu bazijwayeze ukutlola  ngombana lokho kuzokwenza bona bajwayele ukwethula ilwazi labo.</text>
      <sha1>kvd2x07s1ynpdn7nw557ee1fg0y02ev</sha1>
    </revision>
  </page>
  <page>
    <title>Ubuhle nobumbi bokuthi abantwana babe nabomaliledinini</title>
    <ns>0</ns>
    <id>489</id>
    <revision>
      <id>2476</id>
      <timestamp>2025-03-03T09:37:00Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Umaliledinini == '''Umaliledinini''' kuyinto esentjenziswa ukuthintana. Umaliledinini esikhathini sanke uyinto eqakatheke khulu ngombana usetjenziswa ukwenza izinto ezinengi ngapnandle kokudoselana umrhala nokuthumelana imilayezo. Absntu bakhona ukwenza thumelana imali basebenzisa umaliledinini, bakhona ukubamba imihlangan yabo yomsebenzi basebenzisa umaliledini. Esikhathini sanje ababelethi sele bthengela abantwana babo abomaliledii ngesibangasokobana bafuna ukhona u...&quot;</comment>
      <origin>2476</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="721" sha1="3maytf9hw2zrb03alraqpl6q0wznmnv" xml:space="preserve">== Umaliledinini ==
'''Umaliledinini''' kuyinto esentjenziswa ukuthintana. Umaliledinini esikhathini sanke uyinto eqakatheke khulu ngombana usetjenziswa ukwenza izinto ezinengi ngapnandle kokudoselana umrhala nokuthumelana imilayezo. Absntu bakhona ukwenza thumelana imali basebenzisa umaliledinini, bakhona ukubamba imihlangan yabo yomsebenzi basebenzisa umaliledini. Esikhathini sanje ababelethi sele bthengela abantwana babo abomaliledii ngesibangasokobana bafuna ukhona ukuthintana nabo begodu bakghone nokudlala imidlalo ngebomaliledinini.Umaliledinini uyafana nomtjhiningcondo&lt;ref&gt;Prensky, M., 2005. What can you learn from a cell phone? Almost anything!. ''Innovate: Journal of Online Education'', ''1''(5).&lt;/ref&gt;.</text>
      <sha1>3maytf9hw2zrb03alraqpl6q0wznmnv</sha1>
    </revision>
    <revision>
      <id>2477</id>
      <parentid>2476</parentid>
      <timestamp>2025-03-03T09:50:35Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2477</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3258" sha1="4bb7ywgprkpev4dr10yafal4ti2sv00" xml:space="preserve">== Umaliledinini ==
'''Umaliledinini''' kuyinto esentjenziswa ukuthintana. Umaliledinini esikhathini sanke uyinto eqakatheke khulu ngombana usetjenziswa ukwenza izinto ezinengi ngapnandle kokudoselana umrhala nokuthumelana imilayezo. Absntu bakhona ukwenza thumelana imali basebenzisa umaliledinini, bakhona ukubamba imihlangan yabo yomsebenzi basebenzisa umaliledini. Esikhathini sanje ababelethi sele bthengela abantwana babo abomaliledii ngesibangasokobana bafuna ukhona ukuthintana nabo begodu bakghone nokudlala imidlalo ngebomaliledinini.Umaliledinini uyafana nomtjhiningcondo&lt;ref&gt;Prensky, M., 2005. What can you learn from a cell phone? Almost anything!. ''Innovate: Journal of Online Education'', ''1''(5).&lt;/ref&gt;.

== '''Ubuhle''' ==

=== '''Ikghono lokusebenzisa izinto zebutheknikghe''' ===
Kuyinto ehle bonyana abantwana babe nabomaliledinini ngesibanga sokobana bafanele bazijwayeze ukuphila ephasini letjhuguluko lesine lezamabubulo bajwayele ukusebenza ngezinto zedijithali. Abantwana lokha basebenzisa abomaliledinini bakghona nokuthola ilwazi lokusebenzisa ama-AI, lokhu kungenza bona bathole umphumela omuhle esikolweni&lt;ref&gt;Valk, J.H., Rashid, A.T. and Elder, L., 2010. Using mobile phones to improve educational outcomes: An analysis of evidence from Asia. ''International Review of Research in Open and Distributed Learning'', ''11''(1), pp.117-140.&lt;/ref&gt;

=== '''Ukubulungeka''' ===
Umntwana okghona ukusebenzisa umaliledinini ukhona ukubulungeka ngombana lokho nakungenzeka bona avelelwe mraro uzokghona ukudosela ababelethi bakhe umrhala nofana adosele iinomboro zesizo eliphambili, amapholisa Kanye neencimamlilo.

== '''Ubumbi'''&lt;ref&gt;.&lt;/ref&gt; ==

=== '''Ilwazi elingaphezulu kwabo''' ===
Nanyana ukusebenzisa umaliledinini komntwana kuyinto ehle kodwana bukhona nobumbi obuveleleko engekhe babethiswa ngommoya. Ubumbi bakhona kukuthi abantwana bangagcina basebenzisa iinkundla zokuthintana bese kube kulapho bapthola khona ilwazi lepilo elingaphazulu kwabo libalimaze umkhumbulo&lt;ref&gt;O'Keeffe, G.S., Clarke-Pearson, K. and Council on Communications and Media, 2011. The impact of social media on children, adolescents, and families. ''Pediatrics'', ''127''(4), pp.800-804.&lt;/ref&gt;.

=== '''Ukungalali''' ===
Okhunye kukuthi lokha nasele bajwayele ukusebenzisa umaliledinini bangagcina sele bangasalawuleki badlale ngawo bekube sebusuku, bagcine baphathwa buthongo esikolweni ngesibanga sokuthi abalali ubuthongo obulingeneko. Isenzo esifana nalesi singabonomthelela omumbi phezu kweemfundo zomntwana agcine sele athola imiphumela emimbi&lt;ref&gt;Hale, L. and Guan, S., 2015. Screen time and sleep among school-aged children and adolescents: a systematic literature review. ''Sleep medicine reviews'', ''21'', pp.50-58.&lt;/ref&gt;.

=== '''Isiphetho''' ===
Umaliledinini kuyinto qakathekileko esikhathini sanamhlanje ngombana izinto ezinengi zenziwa ngawo. Abantu bakghona ukubamba imihlangano yabo ngayo, bathumelelane nemali, benze nerhubhululo ngayo. Ababelethi kuyinto ehlel bona bathengele abantwana abomaliledinini ngombana lokho kuzobenza bona bebenelwazi lokusebenzisa izinto se thekinoloji. Nalokha babathengelile kufuze bona batjheje bona abantwana babo aphumili elawulweni  njengokokuthi basebenzise abamaliledinini ngesikhathi sokulala.</text>
      <sha1>4bb7ywgprkpev4dr10yafal4ti2sv00</sha1>
    </revision>
    <revision>
      <id>2576</id>
      <parentid>2477</parentid>
      <timestamp>2025-03-22T05:49:04Z</timestamp>
      <contributor>
        <username>Kvazimodo</username>
        <id>341</id>
      </contributor>
      <origin>2576</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3216" sha1="qvjikv8g6dg06ry3xo6vz0wxu7we3wh" xml:space="preserve">'''Umaliledinini''' kuyinto esentjenziswa ukuthintana. Umaliledinini esikhathini sanke uyinto eqakatheke khulu ngombana usetjenziswa ukwenza izinto ezinengi ngapnandle kokudoselana umrhala nokuthumelana imilayezo. Absntu bakhona ukwenza thumelana imali basebenzisa umaliledinini, bakhona ukubamba imihlangan yabo yomsebenzi basebenzisa umaliledini. Esikhathini sanje ababelethi sele bthengela abantwana babo abomaliledii ngesibangasokobana bafuna ukhona ukuthintana nabo begodu bakghone nokudlala imidlalo ngebomaliledinini.Umaliledinini uyafana nomtjhiningcondo&lt;ref&gt;Prensky, M., 2005. What can you learn from a cell phone? Almost anything!. ''Innovate: Journal of Online Education'', ''1''(5).&lt;/ref&gt;.

== Ubuhle ==

=== Ikghono lokusebenzisa izinto zebutheknikghe ===
Kuyinto ehle bonyana abantwana babe nabomaliledinini ngesibanga sokobana bafanele bazijwayeze ukuphila ephasini letjhuguluko lesine lezamabubulo bajwayele ukusebenza ngezinto zedijithali. Abantwana lokha basebenzisa abomaliledinini bakghona nokuthola ilwazi lokusebenzisa ama-AI, lokhu kungenza bona bathole umphumela omuhle esikolweni&lt;ref&gt;Valk, J.H., Rashid, A.T. and Elder, L., 2010. Using mobile phones to improve educational outcomes: An analysis of evidence from Asia. ''International Review of Research in Open and Distributed Learning'', ''11''(1), pp.117-140.&lt;/ref&gt;

=== Ukubulungeka ===
Umntwana okghona ukusebenzisa umaliledinini ukhona ukubulungeka ngombana lokho nakungenzeka bona avelelwe mraro uzokghona ukudosela ababelethi bakhe umrhala nofana adosele iinomboro zesizo eliphambili, amapholisa Kanye neencimamlilo.

== Ubumbi ==

=== Ilwazi elingaphezulu kwabo ===
Nanyana ukusebenzisa umaliledinini komntwana kuyinto ehle kodwana bukhona nobumbi obuveleleko engekhe babethiswa ngommoya. Ubumbi bakhona kukuthi abantwana bangagcina basebenzisa iinkundla zokuthintana bese kube kulapho bapthola khona ilwazi lepilo elingaphazulu kwabo libalimaze umkhumbulo&lt;ref&gt;O'Keeffe, G.S., Clarke-Pearson, K. and Council on Communications and Media, 2011. The impact of social media on children, adolescents, and families. ''Pediatrics'', ''127''(4), pp.800-804.&lt;/ref&gt;.

=== Ukungalali ===
Okhunye kukuthi lokha nasele bajwayele ukusebenzisa umaliledinini bangagcina sele bangasalawuleki badlale ngawo bekube sebusuku, bagcine baphathwa buthongo esikolweni ngesibanga sokuthi abalali ubuthongo obulingeneko. Isenzo esifana nalesi singabonomthelela omumbi phezu kweemfundo zomntwana agcine sele athola imiphumela emimbi&lt;ref&gt;Hale, L. and Guan, S., 2015. Screen time and sleep among school-aged children and adolescents: a systematic literature review. ''Sleep medicine reviews'', ''21'', pp.50-58.&lt;/ref&gt;.

=== Isiphetho ===
Umaliledinini kuyinto qakathekileko esikhathini sanamhlanje ngombana izinto ezinengi zenziwa ngawo. Abantu bakghona ukubamba imihlangano yabo ngayo, bathumelelane nemali, benze nerhubhululo ngayo. Ababelethi kuyinto ehlel bona bathengele abantwana abomaliledinini ngombana lokho kuzobenza bona bebenelwazi lokusebenzisa izinto se thekinoloji. Nalokha babathengelile kufuze bona batjheje bona abantwana babo aphumili elawulweni  njengokokuthi basebenzise abamaliledinini ngesikhathi sokulala.

== Isithasiselo ==
{{Reflist}}</text>
      <sha1>qvjikv8g6dg06ry3xo6vz0wxu7we3wh</sha1>
    </revision>
  </page>
  <page>
    <title>Ukubhabhadiswa</title>
    <ns>0</ns>
    <id>490</id>
    <revision>
      <id>2478</id>
      <timestamp>2025-03-03T09:55:45Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''Ukubhabhadiswa''' kisesenzo esiqakathekileko ekolweni yama khrestu. Kukhombisa ukuzalwa kabutjha nokuhlanzwa&lt;ref&gt;Whitaker, E.C. and Johnson, M.E., 2017. ''Documents of the baptismal liturgy''. Liturgical Press.&lt;/ref&gt;. Kukulokha umuntu akhamba nabafundisi baye endaweni lapho kunamanzi khona akhambako nofana edamini bese afakwe khona ngokuthandazelwa mfundisi. Ukungena emanzini kukhombisa ukuzinikela kukhrestu ikosi.&quot;</comment>
      <origin>2478</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="421" sha1="3tl4lkpspiyyrxwz8sm8ht3qdh5qfd6" xml:space="preserve">'''Ukubhabhadiswa''' kisesenzo esiqakathekileko ekolweni yama khrestu. Kukhombisa ukuzalwa kabutjha nokuhlanzwa&lt;ref&gt;Whitaker, E.C. and Johnson, M.E., 2017. ''Documents of the baptismal liturgy''. Liturgical Press.&lt;/ref&gt;. Kukulokha umuntu akhamba nabafundisi baye endaweni lapho kunamanzi khona akhambako nofana edamini bese afakwe khona ngokuthandazelwa mfundisi. Ukungena emanzini kukhombisa ukuzinikela kukhrestu ikosi.</text>
      <sha1>3tl4lkpspiyyrxwz8sm8ht3qdh5qfd6</sha1>
    </revision>
    <revision>
      <id>2480</id>
      <parentid>2478</parentid>
      <timestamp>2025-03-03T10:11:08Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2480</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2934" sha1="j3cgtybs6wiyjrk6akcbvjsx0z013sp" xml:space="preserve">== Ukubhabhadiswa ==
'''Ukubhabhadiswa''' kisesenzo esiqakathekileko ekolweni yama khrestu. Kukhombisa ukuzalwa kabutjha nokuhlanzwa&lt;ref&gt;Whitaker, E.C. and Johnson, M.E., 2017. ''Documents of the baptismal liturgy''. Liturgical Press.&lt;/ref&gt;. Kukulokha umuntu akhamba nabafundisi baye endaweni lapho kunamanzi khona akhambako nofana edamini bese afakwe khona ngokuthandazelwa mfundisi. Ukungena emanzini kukhombisa ukuzinikela kukhrestu ikosi.

== Umlando wombhabhadiso ==
Umbhabhadiso kuyinto eyathoma esikweni nofana ekolweni yaba juda. Wa ngoUmbhabhadiso lo bewubizwa ngombhabhadisa ka Johana. Ngeskikhathi siskajohana umbhabhatdisi, ukubhabhadiswa kwabe kutjho ukuphenduka ezonweni uphile ipilo ecwengileko&lt;ref&gt;Reynolds, H., 2023. ''John the Baptist''. BoD–Books on Demand.&lt;/ref&gt;

== Imihlobo yombhabhadiso ==

=== '''1. umbhabhadiso womntwana''' ===
Umbhabhadiso lo wezelwa abatwana njengetshwayo lababelethi ukukhombisa ukuthi bayathembisa ukukhulisa umntwana wabo ngaphasi kwekolo nomthetho wamakhrestu&lt;ref&gt;van Beelen, J., 2012. One Lord, One Faith, One Baptism. Baptism of Children in the Letter to the Ephesians. In ''Strangers and Pilgrims on Earth'' (pp. 471-482). Brill.&lt;/ref&gt;.

=== '''2. umbhabhadiso wekholwa''' ===
Lo wenzelwa abantu esele bathethe isiqunto ngamaphilo wabo ukuthi sele balandela ukhrestu bahlollwa kuye ngako koke kwabo. Lombhabhadiso wenzelwa umuntu osathoma ukusonta egade engasondi ngaphambilini.

=== '''3.Umbhabhadiso wokuhlukana nezono''' ===
Lapha umuntu ufakwa emanzini ngomzimba wakhe woke ngombana lokhu kulitshwayo lokuthi sel afile ezonweni begodu sele avukele epilweni etjha yokusindiswa&lt;ref&gt;Mantey, J.R., 2019. Repentance and conversion. ''Basics of the Faith: An Evangelical Introduction to Christian Doctrine'', p.29.&lt;/ref&gt;.

=== '''4. umbhabhadiso kaMoya ocwengileko''' ===
Lo mbhabhadiso owabakhona lokha uJesu nakasuka ephasini abuyela ezulwini. Kilo mbhabhadiso awungeni emanzini kodwana wenzeka lokha nawuthandazako bese wehlelwe mamandla kaZimu ngommoya uzizwe ukhuluma ngamanye amalimi ongawaziko begodu ongawazwisisi kodwana uZimu akuphe ukuphimisela&lt;ref&gt;Torrey, R.A., 2019. ''Baptism of the Holy Spirit: How to Receive This Promised Gift''. Aneko Press.&lt;/ref&gt;&lt;ref&gt;Surburg, M.P., 2024. The Holy Spirit and Baptism in the Book of Acts. ''Concordia Theological Quarterly'', ''88''(1), pp.27-54.&lt;/ref&gt;.

== Umsebenzi wombhabhadiso ==
Umbhadiso uqakathekile ngombana ulitshayo lokuthi umuntu sele amukele uJesu bona abe yikosi nomsindisi wepilo yakhe. Ukhombisa bona umuntu sele ahlukene nezono begodu sele aphila ipilo ocwengileko.

== ISIPHETHO                                         ==
Umbhabhadiso yinto yamakkhrestu eveza ukuzinikela kuzimu nokutjhuguluka ezonweni uphile ipilo ehle begodu enomthetho kaZimu. Abantu babhabhdiswa ngeenzathu ezihlukileko. Le kuyinto engathomi ngesikhathi sanje kodwana yathoma ekadeni ngaphambi kobana kufike uJesu Khreste.</text>
      <sha1>j3cgtybs6wiyjrk6akcbvjsx0z013sp</sha1>
    </revision>
    <revision>
      <id>2968</id>
      <parentid>2480</parentid>
      <timestamp>2025-06-06T19:59:09Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>dfghjhgtfrgthyujyhg</comment>
      <origin>2968</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3022" sha1="j3av0xbr1ipjoqqpgmttkqo7ldo96iq" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.'''

== Ukubhabhadiswa ==
'''Ukubhabhadiswa''' kisesenzo esiqakathekileko ekolweni yama khrestu. Kukhombisa ukuzalwa kabutjha nokuhlanzwa&lt;ref&gt;Whitaker, E.C. and Johnson, M.E., 2017. ''Documents of the baptismal liturgy''. Liturgical Press.&lt;/ref&gt;. Kukulokha umuntu akhamba nabafundisi baye endaweni lapho kunamanzi khona akhambako nofana edamini bese afakwe khona ngokuthandazelwa mfundisi. Ukungena emanzini kukhombisa ukuzinikela kukhrestu ikosi.

== Umlando wombhabhadiso ==
Umbhabhadiso kuyinto eyathoma esikweni nofana ekolweni yaba juda. Wa ngoUmbhabhadiso lo bewubizwa ngombhabhadisa ka Johana. Ngeskikhathi siskajohana umbhabhatdisi, ukubhabhadiswa kwabe kutjho ukuphenduka ezonweni uphile ipilo ecwengileko&lt;ref&gt;Reynolds, H., 2023. ''John the Baptist''. BoD–Books on Demand.&lt;/ref&gt;

== Imihlobo yombhabhadiso ==

=== '''1. umbhabhadiso womntwana''' ===
Umbhabhadiso lo wezelwa abatwana njengetshwayo lababelethi ukukhombisa ukuthi bayathembisa ukukhulisa umntwana wabo ngaphasi kwekolo nomthetho wamakhrestu&lt;ref&gt;van Beelen, J., 2012. One Lord, One Faith, One Baptism. Baptism of Children in the Letter to the Ephesians. In ''Strangers and Pilgrims on Earth'' (pp. 471-482). Brill.&lt;/ref&gt;.

=== '''2. umbhabhadiso wekholwa''' ===
Lo wenzelwa abantu esele bathethe isiqunto ngamaphilo wabo ukuthi sele balandela ukhrestu bahlollwa kuye ngako koke kwabo. Lombhabhadiso wenzelwa umuntu osathoma ukusonta egade engasondi ngaphambilini.

=== '''3.Umbhabhadiso wokuhlukana nezono''' ===
Lapha umuntu ufakwa emanzini ngomzimba wakhe woke ngombana lokhu kulitshwayo lokuthi sel afile ezonweni begodu sele avukele epilweni etjha yokusindiswa&lt;ref&gt;Mantey, J.R., 2019. Repentance and conversion. ''Basics of the Faith: An Evangelical Introduction to Christian Doctrine'', p.29.&lt;/ref&gt;.

=== '''4. umbhabhadiso kaMoya ocwengileko''' ===
Lo mbhabhadiso owabakhona lokha uJesu nakasuka ephasini abuyela ezulwini. Kilo mbhabhadiso awungeni emanzini kodwana wenzeka lokha nawuthandazako bese wehlelwe mamandla kaZimu ngommoya uzizwe ukhuluma ngamanye amalimi ongawaziko begodu ongawazwisisi kodwana uZimu akuphe ukuphimisela&lt;ref&gt;Torrey, R.A., 2019. ''Baptism of the Holy Spirit: How to Receive This Promised Gift''. Aneko Press.&lt;/ref&gt;&lt;ref&gt;Surburg, M.P., 2024. The Holy Spirit and Baptism in the Book of Acts. ''Concordia Theological Quarterly'', ''88''(1), pp.27-54.&lt;/ref&gt;.

== Umsebenzi wombhabhadiso ==
Umbhadiso uqakathekile ngombana ulitshayo lokuthi umuntu sele amukele uJesu bona abe yikosi nomsindisi wepilo yakhe. Ukhombisa bona umuntu sele ahlukene nezono begodu sele aphila ipilo ocwengileko.

== ISIPHETHO                                         ==
Umbhabhadiso yinto yamakkhrestu eveza ukuzinikela kuzimu nokutjhuguluka ezonweni uphile ipilo ehle begodu enomthetho kaZimu. Abantu babhabhdiswa ngeenzathu ezihlukileko. Le kuyinto engathomi ngesikhathi sanje kodwana yathoma ekadeni ngaphambi kobana kufike uJesu Khreste.</text>
      <sha1>j3av0xbr1ipjoqqpgmttkqo7ldo96iq</sha1>
    </revision>
    <revision>
      <id>3146</id>
      <parentid>2968</parentid>
      <timestamp>2025-06-07T03:05:24Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Nqobile69|Nqobile69]]</comment>
      <origin>2480</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2934" sha1="j3cgtybs6wiyjrk6akcbvjsx0z013sp" xml:space="preserve">== Ukubhabhadiswa ==
'''Ukubhabhadiswa''' kisesenzo esiqakathekileko ekolweni yama khrestu. Kukhombisa ukuzalwa kabutjha nokuhlanzwa&lt;ref&gt;Whitaker, E.C. and Johnson, M.E., 2017. ''Documents of the baptismal liturgy''. Liturgical Press.&lt;/ref&gt;. Kukulokha umuntu akhamba nabafundisi baye endaweni lapho kunamanzi khona akhambako nofana edamini bese afakwe khona ngokuthandazelwa mfundisi. Ukungena emanzini kukhombisa ukuzinikela kukhrestu ikosi.

== Umlando wombhabhadiso ==
Umbhabhadiso kuyinto eyathoma esikweni nofana ekolweni yaba juda. Wa ngoUmbhabhadiso lo bewubizwa ngombhabhadisa ka Johana. Ngeskikhathi siskajohana umbhabhatdisi, ukubhabhadiswa kwabe kutjho ukuphenduka ezonweni uphile ipilo ecwengileko&lt;ref&gt;Reynolds, H., 2023. ''John the Baptist''. BoD–Books on Demand.&lt;/ref&gt;

== Imihlobo yombhabhadiso ==

=== '''1. umbhabhadiso womntwana''' ===
Umbhabhadiso lo wezelwa abatwana njengetshwayo lababelethi ukukhombisa ukuthi bayathembisa ukukhulisa umntwana wabo ngaphasi kwekolo nomthetho wamakhrestu&lt;ref&gt;van Beelen, J., 2012. One Lord, One Faith, One Baptism. Baptism of Children in the Letter to the Ephesians. In ''Strangers and Pilgrims on Earth'' (pp. 471-482). Brill.&lt;/ref&gt;.

=== '''2. umbhabhadiso wekholwa''' ===
Lo wenzelwa abantu esele bathethe isiqunto ngamaphilo wabo ukuthi sele balandela ukhrestu bahlollwa kuye ngako koke kwabo. Lombhabhadiso wenzelwa umuntu osathoma ukusonta egade engasondi ngaphambilini.

=== '''3.Umbhabhadiso wokuhlukana nezono''' ===
Lapha umuntu ufakwa emanzini ngomzimba wakhe woke ngombana lokhu kulitshwayo lokuthi sel afile ezonweni begodu sele avukele epilweni etjha yokusindiswa&lt;ref&gt;Mantey, J.R., 2019. Repentance and conversion. ''Basics of the Faith: An Evangelical Introduction to Christian Doctrine'', p.29.&lt;/ref&gt;.

=== '''4. umbhabhadiso kaMoya ocwengileko''' ===
Lo mbhabhadiso owabakhona lokha uJesu nakasuka ephasini abuyela ezulwini. Kilo mbhabhadiso awungeni emanzini kodwana wenzeka lokha nawuthandazako bese wehlelwe mamandla kaZimu ngommoya uzizwe ukhuluma ngamanye amalimi ongawaziko begodu ongawazwisisi kodwana uZimu akuphe ukuphimisela&lt;ref&gt;Torrey, R.A., 2019. ''Baptism of the Holy Spirit: How to Receive This Promised Gift''. Aneko Press.&lt;/ref&gt;&lt;ref&gt;Surburg, M.P., 2024. The Holy Spirit and Baptism in the Book of Acts. ''Concordia Theological Quarterly'', ''88''(1), pp.27-54.&lt;/ref&gt;.

== Umsebenzi wombhabhadiso ==
Umbhadiso uqakathekile ngombana ulitshayo lokuthi umuntu sele amukele uJesu bona abe yikosi nomsindisi wepilo yakhe. Ukhombisa bona umuntu sele ahlukene nezono begodu sele aphila ipilo ocwengileko.

== ISIPHETHO                                         ==
Umbhabhadiso yinto yamakkhrestu eveza ukuzinikela kuzimu nokutjhuguluka ezonweni uphile ipilo ehle begodu enomthetho kaZimu. Abantu babhabhdiswa ngeenzathu ezihlukileko. Le kuyinto engathomi ngesikhathi sanje kodwana yathoma ekadeni ngaphambi kobana kufike uJesu Khreste.</text>
      <sha1>j3cgtybs6wiyjrk6akcbvjsx0z013sp</sha1>
    </revision>
    <revision>
      <id>5203</id>
      <parentid>3146</parentid>
      <timestamp>2025-08-16T11:05:14Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5203</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3219" sha1="jk9n5xsre4jdp11ldtu4ikxa9zashiw" xml:space="preserve">== Ukubhabhadiswa ==
'''Ukubhabhadiswa''' kisesenzo esiqakathekileko ekolweni yama khrestu. Kukhombisa ukuzalwa kabutjha nokuhlanzwa.&lt;ref&gt;Whitaker, E.C. and Johnson, M.E., 2017. ''Documents of the baptismal liturgy''. Liturgical Press.&lt;/ref&gt; Kukulokha umuntu akhamba nabafundisi baye endaweni lapho kunamanzi khona akhambako nofana edamini bese afakwe khona ngokuthandazelwa mfundisi. Ukungena emanzini kukhombisa ukuzinikela kukhrestu ikosi.Umbhabhadiso kuyinto eyathoma esikweni nofana ekolweni yaba juda. Wa ngoUmbhabhadiso lo bewubizwa ngombhabhadisa ka Johana. Ngeskikhathi siskajohana umbhabhadisi, ukubhabhadiswa kwabe kutjho ukuphenduka ezonweni uphile ipilo ecwengileko.&lt;ref&gt;Reynolds, H., 2023. ''John the Baptist''. BoD–Books on Demand.&lt;/ref&gt;

== Imihlobo yombhabhadiso ==

=== '''1. umbhabhadiso womntwana''' ===
Umbhabhadiso lo wezelwa abatwana njengetshwayo lababelethi ukukhombisa ukuthi bayathembisa ukukhulisa umntwana wabo ngaphasi kwekolo nomthetho wamakhrestu&lt;ref&gt;van Beelen, J., 2012. One Lord, One Faith, One Baptism. Baptism of Children in the Letter to the Ephesians. In ''Strangers and Pilgrims on Earth'' (pp. 471-482). Brill.&lt;/ref&gt;.Umbhabhadiso lo wenziwa lokha umntwana nakasesemcani ukwenzela bonya umntwana akhulele ngapbhasi kwesandla saka Zimu.

=== '''2. umbhabhadiso wekholwa''' ===
Lo wenzelwa abantu esele bathethe isiqunto ngamaphilo wabo ukuthi sele balandela ukhrestu bahlala kuye ngako koke kwabo. Lombhabhadiso wenzelwa umuntu osathoma ukusonta egade engasondi ngaphambilini.Lapha umuntu ufakwa emanzini ngomzimba wakhe woke ngombana lokhu kulitshwayo lokuthi sel afile ezonweni begodu sele avukele epilweni etjha yokusindiswa&lt;ref&gt;Mantey, J.R., 2019. Repentance and conversion. ''Basics of the Faith: An Evangelical Introduction to Christian Doctrine'', p.29.&lt;/ref&gt;. eskhathini esinengi wenziwa lokha nakukhathi sephasika mihla namalanga ngombana abantu abanengi vane baye emasontweni ukuyokulotjha uZimu.

=== '''3. umbhabhadiso kaMoya ocwengileko''' ===
Lo mbhabhadiso owabakhona lokha uJesu nakasuka ephasini abuyela ezulwini. Kilo mbhabhadiso awungeni emanzini kodwana wenzeka lokha nawuthandazako bese wehlelwe mamandla kaZimu ngommoya uzizwe ukhuluma ngamanye amalimi ongawaziko begodu ongawazwisisi kodwana uZimu akuphe ukuphimisela.&lt;ref&gt;Torrey, R.A., 2019. ''Baptism of the Holy Spirit: How to Receive This Promised Gift''. Aneko Press.&lt;/ref&gt;&lt;ref&gt;Surburg, M.P., 2024. The Holy Spirit and Baptism in the Book of Acts. ''Concordia Theological Quarterly'', ''88''(1), pp.27-54.&lt;/ref&gt;Lombhabhadisa owathoma ukwenzeka encwadini yezenzo yebhayibhili lapho gade kulilanga lephenthekoste khona kwehla amandla lapho gade abantu bakaZimu gade bahlangene khona.

=== Umsebenzi wombhabhadiso ===
Umbhadiso uqakathekile ngombana ulitshayo lokuthi umuntu sele amukele uJesu bona abe yikosi nomsindisi wepilo yakhe. Ukhombisa bona umuntu sele ahlukene nezono begodu sele aphila ipilo ocwengileko. Umbhabhadiso yinto yamakkhrestu eveza ukuzinikela kuzimu nokutjhuguluka ezonweni uphile ipilo ehle begodu enomthetho kaZimu. Abantu babhabhdiswa ngeenzathu ezihlukileko. Le kuyinto engathomi ngesikhathi sanje kodwana yathoma ekadeni ngaphambi kobana kufike uJesu Khreste.

== Iinkomba ==</text>
      <sha1>jk9n5xsre4jdp11ldtu4ikxa9zashiw</sha1>
    </revision>
    <revision>
      <id>5204</id>
      <parentid>5203</parentid>
      <timestamp>2025-08-16T11:07:52Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5204</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3289" sha1="4z5ncrrxgbj5y73fs9w9rrcv2orw2dj" xml:space="preserve">'''Ukubhabhadiswa''' kisesenzo esiqakathekileko ekolweni yama khrestu. Kukhombisa ukuzalwa kabutjha nokuhlanzwa.&lt;ref&gt;Whitaker, E.C. and Johnson, M.E., 2017. ''Documents of the baptismal liturgy''. Liturgical Press.&lt;/ref&gt; Kukulokha umuntu akhamba nabafundisi baye endaweni lapho kunamanzi khona akhambako nofana edamini bese afakwe khona ngokuthandazelwa mfundisi. Ukungena emanzini kukhombisa ukuzinikela kukhrestu ikosi.Umbhabhadiso kuyinto eyathoma esikweni nofana ekolweni yaba juda. Wa ngoUmbhabhadiso lo bewubizwa ngombhabhadisa ka Johana. Ngeskikhathi siskajohana umbhabhadisi, ukubhabhadiswa kwabe kutjho ukuphenduka ezonweni uphile ipilo ecwengileko.&lt;ref&gt;Reynolds, H., 2023. ''John the Baptist''. BoD–Books on Demand.&lt;/ref&gt;

=== Imihlobo yombhabhadiso ===

==== '''1. umbhabhadiso womntwana''' ====
Umbhabhadiso lo wezelwa abatwana njengetshwayo lababelethi ukukhombisa ukuthi bayathembisa ukukhulisa umntwana wabo ngaphasi kwekolo nomthetho wamakhrestu.&lt;ref&gt;van Beelen, J., 2012. One Lord, One Faith, One Baptism. Baptism of Children in the Letter to the Ephesians. In ''Strangers and Pilgrims on Earth'' (pp. 471-482). Brill.&lt;/ref&gt;Umbhabhadiso lo wenziwa lokha umntwana nakasesemcani ukwenzela bonya umntwana akhulele ngapbhasi kwesandla saka Zimu. Ibhayibhili iyavulwa kufundwe ivesi ngaphambi kobana umntwana athome abhabhadiswe.

==== '''2. umbhabhadiso wekholwa''' ====
Lo wenzelwa abantu esele bathethe isiqunto ngamaphilo wabo ukuthi sele balandela ukhrestu bahlala kuye ngako koke kwabo. Lombhabhadiso wenzelwa umuntu osathoma ukusonta egade engasondi ngaphambilini.Lapha umuntu ufakwa emanzini ngomzimba wakhe woke ngombana lokhu kulitshwayo lokuthi sel afile ezonweni begodu sele avukele epilweni etjha yokusindiswa&lt;ref&gt;Mantey, J.R., 2019. Repentance and conversion. ''Basics of the Faith: An Evangelical Introduction to Christian Doctrine'', p.29.&lt;/ref&gt;. eskhathini esinengi wenziwa lokha nakukhathi sephasika mihla namalanga ngombana abantu abanengi vane baye emasontweni ukuyokulotjha uZimu.

==== '''3. umbhabhadiso kaMoya ocwengileko''' ====
Lo mbhabhadiso owabakhona lokha uJesu nakasuka ephasini abuyela ezulwini. Kilo mbhabhadiso awungeni emanzini kodwana wenzeka lokha nawuthandazako bese wehlelwe mamandla kaZimu ngommoya uzizwe ukhuluma ngamanye amalimi ongawaziko begodu ongawazwisisi kodwana uZimu akuphe ukuphimisela.&lt;ref&gt;Torrey, R.A., 2019. ''Baptism of the Holy Spirit: How to Receive This Promised Gift''. Aneko Press.&lt;/ref&gt;&lt;ref&gt;Surburg, M.P., 2024. The Holy Spirit and Baptism in the Book of Acts. ''Concordia Theological Quarterly'', ''88''(1), pp.27-54.&lt;/ref&gt;Lombhabhadisa owathoma ukwenzeka encwadini yezenzo yebhayibhili lapho gade kulilanga lephenthekoste khona kwehla amandla lapho gade abantu bakaZimu gade bahlangene khona.

=== Umsebenzi wombhabhadiso ===
Umbhadiso uqakathekile ngombana ulitshayo lokuthi umuntu sele amukele uJesu bona abe yikosi nomsindisi wepilo yakhe. Ukhombisa bona umuntu sele ahlukene nezono begodu sele aphila ipilo ocwengileko. Umbhabhadiso yinto yamakkhrestu eveza ukuzinikela kuzimu nokutjhuguluka ezonweni uphile ipilo ehle begodu enomthetho kaZimu. Abantu babhabhdiswa ngeenzathu ezihlukileko. Le kuyinto engathomi ngesikhathi sanje kodwana yathoma ekadeni ngaphambi kobana kufike uJesu Khreste.

== Iinkomba ==</text>
      <sha1>4z5ncrrxgbj5y73fs9w9rrcv2orw2dj</sha1>
    </revision>
    <revision>
      <id>5205</id>
      <parentid>5204</parentid>
      <timestamp>2025-08-16T11:09:15Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5205</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3261" sha1="7oogj3xmwdo4dfg1r48zzmbhaqw9ggv" xml:space="preserve">'''Ukubhabhadiswa''' kisesenzo esiqakathekileko ekolweni yama khrestu. Kukhombisa ukuzalwa kabutjha nokuhlanzwa.&lt;ref&gt;Whitaker, E.C. and Johnson, M.E., 2017. ''Documents of the baptismal liturgy''. Liturgical Press.&lt;/ref&gt; Kukulokha umuntu akhamba nabafundisi baye endaweni lapho kunamanzi khona akhambako nofana edamini bese afakwe khona ngokuthandazelwa mfundisi. Ukungena emanzini kukhombisa ukuzinikela kukhrestu ikosi.Umbhabhadiso kuyinto eyathoma esikweni nofana ekolweni yaba juda. Wa ngoUmbhabhadiso lo bewubizwa ngombhabhadisa ka Johana. Ngeskikhathi siskajohana umbhabhadisi, ukubhabhadiswa kwabe kutjho ukuphenduka ezonweni uphile ipilo ecwengileko.&lt;ref&gt;Reynolds, H., 2023. ''John the Baptist''. BoD–Books on Demand.&lt;/ref&gt;

=== Imihlobo yombhabhadiso ===

==== '''1. umbhabhadiso womntwana''' ====
Umbhabhadiso lo wezelwa abatwana njengetshwayo lababelethi ukukhombisa ukuthi bayathembisa ukukhulisa umntwana wabo ngaphasi kwekolo nomthetho wamakhrestu.&lt;ref&gt;van Beelen, J., 2012. One Lord, One Faith, One Baptism. Baptism of Children in the Letter to the Ephesians. In ''Strangers and Pilgrims on Earth'' (pp. 471-482). Brill.&lt;/ref&gt;Umbhabhadiso lo wenziwa lokha umntwana nakasesemcani ukwenzela bonya umntwana akhulele ngapbhasi kwesandla saka Zimu. Ibhayibhili iyavulwa kufundwe ivesi ngaphambi kobana umntwana athome abhabhadiswe.

==== '''2. umbhabhadiso wekholwa''' ====
Lo wenzelwa abantu esele bathethe isiqunto ngamaphilo wabo ukuthi sele balandela ukhrestu bahlala kuye ngako koke kwabo. Lombhabhadiso wenzelwa umuntu osathoma ukusonta egade engasondi ngaphambilini.Lapha umuntu ufakwa emanzini ngomzimba wakhe woke ngombana lokhu kulitshwayo lokuthi sel afile ezonweni begodu sele avukele epilweni etjha yokusindiswa&lt;ref&gt;Mantey, J.R., 2019. Repentance and conversion. ''Basics of the Faith: An Evangelical Introduction to Christian Doctrine'', p.29.&lt;/ref&gt;. eskhathini esinengi wenziwa lokha nakukhathi sephasika mihla namalanga ngombana abantu abanengi vane baye emasontweni ukuyokulotjha uZimu.

==== '''3. umbhabhadiso kaMoya ocwengileko''' ====
Lo mbhabhadiso owabakhona lokha uJesu nakasuka ephasini abuyela ezulwini. Kilo mbhabhadiso awungeni emanzini kodwana wenzeka lokha nawuthandazako bese wehlelwe mamandla kaZimu ngommoya uzizwe ukhuluma ngamanye amalimi ongawaziko begodu ongawazwisisi kodwana uZimu akuphe ukuphimisela.&lt;ref&gt;Torrey, R.A., 2019. ''Baptism of the Holy Spirit: How to Receive This Promised Gift''. Aneko Press.&lt;/ref&gt;&lt;ref&gt;Surburg, M.P., 2024. The Holy Spirit and Baptism in the Book of Acts. ''Concordia Theological Quarterly'', ''88''(1), pp.27-54.&lt;/ref&gt;Lombhabhadisa owathoma ukwenzeka encwadini yezenzo yebhayibhili lapho gade kulilanga lephenthekoste khona kwehla amandla lapho gade abantu bakaZimu gade bahlangene khona. Umbhabhadiso uqakathekile ngombana ulitshwayo lokuthi umuntu sele amukele uJesu bona abe yikosi nomsindisi wepilo yakhe. Ukhombisa bona umuntu sele ahlukene nezono begodu sele aphila ipilo ocwengileko. Umbhabhadiso yinto yamakkhrestu eveza ukuzinikela kuzimu nokutjhuguluka ezonweni uphile ipilo ehle begodu enomthetho kaZimu. Abantu babhabhadiswa ngeenzathu ezihlukileko. Le kuyinto engathomi ngesikhathi sanje kodwana yathoma ekadeni ngaphambi kobana kufike uJesu Khreste.

== Iinkomba ==</text>
      <sha1>7oogj3xmwdo4dfg1r48zzmbhaqw9ggv</sha1>
    </revision>
    <revision>
      <id>5206</id>
      <parentid>5205</parentid>
      <timestamp>2025-08-16T11:11:01Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>5206</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3335" sha1="3lnicke67x1fmz1vt2y1d4vvyy62wv0" xml:space="preserve">'''Ukubhabhadiswa''' kisesenzo esiqakathekileko ekolweni yama khrestu. Kukhombisa ukuzalwa kabutjha nokuhlanzwa.&lt;ref&gt;Whitaker, E.C. and Johnson, M.E., 2017. ''Documents of the baptismal liturgy''. Liturgical Press.&lt;/ref&gt; Kukulokha umuntu akhamba nabafundisi baye endaweni lapho kunamanzi khona akhambako nofana edamini bese afakwe khona ngokuthandazelwa mfundisi. Ukungena emanzini kukhombisa ukuzinikela kukhrestu ikosi.Umbhabhadiso kuyinto eyathoma esikweni nofana ekolweni yaba juda. Wa ngoUmbhabhadiso lo bewubizwa ngombhabhadisa ka Johana. Ngeskikhathi siskajohana umbhabhadisi, ukubhabhadiswa kwabe kutjho ukuphenduka ezonweni uphile ipilo ecwengileko.&lt;ref&gt;Reynolds, H., 2023. ''John the Baptist''. BoD–Books on Demand.&lt;/ref&gt;

=== Imihlobo yombhabhadiso ===

==== '''1. umbhabhadiso womntwana''' ====
Umbhabhadiso lo wezelwa abatwana njengetshwayo lababelethi ukukhombisa ukuthi bayathembisa ukukhulisa umntwana wabo ngaphasi kwekolo nomthetho wamakhrestu.&lt;ref&gt;van Beelen, J., 2012. One Lord, One Faith, One Baptism. Baptism of Children in the Letter to the Ephesians. In ''Strangers and Pilgrims on Earth'' (pp. 471-482). Brill.&lt;/ref&gt;Umbhabhadiso lo wenziwa lokha umntwana nakasesemcani ukwenzela bonya umntwana akhulele ngapbhasi kwesandla saka Zimu. Ibhayibhili iyavulwa kufundwe ivesi ngaphambi kobana umntwana athome abhabhadiswe.

==== '''2. umbhabhadiso wekholwa''' ====
Lo wenzelwa abantu esele bathethe isiqunto ngamaphilo wabo ukuthi sele balandela ukhrestu bahlala kuye ngako koke kwabo. Lombhabhadiso wenzelwa umuntu osathoma ukusonta egade engasondi ngaphambilini.Lapha umuntu ufakwa emanzini ngomzimba wakhe woke ngombana lokhu kulitshwayo lokuthi sel afile ezonweni begodu sele avukele epilweni etjha yokusindiswa&lt;ref&gt;Mantey, J.R., 2019. Repentance and conversion. ''Basics of the Faith: An Evangelical Introduction to Christian Doctrine'', p.29.&lt;/ref&gt;. eskhathini esinengi wenziwa lokha nakukhathi sephasika mihla namalanga ngombana abantu abanengi vane baye emasontweni ukuyokulotjha uZimu.

==== '''3. umbhabhadiso kaMoya ocwengileko''' ====
Lo mbhabhadiso owabakhona lokha uJesu nakasuka ephasini abuyela ezulwini. Kilo mbhabhadiso awungeni emanzini kodwana wenzeka lokha nawuthandazako bese wehlelwe mamandla kaZimu ngommoya uzizwe ukhuluma ngamanye amalimi ongawaziko begodu ongawazwisisi kodwana uZimu akuphe ukuphimisela.&lt;ref&gt;Torrey, R.A., 2019. ''Baptism of the Holy Spirit: How to Receive This Promised Gift''. Aneko Press.&lt;/ref&gt;&lt;ref&gt;Surburg, M.P., 2024. The Holy Spirit and Baptism in the Book of Acts. ''Concordia Theological Quarterly'', ''88''(1), pp.27-54.&lt;/ref&gt;Lombhabhadisa owathoma ukwenzeka encwadini yezenzo yebhayibhili lapho gade kulilanga lephenthekoste khona kwehla amandla lapho gade abantu bakaZimu gade bahlangene khona. Umbhabhadiso uqakathekile ngombana ulitshwayo lokuthi umuntu sele amukele uJesu bona abe yikosi nomsindisi wepilo yakhe. Ukhombisa bona umuntu sele ahlukene nezono begodu sele aphila ipilo ocwengileko. Umbhabhadiso yinto yamakkhrestu eveza ukuzinikela kuzimu nokutjhuguluka ezonweni uphile ipilo ehle begodu enomthetho kaZimu. Abantu babhabhadiswa ngeenzathu ezihlukileko. Le kuyinto engathomi ngesikhathi sanje kodwana yathoma ekadeni ngaphambi kobana kufike uJesu Khreste.

== Iinkomba ==
[[Category:Ukubhabhadiswa]]
[[Category:Ubukresite]]
[[Category:Amasonto]]</text>
      <sha1>3lnicke67x1fmz1vt2y1d4vvyy62wv0</sha1>
    </revision>
  </page>
  <page>
    <title>Imitlolo yendabuko yesiNdebele</title>
    <ns>0</ns>
    <id>491</id>
    <revision>
      <id>2479</id>
      <timestamp>2025-03-03T09:57:26Z</timestamp>
      <contributor>
        <username>Napangela</username>
        <id>406</id>
      </contributor>
      <comment>Created page with &quot;== '''Imitlolo yendabuko yesiNdebeleIe''' == '''Imitlolo yendabuko''' mitlolo yeendaba ezidluliselwa esizukulwaneni, ezivela esikhathini sakade, ebegade zikhulunywa ngomlomo zingakatlolwa phasi. Imitlolo le iveza umlando wamasiko wesikhathi sakade.   === Izinto ezitholakala phakathi kwemitlolo yendabuko ===  # Zivela emlandwini wokukhuluma # Ziveza amasiko, iimilo, izenzo zabantu, ukutlhaga, ubuloyi, uthando, izondo kanye neenkolo ezihlukahlukeneko # Ziveza iimfundo ezah...&quot;</comment>
      <origin>2479</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="782" sha1="d3oay329gp7nlukjs9mx210icezzr6n" xml:space="preserve">== '''Imitlolo yendabuko yesiNdebeleIe''' ==
'''Imitlolo yendabuko''' mitlolo yeendaba ezidluliselwa esizukulwaneni, ezivela esikhathini sakade, ebegade zikhulunywa ngomlomo zingakatlolwa phasi. Imitlolo le iveza umlando wamasiko wesikhathi sakade. 

=== Izinto ezitholakala phakathi kwemitlolo yendabuko ===

# Zivela emlandwini wokukhuluma
# Ziveza amasiko, iimilo, izenzo zabantu, ukutlhaga, ubuloyi, uthando, izondo kanye neenkolo ezihlukahlukeneko
# Ziveza iimfundo ezahlukahlukeno ezifundisa abantu begodu zikhulisa umkhumbulo waloyo ofundako
# Ofundako angaba namazizo ahlukahlukeno ngomlingisi nanyana umdlali othileko 

==== &lt;big&gt;Imihlobo yemitlolo yendabuko&lt;/big&gt; ====

# Amanovela
# Imidlalo
# Iindatjana ezifitjhani
# Izaga
# Izitjho
# Iinrarejo
# Iinganekwana/Iinolwana</text>
      <sha1>d3oay329gp7nlukjs9mx210icezzr6n</sha1>
    </revision>
  </page>
  <page>
    <title>IMapungubwe</title>
    <ns>0</ns>
    <id>492</id>
    <revision>
      <id>2481</id>
      <timestamp>2025-03-03T10:16:10Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''IMapungubwe''' yindawo yokuthoma eSewula Africa. Indawo le isesiphandeni seLimpopo eduze nomlambo weshashe. Bekuyindawo ezele indlovu ezinengi abantu bebasuka la bahlala khona  beze bazokuzingela iindlovu bafuna iimpondo zeendlovu ezibizwa bona yi-ivory ngelimi lesiNgisi. Bazithathe bayozithengisa kwamanye amazwe begodu bebahlala emaplasini ahlukahlukeneko begodu asemaduzelana&lt;ref&gt;Meskell, L., 2016. Mapungubwe Cultural Landscape. ''World Heritage on the Ground: Ethnog...&quot;</comment>
      <origin>2481</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="518" sha1="dkdtofv4byoeyhp6h4wc0ndeornme0q" xml:space="preserve">'''IMapungubwe''' yindawo yokuthoma eSewula Africa. Indawo le isesiphandeni seLimpopo eduze nomlambo weshashe. Bekuyindawo ezele indlovu ezinengi abantu bebasuka la bahlala khona  beze bazokuzingela iindlovu bafuna iimpondo zeendlovu ezibizwa bona yi-ivory ngelimi lesiNgisi. Bazithathe bayozithengisa kwamanye amazwe begodu bebahlala emaplasini ahlukahlukeneko begodu asemaduzelana&lt;ref&gt;Meskell, L., 2016. Mapungubwe Cultural Landscape. ''World Heritage on the Ground: Ethnographic Perspectives'', ''28'', p.273.&lt;/ref&gt;</text>
      <sha1>dkdtofv4byoeyhp6h4wc0ndeornme0q</sha1>
    </revision>
    <revision>
      <id>2482</id>
      <parentid>2481</parentid>
      <timestamp>2025-03-03T10:23:50Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2482</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1707" sha1="awik06nuj7hhx7389iw4c7ioq768s8x" xml:space="preserve">== IMapungubwe ==
'''IMapungubwe''' yindawo yokuthoma eSewula Africa. Indawo le isesiphandeni seLimpopo eduze nomlambo weshashe. Bekuyindawo ezele indlovu ezinengi abantu bebasuka la bahlala khona  beze bazokuzingela iindlovu bafuna iimpondo zeendlovu ezibizwa bona yi-ivory ngelimi lesiNgisi. Bazithathe bayozithengisa kwamanye amazwe begodu bebahlala emaplasini ahlukahlukeneko begodu asemaduzelana&lt;ref&gt;Meskell, L., 2016. Mapungubwe Cultural Landscape. ''World Heritage on the Ground: Ethnographic Perspectives'', ''28'', p.273.&lt;/ref&gt;

== '''Isikopilo leMapungubwe''' ==
Ikosi yakhona beyihlala phezulu kwesicongolwana esibizwa bona yiMapungubwe hill ngombana lapho bekuhlala imimoya yabaphasi begodu beyikghona ukukhulumna nabo. Amadoda bekanamandla ukudlula abafazi begodu umuntu omncani bekangaphathwa njengomuntu omkhuluBekunabantu abafunda ilikade ababizwa bona Archeologist bebakhamba baya eMapungubwe bayokugubha bathola bona le bekuyindawo yabantu abanothileko ngombana kwatholakala khona ubuhlalo begolide, izitja zobumba namathambo weenlwana&lt;ref&gt;Ashley, C. and Antonites, A., 2020. Art and the everyday: gold, ceramics and meaning in thirteenth-century Mapungubwe.&lt;/ref&gt;.Izinto ezitholakala eMapungubwe kwabe  kuzimpoto zakade nomncamo werhalasi. Bebathatha izinto lezi bese bakhambe nazo bayozithengisa.

Intaba yeMapungubwe beyikhwelwa uqale emuva, bewuthi nawuyicalako uyicala Kanye bese ucala emuva. Bekungayiwa ebusuku entabeni le.Bekungakhanjiwa kiyo ngombana kunomoya wabaphasi. Intaba yayakhona bekuyindawo yobukhosi nendawo lapho kubekwa khona ezinye izinto eziqakathekileko&lt;ref&gt;Ramji, H., 2020. Producing the Precolonial: Professional and Popular Lives of Mapungubwe, 1937-2017.&lt;/ref&gt;.</text>
      <sha1>awik06nuj7hhx7389iw4c7ioq768s8x</sha1>
    </revision>
    <revision>
      <id>2499</id>
      <parentid>2482</parentid>
      <timestamp>2025-03-04T05:54:11Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2499</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1708" sha1="qmsqfv5zz3zuj7iy467psg4lbu3u3nz" xml:space="preserve">== IMapungubwe ==
'''IMapungubwe''' yindawo yokuthoma eSewula Africa. Indawo le isesiphandeni seLimpopo eduze nomlambo weshashe. Bekuyindawo ezele iindlovu ezinengi abantu bebasuka la bahlala khona  beze bazokuzingela iindlovu bafuna iimpondo zeendlovu ezibizwa bona yi-ivory ngelimi lesiNgisi. Bazithathe bayozithengisa kwamanye amazwe begodu bebahlala emaplasini ahlukahlukeneko begodu asemaduzelana&lt;ref&gt;Meskell, L., 2016. Mapungubwe Cultural Landscape. ''World Heritage on the Ground: Ethnographic Perspectives'', ''28'', p.273.&lt;/ref&gt;

== '''Isikopilo leMapungubwe''' ==
Ikosi yakhona beyihlala phezulu kwesicongolwana esibizwa bona yiMapungubwe hill ngombana lapho bekuhlala imimoya yabaphasi begodu beyikghona ukukhulumna nabo. Amadoda bekanamandla ukudlula abafazi begodu umuntu omncani bekangaphathwa njengomuntu omkhuluBekunabantu abafunda ilikade ababizwa bona Archeologist bebakhamba baya eMapungubwe bayokugubha bathola bona le bekuyindawo yabantu abanothileko ngombana kwatholakala khona ubuhlalo begolide, izitja zobumba namathambo weenlwana&lt;ref&gt;Ashley, C. and Antonites, A., 2020. Art and the everyday: gold, ceramics and meaning in thirteenth-century Mapungubwe.&lt;/ref&gt;.Izinto ezitholakala eMapungubwe kwabe  kuzimpoto zakade nomncamo werhalasi. Bebathatha izinto lezi bese bakhambe nazo bayozithengisa.

Intaba yeMapungubwe beyikhwelwa uqale emuva, bewuthi nawuyicalako uyicala Kanye bese ucala emuva. Bekungayiwa ebusuku entabeni le.Bekungakhanjiwa kiyo ngombana kunomoya wabaphasi. Intaba yayakhona bekuyindawo yobukhosi nendawo lapho kubekwa khona ezinye izinto eziqakathekileko&lt;ref&gt;Ramji, H., 2020. Producing the Precolonial: Professional and Popular Lives of Mapungubwe, 1937-2017.&lt;/ref&gt;.</text>
      <sha1>qmsqfv5zz3zuj7iy467psg4lbu3u3nz</sha1>
    </revision>
    <revision>
      <id>2529</id>
      <parentid>2499</parentid>
      <timestamp>2025-03-14T18:56:10Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2529</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1710" sha1="gfzj8ntvoucz0ppojj7k975xpa3mx0p" xml:space="preserve">== IMapungubwe ==
'''IMapungubwe''' yindawo yokuthoma eSewula Africa. Indawo le isesiphandeni seLimpopo eduze nomlambo weshashe. Bekuyindawo ezele iindlovu ezinengi abantu bebasuka la bahlala khona  beze bazokuzingela iindlovu bafuna iimpondo zeendlovu ezibizwa bona yi-ivory ngelimi lesiNgisi. Bazithathe bayozithengisa kwamanye amazwe begodu bebahlala emaplasini ahlukahlukeneko begodu asemaduzelana&lt;ref&gt;Meskell, L., 2016. Mapungubwe Cultural Landscape. ''World Heritage on the Ground: Ethnographic Perspectives'', ''28'', p.273.&lt;/ref&gt;

== '''Isikopilo leMapungubwe''' ==
Ikosi yakhona beyihlala phezulu kwesicongolwana esibizwa bona yiMapungubwe hill ngombana lapho bekuhlala imimoya yabaphasi begodu beyikghona ukukhulumna nabo. Amadoda bekanamandla ukudlula abafazi begodu umuntu omncani bekangaphathwa njengomuntu omkhulu. Bekunabantu abafunda ilikade ababizwa bona Archeologist bebakhamba baya eMapungubwe bayokugubha bathola bona le bekuyindawo yabantu abanothileko ngombana kwatholakala khona ubuhlalo begolide, izitja zobumba namathambo weenlwana&lt;ref&gt;Ashley, C. and Antonites, A., 2020. Art and the everyday: gold, ceramics and meaning in thirteenth-century Mapungubwe.&lt;/ref&gt;.Izinto ezitholakala eMapungubwe kwabe  kuzimpoto zakade nomncamo werhalasi. Bebathatha izinto lezi bese bakhambe nazo bayozithengisa.

Intaba yeMapungubwe bewuyikhwelwa uqale emuva, bewuthi nawuyicalako uyicala Kanye bese ucala emuva. Bekungayiwa ebusuku entabeni le.Bekungakhanjiwa kiyo ngombana kunomoya wabaphasi. Intaba yakhona bekuyindawo yobukhosi nendawo lapho kubekwa khona ezinye izinto eziqakathekileko&lt;ref&gt;Ramji, H., 2020. Producing the Precolonial: Professional and Popular Lives of Mapungubwe, 1937-2017.&lt;/ref&gt;.</text>
      <sha1>gfzj8ntvoucz0ppojj7k975xpa3mx0p</sha1>
    </revision>
    <revision>
      <id>2550</id>
      <parentid>2529</parentid>
      <timestamp>2025-03-19T18:19:29Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2550</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1722" sha1="iz04wxetp0tjtcouc82zbip7yrdzqrf" xml:space="preserve">== IMapungubwe ==
'''IMapungubwe''' yindawo yokuthoma eSewula Africa. Indawo le isesiphandeni seLimpopo eduze nomlambo weshashe. Bekuyindawo ezele iindlovu ezinengi abantu bebasuka la bahlala khona  beze bazokuzingela [[iindlovu]] bafuna iimpondo zeendlovu ezibizwa bona yi-ivory ngelimi lesiNgisi. Bazithathe bayozithengisa kwamanye amazwe begodu bebahlala emaplasini ahlukahlukeneko begodu asemaduzelana&lt;ref&gt;Meskell, L., 2016. Mapungubwe Cultural Landscape. ''World Heritage on the Ground: Ethnographic Perspectives'', ''28'', p.273.&lt;/ref&gt;

== '''Isikopilo leMapungubwe''' ==
Ikosi yakhona beyihlala phezulu kwesicongolwana esibizwa bona yiMapungubwe hill ngombana lapho bekuhlala imimoya yabaphasi begodu beyikghona ukukhulumna nabo. Amadoda bekanamandla ukudlula abafazi begodu umuntu omncani bekangaphathwa njengomuntu omkhulu. Bekunabantu abafunda ilikade ababizwa bona Archeologist bebakhamba baya eMapungubwe bayokugubha bathola bona le bekuyindawo yabantu abanothileko ngombana kwatholakala khona ubuhlalo begolide, izitja zobumba n[[amathambo]] weenlwana&lt;ref&gt;Ashley, C. and Antonites, A., 2020. Art and the everyday: gold, ceramics and meaning in thirteenth-century Mapungubwe.&lt;/ref&gt;.Izinto ezitholakala eMapungubwe kwabe  kuzimpoto zakade nomncamo werhalasi. Bebathatha izinto lezi bese bakhambe nazo bayozithengisa.

[[Intaba]] yeMapungubwe bewuyikhwelwa uqale emuva, bewuthi nawuyicalako uyicala Kanye bese ucala emuva. Bekungayiwa ebusuku entabeni le.Bekungakhanjiwa kiyo ngombana kunomoya wabaphasi. Intaba yakhona bekuyindawo yobukhosi nendawo lapho kubekwa khona ezinye izinto eziqakathekileko&lt;ref&gt;Ramji, H., 2020. Producing the Precolonial: Professional and Popular Lives of Mapungubwe, 1937-2017.&lt;/ref&gt;.</text>
      <sha1>iz04wxetp0tjtcouc82zbip7yrdzqrf</sha1>
    </revision>
    <revision>
      <id>3003</id>
      <parentid>2550</parentid>
      <timestamp>2025-06-06T20:20:31Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>a</comment>
      <origin>3003</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1810" sha1="17h2gpxls84mokirosbadnlrqcts86l" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.'''

== IMapungubwe ==
'''IMapungubwe''' yindawo yokuthoma eSewula Africa. Indawo le isesiphandeni seLimpopo eduze nomlambo weshashe. Bekuyindawo ezele iindlovu ezinengi abantu bebasuka la bahlala khona  beze bazokuzingela [[iindlovu]] bafuna iimpondo zeendlovu ezibizwa bona yi-ivory ngelimi lesiNgisi. Bazithathe bayozithengisa kwamanye amazwe begodu bebahlala emaplasini ahlukahlukeneko begodu asemaduzelana&lt;ref&gt;Meskell, L., 2016. Mapungubwe Cultural Landscape. ''World Heritage on the Ground: Ethnographic Perspectives'', ''28'', p.273.&lt;/ref&gt;

== '''Isikopilo leMapungubwe''' ==
Ikosi yakhona beyihlala phezulu kwesicongolwana esibizwa bona yiMapungubwe hill ngombana lapho bekuhlala imimoya yabaphasi begodu beyikghona ukukhulumna nabo. Amadoda bekanamandla ukudlula abafazi begodu umuntu omncani bekangaphathwa njengomuntu omkhulu. Bekunabantu abafunda ilikade ababizwa bona Archeologist bebakhamba baya eMapungubwe bayokugubha bathola bona le bekuyindawo yabantu abanothileko ngombana kwatholakala khona ubuhlalo begolide, izitja zobumba n[[amathambo]] weenlwana&lt;ref&gt;Ashley, C. and Antonites, A., 2020. Art and the everyday: gold, ceramics and meaning in thirteenth-century Mapungubwe.&lt;/ref&gt;.Izinto ezitholakala eMapungubwe kwabe  kuzimpoto zakade nomncamo werhalasi. Bebathatha izinto lezi bese bakhambe nazo bayozithengisa.

[[Intaba]] yeMapungubwe bewuyikhwelwa uqale emuva, bewuthi nawuyicalako uyicala Kanye bese ucala emuva. Bekungayiwa ebusuku entabeni le.Bekungakhanjiwa kiyo ngombana kunomoya wabaphasi. Intaba yakhona bekuyindawo yobukhosi nendawo lapho kubekwa khona ezinye izinto eziqakathekileko&lt;ref&gt;Ramji, H., 2020. Producing the Precolonial: Professional and Popular Lives of Mapungubwe, 1937-2017.&lt;/ref&gt;.</text>
      <sha1>17h2gpxls84mokirosbadnlrqcts86l</sha1>
    </revision>
    <revision>
      <id>3107</id>
      <parentid>3003</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Nqobile69|Nqobile69]]</comment>
      <origin>2550</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1722" sha1="iz04wxetp0tjtcouc82zbip7yrdzqrf" xml:space="preserve">== IMapungubwe ==
'''IMapungubwe''' yindawo yokuthoma eSewula Africa. Indawo le isesiphandeni seLimpopo eduze nomlambo weshashe. Bekuyindawo ezele iindlovu ezinengi abantu bebasuka la bahlala khona  beze bazokuzingela [[iindlovu]] bafuna iimpondo zeendlovu ezibizwa bona yi-ivory ngelimi lesiNgisi. Bazithathe bayozithengisa kwamanye amazwe begodu bebahlala emaplasini ahlukahlukeneko begodu asemaduzelana&lt;ref&gt;Meskell, L., 2016. Mapungubwe Cultural Landscape. ''World Heritage on the Ground: Ethnographic Perspectives'', ''28'', p.273.&lt;/ref&gt;

== '''Isikopilo leMapungubwe''' ==
Ikosi yakhona beyihlala phezulu kwesicongolwana esibizwa bona yiMapungubwe hill ngombana lapho bekuhlala imimoya yabaphasi begodu beyikghona ukukhulumna nabo. Amadoda bekanamandla ukudlula abafazi begodu umuntu omncani bekangaphathwa njengomuntu omkhulu. Bekunabantu abafunda ilikade ababizwa bona Archeologist bebakhamba baya eMapungubwe bayokugubha bathola bona le bekuyindawo yabantu abanothileko ngombana kwatholakala khona ubuhlalo begolide, izitja zobumba n[[amathambo]] weenlwana&lt;ref&gt;Ashley, C. and Antonites, A., 2020. Art and the everyday: gold, ceramics and meaning in thirteenth-century Mapungubwe.&lt;/ref&gt;.Izinto ezitholakala eMapungubwe kwabe  kuzimpoto zakade nomncamo werhalasi. Bebathatha izinto lezi bese bakhambe nazo bayozithengisa.

[[Intaba]] yeMapungubwe bewuyikhwelwa uqale emuva, bewuthi nawuyicalako uyicala Kanye bese ucala emuva. Bekungayiwa ebusuku entabeni le.Bekungakhanjiwa kiyo ngombana kunomoya wabaphasi. Intaba yakhona bekuyindawo yobukhosi nendawo lapho kubekwa khona ezinye izinto eziqakathekileko&lt;ref&gt;Ramji, H., 2020. Producing the Precolonial: Professional and Popular Lives of Mapungubwe, 1937-2017.&lt;/ref&gt;.</text>
      <sha1>iz04wxetp0tjtcouc82zbip7yrdzqrf</sha1>
    </revision>
    <revision>
      <id>3419</id>
      <parentid>3107</parentid>
      <timestamp>2025-07-12T14:01:05Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3419</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1811" sha1="snbo57apzpmimws1asfnjq98qvt3juu" xml:space="preserve">[[Isimumathi:Mapungubwe, Limpopo, South Africa (20356165510).jpg|thumb|IMapungubwe]]
'''IMapungubwe''' yindawo yokuthoma eSewula Africa. Indawo le isesiphandeni seLimpopo eduze nomlambo weshashe. Bekuyindawo ezele iindlovu ezinengi abantu bebasuka la bahlala khona  beze bazokuzingela [[iindlovu]] bafuna iimpondo zeendlovu ezibizwa bona yi-ivory ngelimi lesiNgisi. Bazithathe bayozithengisa kwamanye amazwe begodu bebahlala emaplasini ahlukahlukeneko begodu asemaduzelana.&lt;ref&gt;Meskell, L., 2016. Mapungubwe Cultural Landscape. ''World Heritage on the Ground: Ethnographic Perspectives'', ''28'', p.273.&lt;/ref&gt;    

=== Isikopilo leMapungu'''bwe''' ===
Ikosi yakhona beyihlala phezulu kwesicongolwana esibizwa bona yiMapungubwe hill ngombana lapho bekuhlala imimoya yabaphasi begodu beyikghona ukukhulumna nabo. Amadoda bekanamandla ukudlula abafazi begodu umuntu omncani bekangaphathwa njengomuntu omkhulu. Bekunabantu abafunda ilikade ababizwa bona Archeologist bebakhamba baya eMapungubwe bayokugubha bathola bona le bekuyindawo yabantu abanothileko ngombana kwatholakala khona ubuhlalo begolide, izitja zobumba n[[amathambo]] weenlwana.&lt;ref&gt;Ashley, C. and Antonites, A., 2020. Art and the everyday: gold, ceramics and meaning in thirteenth-century Mapungubwe.&lt;/ref&gt;Izinto ezitholakala eMapungubwe kwabe  kuzimpoto zakade nomncamo werhalasi. Bebathatha izinto lezi bese bakhambe nazo bayozithengisa. [[Intaba]] yeMapungubwe bewuyikhwelwa uqale emuva, bewuthi nawuyicalako uyicala Kanye bese ucala emuva. Bekungayiwa ebusuku entabeni le.Bekungakhanjiwa kiyo ngombana kunomoya wabaphasi. Intaba yakhona bekuyindawo yobukhosi nendawo lapho kubekwa khona ezinye izinto eziqakathekileko.&lt;ref&gt;Ramji, H., 2020. Producing the Precolonial: Professional and Popular Lives of Mapungubwe, 1937-2017.&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>snbo57apzpmimws1asfnjq98qvt3juu</sha1>
    </revision>
    <revision>
      <id>3420</id>
      <parentid>3419</parentid>
      <timestamp>2025-07-12T14:01:56Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3420</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1805" sha1="ejvo4t6vthfd1swdnxerdivj85jlms3" xml:space="preserve">[[Isimumathi:Mapungubwe, Limpopo, South Africa (20356165510).jpg|thumb|IMapungubwe]]
'''IMapungubwe''' yindawo yokuthoma eSewula Africa. Indawo le isesiphandeni seLimpopo eduze nomlambo weshashe. Bekuyindawo ezele iindlovu ezinengi abantu bebasuka la bahlala khona  beze bazokuzingela [[iindlovu]] bafuna iimpondo zeendlovu ezibizwa bona yi-ivory ngelimi lesiNgisi. Bazithathe bayozithengisa kwamanye amazwe begodu bebahlala emaplasini ahlukahlukeneko begodu asemaduzelana.&lt;ref&gt;Meskell, L., 2016. Mapungubwe Cultural Landscape. ''World Heritage on the Ground: Ethnographic Perspectives'', ''28'', p.273.&lt;/ref&gt;    

=== Isikopilo leMapungubwe ===
Ikosi yakhona beyihlala phezulu kwesicongolwana esibizwa bona yiMapungubwe hill ngombana lapho bekuhlala imimoya yabaphasi begodu beyikghona ukukhulumna nabo. Amadoda bekanamandla ukudlula abafazi begodu umuntu omncani bekangaphathwa njengomuntu omkhulu. Bekunabantu abafunda ilikade ababizwa bona Archeologist bebakhamba baya eMapungubwe bayokugubha bathola bona le bekuyindawo yabantu abanothileko ngombana kwatholakala khona ubuhlalo begolide, izitja zobumba n[[amathambo]] weenlwana.&lt;ref&gt;Ashley, C. and Antonites, A., 2020. Art and the everyday: gold, ceramics and meaning in thirteenth-century Mapungubwe.&lt;/ref&gt;Izinto ezitholakala eMapungubwe kwabe  kuzimpoto zakade nomncamo werhalasi. Bebathatha izinto lezi bese bakhambe nazo bayozithengisa. [[Intaba]] yeMapungubwe bewuyikhwelwa uqale emuva, bewuthi nawuyicalako uyicala Kanye bese ucala emuva. Bekungayiwa ebusuku entabeni le.Bekungakhanjiwa kiyo ngombana kunomoya wabaphasi. Intaba yakhona bekuyindawo yobukhosi nendawo lapho kubekwa khona ezinye izinto eziqakathekileko.&lt;ref&gt;Ramji, H., 2020. Producing the Precolonial: Professional and Popular Lives of Mapungubwe, 1937-2017.&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>ejvo4t6vthfd1swdnxerdivj85jlms3</sha1>
    </revision>
    <revision>
      <id>5642</id>
      <parentid>3420</parentid>
      <timestamp>2025-09-04T10:54:43Z</timestamp>
      <contributor>
        <username>Mannroy</username>
        <id>879</id>
      </contributor>
      <comment>/* Isikopilo leMapungubwe */</comment>
      <origin>5642</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1864" sha1="ind5lezkoo5l02nzp9p8296jd57m4fc" xml:space="preserve">[[Isimumathi:Mapungubwe National Park sign in 2005.jpg|left|thumb|556x556px|Isithombe sendawo i-Mapungubwe national park and heritage site]]
'''IMapungubwe''' yindawo yokuthoma eSewula Africa. Indawo le isesiphandeni seLimpopo eduze nomlambo weshashe. Bekuyindawo ezele iindlovu ezinengi abantu bebasuka la bahlala khona  beze bazokuzingela iindlovu bafuna iimpondo zeendlovu ezibizwa bona yi-ivory ngelimi lesiNgisi. Bazithathe bayozithengisa kwamanye amazwe begodu bebahlala emaplasini ahlukahlukeneko begodu asemaduzelana.&lt;ref&gt;Meskell, L., 2016. Mapungubwe Cultural Landscape. ''World Heritage on the Ground: Ethnographic Perspectives'', ''28'', p.273.&lt;/ref&gt;    

=== Isikopilo leMapungubwe ===
Ikosi yakhona beyihlala phezulu kwesicongolwana esibizwa bona yiMapungubwe hill ngombana lapho bekuhlala imimoya yabaphasi begodu beyikghona ukukhuluma nabo. Amadoda bekanamandla ukudlula abafazi begodu umuntu omncani bekangaphathwa njengomuntu omkhulu. Bekunabantu abafunda ilikade ababizwa bona Archeologist bebakhamba baya eMapungubwe bayokugubha bathola bona le bekuyindawo yabantu abanothileko ngombana kwatholakala khona ubuhlalo begolide, izitja zobumba n[[amathambo]] weenlwana.&lt;ref&gt;Ashley, C. and Antonites, A., 2020. Art and the everyday: gold, ceramics and meaning in thirteenth-century Mapungubwe.&lt;/ref&gt;Izinto ezitholakala eMapungubwe kwabe  kuziimpoto zakade nomncamo werhalasi. Bebathatha izinto lezi bese bakhambe nazo bayozithengisa. [[Intaba]] yeMapungubwe bewuyikhwelwa uqale emuva, bewuthi nawuyicalako uyicala Kanye bese ucala emuva. Bekungayiwa ebusuku entabeni le.Bekungakhanjiwa kiyo ngombana kunomoya wabaphasi. Intaba yakhona bekuyindawo yobukhosi nendawo lapho kubekwa khona ezinye izinto eziqakathekileko.&lt;ref&gt;Ramji, H., 2020. Producing the Precolonial: Professional and Popular Lives of Mapungubwe, 1937-2017.&lt;/ref&gt;

== Imithombo lwazi ==</text>
      <sha1>ind5lezkoo5l02nzp9p8296jd57m4fc</sha1>
    </revision>
  </page>
  <page>
    <title>Ukuthaba</title>
    <ns>0</ns>
    <id>493</id>
    <revision>
      <id>2483</id>
      <timestamp>2025-03-03T10:43:56Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Ukuthaba == Ukuthaba kukulokha uzizwa kamnandi emphefumulweni, wanelisekile begodu unganasidingo esikutlhorisako. Ukuthaba yinto yangaphakathi komuntu kodwana ithelelwa  zizinto ezenzeka ebhodulukweni lomuntu. Isibonelo lokho umunu nasele azuza umnotho, ukuhlonipheka nobudlelwano obuhle ngabantu uzthola athabile ngokwemvelo&lt;ref&gt;Veenhoven, R., 2016. Quality of life and happiness: Concepts and measures. In ''Handbook of research methods and applications in happiness and...&quot;</comment>
      <origin>2483</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3193" sha1="cczglm5lxrpq1lfndxeb5hjo121vi4l" xml:space="preserve">== Ukuthaba ==
Ukuthaba kukulokha uzizwa kamnandi emphefumulweni, wanelisekile begodu unganasidingo esikutlhorisako. Ukuthaba yinto yangaphakathi komuntu kodwana ithelelwa  zizinto ezenzeka ebhodulukweni lomuntu. Isibonelo lokho umunu nasele azuza umnotho, ukuhlonipheka nobudlelwano obuhle ngabantu uzthola athabile ngokwemvelo&lt;ref&gt;Veenhoven, R., 2016. Quality of life and happiness: Concepts and measures. In ''Handbook of research methods and applications in happiness and quality of life'' (pp. 309-333). Edward Elgar Publishing.&lt;/ref&gt;.

== Ubuhle bokuhlala uthabile ==
Umuntu ohlala athabile akusilula bona angenwe magulo, begodu negazi lakhe likhamba kuhle emzimbeni lingaphazamiseki, amosotja womzimba ahlala wakhe ahlala qinile anamandla. Abantu abahlala bathabile bagcine baphile iskhathi eside bangagugi msinyanaAbantu abalala bathabile bakghona ukwenza ubudlelalwane nabanye abantu lula begodu bakghona nokuthuthukisa mphakathi wabo ebahlala kiwo&lt;ref&gt;Diener, Ed, and Louis Tay. &quot;A scientific review of the remarkable benefits of happiness for successful and healthy living.&quot; ''Happiness: Transforming the development landscape'' 6 (2017): 90-117.&lt;/ref&gt;.

== Izinto ezingavimbela abantu bona bangathabi ==
Ukusaba, ukungazithembi kungenza bona umuntu abe nobudisi bokuhlala athabile. Ukucabanga izinto eziceda ithemba nakho kuyamezna bona umuntu aphelelwe lithbo bese agcine adanile ngombana ugcina sele azizwa ngathi akukho okuhle angakwenza.

Indlala nayo iyemenza umuntu bona angathabi ngombana akekho umuntu ongathaba lokha nakaswelileko   nofana nakanganayo imali yokufeza iindingo zakhe. Woke umuntu isidingo sakhe sokuthoma kukudla nasele angatholi imali ezomlekela bona adle nofana ageze angekhe kube lula bona ahlale athabile&lt;ref&gt;Harrison, C., 2019. ''Anti-diet: Reclaim your time, money, well-being, and happiness through intuitive eating''. Hachette UK.&lt;/ref&gt;. 

Inkundla zokuthintana zingenza bona umuntu angathabi ngombana abantu bafaka okuhle ukubenzakalelako kwaphela, bese umunye umuntu onganalwazi angathi nakatjheje lokho eenkundlwni zokuthintana zibone ngathi nguye yeswa onemiraro  agcine see aphelelwa lithabo&lt;ref&gt;Freitas, D., 2017. ''The happiness effect: How social media is driving a generation to appear perfect at any cost''. Oxford University Press.&lt;/ref&gt;.

== Izinto ongazenza ukuhlala uthabile ==

=== Ukuzithabulula ===
Ukuzithabulula nokudla Ukudla okunepilo kuyasiza bona umuntu ahlale athabile ngombana ukuzithsbulula kwehlisa izinga lokukhathazeka emuntwini. Ukulala esikhathi esaneleko esilingana ama-iri ali-8 khona umzimba uzokutholaisikhathi sokuphumula kuhle&lt;ref&gt;Li, C., Ning, G. and Xia, Y., 2023. Does exercise participation promote happiness?: Mediations and heterogeneities. ''Frontiers in Public Health'', ''11'', p.1033157.&lt;/ref&gt;.

=== Ukuzinakekela ===
Umuntu ukuze ahlale athabile kufuze bona enze izinto zokuledlha, azikhiphile endaweni zokuzithabisa, enze ne-yoga ukuze alekelele umizwa yakhe bona ijabule&lt;ref&gt;Butler, L.D., Mercer, K.A., McClain-Meeder, K., Horne, D.M. and Dudley, M., 2019. Six domains of self-care: Attending to the whole person. ''Journal of human behavior in the social environment'', ''29''(1), pp.107-124.&lt;/ref&gt;</text>
      <sha1>cczglm5lxrpq1lfndxeb5hjo121vi4l</sha1>
    </revision>
    <revision>
      <id>2545</id>
      <parentid>2483</parentid>
      <timestamp>2025-03-19T11:56:11Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2545</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3195" sha1="5l7kigsbm8v1xe2jyc5utpud5wjmsyw" xml:space="preserve">== Ukuthaba ==
Ukuthaba kukulokha uzizwa kamnandi emphefumulweni, wanelisekile begodu unganasidingo esikutlhorisako. Ukuthaba yinto yangaphakathi komuntu kodwana ithelelwa  zizinto ezenzeka ebhodulukweni lomuntu. Isibonelo lokha umuntu nasele azuza umnotho, ukuhlonipheka nobudlelwano obuhle ngabantu uzithola athabile ngokwemvelo&lt;ref&gt;Veenhoven, R., 2016. Quality of life and happiness: Concepts and measures. In ''Handbook of research methods and applications in happiness and quality of life'' (pp. 309-333). Edward Elgar Publishing.&lt;/ref&gt;.

== Ubuhle bokuhlala uthabile ==
Umuntu ohlala athabile akusilula bona angenwe magulo, begodu negazi lakhe likhamba kuhle emzimbeni lingaphazamiseki, amosotja womzimba ahlala wakhe ahlala qinile anamandla. Abantu abahlala bathabile bagcine baphile iskhathi eside bangagugi msinyanaAbantu abalala bathabile bakghona ukwenza ubudlelalwane nabanye abantu lula begodu bakghona nokuthuthukisa mphakathi wabo ebahlala kiwo&lt;ref&gt;Diener, Ed, and Louis Tay. &quot;A scientific review of the remarkable benefits of happiness for successful and healthy living.&quot; ''Happiness: Transforming the development landscape'' 6 (2017): 90-117.&lt;/ref&gt;.

== Izinto ezingavimbela abantu bona bangathabi ==
Ukusaba, ukungazithembi kungenza bona umuntu abe nobudisi bokuhlala athabile. Ukucabanga izinto eziceda ithemba nakho kuyamezna bona umuntu aphelelwe lithbo bese agcine adanile ngombana ugcina sele azizwa ngathi akukho okuhle angakwenza.

Indlala nayo iyemenza umuntu bona angathabi ngombana akekho umuntu ongathaba lokha nakaswelileko   nofana nakanganayo imali yokufeza iindingo zakhe. Woke umuntu isidingo sakhe sokuthoma kukudla nasele angatholi imali ezomlekela bona adle nofana ageze angekhe kube lula bona ahlale athabile&lt;ref&gt;Harrison, C., 2019. ''Anti-diet: Reclaim your time, money, well-being, and happiness through intuitive eating''. Hachette UK.&lt;/ref&gt;. 

Inkundla zokuthintana zingenza bona umuntu angathabi ngombana abantu bafaka okuhle ukubenzakalelako kwaphela, bese umunye umuntu onganalwazi angathi nakatjheje lokho eenkundlwni zokuthintana zibone ngathi nguye yeswa onemiraro  agcine see aphelelwa lithabo&lt;ref&gt;Freitas, D., 2017. ''The happiness effect: How social media is driving a generation to appear perfect at any cost''. Oxford University Press.&lt;/ref&gt;.

== Izinto ongazenza ukuhlala uthabile ==

=== Ukuzithabulula ===
Ukuzithabulula nokudla Ukudla okunepilo kuyasiza bona umuntu ahlale athabile ngombana ukuzithsbulula kwehlisa izinga lokukhathazeka emuntwini. Ukulala esikhathi esaneleko esilingana ama-iri ali-8 khona umzimba uzokutholaisikhathi sokuphumula kuhle&lt;ref&gt;Li, C., Ning, G. and Xia, Y., 2023. Does exercise participation promote happiness?: Mediations and heterogeneities. ''Frontiers in Public Health'', ''11'', p.1033157.&lt;/ref&gt;.

=== Ukuzinakekela ===
Umuntu ukuze ahlale athabile kufuze bona enze izinto zokuledlha, azikhiphile endaweni zokuzithabisa, enze ne-yoga ukuze alekelele umizwa yakhe bona ijabule&lt;ref&gt;Butler, L.D., Mercer, K.A., McClain-Meeder, K., Horne, D.M. and Dudley, M., 2019. Six domains of self-care: Attending to the whole person. ''Journal of human behavior in the social environment'', ''29''(1), pp.107-124.&lt;/ref&gt;</text>
      <sha1>5l7kigsbm8v1xe2jyc5utpud5wjmsyw</sha1>
    </revision>
    <revision>
      <id>2546</id>
      <parentid>2545</parentid>
      <timestamp>2025-03-19T11:57:26Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2546</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3197" sha1="pbbtcorisf2mf8wtght25c0k2gnz4dg" xml:space="preserve">== Ukuthaba ==
Ukuthaba kukulokha uzizwa kamnandi emphefumulweni, wanelisekile begodu unganasidingo esikutlhorisako. Ukuthaba yinto yangaphakathi komuntu kodwana ithelelwa  zizinto ezenzeka ebhodulukweni lomuntu. Isibonelo lokha umuntu nasele azuza umnotho, ukuhlonipheka nobudlelwano obuhle ngabantu uzithola athabile ngokwemvelo&lt;ref&gt;Veenhoven, R., 2016. Quality of life and happiness: Concepts and measures. In ''Handbook of research methods and applications in happiness and quality of life'' (pp. 309-333). Edward Elgar Publishing.&lt;/ref&gt;.

== Ubuhle bokuhlala uthabile ==
Umuntu ohlala athabile akusilula bona angenwe magulo, begodu negazi lakhe likhamba kuhle emzimbeni lingaphazamiseki, amosotja womzimba ahlala wakhe ahlala qinile anamandla. Abantu abahlala bathabile bagcine baphile iskhathi eside bangagugi msinyanaAbantu abalala bathabile bakghona ukwenza ubudlelalwane nabanye abantu lula begodu bakghona nokuthuthukisa mphakathi wabo ebahlala kiwo&lt;ref&gt;Diener, Ed, and Louis Tay. &quot;A scientific review of the remarkable benefits of happiness for successful and healthy living.&quot; ''Happiness: Transforming the development landscape'' 6 (2017): 90-117.&lt;/ref&gt;.

== Izinto ezingavimbela abantu bona bangathabi ==
Ukusaba, ukungazithembi kungenza bona umuntu abe nobudisi bokuhlala athabile. Ukucabanga izinto eziceda ithemba nakho kuyamenza bona umuntu aphelelwe lithabo bese agcine adanile ngombana ugcina sele azizwa ngathi akukho okuhle angakwenza.

Indlala nayo iyamenza umuntu bona angathabi ngombana akekho umuntu ongathaba lokha nakaswelileko   nofana nakanganayo imali yokufeza iindingo zakhe. Woke umuntu isidingo sakhe sokuthoma kukudla nasele angatholi imali ezomlekela bona adle nofana ageze angekhe kube lula bona ahlale athabile&lt;ref&gt;Harrison, C., 2019. ''Anti-diet: Reclaim your time, money, well-being, and happiness through intuitive eating''. Hachette UK.&lt;/ref&gt;. 

Inkundla zokuthintana zingenza bona umuntu angathabi ngombana abantu bafaka okuhle ukubenzakalelako kwaphela, bese umunye umuntu onganalwazi angathi nakatjheje lokho eenkundleni zokuthintana azibone ngathi nguye yedwa onemiraro  agcine see aphelelwa lithabo&lt;ref&gt;Freitas, D., 2017. ''The happiness effect: How social media is driving a generation to appear perfect at any cost''. Oxford University Press.&lt;/ref&gt;.

== Izinto ongazenza ukuhlala uthabile ==

=== Ukuzithabulula ===
Ukuzithabulula nokudla Ukudla okunepilo kuyasiza bona umuntu ahlale athabile ngombana ukuzithsbulula kwehlisa izinga lokukhathazeka emuntwini. Ukulala esikhathi esaneleko esilingana ama-iri ali-8 khona umzimba uzokutholaisikhathi sokuphumula kuhle&lt;ref&gt;Li, C., Ning, G. and Xia, Y., 2023. Does exercise participation promote happiness?: Mediations and heterogeneities. ''Frontiers in Public Health'', ''11'', p.1033157.&lt;/ref&gt;.

=== Ukuzinakekela ===
Umuntu ukuze ahlale athabile kufuze bona enze izinto zokuledlha, azikhiphile endaweni zokuzithabisa, enze ne-yoga ukuze alekelele umizwa yakhe bona ijabule&lt;ref&gt;Butler, L.D., Mercer, K.A., McClain-Meeder, K., Horne, D.M. and Dudley, M., 2019. Six domains of self-care: Attending to the whole person. ''Journal of human behavior in the social environment'', ''29''(1), pp.107-124.&lt;/ref&gt;</text>
      <sha1>pbbtcorisf2mf8wtght25c0k2gnz4dg</sha1>
    </revision>
  </page>
  <page>
    <title>Ukukhubazeka</title>
    <ns>0</ns>
    <id>494</id>
    <revision>
      <id>2484</id>
      <timestamp>2025-03-03T11:03:13Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Ukukhubazeka == '''Kukulokha''' umuntu aphila  angaguli kodwana kube khona isitho sakhe somzimba esingekho, esingasebenziko nofana esingakakheki kuhle njengasabanye ngokwemvelo. Ukukhubazeka akutjho bona umuntu uyahluleka nofana kufanale aphathwe ngokuhluka kunabanye abantu. Ukukhubazeka kungaba yinto umuntu azalwa nayo nofana kuyinto engehlela umuntu lokha aphile bese ehlelwe kugula nofana ingozi ezomtjhiya akhubazikile&lt;ref&gt;Retief, M. and Letšosa, R., 2018. Models o...&quot;</comment>
      <origin>2484</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4501" sha1="jfe4fhlf87a1up47tv0gp8se1hqeqoy" xml:space="preserve">== Ukukhubazeka ==
'''Kukulokha''' umuntu aphila  angaguli kodwana kube khona isitho sakhe somzimba esingekho, esingasebenziko nofana esingakakheki kuhle njengasabanye ngokwemvelo. Ukukhubazeka akutjho bona umuntu uyahluleka nofana kufanale aphathwe ngokuhluka kunabanye abantu. Ukukhubazeka kungaba yinto umuntu azalwa nayo nofana kuyinto engehlela umuntu lokha aphile bese ehlelwe kugula nofana ingozi ezomtjhiya akhubazikile&lt;ref&gt;Retief, M. and Letšosa, R., 2018. Models of disability: A brief overview. ''HTS Teologiese Studies/Theological Studies'', ''74''(1).&lt;/ref&gt;.
Abantu abakhubazekileko eSewula Afrika banesibonelelo semali abasitholako esivela kurhulamnde. Isibonelelo lesi sibalekela bona bakghone ukufeza iindingo zabo begodu bakgone ukuba nemali yokudla ngombana abanye babo abakghoni ukusebenza. 

== Izinto ezingabangela ukukhubazaka ==

=== Iindakamizwa ===
Umuntu wengubo lokha nakasidisi bese asebenzise iindakamizwa kungabangela bona Umntwana akhubazele ngombana iindakamizwa zizothikameza bona Umntwana akhule ngesibelthweni bese Umntwana agcine sele akhubazekile. Umntwana angakhubazeka emzimbeni nofana emkhumbulweni&lt;ref&gt;Viteri, O.A., Soto, E.E., Bahado-Singh, R.O., Christensen, C.W., Chauhan, S.P. and Sibai, B.M., 2015. Fetal anomalies and long-term effects associated with substance abuse in pregnancy: a literature review. ''American journal of perinatology'', ''32''(05), pp.405-416.&lt;/ref&gt;.

=== Ukulimala ===
Umuntu nakasidisi nakungenzeka bona awe kabuhlungu nofanaavelelwe yingozi lokhu kungenza bona Umntwana asidisi yena avele akhubazekile. Okhunye kungenzeak bona kwenzakale iimphoso lokha umma nakabelathako lokhu kungenza bona avele akhubazekile&lt;ref&gt;Wilkinson, D., Shepherd, E. and Wallace, E.M., 2016. Melatonin for women in pregnancy for neuroprotection of the fetus. ''Cochrane Database of Systematic Reviews'', (3).&lt;/ref&gt;.

=== Isotja lomndeni ===
Okhunye ukukhubazeka komntwana kungabangelwa lisotja lomndeni bese isotja leli lidlulele emntwaneni.  Isibonelo nangabe Umntwana ubelethwa emndenini wabantu abangakaphili kuhle engcondweni kunamathuba wokobana nomntwana wakhona angpvela angakaphili engcondweni ngombana kuzabe kudlulele isotja lomndeni lokukhubazeka emntwaneni&lt;ref&gt;Vasudevan, P. and Suri, M., 2017. A clinical approach to developmental delay and intellectual disability. ''Clinical Medicine'', ''17''(6), pp.558-561.&lt;/ref&gt;.

== Imihlobo yokukhubazeka ==

=== Ukukhubazeka komzimba ===
Lokhu kukhubazeka ngilokhu ekwenza bona umuntu angakhoni ukukhamba. Lokhu kubangelwa kukobana aquntwe inyawo, isifo samathambo nokhunye. Omunye angahlala angabi nesandla ngesibanga sengozi angina kiyo nofana isandla singasebenzi ngesibanga sokuthi alimele imisipha bese imisipha le yenza bona isandla singakghoni ukusebenza. Abanye babelethwa banganazo&lt;ref&gt;Retief, M. and Letšosa, R., 2018. Models of disability: A brief overview. ''HTS Teologiese Studies/Theological Studies'', ''74''(1).&lt;/ref&gt; inyawo nofana izandla. Laba abanganazo inyawo basebenzisa isitulo samavilo ukukhamba.

=== Ukukhubazeka zithozombiza(Sensory) ===
Abanye abantu babanokukhubazeka bokungaboni emehlweni, nofana babone ngokufifiyela. Ukukhubazela lokhu kungabangelwa kugula okufana nama-Cataracts, glaucoma nokhunye.Ananye abantu bazalwa bangezwa  nofaa banobudisi bokuzwa  nesibanga sokubana kulimele I cochlear ngaphakathi kwendlebe zabo. Icochelear kuyinto engaphakthi kwendlebe egobeke ngathi litjhongololo lokha nalileleko&lt;ref&gt;Sorgini, F., Caliò, R., Carrozza, M.C. and Oddo, C.M., 2018. Haptic-assistive technologies for audition and vision sensory disabilities. ''Disability and Rehabilitation: Assistive Technology'', ''13''(4), pp.394-421.&lt;/ref&gt;.

=== Ukukhubazeka ngokokhumbulo nofana engcondweni ===
Ukukhubazeka lokhu kwenza bona umumntu ingcondo yakhe ingasebenzi kuhle&lt;ref&gt;Nevison, C.D. and Blaxill, M., 2017. Diagnostic substitution for intellectual disability: A flawed explanation for the rise in autism. ''Journal of Autism and Developmental Disorders'', ''47'', pp.2733-2742.&lt;/ref&gt;. Okhunye ukukhubazeka kungavela ngokuthi Umntwana abe ne autism ekuyinto eyenza bona Umntwana abenobudisi bokukhuluma nokuzibandakanya abantu athande ukuba yedwa. Umuntu oone autism akafuni abantu basenzise izinto zakhe begodu akazwani namatjhuguluko enzeka yena akangakatjelwa.

== Isiphetho ==
Ukuphila nokukhubazeka akutjho ukwahluleka ngombana abantu abakhubazekilo bayokghona ukuphila njengabanye abantu benze izinto ezikulu ezitjengisako bona baphelele begodu bahlakaniphile.</text>
      <sha1>jfe4fhlf87a1up47tv0gp8se1hqeqoy</sha1>
    </revision>
  </page>
  <page>
    <title>Iinarhakazi zephasi</title>
    <ns>0</ns>
    <id>495</id>
    <revision>
      <id>2485</id>
      <timestamp>2025-03-03T12:58:56Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''Ephasini''' kuneenarhakazi ezilikhomba, enye nenye inarhakazi inamasiko wayo, amatshwayo wayo neenarha ezingaphakthi kwayo  Iinarhakazi zephasi&lt;ref&gt;Yearwood, P.J., 2014. Continents and consequences: the history of a concept. ''Journal of Global History'', ''9''(3), pp.329-356.&lt;/ref&gt;.  I-Africa  Yinarhakazi yesibili ekulu begodu ngaphakathi iphethe inarha ezima-55 ezifaka hlangana i-Sewila Africa, i-gibhithe neZimbabwe&lt;ref&gt;Khapoya, V., 2015. ''The African Experience''....&quot;</comment>
      <origin>2485</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1500" sha1="22rq75dfki3o8pnzwumyo5lwj0ck9uz" xml:space="preserve">'''Ephasini''' kuneenarhakazi ezilikhomba, enye nenye inarhakazi inamasiko wayo, amatshwayo wayo neenarha ezingaphakthi kwayo

Iinarhakazi zephasi&lt;ref&gt;Yearwood, P.J., 2014. Continents and consequences: the history of a concept. ''Journal of Global History'', ''9''(3), pp.329-356.&lt;/ref&gt;.

I-Africa

Yinarhakazi yesibili ekulu begodu ngaphakathi iphethe inarha ezima-55 ezifaka hlangana i-Sewila Africa, i-gibhithe neZimbabwe&lt;ref&gt;Khapoya, V., 2015. ''The African Experience''. Routledge.&lt;/ref&gt;

I-Antarctica

Yinarhakazi encani begodu emakhazi ukuzidlula zoke. Enarhakazini le akuhlali abantu kodwana kuhlala iinlwana zemangweni zodwa.

I-Asia

Lapha kuneenarha ezima-49, ezifaka hlagana I inarha ye China, India Kanye ne Russia ekuyinarha ekulu ukuzidlula zoke ephasini. Inarhakazi le ngekulu ukuzidlula zoke ephasini&lt;ref&gt;Prange, C., 2019. Asia: The continent of superlatives and contradictions. In ''Management Practices in Asia: Case Studies on Market Entry, CSR, and Coaching'' (pp. 3-9). Cham: Springer International Publishing.&lt;/ref&gt;

I-Australia

Le yinarhakazi encani ehlalwa babantu ephasini, ngaphakathi iineenarha ezi-6 ezine zazo yi- New Zealad, Papua New Guiea ne Australia.

I-Europe

Kulenarhakazi  kunenenrha ezima-50 ezifaka I- Germany, iFrance, ne-United kingdom.Inarhakazi le ngeyesithandathu ekulu

I-North America

Inarhakazi le ilikhaya leenarha ezima-23 begodu ingeyesithathu ekulu 

I-South America

Inarhakazi le ineenarha ezili-12 begodu ingee ingeyesine ekule eeenarhakazini</text>
      <sha1>22rq75dfki3o8pnzwumyo5lwj0ck9uz</sha1>
    </revision>
    <revision>
      <id>2486</id>
      <parentid>2485</parentid>
      <timestamp>2025-03-03T13:00:22Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2486</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1579" sha1="9w3c3l37zkyhpyraf5k5w6kf5msh2jv" xml:space="preserve">== Iinarhakazi zephasi ==
'''Ephasini''' kuneenarhakazi ezilikhomba, enye nenye inarhakazi inamasiko wayo, amatshwayo wayo neenarha ezingaphakthi kwayo

Iinarhakazi zephasi&lt;ref&gt;Yearwood, P.J., 2014. Continents and consequences: the history of a concept. ''Journal of Global History'', ''9''(3), pp.329-356.&lt;/ref&gt;.

== Amagama weenarhakazi zephasi nehlathululo yazo ==
I-Africa

Yinarhakazi yesibili ekulu begodu ngaphakathi iphethe inarha ezima-55 ezifaka hlangana i-Sewila Africa, i-gibhithe neZimbabwe&lt;ref&gt;Khapoya, V., 2015. ''The African Experience''. Routledge.&lt;/ref&gt;

I-Antarctica

Yinarhakazi encani begodu emakhazi ukuzidlula zoke. Enarhakazini le akuhlali abantu kodwana kuhlala iinlwana zemangweni zodwa.

I-Asia

Lapha kuneenarha ezima-49, ezifaka hlagana I inarha ye China, India Kanye ne Russia ekuyinarha ekulu ukuzidlula zoke ephasini. Inarhakazi le ngekulu ukuzidlula zoke ephasini&lt;ref&gt;Prange, C., 2019. Asia: The continent of superlatives and contradictions. In ''Management Practices in Asia: Case Studies on Market Entry, CSR, and Coaching'' (pp. 3-9). Cham: Springer International Publishing.&lt;/ref&gt;

I-Australia

Le yinarhakazi encani ehlalwa babantu ephasini, ngaphakathi iineenarha ezi-6 ezine zazo yi- New Zealad, Papua New Guiea ne Australia.

I-Europe

Kulenarhakazi  kunenenrha ezima-50 ezifaka I- Germany, iFrance, ne-United kingdom.Inarhakazi le ngeyesithandathu ekulu

I-North America

Inarhakazi le ilikhaya leenarha ezima-23 begodu ingeyesithathu ekulu 

I-South America

Inarhakazi le ineenarha ezili-12 begodu ingee ingeyesine ekule eeenarhakazini</text>
      <sha1>9w3c3l37zkyhpyraf5k5w6kf5msh2jv</sha1>
    </revision>
    <revision>
      <id>2498</id>
      <parentid>2486</parentid>
      <timestamp>2025-03-04T05:50:48Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2498</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1581" sha1="l9vbafphjs7fdn4c343ekl73xcryvzp" xml:space="preserve">== Iinarhakazi zephasi ==
'''Ephasini''' kuneenarhakazi ezilikhomba, enye nenye inarhakazi inamasiko wayo, amatshwayo wayo neenarha ezingaphakthi kwayo

Iinarhakazi zephasi&lt;ref&gt;Yearwood, P.J., 2014. Continents and consequences: the history of a concept. ''Journal of Global History'', ''9''(3), pp.329-356.&lt;/ref&gt;.

== Amagama weenarhakazi zephasi nehlathululo yazo ==
I-Africa

Yinarhakazi yesibili ekulu begodu ngaphakathi iphethe inarha ezima-55 ezifaka hlangana i-Sewula Africa, i-gibhithe neZimbabwe&lt;ref&gt;Khapoya, V., 2015. ''The African Experience''. Routledge.&lt;/ref&gt;

I-Antarctica

Yinarhakazi encani begodu emakhaza ukuzidlula zoke. Enarhakazini le akuhlali abantu kodwana kuhlala iinlwana zemangweni kwaphela.

I-Asia

Lapha kuneenarha ezima-49, ezifaka hlagana I inarha ye China, India Kanye ne Russia ekuyinarha ekulu ukuzidlula zoke ephasini. Inarhakazi le ngekulu ukuzidlula zoke ephasini&lt;ref&gt;Prange, C., 2019. Asia: The continent of superlatives and contradictions. In ''Management Practices in Asia: Case Studies on Market Entry, CSR, and Coaching'' (pp. 3-9). Cham: Springer International Publishing.&lt;/ref&gt;

I-Australia

Le yinarhakazi encani ehlalwa babantu ephasini, ngaphakathi iineenarha ezi-6 ezine zazo yi- New Zealad, Papua New Guiea ne Australia.

I-Europe

Kulenarhakazi  kunenarha ezima-50 ezifaka I- Germany, iFrance, ne-United kingdom.Inarhakazi le ngeyesithandathu ekulu

I-North America

Inarhakazi le ilikhaya leenarha ezima-23 begodu ingeyesithathu ekulu. 

I-South America

Inarhakazi le ineenarha ezili-12 begodu ingee ingeyesine ekule eenarhakazini</text>
      <sha1>l9vbafphjs7fdn4c343ekl73xcryvzp</sha1>
    </revision>
    <revision>
      <id>5121</id>
      <parentid>2498</parentid>
      <timestamp>2025-08-10T15:15:05Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5121</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1573" sha1="b88cbyrs325a9fqi9tfkg54niefdjwr" xml:space="preserve">'''Ephasini''' kuneenarhakazi ezilikhomba, enye nenye inarhakazi inamasiko wayo, amatshwayo wayo neenarha ezingaphakthi kwayo

Iinarhakazi zephasi&lt;ref&gt;Yearwood, P.J., 2014. Continents and consequences: the history of a concept. ''Journal of Global History'', ''9''(3), pp.329-356.&lt;/ref&gt;.

=== Amagama weenarhakazi zephasi nehlathululo yazo ===
I-Africa

Yinarhakazi yesibili ekulu begodu ngaphakathi iphethe inarha ezima-55 ezifaka hlangana i-Sewula Africa, i-gibhithe neZimbabwe&lt;ref&gt;Khapoya, V., 2015. ''The African Experience''. Routledge.&lt;/ref&gt;

I-Antarctica

Yinarhakazi encani begodu emakhaza ukuzidlula zoke. Enarhakazini le akuhlali abantu kodwana kuhlala iinlwana zemangweni kwaphela.

I-Asia

Lapha kuneenarha ezima-49, ezifaka hlagana I inarha ye China, India Kanye ne Russia ekuyinarha ekulu ukuzidlula zoke ephasini. Inarhakazi le ngekulu ukuzidlula zoke ephasini&lt;ref&gt;Prange, C., 2019. Asia: The continent of superlatives and contradictions. In ''Management Practices in Asia: Case Studies on Market Entry, CSR, and Coaching'' (pp. 3-9). Cham: Springer International Publishing.&lt;/ref&gt;

I-Australia

Le yinarhakazi encani ehlalwa babantu ephasini, ngaphakathi iineenarha ezi-6 ezine zazo yi- New Zealad, Papua New Guiea ne Australia.

I-Europe

Kulenarhakazi  kunenarha ezima-50 ezifaka I- Germany, iFrance, ne-United kingdom.Inarhakazi le ngeyesithandathu ekulu

I-North America

Inarhakazi le ilikhaya leenarha ezima-23 begodu ingeyesithathu ekulu. 

I-South America

Inarhakazi le ineenarha ezili-12 begodu ingee ingeyesine ekule eenarhakazini

== Iinkomba ==</text>
      <sha1>b88cbyrs325a9fqi9tfkg54niefdjwr</sha1>
    </revision>
    <revision>
      <id>5122</id>
      <parentid>5121</parentid>
      <timestamp>2025-08-10T15:16:41Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>5122</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1646" sha1="h2d4mi32wr1jacer9knysigziwv0llx" xml:space="preserve">'''Ephasini''' kuneenarhakazi ezilikhomba, enye nenye inarhakazi inamasiko wayo, amatshwayo wayo neenarha ezingaphakthi kwayo

Iinarhakazi zephasi&lt;ref&gt;Yearwood, P.J., 2014. Continents and consequences: the history of a concept. ''Journal of Global History'', ''9''(3), pp.329-356.&lt;/ref&gt;.

=== Amagama weenarhakazi zephasi nehlathululo yazo ===
I-Africa

Yinarhakazi yesibili ekulu begodu ngaphakathi iphethe inarha ezima-55 ezifaka hlangana i-Sewula Africa, i-gibhithe neZimbabwe&lt;ref&gt;Khapoya, V., 2015. ''The African Experience''. Routledge.&lt;/ref&gt;

I-Antarctica

Yinarhakazi encani begodu emakhaza ukuzidlula zoke. Enarhakazini le akuhlali abantu kodwana kuhlala iinlwana zemangweni kwaphela.

I-Asia

Lapha kuneenarha ezima-49, ezifaka hlagana I inarha ye China, India Kanye ne Russia ekuyinarha ekulu ukuzidlula zoke ephasini. Inarhakazi le ngekulu ukuzidlula zoke ephasini&lt;ref&gt;Prange, C., 2019. Asia: The continent of superlatives and contradictions. In ''Management Practices in Asia: Case Studies on Market Entry, CSR, and Coaching'' (pp. 3-9). Cham: Springer International Publishing.&lt;/ref&gt;

I-Australia

Le yinarhakazi encani ehlalwa babantu ephasini, ngaphakathi iineenarha ezi-6 ezine zazo yi- New Zealad, Papua New Guiea ne Australia.

I-Europe

Kulenarhakazi  kunenarha ezima-50 ezifaka I- Germany, iFrance, ne-United kingdom.Inarhakazi le ngeyesithandathu ekulu

I-North America

Inarhakazi le ilikhaya leenarha ezima-23 begodu ingeyesithathu ekulu. 

I-South America

Inarhakazi le ineenarha ezili-12 begodu ingee ingeyesine ekule eenarhakazini

== Iinkomba ==
[[Category:Iinarhakazi zephasi]]
[[Category:Inarha]]
[[Category:Iphasi]]</text>
      <sha1>h2d4mi32wr1jacer9knysigziwv0llx</sha1>
    </revision>
  </page>
  <page>
    <title>Abangani</title>
    <ns>0</ns>
    <id>496</id>
    <revision>
      <id>2487</id>
      <timestamp>2025-03-03T13:11:34Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Abangani == '''Abangani''' kubabantu ophila nabo ngamalanga begodu obathembako bonyana ungabelana nabo indaba zakho ongazitjeli abanye abantu. Kungilabo bantu abalunikela isekelo olidingako epilweni bakwenze uzizwe wamukelekile begodu uthandwa.Abangani kungilabo bantu abaphila boke bogodu abathanda izinto izifanako begodu abakhona ukucocoa babonisane ngepilo. Kubanantu abazanako bonya umunye uthanda ini begodu akathandi ini, kungilabo bantu abakghona ukukujamela nalok...&quot;</comment>
      <origin>2487</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="639" sha1="agsx5e3vlv3g1etp63c8gfkryt65u6b" xml:space="preserve">== Abangani ==
'''Abangani''' kubabantu ophila nabo ngamalanga begodu obathembako bonyana ungabelana nabo indaba zakho ongazitjeli abanye abantu. Kungilabo bantu abalunikela isekelo olidingako epilweni bakwenze uzizwe wamukelekile begodu uthandwa.Abangani kungilabo bantu abaphila boke bogodu abathanda izinto izifanako begodu abakhona ukucocoa babonisane ngepilo. Kubanantu abazanako bonya umunye uthanda ini begodu akathandi ini, kungilabo bantu abakghona ukukujamela nalokha wena ungekho&lt;ref&gt;Hartup, W.W., 2022. Friendships and their developmental significance. In ''Childhood social development'' (pp. 175-205). Psychology Press.&lt;/ref&gt;</text>
      <sha1>agsx5e3vlv3g1etp63c8gfkryt65u6b</sha1>
    </revision>
    <revision>
      <id>2488</id>
      <parentid>2487</parentid>
      <timestamp>2025-03-03T13:20:10Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2488</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3093" sha1="ozjkdvnnmsbnagbqqhbovk5dw01gxhk" xml:space="preserve">== Abangani ==
'''Abangani''' kubabantu ophila nabo ngamalanga begodu obathembako bonyana ungabelana nabo indaba zakho ongazitjeli abanye abantu. Kungilabo bantu abalunikela isekelo olidingako epilweni bakwenze uzizwe wamukelekile begodu uthandwa.Abangani kungilabo bantu abaphila boke bogodu abathanda izinto izifanako begodu abakhona ukucocoa babonisane ngepilo. Kubanantu abazanako bonya umunye uthanda ini begodu akathandi ini, kungilabo bantu abakghona ukukujamela nalokha wena ungekho&lt;ref&gt;Hartup, W.W., 2022. Friendships and their developmental significance. In ''Childhood social development'' (pp. 175-205). Psychology Press.&lt;/ref&gt;

== '''Ubuhle bokubamngani''' ==
Abangani kubabantu abangasikhuthaza bonyana silinge nofana sense izinto ezitja epilweni ezizosenza bona sikhule nanyana siphumelele. Abangani bangakukhuthaza boan ulandele izinto ongaba nekareko kizo.

Abangani basihlanganisa nabanye abangani babo nofana basise kwezinye indawo lapho sizokwazana khona nanbanye abantu abangasilekelela ukuthuthuka nofana ukufezekisa amaphupho wethu&lt;ref&gt;McCabe, J.M., 2019. ''Connecting in college: How friendship networks matter for academic and social success''. University of Chicago Press.&lt;/ref&gt;. Abangani bangalekela ngezinye izinto zemakhaya ezifana nokuthutha, ukugada abantwana nangemali.Ngesinye isikhathi lokha nawusemrarweni nofana nawudanileko abangani basinikekeza ihlombe esizokulilela kilo sethule imiraro yethu bese umngani akuphe isiluleko nofana akududuze.

== '''Izinto ongazicala ukubona umngani omuhle''' ==

=== '''Ukuthembeka''' ===
Umngani omuhle ujama nawe ngeenkhathi zoke  akusekele. Akakhulumi ngokuhluleka kwakho kwabanye abantu aabngakauthandiko nofana aveze indaba zakho omthembe ngazo. Kumumuntu okutjela amaqiniso nanyana akangazwisa ubuhlungu kangangani, begodu ukghona ukuthembela kuye lokha nawufuna isekelo&lt;ref&gt;Sinaga, J., Woran, R. and Sinambela, J.L., 2022. The Role Of Friendship In Character Development: Lessons From The Biblical Story Of David And Jonathan. ''Berumpun: International Journal of Social, Politics, and Humanities'', ''5''(1), pp.1-8.&lt;/ref&gt;.

=== '''Ukukhuluma''' ===
Kumumuntu okhuluma naye khulu nanyana angekho eduze niyathintana ngomaliledinini. Kumumuntu oghona ukukulalalela lokha nawukhulumako angakupheleli ihliziyo. Nalokha nasele ucedile ukhuluma ukuphendula ngependulwa ezokwakha&lt;ref&gt;Rawlins, W., 2017. ''Friendship matters: Communication, dialectics and the life course''. Routledge.&lt;/ref&gt;.

=== '''Izwelo''' ===
Umngani omuhle lokha nawehlelwe zizimo nofana iintjhijio ezinzima kuba okukhombisa ukuzwelana nawe. Uzifaka enyathelweni zakho  azisise amazizo wakho  nombona wakho ngesikhathi leso&lt;ref&gt;Gokalp, A. and Inel, Y., 2021. The Mediating Role of Responsibility and Friendship between Empathy Skill and Benevolence. ''Journal of Education and Learning (EduLearn)'', ''15''(2), pp.202-212.&lt;/ref&gt;.

== '''Isiphetho''' ==
Ubungani kuyinto kuyinto ehle eletha ithabo, ukududuzeka  emaphilweni wabantu umuntu lokha anakathole umngani omuhle kufuze bona ache ubudlelwane bakhe nomngani loyo bukhule buhlale iminyaka.</text>
      <sha1>ozjkdvnnmsbnagbqqhbovk5dw01gxhk</sha1>
    </revision>
    <revision>
      <id>2490</id>
      <parentid>2488</parentid>
      <timestamp>2025-03-03T17:22:43Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2490</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3093" sha1="s88gq1ahc8q6o1y4x05bdyrq4gp8vjf" xml:space="preserve">== Abangani ==
'''Abangani''' kubabantu ophila nabo ngamalanga begodu obathembako bonyana ungabelana nabo indaba zakho ongazitjeli abanye abantu. Kungilabo bantu abalunikela isekelo olidingako epilweni bakwenze uzizwe wamukelekile begodu uthandwa.Abangani kungilabo bantu abaphila boke bogodu abathanda izinto izifanako begodu abakhona ukucocoa babonisane ngepilo. Kubabantu abazanako bonya umunye uthanda ini begodu akathandi ini, kungilabo bantu abakghona ukukujamela nalokha wena ungekho&lt;ref&gt;Hartup, W.W., 2022. Friendships and their developmental significance. In ''Childhood social development'' (pp. 175-205). Psychology Press.&lt;/ref&gt;

== '''Ubuhle bokubamngani''' ==
Abangani kubabantu abangasikhuthaza bonyana silinge nofana sense izinto ezitja epilweni ezizosenza bona sikhule nanyana siphumelele. Abangani bangakukhuthaza boan ulandele izinto ongaba nekareko kizo.

Abangani basihlanganisa nabanye abangani babo nofana basise kwezinye indawo lapho sizokwazana khona nanbanye abantu abangasilekelela ukuthuthuka nofana ukufezekisa amaphupho wethu&lt;ref&gt;McCabe, J.M., 2019. ''Connecting in college: How friendship networks matter for academic and social success''. University of Chicago Press.&lt;/ref&gt;. Abangani bangalekela ngezinye izinto zemakhaya ezifana nokuthutha, ukugada abantwana nangemali.Ngesinye isikhathi lokha nawusemrarweni nofana nawudanileko abangani basinikekeza ihlombe esizokulilela kilo sethule imiraro yethu bese umngani akuphe isiluleko nofana akududuze.

== '''Izinto ongazicala ukubona umngani omuhle''' ==

=== '''Ukuthembeka''' ===
Umngani omuhle ujama nawe ngeenkhathi zoke  akusekele. Akakhulumi ngokuhluleka kwakho kwabanye abantu aabngakauthandiko nofana aveze indaba zakho omthembe ngazo. Kumumuntu okutjela amaqiniso nanyana akangazwisa ubuhlungu kangangani, begodu ukghona ukuthembela kuye lokha nawufuna isekelo&lt;ref&gt;Sinaga, J., Woran, R. and Sinambela, J.L., 2022. The Role Of Friendship In Character Development: Lessons From The Biblical Story Of David And Jonathan. ''Berumpun: International Journal of Social, Politics, and Humanities'', ''5''(1), pp.1-8.&lt;/ref&gt;.

=== '''Ukukhuluma''' ===
Kumumuntu okhuluma naye khulu nanyana angekho eduze niyathintana ngomaliledinini. Kumumuntu oghona ukukulalalela lokha nawukhulumako angakupheleli ihliziyo. Nalokha nasele ucedile ukhuluma ukuphendula ngependulwa ezokwakha&lt;ref&gt;Rawlins, W., 2017. ''Friendship matters: Communication, dialectics and the life course''. Routledge.&lt;/ref&gt;.

=== '''Izwelo''' ===
Umngani omuhle lokha nawehlelwe zizimo nofana iintjhijio ezinzima kuba okukhombisa ukuzwelana nawe. Uzifaka enyathelweni zakho  azisise amazizo wakho  nombona wakho ngesikhathi leso&lt;ref&gt;Gokalp, A. and Inel, Y., 2021. The Mediating Role of Responsibility and Friendship between Empathy Skill and Benevolence. ''Journal of Education and Learning (EduLearn)'', ''15''(2), pp.202-212.&lt;/ref&gt;.

== '''Isiphetho''' ==
Ubungani kuyinto kuyinto ehle eletha ithabo, ukududuzeka  emaphilweni wabantu umuntu lokha anakathole umngani omuhle kufuze bona ache ubudlelwane bakhe nomngani loyo bukhule buhlale iminyaka.</text>
      <sha1>s88gq1ahc8q6o1y4x05bdyrq4gp8vjf</sha1>
    </revision>
    <revision>
      <id>2491</id>
      <parentid>2490</parentid>
      <timestamp>2025-03-03T17:24:04Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2491</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3090" sha1="f39ovojgnd6b34nnimkckfkrbz6x988" xml:space="preserve">== Abangani ==
'''Abangani''' kubabantu ophila nabo ngamalanga begodu obathembako bonyana ungabelana nabo indaba zakho ongazitjeli abanye abantu. Kungilabo bantu abalunikela isekelo olidingako epilweni bakwenze uzizwe wamukelekile begodu uthandwa.Abangani kungilabo bantu abaphila boke bogodu abathanda izinto izifanako begodu abakhona ukucocoa babonisane ngepilo. Kubabantu abazanako bonya umunye uthanda ini begodu akathandi ini, kungilabo bantu abakghona ukukujamela nalokha wena ungekho&lt;ref&gt;Hartup, W.W., 2022. Friendships and their developmental significance. In ''Childhood social development'' (pp. 175-205). Psychology Press.&lt;/ref&gt;

== '''Ubuhle bokubamngani''' ==
Abangani kubabantu abangasikhuthaza bonyana silinge nofana sense izinto ezitja epilweni ezizosenza bona sikhule nanyana siphumelele. Abangani bangakukhuthaza bona ulandele izinto ongaba nekareko kizo.

Abangani basihlanganisa nabanye abangani babo nofana basise kwezinye indawo lapho sizokwazana khona nabanye abantu abangasilekelela ukuthuthuka nofana ukufezekisa amaphupho wethu&lt;ref&gt;McCabe, J.M., 2019. ''Connecting in college: How friendship networks matter for academic and social success''. University of Chicago Press.&lt;/ref&gt;. Abangani bangalekela ngezinye izinto zemakhaya ezifana nokuthutha, ukugada abantwana nangemali.Ngesinye isikhathi lokha nawusemrarweni nofana nawudanileko abangani basinikeza ihlombe esizokulilela kilo sethule imiraro yethu bese umngani akuphe isiluleko nofana akududuze.

== '''Izinto ongazicala ukubona umngani omuhle''' ==

=== '''Ukuthembeka''' ===
Umngani omuhle ujama nawe ngeenkhathi zoke  akusekele. Akakhulumi ngokuhluleka kwakho kwabanye abantu aabngakauthandiko nofana aveze indaba zakho omthembe ngazo. Kumumuntu okutjela amaqiniso nanyana akangazwisa ubuhlungu kangangani, begodu ukghona ukuthembela kuye lokha nawufuna isekelo&lt;ref&gt;Sinaga, J., Woran, R. and Sinambela, J.L., 2022. The Role Of Friendship In Character Development: Lessons From The Biblical Story Of David And Jonathan. ''Berumpun: International Journal of Social, Politics, and Humanities'', ''5''(1), pp.1-8.&lt;/ref&gt;.

=== '''Ukukhuluma''' ===
Kumumuntu okhuluma naye khulu nanyana angekho eduze niyathintana ngomaliledinini. Kumumuntu oghona ukukulalalela lokha nawukhulumako angakupheleli ihliziyo. Nalokha nasele ucedile ukhuluma ukuphendula ngependulwa ezokwakha&lt;ref&gt;Rawlins, W., 2017. ''Friendship matters: Communication, dialectics and the life course''. Routledge.&lt;/ref&gt;.

=== '''Izwelo''' ===
Umngani omuhle lokha nawehlelwe zizimo nofana iintjhijio ezinzima kuba okukhombisa ukuzwelana nawe. Uzifaka enyathelweni zakho  azisise amazizo wakho  nombona wakho ngesikhathi leso&lt;ref&gt;Gokalp, A. and Inel, Y., 2021. The Mediating Role of Responsibility and Friendship between Empathy Skill and Benevolence. ''Journal of Education and Learning (EduLearn)'', ''15''(2), pp.202-212.&lt;/ref&gt;.

== '''Isiphetho''' ==
Ubungani kuyinto kuyinto ehle eletha ithabo, ukududuzeka  emaphilweni wabantu umuntu lokha anakathole umngani omuhle kufuze bona ache ubudlelwane bakhe nomngani loyo bukhule buhlale iminyaka.</text>
      <sha1>f39ovojgnd6b34nnimkckfkrbz6x988</sha1>
    </revision>
    <revision>
      <id>2492</id>
      <parentid>2491</parentid>
      <timestamp>2025-03-03T17:24:52Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2492</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3089" sha1="mhz1bn7uehwomdaz1rzskvq0iryyzq6" xml:space="preserve">== Abangani ==
'''Abangani''' kubabantu ophila nabo ngamalanga begodu obathembako bonyana ungabelana nabo indaba zakho ongazitjeli abanye abantu. Kungilabo bantu abalunikela isekelo olidingako epilweni bakwenze uzizwe wamukelekile begodu uthandwa.Abangani kungilabo bantu abaphila boke bogodu abathanda izinto izifanako begodu abakhona ukucocoa babonisane ngepilo. Kubabantu abazanako bonya umunye uthanda ini begodu akathandi ini, kungilabo bantu abakghona ukukujamela nalokha wena ungekho&lt;ref&gt;Hartup, W.W., 2022. Friendships and their developmental significance. In ''Childhood social development'' (pp. 175-205). Psychology Press.&lt;/ref&gt;

== '''Ubuhle bokubamngani''' ==
Abangani kubabantu abangasikhuthaza bonyana silinge nofana sense izinto ezitja epilweni ezizosenza bona sikhule nanyana siphumelele. Abangani bangakukhuthaza bona ulandele izinto ongaba nekareko kizo.

Abangani basihlanganisa nabanye abangani babo nofana basise kwezinye indawo lapho sizokwazana khona nabanye abantu abangasilekelela ukuthuthuka nofana ukufezekisa amaphupho wethu&lt;ref&gt;McCabe, J.M., 2019. ''Connecting in college: How friendship networks matter for academic and social success''. University of Chicago Press.&lt;/ref&gt;. Abangani bangalekela ngezinye izinto zemakhaya ezifana nokuthutha, ukugada abantwana nangemali.Ngesinye isikhathi lokha nawusemrarweni nofana nawudanileko abangani basinikeza ihlombe esizokulilela kilo sethule imiraro yethu bese umngani akuphe isiluleko nofana akududuze.

== '''Izinto ongazicala ukubona umngani omuhle''' ==

=== '''Ukuthembeka''' ===
Umngani omuhle ujama nawe ngeenkhathi zoke  akusekele. Akakhulumi ngokuhluleka kwakho kwabanye abantu abangakuthandiko nofana aveze indaba zakho omthembe ngazo. Kumumuntu okutjela amaqiniso nanyana akangazwisa ubuhlungu kangangani, begodu ukghona ukuthembela kuye lokha nawufuna isekelo&lt;ref&gt;Sinaga, J., Woran, R. and Sinambela, J.L., 2022. The Role Of Friendship In Character Development: Lessons From The Biblical Story Of David And Jonathan. ''Berumpun: International Journal of Social, Politics, and Humanities'', ''5''(1), pp.1-8.&lt;/ref&gt;.

=== '''Ukukhuluma''' ===
Kumumuntu okhuluma naye khulu nanyana angekho eduze niyathintana ngomaliledinini. Kumumuntu oghona ukukulalalela lokha nawukhulumako angakupheleli ihliziyo. Nalokha nasele ucedile ukhuluma ukuphendula ngependulwa ezokwakha&lt;ref&gt;Rawlins, W., 2017. ''Friendship matters: Communication, dialectics and the life course''. Routledge.&lt;/ref&gt;.

=== '''Izwelo''' ===
Umngani omuhle lokha nawehlelwe zizimo nofana iintjhijio ezinzima kuba okukhombisa ukuzwelana nawe. Uzifaka enyathelweni zakho  azisise amazizo wakho  nombona wakho ngesikhathi leso&lt;ref&gt;Gokalp, A. and Inel, Y., 2021. The Mediating Role of Responsibility and Friendship between Empathy Skill and Benevolence. ''Journal of Education and Learning (EduLearn)'', ''15''(2), pp.202-212.&lt;/ref&gt;.

== '''Isiphetho''' ==
Ubungani kuyinto kuyinto ehle eletha ithabo, ukududuzeka  emaphilweni wabantu umuntu lokha anakathole umngani omuhle kufuze bona ache ubudlelwane bakhe nomngani loyo bukhule buhlale iminyaka.</text>
      <sha1>mhz1bn7uehwomdaz1rzskvq0iryyzq6</sha1>
    </revision>
    <revision>
      <id>2493</id>
      <parentid>2492</parentid>
      <timestamp>2025-03-03T17:25:33Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2493</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3089" sha1="9i10wvhzesrw0ecmkxt4w2hg7tqgi5z" xml:space="preserve">== Abangani ==
'''Abangani''' kubabantu ophila nabo ngamalanga begodu obathembako bonyana ungabelana nabo indaba zakho ongazitjeli abanye abantu. Kungilabo bantu abalunikela isekelo olidingako epilweni bakwenze uzizwe wamukelekile begodu uthandwa.Abangani kungilabo bantu abaphila boke bogodu abathanda izinto izifanako begodu abakhona ukucocoa babonisane ngepilo. Kubabantu abazanako bonya umunye uthanda ini begodu akathandi ini, kungilabo bantu abakghona ukukujamela nalokha wena ungekho&lt;ref&gt;Hartup, W.W., 2022. Friendships and their developmental significance. In ''Childhood social development'' (pp. 175-205). Psychology Press.&lt;/ref&gt;

== '''Ubuhle bokubamngani''' ==
Abangani kubabantu abangasikhuthaza bonyana silinge nofana sense izinto ezitja epilweni ezizosenza bona sikhule nanyana siphumelele. Abangani bangakukhuthaza bona ulandele izinto ongaba nekareko kizo.

Abangani basihlanganisa nabanye abangani babo nofana basise kwezinye indawo lapho sizokwazana khona nabanye abantu abangasilekelela ukuthuthuka nofana ukufezekisa amaphupho wethu&lt;ref&gt;McCabe, J.M., 2019. ''Connecting in college: How friendship networks matter for academic and social success''. University of Chicago Press.&lt;/ref&gt;. Abangani bangalekela ngezinye izinto zemakhaya ezifana nokuthutha, ukugada abantwana nangemali.Ngesinye isikhathi lokha nawusemrarweni nofana nawudanileko abangani basinikeza ihlombe esizokulilela kilo sethule imiraro yethu bese umngani akuphe isiluleko nofana akududuze.

== '''Izinto ongazicala ukubona umngani omuhle''' ==

=== '''Ukuthembeka''' ===
Umngani omuhle ujama nawe ngeenkhathi zoke  akusekele. Akakhulumi ngokuhluleka kwakho kwabanye abantu abangakuthandiko nofana aveze indaba zakho omthembe ngazo. Kumumuntu okutjela amaqiniso nanyana akangazwisa ubuhlungu kangangani, begodu ukghona ukuthembela kuye lokha nawufuna isekelo&lt;ref&gt;Sinaga, J., Woran, R. and Sinambela, J.L., 2022. The Role Of Friendship In Character Development: Lessons From The Biblical Story Of David And Jonathan. ''Berumpun: International Journal of Social, Politics, and Humanities'', ''5''(1), pp.1-8.&lt;/ref&gt;.

=== '''Ukukhuluma''' ===
Kumumuntu okhuluma naye khulu nanyana angekho eduze niyathintana ngomaliledinini. Kumumuntu okghona ukukulalalela lokha nawukhulumako angakupheleli ihliziyo. Nalokha nasele ucedile ukhuluma ukuphendula ngependulo ezokwakha&lt;ref&gt;Rawlins, W., 2017. ''Friendship matters: Communication, dialectics and the life course''. Routledge.&lt;/ref&gt;.

=== '''Izwelo''' ===
Umngani omuhle lokha nawehlelwe zizimo nofana iintjhijio ezinzima kuba okukhombisa ukuzwelana nawe. Uzifaka enyathelweni zakho  azisise amazizo wakho  nombona wakho ngesikhathi leso&lt;ref&gt;Gokalp, A. and Inel, Y., 2021. The Mediating Role of Responsibility and Friendship between Empathy Skill and Benevolence. ''Journal of Education and Learning (EduLearn)'', ''15''(2), pp.202-212.&lt;/ref&gt;.

== '''Isiphetho''' ==
Ubungani kuyinto kuyinto ehle eletha ithabo, ukududuzeka  emaphilweni wabantu umuntu lokha anakathole umngani omuhle kufuze bona ache ubudlelwane bakhe nomngani loyo bukhule buhlale iminyaka.</text>
      <sha1>9i10wvhzesrw0ecmkxt4w2hg7tqgi5z</sha1>
    </revision>
    <revision>
      <id>2738</id>
      <parentid>2493</parentid>
      <timestamp>2025-04-23T09:50:22Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2738</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3087" sha1="gdix51ahfpyh5t7r5jt0nl2hverzk0o" xml:space="preserve">== Abangani ==
'''Abangani''' kubabantu ophila nabo ngamalanga begodu obathembako bonyana ungabelana nabo indaba zakho ongazitjeli abanye abantu. Kungilabo bantu abalunikela isekelo olidingako epilweni bakwenze uzizwe wamukelekile begodu uthandwa.Abangani kungilabo bantu abaphila boke bogodu abathanda izinto izifanako begodu abakhona ukucocoa babonisane ngepilo. Kubabantu abazanako bonya umunye uthanda ini begodu akathandi ini, kungilabo bantu abakghona ukukujamela nalokha wena ungekho&lt;ref&gt;Hartup, W.W., 2022. Friendships and their developmental significance. In ''Childhood social development'' (pp. 175-205). Psychology Press.&lt;/ref&gt;

== '''Ubuhle bokubamngani''' ==
Abangani kubabantu abangasikhuthaza bonyana silinge nofana sense izinto ezitja epilweni ezizosenza bona sikhule nanyana siphumelele. Abangani bangakukhuthaza bona ulandele izinto ongaba nekareko kizo.

Abangani basihlanganisa nabanye abangani babo nofana basise kwezinye indawo lapho sizokwazana khona nabanye abantu abangasilekelela ukuthuthuka nofana ukufezekisa amaphupho wethu&lt;ref&gt;McCabe, J.M., 2019. ''Connecting in college: How friendship networks matter for academic and social success''. University of Chicago Press.&lt;/ref&gt;. Abangani bangalekela ngezinye izinto zemakhaya ezifana nokuthutha, ukugada abantwana nangemali.Ngesinye isikhathi lokha nawusemrarweni nofana nawudanileko abangani basinikeza ihlombe esizokulilela kilo sethule imiraro yethu bese umngani akuphe isiluleko nofana akududuze.

== '''Izinto ongazicala ukubona umngani omuhle''' ==

=== '''Ukuthembeka''' ===
Umngani omuhle ujama nawe ngeenkhathi zoke  akusekele. Akakhulumi ngokuhluleka kwakho kwabanye abantu abangakuthandiko nofana aveze indaba zakho omthembe ngazo. Kumumuntu okutjela amaqiniso nanyana akangazwisa ubuhlungu kangangani, begodu ukghona ukuthembela kuye lokha nawufuna isekelo&lt;ref&gt;Sinaga, J., Woran, R. and Sinambela, J.L., 2022. The Role Of Friendship In Character Development: Lessons From The Biblical Story Of David And Jonathan. ''Berumpun: International Journal of Social, Politics, and Humanities'', ''5''(1), pp.1-8.&lt;/ref&gt;.

=== '''Ukukhuluma''' ===
Kumumuntu okhuluma naye khulu nanyana angekho eduze niyathintana ngomaliledinini. Kumumuntu okghona ukukulalela lokha nawukhulumako angakupheleli ihliziyo. Nalokha nasele ucedile ukhuluma ukuphendula ngependulo ezokwakha&lt;ref&gt;Rawlins, W., 2017. ''Friendship matters: Communication, dialectics and the life course''. Routledge.&lt;/ref&gt;.

=== '''Izwelo''' ===
Umngani omuhle lokha nawehlelwe zizimo nofana iintjhijio ezinzima kuba okukhombisa ukuzwelana nawe. Uzifaka enyathelweni zakho  azisise amazizo wakho  nombona wakho ngesikhathi leso&lt;ref&gt;Gokalp, A. and Inel, Y., 2021. The Mediating Role of Responsibility and Friendship between Empathy Skill and Benevolence. ''Journal of Education and Learning (EduLearn)'', ''15''(2), pp.202-212.&lt;/ref&gt;.

== '''Isiphetho''' ==
Ubungani kuyinto kuyinto ehle eletha ithabo, ukududuzeka  emaphilweni wabantu umuntu lokha anakathole umngani omuhle kufuze bona ache ubudlelwane bakhe nomngani loyo bukhule buhlale iminyaka.</text>
      <sha1>gdix51ahfpyh5t7r5jt0nl2hverzk0o</sha1>
    </revision>
    <revision>
      <id>3546</id>
      <parentid>2738</parentid>
      <timestamp>2025-08-05T14:48:02Z</timestamp>
      <contributor>
        <ip>41.13.116.229</ip>
      </contributor>
      <origin>3546</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2989" sha1="83xwswzx39rzpbj4tcsytt3yg7xg3ed" xml:space="preserve">'''Abangani''' kubabantu ophila nabo ngamalanga begodu obathembako bonyana ungabelana nabo indaba zakho ongazitjeli abanye abantu. Kungilabo bantu abalunikela isekelo olidingako epilweni bakwenze uzizwe wamukelekile begodu uthandwa.Abangani kungilabo bantu abaphila boke bogodu abathanda izinto izifanako begodu abakhona ukucocoa babonisane ngepilo. Kubabantu abazanako bonya umunye uthanda ini begodu akathandi ini, kungilabo bantu abakghona ukukujamela nalokha wena ungekho&lt;ref&gt;Hartup, W.W., 2022. Friendships and their developmental significance. In ''Childhood social development'' (pp. 175-205). Psychology Press.&lt;/ref&gt;

=== '''Ubuhle bokubamngani''' ===
Abangani kubabantu abangasikhuthaza bonyana silinge nofana sense izinto ezitja epilweni ezizosenza bona sikhule nanyana siphumelele. Abangani bangakukhuthaza bona ulandele izinto ongaba nekareko kizo. Abangani basihlanganisa nabanye abangani babo nofana basise kwezinye indawo lapho sizokwazana khona nabanye abantu abangasilekelela ukuthuthuka nofana ukufezekisa amaphupho wethu&lt;ref&gt;McCabe, J.M., 2019. ''Connecting in college: How friendship networks matter for academic and social success''. University of Chicago Press.&lt;/ref&gt;. Abangani bangalekela ngezinye izinto zemakhaya ezifana nokuthutha, ukugada abantwana nangemali.Ngesinye isikhathi lokha nawusemrarweni nofana nawudanileko abangani basinikeza ihlombe esizokulilela kilo sethule imiraro yethu bese umngani akuphe isiluleko nofana akududuze.

=== '''Izinto ongazicala ukubona umngani omuhle''' ===
Umngani omuhle ujama nawe ngeenkhathi zoke  akusekele. Akakhulumi ngokuhluleka kwakho kwabanye abantu abangakuthandiko nofana aveze indaba zakho omthembe ngazo. Kumumuntu okutjela amaqiniso nanyana akangazwisa ubuhlungu kangangani, begodu ukghona ukuthembela kuye lokha nawufuna isekelo&lt;ref&gt;Sinaga, J., Woran, R. and Sinambela, J.L., 2022. The Role Of Friendship In Character Development: Lessons From The Biblical Story Of David And Jonathan. ''Berumpun: International Journal of Social, Politics, and Humanities'', ''5''(1), pp.1-8.&lt;/ref&gt;.Kumumuntu okhuluma naye khulu nanyana angekho eduze niyathintana ngomaliledinini. Kumumuntu okghona ukukulalela lokha nawukhulumako angakupheleli ihliziyo. Nalokha nasele ucedile ukhuluma ukuphendula ngependulo ezokwakha&lt;ref&gt;Rawlins, W., 2017. ''Friendship matters: Communication, dialectics and the life course''. Routledge.&lt;/ref&gt;.Umngani omuhle lokha nawehlelwe zizimo nofana iintjhijio ezinzima kuba okukhombisa ukuzwelana nawe. Uzifaka enyathelweni zakho  azisise amazizo wakho  nombona wakho ngesikhathi leso&lt;ref&gt;Gokalp, A. and Inel, Y., 2021. The Mediating Role of Responsibility and Friendship between Empathy Skill and Benevolence. ''Journal of Education and Learning (EduLearn)'', ''15''(2), pp.202-212.&lt;/ref&gt;Ubungani kuyinto kuyinto ehle eletha ithabo, ukududuzeka  emaphilweni wabantu umuntu lokha anakathole umngani omuhle kufuze bona ache ubudlelwane bakhe nomngani loyo bukhule buhlale iminyaka.

== Iinkomba ==</text>
      <sha1>83xwswzx39rzpbj4tcsytt3yg7xg3ed</sha1>
    </revision>
    <revision>
      <id>3547</id>
      <parentid>3546</parentid>
      <timestamp>2025-08-05T14:50:43Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3547</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2990" sha1="sxypa8gfm8r63sqmvytyzk1i7a81b4p" xml:space="preserve">'''Abangani''' kubabantu ophila nabo ngamalanga begodu obathembako bonyana ungabelana nabo indaba zakho ongazitjeli abanye abantu. Kungilabo bantu abalunikela isekelo olidingako epilweni bakwenze uzizwe wamukelekile begodu uthandwa.Abangani kungilabo bantu abaphila boke bogodu abathanda izinto izifanako begodu abakhona ukucoca babonisane ngepilo. Kubabantu abazanako bonyana umunye uthanda ini begodu akathandi ini, kungilabo bantu abakghona ukukujamela nalokha wena ungekho&lt;ref&gt;Hartup, W.W., 2022. Friendships and their developmental significance. In ''Childhood social development'' (pp. 175-205). Psychology Press.&lt;/ref&gt;

=== '''Ubuhle bokubamngani''' ===
Abangani kubabantu abangasikhuthaza bonyana silinge nofana sense izinto ezitja epilweni ezizosenza bona sikhule nanyana siphumelele. Abangani bangakukhuthaza bona ulandele izinto ongaba nekareko kizo. Abangani basihlanganisa nabanye abangani babo nofana basise kwezinye indawo lapho sizokwazana khona nabanye abantu abangasilekelela ukuthuthuka nofana ukufezekisa amaphupho wethu&lt;ref&gt;McCabe, J.M., 2019. ''Connecting in college: How friendship networks matter for academic and social success''. University of Chicago Press.&lt;/ref&gt;. Abangani bangalekela ngezinye izinto zemakhaya ezifana nokuthutha, ukugada abantwana nangemali.Ngesinye isikhathi lokha nawusemrarweni nofana nawudanileko abangani basinikeza ihlombe esizokulilela kilo sethule imiraro yethu bese umngani akuphe isiluleko nofana akududuze.

=== '''Izinto ongazicala ukubona umngani omuhle''' ===
Umngani omuhle ujama nawe ngeenkhathi zoke  akusekele. Akakhulumi ngokuhluleka kwakho kwabanye abantu abangakuthandiko nofana aveze indaba zakho omthembe ngazo. Kumumuntu okutjela amaqiniso nanyana akangazwisa ubuhlungu kangangani, begodu ukghona ukuthembela kuye lokha nawufuna isekelo&lt;ref&gt;Sinaga, J., Woran, R. and Sinambela, J.L., 2022. The Role Of Friendship In Character Development: Lessons From The Biblical Story Of David And Jonathan. ''Berumpun: International Journal of Social, Politics, and Humanities'', ''5''(1), pp.1-8.&lt;/ref&gt;.Kumumuntu okhuluma naye khulu nanyana angekho eduze niyathintana ngomaliledinini. Kumumuntu okghona ukukulalela lokha nawukhulumako angakupheleli ihliziyo. Nalokha nasele ucedile ukhuluma ukuphendula ngependulo ezokwakha&lt;ref&gt;Rawlins, W., 2017. ''Friendship matters: Communication, dialectics and the life course''. Routledge.&lt;/ref&gt;.Umngani omuhle lokha nawehlelwe zizimo nofana iintjhijio ezinzima kuba okukhombisa ukuzwelana nawe. Uzifaka enyathelweni zakho  azisise amazizo wakho  nombona wakho ngesikhathi leso&lt;ref&gt;Gokalp, A. and Inel, Y., 2021. The Mediating Role of Responsibility and Friendship between Empathy Skill and Benevolence. ''Journal of Education and Learning (EduLearn)'', ''15''(2), pp.202-212.&lt;/ref&gt;Ubungani kuyinto kuyinto ehle eletha ithabo, ukududuzeka  emaphilweni wabantu umuntu lokha anakathole umngani omuhle kufuze bona ache ubudlelwane bakhe nomngani loyo bukhule buhlale iminyaka.

== Iinkomba ==</text>
      <sha1>sxypa8gfm8r63sqmvytyzk1i7a81b4p</sha1>
    </revision>
    <revision>
      <id>3548</id>
      <parentid>3547</parentid>
      <timestamp>2025-08-05T14:53:26Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <comment>Added a picture to the article</comment>
      <origin>3548</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3089" sha1="o41uma3shteitpyynj1m6i5pgc8fesf" xml:space="preserve">[[Isimumathi:Friends (Bright-Kauffman-Crane Productions sitcom) official logo.svg|thumb|Abangani]]
'''Abangani''' kubabantu ophila nabo ngamalanga begodu obathembako bonyana ungabelana nabo indaba zakho ongazitjeli abanye abantu. Kungilabo bantu abalunikela isekelo olidingako epilweni bakwenze uzizwe wamukelekile begodu uthandwa.Abangani kungilabo bantu abaphila boke bogodu abathanda izinto izifanako begodu abakhona ukucoca babonisane ngepilo. Kubabantu abazanako bonyana umunye uthanda ini begodu akathandi ini, kungilabo bantu abakghona ukukujamela nalokha wena ungekho&lt;ref&gt;Hartup, W.W., 2022. Friendships and their developmental significance. In ''Childhood social development'' (pp. 175-205). Psychology Press.&lt;/ref&gt;

=== '''Ubuhle bokubamngani''' ===
Abangani kubabantu abangasikhuthaza bonyana silinge nofana sense izinto ezitja epilweni ezizosenza bona sikhule nanyana siphumelele. Abangani bangakukhuthaza bona ulandele izinto ongaba nekareko kizo. Abangani basihlanganisa nabanye abangani babo nofana basise kwezinye indawo lapho sizokwazana khona nabanye abantu abangasilekelela ukuthuthuka nofana ukufezekisa amaphupho wethu&lt;ref&gt;McCabe, J.M., 2019. ''Connecting in college: How friendship networks matter for academic and social success''. University of Chicago Press.&lt;/ref&gt;. Abangani bangalekela ngezinye izinto zemakhaya ezifana nokuthutha, ukugada abantwana nangemali.Ngesinye isikhathi lokha nawusemrarweni nofana nawudanileko abangani basinikeza ihlombe esizokulilela kilo sethule imiraro yethu bese umngani akuphe isiluleko nofana akududuze.

=== '''Izinto ongazicala ukubona umngani omuhle''' ===
Umngani omuhle ujama nawe ngeenkhathi zoke  akusekele. Akakhulumi ngokuhluleka kwakho kwabanye abantu abangakuthandiko nofana aveze indaba zakho omthembe ngazo. Kumumuntu okutjela amaqiniso nanyana akangazwisa ubuhlungu kangangani, begodu ukghona ukuthembela kuye lokha nawufuna isekelo&lt;ref&gt;Sinaga, J., Woran, R. and Sinambela, J.L., 2022. The Role Of Friendship In Character Development: Lessons From The Biblical Story Of David And Jonathan. ''Berumpun: International Journal of Social, Politics, and Humanities'', ''5''(1), pp.1-8.&lt;/ref&gt;.Kumumuntu okhuluma naye khulu nanyana angekho eduze niyathintana ngomaliledinini. Kumumuntu okghona ukukulalela lokha nawukhulumako angakupheleli ihliziyo. Nalokha nasele ucedile ukhuluma ukuphendula ngependulo ezokwakha&lt;ref&gt;Rawlins, W., 2017. ''Friendship matters: Communication, dialectics and the life course''. Routledge.&lt;/ref&gt;.Umngani omuhle lokha nawehlelwe zizimo nofana iintjhijio ezinzima kuba okukhombisa ukuzwelana nawe. Uzifaka enyathelweni zakho  azisise amazizo wakho  nombona wakho ngesikhathi leso&lt;ref&gt;Gokalp, A. and Inel, Y., 2021. The Mediating Role of Responsibility and Friendship between Empathy Skill and Benevolence. ''Journal of Education and Learning (EduLearn)'', ''15''(2), pp.202-212.&lt;/ref&gt;Ubungani kuyinto kuyinto ehle eletha ithabo, ukududuzeka  emaphilweni wabantu umuntu lokha anakathole umngani omuhle kufuze bona ache ubudlelwane bakhe nomngani loyo bukhule buhlale iminyaka.

== Iinkomba ==</text>
      <sha1>o41uma3shteitpyynj1m6i5pgc8fesf</sha1>
    </revision>
    <revision>
      <id>6501</id>
      <parentid>3548</parentid>
      <timestamp>2026-05-15T19:38:36Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <origin>6501</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2980" sha1="8rypc5l17qtcv1buktptipo3lwebwlb" xml:space="preserve">'''Abangani''' babantu ophila nabo ngamalanga begodu obathembako bonyana ungabelana nabo indaba zakho ongazitjeli abanye abantu. Kungilabo bantu abakunikela isekelo olidingako epilweni, bakwenze uzizwe wamukelekile begodu uthandwa. Abangani kungilabo bantu abaphila boke begodu abathanda izinto ezifanako begodu abakghona ukucoca babonisane ngepilo. Kubabantu abazanako bonyana omunye uthanda ini begodu akathandi ini, kungilabo bantu abakghona ukukujamela nalokha wena ungekho.&lt;ref&gt;Hartup, W.W., 2022. Friendships and their developmental significance. In ''Childhood social development'' (pp. 175-205). Psychology Press.&lt;/ref&gt;

== '''Ubuhle bokubamngani''' ==
Abangani kubabantu abangasikhuthaza bonyana silinge nofana senze izinto ezitja epilweni ezizosenza bona sikhule nanyana siphumelele. Abangani bangakukhuthaza bona ulandele izinto ongaba nekareko kizo. Abangani basihlanganisa nabanye abangani babo nofana basise kwezinye iindawo lapho sizokwazana khona nabanye abantu abangasilekelela ukuthuthuka nofana ukufezekisa amabhudango wethu.&lt;ref&gt;McCabe, J.M., 2019. ''Connecting in college: How friendship networks matter for academic and social success''. University of Chicago Press.&lt;/ref&gt; Abangani bangakulekelela ngezinye izinto zemakhaya ezifana nokuthutha, ukugada abantwana nangemali. Ngesinye isikhathi lokha nawusemrarweni nofana nawudanileko abangani basinikela ihlombe esizokulilela kilo sethule imiraro yethu bese umngani akuphe iseluleko nofana akududuze.

== '''Izinto ongaziqala ukubona umngani omuhle''' ==
Umngani omuhle ujama nawe ngeenkhathi zoke akusekele. Akakhulumi ngokuhluleka kwakho kwabanye abantu abangakuthandiko nofana aveze indaba zakho omthembe ngazo. Kumumuntu okutjela amaqiniso nanyana angakuzwisa ubuhlungu kangangani begodu ukghona ukuthembela kuye lokha nawufuna isekelo.&lt;ref&gt;Sinaga, J., Woran, R. and Sinambela, J.L., 2022. The Role Of Friendship In Character Development: Lessons From The Biblical Story Of David And Jonathan. ''Berumpun: International Journal of Social, Politics, and Humanities'', ''5''(1), pp.1-8.&lt;/ref&gt; Kumumuntu okhuluma naye khulu nanyana angekho eduze niyathintana ngomaliledinini. Kumumuntu okghona ukukulalela lokha nawukhulumako angakupheleli ihliziyo. Nalokha nasele uqedile ukukhuluma ukuphendula ngependulo ezokwakha.&lt;ref&gt;Rawlins, W., 2017. ''Friendship matters: Communication, dialectics and the life course''. Routledge.&lt;/ref&gt; Umngani omuhle lokha nawehlelwe bujamo nofana iintjhijio ezinzima ukhombisa ukuzwelana nawe. Uzifaka eenyathelweni zakho azwisise amazizwakho nombonwakho ngesikhathi leso. &lt;ref&gt;Gokalp, A. and Inel, Y., 2021. The Mediating Role of Responsibility and Friendship between Empathy Skill and Benevolence. ''Journal of Education and Learning (EduLearn)'', ''15''(2), pp.202-212.&lt;/ref&gt; Ubungani kuyinto ehle eletha ithabo, ukududuzeka eempilweni zabantu, umuntu lokha nakathole umngani omuhle kufuze bona akhe ubudlelwane bakhe nomngani loyo bukhule buhlale iminyaka.

== Iinkomba ==</text>
      <sha1>8rypc5l17qtcv1buktptipo3lwebwlb</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Артем Загребельный</title>
    <ns>2</ns>
    <id>497</id>
    <revision>
      <id>2502</id>
      <timestamp>2025-03-04T11:53:43Z</timestamp>
      <contributor>
        <username>Артем Загребельный</username>
        <id>464</id>
      </contributor>
      <comment>Created page with &quot;&lt;blockquote&gt;[[File:Noto Emoji Pie 1f4e2.svg|25px]]   Masigcine, masandise [[Special:GlobalContributions/Артем Загребельный{{!}}ilifa lezilimi]]le [[Iphasi (iplanethi)|Umhlaba]]. [[File:Noto Emoji Pie 1f30e.svg|15px]]&lt;/blockquote&gt;&quot;</comment>
      <origin>2502</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="246" sha1="fv3buizdz93l3ytaiqfed1esmbd41vw" xml:space="preserve">&lt;blockquote&gt;[[File:Noto Emoji Pie 1f4e2.svg|25px]]   Masigcine, masandise [[Special:GlobalContributions/Артем Загребельный{{!}}ilifa lezilimi]]le [[Iphasi (iplanethi)|Umhlaba]]. [[File:Noto Emoji Pie 1f30e.svg|15px]]&lt;/blockquote&gt;</text>
      <sha1>fv3buizdz93l3ytaiqfed1esmbd41vw</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Magnefl</title>
    <ns>2</ns>
    <id>498</id>
    <revision>
      <id>2503</id>
      <timestamp>2025-03-05T09:36:29Z</timestamp>
      <contributor>
        <username>Magnefl</username>
        <id>469</id>
      </contributor>
      <comment>Umsebenzisi</comment>
      <origin>2503</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="120" sha1="ovu0kznnvrmw7u8rwq3f1v8whiohpkp" xml:space="preserve">{{#babel:nr-0|no|en-3}}
Hello, I am '''Magne Fl&amp;#229;ten''', [[:no:Bruker:Magnefl|Umsebenzisi:Magnefl]] from [[Norway]].</text>
      <sha1>ovu0kznnvrmw7u8rwq3f1v8whiohpkp</sha1>
    </revision>
  </page>
  <page>
    <title>Ubulelesi</title>
    <ns>0</ns>
    <id>501</id>
    <revision>
      <id>2525</id>
      <timestamp>2025-03-10T14:16:32Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1277660548|Piracy]]&quot;</comment>
      <origin>2525</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="759" sha1="n4s6ysizbcmhs3ug9pkeiafvbkbd7qa" xml:space="preserve">'''Ukuphanga''' sisenzo sokuphanga nofana ubudlwangudlwangu bobulelesi ngabantu abahlasela ngemikhumbi nofana ngesikepe abahlasela omunye umkhumbi nofana indawo eseduze nelwandle, ngokujayelekileko ngomnqopho wokweba imithwalo nezinye izinto ezibizako. Labo abenza izenzo zokuphanga babizwa ngokuthi '''ma-pirates''' ngelimi lesiNgisi, begodu imikhumbi esetjenziselwa ubugebengu ibizwa ngokuthi '''mikhumbi yama-pirates''' . Izehlakalo zokuthoma ezitlolwe phasi zokukhwabanisa bezikhona ngekhulu le-14 BC, lokha abantu beLwandle, isiqhema sabahlaseli belwandle, nabahlasela imikhumbi ye- Aegean ne-Mediterranean. Iindlela ezincani ezidosela ukuthunyelwa kwemikhumbi eendleleni eziqagelekako sele zidale amathuba wobugebengu,  kanye nokuhlasela kwezokurhweba .</text>
      <sha1>n4s6ysizbcmhs3ug9pkeiafvbkbd7qa</sha1>
    </revision>
    <revision>
      <id>2547</id>
      <parentid>2525</parentid>
      <timestamp>2025-03-19T14:07:24Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1280869872|Piracy]]&quot;</comment>
      <origin>2547</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1345" sha1="5rr2akrqimyn89m2tij5y2icab8ylj5" xml:space="preserve">'''Ukuphanga''' sisenzo sokuphanga nofana ubudlwangudlwangu bobulelesi ngabantu abahlasela ngemikhumbi nofana ngesikepe abahlasela omunye umkhumbi nofana indawo eseduze nelwandle, ngokujayelekileko ngomnqopho wokweba imithwalo nezinye izinto ezibizako. Labo abenza izenzo zokuphanga babizwa ngokuthi '''ma-pirates''' ngelimi lesiNgisi, begodu imikhumbi esetjenziselwa ubugebengu ibizwa ngokuthi '''mikhumbi yama-pirates''' . Izehlakalo zokuthoma ezitlolwe phasi zokukhwabanisa bezikhona ngekhulu le-14 BC, lokha abantu beLwandle, isiqhema sabahlaseli belwandle, nabahlasela imikhumbi ye- Aegean ne-Mediterranean. Iindlela ezincani ezidosela ukuthunyelwa kwemikhumbi eendleleni eziqagelekako sele zidale amathuba wobugebengu,  kanye nokuhlasela kwezokurhweba .

Iimbonelo zomlando zeendawo ezinjalo zifaka hlangana amanzi we- Gibraltar, i- Strait of Malacca, i-Madagascar, i -Gulf of Aden, kanye ne- English Channel, lapho izakhiwo zendawo zasiza ukuhlaselwa kwamapirate.   Ibizo elithi ''ubugebengu'' ngokuvamileko litjho ubugebengu belwandle, nanyana ibizo leli sele litjho izenzo ezenziwa ephasini,  emoyeni, emanethiwekhini wamakhomphyutha, kanye (ngeendaba zesayensi) emkhathini. Ubulelesi buvame ukungafaki ubulelesi obenziwe mthengisi emkhunjini wakhe (isib. ukweba), kanye nokuthengisa ngasese, okutjho ukugunyazwa ngurhulumende wombuso .</text>
      <sha1>5rr2akrqimyn89m2tij5y2icab8ylj5</sha1>
    </revision>
  </page>
  <page>
    <title>Wikiphidiya:Community portal</title>
    <ns>4</ns>
    <id>502</id>
    <revision>
      <id>2528</id>
      <timestamp>2025-03-13T02:56:05Z</timestamp>
      <contributor>
        <username>MediaWiki message delivery</username>
        <id>195</id>
      </contributor>
      <comment>/* An improved dashboard for the Content Translation tool */ new section</comment>
      <origin>2528</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2397" sha1="6liu389z0k2nyndh1wwgujjfpox8aqs" xml:space="preserve">== An improved dashboard for the Content Translation tool ==

&lt;div lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;
{{Int:hello}} Wikipedians,

Apologies as this message is not in your language, {{Int:please-translate}}.

The [[mediawikiwiki:Special:MyLanguage/Wikimedia_Language_and_Product_Localization|Language and Product Localization team]] has improved the [https://test.wikipedia.org/w/index.php?title=Special:ContentTranslation&amp;filter-type=automatic&amp;filter-id=previous-edits&amp;active-list=suggestions&amp;from=en&amp;to=es Content Translation dashboard] to create a consistent experience for all contributors using mobile and desktop devices. The improved translation dashboard allows all logged-in users of the tool to enjoy a consistent experience regardless of their type of device.

With a harmonized experience, logged-in desktop users now have access to the capabilities shown in the image below.
[[file:Content_Translation_new-dashboard.png|alt=|center|thumb|576x576px|Notice that in this screenshot, the new dashboard allows: Users to adjust suggestions with the &quot;For you&quot; and &quot;...More&quot; buttons to select general topics or community-created collections (like the example of Climate topic).  Also, users can use translation to create new articles (as before) and expand existing articles section by section. You can see how suggestions are provided in the new dashboard  in two groups (&quot;Create new pages&quot; and &quot;Expand with new sections&quot;)-one for each activity.]]
[[File:Content_Translation_dashboard_on_desktop.png|alt=|center|thumb|577x577px|In the current dashboard, you will notice that you can't adjust suggestions to select topics or community-created collections. Also, you can't expand on existing articles by translating new sections.]]
We will implement [[mw:Special:MyLanguage/Content translation#Improved translation experience|this improvement]] on your wiki '''on Monday, March 17th, 2025''' and remove the current dashboard '''by May 2025'''.
Please reach out with any questions concerning the dashboard in this thread. 

Thank you!

On behalf of the Language and Product Localization team.
&lt;/div&gt;

&lt;bdi lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;[[User:UOzurumba (WMF)|UOzurumba (WMF)]]&lt;/bdi&gt; 04:56, 13 Mbimbitho 2025 (SAST)
&lt;!-- Message sent by User:UOzurumba (WMF)@metawiki using the list at https://meta.wikimedia.org/w/index.php?title=User:UOzurumba_(WMF)/sandbox_CX_Unified_dashboard_announcement_list_1&amp;oldid=28382282 --&gt;</text>
      <sha1>6liu389z0k2nyndh1wwgujjfpox8aqs</sha1>
    </revision>
    <revision>
      <id>2855</id>
      <parentid>2528</parentid>
      <timestamp>2025-05-27T23:46:09Z</timestamp>
      <contributor>
        <username>UOzurumba (WMF)</username>
        <id>48</id>
      </contributor>
      <origin>2855</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5355" sha1="f3z0pd6snfwhmzt7xgcfkeht19rsi6w" xml:space="preserve">== An improved dashboard for the Content Translation tool ==

&lt;div lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;
{{Int:hello}} Wikipedians,

Apologies as this message is not in your language, {{Int:please-translate}}.

The [[mediawikiwiki:Special:MyLanguage/Wikimedia_Language_and_Product_Localization|Language and Product Localization team]] has improved the [https://test.wikipedia.org/w/index.php?title=Special:ContentTranslation&amp;filter-type=automatic&amp;filter-id=previous-edits&amp;active-list=suggestions&amp;from=en&amp;to=es Content Translation dashboard] to create a consistent experience for all contributors using mobile and desktop devices. The improved translation dashboard allows all logged-in users of the tool to enjoy a consistent experience regardless of their type of device.

With a harmonized experience, logged-in desktop users now have access to the capabilities shown in the image below.
[[file:Content_Translation_new-dashboard.png|alt=|center|thumb|576x576px|Notice that in this screenshot, the new dashboard allows: Users to adjust suggestions with the &quot;For you&quot; and &quot;...More&quot; buttons to select general topics or community-created collections (like the example of Climate topic).  Also, users can use translation to create new articles (as before) and expand existing articles section by section. You can see how suggestions are provided in the new dashboard  in two groups (&quot;Create new pages&quot; and &quot;Expand with new sections&quot;)-one for each activity.]]
[[File:Content_Translation_dashboard_on_desktop.png|alt=|center|thumb|577x577px|In the current dashboard, you will notice that you can't adjust suggestions to select topics or community-created collections. Also, you can't expand on existing articles by translating new sections.]]
We will implement [[mw:Special:MyLanguage/Content translation#Improved translation experience|this improvement]] on your wiki '''on Monday, March 17th, 2025''' and remove the current dashboard '''by May 2025'''.
Please reach out with any questions concerning the dashboard in this thread. 

Thank you!

On behalf of the Language and Product Localization team.
&lt;/div&gt;

&lt;bdi lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;[[User:UOzurumba (WMF)|UOzurumba (WMF)]]&lt;/bdi&gt; 04:56, 13 Mbimbitho 2025 (SAST)
&lt;!-- Message sent by User:UOzurumba (WMF)@metawiki using the list at https://meta.wikimedia.org/w/index.php?title=User:UOzurumba_(WMF)/sandbox_CX_Unified_dashboard_announcement_list_1&amp;oldid=28382282 --&gt;

==Proposal to enable the &quot;Contribute&quot; entry point in isiNdebele Wikipedia==
{{Int:Hello}} isiNdebele Wikipedians,

Apologies as this message is not in your language. {{Int:please-translate}}.

The [[mediawikiwiki:Wikimedia_Language_and_Product_Localization|WMF Language and Product Localization]] team proposes enabling an entry point called &quot;Contribute&quot; to your Wikipedia.

The [[:bn:বিশেষ:Contribute|Contribute]] entry point is based on collaborative work with other product teams in the Wikimedia Foundation on [[mediawikiwiki:Edit_Discovery|Edit discovery]], which validated the entry point as a persistent and constant path that contributors took to discover ways to contribute content in Wikipedia.

Therefore, enabling this entry point in your Wikipedia will help contributors quickly discover available tools and immediately click to start using them. This entry point is designed to be a central point for discovering contribution tools in isiNdebele Wikipedia.

'''Who can access it'''

Once it is enabled in your Wikipedia, newcomers can access the entry point automatically by just logging into their account, click on the User drop-down menu and choose the &quot;Contribute&quot; icon, which takes you to another menu where you will find a self-guided description of what you can do to contribute content, as shown in the image below. An option to &quot;view contributions&quot; is also available to access the list of your contributions.

[[File:Mobile_Contribute_Page.png|Mobile Contribute Page]]                             [[File:Mobile_contribute_menu_(detailed).png|Mobile contribute menu (detailed)]]

For experienced contributors, the Contribute icon is not automatically shown in their User drop-down menu. They will still see the &quot;Contributions&quot; option unless they change it to the &quot;Contribute&quot; manually.

We have gotten valuable feedback that helped us improve its discoverability. Now, it is ready to be enabled in other Wikis. One major improvement was to [[phab:T369041|make the entry point optional for experienced contributors]] who still want to have the &quot;Contributions&quot; entry point as default.          

We plan to enable it '''on mobile''' for Wikis, where the Section translation tool is enabled. In this way, we will provide a main entry point to the mobile translation dashboard, and the exposure can still be limited by targeting only the mobile platform for now. If there are no objections to having the entry point for mobile users from your community, we will enable it by 10th June 2025.

We welcome your feedback and questions in this thread on our proposal to enable it here. Suppose there are no objections, we will deploy the &quot;Contribute&quot; entry point in your Wikipedia.

We look forward to your response soon.

Thank you!

On behalf of the WMF Language and Product Localization team.
[[Umsebenzisi:UOzurumba (WMF)|UOzurumba (WMF)]] ([[Umsebenzisi asiqongelane:UOzurumba (WMF)|talk]]) 01:46, 28 Nkwenkwezi 2025 (SAST)</text>
      <sha1>f3z0pd6snfwhmzt7xgcfkeht19rsi6w</sha1>
    </revision>
    <revision>
      <id>2916</id>
      <parentid>2855</parentid>
      <timestamp>2025-06-06T16:58:17Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>LKJHGFGBNVCX</comment>
      <origin>2916</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="80" sha1="4eqellm0byk4eoajmah0qjrk1ddf9hg" xml:space="preserve">This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.</text>
      <sha1>4eqellm0byk4eoajmah0qjrk1ddf9hg</sha1>
    </revision>
    <revision>
      <id>3128</id>
      <parentid>2916</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:UOzurumba (WMF)|UOzurumba (WMF)]]</comment>
      <origin>2855</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5355" sha1="f3z0pd6snfwhmzt7xgcfkeht19rsi6w" xml:space="preserve">== An improved dashboard for the Content Translation tool ==

&lt;div lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;
{{Int:hello}} Wikipedians,

Apologies as this message is not in your language, {{Int:please-translate}}.

The [[mediawikiwiki:Special:MyLanguage/Wikimedia_Language_and_Product_Localization|Language and Product Localization team]] has improved the [https://test.wikipedia.org/w/index.php?title=Special:ContentTranslation&amp;filter-type=automatic&amp;filter-id=previous-edits&amp;active-list=suggestions&amp;from=en&amp;to=es Content Translation dashboard] to create a consistent experience for all contributors using mobile and desktop devices. The improved translation dashboard allows all logged-in users of the tool to enjoy a consistent experience regardless of their type of device.

With a harmonized experience, logged-in desktop users now have access to the capabilities shown in the image below.
[[file:Content_Translation_new-dashboard.png|alt=|center|thumb|576x576px|Notice that in this screenshot, the new dashboard allows: Users to adjust suggestions with the &quot;For you&quot; and &quot;...More&quot; buttons to select general topics or community-created collections (like the example of Climate topic).  Also, users can use translation to create new articles (as before) and expand existing articles section by section. You can see how suggestions are provided in the new dashboard  in two groups (&quot;Create new pages&quot; and &quot;Expand with new sections&quot;)-one for each activity.]]
[[File:Content_Translation_dashboard_on_desktop.png|alt=|center|thumb|577x577px|In the current dashboard, you will notice that you can't adjust suggestions to select topics or community-created collections. Also, you can't expand on existing articles by translating new sections.]]
We will implement [[mw:Special:MyLanguage/Content translation#Improved translation experience|this improvement]] on your wiki '''on Monday, March 17th, 2025''' and remove the current dashboard '''by May 2025'''.
Please reach out with any questions concerning the dashboard in this thread. 

Thank you!

On behalf of the Language and Product Localization team.
&lt;/div&gt;

&lt;bdi lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;[[User:UOzurumba (WMF)|UOzurumba (WMF)]]&lt;/bdi&gt; 04:56, 13 Mbimbitho 2025 (SAST)
&lt;!-- Message sent by User:UOzurumba (WMF)@metawiki using the list at https://meta.wikimedia.org/w/index.php?title=User:UOzurumba_(WMF)/sandbox_CX_Unified_dashboard_announcement_list_1&amp;oldid=28382282 --&gt;

==Proposal to enable the &quot;Contribute&quot; entry point in isiNdebele Wikipedia==
{{Int:Hello}} isiNdebele Wikipedians,

Apologies as this message is not in your language. {{Int:please-translate}}.

The [[mediawikiwiki:Wikimedia_Language_and_Product_Localization|WMF Language and Product Localization]] team proposes enabling an entry point called &quot;Contribute&quot; to your Wikipedia.

The [[:bn:বিশেষ:Contribute|Contribute]] entry point is based on collaborative work with other product teams in the Wikimedia Foundation on [[mediawikiwiki:Edit_Discovery|Edit discovery]], which validated the entry point as a persistent and constant path that contributors took to discover ways to contribute content in Wikipedia.

Therefore, enabling this entry point in your Wikipedia will help contributors quickly discover available tools and immediately click to start using them. This entry point is designed to be a central point for discovering contribution tools in isiNdebele Wikipedia.

'''Who can access it'''

Once it is enabled in your Wikipedia, newcomers can access the entry point automatically by just logging into their account, click on the User drop-down menu and choose the &quot;Contribute&quot; icon, which takes you to another menu where you will find a self-guided description of what you can do to contribute content, as shown in the image below. An option to &quot;view contributions&quot; is also available to access the list of your contributions.

[[File:Mobile_Contribute_Page.png|Mobile Contribute Page]]                             [[File:Mobile_contribute_menu_(detailed).png|Mobile contribute menu (detailed)]]

For experienced contributors, the Contribute icon is not automatically shown in their User drop-down menu. They will still see the &quot;Contributions&quot; option unless they change it to the &quot;Contribute&quot; manually.

We have gotten valuable feedback that helped us improve its discoverability. Now, it is ready to be enabled in other Wikis. One major improvement was to [[phab:T369041|make the entry point optional for experienced contributors]] who still want to have the &quot;Contributions&quot; entry point as default.          

We plan to enable it '''on mobile''' for Wikis, where the Section translation tool is enabled. In this way, we will provide a main entry point to the mobile translation dashboard, and the exposure can still be limited by targeting only the mobile platform for now. If there are no objections to having the entry point for mobile users from your community, we will enable it by 10th June 2025.

We welcome your feedback and questions in this thread on our proposal to enable it here. Suppose there are no objections, we will deploy the &quot;Contribute&quot; entry point in your Wikipedia.

We look forward to your response soon.

Thank you!

On behalf of the WMF Language and Product Localization team.
[[Umsebenzisi:UOzurumba (WMF)|UOzurumba (WMF)]] ([[Umsebenzisi asiqongelane:UOzurumba (WMF)|talk]]) 01:46, 28 Nkwenkwezi 2025 (SAST)</text>
      <sha1>f3z0pd6snfwhmzt7xgcfkeht19rsi6w</sha1>
    </revision>
    <revision>
      <id>3281</id>
      <parentid>3128</parentid>
      <timestamp>2025-07-02T20:22:02Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <origin>3281</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5852" sha1="12c4836kr771kg70ynac1p2f50uvrtt" xml:space="preserve">== An improved dashboard for the Content Translation tool ==

&lt;div lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;
{{Int:hello}} Wikipedians,

Apologies as this message is not in your language, {{Int:please-translate}}.

The [[mediawikiwiki:Special:MyLanguage/Wikimedia_Language_and_Product_Localization|Language and Product Localization team]] has improved the [https://test.wikipedia.org/w/index.php?title=Special:ContentTranslation&amp;filter-type=automatic&amp;filter-id=previous-edits&amp;active-list=suggestions&amp;from=en&amp;to=es Content Translation dashboard] to create a consistent experience for all contributors using mobile and desktop devices. The improved translation dashboard allows all logged-in users of the tool to enjoy a consistent experience regardless of their type of device.

With a harmonized experience, logged-in desktop users now have access to the capabilities shown in the image below.
[[file:Content_Translation_new-dashboard.png|alt=|center|thumb|576x576px|Notice that in this screenshot, the new dashboard allows: Users to adjust suggestions with the &quot;For you&quot; and &quot;...More&quot; buttons to select general topics or community-created collections (like the example of Climate topic).  Also, users can use translation to create new articles (as before) and expand existing articles section by section. You can see how suggestions are provided in the new dashboard  in two groups (&quot;Create new pages&quot; and &quot;Expand with new sections&quot;)-one for each activity.]]
[[File:Content_Translation_dashboard_on_desktop.png|alt=|center|thumb|577x577px|In the current dashboard, you will notice that you can't adjust suggestions to select topics or community-created collections. Also, you can't expand on existing articles by translating new sections.]]
We will implement [[mw:Special:MyLanguage/Content translation#Improved translation experience|this improvement]] on your wiki '''on Monday, March 17th, 2025''' and remove the current dashboard '''by May 2025'''.
Please reach out with any questions concerning the dashboard in this thread. 

Thank you!

On behalf of the Language and Product Localization team.
&lt;/div&gt;

&lt;bdi lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;[[User:UOzurumba (WMF)|UOzurumba (WMF)]]&lt;/bdi&gt; 04:56, 13 Mbimbitho 2025 (SAST)
&lt;!-- Message sent by User:UOzurumba (WMF)@metawiki using the list at https://meta.wikimedia.org/w/index.php?title=User:UOzurumba_(WMF)/sandbox_CX_Unified_dashboard_announcement_list_1&amp;oldid=28382282 --&gt;

==Proposal to enable the &quot;Contribute&quot; entry point in isiNdebele Wikipedia==
{{Int:Hello}} isiNdebele Wikipedians,

Apologies as this message is not in your language. {{Int:please-translate}}.

The [[mediawikiwiki:Wikimedia_Language_and_Product_Localization|WMF Language and Product Localization]] team proposes enabling an entry point called &quot;Contribute&quot; to your Wikipedia.

The [[:bn:বিশেষ:Contribute|Contribute]] entry point is based on collaborative work with other product teams in the Wikimedia Foundation on [[mediawikiwiki:Edit_Discovery|Edit discovery]], which validated the entry point as a persistent and constant path that contributors took to discover ways to contribute content in Wikipedia.

Therefore, enabling this entry point in your Wikipedia will help contributors quickly discover available tools and immediately click to start using them. This entry point is designed to be a central point for discovering contribution tools in isiNdebele Wikipedia.

'''Who can access it'''

Once it is enabled in your Wikipedia, newcomers can access the entry point automatically by just logging into their account, click on the User drop-down menu and choose the &quot;Contribute&quot; icon, which takes you to another menu where you will find a self-guided description of what you can do to contribute content, as shown in the image below. An option to &quot;view contributions&quot; is also available to access the list of your contributions.

[[File:Mobile_Contribute_Page.png|Mobile Contribute Page]]                             [[File:Mobile_contribute_menu_(detailed).png|Mobile contribute menu (detailed)]]

For experienced contributors, the Contribute icon is not automatically shown in their User drop-down menu. They will still see the &quot;Contributions&quot; option unless they change it to the &quot;Contribute&quot; manually.

We have gotten valuable feedback that helped us improve its discoverability. Now, it is ready to be enabled in other Wikis. One major improvement was to [[phab:T369041|make the entry point optional for experienced contributors]] who still want to have the &quot;Contributions&quot; entry point as default.          

We plan to enable it '''on mobile''' for Wikis, where the Section translation tool is enabled. In this way, we will provide a main entry point to the mobile translation dashboard, and the exposure can still be limited by targeting only the mobile platform for now. If there are no objections to having the entry point for mobile users from your community, we will enable it by 10th June 2025.

We welcome your feedback and questions in this thread on our proposal to enable it here. Suppose there are no objections, we will deploy the &quot;Contribute&quot; entry point in your Wikipedia.

We look forward to your response soon.

Thank you!

On behalf of the WMF Language and Product Localization team.
[[Umsebenzisi:UOzurumba (WMF)|UOzurumba (WMF)]] ([[Umsebenzisi asiqongelane:UOzurumba (WMF)|talk]]) 01:46, 28 Nkwenkwezi 2025 (SAST)

== Request for Adminship to support this Wikipedia ==
I request support for Admin rights to this Wikipedia, so I can assist with fighting Vandalism. I have undone a couple acts of vandalism but without sysop tools, it is very tideous to do this efficiently and consistently. I am currently an Admin for my homewiki ts.Wikipedia and I currently patroll South African language wikipedias.
--[[Umsebenzisi:Thuvack|Thuvack]] ([[Umsebenzisi asiqongelane:Thuvack|talk]]) 22:21, 2 Ntulikazi 2025 (SAST)</text>
      <sha1>12c4836kr771kg70ynac1p2f50uvrtt</sha1>
    </revision>
  </page>
  <page>
    <title>Ukubulala</title>
    <ns>0</ns>
    <id>503</id>
    <revision>
      <id>2530</id>
      <timestamp>2025-03-19T08:58:21Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Ukubulala == '''Ukubulala''' kusisenzo sokuthatha ipilo yomuntu umuntu&lt;ref&gt;Ewin, R.E., 1972. What is wrong with killing people?. ''The Philosophical Quarterly (1950-)'', ''22''(87), pp.126-139.&lt;/ref&gt;. Abantu babulala ngenzathu ezinengi abanye babulala ngesizathu sokuzivikela nofana sokuvikela abanye abantu. Elinye lamalungelo wabantu kulilungelo lokuphila ngikho isigwebo sentambo sasuswa. Ikolo ifundisa bona akukafaneli bona abantu babulalane. Isibonelo ibhayibheli em...&quot;</comment>
      <origin>2530</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3757" sha1="qo4dvtdynfkpcgfmg2n9sbght6gihx2" xml:space="preserve">== Ukubulala ==
'''Ukubulala''' kusisenzo sokuthatha ipilo yomuntu umuntu&lt;ref&gt;Ewin, R.E., 1972. What is wrong with killing people?. ''The Philosophical Quarterly (1950-)'', ''22''(87), pp.126-139.&lt;/ref&gt;. Abantu babulala ngenzathu ezinengi abanye babulala ngesizathu sokuzivikela nofana sokuvikela abanye abantu. Elinye lamalungelo wabantu kulilungelo lokuphila ngikho isigwebo sentambo sasuswa. Ikolo ifundisa bona akukafaneli bona abantu babulalane. Isibonelo ibhayibheli emthethweni elitjhumi kuno mthetho oyala abantu bona bangabulali.

== Imihlobo yokubulala ==

=== Ukubulala ngehloso ===
Lokhu kubulala umuntu uhlelile bona uzombulala njani beodu nini. Umuntu ngaphasi kwamhlobo angabulawa ngesigidi, nomukhwa nofana ngetjhefu.&lt;ref&gt;Pitt, J.C., 2013. “Guns don’t kill, people kill”; values in and/or around technologies. In ''The moral status of technical artefacts'' (pp. 89-101). Dordrecht: Springer Netherlands.&lt;/ref&gt;

=== Ukubulala ngaphandle kwehloso ===
Lapha umuntu angabulala omunye umuntu angakahleli. Umuntu angathi uazivikela emuntwini omhlukumezako agcine sele abululelel umuntu loyo angakahlosi&lt;ref&gt;Welch, J.I., 2021. The right to self-defence: Part 1: The killing or injuring of an attacker. ''Servamus Community-based Safety and Security Magazine'', ''114''(12), pp.41-43.&lt;/ref&gt;.

=== I-Euthanasia ===
Lokhu nakho kukubulala ngehloso kodwana kwenzeka ebantwini abagulako abasele baphila ngemitjhini nengcondo zabo sele zingasasebenzi. Abantu bekhabomuntu loyo ogulako bayavumelana bona bazokucima [[imitjhini]] bese umuntu ahlongakale ukuze akghone ukuphumula eenhlungwini azizwako lokha nakaleleko&lt;ref&gt;Fontalis, A., Prousali, E. and Kulkarni, K., 2018. Euthanasia and assisted dying: what is the current position and what are the key arguments informing the debate?. ''Journal of the Royal Society of Medicine'', ''111''(11), pp.407-413.&lt;/ref&gt;.

=== Ukuzikhunga ===
Abanye abantu lokha nabacalanga nobunzima bephasi bagcina sele babona ngathi asisekho isidingo sokuphila bese bagcine bathaha amaphilo wabo. Abantu abazibulalako bayazilengisa, abanye basela itjhefu nofana bazidumuze&lt;ref&gt;Berman, A.L., 2011. Estimating the population of survivors of suicide: Seeking an evidence base. ''Suicide and Life‐Threatening Behavior'', ''41''(1), pp.110-116.&lt;/ref&gt;.

== Izinto ezingabangela ukubulala ==

=== Ipi ===
Abantu bangabulalana ngesibanga sepi. Lokha abantu nabalwako bagcina selel badumuzanan nofana bagwane bese umuntu ophe igaze bekagcine ahlongakale. Namasotja lokha nakasepini ayodumuzana bese amanye agcine abulewe.

=== Ukugula ===
Abanye abantu nabugule khulu bagcina bababulele ngokuthi bacime imitjhini ebalekelela ukuphila bese abantu bagcie sele bahlongakele. Abanye bagandeleleka ngomkhumbulo bagcine bathatha amaphilo wabo&lt;ref&gt;Kierkegaard, S. and Marino, G., 2013. ''Fear and trembling and the sickness unto death''. Princeton University Press.&lt;/ref&gt;.

=== Iingozi ===
Ukungea engozini kungokhunye okubangela abantu bona bahlongakale. Abantu bangenza ingozi bakutuke ngekoloyi nofana ngebhesi balimale, nangabe abatholi isizo msinyana bangagcina sele bahlongakele. Kubangellwa kukuthi abanye balimele endaweni ezibucayi nofana balahlekelwe ziingazi ezinengi emzimbeni&lt;ref&gt;Heron, M.P., 2018. Deaths: leading causes for 2016.&lt;/ref&gt;.

=== Ukweba nobulelesi ===
Ukweba nokho kungenza bona abantu bagcine babulawa. Umuntu lokha nakayokweba nofana ayokulelesa nakabona ukuthi kunabantu abambonileko abangafuna ukumveza emapholiseni angacina sele ababulala ngehloso yokutjhabalalisa ubufakazi.

== Isiphetho ==
Ukubulala kuyinto embi ethaths amaphilo wabantu. Abantu bangabulawa ngesbanga sepi, iingozi, ubulelesi nofana ukugula. Ukubulala kuyinto embi nanyana kungasiyo ihloso ngombana woke umuntu unelungelo lokuphila.</text>
      <sha1>qo4dvtdynfkpcgfmg2n9sbght6gihx2</sha1>
    </revision>
  </page>
  <page>
    <title>Isikhathi</title>
    <ns>0</ns>
    <id>504</id>
    <revision>
      <id>2531</id>
      <timestamp>2025-03-19T09:24:51Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Isikhathi == Isikhathi kuyindlela yokumeda ubude bekwenzeka kwezinto. Kukuragela phambili kusukela ekadeni ukuya esikhathini sanamhlanje nofana esizako. Isikhathi simedwa ngendlela ezinengi ukuya ngobude baso. Ukumeda nofana ukubala isikhathi kusetjenziswa amakhalenda, namawatjhi wesikhathi&lt;ref&gt;What Is Time? A Simple Explanation&lt;/ref&gt;&lt;ref&gt;Peters, J.D., 2013. Calendar, clock, tower. ''Deus in machina: Religion and technology in historical perspective'', pp.25-42.  Vanc...&quot;</comment>
      <origin>2531</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1951" sha1="1lammqq5v9gpf0200p1acim5yvdfpl3" xml:space="preserve">== Isikhathi ==
Isikhathi kuyindlela yokumeda ubude bekwenzeka kwezinto. Kukuragela phambili kusukela ekadeni ukuya esikhathini sanamhlanje nofana esizako. Isikhathi simedwa ngendlela ezinengi ukuya ngobude baso. Ukumeda nofana ukubala isikhathi kusetjenziswa amakhalenda, namawatjhi wesikhathi&lt;ref&gt;What Is Time? A Simple Explanation&lt;/ref&gt;&lt;ref&gt;Peters, J.D., 2013. Calendar, clock, tower. ''Deus in machina: Religion and technology in historical perspective'', pp.25-42.

Vancouver&lt;/ref&gt;. 

== Iindlela zakade zokumeda isikhathi ==
Ekadeni abantu bebameda isikhathi ngelanga bona likuyiphi indawo emafini. Ngamasa bamede ngokulila kweenkukhu nofana ngenyezi.Ukutjhuguluka kweenkhathi zonyaka khabe bakumeda ngokuvela nokunyamalala kweenlwana ezithileko nofana ngokumila kweenthelo ezithileko. Isibonelo ama-orentji amila lokha nakungena ubusika&lt;ref&gt;Holford-Strevens, L., 2005. ''The history of time: a very short introduction'' (Vol. 133). Oxford University Press.&lt;/ref&gt;

== Ukuqakatheka kwesikhathi ==
Isikhathi uyinto eqakathekileko emaphilweni wabantu begou sakhamba sikhambile angekhe sabuyela emuve. kufize abantu basisebenzise ngendlela efaneleko ukuze babalekele ukuzisola. Isikhathi sisisiza bona sikghone ukuzwisisa izolo, inamanhle ne kusasa. Ngaphandle kwesikhathi amaphilo wabantu angatjharagana ngombana angekhe bazi lapho basuka khona begodu nalapho bayakhona

== Ukubala isikhathi&lt;ref&gt;Time - Wikipedia&lt;/ref&gt; ==

=== Unyaka neenyanga ===
Unyaka munye amamalanga ama-365 begodu unenyanga ezili-12.

=== Iveke namalanga ===
Iveke yinye inamalanga alikhomba  begodu ilanga linye linama iri-ama-24

=== Ama-iri ===
Iri linye linamaminithi ama-60, begodu neminithi linye linemizuzu munye.

== Isiphetho ==
Isikhathi ngiso esenza bona amaphilo wabantu aragele phambili, abatu bakghone ukuzazi bona babuya kuphi noma bayaphi.  Kufuze sibulunge isikhathi begodu sisisebenzise kuhle ukubalekela ukuzisola ngombana isikhathi angeze sabiselwa emuva.</text>
      <sha1>1lammqq5v9gpf0200p1acim5yvdfpl3</sha1>
    </revision>
    <revision>
      <id>2542</id>
      <parentid>2531</parentid>
      <timestamp>2025-03-19T11:53:46Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2542</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1951" sha1="040p1n5548otp6kdobcnx0uvz635v65" xml:space="preserve">== Isikhathi ==
Isikhathi kuyindlela yokumeda ubude bekwenzeka kwezinto. Kukuragela phambili kusukela ekadeni ukuya esikhathini sanamhlanje nofana esizako. Isikhathi simedwa ngendlela ezinengi ukuya ngobude baso. Ukumeda nofana ukubala isikhathi kusetjenziswa amakhalenda, namawatjhi wesikhathi&lt;ref&gt;What Is Time? A Simple Explanation&lt;/ref&gt;&lt;ref&gt;Peters, J.D., 2013. Calendar, clock, tower. ''Deus in machina: Religion and technology in historical perspective'', pp.25-42.

Vancouver&lt;/ref&gt;. 

== Iindlela zakade zokumeda isikhathi ==
Ekadeni abantu bebameda isikhathi ngelanga bona likuyiphi indawo emafini. Ngamasa bamede ngokulila kweenkukhu nofana ngenyezi.Ukutjhuguluka kweenkhathi zonyaka khabe bakumeda ngokuvela nokunyamalala kweenlwana ezithileko nofana ngokumila kweenthelo ezithileko. Isibonelo ama-orentji amila lokha nakungena ubusika&lt;ref&gt;Holford-Strevens, L., 2005. ''The history of time: a very short introduction'' (Vol. 133). Oxford University Press.&lt;/ref&gt;

== Ukuqakatheka kwesikhathi ==
Isikhathi uyinto eqakathekileko emaphilweni wabantu begou sakhamba sikhambile angekhe sabuyela emuve. kufuze abantu basisebenzise ngendlela efaneleko ukuze babalekele ukuzisola. Isikhathi sisisiza bona sikghone ukuzwisisa izolo, inamanhle ne kusasa. Ngaphandle kwesikhathi amaphilo wabantu angatjharagana ngombana angekhe bazi lapho basuka khona begodu nalapho bayakhona

== Ukubala isikhathi&lt;ref&gt;Time - Wikipedia&lt;/ref&gt; ==

=== Unyaka neenyanga ===
Unyaka munye amamalanga ama-365 begodu unenyanga ezili-12.

=== Iveke namalanga ===
Iveke yinye inamalanga alikhomba  begodu ilanga linye linama iri-ama-24

=== Ama-iri ===
Iri linye linamaminithi ama-60, begodu neminithi linye linemizuzu munye.

== Isiphetho ==
Isikhathi ngiso esenza bona amaphilo wabantu aragele phambili, abatu bakghone ukuzazi bona babuya kuphi noma bayaphi.  Kufuze sibulunge isikhathi begodu sisisebenzise kuhle ukubalekela ukuzisola ngombana isikhathi angeze sabiselwa emuva.</text>
      <sha1>040p1n5548otp6kdobcnx0uvz635v65</sha1>
    </revision>
    <revision>
      <id>2543</id>
      <parentid>2542</parentid>
      <timestamp>2025-03-19T11:54:17Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2543</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1951" sha1="90fnm1n9u5djgs2yp7oirewm1qwebyl" xml:space="preserve">== Isikhathi ==
Isikhathi kuyindlela yokumeda ubude bekwenzeka kwezinto. Kukuragela phambili kusukela ekadeni ukuya esikhathini sanamhlanje nofana esizako. Isikhathi simedwa ngendlela ezinengi ukuya ngobude baso. Ukumeda nofana ukubala isikhathi kusetjenziswa amakhalenda, namawatjhi wesikhathi&lt;ref&gt;What Is Time? A Simple Explanation&lt;/ref&gt;&lt;ref&gt;Peters, J.D., 2013. Calendar, clock, tower. ''Deus in machina: Religion and technology in historical perspective'', pp.25-42.

Vancouver&lt;/ref&gt;. 

== Iindlela zakade zokumeda isikhathi ==
Ekadeni abantu bebameda isikhathi ngelanga bona likuyiphi indawo emafini. Ngamasa bamede ngokulila kweenkukhu nofana ngenyezi.Ukutjhuguluka kweenkhathi zonyaka khabe bakumeda ngokuvela nokunyamalala kweenlwana ezithileko nofana ngokumila kweenthelo ezithileko. Isibonelo ama-orentji amila lokha nakungena ubusika&lt;ref&gt;Holford-Strevens, L., 2005. ''The history of time: a very short introduction'' (Vol. 133). Oxford University Press.&lt;/ref&gt;

== Ukuqakatheka kwesikhathi ==
Isikhathi uyinto eqakathekileko emaphilweni wabantu begou sakhamba sikhambile angekhe sabuyela emuve. kufuze abantu basisebenzise ngendlela efaneleko ukuze babalekele ukuzisola. Isikhathi sisisiza bona sikghone ukuzwisisa izolo, inamanhle ne kusasa. Ngaphandle kwesikhathi amaphilo wabantu angatjharagana ngombana angekhe bazi lapho basuka khona begodu nalapho bayakhona

== Ukubala isikhathi&lt;ref&gt;Time - Wikipedia&lt;/ref&gt; ==

=== Unyaka neenyanga ===
Unyaka munye unamalanga ama-365 begodu unenyanga ezili-12.

=== Iveke namalanga ===
Iveke yinye inamalanga alikhomba  begodu ilanga linye linama iri-ama-24

=== Ama-iri ===
Iri linye linamaminithi ama-60, begodu neminithi linye linemizuzu munye.

== Isiphetho ==
Isikhathi ngiso esenza bona amaphilo wabantu aragele phambili, abatu bakghone ukuzazi bona babuya kuphi noma bayaphi.  Kufuze sibulunge isikhathi begodu sisisebenzise kuhle ukubalekela ukuzisola ngombana isikhathi angeze sabiselwa emuva.</text>
      <sha1>90fnm1n9u5djgs2yp7oirewm1qwebyl</sha1>
    </revision>
    <revision>
      <id>2544</id>
      <parentid>2543</parentid>
      <timestamp>2025-03-19T11:55:01Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2544</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1952" sha1="841dz8rvvnujkophaplnoiz67ms9orm" xml:space="preserve">== Isikhathi ==
Isikhathi kuyindlela yokumeda ubude bekwenzeka kwezinto. Kukuragela phambili kusukela ekadeni ukuya esikhathini sanamhlanje nofana esizako. Isikhathi simedwa ngendlela ezinengi ukuya ngobude baso. Ukumeda nofana ukubala isikhathi kusetjenziswa amakhalenda, namawatjhi wesikhathi&lt;ref&gt;What Is Time? A Simple Explanation&lt;/ref&gt;&lt;ref&gt;Peters, J.D., 2013. Calendar, clock, tower. ''Deus in machina: Religion and technology in historical perspective'', pp.25-42.

Vancouver&lt;/ref&gt;. 

== Iindlela zakade zokumeda isikhathi ==
Ekadeni abantu bebameda isikhathi ngelanga bona likuyiphi indawo emafini. Ngamasa bamede ngokulila kweenkukhu nofana ngenyezi.Ukutjhuguluka kweenkhathi zonyaka khabe bakumeda ngokuvela nokunyamalala kweenlwana ezithileko nofana ngokumila kweenthelo ezithileko. Isibonelo ama-orentji amila lokha nakungena ubusika&lt;ref&gt;Holford-Strevens, L., 2005. ''The history of time: a very short introduction'' (Vol. 133). Oxford University Press.&lt;/ref&gt;

== Ukuqakatheka kwesikhathi ==
Isikhathi uyinto eqakathekileko emaphilweni wabantu begou sakhamba sikhambile angekhe sabuyela emuve. kufuze abantu basisebenzise ngendlela efaneleko ukuze babalekele ukuzisola. Isikhathi sisisiza bona sikghone ukuzwisisa izolo, inamanhle ne kusasa. Ngaphandle kwesikhathi amaphilo wabantu angatjharagana ngombana angekhe bazi lapho basuka khona begodu nalapho bayakhona

== Ukubala isikhathi&lt;ref&gt;Time - Wikipedia&lt;/ref&gt; ==

=== Unyaka neenyanga ===
Unyaka munye unamalanga ama-365 begodu unenyanga ezili-12.

=== Iveke namalanga ===
Iveke yinye inamalanga alikhomba  begodu ilanga linye linama iri-ama-24

=== Ama-iri ===
Iri linye linamaminithi ama-60, begodu neminithi linye linemizuzu ema-60.

== Isiphetho ==
Isikhathi ngiso esenza bona amaphilo wabantu aragele phambili, abatu bakghone ukuzazi bona babuya kuphi noma bayaphi.  Kufuze sibulunge isikhathi begodu sisisebenzise kuhle ukubalekela ukuzisola ngombana isikhathi angeze sabiselwa emuva.</text>
      <sha1>841dz8rvvnujkophaplnoiz67ms9orm</sha1>
    </revision>
    <revision>
      <id>2555</id>
      <parentid>2544</parentid>
      <timestamp>2025-03-20T16:32:48Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2555</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2016" sha1="95x808mhx10sgnz6fu9mjx1dlzvbsg8" xml:space="preserve">[[Isimumathi:Iwatjhi yesikhathi.jpg|thumb|Iwatjhi yesikhathi]]

== Isikhathi ==
Isikhathi kuyindlela yokumeda ubude bekwenzeka kwezinto. Kukuragela phambili kusukela ekadeni ukuya esikhathini sanamhlanje nofana esizako. Isikhathi simedwa ngendlela ezinengi ukuya ngobude baso. Ukumeda nofana ukubala isikhathi kusetjenziswa amakhalenda, namawatjhi wesikhathi&lt;ref&gt;What Is Time? A Simple Explanation&lt;/ref&gt;&lt;ref&gt;Peters, J.D., 2013. Calendar, clock, tower. ''Deus in machina: Religion and technology in historical perspective'', pp.25-42.

Vancouver&lt;/ref&gt;. 

== Iindlela zakade zokumeda isikhathi ==
Ekadeni abantu bebameda isikhathi ngelanga bona likuyiphi indawo emafini. Ngamasa bamede ngokulila kweenkukhu nofana ngenyezi.Ukutjhuguluka kweenkhathi zonyaka khabe bakumeda ngokuvela nokunyamalala kweenlwana ezithileko nofana ngokumila kweenthelo ezithileko. Isibonelo ama-orentji amila lokha nakungena ubusika&lt;ref&gt;Holford-Strevens, L., 2005. ''The history of time: a very short introduction'' (Vol. 133). Oxford University Press.&lt;/ref&gt;

== Ukuqakatheka kwesikhathi ==
Isikhathi uyinto eqakathekileko emaphilweni wabantu begou sakhamba sikhambile angekhe sabuyela emuve. kufuze abantu basisebenzise ngendlela efaneleko ukuze babalekele ukuzisola. Isikhathi sisisiza bona sikghone ukuzwisisa izolo, inamanhle ne kusasa. Ngaphandle kwesikhathi amaphilo wabantu angatjharagana ngombana angekhe bazi lapho basuka khona begodu nalapho bayakhona

== Ukubala isikhathi&lt;ref&gt;Time - Wikipedia&lt;/ref&gt; ==

=== Unyaka neenyanga ===
Unyaka munye unamalanga ama-365 begodu unenyanga ezili-12.

=== Iveke namalanga ===
Iveke yinye inamalanga alikhomba  begodu ilanga linye linama iri-ama-24

=== Ama-iri ===
Iri linye linamaminithi ama-60, begodu neminithi linye linemizuzu ema-60.

== Isiphetho ==
Isikhathi ngiso esenza bona amaphilo wabantu aragele phambili, abatu bakghone ukuzazi bona babuya kuphi noma bayaphi.  Kufuze sibulunge isikhathi begodu sisisebenzise kuhle ukubalekela ukuzisola ngombana isikhathi angeze sabiselwa emuva.</text>
      <sha1>95x808mhx10sgnz6fu9mjx1dlzvbsg8</sha1>
    </revision>
    <revision>
      <id>2932</id>
      <parentid>2555</parentid>
      <timestamp>2025-06-06T17:11:48Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>Gurg</comment>
      <origin>2932</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="38" sha1="iog8j7ajqb68s69t90m23rmzsaav5vw" xml:space="preserve">I call it vandalism. Rhymes with Grug.</text>
      <sha1>iog8j7ajqb68s69t90m23rmzsaav5vw</sha1>
    </revision>
    <revision>
      <id>3098</id>
      <parentid>2932</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Nqobile69|Nqobile69]]</comment>
      <origin>2555</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2016" sha1="95x808mhx10sgnz6fu9mjx1dlzvbsg8" xml:space="preserve">[[Isimumathi:Iwatjhi yesikhathi.jpg|thumb|Iwatjhi yesikhathi]]

== Isikhathi ==
Isikhathi kuyindlela yokumeda ubude bekwenzeka kwezinto. Kukuragela phambili kusukela ekadeni ukuya esikhathini sanamhlanje nofana esizako. Isikhathi simedwa ngendlela ezinengi ukuya ngobude baso. Ukumeda nofana ukubala isikhathi kusetjenziswa amakhalenda, namawatjhi wesikhathi&lt;ref&gt;What Is Time? A Simple Explanation&lt;/ref&gt;&lt;ref&gt;Peters, J.D., 2013. Calendar, clock, tower. ''Deus in machina: Religion and technology in historical perspective'', pp.25-42.

Vancouver&lt;/ref&gt;. 

== Iindlela zakade zokumeda isikhathi ==
Ekadeni abantu bebameda isikhathi ngelanga bona likuyiphi indawo emafini. Ngamasa bamede ngokulila kweenkukhu nofana ngenyezi.Ukutjhuguluka kweenkhathi zonyaka khabe bakumeda ngokuvela nokunyamalala kweenlwana ezithileko nofana ngokumila kweenthelo ezithileko. Isibonelo ama-orentji amila lokha nakungena ubusika&lt;ref&gt;Holford-Strevens, L., 2005. ''The history of time: a very short introduction'' (Vol. 133). Oxford University Press.&lt;/ref&gt;

== Ukuqakatheka kwesikhathi ==
Isikhathi uyinto eqakathekileko emaphilweni wabantu begou sakhamba sikhambile angekhe sabuyela emuve. kufuze abantu basisebenzise ngendlela efaneleko ukuze babalekele ukuzisola. Isikhathi sisisiza bona sikghone ukuzwisisa izolo, inamanhle ne kusasa. Ngaphandle kwesikhathi amaphilo wabantu angatjharagana ngombana angekhe bazi lapho basuka khona begodu nalapho bayakhona

== Ukubala isikhathi&lt;ref&gt;Time - Wikipedia&lt;/ref&gt; ==

=== Unyaka neenyanga ===
Unyaka munye unamalanga ama-365 begodu unenyanga ezili-12.

=== Iveke namalanga ===
Iveke yinye inamalanga alikhomba  begodu ilanga linye linama iri-ama-24

=== Ama-iri ===
Iri linye linamaminithi ama-60, begodu neminithi linye linemizuzu ema-60.

== Isiphetho ==
Isikhathi ngiso esenza bona amaphilo wabantu aragele phambili, abatu bakghone ukuzazi bona babuya kuphi noma bayaphi.  Kufuze sibulunge isikhathi begodu sisisebenzise kuhle ukubalekela ukuzisola ngombana isikhathi angeze sabiselwa emuva.</text>
      <sha1>95x808mhx10sgnz6fu9mjx1dlzvbsg8</sha1>
    </revision>
  </page>
  <page>
    <title>Ukuhlukumezana eenkundleni zokuthintana</title>
    <ns>0</ns>
    <id>505</id>
    <revision>
      <id>2532</id>
      <timestamp>2025-03-19T09:52:27Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Ukuhlukumezana eenkundleni zokuthintana == '''Iinkundla''' zokuthintana kuyindawo lapho lapho abantu babelana khona ngelwazi, bakghona khona ukucoca begodu benze nesitjhomi. Ukuzwana nokusebezisa iinkundla zokuthintana sele kuvuse enye into engayisiyihle ekukuhlukumenzana okungenzeka gokusabisana,  ukuhlazisana ngemilayezo&lt;ref&gt;Giumetti, G.W. and Kowalski, R.M., 2022. Cyberbullying via social media and well-being. ''Current opinion in psychology'', ''45'', p.101314.&lt;/r...&quot;</comment>
      <origin>2532</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5013" sha1="hz978gg0f3xdaeyuctlie5u1dlco4ue" xml:space="preserve">== Ukuhlukumezana eenkundleni zokuthintana ==
'''Iinkundla''' zokuthintana kuyindawo lapho lapho abantu babelana khona ngelwazi, bakghona khona ukucoca begodu benze nesitjhomi. Ukuzwana nokusebezisa iinkundla zokuthintana sele kuvuse enye into engayisiyihle ekukuhlukumenzana okungenzeka gokusabisana,  ukuhlazisana ngemilayezo&lt;ref&gt;Giumetti, G.W. and Kowalski, R.M., 2022. Cyberbullying via social media and well-being. ''Current opinion in psychology'', ''45'', p.101314.&lt;/ref&gt;.

== Iindlela ezahlukileko zokuhlukumezana eenkundleni zokuthintana ==
Ukusabisana

Abantu bangathumelela amanaba wabo imilayezo yokubasabisa ukwenza bona amanaba wabo agcine sele asaba begodu angasakhululeki eenkundleni zokuthinana&lt;ref&gt;Englander, E., Donnerstein, E., Kowalski, R., Lin, C.A. and Parti, K., 2017. Defining cyberbullying. ''Pediatrics'', ''140''(Supplement_2), pp.S148-S151.&lt;/ref&gt;.

Ukulandelela izinto ezenziwa mumuntu

Abanye abantu bakghona ukulandelela into eyenziwa mumuntu eenkundleni zokuthintana. Balandelela bona ufaka ziphi izinto nofana ubhala ini, balandelela bobana ucoca nabobani nokuthi sele umuntu loyo akuphi&lt;ref&gt;Stevens, F., Nurse, J.R. and Arief, B., 2021. Cyber stalking, cyber harassment, and adult mental health: A systematic review. ''Cyberpsychology, Behavior, and Social Networking'', ''24''(6), pp.367-376.&lt;/ref&gt;.

Ukuphikisana

Ukuphikisana kuyinto evamileko eenkundleni zokuthintana. Abantu bakghona ukuthukana, ukuphisana basebenzisa ilimi elilumelako lokuthukana. Lokhu kungenziwa babantu abangazwaniko babaga into ethileko&lt;ref&gt;Englander, E., Donnerstein, E., Kowalski, R., Lin, C.A. and Parti, K., 2017. Defining cyberbullying. ''Pediatrics'', ''140''(Supplement_2), pp.S148-S151.&lt;/ref&gt;.

Ukuzenza umuntu ongasuye ukuhlukumeza

Abanye abantu basuku benze ama-akhantu bowutsotsi bazenze abantu abangasibo ukuhlupha banye abanye abantu. Lokhui bakweza ngehloso yokuhlupha abanye abantu. 

Ukukhiphana

Ukukhiphaa kutjho loha umuntu akhipha umuntu angamthandiko nofana alwa naye esiqhemeni sokucoca seenkundleni zokuthintana kungaba ku facebook, ku whatsapp nofana kokunye.

== Imiphumela yokuhlukumezana eenkundleni zokuthintana ==
Ukudana nokugandeleleka komkhumbulo

Ukuhlukumezeka eenkundleni zokuthintana kungagcina sele kubangela bona umuntu ahlele adanile, azikhiphe abantwini begodu nasele kudlange khulu umuntu anggcina sele agandeleleke ngokomkhumbulo&lt;ref&gt;Martínez-Monteagudo, M.C., Delgado, B., Díaz-Herrero, Á. and García-Fernández, J.M., 2020. Relationship between suicidal thinking, anxiety, depression and stress in university students who are victims of cyberbullying. ''Psychiatry Research'', ''286'', p.112856.&lt;/ref&gt;.

Ukuzibandlulula ebantwini

Lokha umunu athola ukuhlukumezeka eenkundleni zokuthintana uthola ubudisis bokuhlangana ngabantu azibone sele amumuntu ophasi nofana anganasithunzi bese agcine azikhipha ebantwini azifune ayedwa&lt;ref&gt;Ademiluyi, A., Li, C. and Park, A., 2022. Implications and preventions of cyberbullying and social exclusion in social media: systematic review. ''JMIR formative research'', ''6''(1), p.e30286.&lt;/ref&gt;&lt;ref&gt;Nixon, C.L., 2014. Current perspectives: the impact of cyberbullying on adolescent health. ''Adolescent health, medicine and therapeutics'', pp.143-158.&lt;/ref&gt;.

Ukwehla kwemiphumela esikolweni

Umuntu ohlukumezwako nangabe usese mntwana wesikolo angagcina sele angasabenzi kuhle esikolweni ngesibanga sokuthi into le ingamphazamisa abe nobudisi bokubeka umkhumbulo wakhe entweni ayenzako. Uyokugcina sele athola imiphumela ephasi esikolweni ngesibanga sokuhlukumezeka.

Ukungabi nepilo emzimbeni

Ipilo yomuntu ohlukumezekileko eenkundleni zokuthintana iyaphazamiseka. Ngathola umntu loyo agcina sele aphatha ihloko, amathumbu nofana agcine sele angasakghoni ukulala&lt;ref&gt;Nixon, C.L., 2014. Current perspectives: the impact of cyberbullying on adolescent health. ''Adolescent health, medicine and therapeutics'', pp.143-158.&lt;/ref&gt;.

== Indlela zokuvikela ukuhlukumezana eeenkundleni zokuthintana ==
Ukuzibandakanya kwababelethi

Ukuvikela ukuhlukumezana eenkundlelni zokuthintana kufanele ababelethi bazibandakanye ngokuthi batjheje lokho Umntwana wabo akwenzako eenkundleni zokuthintana. Bese kuthi nangabe babone into ekhombisa ukuhlukumezeka nofana ukuhlukumeza abanye bayakhuze kuseses nesikhathi&lt;ref&gt;Robinson, E., 2013. Parental involvement in preventing and responding to cyberbullying. ''Family Matters'', (92), pp.68-76.&lt;/ref&gt;.

Ukufundisa ngokusebenzisa inkundla lezi
Abantu nofana abantwana kufanelwe bafundiswe indlela ekungiyo yokusebezisa iinkundla zokuthintana. Isibonelo kufanele bafundiswe bona babalekele ukubhala imilayezo ethika abatu nofana ebasabisako.

== Isiphetho ==
Ukuhlukumezana eeenkundleni zokuthintana kuyinto ekhulako amalanga la begodu kufanale ibekwe ilihlo. Kufanale abantu bakghone ukubona ukuhlukumezeka lokhu nokuthi ibanomthelela onjani kibongazimbi bayo. Kufanele sizifundise thina na banye abantu ukuyibalekela begodu abongazimbi bayo bathole isekelo abalidingako ukululama kiyo.</text>
      <sha1>hz978gg0f3xdaeyuctlie5u1dlco4ue</sha1>
    </revision>
  </page>
  <page>
    <title>Ubuhlobo</title>
    <ns>0</ns>
    <id>506</id>
    <revision>
      <id>2533</id>
      <timestamp>2025-03-19T10:09:59Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot; '''Iinhlobo''' kubabantu abaphuma emndenini munye bahlobene ngengazi nofana ngomtjhado&lt;ref&gt;Relative - Definition, Meaning &amp; Synonyms | Vocabulary.com&lt;/ref&gt;. Abantu abazinhlobo bangaba neembongo ezifanako nanyana bangabi nazo.Iinhlobo zingabonakala nangesotja elifanako lomzimba isibonelo: ubide nofana ukunona. Iinhlobo kubabantu abadlali indima eqakathekilo epilweni yomuntu ngombana ngizo oba nobudlelwane obuseduze nobunamandla nabo.  Iinhlobo ziqakathekile ngombana zikg...&quot;</comment>
      <origin>2533</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2031" sha1="fnsmwaw43nb3v7ovkz2z5su53g0c474" xml:space="preserve">
'''Iinhlobo''' kubabantu abaphuma emndenini munye bahlobene ngengazi nofana ngomtjhado&lt;ref&gt;Relative - Definition, Meaning &amp; Synonyms | Vocabulary.com&lt;/ref&gt;. Abantu abazinhlobo bangaba neembongo ezifanako nanyana bangabi nazo.Iinhlobo zingabonakala nangesotja elifanako lomzimba isibonelo: ubide nofana ukunona. Iinhlobo kubabantu abadlali indima eqakathekilo epilweni yomuntu ngombana ngizo oba nobudlelwane obuseduze nobunamandla nabo.

Iinhlobo ziqakathekile ngombana zikghona ukukwenza uzizwe wamukelekile, uzazi ukuthi ungubani nokuthi wazi amasiko nemvelaphi yakho.Abantu abadala abazinhlobo zakho bakghona ukukunikela iinluleko nokuhlakanipha ekuzokwenza bona ukghone ukuthatha inqunto ezihle zepilo&lt;ref&gt;Sefa Dei, G.J., 2020. Elders’ cultural knowledges and African indigeneity. ''The Palgrave handbook of African education and Indigenous knowledge'', pp.279-301.&lt;/ref&gt;.

Iinhlobo zingilabo bantu abangakwenza bona ukghone ukubona ukuthi imikghwa ethileko uyithethephi begodu ukghone ukwazi ukuthi izinto ozenzako uzenza ngombana ufuze ubani emndenini wekhenu.Iinhlobo zikghona ukukunikela isekelo olidingako ngombana abantu abazinhlobo kungilabo bantu engekhe abakulahlela ithemba nanyana sewuhluleka. kungizo ezizwelalana nawe zikunikeze ithando elinganambadela&lt;ref&gt;Malär, L., Krohmer, H., Hoyer, W.D. and Nyffenegger, B., 2011. Emotional brand attachment and brand personality: The relative importance of the actual and the ideal self. ''Journal of marketing'', ''75''(4), pp.35-52.&lt;/ref&gt;.

== Iimbonelo zeenhlobo ==
Umama-Mumuntu wengubo okubelethako

Ubaba -Mumuntu wembaji okubelethako

Ugogo-Ngumma kamamakho nofana kababakho

Umkhulu- Ngubaba obelethe umamakh nofana ubabakho

Ukhokho- ngumma obelethe ugogo

Umani- Ngudadwabo kamma omnani

URhulu- Ngudadwabo kamma omkhulu

Umalume- Ngu bhuthi kamma

Usonghwana- Ngubhuti wakhe likababa omncani

Usorhulu-Ngubhuti kababa omkhulu

Ukhgari- Ngudadwabo kababa

Umntamama-mtwana kamalume, kamani nofana karhulwakho.

Umzala- Umtwana kakghari nofana kasonghwana wakho</text>
      <sha1>fnsmwaw43nb3v7ovkz2z5su53g0c474</sha1>
    </revision>
    <revision>
      <id>2534</id>
      <parentid>2533</parentid>
      <timestamp>2025-03-19T10:13:25Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2534</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2047" sha1="jv3n1cgne7y2gjy14yxg5ela83dkgfm" xml:space="preserve">
'''Iinhlobo''' kubabantu abaphuma emndenini munye bahlobene ngengazi nofana ngomtjhado&lt;ref&gt;Relative - Definition, Meaning &amp; Synonyms | Vocabulary.com&lt;/ref&gt;. Abantu abazinhlobo bangaba neembongo ezifanako nanyana bangabi nazo.Iinhlobo zingabonakala nangesotja elifanako lomzimba isibonelo: ubude nofana [[ukunona]]. Iinhlobo kubabantu abadlali indima eqakathekilo epilweni yomuntu ngombana ngizo oba nobudlelwane obuseduze nobunamandla nabo.

Iinhlobo ziqakathekile ngombana zikghona ukukwenza uzizwe wamukelekile, uzazi ukuthi ungubani nokuthi wazi amasiko nemvelaphi yakho.Abantu abadala abazinhlobo zakho bakghona ukukunikela iinluleko nokuhlakanipha ekuzokwenza bona ukghone ukuthatha inqunto ezihle zepilo&lt;ref&gt;Sefa Dei, G.J., 2020. Elders’ cultural knowledges and African indigeneity. ''The Palgrave handbook of African education and Indigenous knowledge'', pp.279-301.&lt;/ref&gt;.

Iinhlobo zingilabo bantu abangakwenza bona ukghone ukubona ukuthi [[imikghwa]] ethileko uyithethephi begodu ukghone ukwazi ukuthi izinto ozenzako uzenza ngombana ufuze ubani emndenini wekhenu.Iinhlobo zikghona ukukunikela isekelo olidingako ngombana abantu abazinhlobo kungilabo bantu engekhe abakulahlela ithemba nanyana sewuhluleka. kungizo ezizwelalana nawe zikunikeze ithando elinganambadela&lt;ref&gt;Malär, L., Krohmer, H., Hoyer, W.D. and Nyffenegger, B., 2011. Emotional brand attachment and brand personality: The relative importance of the actual and the ideal self. ''Journal of marketing'', ''75''(4), pp.35-52.&lt;/ref&gt;.

== Iimbonelo zeenhlobo ==
[[Umama]]-Mumuntu wengubo okubelethako

[[Ubaba]] -Mumuntu wembaji okubelethako

Ugogo-Ngumma kamamakho nofana kababakho

Umkhulu- Ngubaba obelethe umamakh nofana ubabakho

Ukhokho- ngumma obelethe ugogo

Umani- Ngudadwabo kamma omnani

URhulu- Ngudadwabo kamma omkhulu

Umalume- Ngu bhuthi kamma

Usonghwana- Ngubhuti wakhe likababa omncani

Usorhulu-Ngubhuti kababa omkhulu

Ukhgari- Ngudadwabo kababa

Umntamama-mtwana kamalume, kamani nofana karhulwakho.

Umzala- Umtwana kakghari nofana kasonghwana wakho</text>
      <sha1>jv3n1cgne7y2gjy14yxg5ela83dkgfm</sha1>
    </revision>
  </page>
  <page>
    <title>Igazi</title>
    <ns>0</ns>
    <id>507</id>
    <revision>
      <id>2536</id>
      <timestamp>2025-03-19T10:29:56Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Iingazi == '''Igazi''' kumamanzi abovu akhamba umzimba soke ngaphakathi komuntu. Kuyinto eqakatheke khulu eyenza bona umuntu akghone ukuphila. Ngaphandle kwegazi akekho umuntu ongakghona ukuphila. [[Ihliziyo]] limpompa igazi elizele i-oksijini  lisuke ehliziyweni bese likhambe umzimba woke. Igazi ngilo elenza bona [[umzimba]] usebenze kuhle. Lokha nawunganagazi kuhle nofana igazi lakho lingakhambi kuhle emzimbeni kunogula okuthileko ongakuthola nawumumuntu&lt;ref&gt;Scudell...&quot;</comment>
      <origin>2536</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2590" sha1="7bz48mgcsh4k188vr32kz01ux59n6ka" xml:space="preserve">== Iingazi ==
'''Igazi''' kumamanzi abovu akhamba umzimba soke ngaphakathi komuntu. Kuyinto eqakatheke khulu eyenza bona umuntu akghone ukuphila. Ngaphandle kwegazi akekho umuntu ongakghona ukuphila. [[Ihliziyo]] limpompa igazi elizele i-oksijini  lisuke ehliziyweni bese likhambe umzimba woke. Igazi ngilo elenza bona [[umzimba]] usebenze kuhle. Lokha nawunganagazi kuhle nofana igazi lakho lingakhambi kuhle emzimbeni kunogula okuthileko ongakuthola nawumumuntu&lt;ref&gt;Scudellari, M., 2015. Blood to blood. ''Nature'', ''517''(7535), p.426.&lt;/ref&gt;.

== Izinto ezitholakala ngaphakathi kwegazi ==
Iplazima

Le kuyungcenye yegazi emamanzi eyanza amaphesende ama-55. Ingcenye le iphethe amanzi, itswayi, iswigiri, amafutha Kanye nama phrotheyini.

Amaseli abovu wegazi

Wona Sebenza ukuthwala i-oksijini esuka emaphaphini uyise emzimbeni phezu kwesikhumba nofana enyameni. Amaseli lawa anephrotheyini ebizwa bona yi- haemoglobin, ekungiyo eyenza bona igazi libe nombala obuvu&lt;ref&gt;Litvinov, R.I. and Weisel, J.W., 2017. Role of red blood cells in haemostasis and thrombosis. ''ISBT science series'', ''12''(1), pp.176-183.&lt;/ref&gt;.

Amaseli amhlophe wegazi

Ngelimi lesingisi abizwa bona ma- luecytes ngiwo asiza amasotja womzimba bona akghone ukulwisana namagulo&lt;ref&gt;Nicholson, L.B., 2016. The immune system. ''Essays in biochemistry'', ''60''(3), pp.275-301.&lt;/ref&gt;.

Amaplatileti

Awanabumbeko begodu mancani kodwana adlala indima ekulu ekwenzeni bona igazi lokhone ukwenza amaklothi&lt;ref&gt;Fogelson, A.L. and Neeves, K.B., 2015. Fluid mechanics of blood clot formation. ''Annual review of fluid mechanics'', ''47''(1), pp.377-403.&lt;/ref&gt;.

== Ukukhamba kwegazi emzimbeni ==
Ama-Arteries

Kumisipha ekhambisa igazi elizele i-oksijini lisuka ehliziyweni bese alikhambe lisuke ehliziyweni likhambe umzimba woke&lt;ref&gt;Tucker, W.D., Arora, Y. and Mahajan, K., 2017. Anatomy, blood vessels.&lt;/ref&gt;.

Amaveyini

Kumithambo ephatha igazi eliphelelwe yi-oksijini emzimbeni ilibuyisele ehliziyweni ukuthi ihloziyo iyolipompa&lt;ref&gt;Mitchell, R.N. and Schoen, F.J., 2010. Blood vessels. ''Robbins and Cotran: Pathologic Basis of Disease.(8th edition) Saunders Elsevier, Philadelphia, US'', pp.516-17.&lt;/ref&gt;.

Amakhaphilari

Kumithambo emincani eyamukela esenyameni eyamukela I-oksijini nemisoco.

Isiphetho

Ingazi ziqakathekile emaphilweni wabantu ngombana umuntu angeze aphila ngaphandle kwegazi. Igazi ngilo elenza bona umuntu aphile kuhle, likusuka ehliziyweni likhambe umzimba woke bese likhambisa i-oksijini ngama atheri bese liphinde libuye ngomsipha wamaveyini sele linganayo i-oksijini libuyele ehliziyweni.</text>
      <sha1>7bz48mgcsh4k188vr32kz01ux59n6ka</sha1>
    </revision>
    <revision>
      <id>2797</id>
      <parentid>2536</parentid>
      <timestamp>2025-05-06T12:32:22Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2797</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2588" sha1="fosi3foq6ko42f4xi1yk5rvg34qcyk0" xml:space="preserve">== Iingazi ==
'''Igazi''' kumamanzi abovu akhamba umzimba woke ngaphakathi komuntu. Kuyinto eqakatheke khulu eyenza bona umuntu akghone ukuphila. Ngaphandle kwegazi akekho umuntu ongakghona ukuphila. [[Ihliziyo]] limpompa igazi elizele i-oksijini  lisuke ehliziyweni bese likhambe umzimba woke. Igazi lenza bona [[umzimba]] usebenze kuhle. Lokha nawunganagazi kuhle nofana igazi lakho lingakhambi kuhle emzimbeni kungab namagula athileko ongawathola nawumumuntu&lt;ref&gt;Scudellari, M., 2015. Blood to blood. ''Nature'', ''517''(7535), p.426.&lt;/ref&gt;.

== Izinto ezitholakala ngaphakathi kwegazi ==
Iplazima

Le kuyungcenye yegazi emamanzi eyanza amaphesende ama-55. Ingcenye le iphethe amanzi, itswayi, iswigiri, amafutha Kanye nama phrotheyini.

Amaseli abovu wegazi

Wona Sebenza ukuthwala i-oksijini esuka emaphaphini uyise emzimbeni phezu kwesikhumba nofana enyameni. Amaseli lawa anephrotheyini ebizwa bona yi- haemoglobin, ekungiyo eyenza bona igazi libe nombala obuvu&lt;ref&gt;Litvinov, R.I. and Weisel, J.W., 2017. Role of red blood cells in haemostasis and thrombosis. ''ISBT science series'', ''12''(1), pp.176-183.&lt;/ref&gt;.

Amaseli amhlophe wegazi

Ngelimi lesingisi abizwa bona ma- luecytes ngiwo asiza amasotja womzimba bona akghone ukulwisana namagulo&lt;ref&gt;Nicholson, L.B., 2016. The immune system. ''Essays in biochemistry'', ''60''(3), pp.275-301.&lt;/ref&gt;.

Amaplatileti

Awanabumbeko begodu mancani kodwana adlala indima ekulu ekwenzeni bona igazi lokhone ukwenza amaklothi&lt;ref&gt;Fogelson, A.L. and Neeves, K.B., 2015. Fluid mechanics of blood clot formation. ''Annual review of fluid mechanics'', ''47''(1), pp.377-403.&lt;/ref&gt;.

== Ukukhamba kwegazi emzimbeni ==
Ama-Arteries

Kumisipha ekhambisa igazi elizele i-oksijini lisuka ehliziyweni bese alikhambe lisuke ehliziyweni likhambe umzimba woke&lt;ref&gt;Tucker, W.D., Arora, Y. and Mahajan, K., 2017. Anatomy, blood vessels.&lt;/ref&gt;.

Amaveyini

Kumithambo ephatha igazi eliphelelwe yi-oksijini emzimbeni ilibuyisele ehliziyweni ukuthi ihloziyo iyolipompa&lt;ref&gt;Mitchell, R.N. and Schoen, F.J., 2010. Blood vessels. ''Robbins and Cotran: Pathologic Basis of Disease.(8th edition) Saunders Elsevier, Philadelphia, US'', pp.516-17.&lt;/ref&gt;.

Amakhaphilari

Kumithambo emincani eyamukela esenyameni eyamukela I-oksijini nemisoco.

Isiphetho

Ingazi ziqakathekile emaphilweni wabantu ngombana umuntu angeze aphila ngaphandle kwegazi. Igazi ngilo elenza bona umuntu aphile kuhle, likusuka ehliziyweni likhambe umzimba woke bese likhambisa i-oksijini ngama atheri bese liphinde libuye ngomsipha wamaveyini sele linganayo i-oksijini libuyele ehliziyweni.</text>
      <sha1>fosi3foq6ko42f4xi1yk5rvg34qcyk0</sha1>
    </revision>
    <revision>
      <id>2798</id>
      <parentid>2797</parentid>
      <timestamp>2025-05-06T12:32:59Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2798</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2588" sha1="c9htq854cgbkf8jssj9ji3pjidymbbp" xml:space="preserve">== Iingazi ==
'''Igazi''' kumamanzi abovu akhamba umzimba woke ngaphakathi komuntu. Kuyinto eqakatheke khulu eyenza bona umuntu akghone ukuphila. Ngaphandle kwegazi akekho umuntu ongakghona ukuphila. [[Ihliziyo]] limpompa igazi elizele i-oksijini  lisuke ehliziyweni bese likhambe umzimba woke. Igazi lenza bona [[umzimba]] usebenze kuhle. Lokha nawunganagazi kuhle nofana igazi lakho lingakhambi kuhle emzimbeni kungab namagula athileko ongawathola nawumumuntu&lt;ref&gt;Scudellari, M., 2015. Blood to blood. ''Nature'', ''517''(7535), p.426.&lt;/ref&gt;.

== Izinto ezitholakala ngaphakathi kwegazi ==
Iplazima

Le kuyungcenye yegazi emamanzi eyanza amaphesende ama-55. Ingcenye le iphethe amanzi, itswayi, iswigiri, amafutha Kanye nama phrotheyini.

Amaseli abovu wegazi

Wona Sebenza ukuthwala i-oksijini esuka emaphaphini uyise emzimbeni phezu kwesikhumba nofana enyameni. Amaseli lawa anephrotheyini ebizwa bona yi- haemoglobin, ekungiyo eyenza bona igazi libe nombala obovu&lt;ref&gt;Litvinov, R.I. and Weisel, J.W., 2017. Role of red blood cells in haemostasis and thrombosis. ''ISBT science series'', ''12''(1), pp.176-183.&lt;/ref&gt;.

Amaseli amhlophe wegazi

Ngelimi lesingisi abizwa bona ma- luecytes ngiwo asiza amasotja womzimba bona akghone ukulwisana namagulo&lt;ref&gt;Nicholson, L.B., 2016. The immune system. ''Essays in biochemistry'', ''60''(3), pp.275-301.&lt;/ref&gt;.

Amaplatileti

Awanabumbeko begodu mancani kodwana adlala indima ekulu ekwenzeni bona igazi lokhone ukwenza amaklothi&lt;ref&gt;Fogelson, A.L. and Neeves, K.B., 2015. Fluid mechanics of blood clot formation. ''Annual review of fluid mechanics'', ''47''(1), pp.377-403.&lt;/ref&gt;.

== Ukukhamba kwegazi emzimbeni ==
Ama-Arteries

Kumisipha ekhambisa igazi elizele i-oksijini lisuka ehliziyweni bese alikhambe lisuke ehliziyweni likhambe umzimba woke&lt;ref&gt;Tucker, W.D., Arora, Y. and Mahajan, K., 2017. Anatomy, blood vessels.&lt;/ref&gt;.

Amaveyini

Kumithambo ephatha igazi eliphelelwe yi-oksijini emzimbeni ilibuyisele ehliziyweni ukuthi ihloziyo iyolipompa&lt;ref&gt;Mitchell, R.N. and Schoen, F.J., 2010. Blood vessels. ''Robbins and Cotran: Pathologic Basis of Disease.(8th edition) Saunders Elsevier, Philadelphia, US'', pp.516-17.&lt;/ref&gt;.

Amakhaphilari

Kumithambo emincani eyamukela esenyameni eyamukela I-oksijini nemisoco.

Isiphetho

Ingazi ziqakathekile emaphilweni wabantu ngombana umuntu angeze aphila ngaphandle kwegazi. Igazi ngilo elenza bona umuntu aphile kuhle, likusuka ehliziyweni likhambe umzimba woke bese likhambisa i-oksijini ngama atheri bese liphinde libuye ngomsipha wamaveyini sele linganayo i-oksijini libuyele ehliziyweni.</text>
      <sha1>c9htq854cgbkf8jssj9ji3pjidymbbp</sha1>
    </revision>
    <revision>
      <id>2799</id>
      <parentid>2798</parentid>
      <timestamp>2025-05-06T12:35:01Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2799</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2589" sha1="9q7yhv6jbr827t8o019gfocsmg4eaxr" xml:space="preserve">== Iingazi ==
'''Igazi''' kumamanzi abovu akhamba umzimba woke ngaphakathi komuntu. Kuyinto eqakatheke khulu eyenza bona umuntu akghone ukuphila. Ngaphandle kwegazi akekho umuntu ongakghona ukuphila. [[Ihliziyo]] limpompa igazi elizele i-oksijini  lisuke ehliziyweni bese likhambe umzimba woke. Igazi lenza bona [[umzimba]] usebenze kuhle. Lokha nawunganagazi kuhle nofana igazi lakho lingakhambi kuhle emzimbeni kungab namagula athileko ongawathola nawumumuntu&lt;ref&gt;Scudellari, M., 2015. Blood to blood. ''Nature'', ''517''(7535), p.426.&lt;/ref&gt;.

== Izinto ezitholakala ngaphakathi kwegazi ==
Iplazima

Le kuyungcenye yegazi emamanzi eyanza amaphesende ama-55. Ingcenye le iphethe amanzi, itswayi, iswigiri, amafutha Kanye nama phrotheyini.

Amaseli abovu wegazi

Wona Sebenza ukuthwala i-oksijini esuka emaphaphini uyise emzimbeni phezu kwesikhumba nofana enyameni. Amaseli lawa anephrotheyini ebizwa bona yi- haemoglobin, ekungiyo eyenza bona igazi libe nombala obovu&lt;ref&gt;Litvinov, R.I. and Weisel, J.W., 2017. Role of red blood cells in haemostasis and thrombosis. ''ISBT science series'', ''12''(1), pp.176-183.&lt;/ref&gt;.

Amaseli amhlophe wegazi

Ngelimi lesingisi abizwa bona ma- luecytes ngiwo asiza amasotja womzimba bona akghone ukulwisana namagulo&lt;ref&gt;Nicholson, L.B., 2016. The immune system. ''Essays in biochemistry'', ''60''(3), pp.275-301.&lt;/ref&gt;.

Amaplatileti

Awanabumbeko begodu mancani kodwana adlala indima ekulu ekwenzeni bona igazi likghone ukwenza amatlothi&lt;ref&gt;Fogelson, A.L. and Neeves, K.B., 2015. Fluid mechanics of blood clot formation. ''Annual review of fluid mechanics'', ''47''(1), pp.377-403.&lt;/ref&gt;.

== Ukukhamba kwegazi emzimbeni ==
Ama-Arteries

Kumisipha ekhambisa igazi elizele i-oksijini lisuka ehliziyweni bese alikhambe lisuke ehliziyweni likhambe umzimba woke&lt;ref&gt;Tucker, W.D., Arora, Y. and Mahajan, K., 2017. Anatomy, blood vessels.&lt;/ref&gt;.

Amaveyini

Kumithambo ephatha igazi eliphelelwe yi-oksijini emzimbeni ilibuyisele ehliziyweni ukuthi ihloziyo iyolipompa&lt;ref&gt;Mitchell, R.N. and Schoen, F.J., 2010. Blood vessels. ''Robbins and Cotran: Pathologic Basis of Disease.(8th edition) Saunders Elsevier, Philadelphia, US'', pp.516-17.&lt;/ref&gt;.

Amakhaphilari

Kumithambo emincani eyamukela esenyameni eyamukela I-oksijini nemisoco.

Isiphetho

Ingazi ziqakathekile emaphilweni wabantu ngombana umuntu angeze aphila ngaphandle kwegazi. Igazi ngilo elenza bona umuntu aphile kuhle, likusuka ehliziyweni likhambe umzimba woke bese likhambisa i-oksijini ngama atheri bese liphinde libuye ngomsipha wamaveyini sele linganayo i-oksijini libuyele ehliziyweni.</text>
      <sha1>9q7yhv6jbr827t8o019gfocsmg4eaxr</sha1>
    </revision>
    <revision>
      <id>3424</id>
      <parentid>2799</parentid>
      <timestamp>2025-07-12T14:15:25Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3424</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2570" sha1="5zibwc3hocwvghbyszmc7urt256qopa" xml:space="preserve">'''Igazi''' kumamanzi abovu akhamba umzimba woke ngaphakathi komuntu. Kuyinto eqakatheke khulu eyenza bona umuntu akghone ukuphila. Ngaphandle kwegazi akekho umuntu ongakghona ukuphila. [[Ihliziyo]] limpompa igazi elizele i-oksijini  lisuke ehliziyweni bese likhambe umzimba woke. Igazi lenza bona [[umzimba]] usebenze kuhle. Lokha nawunganagazi kuhle nofana igazi lakho lingakhambi kuhle emzimbeni kungab namagula athileko ongawathola nawumumuntu.&lt;ref&gt;Scudellari, M., 2015. Blood to blood. ''Nature'', ''517''(7535), p.426.&lt;/ref&gt;

=== Izinto ezitholakala ngaphakathi kwegazi ===
Iplazima,Le kuyungcenye yegazi emamanzi eyanza amaphesende ama-55. Ingcenye le iphethe amanzi, itswayi, iswigiri, amafutha Kanye nama phrotheyini.Amaseli abovu wegazi,wona Sebenza ukuthwala i-oksijini esuka emaphaphini uyise emzimbeni phezu kwesikhumba nofana enyameni. Amaseli lawa anephrotheyini ebizwa bona yi- haemoglobin, ekungiyo eyenza bona igazi libe nombala obovu.&lt;ref&gt;Litvinov, R.I. and Weisel, J.W., 2017. Role of red blood cells in haemostasis and thrombosis. ''ISBT science series'', ''12''(1), pp.176-183.&lt;/ref&gt;Amaseli amhlophe wegazi,ngelimi lesingisi abizwa bona ma- luecytes ngiwo asiza amasotja womzimba bona akghone ukulwisana namagulo.&lt;ref&gt;Nicholson, L.B., 2016. The immune system. ''Essays in biochemistry'', ''60''(3), pp.275-301.&lt;/ref&gt;Amaplatileti, awanabumbeko begodu mancani kodwana adlala indima ekulu ekwenzeni bona igazi likghone ukwenza amatlothi.&lt;ref&gt;Fogelson, A.L. and Neeves, K.B., 2015. Fluid mechanics of blood clot formation. ''Annual review of fluid mechanics'', ''47''(1), pp.377-403.&lt;/ref&gt;

=== Ukukhamba kwegazi emzimbeni ===
Ama-Arteries

Kumisipha ekhambisa igazi elizele i-oksijini lisuka ehliziyweni bese alikhambe lisuke ehliziyweni likhambe umzimba woke.&lt;ref&gt;Tucker, W.D., Arora, Y. and Mahajan, K., 2017. Anatomy, blood vessels.&lt;/ref&gt;Amaveyini, kumithambo ephatha igazi eliphelelwe yi-oksijini emzimbeni ilibuyisele ehliziyweni ukuthi ihloziyo iyolipompa.&lt;ref&gt;Mitchell, R.N. and Schoen, F.J., 2010. Blood vessels. ''Robbins and Cotran: Pathologic Basis of Disease.(8th edition) Saunders Elsevier, Philadelphia, US'', pp.516-17.&lt;/ref&gt;Amakhaphilari, kumithambo emincani eyamukela esenyameni eyamukela I-oksijini nemisoco. Ingazi ziqakathekile emaphilweni wabantu ngombana umuntu angeze aphila ngaphandle kwegazi. Igazi ngilo elenza bona umuntu aphile kuhle, likusuka ehliziyweni likhambe umzimba woke bese likhambisa i-oksijini ngama atheri bese liphinde libuye ngomsipha wamaveyini sele linganayo i-oksijini libuyele ehliziyweni.

== Iinkomba ==</text>
      <sha1>5zibwc3hocwvghbyszmc7urt256qopa</sha1>
    </revision>
    <revision>
      <id>3425</id>
      <parentid>3424</parentid>
      <timestamp>2025-07-12T14:17:16Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3425</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2570" sha1="7y692pq4bd39ebomykwxab7upuj26c2" xml:space="preserve">'''Igazi''' kumamanzi abovu akhamba umzimba woke ngaphakathi komuntu. Kuyinto eqakatheke khulu eyenza bona umuntu akghone ukuphila. Ngaphandle kwegazi akekho umuntu ongakghona ukuphila. [[Ihliziyo]] limpompa igazi elizele i-oksijini  lisuke ehliziyweni bese likhambe umzimba woke. Igazi lenza bona [[umzimba]] usebenze kuhle. Lokha nawunganagazi kuhle nofana igazi lakho lingakhambi kuhle emzimbeni kungab namagula athileko ongawathola nawumumuntu.&lt;ref&gt;Scudellari, M., 2015. Blood to blood. ''Nature'', ''517''(7535), p.426.&lt;/ref&gt;

=== Izinto ezitholakala ngaphakathi kwegazi ===
Iplazima,Le kuyungcenye yegazi emamanzi eyanza amaphesende ama-55. Ingcenye le iphethe amanzi, itswayi, iswigiri, amafutha Kanye nama phrotheyini.Amaseli abovu wegazi,wona Sebenza ukuthwala i-oksijini esuka emaphaphini uyise emzimbeni phezu kwesikhumba nofana enyameni. Amaseli lawa anephrotheyini ebizwa bona yi- haemoglobin, ekungiyo eyenza bona igazi libe nombala obovu.&lt;ref&gt;Litvinov, R.I. and Weisel, J.W., 2017. Role of red blood cells in haemostasis and thrombosis. ''ISBT science series'', ''12''(1), pp.176-183.&lt;/ref&gt;Amaseli amhlophe wegazi,ngelimi lesingisi abizwa bona ma- luecytes ngiwo asiza amasotja womzimba bona akghone ukulwisana namagulo.&lt;ref&gt;Nicholson, L.B., 2016. The immune system. ''Essays in biochemistry'', ''60''(3), pp.275-301.&lt;/ref&gt;Amaplatileti, awanabumbeko begodu mancani kodwana adlala indima ekulu ekwenzeni bona igazi likghone ukwenza amatlothi.&lt;ref&gt;Fogelson, A.L. and Neeves, K.B., 2015. Fluid mechanics of blood clot formation. ''Annual review of fluid mechanics'', ''47''(1), pp.377-403.&lt;/ref&gt;

=== Ukukhamba kwegazi emzimbeni ===
Ama-Arteries, kumisipha ekhambisa igazi elizele i-oksijini lisuka ehliziyweni bese alikhambe lisuke ehliziyweni likhambe umzimba woke.&lt;ref&gt;Tucker, W.D., Arora, Y. and Mahajan, K., 2017. Anatomy, blood vessels.&lt;/ref&gt;Amaveyini, kumithambo ephatha igazi eliphelelwe yi-oksijini emzimbeni ilibuyisele ehliziyweni ukuthi ihloziyo iyolipompa.&lt;ref&gt;Mitchell, R.N. and Schoen, F.J., 2010. Blood vessels. ''Robbins and Cotran: Pathologic Basis of Disease.(8th edition) Saunders Elsevier, Philadelphia, US'', pp.516-17.&lt;/ref&gt;Amakhaphilari, kumithambo emincani eyamukela esenyameni eyamukela I-oksijini nemisoco. Ingazi ziqakathekile emaphilweni wabantu ngombana umuntu angeze aphila ngaphandle kwegazi. Igazi ngilo elenza bona umuntu aphile kuhle, likusuka ehliziyweni likhambe umzimba woke bese likhambisa i-oksijini ngama atheri bese liphinde libuye ngomsipha wamaveyini sele linganayo i-oksijini libuyele ehliziyweni.

== Iinkomba ==</text>
      <sha1>7y692pq4bd39ebomykwxab7upuj26c2</sha1>
    </revision>
    <revision>
      <id>3426</id>
      <parentid>3425</parentid>
      <timestamp>2025-07-12T14:18:47Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3426</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2572" sha1="631yf9yoq3h3bmokksyk66syixpk6o5" xml:space="preserve">'''Igazi''' kumamanzi abovu akhamba umzimba woke ngaphakathi komuntu. Kuyinto eqakatheke khulu eyenza bona umuntu akghone ukuphila. Ngaphandle kwegazi akekho umuntu ongakghona ukuphila. [[Ihliziyo]] limpompa igazi elizele i-oksijini lisuke ehliziyweni bese likhambe umzimba woke. Igazi lenza bona [[umzimba]] usebenze kuhle. Lokha nawunganagazi kuhle nofana igazi lakho lingakhambi kuhle emzimbeni kungab namagula athileko ongawathola nawumumuntu.&lt;ref&gt;Scudellari, M., 2015. Blood to blood. ''Nature'', ''517''(7535), p.426.&lt;/ref&gt;

=== Izinto ezitholakala ngaphakathi kwegazi ===
Iplazima, Le kuyungcenye yegazi emamanzi eyanza amaphesende ama-55. Ingcenye le iphethe amanzi, itswayi, iswigiri, amafutha Kanye nama phrotheyini.Amaseli abovu wegazi, wona Sebenza ukuthwala i-oksijini esuka emaphaphini uyise emzimbeni phezu kwesikhumba nofana enyameni. Amaseli lawa anephrotheyini ebizwa bona yi- haemoglobin, ekungiyo eyenza bona igazi libe nombala obovu.&lt;ref&gt;Litvinov, R.I. and Weisel, J.W., 2017. Role of red blood cells in haemostasis and thrombosis. ''ISBT science series'', ''12''(1), pp.176-183.&lt;/ref&gt;Amaseli amhlophe wegazi, ngelimi lesingisi abizwa bona ma- luecytes ngiwo asiza amasotja womzimba bona akghone ukulwisana namagulo.&lt;ref&gt;Nicholson, L.B., 2016. The immune system. ''Essays in biochemistry'', ''60''(3), pp.275-301.&lt;/ref&gt;Amaplatileti, awanabumbeko begodu mancani kodwana adlala indima ekulu ekwenzeni bona igazi likghone ukwenza amatlothi.&lt;ref&gt;Fogelson, A.L. and Neeves, K.B., 2015. Fluid mechanics of blood clot formation. ''Annual review of fluid mechanics'', ''47''(1), pp.377-403.&lt;/ref&gt;

=== Ukukhamba kwegazi emzimbeni ===
Ama-Arteries, kumisipha ekhambisa igazi elizele i-oksijini lisuka ehliziyweni bese alikhambe lisuke ehliziyweni likhambe umzimba woke.&lt;ref&gt;Tucker, W.D., Arora, Y. and Mahajan, K., 2017. Anatomy, blood vessels.&lt;/ref&gt;Amaveyini, kumithambo ephatha igazi eliphelelwe yi-oksijini emzimbeni ilibuyisele ehliziyweni ukuthi ihloziyo iyolipompa.&lt;ref&gt;Mitchell, R.N. and Schoen, F.J., 2010. Blood vessels. ''Robbins and Cotran: Pathologic Basis of Disease.(8th edition) Saunders Elsevier, Philadelphia, US'', pp.516-17.&lt;/ref&gt;Amakhaphilari, kumithambo emincani eyamukela esenyameni eyamukela I-oksijini nemisoco. Ingazi ziqakathekile emaphilweni wabantu ngombana umuntu angeze aphila ngaphandle kwegazi. Igazi ngilo elenza bona umuntu aphile kuhle, likusuka ehliziyweni likhambe umzimba woke bese likhambisa i-oksijini ngama atheri bese liphinde libuye ngomsipha wamaveyini sele linganayo i-oksijini libuyele ehliziyweni.

== Iinkomba ==</text>
      <sha1>631yf9yoq3h3bmokksyk66syixpk6o5</sha1>
    </revision>
    <revision>
      <id>5704</id>
      <parentid>3426</parentid>
      <timestamp>2025-09-07T11:35:07Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5704</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2641" sha1="52gusnsbgtpnillxu2t7q6g78intfy0" xml:space="preserve">[[Isimumathi:Blood Test (15575812743).jpg|thumb|Umuno ophuma igazi]]
'''Igazi''' kumamanzi abovu akhamba umzimba woke ngaphakathi komuntu. Kuyinto eqakatheke khulu eyenza bona umuntu akghone ukuphila. Ngaphandle kwegazi akekho umuntu ongakghona ukuphila. [[Ihliziyo]] limpompa igazi elizele i-oksijini lisuke ehliziyweni bese likhambe umzimba woke. Igazi lenza bona [[umzimba]] usebenze kuhle. Lokha nawunganagazi kuhle nofana igazi lakho lingakhambi kuhle emzimbeni kungab namagula athileko ongawathola nawumumuntu.&lt;ref&gt;Scudellari, M., 2015. Blood to blood. ''Nature'', ''517''(7535), p.426.&lt;/ref&gt;

=== Izinto ezitholakala ngaphakathi kwegazi ===
Iplazima, Le kuyungcenye yegazi emamanzi eyanza amaphesende ama-55. Ingcenye le iphethe amanzi, itswayi, iswigiri, amafutha Kanye nama phrotheyini.Amaseli abovu wegazi, wona Sebenza ukuthwala i-oksijini esuka emaphaphini uyise emzimbeni phezu kwesikhumba nofana enyameni. Amaseli lawa anephrotheyini ebizwa bona yi- haemoglobin, ekungiyo eyenza bona igazi libe nombala obovu.&lt;ref&gt;Litvinov, R.I. and Weisel, J.W., 2017. Role of red blood cells in haemostasis and thrombosis. ''ISBT science series'', ''12''(1), pp.176-183.&lt;/ref&gt;Amaseli amhlophe wegazi, ngelimi lesingisi abizwa bona ma- luecytes ngiwo asiza amasotja womzimba bona akghone ukulwisana namagulo.&lt;ref&gt;Nicholson, L.B., 2016. The immune system. ''Essays in biochemistry'', ''60''(3), pp.275-301.&lt;/ref&gt;Amaplatileti, awanabumbeko begodu mancani kodwana adlala indima ekulu ekwenzeni bona igazi likghone ukwenza amatlothi.&lt;ref&gt;Fogelson, A.L. and Neeves, K.B., 2015. Fluid mechanics of blood clot formation. ''Annual review of fluid mechanics'', ''47''(1), pp.377-403.&lt;/ref&gt;

=== Ukukhamba kwegazi emzimbeni ===
Ama-Arteries, kumisipha ekhambisa igazi elizele i-oksijini lisuka ehliziyweni bese alikhambe lisuke ehliziyweni likhambe umzimba woke.&lt;ref&gt;Tucker, W.D., Arora, Y. and Mahajan, K., 2017. Anatomy, blood vessels.&lt;/ref&gt;Amaveyini, kumithambo ephatha igazi eliphelelwe yi-oksijini emzimbeni ilibuyisele ehliziyweni ukuthi ihloziyo iyolipompa.&lt;ref&gt;Mitchell, R.N. and Schoen, F.J., 2010. Blood vessels. ''Robbins and Cotran: Pathologic Basis of Disease.(8th edition) Saunders Elsevier, Philadelphia, US'', pp.516-17.&lt;/ref&gt;Amakhaphilari, kumithambo emincani eyamukela esenyameni eyamukela I-oksijini nemisoco. Ingazi ziqakathekile emaphilweni wabantu ngombana umuntu angeze aphila ngaphandle kwegazi. Igazi ngilo elenza bona umuntu aphile kuhle, likusuka ehliziyweni likhambe umzimba woke bese likhambisa i-oksijini ngama atheri bese liphinde libuye ngomsipha wamaveyini sele linganayo i-oksijini libuyele ehliziyweni.

== Iinkomba ==</text>
      <sha1>52gusnsbgtpnillxu2t7q6g78intfy0</sha1>
    </revision>
    <revision>
      <id>5705</id>
      <parentid>5704</parentid>
      <timestamp>2025-09-07T11:36:31Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>5705</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2681" sha1="6qnjj2qzum3b679oj3r3xd7uzehh4na" xml:space="preserve">[[Isimumathi:Blood Test (15575812743).jpg|thumb|Umuno ophuma igazi]]
'''Igazi''' kumamanzi abovu akhamba umzimba woke ngaphakathi komuntu. Kuyinto eqakatheke khulu eyenza bona umuntu akghone ukuphila. Ngaphandle kwegazi akekho umuntu ongakghona ukuphila. [[Ihliziyo]] limpompa igazi elizele i-oksijini lisuke ehliziyweni bese likhambe umzimba woke. Igazi lenza bona [[umzimba]] usebenze kuhle. Lokha nawunganagazi kuhle nofana igazi lakho lingakhambi kuhle emzimbeni kungab namagula athileko ongawathola nawumumuntu.&lt;ref&gt;Scudellari, M., 2015. Blood to blood. ''Nature'', ''517''(7535), p.426.&lt;/ref&gt;

=== Izinto ezitholakala ngaphakathi kwegazi ===
Iplazima, Le kuyungcenye yegazi emamanzi eyanza amaphesende ama-55. Ingcenye le iphethe amanzi, itswayi, iswigiri, amafutha Kanye nama phrotheyini.Amaseli abovu wegazi, wona Sebenza ukuthwala i-oksijini esuka emaphaphini uyise emzimbeni phezu kwesikhumba nofana enyameni. Amaseli lawa anephrotheyini ebizwa bona yi- haemoglobin, ekungiyo eyenza bona igazi libe nombala obovu.&lt;ref&gt;Litvinov, R.I. and Weisel, J.W., 2017. Role of red blood cells in haemostasis and thrombosis. ''ISBT science series'', ''12''(1), pp.176-183.&lt;/ref&gt;Amaseli amhlophe wegazi, ngelimi lesingisi abizwa bona ma- luecytes ngiwo asiza amasotja womzimba bona akghone ukulwisana namagulo.&lt;ref&gt;Nicholson, L.B., 2016. The immune system. ''Essays in biochemistry'', ''60''(3), pp.275-301.&lt;/ref&gt;Amaplatileti, awanabumbeko begodu mancani kodwana adlala indima ekulu ekwenzeni bona igazi likghone ukwenza amatlothi.&lt;ref&gt;Fogelson, A.L. and Neeves, K.B., 2015. Fluid mechanics of blood clot formation. ''Annual review of fluid mechanics'', ''47''(1), pp.377-403.&lt;/ref&gt;

=== Ukukhamba kwegazi emzimbeni ===
Ama-Arteries, kumisipha ekhambisa igazi elizele i-oksijini lisuka ehliziyweni bese alikhambe lisuke ehliziyweni likhambe umzimba woke.&lt;ref&gt;Tucker, W.D., Arora, Y. and Mahajan, K., 2017. Anatomy, blood vessels.&lt;/ref&gt;Amaveyini, kumithambo ephatha igazi eliphelelwe yi-oksijini emzimbeni ilibuyisele ehliziyweni ukuthi ihloziyo iyolipompa.&lt;ref&gt;Mitchell, R.N. and Schoen, F.J., 2010. Blood vessels. ''Robbins and Cotran: Pathologic Basis of Disease.(8th edition) Saunders Elsevier, Philadelphia, US'', pp.516-17.&lt;/ref&gt;Amakhaphilari, kumithambo emincani eyamukela esenyameni eyamukela I-oksijini nemisoco. Ingazi ziqakathekile emaphilweni wabantu ngombana umuntu angeze aphila ngaphandle kwegazi. Igazi ngilo elenza bona umuntu aphile kuhle, likusuka ehliziyweni likhambe umzimba woke bese likhambisa i-oksijini ngama atheri bese liphinde libuye ngomsipha wamaveyini sele linganayo i-oksijini libuyele ehliziyweni.

== Iinkomba ==
[[category:igazi]]
[[category:umzimba]]</text>
      <sha1>6qnjj2qzum3b679oj3r3xd7uzehh4na</sha1>
    </revision>
  </page>
  <page>
    <title>Iinkolodo</title>
    <ns>0</ns>
    <id>508</id>
    <revision>
      <id>2537</id>
      <timestamp>2025-03-19T11:18:24Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;sikolodo kukulokha uboleka inani elithileko lemali emuntwini nofana ebulungelweni lemali bese uzibophe bona uzoyibuyisa nini begodu bunjani. Esikhathini esiphila kiso ukwenza isikolodo sele kuyinto ejwayelekileko begodu kuyindlela yokuphila&lt;ref&gt;Debt: What It Is, How It Works, Types, and Ways to Pay Back&lt;/ref&gt;.    == Imihlobo yeenkolodo ==  === Isikolodo seentolo === Isikolodo seentolo ngilesi osenza lokha nawenza ikharada lesitolo esithileko bese uthatha ngalo izambatho...&quot;</comment>
      <origin>2537</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3832" sha1="dfls2dwd8oacsph9zk6huj00k4rbgwc" xml:space="preserve">sikolodo kukulokha uboleka inani elithileko lemali emuntwini nofana ebulungelweni lemali bese uzibophe bona uzoyibuyisa nini begodu bunjani. Esikhathini esiphila kiso ukwenza isikolodo sele kuyinto ejwayelekileko begodu kuyindlela yokuphila&lt;ref&gt;Debt: What It Is, How It Works, Types, and Ways to Pay Back&lt;/ref&gt;.  

== Imihlobo yeenkolodo ==

=== Isikolodo seentolo ===
Isikolodo seentolo ngilesi osenza lokha nawenza ikharada lesitolo esithileko bese uthatha ngalo izambatho ngesikolodo bese ubhadele kancani kancani imali oyikolodako njalo ngenyanga. Nawubhadela kuhle eentolo lezi bakukhuphulela Amandla wokuthuthenga okutjho bona bakhuphula inani lesikolodo ongasenza lokha ngokuthenga izambatho isikolodo&lt;ref&gt;https://legaladvice.org.za/what-happens-if-you-don-t-pay-your-clothing-account-in-south-africa/&lt;/ref&gt;.

=== Isikolodo sepahla ===
Lokha nawufuna ukuthenga ipahla yangendlini unganamali yokuthenga ngasikhathi sinye, uyakghona ukupha I diphozidi bese imali eseleko uyikhiphe kancani kancani ngenyanga. Isilokodo lesi basifaka amakonyana ngombana bakwenzele umusa bokuthi ukghone ukubhadela ngengcezu. Okumbi ngesikolodo lesi kukuthi lokha nawubhalelwa kubhadela kuhle iphahla oyithetheko abantu besitolo leso bayabuya bazokuthatha ipahla yabo.

=== Isikolodo sebulungelweni lemali ===
Ebulungelweni lemali ukghona ukwenza silokodo semali oyifunako ukuya ngokokuthi wena ukghola imali engangani lapho usebenza khona.Lokha nawenza isikolodo lesi kubanephepha lesivumelwano olitlikitlako elitjho bona uzokubhadela njani. Ungenza isikolodo semali ufuna ukwakha indlu, ufuna ukuthenga imodere, ufuna ukuyokubhadela iindleko zokufunda, nokwenza okhunye okuqakathekileko. Ebulungelweni lemali, imali obakoloda yona ugcina sele uyibuyisela nakonyana ngombana kibo ukuboleka umuntu imali kuyirhwebo&lt;ref&gt;Hollander, S. and Verriest, A., 2016. Bridging the gap: the design of bank loan contracts and distance. ''Journal of Financial Economics'', ''119''(2), pp.399-419.&lt;/ref&gt;.

== Ubuhle bokwenza isikolodo ==
Isikolodo siyakghona ukukulekelela ukghine ukufeza iindingo zakho msinya nanyana unganamali. Isikolodo singakukhupha emrarweni wemali oqalana nawo lokha nawufuna ukwenza into. Isibonelo umuntu angaboleka imali ebulungelweni lemali ukuyokubhadela ifundo yamaziko aphezulu ukuthi akghone ukuthola iziqu zakhe&lt;ref&gt;Pros and cons of debt - Economics Help&lt;/ref&gt;. 

== Ubumbi bokwenza isikolodo ==
Lokha nawenza isikolodo ungangcina sele ubhadela imali edlula leyo gade uyibolekile. Ebulungelweni lemali bafaka amakonyana phezu kwemali leyo oyibolekileko ugcine sele ubhadala imali enengi&lt;ref&gt;Blanchard, O., 2019. Public debt and low interest rates. ''American Economic Review'', ''109''(4), pp.1197-1229.&lt;/ref&gt;. Abanye bagcina sele benza iiinkolodo ezinengi khulu bese bahlulwe kuzibhadela bazithole sele banegama elimbi lokungabhadeli iinkolodo.

Lokha nawubuyisela imali oyiboleke ebulungelweni lemali ungagcina sele uhlala unganamali ungakghoni nokondla umndeni wakho kuhle nangebe unganabo ubuhlakani bokusebenzisa imali.

Ubumbi bokuboleka imali kukuthi lokha nawuhlulwa kusibhadela ngesikhathi isikolodo ungavela njengomuntu ongakathembi bese bakufake encwadini enzima  ugcine sele ungasakghoni nokuboleka imali kwezinye indawo ngombana kuzokuvela kizo zoke indawo bona wena umumuntu ongakghoni ukubhadel isikolodo&lt;ref&gt;Opwaka, R.P. and Wanyoike, D., An Assessment of the Attitudes of Blacklisted Bank Clients on Their Bank Use: A Case of Blacklisted National Bank Clients in Nakuru.

Vancouver&lt;/ref&gt;.

== Isiphetho ==
Isikolodo kuyinto engamsiza omunye umuntu. Kufanele lokha anwenza isikolodo usenze wazi bona uzosibhadela njani begodu uqinisekeise bona ukghona ukuphila nasele ubhadela isikolodo. Nawenze isikolodo kufanele ubalekele ukuba negama elimbi lokungabhadeli ngokuthi ubhadele kuhle ngesikhathi isikolodo sakho.</text>
      <sha1>dfls2dwd8oacsph9zk6huj00k4rbgwc</sha1>
    </revision>
    <revision>
      <id>2538</id>
      <parentid>2537</parentid>
      <timestamp>2025-03-19T11:20:28Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2538</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3842" sha1="7ds4znj5vjod8vumtrxlt599h16y053" xml:space="preserve">sikolodo kukulokha uboleka inani elithileko lemali emuntwini nofana ebulungelweni lemali bese uzibophe bona uzoyibuyisa nini begodu bunjani. Esikhathini esiphila kiso ukwenza isikolodo sele kuyinto ejwayelekileko begodu kuyindlela yokuphila&lt;ref&gt;Debt: What It Is, How It Works, Types, and Ways to Pay Back&lt;/ref&gt;.  

== Imihlobo yeenkolodo ==

=== Isikolodo seentolo ===
Isikolodo seentolo ngilesi osenza lokha nawenza ikharada lesitolo esithileko bese uthatha ngalo izambatho ngesikolodo bese ubhadele kancani kancani imali oyikolodako njalo ngenyanga. Nawubhadela kuhle eentolo lezi bakukhuphulela Amandla wokuthuthenga okutjho bona bakhuphula inani lesikolodo ongasenza lokha ngokuthenga izambatho isikolodo&lt;ref&gt;https://legaladvice.org.za/what-happens-if-you-don-t-pay-your-clothing-account-in-south-africa/&lt;/ref&gt;.

=== Isikolodo sepahla ===
Lokha nawufuna ukuthenga ipahla yangendlini unganamali yokuthenga ngasikhathi sinye, uyakghona ukupha I diphozidi bese imali eseleko uyikhiphe kancani kancani ngenyanga. Isilokodo lesi basifaka amakonyana ngombana bakwenzele umusa bokuthi ukghone ukubhadela ngengcezu. Okumbi ngesikolodo lesi kukuthi lokha nawubhalelwa kubhadela kuhle [[ipahla]] oyithetheko abantu besitolo leso bayabuya bazokuthatha ipahla yabo.

=== Isikolodo sebulungelweni lemali ===
Ebulungelweni lemali ukghona ukwenza silokodo semali oyifunako ukuya ngokokuthi wena ukghola [[imali]] engangani lapho usebenza khona.Lokha nawenza isikolodo lesi kubanephepha lesivumelwano olitlikitlako elitjho bona uzokubhadela njani. Ungenza isikolodo semali ufuna ukwakha indlu, ufuna ukuthenga imodere, ufuna ukuyokubhadela iindleko zokufunda, nokwenza okhunye okuqakathekileko. Ebulungelweni lemali, imali obakoloda yona ugcina sele uyibuyisela nakonyana ngombana kibo ukuboleka umuntu imali kuyirhwebo&lt;ref&gt;Hollander, S. and Verriest, A., 2016. Bridging the gap: the design of bank loan contracts and distance. ''Journal of Financial Economics'', ''119''(2), pp.399-419.&lt;/ref&gt;.

== Ubuhle bokwenza isikolodo ==
Isikolodo siyakghona ukukulekelela ukghine ukufeza iindingo zakho msinya nanyana unganamali. Isikolodo singakukhupha emrarweni wemali oqalana nawo lokha nawufuna ukwenza into. Isibonelo umuntu angaboleka imali ebulungelweni lemali ukuyokubhadela ifundo yamaziko aphezulu ukuthi akghone ukuthola iziqu zakhe&lt;ref&gt;Pros and cons of debt - Economics Help&lt;/ref&gt;. 

== Ubumbi bokwenza isikolodo ==
Lokha nawenza isikolodo ungangcina sele ubhadela imali edlula leyo gade uyibolekile. Ebulungelweni lemali bafaka amakonyana phezu kwemali leyo oyibolekileko ugcine sele ubhadala imali enengi&lt;ref&gt;Blanchard, O., 2019. Public debt and low interest rates. ''American Economic Review'', ''109''(4), pp.1197-1229.&lt;/ref&gt;. Abanye bagcina sele benza iiinkolodo ezinengi khulu bese bahlulwe kuzibhadela bazithole sele banegama elimbi lokungabhadeli iinkolodo.

Lokha nawubuyisela imali oyiboleke ebulungelweni lemali ungagcina sele uhlala unganamali ungakghoni nokondla umndeni wakho kuhle nangebe unganabo ubuhlakani bokusebenzisa imali.

Ubumbi bokuboleka imali kukuthi lokha nawuhlulwa kusibhadela ngesikhathi isikolodo ungavela njengomuntu ongakathembeki bese bakufake encwadini enzima  ugcine sele ungasakghoni nokuboleka imali kwezinye indawo ngombana kuzokuvela kizo zoke indawo bona wena umumuntu ongakghoni ukubhadela isikolodo&lt;ref&gt;Opwaka, R.P. and Wanyoike, D., An Assessment of the Attitudes of Blacklisted Bank Clients on Their Bank Use: A Case of Blacklisted National Bank Clients in Nakuru.

Vancouver&lt;/ref&gt;.

== Isiphetho ==
Isikolodo kuyinto engamsiza omunye umuntu. Kufanele lokha anwenza isikolodo usenze wazi bona uzosibhadela njani begodu uqinisekeise bona ukghona ukuphila nasele ubhadela isikolodo. Nawenze isikolodo kufanele ubalekele ukuba negama elimbi lokungabhadeli ngokuthi ubhadele kuhle ngesikhathi isikolodo sakho.</text>
      <sha1>7ds4znj5vjod8vumtrxlt599h16y053</sha1>
    </revision>
    <revision>
      <id>2980</id>
      <parentid>2538</parentid>
      <timestamp>2025-06-06T20:08:39Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>34ghugf43u</comment>
      <origin>2980</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3929" sha1="6rpbp7wpnihaycbfec07p0duhj6fp0g" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.''' sikolodo kukulokha uboleka inani elithileko lemali emuntwini nofana ebulungelweni lemali bese uzibophe bona uzoyibuyisa nini begodu bunjani. Esikhathini esiphila kiso ukwenza isikolodo sele kuyinto ejwayelekileko begodu kuyindlela yokuphila&lt;ref&gt;Debt: What It Is, How It Works, Types, and Ways to Pay Back&lt;/ref&gt;.  

== Imihlobo yeenkolodo ==

=== Isikolodo seentolo ===
Isikolodo seentolo ngilesi osenza lokha nawenza ikharada lesitolo esithileko bese uthatha ngalo izambatho ngesikolodo bese ubhadele kancani kancani imali oyikolodako njalo ngenyanga. Nawubhadela kuhle eentolo lezi bakukhuphulela Amandla wokuthuthenga okutjho bona bakhuphula inani lesikolodo ongasenza lokha ngokuthenga izambatho isikolodo&lt;ref&gt;https://legaladvice.org.za/what-happens-if-you-don-t-pay-your-clothing-account-in-south-africa/&lt;/ref&gt;.

=== Isikolodo sepahla ===
Lokha nawufuna ukuthenga ipahla yangendlini unganamali yokuthenga ngasikhathi sinye, uyakghona ukupha I diphozidi bese imali eseleko uyikhiphe kancani kancani ngenyanga. Isilokodo lesi basifaka amakonyana ngombana bakwenzele umusa bokuthi ukghone ukubhadela ngengcezu. Okumbi ngesikolodo lesi kukuthi lokha nawubhalelwa kubhadela kuhle [[ipahla]] oyithetheko abantu besitolo leso bayabuya bazokuthatha ipahla yabo.

=== Isikolodo sebulungelweni lemali ===
Ebulungelweni lemali ukghona ukwenza silokodo semali oyifunako ukuya ngokokuthi wena ukghola [[imali]] engangani lapho usebenza khona.Lokha nawenza isikolodo lesi kubanephepha lesivumelwano olitlikitlako elitjho bona uzokubhadela njani. Ungenza isikolodo semali ufuna ukwakha indlu, ufuna ukuthenga imodere, ufuna ukuyokubhadela iindleko zokufunda, nokwenza okhunye okuqakathekileko. Ebulungelweni lemali, imali obakoloda yona ugcina sele uyibuyisela nakonyana ngombana kibo ukuboleka umuntu imali kuyirhwebo&lt;ref&gt;Hollander, S. and Verriest, A., 2016. Bridging the gap: the design of bank loan contracts and distance. ''Journal of Financial Economics'', ''119''(2), pp.399-419.&lt;/ref&gt;.

== Ubuhle bokwenza isikolodo ==
Isikolodo siyakghona ukukulekelela ukghine ukufeza iindingo zakho msinya nanyana unganamali. Isikolodo singakukhupha emrarweni wemali oqalana nawo lokha nawufuna ukwenza into. Isibonelo umuntu angaboleka imali ebulungelweni lemali ukuyokubhadela ifundo yamaziko aphezulu ukuthi akghone ukuthola iziqu zakhe&lt;ref&gt;Pros and cons of debt - Economics Help&lt;/ref&gt;. 

== Ubumbi bokwenza isikolodo ==
Lokha nawenza isikolodo ungangcina sele ubhadela imali edlula leyo gade uyibolekile. Ebulungelweni lemali bafaka amakonyana phezu kwemali leyo oyibolekileko ugcine sele ubhadala imali enengi&lt;ref&gt;Blanchard, O., 2019. Public debt and low interest rates. ''American Economic Review'', ''109''(4), pp.1197-1229.&lt;/ref&gt;. Abanye bagcina sele benza iiinkolodo ezinengi khulu bese bahlulwe kuzibhadela bazithole sele banegama elimbi lokungabhadeli iinkolodo.

Lokha nawubuyisela imali oyiboleke ebulungelweni lemali ungagcina sele uhlala unganamali ungakghoni nokondla umndeni wakho kuhle nangebe unganabo ubuhlakani bokusebenzisa imali.

Ubumbi bokuboleka imali kukuthi lokha nawuhlulwa kusibhadela ngesikhathi isikolodo ungavela njengomuntu ongakathembeki bese bakufake encwadini enzima  ugcine sele ungasakghoni nokuboleka imali kwezinye indawo ngombana kuzokuvela kizo zoke indawo bona wena umumuntu ongakghoni ukubhadela isikolodo&lt;ref&gt;Opwaka, R.P. and Wanyoike, D., An Assessment of the Attitudes of Blacklisted Bank Clients on Their Bank Use: A Case of Blacklisted National Bank Clients in Nakuru.

Vancouver&lt;/ref&gt;.

== Isiphetho ==
Isikolodo kuyinto engamsiza omunye umuntu. Kufanele lokha anwenza isikolodo usenze wazi bona uzosibhadela njani begodu uqinisekeise bona ukghona ukuphila nasele ubhadela isikolodo. Nawenze isikolodo kufanele ubalekele ukuba negama elimbi lokungabhadeli ngokuthi ubhadele kuhle ngesikhathi isikolodo sakho.</text>
      <sha1>6rpbp7wpnihaycbfec07p0duhj6fp0g</sha1>
    </revision>
    <revision>
      <id>3119</id>
      <parentid>2980</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Nqobile69|Nqobile69]]</comment>
      <origin>2538</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3842" sha1="7ds4znj5vjod8vumtrxlt599h16y053" xml:space="preserve">sikolodo kukulokha uboleka inani elithileko lemali emuntwini nofana ebulungelweni lemali bese uzibophe bona uzoyibuyisa nini begodu bunjani. Esikhathini esiphila kiso ukwenza isikolodo sele kuyinto ejwayelekileko begodu kuyindlela yokuphila&lt;ref&gt;Debt: What It Is, How It Works, Types, and Ways to Pay Back&lt;/ref&gt;.  

== Imihlobo yeenkolodo ==

=== Isikolodo seentolo ===
Isikolodo seentolo ngilesi osenza lokha nawenza ikharada lesitolo esithileko bese uthatha ngalo izambatho ngesikolodo bese ubhadele kancani kancani imali oyikolodako njalo ngenyanga. Nawubhadela kuhle eentolo lezi bakukhuphulela Amandla wokuthuthenga okutjho bona bakhuphula inani lesikolodo ongasenza lokha ngokuthenga izambatho isikolodo&lt;ref&gt;https://legaladvice.org.za/what-happens-if-you-don-t-pay-your-clothing-account-in-south-africa/&lt;/ref&gt;.

=== Isikolodo sepahla ===
Lokha nawufuna ukuthenga ipahla yangendlini unganamali yokuthenga ngasikhathi sinye, uyakghona ukupha I diphozidi bese imali eseleko uyikhiphe kancani kancani ngenyanga. Isilokodo lesi basifaka amakonyana ngombana bakwenzele umusa bokuthi ukghone ukubhadela ngengcezu. Okumbi ngesikolodo lesi kukuthi lokha nawubhalelwa kubhadela kuhle [[ipahla]] oyithetheko abantu besitolo leso bayabuya bazokuthatha ipahla yabo.

=== Isikolodo sebulungelweni lemali ===
Ebulungelweni lemali ukghona ukwenza silokodo semali oyifunako ukuya ngokokuthi wena ukghola [[imali]] engangani lapho usebenza khona.Lokha nawenza isikolodo lesi kubanephepha lesivumelwano olitlikitlako elitjho bona uzokubhadela njani. Ungenza isikolodo semali ufuna ukwakha indlu, ufuna ukuthenga imodere, ufuna ukuyokubhadela iindleko zokufunda, nokwenza okhunye okuqakathekileko. Ebulungelweni lemali, imali obakoloda yona ugcina sele uyibuyisela nakonyana ngombana kibo ukuboleka umuntu imali kuyirhwebo&lt;ref&gt;Hollander, S. and Verriest, A., 2016. Bridging the gap: the design of bank loan contracts and distance. ''Journal of Financial Economics'', ''119''(2), pp.399-419.&lt;/ref&gt;.

== Ubuhle bokwenza isikolodo ==
Isikolodo siyakghona ukukulekelela ukghine ukufeza iindingo zakho msinya nanyana unganamali. Isikolodo singakukhupha emrarweni wemali oqalana nawo lokha nawufuna ukwenza into. Isibonelo umuntu angaboleka imali ebulungelweni lemali ukuyokubhadela ifundo yamaziko aphezulu ukuthi akghone ukuthola iziqu zakhe&lt;ref&gt;Pros and cons of debt - Economics Help&lt;/ref&gt;. 

== Ubumbi bokwenza isikolodo ==
Lokha nawenza isikolodo ungangcina sele ubhadela imali edlula leyo gade uyibolekile. Ebulungelweni lemali bafaka amakonyana phezu kwemali leyo oyibolekileko ugcine sele ubhadala imali enengi&lt;ref&gt;Blanchard, O., 2019. Public debt and low interest rates. ''American Economic Review'', ''109''(4), pp.1197-1229.&lt;/ref&gt;. Abanye bagcina sele benza iiinkolodo ezinengi khulu bese bahlulwe kuzibhadela bazithole sele banegama elimbi lokungabhadeli iinkolodo.

Lokha nawubuyisela imali oyiboleke ebulungelweni lemali ungagcina sele uhlala unganamali ungakghoni nokondla umndeni wakho kuhle nangebe unganabo ubuhlakani bokusebenzisa imali.

Ubumbi bokuboleka imali kukuthi lokha nawuhlulwa kusibhadela ngesikhathi isikolodo ungavela njengomuntu ongakathembeki bese bakufake encwadini enzima  ugcine sele ungasakghoni nokuboleka imali kwezinye indawo ngombana kuzokuvela kizo zoke indawo bona wena umumuntu ongakghoni ukubhadela isikolodo&lt;ref&gt;Opwaka, R.P. and Wanyoike, D., An Assessment of the Attitudes of Blacklisted Bank Clients on Their Bank Use: A Case of Blacklisted National Bank Clients in Nakuru.

Vancouver&lt;/ref&gt;.

== Isiphetho ==
Isikolodo kuyinto engamsiza omunye umuntu. Kufanele lokha anwenza isikolodo usenze wazi bona uzosibhadela njani begodu uqinisekeise bona ukghona ukuphila nasele ubhadela isikolodo. Nawenze isikolodo kufanele ubalekele ukuba negama elimbi lokungabhadeli ngokuthi ubhadele kuhle ngesikhathi isikolodo sakho.</text>
      <sha1>7ds4znj5vjod8vumtrxlt599h16y053</sha1>
    </revision>
    <revision>
      <id>3532</id>
      <parentid>3119</parentid>
      <timestamp>2025-08-04T17:15:42Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3532</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4305" sha1="45drwaxlmys7cswbzmd1lwgrwhmyye7" xml:space="preserve">'''Isikolodo''' kukulokha uboleka inani elithileko lemali emuntwini nofana ebulungelweni lemali bese uzibophe bona uzoyibuyisa nini begodu bunjani. Esikhathini esiphila kiso ukwenza isikolodo sele kuyinto ejwayelekileko begodu kuyindlela yokuphila&lt;ref&gt;Debt: What It Is, How It Works, Types, and Ways to Pay Back&lt;/ref&gt;.  

== Imihlobo yeenkolodo ==

=== Isikolodo seentolo ===
Isikolodo seentolo ngilesi osenza lokha nawenza ikharada lesitolo esithileko bese uthatha ngalo izambatho ngesikolodo bese ubhadele kancani kancani imali oyikolodako njalo ngenyanga. Nawubhadela kuhle eentolo lezi bakukhuphulela Amandla wokuthuthenga okutjho bona bakhuphula inani lesikolodo ongasenza lokha ngokuthenga izambatho isikolodo&lt;ref&gt;https://legaladvice.org.za/what-happens-if-you-don-t-pay-your-clothing-account-in-south-africa/&lt;/ref&gt;.Isikolodo sepahla sigenziwa ngunynana ngubani umuntu ongakghona ukuthi abuyisele imali yepahlal ayithetheko esitolo athenge kiso. Isitolo esinye nesinye siyasivuma bonyana abantu bathenge ipahla ngesikolodo.

=== Isikolodo sepahla ===
Lokha nawufuna ukuthenga ipahla yangendlini unganamali yokuthenga ngasikhathi sinye, uyakghona ukupha I diphozidi bese [[imali]] eseleko uyikhiphe kancani kancani ngenyanga. Isilokodo lesi basifaka amakonyana ngombana bakwenzele umusa bokuthi ukghone ukubhadela ngengcezu. Okumbi ngesikolodo lesi kukuthi lokha nawubhalelwa kubhadela kuhle [[ipahla]] oyithetheko abantu besitolo leso bayabuya bazokuthatha ipahla yabo.

=== Isikolodo sebulungelweni lemali ===
Ebulungelweni lemali ukghona ukwenza silokodo semali oyifunako ukuya ngokokuthi wena ukghola [[imali]] engangani lapho usebenza khona.Lokha nawenza isikolodo lesi kubanephepha lesivumelwano olitlikitlako elitjho bona uzokubhadela njani. Ungenza isikolodo semali ufuna ukwakha indlu, ufuna ukuthenga imodere, ufuna ukuyokubhadela iindleko zokufunda, nokwenza okhunye okuqakathekileko. Ebulungelweni lemali, imali obakoloda yona ugcina sele uyibuyisela nakonyana ngombana kibo ukuboleka umuntu imali kuyirhwebo&lt;ref&gt;Hollander, S. and Verriest, A., 2016. Bridging the gap: the design of bank loan contracts and distance. ''Journal of Financial Economics'', ''119''(2), pp.399-419.&lt;/ref&gt;.

=== Ubuhle bokwenza isikolodo ===
Isikolodo siyakghona ukukulekelela ukghone ukufeza iindingo zakho msinya nanyana unganamali. Isikolodo singakukhupha emrarweni wemali oqalana nawo lokha nawufuna ukwenza into. Isibonelo umuntu angaboleka imali ebulungelweni lemali ukuyokubhadela ifundo yamaziko aphezulu ukuthi akghone ukuthola iziqu zakhe&lt;ref&gt;Pros and cons of debt - Economics Help&lt;/ref&gt;. Abantu bakghona ukwenza iikolodo ukuze kuze bakghone ukuthuthukisa amaphilo wabo bese kuthi sele bacedile ukwenza njalo bese  bavala iinkolodo zabo. Ukwenza isikodo kugenye yeendlela zokulekelela abantu bakghone ukuphila nanyana banganayo imali 

=== Ubumbi bokwenza isikolodo ===
Lokha nawenza isikolodo ungangcina sele ubhadela imali edlula leyo gade uyibolekile. Ebulungelweni lemali bafaka amakonyana phezu kwemali leyo oyibolekileko ugcine sele ubhadala imali enengi&lt;ref&gt;Blanchard, O., 2019. Public debt and low interest rates. ''American Economic Review'', ''109''(4), pp.1197-1229.&lt;/ref&gt;. Abanye bagcina sele benza iiinkolodo ezinengi khulu bese bahlulwe kuzibhadela bazithole sele banegama elimbi lokungabhadeli iinkolodo.Lokha nawubuyisela imali oyiboleke ebulungelweni lemali ungagcina sele uhlala unganamali ungakghoni nokondla umndeni wakho kuhle nangebe unganabo ubuhlakani bokusebenzisa imali.

Ubumbi bokuboleka imali kukuthi lokha nawuhlulwa kusibhadela ngesikhathi isikolodo ungavela njengomuntu ongakathembeki bese bakufake encwadini enzima  ugcine sele ungasakghoni nokuboleka imali kwezinye indawo ngombana kuzokuvela kizo zoke indawo bona wena umumuntu ongakghoni ukubhadela isikolodo&lt;ref&gt;Opwaka, R.P. and Wanyoike, D., An Assessment of the Attitudes of Blacklisted Bank Clients on Their Bank Use: A Case of Blacklisted National Bank Clients in Nakuru.

Vancouver&lt;/ref&gt;.Isikolodo kuyinto engamsiza omunye umuntu. Kufanele lokha anwenza isikolodo usenze wazi bona uzosibhadela njani begodu uqinisekeise bona ukghona ukuphila nasele ubhadela isikolodo. Nawenze isikolodo kufanele ubalekele ukuba negama elimbi lokungabhadeli ngokuthi ubhadele kuhle ngesikhathi isikolodo sakho.

== Iinkomba ==</text>
      <sha1>45drwaxlmys7cswbzmd1lwgrwhmyye7</sha1>
    </revision>
    <revision>
      <id>3533</id>
      <parentid>3532</parentid>
      <timestamp>2025-08-04T17:16:38Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3533</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4313" sha1="57xj9uxec4uu1ygzeybnl6hoxmchu3t" xml:space="preserve">'''Isikolodo''' kukulokha uboleka inani elithileko lemali emuntwini nofana ebulungelweni lemali bese uzibophe bona uzoyibuyisa nini begodu bunjani. Esikhathini esiphila kiso ukwenza isikolodo sele kuyinto ejwayelekileko begodu kuyindlela yokuphila&lt;ref&gt;Debt: What It Is, How It Works, Types, and Ways to Pay Back&lt;/ref&gt;.  

=== Imihlobo yeenkolodo ===

==== Isikolodo seentolo ====
Isikolodo seentolo ngilesi osenza lokha nawenza ikharada lesitolo esithileko bese uthatha ngalo izambatho ngesikolodo bese ubhadele kancani kancani imali oyikolodako njalo ngenyanga. Nawubhadela kuhle eentolo lezi bakukhuphulela Amandla wokuthuthenga okutjho bona bakhuphula inani lesikolodo ongasenza lokha ngokuthenga izambatho isikolodo&lt;ref&gt;https://legaladvice.org.za/what-happens-if-you-don-t-pay-your-clothing-account-in-south-africa/&lt;/ref&gt;.Isikolodo sepahla sigenziwa ngunynana ngubani umuntu ongakghona ukuthi abuyisele imali yepahlal ayithetheko esitolo athenge kiso. Isitolo esinye nesinye siyasivuma bonyana abantu bathenge ipahla ngesikolodo.

==== Isikolodo sepahla ====
Lokha nawufuna ukuthenga ipahla yangendlini unganamali yokuthenga ngasikhathi sinye, uyakghona ukupha I diphozidi bese [[imali]] eseleko uyikhiphe kancani kancani ngenyanga. Isilokodo lesi basifaka amakonyana ngombana bakwenzele umusa bokuthi ukghone ukubhadela ngengcezu. Okumbi ngesikolodo lesi kukuthi lokha nawubhalelwa kubhadela kuhle [[ipahla]] oyithetheko abantu besitolo leso bayabuya bazokuthatha ipahla yabo.

==== Isikolodo sebulungelweni lemali ====
Ebulungelweni lemali ukghona ukwenza silokodo semali oyifunako ukuya ngokokuthi wena ukghola [[imali]] engangani lapho usebenza khona.Lokha nawenza isikolodo lesi kubanephepha lesivumelwano olitlikitlako elitjho bona uzokubhadela njani. Ungenza isikolodo semali ufuna ukwakha indlu, ufuna ukuthenga imodere, ufuna ukuyokubhadela iindleko zokufunda, nokwenza okhunye okuqakathekileko. Ebulungelweni lemali, imali obakoloda yona ugcina sele uyibuyisela nakonyana ngombana kibo ukuboleka umuntu imali kuyirhwebo&lt;ref&gt;Hollander, S. and Verriest, A., 2016. Bridging the gap: the design of bank loan contracts and distance. ''Journal of Financial Economics'', ''119''(2), pp.399-419.&lt;/ref&gt;.

=== Ubuhle bokwenza isikolodo ===
Isikolodo siyakghona ukukulekelela ukghone ukufeza iindingo zakho msinya nanyana unganamali. Isikolodo singakukhupha emrarweni wemali oqalana nawo lokha nawufuna ukwenza into. Isibonelo umuntu angaboleka imali ebulungelweni lemali ukuyokubhadela ifundo yamaziko aphezulu ukuthi akghone ukuthola iziqu zakhe&lt;ref&gt;Pros and cons of debt - Economics Help&lt;/ref&gt;. Abantu bakghona ukwenza iikolodo ukuze kuze bakghone ukuthuthukisa amaphilo wabo bese kuthi sele bacedile ukwenza njalo bese  bavala iinkolodo zabo. Ukwenza isikodo kugenye yeendlela zokulekelela abantu bakghone ukuphila nanyana banganayo imali 

=== Ubumbi bokwenza isikolodo ===
Lokha nawenza isikolodo ungangcina sele ubhadela imali edlula leyo gade uyibolekile. Ebulungelweni lemali bafaka amakonyana phezu kwemali leyo oyibolekileko ugcine sele ubhadala imali enengi&lt;ref&gt;Blanchard, O., 2019. Public debt and low interest rates. ''American Economic Review'', ''109''(4), pp.1197-1229.&lt;/ref&gt;. Abanye bagcina sele benza iiinkolodo ezinengi khulu bese bahlulwe kuzibhadela bazithole sele banegama elimbi lokungabhadeli iinkolodo.Lokha nawubuyisela imali oyiboleke ebulungelweni lemali ungagcina sele uhlala unganamali ungakghoni nokondla umndeni wakho kuhle nangebe unganabo ubuhlakani bokusebenzisa imali.

Ubumbi bokuboleka imali kukuthi lokha nawuhlulwa kusibhadela ngesikhathi isikolodo ungavela njengomuntu ongakathembeki bese bakufake encwadini enzima  ugcine sele ungasakghoni nokuboleka imali kwezinye indawo ngombana kuzokuvela kizo zoke indawo bona wena umumuntu ongakghoni ukubhadela isikolodo&lt;ref&gt;Opwaka, R.P. and Wanyoike, D., An Assessment of the Attitudes of Blacklisted Bank Clients on Their Bank Use: A Case of Blacklisted National Bank Clients in Nakuru.

Vancouver&lt;/ref&gt;.Isikolodo kuyinto engamsiza omunye umuntu. Kufanele lokha anwenza isikolodo usenze wazi bona uzosibhadela njani begodu uqinisekeise bona ukghona ukuphila nasele ubhadela isikolodo. Nawenze isikolodo kufanele ubalekele ukuba negama elimbi lokungabhadeli ngokuthi ubhadele kuhle ngesikhathi isikolodo sakho.

== Iinkomba ==</text>
      <sha1>57xj9uxec4uu1ygzeybnl6hoxmchu3t</sha1>
    </revision>
    <revision>
      <id>5061</id>
      <parentid>3533</parentid>
      <timestamp>2025-08-07T18:14:32Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>5061</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4386" sha1="9bp8y9t2b9j0klygtbmcevqx31tje35" xml:space="preserve">'''Isikolodo''' kukulokha uboleka inani elithileko lemali emuntwini nofana ebulungelweni lemali bese uzibophe bona uzoyibuyisa nini begodu bunjani. Esikhathini esiphila kiso ukwenza isikolodo sele kuyinto ejwayelekileko begodu kuyindlela yokuphila&lt;ref&gt;Debt: What It Is, How It Works, Types, and Ways to Pay Back&lt;/ref&gt;.  

=== Imihlobo yeenkolodo ===

==== Isikolodo seentolo ====
Isikolodo seentolo ngilesi osenza lokha nawenza ikharada lesitolo esithileko bese uthatha ngalo izambatho ngesikolodo bese ubhadele kancani kancani imali oyikolodako njalo ngenyanga. Nawubhadela kuhle eentolo lezi bakukhuphulela Amandla wokuthuthenga okutjho bona bakhuphula inani lesikolodo ongasenza lokha ngokuthenga izambatho isikolodo&lt;ref&gt;https://legaladvice.org.za/what-happens-if-you-don-t-pay-your-clothing-account-in-south-africa/&lt;/ref&gt;.Isikolodo sepahla sigenziwa ngunynana ngubani umuntu ongakghona ukuthi abuyisele imali yepahlal ayithetheko esitolo athenge kiso. Isitolo esinye nesinye siyasivuma bonyana abantu bathenge ipahla ngesikolodo.

==== Isikolodo sepahla ====
Lokha nawufuna ukuthenga ipahla yangendlini unganamali yokuthenga ngasikhathi sinye, uyakghona ukupha I diphozidi bese [[imali]] eseleko uyikhiphe kancani kancani ngenyanga. Isilokodo lesi basifaka amakonyana ngombana bakwenzele umusa bokuthi ukghone ukubhadela ngengcezu. Okumbi ngesikolodo lesi kukuthi lokha nawubhalelwa kubhadela kuhle [[ipahla]] oyithetheko abantu besitolo leso bayabuya bazokuthatha ipahla yabo.

==== Isikolodo sebulungelweni lemali ====
Ebulungelweni lemali ukghona ukwenza silokodo semali oyifunako ukuya ngokokuthi wena ukghola [[imali]] engangani lapho usebenza khona.Lokha nawenza isikolodo lesi kubanephepha lesivumelwano olitlikitlako elitjho bona uzokubhadela njani. Ungenza isikolodo semali ufuna ukwakha indlu, ufuna ukuthenga imodere, ufuna ukuyokubhadela iindleko zokufunda, nokwenza okhunye okuqakathekileko. Ebulungelweni lemali, imali obakoloda yona ugcina sele uyibuyisela nakonyana ngombana kibo ukuboleka umuntu imali kuyirhwebo&lt;ref&gt;Hollander, S. and Verriest, A., 2016. Bridging the gap: the design of bank loan contracts and distance. ''Journal of Financial Economics'', ''119''(2), pp.399-419.&lt;/ref&gt;.

=== Ubuhle bokwenza isikolodo ===
Isikolodo siyakghona ukukulekelela ukghone ukufeza iindingo zakho msinya nanyana unganamali. Isikolodo singakukhupha emrarweni wemali oqalana nawo lokha nawufuna ukwenza into. Isibonelo umuntu angaboleka imali ebulungelweni lemali ukuyokubhadela ifundo yamaziko aphezulu ukuthi akghone ukuthola iziqu zakhe&lt;ref&gt;Pros and cons of debt - Economics Help&lt;/ref&gt;. Abantu bakghona ukwenza iikolodo ukuze kuze bakghone ukuthuthukisa amaphilo wabo bese kuthi sele bacedile ukwenza njalo bese  bavala iinkolodo zabo. Ukwenza isikodo kugenye yeendlela zokulekelela abantu bakghone ukuphila nanyana banganayo imali 

=== Ubumbi bokwenza isikolodo ===
Lokha nawenza isikolodo ungangcina sele ubhadela imali edlula leyo gade uyibolekile. Ebulungelweni lemali bafaka amakonyana phezu kwemali leyo oyibolekileko ugcine sele ubhadala imali enengi&lt;ref&gt;Blanchard, O., 2019. Public debt and low interest rates. ''American Economic Review'', ''109''(4), pp.1197-1229.&lt;/ref&gt;. Abanye bagcina sele benza iiinkolodo ezinengi khulu bese bahlulwe kuzibhadela bazithole sele banegama elimbi lokungabhadeli iinkolodo.Lokha nawubuyisela imali oyiboleke ebulungelweni lemali ungagcina sele uhlala unganamali ungakghoni nokondla umndeni wakho kuhle nangebe unganabo ubuhlakani bokusebenzisa imali.

Ubumbi bokuboleka imali kukuthi lokha nawuhlulwa kusibhadela ngesikhathi isikolodo ungavela njengomuntu ongakathembeki bese bakufake encwadini enzima  ugcine sele ungasakghoni nokuboleka imali kwezinye indawo ngombana kuzokuvela kizo zoke indawo bona wena umumuntu ongakghoni ukubhadela isikolodo&lt;ref&gt;Opwaka, R.P. and Wanyoike, D., An Assessment of the Attitudes of Blacklisted Bank Clients on Their Bank Use: A Case of Blacklisted National Bank Clients in Nakuru.

Vancouver&lt;/ref&gt;.Isikolodo kuyinto engamsiza omunye umuntu. Kufanele lokha anwenza isikolodo usenze wazi bona uzosibhadela njani begodu uqinisekeise bona ukghona ukuphila nasele ubhadela isikolodo. Nawenze isikolodo kufanele ubalekele ukuba negama elimbi lokungabhadeli ngokuthi ubhadele kuhle ngesikhathi isikolodo sakho.

== Iinkomba ==
[[Category:Isikolodo]]
[[Category:Imali]]
[[Category:Ibulungelo lemali]]</text>
      <sha1>9bp8y9t2b9j0klygtbmcevqx31tje35</sha1>
    </revision>
    <revision>
      <id>6681</id>
      <parentid>5061</parentid>
      <timestamp>2026-06-09T15:49:17Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <origin>6681</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4384" sha1="r0mzjlh2kdqptkxvz8mfz4o9komfszf" xml:space="preserve">'''Isikolodo''' kukulokha uboleka inani elithileko lemali emuntwini nofana ebulungelweni lemali bese uzibophe bona uzoyibuyisa nini begodu bunjani. Esikhathini esiphila kiso ukwenza isikolodo sele kuyinto ejwayelekileko begodu kuyindlela yokuphila&lt;ref&gt;Debt: What It Is, How It Works, Types, and Ways to Pay Back&lt;/ref&gt;.  

== Imihlobo yeenkolodo ==

==== Isikolodo seentolo ====
Isikolodo seentolo ngilesi osenza lokha nawenza ikharada lesitolo esithileko bese uthatha ngalo izambatho ngesikolodo bese ubhadele kancani kancani imali oyikolodako njalo ngenyanga. Nawubhadela kuhle eentolo lezi bakukhuphulela Amandla wokuthuthenga okutjho bona bakhuphula inani lesikolodo ongasenza lokha ngokuthenga izambatho isikolodo&lt;ref&gt;https://legaladvice.org.za/what-happens-if-you-don-t-pay-your-clothing-account-in-south-africa/&lt;/ref&gt;.Isikolodo sepahla sigenziwa ngunynana ngubani umuntu ongakghona ukuthi abuyisele imali yepahlal ayithetheko esitolo athenge kiso. Isitolo esinye nesinye siyasivuma bonyana abantu bathenge ipahla ngesikolodo.

==== Isikolodo sepahla ====
Lokha nawufuna ukuthenga ipahla yangendlini unganamali yokuthenga ngasikhathi sinye, uyakghona ukupha I diphozidi bese [[imali]] eseleko uyikhiphe kancani kancani ngenyanga. Isilokodo lesi basifaka amakonyana ngombana bakwenzele umusa bokuthi ukghone ukubhadela ngengcezu. Okumbi ngesikolodo lesi kukuthi lokha nawubhalelwa kubhadela kuhle [[ipahla]] oyithetheko abantu besitolo leso bayabuya bazokuthatha ipahla yabo.

==== Isikolodo sebulungelweni lemali ====
Ebulungelweni lemali ukghona ukwenza silokodo semali oyifunako ukuya ngokokuthi wena ukghola [[imali]] engangani lapho usebenza khona.Lokha nawenza isikolodo lesi kubanephepha lesivumelwano olitlikitlako elitjho bona uzokubhadela njani. Ungenza isikolodo semali ufuna ukwakha indlu, ufuna ukuthenga imodere, ufuna ukuyokubhadela iindleko zokufunda, nokwenza okhunye okuqakathekileko. Ebulungelweni lemali, imali obakoloda yona ugcina sele uyibuyisela nakonyana ngombana kibo ukuboleka umuntu imali kuyirhwebo&lt;ref&gt;Hollander, S. and Verriest, A., 2016. Bridging the gap: the design of bank loan contracts and distance. ''Journal of Financial Economics'', ''119''(2), pp.399-419.&lt;/ref&gt;.

=== Ubuhle bokwenza isikolodo ===
Isikolodo siyakghona ukukulekelela ukghone ukufeza iindingo zakho msinya nanyana unganamali. Isikolodo singakukhupha emrarweni wemali oqalana nawo lokha nawufuna ukwenza into. Isibonelo umuntu angaboleka imali ebulungelweni lemali ukuyokubhadela ifundo yamaziko aphezulu ukuthi akghone ukuthola iziqu zakhe&lt;ref&gt;Pros and cons of debt - Economics Help&lt;/ref&gt;. Abantu bakghona ukwenza iikolodo ukuze kuze bakghone ukuthuthukisa amaphilo wabo bese kuthi sele bacedile ukwenza njalo bese  bavala iinkolodo zabo. Ukwenza isikodo kugenye yeendlela zokulekelela abantu bakghone ukuphila nanyana banganayo imali 

=== Ubumbi bokwenza isikolodo ===
Lokha nawenza isikolodo ungangcina sele ubhadela imali edlula leyo gade uyibolekile. Ebulungelweni lemali bafaka amakonyana phezu kwemali leyo oyibolekileko ugcine sele ubhadala imali enengi&lt;ref&gt;Blanchard, O., 2019. Public debt and low interest rates. ''American Economic Review'', ''109''(4), pp.1197-1229.&lt;/ref&gt;. Abanye bagcina sele benza iiinkolodo ezinengi khulu bese bahlulwe kuzibhadela bazithole sele banegama elimbi lokungabhadeli iinkolodo.Lokha nawubuyisela imali oyiboleke ebulungelweni lemali ungagcina sele uhlala unganamali ungakghoni nokondla umndeni wakho kuhle nangebe unganabo ubuhlakani bokusebenzisa imali.

Ubumbi bokuboleka imali kukuthi lokha nawuhlulwa kusibhadela ngesikhathi isikolodo ungavela njengomuntu ongakathembeki bese bakufake encwadini enzima  ugcine sele ungasakghoni nokuboleka imali kwezinye indawo ngombana kuzokuvela kizo zoke indawo bona wena umumuntu ongakghoni ukubhadela isikolodo&lt;ref&gt;Opwaka, R.P. and Wanyoike, D., An Assessment of the Attitudes of Blacklisted Bank Clients on Their Bank Use: A Case of Blacklisted National Bank Clients in Nakuru.

Vancouver&lt;/ref&gt;.Isikolodo kuyinto engamsiza omunye umuntu. Kufanele lokha anwenza isikolodo usenze wazi bona uzosibhadela njani begodu uqinisekeise bona ukghona ukuphila nasele ubhadela isikolodo. Nawenze isikolodo kufanele ubalekele ukuba negama elimbi lokungabhadeli ngokuthi ubhadele kuhle ngesikhathi isikolodo sakho.

== Iinkomba ==
[[Category:Isikolodo]]
[[Category:Imali]]
[[Category:Ibulungelo lemali]]</text>
      <sha1>r0mzjlh2kdqptkxvz8mfz4o9komfszf</sha1>
    </revision>
  </page>
  <page>
    <title>Imali</title>
    <ns>0</ns>
    <id>509</id>
    <revision>
      <id>2539</id>
      <timestamp>2025-03-19T11:37:34Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Imali == '''Imali''' kuyinto yokuthenga&lt;ref&gt;Money - Wikipedia&lt;/ref&gt;, iqakathekilo emaphilweni wabantu.Imali yenza bona abantu bakghone ukuba ukuthola amathuba,  ubudlelwano nokhunye. Imali kuyinto eyenza bona abantu bakghone ukutjala imali bewuthole inzuzo. Imali imali isika mahlongothi womabili ngombana inobuhle nombumbi ebulethako emphakathini nephasini loke.Kunemali Yephepha nemali yamasende. Imali yeSewula Afrika ibalwa ngamaranda.  == Ubuhle obulethwa yimali == I...&quot;</comment>
      <origin>2539</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2573" sha1="3c9tn5lssjc8iwe33ok7wboh4kcxrwa" xml:space="preserve">== Imali ==
'''Imali''' kuyinto yokuthenga&lt;ref&gt;Money - Wikipedia&lt;/ref&gt;, iqakathekilo emaphilweni wabantu.Imali yenza bona abantu bakghone ukuba ukuthola amathuba,  ubudlelwano nokhunye. Imali kuyinto eyenza bona abantu bakghone ukutjala imali bewuthole inzuzo. Imali imali isika mahlongothi womabili ngombana inobuhle nombumbi ebulethako emphakathini nephasini loke.Kunemali Yephepha nemali yamasende. Imali yeSewula Afrika ibalwa ngamaranda.

== Ubuhle obulethwa yimali ==
Imali kungaba yinto enamandla wokukhulula umuntu umnikele zizinto ezihle ezinengi.umuntu nakanemali ukhona ukubulunga imali ngokwaneleko abe nokuthula emphefumulweni wakhe ngombana ngemali ayibulungileko uyakghona ukuhlela ikusasa lakhe.Ukuba nemali kuletha kunikela umuntu ikululeko yokuthi akghone ukulanfela amabhudango wakhe, akghone ukuvakatjhela indawo afuna ukuzivakatjhela. Umuntu nakane mali ukghona ukuphila ipilo yakhe ngendlela afuna ngayo angabi esithiyo.Umuntu onemali uthola amathuba aneleko kwezefundo,kwezepilo nakweminye imikhakha eqakathekileko ngombana akghona ukubhadela. Umuntu lo ukghona ukuthoma irhwebo, ukuzithuthukisa nokukhula, bese athuthukise izinga lakhe lokuphila&lt;ref&gt;Mood, C., 2017. More than money: social class, income, and the intergenerational persistence of advantage. ''Sociological Science'', ''4'', pp.263-287.&lt;/ref&gt;.

Ubumbi bemali

Imali iletha ukungalingani phakathi kwabantu ngombana umuntu onemali uyahluka kilabo abanganayo. Kuthiwa boke abantu bayalingana ngaphasi komthetho kodwana imali iyakghona ukuphula umthetho ngombana umuntu onenamali uyakghona ukubhadela ibheyili aphume ejele lokha nagade avalelwe&lt;ref&gt;Why Celebrities and the Wealthy Think They Are Above the Law | Psychology Today&lt;/ref&gt;.Imali iyakhona ukwenzisa umuntu izinto zobutsotsi nobukhohlakali njengokuthi umuntu athengise iindakamizwa ukuze akghone ukuba yinjinga. Abanye abantu abanemali bayakghona ukuthenga abantu ukuze bakghone ukuthola isizo ngaphambi kwabanye abantu&lt;ref&gt;Where South Africans are paying the most bribes | Freight News&lt;/ref&gt;.

Ukusebenzisa imali

Kuqakathekile bona abantu bafundiswe ngokusebenzisa imali ngokuhlakanipha&lt;ref&gt;Lusardi, A. and Mitchell, O.S., 2014. The economic importance of financial literacy: Theory and evidence. ''American Economic Journal: Journal of Economic Literature'', ''52''(1), pp.5-44.&lt;/ref&gt;. Bafundiswe ukusebenzisa ukuthatha inqunto ezihle zemali ukubalekela ukuphelelwa yimali bangakatjheji. Abantu kufanele bakwazi ukusebenzisa imali kuhle ngokuthi bathenge lokho abakudingako kwaphela bese bathathe imali eseleko bayoyibulunga.</text>
      <sha1>3c9tn5lssjc8iwe33ok7wboh4kcxrwa</sha1>
    </revision>
    <revision>
      <id>2540</id>
      <parentid>2539</parentid>
      <timestamp>2025-03-19T11:49:09Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2540</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2573" sha1="k39rqdm9ygj8sif0g8oc5a3lab3x8rc" xml:space="preserve">== Imali ==
'''Imali''' kuyinto yokuthenga&lt;ref&gt;Money - Wikipedia&lt;/ref&gt;, iqakathekile emaphilweni wabantu.Imali yenza bona abantu bakghone ukuba ukuthola amathuba,  ubudlelwano nokhunye. Imali kuyinto eyenza bona abantu bakghone ukutjala imali bebathole inzuzo. Imali imali isika mahlongothi womabili ngombana inobuhle nombumbi ebulethako emphakathini nephasini loke.Kunemali Yephepha nemali yamasende. Imali yeSewula Afrika ibalwa ngamaranda.

== Ubuhle obulethwa yimali ==
Imali kungaba yinto enamandla wokukhulula umuntu umnikele zizinto ezihle ezinengi.umuntu nakanemali ukhona ukubulunga imali ngokwaneleko abe nokuthula emphefumulweni wakhe ngombana ngemali ayibulungileko uyakghona ukuhlela ikusasa lakhe.Ukuba nemali kuletha kunikela umuntu ikululeko yokuthi akghone ukulanfela amabhudango wakhe, akghone ukuvakatjhela indawo afuna ukuzivakatjhela. Umuntu nakane mali ukghona ukuphila ipilo yakhe ngendlela afuna ngayo angabi esithiyo.Umuntu onemali uthola amathuba aneleko kwezefundo,kwezepilo nakweminye imikhakha eqakathekileko ngombana akghona ukubhadela. Umuntu lo ukghona ukuthoma irhwebo, ukuzithuthukisa nokukhula, bese athuthukise izinga lakhe lokuphila&lt;ref&gt;Mood, C., 2017. More than money: social class, income, and the intergenerational persistence of advantage. ''Sociological Science'', ''4'', pp.263-287.&lt;/ref&gt;.

Ubumbi bemali

Imali iletha ukungalingani phakathi kwabantu ngombana umuntu onemali uyahluka kilabo abanganayo. Kuthiwa boke abantu bayalingana ngaphasi komthetho kodwana imali iyakghona ukuphula umthetho ngombana umuntu onenamali uyakghona ukubhadela ibheyili aphume ejele lokha nagade avalelwe&lt;ref&gt;Why Celebrities and the Wealthy Think They Are Above the Law | Psychology Today&lt;/ref&gt;.Imali iyakhona ukwenzisa umuntu izinto zobutsotsi nobukhohlakali njengokuthi umuntu athengise iindakamizwa ukuze akghone ukuba yinjinga. Abanye abantu abanemali bayakghona ukuthenga abantu ukuze bakghone ukuthola isizo ngaphambi kwabanye abantu&lt;ref&gt;Where South Africans are paying the most bribes | Freight News&lt;/ref&gt;.

Ukusebenzisa imali

Kuqakathekile bona abantu bafundiswe ngokusebenzisa imali ngokuhlakanipha&lt;ref&gt;Lusardi, A. and Mitchell, O.S., 2014. The economic importance of financial literacy: Theory and evidence. ''American Economic Journal: Journal of Economic Literature'', ''52''(1), pp.5-44.&lt;/ref&gt;. Bafundiswe ukusebenzisa ukuthatha inqunto ezihle zemali ukubalekela ukuphelelwa yimali bangakatjheji. Abantu kufanele bakwazi ukusebenzisa imali kuhle ngokuthi bathenge lokho abakudingako kwaphela bese bathathe imali eseleko bayoyibulunga.</text>
      <sha1>k39rqdm9ygj8sif0g8oc5a3lab3x8rc</sha1>
    </revision>
    <revision>
      <id>2541</id>
      <parentid>2540</parentid>
      <timestamp>2025-03-19T11:51:56Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2541</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2594" sha1="cnm6rz71r5zgj85t7vbnv0nozgedmx1" xml:space="preserve">== Imali ==
'''Imali''' kuyinto yokuthenga&lt;ref&gt;Money - Wikipedia&lt;/ref&gt;, iqakathekile emaphilweni wabantu.Imali yenza bona abantu bakghone ukuba ukuthola amathuba,  ubudlelwano nokhunye. Imali kuyinto eyenza bona abantu bakghone ukutjala imali bebathole inzuzo. Imali imali isika mahlongothi womabili ngombana inobuhle nombumbi ebulethako emphakathini nephasini loke.Kunemali Yephepha nemali yamasende. Imali yeSewula Afrika ibalwa ngamaranda.

== Ubuhle obulethwa yimali ==
Imali kungaba yinto enamandla wokutjhaphulula umuntu imnikele izinto ezihle ezinengi.umuntu nakanemali ukghona ukubulunga imali ngokwaneleko abe nokuthula emphefumulweni wakhe ngombana uyazi unemali ayibulungileko akghona ukuhlela ikusasa lakhe ngayo.Ukuba nemali kunikela umuntu ikululeko yokuthi akghone ukulandela amabhudango wakhe, akghone ukuvakatjhela indawo afuna ukuzivakatjhela. Umuntu nakane mali ukghona ukuphila ipilo yakhe ngendlela afuna ngayo angabi nesithiyo.Umuntu onemali uthola amathuba aneleko kwezefundo,kwezepilo nakweminye imikhakha eqakathekileko ngombana akghona ukubhadela. Umuntu lo ukghona ukuthoma irhwebo, ukuzithuthukisa nokukhula, bese athuthukise izinga lakhe lokuphila&lt;ref&gt;Mood, C., 2017. More than money: social class, income, and the intergenerational persistence of advantage. ''Sociological Science'', ''4'', pp.263-287.&lt;/ref&gt;.

Ubumbi bemali

Imali iletha ukungalingani phakathi kwabantu ngombana umuntu onemali uyahluka kilabo abanganayo. Kuthiwa boke abantu bayalingana ngaphasi komthetho kodwana imali iyakghona ukuphula umthetho  ngasikhathi, ngombana umuntu onenamali uyakghona ukubhadela ibheyili aphume ejele lokha nagade avalelwe&lt;ref&gt;Why Celebrities and the Wealthy Think They Are Above the Law | Psychology Today&lt;/ref&gt;.Imali iyakhona ukwenzisa umuntu izinto zobutsotsi nobukhohlakali njengokuthi umuntu athengise iindakamizwa ukuze akghone ukuba yinjinga. Abanye abantu abanemali bayakghona ukuthenga abantu ukuze bakghone ukuthola isizo ngaphambi kwabanye abantu&lt;ref&gt;Where South Africans are paying the most bribes | Freight News&lt;/ref&gt;.

Ukusebenzisa imali

Kuqakathekile bona abantu bafundiswe ngokusebenzisa imali ngokuhlakanipha&lt;ref&gt;Lusardi, A. and Mitchell, O.S., 2014. The economic importance of financial literacy: Theory and evidence. ''American Economic Journal: Journal of Economic Literature'', ''52''(1), pp.5-44.&lt;/ref&gt;. Bafundiswe ukusebenzisa ukuthatha inqunto ezihle zemali ukubalekela ukuphelelwa yimali bangakatjheji. Abantu kufanele bakwazi ukusebenzisa imali kuhle ngokuthi bathenge lokho abakudingako kwaphela bese bathathe imali eseleko bayoyibulunga.</text>
      <sha1>cnm6rz71r5zgj85t7vbnv0nozgedmx1</sha1>
    </revision>
    <revision>
      <id>2825</id>
      <parentid>2541</parentid>
      <timestamp>2025-05-19T11:04:05Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2825</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2778" sha1="cbn6cgk7bqnf9wc75xon1yy9f5i8b6w" xml:space="preserve">== Imali ==
'''Imali''' kuyinto yokuthenga&lt;ref&gt;Money - Wikipedia&lt;/ref&gt;, iqakathekile emaphilweni wabantu.Imali yenza bona abantu bakghone ukuba ukuthola amathuba,  ubudlelwano nokhunye. Imali kuyinto eyenza bona abantu bakghone ukutjala imali bebathole inzuzo. Imali imali isika mahlongothi womabili ngombana inobuhle nombumbi ebulethako emphakathini nephasini loke.Kunemali Yephepha nemali yamasende. Imali yeSewula Afrika ibalwa ngamaranda.

== Ubuhle obulethwa yimali ==
Imali kungaba yinto enamandla wokutjhaphulula umuntu imnikele izinto ezihle ezinengi. Umuntu nakanemali ukghona ukubulunga imali ngokwaneleko abe nokuthula emphefumulweni wakhe ngombana uyazi unemali ayibulungileko akghona ukuhlela ikusasa lakhe ngayo. Ukuba nemali kunikela umuntu ikululeko yokuthi akghone ukulandela amabhudango wakhe, akghone ukuvakatjhela indawo afuna ukuzivakatjhela. Umuntu nakane mali ukghona ukuphila ipilo yakhe ngendlela afuna ngayo angabi nesithiyo.Umuntu onemali uthola amathuba aneleko kwezefundo,kwezepilo nakweminye imikhakha eqakathekileko ngombana akghona ukubhadela. Umuntu lo ukghona ukuthoma irhwebo, ukuzithuthukisa nokukhula, bese athuthukise izinga lakhe lokuphila&lt;ref&gt;Mood, C., 2017. More than money: social class, income, and the intergenerational persistence of advantage. ''Sociological Science'', ''4'', pp.263-287.&lt;/ref&gt;.

== Ubumbi bemali ==
Imali iletha ukungalingani phakathi kwabantu ngombana umuntu onemali uyahluka kilabo abanganayo. Kuthiwa boke abantu bayalingana ngaphasi komthetho kodwana imali iyakghona ukuphula umthetho  ngasikhathi, ngombana umuntu onenamali uyakghona ukubhadela ibheyili aphume ejele lokha nagade avalelwe&lt;ref&gt;Why Celebrities and the Wealthy Think They Are Above the Law | Psychology Today&lt;/ref&gt;.Imali iyakhona ukwenzisa umuntu izinto zobutsotsi nobukhohlakali njengokuthi umuntu athengise iindakamizwa ukuze akghone ukuba yinjinga. Abanye abantu abanemali bayakghona ukuthenga abantu ukuze bakghone ukuthola isizo ngaphambi kwabanye abantu&lt;ref&gt;Where South Africans are paying the most bribes | Freight News&lt;/ref&gt;.

== Ukusebenzisa imali ==
Kuqakathekile bona abantu bafundiswe ngokusebenzisa imali ngokuhlakanipha&lt;ref&gt;Lusardi, A. and Mitchell, O.S., 2014. The economic importance of financial literacy: Theory and evidence. ''American Economic Journal: Journal of Economic Literature'', ''52''(1), pp.5-44.&lt;/ref&gt;. Bafundiswe ukusebenzisa ukuthatha inqunto ezihle zemali ukubalekela ukuphelelwa yimali bangakatjheji. Abantu kufanele bakwazi ukusebenzisa imali kuhle ngokuthi bathenge lokho abakudingako kwaphela bese bathathe imali eseleko bayoyibulunga. Abantu nafundiswa ngokusenzisa imali bakhona ukuhlela ukuthi bazoyisebenzisa bubjani begodu bayibulunge bunjani, benze lokho baqale iindingo abazokuba nazo ekusaseni labo.</text>
      <sha1>cbn6cgk7bqnf9wc75xon1yy9f5i8b6w</sha1>
    </revision>
    <revision>
      <id>3030</id>
      <parentid>2825</parentid>
      <timestamp>2025-06-06T20:35:16Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>other</comment>
      <origin>3030</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2866" sha1="57q3git5q5e822secqpvz315khm80fr" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.'''

== Imali ==
'''Imali''' kuyinto yokuthenga&lt;ref&gt;Money - Wikipedia&lt;/ref&gt;, iqakathekile emaphilweni wabantu.Imali yenza bona abantu bakghone ukuba ukuthola amathuba,  ubudlelwano nokhunye. Imali kuyinto eyenza bona abantu bakghone ukutjala imali bebathole inzuzo. Imali imali isika mahlongothi womabili ngombana inobuhle nombumbi ebulethako emphakathini nephasini loke.Kunemali Yephepha nemali yamasende. Imali yeSewula Afrika ibalwa ngamaranda.

== Ubuhle obulethwa yimali ==
Imali kungaba yinto enamandla wokutjhaphulula umuntu imnikele izinto ezihle ezinengi. Umuntu nakanemali ukghona ukubulunga imali ngokwaneleko abe nokuthula emphefumulweni wakhe ngombana uyazi unemali ayibulungileko akghona ukuhlela ikusasa lakhe ngayo. Ukuba nemali kunikela umuntu ikululeko yokuthi akghone ukulandela amabhudango wakhe, akghone ukuvakatjhela indawo afuna ukuzivakatjhela. Umuntu nakane mali ukghona ukuphila ipilo yakhe ngendlela afuna ngayo angabi nesithiyo.Umuntu onemali uthola amathuba aneleko kwezefundo,kwezepilo nakweminye imikhakha eqakathekileko ngombana akghona ukubhadela. Umuntu lo ukghona ukuthoma irhwebo, ukuzithuthukisa nokukhula, bese athuthukise izinga lakhe lokuphila&lt;ref&gt;Mood, C., 2017. More than money: social class, income, and the intergenerational persistence of advantage. ''Sociological Science'', ''4'', pp.263-287.&lt;/ref&gt;.

== Ubumbi bemali ==
Imali iletha ukungalingani phakathi kwabantu ngombana umuntu onemali uyahluka kilabo abanganayo. Kuthiwa boke abantu bayalingana ngaphasi komthetho kodwana imali iyakghona ukuphula umthetho  ngasikhathi, ngombana umuntu onenamali uyakghona ukubhadela ibheyili aphume ejele lokha nagade avalelwe&lt;ref&gt;Why Celebrities and the Wealthy Think They Are Above the Law | Psychology Today&lt;/ref&gt;.Imali iyakhona ukwenzisa umuntu izinto zobutsotsi nobukhohlakali njengokuthi umuntu athengise iindakamizwa ukuze akghone ukuba yinjinga. Abanye abantu abanemali bayakghona ukuthenga abantu ukuze bakghone ukuthola isizo ngaphambi kwabanye abantu&lt;ref&gt;Where South Africans are paying the most bribes | Freight News&lt;/ref&gt;.

== Ukusebenzisa imali ==
Kuqakathekile bona abantu bafundiswe ngokusebenzisa imali ngokuhlakanipha&lt;ref&gt;Lusardi, A. and Mitchell, O.S., 2014. The economic importance of financial literacy: Theory and evidence. ''American Economic Journal: Journal of Economic Literature'', ''52''(1), pp.5-44.&lt;/ref&gt;. Bafundiswe ukusebenzisa ukuthatha inqunto ezihle zemali ukubalekela ukuphelelwa yimali bangakatjheji. Abantu kufanele bakwazi ukusebenzisa imali kuhle ngokuthi bathenge lokho abakudingako kwaphela bese bathathe imali eseleko bayoyibulunga. Abantu nafundiswa ngokusenzisa imali bakhona ukuhlela ukuthi bazoyisebenzisa bubjani begodu bayibulunge bunjani, benze lokho baqale iindingo abazokuba nazo ekusaseni labo.</text>
      <sha1>57q3git5q5e822secqpvz315khm80fr</sha1>
    </revision>
    <revision>
      <id>3041</id>
      <parentid>3030</parentid>
      <timestamp>2025-06-07T03:05:22Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Nqobile69|Nqobile69]]</comment>
      <origin>2825</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2778" sha1="cbn6cgk7bqnf9wc75xon1yy9f5i8b6w" xml:space="preserve">== Imali ==
'''Imali''' kuyinto yokuthenga&lt;ref&gt;Money - Wikipedia&lt;/ref&gt;, iqakathekile emaphilweni wabantu.Imali yenza bona abantu bakghone ukuba ukuthola amathuba,  ubudlelwano nokhunye. Imali kuyinto eyenza bona abantu bakghone ukutjala imali bebathole inzuzo. Imali imali isika mahlongothi womabili ngombana inobuhle nombumbi ebulethako emphakathini nephasini loke.Kunemali Yephepha nemali yamasende. Imali yeSewula Afrika ibalwa ngamaranda.

== Ubuhle obulethwa yimali ==
Imali kungaba yinto enamandla wokutjhaphulula umuntu imnikele izinto ezihle ezinengi. Umuntu nakanemali ukghona ukubulunga imali ngokwaneleko abe nokuthula emphefumulweni wakhe ngombana uyazi unemali ayibulungileko akghona ukuhlela ikusasa lakhe ngayo. Ukuba nemali kunikela umuntu ikululeko yokuthi akghone ukulandela amabhudango wakhe, akghone ukuvakatjhela indawo afuna ukuzivakatjhela. Umuntu nakane mali ukghona ukuphila ipilo yakhe ngendlela afuna ngayo angabi nesithiyo.Umuntu onemali uthola amathuba aneleko kwezefundo,kwezepilo nakweminye imikhakha eqakathekileko ngombana akghona ukubhadela. Umuntu lo ukghona ukuthoma irhwebo, ukuzithuthukisa nokukhula, bese athuthukise izinga lakhe lokuphila&lt;ref&gt;Mood, C., 2017. More than money: social class, income, and the intergenerational persistence of advantage. ''Sociological Science'', ''4'', pp.263-287.&lt;/ref&gt;.

== Ubumbi bemali ==
Imali iletha ukungalingani phakathi kwabantu ngombana umuntu onemali uyahluka kilabo abanganayo. Kuthiwa boke abantu bayalingana ngaphasi komthetho kodwana imali iyakghona ukuphula umthetho  ngasikhathi, ngombana umuntu onenamali uyakghona ukubhadela ibheyili aphume ejele lokha nagade avalelwe&lt;ref&gt;Why Celebrities and the Wealthy Think They Are Above the Law | Psychology Today&lt;/ref&gt;.Imali iyakhona ukwenzisa umuntu izinto zobutsotsi nobukhohlakali njengokuthi umuntu athengise iindakamizwa ukuze akghone ukuba yinjinga. Abanye abantu abanemali bayakghona ukuthenga abantu ukuze bakghone ukuthola isizo ngaphambi kwabanye abantu&lt;ref&gt;Where South Africans are paying the most bribes | Freight News&lt;/ref&gt;.

== Ukusebenzisa imali ==
Kuqakathekile bona abantu bafundiswe ngokusebenzisa imali ngokuhlakanipha&lt;ref&gt;Lusardi, A. and Mitchell, O.S., 2014. The economic importance of financial literacy: Theory and evidence. ''American Economic Journal: Journal of Economic Literature'', ''52''(1), pp.5-44.&lt;/ref&gt;. Bafundiswe ukusebenzisa ukuthatha inqunto ezihle zemali ukubalekela ukuphelelwa yimali bangakatjheji. Abantu kufanele bakwazi ukusebenzisa imali kuhle ngokuthi bathenge lokho abakudingako kwaphela bese bathathe imali eseleko bayoyibulunga. Abantu nafundiswa ngokusenzisa imali bakhona ukuhlela ukuthi bazoyisebenzisa bubjani begodu bayibulunge bunjani, benze lokho baqale iindingo abazokuba nazo ekusaseni labo.</text>
      <sha1>cbn6cgk7bqnf9wc75xon1yy9f5i8b6w</sha1>
    </revision>
    <revision>
      <id>3440</id>
      <parentid>3041</parentid>
      <timestamp>2025-07-15T11:49:09Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3440</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2816" sha1="7psyirr72c4htksb41b1t7f5t27qa10" xml:space="preserve">[[Isimumathi:Imali.jpg|thumb|Imali]]
'''Imali''' kuyinto yokuthenga,&lt;ref&gt;Money - Wikipedia&lt;/ref&gt; iqakathekile emaphilweni wabantu.Imali yenza bona abantu bakghone ukuba ukuthola amathuba,  ubudlelwano nokhunye. Imali kuyinto eyenza bona abantu bakghone ukutjala imali bebathole inzuzo. Imali imali isika mahlongothi womabili ngombana inobuhle nombumbi ebulethako emphakathini nephasini loke.Kunemali Yephepha nemali yamasende. Imali yeSewula Afrika ibalwa ngamaranda.

=== Amatjhuguluko obulethwa yimali ===
Imali kungaba yinto enamandla wokutjhaphulula umuntu imnikele izinto ezihle ezinengi. Umuntu nakanemali ukghona ukubulunga imali ngokwaneleko abe nokuthula emphefumulweni wakhe ngombana uyazi unemali ayibulungileko akghona ukuhlela ikusasa lakhe ngayo. Ukuba nemali kunikela umuntu ikululeko yokuthi akghone ukulandela amabhudango wakhe, akghone ukuvakatjhela indawo afuna ukuzivakatjhela. Umuntu nakane mali ukghona ukuphila ipilo yakhe ngendlela afuna ngayo angabi nesithiyo.Umuntu onemali uthola amathuba aneleko kwezefundo,kwezepilo nakweminye imikhakha eqakathekileko ngombana akghona ukubhadela. Umuntu lo ukghona ukuthoma irhwebo, ukuzithuthukisa nokukhula, bese athuthukise izinga lakhe lokuphila.&lt;ref&gt;Mood, C., 2017. More than money: social class, income, and the intergenerational persistence of advantage. ''Sociological Science'', ''4'', pp.263-287.&lt;/ref&gt;

=== Ubumbi bemali ===
Imali iletha ukungalingani phakathi kwabantu ngombana umuntu onemali uyahluka kilabo abanganayo. Kuthiwa boke abantu bayalingana ngaphasi komthetho kodwana imali iyakghona ukuphula umthetho  ngasikhathi, ngombana umuntu onenamali uyakghona ukubhadela ibheyili aphume ejele lokha nagade avalelwe&lt;ref&gt;Why Celebrities and the Wealthy Think They Are Above the Law | Psychology Today&lt;/ref&gt;.Imali iyakghona ukwenzisa umuntu izinto zobutsotsi nobukhohlakali njengokuthi umuntu athengise iindakamizwa ukuze akghone ukuba yinjinga. Abanye abantu abanemali bayakghona ukuthenga abantu ukuze bakghone ukuthola isizo ngaphambi kwabanye abantu.&lt;ref&gt;Where South Africans are paying the most bribes | Freight News&lt;/ref&gt;

=== Ukusebenzisa imali ===
Kuqakathekile bona abantu bafundiswe ngokusebenzisa imali ngokuhlakanipha.&lt;ref&gt;Lusardi, A. and Mitchell, O.S., 2014. The economic importance of financial literacy: Theory and evidence. ''American Economic Journal: Journal of Economic Literature'', ''52''(1), pp.5-44.&lt;/ref&gt;Bafundiswe ukusebenzisa ukuthatha inqunto ezihle zemali ukubalekela ukuphelelwa yimali bangakatjheji. Abantu kufanele bakwazi ukusebenzisa imali kuhle ngokuthi bathenge lokho abakudingako kwaphela bese bathathe imali eseleko bayoyibulunga. Abantu nafundiswa ngokusenzisa imali bakhona ukuhlela ukuthi bazoyisebenzisa bubjani begodu bayibulunge bunjani, benze lokho baqale iindingo abazokuba nazo ekusaseni labo.</text>
      <sha1>7psyirr72c4htksb41b1t7f5t27qa10</sha1>
    </revision>
    <revision>
      <id>3441</id>
      <parentid>3440</parentid>
      <timestamp>2025-07-15T11:51:34Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3441</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2821" sha1="izd8s7ujsbz2xkxyfp03zp941dpytfv" xml:space="preserve">[[Isimumathi:Imali.jpg|thumb|Imali]]
'''Imali''' kuyinto yokuthenga,&lt;ref&gt;Money - Wikipedia&lt;/ref&gt; iqakathekile emaphilweni wabantu.Imali yenza bona abantu bakghone ukuba ukuthola amathuba,  ubudlelwano nokhunye. Imali kuyinto eyenza bona abantu bakghone [[ukutjala imali]] bebathole inzuzo. Imali imali isika mahlongothi womabili ngombana inobuhle nombumbi ebulethako emphakathini nephasini loke.Kunemali Yephepha nemali yamaseende. Imali yeSewula Afrika ibalwa ngamaranda.

=== Amatjhuguluko obulethwa yimali ===
Imali kungaba yinto enamandla wokutjhaphulula umuntu imnikele izinto ezihle ezinengi. Umuntu nakanemali ukghona ukubulunga imali ngokwaneleko abe nokuthula emphefumulweni wakhe ngombana uyazi unemali ayibulungileko akghona ukuhlela ikusasa lakhe ngayo. Ukuba nemali kunikela umuntu ikululeko yokuthi akghone ukulandela amabhudango wakhe, akghone ukuvakatjhela indawo afuna ukuzivakatjhela. Umuntu nakane mali ukghona ukuphila ipilo yakhe ngendlela afuna ngayo angabi nesithiyo.Umuntu onemali uthola amathuba aneleko kwezefundo,kwezepilo nakweminye imikhakha eqakathekileko ngombana akghona ukubhadela. Umuntu lo ukghona ukuthoma irhwebo, ukuzithuthukisa nokukhula, bese athuthukise izinga lakhe lokuphila.&lt;ref&gt;Mood, C., 2017. More than money: social class, income, and the intergenerational persistence of advantage. ''Sociological Science'', ''4'', pp.263-287.&lt;/ref&gt;

=== Ubumbi bemali ===
Imali iletha ukungalingani phakathi kwabantu ngombana umuntu onemali uyahluka kilabo abanganayo. Kuthiwa boke abantu bayalingana ngaphasi komthetho kodwana imali iyakghona ukuphula umthetho  ngasikhathi, ngombana umuntu onenamali uyakghona ukubhadela ibheyili aphume ejele lokha nagade avalelwe&lt;ref&gt;Why Celebrities and the Wealthy Think They Are Above the Law | Psychology Today&lt;/ref&gt;.Imali iyakghona ukwenzisa umuntu izinto zobutsotsi nobukhohlakali njengokuthi umuntu athengise iindakamizwa ukuze akghone ukuba yinjinga. Abanye abantu abanemali bayakghona ukuthenga abantu ukuze bakghone ukuthola isizo ngaphambi kwabanye abantu.&lt;ref&gt;Where South Africans are paying the most bribes | Freight News&lt;/ref&gt;

=== Ukusebenzisa imali ===
Kuqakathekile bona abantu bafundiswe ngokusebenzisa imali ngokuhlakanipha.&lt;ref&gt;Lusardi, A. and Mitchell, O.S., 2014. The economic importance of financial literacy: Theory and evidence. ''American Economic Journal: Journal of Economic Literature'', ''52''(1), pp.5-44.&lt;/ref&gt;Bafundiswe ukusebenzisa ukuthatha inqunto ezihle zemali ukubalekela ukuphelelwa yimali bangakatjheji. Abantu kufanele bakwazi ukusebenzisa imali kuhle ngokuthi bathenge lokho abakudingako kwaphela bese bathathe imali eseleko bayoyibulunga. Abantu nafundiswa ngokusenzisa imali bakhona ukuhlela ukuthi bazoyisebenzisa bubjani begodu bayibulunge bunjani, benze lokho baqale iindingo abazokuba nazo ekusaseni labo.</text>
      <sha1>izd8s7ujsbz2xkxyfp03zp941dpytfv</sha1>
    </revision>
    <revision>
      <id>3534</id>
      <parentid>3441</parentid>
      <timestamp>2025-08-04T17:21:28Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3534</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2837" sha1="f3l94amqvx2a8d1nx8l1x6e1h3x7dhl" xml:space="preserve">[[Isimumathi:Imali.jpg|thumb|Imali]]
'''Imali''' kuyinto yokuthenga,&lt;ref&gt;Money - Wikipedia&lt;/ref&gt; iqakathekile emaphilweni wabantu.Imali yenza bona abantu bakghone ukuba ukuthola amathuba,  ubudlelwano nokhunye. Imali kuyinto eyenza bona abantu bakghone [[ukutjala imali]] bebathole inzuzo. Imali imali isika mahlongothi womabili ngombana inobuhle nombumbi ebulethako emphakathini nephasini loke.Kunemali Yephepha nemali yamaseende. Imali yeSewula Afrika ibalwa ngamaranda.

=== Amatjhuguluko obulethwa yimali ===
Imali kungaba yinto enamandla wokutjhaphulula umuntu imnikele izinto ezihle ezinengi. Umuntu nakanemali ukghona ukubulunga imali ngokwaneleko abe nokuthula emphefumulweni wakhe ngombana uyazi unemali ayibulungileko akghona ukuhlela ikusasa lakhe ngayo. Ukuba nemali kunikela umuntu ikululeko yokuthi akghone ukulandela amabhudango wakhe, akghone ukuvakatjhela indawo afuna ukuzivakatjhela. Umuntu nakane mali ukghona ukuphila ipilo yakhe ngendlela afuna ngayo angabi nesithiyo.Umuntu onemali uthola amathuba aneleko kwezefundo,kwezepilo nakweminye imikhakha eqakathekileko ngombana akghona ukubhadela. Umuntu lo ukghona ukuthoma irhwebo, ukuzithuthukisa nokukhula, bese athuthukise izinga lakhe lokuphila.&lt;ref&gt;Mood, C., 2017. More than money: social class, income, and the intergenerational persistence of advantage. ''Sociological Science'', ''4'', pp.263-287.&lt;/ref&gt;

=== Ubumbi bemali ===
Imali iletha ukungalingani phakathi kwabantu ngombana umuntu onemali uyahluka kilabo abanganayo. Kuthiwa boke abantu bayalingana ngaphasi komthetho kodwana imali iyakghona ukuphula umthetho  ngasikhathi, ngombana umuntu onenamali uyakghona ukubhadela ibheyili aphume ejele lokha nagade avalelwe&lt;ref&gt;Why Celebrities and the Wealthy Think They Are Above the Law | Psychology Today&lt;/ref&gt;.Imali iyakghona ukwenzisa umuntu izinto zobutsotsi nobukhohlakali njengokuthi umuntu athengise iindakamizwa ukuze akghone ukuba yinjinga. Abanye abantu abanemali bayakghona ukuthenga abantu ukuze bakghone ukuthola isizo ngaphambi kwabanye abantu.&lt;ref&gt;Where South Africans are paying the most bribes | Freight News&lt;/ref&gt;

=== Ukusebenzisa imali ===
Kuqakathekile bona abantu bafundiswe ngokusebenzisa imali ngokuhlakanipha.&lt;ref&gt;Lusardi, A. and Mitchell, O.S., 2014. The economic importance of financial literacy: Theory and evidence. ''American Economic Journal: Journal of Economic Literature'', ''52''(1), pp.5-44.&lt;/ref&gt;Bafundiswe ukusebenzisa ukuthatha inqunto ezihle zemali ukubalekela ukuphelelwa yimali bangakatjheji. Abantu kufanele bakwazi ukusebenzisa imali kuhle ngokuthi bathenge lokho abakudingako kwaphela bese bathathe imali eseleko bayoyibulunga. Abantu nafundiswa ngokusenzisa imali bakhona ukuhlela ukuthi bazoyisebenzisa bubjani begodu bayibulunge bunjani, benze lokho baqale iindingo abazokuba nazo ekusaseni labo.

== Iinkomba ==</text>
      <sha1>f3l94amqvx2a8d1nx8l1x6e1h3x7dhl</sha1>
    </revision>
    <revision>
      <id>5062</id>
      <parentid>3534</parentid>
      <timestamp>2025-08-07T18:17:07Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>5062</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2887" sha1="9b8kvgrmsetnt3erxpg4mtsvqoy0hhp" xml:space="preserve">[[Isimumathi:Imali.jpg|thumb|Imali]]
'''Imali''' kuyinto yokuthenga,&lt;ref&gt;Money - Wikipedia&lt;/ref&gt; iqakathekile emaphilweni wabantu.Imali yenza bona abantu bakghone ukuba ukuthola amathuba,  ubudlelwano nokhunye. Imali kuyinto eyenza bona abantu bakghone [[ukutjala imali]] bebathole inzuzo. Imali imali isika mahlongothi womabili ngombana inobuhle nombumbi ebulethako emphakathini nephasini loke.Kunemali Yephepha nemali yamaseende. Imali yeSewula Afrika ibalwa ngamaranda.

=== Amatjhuguluko obulethwa yimali ===
Imali kungaba yinto enamandla wokutjhaphulula umuntu imnikele izinto ezihle ezinengi. Umuntu nakanemali ukghona ukubulunga imali ngokwaneleko abe nokuthula emphefumulweni wakhe ngombana uyazi unemali ayibulungileko akghona ukuhlela ikusasa lakhe ngayo. Ukuba nemali kunikela umuntu ikululeko yokuthi akghone ukulandela amabhudango wakhe, akghone ukuvakatjhela indawo afuna ukuzivakatjhela. Umuntu nakane mali ukghona ukuphila ipilo yakhe ngendlela afuna ngayo angabi nesithiyo.Umuntu onemali uthola amathuba aneleko kwezefundo,kwezepilo nakweminye imikhakha eqakathekileko ngombana akghona ukubhadela. Umuntu lo ukghona ukuthoma irhwebo, ukuzithuthukisa nokukhula, bese athuthukise izinga lakhe lokuphila.&lt;ref&gt;Mood, C., 2017. More than money: social class, income, and the intergenerational persistence of advantage. ''Sociological Science'', ''4'', pp.263-287.&lt;/ref&gt;

=== Ubumbi bemali ===
Imali iletha ukungalingani phakathi kwabantu ngombana umuntu onemali uyahluka kilabo abanganayo. Kuthiwa boke abantu bayalingana ngaphasi komthetho kodwana imali iyakghona ukuphula umthetho  ngasikhathi, ngombana umuntu onenamali uyakghona ukubhadela ibheyili aphume ejele lokha nagade avalelwe&lt;ref&gt;Why Celebrities and the Wealthy Think They Are Above the Law | Psychology Today&lt;/ref&gt;.Imali iyakghona ukwenzisa umuntu izinto zobutsotsi nobukhohlakali njengokuthi umuntu athengise iindakamizwa ukuze akghone ukuba yinjinga. Abanye abantu abanemali bayakghona ukuthenga abantu ukuze bakghone ukuthola isizo ngaphambi kwabanye abantu.&lt;ref&gt;Where South Africans are paying the most bribes | Freight News&lt;/ref&gt;

=== Ukusebenzisa imali ===
Kuqakathekile bona abantu bafundiswe ngokusebenzisa imali ngokuhlakanipha.&lt;ref&gt;Lusardi, A. and Mitchell, O.S., 2014. The economic importance of financial literacy: Theory and evidence. ''American Economic Journal: Journal of Economic Literature'', ''52''(1), pp.5-44.&lt;/ref&gt;Bafundiswe ukusebenzisa ukuthatha inqunto ezihle zemali ukubalekela ukuphelelwa yimali bangakatjheji. Abantu kufanele bakwazi ukusebenzisa imali kuhle ngokuthi bathenge lokho abakudingako kwaphela bese bathathe imali eseleko bayoyibulunga. Abantu nafundiswa ngokusenzisa imali bakhona ukuhlela ukuthi bazoyisebenzisa bunjani begodu bayibulunge bunjani, benze lokho baqale iindingo abazokuba nazo ekusaseni labo.

== Iinkomba ==
[[category:Imali]]
[[category:Ibulungelo lemali]]</text>
      <sha1>9b8kvgrmsetnt3erxpg4mtsvqoy0hhp</sha1>
    </revision>
    <revision>
      <id>5094</id>
      <parentid>5062</parentid>
      <timestamp>2025-08-08T09:28:45Z</timestamp>
      <contributor>
        <username>SimphiweMcawe</username>
        <id>845</id>
      </contributor>
      <origin>5094</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2885" sha1="dkm3h7ivmvlrg4eze627502towij7pg" xml:space="preserve">[[Isimumathi:Imali.jpg|thumb|Imali]]
'''Imali''' kuyinto yokuthenga,&lt;ref&gt;Money - Wikipedia&lt;/ref&gt; iqakathekile emaphilweni wabantu.Imali yenza bona abantu bakghone ukuba ukuthola amathuba,  ubudlelwano nokhunye. Imali kuyinto eyenza bona abantu bakghone [[ukutjala imali]] bebathole inzuzo. Imali imali isika mahlongothi womabili ngombana inobuhle nombumbi ebulethako emphakathini nephasini loke.Kunemali Yephepha nemali yamaseende. Imali yeSewula Afrika ibalwa ngamaranda.

=== Amatjhuguluko obulethwa yimali ===
Imali kungaba yinto enamandla wokutjhaphulula umuntu imnikele izinto ezihle ezinengi. Umuntu nakanemali ukghona ukubulunga imali ngokwaneleko abe nokuthula emphefumulweni wakhe ngombana uyazi unemali ayibulungileko akghona ukuhlela ikusasa lakhe ngayo. Ukuba nemali kunikela umuntu ikululeko yokuthi akghone ukulandela amabhudango wakhe, akghone ukuvakatjhela indawo afuna ukuzivakatjhela. Umuntu nakane mali ukghona ukuphila ipilo yakhe ngendlela afuna ngayo angabi nesithiyo.Umuntu onemali uthola amathuba aneleko kwezefundo,kwezepilo nakweminye imikhakha eqakathekileko ngombana akghona ukubhadela. Umuntu lo ukghona ukuthoma irhwebo, ukuzithuthukisa nokukhula, bese athuthukise izinga lakhe lokuphila.&lt;ref&gt;Mood, C., 2017. More than money: social class, income, and the intergenerational persistence of advantage. ''Sociological Science'', ''4'', pp.263-287.&lt;/ref&gt;

=== Ubumbi bemali ===
Imali iletha ukungalingani phakathi kwabantu ngombana umuntu onemali uyahluka kilabo abanganayo. Kuthiwa boke abantu bayalingana ngaphasi komthetho kodwana imali iyakghona ukuphula umthetho  ngasikhathi, ngombana umuntu onemali uyakghona ukubhadela ibheyili aphume ejele lokha nagade avalelwe&lt;ref&gt;Why Celebrities and the Wealthy Think They Are Above the Law | Psychology Today&lt;/ref&gt;.Imali iyakghona ukwenzisa umuntu izinto zobutsotsi nobukhohlakali njengokuthi umuntu athengise iindakamizwa ukuze akghone ukuba yinjinga. Abanye abantu abanemali bayakghona ukuthenga abantu ukuze bakghone ukuthola isizo ngaphambi kwabanye abantu.&lt;ref&gt;Where South Africans are paying the most bribes | Freight News&lt;/ref&gt;

=== Ukusebenzisa imali ===
Kuqakathekile bona abantu bafundiswe ngokusebenzisa imali ngokuhlakanipha.&lt;ref&gt;Lusardi, A. and Mitchell, O.S., 2014. The economic importance of financial literacy: Theory and evidence. ''American Economic Journal: Journal of Economic Literature'', ''52''(1), pp.5-44.&lt;/ref&gt;Bafundiswe ukusebenzisa ukuthatha inqunto ezihle zemali ukubalekela ukuphelelwa yimali bangakatjheji. Abantu kufanele bakwazi ukusebenzisa imali kuhle ngokuthi bathenge lokho abakudingako kwaphela bese bathathe imali eseleko bayoyibulunga. Abantu nafundiswa ngokusenzisa imali bakhona ukuhlela ukuthi bazoyisebenzisa bunjani begodu bayibulunge bunjani, benze lokho baqale iindingo abazokuba nazo ekusaseni labo.

== Iinkomba ==
[[category:Imali]]
[[category:Ibulungelo lemali]]</text>
      <sha1>dkm3h7ivmvlrg4eze627502towij7pg</sha1>
    </revision>
  </page>
  <page>
    <title>Umlilo</title>
    <ns>0</ns>
    <id>510</id>
    <revision>
      <id>2551</id>
      <timestamp>2025-03-20T11:50:03Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''Umlilo''' kuyinto ebaswako, ivuthe bese isenzela umtjhiso&lt;ref&gt;Fire - Wikipedia&lt;/ref&gt;. Kuyinto eqakathekileko emaphilweni wabantu.  == Umsebenzi womlilo ==  === Ukufuthumala === Umlilo ukghona ukuletha ukufuthumala emakhayeni. Isibonelo lokha abantu nabezwa amakhaza bayakghona ukubasa umlilo bawothele bese bazizwe bafuthumele.Abanye bakghona ukubasa amahitha ukuthola ukufuthumala&lt;ref&gt;Is Fire Conduction, Convection, or Radiation? Understanding Heat Transfer in Fire - Fi...&quot;</comment>
      <origin>2551</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3081" sha1="fthc0uosrb8ny60m7s0g27blsq5c3zc" xml:space="preserve">'''Umlilo''' kuyinto ebaswako, ivuthe bese isenzela umtjhiso&lt;ref&gt;Fire - Wikipedia&lt;/ref&gt;. Kuyinto eqakathekileko emaphilweni wabantu.

== Umsebenzi womlilo ==

=== Ukufuthumala ===
Umlilo ukghona ukuletha ukufuthumala emakhayeni. Isibonelo lokha abantu nabezwa amakhaza bayakghona ukubasa umlilo bawothele bese bazizwe bafuthumele.Abanye bakghona ukubasa amahitha ukuthola ukufuthumala&lt;ref&gt;Is Fire Conduction, Convection, or Radiation? Understanding Heat Transfer in Fire - Fire Carry&lt;/ref&gt;.

=== Ukukhanya ===
Umlilo ukghona ukuletha ukhanyana ngombana lokha nawungawubasa lapho kumnyama khona kugcina sele kuba nokhunya okuba khona abantu abawubasileko bagcina sele bakghona ukubonana ebumnyameni&lt;ref&gt;Is Fire Conduction, Convection, or Radiation? Understanding Heat Transfer in Fire - Fire Carry&lt;/ref&gt;.

=== Ukupheka ===
Umsebenzi omunye womlilo kukuthi usetjenziselwa ukupheka [[Ukudla]]. Emakhaya  sipheka Ukudla esitofini samahle, emlilweni waphasi nofana esitofini segezi sisebenzisa umlilo okungiwo owenza bona Ukudla kuvuthwe kudleke. Lokhu kutjho bona umlilo kuyinto esiitlhogako ngamalanga ukuphila amaphilo wethu.
Umlilo uyasetjenziswa emafemini ekuncibilikisa iinsimbi nokwenza Amandla wesitimu

== Ubungozi bomlilo ==
Umlilo nanyana uqakathekile kodwana lokho nawungasetjenziswa ngokwefanelo ungaba yingozi khulu, ubulale nofana umotjhe khulu. Umlilo lokha nawungawutjhiya uvutha uwodwa ugagcina sele utjhisa  ibhoduluko nepahla yabantu&lt;ref&gt;bing.com/ck/a?!&amp;&amp;p=4965b2c67fef0572f9c40f3a42ee9255515edae522e69a2eef457803e3a474d1JmltdHM9MTc0MjQyODgwMA&amp;ptn=3&amp;ver=2&amp;hsh=4&amp;fclid=3d4e0e62-479c-632c-2cc9-05ba469c62c6&amp;psq=dangers+of+fire&amp;u=a1aHR0cHM6Ly93d3cuaHNlYmxvZy5jb20vY29tbW9uLWNhdXNlcy1vZi1maXJlLWFuZC1jb25zZXF1ZW5jZXMv&amp;ntb=1&lt;/ref&gt;. 

== Ukuphepha lokha nawusebenzisa umlilo. ==
Umlilo kuyinto engakafaneli bona idlale ngabantwana ngombana ungabatjhisa kabuhlungu nofana bagcine batjhisa imizi yemakhabo. Endaweni lapho kusetjenziswa khona umlilo khulu kufanele bona kube neengubhe zokuqima umlilo ovutha ngendlela engakafaneleki. Emakhaya kungafakwa ama alamu azwelela intuthu ukulekelela abantu bona bakghone ukuzwa lokha nakunalapho kutjha khona. 

Abantu akukafaneli batjhiye amakhandlela, nofana incephu zegway zivutha zodwa ngombana lokho kungadala umlilo ongakalindeleki. Kufanele abantu bangalisi iintambo zegezi ezingasebenzi kuhle zingakalungiswa ngombana nakho lokho kuyakghona ukudala umlilo ongatjhisa indawo nofana umuzi&lt;ref&gt;bing.com/ck/a?!&amp;&amp;p=4965b2c67fef0572f9c40f3a42ee9255515edae522e69a2eef457803e3a474d1JmltdHM9MTc0MjQyODgwMA&amp;ptn=3&amp;ver=2&amp;hsh=4&amp;fclid=3d4e0e62-479c-632c-2cc9-05ba469c62c6&amp;psq=dangers+of+fire&amp;u=a1aHR0cHM6Ly93d3cuaHNlYmxvZy5jb20vY29tbW9uLWNhdXNlcy1vZi1maXJlLWFuZC1jb25zZXF1ZW5jZXMv&amp;ntb=1&lt;/ref&gt;.

== Isiphetho ==
Umlilo kuyinto eqakathekilo emaphilweni wabantu ngombana Usilethela ukukhanya, ukufuthumala begodu sikghona ukupheka Ukudla. Umlilo Kuyinto eyenza bona ipilo ibelula kodwana lokha nawusebenzisa ngaphandle kokutlhogomela ungagcina utjhisa ipahla yabantu nofana ubabulala. Kufanele abantu batlhogomele ukuthi bawusebenzisa njani.</text>
      <sha1>fthc0uosrb8ny60m7s0g27blsq5c3zc</sha1>
    </revision>
    <revision>
      <id>2554</id>
      <parentid>2551</parentid>
      <timestamp>2025-03-20T16:31:40Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2554</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3244" sha1="ftac0lahnn5xd3xbfc8w9brtolgrti7" xml:space="preserve">[[Isimumathi:Umlilo waphasi wokupheka.jpg|thumb|umlilo wokupheka phasi]]
'''Umlilo''' kuyinto ebaswako, ivuthe bese isenzela umtjhiso&lt;ref&gt;Fire - Wikipedia&lt;/ref&gt;. Kuyinto eqakathekileko emaphilweni wabantu.

== Umsebenzi womlilo ==

=== Ukufuthumala ===
Umlilo ukghona ukuletha ukufuthumala emakhayeni. Isibonelo lokha abantu nabezwa amakhaza bayakghona ukubasa umlilo bawothele bese bazizwe bafuthumele.Abanye bakghona ukubasa amahitha ukuthola ukufuthumala&lt;ref&gt;Is Fire Conduction, Convection, or Radiation? Understanding Heat Transfer in Fire - Fire Carry&lt;/ref&gt;.
[[Isimumathi:Umlilo wembawula wokuzifuthumeza.jpg|thumb|umlilo wokufuthumala embawuleni]]

=== Ukukhanya ===
Umlilo ukghona ukuletha ukhanyana ngombana lokha nawungawubasa lapho kumnyama khona kugcina sele kuba nokhunya okuba khona abantu abawubasileko bagcina sele bakghona ukubonana ebumnyameni&lt;ref&gt;Is Fire Conduction, Convection, or Radiation? Understanding Heat Transfer in Fire - Fire Carry&lt;/ref&gt;.

=== Ukupheka ===
Umsebenzi omunye womlilo kukuthi usetjenziselwa ukupheka [[Ukudla]]. Emakhaya  sipheka Ukudla esitofini samahle, emlilweni waphasi nofana esitofini segezi sisebenzisa umlilo okungiwo owenza bona Ukudla kuvuthwe kudleke. Lokhu kutjho bona umlilo kuyinto esiitlhogako ngamalanga ukuphila amaphilo wethu.
Umlilo uyasetjenziswa emafemini ekuncibilikisa iinsimbi nokwenza Amandla wesitimu

== Ubungozi bomlilo ==
Umlilo nanyana uqakathekile kodwana lokho nawungasetjenziswa ngokwefanelo ungaba yingozi khulu, ubulale nofana umotjhe khulu. Umlilo lokha nawungawutjhiya uvutha uwodwa ugagcina sele utjhisa  ibhoduluko nepahla yabantu&lt;ref&gt;bing.com/ck/a?!&amp;&amp;p=4965b2c67fef0572f9c40f3a42ee9255515edae522e69a2eef457803e3a474d1JmltdHM9MTc0MjQyODgwMA&amp;ptn=3&amp;ver=2&amp;hsh=4&amp;fclid=3d4e0e62-479c-632c-2cc9-05ba469c62c6&amp;psq=dangers+of+fire&amp;u=a1aHR0cHM6Ly93d3cuaHNlYmxvZy5jb20vY29tbW9uLWNhdXNlcy1vZi1maXJlLWFuZC1jb25zZXF1ZW5jZXMv&amp;ntb=1&lt;/ref&gt;. 

== Ukuphepha lokha nawusebenzisa umlilo. ==
Umlilo kuyinto engakafaneli bona idlale ngabantwana ngombana ungabatjhisa kabuhlungu nofana bagcine batjhisa imizi yemakhabo. Endaweni lapho kusetjenziswa khona umlilo khulu kufanele bona kube neengubhe zokuqima umlilo ovutha ngendlela engakafaneleki. Emakhaya kungafakwa ama alamu azwelela intuthu ukulekelela abantu bona bakghone ukuzwa lokha nakunalapho kutjha khona. 

Abantu akukafaneli batjhiye amakhandlela, nofana incephu zegway zivutha zodwa ngombana lokho kungadala umlilo ongakalindeleki. Kufanele abantu bangalisi iintambo zegezi ezingasebenzi kuhle zingakalungiswa ngombana nakho lokho kuyakghona ukudala umlilo ongatjhisa indawo nofana umuzi&lt;ref&gt;bing.com/ck/a?!&amp;&amp;p=4965b2c67fef0572f9c40f3a42ee9255515edae522e69a2eef457803e3a474d1JmltdHM9MTc0MjQyODgwMA&amp;ptn=3&amp;ver=2&amp;hsh=4&amp;fclid=3d4e0e62-479c-632c-2cc9-05ba469c62c6&amp;psq=dangers+of+fire&amp;u=a1aHR0cHM6Ly93d3cuaHNlYmxvZy5jb20vY29tbW9uLWNhdXNlcy1vZi1maXJlLWFuZC1jb25zZXF1ZW5jZXMv&amp;ntb=1&lt;/ref&gt;.

== Isiphetho ==
Umlilo kuyinto eqakathekilo emaphilweni wabantu ngombana Usilethela ukukhanya, ukufuthumala begodu sikghona ukupheka Ukudla. Umlilo Kuyinto eyenza bona ipilo ibelula kodwana lokha nawusebenzisa ngaphandle kokutlhogomela ungagcina utjhisa ipahla yabantu nofana ubabulala. Kufanele abantu batlhogomele ukuthi bawusebenzisa njani.</text>
      <sha1>ftac0lahnn5xd3xbfc8w9brtolgrti7</sha1>
    </revision>
    <revision>
      <id>3035</id>
      <parentid>2554</parentid>
      <timestamp>2025-06-06T20:38:08Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>bgvfds</comment>
      <origin>3035</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3325" sha1="6r6awk90xfza977x9sh8kpe29n52uxh" xml:space="preserve">[[Isimumathi:Umlilo waphasi wokupheka.jpg|thumb|umlilo wokupheka phasi]]
'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. Umlilo''' kuyinto ebaswako, ivuthe bese isenzela umtjhiso&lt;ref&gt;Fire - Wikipedia&lt;/ref&gt;. Kuyinto eqakathekileko emaphilweni wabantu.

== Umsebenzi womlilo ==

=== Ukufuthumala ===
Umlilo ukghona ukuletha ukufuthumala emakhayeni. Isibonelo lokha abantu nabezwa amakhaza bayakghona ukubasa umlilo bawothele bese bazizwe bafuthumele.Abanye bakghona ukubasa amahitha ukuthola ukufuthumala&lt;ref&gt;Is Fire Conduction, Convection, or Radiation? Understanding Heat Transfer in Fire - Fire Carry&lt;/ref&gt;.
[[Isimumathi:Umlilo wembawula wokuzifuthumeza.jpg|thumb|umlilo wokufuthumala embawuleni]]

=== Ukukhanya ===
Umlilo ukghona ukuletha ukhanyana ngombana lokha nawungawubasa lapho kumnyama khona kugcina sele kuba nokhunya okuba khona abantu abawubasileko bagcina sele bakghona ukubonana ebumnyameni&lt;ref&gt;Is Fire Conduction, Convection, or Radiation? Understanding Heat Transfer in Fire - Fire Carry&lt;/ref&gt;.

=== Ukupheka ===
Umsebenzi omunye womlilo kukuthi usetjenziselwa ukupheka [[Ukudla]]. Emakhaya  sipheka Ukudla esitofini samahle, emlilweni waphasi nofana esitofini segezi sisebenzisa umlilo okungiwo owenza bona Ukudla kuvuthwe kudleke. Lokhu kutjho bona umlilo kuyinto esiitlhogako ngamalanga ukuphila amaphilo wethu.
Umlilo uyasetjenziswa emafemini ekuncibilikisa iinsimbi nokwenza Amandla wesitimu

== Ubungozi bomlilo ==
Umlilo nanyana uqakathekile kodwana lokho nawungasetjenziswa ngokwefanelo ungaba yingozi khulu, ubulale nofana umotjhe khulu. Umlilo lokha nawungawutjhiya uvutha uwodwa ugagcina sele utjhisa  ibhoduluko nepahla yabantu&lt;ref&gt;bing.com/ck/a?!&amp;&amp;p=4965b2c67fef0572f9c40f3a42ee9255515edae522e69a2eef457803e3a474d1JmltdHM9MTc0MjQyODgwMA&amp;ptn=3&amp;ver=2&amp;hsh=4&amp;fclid=3d4e0e62-479c-632c-2cc9-05ba469c62c6&amp;psq=dangers+of+fire&amp;u=a1aHR0cHM6Ly93d3cuaHNlYmxvZy5jb20vY29tbW9uLWNhdXNlcy1vZi1maXJlLWFuZC1jb25zZXF1ZW5jZXMv&amp;ntb=1&lt;/ref&gt;. 

== Ukuphepha lokha nawusebenzisa umlilo. ==
Umlilo kuyinto engakafaneli bona idlale ngabantwana ngombana ungabatjhisa kabuhlungu nofana bagcine batjhisa imizi yemakhabo. Endaweni lapho kusetjenziswa khona umlilo khulu kufanele bona kube neengubhe zokuqima umlilo ovutha ngendlela engakafaneleki. Emakhaya kungafakwa ama alamu azwelela intuthu ukulekelela abantu bona bakghone ukuzwa lokha nakunalapho kutjha khona. 

Abantu akukafaneli batjhiye amakhandlela, nofana incephu zegway zivutha zodwa ngombana lokho kungadala umlilo ongakalindeleki. Kufanele abantu bangalisi iintambo zegezi ezingasebenzi kuhle zingakalungiswa ngombana nakho lokho kuyakghona ukudala umlilo ongatjhisa indawo nofana umuzi&lt;ref&gt;bing.com/ck/a?!&amp;&amp;p=4965b2c67fef0572f9c40f3a42ee9255515edae522e69a2eef457803e3a474d1JmltdHM9MTc0MjQyODgwMA&amp;ptn=3&amp;ver=2&amp;hsh=4&amp;fclid=3d4e0e62-479c-632c-2cc9-05ba469c62c6&amp;psq=dangers+of+fire&amp;u=a1aHR0cHM6Ly93d3cuaHNlYmxvZy5jb20vY29tbW9uLWNhdXNlcy1vZi1maXJlLWFuZC1jb25zZXF1ZW5jZXMv&amp;ntb=1&lt;/ref&gt;.

== Isiphetho ==
Umlilo kuyinto eqakathekilo emaphilweni wabantu ngombana Usilethela ukukhanya, ukufuthumala begodu sikghona ukupheka Ukudla. Umlilo Kuyinto eyenza bona ipilo ibelula kodwana lokha nawusebenzisa ngaphandle kokutlhogomela ungagcina utjhisa ipahla yabantu nofana ubabulala. Kufanele abantu batlhogomele ukuthi bawusebenzisa njani.</text>
      <sha1>6r6awk90xfza977x9sh8kpe29n52uxh</sha1>
    </revision>
    <revision>
      <id>3056</id>
      <parentid>3035</parentid>
      <timestamp>2025-06-07T03:05:22Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Nqobile69|Nqobile69]]</comment>
      <origin>2554</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3244" sha1="ftac0lahnn5xd3xbfc8w9brtolgrti7" xml:space="preserve">[[Isimumathi:Umlilo waphasi wokupheka.jpg|thumb|umlilo wokupheka phasi]]
'''Umlilo''' kuyinto ebaswako, ivuthe bese isenzela umtjhiso&lt;ref&gt;Fire - Wikipedia&lt;/ref&gt;. Kuyinto eqakathekileko emaphilweni wabantu.

== Umsebenzi womlilo ==

=== Ukufuthumala ===
Umlilo ukghona ukuletha ukufuthumala emakhayeni. Isibonelo lokha abantu nabezwa amakhaza bayakghona ukubasa umlilo bawothele bese bazizwe bafuthumele.Abanye bakghona ukubasa amahitha ukuthola ukufuthumala&lt;ref&gt;Is Fire Conduction, Convection, or Radiation? Understanding Heat Transfer in Fire - Fire Carry&lt;/ref&gt;.
[[Isimumathi:Umlilo wembawula wokuzifuthumeza.jpg|thumb|umlilo wokufuthumala embawuleni]]

=== Ukukhanya ===
Umlilo ukghona ukuletha ukhanyana ngombana lokha nawungawubasa lapho kumnyama khona kugcina sele kuba nokhunya okuba khona abantu abawubasileko bagcina sele bakghona ukubonana ebumnyameni&lt;ref&gt;Is Fire Conduction, Convection, or Radiation? Understanding Heat Transfer in Fire - Fire Carry&lt;/ref&gt;.

=== Ukupheka ===
Umsebenzi omunye womlilo kukuthi usetjenziselwa ukupheka [[Ukudla]]. Emakhaya  sipheka Ukudla esitofini samahle, emlilweni waphasi nofana esitofini segezi sisebenzisa umlilo okungiwo owenza bona Ukudla kuvuthwe kudleke. Lokhu kutjho bona umlilo kuyinto esiitlhogako ngamalanga ukuphila amaphilo wethu.
Umlilo uyasetjenziswa emafemini ekuncibilikisa iinsimbi nokwenza Amandla wesitimu

== Ubungozi bomlilo ==
Umlilo nanyana uqakathekile kodwana lokho nawungasetjenziswa ngokwefanelo ungaba yingozi khulu, ubulale nofana umotjhe khulu. Umlilo lokha nawungawutjhiya uvutha uwodwa ugagcina sele utjhisa  ibhoduluko nepahla yabantu&lt;ref&gt;bing.com/ck/a?!&amp;&amp;p=4965b2c67fef0572f9c40f3a42ee9255515edae522e69a2eef457803e3a474d1JmltdHM9MTc0MjQyODgwMA&amp;ptn=3&amp;ver=2&amp;hsh=4&amp;fclid=3d4e0e62-479c-632c-2cc9-05ba469c62c6&amp;psq=dangers+of+fire&amp;u=a1aHR0cHM6Ly93d3cuaHNlYmxvZy5jb20vY29tbW9uLWNhdXNlcy1vZi1maXJlLWFuZC1jb25zZXF1ZW5jZXMv&amp;ntb=1&lt;/ref&gt;. 

== Ukuphepha lokha nawusebenzisa umlilo. ==
Umlilo kuyinto engakafaneli bona idlale ngabantwana ngombana ungabatjhisa kabuhlungu nofana bagcine batjhisa imizi yemakhabo. Endaweni lapho kusetjenziswa khona umlilo khulu kufanele bona kube neengubhe zokuqima umlilo ovutha ngendlela engakafaneleki. Emakhaya kungafakwa ama alamu azwelela intuthu ukulekelela abantu bona bakghone ukuzwa lokha nakunalapho kutjha khona. 

Abantu akukafaneli batjhiye amakhandlela, nofana incephu zegway zivutha zodwa ngombana lokho kungadala umlilo ongakalindeleki. Kufanele abantu bangalisi iintambo zegezi ezingasebenzi kuhle zingakalungiswa ngombana nakho lokho kuyakghona ukudala umlilo ongatjhisa indawo nofana umuzi&lt;ref&gt;bing.com/ck/a?!&amp;&amp;p=4965b2c67fef0572f9c40f3a42ee9255515edae522e69a2eef457803e3a474d1JmltdHM9MTc0MjQyODgwMA&amp;ptn=3&amp;ver=2&amp;hsh=4&amp;fclid=3d4e0e62-479c-632c-2cc9-05ba469c62c6&amp;psq=dangers+of+fire&amp;u=a1aHR0cHM6Ly93d3cuaHNlYmxvZy5jb20vY29tbW9uLWNhdXNlcy1vZi1maXJlLWFuZC1jb25zZXF1ZW5jZXMv&amp;ntb=1&lt;/ref&gt;.

== Isiphetho ==
Umlilo kuyinto eqakathekilo emaphilweni wabantu ngombana Usilethela ukukhanya, ukufuthumala begodu sikghona ukupheka Ukudla. Umlilo Kuyinto eyenza bona ipilo ibelula kodwana lokha nawusebenzisa ngaphandle kokutlhogomela ungagcina utjhisa ipahla yabantu nofana ubabulala. Kufanele abantu batlhogomele ukuthi bawusebenzisa njani.</text>
      <sha1>ftac0lahnn5xd3xbfc8w9brtolgrti7</sha1>
    </revision>
  </page>
  <page>
    <title>Amathambo</title>
    <ns>0</ns>
    <id>511</id>
    <revision>
      <id>2552</id>
      <timestamp>2025-03-20T16:11:50Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;Amathambo  Amathabo kuyinto  ethekgha umzimba bona ukghone ukujama begodu ubenejamo.Amathambo womzimba nakapheleleko ama-206. Amathambo la woke anikela umzimba isekelo lokujama begodu nevikeleko&lt;ref&gt;Bone | Definition, Anatomy, &amp; Composition | Britannica&lt;/ref&gt;.  == Imihlobo yamathambo == Amathambo amade  Amathambo amade  atholakala ezandleni neenyaweni&lt;ref&gt;Long Bones – Anatomy, Examples, Function, &amp; Labeled Diagram&lt;/ref&gt;.   Amathambo amafitjhani  Lawa kumathambo abumbek...&quot;</comment>
      <origin>2552</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2568" sha1="qxd698gibbs3u8jun34p5xrivhjx73g" xml:space="preserve">Amathambo

Amathabo kuyinto  ethekgha umzimba bona ukghone ukujama begodu ubenejamo.Amathambo womzimba nakapheleleko ama-206. Amathambo la woke anikela umzimba isekelo lokujama begodu nevikeleko&lt;ref&gt;Bone | Definition, Anatomy, &amp; Composition | Britannica&lt;/ref&gt;.

== Imihlobo yamathambo ==
Amathambo amade

Amathambo amade  atholakala ezandleni neenyaweni&lt;ref&gt;Long Bones – Anatomy, Examples, Function, &amp; Labeled Diagram&lt;/ref&gt;. 

Amathambo amafitjhani

Lawa kumathambo abumbeke njengebhoksi atholakala endololwaneni nasemkantjeni.

AMathambo apataleleko

Lawa amhlobo owondileko begodu opataleleko. Atholakala ehloko, ethambeni elihlukanisa imbambo, Kanye nakizo [[imbambo]]&lt;ref&gt;Long Bones – Anatomy, Examples, Function, &amp; Labeled Diagram&lt;/ref&gt;.

Amathambo angakabumbeki

Mathambo angaweli ndawo kweminye imihlobo yamathambo kodwana nawo kumathambo womzimba. Isibonele ithambo lomgogodhla  neledini.

Amathambo wesesamoid
Mathambo amancani ahlangana nemisipha. Isibonelo lithabo elihlanganisa idolo.

== Umsebenzi wamathambo ==
Amathambo asebenza ukunikela umzimba isekelo, akwenza bona ukgohone ukujama njengomuntu begodu ukghone nokukhamba.Amathambo avikela izitho zomzimba eziqakathekileko zanga phakathi zomzimba ezifana nehliziyo, [[amaphaphu]]. Amathambo ayazivalela ukuze  zingalimamali lula&lt;ref&gt;Florencio-Silva, R., Sasso, G.R.D.S., Sasso-Cerri, E., Simões, M.J. and Cerri, P.S., 2015. Biology of bone tissue: structure, function, and factors that influence bone cells. ''BioMed research international'', ''2015''(1), p.421746.&lt;/ref&gt;.

Ukukhamba

Amathambo enza bona sikghone ukukhamba ngombana abambene nemisipha bese kube lula ukuthi umuntu asuke endawen yinye aye kwenye ngaphandle kobudisi.

Ukwakha amaseli 

Amathambo Ngiwo enza amaseli amhlophe nabovu weengaz Kanye amaplatelets.

Ukufaka amaminerali

Amathambo afaka amaminerali afana ne-Calcium,phosphorus  ekungiwo enza bona amathambo ahlale aqinile.Kuqakathekile bona umuntu anakelele amathambo wakhe bona ahle anepilo ukuze azokukghona ukubalekela amalwele wamathambo afana ne arthritis, nofana i-osteoporosis&lt;ref&gt;Weatherholt, A.M., Fuchs, R.K. and Warden, S.J., 2012. Specialized connective tissue: bone, the structural framework of the upper extremity. ''Journal of Hand Therapy'', ''25''(2), pp.123-132.&lt;/ref&gt;.

== Isiphetho ==
Amathambo adlala indima ekulu emzimbeni womuntu ngomba aletha ivikeleko ezithweni zangaphakathi zomzimba. Enza bona umuntu akghone ukukhamba begodu enza umzimba ubumbeke. Kuqakathekile bona siwanakekee amathambo ukubalekela izifo eziphathelene nemathambo emzimbeni.</text>
      <sha1>qxd698gibbs3u8jun34p5xrivhjx73g</sha1>
    </revision>
    <revision>
      <id>2672</id>
      <parentid>2552</parentid>
      <timestamp>2025-04-21T15:45:55Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2672</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2572" sha1="t7ojstbaife9b7j97d9ebi1bywt8fw8" xml:space="preserve">Amathambo

Amathabo kuyinto  ethekgha umzimba bona ukghone ukujama begodu ubenejamo.Amathambo womzimba nakapheleleko ama-206. Amathambo la woke anikela umzimba isekelo lokujama begodu nevikeleko&lt;ref&gt;Bone | Definition, Anatomy, &amp; Composition | Britannica&lt;/ref&gt;.

== Imihlobo yamathambo ==
Amathambo amade

Amathambo amade  atholakala ezandleni neenyaweni&lt;ref&gt;Long Bones – Anatomy, Examples, Function, &amp; Labeled Diagram&lt;/ref&gt;. 

Amathambo amafitjhani

Lawa kumathambo abumbeke njengebhoksi atholakala endololwaneni nasemkantjeni.

AMathambo apataleleko

Lawa amhlobo owondileko begodu opataleleko. Atholakala ehloko, ethambeni elihlukanisa imbambo, Kanye nakizo [[imbambo]]&lt;ref&gt;Long Bones – Anatomy, Examples, Function, &amp; Labeled Diagram&lt;/ref&gt;.

Amathambo angakabumbeki

Mathambo angaweli ndawo kweminye imihlobo yamathambo kodwana nawo kumathambo womzimba. Isibonelo ithambo lomgogodhla  neledinini.

Amathambo wesesamoid

Mathambo amancani ahlangana nemisipha. Isibonelo lithambo elihlanganisa idolo.

== Umsebenzi wamathambo ==
Amathambo asebenza ukunikela umzimba isekelo, akwenza bona ukgohone ukujama njengomuntu begodu ukghone nokukhamba.Amathambo avikela izitho zomzimba eziqakathekileko zanga phakathi zomzimba ezifana nehliziyo, [[amaphaphu]]. Amathambo ayazivalela ukuze  zingalimamali lula&lt;ref&gt;Florencio-Silva, R., Sasso, G.R.D.S., Sasso-Cerri, E., Simões, M.J. and Cerri, P.S., 2015. Biology of bone tissue: structure, function, and factors that influence bone cells. ''BioMed research international'', ''2015''(1), p.421746.&lt;/ref&gt;.

Ukukhamba

Amathambo enza bona sikghone ukukhamba ngombana abambene nemisipha bese kube lula ukuthi umuntu asuke endawen yinye aye kwenye ngaphandle kobudisi.

Ukwakha amaseli 

Amathambo Ngiwo enza amaseli amhlophe nabovu weengaz Kanye amaplatelets.

Ukufaka amaminerali

Amathambo afaka amaminerali afana ne-Calcium,phosphorus  ekungiwo enza bona amathambo ahlale aqinile.Kuqakathekile bona umuntu anakelele amathambo wakhe bona ahle anepilo ukuze azokukghona ukubalekela amalwele wamathambo afana ne arthritis, nofana i-osteoporosis&lt;ref&gt;Weatherholt, A.M., Fuchs, R.K. and Warden, S.J., 2012. Specialized connective tissue: bone, the structural framework of the upper extremity. ''Journal of Hand Therapy'', ''25''(2), pp.123-132.&lt;/ref&gt;.

== Isiphetho ==
Amathambo adlala indima ekulu emzimbeni womuntu ngomba aletha ivikeleko ezithweni zangaphakathi zomzimba. Enza bona umuntu akghone ukukhamba begodu enza umzimba ubumbeke. Kuqakathekile bona siwanakekee amathambo ukubalekela izifo eziphathelene nemathambo emzimbeni.</text>
      <sha1>t7ojstbaife9b7j97d9ebi1bywt8fw8</sha1>
    </revision>
    <revision>
      <id>2800</id>
      <parentid>2672</parentid>
      <timestamp>2025-05-06T12:35:56Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2800</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2579" sha1="i04xzkeqq75n9m5z83240qjkbuz44v4" xml:space="preserve">Amathambo

'''Amathambo''' kuyinto  ethekgha umzimba bona ukghone ukujama begodu ubenejamo.Amathambo womzimba nakapheleleko ama-206. Amathambo la woke anikela umzimba isekelo lokujama begodu nevikeleko&lt;ref&gt;Bone | Definition, Anatomy, &amp; Composition | Britannica&lt;/ref&gt;.

== Imihlobo yamathambo ==
Amathambo amade

Amathambo amade  atholakala ezandleni neenyaweni&lt;ref&gt;Long Bones – Anatomy, Examples, Function, &amp; Labeled Diagram&lt;/ref&gt;. 

Amathambo amafitjhani

Lawa kumathambo abumbeke njengebhoksi atholakala endololwaneni nasemkantjeni.

AMathambo apataleleko

Lawa amhlobo owondileko begodu opataleleko. Atholakala ehloko, ethambeni elihlukanisa imbambo, Kanye nakizo [[imbambo]]&lt;ref&gt;Long Bones – Anatomy, Examples, Function, &amp; Labeled Diagram&lt;/ref&gt;.

Amathambo angakabumbeki

Mathambo angaweli ndawo kweminye imihlobo yamathambo kodwana nawo kumathambo womzimba. Isibonelo ithambo lomgogodhla  neledinini.

Amathambo wesesamoid

Mathambo amancani ahlangana nemisipha. Isibonelo lithambo elihlanganisa idolo.

== Umsebenzi wamathambo ==
Amathambo asebenza ukunikela umzimba isekelo, akwenza bona ukgohone ukujama njengomuntu begodu ukghone nokukhamba.Amathambo avikela izitho zomzimba eziqakathekileko zanga phakathi zomzimba ezifana nehliziyo, [[amaphaphu]]. Amathambo ayazivalela ukuze  zingalimamali lula&lt;ref&gt;Florencio-Silva, R., Sasso, G.R.D.S., Sasso-Cerri, E., Simões, M.J. and Cerri, P.S., 2015. Biology of bone tissue: structure, function, and factors that influence bone cells. ''BioMed research international'', ''2015''(1), p.421746.&lt;/ref&gt;.

Ukukhamba

Amathambo enza bona sikghone ukukhamba ngombana abambene nemisipha bese kube lula ukuthi umuntu asuke endawen yinye aye kwenye ngaphandle kobudisi.

Ukwakha amaseli 

Amathambo Ngiwo enza amaseli amhlophe nabovu weengaz Kanye amaplatelets.

Ukufaka amaminerali

Amathambo afaka amaminerali afana ne-Calcium,phosphorus  ekungiwo enza bona amathambo ahlale aqinile.Kuqakathekile bona umuntu anakelele amathambo wakhe bona ahle anepilo ukuze azokukghona ukubalekela amalwele wamathambo afana ne arthritis, nofana i-osteoporosis&lt;ref&gt;Weatherholt, A.M., Fuchs, R.K. and Warden, S.J., 2012. Specialized connective tissue: bone, the structural framework of the upper extremity. ''Journal of Hand Therapy'', ''25''(2), pp.123-132.&lt;/ref&gt;.

== Isiphetho ==
Amathambo adlala indima ekulu emzimbeni womuntu ngomba aletha ivikeleko ezithweni zangaphakathi zomzimba. Enza bona umuntu akghone ukukhamba begodu enza umzimba ubumbeke. Kuqakathekile bona siwanakekee amathambo ukubalekela izifo eziphathelene nemathambo emzimbeni.</text>
      <sha1>i04xzkeqq75n9m5z83240qjkbuz44v4</sha1>
    </revision>
    <revision>
      <id>2801</id>
      <parentid>2800</parentid>
      <timestamp>2025-05-06T12:37:53Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2801</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2578" sha1="70p213ah61yxlycam9tncfiyj0qnqim" xml:space="preserve">Amathambo

'''Amathambo''' kuyinto  ethekgha umzimba bona ukghone ukujama begodu ubenejamo.Amathambo womzimba nakapheleleko ama-206. Amathambo la woke anikela umzimba isekelo lokujama begodu nevikeleko&lt;ref&gt;Bone | Definition, Anatomy, &amp; Composition | Britannica&lt;/ref&gt;.

== Imihlobo yamathambo ==
Amathambo amade

Amathambo amade  atholakala ezandleni neenyaweni&lt;ref&gt;Long Bones – Anatomy, Examples, Function, &amp; Labeled Diagram&lt;/ref&gt;. 

Amathambo amafitjhani

Lawa kumathambo abumbeke njengebhoksi atholakala endololwaneni nasemkantjeni.

AMathambo apataleleko

Lawa amhlobo owondileko begodu opataleleko. Atholakala ehloko, ethambeni elihlukanisa imbambo, Kanye nakizo [[imbambo]]&lt;ref&gt;Long Bones – Anatomy, Examples, Function, &amp; Labeled Diagram&lt;/ref&gt;.

Amathambo angakabumbeki

Mathambo angaweli ndawo kweminye imihlobo yamathambo kodwana nawo kumathambo womzimba. Isibonelo ithambo lomgogodhla  neledinini.

Amathambo wesesamoid

Mathambo amancani ahlangana nemisipha. Isibonelo lithambo elihlanganisa idolo.

== Umsebenzi wamathambo ==
Amathambo asebenza ukunikela umzimba isekelo, akwenza bona ukghone ukujama njengomuntu begodu ukghone nokukhamba.Amathambo avikela izitho zomzimba eziqakathekileko zanga phakathi ezifana nehliziyo, [[amaphaphu]]. Amathambo avalela izitho lezi ukuze  zingalimamali lula&lt;ref&gt;Florencio-Silva, R., Sasso, G.R.D.S., Sasso-Cerri, E., Simões, M.J. and Cerri, P.S., 2015. Biology of bone tissue: structure, function, and factors that influence bone cells. ''BioMed research international'', ''2015''(1), p.421746.&lt;/ref&gt;.

Ukukhamba

Amathambo enza bona sikghone ukukhamba ngombana abambene nemisipha bese kube lula ukuthi umuntu asuke endawen yinye aye kwenye ngaphandle kobudisi.

Ukwakha amaseli 

Amathambo Ngiwo enza amaseli amhlophe nabovu weengazi Kanye amaplatelets.

Ukufaka amaminerali

Amathambo afaka amaminerali afana ne-Calcium,phosphorus  ekungiwo enza bona amathambo ahlale aqinile.Kuqakathekile bona umuntu anakelele amathambo wakhe bona ahle anepilo ukuze azokukghona ukubalekela amalwele wamathambo afana ne arthritis, nofana i-osteoporosis&lt;ref&gt;Weatherholt, A.M., Fuchs, R.K. and Warden, S.J., 2012. Specialized connective tissue: bone, the structural framework of the upper extremity. ''Journal of Hand Therapy'', ''25''(2), pp.123-132.&lt;/ref&gt;.

== Isiphetho ==
Amathambo adlala indima ekulu emzimbeni womuntu ngomba aletha ivikeleko ezithweni zangaphakathi zomzimba. Enza bona umuntu akghone ukukhamba begodu enza umzimba ubumbeke. Kuqakathekile bona siwanakekee amathambo ukubalekela izifo eziphathelene nemathambo emzimbeni.</text>
      <sha1>70p213ah61yxlycam9tncfiyj0qnqim</sha1>
    </revision>
    <revision>
      <id>2802</id>
      <parentid>2801</parentid>
      <timestamp>2025-05-06T12:39:38Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2802</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2579" sha1="qmvuz8h4mycpzmcd6flodwq6t9pjkjh" xml:space="preserve">Amathambo

'''Amathambo''' kuyinto  ethekgha umzimba bona ukghone ukujama begodu ubenejamo.Amathambo womzimba nakapheleleko ama-206. Amathambo la woke anikela umzimba isekelo lokujama begodu nevikeleko&lt;ref&gt;Bone | Definition, Anatomy, &amp; Composition | Britannica&lt;/ref&gt;.

== Imihlobo yamathambo ==
Amathambo amade

Amathambo amade  atholakala ezandleni neenyaweni&lt;ref&gt;Long Bones – Anatomy, Examples, Function, &amp; Labeled Diagram&lt;/ref&gt;. 

Amathambo amafitjhani

Lawa kumathambo abumbeke njengebhoksi atholakala endololwaneni nasemkantjeni.

AMathambo apataleleko

Lawa amhlobo owondileko begodu opataleleko. Atholakala ehloko, ethambeni elihlukanisa imbambo, Kanye nakizo [[imbambo]]&lt;ref&gt;Long Bones – Anatomy, Examples, Function, &amp; Labeled Diagram&lt;/ref&gt;.

Amathambo angakabumbeki

Mathambo angaweli ndawo kweminye imihlobo yamathambo kodwana nawo kumathambo womzimba. Isibonelo ithambo lomgogodhla  neledinini.

Amathambo wesesamoid

Mathambo amancani ahlangana nemisipha. Isibonelo lithambo elihlanganisa idolo.

== Umsebenzi wamathambo ==
Amathambo asebenza ukunikela umzimba isekelo, akwenza bona ukghone ukujama njengomuntu begodu ukghone nokukhamba.Amathambo avikela izitho zomzimba eziqakathekileko zanga phakathi ezifana nehliziyo, [[amaphaphu]]. Amathambo avalela izitho lezi ukuze  zingalimamali lula&lt;ref&gt;Florencio-Silva, R., Sasso, G.R.D.S., Sasso-Cerri, E., Simões, M.J. and Cerri, P.S., 2015. Biology of bone tissue: structure, function, and factors that influence bone cells. ''BioMed research international'', ''2015''(1), p.421746.&lt;/ref&gt;.

Ukukhamba

Amathambo enza bona sikghone ukukhamba ngombana abambene nemisipha bese kube lula ukuthi umuntu asuke endawen yinye aye kwenye ngaphandle kobudisi.

Ukwakha amaseli 

Amathambo Ngiwo enza amaseli amhlophe nabovu weengazi Kanye amaplatelets.

Ukufaka amaminerali

Amathambo afaka amaminerali afana ne-Calcium,phosphorus  ekungiwo enza bona amathambo ahlale aqinile.Kuqakathekile bona umuntu anakelele amathambo wakhe bona ahle anepilo ukuze azokukghona ukubalekela amalwele wamathambo afana ne arthritis, nofana i-osteoporosis&lt;ref&gt;Weatherholt, A.M., Fuchs, R.K. and Warden, S.J., 2012. Specialized connective tissue: bone, the structural framework of the upper extremity. ''Journal of Hand Therapy'', ''25''(2), pp.123-132.&lt;/ref&gt;.

== Isiphetho ==
Amathambo adlala indima ekulu emzimbeni womuntu ngomba aletha ivikeleko ezithweni zangaphakathi zomzimba. Enza bona umuntu akghone ukukhamba begodu enza umzimba ubumbeke. Kuqakathekile bona siwanakekele amathambo ukubalekela izifo eziphathelene nemathambo emzimbeni.</text>
      <sha1>qmvuz8h4mycpzmcd6flodwq6t9pjkjh</sha1>
    </revision>
    <revision>
      <id>2826</id>
      <parentid>2802</parentid>
      <timestamp>2025-05-19T11:07:04Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2826</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2584" sha1="pt590wsy6v2ud857j29jr49g28ar54f" xml:space="preserve">== Amathambo ==
'''Amathambo''' kuyinto  ethekgha umzimba bona ukghone ukujama begodu ubenejamo.Amathambo womzimba nakapheleleko ama-206. Amathambo la woke anikela umzimba isekelo lokujama begodu nevikeleko&lt;ref&gt;Bone | Definition, Anatomy, &amp; Composition | Britannica&lt;/ref&gt;.

== Imihlobo yamathambo ==
Amathambo amade

Amathambo amade  atholakala ezandleni neenyaweni&lt;ref&gt;Long Bones – Anatomy, Examples, Function, &amp; Labeled Diagram&lt;/ref&gt;. 

Amathambo amafitjhani

Lawa kumathambo abumbeke njengebhoksi atholakala endololwaneni nasemkantjeni.

AMathambo apataleleko

Lawa amhlobo owondileko begodu opataleleko. Atholakala ehloko, ethambeni elihlukanisa imbambo, Kanye nakizo [[imbambo]]&lt;ref&gt;Long Bones – Anatomy, Examples, Function, &amp; Labeled Diagram&lt;/ref&gt;.

Amathambo angakabumbeki

Mathambo angaweli ndawo kweminye imihlobo yamathambo kodwana nawo kumathambo womzimba. Isibonelo ithambo lomgogodhla  neledinini.

Amathambo wesesamoid

Mathambo amancani ahlangana nemisipha. Isibonelo lithambo elihlanganisa idolo.

== Umsebenzi wamathambo ==
Amathambo asebenza ukunikela umzimba isekelo, akwenza bona ukghone ukujama njengomuntu begodu ukghone nokukhamba.Amathambo avikela izitho zomzimba eziqakathekileko zanga phakathi ezifana nehliziyo, [[amaphaphu]]. Amathambo avalela izitho lezi ukuze  zingalimamali lula&lt;ref&gt;Florencio-Silva, R., Sasso, G.R.D.S., Sasso-Cerri, E., Simões, M.J. and Cerri, P.S., 2015. Biology of bone tissue: structure, function, and factors that influence bone cells. ''BioMed research international'', ''2015''(1), p.421746.&lt;/ref&gt;.

Ukukhamba

Amathambo enza bona sikghone ukukhamba ngombana abambene nemisipha bese kube lula ukuthi umuntu asuke endawen yinye aye kwenye ngaphandle kobudisi.

Ukwakha amaseli 

Amathambo Ngiwo enza amaseli amhlophe nabovu weengazi Kanye amaplatelets.

Ukufaka amaminerali

Amathambo afaka amaminerali afana ne-Calcium,phosphorus  ekungiwo enza bona amathambo ahlale aqinile.Kuqakathekile bona umuntu anakelele amathambo wakhe bona ahle anepilo ukuze azokukghona ukubalekela amalwele wamathambo afana ne arthritis, nofana i-osteoporosis&lt;ref&gt;Weatherholt, A.M., Fuchs, R.K. and Warden, S.J., 2012. Specialized connective tissue: bone, the structural framework of the upper extremity. ''Journal of Hand Therapy'', ''25''(2), pp.123-132.&lt;/ref&gt;.

== Isiphetho ==
Amathambo adlala indima ekulu emzimbeni womuntu ngomba aletha ivikeleko ezithweni zangaphakathi zomzimba. Enza bona umuntu akghone ukukhamba begodu enza umzimba ubumbeke. Kuqakathekile bona siwanakekele amathambo ukubalekela izifo eziphathelene nemathambo emzimbeni.</text>
      <sha1>pt590wsy6v2ud857j29jr49g28ar54f</sha1>
    </revision>
    <revision>
      <id>2984</id>
      <parentid>2826</parentid>
      <timestamp>2025-06-06T20:11:12Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>mujnyhtbgrvfecd</comment>
      <origin>2984</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2672" sha1="ch25x7aabzloyvo01klll17rxwx75v8" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.'''

== Amathambo ==
'''Amathambo''' kuyinto  ethekgha umzimba bona ukghone ukujama begodu ubenejamo.Amathambo womzimba nakapheleleko ama-206. Amathambo la woke anikela umzimba isekelo lokujama begodu nevikeleko&lt;ref&gt;Bone | Definition, Anatomy, &amp; Composition | Britannica&lt;/ref&gt;.

== Imihlobo yamathambo ==
Amathambo amade

Amathambo amade  atholakala ezandleni neenyaweni&lt;ref&gt;Long Bones – Anatomy, Examples, Function, &amp; Labeled Diagram&lt;/ref&gt;. 

Amathambo amafitjhani

Lawa kumathambo abumbeke njengebhoksi atholakala endololwaneni nasemkantjeni.

AMathambo apataleleko

Lawa amhlobo owondileko begodu opataleleko. Atholakala ehloko, ethambeni elihlukanisa imbambo, Kanye nakizo [[imbambo]]&lt;ref&gt;Long Bones – Anatomy, Examples, Function, &amp; Labeled Diagram&lt;/ref&gt;.

Amathambo angakabumbeki

Mathambo angaweli ndawo kweminye imihlobo yamathambo kodwana nawo kumathambo womzimba. Isibonelo ithambo lomgogodhla  neledinini.

Amathambo wesesamoid

Mathambo amancani ahlangana nemisipha. Isibonelo lithambo elihlanganisa idolo.

== Umsebenzi wamathambo ==
Amathambo asebenza ukunikela umzimba isekelo, akwenza bona ukghone ukujama njengomuntu begodu ukghone nokukhamba.Amathambo avikela izitho zomzimba eziqakathekileko zanga phakathi ezifana nehliziyo, [[amaphaphu]]. Amathambo avalela izitho lezi ukuze  zingalimamali lula&lt;ref&gt;Florencio-Silva, R., Sasso, G.R.D.S., Sasso-Cerri, E., Simões, M.J. and Cerri, P.S., 2015. Biology of bone tissue: structure, function, and factors that influence bone cells. ''BioMed research international'', ''2015''(1), p.421746.&lt;/ref&gt;.

Ukukhamba

Amathambo enza bona sikghone ukukhamba ngombana abambene nemisipha bese kube lula ukuthi umuntu asuke endawen yinye aye kwenye ngaphandle kobudisi.

Ukwakha amaseli 

Amathambo Ngiwo enza amaseli amhlophe nabovu weengazi Kanye amaplatelets.

Ukufaka amaminerali

Amathambo afaka amaminerali afana ne-Calcium,phosphorus  ekungiwo enza bona amathambo ahlale aqinile.Kuqakathekile bona umuntu anakelele amathambo wakhe bona ahle anepilo ukuze azokukghona ukubalekela amalwele wamathambo afana ne arthritis, nofana i-osteoporosis&lt;ref&gt;Weatherholt, A.M., Fuchs, R.K. and Warden, S.J., 2012. Specialized connective tissue: bone, the structural framework of the upper extremity. ''Journal of Hand Therapy'', ''25''(2), pp.123-132.&lt;/ref&gt;.

== Isiphetho ==
Amathambo adlala indima ekulu emzimbeni womuntu ngomba aletha ivikeleko ezithweni zangaphakathi zomzimba. Enza bona umuntu akghone ukukhamba begodu enza umzimba ubumbeke. Kuqakathekile bona siwanakekele amathambo ukubalekela izifo eziphathelene nemathambo emzimbeni.</text>
      <sha1>ch25x7aabzloyvo01klll17rxwx75v8</sha1>
    </revision>
    <revision>
      <id>3080</id>
      <parentid>2984</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Nqobile69|Nqobile69]]</comment>
      <origin>2826</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2584" sha1="pt590wsy6v2ud857j29jr49g28ar54f" xml:space="preserve">== Amathambo ==
'''Amathambo''' kuyinto  ethekgha umzimba bona ukghone ukujama begodu ubenejamo.Amathambo womzimba nakapheleleko ama-206. Amathambo la woke anikela umzimba isekelo lokujama begodu nevikeleko&lt;ref&gt;Bone | Definition, Anatomy, &amp; Composition | Britannica&lt;/ref&gt;.

== Imihlobo yamathambo ==
Amathambo amade

Amathambo amade  atholakala ezandleni neenyaweni&lt;ref&gt;Long Bones – Anatomy, Examples, Function, &amp; Labeled Diagram&lt;/ref&gt;. 

Amathambo amafitjhani

Lawa kumathambo abumbeke njengebhoksi atholakala endololwaneni nasemkantjeni.

AMathambo apataleleko

Lawa amhlobo owondileko begodu opataleleko. Atholakala ehloko, ethambeni elihlukanisa imbambo, Kanye nakizo [[imbambo]]&lt;ref&gt;Long Bones – Anatomy, Examples, Function, &amp; Labeled Diagram&lt;/ref&gt;.

Amathambo angakabumbeki

Mathambo angaweli ndawo kweminye imihlobo yamathambo kodwana nawo kumathambo womzimba. Isibonelo ithambo lomgogodhla  neledinini.

Amathambo wesesamoid

Mathambo amancani ahlangana nemisipha. Isibonelo lithambo elihlanganisa idolo.

== Umsebenzi wamathambo ==
Amathambo asebenza ukunikela umzimba isekelo, akwenza bona ukghone ukujama njengomuntu begodu ukghone nokukhamba.Amathambo avikela izitho zomzimba eziqakathekileko zanga phakathi ezifana nehliziyo, [[amaphaphu]]. Amathambo avalela izitho lezi ukuze  zingalimamali lula&lt;ref&gt;Florencio-Silva, R., Sasso, G.R.D.S., Sasso-Cerri, E., Simões, M.J. and Cerri, P.S., 2015. Biology of bone tissue: structure, function, and factors that influence bone cells. ''BioMed research international'', ''2015''(1), p.421746.&lt;/ref&gt;.

Ukukhamba

Amathambo enza bona sikghone ukukhamba ngombana abambene nemisipha bese kube lula ukuthi umuntu asuke endawen yinye aye kwenye ngaphandle kobudisi.

Ukwakha amaseli 

Amathambo Ngiwo enza amaseli amhlophe nabovu weengazi Kanye amaplatelets.

Ukufaka amaminerali

Amathambo afaka amaminerali afana ne-Calcium,phosphorus  ekungiwo enza bona amathambo ahlale aqinile.Kuqakathekile bona umuntu anakelele amathambo wakhe bona ahle anepilo ukuze azokukghona ukubalekela amalwele wamathambo afana ne arthritis, nofana i-osteoporosis&lt;ref&gt;Weatherholt, A.M., Fuchs, R.K. and Warden, S.J., 2012. Specialized connective tissue: bone, the structural framework of the upper extremity. ''Journal of Hand Therapy'', ''25''(2), pp.123-132.&lt;/ref&gt;.

== Isiphetho ==
Amathambo adlala indima ekulu emzimbeni womuntu ngomba aletha ivikeleko ezithweni zangaphakathi zomzimba. Enza bona umuntu akghone ukukhamba begodu enza umzimba ubumbeke. Kuqakathekile bona siwanakekele amathambo ukubalekela izifo eziphathelene nemathambo emzimbeni.</text>
      <sha1>pt590wsy6v2ud857j29jr49g28ar54f</sha1>
    </revision>
    <revision>
      <id>3219</id>
      <parentid>3080</parentid>
      <timestamp>2025-06-25T09:11:22Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <comment>change the heading to a sub heading</comment>
      <origin>3219</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2607" sha1="t3n4ug5zv7ersr7o1nsak4j8jgr9cay" xml:space="preserve">== Amathambo ==
'''Amathambo''' kuyinto  ethekgha umzimba bona ukghone ukujama begodu ubenejamo.Amathambo womzimba nakapheleleko ama-206. Amathambo la woke anikela umzimba isekelo lokujama begodu nevikeleko&lt;ref&gt;Bone | Definition, Anatomy, &amp; Composition | Britannica&lt;/ref&gt;.

=== Imihlobo yamathambo ===
Amathambo amade, lawa mathambo amade  atholakala ezandleni neenyaweni&lt;ref&gt;Long Bones – Anatomy, Examples, Function, &amp; Labeled Diagram&lt;/ref&gt;.Amathambo amafitjhani kumathambo abumbeke njengebhoksi atholakala endololwaneni nasemkantjeni. Amathambo apataleleko abonakala ngokuthi amhlobo owondileko begodu opatalele. Atholakala ehloko, ethambeni elihlukanisa imbambo, Kanye nakizo [[imbambo]]&lt;ref&gt;Long Bones – Anatomy, Examples, Function, &amp; Labeled Diagram&lt;/ref&gt;.Amathambo angakabumbeki, kumathambo angaweli ndawo kweminye imihlobo yamathambo kodwana nawo kumathambo womzimba. Isibonelo ithambo lomgogodhla, lehlolo neledinini.Amathambo ''wesesamoid'' wona mathambo amancani ahlangana nemisipha. Isibonelo lithambo elihlanganisa idolo.

=== Umsebenzi wamathambo ===
Amathambo asebenza ukunikela umzimba isekelo, akwenza bona ukghone ukujama njengomuntu begodu ukghone nokukhamba.Amathambo avikela izitho zomzimba eziqakathekileko zanga phakathi ezifana nehliziyo, [[amaphaphu]]. Amathambo avalela izitho lezi ukuze  zingalimamali lula&lt;ref&gt;Florencio-Silva, R., Sasso, G.R.D.S., Sasso-Cerri, E., Simões, M.J. and Cerri, P.S., 2015. Biology of bone tissue: structure, function, and factors that influence bone cells. ''BioMed research international'', ''2015''(1), p.421746.&lt;/ref&gt;.

Ukukhamba

Amathambo enza bona sikghone ukukhamba ngombana abambene nemisipha bese kube lula ukuthi umuntu asuke endawen yinye aye kwenye ngaphandle kobudisi.

Ukwakha amaseli 

Amathambo Ngiwo enza amaseli amhlophe nabovu weengazi Kanye amaplatelets.

Ukufaka amaminerali

Amathambo afaka amaminerali afana ne-Calcium,phosphorus  ekungiwo enza bona amathambo ahlale aqinile.Kuqakathekile bona umuntu anakelele amathambo wakhe bona ahle anepilo ukuze azokukghona ukubalekela amalwele wamathambo afana ne arthritis, nofana i-osteoporosis&lt;ref&gt;Weatherholt, A.M., Fuchs, R.K. and Warden, S.J., 2012. Specialized connective tissue: bone, the structural framework of the upper extremity. ''Journal of Hand Therapy'', ''25''(2), pp.123-132.&lt;/ref&gt;.

== Isiphetho ==
Amathambo adlala indima ekulu emzimbeni womuntu ngomba aletha ivikeleko ezithweni zangaphakathi zomzimba. Enza bona umuntu akghone ukukhamba begodu enza umzimba ubumbeke. Kuqakathekile bona siwanakekele amathambo ukubalekela izifo eziphathelene nemathambo emzimbeni.</text>
      <sha1>t3n4ug5zv7ersr7o1nsak4j8jgr9cay</sha1>
    </revision>
    <revision>
      <id>3220</id>
      <parentid>3219</parentid>
      <timestamp>2025-06-25T09:15:24Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <comment>i removed the conclusion</comment>
      <origin>3220</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2553" sha1="1k151jdqn1atkk3qkkd6arcpkfdavfa" xml:space="preserve">'''Amathambo''' kuyinto  ethekgha umzimba bona ukghone ukujama begodu ubenejamo.Amathambo womzimba nakapheleleko ama-206. Amathambo la woke anikela umzimba isekelo lokujama begodu nevikeleko&lt;ref&gt;Bone | Definition, Anatomy, &amp; Composition | Britannica&lt;/ref&gt;. ayinto eqinileko begodu engeze

=== Imihlobo yamathambo ===
Amathambo amade, lawa mathambo amade  atholakala ezandleni neenyaweni&lt;ref&gt;Long Bones – Anatomy, Examples, Function, &amp; Labeled Diagram&lt;/ref&gt;.Amathambo amafitjhani kumathambo abumbeke njengebhoksi atholakala endololwaneni nasemkantjeni. Amathambo apataleleko abonakala ngokuthi amhlobo owondileko begodu opatalele. Atholakala ehloko, ethambeni elihlukanisa imbambo, Kanye nakizo [[imbambo]]&lt;ref&gt;Long Bones – Anatomy, Examples, Function, &amp; Labeled Diagram&lt;/ref&gt;.Amathambo angakabumbeki, kumathambo angaweli ndawo kweminye imihlobo yamathambo kodwana nawo kumathambo womzimba. Isibonelo ithambo lomgogodhla, lehlolo neledinini.Amathambo ''wesesamoid'' wona mathambo amancani ahlangana nemisipha. Isibonelo lithambo elihlanganisa idolo.

=== Umsebenzi wamathambo ===
Amathambo asebenza ukunikela umzimba isekelo, akwenza bona ukghone ukujama njengomuntu begodu ukghone nokukhamba.Amathambo avikela izitho zomzimba eziqakathekileko zanga phakathi ezifana nehliziyo, [[amaphaphu]]. Amathambo avalela izitho lezi ukuze  zingalimamali lula&lt;ref&gt;Florencio-Silva, R., Sasso, G.R.D.S., Sasso-Cerri, E., Simões, M.J. and Cerri, P.S., 2015. Biology of bone tissue: structure, function, and factors that influence bone cells. ''BioMed research international'', ''2015''(1), p.421746.&lt;/ref&gt;. Amathambo enza bona sikghone ukukhamba ngombana abambene nemisipha bese kube lula ukuthi umuntu asuke endawen yinye aye kwenye ngaphandle kobudisi. Amathambo ngiwo enza amaseli amhlophe nabovu weengazi kanye amaplatelets. Amathambo afaka amaminerali afana ne-Calcium,phosphorus  ekungiwo enza bona amathambo ahlale aqinile.Kuqakathekile bona umuntu anakelele amathambo wakhe bona ahle anepilo ukuze azokukghona ukubalekela amalwele wamathambo afana ne arthritis, nofana i-osteoporosis&lt;ref&gt;Weatherholt, A.M., Fuchs, R.K. and Warden, S.J., 2012. Specialized connective tissue: bone, the structural framework of the upper extremity. ''Journal of Hand Therapy'', ''25''(2), pp.123-132.&lt;/ref&gt;.

Amathambo adlala indima ekulu emzimbeni womuntu ngomba aletha ivikeleko ezithweni zangaphakathi zomzimba. Enza bona umuntu akghone ukukhamba begodu enza umzimba ubumbeke. Kuqakathekile bona siwanakekele amathambo ukubalekela izifo eziphathelene nemathambo emzimbeni.</text>
      <sha1>1k151jdqn1atkk3qkkd6arcpkfdavfa</sha1>
    </revision>
    <revision>
      <id>3221</id>
      <parentid>3220</parentid>
      <timestamp>2025-06-25T09:17:26Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3221</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2624" sha1="lwx90ozpe7jtb86ssmcgub62key5qba" xml:space="preserve">'''Amathambo''' kuyinto  ethekgha umzimba bona ukghone ukujama begodu ubenejamo.Amathambo womzimba nakapheleleko ama-206. Amathambo la woke anikela umzimba isekelo lokujama begodu nevikeleko&lt;ref&gt;Bone | Definition, Anatomy, &amp; Composition | Britannica&lt;/ref&gt;. ayinto eqinileko begodi enziwe maphrotheyini,i- ''collagen'' kanye nama minerali khulu i ''calcuim.''

=== Imihlobo yamathambo ===
Amathambo amade, lawa mathambo amade  atholakala ezandleni neenyaweni&lt;ref&gt;Long Bones – Anatomy, Examples, Function, &amp; Labeled Diagram&lt;/ref&gt;.Amathambo amafitjhani kumathambo abumbeke njengebhoksi atholakala endololwaneni nasemkantjeni. Amathambo apataleleko abonakala ngokuthi amhlobo owondileko begodu opatalele. Atholakala ehloko, ethambeni elihlukanisa imbambo, Kanye nakizo [[imbambo]]&lt;ref&gt;Long Bones – Anatomy, Examples, Function, &amp; Labeled Diagram&lt;/ref&gt;.Amathambo angakabumbeki, kumathambo angaweli ndawo kweminye imihlobo yamathambo kodwana nawo kumathambo womzimba. Isibonelo ithambo lomgogodhla, lehlolo neledinini.Amathambo ''wesesamoid'' wona mathambo amancani ahlangana nemisipha. Isibonelo lithambo elihlanganisa idolo.

=== Umsebenzi wamathambo ===
Amathambo asebenza ukunikela umzimba isekelo, akwenza bona ukghone ukujama njengomuntu begodu ukghone nokukhamba.Amathambo avikela izitho zomzimba eziqakathekileko zanga phakathi ezifana nehliziyo, [[amaphaphu]]. Amathambo avalela izitho lezi ukuze  zingalimamali lula&lt;ref&gt;Florencio-Silva, R., Sasso, G.R.D.S., Sasso-Cerri, E., Simões, M.J. and Cerri, P.S., 2015. Biology of bone tissue: structure, function, and factors that influence bone cells. ''BioMed research international'', ''2015''(1), p.421746.&lt;/ref&gt;. Amathambo enza bona sikghone ukukhamba ngombana abambene nemisipha bese kube lula ukuthi umuntu asuke endawen yinye aye kwenye ngaphandle kobudisi. Amathambo ngiwo enza amaseli amhlophe nabovu weengazi kanye amaplatelets. Amathambo afaka amaminerali afana ne-Calcium,phosphorus  ekungiwo enza bona amathambo ahlale aqinile.Kuqakathekile bona umuntu anakelele amathambo wakhe bona ahle anepilo ukuze azokukghona ukubalekela amalwele wamathambo afana ne arthritis, nofana i-osteoporosis&lt;ref&gt;Weatherholt, A.M., Fuchs, R.K. and Warden, S.J., 2012. Specialized connective tissue: bone, the structural framework of the upper extremity. ''Journal of Hand Therapy'', ''25''(2), pp.123-132.&lt;/ref&gt;.

Amathambo adlala indima ekulu emzimbeni womuntu ngomba aletha ivikeleko ezithweni zangaphakathi zomzimba. Enza bona umuntu akghone ukukhamba begodu enza umzimba ubumbeke. Kuqakathekile bona siwanakekele amathambo ukubalekela izifo eziphathelene nemathambo emzimbeni.</text>
      <sha1>lwx90ozpe7jtb86ssmcgub62key5qba</sha1>
    </revision>
    <revision>
      <id>3414</id>
      <parentid>3221</parentid>
      <timestamp>2025-07-12T13:43:48Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3414</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2699" sha1="4c1cbngxmtq9zaqurs9f6k92v5djr3d" xml:space="preserve">[[Isimumathi:Human skeleton front en.svg|thumb|Amathambo womuntu wengubo]]
'''Amathambo''' kuyinto  ethekgha [[umzimba]] bona ukghone ukujama begodu ubenejamo.Amathambo womzimba nakapheleleko ama-206. Amathambo la woke anikela umzimba isekelo lokujama begodu nevikeleko&lt;ref&gt;Bone | Definition, Anatomy, &amp; Composition | Britannica&lt;/ref&gt;. ayinto eqinileko begodi enziwe maphrotheyini,i- ''collagen'' kanye nama minerali khulu i ''calcuim.''

=== Imihlobo yamathambo ===
Amathambo amade, lawa mathambo amade  atholakala ezandleni neenyaweni&lt;ref&gt;Long Bones – Anatomy, Examples, Function, &amp; Labeled Diagram&lt;/ref&gt;.Amathambo amafitjhani kumathambo abumbeke njengebhoksi atholakala endololwaneni nasemkantjeni. Amathambo apataleleko abonakala ngokuthi amhlobo owondileko begodu opatalele. Atholakala ehloko, ethambeni elihlukanisa imbambo, Kanye nakizo [[imbambo]]&lt;ref&gt;Long Bones – Anatomy, Examples, Function, &amp; Labeled Diagram&lt;/ref&gt;.Amathambo angakabumbeki, kumathambo angaweli ndawo kweminye imihlobo yamathambo kodwana nawo kumathambo womzimba. Isibonelo ithambo lomgogodhla, lehlolo neledinini.Amathambo ''wesesamoid'' wona mathambo amancani ahlangana nemisipha. Isibonelo lithambo elihlanganisa idolo.

=== Umsebenzi wamathambo ===
Amathambo asebenza ukunikela umzimba isekelo, akwenza bona ukghone ukujama njengomuntu begodu ukghone nokukhamba.Amathambo avikela izitho zomzimba eziqakathekileko zanga phakathi ezifana nehliziyo, amaphaphu. Amathambo avalela izitho lezi ukuze  zingalimamali lula&lt;ref&gt;Florencio-Silva, R., Sasso, G.R.D.S., Sasso-Cerri, E., Simões, M.J. and Cerri, P.S., 2015. Biology of bone tissue: structure, function, and factors that influence bone cells. ''BioMed research international'', ''2015''(1), p.421746.&lt;/ref&gt;. Amathambo enza bona sikghone ukukhamba ngombana abambene nemisipha bese kube lula ukuthi umuntu asuke endawen yinye aye kwenye ngaphandle kobudisi. Amathambo ngiwo enza amaseli amhlophe nabovu weengazi kanye amaplatelets. Amathambo afaka amaminerali afana ne-Calcium,phosphorus  ekungiwo enza bona amathambo ahlale aqinile.Kuqakathekile bona umuntu anakelele amathambo wakhe bona ahle anepilo ukuze azokukghona ukubalekela amalwele wamathambo afana ne arthritis, nofana i-osteoporosis&lt;ref&gt;Weatherholt, A.M., Fuchs, R.K. and Warden, S.J., 2012. Specialized connective tissue: bone, the structural framework of the upper extremity. ''Journal of Hand Therapy'', ''25''(2), pp.123-132.&lt;/ref&gt;.

Amathambo adlala indima ekulu emzimbeni womuntu ngomba aletha ivikeleko ezithweni zangaphakathi zomzimba. Enza bona umuntu akghone ukukhamba begodu enza umzimba ubumbeke. Kuqakathekile bona siwanakekele amathambo ukubalekela izifo eziphathelene nemathambo emzimbeni.</text>
      <sha1>4c1cbngxmtq9zaqurs9f6k92v5djr3d</sha1>
    </revision>
    <revision>
      <id>3415</id>
      <parentid>3414</parentid>
      <timestamp>2025-07-12T13:44:26Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3415</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2715" sha1="abpfjm8327h4qzauhcnxjc0qkoy8vky" xml:space="preserve">[[Isimumathi:Human skeleton front en.svg|thumb|Amathambo womuntu wengubo]]
'''Amathambo''' kuyinto  ethekgha [[umzimba]] bona ukghone ukujama begodu ubenejamo.Amathambo womzimba nakapheleleko ama-206. Amathambo la woke anikela umzimba isekelo lokujama begodu nevikeleko&lt;ref&gt;Bone | Definition, Anatomy, &amp; Composition | Britannica&lt;/ref&gt;. ayinto eqinileko begodi enziwe maphrotheyini,i- ''collagen'' kanye nama minerali khulu i ''calcuim.''

=== Imihlobo yamathambo ===
Amathambo amade, lawa mathambo amade  atholakala ezandleni neenyaweni&lt;ref&gt;Long Bones – Anatomy, Examples, Function, &amp; Labeled Diagram&lt;/ref&gt;.Amathambo amafitjhani kumathambo abumbeke njengebhoksi atholakala endololwaneni nasemkantjeni. Amathambo apataleleko abonakala ngokuthi amhlobo owondileko begodu opatalele. Atholakala ehloko, ethambeni elihlukanisa imbambo, Kanye nakizo [[imbambo]]&lt;ref&gt;Long Bones – Anatomy, Examples, Function, &amp; Labeled Diagram&lt;/ref&gt;.Amathambo angakabumbeki, kumathambo angaweli ndawo kweminye imihlobo yamathambo kodwana nawo kumathambo womzimba. Isibonelo ithambo lomgogodhla, lehlolo neledinini.Amathambo ''wesesamoid'' wona mathambo amancani ahlangana nemisipha. Isibonelo lithambo elihlanganisa idolo.

=== Umsebenzi wamathambo ===
Amathambo asebenza ukunikela umzimba isekelo, akwenza bona ukghone ukujama njengomuntu begodu ukghone nokukhamba.Amathambo avikela izitho zomzimba eziqakathekileko zanga phakathi ezifana nehliziyo, amaphaphu. Amathambo avalela izitho lezi ukuze  zingalimamali lula&lt;ref&gt;Florencio-Silva, R., Sasso, G.R.D.S., Sasso-Cerri, E., Simões, M.J. and Cerri, P.S., 2015. Biology of bone tissue: structure, function, and factors that influence bone cells. ''BioMed research international'', ''2015''(1), p.421746.&lt;/ref&gt;. Amathambo enza bona sikghone ukukhamba ngombana abambene nemisipha bese kube lula ukuthi umuntu asuke endawen yinye aye kwenye ngaphandle kobudisi. Amathambo ngiwo enza amaseli amhlophe nabovu weengazi kanye amaplatelets. Amathambo afaka amaminerali afana ne-Calcium,phosphorus  ekungiwo enza bona amathambo ahlale aqinile.Kuqakathekile bona umuntu anakelele amathambo wakhe bona ahle anepilo ukuze azokukghona ukubalekela amalwele wamathambo afana ne arthritis, nofana i-osteoporosis&lt;ref&gt;Weatherholt, A.M., Fuchs, R.K. and Warden, S.J., 2012. Specialized connective tissue: bone, the structural framework of the upper extremity. ''Journal of Hand Therapy'', ''25''(2), pp.123-132.&lt;/ref&gt;.

Amathambo adlala indima ekulu emzimbeni womuntu ngomba aletha ivikeleko ezithweni zangaphakathi zomzimba. Enza bona umuntu akghone ukukhamba begodu enza umzimba ubumbeke. Kuqakathekile bona siwanakekele amathambo ukubalekela izifo eziphathelene nemathambo emzimbeni.

== Iinkomba ==</text>
      <sha1>abpfjm8327h4qzauhcnxjc0qkoy8vky</sha1>
    </revision>
    <revision>
      <id>6407</id>
      <parentid>3415</parentid>
      <timestamp>2026-04-13T07:18:13Z</timestamp>
      <contributor>
        <username>Kwamikagami</username>
        <id>1412</id>
      </contributor>
      <origin>6407</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2720" sha1="7l2g5g4w6icuc2ghnortwjix008e5ng" xml:space="preserve">[[Isimumathi:Human skeleton front en.svg|thumb|Amathambo womuntu wengubo]]
'''Amathambo''' kuyinto  ethekgha [[umzimba]] bona ukghone ukujama begodu ubenejamo.Amathambo womzimba nakapheleleko ama-206. Amathambo la woke anikela umzimba isekelo lokujama begodu nevikeleko&lt;ref&gt;Bone | Definition, Anatomy, &amp; Composition | Britannica&lt;/ref&gt;. ayinto eqinileko begodi enziwe maphrotheyini,i- ''collagen'' kanye nama minerali khulu i ''calcuim.''

=== Imihlobo yamathambo ===
Amathambo amade, lawa mathambo amade  atholakala ezandleni neenyaweni.&lt;ref&gt;Long Bones – Anatomy, Examples, Function, &amp; Labeled Diagram&lt;/ref&gt; Amathambo amafitjhani kumathambo abumbeke njengebhoksi atholakala endololwaneni nasemkantjeni. Amathambo apataleleko abonakala ngokuthi amhlobo owondileko begodu opatalele. Atholakala ehloko, ethambeni elihlukanisa imbambo, Kanye nakizo [[imbambo]].&lt;ref&gt;Long Bones – Anatomy, Examples, Function, &amp; Labeled Diagram&lt;/ref&gt; Amathambo angakabumbeki, kumathambo angaweli ndawo kweminye imihlobo yamathambo kodwana nawo kumathambo womzimba. Isibonelo ithambo lomgogodhla, lehlolo neledinini. Amathambo ''wesesamoid'' wona mathambo amancani ahlangana nemisipha. Isibonelo lithambo elihlanganisa idolo.

=== Umsebenzi wamathambo ===
Amathambo asebenza ukunikela umzimba isekelo, akwenza bona ukghone ukujama njengomuntu begodu ukghone nokukhamba. Amathambo avikela izitho zomzimba eziqakathekileko zanga phakathi ezifana nehliziyo, amaphaphu. Amathambo avalela izitho lezi ukuze zingalimamali lula.&lt;ref&gt;Florencio-Silva, R., Sasso, G.R.D.S., Sasso-Cerri, E., Simões, M.J. and Cerri, P.S., 2015. Biology of bone tissue: structure, function, and factors that influence bone cells. ''BioMed research international'', ''2015''(1), p.421746.&lt;/ref&gt; Amathambo enza bona sikghone ukukhamba ngombana abambene nemisipha bese kube lula ukuthi umuntu asuke endawen yinye aye kwenye ngaphandle kobudisi. Amathambo ngiwo enza amaseli amhlophe nabovu weengazi kanye amaplatelets. Amathambo afaka amaminerali afana ne-Calcium, phosphorus  ekungiwo enza bona amathambo ahlale aqinile. Kuqakathekile bona umuntu anakelele amathambo wakhe bona ahle anepilo ukuze azokukghona ukubalekela amalwele wamathambo afana ne arthritis, nofana i-osteoporosis.&lt;ref&gt;Weatherholt, A.M., Fuchs, R.K. and Warden, S.J., 2012. Specialized connective tissue: bone, the structural framework of the upper extremity. ''Journal of Hand Therapy'', ''25''(2), pp.123-132.&lt;/ref&gt;

Amathambo adlala indima ekulu emzimbeni womuntu ngomba aletha ivikeleko ezithweni zangaphakathi zomzimba. Enza bona umuntu akghone ukukhamba begodu enza umzimba ubumbeke. Kuqakathekile bona siwanakekele amathambo ukubalekela izifo eziphathelene nemathambo emzimbeni.

== Iinkomba ==</text>
      <sha1>7l2g5g4w6icuc2ghnortwjix008e5ng</sha1>
    </revision>
    <revision>
      <id>6408</id>
      <parentid>6407</parentid>
      <timestamp>2026-04-13T07:19:09Z</timestamp>
      <contributor>
        <username>Kwamikagami</username>
        <id>1412</id>
      </contributor>
      <origin>6408</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2728" sha1="cuixwljhcyvar4dnndbsdgtegzlr98v" xml:space="preserve">[[Isimumathi:Human skeleton front en.svg|thumb|Amathambo womuntu wengubo]]
'''Amathambo''' kuyinto  ethekgha [[umzimba]] bona ukghone ukujama begodu ubenejamo. Amathambo womzimba nakapheleleko ama-206. Amathambo la woke anikela umzimba isekelo lokujama begodu nevikeleko,&lt;ref&gt;Bone | Definition, Anatomy, &amp; Composition | Britannica&lt;/ref&gt; ayinto eqinileko begodi enziwe maphrotheyini, i-''collagen'' kanye nama minerali khulu is''calcuim.''

=== Imihlobo yamathambo ===
Amathambo amade, lawa mathambo amade  atholakala ezandleni neenyaweni.&lt;ref&gt;Long Bones – Anatomy, Examples, Function, &amp; Labeled Diagram&lt;/ref&gt; Amathambo amafitjhani kumathambo abumbeke njengebhoksi atholakala endololwaneni nasemkantjeni. Amathambo apataleleko abonakala ngokuthi amhlobo owondileko begodu opatalele. Atholakala ehloko, ethambeni elihlukanisa imbambo, Kanye nakizo [[imbambo]].&lt;ref&gt;Long Bones – Anatomy, Examples, Function, &amp; Labeled Diagram&lt;/ref&gt; Amathambo angakabumbeki, kumathambo angaweli ndawo kweminye imihlobo yamathambo kodwana nawo kumathambo womzimba. Isibonelo ithambo lomgogodhla, lehlolo neledinini. Amathambo ''wesesamoid'' wona mathambo amancani ahlangana nemisipha. Isibonelo lithambo elihlanganisa idolo.

=== Umsebenzi wamathambo ===
Amathambo asebenza ukunikela umzimba isekelo, akwenza bona ukghone ukujama njengomuntu begodu ukghone nokukhamba. Amathambo avikela izitho zomzimba eziqakathekileko zanga phakathi ezifana nehliziyo, amaphaphu. Amathambo avalela izitho lezi ukuze zingalimamali lula.&lt;ref&gt;Florencio-Silva, R., Sasso, G.R.D.S., Sasso-Cerri, E., Simões, M.J. and Cerri, P.S., 2015. Biology of bone tissue: structure, function, and factors that influence bone cells. ''BioMed research international'', ''2015''(1), p.421746.&lt;/ref&gt; Amathambo enza bona sikghone ukukhamba ngombana abambene nemisipha bese kube lula ukuthi umuntu asuke endawen yinye aye kwenye ngaphandle kobudisi. Amathambo ngiwo enza amaseli amhlophe nabovu weengazi kanye amaplatelets. Amathambo afaka amaminerali afana ne-''calcium'', ''phosphorus'' ekungiwo enza bona amathambo ahlale aqinile. Kuqakathekile bona umuntu anakelele amathambo wakhe bona ahle anepilo ukuze azokukghona ukubalekela amalwele wamathambo afana ne arthritis, nofana i-osteoporosis.&lt;ref&gt;Weatherholt, A.M., Fuchs, R.K. and Warden, S.J., 2012. Specialized connective tissue: bone, the structural framework of the upper extremity. ''Journal of Hand Therapy'', ''25''(2), pp.123-132.&lt;/ref&gt;

Amathambo adlala indima ekulu emzimbeni womuntu ngomba aletha ivikeleko ezithweni zangaphakathi zomzimba. Enza bona umuntu akghone ukukhamba begodu enza umzimba ubumbeke. Kuqakathekile bona siwanakekele amathambo ukubalekela izifo eziphathelene nemathambo emzimbeni.

== Iinkomba ==</text>
      <sha1>cuixwljhcyvar4dnndbsdgtegzlr98v</sha1>
    </revision>
    <revision>
      <id>6409</id>
      <parentid>6408</parentid>
      <timestamp>2026-04-13T07:19:24Z</timestamp>
      <contributor>
        <username>Kwamikagami</username>
        <id>1412</id>
      </contributor>
      <minor />
      <origin>6409</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2728" sha1="1nhd9f3p2w5sjjir88tbyfuo0c1ne48" xml:space="preserve">[[Isimumathi:Human skeleton front en.svg|thumb|Amathambo womuntu wengubo]]
'''Amathambo''' kuyinto  ethekgha [[umzimba]] bona ukghone ukujama begodu ubenejamo. Amathambo womzimba nakapheleleko ama-206. Amathambo la woke anikela umzimba isekelo lokujama begodu nevikeleko,&lt;ref&gt;Bone | Definition, Anatomy, &amp; Composition | Britannica&lt;/ref&gt; ayinto eqinileko begodi enziwe maphrotheyini, i-''collagen'' kanye nama minerali khulu i-''calcuim.''

=== Imihlobo yamathambo ===
Amathambo amade, lawa mathambo amade  atholakala ezandleni neenyaweni.&lt;ref&gt;Long Bones – Anatomy, Examples, Function, &amp; Labeled Diagram&lt;/ref&gt; Amathambo amafitjhani kumathambo abumbeke njengebhoksi atholakala endololwaneni nasemkantjeni. Amathambo apataleleko abonakala ngokuthi amhlobo owondileko begodu opatalele. Atholakala ehloko, ethambeni elihlukanisa imbambo, Kanye nakizo [[imbambo]].&lt;ref&gt;Long Bones – Anatomy, Examples, Function, &amp; Labeled Diagram&lt;/ref&gt; Amathambo angakabumbeki, kumathambo angaweli ndawo kweminye imihlobo yamathambo kodwana nawo kumathambo womzimba. Isibonelo ithambo lomgogodhla, lehlolo neledinini. Amathambo ''wesesamoid'' wona mathambo amancani ahlangana nemisipha. Isibonelo lithambo elihlanganisa idolo.

=== Umsebenzi wamathambo ===
Amathambo asebenza ukunikela umzimba isekelo, akwenza bona ukghone ukujama njengomuntu begodu ukghone nokukhamba. Amathambo avikela izitho zomzimba eziqakathekileko zanga phakathi ezifana nehliziyo, amaphaphu. Amathambo avalela izitho lezi ukuze zingalimamali lula.&lt;ref&gt;Florencio-Silva, R., Sasso, G.R.D.S., Sasso-Cerri, E., Simões, M.J. and Cerri, P.S., 2015. Biology of bone tissue: structure, function, and factors that influence bone cells. ''BioMed research international'', ''2015''(1), p.421746.&lt;/ref&gt; Amathambo enza bona sikghone ukukhamba ngombana abambene nemisipha bese kube lula ukuthi umuntu asuke endawen yinye aye kwenye ngaphandle kobudisi. Amathambo ngiwo enza amaseli amhlophe nabovu weengazi kanye amaplatelets. Amathambo afaka amaminerali afana ne-''calcium'', ''phosphorus'' ekungiwo enza bona amathambo ahlale aqinile. Kuqakathekile bona umuntu anakelele amathambo wakhe bona ahle anepilo ukuze azokukghona ukubalekela amalwele wamathambo afana ne arthritis, nofana i-osteoporosis.&lt;ref&gt;Weatherholt, A.M., Fuchs, R.K. and Warden, S.J., 2012. Specialized connective tissue: bone, the structural framework of the upper extremity. ''Journal of Hand Therapy'', ''25''(2), pp.123-132.&lt;/ref&gt;

Amathambo adlala indima ekulu emzimbeni womuntu ngomba aletha ivikeleko ezithweni zangaphakathi zomzimba. Enza bona umuntu akghone ukukhamba begodu enza umzimba ubumbeke. Kuqakathekile bona siwanakekele amathambo ukubalekela izifo eziphathelene nemathambo emzimbeni.

== Iinkomba ==</text>
      <sha1>1nhd9f3p2w5sjjir88tbyfuo0c1ne48</sha1>
    </revision>
  </page>
  <page>
    <title>Umlomo</title>
    <ns>0</ns>
    <id>512</id>
    <revision>
      <id>2553</id>
      <timestamp>2025-03-20T16:28:21Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Umlomo == '''Umlomo''' kusisitho somzimba umuntu asisebenzisa ukukhuluma nokudla&lt;ref&gt;MOUTH | English meaning - Cambridge Dictionary&lt;/ref&gt;. Kusisitho esenza bona umuntu abenepilo.  == Ukubumbeka komlomo == Umlomo wenziwe ngeendebe ezimbili zangaphasi nangaphezulu ekungizo ezenza bona umlomo ukghone ukuvaleka. Umlomo unemihlathi esemahlangothini wawo. Ngaphezulu ngaphakathi emlomeni kunolwangeni bese ngaphasi kunelimu. Umlomo un[[amazinyo]] ama-32 ngaphakathi kwawo Kany...&quot;</comment>
      <origin>2553</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2872" sha1="r7xcnkf45qa955zwt2wl5sqctjqcyl2" xml:space="preserve">== Umlomo ==
'''Umlomo''' kusisitho somzimba umuntu asisebenzisa ukukhuluma nokudla&lt;ref&gt;MOUTH | English meaning - Cambridge Dictionary&lt;/ref&gt;. Kusisitho esenza bona umuntu abenepilo.

== Ukubumbeka komlomo ==
Umlomo wenziwe ngeendebe ezimbili zangaphasi nangaphezulu ekungizo ezenza bona umlomo ukghone ukuvaleka. Umlomo unemihlathi esemahlangothini wawo. Ngaphezulu ngaphakathi emlomeni kunolwangeni bese ngaphasi kunelimu. Umlomo un[[amazinyo]] ama-32 ngaphakathi kwawo Kanye n[[amathe]]&lt;ref&gt;Mouth: Anatomy, Function &amp; Care&lt;/ref&gt;.

== Umsebenzi womlomo ==
Ukudla nokugaya Ukudla 

Umlomo Sebenza ukuwamukela Ukudla umuntu akudlako bese uthome ugaye Ukudla lokho ngamazinyo ekusisitho esihlala gaphakathi komlomo. Ukudla kuthoma ukugayeka emlomeni ngaphambi kukuthi kudlulele emathumbini. Ukudla kuyeka umlomeni ukunzela bona kukghone ukwehla ngomphimbo kuye emathumbini&lt;ref&gt;Escudier, M.P., 2014. Physiology and function of the mouth. ''Advanced Nutrition and Dietetics in Gastroenterology'', pp.1-7.&lt;/ref&gt;.

Ukukhuluma

Umlomo udlala indima ekul ekutheni umuntu akghone ukukhuluma ngombana ngiwo owenza bona umuntu akghone ukwakha amagama begodu akghoe nokuthi awaphimise&lt;ref&gt;Bock, K. and Griffin, Z.M., 2013. Producing words: How mind meets mouth. In ''Aspects of language production'' (pp. 7-47). Psychology Press.&lt;/ref&gt;.

Ukunambitha

Umlomo unezinto ezenza bona umuntu akghone ukunambitha lokho akudlako okutjho bona akghone ukuzwa into ebabako, esudu, emuncu nofana eduma. Umuntu ukghona ukuzwa bona ukudla kumnandi nofana kumbi ngomlomo&lt;ref&gt;Boesveldt, S. and de Graaf, K., 2017. The differential role of smell and taste for eating behavior. ''Perception'', ''46''(3-4), pp.307-319.&lt;/ref&gt;.

Indlela zokutlhogomela umlomo

Ukutlhogomela umlomo kufanele ubhratjhe amazinyo begodu utlubhe upule umlomo ukususa amagcikwane angaba ngemlomeni. Kufuze ubalekele Ukudla okunesigwiri enengi nofana Ukudla okune aside ngombana ngikho okukhuthaza [[ukubola]] kwamazinyo neminye imiraro emlomeni. Kufanale uvakatjhele udorhodere wamazinyo ngasikhathi ukwenzela bona ukghone ukuthola imiraro yomlomo kusesenesikhathi bese uyilungise kusese nesikhathi&lt;ref&gt;Oral Hygiene: Best Practices &amp; Instructions for Good Routine&lt;/ref&gt;.

Ubuhle bokutlhogomela umlomo

Kufanele umlomo utlhogomelwe ngombana lokho kuzokuvikela bona umuntu angatholi amagcikwane emlomeni. Nawutlhogomela umlomo uzokwenza bona amazinyo ahlale ahlanzekile angaboli. Ukuba nomlomo ahlanzekile kwenza bona umlomo ungabi nephunga elimbi begodu ungatholi ukugula kweensini.Kwenza bona ube nokuzithemba lokha momothekako ngombana kuzokuvela amazinyo amahle ahlanzekileko&lt;ref&gt;The Benefits of Good Oral Hygiene - Oral-B&lt;/ref&gt;.

Isiphetho 

Umlomo usisitho somzimba esenza bona umuntu akghone ukukhuluma, ukunambitha Kanye nokudla. Kufanelwe unakekelwe ukuze ungabi namagcikwane nofana amazinyo angaphakathi kwawo angaboli.</text>
      <sha1>r7xcnkf45qa955zwt2wl5sqctjqcyl2</sha1>
    </revision>
    <revision>
      <id>2590</id>
      <parentid>2553</parentid>
      <timestamp>2025-03-26T08:51:38Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2590</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2881" sha1="h3m5ha3k2a7h2l7r35slw11xpqz5wnr" xml:space="preserve">== Umlomo ==
'''Umlomo''' kusisitho somzimba umuntu asisebenzisa ukukhuluma nokudla&lt;ref&gt;MOUTH | English meaning - Cambridge Dictionary&lt;/ref&gt;. Kusisitho esenza bona umuntu abenepilo.

== Ukubumbeka komlomo ==
Umlomo wenziwe ngeendebe ezimbili zangaphasi nangaphezulu ekungizo ezenza bona umlomo ukghone ukuvaleka. Umlomo unemihlathi esemahlangothini wawo. Ngaphezulu ngaphakathi emlomeni kunolwangeni bese ngaphasi kunelimu. Umlomo un[[amazinyo]] ama-32 ngaphakathi kwawo Kanye n[[amathe]]&lt;ref&gt;Mouth: Anatomy, Function &amp; Care&lt;/ref&gt;.

== Umsebenzi womlomo ==
Ukudla nokugaya Ukudla 

Umlomo Sebenza ukuwamukela Ukudla umuntu akudlako bese uthome ugaye Ukudla lokho ngamazinyo ekusisitho esihlala gaphakathi komlomo. [[Ukudla]] kuthoma ukugayeka emlomeni ngaphambi kukuthi kudlulele emathumbini. Ukudla kuyeka umlomeni ukunzela bona kukghone ukwehla ngomphimbo kuye emathumbini&lt;ref&gt;Escudier, M.P., 2014. Physiology and function of the mouth. ''Advanced Nutrition and Dietetics in Gastroenterology'', pp.1-7.&lt;/ref&gt;.

Ukukhuluma

Umlomo udlala indima ekulu ekutheni umuntu akghone [[ukukhuluma]] ngombana ngiwo owenza bona umuntu akghone ukwakha amagama begodu akghoe nokuthi awaphimise&lt;ref&gt;Bock, K. and Griffin, Z.M., 2013. Producing words: How mind meets mouth. In ''Aspects of language production'' (pp. 7-47). Psychology Press.&lt;/ref&gt;.

Ukunambitha

Umlomo unezinto ezenza bona umuntu akghone ukunambitha lokho akudlako okutjho bona akghone ukuzwa into ebabako, esudu, emuncu nofana eduma. Umuntu ukghona ukuzwa bona ukudla kumnandi nofana kumbi ngomlomo&lt;ref&gt;Boesveldt, S. and de Graaf, K., 2017. The differential role of smell and taste for eating behavior. ''Perception'', ''46''(3-4), pp.307-319.&lt;/ref&gt;.

Indlela zokutlhogomela umlomo

Ukutlhogomela umlomo kufanele ubhratjhe amazinyo begodu utlubhe upule umlomo ukususa amagcikwane angaba ngemlomeni. Kufuze ubalekele Ukudla okunesigwiri enengi nofana Ukudla okune aside ngombana ngikho okukhuthaza [[ukubola]] kwamazinyo neminye imiraro emlomeni. Kufanale uvakatjhele udorhodere wamazinyo ngasikhathi ukwenzela bona ukghone ukuthola imiraro yomlomo kusesenesikhathi bese uyilungise kusese nesikhathi&lt;ref&gt;Oral Hygiene: Best Practices &amp; Instructions for Good Routine&lt;/ref&gt;.

Ubuhle bokutlhogomela umlomo

Kufanele umlomo utlhogomelwe ngombana lokho kuzokuvikela bona umuntu angatholi amagcikwane emlomeni. Nawutlhogomela umlomo uzokwenza bona amazinyo ahlale ahlanzekile angaboli. Ukuba nomlomo ahlanzekile kwenza bona umlomo ungabi nephunga elimbi begodu ungatholi ukugula kweensini.Kwenza bona ube nokuzithemba lokha momothekako ngombana kuzokuvela amazinyo amahle ahlanzekileko&lt;ref&gt;The Benefits of Good Oral Hygiene - Oral-B&lt;/ref&gt;.

Isiphetho 

Umlomo usisitho somzimba esenza bona umuntu akghone ukukhuluma, ukunambitha Kanye nokudla. Kufanelwe unakekelwe ukuze ungabi namagcikwane nofana amazinyo angaphakathi kwawo angaboli.</text>
      <sha1>h3m5ha3k2a7h2l7r35slw11xpqz5wnr</sha1>
    </revision>
    <revision>
      <id>5186</id>
      <parentid>2590</parentid>
      <timestamp>2025-08-16T07:45:24Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5186</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2885" sha1="3tv9qnz7kh070hxir98g90eswmu53pj" xml:space="preserve">'''Umlomo''' kusisitho somzimba umuntu asisebenzisa ukukhuluma nokudla.&lt;ref&gt;MOUTH | English meaning - Cambridge Dictionary&lt;/ref&gt; Kusisitho esenza bona umuntu abenepilo.Umlomo wenziwe ngeendebe ezimbili zangaphasi nangaphezulu ekungizo ezenza bona umlomo ukghone ukuvaleka. Umlomo unemihlathi esemahlangothini wawo. Ngaphezulu ngaphakathi emlomeni kunolwangeni bese ngaphasi kunelimu. Umlomo un[[amazinyo]] ama-32 ngaphakathi kwawo Kanye n[[amathe|amathe.]]&lt;ref&gt;Mouth: Anatomy, Function &amp; Care&lt;/ref&gt;

=== Umsebenzi womlomo ===

==== Ukudla, ukugaya Ukudla, nokunambitha ====
Umlomo Sebenza ukuwamukela Ukudla umuntu akudlako bese uthome ugaye Ukudla lokho ngamazinyo ekusisitho esihlala gaphakathi komlomo. [[Ukudla]] kuthoma ukugayeka emlomeni ngaphambi kukuthi kudlulele emathumbini. Ukudla kuyeka umlomeni ukunzela bona kukghone ukwehla ngomphimbo kuye emathumbini.&lt;ref&gt;Escudier, M.P., 2014. Physiology and function of the mouth. ''Advanced Nutrition and Dietetics in Gastroenterology'', pp.1-7.&lt;/ref&gt;Umlomo unezinto ezenza bona umuntu akghone ukunambitha lokho akudlako okutjho bona akghone ukuzwa into ebabako, esudu, emuncu nofana eduma. Umuntu ukghona ukuzwa bona ukudla kumnandi nofana kumbi ngomlomo.&lt;ref&gt;Boesveldt, S. and de Graaf, K., 2017. The differential role of smell and taste for eating behavior. ''Perception'', ''46''(3-4), pp.307-319.&lt;/ref&gt;

==== Ukukhuluma ====
Umlomo udlala indima ekulu ekutheni umuntu akghone [[ukukhuluma]] ngombana ngiwo owenza bona umuntu akghone ukwakha amagama begodu akghoe nokuthi awaphimise.&lt;ref&gt;Bock, K. and Griffin, Z.M., 2013. Producing words: How mind meets mouth. In ''Aspects of language production'' (pp. 7-47). Psychology Press.&lt;/ref&gt;

==== Indlela zokutlhogomela umlomo ====
Ukutlhogomela umlomo kufanele ubhratjhe amazinyo begodu utlubhe upule umlomo ukususa amagcikwane angaba ngemlomeni. Kufuze ubalekele Ukudla okunesigwiri enengi nofana Ukudla okune aside ngombana ngikho okukhuthaza [[ukubola]] kwamazinyo neminye imiraro emlomeni. Kufanale uvakatjhele udorhodere wamazinyo ngasikhathi ukwenzela bona ukghone ukuthola imiraro yomlomo kusesenesikhathi bese uyilungise kusese nesikhathi.&lt;ref&gt;Oral Hygiene: Best Practices &amp; Instructions for Good Routine&lt;/ref&gt;

=== Ubuhle bokutlhogomela umlomo ===
Kufanele umlomo utlhogomelwe ngombana lokho kuzokuvikela bona umuntu angatholi amagcikwane emlomeni. Nawutlhogomela umlomo uzokwenza bona amazinyo ahlale ahlanzekile angaboli. Ukuba nomlomo ahlanzekile kwenza bona umlomo ungabi nephunga elimbi begodu ungatholi ukugula kweensini.Kwenza bona ube nokuzithemba lokha momothekako ngombana kuzokuvela amazinyo amahle ahlanzekileko.&lt;ref&gt;The Benefits of Good Oral Hygiene - Oral-B&lt;/ref&gt;Umlomo usisitho somzimba esenza bona umuntu akghone ukukhuluma, ukunambitha Kanye nokudla. Kufanelwe unakekelwe ukuze ungabi namagcikwane nofana amazinyo angaphakathi kwawo angaboli.

== Iinkomba ==</text>
      <sha1>3tv9qnz7kh070hxir98g90eswmu53pj</sha1>
    </revision>
    <revision>
      <id>5187</id>
      <parentid>5186</parentid>
      <timestamp>2025-08-16T07:47:36Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5187</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2839" sha1="ragjw1u9vr7ahzpyymjy511qj8zu0rz" xml:space="preserve">'''Umlomo''' kusisitho somzimba umuntu asisebenzisa ukukhuluma nokudla.&lt;ref&gt;MOUTH | English meaning - Cambridge Dictionary&lt;/ref&gt; Kusisitho esenza bona umuntu abenepilo. Umlomo wenziwe ngeendebe ezimbili zangaphasi nangaphezulu ekungizo ezenza bona umlomo ukghone ukuvaleka. Umlomo unemihlathi esemahlangothini wawo. Ngaphezulu ngaphakathi emlomeni kunolwangeni bese ngaphasi kunelimu. Umlomo un[[amazinyo]] ama-32 ngaphakathi kwawo Kanye n[[amathe|amathe.]]&lt;ref&gt;Mouth: Anatomy, Function &amp; Care&lt;/ref&gt;

=== Umsebenzi womlomo ===

==== Ukudla, ukugaya Ukudla, nokunambitha ====
Umlomo Sebenza ukuwamukela Ukudla umuntu akudlako bese uthome ugaye Ukudla lokho ngamazinyo ekusisitho esihlala gaphakathi komlomo. [[Ukudla]] kuthoma ukugayeka emlomeni ngaphambi kukuthi kudlulele emathumbini. Ukudla kuyeka umlomeni ukunzela bona kukghone ukwehla ngomphimbo kuye emathumbini.&lt;ref&gt;Escudier, M.P., 2014. Physiology and function of the mouth. ''Advanced Nutrition and Dietetics in Gastroenterology'', pp.1-7.&lt;/ref&gt;Umlomo unezinto ezenza bona umuntu akghone ukunambitha lokho akudlako okutjho bona akghone ukuzwa into ebabako, esudu, emuncu nofana eduma. Umuntu ukghona ukuzwa bona ukudla kumnandi nofana kumbi ngomlomo.&lt;ref&gt;Boesveldt, S. and de Graaf, K., 2017. The differential role of smell and taste for eating behavior. ''Perception'', ''46''(3-4), pp.307-319.&lt;/ref&gt;

==== Ukukhuluma ====
Umlomo udlala indima ekulu ekutheni umuntu akghone [[ukukhuluma]] ngombana ngiwo owenza bona umuntu akghone ukwakha amagama begodu akghone nokuthi awaphimise.&lt;ref&gt;Bock, K. and Griffin, Z.M., 2013. Producing words: How mind meets mouth. In ''Aspects of language production'' (pp. 7-47). Psychology Press.&lt;/ref&gt;

=== Ukutlhogomela umlomo ===
Kufanele umlomo utlhogomelwe ngombana lokho kuzokuvikela bona umuntu angatholi amagcikwane emlomeni. Nawutlhogomela umlomo uzokwenza bona amazinyo ahlale ahlanzekile angaboli. Ukuba nomlomo ahlanzekile kwenza bona umlomo ungabi nephunga elimbi begodu ungatholi ukugula kweensini. Kwenza bona ube nokuzithemba lokha momothekako ngombana kuzokuvela amazinyo amahle ahlanzekileko.&lt;ref&gt;The Benefits of Good Oral Hygiene - Oral-B&lt;/ref&gt;Umlomo usisitho somzimba esenza bona umuntu akghone ukukhuluma, ukunambitha Kanye nokudla. Kufanelwe unakekelwe ukuze ungabi namagcikwane nofana amazinyo angaphakathi kwawo angaboli. Ukutlhogomela umlomo kufanele ubhratjhe amazinyo begodu utlubhe upule umlomo ukususa amagcikwane angaba ngemlomeni. Kufuze ubalekele Ukudla okunesigwiri enengi nofana Ukudla okune aside ngombana ngikho okukhuthaza [[ukubola]] kwamazinyo neminye imiraro emlomeni. Kufanale uvakatjhele udorhodere wamazinyo ngasikhathi ukwenzela bona ukghone ukuthola imiraro yomlomo kusesenesikhathi bese uyilungise kusese nesikhathi.&lt;ref&gt;Oral Hygiene: Best Practices &amp; Instructions for Good Routine&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>ragjw1u9vr7ahzpyymjy511qj8zu0rz</sha1>
    </revision>
    <revision>
      <id>5188</id>
      <parentid>5187</parentid>
      <timestamp>2025-08-16T07:50:13Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5188</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2840" sha1="g94ixu4c87i6up0f8e1gy6f2ho9ubp9" xml:space="preserve">'''Umlomo''' kusisitho somzimba umuntu asisebenzisa ukukhuluma nokudla.&lt;ref&gt;MOUTH | English meaning - Cambridge Dictionary&lt;/ref&gt; Kusisitho esenza bona umuntu abenepilo. Umlomo wenziwe ngeendebe ezimbili zangaphasi nangaphezulu ekungizo ezenza bona umlomo ukghone ukuvaleka. Umlomo unemihlathi esemahlangothini wawo. Ngaphezulu ngaphakathi emlomeni kunolwangeni bese ngaphasi kunelimu. Umlomo un[[amazinyo]] ama-32 ngaphakathi kwawo Kanye n[[amathe|amathe.]]&lt;ref&gt;Mouth: Anatomy, Function &amp; Care&lt;/ref&gt;

=== Umsebenzi womlomo ===

==== Ukudla, ukugaya Ukudla, nokunambitha ====
Umlomo Sebenza ukuwamukela Ukudla umuntu akudlako bese uthome ugaye Ukudla lokho ngamazinyo ekusisitho esihlala gaphakathi komlomo. [[Ukudla]] kuthoma ukugayeka emlomeni ngaphambi kukuthi kudlulele emathumbini. Ukudla kuyeka umlomeni ukunzela bona kukghone ukwehla ngomphimbo kuye emathumbini.&lt;ref&gt;Escudier, M.P., 2014. Physiology and function of the mouth. ''Advanced Nutrition and Dietetics in Gastroenterology'', pp.1-7.&lt;/ref&gt;Umlomo unezinto ezenza bona umuntu akghone ukunambitha lokho akudlako okutjho bona akghone ukuzwa into ebabako, esudu, emuncu nofana eduma. Umuntu ukghona ukuzwa bona ukudla kumnandi nofana kumbi ngomlomo.&lt;ref&gt;Boesveldt, S. and de Graaf, K., 2017. The differential role of smell and taste for eating behavior. ''Perception'', ''46''(3-4), pp.307-319.&lt;/ref&gt;

==== Ukukhuluma ====
Umlomo udlala indima ekulu ekutheni umuntu akghone [[ukukhuluma]] ngombana ngiwo owenza bona umuntu akghone ukwakha amagama begodu akghone nokuthi awaphimise.&lt;ref&gt;Bock, K. and Griffin, Z.M., 2013. Producing words: How mind meets mouth. In ''Aspects of language production'' (pp. 7-47). Psychology Press.&lt;/ref&gt; 

=== Ukutlhogomela umlomo ===
Kufanele umlomo utlhogomelwe ngombana lokho kuzokuvikela bona umuntu angatholi amagcikwane emlomeni. Nawutlhogomela umlomo uzokwenza bona amazinyo ahlale ahlanzekile angaboli. Ukuba nomlomo ahlanzekile kwenza bona umlomo ungabi nephunga elimbi begodu ungatholi ukugula kweensini. Kwenza bona ube nokuzithemba lokha momothekako ngombana kuzokuvela amazinyo amahle ahlanzekileko.&lt;ref&gt;The Benefits of Good Oral Hygiene - Oral-B&lt;/ref&gt;Umlomo usisitho somzimba esenza bona umuntu akghone ukukhuluma, ukunambitha Kanye nokudla. Kufanelwe unakekelwe ukuze ungabi namagcikwane nofana amazinyo angaphakathi kwawo angaboli. Ukutlhogomela umlomo kufanele ubhratjhe amazinyo begodu utlubhe upule umlomo ukususa amagcikwane angaba ngemlomeni. Kufuze ubalekele Ukudla okunesigwiri enengi nofana Ukudla okune aside ngombana ngikho okukhuthaza [[ukubola]] kwamazinyo neminye imiraro emlomeni. Kufanale uvakatjhele udorhodere wamazinyo ngasikhathi ukwenzela bona ukghone ukuthola imiraro yomlomo kusesenesikhathi bese uyilungise kusese nesikhathi.&lt;ref&gt;Oral Hygiene: Best Practices &amp; Instructions for Good Routine&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>g94ixu4c87i6up0f8e1gy6f2ho9ubp9</sha1>
    </revision>
  </page>
  <page>
    <title>Umzimba</title>
    <ns>0</ns>
    <id>513</id>
    <revision>
      <id>2556</id>
      <timestamp>2025-03-20T16:47:38Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;Umzimba  '''Umzimba''' kuyinto ehlala umphefumulo womuntu. Kuyinto umuntu ayisebenzisa ukuphila, ukunyakaza. Umzimba ngiwo osenza bona sikghone ukuhlathulula bona umuntu unjani ngokubukeka&lt;ref&gt;https://dictionary.cambridge.org/dictionary/english/body&lt;/ref&gt;. Ngaphandle komzimba umuntu angeze akghona ukuphila nanyana ukubonakala.  Umzimba kuyinto eyenziwe ngarherho(systems) amanengi  asebenzisanako ukwenza bona umuntu aphile begodu abe epilo. Amarherho womzimba manengi bego...&quot;</comment>
      <origin>2556</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3294" sha1="24mugtosyfiz5850u0noqpu6sw8lhfe" xml:space="preserve">Umzimba

'''Umzimba''' kuyinto ehlala umphefumulo womuntu. Kuyinto umuntu ayisebenzisa ukuphila, ukunyakaza. Umzimba ngiwo osenza bona sikghone ukuhlathulula bona umuntu unjani ngokubukeka&lt;ref&gt;https://dictionary.cambridge.org/dictionary/english/body&lt;/ref&gt;. Ngaphandle komzimba umuntu angeze akghona ukuphila nanyana ukubonakala.

Umzimba kuyinto eyenziwe ngarherho(systems) amanengi  asebenzisanako ukwenza bona umuntu aphile begodu abe epilo. Amarherho womzimba manengi begodu ahlukule ngokomsebenzi&lt;ref&gt;List of systems of the human body - Wikipedia&lt;/ref&gt;.

Amarherho womzimba

Irherho lokugayakudla

Le isebenza ukuwenza Ukudla bona kugayenza emathumbuni bese bese umzimba udosa izakha mzimba ezitlhogaka ngaphakathi kokudla okugayekileko. Lokha okuzinsalelo kuyakhamba kuphume sele kumadede&lt;ref&gt;List of systems of the human body - Wikipedia&lt;/ref&gt;.

Irherho lamathambo

Amathambo  kileli rherho ayasebenzisa ukuthi akghone ukunikela umuntu isekelo alitlhogako ukuthi enze imisebenzi yakhe yoke. Avikela izitho zangaphakathi komuntu ezenza bona ipilo yomuntu iragele phambili&lt;ref&gt;Thomson, J.R. and Friendship, R.M., 2019. Digestive system. ''Diseases of swine'', pp.234-263.&lt;/ref&gt;.

Irherho leengazi

Irherho leli yenza isiqiniseko sokuthi igazi likakhamba umzimba woke womuntu lingathikamezeki. Ithumela igazi ehliziyweni Bese ihliziyo iyalimpopa ilizalise i-oksijini. Igazi elizele i-oksijini lisuka ehliziyweni lizale umzimba woke lifike nenyameni yomuntu. Leli esele liphelelwe yi-oksijini liyajika eskhumbeni nenyameni libuyele ehliziyweni njalo njalo&lt;ref&gt;Saladin, K.S. and Miller, L., 2023. ''Anatomy &amp; physiology'' (p. 1248). McGraw-Hill US Higher Ed ISE.&lt;/ref&gt;.

Irherho lamasotja womzimba

Irherho leli isebenzisa izakhamzimba bonyana ukuqinisa amasotja womziba ukuthi akghone ukulwisana namagula angafuna ukuhlasela umzimba womuntu uwenze ube buthakathaka&lt;ref&gt;Sattler, S., 2017. The role of the immune system beyond the fight against infection. ''The immunology of cardiovascular homeostasis and pathology'', pp.3-14.&lt;/ref&gt;.

Irherho lommoya

Lapha irherho leli iqinisekilsa bona umuntu udosa umoya ohlanzekileko i-oksijini uwuse emaphapheni bese umuntu akhiphe loyo osilaphazekileko obizwa bona yi khaboni dayoksayidi&lt;ref&gt;Peate, I., 2018. Anatomy and physiology, 10. The respiratory system. ''British Journal of Healthcare Assistants'', ''12''(4), pp.178-181.&lt;/ref&gt;

Irherho yelwazi

Iapha Ingcondo yomuntu yenza bona umuntu akghone ukuphendula nofana ukwenza izenzo aphendula imininigwane ibhoduluko ahlala kilo eliyithumela engcondweni yakhe. Isibonelo lokha nangabe ubone inyoka, ingcondo yakho izokutjela bona ubaleke ngombana into oyibonako iyingozi ingakulimaza&lt;ref&gt;Mai, J.K. and Paxinos, G. eds., 2011. ''The human nervous system''. Academic press.&lt;/ref&gt;.

Irherho lokuzala

Leli lirherho eyenza bona umuntu akghone ukubeletha. Iqinisekisa bona abomma bakghone ukuya emalangeni cobe nyanga begodu bakghone ukuthwala abantwana lokha nabasidisi. Kibobaba iqinisekisa bona bahlale banembewu yokukwenza abamma babe sidisi&lt;ref&gt;List of systems of the human body - Wikipedia&lt;/ref&gt;.

Isiphetho

Umzimba kuyinto ehlanganeko kodwana enamasistimu amanengi ngaphakathi ekungiwo akghona ukwenza bona umuntu abe nepilo. Umnntu angeze aphila ngaphandle komzimba. Kufanele unakekelwe umzimba</text>
      <sha1>24mugtosyfiz5850u0noqpu6sw8lhfe</sha1>
    </revision>
    <revision>
      <id>2557</id>
      <parentid>2556</parentid>
      <timestamp>2025-03-20T16:53:24Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2557</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3293" sha1="jhdevlkqnbxzxe0e2xsy1kcd9hdee8o" xml:space="preserve">Umzimba

'''Umzimba''' kuyinto ehlala umphefumulo womuntu. Kuyinto umuntu ayisebenzisa ukuphila, ukunyakaza. Umzimba ngiwo osenza bona sikghone ukuhlathulula bona umuntu unjani ngokubukeka&lt;ref&gt;https://dictionary.cambridge.org/dictionary/english/body&lt;/ref&gt;. Ngaphandle komzimba umuntu angeze akghona ukuphila nanyana ukubonakala.

Umzimba kuyinto eyenziwe ngarherho(systems) amanengi asebenzisanako ukwenza bona umuntu aphile begodu abe epilo. Amarherho womzimba manengi begodu ahlukule ngokomsebenzi&lt;ref&gt;List of systems of the human body - Wikipedia&lt;/ref&gt;.

Amarherho womzimba

Irherho lokugayakudla

Le isebenza ukwenza Ukudla bona kugayeke emathumbuni bese umzimba udosa izakha mzimba ezitlhogaka ngaphakathi kokudla okugayekileko. Lokha okuzinsalelo kuyakhamba kuphume sele kumadede&lt;ref&gt;List of systems of the human body - Wikipedia&lt;/ref&gt;.

Irherho lamathambo

Amathambo kileli rherho ayasebenzisa ukuthi akghone ukunikela umuntu isekelo alitlhogako ukuthi enze imisebenzi yakhe yoke. Avikela izitho zangaphakathi komuntu ezenza bona ipilo yomuntu iragele phambili&lt;ref&gt;Thomson, J.R. and Friendship, R.M., 2019. Digestive system. ''Diseases of swine'', pp.234-263.&lt;/ref&gt;.

Irherho leengazi

Irherho leli yenza isiqiniseko sokuthi igazi likakhamba umzimba woke womuntu lingathikamezeki. Ithumela igazi ehliziyweni Bese ihliziyo iyalimpopa ilizalise i-oksijini. Igazi elizele i-oksijini lisuka ehliziyweni lizale umzimba woke lifike nenyameni yomuntu. Leli esele liphelelwe yi-oksijini liyajika eskhumbeni nenyameni libuyele ehliziyweni njalo njalo&lt;ref&gt;Saladin, K.S. and Miller, L., 2023. ''Anatomy &amp; physiology'' (p. 1248). McGraw-Hill US Higher Ed ISE.&lt;/ref&gt;.

Irherho lamasotja womzimba

Irherho leli isebenzisa izakhamzimba bonyana ukuqinisa [[amasotja womziba]] ukuthi akghone ukulwisana namagulo angafuna ukuhlasela umzimba womuntu uwenze ube buthakathaka&lt;ref&gt;Sattler, S., 2017. The role of the immune system beyond the fight against infection. ''The immunology of cardiovascular homeostasis and pathology'', pp.3-14.&lt;/ref&gt;.

Irherho lommoya

Lapha irherho leli iqinisekilsa bona umuntu udosa umoya ohlanzekileko i-oksijini uwuse emaphapheni bese umuntu akhiphe loyo osilaphazekileko obizwa bona yi khaboni dayoksayidi&lt;ref&gt;Peate, I., 2018. Anatomy and physiology, 10. The respiratory system. ''British Journal of Healthcare Assistants'', ''12''(4), pp.178-181.&lt;/ref&gt;

Irherho yelwazi

Iapha Ingcondo yomuntu yenza bona umuntu akghone ukuphendula nofana ukwenza izenzo aphendula imininigwane [[ibhoduluko]] ahlala kilo eliyithumela engcondweni yakhe. Isibonelo lokha nangabe ubone inyoka, ingcondo yakho izokutjela bona ubaleke ngombana into oyibonako iyingozi ingakulimaza&lt;ref&gt;Mai, J.K. and Paxinos, G. eds., 2011. ''The human nervous system''. Academic press.&lt;/ref&gt;.

Irherho lokuzala

Leli lirherho eyenza bona umuntu akghone ukubeletha. Iqinisekisa bona abomma bakghone ukuya emalangeni cobe nyanga begodu bakghone ukuthwala abantwana lokha nabasidisi. Kibobaba iqinisekisa bona bahlale banembewu yokukwenza abamma babe sidisi&lt;ref&gt;List of systems of the human body - Wikipedia&lt;/ref&gt;.

Isiphetho

Umzimba kuyinto ehlanganeko kodwana enamasistimu amanengi ngaphakathi ekungiwo akghona ukwenza bona umuntu abe nepilo. Umnntu angeze aphila ngaphandle komzimba. Kufanele unakekelwe umzimba</text>
      <sha1>jhdevlkqnbxzxe0e2xsy1kcd9hdee8o</sha1>
    </revision>
    <revision>
      <id>2561</id>
      <parentid>2557</parentid>
      <timestamp>2025-03-21T09:53:07Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2561</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3297" sha1="9xrym1q360xv2nd4crjab4n7ypyy5ob" xml:space="preserve">Umzimba

'''Umzimba''' kuyinto ehlala umphefumulo womuntu. Kuyinto umuntu ayisebenzisa ukuphila, ukunyakaza. Umzimba ngiwo osenza bona sikghone ukuhlathulula bona umuntu unjani ngokubukeka&lt;ref&gt;https://dictionary.cambridge.org/dictionary/english/body&lt;/ref&gt;. Ngaphandle komzimba umuntu angeze akghona ukuphila nanyana ukubonakala.

Umzimba kuyinto eyenziwe ngarherho(systems) amanengi asebenzisanako ukwenza bona umuntu aphile begodu abe epilo. Amarherho womzimba manengi begodu ahlukule ngokomsebenzi&lt;ref&gt;List of systems of the human body - Wikipedia&lt;/ref&gt;.

Amarherho womzimba

Irherho lokugayakudla

Le isebenza ukwenza Ukudla bona kugayeke emathumbuni bese umzimba udosa izakha mzimba ezitlhogaka ngaphakathi kokudla okugayekileko. Lokha okuzinsalelo kuyakhamba kuphume sele kumadede&lt;ref&gt;List of systems of the human body - Wikipedia&lt;/ref&gt;.

Irherho lamathambo

Amathambo kileli rherho ayasebenzisa ukuthi akghone ukunikela umuntu isekelo alitlhogako ukuthi enze imisebenzi yakhe yoke. Avikela izitho zangaphakathi komuntu ezenza bona ipilo yomuntu iragele phambili&lt;ref&gt;Thomson, J.R. and Friendship, R.M., 2019. Digestive system. ''Diseases of swine'', pp.234-263.&lt;/ref&gt;.

Irherho leengazi

Irherho leli yenza isiqiniseko sokuthi igazi liyakhamba umzimba woke womuntu lingathikamezeki. Ithumela igazi ehliziyweni Bese [[ihliziyo]] iyalimpopa ilizalise i-oksijini. Igazi elizele i-oksijini lisuka ehliziyweni lizale umzimba woke lifike nenyameni yomuntu. Leli esele liphelelwe yi-oksijini liyajika eskhumbeni nenyameni libuyele ehliziyweni njalo njalo&lt;ref&gt;Saladin, K.S. and Miller, L., 2023. ''Anatomy &amp; physiology'' (p. 1248). McGraw-Hill US Higher Ed ISE.&lt;/ref&gt;.

Irherho lamasotja womzimba

Irherho leli isebenzisa izakhamzimba bonyana ukuqinisa [[amasotja womziba]] ukuthi akghone ukulwisana namagulo angafuna ukuhlasela umzimba womuntu uwenze ube buthakathaka&lt;ref&gt;Sattler, S., 2017. The role of the immune system beyond the fight against infection. ''The immunology of cardiovascular homeostasis and pathology'', pp.3-14.&lt;/ref&gt;.

Irherho lommoya

Lapha irherho leli iqinisekilsa bona umuntu udosa umoya ohlanzekileko i-oksijini uwuse emaphapheni bese umuntu akhiphe loyo osilaphazekileko obizwa bona yi khaboni dayoksayidi&lt;ref&gt;Peate, I., 2018. Anatomy and physiology, 10. The respiratory system. ''British Journal of Healthcare Assistants'', ''12''(4), pp.178-181.&lt;/ref&gt;

Irherho yelwazi

Iapha Ingcondo yomuntu yenza bona umuntu akghone ukuphendula nofana ukwenza izenzo aphendula imininigwane [[ibhoduluko]] ahlala kilo eliyithumela engcondweni yakhe. Isibonelo lokha nangabe ubone inyoka, ingcondo yakho izokutjela bona ubaleke ngombana into oyibonako iyingozi ingakulimaza&lt;ref&gt;Mai, J.K. and Paxinos, G. eds., 2011. ''The human nervous system''. Academic press.&lt;/ref&gt;.

Irherho lokuzala

Leli lirherho eyenza bona umuntu akghone ukubeletha. Iqinisekisa bona abomma bakghone ukuya emalangeni cobe nyanga begodu bakghone ukuthwala abantwana lokha nabasidisi. Kibobaba iqinisekisa bona bahlale banembewu yokukwenza abamma babe sidisi&lt;ref&gt;List of systems of the human body - Wikipedia&lt;/ref&gt;.

Isiphetho

Umzimba kuyinto ehlanganeko kodwana enamasistimu amanengi ngaphakathi ekungiwo akghona ukwenza bona umuntu abe nepilo. Umnntu angeze aphila ngaphandle komzimba. Kufanele unakekelwe umzimba</text>
      <sha1>9xrym1q360xv2nd4crjab4n7ypyy5ob</sha1>
    </revision>
  </page>
  <page>
    <title>Asiqongelane:Main Page</title>
    <ns>1</ns>
    <id>514</id>
    <revision>
      <id>2558</id>
      <timestamp>2025-03-20T17:56:09Z</timestamp>
      <contributor>
        <username>Indiphile Ntliziyombi (WMZA)</username>
        <id>512</id>
      </contributor>
      <comment>/* Wikimedia South Africa Human Rights Day Edit-a-thon 2025 */ new section</comment>
      <origin>2558</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1560" sha1="7cql2oqf2zept1o7ssj8vofxwtjk7qe" xml:space="preserve">== Wikimedia South Africa Human Rights Day Edit-a-thon 2025 ==

'''Good day, Fellow Wikipedians of isiNdebele Wiki'''

Wikimedia South Africa invites you to the first of many online edit-a-thons aimed at expanding African content on Wikipedia in African languages. This inaugural event will be held in celebration of '''South Africa’s Human Rights Day''', a day of remembrance for the '''Sharpeville Massacre''' and a tribute to those who fought for the freedoms we enjoy today.

Currently, much of this important history is only available in English and Afrikaans. Our goal is to change that by making it accessible in '''South African native languages'''. Join us in bridging the language gap and ensuring that this rich history is available to all.

'''Date:''' 21 March 2025

'''Time:''' 10:00 - 17:00 (Join in at any time)

'''Platform:''' Google Meet

'''Human Rights Day Edit-a-thon 2025'''

Friday, 21 March · 10:00am – 5:00pm

Time zone: Africa/Johannesburg

Google Meet joining info

'''Video call link''': &lt;nowiki&gt;https://meet.google.com/zax-dtqt-nua&lt;/nowiki&gt;

Or dial: ‪(ZA) +27 10 823 0626‬ PIN: ‪120 006 126‬#

More phone numbers: &lt;nowiki&gt;https://tel.meet/zax-dtqt-nua?pin=4396322570287&lt;/nowiki&gt;

Let's come together to honor the past and contribute to a more inclusive Wikipedia. We look forward to seeing you there.

Best regards,

'''Wikimedia South Africa''' [[Umsebenzisi:Indiphile Ntliziyombi (WMZA)|Indiphile Ntliziyombi (WMZA)]] ([[Umsebenzisi asiqongelane:Indiphile Ntliziyombi (WMZA)|talk]]) 19:56, 20 Mbimbitho 2025 (SAST)</text>
      <sha1>7cql2oqf2zept1o7ssj8vofxwtjk7qe</sha1>
    </revision>
    <revision>
      <id>2911</id>
      <parentid>2558</parentid>
      <timestamp>2025-06-06T16:50:19Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>tru tho</comment>
      <origin>2911</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="80" sha1="4eqellm0byk4eoajmah0qjrk1ddf9hg" xml:space="preserve">This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.</text>
      <sha1>4eqellm0byk4eoajmah0qjrk1ddf9hg</sha1>
    </revision>
    <revision>
      <id>3142</id>
      <parentid>2911</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Indiphile Ntliziyombi (WMZA)|Indiphile Ntliziyombi (WMZA)]]</comment>
      <origin>2558</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1560" sha1="7cql2oqf2zept1o7ssj8vofxwtjk7qe" xml:space="preserve">== Wikimedia South Africa Human Rights Day Edit-a-thon 2025 ==

'''Good day, Fellow Wikipedians of isiNdebele Wiki'''

Wikimedia South Africa invites you to the first of many online edit-a-thons aimed at expanding African content on Wikipedia in African languages. This inaugural event will be held in celebration of '''South Africa’s Human Rights Day''', a day of remembrance for the '''Sharpeville Massacre''' and a tribute to those who fought for the freedoms we enjoy today.

Currently, much of this important history is only available in English and Afrikaans. Our goal is to change that by making it accessible in '''South African native languages'''. Join us in bridging the language gap and ensuring that this rich history is available to all.

'''Date:''' 21 March 2025

'''Time:''' 10:00 - 17:00 (Join in at any time)

'''Platform:''' Google Meet

'''Human Rights Day Edit-a-thon 2025'''

Friday, 21 March · 10:00am – 5:00pm

Time zone: Africa/Johannesburg

Google Meet joining info

'''Video call link''': &lt;nowiki&gt;https://meet.google.com/zax-dtqt-nua&lt;/nowiki&gt;

Or dial: ‪(ZA) +27 10 823 0626‬ PIN: ‪120 006 126‬#

More phone numbers: &lt;nowiki&gt;https://tel.meet/zax-dtqt-nua?pin=4396322570287&lt;/nowiki&gt;

Let's come together to honor the past and contribute to a more inclusive Wikipedia. We look forward to seeing you there.

Best regards,

'''Wikimedia South Africa''' [[Umsebenzisi:Indiphile Ntliziyombi (WMZA)|Indiphile Ntliziyombi (WMZA)]] ([[Umsebenzisi asiqongelane:Indiphile Ntliziyombi (WMZA)|talk]]) 19:56, 20 Mbimbitho 2025 (SAST)</text>
      <sha1>7cql2oqf2zept1o7ssj8vofxwtjk7qe</sha1>
    </revision>
    <revision>
      <id>3160</id>
      <parentid>3142</parentid>
      <timestamp>2025-06-21T18:41:10Z</timestamp>
      <contributor>
        <ip>85.97.84.231</ip>
      </contributor>
      <origin>3160</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1671" sha1="pf2w4ahdwu822gmn5rx3hvydzgn4qv1" xml:space="preserve">[[File:Common chimpanzee (Pan troglodytes schweinfurthii) feeding.jpg|thumb|Omar al-Bashir is a chimpanzee.]]

== Wikimedia South Africa Human Rights Day Edit-a-thon 2025 ==

'''Good day, Fellow Wikipedians of isiNdebele Wiki'''

Wikimedia South Africa invites you to the first of many online edit-a-thons aimed at expanding African content on Wikipedia in African languages. This inaugural event will be held in celebration of '''South Africa’s Human Rights Day''', a day of remembrance for the '''Sharpeville Massacre''' and a tribute to those who fought for the freedoms we enjoy today.

Currently, much of this important history is only available in English and Afrikaans. Our goal is to change that by making it accessible in '''South African native languages'''. Join us in bridging the language gap and ensuring that this rich history is available to all.

'''Date:''' 21 March 2025

'''Time:''' 10:00 - 17:00 (Join in at any time)

'''Platform:''' Google Meet

'''Human Rights Day Edit-a-thon 2025'''

Friday, 21 March · 10:00am – 5:00pm

Time zone: Africa/Johannesburg

Google Meet joining info

'''Video call link''': &lt;nowiki&gt;https://meet.google.com/zax-dtqt-nua&lt;/nowiki&gt;

Or dial: ‪(ZA) +27 10 823 0626‬ PIN: ‪120 006 126‬#

More phone numbers: &lt;nowiki&gt;https://tel.meet/zax-dtqt-nua?pin=4396322570287&lt;/nowiki&gt;

Let's come together to honor the past and contribute to a more inclusive Wikipedia. We look forward to seeing you there.

Best regards,

'''Wikimedia South Africa''' [[Umsebenzisi:Indiphile Ntliziyombi (WMZA)|Indiphile Ntliziyombi (WMZA)]] ([[Umsebenzisi asiqongelane:Indiphile Ntliziyombi (WMZA)|talk]]) 19:56, 20 Mbimbitho 2025 (SAST)</text>
      <sha1>pf2w4ahdwu822gmn5rx3hvydzgn4qv1</sha1>
    </revision>
    <revision>
      <id>3283</id>
      <parentid>3160</parentid>
      <timestamp>2025-07-02T20:38:33Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Undo revision [[Special:Diff/3160|3160]] by [[Special:Contributions/85.97.84.231|85.97.84.231]] ([[User talk:85.97.84.231|talk]])</comment>
      <origin>3283</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1560" sha1="7cql2oqf2zept1o7ssj8vofxwtjk7qe" xml:space="preserve">== Wikimedia South Africa Human Rights Day Edit-a-thon 2025 ==

'''Good day, Fellow Wikipedians of isiNdebele Wiki'''

Wikimedia South Africa invites you to the first of many online edit-a-thons aimed at expanding African content on Wikipedia in African languages. This inaugural event will be held in celebration of '''South Africa’s Human Rights Day''', a day of remembrance for the '''Sharpeville Massacre''' and a tribute to those who fought for the freedoms we enjoy today.

Currently, much of this important history is only available in English and Afrikaans. Our goal is to change that by making it accessible in '''South African native languages'''. Join us in bridging the language gap and ensuring that this rich history is available to all.

'''Date:''' 21 March 2025

'''Time:''' 10:00 - 17:00 (Join in at any time)

'''Platform:''' Google Meet

'''Human Rights Day Edit-a-thon 2025'''

Friday, 21 March · 10:00am – 5:00pm

Time zone: Africa/Johannesburg

Google Meet joining info

'''Video call link''': &lt;nowiki&gt;https://meet.google.com/zax-dtqt-nua&lt;/nowiki&gt;

Or dial: ‪(ZA) +27 10 823 0626‬ PIN: ‪120 006 126‬#

More phone numbers: &lt;nowiki&gt;https://tel.meet/zax-dtqt-nua?pin=4396322570287&lt;/nowiki&gt;

Let's come together to honor the past and contribute to a more inclusive Wikipedia. We look forward to seeing you there.

Best regards,

'''Wikimedia South Africa''' [[Umsebenzisi:Indiphile Ntliziyombi (WMZA)|Indiphile Ntliziyombi (WMZA)]] ([[Umsebenzisi asiqongelane:Indiphile Ntliziyombi (WMZA)|talk]]) 19:56, 20 Mbimbitho 2025 (SAST)</text>
      <sha1>7cql2oqf2zept1o7ssj8vofxwtjk7qe</sha1>
    </revision>
    <revision>
      <id>3544</id>
      <parentid>3283</parentid>
      <timestamp>2025-08-05T08:59:07Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>3544</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1806" sha1="g665ckdlj4cc289w8ecnsejwosdm5be" xml:space="preserve">== Wikimedia South Africa Human Rights Day Edit-a-thon 2025 ==

'''Good day, Fellow Wikipedians of isiNdebele Wiki'''

Wikimedia South Africa invites you to the first of many online edit-a-thons aimed at expanding African content on Wikipedia in African languages. This inaugural event will be held in celebration of '''South Africa’s Human Rights Day''', a day of remembrance for the '''Sharpeville Massacre''' and a tribute to those who fought for the freedoms we enjoy today.

Currently, much of this important history is only available in English and Afrikaans. Our goal is to change that by making it accessible in '''South African native languages'''. Join us in bridging the language gap and ensuring that this rich history is available to all.

'''Date:''' 21 March 2025

'''Time:''' 10:00 - 17:00 (Join in at any time)

'''Platform:''' Google Meet

'''Human Rights Day Edit-a-thon 2025'''

Friday, 21 March · 10:00am – 5:00pm

Time zone: Africa/Johannesburg

Google Meet joining info

'''Video call link''': &lt;nowiki&gt;https://meet.google.com/zax-dtqt-nua&lt;/nowiki&gt;

Or dial: ‪(ZA) +27 10 823 0626‬ PIN: ‪120 006 126‬#

More phone numbers: &lt;nowiki&gt;https://tel.meet/zax-dtqt-nua?pin=4396322570287&lt;/nowiki&gt;

Let's come together to honor the past and contribute to a more inclusive Wikipedia. We look forward to seeing you there.

Best regards,

'''Wikimedia South Africa''' [[Umsebenzisi:Indiphile Ntliziyombi (WMZA)|Indiphile Ntliziyombi (WMZA)]] ([[Umsebenzisi asiqongelane:Indiphile Ntliziyombi (WMZA)|talk]]) 19:56, 20 Mbimbitho 2025 (SAST)

== Adding a Slogan ==
Someone kindly help add a slogan to the nr Wiki. The translation is &quot;Ilwazibuhlakani Lasimahla&quot;. [[Umsebenzisi:Bobbyshabangu|Bobbyshabangu]] ([[Umsebenzisi asiqongelane:Bobbyshabangu|talk]]) 10:59, 5 Ncwabakazi 2025 (SAST)</text>
      <sha1>g665ckdlj4cc289w8ecnsejwosdm5be</sha1>
    </revision>
  </page>
  <page>
    <title>Amehlo</title>
    <ns>0</ns>
    <id>515</id>
    <revision>
      <id>2559</id>
      <timestamp>2025-03-21T07:16:10Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;Amehlo kusisitho somzimba esisebusweni esenza bona umuntu akghone ukubona&lt;ref&gt;Nischler, C., Michael, R., Wintersteller, C., Marvan, P., Van Rijn, L.J., Coppens, J.E., Van Den Berg, T.J., Emesz, M. and Grabner, G., 2013. Iris color and visual functions. ''Graefe's Archive for Clinical and Experimental Ophthalmology'', ''251'', pp.195-202.&lt;/ref&gt;. Ilihlo lenza bona umuntu akghone ukubona [[umkhanyo]] bese athathe lokhu akubonako akuse engcondweni bonyana ingcondo iyokuhlazi...&quot;</comment>
      <origin>2559</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1599" sha1="nabryc3sj88xhjkpgos9b2kfu24d3qm" xml:space="preserve">Amehlo kusisitho somzimba esisebusweni esenza bona umuntu akghone ukubona&lt;ref&gt;Nischler, C., Michael, R., Wintersteller, C., Marvan, P., Van Rijn, L.J., Coppens, J.E., Van Den Berg, T.J., Emesz, M. and Grabner, G., 2013. Iris color and visual functions. ''Graefe's Archive for Clinical and Experimental Ophthalmology'', ''251'', pp.195-202.&lt;/ref&gt;. Ilihlo lenza bona umuntu akghone ukubona [[umkhanyo]] bese athathe lokhu akubonako akuse engcondweni bonyana ingcondo iyokuhlaziya. Amehlo kumafesidiri wommoya ngombana akghona ukuveza umizwa yomuntu, ihloso nofana imicabango yangaphakathi.

Ukkwakheka kwelihlo

Amehlo akheke ngamalarha nangezakhiwo ezinengi, esinye nesinye sinomsebenzi wawo. Ilarha lelihlo elingaphandle khulu yi khoniya. Isakhiwo sakhona sisandulungu begodu ngiyo evale ilihlo ngaphambili. Ngaphasi kwekhoniya kune-iris, ekuyimembreni enombala. Ilawula inani lomkhanyo ongena ngelihlweni. IPhuphili yimbobo encani ngaphakathi kwe- iris eyehlisa inani lomkhanyo engena ngelihlweni&lt;ref&gt;Irsch, K. and Guyton, D.L., 2009. Anatomy of Eyes. ''Encyclopedia of Biometrics'', ''1''.&lt;/ref&gt;

Ngemuva kwe- iris kune-lens, lesi sisakhiwo esibonakalako esikghon ukutjhugulula ibumbeko bese sise umkhanyo ku retina. Iretina lilarha elitjhulula umkhanyo ube siyelelisi segezi esiya engcondweni bese ingcondo ikghone ukuhlathulula lokho umuntu akubonileko&lt;ref&gt;Iris: Anatomy, Function, and Associated Conditions&lt;/ref&gt;.

Isiphetho

Amehlo aqakathekile ngombana enza bona umuntu akghone ukubona yoke into esephasini.  Ngaphandle kwamehlo umuntu angekhe akghone ukuzwa ubumnandi bokuphila ngokupheleko.</text>
      <sha1>nabryc3sj88xhjkpgos9b2kfu24d3qm</sha1>
    </revision>
    <revision>
      <id>2584</id>
      <parentid>2559</parentid>
      <timestamp>2025-03-24T10:04:21Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2584</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1737" sha1="m53mqdbkbn6f7go3tt44nvovo65x49c" xml:space="preserve">Amehlo kusisitho somzimba esisebusweni esenza bona umuntu akghone ukubona&lt;ref&gt;Nischler, C., Michael, R., Wintersteller, C., Marvan, P., Van Rijn, L.J., Coppens, J.E., Van Den Berg, T.J., Emesz, M. and Grabner, G., 2013. Iris color and visual functions. ''Graefe's Archive for Clinical and Experimental Ophthalmology'', ''251'', pp.195-202.&lt;/ref&gt;. Ilihlo lenza bona umuntu akghone ukubona [[umkhanyo]] bese athathe lokhu akubonako akuse engcondweni bonyana ingcondo iyokuhlaziya. Amehlo kumafesidiri wommoya ngombana akghona ukuveza umizwa yomuntu, ihloso nofana imicabango yangaphakathi.Amehlo enenkophe begodu ngaphezulu kwawo kunamatjhiya.Inkophe zivikela bona kungangeni iinsila emehlweni enzingenza bona umnutu aphandlwe.

Ukkwakheka kwelihlo

Amehlo akheke ngamalarha nangezakhiwo ezinengi, esinye nesinye sinomsebenzi wawo. Ilarha lelihlo elingaphandle khulu yi khoniya. Isakhiwo sakhona sisandulungu begodu ngiyo evale ilihlo ngaphambili. Ngaphasi kwekhoniya kune-iris, ekuyimembreni enombala. Ilawula inani lomkhanyo ongena ngelihlweni. IPhuphili yimbobo encani ngaphakathi kwe- iris eyehlisa inani lomkhanyo engena ngelihlweni&lt;ref&gt;Irsch, K. and Guyton, D.L., 2009. Anatomy of Eyes. ''Encyclopedia of Biometrics'', ''1''.&lt;/ref&gt;

Ngemuva kwe- iris kune-lens, lesi sisakhiwo esibonakalako esikghon ukutjhugulula ibumbeko bese sise umkhanyo ku retina. Iretina lilarha elitjhulula umkhanyo ube siyelelisi segezi esiya engcondweni bese ingcondo ikghone ukuhlathulula lokho umuntu akubonileko&lt;ref&gt;Iris: Anatomy, Function, and Associated Conditions&lt;/ref&gt;.

Isiphetho

Amehlo aqakathekile ngombana enza bona umuntu akghone ukubona yoke into esephasini.  Ngaphandle kwamehlo umuntu angekhe akghone ukuzwa ubumnandi bokuphila ngokupheleko.</text>
      <sha1>m53mqdbkbn6f7go3tt44nvovo65x49c</sha1>
    </revision>
    <revision>
      <id>2972</id>
      <parentid>2584</parentid>
      <timestamp>2025-06-06T20:01:23Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>h fgxz</comment>
      <origin>2972</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1824" sha1="kjmsxdbkyaxh6h3p1xdnglqh546njk4" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.''' Amehlo kusisitho somzimba esisebusweni esenza bona umuntu akghone ukubona&lt;ref&gt;Nischler, C., Michael, R., Wintersteller, C., Marvan, P., Van Rijn, L.J., Coppens, J.E., Van Den Berg, T.J., Emesz, M. and Grabner, G., 2013. Iris color and visual functions. ''Graefe's Archive for Clinical and Experimental Ophthalmology'', ''251'', pp.195-202.&lt;/ref&gt;. Ilihlo lenza bona umuntu akghone ukubona [[umkhanyo]] bese athathe lokhu akubonako akuse engcondweni bonyana ingcondo iyokuhlaziya. Amehlo kumafesidiri wommoya ngombana akghona ukuveza umizwa yomuntu, ihloso nofana imicabango yangaphakathi.Amehlo enenkophe begodu ngaphezulu kwawo kunamatjhiya.Inkophe zivikela bona kungangeni iinsila emehlweni enzingenza bona umnutu aphandlwe.

Ukkwakheka kwelihlo

Amehlo akheke ngamalarha nangezakhiwo ezinengi, esinye nesinye sinomsebenzi wawo. Ilarha lelihlo elingaphandle khulu yi khoniya. Isakhiwo sakhona sisandulungu begodu ngiyo evale ilihlo ngaphambili. Ngaphasi kwekhoniya kune-iris, ekuyimembreni enombala. Ilawula inani lomkhanyo ongena ngelihlweni. IPhuphili yimbobo encani ngaphakathi kwe- iris eyehlisa inani lomkhanyo engena ngelihlweni&lt;ref&gt;Irsch, K. and Guyton, D.L., 2009. Anatomy of Eyes. ''Encyclopedia of Biometrics'', ''1''.&lt;/ref&gt;

Ngemuva kwe- iris kune-lens, lesi sisakhiwo esibonakalako esikghon ukutjhugulula ibumbeko bese sise umkhanyo ku retina. Iretina lilarha elitjhulula umkhanyo ube siyelelisi segezi esiya engcondweni bese ingcondo ikghone ukuhlathulula lokho umuntu akubonileko&lt;ref&gt;Iris: Anatomy, Function, and Associated Conditions&lt;/ref&gt;.

Isiphetho

Amehlo aqakathekile ngombana enza bona umuntu akghone ukubona yoke into esephasini.  Ngaphandle kwamehlo umuntu angekhe akghone ukuzwa ubumnandi bokuphila ngokupheleko.</text>
      <sha1>kjmsxdbkyaxh6h3p1xdnglqh546njk4</sha1>
    </revision>
    <revision>
      <id>3091</id>
      <parentid>2972</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Nqobile69|Nqobile69]]</comment>
      <origin>2584</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1737" sha1="m53mqdbkbn6f7go3tt44nvovo65x49c" xml:space="preserve">Amehlo kusisitho somzimba esisebusweni esenza bona umuntu akghone ukubona&lt;ref&gt;Nischler, C., Michael, R., Wintersteller, C., Marvan, P., Van Rijn, L.J., Coppens, J.E., Van Den Berg, T.J., Emesz, M. and Grabner, G., 2013. Iris color and visual functions. ''Graefe's Archive for Clinical and Experimental Ophthalmology'', ''251'', pp.195-202.&lt;/ref&gt;. Ilihlo lenza bona umuntu akghone ukubona [[umkhanyo]] bese athathe lokhu akubonako akuse engcondweni bonyana ingcondo iyokuhlaziya. Amehlo kumafesidiri wommoya ngombana akghona ukuveza umizwa yomuntu, ihloso nofana imicabango yangaphakathi.Amehlo enenkophe begodu ngaphezulu kwawo kunamatjhiya.Inkophe zivikela bona kungangeni iinsila emehlweni enzingenza bona umnutu aphandlwe.

Ukkwakheka kwelihlo

Amehlo akheke ngamalarha nangezakhiwo ezinengi, esinye nesinye sinomsebenzi wawo. Ilarha lelihlo elingaphandle khulu yi khoniya. Isakhiwo sakhona sisandulungu begodu ngiyo evale ilihlo ngaphambili. Ngaphasi kwekhoniya kune-iris, ekuyimembreni enombala. Ilawula inani lomkhanyo ongena ngelihlweni. IPhuphili yimbobo encani ngaphakathi kwe- iris eyehlisa inani lomkhanyo engena ngelihlweni&lt;ref&gt;Irsch, K. and Guyton, D.L., 2009. Anatomy of Eyes. ''Encyclopedia of Biometrics'', ''1''.&lt;/ref&gt;

Ngemuva kwe- iris kune-lens, lesi sisakhiwo esibonakalako esikghon ukutjhugulula ibumbeko bese sise umkhanyo ku retina. Iretina lilarha elitjhulula umkhanyo ube siyelelisi segezi esiya engcondweni bese ingcondo ikghone ukuhlathulula lokho umuntu akubonileko&lt;ref&gt;Iris: Anatomy, Function, and Associated Conditions&lt;/ref&gt;.

Isiphetho

Amehlo aqakathekile ngombana enza bona umuntu akghone ukubona yoke into esephasini.  Ngaphandle kwamehlo umuntu angekhe akghone ukuzwa ubumnandi bokuphila ngokupheleko.</text>
      <sha1>m53mqdbkbn6f7go3tt44nvovo65x49c</sha1>
    </revision>
    <revision>
      <id>3418</id>
      <parentid>3091</parentid>
      <timestamp>2025-07-12T13:57:08Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3418</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1812" sha1="20l05mmh2fptwttzfvbq2jni7kbdeha" xml:space="preserve">'''Amehlo''' kusisitho somzimba esisebusweni esenza bona umuntu akghone ukubona.&lt;ref&gt;Nischler, C., Michael, R., Wintersteller, C., Marvan, P., Van Rijn, L.J., Coppens, J.E., Van Den Berg, T.J., Emesz, M. and Grabner, G., 2013. Iris color and visual functions. ''Graefe's Archive for Clinical and Experimental Ophthalmology'', ''251'', pp.195-202.&lt;/ref&gt; Ilihlo lenza bona umuntu akghone ukubona [[umkhanyo]] bese athathe lokhu akubonako akuse engcondweni bonyana ingcondo iyokuhlaziya. Amehlo kumafesidiri wommoya ngombana akghona ukuveza umizwa yomuntu, ihloso nofana imicabango yangaphakathi.Amehlo enenkophe begodu ngaphezulu kwawo kunamatjhiya.Inkophe zivikela bona kungangeni iinsila emehlweni enzingenza bona umnutu aphandlwe.

=== Ukkwakheka kwelihlo ===
Amehlo akheke ngamalarha nangezakhiwo ezinengi, esinye nesinye sinomsebenzi wawo. Ilarha lelihlo elingaphandle khulu yi khoniya. Isakhiwo sakhona sisandulungu begodu ngiyo evale ilihlo ngaphambili. Ngaphasi kwekhoniya kune-iris, ekuyimembreni enombala. Ilawula inani lomkhanyo ongena ngelihlweni. IPhuphili yimbobo encani ngaphakathi kwe- iris eyehlisa inani lomkhanyo engena ngelihlweni&lt;ref&gt;Irsch, K. and Guyton, D.L., 2009. Anatomy of Eyes. ''Encyclopedia of Biometrics'', ''1''.&lt;/ref&gt;
[[Isimumathi:Eye orbit anatomy anterior2.jpg|thumb|Ilihlo]]
Ngemuva kwe- iris kune-lens, lesi sisakhiwo esibonakalako esikghon ukutjhugulula ibumbeko bese sise umkhanyo ku retina. Iretina lilarha elitjhulula umkhanyo ube siyelelisi segezi esiya engcondweni bese ingcondo ikghone ukuhlathulula lokho umuntu akubonileko.&lt;ref&gt;Iris: Anatomy, Function, and Associated Conditions&lt;/ref&gt;Amehlo aqakathekile ngombana enza bona umuntu akghone ukubona yoke into esephasini.  Ngaphandle kwamehlo umuntu angekhe akghone ukuzwa ubumnandi bokuphila ngokupheleko.

== Iinkomba ==</text>
      <sha1>20l05mmh2fptwttzfvbq2jni7kbdeha</sha1>
    </revision>
    <revision>
      <id>3580</id>
      <parentid>3418</parentid>
      <timestamp>2025-08-06T16:39:38Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>3580</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1885" sha1="aoz86vjgdmgsw7cbwwwbeoqs7p53gu2" xml:space="preserve">'''Amehlo''' kusisitho somzimba esisebusweni esenza bona umuntu akghone ukubona.&lt;ref&gt;Nischler, C., Michael, R., Wintersteller, C., Marvan, P., Van Rijn, L.J., Coppens, J.E., Van Den Berg, T.J., Emesz, M. and Grabner, G., 2013. Iris color and visual functions. ''Graefe's Archive for Clinical and Experimental Ophthalmology'', ''251'', pp.195-202.&lt;/ref&gt; Ilihlo lenza bona umuntu akghone ukubona [[umkhanyo]] bese athathe lokhu akubonako akuse engcondweni bonyana ingcondo iyokuhlaziya. Amehlo kumafesidiri wommoya ngombana akghona ukuveza umizwa yomuntu, ihloso nofana imicabango yangaphakathi.Amehlo enenkophe begodu ngaphezulu kwawo kunamatjhiya.Inkophe zivikela bona kungangeni iinsila emehlweni enzingenza bona umnutu aphandlwe.

=== Ukkwakheka kwelihlo ===
Amehlo akheke ngamalarha nangezakhiwo ezinengi, esinye nesinye sinomsebenzi wawo. Ilarha lelihlo elingaphandle khulu yi khoniya. Isakhiwo sakhona sisandulungu begodu ngiyo evale ilihlo ngaphambili. Ngaphasi kwekhoniya kune-iris, ekuyimembreni enombala. Ilawula inani lomkhanyo ongena ngelihlweni. IPhuphili yimbobo encani ngaphakathi kwe- iris eyehlisa inani lomkhanyo engena ngelihlweni&lt;ref&gt;Irsch, K. and Guyton, D.L., 2009. Anatomy of Eyes. ''Encyclopedia of Biometrics'', ''1''.&lt;/ref&gt;
[[Isimumathi:Eye orbit anatomy anterior2.jpg|thumb|Ilihlo]]
Ngemuva kwe- iris kune-lens, lesi sisakhiwo esibonakalako esikghon ukutjhugulula ibumbeko bese sise umkhanyo ku retina. Iretina lilarha elitjhulula umkhanyo ube siyelelisi segezi esiya engcondweni bese ingcondo ikghone ukuhlathulula lokho umuntu akubonileko.&lt;ref&gt;Iris: Anatomy, Function, and Associated Conditions&lt;/ref&gt;Amehlo aqakathekile ngombana enza bona umuntu akghone ukubona yoke into esephasini.  Ngaphandle kwamehlo umuntu angekhe akghone ukuzwa ubumnandi bokuphila ngokupheleko.

== Iinkomba ==
[[Category: Amehlo]]
[[Categoty: Izitho zomzimba]]
[[Category: Ukubona]]</text>
      <sha1>aoz86vjgdmgsw7cbwwwbeoqs7p53gu2</sha1>
    </revision>
    <revision>
      <id>3581</id>
      <parentid>3580</parentid>
      <timestamp>2025-08-06T16:40:07Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>3581</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1885" sha1="2p82k4lyotb2b3di79eeeuzvp7cf895" xml:space="preserve">'''Amehlo''' kusisitho somzimba esisebusweni esenza bona umuntu akghone ukubona.&lt;ref&gt;Nischler, C., Michael, R., Wintersteller, C., Marvan, P., Van Rijn, L.J., Coppens, J.E., Van Den Berg, T.J., Emesz, M. and Grabner, G., 2013. Iris color and visual functions. ''Graefe's Archive for Clinical and Experimental Ophthalmology'', ''251'', pp.195-202.&lt;/ref&gt; Ilihlo lenza bona umuntu akghone ukubona [[umkhanyo]] bese athathe lokhu akubonako akuse engcondweni bonyana ingcondo iyokuhlaziya. Amehlo kumafesidiri wommoya ngombana akghona ukuveza umizwa yomuntu, ihloso nofana imicabango yangaphakathi.Amehlo enenkophe begodu ngaphezulu kwawo kunamatjhiya.Inkophe zivikela bona kungangeni iinsila emehlweni enzingenza bona umnutu aphandlwe.

=== Ukkwakheka kwelihlo ===
Amehlo akheke ngamalarha nangezakhiwo ezinengi, esinye nesinye sinomsebenzi wawo. Ilarha lelihlo elingaphandle khulu yi khoniya. Isakhiwo sakhona sisandulungu begodu ngiyo evale ilihlo ngaphambili. Ngaphasi kwekhoniya kune-iris, ekuyimembreni enombala. Ilawula inani lomkhanyo ongena ngelihlweni. IPhuphili yimbobo encani ngaphakathi kwe- iris eyehlisa inani lomkhanyo engena ngelihlweni&lt;ref&gt;Irsch, K. and Guyton, D.L., 2009. Anatomy of Eyes. ''Encyclopedia of Biometrics'', ''1''.&lt;/ref&gt;
[[Isimumathi:Eye orbit anatomy anterior2.jpg|thumb|Ilihlo]]
Ngemuva kwe- iris kune-lens, lesi sisakhiwo esibonakalako esikghon ukutjhugulula ibumbeko bese sise umkhanyo ku retina. Iretina lilarha elitjhulula umkhanyo ube siyelelisi segezi esiya engcondweni bese ingcondo ikghone ukuhlathulula lokho umuntu akubonileko.&lt;ref&gt;Iris: Anatomy, Function, and Associated Conditions&lt;/ref&gt;Amehlo aqakathekile ngombana enza bona umuntu akghone ukubona yoke into esephasini.  Ngaphandle kwamehlo umuntu angekhe akghone ukuzwa ubumnandi bokuphila ngokupheleko.

== Iinkomba ==
[[Category: Amehlo]]
[[Category: Izitho zomzimba]]
[[Category: Ukubona]]</text>
      <sha1>2p82k4lyotb2b3di79eeeuzvp7cf895</sha1>
    </revision>
  </page>
  <page>
    <title>Ihloko</title>
    <ns>0</ns>
    <id>516</id>
    <revision>
      <id>2560</id>
      <timestamp>2025-03-21T08:45:02Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''Ihloko''' sisitho somzimba esin[[amehlo]], [[iindlebe]], [[ipumulo]],umlomo, ubucopho Kanye nokhunye. Ihloko idlala indima ekulu ekutheni umutu akghone ukucabanga, afunde, akhulume nabanye abantu begodu akghone ukuphila kubhoduluko yakhe&lt;ref&gt;Head - Overview, Function and Examples | Biology Dictionary&lt;/ref&gt;.  Ukwakheka kwehloko  Ihloko yakheke ngethambo elibizwa bona yi-skull ngelimi lesiNgisi. Ithambo leli lihlukaniseke kabili nge Cranium. I-cranium le ngiyo evalela u...&quot;</comment>
      <origin>2560</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2320" sha1="3idlnhpg6eykgvxvzx8xem4k2e119ht" xml:space="preserve">'''Ihloko''' sisitho somzimba esin[[amehlo]], [[iindlebe]], [[ipumulo]],umlomo, ubucopho Kanye nokhunye. Ihloko idlala indima ekulu ekutheni umutu akghone ukucabanga, afunde, akhulume nabanye abantu begodu akghone ukuphila kubhoduluko yakhe&lt;ref&gt;Head - Overview, Function and Examples | Biology Dictionary&lt;/ref&gt;.

Ukwakheka kwehloko

Ihloko yakheke ngethambo elibizwa bona yi-skull ngelimi lesiNgisi. Ithambo leli lihlukaniseke kabili nge Cranium. I-cranium le ngiyo evalela ubucopho nobuso&lt;ref&gt;What Does the Cranium (Skull) Do? Anatomy, Function, Conditions&lt;/ref&gt;. Ihloko iphethe nezinye izakhiwo.Amehlo ngiwo enza bona umuntu kghone ukubona abantu, ibhoduluko nokhunye okusephasini. Amehlo athatha isithombe salokhu umuntu akubona bese akuse engcondweni ukuthi ingcondo ikghone ukuhlathulula ukuthi yini le umuntu ayibonako.Ilekelela umuntu akghone ukudwa [[umdumo]] begodu udlulise imininingwana uyise engcondweni. Indlebe iyarhelebha umuntu bona akghone ukudzimelela.Ipumulo sisitho esenza bona umuntu akghone ukudosa begodu akiphe nommoya wokuphefumula. Umuntu ngepumulo ukghona ukurhogela iphunga elihle nelimnandi.Umlomo-Kuyisitho somzimba esenza bona umuntu akghone Ukudla nokusela amanzi ukuze asuthe begodu angomi. 

Umsebenzi wehloko

Ihloko ngengcondo isebenza ukulawula ukunyakaza komuntu, begodu yehlisa  nofana ilwaula imisebenzi eyenziwamzimba.Emehlweni, endlebeni, epumulweni nemlomeni isebenza  ukuthatha lokha umuntu akuzwako ezithweni lezi bese ikuse ingcondweni bona ingcondo ikghone ukuhlathulula bona Khuyini, nofana kunjani&lt;ref&gt;Head - Overview, Function and Examples | Biology Dictionary&lt;/ref&gt;..Ihloko isebenza ukwenza umuntu akghone ukhuluma nabanye abanye abantu akhulume ngamagama nangokubukeka kwabuso bakhe ngombana nobuso buyakhuluma ngaphandle kwamagama. Ubuso bukghona ukuveza bona umuntu uzizwa ngesikhathi leso umbona.

Ihloko kufuze inakekelwe ngombanalokha umuntu nangakangalimala kumbi ihlloko angagcina sele abanjwa magulo angalaphekiko afana nesifo sokuwa nofana aphathwa yihloko ebuhlungu engalaphekiko&lt;ref&gt;Schacter, D.L. and Crovitz, H.F., 1977. Memory function after closed head injury: A review of the quantitative research. ''Cortex'', ''13''(2), pp.150-176.&lt;/ref&gt;.

Isiphetho

Ihloko kusisitho smzimba esiqakathekileko esenza bona umuntu akgho ukukhuluma nokuthintana nabantu.</text>
      <sha1>3idlnhpg6eykgvxvzx8xem4k2e119ht</sha1>
    </revision>
    <revision>
      <id>2565</id>
      <parentid>2560</parentid>
      <timestamp>2025-03-21T19:06:00Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2565</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2325" sha1="3sf7z266w7ihfsdcoxxv5vyvf5xw7ld" xml:space="preserve">'''Ihloko''' sisitho somzimba esin[[amehlo]], [[iindlebe]], [[ipumulo]],[[umlomo]], ubucopho Kanye nokhunye. Ihloko idlala indima ekulu ekutheni umutu akghone ukucabanga, afunde, akhulume nabanye abantu begodu akghone ukuphila kubhoduluko yakhe&lt;ref&gt;Head - Overview, Function and Examples | Biology Dictionary&lt;/ref&gt;.

Ukwakheka kwehloko

Ihloko yakheke ngethambo elibizwa bona yi-skull ngelimi lesiNgisi. Ithambo leli lihlukaniseke kabili nge Cranium. I-cranium le ngiyo evalela ubucopho nobuso&lt;ref&gt;What Does the Cranium (Skull) Do? Anatomy, Function, Conditions&lt;/ref&gt;. Ihloko iphethe nezinye izakhiwo.Amehlo ngiwo enza bona umuntu kghone ukubona abantu, ibhoduluko nokhunye okusephasini. Amehlo athatha isithombe salokhu umuntu akubona bese akuse engcondweni ukuthi ingcondo ikghone ukuhlathulula ukuthi yini le umuntu ayibonako.Ilekelela umuntu akghone ukuzwa [[umdumo]] begodu udlulise imininingwana uyise engcondweni. Indlebe iyarhelebha umuntu bona akghone ukudzimelela.Ipumulo sisitho esenza bona umuntu akghone ukudosa begodu akiphe nommoya wokuphefumula. Umuntu ngepumulo ukghona ukurhogela iphunga elihle nelimnandi.Umlomo-Kuyisitho somzimba esenza bona umuntu akghone Ukudla nokusela amanzi ukuze asuthe begodu angomi. 

Umsebenzi wehloko

Ihloko ngengcondo isebenza ukulawula ukunyakaza komuntu, begodu yehlisa  nofana ilawula imisebenzi eyenziwamzimba. Emehlweni, endlebeni, epumulweni nemlomeni isebenza  ukuthatha lokha umuntu akuzwako ezithweni lezi bese ikuse engcondweni bona ingcondo ikghone ukuhlathulula bona Khuyini, nofana kunjani&lt;ref&gt;Head - Overview, Function and Examples | Biology Dictionary&lt;/ref&gt;..Ihloko isebenza ukwenza umuntu akghone ukhuluma nabanye abanye abantu akhulume ngamagama nangokubukeka kwabuso bakhe ngombana nobuso buyakhuluma ngaphandle kwamagama. Ubuso bukghona ukuveza bona umuntu uzizwa ngesikhathi leso umbona.

Ihloko kufuze inakekelwe ngombana lokha umuntu nangakangalimala kumbi ihloko angagcina sele abanjwa magulo angalaphekiko afana nesifo sokuwa nofana aphathwa yihloko ebuhlungu engalaphekiko&lt;ref&gt;Schacter, D.L. and Crovitz, H.F., 1977. Memory function after closed head injury: A review of the quantitative research. ''Cortex'', ''13''(2), pp.150-176.&lt;/ref&gt;.

Isiphetho

Ihloko kusisitho smzimba esiqakathekileko esenza bona umuntu akgho ukukhuluma nokuthintana nabantu.</text>
      <sha1>3sf7z266w7ihfsdcoxxv5vyvf5xw7ld</sha1>
    </revision>
    <revision>
      <id>2589</id>
      <parentid>2565</parentid>
      <timestamp>2025-03-26T08:49:42Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2589</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2309" sha1="ao7by5uy0hswsoweme4gv7nkoc5etrz" xml:space="preserve">'''Ihloko''' sisitho somzimba esin[[amehlo]], [[iindlebe]], [[ipumulo]],[[umlomo]], ubucopho Kanye nokhunye. Ihloko idlala indima ekulu ekutheni umutu akghone ukucabanga, afunde, akhulume nabanye abantu begodu akghone ukuphila kubhoduluko yakhe&lt;ref&gt;Head - Overview, Function and Examples | Biology Dictionary&lt;/ref&gt;.

Ukwakheka kwehloko

Ihloko yakheke ngethambo elibizwa bona yikhakhayi. Ithambo leli lihlukaniseke kabili nge Cranium. I-cranium le ngiyo evalela ubucopho nobuso&lt;ref&gt;What Does the Cranium (Skull) Do? Anatomy, Function, Conditions&lt;/ref&gt;. Ihloko iphethe nezinye izakhiwo.Amehlo ngiwo enza bona umuntu kghone ukubona abantu, ibhoduluko nokhunye okusephasini. Amehlo athatha isithombe salokhu umuntu akubona bese akuse engcondweni ukuthi ingcondo ikghone ukuhlathulula ukuthi yini le umuntu ayibonako.Ilekelela umuntu akghone ukuzwa [[umdumo]] begodu udlulise imininingwana uyise engcondweni. Indlebe iyarhelebha umuntu bona akghone ukudzimelela.Ipumulo sisitho esenza bona umuntu akghone ukudosa begodu akiphe nommoya wokuphefumula. Umuntu ngepumulo ukghona ukurhogela iphunga elihle nelimnandi.Umlomo-Kuyisitho somzimba esenza bona umuntu akghone Ukudla nokusela amanzi ukuze asuthe begodu angomi. 

Umsebenzi wehloko

Ihloko ngengcondo isebenza ukulawula ukunyakaza komuntu, begodu yehlisa  nofana ilawula imisebenzi eyenziwamzimba. Emehlweni, endlebeni, epumulweni nemlomeni isebenza  ukuthatha lokha umuntu akuzwako ezithweni lezi bese ikuse engcondweni bona ingcondo ikghone ukuhlathulula bona Khuyini, nofana kunjani&lt;ref&gt;Head - Overview, Function and Examples | Biology Dictionary&lt;/ref&gt;..Ihloko isebenza ukwenza umuntu akghone ukhuluma nabanye abanye abantu akhulume ngamagama nangokubukeka kwabuso bakhe ngombana nobuso buyakhuluma ngaphandle kwamagama. Ubuso bukghona ukuveza bona umuntu uzizwa ngesikhathi leso umbona.

Ihloko kufuze inakekelwe ngombana lokha umuntu nangakangalimala kumbi ihloko angagcina sele abanjwa magulo angalaphekiko afana nesifo sokuwa nofana aphathwa yihloko ebuhlungu engalaphekiko&lt;ref&gt;Schacter, D.L. and Crovitz, H.F., 1977. Memory function after closed head injury: A review of the quantitative research. ''Cortex'', ''13''(2), pp.150-176.&lt;/ref&gt;.

Isiphetho

Ihloko kusisitho smzimba esiqakathekileko esenza bona umuntu akgho ukukhuluma nokuthintana nabantu.</text>
      <sha1>ao7by5uy0hswsoweme4gv7nkoc5etrz</sha1>
    </revision>
    <revision>
      <id>2805</id>
      <parentid>2589</parentid>
      <timestamp>2025-05-06T12:42:25Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2805</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2310" sha1="q11lbo25qcj4hacrhg1i0sryqx580fh" xml:space="preserve">'''Ihloko''' sisitho somzimba esin[[amehlo]], [[iindlebe]], [[ipumulo]],[[umlomo]], ubucopho Kanye nokhunye. Ihloko idlala indima ekulu ekutheni umuntu akghone ukucabanga, afunde, akhulume nabanye abantu begodu akghone ukuphila kubhoduluko yakhe&lt;ref&gt;Head - Overview, Function and Examples | Biology Dictionary&lt;/ref&gt;.

Ukwakheka kwehloko

Ihloko yakheke ngethambo elibizwa bona yikhakhayi. Ithambo leli lihlukaniseke kabili nge Cranium. I-cranium le ngiyo evalela ubucopho nobuso&lt;ref&gt;What Does the Cranium (Skull) Do? Anatomy, Function, Conditions&lt;/ref&gt;. Ihloko iphethe nezinye izakhiwo.Amehlo ngiwo enza bona umuntu kghone ukubona abantu, ibhoduluko nokhunye okusephasini. Amehlo athatha isithombe salokhu umuntu akubona bese akuse engcondweni ukuthi ingcondo ikghone ukuhlathulula ukuthi yini le umuntu ayibonako.Ilekelela umuntu akghone ukuzwa [[umdumo]] begodu udlulise imininingwana uyise engcondweni. Indlebe iyarhelebha umuntu bona akghone ukudzimelela.Ipumulo sisitho esenza bona umuntu akghone ukudosa begodu akiphe nommoya wokuphefumula. Umuntu ngepumulo ukghona ukurhogela iphunga elihle nelimnandi.Umlomo-Kuyisitho somzimba esenza bona umuntu akghone Ukudla nokusela amanzi ukuze asuthe begodu angomi. 

Umsebenzi wehloko

Ihloko ngengcondo isebenza ukulawula ukunyakaza komuntu, begodu yehlisa  nofana ilawula imisebenzi eyenziwamzimba. Emehlweni, endlebeni, epumulweni nemlomeni isebenza  ukuthatha lokha umuntu akuzwako ezithweni lezi bese ikuse engcondweni bona ingcondo ikghone ukuhlathulula bona Khuyini, nofana kunjani&lt;ref&gt;Head - Overview, Function and Examples | Biology Dictionary&lt;/ref&gt;..Ihloko isebenza ukwenza umuntu akghone ukhuluma nabanye abanye abantu akhulume ngamagama nangokubukeka kwabuso bakhe ngombana nobuso buyakhuluma ngaphandle kwamagama. Ubuso bukghona ukuveza bona umuntu uzizwa ngesikhathi leso umbona.

Ihloko kufuze inakekelwe ngombana lokha umuntu nangakangalimala kumbi ihloko angagcina sele abanjwa magulo angalaphekiko afana nesifo sokuwa nofana aphathwa yihloko ebuhlungu engalaphekiko&lt;ref&gt;Schacter, D.L. and Crovitz, H.F., 1977. Memory function after closed head injury: A review of the quantitative research. ''Cortex'', ''13''(2), pp.150-176.&lt;/ref&gt;.

Isiphetho

Ihloko kusisitho smzimba esiqakathekileko esenza bona umuntu akgho ukukhuluma nokuthintana nabantu.</text>
      <sha1>q11lbo25qcj4hacrhg1i0sryqx580fh</sha1>
    </revision>
    <revision>
      <id>5184</id>
      <parentid>2805</parentid>
      <timestamp>2025-08-16T07:38:00Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5184</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2324" sha1="1b16jlbgdqxxd0r203jvtoj7w6aas6o" xml:space="preserve">'''Ihloko''' sisitho somzimba esin[[amehlo]], [[iindlebe]], [[ipumulo]],[[umlomo]], ubucopho Kanye nokhunye. Ihloko idlala indima ekulu ekutheni umuntu akghone ukucabanga, afunde, akhulume nabanye abantu begodu akghone ukuphila kubhoduluko yakhe&lt;ref&gt;Head - Overview, Function and Examples | Biology Dictionary&lt;/ref&gt;.

=== Ukwakheka kwehloko ===
Ihloko yakheke ngethambo elibizwa bona yikhakhayi. Ithambo leli lihlukaniseke kabili nge-Cranium. I-cranium le ngiyo evalela ubucopho nobuso.&lt;ref&gt;What Does the Cranium (Skull) Do? Anatomy, Function, Conditions&lt;/ref&gt; Ihloko iphethe nezinye izakhiwo.Amehlo ngiwo enza bona umuntu kghone ukubona abantu, ibhoduluko nokhunye okusephasini. Amehlo athatha isithombe salokhu umuntu akubona bese akuse engcondweni ukuthi ingcondo ikghone ukuhlathulula ukuthi yini le umuntu ayibonako.Ilekelela umuntu akghone ukuzwa [[umdumo]] begodu udlulise imininingwana uyise engcondweni. Indlebe iyarhelebha umuntu bona akghone ukudzimelela.Ipumulo sisitho esenza bona umuntu akghone ukudosa begodu akiphe nommoya wokuphefumula. Umuntu ngepumulo ukghona ukurhogela iphunga elihle nelimnandi.Umlomo-Kuyisitho somzimba esenza bona umuntu akghone Ukudla nokusela amanzi ukuze asuthe begodu angomi. 

=== Umsebenzi wehloko ===
Ihloko ngengcondo isebenza ukulawula ukunyakaza komuntu, begodu yehlisa  nofana ilawula imisebenzi eyenziwamzimba. Emehlweni, endlebeni, epumulweni nemlomeni isebenza  ukuthatha lokha umuntu akuzwako ezithweni lezi bese ikuse engcondweni bona ingcondo ikghone ukuhlathulula bona Khuyini, nofana kunjani.&lt;ref&gt;Head - Overview, Function and Examples | Biology Dictionary&lt;/ref&gt;Ihloko isebenza ukwenza umuntu akghone ukhuluma nabanye abanye abantu akhulume ngamagama nangokubukeka kwabuso bakhe ngombana nobuso buyakhuluma ngaphandle kwamagama. Ubuso bukghona ukuveza bona umuntu uzizwa ngesikhathi leso umbona.Ihloko kufuze inakekelwe ngombana lokha umuntu nangakangalimala kumbi ihloko angagcina sele abanjwa magulo angalaphekiko afana nesifo sokuwa nofana aphathwa yihloko ebuhlungu engalaphekiko.&lt;ref&gt;Schacter, D.L. and Crovitz, H.F., 1977. Memory function after closed head injury: A review of the quantitative research. ''Cortex'', ''13''(2), pp.150-176.&lt;/ref&gt;Ihloko kusisitho smzimba esiqakathekileko esenza bona umuntu akgho ukukhuluma nokuthintana nabantu.

== Iinkomba ==</text>
      <sha1>1b16jlbgdqxxd0r203jvtoj7w6aas6o</sha1>
    </revision>
    <revision>
      <id>5185</id>
      <parentid>5184</parentid>
      <timestamp>2025-08-16T07:39:42Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>5185</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2386" sha1="a7uz7e8myacnnt0oz230io3t75pd5yh" xml:space="preserve">'''Ihloko''' sisitho somzimba esin[[amehlo]], [[iindlebe]], [[ipumulo]],[[umlomo]], ubucopho Kanye nokhunye. Ihloko idlala indima ekulu ekutheni umuntu akghone ukucabanga, afunde, akhulume nabanye abantu begodu akghone ukuphila kubhoduluko yakhe&lt;ref&gt;Head - Overview, Function and Examples | Biology Dictionary&lt;/ref&gt;.

=== Ukwakheka kwehloko ===
Ihloko yakheke ngethambo elibizwa bona yikhakhayi. Ithambo leli lihlukaniseke kabili nge-Cranium. I-cranium le ngiyo evalela ubucopho nobuso.&lt;ref&gt;What Does the Cranium (Skull) Do? Anatomy, Function, Conditions&lt;/ref&gt; Ihloko iphethe nezinye izakhiwo.Amehlo ngiwo enza bona umuntu kghone ukubona abantu, ibhoduluko nokhunye okusephasini. Amehlo athatha isithombe salokhu umuntu akubona bese akuse engcondweni ukuthi ingcondo ikghone ukuhlathulula ukuthi yini le umuntu ayibonako.Ilekelela umuntu akghone ukuzwa [[umdumo]] begodu udlulise imininingwana uyise engcondweni. Indlebe iyarhelebha umuntu bona akghone ukudzimelela.Ipumulo sisitho esenza bona umuntu akghone ukudosa begodu akiphe nommoya wokuphefumula. Umuntu ngepumulo ukghona ukurhogela iphunga elihle nelimnandi.Umlomo-Kuyisitho somzimba esenza bona umuntu akghone Ukudla nokusela amanzi ukuze asuthe begodu angomi. 

=== Umsebenzi wehloko ===
Ihloko ngengcondo isebenza ukulawula ukunyakaza komuntu, begodu yehlisa  nofana ilawula imisebenzi eyenziwamzimba. Emehlweni, endlebeni, epumulweni nemlomeni isebenza  ukuthatha lokha umuntu akuzwako ezithweni lezi bese ikuse engcondweni bona ingcondo ikghone ukuhlathulula bona Khuyini, nofana kunjani.&lt;ref&gt;Head - Overview, Function and Examples | Biology Dictionary&lt;/ref&gt;Ihloko isebenza ukwenza umuntu akghone ukhuluma nabanye abanye abantu akhulume ngamagama nangokubukeka kwabuso bakhe ngombana nobuso buyakhuluma ngaphandle kwamagama. Ubuso bukghona ukuveza bona umuntu uzizwa ngesikhathi leso umbona.Ihloko kufuze inakekelwe ngombana lokha umuntu nangakangalimala kumbi ihloko angagcina sele abanjwa magulo angalaphekiko afana nesifo sokuwa nofana aphathwa yihloko ebuhlungu engalaphekiko.&lt;ref&gt;Schacter, D.L. and Crovitz, H.F., 1977. Memory function after closed head injury: A review of the quantitative research. ''Cortex'', ''13''(2), pp.150-176.&lt;/ref&gt;Ihloko kusisitho smzimba esiqakathekileko esenza bona umuntu akgho ukukhuluma nokuthintana nabantu.

== Iinkomba ==
[[Category:Ihloko]]
[[Category:amehlo]]
[[Category:iindlebe]]</text>
      <sha1>a7uz7e8myacnnt0oz230io3t75pd5yh</sha1>
    </revision>
    <revision>
      <id>5708</id>
      <parentid>5185</parentid>
      <timestamp>2025-09-07T11:45:32Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5708</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2504" sha1="9tgckd5lhz95qb2rehz6kpasqri97nh" xml:space="preserve">[[Isimumathi:Close-up photograph of a calf's head looking at the viewer in Don Det Laos.jpg|thumb|Ihloko yekonyana]]
'''Ihloko''' sisitho somzimba esin[[amehlo]], [[iindlebe]], [[ipumulo]],[[umlomo]], ubucopho Kanye nokhunye. Ihloko idlala indima ekulu ekutheni umuntu akghone ukucabanga, afunde, akhulume nabanye abantu begodu akghone ukuphila kubhoduluko yakhe&lt;ref&gt;Head - Overview, Function and Examples | Biology Dictionary&lt;/ref&gt;. 

=== Ukwakheka kwehloko ===
Ihloko yakheke ngethambo elibizwa bona yikhakhayi. Ithambo leli lihlukaniseke kabili nge-Cranium. I-cranium le ngiyo evalela ubucopho nobuso.&lt;ref&gt;What Does the Cranium (Skull) Do? Anatomy, Function, Conditions&lt;/ref&gt; Ihloko iphethe nezinye izakhiwo.Amehlo ngiwo enza bona umuntu kghone ukubona abantu, ibhoduluko nokhunye okusephasini. Amehlo athatha isithombe salokhu umuntu akubona bese akuse engcondweni ukuthi ingcondo ikghone ukuhlathulula ukuthi yini le umuntu ayibonako.Ilekelela umuntu akghone ukuzwa [[umdumo]] begodu udlulise imininingwana uyise engcondweni. Indlebe iyarhelebha umuntu bona akghone ukudzimelela.Ipumulo sisitho esenza bona umuntu akghone ukudosa begodu akiphe nommoya wokuphefumula. Umuntu ngepumulo ukghona ukurhogela iphunga elihle nelimnandi.Umlomo-Kuyisitho somzimba esenza bona umuntu akghone Ukudla nokusela amanzi ukuze asuthe begodu angomi. 

=== Umsebenzi wehloko ===
Ihloko ngengcondo isebenza ukulawula ukunyakaza komuntu, begodu yehlisa  nofana ilawula imisebenzi eyenziwamzimba. Emehlweni, endlebeni, epumulweni nemlomeni isebenza  ukuthatha lokha umuntu akuzwako ezithweni lezi bese ikuse engcondweni bona ingcondo ikghone ukuhlathulula bona Khuyini, nofana kunjani.&lt;ref&gt;Head - Overview, Function and Examples | Biology Dictionary&lt;/ref&gt;Ihloko isebenza ukwenza umuntu akghone ukhuluma nabanye abanye abantu akhulume ngamagama nangokubukeka kwabuso bakhe ngombana nobuso buyakhuluma ngaphandle kwamagama. Ubuso bukghona ukuveza bona umuntu uzizwa ngesikhathi leso umbona.Ihloko kufuze inakekelwe ngombana lokha umuntu nangakangalimala kumbi ihloko angagcina sele abanjwa magulo angalaphekiko afana nesifo sokuwa nofana aphathwa yihloko ebuhlungu engalaphekiko.&lt;ref&gt;Schacter, D.L. and Crovitz, H.F., 1977. Memory function after closed head injury: A review of the quantitative research. ''Cortex'', ''13''(2), pp.150-176.&lt;/ref&gt;Ihloko kusisitho smzimba esiqakathekileko esenza bona umuntu akgho ukukhuluma nokuthintana nabantu.

== Iinkomba ==
[[Category:Ihloko]]
[[Category:amehlo]]
[[Category:iindlebe]]</text>
      <sha1>9tgckd5lhz95qb2rehz6kpasqri97nh</sha1>
    </revision>
  </page>
  <page>
    <title>Ihliziyo</title>
    <ns>0</ns>
    <id>517</id>
    <revision>
      <id>2562</id>
      <timestamp>2025-03-21T14:32:50Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot; '''Ihliziy'''o sisitho somzimba esisebenza ukupompa igazi elisemzimbeni. Ihliziyo iqakathekeko erherhweni legazi ngombana ngaphandle kwayo igazi angekhe lakghona ukukhamba emzimbeni. Ihliziyo ngiyo eyenza bona umzimba ube nepilo begodu usebenze. Umzimba angekhe wasebenza lokha ihliziyo nayingekho&lt;ref&gt;Katz, A.M., 2010. ''Physiology of the Heart''. Lippincott Williams &amp; Wilkins.&lt;/ref&gt;.  == Ukwakheka kwehliziyo == Ihliziyo inamakamero amane ngaphakathi ekuyi-atria yangesin...&quot;</comment>
      <origin>2562</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2247" sha1="g7vgwmb398xje6sast4ispz982is73x" xml:space="preserve">
'''Ihliziy'''o sisitho somzimba esisebenza ukupompa igazi elisemzimbeni. Ihliziyo iqakathekeko erherhweni legazi ngombana ngaphandle kwayo igazi angekhe lakghona ukukhamba emzimbeni. Ihliziyo ngiyo eyenza bona umzimba ube nepilo begodu usebenze. Umzimba angekhe wasebenza lokha ihliziyo nayingekho&lt;ref&gt;Katz, A.M., 2010. ''Physiology of the Heart''. Lippincott Williams &amp; Wilkins.&lt;/ref&gt;.

== Ukwakheka kwehliziyo ==
Ihliziyo inamakamero amane ngaphakathi ekuyi-atria yangesinceleni nayange sidleni. Bese kube nama ventricle, yesinceleni neyangesidleni. Wowkke amakamero la asebenza ukwamukelwa iingazi ezivela emzibeni ngmama veyini. Ama ventricle  makamero angaphasi ehliziyweni asebenza ukupompa igazi liphume ezimbeni ngama ngemisipha yama-artery&lt;ref&gt;Human Heart- Location, Anatomy, Structure, Functions&lt;/ref&gt;.

== Umsebenzi wehliziyo ==
Uhliziyo isebenza ukupompa igazi ilizalise nge-oksijini nezakha mzimba bese igazi lko liya ezithweni zomzimba nenyameni. Iqinisekisa bona igazi ligeleza umzimba woke ngaphandle kokujama nofana ngaphandle koku thikamezeka&lt;ref&gt;Fung, Y.C., 2013. ''Biomechanics: circulation''. Springer Science &amp; Business Media.&lt;/ref&gt;.

== Ukukhamba kwegazi ehliziyweni ==
Igazi eliphelelwe yi-oksijini lisuka emzimbeni ngamaveyini bese libuyela ehliziyweni. Igazi leli lingena ehliziyweni lingena ngomsipha we superior ne inferior vena cava ungene ngaku-atria yangesidleni. [[Igazi]] likhamba liyokufika ku ventricle yangesidleni nge-tricuspid valve. Igazi iliyampopeka lisule ku ventricle yangesidleni bese liye emaphaphini lidluliswa yi-pulmonary artery. Igazi nafika emaphaphini lithola nofana lizala nge-oksijini bese libuyela ehliziyweni lingene nge-atria yangesinceleni.Igazi leli bese liyaphuma godu liyokungena ngaku ventricle yangesincelelni lisebenzisa I mitral valve&lt;ref&gt;How Blood Flows Through the Heart &amp; Body&lt;/ref&gt;. I-ventricle yangesinceleni ipompa igazi ilise ku aorta ekungiyo ebuyisela igazi emuva liye ezithweni zomzimba nenyameni&lt;ref&gt;Saladin, K.S. and Miller, L., 2023. ''Anatomy &amp; physiology'' (p. 1248). McGraw-Hill US Higher Ed ISE.&lt;/ref&gt;.

== Isiphetho ==
Ihliziyo isisitho somzimba umuntu anghe akghonaukuphila ngaphandle kwaso. Sisebenza khulu ekukhambiseni iingazi umzimba woke ngaphandle kokujama.</text>
      <sha1>g7vgwmb398xje6sast4ispz982is73x</sha1>
    </revision>
    <revision>
      <id>2806</id>
      <parentid>2562</parentid>
      <timestamp>2025-05-06T12:47:45Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2806</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2258" sha1="eaygasul3uoboz99ltbv1y96aa4vqbv" xml:space="preserve">
'''Ihliziy'''o sisitho somzimba esisebenza ukupompa igazi elisemzimbeni. Ihliziyo iqakathekeko erherhweni legazi ngombana ngaphandle kwayo igazi angekhe lakghona ukukhamba emzimbeni. Ihliziyo ngiyo eyenza bona umzimba ube nepilo begodu usebenze. Umzimba angekhe wasebenza lokha ihliziyo nayingekho&lt;ref&gt;Katz, A.M., 2010. ''Physiology of the Heart''. Lippincott Williams &amp; Wilkins.&lt;/ref&gt;.

== Ukwakheka kwehliziyo ==
Ihliziyo inamakamero amane ngaphakathi ekuyi-atria yangesinceleni nayange sidleni. Bese kube nama ventricle, yesinceleni neyangesidleni. Wowkke amakamero la asebenza ukwamukelwa iingazi ezivela emzibeni ngmama veyini. Ama ventricle  makamero angaphasi ehliziyweni asebenza ukupompa igazi liphume ezimbeni ngama ngemisipha yama-artery&lt;ref&gt;Human Heart- Location, Anatomy, Structure, Functions&lt;/ref&gt;.

== Umsebenzi wehliziyo ==
Uhliziyo isebenza ukupompa igazi ilizalise nge-oksijini nezakha mzimba bese igazi lko liya ezithweni zomzimba nenyameni. Iqinisekisa bona igazi ligeleza umzimba woke ngaphandle kokujama nofana ngaphandle koku thikamezeka&lt;ref&gt;Fung, Y.C., 2013. ''Biomechanics: circulation''. Springer Science &amp; Business Media.&lt;/ref&gt;.

== Ukukhamba kwegazi ehliziyweni ==
Igazi eliphelelwe yi-oksijini lisuka emzimbeni ngamaveyini bese libuyela ehliziyweni. Igazi leli lingena ehliziyweni lingena ngomsipha we superior ne inferior vena cava ungene ngaku-atria yangesidleni. [[Igazi]] likhamba liyokufika ku ventricle yangesidleni nge-tricuspid valve. Igazi liyampopeka lisuke ku ventricle yangesidleni bese liye emaphaphini lidluliswa yi-pulmonary artery. Igazi nalifika emaphaphini lithola nofana lizala nge-oksijini bese libuyela ehliziyweni lingene nge-atria yangesinceleni.Igazi leli bese liyadlula liyaphuma godu liyokungena ngaku ventricle yangesinceleni lisebenzisa I mitral valve&lt;ref&gt;How Blood Flows Through the Heart &amp; Body&lt;/ref&gt;. I-ventricle yangesinceleni ipompa igazi ilise ku aorta ekungiyo ebuyisela igazi emuva liye ezithweni zomzimba nenyameni &lt;ref&gt;Saladin, K.S. and Miller, L., 2023. ''Anatomy &amp; physiology'' (p. 1248). McGraw-Hill US Higher Ed ISE.&lt;/ref&gt;.

== Isiphetho ==
Ihliziyo isisitho somzimba umuntu anghe akghonaukuphila ngaphandle kwaso. Sisebenza khulu ekukhambiseni iingazi umzimba woke ngaphandle kokujama.</text>
      <sha1>eaygasul3uoboz99ltbv1y96aa4vqbv</sha1>
    </revision>
    <revision>
      <id>2807</id>
      <parentid>2806</parentid>
      <timestamp>2025-05-06T12:48:12Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2807</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2261" sha1="0sfj86l9npvdatq7uvcoxicqeqrd7p3" xml:space="preserve">
'''Ihliziy'''o sisitho somzimba esisebenza ukupompa igazi elisemzimbeni. Ihliziyo iqakathekeko erherhweni legazi ngombana ngaphandle kwayo igazi angekhe lakghona ukukhamba emzimbeni. Ihliziyo ngiyo eyenza bona umzimba ube nepilo begodu usebenze. Umzimba angekhe wasebenza lokha ihliziyo nayingekho&lt;ref&gt;Katz, A.M., 2010. ''Physiology of the Heart''. Lippincott Williams &amp; Wilkins.&lt;/ref&gt;.

== Ukwakheka kwehliziyo ==
Ihliziyo inamakamero amane ngaphakathi ekuyi-atria yangesinceleni nayange sidleni. Bese kube nama ventricle, yesinceleni neyangesidleni. Wowkke amakamero la asebenza ukwamukelwa iingazi ezivela emzibeni ngmama veyini. Ama ventricle  makamero angaphasi ehliziyweni asebenza ukupompa igazi liphume ezimbeni ngama ngemisipha yama-artery&lt;ref&gt;Human Heart- Location, Anatomy, Structure, Functions&lt;/ref&gt;.

== Umsebenzi wehliziyo ==
Uhliziyo isebenza ukupompa igazi ilizalise nge-oksijini nezakha mzimba bese igazi lko liya ezithweni zomzimba nenyameni. Iqinisekisa bona igazi ligeleza umzimba woke ngaphandle kokujama nofana ngaphandle koku thikamezeka&lt;ref&gt;Fung, Y.C., 2013. ''Biomechanics: circulation''. Springer Science &amp; Business Media.&lt;/ref&gt;.

== Ukukhamba kwegazi ehliziyweni ==
Igazi eliphelelwe yi-oksijini lisuka emzimbeni ngamaveyini bese libuyela ehliziyweni. Igazi leli lingena ehliziyweni lingena ngomsipha we superior ne inferior vena cava ungene ngaku-atria yangesidleni. [[Igazi]] likhamba liyokufika ku ventricle yangesidleni nge-tricuspid valve. Igazi liyampopeka lisuke ku ventricle yangesidleni bese liye emaphaphini lidluliswa yi-pulmonary artery. Igazi nalifika emaphaphini lithola nofana lizala nge-oksijini bese libuyela ehliziyweni lingene nge-atria yangesinceleni.Igazi leli bese liyadlula liyaphuma godu liyokungena ngaku ventricle yangesinceleni lisebenzisa I mitral valve&lt;ref&gt;How Blood Flows Through the Heart &amp; Body&lt;/ref&gt;. I-ventricle yangesinceleni ipompa igazi ilise ku aorta ekungiyo ebuyisela igazi emuva liye ezithweni zomzimba nenyameni &lt;ref&gt;Saladin, K.S. and Miller, L., 2023. ''Anatomy &amp; physiology'' (p. 1248). McGraw-Hill US Higher Ed ISE.&lt;/ref&gt;.

== Isiphetho ==
Ihliziyo isisitho somzimba umuntu angekhe akghona ukuphila ngaphandle kwaso. Sisebenza khulu ekukhambiseni iingazi umzimba woke ngaphandle kokujama.</text>
      <sha1>0sfj86l9npvdatq7uvcoxicqeqrd7p3</sha1>
    </revision>
    <revision>
      <id>5706</id>
      <parentid>2807</parentid>
      <timestamp>2025-09-07T11:41:11Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5706</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2335" sha1="0bz4lr0e5vqx02mk0kspxjhe821jem5" xml:space="preserve">[[Isimumathi:Myocardial infarction.jpg|thumb|Ihliziyo]]
'''Ihliziy'''o sisitho somzimba esisebenza ukupompa igazi elisemzimbeni. Ihliziyo iqakathekeko erherhweni legazi ngombana ngaphandle kwayo igazi angekhe lakghona ukukhamba emzimbeni. Ihliziyo ngiyo eyenza bona umzimba ube nepilo begodu usebenze. Umzimba angekhe wasebenza lokha ihliziyo nayingekho&lt;ref&gt;Katz, A.M., 2010. ''Physiology of the Heart''. Lippincott Williams &amp; Wilkins.&lt;/ref&gt;.

=== Ukwakheka kwehliziyo ===
Ihliziyo inamakamero amane ngaphakathi ekuyi-atria yangesinceleni nayange sidleni. Bese kube nama ventricle, yesinceleni neyangesidleni. Wowkke amakamero la asebenza ukwamukelwa iingazi ezivela emzibeni ngmama veyini. Ama ventricle  makamero angaphasi ehliziyweni asebenza ukupompa igazi liphume ezimbeni ngama ngemisipha yama-artery&lt;ref&gt;Human Heart- Location, Anatomy, Structure, Functions&lt;/ref&gt;.

=== Umsebenzi wehliziyo ===
Uhliziyo isebenza ukupompa igazi ilizalise nge-oksijini nezakha mzimba bese igazi lko liya ezithweni zomzimba nenyameni. Iqinisekisa bona igazi ligeleza umzimba woke ngaphandle kokujama nofana ngaphandle koku thikamezeka&lt;ref&gt;Fung, Y.C., 2013. ''Biomechanics: circulation''. Springer Science &amp; Business Media.&lt;/ref&gt;.

=== Ukukhamba kwegazi ehliziyweni ===
Igazi eliphelelwe yi-oksijini lisuka emzimbeni ngamaveyini bese libuyela ehliziyweni. Igazi leli lingena ehliziyweni lingena ngomsipha we superior ne inferior vena cava ungene ngaku-atria yangesidleni. [[Igazi]] likhamba liyokufika ku ventricle yangesidleni nge-tricuspid valve. Igazi liyampopeka lisuke ku ventricle yangesidleni bese liye emaphaphini lidluliswa yi-pulmonary artery. Igazi nalifika emaphaphini lithola nofana lizala nge-oksijini bese libuyela ehliziyweni lingene nge-atria yangesinceleni.Igazi leli bese liyadlula liyaphuma godu liyokungena ngaku ventricle yangesinceleni lisebenzisa I mitral valve&lt;ref&gt;How Blood Flows Through the Heart &amp; Body&lt;/ref&gt;. I-ventricle yangesinceleni ipompa igazi ilise ku aorta ekungiyo ebuyisela igazi emuva liye ezithweni zomzimba nenyameni &lt;ref&gt;Saladin, K.S. and Miller, L., 2023. ''Anatomy &amp; physiology'' (p. 1248). McGraw-Hill US Higher Ed ISE.&lt;/ref&gt;.Ihliziyo isisitho somzimba umuntu angekhe akghona ukuphila ngaphandle kwaso. Sisebenza khulu ekukhambiseni iingazi umzimba woke ngaphandle kokujama.

== Iinkomba ==
&lt;references /&gt;</text>
      <sha1>0bz4lr0e5vqx02mk0kspxjhe821jem5</sha1>
    </revision>
    <revision>
      <id>5707</id>
      <parentid>5706</parentid>
      <timestamp>2025-09-07T11:42:24Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>5707</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2377" sha1="r2v8fqmn69zop8fgybvg6v1tor2exfu" xml:space="preserve">[[Isimumathi:Myocardial infarction.jpg|thumb|Ihliziyo]]
'''Ihliziy'''o sisitho somzimba esisebenza ukupompa igazi elisemzimbeni. Ihliziyo iqakathekeko erherhweni legazi ngombana ngaphandle kwayo igazi angekhe lakghona ukukhamba emzimbeni. Ihliziyo ngiyo eyenza bona umzimba ube nepilo begodu usebenze. Umzimba angekhe wasebenza lokha ihliziyo nayingekho&lt;ref&gt;Katz, A.M., 2010. ''Physiology of the Heart''. Lippincott Williams &amp; Wilkins.&lt;/ref&gt;.

=== Ukwakheka kwehliziyo ===
Ihliziyo inamakamero amane ngaphakathi ekuyi-atria yangesinceleni nayange sidleni. Bese kube nama ventricle, yesinceleni neyangesidleni. Wowkke amakamero la asebenza ukwamukelwa iingazi ezivela emzibeni ngmama veyini. Ama ventricle  makamero angaphasi ehliziyweni asebenza ukupompa igazi liphume ezimbeni ngama ngemisipha yama-artery&lt;ref&gt;Human Heart- Location, Anatomy, Structure, Functions&lt;/ref&gt;.

=== Umsebenzi wehliziyo ===
Uhliziyo isebenza ukupompa igazi ilizalise nge-oksijini nezakha mzimba bese igazi lko liya ezithweni zomzimba nenyameni. Iqinisekisa bona igazi ligeleza umzimba woke ngaphandle kokujama nofana ngaphandle koku thikamezeka&lt;ref&gt;Fung, Y.C., 2013. ''Biomechanics: circulation''. Springer Science &amp; Business Media.&lt;/ref&gt;.

=== Ukukhamba kwegazi ehliziyweni ===
Igazi eliphelelwe yi-oksijini lisuka emzimbeni ngamaveyini bese libuyela ehliziyweni. Igazi leli lingena ehliziyweni lingena ngomsipha we superior ne inferior vena cava ungene ngaku-atria yangesidleni. [[Igazi]] likhamba liyokufika ku ventricle yangesidleni nge-tricuspid valve. Igazi liyampopeka lisuke ku ventricle yangesidleni bese liye emaphaphini lidluliswa yi-pulmonary artery. Igazi nalifika emaphaphini lithola nofana lizala nge-oksijini bese libuyela ehliziyweni lingene nge-atria yangesinceleni.Igazi leli bese liyadlula liyaphuma godu liyokungena ngaku ventricle yangesinceleni lisebenzisa I mitral valve&lt;ref&gt;How Blood Flows Through the Heart &amp; Body&lt;/ref&gt;. I-ventricle yangesinceleni ipompa igazi ilise ku aorta ekungiyo ebuyisela igazi emuva liye ezithweni zomzimba nenyameni &lt;ref&gt;Saladin, K.S. and Miller, L., 2023. ''Anatomy &amp; physiology'' (p. 1248). McGraw-Hill US Higher Ed ISE.&lt;/ref&gt;.Ihliziyo isisitho somzimba umuntu angekhe akghona ukuphila ngaphandle kwaso. Sisebenza khulu ekukhambiseni iingazi umzimba woke ngaphandle kokujama.

== Iinkomba ==
&lt;references /&gt;
[[Category: Ihliziyo]]
[[Category:Igazi]]</text>
      <sha1>r2v8fqmn69zop8fgybvg6v1tor2exfu</sha1>
    </revision>
  </page>
  <page>
    <title>Iinyawo</title>
    <ns>0</ns>
    <id>518</id>
    <revision>
      <id>2563</id>
      <timestamp>2025-03-21T18:51:12Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''Iinyawo''' zomzimba zimbili ngilezi umuntu azisebenzisa ukukhamba&lt;ref&gt;Human leg - Wikipedia&lt;/ref&gt;. Inyawo linamathambo, imisipha kanye nenyama.  == Ukwakheka kweenyawo == Inyawo zinamathambo amanengi.Ithambo lesirubhini nofana ethangeni ngilo elide khulu enyamweni libizwa bona yi fumur. Bese kube nethambo ledolo elihlanganisa umlenze negoji. Mlenzeni kunethambo itibia ne fibula. Amathambo lawa athome edolweni ayokuphelela amkantjeni&lt;ref&gt;Herman, I.P., 2016. ''Physics o...&quot;</comment>
      <origin>2563</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1224" sha1="097ks9ujkjimtt3up38eesmso4bku8c" xml:space="preserve">'''Iinyawo''' zomzimba zimbili ngilezi umuntu azisebenzisa ukukhamba&lt;ref&gt;Human leg - Wikipedia&lt;/ref&gt;. Inyawo linamathambo, imisipha kanye nenyama.

== Ukwakheka kweenyawo ==
Inyawo zinamathambo amanengi.Ithambo lesirubhini nofana ethangeni ngilo elide khulu enyamweni libizwa bona yi fumur. Bese kube nethambo ledolo elihlanganisa umlenze negoji. Mlenzeni kunethambo itibia ne fibula. Amathambo lawa athome edolweni ayokuphelela amkantjeni&lt;ref&gt;Herman, I.P., 2016. ''Physics of the human body''. Springer.&lt;/ref&gt;.

== Umsebenzi weenyawo ==
inyawo zisebenza ukulekelela umuntu bona akghone ukukhamba, nokudzimelela.
Zikghona ukuthwala ubudisi bomzimba nokumsiza umuntu bomna akhgone ukujama ngendlela afuna ngayo. Zikghona ukugijima nokuthi umuntu azisebenzise ukudlala umdlalo uyahlukahlukeneko&lt;ref&gt;https://anatomy.co.uk/leg/&lt;/ref&gt;.

== Imisipha esenyaweni ==
AmaQuadriceps

Lemisipha emine etholakala emathangeni eyenza bona idolo linqophe.

AmaHamstrings

Siqheema semisipha emithathu esesirubhini esenza bona idolo likghone ukugoba nofana ukugobeka.

Imisipha emaCalf

Siqheema semisipha emibili esembaleni eyenza bona inyawo linyakaze lula.

Imisipha i-Gluteal

Siqheema semisipha emithathu esesidunwini eyandisa isirubhi.</text>
      <sha1>097ks9ujkjimtt3up38eesmso4bku8c</sha1>
    </revision>
    <revision>
      <id>2566</id>
      <parentid>2563</parentid>
      <timestamp>2025-03-21T19:09:12Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2566</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1239" sha1="i5m1m16d8e0ioygmmqipaxsbtixq9ra" xml:space="preserve">'''Iinyawo''' zomzimba zimbili ngilezi umuntu azisebenzisa ukukhamba&lt;ref&gt;Human leg - Wikipedia&lt;/ref&gt;. Inyawo lin[[amathambo]], imisipha kanye nenyama.

== Ukwakheka kweenyawo ==
Inyawo zinamathambo amanengi.Ithambo lesirubhini nofana ethangeni ngilo elide khulu enyamweni libizwa bona yi fumur. Bese kube nethambo ledolo elihlanganisa umlenze negoji. Mlenzeni kunethambo itibia ne fibula. Amathambo lawa athome edolweni ayokuphelela amkantjeni&lt;ref&gt;Herman, I.P., 2016. ''Physics of the human body''. Springer.&lt;/ref&gt;.

== Umsebenzi weenyawo ==
inyawo zisebenza ukulekelela umuntu bona akghone ukukhamba, nokudzimelela.Zikghona ukuthwala [[ubudisi]] bomzimba nokumsiza umuntu bomna akhgone ukujama ngendlela afuna ngayo. Zikghona [[ukugijima]] nokuthi umuntu azisebenzise ukudlala [[umdlalo]] uyahlukahlukeneko&lt;ref&gt;https://anatomy.co.uk/leg/&lt;/ref&gt;.

== Imisipha esenyaweni ==
AmaQuadriceps

Lemisipha emine etholakala emathangeni eyenza bona idolo linqophe.

AmaHamstrings

Siqheema semisipha emithathu esesirubhini esenza bona idolo likghone ukugoba nofana ukugobeka.

Imisipha emaCalf

Siqheema semisipha emibili esembaleni eyenza bona inyawo linyakaze lula.

Imisipha i-Gluteal

Siqheema semisipha emithathu esesidunwini eyandisa isirubhi.</text>
      <sha1>i5m1m16d8e0ioygmmqipaxsbtixq9ra</sha1>
    </revision>
    <revision>
      <id>2583</id>
      <parentid>2566</parentid>
      <timestamp>2025-03-24T09:58:16Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2583</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1406" sha1="g6gyniy2nf61reu8pogidlih2bysclq" xml:space="preserve">'''Iinyawo''' zomzimba zimbili ngilezi umuntu azisebenzisa ukukhamba&lt;ref&gt;Human leg - Wikipedia&lt;/ref&gt;. Inyawo lin[[amathambo]], imisipha kanye nenyama.

== Ukwakheka kweenyawo ==
Inyawo zinamathambo amanengi.Ithambo lesirubhini nofana ethangeni ngilo elide khulu enyamweni libizwa bona yi fumur. Bese kube nethambo ledolo elihlanganisa umlenze nethango. Mlenzeni kunethambo itibia ne fibula. Amathambo lawa athome edolweni ayokuphelela amkantjeni&lt;ref&gt;Herman, I.P., 2016. ''Physics of the human body''. Springer.&lt;/ref&gt;.

== Umsebenzi weenyawo ==
inyawo zisebenza ukulekelela umuntu bona akghone ukukhamba, nokudzimelela.Zikghona ukuthwala [[ubudisi]] bomzimba nokumsiza umuntu bona akhgone ukujama ngendlela afuna ngayo. Zikghona [[ukugijima]] nokuthi umuntu azisebenzise ukudlala [[umdlalo]] uyahlukahlukeneko&lt;ref&gt;https://anatomy.co.uk/leg/&lt;/ref&gt;. Ukungabi neenyawo akutjho bona umuntu angeze akghona ukuphila nofana ukwenza ezinye izinto. Banengi abantu abaphilako abanganazo iinyawo bakhamba ngesitulo samavilo.

== Imisipha esenyaweni ==
AmaQuadriceps

Lemisipha emine etholakala emathangeni eyenza bona idolo linqophe.

AmaHamstrings

Siqheema semisipha emithathu esesirubhini esenza bona idolo likghone ukugoba nofana ukugobeka.

Imisipha emaCalf

Siqheema semisipha emibili esembaleni eyenza bona inyawo linyakaze lula.

Imisipha i-Gluteal

Siqheema semisipha emithathu esesidunwini eyandisa isirubhi.</text>
      <sha1>g6gyniy2nf61reu8pogidlih2bysclq</sha1>
    </revision>
    <revision>
      <id>3017</id>
      <parentid>2583</parentid>
      <timestamp>2025-06-06T20:28:31Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>ban me now</comment>
      <origin>3017</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1487" sha1="p5ctk9t7asw4e9h49a2lp7sbgjucw8j" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. Iinyawo''' zomzimba zimbili ngilezi umuntu azisebenzisa ukukhamba&lt;ref&gt;Human leg - Wikipedia&lt;/ref&gt;. Inyawo lin[[amathambo]], imisipha kanye nenyama.

== Ukwakheka kweenyawo ==
Inyawo zinamathambo amanengi.Ithambo lesirubhini nofana ethangeni ngilo elide khulu enyamweni libizwa bona yi fumur. Bese kube nethambo ledolo elihlanganisa umlenze nethango. Mlenzeni kunethambo itibia ne fibula. Amathambo lawa athome edolweni ayokuphelela amkantjeni&lt;ref&gt;Herman, I.P., 2016. ''Physics of the human body''. Springer.&lt;/ref&gt;.

== Umsebenzi weenyawo ==
inyawo zisebenza ukulekelela umuntu bona akghone ukukhamba, nokudzimelela.Zikghona ukuthwala [[ubudisi]] bomzimba nokumsiza umuntu bona akhgone ukujama ngendlela afuna ngayo. Zikghona [[ukugijima]] nokuthi umuntu azisebenzise ukudlala [[umdlalo]] uyahlukahlukeneko&lt;ref&gt;https://anatomy.co.uk/leg/&lt;/ref&gt;. Ukungabi neenyawo akutjho bona umuntu angeze akghona ukuphila nofana ukwenza ezinye izinto. Banengi abantu abaphilako abanganazo iinyawo bakhamba ngesitulo samavilo.

== Imisipha esenyaweni ==
AmaQuadriceps

Lemisipha emine etholakala emathangeni eyenza bona idolo linqophe.

AmaHamstrings

Siqheema semisipha emithathu esesirubhini esenza bona idolo likghone ukugoba nofana ukugobeka.

Imisipha emaCalf

Siqheema semisipha emibili esembaleni eyenza bona inyawo linyakaze lula.

Imisipha i-Gluteal

Siqheema semisipha emithathu esesidunwini eyandisa isirubhi.</text>
      <sha1>p5ctk9t7asw4e9h49a2lp7sbgjucw8j</sha1>
    </revision>
    <revision>
      <id>3045</id>
      <parentid>3017</parentid>
      <timestamp>2025-06-07T03:05:22Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Nqobile69|Nqobile69]]</comment>
      <origin>2583</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1406" sha1="g6gyniy2nf61reu8pogidlih2bysclq" xml:space="preserve">'''Iinyawo''' zomzimba zimbili ngilezi umuntu azisebenzisa ukukhamba&lt;ref&gt;Human leg - Wikipedia&lt;/ref&gt;. Inyawo lin[[amathambo]], imisipha kanye nenyama.

== Ukwakheka kweenyawo ==
Inyawo zinamathambo amanengi.Ithambo lesirubhini nofana ethangeni ngilo elide khulu enyamweni libizwa bona yi fumur. Bese kube nethambo ledolo elihlanganisa umlenze nethango. Mlenzeni kunethambo itibia ne fibula. Amathambo lawa athome edolweni ayokuphelela amkantjeni&lt;ref&gt;Herman, I.P., 2016. ''Physics of the human body''. Springer.&lt;/ref&gt;.

== Umsebenzi weenyawo ==
inyawo zisebenza ukulekelela umuntu bona akghone ukukhamba, nokudzimelela.Zikghona ukuthwala [[ubudisi]] bomzimba nokumsiza umuntu bona akhgone ukujama ngendlela afuna ngayo. Zikghona [[ukugijima]] nokuthi umuntu azisebenzise ukudlala [[umdlalo]] uyahlukahlukeneko&lt;ref&gt;https://anatomy.co.uk/leg/&lt;/ref&gt;. Ukungabi neenyawo akutjho bona umuntu angeze akghona ukuphila nofana ukwenza ezinye izinto. Banengi abantu abaphilako abanganazo iinyawo bakhamba ngesitulo samavilo.

== Imisipha esenyaweni ==
AmaQuadriceps

Lemisipha emine etholakala emathangeni eyenza bona idolo linqophe.

AmaHamstrings

Siqheema semisipha emithathu esesirubhini esenza bona idolo likghone ukugoba nofana ukugobeka.

Imisipha emaCalf

Siqheema semisipha emibili esembaleni eyenza bona inyawo linyakaze lula.

Imisipha i-Gluteal

Siqheema semisipha emithathu esesidunwini eyandisa isirubhi.</text>
      <sha1>g6gyniy2nf61reu8pogidlih2bysclq</sha1>
    </revision>
  </page>
  <page>
    <title>Ipumulo</title>
    <ns>0</ns>
    <id>519</id>
    <revision>
      <id>2564</id>
      <timestamp>2025-03-21T19:02:50Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''Ipumulo''' isehloko ngpahezulu komlomo. Inembobo ezimbili zokudosa [[ummoya]]. Ipumulo ngeyokuphefumula nokunukelela&lt;ref&gt;https://dictionary.cambridge.org/dictionary/english/nose&lt;/ref&gt;.Upumulo isebenza ukukghohela iphunga elingaba khona ngaphakathi kwebhoduluko. Ikghona ukusefa ummoya esiwuphefumulako ngaphambi kokuthi ungene ngaphakathi emzimbeni. Yenza ummoya bona bona ufuthumale ngaphambi kokuthi ufike emaphaphini&lt;ref&gt;What Are the 6 Functions of the Nose? Conditions...&quot;</comment>
      <origin>2564</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1795" sha1="qij6myu4p2isqjdpvt4xsnvk7k37oxq" xml:space="preserve">'''Ipumulo''' isehloko ngpahezulu komlomo. Inembobo ezimbili zokudosa [[ummoya]]. Ipumulo ngeyokuphefumula nokunukelela&lt;ref&gt;https://dictionary.cambridge.org/dictionary/english/nose&lt;/ref&gt;.Upumulo isebenza ukukghohela iphunga elingaba khona ngaphakathi kwebhoduluko. Ikghona ukusefa ummoya esiwuphefumulako ngaphambi kokuthi ungene ngaphakathi emzimbeni. Yenza ummoya bona bona ufuthumale ngaphambi kokuthi ufike emaphaphini&lt;ref&gt;What Are the 6 Functions of the Nose? Conditions &amp; Symptoms&lt;/ref&gt;

== Ukwakheka kwepumulo ==
Ipumulo inembobo ezimbili ekuthomeni kwayo, ngizo ezidosa ummoya ziwungenise nofana ziwukhiphe. Bese kubemsipha ohlukanisa imbobo ezimbili zepumulo. Umsipha lo ubizwa bona yi cartilage une thambo. Besekube namathambo we turbinate, made ngokudaleka begodu awondile. Amathambo lawa ngiwo asebenza ukwenza bona ummoya ongena ngepumulweni ufuthumale. Okhunye kune olfactory epithelium ekuyimembreni yamafinyila ehlala ngaphakathi komgodi wepumulo. Into le inamaseli akhethekileko asebenza ukuzwelela iphunga nofana umnuko ongabakhona&lt;ref&gt;Patel, R.G., 2017. Nasal anatomy and function. ''Facial plastic surgery'', ''33''(01), pp.003-008.&lt;/ref&gt;.

== Umsebenzi wepumulo ==
Amafinyila

Ipumulo isebenza ukwenza amafinyila ekumamanzi adage aregako. Amafinyila akghona uku udosa [[ithuli,]] amagcikwane nokhunye okungazama ukungena ngepumulweni.

Ukukghogela

Ikghona ukwenza bona umuntnu okghone [[ukukghogela]] iphunga elingaba khona eduze kwakhe. Isibonelo umuntu angakghona ukuzwa iphunga lentuthu bese abona nofana alemuke bona kunento etjhako eduze nalapha akhona.

Ukuphefumula

Ikhona ukuphefumula yenza ummoya bona ufuthumale ngaphambi kokuthi uye emaphatjhini. Ikghona nokuthi ivimbe amagcikwane bona angakghoni ukungena ngemaphatjhini. Ipumulo iyakghona ukulwisana namagulo.</text>
      <sha1>qij6myu4p2isqjdpvt4xsnvk7k37oxq</sha1>
    </revision>
    <revision>
      <id>2789</id>
      <parentid>2564</parentid>
      <timestamp>2025-04-29T10:58:50Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2789</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1820" sha1="cf60x8vffbndz816e69fwur0oc4fn2w" xml:space="preserve">'''Ipumulo''' isehloko ngaphezulu komlomo begodu ngaphasi kwamehlo. Inembobo ezimbili zokudosa [[ummoya]]. Ipumulo ngeyokuphefumula nokunukelela&lt;ref&gt;https://dictionary.cambridge.org/dictionary/english/nose&lt;/ref&gt;.Upumulo isebenza ukukghogela iphunga elingaba khona ngaphakathi kwebhoduluko. Ikghona ukusefa ummoya esiwuphefumulako ngaphambi kokuthi ungene ngaphakathi emzimbeni. Yenza ummoya bona bona ufuthumale ngaphambi kokuthi ufike emaphaphini&lt;ref&gt;What Are the 6 Functions of the Nose? Conditions &amp; Symptoms&lt;/ref&gt;

== Ukwakheka kwepumulo ==
Ipumulo inembobo ezimbili ekuthomeni kwayo, ngizo ezidosa ummoya ziwungenise nofana ziwukhiphe. Bese kubemsipha ohlukanisa imbobo ezimbili zepumulo. Umsipha lo ubizwa bona yi cartilage une thambo. Besekube namathambo we turbinate, made ngokudaleka begodu awondile. Amathambo lawa ngiwo asebenza ukwenza bona ummoya ongena ngepumulweni ufuthumale. Okhunye kune olfactory epithelium ekuyimembreni yamafinyila ehlala ngaphakathi komgodi wepumulo. Into le inamaseli akhethekileko asebenza ukuzwelela iphunga nofana umnuko ongabakhona&lt;ref&gt;Patel, R.G., 2017. Nasal anatomy and function. ''Facial plastic surgery'', ''33''(01), pp.003-008.&lt;/ref&gt;.

== Umsebenzi wepumulo ==
Amafinyila

Ipumulo isebenza ukwenza amafinyila ekumamanzi adege aregako. Amafinyila akghona uku udosa [[ithuli,]] amagcikwane nokhunye okungazama ukungena ngepumulweni.

Ukukghogela

Ikghona ukwenza bona umuntu akghone [[ukukghogela]] iphunga elingaba khona eduze kwakhe. Isibonelo umuntu angakghona ukuzwa iphunga lentuthu bese abone nofana alemuke bona kunento etjhako eduze nalapha akhona.

Ukuphefumula

Ikhona ukuphefumula, yenza ummoya bona ufuthumale ngaphambi kokuthi uye emaphatjhini. Ikghona nokuthi ivimbe amagcikwane bona angakghoni ukungena ngemaphatjhini. Ipumulo iyakghona ukulwisana namagulo.</text>
      <sha1>cf60x8vffbndz816e69fwur0oc4fn2w</sha1>
    </revision>
    <revision>
      <id>3558</id>
      <parentid>2789</parentid>
      <timestamp>2025-08-05T15:46:15Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3558</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1862" sha1="hu7jn6btidae50qkwo1l7jtxckz4tzb" xml:space="preserve">[[Isimumathi:Canine Nose Macro Photo.png|thumb|Ipumulo yenja]]
'''Ipumulo''' isehloko ngaphezulu komlomo begodu ngaphasi kwamehlo. Inembobo ezimbili zokudosa [[ummoya]]. Ipumulo ngeyokuphefumula nokunukelela&lt;ref&gt;https://dictionary.cambridge.org/dictionary/english/nose&lt;/ref&gt;.Upumulo isebenza ukukghogela iphunga elingaba khona ngaphakathi kwebhoduluko. Ikghona ukusefa ummoya esiwuphefumulako ngaphambi kokuthi ungene ngaphakathi emzimbeni. Yenza ummoya bona bona ufuthumale ngaphambi kokuthi ufike emaphaphini&lt;ref&gt;What Are the 6 Functions of the Nose? Conditions &amp; Symptoms&lt;/ref&gt;

=== Ukwakheka kwepumulo ===
Ipumulo inembobo ezimbili ekuthomeni kwayo, ngizo ezidosa ummoya ziwungenise nofana ziwukhiphe. Bese kubemsipha ohlukanisa imbobo ezimbili zepumulo. Umsipha lo ubizwa bona yi cartilage une thambo. Besekube namathambo we turbinate, made ngokudaleka begodu awondile. Amathambo lawa ngiwo asebenza ukwenza bona ummoya ongena ngepumulweni ufuthumale. Okhunye kune olfactory epithelium ekuyimembreni yamafinyila ehlala ngaphakathi komgodi wepumulo. Into le inamaseli akhethekileko asebenza ukuzwelela iphunga nofana umnuko ongabakhona&lt;ref&gt;Patel, R.G., 2017. Nasal anatomy and function. ''Facial plastic surgery'', ''33''(01), pp.003-008.&lt;/ref&gt;.

=== Umsebenzi wepumulo ===
Ipumulo isebenza ukwenza amafinyila ekumamanzi adege aregako. Amafinyila akghona uku udosa [[ithuli,]] amagcikwane nokhunye okungazama ukungena ngepumulweni. Ikghona ukwenza bona umuntu akghone [[ukukghogela]] iphunga elingaba khona eduze kwakhe. Isibonelo umuntu angakghona ukuzwa iphunga lentuthu bese abone nofana alemuke bona kunento etjhako eduze nalapha akhona. Ikhona ukuphefumula, yenza ummoya bona ufuthumale ngaphambi kokuthi uye emaphatjhini. Ikghona nokuthi ivimbe amagcikwane bona angakghoni ukungena ngemaphatjhini. Ipumulo iyakghona ukulwisana namagulo.

== Iinkomba ==</text>
      <sha1>hu7jn6btidae50qkwo1l7jtxckz4tzb</sha1>
    </revision>
    <revision>
      <id>3559</id>
      <parentid>3558</parentid>
      <timestamp>2025-08-05T15:47:46Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3559</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1859" sha1="bhqajtlnx67falgbh88j8l9gr69lg8f" xml:space="preserve">[[Isimumathi:Canine Nose Macro Photo.png|thumb|Ipumulo yenja]]
'''Ipumulo''' isehloko ngaphezulu komlomo begodu ngaphasi kwamehlo. Inembobo ezimbili zokudosa [[ummoya]]. Ipumulo ngeyokuphefumula nokunukelela&lt;ref&gt;https://dictionary.cambridge.org/dictionary/english/nose&lt;/ref&gt;.Upumulo isebenza ukukghogela iphunga elingaba khona ngaphakathi kwebhoduluko. Ikghona ukusefa ummoya esiwuphefumulako ngaphambi kokuthi ungene ngaphakathi emzimbeni. Yenza ummoya bona bona ufuthumale ngaphambi kokuthi ufike emaphaphini&lt;ref&gt;What Are the 6 Functions of the Nose? Conditions &amp; Symptoms&lt;/ref&gt;

=== Ukwakheka kwepumulo ===
Ipumulo inembobo ezimbili ekuthomeni kwayo, ngizo ezidosa ummoya ziwungenise nofana ziwukhiphe. Bese kubemsipha ohlukanisa imbobo ezimbili zepumulo. Umsipha lo ubizwa bona yi''-cartilage''. Besekube namathambo we ''turbinate,'' made ngokudaleka begodu awondile. Amathambo lawa ngiwo asebenza ukwenza bona ummoya ongena ngepumulweni ufuthumale. Okhunye kune olfactory epithelium ekuyimembreni yamafinyila ehlala ngaphakathi komgodi wepumulo. Into le inamaseli akhethekileko asebenza ukuzwelela iphunga nofana umnuko ongabakhona&lt;ref&gt;Patel, R.G., 2017. Nasal anatomy and function. ''Facial plastic surgery'', ''33''(01), pp.003-008.&lt;/ref&gt;.

=== Umsebenzi wepumulo ===
Ipumulo isebenza ukwenza amafinyila ekumamanzi adege aregako. Amafinyila akghona uku udosa [[ithuli,]] amagcikwane nokhunye okungazama ukungena ngepumulweni. Ikghona ukwenza bona umuntu akghone [[ukukghogela]] iphunga elingaba khona eduze kwakhe. Isibonelo umuntu angakghona ukuzwa iphunga lentuthu bese abone nofana alemuke bona kunento etjhako eduze nalapha akhona. Ikhona ukuphefumula, yenza ummoya bona ufuthumale ngaphambi kokuthi uye emaphatjhini. Ikghona nokuthi ivimbe amagcikwane bona angakghoni ukungena ngemaphatjhini. Ipumulo iyakghona ukulwisana namagulo.

== Iinkomba ==</text>
      <sha1>bhqajtlnx67falgbh88j8l9gr69lg8f</sha1>
    </revision>
  </page>
  <page>
    <title>Amakhotho wethu.</title>
    <ns>0</ns>
    <id>520</id>
    <redirect title="Amakhotho wethu" />
    <revision>
      <id>2572</id>
      <timestamp>2025-03-22T05:40:48Z</timestamp>
      <contributor>
        <username>Kvazimodo</username>
        <id>341</id>
      </contributor>
      <comment>Janabaevazizbek moved page [[Amakhotho wethu.]] to [[Amakhotho wethu]]</comment>
      <origin>2572</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="29" sha1="op1h64ob81y7334c44dbnzb87v8wclu" xml:space="preserve">#REDIRECT [[Amakhotho wethu]]</text>
      <sha1>op1h64ob81y7334c44dbnzb87v8wclu</sha1>
    </revision>
  </page>
  <page>
    <title>Izandla</title>
    <ns>0</ns>
    <id>521</id>
    <revision>
      <id>2580</id>
      <timestamp>2025-03-24T09:17:28Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''Isandla''' sisiebenza ukulekelela umuntu bona akghone ukubamba izinto nofana ukwenza eminye yemisebenzi efana nokubetha izinto zomvumo, ukuluka,ukubamba into yokutlola&lt;ref&gt;HAND | English meaning - Cambridge Dictionary&lt;/ref&gt;. Izandla zomzimba zimbili ngilezi umuntu abamba nazo izinto.  Isandla esinye nesinye sinemino emihlanu. Isandla sinamathambo, imisipha Kanye nenyama.Isindla siyakghona ukusikinyeka ngendlela esifuna ngayo.   == Ukwakheka kwezandla == Isandla sinamt...&quot;</comment>
      <origin>2580</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2179" sha1="rfn3b9jsy4ybe09r3oztoo4bw0i5fzi" xml:space="preserve">'''Isandla''' sisiebenza ukulekelela umuntu bona akghone ukubamba izinto nofana ukwenza eminye yemisebenzi efana nokubetha izinto zomvumo, ukuluka,ukubamba into yokutlola&lt;ref&gt;HAND | English meaning - Cambridge Dictionary&lt;/ref&gt;. Izandla zomzimba zimbili ngilezi umuntu abamba nazo izinto.  Isandla esinye nesinye sinemino emihlanu. Isandla sinamathambo, imisipha Kanye nenyama.Isindla siyakghona ukusikinyeka ngendlela esifuna ngayo. 

== Ukwakheka kwezandla ==
Isandla sinamthambo ama-27 nakapheleleko, ekufaka phakathi [[amathambo]] abizwa bona ma-carpal, metacarpals Kanye nama phalanges. Ama-Carpals abu-8, amathabo amancani. Ama metacarpals mathambo amahlanu. Ama-Phalanges wona mathambo ama-14 lawa enza umini nesithupha. Isandla sinemisipha engaphakathi nengaphandle&lt;ref&gt;Tang, A. and Varacallo, M., 2018. Anatomy, shoulder and upper limb, hand carpal bones.&lt;/ref&gt;. 

== Umsebenzi wezandla. ==
Zilekelela umuntu akghone ukuzwelela into bona ibutjhelela, iyahlaba, nofana iyakghwara. Sikghona ukwenz umuntu akgone ukuzwelela izinto zebhoduluko yakhe zinjani lokha nakazibambako.Izandla ziyakghona ukusebenza nekukhulumeni ngombana abantu abangezwako bayakghona ukusebenzisa izandla ukukhuluma baveze imizwa yabo, imibono kanye nemicabango yabo ngaphandle kokuthi bakhiphe iphimbo labo&lt;ref&gt;Maw, J., Wong, K.Y. and Gillespie, P., 2016. Hand anatomy. ''British Journal of Hospital Medicine'', ''77''(3), pp.C34-C40.&lt;/ref&gt;.

Izandla zilekelela amathulusi wetheknoloji bona akghone ukuwasebenza isibonelo Umuntu usebenzisa izandla ukubetha ihamura begodu nokusebenzia abomaliledini namakhomphyutha sisebeniza izandla ukuwenza asebenze.

Umuntu angakghona ukuphila anganazo izandla ngombana akusiso esithi nasikhutjhwako emzimbeni bese ipilo yomuntu ithikamezeke nofana iphele. Banengi abantu abanganazo izandla ngokwemvelo nofana ngokwenziwa ziintjhijilo abahlangana nazo epilweni bagcina banganazo kodwana basaphila begodu bsakghona ukwenza izinto abafuna ukuzenza.

== Isiphetho ==
Isandla siqakathekile emzimbeni womuntu ngomba sirhelebha umuntu bona akghona ukwenza imisebenzi yakhe yangemihla begodu akghone ukubamba ezwe izinto zinjani ngokuthi ziyahlaba nofana zibutjhelela</text>
      <sha1>rfn3b9jsy4ybe09r3oztoo4bw0i5fzi</sha1>
    </revision>
    <revision>
      <id>2803</id>
      <parentid>2580</parentid>
      <timestamp>2025-05-06T12:40:31Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2803</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2179" sha1="871uu7gdy15kh94oado4pq8x17o096w" xml:space="preserve">'''Isandla''' sisebenza ukulekelela umuntu bona akghone ukubamba izinto nofana ukwenza eminye yemisebenzi efana nokubetha izinto zomvumo, ukuluka,ukubamba into yokutlola&lt;ref&gt;HAND | English meaning - Cambridge Dictionary&lt;/ref&gt;. Izandla zomzimba zimbili ngilezi umuntu abamba ngazo izinto.  Isandla esinye nesinye sinemino emihlanu. Isandla sinamathambo, imisipha Kanye nenyama.Isandla siyakghona ukusikinyeka ngendlela esifuna ngayo. 

== Ukwakheka kwezandla ==
Isandla sinamthambo ama-27 nakapheleleko, ekufaka phakathi [[amathambo]] abizwa bona ma-carpal, metacarpals Kanye nama phalanges. Ama-Carpals abu-8, amathabo amancani. Ama metacarpals mathambo amahlanu. Ama-Phalanges wona mathambo ama-14 lawa enza umini nesithupha. Isandla sinemisipha engaphakathi nengaphandle&lt;ref&gt;Tang, A. and Varacallo, M., 2018. Anatomy, shoulder and upper limb, hand carpal bones.&lt;/ref&gt;. 

== Umsebenzi wezandla. ==
Zilekelela umuntu akghone ukuzwelela into bona ibutjhelela, iyahlaba, nofana iyakghwara. Sikghona ukwenz umuntu akgone ukuzwelela izinto zebhoduluko yakhe zinjani lokha nakazibambako.Izandla ziyakghona ukusebenza nekukhulumeni ngombana abantu abangezwako bayakghona ukusebenzisa izandla ukukhuluma baveze imizwa yabo, imibono kanye nemicabango yabo ngaphandle kokuthi bakhiphe iphimbo labo&lt;ref&gt;Maw, J., Wong, K.Y. and Gillespie, P., 2016. Hand anatomy. ''British Journal of Hospital Medicine'', ''77''(3), pp.C34-C40.&lt;/ref&gt;.

Izandla zilekelela amathulusi wetheknoloji bona akghone ukuwasebenza isibonelo Umuntu usebenzisa izandla ukubetha ihamura begodu nokusebenzia abomaliledini namakhomphyutha sisebeniza izandla ukuwenza asebenze.

Umuntu angakghona ukuphila anganazo izandla ngombana akusiso esithi nasikhutjhwako emzimbeni bese ipilo yomuntu ithikamezeke nofana iphele. Banengi abantu abanganazo izandla ngokwemvelo nofana ngokwenziwa ziintjhijilo abahlangana nazo epilweni bagcina banganazo kodwana basaphila begodu bsakghona ukwenza izinto abafuna ukuzenza.

== Isiphetho ==
Isandla siqakathekile emzimbeni womuntu ngomba sirhelebha umuntu bona akghona ukwenza imisebenzi yakhe yangemihla begodu akghone ukubamba ezwe izinto zinjani ngokuthi ziyahlaba nofana zibutjhelela</text>
      <sha1>871uu7gdy15kh94oado4pq8x17o096w</sha1>
    </revision>
    <revision>
      <id>2804</id>
      <parentid>2803</parentid>
      <timestamp>2025-05-06T12:41:27Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2804</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2199" sha1="932yblhehisgauqvhwsu4f3uiyqkz28" xml:space="preserve">'''Isandla''' sisebenza ukulekelela umuntu bona akghone ukubamba izinto nofana ukwenza eminye yemisebenzi efana nokubetha izinto zomvumo, ukuluka,ukubamba into yokutlola&lt;ref&gt;HAND | English meaning - Cambridge Dictionary&lt;/ref&gt;. Izandla zomzimba zimbili ngilezi umuntu abamba ngazo izinto.  Isandla esinye nesinye sinemino emihlanu. Isandla sinamathambo, imisipha Kanye nenyama.Isandla siyakghona ukusikinyeka ngendlela esifuna ngayo. 

== Ukwakheka kwezandla ==
Isandla sinamathambo ama-27 nakapheleleko, ekufaka phakathi [[amathambo]] abizwa bona ma-carpal, metacarpals Kanye nama phalanges ngelimi lesiNgisi. Ama-Carpals abu-8, amathambo amancani. Ama metacarpals mathambo amahlanu. Ama-Phalanges wona mathambo ama-14 lawa enza imino nesithupha. Isandla sinemisipha engaphakathi nengaphandle&lt;ref&gt;Tang, A. and Varacallo, M., 2018. Anatomy, shoulder and upper limb, hand carpal bones.&lt;/ref&gt;. 

== Umsebenzi wezandla. ==
Zilekelela umuntu akghone ukuzwelela into bona ibutjhelela, iyahlaba, nofana iyakghwara. Sikghona ukwenz umuntu akgone ukuzwelela izinto zebhoduluko yakhe zinjani lokha nakazibambako.Izandla ziyakghona ukusebenza nekukhulumeni ngombana abantu abangezwako bayakghona ukusebenzisa izandla ukukhuluma baveze imizwa yabo, imibono kanye nemicabango yabo ngaphandle kokuthi bakhiphe iphimbo labo&lt;ref&gt;Maw, J., Wong, K.Y. and Gillespie, P., 2016. Hand anatomy. ''British Journal of Hospital Medicine'', ''77''(3), pp.C34-C40.&lt;/ref&gt;.

Izandla zilekelela amathulusi wetheknoloji bona akghone ukuwasebenza isibonelo Umuntu usebenzisa izandla ukubetha ihamura begodu nokusebenzia abomaliledini namakhomphyutha sisebeniza izandla ukuwenza asebenze.

Umuntu angakghona ukuphila anganazo izandla ngombana akusiso esithi nasikhutjhwako emzimbeni bese ipilo yomuntu ithikamezeke nofana iphele. Banengi abantu abanganazo izandla ngokwemvelo nofana ngokwenziwa ziintjhijilo abahlangana nazo epilweni bagcina banganazo kodwana basaphila begodu bsakghona ukwenza izinto abafuna ukuzenza.

== Isiphetho ==
Isandla siqakathekile emzimbeni womuntu ngomba sirhelebha umuntu bona akghona ukwenza imisebenzi yakhe yangemihla begodu akghone ukubamba ezwe izinto zinjani ngokuthi ziyahlaba nofana zibutjhelela</text>
      <sha1>932yblhehisgauqvhwsu4f3uiyqkz28</sha1>
    </revision>
  </page>
  <page>
    <title>Umdosi phambili</title>
    <ns>0</ns>
    <id>522</id>
    <revision>
      <id>2581</id>
      <timestamp>2025-03-24T09:40:24Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''Ukuba mdosi phambil'''i kutjho ukuba nekghona lokukhuthaza, nokukhombisa abantu indlela ebafanele abayithathe ukuze bakghone ukufeza nonyana ukufinyelela amabhudango wabo. Abadosi phambili bayabokala ngamatshwayo nangamakghono athileko ekungiwo abanza bona ukuba nomthelela phezu kwabantu babarhelebhe bakghone ukuzuza okukhulu&lt;ref&gt;LEADER | English meaning - Cambridge Dictionary&lt;/ref&gt;.  Ukubonakala ngani umdosi phambili  Umdosi phambili ubanebhudango  nofana isithombe n...&quot;</comment>
      <origin>2581</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3506" sha1="7l7yly388kuevk83za4biarb6ka709a" xml:space="preserve">'''Ukuba mdosi phambil'''i kutjho ukuba nekghona lokukhuthaza, nokukhombisa abantu indlela ebafanele abayithathe ukuze bakghone ukufeza nonyana ukufinyelela amabhudango wabo. Abadosi phambili bayabokala ngamatshwayo nangamakghono athileko ekungiwo abanza bona ukuba nomthelela phezu kwabantu babarhelebhe bakghone ukuzuza okukhulu&lt;ref&gt;LEADER | English meaning - Cambridge Dictionary&lt;/ref&gt;.

Ukubonakala ngani umdosi phambili

Umdosi phambili ubanebhudango  nofana isithombe ngekusasa.Ukghona ukugcugcuzela bekenze nabanye abantu bona basesenze Kanye naye ukuze bakghone ukuzuza lokho akubonako ebhudangweni lakhe.Ukghona ukukhuluma nanbantu ngendlela ezwakalako, uyakghono ukuveza umbono wakhe, begodu anikeze abantu umphumela walokho esele kwenziweko.Ukghona ukulalela iinlili  zabantu abasesiqhemeni sakhe&lt;ref&gt;Dewan, T. and Myatt, D.P., 2008. The qualities of leadership: Direction, communication, and obfuscation. ''American Political science review'', ''102''(3), pp.351-368.&lt;/ref&gt;

Unekghono lokawula imizwa yakhe, akadoswa kukwata okungalethwa kungavumelani emsebenzini. Uzwisisiwa woke umuntu ukuthi umhlobo onjani ngombana abanye abantu bathanda ukuvusa [[inturhu]] nalapho ingekho khona. Ikghono leli lenza bona umdosi phambi akghone ukuthaha inqunto ezihle begodu abe nobudlelwane obuhle nabantu.Umdosi phambili uyathembeka, unamaqiniso. Umdosi phambili akanayo ifihlo wena yoke into yakhe ekukhanyeni.Uyabekezela nalokha sele kunzima  emsebenzi awenzako kodwa uhlala anethemba lokobana uzinto zizokulunga&lt;ref&gt;Liu, C.H., 2010. Leadership: Qualities, Skills, and Efforts. ''Interbeing'', ''4''(2).&lt;/ref&gt;.

== Imihlobo yabadosi phambili ==

=== Umdosi phambili ongatjelwako ===
Lomhlobo womdosi phmbili othatha inqunto ayedwa angakhulumisani nesiqheema sakhe.  Isenzo lesi siba sihle lokha nangabe kunto efuneka msinya kodwana lokha nayingekho isiqhema nofana abasebenzi bangagcina bangaka khuthali ngombana imibona yabo ayithathwa&lt;ref&gt;Chukwusa, J., 2018. Autocratic leadership style: Obstacle to success in academic libraries. ''Library Philosophy and Practice'', p.1.&lt;/ref&gt;.

=== Umdosi phambili wentando yenengi ===
Lo mdosi phambili othi ngaphambi kobana athathe inqunto abize isiqhema sakhe nofana abasebenzi bese ezwe imibono yabo bese bavumelane bona bathatha isiqunto siphi. Lo mhlobo wenza abasebenzi bazizwe bakhuthele ukusebenza bagodu bamthembe umdosi phambili wabo. Kwesinye iskhathi isezo lesi singenza bona kugcine kungana siqunto esithathwako begodu abantu bangazazi bona bayaphi&lt;ref&gt;Bhatti, N., Maitlo, G.M., Shaikh, N., Hashmi, M.A. and Shaikh, F.M., 2012. The impact of autocratic and democratic leadership style on job satisfaction. ''International business research'', ''5''(2), p.192.&lt;/ref&gt;.

=== Umdosi phambili ovumela koke ===
Lo mdosi phambili ngegama kwaphela ngombana uvumela isiqheema sakhe nofana abasebenzi benze ngendlela abafuna ngayo. Bakghona ukuthatha iqunto ngokwabo yena angekho begodu angaboni ikinga. Isenzo lesi singenza bona kube nokutjharagana kwezinto abantu bagcine sele bamotjha izinto ezinengi&lt;ref&gt;Chaudhry, A.Q. and Javed, H., 2012. Impact of transactional and laissez faire leadership style on motivation. ''International Journal of Business and social science'', ''3''(7).&lt;/ref&gt;.

== Isiphetho ==
Ukuba mdosi phambili akusiyo into elula mgombana kufanele ubenamkghona,namathwayo athileko azokuphumelelisa njengo mdosi phambili afana nokuthi ukghone ukukhuluma nabanye abantu uveze nofana wethule umbono wakho kuhle ukuze abantu bakghone ukulandela.</text>
      <sha1>7l7yly388kuevk83za4biarb6ka709a</sha1>
    </revision>
    <revision>
      <id>2582</id>
      <parentid>2581</parentid>
      <timestamp>2025-03-24T09:47:09Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2582</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3510" sha1="5kcwegobgbp3yhv494dnjojdbijalaw" xml:space="preserve">'''Ukuba mdosi phambil'''i kutjho ukuba nekghona lokukhuthaza, nokukhombisa abantu indlela ebafanele abayithathe ukuze bakghone ukufeza nonyana ukufinyelela amabhudango wabo. Abadosi phambili bayabokala ngamatshwayo nangamakghono athileko ekungiwo abanza bona ukuba nomthelela phezu kwabantu babarhelebhe bakghone ukuzuza okukhulu&lt;ref&gt;LEADER | English meaning - Cambridge Dictionary&lt;/ref&gt;.

Ukubonakala ngani umdosi phambili

Umdosi phambili ubanebhudango  nofana isithombe ngekusasa.Ukghona ukugcugcuzela bekenze nabanye abantu bona basesenze Kanye naye ukuze bakghone ukuzuza lokho akubonako ebhudangweni lakhe.Ukghona ukukhuluma nabantu ngendlela ezwakalako, uyakghono ukuveza umbono wakhe, begodu anikeze abantu umphumela walokho esele kwenziweko.Ukghona ukulalela iinlilo zabantu abasesiqhemeni sakhe&lt;ref&gt;Dewan, T. and Myatt, D.P., 2008. The qualities of leadership: Direction, communication, and obfuscation. ''American Political science review'', ''102''(3), pp.351-368.&lt;/ref&gt;

Unekghono lokulawula imizwa yakhe, akadoswa kukwata okungalethwa kungavumelani emsebenzini. Uzwisisiwa woke umuntu ukuthi umhlobo onjani ngombana abanye abantu bathanda ukuvusa [[inturhu]] nalapho ingekho khona. Ikghono leli lenza bona umdosi phambi akghone ukuthaha inqunto ezihle begodu abe nobudlelwane obuhle nabantu.Umdosi phambili uyathembeka, unamaqiniso. Umdosi phambili akanayo ifihlo wena yoke into yakhe ekukhanyeni.Uyabekezela nalokha sele kunzima  emsebenzini awenzako kodwana uhlala anethemba lokobana uzinto zizokulunga&lt;ref&gt;Liu, C.H., 2010. Leadership: Qualities, Skills, and Efforts. ''Interbeing'', ''4''(2).&lt;/ref&gt;.

== Imihlobo yabadosi phambili ==

=== Umdosi phambili ongatjelwako ===
Lomhlobo womdosi phmbili othatha inqunto ayedwa angakhulumisani nesiqheema sakhe.  Isenzo lesi siba sihle lokha nangabe kunto efuneka msinya kodwana lokha nayingekho isiqhema nofana abasebenzi bangagcina bangaka khuthali ngombana imibona yabo ayithathwa&lt;ref&gt;Chukwusa, J., 2018. Autocratic leadership style: Obstacle to success in academic libraries. ''Library Philosophy and Practice'', p.1.&lt;/ref&gt;.

=== Umdosi phambili wentando yenengi ===
Lo mdosi phambili othi ngaphambi kobana athathe inqunto abize isiqhema sakhe nofana abasebenzi bese ezwe imibono yabo bese bavumelane bona bathatha isiqunto siphi. Lo mhlobo wenza abasebenzi bazizwe bakhuthele ukusebenza bagodu bamthembe umdosi phambili wabo. Kwesinye iskhathi isezo lesi singenza bona kugcine kungana siqunto esithathwako begodu abantu bangazazi bona bayaphi&lt;ref&gt;Bhatti, N., Maitlo, G.M., Shaikh, N., Hashmi, M.A. and Shaikh, F.M., 2012. The impact of autocratic and democratic leadership style on job satisfaction. ''International business research'', ''5''(2), p.192.&lt;/ref&gt;.

=== Umdosi phambili ovumela koke ===
Lo mdosi phambili ngegama kwaphela ngombana uvumela isiqheema sakhe nofana abasebenzi benze ngendlela abafuna ngayo. Bakghona ukuthatha iqunto ngokwabo yena angekho begodu angaboni ikinga. Isenzo lesi singenza bona kube nokutjharagana kwezinto abantu bagcine sele bamotjha izinto ezinengi&lt;ref&gt;Chaudhry, A.Q. and Javed, H., 2012. Impact of transactional and laissez faire leadership style on motivation. ''International Journal of Business and social science'', ''3''(7).&lt;/ref&gt;.

== Isiphetho ==
Ukuba mdosi phambili akusiyo into elula mgombana kufanele ubenamkghona,namathwayo athileko azokuphumelelisa njengo mdosi phambili afana nokuthi ukghone ukukhuluma nabanye abantu uveze nofana wethule umbono wakho kuhle ukuze abantu bakghone ukulandela.</text>
      <sha1>5kcwegobgbp3yhv494dnjojdbijalaw</sha1>
    </revision>
  </page>
  <page>
    <title>Inturhu yobulili</title>
    <ns>0</ns>
    <id>523</id>
    <revision>
      <id>2586</id>
      <timestamp>2025-03-26T08:28:09Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''Inturhu yobulili''' kukulokha abantu bembaji bahlukumeza abantu bengubo. Kuyenzeka nokuthu umuntu weembaji ahlukumeze umuntu wengubo.Ukuhlukumeza kuthoma ngokuthi omunye ebantwini ababili laba azibone anamandla uukudlula omunye agcine sele ahlukumeza&lt;ref&gt;John, N., Casey, S.E., Carino, G. and McGovern, T., 2020. Lessons never learned: crisis and gender‐based violence. ''Developing world bioethics'', ''20''(2), pp.65-68.&lt;/ref&gt;   == Izinto ezibangela inturhu yobulili =...&quot;</comment>
      <origin>2586</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5672" sha1="ql5inn247tzt119yv42e33d5zdr9lu9" xml:space="preserve">'''Inturhu yobulili''' kukulokha abantu bembaji bahlukumeza abantu bengubo. Kuyenzeka nokuthu umuntu weembaji ahlukumeze umuntu wengubo.Ukuhlukumeza kuthoma ngokuthi omunye ebantwini ababili laba azibone anamandla uukudlula omunye agcine sele ahlukumeza&lt;ref&gt;John, N., Casey, S.E., Carino, G. and McGovern, T., 2020. Lessons never learned: crisis and gender‐based violence. ''Developing world bioethics'', ''20''(2), pp.65-68.&lt;/ref&gt; 

== Izinto ezibangela inturhu yobulili ==

=== Ukukwata ===
Abanye abanantu lokha nabakwatileko abakghoni ukuzilawula abagcine bavusa inturhu nalapho kungekho isidingo khona. Umuntu wakhona nakungenzeka ningavumelani ngekulumo nofana kwaba khona ukuphikisana yena ugcina sele avusa inturhu.

=== Ukuhlukumezeka ===
Umuntu okhululele lapho kuhlala kuliwa khona nofana kunenturhu into ingahlukumeza engcoindweni agcine sele abona ngathi ngiyo into ererhe yokuphila. Lokha kuzomenza bona naye agcine sele ahlukumeza umuntu athandana ngokuthu ahlale athoma inturhu ukuthi alungise imiraro abacalana nayo banomuntu athandana naye&lt;ref&gt;John, N., Casey, S.E., Carino, G. and McGovern, T., 2020. Lessons never learned: crisis and gender‐based violence. ''Developing world bioethics'', ''20''(2), pp.65-68.&lt;/ref&gt;.

=== Ukudopha phasi ===
Ukudopha phasi kugabangela ukuthi umuntu agcine azithola sele angungazimbi wenturhu yobulili. Lokhu kwenzeka ngokuthi umuntu azithole athandana nomuntu omhlukumezako kodwana angakghoni ukuhlukana naye ngesibanga sokuthi umuntu ohlukumezako lo ngunye omthengela Ukudla, izambatho nokunye. Abanye abayahlala ngokuthI sele babe nabantwana  ngabantu labo lokho kwenza  bona bangalekeleleki&lt;ref&gt;Onyejekwe, C.J., 2013. The interrelationship between gender-based violence and HIV/AIDS in South Africa. ''Journal of International Women's Studies'', ''6''(1), pp.34-40.&lt;/ref&gt;.

=== Ukubandlulula ngokobulili ===
Amanye amadoda akholwa bona umfazi nofana umuntu wengubbo ungaphasi kwendoda bese ngasikhathi nabafuna ukuveza ubudoda babo bagcina babanga inturhu ngendlini. Amanye amadoda akafuni ukuthi umuntu wengubo aveze umbono wakhe nofana indlela azizwa ngayo ngoba babona ukuthi ufazi ugaphasi kwendoda, bese nakathi uveza indlela azizwa ngayo agcine abethwa. Into le yenzeka khulu endaweni lapho kugcwele khona bantu bamasiko ngombana ngokwesiko umfazi ungaphasi kwendoda begodu indaba yelungelo lokulingana ayikho.

=== Ukuba ngaphasi kwengandelelo lotjwala ===
Abanye abantu lokha nasebesele utjwala bazithola selel babanga inturhu ngombana vane badikiwe begodu umkhumbulo wabo ungasebenzi kuhle&lt;ref&gt;Ndlovu, S., Mulondo, M., Tsoka-Gwegweni, J. and Ndirangu, J., 2022. COVID-19 impact on gender-based violence among women in South Africa during lockdown: A narrative review. ''African Journal of Reproductive Health'', ''26''(7), pp.59-71.&lt;/ref&gt;.

== Imiphumela yenturhu yobulili ==

=== Ukugandeleleka komkhumbulo ===
Umuntu ongungazimbi wenturhu yobulili angacina sele agandelelekile ngokomkhumbulo.Lokho kuzabe kumiphumela yokuthi into le imphatha kumbi begodu abanye babaneenhloni zokukhuluma ngayo, ngombana basaba abantu bona  bazaba hleka  khulu khulu nangabe mumuntu wembaji obethwa mumuntu wengubo. Umuntu wengubo nakangatholo irhelebho emndenini, ebanganini nofana emapholiseni, kunganamuntu akhuluma naye aba manengi amathuba wokuthi agandeleleke nokomkhumbulo&lt;ref&gt;Rees, S., Silove, D., Chey, T., Ivancic, L., Steel, Z., Creamer, M., Teesson, M., Bryant, R., McFarlane, A.C., Mills, K.L. and Slade, T., 2011. Lifetime prevalence of gender-based violence in women and the relationship with mental disorders and psychosocial function. ''Jama'', ''306''(5), pp.513-521.

Vancouver&lt;/ref&gt;.

=== Ukuzikhipha hlangana nabantu ===
Omunye umuntu nangabe ubanjwe yinturhu yobulili ugcina sele azikhipha hlangana ngabantu ngombana agcina sele anganakho [[ukuzithemba]] abane ngathi abantu bayamhleka ngesimo sakhe. Ubona ngathi abantu bahleba ngayo nofana ngathi bayamahlulela. Lokho kugcina kumenza bona abalekele ukuhlangana ngabantu ahlale azivalele ngendlini.

=== Ukuzikhunga ===
Ngesinye isikhathi umuntu angagcina sele angasasiboni usidingo sokuthi aragele phambili aphile nakukuthi uzokuphila ngenturhu ngamalanga. Ugcina sele abona ukuthi kungcono bona athathe ipilo yakhe ukuze aziphumuze enturhwini aphila ngayo ngamalanga ekhaya.

== Iindlela yokulwisana nenturhu yobulili ==

=== Ukufundisa ngobumbi benturhu yokubulili ===
Ukulwisana nenturhu yobulili kufanele abantu bafundiswe ngobumbi benurhu yobulili. Lokhu kungenziwa khulu khulu eneenkundleni zokuthintana ngombana kukulaho abantu baphila babelana khona ngelwazi baveze khona [[imicabango]] yabo Kanye nemibono&lt;ref&gt;Olaitan, Z.M., 2024. Using digital technology to address gender-based violence in South Africa. In ''African women in the fourth industrial revolution'' (pp. 226-240). Routledge.&lt;/ref&gt;.

=== Ukurhelebha labo abanza isenzo lesi ngombana nabo bakhe bababongazimbi ===
Kufanalwe kusizwe labo bantu abahlukumeza abalingani babo ngesibanga sokuthi nabo bakhe bahlala endaweni lapho kuphilwa khona ngenturhu yobulili. Kufanele abatholelwe umuntu abazokucoca naye ukuze bakghone ukukhipha [[ubuhlungu]] ebakhe babuzwa ekubenza bona bagcine sele nabo babanga inturhu&lt;ref&gt;Oparinde, K. and Matsha, R.M., 2021. Powerful discourse: Gender-based violence and counter-discourses in South Africa. ''Cogent Arts &amp; Humanities'', ''8''(1), p.1911035.&lt;/ref&gt;.

== Isipthetho ==
Inturhu yobulili kuyonto engakalungi emphakathini ngombaa yenza abantu wengubo bazizwe bangakavikeleki ebhodulukweni abahlala kilo. Labo bantu ababongazimbi besenzo lesi bagcina sele bazithola bagandelelelkile ngokomkhumbulo nofana bangasafuni ukuba hlangana nabantu.</text>
      <sha1>ql5inn247tzt119yv42e33d5zdr9lu9</sha1>
    </revision>
    <revision>
      <id>2650</id>
      <parentid>2586</parentid>
      <timestamp>2025-04-04T18:31:00Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2650</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5671" sha1="qq0be4u1c2f5fekuuj3h6cuyc4mrc0u" xml:space="preserve">'''Inturhu yobulili''' kukulokha abantu bembaji bahlukumeza abantu bengubo. Kuyenzeka nokuthu umuntu weembaji ahlukumeze umuntu wengubo.Ukuhlukumeza kuthoma ngokuthi omunye ebantwini ababili laba azibone anamandla uukudlula omunye agcine sele ahlukumeza&lt;ref&gt;John, N., Casey, S.E., Carino, G. and McGovern, T., 2020. Lessons never learned: crisis and gender‐based violence. ''Developing world bioethics'', ''20''(2), pp.65-68.&lt;/ref&gt; 

== Izinto ezibangela inturhu yobulili ==

=== Ukukwata ===
Abanye abanantu lokha nabakwatileko abakghoni ukuzilawula abagcine bavusa inturhu nalapho kungekho isidingo khona. Umuntu wakhona nakungenzeka ningavumelani ngekulumo nofana kwaba khona ukuphikisana yena ugcina sele avusa inturhu.

=== Ukuhlukumezeka ===
Umuntu okhululele lapho kuhlala kuliwa khona nofana kunenturhu into ingahlukumeza engcondweni agcine sele abona ngathi ngiyo into ererhe yokuphila. Lokha kuzomenza bona naye agcine sele ahlukumeza umuntu athandana ngokuthu ahlale athoma inturhu ukuthi alungise imiraro abacalana nayo banomuntu athandana naye&lt;ref&gt;John, N., Casey, S.E., Carino, G. and McGovern, T., 2020. Lessons never learned: crisis and gender‐based violence. ''Developing world bioethics'', ''20''(2), pp.65-68.&lt;/ref&gt;.

=== Ukudopha phasi ===
Ukudopha phasi kugabangela ukuthi umuntu agcine azithola sele angungazimbi wenturhu yobulili. Lokhu kwenzeka ngokuthi umuntu azithole athandana nomuntu omhlukumezako kodwana angakghoni ukuhlukana naye ngesibanga sokuthi umuntu ohlukumezako lo ngunye omthengela Ukudla, izambatho nokunye. Abanye abayahlala ngokuthI sele babe nabantwana  ngabantu labo lokho kwenza  bona bangalekeleleki&lt;ref&gt;Onyejekwe, C.J., 2013. The interrelationship between gender-based violence and HIV/AIDS in South Africa. ''Journal of International Women's Studies'', ''6''(1), pp.34-40.&lt;/ref&gt;.

=== Ukubandlulula ngokobulili ===
Amanye amadoda akholwa bona umfazi nofana umuntu wengubbo ungaphasi kwendoda bese ngasikhathi nabafuna ukuveza ubudoda babo bagcina babanga inturhu ngendlini. Amanye amadoda akafuni ukuthi umuntu wengubo aveze umbono wakhe nofana indlela azizwa ngayo ngoba babona ukuthi ufazi ugaphasi kwendoda, bese nakathi uveza indlela azizwa ngayo agcine abethwa. Into le yenzeka khulu endaweni lapho kugcwele khona bantu bamasiko ngombana ngokwesiko umfazi ungaphasi kwendoda begodu indaba yelungelo lokulingana ayikho.

=== Ukuba ngaphasi kwengandelelo lotjwala ===
Abanye abantu lokha nasebesele utjwala bazithola selel babanga inturhu ngombana vane badikiwe begodu umkhumbulo wabo ungasebenzi kuhle&lt;ref&gt;Ndlovu, S., Mulondo, M., Tsoka-Gwegweni, J. and Ndirangu, J., 2022. COVID-19 impact on gender-based violence among women in South Africa during lockdown: A narrative review. ''African Journal of Reproductive Health'', ''26''(7), pp.59-71.&lt;/ref&gt;.

== Imiphumela yenturhu yobulili ==

=== Ukugandeleleka komkhumbulo ===
Umuntu ongungazimbi wenturhu yobulili angacina sele agandelelekile ngokomkhumbulo.Lokho kuzabe kumiphumela yokuthi into le imphatha kumbi begodu abanye babaneenhloni zokukhuluma ngayo, ngombana basaba abantu bona  bazaba hleka  khulu khulu nangabe mumuntu wembaji obethwa mumuntu wengubo. Umuntu wengubo nakangatholo irhelebho emndenini, ebanganini nofana emapholiseni, kunganamuntu akhuluma naye aba manengi amathuba wokuthi agandeleleke nokomkhumbulo&lt;ref&gt;Rees, S., Silove, D., Chey, T., Ivancic, L., Steel, Z., Creamer, M., Teesson, M., Bryant, R., McFarlane, A.C., Mills, K.L. and Slade, T., 2011. Lifetime prevalence of gender-based violence in women and the relationship with mental disorders and psychosocial function. ''Jama'', ''306''(5), pp.513-521.

Vancouver&lt;/ref&gt;.

=== Ukuzikhipha hlangana nabantu ===
Omunye umuntu nangabe ubanjwe yinturhu yobulili ugcina sele azikhipha hlangana ngabantu ngombana agcina sele anganakho [[ukuzithemba]] abane ngathi abantu bayamhleka ngesimo sakhe. Ubona ngathi abantu bahleba ngayo nofana ngathi bayamahlulela. Lokho kugcina kumenza bona abalekele ukuhlangana ngabantu ahlale azivalele ngendlini.

=== Ukuzikhunga ===
Ngesinye isikhathi umuntu angagcina sele angasasiboni usidingo sokuthi aragele phambili aphile nakukuthi uzokuphila ngenturhu ngamalanga. Ugcina sele abona ukuthi kungcono bona athathe ipilo yakhe ukuze aziphumuze enturhwini aphila ngayo ngamalanga ekhaya.

== Iindlela yokulwisana nenturhu yobulili ==

=== Ukufundisa ngobumbi benturhu yokubulili ===
Ukulwisana nenturhu yobulili kufanele abantu bafundiswe ngobumbi benurhu yobulili. Lokhu kungenziwa khulu khulu eneenkundleni zokuthintana ngombana kukulaho abantu baphila babelana khona ngelwazi baveze khona [[imicabango]] yabo Kanye nemibono&lt;ref&gt;Olaitan, Z.M., 2024. Using digital technology to address gender-based violence in South Africa. In ''African women in the fourth industrial revolution'' (pp. 226-240). Routledge.&lt;/ref&gt;.

=== Ukurhelebha labo abanza isenzo lesi ngombana nabo bakhe bababongazimbi ===
Kufanalwe kusizwe labo bantu abahlukumeza abalingani babo ngesibanga sokuthi nabo bakhe bahlala endaweni lapho kuphilwa khona ngenturhu yobulili. Kufanele abatholelwe umuntu abazokucoca naye ukuze bakghone ukukhipha [[ubuhlungu]] ebakhe babuzwa ekubenza bona bagcine sele nabo babanga inturhu&lt;ref&gt;Oparinde, K. and Matsha, R.M., 2021. Powerful discourse: Gender-based violence and counter-discourses in South Africa. ''Cogent Arts &amp; Humanities'', ''8''(1), p.1911035.&lt;/ref&gt;.

== Isipthetho ==
Inturhu yobulili kuyonto engakalungi emphakathini ngombaa yenza abantu wengubo bazizwe bangakavikeleki ebhodulukweni abahlala kilo. Labo bantu ababongazimbi besenzo lesi bagcina sele bazithola bagandelelelkile ngokomkhumbulo nofana bangasafuni ukuba hlangana nabantu.</text>
      <sha1>qq0be4u1c2f5fekuuj3h6cuyc4mrc0u</sha1>
    </revision>
    <revision>
      <id>5189</id>
      <parentid>2650</parentid>
      <timestamp>2025-08-16T08:01:32Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5189</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5685" sha1="pxtxvwmfhkae3rgxkz7z0doxfzrr2ht" xml:space="preserve">'''Inturhu yobulili''' kukulokha abantu bembaji bahlukumeza abantu bengubo. Kuyenzeka nokuthu umuntu weembaji ahlukumeze umuntu wengubo.Ukuhlukumeza kuthoma ngokuthi omunye ebantwini ababili laba azibone anamandla uukudlula omunye agcine sele ahlukumeza.&lt;ref&gt;John, N., Casey, S.E., Carino, G. and McGovern, T., 2020. Lessons never learned: crisis and gender‐based violence. ''Developing world bioethics'', ''20''(2), pp.65-68.&lt;/ref&gt; 

=== Izinto ezibangela inturhu yobulili ===

==== Ukukwata ====
Abanye abanantu lokha nabakwatileko abakghoni ukuzilawula abagcine bavusa inturhu nalapho kungekho isidingo khona. Umuntu wakhona nakungenzeka ningavumelani ngekulumo nofana kwaba khona ukuphikisana yena ugcina sele avusa inturhu.

==== Ukuhlukumezeka nokuba ngaphasi kwegandelelo lotjwala ====
Umuntu okhululele lapho kuhlala kuliwa khona nofana kunenturhu into ingahlukumeza engcondweni agcine sele abona ngathi ngiyo into ererhe yokuphila. Lokha kuzomenza bona naye agcine sele ahlukumeza umuntu athandana ngokuthu ahlale athoma inturhu ukuthi alungise imiraro abacalana nayo banomuntu athandana naye.&lt;ref&gt;John, N., Casey, S.E., Carino, G. and McGovern, T., 2020. Lessons never learned: crisis and gender‐based violence. ''Developing world bioethics'', ''20''(2), pp.65-68.&lt;/ref&gt; Abanye abantu lokha nasebesele utjwala bazithola selel babanga inturhu ngombana vane badikiwe begodu umkhumbulo wabo ungasebenzi kuhle.&lt;ref&gt;Ndlovu, S., Mulondo, M., Tsoka-Gwegweni, J. and Ndirangu, J., 2022. COVID-19 impact on gender-based violence among women in South Africa during lockdown: A narrative review. ''African Journal of Reproductive Health'', ''26''(7), pp.59-71.&lt;/ref&gt;

==== Ukudopha phasi ====
Ukudopha phasi kugabangela ukuthi umuntu agcine azithola sele angungazimbi wenturhu yobulili. Lokhu kwenzeka ngokuthi umuntu azithole athandana nomuntu omhlukumezako kodwana angakghoni ukuhlukana naye ngesibanga sokuthi umuntu ohlukumezako lo ngunye omthengela Ukudla, izambatho nokunye. Abanye abayahlala ngokuthI sele babe nabantwana  ngabantu labo lokho kwenza  bona bangalekeleleki.&lt;ref&gt;Onyejekwe, C.J., 2013. The interrelationship between gender-based violence and HIV/AIDS in South Africa. ''Journal of International Women's Studies'', ''6''(1), pp.34-40.&lt;/ref&gt;

==== Ukubandlulula ngokobulili ====
Amanye amadoda akholwa bona umfazi nofana umuntu wengubbo ungaphasi kwendoda bese ngasikhathi nabafuna ukuveza ubudoda babo bagcina babanga inturhu ngendlini. Amanye amadoda akafuni ukuthi umuntu wengubo aveze umbono wakhe nofana indlela azizwa ngayo ngoba babona ukuthi ufazi ugaphasi kwendoda, bese nakathi uveza indlela azizwa ngayo agcine abethwa. Into le yenzeka khulu endaweni lapho kugcwele khona bantu bamasiko ngombana ngokwesiko umfazi ungaphasi kwendoda begodu indaba yelungelo lokulingana ayikho.

==== Imiphumela yenturhu yobulili ====

==== Ukugandeleleka komkhumbulo ====
Umuntu ongungazimbi wenturhu yobulili angacina sele agandelelekile ngokomkhumbulo.Lokho kuzabe kumiphumela yokuthi into le imphatha kumbi begodu abanye babaneenhloni zokukhuluma ngayo, ngombana basaba abantu bona  bazaba hleka  khulu khulu nangabe mumuntu wembaji obethwa mumuntu wengubo. Umuntu wengubo nakangatholo irhelebho emndenini, ebanganini nofana emapholiseni, kunganamuntu akhuluma naye aba manengi amathuba wokuthi agandeleleke nokomkhumbulo.&lt;ref&gt;Rees, S., Silove, D., Chey, T., Ivancic, L., Steel, Z., Creamer, M., Teesson, M., Bryant, R., McFarlane, A.C., Mills, K.L. and Slade, T., 2011. Lifetime prevalence of gender-based violence in women and the relationship with mental disorders and psychosocial function. ''Jama'', ''306''(5), pp.513-521.

Vancouver&lt;/ref&gt;

==== Ukuzikhipha hlangana nabantu nokulinga ukuzikhunga ====
Omunye umuntu nangabe ubanjwe yinturhu yobulili ugcina sele azikhipha hlangana ngabantu ngombana agcina sele anganakho [[ukuzithemba]] abane ngathi abantu bayamhleka ngesimo sakhe. Ubona ngathi abantu bahleba ngayo nofana ngathi bayamahlulela. Lokho kugcina kumenza bona abalekele ukuhlangana ngabantu ahlale azivalele ngendlini. Ngesinye isikhathi umuntu angagcina sele angasasiboni usidingo sokuthi aragele phambili aphile nakukuthi uzokuphila ngenturhu ngamalanga. Ugcina sele abona ukuthi kungcono bona athathe ipilo yakhe ukuze aziphumuze enturhwini aphila ngayo ngamalanga ekhaya.

=== Iindlela yokulwisana nenturhu yobulili ===

==== Ukufundisa ngobumbi benturhu yokubulili ====
Ukulwisana nenturhu yobulili kufanele abantu bafundiswe ngobumbi benurhu yobulili. Lokhu kungenziwa khulu khulu eneenkundleni zokuthintana ngombana kukulaho abantu baphila babelana khona ngelwazi baveze khona [[imicabango]] yabo Kanye nemibono&lt;ref&gt;Olaitan, Z.M., 2024. Using digital technology to address gender-based violence in South Africa. In ''African women in the fourth industrial revolution'' (pp. 226-240). Routledge.&lt;/ref&gt;.

==== Ukurhelebha labo abanza isenzo lesi ngombana nabo bakhe bababongazimbi ====
Kufanalwe kusizwe labo bantu abahlukumeza abalingani babo ngesibanga sokuthi nabo bakhe bahlala endaweni lapho kuphilwa khona ngenturhu yobulili. Kufanele abatholelwe umuntu abazokucoca naye ukuze bakghone ukukhipha [[ubuhlungu]] ebakhe babuzwa ekubenza bona bagcine sele nabo babanga inturhu.&lt;ref&gt;Oparinde, K. and Matsha, R.M., 2021. Powerful discourse: Gender-based violence and counter-discourses in South Africa. ''Cogent Arts &amp; Humanities'', ''8''(1), p.1911035.&lt;/ref&gt;Inturhu yobulili kuyonto engakalungi emphakathini ngombaa yenza abantu wengubo bazizwe bangakavikeleki ebhodulukweni abahlala kilo. Labo bantu ababongazimbi besenzo lesi bagcina sele bazithola bagandelelelkile ngokomkhumbulo nofana bangasafuni ukuba hlangana nabantu.

== Iinkomba ==</text>
      <sha1>pxtxvwmfhkae3rgxkz7z0doxfzrr2ht</sha1>
    </revision>
    <revision>
      <id>5190</id>
      <parentid>5189</parentid>
      <timestamp>2025-08-16T08:03:56Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5190</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5762" sha1="ekut6lir3tq8gvanbg30v28yg9rgfib" xml:space="preserve">'''Inturhu yobulili''' kukulokha abantu bembaji bahlukumeza abantu bengubo. Kuyenzeka nokuthu umuntu weembaji ahlukumeze umuntu wengubo.Ukuhlukumeza kuthoma ngokuthi omunye ebantwini ababili laba azibone anamandla uukudlula omunye agcine sele ahlukumeza.&lt;ref&gt;John, N., Casey, S.E., Carino, G. and McGovern, T., 2020. Lessons never learned: crisis and gender‐based violence. ''Developing world bioethics'', ''20''(2), pp.65-68.&lt;/ref&gt; 

=== Izinto ezibangela inturhu yobulili ===

==== Ukukwata ====
Abanye abanantu lokha nabakwatileko abakghoni ukuzilawula abagcine bavusa inturhu nalapho kungekho isidingo khona. Umuntu wakhona nakungenzeka ningavumelani ngekulumo nofana kwaba khona ukuphikisana yena ugcina sele avusa inturhu.

==== Ukuhlukumezeka nokuba ngaphasi kwegandelelo lotjwala ====
Umuntu okhululele lapho kuhlala kuliwa khona nofana kunenturhu into ingahlukumeza engcondweni agcine sele abona ngathi ngiyo into ererhe yokuphila. Lokha kuzomenza bona naye agcine sele ahlukumeza umuntu athandana ngokuthu ahlale athoma inturhu ukuthi alungise imiraro abacalana nayo banomuntu athandana naye.&lt;ref&gt;John, N., Casey, S.E., Carino, G. and McGovern, T., 2020. Lessons never learned: crisis and gender‐based violence. ''Developing world bioethics'', ''20''(2), pp.65-68.&lt;/ref&gt; Abanye abantu lokha nasebesele utjwala bazithola selel babanga inturhu ngombana vane badikiwe begodu umkhumbulo wabo ungasebenzi kuhle.&lt;ref&gt;Ndlovu, S., Mulondo, M., Tsoka-Gwegweni, J. and Ndirangu, J., 2022. COVID-19 impact on gender-based violence among women in South Africa during lockdown: A narrative review. ''African Journal of Reproductive Health'', ''26''(7), pp.59-71.&lt;/ref&gt;

==== Ukudopha phasi ====
Ukudopha phasi kugabangela ukuthi umuntu agcine azithola sele angungazimbi wenturhu yobulili. Lokhu kwenzeka ngokuthi umuntu azithole athandana nomuntu omhlukumezako kodwana angakghoni ukuhlukana naye ngesibanga sokuthi umuntu ohlukumezako lo ngunye omthengela Ukudla, izambatho nokunye. Abanye abayahlala ngokuthI sele babe nabantwana  ngabantu labo lokho kwenza  bona bangalekeleleki.&lt;ref&gt;Onyejekwe, C.J., 2013. The interrelationship between gender-based violence and HIV/AIDS in South Africa. ''Journal of International Women's Studies'', ''6''(1), pp.34-40.&lt;/ref&gt;

==== Ukubandlulula ngokobulili ====
Amanye amadoda akholwa bona umfazi nofana umuntu wengubbo ungaphasi kwendoda bese ngasikhathi nabafuna ukuveza ubudoda babo bagcina babanga inturhu ngendlini. Amanye amadoda akafuni ukuthi umuntu wengubo aveze umbono wakhe nofana indlela azizwa ngayo ngoba babona ukuthi ufazi ugaphasi kwendoda, bese nakathi uveza indlela azizwa ngayo agcine abethwa. Into le yenzeka khulu endaweni lapho kugcwele khona bantu bamasiko ngombana ngokwesiko umfazi ungaphasi kwendoda begodu indaba yelungelo lokulingana ayikho.

==== Imiphumela yenturhu yobulili ====
[[Category:Inturhu yobulili]]
[[category:Inturhu]]
[[Category:Ukutlhoriswa]]

==== Ukugandeleleka komkhumbulo ====
Umuntu ongungazimbi wenturhu yobulili angacina sele agandelelekile ngokomkhumbulo.Lokho kuzabe kumiphumela yokuthi into le imphatha kumbi begodu abanye babaneenhloni zokukhuluma ngayo, ngombana basaba abantu bona  bazaba hleka  khulu khulu nangabe mumuntu wembaji obethwa mumuntu wengubo. Umuntu wengubo nakangatholo irhelebho emndenini, ebanganini nofana emapholiseni, kunganamuntu akhuluma naye aba manengi amathuba wokuthi agandeleleke nokomkhumbulo.&lt;ref&gt;Rees, S., Silove, D., Chey, T., Ivancic, L., Steel, Z., Creamer, M., Teesson, M., Bryant, R., McFarlane, A.C., Mills, K.L. and Slade, T., 2011. Lifetime prevalence of gender-based violence in women and the relationship with mental disorders and psychosocial function. ''Jama'', ''306''(5), pp.513-521.

Vancouver&lt;/ref&gt;

==== Ukuzikhipha hlangana nabantu nokulinga ukuzikhunga ====
Omunye umuntu nangabe ubanjwe yinturhu yobulili ugcina sele azikhipha hlangana ngabantu ngombana agcina sele anganakho [[ukuzithemba]] abane ngathi abantu bayamhleka ngesimo sakhe. Ubona ngathi abantu bahleba ngayo nofana ngathi bayamahlulela. Lokho kugcina kumenza bona abalekele ukuhlangana ngabantu ahlale azivalele ngendlini. Ngesinye isikhathi umuntu angagcina sele angasasiboni usidingo sokuthi aragele phambili aphile nakukuthi uzokuphila ngenturhu ngamalanga. Ugcina sele abona ukuthi kungcono bona athathe ipilo yakhe ukuze aziphumuze enturhwini aphila ngayo ngamalanga ekhaya.

=== Iindlela yokulwisana nenturhu yobulili ===

==== Ukufundisa ngobumbi benturhu yokubulili ====
Ukulwisana nenturhu yobulili kufanele abantu bafundiswe ngobumbi benurhu yobulili. Lokhu kungenziwa khulu khulu eneenkundleni zokuthintana ngombana kukulaho abantu baphila babelana khona ngelwazi baveze khona [[imicabango]] yabo Kanye nemibono&lt;ref&gt;Olaitan, Z.M., 2024. Using digital technology to address gender-based violence in South Africa. In ''African women in the fourth industrial revolution'' (pp. 226-240). Routledge.&lt;/ref&gt;.

==== Ukurhelebha labo abanza isenzo lesi ngombana nabo bakhe bababongazimbi ====
Kufanalwe kusizwe labo bantu abahlukumeza abalingani babo ngesibanga sokuthi nabo bakhe bahlala endaweni lapho kuphilwa khona ngenturhu yobulili. Kufanele abatholelwe umuntu abazokucoca naye ukuze bakghone ukukhipha [[ubuhlungu]] ebakhe babuzwa ekubenza bona bagcine sele nabo babanga inturhu.&lt;ref&gt;Oparinde, K. and Matsha, R.M., 2021. Powerful discourse: Gender-based violence and counter-discourses in South Africa. ''Cogent Arts &amp; Humanities'', ''8''(1), p.1911035.&lt;/ref&gt;Inturhu yobulili kuyonto engakalungi emphakathini ngombaa yenza abantu wengubo bazizwe bangakavikeleki ebhodulukweni abahlala kilo. Labo bantu ababongazimbi besenzo lesi bagcina sele bazithola bagandelelelkile ngokomkhumbulo nofana bangasafuni ukuba hlangana nabantu.

== Iinkomba ==</text>
      <sha1>ekut6lir3tq8gvanbg30v28yg9rgfib</sha1>
    </revision>
    <revision>
      <id>5191</id>
      <parentid>5190</parentid>
      <timestamp>2025-08-16T08:06:20Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5191</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5760" sha1="9ne21wo61j5xlpox6copldg976hwxyb" xml:space="preserve">'''Inturhu yobulili''' kukulokha abantu bembaji bahlukumeza abantu bengubo. Kuyenzeka nokuthu umuntu weembaji ahlukumeze umuntu wengubo.Ukuhlukumeza kuthoma ngokuthi omunye ebantwini ababili laba azibone anamandla uukudlula omunye agcine sele ahlukumeza.&lt;ref&gt;John, N., Casey, S.E., Carino, G. and McGovern, T., 2020. Lessons never learned: crisis and gender‐based violence. ''Developing world bioethics'', ''20''(2), pp.65-68.&lt;/ref&gt; 

=== Izinto ezibangela inturhu yobulili ===

==== Ukukwata ====
Abanye abanantu lokha nabakwatileko abakghoni ukuzilawula abagcine bavusa inturhu nalapho kungekho isidingo khona. Umuntu wakhona nakungenzeka ningavumelani ngekulumo nofana kwaba khona ukuphikisana yena ugcina sele avusa inturhu.

==== Ukuhlukumezeka nokuba ngaphasi kwegandelelo lotjwala ====
Umuntu okhululele lapho kuhlala kuliwa khona nofana kunenturhu into ingahlukumeza engcondweni agcine sele abona ngathi ngiyo into ererhe yokuphila. Lokha kuzomenza bona naye agcine sele ahlukumeza umuntu athandana ngokuthu ahlale athoma inturhu ukuthi alungise imiraro abacalana nayo banomuntu athandana naye.&lt;ref&gt;John, N., Casey, S.E., Carino, G. and McGovern, T., 2020. Lessons never learned: crisis and gender‐based violence. ''Developing world bioethics'', ''20''(2), pp.65-68.&lt;/ref&gt; Abanye abantu lokha nasebesele utjwala bazithola selel babanga inturhu ngombana vane badikiwe begodu umkhumbulo wabo ungasebenzi kuhle.&lt;ref&gt;Ndlovu, S., Mulondo, M., Tsoka-Gwegweni, J. and Ndirangu, J., 2022. COVID-19 impact on gender-based violence among women in South Africa during lockdown: A narrative review. ''African Journal of Reproductive Health'', ''26''(7), pp.59-71.&lt;/ref&gt;

==== Ukudopha phasi ====
Ukudopha phasi kugabangela ukuthi umuntu agcine azithola sele angungazimbi wenturhu yobulili. Lokhu kwenzeka ngokuthi umuntu azithole athandana nomuntu omhlukumezako kodwana angakghoni ukuhlukana naye ngesibanga sokuthi umuntu ohlukumezako lo ngunye omthengela Ukudla, izambatho nokunye. Abanye abayahlala ngokuthI sele babe nabantwana  ngabantu labo lokho kwenza  bona bangalekeleleki.&lt;ref&gt;Onyejekwe, C.J., 2013. The interrelationship between gender-based violence and HIV/AIDS in South Africa. ''Journal of International Women's Studies'', ''6''(1), pp.34-40.&lt;/ref&gt;

==== Ukubandlulula ngokobulili ====
Amanye amadoda akholwa bona umfazi nofana umuntu wengubbo ungaphasi kwendoda bese ngasikhathi nabafuna ukuveza ubudoda babo bagcina babanga inturhu ngendlini. Amanye amadoda akafuni ukuthi umuntu wengubo aveze umbono wakhe nofana indlela azizwa ngayo ngoba babona ukuthi ufazi ugaphasi kwendoda, bese nakathi uveza indlela azizwa ngayo agcine abethwa. Into le yenzeka khulu endaweni lapho kugcwele khona bantu bamasiko ngombana ngokwesiko umfazi ungaphasi kwendoda begodu indaba yelungelo lokulingana ayikho.

=== Imiphumela yenturhu yobulili ===
[[Category:Inturhu yobulili]]
[[category:Inturhu]]
[[Category:Ukutlhoriswa]]

==== Ukugandeleleka komkhumbulo ====
Umuntu ongungazimbi wenturhu yobulili angacina sele agandelelekile ngokomkhumbulo.Lokho kuzabe kumiphumela yokuthi into le imphatha kumbi begodu abanye babaneenhloni zokukhuluma ngayo, ngombana basaba abantu bona  bazaba hleka  khulu khulu nangabe mumuntu wembaji obethwa mumuntu wengubo. Umuntu wengubo nakangatholo irhelebho emndenini, ebanganini nofana emapholiseni, kunganamuntu akhuluma naye aba manengi amathuba wokuthi agandeleleke nokomkhumbulo.&lt;ref&gt;Rees, S., Silove, D., Chey, T., Ivancic, L., Steel, Z., Creamer, M., Teesson, M., Bryant, R., McFarlane, A.C., Mills, K.L. and Slade, T., 2011. Lifetime prevalence of gender-based violence in women and the relationship with mental disorders and psychosocial function. ''Jama'', ''306''(5), pp.513-521.

Vancouver&lt;/ref&gt;

==== Ukuzikhipha hlangana nabantu nokulinga ukuzikhunga ====
Omunye umuntu nangabe ubanjwe yinturhu yobulili ugcina sele azikhipha hlangana ngabantu ngombana agcina sele anganakho [[ukuzithemba]] abane ngathi abantu bayamhleka ngesimo sakhe. Ubona ngathi abantu bahleba ngayo nofana ngathi bayamahlulela. Lokho kugcina kumenza bona abalekele ukuhlangana ngabantu ahlale azivalele ngendlini. Ngesinye isikhathi umuntu angagcina sele angasasiboni usidingo sokuthi aragele phambili aphile nakukuthi uzokuphila ngenturhu ngamalanga. Ugcina sele abona ukuthi kungcono bona athathe ipilo yakhe ukuze aziphumuze enturhwini aphila ngayo ngamalanga ekhaya.

=== Iindlela yokulwisana nenturhu yobulili ===

==== Ukufundisa ngobumbi benturhu yokubulili ====
Ukulwisana nenturhu yobulili kufanele abantu bafundiswe ngobumbi benurhu yobulili. Lokhu kungenziwa khulu khulu eneenkundleni zokuthintana ngombana kukulaho abantu baphila babelana khona ngelwazi baveze khona [[imicabango]] yabo Kanye nemibono&lt;ref&gt;Olaitan, Z.M., 2024. Using digital technology to address gender-based violence in South Africa. In ''African women in the fourth industrial revolution'' (pp. 226-240). Routledge.&lt;/ref&gt;.

==== Ukurhelebha labo abanza isenzo lesi ngombana nabo bakhe bababongazimbi ====
Kufanalwe kusizwe labo bantu abahlukumeza abalingani babo ngesibanga sokuthi nabo bakhe bahlala endaweni lapho kuphilwa khona ngenturhu yobulili. Kufanele abatholelwe umuntu abazokucoca naye ukuze bakghone ukukhipha [[ubuhlungu]] ebakhe babuzwa ekubenza bona bagcine sele nabo babanga inturhu.&lt;ref&gt;Oparinde, K. and Matsha, R.M., 2021. Powerful discourse: Gender-based violence and counter-discourses in South Africa. ''Cogent Arts &amp; Humanities'', ''8''(1), p.1911035.&lt;/ref&gt;Inturhu yobulili kuyonto engakalungi emphakathini ngombaa yenza abantu wengubo bazizwe bangakavikeleki ebhodulukweni abahlala kilo. Labo bantu ababongazimbi besenzo lesi bagcina sele bazithola bagandelelelkile ngokomkhumbulo nofana bangasafuni ukuba hlangana nabantu.

== Iinkomba ==</text>
      <sha1>9ne21wo61j5xlpox6copldg976hwxyb</sha1>
    </revision>
  </page>
  <page>
    <title>Amazinyo</title>
    <ns>0</ns>
    <id>524</id>
    <revision>
      <id>2587</id>
      <timestamp>2025-03-26T08:44:00Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Amazinyo == '''Amazinyo''' amhlophe, ahlala ngaphakathi komlomo ngiwo enza bona umuntu akghone [[ukuluma]] izinto. Amazinyo womuntu nakapheleleko ama-32&lt;ref&gt;TOOTH | English meaning - Cambridge Dictionary&lt;/ref&gt;.  == Ukwakheka kwamazinyo == Amazinyo akhiwa yi- enameli ekulilarha elimhlophe eliqinileko elanza bona amazinyo angaboli nofana amotjheke. Bese kube ne-Dentin ekulilarha elithambileko elingaphakathi elakha izinyo ngokupheleleko. I-cementum yona lilarha elivala u...&quot;</comment>
      <origin>2587</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2031" sha1="rs3hjygg48qchf2kx2vzc34qtupqedw" xml:space="preserve">== Amazinyo ==
'''Amazinyo''' amhlophe, ahlala ngaphakathi komlomo ngiwo enza bona umuntu akghone [[ukuluma]] izinto. Amazinyo womuntu nakapheleleko ama-32&lt;ref&gt;TOOTH | English meaning - Cambridge Dictionary&lt;/ref&gt;.

== Ukwakheka kwamazinyo ==
Amazinyo akhiwa yi- enameli ekulilarha elimhlophe eliqinileko elanza bona amazinyo angaboli nofana amotjheke. Bese kube ne-Dentin ekulilarha elithambileko elingaphakathi elakha izinyo ngokupheleleko. I-cementum yona lilarha elivala umrabho wezinyo bese lirhelebhe ukulisekela ethambeni elimbane nala. Kube ne-pulp ekungiyo engaphakathi khulu ezinyweni.Yona iphethe amanevu nemithambo yeengazi&lt;ref&gt;Zimmerman, B., Shumway, K.R. and Jenzer, A.C., 2019. Physiology, tooth.&lt;/ref&gt;.

== Umsebenzi wamazinyo ==
Amazinyo umuntu uwasebenzisela ukuluma nokuhlafunya izinto lezo azidlako. Amazinyo enza lokho ukuze umuntu akghone ukugwinya nokuthi ukudla kukhone ukugayeka emathumbini. Okhunye godu kukuthi amazinyo enza bona umuntu akghone ukukhuluma lokha nakunento afuna ukuyikhuluma. Amanye amagama akaphimiseki lula lokha nawunganawo amazinyo, nofana angeze wazwakala bona uthini nawuwakhulumako. [[Amazinyo]] enza bona ukghone ukuba muhle lokha nawuhlekako  begodu uhleke ngokuzithemba.

== Ukuqatheka kokutlhogomela amazinyo ==
Kuqakathekile ukutlhogomela amazinyo ngombana lokho kuzokuvikela bona amazinyo angabi nomgodi ngaphakathi nokuthi amazinyo angaboli&lt;ref&gt;Heng, C.C., 2016. Tooth decay is the most prevalent disease. ''Federal Practitioner'', ''33''(10), p.31.&lt;/ref&gt;. Kufanale umuntu ahlanze amazinyo cobe lokha nakaceda Ukudla ukuze ahlale ahlanzekile. Umuntu lokha nakabona bonyana unomraro wamazinyo kufuze bona avakatjhele kudorhodere wamazinyo bona amrhelebhe ukuze akwazi ukuthi abe nazinyo anepilo.

== Isiphetho ==
Amazinyo kuyinto kufanele anakelelwe ngombana arhelebha umuntu bona akghone ukudla, ukuhlafunyana kade nokuzithemba. Umuntu kufuze ahlale atlhogomela amazinyo wakhe ngokuthi awa bhrashe, begodu atlubhe nangezinto zokuhlalnza amazinyo khona azokuhlala ahlanzekile.</text>
      <sha1>rs3hjygg48qchf2kx2vzc34qtupqedw</sha1>
    </revision>
    <revision>
      <id>2588</id>
      <parentid>2587</parentid>
      <timestamp>2025-03-26T08:47:15Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2588</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2156" sha1="df2ob13cvyfax1fonbsz67ssxzvdxny" xml:space="preserve">== Amazinyo ==
'''Amazinyo''' amhlophe, ahlala ngaphakathi komlomo ngiwo enza bona umuntu akghone [[ukuluma]] izinto. Amazinyo womuntu nakapheleleko ama-32&lt;ref&gt;TOOTH | English meaning - Cambridge Dictionary&lt;/ref&gt;..Amazinyo abangaphasi nangaphezulu ngaphakathi komlomo.

== Ukwakheka kwamazinyo ==
Amazinyo akhiwa yi- enameli ekulilarha elimhlophe eliqinileko elanza bona amazinyo angaboli nofana amotjheke. Bese kube ne-Dentin ekulilarha elithambileko elingaphakathi elakha izinyo ngokupheleleko. I-cementum yona lilarha elivala umrabho wezinyo bese lirhelebhe ukulisekela ethambeni elimbane nala. Kube ne-pulp ekungiyo engaphakathi khulu ezinyweni.Yona iphethe amanevu nemithambo yeengazi&lt;ref&gt;Zimmerman, B., Shumway, K.R. and Jenzer, A.C., 2019. Physiology, tooth.&lt;/ref&gt;.

== Umsebenzi wamazinyo ==
Amazinyo umuntu uwasebenzisela ukuluma nokuhlafunya izinto lezo azidlako. Amazinyo enza lokho ukuze umuntu akghone ukugwinya nokuthi ukudla kukhone ukugayeka emathumbini. Okhunye godu kukuthi amazinyo enza bona umuntu akghone ukukhuluma lokha nakunento afuna ukuyikhuluma. Amanye amagama akaphimiseki lula lokha nawunganawo amazinyo, nofana angeze wazwakala bona uthini nawuwakhulumako. [[Amazinyo]] enza bona ukghone ukuba muhle lokha nawuhlekako  begodu uhleke ngokuzithemba&lt;ref&gt;Teeth - Structure, Anatomy, Function, Diagram, Significance&lt;/ref&gt;.

== Ukuqatheka kokutlhogomela amazinyo ==
Kuqakathekile ukutlhogomela amazinyo ngombana lokho kuzokuvikela bona amazinyo angabi nomgodi ngaphakathi nokuthi amazinyo angaboli&lt;ref&gt;Heng, C.C., 2016. Tooth decay is the most prevalent disease. ''Federal Practitioner'', ''33''(10), p.31.&lt;/ref&gt;. Kufanale umuntu ahlanze amazinyo cobe lokha nakaceda Ukudla ukuze ahlale ahlanzekile. Umuntu lokha nakabona bonyana unomraro wamazinyo kufuze bona avakatjhele kudorhodere wamazinyo bona amrhelebhe ukuze akwazi ukuthi abe nazinyo anepilo.

== Isiphetho ==
Amazinyo kuyinto kufanele anakelelwe ngombana arhelebha umuntu bona akghone ukudla, ukuhlafunyana kade nokuzithemba. Umuntu kufuze ahlale atlhogomela amazinyo wakhe ngokuthi awa bhrashe, begodu atlubhe nangezinto zokuhlalnza amazinyo khona azokuhlala ahlanzekile.</text>
      <sha1>df2ob13cvyfax1fonbsz67ssxzvdxny</sha1>
    </revision>
    <revision>
      <id>3416</id>
      <parentid>2588</parentid>
      <timestamp>2025-07-12T13:52:05Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3416</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2254" sha1="5ssewd4apy3wfrhj1by03h5kvwlnz3y" xml:space="preserve">'''Amazinyo''' amhlophe, ahlala ngaphakathi komlomo ngiwo enza bona umuntu akghone ukuluma izinto. Amazinyo womuntu nakapheleleko ama-32.&lt;ref&gt;TOOTH | English meaning - Cambridge Dictionary&lt;/ref&gt;Amazinyo abangaphasi nangaphezulu ngaphakathi komlomo. [[Umlomo]] ukghona ukwamukela ukudla bese amazinyo agaye ukudla lokho kughone ukwehla emphinjeni umuntu angarhameki.

=== Ukwakheka kwamazinyo ===
Amazinyo akhiwa yi- enameli ekulilarha elimhlophe eliqinileko elanza bona amazinyo angaboli nofana amotjheke. Bese kube ne-''Dentin'' ekulilarha elithambileko elingaphakathi elakha izinyo ngokupheleleko. I-c''ementum'' yona lilarha elivala umrabho wezinyo bese lirhelebhe ukulisekela ethambeni elimbane nala. Kube ne-''pulp'' ekungiyo engaphakathi khulu ezinyweni.Yona iphethe amanevu nemithambo yeengazi.&lt;ref&gt;Zimmerman, B., Shumway, K.R. and Jenzer, A.C., 2019. Physiology, tooth.&lt;/ref&gt;

=== Umsebenzi wamazinyo ===
Amazinyo umuntu uwasebenzisela ukuluma nokuhlafunya izinto lezo azidlako. Amazinyo enza lokho ukuze umuntu akghone ukugwinya nokuthi ukudla kukhone ukugayeka emathumbini. Okhunye godu kukuthi amazinyo enza bona umuntu akghone ukukhuluma lokha nakunento afuna ukuyikhuluma. Amanye amagama akaphimiseki lula lokha nawunganawo amazinyo, nofana angeze wazwakala bona uthini nawuwakhulumako. Amazinyo enza bona ukghone ukuba muhle lokha nawuhlekako  begodu uhleke ngokuzithemba.&lt;ref&gt;Teeth - Structure, Anatomy, Function, Diagram, Significance&lt;/ref&gt;

=== Ukutlhogomela amazinyo ===
Kuqakathekile ukutlhogomela amazinyo ngombana lokho kuzokuvikela bona amazinyo angabi nomgodi ngaphakathi nokuthi amazinyo angaboli&lt;ref&gt;Heng, C.C., 2016. Tooth decay is the most prevalent disease. ''Federal Practitioner'', ''33''(10), p.31.&lt;/ref&gt;. Kufanale umuntu ahlanze amazinyo cobe lokha nakaceda Ukudla ukuze ahlale ahlanzekile. Umuntu lokha nakabona bonyana unomraro wamazinyo kufuze bona avakatjhele kudorhodere wamazinyo bona amrhelebhe ukuze akwazi ukuthi abe nazinyo anepilo. Amazinyo kuyinto kufanele anakelelwe ngombana arhelebha umuntu bona akghone ukudla, ukuhlafunyana kade nokuzithemba. Umuntu kufuze ahlale atlhogomela amazinyo wakhe ngokuthi awa bhrashe, begodu atlubhe nangezinto zokuhlalnza amazinyo khona azokuhlala ahlanzekile.

== Iinkomba ==</text>
      <sha1>5ssewd4apy3wfrhj1by03h5kvwlnz3y</sha1>
    </revision>
    <revision>
      <id>3417</id>
      <parentid>3416</parentid>
      <timestamp>2025-07-12T13:53:09Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3417</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2328" sha1="163m1e8ovizjzayh3s0uns3nl59q58e" xml:space="preserve">[[Isimumathi:Teenage girl with gap teeth and dimples.jpg|thumb|Amazinyo]]
'''Amazinyo''' amhlophe, ahlala ngaphakathi komlomo ngiwo enza bona umuntu akghone ukuluma izinto. Amazinyo womuntu nakapheleleko ama-32.&lt;ref&gt;TOOTH | English meaning - Cambridge Dictionary&lt;/ref&gt;Amazinyo abangaphasi nangaphezulu ngaphakathi komlomo. [[Umlomo]] ukghona ukwamukela ukudla bese amazinyo agaye ukudla lokho kughone ukwehla emphinjeni umuntu angarhameki.

=== Ukwakheka kwamazinyo ===
Amazinyo akhiwa yi- enameli ekulilarha elimhlophe eliqinileko elanza bona amazinyo angaboli nofana amotjheke. Bese kube ne-''Dentin'' ekulilarha elithambileko elingaphakathi elakha izinyo ngokupheleleko. I-c''ementum'' yona lilarha elivala umrabho wezinyo bese lirhelebhe ukulisekela ethambeni elimbane nala. Kube ne-''pulp'' ekungiyo engaphakathi khulu ezinyweni.Yona iphethe amanevu nemithambo yeengazi.&lt;ref&gt;Zimmerman, B., Shumway, K.R. and Jenzer, A.C., 2019. Physiology, tooth.&lt;/ref&gt;

=== Umsebenzi wamazinyo ===
Amazinyo umuntu uwasebenzisela ukuluma nokuhlafunya izinto lezo azidlako. Amazinyo enza lokho ukuze umuntu akghone ukugwinya nokuthi ukudla kukhone ukugayeka emathumbini. Okhunye godu kukuthi amazinyo enza bona umuntu akghone ukukhuluma lokha nakunento afuna ukuyikhuluma. Amanye amagama akaphimiseki lula lokha nawunganawo amazinyo, nofana angeze wazwakala bona uthini nawuwakhulumako. Amazinyo enza bona ukghone ukuba muhle lokha nawuhlekako  begodu uhleke ngokuzithemba.&lt;ref&gt;Teeth - Structure, Anatomy, Function, Diagram, Significance&lt;/ref&gt;

=== Ukutlhogomela amazinyo ===
Kuqakathekile ukutlhogomela amazinyo ngombana lokho kuzokuvikela bona amazinyo angabi nomgodi ngaphakathi nokuthi amazinyo angaboli&lt;ref&gt;Heng, C.C., 2016. Tooth decay is the most prevalent disease. ''Federal Practitioner'', ''33''(10), p.31.&lt;/ref&gt;. Kufanale umuntu ahlanze amazinyo cobe lokha nakaceda Ukudla ukuze ahlale ahlanzekile. Umuntu lokha nakabona bonyana unomraro wamazinyo kufuze bona avakatjhele kudorhodere wamazinyo bona amrhelebhe ukuze akwazi ukuthi abe nazinyo anepilo. Amazinyo kuyinto kufanele anakelelwe ngombana arhelebha umuntu bona akghone ukudla, ukuhlafunyana kade nokuzithemba. Umuntu kufuze ahlale atlhogomela amazinyo wakhe ngokuthi awa bhrashe, begodu atlubhe nangezinto zokuhlalnza amazinyo khona azokuhlala ahlanzekile.

== Iinkomba ==</text>
      <sha1>163m1e8ovizjzayh3s0uns3nl59q58e</sha1>
    </revision>
    <revision>
      <id>3448</id>
      <parentid>3417</parentid>
      <timestamp>2025-07-15T14:57:27Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3448</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2710" sha1="cipdtwrro10sbyj364ggn7s0rftnfj3" xml:space="preserve">[[Isimumathi:Teenage girl with gap teeth and dimples.jpg|thumb|Amazinyo]]
'''Amazinyo''' amhlophe, ahlala ngaphakathi komlomo ngiwo enza bona umuntu akghone ukuluma izinto. Amazinyo womuntu nakapheleleko ama-32.&lt;ref&gt;TOOTH | English meaning - Cambridge Dictionary&lt;/ref&gt;Amazinyo abangaphasi nangaphezulu ngaphakathi komlomo. [[Umlomo]] ukghona ukwamukela ukudla bese amazinyo agaye ukudla lokho kughone ukwehla emphinjeni umuntu angarhameki. Amazinyo zizinto eziqinileko ngemlomeni ezenziwe nge ''calcium''. Amazinyo ayingcenye yerherho lokugaya Ukudla. Anamathele phezulu kwensini begodu ayahluka ngokubumbeka, nangokusebenza. Kuna manzinyo wangaphambili asebenza ukuluma nokurathula, bese kube namazinyo wehlangothini ahlabako wowna  ngewokudabula Ukudla, kwalowo bese kube namazinyo wemhlathinini adage wokugaya Ukudla.

=== Ukwakheka kwamazinyo ===
Amazinyo akhiwa yi- enameli ekulilarha elimhlophe eliqinileko elanza bona amazinyo angaboli nofana amotjheke. Bese kube ne-''Dentin'' ekulilarha elithambileko elingaphakathi elakha izinyo ngokupheleleko. I-c''ementum'' yona lilarha elivala umrabho wezinyo bese lirhelebhe ukulisekela ethambeni elimbane nala. Kube ne-''pulp'' ekungiyo engaphakathi khulu ezinyweni.Yona iphethe amanevu nemithambo yeengazi.&lt;ref&gt;Zimmerman, B., Shumway, K.R. and Jenzer, A.C., 2019. Physiology, tooth.&lt;/ref&gt;

=== Umsebenzi wamazinyo ===
Amazinyo umuntu uwasebenzisela ukuluma nokuhlafunya izinto lezo azidlako. Amazinyo enza lokho ukuze umuntu akghone ukugwinya nokuthi ukudla kukhone ukugayeka emathumbini. Okhunye godu kukuthi amazinyo enza bona umuntu akghone ukukhuluma lokha nakunento afuna ukuyikhuluma. Amanye amagama akaphimiseki lula lokha nawunganawo amazinyo, nofana angeze wazwakala bona uthini nawuwakhulumako. Amazinyo enza bona ukghone ukuba muhle lokha nawuhlekako  begodu uhleke ngokuzithemba.&lt;ref&gt;Teeth - Structure, Anatomy, Function, Diagram, Significance&lt;/ref&gt;

=== Ukutlhogomela amazinyo ===
Kuqakathekile ukutlhogomela amazinyo ngombana lokho kuzokuvikela bona amazinyo angabi nomgodi ngaphakathi nokuthi amazinyo angaboli&lt;ref&gt;Heng, C.C., 2016. Tooth decay is the most prevalent disease. ''Federal Practitioner'', ''33''(10), p.31.&lt;/ref&gt;. Kufanale umuntu ahlanze amazinyo cobe lokha nakaceda Ukudla ukuze ahlale ahlanzekile. Umuntu lokha nakabona bonyana unomraro wamazinyo kufuze bona avakatjhele kudorhodere wamazinyo bona amrhelebhe ukuze akwazi ukuthi abe nazinyo anepilo. Amazinyo kuyinto kufanele anakelelwe ngombana arhelebha umuntu bona akghone ukudla, ukuhlafunyana kade nokuzithemba. Umuntu kufuze ahlale atlhogomela amazinyo wakhe ngokuthi awa bhrashe, begodu atlubhe nangezinto zokuhlalnza amazinyo khona azokuhlala ahlanzekile.

== Iinkomba ==</text>
      <sha1>cipdtwrro10sbyj364ggn7s0rftnfj3</sha1>
    </revision>
    <revision>
      <id>3449</id>
      <parentid>3448</parentid>
      <timestamp>2025-07-15T15:00:15Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3449</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2807" sha1="jy57cseub1ceu39q3jxef4e1145ktlp" xml:space="preserve">[[Isimumathi:Teenage girl with gap teeth and dimples.jpg|thumb|Amazinyo]]
'''Amazinyo''' amhlophe, ahlala ngaphakathi komlomo ngiwo enza bona umuntu akghone ukuluma izinto. Amazinyo womuntu nakapheleleko ama-32.&lt;ref&gt;TOOTH | English meaning - Cambridge Dictionary&lt;/ref&gt;Amazinyo abangaphasi nangaphezulu ngaphakathi komlomo. [[Umlomo]] ukghona ukwamukela ukudla bese amazinyo agaye ukudla lokho kughone ukwehla emphinjeni umuntu angarhameki. Amazinyo zizinto eziqinileko ngemlomeni ezenziwe nge ''calcium''.&lt;ref&gt;Ungar, P., 2020. The Trouble with Teeth. ''Scientific American'', ''322''(4), pp.44-9.&lt;/ref&gt; Amazinyo ayingcenye yerherho lokugaya Ukudla. Anamathele phezulu kwensini begodu ayahluka ngokubumbeka, nangokusebenza. Kuna manzinyo wangaphambili asebenza ukuluma nokurathula, bese kube namazinyo wehlangothini ahlabako wowna  ngewokudabula Ukudla, kwalowo bese kube namazinyo wemhlathinini adage wokugaya Ukudla.

=== Ukwakheka kwamazinyo ===
Amazinyo akhiwa yi- enameli ekulilarha elimhlophe eliqinileko elanza bona amazinyo angaboli nofana amotjheke. Bese kube ne-''Dentin'' ekulilarha elithambileko elingaphakathi elakha izinyo ngokupheleleko. I-c''ementum'' yona lilarha elivala umrabho wezinyo bese lirhelebhe ukulisekela ethambeni elimbane nala. Kube ne-''pulp'' ekungiyo engaphakathi khulu ezinyweni.Yona iphethe amanevu nemithambo yeengazi.&lt;ref&gt;Zimmerman, B., Shumway, K.R. and Jenzer, A.C., 2019. Physiology, tooth.&lt;/ref&gt;

=== Umsebenzi wamazinyo ===
Amazinyo umuntu uwasebenzisela ukuluma nokuhlafunya izinto lezo azidlako. Amazinyo enza lokho ukuze umuntu akghone ukugwinya nokuthi ukudla kukhone ukugayeka emathumbini. Okhunye godu kukuthi amazinyo enza bona umuntu akghone ukukhuluma lokha nakunento afuna ukuyikhuluma. Amanye amagama akaphimiseki lula lokha nawunganawo amazinyo, nofana angeze wazwakala bona uthini nawuwakhulumako. Amazinyo enza bona ukghone ukuba muhle lokha nawuhlekako  begodu uhleke ngokuzithemba.&lt;ref&gt;Teeth - Structure, Anatomy, Function, Diagram, Significance&lt;/ref&gt;

=== Ukutlhogomela amazinyo ===
Kuqakathekile ukutlhogomela amazinyo ngombana lokho kuzokuvikela bona amazinyo angabi nomgodi ngaphakathi nokuthi amazinyo angaboli&lt;ref&gt;Heng, C.C., 2016. Tooth decay is the most prevalent disease. ''Federal Practitioner'', ''33''(10), p.31.&lt;/ref&gt;. Kufanale umuntu ahlanze amazinyo cobe lokha nakaceda Ukudla ukuze ahlale ahlanzekile. Umuntu lokha nakabona bonyana unomraro wamazinyo kufuze bona avakatjhele kudorhodere wamazinyo bona amrhelebhe ukuze akwazi ukuthi abe nazinyo anepilo. Amazinyo kuyinto kufanele anakelelwe ngombana arhelebha umuntu bona akghone ukudla, ukuhlafunyana kade nokuzithemba. Umuntu kufuze ahlale atlhogomela amazinyo wakhe ngokuthi awa bhrashe, begodu atlubhe nangezinto zokuhlalnza amazinyo khona azokuhlala ahlanzekile.

== Iinkomba ==</text>
      <sha1>jy57cseub1ceu39q3jxef4e1145ktlp</sha1>
    </revision>
    <revision>
      <id>5944</id>
      <parentid>3449</parentid>
      <timestamp>2025-11-02T23:28:22Z</timestamp>
      <contributor>
        <username>Flame, not lame</username>
        <id>1100</id>
      </contributor>
      <comment>removing my picture</comment>
      <origin>5944</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2733" sha1="3xlqlwmuc9lg01zgf3jqioq0xtpbjk2" xml:space="preserve">'''Amazinyo''' amhlophe, ahlala ngaphakathi komlomo ngiwo enza bona umuntu akghone ukuluma izinto. Amazinyo womuntu nakapheleleko ama-32.&lt;ref&gt;TOOTH | English meaning - Cambridge Dictionary&lt;/ref&gt;Amazinyo abangaphasi nangaphezulu ngaphakathi komlomo. [[Umlomo]] ukghona ukwamukela ukudla bese amazinyo agaye ukudla lokho kughone ukwehla emphinjeni umuntu angarhameki. Amazinyo zizinto eziqinileko ngemlomeni ezenziwe nge ''calcium''.&lt;ref&gt;Ungar, P., 2020. The Trouble with Teeth. ''Scientific American'', ''322''(4), pp.44-9.&lt;/ref&gt; Amazinyo ayingcenye yerherho lokugaya Ukudla. Anamathele phezulu kwensini begodu ayahluka ngokubumbeka, nangokusebenza. Kuna manzinyo wangaphambili asebenza ukuluma nokurathula, bese kube namazinyo wehlangothini ahlabako wowna  ngewokudabula Ukudla, kwalowo bese kube namazinyo wemhlathinini adage wokugaya Ukudla.

=== Ukwakheka kwamazinyo ===
Amazinyo akhiwa yi- enameli ekulilarha elimhlophe eliqinileko elanza bona amazinyo angaboli nofana amotjheke. Bese kube ne-''Dentin'' ekulilarha elithambileko elingaphakathi elakha izinyo ngokupheleleko. I-c''ementum'' yona lilarha elivala umrabho wezinyo bese lirhelebhe ukulisekela ethambeni elimbane nala. Kube ne-''pulp'' ekungiyo engaphakathi khulu ezinyweni.Yona iphethe amanevu nemithambo yeengazi.&lt;ref&gt;Zimmerman, B., Shumway, K.R. and Jenzer, A.C., 2019. Physiology, tooth.&lt;/ref&gt;

=== Umsebenzi wamazinyo ===
Amazinyo umuntu uwasebenzisela ukuluma nokuhlafunya izinto lezo azidlako. Amazinyo enza lokho ukuze umuntu akghone ukugwinya nokuthi ukudla kukhone ukugayeka emathumbini. Okhunye godu kukuthi amazinyo enza bona umuntu akghone ukukhuluma lokha nakunento afuna ukuyikhuluma. Amanye amagama akaphimiseki lula lokha nawunganawo amazinyo, nofana angeze wazwakala bona uthini nawuwakhulumako. Amazinyo enza bona ukghone ukuba muhle lokha nawuhlekako  begodu uhleke ngokuzithemba.&lt;ref&gt;Teeth - Structure, Anatomy, Function, Diagram, Significance&lt;/ref&gt;

=== Ukutlhogomela amazinyo ===
Kuqakathekile ukutlhogomela amazinyo ngombana lokho kuzokuvikela bona amazinyo angabi nomgodi ngaphakathi nokuthi amazinyo angaboli&lt;ref&gt;Heng, C.C., 2016. Tooth decay is the most prevalent disease. ''Federal Practitioner'', ''33''(10), p.31.&lt;/ref&gt;. Kufanale umuntu ahlanze amazinyo cobe lokha nakaceda Ukudla ukuze ahlale ahlanzekile. Umuntu lokha nakabona bonyana unomraro wamazinyo kufuze bona avakatjhele kudorhodere wamazinyo bona amrhelebhe ukuze akwazi ukuthi abe nazinyo anepilo. Amazinyo kuyinto kufanele anakelelwe ngombana arhelebha umuntu bona akghone ukudla, ukuhlafunyana kade nokuzithemba. Umuntu kufuze ahlale atlhogomela amazinyo wakhe ngokuthi awa bhrashe, begodu atlubhe nangezinto zokuhlalnza amazinyo khona azokuhlala ahlanzekile.

== Iinkomba ==</text>
      <sha1>3xlqlwmuc9lg01zgf3jqioq0xtpbjk2</sha1>
    </revision>
  </page>
  <page>
    <title>Iqanda</title>
    <ns>0</ns>
    <id>525</id>
    <revision>
      <id>2591</id>
      <timestamp>2025-03-26T09:35:12Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot; '''Iqanda'''   kuyinto eyindulungu nofana i-ovali ebekelwa ziinyoni ezisikazi nofana ezinye iinlwana, kukhombisa bona sele zizokuba nabantwana&lt;ref&gt;EGG | English meaning - Cambridge Dictionary&lt;/ref&gt;. Abantwana beenlwana lezi bakhula ngeengaba ngaphakathi kweqanda bekufike lapho iqephe lelqanda ligamuka khona bese kuvele idzinyani nofana umntwana wesilwane leso.  == Ukwakhekha kweqanda ==  === 1. Iqephe lingaphandle === leqanda elivikela bona lokhu okungaphakathi kweqanda...&quot;</comment>
      <origin>2591</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1866" sha1="4d2551j43vzzsmw5yplcw2gwqdofwfk" xml:space="preserve">
'''Iqanda'''   kuyinto eyindulungu nofana i-ovali ebekelwa ziinyoni ezisikazi nofana ezinye iinlwana, kukhombisa bona sele zizokuba nabantwana&lt;ref&gt;EGG | English meaning - Cambridge Dictionary&lt;/ref&gt;. Abantwana beenlwana lezi bakhula ngeengaba ngaphakathi kweqanda bekufike lapho iqephe lelqanda ligamuka khona bese kuvele idzinyani nofana umntwana wesilwane leso.

== Ukwakhekha kweqanda ==

=== 1. Iqephe lingaphandle ===
leqanda elivikela bona lokhu okungaphakathi kweqanda kungakhubazeki bese kumotjheke. Esikhathini esinengi ingaphandle leqanda libanzotho nofana mhlophe ngokombala.

=== 2 Ubumhlophe beqanda ===
busebenza bonya buvikele iyogu qanda bese iyinikele nazakhamzimba. Ubumhlophe beqanda buthambile bunjengamazi adege aregako. Ubumhlophe lobu abuanwo amafutha amanengi.

=== 3. Ubuthumbu beqanda ===

=== 4. Iyogu ===
Siqephu seqanda  esisarulani ngombala. Sizele ngama fat begodu sinikela udzinyani elisakhulako izakha mzimba nokudla ukuze lokghone ukukhula  izele ngama protheni, amaminerali kanye namavithamini&lt;ref&gt;Odd Eggs, Double Yolks, No Yolks, etc.&lt;/ref&gt;.

== Umsebenzi weqanda ==
Iqanda lisebenza njengesibeletho ukuthwala isilwane nofana esilwane esikhulako esingakabelethwa bekufike isikhathi lapho sibelethwa khona. Iqanda lezinye iinlwana lisebenza njengesitjhebo. Isibonelo lokha ikukhu ibekelileko abantu bayakghona ukuthatha amaqanda lawa bayowadla nangabe ikukhu ayikathomi ukufukama. Abanye bayawasebenzisa amaqanda njesizeso sokwenza ubuso bona bube buhle bathathe ubumhlophe beqanda babuzese ebusweni njenge maskhi.iqanda liyasetjenziswa lokha nakubhagwako amakhekhe nofana ezinye izinto&lt;ref&gt;What Are The Functions of Eggs In Cooking and Baking?&lt;/ref&gt;.

== Isiphetho ==
Iqanda lukuthoma kwepilo yeenyoni nofana ezinye iinlwana, yeke iqanda libalulekile ngombana liletha ipilo eenlwaneni begodu liyakghona nokuba sitjhebo ebantwini.</text>
      <sha1>4d2551j43vzzsmw5yplcw2gwqdofwfk</sha1>
    </revision>
    <revision>
      <id>2592</id>
      <parentid>2591</parentid>
      <timestamp>2025-03-26T09:39:00Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2592</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2012" sha1="kgakg4vr64izufhiheiomnj0bb7sv4n" xml:space="preserve">
'''Iqanda'''   kuyinto eyindulungu nofana i-ovali ebekelwa ziinyoni ezisikazi nofana ezinye iinlwana, kukhombisa bona sele zizokuba nabantwana&lt;ref&gt;EGG | English meaning - Cambridge Dictionary&lt;/ref&gt;. Abantwana beenlwana lezi bakhula ngeengaba ngaphakathi kweqanda bekufike lapho iqephe lelqanda ligamuka khona bese kuvele idzinyani nofana umntwana wesilwane leso.

== Ukwakhekha kweqanda ==

=== 1. Iqephe lingaphandle ===
leqanda elivikela bona lokhu okungaphakathi kweqanda kungakhubazeki bese kumotjheke. Esikhathini esinengi ingaphandle leqanda libanzotho nofana mhlophe ngokombala.

=== 2 Ubumhlophe beqanda ===
busebenza bonya buvikele iyogu qanda bese iyinikele nazakhamzimba. Ubumhlophe beqanda buthambile bunjengamazi adege aregako. Ubumhlophe lobu abuanwo amafutha amanengi.

=== 3. Ubuthumbu beqanda ===

=== 4. Iyogu ===
Siqephu seqanda  esisarulani ngombala. Sizele ngama fat begodu sinikela udzinyani elisakhulako izakha mzimba nokudla ukuze lokghone ukukhula  izele ngama protheni, amaminerali kanye namavithamini&lt;ref&gt;Odd Eggs, Double Yolks, No Yolks, etc.&lt;/ref&gt;.

== Umsebenzi weqanda ==
Iqanda lisebenza njengesibeletho ukuthwala isilwane nofana esilwane esikhulako esingakabelethwa bekufike isikhathi lapho sibelethwa khona. Iqanda lezinye iinlwana lisebenza njengesitjhebo&lt;ref&gt;Yang, S.C. and Baldwin, R.E., 2017. Functional properties of eggs in foods. In ''Egg science and technology'' (pp. 405-463). CRC Press.&lt;/ref&gt;. Isibonelo lokha ikukhu ibekelileko abantu bayakghona ukuthatha amaqanda lawa bayowadla nangabe ikukhu ayikathomi ukufukama. Abanye bayawasebenzisa amaqanda njesizeso sokwenza ubuso bona bube buhle bathathe ubumhlophe beqanda babuzese ebusweni njenge maskhi.iqanda liyasetjenziswa lokha nakubhagwako amakhekhe nofana ezinye izinto&lt;ref&gt;What Are The Functions of Eggs In Cooking and Baking?&lt;/ref&gt;.

== Isiphetho ==
Iqanda lukuthoma kwepilo yeenyoni nofana ezinye iinlwana, yeke iqanda libalulekile ngombana liletha ipilo eenlwaneni begodu liyakghona nokuba sitjhebo ebantwini.</text>
      <sha1>kgakg4vr64izufhiheiomnj0bb7sv4n</sha1>
    </revision>
    <revision>
      <id>2667</id>
      <parentid>2592</parentid>
      <timestamp>2025-04-15T17:19:04Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2667</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2049" sha1="cys8jijssyhylytm0kbis26nx0lx3qs" xml:space="preserve">
'''Iqanda'''   kuyinto eyindulungu nofana i-ovali ebekelwa ziinyoni ezisikazi nofana ezinye iinlwana, kukhombisa bona sele zizokuba nabantwana&lt;ref&gt;EGG | English meaning - Cambridge Dictionary&lt;/ref&gt;. Abantwana beenlwana lezi bakhula ngeengaba ngaphakathi kweqanda bekufike lapho iqephe llqanda ligamuka khona bese kuvele idzinyani nofana umntwana wesilwane leso. Iqanda kuyinto ebekelwa z[[iinyoni]].

== Ukwakhekha kweqanda ==

=== 1. Iqephe lingaphandle ===
leqanda elivikela bona lokhu okungaphakathi kweqanda kungakhubazeki bese kumotjheke. Esikhathini esinengi ingaphandle leqanda libanzotho nofana mhlophe ngokombala.

=== 2 Ubumhlophe beqanda ===
busebenza bonya buvikele iyogu qanda bese iyinikele nazakhamzimba. Ubumhlophe beqanda buthambile bunjengamazi adege aregako. Ubumhlophe lobu abuanwo amafutha amanengi.

=== 3. Ubuthumbu beqanda ===

=== 4. Iyogu ===
Siqephu seqanda  esisarulani ngombala. Sizele ngama fat begodu sinikela udzinyani elisakhulako izakha mzimba nokudla ukuze lokghone ukukhula  izele ngama protheni, amaminerali kanye namavithamini&lt;ref&gt;Odd Eggs, Double Yolks, No Yolks, etc.&lt;/ref&gt;.

== Umsebenzi weqanda ==
Iqanda lisebenza njengesibeletho ukuthwala isilwane nofana esilwane esikhulako esingakabelethwa bekufike isikhathi lapho sibelethwa khona. Iqanda lezinye iinlwana lisebenza njengesitjhebo&lt;ref&gt;Yang, S.C. and Baldwin, R.E., 2017. Functional properties of eggs in foods. In ''Egg science and technology'' (pp. 405-463). CRC Press.&lt;/ref&gt;. Isibonelo lokha ikukhu ibekelileko abantu bayakghona ukuthatha amaqanda lawa bayowadla nangabe ikukhu ayikathomi ukufukama. Abanye bayawasebenzisa amaqanda njesizeso sokwenza ubuso bona bube buhle bathathe ubumhlophe beqanda babuzese ebusweni njenge maskhi.iqanda liyasetjenziswa lokha nakubhagwako amakhekhe nofana ezinye izinto&lt;ref&gt;What Are The Functions of Eggs In Cooking and Baking?&lt;/ref&gt;.

== Isiphetho ==
Iqanda lukuthoma kwepilo yeenyoni nofana ezinye iinlwana, yeke iqanda libalulekile ngombana liletha ipilo eenlwaneni begodu liyakghona nokuba sitjhebo ebantwini.</text>
      <sha1>cys8jijssyhylytm0kbis26nx0lx3qs</sha1>
    </revision>
    <revision>
      <id>5154</id>
      <parentid>2667</parentid>
      <timestamp>2025-08-13T17:27:26Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5154</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2059" sha1="0nu8uacpgtoktc2vltzfmzm8dwvus2c" xml:space="preserve">
'''Iqanda'''   kuyinto eyindulungu nofana i-ovali ebekelwa ziinyoni ezisikazi nofana ezinye iinlwana, kukhombisa bona sele zizokuba nabantwana&lt;ref&gt;EGG | English meaning - Cambridge Dictionary&lt;/ref&gt;. Abantwana beenlwana lezi bakhula ngeengaba ngaphakathi kweqanda bekufike lapho iqephe llqanda ligamuka khona bese kuvele idzinyani nofana umntwana wesilwane leso. Iqanda kuyinto ebekelwa z[[iinyoni]].

=== Ukwakhekha kweqanda ===

==== 1. Iqephe lingaphandle ====
leqanda elivikela bona lokhu okungaphakathi kweqanda kungakhubazeki bese kumotjheke. Esikhathini esinengi ingaphandle leqanda libanzotho nofana mhlophe ngokombala.

==== 2 Ubumhlophe beqanda ====
busebenza bonya buvikele iyogu qanda bese iyinikele nazakhamzimba. Ubumhlophe beqanda buthambile bunjengamazi adege aregako. Ubumhlophe lobu abuanwo amafutha amanengi.

==== 3. Ubuthumbu beqanda ====

==== 4. Iyogu ====
Siqephu seqanda  esisarulani ngombala. Sizele ngama fat begodu sinikela udzinyani elisakhulako izakha mzimba nokudla ukuze lokghone ukukhula  izele ngama protheni, amaminerali kanye namavithamini&lt;ref&gt;Odd Eggs, Double Yolks, No Yolks, etc.&lt;/ref&gt;.

=== Umsebenzi weqanda ===
Iqanda lisebenza njengesibeletho ukuthwala isilwane nofana esilwane esikhulako esingakabelethwa bekufike isikhathi lapho sibelethwa khona. Iqanda lezinye iinlwana lisebenza njengesitjhebo&lt;ref&gt;Yang, S.C. and Baldwin, R.E., 2017. Functional properties of eggs in foods. In ''Egg science and technology'' (pp. 405-463). CRC Press.&lt;/ref&gt;. Isibonelo lokha ikukhu ibekelileko abantu bayakghona ukuthatha amaqanda lawa bayowadla nangabe ikukhu ayikathomi ukufukama. Abanye bayawasebenzisa amaqanda njesizeso sokwenza ubuso bona bube buhle bathathe ubumhlophe beqanda babuzese ebusweni njenge maskhi.iqanda liyasetjenziswa lokha nakubhagwako amakhekhe nofana ezinye izinto&lt;ref&gt;What Are The Functions of Eggs In Cooking and Baking?&lt;/ref&gt;.Iqanda lukuthoma kwepilo yeenyoni nofana ezinye iinlwana, yeke iqanda libalulekile ngombana liletha ipilo eenlwaneni begodu liyakghona nokuba sitjhebo ebantwini.

== Iinkomba ==</text>
      <sha1>0nu8uacpgtoktc2vltzfmzm8dwvus2c</sha1>
    </revision>
    <revision>
      <id>5155</id>
      <parentid>5154</parentid>
      <timestamp>2025-08-13T17:28:28Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>5155</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2100" sha1="0gwwf1ct1lvuxon5uxfuq396kzld2ah" xml:space="preserve">
'''Iqanda'''   kuyinto eyindulungu nofana i-ovali ebekelwa ziinyoni ezisikazi nofana ezinye iinlwana, kukhombisa bona sele zizokuba nabantwana&lt;ref&gt;EGG | English meaning - Cambridge Dictionary&lt;/ref&gt;. Abantwana beenlwana lezi bakhula ngeengaba ngaphakathi kweqanda bekufike lapho iqephe llqanda ligamuka khona bese kuvele idzinyani nofana umntwana wesilwane leso. Iqanda kuyinto ebekelwa z[[iinyoni]].

=== Ukwakhekha kweqanda ===

==== 1. Iqephe lingaphandle ====
leqanda elivikela bona lokhu okungaphakathi kweqanda kungakhubazeki bese kumotjheke. Esikhathini esinengi ingaphandle leqanda libanzotho nofana mhlophe ngokombala.

==== 2 Ubumhlophe beqanda ====
busebenza bonya buvikele iyogu qanda bese iyinikele nazakhamzimba. Ubumhlophe beqanda buthambile bunjengamazi adege aregako. Ubumhlophe lobu abuanwo amafutha amanengi.

==== 3. Ubuthumbu beqanda ====

==== 4. Iyogu ====
Siqephu seqanda  esisarulani ngombala. Sizele ngama fat begodu sinikela udzinyani elisakhulako izakha mzimba nokudla ukuze lokghone ukukhula  izele ngama protheni, amaminerali kanye namavithamini&lt;ref&gt;Odd Eggs, Double Yolks, No Yolks, etc.&lt;/ref&gt;.

=== Umsebenzi weqanda ===
Iqanda lisebenza njengesibeletho ukuthwala isilwane nofana esilwane esikhulako esingakabelethwa bekufike isikhathi lapho sibelethwa khona. Iqanda lezinye iinlwana lisebenza njengesitjhebo&lt;ref&gt;Yang, S.C. and Baldwin, R.E., 2017. Functional properties of eggs in foods. In ''Egg science and technology'' (pp. 405-463). CRC Press.&lt;/ref&gt;. Isibonelo lokha ikukhu ibekelileko abantu bayakghona ukuthatha amaqanda lawa bayowadla nangabe ikukhu ayikathomi ukufukama. Abanye bayawasebenzisa amaqanda njesizeso sokwenza ubuso bona bube buhle bathathe ubumhlophe beqanda babuzese ebusweni njenge maskhi.iqanda liyasetjenziswa lokha nakubhagwako amakhekhe nofana ezinye izinto&lt;ref&gt;What Are The Functions of Eggs In Cooking and Baking?&lt;/ref&gt;.Iqanda lukuthoma kwepilo yeenyoni nofana ezinye iinlwana, yeke iqanda libalulekile ngombana liletha ipilo eenlwaneni begodu liyakghona nokuba sitjhebo ebantwini.

== Iinkomba ==
[[Category:iqanda]]
[[category:iinyoni]]</text>
      <sha1>0gwwf1ct1lvuxon5uxfuq396kzld2ah</sha1>
    </revision>
    <revision>
      <id>5166</id>
      <parentid>5155</parentid>
      <timestamp>2025-08-14T14:55:12Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5166</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2100" sha1="2p5l7zi6wmkvlb9phyxmgndzg76vdzu" xml:space="preserve">
'''Iqanda'''   kuyinto eyindulungu nofana i-ovali ebekelwa ziinyoni ezisikazi nofana ezinye iinlwana, kukhombisa bona sele zizokuba nabantwana.&lt;ref&gt;EGG | English meaning - Cambridge Dictionary&lt;/ref&gt; Abantwana beenlwana lezi bakhula ngeengaba ngaphakathi kweqanda bekufike lapho iqephe llqanda ligamuka khona bese kuvele idzinyani nofana umntwana wesilwane leso. Iqanda kuyinto ebekelwa z[[iinyoni]].

=== Ukwakhekha kweqanda ===

==== 1. Iqephe lingaphandle ====
leqanda elivikela bona lokhu okungaphakathi kweqanda kungakhubazeki bese kumotjheke. Esikhathini esinengi ingaphandle leqanda libanzotho nofana mhlophe ngokombala.

==== 2 Ubumhlophe beqanda ====
busebenza bonya buvikele iyogu qanda bese iyinikele nazakhamzimba. Ubumhlophe beqanda buthambile bunjengamazi adege aregako. Ubumhlophe lobu abuanwo amafutha amanengi.

==== 3. Ubuthumbu beqanda ====

==== 4. Iyogu ====
Siqephu seqanda  esisarulani ngombala. Sizele ngama fat begodu sinikela udzinyani elisakhulako izakha mzimba nokudla ukuze lokghone ukukhula  izele ngama protheni, amaminerali kanye namavithamini.&lt;ref&gt;Odd Eggs, Double Yolks, No Yolks, etc.&lt;/ref&gt;

=== Umsebenzi weqanda ===
Iqanda lisebenza njengesibeletho ukuthwala isilwane nofana esilwane esikhulako esingakabelethwa bekufike isikhathi lapho sibelethwa khona. Iqanda lezinye iinlwana lisebenza njengesitjhebo.&lt;ref&gt;Yang, S.C. and Baldwin, R.E., 2017. Functional properties of eggs in foods. In ''Egg science and technology'' (pp. 405-463). CRC Press.&lt;/ref&gt; Isibonelo lokha ikukhu ibekelileko abantu bayakghona ukuthatha amaqanda lawa bayowadla nangabe ikukhu ayikathomi ukufukama. Abanye bayawasebenzisa amaqanda njesizeso sokwenza ubuso bona bube buhle bathathe ubumhlophe beqanda babuzese ebusweni njenge maskhi.iqanda liyasetjenziswa lokha nakubhagwako amakhekhe nofana ezinye izinto.&lt;ref&gt;What Are The Functions of Eggs In Cooking and Baking?&lt;/ref&gt;Iqanda lukuthoma kwepilo yeenyoni nofana ezinye iinlwana, yeke iqanda libalulekile ngombana liletha ipilo eenlwaneni begodu liyakghona nokuba sitjhebo ebantwini.

== Iinkomba ==
[[Category:iqanda]]
[[category:iinyoni]]</text>
      <sha1>2p5l7zi6wmkvlb9phyxmgndzg76vdzu</sha1>
    </revision>
    <revision>
      <id>5167</id>
      <parentid>5166</parentid>
      <timestamp>2025-08-14T14:56:47Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5167</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2157" sha1="2lyf2jk6f9efk4bitr3swcrn8esvahp" xml:space="preserve">
'''Iqanda'''   kuyinto eyindulungu nofana i-ovali ebekelwa ziinyoni ezisikazi nofana ezinye iinlwana, kukhombisa bona sele zizokuba nabantwana.&lt;ref&gt;EGG | English meaning - Cambridge Dictionary&lt;/ref&gt; Abantwana beenlwana lezi bakhula ngeengaba ngaphakathi kweqanda bekufike lapho iqephe llqanda ligamuka khona bese kuvele idzinyani nofana umntwana wesilwane leso. Iqanda kuyinto ebekelwa z[[iinyoni]].

=== Ukwakhekha kweqanda ===

==== 1. Iqephe lingaphandle ====
[[Isimumathi:Eggs in basket 2020 G1.jpg|thumb|Amaqanda]]
leqanda elivikela bona lokhu okungaphakathi kweqanda kungakhubazeki bese kumotjheke. Esikhathini esinengi ingaphandle leqanda libanzotho nofana mhlophe ngokombala.

==== 2 Ubumhlophe beqanda ====
busebenza bonya buvikele iyogu qanda bese iyinikele nazakhamzimba. Ubumhlophe beqanda buthambile bunjengamazi adege aregako. Ubumhlophe lobu abuanwo amafutha amanengi.

==== 3. Ubuthumbu beqanda ====

==== 4. Iyogu ====
Siqephu seqanda  esisarulani ngombala. Sizele ngama fat begodu sinikela udzinyani elisakhulako izakha mzimba nokudla ukuze lokghone ukukhula  izele ngama protheni, amaminerali kanye namavithamini.&lt;ref&gt;Odd Eggs, Double Yolks, No Yolks, etc.&lt;/ref&gt;

=== Umsebenzi weqanda ===
Iqanda lisebenza njengesibeletho ukuthwala isilwane nofana esilwane esikhulako esingakabelethwa bekufike isikhathi lapho sibelethwa khona. Iqanda lezinye iinlwana lisebenza njengesitjhebo.&lt;ref&gt;Yang, S.C. and Baldwin, R.E., 2017. Functional properties of eggs in foods. In ''Egg science and technology'' (pp. 405-463). CRC Press.&lt;/ref&gt; Isibonelo lokha ikukhu ibekelileko abantu bayakghona ukuthatha amaqanda lawa bayowadla nangabe ikukhu ayikathomi ukufukama. Abanye bayawasebenzisa amaqanda njesizeso sokwenza ubuso bona bube buhle bathathe ubumhlophe beqanda babuzese ebusweni njenge maskhi.iqanda liyasetjenziswa lokha nakubhagwako amakhekhe nofana ezinye izinto.&lt;ref&gt;What Are The Functions of Eggs In Cooking and Baking?&lt;/ref&gt;Iqanda lukuthoma kwepilo yeenyoni nofana ezinye iinlwana, yeke iqanda libalulekile ngombana liletha ipilo eenlwaneni begodu liyakghona nokuba sitjhebo ebantwini.

== Iinkomba ==
[[Category:iqanda]]
[[category:iinyoni]]</text>
      <sha1>2lyf2jk6f9efk4bitr3swcrn8esvahp</sha1>
    </revision>
  </page>
  <page>
    <title>Iindlebe</title>
    <ns>0</ns>
    <id>526</id>
    <revision>
      <id>2593</id>
      <timestamp>2025-03-26T09:57:37Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Ukugijima == '''Ukugijima''' kungeminye yemidlalo edlala eSewula Afrika. Ukuze umuntu akwazi ukugijima ibanga elide kufuze bona azibandule bekufike lapho sele azizwa khona ukuthi uyakghona ukukghodlhelela lokha nakagijimako&lt;ref&gt;Galloway, J., 2023. ''Cross-country running: The best training plans for peak performance in the 5K, 1500M, 2000M, and 10K''. Meyer &amp; Meyer Sport.&lt;/ref&gt;. Ukugijima kuyinto engenziwa nanoma kungubani. Esikathini esinengi abantu bagijima lokha na...&quot;</comment>
      <origin>2593</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2049" sha1="sj1t9jqih3rwnokh08y6bl2h8lr6lym" xml:space="preserve">== Ukugijima ==
'''Ukugijima''' kungeminye yemidlalo edlala eSewula Afrika. Ukuze umuntu akwazi ukugijima ibanga elide kufuze bona azibandule bekufike lapho sele azizwa khona ukuthi uyakghona ukukghodlhelela lokha nakagijimako&lt;ref&gt;Galloway, J., 2023. ''Cross-country running: The best training plans for peak performance in the 5K, 1500M, 2000M, and 10K''. Meyer &amp; Meyer Sport.&lt;/ref&gt;. Ukugijima kuyinto engenziwa nanoma kungubani. Esikathini esinengi abantu bagijima lokha nabanjarhileko isibonelo umuntu angagijima nakatjhiywa yibhesi. 

== Ubuhle bokokugijima ==

=== 1. Ukuba nepilo ===
Umuntu ogikimako umzimba kwakhe uba nepilo, ngombana iingazi zakhe zikghona ukukhamba kuhle emzimbeni ngaphandle kokuthikamezeka. Ukugijima kwenza bona nokuthi ihliziyo ibethe kuhle begodu ingabi semafutheni. Umuntu ogijimako akusilula bona abe nomzimba omkhulu nofana asahlwe magulu emzimbeni. Imisipha iyaluleka lokha nawugijimako bese ikghona ukugobeka ngendlela efuna ngayo&lt;ref&gt;15 Benefits of Running That Will Make You Want to Log Some Miles | SELF&lt;/ref&gt;. 

=== 2. Ukukghodlhelela ===
Lokha nawuzijayeza ukugijima umzimba wakho ugcina sele uba nekghono lokukghodlhelela ungapheli ummoya lokha nawugijimako ugcine sele ujama. Umzimba uyajwayela ukuthi wena ngamalanga uhlala ugijima. Lokho kuyinto ehle khulu ngombana umzimba wakho ubanepilo&lt;ref&gt;Fitzgerald, M., 2014. ''80/20 running: run stronger and race faster by training slower''. Penguin.&lt;/ref&gt;&lt;ref&gt;Greenfield, B., 2014. ''Beyond training: Mastering endurance, health &amp; life''. Simon and Schuster.&lt;/ref&gt;. 

=== 3. Ukuphumelela kwezemidlalo ===
Lokha nawukwazi ukugijima ibanga elide ungadinwa ungakghona ukugcina ungenela amaphaliswano wokugijima bese uthumbe ngombana uzabe usebenzisa ikghono lakho lokugijima. Lokhu kutjho bona ungagcina sele wenza imali ngokwazi ukugijima kwaphela. 

== Isiphetho ==
Ukugijima kuyinto enepilo abantu kufanele bazifundise ukugijima njengendlela yokuzithabulula, Lokhu kuzokqenza bona umzimba womuntu ubenepilo, akghone ukukghodlhelela angaphelelwa mummoya msinya.</text>
      <sha1>sj1t9jqih3rwnokh08y6bl2h8lr6lym</sha1>
    </revision>
    <revision>
      <id>2594</id>
      <parentid>2593</parentid>
      <timestamp>2025-03-26T10:00:51Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2594</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2057" sha1="gj6edjas7qh11hrrk4pnkr0vvmql9dj" xml:space="preserve">== Ukugijima ==
'''Ukugijima''' kungeminye yemidlalo edlala eSewula Afrika. Ukuze umuntu akwazi ukugijima ibanga elide kufuze bona azibandule bekufike lapho sele azizwa khona ukuthi uyakghona ukukghodlhelela lokha nakagijimako&lt;ref&gt;Galloway, J., 2023. ''Cross-country running: The best training plans for peak performance in the 5K, 1500M, 2000M, and 10K''. Meyer &amp; Meyer Sport.&lt;/ref&gt;. Ukugijima kuyinto engenziwa nanoma kungubani. Esikathini esinengi abantu bagijima lokha nabanjarhileko isibonelo umuntu angagijima nakatjhiywa yibhesi. 

== Ubuhle bokokugijima ==

=== 1. Ukuba nepilo ===
Umuntu ogikimako umzimba kwakhe uba nepilo, ngombana iingazi zakhe zikghona ukukhamba kuhle emzimbeni ngaphandle kokuthikamezeka. Ukugijima kwenza bona nokuthi [[ihliziyo]] ibethe kuhle begodu ingabi semafutheni. Umuntu ogijimako akusilula bona abe nomzimba omkhulu nofana asahlwe magulu emzimbeni. [[Imisipha]] iyaluleka lokha nawugijimako bese ikghona ukugobeka ngendlela efuna ngayo&lt;ref&gt;15 Benefits of Running That Will Make You Want to Log Some Miles | SELF&lt;/ref&gt;. 

=== 2. Ukukghodlhelela ===
Lokha nawuzijayeza ukugijima umzimba wakho ugcina sele uba nekghono lokukghodlhelela ungapheli ummoya lokha nawugijimako ugcine sele ujama. Umzimba uyajwayela ukuthi wena ngamalanga uhlala ugijima. Lokho kuyinto ehle khulu ngombana umzimba wakho ubanepilo&lt;ref&gt;Fitzgerald, M., 2014. ''80/20 running: run stronger and race faster by training slower''. Penguin.&lt;/ref&gt;&lt;ref&gt;Greenfield, B., 2014. ''Beyond training: Mastering endurance, health &amp; life''. Simon and Schuster.&lt;/ref&gt;. 

=== 3. Ukuphumelela kwezemidlalo ===
Lokha nawukwazi ukugijima ibanga elide ungadinwa ungakghona ukugcina ungenela amaphaliswano wokugijima bese uthumbe ngombana uzabe usebenzisa ikghono lakho lokugijima. Lokhu kutjho bona ungagcina sele wenza imali ngokwazi ukugijima kwaphela. 

== Isiphetho ==
Ukugijima kuyinto enepilo abantu kufanele bazifundise ukugijima njengendlela yokuzithabulula, Lokhu kuzokqenza bona umzimba womuntu ubenepilo, akghone ukukghodlhelela angaphelelwa mummoya msinya.</text>
      <sha1>gj6edjas7qh11hrrk4pnkr0vvmql9dj</sha1>
    </revision>
    <revision>
      <id>2595</id>
      <parentid>2594</parentid>
      <timestamp>2025-03-26T10:08:23Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2595</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="972" sha1="no16aao4l3y7oupqxd6bs5t79kz1ogk" xml:space="preserve">Indlebe sisitho somzimba esisehloko yomuntu emahlangothini womabili esisebenza ukuzwa. Woke umuntu uba neendlebe ezimbili ezwa ngazo ikulumo, umvumo namanye amatjhada&lt;ref&gt;EAR | English meaning - Cambridge Dictionary&lt;/ref&gt;.

Ukwakheka kwendlebe

Indlebe inesakhiwo sangaphandle nesangaphakathi.

Umsebenzi weendlebe

Iindlebe zisebenza ukwenza bona umuntu akghone ukuza itjhada elenzeka eduze naye nofane kude. Zithatha itjhada nofana umdumo umuntu awuzwako kubhoduluko lakhe bese zilise engcondweni lapho ingcono izokuhlathula khona bona yini umuntu ayizwako begodu kufanele ayiphendule bunjani. Zisiza umuntu bona akghone ukudzimelela lokha nakajamileko. Indlebe isebenza nokuthi umuntu akghone ukukhuluma ngombana lokha umuntu ufunda ukukhuluma ngokuthi ezwa kukhulunywa&lt;ref&gt;Human ear | Structure, Function, &amp; Parts | Britannica&lt;/ref&gt;.

Isiphetho.

Indlebe kusisitho esinqani somziba kodwana siqakathekile ukwenza ukuthi umuntu akghone ukuzwa nokuthi akghone ukukhuluma.</text>
      <sha1>no16aao4l3y7oupqxd6bs5t79kz1ogk</sha1>
    </revision>
    <revision>
      <id>2599</id>
      <parentid>2595</parentid>
      <timestamp>2025-03-26T10:38:42Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2599</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1729" sha1="1r2eadfwo872eurmo8vtczetxslr857" xml:space="preserve">'''Indlebe''' sisitho somzimba esisehloko yomuntu emahlangothini womabili esisebenza ukuzwa. Woke umuntu uba neendlebe ezimbili ezwa ngazo ikulumo, umvumo namanye amatjhada&lt;ref&gt;EAR | English meaning - Cambridge Dictionary&lt;/ref&gt;.

== Ukwakheka kwendlebe ==

=== Indlebe inesakhiwo sangaphandle nesangaphakathi. ===
Indlebe ihlukaniseke ngengaba esithathu kunendlebe yangaphandle, indlebe ephakathi kanye nendlebe yangaphakathi.

=== Indlebe yangaphandle ===
Ithatha umdumo umunntu awuzwako bese iwufakae ngemgodini wendleni bona umdumo loyo ungene ngaphakathi. umgodi weendlebe unenhluthu ezincani ezenza bona ezivikela bona iindlebe ingangenwa ziinsila namagcinakwana.

=== Indlebe ephakathi ===
le yindlebe encani enomgodi. Umgodi lo unanthambo amathathu abizwa bona ma-ossicles. Amathambi la ngiwo adlulisela umdumo esedromini yendlelbe ukuthi uye-endlebeni yangaphakathi

=== Indlebe yangaphakathi ===
indlebe yangaphakathi inesakhiwo esimazombe esneza bona umdumo omavabhretjhini utjhuguluke bese ube yisiginali yegezi ezokuya engcondweni.

=== Umsebenzi weendlebe ===
Iindlebe zisebenza ukwenza bona umuntu akghone ukuza itjhada elenzeka eduze naye nofane kude. Zithatha itjhada nofana umdumo umuntu awuzwako kubhoduluko lakhe bese zilise engcondweni lapho ingcono izokuhlathula khona bona yini umuntu ayizwako begodu kufanele ayiphendule bunjani. Zisiza umuntu bona akghone ukudzimelela lokha nakajamileko. Indlebe isebenza nokuthi umuntu akghone ukukhuluma ngombana lokha umuntu ufunda ukukhuluma ngokuthi ezwa kukhulunywa&lt;ref&gt;Human ear | Structure, Function, &amp; Parts | Britannica&lt;/ref&gt;.

Isiphetho.

Indlebe kusisitho esinqani somziba kodwana siqakathekile ukwenza ukuthi umuntu akghone ukuzwa nokuthi akghone ukukhuluma.</text>
      <sha1>1r2eadfwo872eurmo8vtczetxslr857</sha1>
    </revision>
    <revision>
      <id>5057</id>
      <parentid>2599</parentid>
      <timestamp>2025-08-07T18:06:09Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5057</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2232" sha1="ead1bxki8cz7hxdgbqhk7l0c5gjrdqj" xml:space="preserve">'''Indlebe''' sisitho somzimba esisehloko yomuntu emahlangothini womabili esisebenza ukuzwa. Woke umuntu uba neendlebe ezimbili ezwa ngazo ikulumo, umvumo namanye amatjhada&lt;ref&gt;EAR | English meaning - Cambridge Dictionary&lt;/ref&gt;.Indlebe kuyisitho somzimba esincani kodwana esenza umsebenzi umsebenzi aqakathekileko emzimbeni, ngombanaikghona ukwenza bona umuntu  akghone ukudzimela lokha nakajamileko begodu umuntu ukghona ukuthola ilwazi asebenzisa yona. Indlebe ikghona ukwenza umuntu bona akghone ukuphendula lokho atjelwe khona wakuzwa begodu ikghona ukuthi  zwe loke ihlobo lamatjhada enzekako begodu.

=== Ukwakheka kwendlebe ===

==== Indlebe inesakhiwo sangaphandle nesangaphakathi. ====
Indlebe ihlukaniseke ngengaba esithathu kunendlebe yangaphandle, indlebe ephakathi kanye nendlebe yangaphakathi.Ithatha umdumo umunntu awuzwako bese iwufakae ngemgodini wendleni bona umdumo loyo ungene ngaphakathi.&lt;ref&gt;[https://www.bing.com/videos/search?q=middle%2c+inner+and+outer+ear+anatomy&amp;&amp;view=detail&amp;mid=674857878D4784501B0D674857878D4784501B0D&amp;mmscn=mtsc&amp;aps=6&amp;FORM=VMSOVR Bing Videos]&lt;/ref&gt; umgodi weendlebe unenhluthu ezincani ezenza bona ezivikela bona iindlebe ingangenwa ziinsila namagcinakwana.Indlebe ephakathi, le yindlebe encani enomgodi. Umgodi lo unanthambo amathathu abizwa bona ma-ossicles. Amathambi la ngiwo adlulisela umdumo esedromini yendlelbe ukuthi uye-endlebeni yangaphakathiIndlebe yangaphakathi,indlebe yangaphakathi inesakhiwo esimazombe esneza bona umdumo omavabhretjhini utjhuguluke bese ube yisiginali yegezi ezokuya engcondweni.

=== Umsebenzi weendlebe ===
Iindlebe zisebenza ukwenza bona umuntu akghone ukuza itjhada elenzeka eduze naye nofane kude. Zithatha itjhada nofana umdumo umuntu awuzwako kubhoduluko lakhe bese zilise engcondweni lapho ingcono izokuhlathula khona bona yini umuntu ayizwako begodu kufanele ayiphendule bunjani. Zisiza umuntu bona akghone ukudzimelela lokha nakajamileko. Indlebe isebenza nokuthi umuntu akghone ukukhuluma ngombana lokha umuntu ufunda ukukhuluma ngokuthi ezwa kukhulunywa&lt;ref&gt;Human ear | Structure, Function, &amp; Parts | Britannica&lt;/ref&gt;.Indlebe kusisitho esinqani somziba kodwana siqakathekile ukwenza ukuthi umuntu akghone ukuzwa nokuthi akghone ukukhuluma.</text>
      <sha1>ead1bxki8cz7hxdgbqhk7l0c5gjrdqj</sha1>
    </revision>
    <revision>
      <id>5058</id>
      <parentid>5057</parentid>
      <timestamp>2025-08-07T18:06:59Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <comment>added a heading</comment>
      <origin>5058</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2248" sha1="kpbc801iwu7f9j84gqlf1wwm1b4juo9" xml:space="preserve">'''Indlebe''' sisitho somzimba esisehloko yomuntu emahlangothini womabili esisebenza ukuzwa. Woke umuntu uba neendlebe ezimbili ezwa ngazo ikulumo, umvumo namanye amatjhada&lt;ref&gt;EAR | English meaning - Cambridge Dictionary&lt;/ref&gt;.Indlebe kuyisitho somzimba esincani kodwana esenza umsebenzi umsebenzi aqakathekileko emzimbeni, ngombanaikghona ukwenza bona umuntu  akghone ukudzimela lokha nakajamileko begodu umuntu ukghona ukuthola ilwazi asebenzisa yona. Indlebe ikghona ukwenza umuntu bona akghone ukuphendula lokho atjelwe khona wakuzwa begodu ikghona ukuthi  zwe loke ihlobo lamatjhada enzekako begodu.

=== Ukwakheka kwendlebe ===

==== Indlebe inesakhiwo sangaphandle nesangaphakathi. ====
Indlebe ihlukaniseke ngengaba esithathu kunendlebe yangaphandle, indlebe ephakathi kanye nendlebe yangaphakathi.Ithatha umdumo umunntu awuzwako bese iwufakae ngemgodini wendleni bona umdumo loyo ungene ngaphakathi.&lt;ref&gt;[https://www.bing.com/videos/search?q=middle%2c+inner+and+outer+ear+anatomy&amp;&amp;view=detail&amp;mid=674857878D4784501B0D674857878D4784501B0D&amp;mmscn=mtsc&amp;aps=6&amp;FORM=VMSOVR Bing Videos]&lt;/ref&gt; umgodi weendlebe unenhluthu ezincani ezenza bona ezivikela bona iindlebe ingangenwa ziinsila namagcinakwana.Indlebe ephakathi, le yindlebe encani enomgodi. Umgodi lo unanthambo amathathu abizwa bona ma-ossicles. Amathambi la ngiwo adlulisela umdumo esedromini yendlelbe ukuthi uye-endlebeni yangaphakathiIndlebe yangaphakathi,indlebe yangaphakathi inesakhiwo esimazombe esneza bona umdumo omavabhretjhini utjhuguluke bese ube yisiginali yegezi ezokuya engcondweni.

=== Umsebenzi weendlebe ===
Iindlebe zisebenza ukwenza bona umuntu akghone ukuza itjhada elenzeka eduze naye nofane kude. Zithatha itjhada nofana umdumo umuntu awuzwako kubhoduluko lakhe bese zilise engcondweni lapho ingcono izokuhlathula khona bona yini umuntu ayizwako begodu kufanele ayiphendule bunjani. Zisiza umuntu bona akghone ukudzimelela lokha nakajamileko. Indlebe isebenza nokuthi umuntu akghone ukukhuluma ngombana lokha umuntu ufunda ukukhuluma ngokuthi ezwa kukhulunywa&lt;ref&gt;Human ear | Structure, Function, &amp; Parts | Britannica&lt;/ref&gt;.Indlebe kusisitho esinqani somziba kodwana siqakathekile ukwenza ukuthi umuntu akghone ukuzwa nokuthi akghone ukukhuluma.

== Iinkomba ==</text>
      <sha1>kpbc801iwu7f9j84gqlf1wwm1b4juo9</sha1>
    </revision>
    <revision>
      <id>5059</id>
      <parentid>5058</parentid>
      <timestamp>2025-08-07T18:08:10Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>5059</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2290" sha1="osn06b06zc4dyl49fri109x2i27t2xr" xml:space="preserve">'''Indlebe''' sisitho somzimba esisehloko yomuntu emahlangothini womabili esisebenza ukuzwa. Woke umuntu uba neendlebe ezimbili ezwa ngazo ikulumo, umvumo namanye amatjhada&lt;ref&gt;EAR | English meaning - Cambridge Dictionary&lt;/ref&gt;.Indlebe kuyisitho somzimba esincani kodwana esenza umsebenzi umsebenzi aqakathekileko emzimbeni, ngombanaikghona ukwenza bona umuntu  akghone ukudzimela lokha nakajamileko begodu umuntu ukghona ukuthola ilwazi asebenzisa yona. Indlebe ikghona ukwenza umuntu bona akghone ukuphendula lokho atjelwe khona wakuzwa begodu ikghona ukuthi  zwe loke ihlobo lamatjhada enzekako begodu.

=== Ukwakheka kwendlebe ===

==== Indlebe inesakhiwo sangaphandle nesangaphakathi. ====
Indlebe ihlukaniseke ngengaba esithathu kunendlebe yangaphandle, indlebe ephakathi kanye nendlebe yangaphakathi.Ithatha umdumo umunntu awuzwako bese iwufakae ngemgodini wendleni bona umdumo loyo ungene ngaphakathi.&lt;ref&gt;[https://www.bing.com/videos/search?q=middle%2c+inner+and+outer+ear+anatomy&amp;&amp;view=detail&amp;mid=674857878D4784501B0D674857878D4784501B0D&amp;mmscn=mtsc&amp;aps=6&amp;FORM=VMSOVR Bing Videos]&lt;/ref&gt; umgodi weendlebe unenhluthu ezincani ezenza bona ezivikela bona iindlebe ingangenwa ziinsila namagcinakwana.Indlebe ephakathi, le yindlebe encani enomgodi. Umgodi lo unanthambo amathathu abizwa bona ma-ossicles. Amathambi la ngiwo adlulisela umdumo esedromini yendlelbe ukuthi uye-endlebeni yangaphakathiIndlebe yangaphakathi,indlebe yangaphakathi inesakhiwo esimazombe esneza bona umdumo omavabhretjhini utjhuguluke bese ube yisiginali yegezi ezokuya engcondweni.

=== Umsebenzi weendlebe ===
Iindlebe zisebenza ukwenza bona umuntu akghone ukuza itjhada elenzeka eduze naye nofane kude. Zithatha itjhada nofana umdumo umuntu awuzwako kubhoduluko lakhe bese zilise engcondweni lapho ingcono izokuhlathula khona bona yini umuntu ayizwako begodu kufanele ayiphendule bunjani. Zisiza umuntu bona akghone ukudzimelela lokha nakajamileko. Indlebe isebenza nokuthi umuntu akghone ukukhuluma ngombana lokha umuntu ufunda ukukhuluma ngokuthi ezwa kukhulunywa&lt;ref&gt;Human ear | Structure, Function, &amp; Parts | Britannica&lt;/ref&gt;.Indlebe kusisitho esinqani somziba kodwana siqakathekile ukwenza ukuthi umuntu akghone ukuzwa nokuthi akghone ukukhuluma.

== Iinkomba ==
[[Category:Indlebe]]
[[Category:Umzimba]]</text>
      <sha1>osn06b06zc4dyl49fri109x2i27t2xr</sha1>
    </revision>
    <revision>
      <id>5060</id>
      <parentid>5059</parentid>
      <timestamp>2025-08-07T18:10:34Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5060</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2370" sha1="0vcp8wdcdz32abrexh2jf5qxyjhdka3" xml:space="preserve">[[Isimumathi:Human right ear (cropped).jpg|thumb|Indlebe yomuntu]]
'''Indlebe''' sisitho somzimba esisehloko yomuntu emahlangothini womabili esisebenza ukuzwa. Woke umuntu uba neendlebe ezimbili ezwa ngazo ikulumo, umvumo namanye amatjhada&lt;ref&gt;EAR | English meaning - Cambridge Dictionary&lt;/ref&gt;.Indlebe kuyisitho somzimba esincani kodwana esenza umsebenzi umsebenzi aqakathekileko emzimbeni, ngombana ikghona ukwenza bona [[umzimba]] umuntu  akghone ukudzimela lokha nakajamileko begodu umuntu ukghona ukuthola ilwazi asebenzisa yona. Indlebe ikghona ukwenza umuntu bona akghone ukuphendula lokho atjelwe khona wakuzwa begodu ikghona ukuthi  zwe loke ihlobo lamatjhada enzekako begodu.

=== Ukwakheka kwendlebe ===

==== Indlebe inesakhiwo sangaphandle nesangaphakathi. ====
Indlebe ihlukaniseke ngengaba esithathu kunendlebe yangaphandle, indlebe ephakathi kanye nendlebe yangaphakathi.Ithatha umdumo umunntu awuzwako bese iwufakae ngemgodini wendleni bona umdumo loyo ungene ngaphakathi.&lt;ref&gt;[https://www.bing.com/videos/search?q=middle%2c+inner+and+outer+ear+anatomy&amp;&amp;view=detail&amp;mid=674857878D4784501B0D674857878D4784501B0D&amp;mmscn=mtsc&amp;aps=6&amp;FORM=VMSOVR Bing Videos]&lt;/ref&gt; umgodi weendlebe unenhluthu ezincani ezenza bona ezivikela bona iindlebe ingangenwa ziinsila namagcinakwana.Indlebe ephakathi, le yindlebe encani enomgodi. Umgodi lo unanthambo amathathu abizwa bona ma-ossicles. Amathambi la ngiwo adlulisela umdumo esedromini yendlelbe ukuthi uye-endlebeni yangaphakathiIndlebe yangaphakathi,indlebe yangaphakathi inesakhiwo esimazombe esneza bona umdumo omavabhretjhini utjhuguluke bese ube yisiginali yegezi ezokuya engcondweni.

=== Umsebenzi weendlebe ===
Iindlebe zisebenza ukwenza bona umuntu akghone ukuza itjhada elenzeka eduze naye nofane kude. Zithatha itjhada nofana umdumo umuntu awuzwako kubhoduluko lakhe bese zilise engcondweni lapho ingcono izokuhlathula khona bona yini umuntu ayizwako begodu kufanele ayiphendule bunjani. Zisiza umuntu bona akghone ukudzimelela lokha nakajamileko. Indlebe isebenza nokuthi umuntu akghone ukukhuluma ngombana lokha umuntu ufunda ukukhuluma ngokuthi ezwa kukhulunywa&lt;ref&gt;Human ear | Structure, Function, &amp; Parts | Britannica&lt;/ref&gt;.Indlebe kusisitho esinqani somziba kodwana siqakathekile ukwenza ukuthi umuntu akghone ukuzwa nokuthi akghone ukukhuluma.

== Iinkomba ==
[[Category:Indlebe]]
[[Category:Umzimba]]</text>
      <sha1>0vcp8wdcdz32abrexh2jf5qxyjhdka3</sha1>
    </revision>
  </page>
  <page>
    <title>Ukugijima</title>
    <ns>0</ns>
    <id>527</id>
    <revision>
      <id>2596</id>
      <timestamp>2025-03-26T10:15:59Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Ukugijima == Ukugijima kungeminye yemidlalo edlala eSewula Afrika. Ukuze umuntu akwazi ukugijima ibanga elide kufuze bona azibandule bekufike lapho sele azizwa khona ukuthi uyakghona ukukghodlhelela lokha nakagijimako&lt;ref&gt;Galloway, J., 2023. ''Cross-country running: The best training plans for peak performance in the 5K, 1500M, 2000M, and 10K''. Meyer &amp; Meyer Sport.&lt;/ref&gt;. Ukugijima kuyinto engenziwa nanoma kungubani. Esikathini esinengi abantu bagijima lokha nabanjar...&quot;</comment>
      <origin>2596</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1935" sha1="1ohkl80n0obp9n51ig9eztyazxm76h6" xml:space="preserve">== Ukugijima ==
Ukugijima kungeminye yemidlalo edlala eSewula Afrika. Ukuze umuntu akwazi ukugijima ibanga elide kufuze bona azibandule bekufike lapho sele azizwa khona ukuthi uyakghona ukukghodlhelela lokha nakagijimako&lt;ref&gt;Galloway, J., 2023. ''Cross-country running: The best training plans for peak performance in the 5K, 1500M, 2000M, and 10K''. Meyer &amp; Meyer Sport.&lt;/ref&gt;. Ukugijima kuyinto engenziwa nanoma kungubani. Esikathini esinengi abantu bagijima lokha nabanjarhileko isibonelo umuntu angagijima nakatjhiywa yibhesi. 

== Ubuhle bokokugijima ==

=== 1. Ukuba nepilo ===
Umuntu ogikimako umzimba kwakhe uba nepilo, ngombana iingazi zakhe zikghona ukukhamba kuhle emzimbeni ngaphandle kokuthikamezeka. Ukugijima kwenza bona nokuthi ihliziyo ibethe kuhle begodu ingabi semafutheni. Umuntu ogijimako akusilula bona abe nomzimba omkhulu nofana asahlwe magulu emzimbeni. Imisipha iyaluleka lokha nawugijimako bese ikghona ukugobeka ngendlela efunan ngayo&lt;ref&gt;15 Benefits of Running That Will Make You Want to Log Some Miles | SELF&lt;/ref&gt;. 

=== 2. Ukukghodlhelela ===
Lokha nawuzijayeza ukugijima umzimba wakho ugcina sele uba nekghono lokukghodlhelela ungapheli ummoya lokha nawugijimako ugcine sele ujama. Umzimba uyajwayela ukuthi wena ngamalanga uhlala ugijima. Lokho kuyinto ehle khulu ngombana umzimba wakho ubanepilo&lt;ref&gt;Greenfield, B., 2014. ''Beyond training: Mastering endurance, health &amp; life''. Simon and Schuster.&lt;/ref&gt;. 

=== 3. Ukuphumelela kwezemidlalo ===
Lokha nawukwazi ukugijima ibanga elide ungadinwa ungakghona ukugcina ungenela amaphaliswano wokugijima bese uthumbe ngombana uzabe usebenzisa ikghono lakho lokugijima. Lokhu kutjho bona ungagcina sele wenza imali ngokwazi ukugijima kwaphela. 

== Isiphetho ==
Ukugijima kuyinto enepilo abantu kufanele bazifundise ukugijima njengendlela yokuzithabulula, Lokhu kuzokqenza bona umzimba womuntu ubenepilo, akghone ukukghodlhelela angaphelelwa mummoya msinya.</text>
      <sha1>1ohkl80n0obp9n51ig9eztyazxm76h6</sha1>
    </revision>
    <revision>
      <id>2597</id>
      <parentid>2596</parentid>
      <timestamp>2025-03-26T10:18:16Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2597</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1950" sha1="2x0istbirs9nmvwyi494ks611mr8ulb" xml:space="preserve">== Ukugijima ==
Ukugijima kungeminye yemidlalo edlala eSewula Afrika. Ukuze umuntu akwazi ukugijima ibanga elide kufuze bona azibandule bekufike lapho sele azizwa khona ukuthi uyakghona ukukghodlhelela lokha nakagijimako&lt;ref&gt;Galloway, J., 2023. ''Cross-country running: The best training plans for peak performance in the 5K, 1500M, 2000M, and 10K''. Meyer &amp; Meyer Sport.&lt;/ref&gt;. Ukugijima kuyinto engenziwa nanoma kungubani. Esikathini esinengi abantu bagijima lokha nabanjarhileko isibonelo umuntu angagijima nakatjhiywa yibhesi. 

== Ubuhle bokokugijima ==

=== 1. Ukuba nepilo ===
Umuntu ogikimako umzimba kwakhe uba nepilo, ngombana iingazi zakhe zikghona ukukhamba kuhle emzimbeni ngaphandle kokuthikamezeka. Ukugijima kwenza bona nokuthi [[ihliziyo]] ibethe kuhle begodu ingabi semafutheni. Umuntu ogijimako akusilula bona abe nomzimba omkhulu nofana asahlwe magulu emzimbeni. [[Imisipha]] iyaluleka lokha nawugijimako bese ikghona ukugobeka ngendlela efuna ngayo&lt;ref&gt;15 Benefits of Running That Will Make You Want to Log Some Miles | SELF&lt;/ref&gt;. 

=== 2. Ukukghodlhelela ===
Lokha nawuzijayeza ukugijima [[umzimba]] wakho ugcina sele uba nekghono lokukghodlhelela ungapheli ummoya lokha nawugijimako ugcine sele ujama. Umzimba uyajwayela ukuthi wena ngamalanga uhlala ugijima. Lokho kuyinto ehle khulu ngombana umzimba wakho ubanepilo&lt;ref&gt;Greenfield, B., 2014. ''Beyond training: Mastering endurance, health &amp; life''. Simon and Schuster.&lt;/ref&gt;. 

=== 3. Ukuphumelela kwezemidlalo ===
Lokha nawukwazi ukugijima ibanga elide ungadinwa ungakghona ukugcina ungenela amaphaliswano wokugijima bese uthumbe ngombana uzabe usebenzisa ikghono lakho lokugijima. Lokhu kutjho bona ungagcina sele wenza [[imali]] ngokwazi ukugijima kwaphela. 

== Isiphetho ==
Ukugijima kuyinto enepilo abantu kufanele bazifundise ukugijima njengendlela yokuzithabulula, Lokhu kuzokqenza bona umzimba womuntu ubenepilo, akghone ukukghodlhelela angaphelelwa mummoya msinya.</text>
      <sha1>2x0istbirs9nmvwyi494ks611mr8ulb</sha1>
    </revision>
    <revision>
      <id>2598</id>
      <parentid>2597</parentid>
      <timestamp>2025-03-26T10:20:01Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2598</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1956" sha1="nymdsyehv1szkiu5nrxy2jrzp29k1j9" xml:space="preserve">== Ukugijima ==
'''Ukugijima''' kungeminye yemidlalo edlala eSewula Afrika. Ukuze umuntu akwazi ukugijima ibanga elide kufuze bona azibandule bekufike lapho sele azizwa khona ukuthi uyakghona ukukghodlhelela lokha nakagijimako&lt;ref&gt;Galloway, J., 2023. ''Cross-country running: The best training plans for peak performance in the 5K, 1500M, 2000M, and 10K''. Meyer &amp; Meyer Sport.&lt;/ref&gt;. Ukugijima kuyinto engenziwa nanoma kungubani. Esikathini esinengi abantu bagijima lokha nabanjarhileko isibonelo umuntu angagijima nakatjhiywa yibhesi. 

== Ubuhle bokokugijima ==

=== 1. Ukuba nepilo ===
Umuntu ogikimako umzimba kwakhe uba nepilo, ngombana iingazi zakhe zikghona ukukhamba kuhle emzimbeni ngaphandle kokuthikamezeka. Ukugijima kwenza bona nokuthi [[ihliziyo]] ibethe kuhle begodu ingabi semafutheni. Umuntu ogijimako akusilula bona abe nomzimba omkhulu nofana asahlwe magulu emzimbeni. [[Imisipha]] iyaluleka lokha nawugijimako bese ikghona ukugobeka ngendlela efuna ngayo&lt;ref&gt;15 Benefits of Running That Will Make You Want to Log Some Miles | SELF&lt;/ref&gt;. 

=== 2. Ukukghodlhelela ===
Lokha nawuzijayeza ukugijima [[umzimba]] wakho ugcina sele uba nekghono lokukghodlhelela ungapheli ummoya lokha nawugijimako ugcine sele ujama. Umzimba uyajwayela ukuthi wena ngamalanga uhlala ugijima. Lokho kuyinto ehle khulu ngombana umzimba wakho ubanepilo&lt;ref&gt;Greenfield, B., 2014. ''Beyond training: Mastering endurance, health &amp; life''. Simon and Schuster.&lt;/ref&gt;. 

=== 3. Ukuphumelela kwezemidlalo ===
Lokha nawukwazi ukugijima ibanga elide ungadinwa ungakghona ukugcina ungenela amaphaliswano wokugijima bese uthumbe ngombana uzabe usebenzisa ikghono lakho lokugijima. Lokhu kutjho bona ungagcina sele wenza [[imali]] ngokwazi ukugijima kwaphela. 

== Isiphetho ==
Ukugijima kuyinto enepilo abantu kufanele bazifundise ukugijima njengendlela yokuzithabulula, Lokhu kuzokqenza bona umzimba womuntu ubenepilo, akghone ukukghodlhelela angaphelelwa mummoya msinya.</text>
      <sha1>nymdsyehv1szkiu5nrxy2jrzp29k1j9</sha1>
    </revision>
    <revision>
      <id>2651</id>
      <parentid>2598</parentid>
      <timestamp>2025-04-07T18:30:01Z</timestamp>
      <contributor>
        <username>Elownow</username>
        <id>555</id>
      </contributor>
      <origin>2651</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1957" sha1="5nqwfnc83y2madj8g7pjul854dwwx9i" xml:space="preserve">== Ukugijima ==
'''Ukugijima''' kungeminye yemidlalo edlala eSewula Afrika. Ukuze umuntu akwazi ukugijima ibanga elide kufuze bona azibandule bekufike lapho sele azizwa khona ukuthi huyakghona ukukghodlhelela lokha nakagijimako&lt;ref&gt;Galloway, J., 2023. ''Cross-country running: The best training plans for peak performance in the 5K, 1500M, 2000M, and 10K''. Meyer &amp; Meyer Sport.&lt;/ref&gt;. Ukugijima kuyinto engenziwa nanoma kungubani. Esikathini esinengi abantu bagijima lokha nabanjarhileko isibonelo umuntu angagijima nakatjhiywa yibhesi. 

== Ubuhle bokokugijima ==

=== 1. Ukuba nepilo ===
Umuntu ogikimako umzimba kwakhe uba nepilo, ngombana iingazi zakhe zikghona ukukhamba kuhle emzimbeni ngaphandle kokuthikamezeka. Ukugijima kwenza bona nokuthi [[ihliziyo]] ibethe kuhle begodu ingabi semafutheni. Umuntu ogijimako akusilula bona abe nomzimba omkhulu nofana asahlwe magulu emzimbeni. [[Imisipha]] iyaluleka lokha nawugijimako bese ikghona ukugobeka ngendlela efuna ngayo&lt;ref&gt;15 Benefits of Running That Will Make You Want to Log Some Miles | SELF&lt;/ref&gt;. 

=== 2. Ukukghodlhelela ===
Lokha nawuzijayeza ukugijima [[umzimba]] wakho ugcina sele uba nekghono lokukghodlhelela ungapheli ummoya lokha nawugijimako ugcine sele ujama. Umzimba uyajwayela ukuthi wena ngamalanga uhlala ugijima. Lokho kuyinto ehle khulu ngombana umzimba wakho ubanepilo&lt;ref&gt;Greenfield, B., 2014. ''Beyond training: Mastering endurance, health &amp; life''. Simon and Schuster.&lt;/ref&gt;. 

=== 3. Ukuphumelela kwezemidlalo ===
Lokha nawukwazi ukugijima ibanga elide ungadinwa ungakghona ukugcina ungenela amaphaliswano wokugijima bese uthumbe ngombana uzabe usebenzisa ikghono lakho lokugijima. Lokhu kutjho bona ungagcina sele wenza [[imali]] ngokwazi ukugijima kwaphela. 

== Isiphetho ==
Ukugijima kuyinto enepilo abantu kufanele bazifundise ukugijima njengendlela yokuzithabulula, Lokhu kuzokqenza bona umzimba womuntu ubenepilo, akghone ukukghodlhelela angaphelelwa mummoya msinya.</text>
      <sha1>5nqwfnc83y2madj8g7pjul854dwwx9i</sha1>
    </revision>
    <revision>
      <id>3175</id>
      <parentid>2651</parentid>
      <timestamp>2025-06-21T19:00:18Z</timestamp>
      <contributor>
        <ip>85.97.84.231</ip>
      </contributor>
      <origin>3175</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2068" sha1="9r3gjxcsnroto6v6t6iyxa607q2dimu" xml:space="preserve">[[File:Common chimpanzee (Pan troglodytes schweinfurthii) feeding.jpg|thumb|Omar al-Bashir is a chimpanzee.]]

== Ukugijima ==
'''Ukugijima''' kungeminye yemidlalo edlala eSewula Afrika. Ukuze umuntu akwazi ukugijima ibanga elide kufuze bona azibandule bekufike lapho sele azizwa khona ukuthi huyakghona ukukghodlhelela lokha nakagijimako&lt;ref&gt;Galloway, J., 2023. ''Cross-country running: The best training plans for peak performance in the 5K, 1500M, 2000M, and 10K''. Meyer &amp; Meyer Sport.&lt;/ref&gt;. Ukugijima kuyinto engenziwa nanoma kungubani. Esikathini esinengi abantu bagijima lokha nabanjarhileko isibonelo umuntu angagijima nakatjhiywa yibhesi. 

== Ubuhle bokokugijima ==

=== 1. Ukuba nepilo ===
Umuntu ogikimako umzimba kwakhe uba nepilo, ngombana iingazi zakhe zikghona ukukhamba kuhle emzimbeni ngaphandle kokuthikamezeka. Ukugijima kwenza bona nokuthi [[ihliziyo]] ibethe kuhle begodu ingabi semafutheni. Umuntu ogijimako akusilula bona abe nomzimba omkhulu nofana asahlwe magulu emzimbeni. [[Imisipha]] iyaluleka lokha nawugijimako bese ikghona ukugobeka ngendlela efuna ngayo&lt;ref&gt;15 Benefits of Running That Will Make You Want to Log Some Miles | SELF&lt;/ref&gt;. 

=== 2. Ukukghodlhelela ===
Lokha nawuzijayeza ukugijima [[umzimba]] wakho ugcina sele uba nekghono lokukghodlhelela ungapheli ummoya lokha nawugijimako ugcine sele ujama. Umzimba uyajwayela ukuthi wena ngamalanga uhlala ugijima. Lokho kuyinto ehle khulu ngombana umzimba wakho ubanepilo&lt;ref&gt;Greenfield, B., 2014. ''Beyond training: Mastering endurance, health &amp; life''. Simon and Schuster.&lt;/ref&gt;. 

=== 3. Ukuphumelela kwezemidlalo ===
Lokha nawukwazi ukugijima ibanga elide ungadinwa ungakghona ukugcina ungenela amaphaliswano wokugijima bese uthumbe ngombana uzabe usebenzisa ikghono lakho lokugijima. Lokhu kutjho bona ungagcina sele wenza [[imali]] ngokwazi ukugijima kwaphela. 

== Isiphetho ==
Ukugijima kuyinto enepilo abantu kufanele bazifundise ukugijima njengendlela yokuzithabulula, Lokhu kuzokqenza bona umzimba womuntu ubenepilo, akghone ukukghodlhelela angaphelelwa mummoya msinya.</text>
      <sha1>9r3gjxcsnroto6v6t6iyxa607q2dimu</sha1>
    </revision>
    <revision>
      <id>3190</id>
      <parentid>3175</parentid>
      <timestamp>2025-06-21T19:16:22Z</timestamp>
      <contributor>
        <ip>85.97.84.231</ip>
      </contributor>
      <origin>3190</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2179" sha1="kotfg4xhl1imnczx77da1fac5soje31" xml:space="preserve">[[File:Common chimpanzee (Pan troglodytes schweinfurthii) feeding.jpg|thumb|Omar al-Bashir is a chimpanzee.]]

[[File:Common chimpanzee (Pan troglodytes schweinfurthii) feeding.jpg|thumb|Omar al-Bashir is a chimpanzee.]]

== Ukugijima ==
'''Ukugijima''' kungeminye yemidlalo edlala eSewula Afrika. Ukuze umuntu akwazi ukugijima ibanga elide kufuze bona azibandule bekufike lapho sele azizwa khona ukuthi huyakghona ukukghodlhelela lokha nakagijimako&lt;ref&gt;Galloway, J., 2023. ''Cross-country running: The best training plans for peak performance in the 5K, 1500M, 2000M, and 10K''. Meyer &amp; Meyer Sport.&lt;/ref&gt;. Ukugijima kuyinto engenziwa nanoma kungubani. Esikathini esinengi abantu bagijima lokha nabanjarhileko isibonelo umuntu angagijima nakatjhiywa yibhesi. 

== Ubuhle bokokugijima ==

=== 1. Ukuba nepilo ===
Umuntu ogikimako umzimba kwakhe uba nepilo, ngombana iingazi zakhe zikghona ukukhamba kuhle emzimbeni ngaphandle kokuthikamezeka. Ukugijima kwenza bona nokuthi [[ihliziyo]] ibethe kuhle begodu ingabi semafutheni. Umuntu ogijimako akusilula bona abe nomzimba omkhulu nofana asahlwe magulu emzimbeni. [[Imisipha]] iyaluleka lokha nawugijimako bese ikghona ukugobeka ngendlela efuna ngayo&lt;ref&gt;15 Benefits of Running That Will Make You Want to Log Some Miles | SELF&lt;/ref&gt;. 

=== 2. Ukukghodlhelela ===
Lokha nawuzijayeza ukugijima [[umzimba]] wakho ugcina sele uba nekghono lokukghodlhelela ungapheli ummoya lokha nawugijimako ugcine sele ujama. Umzimba uyajwayela ukuthi wena ngamalanga uhlala ugijima. Lokho kuyinto ehle khulu ngombana umzimba wakho ubanepilo&lt;ref&gt;Greenfield, B., 2014. ''Beyond training: Mastering endurance, health &amp; life''. Simon and Schuster.&lt;/ref&gt;. 

=== 3. Ukuphumelela kwezemidlalo ===
Lokha nawukwazi ukugijima ibanga elide ungadinwa ungakghona ukugcina ungenela amaphaliswano wokugijima bese uthumbe ngombana uzabe usebenzisa ikghono lakho lokugijima. Lokhu kutjho bona ungagcina sele wenza [[imali]] ngokwazi ukugijima kwaphela. 

== Isiphetho ==
Ukugijima kuyinto enepilo abantu kufanele bazifundise ukugijima njengendlela yokuzithabulula, Lokhu kuzokqenza bona umzimba womuntu ubenepilo, akghone ukukghodlhelela angaphelelwa mummoya msinya.</text>
      <sha1>kotfg4xhl1imnczx77da1fac5soje31</sha1>
    </revision>
    <revision>
      <id>3308</id>
      <parentid>3190</parentid>
      <timestamp>2025-07-02T20:48:14Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Undo revision [[Special:Diff/3190|3190]] by [[Special:Contributions/85.97.84.231|85.97.84.231]] ([[User talk:85.97.84.231|talk]])</comment>
      <origin>3308</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1958" sha1="rt5yfaxn4xlp2a1klbu24qsaob1rri9" xml:space="preserve">
== Ukugijima ==
'''Ukugijima''' kungeminye yemidlalo edlala eSewula Afrika. Ukuze umuntu akwazi ukugijima ibanga elide kufuze bona azibandule bekufike lapho sele azizwa khona ukuthi huyakghona ukukghodlhelela lokha nakagijimako&lt;ref&gt;Galloway, J., 2023. ''Cross-country running: The best training plans for peak performance in the 5K, 1500M, 2000M, and 10K''. Meyer &amp; Meyer Sport.&lt;/ref&gt;. Ukugijima kuyinto engenziwa nanoma kungubani. Esikathini esinengi abantu bagijima lokha nabanjarhileko isibonelo umuntu angagijima nakatjhiywa yibhesi. 

== Ubuhle bokokugijima ==

=== 1. Ukuba nepilo ===
Umuntu ogikimako umzimba kwakhe uba nepilo, ngombana iingazi zakhe zikghona ukukhamba kuhle emzimbeni ngaphandle kokuthikamezeka. Ukugijima kwenza bona nokuthi [[ihliziyo]] ibethe kuhle begodu ingabi semafutheni. Umuntu ogijimako akusilula bona abe nomzimba omkhulu nofana asahlwe magulu emzimbeni. [[Imisipha]] iyaluleka lokha nawugijimako bese ikghona ukugobeka ngendlela efuna ngayo&lt;ref&gt;15 Benefits of Running That Will Make You Want to Log Some Miles | SELF&lt;/ref&gt;. 

=== 2. Ukukghodlhelela ===
Lokha nawuzijayeza ukugijima [[umzimba]] wakho ugcina sele uba nekghono lokukghodlhelela ungapheli ummoya lokha nawugijimako ugcine sele ujama. Umzimba uyajwayela ukuthi wena ngamalanga uhlala ugijima. Lokho kuyinto ehle khulu ngombana umzimba wakho ubanepilo&lt;ref&gt;Greenfield, B., 2014. ''Beyond training: Mastering endurance, health &amp; life''. Simon and Schuster.&lt;/ref&gt;. 

=== 3. Ukuphumelela kwezemidlalo ===
Lokha nawukwazi ukugijima ibanga elide ungadinwa ungakghona ukugcina ungenela amaphaliswano wokugijima bese uthumbe ngombana uzabe usebenzisa ikghono lakho lokugijima. Lokhu kutjho bona ungagcina sele wenza [[imali]] ngokwazi ukugijima kwaphela. 

== Isiphetho ==
Ukugijima kuyinto enepilo abantu kufanele bazifundise ukugijima njengendlela yokuzithabulula, Lokhu kuzokqenza bona umzimba womuntu ubenepilo, akghone ukukghodlhelela angaphelelwa mummoya msinya.</text>
      <sha1>rt5yfaxn4xlp2a1klbu24qsaob1rri9</sha1>
    </revision>
  </page>
  <page>
    <title>Iyunivesithi ye-North-West</title>
    <ns>0</ns>
    <id>528</id>
    <revision>
      <id>2600</id>
      <timestamp>2025-03-27T07:42:23Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1282574200|North-West University]]&quot;</comment>
      <origin>2600</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="822" sha1="4a55mf7fhblwppt89rcf4m2nvbornpk" xml:space="preserve">'''IYunivesithi ye-North-West''' ( '''NWU''' ) yiyunivesithi yomphakathi yokwenza irhubhululo etholakala emakhempasini amathathu e -Potchefstroom, Mahikeng ne-Vanderbijlpark [[Isewula Afrika|eSewula Afrika]] . Iyunivesithi le yaba khona ngokuhlanganiswa ngomnyaka wee-2004 hlangana kwe- Potchefstroom University for Christian Higher Education, iyiyunivesithi ekulu, enomlando eyasungulwa ngomnyaka we-1869, nayo ebegade inegatja e-Vanderbijlpark ne-University of North-West (egade iyi- University of Bophuthatswana ).  Ngobujamo bayo obuhlanganisiweko, iYunivesithi ye-North-West yaba ngenye yamayunivesithi amakhulu khulu eSewula Afrika enenani lesithathu ngobukhulu babafundi ( ifundo yesikhathi esizeleko neyebanga ) enarheni.  I-NWU ihlangana namayunivesithi aphambili ekhayapha, e [[I-Afrika|-Afrika]] nephasini loke.</text>
      <sha1>4a55mf7fhblwppt89rcf4m2nvbornpk</sha1>
    </revision>
  </page>
  <page>
    <title>IYunivesithi ye-North-West</title>
    <ns>0</ns>
    <id>529</id>
    <revision>
      <id>2601</id>
      <timestamp>2025-03-27T07:45:55Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1282574200|North-West University]]&quot;</comment>
      <origin>2601</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="925" sha1="5ypbqmwezif8w5l0x8oom2kcsyz71x1" xml:space="preserve">'''IYunivesithi ye-North-West''' ( '''NWU''' ) yiyunivesithi yomphakathi yokwenza irhubhululo etholakala emakhempasini amathathu e -Potchefstroom, Mahikeng ne-Vanderbijlpark [[Isewula Afrika|eSewula Afrika]] . Iyunivesithi le yaba khona ngokuhlanganiswa ngomnyaka wee-2004 hlangana kwe- Potchefstroom University for Christian Higher Education, iyiyunivesithi ekulu, enomlando eyasungulwa ngomnyaka we-1869, nayo ebegade inegatja e-Vanderbijlpark ne-University of North-West (egade iyi- University of Bophuthatswana ).  Ngobujamo bayo obuhlanganisiweko, iYunivesithi ye-North-West yaba ngenye yamayunivesithi amakhulu khulu eSewula Afrika enenani lesithathu ngobukhulu babafundi ( ifundo yesikhathi esizeleko neyebanga ) enarheni.  I-NWU ihlangana namayunivesithi aphambili ekhayapha, e [[I-Afrika|-Afrika]] nephasini loke. 

* Ikhampasi ye-Mahikeng
* Ikhampasi ye-Potchefstroom (ikhampasi ekulu)
* Ikhampasi ye-Vanderbijlpark</text>
      <sha1>5ypbqmwezif8w5l0x8oom2kcsyz71x1</sha1>
    </revision>
    <revision>
      <id>5734</id>
      <parentid>2601</parentid>
      <timestamp>2025-09-18T11:23:23Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>added invoke databox</comment>
      <origin>5734</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="953" sha1="6pih63wmq9p0a89lxjq28wkss478hb3" xml:space="preserve">{{#invoke:Databox|databox}}'''
IYunivesithi ye-North-West''' ( '''NWU''' ) yiyunivesithi yomphakathi yokwenza irhubhululo etholakala emakhempasini amathathu e -Potchefstroom, Mahikeng ne-Vanderbijlpark [[Isewula Afrika|eSewula Afrika]] . Iyunivesithi le yaba khona ngokuhlanganiswa ngomnyaka wee-2004 hlangana kwe- Potchefstroom University for Christian Higher Education, iyiyunivesithi ekulu, enomlando eyasungulwa ngomnyaka we-1869, nayo ebegade inegatja e-Vanderbijlpark ne-University of North-West (egade iyi- University of Bophuthatswana ).  Ngobujamo bayo obuhlanganisiweko, iYunivesithi ye-North-West yaba ngenye yamayunivesithi amakhulu khulu eSewula Afrika enenani lesithathu ngobukhulu babafundi ( ifundo yesikhathi esizeleko neyebanga ) enarheni.  I-NWU ihlangana namayunivesithi aphambili ekhayapha, e [[I-Afrika|-Afrika]] nephasini loke. 

* Ikhampasi ye-Mahikeng
* Ikhampasi ye-Potchefstroom (ikhampasi ekulu)
* Ikhampasi ye-Vanderbijlpark</text>
      <sha1>6pih63wmq9p0a89lxjq28wkss478hb3</sha1>
    </revision>
    <revision>
      <id>5735</id>
      <parentid>5734</parentid>
      <timestamp>2025-09-18T11:23:58Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <origin>5735</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="953" sha1="99a11i6kphh2y9pram1td2o3ecj83i3" xml:space="preserve">{{#invoke:Databox|databox}}
'''IYunivesithi ye-North-West''' ( '''NWU''' ) yiyunivesithi yomphakathi yokwenza irhubhululo etholakala emakhempasini amathathu e -Potchefstroom, Mahikeng ne-Vanderbijlpark [[Isewula Afrika|eSewula Afrika]] . Iyunivesithi le yaba khona ngokuhlanganiswa ngomnyaka wee-2004 hlangana kwe- Potchefstroom University for Christian Higher Education, iyiyunivesithi ekulu, enomlando eyasungulwa ngomnyaka we-1869, nayo ebegade inegatja e-Vanderbijlpark ne-University of North-West (egade iyi- University of Bophuthatswana ).  Ngobujamo bayo obuhlanganisiweko, iYunivesithi ye-North-West yaba ngenye yamayunivesithi amakhulu khulu eSewula Afrika enenani lesithathu ngobukhulu babafundi ( ifundo yesikhathi esizeleko neyebanga ) enarheni.  I-NWU ihlangana namayunivesithi aphambili ekhayapha, e [[I-Afrika|-Afrika]] nephasini loke. 

* Ikhampasi ye-Mahikeng
* Ikhampasi ye-Potchefstroom (ikhampasi ekulu)
* Ikhampasi ye-Vanderbijlpark</text>
      <sha1>99a11i6kphh2y9pram1td2o3ecj83i3</sha1>
    </revision>
    <revision>
      <id>5739</id>
      <parentid>5735</parentid>
      <timestamp>2025-09-18T11:35:50Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>Databox</comment>
      <origin>5739</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="937" sha1="0wj7ymx91ciq0ydqoqsgyq2w8iuo0zo" xml:space="preserve">{{Databox}}
'''IYunivesithi ye-North-West''' ( '''NWU''' ) yiyunivesithi yomphakathi yokwenza irhubhululo etholakala emakhempasini amathathu e -Potchefstroom, Mahikeng ne-Vanderbijlpark [[Isewula Afrika|eSewula Afrika]] . Iyunivesithi le yaba khona ngokuhlanganiswa ngomnyaka wee-2004 hlangana kwe- Potchefstroom University for Christian Higher Education, iyiyunivesithi ekulu, enomlando eyasungulwa ngomnyaka we-1869, nayo ebegade inegatja e-Vanderbijlpark ne-University of North-West (egade iyi- University of Bophuthatswana ).  Ngobujamo bayo obuhlanganisiweko, iYunivesithi ye-North-West yaba ngenye yamayunivesithi amakhulu khulu eSewula Afrika enenani lesithathu ngobukhulu babafundi ( ifundo yesikhathi esizeleko neyebanga ) enarheni.  I-NWU ihlangana namayunivesithi aphambili ekhayapha, e [[I-Afrika|-Afrika]] nephasini loke. 

* Ikhampasi ye-Mahikeng
* Ikhampasi ye-Potchefstroom (ikhampasi ekulu)
* Ikhampasi ye-Vanderbijlpark</text>
      <sha1>0wj7ymx91ciq0ydqoqsgyq2w8iuo0zo</sha1>
    </revision>
  </page>
  <page>
    <title>Iyunivesithi ye-KwaZulu-Natal</title>
    <ns>0</ns>
    <id>530</id>
    <revision>
      <id>2602</id>
      <timestamp>2025-03-27T10:23:39Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1277727545|University of KwaZulu-Natal]]&quot;</comment>
      <origin>2602</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="328" sha1="87bdrnk94um1qgei9c33f4na2l1zaut" xml:space="preserve">
'''IYunivesithi yaKwaZulu-Natal''' ('''UKZN'''; Zulu, Afrikaans) yiyunivesithi yokurhubhulula yomphakathi enamakhampasi amahlanu esifundeni saKwaZulu-Natal [[Isewula Afrika|eSewula Afrika]] .  Yasungulwa mhlazana ilanga lili-1 kuTjhirhweni 2004 ngemva kokuhlanganiswa kweYunivesithi ye-Natal neYunivesithi ye-Durban-Westville .</text>
      <sha1>87bdrnk94um1qgei9c33f4na2l1zaut</sha1>
    </revision>
  </page>
  <page>
    <title>Iimbongo ZakwaSkhosana</title>
    <ns>0</ns>
    <id>531</id>
    <revision>
      <id>2603</id>
      <timestamp>2025-03-27T12:18:34Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <comment>New testing article</comment>
      <origin>2603</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="117" sha1="3yxascgtj3s1aqdqpu1drjf163fshtf" xml:space="preserve">Isibongo sakwaSkhosana ngezinye iimbongo ezikhona elimi lesiNdebele.&lt;ref&gt;[https://www.baala.org.za/conference/]&lt;/ref&gt;</text>
      <sha1>3yxascgtj3s1aqdqpu1drjf163fshtf</sha1>
    </revision>
  </page>
  <page>
    <title>Batho Abantu African Languages Association (BAALA)</title>
    <ns>0</ns>
    <id>532</id>
    <revision>
      <id>2604</id>
      <timestamp>2025-03-27T15:09:03Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <comment>This is the new article.</comment>
      <origin>2604</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="239" sha1="9v9nt59n8196y32telz2plc4nqm7kpi" xml:space="preserve">I-BAALA yihlangano ezinikeleko ekukhangiseni, ekuthuthukiseni nekubulungeni amalimi weSewula Afrika nephasini mazombe. Lo mzamo osemthethweni wesigungu esilawula zamaLimi nomNyango wezobuNtu: IsiKolo sezamaLimi. [https://www.baala.org.za/]</text>
      <sha1>9v9nt59n8196y32telz2plc4nqm7kpi</sha1>
    </revision>
    <revision>
      <id>2964</id>
      <parentid>2604</parentid>
      <timestamp>2025-06-06T19:55:56Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>This page is sponsored by Raid: Shadow Legends, the sponsor of today's page.</comment>
      <origin>2964</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="326" sha1="r3t4zb4xtn41ryousi8kw3jrvn0pgzt" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.''' I-BAALA yihlangano ezinikeleko ekukhangiseni, ekuthuthukiseni nekubulungeni amalimi weSewula Afrika nephasini mazombe. Lo mzamo osemthethweni wesigungu esilawula zamaLimi nomNyango wezobuNtu: IsiKolo sezamaLimi. [https://www.baala.org.za/]</text>
      <sha1>r3t4zb4xtn41ryousi8kw3jrvn0pgzt</sha1>
    </revision>
    <revision>
      <id>3092</id>
      <parentid>2964</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Nomsa Skosana|Nomsa Skosana]]</comment>
      <origin>2604</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="239" sha1="9v9nt59n8196y32telz2plc4nqm7kpi" xml:space="preserve">I-BAALA yihlangano ezinikeleko ekukhangiseni, ekuthuthukiseni nekubulungeni amalimi weSewula Afrika nephasini mazombe. Lo mzamo osemthethweni wesigungu esilawula zamaLimi nomNyango wezobuNtu: IsiKolo sezamaLimi. [https://www.baala.org.za/]</text>
      <sha1>9v9nt59n8196y32telz2plc4nqm7kpi</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi asiqongelane:Roman Oy Bobrov</title>
    <ns>3</ns>
    <id>533</id>
    <revision>
      <id>2606</id>
      <timestamp>2025-03-27T18:52:12Z</timestamp>
      <contributor>
        <username>MediaWiki message delivery</username>
        <id>195</id>
      </contributor>
      <comment>/* Invitation to connect with fellow contributors from language onboarding experiment */ new section</comment>
      <origin>2606</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1883" sha1="3hs0tbsr3syfscc5tndkkplcianjn7d" xml:space="preserve">== Invitation to connect with fellow contributors from language onboarding experiment ==

Hello,

Hope this message finds you well! I would like to invite you to a community conversation to connect with fellow contributors from pilot wikis (Southern Ndebele, Tai Nüa, Iban, Obolo, Pannonian Rusyn) that graduated through a [https://diff.wikimedia.org/2024/10/31/wikipedia-goes-live-for-five-languages-through-the-future-of-language-incubation-initiative/ Language Onboarding Experiment] last year. In this conversation, we plan to facilitate sharing learnings, discussing technical needs post-graduation, and collaborating on solving challenges faced by the pilot wikis.

We spoke with a few contributors from these wikis back in December, and their valuable input on contributions has given us some perspectives on what to investigate next. A report will soon be published on those learnings. We hope that this meeting will not only be a great opportunity for us to come together and learn from each other but also allow us to use your valuable input to shape our plans for the coming year!
If you can attend the call, please sign up here, and I will share more details later:

* [https://www.mediawiki.org/wiki/Language_Onboarding_and_Development/Community_conversations_2024-25#5_April_2025_01:00_UTC 5 April 2025, 01:00 UTC]
* [https://www.mediawiki.org/wiki/Language_Onboarding_and_Development/Community_conversations_2024-25#4_April_2025_15:00_UTC 4 April 2025, 15:00 UTC]

Looking forward to your participation!

Cheers, [[User:SSethi (WMF)]] via [[Umsebenzisi:MediaWiki message delivery|MediaWiki message delivery]] ([[Umsebenzisi asiqongelane:MediaWiki message delivery|talk]]) 20:52, 27 Mbimbitho 2025 (SAST)
&lt;!-- Message sent by User:SSethi (WMF)@metawiki using the list at https://meta.wikimedia.org/w/index.php?title=User:SSethi_(WMF)/MassMessageList&amp;oldid=28454981 --&gt;</text>
      <sha1>3hs0tbsr3syfscc5tndkkplcianjn7d</sha1>
    </revision>
    <revision>
      <id>2620</id>
      <parentid>2606</parentid>
      <timestamp>2025-04-02T17:24:05Z</timestamp>
      <contributor>
        <username>SSethi (WMF)</username>
        <id>105</id>
      </contributor>
      <comment>/* Invitation to connect with fellow contributors from language onboarding experiment */ Reply</comment>
      <origin>2620</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2253" sha1="0wyou0ktenmhc80x3l567vbz626k6wv" xml:space="preserve">== Invitation to connect with fellow contributors from language onboarding experiment ==

Hello,

Hope this message finds you well! I would like to invite you to a community conversation to connect with fellow contributors from pilot wikis (Southern Ndebele, Tai Nüa, Iban, Obolo, Pannonian Rusyn) that graduated through a [https://diff.wikimedia.org/2024/10/31/wikipedia-goes-live-for-five-languages-through-the-future-of-language-incubation-initiative/ Language Onboarding Experiment] last year. In this conversation, we plan to facilitate sharing learnings, discussing technical needs post-graduation, and collaborating on solving challenges faced by the pilot wikis.

We spoke with a few contributors from these wikis back in December, and their valuable input on contributions has given us some perspectives on what to investigate next. A report will soon be published on those learnings. We hope that this meeting will not only be a great opportunity for us to come together and learn from each other but also allow us to use your valuable input to shape our plans for the coming year!
If you can attend the call, please sign up here, and I will share more details later:

* [https://www.mediawiki.org/wiki/Language_Onboarding_and_Development/Community_conversations_2024-25#5_April_2025_01:00_UTC 5 April 2025, 01:00 UTC]
* [https://www.mediawiki.org/wiki/Language_Onboarding_and_Development/Community_conversations_2024-25#4_April_2025_15:00_UTC 4 April 2025, 15:00 UTC]

Looking forward to your participation!

Cheers, [[User:SSethi (WMF)]] via [[Umsebenzisi:MediaWiki message delivery|MediaWiki message delivery]] ([[Umsebenzisi asiqongelane:MediaWiki message delivery|talk]]) 20:52, 27 Mbimbitho 2025 (SAST)
&lt;!-- Message sent by User:SSethi (WMF)@metawiki using the list at https://meta.wikimedia.org/w/index.php?title=User:SSethi_(WMF)/MassMessageList&amp;oldid=28454981 --&gt;
:: Hi! If you haven't signed up yet, you can still consider doing so! You can find more information on [[mediawikiwiki:Language_Onboarding_and_Development/Community_conversations_2024-25|this page]] about the upcoming meetings on April 4th and 5th. 
:[[Umsebenzisi:SSethi (WMF)|SSethi (WMF)]] ([[Umsebenzisi asiqongelane:SSethi (WMF)|talk]]) 19:24, 2 Mabasa 2025 (SAST)</text>
      <sha1>0wyou0ktenmhc80x3l567vbz626k6wv</sha1>
    </revision>
    <revision>
      <id>6592</id>
      <parentid>2620</parentid>
      <timestamp>2026-05-19T06:18:51Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6592</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2282" sha1="t87my5zwt56q89z6gzod5eaf10ex4o6" xml:space="preserve">{{Not around|{{PAGENAME}}}}

== Invitation to connect with fellow contributors from language onboarding experiment ==

Hello,

Hope this message finds you well! I would like to invite you to a community conversation to connect with fellow contributors from pilot wikis (Southern Ndebele, Tai Nüa, Iban, Obolo, Pannonian Rusyn) that graduated through a [https://diff.wikimedia.org/2024/10/31/wikipedia-goes-live-for-five-languages-through-the-future-of-language-incubation-initiative/ Language Onboarding Experiment] last year. In this conversation, we plan to facilitate sharing learnings, discussing technical needs post-graduation, and collaborating on solving challenges faced by the pilot wikis.

We spoke with a few contributors from these wikis back in December, and their valuable input on contributions has given us some perspectives on what to investigate next. A report will soon be published on those learnings. We hope that this meeting will not only be a great opportunity for us to come together and learn from each other but also allow us to use your valuable input to shape our plans for the coming year!
If you can attend the call, please sign up here, and I will share more details later:

* [https://www.mediawiki.org/wiki/Language_Onboarding_and_Development/Community_conversations_2024-25#5_April_2025_01:00_UTC 5 April 2025, 01:00 UTC]
* [https://www.mediawiki.org/wiki/Language_Onboarding_and_Development/Community_conversations_2024-25#4_April_2025_15:00_UTC 4 April 2025, 15:00 UTC]

Looking forward to your participation!

Cheers, [[User:SSethi (WMF)]] via [[Umsebenzisi:MediaWiki message delivery|MediaWiki message delivery]] ([[Umsebenzisi asiqongelane:MediaWiki message delivery|talk]]) 20:52, 27 Mbimbitho 2025 (SAST)
&lt;!-- Message sent by User:SSethi (WMF)@metawiki using the list at https://meta.wikimedia.org/w/index.php?title=User:SSethi_(WMF)/MassMessageList&amp;oldid=28454981 --&gt;
:: Hi! If you haven't signed up yet, you can still consider doing so! You can find more information on [[mediawikiwiki:Language_Onboarding_and_Development/Community_conversations_2024-25|this page]] about the upcoming meetings on April 4th and 5th. 
:[[Umsebenzisi:SSethi (WMF)|SSethi (WMF)]] ([[Umsebenzisi asiqongelane:SSethi (WMF)|talk]]) 19:24, 2 Mabasa 2025 (SAST)</text>
      <sha1>t87my5zwt56q89z6gzod5eaf10ex4o6</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi asiqongelane:Nqobile69</title>
    <ns>3</ns>
    <id>534</id>
    <revision>
      <id>2608</id>
      <timestamp>2025-03-27T18:52:12Z</timestamp>
      <contributor>
        <username>MediaWiki message delivery</username>
        <id>195</id>
      </contributor>
      <comment>/* Invitation to connect with fellow contributors from language onboarding experiment */ new section</comment>
      <origin>2608</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1883" sha1="3hs0tbsr3syfscc5tndkkplcianjn7d" xml:space="preserve">== Invitation to connect with fellow contributors from language onboarding experiment ==

Hello,

Hope this message finds you well! I would like to invite you to a community conversation to connect with fellow contributors from pilot wikis (Southern Ndebele, Tai Nüa, Iban, Obolo, Pannonian Rusyn) that graduated through a [https://diff.wikimedia.org/2024/10/31/wikipedia-goes-live-for-five-languages-through-the-future-of-language-incubation-initiative/ Language Onboarding Experiment] last year. In this conversation, we plan to facilitate sharing learnings, discussing technical needs post-graduation, and collaborating on solving challenges faced by the pilot wikis.

We spoke with a few contributors from these wikis back in December, and their valuable input on contributions has given us some perspectives on what to investigate next. A report will soon be published on those learnings. We hope that this meeting will not only be a great opportunity for us to come together and learn from each other but also allow us to use your valuable input to shape our plans for the coming year!
If you can attend the call, please sign up here, and I will share more details later:

* [https://www.mediawiki.org/wiki/Language_Onboarding_and_Development/Community_conversations_2024-25#5_April_2025_01:00_UTC 5 April 2025, 01:00 UTC]
* [https://www.mediawiki.org/wiki/Language_Onboarding_and_Development/Community_conversations_2024-25#4_April_2025_15:00_UTC 4 April 2025, 15:00 UTC]

Looking forward to your participation!

Cheers, [[User:SSethi (WMF)]] via [[Umsebenzisi:MediaWiki message delivery|MediaWiki message delivery]] ([[Umsebenzisi asiqongelane:MediaWiki message delivery|talk]]) 20:52, 27 Mbimbitho 2025 (SAST)
&lt;!-- Message sent by User:SSethi (WMF)@metawiki using the list at https://meta.wikimedia.org/w/index.php?title=User:SSethi_(WMF)/MassMessageList&amp;oldid=28454981 --&gt;</text>
      <sha1>3hs0tbsr3syfscc5tndkkplcianjn7d</sha1>
    </revision>
    <revision>
      <id>2617</id>
      <parentid>2608</parentid>
      <timestamp>2025-04-02T17:23:29Z</timestamp>
      <contributor>
        <username>SSethi (WMF)</username>
        <id>105</id>
      </contributor>
      <comment>/* Invitation to connect with fellow contributors from language onboarding experiment */ Reply</comment>
      <origin>2617</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2253" sha1="rt1zgzj1g9mqo2ypur2defcy23pcw4c" xml:space="preserve">== Invitation to connect with fellow contributors from language onboarding experiment ==

Hello,

Hope this message finds you well! I would like to invite you to a community conversation to connect with fellow contributors from pilot wikis (Southern Ndebele, Tai Nüa, Iban, Obolo, Pannonian Rusyn) that graduated through a [https://diff.wikimedia.org/2024/10/31/wikipedia-goes-live-for-five-languages-through-the-future-of-language-incubation-initiative/ Language Onboarding Experiment] last year. In this conversation, we plan to facilitate sharing learnings, discussing technical needs post-graduation, and collaborating on solving challenges faced by the pilot wikis.

We spoke with a few contributors from these wikis back in December, and their valuable input on contributions has given us some perspectives on what to investigate next. A report will soon be published on those learnings. We hope that this meeting will not only be a great opportunity for us to come together and learn from each other but also allow us to use your valuable input to shape our plans for the coming year!
If you can attend the call, please sign up here, and I will share more details later:

* [https://www.mediawiki.org/wiki/Language_Onboarding_and_Development/Community_conversations_2024-25#5_April_2025_01:00_UTC 5 April 2025, 01:00 UTC]
* [https://www.mediawiki.org/wiki/Language_Onboarding_and_Development/Community_conversations_2024-25#4_April_2025_15:00_UTC 4 April 2025, 15:00 UTC]

Looking forward to your participation!

Cheers, [[User:SSethi (WMF)]] via [[Umsebenzisi:MediaWiki message delivery|MediaWiki message delivery]] ([[Umsebenzisi asiqongelane:MediaWiki message delivery|talk]]) 20:52, 27 Mbimbitho 2025 (SAST)
&lt;!-- Message sent by User:SSethi (WMF)@metawiki using the list at https://meta.wikimedia.org/w/index.php?title=User:SSethi_(WMF)/MassMessageList&amp;oldid=28454981 --&gt;
:: Hi! If you haven't signed up yet, you can still consider doing so! You can find more information on [[mediawikiwiki:Language_Onboarding_and_Development/Community_conversations_2024-25|this page]] about the upcoming meetings on April 4th and 5th. 
:[[Umsebenzisi:SSethi (WMF)|SSethi (WMF)]] ([[Umsebenzisi asiqongelane:SSethi (WMF)|talk]]) 19:23, 2 Mabasa 2025 (SAST)</text>
      <sha1>rt1zgzj1g9mqo2ypur2defcy23pcw4c</sha1>
    </revision>
    <revision>
      <id>2636</id>
      <parentid>2617</parentid>
      <timestamp>2025-04-03T20:06:07Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>/* Invitation to connect with fellow contributors from language onboarding experiment */ Reply</comment>
      <origin>2636</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2414" sha1="pul02j5l6u75zjzovvd10631wrmfrdp" xml:space="preserve">== Invitation to connect with fellow contributors from language onboarding experiment ==

Hello,

Hope this message finds you well! I would like to invite you to a community conversation to connect with fellow contributors from pilot wikis (Southern Ndebele, Tai Nüa, Iban, Obolo, Pannonian Rusyn) that graduated through a [https://diff.wikimedia.org/2024/10/31/wikipedia-goes-live-for-five-languages-through-the-future-of-language-incubation-initiative/ Language Onboarding Experiment] last year. In this conversation, we plan to facilitate sharing learnings, discussing technical needs post-graduation, and collaborating on solving challenges faced by the pilot wikis.

We spoke with a few contributors from these wikis back in December, and their valuable input on contributions has given us some perspectives on what to investigate next. A report will soon be published on those learnings. We hope that this meeting will not only be a great opportunity for us to come together and learn from each other but also allow us to use your valuable input to shape our plans for the coming year!
If you can attend the call, please sign up here, and I will share more details later:

* [https://www.mediawiki.org/wiki/Language_Onboarding_and_Development/Community_conversations_2024-25#5_April_2025_01:00_UTC 5 April 2025, 01:00 UTC]
* [https://www.mediawiki.org/wiki/Language_Onboarding_and_Development/Community_conversations_2024-25#4_April_2025_15:00_UTC 4 April 2025, 15:00 UTC]

Looking forward to your participation!

Cheers, [[User:SSethi (WMF)]] via [[Umsebenzisi:MediaWiki message delivery|MediaWiki message delivery]] ([[Umsebenzisi asiqongelane:MediaWiki message delivery|talk]]) 20:52, 27 Mbimbitho 2025 (SAST)
&lt;!-- Message sent by User:SSethi (WMF)@metawiki using the list at https://meta.wikimedia.org/w/index.php?title=User:SSethi_(WMF)/MassMessageList&amp;oldid=28454981 --&gt;
:: Hi! If you haven't signed up yet, you can still consider doing so! You can find more information on [[mediawikiwiki:Language_Onboarding_and_Development/Community_conversations_2024-25|this page]] about the upcoming meetings on April 4th and 5th. 
:[[Umsebenzisi:SSethi (WMF)|SSethi (WMF)]] ([[Umsebenzisi asiqongelane:SSethi (WMF)|talk]]) 19:23, 2 Mabasa 2025 (SAST)
:i am interested to join a community conversation. [[Umsebenzisi:Nqobile69|Nqobile69]] ([[Umsebenzisi asiqongelane:Nqobile69|talk]]) 22:06, 3 Mabasa 2025 (SAST)</text>
      <sha1>pul02j5l6u75zjzovvd10631wrmfrdp</sha1>
    </revision>
    <revision>
      <id>2637</id>
      <parentid>2636</parentid>
      <timestamp>2025-04-03T20:09:08Z</timestamp>
      <contributor>
        <username>SSethi (WMF)</username>
        <id>105</id>
      </contributor>
      <comment>/* Invitation to connect with fellow contributors from language onboarding experiment */ Reply</comment>
      <origin>2637</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2595" sha1="2ogubw74fo8oe2bldouu8k4dfcnpl99" xml:space="preserve">== Invitation to connect with fellow contributors from language onboarding experiment ==

Hello,

Hope this message finds you well! I would like to invite you to a community conversation to connect with fellow contributors from pilot wikis (Southern Ndebele, Tai Nüa, Iban, Obolo, Pannonian Rusyn) that graduated through a [https://diff.wikimedia.org/2024/10/31/wikipedia-goes-live-for-five-languages-through-the-future-of-language-incubation-initiative/ Language Onboarding Experiment] last year. In this conversation, we plan to facilitate sharing learnings, discussing technical needs post-graduation, and collaborating on solving challenges faced by the pilot wikis.

We spoke with a few contributors from these wikis back in December, and their valuable input on contributions has given us some perspectives on what to investigate next. A report will soon be published on those learnings. We hope that this meeting will not only be a great opportunity for us to come together and learn from each other but also allow us to use your valuable input to shape our plans for the coming year!
If you can attend the call, please sign up here, and I will share more details later:

* [https://www.mediawiki.org/wiki/Language_Onboarding_and_Development/Community_conversations_2024-25#5_April_2025_01:00_UTC 5 April 2025, 01:00 UTC]
* [https://www.mediawiki.org/wiki/Language_Onboarding_and_Development/Community_conversations_2024-25#4_April_2025_15:00_UTC 4 April 2025, 15:00 UTC]

Looking forward to your participation!

Cheers, [[User:SSethi (WMF)]] via [[Umsebenzisi:MediaWiki message delivery|MediaWiki message delivery]] ([[Umsebenzisi asiqongelane:MediaWiki message delivery|talk]]) 20:52, 27 Mbimbitho 2025 (SAST)
&lt;!-- Message sent by User:SSethi (WMF)@metawiki using the list at https://meta.wikimedia.org/w/index.php?title=User:SSethi_(WMF)/MassMessageList&amp;oldid=28454981 --&gt;
:: Hi! If you haven't signed up yet, you can still consider doing so! You can find more information on [[mediawikiwiki:Language_Onboarding_and_Development/Community_conversations_2024-25|this page]] about the upcoming meetings on April 4th and 5th. 
:[[Umsebenzisi:SSethi (WMF)|SSethi (WMF)]] ([[Umsebenzisi asiqongelane:SSethi (WMF)|talk]]) 19:23, 2 Mabasa 2025 (SAST)
:i am interested to join a community conversation. [[Umsebenzisi:Nqobile69|Nqobile69]] ([[Umsebenzisi asiqongelane:Nqobile69|talk]]) 22:06, 3 Mabasa 2025 (SAST)
::That sounds great! Looking forward to meeting you tomorrow! [[Umsebenzisi:SSethi (WMF)|SSethi (WMF)]] ([[Umsebenzisi asiqongelane:SSethi (WMF)|talk]]) 22:09, 3 Mabasa 2025 (SAST)</text>
      <sha1>2ogubw74fo8oe2bldouu8k4dfcnpl99</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi asiqongelane:Owaziwako</title>
    <ns>3</ns>
    <id>535</id>
    <revision>
      <id>2609</id>
      <timestamp>2025-03-27T18:52:12Z</timestamp>
      <contributor>
        <username>MediaWiki message delivery</username>
        <id>195</id>
      </contributor>
      <comment>/* Invitation to connect with fellow contributors from language onboarding experiment */ new section</comment>
      <origin>2609</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1883" sha1="3hs0tbsr3syfscc5tndkkplcianjn7d" xml:space="preserve">== Invitation to connect with fellow contributors from language onboarding experiment ==

Hello,

Hope this message finds you well! I would like to invite you to a community conversation to connect with fellow contributors from pilot wikis (Southern Ndebele, Tai Nüa, Iban, Obolo, Pannonian Rusyn) that graduated through a [https://diff.wikimedia.org/2024/10/31/wikipedia-goes-live-for-five-languages-through-the-future-of-language-incubation-initiative/ Language Onboarding Experiment] last year. In this conversation, we plan to facilitate sharing learnings, discussing technical needs post-graduation, and collaborating on solving challenges faced by the pilot wikis.

We spoke with a few contributors from these wikis back in December, and their valuable input on contributions has given us some perspectives on what to investigate next. A report will soon be published on those learnings. We hope that this meeting will not only be a great opportunity for us to come together and learn from each other but also allow us to use your valuable input to shape our plans for the coming year!
If you can attend the call, please sign up here, and I will share more details later:

* [https://www.mediawiki.org/wiki/Language_Onboarding_and_Development/Community_conversations_2024-25#5_April_2025_01:00_UTC 5 April 2025, 01:00 UTC]
* [https://www.mediawiki.org/wiki/Language_Onboarding_and_Development/Community_conversations_2024-25#4_April_2025_15:00_UTC 4 April 2025, 15:00 UTC]

Looking forward to your participation!

Cheers, [[User:SSethi (WMF)]] via [[Umsebenzisi:MediaWiki message delivery|MediaWiki message delivery]] ([[Umsebenzisi asiqongelane:MediaWiki message delivery|talk]]) 20:52, 27 Mbimbitho 2025 (SAST)
&lt;!-- Message sent by User:SSethi (WMF)@metawiki using the list at https://meta.wikimedia.org/w/index.php?title=User:SSethi_(WMF)/MassMessageList&amp;oldid=28454981 --&gt;</text>
      <sha1>3hs0tbsr3syfscc5tndkkplcianjn7d</sha1>
    </revision>
    <revision>
      <id>2619</id>
      <parentid>2609</parentid>
      <timestamp>2025-04-02T17:23:54Z</timestamp>
      <contributor>
        <username>SSethi (WMF)</username>
        <id>105</id>
      </contributor>
      <comment>/* Invitation to connect with fellow contributors from language onboarding experiment */ Reply</comment>
      <origin>2619</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2253" sha1="rt1zgzj1g9mqo2ypur2defcy23pcw4c" xml:space="preserve">== Invitation to connect with fellow contributors from language onboarding experiment ==

Hello,

Hope this message finds you well! I would like to invite you to a community conversation to connect with fellow contributors from pilot wikis (Southern Ndebele, Tai Nüa, Iban, Obolo, Pannonian Rusyn) that graduated through a [https://diff.wikimedia.org/2024/10/31/wikipedia-goes-live-for-five-languages-through-the-future-of-language-incubation-initiative/ Language Onboarding Experiment] last year. In this conversation, we plan to facilitate sharing learnings, discussing technical needs post-graduation, and collaborating on solving challenges faced by the pilot wikis.

We spoke with a few contributors from these wikis back in December, and their valuable input on contributions has given us some perspectives on what to investigate next. A report will soon be published on those learnings. We hope that this meeting will not only be a great opportunity for us to come together and learn from each other but also allow us to use your valuable input to shape our plans for the coming year!
If you can attend the call, please sign up here, and I will share more details later:

* [https://www.mediawiki.org/wiki/Language_Onboarding_and_Development/Community_conversations_2024-25#5_April_2025_01:00_UTC 5 April 2025, 01:00 UTC]
* [https://www.mediawiki.org/wiki/Language_Onboarding_and_Development/Community_conversations_2024-25#4_April_2025_15:00_UTC 4 April 2025, 15:00 UTC]

Looking forward to your participation!

Cheers, [[User:SSethi (WMF)]] via [[Umsebenzisi:MediaWiki message delivery|MediaWiki message delivery]] ([[Umsebenzisi asiqongelane:MediaWiki message delivery|talk]]) 20:52, 27 Mbimbitho 2025 (SAST)
&lt;!-- Message sent by User:SSethi (WMF)@metawiki using the list at https://meta.wikimedia.org/w/index.php?title=User:SSethi_(WMF)/MassMessageList&amp;oldid=28454981 --&gt;
:: Hi! If you haven't signed up yet, you can still consider doing so! You can find more information on [[mediawikiwiki:Language_Onboarding_and_Development/Community_conversations_2024-25|this page]] about the upcoming meetings on April 4th and 5th. 
:[[Umsebenzisi:SSethi (WMF)|SSethi (WMF)]] ([[Umsebenzisi asiqongelane:SSethi (WMF)|talk]]) 19:23, 2 Mabasa 2025 (SAST)</text>
      <sha1>rt1zgzj1g9mqo2ypur2defcy23pcw4c</sha1>
    </revision>
    <revision>
      <id>5179</id>
      <parentid>2619</parentid>
      <timestamp>2025-08-15T13:08:24Z</timestamp>
      <contributor>
        <username>Indiphile Ntliziyombi (WMZA)</username>
        <id>512</id>
      </contributor>
      <comment>/* Invitation: Join Us in Celebrating South Africa’s Linguistic Diversity */ new section</comment>
      <origin>5179</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3232" sha1="2o6y9xy4nc48128dkrp3imj1qqjejoy" xml:space="preserve">== Invitation to connect with fellow contributors from language onboarding experiment ==

Hello,

Hope this message finds you well! I would like to invite you to a community conversation to connect with fellow contributors from pilot wikis (Southern Ndebele, Tai Nüa, Iban, Obolo, Pannonian Rusyn) that graduated through a [https://diff.wikimedia.org/2024/10/31/wikipedia-goes-live-for-five-languages-through-the-future-of-language-incubation-initiative/ Language Onboarding Experiment] last year. In this conversation, we plan to facilitate sharing learnings, discussing technical needs post-graduation, and collaborating on solving challenges faced by the pilot wikis.

We spoke with a few contributors from these wikis back in December, and their valuable input on contributions has given us some perspectives on what to investigate next. A report will soon be published on those learnings. We hope that this meeting will not only be a great opportunity for us to come together and learn from each other but also allow us to use your valuable input to shape our plans for the coming year!
If you can attend the call, please sign up here, and I will share more details later:

* [https://www.mediawiki.org/wiki/Language_Onboarding_and_Development/Community_conversations_2024-25#5_April_2025_01:00_UTC 5 April 2025, 01:00 UTC]
* [https://www.mediawiki.org/wiki/Language_Onboarding_and_Development/Community_conversations_2024-25#4_April_2025_15:00_UTC 4 April 2025, 15:00 UTC]

Looking forward to your participation!

Cheers, [[User:SSethi (WMF)]] via [[Umsebenzisi:MediaWiki message delivery|MediaWiki message delivery]] ([[Umsebenzisi asiqongelane:MediaWiki message delivery|talk]]) 20:52, 27 Mbimbitho 2025 (SAST)
&lt;!-- Message sent by User:SSethi (WMF)@metawiki using the list at https://meta.wikimedia.org/w/index.php?title=User:SSethi_(WMF)/MassMessageList&amp;oldid=28454981 --&gt;
:: Hi! If you haven't signed up yet, you can still consider doing so! You can find more information on [[mediawikiwiki:Language_Onboarding_and_Development/Community_conversations_2024-25|this page]] about the upcoming meetings on April 4th and 5th. 
:[[Umsebenzisi:SSethi (WMF)|SSethi (WMF)]] ([[Umsebenzisi asiqongelane:SSethi (WMF)|talk]]) 19:23, 2 Mabasa 2025 (SAST)

== Invitation: Join Us in Celebrating South Africa’s Linguistic Diversity ==

'''Hello fellow Wikipedian!'''

Wikimedia South Africa, in collaboration with the Wikimedia Foundation, is on a mission to create a short video celebrating South Africa’s rich linguistic and cultural diversity. We would like to invite you to take part as an active contributor to one of the South African language Wikipedias.

Through this project, we aim to honour the people who make knowledge in these languages available on Wikipedia, while showcasing the vibrant languages and cultures that shape our nation.

We hope you will join us in this meaningful initiative.

Thank you for your time and for your dedication to making knowledge accessible in South African languages.

Best regards,

'''Wikimedia South Africa''' [[Umsebenzisi:Indiphile Ntliziyombi (WMZA)|Indiphile Ntliziyombi (WMZA)]] ([[Umsebenzisi asiqongelane:Indiphile Ntliziyombi (WMZA)|talk]]) 15:08, 15 Ncwabakazi 2025 (SAST)</text>
      <sha1>2o6y9xy4nc48128dkrp3imj1qqjejoy</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Mr. Ibrahem/1</title>
    <ns>2</ns>
    <id>536</id>
    <revision>
      <id>2610</id>
      <timestamp>2025-03-27T22:22:02Z</timestamp>
      <contributor>
        <username>Mr. Ibrahem</username>
        <id>100</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1274689168|Chibli Mallat]]&quot;</comment>
      <origin>2610</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2" sha1="k1gv11fuxfhxoon8w9pqh7hihq26mvm" xml:space="preserve"> </text>
      <sha1>k1gv11fuxfhxoon8w9pqh7hihq26mvm</sha1>
    </revision>
  </page>
  <page>
    <title>Isivande</title>
    <ns>0</ns>
    <id>537</id>
    <revision>
      <id>2611</id>
      <timestamp>2025-03-31T08:56:28Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Isivande == '''Isivande''' kukulapho umuntu atjalo khona ubuthelo leentjalo, iinthelo, amathuthumbo awathandako bese ayinakelele bona izinto azitjalileko zikghone ukumila&lt;ref&gt;GARDEN | English meaning - Cambridge Dictionary&lt;/ref&gt;. Isivande kuyinto eyathoma ekadeni begodu ngaleso skhathi beyikhombisa ukunotha, ubuhle, Kanye nokuba phezulu.  == Imihlobo yeemvande ==  === Isivande seentjalo === Isivande lesi kukulapho abantu batjala khona iintjalo ezifana nesiphila neziny...&quot;</comment>
      <origin>2611</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3275" sha1="k6c8gyhnuwoaqcuv7e62lqafwa8x9s6" xml:space="preserve">== Isivande ==
'''Isivande''' kukulapho umuntu atjalo khona ubuthelo leentjalo, iinthelo, amathuthumbo awathandako bese ayinakelele bona izinto azitjalileko zikghone ukumila&lt;ref&gt;GARDEN | English meaning - Cambridge Dictionary&lt;/ref&gt;. Isivande kuyinto eyathoma ekadeni begodu ngaleso skhathi beyikhombisa ukunotha, ubuhle, Kanye nokuba phezulu.

== Imihlobo yeemvande ==

=== Isivande seentjalo ===
Isivande lesi kukulapho abantu batjala khona iintjalo ezifana nesiphila nezinye intjalo eziqkathekileko ezidliwa babantu. Lesi sivande esiqakathekileko ebantwini ngombana bakghona ukuthola Ukudla okunepilo kiso. Zoke iinthelo neentjalo eziseentolo zivela esivandeni. 

=== Isivande samathuthumbo ===
Iapho kutholakala amathuthumbo amahle Kanye nemithi. Le kuba yindawo ehle begodu ekghona ukuvakatjhelwa babantu abafuna ukuledlha nokuzithabisa&lt;ref&gt;Majewska, A.A. and Altizer, S., 2020. Planting gardens to support insect pollinators. ''Conservation Biology'', ''34''(1), pp.15-25.&lt;/ref&gt;.

=== Isivande samanzi ===
Isivande samanzi sizele ngezinto zamanzi ezifana namafowuntheni, amaphondi nokunye. Esivandeni lesi kuba yindawo enokuthula. Esivandeni lesi kuba nemihlobo yeentjalo zemanzini ezahlukahlukeneko&lt;ref&gt;Water Gardens: Everything You Need to Know&lt;/ref&gt;

=== Isivande somphakathi ===
Lapho kuba yindawo yomphakathi lapho abantu babelana ngeenqephu esivandeni bese omunye nomunye umntu womphakathi atjele izinto azifunako esiqephini sakhe asabelwe mphakathi. Lo mhlobo wesivande uyawuthuthukisa umphakathi khulu khulu lapho kuhlala khona abantu abadopha phasi&lt;ref name=&quot;:0&quot;&gt;Carney, P.A., Hamada, J.L., Rdesinski, R., Sprager, L., Nichols, K.R., Liu, B.Y., Pelayo, J., Sanchez, M.A. and Shannon, J., 2012. Impact of a community gardening project on vegetable intake, food security and family relationships: a community-based participatory research study. ''Journal of community health'', ''37'', pp.874-881.&lt;/ref&gt;.

== Ukuqakatheka kwesivande ==

=== Umthombo wokudla ===
Isivande siqakatheikile ngombana abantuesivandeni bakghona ukutjhala Ukudla okunepilo njengesiphila, amatapula nokhunye. Lokhu kutjho bona isivande singabalwa njemgomthombo wepilo yabantu lokha nakutjaliweko kiso&lt;ref name=&quot;:0&quot; /&gt;.

=== Ubuhle ===
Isivande kuba yindawo ehle enokuthu lapho abantu bangaledlha khona bazicocele ngandaba zabo badle nokudla ebeze nakho esivandeni. Abanye abantu bakghona ukuthi nabavakatjhele isivande bakhiphe ukugandeleka nokudindwa bese bazithole bathabile.

=== Ukubutha nokuhlanza ibhoduluko ===
Isivande zikghoa ukuthi sibe yindawo yemvelo lapho kuhlala khona iinlwana zemangweni ezifana neenyoni. Esivandeni ngoba kuneentjalo  ihlabathi yakhna iyabulungeka ingakhukhuleki namanzi lokha nakune nkhukhula ngombana ihlabathi ibamba imirabho. Okhunye kukuthi yenza ummoya uhlale uhlanzekile ngombana iintjalo zesivandeni zizokudosa ummoya osiphazekileko&lt;ref&gt;Soga, M., Gaston, K.J. and Yamaura, Y., 2017. Gardening is beneficial for health: A meta-analysis. ''Preventive medicine reports'', ''5'', pp.92-99.&lt;/ref&gt;.

== Isiphetho ==
Isivande kuyinto eqakathekilo emaphilweni wabantu ngombana sithola khona ukudla, ukuthula begodu umuntu angehlisa khona ukugandeleleka. Imihlobo yemvande minengi kodwana yoke iqakathekile ngombana yenza abantu babe nepilo nokuhlala kuhle.</text>
      <sha1>k6c8gyhnuwoaqcuv7e62lqafwa8x9s6</sha1>
    </revision>
    <revision>
      <id>5156</id>
      <parentid>2611</parentid>
      <timestamp>2025-08-13T17:31:25Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5156</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3188" sha1="0hbxw4lgdvf8ae1vracmccty4s7lrla" xml:space="preserve">'''Isivande''' kukulapho umuntu atjalo khona ubuthelo leentjalo, iinthelo, amathuthumbo awathandako bese ayinakelele bona izinto azitjalileko zikghone ukumila&lt;ref&gt;GARDEN | English meaning - Cambridge Dictionary&lt;/ref&gt;. Isivande kuyinto eyathoma ekadeni begodu ngaleso skhathi beyikhombisa ukunotha, ubuhle, Kanye nokuba phezulu.

=== Imihlobo yeemvande ===

==== Isivande seentjalo ====
Isivande lesi kukulapho abantu batjala khona iintjalo ezifana nesiphila nezinye intjalo eziqkathekileko ezidliwa babantu. Lesi sivande esiqakathekileko ebantwini ngombana bakghona ukuthola Ukudla okunepilo kiso. Zoke iinthelo neentjalo eziseentolo zivela esivandeni. 

==== Isivande samathuthumbo ====
Iapho kutholakala amathuthumbo amahle Kanye nemithi. Le kuba yindawo ehle begodu ekghona ukuvakatjhelwa babantu abafuna ukuledlha nokuzithabisa&lt;ref&gt;Majewska, A.A. and Altizer, S., 2020. Planting gardens to support insect pollinators. ''Conservation Biology'', ''34''(1), pp.15-25.&lt;/ref&gt;.

==== Isivande samanzi ====
Isivande samanzi sizele ngezinto zamanzi ezifana namafowuntheni, amaphondi nokunye. Esivandeni lesi kuba yindawo enokuthula. Esivandeni lesi kuba nemihlobo yeentjalo zemanzini ezahlukahlukeneko&lt;ref&gt;Water Gardens: Everything You Need to Know&lt;/ref&gt;

==== Isivande somphakathi ====
Lapho kuba yindawo yomphakathi lapho abantu babelana ngeenqephu esivandeni bese omunye nomunye umntu womphakathi atjele izinto azifunako esiqephini sakhe asabelwe mphakathi. Lo mhlobo wesivande uyawuthuthukisa umphakathi khulu khulu lapho kuhlala khona abantu abadopha phasi&lt;ref name=&quot;:0&quot;&gt;Carney, P.A., Hamada, J.L., Rdesinski, R., Sprager, L., Nichols, K.R., Liu, B.Y., Pelayo, J., Sanchez, M.A. and Shannon, J., 2012. Impact of a community gardening project on vegetable intake, food security and family relationships: a community-based participatory research study. ''Journal of community health'', ''37'', pp.874-881.&lt;/ref&gt;.

=== Ukuqakatheka kwesivande ===
Isivande siqakatheikile ngombana abantu esivandeni bakghona ukutjhala Ukudla okunepilo njengesiphila, amatapula nokhunye. Lokhu kutjho bona isivande singabalwa njemgomthombo wepilo yabantu lokha nakutjaliweko kiso&lt;ref name=&quot;:0&quot; /&gt;.Isivande kuba yindawo ehle enokuthu lapho abantu bangaledlha khona bazicocele ngandaba zabo badle nokudla ebeze nakho esivandeni. Abanye abantu bakghona ukuthi nabavakatjhele isivande bakhiphe ukugandeleka nokudindwa bese bazithole bathabile

Isivande zikghoa ukuthi sibe yindawo yemvelo lapho kuhlala khona iinlwana zemangweni ezifana neenyoni. Esivandeni ngoba kuneentjalo  ihlabathi yakhna iyabulungeka ingakhukhuleki namanzi lokha nakune nkhukhula ngombana ihlabathi ibamba imirabho. Okhunye kukuthi yenza ummoya uhlale uhlanzekile ngombana iintjalo zesivandeni zizokudosa ummoya osiphazekileko&lt;ref&gt;Soga, M., Gaston, K.J. and Yamaura, Y., 2017. Gardening is beneficial for health: A meta-analysis. ''Preventive medicine reports'', ''5'', pp.92-99.&lt;/ref&gt;.Isivande kuyinto eqakathekilo emaphilweni wabantu ngombana sithola khona ukudla, ukuthula begodu umuntu angehlisa khona ukugandeleleka. Imihlobo yemvande minengi kodwana yoke iqakathekile ngombana yenza abantu babe nepilo nokuhlala kuhle.

== Iinkomba ==</text>
      <sha1>0hbxw4lgdvf8ae1vracmccty4s7lrla</sha1>
    </revision>
    <revision>
      <id>5157</id>
      <parentid>5156</parentid>
      <timestamp>2025-08-13T17:33:16Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5157</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3258" sha1="cyhnt0trc7c22fswugq1g7vlu7mtc2w" xml:space="preserve">'''Isivande''' kukulapho umuntu atjalo khona ubuthelo leentjalo, iinthelo, amathuthumbo awathandako bese ayinakelele bona izinto azitjalileko zikghone ukumila&lt;ref&gt;GARDEN | English meaning - Cambridge Dictionary&lt;/ref&gt;. Isivande kuyinto eyathoma ekadeni begodu ngaleso skhathi beyikhombisa ukunotha, ubuhle, Kanye nokuba phezulu.

=== Imihlobo yeemvande ===

==== Isivande seentjalo ====
Isivande lesi kukulapho abantu batjala khona iintjalo ezifana nesiphila nezinye intjalo eziqkathekileko ezidliwa babantu. Lesi sivande esiqakathekileko ebantwini ngombana bakghona ukuthola Ukudla okunepilo kiso. Zoke iinthelo neentjalo eziseentolo zivela esivandeni. 

==== Isivande samathuthumbo ====
Iapho kutholakala amathuthumbo amahle Kanye nemithi. Le kuba yindawo ehle begodu ekghona ukuvakatjhelwa babantu abafuna ukuledlha nokuzithabisa&lt;ref&gt;Majewska, A.A. and Altizer, S., 2020. Planting gardens to support insect pollinators. ''Conservation Biology'', ''34''(1), pp.15-25.&lt;/ref&gt;.

==== Isivande samanzi ====
Isivande samanzi sizele ngezinto zamanzi ezifana namafowuntheni, amaphondi nokunye. Esivandeni lesi kuba yindawo enokuthula. Esivandeni lesi kuba nemihlobo yeentjalo zemanzini ezahlukahlukeneko&lt;ref&gt;Water Gardens: Everything You Need to Know&lt;/ref&gt;

==== Isivande somphakathi ====
Lapho kuba yindawo yomphakathi lapho abantu babelana ngeenqephu esivandeni bese omunye nomunye umntu womphakathi atjele izinto azifunako esiqephini sakhe asabelwe mphakathi. Lo mhlobo wesivande uyawuthuthukisa umphakathi khulu khulu lapho kuhlala khona abantu abadopha phasi&lt;ref name=&quot;:0&quot;&gt;Carney, P.A., Hamada, J.L., Rdesinski, R., Sprager, L., Nichols, K.R., Liu, B.Y., Pelayo, J., Sanchez, M.A. and Shannon, J., 2012. Impact of a community gardening project on vegetable intake, food security and family relationships: a community-based participatory research study. ''Journal of community health'', ''37'', pp.874-881.&lt;/ref&gt;.

=== Ukuqakatheka kwesivande ===
Isivande siqakatheikile ngombana abantu esivandeni bakghona ukutjhala Ukudla okunepilo njengesiphila, amatapula nokhunye. Lokhu kutjho bona isivande singabalwa njemgomthombo wepilo yabantu lokha nakutjaliweko kiso&lt;ref name=&quot;:0&quot; /&gt;.Isivande kuba yindawo ehle enokuthu lapho abantu bangaledlha khona bazicocele ngandaba zabo badle nokudla ebeze nakho esivandeni. Abanye abantu bakghona ukuthi nabavakatjhele isivande bakhiphe ukugandeleka nokudindwa bese bazithole bathabile

Isivande zikghoa ukuthi sibe yindawo yemvelo lapho kuhlala khona iinlwana zemangweni ezifana neenyoni. Esivandeni ngoba kuneentjalo  ihlabathi yakhna iyabulungeka ingakhukhuleki namanzi lokha nakune nkhukhula ngombana ihlabathi ibamba imirabho. Okhunye kukuthi yenza ummoya uhlale uhlanzekile ngombana iintjalo zesivandeni zizokudosa ummoya osiphazekileko&lt;ref&gt;Soga, M., Gaston, K.J. and Yamaura, Y., 2017. Gardening is beneficial for health: A meta-analysis. ''Preventive medicine reports'', ''5'', pp.92-99.&lt;/ref&gt;.Isivande kuyinto eqakathekilo emaphilweni wabantu ngombana sithola khona ukudla, ukuthula begodu umuntu angehlisa khona ukugandeleleka. Imihlobo yemvande minengi kodwana yoke iqakathekile ngombana yenza abantu babe nepilo nokuhlala kuhle.

== Iinkomba ==
[[category:isivande]]
[[Category:amathuthumbo]]
[[category:iintjalo]]</text>
      <sha1>cyhnt0trc7c22fswugq1g7vlu7mtc2w</sha1>
    </revision>
    <revision>
      <id>5161</id>
      <parentid>5157</parentid>
      <timestamp>2025-08-14T14:46:14Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5161</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4405" sha1="ajuuuccxropa1dysx4sevy0xz32o3ag" xml:space="preserve">[[Isimumathi:Red Salvia and Celosia in the flower garden of the Tumuli Park at sunset in Gyeongju South Korea.jpg|thumb|Isivande samathuthumbo]]
'''Isivande''' kukulapho umuntu atjalo khona ubuthelo leentjalo, iinthelo, amathuthumbo awathandako bese ayinakelele bona izinto azitjalileko zikghone ukumila&lt;ref&gt;GARDEN | English meaning - Cambridge Dictionary&lt;/ref&gt;. Isivande kuyinto eyathoma ekadeni begodu ngaleso skhathi beyikhombisa ukunotha, ubuhle, Kanye nokuba phezulu.

=== Imihlobo yeemvande ===

==== Isivande seentjalo ====
Isivande lesi kukulapho abantu batjala khona iintjalo ezifana nesiphila nezinye intjalo eziqkathekileko ezidliwa babantu. Lesi sivande esiqakathekileko ebantwini ngombana bakghona ukuthola Ukudla okunepilo kiso. Zoke iinthelo neentjalo eziseentolo zivela esivandeni. 

==== Isivande samathuthumbo ====
Iapho kutholakala amathuthumbo amahle Kanye nemithi. Le kuba yindawo ehle begodu ekghona ukuvakatjhelwa babantu abafuna ukuledlha nokuzithabisa&lt;ref&gt;Majewska, A.A. and Altizer, S., 2020. Planting gardens to support insect pollinators. ''Conservation Biology'', ''34''(1), pp.15-25.&lt;/ref&gt;.Kusikhala esihleliweko ngaphandle kwendlu sihlelelwe ukukhulisa nokuza amathuthumbo ahlukahlukenoko, itjalo nokhunye. Kuyindawo yemvelo, begodu kuba yinndawo ebonakala iyihle ebantwini abathanda imvelo.Isivande lesi singaba yinto ethekgha ipilo yezinye iinlwanya ezifana neenyosi, amaviyaviyani Kanye neenyoni Ungathola amathuthumbo wemibala ehlukahlukeneko begodu esikwe ngendlela yokurhabisa.

==== Isivande samanzi ====
Isivande samanzi sizele ngezinto zamanzi ezifana namafowuntheni, amaphondi nokunye. Esivandeni lesi kuba yindawo enokuthula. Esivandeni lesi kuba nemihlobo yeentjalo zemanzini ezahlukahlukeneko&lt;ref&gt;Water Gardens: Everything You Need to Know&lt;/ref&gt;Kumhlobo wesivande owenziwe ngezinto ezifuna amanzi ezifana namadamu amancani nofana amafawuntheni, nokhunye. Amanzi wesivandelesi angatheka ipilo yeenlwana eziphila ngamanzi nofana ngemanzini njengemfesi, iinrhwarhwa neenyoni. Abanye abantu bakghona ukwenzela iimphathi zabo endaweni lezi. Ukuzwakala kwetjhada lamanzi kungenza bona umuntu azizwe anokuthula emmoyeni wakhe kwehlise nokugandeleleka.

==== Isivande somphakathi ====
Lapho kuba yindawo yomphakathi lapho abantu babelana ngeenqephu esivandeni bese omunye nomunye umuntu womphakathi atjele izinto azifunako esiqephini sakhe asabelwe mphakathi. Lo mhlobo wesivande uyawuthuthukisa umphakathi khulu khulu lapho kuhlala khona abantu abadopha phasi&lt;ref name=&quot;:0&quot;&gt;Carney, P.A., Hamada, J.L., Rdesinski, R., Sprager, L., Nichols, K.R., Liu, B.Y., Pelayo, J., Sanchez, M.A. and Shannon, J., 2012. Impact of a community gardening project on vegetable intake, food security and family relationships: a community-based participatory research study. ''Journal of community health'', ''37'', pp.874-881.&lt;/ref&gt;.Isivande somphakathi  Sakha ukuzwana nokusebenzisana phakathi kwabantu abatjalako.Abantu basikelana iikhundla nofana amaplot lapho omunye nomunye nomunye azokutjala khona begodu atjale izinto ezithandwa nguye.

=== Ukuqakatheka kwesivande ===
Isivande siqakatheikile ngombana abantu esivandeni bakghona ukutjhala Ukudla okunepilo njengesiphila, amatapula nokhunye. Lokhu kutjho bona isivande singabalwa njemgomthombo wepilo yabantu lokha nakutjaliweko kiso&lt;ref name=&quot;:0&quot; /&gt;.Isivande kuba yindawo ehle enokuthu lapho abantu bangaledlha khona bazicocele ngandaba zabo badle nokudla ebeze nakho esivandeni. Abanye abantu bakghona ukuthi nabavakatjhele isivande bakhiphe ukugandeleka nokudindwa bese bazithole bathabileIsivande zikghoa ukuthi sibe yindawo yemvelo lapho kuhlala khona iinlwana zemangweni ezifana neenyoni. Esivandeni ngoba kuneentjalo  ihlabathi yakhna iyabulungeka ingakhukhuleki namanzi lokha nakune nkhukhula ngombana ihlabathi ibamba imirabho. Okhunye kukuthi yenza ummoya uhlale uhlanzekile ngombana iintjalo zesivandeni zizokudosa ummoya osiphazekileko&lt;ref&gt;Soga, M., Gaston, K.J. and Yamaura, Y., 2017. Gardening is beneficial for health: A meta-analysis. ''Preventive medicine reports'', ''5'', pp.92-99.&lt;/ref&gt;.Isivande kuyinto eqakathekilo emaphilweni wabantu ngombana sithola khona ukudla, ukuthula begodu umuntu angehlisa khona ukugandeleleka. Imihlobo yemvande minengi kodwana yoke iqakathekile ngombana yenza abantu babe nepilo nokuhlala kuhle.

== Iinkomba ==
[[category:isivande]]
[[Category:amathuthumbo]]
[[category:iintjalo]]</text>
      <sha1>ajuuuccxropa1dysx4sevy0xz32o3ag</sha1>
    </revision>
    <revision>
      <id>5162</id>
      <parentid>5161</parentid>
      <timestamp>2025-08-14T14:47:32Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5162</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4765" sha1="tp7i79p5qfp1q2xn1v88dgjih78kcxz" xml:space="preserve">[[Isimumathi:Red Salvia and Celosia in the flower garden of the Tumuli Park at sunset in Gyeongju South Korea.jpg|thumb|Isivande samathuthumbo]]
'''Isivande''' kukulapho umuntu atjalo khona ubuthelo leentjalo, iinthelo, amathuthumbo awathandako bese ayinakelele bona izinto azitjalileko zikghone ukumila&lt;ref&gt;GARDEN | English meaning - Cambridge Dictionary&lt;/ref&gt;. Isivande kuyinto eyathoma ekadeni begodu ngaleso skhathi beyikhombisa ukunotha, ubuhle, Kanye nokuba phezulu.

=== Imihlobo yeemvande ===

==== Isivande seentjalo ====
Isivande lesi kukulapho abantu batjala khona iintjalo ezifana nesiphila nezinye intjalo eziqakathekileko ezidliwa babantu. Lesi sivande esiqakathekileko ebantwini ngombana bakghona ukuthola Ukudla okunepilo kiso. Zoke iinthelo neentjalo eziseentolo zivela esivandeni.Kuyindawa lapho iintjalo zikhuliselwa khona. Singababa sincani sibengaphakathi kwezinto zkutjala nofana sibe sikhulu sivuleke ngaphandle ukuthi  sithole isimo sezulu esitlhogekako. Sinikela Ukudla okunepilo.sifuna ukutlhogonyelwa ukuze  iintjalo zakhona zikhule kuhle, zingotlhogonyelwa ngokuthi zithelelelwe nofana umuntu asuse iinsila ezimila ehlabathini. 

==== Isivande samathuthumbo ====
Iapho kutholakala amathuthumbo amahle Kanye nemithi. Le kuba yindawo ehle begodu ekghona ukuvakatjhelwa babantu abafuna ukuledlha nokuzithabisa&lt;ref&gt;Majewska, A.A. and Altizer, S., 2020. Planting gardens to support insect pollinators. ''Conservation Biology'', ''34''(1), pp.15-25.&lt;/ref&gt;.Kusikhala esihleliweko ngaphandle kwendlu sihlelelwe ukukhulisa nokuza amathuthumbo ahlukahlukenoko, itjalo nokhunye. Kuyindawo yemvelo, begodu kuba yinndawo ebonakala iyihle ebantwini abathanda imvelo.Isivande lesi singaba yinto ethekgha ipilo yezinye iinlwanya ezifana neenyosi, amaviyaviyani Kanye neenyoni Ungathola amathuthumbo wemibala ehlukahlukeneko begodu esikwe ngendlela yokurhabisa.

==== Isivande samanzi ====
Isivande samanzi sizele ngezinto zamanzi ezifana namafowuntheni, amaphondi nokunye. Esivandeni lesi kuba yindawo enokuthula. Esivandeni lesi kuba nemihlobo yeentjalo zemanzini ezahlukahlukeneko&lt;ref&gt;Water Gardens: Everything You Need to Know&lt;/ref&gt;Kumhlobo wesivande owenziwe ngezinto ezifuna amanzi ezifana namadamu amancani nofana amafawuntheni, nokhunye. Amanzi wesivandelesi angatheka ipilo yeenlwana eziphila ngamanzi nofana ngemanzini njengemfesi, iinrhwarhwa neenyoni. Abanye abantu bakghona ukwenzela iimphathi zabo endaweni lezi. Ukuzwakala kwetjhada lamanzi kungenza bona umuntu azizwe anokuthula emmoyeni wakhe kwehlise nokugandeleleka.

==== Isivande somphakathi ====
Lapho kuba yindawo yomphakathi lapho abantu babelana ngeenqephu esivandeni bese omunye nomunye umuntu womphakathi atjele izinto azifunako esiqephini sakhe asabelwe mphakathi. Lo mhlobo wesivande uyawuthuthukisa umphakathi khulu khulu lapho kuhlala khona abantu abadopha phasi&lt;ref name=&quot;:0&quot;&gt;Carney, P.A., Hamada, J.L., Rdesinski, R., Sprager, L., Nichols, K.R., Liu, B.Y., Pelayo, J., Sanchez, M.A. and Shannon, J., 2012. Impact of a community gardening project on vegetable intake, food security and family relationships: a community-based participatory research study. ''Journal of community health'', ''37'', pp.874-881.&lt;/ref&gt;.Isivande somphakathi  Sakha ukuzwana nokusebenzisana phakathi kwabantu abatjalako.Abantu basikelana iikhundla nofana amaplot lapho omunye nomunye nomunye azokutjala khona begodu atjale izinto ezithandwa nguye.

=== Ukuqakatheka kwesivande ===
Isivande siqakatheikile ngombana abantu esivandeni bakghona ukutjhala Ukudla okunepilo njengesiphila, amatapula nokhunye. Lokhu kutjho bona isivande singabalwa njemgomthombo wepilo yabantu lokha nakutjaliweko kiso&lt;ref name=&quot;:0&quot; /&gt;.Isivande kuba yindawo ehle enokuthu lapho abantu bangaledlha khona bazicocele ngandaba zabo badle nokudla ebeze nakho esivandeni. Abanye abantu bakghona ukuthi nabavakatjhele isivande bakhiphe ukugandeleka nokudindwa bese bazithole bathabileIsivande zikghoa ukuthi sibe yindawo yemvelo lapho kuhlala khona iinlwana zemangweni ezifana neenyoni. Esivandeni ngoba kuneentjalo  ihlabathi yakhna iyabulungeka ingakhukhuleki namanzi lokha nakune nkhukhula ngombana ihlabathi ibamba imirabho. Okhunye kukuthi yenza ummoya uhlale uhlanzekile ngombana iintjalo zesivandeni zizokudosa ummoya osiphazekileko&lt;ref&gt;Soga, M., Gaston, K.J. and Yamaura, Y., 2017. Gardening is beneficial for health: A meta-analysis. ''Preventive medicine reports'', ''5'', pp.92-99.&lt;/ref&gt;.Isivande kuyinto eqakathekilo emaphilweni wabantu ngombana sithola khona ukudla, ukuthula begodu umuntu angehlisa khona ukugandeleleka. Imihlobo yemvande minengi kodwana yoke iqakathekile ngombana yenza abantu babe nepilo nokuhlala kuhle.

== Iinkomba ==
[[category:isivande]]
[[Category:amathuthumbo]]
[[category:iintjalo]]</text>
      <sha1>tp7i79p5qfp1q2xn1v88dgjih78kcxz</sha1>
    </revision>
    <revision>
      <id>5163</id>
      <parentid>5162</parentid>
      <timestamp>2025-08-14T14:48:24Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5163</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4769" sha1="thvnkjlj52ydunuv3iirplyrajfkkhh" xml:space="preserve">[[Isimumathi:Red Salvia and Celosia in the flower garden of the Tumuli Park at sunset in Gyeongju South Korea.jpg|thumb|Isivande samathuthumbo]]
'''Isivande''' kukulapho umuntu atjalo khona ubuthelo leentjalo, iinthelo, [[amathuthumbo]] awathandako bese ayinakelele bona izinto azitjalileko zikghone ukumila&lt;ref&gt;GARDEN | English meaning - Cambridge Dictionary&lt;/ref&gt;. Isivande kuyinto eyathoma ekadeni begodu ngaleso skhathi beyikhombisa ukunotha, ubuhle, Kanye nokuba phezulu.

=== Imihlobo yeemvande ===

==== Isivande seentjalo ====
Isivande lesi kukulapho abantu batjala khona iintjalo ezifana nesiphila nezinye intjalo eziqakathekileko ezidliwa babantu. Lesi sivande esiqakathekileko ebantwini ngombana bakghona ukuthola Ukudla okunepilo kiso. Zoke iinthelo neentjalo eziseentolo zivela esivandeni.Kuyindawa lapho iintjalo zikhuliselwa khona. Singababa sincani sibengaphakathi kwezinto zkutjala nofana sibe sikhulu sivuleke ngaphandle ukuthi  sithole isimo sezulu esitlhogekako. Sinikela Ukudla okunepilo.sifuna ukutlhogonyelwa ukuze  iintjalo zakhona zikhule kuhle, zingotlhogonyelwa ngokuthi zithelelelwe nofana umuntu asuse iinsila ezimila ehlabathini. 

==== Isivande samathuthumbo ====
Iapho kutholakala amathuthumbo amahle Kanye nemithi. Le kuba yindawo ehle begodu ekghona ukuvakatjhelwa babantu abafuna ukuledlha nokuzithabisa&lt;ref&gt;Majewska, A.A. and Altizer, S., 2020. Planting gardens to support insect pollinators. ''Conservation Biology'', ''34''(1), pp.15-25.&lt;/ref&gt;.Kusikhala esihleliweko ngaphandle kwendlu sihlelelwe ukukhulisa nokuza amathuthumbo ahlukahlukenoko, itjalo nokhunye. Kuyindawo yemvelo, begodu kuba yinndawo ebonakala iyihle ebantwini abathanda imvelo.Isivande lesi singaba yinto ethekgha ipilo yezinye iinlwanya ezifana neenyosi, amaviyaviyani Kanye neenyoni Ungathola amathuthumbo wemibala ehlukahlukeneko begodu esikwe ngendlela yokurhabisa.

==== Isivande samanzi ====
Isivande samanzi sizele ngezinto zamanzi ezifana namafowuntheni, amaphondi nokunye. Esivandeni lesi kuba yindawo enokuthula. Esivandeni lesi kuba nemihlobo yeentjalo zemanzini ezahlukahlukeneko&lt;ref&gt;Water Gardens: Everything You Need to Know&lt;/ref&gt;Kumhlobo wesivande owenziwe ngezinto ezifuna amanzi ezifana namadamu amancani nofana amafawuntheni, nokhunye. Amanzi wesivandelesi angatheka ipilo yeenlwana eziphila ngamanzi nofana ngemanzini njengemfesi, iinrhwarhwa neenyoni. Abanye abantu bakghona ukwenzela iimphathi zabo endaweni lezi. Ukuzwakala kwetjhada lamanzi kungenza bona umuntu azizwe anokuthula emmoyeni wakhe kwehlise nokugandeleleka.

==== Isivande somphakathi ====
Lapho kuba yindawo yomphakathi lapho abantu babelana ngeenqephu esivandeni bese omunye nomunye umuntu womphakathi atjele izinto azifunako esiqephini sakhe asabelwe mphakathi. Lo mhlobo wesivande uyawuthuthukisa umphakathi khulu khulu lapho kuhlala khona abantu abadopha phasi&lt;ref name=&quot;:0&quot;&gt;Carney, P.A., Hamada, J.L., Rdesinski, R., Sprager, L., Nichols, K.R., Liu, B.Y., Pelayo, J., Sanchez, M.A. and Shannon, J., 2012. Impact of a community gardening project on vegetable intake, food security and family relationships: a community-based participatory research study. ''Journal of community health'', ''37'', pp.874-881.&lt;/ref&gt;.Isivande somphakathi  Sakha ukuzwana nokusebenzisana phakathi kwabantu abatjalako.Abantu basikelana iikhundla nofana amaplot lapho omunye nomunye nomunye azokutjala khona begodu atjale izinto ezithandwa nguye.

=== Ukuqakatheka kwesivande ===
Isivande siqakatheikile ngombana abantu esivandeni bakghona ukutjhala Ukudla okunepilo njengesiphila, amatapula nokhunye. Lokhu kutjho bona isivande singabalwa njemgomthombo wepilo yabantu lokha nakutjaliweko kiso&lt;ref name=&quot;:0&quot; /&gt;.Isivande kuba yindawo ehle enokuthu lapho abantu bangaledlha khona bazicocele ngandaba zabo badle nokudla ebeze nakho esivandeni. Abanye abantu bakghona ukuthi nabavakatjhele isivande bakhiphe ukugandeleka nokudindwa bese bazithole bathabileIsivande zikghoa ukuthi sibe yindawo yemvelo lapho kuhlala khona iinlwana zemangweni ezifana neenyoni. Esivandeni ngoba kuneentjalo  ihlabathi yakhna iyabulungeka ingakhukhuleki namanzi lokha nakune nkhukhula ngombana ihlabathi ibamba imirabho. Okhunye kukuthi yenza ummoya uhlale uhlanzekile ngombana iintjalo zesivandeni zizokudosa ummoya osiphazekileko&lt;ref&gt;Soga, M., Gaston, K.J. and Yamaura, Y., 2017. Gardening is beneficial for health: A meta-analysis. ''Preventive medicine reports'', ''5'', pp.92-99.&lt;/ref&gt;.Isivande kuyinto eqakathekilo emaphilweni wabantu ngombana sithola khona ukudla, ukuthula begodu umuntu angehlisa khona ukugandeleleka. Imihlobo yemvande minengi kodwana yoke iqakathekile ngombana yenza abantu babe nepilo nokuhlala kuhle.

== Iinkomba ==
[[category:isivande]]
[[Category:amathuthumbo]]
[[category:iintjalo]]</text>
      <sha1>thvnkjlj52ydunuv3iirplyrajfkkhh</sha1>
    </revision>
    <revision>
      <id>5164</id>
      <parentid>5163</parentid>
      <timestamp>2025-08-14T14:50:22Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5164</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4771" sha1="1ylseahxrusovedzej2yw0pocjux0ir" xml:space="preserve">[[Isimumathi:Red Salvia and Celosia in the flower garden of the Tumuli Park at sunset in Gyeongju South Korea.jpg|thumb|Isivande samathuthumbo]]
'''Isivande''' kukulapho umuntu atjalo khona ubuthelo leentjalo, iinthelo, [[amathuthumbo]] awathandako bese ayinakelele bona izinto azitjalileko zikghone ukumila.&lt;ref&gt;GARDEN | English meaning - Cambridge Dictionary&lt;/ref&gt; Isivande kuyinto eyathoma ekadeni begodu ngaleso skhathi beyikhombisa ukunotha, ubuhle, Kanye nokuba phezulu.

=== Imihlobo yeemvande ===

==== Isivande seentjalo ====
Isivande lesi kukulapho abantu batjala khona iintjalo ezifana nesiphila nezinye intjalo eziqakathekileko ezidliwa babantu. Lesi sivande esiqakathekileko ebantwini ngombana bakghona ukuthola Ukudla okunepilo kiso. Zoke iinthelo neentjalo eziseentolo zivela esivandeni. Kuyindawa lapho iintjalo zikhuliselwa khona. Singababa sincani sibengaphakathi kwezinto zkutjala nofana sibe sikhulu sivuleke ngaphandle ukuthi  sithole isimo sezulu esitlhogekako. Sinikela Ukudla okunepilo.sifuna ukutlhogonyelwa ukuze  iintjalo zakhona zikhule kuhle, zingotlhogonyelwa ngokuthi zithelelelwe nofana umuntu asuse iinsila ezimila ehlabathini. 

==== Isivande samathuthumbo ====
Iapho kutholakala amathuthumbo amahle Kanye nemithi. Le kuba yindawo ehle begodu ekghona ukuvakatjhelwa babantu abafuna ukuledlha nokuzithabisa.&lt;ref&gt;Majewska, A.A. and Altizer, S., 2020. Planting gardens to support insect pollinators. ''Conservation Biology'', ''34''(1), pp.15-25.&lt;/ref&gt;Kusikhala esihleliweko ngaphandle kwendlu sihlelelwe ukukhulisa nokuza amathuthumbo ahlukahlukenoko, itjalo nokhunye. Kuyindawo yemvelo, begodu kuba yinndawo ebonakala iyihle ebantwini abathanda imvelo.Isivande lesi singaba yinto ethekgha ipilo yezinye iinlwanya ezifana neenyosi, amaviyaviyani Kanye neenyoni Ungathola amathuthumbo wemibala ehlukahlukeneko begodu esikwe ngendlela yokurhabisa.

==== Isivande samanzi ====
Isivande samanzi sizele ngezinto zamanzi ezifana namafowuntheni, amaphondi nokunye. Esivandeni lesi kuba yindawo enokuthula. Esivandeni lesi kuba nemihlobo yeentjalo zemanzini ezahlukahlukeneko.&lt;ref&gt;Water Gardens: Everything You Need to Know&lt;/ref&gt;Kumhlobo wesivande owenziwe ngezinto ezifuna amanzi ezifana namadamu amancani nofana amafawuntheni, nokhunye. Amanzi wesivandelesi angatheka ipilo yeenlwana eziphila ngamanzi nofana ngemanzini njengemfesi, iinrhwarhwa neenyoni. Abanye abantu bakghona ukwenzela iimphathi zabo endaweni lezi. Ukuzwakala kwetjhada lamanzi kungenza bona umuntu azizwe anokuthula emmoyeni wakhe kwehlise nokugandeleleka.

==== Isivande somphakathi ====
Lapho kuba yindawo yomphakathi lapho abantu babelana ngeenqephu esivandeni bese omunye nomunye umuntu womphakathi atjele izinto azifunako esiqephini sakhe asabelwe mphakathi. Lo mhlobo wesivande uyawuthuthukisa umphakathi khulu khulu lapho kuhlala khona abantu abadopha phasi.&lt;ref name=&quot;:0&quot;&gt;Carney, P.A., Hamada, J.L., Rdesinski, R., Sprager, L., Nichols, K.R., Liu, B.Y., Pelayo, J., Sanchez, M.A. and Shannon, J., 2012. Impact of a community gardening project on vegetable intake, food security and family relationships: a community-based participatory research study. ''Journal of community health'', ''37'', pp.874-881.&lt;/ref&gt;Isivande somphakathi  Sakha ukuzwana nokusebenzisana phakathi kwabantu abatjalako.Abantu basikelana iikhundla nofana amaplot lapho omunye nomunye nomunye azokutjala khona begodu atjale izinto ezithandwa nguye.

=== Ukuqakatheka kwesivande ===
Isivande siqakatheikile ngombana abantu esivandeni bakghona ukutjhala Ukudla okunepilo njengesiphila, amatapula nokhunye. Lokhu kutjho bona isivande singabalwa njemgomthombo wepilo yabantu lokha nakutjaliweko kiso.&lt;ref name=&quot;:0&quot; /&gt;Isivande kuba yindawo ehle enokuthu lapho abantu bangaledlha khona bazicocele ngandaba zabo badle nokudla ebeze nakho esivandeni. Abanye abantu bakghona ukuthi nabavakatjhele isivande bakhiphe ukugandeleka nokudindwa bese bazithole bathabileIsivande zikghoa ukuthi sibe yindawo yemvelo lapho kuhlala khona iinlwana zemangweni ezifana neenyoni. Esivandeni ngoba kuneentjalo  ihlabathi yakhna iyabulungeka ingakhukhuleki namanzi lokha nakune nkhukhula ngombana ihlabathi ibamba imirabho. Okhunye kukuthi yenza ummoya uhlale uhlanzekile ngombana iintjalo zesivandeni zizokudosa ummoya osiphazekileko.&lt;ref&gt;Soga, M., Gaston, K.J. and Yamaura, Y., 2017. Gardening is beneficial for health: A meta-analysis. ''Preventive medicine reports'', ''5'', pp.92-99.&lt;/ref&gt;Isivande kuyinto eqakathekilo emaphilweni wabantu ngombana sithola khona ukudla, ukuthula begodu umuntu angehlisa khona ukugandeleleka. Imihlobo yemvande minengi kodwana yoke iqakathekile ngombana yenza abantu babe nepilo nokuhlala kuhle.

== Iinkomba ==
[[category:isivande]]
[[Category:amathuthumbo]]
[[category:iintjalo]]</text>
      <sha1>1ylseahxrusovedzej2yw0pocjux0ir</sha1>
    </revision>
    <revision>
      <id>5165</id>
      <parentid>5164</parentid>
      <timestamp>2025-08-14T14:53:13Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5165</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4933" sha1="0faxyient58vazvtoe38gr12dz92m2o" xml:space="preserve">[[Isimumathi:Red Salvia and Celosia in the flower garden of the Tumuli Park at sunset in Gyeongju South Korea.jpg|thumb|Isivande samathuthumbo]]
'''Isivande''' kukulapho umuntu atjalo khona ubuthelo leentjalo, iinthelo, [[amathuthumbo]] awathandako bese ayinakelele bona izinto azitjalileko zikghone ukumila.&lt;ref&gt;GARDEN | English meaning - Cambridge Dictionary&lt;/ref&gt; Isivande kuyinto eyathoma ekadeni begodu ngaleso skhathi beyikhombisa ukunotha, ubuhle, Kanye nokuba phezulu. kuyindawo enepilo abantu bakghona ukweza isivande ngehloso yokwenza imali nofana ngehloso yokuthi basenze. kuyindawo yemvelo lapho ezinye iinlwana ziphila khona.

=== Imihlobo yeemvande ===

==== Isivande seentjalo ====
Isivande lesi kukulapho abantu batjala khona iintjalo ezifana nesiphila nezinye intjalo eziqakathekileko ezidliwa babantu. Lesi sivande esiqakathekileko ebantwini ngombana bakghona ukuthola Ukudla okunepilo kiso. Zoke iinthelo neentjalo eziseentolo zivela esivandeni. Kuyindawa lapho iintjalo zikhuliselwa khona. Singababa sincani sibengaphakathi kwezinto zkutjala nofana sibe sikhulu sivuleke ngaphandle ukuthi  sithole isimo sezulu esitlhogekako. Sinikela Ukudla okunepilo.sifuna ukutlhogonyelwa ukuze  iintjalo zakhona zikhule kuhle, zingotlhogonyelwa ngokuthi zithelelelwe nofana umuntu asuse iinsila ezimila ehlabathini. 

==== Isivande samathuthumbo ====
Iapho kutholakala amathuthumbo amahle Kanye nemithi. Le kuba yindawo ehle begodu ekghona ukuvakatjhelwa babantu abafuna ukuledlha nokuzithabisa.&lt;ref&gt;Majewska, A.A. and Altizer, S., 2020. Planting gardens to support insect pollinators. ''Conservation Biology'', ''34''(1), pp.15-25.&lt;/ref&gt;Kusikhala esihleliweko ngaphandle kwendlu sihlelelwe ukukhulisa nokuza amathuthumbo ahlukahlukenoko, itjalo nokhunye. Kuyindawo yemvelo, begodu kuba yinndawo ebonakala iyihle ebantwini abathanda imvelo.Isivande lesi singaba yinto ethekgha ipilo yezinye iinlwanya ezifana neenyosi, amaviyaviyani Kanye neenyoni Ungathola amathuthumbo wemibala ehlukahlukeneko begodu esikwe ngendlela yokurhabisa.

==== Isivande samanzi ====
Isivande samanzi sizele ngezinto zamanzi ezifana namafowuntheni, amaphondi nokunye. Esivandeni lesi kuba yindawo enokuthula. Esivandeni lesi kuba nemihlobo yeentjalo zemanzini ezahlukahlukeneko.&lt;ref&gt;Water Gardens: Everything You Need to Know&lt;/ref&gt;Kumhlobo wesivande owenziwe ngezinto ezifuna amanzi ezifana namadamu amancani nofana amafawuntheni, nokhunye. Amanzi wesivandelesi angatheka ipilo yeenlwana eziphila ngamanzi nofana ngemanzini njengemfesi, iinrhwarhwa neenyoni. Abanye abantu bakghona ukwenzela iimphathi zabo endaweni lezi. Ukuzwakala kwetjhada lamanzi kungenza bona umuntu azizwe anokuthula emmoyeni wakhe kwehlise nokugandeleleka.

==== Isivande somphakathi ====
Lapho kuba yindawo yomphakathi lapho abantu babelana ngeenqephu esivandeni bese omunye nomunye umuntu womphakathi atjele izinto azifunako esiqephini sakhe asabelwe mphakathi. Lo mhlobo wesivande uyawuthuthukisa umphakathi khulu khulu lapho kuhlala khona abantu abadopha phasi.&lt;ref name=&quot;:0&quot;&gt;Carney, P.A., Hamada, J.L., Rdesinski, R., Sprager, L., Nichols, K.R., Liu, B.Y., Pelayo, J., Sanchez, M.A. and Shannon, J., 2012. Impact of a community gardening project on vegetable intake, food security and family relationships: a community-based participatory research study. ''Journal of community health'', ''37'', pp.874-881.&lt;/ref&gt;Isivande somphakathi  Sakha ukuzwana nokusebenzisana phakathi kwabantu abatjalako.Abantu basikelana iikhundla nofana amaplot lapho omunye nomunye nomunye azokutjala khona begodu atjale izinto ezithandwa nguye.

=== Ukuqakatheka kwesivande ===
Isivande siqakatheikile ngombana abantu esivandeni bakghona ukutjhala Ukudla okunepilo njengesiphila, amatapula nokhunye. Lokhu kutjho bona isivande singabalwa njemgomthombo wepilo yabantu lokha nakutjaliweko kiso.&lt;ref name=&quot;:0&quot; /&gt;Isivande kuba yindawo ehle enokuthu lapho abantu bangaledlha khona bazicocele ngandaba zabo badle nokudla ebeze nakho esivandeni. Abanye abantu bakghona ukuthi nabavakatjhele isivande bakhiphe ukugandeleka nokudindwa bese bazithole bathabileIsivande zikghoa ukuthi sibe yindawo yemvelo lapho kuhlala khona iinlwana zemangweni ezifana neenyoni. Esivandeni ngoba kuneentjalo  ihlabathi yakhna iyabulungeka ingakhukhuleki namanzi lokha nakune nkhukhula ngombana ihlabathi ibamba imirabho. Okhunye kukuthi yenza ummoya uhlale uhlanzekile ngombana iintjalo zesivandeni zizokudosa ummoya osiphazekileko.&lt;ref&gt;Soga, M., Gaston, K.J. and Yamaura, Y., 2017. Gardening is beneficial for health: A meta-analysis. ''Preventive medicine reports'', ''5'', pp.92-99.&lt;/ref&gt;Isivande kuyinto eqakathekilo emaphilweni wabantu ngombana sithola khona ukudla, ukuthula begodu umuntu angehlisa khona ukugandeleleka. Imihlobo yemvande minengi kodwana yoke iqakathekile ngombana yenza abantu babe nepilo nokuhlala kuhle.

== Iinkomba ==
[[category:isivande]]
[[Category:amathuthumbo]]
[[category:iintjalo]]</text>
      <sha1>0faxyient58vazvtoe38gr12dz92m2o</sha1>
    </revision>
  </page>
  <page>
    <title>Ibulungelo lemali</title>
    <ns>0</ns>
    <id>538</id>
    <revision>
      <id>2612</id>
      <timestamp>2025-03-31T09:15:19Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Ibulungelo lemali == Ibulungelo lemali kuyindawo lapho abantu babeka khona imali yabo ngehloso yokuthi ihlale ibulungekile ingebiwa botsotsi. Indawo lezi abantu bakghona ukuya kizo bayokuboleka imali nafana bayokufaka kizo imali zabo&lt;ref&gt;BANK | English meaning - Cambridge Dictionary&lt;/ref&gt;.  == Umsebenzi webulungelo lemali ==  === Ukuboleka imali === Abantu lokha nabaneedingo zemali enengi, bayakghona ukuthi baye ebulungelweni lemali bayokuboleka iami yokuthi bafez iin...&quot;</comment>
      <origin>2612</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2890" sha1="g3n9uoz0olqu2jdy0qi5ojecjofsnuv" xml:space="preserve">== Ibulungelo lemali ==
Ibulungelo lemali kuyindawo lapho abantu babeka khona imali yabo ngehloso yokuthi ihlale ibulungekile ingebiwa botsotsi. Indawo lezi abantu bakghona ukuya kizo bayokuboleka imali nafana bayokufaka kizo imali zabo&lt;ref&gt;BANK | English meaning - Cambridge Dictionary&lt;/ref&gt;.

== Umsebenzi webulungelo lemali ==

=== Ukuboleka imali ===
Abantu lokha nabaneedingo zemali enengi, bayakghona ukuthi baye ebulungelweni lemali bayokuboleka iami yokuthi bafez iindingo zabe bese babhadele ibulungelo leamli kancani kancani. Lokha baboleka imali kufuze bayibuyisele inamakonyana wakhona phezulu, ngombana lokho kumthetho wokuboleka imali&lt;ref&gt;Schwert, M., 2020. Does borrowing from banks cost more than borrowing from the market?. ''The Journal of Finance'', ''75''(2), pp.905-947.&lt;/ref&gt;. 

=== Ukufaka imali ===
Umuntu lokha nakazibona ukuth unemali enengi ayiphethe kuye uyakghona ukuthi ayiathathe ayoyifaka ebulungweni lemali ngehloso yokuthi ihlale ibulungekile ingetjiwa botsotsi. Abantu abanamabubulo bayakghona nabo ukuthi bathathe inzuzo ebayenze amabubulweni wabo bese bayoyibulunga ukuze bangalingeki bayidle nofana betjelwe yona&lt;ref&gt;Sharman, J.C., 2011. ''The money laundry: Regulating criminal finance in the global economy''. Cornell University Press.&lt;/ref&gt;

=== Ukutjala imali ===
Abanye abantu abanemali bayakghona ukuthatha iimali zabo bayozitjala ebulungelweni lemali bese bazokukghona ukuthola inzuzo. Le into yenziwa babantu ebanemali enengi ngombana lokha nawubuke imali ebulungweli lemali ngehloso yokuyitjala, imali yakho uyikhipha ngemva kwesikhathi eside esibekiweko nakungenzeka bona uyikhiphe ngaphambi kobana isikhathi leso sifike kungagcina sele kudliwa wena imali kunokuthi wenze inzuzo&lt;ref name=&quot;:0&quot;&gt;Finke, M.S., Huston, S.J. and Winchester, D.D., 2011. Financial Advice: Who Pays. ''Journal of Financial Counseling and Planning'', ''22''(1), pp.18-26.&lt;/ref&gt;. 

=== Ukuthumelelana imali lula ===
Esikhathini sanje amabulungelo wemali sele anama-aplikhetjhini enza bona abantu bakghone ukuthumelela imali lula ngaphandle kokuthi baye ebulungelweni lemali. Lokhu kutjho bona abantu bakghona ukuthumelela imali ngananyana kungisiphi isikhathi selanga begodu imali leyi ingathathi isikhathi eside ukufika&lt;ref&gt;Gill, A., 2018. Developing a real-time electronic funds transfer system for credit unions. ''International Journal of Advanced Research in Engineering and Technology (IJARET)'', ''9''(01), pp.162-184.&lt;/ref&gt;.

=== Ukunikela abantu iinluleko ngemali ===
Ebulungelweni lemali abasenzi bayakhona eminye yemisebenzi ebayenzako ukuthi banikele abantu iinluleko zokuthi bayisebenzise njani imali yabo. Lokhu bangakwenza ngokuthi babonise abantu ukuthi bakghona ukuthenga ukufikela kuphi begodu nokuthi bangenzi iinkolodo ezidlula imali ebayitholako ngombana lokho kungenza bona badose emuhlweni lokha nasele babuyisela imali yebhanka&lt;ref name=&quot;:0&quot; /&gt;.</text>
      <sha1>g3n9uoz0olqu2jdy0qi5ojecjofsnuv</sha1>
    </revision>
    <revision>
      <id>2613</id>
      <parentid>2612</parentid>
      <timestamp>2025-03-31T09:18:50Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2613</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2900" sha1="oxme37j2ty89au6pvpzip3rbevvf4nz" xml:space="preserve">== Ibulungelo lemali ==
'''Ibulungelo lemali''' kuyindawo lapho abantu babeka khona [[imali]] yabo ngehloso yokuthi ihlale ibulungekile ingebiwa botsotsi. Indawo lezi abantu bakghona ukuya kizo bayokuboleka imali nafana bayokufaka kizo imali zabo&lt;ref&gt;BANK | English meaning - Cambridge Dictionary&lt;/ref&gt;.

== Umsebenzi webulungelo lemali ==

=== Ukuboleka imali ===
Abantu lokha nabaneedingo zemali enengi, bayakghona ukuthi baye ebulungelweni lemali bayokuboleka iami yokuthi bafez iindingo zabe bese babhadele ibulungelo leamli kancani kancani. Lokha baboleka imali kufuze bayibuyisele inamakonyana wakhona phezulu, ngombana lokho kumthetho wokuboleka imali&lt;ref&gt;Schwert, M., 2020. Does borrowing from banks cost more than borrowing from the market?. ''The Journal of Finance'', ''75''(2), pp.905-947.&lt;/ref&gt;. 

=== Ukufaka imali ===
Umuntu lokha nakazibona ukuth unemali enengi ayiphethe kuye uyakghona ukuthi ayiathathe ayoyifaka ebulungweni lemali ngehloso yokuthi ihlale ibulungekile ingetjiwa botsotsi. Abantu abanamabubulo bayakghona nabo ukuthi bathathe inzuzo ebayenze amabubulweni wabo bese bayoyibulunga ukuze bangalingeki bayidle nofana betjelwe yona&lt;ref&gt;Sharman, J.C., 2011. ''The money laundry: Regulating criminal finance in the global economy''. Cornell University Press.&lt;/ref&gt;

=== Ukutjala imali ===
Abanye abantu abanemali bayakghona ukuthatha iimali zabo bayozitjala ebulungelweni lemali bese bazokukghona ukuthola inzuzo. Le into yenziwa babantu ebanemali enengi ngombana lokha nawubuke imali ebulungweli lemali ngehloso yokuyitjala, imali yakho uyikhipha ngemva kwesikhathi eside esibekiweko nakungenzeka bona uyikhiphe ngaphambi kobana isikhathi leso sifike kungagcina sele kudliwa wena imali kunokuthi wenze inzuzo&lt;ref name=&quot;:0&quot;&gt;Finke, M.S., Huston, S.J. and Winchester, D.D., 2011. Financial Advice: Who Pays. ''Journal of Financial Counseling and Planning'', ''22''(1), pp.18-26.&lt;/ref&gt;. 

=== Ukuthumelelana imali lula ===
Esikhathini sanje amabulungelo wemali sele anama-aplikhetjhini enza bona abantu bakghone ukuthumelela imali lula ngaphandle kokuthi baye ebulungelweni lemali. Lokhu kutjho bona abantu bakghona ukuthumelela imali ngananyana kungisiphi isikhathi selanga begodu imali leyi ingathathi isikhathi eside ukufika&lt;ref&gt;Gill, A., 2018. Developing a real-time electronic funds transfer system for credit unions. ''International Journal of Advanced Research in Engineering and Technology (IJARET)'', ''9''(01), pp.162-184.&lt;/ref&gt;.

=== Ukunikela abantu iinluleko ngemali ===
Ebulungelweni lemali abasenzi bayakhona eminye yemisebenzi ebayenzako ukuthi banikele abantu iinluleko zokuthi bayisebenzise njani imali yabo. Lokhu bangakwenza ngokuthi babonise abantu ukuthi bakghona ukuthenga ukufikela kuphi begodu nokuthi bangenzi iinkolodo ezidlula imali ebayitholako ngombana lokho kungenza bona badose emuhlweni lokha nasele babuyisela imali yebhanka&lt;ref name=&quot;:0&quot; /&gt;.</text>
      <sha1>oxme37j2ty89au6pvpzip3rbevvf4nz</sha1>
    </revision>
    <revision>
      <id>3422</id>
      <parentid>2613</parentid>
      <timestamp>2025-07-12T14:10:22Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3422</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2967" sha1="hk0t5cz7lwr6psenfabulqmpwba6sc6" xml:space="preserve">[[Isimumathi:Capitec 0.png|thumb|Elinye lebungelo lemali eSewula Afrika]]
'''Ibulungelo lemali''' kuyindawo lapho abantu babeka khona [[imali]] yabo ngehloso yokuthi ihlale ibulungekile ingebiwa botsotsi. Indawo lezi abantu bakghona ukuya kizo bayokuboleka imali nafana bayokufaka kizo imali zabo&lt;ref&gt;BANK | English meaning - Cambridge Dictionary&lt;/ref&gt;. 

== Umsebenzi webulungelo lemali ==

=== Ukuboleka imali ===
Abantu lokha nabaneedingo zemali enengi, bayakghona ukuthi baye ebulungelweni lemali bayokuboleka iami yokuthi bafez iindingo zabe bese babhadele ibulungelo leamli kancani kancani. Lokha baboleka imali kufuze bayibuyisele inamakonyana wakhona phezulu, ngombana lokho kumthetho wokuboleka imali.&lt;ref&gt;Schwert, M., 2020. Does borrowing from banks cost more than borrowing from the market?. ''The Journal of Finance'', ''75''(2), pp.905-947.&lt;/ref&gt; 

=== Ukufaka imali ===
Umuntu lokha nakazibona ukuth unemali enengi ayiphethe kuye uyakghona ukuthi ayiathathe ayoyifaka ebulungweni lemali ngehloso yokuthi ihlale ibulungekile ingetjiwa botsotsi. Abantu abanamabubulo bayakghona nabo ukuthi bathathe inzuzo ebayenze amabubulweni wabo bese bayoyibulunga ukuze bangalingeki bayidle nofana betjelwe yona.&lt;ref&gt;Sharman, J.C., 2011. ''The money laundry: Regulating criminal finance in the global economy''. Cornell University Press.&lt;/ref&gt;

=== Ukutjala imali ===
Abanye abantu abanemali bayakghona ukuthatha iimali zabo bayozitjala ebulungelweni lemali bese bazokukghona ukuthola inzuzo. Le into yenziwa babantu ebanemali enengi ngombana lokha nawubuke imali ebulungweli lemali ngehloso yokuyitjala, imali yakho uyikhipha ngemva kwesikhathi eside esibekiweko nakungenzeka bona uyikhiphe ngaphambi kobana isikhathi leso sifike kungagcina sele kudliwa wena imali kunokuthi wenze inzuzo.&lt;ref name=&quot;:0&quot;&gt;Finke, M.S., Huston, S.J. and Winchester, D.D., 2011. Financial Advice: Who Pays. ''Journal of Financial Counseling and Planning'', ''22''(1), pp.18-26.&lt;/ref&gt; 

=== Ukuthumelelana imali lula ===
Esikhathini sanje amabulungelo wemali sele anama-aplikhetjhini enza bona abantu bakghone ukuthumelela imali lula ngaphandle kokuthi baye ebulungelweni lemali. Lokhu kutjho bona abantu bakghona ukuthumelela imali ngananyana kungisiphi isikhathi selanga begodu imali leyi ingathathi isikhathi eside ukufika.&lt;ref&gt;Gill, A., 2018. Developing a real-time electronic funds transfer system for credit unions. ''International Journal of Advanced Research in Engineering and Technology (IJARET)'', ''9''(01), pp.162-184.&lt;/ref&gt;

=== Ukunikela abantu iinluleko ngemali ===
Ebulungelweni lemali abasenzi bayakhona eminye yemisebenzi ebayenzako ukuthi banikele abantu iinluleko zokuthi bayisebenzise njani imali yabo. Lokhu bangakwenza ngokuthi babonise abantu ukuthi bakghona ukuthenga ukufikela kuphi begodu nokuthi bangenzi iinkolodo ezidlula imali ebayitholako ngombana lokho kungenza bona badose emuhlweni lokha nasele babuyisela imali yebhanka.&lt;ref name=&quot;:0&quot; /&gt;

== Inkomba ==</text>
      <sha1>hk0t5cz7lwr6psenfabulqmpwba6sc6</sha1>
    </revision>
    <revision>
      <id>3423</id>
      <parentid>3422</parentid>
      <timestamp>2025-07-12T14:11:35Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3423</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2977" sha1="34oqimzzfg3m3cd6x0n1lv2gwh5hx93" xml:space="preserve">[[Isimumathi:Capitec 0.png|thumb|Elinye lebungelo lemali eSewula Afrika]]
'''Ibulungelo lemali''' kuyindawo lapho abantu babeka khona [[imali]] yabo ngehloso yokuthi ihlale ibulungekile ingebiwa botsotsi. Indawo lezi abantu bakghona ukuya kizo bayokuboleka imali nafana bayokufaka kizo imali zabo&lt;ref&gt;BANK | English meaning - Cambridge Dictionary&lt;/ref&gt;. 

=== Umsebenzi webulungelo lemali ===

==== Ukuboleka imali ====
Abantu lokha nabaneedingo zemali enengi, bayakghona ukuthi baye ebulungelweni lemali bayokuboleka iami yokuthi bafez iindingo zabe bese babhadele ibulungelo leamli kancani kancani. Lokha baboleka imali kufuze bayibuyisele inamakonyana wakhona phezulu, ngombana lokho kumthetho wokuboleka imali.&lt;ref&gt;Schwert, M., 2020. Does borrowing from banks cost more than borrowing from the market?. ''The Journal of Finance'', ''75''(2), pp.905-947.&lt;/ref&gt;

==== Ukufaka imali ====
Umuntu lokha nakazibona ukuth unemali enengi ayiphethe kuye uyakghona ukuthi ayiathathe ayoyifaka ebulungweni lemali ngehloso yokuthi ihlale ibulungekile ingetjiwa botsotsi. Abantu abanamabubulo bayakghona nabo ukuthi bathathe inzuzo ebayenze amabubulweni wabo bese bayoyibulunga ukuze bangalingeki bayidle nofana betjelwe yona.&lt;ref&gt;Sharman, J.C., 2011. ''The money laundry: Regulating criminal finance in the global economy''. Cornell University Press.&lt;/ref&gt;

==== Ukutjala imali ====
Abanye abantu abanemali bayakghona ukuthatha iimali zabo bayozitjala ebulungelweni lemali bese bazokukghona ukuthola inzuzo. Le into yenziwa babantu ebanemali enengi ngombana lokha nawubuke imali ebulungweli lemali ngehloso yokuyitjala, imali yakho uyikhipha ngemva kwesikhathi eside esibekiweko nakungenzeka bona uyikhiphe ngaphambi kobana isikhathi leso sifike kungagcina sele kudliwa wena imali kunokuthi wenze inzuzo.&lt;ref name=&quot;:0&quot;&gt;Finke, M.S., Huston, S.J. and Winchester, D.D., 2011. Financial Advice: Who Pays. ''Journal of Financial Counseling and Planning'', ''22''(1), pp.18-26.&lt;/ref&gt;

==== Ukuthumelelana imali lula ====
Esikhathini sanje amabulungelo wemali sele anama-aplikhetjhini enza bona abantu bakghone ukuthumelela imali lula ngaphandle kokuthi baye ebulungelweni lemali. Lokhu kutjho bona abantu bakghona ukuthumelela imali ngananyana kungisiphi isikhathi selanga begodu imali leyi ingathathi isikhathi eside ukufika.&lt;ref&gt;Gill, A., 2018. Developing a real-time electronic funds transfer system for credit unions. ''International Journal of Advanced Research in Engineering and Technology (IJARET)'', ''9''(01), pp.162-184.&lt;/ref&gt;

==== Ukunikela abantu iinluleko ngemali ====
Ebulungelweni lemali abasenzi bayakhona eminye yemisebenzi ebayenzako ukuthi banikele abantu iinluleko zokuthi bayisebenzise njani imali yabo. Lokhu bangakwenza ngokuthi babonise abantu ukuthi bakghona ukuthenga ukufikela kuphi begodu nokuthi bangenzi iinkolodo ezidlula imali ebayitholako ngombana lokho kungenza bona badose emuhlweni lokha nasele babuyisela imali yebhanka.&lt;ref name=&quot;:0&quot; /&gt;

== Inkomba ==</text>
      <sha1>34oqimzzfg3m3cd6x0n1lv2gwh5hx93</sha1>
    </revision>
  </page>
  <page>
    <title>Amapholisa</title>
    <ns>0</ns>
    <id>539</id>
    <revision>
      <id>2614</id>
      <timestamp>2025-03-31T09:34:34Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Amapholisa == '''Amapholisa''' kubabantu bomthetho abasebenza ukulwisana nobugebengu obukhona emphakathini esihlala kiwo. [[Amapholisa]] weSewula Afrika agcoka ijinifomu ehlaza kwesibhakabhaka&lt;ref&gt;POLICE | English meaning - Cambridge Dictionary&lt;/ref&gt;.   == Umsebenzi wamapholisa ==  === Akubopha iingebengu === Amapholisa asebenza ukubopha iingebengu. Lokha nakungenzeka bona kunomuntu akghona  ongena emzini yabantu nofana eentolo abe izinto ubizelwa amapholisa ukuthi az...&quot;</comment>
      <origin>2614</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2063" sha1="hk84arw9x73p9kcftzy9hr8usfziffb" xml:space="preserve">== Amapholisa ==
'''Amapholisa''' kubabantu bomthetho abasebenza ukulwisana nobugebengu obukhona emphakathini esihlala kiwo. [[Amapholisa]] weSewula Afrika agcoka ijinifomu ehlaza kwesibhakabhaka&lt;ref&gt;POLICE | English meaning - Cambridge Dictionary&lt;/ref&gt;. 

== Umsebenzi wamapholisa ==

=== Akubopha iingebengu ===
Amapholisa asebenza ukubopha iingebengu. Lokha nakungenzeka bona kunomuntu akghona  ongena emzini yabantu nofana eentolo abe izinto ubizelwa amapholisa ukuthi azomthatha ayomvalela ngentronkweni nezinye imbotjhwa.
Ukugadangisa imino
Amanye amapholisa asebenza ukugadangisa imino yokuthi kuyokuhlolwa bona ukuthi umuntu akanawo amacala esele awenzile enarheni aphila kiyo&lt;ref&gt;Telep, C.W. and Weisburd, D., 2012. What is known about the effectiveness of police practices in reducing crime and disorder?. ''Police quarterly'', ''15''(4), pp.331-357.&lt;/ref&gt;.

=== Ukuphenya ===
Abanye basebenza ngokuthi lokha nangabe kunomlandu owenzekileko emphakathini begodu  akwaziwa bonyana wenziwe ngubani, amapholisa la ayaphenya akahambe afuna abantu abanga basolwa ekwenzini umlando loyo. Bayaphenyisisa bekufuke lapho bathola khona isigebengu leso.

=== Ukubhalela abantu ama-afidavidi nokuqinisekisa amaphepha ===
Amanye amapholisa ahlala esitetjhini bese agcwalisele abantu amafidivi ngokwendlela abafuna ngayo. Okhunye baqinisekisa amaphepha akopiweko ngokuwamadanisa nalawo weqiniso bese bawabethe isitempu esitjhoko bona amaphepha akopiweko la ngewiqiniso.

== Iindima edlalwa ampholisa emphakathini ==
Amapholisa adlala indima ekulu emphakathini esiphila kiwo ngombana asenza sisizwe sivikelekile emphakathini esiphila kiwo. Abanye abantu bayabulisa ubulelesi ngesibanga sokuthi basaba amapholisa angabafaka ejele lokha nabalelesileko&lt;ref&gt;Cain, M.E., 2015. ''Society and the Policeman's Role''. Routledge.&lt;/ref&gt;. Uyarhelabha nokuthi abathu bakghone ukuthola ubulungiswa lokha nangebe betjelwe izinto nofana nangabe abantu babulawele ilunga labo lomndeni libulawe mumuntu ebangamaziko. Amapholisa ayarhelebha ukuthi umuntu loyo atholakale bese ayobotjhwa.</text>
      <sha1>hk84arw9x73p9kcftzy9hr8usfziffb</sha1>
    </revision>
    <revision>
      <id>3411</id>
      <parentid>2614</parentid>
      <timestamp>2025-07-12T13:35:26Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3411</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2089" sha1="hq3f0ieufo2w5qm00kr3x94fst3jxqb" xml:space="preserve">== Amapholisa ==
'''Amapholisa''' kubabantu bomthetho abasebenza ukulwisana nobugebengu obukhona emphakathini esihlala kiwo. [[Amapholisa]] weSewula Afrika agcoka ijinifomu ehlaza kwesibhakabhaka&lt;ref&gt;POLICE | English meaning - Cambridge Dictionary&lt;/ref&gt;. 

=== Umsebenzi wamapholisa ===

==== Akubopha iingebengu ====
Amapholisa asebenza ukubopha iingebengu. Lokha nakungenzeka bona kunomuntu akghona  ongena emzini yabantu nofana eentolo abe izinto ubizelwa amapholisa ukuthi azomthatha ayomvalela ngentronkweni nezinye imbotjhwa.
Ukugadangisa imino
Amanye amapholisa asebenza ukugadangisa imino yokuthi kuyokuhlolwa bona ukuthi umuntu akanawo amacala esele awenzile enarheni aphila kiyo&lt;ref&gt;Telep, C.W. and Weisburd, D., 2012. What is known about the effectiveness of police practices in reducing crime and disorder?. ''Police quarterly'', ''15''(4), pp.331-357.&lt;/ref&gt;.

==== Ukuphenya ====
Abanye basebenza ngokuthi lokha nangabe kunomlandu owenzekileko emphakathini begodu  akwaziwa bonyana wenziwe ngubani, amapholisa la ayaphenya akahambe afuna abantu abanga basolwa ekwenzini umlando loyo. Bayaphenyisisa bekufuke lapho bathola khona isigebengu leso.

==== Ukubhalela abantu ama-afidavidi nokuqinisekisa amaphepha ====
Amanye amapholisa ahlala esitetjhini bese agcwalisele abantu amafidivi ngokwendlela abafuna ngayo. Okhunye baqinisekisa amaphepha akopiweko ngokuwamadanisa nalawo weqiniso bese bawabethe isitempu esitjhoko bona amaphepha akopiweko la ngewiqiniso.

=== Iindima edlalwa ampholisa emphakathini ===
Amapholisa adlala indima ekulu emphakathini esiphila kiwo ngombana asenza sisizwe sivikelekile emphakathini esiphila kiwo. Abanye abantu bayabulisa ubulelesi ngesibanga sokuthi basaba amapholisa angabafaka ejele lokha nabalelesileko&lt;ref&gt;Cain, M.E., 2015. ''Society and the Policeman's Role''. Routledge.&lt;/ref&gt;. Uyarhelabha nokuthi abathu bakghone ukuthola ubulungiswa lokha nangebe betjelwe izinto nofana nangabe abantu babulawele ilunga labo lomndeni libulawe mumuntu ebangamaziko. Amapholisa ayarhelebha ukuthi umuntu loyo atholakale bese ayobotjhwa.

== Iinkomba ==</text>
      <sha1>hq3f0ieufo2w5qm00kr3x94fst3jxqb</sha1>
    </revision>
    <revision>
      <id>3412</id>
      <parentid>3411</parentid>
      <timestamp>2025-07-12T13:38:30Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3412</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2165" sha1="db021q1c0wz8evjy237mpi7wb2ir361" xml:space="preserve">== Amapholisa ==
'''Amapholisa''' kubabantu bomthetho abasebenza ukulwisana nobugebengu obukhona emphakathini esihlala kiwo. [[Amapholisa]] weSewula Afrika agcoka ijinifomu ehlaza kwesibhakabhaka&lt;ref&gt;POLICE | English meaning - Cambridge Dictionary&lt;/ref&gt;. 

=== Umsebenzi wamapholisa ===

==== Akubopha iingebengu ====
[[Isimumathi:South african police may 2010.jpg|thumb|Amapholisa asemsebenzini aphethe iingidi]]
Amapholisa asebenza ukubopha iingebengu. Lokha nakungenzeka bona kunomuntu akghona  ongena emzini yabantu nofana eentolo abe izinto ubizelwa amapholisa ukuthi azomthatha ayomvalela ngentronkweni nezinye imbotjhwa.Amanye amapholisa asebenza ukugadangisa imino yokuthi kuyokuhlolwa bona ukuthi umuntu akanawo amacala esele awenzile enarheni aphila kiyo&lt;ref&gt;Telep, C.W. and Weisburd, D., 2012. What is known about the effectiveness of police practices in reducing crime and disorder?. ''Police quarterly'', ''15''(4), pp.331-357.&lt;/ref&gt;.

==== Ukuphenya ====
Abanye basebenza ngokuthi lokha nangabe kunomlandu owenzekileko emphakathini begodu  akwaziwa bonyana wenziwe ngubani, amapholisa la ayaphenya akahambe afuna abantu abanga basolwa ekwenzini umlando loyo. Bayaphenyisisa bekufuke lapho bathola khona isigebengu leso.

==== Ukubhalela abantu ama-afidavidi nokuqinisekisa amaphepha ====
Amanye amapholisa ahlala esitetjhini bese agcwalisele abantu amafidivi ngokwendlela abafuna ngayo. Okhunye baqinisekisa amaphepha akopiweko ngokuwamadanisa nalawo weqiniso bese bawabethe isitempu esitjhoko bona amaphepha akopiweko la ngewiqiniso.

=== Iindima edlalwa ampholisa emphakathini ===
Amapholisa adlala indima ekulu emphakathini esiphila kiwo ngombana asenza sisizwe sivikelekile emphakathini esiphila kiwo. Abanye abantu bayabulisa ubulelesi ngesibanga sokuthi basaba amapholisa angabafaka ejele lokha nabalelesileko&lt;ref&gt;Cain, M.E., 2015. ''Society and the Policeman's Role''. Routledge.&lt;/ref&gt;. Uyarhelabha nokuthi abathu bakghone ukuthola ubulungiswa lokha nangebe betjelwe izinto nofana nangabe abantu babulawele ilunga labo lomndeni libulawe mumuntu ebangamaziko. Amapholisa ayarhelebha ukuthi umuntu loyo atholakale bese ayobotjhwa.

== Iinkomba ==</text>
      <sha1>db021q1c0wz8evjy237mpi7wb2ir361</sha1>
    </revision>
    <revision>
      <id>3435</id>
      <parentid>3412</parentid>
      <timestamp>2025-07-15T11:28:54Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3435</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3369" sha1="98k0tkbduhup9qhvos7ayerjd6t2lm5" xml:space="preserve">== Amapholisa ==
'''Amapholisa''' kubabantu bomthetho abasebenza ukulwisana nobugebengu obukhona emphakathini esihlala kiwo. [[Amapholisa]] weSewula Afrika agcoka ijinifomu ehlaza kwesibhakabhaka.&lt;ref&gt;POLICE | English meaning - Cambridge Dictionary&lt;/ref&gt; 

=== Umsebenzi wamapholisa ===

==== Akubopha iingebengu ====
[[Isimumathi:South african police may 2010.jpg|thumb|Amapholisa asemsebenzini aphethe iingidi]]
Amapholisa asebenza ukubopha iingebengu. Lokha nakungenzeka bona kunomuntu akghona  ongena emzini yabantu nofana eentolo abe izinto ubizelwa amapholisa ukuthi azomthatha ayomvalela ngentronkweni nezinye imbotjhwa.Amanye amapholisa asebenza ukugadangisa imino yokuthi kuyokuhlolwa bona ukuthi umuntu akanawo amacala esele awenzile enarheni aphila kiyo&lt;ref&gt;Telep, C.W. and Weisburd, D., 2012. What is known about the effectiveness of police practices in reducing crime and disorder?. ''Police quarterly'', ''15''(4), pp.331-357.&lt;/ref&gt;.

==== Ukuphenya ====
Abanye basebenza ngokuthi lokha nangabe kunomlandu owenzekileko emphakathini begodu  akwaziwa bonyana wenziwe ngubani, amapholisa la ayaphenya akahambe afuna abantu abanga basolwa ekwenzini umlando loyo. Bayaphenyisisa bekufuke lapho bathola khona isigebengu leso. Amapholisa lokha nakenza irhubhulula athatha amagadango amanengi ukukwenza ukuthi bakghone ukuthi bahlanganise ubufakazi ababutlhogako nokuthi bararulule abamacala alethiweko. Lokho bakweza ngokuthi baye endaweni lapho kwenzeke khona umlando batjhege ukuthi bathola ini engabarheleba ukuthola iinlelesi, babuze abofakazi imibuzo, bese bakhe iqala phezulu kwabasolwa. Nabathole ubufakakzi obaneleko bangabopha abasolwa.

==== Ukubhalela abantu ama-afidavidi nokuqinisekisa amaphepha ====
Amanye amapholisa ahlala esitetjhini bese agcwalisele abantu amafidivi ngokwendlela abafuna ngayo. Okhunye baqinisekisa amaphepha akopiweko ngokuwamadanisa nalawo weqiniso bese bawabethe isitempu esitjhoko bona amaphepha akopiweko la ngewiqiniso. Ukuqinisekisa amaphepha kukulokha umuntu athathe iphela elisithombe salelo eliliqiniso alise emapholiseni bonyana liyokugadangiswa istempu semapholiseni esiqinisekisa bonyana iphela leli ngeleqiniso alisilo lokuzenzela.Amapholisa asebenza ukuqinisekisa amaphepha, loho akwenzela bonyana akghone ukuthi aveze aqinisekise bonyana kumaphepha weqiniso angakenziwa ngobutsosti.&lt;ref&gt;Marković, D.M., 2021. The role and importance of border police in detecting forged documents. ''Nauka idruštvo'', ''8''(1), pp.212-227.&lt;/ref&gt;i-fidavidi kumamezwi wokufunga atlolwe phasi asetjenziswa ukusela into etjhiweko ebantwini bomthetho. Kuyinto engenziwa mapholisa ukuthi bakghone ukuthi bakghone ukuthi bathole ilungelo lokuthi bayoku zuma enzini ingto abayifunako, ingenzelwa nezinye godu iinzathu

=== Iindima edlalwa ampholisa emphakathini ===
Amapholisa adlala indima ekulu emphakathini esiphila kiwo ngombana asenza sisizwe sivikelekile emphakathini esiphila kiwo. Abanye abantu bayabulisa ubulelesi ngesibanga sokuthi basaba amapholisa angabafaka ejele lokha nabalelesileko.&lt;ref&gt;Cain, M.E., 2015. ''Society and the Policeman's Role''. Routledge.&lt;/ref&gt; Uyarhelabha nokuthi abathu bakghone ukuthola ubulungiswa lokha nangebe betjelwe izinto nofana nangabe abantu babulawele ilunga labo lomndeni libulawe mumuntu ebangamaziko. Amapholisa ayarhelebha ukuthi umuntu loyo atholakale bese ayobotjhwa.

== Iinkomba ==</text>
      <sha1>98k0tkbduhup9qhvos7ayerjd6t2lm5</sha1>
    </revision>
    <revision>
      <id>3436</id>
      <parentid>3435</parentid>
      <timestamp>2025-07-15T11:30:10Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3436</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3353" sha1="229tilk3r301bs0sjzyravnmnzzu68k" xml:space="preserve">'''Amapholisa''' kubabantu bomthetho abasebenza ukulwisana nobugebengu obukhona emphakathini esihlala kiwo. [[Amapholisa]] weSewula Afrika agcoka ijinifomu ehlaza kwesibhakabhaka.&lt;ref&gt;POLICE | English meaning - Cambridge Dictionary&lt;/ref&gt;  

=== Umsebenzi wamapholisa ===

==== Akubopha iingebengu ====
[[Isimumathi:South african police may 2010.jpg|thumb|Amapholisa asemsebenzini aphethe iingidi]]
Amapholisa asebenza ukubopha iingebengu. Lokha nakungenzeka bona kunomuntu akghona  ongena emzini yabantu nofana eentolo abe izinto ubizelwa amapholisa ukuthi azomthatha ayomvalela ngentronkweni nezinye imbotjhwa.Amanye amapholisa asebenza ukugadangisa imino yokuthi kuyokuhlolwa bona ukuthi umuntu akanawo amacala esele awenzile enarheni aphila kiyo&lt;ref&gt;Telep, C.W. and Weisburd, D., 2012. What is known about the effectiveness of police practices in reducing crime and disorder?. ''Police quarterly'', ''15''(4), pp.331-357.&lt;/ref&gt;.

==== Ukuphenya ====
Abanye basebenza ngokuthi lokha nangabe kunomlandu owenzekileko emphakathini begodu  akwaziwa bonyana wenziwe ngubani, amapholisa la ayaphenya akahambe afuna abantu abanga basolwa ekwenzini umlando loyo. Bayaphenyisisa bekufuke lapho bathola khona isigebengu leso. Amapholisa lokha nakenza irhubhulula athatha amagadango amanengi ukukwenza ukuthi bakghone ukuthi bahlanganise ubufakazi ababutlhogako nokuthi bararulule abamacala alethiweko. Lokho bakweza ngokuthi baye endaweni lapho kwenzeke khona umlando batjhege ukuthi bathola ini engabarheleba ukuthola iinlelesi, babuze abofakazi imibuzo, bese bakhe iqala phezulu kwabasolwa. Nabathole ubufakakzi obaneleko bangabopha abasolwa.

==== Ukubhalela abantu ama-afidavidi nokuqinisekisa amaphepha ====
Amanye amapholisa ahlala esitetjhini bese agcwalisele abantu amafidivi ngokwendlela abafuna ngayo. Okhunye baqinisekisa amaphepha akopiweko ngokuwamadanisa nalawo weqiniso bese bawabethe isitempu esitjhoko bona amaphepha akopiweko la ngewiqiniso. Ukuqinisekisa amaphepha kukulokha umuntu athathe iphela elisithombe salelo eliliqiniso alise emapholiseni bonyana liyokugadangiswa istempu semapholiseni esiqinisekisa bonyana iphela leli ngeleqiniso alisilo lokuzenzela.Amapholisa asebenza ukuqinisekisa amaphepha, loho akwenzela bonyana akghone ukuthi aveze aqinisekise bonyana kumaphepha weqiniso angakenziwa ngobutsosti.&lt;ref&gt;Marković, D.M., 2021. The role and importance of border police in detecting forged documents. ''Nauka idruštvo'', ''8''(1), pp.212-227.&lt;/ref&gt;i-fidavidi kumamezwi wokufunga atlolwe phasi asetjenziswa ukusela into etjhiweko ebantwini bomthetho. Kuyinto engenziwa mapholisa ukuthi bakghone ukuthi bakghone ukuthi bathole ilungelo lokuthi bayoku zuma enzini ingto abayifunako, ingenzelwa nezinye godu iinzathu

=== Iindima edlalwa ampholisa emphakathini ===
Amapholisa adlala indima ekulu emphakathini esiphila kiwo ngombana asenza sisizwe sivikelekile emphakathini esiphila kiwo. Abanye abantu bayabulisa ubulelesi ngesibanga sokuthi basaba amapholisa angabafaka ejele lokha nabalelesileko.&lt;ref&gt;Cain, M.E., 2015. ''Society and the Policeman's Role''. Routledge.&lt;/ref&gt; Uyarhelabha nokuthi abathu bakghone ukuthola ubulungiswa lokha nangebe betjelwe izinto nofana nangabe abantu babulawele ilunga labo lomndeni libulawe mumuntu ebangamaziko. Amapholisa ayarhelebha ukuthi umuntu loyo atholakale bese ayobotjhwa.

== Iinkomba ==</text>
      <sha1>229tilk3r301bs0sjzyravnmnzzu68k</sha1>
    </revision>
    <revision>
      <id>3437</id>
      <parentid>3436</parentid>
      <timestamp>2025-07-15T11:42:19Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3437</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3664" sha1="hafucrzvaz7l45fthc40w2e84djj7f2" xml:space="preserve">'''Amapholisa''' kubabantu bomthetho abasebenza ukulwisana nobugebengu obukhona emphakathini esihlala kiwo. [[Amapholisa]] weSewula Afrika agcoka ijinifomu ehlaza kwesibhakabhaka.&lt;ref&gt;POLICE | English meaning - Cambridge Dictionary&lt;/ref&gt;  

=== Umsebenzi wamapholisa ===

==== Akubopha iingebengu ====
[[Isimumathi:South african police may 2010.jpg|thumb|Amapholisa asemsebenzini aphethe iingidi]]
Amapholisa asebenza ukubopha iingebengu ngokuhluhlukana kwazo. Lokha nakungenzeka bona kunomuntu akghona ongena emzini yabantu nofana eentolo ebe izinto ubizelwa amapholisa ukuthi azomthatha ayomvalela ejele nezinye imbotjhwa. Amanye amapholisa asebenza ukugadangisa imino ukuthi kuyokuhlolwa bona ukuthi umuntu akanawo amacala esele awenzile enarheni aphila kiyo&lt;ref&gt;Telep, C.W. and Weisburd, D., 2012. What is known about the effectiveness of police practices in reducing crime and disorder?. ''Police quarterly'', ''15''(4), pp.331-357.&lt;/ref&gt;. Amapholisa asebenza imisebenzi eminengi ezintweni eziphathelene nokuqinisa umthetho enarheni le.

==== Ukuphenya ====
Abanye basebenza ngokuthi lokha nangabe kunomlandu owenzekileko emphakathini begodu akwaziwa bonyana wenziwe ngubani, amapholisa la ayaphenya akahambe afuna abantu abanga basolwa ekwenzini umlando loyo. Bayaphenyisisa bekufuke lapho bathola khona isigebengu leso. Amapholisa lokha nakenza irhubhulula athatha amagadango amanengi ukukwenza ukuthi bakghone ukuthi bahlanganise ubufakazi ababutlhogako nokuthi bararulule abamacala alethiweko. Lokho bakweza ngokuthi baye endaweni lapho kwenzeke khona umlando batjhege ukuthi bathola ini engabarheleba ukuthola iinlelesi, babuze abofakazi imibuzo, bese bakhe iqala phezulu kwabasolwa.&lt;ref&gt;Smith, J. and Horne, J.S., 2024. The processing of forensic investigative leads in criminal investigations conducted by the South African police service. ''JH Smith &amp; JS Horne'', pp.284-303.&lt;/ref&gt; Nabathole ubufakakzi obaneleko bangabopha abasolwa.

==== Ukubhalela abantu ama-afidavidi nokuqinisekisa amaphepha ====
Amanye amapholisa ahlala esitetjhini bese agcwalisele abantu amafidivi ngokwendlela abafuna ngayo. Okhunye baqinisekisa amaphepha akopiweko ngokuwamadanisa nalawo weqiniso bese bawabethe isitempu esitjhoko bona amaphepha akopiweko la ngewiqiniso. Ukuqinisekisa amaphepha kukulokha umuntu athathe iphela elisithombe salelo eliliqiniso alise emapholiseni bonyana liyokugadangiswa istempu semapholiseni esiqinisekisa bonyana iphela leli ngeleqiniso alisilo lokuzenzela. Amapholisa asebenza ukuqinisekisa amaphepha, loho akwenzela bonyana akghone ukuthi aveze aqinisekise bonyana kumaphepha weqiniso angakenziwa ngobutsosti.&lt;ref&gt;Marković, D.M., 2021. The role and importance of border police in detecting forged documents. ''Nauka idruštvo'', ''8''(1), pp.212-227.&lt;/ref&gt;i-fidavidi kumamezwi wokufunga atlolwe phasi asetjenziswa ukusela into etjhiweko ebantwini bomthetho. Kuyinto engenziwa mapholisa ukuthi bakghone ukuthi bakghone ukuthi bathole ilungelo lokuthi bayoku zuma enzini ingto abayifunako, ingenzelwa nezinye godu iinzathu

=== Iindima edlalwa ampholisa emphakathini ===
Amapholisa adlala indima ekulu emphakathini esiphila kiwo ngombana asenza sisizwe sivikelekile emphakathini esiphila kiwo. Abanye abantu bayabulisa ubulelesi ngesibanga sokuthi basaba amapholisa angabafaka ejele lokha nabalelesileko.&lt;ref&gt;Cain, M.E., 2015. ''Society and the Policeman's Role''. Routledge.&lt;/ref&gt; Uyarhelabha nokuthi abathu bakghone ukuthola ubulungiswa lokha nangebe betjelwe izinto nofana nangabe abantu babulawele ilunga labo lomndeni libulawe mumuntu ebangamaziko. Amapholisa ayarhelebha ukuthi umuntu loyo atholakale bese ayobotjhwa.

== Iinkomba ==</text>
      <sha1>hafucrzvaz7l45fthc40w2e84djj7f2</sha1>
    </revision>
  </page>
  <page>
    <title>Itatawu</title>
    <ns>0</ns>
    <id>540</id>
    <revision>
      <id>2615</id>
      <timestamp>2025-03-31T09:42:50Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Itatawu == '''Itatawu''' kuyindawo lapho kudlalelwa khona umdlalo&lt;ref&gt;STADIUM | English meaning - Cambridge Dictionary&lt;/ref&gt;. Itatawu kuyindawo yompkhathi ngombana kilo kuhlangana iinkulwangwane zabantu zizokuginding  into yinye bezitjengise nethabo. Itatawu kuyinto eyayikhona ekadeni kodwana nje sele itjengisa ukuthuthuka ngokokwenziwa nangobuhle.  == Imihlobo yama tatawu ==  === Itatawu lomdlalo webholo === Litatawu elenzelwe ukuthi abadlali bakghone ukdalal umdlalo...&quot;</comment>
      <origin>2615</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2119" sha1="dfiz1gmhwfn4g2is40s6wctd7wi063o" xml:space="preserve">== Itatawu ==
'''Itatawu''' kuyindawo lapho kudlalelwa khona umdlalo&lt;ref&gt;STADIUM | English meaning - Cambridge Dictionary&lt;/ref&gt;. Itatawu kuyindawo yompkhathi ngombana kilo kuhlangana iinkulwangwane zabantu zizokuginding  into yinye bezitjengise nethabo. Itatawu kuyinto eyayikhona ekadeni kodwana nje sele itjengisa ukuthuthuka ngokokwenziwa nangobuhle.

== Imihlobo yama tatawu ==

=== Itatawu lomdlalo webholo ===
Litatawu elenzelwe ukuthi abadlali bakghone ukdalal umdlalo webholo, begodu nababukeli nabo bakghone ukubukela ibholo khona. Amatatawu lawa aba makhulu, abangu ncazine ngokubumbeka bese azingezwe zihlalo zababukeli.

=== Itatawu lemisebenzi eminengi ===
Itatawi lemisebenzi eminengi ngileli elikghona ukuthi kwenzeka imisebenzi nofana imidlalo eyahlukahluneko kilo. Isibonelo kungenzela amakhonseti, amafestivali nofana imdlalo kilo. Itatawu leli liba nehlalo ezihlaliseka ngeendlela ezinengi ukuze zikghone ukwamukela ababukeli bento ezabe yenzeka ngesikhathi leso&lt;ref name=&quot;:0&quot;&gt;Hock, C., Ringle, C.M. and Sarstedt, M., 2010. Management of multi-purpose stadiums: Importance and performance measurement of service interfaces. ''International journal of services technology and management'', ''14''(2-3), pp.188-207.&lt;/ref&gt;.

=== Itatawu lomdlalo wama-olympic ===
LItatwu elakhwelwe kuthi kudlalelwe kilo imidlalo yama-olympic. Amatatawu la nawo makhu begodu ngokubumbeka ayindulungu nofana I-ovali, abhodwe ziintulo&lt;ref&gt;Kiuri, M. and Teller, J., 2012. Olympic stadiums in their urban environment: A question of design and cultural significance. ''Journal of Cultural Heritage Management and Sustainable Development'', ''2''(2), pp.115-129.&lt;/ref&gt;.

== Ukuqakatheka kwatatawu ==
Amatatawu aqakathekile kwezomnotho nemphakathini. Amatatawu akghona ukwakha amathuba womsebenzi lokha nawasakhiwako bogodu nalokha nasele akhiwe asetjenziswa. Lokho kutjho bona umnotho wendawo wabantu balapho lakhiwa khona uyathuthuka ngombana abantu bathoila imisebenzi.Abantu bomphakathi bakghona ukuzibandakanyan lapho ngokuthi babambele khona imigidi yabo ukuthuthukisa ukuzwana phakathi kwabantu bendawo&lt;ref name=&quot;:0&quot; /&gt;.</text>
      <sha1>dfiz1gmhwfn4g2is40s6wctd7wi063o</sha1>
    </revision>
    <revision>
      <id>2616</id>
      <parentid>2615</parentid>
      <timestamp>2025-03-31T09:43:59Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2616</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2123" sha1="cmpb0kxos3e12incmp18beksdv9zq44" xml:space="preserve">== Itatawu ==
'''Itatawu''' kuyindawo lapho kudlalelwa khona umdlalo&lt;ref&gt;STADIUM | English meaning - Cambridge Dictionary&lt;/ref&gt;. Itatawu kuyindawo yomphakathi ngombana kilo kuhlangana iinkulwangwane zabantu zizokugidinag  into yinye bezitjengise nethabo. Itatawu kuyinto eyayikhona ekadeni kodwana nje sele itjengisa ukuthuthuka ngokokwenziwa nangobuhle.

== Imihlobo yama tatawu ==

=== Itatawu lomdlalo webholo ===
Litatawu elenzelwe ukuthi abadlali bakghone ukdala umdlalo webholo, begodu nababukeli nabo bakghone ukubukela [[ibholo]] khona. Amatatawu lawa aba makhulu, abangu ncazine ngokubumbeka bese azingezwe zihlalo zababukeli.

=== Itatawu lemisebenzi eminengi ===
Itatawi lemisebenzi eminengi ngileli elikghona ukuthi kwenzeka imisebenzi nofana imidlalo eyahlukahluneko kilo. Isibonelo kungenzela amakhonseti, amafestivali nofana imdlalo kilo. Itatawu leli liba nehlalo ezihlaliseka ngeendlela ezinengi ukuze zikghone ukwamukela ababukeli bento ezabe yenzeka ngesikhathi leso&lt;ref name=&quot;:0&quot;&gt;Hock, C., Ringle, C.M. and Sarstedt, M., 2010. Management of multi-purpose stadiums: Importance and performance measurement of service interfaces. ''International journal of services technology and management'', ''14''(2-3), pp.188-207.&lt;/ref&gt;.

=== Itatawu lomdlalo wama-olympic ===
LItatwu elakhwelwe kuthi kudlalelwe kilo imidlalo yama-olympic. Amatatawu la nawo makhu begodu ngokubumbeka ayindulungu nofana I-ovali, abhodwe ziintulo&lt;ref&gt;Kiuri, M. and Teller, J., 2012. Olympic stadiums in their urban environment: A question of design and cultural significance. ''Journal of Cultural Heritage Management and Sustainable Development'', ''2''(2), pp.115-129.&lt;/ref&gt;.

== Ukuqakatheka kwatatawu ==
Amatatawu aqakathekile kwezomnotho nemphakathini. Amatatawu akghona ukwakha amathuba womsebenzi lokha nawasakhiwako bogodu nalokha nasele akhiwe asetjenziswa. Lokho kutjho bona umnotho wendawo wabantu balapho lakhiwa khona uyathuthuka ngombana abantu bathoila imisebenzi.Abantu bomphakathi bakghona ukuzibandakanyan lapho ngokuthi babambele khona imigidi yabo ukuthuthukisa ukuzwana phakathi kwabantu bendawo&lt;ref name=&quot;:0&quot; /&gt;.</text>
      <sha1>cmpb0kxos3e12incmp18beksdv9zq44</sha1>
    </revision>
  </page>
  <page>
    <title>UbulungiswaKwakaCwecwe</title>
    <ns>0</ns>
    <id>541</id>
    <revision>
      <id>2621</id>
      <timestamp>2025-04-03T12:57:15Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1283489504|JusticeForCwecwe]]&quot;</comment>
      <origin>2621</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="416" sha1="1zidxaxp6pkvy0vdwoanvewgc22o3y7" xml:space="preserve">
'''#UbulungiswaKwakaCwecwe''' mkhankaso weendaba zomphakathi weSewula Afrika kanye nomnyakazo womphakathi owavela ngemva kokuhlaselwa komntazanyana oneminyaka elikhomba, owaziwa ngegama lakaCwecwe, e-Bergview College,   isikolo sangeqadi e- Matatiele, e-Eastern Cape, [[Isewula Afrika|eSewula Afrika]] . Ijimeli lifuna ubulungiswa kumhlukunyezwa, lifuna ukuziphendulela esikolweni neemphathisweni ezibandakanyekako.</text>
      <sha1>1zidxaxp6pkvy0vdwoanvewgc22o3y7</sha1>
    </revision>
  </page>
  <page>
    <title>Ukurhulula umbungu</title>
    <ns>0</ns>
    <id>542</id>
    <revision>
      <id>2638</id>
      <timestamp>2025-04-04T08:51:03Z</timestamp>
      <contributor>
        <ip>192.143.110.248</ip>
      </contributor>
      <comment>Created page with &quot;Ukurhulula umbungu   Ukurhulula umbungu kukulokha umuntu wengubo nakazithweleko bese athathe isiqunto sokabana akafuni ukuba nomntwana bese akhuphe umtwana amthweleko&lt;ref&gt;https://www.merriam-webster.com/dictionary/abortion&lt;/ref&gt;. Ukurhulula umbungu kuyinto esemthethweni enarheni yeSewula Afrika, ngombana kuthiwa umuntu unelungelo lokuzikhethela bona wenzakalani emzimbeni wakhe. Imibono eyahlukileko ngokurhulula umbungu Ukurhululula umbungu kuyisihloko esingabanga ukuphik...&quot;</comment>
      <origin>2638</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2610" sha1="bqj49a0ftx70yhzv9qapo23vkre2ytu" xml:space="preserve">Ukurhulula umbungu 

Ukurhulula umbungu kukulokha umuntu wengubo nakazithweleko bese athathe isiqunto sokabana akafuni ukuba nomntwana bese akhuphe umtwana amthweleko&lt;ref&gt;https://www.merriam-webster.com/dictionary/abortion&lt;/ref&gt;. Ukurhulula umbungu kuyinto esemthethweni enarheni yeSewula Afrika, ngombana kuthiwa umuntu unelungelo lokuzikhethela bona wenzakalani emzimbeni wakhe.
Imibono eyahlukileko ngokurhulula umbungu
Ukurhululula umbungu kuyisihloko esingabanga ukuphikisana phakathi kwabantu ngombana abantu banemibono eminengi eyahlukeneko. Abanye babona kuyinto ehle efanele yenziwe babantu. Kuthi abanye abantu babone kuyinto embi enesihlungu engenziwako. Omunye nomunye umuntu wengubo wenza okubonwa nguye nakafika kulobujamo ngombana ukurhulula umbungu kuyinto esemthethweni eSewula Afrika. 

Abavumelana nakho 

Abavumelana nokurhulula umbungu bathi kuyinto ehle khulu khulu lokha nangabe umma ukatiwe wagcina sele azithwele Umntwana ngokatwa, nofana kilabo bantu abanokugula ukungabafaka engozini yokufa lokha nabasidisi. Ngalezi inzathu eziveziweko babona ukuthi ukurhulula umbungu akusiyo into embi ngombana umu ntu akukafaneli abe nomtwnan angafuni nofana amthole ngesibanga sesehlakalo esimbi esifana nokukatwa&lt;ref name=&quot;:0&quot;&gt;https://www.britannica.com/procon/abortion-debate&lt;/ref&gt;. 

Abaphikisana nakho 

Abanye abantu bayaphikisa bathi ukuehulula umbung yinto embi ngombana lokha wenza into le ukhipha umphefumulo womntwana onganacala. Godu baphikisa ngokuthi ukurhulula umbungu akusikuhle ngombana lokha nawukwenzileko ipilo yakho ingakhubazeka njengokuthu umma angasakghoni ukuba nabanye abantwana.  Umunye agcine sele ahla emzimbeni ngombana ahlala ngakajabuli anokuzisola&lt;ref name=&quot;:0&quot; /&gt;&lt;ref&gt;https://www.bbc.co.uk/bitesize/guides/zhbqf4j/revision/4&lt;/ref&gt;. 

Imiphumela yokurhulula umbungu 

Umuntu orhulule umbungu angagcina ahlulwa kuzilibalela ngesenzo asenzileko lokha nakabona abantu bona bayamahlulela ngesenzo lesi asenzileko. Angazibona alihlazo emphakathini aphila kiwo ngombana kwamanye amasiko namakhaya ayenziwa into leyo. Ukurhulula umbungu kungaletha ukwahlukana phakathi kwabantu abathandanako lokha nangabe into le yenzeke bangaka vumelani njengenthandani&lt;ref&gt;https://www.worldpulse.org/es/story/the-impact-of-abortion-bans-on-womens-mental-health-61476?gad_source=1&amp;gclid=EAIaIQobChMIg4TQx_-9jAMVOIBQBh3PljsEEAAYASAAEgLgYvD_BwE&lt;/ref&gt;. 

Isiphetho 

Ukurhulula umbungu kuyinto abantu abayicala ngeendlea ezinengi ezahlukileko. Abanye bayayamukela abanye bayayiohikisa. Woke umuntu wengubo kufanele enze lokhu ekuzomenza bona akghone ukuragela phambili kuhle nepilo yakhe.</text>
      <sha1>bqj49a0ftx70yhzv9qapo23vkre2ytu</sha1>
    </revision>
    <revision>
      <id>2969</id>
      <parentid>2638</parentid>
      <timestamp>2025-06-06T20:00:06Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>thbgrvfecdwsxa</comment>
      <origin>2969</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2700" sha1="r4p4m5pfcvcpst5m67435cxb4erbej4" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.u''' 

Ukurhulula umbungu 

Ukurhulula umbungu kukulokha umuntu wengubo nakazithweleko bese athathe isiqunto sokabana akafuni ukuba nomntwana bese akhuphe umtwana amthweleko&lt;ref&gt;https://www.merriam-webster.com/dictionary/abortion&lt;/ref&gt;. Ukurhulula umbungu kuyinto esemthethweni enarheni yeSewula Afrika, ngombana kuthiwa umuntu unelungelo lokuzikhethela bona wenzakalani emzimbeni wakhe.
Imibono eyahlukileko ngokurhulula umbungu
Ukurhululula umbungu kuyisihloko esingabanga ukuphikisana phakathi kwabantu ngombana abantu banemibono eminengi eyahlukeneko. Abanye babona kuyinto ehle efanele yenziwe babantu. Kuthi abanye abantu babone kuyinto embi enesihlungu engenziwako. Omunye nomunye umuntu wengubo wenza okubonwa nguye nakafika kulobujamo ngombana ukurhulula umbungu kuyinto esemthethweni eSewula Afrika. 

Abavumelana nakho 

Abavumelana nokurhulula umbungu bathi kuyinto ehle khulu khulu lokha nangabe umma ukatiwe wagcina sele azithwele Umntwana ngokatwa, nofana kilabo bantu abanokugula ukungabafaka engozini yokufa lokha nabasidisi. Ngalezi inzathu eziveziweko babona ukuthi ukurhulula umbungu akusiyo into embi ngombana umu ntu akukafaneli abe nomtwnan angafuni nofana amthole ngesibanga sesehlakalo esimbi esifana nokukatwa&lt;ref name=&quot;:0&quot;&gt;https://www.britannica.com/procon/abortion-debate&lt;/ref&gt;. 

Abaphikisana nakho 

Abanye abantu bayaphikisa bathi ukuehulula umbung yinto embi ngombana lokha wenza into le ukhipha umphefumulo womntwana onganacala. Godu baphikisa ngokuthi ukurhulula umbungu akusikuhle ngombana lokha nawukwenzileko ipilo yakho ingakhubazeka njengokuthu umma angasakghoni ukuba nabanye abantwana.  Umunye agcine sele ahla emzimbeni ngombana ahlala ngakajabuli anokuzisola&lt;ref name=&quot;:0&quot; /&gt;&lt;ref&gt;https://www.bbc.co.uk/bitesize/guides/zhbqf4j/revision/4&lt;/ref&gt;. 

Imiphumela yokurhulula umbungu 

Umuntu orhulule umbungu angagcina ahlulwa kuzilibalela ngesenzo asenzileko lokha nakabona abantu bona bayamahlulela ngesenzo lesi asenzileko. Angazibona alihlazo emphakathini aphila kiwo ngombana kwamanye amasiko namakhaya ayenziwa into leyo. Ukurhulula umbungu kungaletha ukwahlukana phakathi kwabantu abathandanako lokha nangabe into le yenzeke bangaka vumelani njengenthandani&lt;ref&gt;https://www.worldpulse.org/es/story/the-impact-of-abortion-bans-on-womens-mental-health-61476?gad_source=1&amp;gclid=EAIaIQobChMIg4TQx_-9jAMVOIBQBh3PljsEEAAYASAAEgLgYvD_BwE&lt;/ref&gt;. 

Isiphetho 

Ukurhulula umbungu kuyinto abantu abayicala ngeendlea ezinengi ezahlukileko. Abanye bayayamukela abanye bayayiohikisa. Woke umuntu wengubo kufanele enze lokhu ekuzomenza bona akghone ukuragela phambili kuhle nepilo yakhe.</text>
      <sha1>r4p4m5pfcvcpst5m67435cxb4erbej4</sha1>
    </revision>
    <revision>
      <id>2970</id>
      <parentid>2969</parentid>
      <timestamp>2025-06-06T20:00:29Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>ujytg</comment>
      <origin>2970</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2700" sha1="8h8rfhv9ns7hptcmp6ertafeghn2p8x" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.'''  

Ukurhulula umbungu 

Ukurhulula umbungu kukulokha umuntu wengubo nakazithweleko bese athathe isiqunto sokabana akafuni ukuba nomntwana bese akhuphe umtwana amthweleko&lt;ref&gt;https://www.merriam-webster.com/dictionary/abortion&lt;/ref&gt;. Ukurhulula umbungu kuyinto esemthethweni enarheni yeSewula Afrika, ngombana kuthiwa umuntu unelungelo lokuzikhethela bona wenzakalani emzimbeni wakhe.
Imibono eyahlukileko ngokurhulula umbungu
Ukurhululula umbungu kuyisihloko esingabanga ukuphikisana phakathi kwabantu ngombana abantu banemibono eminengi eyahlukeneko. Abanye babona kuyinto ehle efanele yenziwe babantu. Kuthi abanye abantu babone kuyinto embi enesihlungu engenziwako. Omunye nomunye umuntu wengubo wenza okubonwa nguye nakafika kulobujamo ngombana ukurhulula umbungu kuyinto esemthethweni eSewula Afrika. 

Abavumelana nakho 

Abavumelana nokurhulula umbungu bathi kuyinto ehle khulu khulu lokha nangabe umma ukatiwe wagcina sele azithwele Umntwana ngokatwa, nofana kilabo bantu abanokugula ukungabafaka engozini yokufa lokha nabasidisi. Ngalezi inzathu eziveziweko babona ukuthi ukurhulula umbungu akusiyo into embi ngombana umu ntu akukafaneli abe nomtwnan angafuni nofana amthole ngesibanga sesehlakalo esimbi esifana nokukatwa&lt;ref name=&quot;:0&quot;&gt;https://www.britannica.com/procon/abortion-debate&lt;/ref&gt;. 

Abaphikisana nakho 

Abanye abantu bayaphikisa bathi ukuehulula umbung yinto embi ngombana lokha wenza into le ukhipha umphefumulo womntwana onganacala. Godu baphikisa ngokuthi ukurhulula umbungu akusikuhle ngombana lokha nawukwenzileko ipilo yakho ingakhubazeka njengokuthu umma angasakghoni ukuba nabanye abantwana.  Umunye agcine sele ahla emzimbeni ngombana ahlala ngakajabuli anokuzisola&lt;ref name=&quot;:0&quot; /&gt;&lt;ref&gt;https://www.bbc.co.uk/bitesize/guides/zhbqf4j/revision/4&lt;/ref&gt;. 

Imiphumela yokurhulula umbungu 

Umuntu orhulule umbungu angagcina ahlulwa kuzilibalela ngesenzo asenzileko lokha nakabona abantu bona bayamahlulela ngesenzo lesi asenzileko. Angazibona alihlazo emphakathini aphila kiwo ngombana kwamanye amasiko namakhaya ayenziwa into leyo. Ukurhulula umbungu kungaletha ukwahlukana phakathi kwabantu abathandanako lokha nangabe into le yenzeke bangaka vumelani njengenthandani&lt;ref&gt;https://www.worldpulse.org/es/story/the-impact-of-abortion-bans-on-womens-mental-health-61476?gad_source=1&amp;gclid=EAIaIQobChMIg4TQx_-9jAMVOIBQBh3PljsEEAAYASAAEgLgYvD_BwE&lt;/ref&gt;. 

Isiphetho 

Ukurhulula umbungu kuyinto abantu abayicala ngeendlea ezinengi ezahlukileko. Abanye bayayamukela abanye bayayiohikisa. Woke umuntu wengubo kufanele enze lokhu ekuzomenza bona akghone ukuragela phambili kuhle nepilo yakhe.</text>
      <sha1>8h8rfhv9ns7hptcmp6ertafeghn2p8x</sha1>
    </revision>
    <revision>
      <id>3076</id>
      <parentid>2970</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edits by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:192.143.110.248|192.143.110.248]]</comment>
      <origin>2638</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2610" sha1="bqj49a0ftx70yhzv9qapo23vkre2ytu" xml:space="preserve">Ukurhulula umbungu 

Ukurhulula umbungu kukulokha umuntu wengubo nakazithweleko bese athathe isiqunto sokabana akafuni ukuba nomntwana bese akhuphe umtwana amthweleko&lt;ref&gt;https://www.merriam-webster.com/dictionary/abortion&lt;/ref&gt;. Ukurhulula umbungu kuyinto esemthethweni enarheni yeSewula Afrika, ngombana kuthiwa umuntu unelungelo lokuzikhethela bona wenzakalani emzimbeni wakhe.
Imibono eyahlukileko ngokurhulula umbungu
Ukurhululula umbungu kuyisihloko esingabanga ukuphikisana phakathi kwabantu ngombana abantu banemibono eminengi eyahlukeneko. Abanye babona kuyinto ehle efanele yenziwe babantu. Kuthi abanye abantu babone kuyinto embi enesihlungu engenziwako. Omunye nomunye umuntu wengubo wenza okubonwa nguye nakafika kulobujamo ngombana ukurhulula umbungu kuyinto esemthethweni eSewula Afrika. 

Abavumelana nakho 

Abavumelana nokurhulula umbungu bathi kuyinto ehle khulu khulu lokha nangabe umma ukatiwe wagcina sele azithwele Umntwana ngokatwa, nofana kilabo bantu abanokugula ukungabafaka engozini yokufa lokha nabasidisi. Ngalezi inzathu eziveziweko babona ukuthi ukurhulula umbungu akusiyo into embi ngombana umu ntu akukafaneli abe nomtwnan angafuni nofana amthole ngesibanga sesehlakalo esimbi esifana nokukatwa&lt;ref name=&quot;:0&quot;&gt;https://www.britannica.com/procon/abortion-debate&lt;/ref&gt;. 

Abaphikisana nakho 

Abanye abantu bayaphikisa bathi ukuehulula umbung yinto embi ngombana lokha wenza into le ukhipha umphefumulo womntwana onganacala. Godu baphikisa ngokuthi ukurhulula umbungu akusikuhle ngombana lokha nawukwenzileko ipilo yakho ingakhubazeka njengokuthu umma angasakghoni ukuba nabanye abantwana.  Umunye agcine sele ahla emzimbeni ngombana ahlala ngakajabuli anokuzisola&lt;ref name=&quot;:0&quot; /&gt;&lt;ref&gt;https://www.bbc.co.uk/bitesize/guides/zhbqf4j/revision/4&lt;/ref&gt;. 

Imiphumela yokurhulula umbungu 

Umuntu orhulule umbungu angagcina ahlulwa kuzilibalela ngesenzo asenzileko lokha nakabona abantu bona bayamahlulela ngesenzo lesi asenzileko. Angazibona alihlazo emphakathini aphila kiwo ngombana kwamanye amasiko namakhaya ayenziwa into leyo. Ukurhulula umbungu kungaletha ukwahlukana phakathi kwabantu abathandanako lokha nangabe into le yenzeke bangaka vumelani njengenthandani&lt;ref&gt;https://www.worldpulse.org/es/story/the-impact-of-abortion-bans-on-womens-mental-health-61476?gad_source=1&amp;gclid=EAIaIQobChMIg4TQx_-9jAMVOIBQBh3PljsEEAAYASAAEgLgYvD_BwE&lt;/ref&gt;. 

Isiphetho 

Ukurhulula umbungu kuyinto abantu abayicala ngeendlea ezinengi ezahlukileko. Abanye bayayamukela abanye bayayiohikisa. Woke umuntu wengubo kufanele enze lokhu ekuzomenza bona akghone ukuragela phambili kuhle nepilo yakhe.</text>
      <sha1>bqj49a0ftx70yhzv9qapo23vkre2ytu</sha1>
    </revision>
    <revision>
      <id>3189</id>
      <parentid>3076</parentid>
      <timestamp>2025-06-21T19:14:52Z</timestamp>
      <contributor>
        <ip>85.97.84.231</ip>
      </contributor>
      <origin>3189</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2721" sha1="9atcut6ilhl8lzdx5ftc3kxll7chzt3" xml:space="preserve">[[File:Common chimpanzee (Pan troglodytes schweinfurthii) feeding.jpg|thumb|Omar al-Bashir is a chimpanzee.]]

Ukurhulula umbungu 

Ukurhulula umbungu kukulokha umuntu wengubo nakazithweleko bese athathe isiqunto sokabana akafuni ukuba nomntwana bese akhuphe umtwana amthweleko&lt;ref&gt;https://www.merriam-webster.com/dictionary/abortion&lt;/ref&gt;. Ukurhulula umbungu kuyinto esemthethweni enarheni yeSewula Afrika, ngombana kuthiwa umuntu unelungelo lokuzikhethela bona wenzakalani emzimbeni wakhe.
Imibono eyahlukileko ngokurhulula umbungu
Ukurhululula umbungu kuyisihloko esingabanga ukuphikisana phakathi kwabantu ngombana abantu banemibono eminengi eyahlukeneko. Abanye babona kuyinto ehle efanele yenziwe babantu. Kuthi abanye abantu babone kuyinto embi enesihlungu engenziwako. Omunye nomunye umuntu wengubo wenza okubonwa nguye nakafika kulobujamo ngombana ukurhulula umbungu kuyinto esemthethweni eSewula Afrika. 

Abavumelana nakho 

Abavumelana nokurhulula umbungu bathi kuyinto ehle khulu khulu lokha nangabe umma ukatiwe wagcina sele azithwele Umntwana ngokatwa, nofana kilabo bantu abanokugula ukungabafaka engozini yokufa lokha nabasidisi. Ngalezi inzathu eziveziweko babona ukuthi ukurhulula umbungu akusiyo into embi ngombana umu ntu akukafaneli abe nomtwnan angafuni nofana amthole ngesibanga sesehlakalo esimbi esifana nokukatwa&lt;ref name=&quot;:0&quot;&gt;https://www.britannica.com/procon/abortion-debate&lt;/ref&gt;. 

Abaphikisana nakho 

Abanye abantu bayaphikisa bathi ukuehulula umbung yinto embi ngombana lokha wenza into le ukhipha umphefumulo womntwana onganacala. Godu baphikisa ngokuthi ukurhulula umbungu akusikuhle ngombana lokha nawukwenzileko ipilo yakho ingakhubazeka njengokuthu umma angasakghoni ukuba nabanye abantwana.  Umunye agcine sele ahla emzimbeni ngombana ahlala ngakajabuli anokuzisola&lt;ref name=&quot;:0&quot; /&gt;&lt;ref&gt;https://www.bbc.co.uk/bitesize/guides/zhbqf4j/revision/4&lt;/ref&gt;. 

Imiphumela yokurhulula umbungu 

Umuntu orhulule umbungu angagcina ahlulwa kuzilibalela ngesenzo asenzileko lokha nakabona abantu bona bayamahlulela ngesenzo lesi asenzileko. Angazibona alihlazo emphakathini aphila kiwo ngombana kwamanye amasiko namakhaya ayenziwa into leyo. Ukurhulula umbungu kungaletha ukwahlukana phakathi kwabantu abathandanako lokha nangabe into le yenzeke bangaka vumelani njengenthandani&lt;ref&gt;https://www.worldpulse.org/es/story/the-impact-of-abortion-bans-on-womens-mental-health-61476?gad_source=1&amp;gclid=EAIaIQobChMIg4TQx_-9jAMVOIBQBh3PljsEEAAYASAAEgLgYvD_BwE&lt;/ref&gt;. 

Isiphetho 

Ukurhulula umbungu kuyinto abantu abayicala ngeendlea ezinengi ezahlukileko. Abanye bayayamukela abanye bayayiohikisa. Woke umuntu wengubo kufanele enze lokhu ekuzomenza bona akghone ukuragela phambili kuhle nepilo yakhe.</text>
      <sha1>9atcut6ilhl8lzdx5ftc3kxll7chzt3</sha1>
    </revision>
    <revision>
      <id>3307</id>
      <parentid>3189</parentid>
      <timestamp>2025-07-02T20:47:31Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Undo revision [[Special:Diff/3189|3189]] by [[Special:Contributions/85.97.84.231|85.97.84.231]] ([[User talk:85.97.84.231|talk]])</comment>
      <origin>3307</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2610" sha1="bqj49a0ftx70yhzv9qapo23vkre2ytu" xml:space="preserve">Ukurhulula umbungu 

Ukurhulula umbungu kukulokha umuntu wengubo nakazithweleko bese athathe isiqunto sokabana akafuni ukuba nomntwana bese akhuphe umtwana amthweleko&lt;ref&gt;https://www.merriam-webster.com/dictionary/abortion&lt;/ref&gt;. Ukurhulula umbungu kuyinto esemthethweni enarheni yeSewula Afrika, ngombana kuthiwa umuntu unelungelo lokuzikhethela bona wenzakalani emzimbeni wakhe.
Imibono eyahlukileko ngokurhulula umbungu
Ukurhululula umbungu kuyisihloko esingabanga ukuphikisana phakathi kwabantu ngombana abantu banemibono eminengi eyahlukeneko. Abanye babona kuyinto ehle efanele yenziwe babantu. Kuthi abanye abantu babone kuyinto embi enesihlungu engenziwako. Omunye nomunye umuntu wengubo wenza okubonwa nguye nakafika kulobujamo ngombana ukurhulula umbungu kuyinto esemthethweni eSewula Afrika. 

Abavumelana nakho 

Abavumelana nokurhulula umbungu bathi kuyinto ehle khulu khulu lokha nangabe umma ukatiwe wagcina sele azithwele Umntwana ngokatwa, nofana kilabo bantu abanokugula ukungabafaka engozini yokufa lokha nabasidisi. Ngalezi inzathu eziveziweko babona ukuthi ukurhulula umbungu akusiyo into embi ngombana umu ntu akukafaneli abe nomtwnan angafuni nofana amthole ngesibanga sesehlakalo esimbi esifana nokukatwa&lt;ref name=&quot;:0&quot;&gt;https://www.britannica.com/procon/abortion-debate&lt;/ref&gt;. 

Abaphikisana nakho 

Abanye abantu bayaphikisa bathi ukuehulula umbung yinto embi ngombana lokha wenza into le ukhipha umphefumulo womntwana onganacala. Godu baphikisa ngokuthi ukurhulula umbungu akusikuhle ngombana lokha nawukwenzileko ipilo yakho ingakhubazeka njengokuthu umma angasakghoni ukuba nabanye abantwana.  Umunye agcine sele ahla emzimbeni ngombana ahlala ngakajabuli anokuzisola&lt;ref name=&quot;:0&quot; /&gt;&lt;ref&gt;https://www.bbc.co.uk/bitesize/guides/zhbqf4j/revision/4&lt;/ref&gt;. 

Imiphumela yokurhulula umbungu 

Umuntu orhulule umbungu angagcina ahlulwa kuzilibalela ngesenzo asenzileko lokha nakabona abantu bona bayamahlulela ngesenzo lesi asenzileko. Angazibona alihlazo emphakathini aphila kiwo ngombana kwamanye amasiko namakhaya ayenziwa into leyo. Ukurhulula umbungu kungaletha ukwahlukana phakathi kwabantu abathandanako lokha nangabe into le yenzeke bangaka vumelani njengenthandani&lt;ref&gt;https://www.worldpulse.org/es/story/the-impact-of-abortion-bans-on-womens-mental-health-61476?gad_source=1&amp;gclid=EAIaIQobChMIg4TQx_-9jAMVOIBQBh3PljsEEAAYASAAEgLgYvD_BwE&lt;/ref&gt;. 

Isiphetho 

Ukurhulula umbungu kuyinto abantu abayicala ngeendlea ezinengi ezahlukileko. Abanye bayayamukela abanye bayayiohikisa. Woke umuntu wengubo kufanele enze lokhu ekuzomenza bona akghone ukuragela phambili kuhle nepilo yakhe.</text>
      <sha1>bqj49a0ftx70yhzv9qapo23vkre2ytu</sha1>
    </revision>
    <revision>
      <id>5650</id>
      <parentid>3307</parentid>
      <timestamp>2025-09-04T11:06:06Z</timestamp>
      <contributor>
        <username>2003.Ma</username>
        <id>882</id>
      </contributor>
      <minor />
      <comment>spelling and authography</comment>
      <origin>5650</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2777" sha1="hrmeeo66ngutcc7cthh3px013o2c9fd" xml:space="preserve">Ukurhulula umbungu 

Ukurhulula umbungu kukulokha umuntu wengubo nakazithweleko bese athathe isiqunto sokabana akafuni ukuba nomntwana bese akhuphe umtwana amthweleko ngokusebenzisa imitjhoga.&lt;ref&gt;https://www.merriam-webster.com/dictionary/abortion&lt;/ref&gt;. Ukurhulula umbungu kuyinto esemthethweni enarheni yeSewula Afrika, ngombana umuntu unelungelo lokuzikhethela bona wenzakalani emzimbeni wakhe.
Imibono eyahlukileko ngokurhulula umbungu
Ukurhululula umbungu kuyisihloko esingabanga ukuphikisana phakathi kwabantu ngombana abantu banemibono eminengi eyahlukeneko. Abanye babona kuyinto ehle efanele yenziwe babantu. Kuthi abanye abantu babone kuyinto embi enesihlungu engenziwako. Omunye nomunye umuntu wengubo wenza okubonwa nguye nakafika kulobujamo ngombana ukurhulula umbungu kuyinto esemthethweni eSewula [[I-Afrika|Afrika.]] 

Abavumelana nakho 

Abavumelana nokurhulula umbungu bathi kuyinto ehle khulu khulu lokha nangabe umma ukatiwe wagcina sele azithwele [[umntwana]] ngokatwa, nofana kilabo bantu abanokugula ukungabafaka engozini yokufa lokha nabasidisi. Ngalezi iinzathu eziveziweko babona ukuthi ukurhulula umbungu akusiyo into embi ngombana umuntu akukafaneli abe nomtwana angafuni nofana amthole ngesibanga sesehlakalo esimbi esifana nokukatwa&lt;ref name=&quot;:0&quot;&gt;https://www.britannica.com/procon/abortion-debate&lt;/ref&gt;. 

Abaphikisana nakho 
[[Isimumathi:A One Medical clinic in Bethesda, Maryland 01.jpg|thumb|isthomb&lt;ref name=&quot;:1&quot; /&gt;e semtholampilo]]
Abanye abantu bayaphikisa bathi ukurhulula umbungu yinto embi ngombana lokha wenza into le ukhipha umphefumulo womntwana ongana cala. Godu baphikisa ngokuthi ukurhulula umbungu akusikuhle ngombana lokha nawukwenzileko ipilo yakho ingakhubazeka njengokuthu umma angasakghoni ukuba nabanye abantwana.  Umunye agcine sele ehla emzimbeni ngombana ahlala angakajabuli anokuzisola&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot;&gt;https://www.bbc.co.uk/bitesize/guides/zhbqf4j/revision/4&lt;/ref&gt;. 

Imiphumela yokurhulula umbungu 

Umuntu orhulule umbungu angagcina ahlulwa kuzilibalela ngesenzo asenzileko lokha nakabona abantu bona bayamahlulela ngesenzo lesi asenzileko. Angazibona alihlazo emphakathini aphila kiwo ngombana kwamanye amasiko namakhaya ayenziwa into leyo. Ukurhulula umbungu kungaletha ukwahlukana phakathi kwabantu abathandanako lokha nangabe into le yenzeke bangaka vumelani njengeenthandani&lt;ref&gt;https://www.worldpulse.org/es/story/the-impact-of-abortion-bans-on-womens-mental-health-61476?gad_source=1&amp;gclid=EAIaIQobChMIg4TQx_-9jAMVOIBQBh3PljsEEAAYASAAEgLgYvD_BwE&lt;/ref&gt;. 

Isiphetho 

Ukurhulula umbungu kuyinto abantu abayicala ngeendlela ezinengi ezahlukileko. Abanye bayakwamukela abanye baphihikisana nakho. Woke umuntu wengubo kufanele enze lokhu ekuzomenza bona akghone ukuragela phambili kuhle nepilo yakhe.</text>
      <sha1>hrmeeo66ngutcc7cthh3px013o2c9fd</sha1>
    </revision>
  </page>
  <page>
    <title>Imisila</title>
    <ns>0</ns>
    <id>543</id>
    <revision>
      <id>2639</id>
      <timestamp>2025-04-04T09:07:59Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== '''Umsila''' == '''Umsila''' kuyinto ede nofana efitjhani elengako emva edinini lesilwana&lt;ref&gt;https://www.merriam-webster.com/dictionary/tail#:~:text=Synonyms%20of%20tail-,1,shape%20or%20position%3A%20such%20as&lt;/ref&gt;. Imisila iyahluka ngokwakheka kwesinye nesinye isilwana. Imisila isebenza ngokwahlukana kwesinye nesiinye isilwane. Imisila ifana ngento eyodwa ekukuthi ilekelela abanikazi ukuthi bakghone ukococisana, [[ukudzimelela]] naye nokuphila.  == Umsebenzi womsil...&quot;</comment>
      <origin>2639</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2986" sha1="m31p4uqblcds8qjn88c90qe8etue0k7" xml:space="preserve">== '''Umsila''' ==
'''Umsila''' kuyinto ede nofana efitjhani elengako emva edinini lesilwana&lt;ref&gt;https://www.merriam-webster.com/dictionary/tail#:~:text=Synonyms%20of%20tail-,1,shape%20or%20position%3A%20such%20as&lt;/ref&gt;. Imisila iyahluka ngokwakheka kwesinye nesinye isilwana. Imisila isebenza ngokwahlukana kwesinye nesiinye isilwane. Imisila ifana ngento eyodwa ekukuthi ilekelela abanikazi ukuthi bakghone ukococisana, [[ukudzimelela]] naye nokuphila.

== Umsebenzi womsila ==

=== Ukudzimelela ===
Iinlwana ezinengi ezifana nezinja anabokatsu zisebenzisa imisila yazo ukudzimelala lokha nazijamileko. Imisila yenza bona zikghone ukujika msinya begodu zikghone nokutjhugulula ama indlela ezikhamba ngayo&lt;ref&gt;https://en.wikipedia.org/wiki/Tail&lt;/ref&gt;.

=== Ukukhulumisana ===
Iinlwana zikghona ukukhuluma ngemisila, zisebenzisa umsila ukuveza bona zikwatile nofana zithabile ngemisila zingaka khiphi iphimbo&lt;ref&gt;https://www.earth.com/news/dogs-use-their-tails-more-for-communication-than-movement/&lt;/ref&gt;.

=== Ukuzivikela ===
Ezinye iinlwana ezifana nebhadwa nabofezelwa zisebenzisa umsila wazo ukuthi zikhone ukuzivikela ebingozini ebungazivelela. Imisiphala yakhona esikhathini esinengi ibanetjhefu ethela abantu nofana ezinye iinlwana ezingalinga ukuzihlukumeza&lt;ref&gt;Hickman, G.C., 1979. The mammalian tail: a review of functions. ''Mammal review'', ''9''(4), pp.143-157.&lt;/ref&gt;.

=== Ukududa nokunyakaza ===
Iinlwana ezinengi ezihlala emanzini ezifana nefesi zisebenzisa  imisila yazoi ukududa bese zikghone ukududa nokunyaka emanzini. Umsila uzinekeza Amandla wokuthi zikghone ukududa kuhle ngemanzini ngaphandle kokuthi ziphelelwe mamandla&lt;ref&gt;Dao, A.H. and Netsky, M.G., 1984. Human tails and pseudotails. ''Human pathology'', ''15''(5), pp.449-453.&lt;/ref&gt;.

== Imihlobo yemisila ==

=== Imisila ebambelelako ===
Imisila itholakala enlwaneni ezifana nefene. imisila yakhona ikghona ukubamba izinto nofana ibambelele  ngawo ezintweni njengesihlahleni. Lokhu kutjho bona iinlwana ezinomsila lo ziyakghone ukuwusebenzisa njengesandla. Imisila le inikeda iinlwana lesi isekelo nokudzimelela okuzeleko&lt;ref&gt;Youlatos, D., 1999. Tail-use in capuchin monkeys. ''Neotropical Primates'', ''7''(1), pp.16-20.&lt;/ref&gt;. 

=== Imisila enoboya obunengi ===
Iinlwana ezinengi ezifana ne nemiqasa zinoboya obunengi emsileni eyenza bona zivikeleke ezintweni. Umsila lo inlwana zakhona ziyawusebenzisa ukuveza imizwa yaso nofana ukunikelana amatshwayo nehloso ezinayo&lt;ref&gt;Hare, T., 2018. ''Animal Fact File: Head to tail profiles of more than 90 mammals''. Marshall Cavendish International Asia Pte Ltd.&lt;/ref&gt;. 

=== Imisila eqinileko ===
Ezinye iinlwana zinemisila eqinileko enikeza iinlwana ezinomsila ivikeleko enlwaneni lezi ezizingelako. 

== Isiphetho ==
Imisila iqakathekile eenlwaneni ngombana uzenza bona zihlale zivikelekile bogodu zikghone nokuthi zivezwa imizwa yazo ngaphandle kokuthi zikhulume. Imihlobo yemisila iyahluka ngokuya ngokomhlobo wesilwane begodu yenza nemisebenzi ehlukileko.</text>
      <sha1>m31p4uqblcds8qjn88c90qe8etue0k7</sha1>
    </revision>
    <revision>
      <id>2644</id>
      <parentid>2639</parentid>
      <timestamp>2025-04-04T18:25:25Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2644</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2985" sha1="p0210d4bo5w17gzmobkpo7jxblm8bs7" xml:space="preserve">== '''Umsila''' ==
'''Umsila''' kuyinto ede nofana efitjhani elengako emva edinini lesilwana&lt;ref&gt;https://www.merriam-webster.com/dictionary/tail#:~:text=Synonyms%20of%20tail-,1,shape%20or%20position%3A%20such%20as&lt;/ref&gt;. Imisila iyahluka ngokwakheka kwesinye nesinye isilwana. Imisila isebenza ngokwahlukana kwesinye nesinye isilwane. Imisila ifana ngento eyodwa ekukuthi ilekelela abanikazi ukuthi bakghone ukococisana, [[ukudzimelela]] naye nokuphila.

== Umsebenzi womsila ==

=== Ukudzimelela ===
Iinlwana ezinengi ezifana nezinja anabokatsu zisebenzisa imisila yazo ukudzimelala lokha nazijamileko. Imisila yenza bona zikghone ukujika msinya begodu zikghone nokutjhugulula ama indlela ezikhamba ngayo&lt;ref&gt;https://en.wikipedia.org/wiki/Tail&lt;/ref&gt;.

=== Ukukhulumisana ===
Iinlwana zikghona ukukhuluma ngemisila, zisebenzisa umsila ukuveza bona zikwatile nofana zithabile ngemisila zingaka khiphi iphimbo&lt;ref&gt;https://www.earth.com/news/dogs-use-their-tails-more-for-communication-than-movement/&lt;/ref&gt;.

=== Ukuzivikela ===
Ezinye iinlwana ezifana nebhadwa nabofezelwa zisebenzisa umsila wazo ukuthi zikhone ukuzivikela ebingozini ebungazivelela. Imisiphala yakhona esikhathini esinengi ibanetjhefu ethela abantu nofana ezinye iinlwana ezingalinga ukuzihlukumeza&lt;ref&gt;Hickman, G.C., 1979. The mammalian tail: a review of functions. ''Mammal review'', ''9''(4), pp.143-157.&lt;/ref&gt;.

=== Ukududa nokunyakaza ===
Iinlwana ezinengi ezihlala emanzini ezifana nefesi zisebenzisa  imisila yazoi ukududa bese zikghone ukududa nokunyaka emanzini. Umsila uzinekeza Amandla wokuthi zikghone ukududa kuhle ngemanzini ngaphandle kokuthi ziphelelwe mamandla&lt;ref&gt;Dao, A.H. and Netsky, M.G., 1984. Human tails and pseudotails. ''Human pathology'', ''15''(5), pp.449-453.&lt;/ref&gt;.

== Imihlobo yemisila ==

=== Imisila ebambelelako ===
Imisila itholakala enlwaneni ezifana nefene. imisila yakhona ikghona ukubamba izinto nofana ibambelele  ngawo ezintweni njengesihlahleni. Lokhu kutjho bona iinlwana ezinomsila lo ziyakghone ukuwusebenzisa njengesandla. Imisila le inikeda iinlwana lesi isekelo nokudzimelela okuzeleko&lt;ref&gt;Youlatos, D., 1999. Tail-use in capuchin monkeys. ''Neotropical Primates'', ''7''(1), pp.16-20.&lt;/ref&gt;. 

=== Imisila enoboya obunengi ===
Iinlwana ezinengi ezifana ne nemiqasa zinoboya obunengi emsileni eyenza bona zivikeleke ezintweni. Umsila lo inlwana zakhona ziyawusebenzisa ukuveza imizwa yaso nofana ukunikelana amatshwayo nehloso ezinayo&lt;ref&gt;Hare, T., 2018. ''Animal Fact File: Head to tail profiles of more than 90 mammals''. Marshall Cavendish International Asia Pte Ltd.&lt;/ref&gt;. 

=== Imisila eqinileko ===
Ezinye iinlwana zinemisila eqinileko enikeza iinlwana ezinomsila ivikeleko enlwaneni lezi ezizingelako. 

== Isiphetho ==
Imisila iqakathekile eenlwaneni ngombana uzenza bona zihlale zivikelekile bogodu zikghone nokuthi zivezwa imizwa yazo ngaphandle kokuthi zikhulume. Imihlobo yemisila iyahluka ngokuya ngokomhlobo wesilwane begodu yenza nemisebenzi ehlukileko.</text>
      <sha1>p0210d4bo5w17gzmobkpo7jxblm8bs7</sha1>
    </revision>
    <revision>
      <id>2645</id>
      <parentid>2644</parentid>
      <timestamp>2025-04-04T18:26:17Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2645</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2985" sha1="1e6uz06i4r53n81e0tp3duod3hpnnr6" xml:space="preserve">== '''Umsila''' ==
'''Umsila''' kuyinto ede nofana efitjhani elengako emva edinini lesilwana&lt;ref&gt;https://www.merriam-webster.com/dictionary/tail#:~:text=Synonyms%20of%20tail-,1,shape%20or%20position%3A%20such%20as&lt;/ref&gt;. Imisila iyahluka ngokwakheka kwesinye nesinye isilwana. Imisila isebenza ngokwahlukana kwesinye nesinye isilwane. Imisila ifana ngento eyodwa ekukuthi ilekelela abanikazi ukuthi bakghone ukococisana, [[ukudzimelela]] naye nokuphila.

== Umsebenzi womsila ==

=== Ukudzimelela ===
Iinlwana ezinengi ezifana nezinja anabokatsu zisebenzisa imisila yazo ukudzimelala lokha nazijamileko. Imisila yenza bona zikghone ukujika msinya begodu zikghone nokutjhugulula ama indlela ezikhamba ngayo&lt;ref&gt;https://en.wikipedia.org/wiki/Tail&lt;/ref&gt;.

=== Ukukhulumisana ===
Iinlwana zikghona ukukhuluma ngemisila, zisebenzisa umsila ukuveza bona zikwatile nofana zithabile ngemisila zingaka khiphi iphimbo&lt;ref&gt;https://www.earth.com/news/dogs-use-their-tails-more-for-communication-than-movement/&lt;/ref&gt;.

=== Ukuzivikela ===
Ezinye iinlwana ezifana nebhadwa nabofezelwa zisebenzisa umsila wazo ukuthi zikhone ukuzivikela ebingozini ebungazivelela. Imisiphala yakhona esikhathini esinengi ibanetjhefu ethela abantu nofana ezinye iinlwana ezingalinga ukuzihlukumeza&lt;ref&gt;Hickman, G.C., 1979. The mammalian tail: a review of functions. ''Mammal review'', ''9''(4), pp.143-157.&lt;/ref&gt;.

=== Ukududa nokunyakaza ===
Iinlwana ezinengi ezihlala emanzini ezifana nefesi zisebenzisa  imisila yazoi ukududa bese zikghone ukududa nokunyaka emanzini. Umsila uzinekeza Amandla wokuthi zikghone ukududa kuhle ngemanzini ngaphandle kokuthi ziphelelwe mamandla&lt;ref&gt;Dao, A.H. and Netsky, M.G., 1984. Human tails and pseudotails. ''Human pathology'', ''15''(5), pp.449-453.&lt;/ref&gt;.

== Imihlobo yemisila ==

=== Imisila ebambelelako ===
Imisila itholakala enlwaneni ezifana nefene. imisila yakhona ikghona ukubamba izinto nofana ibambelele  ngawo ezintweni njengesihlahleni. Lokhu kutjho bona iinlwana ezinomsila lo ziyakghona ukuwusebenzisa njengesandla. Imisila le inikeza iinlwana lezi isekelo nokudzimelela okuzeleko&lt;ref&gt;Youlatos, D., 1999. Tail-use in capuchin monkeys. ''Neotropical Primates'', ''7''(1), pp.16-20.&lt;/ref&gt;. 

=== Imisila enoboya obunengi ===
Iinlwana ezinengi ezifana ne nemiqasa zinoboya obunengi emsileni eyenza bona zivikeleke ezintweni. Umsila lo inlwana zakhona ziyawusebenzisa ukuveza imizwa yaso nofana ukunikelana amatshwayo nehloso ezinayo&lt;ref&gt;Hare, T., 2018. ''Animal Fact File: Head to tail profiles of more than 90 mammals''. Marshall Cavendish International Asia Pte Ltd.&lt;/ref&gt;. 

=== Imisila eqinileko ===
Ezinye iinlwana zinemisila eqinileko enikeza iinlwana ezinomsila ivikeleko enlwaneni lezi ezizingelako. 

== Isiphetho ==
Imisila iqakathekile eenlwaneni ngombana uzenza bona zihlale zivikelekile bogodu zikghone nokuthi zivezwa imizwa yazo ngaphandle kokuthi zikhulume. Imihlobo yemisila iyahluka ngokuya ngokomhlobo wesilwane begodu yenza nemisebenzi ehlukileko.</text>
      <sha1>1e6uz06i4r53n81e0tp3duod3hpnnr6</sha1>
    </revision>
    <revision>
      <id>2646</id>
      <parentid>2645</parentid>
      <timestamp>2025-04-04T18:27:01Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2646</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2982" sha1="6b3xut5w9m52hekn52h07npk9o39qws" xml:space="preserve">== '''Umsila''' ==
'''Umsila''' kuyinto ede nofana efitjhani elengako emva edinini lesilwana&lt;ref&gt;https://www.merriam-webster.com/dictionary/tail#:~:text=Synonyms%20of%20tail-,1,shape%20or%20position%3A%20such%20as&lt;/ref&gt;. Imisila iyahluka ngokwakheka kwesinye nesinye isilwana. Imisila isebenza ngokwahlukana kwesinye nesinye isilwane. Imisila ifana ngento eyodwa ekukuthi ilekelela abanikazi ukuthi bakghone ukococisana, [[ukudzimelela]] naye nokuphila.

== Umsebenzi womsila ==

=== Ukudzimelela ===
Iinlwana ezinengi ezifana nezinja anabokatsu zisebenzisa imisila yazo ukudzimelala lokha nazijamileko. Imisila yenza bona zikghone ukujika msinya begodu zikghone nokutjhugulula  indlela ezikhamba ngayo&lt;ref&gt;https://en.wikipedia.org/wiki/Tail&lt;/ref&gt;.

=== Ukukhulumisana ===
Iinlwana zikghona ukukhuluma ngemisila, zisebenzisa umsila ukuveza bona zikwatile nofana zithabile ngemisila zingaka khiphi iphimbo&lt;ref&gt;https://www.earth.com/news/dogs-use-their-tails-more-for-communication-than-movement/&lt;/ref&gt;.

=== Ukuzivikela ===
Ezinye iinlwana ezifana nebhadwa nabofezelwa zisebenzisa umsila wazo ukuthi zikhone ukuzivikela ebingozini ebungazivelela. Imisiphala yakhona esikhathini esinengi ibanetjhefu ethela abantu nofana ezinye iinlwana ezingalinga ukuzihlukumeza&lt;ref&gt;Hickman, G.C., 1979. The mammalian tail: a review of functions. ''Mammal review'', ''9''(4), pp.143-157.&lt;/ref&gt;.

=== Ukududa nokunyakaza ===
Iinlwana ezinengi ezihlala emanzini ezifana nefesi zisebenzisa  imisila yazoi ukududa bese zikghone ukududa nokunyaka emanzini. Umsila uzinekeza Amandla wokuthi zikghone ukududa kuhle ngemanzini ngaphandle kokuthi ziphelelwe mamandla&lt;ref&gt;Dao, A.H. and Netsky, M.G., 1984. Human tails and pseudotails. ''Human pathology'', ''15''(5), pp.449-453.&lt;/ref&gt;.

== Imihlobo yemisila ==

=== Imisila ebambelelako ===
Imisila itholakala enlwaneni ezifana nefene. imisila yakhona ikghona ukubamba izinto nofana ibambelele  ngawo ezintweni njengesihlahleni. Lokhu kutjho bona iinlwana ezinomsila lo ziyakghona ukuwusebenzisa njengesandla. Imisila le inikeza iinlwana lezi isekelo nokudzimelela okuzeleko&lt;ref&gt;Youlatos, D., 1999. Tail-use in capuchin monkeys. ''Neotropical Primates'', ''7''(1), pp.16-20.&lt;/ref&gt;. 

=== Imisila enoboya obunengi ===
Iinlwana ezinengi ezifana ne nemiqasa zinoboya obunengi emsileni eyenza bona zivikeleke ezintweni. Umsila lo inlwana zakhona ziyawusebenzisa ukuveza imizwa yaso nofana ukunikelana amatshwayo nehloso ezinayo&lt;ref&gt;Hare, T., 2018. ''Animal Fact File: Head to tail profiles of more than 90 mammals''. Marshall Cavendish International Asia Pte Ltd.&lt;/ref&gt;. 

=== Imisila eqinileko ===
Ezinye iinlwana zinemisila eqinileko enikeza iinlwana ezinomsila ivikeleko enlwaneni lezi ezizingelako. 

== Isiphetho ==
Imisila iqakathekile eenlwaneni ngombana uzenza bona zihlale zivikelekile bogodu zikghone nokuthi zivezwa imizwa yazo ngaphandle kokuthi zikhulume. Imihlobo yemisila iyahluka ngokuya ngokomhlobo wesilwane begodu yenza nemisebenzi ehlukileko.</text>
      <sha1>6b3xut5w9m52hekn52h07npk9o39qws</sha1>
    </revision>
    <revision>
      <id>2647</id>
      <parentid>2646</parentid>
      <timestamp>2025-04-04T18:27:56Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2647</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2982" sha1="ickc65badim2vtnje6rh2tnqtba08yf" xml:space="preserve">== '''Umsila''' ==
'''Umsila''' kuyinto ede nofana efitjhani elengako emva edinini lesilwana&lt;ref&gt;https://www.merriam-webster.com/dictionary/tail#:~:text=Synonyms%20of%20tail-,1,shape%20or%20position%3A%20such%20as&lt;/ref&gt;. Imisila iyahluka ngokwakheka kwesinye nesinye isilwana. Imisila isebenza ngokwahlukana kwesinye nesinye isilwane. Imisila ifana ngento eyodwa ekukuthi ilekelela abanikazi ukuthi bakghone ukococisana, [[ukudzimelela]] naye nokuphila.

== Umsebenzi womsila ==

=== Ukudzimelela ===
Iinlwana ezinengi ezifana nezinja anabokatsu zisebenzisa imisila yazo ukudzimelala lokha nazijamileko. Imisila yenza bona zikghone ukujika msinya begodu zikghone nokutjhugulula  indlela ezikhamba ngayo&lt;ref&gt;https://en.wikipedia.org/wiki/Tail&lt;/ref&gt;.

=== Ukukhulumisana ===
Iinlwana zikghona ukukhuluma ngemisila, zisebenzisa umsila ukuveza bona zikwatile nofana zithabile ngemisila zingaka khiphi iphimbo&lt;ref&gt;https://www.earth.com/news/dogs-use-their-tails-more-for-communication-than-movement/&lt;/ref&gt;.

=== Ukuzivikela ===
Ezinye iinlwana ezifana neembhadwa nabofezelwa zisebenzisa umsila wazo ukuthi zikghone ukuzivikela ebungozini ebungazivelela. Imisila yakhona esikhathini esinengi ibanetjhefu ethela abantu nofana ezinye iinlwana ezingalinga ukuzihlukumeza&lt;ref&gt;Hickman, G.C., 1979. The mammalian tail: a review of functions. ''Mammal review'', ''9''(4), pp.143-157.&lt;/ref&gt;.

=== Ukududa nokunyakaza ===
Iinlwana ezinengi ezihlala emanzini ezifana nefesi zisebenzisa  imisila yazoi ukududa bese zikghone ukududa nokunyaka emanzini. Umsila uzinekeza Amandla wokuthi zikghone ukududa kuhle ngemanzini ngaphandle kokuthi ziphelelwe mamandla&lt;ref&gt;Dao, A.H. and Netsky, M.G., 1984. Human tails and pseudotails. ''Human pathology'', ''15''(5), pp.449-453.&lt;/ref&gt;.

== Imihlobo yemisila ==

=== Imisila ebambelelako ===
Imisila itholakala enlwaneni ezifana nefene. imisila yakhona ikghona ukubamba izinto nofana ibambelele  ngawo ezintweni njengesihlahleni. Lokhu kutjho bona iinlwana ezinomsila lo ziyakghona ukuwusebenzisa njengesandla. Imisila le inikeza iinlwana lezi isekelo nokudzimelela okuzeleko&lt;ref&gt;Youlatos, D., 1999. Tail-use in capuchin monkeys. ''Neotropical Primates'', ''7''(1), pp.16-20.&lt;/ref&gt;. 

=== Imisila enoboya obunengi ===
Iinlwana ezinengi ezifana ne nemiqasa zinoboya obunengi emsileni eyenza bona zivikeleke ezintweni. Umsila lo inlwana zakhona ziyawusebenzisa ukuveza imizwa yaso nofana ukunikelana amatshwayo nehloso ezinayo&lt;ref&gt;Hare, T., 2018. ''Animal Fact File: Head to tail profiles of more than 90 mammals''. Marshall Cavendish International Asia Pte Ltd.&lt;/ref&gt;. 

=== Imisila eqinileko ===
Ezinye iinlwana zinemisila eqinileko enikeza iinlwana ezinomsila ivikeleko enlwaneni lezi ezizingelako. 

== Isiphetho ==
Imisila iqakathekile eenlwaneni ngombana uzenza bona zihlale zivikelekile bogodu zikghone nokuthi zivezwa imizwa yazo ngaphandle kokuthi zikhulume. Imihlobo yemisila iyahluka ngokuya ngokomhlobo wesilwane begodu yenza nemisebenzi ehlukileko.</text>
      <sha1>ickc65badim2vtnje6rh2tnqtba08yf</sha1>
    </revision>
    <revision>
      <id>2648</id>
      <parentid>2647</parentid>
      <timestamp>2025-04-04T18:28:35Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2648</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2983" sha1="dwhajakj4b4z7seyv89fc1mcv8tiqb6" xml:space="preserve">== '''Umsila''' ==
'''Umsila''' kuyinto ede nofana efitjhani elengako emva edinini lesilwana&lt;ref&gt;https://www.merriam-webster.com/dictionary/tail#:~:text=Synonyms%20of%20tail-,1,shape%20or%20position%3A%20such%20as&lt;/ref&gt;. Imisila iyahluka ngokwakheka kwesinye nesinye isilwana. Imisila isebenza ngokwahlukana kwesinye nesinye isilwane. Imisila ifana ngento eyodwa ekukuthi ilekelela abanikazi ukuthi bakghone ukococisana, [[ukudzimelela]] naye nokuphila.

== Umsebenzi womsila ==

=== Ukudzimelela ===
Iinlwana ezinengi ezifana nezinja anabokatsu zisebenzisa imisila yazo ukudzimelala lokha nazijamileko. Imisila yenza bona zikghone ukujika msinya begodu zikghone nokutjhugulula  indlela ezikhamba ngayo&lt;ref&gt;https://en.wikipedia.org/wiki/Tail&lt;/ref&gt;.

=== Ukukhulumisana ===
Iinlwana zikghona ukukhuluma ngemisila, zisebenzisa umsila ukuveza bona zikwatile nofana zithabile ngemisila zingaka khiphi iphimbo&lt;ref&gt;https://www.earth.com/news/dogs-use-their-tails-more-for-communication-than-movement/&lt;/ref&gt;.

=== Ukuzivikela ===
Ezinye iinlwana ezifana neembhadwa nabofezelwa zisebenzisa umsila wazo ukuthi zikghone ukuzivikela ebungozini ebungazivelela. Imisila yakhona esikhathini esinengi ibanetjhefu ethela abantu nofana ezinye iinlwana ezingalinga ukuzihlukumeza&lt;ref&gt;Hickman, G.C., 1979. The mammalian tail: a review of functions. ''Mammal review'', ''9''(4), pp.143-157.&lt;/ref&gt;.

=== Ukududa nokunyakaza ===
Iinlwana ezinengi ezihlala emanzini ezifana nefesi zisebenzisa  imisila yazo ukududa bese zikghone ukududa nokunyakaza emanzini. Umsila uzinikeza Amandla wokuthi zikghone ukududa kuhle ngemanzini ngaphandle kokuthi ziphelelwe mamandla&lt;ref&gt;Dao, A.H. and Netsky, M.G., 1984. Human tails and pseudotails. ''Human pathology'', ''15''(5), pp.449-453.&lt;/ref&gt;.

== Imihlobo yemisila ==

=== Imisila ebambelelako ===
Imisila itholakala enlwaneni ezifana nefene. imisila yakhona ikghona ukubamba izinto nofana ibambelele  ngawo ezintweni njengesihlahleni. Lokhu kutjho bona iinlwana ezinomsila lo ziyakghona ukuwusebenzisa njengesandla. Imisila le inikeza iinlwana lezi isekelo nokudzimelela okuzeleko&lt;ref&gt;Youlatos, D., 1999. Tail-use in capuchin monkeys. ''Neotropical Primates'', ''7''(1), pp.16-20.&lt;/ref&gt;. 

=== Imisila enoboya obunengi ===
Iinlwana ezinengi ezifana ne nemiqasa zinoboya obunengi emsileni eyenza bona zivikeleke ezintweni. Umsila lo inlwana zakhona ziyawusebenzisa ukuveza imizwa yaso nofana ukunikelana amatshwayo nehloso ezinayo&lt;ref&gt;Hare, T., 2018. ''Animal Fact File: Head to tail profiles of more than 90 mammals''. Marshall Cavendish International Asia Pte Ltd.&lt;/ref&gt;. 

=== Imisila eqinileko ===
Ezinye iinlwana zinemisila eqinileko enikeza iinlwana ezinomsila ivikeleko enlwaneni lezi ezizingelako. 

== Isiphetho ==
Imisila iqakathekile eenlwaneni ngombana uzenza bona zihlale zivikelekile bogodu zikghone nokuthi zivezwa imizwa yazo ngaphandle kokuthi zikhulume. Imihlobo yemisila iyahluka ngokuya ngokomhlobo wesilwane begodu yenza nemisebenzi ehlukileko.</text>
      <sha1>dwhajakj4b4z7seyv89fc1mcv8tiqb6</sha1>
    </revision>
    <revision>
      <id>2649</id>
      <parentid>2648</parentid>
      <timestamp>2025-04-04T18:29:20Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2649</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2982" sha1="88gcjqdckebbk97km4q695jfvtok9qo" xml:space="preserve">== '''Umsila''' ==
'''Umsila''' kuyinto ede nofana efitjhani elengako emva edinini lesilwana&lt;ref&gt;https://www.merriam-webster.com/dictionary/tail#:~:text=Synonyms%20of%20tail-,1,shape%20or%20position%3A%20such%20as&lt;/ref&gt;. Imisila iyahluka ngokwakheka kwesinye nesinye isilwana. Imisila isebenza ngokwahlukana kwesinye nesinye isilwane. Imisila ifana ngento eyodwa ekukuthi ilekelela abanikazi ukuthi bakghone ukococisana, [[ukudzimelela]] naye nokuphila.

== Umsebenzi womsila ==

=== Ukudzimelela ===
Iinlwana ezinengi ezifana nezinja anabokatsu zisebenzisa imisila yazo ukudzimelala lokha nazijamileko. Imisila yenza bona zikghone ukujika msinya begodu zikghone nokutjhugulula  indlela ezikhamba ngayo&lt;ref&gt;https://en.wikipedia.org/wiki/Tail&lt;/ref&gt;.

=== Ukukhulumisana ===
Iinlwana zikghona ukukhuluma ngemisila, zisebenzisa umsila ukuveza bona zikwatile nofana zithabile ngemisila zingaka khiphi iphimbo&lt;ref&gt;https://www.earth.com/news/dogs-use-their-tails-more-for-communication-than-movement/&lt;/ref&gt;.

=== Ukuzivikela ===
Ezinye iinlwana ezifana neembhadwa nabofezelwa zisebenzisa umsila wazo ukuthi zikghone ukuzivikela ebungozini ebungazivelela. Imisila yakhona esikhathini esinengi ibanetjhefu ethela abantu nofana ezinye iinlwana ezingalinga ukuzihlukumeza&lt;ref&gt;Hickman, G.C., 1979. The mammalian tail: a review of functions. ''Mammal review'', ''9''(4), pp.143-157.&lt;/ref&gt;.

=== Ukududa nokunyakaza ===
Iinlwana ezinengi ezihlala emanzini ezifana nefesi zisebenzisa  imisila yazo ukududa bese zikghone ukududa nokunyakaza emanzini. Umsila uzinikeza Amandla wokuthi zikghone ukududa kuhle ngemanzini ngaphandle kokuthi ziphelelwe mamandla&lt;ref&gt;Dao, A.H. and Netsky, M.G., 1984. Human tails and pseudotails. ''Human pathology'', ''15''(5), pp.449-453.&lt;/ref&gt;.

== Imihlobo yemisila ==

=== Imisila ebambelelako ===
Imisila itholakala enlwaneni ezifana nefene. imisila yakhona ikghona ukubamba izinto nofana ibambelele  ngawo ezintweni njengesihlahleni. Lokhu kutjho bona iinlwana ezinomsila lo ziyakghona ukuwusebenzisa njengesandla. Imisila le inikeza iinlwana lezi isekelo nokudzimelela okuzeleko&lt;ref&gt;Youlatos, D., 1999. Tail-use in capuchin monkeys. ''Neotropical Primates'', ''7''(1), pp.16-20.&lt;/ref&gt;. 

=== Imisila enoboya obunengi ===
Iinlwana ezinengi ezifana ne nemiqasa zinoboya obunengi emsileni eyenza bona zivikeleke ezintweni. Umsila lo inlwana zakhona ziyawusebenzisa ukuveza imizwa yaso nofana ukunikelana amatshwayo nehloso ezinayo&lt;ref&gt;Hare, T., 2018. ''Animal Fact File: Head to tail profiles of more than 90 mammals''. Marshall Cavendish International Asia Pte Ltd.&lt;/ref&gt;. 

=== Imisila eqinileko ===
Ezinye iinlwana zinemisila eqinileko enikeza iinlwana ezinomsila ivikeleko enlwaneni lezi ezizingelako. 

== Isiphetho ==
Imisila iqakathekile eenlwaneni ngombana uzenza bona zihlale zivikelekile bogodu zikghone nokuthi ziveze imizwa yazo ngaphandle kokuthi zikhulume. Imihlobo yemisila iyahluka ngokuya ngokomhlobo wesilwane begodu yenza nemisebenzi ehlukileko.</text>
      <sha1>88gcjqdckebbk97km4q695jfvtok9qo</sha1>
    </revision>
    <revision>
      <id>3549</id>
      <parentid>2649</parentid>
      <timestamp>2025-08-05T14:59:40Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3549</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3043" sha1="9hhscyirjiscn74gj17poo1qlmy7f8t" xml:space="preserve">'''Umsila''' kuyinto ede nofana efitjhani elengako emva edinini lesibandandana&lt;ref&gt;https://www.merriam-webster.com/dictionary/tail#:~:text=Synonyms%20of%20tail-,1,shape%20or%20position%3A%20such%20as&lt;/ref&gt;. Imisila iyahluka ngokwakheka kwesinye nesinye isibandana. Imisila isebenza ngokwahlukana kwesinye nesinye isilwane ngokuya kwendlela isibandana sikghona ukuwusebenzisa ngakkhona. Imisila ifana nento eyodwa ekukuthi ilekelela abanikazi ukuthi bakghone ukococisana, [[ukudzimelela]] naye nokuphila.

=== Umsebenzi womsila ===

==== Ukudzimelela ====
Iinlwana ezinengi ezifana nezinja anabokatsu zisebenzisa imisila yazo ukudzimelala lokha nazijamileko. Imisila yenza bona zikghone ukujika msinya begodu zikghone nokutjhugulula  indlela ezikhamba ngayo&lt;ref&gt;https://en.wikipedia.org/wiki/Tail&lt;/ref&gt;.

==== Ukukhulumisana ====
Iinlwana zikghona ukukhuluma ngemisila, zisebenzisa umsila ukuveza bona zikwatile nofana zithabile ngemisila zingaka khiphi iphimbo&lt;ref&gt;https://www.earth.com/news/dogs-use-their-tails-more-for-communication-than-movement/&lt;/ref&gt;.

==== Ukuzivikela ====
Ezinye iinlwana ezifana neembhadwa nabofezelwa zisebenzisa umsila wazo ukuthi zikghone ukuzivikela ebungozini ebungazivelela. Imisila yakhona esikhathini esinengi ibanetjhefu ethela abantu nofana ezinye iinlwana ezingalinga ukuzihlukumeza&lt;ref&gt;Hickman, G.C., 1979. The mammalian tail: a review of functions. ''Mammal review'', ''9''(4), pp.143-157.&lt;/ref&gt;.

==== Ukududa nokunyakaza ====
Iinlwana ezinengi ezihlala emanzini ezifana nefesi zisebenzisa  imisila yazo ukududa bese zikghone ukududa nokunyakaza emanzini. Umsila uzinikeza Amandla wokuthi zikghone ukududa kuhle ngemanzini ngaphandle kokuthi ziphelelwe mamandla&lt;ref&gt;Dao, A.H. and Netsky, M.G., 1984. Human tails and pseudotails. ''Human pathology'', ''15''(5), pp.449-453.&lt;/ref&gt;.

=== Imihlobo yemisila ===

=== Imisila ebambelelako ===
Imisila itholakala enlwaneni ezifana nefene. imisila yakhona ikghona ukubamba izinto nofana ibambelele  ngawo ezintweni njengesihlahleni. Lokhu kutjho bona iinlwana ezinomsila lo ziyakghona ukuwusebenzisa njengesandla. Imisila le inikeza iinlwana lezi isekelo nokudzimelela okuzeleko&lt;ref&gt;Youlatos, D., 1999. Tail-use in capuchin monkeys. ''Neotropical Primates'', ''7''(1), pp.16-20.&lt;/ref&gt;. 

=== Imisila enoboya obunengi ===
Iinlwana ezinengi ezifana ne nemiqasa zinoboya obunengi emsileni eyenza bona zivikeleke ezintweni. Umsila lo inlwana zakhona ziyawusebenzisa ukuveza imizwa yaso nofana ukunikelana amatshwayo nehloso ezinayo&lt;ref&gt;Hare, T., 2018. ''Animal Fact File: Head to tail profiles of more than 90 mammals''. Marshall Cavendish International Asia Pte Ltd.&lt;/ref&gt;. 

=== Imisila eqinileko ===
Ezinye iinlwana zinemisila eqinileko enikeza iinlwana ezinomsila ivikeleko enlwaneni lezi ezizingelako. Imisila iqakathekile eenlwaneni ngombana uzenza bona zihlale zivikelekile bogodu zikghone nokuthi ziveze imizwa yazo ngaphandle kokuthi zikhulume. Imihlobo yemisila iyahluka ngokuya ngokomhlobo wesilwane begodu yenza nemisebenzi ehlukileko. 

== Iinkomba ==</text>
      <sha1>9hhscyirjiscn74gj17poo1qlmy7f8t</sha1>
    </revision>
    <revision>
      <id>3550</id>
      <parentid>3549</parentid>
      <timestamp>2025-08-05T15:03:02Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3550</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3036" sha1="bll1yvsx66n56ntq651l68k687zug7j" xml:space="preserve">'''Umsila''' kuyinto ede nofana efitjhani elengako emva edinini lesibandandana&lt;ref&gt;https://www.merriam-webster.com/dictionary/tail#:~:text=Synonyms%20of%20tail-,1,shape%20or%20position%3A%20such%20as&lt;/ref&gt;. Imisila iyahluka ngokwakheka kwesinye nesinye isibandana. Imisila isebenza ngokwahlukana kwesinye nesinye isilwane ngokuya kwendlela isibandana sikghona ukuwusebenzisa ngakkhona. Imisila ifana nento eyodwa ekukuthi ilekelela abanikazi ukuthi bakghone ukococisana, [[ukudzimelela]] naye nokuphila.

=== Umsebenzi womsila ===

==== Ukudzimelela ====
Iinlwana ezinengi ezifana nezinja anabokatsu zisebenzisa imisila yazo ukudzimelala lokha nazijamileko. Imisila yenza bona zikghone ukujika msinya begodu zikghone nokutjhugulula  indlela ezikhamba ngayo&lt;ref&gt;https://en.wikipedia.org/wiki/Tail&lt;/ref&gt;.

==== Ukukhulumisana ====
Iinlwana zikghona ukukhuluma ngemisila, zisebenzisa umsila ukuveza bona zikwatile nofana zithabile ngemisila zingaka khiphi iphimbo&lt;ref&gt;https://www.earth.com/news/dogs-use-their-tails-more-for-communication-than-movement/&lt;/ref&gt;.

==== Ukuzivikela ====
Ezinye iinlwana ezifana neembhadwa nabofezelwa zisebenzisa umsila wazo ukuthi zikghone ukuzivikela ebungozini ebungazivelela. Imisila yakhona esikhathini esinengi ibanetjhefu ethela abantu nofana ezinye iinlwana ezingalinga ukuzihlukumeza&lt;ref&gt;Hickman, G.C., 1979. The mammalian tail: a review of functions. ''Mammal review'', ''9''(4), pp.143-157.&lt;/ref&gt;.

==== Ukududa nokunyakaza ====
Iinlwana ezinengi ezihlala emanzini ezifana nefesi zisebenzisa  imisila yazo ukududa bese zikghone ukududa nokunyakaza emanzini. Umsila uzinikeza Amandla wokuthi zikghone ukududa kuhle ngemanzini ngaphandle kokuthi ziphelelwe mamandla&lt;ref&gt;Dao, A.H. and Netsky, M.G., 1984. Human tails and pseudotails. ''Human pathology'', ''15''(5), pp.449-453.&lt;/ref&gt;.

=== Imihlobo yemisila ===

=== Imisila ebambelelako ===
Imisila itholakala enlwaneni ezifana nefene. Imisila yakhona ikghona ukubamba izinto nofana ibambelele ezintweni njengesihlahleni. Lokhu kutjho bona iinlwana ezinomsila lo ziyakghona ukuwusebenzisa njengesandla. Imisila le inikeza iinlwana lezi isekelo nokudzimelela okuzeleko&lt;ref&gt;Youlatos, D., 1999. Tail-use in capuchin monkeys. ''Neotropical Primates'', ''7''(1), pp.16-20.&lt;/ref&gt;. 

=== Imisila enoboya obunengi ===
Iinlwana ezinengi ezifana ne nemiqasa zinoboya obunengi emsileni eyenza bona zivikeleke ezintweni. Umsila lo inlwana zakhona ziyawusebenzisa ukuveza imizwa yaso nofana ukunikelana amatshwayo nehloso ezinayo&lt;ref&gt;Hare, T., 2018. ''Animal Fact File: Head to tail profiles of more than 90 mammals''. Marshall Cavendish International Asia Pte Ltd.&lt;/ref&gt;. 

=== Imisila eqinileko ===
Ezinye iinlwana zinemisila eqinileko enikeza iinlwana ezinomsila ivikeleko enlwaneni lezi ezizingelako. Imisila iqakathekile eenlwaneni ngombana uzenza bona zihlale zivikelekile bogodu zikghone nokuthi ziveze imizwa yazo ngaphandle kokuthi zikhulume. Imihlobo yemisila iyahluka ngokuya ngokomhlobo wesilwane begodu yenza nemisebenzi ehlukileko. 

== Iinkomba ==</text>
      <sha1>bll1yvsx66n56ntq651l68k687zug7j</sha1>
    </revision>
    <revision>
      <id>3551</id>
      <parentid>3550</parentid>
      <timestamp>2025-08-05T15:22:29Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <comment>Added few lines to the article</comment>
      <origin>3551</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3315" sha1="j7mmej9db76kgu012xkbgo8pewk30sj" xml:space="preserve">'''Umsila''' kuyinto ede nofana efitjhani elengako emva edinini lesibandandana&lt;ref&gt;https://www.merriam-webster.com/dictionary/tail#:~:text=Synonyms%20of%20tail-,1,shape%20or%20position%3A%20such%20as&lt;/ref&gt;. Imisila iyahluka ngokwakheka kwesinye nesinye isibandana. Imisila isebenza ngokwahlukana kwesinye nesinye isilwane ngokuya kwendlela isibandana sikghona ukuwusebenzisa ngakkhona. Imisila ifana nento eyodwa ekukuthi ilekelela abanikazi ukuthi bakghone ukococisana, [[ukudzimelela]] naye nokuphila.

=== Umsebenzi womsila ===

==== Ukudzimelela ====
Iinlwana ezinengi ezifana nezinja anabokatsu zisebenzisa imisila yazo ukudzimelala lokha nazijamileko. Imisila yenza bona zikghone ukujika msinya begodu zikghone nokutjhugulula  indlela ezikhamba ngayo&lt;ref&gt;https://en.wikipedia.org/wiki/Tail&lt;/ref&gt;. 

==== Ukukhulumisana ====
Iinlwana zikghona ukukhuluma ngemisila, zisebenzisa umsila ukuveza bona zikwatile nofana zithabile ngemisila zingaka khiphi iphimbo&lt;ref&gt;https://www.earth.com/news/dogs-use-their-tails-more-for-communication-than-movement/&lt;/ref&gt;. Kwezinye iimbandana umsila onyakazako ukhombisa ithabo, ogebekileko ukhombisa ukusaba, onganyakaziko ukhombisa ukuzifihla nofana ukwaneliseka. Inja ikghona ukudlalisa umsila wayo ukukhombisa boyana ithabile, nanyana ifake umsile hlangana neenyawo ukukhombisa ukuswaba nokusaba.

==== Ukuzivikela ====
Ezinye iinlwana ezifana neembhadwa nabofezelwa zisebenzisa umsila wazo ukuthi zikghone ukuzivikela ebungozini ebungazivelela. Imisila yakhona esikhathini esinengi ibanetjhefu ethela abantu nofana ezinye iinlwana ezingalinga ukuzihlukumeza&lt;ref&gt;Hickman, G.C., 1979. The mammalian tail: a review of functions. ''Mammal review'', ''9''(4), pp.143-157.&lt;/ref&gt;.

==== Ukududa nokunyakaza ====
Iinlwana ezinengi ezihlala emanzini ezifana nefesi zisebenzisa  imisila yazo ukududa bese zikghone ukududa nokunyakaza emanzini. Umsila uzinikeza Amandla wokuthi zikghone ukududa kuhle ngemanzini ngaphandle kokuthi ziphelelwe mamandla&lt;ref&gt;Dao, A.H. and Netsky, M.G., 1984. Human tails and pseudotails. ''Human pathology'', ''15''(5), pp.449-453.&lt;/ref&gt;.

=== Imihlobo yemisila ===

=== Imisila ebambelelako ===
Imisila itholakala enlwaneni ezifana nefene. Imisila yakhona ikghona ukubamba izinto nofana ibambelele ezintweni njengesihlahleni. Lokhu kutjho bona iinlwana ezinomsila lo ziyakghona ukuwusebenzisa njengesandla. Imisila le inikeza iinlwana lezi isekelo nokudzimelela okuzeleko&lt;ref&gt;Youlatos, D., 1999. Tail-use in capuchin monkeys. ''Neotropical Primates'', ''7''(1), pp.16-20.&lt;/ref&gt;. 

=== Imisila enoboya obunengi ===
Iinlwana ezinengi ezifana ne nemiqasa zinoboya obunengi emsileni eyenza bona zivikeleke ezintweni. Umsila lo inlwana zakhona ziyawusebenzisa ukuveza imizwa yaso nofana ukunikelana amatshwayo nehloso ezinayo&lt;ref&gt;Hare, T., 2018. ''Animal Fact File: Head to tail profiles of more than 90 mammals''. Marshall Cavendish International Asia Pte Ltd.&lt;/ref&gt;. 

=== Imisila eqinileko ===
Ezinye iinlwana zinemisila eqinileko enikeza iinlwana ezinomsila ivikeleko enlwaneni lezi ezizingelako. Imisila iqakathekile eenlwaneni ngombana uzenza bona zihlale zivikelekile bogodu zikghone nokuthi ziveze imizwa yazo ngaphandle kokuthi zikhulume. Imihlobo yemisila iyahluka ngokuya ngokomhlobo wesilwane begodu yenza nemisebenzi ehlukileko. 

== Iinkomba ==</text>
      <sha1>j7mmej9db76kgu012xkbgo8pewk30sj</sha1>
    </revision>
    <revision>
      <id>3552</id>
      <parentid>3551</parentid>
      <timestamp>2025-08-05T15:28:41Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3552</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3510" sha1="7lhtkyo083ksqtri8iljfi3pu8hf22p" xml:space="preserve">'''Umsila''' kuyinto ede nofana efitjhani elengako emva edinini lesibandandana&lt;ref&gt;https://www.merriam-webster.com/dictionary/tail#:~:text=Synonyms%20of%20tail-,1,shape%20or%20position%3A%20such%20as&lt;/ref&gt;. Imisila iyahluka ngokwakheka kwesinye nesinye isibandana. Imisila isebenza ngokwahlukana kwesinye nesinye isilwane ngokuya kwendlela isibandana sikghona ukuwusebenzisa ngakkhona. Imisila ifana nento eyodwa ekukuthi ilekelela abanikazi ukuthi bakghone ukococisana, [[ukudzimelela]] naye nokuphila.

=== Umsebenzi womsila ===

==== Ukudzimelela ====
Iinlwana ezinengi ezifana nezinja anabokatsu zisebenzisa imisila yazo ukudzimelala lokha nazijamileko. Imisila yenza bona zikghone ukujika msinya begodu zikghone nokutjhugulula  indlela ezikhamba ngayo&lt;ref&gt;https://en.wikipedia.org/wiki/Tail&lt;/ref&gt;. 

==== Ukukhulumisana ====
Iinlwana zikghona ukukhuluma ngemisila, zisebenzisa umsila ukuveza bona zikwatile nofana zithabile ngemisila zingaka khiphi iphimbo&lt;ref&gt;https://www.earth.com/news/dogs-use-their-tails-more-for-communication-than-movement/&lt;/ref&gt;. Kwezinye iimbandana umsila onyakazako ukhombisa ithabo, ogebekileko ukhombisa ukusaba, onganyakaziko ukhombisa ukuzifihla nofana ukwaneliseka. Inja ikghona ukudlalisa umsila wayo ukukhombisa boyana ithabile, nanyana ifake umsile hlangana neenyawo ukukhombisa ukuswaba nokusaba.

==== Ukuzivikela ====
Ezinye iinlwana ezifana neembhadwa nabofezelwa zisebenzisa umsila wazo ukuthi zikghone ukuzivikela ebungozini ebungazivelela. Imisila yakhona esikhathini esinengi ibanetjhefu ethela abantu nofana ezinye iinlwana ezingalinga ukuzihlukumeza&lt;ref&gt;Hickman, G.C., 1979. The mammalian tail: a review of functions. ''Mammal review'', ''9''(4), pp.143-157.&lt;/ref&gt;.

==== Ukududa nokunyakaza ====
Iinlwana ezinengi ezihlala emanzini ezifana nefesi zisebenzisa  imisila yazo ukududa bese zikghone ukududa nokunyakaza emanzini. Umsila uzinikeza Amandla wokuthi zikghone ukududa kuhle ngemanzini ngaphandle kokuthi ziphelelwe mamandla&lt;ref&gt;Dao, A.H. and Netsky, M.G., 1984. Human tails and pseudotails. ''Human pathology'', ''15''(5), pp.449-453.&lt;/ref&gt;.

=== Imihlobo yemisila ===

==== Imisila ebambelelako ====
Imisila itholakala enlwaneni ezifana nefene. Imisila yakhona ikghona ukubamba izinto nofana ibambelele ezintweni njengesihlahleni. Lokhu kutjho bona iinlwana ezinomsila lo ziyakghona ukuwusebenzisa njengesandla. Imisila le inikeza iinlwana lezi isekelo nokudzimelela okuzeleko&lt;ref&gt;Youlatos, D., 1999. Tail-use in capuchin monkeys. ''Neotropical Primates'', ''7''(1), pp.16-20.&lt;/ref&gt;. 

==== Imisila enoboya obunengi ====
Iinlwana ezinengi ezifana ne nemiqasa zinoboya obunengi emsileni eyenza bona zivikeleke ezintweni. Umsila lo inlwana zakhona ziyawusebenzisa ukuveza imizwa yaso nofana ukunikelana amatshwayo nehloso ezinayo&lt;ref&gt;Hare, T., 2018. ''Animal Fact File: Head to tail profiles of more than 90 mammals''. Marshall Cavendish International Asia Pte Ltd.&lt;/ref&gt;. Iimbandana ziyawusebenzisa ukuthi zikghone ukuzivikela emakhazeni lokha nakumakhaza. zikghonna nokusebenzisa imisila bonyana zikghone ukudzimelela lokha nazeqa endaweni efana nesihlahleni. 

==== Imisila eqinileko ====
Ezinye iinlwana zinemisila eqinileko enikeza iinlwana ezinomsila ivikeleko enlwaneni lezi ezizingelako. Imisila iqakathekile eenlwaneni ngombana uzenza bona zihlale zivikelekile bogodu zikghone nokuthi ziveze imizwa yazo ngaphandle kokuthi zikhulume. Imihlobo yemisila iyahluka ngokuya ngokomhlobo wesilwane begodu yenza nemisebenzi ehlukileko. 

== Iinkomba ==</text>
      <sha1>7lhtkyo083ksqtri8iljfi3pu8hf22p</sha1>
    </revision>
    <revision>
      <id>3553</id>
      <parentid>3552</parentid>
      <timestamp>2025-08-05T15:34:34Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3553</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3727" sha1="dsefhktjlge8hqezsa8z8m1pry7e9vu" xml:space="preserve">'''Umsila''' kuyinto ede nofana efitjhani elengako emva edinini lesibandandana&lt;ref&gt;https://www.merriam-webster.com/dictionary/tail#:~:text=Synonyms%20of%20tail-,1,shape%20or%20position%3A%20such%20as&lt;/ref&gt;. Imisila iyahluka ngokwakheka kwesinye nesinye isibandana. Imisila isebenza ngokwahlukana kwesinye nesinye isilwane ngokuya kwendlela isibandana sikghona ukuwusebenzisa ngakkhona. Imisila ifana nento eyodwa ekukuthi ilekelela abanikazi ukuthi bakghone ukococisana, [[ukudzimelela]] naye nokuphila.

=== Umsebenzi womsila ===

==== Ukudzimelela ====
Iinlwana ezinengi ezifana nezinja anabokatsu zisebenzisa imisila yazo ukudzimelala lokha nazijamileko. Imisila yenza bona zikghone ukujika msinya begodu zikghone nokutjhugulula  indlela ezikhamba ngayo&lt;ref&gt;https://en.wikipedia.org/wiki/Tail&lt;/ref&gt;. Umsila wenza bona isibandana sikghone  ukuzwizwa bonyana sijame kuphi ngesikhathii isibandana sisafuna indlela yokukhamba. Urhelelbha nokuthi imbandana zikghone ukugijima khulu lokha nasizingelwa ngesinye isibandana. 

==== Ukukhulumisana ====
Iinlwana zikghona ukukhuluma ngemisila, zisebenzisa umsila ukuveza bona zikwatile nofana zithabile ngemisila zingaka khiphi iphimbo&lt;ref&gt;https://www.earth.com/news/dogs-use-their-tails-more-for-communication-than-movement/&lt;/ref&gt;. Kwezinye iimbandana umsila onyakazako ukhombisa ithabo, ogebekileko ukhombisa ukusaba, onganyakaziko ukhombisa ukuzifihla nofana ukwaneliseka. Inja ikghona ukudlalisa umsila wayo ukukhombisa boyana ithabile, nanyana ifake umsile hlangana neenyawo ukukhombisa ukuswaba nokusaba.

==== Ukuzivikela ====
Ezinye iinlwana ezifana neembhadwa nabofezelwa zisebenzisa umsila wazo ukuthi zikghone ukuzivikela ebungozini ebungazivelela. Imisila yakhona esikhathini esinengi ibanetjhefu ethela abantu nofana ezinye iinlwana ezingalinga ukuzihlukumeza&lt;ref&gt;Hickman, G.C., 1979. The mammalian tail: a review of functions. ''Mammal review'', ''9''(4), pp.143-157.&lt;/ref&gt;.

==== Ukududa nokunyakaza ====
Iinlwana ezinengi ezihlala emanzini ezifana nefesi zisebenzisa  imisila yazo ukududa bese zikghone ukududa nokunyakaza emanzini. Umsila uzinikeza Amandla wokuthi zikghone ukududa kuhle ngemanzini ngaphandle kokuthi ziphelelwe mamandla&lt;ref&gt;Dao, A.H. and Netsky, M.G., 1984. Human tails and pseudotails. ''Human pathology'', ''15''(5), pp.449-453.&lt;/ref&gt;.

=== Imihlobo yemisila ===

==== Imisila ebambelelako ====
Imisila itholakala enlwaneni ezifana nefene. Imisila yakhona ikghona ukubamba izinto nofana ibambelele ezintweni njengesihlahleni. Lokhu kutjho bona iinlwana ezinomsila lo ziyakghona ukuwusebenzisa njengesandla. Imisila le inikeza iinlwana lezi isekelo nokudzimelela okuzeleko&lt;ref&gt;Youlatos, D., 1999. Tail-use in capuchin monkeys. ''Neotropical Primates'', ''7''(1), pp.16-20.&lt;/ref&gt;. 

==== Imisila enoboya obunengi ====
Iinlwana ezinengi ezifana ne nemiqasa zinoboya obunengi emsileni eyenza bona zivikeleke ezintweni. Umsila lo inlwana zakhona ziyawusebenzisa ukuveza imizwa yaso nofana ukunikelana amatshwayo nehloso ezinayo&lt;ref&gt;Hare, T., 2018. ''Animal Fact File: Head to tail profiles of more than 90 mammals''. Marshall Cavendish International Asia Pte Ltd.&lt;/ref&gt;. Iimbandana ziyawusebenzisa ukuthi zikghone ukuzivikela emakhazeni lokha nakumakhaza. zikghonna nokusebenzisa imisila bonyana zikghone ukudzimelela lokha nazeqa endaweni efana nesihlahleni. 

==== Imisila eqinileko ====
Ezinye iinlwana zinemisila eqinileko enikeza iinlwana ezinomsila ivikeleko enlwaneni lezi ezizingelako. Imisila iqakathekile eenlwaneni ngombana uzenza bona zihlale zivikelekile bogodu zikghone nokuthi ziveze imizwa yazo ngaphandle kokuthi zikhulume. Imihlobo yemisila iyahluka ngokuya ngokomhlobo wesilwane begodu yenza nemisebenzi ehlukileko. 

== Iinkomba ==</text>
      <sha1>dsefhktjlge8hqezsa8z8m1pry7e9vu</sha1>
    </revision>
    <revision>
      <id>3554</id>
      <parentid>3553</parentid>
      <timestamp>2025-08-05T15:37:55Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3554</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3790" sha1="kv802uun71w6m4zd0drxyinckqpv6em" xml:space="preserve">'''Umsila''' kuyinto ede nofana efitjhani elengako emva edinini lesibandandana&lt;ref&gt;https://www.merriam-webster.com/dictionary/tail#:~:text=Synonyms%20of%20tail-,1,shape%20or%20position%3A%20such%20as&lt;/ref&gt;. Imisila iyahluka ngokwakheka kwesinye nesinye isibandana. Imisila isebenza ngokwahlukana kwesinye nesinye isilwane ngokuya kwendlela isibandana sikghona ukuwusebenzisa ngakhona. Imisila ifana nento eyodwa ekukuthi ilekelela abanikazi ukuthi bakghone ukococisana, [[ukudzimelela]]&lt;ref&gt;https://www.ncbi.nlm.nih.gov/pmc/articles/PMC11574348&lt;/ref&gt; naye nokuphila.

=== Umsebenzi womsila ===

==== Ukudzimelela ====
Iinlwana ezinengi ezifana nezinja anabokatsu zisebenzisa imisila yazo ukudzimelala lokha nazijamileko. Imisila yenza bona zikghone ukujika msinya begodu zikghone nokutjhugulula  indlela ezikhamba ngayo&lt;ref&gt;https://en.wikipedia.org/wiki/Tail&lt;/ref&gt;. Umsila wenza bona isibandana sikghone  ukuzwizwa bonyana sijame kuphi ngesikhathii isibandana sisafuna indlela yokukhamba. Urhelelbha nokuthi imbandana zikghone ukugijima khulu lokha nasizingelwa ngesinye isibandana. 

==== Ukukhulumisana ====
Iinlwana zikghona ukukhuluma ngemisila, zisebenzisa umsila ukuveza bona zikwatile nofana zithabile ngemisila zingaka khiphi iphimbo&lt;ref&gt;https://www.earth.com/news/dogs-use-their-tails-more-for-communication-than-movement/&lt;/ref&gt;. Kwezinye iimbandana umsila onyakazako ukhombisa ithabo, ogebekileko ukhombisa ukusaba, onganyakaziko ukhombisa ukuzifihla nofana ukwaneliseka. Inja ikghona ukudlalisa umsila wayo ukukhombisa boyana ithabile, nanyana ifake umsile hlangana neenyawo ukukhombisa ukuswaba nokusaba.

==== Ukuzivikela ====
Ezinye iinlwana ezifana neembhadwa nabofezelwa zisebenzisa umsila wazo ukuthi zikghone ukuzivikela ebungozini ebungazivelela. Imisila yakhona esikhathini esinengi ibanetjhefu ethela abantu nofana ezinye iinlwana ezingalinga ukuzihlukumeza&lt;ref&gt;Hickman, G.C., 1979. The mammalian tail: a review of functions. ''Mammal review'', ''9''(4), pp.143-157.&lt;/ref&gt;.

==== Ukududa nokunyakaza ====
Iinlwana ezinengi ezihlala emanzini ezifana nefesi zisebenzisa  imisila yazo ukududa bese zikghone ukududa nokunyakaza emanzini. Umsila uzinikeza Amandla wokuthi zikghone ukududa kuhle ngemanzini ngaphandle kokuthi ziphelelwe mamandla&lt;ref&gt;Dao, A.H. and Netsky, M.G., 1984. Human tails and pseudotails. ''Human pathology'', ''15''(5), pp.449-453.&lt;/ref&gt;.

=== Imihlobo yemisila ===

==== Imisila ebambelelako ====
Imisila itholakala enlwaneni ezifana nefene. Imisila yakhona ikghona ukubamba izinto nofana ibambelele ezintweni njengesihlahleni. Lokhu kutjho bona iinlwana ezinomsila lo ziyakghona ukuwusebenzisa njengesandla. Imisila le inikeza iinlwana lezi isekelo nokudzimelela okuzeleko&lt;ref&gt;Youlatos, D., 1999. Tail-use in capuchin monkeys. ''Neotropical Primates'', ''7''(1), pp.16-20.&lt;/ref&gt;. 

==== Imisila enoboya obunengi ====
Iinlwana ezinengi ezifana ne nemiqasa zinoboya obunengi emsileni eyenza bona zivikeleke ezintweni. Umsila lo inlwana zakhona ziyawusebenzisa ukuveza imizwa yaso nofana ukunikelana amatshwayo nehloso ezinayo&lt;ref&gt;Hare, T., 2018. ''Animal Fact File: Head to tail profiles of more than 90 mammals''. Marshall Cavendish International Asia Pte Ltd.&lt;/ref&gt;. Iimbandana ziyawusebenzisa ukuthi zikghone ukuzivikela emakhazeni lokha nakumakhaza. zikghonna nokusebenzisa imisila bonyana zikghone ukudzimelela lokha nazeqa endaweni efana nesihlahleni. 

==== Imisila eqinileko ====
Ezinye iinlwana zinemisila eqinileko enikeza iinlwana ezinomsila ivikeleko enlwaneni lezi ezizingelako. Imisila iqakathekile eenlwaneni ngombana uzenza bona zihlale zivikelekile bogodu zikghone nokuthi ziveze imizwa yazo ngaphandle kokuthi zikhulume. Imihlobo yemisila iyahluka ngokuya ngokomhlobo wesilwane begodu yenza nemisebenzi ehlukileko. 

== Iinkomba ==</text>
      <sha1>kv802uun71w6m4zd0drxyinckqpv6em</sha1>
    </revision>
    <revision>
      <id>3555</id>
      <parentid>3554</parentid>
      <timestamp>2025-08-05T15:39:51Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3555</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3791" sha1="9xft50mw3h463c63ag4qg44uf05w7zg" xml:space="preserve">'''Umsila''' kuyinto ede nofana efitjhani elengako emva edinini lesibandandana&lt;ref&gt;https://www.merriam-webster.com/dictionary/tail#:~:text=Synonyms%20of%20tail-,1,shape%20or%20position%3A%20such%20as&lt;/ref&gt;. Imisila iyahluka ngokwakheka kwesinye nesinye isibandana. Imisila isebenza ngokwahlukana kwesinye nesinye isilwane ngokuya kwendlela isibandana sikghona ukuwusebenzisa ngakhona. Imisila ifana nento eyodwa ekukuthi ilekelela abanikazi ukuthi bakghone ukococisana, [[ukudzimelela]]&lt;ref&gt;https://www.ncbi.nlm.nih.gov/pmc/articles/PMC11574348&lt;/ref&gt; naye nokuphila.

=== Umsebenzi womsila ===

==== Ukudzimelela ====
Iinlwana ezinengi ezifana nezinja anabokatsu zisebenzisa imisila yazo ukudzimelala lokha nazijamileko. Imisila yenza bona zikghone ukujika msinya begodu zikghone nokutjhugulula  indlela ezikhamba ngayo&lt;ref&gt;https://en.wikipedia.org/wiki/Tail&lt;/ref&gt;. Umsila wenza bona isibandana sikghone  ukuzwizwa bonyana sijame kuphi ngesikhathii isibandana sisafuna indlela yokukhamba. Urhelelbha nokuthi imbandana zikghone ukugijima khulu lokha nasizingelwa ngesinye isibandana. 

==== Ukukhulumisana ====
Iinlwana zikghona ukukhuluma ngemisila, zisebenzisa umsila ukuveza bona zikwatile nofana zithabile ngemisila zingaka khiphi iphimbo&lt;ref&gt;https://www.earth.com/news/dogs-use-their-tails-more-for-communication-than-movement/&lt;/ref&gt;. Kwezinye iimbandana umsila onyakazako ukhombisa ithabo, ogebekileko ukhombisa ukusaba, onganyakaziko ukhombisa ukuzifihla nofana ukwaneliseka. Inja ikghona ukudlalisa umsila wayo ukukhombisa boyana ithabile, nanyana ifake umsile hlangana neenyawo ukukhombisa ukuswaba nokusaba.

==== Ukuzivikela ====
Ezinye iinlwana ezifana neembhadwa nabofezelwa zisebenzisa umsila wazo ukuthi zikghone ukuzivikela ebungozini ebungazivelela. Imisila yakhona esikhathini esinengi ibanetjhefu ethela abantu nofana ezinye iinlwana ezingalinga ukuzihlukumeza&lt;ref&gt;Hickman, G.C., 1979. The mammalian tail: a review of functions. ''Mammal review'', ''9''(4), pp.143-157.&lt;/ref&gt;.

==== Ukududa nokunyakaza ====
Iinlwana ezinengi ezihlala emanzini ezifana nefesi zisebenzisa  imisila yazo ukududa bese zikghone ukududa nokunyakaza emanzini. Umsila uzinikeza Amandla wokuthi zikghone ukududa kuhle ngemanzini ngaphandle kokuthi ziphelelwe mamandla&lt;ref&gt;Dao, A.H. and Netsky, M.G., 1984. Human tails and pseudotails. ''Human pathology'', ''15''(5), pp.449-453.&lt;/ref&gt;.

=== Imihlobo yemisila ===

==== Imisila ebambelelako ====
Imisila itholakala enlwaneni ezifana nefene. Imisila yakhona ikghona ukubamba izinto nofana ibambelele ezintweni njengesihlahleni. Lokhu kutjho bona iinlwana ezinomsila lo ziyakghona ukuwusebenzisa njengesandla. Imisila le inikeza iinlwana lezi isekelo nokudzimelela okuzeleko&lt;ref&gt;Youlatos, D., 1999. Tail-use in capuchin monkeys. ''Neotropical Primates'', ''7''(1), pp.16-20.&lt;/ref&gt;.  

==== Imisila enoboya obunengi ====
Iinlwana ezinengi ezifana ne nemiqasa zinoboya obunengi emsileni eyenza bona zivikeleke ezintweni. Umsila lo inlwana zakhona ziyawusebenzisa ukuveza imizwa yaso nofana ukunikelana amatshwayo nehloso ezinayo&lt;ref&gt;Hare, T., 2018. ''Animal Fact File: Head to tail profiles of more than 90 mammals''. Marshall Cavendish International Asia Pte Ltd.&lt;/ref&gt;. Iimbandana ziyawusebenzisa ukuthi zikghone ukuzivikela emakhazeni lokha nakumakhaza. zikghonna nokusebenzisa imisila bonyana zikghone ukudzimelela lokha nazeqa endaweni efana nesihlahleni. 

==== Imisila eqinileko ====
Ezinye iinlwana zinemisila eqinileko enikeza iinlwana ezinomsila ivikeleko enlwaneni lezi ezizingelako. Imisila iqakathekile eenlwaneni ngombana uzenza bona zihlale zivikelekile bogodu zikghone nokuthi ziveze imizwa yazo ngaphandle kokuthi zikhulume. Imihlobo yemisila iyahluka ngokuya ngokomhlobo wesilwane begodu yenza nemisebenzi ehlukileko. 

== Iinkomba ==</text>
      <sha1>9xft50mw3h463c63ag4qg44uf05w7zg</sha1>
    </revision>
    <revision>
      <id>5068</id>
      <parentid>3555</parentid>
      <timestamp>2025-08-07T18:32:55Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5068</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3896" sha1="fkbn2xjtydyljt42w91ik9im5qw9179" xml:space="preserve">[[Isimumathi:Eichhörnchen Düsseldorf Hofgarten edit.jpg|thumb|Isibandana isinomsila onoboya obunengi]]
'''Umsila''' kuyinto ede nofana efitjhani elengako emva edinini lesibandandana&lt;ref&gt;https://www.merriam-webster.com/dictionary/tail#:~:text=Synonyms%20of%20tail-,1,shape%20or%20position%3A%20such%20as&lt;/ref&gt;. Imisila iyahluka ngokwakheka kwesinye nesinye isibandana. Imisila isebenza ngokwahlukana kwesinye nesinye isilwane ngokuya kwendlela isibandana sikghona ukuwusebenzisa ngakhona. Imisila ifana nento eyodwa ekukuthi ilekelela abanikazi ukuthi bakghone ukococisana, [[ukudzimelela]]&lt;ref&gt;https://www.ncbi.nlm.nih.gov/pmc/articles/PMC11574348&lt;/ref&gt; naye nokuphila.

=== Umsebenzi womsila ===

==== Ukudzimelela ====
Iinlwana ezinengi ezifana nezinja anabokatsu zisebenzisa imisila yazo ukudzimelala lokha nazijamileko. Imisila yenza bona zikghone ukujika msinya begodu zikghone nokutjhugulula  indlela ezikhamba ngayo&lt;ref&gt;https://en.wikipedia.org/wiki/Tail&lt;/ref&gt;. Umsila wenza bona isibandana sikghone  ukuzwizwa bonyana sijame kuphi ngesikhathii isibandana sisafuna indlela yokukhamba. Urhelelbha nokuthi imbandana zikghone ukugijima khulu lokha nasizingelwa ngesinye isibandana. 

==== Ukukhulumisana ====
Iinlwana zikghona ukukhuluma ngemisila, zisebenzisa umsila ukuveza bona zikwatile nofana zithabile ngemisila zingaka khiphi iphimbo&lt;ref&gt;https://www.earth.com/news/dogs-use-their-tails-more-for-communication-than-movement/&lt;/ref&gt;. Kwezinye iimbandana umsila onyakazako ukhombisa ithabo, ogebekileko ukhombisa ukusaba, onganyakaziko ukhombisa ukuzifihla nofana ukwaneliseka. Inja ikghona ukudlalisa umsila wayo ukukhombisa boyana ithabile, nanyana ifake umsile hlangana neenyawo ukukhombisa ukuswaba nokusaba.

==== Ukuzivikela ====
Ezinye iinlwana ezifana neembhadwa nabofezelwa zisebenzisa umsila wazo ukuthi zikghone ukuzivikela ebungozini ebungazivelela. Imisila yakhona esikhathini esinengi ibanetjhefu ethela abantu nofana ezinye iinlwana ezingalinga ukuzihlukumeza&lt;ref&gt;Hickman, G.C., 1979. The mammalian tail: a review of functions. ''Mammal review'', ''9''(4), pp.143-157.&lt;/ref&gt;.

==== Ukududa nokunyakaza ====
Iinlwana ezinengi ezihlala emanzini ezifana nefesi zisebenzisa  imisila yazo ukududa bese zikghone ukududa nokunyakaza emanzini. Umsila uzinikeza Amandla wokuthi zikghone ukududa kuhle ngemanzini ngaphandle kokuthi ziphelelwe mamandla&lt;ref&gt;Dao, A.H. and Netsky, M.G., 1984. Human tails and pseudotails. ''Human pathology'', ''15''(5), pp.449-453.&lt;/ref&gt;.

=== Imihlobo yemisila ===

==== Imisila ebambelelako ====
Imisila itholakala enlwaneni ezifana nefene. Imisila yakhona ikghona ukubamba izinto nofana ibambelele ezintweni njengesihlahleni. Lokhu kutjho bona iinlwana ezinomsila lo ziyakghona ukuwusebenzisa njengesandla. Imisila le inikeza iinlwana lezi isekelo nokudzimelela okuzeleko&lt;ref&gt;Youlatos, D., 1999. Tail-use in capuchin monkeys. ''Neotropical Primates'', ''7''(1), pp.16-20.&lt;/ref&gt;.  

==== Imisila enoboya obunengi ====
Iinlwana ezinengi ezifana ne nemiqasa zinoboya obunengi emsileni eyenza bona zivikeleke ezintweni. Umsila lo inlwana zakhona ziyawusebenzisa ukuveza imizwa yaso nofana ukunikelana amatshwayo nehloso ezinayo&lt;ref&gt;Hare, T., 2018. ''Animal Fact File: Head to tail profiles of more than 90 mammals''. Marshall Cavendish International Asia Pte Ltd.&lt;/ref&gt;. Iimbandana ziyawusebenzisa ukuthi zikghone ukuzivikela emakhazeni lokha nakumakhaza. zikghonna nokusebenzisa imisila bonyana zikghone ukudzimelela lokha nazeqa endaweni efana nesihlahleni. 

==== Imisila eqinileko ====
Ezinye iinlwana zinemisila eqinileko enikeza iinlwana ezinomsila ivikeleko enlwaneni lezi ezizingelako. Imisila iqakathekile eenlwaneni ngombana uzenza bona zihlale zivikelekile bogodu zikghone nokuthi ziveze imizwa yazo ngaphandle kokuthi zikhulume. Imihlobo yemisila iyahluka ngokuya ngokomhlobo wesilwane begodu yenza nemisebenzi ehlukileko. 

== Iinkomba ==</text>
      <sha1>fkbn2xjtydyljt42w91ik9im5qw9179</sha1>
    </revision>
  </page>
  <page>
    <title>Ibulungelo leencwadi</title>
    <ns>0</ns>
    <id>544</id>
    <revision>
      <id>2640</id>
      <timestamp>2025-04-04T09:19:41Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Ibulungelo leencwadi == '''Ibulungelo leencwadi''' kuyindawo yomphakathi lapho kubekwe khona iiincwadi ngokwahlukahlukana ukuthi abantu bakghone ukuzifunda begodu thole ilwazi ngeenhloko ezahlukahlukeneko abazithandako&lt;ref&gt;https://www.dictionary.com/browse/library&lt;/ref&gt;. Ibulungelo lencwadi lenza bona abantu bakghone ukuthola [[ilwazi]] lakade nelanje ngezinto zanje. Lithuthukisa izinga lefundo yabantu ngombana abantu bakghona ukuthola imithomba yelwazi eminenengi efa...&quot;</comment>
      <origin>2640</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3753" sha1="34a55y62udnma8tpzy0zh9w6vfl82su" xml:space="preserve">== Ibulungelo leencwadi ==
'''Ibulungelo leencwadi''' kuyindawo yomphakathi lapho kubekwe khona iiincwadi ngokwahlukahlukana ukuthi abantu bakghone ukuzifunda begodu thole ilwazi ngeenhloko ezahlukahlukeneko abazithandako&lt;ref&gt;https://www.dictionary.com/browse/library&lt;/ref&gt;. Ibulungelo lencwadi lenza bona abantu bakghone ukuthola [[ilwazi]] lakade nelanje ngezinto zanje. Lithuthukisa izinga lefundo yabantu ngombana abantu bakghona ukuthola imithomba yelwazi eminenengi efana neencwadi, amajenali, noku inthaneti lapho bazokufuna khona khona ilwazi. 

== Ukuqakatheka kwebulungelo leencwadi ==

=== Ukufunda nokutlola ===
Ibulungelo leencwadi lidala indima ekulu ekutheni abantu bakghone ukufunda nokutola, khulu khulu ebantwaneni nalapho imiphakathi yethu yakhona ingakathuthuki. Lokhu kwenziwa kukuthi endaweni ezinjengalezi ibulungelo leencwadi likghona ukwenza amahlelo wokufundisa abantwana ilimi begodu benze nemisebenzi eminye eyenza abantuwana bakghone ukufunda nokulalela&lt;ref&gt;Itsekor, V.O. and Nwokeoma, N.M., 2017. The Importance of the Use of Libraries and the Need for a Reading Culture. ''Acta Universitatis Lodziensis. Folia Librorum'', ''1''(24), pp.97-110.&lt;/ref&gt;. 

=== Irhubhululo nelwazi ===
Umuntu lokha nakenza irhubhululo afuna ilwazi eliliqiniso ukughona ukuya ebulungweni leencwadi lapho azokuthola khona ilwazi elizeleko ngesihloko arhubhulula ngaso. Ukhona ukuthola ama-athikili ezowasebenzisa erhubhululweni lakhe okutjho bona uzokuthola umthombo lwazi oneqiniso bese [[irhubhululo]] lakhe libe namandla. Abasenzi belungelweni leencwadi kwesinye isikhathi bayakghona ukuthi bakulelele ukwenza irhubhululo nokuthi ufake amareferensi ngendlela efaneleko. Lokhu kungenza umuntu orhubhululako aphumelele kuhle&lt;ref name=&quot;:0&quot;&gt;Hider, P., Garner, J., Wakeling, S. and Jamali, H.R., 2023. “Part of my daily life”: The importance of public libraries as physical spaces. ''Public Library Quarterly'', ''42''(2), pp.190-219.&lt;/ref&gt;. 

=== Ukuzikhipha ukubhoreka ===
Ebantwini abanekareko yokufunda nofana kwabathandaka ukufunda lokho nababhorekileko, ibulungelo leencwadi kuba yinto ebasizako. Ebulungelweni leencwadi kunemihlobo yoke yeencwadi abantu abangathanda ukuyifunda. Isibonelo iincwadi ezinenganekwana, iincwadi zelwazi, iincwadi ezikhulumako nezinye. Phezulu kwalokho bakunikela nendawo ethulileko ongafundela kiyo uthabelel ukufunda incwadi yakho. Nawungafuni ukuyindela khona bayakghona ukukuboleka yona uyoyifundela ekhaya bese uyibuyse ngenva kwamalanga. Akusizo zoke iincwadi ukghona ukuziboleka ukhambe nazo ekhaya&lt;ref name=&quot;:0&quot; /&gt;. 

=== Ukuzibandakanya komphakathi ===
Ibulungelo leencwadi likghona ukuba namakamero lapho abantu bomphakathi bangakghona ukuthi babambele khona imihlangano, nofana benzele khona indawo lapho iinqhema ziikghona ukuhlangana zabena ngemibono. 

=== Ukusebenzisa i-wifi simahla ===
Ebulungelweni leeencwadi abantu bakghona ukusebenzisa i-wifi simahla bangqabhadeli. Uthola ibulungelo leencwadi linamakhomphyutha abantu abangawasebenzisa ukuthola ilwazi ku-inthaneti. Lu kuyinto ehle khulu ngombana isiza nalabo bantu abangazo iinsetjenziswa zedijithali ukuthi bakghone nabo ukuthola ilwazi abalindingako&lt;ref&gt;Park, S., 2019. Analyzing library space use patterns in a public library through smartphone WiFi. ''Journal of the Korean Society for information Management'', ''36''(1), pp.295-313.&lt;/ref&gt;. 

== Isiphetho ==
bulungelo leencwadi luyindawo lapho abantu bakghona ukuthola ilwazi khona bathuthukise nekghona labo lokufunda nokufunda nokutlola. Kuyinawo lapho abantu bakghona ukurhelebheka khona ngeendlela ezinengi khona njengokuti bathole imthombo welwazi erhubhululweni labo, nokuthi bathole indawo ethulileko yokufunda. Ibulungelo leencwadi kuyindawo yokuzithuthukisa komphakathi.</text>
      <sha1>34a55y62udnma8tpzy0zh9w6vfl82su</sha1>
    </revision>
    <revision>
      <id>2643</id>
      <parentid>2640</parentid>
      <timestamp>2025-04-04T13:22:12Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2643</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3751" sha1="nzm30jf8waooh28too4xtjt6w6kofpa" xml:space="preserve">== Ibulungelo leencwadi ==
'''Ibulungelo leencwadi''' kuyindawo yomphakathi lapho kubekwe khona iiincwadi ngokwahlukahlukana ukuthi abantu bakghone ukuzifunda begodu bathole ilwazi ngeenhloko ezahlukahlukeneko abazithandako&lt;ref&gt;https://www.dictionary.com/browse/library&lt;/ref&gt;. Ibulungelo lencwadi lenza bona abantu bakghone ukuthola [[ilwazi]] lakade nelanje ngezinto zanje. Lithuthukisa izinga lefundo yabantu ngombana abantu bakghona ukuthola imithombo yelwazi eminengi efana neencwadi, amajenali, ne inthaneti lapho bazokufuna khona khona ilwazi. 

== Ukuqakatheka kwebulungelo leencwadi ==

=== Ukufunda nokutlola ===
Ibulungelo leencwadi lidala indima ekulu ekutheni abantu bakghone ukufunda nokutola, khulu khulu ebantwaneni nalapho imiphakathi yethu yakhona ingakathuthuki. Lokhu kwenziwa kukuthi endaweni ezinjengalezi ibulungelo leencwadi likghona ukwenza amahlelo wokufundisa abantwana ilimi begodu benze nemisebenzi eminye eyenza abantuwana bakghone ukufunda nokulalela&lt;ref&gt;Itsekor, V.O. and Nwokeoma, N.M., 2017. The Importance of the Use of Libraries and the Need for a Reading Culture. ''Acta Universitatis Lodziensis. Folia Librorum'', ''1''(24), pp.97-110.&lt;/ref&gt;. 

=== Irhubhululo nelwazi ===
Umuntu lokha nakenza irhubhululo afuna ilwazi eliliqiniso ukughona ukuya ebulungweni leencwadi lapho azokuthola khona ilwazi elizeleko ngesihloko arhubhulula ngaso. Ukhona ukuthola ama-athikili ezowasebenzisa erhubhululweni lakhe okutjho bona uzokuthola umthombo lwazi oneqiniso bese [[irhubhululo]] lakhe libe namandla. Abasenzi belungelweni leencwadi kwesinye isikhathi bayakghona ukuthi bakulelele ukwenza irhubhululo nokuthi ufake amareferensi ngendlela efaneleko. Lokhu kungenza umuntu orhubhululako aphumelele kuhle&lt;ref name=&quot;:0&quot;&gt;Hider, P., Garner, J., Wakeling, S. and Jamali, H.R., 2023. “Part of my daily life”: The importance of public libraries as physical spaces. ''Public Library Quarterly'', ''42''(2), pp.190-219.&lt;/ref&gt;. 

=== Ukuzikhipha ukubhoreka ===
Ebantwini abanekareko yokufunda nofana kwabathandaka ukufunda lokho nababhorekileko, ibulungelo leencwadi kuba yinto ebasizako. Ebulungelweni leencwadi kunemihlobo yoke yeencwadi abantu abangathanda ukuyifunda. Isibonelo iincwadi ezinenganekwana, iincwadi zelwazi, iincwadi ezikhulumako nezinye. Phezulu kwalokho bakunikela nendawo ethulileko ongafundela kiyo uthabelel ukufunda incwadi yakho. Nawungafuni ukuyindela khona bayakghona ukukuboleka yona uyoyifundela ekhaya bese uyibuyse ngenva kwamalanga. Akusizo zoke iincwadi ukghona ukuziboleka ukhambe nazo ekhaya&lt;ref name=&quot;:0&quot; /&gt;. 

=== Ukuzibandakanya komphakathi ===
Ibulungelo leencwadi likghona ukuba namakamero lapho abantu bomphakathi bangakghona ukuthi babambele khona imihlangano, nofana benzele khona indawo lapho iinqhema ziikghona ukuhlangana zabena ngemibono. 

=== Ukusebenzisa i-wifi simahla ===
Ebulungelweni leeencwadi abantu bakghona ukusebenzisa i-wifi simahla bangqabhadeli. Uthola ibulungelo leencwadi linamakhomphyutha abantu abangawasebenzisa ukuthola ilwazi ku-inthaneti. Lu kuyinto ehle khulu ngombana isiza nalabo bantu abangazo iinsetjenziswa zedijithali ukuthi bakghone nabo ukuthola ilwazi abalindingako&lt;ref&gt;Park, S., 2019. Analyzing library space use patterns in a public library through smartphone WiFi. ''Journal of the Korean Society for information Management'', ''36''(1), pp.295-313.&lt;/ref&gt;. 

== Isiphetho ==
bulungelo leencwadi luyindawo lapho abantu bakghona ukuthola ilwazi khona bathuthukise nekghona labo lokufunda nokufunda nokutlola. Kuyinawo lapho abantu bakghona ukurhelebheka khona ngeendlela ezinengi khona njengokuti bathole imthombo welwazi erhubhululweni labo, nokuthi bathole indawo ethulileko yokufunda. Ibulungelo leencwadi kuyindawo yokuzithuthukisa komphakathi.</text>
      <sha1>nzm30jf8waooh28too4xtjt6w6kofpa</sha1>
    </revision>
    <revision>
      <id>3002</id>
      <parentid>2643</parentid>
      <timestamp>2025-06-06T20:20:11Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>kiujyhtgbrvfd</comment>
      <origin>3002</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3839" sha1="06b3gndd2z6po52hxf1q1flwv2dw09b" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.'''

== Ibulungelo leencwadi ==
'''Ibulungelo leencwadi''' kuyindawo yomphakathi lapho kubekwe khona iiincwadi ngokwahlukahlukana ukuthi abantu bakghone ukuzifunda begodu bathole ilwazi ngeenhloko ezahlukahlukeneko abazithandako&lt;ref&gt;https://www.dictionary.com/browse/library&lt;/ref&gt;. Ibulungelo lencwadi lenza bona abantu bakghone ukuthola [[ilwazi]] lakade nelanje ngezinto zanje. Lithuthukisa izinga lefundo yabantu ngombana abantu bakghona ukuthola imithombo yelwazi eminengi efana neencwadi, amajenali, ne inthaneti lapho bazokufuna khona khona ilwazi. 

== Ukuqakatheka kwebulungelo leencwadi ==

=== Ukufunda nokutlola ===
Ibulungelo leencwadi lidala indima ekulu ekutheni abantu bakghone ukufunda nokutola, khulu khulu ebantwaneni nalapho imiphakathi yethu yakhona ingakathuthuki. Lokhu kwenziwa kukuthi endaweni ezinjengalezi ibulungelo leencwadi likghona ukwenza amahlelo wokufundisa abantwana ilimi begodu benze nemisebenzi eminye eyenza abantuwana bakghone ukufunda nokulalela&lt;ref&gt;Itsekor, V.O. and Nwokeoma, N.M., 2017. The Importance of the Use of Libraries and the Need for a Reading Culture. ''Acta Universitatis Lodziensis. Folia Librorum'', ''1''(24), pp.97-110.&lt;/ref&gt;. 

=== Irhubhululo nelwazi ===
Umuntu lokha nakenza irhubhululo afuna ilwazi eliliqiniso ukughona ukuya ebulungweni leencwadi lapho azokuthola khona ilwazi elizeleko ngesihloko arhubhulula ngaso. Ukhona ukuthola ama-athikili ezowasebenzisa erhubhululweni lakhe okutjho bona uzokuthola umthombo lwazi oneqiniso bese [[irhubhululo]] lakhe libe namandla. Abasenzi belungelweni leencwadi kwesinye isikhathi bayakghona ukuthi bakulelele ukwenza irhubhululo nokuthi ufake amareferensi ngendlela efaneleko. Lokhu kungenza umuntu orhubhululako aphumelele kuhle&lt;ref name=&quot;:0&quot;&gt;Hider, P., Garner, J., Wakeling, S. and Jamali, H.R., 2023. “Part of my daily life”: The importance of public libraries as physical spaces. ''Public Library Quarterly'', ''42''(2), pp.190-219.&lt;/ref&gt;. 

=== Ukuzikhipha ukubhoreka ===
Ebantwini abanekareko yokufunda nofana kwabathandaka ukufunda lokho nababhorekileko, ibulungelo leencwadi kuba yinto ebasizako. Ebulungelweni leencwadi kunemihlobo yoke yeencwadi abantu abangathanda ukuyifunda. Isibonelo iincwadi ezinenganekwana, iincwadi zelwazi, iincwadi ezikhulumako nezinye. Phezulu kwalokho bakunikela nendawo ethulileko ongafundela kiyo uthabelel ukufunda incwadi yakho. Nawungafuni ukuyindela khona bayakghona ukukuboleka yona uyoyifundela ekhaya bese uyibuyse ngenva kwamalanga. Akusizo zoke iincwadi ukghona ukuziboleka ukhambe nazo ekhaya&lt;ref name=&quot;:0&quot; /&gt;. 

=== Ukuzibandakanya komphakathi ===
Ibulungelo leencwadi likghona ukuba namakamero lapho abantu bomphakathi bangakghona ukuthi babambele khona imihlangano, nofana benzele khona indawo lapho iinqhema ziikghona ukuhlangana zabena ngemibono. 

=== Ukusebenzisa i-wifi simahla ===
Ebulungelweni leeencwadi abantu bakghona ukusebenzisa i-wifi simahla bangqabhadeli. Uthola ibulungelo leencwadi linamakhomphyutha abantu abangawasebenzisa ukuthola ilwazi ku-inthaneti. Lu kuyinto ehle khulu ngombana isiza nalabo bantu abangazo iinsetjenziswa zedijithali ukuthi bakghone nabo ukuthola ilwazi abalindingako&lt;ref&gt;Park, S., 2019. Analyzing library space use patterns in a public library through smartphone WiFi. ''Journal of the Korean Society for information Management'', ''36''(1), pp.295-313.&lt;/ref&gt;. 

== Isiphetho ==
bulungelo leencwadi luyindawo lapho abantu bakghona ukuthola ilwazi khona bathuthukise nekghona labo lokufunda nokufunda nokutlola. Kuyinawo lapho abantu bakghona ukurhelebheka khona ngeendlela ezinengi khona njengokuti bathole imthombo welwazi erhubhululweni labo, nokuthi bathole indawo ethulileko yokufunda. Ibulungelo leencwadi kuyindawo yokuzithuthukisa komphakathi.</text>
      <sha1>06b3gndd2z6po52hxf1q1flwv2dw09b</sha1>
    </revision>
    <revision>
      <id>3051</id>
      <parentid>3002</parentid>
      <timestamp>2025-06-07T03:05:22Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Nqobile69|Nqobile69]]</comment>
      <origin>2643</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3751" sha1="nzm30jf8waooh28too4xtjt6w6kofpa" xml:space="preserve">== Ibulungelo leencwadi ==
'''Ibulungelo leencwadi''' kuyindawo yomphakathi lapho kubekwe khona iiincwadi ngokwahlukahlukana ukuthi abantu bakghone ukuzifunda begodu bathole ilwazi ngeenhloko ezahlukahlukeneko abazithandako&lt;ref&gt;https://www.dictionary.com/browse/library&lt;/ref&gt;. Ibulungelo lencwadi lenza bona abantu bakghone ukuthola [[ilwazi]] lakade nelanje ngezinto zanje. Lithuthukisa izinga lefundo yabantu ngombana abantu bakghona ukuthola imithombo yelwazi eminengi efana neencwadi, amajenali, ne inthaneti lapho bazokufuna khona khona ilwazi. 

== Ukuqakatheka kwebulungelo leencwadi ==

=== Ukufunda nokutlola ===
Ibulungelo leencwadi lidala indima ekulu ekutheni abantu bakghone ukufunda nokutola, khulu khulu ebantwaneni nalapho imiphakathi yethu yakhona ingakathuthuki. Lokhu kwenziwa kukuthi endaweni ezinjengalezi ibulungelo leencwadi likghona ukwenza amahlelo wokufundisa abantwana ilimi begodu benze nemisebenzi eminye eyenza abantuwana bakghone ukufunda nokulalela&lt;ref&gt;Itsekor, V.O. and Nwokeoma, N.M., 2017. The Importance of the Use of Libraries and the Need for a Reading Culture. ''Acta Universitatis Lodziensis. Folia Librorum'', ''1''(24), pp.97-110.&lt;/ref&gt;. 

=== Irhubhululo nelwazi ===
Umuntu lokha nakenza irhubhululo afuna ilwazi eliliqiniso ukughona ukuya ebulungweni leencwadi lapho azokuthola khona ilwazi elizeleko ngesihloko arhubhulula ngaso. Ukhona ukuthola ama-athikili ezowasebenzisa erhubhululweni lakhe okutjho bona uzokuthola umthombo lwazi oneqiniso bese [[irhubhululo]] lakhe libe namandla. Abasenzi belungelweni leencwadi kwesinye isikhathi bayakghona ukuthi bakulelele ukwenza irhubhululo nokuthi ufake amareferensi ngendlela efaneleko. Lokhu kungenza umuntu orhubhululako aphumelele kuhle&lt;ref name=&quot;:0&quot;&gt;Hider, P., Garner, J., Wakeling, S. and Jamali, H.R., 2023. “Part of my daily life”: The importance of public libraries as physical spaces. ''Public Library Quarterly'', ''42''(2), pp.190-219.&lt;/ref&gt;. 

=== Ukuzikhipha ukubhoreka ===
Ebantwini abanekareko yokufunda nofana kwabathandaka ukufunda lokho nababhorekileko, ibulungelo leencwadi kuba yinto ebasizako. Ebulungelweni leencwadi kunemihlobo yoke yeencwadi abantu abangathanda ukuyifunda. Isibonelo iincwadi ezinenganekwana, iincwadi zelwazi, iincwadi ezikhulumako nezinye. Phezulu kwalokho bakunikela nendawo ethulileko ongafundela kiyo uthabelel ukufunda incwadi yakho. Nawungafuni ukuyindela khona bayakghona ukukuboleka yona uyoyifundela ekhaya bese uyibuyse ngenva kwamalanga. Akusizo zoke iincwadi ukghona ukuziboleka ukhambe nazo ekhaya&lt;ref name=&quot;:0&quot; /&gt;. 

=== Ukuzibandakanya komphakathi ===
Ibulungelo leencwadi likghona ukuba namakamero lapho abantu bomphakathi bangakghona ukuthi babambele khona imihlangano, nofana benzele khona indawo lapho iinqhema ziikghona ukuhlangana zabena ngemibono. 

=== Ukusebenzisa i-wifi simahla ===
Ebulungelweni leeencwadi abantu bakghona ukusebenzisa i-wifi simahla bangqabhadeli. Uthola ibulungelo leencwadi linamakhomphyutha abantu abangawasebenzisa ukuthola ilwazi ku-inthaneti. Lu kuyinto ehle khulu ngombana isiza nalabo bantu abangazo iinsetjenziswa zedijithali ukuthi bakghone nabo ukuthola ilwazi abalindingako&lt;ref&gt;Park, S., 2019. Analyzing library space use patterns in a public library through smartphone WiFi. ''Journal of the Korean Society for information Management'', ''36''(1), pp.295-313.&lt;/ref&gt;. 

== Isiphetho ==
bulungelo leencwadi luyindawo lapho abantu bakghona ukuthola ilwazi khona bathuthukise nekghona labo lokufunda nokufunda nokutlola. Kuyinawo lapho abantu bakghona ukurhelebheka khona ngeendlela ezinengi khona njengokuti bathole imthombo welwazi erhubhululweni labo, nokuthi bathole indawo ethulileko yokufunda. Ibulungelo leencwadi kuyindawo yokuzithuthukisa komphakathi.</text>
      <sha1>nzm30jf8waooh28too4xtjt6w6kofpa</sha1>
    </revision>
    <revision>
      <id>3369</id>
      <parentid>3051</parentid>
      <timestamp>2025-07-09T13:03:26Z</timestamp>
      <contributor>
        <username>Roxanne2019</username>
        <id>755</id>
      </contributor>
      <comment>I edited the errors and changed few words and repeatition</comment>
      <origin>3369</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1907" sha1="qwe75768rntjr7cajgdqv18p28phbjh" xml:space="preserve">
Ibulungelo leencwadi kuyindawo yomphakathi lapho kubekwa khona iincwadi ngokwahlukahlukana kwazo ukuthi abantu bakghone ukuzifunda begodu bathole ilwazi ngeenhloko ezahlukahlukeneko abazithandako. Ibulungelo leencwadi lenza bona abantu bakghone ukuthola ilwazi lezinto zakade nezakhathesu. Lithuthukisa izinga lefundo yabantu ngombana bakghona ukuthola imithombo yelwazi eminengi efaka hlangana neencwadi, amajenali, ne inthaneti lapho bazokufuna khona ilwazi.[1]

Amabulungelo weencwadi ahluke khulu ngobukhulu, itlhogomelwa yihlangano yomphakathi efana norhulumende, isikole, nofana umuntu ozijameleko. Ibulungelo leli linikela ngamahlelo wabasebenzi belungelo leencwadi ekutholeni, ukukhetha, nokuhlela ilwazi lokha nabahlathulula abakufunako ngelwazi basebenzisa iinsetjenziswa ezahlukahlukeneko. Indawo le yaziwa ngokuthi iyi iyisayensi yebulungelo leenwadi nelwazi nofana iimfundo.[2]

Umlando
Umlando webulungelo leencwadi wathoma ngemizamo yokuthoma yokuhlela amaphepha abalulekileko. Iinhloko ezidosa amehlo ezifaka hlangana ukurhweba kweencwadi, ukusabalaliswa kwelimi, indima emfundweni, izakhiwo, amazinga wokufunda nokutlola, ukusebenziswa kwamabulungelo weencwadi zamagugu wamasiko wesitjhaba, kanye nendima karhulumende, isondo nofana ukusejelwa kwangesese. Ukusetjenziswa kwamakhomphyutha nokudijithali kwavela ngeminyaka yabo-1960, begodu kwatjhugulula izinto ezinengi zamabulungelo weencwadi.[3]

Iinkomba
 Searing, Susan E.; Greenlee, Alison M. (2011). &quot;Faculty Responses to Library Service Innovations: A Case Study&quot;. Journal of Education for Library and Information Science,https://www.jstor.org/stable/41308904
 Fleming-May, Rachel A. (2011)The Library Quarterly: Information, Community, Policy. 81 (3): 297–320.,https://www.jstor.org/stable/10.1086/660133
 Wikipedia, 2025-06-20, retrieved 2025-07-09,https://en.wikipedia.org/w/index.php?title=History_of_libraries&amp;oldid=1296583094</text>
      <sha1>qwe75768rntjr7cajgdqv18p28phbjh</sha1>
    </revision>
    <revision>
      <id>3370</id>
      <parentid>3369</parentid>
      <timestamp>2025-07-09T13:08:55Z</timestamp>
      <contributor>
        <username>Roxanne2019</username>
        <id>755</id>
      </contributor>
      <origin>3370</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2245" sha1="121e5a6xs5aciibudbs4spqng93bkzp" xml:space="preserve">
[[Isimumathi:Library Image.jpg|thumb|Isibonelo sebulungelo leencwadi]]

Original page; [[Ibulungelo leencwadi|'''Ibulungelo leencwadi''']]


Ibulungelo leencwadi kuyindawo yomphakathi lapho kubekwa khona iincwadi ngokwahlukahlukana kwazo ukuthi abantu bakghone ukuzifunda begodu bathole ilwazi ngeenhloko ezahlukahlukeneko abazithandako. Ibulungelo leencwadi lenza bona abantu bakghone ukuthola ilwazi lezinto zakade nezakhathesu. Lithuthukisa izinga lefundo yabantu ngombana bakghona ukuthola imithombo yelwazi eminengi efaka hlangana neencwadi, amajenali, ne inthaneti lapho bazokufuna khona ilwazi.&lt;ref&gt;Searing, Susan E.; Greenlee, Alison M. (2011). &quot;Faculty Responses to Library Service Innovations: A Case Study&quot;. ''Journal of Education for Library and Information Science'',https://www.jstor.org/stable/41308904&lt;/ref&gt; 

Amabulungelo weencwadi ahluke khulu ngobukhulu, itlhogomelwa yihlangano yomphakathi efana norhulumende, isikole, nofana umuntu ozijameleko. Ibulungelo leli linikela ngamahlelo wabasebenzi belungelo leencwadi ekutholeni, ukukhetha, nokuhlela ilwazi lokha nabahlathulula abakufunako ngelwazi basebenzisa iinsetjenziswa ezahlukahlukeneko. Indawo le yaziwa ngokuthi iyi iyisayensi yebulungelo leenwadi nelwazi nofana iimfundo.&lt;ref&gt;Fleming-May, Rachel A. (2011)[https://www.jstor.org/stable/10.1086/660133 ''The Library Quarterly: Information, Community, Policy''. '''81''' (3): 297–320.,https://www.jstor.org/stable/10.1086/660133]&lt;/ref&gt;   

== Umlando ==
Umlando webulungelo leencwadi wathoma ngemizamo yokuthoma yokuhlela amaphepha abalulekileko. Iinhloko ezidosa amehlo ezifaka hlangana ukurhweba kweencwadi, ukusabalaliswa kwelimi, indima emfundweni, izakhiwo, amazinga wokufunda nokutlola, ukusebenziswa kwamabulungelo weencwadi zamagugu wamasiko wesitjhaba, kanye nendima karhulumende, isondo nofana ukusejelwa kwangesese. Ukusetjenziswa kwamakhomphyutha nokudijithali kwavela ngeminyaka yabo-1960, begodu kwatjhugulula izinto ezinengi zamabulungelo weencwadi.&lt;ref&gt;''Wikipedia'', 2025-06-20, retrieved 2025-07-09,https://en.wikipedia.org/w/index.php?title=History_of_libraries&amp;oldid=1296583094&lt;/ref&gt;  

== Iinkomba ==
&lt;references /&gt;
[[Mkhakha:Ibulungelo leencwadi]]
[[Mkhakha:Iinsetjenziswa zebulungelo leencwadi]]</text>
      <sha1>121e5a6xs5aciibudbs4spqng93bkzp</sha1>
    </revision>
    <revision>
      <id>3372</id>
      <parentid>3370</parentid>
      <timestamp>2025-07-09T13:10:49Z</timestamp>
      <contributor>
        <username>Roxanne2019</username>
        <id>755</id>
      </contributor>
      <origin>3372</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2230" sha1="ea1wfpoib324oj0vxs98vouqsk1ux7j" xml:space="preserve">
[[Isimumathi:Library Image.jpg|thumb|Isibonelo sebulungelo leencwadi]]

[[Ibulungelo leencwadi|'''Ibulungelo leencwadi''']]


Ibulungelo leencwadi kuyindawo yomphakathi lapho kubekwa khona iincwadi ngokwahlukahlukana kwazo ukuthi abantu bakghone ukuzifunda begodu bathole ilwazi ngeenhloko ezahlukahlukeneko abazithandako. Ibulungelo leencwadi lenza bona abantu bakghone ukuthola ilwazi lezinto zakade nezakhathesu. Lithuthukisa izinga lefundo yabantu ngombana bakghona ukuthola imithombo yelwazi eminengi efaka hlangana neencwadi, amajenali, ne inthaneti lapho bazokufuna khona ilwazi.&lt;ref&gt;Searing, Susan E.; Greenlee, Alison M. (2011). &quot;Faculty Responses to Library Service Innovations: A Case Study&quot;. ''Journal of Education for Library and Information Science'',https://www.jstor.org/stable/41308904&lt;/ref&gt; 

Amabulungelo weencwadi ahluke khulu ngobukhulu, itlhogomelwa yihlangano yomphakathi efana norhulumende, isikole, nofana umuntu ozijameleko. Ibulungelo leli linikela ngamahlelo wabasebenzi belungelo leencwadi ekutholeni, ukukhetha, nokuhlela ilwazi lokha nabahlathulula abakufunako ngelwazi basebenzisa iinsetjenziswa ezahlukahlukeneko. Indawo le yaziwa ngokuthi iyi iyisayensi yebulungelo leenwadi nelwazi nofana iimfundo.&lt;ref&gt;Fleming-May, Rachel A. (2011)[https://www.jstor.org/stable/10.1086/660133 ''The Library Quarterly: Information, Community, Policy''. '''81''' (3): 297–320.,https://www.jstor.org/stable/10.1086/660133]&lt;/ref&gt;   

== Umlando ==
Umlando webulungelo leencwadi wathoma ngemizamo yokuthoma yokuhlela amaphepha abalulekileko. Iinhloko ezidosa amehlo ezifaka hlangana ukurhweba kweencwadi, ukusabalaliswa kwelimi, indima emfundweni, izakhiwo, amazinga wokufunda nokutlola, ukusebenziswa kwamabulungelo weencwadi zamagugu wamasiko wesitjhaba, kanye nendima karhulumende, isondo nofana ukusejelwa kwangesese. Ukusetjenziswa kwamakhomphyutha nokudijithali kwavela ngeminyaka yabo-1960, begodu kwatjhugulula izinto ezinengi zamabulungelo weencwadi.&lt;ref&gt;''Wikipedia'', 2025-06-20, retrieved 2025-07-09,https://en.wikipedia.org/w/index.php?title=History_of_libraries&amp;oldid=1296583094&lt;/ref&gt;  

== Iinkomba ==
&lt;references /&gt;
[[Mkhakha:Ibulungelo leencwadi]]
[[Mkhakha:Iinsetjenziswa zebulungelo leencwadi]]</text>
      <sha1>ea1wfpoib324oj0vxs98vouqsk1ux7j</sha1>
    </revision>
    <revision>
      <id>3421</id>
      <parentid>3372</parentid>
      <timestamp>2025-07-12T14:04:56Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3421</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2185" sha1="tcn3pqsmjqsnjkzr76dk75u53pn21c9" xml:space="preserve">
[[Isimumathi:Library Image.jpg|thumb|Isibonelo sebulungelo leencwadi]]
'''Ibulungelo leencwadi''' kuyindawo yomphakathi lapho kubekwa khona [[iincwadi]] ngokwahlukahlukana kwazo ukuthi abantu bakghone ukuzifunda begodu bathole ilwazi ngeenhloko ezahlukahlukeneko abazithandako. Ibulungelo leencwadi lenza bona abantu bakghone ukuthola ilwazi lezinto zakade nezakhathesu. Lithuthukisa izinga lefundo yabantu ngombana bakghona ukuthola imithombo yelwazi eminengi efaka hlangana neencwadi, amajenali, ne inthaneti lapho bazokufuna khona ilwazi.&lt;ref&gt;Searing, Susan E.; Greenlee, Alison M. (2011). &quot;Faculty Responses to Library Service Innovations: A Case Study&quot;. ''Journal of Education for Library and Information Science'',https://www.jstor.org/stable/41308904&lt;/ref&gt; 

Amabulungelo weencwadi ahluke khulu ngobukhulu, itlhogonyelwa yihlangano yomphakathi efana norhulumende, isikolo, nofana umuntu ozijameleko. Ibulungelo leli linikela ngamahlelo wabasebenzi belungelo leencwadi ekutholeni, ukukhetha, nokuhlela ilwazi lokha nabahlathulula abakufunako ngelwazi basebenzisa iinsetjenziswa ezahlukahlukeneko. Indawo le yaziwa ngokuthi iyi iyisayensi yebulungelo leenwadi nelwazi nofana iimfundo.&lt;ref&gt;Fleming-May, Rachel A. (2011)[https://www.jstor.org/stable/10.1086/660133 ''The Library Quarterly: Information, Community, Policy''. '''81''' (3): 297–320.,https://www.jstor.org/stable/10.1086/660133]&lt;/ref&gt;

=== Umlando ===
Umlando webulungelo leencwadi wathoma ngemizamo yokuthoma yokuhlela amaphepha abalulekileko. Iinhloko ezidosa amehlo ezifaka hlangana ukurhweba kweencwadi, ukusabalaliswa kwelimi, indima emfundweni, izakhiwo, amazinga wokufunda nokutlola, ukusebenziswa kwamabulungelo weencwadi zamagugu wamasiko wesitjhaba, kanye nendima karhulumende, isondo nofana ukusejelwa kwangesese. Ukusetjenziswa kwamakhomphyutha nokudijithali kwavela ngeminyaka yabo-1960, begodu kwatjhugulula izinto ezinengi zamabulungelo weencwadi.&lt;ref&gt;''Wikipedia'', 2025-06-20, retrieved 2025-07-09,https://en.wikipedia.org/w/index.php?title=History_of_libraries&amp;oldid=1296583094&lt;/ref&gt;  

== Iinkomba ==
&lt;references /&gt;
[[Mkhakha:Ibulungelo leencwadi]]
[[Mkhakha:Iinsetjenziswa zebulungelo leencwadi]]</text>
      <sha1>tcn3pqsmjqsnjkzr76dk75u53pn21c9</sha1>
    </revision>
  </page>
  <page>
    <title>Ukubumba</title>
    <ns>0</ns>
    <id>545</id>
    <revision>
      <id>2641</id>
      <timestamp>2025-04-04T09:26:23Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Ukubumba == '''Ukubumba''' kukulokha umuntu athathe idaka elithileko ngemlanjeni elibizwa ngobumba bese alisebenzise ukwakha into ethileko&lt;ref&gt;https://www.dictionary.com/browse/pottery&lt;/ref&gt;. Umuntu nakabumbako uthatha idaka leli aleze libe manzi alibhice, aligobe nofana alimbumbe ukuze akhone ukukhipha into ahlose ukuyenza. Bese kuthi sele abumbile alibeke alindele bona lome bese lingaphuki.Umuntu angakha ikomo, ikukhu, nofana okunye ngobumba.  Ukubumba kungobunye bo...&quot;</comment>
      <origin>2641</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2262" sha1="qr4z6ykr5sr266iv8jiecjl977zrt66" xml:space="preserve">== Ukubumba ==
'''Ukubumba''' kukulokha umuntu athathe idaka elithileko ngemlanjeni elibizwa ngobumba bese alisebenzise ukwakha into ethileko&lt;ref&gt;https://www.dictionary.com/browse/pottery&lt;/ref&gt;. Umuntu nakabumbako uthatha idaka leli aleze libe manzi alibhice, aligobe nofana alimbumbe ukuze akhone ukukhipha into ahlose ukuyenza. Bese kuthi sele abumbile alibeke alindele bona lome bese lingaphuki.Umuntu angakha ikomo, ikukhu, nofana okunye ngobumba.

Ukubumba kungobunye bobukghwari babantu abanzima bekadeni. [[Amasokana]] lokha nakaweleko nakufika [[isikhathi]] seenthalelo bapha abantwana izipho ebazenze ngobumba lokha nabeze eenthalelweni. Ekadeni ukubumba bekuyinto eqakathekileko ngombana bekubunjwa imijeka uzokufaka Ukudla, amanzi nofana ezinye izinto zangendlini. Abanye bebabumba izinto abazokurhabisa ngazo.

== Ukuqakatheka kokubumba ==
Ukubumba kuyinto ehle khulu ngombana kukhombisa ikghono lobukghwari. Ekadeni beyinto eqakatheke khulu elekelela abantu bona babe nezinto zokufaka begodu bebakghona nokukhangisa inzinto ebazibumbuleko benze imali&lt;ref&gt;Jones, R.F.J., 2016. Why Pottery?. In ''Pottery and the Archaeologist'' (pp. 1-5). Routledge.&lt;/ref&gt;. Kuyinto elekelela abarhubhululi bezinto zakade bona bakghone ukuthola isikhathi somlando wezinto zakade ukuze bakghone ukubulunga amasiko nobunjalo bawo&lt;ref&gt;Skibo, J.M. and Skibo, J.M., 2013. ''Understanding pottery function'' (pp. 1-25). Springer New York.&lt;/ref&gt;.

Ukubumba kuyinto etholakale bona kuyakhona ukwenza bona umuntu aledlhe akhone ukwehlisa ukucabanga khulu nokuhlubayejeka emkhumbulweni. Ukubumba kulekelela umuntu bona ukuthuthukisa ikghono lokukhambelana kwesandla nelihlo. Ukubumba kusiza bona umuntu athuthukise ikghono lokusebenza kwemisipha emincani esesandleni.

== Iindlela zokubumba ==
Ukubumba ngemithi nofana ngeengodo
Ukubumba ngeengodo kukolokha umuntu athatha isigodo esiphuma esihlahleni bese asibaze ache nofana abumbe into ayifunako. Isibonelo umuntu angathatha isigodo bese asibaze akhiphe iphini nofana iphehlo lokhupheka ngendlini.

Ukubumba ngomdaka

Ukubumba ngomdaka kukulokha umuntu athatha idaka lokubumba akha into ayifunako kungaba yinto ehle yokuhlobisa ngendlini. Zikhona nezinye iindlela zokubumba zesikhathi zanamhlanjesi ekungasizo ezivela ekadeni</text>
      <sha1>qr4z6ykr5sr266iv8jiecjl977zrt66</sha1>
    </revision>
    <revision>
      <id>2642</id>
      <parentid>2641</parentid>
      <timestamp>2025-04-04T09:27:21Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2642</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2267" sha1="qlv7fft5hzwmm5r9jmt4zsgaeqlcm28" xml:space="preserve">== Ukubumba ==
'''Ukubumba''' kukulokha umuntu athathe idaka elithileko ngemlanjeni elibizwa ngobumba bese alisebenzise ukwakha into ethileko&lt;ref&gt;https://www.dictionary.com/browse/pottery&lt;/ref&gt;. Umuntu nakabumbako uthatha idaka leli aleze libe manzi alibhice, aligobe nofana alimbumbe ukuze akhone ukukhipha into ahlose ukuyenza. Bese kuthi sele abumbile alibeke alindele bona lome bese lingaphuki.Umuntu angakha ikomo, ikukhu, nofana okunye ngobumba.

Ukubumba kungobunye bobukghwari babantu abanzima bekadeni. [[Amasokana]] lokha nakaweleko nakufika [[isikhathi]] seenthalelo bapha abantwana izipho ebazenze ngobumba lokha nabeze eenthalelweni. Ekadeni ukubumba bekuyinto eqakathekileko ngombana bekubunjwa imijeka uzokufaka Ukudla, amanzi nofana ezinye izinto zangendlini. Abanye bebabumba izinto abazokurhabisa ngazo.

== Ukuqakatheka kokubumba ==
Ukubumba kuyinto ehle khulu ngombana kukhombisa ikghono lobukghwari. Ekadeni beyinto eqakatheke khulu elekelela abantu bona babe nezinto zokufaka begodu bebakghona nokukhangisa inzinto ebazibumbuleko benze imali&lt;ref&gt;Jones, R.F.J., 2016. Why Pottery?. In ''Pottery and the Archaeologist'' (pp. 1-5). Routledge.&lt;/ref&gt;. Kuyinto elekelela abarhubhululi bezinto zakade bona bakghone ukuthola isikhathi somlando wezinto zakade ukuze bakghone ukubulunga amasiko nobunjalo bawo&lt;ref&gt;Skibo, J.M. and Skibo, J.M., 2013. ''Understanding pottery function'' (pp. 1-25). Springer New York.&lt;/ref&gt;.

Ukubumba kuyinto etholakale bona kuyakhona ukwenza bona umuntu aledlhe akhone ukwehlisa ukucabanga khulu nokuhlubayejeka emkhumbulweni. Ukubumba kulekelela umuntu bona ukuthuthukisa ikghono lokukhambelana kwesandla nelihlo. Ukubumba kusiza bona umuntu athuthukise ikghono lokusebenza kwemisipha emincani esesandleni.

== Iindlela zokubumba ==
Ukubumba ngemithi nofana ngeengodo

Ukubumba ngeengodo kukolokha umuntu athatha isigodo esiphuma esihlahleni bese asibaze ache nofana abumbe into ayifunako. Isibonelo umuntu angathatha isigodo bese asibaze akhiphe iphini nofana iphehlo lokhupheka ngendlini.

Ukubumba ngomdaka

Ukubumba ngomdaka kukulokha umuntu athatha [[idaka]] lokubumba akha into ayifunako kungaba yinto ehle yokuhlobisa ngendlini. Zikhona nezinye iindlela zokubumba zesikhathi zanamhlanjesi ekungasizo ezivela ekadeni</text>
      <sha1>qlv7fft5hzwmm5r9jmt4zsgaeqlcm28</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Derek J Moore</title>
    <ns>2</ns>
    <id>546</id>
    <revision>
      <id>2652</id>
      <timestamp>2025-04-07T18:32:42Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>Tabs Added</comment>
      <origin>2652</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="133" sha1="24561wyryb7gdeg3pxvmq15e7aq5tdn" xml:space="preserve">{{Tabs
| NOTOC = true
| [[Umsebenzisi:Derek_J_Moore|Tab 1]]
| [[Umsebenzisi:Derek_J_Moore|Tab 2]]
| [[Main Page |Home]]
| This = 1
}}</text>
      <sha1>24561wyryb7gdeg3pxvmq15e7aq5tdn</sha1>
    </revision>
    <revision>
      <id>2656</id>
      <parentid>2652</parentid>
      <timestamp>2025-04-07T18:56:26Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <minor />
      <comment>Added greetings sign</comment>
      <origin>2656</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="204" sha1="66kvcyu7wl7uteqwcj27xikvw6v2vui" xml:space="preserve">{{Tabs
| NOTOC = true
| [[Umsebenzisi:Derek_J_Moore|Tab 1]]
| [[Umsebenzisi:Derek_J_Moore|Tab 2]]
| [[Main Page |Home]]
| This = 1
}}
[[File:Greetings in many languages.png|thumb|South African Greetings]]</text>
      <sha1>66kvcyu7wl7uteqwcj27xikvw6v2vui</sha1>
    </revision>
    <revision>
      <id>5919</id>
      <parentid>2656</parentid>
      <timestamp>2025-10-23T12:17:15Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>added tabs</comment>
      <origin>5919</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="335" sha1="332dp3b30mutpoqyxwvg2cvco92zgho" xml:space="preserve">{{Tabs
| NOTOC = true
| [[Umsebenzisi:Derek_J_Moore|Umsebenzisi]]
| [[Umsebenzisi:Derek_J_Moore/Begin|okuphelelwe yisikhathi]]
| [[Umsebenzisi:Derek_J_Moore/Middle|ukubuyekezwa]]
| [[Umsebenzisi:Derek_J_Moore/Sandbox|Sandbox]]
| [[Main Page |ikhasi]]
| This = 1
}}
[[File:Greetings in many languages.png|thumb|South African Greetings]]</text>
      <sha1>332dp3b30mutpoqyxwvg2cvco92zgho</sha1>
    </revision>
    <revision>
      <id>5922</id>
      <parentid>5919</parentid>
      <timestamp>2025-10-23T12:26:46Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>test</comment>
      <origin>5922</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="79" sha1="giqj0o25yvkgfxgyj7re1a27m0o3pmn" xml:space="preserve">{{Tabs}}
[[File:Greetings in many languages.png|thumb|South African Greetings]]</text>
      <sha1>giqj0o25yvkgfxgyj7re1a27m0o3pmn</sha1>
    </revision>
    <revision>
      <id>5924</id>
      <parentid>5922</parentid>
      <timestamp>2025-10-23T12:40:04Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>set up tabs</comment>
      <origin>5924</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="288" sha1="7gmr6w7n9xgq5cdtt3mcixyt85adssc" xml:space="preserve">{{Tabs
| NOTOC = true
| [[User:Derek_J_Moore|umsebenzisi]]
| [[User:Derek_J_Moore/Begin|dala]]
| [[User:Derek_J_Moore/Middle|ukubuyekeza]]
| [[User:Derek_J_Moore/Sandbox|sandbox]]
| [[Main Page |ikhasi]]
| This = 1
}}
[[File:Greetings in many languages.png|thumb|South African Greetings]]</text>
      <sha1>7gmr6w7n9xgq5cdtt3mcixyt85adssc</sha1>
    </revision>
    <revision>
      <id>5925</id>
      <parentid>5924</parentid>
      <timestamp>2025-10-23T12:43:57Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>home page</comment>
      <origin>5925</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1890" sha1="l9bg7vf9aej07tohafcpyvxd3mjc4ln" xml:space="preserve">{{Tabs
| NOTOC = true
| [[User:Derek_J_Moore|umsebenzisi]]
| [[User:Derek_J_Moore/Begin|dala]]
| [[User:Derek_J_Moore/Middle|ukubuyekeza]]
| [[User:Derek_J_Moore/Sandbox|sandbox]]
| [[Main Page |ikhasi]]
| This = 1
}}
[[File:Greetings in many languages.png|thumb|South African Greetings]]

== Ufuna ukufunda ngekhasi lomsebenzisi ndawonye? ==

Lotjha. Ibizo lami ngingu-Derek Moore. Ngingu-[[Ithekhnoloji yezeFundo]] begodu ngisebenza ne-[[ithekhnoloji yezeFundo]]. Ngibuye ngibe [[Umklami wokufundisa|umklami wokufundisa]]. Senza i-encyclopedia esezingeni lephasi ngesi-Afrikaans, begodu ungasiza!

{{Fmbox
|isithombe=[[Ifayela:Ikhamera aabb.svg|20px|link=Umsebenzisi:Derek_J_Moore]]
|isitayela = umbala wangemuva: #EAF3FF; ukugcwalisa: .5em 1em .5em .5em; umngcele: ayikho;
|umtlolo = {{sula}}
# Thatha [[Isithombe sehloko |isithombe sehloko]]
# Ngena ngebizo lakho lomsebenzisi nephasiwedi
# Vakatjhela [https://commons.wikimedia.org/wiki/Homepage Commons.Wikipedia]. Layisha isithombe nofana isithombe
}}

== Iye, ngizokwenza ikhasi lomsebenzisi ==
{{Ikhasi elitjha lomsebenzisi}}

&lt;nowiki&gt;*&lt;/nowiki&gt; [[ORCID]]{{Ukulawula igunya | ORCID = 0000-0003-1895-2918 }}


{{imbewu}}

&lt;hr&gt;


{{Userbox|border-c=#bcb234|border-s=1|id-c=#819637|id-p=5px|info-p=0px 8px|info-c=#f4f4f4|info-s=9|info-fc=black|id=[File:Finger:Ing-ing-ing. 52px]]|info=Umsebenzisi lo ukholelwa bona [[User:Derek_J_Moore/Begin|Ukuthembeka kwe-Wikipedia]] kuthembele kuwe.}}


&lt;div id=&quot;previewnote-an&quot;&gt;
{| cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; style=&quot;width:100%; clear:both; background-color:#e2f2d2; border:2px solid #acce79;&quot;
|- align=&quot;kwesokudla&quot;
| rowspan=&quot;3&quot; align=&quot;center&quot; width=&quot;64px&quot; | [[Isithombe:Start hand.svg|30x30px]]
|align=&quot;left&quot; style=&quot;padding-left:30px&quot;|&lt;span style=&quot;color:green; solid green&quot;&gt;[[:ZU:User:Derek_J_Moore|Lo suktiusei uhinwesi ukubeinde kweWikipedia kuncike kuwe.]]
|}
&lt;/div&gt;
{{Isigaba:Ikholi|1}}</text>
      <sha1>l9bg7vf9aej07tohafcpyvxd3mjc4ln</sha1>
    </revision>
    <revision>
      <id>5928</id>
      <parentid>5925</parentid>
      <timestamp>2025-10-23T12:51:22Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <origin>5928</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1891" sha1="csii1mma9ae8dwm8m21ch36gix9wbdf" xml:space="preserve">{{Tabs
| NOTOC = true
| [[User:Derek_J_Moore|umsebenzisi]]
| [[User:Derek_J_Moore/Begin|dala]]
| [[User:Derek_J_Moore/Middle|ukubuyekeza]]
| [[User:Derek_J_Moore/Sandbox|sandbox]]
| [[Main Page |ikhasi]]
| This = 1
}}
[[File:Greetings in many languages.png|thumb|South African Greetings]]

== Ufuna ukufunda ngekhasi lomsebenzisi ndawonye? ==

Lotjha. Ibizo lami ngingu-Derek Moore. Ngingu-[[Ithekhnoloji yezeFundo]] begodu ngisebenza ne-[[ithekhnoloji yezeFundo]]. Ngibuye ngibe [[Umklami wokufundisa|umklami wokufundisa]]. Senza i-encyclopedia esezingeni lephasi ngesi-Afrikaans, begodu ungasiza!

{{Fmbox
|isithombe=[[Ifayela:Ikhamera aabb.svg|20px|link=Umsebenzisi:Derek_J_Moore]]
|isitayela = umbala wangemuva: #EAF3FF; ukugcwalisa: .5em 1em .5em .5em; umngcele: ayikho;
|umtlolo = {{clear}}
# Thatha [[Isithombe sehloko |isithombe sehloko]]
# Ngena ngebizo lakho lomsebenzisi nephasiwedi
# Vakatjhela [https://commons.wikimedia.org/wiki/Homepage Commons.Wikipedia]. Layisha isithombe nofana isithombe
}}

== Iye, ngizokwenza ikhasi lomsebenzisi ==
{{Ikhasi elitjha lomsebenzisi}}

&lt;nowiki&gt;*&lt;/nowiki&gt; [[ORCID]]{{Ukulawula igunya | ORCID = 0000-0003-1895-2918 }}


{{imbewu}}

&lt;hr&gt;


{{Userbox|border-c=#bcb234|border-s=1|id-c=#819637|id-p=5px|info-p=0px 8px|info-c=#f4f4f4|info-s=9|info-fc=black|id=[File:Finger:Ing-ing-ing. 52px]]|info=Umsebenzisi lo ukholelwa bona [[User:Derek_J_Moore/Begin|Ukuthembeka kwe-Wikipedia]] kuthembele kuwe.}}


&lt;div id=&quot;previewnote-an&quot;&gt;
{| cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; style=&quot;width:100%; clear:both; background-color:#e2f2d2; border:2px solid #acce79;&quot;
|- align=&quot;kwesokudla&quot;
| rowspan=&quot;3&quot; align=&quot;center&quot; width=&quot;64px&quot; | [[Isithombe:Start hand.svg|30x30px]]
|align=&quot;left&quot; style=&quot;padding-left:30px&quot;|&lt;span style=&quot;color:green; solid green&quot;&gt;[[:ZU:User:Derek_J_Moore|Lo suktiusei uhinwesi ukubeinde kweWikipedia kuncike kuwe.]]
|}
&lt;/div&gt;
{{Isigaba:Ikholi|1}}</text>
      <sha1>csii1mma9ae8dwm8m21ch36gix9wbdf</sha1>
    </revision>
    <revision>
      <id>5929</id>
      <parentid>5928</parentid>
      <timestamp>2025-10-23T12:51:39Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <origin>5929</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1891" sha1="tpgcaonlogb4rovyyj65k2rbz2y8y8d" xml:space="preserve">{{Tabs
| NOTOC = true
| [[User:Derek_J_Moore|umsebenzisi]]
| [[User:Derek_J_Moore/Begin|dala]]
| [[User:Derek_J_Moore/Middle|ukubuyekeza]]
| [[User:Derek_J_Moore/Sandbox|sandbox]]
| [[Main Page |ikhasi]]
| This = 1
}}
[[File:Greetings in many languages.png|thumb|South African Greetings]]

== Ufuna ukufunda ngekhasi lomsebenzisi ndawonye? ==

Lotjha. Ibizo lami ngingu-Derek Moore. Ngingu-[[Ithekhnoloji yezeFundo]] begodu ngisebenza ne-[[ithekhnoloji yezeFundo]]. Ngibuye ngibe [[Umklami wokufundisa|umklami wokufundisa]]. Senza i-encyclopedia esezingeni lephasi ngesi-Afrikaans, begodu ungasiza!

{{Fmbox
|isithombe=[[Ifayela:Ikhamera aabb.svg|20px|link=Umsebenzisi:Derek_J_Moore]]
|isitayela = umbala wangemuva: #EAF3FF; ukugcwalisa: .5em 1em .5em .5em; umngcele: ayikho;
|umtlolo = {{Clear}}
# Thatha [[Isithombe sehloko |isithombe sehloko]]
# Ngena ngebizo lakho lomsebenzisi nephasiwedi
# Vakatjhela [https://commons.wikimedia.org/wiki/Homepage Commons.Wikipedia]. Layisha isithombe nofana isithombe
}}

== Iye, ngizokwenza ikhasi lomsebenzisi ==
{{Ikhasi elitjha lomsebenzisi}}

&lt;nowiki&gt;*&lt;/nowiki&gt; [[ORCID]]{{Ukulawula igunya | ORCID = 0000-0003-1895-2918 }}


{{imbewu}}

&lt;hr&gt;


{{Userbox|border-c=#bcb234|border-s=1|id-c=#819637|id-p=5px|info-p=0px 8px|info-c=#f4f4f4|info-s=9|info-fc=black|id=[File:Finger:Ing-ing-ing. 52px]]|info=Umsebenzisi lo ukholelwa bona [[User:Derek_J_Moore/Begin|Ukuthembeka kwe-Wikipedia]] kuthembele kuwe.}}


&lt;div id=&quot;previewnote-an&quot;&gt;
{| cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; style=&quot;width:100%; clear:both; background-color:#e2f2d2; border:2px solid #acce79;&quot;
|- align=&quot;kwesokudla&quot;
| rowspan=&quot;3&quot; align=&quot;center&quot; width=&quot;64px&quot; | [[Isithombe:Start hand.svg|30x30px]]
|align=&quot;left&quot; style=&quot;padding-left:30px&quot;|&lt;span style=&quot;color:green; solid green&quot;&gt;[[:ZU:User:Derek_J_Moore|Lo suktiusei uhinwesi ukubeinde kweWikipedia kuncike kuwe.]]
|}
&lt;/div&gt;
{{Isigaba:Ikholi|1}}</text>
      <sha1>tpgcaonlogb4rovyyj65k2rbz2y8y8d</sha1>
    </revision>
    <revision>
      <id>5931</id>
      <parentid>5929</parentid>
      <timestamp>2025-10-23T12:57:17Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>nope</comment>
      <origin>5931</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1860" sha1="4xwmk3sqctaanqvu98bwwax93tboti4" xml:space="preserve">{{Tabs
| NOTOC = true
| [[User:Derek_J_Moore|umsebenzisi]]
| [[User:Derek_J_Moore/Begin|dala]]
| [[User:Derek_J_Moore/Middle|ukubuyekeza]]
| [[User:Derek_J_Moore/Sandbox|sandbox]]
| [[Main Page |ikhasi]]
| This = 1
}}
[[File:Greetings in many languages.png|thumb|South African Greetings]]

== Ufuna ukufunda ngekhasi lomsebenzisi ndawonye? ==

Lotjha. Ibizo lami ngingu-Derek Moore. Ngingu-[[Ithekhnoloji yezeFundo]] begodu ngisebenza ne-[[ithekhnoloji yezeFundo]]. Ngibuye ngibe [[Umklami wokufundisa|umklami wokufundisa]]. Senza i-encyclopedia esezingeni lephasi ngesi-Afrikaans, begodu ungasiza!

{{Fmbox
|image=[[File:Camera aabb.svg|20px|link=User:Derek_J_Moore]]
|style = background-color: #EAF3FF; padding: .5em 1em .5em .5em; border: none;
|text = {{clear}}
# Thatha [[Isithombe sehloko |isithombe sehloko]]
# Ngena ngebizo lakho lomsebenzisi nephasiwedi
# Vakatjhela [https://commons.wikimedia.org/wiki/Homepage Commons.Wikipedia]. Layisha isithombe nofana isithombe
}}

== Iye, ngizokwenza ikhasi lomsebenzisi ==
{{Ikhasi elitjha lomsebenzisi}}

&lt;nowiki&gt;*&lt;/nowiki&gt; [[ORCID]]{{Ukulawula igunya | ORCID = 0000-0003-1895-2918 }}


{{imbewu}}

&lt;hr&gt;


{{Userbox|border-c=#bcb234|border-s=1|id-c=#819637|id-p=5px|info-p=0px 8px|info-c=#f4f4f4|info-s=9|info-fc=black|id=[File:Finger:Ing-ing-ing. 52px]]|info=Umsebenzisi lo ukholelwa bona [[User:Derek_J_Moore/Begin|Ukuthembeka kwe-Wikipedia]] kuthembele kuwe.}}


&lt;div id=&quot;previewnote-an&quot;&gt;
{| cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; style=&quot;width:100%; clear:both; background-color:#e2f2d2; border:2px solid #acce79;&quot;
|- align=&quot;kwesokudla&quot;
| rowspan=&quot;3&quot; align=&quot;center&quot; width=&quot;64px&quot; | [[Isithombe:Start hand.svg|30x30px]]
|align=&quot;left&quot; style=&quot;padding-left:30px&quot;|&lt;span style=&quot;color:green; solid green&quot;&gt;[[:ZU:User:Derek_J_Moore|Lo suktiusei uhinwesi ukubeinde kweWikipedia kuncike kuwe.]]
|}
&lt;/div&gt;
{{Isigaba:Ikholi|1}}</text>
      <sha1>4xwmk3sqctaanqvu98bwwax93tboti4</sha1>
    </revision>
    <revision>
      <id>5932</id>
      <parentid>5931</parentid>
      <timestamp>2025-10-23T12:59:06Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>added</comment>
      <origin>5932</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1860" sha1="izwzy8sqs7g6b2y3d6yp8548qfuteqm" xml:space="preserve">{{Tabs
| NOTOC = true
| [[User:Derek_J_Moore|umsebenzisi]]
| [[User:Derek_J_Moore/Begin|dala]]
| [[User:Derek_J_Moore/Middle|ukubuyekeza]]
| [[User:Derek_J_Moore/Sandbox|sandbox]]
| [[Main Page |ikhasi]]
| This = 1
}}
[[File:Greetings in many languages.png|thumb|South African Greetings]]

== Ufuna ukufunda ngekhasi lomsebenzisi ndawonye? ==

Lotjha. Ibizo lami ngingu-Derek Moore. Ngingu-[[Ithekhnoloji yezeFundo]] begodu ngisebenza ne-[[ithekhnoloji yezeFundo]]. Ngibuye ngibe [[Umklami wokufundisa|umklami wokufundisa]]. Senza i-encyclopedia esezingeni lephasi ngesi-Afrikaans, begodu ungasiza!

{{Fmbox
|image=[[File:Camera aabb.svg|20px|link=User:Derek_J_Moore]]
|style = background-color: #EAF3FF; padding: .5em 1em .5em .5em; border: none;
|text = {{clear}}
# Thatha [[Isithombe sehloko |isithombe sehloko]]
# Ngena ngebizo lakho lomsebenzisi nephasiwedi
# Vakatjhela [https://commons.wikimedia.org/wiki/Homepage Commons.Wikipedia]. Layisha isithombe nofana isithombe
}}

== Iye, ngizokwenza ikhasi lomsebenzisi ==
{{Ikhasi elitjha lomsebenzisi}}
&lt;nowiki&gt;*&lt;/nowiki&gt; [[ORCID]]{{Authority control | ORCID = 0000-0003-1895-2918 }}


{{imbewu}}

&lt;hr&gt;


{{Userbox|border-c=#bcb234|border-s=1|id-c=#819637|id-p=5px|info-p=0px 8px|info-c=#f4f4f4|info-s=9|info-fc=black|id=[File:Finger:Ing-ing-ing. 52px]]|info=Umsebenzisi lo ukholelwa bona [[User:Derek_J_Moore/Begin|Ukuthembeka kwe-Wikipedia]] kuthembele kuwe.}}


&lt;div id=&quot;previewnote-an&quot;&gt;
{| cellspacing=&quot;0&quot; cellpadding=&quot;2&quot; style=&quot;width:100%; clear:both; background-color:#e2f2d2; border:2px solid #acce79;&quot;
|- align=&quot;kwesokudla&quot;
| rowspan=&quot;3&quot; align=&quot;center&quot; width=&quot;64px&quot; | [[Isithombe:Start hand.svg|30x30px]]
|align=&quot;left&quot; style=&quot;padding-left:30px&quot;|&lt;span style=&quot;color:green; solid green&quot;&gt;[[:ZU:User:Derek_J_Moore|Lo suktiusei uhinwesi ukubeinde kweWikipedia kuncike kuwe.]]
|}
&lt;/div&gt;
{{Isigaba:Ikholi|1}}</text>
      <sha1>izwzy8sqs7g6b2y3d6yp8548qfuteqm</sha1>
    </revision>
    <revision>
      <id>5933</id>
      <parentid>5932</parentid>
      <timestamp>2025-10-23T13:35:12Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>added</comment>
      <origin>5933</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1165" sha1="3nl0d3cyhpbtncpp770p2scftns2a73" xml:space="preserve">{{Tabs
| NOTOC = true
| [[User:Derek_J_Moore|umsebenzisi]]
| [[User:Derek_J_Moore/Begin|dala]]
| [[User:Derek_J_Moore/Middle|ukubuyekeza]]
| [[User:Derek_J_Moore/Sandbox|sandbox]]
| [[Main Page |ikhasi]]
| This = 1
}}
[[File:Greetings in many languages.png|thumb|South African Greetings]]

== Ufuna ukufunda ngekhasi lomsebenzisi ndawonye? ==

Lotjha. Ibizo lami ngingu-Derek Moore. Ngingu- begodu ngisebenza ne-[[:simple:Educational_technologist|ithekhnoloji yezeFundo]]. Ngibuye ngibe [[:en:Instructional_design|umklami wokufundisa]]. Senza i-encyclopedia esezingeni lephasi ngesi-Afrikaans, begodu ungasiza!

{{Fmbox
|image=[[File:Camera aabb.svg|20px|link=User:Derek_J_Moore]]
|style = background-color: #EAF3FF; padding: .5em 1em .5em .5em; border: none;
|text = {{clear}}
# Thatha [[:simple:Headshot |isithombe sehloko]]
# Ngena ngebizo lakho lomsebenzisi nephasiwedi
# Vakatjhela [https://commons.wikimedia.org/wiki/Homepage Commons.Wikipedia]. Layisha isithombe nofana isithombe
}}

== Iye, ngizokwenza ikhasi lomsebenzisi ==
{{Ikhasi elitjha lomsebenzisi}}
&lt;nowiki&gt;*&lt;/nowiki&gt; [[ORCID]]{{Authority control | ORCID = 0000-0003-1895-2918 }}


{{imbewu}}

&lt;hr&gt;</text>
      <sha1>3nl0d3cyhpbtncpp770p2scftns2a73</sha1>
    </revision>
    <revision>
      <id>5934</id>
      <parentid>5933</parentid>
      <timestamp>2025-10-23T13:35:44Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>/* Iye, ngizokwenza ikhasi lomsebenzisi */</comment>
      <origin>5934</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="996" sha1="hoz9ezu1f0mxmian89lc1kd5u3i827r" xml:space="preserve">{{Tabs
| NOTOC = true
| [[User:Derek_J_Moore|umsebenzisi]]
| [[User:Derek_J_Moore/Begin|dala]]
| [[User:Derek_J_Moore/Middle|ukubuyekeza]]
| [[User:Derek_J_Moore/Sandbox|sandbox]]
| [[Main Page |ikhasi]]
| This = 1
}}
[[File:Greetings in many languages.png|thumb|South African Greetings]]

== Ufuna ukufunda ngekhasi lomsebenzisi ndawonye? ==

Lotjha. Ibizo lami ngingu-Derek Moore. Ngingu- begodu ngisebenza ne-[[:simple:Educational_technologist|ithekhnoloji yezeFundo]]. Ngibuye ngibe [[:en:Instructional_design|umklami wokufundisa]]. Senza i-encyclopedia esezingeni lephasi ngesi-Afrikaans, begodu ungasiza!

{{Fmbox
|image=[[File:Camera aabb.svg|20px|link=User:Derek_J_Moore]]
|style = background-color: #EAF3FF; padding: .5em 1em .5em .5em; border: none;
|text = {{clear}}
# Thatha [[:simple:Headshot |isithombe sehloko]]
# Ngena ngebizo lakho lomsebenzisi nephasiwedi
# Vakatjhela [https://commons.wikimedia.org/wiki/Homepage Commons.Wikipedia]. Layisha isithombe nofana isithombe
}}


&lt;hr&gt;</text>
      <sha1>hoz9ezu1f0mxmian89lc1kd5u3i827r</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Page tabs</title>
    <ns>10</ns>
    <id>547</id>
    <revision>
      <id>2653</id>
      <timestamp>2025-04-07T18:36:03Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>Template:Page tabs/styles.css</comment>
      <origin>2653</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="54" sha1="gywqy631fvfadn84e8og9rj4w5iug9k" xml:space="preserve">&lt;templatestyles src=&quot;Template:Page tabs/styles.css&quot; /&gt;</text>
      <sha1>gywqy631fvfadn84e8og9rj4w5iug9k</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Page tabs/styles.css</title>
    <ns>10</ns>
    <id>548</id>
    <revision>
      <id>2654</id>
      <timestamp>2025-04-07T18:37:06Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>CSS</comment>
      <origin>2654</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="621" sha1="4edst2rgpx0mooekbnykep8cev6rest" xml:space="preserve">/* {{pp-template}} */
.template-page-tabs {
	background: #F8FCFF;
    color:black;
	width: 100%;
	display: flex;
	flex-wrap: wrap;
	margin-bottom: -4px;
}

.template-page-tabs &gt; span {
	padding: 0.5em;
	line-height: 0.95em;
	border: solid 2px #a3b1bf;
	white-space: nowrap;
	margin-bottom: 4px;
}

.template-page-tabs &gt; span.spacer {
	display: flex; /* hides any whitespace we put inside */
	padding: 0;
	flex: 9px;
	border-width: 0 0 2px 0;
}

.template-page-tabs &gt; span.spacer:last-child {
	/* We want this to get first priority, which flexbox doesn't really understand but hopefully this will do. */
	flex: 1000 1 0;
}</text>
      <sha1>4edst2rgpx0mooekbnykep8cev6rest</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Tabs</title>
    <ns>10</ns>
    <id>549</id>
    <revision>
      <id>2655</id>
      <timestamp>2025-04-07T18:43:44Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>tabs</comment>
      <origin>2655</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="161" sha1="lpkjdoubcwsb6rtx4f11r76lb4ux7ml" xml:space="preserve">{{Page tabs
| NOTOC = true
| [[User:Example]]
| [[User:Example/Subpage 1]]
| [[User:Example/Subpage 2|Second subpage]]
| [[User:Example/Subpage 3]]
| This = 2
}}</text>
      <sha1>lpkjdoubcwsb6rtx4f11r76lb4ux7ml</sha1>
    </revision>
    <revision>
      <id>5923</id>
      <parentid>2655</parentid>
      <timestamp>2025-10-23T12:28:11Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>Documentation is there</comment>
      <origin>5923</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="187" sha1="8v5qhy29opj6soqlqqidalrxdu0j2x8" xml:space="preserve">&lt;templatestyles src=&quot;Template:tabs/styles.css&quot; /&gt;{{#invoke:tabs|main}}&lt;noinclude&gt;
{{documentation}}
&lt;!-- Categories go on the /doc subpage, and interwikis go on Wikidata. --&gt;
&lt;/noinclude&gt;</text>
      <sha1>8v5qhy29opj6soqlqqidalrxdu0j2x8</sha1>
    </revision>
  </page>
  <page>
    <title>Ibisi</title>
    <ns>0</ns>
    <id>551</id>
    <revision>
      <id>2658</id>
      <timestamp>2025-04-15T15:40:22Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Ibisi == Ibisi kuyinto kumamanzi amhlophe aphuma ekomeni esikazi lokha nayiceda ukuba nekonyana&lt;ref&gt;MILK | English meaning - Cambridge Dictionary&lt;/ref&gt;. Ibisi leli kukukudla kwekonyana bekufike lapho ikonyana leli lithoma khona Ukudla utjani ngokupheleleko.Abantu bathatha iinkomo lezi bazisenge bese bakhiphe ibisi ngombana linepilo.   === Ukuqakatheka kwebisi === Ibisi liqakatheke khulu ngombana alisikukudla kwekonyana kwaphela kodwana likukudla nebantwini abaphilako....&quot;</comment>
      <origin>2658</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1903" sha1="7k8d6x8354kk4yjzznxaeqfzo9gdbvg" xml:space="preserve">== Ibisi ==
Ibisi kuyinto kumamanzi amhlophe aphuma ekomeni esikazi lokha nayiceda ukuba nekonyana&lt;ref&gt;MILK | English meaning - Cambridge Dictionary&lt;/ref&gt;. Ibisi leli kukukudla kwekonyana bekufike lapho ikonyana leli lithoma khona Ukudla utjani ngokupheleleko.Abantu bathatha iinkomo lezi bazisenge bese bakhiphe ibisi ngombana linepilo. 

=== Ukuqakatheka kwebisi ===
Ibisi liqakatheke khulu ngombana alisikukudla kwekonyana kwaphela kodwana likukudla nebantwini abaphilako. Liqinisa [[amathambo]] ngombana linama phrotheyini&lt;ref&gt;Fox, P.F., Uniacke-Lowe, T., McSweeney, P.L.H., O'Mahony, J.A., Fox, P.F., Uniacke-Lowe, T., McSweeney, P.L.H. and O’Mahony, J.A., 2015. Milk proteins. ''Dairy chemistry and biochemistry'', pp.145-239.&lt;/ref&gt;. Lenza bona umuntu angaphuki lula amathambo nofana angatholi amagulo aphathelene namathambo afana ne osteoporosis. Ibisi liyasetjenziswa nokubhaga nokwenza okunye Ukudla okufana netjhizi, iyogadi, amasi, nokhunye.  

== Ubungozi bebisi ==
Abanye abantu abanonalo i-enzamu eliphula iswigiri yemvelo engaphakathi kwebisi abizwa bona yi lactose ngelimi lesiNgisi&lt;ref&gt;Rangel, A.H.D.N., Sales, D.C., Urbano, S.A., GALVÃO, J.G.B., ANDRADE, J.C.D. and Macêdo, C.D.S., 2016. Lactose intolerance and cow's milk protein allergy. ''Food Science and Technology (Campinas)'', ''36''(2), pp.179-187.&lt;/ref&gt;&lt;ref&gt;Heine, R.G., AlRefaee, F., Bachina, P., De Leon, J.C., Geng, L., Gong, S., Madrazo, J.A., Ngamphaiboon, J., Ong, C. and Rogacion, J.M., 2017. Lactose intolerance and gastrointestinal cow’s milk allergy in infants and children–common misconceptions revisited. ''World Allergy Organization Journal'', ''10'', pp.1-8.&lt;/ref&gt;.Umuntu ukuze akghone ukubona ukuthi unomraro lo uzibona ngokuthi azale umoya ngemathumbini,begodu azithole athulula.  Ibisi alidliwa babantu boke ngombana line lactose, begodu abanye abantu bane allergy ye lactogen le engaphakathi kwebisi.</text>
      <sha1>7k8d6x8354kk4yjzznxaeqfzo9gdbvg</sha1>
    </revision>
    <revision>
      <id>5700</id>
      <parentid>2658</parentid>
      <timestamp>2025-09-06T14:38:00Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5700</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1935" sha1="gn62th97ry9lm8dud0pb8o86u3zz84k" xml:space="preserve">'''Ibisi''' kuyinto kumamanzi amhlophe aphuma ekomeni esikazi lokha nayiceda ukuba nekonyana&lt;ref&gt;MILK | English meaning - Cambridge Dictionary&lt;/ref&gt;. Ibisi leli kukukudla kwekonyana bekufike lapho ikonyana leli lithoma khona Ukudla utjani ngokupheleleko.Abantu bathatha iinkomo lezi bazisenge bese bakhiphe ibisi ngombana linepilo. Ibisi liqakatheke  ngombana alisikukudla kwekonyana kwaphela kodwana likukudla nebantwini abaphilako. Liqinisa [[amathambo]] ngombana linama phrotheyini&lt;ref&gt;Fox, P.F., Uniacke-Lowe, T., McSweeney, P.L.H., O'Mahony, J.A., Fox, P.F., Uniacke-Lowe, T., McSweeney, P.L.H. and O’Mahony, J.A., 2015. Milk proteins. ''Dairy chemistry and biochemistry'', pp.145-239.&lt;/ref&gt;. Lenza bona umuntu angaphuki lula amathambo nofana angatholi amagulo aphathelene namathambo afana ne osteoporosis. Ibisi liyasetjenziswa nokubhaga nokwenza okunye Ukudla okufana netjhizi, iyogadi, amasi, nokhunye. 

=== Ubungozi bebisi ===
[[Isimumathi:Milk 001.JPG|thumb|Irhalasi elizele ibisi]]
Abanye abantu abanonalo i-enzamu eliphula iswigiri yemvelo engaphakathi kwebisi abizwa bona yi lactose ngelimi lesiNgisi&lt;ref&gt;Rangel, A.H.D.N., Sales, D.C., Urbano, S.A., GALVÃO, J.G.B., ANDRADE, J.C.D. and Macêdo, C.D.S., 2016. Lactose intolerance and cow's milk protein allergy. ''Food Science and Technology (Campinas)'', ''36''(2), pp.179-187.&lt;/ref&gt;&lt;ref&gt;Heine, R.G., AlRefaee, F., Bachina, P., De Leon, J.C., Geng, L., Gong, S., Madrazo, J.A., Ngamphaiboon, J., Ong, C. and Rogacion, J.M., 2017. Lactose intolerance and gastrointestinal cow’s milk allergy in infants and children–common misconceptions revisited. ''World Allergy Organization Journal'', ''10'', pp.1-8.&lt;/ref&gt;.Umuntu ukuze akghone ukubona ukuthi unomraro lo uzibona ngokuthi azale umoya ngemathumbini,begodu azithole athulula.  Ibisi alidliwa babantu boke ngombana line lactose, begodu abanye abantu bane allergy ye lactogen le engaphakathi kwebisi.

== Iinkomba ==</text>
      <sha1>gn62th97ry9lm8dud0pb8o86u3zz84k</sha1>
    </revision>
    <revision>
      <id>5701</id>
      <parentid>5700</parentid>
      <timestamp>2025-09-06T14:39:53Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>5701</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1990" sha1="rhwoyxbz8xbwkcom7yng5a9wxe3avvb" xml:space="preserve">'''Ibisi''' kuyinto kumamanzi amhlophe aphuma ekomeni esikazi lokha nayiceda ukuba nekonyana&lt;ref&gt;MILK | English meaning - Cambridge Dictionary&lt;/ref&gt;. Ibisi leli kukukudla kwekonyana bekufike lapho ikonyana leli lithoma khona Ukudla utjani ngokupheleleko.Abantu bathatha iinkomo lezi bazisenge bese bakhiphe ibisi ngombana linepilo. Ibisi liqakatheke  ngombana alisikukudla kwekonyana kwaphela kodwana likukudla nebantwini abaphilako. Liqinisa [[amathambo]] ngombana linama phrotheyini&lt;ref&gt;Fox, P.F., Uniacke-Lowe, T., McSweeney, P.L.H., O'Mahony, J.A., Fox, P.F., Uniacke-Lowe, T., McSweeney, P.L.H. and O’Mahony, J.A., 2015. Milk proteins. ''Dairy chemistry and biochemistry'', pp.145-239.&lt;/ref&gt;. Lenza bona umuntu angaphuki lula amathambo nofana angatholi amagulo aphathelene namathambo afana ne osteoporosis. Ibisi liyasetjenziswa nokubhaga nokwenza okunye Ukudla okufana netjhizi, iyogadi, amasi, nokhunye. 

=== Ubungozi bebisi ===
[[Isimumathi:Milk 001.JPG|thumb|Irhalasi elizele ibisi]]
Abanye abantu abanonalo i-enzamu eliphula iswigiri yemvelo engaphakathi kwebisi abizwa bona yi lactose ngelimi lesiNgisi&lt;ref&gt;Rangel, A.H.D.N., Sales, D.C., Urbano, S.A., GALVÃO, J.G.B., ANDRADE, J.C.D. and Macêdo, C.D.S., 2016. Lactose intolerance and cow's milk protein allergy. ''Food Science and Technology (Campinas)'', ''36''(2), pp.179-187.&lt;/ref&gt;&lt;ref&gt;Heine, R.G., AlRefaee, F., Bachina, P., De Leon, J.C., Geng, L., Gong, S., Madrazo, J.A., Ngamphaiboon, J., Ong, C. and Rogacion, J.M., 2017. Lactose intolerance and gastrointestinal cow’s milk allergy in infants and children–common misconceptions revisited. ''World Allergy Organization Journal'', ''10'', pp.1-8.&lt;/ref&gt;.Umuntu ukuze akghone ukubona ukuthi unomraro lo uzibona ngokuthi azale umoya ngemathumbini,begodu azithole athulula.  Ibisi alidliwa babantu boke ngombana line lactose, begodu abanye abantu bane allergy ye lactogen le engaphakathi kwebisi.

== Iinkomba ==
[category:ibisi]
[Category:Ikomo]
[Category:Amathambo]</text>
      <sha1>rhwoyxbz8xbwkcom7yng5a9wxe3avvb</sha1>
    </revision>
    <revision>
      <id>5702</id>
      <parentid>5701</parentid>
      <timestamp>2025-09-06T14:41:44Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>5702</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1996" sha1="2af1d1l9q7pg4t01ko5azhcxgep5x7n" xml:space="preserve">'''Ibisi''' kuyinto kumamanzi amhlophe aphuma ekomeni esikazi lokha nayiceda ukuba nekonyana&lt;ref&gt;MILK | English meaning - Cambridge Dictionary&lt;/ref&gt;. Ibisi leli kukukudla kwekonyana bekufike lapho ikonyana leli lithoma khona Ukudla utjani ngokupheleleko.Abantu bathatha iinkomo lezi bazisenge bese bakhiphe ibisi ngombana linepilo. Ibisi liqakatheke  ngombana alisikukudla kwekonyana kwaphela kodwana likukudla nebantwini abaphilako. Liqinisa [[amathambo]] ngombana linama phrotheyini&lt;ref&gt;Fox, P.F., Uniacke-Lowe, T., McSweeney, P.L.H., O'Mahony, J.A., Fox, P.F., Uniacke-Lowe, T., McSweeney, P.L.H. and O’Mahony, J.A., 2015. Milk proteins. ''Dairy chemistry and biochemistry'', pp.145-239.&lt;/ref&gt;. Lenza bona umuntu angaphuki lula amathambo nofana angatholi amagulo aphathelene namathambo afana ne osteoporosis. Ibisi liyasetjenziswa nokubhaga nokwenza okunye Ukudla okufana netjhizi, iyogadi, amasi, nokhunye. 

=== Ubungozi bebisi ===
[[Isimumathi:Milk 001.JPG|thumb|Irhalasi elizele ibisi]]
Abanye abantu abanonalo i-enzamu eliphula iswigiri yemvelo engaphakathi kwebisi abizwa bona yi lactose ngelimi lesiNgisi&lt;ref&gt;Rangel, A.H.D.N., Sales, D.C., Urbano, S.A., GALVÃO, J.G.B., ANDRADE, J.C.D. and Macêdo, C.D.S., 2016. Lactose intolerance and cow's milk protein allergy. ''Food Science and Technology (Campinas)'', ''36''(2), pp.179-187.&lt;/ref&gt;&lt;ref&gt;Heine, R.G., AlRefaee, F., Bachina, P., De Leon, J.C., Geng, L., Gong, S., Madrazo, J.A., Ngamphaiboon, J., Ong, C. and Rogacion, J.M., 2017. Lactose intolerance and gastrointestinal cow’s milk allergy in infants and children–common misconceptions revisited. ''World Allergy Organization Journal'', ''10'', pp.1-8.&lt;/ref&gt;.Umuntu ukuze akghone ukubona ukuthi unomraro lo uzibona ngokuthi azale umoya ngemathumbini,begodu azithole athulula.  Ibisi alidliwa babantu boke ngombana line lactose, begodu abanye abantu bane allergy ye lactogen le engaphakathi kwebisi.

== Iinkomba ==
[[category:ibisi]]
[[Category:Ikomo]]
[[Category:Amathambo]]</text>
      <sha1>2af1d1l9q7pg4t01ko5azhcxgep5x7n</sha1>
    </revision>
    <revision>
      <id>5703</id>
      <parentid>5702</parentid>
      <timestamp>2025-09-06T14:44:00Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5703</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2000" sha1="1051eafu5ekpz1w11p6uu6b9pycz3m9" xml:space="preserve">'''Ibisi''' kuyinto kumamanzi amhlophe aphuma ekomeni esikazi lokha nayiceda ukuba nekonyana&lt;ref&gt;MILK | English meaning - Cambridge Dictionary&lt;/ref&gt;. Ibisi leli kukukudla kwekonyana bekufike lapho ikonyana leli lithoma khona Ukudla utjani ngokupheleleko.Abantu bathatha iinkomo lezi bazisenge bese bakhiphe ibisi ngombana linepilo. Ibisi liqakatheke  ngombana alisikukudla kwekonyana kwaphela kodwana likukudla nebantwini abaphilako. Liqinisa [[amathambo]] ngombana linama phrotheyini&lt;ref&gt;Fox, P.F., Uniacke-Lowe, T., McSweeney, P.L.H., O'Mahony, J.A., Fox, P.F., Uniacke-Lowe, T., McSweeney, P.L.H. and O’Mahony, J.A., 2015. Milk proteins. ''Dairy chemistry and biochemistry'', pp.145-239.&lt;/ref&gt;. Lenza bona umuntu angaphuki lula amathambo nofana angatholi amagulo aphathelene namathambo afana ne-''osteoporosis''. Ibisi liyasetjenziswa nokubhaga nokwenza okunye Ukudla okufana netjhizi, iyogadi, amasi, nokhunye. 

=== Ubungozi bebisi ===
[[Isimumathi:Milk 001.JPG|thumb|Irhalasi elizele ibisi]]
Abanye abantu abanonalo i-enzamu eliphula iswigiri yemvelo engaphakathi kwebisi abizwa bona yi lactose ngelimi lesiNgisi&lt;ref&gt;Rangel, A.H.D.N., Sales, D.C., Urbano, S.A., GALVÃO, J.G.B., ANDRADE, J.C.D. and Macêdo, C.D.S., 2016. Lactose intolerance and cow's milk protein allergy. ''Food Science and Technology (Campinas)'', ''36''(2), pp.179-187.&lt;/ref&gt;&lt;ref&gt;Heine, R.G., AlRefaee, F., Bachina, P., De Leon, J.C., Geng, L., Gong, S., Madrazo, J.A., Ngamphaiboon, J., Ong, C. and Rogacion, J.M., 2017. Lactose intolerance and gastrointestinal cow’s milk allergy in infants and children–common misconceptions revisited. ''World Allergy Organization Journal'', ''10'', pp.1-8.&lt;/ref&gt;.Umuntu ukuze akghone ukubona ukuthi unomraro lo uzibona ngokuthi azale umoya ngemathumbini,begodu azithole athulula.  Ibisi alidliwa babantu boke ngombana line lactose, begodu abanye abantu bane allergy ye lactogen le engaphakathi kwebisi.

== Iinkomba ==
[[category:ibisi]]
[[Category:Ikomo]]
[[Category:Amathambo]]</text>
      <sha1>1051eafu5ekpz1w11p6uu6b9pycz3m9</sha1>
    </revision>
  </page>
  <page>
    <title>Iincwadi</title>
    <ns>0</ns>
    <id>552</id>
    <revision>
      <id>2659</id>
      <timestamp>2025-04-15T15:49:50Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Incwadi == '''Incwadi''' kulibuthelelo lamaphepha ahlanganisweko&lt;ref&gt;BOOK | English meaning - Cambridge Dictionary&lt;/ref&gt;. Incwadi nakungasiyo yokutlolela kodwana kungeyokufunda iba nomtloli nofana abatloli. Incwadi ngezinye zeensetjenziswa ezenza bona ifundo iragele phambili begodu abantu bakghone ukwabelana ngelwazi.  == Imihlobo yeencwadi ==  === Incwadi yokubukela === Incwadi yokubukela kuyincwadi esikhathini esinengi esetjenziselwa [[ukukhangi]]&lt;nowiki/&gt;sa ngomban...&quot;</comment>
      <origin>2659</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1676" sha1="spc176fqhj88i5dgyh32djm96yva807" xml:space="preserve">== Incwadi ==
'''Incwadi''' kulibuthelelo lamaphepha ahlanganisweko&lt;ref&gt;BOOK | English meaning - Cambridge Dictionary&lt;/ref&gt;. Incwadi nakungasiyo yokutlolela kodwana kungeyokufunda iba nomtloli nofana abatloli. Incwadi ngezinye zeensetjenziswa ezenza bona ifundo iragele phambili begodu abantu bakghone ukwabelana ngelwazi.

== Imihlobo yeencwadi ==

=== Incwadi yokubukela ===
Incwadi yokubukela kuyincwadi esikhathini esinengi esetjenziselwa [[ukukhangi]]&lt;nowiki/&gt;sa ngombana kiyo abantu bakghona ukuthi babukele izinto ebangazithanda bese bathi  nabazithandileko bakhambe bayozithenga. Isibonelo kungaba mamegazini wefetjheni&lt;ref&gt;Caniato, M., 2015. Fashion magazines in the digital era. ''J fashion mark and Manag inte J''.&lt;/ref&gt;.

=== Incwadi yokufunda ===
Incwadi lezi ngilezo ezitlolwe indaba ezithileko abantu abangathanda ukuzifunda. Isibonelo seencwadi lezi kungaba yibhayibhili, amanoveli ndaba nokhunye. Abantu abafunda iincwadi lezi baba nelwazi lwamagama elenza bona babe nelwazi lelimi abafunda ngalo&lt;ref&gt;Porter, N., 2023. ''Books and reading''. BoD–Books on Demand.&lt;/ref&gt;.

=== Incwadi yokutlolela ===
Kuzincwadi lezi ezinaphepha amhlophe ngaphakathi, begodu sidetjelwa imida ukuthi umuntu akghone ukutlola kuhle. Zisetjenziswa khulu eenkolweni ngombana abafundi batlolela kizo umsebenzi wesikolo. 

=== Incwadi yeenthaga ===
Lezi zisetjenziswa khulu babantu abathanda ukupheka nofana abafundele ukupheka. Incwadi lezi ziphatha nofana zitlowe iintaga zokupheka nokubhaga&lt;ref&gt;Lehmann, G., 2018. Reading recipe books and culinary history: opening a new field. In ''Reading and writing recipe books, 1550–1800'' (pp. 93-113). Manchester University Press.&lt;/ref&gt;.</text>
      <sha1>spc176fqhj88i5dgyh32djm96yva807</sha1>
    </revision>
    <revision>
      <id>5123</id>
      <parentid>2659</parentid>
      <timestamp>2025-08-10T15:21:53Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5123</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1751" sha1="1zwjjuef25gghxgc4gglvzfn1gpxash" xml:space="preserve">'''Incwadi''' kulibuthelelo lamaphepha ahlanganisweko&lt;ref&gt;BOOK | English meaning - Cambridge Dictionary&lt;/ref&gt;. Ingasetjenziselwa ukuutlolela nofana Ukufunda, begodu lokha nayenzelwe ukufunda iba nomtloli nofana abatloli. Kuyinto etholakala ebulungweni leencwadi.Ingezinye zeensetjenziswa ezenza bona [[ifundo]] iragele phambili begodu abantu bakghone ukwabelana ngelwazi.

=== Imihlobo yeencwadi ===

==== Incwadi yokubukela ====
Incwadi yokubukela kuyincwadi esikhathini esinengi esetjenziselwa [[ukukhangi]]&lt;nowiki/&gt;sa ngombana kiyo abantu bakghona ukuthi babukele izinto ebangazithanda bese bathi  nabazithandileko bakhambe bayozithenga. Isibonelo kungaba mamegazini wefetjheni&lt;ref&gt;Caniato, M., 2015. Fashion magazines in the digital era. ''J fashion mark and Manag inte J''.&lt;/ref&gt;.

==== Incwadi yokufunda ====
Incwadi lezi ngilezo ezitlolwe indaba ezithileko abantu abangathanda ukuzifunda. Isibonelo seencwadi lezi kungaba yibhayibhili, amanoveli ndaba nokhunye. Abantu abafunda iincwadi lezi baba nelwazi lwamagama elenza bona babe nelwazi lelimi abafunda ngalo&lt;ref&gt;Porter, N., 2023. ''Books and reading''. BoD–Books on Demand.&lt;/ref&gt;.

==== Incwadi yokutlolela ====
Kuzincwadi lezi ezinaphepha amhlophe ngaphakathi, begodu sidetjelwa imida ukuthi umuntu akghone ukutlola kuhle. Zisetjenziswa khulu eenkolweni ngombana abafundi batlolela kizo umsebenzi wesikolo. 

==== Incwadi yeenthaga ====
Lezi zisetjenziswa khulu babantu abathanda ukupheka nofana abafundele ukupheka. Incwadi lezi ziphatha nofana zitlowe iintaga zokupheka nokubhaga&lt;ref&gt;Lehmann, G., 2018. Reading recipe books and culinary history: opening a new field. In ''Reading and writing recipe books, 1550–1800'' (pp. 93-113). Manchester University Press.&lt;/ref&gt;.

== Iinkomba ==</text>
      <sha1>1zwjjuef25gghxgc4gglvzfn1gpxash</sha1>
    </revision>
    <revision>
      <id>5124</id>
      <parentid>5123</parentid>
      <timestamp>2025-08-10T15:23:53Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5124</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1844" sha1="ep8wfu671sb6h356na0agau6z9bcjyd" xml:space="preserve">'''Incwadi''' kulibuthelelo lamaphepha ahlanganisweko&lt;ref&gt;BOOK | English meaning - Cambridge Dictionary&lt;/ref&gt;. Ingasetjenziselwa ukuutlolela nofana Ukufunda, begodu lokha nayenzelwe ukufunda iba nomtloli nofana abatloli. Kuyinto etholakala ebulungweni leencwadi.Ingezinye zeensetjenziswa ezenza bona [[ifundo]] iragele phambili begodu abantu bakghone ukwabelana ngelwazi.

=== Imihlobo yeencwadi ===

==== Incwadi yokubukela ====
[[Isimumathi:Latin dictionary.jpg|thumb|Isihlathululi magama, ekungomunye umhlobo wencwadi]]
Incwadi yokubukela kuyincwadi esikhathini esinengi esetjenziselwa [[ukukhangi]]&lt;nowiki/&gt;sa ngombana kiyo abantu bakghona ukuthi babukele izinto ebangazithanda bese bathi  nabazithandileko bakhambe bayozithenga. Isibonelo kungaba mamegazini wefetjheni&lt;ref&gt;Caniato, M., 2015. Fashion magazines in the digital era. ''J fashion mark and Manag inte J''.&lt;/ref&gt;.

==== Incwadi yokufunda ====
Incwadi lezi ngilezo ezitlolwe indaba ezithileko abantu abangathanda ukuzifunda. Isibonelo seencwadi lezi kungaba yibhayibhili, amanoveli ndaba nokhunye. Abantu abafunda iincwadi lezi baba nelwazi lwamagama elenza bona babe nelwazi lelimi abafunda ngalo&lt;ref&gt;Porter, N., 2023. ''Books and reading''. BoD–Books on Demand.&lt;/ref&gt;.

==== Incwadi yokutlolela ====
Kuzincwadi lezi ezinaphepha amhlophe ngaphakathi, begodu sidetjelwa imida ukuthi umuntu akghone ukutlola kuhle. Zisetjenziswa khulu eenkolweni ngombana abafundi batlolela kizo umsebenzi wesikolo. 

==== Incwadi yeenthaga ====
Lezi zisetjenziswa khulu babantu abathanda ukupheka nofana abafundele ukupheka. Incwadi lezi ziphatha nofana zitlowe iintaga zokupheka nokubhaga&lt;ref&gt;Lehmann, G., 2018. Reading recipe books and culinary history: opening a new field. In ''Reading and writing recipe books, 1550–1800'' (pp. 93-113). Manchester University Press.&lt;/ref&gt;.

== Iinkomba ==</text>
      <sha1>ep8wfu671sb6h356na0agau6z9bcjyd</sha1>
    </revision>
    <revision>
      <id>5125</id>
      <parentid>5124</parentid>
      <timestamp>2025-08-10T15:25:02Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>5125</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1922" sha1="c437u8orvu3az88xupywuf350hodpki" xml:space="preserve">'''Incwadi''' kulibuthelelo lamaphepha ahlanganisweko&lt;ref&gt;BOOK | English meaning - Cambridge Dictionary&lt;/ref&gt;. Ingasetjenziselwa ukuutlolela nofana Ukufunda, begodu lokha nayenzelwe ukufunda iba nomtloli nofana abatloli. Kuyinto etholakala ebulungweni leencwadi.Ingezinye zeensetjenziswa ezenza bona [[ifundo]] iragele phambili begodu abantu bakghone ukwabelana ngelwazi.

=== Imihlobo yeencwadi ===

==== Incwadi yokubukela ====
[[Isimumathi:Latin dictionary.jpg|thumb|Isihlathululi magama, ekungomunye umhlobo wencwadi]]
Incwadi yokubukela kuyincwadi esikhathini esinengi esetjenziselwa [[ukukhangi]]&lt;nowiki/&gt;sa ngombana kiyo abantu bakghona ukuthi babukele izinto ebangazithanda bese bathi  nabazithandileko bakhambe bayozithenga. Isibonelo kungaba mamegazini wefetjheni&lt;ref&gt;Caniato, M., 2015. Fashion magazines in the digital era. ''J fashion mark and Manag inte J''.&lt;/ref&gt;.

==== Incwadi yokufunda ====
Incwadi lezi ngilezo ezitlolwe indaba ezithileko abantu abangathanda ukuzifunda. Isibonelo seencwadi lezi kungaba yibhayibhili, amanoveli ndaba nokhunye. Abantu abafunda iincwadi lezi baba nelwazi lwamagama elenza bona babe nelwazi lelimi abafunda ngalo&lt;ref&gt;Porter, N., 2023. ''Books and reading''. BoD–Books on Demand.&lt;/ref&gt;.

==== Incwadi yokutlolela ====
Kuzincwadi lezi ezinaphepha amhlophe ngaphakathi, begodu sidetjelwa imida ukuthi umuntu akghone ukutlola kuhle. Zisetjenziswa khulu eenkolweni ngombana abafundi batlolela kizo umsebenzi wesikolo. 

==== Incwadi yeenthaga ====
Lezi zisetjenziswa khulu babantu abathanda ukupheka nofana abafundele ukupheka. Incwadi lezi ziphatha nofana zitlowe iintaga zokupheka nokubhaga&lt;ref&gt;Lehmann, G., 2018. Reading recipe books and culinary history: opening a new field. In ''Reading and writing recipe books, 1550–1800'' (pp. 93-113). Manchester University Press.&lt;/ref&gt;.

== Iinkomba ==
[[Category:Iincwadi]]
[[Category:Ibulungelo leencwadi]]
[[Category:UKufunda]]</text>
      <sha1>c437u8orvu3az88xupywuf350hodpki</sha1>
    </revision>
  </page>
  <page>
    <title>Abotitjhere</title>
    <ns>0</ns>
    <id>553</id>
    <revision>
      <id>2660</id>
      <timestamp>2025-04-15T16:01:15Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Abotitjhere == '''Abotitjhere''' bafundisi  babentwana kuze bangatholakali izintweni namkha ezindleleni eziphuma endleleni.[[Isikolo]] ngeze saba khona ngaphandle kotitjhere Barhelebha abentwana bona babenelwazi mayelana nefundo, bafundisa bona umntwana abenokuzithemba azazi bona yini akghona kuyenza nento angakghoni ukuyenza&lt;ref&gt;TEACHER | English meaning - Cambridge Dictionary&lt;/ref&gt;. Abotitjhere abafundisa amabanga aphasi,bafundisa  abentwana bona bakghone ukutlola ,...&quot;</comment>
      <origin>2660</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3894" sha1="lq02gxcocaiqor8oc8sw3890clrjf7d" xml:space="preserve">== Abotitjhere ==
'''Abotitjhere''' bafundisi  babentwana kuze bangatholakali izintweni namkha ezindleleni eziphuma endleleni.[[Isikolo]] ngeze saba khona ngaphandle kotitjhere Barhelebha abentwana bona babenelwazi mayelana nefundo, bafundisa bona umntwana abenokuzithemba azazi bona yini akghona kuyenza nento angakghoni ukuyenza&lt;ref&gt;TEACHER | English meaning - Cambridge Dictionary&lt;/ref&gt;. Abotitjhere abafundisa amabanga aphasi,bafundisa  abentwana bona bakghone ukutlola ,nokufunda nokhunye. Barhelebha umntwana bona akghone ukufunda incwadi nokutlola imitjho emide , begodu bakghone ukutlola kuhle imisebenzi yabo.

== Ukuqakatheka kukatitjhere ==
Abotitjhere baqakathekile ngombana basisekelo sefundo. Lokha abotitjhere nabangekho ifundo ngekhe yabalula. Abotitjhere bafundisa aabantwana bona bakghona ukufunda nokutlolwa. Banikelwa abantwana ilwazi elizeleko ngepilo babasize bonyana bakghone ukufezikisa amabhudango wabo ngokuthi babe ngilokho abafuna ukuba ngikho nabakhulako.
Woke amabizelo abawalandeko abantu abelethwa botitjhere ngombana bengekhe kube lula ukuthi bawalandele kube azange abotitjhere babekhona ukubafundisa babe nelwazi lokuthi kufuze benzene ukuthi balandele amabizelo lawo&lt;ref&gt;Gore, V. and Begum, S., 2012. Role of a Teacher in 21st Century. ''The Criterion: An International Journal in English'', ''3''(3), pp.2-7.&lt;/ref&gt;.

== Umsebenzi katitjhere ==

=== Ukulawula itlasi ===
Utitjhere usebenza ukuthi alawule itlasi lakhe liba njani. Lokhu angakwenza ngokuthi enze immithetho yangetlasini abafundi abazoyilandela. Okhunye godu uhle indlela itlasi lakhe lizokuqaleka ngakhona isibonelo iindlela abantwana abazokuhlala ngayo nokuthi yena uzokuhlala kuphi&lt;ref&gt;Ibrahim, M.H.A.R., 2016. Classroom management: The effectiveness of teacher’s roles. ''Education and Linguistics Research'', ''2''(1), pp.69-84.&lt;/ref&gt;. Nokuthi uzokusebenzisa yiphi ikambiso ukuthi abafundi bafunde kamnandi bathabele ukufunda.

=== Ukufundisa ===
Ukufundisa msebenzi ovamilleko katitijhere ngombana ngombana woke umuntu uyazi ukuthi abotitjhere basebenza ukufundisa. Ukutjho bona banikela abafundi babo ilwazi leli egade banganalo nofana bathuthukise lelilwazi abafundi asele baliphethe

=== Ukwenza insiza zokufundisa ===
Lokha utitjhere nakafundisako akamane akhulume kwaphela kodwana kube neensiza zokufundisa ezifana namatjhadi, iinthombe nokhunye ekuzokwenza bona abafundi bakghone ukuzwisisa isifundo lula ngaphandle kokuthi bararane ihloko.

=== Ukwenza iinhlahlubo ===
Umsebenzi katitjhere kukuthi athathe koke lokhu akufundise abafundi bakhe bese ahlele isihlahlubo sakhe sethemu nofana sonyaka ahlolel bonyana lokhu abekakufundisa abafundi bakhe sele bakuzwisisile nofana awa&lt;ref&gt;Doyle, A., Johnson, M.C., Donlon, E., McDonald, E. and Sexton, P.J., 2021. The role of the teacher as assessor: Developing student teacher's assessment identity. ''Australian Journal of Teacher Education (Online)'', ''46''(12), pp.52-68.&lt;/ref&gt;. Uhlola bonyana khuyini leyo ebatlhaga ukuyimba nokuzwisisa nokuthi yini esele bayazi khulu kilezi zinto abazifundileko

== Iintjhijilo zokuba ngutitjhere ==
Abotitjhere lokha nabasebenzako baqaalana neetjhijilo ezinengi ezahlukahlukeno.Uthole abotitjhere badelelwa bafundi ngesibanga sokuthi abafundi abasabethwa eenkolweni bese bagcine sele babona abotitjhere njebantu abadelelekileko&lt;ref&gt;Flores, M.A., 2017. The complexities and challenges of be (com) ing a teacher and a teacher educator. ''European journal of teacher education'', ''40''(1), pp.2-5.&lt;/ref&gt;. Obunye ubudisi kukuthi abantu babona ngathi umsebenzi wabo titjhere bamabanga aphasi ngathi ulula khulu begodu babona kanti ngibo ebenza umsebenzi omkhulu. 

Abantu bacabanga bona utitjhere usebenza ukufundisa kwaphela abazi ukuthi minengi imisebenzi ebayenzako lokha nabange tlasini efana nokuthi baqinisekile ukuthi amafayili wabo ahleleke kuhle begodu kufanele benze neensiza zokufundisa.</text>
      <sha1>lq02gxcocaiqor8oc8sw3890clrjf7d</sha1>
    </revision>
    <revision>
      <id>2674</id>
      <parentid>2660</parentid>
      <timestamp>2025-04-22T17:50:24Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2674</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3898" sha1="kud414az94tvmnmtuchjtwbdfg5zyeg" xml:space="preserve">== Abotitjhere ==
'''Abotitjhere''' bafundisi  babentwana kuze bangatholakali izintweni namkha ezindleleni eziphuma endleleni.[[Isikolo]] ngeze saba khona ngaphandle kotitjhere Barhelebha abentwana bona babenelwazi mayelana nefundo, bafundisa bona umntwana abenokuzithemba azazi bona yini akghona kuyenza nento angakghoni ukuyenza&lt;ref&gt;TEACHER | English meaning - Cambridge Dictionary&lt;/ref&gt;. Abotitjhere abafundisa amabanga aphasi,bafundisa  abentwana bona bakghone ukutlola ,nokufunda nokhunye. Barhelebha umntwana bona akghone ukufunda incwadi nokutlola imitjho emide , begodu bakghone ukutlola kuhle imisebenzi yabo.

== Ukuqakatheka kukatitjhere ==
Abotitjhere baqakathekile ngombana basisekelo sefundo. Lokha abotitjhere nabangekho ifundo ngekhe yabalula. Abotitjhere bafundisa aabantwana bona bakghona ukufunda nokutlolwa. Banikelwa abantwana ilwazi elizeleko ngepilo babasize bonyana bakghone ukufezikisa amabhudango wabo ngokuthi babe ngilokho abafuna ukuba ngikho nabakhulako.
Woke amabizelo abawalandeko abantu abelethwa botitjhere ngombana bengekhe kube lula ukuthi bawalandele kube azange abotitjhere babekhona ukubafundisa babe nelwazi lokuthi kufuze benzene ukuthi balandele amabizelo lawo&lt;ref&gt;Gore, V. and Begum, S., 2012. Role of a Teacher in 21st Century. ''The Criterion: An International Journal in English'', ''3''(3), pp.2-7.&lt;/ref&gt;.

== Umsebenzi katitjhere ==

=== Ukulawula itlasi ===
Utitjhere usebenza ukuthi alawule [[itlasi]] lakhe liba njani. Lokhu angakwenza ngokuthi enze immithetho yangetlasini abafundi abazoyilandela. Okhunye godu uhle indlela itlasi lakhe lizokuqaleka ngakhona isibonelo iindlela abantwana abazokuhlala ngayo nokuthi yena uzokuhlala kuphi&lt;ref&gt;Ibrahim, M.H.A.R., 2016. Classroom management: The effectiveness of teacher’s roles. ''Education and Linguistics Research'', ''2''(1), pp.69-84.&lt;/ref&gt;. Nokuthi uzokusebenzisa yiphi ikambiso ukuthi abafundi bafunde kamnandi bathabele ukufunda.

=== Ukufundisa ===
Ukufundisa msebenzi ovamilleko katitijhere ngombana ngombana woke umuntu uyazi ukuthi abotitjhere basebenza ukufundisa. Ukutjho bona banikela abafundi babo ilwazi leli egade banganalo nofana bathuthukise lelilwazi abafundi asele baliphethe

=== Ukwenza insiza zokufundisa ===
Lokha utitjhere nakafundisako akamane akhulume kwaphela kodwana kube neensiza zokufundisa ezifana namatjhadi, iinthombe nokhunye ekuzokwenza bona abafundi bakghone ukuzwisisa isifundo lula ngaphandle kokuthi bararane ihloko.

=== Ukwenza iinhlahlubo ===
Umsebenzi katitjhere kukuthi athathe koke lokhu akufundise abafundi bakhe bese ahlele isihlahlubo sakhe sethemu nofana sonyaka ahlolel bonyana lokhu abekakufundisa abafundi bakhe sele bakuzwisisile nofana awa&lt;ref&gt;Doyle, A., Johnson, M.C., Donlon, E., McDonald, E. and Sexton, P.J., 2021. The role of the teacher as assessor: Developing student teacher's assessment identity. ''Australian Journal of Teacher Education (Online)'', ''46''(12), pp.52-68.&lt;/ref&gt;. Uhlola bonyana khuyini leyo ebatlhaga ukuyimba nokuzwisisa nokuthi yini esele bayazi khulu kilezi zinto abazifundileko

== Iintjhijilo zokuba ngutitjhere ==
Abotitjhere lokha nabasebenzako baqaalana neetjhijilo ezinengi ezahlukahlukeno.Uthole abotitjhere badelelwa bafundi ngesibanga sokuthi abafundi abasabethwa eenkolweni bese bagcine sele babona abotitjhere njebantu abadelelekileko&lt;ref&gt;Flores, M.A., 2017. The complexities and challenges of be (com) ing a teacher and a teacher educator. ''European journal of teacher education'', ''40''(1), pp.2-5.&lt;/ref&gt;. Obunye ubudisi kukuthi abantu babona ngathi umsebenzi wabo titjhere bamabanga aphasi ngathi ulula khulu begodu babona kanti ngibo ebenza umsebenzi omkhulu. 

Abantu bacabanga bona utitjhere usebenza ukufundisa kwaphela abazi ukuthi minengi imisebenzi ebayenzako lokha nabange tlasini efana nokuthi baqinisekile ukuthi amafayili wabo ahleleke kuhle begodu kufanele benze neensiza zokufundisa.</text>
      <sha1>kud414az94tvmnmtuchjtwbdfg5zyeg</sha1>
    </revision>
    <revision>
      <id>3405</id>
      <parentid>2674</parentid>
      <timestamp>2025-07-12T13:13:14Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3405</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3989" sha1="7no96zs6c99nvac4yo2cnhqs860ynu1" xml:space="preserve">[[Isimumathi:Teacher teaching mathematics.png|thumb|Utitjhere afundisa abafundi iimbalo]]

== Abotitjhere ==
'''Abotitjhere''' bafundisi  babentwana kuze bangatholakali izintweni namkha ezindleleni eziphuma endleleni.[[Isikolo]] ngeze saba khona ngaphandle kotitjhere Barhelebha abentwana bona babenelwazi mayelana nefundo, bafundisa bona umntwana abenokuzithemba azazi bona yini akghona kuyenza nento angakghoni ukuyenza&lt;ref&gt;TEACHER | English meaning - Cambridge Dictionary&lt;/ref&gt;. Abotitjhere abafundisa amabanga aphasi,bafundisa  abentwana bona bakghone ukutlola ,nokufunda nokhunye. Barhelebha umntwana bona akghone ukufunda incwadi nokutlola imitjho emide , begodu bakghone ukutlola kuhle imisebenzi yabo.

== Ukuqakatheka kukatitjhere ==
Abotitjhere baqakathekile ngombana basisekelo sefundo. Lokha abotitjhere nabangekho ifundo ngekhe yabalula. Abotitjhere bafundisa aabantwana bona bakghona ukufunda nokutlolwa. Banikelwa abantwana ilwazi elizeleko ngepilo babasize bonyana bakghone ukufezikisa amabhudango wabo ngokuthi babe ngilokho abafuna ukuba ngikho nabakhulako.
Woke amabizelo abawalandeko abantu abelethwa botitjhere ngombana bengekhe kube lula ukuthi bawalandele kube azange abotitjhere babekhona ukubafundisa babe nelwazi lokuthi kufuze benzene ukuthi balandele amabizelo lawo&lt;ref&gt;Gore, V. and Begum, S., 2012. Role of a Teacher in 21st Century. ''The Criterion: An International Journal in English'', ''3''(3), pp.2-7.&lt;/ref&gt;.

== Umsebenzi katitjhere ==

=== Ukulawula itlasi ===
Utitjhere usebenza ukuthi alawule [[itlasi]] lakhe liba njani. Lokhu angakwenza ngokuthi enze immithetho yangetlasini abafundi abazoyilandela. Okhunye godu uhle indlela itlasi lakhe lizokuqaleka ngakhona isibonelo iindlela abantwana abazokuhlala ngayo nokuthi yena uzokuhlala kuphi&lt;ref&gt;Ibrahim, M.H.A.R., 2016. Classroom management: The effectiveness of teacher’s roles. ''Education and Linguistics Research'', ''2''(1), pp.69-84.&lt;/ref&gt;. Nokuthi uzokusebenzisa yiphi ikambiso ukuthi abafundi bafunde kamnandi bathabele ukufunda.

=== Ukufundisa ===
Ukufundisa msebenzi ovamilleko katitijhere ngombana ngombana woke umuntu uyazi ukuthi abotitjhere basebenza ukufundisa. Ukutjho bona banikela abafundi babo ilwazi leli egade banganalo nofana bathuthukise lelilwazi abafundi asele baliphethe

=== Ukwenza insiza zokufundisa ===
Lokha utitjhere nakafundisako akamane akhulume kwaphela kodwana kube neensiza zokufundisa ezifana namatjhadi, iinthombe nokhunye ekuzokwenza bona abafundi bakghone ukuzwisisa isifundo lula ngaphandle kokuthi bararane ihloko.

=== Ukwenza iinhlahlubo ===
Umsebenzi katitjhere kukuthi athathe koke lokhu akufundise abafundi bakhe bese ahlele isihlahlubo sakhe sethemu nofana sonyaka ahlolel bonyana lokhu abekakufundisa abafundi bakhe sele bakuzwisisile nofana awa&lt;ref&gt;Doyle, A., Johnson, M.C., Donlon, E., McDonald, E. and Sexton, P.J., 2021. The role of the teacher as assessor: Developing student teacher's assessment identity. ''Australian Journal of Teacher Education (Online)'', ''46''(12), pp.52-68.&lt;/ref&gt;. Uhlola bonyana khuyini leyo ebatlhaga ukuyimba nokuzwisisa nokuthi yini esele bayazi khulu kilezi zinto abazifundileko

== Iintjhijilo zokuba ngutitjhere ==
Abotitjhere lokha nabasebenzako baqaalana neetjhijilo ezinengi ezahlukahlukeno.Uthole abotitjhere badelelwa bafundi ngesibanga sokuthi abafundi abasabethwa eenkolweni bese bagcine sele babona abotitjhere njebantu abadelelekileko&lt;ref&gt;Flores, M.A., 2017. The complexities and challenges of be (com) ing a teacher and a teacher educator. ''European journal of teacher education'', ''40''(1), pp.2-5.&lt;/ref&gt;. Obunye ubudisi kukuthi abantu babona ngathi umsebenzi wabo titjhere bamabanga aphasi ngathi ulula khulu begodu babona kanti ngibo ebenza umsebenzi omkhulu. 

Abantu bacabanga bona utitjhere usebenza ukufundisa kwaphela abazi ukuthi minengi imisebenzi ebayenzako lokha nabange tlasini efana nokuthi baqinisekile ukuthi amafayili wabo ahleleke kuhle begodu kufanele benze neensiza zokufundisa.</text>
      <sha1>7no96zs6c99nvac4yo2cnhqs860ynu1</sha1>
    </revision>
    <revision>
      <id>3577</id>
      <parentid>3405</parentid>
      <timestamp>2025-08-06T16:18:42Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>3577</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4055" sha1="2xpp0nz73fhzgl05kdw9sz5kskbpu5s" xml:space="preserve">[[Isimumathi:Teacher teaching mathematics.png|thumb|Utitjhere afundisa abafundi iimbalo]]

== Abotitjhere ==
'''Abotitjhere''' bafundisi  babentwana kuze bangatholakali izintweni namkha ezindleleni eziphuma endleleni.[[Isikolo]] ngeze saba khona ngaphandle kotitjhere Barhelebha abentwana bona babenelwazi mayelana nefundo, bafundisa bona umntwana abenokuzithemba azazi bona yini akghona kuyenza nento angakghoni ukuyenza&lt;ref&gt;TEACHER | English meaning - Cambridge Dictionary&lt;/ref&gt;. Abotitjhere abafundisa amabanga aphasi,bafundisa  abentwana bona bakghone ukutlola ,nokufunda nokhunye. Barhelebha umntwana bona akghone ukufunda incwadi nokutlola imitjho emide , begodu bakghone ukutlola kuhle imisebenzi yabo.

== Ukuqakatheka kukatitjhere ==
Abotitjhere baqakathekile ngombana basisekelo sefundo. Lokha abotitjhere nabangekho ifundo ngekhe yabalula. Abotitjhere bafundisa aabantwana bona bakghona ukufunda nokutlolwa. Banikelwa abantwana ilwazi elizeleko ngepilo babasize bonyana bakghone ukufezikisa amabhudango wabo ngokuthi babe ngilokho abafuna ukuba ngikho nabakhulako.
Woke amabizelo abawalandeko abantu abelethwa botitjhere ngombana bengekhe kube lula ukuthi bawalandele kube azange abotitjhere babekhona ukubafundisa babe nelwazi lokuthi kufuze benzene ukuthi balandele amabizelo lawo&lt;ref&gt;Gore, V. and Begum, S., 2012. Role of a Teacher in 21st Century. ''The Criterion: An International Journal in English'', ''3''(3), pp.2-7.&lt;/ref&gt;.

== Umsebenzi katitjhere ==

=== Ukulawula itlasi ===
Utitjhere usebenza ukuthi alawule [[itlasi]] lakhe liba njani. Lokhu angakwenza ngokuthi enze immithetho yangetlasini abafundi abazoyilandela. Okhunye godu uhle indlela itlasi lakhe lizokuqaleka ngakhona isibonelo iindlela abantwana abazokuhlala ngayo nokuthi yena uzokuhlala kuphi&lt;ref&gt;Ibrahim, M.H.A.R., 2016. Classroom management: The effectiveness of teacher’s roles. ''Education and Linguistics Research'', ''2''(1), pp.69-84.&lt;/ref&gt;. Nokuthi uzokusebenzisa yiphi ikambiso ukuthi abafundi bafunde kamnandi bathabele ukufunda.

=== Ukufundisa ===
Ukufundisa msebenzi ovamilleko katitijhere ngombana ngombana woke umuntu uyazi ukuthi abotitjhere basebenza ukufundisa. Ukutjho bona banikela abafundi babo ilwazi leli egade banganalo nofana bathuthukise lelilwazi abafundi asele baliphethe

=== Ukwenza insiza zokufundisa ===
Lokha utitjhere nakafundisako akamane akhulume kwaphela kodwana kube neensiza zokufundisa ezifana namatjhadi, iinthombe nokhunye ekuzokwenza bona abafundi bakghone ukuzwisisa isifundo lula ngaphandle kokuthi bararane ihloko.

=== Ukwenza iinhlahlubo ===
Umsebenzi katitjhere kukuthi athathe koke lokhu akufundise abafundi bakhe bese ahlele isihlahlubo sakhe sethemu nofana sonyaka ahlolel bonyana lokhu abekakufundisa abafundi bakhe sele bakuzwisisile nofana awa&lt;ref&gt;Doyle, A., Johnson, M.C., Donlon, E., McDonald, E. and Sexton, P.J., 2021. The role of the teacher as assessor: Developing student teacher's assessment identity. ''Australian Journal of Teacher Education (Online)'', ''46''(12), pp.52-68.&lt;/ref&gt;. Uhlola bonyana khuyini leyo ebatlhaga ukuyimba nokuzwisisa nokuthi yini esele bayazi khulu kilezi zinto abazifundileko

== Iintjhijilo zokuba ngutitjhere ==
Abotitjhere lokha nabasebenzako baqaalana neetjhijilo ezinengi ezahlukahlukeno.Uthole abotitjhere badelelwa bafundi ngesibanga sokuthi abafundi abasabethwa eenkolweni bese bagcine sele babona abotitjhere njebantu abadelelekileko&lt;ref&gt;Flores, M.A., 2017. The complexities and challenges of be (com) ing a teacher and a teacher educator. ''European journal of teacher education'', ''40''(1), pp.2-5.&lt;/ref&gt;. Obunye ubudisi kukuthi abantu babona ngathi umsebenzi wabo titjhere bamabanga aphasi ngathi ulula khulu begodu babona kanti ngibo ebenza umsebenzi omkhulu. 

Abantu bacabanga bona utitjhere usebenza ukufundisa kwaphela abazi ukuthi minengi imisebenzi ebayenzako lokha nabange tlasini efana nokuthi baqinisekile ukuthi amafayili wabo ahleleke kuhle begodu kufanele benze neensiza zokufundisa.
[[Category:Abotitjhere]]
[[Category:Ifundo]]
[[Category:Isikolo]]</text>
      <sha1>2xpp0nz73fhzgl05kdw9sz5kskbpu5s</sha1>
    </revision>
    <revision>
      <id>3578</id>
      <parentid>3577</parentid>
      <timestamp>2025-08-06T16:20:45Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3578</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4065" sha1="3mclubyf3k5nmddr2h04stymu4c7no0" xml:space="preserve">[[Isimumathi:Teacher teaching mathematics.png|thumb|Utitjhere afundisa abafundi iimbalo]]

'''Abotitjhere''' bafundisi  babentwana kuze bangatholakali izintweni namkha ezindleleni eziphuma endleleni.[[Isikolo]] ngeze saba khona ngaphandle kotitjhere Barhelebha abentwana bona babenelwazi mayelana nefundo, bafundisa bona umntwana abenokuzithemba azazi bona yini akghona kuyenza nento angakghoni ukuyenza&lt;ref&gt;TEACHER | English meaning - Cambridge Dictionary&lt;/ref&gt;. Abotitjhere abafundisa amabanga aphasi,bafundisa  abentwana bona bakghone ukutlola ,nokufunda nokhunye. Barhelebha umntwana bona akghone ukufunda incwadi nokutlola imitjho emide , begodu bakghone ukutlola kuhle imisebenzi yabo.

=== Ukuqakatheka kukatitjhere ===
Abotitjhere baqakathekile ngombana basisekelo sefundo. Lokha abotitjhere nabangekho ifundo ngekhe yabalula. Abotitjhere bafundisa aabantwana bona bakghona ukufunda nokutlolwa. Banikelwa abantwana ilwazi elizeleko ngepilo babasize bonyana bakghone ukufezikisa amabhudango wabo ngokuthi babe ngilokho abafuna ukuba ngikho nabakhulako.
Woke amabizelo abawalandeko abantu abelethwa botitjhere ngombana bengekhe kube lula ukuthi bawalandele kube azange abotitjhere babekhona ukubafundisa babe nelwazi lokuthi kufuze benzene ukuthi balandele amabizelo lawo&lt;ref&gt;Gore, V. and Begum, S., 2012. Role of a Teacher in 21st Century. ''The Criterion: An International Journal in English'', ''3''(3), pp.2-7.&lt;/ref&gt;.

=== Umsebenzi katitjhere ===

==== Ukulawula itlasi ====
Utitjhere usebenza ukuthi alawule [[itlasi]] lakhe liba njani. Lokhu angakwenza ngokuthi enze immithetho yangetlasini abafundi abazoyilandela. Okhunye godu uhle indlela itlasi lakhe lizokuqaleka ngakhona isibonelo iindlela abantwana abazokuhlala ngayo nokuthi yena uzokuhlala kuphi&lt;ref&gt;Ibrahim, M.H.A.R., 2016. Classroom management: The effectiveness of teacher’s roles. ''Education and Linguistics Research'', ''2''(1), pp.69-84.&lt;/ref&gt;. Nokuthi uzokusebenzisa yiphi ikambiso ukuthi abafundi bafunde kamnandi bathabele ukufunda.

==== Ukufundisa ====
Ukufundisa msebenzi ovamilleko katitijhere ngombana ngombana woke umuntu uyazi ukuthi abotitjhere basebenza ukufundisa. Ukutjho bona banikela abafundi babo ilwazi leli egade banganalo nofana bathuthukise lelilwazi abafundi asele baliphethe

==== Ukwenza insiza zokufundisa ====
Lokha utitjhere nakafundisako akamane akhulume kwaphela kodwana kube neensiza zokufundisa ezifana namatjhadi, iinthombe nokhunye ekuzokwenza bona abafundi bakghone ukuzwisisa isifundo lula ngaphandle kokuthi bararane ihloko.

==== Ukwenza iinhlahlubo ====
Umsebenzi katitjhere kukuthi athathe koke lokhu akufundise abafundi bakhe bese ahlele isihlahlubo sakhe sethemu nofana sonyaka ahlolel bonyana lokhu abekakufundisa abafundi bakhe sele bakuzwisisile nofana awa&lt;ref&gt;Doyle, A., Johnson, M.C., Donlon, E., McDonald, E. and Sexton, P.J., 2021. The role of the teacher as assessor: Developing student teacher's assessment identity. ''Australian Journal of Teacher Education (Online)'', ''46''(12), pp.52-68.&lt;/ref&gt;. Uhlola bonyana khuyini leyo ebatlhaga ukuyimba nokuzwisisa nokuthi yini esele bayazi khulu kilezi zinto abazifundileko

=== Iintjhijilo zokuba ngutitjhere ===
Abotitjhere lokha nabasebenzako baqaalana neetjhijilo ezinengi ezahlukahlukeno.Uthole abotitjhere badelelwa bafundi ngesibanga sokuthi abafundi abasabethwa eenkolweni bese bagcine sele babona abotitjhere njebantu abadelelekileko&lt;ref&gt;Flores, M.A., 2017. The complexities and challenges of be (com) ing a teacher and a teacher educator. ''European journal of teacher education'', ''40''(1), pp.2-5.&lt;/ref&gt;. Obunye ubudisi kukuthi abantu babona ngathi umsebenzi wabo titjhere bamabanga aphasi ngathi ulula khulu begodu babona kanti ngibo ebenza umsebenzi omkhulu.Abantu bacabanga bona utitjhere usebenza ukufundisa kwaphela abazi ukuthi minengi imisebenzi ebayenzako lokha nabange tlasini efana nokuthi baqinisekile ukuthi amafayili wabo ahleleke kuhle begodu kufanele benze neensiza zokufundisa. 

== Iinkomba ==
[[Category:Abotitjhere]]
[[Category:Ifundo]]
[[Category:Isikolo]]</text>
      <sha1>3mclubyf3k5nmddr2h04stymu4c7no0</sha1>
    </revision>
    <revision>
      <id>3579</id>
      <parentid>3578</parentid>
      <timestamp>2025-08-06T16:35:14Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3579</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5024" sha1="lorvfkjuniyxhykcdcmn6rgoeobg7dr" xml:space="preserve">[[Isimumathi:Teacher teaching mathematics.png|thumb|Utitjhere afundisa abafundi iimbalo]]

'''Abotitjhere''' bafundisi  babentwana kuze bangatholakali izintweni namkha ezindleleni eziphuma endleleni.[[Isikolo]] ngeze saba khona ngaphandle kotitjhere Barhelebha abentwana bona babenelwazi mayelana nefundo, bafundisa bona umntwana abenokuzithemba azazi bona yini akghona kuyenza nento angakghoni ukuyenza&lt;ref&gt;TEACHER | English meaning - Cambridge Dictionary&lt;/ref&gt;. Abotitjhere abafundisa amabanga aphasi,bafundisa  abentwana bona bakghone ukutlola ,nokufunda nokhunye. Barhelebha umntwana bona akghone ukufunda incwadi nokutlola imitjho emide , begodu bakghone ukutlola kuhle imisebenzi yabo.

=== Ukuqakatheka kukatitjhere ===
Abotitjhere baqakathekile ngombana basisekelo sefundo. Lokha abotitjhere nabangekho [[ifundo]] ngekhe yabalula. Abotitjhere bafundisa aabantwana bona bakghona ukufunda nokutlolwa. Banikelwa abantwana ilwazi elizeleko ngepilo babasize bonyana bakghone ukufezikisa amabhudango wabo ngokuthi babe ngilokho abafuna ukuba ngikho nabakhulako.Woke amabizelo abawalandeko abantu abelethwa botitjhere ngombana bengekhe kube lula ukuthi bawalandele kube azange abotitjhere babekhona ukubafundisa babe nelwazi lokuthi kufuze benzene ukuthi balandele amabizelo lawo&lt;ref&gt;Gore, V. and Begum, S., 2012. Role of a Teacher in 21st Century. ''The Criterion: An International Journal in English'', ''3''(3), pp.2-7.&lt;/ref&gt;.

=== Umsebenzi katitjhere ===

==== Ukulawula itlasi ====
Utitjhere usebenza ukuthi alawule [[itlasi]] lakhe liba njani. Lokhu angakwenza ngokuthi enze immithetho yangetlasini abafundi abazoyilandela. Okhunye godu uhle indlela itlasi lakhe lizokuqaleka ngakhona isibonelo iindlela abantwana abazokuhlala ngayo nokuthi yena uzokuhlala kuphi&lt;ref&gt;Ibrahim, M.H.A.R., 2016. Classroom management: The effectiveness of teacher’s roles. ''Education and Linguistics Research'', ''2''(1), pp.69-84.&lt;/ref&gt;. Nokuthi uzokusebenzisa yiphi ikambiso ukuthi abafundi bafunde kamnandi bathabele ukufunda.Ukulawula kumsebenzi katitjhere wangangamalanga awenzako ngombana lokho kulawula bonyana kuyafundeka ngetasini nofana akufundeki.

==== Ukufundisa ====
Ukufundisa msebenzi ovamilleko katitijhere ngombana ngombana woke umuntu uyazi ukuthi abotitjhere basebenza ukufundisa. Ukutjho bona banikela abafundi babo ilwazi leli egade banganalo nofana bathuthukise lelilwazi abafundi asele baliphethe. Utitjhere lokha nakafundisako wenza bonyana abantwana bakghone ukuzwisisa iinhloko ezithileko egade bangazizwisisi ekuthomeni bakhulume ngelwazi lokuphila amaphilo wabo begodu bafundu ukuthi bajamele. Utitjhere ufundisa abafundi izint ezinengi kungaba kukuthi bathole amakghono wepilo, ilimi nofana ukubala. Omunye nomunye utitjhere ufundisa isifundo esithwaselko efundweni yamaziko aphezulu,

==== Ukwenza insiza zokufundisa ====
Lokha utitjhere nakafundisako akamane akhulume kwaphela kodwana kube neensiza zokufundisa ezifana namatjhadi, iinthombe nokhunye ekuzokwenza bona abafundi bakghone ukuzwisisa isifundo lula ngaphandle kokuthi bararane ihloko. Utitjhwere wenza iinsiza zokufundisa ngombana abanye abafundi kungenzeka bonyana bangamuzwa lokha nakafundisako kodwana kuthi lokha nabaqala isisiza sokufundisa bese bakghone ukubona bonyana kufundwa ngani nofana bakghone ukuzwisisa isifundo leso abafundosswa sona.

==== Ukwenza iinhlahlubo ====
Umsebenzi katitjhere kukuthi athathe koke lokhu akufundise abafundi bakhe bese ahlele isihlahlubo sakhe sethemu nofana sonyaka ahlole bonyana lokhu abekakufundisa abafundi bakhe sele bakuzwisisile nofana awa&lt;ref&gt;Doyle, A., Johnson, M.C., Donlon, E., McDonald, E. and Sexton, P.J., 2021. The role of the teacher as assessor: Developing student teacher's assessment identity. ''Australian Journal of Teacher Education (Online)'', ''46''(12), pp.52-68.&lt;/ref&gt;. Uhlola bonyana khuyini leyo ebatlhaga ukuyibamba nokuzwisisa nokuthi yini esele bayazi khulu kilezi zinto abazifundileko. Omunye nomunye utitjhere ukghona ukubona abafundi abanekghono lokubamba begodu nabafundi abathatheloa kude. abaotitjhere bakghona ukuhlela imihlohlobo yeenhlahlubo.

=== Iintjhijilo zokuba ngutitjhere ===
Abotitjhere lokha nabasebenzako baqaalana neetjhijilo ezinengi ezahlukahlukeno.Uthole abotitjhere badelelwa bafundi ngesibanga sokuthi abafundi abasabethwa eenkolweni bese bagcine sele babona abotitjhere njebantu abadelelekileko&lt;ref&gt;Flores, M.A., 2017. The complexities and challenges of be (com) ing a teacher and a teacher educator. ''European journal of teacher education'', ''40''(1), pp.2-5.&lt;/ref&gt;. Obunye ubudisi kukuthi abantu babona ngathi umsebenzi wabo titjhere bamabanga aphasi ngathi ulula khulu begodu babona kanti ngibo ebenza umsebenzi omkhulu.Abantu bacabanga bona utitjhere usebenza ukufundisa kwaphela abazi ukuthi minengi imisebenzi ebayenzako lokha nabange tlasini efana nokuthi baqinisekile ukuthi amafayili wabo ahleleke kuhle begodu kufanele benze neensiza zokufundisa. 

== Iinkomba ==
[[Category:Abotitjhere]]
[[Category:Ifundo]]
[[Category:Isikolo]]</text>
      <sha1>lorvfkjuniyxhykcdcmn6rgoeobg7dr</sha1>
    </revision>
    <revision>
      <id>5168</id>
      <parentid>3579</parentid>
      <timestamp>2025-08-14T14:58:59Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5168</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5023" sha1="8iju9nx7ok9pg01qliavk00885cre85" xml:space="preserve">[[Isimumathi:Teacher teaching mathematics.png|thumb|Utitjhere afundisa abafundi iimbalo]]

'''Abotitjhere''' bafundisi  babentwana kuze bangatholakali izintweni namkha ezindleleni eziphuma endleleni.[[Isikolo]] ngeze saba khona ngaphandle kotitjhere Barhelebha abentwana bona babenelwazi mayelana nefundo, bafundisa bona umntwana abenokuzithemba azazi bona yini akghona kuyenza nento angakghoni ukuyenza.&lt;ref&gt;TEACHER | English meaning - Cambridge Dictionary&lt;/ref&gt; Abotitjhere abafundisa amabanga aphasi,bafundisa  abentwana bona bakghone ukutlola ,nokufunda nokhunye. Barhelebha umntwana bona akghone ukufunda incwadi nokutlola imitjho emide , begodu bakghone ukutlola kuhle imisebenzi yabo.

=== Ukuqakatheka kukatitjhere ===
Abotitjhere baqakathekile ngombana basisekelo sefundo. Lokha abotitjhere nabangekho [[ifundo]] ngekhe yabalula. Abotitjhere bafundisa aabantwana bona bakghona ukufunda nokutlolwa. Banikelwa abantwana ilwazi elizeleko ngepilo babasize bonyana bakghone ukufezikisa amabhudango wabo ngokuthi babe ngilokho abafuna ukuba ngikho nabakhulako.Woke amabizelo abawalandeko abantu abelethwa botitjhere ngombana bengekhe kube lula ukuthi bawalandele kube azange abotitjhere babekhona ukubafundisa babe nelwazi lokuthi kufuze benzene ukuthi balandele amabizelo lawo.&lt;ref&gt;Gore, V. and Begum, S., 2012. Role of a Teacher in 21st Century. ''The Criterion: An International Journal in English'', ''3''(3), pp.2-7.&lt;/ref&gt;

=== Umsebenzi katitjhere ===

==== Ukulawula itlasi ====
Utitjhere usebenza ukuthi alawule [[itlasi]] lakhe liba njani. Lokhu angakwenza ngokuthi enze immithetho yangetlasini abafundi abazoyilandela. Okhunye godu uhle indlela itlasi lakhe lizokuqaleka ngakhona isibonelo iindlela abantwana abazokuhlala ngayo nokuthi yena uzokuhlala kuphi.&lt;ref&gt;Ibrahim, M.H.A.R., 2016. Classroom management: The effectiveness of teacher’s roles. ''Education and Linguistics Research'', ''2''(1), pp.69-84.&lt;/ref&gt; Nokuthi uzokusebenzisa yiphi ikambiso ukuthi abafundi bafunde kamnandi bathabele ukufunda.Ukulawula kumsebenzi katitjhere wangangamalanga awenzako ngombana lokho kulawula bonyana kuyafundeka ngetasini nofana akufundeki.

==== Ukufundisa ====
Ukufundisa msebenzi ovamilleko katitijhere ngombana ngombana woke umuntu uyazi ukuthi abotitjhere basebenza ukufundisa. Ukutjho bona banikela abafundi babo ilwazi leli egade banganalo nofana bathuthukise lelilwazi abafundi asele baliphethe. Utitjhere lokha nakafundisako wenza bonyana abantwana bakghone ukuzwisisa iinhloko ezithileko egade bangazizwisisi ekuthomeni bakhulume ngelwazi lokuphila amaphilo wabo begodu bafundu ukuthi bajamele. Utitjhere ufundisa abafundi izint ezinengi kungaba kukuthi bathole amakghono wepilo, ilimi nofana ukubala. Omunye nomunye utitjhere ufundisa isifundo esithwaselko efundweni yamaziko aphezulu,

==== Ukwenza insiza zokufundisa ====
Lokha utitjhere nakafundisako akamane akhulume kwaphela kodwana kube neensiza zokufundisa ezifana namatjhadi, iinthombe nokhunye ekuzokwenza bona abafundi bakghone ukuzwisisa isifundo lula ngaphandle kokuthi bararane ihloko. Utitjhwere wenza iinsiza zokufundisa ngombana abanye abafundi kungenzeka bonyana bangamuzwa lokha nakafundisako kodwana kuthi lokha nabaqala isisiza sokufundisa bese bakghone ukubona bonyana kufundwa ngani nofana bakghone ukuzwisisa isifundo leso abafundosswa sona.

==== Ukwenza iinhlahlubo ====
Umsebenzi katitjhere kukuthi athathe koke lokhu akufundise abafundi bakhe bese ahlele isihlahlubo sakhe sethemu nofana sonyaka ahlole bonyana lokhu abekakufundisa abafundi bakhe sele bakuzwisisile nofana awa.&lt;ref&gt;Doyle, A., Johnson, M.C., Donlon, E., McDonald, E. and Sexton, P.J., 2021. The role of the teacher as assessor: Developing student teacher's assessment identity. ''Australian Journal of Teacher Education (Online)'', ''46''(12), pp.52-68.&lt;/ref&gt;Uhlola bonyana khuyini leyo ebatlhaga ukuyibamba nokuzwisisa nokuthi yini esele bayazi khulu kilezi zinto abazifundileko. Omunye nomunye utitjhere ukghona ukubona abafundi abanekghono lokubamba begodu nabafundi abathatheloa kude. abaotitjhere bakghona ukuhlela imihlohlobo yeenhlahlubo.

=== Iintjhijilo zokuba ngutitjhere ===
Abotitjhere lokha nabasebenzako baqaalana neetjhijilo ezinengi ezahlukahlukeno.Uthole abotitjhere badelelwa bafundi ngesibanga sokuthi abafundi abasabethwa eenkolweni bese bagcine sele babona abotitjhere njebantu abadelelekileko.&lt;ref&gt;Flores, M.A., 2017. The complexities and challenges of be (com) ing a teacher and a teacher educator. ''European journal of teacher education'', ''40''(1), pp.2-5.&lt;/ref&gt; Obunye ubudisi kukuthi abantu babona ngathi umsebenzi wabo titjhere bamabanga aphasi ngathi ulula khulu begodu babona kanti ngibo ebenza umsebenzi omkhulu.Abantu bacabanga bona utitjhere usebenza ukufundisa kwaphela abazi ukuthi minengi imisebenzi ebayenzako lokha nabange tlasini efana nokuthi baqinisekile ukuthi amafayili wabo ahleleke kuhle begodu kufanele benze neensiza zokufundisa. 

== Iinkomba ==
[[Category:Abotitjhere]]
[[Category:Ifundo]]
[[Category:Isikolo]]</text>
      <sha1>8iju9nx7ok9pg01qliavk00885cre85</sha1>
    </revision>
    <revision>
      <id>6698</id>
      <parentid>5168</parentid>
      <timestamp>2026-06-12T08:24:38Z</timestamp>
      <contributor>
        <username>MissHadassah</username>
        <id>1561</id>
      </contributor>
      <comment>changed formatting</comment>
      <origin>6698</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5031" sha1="tq7i1mvwxqibd0b2sky5y82c4vkbk06" xml:space="preserve">[[Isimumathi:Teacher teaching mathematics.png|thumb|Utitjhere afundisa abafundi iimbalo]]

'''Abotitjhere''' bafundisi  babentwana kuze bangatholakali izintweni namkha ezindleleni eziphuma endleleni''.[[Isikolo]]'' ngeze saba khona ngaphandle kotitjhere Barhelebha abentwana bona babenelwazi mayelana nefundo, bafundisa bona umntwana abenokuzithemba azazi bona yini akghona kuyenza nento angakghoni ukuyenza.&lt;ref&gt;TEACHER | English meaning - Cambridge Dictionary&lt;/ref&gt; Abotitjhere abafundisa amabanga aphasi,bafundisa  abentwana bona bakghone ukutlola ,nokufunda nokhunye. Barhelebha umntwana bona akghone ukufunda incwadi nokutlola imitjho emide , begodu bakghone ukutlola kuhle imisebenzi yabo.

=== Ukuqakatheka kukatitjhere ===
Abotitjhere baqakathekile ngombana basisekelo ''sefundo''. Lokha abotitjhere nabangekho [[ifundo]] ngekhe yabalula. Abotitjhere bafundisa aabantwana bona bakghona ukufunda nokutlolwa. Banikelwa abantwana ilwazi elizeleko ngepilo babasize bonyana bakghone ukufezikisa amabhudango wabo ngokuthi babe ngilokho abafuna ukuba ngikho nabakhulako.Woke amabizelo abawalandeko abantu abelethwa botitjhere ngombana bengekhe kube lula ukuthi bawalandele kube azange abotitjhere babekhona ukubafundisa babe nelwazi lokuthi kufuze benzene ukuthi balandele amabizelo lawo.&lt;ref&gt;Gore, V. and Begum, S., 2012. Role of a Teacher in 21st Century. ''The Criterion: An International Journal in English'', ''3''(3), pp.2-7.&lt;/ref&gt;

=== Umsebenzi katitjhere ===

==== Ukulawula itlasi ====
Utitjhere usebenza ukuthi alawule [[itlasi]] lakhe liba njani. Lokhu angakwenza ngokuthi enze immithetho yangetlasini abafundi abazoyilandela. Okhunye godu uhle indlela itlasi lakhe lizokuqaleka ngakhona isibonelo iindlela abantwana abazokuhlala ngayo nokuthi yena uzokuhlala kuphi.&lt;ref&gt;Ibrahim, M.H.A.R., 2016. Classroom management: The effectiveness of teacher’s roles. ''Education and Linguistics Research'', ''2''(1), pp.69-84.&lt;/ref&gt; Nokuthi uzokusebenzisa yiphi ikambiso ukuthi abafundi bafunde kamnandi bathabele ukufunda.Ukulawula kumsebenzi katitjhere wangangamalanga awenzako ngombana lokho kulawula bonyana kuyafundeka ngetasini nofana akufundeki.

==== Ukufundisa ====
Ukufundisa msebenzi ovamilleko katitijhere ngombana ngombana woke umuntu uyazi ukuthi abotitjhere basebenza ukufundisa. Ukutjho bona banikela abafundi babo ilwazi leli egade banganalo nofana bathuthukise lelilwazi abafundi asele baliphethe. Utitjhere lokha nakafundisako wenza bonyana abantwana bakghone ukuzwisisa iinhloko ezithileko egade bangazizwisisi ekuthomeni bakhulume ngelwazi lokuphila amaphilo wabo begodu bafundu ukuthi bajamele. Utitjhere ufundisa abafundi izint ezinengi kungaba kukuthi bathole amakghono wepilo, ilimi nofana ukubala. Omunye nomunye utitjhere ufundisa isifundo esithwaselko efundweni yamaziko aphezulu,

==== Ukwenza insiza zokufundisa ====
Lokha utitjhere nakafundisako akamane akhulume kwaphela kodwana kube neensiza zokufundisa ezifana namatjhadi, iinthombe nokhunye ekuzokwenza bona abafundi bakghone ukuzwisisa isifundo lula ngaphandle kokuthi bararane ihloko. Utitjhwere wenza iinsiza zokufundisa ngombana abanye abafundi kungenzeka bonyana bangamuzwa lokha nakafundisako kodwana kuthi lokha nabaqala isisiza sokufundisa bese bakghone ukubona bonyana kufundwa ngani nofana bakghone ukuzwisisa isifundo leso abafundosswa sona.

==== Ukwenza iinhlahlubo ====
Umsebenzi katitjhere kukuthi athathe koke lokhu akufundise abafundi bakhe bese ahlele isihlahlubo sakhe sethemu nofana sonyaka ahlole bonyana lokhu abekakufundisa abafundi bakhe sele bakuzwisisile nofana awa.&lt;ref&gt;Doyle, A., Johnson, M.C., Donlon, E., McDonald, E. and Sexton, P.J., 2021. The role of the teacher as assessor: Developing student teacher's assessment identity. ''Australian Journal of Teacher Education (Online)'', ''46''(12), pp.52-68.&lt;/ref&gt;Uhlola bonyana khuyini leyo ebatlhaga ukuyibamba nokuzwisisa nokuthi yini esele bayazi khulu kilezi zinto abazifundileko. Omunye nomunye utitjhere ukghona ukubona abafundi abanekghono lokubamba begodu nabafundi abathatheloa kude. abaotitjhere bakghona ukuhlela imihlohlobo yeenhlahlubo.

=== Iintjhijilo zokuba ngutitjhere ===
Abotitjhere lokha nabasebenzako baqaalana neetjhijilo ezinengi ezahlukahlukeno.Uthole abotitjhere badelelwa bafundi ngesibanga sokuthi abafundi abasabethwa eenkolweni bese bagcine sele babona abotitjhere njebantu abadelelekileko.&lt;ref&gt;Flores, M.A., 2017. The complexities and challenges of be (com) ing a teacher and a teacher educator. ''European journal of teacher education'', ''40''(1), pp.2-5.&lt;/ref&gt; Obunye ubudisi kukuthi abantu babona ngathi umsebenzi wabo titjhere bamabanga aphasi ngathi ulula khulu begodu babona kanti ngibo ebenza umsebenzi omkhulu.Abantu bacabanga bona utitjhere usebenza ukufundisa kwaphela abazi ukuthi minengi imisebenzi ebayenzako lokha nabange tlasini efana nokuthi baqinisekile ukuthi amafayili wabo ahleleke kuhle begodu kufanele benze neensiza zokufundisa. 

== Iinkomba ==
[[Category:Abotitjhere]]
[[Category:Ifundo]]
[[Category:Isikolo]]</text>
      <sha1>tq7i1mvwxqibd0b2sky5y82c4vkbk06</sha1>
    </revision>
  </page>
  <page>
    <title>Ukuphefumula</title>
    <ns>0</ns>
    <id>554</id>
    <revision>
      <id>2661</id>
      <timestamp>2025-04-15T16:35:17Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Ukuphefumula == '''Ukuphefumula''' kukulokha ipumulo ingenisa nofana ikhipha ummoya&lt;ref&gt;BREATHING | English meaning - Cambridge Dictionary&lt;/ref&gt;. Ukuphefumula ngikho okukhombisa ukuthi umuntu uyaphila. Nawufuna ukuhlukanisa izinto eziphilako nezingaphiliko kufuze utjheje bonyana into leyo iyaphefumula nofana awa.   Umuntu lokha nakaphefumulako udosa ummoya ocwengileko obizwa nge oksijini awungenise ngaphakathi uye emaphaphini. Ukhipha ummoya osilaphazekileko obizwa bo...&quot;</comment>
      <origin>2661</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="654" sha1="8y9qwo01zs1nxgyes1a95v1m4c9jtq0" xml:space="preserve">== Ukuphefumula ==
'''Ukuphefumula''' kukulokha ipumulo ingenisa nofana ikhipha ummoya&lt;ref&gt;BREATHING | English meaning - Cambridge Dictionary&lt;/ref&gt;. Ukuphefumula ngikho okukhombisa ukuthi umuntu uyaphila. Nawufuna ukuhlukanisa izinto eziphilako nezingaphiliko kufuze utjheje bonyana into leyo iyaphefumula nofana awa. 

Umuntu lokha nakaphefumulako udosa ummoya ocwengileko obizwa nge oksijini awungenise ngaphakathi uye emaphaphini. Ukhipha ummoya osilaphazekileko obizwa bona nge khabhoni dayoksayidi.  

Yoke into ephilako iyaphefumula. Iintjalo ziyaphefumula ngokuphikisana nabantu ngombana zona zikhupha i-oksijini bese zidose ikhabhoni dayoksayidi.</text>
      <sha1>8y9qwo01zs1nxgyes1a95v1m4c9jtq0</sha1>
    </revision>
    <revision>
      <id>2983</id>
      <parentid>2661</parentid>
      <timestamp>2025-06-06T20:10:41Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>ytgfewkdgrej</comment>
      <origin>2983</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="742" sha1="og1lxq74xi8oy8fcp55tgo52f9trpul" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.'''

== Ukuphefumula ==
'''Ukuphefumula''' kukulokha ipumulo ingenisa nofana ikhipha ummoya&lt;ref&gt;BREATHING | English meaning - Cambridge Dictionary&lt;/ref&gt;. Ukuphefumula ngikho okukhombisa ukuthi umuntu uyaphila. Nawufuna ukuhlukanisa izinto eziphilako nezingaphiliko kufuze utjheje bonyana into leyo iyaphefumula nofana awa. 

Umuntu lokha nakaphefumulako udosa ummoya ocwengileko obizwa nge oksijini awungenise ngaphakathi uye emaphaphini. Ukhipha ummoya osilaphazekileko obizwa bona nge khabhoni dayoksayidi.  

Yoke into ephilako iyaphefumula. Iintjalo ziyaphefumula ngokuphikisana nabantu ngombana zona zikhupha i-oksijini bese zidose ikhabhoni dayoksayidi.</text>
      <sha1>og1lxq74xi8oy8fcp55tgo52f9trpul</sha1>
    </revision>
    <revision>
      <id>3069</id>
      <parentid>2983</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Nqobile69|Nqobile69]]</comment>
      <origin>2661</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="654" sha1="8y9qwo01zs1nxgyes1a95v1m4c9jtq0" xml:space="preserve">== Ukuphefumula ==
'''Ukuphefumula''' kukulokha ipumulo ingenisa nofana ikhipha ummoya&lt;ref&gt;BREATHING | English meaning - Cambridge Dictionary&lt;/ref&gt;. Ukuphefumula ngikho okukhombisa ukuthi umuntu uyaphila. Nawufuna ukuhlukanisa izinto eziphilako nezingaphiliko kufuze utjheje bonyana into leyo iyaphefumula nofana awa. 

Umuntu lokha nakaphefumulako udosa ummoya ocwengileko obizwa nge oksijini awungenise ngaphakathi uye emaphaphini. Ukhipha ummoya osilaphazekileko obizwa bona nge khabhoni dayoksayidi.  

Yoke into ephilako iyaphefumula. Iintjalo ziyaphefumula ngokuphikisana nabantu ngombana zona zikhupha i-oksijini bese zidose ikhabhoni dayoksayidi.</text>
      <sha1>8y9qwo01zs1nxgyes1a95v1m4c9jtq0</sha1>
    </revision>
  </page>
  <page>
    <title>Isikolo</title>
    <ns>0</ns>
    <id>555</id>
    <revision>
      <id>2662</id>
      <timestamp>2025-04-15T16:39:16Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Isikolo == '''Isikolo''' kuyindawo kuyindawo lapho kuhlangana abantwana abanengi bendawo bazokufunda&lt;ref&gt;SCHOOL | English meaning - Cambridge Dictionary&lt;/ref&gt;. Isikolo yindawo ekulu ematlasi amanengi lapho kufundela khona abantwana ngokwesigaba abakiso ngefundo.Esikolweni kunama ofisi wabo titjhere nelaka hlokokulu. Esikolweni kuyindawo lapho abantwana baceda khona iskhathi sabo esinengi ngelanga, lokhu kuhle ngombana kwenza bona bahlale babulungekile. Abantwana batho...&quot;</comment>
      <origin>2662</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="786" sha1="p9p58vt32xtzmshnrizl3w30pse4enb" xml:space="preserve">== Isikolo ==
'''Isikolo''' kuyindawo kuyindawo lapho kuhlangana abantwana abanengi bendawo bazokufunda&lt;ref&gt;SCHOOL | English meaning - Cambridge Dictionary&lt;/ref&gt;. Isikolo yindawo ekulu ematlasi amanengi lapho kufundela khona abantwana ngokwesigaba abakiso ngefundo.Esikolweni kunama ofisi wabo titjhere nelaka hlokokulu. Esikolweni kuyindawo lapho abantwana baceda khona iskhathi sabo esinengi ngelanga, lokhu kuhle ngombana kwenza bona bahlale babulungekile. Abantwana bathola ilwazi elibenza bona ukujamelana nepillo esikolweni. Isikolo kuyindawo yomphakathi ngombana ngaphandle komphakathi isikolo ngekhe sabo khona nehlelo lokufunda nokufundisa emphakathini angeze libe khona&lt;ref&gt;Smith, G.A. and Sobel, D., 2014. ''Place-and community-based education in schools''. Routledge.&lt;/ref&gt;.</text>
      <sha1>p9p58vt32xtzmshnrizl3w30pse4enb</sha1>
    </revision>
    <revision>
      <id>2673</id>
      <parentid>2662</parentid>
      <timestamp>2025-04-22T17:49:05Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2673</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="776" sha1="c4ual4f769x3kp1b561mzla7i2xdr7g" xml:space="preserve">== Isikolo ==
'''Isikolo''' kuyindawo lapho kuhlangana abantwana abanengi bendawo bazokufunda&lt;ref&gt;SCHOOL | English meaning - Cambridge Dictionary&lt;/ref&gt;. Isikolo yindawo ekulu ematlasi amanengi lapho kufundela khona abantwana ngokwesigaba abakiso ngefundo.Esikolweni kunama ofisi wabo titjhere nelaka hlokokulu. Esikolweni kuyindawo lapho abantwana baceda khona iskhathi sabo esinengi ngelanga, lokhu kuhle ngombana kwenza bona bahlale babulungekile. Abantwana bathola ilwazi elibenza bona ukujamelana nepillo esikolweni. Isikolo kuyindawo yomphakathi ngombana ngaphandle komphakathi isikolo ngekhe sabo khona nehlelo lokufunda nokufundisa emphakathini angeze libe khona&lt;ref&gt;Smith, G.A. and Sobel, D., 2014. ''Place-and community-based education in schools''. Routledge.&lt;/ref&gt;.</text>
      <sha1>c4ual4f769x3kp1b561mzla7i2xdr7g</sha1>
    </revision>
    <revision>
      <id>2994</id>
      <parentid>2673</parentid>
      <timestamp>2025-06-06T20:16:15Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>I am steve</comment>
      <origin>2994</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="864" sha1="sh4ke1l5ulbq29biwrsx511cy303pfa" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.'''

== Isikolo ==
'''Isikolo''' kuyindawo lapho kuhlangana abantwana abanengi bendawo bazokufunda&lt;ref&gt;SCHOOL | English meaning - Cambridge Dictionary&lt;/ref&gt;. Isikolo yindawo ekulu ematlasi amanengi lapho kufundela khona abantwana ngokwesigaba abakiso ngefundo.Esikolweni kunama ofisi wabo titjhere nelaka hlokokulu. Esikolweni kuyindawo lapho abantwana baceda khona iskhathi sabo esinengi ngelanga, lokhu kuhle ngombana kwenza bona bahlale babulungekile. Abantwana bathola ilwazi elibenza bona ukujamelana nepillo esikolweni. Isikolo kuyindawo yomphakathi ngombana ngaphandle komphakathi isikolo ngekhe sabo khona nehlelo lokufunda nokufundisa emphakathini angeze libe khona&lt;ref&gt;Smith, G.A. and Sobel, D., 2014. ''Place-and community-based education in schools''. Routledge.&lt;/ref&gt;.</text>
      <sha1>sh4ke1l5ulbq29biwrsx511cy303pfa</sha1>
    </revision>
    <revision>
      <id>3065</id>
      <parentid>2994</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Nqobile69|Nqobile69]]</comment>
      <origin>2673</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="776" sha1="c4ual4f769x3kp1b561mzla7i2xdr7g" xml:space="preserve">== Isikolo ==
'''Isikolo''' kuyindawo lapho kuhlangana abantwana abanengi bendawo bazokufunda&lt;ref&gt;SCHOOL | English meaning - Cambridge Dictionary&lt;/ref&gt;. Isikolo yindawo ekulu ematlasi amanengi lapho kufundela khona abantwana ngokwesigaba abakiso ngefundo.Esikolweni kunama ofisi wabo titjhere nelaka hlokokulu. Esikolweni kuyindawo lapho abantwana baceda khona iskhathi sabo esinengi ngelanga, lokhu kuhle ngombana kwenza bona bahlale babulungekile. Abantwana bathola ilwazi elibenza bona ukujamelana nepillo esikolweni. Isikolo kuyindawo yomphakathi ngombana ngaphandle komphakathi isikolo ngekhe sabo khona nehlelo lokufunda nokufundisa emphakathini angeze libe khona&lt;ref&gt;Smith, G.A. and Sobel, D., 2014. ''Place-and community-based education in schools''. Routledge.&lt;/ref&gt;.</text>
      <sha1>c4ual4f769x3kp1b561mzla7i2xdr7g</sha1>
    </revision>
    <revision>
      <id>3439</id>
      <parentid>3065</parentid>
      <timestamp>2025-07-15T11:45:35Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3439</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="803" sha1="kxo3qui3zec3399sdesii7fako3wzxc" xml:space="preserve">[[Isimumathi:Isikolo.jpg|thumb|Isikolo]]
'''Isikolo''' kuyindawo lapho kuhlangana abantwana abanengi bendawo bazokufunda&lt;ref&gt;SCHOOL | English meaning - Cambridge Dictionary&lt;/ref&gt;. Isikolo yindawo ekulu ematlasi amanengi lapho kufundela khona abantwana ngokwesigaba abakiso ngefundo.Esikolweni kunama ofisi wabo titjhere nelaka hlokokulu. Esikolweni kuyindawo lapho abantwana baceda khona iskhathi sabo esinengi ngelanga, lokhu kuhle ngombana kwenza bona bahlale babulungekile. Abantwana bathola ilwazi elibenza bona ukujamelana nepillo esikolweni. Isikolo kuyindawo yomphakathi ngombana ngaphandle komphakathi isikolo ngekhe sabo khona nehlelo lokufunda nokufundisa emphakathini angeze libe khona&lt;ref&gt;Smith, G.A. and Sobel, D., 2014. ''Place-and community-based education in schools''. Routledge.&lt;/ref&gt;.</text>
      <sha1>kxo3qui3zec3399sdesii7fako3wzxc</sha1>
    </revision>
    <revision>
      <id>5207</id>
      <parentid>3439</parentid>
      <timestamp>2025-08-16T11:12:58Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5207</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="819" sha1="knjw0k0awuzvwq5uh8f0ps0wiiruoik" xml:space="preserve">[[Isimumathi:Isikolo.jpg|thumb|Isikolo]]
'''Isikolo''' kuyindawo lapho kuhlangana abantwana abanengi bendawo bazokufunda&lt;ref&gt;SCHOOL | English meaning - Cambridge Dictionary&lt;/ref&gt;. Isikolo yindawo ekulu ematlasi amanengi lapho kufundela khona abantwana ngokwesigaba abakiso ngefundo.Esikolweni kunama ofisi wabo titjhere nelaka hlokokulu. Esikolweni kuyindawo lapho abantwana baceda khona iskhathi sabo esinengi ngelanga, lokhu kuhle ngombana kwenza bona bahlale babulungekile. Abantwana bathola ilwazi elibenza bona ukujamelana nepillo esikolweni. Isikolo kuyindawo yomphakathi ngombana ngaphandle komphakathi isikolo ngekhe sabo khona nehlelo lokufunda nokufundisa emphakathini angeze libe khona&lt;ref&gt;Smith, G.A. and Sobel, D., 2014. ''Place-and community-based education in schools''. Routledge.&lt;/ref&gt;.

== Iinkomba ==</text>
      <sha1>knjw0k0awuzvwq5uh8f0ps0wiiruoik</sha1>
    </revision>
    <revision>
      <id>5208</id>
      <parentid>5207</parentid>
      <timestamp>2025-08-16T11:14:18Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5208</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="885" sha1="269pjqelirj1uwi3tt0raq7gkeis1c0" xml:space="preserve">[[Isimumathi:Isikolo.jpg|thumb|Isikolo]]
'''Isikolo''' kuyindawo lapho kuhlangana abantwana abanengi bendawo bazokufunda&lt;ref&gt;SCHOOL | English meaning - Cambridge Dictionary&lt;/ref&gt;. Isikolo yindawo ekulu ematlasi amanengi lapho kufundela khona abantwana ngokwesigaba abakiso ngefundo.Esikolweni kunama ofisi wabo titjhere nelaka hlokokulu. Esikolweni kuyindawo lapho abantwana baceda khona iskhathi sabo esinengi ngelanga, lokhu kuhle ngombana kwenza bona bahlale babulungekile. Abantwana bathola ilwazi elibenza bona ukujamelana nepillo esikolweni. Isikolo kuyindawo yomphakathi ngombana ngaphandle komphakathi isikolo ngekhe sabo khona nehlelo lokufunda nokufundisa emphakathini angeze libe khona&lt;ref&gt;Smith, G.A. and Sobel, D., 2014. ''Place-and community-based education in schools''. Routledge.&lt;/ref&gt;.

== Iinkomba ==
[[Category:Isikolo]]
[[Category:Ifundo]]
[[Category:Abotitjhere]]</text>
      <sha1>269pjqelirj1uwi3tt0raq7gkeis1c0</sha1>
    </revision>
    <revision>
      <id>5209</id>
      <parentid>5208</parentid>
      <timestamp>2025-08-16T11:15:31Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5209</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="915" sha1="7j048o4qzwictlekynzsri9jqbgt986" xml:space="preserve">[[Isimumathi:Isikolo.jpg|thumb|Isikolo]]
'''Isikolo''' kuyindawo lapho kuhlangana abantwana abanengi bendawo bazokufunda begodu bafundiswa botitjhere&lt;ref&gt;SCHOOL | English meaning - Cambridge Dictionary&lt;/ref&gt;. Isikolo yindawo ekulu ematlasi amanengi lapho kufundela khona abantwana ngokwesigaba abakiso ngefundo.Esikolweni kunama ofisi wabo titjhere nelaka hlokokulu. Esikolweni kuyindawo lapho abantwana baceda khona iskhathi sabo esinengi ngelanga, lokhu kuhle ngombana kwenza bona bahlale babulungekile. Abantwana bathola ilwazi elibenza bona ukujamelana nepillo esikolweni. Isikolo kuyindawo yomphakathi ngombana ngaphandle komphakathi isikolo ngekhe sabo khona nehlelo lokufunda nokufundisa emphakathini angeze libe khona&lt;ref&gt;Smith, G.A. and Sobel, D., 2014. ''Place-and community-based education in schools''. Routledge.&lt;/ref&gt;. 

== Iinkomba ==
[[Category:Isikolo]]
[[Category:Ifundo]]
[[Category:Abotitjhere]]</text>
      <sha1>7j048o4qzwictlekynzsri9jqbgt986</sha1>
    </revision>
  </page>
  <page>
    <title>Umlando wombuso wegandelelo eSewula Afrika</title>
    <ns>0</ns>
    <id>556</id>
    <revision>
      <id>2663</id>
      <timestamp>2025-04-15T16:50:28Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Umlando wombuso wegandelelo enarheni yeSewula Afrika == '''Umbuso''' wegandelelo eSewula Afrika wathoma ngonyaka we-1948 ukuya enyakeni we-1994. Umbuso lo bewenza bona kube nokuhlukana phakathi kwabantu ngesibanga sombalal wabo. Umbuso lo wathoma yihlangano ebeyidoswa phambili ngu-Daniel Francois Malan ekunguye oweza nomthetho wokugandelela abantu abanzima.  == Imithetho eyabekwako == Ukuzitlolisa ngokuya kombala   Kwabekwa umthetho wokuthi woke umuntu kufanele ayozit...&quot;</comment>
      <origin>2663</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3420" sha1="676cc5f5hc3i4s8vf1d5q6adi5nmxk8" xml:space="preserve">== Umlando wombuso wegandelelo enarheni yeSewula Afrika ==
'''Umbuso''' wegandelelo eSewula Afrika wathoma ngonyaka we-1948 ukuya enyakeni we-1994. Umbuso lo bewenza bona kube nokuhlukana phakathi kwabantu ngesibanga sombalal wabo. Umbuso lo wathoma yihlangano ebeyidoswa phambili ngu-Daniel Francois Malan ekunguye oweza nomthetho wokugandelela abantu abanzima.

== Imithetho eyabekwako ==
Ukuzitlolisa ngokuya kombala 

Kwabekwa umthetho wokuthi woke umuntu kufanele ayozitlosa ngokuya kombala wakhe lokhu bekwenzelwa ukuthi kwaziwe ukuthi umuntu uzokupohatha njani ngouya kombala wakhe&lt;ref name=&quot;:0&quot;&gt;Mhlauli, M.B., Salani, E. and Mokotedi, R., 2015. Understanding apartheid in South Africa through the racial contract. ''International Journal of Asian Social Science'', ''5''(4), pp.203-219.&lt;/ref&gt;.

Ukuhlukanisa abantu ngeenqhema

Kwahlukaniswa abantu ngendlela ebabehlala ngayo, abantu abamhlophe bebahlalaendaweni ezihle eziphezulu bese kuthi abantu abanzima banikelwe indawo lezo ezingakathuthuki. Abantu abanzima bebangaka vunyelwa bona ukuya amabhitjhi,emaphageni nakwenzinye indawo zokuledlha. Lokha nagade umuntu atholakala endaweni yabantu abamhlophe begade amapholisa ambopha&lt;ref name=&quot;:0&quot; /&gt;.

Ukwala imitjhado yabantu abahlukileko ngombalaAbantu abanzima bebangaka vunyelwa bona bangathandana nofana batjhadane nabantu  abamhlophe. Abantu bakufanele bona bathandane ngokombala ofanako&lt;ref&gt;Dalmage, H.M., 2018. Mixed race families in South Africa: Naming and claiming a location. ''Journal of Intercultural Studies'', ''39''(4), pp.399-413.&lt;/ref&gt;.

Umthetho umthetho wokuphatha umazisi

Abantu abanzima bekufanele bahlale baphethe umazisi koke lapho bakhamba khona ukwenzela bona bagabotjhwa. Nanyana bebekhamba baphethe umazisi kodwana bebangangeni nanoma kukuphi&lt;ref&gt;Du Bruyn, D., 2024. Memories and testimonies of passbooks, permits and platkeps in apartheid-era Batho, Mangaung.&lt;/ref&gt;.

Ifundo yabantu abanzima

Abantu abanzima bebathola ifundo ephasi kuneyabantu abamhlophe ngokwezinga lokho bekwenziwa ngilezi inzathu

Ukufunda umsebenzi ovamileko

Abafundi abanzima ngalesi iskhathi bebafunda ikharikhulamu enciphisiweko eyenza bona bona benze imisebenzi evamileko njengokuthuga, ukutjala esivandeni nokhunye. Lokhu bekwenziwa mthetho obizwa bona yi bantu act yango 1953, ekungiyo ebeyehlisa izinga lefundo yabantu abanzima ukubagandelela bona bahlale baphasi kwabamhlophe&lt;ref&gt;Wills, I.R., 2011. ''The history of Bantu education: 1948-1994'' (Doctoral dissertation, Australian Catholic University).&lt;/ref&gt;.

Inkolo ezingabhadelelwa ngurhulumende

Inkolo lapho kufunda khona abantu abanzima beziphasi ngokwezinga lokufundisa ngombana abotitjhere bakhona kade bangakabandulwa bonyana bazokufundisa. Inkolo bezitloga iinsetjenziswa neensiza zokufundisa&lt;ref&gt;Ndimande, B.S., 2013. From Bantu education to the fight for socially just education. ''Equity &amp; Excellence in Education'', ''46''(1), pp.20-35.&lt;/ref&gt;.

Ukuphela kombuso wegandelelo

Ihlangano ye african national congress eyabe idoswa phambili ngubaba u-Nelson Mandela yadlala indima ekulu ekulwisana nebandlululo. Ihlangano yasungula isiqhema esingana nturhu Umkhonto wesizwe ukulwisana negandelelo&lt;ref&gt;Clark, N.L. and Worger, W.H., 2016. ''South Africa: The rise and fall of apartheid''. Routledge.&lt;/ref&gt;. Kwathi ngonyaka we-1994 abantu amekhathweni bakhetha uNelson Mandela bona abe ngu Mongameli wesitjhaba. Kukulapho kwathoma khona ikululeko.</text>
      <sha1>676cc5f5hc3i4s8vf1d5q6adi5nmxk8</sha1>
    </revision>
  </page>
  <page>
    <title>Ukutlola isihlahlubo</title>
    <ns>0</ns>
    <id>557</id>
    <revision>
      <id>2664</id>
      <timestamp>2025-04-15T16:57:13Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Isihlahlubo == '''Isihlahlubo''' kuyinto oyitlolako ukuze kughona ukuvelwa ilwazi onalo ngezinto obuzwa zona&lt;ref&gt;TEST | English meaning - Cambridge Dictionary&lt;/ref&gt;.  == Inzathu ezenza bona abantu batlole iinhlahlubo == Abantu batlola iinhlahlubo ukuze abotitjhere bakghone ukubona ukuthi abanfundi babo Khuyini ebayizwisisako kilokho abakufundako begodu Khuyini abanobudisi bokuyizwisisa.  Isihlahlubo sikghona ukunikela umuntu osenzako impendulo zokuthi Khuyini umuntu a...&quot;</comment>
      <origin>2664</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1818" sha1="dzvqvlpaf2youz08e88ezizp2pniydu" xml:space="preserve">== Isihlahlubo ==
'''Isihlahlubo''' kuyinto oyitlolako ukuze kughona ukuvelwa ilwazi onalo ngezinto obuzwa zona&lt;ref&gt;TEST | English meaning - Cambridge Dictionary&lt;/ref&gt;.

== Inzathu ezenza bona abantu batlole iinhlahlubo ==
Abantu batlola iinhlahlubo ukuze abotitjhere bakghone ukubona ukuthi abanfundi babo Khuyini ebayizwisisako kilokho abakufundako begodu Khuyini abanobudisi bokuyizwisisa.

Isihlahlubo sikghona ukunikela umuntu osenzako impendulo zokuthi Khuyini umuntu ayikghona khulu begodu Khuyini umuntu abuthaka ngakiyo. Sikghona ukuveza indawo ezidinga ukuthuthukiswa&lt;ref&gt;Knoch, U., 2011. Rating scales for diagnostic assessment of writing: What should they look like and where should the criteria come from?. ''Assessing Writing'', ''16''(2), pp.81-96.&lt;/ref&gt;&lt;ref&gt;Al-Shammari, Z., 2011. Assessment of student learning outcomes: Indicators of strengths and weaknesses. In ''ICERI2011 Proceedings'' (pp. 4228-4230). IATED.&lt;/ref&gt;.

Isihlahlubo esikhathi esinengi sifuna bona abafundi bakghone ukucabanga ngobukhali begodu basenzise ilwazi labo ukurarulula imiraro. Lokhu kurhelebha umunti bona akghone ukukhula emkhumbulweni&lt;ref&gt;Gelerstein, D., Del Rio, R., Nussbaum, M., Chiuminatto, P. and López, X., 2016. Designing and implementing a test for measuring critical thinking in primary school. ''Thinking Skills and Creativity'', ''20'', pp.40-49.&lt;/ref&gt;. Isihlahlubo sirhelebha umfundi bona akghone ukuziphendulela ngofundo yakhe ngombana isihlahlubo sizomenza akhuthalele ukufunda nokuthi ahlale athola imiphumela ephezulu.

== Isiphetho ==
Isihlahlubo abanye siqakathekile emuntwini ofunako ngombana umuntu loyo ukgona ukubona ukuthi unelwazi elingangani entweni ayifundako begodu akghone nokuthi akhuphule izinga lakhe lokufunda ezintweni angazaziko. Isihlahlubo siveza bona umuntu sele abufunde kangangani.</text>
      <sha1>dzvqvlpaf2youz08e88ezizp2pniydu</sha1>
    </revision>
  </page>
  <page>
    <title>Isimunyisi</title>
    <ns>0</ns>
    <id>558</id>
    <revision>
      <id>2665</id>
      <timestamp>2025-04-15T17:07:12Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Isimunyisi == Iimunyisi kusiqhema seenlwana esinegazi elitjhisako. Iinlwana lezi zihlala endaweni zazo zemvelo ezahlukahlukeneko ngombana nazo zihlukile ngokwakheka&lt;ref&gt;MAMMAL | English meaning - Cambridge Dictionary&lt;/ref&gt;.  == Sibinakala njani isimunyisi? ==  === Uboya === Zoke iimunyisi zinoboya nofana iinhluthu emzibeni wazo. Uboya lobu benza bona inlwana lezi zivikele ezintweni ezingazilimaza. Begodu zikghona nokuthi zingangenwa makhaza. Igazi lesimunyisi lihlala...&quot;</comment>
      <origin>2665</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3202" sha1="8qk312ea86dimno5b2t16q5x0kjk6h3" xml:space="preserve">== Isimunyisi ==
Iimunyisi kusiqhema seenlwana esinegazi elitjhisako. Iinlwana lezi zihlala endaweni zazo zemvelo ezahlukahlukeneko ngombana nazo zihlukile ngokwakheka&lt;ref&gt;MAMMAL | English meaning - Cambridge Dictionary&lt;/ref&gt;.

== Sibinakala njani isimunyisi? ==

=== Uboya ===
Zoke iimunyisi zinoboya nofana iinhluthu emzibeni wazo. Uboya lobu benza bona inlwana lezi zivikele ezintweni ezingazilimaza. Begodu zikghona nokuthi zingangenwa makhaza. Igazi lesimunyisi lihlala litjhisa nanyana isimo sezulu singaba njani&lt;ref&gt;Sokolov, V.E., 2023. ''Mammal skin''. Univ of California Press.&lt;/ref&gt;.

=== Ibisi ===
Umunyisi zoke zikghone ukwenza ibisi emzimbeni wazo lokha nazizithweleko&lt;ref&gt;Skibiel, A.L., Downing, L.M., Orr, T.J. and Hood, W.R., 2013. The evolution of the nutrient composition of mammalian milks. ''Journal of Animal Ecology'', pp.1254-1264.&lt;/ref&gt;. Lokhu zikwenzela ukuthi ngesikhathi isimunyisi siceda ukuba nomtwana sikghone ukumunyisa umntwana waso ibisi. Umtwana waso uthoma ukukhula akhuliswa yibisi bese agcine adla Ukudla lokhu akudliwa ngunina nasele akhulileko. 

=== Amathambo amathathu phakathi endlebeni ===
Isimunyisi sinamthambo amathathu endlebeni ephakathi&lt;ref&gt;Fleischer, G., 2013. ''Evolutionary principles of the mammalian middle ear'' (Vol. 55). Springer Science &amp; Business Media.&lt;/ref&gt;.

=== Ukubeletha ===
Isimunyisi asibekeli abamaqanda ukuthi sikghone ukuba nabantwana. Isimunyisi siyamthwala Umntwana waso emzimbeni waso bese nakufika iskhathi siyamubeletha. Iinkhathi zokuthwala abantwana zeemunyisi azifani  esibonelo iindlovu ithwala Umntwana waso imiyaka emibili, umuntu uthwala umntwana iinyanga ezilithoba.

== Ukuqakatheka kwesimunyisi ==
Umthombo wokudla

Iimunyisi zidlala indima eqakathekileko ephasini ngombana ziimthombo wokudla ebantwini, isibonelo iinkomo zikhipha ibisi elidliwa babantu. Iinyama yeemunyisi ezinye iyadliwa, begodu nesikhumba sazo abantu bakghone ukuwenza izambatho ngazo.

Ukuphila nabantu

IImunyisi ziyakghona ukuthi zibe yifuyo sithandwa yabantu, ezinye ziyakghona ukuthi abantu bazi sebenzise njenge nthuthi zabe zibase lapho bafuna ukuya khona. Isibonelo: inja  nomqasa ziyakghona ukuba yifuyo sithandwa, ipera iyasebenza njenge njengesithuthi.

Irhubhululo yeemithi
Isimunyisi siyasetjenziswa lokha abasosayensi naba rhubhulula ngemithi engasetjenziswa ukuthi ilaphe abantu amagulo abangaba nawo.

Ukudzimelelisa irherho lepilo yeenlwano

Iimunyisi ezinye ziyadla inyama ekutjho bona ziphila ngokuthi zizingele ezinye inlwana. Ezinye zakhona ziphila ngokudla utjani. Ezinye zilahla imbewu. Iinlwana lezi ngokwenza njalo zinza bona kube nokudzimelela kwerherho yepilo yeenlwana&lt;ref&gt;Lacher Jr, T.E., Davidson, A.D., Fleming, T.H., Gómez-Ruiz, E.P., McCracken, G.F., Owen-Smith, N., Peres, C.A. and Vander Wall, S.B., 2019. The functional roles of mammals in ecosystems. ''Journal of Mammalogy'', ''100''(3), pp.942-964.&lt;/ref&gt;.

== Isiphetho ==
isimunyisi siqakathekile ngombana senza abantu bona bakghone ukuphila. Abasosayensi bakghone ukwenza amarhubhululo wabo. Isimunyisi sibonakala ngokuthi sibe noboya mezimbeni, sithwale abantwana emzibeni begodu nalokha sele bavelile abantwana sibamunyise ibisi ukuze bakghone ukukhula.</text>
      <sha1>8qk312ea86dimno5b2t16q5x0kjk6h3</sha1>
    </revision>
    <revision>
      <id>3582</id>
      <parentid>2665</parentid>
      <timestamp>2025-08-06T16:45:15Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3582</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3032" sha1="jl0n0yklbr22jclb5pgv736j4ltl6w7" xml:space="preserve">== Isimunyisi ==
Iimunyisi kusiqhema seenlwana esinegazi elitjhisako. Iinlwana lezi zihlala endaweni zazo zemvelo ezahlukahlukeneko ngombana nazo zihlukile ngokwakheka&lt;ref&gt;MAMMAL | English meaning - Cambridge Dictionary&lt;/ref&gt;.

=== Sibinakala njani isimunyisi? ===
Zoke iimunyisi zinoboya nofana iinhluthu emzibeni wazo. Uboya lobu benza bona inlwana lezi zivikele ezintweni ezingazilimaza. Begodu zikghona nokuthi zingangenwa makhaza. Igazi lesimunyisi lihlala litjhisa nanyana isimo sezulu singaba njani&lt;ref&gt;Sokolov, V.E., 2023. ''Mammal skin''. Univ of California Press.&lt;/ref&gt;.Iimunyisi zoke zikghone ukwenza ibisi emzimbeni wazo lokha nazizithweleko&lt;ref&gt;Skibiel, A.L., Downing, L.M., Orr, T.J. and Hood, W.R., 2013. The evolution of the nutrient composition of mammalian milks. ''Journal of Animal Ecology'', pp.1254-1264.&lt;/ref&gt;. Lokhu zikwenzela ukuthi ngesikhathi isimunyisi siceda ukuba nomtwana sikghone ukumunyisa umntwana waso ibisi. Umtwana waso uthoma ukukhula akhuliswa yibisi bese agcine adla Ukudla lokhu akudliwa ngunina nasele akhulileko. Isimunyisi sinamthambo amathathu endlebeni ephakathi&lt;ref&gt;Fleischer, G., 2013. ''Evolutionary principles of the mammalian middle ear'' (Vol. 55). Springer Science &amp; Business Media.&lt;/ref&gt;.Isimunyisi asibekeli abamaqanda ukuthi sikghone ukuba nabantwana. Isimunyisi siyamthwala Umntwana waso emzimbeni waso bese nakufika iskhathi siyamubeletha. Iinkhathi zokuthwala abantwana zeemunyisi azifani  esibonelo iindlovu ithwala Umntwana waso imiyaka emibili, umuntu uthwala umntwana iinyanga ezilithoba.

=== Ukuqakatheka kwesimunyisi ===
Iimunyisi zidlala indima eqakathekileko ephasini ngombana ziimthombo wokudla ebantwini, isibonelo iinkomo zikhipha ibisi elidliwa babantu. Iinyama yeemunyisi ezinye iyadliwa, begodu nesikhumba sazo abantu bakghone ukuwenza izambatho ngazo. Ziphila nabantu iimunyisi ziyakghona ukuthi zibe yifuyo sithandwa yabantu, ezinye ziyakghona ukuthi abantu bazi sebenzise njenge nthuthi zabe zibase lapho bafuna ukuya khona. Isibonelo: inja  nomqasa ziyakghona ukuba yifuyo sithandwa, ipera iyasebenza njenge njengesithuthi.Isimunyisi siyasetjenziswa lokha abasosayensi naba rhubhulula ngemithi engasetjenziswa ukuthi ilaphe abantu amagulo abangaba nawo.Iimunyisi ezinye ziyadla inyama ekutjho bona ziphila ngokuthi zizingele ezinye inlwana. Ezinye zakhona ziphila ngokudla utjani. Ezinye zilahla imbewu. Iinlwana lezi ngokwenza njalo zinza bona kube nokudzimelela kwerherho yepilo yeenlwana&lt;ref&gt;Lacher Jr, T.E., Davidson, A.D., Fleming, T.H., Gómez-Ruiz, E.P., McCracken, G.F., Owen-Smith, N., Peres, C.A. and Vander Wall, S.B., 2019. The functional roles of mammals in ecosystems. ''Journal of Mammalogy'', ''100''(3), pp.942-964.&lt;/ref&gt;.isimunyisi siqakathekile ngombana senza abantu bona bakghone ukuphila. Abasosayensi bakghone ukwenza amarhubhululo wabo. Isimunyisi sibonakala ngokuthi sibe noboya mezimbeni, sithwale abantwana emzibeni begodu nalokha sele bavelile abantwana sibamunyise ibisi ukuze bakghone ukukhula.

== Iinkomba ==
&lt;references /&gt;</text>
      <sha1>jl0n0yklbr22jclb5pgv736j4ltl6w7</sha1>
    </revision>
    <revision>
      <id>3583</id>
      <parentid>3582</parentid>
      <timestamp>2025-08-06T16:46:33Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <comment>/* Isimunyisi */</comment>
      <origin>3583</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3038" sha1="rzrahayoyzlmssu14woi64hc8j7d27o" xml:space="preserve">== Isimunyisi ==
'''Iimunyisi''' kusiqhema seenlwana esinegazi elitjhisako. Iinlwana lezi zihlala endaweni zazo zemvelo ezahlukahlukeneko ngombana nazo zihlukile ngokwakheka&lt;ref&gt;MAMMAL | English meaning - Cambridge Dictionary&lt;/ref&gt;.

=== Sibinakala njani isimunyisi? ===
Zoke iimunyisi zinoboya nofana iinhluthu emzibeni wazo. Uboya lobu benza bona inlwana lezi zivikele ezintweni ezingazilimaza. Begodu zikghona nokuthi zingangenwa makhaza. Igazi lesimunyisi lihlala litjhisa nanyana isimo sezulu singaba njani&lt;ref&gt;Sokolov, V.E., 2023. ''Mammal skin''. Univ of California Press.&lt;/ref&gt;.Iimunyisi zoke zikghone ukwenza ibisi emzimbeni wazo lokha nazizithweleko&lt;ref&gt;Skibiel, A.L., Downing, L.M., Orr, T.J. and Hood, W.R., 2013. The evolution of the nutrient composition of mammalian milks. ''Journal of Animal Ecology'', pp.1254-1264.&lt;/ref&gt;. Lokhu zikwenzela ukuthi ngesikhathi isimunyisi siceda ukuba nomtwana sikghone ukumunyisa umntwana waso ibisi. Umtwana waso uthoma ukukhula akhuliswa yibisi bese agcine adla Ukudla lokhu akudliwa ngunina nasele akhulileko. Isimunyisi sinamthambo amathathu endlebeni ephakathi&lt;ref&gt;Fleischer, G., 2013. ''Evolutionary principles of the mammalian middle ear'' (Vol. 55). Springer Science &amp; Business Media.&lt;/ref&gt;.Isimunyisi asibekeli abamaqanda ukuthi sikghone ukuba nabantwana. Isimunyisi siyamthwala Umntwana waso emzimbeni waso bese nakufika iskhathi siyamubeletha. Iinkhathi zokuthwala abantwana zeemunyisi azifani  esibonelo iindlovu ithwala Umntwana waso imiyaka emibili, umuntu uthwala umntwana iinyanga ezilithoba.

=== Ukuqakatheka kwesimunyisi ===
Iimunyisi zidlala indima eqakathekileko ephasini ngombana ziimthombo wokudla ebantwini, isibonelo iinkomo zikhipha ibisi elidliwa babantu. Iinyama yeemunyisi ezinye iyadliwa, begodu nesikhumba sazo abantu bakghone ukuwenza izambatho ngazo. Ziphila nabantu iimunyisi ziyakghona ukuthi zibe yifuyo sithandwa yabantu, ezinye ziyakghona ukuthi abantu bazi sebenzise njenge nthuthi zabe zibase lapho bafuna ukuya khona. Isibonelo: inja  nomqasa ziyakghona ukuba yifuyo sithandwa, ipera iyasebenza njenge njengesithuthi.Isimunyisi siyasetjenziswa lokha abasosayensi naba rhubhulula ngemithi engasetjenziswa ukuthi ilaphe abantu amagulo abangaba nawo.Iimunyisi ezinye ziyadla inyama ekutjho bona ziphila ngokuthi zizingele ezinye inlwana. Ezinye zakhona ziphila ngokudla utjani. Ezinye zilahla imbewu. Iinlwana lezi ngokwenza njalo zinza bona kube nokudzimelela kwerherho yepilo yeenlwana&lt;ref&gt;Lacher Jr, T.E., Davidson, A.D., Fleming, T.H., Gómez-Ruiz, E.P., McCracken, G.F., Owen-Smith, N., Peres, C.A. and Vander Wall, S.B., 2019. The functional roles of mammals in ecosystems. ''Journal of Mammalogy'', ''100''(3), pp.942-964.&lt;/ref&gt;.isimunyisi siqakathekile ngombana senza abantu bona bakghone ukuphila. Abasosayensi bakghone ukwenza amarhubhululo wabo. Isimunyisi sibonakala ngokuthi sibe noboya mezimbeni, sithwale abantwana emzibeni begodu nalokha sele bavelile abantwana sibamunyise ibisi ukuze bakghone ukukhula.

== Iinkomba ==
&lt;references /&gt;</text>
      <sha1>rzrahayoyzlmssu14woi64hc8j7d27o</sha1>
    </revision>
    <revision>
      <id>3584</id>
      <parentid>3583</parentid>
      <timestamp>2025-08-06T16:53:13Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3584</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3422" sha1="r69cyz8itk2tcym22ftx7y0tntr8hlu" xml:space="preserve">'''Iimunyisi''' kusiqhema seenlwana esinegazi elitjhisako. Iinlwana lezi zihlala endaweni zazo zemvelo ezahlukahlukeneko ngombana nazo zihlukile ngokwakheka&lt;ref&gt;MAMMAL | English meaning - Cambridge Dictionary&lt;/ref&gt;. Iimunyisi kuzimbandana ezibahlakaniphileko ngombana zikghona ukuhlla eendaweni ezihlukahlukeneko ezifana nelwandle, entabeni,nalapho kumakhaza khona khulu, zikghona ukuhlala ngeenqhema nangokuphilisana. Ezinye zazo ziyazingelwa ukuze zithole ukudla begodu ezinye ngokuhlukileko zid;a utjani. Iimunyisi ziyasetjenziswa ukwenza ukudla, izambatho nokhunye abantu abakusebenzisa mihla namalanga ukuphila.

=== Sibinakala njani isimunyisi? ===
Zoke iimunyisi zinoboya nofana iinhluthu emzibeni wazo. Uboya lobu benza bona inlwana lezi zivikele ezintweni ezingazilimaza. Begodu zikghona nokuthi zingangenwa makhaza. Igazi lesimunyisi lihlala litjhisa nanyana isimo sezulu singaba njani&lt;ref&gt;Sokolov, V.E., 2023. ''Mammal skin''. Univ of California Press.&lt;/ref&gt;.Iimunyisi zoke zikghone ukwenza ibisi emzimbeni wazo lokha nazizithweleko&lt;ref&gt;Skibiel, A.L., Downing, L.M., Orr, T.J. and Hood, W.R., 2013. The evolution of the nutrient composition of mammalian milks. ''Journal of Animal Ecology'', pp.1254-1264.&lt;/ref&gt;. Lokhu zikwenzela ukuthi ngesikhathi isimunyisi siceda ukuba nomtwana sikghone ukumunyisa umntwana waso ibisi. Umtwana waso uthoma ukukhula akhuliswa yibisi bese agcine adla Ukudla lokhu akudliwa ngunina nasele akhulileko. Isimunyisi sinamthambo amathathu endlebeni ephakathi&lt;ref&gt;Fleischer, G., 2013. ''Evolutionary principles of the mammalian middle ear'' (Vol. 55). Springer Science &amp; Business Media.&lt;/ref&gt;.Isimunyisi asibekeli abamaqanda ukuthi sikghone ukuba nabantwana. Isimunyisi siyamthwala Umntwana waso emzimbeni waso bese nakufika iskhathi siyamubeletha. Iinkhathi zokuthwala abantwana zeemunyisi azifani  esibonelo iindlovu ithwala Umntwana waso imiyaka emibili, umuntu uthwala umntwana iinyanga ezilithoba.

=== Ukuqakatheka kwesimunyisi ===
Iimunyisi zidlala indima eqakathekileko ephasini ngombana ziimthombo wokudla ebantwini, isibonelo iinkomo zikhipha ibisi elidliwa babantu. Iinyama yeemunyisi ezinye iyadliwa, begodu nesikhumba sazo abantu bakghone ukuwenza izambatho ngazo. Ziphila nabantu iimunyisi ziyakghona ukuthi zibe yifuyo sithandwa yabantu, ezinye ziyakghona ukuthi abantu bazi sebenzise njenge nthuthi zabe zibase lapho bafuna ukuya khona. Isibonelo: inja  nomqasa ziyakghona ukuba yifuyo sithandwa, ipera iyasebenza njenge njengesithuthi.Isimunyisi siyasetjenziswa lokha abasosayensi naba rhubhulula ngemithi engasetjenziswa ukuthi ilaphe abantu amagulo abangaba nawo.Iimunyisi ezinye ziyadla inyama ekutjho bona ziphila ngokuthi zizingele ezinye inlwana. Ezinye zakhona ziphila ngokudla utjani. Ezinye zilahla imbewu. Iinlwana lezi ngokwenza njalo zinza bona kube nokudzimelela kwerherho yepilo yeenlwana&lt;ref&gt;Lacher Jr, T.E., Davidson, A.D., Fleming, T.H., Gómez-Ruiz, E.P., McCracken, G.F., Owen-Smith, N., Peres, C.A. and Vander Wall, S.B., 2019. The functional roles of mammals in ecosystems. ''Journal of Mammalogy'', ''100''(3), pp.942-964.&lt;/ref&gt;.isimunyisi siqakathekile ngombana senza abantu bona bakghone ukuphila. Abasosayensi bakghone ukwenza amarhubhululo wabo. Isimunyisi sibonakala ngokuthi sibe noboya mezimbeni, sithwale abantwana emzibeni begodu nalokha sele bavelile abantwana sibamunyise ibisi ukuze bakghone ukukhula.

== Iinkomba ==
&lt;references /&gt;</text>
      <sha1>r69cyz8itk2tcym22ftx7y0tntr8hlu</sha1>
    </revision>
    <revision>
      <id>3585</id>
      <parentid>3584</parentid>
      <timestamp>2025-08-06T16:55:08Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>3585</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3471" sha1="0q2bkguztq11794eubfdgvsbf2jdqpl" xml:space="preserve">'''Iimunyisi''' kusiqhema seenlwana esinegazi elitjhisako. Iinlwana lezi zihlala endaweni zazo zemvelo ezahlukahlukeneko ngombana nazo zihlukile ngokwakheka&lt;ref&gt;MAMMAL | English meaning - Cambridge Dictionary&lt;/ref&gt;. Iimunyisi kuzimbandana ezibahlakaniphileko ngombana zikghona ukuhlla eendaweni ezihlukahlukeneko ezifana nelwandle, entabeni,nalapho kumakhaza khona khulu, zikghona ukuhlala ngeenqhema nangokuphilisana. Ezinye zazo ziyazingelwa ukuze zithole ukudla begodu ezinye ngokuhlukileko zid;a utjani. Iimunyisi ziyasetjenziswa ukwenza ukudla, izambatho nokhunye abantu abakusebenzisa mihla namalanga ukuphila.

=== Sibinakala njani isimunyisi? ===
Zoke iimunyisi zinoboya nofana iinhluthu emzibeni wazo. Uboya lobu benza bona inlwana lezi zivikele ezintweni ezingazilimaza. Begodu zikghona nokuthi zingangenwa makhaza. Igazi lesimunyisi lihlala litjhisa nanyana isimo sezulu singaba njani&lt;ref&gt;Sokolov, V.E., 2023. ''Mammal skin''. Univ of California Press.&lt;/ref&gt;.Iimunyisi zoke zikghone ukwenza ibisi emzimbeni wazo lokha nazizithweleko&lt;ref&gt;Skibiel, A.L., Downing, L.M., Orr, T.J. and Hood, W.R., 2013. The evolution of the nutrient composition of mammalian milks. ''Journal of Animal Ecology'', pp.1254-1264.&lt;/ref&gt;. Lokhu zikwenzela ukuthi ngesikhathi isimunyisi siceda ukuba nomtwana sikghone ukumunyisa umntwana waso ibisi. Umtwana waso uthoma ukukhula akhuliswa yibisi bese agcine adla Ukudla lokhu akudliwa ngunina nasele akhulileko. Isimunyisi sinamthambo amathathu endlebeni ephakathi&lt;ref&gt;Fleischer, G., 2013. ''Evolutionary principles of the mammalian middle ear'' (Vol. 55). Springer Science &amp; Business Media.&lt;/ref&gt;.Isimunyisi asibekeli abamaqanda ukuthi sikghone ukuba nabantwana. Isimunyisi siyamthwala Umntwana waso emzimbeni waso bese nakufika iskhathi siyamubeletha. Iinkhathi zokuthwala abantwana zeemunyisi azifani  esibonelo iindlovu ithwala Umntwana waso imiyaka emibili, umuntu uthwala umntwana iinyanga ezilithoba.

=== Ukuqakatheka kwesimunyisi ===
Iimunyisi zidlala indima eqakathekileko ephasini ngombana ziimthombo wokudla ebantwini, isibonelo iinkomo zikhipha ibisi elidliwa babantu. Iinyama yeemunyisi ezinye iyadliwa, begodu nesikhumba sazo abantu bakghone ukuwenza izambatho ngazo. Ziphila nabantu iimunyisi ziyakghona ukuthi zibe yifuyo sithandwa yabantu, ezinye ziyakghona ukuthi abantu bazi sebenzise njenge nthuthi zabe zibase lapho bafuna ukuya khona. Isibonelo: inja  nomqasa ziyakghona ukuba yifuyo sithandwa, ipera iyasebenza njenge njengesithuthi.Isimunyisi siyasetjenziswa lokha abasosayensi naba rhubhulula ngemithi engasetjenziswa ukuthi ilaphe abantu amagulo abangaba nawo.Iimunyisi ezinye ziyadla inyama ekutjho bona ziphila ngokuthi zizingele ezinye inlwana. Ezinye zakhona ziphila ngokudla utjani. Ezinye zilahla imbewu. Iinlwana lezi ngokwenza njalo zinza bona kube nokudzimelela kwerherho yepilo yeenlwana&lt;ref&gt;Lacher Jr, T.E., Davidson, A.D., Fleming, T.H., Gómez-Ruiz, E.P., McCracken, G.F., Owen-Smith, N., Peres, C.A. and Vander Wall, S.B., 2019. The functional roles of mammals in ecosystems. ''Journal of Mammalogy'', ''100''(3), pp.942-964.&lt;/ref&gt;.isimunyisi siqakathekile ngombana senza abantu bona bakghone ukuphila. Abasosayensi bakghone ukwenza amarhubhululo wabo. Isimunyisi sibonakala ngokuthi sibe noboya mezimbeni, sithwale abantwana emzibeni begodu nalokha sele bavelile abantwana sibamunyise ibisi ukuze bakghone ukukhula.

== Iinkomba ==
&lt;references /&gt;
[[category: Iimunyisi]]
[[Category: Iimbandana]]</text>
      <sha1>0q2bkguztq11794eubfdgvsbf2jdqpl</sha1>
    </revision>
  </page>
  <page>
    <title>Iinyoni</title>
    <ns>0</ns>
    <id>559</id>
    <revision>
      <id>2666</id>
      <timestamp>2025-04-15T17:17:41Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Iinyoni == '''Iinyoni''' kuzinlwana ezinaphiko begodu zinesiba ezinengi emzimbeni wazo&lt;ref&gt;BIRD | English meaning - Cambridge Dictionary&lt;/ref&gt;. Iinsiba zenyoni zilula begodu ziqinile zikghona ukulekelela iinyoni bona zikghone ukuphapha emoyeni bezizivikele. Iinyoni ziimhlobo omnengi ohluka ngemibala,ngokubumbeka, nangobukhulu. Ukubumbeka kwazo kulawulwa kukuthi zizifihla kangangani,ziphaphela phezulu  kangangani nokhunye.  == Uyibona ngani inyoni? ==  === Umlomo wenyo...&quot;</comment>
      <origin>2666</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2778" sha1="7xlstyeq9jtdttp7nikn2qsf7ct22bf" xml:space="preserve">== Iinyoni ==
'''Iinyoni''' kuzinlwana ezinaphiko begodu zinesiba ezinengi emzimbeni wazo&lt;ref&gt;BIRD | English meaning - Cambridge Dictionary&lt;/ref&gt;. Iinsiba zenyoni zilula begodu ziqinile zikghona ukulekelela iinyoni bona zikghone ukuphapha emoyeni bezizivikele. Iinyoni ziimhlobo omnengi ohluka ngemibala,ngokubumbeka, nangobukhulu. Ukubumbeka kwazo kulawulwa kukuthi zizifihla kangangani,ziphaphela phezulu  kangangani nokhunye.

== Uyibona ngani inyoni? ==

=== Umlomo wenyoni ===
Umlomo wenyoni ubizwa bona yibhigi. Imilomo le iyahluka ngokuqina nangokubumbeka ihlukaniswa kukuthi inyoni idla ukudla okunjani, ibamba ini&lt;ref&gt;Bright, J.A., Marugán-Lobón, J., Cobb, S.N. and Rayfield, E.J., 2016. The shapes of bird beaks are highly controlled by nondietary factors. ''Proceedings of the National Academy of Sciences'', ''113''(19), pp.5352-5357.&lt;/ref&gt;. Ezinye iinyoni zinomlomo oqinileko ohagako ngombana zikghona ukudabula inyama. Ezinye zinomlomo owondileko okghona ukungena ehlabathini nokuthi udle emathuthumbeni. Iinyoni ziyakghona ukusebenzisa umilomo yazo ukwakha iindleke ekuzizindlu zazo. Umlomo wenyoni wenziwe nge phrotheyini ebizwa ngokuthi yi-Keratin&lt;ref&gt;Shah, A., Tyagi, S., Bharagava, R.N., Belhaj, D., Kumar, A., Saxena, G., Saratale, G.D. and Mulla, S.I., 2019. Keratin production and its applications: current and future perspective. ''Keratin as a protein biopolymer: Extraction from waste biomass and applications'', pp.19-34.&lt;/ref&gt;. 

=== Amaphiko wenyoni ===
Inyoni yaziwa ngamaphiko wayo. Amaphiko enziwe ngamathambo imisipha, nangasiba ethileko asebenzisanako ukuze amaphiko akghone ukusebenza&lt;ref&gt;Kaiser, G.W., 2010. ''The inner bird: anatomy and evolution''. UBC Press.&lt;/ref&gt;. Amaphiko akghona ukuthi alekelele inyoni ukuthi ikghone ukuphapha, akhambe emoyeni iskhathi eside. Ezinye iinyoni zikghona ukuphapha ibanga elide unyaka nonyaka zifuna Ukudla nokubalekela isimo sezulu esimbi. Akusizo zoke iinyoni ezikghona ukuphapha ngamaphiko wazo, isibonelo ikukhu nenqiliba azikghoni ukuphapha emoyeni.

=== Ukubekela amaqanda ===
Iinyoni ukuthi zikghone ukwanda zibekela amaqanda beze ziwafukamele bese nakufika isikhathi amaqanda aqhume kuvele amadzinyani wakhona. Inyoni lokha nayingathi isabekela ithole bona [[iqanda]] layo libanjwe mumuntu iyawanghala bese ingasawafukamela&lt;ref&gt;Stadelman, W.J., 2017. Egg-production practices. In ''Egg science and technology'' (pp. 9-37). CRC Press.&lt;/ref&gt;.

Isibonel seenyoni: likhozi, idlanga, ikukhu

Isiphetho

Iinyoni zilwana ezinaphiko emzibeni namisiba amanengi angasibudisi. Zibekela amaqanda ukuba nabantwana. Zinomlomo obizwa ngebhigi obukhali ngombana zisebenzisa wona Ukudla, ukuzingela nokwakha iindleke zawo. Iiinyoni ezinengi zisebenzisa amaphiko wazo  ukuphapha kodwana ezinye azikghoni ukuphapha.</text>
      <sha1>7xlstyeq9jtdttp7nikn2qsf7ct22bf</sha1>
    </revision>
    <revision>
      <id>3537</id>
      <parentid>2666</parentid>
      <timestamp>2025-08-04T17:41:28Z</timestamp>
      <contributor>
        <ip>105.245.115.236</ip>
      </contributor>
      <origin>3537</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2777" sha1="sc9r4qj62e83zn87d3qnf2fagfmtmos" xml:space="preserve">'''Iinyoni''' kuzinlwana ezinaphiko begodu zinesiba ezinengi emzimbeni wazo&lt;ref&gt;BIRD | English meaning - Cambridge Dictionary&lt;/ref&gt;. Iinsiba zenyoni zilula begodu ziqinile zikghona ukulekelela iinyoni bona zikghone ukuphapha emoyeni bezizivikele. Iinyoni ziimhlobo omnengi ohluka ngemibala,ngokubumbeka, nangobukhulu. Ukubumbeka kwazo kulawulwa kukuthi zizifihla kangangani,ziphaphela phezulu  kangangani nokhunye.

=== Uyibona ngani inyoni? ===

==== Umlomo wenyoni ====
Umlomo wenyoni ubizwa bona yibhigi. Imilomo le iyahluka ngokuqina nangokubumbeka ihlukaniswa kukuthi inyoni idla ukudla okunjani, ibamba ini&lt;ref&gt;Bright, J.A., Marugán-Lobón, J., Cobb, S.N. and Rayfield, E.J., 2016. The shapes of bird beaks are highly controlled by nondietary factors. ''Proceedings of the National Academy of Sciences'', ''113''(19), pp.5352-5357.&lt;/ref&gt;. Ezinye iinyoni zinomlomo oqinileko ohagako ngombana zikghona ukudabula inyama. Ezinye zinomlomo owondileko okghona ukungena ehlabathini nokuthi udle emathuthumbeni. Iinyoni ziyakghona ukusebenzisa umilomo yazo ukwakha iindleke ekuzizindlu zazo. Umlomo wenyoni wenziwe nge phrotheyini ebizwa ngokuthi yi-Keratin&lt;ref&gt;Shah, A., Tyagi, S., Bharagava, R.N., Belhaj, D., Kumar, A., Saxena, G., Saratale, G.D. and Mulla, S.I., 2019. Keratin production and its applications: current and future perspective. ''Keratin as a protein biopolymer: Extraction from waste biomass and applications'', pp.19-34.&lt;/ref&gt;. 

==== Amaphiko wenyoni ====
Inyoni yaziwa ngamaphiko wayo. Amaphiko enziwe ngamathambo imisipha, nangasiba ethileko asebenzisanako ukuze amaphiko akghone ukusebenza&lt;ref&gt;Kaiser, G.W., 2010. ''The inner bird: anatomy and evolution''. UBC Press.&lt;/ref&gt;. Amaphiko akghona ukuthi alekelele inyoni ukuthi ikghone ukuphapha, akhambe emoyeni iskhathi eside. Ezinye iinyoni zikghona ukuphapha ibanga elide unyaka nonyaka zifuna Ukudla nokubalekela isimo sezulu esimbi. Akusizo zoke iinyoni ezikghona ukuphapha ngamaphiko wazo, isibonelo ikukhu nenqiliba azikghoni ukuphapha emoyeni.

==== Ukubekela amaqanda ====
Iinyoni ukuthi zikghone ukwanda zibekela amaqanda beze ziwafukamele bese nakufika isikhathi amaqanda aqhume kuvele amadzinyani wakhona. Inyoni lokha nayingathi isabekela ithole bona [[iqanda]] layo libanjwe mumuntu iyawanghala bese ingasawafukamela&lt;ref&gt;Stadelman, W.J., 2017. Egg-production practices. In ''Egg science and technology'' (pp. 9-37). CRC Press.&lt;/ref&gt;

Isibonelo seenyoni: likhozi, idlanga, ikukhu. Iinyoni zilwana ezinaphiko emzibeni namisiba amanengi angasibudisi. Zibekela amaqanda ukuba nabantwana. Zinomlomo obizwa ngebhigi obukhali ngombana zisebenzisa wona Ukudla, ukuzingela nokwakha iindleke zawo. Iiinyoni ezinengi zisebenzisa amaphiko wazo  ukuphapha kodwana ezinye azikghoni ukuphapha.

== Iinkomba ==</text>
      <sha1>sc9r4qj62e83zn87d3qnf2fagfmtmos</sha1>
    </revision>
    <revision>
      <id>5063</id>
      <parentid>3537</parentid>
      <timestamp>2025-08-07T18:22:13Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5063</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3084" sha1="h5uf6yh1rwl6b4dzxf6t7ermlob39mk" xml:space="preserve">[[Isimumathi:Female house sparrow at Kodai.jpg|thumb|Iinyoni]]
'''Iinyoni''' kuzinlwana ezinaphiko begodu zinesiba ezinengi emzimbeni wazo&lt;ref&gt;BIRD | English meaning - Cambridge Dictionary&lt;/ref&gt;. Iinsiba zenyoni zilula begodu ziqinile zikghona ukulekelela iinyoni bona zikghone ukuphapha emoyeni bezizivikele. Iinyoni ziimhlobo omnengi ohluka ngemibala,ngokubumbeka, nangobukhulu. Ukubumbeka kwazo kulawulwa kukuthi zizifihla kangangani,ziphaphela phezulu  kangangani nokhunye.

=== Uyibona ngani inyoni? ===

==== Umlomo wenyoni ====
Umlomo wenyoni ubizwa bona yibhigi. Imilomo le iyahluka ngokuqina nangokubumbeka ihlukaniswa kukuthi inyoni idla ukudla okunjani, ibamba ini&lt;ref&gt;Bright, J.A., Marugán-Lobón, J., Cobb, S.N. and Rayfield, E.J., 2016. The shapes of bird beaks are highly controlled by nondietary factors. ''Proceedings of the National Academy of Sciences'', ''113''(19), pp.5352-5357.&lt;/ref&gt;. Ezinye iinyoni zinomlomo oqinileko ohagako ngombana zikghona ukudabula inyama. Ezinye zinomlomo owondileko okghona ukungena ehlabathini nokuthi udle emathuthumbeni. Iinyoni ziyakghona ukusebenzisa umilomo yazo ukwakha iindleke ekuzizindlu zazo. Umlomo wenyoni wenziwe nge phrotheyini ebizwa ngokuthi yi-Keratin&lt;ref&gt;Shah, A., Tyagi, S., Bharagava, R.N., Belhaj, D., Kumar, A., Saxena, G., Saratale, G.D. and Mulla, S.I., 2019. Keratin production and its applications: current and future perspective. ''Keratin as a protein biopolymer: Extraction from waste biomass and applications'', pp.19-34.&lt;/ref&gt;. 

==== Amaphiko wenyoni ====
[[Isimumathi:Carpodacus erythrinus erythrinus MHNT.ZOO.2010.11 Vyborg.jpg|thumb|Amaqanada weenyoni]]
Inyoni yaziwa ngamaphiko wayo. Amaphiko enziwe ngamathambo imisipha, nangasiba ethileko asebenzisanako ukuze amaphiko akghone ukusebenza&lt;ref&gt;Kaiser, G.W., 2010. ''The inner bird: anatomy and evolution''. UBC Press.&lt;/ref&gt;. Amaphiko akghona ukuthi alekelele inyoni ukuthi ikghone ukuphapha, akhambe emoyeni iskhathi eside. Ezinye iinyoni zikghona ukuphapha ibanga elide unyaka nonyaka zifuna Ukudla nokubalekela isimo sezulu esimbi. Akusizo zoke iinyoni ezikghona ukuphapha ngamaphiko wazo, isibonelo ikukhu nenqiliba azikghoni ukuphapha emoyeni.

==== Ukubekela amaqanda ====
[[Isimumathi:Common ostrich (Struthio camelus australis) male running composite.jpg|thumb|inciliba mhlobo wenyoni engakwazi ukuphapha emmoyeni]]
Iinyoni ukuthi zikghone ukwanda zibekela amaqanda beze ziwafukamele bese nakufika isikhathi amaqanda aqhume kuvele amadzinyani wakhona. Inyoni lokha nayingathi isabekela ithole bona [[iqanda]] layo libanjwe mumuntu iyawanghala bese ingasawafukamela&lt;ref&gt;Stadelman, W.J., 2017. Egg-production practices. In ''Egg science and technology'' (pp. 9-37). CRC Press.&lt;/ref&gt;Isibonelo seenyoni: likhozi, idlanga, ikukhu. Iinyoni zilwana ezinaphiko emzibeni namisiba amanengi angasibudisi. Zibekela amaqanda ukuba nabantwana. Zinomlomo obizwa ngebhigi obukhali ngombana zisebenzisa wona Ukudla, ukuzingela nokwakha iindleke zawo. Iiinyoni ezinengi zisebenzisa amaphiko wazo  ukuphapha kodwana ezinye azikghoni ukuphapha.

== Iinkomba ==</text>
      <sha1>h5uf6yh1rwl6b4dzxf6t7ermlob39mk</sha1>
    </revision>
    <revision>
      <id>5064</id>
      <parentid>5063</parentid>
      <timestamp>2025-08-07T18:23:26Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>5064</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3127" sha1="bqw0eqt795585tj61s02aetskrnn4yk" xml:space="preserve">[[Isimumathi:Female house sparrow at Kodai.jpg|thumb|Iinyoni]]
'''Iinyoni''' kuzinlwana ezinaphiko begodu zinesiba ezinengi emzimbeni wazo&lt;ref&gt;BIRD | English meaning - Cambridge Dictionary&lt;/ref&gt;. Iinsiba zenyoni zilula begodu ziqinile zikghona ukulekelela iinyoni bona zikghone ukuphapha emoyeni bezizivikele. Iinyoni ziimhlobo omnengi ohluka ngemibala,ngokubumbeka, nangobukhulu. Ukubumbeka kwazo kulawulwa kukuthi zizifihla kangangani,ziphaphela phezulu  kangangani nokhunye.

=== Uyibona ngani inyoni? ===

==== Umlomo wenyoni ====
Umlomo wenyoni ubizwa bona yibhigi. Imilomo le iyahluka ngokuqina nangokubumbeka ihlukaniswa kukuthi inyoni idla ukudla okunjani, ibamba ini&lt;ref&gt;Bright, J.A., Marugán-Lobón, J., Cobb, S.N. and Rayfield, E.J., 2016. The shapes of bird beaks are highly controlled by nondietary factors. ''Proceedings of the National Academy of Sciences'', ''113''(19), pp.5352-5357.&lt;/ref&gt;. Ezinye iinyoni zinomlomo oqinileko ohagako ngombana zikghona ukudabula inyama. Ezinye zinomlomo owondileko okghona ukungena ehlabathini nokuthi udle emathuthumbeni. Iinyoni ziyakghona ukusebenzisa umilomo yazo ukwakha iindleke ekuzizindlu zazo. Umlomo wenyoni wenziwe nge phrotheyini ebizwa ngokuthi yi-Keratin&lt;ref&gt;Shah, A., Tyagi, S., Bharagava, R.N., Belhaj, D., Kumar, A., Saxena, G., Saratale, G.D. and Mulla, S.I., 2019. Keratin production and its applications: current and future perspective. ''Keratin as a protein biopolymer: Extraction from waste biomass and applications'', pp.19-34.&lt;/ref&gt;. 

==== Amaphiko wenyoni ====
[[Isimumathi:Carpodacus erythrinus erythrinus MHNT.ZOO.2010.11 Vyborg.jpg|thumb|Amaqanada weenyoni]]
Inyoni yaziwa ngamaphiko wayo. Amaphiko enziwe ngamathambo imisipha, nangasiba ethileko asebenzisanako ukuze amaphiko akghone ukusebenza&lt;ref&gt;Kaiser, G.W., 2010. ''The inner bird: anatomy and evolution''. UBC Press.&lt;/ref&gt;. Amaphiko akghona ukuthi alekelele inyoni ukuthi ikghone ukuphapha, akhambe emoyeni iskhathi eside. Ezinye iinyoni zikghona ukuphapha ibanga elide unyaka nonyaka zifuna Ukudla nokubalekela isimo sezulu esimbi. Akusizo zoke iinyoni ezikghona ukuphapha ngamaphiko wazo, isibonelo ikukhu nenqiliba azikghoni ukuphapha emoyeni.

==== Ukubekela amaqanda ====
[[Isimumathi:Common ostrich (Struthio camelus australis) male running composite.jpg|thumb|inciliba mhlobo wenyoni engakwazi ukuphapha emmoyeni]]
Iinyoni ukuthi zikghone ukwanda zibekela amaqanda beze ziwafukamele bese nakufika isikhathi amaqanda aqhume kuvele amadzinyani wakhona. Inyoni lokha nayingathi isabekela ithole bona [[iqanda]] layo libanjwe mumuntu iyawanghala bese ingasawafukamela&lt;ref&gt;Stadelman, W.J., 2017. Egg-production practices. In ''Egg science and technology'' (pp. 9-37). CRC Press.&lt;/ref&gt;Isibonelo seenyoni: likhozi, idlanga, ikukhu. Iinyoni zilwana ezinaphiko emzibeni namisiba amanengi angasibudisi. Zibekela amaqanda ukuba nabantwana. Zinomlomo obizwa ngebhigi obukhali ngombana zisebenzisa wona Ukudla, ukuzingela nokwakha iindleke zawo. Iiinyoni ezinengi zisebenzisa amaphiko wazo  ukuphapha kodwana ezinye azikghoni ukuphapha.

== Iinkomba ==
[[Category:Iinyoni]]
[[Category:Amaqanda]]</text>
      <sha1>bqw0eqt795585tj61s02aetskrnn4yk</sha1>
    </revision>
    <revision>
      <id>5126</id>
      <parentid>5064</parentid>
      <timestamp>2025-08-10T15:28:32Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5126</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3153" sha1="klu16x0dmjuhh1qe81kk6vxtynitfyz" xml:space="preserve">[[Isimumathi:Female house sparrow at Kodai.jpg|thumb|Iinyoni]]
'''Iinyoni''' kuzinlwana ezinamaphiko begodu zinensiba ezinengi emzimbeni wazo ukuvala isikhumba sazo&lt;ref&gt;BIRD | English meaning - Cambridge Dictionary&lt;/ref&gt;. Iinsiba zenyoni zilula begodu ziqinile zikghona ukulekelela iinyoni bona zikghone ukuphapha emoyeni bezizivikele. Iinyoni ziimhlobo omnengi ohluka ngemibala,ngokubumbeka, nangobukhulu. Ukubumbeka kwazo kulawulwa kukuthi zizifihla kangangani,ziphaphela phezulu  kangangani nokhunye.

=== Uyibona ngani inyoni? ===

==== Umlomo wenyoni ====
Umlomo wenyoni ubizwa bona yibhigi. Imilomo le iyahluka ngokuqina nangokubumbeka ihlukaniswa kukuthi inyoni idla ukudla okunjani, ibamba ini&lt;ref&gt;Bright, J.A., Marugán-Lobón, J., Cobb, S.N. and Rayfield, E.J., 2016. The shapes of bird beaks are highly controlled by nondietary factors. ''Proceedings of the National Academy of Sciences'', ''113''(19), pp.5352-5357.&lt;/ref&gt;. Ezinye iinyoni zinomlomo oqinileko ohagako ngombana zikghona ukudabula inyama. Ezinye zinomlomo owondileko okghona ukungena ehlabathini nokuthi udle emathuthumbeni. Iinyoni ziyakghona ukusebenzisa umilomo yazo ukwakha iindleke ekuzizindlu zazo. Umlomo wenyoni wenziwe nge phrotheyini ebizwa ngokuthi yi-Keratin&lt;ref&gt;Shah, A., Tyagi, S., Bharagava, R.N., Belhaj, D., Kumar, A., Saxena, G., Saratale, G.D. and Mulla, S.I., 2019. Keratin production and its applications: current and future perspective. ''Keratin as a protein biopolymer: Extraction from waste biomass and applications'', pp.19-34.&lt;/ref&gt;. 

==== Amaphiko wenyoni ====
[[Isimumathi:Carpodacus erythrinus erythrinus MHNT.ZOO.2010.11 Vyborg.jpg|thumb|Amaqanada weenyoni]]
Inyoni yaziwa ngamaphiko wayo. Amaphiko enziwe ngamathambo imisipha, nangasiba ethileko asebenzisanako ukuze amaphiko akghone ukusebenza&lt;ref&gt;Kaiser, G.W., 2010. ''The inner bird: anatomy and evolution''. UBC Press.&lt;/ref&gt;. Amaphiko akghona ukuthi alekelele inyoni ukuthi ikghone ukuphapha, akhambe emoyeni iskhathi eside. Ezinye iinyoni zikghona ukuphapha ibanga elide unyaka nonyaka zifuna Ukudla nokubalekela isimo sezulu esimbi. Akusizo zoke iinyoni ezikghona ukuphapha ngamaphiko wazo, isibonelo ikukhu nenqiliba azikghoni ukuphapha emoyeni.

==== Ukubekela amaqanda ====
[[Isimumathi:Common ostrich (Struthio camelus australis) male running composite.jpg|thumb|inciliba mhlobo wenyoni engakwazi ukuphapha emmoyeni]]
Iinyoni ukuthi zikghone ukwanda zibekela amaqanda beze ziwafukamele bese nakufika isikhathi amaqanda aqhume kuvele amadzinyani wakhona. Inyoni lokha nayingathi isabekela ithole bona [[iqanda]] layo libanjwe mumuntu iyawanghala bese ingasawafukamela&lt;ref&gt;Stadelman, W.J., 2017. Egg-production practices. In ''Egg science and technology'' (pp. 9-37). CRC Press.&lt;/ref&gt;Isibonelo seenyoni: likhozi, idlanga, ikukhu. Iinyoni zilwana ezinaphiko emzibeni namisiba amanengi angasibudisi. Zibekela amaqanda ukuba nabantwana. Zinomlomo obizwa ngebhigi obukhali ngombana zisebenzisa wona Ukudla, ukuzingela nokwakha iindleke zawo. Iiinyoni ezinengi zisebenzisa amaphiko wazo  ukuphapha kodwana ezinye azikghoni ukuphapha.

== Iinkomba ==
[[Category:Iinyoni]]
[[Category:Amaqanda]]</text>
      <sha1>klu16x0dmjuhh1qe81kk6vxtynitfyz</sha1>
    </revision>
  </page>
  <page>
    <title>Isibaya</title>
    <ns>0</ns>
    <id>560</id>
    <revision>
      <id>2668</id>
      <timestamp>2025-04-15T17:22:55Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Isibaya == Isibaya kuyindawo kuhlala khona iinlwana. Kuyindlu yeenlwana lapho zivalelwa khona lokha nazise khaya zingakayi emadlelweni ukuyokudla. Isibaya senza bona iinlwana zihlale zivikelekile begodu zingagcwali inarha yoke zifuna indawo yokulala&lt;ref&gt;Kraal - Wikipedia&lt;/ref&gt;. Kwezinye indawo isibaya kuyindawo eqakathekileko yamasiko ngombana abanye abantu basebenzisa isibaya ukwenza ezinye izinto zamasiko njengokuphahla.&quot;</comment>
      <origin>2668</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="429" sha1="iuu7n90s4b95t304z3vxpuy1oh6kscv" xml:space="preserve">== Isibaya ==
Isibaya kuyindawo kuhlala khona iinlwana. Kuyindlu yeenlwana lapho zivalelwa khona lokha nazise khaya zingakayi emadlelweni ukuyokudla. Isibaya senza bona iinlwana zihlale zivikelekile begodu zingagcwali inarha yoke zifuna indawo yokulala&lt;ref&gt;Kraal - Wikipedia&lt;/ref&gt;. Kwezinye indawo isibaya kuyindawo eqakathekileko yamasiko ngombana abanye abantu basebenzisa isibaya ukwenza ezinye izinto zamasiko njengokuphahla.</text>
      <sha1>iuu7n90s4b95t304z3vxpuy1oh6kscv</sha1>
    </revision>
    <revision>
      <id>2669</id>
      <parentid>2668</parentid>
      <timestamp>2025-04-15T17:23:40Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2669</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="458" sha1="q27lcykqelxnjbhfk2rxvoxz1pet9vy" xml:space="preserve">== Isibaya ==
'''Isibaya''' kuyindawo kuhlala khona iinlwana. Kuyindlu yeenlwana lapho zivalelwa khona lokha nazise khaya zingakayi emadlelweni ukuyokudla. Isibaya senza bona iinlwana zihlale zivikelekile begodu zingagcwali [[inarha]] yoke zifuna indawo yokulala&lt;ref&gt;Kraal - Wikipedia&lt;/ref&gt;. Kwezinye indawo isibaya kuyindawo eqakathekileko y[[amasiko]] ngombana abanye abantu basebenzisa isibaya ukwenza ezinye izinto zamasiko njengokuphahla.
&lt;references /&gt;</text>
      <sha1>q27lcykqelxnjbhfk2rxvoxz1pet9vy</sha1>
    </revision>
  </page>
  <page>
    <title>Ubulungiswa beCwewe</title>
    <ns>0</ns>
    <id>561</id>
    <revision>
      <id>2671</id>
      <timestamp>2025-04-21T14:24:51Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1285254265|JusticeForCwecwe]]&quot;</comment>
      <origin>2671</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="432" sha1="hy6it003fbr2f3fmy037b1pjwr9re21" xml:space="preserve">'''#JusticeForCwecwe''' mkhankaso weendaba zomphakathi [[Isewula Afrika|weSewula Afrika]] kanye nomkhankaso womphakathi owavela ngemva kokuhlukunyezwa ngokomseme komntazinyana eneminyaka elikhomba, eyaziwa ngoCwecwe, e-Bergview College,   isikolo sangasese e- Matatiele, e-Eastern Cape, [[Isewula Afrika|e-South Africa]] . Ijima lifuna ubulungiswa kumhlukunyezwa, lifuna ukuziphendulela esikolweni neemphathisweni ezibandakanyekako.</text>
      <sha1>hy6it003fbr2f3fmy037b1pjwr9re21</sha1>
    </revision>
    <revision>
      <id>3034</id>
      <parentid>2671</parentid>
      <timestamp>2025-06-06T20:37:44Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>do it</comment>
      <origin>3034</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="513" sha1="5a9t8dtc1wguasye6mbsaxhngo48jdl" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. #JusticeForCwecwe''' mkhankaso weendaba zomphakathi [[Isewula Afrika|weSewula Afrika]] kanye nomkhankaso womphakathi owavela ngemva kokuhlukunyezwa ngokomseme komntazinyana eneminyaka elikhomba, eyaziwa ngoCwecwe, e-Bergview College,   isikolo sangasese e- Matatiele, e-Eastern Cape, [[Isewula Afrika|e-South Africa]] . Ijima lifuna ubulungiswa kumhlukunyezwa, lifuna ukuziphendulela esikolweni neemphathisweni ezibandakanyekako.</text>
      <sha1>5a9t8dtc1wguasye6mbsaxhngo48jdl</sha1>
    </revision>
    <revision>
      <id>3047</id>
      <parentid>3034</parentid>
      <timestamp>2025-06-07T03:05:22Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Nomsa Skosana|Nomsa Skosana]]</comment>
      <origin>2671</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="432" sha1="hy6it003fbr2f3fmy037b1pjwr9re21" xml:space="preserve">'''#JusticeForCwecwe''' mkhankaso weendaba zomphakathi [[Isewula Afrika|weSewula Afrika]] kanye nomkhankaso womphakathi owavela ngemva kokuhlukunyezwa ngokomseme komntazinyana eneminyaka elikhomba, eyaziwa ngoCwecwe, e-Bergview College,   isikolo sangasese e- Matatiele, e-Eastern Cape, [[Isewula Afrika|e-South Africa]] . Ijima lifuna ubulungiswa kumhlukunyezwa, lifuna ukuziphendulela esikolweni neemphathisweni ezibandakanyekako.</text>
      <sha1>hy6it003fbr2f3fmy037b1pjwr9re21</sha1>
    </revision>
  </page>
  <page>
    <title>Amalwandle</title>
    <ns>0</ns>
    <id>562</id>
    <revision>
      <id>2675</id>
      <timestamp>2025-04-22T19:25:03Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Ilwande == '''Ilwande''' yindawo enamanzi amanengi khulu enetswayi&lt;ref&gt;OCEAN | English meaning - Cambridge Dictionary&lt;/ref&gt;. Amanzi welwandle athathe isikhundla esima-70% wephasi. [[Ilwandle]] liqakathekile ngombana kuyindawo lapho kuhlala khona ezinye zeenlwana, likhupha isiqunto se-oksijini ephufumulwa babantu. Ephasini sinemhlobo emine wamalwandle ekuyi lwandle ipacific, ilwandle I indian, ilwandle I-atlantic, ilwandle i-arctic ne ilwandle IeSewula.  '''Umhlobo wam...&quot;</comment>
      <origin>2675</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2854" sha1="bnzch4cmhz2bp01z006r8n3mk0ibsy9" xml:space="preserve">== Ilwande ==
'''Ilwande''' yindawo enamanzi amanengi khulu enetswayi&lt;ref&gt;OCEAN | English meaning - Cambridge Dictionary&lt;/ref&gt;. Amanzi welwandle athathe isikhundla esima-70% wephasi. [[Ilwandle]] liqakathekile ngombana kuyindawo lapho kuhlala khona ezinye zeenlwana, likhupha isiqunto se-oksijini ephufumulwa babantu. Ephasini sinemhlobo emine wamalwandle ekuyi lwandle ipacific, ilwandle I indian, ilwandle I-atlantic, ilwandle i-arctic ne ilwandle IeSewula.

'''Umhlobo wamalwandle'''

'''1. ilwandle i-Pacific'''

Leli kulilwandle elikhulu ukuwadlula woke amalwandle ephasini. Ilikhaya le-Marian Trench ekuyindawo edibhelako ukudlula zoke phasini&lt;ref&gt;Stewart, H.A. and Jamieson, A.J., 2019. The five deeps: The location and depth of the deepest place in each of the world's oceans. ''Earth-Science Reviews'', ''197'', p.102896.&lt;/ref&gt;. 

2. I lwandle I- indian

Linamanzi apholileko Ukudla woke amalwande, lizele ngeenlwana zemanzini ezihlukahlukeneko.

'''3.Ilwandle i-Arctic''' 

Lilwanndle elincani ukwadlula woke ephasini begodu ngilo elimakhaza nofana elimanzi amakhaza khulu. Libonakala ngamanzi agubuzeswe lirhwaba. Linenlwana zakhona ezihlala khona elwandle leli.

'''4.  ilwandle i-Atlantic'''

Leli lilwandle lesibili elikulu, laziwa ngamagagasi walo  anamandla&lt;ref&gt;Anfuso, G., Rangel‐Buitrago, N., Cortés‐Useche, C., Iglesias Castillo, B. and Gracia, F.J., 2016. Characterization of storm events along the Gulf of Cadiz (eastern central Atlantic Ocean). ''International Journal of Climatology'', ''36''(11), pp.3690-3707.&lt;/ref&gt;

'''5. ilwandle IeSewula'''

Yaziwa bona yi lwandle i-Antarctic  ngombana indulungele ikhontinenti I-Antarctica. Linamanzi emakhaza .

== Ukuqakatheka kwelwandle ==
Amalwandle aqakathekile ukwenza bona abantu baphile kuhle.

'''Ukudla'''

Ilwandle lenza bona abantu bakghone ukuthola Ukudla ngombana abantu bakghona ukuthiya iimfesi bayozidla nofana  bazithengize&lt;ref&gt;Ferreira, B., Rice, J. and Rosenberg, A., 2016. The oceans as a source of food. ''The First Global Integrated Marine Assessment (World Ocean Assessment I). United Nations, USA''.&lt;/ref&gt;. Lokhu kutjho bona ilwandle likhona ukondla iingidi zabantu.

'''Umoya'''

Ilwandle likhipha umoya ophefumulwa babantu obizwa bona yi-oksijini. Isiqunto se-oksijini esiyiphefumulako sivela elwandle&lt;ref&gt;Sigman, D.M. and Hain, M.P., 2012. The biological productivity of the ocean. ''Nature Education Knowledge'', ''3''(10), p.21.&lt;/ref&gt;.

'''Isimo sezulu'''

Ilwandle lilawula isimo seZulu ngombana lidosa ikhabhoni dioksayidi nomtjhiso emoyeni

'''Isiphetho'''

Ilwandle liqakathekile begodu lidlala indima ekulu emaphilweni wabantu ngombana abantu bathola Ukudla kilo, bakghona ukuthola nomoya wokuphefumula  ovela kilo. Kufuze abantu bavikele ilwandle bangalisilaphazi ukuze neenzukulwana ezizako zikghone ukuphile kuhle ngenzuzo abayithola elwandle.</text>
      <sha1>bnzch4cmhz2bp01z006r8n3mk0ibsy9</sha1>
    </revision>
    <revision>
      <id>2681</id>
      <parentid>2675</parentid>
      <timestamp>2025-04-23T04:25:27Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2681</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3368" sha1="fg608zkqe52xowo39yhx7nj7nyffrge" xml:space="preserve">== Ilwande ==
'''Ilwande''' yindawo enamanzi amanengi khulu enetswayi&lt;ref&gt;OCEAN | English meaning - Cambridge Dictionary&lt;/ref&gt;. Amanzi welwandle athathe isikhundla esima-70% wephasi. [[Ilwandle]] liqakathekile ngombana kuyindawo lapho kuhlala khona ezinye zeenlwana, likhupha isiqunto se-oksijini ephufumulwa babantu. Ephasini sinemhlobo emine wamalwandle ekuyi lwandle ipacific, ilwandle I indian, ilwandle I-atlantic, ilwandle i-arctic ne ilwandle IeSewula.

== Umhlobo wamalwandle ==
'''1. ilwandle i-Pacific'''

Leli kulilwandle elikhulu ukuwadlula woke amalwandle ephasini.Ubukhulu belwandle leli budlula ubukhulu beenarhakazi zoke zephasi selel zihlanganisiwe. Ilikhaya le-Marian Trench ekuyindawo edibhelako ukudlula zoke phasini&lt;ref&gt;Stewart, H.A. and Jamieson, A.J., 2019. The five deeps: The location and depth of the deepest place in each of the world's oceans. ''Earth-Science Reviews'', ''197'', p.102896.&lt;/ref&gt;. Elwandle leli kunamahlengethwa, namatjhagi ahlala khona ngombana ilwandle leli kuyikhaya lawo. 

2. I lwandle I- indian

Linamanzi apholileko Ukudla woke amalwande, lizele ngeenlwana zemanzini ezihlukahlukeneko.

'''3.Ilwandle i-Arctic''' 

Lilwanndle elincani ukwadlula woke ephasini begodu ngilo elimakhaza nofana elimanzi amakhaza khulu. Libonakala ngamanzi agubuzeswe lirhwaba. Linenlwana zakhona ezihlala khona elwandle leli.

'''4.  ilwandle i-Atlantic'''

Leli lilwandle lesibili elikulu, laziwa ngamagagasi walo  anamandla&lt;ref&gt;Anfuso, G., Rangel‐Buitrago, N., Cortés‐Useche, C., Iglesias Castillo, B. and Gracia, F.J., 2016. Characterization of storm events along the Gulf of Cadiz (eastern central Atlantic Ocean). ''International Journal of Climatology'', ''36''(11), pp.3690-3707.&lt;/ref&gt;

'''5. ilwandle IeSewula'''

Yaziwa bona yi lwandle i-Antarctic  ngombana indulungele ikhontinenti I-Antarctica. Linamanzi emakhaza .

== Ukuqakatheka kwelwandle ==
Amalwandle aqakatheke ngendlela ezinengi okhonye kukuthi enza bona abantu bona bakghone ukuphila kuhle.

=== Ukudla ===
Ilwandle lenza bona abantu bakghone ukuthola Ukudla ngombana abantu bakghona ukuthiya iimfesi bayozidla nofana  bazithengize&lt;ref&gt;Ferreira, B., Rice, J. and Rosenberg, A., 2016. The oceans as a source of food. ''The First Global Integrated Marine Assessment (World Ocean Assessment I). United Nations, USA''.&lt;/ref&gt;.. Lokhu kutjho bona ilwandle likhona ukondla iingidi zabantu ephasini. Abantu nbakghona ukukwakha ukwakha umnotho ngezinto ngenlwana abazithola elwandle,  omunye umuntu angathatha iinlwana ezitholakala elwandle azathengise Ukuze akghone ukwenza imali.

=== Umoya ===
Ilwandle likhipha umoya ophefumulwa babantu obizwa bona yi-oksijini. Isiqunto se-oksijini esiyiphefumulako sivela elwandle&lt;ref&gt;Sigman, D.M. and Hain, M.P., 2012. The biological productivity of the ocean. ''Nature Education Knowledge'', ''3''(10), p.21.&lt;/ref&gt;. Ilwandle lingeminye yemithombo lapho abantu bathoma khona ummoya ohlanzekileko abawutlhogako.

=== Isimo sezulu ===
Ilwandle lilawula isimo seZulu ngombana lidosa ikhabhoni dioksayidi nomtjhiso emoyeni

== Isiphetho ==
Ilwandle liqakathekile begodu lidlala indima ekulu emaphilweni wabantu ngombana abantu bathola Ukudla kilo, bakghona ukuthola nomoya wokuphefumula  ovela kilo. Kufuze abantu bavikele ilwandle bangalisilaphazi ukuze neenzukulwana ezizako zikghone ukuphile kuhle ngenzuzo abayithola elwandle.</text>
      <sha1>fg608zkqe52xowo39yhx7nj7nyffrge</sha1>
    </revision>
    <revision>
      <id>2682</id>
      <parentid>2681</parentid>
      <timestamp>2025-04-23T04:36:08Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2682</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3402" sha1="jtc4e9yyjf2r59t9ot930uknsph4g8c" xml:space="preserve">== Ilwande ==
'''Ilwande''' yindawo enamanzi amanengi khulu enetswayi&lt;ref&gt;OCEAN | English meaning - Cambridge Dictionary&lt;/ref&gt;. Amanzi welwandle athathe isikhundla esima-70% wephasi. [[Ilwandle]] liqakathekile ngombana kuyindawo lapho kuhlala khona ezinye zeenlwana, likhupha isiqunto se-oksijini ephufumulwa babantu. Ephasini sinemhlobo emine wamalwandle ekuyi lwandle ipacific, ilwandle I indian, ilwandle I-atlantic, ilwandle i-arctic ne ilwandle IeSewula.

== Umhlobo wamalwandle ==
'''1. ilwandle i-Pacific'''

Leli kulilwandle elikhulu ukuwadlula woke amalwandle ephasini.Ubukhulu belwandle leli budlula ubukhulu beenarhakazi zoke zephasi selel zihlanganisiwe. Ilikhaya le-Marian Trench ekuyindawo edibhelako ukudlula zoke phasini&lt;ref&gt;Stewart, H.A. and Jamieson, A.J., 2019. The five deeps: The location and depth of the deepest place in each of the world's oceans. ''Earth-Science Reviews'', ''197'', p.102896.&lt;/ref&gt;. Elwandle leli kunamahlengethwa, namatjhagi ahlala khona ngombana ilwandle leli kuyikhaya lawo. 

2. I lwandle I- indian

Linamanzi apholileko Ukudla woke amalwande, lizele ngeenlwana zemanzini ezihlukahlukeneko.

'''3.Ilwandle i-Arctic''' 

Lilwanndle elincani ukwadlula woke ephasini begodu ngilo elimakhaza nofana elimanzi amakhaza khulu. Libonakala ngamanzi agubuzeswe lirhwaba.Ilwandle leli linamanzi  afretjhi. Linenlwana zakhona ezihlala khona elwandle leli.

'''4.  ilwandle i-Atlantic'''

Leli lilwandle lesibili elikulu, laziwa ngamagagasi walo  anamandla&lt;ref&gt;Anfuso, G., Rangel‐Buitrago, N., Cortés‐Useche, C., Iglesias Castillo, B. and Gracia, F.J., 2016. Characterization of storm events along the Gulf of Cadiz (eastern central Atlantic Ocean). ''International Journal of Climatology'', ''36''(11), pp.3690-3707.&lt;/ref&gt;

'''5. ilwandle IeSewula'''

Yaziwa bona yi lwandle i-Antarctic  ngombana indulungele ikhontinenti I-Antarctica. Linamanzi emakhaza .

== Ukuqakatheka kwelwandle ==
Amalwandle aqakatheke ngendlela ezinengi okhonye kukuthi enza bona abantu bona bakghone ukuphila kuhle.

=== Ukudla ===
Ilwandle lenza bona abantu bakghone ukuthola Ukudla ngombana abantu bakghona ukuthiya iimfesi bayozidla nofana  bazithengize&lt;ref&gt;Ferreira, B., Rice, J. and Rosenberg, A., 2016. The oceans as a source of food. ''The First Global Integrated Marine Assessment (World Ocean Assessment I). United Nations, USA''.&lt;/ref&gt;.. Lokhu kutjho bona ilwandle likhona ukondla iingidi zabantu ephasini. Abantu nbakghona ukukwakha ukwakha umnotho ngezinto ngenlwana abazithola elwandle,  omunye umuntu angathatha iinlwana ezitholakala elwandle azathengise Ukuze akghone ukwenza imali.

=== Umoya ===
Ilwandle likhipha umoya ophefumulwa babantu obizwa bona yi-oksijini. Isiqunto se-oksijini esiyiphefumulako sivela elwandle&lt;ref&gt;Sigman, D.M. and Hain, M.P., 2012. The biological productivity of the ocean. ''Nature Education Knowledge'', ''3''(10), p.21.&lt;/ref&gt;. Ilwandle lingeminye yemithombo lapho abantu bathoma khona ummoya ohlanzekileko abawutlhogako.

=== Isimo sezulu ===
Ilwandle lilawula isimo seZulu ngombana lidosa ikhabhoni dioksayidi nomtjhiso emoyeni

== Isiphetho ==
Ilwandle liqakathekile begodu lidlala indima ekulu emaphilweni wabantu ngombana abantu bathola Ukudla kilo, bakghona ukuthola nomoya wokuphefumula  ovela kilo. Kufuze abantu bavikele ilwandle bangalisilaphazi ukuze neenzukulwana ezizako zikghone ukuphile kuhle ngenzuzo abayithola elwandle.</text>
      <sha1>jtc4e9yyjf2r59t9ot930uknsph4g8c</sha1>
    </revision>
    <revision>
      <id>2683</id>
      <parentid>2682</parentid>
      <timestamp>2025-04-23T04:44:11Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>2683</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3701" sha1="hrbgq0bo2tmbvpdoh972zgx0v625j43" xml:space="preserve">== Ilwande ==
'''Ilwande''' yindawo enamanzi amanengi khulu enetswayi&lt;ref&gt;OCEAN | English meaning - Cambridge Dictionary&lt;/ref&gt;. Amanzi welwandle athathe isikhundla esima-70% wephasi. [[Ilwandle]] liqakathekile ngombana kuyindawo lapho kuhlala khona ezinye zeenlwana, likhupha isiqunto se-oksijini ephufumulwa babantu. Ephasini sinemhlobo emine wamalwandle ekuyi lwandle ipacific, ilwandle I indian, ilwandle I-atlantic, ilwandle i-arctic ne ilwandle IeSewula.

== Umhlobo wamalwandle ==
'''1. ilwandle i-Pacific'''

Leli kulilwandle elikhulu ukuwadlula woke amalwandle ephasini.Ubukhulu belwandle leli budlula ubukhulu beenarhakazi zoke zephasi selel zihlanganisiwe. Ilikhaya le-Marian Trench ekuyindawo edibhelako ukudlula zoke phasini&lt;ref&gt;Stewart, H.A. and Jamieson, A.J., 2019. The five deeps: The location and depth of the deepest place in each of the world's oceans. ''Earth-Science Reviews'', ''197'', p.102896.&lt;/ref&gt;. Elwandle leli kunamahlengethwa, namatjhagi ahlala khona ngombana ilwandle leli kuyikhaya lawo. 

2. I lwandle I- indian

Linamanzi apholileko Ukudla woke amalwande, lizele ngeenlwana zemanzini ezihlukahlukeneko.

'''3.Ilwandle i-Arctic''' 

Lilwanndle elincani ukwadlula woke ephasini begodu ngilo elimakhaza nofana elimanzi amakhaza khulu. Libonakala ngamanzi agubuzeswe lirhwaba.Ilwandle leli linamanzi  afretjhibegodi amanzi la ngiwo elawula ubujamo bezulu ephasini loke&lt;ref&gt;Solomon, A., Heuzé, C., Rabe, B., Bacon, S., Bertino, L., Heimbach, P., Inoue, J., Iovino, D., Mottram, R., Zhang, X. and Aksenov, Y., 2021. Freshwater in the arctic ocean 2010–2019. ''Ocean Science'', ''17''(4), pp.1081-1102.&lt;/ref&gt;. Linenlwana zakhona ezihlala khona elwandle leli.

'''4.  ilwandle i-Atlantic'''

Leli lilwandle lesibili elikulu, laziwa ngamagagasi walo  anamandla&lt;ref&gt;Anfuso, G., Rangel‐Buitrago, N., Cortés‐Useche, C., Iglesias Castillo, B. and Gracia, F.J., 2016. Characterization of storm events along the Gulf of Cadiz (eastern central Atlantic Ocean). ''International Journal of Climatology'', ''36''(11), pp.3690-3707.&lt;/ref&gt;

'''5. ilwandle IeSewula'''

Yaziwa bona yi lwandle i-Antarctic  ngombana indulungele ikhontinenti I-Antarctica. Linamanzi emakhaza .

== Ukuqakatheka kwelwandle ==
Amalwandle aqakatheke ngendlela ezinengi okhonye kukuthi enza bona abantu bona bakghone ukuphila kuhle.

=== Ukudla ===
Ilwandle lenza bona abantu bakghone ukuthola Ukudla ngombana abantu bakghona ukuthiya iimfesi bayozidla nofana  bazithengize&lt;ref&gt;Ferreira, B., Rice, J. and Rosenberg, A., 2016. The oceans as a source of food. ''The First Global Integrated Marine Assessment (World Ocean Assessment I). United Nations, USA''.&lt;/ref&gt;.. Lokhu kutjho bona ilwandle likhona ukondla iingidi zabantu ephasini. Abantu nbakghona ukukwakha ukwakha umnotho ngezinto ngenlwana abazithola elwandle,  omunye umuntu angathatha iinlwana ezitholakala elwandle azathengise Ukuze akghone ukwenza imali.

=== Umoya ===
Ilwandle likhipha umoya ophefumulwa babantu obizwa bona yi-oksijini. Isiqunto se-oksijini esiyiphefumulako sivela elwandle&lt;ref&gt;Sigman, D.M. and Hain, M.P., 2012. The biological productivity of the ocean. ''Nature Education Knowledge'', ''3''(10), p.21.&lt;/ref&gt;. Ilwandle lingeminye yemithombo lapho abantu bathoma khona ummoya ohlanzekileko abawutlhogako.

=== Isimo sezulu ===
Ilwandle lilawula isimo seZulu ngombana lidosa ikhabhoni dioksayidi nomtjhiso emoyeni

== Isiphetho ==
Ilwandle liqakathekile begodu lidlala indima ekulu emaphilweni wabantu ngombana abantu bathola Ukudla kilo, bakghona ukuthola nomoya wokuphefumula  ovela kilo. Kufuze abantu bavikele ilwandle bangalisilaphazi ukuze neenzukulwana ezizako zikghone ukuphile kuhle ngenzuzo abayithola elwandle.</text>
      <sha1>hrbgq0bo2tmbvpdoh972zgx0v625j43</sha1>
    </revision>
    <revision>
      <id>2684</id>
      <parentid>2683</parentid>
      <timestamp>2025-04-23T04:49:52Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2684</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3702" sha1="aorwvkgg567wl2t8ymcfay3wk4vxvw9" xml:space="preserve">== Ilwande ==
'''Ilwande''' yindawo enamanzi amanengi khulu enetswayi&lt;ref&gt;OCEAN | English meaning - Cambridge Dictionary&lt;/ref&gt;. Amanzi welwandle athathe isikhundla esima-70% wephasi. [[Ilwandle]] liqakathekile ngombana kuyindawo lapho kuhlala khona ezinye zeenlwana, likhupha isiqunto se-oksijini ephufumulwa babantu. Ephasini sinemhlobo emine wamalwandle ekuyi lwandle ipacific, ilwandle I indian, ilwandle I-atlantic, ilwandle i-arctic ne ilwandle IeSewula.

== Umhlobo wamalwandle ==
'''1. ilwandle i-Pacific'''

Leli kulilwandle elikhulu ukuwadlula woke amalwandle ephasini. Ubukhulu belwandle leli budlula ubukhulu beenarhakazi zoke zephasi selel zihlanganisiwe. Ilikhaya le-Marian Trench ekuyindawo edibhelako ukudlula zoke phasini&lt;ref&gt;Stewart, H.A. and Jamieson, A.J., 2019. The five deeps: The location and depth of the deepest place in each of the world's oceans. ''Earth-Science Reviews'', ''197'', p.102896.&lt;/ref&gt;. Elwandle leli kunamahlengethwa, namatjhagi ahlala khona ngombana ilwandle leli kuyikhaya lawo. 

2. I lwandle I- indian

Linamanzi apholileko Ukudla woke amalwande, lizele ngeenlwana zemanzini ezihlukahlukeneko.

'''3.Ilwandle i-Arctic''' 

Lilwanndle elincani ukwadlula woke ephasini begodu ngilo elimakhaza nofana elimanzi amakhaza khulu. Libonakala ngamanzi agubuzeswe lirhwaba.Ilwandle leli linamanzi  afretjhibegodi amanzi la ngiwo elawula ubujamo bezulu ephasini loke&lt;ref&gt;Solomon, A., Heuzé, C., Rabe, B., Bacon, S., Bertino, L., Heimbach, P., Inoue, J., Iovino, D., Mottram, R., Zhang, X. and Aksenov, Y., 2021. Freshwater in the arctic ocean 2010–2019. ''Ocean Science'', ''17''(4), pp.1081-1102.&lt;/ref&gt;. Linenlwana zakhona ezihlala khona elwandle leli.

'''4.  ilwandle i-Atlantic'''

Leli lilwandle lesibili elikulu, laziwa ngamagagasi walo  anamandla&lt;ref&gt;Anfuso, G., Rangel‐Buitrago, N., Cortés‐Useche, C., Iglesias Castillo, B. and Gracia, F.J., 2016. Characterization of storm events along the Gulf of Cadiz (eastern central Atlantic Ocean). ''International Journal of Climatology'', ''36''(11), pp.3690-3707.&lt;/ref&gt;

'''5. ilwandle IeSewula'''

Yaziwa bona yi lwandle i-Antarctic  ngombana indulungele ikhontinenti I-Antarctica. Linamanzi emakhaza .

== Ukuqakatheka kwelwandle ==
Amalwandle aqakatheke ngendlela ezinengi okhonye kukuthi enza bona abantu bona bakghone ukuphila kuhle.

=== Ukudla ===
Ilwandle lenza bona abantu bakghone ukuthola Ukudla ngombana abantu bakghona ukuthiya iimfesi bayozidla nofana  bazithengize&lt;ref&gt;Ferreira, B., Rice, J. and Rosenberg, A., 2016. The oceans as a source of food. ''The First Global Integrated Marine Assessment (World Ocean Assessment I). United Nations, USA''.&lt;/ref&gt;.. Lokhu kutjho bona ilwandle likhona ukondla iingidi zabantu ephasini. Abantu nbakghona ukukwakha ukwakha umnotho ngezinto ngenlwana abazithola elwandle,  omunye umuntu angathatha iinlwana ezitholakala elwandle azathengise Ukuze akghone ukwenza imali.

=== Umoya ===
Ilwandle likhipha umoya ophefumulwa babantu obizwa bona yi-oksijini. Isiqunto se-oksijini esiyiphefumulako sivela elwandle&lt;ref&gt;Sigman, D.M. and Hain, M.P., 2012. The biological productivity of the ocean. ''Nature Education Knowledge'', ''3''(10), p.21.&lt;/ref&gt;. Ilwandle lingeminye yemithombo lapho abantu bathoma khona ummoya ohlanzekileko abawutlhogako.

=== Isimo sezulu ===
Ilwandle lilawula isimo seZulu ngombana lidosa ikhabhoni dioksayidi nomtjhiso emoyeni

== Isiphetho ==
Ilwandle liqakathekile begodu lidlala indima ekulu emaphilweni wabantu ngombana abantu bathola Ukudla kilo, bakghona ukuthola nomoya wokuphefumula  ovela kilo. Kufuze abantu bavikele ilwandle bangalisilaphazi ukuze neenzukulwana ezizako zikghone ukuphile kuhle ngenzuzo abayithola elwandle.</text>
      <sha1>aorwvkgg567wl2t8ymcfay3wk4vxvw9</sha1>
    </revision>
  </page>
  <page>
    <title>SWIP</title>
    <ns>0</ns>
    <id>563</id>
    <revision>
      <id>2676</id>
      <timestamp>2025-04-22T20:46:47Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <comment>Created page with &quot;'''SWiP'''   I-SWiP yiphrojekthi ehloselwe ukuthuthukisa amalimi wendabuko weSewula Afrika ebuthelelwenilwazi, khulu khulu ilimi lesiNdebele ku-Wikipedia. Ilimi lesiNdebele lisetjenziswa njengelimi lokuhlola ngebanga lokuthi alikajanyelwa khulu ku-Wikipedia njengamanye amalimi weSewul Afrika begodu iphrojekthi le ihlose ukunikela abantu abakhuluma IsiNdebele amandla nomdlandla wokutlola ama-athikili ku-wikipedia simahla. Kanti-ke, i-SWiP yi-akhronimu ejamele iinhlangano...&quot;</comment>
      <origin>2676</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3774" sha1="ffjjmjsy0xw1t40rhrma20hya5slj6v" xml:space="preserve">'''SWiP''' 

I-SWiP yiphrojekthi ehloselwe ukuthuthukisa amalimi wendabuko weSewula Afrika ebuthelelwenilwazi, khulu khulu ilimi lesiNdebele ku-Wikipedia. Ilimi lesiNdebele lisetjenziswa njengelimi lokuhlola ngebanga lokuthi alikajanyelwa khulu ku-Wikipedia njengamanye amalimi weSewul Afrika begodu iphrojekthi le ihlose ukunikela abantu abakhuluma IsiNdebele amandla nomdlandla wokutlola ama-athikili ku-wikipedia simahla. Kanti-ke, i-SWiP yi-akhronimu ejamele iinhlangano ezintathu ekungizo ezakhe iphrojekthi le, iinhlangano lezo yi: SADiLaR begodu ngokuzeleko yi-South African Centre for for Digital Language Resources, ne-Wikipedia  kanye nehlangano ye-PanSALB ekuyi-Pan South African Language Board ngokuzeleko. &lt;ref&gt;https://www.dst.gov.za/index.php/media-room/latest-news/2885-government-establishes-a-new-digital-centre-to-promote-indigenous-languages%5B%5D&lt;/ref&gt;

I-SADiLaR yatlanywa ngomnyaka wee-2016 begodu kuligadango lokwakha nokuphatha iintlabagelo zebuthelelolwazi nemitjhini yokurhubhulula edijithali kanye nokuthuthukisa iintlabagelo zamalimi adijithali eSewula Afrika. Igadango leli linikelwa isekele mNyango weSayentsi nokwakha eSewula Afrika.&lt;ref&gt;https://en.wikipedia.org/wiki/SADiLaR#:~:text=Founded%20in%202016%2C%20and%20hosted,of%20South%20Africa's%20official%20languages.&lt;/ref&gt; I-Wikipedia yatlanywa ngomnyaka we-2001 begodu yi-ensatlophidiya yasimahla etholakala ebuthelelwenilwazi, itlolwa beyibuye iphathwe mphakathi wabantu abazinikela simahla.&lt;ref&gt;https://www.britannica.com/topic/Wikipedia&lt;/ref&gt; Kanti-ke, i-PanSALB yihlangano yeSewula Afrika eyakhwa ngesizathu sokukhuthaza ubuliminengi ukuze ithuthukise beyinzinzise amalimi woke weSewula Afrika alitjhumi nambili ngenani begodu ivikele amalungelo wamalimi eSewula Afrika, le ihlangano yatlanywa ngomnyaka we-1995. I-SWiP yona yatlanywa ngomnyaka wee-2023.&lt;ref&gt;https://sadilar.org/en/swip/&lt;/ref&gt; 

Iminqopho ye-SWiP kukhulisa ubukhona bebuthelelolwazi bamalimi we-Sewula Afrika, ngokutjheja amalimi wendabuko, ngokukghonakalisa imiphakathi yendawo bona yenze begodu yabelane ngelwazi le-Wikipedia emalimini wabo. Iphrojekthi le ihlose ukuvikela amalimi wendabuko ngokukhuthaza ukusetjenziswa kwawo, ukubulunga amagugu wawo, nokukhuthaza ukusebenzisana hlangana nabathintekako bamalimi. Igadango leli lifuna ukuvuselela nokuvikela amalimi wendabuko, ukuqinisekisa ukuphila kwawo nokukhuthaza ukuzibandakanya okuhlukahlukeneko  wokulondolozwa kwelimi. Iphrojekthi le ikhuthaza ukulondolozwa nokugidingwa kwamalimi wendabuko, isebenzela ukukhandela ukuwohloka kwawo begodu ikhuthaze ukuzibandakanya okusebenzako kwabasebenzi bamalimi nemiphakathi. &lt;ref&gt;https://www.dst.gov.za/index.php/media-room/latest-news/2885-government-establishes-a-new-digital-centre-to-promote-indigenous-languages%5B%5D&lt;/ref&gt;

Iphrojekthi ye-SWiP yenze amagadango soloko yasangulwa, yaqeda ngepumelelo isigaba sayo sokuthoma, esakha umfutho wokujanyelwa kwelimi le-Afrika ku-Wikipedia begodu yakhulisa umphakathi wabafaki-galelo abanekghono. Ipumelelo eqakathekileko ifaka hlangana ukusingatha imihlangano yokuqoqisana ngokutlola emalangeni amabili eendaweni ezisithandathu, ukubandula abahlanganyeli abama-483 abavela emayunivesithi ali-10, nokuhlela umnyanya oseqadi e-Sayensi Forum South Africa 2024, owakhuthaza ilwazi elivulekileko nelifinyelelekako kibo boke abantu. Iphaliswano lokutlola nalo lihlanganyelwe nabahleli abama-56, baqakathekisa abafaki-galelo abaphezulu nabaphumeleleko ngelimi ngalinye elitloliweko leSewula Afrika. Ukwakha phezu kwesisekelo lesi, iSigaba sesibili sathoma ngoSinyikhaba 2024 begodu sizokuragela phambili bekube nguMgwengweni 2027, sizokwethula amagadango amatjha wokuthuthukisa imiphakathi yamalimi nokuthuthukisa amalimi weSewula Afrika.&lt;ref&gt;https://sadilar.org/en/swip/&lt;/ref&gt;</text>
      <sha1>ffjjmjsy0xw1t40rhrma20hya5slj6v</sha1>
    </revision>
    <revision>
      <id>2836</id>
      <parentid>2676</parentid>
      <timestamp>2025-05-22T15:48:19Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <origin>2836</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4734" sha1="imlah8mc46vgnpc7upzkdufinf4k2sa" xml:space="preserve">== '''SWiP''' ==
'''I-SWiP''' yiphrojekthi ehloselwe ukuthuthukisa amalimi wendabuko weSewula Afrika ebuthelelwenilwazi, khulu khulu ilimi lesiNdebele ku-Wikipedia. Ilimi lesiNdebele lisetjenziswa njengelimi lokuhlola ngebanga lokuthi alikajanyelwa khulu ku-Wikipedia njengamanye amalimi weSewul Afrika begodu iphrojekthi le ihlose ukunikela abantu abakhuluma IsiNdebele amandla nomdlandla wokutlola ama-athikili ku-wikipedia simahla. Kanti-ke, i-SWiP yi-akhronimu ejamele iinhlangano ezintathu ekungizo ezakhe iphrojekthi le, iinhlangano lezo yi: SADiLaR begodu ngokuzeleko yi-South African Centre for for Digital Language Resources, ne-Wikipedia  kanye nehlangano ye-PanSALB ekuyi-Pan South African Language Board ngokuzeleko. 

I-SADiLaR yatlanywa ngomnyaka wee-2016 begodu kuligadango lokwakha nokuphatha iintlabagelo zebuthelelolwazi nemitjhini yokurhubhulula edijithali kanye nokuthuthukisa iintlabagelo zamalimi adijithali eSewula Afrika. Igadango leli linikelwa isekele mNyango weSayentsi nokwakha eSewula Afrika. I-Wikipedia yatlanywa ngomnyaka we-2001 begodu yi-ensatlophidiya yasimahla etholakala ebuthelelwenilwazi, itlolwa beyibuye iphathwe mphakathi wabantu abazinikela simahla. &lt;ref&gt;{{Cite web|date=2025-05-13|title=Wikipedia {{!}} Definition, Encyclopedia, History, &amp; Facts {{!}} Britannica|url=https://www.britannica.com/topic/Wikipedia|access-date=2025-05-22|website=www.britannica.com|language=en}}&lt;/ref&gt; Kanti-ke, i-PanSALB yihlangano yeSewula Afrika eyakhwa ngesizathu sokukhuthaza ubuliminengi ukuze ithuthukise beyinzinzise amalimi woke weSewula Afrika alitjhumi nambili ngenani begodu ivikele amalungelo wamalimi eSewula Afrika, le ihlangano yatlanywa ngomnyaka we-1995. I-SWiP yona yatlanywa ngomnyaka wee-2023. &lt;ref&gt;{{Cite web|title=SADiLaR-Wikipedia-PanSALB (SWiP) – SADiLaR|url=https://sadilar.org/en/swip/|access-date=2025-05-22|website=sadilar.org}}&lt;/ref&gt; 

Iminqopho ye-SWiP kukhulisa ubukhona bebuthelelolwazi bamalimi we-Sewula Afrika, ngokutjheja amalimi wendabuko, ngokukghonakalisa imiphakathi yendawo bona yenze begodu yabelane ngelwazi le-Wikipedia emalimini wabo. Iphrojekthi le ihlose ukuvikela amalimi wendabuko ngokukhuthaza ukusetjenziswa kwawo, ukubulunga amagugu wawo, nokukhuthaza ukusebenzisana hlangana nabathintekako bamalimi. Igadango leli lifuna ukuvuselela nokuvikela amalimi wendabuko, ukuqinisekisa ukuphila kwawo nokukhuthaza ukuzibandakanya okuhlukahlukeneko  wokulondolozwa kwelimi. Iphrojekthi le ikhuthaza ukulondolozwa nokugidingwa kwamalimi wendabuko, isebenzela ukukhandela ukuwohloka kwawo begodu ikhuthaze ukuzibandakanya okusebenzako kwabasebenzi bamalimi nemiphakathi. &lt;ref&gt;{{Cite web|title=Wayback Machine|url=https://www.dst.gov.za/index.php/media-room/latest-news/2885-government-establishes-a-new-digital-centre-to-promote-indigenous-languages%5B%5D|archive-url=http://web.archive.org/web/20240212210914/https://www.dst.gov.za/index.php/media-room/latest-news/2885-government-establishes-a-new-digital-centre-to-promote-indigenous-languages%5B%5D|archive-date=2024-02-12|access-date=2025-05-22|website=www.dst.gov.za}}&lt;/ref&gt;

Iphrojekthi ye-SWiP yenze amagadango soloko yasangulwa, yaqeda ngepumelelo isigaba sayo sokuthoma, esakha umfutho wokujanyelwa kwelimi le-Afrika ku-Wikipedia begodu yakhulisa umphakathi wabafaki-galelo abanekghono. Ipumelelo eqakathekileko ifaka hlangana ukusingatha imihlangano yokuqoqisana ngokutlola emalangeni amabili eendaweni ezisithandathu, ukubandula abahlanganyeli abama-483 abavela emayunivesithi ali-10, nokuhlela umnyanya oseqadi e-Sayensi Forum South Africa 2024, owakhuthaza ilwazi elivulekileko nelifinyelelekako kibo boke abantu. Iphaliswano lokutlola nalo lihlanganyelwe nabahleli abama-56, baqakathekisa abafaki-galelo abaphezulu nabaphumeleleko ngelimi ngalinye elitloliweko leSewula Afrika. Ukwakha phezu kwesisekelo lesi, iSigaba sesibili sathoma ngoSinyikhaba 2024 begodu sizokuragela phambili bekube nguMgwengweni 2027, sizokwethula amagadango amatjha wokuthuthukisa imiphakathi yamalimi nokuthuthukisa amalimi weSewula Afrika. &lt;ref&gt;{{Cite web|title=SADiLaR-Wikipedia-PanSALB (SWiP) – SADiLaR|url=https://sadilar.org/en/swip/|access-date=2025-05-22|website=sadilar.org}}&lt;/ref&gt;

=== REFERENCES ===
1) {{Cite web|date=2025-05-13|title=Wikipedia {{!}} Definition, Encyclopedia, History, &amp; Facts {{!}} Britannica|url=https://www.britannica.com/topic/Wikipedia|access-date=2025-05-22|website=www.britannica.com|language=en}}&lt;

2)  &quot;SADiLaR-Wikipedia-PanSALB (SWiP) – SADiLaR&quot;. ''sadilar.org''. Retrieved 2025-05-22.

3)  &quot;Wayback Machine&quot;. ''www.dst.gov.za''. Archived from the original on 2024-02-12. Retrieved 2025-05-22.

4)  SADiLaR-Wikipedia-PanSALB (SWiP) – SADiLaR&quot;. ''sadilar.org''. Retrieved 2025-05-22.</text>
      <sha1>imlah8mc46vgnpc7upzkdufinf4k2sa</sha1>
    </revision>
    <revision>
      <id>2837</id>
      <parentid>2836</parentid>
      <timestamp>2025-05-22T15:49:09Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <comment>FIXED REFERENCES</comment>
      <origin>2837</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4219" sha1="nr994usbiipr0oh22cjijc54z1xvhv3" xml:space="preserve">== '''SWiP''' ==
'''I-SWiP''' yiphrojekthi ehloselwe ukuthuthukisa amalimi wendabuko weSewula Afrika ebuthelelwenilwazi, khulu khulu ilimi lesiNdebele ku-Wikipedia. Ilimi lesiNdebele lisetjenziswa njengelimi lokuhlola ngebanga lokuthi alikajanyelwa khulu ku-Wikipedia njengamanye amalimi weSewul Afrika begodu iphrojekthi le ihlose ukunikela abantu abakhuluma IsiNdebele amandla nomdlandla wokutlola ama-athikili ku-wikipedia simahla. Kanti-ke, i-SWiP yi-akhronimu ejamele iinhlangano ezintathu ekungizo ezakhe iphrojekthi le, iinhlangano lezo yi: SADiLaR begodu ngokuzeleko yi-South African Centre for for Digital Language Resources, ne-Wikipedia  kanye nehlangano ye-PanSALB ekuyi-Pan South African Language Board ngokuzeleko. 

I-SADiLaR yatlanywa ngomnyaka wee-2016 begodu kuligadango lokwakha nokuphatha iintlabagelo zebuthelelolwazi nemitjhini yokurhubhulula edijithali kanye nokuthuthukisa iintlabagelo zamalimi adijithali eSewula Afrika. Igadango leli linikelwa isekele mNyango weSayentsi nokwakha eSewula Afrika. I-Wikipedia yatlanywa ngomnyaka we-2001 begodu yi-ensatlophidiya yasimahla etholakala ebuthelelwenilwazi, itlolwa beyibuye iphathwe mphakathi wabantu abazinikela simahla. &lt;ref&gt;{{Cite web|date=2025-05-13|title=Wikipedia {{!}} Definition, Encyclopedia, History, &amp; Facts {{!}} Britannica|url=https://www.britannica.com/topic/Wikipedia|access-date=2025-05-22|website=www.britannica.com|language=en}}&lt;/ref&gt; Kanti-ke, i-PanSALB yihlangano yeSewula Afrika eyakhwa ngesizathu sokukhuthaza ubuliminengi ukuze ithuthukise beyinzinzise amalimi woke weSewula Afrika alitjhumi nambili ngenani begodu ivikele amalungelo wamalimi eSewula Afrika, le ihlangano yatlanywa ngomnyaka we-1995. I-SWiP yona yatlanywa ngomnyaka wee-2023. &lt;ref&gt;{{Cite web|title=SADiLaR-Wikipedia-PanSALB (SWiP) – SADiLaR|url=https://sadilar.org/en/swip/|access-date=2025-05-22|website=sadilar.org}}&lt;/ref&gt; 

Iminqopho ye-SWiP kukhulisa ubukhona bebuthelelolwazi bamalimi we-Sewula Afrika, ngokutjheja amalimi wendabuko, ngokukghonakalisa imiphakathi yendawo bona yenze begodu yabelane ngelwazi le-Wikipedia emalimini wabo. Iphrojekthi le ihlose ukuvikela amalimi wendabuko ngokukhuthaza ukusetjenziswa kwawo, ukubulunga amagugu wawo, nokukhuthaza ukusebenzisana hlangana nabathintekako bamalimi. Igadango leli lifuna ukuvuselela nokuvikela amalimi wendabuko, ukuqinisekisa ukuphila kwawo nokukhuthaza ukuzibandakanya okuhlukahlukeneko  wokulondolozwa kwelimi. Iphrojekthi le ikhuthaza ukulondolozwa nokugidingwa kwamalimi wendabuko, isebenzela ukukhandela ukuwohloka kwawo begodu ikhuthaze ukuzibandakanya okusebenzako kwabasebenzi bamalimi nemiphakathi. &lt;ref&gt;{{Cite web|title=Wayback Machine|url=https://www.dst.gov.za/index.php/media-room/latest-news/2885-government-establishes-a-new-digital-centre-to-promote-indigenous-languages%5B%5D|archive-url=http://web.archive.org/web/20240212210914/https://www.dst.gov.za/index.php/media-room/latest-news/2885-government-establishes-a-new-digital-centre-to-promote-indigenous-languages%5B%5D|archive-date=2024-02-12|access-date=2025-05-22|website=www.dst.gov.za}}&lt;/ref&gt;

Iphrojekthi ye-SWiP yenze amagadango soloko yasangulwa, yaqeda ngepumelelo isigaba sayo sokuthoma, esakha umfutho wokujanyelwa kwelimi le-Afrika ku-Wikipedia begodu yakhulisa umphakathi wabafaki-galelo abanekghono. Ipumelelo eqakathekileko ifaka hlangana ukusingatha imihlangano yokuqoqisana ngokutlola emalangeni amabili eendaweni ezisithandathu, ukubandula abahlanganyeli abama-483 abavela emayunivesithi ali-10, nokuhlela umnyanya oseqadi e-Sayensi Forum South Africa 2024, owakhuthaza ilwazi elivulekileko nelifinyelelekako kibo boke abantu. Iphaliswano lokutlola nalo lihlanganyelwe nabahleli abama-56, baqakathekisa abafaki-galelo abaphezulu nabaphumeleleko ngelimi ngalinye elitloliweko leSewula Afrika. Ukwakha phezu kwesisekelo lesi, iSigaba sesibili sathoma ngoSinyikhaba 2024 begodu sizokuragela phambili bekube nguMgwengweni 2027, sizokwethula amagadango amatjha wokuthuthukisa imiphakathi yamalimi nokuthuthukisa amalimi weSewula Afrika. &lt;ref&gt;{{Cite web|title=SADiLaR-Wikipedia-PanSALB (SWiP) – SADiLaR|url=https://sadilar.org/en/swip/|access-date=2025-05-22|website=sadilar.org}}&lt;/ref&gt;

=== REFERENCES ===</text>
      <sha1>nr994usbiipr0oh22cjijc54z1xvhv3</sha1>
    </revision>
    <revision>
      <id>2838</id>
      <parentid>2837</parentid>
      <timestamp>2025-05-22T15:49:49Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <origin>2838</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4225" sha1="adsac26rjcx79ma4no8kixtmb3mv51o" xml:space="preserve">== '''SWiP''' ==
'''I-SWiP''' yiphrojekthi ehloselwe ukuthuthukisa amalimi wendabuko weSewula Afrika ebuthelelwenilwazi, khulu khulu ilimi lesiNdebele ku-Wikipedia. Ilimi lesiNdebele lisetjenziswa njengelimi lokuhlola ngebanga lokuthi alikajanyelwa khulu ku-Wikipedia njengamanye amalimi weSewul Afrika begodu iphrojekthi le ihlose ukunikela abantu abakhuluma IsiNdebele amandla nomdlandla wokutlola ama-athikili ku-wikipedia simahla. Kanti-ke, i-SWiP yi-akhronimu ejamele iinhlangano ezintathu ekungizo ezakhe iphrojekthi le, iinhlangano lezo yi: SADiLaR begodu ngokuzeleko yi-South African Centre for for Digital Language Resources, ne-Wikipedia  kanye nehlangano ye-PanSALB ekuyi-Pan South African Language Board ngokuzeleko. 

I-SADiLaR yatlanywa ngomnyaka wee-2016 begodu kuligadango lokwakha nokuphatha iintlabagelo zebuthelelolwazi nemitjhini yokurhubhulula edijithali kanye nokuthuthukisa iintlabagelo zamalimi adijithali eSewula Afrika. Igadango leli linikelwa isekele mNyango weSayentsi nokwakha eSewula Afrika. I-Wikipedia yatlanywa ngomnyaka we-2001 begodu yi-ensatlophidiya yasimahla etholakala ebuthelelwenilwazi, itlolwa beyibuye iphathwe mphakathi wabantu abazinikela simahla. &lt;ref&gt;{{Cite web|date=2025-05-13|title=Wikipedia {{!}} Definition, Encyclopedia, History, &amp; Facts {{!}} Britannica|url=https://www.britannica.com/topic/Wikipedia|access-date=2025-05-22|website=www.britannica.com|language=en}}&lt;/ref&gt; Kanti-ke, i-PanSALB yihlangano yeSewula Afrika eyakhwa ngesizathu sokukhuthaza ubuliminengi ukuze ithuthukise beyinzinzise amalimi woke weSewula Afrika alitjhumi nambili ngenani begodu ivikele amalungelo wamalimi eSewula Afrika, le ihlangano yatlanywa ngomnyaka we-1995. I-SWiP yona yatlanywa ngomnyaka wee-2023. &lt;ref&gt;{{Cite web|title=SADiLaR-Wikipedia-PanSALB (SWiP) – SADiLaR|url=https://sadilar.org/en/swip/|access-date=2025-05-22|website=sadilar.org}}&lt;/ref&gt; 

Iminqopho ye-SWiP kukhulisa ubukhona bebuthelelolwazi bamalimi we-Sewula Afrika, ngokutjheja amalimi wendabuko, ngokukghonakalisa imiphakathi yendawo bona yenze begodu yabelane ngelwazi le-Wikipedia emalimini wabo. Iphrojekthi le ihlose ukuvikela amalimi wendabuko ngokukhuthaza ukusetjenziswa kwawo, ukubulunga amagugu wawo, nokukhuthaza ukusebenzisana hlangana nabathintekako bamalimi. Igadango leli lifuna ukuvuselela nokuvikela amalimi wendabuko, ukuqinisekisa ukuphila kwawo nokukhuthaza ukuzibandakanya okuhlukahlukeneko  wokulondolozwa kwelimi. Iphrojekthi le ikhuthaza ukulondolozwa nokugidingwa kwamalimi wendabuko, isebenzela ukukhandela ukuwohloka kwawo begodu ikhuthaze ukuzibandakanya okusebenzako kwabasebenzi bamalimi nemiphakathi. &lt;ref&gt;{{Cite web|title=Wayback Machine|url=https://www.dst.gov.za/index.php/media-room/latest-news/2885-government-establishes-a-new-digital-centre-to-promote-indigenous-languages%5B%5D|archive-url=http://web.archive.org/web/20240212210914/https://www.dst.gov.za/index.php/media-room/latest-news/2885-government-establishes-a-new-digital-centre-to-promote-indigenous-languages%5B%5D|archive-date=2024-02-12|access-date=2025-05-22|website=www.dst.gov.za}}&lt;/ref&gt;

Iphrojekthi ye-SWiP yenze amagadango soloko yasangulwa, yaqeda ngepumelelo isigaba sayo sokuthoma, esakha umfutho wokujanyelwa kwelimi le-Afrika ku-Wikipedia begodu yakhulisa umphakathi wabafaki-galelo abanekghono. Ipumelelo eqakathekileko ifaka hlangana ukusingatha imihlangano yokuqoqisana ngokutlola emalangeni amabili eendaweni ezisithandathu, ukubandula abahlanganyeli abama-483 abavela emayunivesithi ali-10, nokuhlela umnyanya oseqadi e-Sayensi Forum South Africa 2024, owakhuthaza ilwazi elivulekileko nelifinyelelekako kibo boke abantu. Iphaliswano lokutlola nalo lihlanganyelwe nabahleli abama-56, baqakathekisa abafaki-galelo abaphezulu nabaphumeleleko ngelimi ngalinye elitloliweko leSewula Afrika. Ukwakha phezu kwesisekelo lesi, iSigaba sesibili sathoma ngoSinyikhaba 2024 begodu sizokuragela phambili bekube nguMgwengweni 2027, sizokwethula amagadango amatjha wokuthuthukisa imiphakathi yamalimi nokuthuthukisa amalimi weSewula Afrika. &lt;ref&gt;{{Cite web|title=SADiLaR-Wikipedia-PanSALB (SWiP) – SADiLaR|url=https://sadilar.org/en/swip/|access-date=2025-05-22|website=sadilar.org}}&lt;/ref&gt;

=== UMTHOMBO WELWAZI ===</text>
      <sha1>adsac26rjcx79ma4no8kixtmb3mv51o</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Mosakaruka</title>
    <ns>2</ns>
    <id>564</id>
    <revision>
      <id>2677</id>
      <timestamp>2025-04-22T20:48:15Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>Created page with &quot;= UkuGandeleleka KomKhumbulo = [[Isimumathi:Depressione.jpg|thumb|Ukugandeleleka komkhumbulo kufana nejele]] '''UkuGandeleleka koKhumbulo''' (''Depression'', namkha ''Depressive Disorder'' ngesiNgisi) kugula kwengqondo okwenza umuntu ahlale adanile, angabi nekareko namkha alahlekelwe lithemba isikhathi eside. Woke umuntu uba neenkhathi zokudana nokungathabi, kodwana ukuGandeleleka komKhumbulo kuhlukile ngombana kuthatha isikhathi eside. Ingathinta ipilo yomuntu, itjhebis...&quot;</comment>
      <origin>2677</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3499" sha1="m95p8d5ozk64fe3dioh19go0p0jc6x8" xml:space="preserve">= UkuGandeleleka KomKhumbulo =
[[Isimumathi:Depressione.jpg|thumb|Ukugandeleleka komkhumbulo kufana nejele]]
'''UkuGandeleleka koKhumbulo''' (''Depression'', namkha ''Depressive Disorder'' ngesiNgisi) kugula kwengqondo okwenza umuntu ahlale adanile, angabi nekareko namkha alahlekelwe lithemba isikhathi eside. Woke umuntu uba neenkhathi zokudana nokungathabi, kodwana ukuGandeleleka komKhumbulo kuhlukile ngombana kuthatha isikhathi eside. Ingathinta ipilo yomuntu, itjhebiswano lakhe nomndenakhe, abangani bakhe, nomphakathi ahlala kiwo. Kungabanga imiraro esikolweni nakamfundi, namkha abe nemiraro  emsebenzini.&lt;ref name=&quot;:0&quot;&gt;World Health Organisation Website - [https://www.who.int/news-room/fact-sheets/detail/depression Depressive Disorder]&lt;/ref&gt; Kungathinta indlela acabanga ngayo, azizwa ngayo nenza ngayo izinto, njengokulala, ukudla nemisebenzi ayenza namalanga. Umhlobo lo wokugula awukhethi ukuthi umhlobo bani, ubulili bani, usebenza kuphi, urhola malini, wenza isiko bani nokuthi ufunde kangangani. &lt;ref&gt;[https://www.nimh.nih.gov/health/topics/depression#hts-intro National Institute of Mental Health - Depression]&lt;/ref&gt; 

Okumbi khulu kukuthi ukugandeleleka komKhumbulo kungenza umuntu azibulale. Ngokwewebhusayidi ye-''World Health Organization,'' abantu abama-700 000 bayazibulala qobe mnyaka ngebanga lokugandeleleka komkhumbulo. Nayiragako ithi pheze abantu abaziingidi ezima-280 ephasini mazombe kubaphethe ukugulokhu begodu kubonakala kubamba khulu abantu abasikazi kunabaduna, okumaphesente amane wabembaji, nasithandathu wabengubo. &lt;ref name=&quot;:0&quot; /&gt; 

== Amatshwayo WokuGandeleleka KomKhumbulo ==
[[Isimumathi:Depression-loss of loved one.jpg|thumb|Ukugandeleleka komkhumbulo kukwenza uhlangahlangane]]
Kunamatshwayo atjengisa bona umuntu uphethwe kugulokhu. Umuntu angabonakala ngokutjhugutjhuguluka kwemizwa msinyana, ahlale adanile isikhathi eside, azizwe angasililitho, aphelelwe lithemba. Godu angabonakala ngokukwata nangokusilingwa zizinto ezincani ezingatjho litho, namkha ahlangahlangane. Ukungasabi nekareko emsebenzini yangamalanga nakho kulitshwayo elitjengisa bona ukugulokhu kumphethe. Abanye baphilelwa ubusuku boke, abanye balale isikhathi eside. Abanye kubenza bahlale badiniwe baphelelwe namdlandla wokusebenza bese kuthathe isikhathi eside ukwenza umsetjenzana omncani. Abanye abakuthandi ukudla abanye bayafobela. Abanye bazibetha khulu nabenze iimphoso, bazizwe bangasililitho. &lt;ref&gt;Mayo Clinic - [https://www.mayoclinic.org/diseases-conditions/depression/symptoms-causes/syc-20356007#:~:text=Feelings%20of%20sadness%2C%20tearfulness%2C%20emptiness,there%20can%20be%20some%20differences. Symptoms of Depression]&lt;/ref&gt;

Kuthiwani ngokuGandeleleka komKhumbulo eSewula Afrika? Kunerhubhululo elitjengisa bona abantu beSewula Afrika basemathubeni amanengi wokuphathwa kugandeleleka komkhumbulo nokutshwenyeka ukudlula kwezinye iinarha. Irhubhululwelo lenziwe yi-''Wits/Medical Research Council Developmental Pathways for Health Research Unit (DPHRU).'' UDorhodere u-Ashleigh Craig, ongumrhubhululi we-(DPHRU) uthi imininingwana yerhubhululweli iveza bona inani labantu abaphethwe kugandeleleka nokutshwenyeka eSewula Afrika lidlula inani le-USA, le-Germany nele-Australia, okuveza ukuba masikizi kokugulokhu eSewula Afrika. &lt;ref&gt;University of Witwatersrand Johannesburg - [https://www.wits.ac.za/news/latest-news/research-news/2022/2022-11/mental-health-in-sa-is-at-shocking-levels-but-people-are-not-seeking-help-.html Mental Health in South Africa]

&lt;/ref&gt;</text>
      <sha1>m95p8d5ozk64fe3dioh19go0p0jc6x8</sha1>
    </revision>
    <revision>
      <id>2680</id>
      <parentid>2677</parentid>
      <timestamp>2025-04-22T22:07:37Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <minor />
      <comment>I've put a new paragraph</comment>
      <origin>2680</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3894" sha1="ilu9n1sz5oc5ctzjhy0d0ounjrg4hzx" xml:space="preserve">= UkuGandeleleka KomKhumbulo =
[[Isimumathi:Depressione.jpg|thumb|Ukugandeleleka komkhumbulo kufana nokuba sejele lomkhumbulo]]
'''UkuGandeleleka koKhumbulo''' (''Depression'', namkha ''Depressive Disorder'' ngesiNgisi) kugula kwengqondo okwenza umuntu ahlale adanile, angabi nekareko namkha alahlekelwe lithemba isikhathi eside. Woke umuntu uba neenkhathi zokudana nokungathabi, kodwana ukuGandeleleka komKhumbulo kuhlukile ngombana kuthatha isikhathi eside. Ingathinta ipilo yomuntu, itjhebiswano lakhe nomndenakhe, abangani bakhe, nomphakathi ahlala kiwo. Kungabanga imiraro esikolweni nakamfundi, namkha abe nemiraro  emsebenzini.&lt;ref name=&quot;:0&quot;&gt;World Health Organisation Website - [https://www.who.int/news-room/fact-sheets/detail/depression Depressive Disorder]&lt;/ref&gt; Kungathinta indlela acabanga ngayo, azizwa ngayo nenza ngayo izinto, njengokulala, ukudla nemisebenzi ayenza namalanga. Umhlobo lo wokugula awukhethi ukuthi umhlobo bani, ubulili bani, usebenza kuphi, urhola malini, wenza isiko bani nokuthi ufunde kangangani. &lt;ref&gt;[https://www.nimh.nih.gov/health/topics/depression#hts-intro National Institute of Mental Health - Depression]&lt;/ref&gt; 

Okumbi khulu kukuthi ukugandeleleka komKhumbulo kungenza umuntu azibulale. Ngokwewebhusayidi ye-''World Health Organization,'' abantu abama-700 000 bayazibulala qobe mnyaka ngebanga lokugandeleleka komkhumbulo. Nayiragako ithi pheze abantu abaziingidi ezima-280 ephasini mazombe kubaphethe ukugulokhu begodu kubonakala kubamba khulu abantu abasikazi kunabaduna, okumaphesente amane wabembaji, nasithandathu wabengubo. &lt;ref name=&quot;:0&quot; /&gt;

== UkuGandeleleka KomKhumbulo ESewula Afrika ==
Kuthiwani ngokuGandeleleka komKhumbulo eSewula Afrika? Kunerhubhululo elitjengisa bona abantu beSewula Afrika basemathubeni amanengi wokuphathwa kugandeleleka komkhumbulo nokutshwenyeka ukudlula kwezinye iinarha. Irhubhululwelo lenziwe yi-''Wits/Medical Research Council Developmental Pathways for Health Research Unit (DPHRU).'' UDorhodere u-Ashleigh Craig, ongumrhubhululi we-(DPHRU) uthi imininingwana yerhubhululweli iveza bona inani labantu abaphethwe kugandeleleka nokutshwenyeka eSewula Afrika lidlula inani le-USA, le-Germany nele-Australia. &lt;ref&gt;University of Witwatersrand Johannesburg - [https://www.wits.ac.za/news/latest-news/research-news/2022/2022-11/mental-health-in-sa-is-at-shocking-levels-but-people-are-not-seeking-help-.html Mental Health in South Africa]
&lt;/ref&gt;
== Amatshwayo WokuGandeleleka KomKhumbulo ==
[[Isimumathi:Depression-loss of loved one.jpg|thumb|Ukugandeleleka komkhumbulo kukwenza uhlangahlangane]]
Kunamatshwayo atjengisa bona umuntu uphethwe kugulokhu. Umuntu angabonakala 

* Ngokutjhugutjhuguluka kwemizwa msinyana 
* Ngokuhlala adanile isikhathi eside, 
* Nokuzizwa angasililitho, aphelelwe lithemba 

* ngokukwata nangokusilingwa zizinto ezincani ezingatjho litho, namkha ahlangahlangane. 
* Ngokungasabi nekareko emsebenzini yangamalanga
* Ngokuphilelwa ubusuku boke, abanye balale isikhathi eside. 
* Ngokuhlala udiniwe nokuphelelwa namdlandla wokusebenza bese kuthathe isikhathi eside ukwenza umsetjenzana omncani. 
* Abanye abakuthandi ukudla abanye bayafobela. 
* Abanye bazibetha khulu nabenze iimphoso, bazizwe bangasililitho. &lt;ref&gt;Mayo Clinic - [https://www.mayoclinic.org/diseases-conditions/depression/symptoms-causes/syc-20356007#:~:text=Feelings%20of%20sadness%2C%20tearfulness%2C%20emptiness,there%20can%20be%20some%20differences. Symptoms of Depression]&lt;/ref&gt;

== Lokho Kufuze Umuntu Akwenze Nakagandelelekileko ==
Kunezinto umuntu nakazizwa agandelelekile okufuze azenze ngokuya ngokwewebhusayidi ye-NHS ye-UK:

* Kufuze athintane nabodorhodere bengqondo ngokurhabako bona afumane isizo
* Kufuze adle ukudla okunepilo
* Angaseli khulu utjwala
* Kufuze kube nemisetjenzana ayenzako 
* Ahlale akhuluma nabantu
* Aqalane nalokho okumlethela ukwesaba &lt;ref&gt;NHS - [[How to cope with depression]]&lt;/ref&gt;</text>
      <sha1>ilu9n1sz5oc5ctzjhy0d0ounjrg4hzx</sha1>
    </revision>
    <revision>
      <id>2685</id>
      <parentid>2680</parentid>
      <timestamp>2025-04-23T07:09:57Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>2685</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3912" sha1="ks0ktv9smpjg6q938u1dpz0brlqi32o" xml:space="preserve">= UkuGandeleleka KomKhumbulo =
[[Isimumathi:Depressione.jpg|thumb|Ukugandeleleka komkhumbulo kufana nokuba sejele lomkhumbulo]]
'''UkuGandeleleka koKhumbulo''' (''Depression'', namkha ''Depressive Disorder'' ngesiNgisi) kugula kwengqondo okwenza umuntu ahlale adanile, angabi nekareko namkha alahlekelwe lithemba isikhathi eside. Woke umuntu uba neenkhathi zokudana nokungathabi, kodwana ukuGandeleleka komKhumbulo kuhlukile ngombana kuthatha isikhathi eside. Ingathinta ipilo yomuntu, itjhebiswano lakhe nomndenakhe, abangani bakhe, nomphakathi ahlala kiwo. Kungabanga imiraro esikolweni nakamfundi, namkha abe nemiraro  emsebenzini.&lt;ref name=&quot;:0&quot;&gt;World Health Organisation Website - [https://www.who.int/news-room/fact-sheets/detail/depression Depressive Disorder]&lt;/ref&gt; Kungathinta indlela acabanga ngayo, azizwa ngayo nenza ngayo izinto, njengokulala, ukudla nemisebenzi ayenza namalanga. Umhlobo lo wokugula awukhethi ukuthi umhlobo bani, ubulili bani, usebenza kuphi, urhola malini, wenza isiko bani nokuthi ufunde kangangani. &lt;ref&gt;[https://www.nimh.nih.gov/health/topics/depression#hts-intro National Institute of Mental Health - Depression]&lt;/ref&gt; 

Okumbi khulu kukuthi ukugandeleleka komKhumbulo kungenza umuntu azibulale. Ngokwewebhusayidi ye-''World Health Organization,'' abantu abama-700 000 bayazibulala qobe mnyaka ngebanga lokugandeleleka komkhumbulo. Nayiragako ithi pheze abantu abaziingidi ezima-280 ephasini mazombe kubaphethe ukugulokhu begodu kubonakala kubamba khulu abantu abasikazi kunabaduna, okumaphesente amane wabembaji, nasithandathu wabengubo. &lt;ref name=&quot;:0&quot; /&gt;

== UkuGandeleleka KomKhumbulo ESewula Afrika ==
Kuthiwani ngokuGandeleleka komKhumbulo eSewula Afrika? Kunerhubhululo elitjengisa bona abantu beSewula Afrika basemathubeni amanengi wokuphathwa kugandeleleka komkhumbulo nokutshwenyeka ukudlula kwezinye iinarha. Irhubhululwelo lenziwe yi-''Wits/Medical Research Council Developmental Pathways for Health Research Unit (DPHRU).'' UDorhodere u-Ashleigh Craig, ongumrhubhululi we-(DPHRU) uthi imininingwana yerhubhululweli iveza bona inani labantu abaphethwe kugandeleleka nokutshwenyeka eSewula Afrika lidlula inani le-USA, le-Germany nele-Australia. &lt;ref&gt;University of Witwatersrand Johannesburg - [https://www.wits.ac.za/news/latest-news/research-news/2022/2022-11/mental-health-in-sa-is-at-shocking-levels-but-people-are-not-seeking-help-.html Mental Health in South Africa]
&lt;/ref&gt;
== Amatshwayo WokuGandeleleka KomKhumbulo ==
[[Isimumathi:Depression-loss of loved one.jpg|thumb|Ukugandeleleka komkhumbulo kukwenza uhlangahlangane]]
Kunamatshwayo atjengisa bona umuntu uphethwe kugulokhu. Umuntu angabonakala 

* Ngokutjhugutjhuguluka kwemizwa msinyana 
* Ngokuhlala adanile isikhathi eside, 
* Nokuzizwa angasililitho, aphelelwe lithemba 

* ngokukwata nangokusilingwa zizinto ezincani ezingatjho litho, namkha ahlangahlangane. 
* Ngokungasabi nekareko emsebenzini yangamalanga
* Ngokuphilelwa ubusuku boke, abanye balale isikhathi eside. 
* Ngokuhlala udiniwe nokuphelelwa namdlandla wokusebenza bese kuthathe isikhathi eside ukwenza umsetjenzana omncani. 
* Abanye abakuthandi ukudla abanye bayafobela. 
* Abanye bazibetha khulu nabenze iimphoso, bazizwe bangasililitho. &lt;ref&gt;Mayo Clinic - [https://www.mayoclinic.org/diseases-conditions/depression/symptoms-causes/syc-20356007#:~:text=Feelings%20of%20sadness%2C%20tearfulness%2C%20emptiness,there%20can%20be%20some%20differences. Symptoms of Depression]&lt;/ref&gt;

== Lokho Kufuze Umuntu Akwenze Nakagandelelekileko ==
Kunezinto umuntu nakazizwa agandelelekile okufuze azenze ngokuya ngokwewebhusayidi ye-NHS ye-UK:

* Kufuze athintane nabodorhodere bengqondo ngokurhabako bona afumane isizo
* Kufuze adle ukudla okunepilo
* Angaseli khulu utjwala
* Kufuze kube nemisetjenzana ayenzako 
* Ahlale akhuluma nabantu
* Aqalane nalokho okumlethela ukwesaba &lt;ref&gt;NHS - [[How to cope with depression]]&lt;/ref&gt; 

== Iinkhombo ==</text>
      <sha1>ks0ktv9smpjg6q938u1dpz0brlqi32o</sha1>
    </revision>
    <revision>
      <id>2690</id>
      <parentid>2685</parentid>
      <timestamp>2025-04-23T08:40:01Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>Replaced content with &quot;This is my usepage&quot;</comment>
      <origin>2690</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="18" sha1="macynryfm92shqhd7i5rjgvb87z1tu2" xml:space="preserve">This is my usepage</text>
      <sha1>macynryfm92shqhd7i5rjgvb87z1tu2</sha1>
    </revision>
    <revision>
      <id>2697</id>
      <parentid>2690</parentid>
      <timestamp>2025-04-23T09:17:14Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>2697</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="106" sha1="r5yl7e5karl1z0kujbma7he2astldds" xml:space="preserve">This is my usepage

[[Umsebenzisi:Mosakaruka/Draft Page 1|Draft page 1]]   | Draft Page 2  |  Draft Page 3</text>
      <sha1>r5yl7e5karl1z0kujbma7he2astldds</sha1>
    </revision>
    <revision>
      <id>2702</id>
      <parentid>2697</parentid>
      <timestamp>2025-04-23T09:21:42Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>2702</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="186" sha1="9fwg5bd8lyvw76rc0phshlz3ijp2jiz" xml:space="preserve">This is my usepage

[[Umsebenzisi:Mosakaruka/Draft Page 1|Draft page 1]]   | [[Umsebenzisi:Mosakaruka/Draft Page 2|Draft Page 2]]  |  [[Umsebenzisi:Mosakaruka/Draft Page 3|Draft Page 3]]</text>
      <sha1>9fwg5bd8lyvw76rc0phshlz3ijp2jiz</sha1>
    </revision>
    <revision>
      <id>2728</id>
      <parentid>2702</parentid>
      <timestamp>2025-04-23T09:36:03Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>2728</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="186" sha1="0ryikoxjwl3fdczw638felq4rmn2edy" xml:space="preserve">This is my usepage

[[Umsebenzisi:Mosakaruka/Draft Page 1|Draft Page 1]]   | [[Umsebenzisi:Mosakaruka/Draft Page 2|Draft Page 2]]  |  [[Umsebenzisi:Mosakaruka/Draft Page 3|Draft Page 3]]</text>
      <sha1>0ryikoxjwl3fdczw638felq4rmn2edy</sha1>
    </revision>
  </page>
  <page>
    <title>USteffans Mahlangu</title>
    <ns>0</ns>
    <id>565</id>
    <revision>
      <id>2678</id>
      <timestamp>2025-04-22T20:54:05Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>Created page with &quot;USteffans Mahlangu njenganje sele ayikosi etjha ye Charl Cilliers. [[Isimumathi:Steffanns5 88732.jpg|thumb|Chief Steffans Mahlangu.]] uBafana Mahlangu obegade kunguye omdosi phambili webutho elithunyelwe yiNgwenyama yama Ndzundza uMabhoko III,unikele ngokusemthethweni incwadi yesitifiketi ku Mahlangu Steffans.&lt;ref&gt;https://ridgetimes.co.za&lt;/ref&gt;  Ubaba u Steffans Mahlangu nje sele ayikosi ye Charl Cilliers ngemva komnyanya wokubekwa kwakhe mhlana amalanga alitjhumi nekhom...&quot;</comment>
      <origin>2678</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1823" sha1="ezs4wcxfdc8dkahsc5oill507yio9t1" xml:space="preserve">USteffans Mahlangu njenganje sele ayikosi etjha ye Charl Cilliers.
[[Isimumathi:Steffanns5 88732.jpg|thumb|Chief Steffans Mahlangu.]]
uBafana Mahlangu obegade kunguye omdosi phambili webutho elithunyelwe yiNgwenyama yama Ndzundza uMabhoko III,unikele ngokusemthethweni incwadi yesitifiketi ku Mahlangu Steffans.&lt;ref&gt;https://ridgetimes.co.za&lt;/ref&gt;

Ubaba u Steffans Mahlangu nje sele ayikosi ye Charl Cilliers ngemva komnyanya wokubekwa kwakhe mhlana amalanga alitjhumi nekhomba kuRhoboyi 2024.

Uthweswe isikhundla lesi endaweni ye Charl Cilliers multi purpose centre ngebe Ndzundza Mabhoko Traditional Council.Nakakhuluma nababiki beendaba uBafana Mahlangu uthe ikosi etja ekungu Steffans Mahlangu uvumelekile bonyana akhalime eendabeni ezifaka hlangana zomphakathi ngokubambisana nesipholisa kunye neendabeni ezifaka isigodlo sakhe.Ubuyele watjho bonyana unelungelo lokungenelela abuye abonelele zesintu kunye neminyanya ekhona njengokutjho komthetho wezokubusa namasiko.

UMahlangu Bafana ubuye wayelelisa ikosi etja bonyana ingathathi hlangothi lokha nayithatha iinqundo eziphathelene nokutjhutjhiswa kwabantu abatholakala bamlandu.

&quot;Kufuze bonyana uphathe boke abantu ngendlela elinganako ungathi hlangothi.Usebenze ngokuthembeka kunye nomphakathi ukusize.&quot;

&quot;Kufuze bonyana utjheje khulu amasiko wethu angathathelwa phasi.Usebenze namanye amakhosi nabanye abantu abasemphakathini njengombana siphila emphakathini onabantu abanamasiko ahlukeneko.Wenze isiciniseko sokobana isithuzi sobukhosi bethu namasiko wethu akathathelwa phasi begodu ayahlonitjhwa.&quot;

Ikosi uMahlangu uthembisile bonyana uzokulandela yoke imithetho kunye nemigomo begodu wathembisa bonyana uzokusebenza nabo boke abantu be Charl Cilliers ngokuthembeka nangeqiniso.

https://www.citizen.co.za

https://www&lt;nowiki/&gt;.Ridge Times.co.za
&lt;references /&gt;</text>
      <sha1>ezs4wcxfdc8dkahsc5oill507yio9t1</sha1>
    </revision>
    <revision>
      <id>2790</id>
      <parentid>2678</parentid>
      <timestamp>2025-04-30T06:02:34Z</timestamp>
      <contributor>
        <username>KeMang??</username>
        <id>604</id>
      </contributor>
      <minor />
      <comment>maphutha</comment>
      <origin>2790</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1773" sha1="bv7ewr221uz8oisj5wqk8tlt42sv03x" xml:space="preserve">USteffans Mahlangu njenganje sele ayikosi etjha ye Charl Cilliers.
[[Isimumathi:Steffanns5 88732.jpg|thumb|Chief Steffans Mahlangu.]]
uBafana Mahlangu obegade kunguye omdosi phambili webutho elithunyelwe yiNgwenyama yama Ndzundza uMabhoko III,unikele ngokusemthethweni incwadi yesitifiketi ku Mahlangu Steffans.&lt;ref&gt;https://ridgetimes.co.za&lt;/ref&gt;

Ubaba u Steffans Mahlangu nje sele ayikosi ye Charl Cilliers ngemva komnyanya wokubekwa kwakhe mhlana amalanga alitjhumi nekhomba kuRhoboyi 2024.

Uthweswe isikhundla lesi endaweni ye Charl Cilliers multi purpose centre ngebe Ndzundza Mabhoko Traditional Council.Nakakhuluma nababiki beendaba uBafana Mahlangu uthe ikosi etja ekungu Steffans Mahlangu uvumelekile bonyana akhalime eendabeni ezifaka hlangana zomphakathi ngokubambisana nesipholisa kunye neendabeni ezifaka isigodlo sakhe.Ubuyele watjho bonyana unelungelo lokungenelela abuye abonelele zesintu kunye neminyanya ekhona njengokutjho komthetho wezokubusa namasiko.

UMahlangu Bafana ubuye wayelelisa ikosi etja bonyana ingathathi hlangothi lokha nayithatha iinqundo eziphathelene nokutjhutjhiswa kwabantu abatholakala bamlandu.

&quot;Kufuze bonyana uphathe boke abantu ngendlela elinganako ungathi hlangothi.Usebenze ngokuthembeka kunye nomphakathi ukusize.&quot;

&quot;Kufuze bonyana utjheje khulu amasiko wethu angathathelwa phasi.Usebenze namanye amakhosi nabanye abantu abasemphakathini njengombana siphila emphakathini onabantu abanamasiko ahlukeneko.Wenze isiciniseko sokobana isithuzi sobukhosi bethu namasiko wethu akathathelwa phasi begodu ayahlonitjhwa.&quot;

Ikosi uMahlangu uthembisile bonyana uzokulandela yoke imithetho kunye nemigomo begodu wathembisa bonyana uzokusebenza nabo boke abantu be Charl Cilliers ngokuthembeka nangeqiniso.

== Imikhombo ==
&lt;references /&gt;</text>
      <sha1>bv7ewr221uz8oisj5wqk8tlt42sv03x</sha1>
    </revision>
    <revision>
      <id>6377</id>
      <parentid>2790</parentid>
      <timestamp>2026-03-31T18:45:34Z</timestamp>
      <contributor>
        <username>Dumbassman</username>
        <id>1091</id>
      </contributor>
      <minor />
      <origin>6377</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1779" sha1="p4ml6w7y2r6cepzhg5ubmw67hkmveqy" xml:space="preserve">'''USteffans Mahlangu''' njenganje sele ayikosi etjha ye Charl Cilliers.
[[Isimumathi:Steffanns5 88732.jpg|thumb|Chief Steffans Mahlangu.]]
uBafana Mahlangu obegade kunguye omdosi phambili webutho elithunyelwe yiNgwenyama yama Ndzundza uMabhoko III,unikele ngokusemthethweni incwadi yesitifiketi ku Mahlangu Steffans.&lt;ref&gt;https://ridgetimes.co.za&lt;/ref&gt;

Ubaba u Steffans Mahlangu nje sele ayikosi ye Charl Cilliers ngemva komnyanya wokubekwa kwakhe mhlana amalanga alitjhumi nekhomba kuRhoboyi 2024.

Uthweswe isikhundla lesi endaweni ye Charl Cilliers multi purpose centre ngebe Ndzundza Mabhoko Traditional Council.Nakakhuluma nababiki beendaba uBafana Mahlangu uthe ikosi etja ekungu Steffans Mahlangu uvumelekile bonyana akhalime eendabeni ezifaka hlangana zomphakathi ngokubambisana nesipholisa kunye neendabeni ezifaka isigodlo sakhe.Ubuyele watjho bonyana unelungelo lokungenelela abuye abonelele zesintu kunye neminyanya ekhona njengokutjho komthetho wezokubusa namasiko.

UMahlangu Bafana ubuye wayelelisa ikosi etja bonyana ingathathi hlangothi lokha nayithatha iinqundo eziphathelene nokutjhutjhiswa kwabantu abatholakala bamlandu.

&quot;Kufuze bonyana uphathe boke abantu ngendlela elinganako ungathi hlangothi.Usebenze ngokuthembeka kunye nomphakathi ukusize.&quot;

&quot;Kufuze bonyana utjheje khulu amasiko wethu angathathelwa phasi.Usebenze namanye amakhosi nabanye abantu abasemphakathini njengombana siphila emphakathini onabantu abanamasiko ahlukeneko.Wenze isiciniseko sokobana isithuzi sobukhosi bethu namasiko wethu akathathelwa phasi begodu ayahlonitjhwa.&quot;

Ikosi uMahlangu uthembisile bonyana uzokulandela yoke imithetho kunye nemigomo begodu wathembisa bonyana uzokusebenza nabo boke abantu be Charl Cilliers ngokuthembeka nangeqiniso.

== Imikhombo ==
&lt;references /&gt;</text>
      <sha1>p4ml6w7y2r6cepzhg5ubmw67hkmveqy</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Orrora</title>
    <ns>2</ns>
    <id>566</id>
    <revision>
      <id>2679</id>
      <timestamp>2025-04-22T21:48:15Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <comment>Created page with &quot;= UKUGULA KOKUKHOHLWA - ''DEMENTIA'' = [[Isimumathi:Old zacatecas lady.jpg|thumb|Isifo sokukhohlwa siphatha abantu abalupheleko]] Ukugula kokukholwa ngesikhuwa okubizwa ngokobana yi-''Dementia'' sisifo esitsatsela abantu abalupheleko nasele bayile ngeminyaka.  Sibenza balahlekelwe mkhumbulo, balahlekelwe lilimi abalikhulumako, bangakghoni ukurarulula imiraro ebebayirarulula nabasaphile kuhle, bangakghoni ukuzicabangela.&lt;ref&gt;ALZHEIMER'S ASSOCIATION, [https://www.alz.org/a...&quot;</comment>
      <origin>2679</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2344" sha1="ttqmg22igkc1gji1g0rzm35r0gplt58" xml:space="preserve">= UKUGULA KOKUKHOHLWA - ''DEMENTIA'' =
[[Isimumathi:Old zacatecas lady.jpg|thumb|Isifo sokukhohlwa siphatha abantu abalupheleko]]
Ukugula kokukholwa ngesikhuwa okubizwa ngokobana yi-''Dementia'' sisifo esitsatsela abantu abalupheleko nasele bayile ngeminyaka.  Sibenza balahlekelwe mkhumbulo, balahlekelwe lilimi abalikhulumako, bangakghoni ukurarulula imiraro ebebayirarulula nabasaphile kuhle, bangakghoni ukuzicabangela.&lt;ref&gt;ALZHEIMER'S ASSOCIATION, [https://www.alz.org/alzheimers-dementia/what-is-dementia what is dementia?]&lt;/ref&gt; Abantwaba bakhohlwa  nabantu abahlala nabo ngendlina bangasabazi nokubazi. 

Ngaphezu kwalokho, abantu ababatlhogomelako bayathinteka ngokomkhumbulo nangokwamazizo ngebanga lokugula okuphethe amalungu wemindenabo. Nanyana amalunga womndeni angalinga ngamandla ukubaphatha ngethando labo abanesifo sokukhohlwa, angazizwa adiniwe, atjharagene namkha azizwe amlandu. Yeke amalunga womndeni akuthola kubudisi ukutlhogomela abanesifo sokukhohlwa.&lt;ref&gt;National Institute of Medicine, [https://pmc.ncbi.nlm.nih.gov/articles/PMC3181916/ The caregivers of people with dementia]&lt;/ref&gt;

== NGABANJANI ABAPHATHWA SISIFO SOKUKHOHLWA? ==
I-''World Health Organization'' iveza bona abantu abasengozini yokuphathwa kugulokhu babantu:

* Abanokugandeleleka nokutshwenyeka
* Abasela khulu
* Abanomzimba omkhulu
* Abanetjhukela
* Abanomfutho weengazi ophezulu
* Ababhemako
* Abangawusebenzisi khulu umzimbabo
* Abagegedwako emphakathini
* Nabalupheleko&lt;ref name=&quot;:0&quot;&gt;World Health Organization, [[Dementia]]&lt;/ref&gt;

== INDLELA ONGALEMUKA NGAYO UMUNTU ONESIFO SOKUKHOHLWA ==
Kunezinto abantu abanesifo sokukhohwa abazenzako. Irhubhululo le-WHO liveze nanzi ezilandelako:

* Ukukhohlwa izinto eziqeda ukwenzeka
* Ukubeka into bese ungasazi bona uyibekephi
* Ukulahleka nawukhamba endleleni oyijayeleko
* Ukungasakghoni ukulungisa imiraro
* Ukuthola kubudisi ukukhuluma nabantu 
* Ukutjhuguluka kwemizwa

Iintjengiswezi azibi khona zoke kibo boke abantu abaphethwe bulwele bokukhohlwa, kodwana ziyatjhiyatjhiyana.

Okudanisako kukuthi abulapheki ubulwelobu kodwana kuneendlela ezingasiza umuntu ophethwe bulwelobu. Kokuthoma kufuze adle ukudla okunepilo. Okwesibili athabulule umzimba  qobe, arage nokuzihlanganisa nabantu akhulume nabo. Okokugcina kufuze aye kwadorhodere asele namapilisi nemitjhoga anikelwa yona.&lt;ref name=&quot;:0&quot; /&gt;</text>
      <sha1>ttqmg22igkc1gji1g0rzm35r0gplt58</sha1>
    </revision>
    <revision>
      <id>2715</id>
      <parentid>2679</parentid>
      <timestamp>2025-04-23T09:29:45Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <comment>Replaced content with &quot;This is my user space&quot;</comment>
      <origin>2715</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="21" sha1="ckxcvnfa5mhd4gtlf3zskiy4g6abcju" xml:space="preserve">This is my user space</text>
      <sha1>ckxcvnfa5mhd4gtlf3zskiy4g6abcju</sha1>
    </revision>
    <revision>
      <id>2717</id>
      <parentid>2715</parentid>
      <timestamp>2025-04-23T09:31:51Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <origin>2717</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="76" sha1="m4he30di4sqtijy4qfh2fi9tkypjm6e" xml:space="preserve">This is my user space

draft page 1     |    draft page 2  |    draft page 3</text>
      <sha1>m4he30di4sqtijy4qfh2fi9tkypjm6e</sha1>
    </revision>
    <revision>
      <id>2720</id>
      <parentid>2717</parentid>
      <timestamp>2025-04-23T09:32:58Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <origin>2720</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="112" sha1="06cq1aj8iguz2d73wscze630s04npqy" xml:space="preserve">This is my user space

[[Umsebenzisi:Orrora/Draft page 1|draft page 1]]     |    draft page 2  |    draft page 3</text>
      <sha1>06cq1aj8iguz2d73wscze630s04npqy</sha1>
    </revision>
    <revision>
      <id>2723</id>
      <parentid>2720</parentid>
      <timestamp>2025-04-23T09:33:40Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <origin>2723</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="148" sha1="4zyljkp6mwgynrv89gh717tl0pd3uvk" xml:space="preserve">This is my user space

[[Umsebenzisi:Orrora/Draft page 1|draft page 1]]     |    [[Umsebenzisi:Orrora/Draft page 2|draft page 2]]  |    draft page 3</text>
      <sha1>4zyljkp6mwgynrv89gh717tl0pd3uvk</sha1>
    </revision>
    <revision>
      <id>2724</id>
      <parentid>2723</parentid>
      <timestamp>2025-04-23T09:34:14Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <origin>2724</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="184" sha1="1pdwo8nml34xaisrh50tblf18cvogd7" xml:space="preserve">This is my user space

[[Umsebenzisi:Orrora/Draft page 1|draft page 1]]     |    [[Umsebenzisi:Orrora/Draft page 2|draft page 2]]  |    [[Umsebenzisi:Orrora/Draft page 3|draft page 3]]</text>
      <sha1>1pdwo8nml34xaisrh50tblf18cvogd7</sha1>
    </revision>
  </page>
  <page>
    <title>Ukugandeleleka komkhumbulo</title>
    <ns>0</ns>
    <id>567</id>
    <revision>
      <id>2689</id>
      <timestamp>2025-04-23T08:39:00Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>creating a new page</comment>
      <origin>2689</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3912" sha1="ks0ktv9smpjg6q938u1dpz0brlqi32o" xml:space="preserve">= UkuGandeleleka KomKhumbulo =
[[Isimumathi:Depressione.jpg|thumb|Ukugandeleleka komkhumbulo kufana nokuba sejele lomkhumbulo]]
'''UkuGandeleleka koKhumbulo''' (''Depression'', namkha ''Depressive Disorder'' ngesiNgisi) kugula kwengqondo okwenza umuntu ahlale adanile, angabi nekareko namkha alahlekelwe lithemba isikhathi eside. Woke umuntu uba neenkhathi zokudana nokungathabi, kodwana ukuGandeleleka komKhumbulo kuhlukile ngombana kuthatha isikhathi eside. Ingathinta ipilo yomuntu, itjhebiswano lakhe nomndenakhe, abangani bakhe, nomphakathi ahlala kiwo. Kungabanga imiraro esikolweni nakamfundi, namkha abe nemiraro  emsebenzini.&lt;ref name=&quot;:0&quot;&gt;World Health Organisation Website - [https://www.who.int/news-room/fact-sheets/detail/depression Depressive Disorder]&lt;/ref&gt; Kungathinta indlela acabanga ngayo, azizwa ngayo nenza ngayo izinto, njengokulala, ukudla nemisebenzi ayenza namalanga. Umhlobo lo wokugula awukhethi ukuthi umhlobo bani, ubulili bani, usebenza kuphi, urhola malini, wenza isiko bani nokuthi ufunde kangangani. &lt;ref&gt;[https://www.nimh.nih.gov/health/topics/depression#hts-intro National Institute of Mental Health - Depression]&lt;/ref&gt; 

Okumbi khulu kukuthi ukugandeleleka komKhumbulo kungenza umuntu azibulale. Ngokwewebhusayidi ye-''World Health Organization,'' abantu abama-700 000 bayazibulala qobe mnyaka ngebanga lokugandeleleka komkhumbulo. Nayiragako ithi pheze abantu abaziingidi ezima-280 ephasini mazombe kubaphethe ukugulokhu begodu kubonakala kubamba khulu abantu abasikazi kunabaduna, okumaphesente amane wabembaji, nasithandathu wabengubo. &lt;ref name=&quot;:0&quot; /&gt;

== UkuGandeleleka KomKhumbulo ESewula Afrika ==
Kuthiwani ngokuGandeleleka komKhumbulo eSewula Afrika? Kunerhubhululo elitjengisa bona abantu beSewula Afrika basemathubeni amanengi wokuphathwa kugandeleleka komkhumbulo nokutshwenyeka ukudlula kwezinye iinarha. Irhubhululwelo lenziwe yi-''Wits/Medical Research Council Developmental Pathways for Health Research Unit (DPHRU).'' UDorhodere u-Ashleigh Craig, ongumrhubhululi we-(DPHRU) uthi imininingwana yerhubhululweli iveza bona inani labantu abaphethwe kugandeleleka nokutshwenyeka eSewula Afrika lidlula inani le-USA, le-Germany nele-Australia. &lt;ref&gt;University of Witwatersrand Johannesburg - [https://www.wits.ac.za/news/latest-news/research-news/2022/2022-11/mental-health-in-sa-is-at-shocking-levels-but-people-are-not-seeking-help-.html Mental Health in South Africa]
&lt;/ref&gt;
== Amatshwayo WokuGandeleleka KomKhumbulo ==
[[Isimumathi:Depression-loss of loved one.jpg|thumb|Ukugandeleleka komkhumbulo kukwenza uhlangahlangane]]
Kunamatshwayo atjengisa bona umuntu uphethwe kugulokhu. Umuntu angabonakala 

* Ngokutjhugutjhuguluka kwemizwa msinyana 
* Ngokuhlala adanile isikhathi eside, 
* Nokuzizwa angasililitho, aphelelwe lithemba 

* ngokukwata nangokusilingwa zizinto ezincani ezingatjho litho, namkha ahlangahlangane. 
* Ngokungasabi nekareko emsebenzini yangamalanga
* Ngokuphilelwa ubusuku boke, abanye balale isikhathi eside. 
* Ngokuhlala udiniwe nokuphelelwa namdlandla wokusebenza bese kuthathe isikhathi eside ukwenza umsetjenzana omncani. 
* Abanye abakuthandi ukudla abanye bayafobela. 
* Abanye bazibetha khulu nabenze iimphoso, bazizwe bangasililitho. &lt;ref&gt;Mayo Clinic - [https://www.mayoclinic.org/diseases-conditions/depression/symptoms-causes/syc-20356007#:~:text=Feelings%20of%20sadness%2C%20tearfulness%2C%20emptiness,there%20can%20be%20some%20differences. Symptoms of Depression]&lt;/ref&gt;

== Lokho Kufuze Umuntu Akwenze Nakagandelelekileko ==
Kunezinto umuntu nakazizwa agandelelekile okufuze azenze ngokuya ngokwewebhusayidi ye-NHS ye-UK:

* Kufuze athintane nabodorhodere bengqondo ngokurhabako bona afumane isizo
* Kufuze adle ukudla okunepilo
* Angaseli khulu utjwala
* Kufuze kube nemisetjenzana ayenzako 
* Ahlale akhuluma nabantu
* Aqalane nalokho okumlethela ukwesaba &lt;ref&gt;NHS - [[How to cope with depression]]&lt;/ref&gt; 

== Iinkhombo ==</text>
      <sha1>ks0ktv9smpjg6q938u1dpz0brlqi32o</sha1>
    </revision>
    <revision>
      <id>2736</id>
      <parentid>2689</parentid>
      <timestamp>2025-04-23T09:44:53Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>2736</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3880" sha1="tgz9kqbhvpeey3r4cmv1w4y75dvmgz2" xml:space="preserve">[[Isimumathi:Depressione.jpg|thumb|Ukugandeleleka komkhumbulo kufana nokuba sejele lomkhumbulo]]
'''UkuGandeleleka koKhumbulo''' (''Depression'', namkha ''Depressive Disorder'' ngesiNgisi) kugula kwengqondo okwenza umuntu ahlale adanile, angabi nekareko namkha alahlekelwe lithemba isikhathi eside. Woke umuntu uba neenkhathi zokudana nokungathabi, kodwana ukuGandeleleka komKhumbulo kuhlukile ngombana kuthatha isikhathi eside. Ingathinta ipilo yomuntu, itjhebiswano lakhe nomndenakhe, abangani bakhe, nomphakathi ahlala kiwo. Kungabanga imiraro esikolweni nakamfundi, namkha abe nemiraro  emsebenzini.&lt;ref name=&quot;:0&quot;&gt;World Health Organisation Website - [https://www.who.int/news-room/fact-sheets/detail/depression Depressive Disorder]&lt;/ref&gt; Kungathinta indlela acabanga ngayo, azizwa ngayo nenza ngayo izinto, njengokulala, ukudla nemisebenzi ayenza namalanga. Umhlobo lo wokugula awukhethi ukuthi umhlobo bani, ubulili bani, usebenza kuphi, urhola malini, wenza isiko bani nokuthi ufunde kangangani. &lt;ref&gt;[https://www.nimh.nih.gov/health/topics/depression#hts-intro National Institute of Mental Health - Depression]&lt;/ref&gt; 

Okumbi khulu kukuthi ukugandeleleka komKhumbulo kungenza umuntu azibulale. Ngokwewebhusayidi ye-''World Health Organization,'' abantu abama-700 000 bayazibulala qobe mnyaka ngebanga lokugandeleleka komkhumbulo. Nayiragako ithi pheze abantu abaziingidi ezima-280 ephasini mazombe kubaphethe ukugulokhu begodu kubonakala kubamba khulu abantu abasikazi kunabaduna, okumaphesente amane wabembaji, nasithandathu wabengubo. &lt;ref name=&quot;:0&quot; /&gt;

== UkuGandeleleka KomKhumbulo ESewula Afrika ==
Kuthiwani ngokuGandeleleka komKhumbulo eSewula Afrika? Kunerhubhululo elitjengisa bona abantu beSewula Afrika basemathubeni amanengi wokuphathwa kugandeleleka komkhumbulo nokutshwenyeka ukudlula kwezinye iinarha. Irhubhululwelo lenziwe yi-''Wits/Medical Research Council Developmental Pathways for Health Research Unit (DPHRU).'' UDorhodere u-Ashleigh Craig, ongumrhubhululi we-(DPHRU) uthi imininingwana yerhubhululweli iveza bona inani labantu abaphethwe kugandeleleka nokutshwenyeka eSewula Afrika lidlula inani le-USA, le-Germany nele-Australia. &lt;ref&gt;University of Witwatersrand Johannesburg - [https://www.wits.ac.za/news/latest-news/research-news/2022/2022-11/mental-health-in-sa-is-at-shocking-levels-but-people-are-not-seeking-help-.html Mental Health in South Africa]
&lt;/ref&gt;
== Amatshwayo WokuGandeleleka KomKhumbulo ==
[[Isimumathi:Depression-loss of loved one.jpg|thumb|Ukugandeleleka komkhumbulo kukwenza uhlangahlangane]]
Kunamatshwayo atjengisa bona umuntu uphethwe kugulokhu. Umuntu angabonakala 

* Ngokutjhugutjhuguluka kwemizwa msinyana 
* Ngokuhlala adanile isikhathi eside, 
* Nokuzizwa angasililitho, aphelelwe lithemba 

* ngokukwata nangokusilingwa zizinto ezincani ezingatjho litho, namkha ahlangahlangane. 
* Ngokungasabi nekareko emsebenzini yangamalanga
* Ngokuphilelwa ubusuku boke, abanye balale isikhathi eside. 
* Ngokuhlala udiniwe nokuphelelwa namdlandla wokusebenza bese kuthathe isikhathi eside ukwenza umsetjenzana omncani. 
* Abanye abakuthandi ukudla abanye bayafobela. 
* Abanye bazibetha khulu nabenze iimphoso, bazizwe bangasililitho. &lt;ref&gt;Mayo Clinic - [https://www.mayoclinic.org/diseases-conditions/depression/symptoms-causes/syc-20356007#:~:text=Feelings%20of%20sadness%2C%20tearfulness%2C%20emptiness,there%20can%20be%20some%20differences. Symptoms of Depression]&lt;/ref&gt;

== Lokho Kufuze Umuntu Akwenze Nakagandelelekileko ==
Kunezinto umuntu nakazizwa agandelelekile okufuze azenze ngokuya ngokwewebhusayidi ye-NHS ye-UK:

* Kufuze athintane nabodorhodere bengqondo ngokurhabako bona afumane isizo
* Kufuze adle ukudla okunepilo
* Angaseli khulu utjwala
* Kufuze kube nemisetjenzana ayenzako 
* Ahlale akhuluma nabantu
* Aqalane nalokho okumlethela ukwesaba &lt;ref&gt;NHS - [[How to cope with depression]]&lt;/ref&gt;

== Iinkhombo ==</text>
      <sha1>tgz9kqbhvpeey3r4cmv1w4y75dvmgz2</sha1>
    </revision>
    <revision>
      <id>2737</id>
      <parentid>2736</parentid>
      <timestamp>2025-04-23T09:49:11Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>2737</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3960" sha1="qnr8rxv2013uu2qsdt3im675371wptd" xml:space="preserve">[[Isimumathi:Depressione.jpg|thumb|Ukugandeleleka komkhumbulo kufana nokuba sejele lomkhumbulo]]
'''UkuGandeleleka koKhumbulo''' (''Depression'', namkha ''Depressive Disorder'' ngesiNgisi) kugula kwengqondo okwenza umuntu ahlale adanile, angabi nekareko namkha alahlekelwe lithemba isikhathi eside. Woke umuntu uba neenkhathi zokudana nokungathabi, kodwana ukuGandeleleka komKhumbulo kuhlukile ngombana kuthatha isikhathi eside. Ingathinta ipilo yomuntu, itjhebiswano lakhe nomndenakhe, abangani bakhe, nomphakathi ahlala kiwo. Kungabanga imiraro esikolweni nakamfundi, namkha abe nemiraro  emsebenzini.&lt;ref name=&quot;:0&quot;&gt;World Health Organisation Website - [https://www.who.int/news-room/fact-sheets/detail/depression Depressive Disorder]&lt;/ref&gt; Kungathinta indlela acabanga ngayo, azizwa ngayo nenza ngayo izinto, njengokulala, ukudla nemisebenzi ayenza namalanga. Umhlobo lo wokugula awukhethi ukuthi umhlobo bani, ubulili bani, usebenza kuphi, urhola malini, wenza isiko bani nokuthi ufunde kangangani. &lt;ref&gt;[https://www.nimh.nih.gov/health/topics/depression#hts-intro National Institute of Mental Health - Depression]&lt;/ref&gt; 

Okumbi khulu kukuthi ukugandeleleka komKhumbulo kungenza umuntu azibulale. Ngokwewebhusayidi ye-''World Health Organization,'' abantu abama-700 000 bayazibulala qobe mnyaka ngebanga lokugandeleleka komkhumbulo. Nayiragako ithi pheze abantu abaziingidi ezima-280 ephasini mazombe kubaphethe ukugulokhu begodu kubonakala kubamba khulu abantu abasikazi kunabaduna, okumaphesente amane wabembaji, nasithandathu wabengubo. &lt;ref name=&quot;:0&quot; /&gt;

== UkuGandeleleka KomKhumbulo ESewula Afrika ==
Kuthiwani ngokuGandeleleka komKhumbulo eSewula Afrika? Kunerhubhululo elitjengisa bona abantu beSewula Afrika basemathubeni amanengi wokuphathwa kugandeleleka komkhumbulo nokutshwenyeka ukudlula kwezinye iinarha. Irhubhululwelo lenziwe yi-''Wits/Medical Research Council Developmental Pathways for Health Research Unit (DPHRU).'' UDorhodere u-Ashleigh Craig, ongumrhubhululi we-(DPHRU) uthi imininingwana yerhubhululweli iveza bona inani labantu abaphethwe kugandeleleka nokutshwenyeka eSewula Afrika lidlula inani le-USA, le-Germany nele-Australia. &lt;ref&gt;University of Witwatersrand Johannesburg - [https://www.wits.ac.za/news/latest-news/research-news/2022/2022-11/mental-health-in-sa-is-at-shocking-levels-but-people-are-not-seeking-help-.html Mental Health in South Africa]
&lt;/ref&gt;
== Amatshwayo WokuGandeleleka KomKhumbulo ==
[[Isimumathi:Depression-loss of loved one.jpg|thumb|Ukugandeleleka komkhumbulo kukwenza uhlangahlangane]]
Kunamatshwayo atjengisa bona umuntu uphethwe kugulokhu. Umuntu angabonakala 

* Ngokutjhugutjhuguluka kwemizwa msinyana 
* Ngokuhlala adanile isikhathi eside, 
* Nokuzizwa angasililitho, aphelelwe lithemba 

* ngokukwata nangokusilingwa zizinto ezincani ezingatjho litho, namkha ahlangahlangane. 
* Ngokungasabi nekareko emsebenzini yangamalanga
* Ngokuphilelwa ubusuku boke, abanye balale isikhathi eside. 
* Ngokuhlala udiniwe nokuphelelwa namdlandla wokusebenza bese kuthathe isikhathi eside ukwenza umsetjenzana omncani. 
* Abanye abakuthandi ukudla abanye bayafobela. 
* Abanye bazibetha khulu nabenze iimphoso, bazizwe bangasililitho. &lt;ref&gt;Mayo Clinic - [https://www.mayoclinic.org/diseases-conditions/depression/symptoms-causes/syc-20356007#:~:text=Feelings%20of%20sadness%2C%20tearfulness%2C%20emptiness,there%20can%20be%20some%20differences. Symptoms of Depression]&lt;/ref&gt;

== Lokho Kufuze Umuntu Akwenze Nakagandelelekileko ==
Kunezinto umuntu nakazizwa agandelelekile okufuze azenze ngokuya ngokwewebhusayidi ye-NHS ye-UK:

* Kufuze athintane nabodorhodere bengqondo ngokurhabako bona afumane isizo
* Kufuze adle ukudla okunepilo
* Angaseli khulu utjwala
* Kufuze kube nemisetjenzana ayenzako 
* Ahlale akhuluma nabantu
* Aqalane nalokho okumlethela ukwesaba &lt;ref&gt;NHS - [https://www.nhs.uk/mental-health/self-help/tips-and-support/cope-with-depression/ How to cope with depression]&lt;/ref&gt;

== Iinkhombo ==</text>
      <sha1>qnr8rxv2013uu2qsdt3im675371wptd</sha1>
    </revision>
    <revision>
      <id>2746</id>
      <parentid>2737</parentid>
      <timestamp>2025-04-23T10:33:16Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>2746</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3936" sha1="45re6764gaetkahmi1u2z1zmjnetg2m" xml:space="preserve">[[Isimumathi:Depressione.jpg|thumb|Ukugandeleleka komkhumbulo kufana nokuba sejele lomkhumbulo]]
'''UkuGandeleleka koKhumbulo''' (''Depression'', namkha ''Depressive Disorder'' ngesiNgisi) kugula kwengqondo okwenza umuntu ahlale adanile, angabi nekareko namkha alahlekelwe lithemba isikhathi eside. Woke umuntu uba neenkhathi zokudana nokungathabi, kodwana ukuGandeleleka komKhumbulo kuhlukile ngombana kuthatha isikhathi eside. Ingathinta ipilo yomuntu, itjhebiswano lakhe nomndenakhe, abangani bakhe, nomphakathi ahlala kiwo. Kungabanga imiraro esikolweni nakamfundi, namkha abe nemiraro  emsebenzini.&lt;ref name=&quot;:0&quot;&gt;World Health Organisation Website - [https://www.who.int/news-room/fact-sheets/detail/depression Depressive Disorder]&lt;/ref&gt; Kungathinta indlela acabanga ngayo, azizwa ngayo nenza ngayo izinto, njengokulala, ukudla nemisebenzi ayenza namalanga. Umhlobo lo wokugula awukhethi ukuthi umhlobo bani, ubulili bani, usebenza kuphi, urhola malini, wenza isiko bani nokuthi ufunde kangangani. &lt;ref&gt;[https://www.nimh.nih.gov/health/topics/depression#hts-intro National Institute of Mental Health - Depression]&lt;/ref&gt; 

Okumbi khulu kukuthi ukugandeleleka komKhumbulo kungenza umuntu azibulale. Ngokwewebhusayidi ye-''World Health Organization,'' abantu abama-700 000 bayazibulala qobe mnyaka ngebanga lokugandeleleka komkhumbulo. Nayiragako ithi pheze abantu abaziingidi ezima-280 ephasini mazombe kubaphethe ukugulokhu begodu kubonakala kubamba khulu abantu abasikazi kunabaduna, okumaphesente amane wabembaji, nasithandathu wabengubo. &lt;ref name=&quot;:0&quot; /&gt;

== UkuGandeleleka KomKhumbulo ESewula Afrika ==
Kuthiwani ngokuGandeleleka komKhumbulo eSewula Afrika? Kunerhubhululo elitjengisa bona abantu beSewula Afrika basemathubeni amanengi wokuphathwa kugandeleleka komkhumbulo nokutshwenyeka ukudlula kwezinye iinarha. Irhubhululwelo lenziwe yi-''Wits/Medical Research Council Developmental Pathways for Health Research Unit (DPHRU).'' UDorhodere u-Ashleigh Craig, ongumrhubhululi we-(DPHRU) uthi imininingwana yerhubhululweli iveza bona inani labantu abaphethwe kugandeleleka nokutshwenyeka eSewula Afrika lidlula inani le-USA, le-Germany nele-Australia. &lt;ref&gt;University of Witwatersrand Johannesburg - [https://www.wits.ac.za/news/latest-news/research-news/2022/2022-11/mental-health-in-sa-is-at-shocking-levels-but-people-are-not-seeking-help-.html Mental Health in South Africa]
&lt;/ref&gt;
== Amatshwayo WokuGandeleleka KomKhumbulo ==
[[Isimumathi:Depression-loss of loved one.jpg|thumb|Ukugandeleleka komkhumbulo kukwenza uhlangahlangane]]
Kunamatshwayo atjengisa bona umuntu uphethwe kugulokhu. Umuntu angabonakala 

* Ngokutjhugutjhuguluka kwemizwa msinyana 
* Ngokuhlala adanile isikhathi eside, 
* Nokuzizwa angasililitho, aphelelwe lithemba 

* ngokukwata nangokusilingwa zizinto ezincani ezingatjho litho, namkha ahlangahlangane. 
* Ngokungasabi nekareko emsebenzini yangamalanga
* Ngokuphilelwa ubusuku boke, abanye balale isikhathi eside. 
* Ngokuhlala udiniwe nokuphelelwa namdlandla wokusebenza bese kuthathe isikhathi eside ukwenza umsetjenzana omncani. 
* Abanye abakuthandi ukudla abanye bayafobela. 
* Abanye bazibetha khulu nabenze iimphoso, bazizwe bangasililitho. &lt;ref&gt;{{Cite web |date=2021-02-02 |title=How to cope with depression |url=https://www.nhs.uk/mental-health/self-help/tips-and-support/cope-with-depression/ |access-date=2025-04-23 |website=nhs.uk |language=en}}&lt;/ref&gt;

== Lokho Kufuze Umuntu Akwenze Nakagandelelekileko ==
Kunezinto umuntu nakazizwa agandelelekile okufuze azenze ngokuya ngokwewebhusayidi ye-NHS ye-UK:

* Kufuze athintane nabodorhodere bengqondo ngokurhabako bona afumane isizo
* Kufuze adle ukudla okunepilo
* Angaseli khulu utjwala
* Kufuze kube nemisetjenzana ayenzako 
* Ahlale akhuluma nabantu
* Aqalane nalokho okumlethela ukwesaba &lt;ref&gt;NHS - [https://www.nhs.uk/mental-health/self-help/tips-and-support/cope-with-depression/ How to cope with depression]&lt;/ref&gt;

== Iinkhombo ==</text>
      <sha1>45re6764gaetkahmi1u2z1zmjnetg2m</sha1>
    </revision>
    <revision>
      <id>3173</id>
      <parentid>2746</parentid>
      <timestamp>2025-06-21T18:48:28Z</timestamp>
      <contributor>
        <ip>85.97.84.231</ip>
      </contributor>
      <origin>3173</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4047" sha1="8lm79rd0grejjcykvvmpoqi27vrd8ti" xml:space="preserve">[[File:Common chimpanzee (Pan troglodytes schweinfurthii) feeding.jpg|thumb|Omar al-Bashir is a chimpanzee.]]

[[Isimumathi:Depressione.jpg|thumb|Ukugandeleleka komkhumbulo kufana nokuba sejele lomkhumbulo]]
'''UkuGandeleleka koKhumbulo''' (''Depression'', namkha ''Depressive Disorder'' ngesiNgisi) kugula kwengqondo okwenza umuntu ahlale adanile, angabi nekareko namkha alahlekelwe lithemba isikhathi eside. Woke umuntu uba neenkhathi zokudana nokungathabi, kodwana ukuGandeleleka komKhumbulo kuhlukile ngombana kuthatha isikhathi eside. Ingathinta ipilo yomuntu, itjhebiswano lakhe nomndenakhe, abangani bakhe, nomphakathi ahlala kiwo. Kungabanga imiraro esikolweni nakamfundi, namkha abe nemiraro  emsebenzini.&lt;ref name=&quot;:0&quot;&gt;World Health Organisation Website - [https://www.who.int/news-room/fact-sheets/detail/depression Depressive Disorder]&lt;/ref&gt; Kungathinta indlela acabanga ngayo, azizwa ngayo nenza ngayo izinto, njengokulala, ukudla nemisebenzi ayenza namalanga. Umhlobo lo wokugula awukhethi ukuthi umhlobo bani, ubulili bani, usebenza kuphi, urhola malini, wenza isiko bani nokuthi ufunde kangangani. &lt;ref&gt;[https://www.nimh.nih.gov/health/topics/depression#hts-intro National Institute of Mental Health - Depression]&lt;/ref&gt; 

Okumbi khulu kukuthi ukugandeleleka komKhumbulo kungenza umuntu azibulale. Ngokwewebhusayidi ye-''World Health Organization,'' abantu abama-700 000 bayazibulala qobe mnyaka ngebanga lokugandeleleka komkhumbulo. Nayiragako ithi pheze abantu abaziingidi ezima-280 ephasini mazombe kubaphethe ukugulokhu begodu kubonakala kubamba khulu abantu abasikazi kunabaduna, okumaphesente amane wabembaji, nasithandathu wabengubo. &lt;ref name=&quot;:0&quot; /&gt;

== UkuGandeleleka KomKhumbulo ESewula Afrika ==
Kuthiwani ngokuGandeleleka komKhumbulo eSewula Afrika? Kunerhubhululo elitjengisa bona abantu beSewula Afrika basemathubeni amanengi wokuphathwa kugandeleleka komkhumbulo nokutshwenyeka ukudlula kwezinye iinarha. Irhubhululwelo lenziwe yi-''Wits/Medical Research Council Developmental Pathways for Health Research Unit (DPHRU).'' UDorhodere u-Ashleigh Craig, ongumrhubhululi we-(DPHRU) uthi imininingwana yerhubhululweli iveza bona inani labantu abaphethwe kugandeleleka nokutshwenyeka eSewula Afrika lidlula inani le-USA, le-Germany nele-Australia. &lt;ref&gt;University of Witwatersrand Johannesburg - [https://www.wits.ac.za/news/latest-news/research-news/2022/2022-11/mental-health-in-sa-is-at-shocking-levels-but-people-are-not-seeking-help-.html Mental Health in South Africa]
&lt;/ref&gt;
== Amatshwayo WokuGandeleleka KomKhumbulo ==
[[Isimumathi:Depression-loss of loved one.jpg|thumb|Ukugandeleleka komkhumbulo kukwenza uhlangahlangane]]
Kunamatshwayo atjengisa bona umuntu uphethwe kugulokhu. Umuntu angabonakala 

* Ngokutjhugutjhuguluka kwemizwa msinyana 
* Ngokuhlala adanile isikhathi eside, 
* Nokuzizwa angasililitho, aphelelwe lithemba 

* ngokukwata nangokusilingwa zizinto ezincani ezingatjho litho, namkha ahlangahlangane. 
* Ngokungasabi nekareko emsebenzini yangamalanga
* Ngokuphilelwa ubusuku boke, abanye balale isikhathi eside. 
* Ngokuhlala udiniwe nokuphelelwa namdlandla wokusebenza bese kuthathe isikhathi eside ukwenza umsetjenzana omncani. 
* Abanye abakuthandi ukudla abanye bayafobela. 
* Abanye bazibetha khulu nabenze iimphoso, bazizwe bangasililitho. &lt;ref&gt;{{Cite web |date=2021-02-02 |title=How to cope with depression |url=https://www.nhs.uk/mental-health/self-help/tips-and-support/cope-with-depression/ |access-date=2025-04-23 |website=nhs.uk |language=en}}&lt;/ref&gt;

== Lokho Kufuze Umuntu Akwenze Nakagandelelekileko ==
Kunezinto umuntu nakazizwa agandelelekile okufuze azenze ngokuya ngokwewebhusayidi ye-NHS ye-UK:

* Kufuze athintane nabodorhodere bengqondo ngokurhabako bona afumane isizo
* Kufuze adle ukudla okunepilo
* Angaseli khulu utjwala
* Kufuze kube nemisetjenzana ayenzako 
* Ahlale akhuluma nabantu
* Aqalane nalokho okumlethela ukwesaba &lt;ref&gt;NHS - [https://www.nhs.uk/mental-health/self-help/tips-and-support/cope-with-depression/ How to cope with depression]&lt;/ref&gt;

== Iinkhombo ==</text>
      <sha1>8lm79rd0grejjcykvvmpoqi27vrd8ti</sha1>
    </revision>
    <revision>
      <id>3210</id>
      <parentid>3173</parentid>
      <timestamp>2025-06-24T12:31:28Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>deleted irrelevant picture</comment>
      <origin>3210</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3936" sha1="45re6764gaetkahmi1u2z1zmjnetg2m" xml:space="preserve">[[Isimumathi:Depressione.jpg|thumb|Ukugandeleleka komkhumbulo kufana nokuba sejele lomkhumbulo]]
'''UkuGandeleleka koKhumbulo''' (''Depression'', namkha ''Depressive Disorder'' ngesiNgisi) kugula kwengqondo okwenza umuntu ahlale adanile, angabi nekareko namkha alahlekelwe lithemba isikhathi eside. Woke umuntu uba neenkhathi zokudana nokungathabi, kodwana ukuGandeleleka komKhumbulo kuhlukile ngombana kuthatha isikhathi eside. Ingathinta ipilo yomuntu, itjhebiswano lakhe nomndenakhe, abangani bakhe, nomphakathi ahlala kiwo. Kungabanga imiraro esikolweni nakamfundi, namkha abe nemiraro  emsebenzini.&lt;ref name=&quot;:0&quot;&gt;World Health Organisation Website - [https://www.who.int/news-room/fact-sheets/detail/depression Depressive Disorder]&lt;/ref&gt; Kungathinta indlela acabanga ngayo, azizwa ngayo nenza ngayo izinto, njengokulala, ukudla nemisebenzi ayenza namalanga. Umhlobo lo wokugula awukhethi ukuthi umhlobo bani, ubulili bani, usebenza kuphi, urhola malini, wenza isiko bani nokuthi ufunde kangangani. &lt;ref&gt;[https://www.nimh.nih.gov/health/topics/depression#hts-intro National Institute of Mental Health - Depression]&lt;/ref&gt; 

Okumbi khulu kukuthi ukugandeleleka komKhumbulo kungenza umuntu azibulale. Ngokwewebhusayidi ye-''World Health Organization,'' abantu abama-700 000 bayazibulala qobe mnyaka ngebanga lokugandeleleka komkhumbulo. Nayiragako ithi pheze abantu abaziingidi ezima-280 ephasini mazombe kubaphethe ukugulokhu begodu kubonakala kubamba khulu abantu abasikazi kunabaduna, okumaphesente amane wabembaji, nasithandathu wabengubo. &lt;ref name=&quot;:0&quot; /&gt;

== UkuGandeleleka KomKhumbulo ESewula Afrika ==
Kuthiwani ngokuGandeleleka komKhumbulo eSewula Afrika? Kunerhubhululo elitjengisa bona abantu beSewula Afrika basemathubeni amanengi wokuphathwa kugandeleleka komkhumbulo nokutshwenyeka ukudlula kwezinye iinarha. Irhubhululwelo lenziwe yi-''Wits/Medical Research Council Developmental Pathways for Health Research Unit (DPHRU).'' UDorhodere u-Ashleigh Craig, ongumrhubhululi we-(DPHRU) uthi imininingwana yerhubhululweli iveza bona inani labantu abaphethwe kugandeleleka nokutshwenyeka eSewula Afrika lidlula inani le-USA, le-Germany nele-Australia. &lt;ref&gt;University of Witwatersrand Johannesburg - [https://www.wits.ac.za/news/latest-news/research-news/2022/2022-11/mental-health-in-sa-is-at-shocking-levels-but-people-are-not-seeking-help-.html Mental Health in South Africa]
&lt;/ref&gt;
== Amatshwayo WokuGandeleleka KomKhumbulo ==
[[Isimumathi:Depression-loss of loved one.jpg|thumb|Ukugandeleleka komkhumbulo kukwenza uhlangahlangane]]
Kunamatshwayo atjengisa bona umuntu uphethwe kugulokhu. Umuntu angabonakala 

* Ngokutjhugutjhuguluka kwemizwa msinyana 
* Ngokuhlala adanile isikhathi eside, 
* Nokuzizwa angasililitho, aphelelwe lithemba 

* ngokukwata nangokusilingwa zizinto ezincani ezingatjho litho, namkha ahlangahlangane. 
* Ngokungasabi nekareko emsebenzini yangamalanga
* Ngokuphilelwa ubusuku boke, abanye balale isikhathi eside. 
* Ngokuhlala udiniwe nokuphelelwa namdlandla wokusebenza bese kuthathe isikhathi eside ukwenza umsetjenzana omncani. 
* Abanye abakuthandi ukudla abanye bayafobela. 
* Abanye bazibetha khulu nabenze iimphoso, bazizwe bangasililitho. &lt;ref&gt;{{Cite web |date=2021-02-02 |title=How to cope with depression |url=https://www.nhs.uk/mental-health/self-help/tips-and-support/cope-with-depression/ |access-date=2025-04-23 |website=nhs.uk |language=en}}&lt;/ref&gt;

== Lokho Kufuze Umuntu Akwenze Nakagandelelekileko ==
Kunezinto umuntu nakazizwa agandelelekile okufuze azenze ngokuya ngokwewebhusayidi ye-NHS ye-UK:

* Kufuze athintane nabodorhodere bengqondo ngokurhabako bona afumane isizo
* Kufuze adle ukudla okunepilo
* Angaseli khulu utjwala
* Kufuze kube nemisetjenzana ayenzako 
* Ahlale akhuluma nabantu
* Aqalane nalokho okumlethela ukwesaba &lt;ref&gt;NHS - [https://www.nhs.uk/mental-health/self-help/tips-and-support/cope-with-depression/ How to cope with depression]&lt;/ref&gt;

== Iinkhombo ==</text>
      <sha1>45re6764gaetkahmi1u2z1zmjnetg2m</sha1>
    </revision>
    <revision>
      <id>3228</id>
      <parentid>3210</parentid>
      <timestamp>2025-06-25T19:20:49Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>3228</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3937" sha1="5h79t9weak5tfr6cfmo2gzf7ip1jjjy" xml:space="preserve">[[Isimumathi:Depressione.jpg|thumb|Ukugandeleleka komkhumbulo kufana nokuba sejele lomkhumbulo]]
'''UkuGandeleleka komKhumbulo''' (''Depression'', namkha ''Depressive Disorder'' ngesiNgisi) kugula kwengqondo okwenza umuntu ahlale adanile, angabi nekareko namkha alahlekelwe lithemba isikhathi eside. Woke umuntu uba neenkhathi zokudana nokungathabi, kodwana ukuGandeleleka komKhumbulo kuhlukile ngombana kuthatha isikhathi eside. Ingathinta ipilo yomuntu, itjhebiswano lakhe nomndenakhe, abangani bakhe, nomphakathi ahlala kiwo. Kungabanga imiraro esikolweni nakamfundi, namkha abe nemiraro  emsebenzini.&lt;ref name=&quot;:0&quot;&gt;World Health Organisation Website - [https://www.who.int/news-room/fact-sheets/detail/depression Depressive Disorder]&lt;/ref&gt; Kungathinta indlela acabanga ngayo, azizwa ngayo nenza ngayo izinto, njengokulala, ukudla nemisebenzi ayenza namalanga. Umhlobo lo wokugula awukhethi ukuthi umhlobo bani, ubulili bani, usebenza kuphi, urhola malini, wenza isiko bani nokuthi ufunde kangangani. &lt;ref&gt;[https://www.nimh.nih.gov/health/topics/depression#hts-intro National Institute of Mental Health - Depression]&lt;/ref&gt; 

Okumbi khulu kukuthi ukugandeleleka komKhumbulo kungenza umuntu azibulale. Ngokwewebhusayidi ye-''World Health Organization,'' abantu abama-700 000 bayazibulala qobe mnyaka ngebanga lokugandeleleka komkhumbulo. Nayiragako ithi pheze abantu abaziingidi ezima-280 ephasini mazombe kubaphethe ukugulokhu begodu kubonakala kubamba khulu abantu abasikazi kunabaduna, okumaphesente amane wabembaji, nasithandathu wabengubo. &lt;ref name=&quot;:0&quot; /&gt;

== UkuGandeleleka KomKhumbulo ESewula Afrika ==
Kuthiwani ngokuGandeleleka komKhumbulo eSewula Afrika? Kunerhubhululo elitjengisa bona abantu beSewula Afrika basemathubeni amanengi wokuphathwa kugandeleleka komkhumbulo nokutshwenyeka ukudlula kwezinye iinarha. Irhubhululwelo lenziwe yi-''Wits/Medical Research Council Developmental Pathways for Health Research Unit (DPHRU).'' UDorhodere u-Ashleigh Craig, ongumrhubhululi we-(DPHRU) uthi imininingwana yerhubhululweli iveza bona inani labantu abaphethwe kugandeleleka nokutshwenyeka eSewula Afrika lidlula inani le-USA, le-Germany nele-Australia. &lt;ref&gt;University of Witwatersrand Johannesburg - [https://www.wits.ac.za/news/latest-news/research-news/2022/2022-11/mental-health-in-sa-is-at-shocking-levels-but-people-are-not-seeking-help-.html Mental Health in South Africa]
&lt;/ref&gt;
== Amatshwayo WokuGandeleleka KomKhumbulo ==
[[Isimumathi:Depression-loss of loved one.jpg|thumb|Ukugandeleleka komkhumbulo kukwenza uhlangahlangane]]
Kunamatshwayo atjengisa bona umuntu uphethwe kugulokhu. Umuntu angabonakala 

* Ngokutjhugutjhuguluka kwemizwa msinyana 
* Ngokuhlala adanile isikhathi eside, 
* Nokuzizwa angasililitho, aphelelwe lithemba 

* ngokukwata nangokusilingwa zizinto ezincani ezingatjho litho, namkha ahlangahlangane. 
* Ngokungasabi nekareko emsebenzini yangamalanga
* Ngokuphilelwa ubusuku boke, abanye balale isikhathi eside. 
* Ngokuhlala udiniwe nokuphelelwa namdlandla wokusebenza bese kuthathe isikhathi eside ukwenza umsetjenzana omncani. 
* Abanye abakuthandi ukudla abanye bayafobela. 
* Abanye bazibetha khulu nabenze iimphoso, bazizwe bangasililitho. &lt;ref&gt;{{Cite web |date=2021-02-02 |title=How to cope with depression |url=https://www.nhs.uk/mental-health/self-help/tips-and-support/cope-with-depression/ |access-date=2025-04-23 |website=nhs.uk |language=en}}&lt;/ref&gt;

== Lokho Kufuze Umuntu Akwenze Nakagandelelekileko ==
Kunezinto umuntu nakazizwa agandelelekile okufuze azenze ngokuya ngokwewebhusayidi ye-NHS ye-UK:

* Kufuze athintane nabodorhodere bengqondo ngokurhabako bona afumane isizo
* Kufuze adle ukudla okunepilo
* Angaseli khulu utjwala
* Kufuze kube nemisetjenzana ayenzako 
* Ahlale akhuluma nabantu
* Aqalane nalokho okumlethela ukwesaba &lt;ref&gt;NHS - [https://www.nhs.uk/mental-health/self-help/tips-and-support/cope-with-depression/ How to cope with depression]&lt;/ref&gt;

== Iinkhombo ==</text>
      <sha1>5h79t9weak5tfr6cfmo2gzf7ip1jjjy</sha1>
    </revision>
    <revision>
      <id>3234</id>
      <parentid>3228</parentid>
      <timestamp>2025-06-26T12:59:57Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>spelling fix</comment>
      <origin>3234</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3940" sha1="8ju5i78yp4axd0pv9pxjagf1mn8t5bu" xml:space="preserve">[[Isimumathi:Depressione.jpg|thumb|Ukugandeleleka komkhumbulo kufana nokuba sejele lomkhumbulo]]
'''UkuGandeleleka komKhumbulo''' (''Depression'', namkha ''Depressive Disorder'' ngesiNgisi) kugula kwengqondo okwenza umuntu ahlale adanile, angabi nekareko namkha alahlekelwe lithemba isikhathi eside. Woke umuntu uba neenkhathi zokudana nokungathabi, kodwana ukuGandeleleka komKhumbulo kuhlukile ngombana kuthatha isikhathi eside. Ingathinta ipilo yomuntu, itjhebiswano lakhe nomndenakhe, abangani bakhe, nomphakathi ahlala kiwo. Kungabanga imiraro esikolweni nakamfundi, namkha abe nemiraro  emsebenzini.&lt;ref name=&quot;:0&quot;&gt;World Health Organisation Website - [https://www.who.int/news-room/fact-sheets/detail/depression Depressive Disorder]&lt;/ref&gt; Kungathinta indlela acabanga ngayo, azizwa ngayo nenza ngayo izinto, njengokulala, ukudla nemisebenzi ayenza namalanga. Umhlobo lo wokugula awukhethi ukuthi umhlobo bani, ubulili bani, usebenza kuphi, urhola malini, wenza isiko bani nokuthi ufunde kangangani. &lt;ref&gt;[https://www.nimh.nih.gov/health/topics/depression#hts-intro National Institute of Mental Health - Depression]&lt;/ref&gt; 

Okumbi khulu kukuthi ukuGandeleleka komKhumbulo kungenza umuntu azibulale. Ngokwewebhusayidi ye-''World Health Organization,'' abantu abama-700 000 bayazibulala qobe mnyaka ngebanga lokugandeleleka ngokomkhumbulo. Nayiragako ithi pheze abantu abaziingidi ezima-280 ephasini mazombe kubaphethe ukugulokhu begodu kubonakala kubamba khulu abantu abasikazi kunabaduna, okumaphesente amane wabembaji, nasithandathu wabengubo. &lt;ref name=&quot;:0&quot; /&gt;

== UkuGandeleleka KomKhumbulo ESewula Afrika ==
Kuthiwani ngokuGandeleleka komKhumbulo eSewula Afrika? Kunerhubhululo elitjengisa bona abantu beSewula Afrika basemathubeni amanengi wokuphathwa kugandeleleka komkhumbulo nokutshwenyeka ukudlula kwezinye iinarha. Irhubhululwelo lenziwe yi-''Wits/Medical Research Council Developmental Pathways for Health Research Unit (DPHRU).'' UDorhodere u-Ashleigh Craig, ongumrhubhululi we-(DPHRU) uthi imininingwana yerhubhululweli iveza bona inani labantu abaphethwe kugandeleleka nokutshwenyeka eSewula Afrika lidlula inani le-USA, le-Germany nele-Australia. &lt;ref&gt;University of Witwatersrand Johannesburg - [https://www.wits.ac.za/news/latest-news/research-news/2022/2022-11/mental-health-in-sa-is-at-shocking-levels-but-people-are-not-seeking-help-.html Mental Health in South Africa]
&lt;/ref&gt;
== Amatshwayo WokuGandeleleka KomKhumbulo ==
[[Isimumathi:Depression-loss of loved one.jpg|thumb|Ukugandeleleka komkhumbulo kukwenza uhlangahlangane]]
Kunamatshwayo atjengisa bona umuntu uphethwe kugulokhu. Umuntu angabonakala 

* Ngokutjhugutjhuguluka kwemizwa msinyana 
* Ngokuhlala adanile isikhathi eside, 
* Nokuzizwa angasililitho, aphelelwe lithemba 

* ngokukwata nangokusilingwa zizinto ezincani ezingatjho litho, namkha ahlangahlangane. 
* Ngokungasabi nekareko emsebenzini yangamalanga
* Ngokuphilelwa ubusuku boke, abanye balale isikhathi eside. 
* Ngokuhlala udiniwe nokuphelelwa namdlandla wokusebenza bese kuthathe isikhathi eside ukwenza umsetjenzana omncani. 
* Abanye abakuthandi ukudla abanye bayafobela. 
* Abanye bazibetha khulu nabenze iimphoso, bazizwe bangasililitho. &lt;ref&gt;{{Cite web |date=2021-02-02 |title=How to cope with depression |url=https://www.nhs.uk/mental-health/self-help/tips-and-support/cope-with-depression/ |access-date=2025-04-23 |website=nhs.uk |language=en}}&lt;/ref&gt;

== Lokho Kufuze Umuntu Akwenze Nakagandelelekileko ==
Kunezinto umuntu nakazizwa agandelelekile okufuze azenze ngokuya ngokwewebhusayidi ye-NHS ye-UK:

* Kufuze athintane nabodorhodere bengqondo ngokurhabako bona afumane isizo
* Kufuze adle ukudla okunepilo
* Angaseli khulu utjwala
* Kufuze kube nemisetjenzana ayenzako 
* Ahlale akhuluma nabantu
* Aqalane nalokho okumlethela ukwesaba &lt;ref&gt;NHS - [https://www.nhs.uk/mental-health/self-help/tips-and-support/cope-with-depression/ How to cope with depression]&lt;/ref&gt;

== Iinkhombo ==</text>
      <sha1>8ju5i78yp4axd0pv9pxjagf1mn8t5bu</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Nqobile69</title>
    <ns>2</ns>
    <id>568</id>
    <revision>
      <id>2691</id>
      <timestamp>2025-04-23T08:40:07Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;Ikhasi lami lokusebenzela&quot;</comment>
      <origin>2691</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="25" sha1="njzrped9lj32n0mar6id1q349ydcno2" xml:space="preserve">Ikhasi lami lokusebenzela</text>
      <sha1>njzrped9lj32n0mar6id1q349ydcno2</sha1>
    </revision>
    <revision>
      <id>2695</id>
      <parentid>2691</parentid>
      <timestamp>2025-04-23T09:16:21Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2695</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="41" sha1="mi646wtd1ok81h77dt4n939hxqb3bfm" xml:space="preserve">Ikhasi lami lokusebenzela

[[draftpage1]]</text>
      <sha1>mi646wtd1ok81h77dt4n939hxqb3bfm</sha1>
    </revision>
    <revision>
      <id>2699</id>
      <parentid>2695</parentid>
      <timestamp>2025-04-23T09:19:16Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2699</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="73" sha1="2325mmlhdcn254e3vyr6ouoi5s999el" xml:space="preserve">Ikhasi lami lokusebenzela

[[Umsebenzisi:Nqobile69Draftpage1|draftpage1]]</text>
      <sha1>2325mmlhdcn254e3vyr6ouoi5s999el</sha1>
    </revision>
    <revision>
      <id>2703</id>
      <parentid>2699</parentid>
      <timestamp>2025-04-23T09:21:51Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2703</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="88" sha1="rrnx7zzrlaf5gaet08lizrrs1sxobx8" xml:space="preserve">Ikhasi lami lokusebenzela

[[Umsebenzisi:Nqobile69Draftpage1|draftpage1]] [[draftpage2]]</text>
      <sha1>rrnx7zzrlaf5gaet08lizrrs1sxobx8</sha1>
    </revision>
    <revision>
      <id>2709</id>
      <parentid>2703</parentid>
      <timestamp>2025-04-23T09:24:52Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2709</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="88" sha1="2lcrgkd0qe0su5qilbxzlxf9f2h7nvl" xml:space="preserve">Ikhasi lami lokusebenzela

[[Umsebenzisi:Nqobile69Draftpage1|draftpage1]]|[[draftpage2]]</text>
      <sha1>2lcrgkd0qe0su5qilbxzlxf9f2h7nvl</sha1>
    </revision>
    <revision>
      <id>2716</id>
      <parentid>2709</parentid>
      <timestamp>2025-04-23T09:31:25Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2716</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="100" sha1="1nad52ke697wa6udm0u008vx87s4leb" xml:space="preserve">Ikhasi lami lokusebenzela

[[Umsebenzisi:Nqobile69Draftpage1|draftpage1]]|[[draftpage2|draftpage2|]]</text>
      <sha1>1nad52ke697wa6udm0u008vx87s4leb</sha1>
    </revision>
    <revision>
      <id>2721</id>
      <parentid>2716</parentid>
      <timestamp>2025-04-23T09:33:11Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2721</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="114" sha1="d38bl1hk6phls9sbm5rtvidpg76lgyi" xml:space="preserve">Ikhasi lami lokusebenzela

[[Umsebenzisi:Nqobile69Draftpage1|draftpage1]]|[[draftpage2|draftpage2|]][[draftpage3]]</text>
      <sha1>d38bl1hk6phls9sbm5rtvidpg76lgyi</sha1>
    </revision>
    <revision>
      <id>2740</id>
      <parentid>2721</parentid>
      <timestamp>2025-04-23T09:56:29Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2740</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="115" sha1="kq0u9g8logbwgttc95p0lrpzlxat381" xml:space="preserve">Ikhasi lami lokusebenzela.

[[Umsebenzisi:Nqobile69Draftpage1|draftpage1]]|[[draftpage2|draftpage2|]][[draftpage3]]</text>
      <sha1>kq0u9g8logbwgttc95p0lrpzlxat381</sha1>
    </revision>
  </page>
  <page>
    <title>UKUGULA KOKUKHOHLWA</title>
    <ns>0</ns>
    <id>569</id>
    <revision>
      <id>2692</id>
      <timestamp>2025-04-23T09:10:45Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <comment>Created page with &quot;= UKUGULA KOKUKHOHLWA - ''DEMENTIA'' = [[Isimumathi:Old zacatecas lady.jpg|thumb|Isifo sokukhohlwa siphatha abantu abalupheleko]] Ukugula kokukholwa ngesikhuwa okubizwa ngokobana yi-''Dementia'' sisifo esitsatsela abantu abalupheleko nasele bayile ngeminyaka.  Sibenza balahlekelwe mkhumbulo, balahlekelwe lilimi abalikhulumako, bangakghoni ukurarulula imiraro ebebayirarulula nabasaphile kuhle, bangakghoni ukuzicabangela.&lt;ref&gt;ALZHEIMER'S ASSOCIATION, [https://www.alz.org/a...&quot;</comment>
      <origin>2692</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2344" sha1="ttqmg22igkc1gji1g0rzm35r0gplt58" xml:space="preserve">= UKUGULA KOKUKHOHLWA - ''DEMENTIA'' =
[[Isimumathi:Old zacatecas lady.jpg|thumb|Isifo sokukhohlwa siphatha abantu abalupheleko]]
Ukugula kokukholwa ngesikhuwa okubizwa ngokobana yi-''Dementia'' sisifo esitsatsela abantu abalupheleko nasele bayile ngeminyaka.  Sibenza balahlekelwe mkhumbulo, balahlekelwe lilimi abalikhulumako, bangakghoni ukurarulula imiraro ebebayirarulula nabasaphile kuhle, bangakghoni ukuzicabangela.&lt;ref&gt;ALZHEIMER'S ASSOCIATION, [https://www.alz.org/alzheimers-dementia/what-is-dementia what is dementia?]&lt;/ref&gt; Abantwaba bakhohlwa  nabantu abahlala nabo ngendlina bangasabazi nokubazi. 

Ngaphezu kwalokho, abantu ababatlhogomelako bayathinteka ngokomkhumbulo nangokwamazizo ngebanga lokugula okuphethe amalungu wemindenabo. Nanyana amalunga womndeni angalinga ngamandla ukubaphatha ngethando labo abanesifo sokukhohlwa, angazizwa adiniwe, atjharagene namkha azizwe amlandu. Yeke amalunga womndeni akuthola kubudisi ukutlhogomela abanesifo sokukhohlwa.&lt;ref&gt;National Institute of Medicine, [https://pmc.ncbi.nlm.nih.gov/articles/PMC3181916/ The caregivers of people with dementia]&lt;/ref&gt;

== NGABANJANI ABAPHATHWA SISIFO SOKUKHOHLWA? ==
I-''World Health Organization'' iveza bona abantu abasengozini yokuphathwa kugulokhu babantu:

* Abanokugandeleleka nokutshwenyeka
* Abasela khulu
* Abanomzimba omkhulu
* Abanetjhukela
* Abanomfutho weengazi ophezulu
* Ababhemako
* Abangawusebenzisi khulu umzimbabo
* Abagegedwako emphakathini
* Nabalupheleko&lt;ref name=&quot;:0&quot;&gt;World Health Organization, [[Dementia]]&lt;/ref&gt;

== INDLELA ONGALEMUKA NGAYO UMUNTU ONESIFO SOKUKHOHLWA ==
Kunezinto abantu abanesifo sokukhohwa abazenzako. Irhubhululo le-WHO liveze nanzi ezilandelako:

* Ukukhohlwa izinto eziqeda ukwenzeka
* Ukubeka into bese ungasazi bona uyibekephi
* Ukulahleka nawukhamba endleleni oyijayeleko
* Ukungasakghoni ukulungisa imiraro
* Ukuthola kubudisi ukukhuluma nabantu 
* Ukutjhuguluka kwemizwa

Iintjengiswezi azibi khona zoke kibo boke abantu abaphethwe bulwele bokukhohlwa, kodwana ziyatjhiyatjhiyana.

Okudanisako kukuthi abulapheki ubulwelobu kodwana kuneendlela ezingasiza umuntu ophethwe bulwelobu. Kokuthoma kufuze adle ukudla okunepilo. Okwesibili athabulule umzimba  qobe, arage nokuzihlanganisa nabantu akhulume nabo. Okokugcina kufuze aye kwadorhodere asele namapilisi nemitjhoga anikelwa yona.&lt;ref name=&quot;:0&quot; /&gt;</text>
      <sha1>ttqmg22igkc1gji1g0rzm35r0gplt58</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Lungile M. Mabhena</title>
    <ns>2</ns>
    <id>570</id>
    <revision>
      <id>2693</id>
      <timestamp>2025-04-23T09:13:12Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <comment>Created a user page</comment>
      <origin>2693</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="97" sha1="8z9m414c7jm9ytzwf05ri0vb3q16c3u" xml:space="preserve">Ikhasi lami buncopha lokutlola nokubuyekeza imitlolo.

Draft page 1 | Draft page 2 | Draft page 3</text>
      <sha1>8z9m414c7jm9ytzwf05ri0vb3q16c3u</sha1>
    </revision>
    <revision>
      <id>2696</id>
      <parentid>2693</parentid>
      <timestamp>2025-04-23T09:16:27Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <minor />
      <origin>2696</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="139" sha1="jm06qsk8v4i315ea4f46ik4kh6xscj5" xml:space="preserve">Ikhasi lami buncopha lokutlola nokubuyekeza imitlolo.

[[Umsebenzisi:Lungile M. MabhenaDraft 1|Draft page 1 |]] Draft page 2 | Draft page 3</text>
      <sha1>jm06qsk8v4i315ea4f46ik4kh6xscj5</sha1>
    </revision>
    <revision>
      <id>2701</id>
      <parentid>2696</parentid>
      <timestamp>2025-04-23T09:21:23Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <comment>CREATED DRAFT 2</comment>
      <origin>2701</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="186" sha1="9d21rpnebkux2syqc0564dfyqbqj0qu" xml:space="preserve">Ikhasi lami buncopha lokutlola nokubuyekeza imitlolo.

[[Umsebenzisi:Lungile M. MabhenaDraft 1|Draft page 1 |]] [[Umsebenzisi:Lungile M. MabhenaDraft page 2|Draft page 2]] | Draft page 3</text>
      <sha1>9d21rpnebkux2syqc0564dfyqbqj0qu</sha1>
    </revision>
    <revision>
      <id>2706</id>
      <parentid>2701</parentid>
      <timestamp>2025-04-23T09:23:23Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <comment>CREATED DRAFT 3</comment>
      <origin>2706</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="233" sha1="iqxgn62pu7qdqsd42eirk60119qrt3n" xml:space="preserve">Ikhasi lami buncopha lokutlola nokubuyekeza imitlolo.

[[Umsebenzisi:Lungile M. MabhenaDraft 1|Draft page 1 |]] [[Umsebenzisi:Lungile M. MabhenaDraft page 2|Draft page 2]] | [[Umsebenzisi:Lungile M. MabhenaDraft page 3|Draft page 3]]</text>
      <sha1>iqxgn62pu7qdqsd42eirk60119qrt3n</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Lungile M. MabhenaDraft 1</title>
    <ns>2</ns>
    <id>571</id>
    <revision>
      <id>2694</id>
      <timestamp>2025-04-23T09:15:28Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <comment>CREATED DRAFT 1</comment>
      <origin>2694</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8" sha1="203qdhs6u2dpptvzhy16fqjj056x4q6" xml:space="preserve">MY SPACE</text>
      <sha1>203qdhs6u2dpptvzhy16fqjj056x4q6</sha1>
    </revision>
    <revision>
      <id>2712</id>
      <parentid>2694</parentid>
      <timestamp>2025-04-23T09:26:01Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <comment>DRAFT 1</comment>
      <origin>2712</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="13" sha1="hkwri5jrula3206lag2myps4i87429s" xml:space="preserve">== DRAFT 1 ==</text>
      <sha1>hkwri5jrula3206lag2myps4i87429s</sha1>
    </revision>
    <revision>
      <id>2739</id>
      <parentid>2712</parentid>
      <timestamp>2025-04-23T09:55:32Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <origin>2739</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="34" sha1="2un7ys3w0hvyn5rwbp4gcv1s066u5gb" xml:space="preserve">== DRAFT 1 ==

=== References: ===</text>
      <sha1>2un7ys3w0hvyn5rwbp4gcv1s066u5gb</sha1>
    </revision>
    <revision>
      <id>2741</id>
      <parentid>2739</parentid>
      <timestamp>2025-04-23T09:58:35Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <origin>2741</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="87" sha1="44f0jfkgprq8x1ulreevm0l8mlv7b8a" xml:space="preserve">== DRAFT 1 ==
'''[[Esther Mahlangu]]''' is an artist. Art painter.

=== References: ===</text>
      <sha1>44f0jfkgprq8x1ulreevm0l8mlv7b8a</sha1>
    </revision>
    <revision>
      <id>2742</id>
      <parentid>2741</parentid>
      <timestamp>2025-04-23T10:03:43Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <origin>2742</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="151" sha1="fxp78gnyawp38tj9rquob3xr6115ozz" xml:space="preserve">== DRAFT 1 ==
'''[[Esther Mahlangu]]''' is an artist. Art painter. SWiP Project. 
[[Isimumathi:ISITHOMBE.jpg|thumb|SWiP TTT 2025]]

=== References: ===</text>
      <sha1>fxp78gnyawp38tj9rquob3xr6115ozz</sha1>
    </revision>
    <revision>
      <id>2743</id>
      <parentid>2742</parentid>
      <timestamp>2025-04-23T10:07:56Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <origin>2743</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="191" sha1="ckz88jm7akmakliw3x0rgus6zudi92z" xml:space="preserve">== DRAFT 1 ==
'''[[Esther Mahlangu]]''' is an artist. Art painter. SWiP Project. &lt;ref&gt;https://sadilar.org/en/swip/&lt;/ref&gt; 
[[Isimumathi:ISITHOMBE.jpg|thumb|SWiP TTT 2025]]

=== References: ===</text>
      <sha1>ckz88jm7akmakliw3x0rgus6zudi92z</sha1>
    </revision>
    <revision>
      <id>2744</id>
      <parentid>2743</parentid>
      <timestamp>2025-04-23T10:19:00Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <origin>2744</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="390" sha1="gdb7wus964cuuc6w2gqpsxawjmlupag" xml:space="preserve">== DRAFT 1 ==
'''[[Esther Mahlangu]]''' is an artist. Art painter. SWiP Project. &lt;ref&gt;https://sadilar.org/en/swip/&lt;/ref&gt; 
[[Isimumathi:ISITHOMBE.jpg|thumb|SWiP TTT 2025]] &lt;!-- EDIT BELOW THIS LINE --&gt;&lt;ref&gt;{{Cite web |title=SADiLaR-Wikipedia-PanSALB (SWiP) – SADiLaR |url=https://sadilar.org/en/swip/ |access-date=2025-04-23 |website=sadilar.org}}&lt;/ref&gt;&lt;references /&gt;


=== References: ===</text>
      <sha1>gdb7wus964cuuc6w2gqpsxawjmlupag</sha1>
    </revision>
    <revision>
      <id>2854</id>
      <parentid>2744</parentid>
      <timestamp>2025-05-27T14:35:35Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <comment>/* DRAFT 1 */</comment>
      <origin>2854</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3644" sha1="p2z4gdas5v6qpe8wfr5huqykplnoas3" xml:space="preserve">== DRAFT 1 ==
'''[[Esther Mahlangu]]''' omgwali obuya [https://www.britannica.com/topic/Ndebele-South-African-people esizweni samaNdebele weSewula Afrika] ube nomqaliso wezobukghwari ebizwa bona yi-''&lt;nowiki/&gt;'then I knew I was good at painting''' elethwe yi-[https://www.getyourguide.com/-l10476/?cmp=bing&amp;ad_id=78202963710359&amp;adgroup_id=1251244854683240&amp;bid_match_type=bb&amp;campaign_id=434111534&amp;device=c&amp;feed_item_id=&amp;keyword=www.getyourguide.com&amp;loc_interest_ms=&amp;loc_physical_ms=136830&amp;match_type=b&amp;msclkid=d65a70a8cc4e1d1378f2189d722a4aed&amp;network=o&amp;partner_id=CD951&amp;target_id=dat-2330002578451845&amp;utm_adgroup=ct%3Ddsa%7Cfn%3Df1&amp;utm_campaign=ct%3Ddsa%7Cln%3D29%3Aen%7Ctc%3Dall&amp;utm_keyword=www.getyourguide.com&amp;utm_medium=paid_search&amp;utm_query=iziko%20art%20gallery&amp;utm_source=bing Iziko South African Museums]. U-Esther Mahlangu wabelethwa mhlana amalanga ali-11 kuSinyikhaba ngomnyaka we-1935 endaweni yange-Middleburg ePumalanga, ngokubelethwa ungu-Esther Ntuli bese wendela kwaMahlangu, kanti-ke wathoma ukugwala aneminyaka elitjhumi ngobudala. Imisebenzi yakhe ayithathelwa phasi, wanikelwa ubudorhodere mayunivesithi amane okuyi - [https://www.news24.com/citypress/News/its-dr-esther-mahlangu-uj-honours-renowned-sa-artist-with-honorary-doctorate-20180409 University of Johannesburg] ne[https://www.dut.ac.za/dr-esther-mahlangu-to-host-a-retrospective-exhibition-to-celebrate-over-50-years-in-the-arts/ -Durban University of Technology] ngomnyaka wee-2018, [https://www.bona.co.za/celebrity-news/tut-honours-esther-mahlangu-and-david-tlale-with-honorary-doctorates/ Tshwane University of Technology] ngomnyaka wee-2022 kanye ne - [https://www.bing.com/search?q=unisa+honors+esther+mahlangu&amp;form=WSBEDG&amp;qs=SW&amp;cvid=8b979d91361a45ddabfc026c8650c924&amp;pq=unisa+honors+esther+mahlangu&amp;cc=ZA&amp;setlang=en-US&amp;PC=NMTS&amp;nclid=225FE419E1A8A46D5834F8A8971FEAF4&amp;ts=1748354091602&amp;wsso=Moderate University of South Africa] ngomnyaka wee-2024. 

Iziko South African Museums ivulele abantu bona bazokubona umsebenzi ka-Esther Mahlangu obukghwari bokugwala ukuthoma mhlana amalanga ama-18 Mhlolanja ukuya mhlana ama-11 Rhoboyi kumnya wee-2024. Umqaliso lo utjengisa umnikelo omangalisako ka-Esther Mahlangu weminyaka ematjhumi alikhomba ebukghwarini besimanjemanje ngemibala namafomu aphilako. Ifaka imisebenzi yobukghwari engaphezu kwe-100 evela emaqoqweni weentjhabatjhaba, iinthombe zomlando, kanye nefilimu emfitjhani, umqaliso lo unikela ngokudephileko emsebenzini wakhe. Okuqakathekileko yi-BMW 525i Art Car ka-Mahlangu, ebuyela eSewula Afrika kokuthoma eminyakeni engaphezu kwama-30. Ngo-1991, wenza umlando njengomfazi wokuthoma nomgwalii we-Afrika obe ngomunye wabakghwari ku-BMW's Art Car Collection. Lokhu kubuyela emuva kunikela umbono ohlukileko womsebenzi ka-Mahlangu omkhulu nonamandla.

Akupheleli lapho, ubukghwarobo ngitjho nayo ikoloyi ye-BMW ayigwalako ibuye yalethwa godu e-[https://www.esthermahlangu.com/retrospective-projects/wits-art-museum Wits Arts Gallery] bona izokubona babantu mhlana amalanga ama-20 kuSinyikhaba ukuya mhlana amalanga ali-17 kuSihlabantangana kiwo umnyaka lo bese yabuyela emva. Okungaphezu kwalokho umqiniseki womqaliso lo uNontobeko Ntombela uyahlathulula bona “Umqaliso lo uletha ithuba elitjha lokuthi sibone umsebenzi wobukghwari omuhle ka-Esther Mahlangu. Umsebenzakhe ube nomthelela omkhulu emkhakheni wezobukghwari eSewula Afrika begodu umqaliso lo bufakazi bomnikeleo omuhle.” &lt;!-- EDIT BELOW THIS LINE --&gt;

&lt;ref&gt;{{Cite web |title=SADiLaR-Wikipedia-PanSALB (SWiP) – SADiLaR |url=https://sadilar.org/en/swip/ |access-date=2025-04-23 |website=sadilar.org}}&lt;/ref&gt;&lt;references /&gt;


=== References: ===</text>
      <sha1>p2z4gdas5v6qpe8wfr5huqykplnoas3</sha1>
    </revision>
    <revision>
      <id>2859</id>
      <parentid>2854</parentid>
      <timestamp>2025-05-29T13:08:25Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <origin>2859</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3665" sha1="118f7c2w443r8cpyph4ut0nl9foepfs" xml:space="preserve">== DRAFT 1 ==
''[[Esther Mahlangu]]''' omgwali obuya [https://www.britannica.com/topic/Ndebele-South-African-people esizweni samaNdebele weSewula Afrika]''''' ube nomqaliso wezobukghwari ebizwa bona yi '''-''' ''&lt;nowiki/&gt;'then I knew I was good at painting'&lt;nowiki/&gt;'' elethwe yi-[https://www.getyourguide.com/-l10476/?cmp=bing&amp;ad_id=78202963710359&amp;adgroup_id=1251244854683240&amp;bid_match_type=bb&amp;campaign_id=434111534&amp;device=c&amp;feed_item_id=&amp;keyword=www.getyourguide.com&amp;loc_interest_ms=&amp;loc_physical_ms=136830&amp;match_type=b&amp;msclkid=d65a70a8cc4e1d1378f2189d722a4aed&amp;network=o&amp;partner_id=CD951&amp;target_id=dat-2330002578451845&amp;utm_adgroup=ct%3Ddsa%7Cfn%3Df1&amp;utm_campaign=ct%3Ddsa%7Cln%3D29%3Aen%7Ctc%3Dall&amp;utm_keyword=www.getyourguide.com&amp;utm_medium=paid_search&amp;utm_query=iziko%20art%20gallery&amp;utm_source=bing Iziko South African Museums]. U-Esther Mahlangu wabelethwa mhlana amalanga ali-11 kuSinyikhaba ngomnyaka we-1935 endaweni yange-Middleburg ePumalanga, ngokubelethwa ungu-Esther Ntuli bese wendela kwaMahlangu, kanti-ke wathoma ukugwala aneminyaka elitjhumi ngobudala. Imisebenzi yakhe ayithathelwa phasi, wanikelwa ubudorhodere mayunivesithi amane okuyi - [https://www.news24.com/citypress/News/its-dr-esther-mahlangu-uj-honours-renowned-sa-artist-with-honorary-doctorate-20180409 University of Johannesburg] ne[https://www.dut.ac.za/dr-esther-mahlangu-to-host-a-retrospective-exhibition-to-celebrate-over-50-years-in-the-arts/ -Durban University of Technology] ngomnyaka wee-2018, [https://www.bona.co.za/celebrity-news/tut-honours-esther-mahlangu-and-david-tlale-with-honorary-doctorates/ Tshwane University of Technology] ngomnyaka wee-2022 kanye ne - [https://www.bing.com/search?q=unisa+honors+esther+mahlangu&amp;form=WSBEDG&amp;qs=SW&amp;cvid=8b979d91361a45ddabfc026c8650c924&amp;pq=unisa+honors+esther+mahlangu&amp;cc=ZA&amp;setlang=en-US&amp;PC=NMTS&amp;nclid=225FE419E1A8A46D5834F8A8971FEAF4&amp;ts=1748354091602&amp;wsso=Moderate University of South Africa] ngomnyaka wee-2024. 

Iziko South African Museums ivulele abantu bona bazokubona umsebenzi ka-Esther Mahlangu obukghwari bokugwala ukuthoma mhlana amalanga ama-18 Mhlolanja ukuya mhlana ama-11 Rhoboyi kumnya wee-2024. Umqaliso lo utjengisa umnikelo omangalisako ka-Esther Mahlangu weminyaka ematjhumi alikhomba ebukghwarini besimanjemanje ngemibala namafomu aphilako. Ifaka imisebenzi yobukghwari engaphezu kwe-100 evela emaqoqweni weentjhabatjhaba, iinthombe zomlando, kanye nefilimu emfitjhani, umqaliso lo unikela ngokudephileko emsebenzini wakhe. Okuqakathekileko yi-BMW 525i Art Car ka-Mahlangu, ebuyela eSewula Afrika kokuthoma eminyakeni engaphezu kwama-30. Ngo-1991, wenza umlando njengomfazi wokuthoma nomgwalii we-Afrika obe ngomunye wabakghwari ku-BMW's Art Car Collection. Lokhu kubuyela emuva kunikela umbono ohlukileko womsebenzi ka-Mahlangu omkhulu nonamandla.

Akupheleli lapho, ubukghwarobo ngitjho nayo ikoloyi ye-BMW ayigwalako ibuye yalethwa godu e-[https://www.esthermahlangu.com/retrospective-projects/wits-art-museum Wits Arts Gallery] bona izokubona babantu mhlana amalanga ama-20 kuSinyikhaba ukuya mhlana amalanga ali-17 kuSihlabantangana kiwo umnyaka lo bese yabuyela emva. Okungaphezu kwalokho umqiniseki womqaliso lo uNontobeko Ntombela uyahlathulula bona “Umqaliso lo uletha ithuba elitjha lokuthi sibone umsebenzi wobukghwari omuhle ka-Esther Mahlangu. Umsebenzakhe ube nomthelela omkhulu emkhakheni wezobukghwari eSewula Afrika begodu umqaliso lo bufakazi bomnikeleo omuhle.” &lt;!-- EDIT BELOW THIS LINE --&gt;

&lt;ref&gt;{{Cite web |title=SADiLaR-Wikipedia-PanSALB (SWiP) – SADiLaR |url=https://sadilar.org/en/swip/ |access-date=2025-04-23 |website=sadilar.org}}&lt;/ref&gt;&lt;references /&gt;


=== References: ===</text>
      <sha1>118f7c2w443r8cpyph4ut0nl9foepfs</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Mosakaruka/Draft Page 1</title>
    <ns>2</ns>
    <id>572</id>
    <revision>
      <id>2698</id>
      <timestamp>2025-04-23T09:18:59Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>Created page with &quot;== Draft Space 1 ==&quot;</comment>
      <origin>2698</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="19" sha1="18n7y18ghorstdggo7ek5hyav8bgmj6" xml:space="preserve">== Draft Space 1 ==</text>
      <sha1>18n7y18ghorstdggo7ek5hyav8bgmj6</sha1>
    </revision>
    <revision>
      <id>2791</id>
      <parentid>2698</parentid>
      <timestamp>2025-05-01T19:14:11Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>/* Draft Space 1 */</comment>
      <origin>2791</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="272" sha1="icy3fz28mr9nnt1j9ge3z5o73kvro6f" xml:space="preserve">== Draft Space 1 ==

= Amalimi WeSewula Afrika =

== IsiNdebele ==

== IsiSwati ==

== IsiZulu ==

== IsiXhosa ==

== IsiSuthu ==

== IsiTswana ==

== IsiPedi ==

== IsiVenda ==

== IsiTsonga ==

== I-''Afrikaans'' ==

== IsiNgisi ==

== ILimi LeZandla ==

== Iinkhombo ==</text>
      <sha1>icy3fz28mr9nnt1j9ge3z5o73kvro6f</sha1>
    </revision>
    <revision>
      <id>2792</id>
      <parentid>2791</parentid>
      <timestamp>2025-05-01T20:15:04Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>New article</comment>
      <origin>2792</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1621" sha1="6feanqofunx15qfgrjxuj8339iq4a34" xml:space="preserve">== Draft Space 1 ==

= Amalimi WeSewula Afrika =
Inarha yeSewula Afrika yinarha enabantu abanamasiko nabaneenzinda ezihlukahlukeneko, nabakhuluma amalimi ahlukahlukeneko. Inengi labantu enarheni le lisesiqhemeni sokuthoma sabantu abakhuluma amalimi angaphasi kwesiNguni, okusiZulu, isiXhosa, isiNdebele nesiSwati. Bese isiqhema sesibili ngobukhulu ngesikhuluma amalimi wesiSuthu, okusiTswana, isiPedi (okusiSuthu seTlhagwini) nesiSuthu (okusiSuthu seSewula, namkha isiSuthu sesiShweshwe). Bese kunesiqhema esikhuluma isiTsonga nesiqhema esikhuluma isiVenda. 

Ngaphezu kwamalimi abaliweko la kunamalimi ahlobene nawo. Ngokwesibonelo, esiNdebeleni kunesiNala, nesiNdebele seMoletlane. EsiXhoseni kube nesiNgqika, isiThembu, isiBhaca, isiGcaleka, isiMpondo, isiMpondomise, isiMfengu nesiBomvana. Kusese nelimi lesiThwa elibandaka isiKhoe nesiTu. Bese isiSwati kunesikhulunywa eManzini, esikhulunywa eShiselweni, nesikhulunywa eHhoho. IsiPedi naso sinamalinyana angaphasi kwaso anjengesiTlokwa nesiLobedu.

Bese kube namalimi angasiwo wendabuko, namkha amalimi wesikhuwa akhulunywako njengesiNgisi nesiBhuru. Woke amalimi la namanye angakabalwa lapha malimi akhulunywa babantu beSewula Afrika. 

== Amalimi Asemthethweni ==
Amalimi aseMthethweni eSewula Afrika siNdebele, isiZulu, isiSwati, isiXhosa, isiSuthu, isiPedi, isiTswana, isiVenda, isiTsonga okumalimi wendabuko, bese kuba siBhuru nesiNgisi.

== IsiNdebele ==

== IsiSwati ==

== IsiZulu ==

== IsiXhosa ==

== IsiSuthu ==

== IsiTswana ==

== IsiPedi ==

== IsiVenda ==

== IsiTsonga ==

== I-''Afrikaans'' ==

== IsiNgisi ==

== ILimi LeZandla ==

== Iinkhombo ==</text>
      <sha1>6feanqofunx15qfgrjxuj8339iq4a34</sha1>
    </revision>
    <revision>
      <id>2793</id>
      <parentid>2792</parentid>
      <timestamp>2025-05-01T20:22:52Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>2793</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1689" sha1="9ws2mvjlyeck3ex3wa8s1qwlfeolipv" xml:space="preserve">[[Isimumathi:Flag of South Africa.svg|thumb|Iflarha leSewula Afrika]]

== Draft Space 1 ==

= Amalimi WeSewula Afrika =
Inarha yeSewula Afrika yinarha enabantu abanamasiko nabaneenzinda ezihlukahlukeneko, nabakhuluma amalimi ahlukahlukeneko. Inengi labantu enarheni le lisesiqhemeni sokuthoma sabantu abakhuluma amalimi angaphasi kwesiNguni, okusiZulu, isiXhosa, isiNdebele nesiSwati. Bese isiqhema sesibili ngobukhulu ngesikhuluma amalimi wesiSuthu, okusiTswana, isiPedi (okusiSuthu seTlhagwini) nesiSuthu (okusiSuthu seSewula, namkha isiSuthu sesiShweshwe). Bese kunesiqhema esikhuluma isiTsonga nesiqhema esikhuluma isiVenda. 

Ngaphezu kwamalimi abaliweko la kunamalimi ahlobene nawo. Ngokwesibonelo, esiNdebeleni kunesiNala, nesiNdebele seMoletlane. EsiXhoseni kube nesiNgqika, isiThembu, isiBhaca, isiGcaleka, isiMpondo, isiMpondomise, isiMfengu nesiBomvana. Kusese nelimi lesiThwa elibandaka isiKhoe nesiTu. Bese isiSwati kunesikhulunywa eManzini, esikhulunywa eShiselweni, nesikhulunywa eHhoho. IsiPedi naso sinamalinyana angaphasi kwaso anjengesiTlokwa nesiLobedu.Bese kube namalimi angasiwo wendabuko, namkha amalimi wesikhuwa akhulunywako njengesiNgisi nesiBhuru. Woke amalimi la namanye angakabalwa lapha malimi akhulunywa babantu beSewula Afrika.

== Amalimi Asemthethweni ==
Amalimi aseMthethweni eSewula Afrika siNdebele, isiZulu, isiSwati, isiXhosa, isiSuthu, isiPedi, isiTswana, isiVenda, isiTsonga okumalimi wendabuko, bese kuba siBhuru nesiNgisi.

== IsiNdebele ==

== IsiSwati ==

== IsiZulu ==

== IsiXhosa ==

== IsiSuthu ==

== IsiTswana ==

== IsiPedi ==

== IsiVenda ==

== IsiTsonga ==

== I-''Afrikaans'' ==

== IsiNgisi ==

== ILimi LeZandla ==

== Iinkhombo ==</text>
      <sha1>9ws2mvjlyeck3ex3wa8s1qwlfeolipv</sha1>
    </revision>
    <revision>
      <id>2795</id>
      <parentid>2793</parentid>
      <timestamp>2025-05-05T16:23:40Z</timestamp>
      <contributor>
        <ip>41.13.118.14</ip>
      </contributor>
      <comment>Putting references</comment>
      <origin>2795</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2149" sha1="33bkbhdbfe219c2ukz0g0zrblnphy2u" xml:space="preserve">[[Isimumathi:Flag of South Africa.svg|thumb|Iflarha leSewula Afrika]]

== Draft Space 1 ==

= Amalimi WeSewula Afrika =
Inarha yeSewula Afrika yinarha enabantu abanamasiko nabaneenzinda ezihlukahlukeneko, nabakhuluma amalimi ahlukahlukeneko. Inengi labantu enarheni le lisesiqhemeni sokuthoma sabantu abakhuluma amalimi angaphasi kwesiNguni, okusiZulu, isiXhosa, isiNdebele nesiSwati. Bese isiqhema sesibili ngobukhulu ngesikhuluma amalimi wesiSuthu, okusiTswana, isiPedi (okusiSuthu seTlhagwini) nesiSuthu (okusiSuthu seSewula, namkha isiSuthu sesiShweshwe). Bese kunesiqhema esikhuluma isiTsonga nesiqhema esikhuluma isiVenda.&lt;ref&gt;{{Cite web|date=2025-04-29|title=South Africa - Languages, Dialects, Afrikaans {{!}} Britannica|url=https://www.britannica.com/place/South-Africa/Languages|access-date=2025-05-01|website=www.britannica.com|language=en}}&lt;/ref&gt; 

Ngaphezu kwamalimi abaliweko la kunamalimi ahlobene nawo. Ngokwesibonelo, esiNdebeleni kunesiNala, nesiNdebele seMoletlane. EsiXhoseni kube nesiNgqika, isiThembu, isiBhaca, isiGcaleka, isiMpondo, isiMpondomise, isiMfengu nesiBomvana. Kusese nelimi lesiThwa elibandaka isiKhoe nesiTu. Bese isiSwati kunesikhulunywa eManzini, esikhulunywa eShiselweni, nesikhulunywa eHhoho. IsiPedi naso sinamalinyana angaphasi kwaso anjengesiTlokwa nesiLobedu.Bese kube namalimi angasiwo wendabuko, namkha amalimi wesikhuwa akhulunywako njengesiNgisi nesiBhuru. Woke amalimi la namanye angakabalwa lapha malimi akhulunywa babantu beSewula Afrika.&lt;ref&gt;{{Cite web|date=2025-04-29|title=South Africa - Languages, Dialects, Afrikaans {{!}} Britannica|url=https://www.britannica.com/place/South-Africa/Languages|access-date=2025-05-01|website=www.britannica.com|language=en}}&lt;/ref&gt;

== Amalimi Asemthethweni ==
Amalimi aseMthethweni eSewula Afrika siNdebele, isiZulu, isiSwati, isiXhosa, isiSuthu, isiPedi, isiTswana, isiVenda, isiTsonga okumalimi wendabuko, bese kuba siBhuru nesiNgisi.

== IsiNdebele ==

== IsiSwati ==

== IsiZulu ==

== IsiXhosa ==

== IsiSuthu ==

== IsiTswana ==

== IsiPedi ==

== IsiVenda ==

== IsiTsonga ==

== I-''Afrikaans'' ==

== IsiNgisi ==

== ILimi LeZandla ==

== Iinkhombo ==</text>
      <sha1>33bkbhdbfe219c2ukz0g0zrblnphy2u</sha1>
    </revision>
    <revision>
      <id>2796</id>
      <parentid>2795</parentid>
      <timestamp>2025-05-05T16:34:41Z</timestamp>
      <contributor>
        <ip>41.13.118.14</ip>
      </contributor>
      <origin>2796</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2148" sha1="a7vptwbr84ppphopuwxb153j7c6kr7j" xml:space="preserve">[[Isimumathi:Flag of South Africa.svg|thumb|Iflarha leSewula Afrika]]

== Draft Space 1 ==

= Amalimi WeSewula Afrika =
Inarha yeSewula Afrika yinarha enabantu abanamasiko nabaneenzinda ezihlukahlukeneko, nabakhuluma amalimi ahlukahlukeneko. Inengi labantu enarheni le lisesiqhemeni sokuthoma sabantu abakhuluma amalimi angaphasi kwesiNguni, okusiZulu, isiXhosa, isiNdebele nesiSwati. Bese isiqhema sesibili ngobukhulu ngesikhuluma amalimi wesiSuthu, okusiTswana, isiPedi (okusiSuthu seTlhagwini) nesiSuthu (okusiSuthu seSewula, namkha isiSuthu sesiShweshwe). Bese kunesiqhema esikhuluma isiTsonga nesiqhema esikhuluma isiVenda.&lt;ref&gt;{{Cite web|date=2025-05-05|title=South Africa - Languages, Dialects, Afrikaans {{!}} Britannica|url=https://www.britannica.com/place/South-Africa/Languages|access-date=2025-05-05|website=www.britannica.com|language=en}}&lt;/ref&gt;

Ngaphezu kwamalimi abaliweko la kunamalimi ahlobene nawo. Ngokwesibonelo, esiNdebeleni kunesiNala, nesiNdebele seMoletlane. EsiXhoseni kube nesiNgqika, isiThembu, isiBhaca, isiGcaleka, isiMpondo, isiMpondomise, isiMfengu nesiBomvana. Kusese nelimi lesiThwa elibandaka isiKhoe nesiTu. Bese isiSwati kunesikhulunywa eManzini, esikhulunywa eShiselweni, nesikhulunywa eHhoho. IsiPedi naso sinamalinyana angaphasi kwaso anjengesiTlokwa nesiLobedu.Bese kube namalimi angasiwo wendabuko, namkha amalimi wesikhuwa akhulunywako njengesiNgisi nesiBhuru. Woke amalimi la namanye angakabalwa lapha malimi akhulunywa babantu beSewula Afrika.&lt;ref&gt;{{Cite web|date=2025-05-05|title=South Africa - Languages, Dialects, Afrikaans {{!}} Britannica|url=https://www.britannica.com/place/South-Africa/Languages|access-date=2025-05-05|website=www.britannica.com|language=en}}&lt;/ref&gt;

== Amalimi Asemthethweni ==
Amalimi aseMthethweni eSewula Afrika siNdebele, isiZulu, isiSwati, isiXhosa, isiSuthu, isiPedi, isiTswana, isiVenda, isiTsonga okumalimi wendabuko, bese kuba siBhuru nesiNgisi.

== IsiNdebele ==

== IsiSwati ==

== IsiZulu ==

== IsiXhosa ==

== IsiSuthu ==

== IsiTswana ==

== IsiPedi ==

== IsiVenda ==

== IsiTsonga ==

== I-''Afrikaans'' ==

== IsiNgisi ==

== ILimi LeZandla ==

== Iinkhombo ==</text>
      <sha1>a7vptwbr84ppphopuwxb153j7c6kr7j</sha1>
    </revision>
    <revision>
      <id>2813</id>
      <parentid>2796</parentid>
      <timestamp>2025-05-15T08:36:51Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>2813</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1924" sha1="8lx0kguqvuapc7vl7c77vaegqpi11g8" xml:space="preserve">[[Isimumathi:Flag of South Africa.svg|thumb|Iflarha leSewula Afrika]]

== Draft Space 1 ==

= Amalimi WeSewula Afrika =
Inarha yeSewula Afrika yinarha enabantu abanamasiko nabaneenzinda ezihlukahlukeneko, nabakhuluma amalimi ahlukahlukeneko. Inengi labantu enarheni le lisesiqhemeni sokuthoma sabantu abakhuluma amalimi angaphasi kwesiNguni, okusiZulu, isiXhosa, isiNdebele nesiSwati. Bese isiqhema sesibili ngobukhulu ngesikhuluma amalimi wesiSuthu, okusiTswana, isiPedi (okusiSuthu seTlhagwini) nesiSuthu (okusiSuthu seSewula, namkha isiSuthu sesiShweshwe). Bese kunesiqhema esikhuluma isiTsonga nesiqhema esikhuluma isiVenda.&lt;ref&gt;{{Cite web |date=2025-05-14 |title=South Africa - Languages, Dialects, Afrikaans {{!}} Britannica |url=https://www.britannica.com/place/South-Africa/Languages |access-date=2025-05-15 |website=www.britannica.com |language=en}}&lt;/ref&gt;

Ngaphezu kwamalimi abaliweko la kunamalimi ahlobene nawo. Ngokwesibonelo, esiNdebeleni kunesiNala, nesiNdebele seMoletlane. EsiXhoseni kube nesiNgqika, isiThembu, isiBhaca, isiGcaleka, isiMpondo, isiMpondomise, isiMfengu nesiBomvana. Kusese nelimi lesiThwa elibandaka isiKhoe nesiTu. Bese isiSwati kunesikhulunywa eManzini, esikhulunywa eShiselweni, nesikhulunywa eHhoho. IsiPedi naso sinamalinyana angaphasi kwaso anjengesiTlokwa nesiLobedu.Bese kube namalimi angasiwo wendabuko, namkha amalimi wesikhuwa akhulunywako njengesiNgisi nesiBhuru. Woke amalimi la namanye angakabalwa lapha malimi akhulunywa babantu beSewula Afrika.

== Amalimi Asemthethweni ==
Amalimi aseMthethweni eSewula Afrika siNdebele, isiZulu, isiSwati, isiXhosa, isiSuthu, isiPedi, isiTswana, isiVenda, isiTsonga okumalimi wendabuko, bese kuba siBhuru nesiNgisi.

== IsiNdebele ==

== IsiSwati ==

== IsiZulu ==

== IsiXhosa ==

== IsiSuthu ==

== IsiTswana ==

== IsiPedi ==

== IsiVenda ==

== IsiTsonga ==

== I-''Afrikaans'' ==

== IsiNgisi ==

== ILimi LeZandla ==

== Iinkhombo ==</text>
      <sha1>8lx0kguqvuapc7vl7c77vaegqpi11g8</sha1>
    </revision>
    <revision>
      <id>2814</id>
      <parentid>2813</parentid>
      <timestamp>2025-05-15T10:41:37Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>edits</comment>
      <origin>2814</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5727" sha1="q1isejo5jtln70clpl5wrsxf8yct862" xml:space="preserve">[[Isimumathi:Flag of South Africa.svg|thumb|Iflarha leSewula Afrika]]

== Draft Space 1 ==

= Amalimi WeSewula Afrika =
Inarha yeSewula Afrika yinarha enabantu abanamasiko nabaneenzinda ezihlukahlukeneko, nabakhuluma amalimi ahlukahlukeneko. Inengi labantu enarheni le lisesiqhemeni sokuthoma sabantu abakhuluma amalimi angaphasi kwesiNguni, okusiZulu, isiXhosa, [[Isindebele|isiNdebele]] nesiSwati. Bese isiqhema sesibili ngobukhulu ngesikhuluma amalimi wesiSuthu, okusiTswana, isiPedi (okusiSuthu seTlhagwini) nesiSuthu (okusiSuthu seSewula, namkha isiSuthu sesiShweshwe). Bese kunesiqhema esikhuluma isiTsonga nesiqhema esikhuluma isiVenda.&lt;ref&gt;{{Cite web |date=2025-05-14 |title=South Africa - Languages, Dialects, Afrikaans {{!}} Britannica |url=https://www.britannica.com/place/South-Africa/Languages |access-date=2025-05-15 |website=www.britannica.com |language=en}}&lt;/ref&gt;

Ngaphezu kwamalimi abaliweko la kunamalimi ahlobene nawo. Ngokwesibonelo, esiNdebeleni kunesiNala, nesiNdebele seMoletlane. &lt;ref name=&quot;:0&quot;&gt;{{Cite web|title=Ndebele people, traditions culture|url=https://www.africancraftsmarket.com/african-tribes/ndebele-people.html|access-date=2025-05-15|website=www.africancraftsmarket.com}}&lt;/ref&gt; EsiXhoseni kube nesiNgqika, isiThembu, isiBhaca, isiGcaleka, isiMpondo, isiMpondomise, isiMfengu nesiBomvana.&lt;ref&gt;{{Cite web|title=XHOSA - South African Language Xhosa|url=https://www.sa-venues.com/language-xhosa.htm#:~:text=Xhosa%20has%20been%20grouped%20into,yet%20pretty-sounding,%20language.|access-date=2025-05-15|website=www.sa-venues.com}}&lt;/ref&gt; Kusese nelimi lesiThwa elibandaka isi-Khoe, isi-Tu nesi-Kx'a.&lt;ref&gt;{{Cite web|title=AFRICA {{!}} 101 Last Tribes - San people|url=https://www.101lasttribes.com/tribes/san.html|access-date=2025-05-15|website=www.101lasttribes.com}}&lt;/ref&gt; Bese isiSwati kunesikhulunywa eManzini, esikhulunywa eShiselweni, nesikhulunywa eHhoho.&lt;ref&gt;{{Cite web|last=web-lingo|date=2013-01-07|title=SA’s Eleven Official Languages: SiSwati|url=https://web-lingo.com/sas-eleven-official-languages-siswati/#:~:text=Swazi%20is%20most%20closely%20related,considered%20closer%20to%20standard%20Swazi.|access-date=2025-05-15|website=Web-lingo|language=en-ZA}}&lt;/ref&gt; IsiPedi naso sinamalinyana angaphasi kwaso anjengesiTlokwa nesiLobedu.&lt;ref&gt;{{Cite web|title=free online course|url=https://www.unisa.ac.za/static/corporate_web/Content/UnisaOpen/freeOnlineCourse/nSotho/nSotho.html#:~:text=Northern%20Sotho%20is%20based%20mainly,(Cf.|access-date=2025-05-15|website=www.unisa.ac.za}}&lt;/ref&gt; Bese kube namalimi angasiwo wendabuko, namkha amalimi wesikhuwa akhulunywako njengesiNgisi nesiBhuru. Woke amalimi la namanye angakabalwa lapha malimi akhulunywa babantu beSewula Afrika.

== Amalimi Asemthethweni ==
Amalimi aseMthethweni eSewula Afrika siNdebele, isiZulu, isiSwati, isiXhosa, isiSuthu, isiPedi, isiTswana, isiVenda, isiTsonga okumalimi wendabuko, bese kuba siBhuru nesiNgisi. Ithebula elingenzasi litjengisa isibalo sabantu abakhuluma amalimi asemthethweni eSewula Afrika namaphesente wabalikhulumako esibalweni sabo boke abantu abahlala eSewula Afrika ngokweembalobalo zango-2022. &lt;ref name=&quot;:1&quot;&gt;https://en.wikipedia.org/wiki/Languages_of_South_Africa#cite_note-EthnologueZA-7&lt;/ref&gt;
{| class=&quot;wikitable sortable mw-collapsible&quot;
|+
! rowspan=&quot;2&quot; |Ilimi
! colspan=&quot;2&quot; |Ilimi lebele&lt;ref name=&quot;:1&quot; /&gt;
! colspan=&quot;2&quot; |Ilimi lesibili&lt;ref name=&quot;:1&quot; /&gt;
! colspan=&quot;2&quot; |Ilimi lesithathu&lt;ref name=&quot;:1&quot; /&gt;
|-
!Isibalo 
!Amaphesente 
!Isibalo 
!Amaphesente 
!Isibalo 
!Amaphesente 
|-
|IsiZulu
|11,587,374
|22.7%
|15,700,000
|30.8%
|27,300,000
|46%
|-
|IsiXhosa
|8,154,258
|16.0%
|11,000,000
|21.6%
|19,150,000
|33%
|-
|IsiVenda
|1,209,388
|2.4%
|1,700,000
|3.3%
|2,910,000
|5%
|-
|IsiTswana
|4,067,248
|8.0%
|7,700,000
|15.1%
|11,770,000
|20%
|-
|IsiTsonga
|2,277,148
|4.5%
|3,400,000
|6.6%
|5,680,000
|10%
|-
|IsiSwati
|1,297,046
|2.5%
|2,400,000
|4.7%
|3,700,000
|6%
|-
|IsiSuthu
|3,849,563
|7.6%
|7,900,000
|15.5%
|11,750,000
|20%
|-
|IsiPedi
|4,618,576
|9.1%
|9,100,000
|17.8%
|13,720,000
|23%
|-
|IsiNdebele
|1,090,223
|2.1%
|1,400,000
|2.7%
|2,490,000
|4%
|-
|IsiNgisi
|4,892,623
|9.6%
|14,000,000
|27.4%
|19,640,000
|33%
|-
|Isi-Afrikaans
|6,855,082
|13.5%
|10,300,000
|20.2%
|17,160,000
|29%
|-
|Ilimi Lezandla le-SA
|234,655
|0.5%
|500,000
|1.0%
|834,655
|1.5%
|-
|Amanye Amalimi
|828,258
|1.6%
|
|
|
|
|-
|'''Isibalo Sisoke'''
|'''50,961,443'''
|'''100.0%'''
|
|
|
|
|}

== IsiNdebele ==
[[Isimumathi:Ndebele women-1.jpg|thumb|Abomma bamaNdebele]]
IsiNdebele seSewula Afrika ngelinye lamalimi akhulunywa enarheni le. Isizathu sokuthi kuthiwe siNdebele seSewula Afrika kukuthi kunesiNdebele seZimbabwe. &lt;ref&gt;{{Cite web|last=web-lingo|date=2012-10-19|title=Ndebele: What is Ndebele?|url=https://web-lingo.com/ndebele-what-is-ndebele/#:~:text=Northern%20Ndebele,%20or%20Matabele,%20or,nineteenth%20century%20during%20the%20Mfecane.|access-date=2025-05-15|website=Web-lingo|language=en-ZA}}&lt;/ref&gt; Ngokwethebula elingehla, abantu abakhuluma isiNdebele - abasimunyileko, okulilimi lesibili nalabo okulilimi lesithathu kibo bangaphezu kweengidi ezine.

IsiNdebele esisemthethweni siNzunza, kodwana kusese nesiNdebele sakwaManala nesiNdebele seMoletlane. IsiNdebele sikhulunywa khulukhulu esifundeni seMpumalanga eendaweni ezinjengaKwaNdebele, eMalahleni, eMiddleburg njll.&lt;ref name=&quot;:0&quot; /&gt;

AmaNdebele aziwa njengesitjhaba esithanda imibala emihle nekhanyako ongayibona endleleni abambatha ngayo nabenza ngayo imigwalo yabo.

== IsiSwati ==
[[Isimumathi:Swazi Wedding Dancer.jpg|thumb|AmaSwati ayagida]]

== IsiZulu ==

== IsiXhosa ==

== IsiSuthu ==

== IsiTswana ==

== IsiPedi ==

== IsiVenda ==

== IsiTsonga ==

== I-''Afrikaans'' ==

== IsiNgisi ==

== ILimi LeZandla ==

== Iinkhombo ==</text>
      <sha1>q1isejo5jtln70clpl5wrsxf8yct862</sha1>
    </revision>
    <revision>
      <id>2839</id>
      <parentid>2814</parentid>
      <timestamp>2025-05-23T09:56:02Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>/* Amalimi WeSewula Afrika */</comment>
      <origin>2839</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7214" sha1="jowuu03xdh3xvk4na7jdrmjiy67lj5z" xml:space="preserve">[[Isimumathi:Flag of South Africa.svg|thumb|Iflarha leSewula Afrika]]

== Draft Space 1 ==

= Amalimi WeSewula Afrika =
Inarha yeSewula Afrika yinarha enabantu abanamasiko nabaneenzinda ezihlukahlukeneko, nabakhuluma amalimi ahlukahlukeneko. Inengi labantu enarheni le lisesiqhemeni sokuthoma sabantu abakhuluma amalimi angaphasi kwesiNguni, okusiZulu, isiXhosa, [[Isindebele|isiNdebele]] nesiSwati. Bese isiqhema sesibili ngobukhulu ngesikhuluma amalimi wesiSuthu, okusiTswana, isiPedi (okusiSuthu seTlhagwini) nesiSuthu (okusiSuthu seSewula, namkha isiSuthu sesiShweshwe). Bese kunesiqhema esikhuluma isiTsonga nesiqhema esikhuluma isiVenda.&lt;ref&gt;{{Cite web |date=2025-05-14 |title=South Africa - Languages, Dialects, Afrikaans {{!}} Britannica |url=https://www.britannica.com/place/South-Africa/Languages |access-date=2025-05-15 |website=www.britannica.com |language=en}}&lt;/ref&gt;

Ngaphezu kwamalimi abaliweko la kunamalimi ahlobene nawo. Ngokwesibonelo, esiNdebeleni kunesiNala, nesiNdebele seMoletlane. &lt;ref name=&quot;:0&quot;&gt;{{Cite web|title=Ndebele people, traditions culture|url=https://www.africancraftsmarket.com/african-tribes/ndebele-people.html|access-date=2025-05-15|website=www.africancraftsmarket.com}}&lt;/ref&gt; EsiXhoseni kube nesiNgqika, isiThembu, isiBhaca, isiGcaleka, isiMpondo, isiMpondomise, isiMfengu nesiBomvana.&lt;ref&gt;{{Cite web|title=XHOSA - South African Language Xhosa|url=https://www.sa-venues.com/language-xhosa.htm#:~:text=Xhosa%20has%20been%20grouped%20into,yet%20pretty-sounding,%20language.|access-date=2025-05-15|website=www.sa-venues.com}}&lt;/ref&gt; Kusese nelimi lesiThwa elibandaka isi-Khoe, isi-Tu isi-Kx'a, namanye amalimi.&lt;ref&gt;{{Cite web|title=AFRICA {{!}} 101 Last Tribes - San people|url=https://www.101lasttribes.com/tribes/san.html|access-date=2025-05-15|website=www.101lasttribes.com}}&lt;/ref&gt; Bese isiSwati kunesikhulunywa eManzini, esikhulunywa eShiselweni, nesikhulunywa eHhoho.&lt;ref name=&quot;:2&quot;&gt;{{Cite web|last=web-lingo|date=2013-01-07|title=SA’s Eleven Official Languages: SiSwati|url=https://web-lingo.com/sas-eleven-official-languages-siswati/#:~:text=Swazi%20is%20most%20closely%20related,considered%20closer%20to%20standard%20Swazi.|access-date=2025-05-15|website=Web-lingo|language=en-ZA}}&lt;/ref&gt; IsiPedi naso sinamalinyana angaphasi kwaso anjengesiTlokwa nesiLobedu.&lt;ref&gt;{{Cite web|title=free online course|url=https://www.unisa.ac.za/static/corporate_web/Content/UnisaOpen/freeOnlineCourse/nSotho/nSotho.html#:~:text=Northern%20Sotho%20is%20based%20mainly,(Cf.|access-date=2025-05-15|website=www.unisa.ac.za}}&lt;/ref&gt; Bese kube namalimi angasiwo wendabuko, namkha amalimi wesikhuwa akhulunywako njengesiNgisi nesiBhuru. Woke amalimi la namanye angakabalwa lapha malimi akhulunywa babantu beSewula Afrika.

== Amalimi Asemthethweni ==
Amalimi aseMthethweni eSewula Afrika siNdebele, isiZulu, isiSwati, isiXhosa, isiSuthu, isiPedi, isiTswana, isiVenda, isiTsonga okumalimi wendabuko, bese kuba siBhuru nesiNgisi. Ithebula elingenzasi litjengisa isibalo sabantu abakhuluma amalimi asemthethweni eSewula Afrika namaphesente wabalikhulumako esibalweni sabo boke abantu abahlala eSewula Afrika ngokweembalobalo zango-2022. &lt;ref name=&quot;:1&quot;&gt;https://en.wikipedia.org/wiki/Languages_of_South_Africa#cite_note-EthnologueZA-7&lt;/ref&gt;
{| class=&quot;wikitable sortable mw-collapsible&quot;
|+
! rowspan=&quot;2&quot; |Ilimi
! colspan=&quot;2&quot; |Ilimi lebele&lt;ref name=&quot;:1&quot; /&gt;
! colspan=&quot;2&quot; |Ilimi lesibili&lt;ref name=&quot;:1&quot; /&gt;
! colspan=&quot;2&quot; |Ilimi lesithathu&lt;ref name=&quot;:1&quot; /&gt;
|-
!Isibalo 
!Amaphesente 
!Isibalo 
!Amaphesente 
!Isibalo 
!Amaphesente 
|-
|IsiZulu
|11,587,374
|22.7%
|15,700,000
|30.8%
|27,300,000
|46%
|-
|IsiXhosa
|8,154,258
|16.0%
|11,000,000
|21.6%
|19,150,000
|33%
|-
|IsiVenda
|1,209,388
|2.4%
|1,700,000
|3.3%
|2,910,000
|5%
|-
|IsiTswana
|4,067,248
|8.0%
|7,700,000
|15.1%
|11,770,000
|20%
|-
|IsiTsonga
|2,277,148
|4.5%
|3,400,000
|6.6%
|5,680,000
|10%
|-
|IsiSwati
|1,297,046
|2.5%
|2,400,000
|4.7%
|3,700,000
|6%
|-
|IsiSuthu
|3,849,563
|7.6%
|7,900,000
|15.5%
|11,750,000
|20%
|-
|IsiPedi
|4,618,576
|9.1%
|9,100,000
|17.8%
|13,720,000
|23%
|-
|IsiNdebele
|1,090,223
|2.1%
|1,400,000
|2.7%
|2,490,000
|4%
|-
|IsiNgisi
|4,892,623
|9.6%
|14,000,000
|27.4%
|19,640,000
|33%
|-
|Isi-Afrikaans
|6,855,082
|13.5%
|10,300,000
|20.2%
|17,160,000
|29%
|-
|Ilimi Lezandla le-SA
|234,655
|0.5%
|500,000
|1.0%
|834,655
|1.5%
|-
|Amanye Amalimi
|828,258
|1.6%
|
|
|
|
|-
|'''Isibalo Sisoke'''
|'''50,961,443'''
|'''100.0%'''
|
|
|
|
|}

== IsiNdebele ==
[[Isimumathi:Ndebele women-1.jpg|thumb|Abomma bamaNdebele]]
IsiNdebele seSewula Afrika ngelinye lamalimi akhulunywa enarheni le. Isizathu sokuthi kuthiwe siNdebele seSewula Afrika kukuthi kunesiNdebele seZimbabwe. &lt;ref&gt;{{Cite web|last=web-lingo|date=2012-10-19|title=Ndebele: What is Ndebele?|url=https://web-lingo.com/ndebele-what-is-ndebele/#:~:text=Northern%20Ndebele,%20or%20Matabele,%20or,nineteenth%20century%20during%20the%20Mfecane.|access-date=2025-05-15|website=Web-lingo|language=en-ZA}}&lt;/ref&gt; Ngokwethebula elingehla, abantu abakhuluma isiNdebele - abasimunyileko, okulilimi lesibili nalabo okulilimi lesithathu kibo - bangaphezu kweengidi ezine. Ilimeli likhulunywa khulukhulu esifundeni seMpumalanga eendaweni ezinjengaKwaNdebele, eMalahleni, e-Middleburg, e-Belfast, kwaDlawulale nakezinye iindawo. 

IsiNdebele esisemthethweni siNzunza, kodwana kusese nesiNdebele sakwaManala nesiNdebele seMoletlane. IsiNdebele sikhulunywa khulukhulu esifundeni seMpumalanga eendaweni ezinjengaKwaNdebele, eMalahleni, eMiddleburg njll.&lt;ref name=&quot;:0&quot; /&gt; AmaNdebele aziwa njengesitjhaba esithanda imibala emihle nekhanyako ongayibona endleleni abambatha ngayo nabenza ngayo imigwalo yabo.

== IsiSwati ==
IsiSwati sikhulunywa eenarheni ezimbili, eSewula Afrika neSwatini. Ngokwethebula elingehla abantu abakhuluma isiSwati eSewula Afrika  bangaphezu kweengidi ezilikhomba.&lt;ref name=&quot;:1&quot; /&gt; KunesiSwati esikhulunywa eSwatini kwaManzini, eShiselweni neHhoho.&lt;ref name=&quot;:2&quot; /&gt; Abantu abakhuluma isiSwati eSwatini babalelwa eengidini ezine. &lt;ref&gt;https://en.wikipedia.org/wiki/Zulu_language&lt;/ref&gt;

== IsiZulu ==
IsiZulu ngelinye lamalimi adumileko asemthethweni eSewula Afrika elikhulunywa babantu ababgaogezu kweengidi ezimatjhumi amahlanu, kuthi labo abalimunyileko bangaphezu kweengidi ezilitjhumi nanye. &lt;ref name=&quot;:1&quot; /&gt; IsiZulu sikhulunywa khulu KwaZulu Natal, esiFundeni se-Gauteng nakezinye iimfunda.

== IsiXhosa ==
IsiXhosa naso singelinye lamalimi weSewula Afrika asemthethweni. IsiXhosa sikhulunywa babantu abangaphezu kweengidi ezimatjhumi amathathu nobunane, kuthi labo okulimi labo lokubelethwa bangaphezu kweengidi ezibunane. &lt;ref name=&quot;:1&quot; /&gt; IsiXhosa sikhulunywa khulukhulu esiFundeni seTjingalanga Kapa, eTlhagwini  Kapa nesiFundeni se-Gauteng.&lt;ref&gt;{{Cite web|last=Alexander|first=Mary|date=2025-04-06|title=The languages of South Africa|url=https://southafrica-info.com/arts-culture/11-languages-south-africa/#:~:text=Among%20South%20Africa's%20population%20groups,),%20based%20on%20Census%202022.|access-date=2025-05-23|website=South Africa Gateway|language=en-GB}}&lt;/ref&gt;

== IsiSuthu ==

== IsiTswana ==

== IsiPedi ==

== IsiVenda ==

== IsiTsonga ==

== I-''Afrikaans'' ==

== IsiNgisi ==

== ILimi LeZandla ==

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>jowuu03xdh3xvk4na7jdrmjiy67lj5z</sha1>
    </revision>
    <revision>
      <id>2845</id>
      <parentid>2839</parentid>
      <timestamp>2025-05-26T10:40:42Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>added paragraphs</comment>
      <origin>2845</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9468" sha1="8h1v4zf0nmk2xmgmgowkob6auqnny3r" xml:space="preserve">[[Isimumathi:Flag of South Africa.svg|thumb|Iflarha leSewula Afrika]]

== Draft Space 1 ==

= Amalimi WeSewula Afrika =
'''Inarha yeSewula Afrika''' yinarha enabantu abanamasiko nabaneenzinda ezihlukahlukeneko, nabakhuluma amalimi ahlukahlukeneko. Inengi labantu enarheni le lisesiqhemeni sokuthoma sabantu abakhuluma amalimi angaphasi kwesiNguni, okusiZulu, isiXhosa, [[Isindebele|isiNdebele]] nesiSwati. Bese isiqhema sesibili ngobukhulu ngesikhuluma amalimi wesiSuthu, okusiTswana, isiPedi (okusiSuthu seTlhagwini) nesiSuthu (okusiSuthu seSewula, namkha isiSuthu sesiShweshwe). Bese kunesiqhema esikhuluma isiTsonga nesiqhema esikhuluma isiVenda.&lt;ref&gt;{{Cite web |date=2025-05-14 |title=South Africa - Languages, Dialects, Afrikaans {{!}} Britannica |url=https://www.britannica.com/place/South-Africa/Languages |access-date=2025-05-15 |website=www.britannica.com |language=en}}&lt;/ref&gt;

Ngaphezu kwamalimi abaliweko la kunamalimi ahlobene nawo. Ngokwesibonelo, esiNdebeleni kunesiNala, nesiNdebele seMoletlane. &lt;ref name=&quot;:0&quot;&gt;{{Cite web|title=Ndebele people, traditions culture|url=https://www.africancraftsmarket.com/african-tribes/ndebele-people.html|access-date=2025-05-15|website=www.africancraftsmarket.com}}&lt;/ref&gt; EsiXhoseni kube nesiNgqika, isiThembu, isiBhaca, isiGcaleka, isiMpondo, isiMpondomise, isiMfengu nesiBomvana.&lt;ref&gt;{{Cite web|title=XHOSA - South African Language Xhosa|url=https://www.sa-venues.com/language-xhosa.htm#:~:text=Xhosa%20has%20been%20grouped%20into,yet%20pretty-sounding,%20language.|access-date=2025-05-15|website=www.sa-venues.com}}&lt;/ref&gt; Kusese nelimi lesiThwa elibandaka isi-Khoe, isi-Tu isi-Kx'a, namanye amalimi.&lt;ref&gt;{{Cite web|title=AFRICA {{!}} 101 Last Tribes - San people|url=https://www.101lasttribes.com/tribes/san.html|access-date=2025-05-15|website=www.101lasttribes.com}}&lt;/ref&gt; Bese isiSwati kunesikhulunywa eManzini, esikhulunywa eShiselweni, nesikhulunywa eHhoho.&lt;ref name=&quot;:2&quot;&gt;{{Cite web|last=web-lingo|date=2013-01-07|title=SA’s Eleven Official Languages: SiSwati|url=https://web-lingo.com/sas-eleven-official-languages-siswati/#:~:text=Swazi%20is%20most%20closely%20related,considered%20closer%20to%20standard%20Swazi.|access-date=2025-05-15|website=Web-lingo|language=en-ZA}}&lt;/ref&gt; IsiPedi naso sinamalinyana angaphasi kwaso anjengesiTlokwa nesiLobedu.&lt;ref&gt;{{Cite web|title=free online course|url=https://www.unisa.ac.za/static/corporate_web/Content/UnisaOpen/freeOnlineCourse/nSotho/nSotho.html#:~:text=Northern%20Sotho%20is%20based%20mainly,(Cf.|access-date=2025-05-15|website=www.unisa.ac.za}}&lt;/ref&gt; Bese kube namalimi angasiwo wendabuko, namkha amalimi wesikhuwa akhulunywako njengesiNgisi nesiBhuru. Woke amalimi la namanye angakabalwa lapha malimi akhulunywa babantu beSewula Afrika.

== Amalimi Asemthethweni ==
Amalimi aseMthethweni eSewula Afrika siNdebele, isiZulu, isiSwati, isiXhosa, isiSuthu, isiPedi, isiTswana, isiVenda, isiTsonga okumalimi wendabuko, bese kuba siBhuru nesiNgisi. Ithebula elingenzasi litjengisa isibalo sabantu abakhuluma amalimi asemthethweni eSewula Afrika namaphesente wabalikhulumako esibalweni sabo boke abantu abahlala eSewula Afrika ngokweembalobalo zango-2022. &lt;ref name=&quot;:1&quot;&gt;https://en.wikipedia.org/wiki/Languages_of_South_Africa#cite_note-EthnologueZA-7&lt;/ref&gt;
{| class=&quot;wikitable sortable mw-collapsible&quot;
|+
! rowspan=&quot;2&quot; |Ilimi
! colspan=&quot;2&quot; |Ilimi lebele&lt;ref name=&quot;:1&quot; /&gt;
! colspan=&quot;2&quot; |Ilimi lesibili&lt;ref name=&quot;:1&quot; /&gt;
! colspan=&quot;2&quot; |Ilimi lesithathu&lt;ref name=&quot;:1&quot; /&gt;
|-
!Isibalo 
!Amaphesente 
!Isibalo 
!Amaphesente 
!Isibalo 
!Amaphesente 
|-
|IsiZulu
|11,587,374
|22.7%
|15,700,000
|30.8%
|27,300,000
|46%
|-
|IsiXhosa
|8,154,258
|16.0%
|11,000,000
|21.6%
|19,150,000
|33%
|-
|IsiVenda
|1,209,388
|2.4%
|1,700,000
|3.3%
|2,910,000
|5%
|-
|IsiTswana
|4,067,248
|8.0%
|7,700,000
|15.1%
|11,770,000
|20%
|-
|IsiTsonga
|2,277,148
|4.5%
|3,400,000
|6.6%
|5,680,000
|10%
|-
|IsiSwati
|1,297,046
|2.5%
|2,400,000
|4.7%
|3,700,000
|6%
|-
|IsiSuthu
|3,849,563
|7.6%
|7,900,000
|15.5%
|11,750,000
|20%
|-
|IsiPedi
|4,618,576
|9.1%
|9,100,000
|17.8%
|13,720,000
|23%
|-
|IsiNdebele
|1,090,223
|2.1%
|1,400,000
|2.7%
|2,490,000
|4%
|-
|IsiNgisi
|4,892,623
|9.6%
|14,000,000
|27.4%
|19,640,000
|33%
|-
|Isi-Afrikaans
|6,855,082
|13.5%
|10,300,000
|20.2%
|17,160,000
|29%
|-
|Ilimi Lezandla le-SA
|234,655
|0.5%
|500,000
|1.0%
|834,655
|1.5%
|-
|Amanye Amalimi
|828,258
|1.6%
|
|
|
|
|-
|'''Isibalo Sisoke'''
|'''50,961,443'''
|'''100.0%'''
|
|
|
|
|}

== IsiNdebele ==
[[Isimumathi:Ndebele women-1.jpg|thumb|Abomma bamaNdebele]]
IsiNdebele seSewula Afrika ngelinye lamalimi akhulunywa enarheni le. Isizathu sokuthi kuthiwe siNdebele seSewula Afrika kukuthi kunesiNdebele seZimbabwe. &lt;ref&gt;{{Cite web|last=web-lingo|date=2012-10-19|title=Ndebele: What is Ndebele?|url=https://web-lingo.com/ndebele-what-is-ndebele/#:~:text=Northern%20Ndebele,%20or%20Matabele,%20or,nineteenth%20century%20during%20the%20Mfecane.|access-date=2025-05-15|website=Web-lingo|language=en-ZA}}&lt;/ref&gt; Ngokwethebula elingehla, abantu abakhuluma isiNdebele - abasimunyileko, okulilimi lesibili nalabo okulilimi lesithathu kibo - bangaphezu kweengidi ezine. Ilimeli likhulunywa khulukhulu esifundeni seMpumalanga eendaweni ezinjengaKwaNdebele, eMalahleni, e-Middleburg, e-Belfast, kwaDlawulale nakezinye iindawo  njengesiFunda seLimpopo. 

IsiNdebele esisemthethweni siNzunza, kodwana kusese nesiNdebele sakwaManala nesiNdebele seMoletlane. IsiNdebele sikhulunywa khulukhulu esifundeni seMpumalanga eendaweni ezinjengaKwaNdebele, eMalahleni, eMiddleburg njll.&lt;ref name=&quot;:0&quot; /&gt; AmaNdebele aziwa njengesitjhaba esithanda imibala emihle nekhanyako ongayibona endleleni abambatha ngayo nabenza ngayo imigwalo yabo.

AmaNdebele bekangaphasi kwesiqhema sabaMbo ngaphambi kobana sizijamele ngaphasi kweNgwenyama uNdebele. Ngikho namhlanjesi kunezici ezifanako phakathi kwelimi lesiNdebele nelimi lesiHlubi, isiBhaca, isiMpondo nesiMpondomise.  Ngemva kwesikhathi uNdebele wabeletha uMkhalangana owabeletha umNtungwa. Ngemva kwesikhathi umNtungwa wabeletha uNjonono owabeletha uNjonono. UNjonono wabeletha uNanasi, uNanasi wabeletha uMafana. UMafana wabeletha uMhlanga owabeletha uMusi. Kusesikhathini seNgwenyama uMusi lapha amaNdebele ahlukana khona waba maNzunza namaNala. AmaNdebele akheka ngaleyondlela sele ahlala eSewula Afrika nje. &lt;ref&gt;https://en.wikipedia.org/wiki/Southern_Ndebele_language&lt;/ref&gt;

== IsiSwati ==
[[Isimumathi:Indoni Parade 2018. Swati Kingdom by Sizwe Sibiya (10).jpg|thumb]]
IsiSwati sikhulunywa eenarheni ezimbili, eSewula Afrika neSwatini. Ngokwethebula elingehla abantu abakhuluma isiSwati eSewula Afrika  bangaphezu kweengidi ezilikhomba.&lt;ref name=&quot;:1&quot; /&gt; KunesiSwati esikhulunywa eSwatini kwaManzini, eShiselweni neHhoho.&lt;ref name=&quot;:2&quot; /&gt; Abantu abakhuluma isiSwati eSwatini babalelwa eengidini ezine. &lt;ref name=&quot;:3&quot;&gt;https://en.wikipedia.org/wiki/Zulu_language&lt;/ref&gt; 

AmaSwati bewasiqhenyana esincani sabeNguni ebesaziwa bona Mangwane. Ngokukhamba kwesikhathi isiqhemesi sahlangana nesiqhenyana sabeSuthu ebesihlala endaweni namhlanjesi ebizwa bona kuseSwatini. Ngemva kwalokho bakhula baba sisizwe ngaphasi kweNgwenyama uDlamini III eyathatha iintambo eNgwenyameni uMaseko, yathatha isitjhaba yayosinzinzisa emlanjeni iPongola bahlala eduze namaNdwandwe ngo-1750. UDlamini III walandelwa yiNgwenyama uNgwane III okukholelwa bona nguye owaba yiNgwenyama yokuthoma eyabusa indawo namhlanjesi ebizwa bona kuseSwatini.&lt;ref&gt;https://en.wikipedia.org/wiki/Swazi_people&lt;/ref&gt;

== IsiZulu ==
[[Isimumathi:Zulu Krieger.jpg|thumb]]
IsiZulu ngelinye lamalimi adumileko asemthethweni eSewula Afrika elikhulunywa babantu ababgaogezu kweengidi ezimatjhumi amahlanu, kuthi labo abalimunyileko bangaphezu kweengidi ezilitjhumi nanye. &lt;ref name=&quot;:1&quot; /&gt; IsiZulu sikhulunywa khulu KwaZulu Natal, esiFundeni se-Gauteng nakezinye iimfunda.

Umuntu owadlala indima ekulu ekwakhekeni kwesitjhaba samaZulu yiNgwenyama uShaka. UShaka walwa neentjhaba ezincani nezikulu zabeNguni kuhlanganise namaNdwandwe wazihlula. Ngemva kwalokho wazibiza ngoZulu obekangukhokho omkhulu wesitjhaba abelethelwa kiso. Iintjhabezi zahlangana kwavela ilimi lesiZulu.&lt;ref name=&quot;:3&quot; /&gt; 

== IsiXhosa ==
[[Isimumathi:Xhosa traditionally dressed women.jpg|thumb|250x250px|Abomma bamaXhosa]]
IsiXhosa naso singelinye lamalimi weSewula Afrika asemthethweni. IsiXhosa sikhulunywa babantu abangaphezu kweengidi ezimatjhumi amathathu nobunane, kuthi labo okulimi labo lokubelethwa bangaphezu kweengidi ezibunane. &lt;ref name=&quot;:1&quot; /&gt; IsiXhosa sikhulunywa khulukhulu esiFundeni seTjingalanga Kapa, eTlhagwini  Kapa nesiFundeni se-Gauteng.&lt;ref&gt;{{Cite web|last=Alexander|first=Mary|date=2025-04-06|title=The languages of South Africa|url=https://southafrica-info.com/arts-culture/11-languages-south-africa/#:~:text=Among%20South%20Africa's%20population%20groups,),%20based%20on%20Census%202022.|access-date=2025-05-23|website=South Africa Gateway|language=en-GB}}&lt;/ref&gt;

Ekadeni bekuneenqhema zabeNguni ezakha ubuhlobo neentjhaba zabaThwa nabaKhoekhoe. Ngokukhamba kwesikhathi iintjhabezi zahlangana zaba sisizwe ngaphasi kokubusa kweNgwenyama uTshawe owahlula isitjhaba samaCirha namaJwarha. Ngemva kwalokho wahlanganisa zoke iintjhaba ezincani kuhlanganise nesabaKhoekhoe. Labeletheka njalo-ke ilimi lesiXhosa.&lt;ref&gt;https://en.wikipedia.org/wiki/Xhosa_people&lt;/ref&gt;

== IsiSuthu ==

== IsiTswana ==

== IsiPedi ==

== IsiVenda ==

== IsiTsonga ==

== I-''Afrikaans'' ==

== IsiNgisi ==

== ILimi LeZandla ==

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>8h1v4zf0nmk2xmgmgowkob6auqnny3r</sha1>
    </revision>
    <revision>
      <id>2846</id>
      <parentid>2845</parentid>
      <timestamp>2025-05-26T15:38:38Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>added paragraphs</comment>
      <origin>2846</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="12575" sha1="9nyn68tx9mrevjlg4msiticmgaeu0u7" xml:space="preserve">[[Isimumathi:Flag of South Africa.svg|thumb|Iflarha leSewula Afrika]]

== Draft Space 1 ==

= Amalimi WeSewula Afrika =
'''Inarha yeSewula Afrika''' yinarha enabantu abanamasiko nabaneenzinda ezihlukahlukeneko, nabakhuluma amalimi ahlukahlukeneko. Inengi labantu enarheni le lisesiqhemeni sokuthoma sabantu abakhuluma amalimi angaphasi kwesiNguni, okusiZulu, isiXhosa, [[Isindebele|isiNdebele]] nesiSwati. Bese isiqhema sesibili ngobukhulu ngesikhuluma amalimi wesiSuthu, okusiTswana, isiPedi (okusiSuthu seTlhagwini) nesiSuthu (okusiSuthu seSewula, namkha isiSuthu sesiShweshwe). Bese kunesiqhema esikhuluma isiTsonga nesiqhema esikhuluma isiVenda.&lt;ref&gt;{{Cite web |date=2025-05-14 |title=South Africa - Languages, Dialects, Afrikaans {{!}} Britannica |url=https://www.britannica.com/place/South-Africa/Languages |access-date=2025-05-15 |website=www.britannica.com |language=en}}&lt;/ref&gt;

Ngaphezu kwamalimi abaliweko la kunamalimi ahlobene nawo. Ngokwesibonelo, esiNdebeleni kunesiNala, nesiNdebele seMoletlane. &lt;ref name=&quot;:0&quot;&gt;{{Cite web|title=Ndebele people, traditions culture|url=https://www.africancraftsmarket.com/african-tribes/ndebele-people.html|access-date=2025-05-15|website=www.africancraftsmarket.com}}&lt;/ref&gt; EsiXhoseni kube nesiNgqika, isiThembu, isiBhaca, isiGcaleka, isiMpondo, isiMpondomise, isiMfengu nesiBomvana.&lt;ref&gt;{{Cite web|title=XHOSA - South African Language Xhosa|url=https://www.sa-venues.com/language-xhosa.htm#:~:text=Xhosa%20has%20been%20grouped%20into,yet%20pretty-sounding,%20language.|access-date=2025-05-15|website=www.sa-venues.com}}&lt;/ref&gt; Kusese nelimi lesiThwa elibandaka isi-Khoe, isi-Tu isi-Kx'a, namanye amalimi.&lt;ref&gt;{{Cite web|title=AFRICA {{!}} 101 Last Tribes - San people|url=https://www.101lasttribes.com/tribes/san.html|access-date=2025-05-15|website=www.101lasttribes.com}}&lt;/ref&gt; Bese isiSwati kunesikhulunywa eManzini, esikhulunywa eShiselweni, nesikhulunywa eHhoho.&lt;ref name=&quot;:2&quot;&gt;{{Cite web|last=web-lingo|date=2013-01-07|title=SA’s Eleven Official Languages: SiSwati|url=https://web-lingo.com/sas-eleven-official-languages-siswati/#:~:text=Swazi%20is%20most%20closely%20related,considered%20closer%20to%20standard%20Swazi.|access-date=2025-05-15|website=Web-lingo|language=en-ZA}}&lt;/ref&gt; IsiPedi naso sinamalinyana angaphasi kwaso anjengesiTlokwa nesiLobedu.&lt;ref&gt;{{Cite web|title=free online course|url=https://www.unisa.ac.za/static/corporate_web/Content/UnisaOpen/freeOnlineCourse/nSotho/nSotho.html#:~:text=Northern%20Sotho%20is%20based%20mainly,(Cf.|access-date=2025-05-15|website=www.unisa.ac.za}}&lt;/ref&gt; Bese kube namalimi angasiwo wendabuko, namkha amalimi wesikhuwa akhulunywako njengesiNgisi nesiBhuru. Woke amalimi la namanye angakabalwa lapha malimi akhulunywa babantu beSewula Afrika.

== Amalimi Asemthethweni ==
Amalimi aseMthethweni eSewula Afrika siNdebele, isiZulu, isiSwati, isiXhosa, isiSuthu, isiPedi, isiTswana, isiVenda, isiTsonga okumalimi wendabuko, bese kuba siBhuru nesiNgisi. Ithebula elingenzasi litjengisa isibalo sabantu abakhuluma amalimi asemthethweni eSewula Afrika namaphesente wabalikhulumako esibalweni sabo boke abantu abahlala eSewula Afrika ngokweembalobalo zango-2022. &lt;ref name=&quot;:1&quot;&gt;https://en.wikipedia.org/wiki/Languages_of_South_Africa#cite_note-EthnologueZA-7&lt;/ref&gt;
{| class=&quot;wikitable sortable mw-collapsible&quot;
|+
! rowspan=&quot;2&quot; |Ilimi
! colspan=&quot;2&quot; |Ilimi lebele&lt;ref name=&quot;:1&quot; /&gt;
! colspan=&quot;2&quot; |Ilimi lesibili&lt;ref name=&quot;:1&quot; /&gt;
! colspan=&quot;2&quot; |Ilimi lesithathu&lt;ref name=&quot;:1&quot; /&gt;
|-
!Isibalo 
!Amaphesente 
!Isibalo 
!Amaphesente 
!Isibalo 
!Amaphesente 
|-
|IsiZulu
|11,587,374
|22.7%
|15,700,000
|30.8%
|27,300,000
|46%
|-
|IsiXhosa
|8,154,258
|16.0%
|11,000,000
|21.6%
|19,150,000
|33%
|-
|IsiVenda
|1,209,388
|2.4%
|1,700,000
|3.3%
|2,910,000
|5%
|-
|IsiTswana
|4,067,248
|8.0%
|7,700,000
|15.1%
|11,770,000
|20%
|-
|IsiTsonga
|2,277,148
|4.5%
|3,400,000
|6.6%
|5,680,000
|10%
|-
|IsiSwati
|1,297,046
|2.5%
|2,400,000
|4.7%
|3,700,000
|6%
|-
|IsiSuthu
|3,849,563
|7.6%
|7,900,000
|15.5%
|11,750,000
|20%
|-
|IsiPedi
|4,618,576
|9.1%
|9,100,000
|17.8%
|13,720,000
|23%
|-
|IsiNdebele
|1,090,223
|2.1%
|1,400,000
|2.7%
|2,490,000
|4%
|-
|IsiNgisi
|4,892,623
|9.6%
|14,000,000
|27.4%
|19,640,000
|33%
|-
|Isi-Afrikaans
|6,855,082
|13.5%
|10,300,000
|20.2%
|17,160,000
|29%
|-
|Ilimi Lezandla le-SA
|234,655
|0.5%
|500,000
|1.0%
|834,655
|1.5%
|-
|Amanye Amalimi
|828,258
|1.6%
|
|
|
|
|-
|'''Isibalo Sisoke'''
|'''50,961,443'''
|'''100.0%'''
|
|
|
|
|}

== IsiNdebele ==
[[Isimumathi:Ndebele women-1.jpg|thumb|Abomma bamaNdebele]]
IsiNdebele seSewula Afrika ngelinye lamalimi akhulunywa enarheni le. Isizathu sokuthi kuthiwe siNdebele seSewula Afrika kukuthi kunesiNdebele seZimbabwe. &lt;ref&gt;{{Cite web|last=web-lingo|date=2012-10-19|title=Ndebele: What is Ndebele?|url=https://web-lingo.com/ndebele-what-is-ndebele/#:~:text=Northern%20Ndebele,%20or%20Matabele,%20or,nineteenth%20century%20during%20the%20Mfecane.|access-date=2025-05-15|website=Web-lingo|language=en-ZA}}&lt;/ref&gt; Ngokwethebula elingehla, abantu abakhuluma isiNdebele - abasimunyileko, okulilimi lesibili nalabo okulilimi lesithathu kibo - bangaphezu kweengidi ezine. Ilimeli likhulunywa khulukhulu esifundeni seMpumalanga eendaweni ezinjengaKwaNdebele, eMalahleni, e-Middleburg, e-Belfast, kwaDlawulale nakezinye iindawo  njengesiFunda seLimpopo. 

IsiNdebele esisemthethweni siNzunza, kodwana kusese nesiNdebele sakwaManala nesiNdebele seMoletlane. IsiNdebele sikhulunywa khulukhulu esifundeni seMpumalanga eendaweni ezinjengaKwaNdebele, eMalahleni, eMiddleburg njll.&lt;ref name=&quot;:0&quot; /&gt; AmaNdebele aziwa njengesitjhaba esithanda imibala emihle nekhanyako ongayibona endleleni abambatha ngayo nabenza ngayo imigwalo yabo.

AmaNdebele bekangaphasi kwesiqhema sabaMbo ngaphambi kobana sizijamele ngaphasi kweNgwenyama uNdebele. Ngikho namhlanjesi kunezici ezifanako phakathi kwelimi lesiNdebele nelimi lesiHlubi, isiBhaca, isiMpondo nesiMpondomise.  Ngemva kwesikhathi uNdebele wabeletha uMkhalangana owabeletha umNtungwa. Ngemva kwesikhathi umNtungwa wabeletha uNjonono owabeletha uNjonono. UNjonono wabeletha uNanasi, uNanasi wabeletha uMafana. UMafana wabeletha uMhlanga owabeletha uMusi. Kusesikhathini seNgwenyama uMusi lapha amaNdebele ahlukana khona waba maNzunza namaNala. AmaNdebele akheka ngaleyondlela sele ahlala eSewula Afrika nje. &lt;ref&gt;https://en.wikipedia.org/wiki/Southern_Ndebele_language&lt;/ref&gt;

== IsiSwati ==
[[Isimumathi:Indoni Parade 2018. Swati Kingdom by Sizwe Sibiya (10).jpg|thumb|AmaSwati ]]
IsiSwati sikhulunywa eenarheni ezimbili, eSewula Afrika neSwatini. Ngokwethebula elingehla abantu abakhuluma isiSwati eSewula Afrika  bangaphezu kweengidi ezilikhomba.&lt;ref name=&quot;:1&quot; /&gt; KunesiSwati esikhulunywa eSwatini kwaManzini, eShiselweni neHhoho.&lt;ref name=&quot;:2&quot; /&gt; Abantu abakhuluma isiSwati eSwatini babalelwa eengidini ezine. &lt;ref name=&quot;:3&quot;&gt;https://en.wikipedia.org/wiki/Zulu_language&lt;/ref&gt; 

AmaSwati bewasiqhenyana esincani sabeNguni ebesaziwa bona Mangwane. Ngokukhamba kwesikhathi isiqhemesi sahlangana nesiqhenyana sabeSuthu ebesihlala endaweni namhlanjesi ebizwa bona kuseSwatini. Ngemva kwalokho bakhula baba sisizwe ngaphasi kweNgwenyama uDlamini III eyathatha iintambo eNgwenyameni uMaseko, yathatha isitjhaba yayosinzinzisa emlanjeni iPongola bahlala eduze namaNdwandwe ngo-1750. UDlamini III walandelwa yiNgwenyama uNgwane III okukholelwa bona nguye owaba yiNgwenyama yokuthoma eyabusa indawo namhlanjesi ebizwa bona kuseSwatini.&lt;ref&gt;https://en.wikipedia.org/wiki/Swazi_people&lt;/ref&gt;

== IsiZulu ==
[[Isimumathi:Zulu Krieger.jpg|thumb|Abobaba bamaZulu bayagida]]
IsiZulu ngelinye lamalimi adumileko asemthethweni eSewula Afrika elikhulunywa babantu ababgaogezu kweengidi ezimatjhumi amahlanu, kuthi labo abalimunyileko bangaphezu kweengidi ezilitjhumi nanye. &lt;ref name=&quot;:1&quot; /&gt; IsiZulu sikhulunywa khulu KwaZulu Natal, esiFundeni se-Gauteng nakezinye iimfunda.

Umuntu owadlala indima ekulu ekwakhekeni kwesitjhaba samaZulu yiNgwenyama uShaka. UShaka walwa neentjhaba ezincani nezikulu zabeNguni kuhlanganise namaNdwandwe wazihlula. Ngemva kwalokho wazibiza ngoZulu obekangukhokho omkhulu wesitjhaba abelethelwa kiso. Iintjhabezi zahlangana kwavela ilimi lesiZulu.&lt;ref name=&quot;:3&quot; /&gt;  

== IsiXhosa ==
[[Isimumathi:Xhosa traditionally dressed women.jpg|thumb|250x250px|Abomma bamaXhosa]]
IsiXhosa naso singelinye lamalimi weSewula Afrika asemthethweni. IsiXhosa sikhulunywa babantu abangaphezu kweengidi ezimatjhumi amathathu nobunane, kuthi labo okulimi labo lokubelethwa bangaphezu kweengidi ezibunane. &lt;ref name=&quot;:1&quot; /&gt; IsiXhosa sikhulunywa khulukhulu esiFundeni seTjingalanga Kapa, eTlhagwini  Kapa nesiFundeni se-Gauteng.&lt;ref&gt;{{Cite web|last=Alexander|first=Mary|date=2025-04-06|title=The languages of South Africa|url=https://southafrica-info.com/arts-culture/11-languages-south-africa/#:~:text=Among%20South%20Africa's%20population%20groups,),%20based%20on%20Census%202022.|access-date=2025-05-23|website=South Africa Gateway|language=en-GB}}&lt;/ref&gt;

Ekadeni bekuneenqhema zabeNguni ezakha ubuhlobo neentjhaba zabaThwa nabaKhoekhoe. Ngokukhamba kwesikhathi iintjhabezi zahlangana zaba sisizwe ngaphasi kokubusa kweNgwenyama uTshawe owahlula isitjhaba samaCirha namaJwarha. Ngemva kwalokho wahlanganisa zoke iintjhaba ezincani kuhlanganise nesabaKhoekhoe. Labeletheka njalo-ke ilimi lesiXhosa.&lt;ref&gt;https://en.wikipedia.org/wiki/Xhosa_people&lt;/ref&gt;

== IsiSuthu ==
[[Isimumathi:Sotho regalia.jpg|thumb|Abobaba babeSuthu]]
IsiSuthu lilimi elisemthethweni eSewula Afrika elikhunywa babantu abangaphezu kweengidi ezimatjhumi amabili nambili. Okulilmi labo abalimunyileko bangaphezu kweengidi ezintathu. &lt;ref name=&quot;:1&quot; /&gt; IsiSuthu sikhulunywa khulu enarheni yeLesotho, kanti eSewula Afrikapha sikhulunywa khulukhulu esiFundeni seFreestate, seGauteng. Umhlobo lo wesiSuthu ubizwa ngokobana siSuthu seSewula ngombana uhlukaniswa nesiSuthu seTlhagwini - okusiPedi, nesiSuthu seTjingalanga - okusiTswana.

Emandulo abeSuthu beza eSewula Afrika bavela eTlhagwini njengezinye iintjhaba bafika bahlala etlhagwini yeSewula Afrika. Bafika baba ziinqhenyana ezinjengabaTaung, abaSia, abaFokeng, amaKgolokoe nabaKwena nezinye iinqenyana. Kuhlekuhle umndeni webukhosini eLesotho mndeni wabaKwena. AbeSuthwaba ngibo-ke ababanikazi belimi lesiSuthu esikhulunywa eSewula Afrika neLesotho.&lt;ref&gt;{{Cite web|title=SOUTHERN SESOTHO - South African Language Southern Sesotho|url=https://www.sa-venues.com/language-southern-sesotho.htm|access-date=2025-05-26|website=www.sa-venues.com}}&lt;/ref&gt;

== IsiTswana ==
[[Isimumathi:Tswana Dancers 3.jpg|thumb|Isiqhema esigidako sabaTswana]]
IsiTswana nalo ngelinye lamalimi asesiqhemeni sesiSuthu seTjingalanga esikhulunywa eSewula Afrika neBotswana. Abantu abasikhulumako eSewula Afrika bangaphezu kweengidi ezimatjhumi amabili nantathu, abalimunyileko bangaphezu kweengidi ezine.&lt;ref name=&quot;:1&quot; /&gt; isiTswana sikhulunywa khulu enarheni yeBotswana kanti eSewula Afrika sikhulunywa khulu esiFundeni seTlhagwini-Tjhingalanga, neGauteng.

Emandulo abeTswana bebangaphasi kwesiqhema sabeSuthu nabazakufika eSewula Afrika bavela eTlhagwini ne-Afrika. Bafika baba ziinqhenyana ezinjengabaTaung, abaSia, abaFokeng, amaKgolokoe nabaKwena kunye nezinye iinqhenyana. Bafika endaweni ebizwa ngokobana yiBotswana namhlanjesi balwa nabaThwa babahlula, bese bakha umbuso wabaTswana. Ngibo-ke namhlanjesi ababanikazi belimi lesiTswana.&lt;ref&gt;{{Cite web|title=AFRICA {{!}} 101 Last Tribes - Tswana people|url=http://www.101lasttribes.com/tribes/tswana.html|access-date=2025-05-26|website=www.101lasttribes.com}}&lt;/ref&gt;

== IsiPedi ==
[[Isimumathi:Pedi Living Culture Route, Limpopo, South Africa (2417712111).jpg|thumb|Umuzi wesiPedi]]
IsiPedi ([https://www.sahistory.org.za/article/pedi Sepedi]) nalo ngelinye lamalimi angaphasi kwesiSuthu atloliswe ngokomthetho eSewula Afrika, begodu saziwa ngokuthi siSuthu seTlhagwini. &lt;ref name=&quot;:4&quot;&gt;{{Cite web|title=AFRICA {{!}} 101 Last Tribes - Pedi people|url=http://www.101lasttribes.com/tribes/pedi.html|access-date=2025-05-26|website=www.101lasttribes.com}}&lt;/ref&gt; Ilimeli likhulunywa khulukhulu esiFundeni seLimpopo neseGauteng babantu abalinganiswela eengidini ezimatjhumi amabili nekhomba.&lt;ref name=&quot;:1&quot; /&gt; 

Ekadeni isiqhemesi besiyingcenye yesiqhema sabeSuthu, kwathi nakukhamba ezinye iinqhema sona sasala ngetlhagwini yeSewula Afrika. Sineenqhenyana ezinengana okucatjangelwa bona sikhuluma amalinyana amatjhumi amathathu. Abanye bathi isiSuthu seTlhagwini akusiso isiPedi kodwana lilimi elihlukileko. &lt;ref name=&quot;:4&quot; /&gt;

== IsiVenda ==

== IsiTsonga ==

== I-''Afrikaans'' ==

== IsiNgisi ==

== ILimi LeZandla ==

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>9nyn68tx9mrevjlg4msiticmgaeu0u7</sha1>
    </revision>
    <revision>
      <id>2847</id>
      <parentid>2846</parentid>
      <timestamp>2025-05-26T16:18:40Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>/* IsiNdebele */</comment>
      <origin>2847</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="13646" sha1="0tw7m8wn6t9sr7hccjf1y1xf72ucaoy" xml:space="preserve">[[Isimumathi:Flag of South Africa.svg|thumb|Iflarha leSewula Afrika]]

== Draft Space 1 ==

= Amalimi WeSewula Afrika =
'''Inarha yeSewula Afrika''' yinarha enabantu abanamasiko nabaneenzinda ezihlukahlukeneko, nabakhuluma amalimi ahlukahlukeneko. Inengi labantu enarheni le lisesiqhemeni sokuthoma sabantu abakhuluma amalimi angaphasi kwesiNguni, okusiZulu, isiXhosa, [[Isindebele|isiNdebele]] nesiSwati. Bese isiqhema sesibili ngobukhulu ngesikhuluma amalimi wesiSuthu, okusiTswana, isiPedi (okusiSuthu seTlhagwini) nesiSuthu (okusiSuthu seSewula, namkha isiSuthu sesiShweshwe). Bese kunesiqhema esikhuluma isiTsonga nesiqhema esikhuluma isiVenda.&lt;ref&gt;{{Cite web |date=2025-05-14 |title=South Africa - Languages, Dialects, Afrikaans {{!}} Britannica |url=https://www.britannica.com/place/South-Africa/Languages |access-date=2025-05-15 |website=www.britannica.com |language=en}}&lt;/ref&gt;

Ngaphezu kwamalimi abaliweko la kunamalimi ahlobene nawo. Ngokwesibonelo, esiNdebeleni kunesiNala, nesiNdebele seMoletlane. &lt;ref name=&quot;:0&quot;&gt;{{Cite web|title=Ndebele people, traditions culture|url=https://www.africancraftsmarket.com/african-tribes/ndebele-people.html|access-date=2025-05-15|website=www.africancraftsmarket.com}}&lt;/ref&gt; EsiXhoseni kube nesiNgqika, isiThembu, isiBhaca, isiGcaleka, isiMpondo, isiMpondomise, isiMfengu nesiBomvana.&lt;ref&gt;{{Cite web|title=XHOSA - South African Language Xhosa|url=https://www.sa-venues.com/language-xhosa.htm#:~:text=Xhosa%20has%20been%20grouped%20into,yet%20pretty-sounding,%20language.|access-date=2025-05-15|website=www.sa-venues.com}}&lt;/ref&gt; Kusese nelimi lesiThwa elibandaka isi-Khoe, isi-Tu isi-Kx'a, namanye amalimi.&lt;ref&gt;{{Cite web|title=AFRICA {{!}} 101 Last Tribes - San people|url=https://www.101lasttribes.com/tribes/san.html|access-date=2025-05-15|website=www.101lasttribes.com}}&lt;/ref&gt; Bese isiSwati kunesikhulunywa eManzini, esikhulunywa eShiselweni, nesikhulunywa eHhoho.&lt;ref name=&quot;:2&quot;&gt;{{Cite web|last=web-lingo|date=2013-01-07|title=SA’s Eleven Official Languages: SiSwati|url=https://web-lingo.com/sas-eleven-official-languages-siswati/#:~:text=Swazi%20is%20most%20closely%20related,considered%20closer%20to%20standard%20Swazi.|access-date=2025-05-15|website=Web-lingo|language=en-ZA}}&lt;/ref&gt; IsiPedi naso sinamalinyana angaphasi kwaso anjengesiTlokwa nesiLobedu.&lt;ref&gt;{{Cite web|title=free online course|url=https://www.unisa.ac.za/static/corporate_web/Content/UnisaOpen/freeOnlineCourse/nSotho/nSotho.html#:~:text=Northern%20Sotho%20is%20based%20mainly,(Cf.|access-date=2025-05-15|website=www.unisa.ac.za}}&lt;/ref&gt; Bese kube namalimi angasiwo wendabuko, namkha amalimi wesikhuwa akhulunywako njengesiNgisi nesiBhuru. Woke amalimi la namanye angakabalwa lapha malimi akhulunywa babantu beSewula Afrika.

== Amalimi Asemthethweni ==
Amalimi aseMthethweni eSewula Afrika siNdebele, isiZulu, isiSwati, isiXhosa, isiSuthu, isiPedi, isiTswana, isiVenda, isiTsonga okumalimi wendabuko, bese kuba siBhuru nesiNgisi. Ithebula elingenzasi litjengisa isibalo sabantu abakhuluma amalimi asemthethweni eSewula Afrika namaphesente wabalikhulumako esibalweni sabo boke abantu abahlala eSewula Afrika ngokweembalobalo zango-2022. &lt;ref name=&quot;:1&quot;&gt;https://en.wikipedia.org/wiki/Languages_of_South_Africa#cite_note-EthnologueZA-7&lt;/ref&gt;
{| class=&quot;wikitable sortable mw-collapsible&quot;
|+
! rowspan=&quot;2&quot; |Ilimi
! colspan=&quot;2&quot; |Ilimi lebele&lt;ref name=&quot;:1&quot; /&gt;
! colspan=&quot;2&quot; |Ilimi lesibili&lt;ref name=&quot;:1&quot; /&gt;
! colspan=&quot;2&quot; |Ilimi lesithathu&lt;ref name=&quot;:1&quot; /&gt;
|-
!Isibalo 
!Amaphesente 
!Isibalo 
!Amaphesente 
!Isibalo 
!Amaphesente 
|-
|IsiZulu
|11,587,374
|22.7%
|15,700,000
|30.8%
|27,300,000
|46%
|-
|IsiXhosa
|8,154,258
|16.0%
|11,000,000
|21.6%
|19,150,000
|33%
|-
|IsiVenda
|1,209,388
|2.4%
|1,700,000
|3.3%
|2,910,000
|5%
|-
|IsiTswana
|4,067,248
|8.0%
|7,700,000
|15.1%
|11,770,000
|20%
|-
|IsiTsonga
|2,277,148
|4.5%
|3,400,000
|6.6%
|5,680,000
|10%
|-
|IsiSwati
|1,297,046
|2.5%
|2,400,000
|4.7%
|3,700,000
|6%
|-
|IsiSuthu
|3,849,563
|7.6%
|7,900,000
|15.5%
|11,750,000
|20%
|-
|IsiPedi
|4,618,576
|9.1%
|9,100,000
|17.8%
|13,720,000
|23%
|-
|IsiNdebele
|1,090,223
|2.1%
|1,400,000
|2.7%
|2,490,000
|4%
|-
|IsiNgisi
|4,892,623
|9.6%
|14,000,000
|27.4%
|19,640,000
|33%
|-
|Isi-Afrikaans
|6,855,082
|13.5%
|10,300,000
|20.2%
|17,160,000
|29%
|-
|Ilimi Lezandla le-SA
|234,655
|0.5%
|500,000
|1.0%
|834,655
|1.5%
|-
|Amanye Amalimi
|828,258
|1.6%
|
|
|
|
|-
|'''Isibalo Sisoke'''
|'''50,961,443'''
|'''100.0%'''
|
|
|
|
|}

== IsiNdebele ==
[[Isimumathi:Ndebele women-1.jpg|thumb|Abomma bamaNdebele]]
IsiNdebele seSewula Afrika ngelinye lamalimi akhulunywa enarheni le. Isizathu sokuthi kuthiwe siNdebele seSewula Afrika kukuthi kunesiNdebele seZimbabwe. &lt;ref&gt;{{Cite web|last=web-lingo|date=2012-10-19|title=Ndebele: What is Ndebele?|url=https://web-lingo.com/ndebele-what-is-ndebele/#:~:text=Northern%20Ndebele,%20or%20Matabele,%20or,nineteenth%20century%20during%20the%20Mfecane.|access-date=2025-05-15|website=Web-lingo|language=en-ZA}}&lt;/ref&gt; Ngokwethebula elingehla, abantu abakhuluma isiNdebele - abasimunyileko, okulilimi lesibili nalabo okulilimi lesithathu kibo - bangaphezu kweengidi ezine. Ilimeli likhulunywa khulukhulu esifundeni seMpumalanga eendaweni ezinjengaKwaNdebele, eMalahleni, e-Middleburg, e-Belfast, kwaDlawulale nakezinye iindawo  njengesiFunda seLimpopo. 

IsiNdebele esisemthethweni siNzunza, kodwana kusese nesiNdebele sakwaManala nesiNdebele seMoletlane. IsiNdebele sikhulunywa khulukhulu esifundeni seMpumalanga eendaweni ezinjengaKwaNdebele, eMalahleni, eMiddleburg njll.&lt;ref name=&quot;:0&quot; /&gt; AmaNdebele aziwa njengesitjhaba esithanda imibala emihle nekhanyako ongayibona endleleni abambatha ngayo nabenza ngayo imigwalo yabo.

AmaNdebele bekangaphasi kwesiqhema sabaMbo ngaphambi kobana sizijamele ngaphasi kweNgwenyama uNdebele. Ngikho namhlanjesi kunezici ezifanako phakathi kwelimi lesiNdebele nelimi lesiHlubi, isiBhaca, isiMpondo nesiMpondomise.  Ngemva kwesikhathi uNdebele wabeletha uMkhalangana owabeletha umNtungwa. Ngemva kwesikhathi umNtungwa wabeletha uNjonono owabeletha uNjonono. UNjonono wabeletha uNanasi, uNanasi wabeletha uMafana. UMafana wabeletha uMhlanga owabeletha uMusi. Kusesikhathini seNgwenyama uMusi lapha amaNdebele ahlukana khona waba maNzunza namaNala. AmaNdebele akheka ngaleyondlela sele ahlala eSewula Afrika nje. &lt;ref&gt;https://en.wikipedia.org/wiki/Southern_Ndebele_language&lt;/ref&gt;

== IsiSwati ==
[[Isimumathi:Indoni Parade 2018. Swati Kingdom by Sizwe Sibiya (10).jpg|thumb|AmaSwati ]]
IsiSwati sikhulunywa eenarheni ezimbili, eSewula Afrika neSwatini. Ngokwethebula elingehla abantu abakhuluma isiSwati eSewula Afrika  bangaphezu kweengidi ezilikhomba.&lt;ref name=&quot;:1&quot; /&gt; KunesiSwati esikhulunywa eSwatini kwaManzini, eShiselweni neHhoho.&lt;ref name=&quot;:2&quot; /&gt; Abantu abakhuluma isiSwati eSwatini babalelwa eengidini ezine. &lt;ref name=&quot;:3&quot;&gt;https://en.wikipedia.org/wiki/Zulu_language&lt;/ref&gt; 

AmaSwati bewasiqhenyana esincani sabeNguni ebesaziwa bona Mangwane. Ngokukhamba kwesikhathi isiqhemesi sahlangana nesiqhenyana sabeSuthu ebesihlala endaweni namhlanjesi ebizwa bona kuseSwatini. Ngemva kwalokho bakhula baba sisizwe ngaphasi kweNgwenyama uDlamini III eyathatha iintambo eNgwenyameni uMaseko, yathatha isitjhaba yayosinzinzisa emlanjeni iPongola bahlala eduze namaNdwandwe ngo-1750. UDlamini III walandelwa yiNgwenyama uNgwane III okukholelwa bona nguye owaba yiNgwenyama yokuthoma eyabusa indawo namhlanjesi ebizwa bona kuseSwatini.&lt;ref&gt;https://en.wikipedia.org/wiki/Swazi_people&lt;/ref&gt;

== IsiZulu ==
[[Isimumathi:Zulu Krieger.jpg|thumb|Abobaba bamaZulu bayagida]]
IsiZulu ngelinye lamalimi adumileko asemthethweni eSewula Afrika elikhulunywa babantu ababgaogezu kweengidi ezimatjhumi amahlanu, kuthi labo abalimunyileko bangaphezu kweengidi ezilitjhumi nanye. &lt;ref name=&quot;:1&quot; /&gt; IsiZulu sikhulunywa khulu KwaZulu Natal, esiFundeni se-Gauteng nakezinye iimfunda.

Umuntu owadlala indima ekulu ekwakhekeni kwesitjhaba samaZulu yiNgwenyama uShaka. UShaka walwa neentjhaba ezincani nezikulu zabeNguni kuhlanganise namaNdwandwe wazihlula. Ngemva kwalokho wazibiza ngoZulu obekangukhokho omkhulu wesitjhaba abelethelwa kiso. Iintjhabezi zahlangana kwavela ilimi lesiZulu.&lt;ref name=&quot;:3&quot; /&gt;  

== IsiXhosa ==
[[Isimumathi:Xhosa traditionally dressed women.jpg|thumb|250x250px|Abomma bamaXhosa]]
IsiXhosa naso singelinye lamalimi weSewula Afrika asemthethweni. IsiXhosa sikhulunywa babantu abangaphezu kweengidi ezimatjhumi amathathu nobunane, kuthi labo okulimi labo lokubelethwa bangaphezu kweengidi ezibunane. &lt;ref name=&quot;:1&quot; /&gt; IsiXhosa sikhulunywa khulukhulu esiFundeni seTjingalanga Kapa, eTlhagwini  Kapa nesiFundeni se-Gauteng.&lt;ref&gt;{{Cite web|last=Alexander|first=Mary|date=2025-04-06|title=The languages of South Africa|url=https://southafrica-info.com/arts-culture/11-languages-south-africa/#:~:text=Among%20South%20Africa's%20population%20groups,),%20based%20on%20Census%202022.|access-date=2025-05-23|website=South Africa Gateway|language=en-GB}}&lt;/ref&gt;

Ekadeni bekuneenqhema zabeNguni ezakha ubuhlobo neentjhaba zabaThwa nabaKhoekhoe. Ngokukhamba kwesikhathi iintjhabezi zahlangana zaba sisizwe ngaphasi kokubusa kweNgwenyama uTshawe owahlula isitjhaba samaCirha namaJwarha. Ngemva kwalokho wahlanganisa zoke iintjhaba ezincani kuhlanganise nesabaKhoekhoe. Labeletheka njalo-ke ilimi lesiXhosa.&lt;ref&gt;https://en.wikipedia.org/wiki/Xhosa_people&lt;/ref&gt;

== IsiSuthu ==
[[Isimumathi:Sotho regalia.jpg|thumb|Abobaba babeSuthu]]
IsiSuthu lilimi elisemthethweni eSewula Afrika elikhunywa babantu abangaphezu kweengidi ezimatjhumi amabili nambili. Okulilmi labo abalimunyileko bangaphezu kweengidi ezintathu. &lt;ref name=&quot;:1&quot; /&gt; IsiSuthu sikhulunywa khulu enarheni yeLesotho, kanti eSewula Afrikapha sikhulunywa khulukhulu esiFundeni seFreestate, seGauteng. Umhlobo lo wesiSuthu ubizwa ngokobana siSuthu seSewula ngombana uhlukaniswa nesiSuthu seTlhagwini - okusiPedi, nesiSuthu seTjingalanga - okusiTswana.

Emandulo abeSuthu beza eSewula Afrika bavela eTlhagwini njengezinye iintjhaba bafika bahlala etlhagwini yeSewula Afrika. Bafika baba ziinqhenyana ezinjengabaTaung, abaSia, abaFokeng, amaKgolokoe nabaKwena nezinye iinqenyana. Kuhlekuhle umndeni webukhosini eLesotho mndeni wabaKwena. AbeSuthwaba ngibo-ke ababanikazi belimi lesiSuthu esikhulunywa eSewula Afrika neLesotho.&lt;ref&gt;{{Cite web|title=SOUTHERN SESOTHO - South African Language Southern Sesotho|url=https://www.sa-venues.com/language-southern-sesotho.htm|access-date=2025-05-26|website=www.sa-venues.com}}&lt;/ref&gt;

== IsiTswana ==
[[Isimumathi:Tswana Dancers 3.jpg|thumb|Isiqhema esigidako sabaTswana]]
IsiTswana nalo ngelinye lamalimi asesiqhemeni sesiSuthu seTjingalanga esikhulunywa eSewula Afrika neBotswana. Abantu abasikhulumako eSewula Afrika bangaphezu kweengidi ezimatjhumi amabili nantathu, abalimunyileko bangaphezu kweengidi ezine.&lt;ref name=&quot;:1&quot; /&gt; isiTswana sikhulunywa khulu enarheni yeBotswana kanti eSewula Afrika sikhulunywa khulu esiFundeni seTlhagwini-Tjhingalanga, neGauteng.

Emandulo abeTswana bebangaphasi kwesiqhema sabeSuthu nabazakufika eSewula Afrika bavela eTlhagwini ne-Afrika. Bafika baba ziinqhenyana ezinjengabaTaung, abaSia, abaFokeng, amaKgolokoe nabaKwena kunye nezinye iinqhenyana. Bafika endaweni ebizwa ngokobana yiBotswana namhlanjesi balwa nabaThwa babahlula, bese bakha umbuso wabaTswana. Ngibo-ke namhlanjesi ababanikazi belimi lesiTswana.&lt;ref&gt;{{Cite web|title=AFRICA {{!}} 101 Last Tribes - Tswana people|url=http://www.101lasttribes.com/tribes/tswana.html|access-date=2025-05-26|website=www.101lasttribes.com}}&lt;/ref&gt;

== IsiPedi ==
[[Isimumathi:Pedi Living Culture Route, Limpopo, South Africa (2417712111).jpg|thumb|Umuzi wesiPedi]]
IsiPedi ([https://www.sahistory.org.za/article/pedi Sepedi]) nalo ngelinye lamalimi angaphasi kwesiSuthu atloliswe ngokomthetho eSewula Afrika, begodu saziwa ngokuthi siSuthu seTlhagwini. &lt;ref name=&quot;:4&quot;&gt;{{Cite web|title=AFRICA {{!}} 101 Last Tribes - Pedi people|url=http://www.101lasttribes.com/tribes/pedi.html|access-date=2025-05-26|website=www.101lasttribes.com}}&lt;/ref&gt; Ilimeli likhulunywa khulukhulu esiFundeni seLimpopo neseGauteng babantu abalinganiswela eengidini ezimatjhumi amabili nekhomba.&lt;ref name=&quot;:1&quot; /&gt; 

Ekadeni isiqhemesi besiyingcenye yesiqhema sabeSuthu, kwathi nakukhamba ezinye iinqhema sona sasala ngetlhagwini yeSewula Afrika. Sineenqhenyana ezinengana okucatjangelwa bona sikhuluma amalinyana amatjhumi amathathu. Abanye bathi isiSuthu seTlhagwini akusiso isiPedi kodwana lilimi elihlukileko. &lt;ref name=&quot;:4&quot; /&gt;

== IsiVenda ==
[[Isimumathi:Venda culture, Limpopo, South Africa (8714283418).jpg|thumb|251x251px|Izindlu zamaVenda]]
Elinye lamalimi atloliswe ngokomthetho eSewula Afrika siVenda. Abantu abakhuluma isiVenda balinganiselwa eengidini ezihlanu. &lt;ref name=&quot;:1&quot; /&gt; IsiVenda sikhulunywa khulu esiFundeni seLimpopo ngetlhagwini ngitjho nesiFundeni seGauteng. Nawulilemukisisa kuhle ilimeli linezici ezivela elimini lesiShona nelesiTokwa.

Ekadeni isiqhemesi kukholelwa bona sathoma ukuba khona nakusabusa uMpuso weMapungubwe, kwathi nakuwa umbuso lo kuvuka umbuso weZimbabwe sathutha sayokuhlala endaweni namhlanjesi ebizwa ngokobana kuseZimbabwe. Sakhamba isikhathi, isiqhemesi sathutha eZimbabwe sehla seyama umlambo weZambezi sazitholela indawo sayithiya ngokuthi yi-D'zata. Kusukela ngalesosikhathi umbuso wabo uye wannzinza kwabusa amakhosi wawo ngokulandelana kwawo. Namhlanjesi ngibo ababanikazi belimi lesiVenda. &lt;ref&gt;{{Cite web|title=Venda - African Tribe - Venda Culture|url=https://www.krugerpark.co.za/africa_venda.html|access-date=2025-05-26|website=www.krugerpark.co.za}}&lt;/ref&gt;

== IsiTsonga ==

== I-''Afrikaans'' ==

== IsiNgisi ==

== ILimi LeZandla ==

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>0tw7m8wn6t9sr7hccjf1y1xf72ucaoy</sha1>
    </revision>
    <revision>
      <id>2848</id>
      <parentid>2847</parentid>
      <timestamp>2025-05-26T20:51:00Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>/* IsiTsonga */</comment>
      <origin>2848</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="17759" sha1="tddhqlhc0olhcrlscxvpjw7qfw4bhmy" xml:space="preserve">[[Isimumathi:Flag of South Africa.svg|thumb|Iflarha leSewula Afrika]]

== Draft Space 1 ==

= Amalimi WeSewula Afrika =
'''Inarha yeSewula Afrika''' yinarha enabantu abanamasiko nabaneenzinda ezihlukahlukeneko, nabakhuluma amalimi ahlukahlukeneko. Inengi labantu enarheni le lisesiqhemeni sokuthoma sabantu abakhuluma amalimi angaphasi kwesiNguni, okusiZulu, isiXhosa, [[Isindebele|isiNdebele]] nesiSwati. Bese isiqhema sesibili ngobukhulu ngesikhuluma amalimi wesiSuthu, okusiTswana, isiPedi (okusiSuthu seTlhagwini) nesiSuthu (okusiSuthu seSewula, namkha isiSuthu sesiShweshwe). Bese kunesiqhema esikhuluma isiTsonga nesiqhema esikhuluma isiVenda.&lt;ref&gt;{{Cite web |date=2025-05-14 |title=South Africa - Languages, Dialects, Afrikaans {{!}} Britannica |url=https://www.britannica.com/place/South-Africa/Languages |access-date=2025-05-15 |website=www.britannica.com |language=en}}&lt;/ref&gt;

Ngaphezu kwamalimi abaliweko la kunamalimi ahlobene nawo. Ngokwesibonelo, esiNdebeleni kunesiNala, nesiNdebele seMoletlane. &lt;ref name=&quot;:0&quot;&gt;{{Cite web|title=Ndebele people, traditions culture|url=https://www.africancraftsmarket.com/african-tribes/ndebele-people.html|access-date=2025-05-15|website=www.africancraftsmarket.com}}&lt;/ref&gt; EsiXhoseni kube nesiNgqika, isiThembu, isiBhaca, isiGcaleka, isiMpondo, isiMpondomise, isiMfengu nesiBomvana.&lt;ref&gt;{{Cite web|title=XHOSA - South African Language Xhosa|url=https://www.sa-venues.com/language-xhosa.htm#:~:text=Xhosa%20has%20been%20grouped%20into,yet%20pretty-sounding,%20language.|access-date=2025-05-15|website=www.sa-venues.com}}&lt;/ref&gt; Kusese nelimi lesiThwa elibandaka isi-Khoe, isi-Tu isi-Kx'a, namanye amalimi.&lt;ref&gt;{{Cite web|title=AFRICA {{!}} 101 Last Tribes - San people|url=https://www.101lasttribes.com/tribes/san.html|access-date=2025-05-15|website=www.101lasttribes.com}}&lt;/ref&gt; Bese isiSwati kunesikhulunywa eManzini, esikhulunywa eShiselweni, nesikhulunywa eHhoho.&lt;ref name=&quot;:2&quot;&gt;{{Cite web|last=web-lingo|date=2013-01-07|title=SA’s Eleven Official Languages: SiSwati|url=https://web-lingo.com/sas-eleven-official-languages-siswati/#:~:text=Swazi%20is%20most%20closely%20related,considered%20closer%20to%20standard%20Swazi.|access-date=2025-05-15|website=Web-lingo|language=en-ZA}}&lt;/ref&gt; IsiPedi naso sinamalinyana angaphasi kwaso anjengesiTlokwa nesiLobedu.&lt;ref&gt;{{Cite web|title=free online course|url=https://www.unisa.ac.za/static/corporate_web/Content/UnisaOpen/freeOnlineCourse/nSotho/nSotho.html#:~:text=Northern%20Sotho%20is%20based%20mainly,(Cf.|access-date=2025-05-15|website=www.unisa.ac.za}}&lt;/ref&gt; Bese kube namalimi angasiwo wendabuko, namkha amalimi wesikhuwa akhulunywako njengesiNgisi nesiBhuru. Woke amalimi la namanye angakabalwa lapha malimi akhulunywa babantu beSewula Afrika.

== Amalimi Asemthethweni ==
Amalimi aseMthethweni eSewula Afrika siNdebele, isiZulu, isiSwati, isiXhosa, isiSuthu, isiPedi, isiTswana, isiVenda, isiTsonga okumalimi wendabuko, bese kuba siBhuru nesiNgisi. Ithebula elingenzasi litjengisa isibalo sabantu abakhuluma amalimi asemthethweni eSewula Afrika namaphesente wabalikhulumako esibalweni sabo boke abantu abahlala eSewula Afrika ngokweembalobalo zango-2022. &lt;ref name=&quot;:1&quot;&gt;https://en.wikipedia.org/wiki/Languages_of_South_Africa#cite_note-EthnologueZA-7&lt;/ref&gt;
{| class=&quot;wikitable sortable mw-collapsible&quot;
|+
! rowspan=&quot;2&quot; |Ilimi
! colspan=&quot;2&quot; |Ilimi lebele&lt;ref name=&quot;:1&quot; /&gt;
! colspan=&quot;2&quot; |Ilimi lesibili&lt;ref name=&quot;:1&quot; /&gt;
! colspan=&quot;2&quot; |Ilimi lesithathu&lt;ref name=&quot;:1&quot; /&gt;
|-
!Isibalo 
!Amaphesente 
!Isibalo 
!Amaphesente 
!Isibalo 
!Amaphesente 
|-
|IsiZulu
|11,587,374
|22.7%
|15,700,000
|30.8%
|27,300,000
|46%
|-
|IsiXhosa
|8,154,258
|16.0%
|11,000,000
|21.6%
|19,150,000
|33%
|-
|IsiVenda
|1,209,388
|2.4%
|1,700,000
|3.3%
|2,910,000
|5%
|-
|IsiTswana
|4,067,248
|8.0%
|7,700,000
|15.1%
|11,770,000
|20%
|-
|IsiTsonga
|2,277,148
|4.5%
|3,400,000
|6.6%
|5,680,000
|10%
|-
|IsiSwati
|1,297,046
|2.5%
|2,400,000
|4.7%
|3,700,000
|6%
|-
|IsiSuthu
|3,849,563
|7.6%
|7,900,000
|15.5%
|11,750,000
|20%
|-
|IsiPedi
|4,618,576
|9.1%
|9,100,000
|17.8%
|13,720,000
|23%
|-
|IsiNdebele
|1,090,223
|2.1%
|1,400,000
|2.7%
|2,490,000
|4%
|-
|IsiNgisi
|4,892,623
|9.6%
|14,000,000
|27.4%
|19,640,000
|33%
|-
|Isi-Afrikaans
|6,855,082
|13.5%
|10,300,000
|20.2%
|17,160,000
|29%
|-
|Ilimi Lezandla le-SA
|234,655
|0.5%
|500,000
|1.0%
|834,655
|1.5%
|-
|Amanye Amalimi
|828,258
|1.6%
|
|
|
|
|-
|'''Isibalo Sisoke'''
|'''50,961,443'''
|'''100.0%'''
|
|
|
|
|}

== IsiNdebele ==
[[Isimumathi:Ndebele women-1.jpg|thumb|Abomma bamaNdebele]]
IsiNdebele seSewula Afrika ngelinye lamalimi akhulunywa enarheni le. Isizathu sokuthi kuthiwe siNdebele seSewula Afrika kukuthi kunesiNdebele seZimbabwe. &lt;ref&gt;{{Cite web|last=web-lingo|date=2012-10-19|title=Ndebele: What is Ndebele?|url=https://web-lingo.com/ndebele-what-is-ndebele/#:~:text=Northern%20Ndebele,%20or%20Matabele,%20or,nineteenth%20century%20during%20the%20Mfecane.|access-date=2025-05-15|website=Web-lingo|language=en-ZA}}&lt;/ref&gt; Ngokwethebula elingehla, abantu abakhuluma isiNdebele - abasimunyileko, okulilimi lesibili nalabo okulilimi lesithathu kibo - bangaphezu kweengidi ezine. Ilimeli likhulunywa khulukhulu esifundeni seMpumalanga eendaweni ezinjengaKwaNdebele, eMalahleni, e-Middleburg, e-Belfast, kwaDlawulale nakezinye iindawo  njengesiFunda seLimpopo. 

IsiNdebele esisemthethweni siNzunza, kodwana kusese nesiNdebele sakwaManala nesiNdebele seMoletlane. IsiNdebele sikhulunywa khulukhulu esifundeni seMpumalanga eendaweni ezinjengaKwaNdebele, eMalahleni, eMiddleburg njll.&lt;ref name=&quot;:0&quot; /&gt; AmaNdebele aziwa njengesitjhaba esithanda imibala emihle nekhanyako ongayibona endleleni abambatha ngayo nabenza ngayo imigwalo yabo.

AmaNdebele bekangaphasi kwesiqhema sabaMbo ngaphambi kobana sizijamele ngaphasi kweNgwenyama uNdebele. Ngikho namhlanjesi kunezici ezifanako phakathi kwelimi lesiNdebele nelimi lesiHlubi, isiBhaca, isiMpondo nesiMpondomise.  Ngemva kwesikhathi uNdebele wabeletha uMkhalangana owabeletha umNtungwa. Ngemva kwesikhathi umNtungwa wabeletha uNjonono owabeletha uNjonono. UNjonono wabeletha uNanasi, uNanasi wabeletha uMafana. UMafana wabeletha uMhlanga owabeletha uMusi. Kusesikhathini seNgwenyama uMusi lapha amaNdebele ahlukana khona waba maNzunza namaNala. AmaNdebele akheka ngaleyondlela sele ahlala eSewula Afrika nje. &lt;ref&gt;https://en.wikipedia.org/wiki/Southern_Ndebele_language&lt;/ref&gt;

== IsiSwati ==
[[Isimumathi:Indoni Parade 2018. Swati Kingdom by Sizwe Sibiya (10).jpg|thumb|AmaSwati ]]
IsiSwati sikhulunywa eenarheni ezimbili, eSewula Afrika neSwatini. Ngokwethebula elingehla abantu abakhuluma isiSwati eSewula Afrika  bangaphezu kweengidi ezilikhomba.&lt;ref name=&quot;:1&quot; /&gt; KunesiSwati esikhulunywa eSwatini kwaManzini, eShiselweni neHhoho.&lt;ref name=&quot;:2&quot; /&gt; Abantu abakhuluma isiSwati eSwatini babalelwa eengidini ezine. &lt;ref name=&quot;:3&quot;&gt;https://en.wikipedia.org/wiki/Zulu_language&lt;/ref&gt; 

AmaSwati bewasiqhenyana esincani sabeNguni ebesaziwa bona Mangwane. Ngokukhamba kwesikhathi isiqhemesi sahlangana nesiqhenyana sabeSuthu ebesihlala endaweni namhlanjesi ebizwa bona kuseSwatini. Ngemva kwalokho bakhula baba sisizwe ngaphasi kweNgwenyama uDlamini III eyathatha iintambo eNgwenyameni uMaseko, yathatha isitjhaba yayosinzinzisa emlanjeni iPongola bahlala eduze namaNdwandwe ngo-1750. UDlamini III walandelwa yiNgwenyama uNgwane III okukholelwa bona nguye owaba yiNgwenyama yokuthoma eyabusa indawo namhlanjesi ebizwa bona kuseSwatini.&lt;ref&gt;https://en.wikipedia.org/wiki/Swazi_people&lt;/ref&gt;

== IsiZulu ==
[[Isimumathi:Zulu Krieger.jpg|thumb|Abobaba bamaZulu bayagida]]
IsiZulu ngelinye lamalimi adumileko asemthethweni eSewula Afrika elikhulunywa babantu ababgaogezu kweengidi ezimatjhumi amahlanu, kuthi labo abalimunyileko bangaphezu kweengidi ezilitjhumi nanye. &lt;ref name=&quot;:1&quot; /&gt; IsiZulu sikhulunywa khulu KwaZulu Natal, esiFundeni se-Gauteng nakezinye iimfunda.

Umuntu owadlala indima ekulu ekwakhekeni kwesitjhaba samaZulu yiNgwenyama uShaka. UShaka walwa neentjhaba ezincani nezikulu zabeNguni kuhlanganise namaNdwandwe wazihlula. Ngemva kwalokho wazibiza ngoZulu obekangukhokho omkhulu wesitjhaba abelethelwa kiso. Iintjhabezi zahlangana kwavela ilimi lesiZulu.&lt;ref name=&quot;:3&quot; /&gt;  

== IsiXhosa ==
[[Isimumathi:Xhosa traditionally dressed women.jpg|thumb|250x250px|Abomma bamaXhosa]]
IsiXhosa naso singelinye lamalimi weSewula Afrika asemthethweni. IsiXhosa sikhulunywa babantu abangaphezu kweengidi ezimatjhumi amathathu nobunane, kuthi labo okulimi labo lokubelethwa bangaphezu kweengidi ezibunane. &lt;ref name=&quot;:1&quot; /&gt; IsiXhosa sikhulunywa khulukhulu esiFundeni seTjingalanga Kapa, eTlhagwini  Kapa nesiFundeni se-Gauteng.&lt;ref&gt;{{Cite web|last=Alexander|first=Mary|date=2025-04-06|title=The languages of South Africa|url=https://southafrica-info.com/arts-culture/11-languages-south-africa/#:~:text=Among%20South%20Africa's%20population%20groups,),%20based%20on%20Census%202022.|access-date=2025-05-23|website=South Africa Gateway|language=en-GB}}&lt;/ref&gt;

Ekadeni bekuneenqhema zabeNguni ezakha ubuhlobo neentjhaba zabaThwa nabaKhoekhoe. Ngokukhamba kwesikhathi iintjhabezi zahlangana zaba sisizwe ngaphasi kokubusa kweNgwenyama uTshawe owahlula isitjhaba samaCirha namaJwarha. Ngemva kwalokho wahlanganisa zoke iintjhaba ezincani kuhlanganise nesabaKhoekhoe. Labeletheka njalo-ke ilimi lesiXhosa.&lt;ref&gt;https://en.wikipedia.org/wiki/Xhosa_people&lt;/ref&gt;

== IsiSuthu ==
[[Isimumathi:Sotho regalia.jpg|thumb|Abobaba babeSuthu]]
IsiSuthu lilimi elisemthethweni eSewula Afrika elikhunywa babantu abangaphezu kweengidi ezimatjhumi amabili nambili. Okulilmi labo abalimunyileko bangaphezu kweengidi ezintathu. &lt;ref name=&quot;:1&quot; /&gt; IsiSuthu sikhulunywa khulu enarheni yeLesotho, kanti eSewula Afrikapha sikhulunywa khulukhulu esiFundeni seFreestate, seGauteng. Umhlobo lo wesiSuthu ubizwa ngokobana siSuthu seSewula ngombana uhlukaniswa nesiSuthu seTlhagwini - okusiPedi, nesiSuthu seTjingalanga - okusiTswana.

Emandulo abeSuthu beza eSewula Afrika bavela eTlhagwini njengezinye iintjhaba bafika bahlala etlhagwini yeSewula Afrika. Bafika baba ziinqhenyana ezinjengabaTaung, abaSia, abaFokeng, amaKgolokoe nabaKwena nezinye iinqenyana. Kuhlekuhle umndeni webukhosini eLesotho mndeni wabaKwena. AbeSuthwaba ngibo-ke ababanikazi belimi lesiSuthu esikhulunywa eSewula Afrika neLesotho.&lt;ref&gt;{{Cite web|title=SOUTHERN SESOTHO - South African Language Southern Sesotho|url=https://www.sa-venues.com/language-southern-sesotho.htm|access-date=2025-05-26|website=www.sa-venues.com}}&lt;/ref&gt;

== IsiTswana ==
[[Isimumathi:Tswana Dancers 3.jpg|thumb|Isiqhema esigidako sabaTswana]]
IsiTswana nalo ngelinye lamalimi asesiqhemeni sesiSuthu seTjingalanga esikhulunywa eSewula Afrika neBotswana. Abantu abasikhulumako eSewula Afrika bangaphezu kweengidi ezimatjhumi amabili nantathu, abalimunyileko bangaphezu kweengidi ezine.&lt;ref name=&quot;:1&quot; /&gt; isiTswana sikhulunywa khulu enarheni yeBotswana kanti eSewula Afrika sikhulunywa khulu esiFundeni seTlhagwini-Tjhingalanga, neGauteng.

Emandulo abeTswana bebangaphasi kwesiqhema sabeSuthu nabazakufika eSewula Afrika bavela eTlhagwini ne-Afrika. Bafika baba ziinqhenyana ezinjengabaTaung, abaSia, abaFokeng, amaKgolokoe nabaKwena kunye nezinye iinqhenyana. Bafika endaweni ebizwa ngokobana yiBotswana namhlanjesi balwa nabaThwa babahlula, bese bakha umbuso wabaTswana. Ngibo-ke namhlanjesi ababanikazi belimi lesiTswana.&lt;ref&gt;{{Cite web|title=AFRICA {{!}} 101 Last Tribes - Tswana people|url=http://www.101lasttribes.com/tribes/tswana.html|access-date=2025-05-26|website=www.101lasttribes.com}}&lt;/ref&gt;

== IsiPedi ==
[[Isimumathi:Pedi Living Culture Route, Limpopo, South Africa (2417712111).jpg|thumb|Umuzi wesiPedi]]
IsiPedi ([https://www.sahistory.org.za/article/pedi Sepedi]) nalo ngelinye lamalimi angaphasi kwesiSuthu atloliswe ngokomthetho eSewula Afrika, begodu saziwa ngokuthi siSuthu seTlhagwini. &lt;ref name=&quot;:4&quot;&gt;{{Cite web|title=AFRICA {{!}} 101 Last Tribes - Pedi people|url=http://www.101lasttribes.com/tribes/pedi.html|access-date=2025-05-26|website=www.101lasttribes.com}}&lt;/ref&gt; Ilimeli likhulunywa khulukhulu esiFundeni seLimpopo neseGauteng babantu abalinganiswela eengidini ezimatjhumi amabili nekhomba.&lt;ref name=&quot;:1&quot; /&gt; 

Ekadeni isiqhemesi besiyingcenye yesiqhema sabeSuthu, kwathi nakukhamba ezinye iinqhema sona sasala ngetlhagwini yeSewula Afrika. Sineenqhenyana ezinengana okucatjangelwa bona sikhuluma amalinyana amatjhumi amathathu. Abanye bathi isiSuthu seTlhagwini akusiso isiPedi kodwana lilimi elihlukileko. &lt;ref name=&quot;:4&quot; /&gt;

== IsiVenda ==
[[Isimumathi:Venda culture, Limpopo, South Africa (8714283418).jpg|thumb|251x251px|Izindlu zamaVenda]]
Elinye lamalimi atloliswe ngokomthetho eSewula Afrika siVenda. Abantu abakhuluma isiVenda balinganiselwa eengidini ezihlanu. &lt;ref name=&quot;:1&quot; /&gt; IsiVenda sikhulunywa khulu esiFundeni seLimpopo ngetlhagwini ngitjho nesiFundeni seGauteng. Nawulilemukisisa kuhle ilimeli linezici ezivela elimini lesiShona nelesiTokwa.

Ekadeni isiqhemesi kukholelwa bona sathoma ukuba khona nakusabusa uMpuso weMapungubwe, kwathi nakuwa umbuso lo kuvuka umbuso weZimbabwe sathutha sayokuhlala endaweni namhlanjesi ebizwa ngokobana kuseZimbabwe. Sakhamba isikhathi, isiqhemesi sathutha eZimbabwe sehla seyama umlambo weZambezi sazitholela indawo sayithiya ngokuthi yi-D'zata. Kusukela ngalesosikhathi umbuso wabo uye wannzinza kwabusa amakhosi wawo ngokulandelana kwawo. Namhlanjesi ngibo ababanikazi belimi lesiVenda. &lt;ref&gt;{{Cite web|title=Venda - African Tribe - Venda Culture|url=https://www.krugerpark.co.za/africa_venda.html|access-date=2025-05-26|website=www.krugerpark.co.za}}&lt;/ref&gt;

== IsiTsonga ==
[[Isimumathi:Tsonga women in South Africa.jpg|thumb|Abomma bambethe isiTsonga]]
IsiTsonga ngelinye lamalimi akhulunywa eSewula Afrika atloliswe ngokomthetho. Ilimeli likhulunywa babantu abangaphezu kweengidi ezilitjhumi nanye. IsiTsonga sikhulunywa  khulukhulu esifundeni seLimpopo neseGauteng, bese kube nesiTsonga esikhulunywa eMozambique. &lt;ref name=&quot;:1&quot; /&gt; 

Abantwaba bebasiqhema sabeNguni abathoma lokha uSoshangane ebekuyinduna kaShaka abalekela enarheni yangepumalanga. Bathi nabafika lapho bazakhela umbuso omkhulu nedorhobho elibizwa bona yiGaza. Bfika bahlula izizwe ezinengi abazithola lapho njengesizwe samaNdawu, amaTonga, amaTjopi amaSena nezinye. Ilimi labo lesiNguni lahlangana nesiTonga namalimi walapho laba siTsonga. Ngokukhamba kwesikhathi umbuso lo wahlukana, amanye amaTsonga athuthela ngapha ngendaweni yeSewula Afrika.&lt;ref&gt;{{Cite web|title=Shangaan Tsonga - Nguni People, Tribe - South Africa...|url=https://www.krugerpark.co.za/africa_shangaan_tsonga.html|access-date=2025-05-26|website=www.krugerpark.co.za}}&lt;/ref&gt;

== I-''Afrikaans'' ==
[[Isimumathi:Boer Family with a wagon - false colour image.jpg|thumb|AmaBhuru wakade]]
I-Afrikaans namkha isiBhuru lilimi mhlobo welimi lamakhuwa angasiwo wendabuko weSewula Afrika. Nalo litlolisiwe ngokomthetho begodu likhulunywa babantu abangaphezu kweengidi ezimatjhumi amathathu nane. &lt;ref name=&quot;:1&quot; /&gt; I-Afrikaans ikhulunywa khulu eemfundeni zangeTjingalanga Kapa, eGauteng nakezinye iimfunda.

Ilimi le-Afrikaans livela elimini lesiDatjhi. AmaDatjhi afika eSewula Afrika lokha uJan Van Riebeeck obekasebenzela i-VOC (''[https://www.worldhistory.org/Dutch_East_India_Company/ Vereenigde Oost-Indische Compagnie]'') afika nabantu bekhabo ngo-1652, bafika bahlala endaweni abayibiza bona yi-''Cape of Good Hope''. Bafika lapho bahlangana nesitjhaba sabaKhoekhoe. Ngokukhamba kwesikhathi ilimi lesiDatjhi lahlangana nelesiKhoe kunye namanye amalimi kwakheka ilimi namhlanjesi elibizwa ngokuthi yi-Afrikaans namkha isiBhuru, okulilimi elisemthethweni bekube njenganje eSewula Afrika.&lt;ref&gt;{{Cite web|title=The Dutch Settlement {{!}} South African History Online|url=https://www.sahistory.org.za/article/dutch-settlement|access-date=2025-05-26|website=www.sahistory.org.za}}&lt;/ref&gt;&lt;ref&gt;{{Cite web|date=2023-10-13|title=‘The language we know as Afrikaans today owes much to the enslaved people who spoke it’—Read an excerpt from Coloured: How Classification Became Culture|url=https://johannesburgreviewofbooks.com/2023/10/13/the-language-we-know-as-afrikaans-today-owes-much-to-the-enslaved-people-who-spoke-it-read-an-excerpt-from-coloured-how-classification-became-culture/|access-date=2025-05-26|website=The Johannesburg Review of Books|language=en-US}}&lt;/ref&gt;

== IsiNgisi ==
[[Isimumathi:English settlers landing in Virginia 1607 Image from page 42 of A junior class history of the United States; to which are added the Declaration of independence, and the Constitution of the United States (1899).jpg|thumb|AmaNgisi bokufika]]
IsiNgisi kuphela kwelimi elikhulunywa khulu ukudlula woke eSewula Afrika. Sikhulunywa babantu abangaphezu kweengidi ezimatjhumi amathathu nekhomba. Ilimeli ngilo esisetjenziswa khulu emazikweni wezefundo, wezepolotiki, wezeemali, wezamaphilo namanye.

Safika njani isiNgisi eSewula Afrika? IsiNgisi besele sikhona nakufika amaBhuru ngo-1652 ngombana nakufika amaDatjhi athola u-Atjhumato obekayikosi yabaKhoekhoe besele abuya eBantam ngo-1630, akghona ukukhuluma isiNgisi nesiDatjhi. &lt;ref&gt;{{Cite web|title=Autshumao (Herry the Strandloper) {{!}} South African History Online|url=https://www.sahistory.org.za/people/autshumao-herry-strandloper#:~:text=Autshumao%20also%20known%20as%20Herry%20the%20strandloper,who%20were%20engaged%20in%20a%20trading%20relationship.|access-date=2025-05-26|website=www.sahistory.org.za}}&lt;/ref&gt; Nanyana isiNgisi besele sikhulunywa eSewula Afrika, amaNgisi wokufika nokuhlala eza mva kunamaDatjhi. Kwathoma mhlokho bona isiNgisi sikhulunywe eSewula Afrika.

== Ilimi Lezandla ==
Ilimi lezandla ngelinye lamalimi akhulunywa eSewula Afrika. Likhulunywa babantu abangaphesu kwesigidi sinye, begodu kunabantu abama-234,655 okulilimi labo lokuthoma.

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>tddhqlhc0olhcrlscxvpjw7qfw4bhmy</sha1>
    </revision>
    <revision>
      <id>3207</id>
      <parentid>2848</parentid>
      <timestamp>2025-06-23T12:09:13Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>Replaced content with &quot;== Draft Space 1 ==  &lt;references /&gt;&quot;</comment>
      <origin>3207</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="35" sha1="lsnbttdwr4rhff0c1htz25o0xw6edva" xml:space="preserve">== Draft Space 1 ==

&lt;references /&gt;</text>
      <sha1>lsnbttdwr4rhff0c1htz25o0xw6edva</sha1>
    </revision>
    <revision>
      <id>3208</id>
      <parentid>3207</parentid>
      <timestamp>2025-06-23T14:53:18Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>New article</comment>
      <origin>3208</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6144" sha1="6uokpw77ff7vz0njnoh3xien66vs03y" xml:space="preserve">== Draft Space 1 ==

== U-Hector Pieterson ==
'''UZolile Hector Pieterson''' bekaneminyaka eli-12 lokha nakazakubulawa mapholisa womBuso weBandlululo ngomhlaka-16 kuMgwengweni 1976. Lokhu kwenzeke ngesikhathi abantwana babantu abanzima benza umtjhagalo e-Soweto, balwela ukukhitjhwa kwemithethokambiso enganabulungisa nokuthi isiBhuru kufuze singasabi lilimi okufundiswa ngalo zoke iimfundo esikolweni sabanzima. Isithombe sokufa kwakhe esidumileko esatjhudwa nguSam Nzima senza iphasi loke lawuqala ngamanye amehlo umBuso weBandlululo. U-Hector Pieterson noHastings Ndlovu, naye obekamfundi, baba bantwana bokuthoma ukubulawa emTjhagalweni we-Soweto.&lt;ref&gt;Ernest Leong, J.E. Luebering (2025), ''Hector Pieterson'', Encyclopedia Britannica,  retrieved at: https://www.britannica.com/biography/Hector-Pieterson Retrieved 23-06-2025.&lt;/ref&gt; 

== Umlando Ka-Hector Pieterson ==
UZolile Hector Pieterson wabelethwa ngo-1963 abelethwa nguDorothy Molefi unina, noyise uVivian Pieterson. Wabelethelwa bewakhuliselwa e-Soweto eSewula Afrika. Nanyana bekunguye omsana kunina, bekanabodadwabo abane, abanye u-Antoinette Sithole noSina Molefi abeze nonina, bese uLulu Pieterson angudadwabo kubabelethi bobabili. Ngokwalokho unina akutjhoko ngaye, uthi u-Hector bekamsanyana othandekako othanda ukumomotheka, amsana othanda amahlaya ahlakaniphile. Yena nodadwabo u-Antoinette bebangena isikolo sinye. Nanyana ngiliphi ibhudango ebekanalo ngengomuso lakhe latjhabalala mhla kuhlelwa ijima lomtjhagalo ngo-1976.&lt;ref&gt;Briefly Website, (2025), Hector Pieterson: The untold truth of the 1976 Soweto Uprising - Written on 17-06-2021, Retrieved from: https://briefly.co.za/31902-hector-pieterson-untold-truth-symbol-1976-soweto-uprising.html Retrieved on 23-06-2025.&lt;/ref&gt;

== Isizathu Somtjhagalo We-Soweto ==
Umtjhagalo we-Soweto ngesikhuwa owaziwa ngokuthi yi-''Soweto Uprising'' wathoma ngomhlaka-16 kaMgwengweni 1976. Isizathu sokuba khona komtjhagalo lo kukwethulwa kwesiBhuru njengelimi okuzokufundwa ngalo zoke iimfundo eenkolweni zabantu abanzima. Abantwana abaziinkulungwana ezimatjhumi amabili (20 000) bahlanganyela emtjhagalweni lo. U-Hector nodadwabo u-Antoinette Sithole bebahlangana nesibalweso. Amapholisa womBuso webandlululo athuthumbisa iinkule nama-''teargas,'' kwafa isibalo sabantwana esingaba likhulu namatjhumi alikhomba nesithandathu (176). Kusolelwa bona abantwana abafa mhlokho bangaphezu kwesibalwesi.&lt;ref&gt;Zinn Education Project (2025), ''June 16, 1976: Soweto Uprising,'' Retrieved at: https://www.zinnedproject.org/news/tdih/soweto-uprising/ Retreived on 23-06-2025.&lt;/ref&gt; 

Nasizokuzwisisa bona izenzakalo zango-1976 zenzeka njani, kufuze sizwisise bona umsuka wazo uza njani. Ekuthomeni kwabo-1970, umnotho enarheni le bewusezingeni eliphasi, amanani wokuthenga izinto ezitlhogekako bekaphezulu, nemisebenzi iyindlala. Ngaphezu kwalokho bekunabantu abanengi abasuka eendaweni zemakhaya abeza bazokuhlala emalokitjhini ngebanga lokufuna amadlelo alihlaza. Ngebanga lalokho amalokitjhi besele anesibalo esikhulu sabantu abavela eendaweni ezinengi, bese lokho kwenza  neensetjenziswa zaba zincani. Lokhu kwabangela abantu bona bahlangahlangane bebathukuthele njengombana izinga lokuphila sele lehle khulu. Kodwana lokho khenge kube semtarini bekwaba kulapho kuthoma umtjhagalo wabantwana besikolo. &lt;ref name=&quot;:0&quot;&gt;South African History Archive (SAHA), (2025), ''The Youth take charge: the Soweto Uprising of June 1976'', Retrieved from: https://www.saha.org.za/youth/bantu_education.htm Retrived on 23-06-2025.&lt;/ref&gt;

Abantwana besikolo bangesikhatheso besele bangasanalo ithemba ngengomuso. Iinkumba zokufundela bezizele swi ngabangafundi, zinganazo iintlabagelo ezaneleko zokufunda, begodu abotitjhere nabazakulawula kuhle abantwana bekufuze babakhalime budisi ngokubabetha nangokubajezisa ngezinye iindlela ezibudisi. Kuncani khulu ebekufundwa esikolweni ngesikhatheso. Ngaphezu kwalokho ngo-1975, urhulumende wangaleso sikhathi wangezelela ebudisini ebebaqalene nabo ngokuthatha isiqunto sokuthi isiBhuru kube lilimi okuzokufundwa ngalo iimfundo esikolweni, okutjho bona ingcenye yeemfundo ezifundwako kufuze zifundiswe ngesiBhuru.&lt;ref name=&quot;:0&quot; /&gt;

Ukufundiswa kweemfundo ngesiBhuru kwaletha ihlekelele ekabili. Kokuthoma abotitjhere bebangakghoni ukufundisa ngesiBhuru, ngapha nabafundi bangakghoni ukulikhuluma kuhle ilimeli, okutjho bona abafundi bebazokufeyila iimvivinyo zabo, bese babe bomahlalela bangawufumani umsebenzi. Okwesibili isiBhuru besiqalwa njengelimi labagqilazi, okwenza abantwana banyanya ukulikhuluma. Ngaphezu kobana kuthethe iinyanga abazali bafake iimbawo namahlongozo ngendaba le, umBuso waragela phambili nesiqunto sawo. Kwathi ekuthomeni kwango-1976 abafundi bathoma ukuhlela amajima wokulwisana nesiBhuru, nanyana kunjalo urhulumende waqinisa ihloko, wala ukulalela iinghonghoyilo zabo. Ngebanga lalokho, iinkulungwana zabafundi e-Soweto zamatjhela e-Orlando Stadium ngomhlaka-16 kaMngwengweni 1976, okukulapho bebaletha khona isinghonghoyilo sabo ngesiBhuru.&lt;ref name=&quot;:0&quot; /&gt;

Kunokuthi kulalelwe iinghonghoyilo zabafundaba, amapholisa womBuso weBandlululo wathoma ukudumuza abafundi. U-Hector Pieterson waba ngewokuthoma ukudumuzeka bewafa. Amapholisa araga nokudumuza abafundi, kodwana lokho khenge kubajamise abafundi ekutjhagaleni. Kunalokho, ukubulawa kuka-Hector kwabenza baqunga isibindi sokuraga nomtjhagalo. Baqalana namapholisa, bebatjhisa nama-ofisi we-''West Rand Administration Board (WRAB),'' ebebayiqala njengetshwayo lokugqilazwa nokugandelelwa. Batjhisa bebatjhisa neengodi phola okuziindawo ebeziqalwa njengamahlelo karhulumende wokuqeda isimilo sabantu abanzima.&lt;ref name=&quot;:0&quot; /&gt;

Naynyana urhulumende webandlululo athumela amasotja eSoweto bona bayokujamisa umtjhagalo lo, abantu baraga nawo bekwaba ziinyanga ezintathu zoke. Izenzo zabo zabasela abanye abantu abatjha kiyo yoke inarha, kwavuka imitjhagalo emalokitjhini enarheni yoke. Abantu abatjha abangaba makhulu amathathu (300) babhubha, abaziinkulungwana ezimbili (2000) balimala. Boke abafundaba - kuhlanganise no-Hector Pietersen babhadela ngepilwabo ekuthuthukiseni ifundo yabantu abanzima.

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>6uokpw77ff7vz0njnoh3xien66vs03y</sha1>
    </revision>
    <revision>
      <id>3216</id>
      <parentid>3208</parentid>
      <timestamp>2025-06-24T12:48:48Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>3216</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7920" sha1="oacixysepwhep2p1nuzgvzjfyf41jvr" xml:space="preserve">== Draft Space 1 ==

== U-Hector Pieterson ==
[[Isimumathi:Hector Pieterson Memorial, Soweto.jpg|thumb|264x264px|Ilitje lesikhumbuzo sika-Hector Pieterson]]
'''UZolile Hector Pieterson''' bekaneminyaka eli-12 lokha nakazakubulawa mapholisa womBuso weBandlululo ngomhlaka-16 kuMgwengweni 1976. Lokhu kwenzeke ngesikhathi abantwana babantu abanzima ababafundi benza umtjhagalo e-Soweto, balwela ukukhitjhwa kwemithethokambiso enganabulungisa yomBuso weBandlululo, balwela nokuthi isiBhuru kufuze singasabi lilimi okufundiswa ngalo ingcenye yeemfundo esikolweni sabanzima. Isithombe sokufa kwakhe esidumileko esatjhudwa nguSam Nzima senza iphasi loke lawuqala ngamanye amehlo umBuso weBandlululo. U-Hector Pieterson noHastings Ndlovu, naye obekamfundi, baba bantwana bokuthoma ukubulawa emTjhagalweni we-Soweto.&lt;ref&gt;Ernest Leong, J.E. Luebering (2025), ''Hector Pieterson'', Encyclopedia Britannica. Retrieved from: https://www.britannica.com/biography/Hector-Pieterson Retrieved on 23-06-2025.&lt;/ref&gt;  

== Umlando Ka-Hector Pieterson ==
UZolile Hector Pieterson wabelethwa ngo-1963 abelethwa nguDorothy Molefi unina, noyise uVivian Pieterson. Wabelethelwa bewakhuliselwa e-Soweto eSewula Afrika. Nanyana bekunguye omsana kunina, bekanabodadwabo abane, u-Antoinette Sithole noSina Molefi abeze nonina, bese uLulu Pieterson angudadwabo kubabelethi bobabili. Ngokwalokho unina akutjhoko ngaye, uthi u-Hector bekamsanyana othandekako othanda ukumomotheka, amsana ohlakaniphileko othanda amahlaya . Yena nodadwabo u-Antoinette bebangena isikolo sinye. Nanyana ngiliphi ibhudango ebekanalo ngengomuso lakhe latjhabalala mhla kuhlelwa ijima lomtjhagalo ngo-1976.&lt;ref&gt;Briefly Website, (2025), Hector Pieterson: The untold truth of the 1976 Soweto Uprising - Written on 17-06-2021, Retrieved from: https://briefly.co.za/31902-hector-pieterson-untold-truth-symbol-1976-soweto-uprising.html Retrieved on 23-06-2025.&lt;/ref&gt;

== Isizathu Somtjhagalo We-Soweto ==
Umtjhagalo we-Soweto ngesikhuwa owaziwa ngokuthi yi-''Soweto Uprising'' wathoma ngomhlaka-16 kaMgwengweni 1976. Isizathu sokuba khona komtjhagalo lo kukwethulwa kwesiBhuru njengelimi okuzokufundwa ngalo ingcenye yeemfundo eenkolweni zabantu abanzima. Abantwana abaziinkulungwana ezimatjhumi amabili bahlanganyela emtjhagalweni lo. U-Hector nodadwabo u-Antoinette Sithole bebahlangana nesibalweso. Amapholisa womBuso webandlululo athuthumbisa iinkule nama-''teargas,'' kwafa isibalo sabantwana esingaba likhulu namatjhumi alikhomba nesithandathu. Kusolelwa bona abantwana abafa mhlokho bangaphezu kwesibalwesi.&lt;ref&gt;Zinn Education Project (2025), ''June 16, 1976: Soweto Uprising,'' Retrieved at: https://www.zinnedproject.org/news/tdih/soweto-uprising/ Retreived on 23-06-2025.&lt;/ref&gt; 

Nasizokuzwisisa bona izenzakalo zango-1976 zenzeka njani, kufuze sizwisise bona umsuka wazo uza njani. Ekuthomeni kwabo-1970, umnotho enarheni le bewusezingeni eliphasi, amanani wokuthenga izinto ezitlhogekako bekaphezulu, nemisebenzi iyindlala. Ngaphezu kwalokho bekunabantu abanengi abasuka eendaweni zemakhaya abeza bazokuhlala emalokitjhini ngebanga lokuthuthukisa ipilwabo. Ngebanga lalokho amalokitjhi besele anesibalo esikhulu sabantu abavela eendaweni ezinengi, bese lokho kwenza  neensetjenziswa zaba zincani. Lokhu kwabangela abantu bona bahlangahlangane bebathukuthele njengombana izinga lokuphila sele lehle khulu. Kodwana lokho khenge kube semtarini bekwaba kulapho kuthoma umtjhagalo wabantwana besikolo. &lt;ref name=&quot;:0&quot;&gt;South African History Archive (SAHA), (2025), ''The Youth take charge: the Soweto Uprising of June 1976'', Retrieved from: https://www.saha.org.za/youth/bantu_education.htm Retrived on 23-06-2025.&lt;/ref&gt;

Abantwana besikolo bangesikhatheso besele bangasanalo ithemba ngengomuso. Iinkumba zokufundela bezizele swi ngabangafundi, zinganazo iintlabagelo ezaneleko zokufunda, begodu abotitjhere nabazakulawula kuhle abantwana bekufuze babakhalime budisi ngokubabetha nangokubajezisa ngezinye iindlela ezibudisi. Kuncani khulu ebekufundwa esikolweni ngesikhatheso. Ngaphezu kwalokho ngo-1975, urhulumende wangezelela ebudisini ebebaqalene nabo ngokuthatha isiqunto sokuthi isiBhuru kube lilimi okuzokufundwa ngalo iimfundo esikolweni, okutjho bona ingcenye yeemfundo ezifundwako kufuze zifundiswe ngesiBhuru.&lt;ref name=&quot;:0&quot; /&gt;

Ukufundiswa kweemfundo ngesiBhuru kwaletha umraro okabili. Kokuthoma abotitjhere bebangakghoni ukufundisa ngesiBhuru, ngapha nabafundi bangakghoni ukulikhuluma kuhle ilimeli, okutjho bona abafundi bebazokufeyila iimvivinyo zabo, bese babe bomahlalela bangawufumani umsebenzi. Okwesibili isiBhuru besiqalwa njengelimi labagqilazi, okwenza abantwana banyanya ukulisebenzisa. Ngaphezu kobana kuthethe iinyanga abazali bafake iimbawo neenghonghoyilo ngendaba le, umBuso waragela phambili nesiqunto sawo. Kwathi ekuthomeni kwango-1976 abafundi bathoma ukuhlela amajima wokulwisana nesiBhuru, nanyana kunjalo urhulumende waqinisa ihloko, wala ukulalela iinghonghoyilo zabo. Ngebanga lalokho, iinkulungwana zabafundi e-Soweto zamatjhela e-Orlando Stadium ngomhlaka-16 kaMgwengweni 1976, okukulapho baletha khona iinghonghoyilo zabo.&lt;ref name=&quot;:0&quot; /&gt;

Kunokuthi kulalelwe iinghonghoyilo zabafundaba abatjhagala ngokuthula, amapholisa womBuso weBandlululo athoma ukuvulela ngeenkule ebafundini. U-Hector Pieterson waba ngewokuthoma ukudumuzeka bewafa. Amapholisa araga nokudumuza abafundi, kodwana lokho khenge kubajamise abafundi ekutjhagaleni. Kunalokho, ukubulawa kuka-Hector kwabenza baqunga isibindi sokuraga nomtjhagalo. Baqalana namapholisa, bebatjhisa nama-ofisi we-''West Rand Administration Board (WRAB),'' ebebayiqala njengetshwayo lokugqilazwa nokugandelelwa. Batjhisa bebatjhisa neengodiphola okuziindawo ebeziqalwa njengamahlelo karhulumende wokuqeda isimilo sabantu abanzima.&lt;ref name=&quot;:0&quot; /&gt;

Nanyana urhulumende webandlululo athumela amasotja e-Soweto bona ayokujamisa umtjhagalo lo, abantu baraga nawo iinyanga ezintathu zoke. Izenzo zabo zabasela abanye abantu abatjha kiyo yoke inarha, kwaqubuka imitjhagalo ngemitjhagalo emalokitjhini enarheni yoke. Abantu abatjha abangaba makhulu amathathu babhubha, abaziinkulungwana ezimbili balimala. Boke abafundaba - kuhlanganise no-Hector Pietersen babhadela ngepilwabo ekuthuthukiseni ifundo yabantu abanzima.&lt;ref name=&quot;:0&quot; /&gt;

== Indima Edlalwe Kukufa Kuka-Hector Pieterson ==
[[Isimumathi:Hector Pieterson Museum, Soweto.jpg|thumb|333x333px|Imiziyamu ka-Hector Pieterson]]
Ukuhlongakala kuka-Hector Pieterson kudlale indima ekulu ekulwelweni kwamalungelo wobuntu nomBuso webandlululo kangangobana ilanga langomhlaka-16 kaMgwengweni lilanga labantu abatjha eligidingwa enarheni yoke. Isithombe sika-Hector athwelwe nguMbuyisa Makhubo, dnoadwabo ka-Hector agijima hlanu kwabo ngiso esithathwa njengetshwayo lelangeli. Isithombesi singezinye zeenthombe eziveza isehlakalwesi ezithwetjulwe nguSam Nzima.&lt;ref name=&quot;:1&quot;&gt;Lucille Davie, (14 June 2002), ''Hector: the famous child''

''whose face is unknown,'' Web Archive website (2023). Retrieved from: https://web.archive.org/web/20030327052242/https://joburg.org.za/june_2002/hector.stm Retrieved on 24-06-2025.&lt;/ref&gt; 

Ngaphezu kwalokho, bekwavulwa nemiziyamu ebizwa ngegama lakhe - ''Hector Pieterson Museum'' - e-Orlando West e-Soweto. Imiziyamu le isesitaradeni sesibili ukusukela lapha u-Hector adunyuzelwa khona. Indawo le inamafilimu, amaphephandaba, ukulandisa kwabantu abazibonele ngewabo isenzakalwesi neenthombe, nalesi esidume khulu esathwetjulwa nguSam Nzima. i-''Hector Peterson Museum'' yimiziyamu yokuthoma e-Soweto eyavulwa ngomhlaka-16 kaMgwengweni 2002. Kuthethe imali engange-R23 200 000 ukuyakha begodu i-R16 000 000 yimali enikelwe ngokuzithandela mNyango wezeBhoduluko nezokuVakatjha, bese i-R7 200 000 yanikelwa Mkhandlu weDorobho le-Johannesburg. Yeke imiziyamu le iyokuhlala isikhumbuzo sokufa kuka-Hector Pieterson nokulwela kwabantu abatjha itjhaphuluko.&lt;ref name=&quot;:1&quot; /&gt; 

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>oacixysepwhep2p1nuzgvzjfyf41jvr</sha1>
    </revision>
    <revision>
      <id>3456</id>
      <parentid>3216</parentid>
      <timestamp>2025-07-23T12:03:07Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>Deleted an article</comment>
      <origin>3456</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="19" sha1="18n7y18ghorstdggo7ek5hyav8bgmj6" xml:space="preserve">== Draft Space 1 ==</text>
      <sha1>18n7y18ghorstdggo7ek5hyav8bgmj6</sha1>
    </revision>
    <revision>
      <id>3497</id>
      <parentid>3456</parentid>
      <timestamp>2025-07-29T17:59:57Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>New article</comment>
      <origin>3497</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5936" sha1="c1dj9vzy9zzuntg6u8brc5hep13n47y" xml:space="preserve">== Draft Space 1 ==

== INgwenyama UMagodongo ==
INgwenyama uMagodongo (1811-1827) khabe ayiNgwenyama yamaNdebele wakwaNzunza kusukela ngomnyaka wango-1814 ukuya ngo-1827. UMagodongo uyindodana yeNgwenyama uMgwezani umfowabo kaGembe. Yena bekaliDlowu (1799) umnakwabo aliNghana (1791). Nanyana kunezenzakalo ezinengi ezenzeke ngokubusa kwayo iNgwenyama uMagodongo waziwa ngokulwa nebutho likaMzilikazi wesitjhaba samaZulu wakwaKhumalo, okukulapho yalahlekelwa khona buphilo bayo ngo-1827. Namhlanjesi iNgwenyama uMagodongo kaMgwezani yaziwa njengekosi eyatjengisa isibindi ekudoseni phambili isitjhaba samaNdebele wakwaNzunza.

== Umlando KaMagodongo Wangaphambi Kobukhosi ==
UMagodongo wabelethwa ngomnyaka ka-1811 kwaSimkhulu, abelethwa nguyise iNgwenyama uMgwezani. Ubelethwa nomnakwabo uGembe oliNghana (1791), nomfowabo uMrabheli oliDlhari (1803). Isikhathi sokubelethwa kwakhe bekusikhathi sokuthula ngombana uMgwezani ekubuseni kwakhe akhenge alwe ipi. Kwathi nakuhlongakala uMgwezani, uGembe ebekunguye obekufuze athathe isihlalo sobukhosi ngokomthetho bekasesemncani ngalesosikhathi. Yeke uDzela umfowabo kayise uMgwezani wabambela uGembe waba yikosi.

=== Nakubusa uDzela ===
Kwathi bona iNgwenyama uDzela ithwale isiba, yafuduka kwaSimkhulu nesitjhaba sayo yayokwakha eMlotheni kwaMaza hlanu komlambo iSakazana. Kwathi ngelinye ilanga iNgwenyama uDzela yakhamba yayokuhlasela isitjhaba sabaNguni ebesisendaweni yangemaTjhitjhini. Bafika lapho kwalwiwa, amaNdebele ehlulwa abaleka, kanti nababalekako nje uDzela uyokuwela ngemgodini. Amanaba amlandela afika amthola ngemgodini loyo bambulalela khona, umgodi loyo waba lithuna lakhe uDzela. Kodwana ngebanga lokuthi uGembe bekasesemncani ngesikhatheso kwafuze abanjelwe isihlalo. Yeke omunye umfowabo kayise, uMrhabuli kwaba nguye obambela uGembe.

=== Nakubusa uMrhabuli ===
UMrhabuli (uSirudla) wathwala isiba ngo-1797 wabusa isitjhaba samaNdebele kwaMaza eMlotheni. Ngesikhathi sokubusa kwakhe, uMrhabuli nguye owathumela uMagodongo nomnakwabo uGembe bona bayokuhlasela esinye isitjhaba sabeNguni. UGembe wadosa intangakhe amaNghana phambili, uMagodongo yena warhola amaDlowu, kwatjhingwa ngePumalanga. Kwathi bona uGembe abone ibutho labeNguni warhidlwa livalo waze waphathwa namathumbu, kwafuze bona abhace khona angazukubonakala. UMagodongo yena wathatha ibutho likamnakwabo walihlanganisa nelakhe wathathana phezulu namanaba. AbeNguni bahlulwa epini leyo. UMagodongo nebutho lakhe bathumba iinkomo neembuzi zabeNguni wabuya ekhaya.

Ngebanga lokuthi uGembe abe litjhatjha epini amadoda athi akakafaneli ukuba yikosi, kodwana benyula uMagodongo. Lokho kwenza bona uGembe noMagodongo bangasathelelani amanzi. Amadoda athi nakalemuka lokho, athatha uMagodongo ayomfihla ekhabomkhulu kwaMahlaza.

=== Ipi KaMagodongo NoKhunwana ===
Ikosi uMrhabuli njengombana beyilibambela nje ithe nayilemukako bona amadodanayo sele akhulile yafisa ngathana uMagodongo angabuya athathe iintambo. Kodwana amadodanayo ala. Alibeka emtarini bona uyise nakakhothamako indodanakhe ekulu uKhunwana nguye ozokuthatha isihlalo. UMrhabuli wathumela bona kuyokulandwa uMagodongo azokuzwa indaba le. Uthe nakafikako, uMrhabuli wamthatha wamfihla endaweni lapho bekuzokubanjelwa khona umhlangano. Emhlanganweni uMrhabuli wathoma indaba emadodeni, indaba yadenjwa, kwaphikiswana, kwathi nakuphela umhlangano, uMrhabuli wavumbulula uMagodongo wambuza bona uzwile na. UMagodongo wathi uzwile, nokuthi uzokuthatha ubukhosi ngepi. Uzokuthatha isitjhaba kwaMahlaza azokwakha kwaMaza.

Kwaba nepi phakathi kukaMagodongo noKhunwana. Ipi leyo yalwiwa beyayokufika kwaPondo, yabuya yayokulwelwa ekhaya kwaMaza. UMrhabuli wayetjele uMagodongo bona nakazokuthatha ubukhosi ngepi, kufuze angayibulali indodana yekosi, uMavula, ngombana nguye okufuze ambambele ikapho kanaselako. Kodwana kwathi nakulwiwako nje uMavula nguye okhabe aqeda ibutho likaMagodongo, okwenza bona ekugcineni uMagodongo ambulale uMavula. Kwathi bona uMagodongo ahlule ipi, uMrhabuli wambuza bona uphi uMavula. UMagodongo wathi umbulele. UMrhabuli wathi ngombana abulele uMavula angekhe abe yikosi. Kodwana uMagodongo wabulala uMrhabuli nenye yamakhosikazakhe. Ekugcineni uMagodongo wayihlula ipi. UKhunwana nabanye bakwaMrhabuli bafuduka bayokuhlala nabaTswana eBurolong. Ekugcineni uMagodongo wathatha isihlalo ngo-1814, wabusa isitjhaba samaNdebele ebesele sihlala esiKhunjini.

== Umlando kaMagodongo Nasele Abusa ==
Ekubuseni kwakhe uMagodongo wathatha amakhosikazi. Naka amagamawo:

* UNaMahena ongunina NoBharhuza
* UNaMabhena oyihlanzi onguNoMtshabi
* UNaMatjhaba ongunina kaSibogo
* UNaMdluli uNoMagogo onguNoMabhoko
* UNaNtuli onguNoGwalimba

Naka amadodana kaMagodongo:

* UBharhuza (liGawu - 1815) 
* UMloyi (liDzibha - 1819)
* UMtshabi (liThula - 1823)
* UBengwabo (liDlaza - 1827)
* USomdeyi - 1831
* UMgwayana (liDugu - 1835)
* USibogo - 1831
* UMabhoko (liSinya - 1839)
* UNdaweni (liRhorha - 1847)
* UGwalimba (liPhogo - 1843)

== Ipi KaMagodongo NoMzilikazi ==
Ngo-1831 kwafika uMzilikazi kaMashobane wesitjhaba sakwaKhumalo asuka kwelabeNguni eSewula abalekela uShaka. Kwathi bona uMzilikazi afike esigodlweni sikaMagodongo esiKhunjini, wafika wabawa amabutho wokulwa nekosi uShaka. UMagodongo wavuma angakahlali phasi wacoca namadoda. Bavumelana, ngemva kwalokho uMzilikazi wathi usaya kwaManala uyokubawa amanye amabutha. UMagodongo wathi akakhambe uzawathatha nakabuyako. Wakhamba uMzilikazi waya ekosini yaManala uSibindi.

Uthe nakasakhambileko uMzilikazi, uMagodongo wabiza amadoda bona kuzokucociswana ngendaba le. Kwathi nakucociswanako amadoda wala ukunikela uMzilikazi amabutho. Isizathu salokho kukuthi uShaka kubudisi ukumehlula ngombana udlondlobele. Yeke bavumelana ngokuthi bazokukhambisa boke abantu abatjha okufuze babe libutho baye ebuzimbeni bomqedantonga ukwenzela bona uMzilikazi nakafikako abathole bangekho. Nangambala kwaba njalo.

UMzilikazi wafika kwaManala wabawa uSibindi, uSibindi naye wavuma.</text>
      <sha1>c1dj9vzy9zzuntg6u8brc5hep13n47y</sha1>
    </revision>
    <revision>
      <id>3502</id>
      <parentid>3497</parentid>
      <timestamp>2025-07-30T12:28:11Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>references put</comment>
      <origin>3502</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7970" sha1="or5i5kf32hybuep8lkbsc42comhtqtp" xml:space="preserve">== Draft Space 1 ==

== INgwenyama UMagodongo ==
INgwenyama uMagodongo (1811-1827) khabe ayiNgwenyama yamaNdebele wakwaNzunza kusukela ngomnyaka wango-1814 ukuya ngo-1827. UMagodongo uyindodana yeNgwenyama uMgwezani umfowabo kaGembe. Yena bekaliDlowu (1799) umnakwabo aliNghana (1791). Nanyana kunezenzakalo ezinengi ezenzeke ngokubusa kwayo iNgwenyama uMagodongo waziwa ngokulwa nebutho likaMzilikazi wesitjhaba samaZulu wakwaKhumalo, okukulapho yalahlekelwa khona buphilo bayo ngo-1827. Namhlanjesi iNgwenyama uMagodongo kaMgwezani yaziwa njengekosi eyatjengisa isibindi ekudoseni phambili isitjhaba samaNdebele wakwaNzunza.&lt;ref name=&quot;:0&quot;&gt;South African History Online. (2011, April 3). ''The Ndebele in history''. South African History Online. Retrieved from:https://sahistory.org.za/article/ndebele-history. Retrieved on 30/07/2025.&lt;/ref&gt;

== Umlando KaMagodongo Wangaphambi Kobukhosi ==
UMagodongo wabelethwa ngomnyaka ka-1811 kwaSimkhulu, abelethwa nguyise iNgwenyama uMgwezani. Ubelethwa nomnakwabo uGembe oliNghana (1791), nomfowabo uMrabheli oliDlhari (1803). Isikhathi sokubelethwa kwakhe bekusikhathi sokuthula ngombana uMgwezani ekubuseni kwakhe akhenge alwe ipi. Kwathi nakuhlongakala uMgwezani, uGembe ebekunguye obekufuze athathe isihlalo sobukhosi ngokomthetho bekasesemncani ngalesosikhathi. Yeke uDzela umfowabo kayise uMgwezani wabambela uGembe waba yikosi.&lt;ref name=&quot;:1&quot;&gt;C.J. Mahlangu, K.N. Mahlangu, M. A. Mahlangu, S. M. Mtshweni, (2011) ''Iziko Lamakhosi''. Shutter &amp; Shooter.&lt;/ref&gt;

=== Nakubusa uDzela ===
Kwathi bona iNgwenyama uDzela ithwale isiba, yafuduka kwaSimkhulu nesitjhaba sayo yayokwakha eMlotheni kwaMaza hlanu komlambo iSakazana. Kwathi ngelinye ilanga iNgwenyama uDzela yakhamba yayokuhlasela isitjhaba sabaNguni ebesisendaweni yangemaTjhitjhini. Bafika lapho kwalwiwa, amaNdebele ehlulwa abaleka, kanti nababalekako nje uDzela uyokuwela ngemgodini. Amanaba amlandela afika amthola ngemgodini loyo bambulalela khona, umgodi loyo waba lithuna lakhe uDzela. Kodwana ngebanga lokuthi uGembe bekasesemncani ngesikhatheso kwafuze abanjelwe isihlalo. Yeke omunye umfowabo kayise, uMrhabuli kwaba nguye obambela uGembe.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot;&gt;M.H. Schoeman (1998), Excavating Ndzudza Ndebele Identity at KwaMaza, Southern African Field Archaeology. Retrieved from: https://journals.uj.ac.za/pdf/safa/1998_1%20UJ%20FIELD%20Archive/07_42-52%20Schoeman%201998%20Excavating%20Ndzundza%20identity.pdf. Retrieved on 30/07/2025.&lt;/ref&gt;

=== Nakubusa uMrhabuli ===
UMrhabuli (uSirudla) wathwala isiba ngo-1797 wabusa isitjhaba samaNdebele kwaMaza eMlotheni. Ngesikhathi sokubusa kwakhe, uMrhabuli nguye owathumela uMagodongo nomnakwabo uGembe bona bayokuhlasela esinye isitjhaba sabeNguni. UGembe wadosa intangakhe amaNghana phambili, uMagodongo yena warhola amaDlowu, kwatjhingwa ngePumalanga. Kwathi bona uGembe abone ibutho labeNguni warhidlwa livalo waze waphathwa namathumbu, kwafuze bona abhace khona angazukubonakala. UMagodongo yena wathatha ibutho likamnakwabo walihlanganisa nelakhe wathathana phezulu namanaba. AbeNguni bahlulwa epini leyo. UMagodongo nebutho lakhe bathumba iinkomo neembuzi zabeNguni wabuya ekhaya.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

Ngebanga lokuthi uGembe abe litjhatjha epini amadoda athi akakafaneli ukuba yikosi, kodwana benyula uMagodongo. Lokho kwenza bona uGembe noMagodongo bangasathelelani amanzi. Amadoda athi nakalemuka lokho, athatha uMagodongo ayomfihla ekhabomkhulu kwaMahlaza.&lt;ref name=&quot;:1&quot; /&gt;

=== Ipi KaMagodongo NoKhunwana ===
Ikosi uMrhabuli njengombana beyilibambela nje ithe nayilemukako bona amadodanayo sele akhulile yafisa ngathana uMagodongo angabuya athathe iintambo. Kodwana amadodanayo ala. Alibeka emtarini bona uyise nakakhothamako indodanakhe ekulu uKhunwana nguye ozokuthatha isihlalo. UMrhabuli wathumela bona kuyokulandwa uMagodongo azokuzwa indaba le. Uthe nakafikako, uMrhabuli wamthatha wamfihla endaweni lapho bekuzokubanjelwa khona umhlangano. Emhlanganweni uMrhabuli wathoma indaba emadodeni, indaba yadenjwa, kwaphikiswana, kwathi nakuphela umhlangano, uMrhabuli wavumbulula uMagodongo wambuza bona uzwile na. UMagodongo wathi uzwile, nokuthi uzokuthatha ubukhosi ngepi. Uzokuthatha isitjhaba kwaMahlaza azokwakha kwaMaza.&lt;ref name=&quot;:2&quot; /&gt;

Kwaba nepi phakathi kukaMagodongo noKhunwana. Ipi leyo yalwiwa beyayokufika kwaPondo, yabuya yayokulwelwa ekhaya kwaMaza. UMrhabuli wayetjele uMagodongo bona nakazokuthatha ubukhosi ngepi, kufuze angayibulali indodana yekosi, uMavula, ngombana nguye okufuze ambambele ikapho kanaselako. Kodwana kwathi nakulwiwako nje uMavula nguye okhabe aqeda ibutho likaMagodongo, okwenza bona ekugcineni uMagodongo ambulale uMavula. Kwathi bona uMagodongo ahlule ipi, uMrhabuli wambuza bona uphi uMavula. UMagodongo wathi umbulele. UMrhabuli wathi ngombana abulele uMavula angekhe abe yikosi. Bewaqalekisa ngokuthi &quot;napo ubunyonyo obunzima phezu kwakho.&quot; Kodwana uMagodongo wabulala uMrhabuli nenye yamakhosikazakhe. Ekugcineni uMagodongo wayihlula ipi. UKhunwana nabanye bakwaMrhabuli bafuduka bayokuhlala nabaTswana eBurolong. Ekugcineni uMagodongo wathatha isihlalo ngo-1814, wabusa isitjhaba samaNdebele ebesele sihlala esiKhunjini.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

== Umlando kaMagodongo Nasele Abusa ==
Ekubuseni kwakhe uMagodongo wathatha amakhosikazi. Naka amagamawo:

* UNaMahena ongunina NoBharhuza
* UNaMabhena oyihlanzi onguNoMtshabi
* UNaMatjhaba ongunina kaSibogo
* UNaMdluli uNoMagogo onguNoMabhoko
* UNaNtuli onguNoGwalimba &lt;ref name=&quot;:1&quot; /&gt;

Naka amadodana kaMagodongo:

* UBharhuza (liGawu - 1815) 
* UMloyi (liDzibha - 1819)
* UMtshabi (liThula - 1823)
* UBengwabo (liDlaza - 1827)
* USomdeyi - 1831
* UMgwayana (liDugu - 1835)
* USibogo - 1831
* UMabhoko (liSinya - 1839)
* UNdaweni (liRhorha - 1847)
* UGwalimba (liPhogo - 1843)&lt;ref name=&quot;:1&quot; /&gt;

== Ipi KaMagodongo NoMzilikazi ==
Ngo-1831 kwafika uMzilikazi kaMashobane wesitjhaba sakwaKhumalo asuka kwelabeNguni eSewula abalekela uShaka. Kwathi bona uMzilikazi afike esigodlweni sikaMagodongo esiKhunjini, wafika wabawa amabutho wokulwa nekosi uShaka. UMagodongo wavuma angakahlali phasi wacoca namadoda. Bavumelana, ngemva kwalokho uMzilikazi wathi usaya kwaManala uyokubawa amanye amabutha. UMagodongo wathi akakhambe uzawathatha nakabuyako. Wakhamba uMzilikazi waya ekosini yaManala uSibindi.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

Uthe nakasakhambileko uMzilikazi, uMagodongo wabiza amadoda bona kuzokucociswana ngendaba le. Kwathi nakucociswanako amadoda wala ukunikela uMzilikazi amabutho. Isizathu salokho kukuthi uShaka kubudisi ukumehlula ngombana udlondlobele. Yeke bavumelana ngokuthi bazokukhambisa boke abantu abatjha okufuze babe libutho baye ebuzimbeni bomqedantonga ukwenzela bona uMzilikazi nakafikako abathole bangekho. Nangambala kwaba njalo.&lt;ref name=&quot;:1&quot; /&gt;

UMzilikazi wafika kwaManala wabawa uSibindi, uSibindi naye wavuma. Ngemva kwalokho uMzilikazi wabuyela emva kwaMagodongo bona ayokulanda ibutho athenjiswe lona. Enye indoda yatjela uSibindi namadoda waManala bona uzwe ngamahlebezana bona uMzilikazi ufuna ukuthatha amabutho wabo nakaqeda abaleke nawo. Kodwana uSibindi namadoda wakwaManala khenge bayilalele.&lt;ref name=&quot;:1&quot; /&gt;

UMzilikazi wabuya kelakaNzunza wabawa lokho athenjiswe khona, kodwana uMagodongo namadoda wamaNzunza bala baphetha ngokumnikela ibutho. Batjho nokuthi nanyana bangamnikela amabutho angekhe akghone ukulwa noShaka. UMzilikazi waqunta ukuhlasela uMagodongo nesitjhaba. Kuthiwa ibutho lakhe lehla livela entabeni yesiKhunjini, elinye lavela ncazoke ngakaMaza. Kodwana nanyana arogelelekile amaNdebele alwa. Ekugcineni ahluleka. UMzilikazi wathatha uMagodongo nendodanakhe uMloyi, nenduna uMthimunye wababophelela ngamatje entanyeni wabaphosela ngesizibeni. Kwaba kuhlongakala kweNgwenyama uMagodongo. Kwathi bona abantu abatjha sele babuyile babalandela iinthunjwa basindisa ezinye zazo. Isitjhaba samaNdebele savuseleleka ngobunjalo.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>or5i5kf32hybuep8lkbsc42comhtqtp</sha1>
    </revision>
    <revision>
      <id>3503</id>
      <parentid>3502</parentid>
      <timestamp>2025-07-30T13:00:40Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>spelling fix</comment>
      <origin>3503</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7978" sha1="ng5pnsysbcoovo8dqjgrhb38mzcli5x" xml:space="preserve">== Draft Space 1 ==

== INgwenyama UMagodongo ==
'''INgwenyama uMagodongo''' (1811-1827) yingwenyama eyabusa  amaNdebele wakwaNzunza kusukela ngomnyaka wango-1814 ukuya ngo-1827. UMagodongo uyindodana yeNgwenyama uMgwezani. Welama uGembe, godu abe mnakwabo kaMrabheli. Nanyana kunezenzakalo ezinengi ezenzeke ngokubusa kwakhe, uMagodongo waziwa ngokulwa nebutho likaMzilikazi wesitjhaba samaZulu wakwaKhumalo, okukulapho alahlekelwa khona yipwakhe ngo-1827. Namhlanjesi iNgwenyama uMagodongo kaMgwezani yaziwa njengekosi eyatjengisa isibindi ekudoseni phambili isitjhaba samaNdebele wakwaNzunza.&lt;ref name=&quot;:0&quot;&gt;South African History Online. (2011, April 3). ''The Ndebele in history''. South African History Online. Retrieved from:https://sahistory.org.za/article/ndebele-history. Retrieved on 30/07/2025.&lt;/ref&gt;&lt;ref name=&quot;:1&quot; /&gt;

== Umlando KaMagodongo Wangaphambi Kobukhosi ==
UMagodongo wabelethwa ngomnyaka ka-1811 kwaSimkhulu, abelethwa nguyise iNgwenyama uMgwezani. Ubelethwa nomnakwabo uGembe oliNghana (1791), nomtanabo uMrabheli oliDlhari (1803). Isikhathi sokubelethwa kwakhe bekusikhathi sokuthula ngombana uMgwezani ekubuseni kwakhe akhenge alwe ipi. Kwathi nakuhlongakala uMgwezani, uGembe ebekunguye obekufuze athathe isihlalo sobukhosi ngokomthetho bekasesemncani ngalesosikhathi. Yeke uDzela umfowabo kayise uMgwezani wabambela uGembe isihlalo sobukhosi.&lt;ref name=&quot;:1&quot;&gt;C.J. Mahlangu, K.N. Mahlangu, M. A. Mahlangu, S. M. Mtshweni, (2011) ''Iziko Lamakhosi''. Shutter &amp; Shooter.&lt;/ref&gt;

=== Nakubusa uDzela ===
Kwathi bona iNgwenyama uDzela ithwale isiba, yafuduka kwaSimkhulu nesitjhaba sayo yayokwakha eMlotheni kwaMaza hlanu komlambo iSakazana. Kwathi ngelinye ilanga iNgwenyama uDzela yakhamba yayokuhlasela isitjhaba sabaNguni ebesisendaweni yangemaTjhitjhini. Bafika lapho kwalwiwa, amaNdebele ehlulwa abaleka, kanti nababalekako nje uDzela uyokuwela ngemgodini. Amanaba amlandela afika amthola ngemgodini loyo ambulalela khona, umgodi loyo waba lithuna lakhe uDzela. Kodwana ngebanga lokuthi uGembe bekasesemncani ngesikhatheso kwafuze abanjelwe isihlalo. Yeke omunye umfowabo kayise, uMrhabuli kwaba nguye obambela uGembe.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot;&gt;M.H. Schoeman (1998), Excavating Ndzudza Ndebele Identity at KwaMaza, Southern African Field Archaeology. Retrieved from: https://journals.uj.ac.za/pdf/safa/1998_1%20UJ%20FIELD%20Archive/07_42-52%20Schoeman%201998%20Excavating%20Ndzundza%20identity.pdf. Retrieved on 30/07/2025.&lt;/ref&gt;

=== Nakubusa uMrhabuli ===
UMrhabuli (uSirudla) wathwala isiba ngo-1797 wabusa isitjhaba samaNdebele kwaMaza eMlotheni. Ngesikhathi sokubusa kwakhe, uMrhabuli nguye owathumela uMagodongo nomnakwabo uGembe bona bayokuhlasela esinye isitjhaba sabeNguni. UGembe wadosa intangakhe amaNghana phambili, uMagodongo yena warhola amaDlowu, kwatjhingwa ePumalanga. Kwathi bona uGembe abone ibutho labeNguni warhidlwa livalo waze waphathwa namathumbu, kwafuze bona abhace khona angazukubonakala. UMagodongo yena wathatha ibutho likamnakwabo walihlanganisa nelakhe wathathana phezulu namanaba. AbeNguni bahlulwa epini leyo. UMagodongo nebutho lakhe bathumba iinkomo neembuzi zabeNguni wabuya ekhaya.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

Ngebanga lokuthi uGembe abe litjhatjha epini amadoda athi akakafaneli ukuba yikosi, kodwana benyula uMagodongo. Lokho kwenza bona uGembe noMagodongo bangasathelelani amanzi. Amadoda athi nakalemuka lokho, athatha uMagodongo ayomfihla ekhabomkhulu kwaMahlaza.&lt;ref name=&quot;:1&quot; /&gt;

=== Ipi KaMagodongo NoKhunwana ===
Ikosi uMrhabuli njengombana beyilibambela nje ithe nayilemukako bona amadodanayo sele akhulile yafisa ngathana uMagodongo angabuya athathe iintambo. Kodwana amadodanayo ala. Alibeka emtarini bona uyise nakakhothamako indodanakhe ekulu uKhunwana nguye ozokuthatha isihlalo. UMrhabuli wathumela bona kuyokulandwa uMagodongo azokuzwa indaba le. Uthe nakafikako, uMrhabuli wamthatha wamfihla endaweni lapho bekuzokubanjelwa khona umhlangano. Emhlanganweni uMrhabuli wathoma indaba emadodeni, indaba yadenjwa, kwaphikiswana, kwathi nakuphela umhlangano, wakhambisa amadoda, ngemva kwalokho wavumbulula uMagodongo wambuza bona uzwile na. UMagodongo wathi uzwile, watjho nokuthi nakunjalo-ke uzokuthatha ubukhosi ngepi. Bese athathe isitjhaba kwaMahlaza azokwakha kwaMaza.&lt;ref name=&quot;:2&quot; /&gt;

Kwaba nepi phakathi kukaMagodongo noKhunwana. Ipi leyo yalwiwa beyayokufika kwaPondo, yabuya yayokulwelwa ekhaya kwaMaza. UMrhabuli wayetjele uMagodongo bona nakazokuthatha ubukhosi ngepi, kufuze angayibulali indodana yekosi, uMavula, ngombana nguye okufuze ambambele ikapho kanaselako. Kodwana kwathi nakulwiwako nje uMavula nguye okhabe aqeda ibutho likaMagodongo, okwenza bona ekugcineni uMagodongo abulale uMavula. Kwathi bona uMagodongo ahlule ipi, uMrhabuli wambuza bona uphi uMavula. UMagodongo wathi umbulele. UMrhabuli wathi ngombana abulele uMavula angekhe abe yikosi. Bewaqalekisa nangokuthi nangabe uzokubusa &quot;napo ubunyonyo obunzima phezu kwakho.&quot; Kodwana uMagodongo wabulala uMrhabuli nenye yamakhosikazakhe. Ekugcineni uMagodongo wayihlula ipi. UKhunwana nabanye bakwaMrhabuli bafuduka bayokuhlala nabaTswana eBurolong. Ekugcineni uMagodongo wathatha isihlalo ngo-1814, wabusa isitjhaba samaNdebele.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

== Umlando kaMagodongo Nasele Abusa ==
Ekubuseni kwakhe uMagodongo wathatha amakhosikazi. Naka amagamawo:

* UNaMahena onguNoBharhuza
* UNaMabhena oyihlanzi onguNoMtshabi
* UNaMatjhaba onguNoSibogo
* UNaMdluli uNoMagogo onguNoMabhoko
* UNaNtuli onguNoGwalimba &lt;ref name=&quot;:1&quot; /&gt;

Naka amadodana kaMagodongo:

* UBharhuza (liGawu - 1815) 
* UMloyi (liDzibha - 1819)
* UMtshabi (liThula - 1823)
* UBengwabo (liDlaza - 1827)
* USomdeyi - 1831
* UMgwayana (liDugu - 1835)
* USibogo - 1831
* UMabhoko (liSinya - 1839)
* UNdaweni (liRhorha - 1847)
* UGwalimba (liPhogo - 1843)&lt;ref name=&quot;:1&quot; /&gt;

== Ipi KaMagodongo NoMzilikazi ==
Ngo-1831 kwafika uMzilikazi kaMashobane wesitjhaba sakwaKhumalo asuka kwelabeNguni eSewula abalekela uShaka. Kwathi bona uMzilikazi afike esigodlweni sikaMagodongo esiKhunjini kwaMaza, wafika wabawa amabutho wokulwa nekosi uShaka. UMagodongo wavuma angakabonisani namadoda. Bavumelana, ngemva kwalokho uMzilikazi wathi usaya kwaManala uyokubawa amanye amabutho. UMagodongo wathi akakhambe uzawathatha nakabuyako. Wakhamba uMzilikazi waya ekosini yaManala uSibindi.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

Uthe nakasakhambileko uMzilikazi, uMagodongo wabiza amadoda bona bazokubonisana ngendaba le. Kwathi nakucociswanako amadoda wala ukunikela uMzilikazi amabutho. Isizathu salokho kukuthi uShaka kubudisi ukumehlula ngombana udlondlobele. Yeke bavumelana ngokuthi bazokukhambisa boke abantu abatjha okufuze babe libutho baye ebuzimbeni bomqedantonga ukwenzela bona uMzilikazi nakafikako abathole bangekho. Nangambala kwaba njalo.&lt;ref name=&quot;:1&quot; /&gt;

UMzilikazi wafika kwaManala wabawa uSibindi, uSibindi naye wavuma. Ngemva kwalokho uMzilikazi wabuyela emva kwaMagodongo bona ayokulanda ibutho athenjiswe lona. Enye indoda yatjela uSibindi namadoda wakwaManala bona uzwe ngamahlebezana bona uMzilikazi ufuna ukuthatha amabutho wabo nakaqeda abaleke nawo. Kodwana uSibindi namadoda wakwaManala khenge bayilalele.&lt;ref name=&quot;:1&quot; /&gt;

UMzilikazi wabuya kwaNzunza wabawa lokho athenjiswe khona, kodwana uMagodongo namadoda wamaNzunza bala baphetha ngokumnikela ibutho. Batjho nokuthi nanyana bangamnikela amabutho angekhe akghone ukulwa noShaka. UMzilikazi waqunta ukuhlasela uMagodongo nesitjhaba. Kuthiwa ibutho lakhe lehla livela entabeni yesiKhunjini, elinye lavela ncazoke ngakaMaza. Kodwana nanyana arogelelekile amaNdebele alwa. Ekugcineni ahluleka. UMzilikazi wathatha uMagodongo nendodanakhe uMloyi, nenduna uMthimunye wababophelela ngamatje entanyeni wabaphosela ngesizibeni. Kwaba kuhlongakala kweNgwenyama uMagodongo. Kwathi bona abantu abatjha sele babuyile balandela iinthunjwa basindisa ezinye zazo. Isitjhaba samaNdebele sasinda ngobunjalo.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>ng5pnsysbcoovo8dqjgrhb38mzcli5x</sha1>
    </revision>
    <revision>
      <id>5231</id>
      <parentid>3503</parentid>
      <timestamp>2025-08-25T12:18:23Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>New article</comment>
      <origin>5231</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1569" sha1="p2pdtsz7j7q3mm5tte2dsge5l5a6msi" xml:space="preserve">== Draft Space 1 ==

== ILanga LaboMma ==
[[Isimumathi:Women of Ndebele village, Mpumalanga, South Africa (20489604056).jpg|thumb|377x377px|Abomma bamaNdebele]]
'''ILanga laboMma''' lilanga eligidingwa qobe mnyaka eSewula Afrika ngomhla ka-9 kuRhoboyi. Ilangeli lasungulwa ngomnyaka wango-1956 lokha abomma abanzima babamba umtjhagalo omayelana nokuphasiswa kwemiThetho yePasa ebafazini ngesikhathi somBuso weBandlululo. Umthetho lo wawutlanyelwe ukugandelela abomma bona bangakghoni ukuzenzela kodwana babe ngaphasi kwamadodabo. Yeke abomma abangaba zii-20 000 bamatjha batjhinga e-''Union Building'' ePitori bona bafake isinghonghoyilo esiphikisana nomThetho i-''Population Registration Act'' bona nabazokukhamba eSewula Afrika kufuze bahlale baphethe ipasa.&lt;ref name=&quot;:0&quot;&gt;South African Government (9 August 2025) ''Women's Day 2025.'' Retrieved From: https://www.gov.za/WomensDay2025. Retrieved on 25/08/2025.&lt;/ref&gt; 

ILanga laboMma aligidingi isenzakalweso kwaphela, kodwana ligidinga nezinye izenzakalo lapho kunabomma ababa mavulandlela kilenarha yeSewula Afrika kusukela ngo-1913, lokha abomma abanjengo-Charlotte Maxeke basungula iLigi yaboMma (''Womens League'') ehlanganweni ye-ANC ekhuthaza abomma bona bazibandakanye ekulweleni ithaphuluko. Amavulandlela la ahlanganisa nabo-Cissy, u-Jaynab noAmina Gool, ebebaphakathi kwabadosiphambili be- National Liberation League nebe-Non-European United Front yangabo-1930. Ngikho nje inyanga kaRhoboyi yoke nje kuyinyanga ekhethelwe ukugidinga abomma boke beSewula Afrika.&lt;ref name=&quot;:0&quot; /&gt;

Umtjhagalo Wabomma Wango-1</text>
      <sha1>p2pdtsz7j7q3mm5tte2dsge5l5a6msi</sha1>
    </revision>
    <revision>
      <id>5232</id>
      <parentid>5231</parentid>
      <timestamp>2025-08-25T12:57:08Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>5232</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2486" sha1="9to27lv6cag5jjkt4ko5541zmujc2az" xml:space="preserve">== Draft Space 1 ==

== ILanga LaboMma ==
[[Isimumathi:Women of Ndebele village, Mpumalanga, South Africa (20489604056).jpg|thumb|197x197px|Abomma bamaNdebele]]
'''ILanga laboMma''' lilanga eligidingwa qobe mnyaka eSewula Afrika ngomhla ka-9 kuRhoboyi. Ilangeli lasungulwa ngomnyaka wango-1956 lokha abomma abanzima babamba umtjhagalo omayelana nokuphasiswa kwemiThetho yePasa ebafazini ngesikhathi somBuso weBandlululo. Umthetho lo wawutlanyelwe ukugandelela abomma bona bangakghoni ukuzenzela kodwana babe ngaphasi kwamadodabo. Yeke abomma abangaba zii-20 000 bamatjha batjhinga e-''Union Building'' ePitori bona bafake isinghonghoyilo esiphikisana nomThetho i-''Population Registration Act'' bona nabazokukhamba eSewula Afrika kufuze bahlale baphethe ipasa.&lt;ref name=&quot;:0&quot;&gt;South African Government (9 August 2025) ''Women's Day 2025.'' Retrieved From: https://www.gov.za/WomensDay2025. Retrieved on 25/08/2025.&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;South African History (2 August 2012) ''South Africa celebrates the first National Women’s Day.'' Retrieved From: https://sahistory.org.za/dated-event/south-africa-celebrates-first-national-womens-day. Retrieved on 25/08/2025.&lt;/ref&gt; 

ILanga laboMma aligidingi isenzakalweso kwaphela, kodwana ligidinga nezinye izenzakalo lapho kunabomma ababa mavulandlela kilenarha yeSewula Afrika kusukela ngo-1913, lokha abomma abanjengo-Charlotte Maxeke basungula iLigi yaboMma (''Womens League'') ehlanganweni ye-ANC ekhuthaza abomma bona bazibandakanye ekulweleni ithaphuluko. Amavulandlela la ahlanganisa nabo-Cissy, u-Jaynab noAmina Gool, ebebaphakathi kwabadosiphambili be-''National Liberation League'' nebe-''Non-European United Front'' yangabo-1930. Ngikho nje inyanga kaRhoboyi yoke nje kuyinyanga ekhethelwe ukugidinga abomma boke beSewula Afrika nokugidinga labo abadlale indima ekulwelweni kwamalungelo wobuntu.&lt;ref name=&quot;:0&quot; /&gt;

== Ukusungulwa KweLanga LaboMma&lt;ref name=&quot;:1&quot; /&gt; ==
ILanga laboMma lagidingwa kokuthoma ngomhla ka-9 kuRhuboyi 1994 ngesikhathi iSewula Afrika iba yiriphabliki yedemokhrasi. Umhla ka-9 kaRhoboyi wamenyezelwa bona uzokuba yiholideyi lapha amaSewula Afrika azokuhlonipha khona abomma ababa nesibindi sokujamelana nemithetho ebandlulula ngokobulili ebeyikhandela ukutjhaphuluka nokulingana. Kusukela ngeLanga laboMma lokuthoma isikhundla sabomma emphakathini sithuthuke khulu. Ngokwesibonelo, ngo-1994, abomma bebakha isibalo esimaphesenthe amathathu epalamende yeSewula Afrika, kodwana namhlanjesi sele bamaphesente ama-40.</text>
      <sha1>9to27lv6cag5jjkt4ko5541zmujc2az</sha1>
    </revision>
    <revision>
      <id>5233</id>
      <parentid>5232</parentid>
      <timestamp>2025-08-25T14:02:40Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>edited</comment>
      <origin>5233</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5206" sha1="b250e83u4pc61affga3kjt2pp6kb0pl" xml:space="preserve">== Draft Space 1 ==

== ILanga LaboMma ==
[[Isimumathi:Women of Ndebele village, Mpumalanga, South Africa (20489604056).jpg|thumb|380x380px|Abomma bamaNdebele]]
'''ILanga laboMma''' lilanga eligidingwa qobe mnyaka eSewula Afrika ngomhla ka-9 kuRhoboyi. Ilangeli lasungulwa ngomnyaka wango-1956 lokha abomma abanzima babamba umtjhagalo omayelana nokuphasiswa kwemiThetho yePasa ebafazini ngesikhathi somBuso weBandlululo. Umthetho lo wawutlanyelwe ukugandelela abomma bona bangakghoni ukuzenzela kodwana babe ngaphasi kwamadodabo. Yeke abomma abangaba zii-20 000 bamatjha batjhinga e-''Union Building'' ePitori bona bafake isinghonghoyilo esiphikisana nomThetho i-''Population Registration Act'' bona nabazokukhamba eSewula Afrika kufuze bahlale baphethe ipasa.&lt;ref name=&quot;:0&quot;&gt;South African Government (9 August 2025) ''Women's Day 2025.'' Retrieved From: https://www.gov.za/WomensDay2025. Retrieved on 25/08/2025.&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;South African History (2 August 2012) ''South Africa celebrates the first National Women’s Day.'' Retrieved From: https://sahistory.org.za/dated-event/south-africa-celebrates-first-national-womens-day. Retrieved on 25/08/2025.&lt;/ref&gt; 

ILanga laboMma aligidingi isenzakalweso kwaphela, kodwana ligidinga nezinye izenzakalo lapho kunabomma ababa mavulandlela kilenarha yeSewula Afrika kusukela ngo-1913, lokha abomma abanjengo-Charlotte Maxeke basungula iLigi yaboMma (''Womens League'') ehlanganweni ye-ANC ekhuthaza abomma bona bazibandakanye ekulweleni ithaphuluko. Amavulandlela la ahlanganisa nabo-Cissy, u-Jaynab noAmina Gool, ebebaphakathi kwabadosiphambili be-''National Liberation League'' nebe-''Non-European United Front'' yangabo-1930. Ngikho nje inyanga kaRhoboyi yoke nje kuyinyanga ekhethelwe ukugidinga abomma boke beSewula Afrika nokugidinga labo abadlale indima ekulwelweni kwamalungelo wobuntu.&lt;ref name=&quot;:0&quot; /&gt;

== Ukusungulwa KweLanga LaboMma&lt;ref name=&quot;:1&quot; /&gt; ==
ILanga laboMma lagidingwa kokuthoma ngomhla ka-9 kuRhuboyi 1994 ngesikhathi iSewula Afrika iba yiriphabliki yedemokhrasi. Umhla ka-9 kaRhoboyi wamenyezelwa bona uzokuba yiholideyi lapha amaSewula Afrika azokuhlonipha khona abomma ababa nesibindi sokujamelana nemithetho ebandlulula ngokobulili ebeyikhandela ukutjhaphuluka nokulingana. Kusukela ngeLanga laboMma lokuthoma isikhundla sabomma emphakathini sithuthuke khulu. Ngokwesibonelo, ngo-1994, abomma bebakha isibalo esimaphesenthe amathathu epalamende yeSewula Afrika, kodwana namhlanjesi sele bamaphesente ama-40.&lt;ref&gt;Bankmed (2025) ''Women's Month - you strike a woman you strike a rock.'' Retrieved From: https://www.bankmed.co.za/portal/individual/bankmed-article-womens-day. Retrieved on 25/08/2025.&lt;/ref&gt;

== Umtjhagalo Wabomma Wango-1956 ==
[[Isimumathi:Mandela burn pass 1960.jpg|thumb|311x311px|UNelson Mandela atjhisa ipasakhe ]]
Umnqopho omkhulu womBuso weBandlululo bekukuhlukanisa abantu ngokobutjhaba khona uzokukghona ukubalawula kuhle. Lokho bekwenzelwe bona abantu abanzima basebenze emakhuweni wendaweni yemakhabo. Kodwana amadlelo alihlaza besele atholakala ngaphandle kwendawo ababelwe kiyo, yeke abantu abanzima besele batholakala eendaweni ezingaphandle kwalezo abahlala kizo. Ngikho nje umBuso weBandlululo weza nehlelo lokuthi nangabe umuntu uzokuya namkha asebenze andaweni yangaphandle kweyekhabo kufuze uthole imvumo. Woke umuntu ofuna ukusuka lapha ahlala khona aye kenye indawo ngananyana ngiliphi ibanga bekufuze aphathe ipasa. Yeke imithetho le yathoma ngokusebenza khulukhulu emadodeni. UmBuso wabeka imithetho emayelana nalokho.&lt;ref name=&quot;:2&quot;&gt;Ntsoxeko Maluleke (6 March 2023) ''Discovery: the 'dompas' – A young person’s perspective,'' Nelson Mandela Foundation website''.'' Retrieved from: https://www.nelsonmandela.org/news/entry/discovery-the-dompas-a-young-persons-perspective. Retrieved on 25/08/2025.&lt;/ref&gt;&lt;ref name=&quot;:3&quot;&gt;O' Malley (2025) ''1923. Native Urban Areas Act No 21.'' Retrieved from: https://omalley.nelsonmandela.org/index.php/site/q/03lv01538/04lv01646/05lv01758.htm. Retrieved on 25/08/2025.&lt;/ref&gt;
UmThetho i-'''''Natives (Urban Areas) Act''''' wango-1923 bewuthi woke umuntu onzima oyindoda otholakala eendaweni zabamhlophe kufuze aphathe ipasa ngaso soke isikhathi. Nanyana ngubani ozokutholakala angakaphathi ipasa uzokubotjhwa athunyelwe ethrestini lekhabo.&lt;ref name=&quot;:3&quot; /&gt; Ngo-1955 urhulumende webandlululo waqunta bona amapasa bekungakafuzi aphathwe madoda kwaphela, kodwana nananyana ngimuphi umfazi ongaphezu kweminyaka eli-16 kufuze aphathe ipasa nakaya eendaweni ezihlala abamhlophe. Lokho kwabatshwenya khulu abafazi ngombana bebayibona indlela umthetho wepasa obathinta ngayo amadoda abaphila nawo. Kwezinye iikhathi bekungibo abafazi abezako bazokukhupha amadoda ejele ababanjwe ngombana bakhohlwe amapasa ekhaya.&lt;ref name=&quot;:2&quot; /&gt; 

Lokho ngikho okwenza abomma abangaphasi kwehlangano i-''Federation of South African Women (FSAW)'' bathathe igadango lokutjhagala. Ngomhla ka-9 kuRhoboyi 1956 abomma abazii-20 000 bamatjhela e-Union Building ePitori ngesinghonghoyilo sokuthi awuphele umthetho wamapasa. Kodwana kwafana nokuthela amanzi emhlana wedada. Ngikho nje ilangeli ligidingwa eSewula Afrika yoke ngoRhoboyi iNyanga yaboMma.&lt;ref name=&quot;:2&quot; /&gt;

== Iinkhombo ==</text>
      <sha1>b250e83u4pc61affga3kjt2pp6kb0pl</sha1>
    </revision>
    <revision>
      <id>5951</id>
      <parentid>5233</parentid>
      <timestamp>2025-11-06T10:25:54Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>Replaced content with &quot;== Draft Space 1 ==&quot;</comment>
      <origin>5951</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="19" sha1="18n7y18ghorstdggo7ek5hyav8bgmj6" xml:space="preserve">== Draft Space 1 ==</text>
      <sha1>18n7y18ghorstdggo7ek5hyav8bgmj6</sha1>
    </revision>
    <revision>
      <id>6122</id>
      <parentid>5951</parentid>
      <timestamp>2026-01-12T20:53:58Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>New article</comment>
      <origin>6122</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8770" sha1="fi4zptt1j8nmvlxick5h1llli0o8i5n" xml:space="preserve">== Draft Space 1 ==

== Ukufika KwamaBhuru ESewula Afrika ==
'''AmaDatjhi''' (ngokhamba kwesikhathi abizwa ngamaBhuru) afika esewula ne-Afrika, eKapa, ngomhla we-6 kuSihlabantangana 1652. Bafika bakhamba ngemikhumbi emihlanu badoswa phambili ngu-Jan van Riebeeck. Isizathu esenza amaDatjhi azithole aseKapa yindaba yezerhwebo. Abantwaba  bebangaphasi kwekhamphani ebizwa bona yi-''Dutch East India Company'' (V''ereenigde Oost-Indische Compagnie'' ''-'' VOC).&lt;ref name=&quot;:0&quot;&gt;South African History Online (13 January 2024) ''The Dutch Settlement.'' Retrieved from: https://sahistory.org.za/article/dutch-settlement Retrieved on 01/01/2026.&lt;/ref&gt;
[[Isimumathi:Flag of the Dutch East India Company.svg|thumb|260x260px|Iflarha le-VOC (Dutch East India Company)]]
Ikhamphani le beyithatha ipahla, ikhambe amalwandle ngemikhumbi, iyoyithengisa eNdiya. Yeke ngebanga lokubalekela iingebengu zelwandle bebazomba inarhakazi yoke ye-Afrika. Kodwana ibangeli belilide khulu, begodu imikhumbi beyiphelelwa kukudla isesendleleni. Yeke bekufuze kube nendawo lapha bangajama khona baphumule bathole nokudla okuzobafikisa eNdiya, iinthelo, imirorho, namanzi ahlanzekileko ebekutholakala budisi kezinye iindawo. IKapa yaba ngileyondawo, ngikho nje beyibizwa bona yi-Cape of Good Hope.

U-Jan Van Riebeek wabona indawo le asendleleni ebuyela emva eHolland, avela eJapani, njengombana bekathengisela i-VOC iinkhumba. Wathi nakehla emkhunjini eKapa, wabona indawo le ingaba yihle khulu bona imikhumbi ye-VOC ingaphumulela khona bese iraga nekhambo layo itjhinge eNdiya.

== U-Jan Van Riebeeck - 1647 ==
[[Isimumathi:Jan van Riebeeck cropped.jpg|thumb|U-Jan Van Riebeeck]]
Kuhlekuhle bekungasikokuthoma amaDatjhi afika ngo-1652. Bakhe bafika okokuthoma ngenyanga kaNtaka ngo-1647 bakhamba ngomkhumbi obizwa bona yi-Nieuwe Haarlem. Umkhumbi lo wafika waphahlazeka eKapa. Abasinda emkhunjini lowo bafika bakha indawo abayibiza bona yi-''Sand Fort of the Cape of Good Hope.'' Bahlala lapho pheze umnyaka woke. Ekugcineni kwafika imikhumbili eli-12 ebeyidoswa phambili ngu-W.G de Jong. Komunye wemikhumbi le bekunendoda ebizwa bona ngu-Jan Van Riebeeck.&lt;ref name=&quot;:1&quot;&gt;Marco Ramerini, English text by Dietrich Köster (January, 11 2014), ''The Dutch in South Africa, 1652-1795 and 1802-1806.'' Retrieved from https://www.colonialvoyage.com/dutch-south-africa/. Retrieved on 03/01/2026.&lt;/ref&gt;&lt;ref name=&quot;:2&quot;&gt;South African History Online (17 October 2011), ''Jan van Riebeeck.'' Retrieved from: https://sahistory.org.za/people/jan-van-riebeeck. Retreived on 03/01/2026.&lt;/ref&gt;

UJan Van Riebeeck (U-''Johan Anthoniszoon &quot;Jan&quot; van Riebeeck'') wabelethwa ngomhla ka-21 kuSihlabantangana 1619 e-Culemborg, e-Netherlands abelethwa nguyise ungodorhodere ohlinzako. Wakhulela e-Schiedam, e-Netherlands where, kwathi ngomhla wama-28 kuNtaka 1649, watjhada u-''Maria de la Queillerie'', waba nabantwana ababunane naye.&lt;ref name=&quot;:2&quot; /&gt;

U-Jan van Riebeeck waba lilunga le-''Dutch East India Company'' (''Vereenigde Oost-Indische Compagnie'' -  VOC) ngo-1639 lapha athoma khona ukuba msizi kadorhodere ohlinzako ekhambeni labo lokuya e- Batavia (namhlanjesi eyaziwa nge-Jakarta) ngenyanga kaSihlabantangana 1639 bese batjhinga e-Nagasaki eJapani ngo-1643.&lt;ref name=&quot;:2&quot; /&gt;

Ngo-1645 u-Jan van Riebeeck wanikelwa isabelo sokuba mphathi wesitetjhi sokurhwebela se-VOC ebesise-Tongkin e-French Indochina (namhlanjesi eyaziwa nge-Vietnam). Wehliswa esikhundleneso ngebanga lokuthi besele azenzela irhwebo lakhe langeqadi, okuphula umthetho wekhamphani othi abaphathi akukafuzi bazenzele irhwebo ngeqadi ngepahla yekhamphani. Kwathi bona ehliswe esihlkhundleni, wazithola sele kufuze abuyele emva e-Netherlands. Ngikho-ke besele atholakala komnuye wemikhumbi eli-12 ebeyidoswa phambili ngu-W.G de Jong. Wafika e-''Table Bay'' hlanu kwe-''Cape of Good Hope'' wahlala khona amalanga ali-18. Lokho kwamnikela isikhathi sokuqalisisa indawo, nokucabanga bona angayisebenzisa njani ekwenzeni bona i-VOC imthembe godu. Wayibona iyindawo enganikela ngokudla namanzi kabakhamba ngemikhumbi.&lt;ref name=&quot;:2&quot; /&gt;

Njengombana umkhumbi i-''Nieuwe Haerlem'' waphahlazeka ngo-1647, abasindileko bakha indawo lapho, u-Jan Van Riebeeck walemuka indlela ebebarhwebelana ngayo namaKhoikhoi njengombana balinde ukutakulwa. Ngemva kwalokho-ke watlola umbiko ngendawo le nangakho koke akubonileko, bewahlongoza bona indawo le ingaba yindawo ehle khulu i-VOC engayisebenzisa. Umbiko lo watlolwa ngo-1648 wathunyelwa ekhamphanini. Kwathi ngo-1651 i-VOC yathatha isiqunto sokuthi indawo ye-''Cape of Good Hope'' ayisetjenziselwe iminqopho yekhamphani.&lt;ref name=&quot;:2&quot; /&gt;

I-VOC yakhetha yena u-Jan van Riebeeck bona kube nguye umdosiphambili ozokuhloma isitetjhi sokuphumula semikhumbi yamaDatjhi khona izokuthola ukudla okutjha okunepilo namanzi ahlanzekileko. Kwaba kusuka kwakhe-ke u-Jan Van Riebeek, asuka e-Texel, e-Netherlands ngomhla wama-24 kuNobayeni 1651 bewayokufika e-''Table Bay'' ngomhla wesi-6 kaSihlabantangana 1652.&lt;ref name=&quot;:2&quot; /&gt; Bafika bakhamba ngemikhumbi emithathu - i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch''.”&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;

== Ukufika KwamaDatjhi  - 1652 ==
[[Isimumathi:VOC ship Phenix.jpg|thumb|Imikhumbi yamaDatjhi ifika eKapa]]
U-Jan Van Riebeeck wasuka ngomhla wama-24 kuNobayeni 1651 e-Texel, e-Netherlands, wafika ngomhla wesi-6 kaSihlabantangana 1652.&lt;ref name=&quot;:2&quot; /&gt; Bafika bakhamba ngemikhumbi emithathu - i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;'' Ekufikeni kwakhe nabantu ebekakhamba nabo ngemikhumbi le wafika wakha indawo yobuphephelo ebizwa bona yi-''Fort de Goede Hoop (Fort of Good Hope).'' Bafika batjala endaweni leyo, kodwana iintjalo zabo khenge zitlhurhe kuhle, mhlamunye ngebanga lobujamo bezulu obungafani nobe-Netherlands, netjharagano ebeliphakathi kwamadoda ebekakhamba nawo nakufuze basebenze batlhgomele imikhumbu edlulako. Abantu bebabancani umsebenzi umnengi.&lt;ref name=&quot;:2&quot; /&gt;

Kwathi ngo-1655 u-van Riebeeck wabika bona ngaphandle kwabantu abazimiseleko ukusebenza emasimini, isitetjhesi sizokubhalelwa ukwenza umsebenzi esihloselwe wona. Kwathi ngo-1657, i-VOC yathumela abalimi ababhadelwako, ngombandela wokuthi abalime inarha bebathengisele ikhamphani iintjalo abazilimileko. Ngibo laba ebebizwa bona ma-''free burghers''. U-Jan van Riebeeck wathatha isikhathi sakhe soke atjala bekakhiqiza amagrepsi, ama-apula namazambana azokuba lisizo khulu emikhumbini edlulako. Kwathi ngo-1659 besele anesivuno samagrepsi ebesikhiqiza iwayini elibovu elilwisana nobulwele be-''scurvy,'' njengombana besele alemukile bona ukusela iwayini kuyabuvikela ubulwelobu ngokwezinga elithileko.&lt;ref name=&quot;:2&quot; /&gt;

== Ama-Khoikhoi - 1654 ==
Ukuthoma kokufika kwamaDatjhi eKapa (''Cape of Good Hope'') khenge kuwamangaze abantu bendabuko bendawo leyo ama-Khoikhoi ngombana besele kukade ama-Khoi arhwebelana nemikhumbi endaweni leyo. AmaDatjhi afika nje ama-Khoikhoi besele kukade arhwebelana namaPutukezi namaNgisi. Nangaphezu kokufika kuka-van Riebeeck, ngokuya kuka-Knox‑Johnson, phakathi nomnyaka wabo-1600 kuya ku-1700, besele kudlule imikhumbi yamaDatjhi eziyi-1 730. Yeke amaKhoikhoi bekangawaqabuki amaDatjhi ngesikhatheso.&lt;ref&gt;Helen Swingler (22 September 2021) ''Heritage Month: The Khoi encountered Europeans long before Van Riebeeck,'' University of Cape Town News. Retrieved from: https://www.news.uct.ac.za/article/-2021-09-22-the-khoi-encountered-europeans-long-before-van-riebeeck. Retrieved on 12/01/2026.&lt;/ref&gt;
[[Isimumathi:Khoikhoi Hottentot p197.jpg|thumb|Ama-Khoikhoi]]
Esikhathini sokufika kwamaDatjhi bekunendoda ebizwa bona ngu-Autshumao, amaDatjhi ebebambiza bona ngu-''Harry''. U-Autshumao bekayikosi yesitjhaba samaKhoikhoi. Isitetjhana sokurhwebelana nabantu bemikhumbi sathonywa nguye. Ngo-1630 wathathwa maNgisi esitjhabeni sekhabo bona ambandulele bona kube nguye okghona ukukhulumisana nabanye ngendaba yezokurhwebelana. Yeke amaNgisi amthatha amusa e-Java wafika wabandulwa, wathi nakabuya eKapa bamthatha bamusa e-Robben Island yena nabalandeli bakhe. Bekuthi imikhumbi nayifikako ambathe iimpahla zamaYurobhu akhulumisane nabokapteni bemikhumbi, akhulume isiNgisi nesiFrentji. Bambiza bona yi-''Governor.''&lt;ref&gt;Camissa Museum (2026) ''Autshumao (1610 - 1674)'', Retrieved from: https://camissamuseum.co.za/index.php/7-tributaries/1-cape-indigenous-africans/autshumao. Retrieved on 12/01/2026.&lt;/ref&gt;

Kwathi ngo-1638, u-Autshumao nomphakathi wekhabo ebewunabantu abangaba ma-60, babuya esihlengehlengeni beza enarheni eKapa, lapha kuhlangana khona umlambo i-''Camissa River'' nelwandle. Yena nomndenakhe ngibo ebebaphethe isitetjhi sokurhwebelana i-‖Ammaqua (okutjho Abantu bemanzini) okulibizo u-Jan van Riebeeck ebekababiza ngalo.</text>
      <sha1>fi4zptt1j8nmvlxick5h1llli0o8i5n</sha1>
    </revision>
    <revision>
      <id>6124</id>
      <parentid>6122</parentid>
      <timestamp>2026-01-14T15:48:26Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>edited</comment>
      <origin>6124</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="11313" sha1="ta0ojwl7z8yhz7dob01mle1xlzciibu" xml:space="preserve">== Draft Space 1 ==

== Ukufika KwamaBhuru ESewula Afrika ==
[[Isimumathi:Flag of the Dutch East India Company.svg|thumb|260x260px|Iflarha le-VOC (Dutch East India Company)]]
'''AmaDatjhi''' (ngokhamba kwesikhathi abizwa ngamaBhuru) afika esewula ne-Afrika, eKapa, ngomhla we-6 kuSihlabantangana 1652. Bafika bakhamba ngemikhumbi emihlanu badoswa phambili ngu-Jan van Riebeeck. Isizathu esenza amaDatjhi azithole aseKapa yindaba yezerhwebo. Abantwaba  bebangaphasi kwekhamphani ebizwa bona yi-''Dutch East India Company'' (V''ereenigde Oost-Indische Compagnie'' ''-'' VOC).&lt;ref name=&quot;:0&quot;&gt;South African History Online (13 January 2024) ''The Dutch Settlement.'' Retrieved from: https://sahistory.org.za/article/dutch-settlement Retrieved on 01/01/2026.&lt;/ref&gt;

Ikhamphani le beyithatha ipahla, ikhambe amalwandle ngemikhumbi, iyoyithengisa eNdiya. Yeke ngebanga lokubalekela iingebengu zelwandle bebazomba inarhakazi yoke ye-Afrika. Kodwana ibangeli belilide khulu, begodu imikhumbi beyiphelelwa kukudla isesendleleni. Yeke bekufuze kube nendawo lapha bangajama khona baphumule bathole nokudla okuzobafikisa eNdiya, iinthelo, imirorho, namanzi ahlanzekileko ebekutholakala budisi kezinye iindawo. IKapa yaba ngileyondawo, ngikho nje beyibizwa bona yi-Cape of Good Hope.

U-Jan Van Riebeek wabona indawo le asendleleni ebuyela emva eHolland, avela eJapani, njengombana bekathengisela i-VOC iinkhumba. Wathi nakehla emkhunjini eKapa, wabona indawo le ingaba yihle khulu bona imikhumbi ye-VOC ingaphumulela khona bese iraga nekhambo layo itjhinge eNdiya.

== U-Jan Van Riebeeck - 1647 ==
[[Isimumathi:Jan van Riebeeck cropped.jpg|thumb|U-Jan Van Riebeeck]]
Kuhlekuhle bekungasikokuthoma amaDatjhi afika ngo-1652. Bakhe bafika okokuthoma ngenyanga kaNtaka ngo-1647 bakhamba ngomkhumbi obizwa bona yi-Nieuwe Haarlem. Umkhumbi lo wafika waphahlazeka eKapa. Abasinda emkhunjini lowo bafika bakha indawo abayibiza bona yi-''Sand Fort of the Cape of Good Hope.'' Bahlala lapho pheze umnyaka woke. Ekugcineni kwafika imikhumbili eli-12 ebeyidoswa phambili ngu-W.G de Jong. Komunye wemikhumbi le bekunendoda ebizwa bona ngu-Jan Van Riebeeck.&lt;ref name=&quot;:1&quot;&gt;Marco Ramerini, English text by Dietrich Köster (January, 11 2014), ''The Dutch in South Africa, 1652-1795 and 1802-1806.'' Retrieved from https://www.colonialvoyage.com/dutch-south-africa/. Retrieved on 03/01/2026.&lt;/ref&gt;&lt;ref name=&quot;:2&quot;&gt;South African History Online (17 October 2011), ''Jan van Riebeeck.'' Retrieved from: https://sahistory.org.za/people/jan-van-riebeeck. Retreived on 03/01/2026.&lt;/ref&gt;

UJan Van Riebeeck (U-''Johan Anthoniszoon &quot;Jan&quot; van Riebeeck'') wabelethwa ngomhla ka-21 kuSihlabantangana 1619 e-Culemborg, e-Netherlands abelethwa nguyise ungodorhodere ohlinzako. Wakhulela e-Schiedam, e-Netherlands where, kwathi ngomhla wama-28 kuNtaka 1649, watjhada u-''Maria de la Queillerie'', waba nabantwana ababunane naye.&lt;ref name=&quot;:2&quot; /&gt;

U-Jan van Riebeeck waba lilunga le-''Dutch East India Company'' (''Vereenigde Oost-Indische Compagnie'' -  VOC) ngo-1639 lapha athoma khona ukuba msizi kadorhodere ohlinzako ekhambeni labo lokuya e- Batavia (namhlanjesi eyaziwa nge-Jakarta) ngenyanga kaSihlabantangana 1639 bese batjhinga e-Nagasaki eJapani ngo-1643.&lt;ref name=&quot;:2&quot; /&gt;

Ngo-1645 u-Jan van Riebeeck wanikelwa isabelo sokuba mphathi wesitetjhi sokurhwebela se-VOC ebesise-Tongkin e-French Indochina (namhlanjesi eyaziwa nge-Vietnam). Wehliswa esikhundleneso ngebanga lokuthi besele azenzela irhwebo lakhe langeqadi, okuphula umthetho wekhamphani othi abaphathi akukafuzi bazenzele irhwebo ngeqadi ngepahla yekhamphani. Kwathi bona ehliswe esihlkhundleni, wazithola sele kufuze abuyele emva e-Netherlands. Ngikho-ke besele atholakala komnuye wemikhumbi eli-12 ebeyidoswa phambili ngu-W.G de Jong. Wafika e-''Table Bay'' hlanu kwe-''Cape of Good Hope'' wahlala khona amalanga ali-18. Lokho kwamnikela isikhathi sokuqalisisa indawo, nokucabanga bona angayisebenzisa njani ekwenzeni bona i-VOC imthembe godu. Wayibona iyindawo enganikela ngokudla namanzi kabakhamba ngemikhumbi.&lt;ref name=&quot;:2&quot; /&gt;

Njengombana umkhumbi i-''Nieuwe Haerlem'' waphahlazeka ngo-1647, abasindileko bakha indawo lapho, u-Jan Van Riebeeck walemuka indlela ebebarhwebelana ngayo namaKhoikhoi njengombana balinde ukutakulwa. Ngemva kwalokho-ke watlola umbiko ngendawo le nangakho koke akubonileko, bewahlongoza bona indawo le ingaba yindawo ehle khulu i-VOC engayisebenzisa. Umbiko lo watlolwa ngo-1648 wathunyelwa ekhamphanini. Kwathi ngo-1651 i-VOC yathatha isiqunto sokuthi indawo ye-''Cape of Good Hope'' ayisetjenziselwe iminqopho yekhamphani.&lt;ref name=&quot;:2&quot; /&gt;

I-VOC yakhetha yena u-Jan van Riebeeck bona kube nguye umdosiphambili ozokuhloma isitetjhi sokuphumula semikhumbi yamaDatjhi khona izokuthola ukudla okutjha okunepilo namanzi ahlanzekileko. Kwaba kusuka kwakhe-ke u-Jan Van Riebeek, asuka e-Texel, e-Netherlands ngomhla wama-24 kuNobayeni 1651 bewayokufika e-''Table Bay'' ngomhla wesi-6 kaSihlabantangana 1652.&lt;ref name=&quot;:2&quot; /&gt; Bafika bakhamba ngemikhumbi emithathu - i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch''.”&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;

== Ukufika KwamaDatjhi  - 1652 ==
[[Isimumathi:VOC ship Phenix.jpg|thumb|Imikhumbi yamaDatjhi ifika eKapa]]
U-Jan Van Riebeeck wasuka ngomhla wama-24 kuNobayeni 1651 e-Texel, e-Netherlands, wafika ngomhla wesi-6 kaSihlabantangana 1652.&lt;ref name=&quot;:2&quot; /&gt; Bafika bakhamba ngemikhumbi emithathu - i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;'' Ekufikeni kwakhe nabantu ebekakhamba nabo ngemikhumbi le wafika wakha indawo yobuphephelo ebizwa bona yi-''Fort de Goede Hoop (Fort of Good Hope).'' Bafika batjala endaweni leyo, kodwana iintjalo zabo khenge zitlhurhe kuhle, mhlamunye ngebanga lobujamo bezulu obungafani nobe-Netherlands, netjharagano ebeliphakathi kwamadoda ebekakhamba nawo nakufuze basebenze batlhgomele imikhumbu edlulako. Abantu bebabancani umsebenzi umnengi.&lt;ref name=&quot;:2&quot; /&gt;

Kwathi ngo-1655 u-van Riebeeck wabika bona ngaphandle kwabantu abazimiseleko ukusebenza emasimini, isitetjhesi sizokubhalelwa ukwenza umsebenzi esihloselwe wona. Kwathi ngo-1657, i-VOC yathumela abalimi ababhadelwako, ngombandela wokuthi abalime inarha bebathengisele ikhamphani iintjalo abazilimileko. Ngibo laba ebebizwa bona ma-''free burghers''. U-Jan van Riebeeck wathatha isikhathi sakhe soke atjala bekakhiqiza amagrepsi, ama-apula namazambana azokuba lisizo khulu emikhumbini edlulako. Kwathi ngo-1659 besele anesivuno samagrepsi ebesikhiqiza iwayini elibovu elilwisana nobulwele be-''scurvy,'' njengombana besele alemukile bona ukusela iwayini kuyabuvikela ubulwelobu ngokwezinga elithileko.&lt;ref name=&quot;:2&quot; /&gt;

== Ama-Khoikhoi - 1654 ==
Ukuthoma kokufika kwamaDatjhi eKapa (''Cape of Good Hope'') khenge kuwamangaze abantu bendabuko bendawo leyo ama-Khoikhoi ngombana besele kukade ama-Khoi arhwebelana nemikhumbi endaweni leyo. AmaDatjhi afika nje ama-Khoikhoi besele kukade arhwebelana namaPutukezi namaNgisi. Nangaphezu kokufika kuka-van Riebeeck, ngokuya kuka-Knox‑Johnson, phakathi nomnyaka wabo-1600 kuya ku-1700, besele kudlule imikhumbi yamaDatjhi eziyi-1 730. Yeke amaKhoikhoi bekangawaqabuki amaDatjhi ngesikhatheso.&lt;ref&gt;Helen Swingler (22 September 2021) ''Heritage Month: The Khoi encountered Europeans long before Van Riebeeck,'' University of Cape Town News. Retrieved from: https://www.news.uct.ac.za/article/-2021-09-22-the-khoi-encountered-europeans-long-before-van-riebeeck. Retrieved on 12/01/2026.&lt;/ref&gt;
[[Isimumathi:Khoikhoi Hottentot p197.jpg|thumb|Ama-Khoikhoi]]
Esikhathini sokufika kwamaDatjhi bekunendoda ebizwa bona ngu-Autshumato, namkha u-Autshumao, amaDatjhi ebebambiza bona ngu-''Harry die Strandloper''. U-Autshumao bekayikosi yesitjhaba samaKhoikhoi ebesibizwa bona ma-''Gorinhaikona''. Isitetjhana sokurhwebelana nabantu bemikhumbi sathonywa nguye.&lt;ref name=&quot;:3&quot;&gt;Roben Island Museum (13 May 2017) ''Autshumato''. Retrieved from: http://www.robben-island.org.za/departments/heritage/gallery/autshumato.asp. Retrieved on 14/01/2026.&lt;/ref&gt; Ngo-1630 wathathwa maNgisi esitjhabeni sekhabo bona ambandulele bona kube nguye okghona ukukhulumisana nabanye ngendaba yezokurhwebelana. Yeke amaNgisi amthatha amusa e-Java eNgilandi, wafika wafundiswa isiNgisi, isiDatjhi nesiFrentji nesiPutukezi. Wathi nakabuya eKapa bamthatha bamusa e-Robben Island yena nabalandeli bakhe. Bekuthi imikhumbi nayifikako ambathe iimpahla zamaYurobhu akhulumisane nabokapteni bemikhumbi, akhulume isiNgisi nesiFrentji. Bambiza bona yi-''Governor.''&lt;ref name=&quot;:4&quot;&gt;Camissa Museum (2026) ''Autshumao (1610 - 1674)'', Retrieved from: https://camissamuseum.co.za/index.php/7-tributaries/1-cape-indigenous-africans/autshumao. Retrieved on 12/01/2026.&lt;/ref&gt;

Kwathi ngo-1638, u-Autshumao nomphakathi wekhabo ebewunabantu abangaba ma-60, babuya esihlengehlengeni beza enarheni eKapa, lapha kuhlangana khona umlambo i-''Camissa River'' nelwandle. Yena nomndenakhe ngibo ebebaphethe isitetjhi sokurhwebelana i-‖Ammaqua (okutjho Abantu bemanzini) okulibizo u-Jan van Riebeeck ebekababiza ngalo.&lt;ref name=&quot;:3&quot; /&gt;&lt;ref name=&quot;:4&quot; /&gt;

Ngesikhathi amaDatjhi afika, umuntu wokuthoma ukubamukela bekungu-Autshumao nabantu bakhe. ngikho nje amaDatjhi ambiza ngokuthi yi-''Strandloper'' ngombana babathola eligwini lelwandle. Kusukela bathoma ukubonana bathoma ukurhwebelana. Zoke izinto ebezenzeka u-Jan van Riebeeck wazitlola emajenalini wakhe. AmaDatjhi bebathenga iinkomo nezimvu kuma-Khoikhoi ngepahla ehlukahlukeneko kuhlanganise notjwala negwayi. Bese inyama yefuyo le idliwe, enye ethengiselwe abantu abadlula ngemikhumbi yekhamphani.&lt;ref name=&quot;:5&quot;&gt;Steemit Website (2018) ''SOUTH AFRICAN HISTORY: Autshumato translator and first Postmaster of The Cape of Good Hope''. Retrieved from: https://steemit.com/history/@krabgat/south-african-history-autshumato-translator-and-first-postmaster-of-the-cape-of-good-hope. Retrieved on 14/01/2026.&lt;/ref&gt; 

Kwathi ngenyanga kaSewula wango-1653 kwaba nokurhitjhana phakathi kuka-Autshumato nomelusi weenkomo zika-Van Riebeeck u-David Jansz. U-Autshumato wambulala wathatha iinkomo. Ukurhitjhanoku kuthoma nje iintjhaba ezimbili lezi besele zingasathelelani kuhle amanzi. AmaDatjhi besele baqala u-Autshumato nabantu bakhe njengamasela. U-Jan Van Riebeek wathi u-Autshumato lisela elinelimi elibutjhelelezi. AmaKhoikhoi baqala amaDatjhi njengabakhohlisi ngokuthi intengo yotjwala negwayi ayilingani nentengo yesilwana esifuywako. Bebathi bangabusela utjwala buphele, babone ifuywabo emadlelweni wamaDatjhi. Bese amaKhoikhoi akhambe ayoyeba.&lt;ref&gt;Castle of Good Hope (''13th November 2018'') ''Interpreters' Flawed Contracts With Dutch''Retrieved from: https://www.castleofgoodhope.co.za/index.php/news/100-news/142-interpreters-flawed-contracts-with-dutch. Retrieved on 14/01/2026.&lt;/ref&gt; 

Isenzakalo sokubulawa kuka-David Jansz sasusa ipi phakathi kwama-Khoi namaDatjhi. U-Van RieBeeck wathi u-Autshumato unomlandu wokubulala. Yeke kwaliwa ipi, ekugcineni ama-Khoi ahlulwa. U-Atshumato wabanjwa wasiwa ekuthunjweni e-''Robben Island'' ngawo umnyaka ka-1653. Kodwana ngo-1655 waphunyurha yena nalabo ebekathunjwe nabo babuyela enarheni ngesikepe esinembobo.  Nakafikako u-Jan Van Riebeeck wamamukela wambuyisela esikhundleni sakhe sokutoliga.&lt;ref name=&quot;:5&quot; /&gt;

== Iinkhombo ==</text>
      <sha1>ta0ojwl7z8yhz7dob01mle1xlzciibu</sha1>
    </revision>
    <revision>
      <id>6125</id>
      <parentid>6124</parentid>
      <timestamp>2026-01-14T16:43:22Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>edited</comment>
      <origin>6125</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="11455" sha1="g9awbg904bc5sgkvpm8pauhwqcz9188" xml:space="preserve">== Draft Space 1 ==

== Ukufika KwamaBhuru ESewula Afrika ==
[[Isimumathi:Flag of the Dutch East India Company.svg|thumb|260x260px|Iflarha le-VOC (Dutch East India Company)]]
'''AmaDatjhi''' '''(ngokhamba kwesikhathi abizwa ngamaBhuru)''' afika esewula ne-Afrika, eKapa, ngomhla we-6 kuSihlabantangana 1652. Bafika bakhamba ngemikhumbi emihlanu badoswa phambili ngu-Jan Van Riebeeck. Isizathu esenza amaDatjhi azithole aseKapa yindaba yezerhwebo. Abantwaba  bebangaphasi kwekhamphani ebizwa bona yi-''Dutch East India Company'' (V''ereenigde Oost-Indische Compagnie'' ''-'' VOC).&lt;ref name=&quot;:0&quot;&gt;South African History Online (13 January 2024) ''The Dutch Settlement.'' Retrieved from: https://sahistory.org.za/article/dutch-settlement Retrieved on 01/01/2026.&lt;/ref&gt;

Ikhamphani le beyithatha ipahla, ikhambe amalwandle ngemikhumbi, iyoyithengisa eNdiya. Yeke ngebanga lokubalekela iingebengu zelwandle beyizomba inarhakazi yoke ye-Afrika. Kodwana ibangeli belilide khulu, begodu imikhumbi beyiphelelwa kukudla isendleleni. Yeke bekufuze kube nendawo lapha bangajama khona baphumule bathole nokudla okuzobafikisa eNdiya, iinthelo, imirorho, inyama namanzi ahlanzekileko ebekutholakala budisi kezinye iindawo. IKapa yaba ngileyondawo, ngikho nje beyibizwa bona yi-''Cape of Good Hope''.&lt;ref name=&quot;:2&quot; /&gt;

U-Jan Van Riebeeck wabona indawo le asendleleni ebuyela emva e-Holland, avela eJapani, njengombana bekathengisela i-VOC iinkhumba. Wathi nakehla emkhunjini eKapa, wabona indawo le ingaba yihle khulu bona imikhumbi ye-VOC ingaphumulela khona bese iraga nekhambo layo itjhinge eNdiya.&lt;ref name=&quot;:2&quot; /&gt;

== U-Jan Van Riebeeck - 1647 ==
[[Isimumathi:Jan van Riebeeck cropped.jpg|thumb|U-Jan Van Riebeeck]]
Kuhlekuhle bekungasikokuthoma amaDatjhi afika ngo-1652. Bakhe bafika okokuthoma ngenyanga kaNtaka ngo-1647 bakhamba ngomkhumbi obizwa bona yi-''Nieuwe Haarlem''. Umkhumbi lo wafika waphahlazeka eKapa. Abasinda emkhunjini lowo bafika bakha indawo abayibiza bona yi-''Sand Fort of the Cape of Good Hope.'' Bahlala lapho pheze umnyaka woke. Ekugcineni kwafika imikhumbi eli-12 ebeyidoswa phambili ngu-W.G de Jong. Komunye wemikhumbi le bekunendoda ebizwa bona ngu-Jan Van Riebeeck.&lt;ref name=&quot;:1&quot;&gt;Marco Ramerini, English text by Dietrich Köster (January, 11 2014), ''The Dutch in South Africa, 1652-1795 and 1802-1806.'' Retrieved from https://www.colonialvoyage.com/dutch-south-africa/. Retrieved on 03/01/2026.&lt;/ref&gt;&lt;ref name=&quot;:2&quot;&gt;South African History Online (17 October 2011), ''Jan van Riebeeck.'' Retrieved from: https://sahistory.org.za/people/jan-van-riebeeck. Retreived on 03/01/2026.&lt;/ref&gt;

UJan Van Riebeeck (U-''Johan Anthoniszoon &quot;Jan&quot; Van Riebeeck'') wabelethwa ngomhla ka-21 kuSihlabantangana 1619 e-Culemborg, e-Netherlands abelethwa nguyise ungodorhodere ohlinzako. Wakhulela e-Schiedam, e-Netherlands, kwathi ngomhla wama-28 kuNtaka 1649, watjhada u-''Maria de la Queillerie'', waba nabantwana ababunane naye.&lt;ref name=&quot;:2&quot; /&gt;

U-Jan Van Riebeeck waba lilunga le-''Dutch East India Company'' (''Vereenigde Oost-Indische Compagnie'' -  VOC) ngo-1639 lapha athoma khona ukuba msizi kadorhodere ohlinzako ekhambeni labo lokuya e-Batavia (namhlanjesi eyaziwa nge-Jakarta) ngenyanga kaSihlabantangana 1639 bese batjhinga e-Nagasaki eJapani ngo-1643.&lt;ref name=&quot;:2&quot; /&gt;

Ngo-1645 u-Jan Van Riebeeck wanikelwa isabelo sokuba mphathi wesitetjhi sokurhwebela se-VOC ebesise-Tongkin e-''French Indochina'' (namhlanjesi eyaziwa nge-Vietnam). Wehliswa esikhundleneso ngebanga lokuthi besele azenzela irhwebo lakhe langeqadi, okuphula umthetho wekhamphani othi abaphathi akukafuzi bazenzele irhwebo ngeqadi ngepahla yekhamphani. Kwathi bona ehliswe esikhundleni, wazithola sele kufuze abuyele emva e-Netherlands ayoqalana nemilandu yakhe. Ngikho-ke besele atholakala komunye wemikhumbi eli-12 ebeyidoswa phambili ngu-W.G de Jong. Wafika e-''Table Bay'' hlanu kwe-''Cape of Good Hope'' wahlala khona amalanga ali-18. Lokho kwamnikela isikhathi sokuqalisisa indawo, nokucabanga bona angayisebenzisa njani ekwenzeni bona i-VOC imthembe godu. Wayibona iyindawo enganikela ngokudla namanzi kabakhamba ngemikhumbi.&lt;ref name=&quot;:2&quot; /&gt;

Njengombana umkhumbi i-''Nieuwe Haerlem'' waphahlazeka ngo-1647, abasindileko bakha indawo lapho, u-Jan Van Riebeeck walemuka indlela ebebarhwebelana ngayo namaKhoikhoi njengombana balinde ukutakulwa. Ngemva kwalokho-ke watlola umbiko ngendawo le nangakho koke akubonileko, bewahlongoza bona indawo le ingaba yindawo ehle khulu i-VOC engayisebenzisa. Umbiko lo watlolwa ngo-1648 wathunyelwa ekhamphanini. Kwathi ngo-1651 i-VOC yathatha isiqunto sokuthi indawo ye-''Cape of Good Hope'' ayisetjenziselwe iminqopho yekhamphani.&lt;ref name=&quot;:2&quot; /&gt;

I-VOC yakhetha yena u-Jan Van Riebeeck bona kube nguye umdosiphambili ozokuhloma isitetjhi sokuphumula semikhumbi yamaDatjhi khona izokuthola ukudla okutjha okunepilo namanzi ahlanzekileko. Kwaba kusuka kwakhe-ke u-Jan Van Riebeeck, asuka e-Texel, e-Netherlands ngomhla wama-24 kuNobayeni 1651 bewayokufika e-''Table Bay'' ngomhla wesi-6 kaSihlabantangana 1652.&lt;ref name=&quot;:2&quot; /&gt; Bafika bakhamba ngemikhumbi emihlanu - i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch''.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;

== Ukufika KwamaDatjhi  - 1652 ==
[[Isimumathi:VOC ship Phenix.jpg|thumb|Imikhumbi yamaDatjhi ifika eKapa]]
U-Jan Van Riebeeck wasuka ngomhla wama-24 kuNobayeni 1651 e-Texel, e-Netherlands, wafika ngomhla wesi-6 kaSihlabantangana 1652.&lt;ref name=&quot;:2&quot; /&gt; Bafika bakhamba ngemikhumbi emihlanu - i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;'' Emithathu le ngiyo eyafika qangi, ngikho kwaziwa khulu le emithathu, le eminye imikhumbi emibili yafika mva. Ekufikeni kwakhe nabantu ebekakhamba nabo ngemikhumbi le wafika wakha indawo yobuphephelo ebizwa bona yi-''Fort de Goede Hoop (Fort of Good Hope).'' Bafika batjala endaweni leyo, kodwana iintjalo zabo khenge zitlhurhe kuhle, mhlamunye ngebanga lobujamo bezulu obungafani nobe-Netherlands, netjharagano ebeliphakathi kwamadoda ebekakhamba nawo nakufuze basebenze batlhgomele imikhumbu edlulako. Abantu bebabancani umsebenzi umnengi.&lt;ref name=&quot;:2&quot; /&gt;

Kwathi ngo-1655 u-Van Riebeeck wabika bona ngaphandle kwabantu abazimisele ukusebenza emasimini, isitetjhesi sizokubhalelwa ukwenza umsebenzi esihloselwe wona. Kwathi ngo-1657, i-VOC yathumela abalimi ababhadelwako, ngombandela wokuthi balime inarha bebathengisele ikhamphani iintjalo abazilimileko. Ngibo laba ebebabizwa bona ma-''free burghers''. U-Jan Van Riebeeck wathatha isikhathi sakhe soke atjala bekakhiqiza amagrepsi, ama-apula namazambana, ukudla okuzokuba lisizo khulu emikhumbini edlulako. Kwathi ngo-1659 besele anesivuno samagrepsi ebesikhiqiza iwayini elibovu elilwisana nobulwele be-''scurvy,'' njengombana besele alemukile bona ukusela iwayini kuyabuvikela ubulwelobu ngokwezinga elithileko.&lt;ref name=&quot;:2&quot; /&gt;

== Ama-Khoikhoi ==
Ukuthoma kokufika kwamaDatjhi eKapa (''Cape of Good Hope'') khenge kubamangaze abantu bendabuko bendawo leyo ama-Khoikhoi. AmaDatjhi afika nje ama-Khoikhoi besele kukade arhwebelana namaPutukezi namaNgisi. Nangaphezu kokufika kuka-Van Riebeeck, ngokuya kuka-Knox‑Johnson, phakathi nomnyaka wabo-1600 kuya ku-1700, besele kudlule imikhumbi yamaDatjhi eziyi-1 730. Yeke amaKhoikhoi bekangawaqabuki amaDatjhi ngesikhatheso.&lt;ref&gt;Helen Swingler (22 September 2021) ''Heritage Month: The Khoi encountered Europeans long before Van Riebeeck,'' University of Cape Town News. Retrieved from: https://www.news.uct.ac.za/article/-2021-09-22-the-khoi-encountered-europeans-long-before-van-riebeeck. Retrieved on 12/01/2026.&lt;/ref&gt;
[[Isimumathi:Khoikhoi Hottentot p197.jpg|thumb|Ama-Khoikhoi]]
Esikhathini sokufika kwamaDatjhi bekunendoda ebizwa bona ngu-Autshumato, namkha u-Autshumao, amaDatjhi ebebambiza bona ngu-''Harry die Strandloper''. U-Autshumao bekayikosi yesitjhaba samaKhoikhoi ebesibizwa bona ma-''Gorinhaikona''. Isitetjhana sokurhwebelana nabantu bemikhumbi sathonywa nguye.&lt;ref name=&quot;:3&quot;&gt;Roben Island Museum (13 May 2017) ''Autshumato''. Retrieved from: http://www.robben-island.org.za/departments/heritage/gallery/autshumato.asp. Retrieved on 14/01/2026.&lt;/ref&gt; Ngo-1630 wathathwa maNgisi esitjhabeni sekhabo bona ambandulele ukukhulumisana nabanye ngendaba yezokurhwebelana begodu atolige. Yeke amaNgisi amthatha amusa e-Java eNgilandi, wafika wafundiswa isiNgisi, isiDatjhi nesiFrentji nesiPutukezi. Wathi nakabuya eKapa bamthatha bamusa e-''Robben Island'' yena nabalandeli bakhe. Bekuthi imikhumbi nayifikako ambathe iimpahla zamaYurobhu akhulumisane nabokapteni bemikhumbi, akhulume isiNgisi nesiFrentji. Bambiza bona yi-''Governor.''&lt;ref name=&quot;:4&quot;&gt;Camissa Museum (2026) ''Autshumao (1610 - 1674)'', Retrieved from: https://camissamuseum.co.za/index.php/7-tributaries/1-cape-indigenous-africans/autshumao. Retrieved on 12/01/2026.&lt;/ref&gt;

Kwathi ngo-1638, u-Autshumao nomphakathi wekhabo ebewunabantu abangaba ma-60, babuya esihlengehlengeni beza enarheni eKapa, lapha kuhlangana khona umlambo i-''Camissa River'' nelwandle. Yena nomndenakhe ngibo ebebaphethe isitetjhi sokurhwebelana i-''‖Ammaqua'' (okutjho Abantu bemanzini) okulibizo u-Jan Van Riebeeck ebekababiza ngalo ekuthomeni.&lt;ref name=&quot;:3&quot; /&gt;&lt;ref name=&quot;:4&quot; /&gt;

Ngesikhathi amaDatjhi afika, umuntu wokuthoma ukubamukela bekungu-Autshumao nabantu bakhe. ngikho nje amaDatjhi bebababiza ngokuthi ma-''Strandloper'' ngombana babathola bakhamba eligwini lelwandle. Kusukela bathoma ukubonana bathoma ukurhwebelana. Zoke izinto ebezenzeka u-Jan Van Riebeeck wazitlola emajenalini wakhe. AmaDatjhi bewathenga iinkomo nezimvu kuma-Khoikhoi ngepahla ehlukahlukeneko kuhlanganise notjwala negwayi. Bese inyama yefuyo le idliwe, enye ethengiselwe abantu abadlula ngemikhumbi yekhamphani.&lt;ref name=&quot;:5&quot;&gt;Steemit Website (2018) ''SOUTH AFRICAN HISTORY: Autshumato translator and first Postmaster of The Cape of Good Hope''. Retrieved from: https://steemit.com/history/@krabgat/south-african-history-autshumato-translator-and-first-postmaster-of-the-cape-of-good-hope. Retrieved on 14/01/2026.&lt;/ref&gt; 

Kwathi ngenyanga kaSewula wango-1653 kwaba nokurhitjhana phakathi kuka-Autshumato nomelusi weenkomo zika-Van Riebeeck u-David Jansz. U-Autshumato wambulala wathatha iinkomo. Ukurhitjhanokhu kuthoma nje iintjhaba ezimbili lezi besele zingasathelelani kuhle amanzi. AmaDatjhi besele aqala u-Autshumato nabantu bakhe njengamasela. U-Jan Van Riebeeck wathi u-Autshumato lisela elinelimi elibutjhelelezi. AmaKhoikhoi aqala amaDatjhi njengabakhohlisi ngokuthi intengo yotjwala negwayi ayilingani nentengo yesilwana esifuywako. Bebathi bangabusela utjwala buphele, babone ifuywabo emadlelweni wamaDatjhi, yanda. Bese amaKhoikhoi akhambe ayoyeba.&lt;ref&gt;Castle of Good Hope (''13th November 2018'') ''Interpreters' Flawed Contracts With Dutch''Retrieved from: https://www.castleofgoodhope.co.za/index.php/news/100-news/142-interpreters-flawed-contracts-with-dutch. Retrieved on 14/01/2026.&lt;/ref&gt; 

Isenzakalo sokubulawa kuka-David Jansz sasusa ipi phakathi kwama-Khoi namaDatjhi. U-Van RieBeeck wathi u-Autshumato unomlandu wokubulala. Yeke kwaliwa ipi, ekugcineni ama-Khoi ahlulwa. U-Atshumato wabanjwa wasiwa ekuthunjweni e-''Robben Island'' ngawo umnyaka ka-1653. Kodwana ngo-1655 waphunyurha yena nalabo ebekathunjwe nabo babuyela enarheni ngesikepe esinembobo.  Nakafikako u-Jan Van Riebeeck wamamukela wambuyisela esikhundleni sakhe sokutoliga.&lt;ref name=&quot;:5&quot; /&gt;

== Iinkhombo ==</text>
      <sha1>g9awbg904bc5sgkvpm8pauhwqcz9188</sha1>
    </revision>
    <revision>
      <id>6142</id>
      <parentid>6125</parentid>
      <timestamp>2026-01-19T20:42:39Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>edited</comment>
      <origin>6142</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="11484" sha1="kv7qlbbckuk64ai6abrt174rgsw5ka0" xml:space="preserve">== Draft Space 1 ==

== Ukufika KwamaBhuru ESewula Afrika ==
[[Isimumathi:Flag of the Dutch East India Company.svg|thumb|260x260px|Iflarha le-VOC (Dutch East India Company)]]
'''AmaDatjhi''' '''(ngokhamba kwesikhathi abizwa ngamaBhuru)''' afika esewula ne-Afrika, eKapa, ngomhla we-6 kuSihlabantangana 1652. Bafika bakhamba ngemikhumbi emihlanu badoswa phambili ngu-Jan Van Riebeeck. Isizathu esenza amaDatjhi azithole aseKapa yindaba yezerhwebo. Abantwaba  bebangaphasi kwekhamphani ebizwa bona yi-''Dutch East India Company'' (V''ereenigde Oost-Indische Compagnie'' ''-'' VOC).&lt;ref name=&quot;:0&quot;&gt;South African History Online (13 January 2024) ''The Dutch Settlement.'' Retrieved from: https://sahistory.org.za/article/dutch-settlement Retrieved on 01/01/2026.&lt;/ref&gt; 

Ikhamphani le beyithatha ipahla, ikhambe amalwandle ngemikhumbi, iyoyithengisa eNdiya. Yeke ngebanga lokubalekela iingebengu zelwandle beyizomba inarhakazi yoke ye-Afrika. Kodwana ibangeli belilide khulu, begodu imikhumbi beyiphelelwa kukudla isendleleni. Yeke bekufuze kube nendawo lapha bangajama khona baphumule bathole nokudla okuzobafikisa eNdiya, iinthelo, imirorho, inyama namanzi ahlanzekileko ebekutholakala budisi kezinye iindawo. IKapa yaba ngileyondawo, ngikho nje beyibizwa bona yi-''Cape of Good Hope''.&lt;ref name=&quot;:2&quot; /&gt;

U-Jan Van Riebeeck wabona indawo le asendleleni ebuyela emva e-Holland, avela eJapani, njengombana bekathengisela i-VOC iinkhumba. Wathi nakehla emkhunjini eKapa, wabona indawo le ingaba yihle khulu bona imikhumbi ye-VOC ingaphumulela khona bese iraga nekhambo layo itjhinge eNdiya.&lt;ref name=&quot;:2&quot; /&gt;

== U-Jan Van Riebeeck - 1647 ==
[[Isimumathi:Jan van Riebeeck cropped.jpg|thumb|U-Jan Van Riebeeck]]
Kuhlekuhle bekungasikokuthoma amaDatjhi afika ngo-1652. Bakhe bafika okokuthoma ngenyanga kaNtaka ngo-1647 bakhamba ngomkhumbi obizwa bona yi-''Nieuwe Haarlem''. Umkhumbi lo wafika waphahlazeka eKapa. Abasinda emkhunjini lowo bafika bakha indawo abayibiza bona yi-''Sand Fort of the Cape of Good Hope.'' Bahlala lapho pheze umnyaka woke. Ekugcineni kwafika imikhumbi eli-12 ebeyidoswa phambili ngu-W.G de Jong. Komunye wemikhumbi le bekunendoda ebizwa bona ngu-Jan Van Riebeeck.&lt;ref name=&quot;:1&quot;&gt;Marco Ramerini, English text by Dietrich Köster (January, 11 2014), ''The Dutch in South Africa, 1652-1795 and 1802-1806.'' Retrieved from https://www.colonialvoyage.com/dutch-south-africa/. Retrieved on 03/01/2026.&lt;/ref&gt;&lt;ref name=&quot;:2&quot;&gt;South African History Online (17 October 2011), ''Jan van Riebeeck.'' Retrieved from: https://sahistory.org.za/people/jan-van-riebeeck. Retreived on 03/01/2026.&lt;/ref&gt;

UJan Van Riebeeck (U-''Johan Anthoniszoon &quot;Jan&quot; Van Riebeeck'') wabelethwa ngomhla ka-21 kuSihlabantangana 1619 e-Culemborg, e-Netherlands abelethwa nguyise ungodorhodere ohlinzako. Wakhulela e-Schiedam, e-Netherlands, kwathi ngomhla wama-28 kuNtaka 1649, watjhada u-''Maria de la Queillerie'', waba nabantwana ababunane naye.&lt;ref name=&quot;:2&quot; /&gt;

U-Jan Van Riebeeck waba lilunga le-''Dutch East India Company'' (''Vereenigde Oost-Indische Compagnie'' -  VOC) ngo-1639 lapha athoma khona ukuba msizi kadorhodere ohlinzako ekhambeni labo lokuya e-Batavia (namhlanjesi eyaziwa nge-Jakarta) ngenyanga kaSihlabantangana 1639 bese batjhinga e-Nagasaki eJapani ngo-1643.&lt;ref name=&quot;:2&quot; /&gt;

Ngo-1645 u-Jan Van Riebeeck wanikelwa isabelo sokuba mphathi wesitetjhi sokurhwebela se-VOC ebesise-Tongkin e-''French Indochina'' (namhlanjesi eyaziwa nge-Vietnam). Wehliswa esikhundleneso ngebanga lokuthi besele azenzela irhwebo lakhe langeqadi, okuphula umthetho wekhamphani othi abaphathi akukafuzi bazenzele irhwebo ngeqadi ngepahla yekhamphani. Kwathi bona ehliswe esikhundleni, wazithola sele kufuze abuyele emva e-Netherlands ayoqalana nemilandu yakhe. Ngikho-ke besele atholakala komunye wemikhumbi eli-12 ebeyidoswa phambili ngu-W.G de Jong. Wafika e-''Table Bay'' hlanu kwe-''Cape of Good Hope'' wahlala khona amalanga ali-18. Lokho kwamnikela isikhathi sokuqalisisa indawo, nokucabanga bona angayisebenzisa njani ekwenzeni bona i-VOC imthembe godu. Wayibona iyindawo enganikela ngokudla namanzi kabakhamba ngemikhumbi.&lt;ref name=&quot;:2&quot; /&gt;

Njengombana umkhumbi i-''Nieuwe Haerlem'' waphahlazeka ngo-1647, abasindileko bakha indawo lapho, u-Jan Van Riebeeck walemuka indlela ebebarhwebelana ngayo namaKhoikhoi njengombana balinde ukutakulwa. Ngemva kwalokho-ke watlola umbiko ngendawo le nangakho koke akubonileko, bewahlongoza bona indawo le ingaba yindawo ehle khulu i-VOC engayisebenzisa. Umbiko lo watlolwa ngo-1648 wathunyelwa ekhamphanini. Kwathi ngo-1651 i-VOC yathatha isiqunto sokuthi indawo ye-''Cape of Good Hope'' ayisetjenziselwe iminqopho yekhamphani.&lt;ref name=&quot;:2&quot; /&gt;

I-VOC yakhetha yena u-Jan Van Riebeeck bona kube nguye umdosiphambili ozokuhloma isitetjhi sokuphumula semikhumbi yamaDatjhi khona izokuthola ukudla okutjha okunepilo namanzi ahlanzekileko. Kwaba kusuka kwakhe-ke u-Jan Van Riebeeck, asuka e-Texel, e-Netherlands ngomhla wama-24 kuNobayeni 1651 bewayokufika e-''Table Bay'' ngomhla wesi-6 kaSihlabantangana 1652.&lt;ref name=&quot;:2&quot; /&gt; Bafika bakhamba ngemikhumbi emihlanu - i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch''.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;

== Ukufika KwamaDatjhi  - 1652 ==
[[Isimumathi:VOC ship Phenix.jpg|thumb|Imikhumbi yamaDatjhi ifika eKapa]]
U-Jan Van Riebeeck wasuka ngomhla wama-24 kuNobayeni 1651 e-Texel, e-Netherlands, wafika ngomhla wesi-6 kaSihlabantangana 1652.&lt;ref name=&quot;:2&quot; /&gt; Bafika bakhamba ngemikhumbi emihlanu - i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;'' Emithathu le ngiyo eyafika qangi, ngikho kwaziwa khulu le emithathu, le eminye imikhumbi emibili yafika mva. Ekufikeni kwakhe nabantu ebekakhamba nabo ngemikhumbi le wafika wakha indawo yobuphephelo ebizwa bona yi-''Fort de Goede Hoop (Fort of Good Hope).'' Bafika batjala endaweni leyo, kodwana iintjalo zabo khenge zitlhurhe kuhle, mhlamunye ngebanga lobujamo bezulu obungafani nobe-Netherlands, netjharagano ebeliphakathi kwamadoda ebekakhamba nawo nakufuze basebenze batlhgomele imikhumbu edlulako. Abantu bebabancani umsebenzi umnengi.&lt;ref name=&quot;:2&quot; /&gt;

Kwathi ngo-1655 u-Van Riebeeck wabika bona ngaphandle kwabantu abazimisele ukusebenza emasimini, isitetjhesi sizokubhalelwa ukwenza umsebenzi esihloselwe wona. Kwathi ngo-1657, i-VOC yathumela abalimi ababhadelwako, ngombandela wokuthi balime inarha bebathengisele ikhamphani iintjalo abazilimileko. Ngibo laba ebebabizwa bona ma-''Free Burghers (Vry Burgers)''. U-Jan Van Riebeeck wathatha isikhathi sakhe soke atjala bekakhiqiza amagrepsi, ama-apula namazambana, ukudla okuzokuba lisizo khulu emikhumbini edlulako. Kwathi ngo-1659 besele anesivuno samagrepsi ebesikhiqiza iwayini elibovu elilwisana nobulwele be-''scurvy,'' njengombana besele alemukile bona ukusela iwayini kuyabuvikela ubulwelobu ngokwezinga elithileko.&lt;ref name=&quot;:2&quot; /&gt;

== Ama-Khoikhoi ==
Ukuthoma kokufika kwamaDatjhi eKapa (''Cape of Good Hope'') khenge kubamangaze abantu bendabuko bendawo leyo ama-Khoikhoi. AmaDatjhi afika nje ama-Khoikhoi besele kukade arhwebelana namaPutukezi, amaFrentji namaNgisi. Nangaphezu kokufika kuka-Van Riebeeck, ngokuya kuka-Knox‑Johnson, phakathi nomnyaka wabo-1600 kuya ku-1700, besele kudlule imikhumbi yamaDatjhi eziyi-1 730. Yeke amaKhoikhoi bekangawaqabuki amaDatjhi ngesikhatheso.&lt;ref&gt;Helen Swingler (22 September 2021) ''Heritage Month: The Khoi encountered Europeans long before Van Riebeeck,'' University of Cape Town News. Retrieved from: https://www.news.uct.ac.za/article/-2021-09-22-the-khoi-encountered-europeans-long-before-van-riebeeck. Retrieved on 12/01/2026.&lt;/ref&gt;
[[Isimumathi:Khoikhoi Hottentot p197.jpg|thumb|Ama-Khoikhoi]]
Esikhathini sokufika kwamaDatjhi bekunendoda ebizwa bona ngu-Autshumato, namkha u-Autshumao, amaDatjhi ebebambiza bona ngu-''Harry die Strandloper''. U-Autshumao bekayikosi yesitjhaba samaKhoikhoi ebesibizwa bona ma-''Gorinhaikona''. Isitetjhana sokurhwebelana nabantu bemikhumbi sathonywa nguye.&lt;ref name=&quot;:3&quot;&gt;Roben Island Museum (13 May 2017) ''Autshumato''. Retrieved from: http://www.robben-island.org.za/departments/heritage/gallery/autshumato.asp. Retrieved on 14/01/2026.&lt;/ref&gt; Ngo-1630 wathathwa maNgisi esitjhabeni sekhabo bona ambandulele ukukhulumisana nabanye ngendaba yezokurhwebelana begodu atolige. Yeke amaNgisi amthatha amusa e-Bantam eNgilandi, wafika wafundiswa isiNgisi, isiDatjhi nesiFrentji nesiPutukezi. Wathi nakabuya eKapa bamthatha bamusa e-''Robben Island'' yena nabalandeli bakhe. Bekuthi imikhumbi nayifikako ambathe iimpahla zamaYurobhu akhulumisane nabokapteni bemikhumbi, akhulume isiNgisi nesiFrentji. Bambiza bona yi-''Governor.''&lt;ref name=&quot;:4&quot;&gt;Camissa Museum (2026) ''Autshumao (1610 - 1674)'', Retrieved from: https://camissamuseum.co.za/index.php/7-tributaries/1-cape-indigenous-africans/autshumao. Retrieved on 12/01/2026.&lt;/ref&gt;

Kwathi ngo-1638, u-Autshumao nomphakathi wekhabo ebewunabantu abangaba ma-60, babuya esihlengehlengeni beza enarheni eKapa, lapha kuhlangana khona umlambo i-''Camissa River'' nelwandle. Yena nomndenakhe ngibo ebebaphethe isitetjhi sokurhwebelana i-''‖Ammaqua'' (okutjho Abantu bemanzini) okulibizo u-Jan Van Riebeeck ebekababiza ngalo ekuthomeni.&lt;ref name=&quot;:3&quot; /&gt;&lt;ref name=&quot;:4&quot; /&gt;

Ngesikhathi amaDatjhi afika, umuntu wokuthoma ukubamukela bekungu-Autshumao nabantu bakhe. ngikho nje amaDatjhi bebababiza ngokuthi ma-''Strandloper'' ngombana babathola bakhamba eligwini lelwandle. Kusukela bathoma ukubonana bathoma ukurhwebelana. Zoke izinto ebezenzeka u-Jan Van Riebeeck wazitlola emajenalini wakhe. AmaDatjhi bewathenga iinkomo nezimvu kuma-Khoikhoi ngepahla ehlukahlukeneko kuhlanganise notjwala negwayi. Bese inyama yefuyo le idliwe, enye ethengiselwe abantu abadlula ngemikhumbi yekhamphani.&lt;ref name=&quot;:5&quot;&gt;Steemit Website (2018) ''SOUTH AFRICAN HISTORY: Autshumato translator and first Postmaster of The Cape of Good Hope''. Retrieved from: https://steemit.com/history/@krabgat/south-african-history-autshumato-translator-and-first-postmaster-of-the-cape-of-good-hope. Retrieved on 14/01/2026.&lt;/ref&gt; 

Kwathi ngenyanga kaSewula wango-1653 kwaba nokurhitjhana phakathi kuka-Autshumato nomelusi weenkomo zika-Van Riebeeck u-David Jansz. U-Autshumato wambulala wathatha iinkomo. Ukurhitjhanokhu kuthoma nje iintjhaba ezimbili lezi besele zingasathelelani kuhle amanzi. AmaDatjhi besele aqala u-Autshumato nabantu bakhe njengamasela. U-Jan Van Riebeeck wathi u-Autshumato lisela elinelimi elibutjhelelezi. AmaKhoikhoi aqala amaDatjhi njengabakhohlisi ngokuthi intengo yotjwala negwayi ayilingani nentengo yesilwana esifuywako. Bebathi bangabusela utjwala buphele, babone ifuywabo emadlelweni wamaDatjhi, yanda. Bese amaKhoikhoi akhambe ayoyeba.&lt;ref&gt;Castle of Good Hope (''13th November 2018'') ''Interpreters' Flawed Contracts With Dutch''Retrieved from: https://www.castleofgoodhope.co.za/index.php/news/100-news/142-interpreters-flawed-contracts-with-dutch. Retrieved on 14/01/2026.&lt;/ref&gt; 

Isenzakalo sokubulawa kuka-David Jansz sasusa ipi phakathi kwama-Khoi namaDatjhi. U-Van RieBeeck wathi u-Autshumato unomlandu wokubulala. Yeke kwaliwa ipi, ekugcineni ama-Khoi ahlulwa. U-Atshumato wabanjwa wasiwa ekuthunjweni e-''Robben Island'' ngawo umnyaka ka-1653. Kodwana ngo-1655 waphunyurha yena nalabo ebekathunjwe nabo babuyela enarheni ngesikepe esinembobo.  Nakafikako u-Jan Van Riebeeck wamamukela wambuyisela esikhundleni sakhe sokutoliga.&lt;ref name=&quot;:5&quot; /&gt;

== Iinkhombo ==</text>
      <sha1>kv7qlbbckuk64ai6abrt174rgsw5ka0</sha1>
    </revision>
    <revision>
      <id>6158</id>
      <parentid>6142</parentid>
      <timestamp>2026-02-10T14:21:43Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>edited</comment>
      <origin>6158</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="35" sha1="551a0mh9tjjmc54uayd1njqyutu2bl0" xml:space="preserve">== Draft Space 1 ==

== U-Krotoa ==</text>
      <sha1>551a0mh9tjjmc54uayd1njqyutu2bl0</sha1>
    </revision>
    <revision>
      <id>6159</id>
      <parentid>6158</parentid>
      <timestamp>2026-02-10T20:01:09Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>New article</comment>
      <origin>6159</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6336" sha1="ci2p3lz0rz0lmpumrn60nv60h7wwjuu" xml:space="preserve">== Draft Space 1 ==

== U-Krotoa ==
[[Isimumathi:Krotoa Picture.jpg|thumb|U-Krotoa]]
'''U-Krotoa''' (amaDatjhi bekalipeleda bunjesi ibizo lakhe - !Goroǀgôas) bekamfazi wom-Khoekhoe owalethwa ngu-Autshumato ku-Jan Van Riebeeck bona azokuba likhobokakazi lomkakhe u-Maria de la Quellerie. Ibizo lakhe lamambala alaziwa kodwana elidume khulu ngilelo amaDatjhi ebekambiza ngalo - u-Eva. Umfazi lo wadlala indima ekulu ekubeni mtologi phakathi kwesitjhaba samaDatjhi nesama-Khoekhoe, begodu waba ngomunye wabantu abanzima umlando wabo otlolwe maDatjhi. Umalumake [[u-Autshumato]] uvuma ukumnikela [[u-Jan Van Riebeeck]] ngombana bekafuna abe mputjuzi wazo zoke iindaba zamaDatjhi nendlelawo yokwenza izinto.&lt;ref&gt;Cape Town Museum (2021), ''!Goroǀgôas (Krotoa) or Eva van Meerhof''. Retrieved from: https://www.capetownmuseum.org.za/impactfulwomeneng/krotoa-72dn4. Retrieved on 10/02/2026.&lt;/ref&gt;

== Ekukhuleni Kwakhe ==
U-Krotoa wabelethwa ngo-c.1642, abelethelwa esitjhabeni sama-Khoekhoe esibizwa bona ma-Goringhaicona. Ubelethwa amtjhana wekosi yesitjhabeso u-Autshumato, omtologi phakathi wesitjhaba sakhe nesamaDatjhi. Kungenzeka bona u-Krotoa bekatjhidelene khulu nomalumake okwamenza wafunda izinto ezinengi kuye, kuhlanganise nokutologa ilimi lesiDatjhi nokufunda isikopilo lawo. Kwathi nakaneminyaka elitjhumi kuya kwelitjhumi nambili, umalumakhe wanikela ngaye ku-Jan Van Riebeeck bona abe mtlhogomeli namkha ikhobokakazi lika-Maria de la Quellerie. Lokho kwenzeka emalangeni ambalwa amaDatjhi aqeda ukufika eKapa. Kodwana u-Jan Van Riebeeck uthoma ukukhuluma ngaye edayarinakhe ngenyanga kaTjhirhweni wango - 1654, ambiza bona 'mntazana ohlala nathi.' U-Krotoa walifunda ilimi begodu walikhuluma kuhle khulu ilimi lesiDatjhi nelesiPutukezi, begodu bekazithoba msinya esikweni lesiKrestu njengokulayelwa kwakhe ngu-Maria.&quot;.&lt;ref name=&quot;:0&quot;&gt;South African History Online (21 July 2020), ''Krotoa (Eva).'' Retrieve from: https://sahistory.org.za/people/krotoa-eva. Retrieved on 10/02/2026.&lt;/ref&gt; 
[[Isimumathi:Jan van Riebeeck cropped.jpg|thumb|U-Jan Van Riebeeck]]
Ukulikhuluma kwakhe kuhle ilimi lesiDatjhi kwenza bona uJan Van Riebeeck amsebenzise khulu njengomtologi lokha nakabamba ikulumiswano neentjhaba zama-Khoekhoe. Lokho kwathoma sele aneminyaka eli-15. Bekadlala indima ekulu eenquntweni ebezithathwa maDatjhi. Nabathengiselana bekunguye otologako. Nanyana kunjalo umsebenzakhe bewungasibulula ngombana bekazithola sele ahlukene phakathi, angazwisisi bona kufuze athembeke kibobani - emaDatjhini awasebenzelako namkha ebantwini bekhabo ama-Khoekhoe. Ngebanga lakho womabili amahlangothi bewangamthembi kuhle&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot;&gt;Camissa Museum (2026), ''Krotoa (circa 1642 - 1674)''. Retrieved from: https://camissamuseum.co.za/index.php/7-tributaries/1-cape-indigenous-africans/krotoa. Retrieved on 10/02/2026.&lt;/ref&gt; 

Ekuthomeni [[u-Jan Van Riebeeck]] bekakhuluma kuhle ngaye nemisebenzi ayenzako, kodwana ngokukhamba kwesikhathi watjho bona akasamthembi u-Krotoa ngombana bekamane atjela amaDatjhi lokho abafuna ukukuzwa. Waveza nokuthi u-Krotoa uthanda abantu besitjhaba salapho udadwabo ka-Krotoa ende khona ikosana u-Oedasoa wesitjhaba sama-''Cochoqua'', nebekhabo ama-''Goringhaicona,'' nama-''‖Ammaqua.''&lt;ref name=&quot;:1&quot; /&gt; Ngakelinye ihlangothi, idayari ka-Van Riebeeck, iveze amezwi wekulumiswano phakathi kuka-Doman oyikosana yama-Khoe no-Krotroa. U-Doman wathi, &quot;Mina ngili-Khoekhoe angisilo iDatjhi, kodwana, wena, Eva, ulinga ukuthandwa Mphathi [u-Van Riebeeck].' Amagama la aveza bona no-Doman bekangamthembi uKrotoa.&lt;ref name=&quot;:0&quot; /&gt; Kwathi ngemva kokuhlongakala kuka-Doman no-Autshumato, ipilwakhe yaba budisi khulu.

== Umtjhado Wakhe ==
Ngo-1662 u-Krotoa waba mumuntu wokuthoma esitjhabeni sekhabo bona abhajadiswe abe mKrestu esontweni lamaDatjhi, ngemva kwalokho wanikelwa ibizo bona ngu-Eva. Kodwana ngawo umnyaka wokubhajadiswa kwakhe, u-Jan Van Riebeeck wakhamba eKapa, watjhiya u-Krotoa anganabani. Kwahlongozwa bona bona akasebenzele ozokulandela u-Van Riebeeck esikhundleni, u-Zacharias Wagenaer, kodwana u-Wagenaer khabe angamthembi u-Krotoa. Lokho bekungebanga lokuthi u-Krotoa bekathanda ukuvakatjhela abantu bekhabo khulu. Ipilo beyibudisi khulu ku-Krotoa ngemva kobana u-Autshumato no-Doman bahlongakale. Lokho kwamenza bona abe kuphela komuntu omtologi phakathi kwamaDatjhi nama-Khoekhoe. Ubuhlobo phakathi kweentjhaba ezimbilezi bebungekho ngaphandle kwakhe.&lt;ref name=&quot;:0&quot; /&gt; 

Kwathi ngomhla wama-26 kuSihlabantangana wango-1664, u-Krotoa wathembisana umtjhado nesotja lomDenitjhi, u-Pieter van Meerhof. Batjhada ngomhla wesi-2 kuMgwengweni ngo-1664 endlini yoMphathi u-Zacharias Wagenaer. I-VOC ebeyikuthanda ukutjhadiselana nabantu bendabuko yakhupha ilobolo elikhulu khulu. Umtloli wedayari ka-Wagenaer’s bewatjho bona 'bekumtjhado wokuthoma wesiKrestu phakathi kwamaDatjhi nabantu bendabuko.' Besele kuminyaka eli-12 u-Jan Van Riebeeck afika eKapa, imitjhado yabantu bendabuko nabamhlophe beyingakavumeleki ngaleso sikhathi. Yeke u-Krotoa waba ngu-Eva Van Meerhof.&lt;ref name=&quot;:0&quot; /&gt; Ngomnyaka olandelako indodakwakhe yabekwa bona ibe sikhulu se-''Robben Island,'' yeke njengabatjhadikazi besele kufuze bathuthele khona. Ngo-1665, sele banabentwana abathathu, indodakwakhe yabulawa e-Madagascar. U-Krotoa wagcina abuyele eKapa nabantwana bakhe ngomhla wama-30 Kukhukhulamunu wona umnyaka loyo. Wavunyelwa bona ahlale njengesivakatjhi emzini woMphathi.&lt;ref name=&quot;:2&quot;&gt;Krabgat (2018), ''SOUTH AFRICAN HISTORY: Krotoa, the bridge between European and African culture,'' Steemit Website. Retrieved from: https://steemit.com/history/@krabgat/south-african-history-krotoa-the-bridge-between-european-and-african-culture. Retrieved on 10/02/2026.&lt;/ref&gt; 

Isizi nobudisi ebekaqalene, nehloyo ebekanayo ngamaDatjho kwamenza wathoma ukusela khulu, bewathengisa nedini. Umukghwa wokusela khulu wabonakala ngitjho netafuleni lomphathi. Kwathathwa isiqunto sokobana akhalinywe bona alungise iindlela zakhe. Kunokuthi azilungise, watjhiya abantwana bakhe walinga ukubaleka kodwana wabanjwa wavalelwa ejele lalapho. NgoNtaka wangawo umnyaka lowo, u-Krotoa wadingiselwa e-Robben Island ngebanga lokuziphatha kumbi kwakhe. Wahlala lapho bekwaba kuhlongakala kwakhe ngomhla wama-29 kaVelabahlinze 1674. Wabulungwa ngendlela yesiKrestu esontweni elisendaweni yamaDatjhi etja.&lt;ref name=&quot;:2&quot; /&gt;</text>
      <sha1>ci2p3lz0rz0lmpumrn60nv60h7wwjuu</sha1>
    </revision>
    <revision>
      <id>6160</id>
      <parentid>6159</parentid>
      <timestamp>2026-02-11T15:20:05Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>6160</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6459" sha1="dlowenrspfebn4nz4es4v1g19hts5vj" xml:space="preserve">== Draft Space 1 ==

== U-Krotoa ==
[[Isimumathi:Krotoa Picture.jpg|thumb|U-Krotoa]]
'''U-Krotoa''' (amaDatjhi bekalipeleda bunjesi ibizo lakhe - !Goroǀgôas) bekamfazi wom-Khoekhoe owalethwa ngu-Autshumato ku-Jan Van Riebeeck bona azokuba likhobokakazi lomkakhe u-Maria de la Quellerie. Ibizo lakhe lamambala alaziwa kodwana elidume khulu ngilelo amaDatjhi ebekambiza ngalo - u-Eva. Umfazi lo wadlala indima ekulu ekubeni mtologi phakathi kwesitjhaba samaDatjhi nesama-Khoekhoe, begodu waba ngomunye wabantu abanzima umlando wabo otlolwe phasi maDatjhi. Umalumakhe [[u-Autshumato]] wavuma ukumnikela [[u-Jan Van Riebeeck]] ngombana bekafuna abe mputjuzi wazo zoke iindaba zamaDatjhi nendlelawo yokwenza izinto.&lt;ref&gt;Cape Town Museum (2021), ''!Goroǀgôas (Krotoa) or Eva van Meerhof''. Retrieved from: https://www.capetownmuseum.org.za/impactfulwomeneng/krotoa-72dn4. Retrieved on 10/02/2026.&lt;/ref&gt;

== Ekukhuleni Kwakhe ==
U-Krotoa wabelethwa ngo-c.1642, abelethelwa esitjhabeni sama-Khoekhoe esibizwa bona ma-Goringhaicona. U-Krotoa mtjhana wekosi yesitjhabeso u-Autshumato, naye obekamtologi phakathi wesitjhaba sakhe nesamaDatjhi. Kungenzeka bona u-Krotoa bekatjhidelene khulu nomalumakhe okwamenza wafunda izinto ezinengi kuye, kuhlanganise nokutologa ilimi lesiDatjhi nokufunda isikopilo lawo. Kwathi nakaneminyaka elitjhumi kuya kwelitjhumi nambili, umalumakhe wanikela ngaye ku-Jan Van Riebeeck bona abe mtlhogomeli namkha ikhobokakazi lomkakhe u-Maria de la Quellerie. Lokho kwenzeka emalangeni ambalwa amaDatjhi aqeda ukufika eKapa. Kodwana u-Jan Van Riebeeck uthoma ukukhuluma ngaye edayarinakhe ngenyanga kaTjhirhweni wango-1654, ambiza bona 'mntazana ohlala nathi.' U-Krotoa walifunda ilimi lesiDatjhi begodu walikhuluma kuhle khulu, ingasi isiDatjhi kwaphela kodwana nesiPutukezi, begodu bekazithoba msinya esikweni lesiKrestu njengokulayelwa kwakhe ngu-Maria.&quot;&lt;ref name=&quot;:0&quot;&gt;South African History Online (21 July 2020), ''Krotoa (Eva).'' Retrieve from: https://sahistory.org.za/people/krotoa-eva. Retrieved on 10/02/2026.&lt;/ref&gt; 
[[Isimumathi:Jan van Riebeeck cropped.jpg|thumb|U-Jan Van Riebeeck]]
Ukulikhuluma kwakhe kuhle ilimi lesiDatjhi kwenza bona u-Jan Van Riebeeck amsebenzise khulu njengomtologi lokha nakabamba iinkulumiswano neentjhaba zama-Khoekhoe. Wathoma ukusebezisa u-Krotoa lokha nakaneminyaka eli-15. U-Krotoa ekadlala indima ekulu eenquntweni ebezithathwa maDatjhi. Nabathengiselanako bekunguye otologako. Nanyana kunjalo umsebenzakhe bewungasibulula ngombana bekazithola sele ahlukene phakathi, angazwisisi bona kufuze athembeke kibobani - emaDatjhini awasebenzelako namkha ebantwini bekhabo ama-Khoekhoe. Ngebanga lakho womabili amahlangothi bewangamthembi kuhle.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot;&gt;Camissa Museum (2026), ''Krotoa (circa 1642 - 1674)''. Retrieved from: https://camissamuseum.co.za/index.php/7-tributaries/1-cape-indigenous-africans/krotoa. Retrieved on 10/02/2026.&lt;/ref&gt; 

Ekuthomeni [[u-Jan Van Riebeeck]] bekakhuluma kuhle ngaye nemisebenzi ayenzako, kodwana ngokukhamba kwesikhathi watjho bona akasamthembi u-Krotoa ngombana bekamane atjela amaDatjhi lokho ebekafuna ukukuzwa. Waveza nokuthi u-Krotoa ubathanda khulu abantu besitjhaba salapho udadwabo  ende khona, ekosini u-Oedasoa wesitjhaba sama-''Cochoqua.'' Lokho kuhlanganise nebekhabo ama-''Goringhaicona,'' nama-''‖Ammaqua.''&lt;ref name=&quot;:1&quot; /&gt; Ngakelinye ihlangothi, idayari ka-Van Riebeeck, iveze amezwi wekulumiswano phakathi kuka-Doman oyikosana yama-Khoe no-Krotoa. U-Doman wathi, &quot;Mina ngili-Khoekhoe angisilo iDatjhi, kodwana, wena, Eva, ulinga ukuthandwa Mphathi [u-Van Riebeeck].' Amagama la aveza bona no-Doman bekangamthembi uKrotoa.&lt;ref name=&quot;:0&quot; /&gt; Kwathi ngemva kokuhlongakala kuka-Doman no-Autshumato, ipilwakhe yaba budisi khulu.

== Umtjhado Wakhe ==
Ngo-1662 u-Krotoa waba mumuntu wokuthoma esitjhabeni sekhabo bona abhajadiswe abe mKrestu esontweni lamaDatjhi, ngemva kwalokho wanikelwa ibizo bona ngu-Eva. Kodwana ngawo umnyaka wokubhajadiswa kwakhe, u-Jan Van Riebeeck wakhamba eKapa, watjhiya u-Krotoa anganabani. Kwahlongozwa bona akasebenzele ozokulandela u-Van Riebeeck esikhundleni, u-Zacharias Wagenaer, kodwana u-Wagenaer khabe angamthembi u-Krotoa. Lokho bekungebanga lokuthi u-Krotoa bekathanda ukuvakatjhela abantu bekhabo khulu. Ipilo beyibudisi khulu ku-Krotoa ngemva kobana u-Autshumato no-Doman bahlongakale. Lokho kwamenza bona abe kuphela komuntu omtologi phakathi kwamaDatjhi nama-Khoekhoe. Ubuhlobo phakathi kweentjhaba ezimbilezi bebungekho ngaphandle kwakhe.&lt;ref name=&quot;:0&quot; /&gt; 

Kwathi ngomhla wama-26 kuSihlabantangana wango-1664, u-Krotoa wathembisana umtjhado nesotja lomDenitjhi, u-Pieter van Meerhof. Batjhada ngomhla wesi-2 kuMgwengweni ngo-1664 endlini yoMphathi u-Zacharias Wagenaer. I-VOC beyikuthanda ukutjhadiselana nabantu bendabuko, yeke yakhupha ilobolo elikhulu khulu. Umtloli wedayari ka-Wagenaer bewatjho bona 'bekumtjhado wokuthoma wesiKrestu phakathi kwamaDatjhi nabantu bendabuko.' Besele kuminyaka eli-12 u-Jan Van Riebeeck afika eKapa, imitjhado yabantu bendabuko nabamhlophe beyingakavumeleki ngaleso sikhathi. Yeke u-Krotoa waba ngu-Eva Van Meerhof.&lt;ref name=&quot;:0&quot; /&gt; Ngomnyaka olandelako indodakwakhe yabekwa bona ibe sikhulu se-''Robben Island,'' yeke njengabatjhadikazi besele kufuze bathuthele khona. Ngo-1665, sele banabentwana abathathu, indodakwakhe yabulawa epini e-Madagascar. U-Krotoa wagcina abuyele eKapa nabantwana bakhe ngomhla wama-30 kuKhukhulamungu wona umnyaka loyo. Wavunyelwa bona ahlale njengesivakatjhi emzini woMphathi.&lt;ref name=&quot;:2&quot;&gt;Krabgat (2018), ''SOUTH AFRICAN HISTORY: Krotoa, the bridge between European and African culture,'' Steemit Website. Retrieved from: https://steemit.com/history/@krabgat/south-african-history-krotoa-the-bridge-between-european-and-african-culture. Retrieved on 10/02/2026.&lt;/ref&gt; 

Isizi nobudisi ebekaqalene nabo, nehloyo ebekanayo ngamaDatjhi kwamenza wathoma ukusela khulu, bewathengisa nedini. Umukghwa wokusela khulu wabonakala ngitjho netafuleni loMphathi. Kwathathwa isiqunto sokobana akhalinywe bona alungise iindlela zakhe. Kunokuthi azilungise, watjhiya abantwana bakhe walinga ukubaleka kodwana wabanjwa wavalelwa ejele lalapho. NgoNtaka wangawo umnyaka lowo, u-Krotoa wadingiselwa e-Robben Island ngebanga lokuziphatha kumbi kwakhe. Wahlala lapho bekwaba kuhlongakala kwakhe ngomhla wama-29 kaVelabahlinze 1674. Wabulungwa ngendlela yesiKrestu esontweni elisendaweni yamaDatjhi etja.&lt;ref name=&quot;:2&quot; /&gt;

== Iinkhombo ==</text>
      <sha1>dlowenrspfebn4nz4es4v1g19hts5vj</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Nqobile69Draftpage1</title>
    <ns>2</ns>
    <id>573</id>
    <revision>
      <id>2700</id>
      <timestamp>2025-04-23T09:20:13Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;This is my personal  working space&quot;</comment>
      <origin>2700</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="34" sha1="ish8hbp6catpclub0pvxk4w2knh5jac" xml:space="preserve">This is my personal  working space</text>
      <sha1>ish8hbp6catpclub0pvxk4w2knh5jac</sha1>
    </revision>
    <revision>
      <id>2713</id>
      <parentid>2700</parentid>
      <timestamp>2025-04-23T09:27:30Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2713</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="40" sha1="8dux8zgj6yfqlcfu26a2ivvdnxfkuhn" xml:space="preserve">== This is my personal  working space ==</text>
      <sha1>8dux8zgj6yfqlcfu26a2ivvdnxfkuhn</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Lungile M. MabhenaDraft page 2</title>
    <ns>2</ns>
    <id>574</id>
    <revision>
      <id>2704</id>
      <timestamp>2025-04-23T09:21:53Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <comment>DRAFT 2</comment>
      <origin>2704</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="19" sha1="jgfj0mdc9ck0sjnhp9awcdcv46q7nsx" xml:space="preserve">My personal space 2</text>
      <sha1>jgfj0mdc9ck0sjnhp9awcdcv46q7nsx</sha1>
    </revision>
    <revision>
      <id>2710</id>
      <parentid>2704</parentid>
      <timestamp>2025-04-23T09:25:15Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <comment>DRAFT 2</comment>
      <origin>2710</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="13" sha1="3hgbcungnmni58lhqhmn0ckxfu11mzx" xml:space="preserve">== DRAFT 2 ==</text>
      <sha1>3hgbcungnmni58lhqhmn0ckxfu11mzx</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Mosakaruka/Draft Page 2</title>
    <ns>2</ns>
    <id>575</id>
    <revision>
      <id>2705</id>
      <timestamp>2025-04-23T09:22:35Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>Created page with &quot;== Draft Space 2 ==&quot;</comment>
      <origin>2705</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="19" sha1="dlolxaqvj8l6x19oda12qyxaucrvcj7" xml:space="preserve">== Draft Space 2 ==</text>
      <sha1>dlolxaqvj8l6x19oda12qyxaucrvcj7</sha1>
    </revision>
    <revision>
      <id>2851</id>
      <parentid>2705</parentid>
      <timestamp>2025-05-26T21:37:23Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>2851</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1060" sha1="58fucqaxpjbbcp7pu3iwr2rua1qh41l" xml:space="preserve">== Draft Space 2 ==

= Ukuhlukahluka Kwesikopilo =
Nasikhuluma ngokuhlukahluka kwesikopilo sikhuluma ngokungafani kwamasiko nepilo yeentjhaba ezihlukahlukeneko enarheni yinye. Kubandakanya iindlela ezinengi iinqema nemiphakathi ekhuluma, nenza ngayo izinto okwenza esinye nesinye isitjhaba sizikhakhazise ngokuba ngilokho esingikho nendima esiyidlalako enarheni.

ISewula Afrika ngenye yeenarha ezineentjhaba ezinamasikopilo ahlukahlukeneko. Iintjhabezi zinamasiko, amalimi, nendlela yokwenza izinto engafaniko. 

== Ukuqakatheka Kokuhluka Kwesikopilo ==
I-UNESCO iveza ukuhlukahluka kwesikopilo kuletha ukwabelana ngelwazi emazikweni ahlukahlukeneko njengakwezobukghwari, ukwenziwa kwemikhiqizo emitjha, nemazikweni wezemvelo. Ukuthuthukiswa kwelwazi elabelwanakweli kuqakathekile esitjhabeni ngombana kuthuthukisa zefundo, zomnotho nezokuhlala enarheni le.

== Iimbonelo Zokuhluka Kwesikopilo ==

* Ukudla Okungafaniko
* Iindatjana Ezicocwako Zendabuko
* Imibono Engafaniko

== Indima Edlalwa Yisikopilo ESewula Afrika ==

== Iinzuzo Zokuhluka Kwesikopilo ==</text>
      <sha1>58fucqaxpjbbcp7pu3iwr2rua1qh41l</sha1>
    </revision>
    <revision>
      <id>2852</id>
      <parentid>2851</parentid>
      <timestamp>2025-05-26T21:47:01Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>2852</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1355" sha1="2mesa8go22qa5wohze84lxmzaeb83hy" xml:space="preserve">== Draft Space 2 ==

= Ukuhlukahluka Kwesikopilo =
Nasikhuluma ngokuhlukahluka kwesikopilo sikhuluma ngokungafani kwamasiko nepilo yeentjhaba ezihlukahlukeneko enarheni yinye. Kubandakanya iindlela ezinengi iinqema nemiphakathi ekhuluma, nenza ngayo izinto okwenza esinye nesinye isitjhaba sizikhakhazise ngokuba ngilokho esingikho nendima esiyidlalako enarheni.

ISewula Afrika ngenye yeenarha ezineentjhaba ezinamasikopilo ahlukahlukeneko. Iintjhabezi zinamasiko, amalimi, nendlela yokwenza izinto engafaniko. 

== Ukuqakatheka Kokuhluka Kwesikopilo ==
I-UNESCO iveza ukuhlukahluka kwesikopilo kuletha ukwabelana ngelwazi emazikweni ahlukahlukeneko njengakwezobukghwari, ukwenziwa kwemikhiqizo emitjha, nemazikweni wezemvelo. Ukuthuthukiswa kwelwazi elabelwanakweli kuqakathekile esitjhabeni ngombana kuthuthukisa zefundo, zomnotho nendlela yokuhlalisana ngobunye enarheni le. Naka amanye amaphuzu amahlanu ukuhluka kwesikopilo okuqakatheke ngayo:

* Kuthuthukisa Ukwenziwa Kwemitlamo Emitjha
* Kuthuthukisa Indlela Yokufunda Neyokuthuthuka Kwelwazi
* Kukatelela Ukusebenzisana Nokuthula
* Kuthuthukisa Ezomnotho
* Kukhulisa Imiphakathi

== Iimbonelo Zokuhluka Kwesikopilo ==

* Ukudla Okungafaniko
* Amalimi
* Amasiko Nokuziphatha
* Ubukghwari Nezokuzithabisa
* Ikolo

== Indima Edlalwa Yisikopilo ESewula Afrika ==

== Iinzuzo Zokuhluka Kwesikopilo ==</text>
      <sha1>2mesa8go22qa5wohze84lxmzaeb83hy</sha1>
    </revision>
    <revision>
      <id>2856</id>
      <parentid>2852</parentid>
      <timestamp>2025-05-28T20:40:33Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>added paragraphs</comment>
      <origin>2856</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3275" sha1="fk7iaysj4hms81js6ga0s7fyqt0xyux" xml:space="preserve">== Draft Space 2 ==

= Ukuhlalisana Kwabantu Abanamasikopilo Angafaniko =
Ukuhlalisana kwabantu abanesikopilo engafani kutjho ukuthatha abantu abavela eenzindeni namasikopilo ahlukahlukeneko bese ubahlalise ngobunye nangokuzwana, bangaqali kwaphela bona baneenzinda namasiko angafaniko, kodwana bakwamukele bebakuthabele lokho. Lokhu kunikela woke umuntu ilungelo lokuphila ngokwalokho angikho ingasi ngokwalokho abanye abafuna abe ngikho. &lt;ref&gt;{{Cite web|title=What is Cultural Diversity and Why Does it Matter? - Hourly, Inc.|url=https://www.hourly.io/post/cultural-diversity|access-date=2025-05-28|website=www.hourly.io|language=en}}&lt;/ref&gt;

Ngamanye amagama ukuhlalisana kwabantu abanesikopilo engafaniko kukwamukela bona umphakathi wethu wakhiwa babantu abafuna izinto ezingafaniko, abanamakghono namatalende angafaniko neendingo ezingafaniko. Begodu kutjho bona nawumumuntu  kufuze utjheje bona uphila nabantu abanekolo engafani neyakho, nabanobulili obungafani nebakho, nokuthi lokho kufuze ukwamukele.&lt;ref&gt;{{Cite web|date=2024-10-03|title=What is Cultural Diversity?|url=https://young.scot/get-informed/what-is-cultural-diversity/|access-date=2025-05-28|website=Young Scot|language=en-US}}&lt;/ref&gt; Ukuba nombono onjalo kwenza abantu bahlalisane ngobunye nokusebenzisana kunokuthi baninane. 

== Ukuqakatheka Kokuhluka Kwesikopilo ==
Ukuhlukahluka kwesikopilo kuletha ukwabelana ngelwazi emazikweni ahlukahlukeneko njengakwezobukghwari, ukwenziwa kwemikhiqizo emitjha, nemazikweni wezemvelo. Ukuthuthukiswa kwelwazi elabelwanakweli kuqakathekile esitjhabeni ngombana kuthuthukisa zefundo, zomnotho nendlela yokuhlalisana ngobunye enarheni le. 

Ukulemuka nokwamukela abanye nendlela abaphila ngayo kwenza umuntu azwisise amasiko neenkolelo zabanye. Izinto umuntu ebekangaziqala njengezingasizihle namkha ezithusako ngamasiko womunye zingazwisiseka nange omunye angazifaka emanyathelweni womunye. Izazi zezokuhlalisana zithi umuntu ozwisisa isikopilo labanye 

* kumenza alemuke bekatjheje bona iinzinda namasiko akufani, 
* kumenza ahloniphe izici ezingafaniko esikweni lakhe nelomunye, 
* kumenza anganyazi nanyana yini omunye ayibeka etafuleni ngokwesiko lakhe, 
* kumenza akghone nokweluleka abanye abangafuni ukwamukela amasiko angafani newabo, 
* begodu kumenze akuthabele ukungafani esikhundleni sokukunina.&lt;ref&gt;{{Cite web|last=lesadmin|date=2021-07-26|title=What Are the Benefits of Understanding Different Cultures?|url=https://www.leselfes.com/understanding-different-cultures/|access-date=2025-05-28|website=Les Elfes International Camps Switzerland|language=en-US}}&lt;/ref&gt;

* Recognize that there are lots of different cultures and that they’re individually diverse
* Acknowledge that all cultural expressions and backgrounds are valid
* Respect the differences between you and people from other cultures
* Value everything that other cultures bring to the table
* Empower people to accomplish their ultimate potential by criticizing their own biases
* Celebrate each other instead of condoning our differences

== Iimbonelo Zokuhluka Kwesikopilo ==

* Ukudla Okungafaniko
* Amalimi
* Amasiko Nokuziphatha
* Ubukghwari Nezokuzithabisa
* Ikolo

== Indima Edlalwa Yisikopilo ESewula Afrika ==

== Iinzuzo Zokuhluka Kwesikopilo ==

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>fk7iaysj4hms81js6ga0s7fyqt0xyux</sha1>
    </revision>
    <revision>
      <id>2857</id>
      <parentid>2856</parentid>
      <timestamp>2025-05-28T20:47:51Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>2857</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3124" sha1="bkbdeu68269gayot3ndo3xlgzqqbfpl" xml:space="preserve">== Draft Space 2 ==

= Ukuhlalisana Kwabantu Abanamasikopilo Angafaniko =
Ukuhlalisana kwabantu abanesikopilo engafani kutjho ukuthatha abantu abavela eenzindeni namasikopilo ahlukahlukeneko bese ubahlalise ngobunye nangokuzwana, bangaqali kwaphela bona baneenzinda namasiko angafaniko, kodwana bakwamukele bebakuthabele lokho. Lokhu kunikela woke umuntu ilungelo lokuphila ngokwalokho angikho ingasi ngokwalokho abanye abafuna abe ngikho. &lt;ref&gt;{{Cite web|title=What is Cultural Diversity and Why Does it Matter? - Hourly, Inc.|url=https://www.hourly.io/post/cultural-diversity|access-date=2025-05-28|website=www.hourly.io|language=en}}&lt;/ref&gt;

Ngamanye amagama ukuhlalisana kwabantu abanesikopilo engafaniko kukwamukela bona umphakathi wethu wakhiwa babantu abafuna izinto ezingafaniko, abanamakghono namatalende angafaniko neendingo ezingafaniko. Begodu kutjho bona nawumumuntu  kufuze utjheje bona uphila nabantu abanekolo engafani neyakho, nabanobulili obungafani nebakho, nokuthi lokho kufuze ukwamukele.&lt;ref&gt;{{Cite web|date=2024-10-03|title=What is Cultural Diversity?|url=https://young.scot/get-informed/what-is-cultural-diversity/|access-date=2025-05-28|website=Young Scot|language=en-US}}&lt;/ref&gt; Ukuba nombono onjalo kwenza abantu bahlalisane ngobunye nokusebenzisana kunokuthi baninane. 

== Ukuqakatheka Kokuhluka Kwesikopilo ==
Ukuhlukahluka kwesikopilo kuletha ukwabelana ngelwazi emazikweni ahlukahlukeneko njengakwezobukghwari, ukwenziwa kwemikhiqizo emitjha, nemazikweni wezemvelo. Ukuthuthukiswa kwelwazi elabelwanakweli kuqakathekile esitjhabeni ngombana kuthuthukisa zefundo, zomnotho nendlela yokuhlalisana ngobunye enarheni le. 

Ukulemuka nokwamukela abanye nendlela abaphila ngayo kwenza umuntu azwisise amasiko neenkolelo zabanye. Izinto umuntu ebekangaziqala njengezingasizihle namkha ezithusako ngamasiko womunye zingazwisiseka nange omunye angazifaka emanyathelweni womunye. Izazi zezokuhlalisana zithi umuntu ozwisisa isikopilo labanye 

* kumenza alemuke bekatjheje bona iinzinda namasiko akufani, 
* kumenza ahloniphe izici ezingafaniko esikweni lakhe nelomunye, 
* kumenza anganyazi nanyana yini omunye ayibeka etafuleni ngokwesiko lakhe, 
* kumenza akghone nokweluleka abanye abangafuni ukwamukela amasiko angafani newabo, 
* begodu kumenze akuthabele ukungafani esikhundleni sokukunina.&lt;ref&gt;{{Cite web|last=lesadmin|date=2021-07-26|title=What Are the Benefits of Understanding Different Cultures?|url=https://www.leselfes.com/understanding-different-cultures/|access-date=2025-05-28|website=Les Elfes International Camps Switzerland|language=en-US}}&lt;/ref&gt;
Yeke ngokuya ngokwamaphuzu la kuba bulula ukuhlalisana nomuntu nangabe uyalizwisisa isiko nendlelakhe yokuphila, kuba bulula ukusebenza naye emsebenzini, kuba lula nokwakha ubungani nokwabelana naye amakghono nangabe uyasizwisisa isizinda avela kiso, amasiko awenzako nelimi alikhulumako.

== Iimbonelo Zokuhluka Kwesikopilo ==

* Ukudla Okungafaniko
* Amalimi
* Amasiko Nokuziphatha
* Ubukghwari Nezokuzithabisa
* Ikolo

== Indima Edlalwa Yisikopilo ESewula Afrika ==

== Iinzuzo Zokuhluka Kwesikopilo ==

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>bkbdeu68269gayot3ndo3xlgzqqbfpl</sha1>
    </revision>
    <revision>
      <id>2862</id>
      <parentid>2857</parentid>
      <timestamp>2025-05-29T14:42:06Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>added paragraphs</comment>
      <origin>2862</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7786" sha1="s16h58f2bjvsiyp9ach0nh4m5an26zd" xml:space="preserve">== Draft Space 2 ==

= Ukuhluka Kwesikopilo =
[[Isimumathi:Variety of male human faces (collage).jpg|thumb|312x312px|Abantu abahlukahlukeneko]]
Ukuhlalisana kwabantu abanesikopilo engafani kutjho ukuthatha abantu abavela eenzindeni namasikopilo ahlukahlukeneko bese ubahlalise ngobunye nangokuzwana, bangaqali kwaphela bona baneenzinda namasiko angafaniko, kodwana bakwamukele bebakuthabele lokho. Lokhu kunikela woke umuntu ilungelo lokuphila ngokwalokho angikho ingasi ngokwalokho abanye abafuna abe ngikho. &lt;ref&gt;{{Cite web|title=What is Cultural Diversity and Why Does it Matter? - Hourly, Inc.|url=https://www.hourly.io/post/cultural-diversity|access-date=2025-05-28|website=www.hourly.io|language=en}}&lt;/ref&gt; 

Ngamanye amagama ukuhlalisana kwabantu abanesikopilo engafaniko kukwamukela bona umphakathi wethu wakhiwa babantu abafuna izinto ezingafaniko, abanamakghono namatalende angafaniko neendingo ezingafaniko. Begodu kutjho bona nawumumuntu  kufuze utjheje bona uphila nabantu abanekolo engafani neyakho, nabanobulili obungafani nebakho, nokuthi lokho kufuze ukwamukele.&lt;ref&gt;{{Cite web|date=2024-10-03|title=What is Cultural Diversity?|url=https://young.scot/get-informed/what-is-cultural-diversity/|access-date=2025-05-28|website=Young Scot|language=en-US}}&lt;/ref&gt; Ukuba nombono onjalo kwenza abantu bahlalisane ngobunye nokusebenzisana kunokuthi baninane. 

== Ukuqakatheka Kokuhluka Kwesikopilo ==
Ukuhlukahluka kwesikopilo kuletha ukwabelana ngelwazi emazikweni ahlukahlukeneko njengakwezobukghwari, ukwenziwa kwemikhiqizo emitjha, nemazikweni wezemvelo. Ukuthuthukiswa kwelwazi elabelwanakweli kuqakathekile esitjhabeni ngombana kuthuthukisa zefundo, zomnotho nendlela yokuhlalisana ngobunye enarheni le. 

Ukulemuka nokwamukela abanye nendlela abaphila ngayo kwenza umuntu azwisise amasiko neenkolelo zabanye. Izinto umuntu ebekangaziqala njengezingasizihle namkha ezithusako ngamasiko womunye zingazwisiseka nange omunye angazifaka emanyathelweni womunye. Izazi zezokuhlalisana zithi umuntu ozwisisa isikopilo labanye 

* kumenza alemuke bekatjheje bona iinzinda namasiko akufani, 
* kumenza ahloniphe izici ezingafaniko esikweni lakhe nelomunye, 
* kumenza anganyazi nanyana yini omunye ayibeka etafuleni ngokwesiko lakhe, 
* kumenza akghone nokweluleka abanye abangafuni ukwamukela amasiko angafani newabo, 
* begodu kumenze akuthabele ukungafani esikhundleni sokukunina.&lt;ref&gt;{{Cite web|last=lesadmin|date=2021-07-26|title=What Are the Benefits of Understanding Different Cultures?|url=https://www.leselfes.com/understanding-different-cultures/|access-date=2025-05-28|website=Les Elfes International Camps Switzerland|language=en-US}}&lt;/ref&gt;
Yeke ngokuya ngokwamaphuzu la kuba bulula ukuhlalisana nomuntu nangabe uyalizwisisa isiko nendlelakhe yokuphila, kuba bulula ukusebenza naye emsebenzini, kuba lula nokwakha ubungani nokwabelana naye amakghono nangabe uyasizwisisa isizinda avela kiso, amasiko awenzako nelimi alikhulumako.

== Ukungafani Kwesikopilo ESewula Afrika ==
[[Isimumathi:Pella faces, Klein Pella, Northern Cape, South Africa (19921756083).jpg|thumb|449x449px|Abantwana abahlukileko beSewula Afrika]]
UmThethosisekelo weSewula Afrika uthi woke umuntu unelungelo lokukhuluma ilimi alimunyako begodu azikhakhazise ngalo, unelungelo lokwenza amasiko wekhabo, nelokukhetha ikolo afuna ukuba ngaphasi kwayo.&lt;ref&gt;{{Cite web|title=Cultural, Religious and Language Diversity|url=https://fwdeklerk.org/reconciliation-and-unity-in-diversity/cultural-religious-and-language-diversity/|access-date=2025-05-29|website=FW de Klerk Foundation|language=en-US}}&lt;/ref&gt; Yeke  ngokomthethosisekelo lo woke umuntu nanyana anelungelo lokwenza amasiko wekhabo kufuze atjheje amalungelo wabanye wokwenza amasiko wemakhabo. Lokho kwenza abantu bahlalisane ngobunye nokwamukelana.

Iimbalobalo zango-2024  ze-Statistic South Africa (Stats SA) zilinganisela bona isibalo sabantu baboke eSewula Afrika ziingidi ezima-63,02. Bese amalimi atloliswe ngokomthetho akhulunywa babantwaba ali-12 - isiNgisi, isiBhuru, isiZulu, isiXhosa, isiSwati, isiPedi, isiSuthu, isiTswana, isiTsonga, isiVenda nelimi lezandla leSewula Afrika. Woke amalimi la anamalungelo wokusetjenziswa ngendlela elinganako. Ngikho inengi labantu eSewula Afrika likhuluma amalimi amabili asemthethweni umuntu ngamunye.&lt;ref&gt;{{Cite web|title=People of South Africa {{!}} South African Government|url=https://www.gov.za/about-sa/south-africas-people|access-date=2025-05-29|website=www.gov.za}}&lt;/ref&gt; 

Ukuhlukahluka kwamalimi, isizinda namasiko kuyithuthukisile iSewula Afrika emikhakheni ehlukahlukeneko njengakwezokuthibisa, kezomnotho nakezefundo. 

=== Kwezokuzithabisa ===
Ukuhluka okukhulu kwesikopilo eSewula Afrika kuvela kuhle ezikweni lokuzithabisa lenarha le. Kuneenqhema ezinengi zabantu bendabuko abahlukahlukeneko begodu boke banamasiko, amalimi neendlela zokwenza imitlamo emitjha. Lokho ukubona emafilimini, ekugideni nembhinweni weSewula Afrika begodu abantwaba bahlanganisa isikopilwabo emazwikweni la bawenze abe mahle. Ngaphezu kwalokhko kuba namajima nezenzakalo ezifana ne-''Cape Town International Jazz Festival'' ne-''National Arts Festival in Grahams Town'' edosa iinthekeli ezivela ephasini loke ezifuna ukubona ukuhlukahluka kwesikopilo lenarha le. Lokho kulithuthukisile iziko lokuzithabisa.&lt;ref&gt;{{Cite web|last=Mukhari|first=Vutlhari|date=2024-08-28|title=Why is South Africa’s entertainment industry a gold mine to boost local tourism? - Etela Africa|url=https://etela.africa/why-is-south-africas-entertainment-industry-a-gold-mine-to-boost-local-tourism/|access-date=2025-05-29|language=en-US}}&lt;/ref&gt;

=== Kwezomnotho ===
Ukuhluka kwesikopilo eSewula Afrika kube nesandla ekukhuleni komnotho wenarha le ngokuza nendlela yokwenza imikhiqizo emitjha - njengezokuzithabisa - nokurherha amathalente amatjha. Abantu abahlukahlukeneko abasemabubulweni la beza nemibono emitjha eyenza kuthathwe iinqunto ezingcono, kukhuphule indlela yokurarulula imiraro neyokuza neendlela ezitjha zokwenza imikhiqizo. Ngaphezu kwalokho inarha le ikghona ukuletha inzuzo ekulu ngamaziko wezokuvakatjha newokwenza imitlamo emitjha.&lt;ref&gt;{{Cite web|title=how cultural diversity improves economic growth in south africa - Google Search|url=https://www.google.com/search?q=how+cultural+diversity+improves+economic+growth+in+south+africa&amp;sca_esv=595de8d130c61221&amp;rlz=1C1JJTC_enZA1159ZA1159&amp;sxsrf=AE3TifPbzq6OPF4689gtEIaG4WfdKVsDrg:1748523734674&amp;ei=1lo4aPb8KO6zhbIP7ZzH8Qk&amp;oq=how+cultural+diversity+improves+econo+in+south+africa&amp;gs_lp=Egxnd3Mtd2l6LXNlcnAiNWhvdyBjdWx0dXJhbCBkaXZlcnNpdHkgaW1wcm92ZXMgZWNvbm8gaW4gc291dGggYWZyaWNhKgIIADIKECEYoAEYwwQYCjIKECEYoAEYwwQYCjIKECEYoAEYwwQYCjIKECEYoAEYwwQYCkj8O1D2Dli8H3ACeAGQAQCYAYMDoAHsDaoBAzMtNbgBAcgBAPgBAZgCBKAC1gbCAgoQABiwAxjWBBhHwgIIEAAYgAQYogTCAgUQABjvBcICCBAAGKIEGIkFmAMAiAYBkAYIkgcFMi40LTKgB8sqsgcDNC0yuAevBsIHBTMtMy4xyAc-&amp;sclient=gws-wiz-serp|access-date=2025-05-29|website=www.google.com}}&lt;/ref&gt;

=== Kwezefundo ===
Ukuhluka kwesikopilo eSewula Afrika kuyithuthukisile ifundo ngokwenza abafundi bafunde ukuhlalisana nokusebenzisana emsebenzinabo yesikolo ngitjho nanyana bavela eenzindeni ezingafaniko. Lokho kubafundisa ukusebenzisana ngitjho nanyana sele baqedile isikolo basebenza. Kubenze baba nomqondo ovulekileko, bazithemba khudlwana begodu kwabasiza bakghona ukuzwisisa amasiko ahlukahlukeneko. Yeke ngokwamukela ifundo ngokuhlukahluka kwesikopilo, iinkolo zikghona ukuba nendawo engcono yokufundela khona amakghono wokucabanga azokuthuthuke, kwehlise nebandlululo. &lt;ref&gt;{{Cite web|date=2025-05-14|title=The Importance of Multicultural Education|url=https://drexel.edu/soe/resources/student-teaching/advice/importance-of-cultural-diversity-in-classroom/|access-date=2025-05-29|website=School of Education|language=en}}&lt;/ref&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>s16h58f2bjvsiyp9ach0nh4m5an26zd</sha1>
    </revision>
    <revision>
      <id>3218</id>
      <parentid>2862</parentid>
      <timestamp>2025-06-24T15:12:31Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>3218</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3149" sha1="m8xh836wfdsr02e7lq30gi4ncu9q61r" xml:space="preserve">== Draft Space 2 ==

== Abatloli Abasesebatjha ==
'''ISewula Afrika''' inomphakathi wabantu abatjha abanetalente lokutlola abazakhela ibizo emkhakheni wokutlola. Abatlolaba abasesebatjha abakhiqizi iincwadi kwaphela kodwana baba sikhuthazo nakwabanye bona bakuthande ukutlola. Badlale indima ekulu ekucocweni kweendatjana kusukela basesebancani.&lt;ref&gt;News24 (30 August 2017) ''Meet these SA kids who published books before they were 16,'' News24 website (2025). Retrieved from: https://www.news24.com/life/south-africas-youngest-authors-20170830 Retrieved on 24-06-2025.&lt;/ref&gt;

== U-Michelle Nkamankeng ==
U-Michelle Nkamankeg owaziwa ngencwadakhe yokuthoma ayitlolileko i-''&quot;Waiting for the Waves&quot;''  wathoma ukutlola aneminyaka elikhomba. Wabelethwa ngo-2008 ngunina u-Laurentine (Lolo) Nkamankeng oyimeneja yakhe, noyise uPaul Nkamankeng. Abentwana bakwabo ngu-Shawn, u-Sheena no-Marion. UMichelle ube hlangana nabantu abatjha abalitjhumi ephasini ababa batloli basesebancani. Kusukela mhlokho sekatlole umlandelande weencwadi ezine: &lt;ref name=&quot;:0&quot;&gt;Mbali Kgame (August 31, 2018), ''Meet Michelle Nkamankeng, Africa’s Famous School-Age Author,'' Global Citizen website. Retrieved from: https://www.globalcitizen.org/en/content/michelle-nkamankeng-south-africa-author-education/ Retrieved on 24-06-2025.&lt;/ref&gt;

# ''Waiting for the Waves''
# ''The little girl who believes on herself''
# ''The little mouse''
# ''The Golden Ring''&lt;ref name=&quot;:0&quot; /&gt;

== U-Stacey Fru&lt;ref name=&quot;:1&quot;&gt;Stacey Fru (2025), Meet Stacey, Stacey Fru website (2025). Retrieved from: https://staceyfru.co.za/ Retrieved on 24-06-2025.&lt;/ref&gt; ==
U-Stacey Fru mtlolo osele athumbe abonongorwana ngencwadi yakhe yokuthoma ethi, ''&quot;Smelly Cats&quot;'' aneminyaka ebunane kwaphela. Wabelethwa ngo-2007 amntwana wesibili ebantwaneni abane ekhabo. Waziwa njengomntwana onamatalende amanengi nezinto ezinengi azenzileko. Usikhulumi, uyagida begodu ungumlweli wamalungelo wabantwana. Nanzi iincwadi zakhe:&lt;ref name=&quot;:1&quot; /&gt;

# ''Smelly Cats''
# ''Bob and the Snake''
# ''Tim's Answer''&lt;ref name=&quot;:1&quot; /&gt;

== Hallelujah Khumalo ==

* At six years old, Hallelujah has already written two books, including &quot;Where I Fit,&quot; which encourages children to embrace their uniqueness. 

== Reabetswe Kungwane ==

* At the age of nine, Reabetswe was already pursuing her dream of becoming an author, demonstrating a passion for writing at a young age. 

== Jaco Jacobs ==

* While not as young as the others mentioned, Jaco Jacobs started writing at 7 years old and has become one of South Africa's most successful children's authors with over 220 books translated into multiple languages. 

== '''Andy Petersen:''' ==

* At 16, Andy became a published author with his fantasy novel, &quot;Daniel Fox and the Jester's Legacy&quot;. 

These are just a few examples of the many young, talented writers emerging from South Africa, contributing to a growing body of children's literature and inspiring others to explore the world of writing and storytelling. The Kingsmead Young Writers' Competition also highlights the burgeoning talent in South African youth, with winners and runners-up showcasing their literary skills.</text>
      <sha1>m8xh836wfdsr02e7lq30gi4ncu9q61r</sha1>
    </revision>
    <revision>
      <id>3224</id>
      <parentid>3218</parentid>
      <timestamp>2025-06-25T12:11:17Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>3224</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3132" sha1="fbkrmwvjooaa0v46lyefmpwqq1t6w4o" xml:space="preserve">== Draft Space 2 ==

== Abatloli Abasesebatjha ==
'''ISewula Afrika''' inomphakathi wabantu abatjha abanetalente lokutlola abazakhela ibizo emkhakheni wokutlola. Abatlolaba abasesebatjha abakhiqizi iincwadi kwaphela kodwana baba sikhuthazo nakwabanye bona bakuthande ukutlola. Badlale indima ekulu ekucocweni kweendatjana kusukela basesebancani.&lt;ref&gt;News24 (30 August 2017) ''Meet these SA kids who published books before they were 16,'' News24 website (2025). Retrieved from: https://www.news24.com/life/south-africas-youngest-authors-20170830 Retrieved on 24-06-2025.&lt;/ref&gt;

== U-Michelle Nkamankeng ==
U-Michelle Nkamankeg owaziwa ngencwadakhe yokuthoma ayitlolileko i-''&quot;Waiting for the Waves&quot;''  wathoma ukutlola aneminyaka elikhomba. Wabelethwa ngo-2008 ngunina u-Laurentine (Lolo) Nkamankeng oyimeneja yakhe, noyise uPaul Nkamankeng. Abentwana bakwabo ngu-Shawn, u-Sheena no-Marion. UMichelle ube hlangana nabantu abatjha abalitjhumi ephasini ababa batloli basesebancani. Kusukela mhlokho sekatlole umlandelande weencwadi ezine: &lt;ref name=&quot;:0&quot;&gt;Mbali Kgame (August 31, 2018), ''Meet Michelle Nkamankeng, Africa’s Famous School-Age Author,'' Global Citizen website. Retrieved from: https://www.globalcitizen.org/en/content/michelle-nkamankeng-south-africa-author-education/ Retrieved on 24-06-2025.&lt;/ref&gt;

# ''Waiting for the Waves''
# ''The little girl who believes on herself''
# ''The little mouse''
# ''The Golden Ring''&lt;ref name=&quot;:0&quot; /&gt;

== U-Stacey Fru ==
U-Stacey Fru mtlolo osele athumbe abonongorwana ngencwadi yakhe yokuthoma ethi, ''&quot;Smelly Cats&quot;'' aneminyaka ebunane kwaphela. Wabelethwa ngo-2007 amntwana wesibili ebantwaneni abane ekhabo. Waziwa njengomntwana onamatalende amanengi nezinto ezinengi azenzileko. Usikhulumi, uyagida begodu ungumlweli wamalungelo wabantwana. Nanzi iincwadi zakhe:&lt;ref name=&quot;:1&quot;&gt;Stacey Fru (2025), Meet Stacey, Stacey Fru website (2025). Retrieved from: https://staceyfru.co.za/ Retrieved on 24-06-2025.&lt;/ref&gt;

# ''Smelly Cats''
# ''Bob and the Snake''
# ''Tim's Answer''&lt;ref name=&quot;:1&quot; /&gt;

== Hallelujah Khumalo ==

* At six years old, Hallelujah has already written two books, including &quot;Where I Fit,&quot; which encourages children to embrace their uniqueness. 

== Reabetswe Kungwane ==

* At the age of nine, Reabetswe was already pursuing her dream of becoming an author, demonstrating a passion for writing at a young age. 

== Jaco Jacobs ==

* While not as young as the others mentioned, Jaco Jacobs started writing at 7 years old and has become one of South Africa's most successful children's authors with over 220 books translated into multiple languages. 

== '''Andy Petersen:''' ==

* At 16, Andy became a published author with his fantasy novel, &quot;Daniel Fox and the Jester's Legacy&quot;. 

These are just a few examples of the many young, talented writers emerging from South Africa, contributing to a growing body of children's literature and inspiring others to explore the world of writing and storytelling. The Kingsmead Young Writers' Competition also highlights the burgeoning talent in South African youth, with winners and runners-up showcasing their literary skills.</text>
      <sha1>fbkrmwvjooaa0v46lyefmpwqq1t6w4o</sha1>
    </revision>
    <revision>
      <id>3240</id>
      <parentid>3224</parentid>
      <timestamp>2025-06-26T14:46:29Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>references put</comment>
      <origin>3240</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3770" sha1="nyvdm01zagcj2hzmyr6xq10taa1nrzl" xml:space="preserve">== Draft Space 2 ==

== Abatloli Abasesebatjha ==
'''ISewula Afrika''' inomphakathi wabantu abatjha abanetalente lokutlola abazakhela ibizo emkhakheni wokutlola. Abatlolaba abasesebatjha abakhiqizi iincwadi kwaphela kodwana baba sikhuthazo nakwabanye bona bakuthande ukutlola. Badlale indima ekulu ekucocweni kweendatjana kusukela basesebancani.&lt;ref&gt;News24 (30 August 2017) ''Meet these SA kids who published books before they were 16,'' News24 website (2025). Retrieved from: https://www.news24.com/life/south-africas-youngest-authors-20170830 Retrieved on 24-06-2025.&lt;/ref&gt;

== U-Michelle Nkamankeng ==
U-Michelle Nkamankeg owaziwa ngencwadakhe yokuthoma ayitlolileko i-''&quot;Waiting for the Waves&quot;''  wathoma ukutlola aneminyaka elikhomba. Wabelethwa ngo-2008 ngunina u-Laurentine (Lolo) Nkamankeng oyimeneja yakhe, noyise uPaul Nkamankeng. Abentwana bakwabo ngu-Shawn, u-Sheena no-Marion. UMichelle ube hlangana nabantu abatjha abalitjhumi ephasini ababa batloli basesebancani. Kusukela mhlokho sekatlole umlandelande weencwadi ezine: &lt;ref name=&quot;:0&quot;&gt;Mbali Kgame (August 31, 2018), ''Meet Michelle Nkamankeng, Africa’s Famous School-Age Author,'' Global Citizen website. Retrieved from: https://www.globalcitizen.org/en/content/michelle-nkamankeng-south-africa-author-education/ Retrieved on 24-06-2025.&lt;/ref&gt;

# ''Waiting for the Waves''
# ''The little girl who believes on herself''
# ''The little mouse''
# ''The Golden Ring''&lt;ref name=&quot;:0&quot; /&gt;

== U-Stacey Fru ==
U-Stacey Fru mtlolo osele athumbe abonongorwana ngencwadi yakhe yokuthoma ethi, ''&quot;Smelly Cats&quot;'' aneminyaka ebunane kwaphela. Wabelethwa ngo-2007 amntwana wesibili ebantwaneni abane ekhabo. Waziwa njengomntwana onamatalende amanengi nezinto ezinengi azenzileko. Usikhulumi, uyagida begodu ungumlweli wamalungelo wabantwana. Nanzi iincwadi zakhe:&lt;ref name=&quot;:1&quot;&gt;Stacey Fru (2025), Meet Stacey, Stacey Fru website (2025). Retrieved from: https://staceyfru.co.za/ Retrieved on 24-06-2025.&lt;/ref&gt;

# ''Smelly Cats''
# ''Bob and the Snake''
# ''Tim's Answer''&lt;ref name=&quot;:1&quot; /&gt;

== Hallelujah Khumalo ==
U-Hallelujah Khumalo ngomunye walabo abathola ukutlola basesebancani. Wabelethwa ngo-2016 abelethwa nguSkhona no-Theodora Khumalo. Unabantwana bekhabo abathathu. Waziwa ngencwadakhe edumileko ethi &quot;Where I Fit,&quot; ekhuthaza abantwana bona bamukele bonyana abafani nabanye abantwana. Naye unamatalenta amanengana njengokudlala ipiyano, ukudansa umjido be ballet nokhunye. Nanzi iincwadi azitlolileko:&lt;ref name=&quot;:2&quot;&gt;Reitumetse Makwea (20 May 2023), ''Young author Hallelujah Khumalo wants other children to know it's okay not to fit,'' The Citizen (2025). Retrieved from: https://www.citizen.co.za/news/south-africa/special-features/young-author-hallelujah-khumalo-where-i-fit/ Retrieved on 26-06-2025.&lt;/ref&gt;

# ''Where I Fit''
# ''How Halle and Liesl became friends''&lt;ref name=&quot;:2&quot; /&gt;

== Reabetswe Kungwane ==

* At the age of nine, Reabetswe was already pursuing her dream of becoming an author, demonstrating a passion for writing at a young age. 

== Jaco Jacobs ==

* While not as young as the others mentioned, Jaco Jacobs started writing at 7 years old and has become one of South Africa's most successful children's authors with over 220 books translated into multiple languages. 

== '''Andy Petersen:''' ==

* At 16, Andy became a published author with his fantasy novel, &quot;Daniel Fox and the Jester's Legacy&quot;. 

These are just a few examples of the many young, talented writers emerging from South Africa, contributing to a growing body of children's literature and inspiring others to explore the world of writing and storytelling. The Kingsmead Young Writers' Competition also highlights the burgeoning talent in South African youth, with winners and runners-up showcasing their literary skills.</text>
      <sha1>nyvdm01zagcj2hzmyr6xq10taa1nrzl</sha1>
    </revision>
    <revision>
      <id>3242</id>
      <parentid>3240</parentid>
      <timestamp>2025-06-26T21:15:47Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>3242</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4677" sha1="6gc5qy9ddjji2t93qt0djjauyh7o8es" xml:space="preserve">== Draft Space 2 ==

== Abatloli Abasesebatjha ==
'''ISewula Afrika''' inomphakathi wabantu abatjha abanetalente lokutlola abazakhela ibizo emkhakheni wezokutlola. Abatlolaba abasesebatjha abakhiqizi iincwadi kwaphela kodwana baba sikhuthazo nakwabanye bona bakuthande ukutlola. Badlale indima ekulu ekucocweni kweendatjana kusukela basesebancani.&lt;ref&gt;News24 (30 August 2017) ''Meet these SA kids who published books before they were 16,'' News24 website (2025). Retrieved from: https://www.news24.com/life/south-africas-youngest-authors-20170830 Retrieved on 24-06-2025.&lt;/ref&gt;

== U-Michelle Nkamankeng ==
U-Michelle Nkamankeng owaziwa ngencwadakhe yokuthoma ayitlolileko i-''&quot;Waiting for the Waves&quot;''  wathoma ukutlola aneminyaka elikhomba. Wabelethwa ngo-2008 ngunina u-Laurentine (Lolo) Nkamankeng oyimeneja yakhe, noyise uPaul Nkamankeng. Abentwana bakwabo ngu-Shawn, u-Sheena no-Marion. UMichelle ube hlangana nabantu abatjha abalitjhumi ephasini ababa batloli basesebancani. Kusukela mhlokho sekatlole umlandelande weencwadi ezine:&lt;ref name=&quot;:0&quot;&gt;Mbali Kgame (August 31, 2018), ''Meet Michelle Nkamankeng, Africa’s Famous School-Age Author,'' Global Citizen website. Retrieved from: https://www.globalcitizen.org/en/content/michelle-nkamankeng-south-africa-author-education/ Retrieved on 24-06-2025.&lt;/ref&gt;

# ''Waiting for the Waves''
# ''The little girl who believes on herself''
# ''The little mouse''
# ''The Golden Ring''&lt;ref name=&quot;:0&quot; /&gt;

== U-Stacey Fru ==
U-Stacey Fru mtloli osele athumbe abonongorwana ngencwadi yakhe yokuthoma ethi, ''&quot;Smelly Cats&quot;'' aneminyaka ebunane kwaphela. Wabelethwa ngo-2007 amntwana wesibili ebantwaneni abane ekhabo. Waziwa njengomntwana onamatalende amanengi nezinto ezinengi azenzileko. Usikhulumi, uyagida begodu ungumlweli wamalungelo wabantwana. Nanzi iincwadi zakhe:&lt;ref name=&quot;:1&quot;&gt;Stacey Fru (2025), Meet Stacey, Stacey Fru website (2025). Retrieved from: https://staceyfru.co.za/ Retrieved on 24-06-2025.&lt;/ref&gt;

# ''Smelly Cats''
# ''Bob and the Snake''
# ''Tim's Answer''&lt;ref name=&quot;:1&quot; /&gt;

== Hallelujah Khumalo ==
U-Hallelujah Khumalo ngomunye walabo abathoma ukutlola basesebancani. Wabelethwa ngo-2016 abelethwa nguSkhona no-Theodora Khumalo.  Waziwa ngencwadakhe edumileko ethi &quot;''Where I Fit''&quot; ekhuthaza abantwana bona bamukele bonyana abafani nabanye abantwana. Naye unamatalenta amanengana njengokudlala ipiyano, ukudansa umjido we-''ballet'' nokhunye. Nanzi iincwadi azitlolileko:&lt;ref name=&quot;:2&quot;&gt;Reitumetse Makwea (20 May 2023), ''Young author Hallelujah Khumalo wants other children to know it's okay not to fit,'' The Citizen (2025). Retrieved from: https://www.citizen.co.za/news/south-africa/special-features/young-author-hallelujah-khumalo-where-i-fit/ Retrieved on 26-06-2025.&lt;/ref&gt;

# ''Where I Fit''
# ''How Halle and Liesl became friends''&lt;ref name=&quot;:2&quot; /&gt;

== Reabetswe Kungwane ==
U-Reabetswe Kungwane besele athoma ukufeza ibhudango lakhe ngokuthoma ukutlola aneminyaka elikhomba. Waziwa ngencwadakhe enesihloko esithi ''‘Stories you’ve never heard before’'' emlandelande weendatjana ezilitjhumi ezikhuluma ngalokho okwenzeke epilwenakhe, ngasinye sinesifundo esiqakathekileko epilweni uReabetswe acabanga bona singahlohlozela abantwana abalingana naye. Incwadi le ineenthombe ezigwalwe nguye. &lt;ref&gt;Rudzani Matshili (2018), ''How a 9-year-old pupil became a published author,'' IOL website (2025). Retrieved from: https://iol.co.za/news/south-africa/gauteng/2018-02-19-how-a-9-year-old-pupil-became-a-published-author/ Retrieved on 26-06-2025.&lt;/ref&gt;

# ''Stories you’ve never heard before''

== U-Metu Ngcali ==
U-Metu Ngcali oneminyaka elitjhumi nanye wazithola anetalente lokutlola ngemva kokungenela isifundobandulo sokutlola. Lokhu kwamenza wakhupha incwadakhe yokuthoma enesihloko esithi &quot;''The Clever Twins&quot;'' ngoVelabahlinze 2019. Uthe nakayethulako incwadi le kwathengwa amakhophi ama-300 ngelangelo. Incwadi le wayitlola acabanga ngomkhulwakhe. U-Metu uthi: &quot;Ngithabe khulu ngokutlola incwadi le. Bengingakuthandi ukutlola ekuthomeni, kodwana ngithe ukungenela isifundobandulo sokutlola esihlelwe yi-''Bala Books'' ngathoma ukuthanda ukutlola. &lt;ref&gt;Lerato Mogoatlhe, (August 2, 2019), ''These 8 Young Authors Want Every Child in South Africa to Have Access to Books,'' Global Citizen website. Retrieved from: https://www.globalcitizen.org/en/content/child-authors-turn-the-page-campaign-south-africa/ Retrieved on 26-06-2025.&lt;/ref&gt;

# ''The Clever Twins''

== Isiphetho ==
Lezi ziimbonelo ezimbalwa kwezinengi zabantu abatjha abanetalende lokutlola abahlala eSewula Afrika. Abantwanaba banikele ngokuthileko okungahlohlozela abanye bona bafune ukutlola nokucoca iindaba.

== Iinkhombo ==</text>
      <sha1>6gc5qy9ddjji2t93qt0djjauyh7o8es</sha1>
    </revision>
    <revision>
      <id>5241</id>
      <parentid>3242</parentid>
      <timestamp>2025-08-30T23:52:19Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>New article</comment>
      <origin>5241</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4761" sha1="tt55akmrnrq0euxl58igggzjylg4v5q" xml:space="preserve">== Draft Space 2 ==

== UMkabayi KaJama ==
'''UMkabayi kaJama''' bekangomunye wabantu besifazana abadlala indima ekulu ebukhosini bakwaZulu. Wabelethwa ngo-1750 wahlongakala ngo-1843. Uyise nguJama kaNdaba, ungudadwabo omdala wekosi uSenzangakhona, begodu bekaliwele nodadwabo uMamma. Bekaziwa njengomfazi webukhosini okghona ukuzijamela. Amagadango awathathako ngesikhathi asaphila bekatjengisa ukukhalipha engqondweni, nokuthanda isitjhaba sekhabo, kangangobana kwafuze athathe iinqunto ezibudisi ukuvikela isitjhaba sakwaZulu.&lt;ref name=&quot;:0&quot;&gt;ULwazi (2025) ''Princess Mkabayi Kajama, an Early Zulu Feminist.'' Retrieved from: https://www.ulwaziprogramme.org/princess-mkabayi-kajama-an-early-zulu-feminist/ Retrieved on 31/08/2025.&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;Maxwel Z Shamase (2014) The royal women of the Zulu monarchy–through the keyhole of oral history: Princess Mkabayi Kajama (c. 1750–c. 1843). Inkanyiso: Journal of Humanities and Social Sciences, 6(1), pp.15-22. Retrived from: https://uzspace.unizulu.ac.za/server/api/core/bitstreams/a6886ed0-073d-4216-9fd6-63b9b1c17076/content Retrieved on 31/08/2025.&lt;/ref&gt;

== Umlando Webuncanini Bakhe ==
UMkabayi wabelethelwa esitjhabeni sakwaZulu nodadwabo uMamma ngo-1750. Emihleni leyo bekukholelwa bona ukubelethwa kwamaphahla kuletha itjhudu elimbi esitjhabeni, mhlamunye bekufe nababelethi babo. Yeke bekuthi qobe nakubelethwa amaphahla elinye libulawe. Kodwana kosi uJama kaNdaba walikhomba libaba wathi nakubantwana bakhe bazokuphila bobabili. Yeke uMkabayi noMamma baphila bobabili. Kodwana lokho khenge kusiphathe kuhle isitjhaba, yeke uMkabayi wakhula ahloyiwe njalo. Kwathi nakaneminyaka emihlanu unina kaMkabayi wahlongakala. Abantu basola yena ngokuhlongakala kukanina. Unina ufa nje angakabeletheli uJama indlalifa yobukhosi.&lt;ref&gt;Manyathi PPP (1997). ''Ucwaningo Ngeqhaza labesifazane esizweni samaZulu, Kubhekiswe kakhulukazi kuMkabayi kaJama''. pp. 86–103.&lt;/ref&gt;

== Umlando Ekukhuleni Kwakhe ==
Wakhula njalo uMkabayi uyise anganayo indlalifa. Lokho kwenza bona ngo-1777 uMkabayi ayokufunela uyise umfazi ozomzalela indlalifa, nakuya azamtholela uMthaniya wesitjhaba sakwaSibiya. UMthaniya wambelethela indodana wayithiya ibizo bona nguSenzangakhona, ngombana ikosi ikghonile ukwenza ngakhona ngebanga lendodakazakhe uMkabayi. Lokho kwenza isitjhaba samthanda uMkabayi ngombana ikosi uJama kaNdaba besele athole umfazi wamaThonga ngokungasi seMthethweni, umfazi loyo waba sidisi wabeletha indodana kwathiwa nguSojiyisa. Kusukela ngalesosikhathi uMkabayi wathathwa njengomfazi othatha iinqunto ezihlakaniphileko bona avikele isitjhaba, ngombana ubukhosi bebuzokuwela ezandleni zevezandlebe. UMkabayi kaJama khenge enda, begodu wahlongakala angakendi.&lt;ref name=&quot;:1&quot; /&gt; Ngikho abizwa ngokobana nguMkabani kaJama (ekadeni abantu bebathefula nabakhulumako, yeke esikhundleni sokuthi bambize ngoMkabani, bathi nguMkabayi.)

=== UMkabayi Ngesikhathi Sokubusa KukaSenzangakhona ===
Ngokukhamba kwesikhathi uyise uJama wahlongakala. UMkabayi wazibeka esihlalweni sobukhosi wabambela uSenzangakhona ngombana bekasesemncani bona angabusa. Emihleni leyo isitjhaba besiphathwa madoda, ngikho nje bekunabantu emkhandlwini ebebangamthandisisi kuhle. Kodwana kwafuze bakubekezelele ukuphathwa mfazi. Lokho kwamenza waba nesithunzi namandla. Kwakuneenkhathi lapha bekufuze avikele khona isitjhaba ngokuthumela amabutho bona ayokulwa noSojiyisa ebekucatjangwa bona angaba yingozi ebukhosini bukaSenzangakhona. Yeke abantu bebamthatha njengomuntu onenturhu.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;

Wakhula uSenzangakhona, uMkabayi kwafuze ehle esihlalweni ngomnyaka ka-1781. Njengombana uSenzangakhona besele ayikosi nje uMkabayi waba ngumeluleki wakhe. Iindaba ezinengi zobukhosi uSenzangakhona bekazicoca naye uMkabayi. Nakuya uSenzangakhona azokukhulelisa uNandi kaBhebhe bangakatjhadi, bathola indodana bayithiya ngoSigidi. Ngemva kwalokho uNandi nendodanakhe baqothwa esitjhabeni. Kwathi bona uSigidi akhule ayokuhlala esitjhabeni sakwaMthethwa uMkabayi bekasolo amthanda.&lt;ref name=&quot;:1&quot; /&gt; 

=== UMkabayi Ngesikhathi Sokubusa KukaShaka ===
UShaka wagcina abuthethe ubukhosi, wabulala umfowabo uSigujana. UMkabayi wamamukela uShaka njengekosi yesitjhaba sakwaZulu, waraga nokubusa. Kwathi ngokukhamba  kwesikhathi uShaka wathoma ukuba yingozi esitjhabeni. Abantu abanengi bafa babulawa yikosi uShaka. UMkabayi kwaba nguye oza neqhinga lokuthi uShaka kufuze abulawe bona kuphephiswe isitjhaba. Iqhingelo walibopha noDingane, uMhlangana noMbopha kaSithayi. Ekugcineni kwathi ngo-1828 bambulala uShaka. Kwathi bona uDingane athathe isihlalo wadingisa uMkabayi kaJama esitjhabeni esibizwa ngokuthi kusebaQulusini. UMkabayi wafela lapho, asilukazi, kunganamuntu omtjhejako.&lt;ref name=&quot;:1&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>tt55akmrnrq0euxl58igggzjylg4v5q</sha1>
    </revision>
    <revision>
      <id>5858</id>
      <parentid>5241</parentid>
      <timestamp>2025-09-30T08:12:29Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>Replaced content with &quot;== Draft Space 2 ==&quot;</comment>
      <origin>5858</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="19" sha1="dlolxaqvj8l6x19oda12qyxaucrvcj7" xml:space="preserve">== Draft Space 2 ==</text>
      <sha1>dlolxaqvj8l6x19oda12qyxaucrvcj7</sha1>
    </revision>
    <revision>
      <id>5863</id>
      <parentid>5858</parentid>
      <timestamp>2025-09-30T09:46:20Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>New article</comment>
      <origin>5863</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4288" sha1="ekcju3cuyy4808slceohbhbdfjtelrm" xml:space="preserve">== Draft Space 2 ==

== INyanga YamaGugu ==
[[Isimumathi:Ndebele Architecture.jpg|thumb|392x392px|Indlu yesiNdebele]]
Qobe mnyaka, inyanga kaKhukhulamungu yinyanga yokugidinga amagugu namasiko wesintu eSewula Afrika. Ilanga lamaGugu elingomhla ka-24 kuKhukhulamungu, ligidinga amagugu wesintu anjengamasiko, ubukghwari, nokuhlukahluka kwamasiko wendabuko eentjhabeni zeSewula Afrika. 

Asigidingi ukuhlukahluka kwamaSewula Afrika kwaphela, kodwana nokuhlukahluka kwamasiko wephasi loke, ama-Afrika, ama-Asia, ama-Yurobhu namanye amakhontinenti, ikani nje nakanamasiko nesintu sabo esihlukahlukeneko. Lokho kubonakala ngokuthi kuhlelwe izenzakalo ezizokutjengisa ukuhlukahluka kwamagugu wamasiko nobukghwari, njengokuthi umuntu nomuntu ambathe isikhabo, nokuhlelwa kwesenzakalo esinombhino wesitjhaba ngasinye kunye nokukhangiswa kobukghwari obenziwa malunga wesitjhaba ngasinye.&lt;ref&gt;Department of Sport, Arts, and Culture (2023) ''Heritage Month - September.'' Retreived from: https://www.dsac.gov.za/Heritage-Month-2023. Retrieved on 30/09/2025.&lt;/ref&gt; 

== Umlando Wenyanga Yamagugu ==
Kuhlekuhle, ilanga langomhla ka-24 kuKhukhulamungu bekuliLanga likaShaka. Ilangeli beligidinga ukukhunjulwa kweKosi uShaka njengombana adlala indima ekulu yokuhlanganisa izizwe zabeNguni endaweni namhlanjesi ebizwa bona kuKwaZulu Natal. Yeke, qobe mnyaka iinkulungwana zabantu bakwaZulu beziza ethuneni leKosi uShaka bona lizomhlonipha belimkhumbule. Kwathi bona kuwe umBuso weBandlululo urhulumende wethula amaholideyi womphakathi amatjha. Kodwana akhenge ufake iLanga leKosi uShaka emaholideyini lawo. Yeke Inkatha Freedom Party, amalunga wayo amanengi okumaZulu, yabawa bona iLanga likaShaka lirage nokuba yiholideyi yabo. Urhulumende waqunta bona kuzokuba nelanga eliholideyi yomphakathi lapha woke umuntu eSewula Afrika azokugidinga khona amagugu wekhabo. Bekuzakuthi lokha amaZulu nakagidinga amagugu wekhabo ngeLanga likaShaka, nezinye iintjhaba zigidinge amagugu wabo wendabuko ngalo ilangeli. Ngikho nje umhla ka-24 kuKhukhulamungu, ulilanga lamagugu eSewula Afrika, nenyanga yoke kaKhukhula yaba yiNyanga yamaGugu.&lt;ref name=&quot;:0&quot;&gt;Kids Encyclopedia Britannica (2025) ''Heritage Day.'' Retrieved from: https://kids.britannica.com/kids/article/Heritage-Day/602049 Retrieved on 30/09/25&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;African Travel Canvas (Sep 13, 2021) ''National Heritage Day in South Africa: What is Heritage Day and Why Do We Celebrate It.'' Retrieved from: https://africantravelcanvas.com/news/national-heritage-day-in-south-africa-what-is-heritage-day-and-why-do-we-celebrate-it/. Retrieved on 30/09/2025.&lt;/ref&gt;

ILanga lamaGugu lathonywa ukugidingwa ngomhla ka-24 kuKhukhulamungu 1995. U-Atjhibhitjhobhu u-Emeritus Desmond Tutu wasebenzisa ibizo elithi &quot;''Rainbow Nation&quot;''  ukuhlathulula ngendlela amasiko, umlando, amalimi wethu okuhlukahluke ngayo. Ngilokho-ke iLanga lamaGugu elikugidingako. UmNyango wezobuKghwari namaSiko uhlela imihlangano nezenzakalo zaqobe mnyaka zokugidinga iLanga lamaGugu, bese ukhetha nendlela yokuligidingela. Amagugu angahlathululwa ngalokho esinye nesinye isitjhaba enarheni esithi nasikwenzako kusenze sikhumbule indabuko yaso. Lokhu kuhlanganisa ubuhle benarha bemvelo, iindawo zezesayensi namkha zomlando ezisikhumbuzo, amatje wesikhumbuzo, imakhiwo engokomlando, ubukghwari, iincwadi, umbhino, okucocwa ngomlomo namamiziyamu.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt; 

== Ukuqakatheka Kokugidinga INyanga YamaGugu ==
Njengombana amaSewula Afrika wendabuko akhe abuswa mBuso weBandlululo, omunye wemigomo yawo bekukuthi abantu bendabuko bakhohlwe ngomlando wabo, amasikwabo nezici ezenza babe ngibo khona bazokulawuleka. Kwathi bona uwe umBuso webandlululo, urhulumende omutjha wathoma ijima lokuthi ubuyisele isithunzi sabantu bendabuko eSewula Afrika ngokugidinga iNyanga yamaGugu. Ukugidinga isenzakalwesi kungenza umuntu azikhakhazise ngesikhabo, amasiko, ilimi, ubukghwari nombhino wesikhabo. Bese lokho kwenze inarha ibe nabantu abayaziko imveliphi yabo namasiko wabo, okwenza abantu bahlalisane ngokuthula enarheni, bamukelane bona bahlukile endabukweni yabo. Kuphinde kuthuthukise umnotho wenarha.&lt;ref&gt;South African Government (2013) ''Heritage Day.'' Retrieved from: https://www.gov.za/news/events/commemorative-events/heritage-day. Retrieved on 30/09/25.&lt;/ref&gt;</text>
      <sha1>ekcju3cuyy4808slceohbhbdfjtelrm</sha1>
    </revision>
    <revision>
      <id>5864</id>
      <parentid>5863</parentid>
      <timestamp>2025-09-30T09:47:30Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>5864</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4306" sha1="exrldsbbminc64dc7sjxs73p29kkkif" xml:space="preserve">== Draft Space 2 ==

== INyanga YamaGugu ==
[[Isimumathi:Ndebele Architecture.jpg|thumb|392x392px|Indlu yesiNdebele]]
Qobe mnyaka, inyanga kaKhukhulamungu yinyanga yokugidinga amagugu namasiko wesintu eSewula Afrika. Ilanga lamaGugu elingomhla ka-24 kuKhukhulamungu, ligidinga amagugu wesintu anjengamasiko, ubukghwari, nokuhlukahluka kwamasiko wendabuko eentjhabeni zeSewula Afrika. 

Asigidingi ukuhlukahluka kwamaSewula Afrika kwaphela, kodwana nokuhlukahluka kwamasiko wephasi loke, ama-Afrika, ama-Asia, ama-Yurobhu namanye amakhontinenti, ikani nje nakanamasiko nesintu sabo esihlukahlukeneko. Lokho kubonakala ngokuthi kuhlelwe izenzakalo ezizokutjengisa ukuhlukahluka kwamagugu wamasiko nobukghwari, njengokuthi umuntu nomuntu ambathe isikhabo, nokuhlelwa kwesenzakalo esinombhino wesitjhaba ngasinye kunye nokukhangiswa kobukghwari obenziwa malunga wesitjhaba ngasinye.&lt;ref&gt;Department of Sport, Arts, and Culture (2023) ''Heritage Month - September.'' Retreived from: https://www.dsac.gov.za/Heritage-Month-2023. Retrieved on 30/09/2025.&lt;/ref&gt; 

== Umlando Wenyanga Yamagugu ==
Kuhlekuhle, ilanga langomhla ka-24 kuKhukhulamungu bekuliLanga likaShaka. Ilangeli beligidinga ukukhunjulwa kweKosi uShaka njengombana adlala indima ekulu yokuhlanganisa izizwe zabeNguni endaweni namhlanjesi ebizwa bona kuKwaZulu Natal. Yeke, qobe mnyaka iinkulungwana zabantu bakwaZulu beziza ethuneni leKosi uShaka bona lizomhlonipha belimkhumbule. Kwathi bona kuwe umBuso weBandlululo urhulumende wethula amaholideyi womphakathi amatjha. Kodwana akhenge ufake iLanga leKosi uShaka emaholideyini lawo. Yeke Inkatha Freedom Party, amalunga wayo amanengi okumaZulu, yabawa bona iLanga likaShaka lirage nokuba yiholideyi yabo. Urhulumende waqunta bona kuzokuba nelanga eliholideyi yomphakathi lapha woke umuntu eSewula Afrika azokugidinga khona amagugu wekhabo. Bekuzakuthi lokha amaZulu nakagidinga amagugu wekhabo ngeLanga likaShaka, nezinye iintjhaba zigidinge amagugu wabo wendabuko ngalo ilangeli. Ngikho nje umhla ka-24 kuKhukhulamungu, ulilanga lamagugu eSewula Afrika, nenyanga yoke kaKhukhula yaba yiNyanga yamaGugu.&lt;ref name=&quot;:0&quot;&gt;Kids Encyclopedia Britannica (2025) ''Heritage Day.'' Retrieved from: https://kids.britannica.com/kids/article/Heritage-Day/602049 Retrieved on 30/09/25&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;African Travel Canvas (Sep 13, 2021) ''National Heritage Day in South Africa: What is Heritage Day and Why Do We Celebrate It.'' Retrieved from: https://africantravelcanvas.com/news/national-heritage-day-in-south-africa-what-is-heritage-day-and-why-do-we-celebrate-it/. Retrieved on 30/09/2025.&lt;/ref&gt;

ILanga lamaGugu lathonywa ukugidingwa ngomhla ka-24 kuKhukhulamungu 1995. U-Atjhibhitjhobhu u-Emeritus Desmond Tutu wasebenzisa ibizo elithi &quot;''Rainbow Nation&quot;''  ukuhlathulula ngendlela amasiko, umlando, amalimi wethu okuhlukahluke ngayo. Ngilokho-ke iLanga lamaGugu elikugidingako. UmNyango wezobuKghwari namaSiko uhlela imihlangano nezenzakalo zaqobe mnyaka zokugidinga iLanga lamaGugu, bese ukhetha nendlela yokuligidingela. Amagugu angahlathululwa ngalokho esinye nesinye isitjhaba enarheni esithi nasikwenzako kusenze sikhumbule indabuko yaso. Lokhu kuhlanganisa ubuhle benarha bemvelo, iindawo zezesayensi namkha zomlando ezisikhumbuzo, amatje wesikhumbuzo, imakhiwo engokomlando, ubukghwari, iincwadi, umbhino, okucocwa ngomlomo namamiziyamu.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt; 

== Ukuqakatheka Kokugidinga INyanga YamaGugu ==
Njengombana amaSewula Afrika wendabuko akhe abuswa mBuso weBandlululo, omunye wemigomo yawo bekukuthi abantu bendabuko bakhohlwe ngomlando wabo, amasikwabo nezici ezenza babe ngibo khona bazokulawuleka. Kwathi bona uwe umBuso webandlululo, urhulumende omutjha wathoma ijima lokuthi ubuyisele isithunzi sabantu bendabuko eSewula Afrika ngokugidinga iNyanga yamaGugu. Ukugidinga isenzakalwesi kungenza umuntu azikhakhazise ngesikhabo, amasiko, ilimi, ubukghwari nombhino wesikhabo. Bese lokho kwenze inarha ibe nabantu abayaziko imveliphi yabo namasiko wabo, okwenza abantu bahlalisane ngokuthula enarheni, bamukelane bona bahlukile endabukweni yabo. Kuphinde kuthuthukise umnotho wenarha.&lt;ref&gt;South African Government (2013) ''Heritage Day.'' Retrieved from: https://www.gov.za/news/events/commemorative-events/heritage-day. Retrieved on 30/09/25.&lt;/ref&gt; 

== Iinkhombo ==</text>
      <sha1>exrldsbbminc64dc7sjxs73p29kkkif</sha1>
    </revision>
    <revision>
      <id>5948</id>
      <parentid>5864</parentid>
      <timestamp>2025-11-06T10:22:47Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>Replaced content with &quot;== Draft Space 2 ==  == INyanga YamaGugu ==&quot;</comment>
      <origin>5948</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="43" sha1="rcay77dpz9iieuj0gn5gufowy2lkgz5" xml:space="preserve">== Draft Space 2 ==

== INyanga YamaGugu ==</text>
      <sha1>rcay77dpz9iieuj0gn5gufowy2lkgz5</sha1>
    </revision>
    <revision>
      <id>5949</id>
      <parentid>5948</parentid>
      <timestamp>2025-11-06T10:23:06Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>5949</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="19" sha1="dlolxaqvj8l6x19oda12qyxaucrvcj7" xml:space="preserve">== Draft Space 2 ==</text>
      <sha1>dlolxaqvj8l6x19oda12qyxaucrvcj7</sha1>
    </revision>
    <revision>
      <id>6126</id>
      <parentid>5949</parentid>
      <timestamp>2026-01-14T17:07:31Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>New article</comment>
      <origin>6126</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3618" sha1="kiich92abnm7liedqb3g67hc5zssujh" xml:space="preserve">== Draft Space 2 ==
== U-Jan Van Riebeeck ==
[[Isimumathi:Jan van Riebeeck cropped.jpg|thumb|U-Jan Van Riebeeck]]
Kuhlekuhle bekungasikokuthoma amaDatjhi afika ngo-1652. Bakhe bafika okokuthoma ngenyanga kaNtaka ngo-1647 bakhamba ngomkhumbi obizwa bona yi-''Nieuwe Haarlem''. Umkhumbi lo wafika waphahlazeka eKapa. Abasinda emkhunjini lowo bafika bakha indawo abayibiza bona yi-''Sand Fort of the Cape of Good Hope.'' Bahlala lapho pheze umnyaka woke. Ekugcineni kwafika imikhumbi eli-12 ebeyidoswa phambili ngu-W.G de Jong. Komunye wemikhumbi le bekunendoda ebizwa bona ngu-Jan Van Riebeeck.&lt;ref name=&quot;:1&quot;&gt;Marco Ramerini, English text by Dietrich Köster (January, 11 2014), ''The Dutch in South Africa, 1652-1795 and 1802-1806.'' Retrieved from https://www.colonialvoyage.com/dutch-south-africa/. Retrieved on 03/01/2026.&lt;/ref&gt;&lt;ref name=&quot;:2&quot;&gt;South African History Online (17 October 2011), ''Jan van Riebeeck.'' Retrieved from: https://sahistory.org.za/people/jan-van-riebeeck. Retreived on 03/01/2026.&lt;/ref&gt;

UJan Van Riebeeck (U-''Johan Anthoniszoon &quot;Jan&quot; Van Riebeeck'') wabelethwa ngomhla ka-21 kuSihlabantangana 1619 e-Culemborg, e-Netherlands abelethwa nguyise ungodorhodere ohlinzako. Wakhulela e-Schiedam, e-Netherlands, kwathi ngomhla wama-28 kuNtaka 1649, watjhada u-''Maria de la Queillerie'', waba nabantwana ababunane naye.&lt;ref name=&quot;:2&quot; /&gt;

U-Jan Van Riebeeck waba lilunga le-''Dutch East India Company'' (''Vereenigde Oost-Indische Compagnie'' -  VOC) ngo-1639 lapha athoma khona ukuba msizi kadorhodere ohlinzako ekhambeni labo lokuya e-Batavia (namhlanjesi eyaziwa nge-Jakarta) ngenyanga kaSihlabantangana 1639 bese batjhinga e-Nagasaki eJapani ngo-1643.&lt;ref name=&quot;:2&quot; /&gt;

Ngo-1645 u-Jan Van Riebeeck wanikelwa isabelo sokuba mphathi wesitetjhi sokurhwebela se-VOC ebesise-Tongkin e-''French Indochina'' (namhlanjesi eyaziwa nge-Vietnam). Wehliswa esikhundleneso ngebanga lokuthi besele azenzela irhwebo lakhe langeqadi, okuphula umthetho wekhamphani othi abaphathi akukafuzi bazenzele irhwebo ngeqadi ngepahla yekhamphani. Kwathi bona ehliswe esikhundleni, wazithola sele kufuze abuyele emva e-Netherlands ayoqalana nemilandu yakhe. Ngikho-ke besele atholakala komunye wemikhumbi eli-12 ebeyidoswa phambili ngu-W.G de Jong. Wafika e-''Table Bay'' hlanu kwe-''Cape of Good Hope'' wahlala khona amalanga ali-18. Lokho kwamnikela isikhathi sokuqalisisa indawo, nokucabanga bona angayisebenzisa njani ekwenzeni bona i-VOC imthembe godu. Wayibona iyindawo enganikela ngokudla namanzi kabakhamba ngemikhumbi.&lt;ref name=&quot;:2&quot; /&gt;

Njengombana umkhumbi i-''Nieuwe Haerlem'' waphahlazeka ngo-1647, abasindileko bakha indawo lapho, u-Jan Van Riebeeck walemuka indlela ebebarhwebelana ngayo namaKhoikhoi njengombana balinde ukutakulwa. Ngemva kwalokho-ke watlola umbiko ngendawo le nangakho koke akubonileko, bewahlongoza bona indawo le ingaba yindawo ehle khulu i-VOC engayisebenzisa. Umbiko lo watlolwa ngo-1648 wathunyelwa ekhamphanini. Kwathi ngo-1651 i-VOC yathatha isiqunto sokuthi indawo ye-''Cape of Good Hope'' ayisetjenziselwe iminqopho yekhamphani.&lt;ref name=&quot;:2&quot; /&gt;

I-VOC yakhetha yena u-Jan Van Riebeeck bona kube nguye umdosiphambili ozokuhloma isitetjhi sokuphumula semikhumbi yamaDatjhi khona izokuthola ukudla okutjha okunepilo namanzi ahlanzekileko. Kwaba kusuka kwakhe-ke u-Jan Van Riebeeck, asuka e-Texel, e-Netherlands ngomhla wama-24 kuNobayeni 1651 bewayokufika e-''Table Bay'' ngomhla wesi-6 kaSihlabantangana 1652.&lt;ref name=&quot;:2&quot; /&gt; Bafika bakhamba ngemikhumbi emihlanu - i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch''.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;</text>
      <sha1>kiich92abnm7liedqb3g67hc5zssujh</sha1>
    </revision>
    <revision>
      <id>6129</id>
      <parentid>6126</parentid>
      <timestamp>2026-01-16T11:26:37Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>edited</comment>
      <origin>6129</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9908" sha1="rwhd307mwzh5n0gkgbpgyvnr2qg6499" xml:space="preserve">== Draft Space 2 ==
== U-Jan Van Riebeeck ==
[[Isimumathi:Jan van Riebeeck cropped.jpg|thumb|U-Jan Van Riebeeck]]
UJan Van Riebeeck (U-''Johan Anthoniszoon &quot;Jan&quot; Van Riebeeck'') wabelethwa ngomhla ka-21 kuSihlabantangana 1619 e-Culemborg, e-Netherlands abelethwa nguyise ungodorhodere ohlinzako. Wakhulela e-Schiedam, e-Netherlands, kwathi ngomhla wama-28 kuNtaka 1649, watjhada u-''Maria de la Queillerie'', waba nabantwana ababunane naye.&lt;ref name=&quot;:2&quot;&gt;South African History Online (17 October 2011), ''Jan van Riebeeck.'' Retrieved from: https://sahistory.org.za/people/jan-van-riebeeck. Retreived on 03/01/2026.&lt;/ref&gt;

U-Jan Van Riebeeck waba lilunga le-''Dutch East India Company'' (''Vereenigde Oost-Indische Compagnie'' -  VOC) ngo-1639 lapha athoma khona ukuba msizi kadorhodere ohlinzako ekhambeni labo lokuya e-Batavia (namhlanjesi eyaziwa nge-Jakarta) ngenyanga kaSihlabantangana 1639 bese batjhinga e-Nagasaki eJapani ngo-1643.&lt;ref name=&quot;:2&quot; /&gt;
[[Isimumathi:Maria Quevellerius (1629-64), eerste vrouw van Jan van Riebeeck, of diens tweede vrouw Maria Scipio (ca. 1630-95) Rijksmuseum SK-A-806.jpeg|thumb|Umka-Jan Van Riebeeck, u-Maria Quevellerius]]
Ngo-1645 u-Jan Van Riebeeck wanikelwa isabelo sokuba mphathi wesitetjhi sokurhwebela se-VOC ebesise-Tongkin e-''French Indochina'' (namhlanjesi eyaziwa nge-Vietnam). Wehliswa esikhundleneso ngebanga lokuthi besele azenzela irhwebo lakhe langeqadi, okuphula umthetho wekhamphani othi abaphathi akukafuzi bazenzele irhwebo ngeqadi ngepahla yekhamphani. Kwathi bona ehliswe esikhundleni, wazithola sele kufuze abuyele emva e-Netherlands ayoqalana nemilandu yakhe. Ngikho-ke besele atholakala komunye wemikhumbi eli-12 ebeyidoswa phambili ngu-W.G de Jong. Wafika e-''Table Bay'' hlanu kwe-''Cape of Good Hope'' wahlala khona amalanga ali-18. Lokho kwamnikela isikhathi sokuqalisisa indawo, nokucabanga bona angayisebenzisa njani ekwenzeni bona i-VOC imthembe godu. Wayibona iyindawo enganikela ngokudla namanzi kabakhamba ngemikhumbi.&lt;ref name=&quot;:2&quot; /&gt;

Njengombana umkhumbi i-''Nieuwe Haerlem'' waphahlazeka ngo-1647, abasindileko bakha indawo lapho, u-Jan Van Riebeeck walemuka indlela ebebarhwebelana ngayo namaKhoikhoi njengombana balinde ukutakulwa. Ngemva kwalokho-ke watlola umbiko ngendawo le nangakho koke akubonileko, bewahlongoza bona indawo le ingaba yindawo ehle khulu i-VOC engayisebenzisa. Umbiko lo watlolwa ngo-1648 wathunyelwa ekhamphanini. Kwathi ngo-1651 i-VOC yathatha isiqunto sokuthi indawo ye-''Cape of Good Hope'' ayisetjenziselwe iminqopho yekhamphani.&lt;ref name=&quot;:2&quot; /&gt;

I-VOC yakhetha yena u-Jan Van Riebeeck bona kube nguye umdosiphambili ozokuhloma isitetjhi sokuphumula semikhumbi yamaDatjhi khona izokuthola ukudla okutjha okunepilo namanzi ahlanzekileko. Kwaba kusuka kwakhe-ke u-Jan Van Riebeeck, asuka e-Texel, e-Netherlands ngomhla wama-24 kuNobayeni 1651 bewayokufika e-''Table Bay'' ngomhla wesi-6 kaSihlabantangana 1652.&lt;ref name=&quot;:2&quot; /&gt; Bafika bakhamba ngemikhumbi emihlanu - i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch''.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot;&gt;Marco Ramerini, English text by Dietrich Köster (January, 11 2014), ''The Dutch in South Africa, 1652-1795 and 1802-1806.'' Retrieved from https://www.colonialvoyage.com/dutch-south-africa/. Retrieved on 03/01/2026.&lt;/ref&gt;

== Ukufika Kwakhe EKapa ==
[[Isimumathi:Jan van Riebeeck .jpg|thumb|280x280px|Ukufika kuka-Jan Van Riebeeck eKapa]]
U-Jan Van Riebeeck wasuka ngomhla wama-24 kuNobayeni 1651 e-Texel, e-Netherlands, wafika ngomhla wesi-6 kaSihlabantangana 1652.&lt;ref name=&quot;:22&quot;&gt;South African History Online (17 October 2011), ''Jan van Riebeeck.'' Retrieved from: https://sahistory.org.za/people/jan-van-riebeeck. Retreived on 03/01/2026.&lt;/ref&gt; Bafika bakhamba ngemikhumbi emihlanu - i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch.&lt;ref name=&quot;:02&quot;&gt;South African History Online (13 January 2024) ''The Dutch Settlement.'' Retrieved from: https://sahistory.org.za/article/dutch-settlement Retrieved on 01/01/2026.&lt;/ref&gt;&lt;ref name=&quot;:12&quot;&gt;Marco Ramerini, English text by Dietrich Köster (January, 11 2014), ''The Dutch in South Africa, 1652-1795 and 1802-1806.'' Retrieved from https://www.colonialvoyage.com/dutch-south-africa/. Retrieved on 03/01/2026.&lt;/ref&gt;'' Emithathu le ngiyo eyafika qangi, ngikho kwaziwa khulu le emithathu, le eminye imikhumbi emibili yafika mva. Ekufikeni kwakhe nabantu ebekakhamba nabo ngemikhumbi le wafika wakha indawo yobuphephelo ebizwa bona yi-''Fort de Goede Hoop (Fort of Good Hope).'' Bafika batjala endaweni leyo, kodwana iintjalo zabo khenge zitlhurhe kuhle, mhlamunye ngebanga lobujamo bezulu obungafani nobe-Netherlands, netjharagano ebeliphakathi kwamadoda ebekakhamba nawo nakufuze basebenze batlhgomele imikhumbu edlulako. Abantu bebabancani umsebenzi umnengi.&lt;ref name=&quot;:22&quot; /&gt;

Kwathi ngo-1655 u-Van Riebeeck wabika bona ngaphandle kwabantu abazimisele ukusebenza emasimini, isitetjhesi sizokubhalelwa ukwenza umsebenzi esihloselwe wona. Kwathi ngo-1657, i-VOC yathumela abalimi ababhadelwako, ngombandela wokuthi balime inarha bebathengisele ikhamphani iintjalo abazilimileko. Ngibo laba ebebabizwa bona ma-''Free Burghers (Vry Burgers)''. U-Jan Van Riebeeck wathatha isikhathi sakhe soke atjala bekakhiqiza amagrepsi, ama-apula namazambana, ukudla okuzokuba lisizo khulu emikhumbini edlulako. Kwathi ngo-1659 besele anesivuno samagrepsi ebesikhiqiza iwayini elibovu elilwisana nobulwele be-''scurvy,'' njengombana besele alemukile bona ukusela iwayini kuyabuvikela ubulwelobu ngokwezinga elithileko.&lt;ref name=&quot;:22&quot; /&gt;

Endabeni yokurhwebelana, zoke izinto ebezenzeka u-Jan Van Riebeeck wazitlola emajenalini wakhe. AmaDatjhi bewathenga iinkomo nezimvu kuma-Khoekhoe ngepahla ehlukahlukeneko kuhlanganise notjwala negwayi. Bese inyama yefuyo le idliwe, enye ithengiselwe abantu abadlula ngemikhumbi yekhamphani.&lt;ref name=&quot;:5&quot;&gt;Steemit Website (2018) ''SOUTH AFRICAN HISTORY: Autshumato translator and first Postmaster of The Cape of Good Hope''. Retrieved from: https://steemit.com/history/@krabgat/south-african-history-autshumato-translator-and-first-postmaster-of-the-cape-of-good-hope. Retrieved on 14/01/2026.&lt;/ref&gt;

Kwathi ngenyanga kaSewula wango-1653 kwaba nokurhitjhana phakathi kuka-Autshumato, umdosiphambili wesitjhaba sama-Khoekhoe ama-''Gorinhaikona,'' nomelusi weenkomo zika-Van Riebeeck u-David Jansz. U-Autshumato wambulala wathatha iinkomo. Ukurhitjhanokhu kuthoma nje, iintjhaba ezimbili lezi besele zingasathelelani kuhle amanzi. AmaDatjhi besele aqala u-Autshumato nabantu bakhe njengamasela. U-Jan Van Riebeeck wathi u-Autshumato lisela elinelimi elibutjhelelezi. Ama-Khoekhoe aqala amaDatjhi njengabakhohlisi ngokuthi intengo yotjwala negwayi ayilingani nentengo yesilwana esifuywako. Bebathi bangabusela utjwala buphele, babone ifuywabo emadlelweni wamaDatjhi, yanda. Bese amaKhoekhoe akhambe ayoyeba.&lt;ref&gt;Castle of Good Hope (''13th November 2018'') ''Interpreters' Flawed Contracts With Dutch''Retrieved from: https://www.castleofgoodhope.co.za/index.php/news/100-news/142-interpreters-flawed-contracts-with-dutch. Retrieved on 14/01/2026.&lt;/ref&gt;

Isenzakalo sokubulawa kuka-David Jansz sasusa ipi phakathi kwama-Khoe namaDatjhi. U-Van RieBeeck wathi u-Autshumato unomlandu wokubulala. Yeke kwaliwa ipi, ekugcineni ama-Khoe ahlulwa. U-Autshumato wabanjwa wasiwa ekuthunjweni e-''Robben Island'' ngawo umnyaka ka-1653. Kodwana ngo-1655 watjhatjululwa wabuyiswa enarheni.  Nakafikako u-Jan Van Riebeeck wamamukela wambuyisela esikhundleni sakhe sokutologa.&lt;ref name=&quot;:5&quot; /&gt;  Ngesikhathesi u-Autshumato besele azwisisa indlela amaYurobhu arhweba ngayo nendlela yokuzuza kiyo. Bekathi nakarhwebela u-Jan Van Riebeeck iinkomo, aqiniseke bona imbadelo yekhamphani yanele bona ingabhadela neenkomo azithengela zona yena, ngikho nje aba mumuntu oregileko eKapa.&lt;ref name=&quot;:5&quot; /&gt;

Ngokukhamba kwesikhathi kwaba nokhunye godu ukurhitjhana phakathi kwama-Khoekhoe namaDatjhi ngo-1657. Ukurhitjhanokhu kubangwa kungazwani kwama-''Free Burghers (Vry Burgers)''  neengqila ze-Madagascar.  U-Jan Van Riebeeck wakateleleka bona akhe isivikelo endaweni leyo, bona enze ama-Khoekhoe asuke endaweni leyo. Bekuthi ezinye iingqila naziphunyurhako asebenzise u-Autshumato njengesithunjwa ukuhlohlozela ama-Khoe bona akhambe ayokubamba iingqilezo. Kodwana iqhinga lika-Van Riebeeck khenge liphumelele ngendlela afuna ngayo. Kwathi ngo-1658 u-Autshumato wabanjwa, wathathelwa yoke ifuywakhe. Ngemva kokutjhutjhiswa wathunjwa wasiwa e-''Robben Island'' godu. Kodwana wathi nakalapho waphunyurha ngesikepe esivuzako. Bekube kunamhlanjesi, u-Autshumato nguye kwaphela umuntu okghone ukuphunyurha e-''Robben Island'' njengesibotjhwa. Kunokuthi nakabuyako enarheni abotjhwe, u-Van Riebeeck wambuyisela esikhundleni sakhe sokukhulumisana nokutologa.&lt;ref name=&quot;:5&quot; /&gt;&lt;ref name=&quot;:4&quot;&gt;Camissa Museum (2026) ''Autshumao (1610 - 1674)'', Retrieved from: https://camissamuseum.co.za/index.php/7-tributaries/1-cape-indigenous-africans/autshumao. Retrieved on 12/01/2026.&lt;/ref&gt;

== Ukufa Kwakhe ==
Ngomhla wobu-8 kuKhukhulamungu wango-1662 u-Jan Van Riebeeck wakhamba eKapa esesewula Afrika, watjhiya u-Zacharias Wagenaer bona kube nguye osala aphethe endaweni abakiyo eKapa. Wafika wahlala endaweni ebizwa bona yiMalacca namhlanjesi ebizwa bona yi-Melaka eseMalaysia, wahlala lapho bekwaba nguKhukhulamungu wango-1665. Umkakhe wahlongakala ngokubulawa bulwele bepokisi ngenyanga kaSinyikhaba ngo-1664. Ngemva kwalokho wabekwa esikhundleni sokuba ngu-''Governor-General-in-Council'' wenarha yeNdiya, begodu wahlala e-Batavia ipilwakhe yoke. Wahlongakala ngomhla we-18 kuTjhirhweni 1677.&lt;ref&gt;S2A3 Biographical Database of Southern African Science (2026)'''''Van Riebeeck,''' Commander '''Johan Antoniszoon''' (advancement of science).'' Retrieved from: https://www.s2a3.org.za/bio/Biograph_final.php?serial=2953. Retrieved on 16/01/2026.&lt;/ref&gt;

== Iinkhombo ==</text>
      <sha1>rwhd307mwzh5n0gkgbpgyvnr2qg6499</sha1>
    </revision>
    <revision>
      <id>6168</id>
      <parentid>6129</parentid>
      <timestamp>2026-02-16T15:56:47Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>New article</comment>
      <origin>6168</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3788" sha1="sx6f5of1iva6d9cgzxzuxmo6ivvw7ht" xml:space="preserve">== Draft Space 2 ==
== Ilanga le-''Valentine'' ==
[[Isimumathi:Antique Valentine 1909 01.jpg|thumb|Ikarada le-Valentine lango-1909]]
'''Ilanga le-Valentine''' lilanga elaziwa ngokuthi lilalanga leenthandani eligidingwa ephasini mazombe ngomhla we-14 kuMhlolanja. Lilanga lapho iinthandani eziphana khona izipho njengendlela yokutjengisana ithando. Abantu abanengi bakholelwa bona ilangelilasungulwa ngesikhathi kubulawa u-Saint Valentine, umphristi omKrestu ngebanga lokutjhadisa abantu abathandanako esiphirini embusweni weRoma. UmBuso weRoma bewalela amadoda bona atjhade ngebanga lokuthi kufuze aye epini. Yeke ukutjhadisa amadoda lawo bekuphambana nomthetho wamaRoma. Ngilokho-ke okwafaka u-Saint Valentine ekingeni, wagcina sele alahlekelwa nayipilwakhe. Kodwana zinengi izinto ezicatjangelwako emlandweni ezaba mthelela ekusungulweni kwelangeli.&lt;ref name=&quot;:0&quot;&gt;History.com (2026)''History of Valentine’s Day.'' Retrieved from: https://www.history.com/articles/history-of-valentines-day. Retrieved on 16/02/2026.&lt;/ref&gt; 

== Umlando Ka-Valentine ==
[[Isimumathi:Saint Valentine - facial reconstruction.jpg|thumb|Isithombe esakhwe kabutjha sika-Saint Valentine]]
Nanyana kunabantu abambalwa abamaKrestu ababulawelwa ukukholwa kwabo ababizwa ngabo-Valentine, ilangeli kungenzeka lasungulwa lisuselwa emphristini owabulawa ngo 270 AD, abulawa mbusi u-Claudius II Gothicus. Endabeni ecocwako, umphristi lo watlikitla incwadi ngokuthi &quot;ivela ku-Valentine wakho&quot; ayitlolela indodakazi yomuntu omfake ejele, ebesele amngani nayo, kokunye ukulandisa okuthiwa wayelapha bona ikghone ukubona ngombana beyiphophele. Kokunye ukulandisa kuthiwa ngu-St Valentine ombhitjhobhu ovela endaweni ye-Temi, okunguye ilangeli elibizwa ngaye, nanyana kungenzeka bona abantwaba bamumuntu munye. Omunye umlando uthi u-St Valentine khenge alalele umthetho wekosi, bewatjhadisa iinthandani esiphirini, okwenza bona amadoda atjhadileko angayi epini. Kwathi bona atholakale, wagwetjelwa ukufa. Kungenzeka ngilesi sizathu ilangeli lihlobene nethando kangaka.&lt;ref&gt;Britannica (2026) ''Valentines Day.'' Retrieved from: https://www.britannica.com/topic/Valentines-Day. Retrieved on 16/02/2026.&lt;/ref&gt; 

== Umlando Womnyanya WamaRoma ==
Eqinisweni, amaRoma asabusa, bekunomnyanya wamaRoma ebewubizwa bona mNyanya ka-Lupercalia. Amadoda bekahlaba imbuzi nenja, bomise iinkhumba zazo, bese bayazisika zibe mimitja. Amadoda ngelangelo bekagijima endleleni bese barithe abafazi ngemitja yeenkhumbezo. Umnyanya lo bewenziwa ngomhla we-13 kuya ngowe-15 kuMhlolanja. Ngalesosikhathi kuthiwa abafazi bebakuthanda ukurithwa ngeenkhumbezi ngombana bebakholelwa ukuthi bazokuba nembeleko emnyakeni olandelako.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot;&gt;Arnie Seipel (14 February 2022) ''The dark origins of Valentine's Day,'' NPR. Retrieved from: https://www.npr.org/2011/02/14/133693152/the-dark-origins-of-valentines-day. Retreived on 16/02/2026.&lt;/ref&gt; 

Ngokuka-Noel Lenski, onguphrofesa weemfundo zezekolo e-Yale University, atjela i-NPR ngo-2011, uthi amaRoma 'bewasela adakwe, abe hlubule.' Abafazi bebajama babe mjeje, bajamele bona amadoda abarithe ngemitja yesikhumba seenlwana.&lt;ref name=&quot;:1&quot; /&gt; Umnyanya lowo bewuphetha ngekatho eyenziwa madoda, ngokukhetha amagama wabafazi angaphakathi emjekeni. Umfazi omkhethileko uzokuthandana naye emnyanyeni loyo kwaphela, namkha isikhathi eside nangabe niyakhambelana.&lt;ref name=&quot;:1&quot; /&gt;

Nanyana amaKrestu andlondlobala, umnyanya lo bewusolo ukhona bekwafika lapha kuthiwa khona umnyanya lo awusiwo wobuKrestu, ekugcineni kweminyaka yama-500 AD, lokha uPapa u-Gelasius aqunta bona umhla we-14 kaMhlolanja sele kulilanga okuzokugidingwa ngalo u-St Valentine. Nanyana kunjalo kwakhamba iminyaka eminengi khulu ngaphambi kobana ilangeli lihlotjaniswe nethando.&lt;ref name=&quot;:0&quot; /&gt;

== Iinkhombo ==</text>
      <sha1>sx6f5of1iva6d9cgzxzuxmo6ivvw7ht</sha1>
    </revision>
    <revision>
      <id>6230</id>
      <parentid>6168</parentid>
      <timestamp>2026-02-21T13:02:24Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>edited</comment>
      <origin>6230</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3789" sha1="22p7zdh4s557y5xc7qdgzv5jtz0flk8" xml:space="preserve">== Draft Space 2 ==
== Ilanga le-''Valentine'' ==
[[Isimumathi:Antique Valentine 1909 01.jpg|thumb|Ikarada le-Valentine lango-1909]]
'''Ilanga le-Valentine''' lilanga elaziwa ngokuthi lilalanga leenthandani eligidingwa ephasini mazombe ngomhla we-14 kuMhlolanja. Lilanga lapho iinthandani eziphana khona izipho njengendlela yokutjengisana ithando. Abantu abanengi bakholelwa bona ilangelilasungulwa ngesikhathi kubulawa u-Saint Valentine, umphristi omKrestu ngebanga lokutjhadisa abantu abathandanako esiphirini embusweni weRoma. UmBuso weRoma bewalela amadoda bona atjhade ngebanga lokuthi kufuze aye epini. Yeke ukutjhadisa amadoda lawo bekuphambana nomthetho wamaRoma. Ngilokho-ke okwafaka u-Saint Valentine ekingeni, wagcina sele alahlekelwa nayipilwakhe. Kodwana zinengi izinto ezicatjangelwako emlandweni ezaba mthelela ekusungulweni kwelangeli.&lt;ref name=&quot;:0&quot;&gt;History.com (2026)''History of Valentine’s Day.'' Retrieved from: https://www.history.com/articles/history-of-valentines-day. Retrieved on 16/02/2026.&lt;/ref&gt;  

== Umlando Ka-Valentine ==
[[Isimumathi:Saint Valentine - facial reconstruction.jpg|thumb|Isithombe esakhwe kabutjha sika-Saint Valentine]]
Nanyana kunabantu abambalwa abamaKrestu ababulawelwa ukukholwa kwabo ababizwa ngabo-Valentine, ilangeli kungenzeka lasungulwa lisuselwa emphristini owabulawa ngo 270 AD, abulawa mbusi u-Claudius II Gothicus. Endabeni ecocwako, umphristi lo watlikitla incwadi ngokuthi &quot;ivela ku-Valentine wakho&quot; ayitlolela indodakazi yomuntu omfake ejele, ebesele amngani nayo, kokunye ukulandisa okuthiwa wayelapha bona ikghone ukubona ngombana beyiphophele. Kokunye ukulandisa kuthiwa ngu-St Valentine ombhitjhobhu ovela endaweni ye-Temi, okunguye ilangeli elibizwa ngaye, nanyana kungenzeka bona abantwaba bamumuntu munye. Omunye umlando uthi u-St Valentine khenge alalele umthetho wekosi, bewatjhadisa iinthandani esiphirini, okwenza bona amadoda atjhadileko angayi epini. Kwathi bona atholakale, wagwetjelwa ukufa. Kungenzeka ngilesi sizathu ilangeli lihlobene nethando kangaka.&lt;ref&gt;Britannica (2026) ''Valentines Day.'' Retrieved from: https://www.britannica.com/topic/Valentines-Day. Retrieved on 16/02/2026.&lt;/ref&gt; 

== Umlando Womnyanya WamaRoma ==
Eqinisweni, amaRoma asabusa, bekunomnyanya wamaRoma ebewubizwa bona mNyanya ka-Lupercalia. Amadoda bekahlaba imbuzi nenja, bomise iinkhumba zazo, bese bayazisika zibe mimitja. Amadoda ngelangelo bekagijima endleleni bese barithe abafazi ngemitja yeenkhumbezo. Umnyanya lo bewenziwa ngomhla we-13 kuya ngowe-15 kuMhlolanja. Ngalesosikhathi kuthiwa abafazi bebakuthanda ukurithwa ngeenkhumbezi ngombana bebakholelwa ukuthi bazokuba nembeleko emnyakeni olandelako.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot;&gt;Arnie Seipel (14 February 2022) ''The dark origins of Valentine's Day,'' NPR. Retrieved from: https://www.npr.org/2011/02/14/133693152/the-dark-origins-of-valentines-day. Retreived on 16/02/2026.&lt;/ref&gt; 

Ngokuka-Noel Lenski, onguphrofesa weemfundo zezekolo e-Yale University, atjela i-NPR ngo-2011, uthi amaRoma 'bewasela adakwe, abe hlubule.' Abafazi bebajama babe mjeje, bajamele bona amadoda abarithe ngemitja yesikhumba seenlwana.&lt;ref name=&quot;:1&quot; /&gt; Umnyanya lowo bewuphetha ngekatho eyenziwa madoda, ngokukhetha amagama wabafazi angaphakathi emjekeni. Umfazi omkhethileko uzokuthandana naye emnyanyeni loyo kwaphela, namkha isikhathi eside nangabe niyakhambelana.&lt;ref name=&quot;:1&quot; /&gt;

Nanyana amaKrestu andlondlobala, umnyanya lo bewusolo ukhona bekwafika lapha kuthiwa khona umnyanya lo awusiwo wobuKrestu, ekugcineni kweminyaka yama-500 AD, lokha uPapa u-Gelasius aqunta bona umhla we-14 kaMhlolanja sele kulilanga okuzokugidingwa ngalo u-St Valentine. Nanyana kunjalo kwakhamba iminyaka eminengi khulu ngaphambi kobana ilangeli lihlotjaniswe nethando.&lt;ref name=&quot;:0&quot; /&gt;

== Iinkhombo ==</text>
      <sha1>22p7zdh4s557y5xc7qdgzv5jtz0flk8</sha1>
    </revision>
    <revision>
      <id>6485</id>
      <parentid>6230</parentid>
      <timestamp>2026-04-28T09:21:20Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>Replaced content with &quot;== Draft Space 2 ==&quot;</comment>
      <origin>6485</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="19" sha1="dlolxaqvj8l6x19oda12qyxaucrvcj7" xml:space="preserve">== Draft Space 2 ==</text>
      <sha1>dlolxaqvj8l6x19oda12qyxaucrvcj7</sha1>
    </revision>
    <revision>
      <id>6486</id>
      <parentid>6485</parentid>
      <timestamp>2026-04-28T12:36:31Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>New article</comment>
      <origin>6486</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3870" sha1="jjew2amx9p1f4uemlyzpz7o2dml7ekj" xml:space="preserve">== Draft Space 2 ==

== U-Peter Van Meerhof ==
'''U-Pieter van Meerhof''' wabelethelwa e-Copenhagen, e-Denmark. Wafika eKapa ngomkhumbi ebewubizwa bona yi-''Princess van Royael.'' Bekamumuntu othanda ukukhamba iphasi begodu bekangudorhodere ohlinzako. Usebenzile njengomnqophisi wesihlengehlenge i-Robben Island. Ngemva kwalokho wakhamba nomkhumbi ebewuthwele iingqila i-''Westwout.'' Wabulawa ejimeni lokubuthelela iingqila e-Antogil Bay e-Madagascar elenzeka ngaphambi kwangomhla wa-27 kaMhlolanja 1668. Umkhumbi wabo lo wafika eKapa ngomhla wama-30 kaKhukhulamungu 1668. ESewula Afrika waziwa ngokutjhada kwakhe no-[[U-Krotoa|Krotoa]] (namkha u-Eva) ongowesitjhaba sama-Goringhaikona ngomhla wama-26 kaSihlabantangana 1664, u-Krotoa owakhulela emzini womphathi [[u-Jan Van Riebeeck]].&lt;ref name=&quot;:0&quot;&gt;Stamouers  (30 November 1999) ''Pieter van Meerhof,'' Stamouers Website. Retrieved from: https://www.stamouers.com/stamouers/surnames-v-z/549-van-meerhof-ieter. Retrieved on 28/04/2026.&lt;/ref&gt;

== Imvelaphi Ka-Pieter van Meerhof ==
U-Pieter Van Meerhof, ibizo lakhe lesiDenitjhi bekungu-Peder Havgaard, amaBhuru balitjhugululela esiBhurwini laba ngu-Pieter Van Meerhof. Uyindodana ka-Aug no-Marie Ede, ebebavela e-Havgaard, kodwana bahlala eplasini esihlengehlengeni esibizwa bona yi-Langeland. Iplaselo lisesekhona nanamhlanjesi begodu isibongo sakwa-Havgaard sisesekhona. Kungenzeka wabelethwa ngabo-1636, e-Copenhagen, e-Denmark, ayindodana ka-Aug Ede. U-Pietre bekamumuntu obekathanda ukukweriyela kezinye iinarha, begodu angudorhodere ohlinzako. Wafika eKapa ngomkhumbi ebewubizwa bona yi-''Princess van Royael.''&lt;ref&gt;FamilySearch (2026) ''Pieter Van Meerhof.'' Retrieved from: https://ancestors.familysearch.org/en/M1G4-H34/pieter-van-meerhof-1636-1668. Retrieved on 28/04/2026.&lt;/ref&gt; 

== Ukutjhada Kwakhe No-Krotoa ==
[[Isimumathi:Krotoa.webp|thumb|U-Krotoa]]
Ngomhla wama-26 kaSihlabantangana 1664, kwamenyezelwa bona u-Pieter no-Krotoa (Eva) bathembisene umtjhado. Isaziswesi seza ngemva kobana u-Van Meerhof afike eKapa okwesithandathu. Bobabili batjhada ngomhla wesi-2 kaMgwengweni 1664, emzini ka-Zacharias Wagenaer, umphathi wabo wangalesosikhathi. IKhamphani (i-VOC), ebeyikuthanda ukuzihlanganisa nama-Khoikhoi, ngiyo eyalobolela u-Pieter ngelobolo elikhulu. Umphathi wedayari ka-Wagenaer watlola kiyo bona &quot;Lo mtjhado wokuthoma owatloliswa ngokuhlanganisa isiKrestu nesintu sendabuko.&quot; AmaDatjhi bebangathathelani nabantu balapho bendabuko bekwaba ngemva kweminyala eli-12 ngemva kokufika kuka-Van Riebeeck eKapa.&lt;ref name=&quot;:1&quot;&gt;South African History Online (17 February 2011) ''Krotoa (Eva)''. Retrieved from: https://sahistory.org.za/people/krotoa-eva. Retrieved on 28/04/2026.&lt;/ref&gt; 

Ngemva komnyaka, u-Krotoa no-Van Meerhof baba nabantwana ababili, bakhamba bayokuhlala esihlengehlengeni se-Robben Island. U-Pieter wabekwa bona abe mnqophisi wendawo leyo. Umsebenzi wakhe bekususa iinyoka, iinswebo nezinye iinlwana ezitshwenyako. Kwathi ngomnyaka wango-1666 babeletha umntwana wesithathu. Babuyela enarheni bona bayombhabhadisa.&lt;ref name=&quot;:1&quot; /&gt; Kubonakala kwanga ube nabantwana  ababili ngaphandle komtjhadwakhe.&lt;ref name=&quot;:0&quot; /&gt;

Napa abantwana baka-Pieter:&lt;ref name=&quot;:0&quot; /&gt;

* U-Jacobus owabelethwa ngo-1661 wahlongakala ngo-1685 emkhumbini obuya e-Mauritius
* U-Pieternella owabelethwa ngo-1663
* U-Salamon owabhatjhadiswa ngomhla woku-1 kuKhukhulamungu 1666
* U-Jeronimus owabhatjhadiswa ngomhla wama-23 kaSinyikhaba1670 (Amthole ngaphandle komtjhado)
* U-Anthonij owabhatjhadiswa ngomhla wesi-6 kaRhoboyi1673 (Amthole ngaphandle komtjhado)

Ngemva kwalokho watjhinga eMadacascar, wakhamba nomkhumbi ebewuthwele iingqila i-''Westwout.'' Wabulawa ejimeni lokubuthelela iingqila e-Antogil Bay e-Madagascar elenzeka ngaphambi kwangomhla wa-27 kaMhlolanja 1668. Umkhumbi wabo lo wafika eKapa ngomhla wama-30 kaKhukhulamungu 1668.

== Iinkhombo ==</text>
      <sha1>jjew2amx9p1f4uemlyzpz7o2dml7ekj</sha1>
    </revision>
    <revision>
      <id>6487</id>
      <parentid>6486</parentid>
      <timestamp>2026-04-28T13:01:30Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>6487</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3901" sha1="r0g7uzj4vq45o1vdvbu7nysx4knnttf" xml:space="preserve">== Draft Space 2 ==

== U-Peter Van Meerhof ==
'''U-Pieter van Meerhof''' wabelethelwa e-Copenhagen, e-Denmark. Wafika eKapa ngomkhumbi ebewubizwa bona yi-''Princess van Royael.'' Bekamumuntu othanda ukukhamba iphasi begodu bekangudorhodere ohlinzako. Usebenzile njengomnqophisi wesihlengehlenge i-Robben Island. Ngemva kwalokho wakhamba nomkhumbi ebewuthwele iingqila i-''Westwout.'' Wabulawa ejimeni lokubuthelela iingqila e-Antogil Bay e-Madagascar elenzeka ngaphambi kwangomhla wa-27 kaMhlolanja 1668. Umkhumbi wabo lo wafika eKapa ngomhla wama-30 kaKhukhulamungu 1668. ESewula Afrika waziwa ngokutjhada kwakhe no-[[U-Krotoa|Krotoa]] (namkha u-Eva) ongowesitjhaba sama-Goringhaicona ngomhla wama-26 kaSihlabantangana 1664, u-Krotoa owakhulela emzini womphathi [[u-Jan Van Riebeeck]].&lt;ref name=&quot;:0&quot;&gt;Stamouers  (30 November 1999) ''Pieter van Meerhof,'' Stamouers Website. Retrieved from: https://www.stamouers.com/stamouers/surnames-v-z/549-van-meerhof-ieter. Retrieved on 28/04/2026.&lt;/ref&gt;

== Imvelaphi Ka-Pieter van Meerhof ==
U-Pieter Van Meerhof, ibizo lakhe lesiDenitjhi bekungu-Peder Havgaard, amaBhuru alitjhugululela esiBhurwini laba ngu-Pieter Van Meerhof. Uyindodana ka-Aug no-Marie Ede, ebebavela e-Havgaard, kodwana bahlala eplasini esihlengehlengeni esibizwa bona yi-Langeland. Iplaselo lisesekhona nanamhlanjesi begodu isibongo sakwa-Havgaard sisesekhona. Kungenzeka wabelethwa ngabo-1636, e-Copenhagen, e-Denmark, ayindodana ka-Aug Ede. U-Pietre bekamumuntu obekathanda ukukhamba avakatjhele kezinye iinarha, begodu angudorhodere ohlinzako. Wafika eKapa ngomkhumbi ebewubizwa bona yi-''Princess van Royael.''&lt;ref&gt;FamilySearch (2026) ''Pieter Van Meerhof.'' Retrieved from: https://ancestors.familysearch.org/en/M1G4-H34/pieter-van-meerhof-1636-1668. Retrieved on 28/04/2026.&lt;/ref&gt; 

== Ukutjhada Kwakhe No-Krotoa ==
[[Isimumathi:Krotoa.webp|thumb|U-Krotoa]]
Ngomhla wama-26 kaSihlabantangana 1664, kwamenyezelwa bona u-Pieter no-Krotoa (Eva) bathembisene umtjhado. Isaziswesi seza ngemva kobana u-Van Meerhof afike eKapa okwesithandathu. Bobabili batjhada ngomhla wesi-2 kaMgwengweni 1664, emzini ka-Zacharias Wagenaer, umphathi wamaDatjhi wangalesosikhathi. IKhamphani (i-VOC), ebeyikuthanda ukuzihlanganisa nama-Khoikhoi, ngiyo eyalobolela u-Pieter ngelobolo elikhulu. Umphathi wedayari ka-Wagenaer watlola kiyo bona &quot;Lo mtjhado wokuthoma owatloliswa ngokuhlanganisa isiKrestu nesintu sendabuko.&quot; AmaDatjhi bewangathathelani nabantu balapho bendabuko bekwaba ngemva kweminyala eli-12 ngemva kokufika kuka-Van Riebeeck eKapa.&lt;ref name=&quot;:1&quot;&gt;South African History Online (17 February 2011) ''Krotoa (Eva)''. Retrieved from: https://sahistory.org.za/people/krotoa-eva. Retrieved on 28/04/2026.&lt;/ref&gt; 

Ngemva komnyaka, u-Krotoa no-Van Meerhof baba nabantwana ababili, bakhamba bayokuhlala esihlengehlengeni se-Robben Island. U-Pieter wabekwa bona abe mnqophisi wendawo leyo. Umsebenzi wakhe bekususa iinyoka, iinswebu nezinye iinlwana ezitshwenyako. Kwathi ngomnyaka wango-1666 babeletha umntwana wesithathu. Babuyela enarheni bona bayombhabhadisa.&lt;ref name=&quot;:1&quot; /&gt; Kubonakala kwanga u-Pieter ube nabantwana  ababili ngaphandle komtjhadwakhe.&lt;ref name=&quot;:0&quot; /&gt;

Napa abantwana baka-Pieter:&lt;ref name=&quot;:0&quot; /&gt;

* U-Jacobus owabelethwa ngo-1661 wahlongakala ngo-1685 emkhumbini obuya e-Mauritius
* U-Pieternella owabelethwa ngo-1663
* U-Salamon owabhajadiswa ngomhla woku-1 kuKhukhulamungu 1666
* U-Jeronimus owabhajadiswa ngomhla wama-23 kaSinyikhaba1670 (Amthole ngaphandle komtjhado)
* U-Anthonij owabhajadiswa ngomhla wesi-6 kaRhoboyi 1673 (Amthole ngaphandle komtjhado)

Ngemva kwalokho u-Pieter watjhinga eMadacascar, wakhamba nomkhumbi ebewuthwele iingqila i-''Westwout.'' Wabulawa ejimeni lokubuthelela iingqila e-''Antogil Bay'' e-Madagascar elenzeka ngaphambi kwangomhla wa-27 kaMhlolanja 1668. Umkhumbi wabo lo wafika eKapa ngomhla wama-30 kaKhukhulamungu 1668.

== Iinkhombo ==</text>
      <sha1>r0g7uzj4vq45o1vdvbu7nysx4knnttf</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Mosakaruka/Draft Page 3</title>
    <ns>2</ns>
    <id>576</id>
    <revision>
      <id>2707</id>
      <timestamp>2025-04-23T09:24:11Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>Created page with &quot;== Draft Space 3 ==&quot;</comment>
      <origin>2707</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="19" sha1="7w6jurwey5tfi5ofwbia185t2lxqudi" xml:space="preserve">== Draft Space 3 ==</text>
      <sha1>7w6jurwey5tfi5ofwbia185t2lxqudi</sha1>
    </revision>
    <revision>
      <id>3513</id>
      <parentid>2707</parentid>
      <timestamp>2025-07-31T20:35:32Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>New aticle</comment>
      <origin>3513</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4088" sha1="9wliianvyljm7o7r0a0g8yv80n1up6h" xml:space="preserve">== Draft Space 3 ==

== UDorh. Lungile Mabhena ==
[[Isimumathi:Dr. Lungile Mabhena.jpg|thumb|316x316px|UDorh. Lungile Mabhena]]
'''UDorhodere Lungile Monica Mabhena''' ngomunye wabantu abatjha abadlala indima emphakathini wamaNdebele. Umtloli, imbongi, umeluleki wendabuko nonamatalente amanengana kwezobukghwari. Ngaphezu kwalokho ungutitjhere oneziqu ze-''Bachelors of Education,'' begodu wahlonitjhwa nge-''Honorary Doctorate'' ngebanga lendima ayidlalileko emphakathini. Mtloli wokuthoma wemitlolo yesiNdebele ukutjhejwa yi-''Afrika Digital'', bewakhethwa njengembongi ekhamba phambili ku-''Mzansi Art’s and Media Awards'' (MAMA). Wathola isitifiketi seZimbabwe ngebanga lokukhuluma eenkundleni zokuthintana ngesiNdebele.&lt;ref name=&quot;:0&quot;&gt;Precious Mashiane (October 16, 2024), ''Tweefontein poet Lungile Mabhena recognised by iArika digital, nominated for best poet at MAMA.'' Highveld Chronicle website. Retreived from: https://hconline.co.za/tweefontein-poet-lungile-mabhena-recognised-by-iarika-digital-nominated-for-best-poet-at-mama/ Retrieved on 31/07/2025.&lt;/ref&gt;

ULungile Mabhena wabelethelwa endaweni ye-Tweefontein C kwaNdebele, abelethwa nguSamuel Mabhena noJosephine Masombuka ngomhla ka-28 December 1999. Wathoma ukufunda esikolweni samabanga aphasi i-''Hlobisa Primary School,'' nakaqeda waya e-''Sifunda Khona Primary School,'' ngemva kwalokho wayokufunda kwesamabanga aphakemeko i-Siphiwe Combined School, bese waqedelela ngokufunda e-''Vukuzame Secondary School'' okukulapho aqeda khona ukufunda. Ithando lakhe ngokuba yimbongi.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot;&gt;Linkedin (2025) Dr Lungile Mabhena. Retrieved from: https://www.linkedin.com/in/lungile-mabena-4812aa214/?originalSubdomain=za. Retrieved on 31/07/2025.&lt;/ref&gt;

== Iindima Ayidlalako ==
[[Isimumathi:Vukani.png|thumb|318x318px|Incwadi ethi &quot;Vukani Kusile&quot;]]
UDorh. Lungile Mabhena unamatjhaneli eenkundleni zokuthintana aluleka abantu abatjha nabantu baboke ngendlela efaneleko yokwenza amasiko nekambiso yesiNdebele neyesintu okumkhakha abantu abatjha abangatholakali ngobunengi kiwo. Abuye eluleke nangendlela yokuziphatha kwabantu abatjha esikweni. Lokho ukwenza ngitjho nemrhatjhweni. Ngaphezu kwalokho sekunemitlolo abandakanyeke kiyo ethuthukisa ilimi lesiNdebele. Uneenkondlo azitlolileko ezitholakala encwadini ethi Vukani Kusile.&lt;ref name=&quot;:1&quot; /&gt;

Incwadi-le libuthelelo leenkondlo, eziveza ubudisi esizithola siqalana nabo sima-Sewula Afrika. Khumbula bona ukuhlunguphazwa kwabantu bengubo kudlange komlilo wesikhotha lapha enarheni yekhethu, kanti abobaba nabo bavela barhabile bathi nathi silila sona leso isililo sokuhlunguphazwa bomma. Nanyana kunjalo, incwadi le imumethe umlayezo wokubuyisana, ithando nokuzwelana ubuhlungu. Iimbongi nofana abatloli bencwadi le, benze okusemandleni wabo bona umamukelilwazi osebujameni nanyana ngabe ngibuphi azithole sele athobekile nofana akhandeleka. Khulu khulu incwadi le, ithoba nofana ikhandela laba abalandelako: Ababhujelweko, abalahle ithemba, abagulako, abasebenzisa iindakamizwa ngokweqileko. &lt;ref&gt;Epubhlishing and Digital Displays (2025) Books, Retrieved from: https://epublishing.store/products/ Retrieved 30-06-2025.&lt;/ref&gt;

== Nasi imitlomelo atlonyeliswe ngayo ==
[[Isimumathi:Ikhambi Literary Journal.jpg|thumb|Iinkondlo zakhe ezimbili zitholakala kilencwadi ethi Ikhambi]]

* 2008 - Umtlomelo Wokubeka Ikulumo Ekhamba Phambili - ''Award for Best Speech''
* 2011 - Umtlomelo Wokubeka Ikulumo Ekhamba Phambili - ''Award for Best Speech''
* 2024 - ''IsiNdebele Content Writer for Afrika Digital''
* 2024 - Wafunama i-Honorary Doctorate

ULungile Mabhena usibonelo ebantwini abatjha sokudlala indima ekuthuthukiseni umphakathi ngamakghono ahlukahlukeneko.

Nakazikhulumelako uthi: &quot;Ngiyakuthabela ukutlola ngomlando, ilimi, ikolo yesintu namasiko bona ngifundise abantu, ngombana njengama-Afrika sathathelwa ubuthina bethu. Kuqakathekile kimi ukwenza abantu bazi bona bangaphila ngesiko lesi-Afrika, bazihlanganise nekolo yesi-Afrika kunokuthi balahleke emasikweni wakosobani angabasizi ngalitho.&quot;&lt;ref name=&quot;:0&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>9wliianvyljm7o7r0a0g8yv80n1up6h</sha1>
    </revision>
    <revision>
      <id>5890</id>
      <parentid>3513</parentid>
      <timestamp>2025-10-03T07:52:50Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>Replaced content with &quot;== Draft Space 3 ==&quot;</comment>
      <origin>5890</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="19" sha1="7w6jurwey5tfi5ofwbia185t2lxqudi" xml:space="preserve">== Draft Space 3 ==</text>
      <sha1>7w6jurwey5tfi5ofwbia185t2lxqudi</sha1>
    </revision>
    <revision>
      <id>5891</id>
      <parentid>5890</parentid>
      <timestamp>2025-10-03T12:03:20Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>New article</comment>
      <origin>5891</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4207" sha1="dj2s0f484uvfk2w5u2hzt7aej293982" xml:space="preserve">== Draft Space 3 ==

== Isintu, Amasiko Nemikghwa ==
[[Isimumathi:AmaNdebele.jpg|thumb|IsiNdebele]]
Esinye nesinye isitjhaba ephasini sinendlela yaso yokwenza izinto. Sinemikghwa, sinamasiko nesikopilo. Amanye namanye amasiko abe nendlela yawo yokuwenza engafani nenye. Indlela le ithoma ngokubonakala emakhaya, emphakathini, esitjhabeni nesizweni. Imikghwa yakha amasiko, amasiko akha isintu.&lt;ref name=&quot;:0&quot;&gt;The Brittanica Dictionary (2025) ''Tradition.'' Retrieved  from:https://www.britannica.com/dictionary/tradition Retrieved from: 30/09/2025.&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;Fundamentals (2025) ''Cultural Habits.'' Retrieved from: https://sustainability-directory.com/fundamentals/cultural-habits-fundamentals/ Retrieved on 30//09/2025.&lt;/ref&gt; 

== Isintu ==
Ngokwehlathululo yephasi loke, isintu (''tradition'') yindlela yokucabanga, yokuziphatha neyokwenza imikghwa, enjengamasiko, amariyadlhana, indlela yokumbatha, yokudla neyobukghwari ebeyenziwa ziintjhaba zabantu abanzima, emindenini, emphakathini, nesitjhabeni esele inesikhathi eside ikhona.&lt;ref name=&quot;:0&quot; /&gt; Ngokwehlathululo yesi-Afrika isintu, nendlela yokuziphatha, yokucabanga neyokuphatha abanye abantu ngendlela enobuntu (''humanity''). Isaga esithi, '''&quot;umuntu mumuntu ngabantu&quot;''' mgogodlha wefundiso yesintu. &quot;'''Ungilokho ongikho ngebanga lokuthi abanye bangilokho abangikho'''&quot;.&lt;ref&gt;Herbert Moyo (October 14, 2022) ''Isintu.'' Retrieved from: https://globalcritical.barefield.ua.edu/self-and-persistence/isintu/ Retrieved  on 30/09/25.&lt;/ref&gt; Bubuntu-ke lobo. Ifundiso le kade khulu ikhona. Yeke isintu sibonakala ngemicabango, ngekolelo, ngemizwa nangezenzo ezinobuntu - mimikghwa, isikopilo, amasiko namariyadlhana.&lt;ref&gt;Desmond Tutu (2013), ''Who are we: Human Uniqueness and African Spirit of Ubuntu'' (Video)''.'' Retrieved from: https://www.youtube.com/watch?v=0wZtfqZ271w#t=162 Retreived on 30/09/25.&lt;/ref&gt;

== Amasiko ==
[[Isimumathi:Mapoch.- Femmes Ndebele in Cultural Village (1).jpg|thumb|Indlela yokumbatha yamaNdebele]]
Ayini-ke amasiko? Amasiko yindlela yokwenza izinto yendabuko eyenziwa sitjhaba esithileko ekolweni, embusweni nekuhlalisaneni kwabantu. Indlela le kade yenziwa begodu idluliselwa esizukulwaneni esilandelako ngokufundiswa ngomlomo nangezenzo. Kungaba yindlela yokwenza izenzo ezithileko zendabuko zendlela yokuziphatha, indlela yokuhlalisana nabanye, indlela yokumbatha, indlela yokudla, indlela yokubusa, indlela yokurarulula imiraro, indlela yokuraga amariyadlhana wekolo yesintu namkha yendabuko. Ngamanye amagama umukghwa othileko nawusolo ubuyelelwa iinkhathi ezinengana mumuntu, mndeni, mphakathi nesitjhaba, ugcina sele ulisiko.&lt;ref&gt;Gibbon Rangel (2022) ''Characteristics of Culture, Customs and Traditions,'' from Walsh and Medical Media Websie. Retrieved from: https://www.walshmedicalmedia.com/open-access/characteristics-of-culture-customs-and-traditions-114614.html Retrieved on 30/09/2025.&lt;/ref&gt; 

Aqakatheke kangangani amasiko ebantwini? Amasiko enza umuntu azikhakhazise ngendabuko yakhe. Umuntu nakazikhakhazisa ngendabukwakhe uzozikhakhazisa ngaye ngokwakhe. Ukuzikhakhazisa kumenza azithembe yena ngokwakhe begodu azizwe amumuntu. Amasiko anendlela yokuziphatha neyokuziphatha emukelekako emphakathini nesitjhabeni. Lokha umuntu nakaziphatha kuhle abantu bayamthanda. Ukuthandwa babantu kukwenza uzizwe uhloniphekile unesithunzi, uzizwe unendima eqakathekileko oyidlalako emphakathini othileko. Nanyana kunamasiko angaba nomphumela omumbi emntwini, amasiko amahle angaletha imiphumela emihle.&lt;ref&gt;Frank Sonnenberg (2025) ''7 Reasons Why Traditions Are So Important.'' Retrieved from: https://www.franksonnenbergonline.com/blog/7-reasons-why-traditions-are-so-important/ Retrieved on 30/05/25.&lt;/ref&gt; Ibuthelelo lamasiko ngilo elakha isintu.

== Imikghwa ==
Njengomana kutjhiwo ngehla, imikghwa yakha isiko, isiko lakha isintu. Alo, iyini imikghwa? Imikghwa zizenzo abantu abajayele ukuzenza. Kunemikghwa yokudla, yokukhuluma, neyokwenza, imikghwa yokuziphatha, imikghwa yokuphatha abanye, imigkhwa yokumbatha, yokubukghwari neyombhino. Imikghwa le nayisolo yenziwa mumuntu, mphakathi namkha isitjhaba, bese imukeleke ebantwini igcina sele ilisiko.&lt;ref name=&quot;:1&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>dj2s0f484uvfk2w5u2hzt7aej293982</sha1>
    </revision>
    <revision>
      <id>5892</id>
      <parentid>5891</parentid>
      <timestamp>2025-10-03T12:06:13Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>5892</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4217" sha1="dy0dpp7g2j6qef988ztppgg2k92yki4" xml:space="preserve">== Draft Space 3 ==

== Isintu, Amasiko Nemikghwa ==
[[Isimumathi:AmaNdebele.jpg|thumb|IsiNdebele|478x478px]]
Esinye nesinye isitjhaba ephasini sinendlela yaso yokwenza izinto. Sinemikghwa, sinamasiko nesikopilo. Amanye namanye amasiko abe nendlela yawo yokuwenza engafani nenye. Indlela le ithoma ngokubonakala emakhaya, emphakathini, esitjhabeni nesizweni. Imikghwa yakha amasiko, amasiko akha isintu.&lt;ref name=&quot;:0&quot;&gt;The Brittanica Dictionary (2025) ''Tradition.'' Retrieved  from:https://www.britannica.com/dictionary/tradition Retrieved from: 30/09/2025.&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;Fundamentals (2025) ''Cultural Habits.'' Retrieved from: https://sustainability-directory.com/fundamentals/cultural-habits-fundamentals/ Retrieved on 30//09/2025.&lt;/ref&gt; 

== Isintu ==
Ngokwehlathululo yephasi loke, isintu (''tradition'') yindlela yokucabanga, yokuziphatha neyokwenza imikghwa, enjengamasiko, amariyadlhana, indlela yokumbatha, yokudla neyobukghwari ebeyenziwa ziintjhaba zabantu abanzima, emindenini, emphakathini, nesitjhabeni esele inesikhathi eside ikhona.&lt;ref name=&quot;:0&quot; /&gt; Ngokwehlathululo yesi-Afrika isintu, nendlela yokuziphatha, yokucabanga neyokuphatha abanye abantu ngendlela enobuntu (''humanity''). Isaga esithi, '''&quot;umuntu mumuntu ngabantu&quot;''' mgogodlha wefundiso yesintu. &quot;'''Ungilokho ongikho ngebanga lokuthi abanye bangilokho abangikho'''&quot;.&lt;ref&gt;Herbert Moyo (October 14, 2022) ''Isintu.'' Retrieved from: https://globalcritical.barefield.ua.edu/self-and-persistence/isintu/ Retrieved  on 30/09/25.&lt;/ref&gt; Bubuntu-ke lobo. Ifundiso le kade khulu ikhona. Yeke isintu sibonakala ngemicabango, ngekolelo, ngemizwa nangezenzo ezinobuntu - mimikghwa, isikopilo, amasiko namariyadlhana.&lt;ref&gt;Desmond Tutu (2013), ''Who are we: Human Uniqueness and African Spirit of Ubuntu'' (Video)''.'' Retrieved from: https://www.youtube.com/watch?v=0wZtfqZ271w#t=162 Retreived on 30/09/25.&lt;/ref&gt;

== Amasiko ==
[[Isimumathi:Mapoch.- Femmes Ndebele in Cultural Village (1).jpg|thumb|Indlela yokumbatha yamaNdebele]]
Ayini-ke amasiko? Amasiko yindlela yokwenza izinto yendabuko eyenziwa sitjhaba esithileko ekolweni, embusweni nekuhlalisaneni kwabantu. Indlela le kade yenziwa begodu idluliselwa esizukulwaneni esilandelako ngokufundiswa ngomlomo nangezenzo. Kungaba yindlela yokwenza izenzo ezithileko zendabuko zendlela yokuziphatha, indlela yokuhlalisana nabanye, indlela yokumbatha, indlela yokudla, indlela yokubusa, indlela yokurarulula imiraro, indlela yokuraga amariyadlhana wekolo yesintu namkha yendabuko. Ngamanye amagama umukghwa othileko nawusolo ubuyelelwa iinkhathi ezinengana mumuntu, mndeni, mphakathi nesitjhaba, ugcina sele ulisiko.&lt;ref&gt;Gibbon Rangel (2022) ''Characteristics of Culture, Customs and Traditions,'' from Walsh and Medical Media Websie. Retrieved from: https://www.walshmedicalmedia.com/open-access/characteristics-of-culture-customs-and-traditions-114614.html Retrieved on 30/09/2025.&lt;/ref&gt; 

Aqakatheke kangangani amasiko ebantwini? Amasiko enza umuntu azikhakhazise ngendabuko yakhe. Umuntu nakazikhakhazisa ngendabukwakhe uzozikhakhazisa ngaye ngokwakhe. Ukuzikhakhazisa kumenza azithembe yena ngokwakhe begodu azizwe amumuntu. Amasiko anendlela yokuziphatha neyokuziphatha emukelekako emphakathini nesitjhabeni. Lokha umuntu nakaziphatha kuhle abantu bayamthanda. Ukuthandwa babantu kukwenza uzizwe uhloniphekile unesithunzi, uzizwe unendima eqakathekileko oyidlalako emphakathini othileko. Nanyana kunamasiko angaba nomphumela omumbi emntwini, amasiko amahle angaletha imiphumela emihle.&lt;ref&gt;Frank Sonnenberg (2025) ''7 Reasons Why Traditions Are So Important.'' Retrieved from: https://www.franksonnenbergonline.com/blog/7-reasons-why-traditions-are-so-important/ Retrieved on 30/05/25.&lt;/ref&gt; Ibuthelelo lamasiko ngilo elakha isintu.

== Imikghwa ==
Njengomana kutjhiwo ngehla, imikghwa yakha isiko, isiko lakha isintu. Alo, iyini imikghwa? Imikghwa zizenzo abantu abajayele ukuzenza. Kunemikghwa yokudla, yokukhuluma, neyokwenza, imikghwa yokuziphatha, imikghwa yokuphatha abanye, imigkhwa yokumbatha, yokubukghwari neyombhino. Imikghwa le nayisolo yenziwa mumuntu, mphakathi namkha isitjhaba, bese imukeleke ebantwini igcina sele ilisiko.&lt;ref name=&quot;:1&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>dy0dpp7g2j6qef988ztppgg2k92yki4</sha1>
    </revision>
    <revision>
      <id>5950</id>
      <parentid>5892</parentid>
      <timestamp>2025-11-06T10:24:35Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>Replaced content with &quot;== Draft Space 3 == &lt;references /&gt;&quot;</comment>
      <origin>5950</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="34" sha1="574x17myv06dbp5ptzp4ycywcpiaoey" xml:space="preserve">== Draft Space 3 ==
&lt;references /&gt;</text>
      <sha1>574x17myv06dbp5ptzp4ycywcpiaoey</sha1>
    </revision>
    <revision>
      <id>6127</id>
      <parentid>5950</parentid>
      <timestamp>2026-01-15T15:22:10Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>New article</comment>
      <origin>6127</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8418" sha1="izyjcckkfw42x5o2887tsvmlhpk5rqm" xml:space="preserve">== Draft Space 3 ==

== U-Autshumato ==
[[Isimumathi:Homo sapiens - Khoikhoi, Zuid-Afrika - 1700-1880 - Print - Iconographia Zoologica - Special Collections University of Amsterdam - UBA01 IZ19400109.tif|thumb|363x363px|Isithombe se-Khoekhoe]]
'''U-Autshumato namkha u-Autshumao''' (c. 1610-1660) amaDatjhi ebebamazi ngo-''Herry die Strandloper'', bekayikosi yesitjhaba sama-Khoekhoe (ama-Khoikhoi) ebesibizwa bona ma-Gorinhaikona ebesihlala endaweni yeKapa lakade amaDatjhi awayibiza nge-''Cape of Good Hope.'' Ngesikhathi amaDatjhi afika, umuntu wokuthoma ukubamukela bekungu-Autshumao nabantu bakhe. ngikho nje amaDatjhi bebababiza ngokuthi ma-Strandloper ngombana babathola bakhamba eligwini lelwandle. Kusukela bathoma ukubonana bathoma ukurhwebelana.&lt;ref name=&quot;:5&quot;&gt;Steemit Website (2018) ''SOUTH AFRICAN HISTORY: Autshumato translator and first Postmaster of The Cape of Good Hope''. Retrieved from: https://steemit.com/history/@krabgat/south-african-history-autshumato-translator-and-first-postmaster-of-the-cape-of-good-hope. Retrieved on 14/01/2026.&lt;/ref&gt;&lt;ref name=&quot;:4&quot;&gt;Camissa Museum (2026) ''Autshumao (1610 - 1674)'', Retrieved from: https://camissamuseum.co.za/index.php/7-tributaries/1-cape-indigenous-africans/autshumao. Retrieved on 12/01/2026.&lt;/ref&gt; 

Into eyenza bona u-Autshumato aqakatheke emlandweni weSewula Afrika kukuthi zinengi izinto ezenzeka epilwenakhe ezivala isikhala somlando wokusebenzelana kwabantu abanzima nabamhlophe eSewula Afrika. U-Autsumato wasebenzelana nabantu ebebeza nemikhumbi eKapa ngombana bekakwazi ukukhulumisana nabo ngesiNgisi, isiDatjhi, isiPutukezi nesiFrentji,&lt;ref name=&quot;:4&quot; /&gt; begodu ukusebenzelana kwakhe nabo kwaba nemiphumela ehlala isikhathi eside, esesekhona bekube namhlanjesi.&lt;ref&gt;Britnnica Kids (2026) ''Autshumato,'' Britannica Kids website. Retrieved from: https://kids.britannica.com/kids/article/Autshumato/601918. Retrieved on 15/01/2026.&lt;/ref&gt;

== Ipilwakhe Ngaphambi Kokufika KwamaDatjhi ==
[[Isimumathi:Khoikhoi_Hottentot_p197.jpg|thumb|Ama-Khoikhoi]]
Kungenzeka u-Autshumato wabelethwa ngabo 1610 endaweni yeKapa ebeyibizwa bona yi-''Cape of Good Hope''. Bekayikosi yesitjhaba sama-Gorinhaikona, esima-Khoekhoe.&lt;ref name=&quot;:5&quot; /&gt; Ibizo lakhe lokubelethwa bekungu-Arri, njengombana nezibulo lakhe igama lalo lingu-Arri. U-Autshumato (okutjho ukuthi &quot;loyo othaya neemfesi,  ''ǀAu-tsâma-ao'') bekulibizo ebebambongelela ngalo, ngebanga lokuthi bekathaya emanzini ngendlela erarako, aduda ngasuthi yifesi.&lt;ref name=&quot;:4&quot; /&gt; 

Ngabo-1630 wathathwa maNgisi amusa e-Bantam eNgilandi bona ambandulele ukuba mkhulumeli wabantu abeza ngemikhumbi yamaNgisi. Ngibo abamupha negama lika-Harry. Kubonakala ngasuthi watjhinga ne-Batavia&lt;ref name=&quot;:5&quot; /&gt;. Kulapho afunda khona ukukhuluma isiNgisi nesiDatjhi. Wathi nakabuya eKapa ngo-1931, yena nabalandeli bakhe bavula isitetjhi sokurhweba e-''Robben Island.'' Bekuthi imikhumbi nayifikako, ambathe iimpahla ezimbathwa maYurobhu, akhulume nabokapteni bemikhumbi ngesibindi. Lokho, kwenza u-Autshumato wabizwa ngokobana yi-'Governor' maNgisi namaFrentji.&lt;ref name=&quot;:4&quot; /&gt; 

Kwaba nelinye godu ibanga elenza bona amaNgisi amthathe amuse e-''Robben Island'' godu''.'' U-Autshumato besele arhitjhene nezinye iintjhaba zama-Khoekhoe. Wabawa umkhumbi wamaNgisi ebewudlula endaweni leyo bona uthathe yena nabalandeli bakhe  basiwe e-''Robben Island,'' nangambala kwaba njalo. Esikhathineso u-Autshumato wasebenziswa njengeposo yemikhumbi yamaYurobhu. Kungenzeka isiFrentji nesiPutukezi wazifunda lapho. Kwathi ngemva kweminyaka ebunane, ngabo-1940 wabuya, ngombana irarano liphelile.&lt;ref name=&quot;:5&quot; /&gt;  Babuya esihlengehlengeni beza enarheni eKapa, lapha kuhlangana khona umlambo i-''Camissa River'' nelwandle. Yena nomndenakhe ngibo ebebaphethe isitetjhi sokurhwebelana i-''‖Ammaqua'' (okutjho Abantu bemanzini) okulibizo u-Jan Van Riebeeck ebekababiza ngalo ekuthomeni.&lt;ref name=&quot;:3&quot;&gt;Roben Island Museum (13 May 2017) ''Autshumato''. Retrieved from: http://www.robben-island.org.za/departments/heritage/gallery/autshumato.asp. Retrieved on 14/01/2026.&lt;/ref&gt;&lt;ref name=&quot;:4&quot; /&gt;

== Ipilwakhe Ngemva Kokufika KwamaDatjhi ==
[[Isimumathi:VOC ship Phenix.jpg|thumb|Imikhumbi yamaDatjhi]]
Afika amaDatjhi ngo-1652 ngemikhumbi yawo emihlanu, i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch.'' Ukuthoma kokufika kwamaDatjhi eKapa (''Cape of Good Hope'') khenge kubamangaze abantu bendabuko bendawo leyo ama-Khoekhoe. AmaDatjhi afika nje ama-Khoikhoi besele kukade arhwebelana namaNgisi, amaPutukezi namaFrentji. Nangaphezu kokufika kuka-Van Riebeeck, ngokuya kuka-Knox‑Johnson, phakathi nomnyaka wabo-1600 kuya ku-1700, besele kudlule imikhumbi yamaDatjhi eziyi-1 730. Yeke ama-Khoikhoi bekangawaqabuki amaDatjhi ngesikhatheso.&lt;ref&gt;Helen Swingler (22 September 2021) ''Heritage Month: The Khoi encountered Europeans long before Van Riebeeck,'' University of Cape Town News. Retrieved from: https://www.news.uct.ac.za/article/-2021-09-22-the-khoi-encountered-europeans-long-before-van-riebeeck. Retrieved on 12/01/2026.&lt;/ref&gt;

Endabeni yokurhwebelana Zoke izinto ebezenzeka u-Jan Van Riebeeck wazitlola emajenalini wakhe. AmaDatjhi bewathenga iinkomo nezimvu kuma-Khoekhoe ngepahla ehlukahlukeneko kuhlanganise notjwala negwayi. Bese inyama yefuyo le idliwe, enye ethengiselwe abantu abadlula ngemikhumbi yekhamphani.&lt;ref name=&quot;:5&quot; /&gt;

Kwathi ngenyanga kaSewula wango-1653 kwaba nokurhitjhana phakathi kuka-Autshumato nomelusi weenkomo zika-Van Riebeeck u-David Jansz. U-Autshumato wambulala wathatha iinkomo. Ukurhitjhanokhu kuthoma nje iintjhaba ezimbili lezi besele zingasathelelani kuhle amanzi. AmaDatjhi besele aqala u-Autshumato nabantu bakhe njengamasela. U-Jan Van Riebeeck wathi u-Autshumato lisela elinelimi elibutjhelelezi. AmaKhoikhoi aqala amaDatjhi njengabakhohlisi ngokuthi intengo yotjwala negwayi ayilingani nentengo yesilwana esifuywako. Bebathi bangabusela utjwala buphele, babone ifuywabo emadlelweni wamaDatjhi, yanda. Bese amaKhoikhoi akhambe ayoyeba.&lt;ref&gt;Castle of Good Hope (''13th November 2018'') ''Interpreters' Flawed Contracts With Dutch''Retrieved from: https://www.castleofgoodhope.co.za/index.php/news/100-news/142-interpreters-flawed-contracts-with-dutch. Retrieved on 14/01/2026.&lt;/ref&gt;

Isenzakalo sokubulawa kuka-David Jansz sasusa ipi phakathi kwama-Khoi namaDatjhi. U-Van RieBeeck wathi u-Autshumato unomlandu wokubulala. Yeke kwaliwa ipi, ekugcineni ama-Khoi ahlulwa. U-Atshumato wabanjwa wasiwa ekuthunjweni e-''Robben Island'' ngawo umnyaka ka-1653. Kodwana ngo-1655 watjhatjululwa wabuyiswa enarheni.  Nakafikako u-Jan Van Riebeeck wamamukela wambuyisela esikhundleni sakhe sokutoliga.&lt;ref name=&quot;:5&quot; /&gt;  Ngesikhathesi u-Autshumato besele azwisisa indlela amaYurobhu arhweba ngayo nendlela yokuzuza kiyo. Bekathi nakarhwebela u-Jan Van Riebeeck iinkomo, aqiniseke bona imbadelo yekhamphani yanele bona ingabhadela neenkomo azithengela zona yena, ngikho nje aba mumuntu oregileko eKapa.&lt;ref name=&quot;:5&quot; /&gt; 

Ngokukhamba kwesikhathi kwaba nokhunye godu ukurhitjhana phakathi kwama-Khoekhoe namaDatjhi ngo-1657. Ukurhitjhanokhu kubangwa kungazwani kwa- ''Free Burger''  neengqila zeMadagascar.  U-Jan Van Riebeeck wakateleleka bona akhe isivikelo endaweni leyo, bona enze ama-Khoekhoe asuke endaweni leyo. Bekuthi ezinye iingqila naziphunyurhako asebenzise u-Atshumato njengesithunjwa ukuhlohlozela ama-khoi bona akhambe ayokubamba iingqilezo. Kodwana iqhinga lika-Van Riebeeck khenge liphumelele ngendlela afuna ngayo. Kwathi ngo-1658 u-Atshumato wabanjwa, wathathelwa yoke ifuywakhe. Ngemva kokutjhutjhiswa wathunjwa wasiwa e-Robben Island godu. Kodwana wathi nakalapho waphunyurha ngesikepe esivuzako. Bekube kunamhlanjesi, u-Autshumato nguye kwaphela umuntu okghone ukuphunyurha e-Robben Island njengesibotjhwa. Kunokuthi nakabuyako enarheni abotjhwe, u-Van Riebeeck wambuyisela esikhundleni sakhe sokukhulumisana nokutologa.&lt;ref name=&quot;:5&quot; /&gt;&lt;ref name=&quot;:4&quot; /&gt; 

Ubuhlobo bamaDatjhi nama-Khoekhoe bebuhlala bunemiraro kangangobana amaDatjhi abatjhidisela kude nendawo abakiyo. U-Autshumato waragela phambili nokufuya nokurhwebelana nabakhambi namaDatjhi bekwaba sekufeni kwakhe ngo-1663, ngemva komnyaka u-Jan Van Riebeeck akhambile. Ngo-1713 u-Francois Valentyn wabika bona isitjhaba sama-Gorinhaikona besele singasabonakali endaweni leyo. Uthi kungenzeka baqedwe bulwele bepokisi obarhagala ngo-1713.&lt;ref name=&quot;:5&quot; /&gt; 

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>izyjcckkfw42x5o2887tsvmlhpk5rqm</sha1>
    </revision>
    <revision>
      <id>6128</id>
      <parentid>6127</parentid>
      <timestamp>2026-01-15T16:00:35Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>edited</comment>
      <origin>6128</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8462" sha1="5f5bggchl3s648g37s4vet3b15dv005" xml:space="preserve">== Draft Space 3 ==

== U-Autshumato ==
[[Isimumathi:Homo sapiens - Khoikhoi, Zuid-Afrika - 1700-1880 - Print - Iconographia Zoologica - Special Collections University of Amsterdam - UBA01 IZ19400109.tif|thumb|363x363px|Isithombe se-Khoekhoe]]
'''U-Autshumato namkha u-Autshumao,''' (c. 1610-1663) amaDatjhi ebebamazi ngo-''Harry die Strandloper'', bekayikosi yesitjhaba sama-Khoekhoe ( namkha ama-Khoekhoe) ebesibizwa bona ma-Gorinhaikona ebesihlala endaweni yeKapa lakade, amaDatjhi awayibiza nge-''Cape of Good Hope.'' Ngesikhathi amaDatjhi afika, umuntu wokuthoma ukubamukela bekungu-Autshumao nabantu bakhe. Ngikho nje amaDatjhi bebababiza ngokuthi ma-Strandloper ngombana babathola bakhamba eligwini lelwandle. Kusukela bathoma ukubonana bathoma nokurhwebelana.&lt;ref name=&quot;:5&quot;&gt;Steemit Website (2018) ''SOUTH AFRICAN HISTORY: Autshumato translator and first Postmaster of The Cape of Good Hope''. Retrieved from: https://steemit.com/history/@krabgat/south-african-history-autshumato-translator-and-first-postmaster-of-the-cape-of-good-hope. Retrieved on 14/01/2026.&lt;/ref&gt;&lt;ref name=&quot;:4&quot;&gt;Camissa Museum (2026) ''Autshumao (1610 - 1674)'', Retrieved from: https://camissamuseum.co.za/index.php/7-tributaries/1-cape-indigenous-africans/autshumao. Retrieved on 12/01/2026.&lt;/ref&gt; 

Into eyenza bona u-Autshumato aqakatheke emlandweni weSewula Afrika kukuthi zinengi izinto ezenzeka epilwenakhe ezivala isikhala somlando wokusebenzelana kwabantu abanzima nabamhlophe eSewula Afrika. U-Autsumato wasebenzelana nabantu ebebeza ngemikhumbi eKapa ngombana bekakwazi ukukhulumisana nabo ngesiNgisi, isiDatjhi, isiPutukezi nesiFrentji,&lt;ref name=&quot;:4&quot; /&gt; begodu ukusebenzelana kwakhe nabo kwaba nemiphumela ehlala isikhathi eside, esesekhona bekube namhlanjesi.&lt;ref&gt;Britnnica Kids (2026) ''Autshumato,'' Britannica Kids website. Retrieved from: https://kids.britannica.com/kids/article/Autshumato/601918. Retrieved on 15/01/2026.&lt;/ref&gt;

== Ipilwakhe Ngaphambi Kokufika KwamaDatjhi ==
[[Isimumathi:Khoikhoi_Hottentot_p197.jpg|thumb|Ama-Khoekhoe]]
Kungenzeka u-Autshumato wabelethwa ngabo-1610 endaweni yeKapa ebeyibizwa bona yi-''Cape of Good Hope''. Bekayikosi yesitjhaba sama-Gorinhaikona, esima-Khoekhoe.&lt;ref name=&quot;:5&quot; /&gt; Ibizo lakhe lokubelethwa bekungu-Arri, njengombana nezibulo lakhe igama lalo lingu-Arri. U-Autshumato (okutjho ukuthi &quot;loyo othaya neemfesi,  ''ǀAu-tsâma-ao'') bekulibizo ebebambongelela ngalo, ngebanga lokuthi bekathaya emanzini ngendlela erarako, aduda ngasuthi yifesi.&lt;ref name=&quot;:4&quot; /&gt; 

Ngabo-1630 wathathwa maNgisi amusa e-Bantam eNgilandi bona ambandulele ukuba mkhulumeli wabantu abeza ngemikhumbi yamaNgisi. Ngibo abamupha negama lika-Harry. Kulapho afunda khona ukukhuluma isiNgisi nesiDatjhi. Kubonakala ngasuthi watjhinga ne-Batavia&lt;ref name=&quot;:5&quot; /&gt;.  Wathi nakabuya eKapa ngo-1931, yena nabalandeli bakhe bavula isitetjhi sokurhweba e-''Robben Island.'' Bekuthi imikhumbi nayifikako, ambathe iimpahla ezimbathwa maYurobhu, akhulume nabokapteni bemikhumbi ngesibindi. Lokho, kwenza u-Autshumato wabizwa ngokobana yi-'Governor' maNgisi namaFrentji.&lt;ref name=&quot;:4&quot; /&gt; 

Kwaba nelinye godu ibanga elenza bona amaNgisi amthathe amuse e-''Robben Island'' ''.'' U-Autshumato besele arhitjhene nezinye iintjhaba zama-Khoekhoe. Wabawa umkhumbi wamaNgisi ebewudlula endaweni leyo bona uthathe yena nabalandeli bakhe  basiwe e-''Robben Island,'' nangambala kwaba njalo. Esikhathineso u-Autshumato wasebenziswa njengeposo yemikhumbi yamaYurobhu. Kungenzeka isiFrentji nesiPutukezi wazifunda lapho. Kwathi ngemva kweminyaka ebunane, ngabo-1940 wabuya, ngombana irarano liphelile.&lt;ref name=&quot;:5&quot; /&gt;  Babuya esihlengehlengeni beza enarheni eKapa, lapha kuhlangana khona umlambo i-''Camissa River'' nelwandle. Yena nomndenakhe ngibo ebebaphethe isitetjhi sokurhwebelana i-''‖Ammaqua'' (okutjho bona Abantu bemanzini) okulibizo u-Jan Van Riebeeck ebekababiza ngalo ekuthomeni.&lt;ref name=&quot;:3&quot;&gt;Roben Island Museum (13 May 2017) ''Autshumato''. Retrieved from: http://www.robben-island.org.za/departments/heritage/gallery/autshumato.asp. Retrieved on 14/01/2026.&lt;/ref&gt;&lt;ref name=&quot;:4&quot; /&gt;

== Ipilwakhe Ngemva Kokufika KwamaDatjhi ==
[[Isimumathi:VOC ship Phenix.jpg|thumb|Imikhumbi yamaDatjhi]]
Afika amaDatjhi ngo-1652 ngemikhumbi yawo emihlanu, i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch.'' Ukuthoma kokufika kwamaDatjhi eKapa (''Cape of Good Hope'') khenge kubamangaze abantu bendabuko bendawo leyo ama-Khoekhoe. AmaDatjhi afika nje ama-Khoekhoe besele kukade arhwebelana namaNgisi, amaPutukezi namaFrentji. Nangaphezu kokufika kuka-Van Riebeeck, ngokuya kuka-Knox‑Johnson, phakathi nomnyaka wabo-1600 kuya ku-1700, besele kudlule imikhumbi yamaDatjhi eyi-1 730. Yeke ama-Khoekhoe bekangawaqabuki amaDatjhi ngesikhatheso.&lt;ref&gt;Helen Swingler (22 September 2021) ''Heritage Month: The Khoi encountered Europeans long before Van Riebeeck,'' University of Cape Town News. Retrieved from: https://www.news.uct.ac.za/article/-2021-09-22-the-khoi-encountered-europeans-long-before-van-riebeeck. Retrieved on 12/01/2026.&lt;/ref&gt;

Endabeni yokurhwebelana, zoke izinto ebezenzeka u-Jan Van Riebeeck wazitlola emajenalini wakhe. AmaDatjhi bewathenga iinkomo nezimvu kuma-Khoekhoe ngepahla ehlukahlukeneko kuhlanganise notjwala negwayi. Bese inyama yefuyo le idliwe, enye ithengiselwe abantu abadlula ngemikhumbi yekhamphani.&lt;ref name=&quot;:5&quot; /&gt;

Kwathi ngenyanga kaSewula wango-1653 kwaba nokurhitjhana phakathi kuka-Autshumato nomelusi weenkomo zika-Van Riebeeck u-David Jansz. U-Autshumato wambulala wathatha iinkomo. Ukurhitjhanokhu kuthoma nje, iintjhaba ezimbili lezi besele zingasathelelani kuhle amanzi. AmaDatjhi besele aqala u-Autshumato nabantu bakhe njengamasela. U-Jan Van Riebeeck wathi u-Autshumato lisela elinelimi elibutjhelelezi. Ama-Khoekhoe aqala amaDatjhi njengabakhohlisi ngokuthi intengo yotjwala negwayi ayilingani nentengo yesilwana esifuywako. Bebathi bangabusela utjwala buphele, babone ifuywabo emadlelweni wamaDatjhi, yanda. Bese amaKhoekhoe akhambe ayoyeba.&lt;ref&gt;Castle of Good Hope (''13th November 2018'') ''Interpreters' Flawed Contracts With Dutch''Retrieved from: https://www.castleofgoodhope.co.za/index.php/news/100-news/142-interpreters-flawed-contracts-with-dutch. Retrieved on 14/01/2026.&lt;/ref&gt;

Isenzakalo sokubulawa kuka-David Jansz sasusa ipi phakathi kwama-Khoe namaDatjhi. U-Van RieBeeck wathi u-Autshumato unomlandu wokubulala. Yeke kwaliwa ipi, ekugcineni ama-Khoe ahlulwa. U-Autshumato wabanjwa wasiwa ekuthunjweni e-''Robben Island'' ngawo umnyaka ka-1653. Kodwana ngo-1655 watjhatjululwa wabuyiswa enarheni.  Nakafikako u-Jan Van Riebeeck wamamukela wambuyisela esikhundleni sakhe sokutologa.&lt;ref name=&quot;:5&quot; /&gt;  Ngesikhathesi u-Autshumato besele azwisisa indlela amaYurobhu arhweba ngayo nendlela yokuzuza kiyo. Bekathi nakarhwebela u-Jan Van Riebeeck iinkomo, aqiniseke bona imbadelo yekhamphani yanele bona ingabhadela neenkomo azithengela zona yena, ngikho nje aba mumuntu oregileko eKapa.&lt;ref name=&quot;:5&quot; /&gt; 

Ngokukhamba kwesikhathi kwaba nokhunye godu ukurhitjhana phakathi kwama-Khoekhoe namaDatjhi ngo-1657. Ukurhitjhanokhu kubangwa kungazwani kwama-''Free Burghers (Vry Burgers)''  neengqila ze-Madagascar.  U-Jan Van Riebeeck wakateleleka bona akhe isivikelo endaweni leyo, bona enze ama-Khoekhoe asuke endaweni leyo. Bekuthi ezinye iingqila naziphunyurhako asebenzise u-Autshumato njengesithunjwa ukuhlohlozela ama-Khoe bona akhambe ayokubamba iingqilezo. Kodwana iqhinga lika-Van Riebeeck khenge liphumelele ngendlela afuna ngayo. Kwathi ngo-1658 u-Autshumato wabanjwa, wathathelwa yoke ifuywakhe. Ngemva kokutjhutjhiswa wathunjwa wasiwa e-''Robben Island'' godu. Kodwana wathi nakalapho waphunyurha ngesikepe esivuzako. Bekube kunamhlanjesi, u-Autshumato nguye kwaphela umuntu okghone ukuphunyurha e-''Robben Island'' njengesibotjhwa. Kunokuthi nakabuyako enarheni abotjhwe, u-Van Riebeeck wambuyisela esikhundleni sakhe sokukhulumisana nokutologa.&lt;ref name=&quot;:5&quot; /&gt;&lt;ref name=&quot;:4&quot; /&gt; 

Ubuhlobo bamaDatjhi nama-Khoekhoe bebuhlala bunemiraro kangangobana amaDatjhi abatjhidisela kude nendawo abakiyo. U-Autshumato waragela phambili nokufuya nokurhwebelana nabakhambi namaDatjhi bekwaba sekufeni kwakhe ngo-1663, ngemva komnyaka u-Jan Van Riebeeck akhambile. Ngo-1713 u-Francois Valentyn wabika bona isitjhaba sama-Gorinhaikona besele singasabonakali endaweni leyo. Uthi kungenzeka baqedwe bulwele bepokisi obarhagala ngo-1713.&lt;ref name=&quot;:5&quot; /&gt; 

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>5f5bggchl3s648g37s4vet3b15dv005</sha1>
    </revision>
    <revision>
      <id>6765</id>
      <parentid>6128</parentid>
      <timestamp>2026-08-06T06:08:05Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>New article</comment>
      <origin>6765</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7939" sha1="ecvpry8dgs4q34dhopja2ist5blsipm" xml:space="preserve">== Draft Space 3 ==

== I-''Capitalism'' ==

== [[Isimumathi:Anti-capitalism color.jpg|link=https://nr.wikipedia.org/wiki/Isimumathi:Anti-capitalism%20color.jpg|thumb|Umdwebo ofanisa ihlelo le-Capitalism]]'''I-''Capitalism'' namkha ihlelo lokuthola inzuzo''' lihlelo elilawula ezomnotho lapha ipahla nomkhiqizo wayo kulawulwa babantu abazijameleko namkha mabubulo azijameleko ngehloso yokufumana inzuzo. Abantwaba ngibo ababeka intengo yepahla ethengiswako ngendlela yokuthi bona bathole abakufunako ngokunikela umphakathi lokho okufunako. Ihlelweli lande khulukhulu eenarheni zangetjingalanga. Ihloso ekulu ye-capitalism kuthola inzuzo kilokho okuthengiswako. Ngokwesazi sefilosofi u-Adam Smith, sangabo-1700 okunguye oqalwa njengobaba weemfundo zezomnotho zanamhlanjesi, uthi: &quot;Usosilarha, umtlhodlhi wotjwala namkha umbhagi abenzi umusa nabenza umsebenzabo, kodwana bawenza ngebanga lenzuzo abayifunako.&quot; Amahlangothi womabili ayathengiselana ngokuzithandela khona azokuthola inzuzo ngaphandle kokutjho lokho akufunako kwamambala. Lokho umuntu akufunako ngikho okwenza umnotho ukhule bewuphumelele.&lt;ref name=&quot;:0&quot;&gt;International Monetary Fund (2026), ''Free markets may not be perfect but they are probably the best way to organize an economy.'' Retrieved from: https://www.imf.org/en/publications/fandd/issues/series/back-to-basics/capitalism. Retrieved on 14/07/2026.&lt;/ref&gt;   Ukukhiqizwa kwemikhiqizo nezenzelwa ngaphasi kwe-''capitalism'' kusekelwe ezintweni ezifunekako nezinto ezitholakalako. Okuletha inzuzo njengamafekthri, amamayini neemporo, zingalawula bezibe ngezomuntu ozijameleko, abasebenzako bangabhadelwa ngemali, abanikazi abazijameleko bangathola inzuzo, intengo yalokho okuthengiswako ingaletha inzuzo nomsebenzi ephaliswaneni lezerhwebo. Nanyana ihlelweli le-''capitalism'' lisisekelo sawo woke ama-ikonomi  akhona namhlanjesi, eminyakeni elikhulu edlulileko belingelinye lamahlelo amabili aphalisanako. Elinye bekuyi-''socialism,'' lapha urhulumende kunguye olawula amabhizinisi nendlela yokhiqiza bona yandise ipahla yomphakathi kunokuthi kutholakale inzuzo.&lt;ref name=&quot;:0&quot; /&gt;   ==

== Umlando We-''Capitalism'' ==

==  Nanyana ukuthuthukiswa kwe-''capitalism'' njengehlelo bekwenzeka ngeminyaka yabo-1500, iinhlangano zabantu abafuna inzuzo bezisolo zikhona kwekadeni, begodu abantwaba bebasolo benza inzuzo eYurobhu ngaphambi kwalokho. Ukuthuthukiswa kwe-''capitalism'' bekudoswa phambili kukhula kwebubulo elithengisa itjhila lamaNgisi ngabo-1500, 1600, nabo-1700. Into ebeyiletha ithuthuko le ehlukanisa i-''capitalism'' kwamanye amahlelo wangaphambilini bekukusetjeniswa kwenzuzo ukukhulisa izinga lokukhiqiza kunokuthi ifakwe ezintweni ezingalethi inzuzo, njengamaphiramidi nama-''cathedral''.&lt;ref&gt;Encyclopaedia Britannica (2026) C''apitalism,'' Britannica Money.Retrieved from: https://www.britannica.com/money/capitalism. Retrieved on 15/07/2026.&lt;/ref&gt; Ngaphambi kwe-''capitalism'' bekunamanye amahlelo wokukhiqiza neenhlangano zomphakathi ebekungizo ezidosa phambili ngalesosikhathi.  ==

=== I-''feudalism  -'' Imirabhu Ye-''capitalism'' ===

==  I-''capitalism'' kuhlekuhle libelethwa lihlelo le-''feudalism.'' Bekube seminyakeni yabo-1100, bancane khulu abantu ebebahlala emalokitjhini. Abasebenzi abanamakghono ahlukahlukeneko bebahlala edorobheni kodwana banikelwe indawo yokufihla ihloko makhosana awabizwa bona ma-feudal esikhundleni sokubanikela umrholo, begodu bebabalimi beenkhulu zakhona. Nanyana kunjalo,  nakuphela iminyaka yesikhathi esiphakathi kwathoma kwaqubuka amalokitjhi, bese amadorobho waba yindawo yomsebenzi neyokurhwebelana, lokho kwenza ezomnotho zaba yinto eqakathekileko. Ngaphasi kwehlelo le-feudalism, umphakathi wahlukaniswa ngokweengaba kuye ngokuthi ubelethelwe kimuphi umndeni nesigaba umndenakho okiso. Iinkhulu (iintatanyiswa) bekubanikazi benarha, bese ababasebenzelako bebanganayo inarha kodwana bebaqatjhwa ziinkhulu. Kwathi lokha izinto nazitjhugulukela ekubeni khona kwamafemu namafekthri, indlela yokurhwebelana yatjhuguluka, begodu yakhuthaza abantu bona bathuthele emalokitjhini lapha bazokwenza khona imali enengana basebenza emafektrhi kunokuthi basebenzela iinkhulu.&lt;ref name=&quot;:1&quot;&gt;By Daniel Liberto (Updated June 30, 2026) ''What Is Capitalism? History, Pros &amp; Cons, vs. Socialism,'' investopedia. Retrieved from: https://www.investopedia.com/terms/c/capitalism.asp. Retrieed on 20/07/2026.&lt;/ref&gt;  ==

=== I-''Mercantilism'' ===

==  Ngokukhamba kwesikhathi, ihlelo elibizwa bona yi-mercantilisim langena esikhundleni se-feudalism eTjingalanga Yurobhu, begodu laba lihlelo eliyihloko elilawula ezomnotho nezeemali phakathi kwabo-1500 nabo-1600. Ihlelweli lathoma ngokurhwebelana emiphakathini yamalokitjhi ahlukahlukeneko, kodwana belinganayo iphaliswano. Ekuthomeni esinye nesinye isigoga besinikela ngemikhiqizo nezenzelwa, okwathi ngokukhamba kwesikhathi imikhiqizo nezenzelwezo zafana zangaba namatshwayo azihlukanisako, ikani nazenza umsebenzi lowo ezenzelwe wona kuye ngetlhogeko yazo. Ngemva kokuthi imikhiqizo nezenzelwa zibe njalo, irhwebo belenziwa miphakathi emikhudlwana: kusukela kwelinye ilokitjhi kuya kwelinye, kusukela kwenye inarha ukuya kwenye, isifunda nesifunda ekugcineni isitjhaba ngesitjhaba. Kwathi bona iintjhaba ezinengi zirhwebelane ngepahla efanako, irhwebo lathola ukuba nephaliswano, kwathoma kwaba nobutjhaba enarhakazini ebeyisolo iqalana nezipi.&lt;ref name=&quot;:1&quot; /&gt;  I-''colonialism'' yathoma yadlondlobala ikhambisana ne-''mercantilism,'' kodwana iintjhaba lezi ezifika kwezinye bese zihlale khona bezilinga ukukhulisa irhwebo lazo. Kuhlekuhle i-''colonialism'' yenziwa ngebanga lehlelo lezomnotho elibelethwe yi-''feudalism.'' Ipahla ebeyitholwa eenarheni ezikholonayiziweko bezisiwa enarheni ekholonayizileko, ngokwesibonelo kiwo woke amakoloni we-Britain aseTlhagwini Amerikha, akatelelwa bona athenge kabutjha umkhiqizo osele uqediwe ngemali ebeyibenza amakoloni la angakghoni ukurhwebelana nezinye iinarha.&lt;ref name=&quot;:1&quot; /&gt;[[Isimumathi:Adam Smith The Muir portrait.jpg|link=https://nr.wikipedia.org/wiki/Isimumathi:Adam%20Smith%20The%20Muir%20portrait.jpg|thumb|Isazi sezomnotho nesefilosophi u-Adam Smith]]Kulapha-ke isazi sezomnotho u-Adam Smith alemuka khona bona i-mercantilism lihlelo elibuyiselana emuva ebelibangela ukungalingani phakathi kweetjhaba, begodu elingazivumeli iintjhabezo bona zithuthuke. Ifundiswakhe yokuthi abantu bathengiselane ngendlela etjhaphulukileko ngiyo eyenza iphasi lalemuka i-capitalism.&lt;ref name=&quot;:1&quot; /&gt;  ==

=== Ukukhula Kwe-indastri ===

==  Amaphuzu ka-Adam Smith afika ngesikhathi esihle, njengombana i-Industrial Revolution besele ithoma umsikinyeko ebewuzokusikinya loke iphasi langetjingalanga. I-colonialisim ilethe umnotho omutjha netlhogeko etjha yemikhiqizo ye-indastri, eyenza izikweli lathuthuka ekwenzeni amahlelo wokukhiqiza. Njengombana itheknoloji ithuthuka, amafekthri akhenge asasebenzisa imilambo namawindimili bona akhambise imitjhini, kodwana bathoma ukwakha iindawo zabo emadorobheni amakhulu lapha kunabantu abanengi abangabasebenzela.  ==

== Iinsekelo Okwakhelwe Kizo I-''capitalism'' ==

==  I-Capitalism yakhelwe kileziinsekelo ezilandelako:

* Ipahla kufuze ibe ngeyomuntu namkha ikhamphani ezijameleko. Lokho kwenza abantu babe banikazi bepahla enjengenarha nezindlu namkha amabhondi nama-''stocks.''
* Kufuze isekelwe kulokho umuntu azivunela khona mathupha ngaphandle kokuthi bakatelelwe mphakathi namkha urhulumende. Nanyana abantwaba bazilawula bona ngokwalokho abakufunako.
* Kufuze kube nephaliswano, amafemu kufuze abe netjhaphuluko yokungenga nokuphuma emamakethe, izuzise bobabili abakhiqizi nabathengi balowomkhiqizo.
* Ihlelo lemakethe okungilo elibeka intengo ngendlela yayo phakathi kwabathengi nabathengisi
* Kufuze ube netjhaphuluko yokukhetha okuthengako, okukhiqizako notjala imalakho kikho, kube nabantu abazokuzuza khulu ngalokho ingasi epahleni nezenzelweni kwaphela kodwana nendleleni abarhola ngayo.   == 

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>ecvpry8dgs4q34dhopja2ist5blsipm</sha1>
    </revision>
    <revision>
      <id>6766</id>
      <parentid>6765</parentid>
      <timestamp>2026-08-06T06:11:51Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>edited</comment>
      <origin>6766</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7879" sha1="p8jgk7h3qhnejbbf3i2lm42xucc9jbk" xml:space="preserve">== Draft Space 3 ==

== I-''Capitalism'' ==
[[Isimumathi:Anti-capitalism color.jpg|link=https://nr.wikipedia.org/wiki/Isimumathi:Anti-capitalism%20color.jpg|thumb|Umdwebo ofanisa ihlelo le-Capitalism]]'''I-''Capitalism'' namkha ihlelo lokuthola inzuzo''' lihlelo elilawula ezomnotho lapha ipahla nomkhiqizo wayo kulawulwa babantu abazijameleko namkha mabubulo azijameleko ngehloso yokufumana inzuzo. Abantwaba ngibo ababeka intengo yepahla ethengiswako ngendlela yokuthi bona bathole abakufunako ngokunikela umphakathi lokho okufunako. Ihlelweli lande khulukhulu eenarheni zangetjingalanga. Ihloso ekulu ye-capitalism kuthola inzuzo kilokho okuthengiswako. Ngokwesazi sefilosofi u-Adam Smith, sangabo-1700 okunguye oqalwa njengobaba weemfundo zezomnotho zanamhlanjesi, uthi: &quot;Usosilarha, umtlhodlhi wotjwala namkha umbhagi abenzi umusa nabenza umsebenzabo, kodwana bawenza ngebanga lenzuzo abayifunako.&quot; Amahlangothi womabili ayathengiselana ngokuzithandela khona azokuthola inzuzo ngaphandle kokutjho lokho akufunako kwamambala. Lokho umuntu akufunako ngikho okwenza umnotho ukhule bewuphumelele.&lt;ref name=&quot;:0&quot;&gt;International Monetary Fund (2026), ''Free markets may not be perfect but they are probably the best way to organize an economy.'' Retrieved from: https://www.imf.org/en/publications/fandd/issues/series/back-to-basics/capitalism. Retrieved on 14/07/2026.&lt;/ref&gt;   Ukukhiqizwa kwemikhiqizo nezenzelwa ngaphasi kwe-''capitalism'' kusekelwe ezintweni ezifunekako nezinto ezitholakalako. Okuletha inzuzo njengamafekthri, amamayini neemporo, zingalawula bezibe ngezomuntu ozijameleko, abasebenzako bangabhadelwa ngemali, abanikazi abazijameleko bangathola inzuzo, intengo yalokho okuthengiswako ingaletha inzuzo nomsebenzi ephaliswaneni lezerhwebo. Nanyana ihlelweli le-''capitalism'' lisisekelo sawo woke ama-ikonomi  akhona namhlanjesi, eminyakeni elikhulu edlulileko belingelinye lamahlelo amabili aphalisanako. Elinye bekuyi-''socialism,'' lapha urhulumende kunguye olawula amabhizinisi nendlela yokhiqiza bona yandise ipahla yomphakathi kunokuthi kutholakale inzuzo.&lt;ref name=&quot;:0&quot; /&gt;

== Umlando We-''Capitalism'' ==
Nanyana ukuthuthukiswa kwe-''capitalism'' njengehlelo bekwenzeka ngeminyaka yabo-1500, iinhlangano zabantu abafuna inzuzo bezisolo zikhona kwekadeni, begodu abantwaba bebasolo benza inzuzo eYurobhu ngaphambi kwalokho. Ukuthuthukiswa kwe-''capitalism'' bekudoswa phambili kukhula kwebubulo elithengisa itjhila lamaNgisi ngabo-1500, 1600, nabo-1700. Into ebeyiletha ithuthuko le ehlukanisa i-''capitalism'' kwamanye amahlelo wangaphambilini bekukusetjeniswa kwenzuzo ukukhulisa izinga lokukhiqiza kunokuthi ifakwe ezintweni ezingalethi inzuzo, njengamaphiramidi nama-''cathedral''.&lt;ref&gt;Encyclopaedia Britannica (2026) C''apitalism,'' Britannica Money.Retrieved from: https://www.britannica.com/money/capitalism. Retrieved on 15/07/2026.&lt;/ref&gt; Ngaphambi kwe-''capitalism'' bekunamanye amahlelo wokukhiqiza neenhlangano zomphakathi ebekungizo ezidosa phambili ngalesosikhathi.

== I-''feudalism  -'' Imirabhu Ye-''capitalism'' ==
I-''capitalism'' kuhlekuhle libelethwa lihlelo le-''feudalism.'' Bekube seminyakeni yabo-1100, bancane khulu abantu ebebahlala emalokitjhini. Abasebenzi abanamakghono ahlukahlukeneko bebahlala edorobheni kodwana banikelwe indawo yokufihla ihloko makhosana awabizwa bona ma-feudal esikhundleni sokubanikela umrholo, begodu bebabalimi beenkhulu zakhona. Nanyana kunjalo,  nakuphela iminyaka yesikhathi esiphakathi kwathoma kwaqubuka amalokitjhi, bese amadorobho waba yindawo yomsebenzi neyokurhwebelana, lokho kwenza ezomnotho zaba yinto eqakathekileko. Ngaphasi kwehlelo le-feudalism, umphakathi wahlukaniswa ngokweengaba kuye ngokuthi ubelethelwe kimuphi umndeni nesigaba umndenakho okiso. Iinkhulu (iintatanyiswa) bekubanikazi benarha, bese ababasebenzelako bebanganayo inarha kodwana bebaqatjhwa ziinkhulu. Kwathi lokha izinto nazitjhugulukela ekubeni khona kwamafemu namafekthri, indlela yokurhwebelana yatjhuguluka, begodu yakhuthaza abantu bona bathuthele emalokitjhini lapha bazokwenza khona imali enengana basebenza emafektrhi kunokuthi basebenzela iinkhulu.&lt;ref name=&quot;:1&quot;&gt;By Daniel Liberto (Updated June 30, 2026) ''What Is Capitalism? History, Pros &amp; Cons, vs. Socialism,'' investopedia. Retrieved from: https://www.investopedia.com/terms/c/capitalism.asp. Retrieed on 20/07/2026.&lt;/ref&gt;

== I-''Mercantilism'' ==
Ngokukhamba kwesikhathi, ihlelo elibizwa bona yi-mercantilisim langena esikhundleni se-feudalism eTjingalanga Yurobhu, begodu laba lihlelo eliyihloko elilawula ezomnotho nezeemali phakathi kwabo-1500 nabo-1600. Ihlelweli lathoma ngokurhwebelana emiphakathini yamalokitjhi ahlukahlukeneko, kodwana belinganayo iphaliswano. Ekuthomeni esinye nesinye isigoga besinikela ngemikhiqizo nezenzelwa, okwathi ngokukhamba kwesikhathi imikhiqizo nezenzelwezo zafana zangaba namatshwayo azihlukanisako, ikani nazenza umsebenzi lowo ezenzelwe wona kuye ngetlhogeko yazo. Ngemva kokuthi imikhiqizo nezenzelwa zibe njalo, irhwebo belenziwa miphakathi emikhudlwana: kusukela kwelinye ilokitjhi kuya kwelinye, kusukela kwenye inarha ukuya kwenye, isifunda nesifunda ekugcineni isitjhaba ngesitjhaba. Kwathi bona iintjhaba ezinengi zirhwebelane ngepahla efanako, irhwebo lathola ukuba nephaliswano, kwathoma kwaba nobutjhaba enarhakazini ebeyisolo iqalana nezipi.&lt;ref name=&quot;:1&quot; /&gt;  I-''colonialism'' yathoma yadlondlobala ikhambisana ne-''mercantilism,'' kodwana iintjhaba lezi ezifika kwezinye bese zihlale khona bezilinga ukukhulisa irhwebo lazo. Kuhlekuhle i-''colonialism'' yenziwa ngebanga lehlelo lezomnotho elibelethwe yi-''feudalism.'' Ipahla ebeyitholwa eenarheni ezikholonayiziweko bezisiwa enarheni ekholonayizileko, ngokwesibonelo kiwo woke amakoloni we-Britain aseTlhagwini Amerikha, akatelelwa bona athenge kabutjha umkhiqizo osele uqediwe ngemali ebeyibenza amakoloni la angakghoni ukurhwebelana nezinye iinarha.&lt;ref name=&quot;:1&quot; /&gt;[[Isimumathi:Adam Smith The Muir portrait.jpg|link=https://nr.wikipedia.org/wiki/Isimumathi:Adam%20Smith%20The%20Muir%20portrait.jpg|thumb|Isazi sezomnotho nesefilosophi u-Adam Smith]]Kulapha-ke isazi sezomnotho u-Adam Smith alemuka khona bona i-mercantilism lihlelo elibuyiselana emuva ebelibangela ukungalingani phakathi kweetjhaba, begodu elingazivumeli iintjhabezo bona zithuthuke. Ifundiswakhe yokuthi abantu bathengiselane ngendlela etjhaphulukileko ngiyo eyenza iphasi lalemuka i-capitalism.&lt;ref name=&quot;:1&quot; /&gt;

== Ukukhula Kwe-indastri ==
Amaphuzu ka-Adam Smith afika ngesikhathi esihle, njengombana i-Industrial Revolution besele ithoma umsikinyeko ebewuzokusikinya loke iphasi langetjingalanga. I-colonialisim ilethe umnotho omutjha netlhogeko etjha yemikhiqizo ye-indastri, eyenza izikweli lathuthuka ekwenzeni amahlelo wokukhiqiza. Njengombana itheknoloji ithuthuka, amafekthri akhenge asasebenzisa imilambo namawindimili bona akhambise imitjhini, kodwana bathoma ukwakha iindawo zabo emadorobheni amakhulu lapha kunabantu abanengi abangabasebenzela.

== Iinsekelo Okwakhelwe Kizo I-''capitalism'' ==

I-Capitalism yakhelwe kileziinsekelo ezilandelako:

* Ipahla kufuze ibe ngeyomuntu namkha ikhamphani ezijameleko. Lokho kwenza abantu babe banikazi bepahla enjengenarha nezindlu namkha amabhondi nama-''stocks.''
* Kufuze isekelwe kulokho umuntu azivunela khona mathupha ngaphandle kokuthi bakatelelwe mphakathi namkha urhulumende. Nanyana abantwaba bazilawula bona ngokwalokho abakufunako.
* Kufuze kube nephaliswano, amafemu kufuze abe netjhaphuluko yokungenga nokuphuma emamakethe, izuzise bobabili abakhiqizi nabathengi balowomkhiqizo.
* Ihlelo lemakethe okungilo elibeka intengo ngendlela yayo phakathi kwabathengi nabathengisi
* Kufuze ube netjhaphuluko yokukhetha okuthengako, okukhiqizako notjala imalakho kikho, kube nabantu abazokuzuza khulu ngalokho ingasi epahleni nezenzelweni kwaphela kodwana nendleleni abarhola ngayo. 

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>p8jgk7h3qhnejbbf3i2lm42xucc9jbk</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Lungile M. MabhenaDraft page 3</title>
    <ns>2</ns>
    <id>577</id>
    <revision>
      <id>2708</id>
      <timestamp>2025-04-23T09:24:24Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <comment>DRAFT 3</comment>
      <origin>2708</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="13" sha1="s2achj07hr9mu58fo28b3aloowo6h0l" xml:space="preserve">== DRAFT 3 ==</text>
      <sha1>s2achj07hr9mu58fo28b3aloowo6h0l</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Jetro mahlangu</title>
    <ns>2</ns>
    <id>579</id>
    <revision>
      <id>2719</id>
      <timestamp>2025-04-23T09:32:46Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>Created page with &quot;this is my person  |draft 1  |  draft2 |draft 3&quot;</comment>
      <origin>2719</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="47" sha1="dief29i3wd4x3xfkher0h1ps01o7ytm" xml:space="preserve">this is my person

|draft 1  |  draft2 |draft 3</text>
      <sha1>dief29i3wd4x3xfkher0h1ps01o7ytm</sha1>
    </revision>
    <revision>
      <id>2730</id>
      <parentid>2719</parentid>
      <timestamp>2025-04-23T09:40:31Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <origin>2730</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="93" sha1="m2kn5gdu9615tf01p4dbf9ejtsfw2vr" xml:space="preserve">this is my personal space

[[Umsebenzisi:Jetro mahlangu/Draft 1|draft 1]]  |  draft2 |draft 3</text>
      <sha1>m2kn5gdu9615tf01p4dbf9ejtsfw2vr</sha1>
    </revision>
    <revision>
      <id>2732</id>
      <parentid>2730</parentid>
      <timestamp>2025-04-23T09:42:48Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <origin>2732</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="131" sha1="9qbcyarzfe05ws0z1wy37a5e705hkhj" xml:space="preserve">this is my personal space

[[Umsebenzisi:Jetro mahlangu/Draft 1|draft 1]]  |  [[Umsebenzisi:Jetro mahlangu/Draft2|draft2]] |draft 3</text>
      <sha1>9qbcyarzfe05ws0z1wy37a5e705hkhj</sha1>
    </revision>
    <revision>
      <id>2734</id>
      <parentid>2732</parentid>
      <timestamp>2025-04-23T09:44:12Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <origin>2734</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="170" sha1="bc7fyd1x2427epegt84kjhc6qpkcgvb" xml:space="preserve">this is my personal space

[[Umsebenzisi:Jetro mahlangu/Draft 1|draft 1]]  |  [[Umsebenzisi:Jetro mahlangu/Draft2|draft2]] |[[Umsebenzisi:Jetro mahlangu/Draft 3|draft 3]]</text>
      <sha1>bc7fyd1x2427epegt84kjhc6qpkcgvb</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Orrora/Draft page 1</title>
    <ns>2</ns>
    <id>580</id>
    <revision>
      <id>2725</id>
      <timestamp>2025-04-23T09:34:59Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <comment>Created page with &quot;== draft page 1 ==&quot;</comment>
      <origin>2725</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="18" sha1="cuk8cv9cqkekjepva0bwy554inaqz95" xml:space="preserve">== draft page 1 ==</text>
      <sha1>cuk8cv9cqkekjepva0bwy554inaqz95</sha1>
    </revision>
    <revision>
      <id>2835</id>
      <parentid>2725</parentid>
      <timestamp>2025-05-22T14:47:03Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <origin>2835</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="931" sha1="kk6mjd2285al4t12luwftlzy6te7toa" xml:space="preserve">== draft page 1 ==

= Ukulondolozwa Kwamalimi Wendabuko WeSewula Afrika =
'''ESewula''' Afrika kunamalimi ayi 11 akhulunywako, amalimi la yisi Ngisi, i-Afrikaans, isiZulu, isiXhosa, iSepedi, isiTsonga, isiVenda, isiSwati, isiNdebele, isiTswana nesiSotho seSewula Afrika. Kodwana kunamanye amalimi angakatloliswa ngokomthetho njengesiLobedu, isi-Korana, isi-Nluu, isi-Xiri namanye.  &lt;ref&gt;{{Cite web|last=Alexander|first=Mary|date=2025-04-06|title=The languages of South Africa|url=https://southafrica-info.com/arts-culture/11-languages-south-africa/|access-date=2025-05-22|website=South Africa Gateway|language=en-GB}}&lt;/ref&gt; UmThethosisekelo uthi amalimi la, khulukhulu wendubuko kufuze alondolozwe namkha abulungwe.&lt;ref&gt;{{Cite web|title=The SA Constitution|url=https://www.justice.gov.za/constitution/chp01.html|access-date=2025-05-22|website=www.justice.gov.za}}&lt;/ref&gt;

== Isizathu Sokulondolozwa Kwamalimi La ==



&lt;references /&gt;</text>
      <sha1>kk6mjd2285al4t12luwftlzy6te7toa</sha1>
    </revision>
    <revision>
      <id>2861</id>
      <parentid>2835</parentid>
      <timestamp>2025-05-29T14:29:21Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <origin>2861</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2655" sha1="fm5iepkaf0yvhegfb173an3l76rzxae" xml:space="preserve">== draft page 1 ==

= Ukulondolozwa Kwamalimi Wendabuko WeSewula Afrika =
'''ESewula''' Afrika kunamalimi ayi 12 akhulunywako, amalimi la yisi Ngisi, i-Afrikaans, isiZulu, isiXhosa, iSepedi, isiTsonga, isiTshivenda, isiSwati, isiNdebele, isiTswana,siSotho seSewula Afrika nelimi lezandla leSewula Afrika. Kodwana kunamanye amalimi angakatloliswa ngokomthetho njengesiLobedu, isi-Korana, isi-Nluu, isi-Xiri namanye.  &lt;ref&gt;{{Cite web|last=Alexander|first=Mary|date=2025-04-06|title=The languages of South Africa|url=https://southafrica-info.com/arts-culture/11-languages-south-africa/|access-date=2025-05-22|website=South Africa Gateway|language=en-GB}}&lt;/ref&gt; UmThethosisekelo uthi amalimi la, khulukhulu wendubuko kufuze alondolozwe namkha abulungwe.&lt;ref&gt;{{Cite web|title=The SA Constitution|url=https://www.justice.gov.za/constitution/chp01.html|access-date=2025-05-22|website=www.justice.gov.za}}&lt;/ref&gt;

Amalimi la ahlukaniswe kathathu. Ahlukaniswe ngendlela ahlobene begodu afana ngakho.

* amalimi wesiNguni
* amalimi wesiSotho- Tswana
* amailimi wesikhuwa 


'''Amalimi wesiNguni ahlanganisa amalimi ayi 4 alandelako:'''

* isiZulu- ilimi leli likhulunywa ngamaZulu
* isiXhoza- ilimi leli likhulunywa ngamaXhoza
* isiNdebele- ilimi leli likhulinywa ngamaNdebele
* isiSwati- ilimi leli likhulunywa ngamaSwati


'''Amalimi wesiSotho - Tswana ahlanganisa amalimi ayi 5 alandelako:'''

* Sepedi (seSotho sa Leboa) -ilimi leli likhulunywa ngamaPedi
* seSotho- Southern Sotho
* siTswana- ilimi leli likhulunywa ngamaTswana
* Tshivenda- ilimi leli likhulunywa ngamaVenda
* xiTsonga- ilimi leli likhulunywa ngamaTsonga


'''Amalimi wesiKhuwa ahlanganiswa malimi ayi 2 alandelako:'''

* Isikhuwa (English) - ilimi leli likhulunywa ngamaNgisi
* Afrikaans - ilimi leli likhulunywa ngama Afrikaaners

== Isizathu Sokulondolozwa Kwamalimi La ==


Ukulondolozwa kwamalimi wendabuko eSewula Afrika kuqakatheke khulu ngoba kwenza abantu bakghone ukukhulumisana kuhle bebazwisisane kuhle ngamalimi abawamunyileko bese lokho kwenza ilimi lingafi kodwana lithuthuke. Ukulondolozwa kwelimi kusiza nabanye abeza ngemva bazi ilimi lendabuko namasiko wendabuko,  kwenza kube nokuzwana nokubekezelelana nanokuhloniphana emphakathini. Godu kuthuthukisa nezemnotho zeSewula Afrika.&lt;ref&gt;{{Cite web|last=Baker|first=Abigail|date=2024-10-11|title=PRESERVING SOUTH AFRICA'S INDIGENOUS LANGUAGES: A LIVING LEGACY FOR FUTURE GENERATIONS|url=https://fwdeklerk.org/preserving-south-africas-indigenous-languages-a-living-legacy-for-future-generations/|access-date=2025-05-29|website=FW de Klerk Foundation|language=en-US}}&lt;/ref&gt;

Ihlathululo yaloku okubalwe ngaphezulu:


&lt;references /&gt;</text>
      <sha1>fm5iepkaf0yvhegfb173an3l76rzxae</sha1>
    </revision>
    <revision>
      <id>2863</id>
      <parentid>2861</parentid>
      <timestamp>2025-05-29T21:10:13Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <origin>2863</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8030" sha1="229fmjot5rqph3x16sd00cxgv291khy" xml:space="preserve">== draft page 1 ==

= Ukulondolozwa Kwamalimi Wendabuko WeSewula Afrika =
[[Isimumathi:Variety of male human faces (collage).jpg|thumb|Abantu bemihlobo ehlukahlukeneko]]
'''ESewula''' Afrika kunamalimi ali-12 akhulunywako, amalimi la yisiNgisi, i-Afrikaans, isiZulu, isiXhosa, iSepedi, isiTsonga, isiTshivenda, isiSwati, isiNdebele, isiTswana, isiSotho seSewula Afrika nelimi lezandla leSewula Afrika. Kodwana kunamanye amalimi angakatloliswa ngokomthetho njengesiLobedu, isi-Korana, isi-Nluu, isi-Xiri namanye.  &lt;ref&gt;{{Cite web|last=Alexander|first=Mary|date=2025-04-06|title=The languages of South Africa|url=https://southafrica-info.com/arts-culture/11-languages-south-africa/|access-date=2025-05-22|website=South Africa Gateway|language=en-GB}}&lt;/ref&gt; UmThethosisekelo uthi amalimi la, khulukhulu wenda
{| class=&quot;wikitable&quot;
|+
!Amalimi
wesiNguni
!Amalimi
wesiSotho
!Amalimi
wesiKhuwa
!Eminye 
Imihlobo Yamalimi
|-
|IsiZulu
|IsiPedi
|IsiNgisi
|isiTsonga
|-
|IsiXhosa
|IsiSotho
|I-Afrikaans
|IsiVenda
|-
|IsiNdebele
|IsiTswana
|
|Ilimi Lezandla
|-
|IsiSwati
|
|
|
|}
buko kufuze alondolozwe namkha abulungwe.&lt;ref&gt;{{Cite web|title=The SA Constitution|url=https://www.justice.gov.za/constitution/chp01.html|access-date=2025-05-22|website=www.justice.gov.za}}&lt;/ref&gt; 

Amalimi la ahlukaniswe ngokuya ngokwemihlobo emine. Ahlukaniswe ngendlela ahlobene begodu afana ngakho.

* amalimi wesiNguni
* amalimi wesiSotho
* amailimi wesikhuwa &lt;ref name=&quot;:0&quot;&gt;{{Cite web|date=2025-05-25|title=South Africa - Languages, Dialects, Afrikaans {{!}} Britannica|url=https://www.britannica.com/place/South-Africa/Languages|access-date=2025-05-29|website=www.britannica.com|language=en}}&lt;/ref&gt; 

===  '''Amalimi wesiNguni:''' ===
* isiZulu- ilimi leli likhulunywa maZulu
* isiXhoza- ilimi leli likhulunywa maXhoza
* isiNdebele- ilimi leli likhulinywa maNdebele
* isiSwati- ilimi leli likhulunywa maSwati&lt;ref name=&quot;:0&quot; /&gt;

=== '''Amalimi wesiSotho:''' ===
* Sepedi (seSotho sa Leboa) -ilimi leli likhulunywa baPedi
* seSotho- Leli ilimi likhulunywa beSotho
* siTswana- ilimi leli likhulunywa beTswana

=== '''Omunye Umhlobo Wamalimi''' ===

* Tshivenda- ilimi leli likhulunywa maVenda 

* xiTsonga- ilimi leli likhulunywa maTsonga&lt;ref name=&quot;:0&quot; /&gt;

=== '''Amalimi wesiKhuwa:''' ===
* Isikhuwa (English) - ilimi leli likhulunywa maNgisi
* Afrikaans - ilimi leli likhulunywa ma-Afrikaaners&lt;ref name=&quot;:0&quot; /&gt;

== Isizathu Sokulondolozwa Kwamalimi La ==



Ukulondolozwa kwamalimi wendabuko eSewula Afrika kuqakatheke khulu ngombana kwenza abantu bakghone ukukhulumisana kuhle bebazwisisane kuhle ngamalimi abawamunyileko bese lokho kwenza ilimi lingafi kodwana lithuthuke. Ukulondolozwa kwelimi kusiza ukundlulisela isizukulwane esiza ngemva ilwazi lelimi lendabuko namasiko wendabuko,  kwenza kube nokuzwana nokubekezelelana nanokuhloniphana emphakathini. Godu kuthuthukisa nezomnotho zeSewula Afrika.&lt;ref&gt;{{Cite web|last=Baker|first=Abigail|date=2024-10-11|title=PRESERVING SOUTH AFRICA'S INDIGENOUS LANGUAGES: A LIVING LEGACY FOR FUTURE GENERATIONS|url=https://fwdeklerk.org/preserving-south-africas-indigenous-languages-a-living-legacy-for-future-generations/|access-date=2025-05-29|website=FW de Klerk Foundation|language=en-US}}&lt;/ref&gt;

Ihlathululo yaloku okubalwe ngaphezulu:

'''Ukufa kwelimi'''

Ukufa kwelimi nofana ukungasebenzisi ilimi lendabuko kungabangela ukulahleka kwesiko, kuphazamise nokuhlalisana kuhle emphakathini. Loke ilwazi elimayelana nobukghwari, amasiko, imikghwa yokuphatha abantu ngehlonipho, neemfundo eziqakathekileko epilweni kuyafa kuphele lokha ilimi nalifako. Bona kubabalele ilwazelo ilimi kufuze lilondolozwe bona lingafi. &lt;ref name=&quot;:1&quot;&gt;{{Cite web|title=Google Search|url=https://www.google.com/search?q=reasons+for+preserving+languages+in+south+africa&amp;rlz=1C1JJTC_enZA1156ZA1159&amp;oq=reasons+for+preserving+languages+in+south+africa&amp;gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIKCAEQABiiBBiJBTIHCAIQABjvBTIHCAMQABjvBTIKCAQQABiABBiiBDIGCAUQRRg8MgYIBhBFGDwyBggHEEUYPNIBCTE2MTE1ajBqNKgCALACAQ&amp;sourceid=chrome&amp;ie=UTF-8|access-date=2025-05-29|website=www.google.com}}&lt;/ref&gt; 

'''Ukudlulisela ilwazi lwelimi namasiko wendabuko'''

Ukulondoloza ilimi nesikopilo lendabuko kusiza ukuthi loke ilwazi lidluliselwe kusizukulwana esiza ngemva lokho kuzokwenza ilimi liragele phambili likhulunywa namasiko nawo aragele phambile.&lt;ref name=&quot;:1&quot; /&gt; Ngokwesibonelo, kunemithi yesintu esetjenziswa sitjhaba esithileko kodwana engekho kesinye isitjhaba. Lokha iintjhaba ezimbili nazikhulumisanako zikghona ukwabelana ngelwazi lezokwelapha, nemiithi yendabuko nalokho ekulaphako. 

'''Ukubambisana komphakathi'''

Ukulondolozwa kwelimi kuthuthukisa ukubambisana emphakathini, ukuhloniphana nokuthula. Kwenza umphakathi uhloniphe amanye amalimi begodu uwaqale njengaqakathekileko.&lt;ref name=&quot;:1&quot; /&gt; Ngokwesibonelo, kuba nokubambisana emalungwini womphakathi azwisisanako, begodu kuvula ithuba lokuveza imibono, ukuze kuthathwe iinqunto ezivuthiweko ezingasiza umphakathi. 

'''Ukuthuthuka komnotho'''

Ukulondolozwa kwelimi kungavula amathuba amanengi womsebenzi khulukhulu kilaba abanekareko yokusebenza ngamalimi wendabuko.&lt;ref name=&quot;:1&quot; /&gt; Ngokwesibonelo, abantu abakghona ukukhuluma amalimi amanengana banamathuba amanengi wokuqatjhwa emisebenzini nemabubulweni asebenza ngabantu beenzinda ezihlukahlukeneko. Ukuqatjhwa kwabantwaba kuthuthukisa umnotho wenarha.

== Angalondolozwa njani amalimi wendabuko ==
Ukulondolozwa kwamalimi wendabuko weSewula Afrika kutloga iindlela ezihlukahlukeneko zokurarulula umraro wokulondolozwa kwawo. kuneendlela ezimbalwa ezingasebenzizwa ukulondolozwa kwamalimi wendabuko, kokuthoma kufundisa nofana ukudlulisela ilwazi ngamalimi wendabuko. Kwesibili ukusebenzisa itheknoloji ekufundiseni nekuthuthukiseni ilimi. Kwesithathu ukutlola phasi nokuzihlanganisa nomphakathi.&lt;ref name=&quot;:2&quot;&gt;{{Cite web|title=Google Search|url=https://www.google.com/search?q=how+do+we+preserve+south+african+indigenous+languages&amp;rlz=1C1JJTC_enZA1156ZA1159&amp;oq=how+do+we+preserve+south+african+indigenous+lan&amp;gs_lcrp=EgZjaHJvbWUqBggDECEYFTIGCAAQRRg5MgkIARAhGAoYoAEyCQgCECEYChigATIGCAMQIRgVMgcIBBAhGJ8FMgcIBRAhGI8C0gEJNDY4MjJqMGo5qAIAsAIB&amp;sourceid=chrome&amp;ie=UTF-8|access-date=2025-05-29|website=www.google.com}}&lt;/ref&gt;

'''Fundisa ngelimi leNdabuko'''

Ukufundisa ngelimi lendabuko ezikolweni zamabanga aphasi naphezulu kungasiza ukuthi ilimi lilondolozwe. Irhubhullulo likhombisa ukuthi abantwana abaningi baphasa kuhle khulu nabafundiswa ngamalimi abawamunyileko. Kutlogeka izincwadi zamalimi wendabuko nezinye izinto ezingasebenzizwa bona kufundiswe abanye bunqopha nofana online.&lt;ref name=&quot;:2&quot; /&gt;

'''Ukusebenziswa kwetheknoloji'''

Ukutjhugululwa kwezincwadi zamalimi wendabuko zenziwe ihlelo elilalelwako, lokho kungenye yezindlela ezisebenzako zokulondoloza amalimi begodu kwenza kube lula ukuthi zihlale isikhathi eside bezitholakale lula. Ukwenza isihlathululi magama App(online dictionery)  namanye amahlelo wetheknoloji ngamalimi wendabuko angasiza ukuthuthukisa  nokulondoloza begodu kubalula ukuthi zitholakale kiwo woke umunyu osebenzisa itheknoloji.&lt;ref name=&quot;:2&quot; /&gt;

Ukutjhugulula, amaziko welimi wetheknoloji nama-''software'' asetjenziswa khudlwana emalimini wendabuko godu asiza amalimi bona alondolozwe bulula godu nabantu bazokujwayelana khulu netheknoloji ngoba izokuzwisiseka ngcono.&lt;ref name=&quot;:2&quot; /&gt;

'''Ukuzibandakanya komphakathi ekuthuthukiseni ilimi'''

Ukukhuthaza nokusekela igadango lokurhatjha ngamalimi wendabuko kumabona kude nasemrhatjhweni lokho kudlala indima ekulu ekulondolozeni amalimi wendabuko. Ukusekela umphakathi nawenza iminyanya ethuthukisa amasiko namalimi wendabuko kungaba nomthelela omuhle.&lt;ref name=&quot;:2&quot; /&gt;

Ukutholakala kwabatjhugululi bamalimi wendabuko kusiza amalunga womphakathi ukuthi bathole ilwazi begodu bazwisise kuhle ezinye zezinto ezibhalwe ngesikhuwa. ukusebenzisa zokuqhumana (social media) ngamalimi wendabuko nokuzihlanganisa neziqhema zabantu abakhuluma amalimi wendabuko online lokho nakho kuthuthukisa bekulondoloze ilimi.&lt;ref name=&quot;:2&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>229fmjot5rqph3x16sd00cxgv291khy</sha1>
    </revision>
    <revision>
      <id>3248</id>
      <parentid>2863</parentid>
      <timestamp>2025-06-28T17:46:18Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <origin>3248</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6161" sha1="ixqdsw5cquv315nutlxldx6nl5d9187" xml:space="preserve">== draft page 1 ==

= Indima Yabantu Abatjha Kwezokulima =
[[Isimumathi:Marcus Bai with PNG youth (10698164975).jpg|thumb|321x321px|Abantu abatjha bayalima]]
ESewula Afrika, abantu abatjha abakavami ukutholakala khulu kwezokulima, yeke sibalo esincani khulu sabantu abatjha abathuthukisa zokulima. Nanyana kunjalo kunomnyakazo owenzekako kwezokulima, njengokukhiqizwa kokudla, ukuthengiswa kokudla nokwehla komtlhago ezikweneli ngebanga lendima edlalwa babantu abatjha abambalwa, khulukhulu eendaweni zemakhaya. Kodwana kusesenesitjhijilo sokukara abantu abatjha ezikweneli, kuhlanganise nokungatholakali kuhle kwenarha yokutjala, iimali namakghono atlhogekako.&lt;ref&gt;Ongama Giwu, Lelethu Mdoda, Samuel S. Ntlanga, Olwethu Loki ( 08 Nov. 2024), ''Evaluating factors influencing youth participation in agricultural enterprises: Implications for food security and agribusiness,'' SAJEBSM website. Retrieved from: https://sajesbm.co.za/index.php/sajesbm/article/view/903/1130 Retrieved 28-06-2025.&lt;/ref&gt; 

Irhubululo litjengisa bona kunamaphesente ama-24 wabantu abatjha ababandakanyeke kezokulima, begodu bambalwa khulu abenza imali ngakho. Abtjha abamaphesente ama-23 nama-21 benza imali ngamaplasi begodu banamabubulo wabo. Abatjha abatjhadileko nalabo ababondlako emizinabo nabo baba nethando lokulima ngombana ekhaya bayalama.&lt;ref&gt;The Water Wheel pamphlet (January-February 2022) ''Youth and Agriculture.''&lt;/ref&gt; 

== Iintjhijilo Abatjha Abaqalana Nazo Kezokulima ==
Nanzi iintjhijilo abantu abatjha abaqalene nazo ezikweni lezokulima:

# Ukungatholakali lula kwelwazi nefundo yezokulima. Lokhu kuhlanganisa ifundo namakghono wezokulima asezingeni eliphasi okungilo elinomthelela omkhulu ekungabini khona kwemikhiqizo yezokulima, bese lokhu kubangele ukungalingani nomtlhago enarheni. 
# Ukungatholakali kwenarha. Lokhu kumraro khulukhulu kabengubo abasesebatjha ngokwesiko labanzima abanganikelwa ilifa lenarha. Ngaphezu kwalokho bambalwa khulu abantu abatjha abakghona ukuthoma imali-mbonelelo etholakalako yokuthenga inarha.
# Ukungatholakali lula kwemali nezenzelwa, kuhlanganise nemali-mboleko, imali ebulungwako netjhorensi etlhogekako bona ithomise ibubulo lokulima beyithuthukise nemikhiqizo yakhona.
# Ubudisi bokutholakala kwemisebenzi ephathelene nezokulima engondla amaphilo wabantu abatjha isikhathi eside. 
# Ukungatholakali lula kwamamakethe okungathengiswa kiwo imikhiqizo yezokulima okwenziwa ziintolo ezikulu ezithengisa imikhiqizo yezokulima, ukungabibikho kwefundo, ibandulo nelwazi elaneleko ngokuthengisa imikhiqizo yokulima.
# Ukungatholakali lula kwamathuba wokubandakanyeka nakucociswana ngepholisi yezokulima. Lokho kutjho bona kunabantu imibono yabo engekhe izwakale, bese lokho kwenze abantu abatjha abathanda ukulima bangakutholi abakutlhogako.&lt;ref name=&quot;:0&quot;&gt;UNAI Hub for SDG2 News, (June 16, 2022) ''The youth are the future of the agricultural sector'', University of Pretoria website. Retrieved from: https://www.up.ac.za/unai-hub-for-sdg2/news/post_3082769-the-youth-are-the-future-of-the-agricultural-sector Retrieved on 28-06-2025.&lt;/ref&gt; 

== Indlela Iintjhijilwezi Ezingararululwa Ngayo ==

# Urhulumende kufuze wandise amahlelo wokwabelana ngelwazi nefundo yezokulima ukuze kutholakale ilwazi elaneleko ngezokulima. Amahlelo la angenziwa bese afundiswe abantu abatjha kusukela ebuncanini babo, okungasiza ekwakheni ithando lezokulima eenhliziyweni zabo. Kufuze kube namahlelo wokubandula abafundisi begodu eze neentlabagelo zokufundisa abantu abatjha ngezokulima nangendlela ukudla okukhiqizwa ngayo.&lt;ref name=&quot;:0&quot; /&gt;
# Urhulumende kuye namabubulo azijameleko kufuze bafake imali ekuthuthukiseni ezokulima begodu bathuthukise nethekhnoloji yezokulima, bebasekele abantu abatjha abangenela umkhakhalo. Amaziko wezeemali nawo kufuze avulele abantu abatjha amathuba aneleko begodu kube bulula bona abantu abatjha bawafumane.&lt;ref name=&quot;:0&quot; /&gt;
# Urhulumende kufuze unikelane ngenarha ekhona bona abantu abatjha balimele kiyo, begodu kufuze anikele nangemali engathenga inarha yokulima. Yeke kufuze uthuthukise imithethokambiso yokutholakala kwenarha yokulima eSewula Afrika. Nanyana kunamahlelo nemithethokambiso eminengi emalungana nokwabiwa kwenarha yokulima, kusafuze enze kube bulula ukufumana amathuba lawo.&lt;ref&gt;South African Government website (2025), ''Land and agriculture.'' Retrieve from: https://www.gov.za/issues/land-and-agriculture Retrieved on 28-06-2025.&lt;/ref&gt; 

== Abatjha Abaphumelelako Kwezokulima ==

* '''Phikolomzi Qinisa Dlamini:''' Umphathi kezokulima ekhamphanini i-''Ndela Farming'', wathola iziqu zakhe e-''Cedara College of Agriculture'' begodu ukhuthaza abantu abatjha bona balandelele khulu ifundo yezokulima.&lt;ref name=&quot;:1&quot;&gt;Nicole Ludolph (21st June 2022) ''Watch out, these young farmers are on fire!'', foodformzansi.co.za, Retrieved from: https://www.foodformzansi.co.za/watch-out-these-young-farmers-are-on-fire/ Retrieved on 28-08-2025.&lt;/ref&gt; 
* '''Keneilwe Raphesu:''' Uphethe ibubulo i-''Runs Mogalemone Farm'' banoyise begodu ukhuthaza nabanye bona bangenele zokulima.&lt;ref name=&quot;:1&quot; /&gt; 
* '''Thabo Herman Dithakgwe:''' Wathoma ibubulo elibizwa bona yi-''Ditha Farming, Wildlife and Projects''  aneminyaka eli-19.&lt;ref&gt;More Matshediso (2019)''Teen farmer makes dad proud'', Vuk'uzenzele website (2025).Retrieved from: https://www.vukuzenzele.gov.za/teen-farmer-makes-dad-proud Retrieved on 28-06-2025.&lt;/ref&gt;
* '''Sabelo Mdlalose:''' Nguye odosa phambili i-''Iqabungelihle Primary Cooperative'', utjala imirorho neenungo.&lt;ref&gt;Food and Trees for Africa (2021) ''Youth are the future of SA agriculture''. Retrieved from: https://trees.org.za/youth-are-the-future-of-sa-agriculture Retrieve on 28-06-2025.&lt;/ref&gt;
* '''Stanley Ntshangase:''' Umlimi onesivuno esincani ophumelele khulu ukutjala ikhabitjhi, amabhatata nesiphila begodu imikhiqizo yakhe uyithumela e-SPAR.&lt;ref&gt;Timbali Technologies (28 Nov 2023) ''Southern Africa small-scale farming success featuring individual success story'', PROAGRIMEDIA Retrieved from: https://www.proagrimedia.com/people/southern-africa-small-scale-farming-success-featuring-individual-success-story Retrieved on 28-06-2025.&lt;/ref&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>ixqdsw5cquv315nutlxldx6nl5d9187</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Orrora/Draft page 2</title>
    <ns>2</ns>
    <id>581</id>
    <revision>
      <id>2726</id>
      <timestamp>2025-04-23T09:35:47Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <comment>Created page with &quot;== draft page 2 ==&quot;</comment>
      <origin>2726</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="18" sha1="1cqk8akc33j0nvy48hqpgxeuv3hkutj" xml:space="preserve">== draft page 2 ==</text>
      <sha1>1cqk8akc33j0nvy48hqpgxeuv3hkutj</sha1>
    </revision>
    <revision>
      <id>2873</id>
      <parentid>2726</parentid>
      <timestamp>2025-05-30T22:09:30Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <origin>2873</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1379" sha1="m5x9k183s0xl3q1isbf1lvir87tnky8" xml:space="preserve">== draft page 2 ==

= INgwenyama UNyabela =
'''UNyabela''' yiNgwenyama yamaNdebele wakwaNzunza  eyabusa kusukela ngenyanga kaVelabahlinze 1879 nakuhlongakala iNgwenyama uRhobongo, walwa ipi namaBhuru eyathoma ngomhlaka-07 kaSinyikhaba 1882 eyaphela ngomhlaka-08 kaVelabahlinze 1883 mhla bazinikela yena noMampuru emaBhurwini, kwaba kubotjhwa kwabo nokuhluleka kwepi yamaNdebele emaBhurwini.&lt;ref name=&quot;:0&quot;&gt;Iziko Lamakhosi - C. J Mahlangu, K. N Mahlangu, M. A Mahlangu, no-S. M Mtshweni&lt;/ref&gt;

Ngokwencwadi ethi '''Iziko lamaKhosi''', uNyabela  - uGijamphezeni kaMabhoko  - wathatha isihlalo  abambele uFene indodana kaMkhephuli ngombana bekasesemncani bona angabusa. Nayiragako ithi ekuthomeni kokubusa kwakhe uNyabela wayenganayo ingubo yobukhosi. Yeke wakhupha intanga yamaDlaza bona iyokufuna ingwe khona kuzokutholakala isikhumba esizokuba yingubo yobukhosi. Umthwalintanga yamaDlaza ibizo lakhe kwakunguNomacwayi. Bagcina Bayifumene ingwe entabeni yakwaCabha, bayibulala beza nayo ekosini. &lt;ref name=&quot;:0&quot; /&gt;

=== Amadodana weNgwenyama uNyabela ===

* UMtjongweni (uSomphezeni) oliDugu noyindondana ekulu

* UMofu (uSoSenzeni) oliPhogo
* UNgobe oliDuba
* UMpepe (uSovelemu) oliDlowu
* UMzitha (uSoMene) oliSinya
* UMakhabakhubu (uSovusani) oliPhogo
* UPama (uSoMvumazoke) liRhorha
* UZalabo (uSoMlingo) oliDuba
* UMarhagi (uSoZilani) oliRhorha


== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>m5x9k183s0xl3q1isbf1lvir87tnky8</sha1>
    </revision>
    <revision>
      <id>3267</id>
      <parentid>2873</parentid>
      <timestamp>2025-06-30T12:46:08Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <origin>3267</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4449" sha1="3l1drkw3xwo8lm5ewx1p3xs01az5act" xml:space="preserve">== draft page 2 ==

== Iincwadi ZesiNdebele Ezitlolwe Babantu Abatjha ==
'''IsiNdebele''' seSewula Afrika sinabantu abatjha abanetalende lokutlola. Abatjhaba sele kuneencwadi abazikhuphileko abantu abangathabela ukuzifunda. Indima yokutlola edlalwa babantu abatjha ithuthukisa ilimi. Nakunabantu abatlolako nabafunda iincwadi ezitloliweko, nesiNdebele naso siyathuthuka.Ngikho nje urhulumende weSewula Afrika ufuna abantu abatjha bakuthande ukutlola nokufunda iincwadi ezitloliweko. Yeke iincwadi ezilandelako ngezitlolwe babantu abatjha ngelimi lesiNdebele.

== Vukani Kusile! ==
[[Isimumathi:Vukani.png|thumb|298x298px|Incwadi ethi, &quot;Vukani! Sekusile&quot;]]
'''Incwadi''': Vukani Kusile!

'''Abatloli''': Ntando Mtshweni, Dr Lungile Mabhena, Thobile Skhosana, Given Lungile

'''Okumunyethwe yincwadi le:''' Incwadi-le libuthelelo leenkondlo, eziveza ubudisi esizithola siqalana nabo sima-Sewula Afrika. Khumbula bona ukuhlunguphazwa kwabantu bengubo kudlange komlilo wesikhotha lapha enarheni yekhethu, kanti abobaba nabo bavela barhabile bathi nathi silila sona leso isililo sokuhlunguphazwa bomma. Nanyana kunjalo, incwadi le imumethe umlayezo wokubuyisana, ithando nokuzwelana ubuhlungu. Iimbongi nofana abatloli bencwadi le, benze okusemandleni wabo bona umamukelilwazi osebujameni nanyana ngabe ngibuphi azithole sele athobekile nofana akhandeleka. Khulu khulu incwadi le, ithoba nofana ikhandela laba abalandelako: Ababhujelweko, abalahle ithemba, abagulako, abasebenzisa iindakamizwa ngokweqileko.&lt;ref name=&quot;:0&quot;&gt;Epubhlishing and Digital Displays (2025) Books, Retrieved from: https://epublishing.store/product Retrieved 30-06-2025&lt;/ref&gt;

== Ongathandwa Ngunina ==
[[Isimumathi:Ongathandwa Ngunina.jpg|thumb|287x287px|Incwadi &quot;Ongathandwa Ngunina&quot;]]
'''Incwadi''': Thabi Mahamba

'''Abatloli''': Ongathandwa Ngunina

'''Okumunyethwe yincwadi le:''' Inoveli Ongathandwa Ngunina ikhuluma ngomntazanyana onganabudlelwano obuhle nababelethi bakhe ngebanga lemali ebhadelele iimfundo zakhe esikolweni samaziko aphakamileko esingakatloliswa emnyangweni wezefundo. Unina umkatelela bona athole umsebenzi abuyise imali enyamalele nesikolo sakhe esingasi semthethweni. Kwafika lapha umraro ukhwela intaba nababelethi bakhe nakangafumani umsebenzi.&lt;ref name=&quot;:0&quot; /&gt;

Ukuqothwa ekhabo kwasusa igodo elihlweni wafunda ukuzijamela ngezakhe zombili ngaphandle kokusunduzwa mumuntu ngamandla namkha amenzise angakufuniko. Kwafika lapha ikghono lakhe aliphiwe nguSomnini lokutlola incwadi likhanyisa umkhanyo orhelebhileko wabuyisana nomndeni wakhe khulu unina, ozange amsekele ekuthomeni bona abhadelelwe esikolweni sefundo ephakamileko.&lt;ref name=&quot;:0&quot; /&gt;

== Aziyokujama Elitjeni ==
[[Isimumathi:Aziyokujama Elitjeni.jpg|thumb|285x285px|Incwadi ethi &quot;Aziyokujama Elitjeni&quot;]]
'''Incwadi''': Aziyokujama Elitjeni

'''Abatloli''': Nomajoni O Mahlangu

'''Okumunyethwe yincwadi le:''' Inovela le isivezela ipilo ngemva kwebanga letjhumi nambili. Kusetjenziswe umlingiswa onguThuba, umntazanyana ohlakaniphileko. Akhange aphumelele kuhle ebangeni lakhe letjhumi nambili.  Wazifumana angaphasi kwegandelelo lokuya ekholiji njengombana boke abangani bakhe baphumelele kuhle begodu baya emayunivesithi ahlukileko. Uzifumene afunda iimfundo angazithandiko ngombana begade angafuni ukubuyela esikolweni ayokubuyekeza ibanga letjhumi nambili. Okubuhlungu kukobana uzithole sele azifake emrarweni wokubhema iindakamizwa, athengisa umzimba, bewazithwala. Walinga ukurarulula umraro loyo ngokurhulula umbungu kanti ubeka ipilo yakhe engozini.&lt;ref name=&quot;:0&quot; /&gt;

== Unjengabo ==
[[Isimumathi:UNJENGABO.jpg|thumb|280x280px|Incwadi ethi, &quot;Unjengabo&quot;]]
'''Incwadi''': Unjengabo

'''Abatloli''': Sabelo Mthombeni

'''Okumunyethwe yincwadi le:''' Incwadi le, iqaliswe ebantwini abakhulu nelutjha. Nawumumuntu omkhulu, ngokufunda inwadi le, uzokuthola isifundo sokobana ufanele ubayelelise njani abasakhulako ngendlela yokuziphatha. Uthi bewunelemuko lokobana  sifanele siphilisane njani nabantu abaphila nobujamo be-''Albinism?'' Athini amalungelo wabo? '' ''Ingabe abantu abavela eenarheni zangaphandle beze lapha enarheni yeSewula Afrika bezele ukuzosakhisa nofana bezele ukutjala umonyani? Koke kumumethwe yincwadi le. Inabela  ilutjha ngobungozi elingahlangabezana nabo lokha nalisemazikweni wefundo ephakemeko kanye nokukhetha abangani. Ngikuphi okuqakathekileko phakathi kwendlela kaZimu, iindakamizwa? Namalungelo? Naku umthombo welwazi ziselele mfundi.&lt;ref name=&quot;:0&quot; /&gt;</text>
      <sha1>3l1drkw3xwo8lm5ewx1p3xs01az5act</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Orrora/Draft page 3</title>
    <ns>2</ns>
    <id>583</id>
    <revision>
      <id>2729</id>
      <timestamp>2025-04-23T09:36:20Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <comment>Created page with &quot;== draft page 3 ==&quot;</comment>
      <origin>2729</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="18" sha1="16zgigc936bnc7ur5yz1hu5n94tgxtu" xml:space="preserve">== draft page 3 ==</text>
      <sha1>16zgigc936bnc7ur5yz1hu5n94tgxtu</sha1>
    </revision>
    <revision>
      <id>3518</id>
      <parentid>2729</parentid>
      <timestamp>2025-07-31T21:15:52Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <comment>new article</comment>
      <origin>3518</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3907" sha1="ssp5x55p5mwjqxr5hhq2bw3z7qc9f9e" xml:space="preserve">== draft page 3 ==

== Ukugula Kwengqondo ==
'''Ukugula kwengqondo''' (''Mental Disoder'') libuthelelo lokugula kwengqondo okuhlukahlukeneko, okungaba kuhlangahlangana emcabangweni, emizweni, endleleni umutu aqala ngayo izinto nekuziphatheni kwakhe. Ukugula komkhumbulo kungabangela umuntu bona agandeleleke namkha atshwenyeke ngokudluleleko, abone, ezwe izinto ezingekho bese lokho kuthinte nomsebenzi wakhe wokuziphilisa kuhlanganise nomdenakhe. Ukugulokhu kujayeleke khulu begodu kungaphatha nanyana ngubani, kungakhathaliseki bona umumuntu wengubo nofana omduna. Akukhethi bona unemali nofana awa.&lt;ref name=&quot;:0&quot;&gt;American Psychiatry Association (2025) What is mental illness? Retrieved from: https://www.psychiatry.org/patients-families/what-is-mental-illness.  Retrieved on 31/07/2025.&lt;/ref&gt;

== Imihlobo Yokugula Kwengqondo ==
Ukugula kwengqondo kuhlukaniswe nganasi indlela:

* Ukutshwenyeka Ngokudluleleko. Ukugula lokhu kuhlanganisa ukuthukwa khulu nanokutshwenyeka khulu ngezinto ezizokwenzeka namkha ngezinto afuna zenzeke. 
* Ukugandeleleka. Ukugula lokhu kwenza umuntu agandeleleke khulu, khulukhulu ngezinto ezenzeke esikhathini esidlulileko,  azizwe angakathabi, angakhanuki ukwenza litho, bekuthinte nendlela alala nadla ngayo.
* Ukutjhugutjhuguluka kwemizwa. Ukugula lokhu kwenza umuntu atjhugulule imizwa yakhe qobe sikhathi. Angathaba khulu godu ngokuphazima kwelihlo azizwe adane khulu.
* Ukuhlanya. Ukukhubazeka kwengqondo okubangela umuntu abone izinto ezibonwa nguye yedwa, bekezwa nemidumo ezwiwa nguye yedwa, namkha abe nomuzwa wokuthinta izinto ezingekho.
* Ukungadli ngendlela efaneleko. Ukuthikaziseka kwengqondo okubangela umuntu angadli ngendlela efaneleko bese kuthinte indlela umuntu aqaleka ngayo.
* Ukusebenzisa kumbi iindakamizwa. Ukuphazamiseka kwengqondo okukwenza ungasakhoni ukuphila ngaphandle kotshwala neendakamizwa.&lt;ref name=&quot;:1&quot;&gt;World Health Organisation (8 June 2022) ''Mental Disoders.'' Retrieved from: https://www.who.int/news-room/fact-sheets/detail/mental-disorders. Retrieved on 31/07/2025&lt;/ref&gt;

== Ongakwenza nange uqalene Nokhunye Kokugula Okubaliweko ==

* ''Rhaba ufune isizo zisuka'': Kuqakatheke khulu ukurhaba ufune isizo nange ubona amatshwayo wokugula nofana kungeze kwakuqeda ukugula lokho kodwana kungenza uthole imitjhoga etlhogekako msinyana.

* ''Thola imitjhoga ekhambelana nawe'': Amagulo la awafani yeke kuqakatheke khulu ukuthola imitjhoga ekhambelana nokugula okuphethe wena mathupha.

* ''Thola isekelo'': Kuqakatheke khulu ukuba nesekelo kungathaliseki bone livela kubangani nofana emdenini. Ukuthola ilwazi elinengi ngendlela ongakghona ngayo ngokugulokhu kungaba lirhelebho elikhulu.&lt;ref&gt;Mayo Clinic (2025) Mental Illness - Symptoms-causes. Retrieved from: https://www.mayoclinic.org/diseases-conditions/mental-illness/symptoms-causes/syc-20374968. Retrieved on 31/07/2025.&lt;/ref&gt;

== Okufuze Ukwazi Ngokugula Kwengqondo ==
Okokuthona okufuze ukwazi ngabantu abaqalene nokugula kwengqondo ukuthi bakuthola kubudisi ukuqalana nezinto ekufuze zenziwe ilanga nelanga. Abanye bakuthola kubudisi ukubulunga ubudlelwane obuhle nabangani nofana umndeni. Abanye bakuthola kubudisi ukwenza umsebenzi wabo wokuziphilisa nofana ukwenza umsebenzi wesikolo nange bafunda. Ukugula loku kwenza ukuphila kwaqobe langa kube budisi.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;

Okwesibili kukuthi ukugula lokhu abe akusilo ihlazo kungaphatha nanyana ngubani, yeke akukafuzi uzizwe unamahloni bewusabe nokufuna irhelebho. Ukufuna kwakho irhelebho kuzobe kutjengisa ukuhlakanipha nokuhluzeka. Akukafuzi uphathwe ziinhloni, banengi tle abantu abaphila nokugula kwengqondo.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;

Okwamaswaphela ukuthi ikhona imitjhoga namapilisi ongayisebenzisa begodu bakhona nabodorhodera abasebenza ngokugula kwengqondo. Kuqakatheke khulu ukuba nabantu abazokusekela bebazwisise ukugula oqalane nakho.&lt;ref name=&quot;:1&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>ssp5x55p5mwjqxr5hhq2bw3z7qc9f9e</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Jetro mahlangu/Draft 1</title>
    <ns>2</ns>
    <id>584</id>
    <revision>
      <id>2731</id>
      <timestamp>2025-04-23T09:41:31Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>Created page with &quot;== leli likhasi lami lokuthoma ==&quot;</comment>
      <origin>2731</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="33" sha1="tgx435z5nj8nh0tamjqlermqlpu6we0" xml:space="preserve">== leli likhasi lami lokuthoma ==</text>
      <sha1>tgx435z5nj8nh0tamjqlermqlpu6we0</sha1>
    </revision>
    <revision>
      <id>2808</id>
      <parentid>2731</parentid>
      <timestamp>2025-05-10T11:01:26Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>/* leli likhasi lami lokuthoma */</comment>
      <origin>2808</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2767" sha1="d0nmxdjhhsayi4f35m53kp8e626mo0q" xml:space="preserve">== leli likhasi lami lokuthoma. ==


'''UMRHAYILI''' yinyanga yesihlanu ku https://en.wikipedia.org/wiki/Julian_calendar ne https://en.wikipedia.org/wiki/Gregorian_calendar&lt;nowiki/&gt;.Inyanga ka Mrhayili inamalanga amatjhumi amathathu nanye.eSewula Afrika kilenyanga kuthoma umoya omakhaza orhayila nofana obulala yoke into emilileko namkha ebeyihlaza ehlobo.Inyanga kaMrhayili ise sizinini ye kwindla nalapho kuthoma khona isikhathi sobusika.Ibizo lenyanga lihlathulula bonyana kusikhathi sokobana izinto ezinengi ezifana neentjalo ziyarhayileka nofana ziyafa.
[[Isimumathi:Africa Month Logo web(1).jpg|thumb|Africa month commemoration logo]]


Inyanga ye Afrika igidingwa qobe mnyaka ngoMrhayili,ukukhumbula ukusungulwa kwe    [[:en:Organisation_of_African_Unity#:~:text=The%20OAU%20was%20founded%20in,May%201963%20in%20Addis%20Ababa.|https://en.wikipedia.org/wiki/Organisation_of_African_Unity#:~:text=The%20OAU%20was%20founded%20in,May%201963%20in%20Addis%20Ababa]] I edishini yetjhumi yenyanga ye Afrika igidingwa ngaphasi kewsiqubulo esithi:&quot;SIGIDINGA IMINYAKA EMATJHUMI AMATHATHU NANYE YE TJHAPHULUKO&quot;,sakha iAfrika encono  nephasi  elincono.  eSewula Afrika inyanga kaMrhayili qobe mnyaka itshwaywa njenge nyanga yeAfrika begodu ithungelene nokhu sekela nokuqinisa ilanga le Afrika.Ngomnyaka ka 2024 i    https://en.wikipedia.org/wiki/African_Union yahloma ilanga leAfika ngokurhabisa ukutlanywa kwe        https://en.wikipedia.org/wiki/African_Continental_Free_Trade_Area&lt;nowiki/&gt;.Ibuye isekele amahlelo asekela i '''International Decade Of Indigenous''' '''Languages''' njengo kutjho kwe '''UNESCO''' ukutjengisa ukuqakatheka kokuthuthukisa ukusetjenziswa kwamalimi wendabuko we Afrika.
[[Isimumathi:SAfricaDay12.jpg|left|thumb|professor samba buri mboup]]
Iyunivesithi ye Mpumalanga https://www.ump.ac.za/ igidinga ilanga le Afrika solo kwango 2015.U vice chancellor we univesithi ye Mpumalanga uProfessor Thoko Mayekiso wathi  iziko lezefundo ligidinga beliyazikhakhazisa ngoutjhidelana nenarhakazi yeAfrika. 

&quot; ngokwehloso yethu sirhuluphela ukuba yi univesithi ye Afrika ekhamba phambili ekuletheni amathuba wokuthuthuka ngokusungula nokhu sungula.sikholwa bonyana kusinikela ithuba elihle ukuthuthukisa umqopho wethu ngamalanga.sisungule isiko lokugidinga iAfrika day solo kwango 2015.sibe netjhudu lokumema aboqwephetjhe bazositlhadlhula ngenarhakazi ye Afrika.

https://en.wikipedia.org/wiki/File:Hooker_emerald.jpg&lt;nowiki/&gt;i emerald lilitje lokubelethwa lenyanga kaMrhayili.Lingelinye lamatje aligugu aziwako eminyakeni emakhulu  ngamakhulu.i emerald ihlobene khulu nobukhosi.Imihlobohlobo ye Berly family.Umbala ohlaza we litje le emerald esikhathini esinengi ukhambisana bulenda obuhlaza sasibhakabhaka no sarulana otholakala elitjeni nlegugu leli.</text>
      <sha1>d0nmxdjhhsayi4f35m53kp8e626mo0q</sha1>
    </revision>
    <revision>
      <id>2809</id>
      <parentid>2808</parentid>
      <timestamp>2025-05-11T18:42:41Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <minor />
      <comment>/* leli likhasi lami lokuthoma. */</comment>
      <origin>2809</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2769" sha1="qhtgzzzhyab9aqjd8g9fc6770hmh0wk" xml:space="preserve">== leli likhasi lami lokuthoma. ==


'''UMRHAYILI''' yinyanga yesihlanu ku https://en.wikipedia.org/wiki/Julian_calendar ne https://en.wikipedia.org/wiki/Gregorian_calendar&lt;nowiki/&gt;.Inyanga ka Mrhayili inamalanga amatjhumi amathathu nanye.eSewula Afrika kilenyanga kuthoma umoya omakhaza orhayila nofana obulala yoke into emilileko namkha ebeyihlaza ehlobo.Inyanga kaMrhayili ise sizinini ye kwindla nalapho kuthoma khona isikhathi sobusika.Ibizo lenyanga lihlathulula bonyana kusikhathi sokobana izinto ezinengi ezifana neentjalo ziyarhayileka nofana ziyafa.
[[Isimumathi:Africa Month Logo web(1).jpg|thumb|Africa month commemoration logo]]


Inyanga ye Afrika igidingwa qobe mnyaka ngoMrhayili,ukukhumbula ukusungulwa kwe    [[:en:Organisation_of_African_Unity#:~:text=The%20OAU%20was%20founded%20in,May%201963%20in%20Addis%20Ababa.|https://en.wikipedia.org/wiki/Organisation_of_African_Unity#:~:text=The%20OAU%20was%20founded%20in,May%201963%20in%20Addis%20Ababa]] I edishini yetjhumi yenyanga ye Afrika igidingwa ngaphasi kewsiqubulo esithi:&quot;SIGIDINGA IMINYAKA EMATJHUMI AMATHATHU NANYE YE TJHAPHULUKO&quot;,sakha iAfrika encono  nephasi  elincono.  eSewula Afrika inyanga kaMrhayili qobe mnyaka itshwaywa njenge nyanga yeAfrika begodu ithungelene nokhu sekela nokuqinisa ilanga le Afrika.Ngomnyaka ka 2024 i    https://en.wikipedia.org/wiki/African_Union yahloma ilanga leAfika ngokurhabisa ukutlanywa kwe        https://en.wikipedia.org/wiki/African_Continental_Free_Trade_Area&lt;nowiki/&gt;.Ibuye isekele amahlelo asekela i '''International Decade Of Indigenous''' '''Languages''' njengo kutjho kwe '''UNESCO''' ukutjengisa ukuqakatheka kokuthuthukisa ukusetjenziswa kwamalimi wendabuko we Afrika.
[[Isimumathi:SAfricaDay12.jpg|left|thumb|Professor Samba Buri Mboup]]
Iyunivesithi ye Mpumalanga https://www.ump.ac.za/ igidinga ilanga le Afrika solo kwango 2015.U vice chancellor we univesithi ye Mpumalanga uProfessor Thoko Mayekiso wathi  iziko lezefundo ligidinga beliyazikhakhazisa ngoutjhidelana nenarhakazi yeAfrika. 

&quot; ngokwehloso yethu sirhuluphela ukuba yi univesithi ye Afrika ekhamba phambili ekuletheni amathuba wokuthuthuka ngokusungula nokhu sungula.sikholwa bonyana kusinikela ithuba elihle ukuthuthukisa umqopho wethu ngamalanga.sisungule isiko lokugidinga iAfrika day solo kwango 2015.sibe netjhudu lokumema aboqwephetjhe bazositlhadlhula ngenarhakazi ye Afrika.

https://en.wikipedia.org/wiki/File:Hooker_emerald.jpg&lt;nowiki/&gt;i emerald lilitje lokubelethwa lenyanga kaMrhayili.Lingelinye lamatje aligugu aziwako eminyakeni emakhulu  ngamakhulu.i emerald ihlobene khulu nobukhosi.Imihlobohlobo ye Berly family.Umbala ohlaza we litje le emerald esikhathini esinengi ukhambisana bulenda obuhlaza sasibhakabhaka no sarulana otholakala elitjeni nlegugu leli

.</text>
      <sha1>qhtgzzzhyab9aqjd8g9fc6770hmh0wk</sha1>
    </revision>
    <revision>
      <id>2811</id>
      <parentid>2809</parentid>
      <timestamp>2025-05-13T20:01:00Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>i changed references</comment>
      <origin>2811</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3842" sha1="60mxm1g5e3u4hed8k66e0lh5bwuz5xv" xml:space="preserve">== leli likhasi lami lokuthoma. ==


'''UMRHAYILI''' yinyanga yesihlanu ku https://en.wikipedia.org/wiki/Julian_calendar ne https://en.wikipedia.org/wiki/Gregorian_calendar&lt;nowiki/&gt;.Inyanga ka Mrhayili inamalanga amatjhumi amathathu nanye.eSewula Afrika kilenyanga kuthoma umoya omakhaza orhayila nofana obulala yoke into emilileko namkha ebeyihlaza ehlobo.Inyanga kaMrhayili ise sizinini ye kwindla nalapho kuthoma khona isikhathi sobusika.Ibizo lenyanga lihlathulula bonyana kusikhathi sokobana izinto ezinengi ezifana neentjalo ziyarhayileka nofana ziyafa.
[[Isimumathi:Africa Month Logo web(1).jpg|thumb|Africa month commemoration logo]]


Inyanga ye Afrika igidingwa qobe mnyaka ngoMrhayili,ukukhumbula ukusungulwa kwe    [[:en:Organisation_of_African_Unity#:~:text=The%20OAU%20was%20founded%20in,May%201963%20in%20Addis%20Ababa.|https://en.wikipedia.org/wiki/Organisation_of_African_Unity#:~:text=The%20OAU%20was%20founded%20in,May%201963%20in%20Addis%20Ababa]] I edishini yetjhumi yenyanga ye Afrika igidingwa ngaphasi kewsiqubulo esithi:&quot;SIGIDINGA IMINYAKA EMATJHUMI AMATHATHU NANYE YE TJHAPHULUKO&quot;,sakha iAfrika encono  nephasi  elincono.  eSewula Afrika inyanga kaMrhayili qobe mnyaka itshwaywa njenge nyanga yeAfrika begodu ithungelene nokhu sekela nokuqinisa ilanga le Afrika.Ngomnyaka ka 2024 i    https://en.wikipedia.org/wiki/African_Union yahloma ilanga leAfika ngokurhabisa ukutlanywa kwe        https://en.wikipedia.org/wiki/African_Continental_Free_Trade_Area&lt;nowiki/&gt;.Ibuye isekele amahlelo asekela i '''International Decade Of Indigenous''' '''Languages''' njengo kutjho kwe '''UNESCO''' ukutjengisa ukuqakatheka kokuthuthukisa ukusetjenziswa kwamalimi wendabuko we Afrika.
[[Isimumathi:SAfricaDay12.jpg|left|thumb|Professor Samba Buri Mboup]]
Iyunivesithi ye Mpumalanga https://www.ump.ac.za/ igidinga ilanga le Afrika solo kwango 2015.U vice chancellor we univesithi ye Mpumalanga uProfessor Thoko Mayekiso wathi  iziko lezefundo ligidinga beliyazikhakhazisa ngoutjhidelana nenarhakazi yeAfrika. 

&quot; ngokwehloso yethu sirhuluphela ukuba yi univesithi ye Afrika ekhamba phambili ekuletheni amathuba wokuthuthuka ngokusungula nokhu sungula.sikholwa bonyana kusinikela ithuba elihle ukuthuthukisa umqopho wethu ngamalanga.sisungule isiko lokugidinga iAfrika day solo kwango 2015.sibe netjhudu lokumema aboqwephetjhe bazositlhadlhula ngenarhakazi ye Afrika.
[[Isimumathi:Stratimage.jpg|thumb]]
I Zanex Foundation African languages literarcy project eyaziwa bonyana yi Ulwazi Lwethu ihlanganisa iinhlangano ezine zeengweli esikhaleni semitlolo yabantwana begodu isebenzisa ubucwephetjhe babo ukukhiqiza izinga eliphezulu lelimi le Afrika lokuzigedla kunye nabafundi  abalinganisiweko besigaba sesisekelo.

I Zanex Foundation ithome begodu yasekela ngeemali i Ulwazi lwethu African language reading materials project ngomqopho wokuthuthukisa ukufunda kweencwadi zamalimi we Afrika nokusekela abotitjhere ngensetjenziswa zokufundisa ukufunda kwabentwana abasemazingeni aphasi wefundo ukufunda ngelimi lekhaya.

'''IINKOMBA.'''                                                                                                                              

1.https://ienabler.ump.ac.za/pls/prodi41/w99pkg.mi_login

2.https://www.dsac.gov.za/

3.https://www.zenexfoundation.org.za/

4.https://www.googleadservices.com/pagead/aclk?sa=L&amp;ai=DChcSEwjFqoiInqGNAxWOmFAGHfFjAIUYABABGgJkZw&amp;co=1&amp;gclid=EAIaIQobChMIxaqIiJ6hjQMVjphQBh3xYwCFEAAYASAAEgL_XvD_BwE&amp;ohost=&amp;cid=CAASAuRo&amp;category=acrcp_v1_0&amp;sig=AOD64_3drcTFHUq-fKd8NUbc2q4_SQeLNQ&amp;adurl=https://expatexplore.com/blog/interesting-facts-south-africa/%3Futm_source%3Dgoogle%26utm_medium%3Dcpc%26utm_campaign%3D%7Bcampaignname%7D%26utm_term%3D%26utm_content%3D%26gad_source%3D5%26gad_campaignid%3D22453287344&amp;q=&amp;nb=1&amp;rurl=https%3A%2F%2Fsyndicatedsearch.goog%2F&amp;nm=5&amp;nx=50&amp;ny=7&amp;is=530x806</text>
      <sha1>60mxm1g5e3u4hed8k66e0lh5bwuz5xv</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Jetro mahlangu/Draft2</title>
    <ns>2</ns>
    <id>585</id>
    <revision>
      <id>2733</id>
      <timestamp>2025-04-23T09:43:32Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>Created page with &quot;== ikhasi lami lesibili ==&quot;</comment>
      <origin>2733</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="26" sha1="g56gz5blu222tz47ximcxvusz7x55jj" xml:space="preserve">== ikhasi lami lesibili ==</text>
      <sha1>g56gz5blu222tz47ximcxvusz7x55jj</sha1>
    </revision>
    <revision>
      <id>2858</id>
      <parentid>2733</parentid>
      <timestamp>2025-05-29T02:50:02Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>full article</comment>
      <origin>2858</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4933" sha1="dde6sa0j7wur6lku19u135zj9pryzfd" xml:space="preserve">== ikhasi lami lesibili. ==
'''Ivunulo''' yama https://en.wikipedia.org/wiki/Southern_Ndebele_language ikhamba ihluka kusukela ebantwini beengubo kunye nebantwini bembaji.Kujayelekile ukubona ama Afrika amanengi ahlotjiswe ngeendlela ezihlukahlukeneko zomncamo,yincenye yamasiko wethu.Isiko elingatjhugulukiko elidluliselwa ukusukela esizukulwaneni  ukuya kwesinye.Iinarha ezinengi ze Afrika zinendlela yazo ekhethekileko yokutlama begodu kuyakarisa ukubona iinarha ze Afrika ezahlukahlukeneko zisebenzisa ivunulo ukurhatjha imilayezo ehlukeneko.

https://en.wikipedia.org/wiki/Amandebele sitjhaba sama Nguni esise Sewula Afrika.Isitjhaba lesi saziwa ngobuciko ne vunulo yaso.Umsebenzi wevunulo udlala indima ekulu ekumbaheni kwabo kusukela besebancani njengombana bayisebenzisa ukutshwaya amazinga ahlukileko wamasiko wepilo.Into eqakatheke khulu ekumbatheni kwabo mma bama Ndebele yi tjorholo encani.Abentazana abasebancane bahlobisa itjorholo encani enomncamo.Isiketi esihlukileko lesi sakhiwe ngokuqinileko mtjhini we khanvani ogoqiweko ubotjhwa edinini uhlotjiswe ngqo phezu kwalokhu.Okulenga ebhandeni eliphezulu kulitjhila elifana ne lace ehlanganiswe emabhandeni womncamo.Lokhu kwakhiwe bona kuwele phambi komjeje oqinileko weentambo zekoteni ezifakwe umncamo wembewu emhlophe ephazamiswa isikeli ukwandisa ubukhulu be https://en.wiktionary.org/wiki/garmet begodu kukhuthaze ukudlala kokukhanya lokha nakubonwa kusikinyeka ukutjengisa ukuthaba.

Abentazana abadala esele balenzile isiko bambatha i phephethu ngokunikelwa bomma babo.Iphephethu yenziwe ngesikhumba esikhulu esibunjwe njenge oval esihlanganiswe ngomjeje wemicu emide yomncamo omhlophe begodu sihlotjiswe ngaphezulu ngephetheni yejometri enemibala eminengi kunye neendima ezintathu yamasongo wethusi.Iphephethu ivamise ukubotjhwa edinini belimbathwe phezu kwedini ukuya enzasi.Isikhumba sesikhumba sihloselwe kudosa amehlo ngokugona iinqulo neenyanga begodu ukutjhinga komncamo kungezelela umthelela lokha umntazana nanyakazako.

Ngesikhathi somtjhado nomnyanya wokuthomba umlobokazi umbatha isiyaya ukufihla ubuso lesi kusikhathi sokutjhuguluka ukusuka kwesinye isigaba ukuya kwesinye.Ngaphandle kwesiyaya abomalukazana bama Ndebele bambatha inyonga eyenziwe ngomncamo omhlophe olukwe ngentambo bomma abazinhlobo.Ubude bephetheni nesakhiwo se nyonga kutjho ukuveza izinto ezifana nokobana inga kghani umalukazana uzokuba mfazi wokuthoma womkhwenyana nofana useyintombi.

Umfazi otjhadileko umbatha ingubo phezu kwamahlombe wakhe eneenhluthu ezinengi ezidephileko ezitjhugulweko ezibizwa ngeenrholwani okumincamo eqinileko efakwa entanyeni,eenyaweni,emilenzeni kunye nekhalweni.Babuye bambathe ithusi nethusi emikhonweni entanyeni nemilenzeni.Ingubo abayimbathako yingubo wombhalo unoKhethwako.Abafazi abatjhadileko bahlobisa amabhande wehloko namkha ikepisi elukiweko ukwenza iinhloko ezihle.Umcamo osetjenziselwa ababfazi bama Ndebele abatjhadileko bewune palate ehlengiweko begodu bawusebenzisela umbala izinto kunye namaphetheni ahlotjiswa nokubeletha ne pumelelo.

Imincamo bayifaka imibala ukwenzela bona badlulise ilwazi ngobujamo bezulu,izinga lakhe lokuhlobana nabanye abafazi emphakathini wakhe nofana emdenini wakhe abenza isambatho kunye nekareko yakhe emtjhadweni nomndeni.

Emadodeni wama Ndebele ivunulo yawo ayinamibalabala,ngokwesiko amadoda wama Ndebele ambatha i puleli yesifuba nofana i poriyana elenga entanyeni.Ivamise ukuhlotjiswa ngemincamo phezulu begodu yenziwa ngeenkhumba iporiyana litshwayo lobudoda begodu isokana linikelwa nguyise ngemva kobana lithathe umfazi.Amadoda wama Ndebele amabatha imihlobiso  abayenzelwe bafazi babo.

Ngokwesiko amaNdebele esebenzisa izinto ezitholakala ekhaya ezifana namagobolonda,iinsimbi kunye namathambo weenlwana neenkhumba ukwenza izambatho ezineenhluthu kunye nemihlobiso.Bakhetha izinto ezithileko malungana nokuhlobana kwazo nemvelo engomkomfanekiso nofana engokomoya nofana amakghono wabo wokuvikela umgqoki nokuthuthukisa ubujamo babo emphakathini.Umcamo omnengi wamaNdebele wenziwa ngengilazi nofana umncamo weplastiki.

Ukuqakatheka okukhulu kokwenza umncamo epilweni yabantu abasikazi nendlela ihlathulula ivezwa ngemibala ,amaphetheni we goemetric begodu ukusikinyeka kuragela phambili ngokutjhuguluka kwesikhathi.Umsebenzi wemncamo yihlathululo ebonakalako yokuveza isiqhema sobuhlanga namagugu nobufakazi kunye nokudlulisa ubujamo nokhudluliswa kwama siko.

Hlangana neentjhaba ze Afrika umncamo uhlanganisa ubuhle besiko nofana ubujamo bomtjhado.Esiqhemeni sendabuko samaNdebele abafazi baba mbatha iingubo ezineenhluthu njengetshwayo lepilo yomnotho begodu nokutjengisa inani labentwana abanalo.e-Arika yesimanje manje ihlathululo namatshwayo wokwenza ivunulo sele itjhugulukile kodwana isasetjenziswa ukuzikhakhazisa kwethu ngobu Afrika bethu.

'''iinkomba.'''

1.https://www.vukuzenzele.gov.za/employment

2.https://www.nomadafricamag.com/welcome-mobile/

3.https://www.bona.co.za/</text>
      <sha1>dde6sa0j7wur6lku19u135zj9pryzfd</sha1>
    </revision>
    <revision>
      <id>3198</id>
      <parentid>2858</parentid>
      <timestamp>2025-06-22T18:25:24Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <minor />
      <comment>ngitjhugulule iinkomba</comment>
      <origin>3198</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4996" sha1="9bsycbd68cm48re61dffzp6gmrn0xzp" xml:space="preserve">
[[Isimumathi:Le Grand-Chef Ndébélé en Avril 2017.jpg|thumb|ivunulo yamaNdebele]]
'''Ivunulo''' yama '''Ndebele''' ikhamba ihluka kusukela ebantwini beengubo kunye nebantwini bembaji.Kujayelekile ukubona ama Afrika amanengi ahlotjiswe ngeendlela ezihlukahlukeneko zomncamo,yincenye yamasiko wethu.Isiko elingatjhugulukiko elidluliselwa ukusukela esizukulwaneni  ukuya kwesinye.Iinarha ezinengi ze Afrika zinendlela yazo ekhethekileko yokutlama begodu kuyakarisa ukubona iinarha ze Afrika ezahlukahlukeneko zisebenzisa ivunulo ukurhatjha imilayezo ehlukeneko.

=== Isitjhaba samaNdebele ===
'''AmaNDEBELE''' sitjhaba sama Nguni esise Sewula Afrika.Isitjhaba lesi saziwa ngobuciko ne vunulo yaso.Umsebenzi wevunulo udlala indima ekulu ekumbaheni kwabo kusukela besebancani njengombana bayisebenzisa ukutshwaya amazinga ahlukileko wamasiko wepilo.Into eqakatheke khulu ekumbatheni kwabo mma bama Ndebele yi tjorholo encani.Abentazana abasebancane bahlobisa itjorholo encani enomncamo.Isiketi esihlukileko lesi sakhiwe ngokuqinileko mtjhini we khanvani ogoqiweko ubotjhwa edinini uhlotjiswe ngqo phezu kwalokhu.Okulenga ebhandeni eliphezulu kulitjhila elifana nentambo ehlanganiswe emabhandeni womncamo.Lokhu kwakhiwe bona kuwele phambi komjeje oqinileko weentambo zekoteni ezifakwe umncamo wembewu emhlophe ephazamiswa isikeli ukwandisa ubukhulu besembatho begodu kukhuthaze ukudlala kokukhanya lokha nakubonwa kusikinyeka ukutjengisa ukuthaba.

==== Abentazana bamaNdebele ====
Abentazana abadala esele balenzile isiko bambatha i phephethu ngokunikelwa bomma babo.Iphephethu yenziwe ngesikhumba esikhulu esibunjwe njenge oval esihlanganiswe ngomjeje wemicu emide yomncamo omhlophe begodu sihlotjiswe ngaphezulu ngephetheni yejometri enemibala eminengi kunye neendima ezintathu yamasongo wethusi.Iphephethu ivamise ukubotjhwa edinini belimbathwe phezu kwedini ukuya enzasi.Isikhumba sesikhumba sihloselwe kudosa amehlo ngokugona iinqulo neenyanga begodu ukutjhinga komncamo kungezelela umthelela lokha umntazana nanyakazako.

Ngesikhathi somtjhado nomnyanya wokuthomba umlobokazi umbatha isiyaya ukufihla ubuso lesi kusikhathi sokutjhuguluka ukusuka kwesinye isigaba ukuya kwesinye.Ngaphandle kwesiyaya abomalukazana bama Ndebele bambatha inyonga eyenziwe ngomncamo omhlophe olukwe ngentambo bomma abazinhlobo.Ubude bephetheni nesakhiwo se nyonga kutjho ukuveza izinto ezifana nokobana inga kghani umalukazana uzokuba mfazi wokuthoma womkhwenyana nofana useyintombi.

===== Abomma bamaNdebele =====
Umfazi otjhadileko umbatha ingubo phezu kwamahlombe wakhe eneenhluthu ezinengi ezidephileko ezitjhugulweko ezibizwa ngeenrholwani okumincamo eqinileko efakwa entanyeni,eenyaweni,emilenzeni kunye nekhalweni.Babuye bambathe ithusi nethusi emikhonweni entanyeni nemilenzeni.Ingubo abayimbathako yingubo wombhalo unoKhethwako.Abafazi abatjhadileko bahlobisa amabhande wehloko namkha ikepisi elukiweko ukwenza iinhloko ezihle.Umcamo osetjenziselwa ababfazi bama Ndebele abatjhadileko bewune palate ehlengiweko begodu bawusebenzisela umbala izinto kunye namaphetheni ahlotjiswa nokubeletha ne pumelelo.

Imincamo bayifaka imibala ukwenzela bona badlulise ilwazi ngobujamo bezulu,izinga lakhe lokuhlobana nabanye abafazi emphakathini wakhe nofana emdenini wakhe abenza isambatho kunye nekareko yakhe emtjhadweni nomndeni.

====== Amadoda wamaNdebele        ======
[[Isimumathi:Ndebele Zimbabwe.jpg|thumb|amadoda wamaNdebele]]
Emadodeni wama Ndebele ivunulo yawo ayinamibalabala,ngokwesiko amadoda wama Ndebele ambatha i puleli yesifuba nofana i poriyana elenga entanyeni.Ivamise ukuhlotjiswa ngemincamo phezulu begodu yenziwa ngeenkhumba iporiyana litshwayo lobudoda begodu isokana linikelwa nguyise ngemva kobana lithathe umfazi.Amadoda wama Ndebele amabatha imihlobiso  abayenzelwe bafazi babo.

Ngokwesiko amaNdebele esebenzisa izinto ezitholakala ekhaya ezifana namagobolonda,iinsimbi kunye namathambo weenlwana neenkhumba ukwenza izambatho ezineenhluthu kunye nemihlobiso.Bakhetha izinto ezithileko malungana nokuhlobana kwazo nemvelo engomkomfanekiso nofana engokomoya nofana amakghono wabo wokuvikela umgqoki nokuthuthukisa ubujamo babo emphakathini.Umcamo omnengi wamaNdebele wenziwa ngengilazi nofana umncamo weplastiki.

Ukuqakatheka okukhulu kokwenza umncamo epilweni yabantu abasikazi nendlela ihlathulula ivezwa ngemibala ,amaphetheni we goemetric begodu ukusikinyeka kuragela phambili ngokutjhuguluka kwesikhathi.Umsebenzi wemncamo yihlathululo ebonakalako yokuveza isiqhema sobuhlanga namagugu nobufakazi kunye nokudlulisa ubujamo nokhudluliswa kwama siko.

Hlangana neentjhaba ze Afrika umncamo uhlanganisa ubuhle besiko nofana ubujamo bomtjhado.Esiqhemeni sendabuko samaNdebele abafazi baba mbatha iingubo ezineenhluthu njengetshwayo lepilo yomnotho begodu nokutjengisa inani labentwana abanalo.e-Arika yesimanje manje ihlathululo namatshwayo wokwenza ivunulo sele itjhugulukile kodwana isasetjenziswa ukuzikhakhazisa kwethu ngobu Afrika bethu.

https://www.vukuzenzele.gov.za/employment</text>
      <sha1>9bsycbd68cm48re61dffzp6gmrn0xzp</sha1>
    </revision>
    <revision>
      <id>3199</id>
      <parentid>3198</parentid>
      <timestamp>2025-06-22T18:32:57Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <origin>3199</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5067" sha1="p4if3zyk2sov8klzf7dup6oe6ropedb" xml:space="preserve">
[[Isimumathi:Le Grand-Chef Ndébélé en Avril 2017.jpg|thumb|ivunulo yamaNdebele]]
'''Ivunulo''' yama '''Ndebele''' ikhamba ihluka kusukela ebantwini beengubo kunye nebantwini bembaji.Kujayelekile ukubona ama Afrika amanengi ahlotjiswe ngeendlela ezihlukahlukeneko zomncamo,yincenye yamasiko wethu.Isiko elingatjhugulukiko elidluliselwa ukusukela esizukulwaneni  ukuya kwesinye.Iinarha ezinengi ze Afrika zinendlela yazo ekhethekileko yokutlama begodu kuyakarisa ukubona iinarha ze Afrika ezahlukahlukeneko zisebenzisa ivunulo ukurhatjha imilayezo ehlukeneko.

=== Isitjhaba samaNdebele ===
'''AmaNDEBELE''' sitjhaba sama Nguni esise Sewula Afrika.Isitjhaba lesi saziwa ngobuciko ne vunulo yaso.Umsebenzi wevunulo udlala indima ekulu ekumbaheni kwabo kusukela besebancani njengombana bayisebenzisa ukutshwaya amazinga ahlukileko wamasiko wepilo.Into eqakatheke khulu ekumbatheni kwabo mma bama Ndebele yi tjorholo encani.Abentazana abasebancane bahlobisa itjorholo encani enomncamo.Isiketi esihlukileko lesi sakhiwe ngokuqinileko mtjhini we khanvani ogoqiweko ubotjhwa edinini uhlotjiswe ngqo phezu kwalokhu.Okulenga ebhandeni eliphezulu kulitjhila elifana nentambo ehlanganiswe emabhandeni womncamo.Lokhu kwakhiwe bona kuwele phambi komjeje oqinileko weentambo zekoteni ezifakwe umncamo wembewu emhlophe ephazamiswa isikeli ukwandisa ubukhulu besembatho begodu kukhuthaze ukudlala kokukhanya lokha nakubonwa kusikinyeka ukutjengisa ukuthaba.

==== Abentazana bamaNdebele ====
Abentazana abadala esele balenzile isiko bambatha i phephethu ngokunikelwa bomma babo.Iphephethu yenziwe ngesikhumba esikhulu esibunjwe njenge oval esihlanganiswe ngomjeje wemicu emide yomncamo omhlophe begodu sihlotjiswe ngaphezulu ngephetheni yejometri enemibala eminengi kunye neendima ezintathu yamasongo wethusi.Iphephethu ivamise ukubotjhwa edinini belimbathwe phezu kwedini ukuya enzasi.Isikhumba sesikhumba sihloselwe kudosa amehlo ngokugona iinqulo neenyanga begodu ukutjhinga komncamo kungezelela umthelela lokha umntazana nanyakazako.

Ngesikhathi somtjhado nomnyanya wokuthomba umlobokazi umbatha isiyaya ukufihla ubuso lesi kusikhathi sokutjhuguluka ukusuka kwesinye isigaba ukuya kwesinye.Ngaphandle kwesiyaya abomalukazana bama Ndebele bambatha inyonga eyenziwe ngomncamo omhlophe olukwe ngentambo bomma abazinhlobo.Ubude bephetheni nesakhiwo se nyonga kutjho ukuveza izinto ezifana nokobana inga kghani umalukazana uzokuba mfazi wokuthoma womkhwenyana nofana useyintombi.

===== Abomma bamaNdebele =====
Umfazi otjhadileko umbatha ingubo phezu kwamahlombe wakhe eneenhluthu ezinengi ezidephileko ezitjhugulweko ezibizwa ngeenrholwani okumincamo eqinileko efakwa entanyeni,eenyaweni,emilenzeni kunye nekhalweni.Babuye bambathe ithusi nethusi emikhonweni entanyeni nemilenzeni.Ingubo abayimbathako yingubo wombhalo unoKhethwako.Abafazi abatjhadileko bahlobisa amabhande wehloko namkha ikepisi elukiweko ukwenza iinhloko ezihle.Umcamo osetjenziselwa ababfazi bama Ndebele abatjhadileko bewune palate ehlengiweko begodu bawusebenzisela umbala izinto kunye namaphetheni ahlotjiswa nokubeletha ne pumelelo.

Imincamo bayifaka imibala ukwenzela bona badlulise ilwazi ngobujamo bezulu,izinga lakhe lokuhlobana nabanye abafazi emphakathini wakhe nofana emdenini wakhe abenza isambatho kunye nekareko yakhe emtjhadweni nomndeni.

====== Amadoda wamaNdebele        ======
[[Isimumathi:Ndebele Zimbabwe.jpg|thumb|amadoda wamaNdebele]]
Emadodeni wama Ndebele ivunulo yawo ayinamibalabala,ngokwesiko amadoda wama Ndebele ambatha i puleli yesifuba nofana i poriyana elenga entanyeni.Ivamise ukuhlotjiswa ngemincamo phezulu begodu yenziwa ngeenkhumba iporiyana litshwayo lobudoda begodu isokana linikelwa nguyise ngemva kobana lithathe umfazi.Amadoda wama Ndebele amabatha imihlobiso  abayenzelwe bafazi babo.

Ngokwesiko amaNdebele esebenzisa izinto ezitholakala ekhaya ezifana namagobolonda,iinsimbi kunye namathambo weenlwana neenkhumba ukwenza izambatho ezineenhluthu kunye nemihlobiso.Bakhetha izinto ezithileko malungana nokuhlobana kwazo nemvelo engomkomfanekiso nofana engokomoya nofana amakghono wabo wokuvikela umgqoki nokuthuthukisa ubujamo babo emphakathini.Umcamo omnengi wamaNdebele wenziwa ngengilazi nofana umncamo weplastiki.

Ukuqakatheka okukhulu kokwenza umncamo epilweni yabantu abasikazi nendlela ihlathulula ivezwa ngemibala ,amaphetheni we goemetric begodu ukusikinyeka kuragela phambili ngokutjhuguluka kwesikhathi.Umsebenzi wemncamo yihlathululo ebonakalako yokuveza isiqhema sobuhlanga namagugu nobufakazi kunye nokudlulisa ubujamo nokhudluliswa kwama siko.

Hlangana neentjhaba ze Afrika umncamo uhlanganisa ubuhle besiko nofana ubujamo bomtjhado.Esiqhemeni sendabuko samaNdebele abafazi baba mbatha iingubo ezineenhluthu njengetshwayo lepilo yomnotho begodu nokutjengisa inani labentwana abanalo.e-Arika yesimanje manje ihlathululo namatshwayo wokwenza ivunulo sele itjhugulukile kodwana isasetjenziswa ukuzikhakhazisa kwethu ngobu Afrika bethu.

https://www.vukuzenzele.gov.za/employment
https://www.nomadafricamag.com/welcome-mobile/
https://www.bona.co.za/</text>
      <sha1>p4if3zyk2sov8klzf7dup6oe6ropedb</sha1>
    </revision>
    <revision>
      <id>3200</id>
      <parentid>3199</parentid>
      <timestamp>2025-06-22T18:35:44Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <origin>3200</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5069" sha1="lyjxsmms665dy0ddadr162o4r5u08k7" xml:space="preserve">
[[Isimumathi:Le Grand-Chef Ndébélé en Avril 2017.jpg|thumb|ivunulo yamaNdebele]]
'''Ivunulo''' yama '''Ndebele''' ikhamba ihluka kusukela ebantwini beengubo kunye nebantwini bembaji.Kujayelekile ukubona ama Afrika amanengi ahlotjiswe ngeendlela ezihlukahlukeneko zomncamo,yincenye yamasiko wethu.Isiko elingatjhugulukiko elidluliselwa ukusukela esizukulwaneni  ukuya kwesinye.Iinarha ezinengi ze Afrika zinendlela yazo ekhethekileko yokutlama begodu kuyakarisa ukubona iinarha ze Afrika ezahlukahlukeneko zisebenzisa ivunulo ukurhatjha imilayezo ehlukeneko.

=== Isitjhaba samaNdebele ===
'''AmaNDEBELE''' sitjhaba sama Nguni esise Sewula Afrika.Isitjhaba lesi saziwa ngobuciko ne vunulo yaso.Umsebenzi wevunulo udlala indima ekulu ekumbaheni kwabo kusukela besebancani njengombana bayisebenzisa ukutshwaya amazinga ahlukileko wamasiko wepilo.Into eqakatheke khulu ekumbatheni kwabo mma bama Ndebele yi tjorholo encani.Abentazana abasebancane bahlobisa itjorholo encani enomncamo.Isiketi esihlukileko lesi sakhiwe ngokuqinileko mtjhini we khanvani ogoqiweko ubotjhwa edinini uhlotjiswe ngqo phezu kwalokhu.Okulenga ebhandeni eliphezulu kulitjhila elifana nentambo ehlanganiswe emabhandeni womncamo.Lokhu kwakhiwe bona kuwele phambi komjeje oqinileko weentambo zekoteni ezifakwe umncamo wembewu emhlophe ephazamiswa isikeli ukwandisa ubukhulu besembatho begodu kukhuthaze ukudlala kokukhanya lokha nakubonwa kusikinyeka ukutjengisa ukuthaba.

==== Abentazana bamaNdebele ====
Abentazana abadala esele balenzile isiko bambatha i phephethu ngokunikelwa bomma babo.Iphephethu yenziwe ngesikhumba esikhulu esibunjwe njenge oval esihlanganiswe ngomjeje wemicu emide yomncamo omhlophe begodu sihlotjiswe ngaphezulu ngephetheni yejometri enemibala eminengi kunye neendima ezintathu yamasongo wethusi.Iphephethu ivamise ukubotjhwa edinini belimbathwe phezu kwedini ukuya enzasi.Isikhumba sesikhumba sihloselwe kudosa amehlo ngokugona iinqulo neenyanga begodu ukutjhinga komncamo kungezelela umthelela lokha umntazana nanyakazako.

Ngesikhathi somtjhado nomnyanya wokuthomba umlobokazi umbatha isiyaya ukufihla ubuso lesi kusikhathi sokutjhuguluka ukusuka kwesinye isigaba ukuya kwesinye.Ngaphandle kwesiyaya abomalukazana bama Ndebele bambatha inyonga eyenziwe ngomncamo omhlophe olukwe ngentambo bomma abazinhlobo.Ubude bephetheni nesakhiwo se nyonga kutjho ukuveza izinto ezifana nokobana inga kghani umalukazana uzokuba mfazi wokuthoma womkhwenyana nofana useyintombi.

===== Abomma bamaNdebele =====
Umfazi otjhadileko umbatha ingubo phezu kwamahlombe wakhe eneenhluthu ezinengi ezidephileko ezitjhugulweko ezibizwa ngeenrholwani okumincamo eqinileko efakwa entanyeni,eenyaweni,emilenzeni kunye nekhalweni.Babuye bambathe ithusi nethusi emikhonweni entanyeni nemilenzeni.Ingubo abayimbathako yingubo wombhalo unoKhethwako.Abafazi abatjhadileko bahlobisa amabhande wehloko namkha ikepisi elukiweko ukwenza iinhloko ezihle.Umcamo osetjenziselwa ababfazi bama Ndebele abatjhadileko bewune palate ehlengiweko begodu bawusebenzisela umbala izinto kunye namaphetheni ahlotjiswa nokubeletha ne pumelelo.

Imincamo bayifaka imibala ukwenzela bona badlulise ilwazi ngobujamo bezulu,izinga lakhe lokuhlobana nabanye abafazi emphakathini wakhe nofana emdenini wakhe abenza isambatho kunye nekareko yakhe emtjhadweni nomndeni.

====== Amadoda wamaNdebele        ======
[[Isimumathi:Ndebele Zimbabwe.jpg|thumb|amadoda wamaNdebele]]
Emadodeni wama Ndebele ivunulo yawo ayinamibalabala,ngokwesiko amadoda wama Ndebele ambatha i puleli yesifuba nofana i poriyana elenga entanyeni.Ivamise ukuhlotjiswa ngemincamo phezulu begodu yenziwa ngeenkhumba iporiyana litshwayo lobudoda begodu isokana linikelwa nguyise ngemva kobana lithathe umfazi.Amadoda wama Ndebele amabatha imihlobiso  abayenzelwe bafazi babo.

Ngokwesiko amaNdebele esebenzisa izinto ezitholakala ekhaya ezifana namagobolonda,iinsimbi kunye namathambo weenlwana neenkhumba ukwenza izambatho ezineenhluthu kunye nemihlobiso.Bakhetha izinto ezithileko malungana nokuhlobana kwazo nemvelo engomkomfanekiso nofana engokomoya nofana amakghono wabo wokuvikela umgqoki nokuthuthukisa ubujamo babo emphakathini.Umcamo omnengi wamaNdebele wenziwa ngengilazi nofana umncamo weplastiki.

Ukuqakatheka okukhulu kokwenza umncamo epilweni yabantu abasikazi nendlela ihlathulula ivezwa ngemibala ,amaphetheni we goemetric begodu ukusikinyeka kuragela phambili ngokutjhuguluka kwesikhathi.Umsebenzi wemncamo yihlathululo ebonakalako yokuveza isiqhema sobuhlanga namagugu nobufakazi kunye nokudlulisa ubujamo nokhudluliswa kwama siko.

Hlangana neentjhaba ze Afrika umncamo uhlanganisa ubuhle besiko nofana ubujamo bomtjhado.Esiqhemeni sendabuko samaNdebele abafazi baba mbatha iingubo ezineenhluthu njengetshwayo lepilo yomnotho begodu nokutjengisa inani labentwana abanalo.e-Arika yesimanje manje ihlathululo namatshwayo wokwenza ivunulo sele itjhugulukile kodwana isasetjenziswa ukuzikhakhazisa kwethu ngobu Afrika bethu.

https://www.vukuzenzele.gov.za/employment

https://www.nomadafricamag.com/welcome-mobile/

https://www.bona.co.za/</text>
      <sha1>lyjxsmms665dy0ddadr162o4r5u08k7</sha1>
    </revision>
    <revision>
      <id>3201</id>
      <parentid>3200</parentid>
      <timestamp>2025-06-22T18:38:08Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <origin>3201</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5085" sha1="itcr7gri7fu5g3qtxaprgrxglqxxn1g" xml:space="preserve">
[[Isimumathi:Le Grand-Chef Ndébélé en Avril 2017.jpg|thumb|ivunulo yamaNdebele]]
'''Ivunulo''' yama '''Ndebele''' ikhamba ihluka kusukela ebantwini beengubo kunye nebantwini bembaji.Kujayelekile ukubona ama Afrika amanengi ahlotjiswe ngeendlela ezihlukahlukeneko zomncamo,yincenye yamasiko wethu.Isiko elingatjhugulukiko elidluliselwa ukusukela esizukulwaneni  ukuya kwesinye.Iinarha ezinengi ze Afrika zinendlela yazo ekhethekileko yokutlama begodu kuyakarisa ukubona iinarha ze Afrika ezahlukahlukeneko zisebenzisa ivunulo ukurhatjha imilayezo ehlukeneko.

=== Isitjhaba samaNdebele ===
'''AmaNDEBELE''' sitjhaba sama Nguni esise Sewula Afrika.Isitjhaba lesi saziwa ngobuciko ne vunulo yaso.Umsebenzi wevunulo udlala indima ekulu ekumbaheni kwabo kusukela besebancani njengombana bayisebenzisa ukutshwaya amazinga ahlukileko wamasiko wepilo.Into eqakatheke khulu ekumbatheni kwabo mma bama Ndebele yi tjorholo encani.Abentazana abasebancane bahlobisa itjorholo encani enomncamo.Isiketi esihlukileko lesi sakhiwe ngokuqinileko mtjhini we khanvani ogoqiweko ubotjhwa edinini uhlotjiswe ngqo phezu kwalokhu.Okulenga ebhandeni eliphezulu kulitjhila elifana nentambo ehlanganiswe emabhandeni womncamo.Lokhu kwakhiwe bona kuwele phambi komjeje oqinileko weentambo zekoteni ezifakwe umncamo wembewu emhlophe ephazamiswa isikeli ukwandisa ubukhulu besembatho begodu kukhuthaze ukudlala kokukhanya lokha nakubonwa kusikinyeka ukutjengisa ukuthaba.

==== Abentazana bamaNdebele ====
Abentazana abadala esele balenzile isiko bambatha i phephethu ngokunikelwa bomma babo.Iphephethu yenziwe ngesikhumba esikhulu esibunjwe njenge oval esihlanganiswe ngomjeje wemicu emide yomncamo omhlophe begodu sihlotjiswe ngaphezulu ngephetheni yejometri enemibala eminengi kunye neendima ezintathu yamasongo wethusi.Iphephethu ivamise ukubotjhwa edinini belimbathwe phezu kwedini ukuya enzasi.Isikhumba sesikhumba sihloselwe kudosa amehlo ngokugona iinqulo neenyanga begodu ukutjhinga komncamo kungezelela umthelela lokha umntazana nanyakazako.

Ngesikhathi somtjhado nomnyanya wokuthomba umlobokazi umbatha isiyaya ukufihla ubuso lesi kusikhathi sokutjhuguluka ukusuka kwesinye isigaba ukuya kwesinye.Ngaphandle kwesiyaya abomalukazana bama Ndebele bambatha inyonga eyenziwe ngomncamo omhlophe olukwe ngentambo bomma abazinhlobo.Ubude bephetheni nesakhiwo se nyonga kutjho ukuveza izinto ezifana nokobana inga kghani umalukazana uzokuba mfazi wokuthoma womkhwenyana nofana useyintombi.

===== Abomma bamaNdebele =====
Umfazi otjhadileko umbatha ingubo phezu kwamahlombe wakhe eneenhluthu ezinengi ezidephileko ezitjhugulweko ezibizwa ngeenrholwani okumincamo eqinileko efakwa entanyeni,eenyaweni,emilenzeni kunye nekhalweni.Babuye bambathe ithusi nethusi emikhonweni entanyeni nemilenzeni.Ingubo abayimbathako yingubo wombhalo unoKhethwako.Abafazi abatjhadileko bahlobisa amabhande wehloko namkha ikepisi elukiweko ukwenza iinhloko ezihle.Umcamo osetjenziselwa ababfazi bama Ndebele abatjhadileko bewune palate ehlengiweko begodu bawusebenzisela umbala izinto kunye namaphetheni ahlotjiswa nokubeletha ne pumelelo.

Imincamo bayifaka imibala ukwenzela bona badlulise ilwazi ngobujamo bezulu,izinga lakhe lokuhlobana nabanye abafazi emphakathini wakhe nofana emdenini wakhe abenza isambatho kunye nekareko yakhe emtjhadweni nomndeni.

====== Amadoda wamaNdebele        ======
[[Isimumathi:Ndebele Zimbabwe.jpg|thumb|amadoda wamaNdebele]]
Emadodeni wama Ndebele ivunulo yawo ayinamibalabala,ngokwesiko amadoda wama Ndebele ambatha i puleli yesifuba nofana i poriyana elenga entanyeni.Ivamise ukuhlotjiswa ngemincamo phezulu begodu yenziwa ngeenkhumba iporiyana litshwayo lobudoda begodu isokana linikelwa nguyise ngemva kobana lithathe umfazi.Amadoda wama Ndebele amabatha imihlobiso  abayenzelwe bafazi babo.

Ngokwesiko amaNdebele esebenzisa izinto ezitholakala ekhaya ezifana namagobolonda,iinsimbi kunye namathambo weenlwana neenkhumba ukwenza izambatho ezineenhluthu kunye nemihlobiso.Bakhetha izinto ezithileko malungana nokuhlobana kwazo nemvelo engomkomfanekiso nofana engokomoya nofana amakghono wabo wokuvikela umgqoki nokuthuthukisa ubujamo babo emphakathini.Umcamo omnengi wamaNdebele wenziwa ngengilazi nofana umncamo weplastiki.

Ukuqakatheka okukhulu kokwenza umncamo epilweni yabantu abasikazi nendlela ihlathulula ivezwa ngemibala ,amaphetheni we goemetric begodu ukusikinyeka kuragela phambili ngokutjhuguluka kwesikhathi.Umsebenzi wemncamo yihlathululo ebonakalako yokuveza isiqhema sobuhlanga namagugu nobufakazi kunye nokudlulisa ubujamo nokhudluliswa kwama siko.

Hlangana neentjhaba ze Afrika umncamo uhlanganisa ubuhle besiko nofana ubujamo bomtjhado.Esiqhemeni sendabuko samaNdebele abafazi baba mbatha iingubo ezineenhluthu njengetshwayo lepilo yomnotho begodu nokutjengisa inani labentwana abanalo.e-Arika yesimanje manje ihlathululo namatshwayo wokwenza ivunulo sele itjhugulukile kodwana isasetjenziswa ukuzikhakhazisa kwethu ngobu Afrika bethu.

'''IINKOMBA'''

https://www.vukuzenzele.gov.za/employment

https://www.nomadafricamag.com/welcome-mobile/

https://www.bona.co.za/</text>
      <sha1>itcr7gri7fu5g3qtxaprgrxglqxxn1g</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Jetro mahlangu/Draft 3</title>
    <ns>2</ns>
    <id>586</id>
    <revision>
      <id>2735</id>
      <timestamp>2025-04-23T09:44:43Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>Created page with &quot;== ikhasi lam lesithathu ==&quot;</comment>
      <origin>2735</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="27" sha1="807i44euz27mhb3704k59gyb6khwis1" xml:space="preserve">== ikhasi lam lesithathu ==</text>
      <sha1>807i44euz27mhb3704k59gyb6khwis1</sha1>
    </revision>
    <revision>
      <id>6035</id>
      <parentid>2735</parentid>
      <timestamp>2025-11-26T08:19:58Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>/* ikhasi lam lesithathu */</comment>
      <origin>6035</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5188" sha1="tktbt7kmbkudjo85whb3zraxdzuikyf" xml:space="preserve">== I-POLITICAL KILLINGS TASK TEAM. ==
[[Isimumathi:Part_of_a_bookshelf_containing_books_by_Aristotle_(1).jpg|thumb|iincwadi zomthetho]]

==== '''I-Political killings task team(PKTT)'''bekuyiyunithi ekhethekileko yamapholisa e'''Sewula Afrika''' eyasungulwa ukuphenya nokutjhutjhisa ubulelesi obubangelwa kulwa kwezepolotiki,khulu khulu eendaweni ezifana ne-'''Kwa Zulu Natal''' lapho ukubulawa kwabantu ngebanga lepolitiki kuvame khona.Isiqhema sokusebenza sahlakazwa ngokusemthethweni ngoNobayeni 2024 nguNgqongotjhe wamapholisa u-'''Senzo Mchunu,'''isiqunto athi sivunywe nguMengameli u-'''Cyril Ramaphosa'''. ====

== Umqopho neSakhiwo se-PKTT. ==
Umqopho we-'''PKTT''' bekuphenya ngokubulawa okuhlobene nokuphalisana kwezepolitiki,ngengokulwa ngezikhundla ngaphakathi kweenhlangano zepolotiki nabomasipala.

Isakhiwo se-'''PKTT''' bekuliyunithi ezinikeleko ebegade isebenza namanye ama-ejensi wombuso afana ne-'''National Prosecuting Authority Agency (NPA)'''.Isiqhema siphumelele ekwenzeni ukubopha nokuthola amacala.

==== Ituthuko eqakathekileko. ====
'''.'''Ukuphindaphinda kwesibili kwesiqhema somsebenzi kwathonywa ngo-Velabahlinze 2018.

'''.'''Isiqhema besinomthwalo wenani eliphezulu lokubotjhwa nokugwetjwa okuhlobene nokubulawa kwabantu ngebanga lezepolotiki.

'''.'''Iinhlangano zepolotiki ezithinteke khulu bekuyi-'''ANC,IFP,'''ne-'''NFP.'''

==== Kubayini uNgqongqotjhe wamapholisa e-'''Sewula Afrika''' wayala bonyana isiqhema se-'''PKTT'''  '''sivalwe?''' ====
Imibuzo mibili ekufanele icacise bona umphathintambo bekakhuthazwa ziintshwenyeko ezizwakalako nofana iinhloso zepolotiki ezingakalungi.Emhlanganweni wakhe omangalisako weendaba wango mhlaka-06 kuVelabahlinze 2025,uKhomitjhana wamaPholisa we-Phrovinsi ye-'''KwaZulu-Natal''' u-'''Nhlanhla Mkhwanazi''' iinsolo ezinengi eziphakamisa imibuzo emikhulu ngendima yabosopolotiki abakhohlakeleko namaPholisa ekukhuthazeni ubulelesi obuhlelekileko e-'''Sewula Afrika'''.Ikulumo ka'''Mkhwanazi''' iveze umyalo otlolwe ngu-Ngqongqotjhe wamaPholisa u-'''Senzo Mchunu''' mhlazi-31 kuNobayeni 2024,kobana isiqhema sokusebenza ngokubulalana kwezepolotiki sivalwe msinyana.Waveza bona umyalo lo bewuhloselwe ukukhandela iphenyo lamalunga weenlelesi athokozela ukuvikelwa kwabosopolotiki abakhohlakeleko begodu okungenzeka ahlotjaniswa nokubulawa kwababiki.U-'''Mkhwanazi''' ubonakala aqinisekisa bona amapholisa aphezulu nawo abandakanyeka ekuvimbeleni iphenyo eliragela phambili ngamacala la.Iinsolo zakhe ziphakamisa imibuzo malungana nokuthi u-'''Mchunu''' wenze ngokuzwakalako nangokufaneleko na ngokulaya bona isiqhema sokusebenza sivalwe,nofana bekaneenhloso ezingakalungi.
[[Isimumathi:Senzo Mchunu on PolitySA.jpg|thumb|u-Senzo Mchunu]]

===== UNgqongqotjhe wamaPholisa uvikela ukuhlakazwa kwe-PKTT,wathi uMengameli uvume isiqundo. =====
Ngesikhathi avela uNgqongqotjhe u-'''Mchunu''' wavikela isiqundo sakhe sokuhlakaza i-'''PKTT''' '''Kwa-Zulu Natal''',wazisa ikomidi bona unemvumo kaMengameli u-'''Cyril Ramaphosa''' ukuragela phambili ngesiqundo.U-'''Mchunu''' uveze bona utjele uMengameli u-'''Cyril Ramaphosa''' ngehloso yakhe yokuhlakaza isiqhema somsebenzi begodu begodu uMengameli wasekela ukucabanga kwakhe.Wahlathulula bona ukutjela uMengameli bekuhloswe ngakho ukukhandela ukungezwani kwezepolotiki obuhlobene nesiqhema sokusebenza.&quot;Ngamtjela bona iindaba lezi,hlangana nezinye zingenze ngahlakaza isiqhema lesi.Ngathana bengingakathathi igadango,bekungaba nesikhathi sokuthi kube nekhomitjhini yokuphenya ngeendaba lezo.Nje ke ngaqunda ukukhandela ukubizwa okunjalo.&quot;watjho.Ikomidi ibuye yezwa bona u-'''Mchunu''' weluleka umphathi wakhe wange-ofisini u-'''Cedrick Nkabinde''' bona arekhode ikulumo no-Lieutenant General '''Mkhwanazi''' ngemva kokuthola lokhu ahlathulule bona ziinsongo zokuziphindiselela ezihlobene nokuhlakazwa kwe-'''PKTT'''.Wahlathulula bona ukurekhodwa kwephimbo nge-WhatsApp hlangana no-'''Nkabinde''' no-'''Mkhwanazi''' bekuneentjhijilo zokuthi uKhomitjhina uzokulwa okuvuse ukutshwenyeka ngokuphepha kwakhe.Amagama anqophileko nanyana kunjalo bekangakghoni ukuzwakala kuhle etjhadeni elidlalwe phambi kwekomidi.

====== Nanyana isiqhema somsebenzi sinedumela lokusebenza kuhle,umthelela waso ekubulaweni kwabantu ngebanga lezepolotiki awucaci. ======
Eminyakeni eminengi eli-17 edlulileko uNgqongqotjhe wamaPholisa we-'''Sewula Afrika''' bekavela '''Kwa-Zulu Natal'''.Akukho Ngqongqotjhe wamaPholisa owaziwako bona walinga ukukhawulela ithonya lezepolitiki emapholiseni.Isiqhema esisebenzako kungenzeka bona besisilaphazwe lithonya lezepolotiki solo sathoma.Yasungulwa ngo-2016 ngaphasi kuka-'''Nathi Nhleko''' owakhethwa njengo ngqongqotjhe wamapholisa ngumengameli waphambilini u-'''Jacob Zuma''' ngo-2014.Umbuso ka-'''Zuma''' wazibandakanya ekukhohliseni ihlelo lobulungiswa lobulelesi.

====== Inkhombo. ======
1.https://issafrica.org/iss-today/why-did-sa-s-police-minister-order-the-political-killings-task-team-shutdown
2.https://www.parliament.gov.za/news/police-minister-defends-disbanding-political-killings-task-team-saying-president-approved-decision
3.https://www.enca.com/news/madlanga-commission-mkhwanazi-reveals-why-political-killings-task-team-was-established</text>
      <sha1>tktbt7kmbkudjo85whb3zraxdzuikyf</sha1>
    </revision>
  </page>
  <page>
    <title>Umlambo i-Olifants (i-Limpopo)</title>
    <ns>0</ns>
    <id>587</id>
    <revision>
      <id>2751</id>
      <timestamp>2025-04-24T12:44:44Z</timestamp>
      <contributor>
        <username>Mojonom</username>
        <id>593</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1260180850|Olifants River (Limpopo)]]&quot;</comment>
      <origin>2751</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="952" sha1="em61wz9kvknopz9dyrbgtqn8bdhgxoy" xml:space="preserve"> 

== Umsuka womlambo ==
Umlambo i-Olifants uthoma phakathi kweendawo i-Breyten ne-Bethal, [[Isifunda seMpumalanga|esifundeni se-Mpumalanga]].  Umlambo lo ugeleza tjhuba langetlhagwini ukuya e [[Limpopo|sifundeni seLimpopo]] ngokudlula e-Witbank Dam, idlule nase Loskop Dam bese ikateleleka bonyana itjhinge ngepumalanga yeLimpopo ziintaba ze [[Transvaal]] Drakensberg. Sele useLimpopo. udlula e-Abel Erasmus Pass bese ugelezela ngepumalanga uyokudlula i-Lowveld (esehleni) lapha uyokuhlangana khona nomlambo i-Letaba. Nawusuka lapho, umlambo lo ukhamba utjhinge esifundeni se-Gaza, [[Mozambique|ese-Mozambique]]. ngemva kokuba namajikajika ngonobangela weentaba ze-Lebombo ngendlela ye-[[Olifants Gorge]]. Lapha ke, umlambo lo sewubizwa ngokuthi yi ''-Rio dos Elefantes'', ngelimi lesi Portuguese.  Ekugcineni ihlangane nomlambo i-Limpopo eselelwe makhilomitha ama-40km bonyana ingene e-Indian Ocean e-Xai-Xai etlhagwini ye-[[Maputo]]. 

== I ==



*</text>
      <sha1>em61wz9kvknopz9dyrbgtqn8bdhgxoy</sha1>
    </revision>
    <revision>
      <id>2755</id>
      <parentid>2751</parentid>
      <timestamp>2025-04-24T13:17:21Z</timestamp>
      <contributor>
        <username>Mojonom</username>
        <id>593</id>
      </contributor>
      <origin>2755</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="987" sha1="8n7bnw5amtzghxrtai4vja0ve8zk9em" xml:space="preserve"> 

== Umsuka womlambo ==
Umlambo i-Olifants uthoma phakathi kweendawo i-Breyten ne-Bethal, [[Isifunda seMpumalanga|esifundeni se-Mpumalanga]].  Umlambo lo ugelezela tjhuba langetlhagwini ukuya e[[Limpopo|sifundeni seLimpopo]] ngokudlula e-Witbank Dam, begodu idlule nase Loskop Dam. Kusukela lapho, ikatelelwa ziintaba ze Transvaal Drankensberg bonyana itjhinge ngepumalanga yeLimpopo. Sele useLimpopo, udlula e-Abel Erasmus Pass bese ugelezela ngepumalanga uyokudlula i-Lowveld (esehleni) lapha uyokuhlangana khona nomlambo i-Letaba. Nawusuka lapho, umlambo lo ukhamba utjhinge esifundeni se-Gaza, [[Mozambique|ese-Mozambique]]. ngemva kokuba namajikajika ngonobangela weentaba ze-Lebombo ngendlela ye-[[Olifants Gorge]]. Lapha ke, umlambo lo sewubizwa ngokuthi yi ''-Rio dos Elefantes'', ngelimi lesi [[Portuguese]].  Ekugcineni kwayo ihlangana nomlambo i-Limpopo eselelwe makhilomitha ama-40km bonyana ingene elwandle i-Indian Ocean e-Xai-Xai etlhagwini ye-[[Maputo]]. 

== I ==



*</text>
      <sha1>8n7bnw5amtzghxrtai4vja0ve8zk9em</sha1>
    </revision>
    <revision>
      <id>2757</id>
      <parentid>2755</parentid>
      <timestamp>2025-04-24T13:20:21Z</timestamp>
      <contributor>
        <username>Mojonom</username>
        <id>593</id>
      </contributor>
      <comment>Removed the I that was mistakenly put</comment>
      <origin>2757</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="979" sha1="a4l2it5ev9hfi8kt3goflgnpc2mpsmw" xml:space="preserve"> 

== Umsuka womlambo ==
Umlambo i-Olifants uthoma phakathi kweendawo i-Breyten ne-Bethal, [[Isifunda seMpumalanga|esifundeni se-Mpumalanga]].  Umlambo lo ugelezela tjhuba langetlhagwini ukuya e[[Limpopo|sifundeni seLimpopo]] ngokudlula e-Witbank Dam, begodu idlule nase Loskop Dam. Kusukela lapho, ikatelelwa ziintaba ze Transvaal Drankensberg bonyana itjhinge ngepumalanga yeLimpopo. Sele useLimpopo, udlula e-Abel Erasmus Pass bese ugelezela ngepumalanga uyokudlula i-Lowveld (esehleni) lapha uyokuhlangana khona nomlambo i-Letaba. Nawusuka lapho, umlambo lo ukhamba utjhinge esifundeni se-Gaza, [[Mozambique|ese-Mozambique]]. ngemva kokuba namajikajika ngonobangela weentaba ze-Lebombo ngendlela ye-[[Olifants Gorge]]. Lapha ke, umlambo lo sewubizwa ngokuthi yi ''-Rio dos Elefantes'', ngelimi lesi [[Portuguese]].  Ekugcineni kwayo ihlangana nomlambo i-Limpopo eselelwe makhilomitha ama-40km bonyana ingene elwandle i-Indian Ocean e-Xai-Xai etlhagwini ye-[[Maputo]]. 




*</text>
      <sha1>a4l2it5ev9hfi8kt3goflgnpc2mpsmw</sha1>
    </revision>
    <revision>
      <id>2761</id>
      <parentid>2757</parentid>
      <timestamp>2025-04-24T13:32:36Z</timestamp>
      <contributor>
        <username>Mojonom</username>
        <id>593</id>
      </contributor>
      <origin>2761</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="999" sha1="i10sp5kmff0use1mm0db9l66o1wfemj" xml:space="preserve"> 

== Umsuka womlambo ==
Umlambo i-Olifants uthoma phakathi kweendawo i-Breyten ne-Bethal, [[Isifunda seMpumalanga|esifundeni se-Mpumalanga]].  Umlambo lo ugelezela tjhuba langetlhagwini ukuya e[[Limpopo|sifundeni seLimpopo]] ngokudlula e-Witbank Dam, begodu idlule nase Loskop Dam. Kusukela lapho, ikatelelwa ziintaba ze Transvaal [[:en:Drakensberg|Drankensberg]] bonyana itjhinge ngepumalanga yeLimpopo. Sele useLimpopo, udlula e-Abel Erasmus Pass bese ugelezela ngepumalanga uyokudlula i-Lowveld (esehleni) lapha uyokuhlangana khona nomlambo i-Letaba. Nawusuka lapho, umlambo lo ukhamba utjhinge esifundeni se-Gaza, [[Mozambique|ese-Mozambique]]. ngemva kokuba namajikajika ngonobangela weentaba ze-Lebombo ngendlela ye-[[Olifants Gorge]]. Lapha ke, umlambo lo sewubizwa ngokuthi yi ''-Rio dos Elefantes'', ngelimi lesi [[Portuguese]].  Ekugcineni kwayo ihlangana nomlambo i-Limpopo eselelwe makhilomitha ama-40km bonyana ingene elwandle i-Indian Ocean e-Xai-Xai etlhagwini ye-[[Maputo]]. 




*</text>
      <sha1>i10sp5kmff0use1mm0db9l66o1wfemj</sha1>
    </revision>
    <revision>
      <id>2762</id>
      <parentid>2761</parentid>
      <timestamp>2025-04-24T13:46:45Z</timestamp>
      <contributor>
        <username>Mojonom</username>
        <id>593</id>
      </contributor>
      <comment>Inserted an added reference</comment>
      <origin>2762</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1024" sha1="or20hcj1d26z7pf6sacku5po4rw51pv" xml:space="preserve"> 

== Umsuka womlambo ==
Umlambo i-Olifants uthoma phakathi kweendawo i-Breyten ne-Bethal, [[Isifunda seMpumalanga|esifundeni se-Mpumalanga]].  Umlambo lo ugelezela tjhuba langetlhagwini ukuya e[[Limpopo|sifundeni seLimpopo]] ngokudlula e-Witbank Dam&lt;ref&gt;A Record Breaking Dam - Mpumalanga&lt;/ref&gt;, begodu idlule nase Loskop Dam. Kusukela lapho, ikatelelwa ziintaba ze Transvaal Drankensberg bonyana itjhinge ngepumalanga yeLimpopo. Sele useLimpopo, udlula e-Abel Erasmus Pass bese ugelezela ngepumalanga uyokudlula i-Lowveld (esehleni) lapha uyokuhlangana khona nomlambo i-Letaba. Nawusuka lapho, umlambo lo ukhamba utjhinge esifundeni se-Gaza, [[Mozambique|ese-Mozambique]]. ngemva kokuba namajikajika ngonobangela weentaba ze-Lebombo ngendlela ye-[[Olifants Gorge]]. Lapha ke, umlambo lo sewubizwa ngokuthi yi ''-Rio dos Elefantes'', ngelimi lesi [[Portuguese]].  Ekugcineni kwayo ihlangana nomlambo i-Limpopo eselelwe makhilomitha ama-40km bonyana ingene elwandle i-Indian Ocean e-Xai-Xai etlhagwini ye-[[Maputo]]. 




*</text>
      <sha1>or20hcj1d26z7pf6sacku5po4rw51pv</sha1>
    </revision>
    <revision>
      <id>2764</id>
      <parentid>2762</parentid>
      <timestamp>2025-04-24T13:50:25Z</timestamp>
      <contributor>
        <username>Mojonom</username>
        <id>593</id>
      </contributor>
      <origin>2764</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1092" sha1="dcnmb9310jblpncu7cxek90yj3x5c61" xml:space="preserve"> 

== Umsuka womlambo ==
Umlambo i-Olifants uthoma phakathi kweendawo i-Breyten ne-Bethal, [[Isifunda seMpumalanga|esifundeni se-Mpumalanga]].  Umlambo lo ugelezela tjhuba langetlhagwini ukuya e[[Limpopo|sifundeni seLimpopo]] ngokudlula e-Witbank Dam&lt;ref&gt;[https://www.mpumalanga.com/press-media/blog/a-record-breaking-dam A Record Breaking Dam - Mpumalanga]&lt;/ref&gt;, begodu idlule nase Loskop Dam. Kusukela lapho, ikatelelwa ziintaba ze Transvaal Drankensberg bonyana itjhinge ngepumalanga yeLimpopo. Sele useLimpopo, udlula e-Abel Erasmus Pass bese ugelezela ngepumalanga uyokudlula i-Lowveld (esehleni) lapha uyokuhlangana khona nomlambo i-Letaba. Nawusuka lapho, umlambo lo ukhamba utjhinge esifundeni se-Gaza, [[Mozambique|ese-Mozambique]]. ngemva kokuba namajikajika ngonobangela weentaba ze-Lebombo ngendlela ye-[[Olifants Gorge]]. Lapha ke, umlambo lo sewubizwa ngokuthi yi ''-Rio dos Elefantes'', ngelimi lesi [[Portuguese]].  Ekugcineni kwayo ihlangana nomlambo i-Limpopo eselelwe makhilomitha ama-40km bonyana ingene elwandle i-Indian Ocean e-Xai-Xai etlhagwini ye-[[Maputo]]. 




*</text>
      <sha1>dcnmb9310jblpncu7cxek90yj3x5c61</sha1>
    </revision>
    <revision>
      <id>5643</id>
      <parentid>2764</parentid>
      <timestamp>2025-09-04T10:56:34Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <comment>Migrated page from user draft space</comment>
      <origin>5643</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1597" sha1="ofozndltegrzl2pt5m74outmx5pllwy" xml:space="preserve">[[Isimumathi:Olifants River at Dusk (2393448250).jpg|thumb|Isithombe somalmbo we-Olifants eMpumalanga]]
Umlambo i-Olifants (begodu laziwa nge Lepelle)&lt;ref&gt;{{Cite web |title=Kruger Park Times - Olifants River now called Lepelle |url=https://www.krugerpark.co.za/krugerpark-times-2-15-olifants-river-lepelle-20557.html |access-date=2025-09-04 |website=www.krugerpark.co.za}}&lt;/ref&gt; uthoma phakathi kweendawo i-Breyten ne-Bethal, [[Isifunda seMpumalanga|esifundeni se-Mpumalanga]].  

=== Umlando womlambo ===
Umlambo lo ugelezela tjhuba langetlhagwini ukuya [[Limpopo|esifundeni seLimpopo]] ngokudlula e-Witbank Dam, begodu idlule nase Loskop Dam.&lt;ref&gt;{{Cite web|title=Kruger Park Times - Olifants River now called Lepelle|url=https://www.krugerpark.co.za/krugerpark-times-2-15-olifants-river-lepelle-20557.html|access-date=2025-09-04|website=www.krugerpark.co.za}}&lt;/ref&gt; Kusukela lapho, ikatelelwa ziintaba ze Transvaal Drankensberg bonyana itjhinge ngepumalanga yeLimpopo. Sele useLimpopo, udlula e-Abel Erasmus Pass bese ugelezela ngepumalanga uyokudlula i-Lowveld (esehleni) lapha uyokuhlangana khona nomlambo i-Letaba. Nawusuka lapho, umlambo lo ukhamba utjhinge esifundeni se-Gaza, [[Mozambique|ese-Mozambique]]. ngemva kokuba namajikajika ngonobangela weentaba ze-Lebombo ngendlela ye-[[Olifants Gorge]]. Lapha ke, umlambo lo sewubizwa ngokuthi yi ''-Rio dos Elefantes'', ngelimi lesi [[Portuguese]].  Ekugcineni kwayo ihlangana nomlambo i-Limpopo eselelwe makhilomitha ama-40km bonyana ingene elwandle i-Indian Ocean e-Xai-Xai etlhagwini ye-[[Maputo]].

=== Imithombo lwazi ===
&lt;references /&gt;</text>
      <sha1>ofozndltegrzl2pt5m74outmx5pllwy</sha1>
    </revision>
    <revision>
      <id>5644</id>
      <parentid>5643</parentid>
      <timestamp>2025-09-04T10:59:04Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <comment>Removed redlinks</comment>
      <origin>5644</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1585" sha1="pmy55kgg1vzu4uuldlzcozmug0q75yz" xml:space="preserve">[[Isimumathi:Olifants River at Dusk (2393448250).jpg|thumb|Isithombe somalmbo we-Olifants eMpumalanga]]
Umlambo i-Olifants (begodu laziwa nge Lepelle)&lt;ref&gt;{{Cite web |title=Kruger Park Times - Olifants River now called Lepelle |url=https://www.krugerpark.co.za/krugerpark-times-2-15-olifants-river-lepelle-20557.html |access-date=2025-09-04 |website=www.krugerpark.co.za}}&lt;/ref&gt; uthoma phakathi kweendawo i-Breyten ne-Bethal, [[Isifunda seMpumalanga|esifundeni se-Mpumalanga]].  

=== Umlando womlambo ===
Umlambo lo ugelezela tjhuba langetlhagwini ukuya [[Limpopo|esifundeni seLimpopo]] ngokudlula e-Witbank Dam, begodu idlule nase Loskop Dam.&lt;ref&gt;{{Cite web|title=Kruger Park Times - Olifants River now called Lepelle|url=https://www.krugerpark.co.za/krugerpark-times-2-15-olifants-river-lepelle-20557.html|access-date=2025-09-04|website=www.krugerpark.co.za}}&lt;/ref&gt; Kusukela lapho, ikatelelwa ziintaba ze Transvaal Drankensberg bonyana itjhinge ngepumalanga yeLimpopo. Sele useLimpopo, udlula e-Abel Erasmus Pass bese ugelezela ngepumalanga uyokudlula i-Lowveld (esehleni) lapha uyokuhlangana khona nomlambo i-Letaba. Nawusuka lapho, umlambo lo ukhamba utjhinge esifundeni se-Gaza, [[Mozambique|ese-Mozambique]]. ngemva kokuba namajikajika ngonobangela weentaba ze-Lebombo ngendlela ye-Olifants Gorge. Lapha ke, umlambo lo sewubizwa ngokuthi yi ''-Rio dos Elefantes'', ngelimi lesi Portuguese.  Ekugcineni kwayo ihlangana nomlambo i-Limpopo eselelwe makhilomitha ama-40km bonyana ingene elwandle i-Indian Ocean e-Xai-Xai etlhagwini ye-Maputo.

=== Imithombo lwazi ===
&lt;references /&gt;</text>
      <sha1>pmy55kgg1vzu4uuldlzcozmug0q75yz</sha1>
    </revision>
    <revision>
      <id>5647</id>
      <parentid>5644</parentid>
      <timestamp>2025-09-04T11:05:19Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <minor />
      <comment>added [[Category:Imilambo]] using [[Help:Gadget-HotCat|HotCat]]</comment>
      <origin>5647</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1607" sha1="6wj0w6z0d5oq25l1pxzjkelw9qg3p1e" xml:space="preserve">[[Isimumathi:Olifants River at Dusk (2393448250).jpg|thumb|Isithombe somalmbo we-Olifants eMpumalanga]]
Umlambo i-Olifants (begodu laziwa nge Lepelle)&lt;ref&gt;{{Cite web |title=Kruger Park Times - Olifants River now called Lepelle |url=https://www.krugerpark.co.za/krugerpark-times-2-15-olifants-river-lepelle-20557.html |access-date=2025-09-04 |website=www.krugerpark.co.za}}&lt;/ref&gt; uthoma phakathi kweendawo i-Breyten ne-Bethal, [[Isifunda seMpumalanga|esifundeni se-Mpumalanga]].  

=== Umlando womlambo ===
Umlambo lo ugelezela tjhuba langetlhagwini ukuya [[Limpopo|esifundeni seLimpopo]] ngokudlula e-Witbank Dam, begodu idlule nase Loskop Dam.&lt;ref&gt;{{Cite web|title=Kruger Park Times - Olifants River now called Lepelle|url=https://www.krugerpark.co.za/krugerpark-times-2-15-olifants-river-lepelle-20557.html|access-date=2025-09-04|website=www.krugerpark.co.za}}&lt;/ref&gt; Kusukela lapho, ikatelelwa ziintaba ze Transvaal Drankensberg bonyana itjhinge ngepumalanga yeLimpopo. Sele useLimpopo, udlula e-Abel Erasmus Pass bese ugelezela ngepumalanga uyokudlula i-Lowveld (esehleni) lapha uyokuhlangana khona nomlambo i-Letaba. Nawusuka lapho, umlambo lo ukhamba utjhinge esifundeni se-Gaza, [[Mozambique|ese-Mozambique]]. ngemva kokuba namajikajika ngonobangela weentaba ze-Lebombo ngendlela ye-Olifants Gorge. Lapha ke, umlambo lo sewubizwa ngokuthi yi ''-Rio dos Elefantes'', ngelimi lesi Portuguese.  Ekugcineni kwayo ihlangana nomlambo i-Limpopo eselelwe makhilomitha ama-40km bonyana ingene elwandle i-Indian Ocean e-Xai-Xai etlhagwini ye-Maputo.

=== Imithombo lwazi ===
&lt;references /&gt;

[[Mkhakha:Imilambo]]</text>
      <sha1>6wj0w6z0d5oq25l1pxzjkelw9qg3p1e</sha1>
    </revision>
    <revision>
      <id>5670</id>
      <parentid>5647</parentid>
      <timestamp>2025-09-04T11:21:10Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <origin>5670</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1092" sha1="dcnmb9310jblpncu7cxek90yj3x5c61" xml:space="preserve"> 

== Umsuka womlambo ==
Umlambo i-Olifants uthoma phakathi kweendawo i-Breyten ne-Bethal, [[Isifunda seMpumalanga|esifundeni se-Mpumalanga]].  Umlambo lo ugelezela tjhuba langetlhagwini ukuya e[[Limpopo|sifundeni seLimpopo]] ngokudlula e-Witbank Dam&lt;ref&gt;[https://www.mpumalanga.com/press-media/blog/a-record-breaking-dam A Record Breaking Dam - Mpumalanga]&lt;/ref&gt;, begodu idlule nase Loskop Dam. Kusukela lapho, ikatelelwa ziintaba ze Transvaal Drankensberg bonyana itjhinge ngepumalanga yeLimpopo. Sele useLimpopo, udlula e-Abel Erasmus Pass bese ugelezela ngepumalanga uyokudlula i-Lowveld (esehleni) lapha uyokuhlangana khona nomlambo i-Letaba. Nawusuka lapho, umlambo lo ukhamba utjhinge esifundeni se-Gaza, [[Mozambique|ese-Mozambique]]. ngemva kokuba namajikajika ngonobangela weentaba ze-Lebombo ngendlela ye-[[Olifants Gorge]]. Lapha ke, umlambo lo sewubizwa ngokuthi yi ''-Rio dos Elefantes'', ngelimi lesi [[Portuguese]].  Ekugcineni kwayo ihlangana nomlambo i-Limpopo eselelwe makhilomitha ama-40km bonyana ingene elwandle i-Indian Ocean e-Xai-Xai etlhagwini ye-[[Maputo]]. 




*</text>
      <sha1>dcnmb9310jblpncu7cxek90yj3x5c61</sha1>
    </revision>
    <revision>
      <id>5681</id>
      <parentid>5670</parentid>
      <timestamp>2025-09-04T11:34:11Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <origin>5681</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1597" sha1="ofozndltegrzl2pt5m74outmx5pllwy" xml:space="preserve">[[Isimumathi:Olifants River at Dusk (2393448250).jpg|thumb|Isithombe somalmbo we-Olifants eMpumalanga]]
Umlambo i-Olifants (begodu laziwa nge Lepelle)&lt;ref&gt;{{Cite web |title=Kruger Park Times - Olifants River now called Lepelle |url=https://www.krugerpark.co.za/krugerpark-times-2-15-olifants-river-lepelle-20557.html |access-date=2025-09-04 |website=www.krugerpark.co.za}}&lt;/ref&gt; uthoma phakathi kweendawo i-Breyten ne-Bethal, [[Isifunda seMpumalanga|esifundeni se-Mpumalanga]].  

=== Umlando womlambo ===
Umlambo lo ugelezela tjhuba langetlhagwini ukuya [[Limpopo|esifundeni seLimpopo]] ngokudlula e-Witbank Dam, begodu idlule nase Loskop Dam.&lt;ref&gt;{{Cite web|title=Kruger Park Times - Olifants River now called Lepelle|url=https://www.krugerpark.co.za/krugerpark-times-2-15-olifants-river-lepelle-20557.html|access-date=2025-09-04|website=www.krugerpark.co.za}}&lt;/ref&gt; Kusukela lapho, ikatelelwa ziintaba ze Transvaal Drankensberg bonyana itjhinge ngepumalanga yeLimpopo. Sele useLimpopo, udlula e-Abel Erasmus Pass bese ugelezela ngepumalanga uyokudlula i-Lowveld (esehleni) lapha uyokuhlangana khona nomlambo i-Letaba. Nawusuka lapho, umlambo lo ukhamba utjhinge esifundeni se-Gaza, [[Mozambique|ese-Mozambique]]. ngemva kokuba namajikajika ngonobangela weentaba ze-Lebombo ngendlela ye-[[Olifants Gorge]]. Lapha ke, umlambo lo sewubizwa ngokuthi yi ''-Rio dos Elefantes'', ngelimi lesi [[Portuguese]].  Ekugcineni kwayo ihlangana nomlambo i-Limpopo eselelwe makhilomitha ama-40km bonyana ingene elwandle i-Indian Ocean e-Xai-Xai etlhagwini ye-[[Maputo]].

=== Imithombo lwazi ===
&lt;references /&gt;</text>
      <sha1>ofozndltegrzl2pt5m74outmx5pllwy</sha1>
    </revision>
    <revision>
      <id>5683</id>
      <parentid>5681</parentid>
      <timestamp>2025-09-04T11:35:37Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <origin>5683</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1585" sha1="pmy55kgg1vzu4uuldlzcozmug0q75yz" xml:space="preserve">[[Isimumathi:Olifants River at Dusk (2393448250).jpg|thumb|Isithombe somalmbo we-Olifants eMpumalanga]]
Umlambo i-Olifants (begodu laziwa nge Lepelle)&lt;ref&gt;{{Cite web |title=Kruger Park Times - Olifants River now called Lepelle |url=https://www.krugerpark.co.za/krugerpark-times-2-15-olifants-river-lepelle-20557.html |access-date=2025-09-04 |website=www.krugerpark.co.za}}&lt;/ref&gt; uthoma phakathi kweendawo i-Breyten ne-Bethal, [[Isifunda seMpumalanga|esifundeni se-Mpumalanga]].  

=== Umlando womlambo ===
Umlambo lo ugelezela tjhuba langetlhagwini ukuya [[Limpopo|esifundeni seLimpopo]] ngokudlula e-Witbank Dam, begodu idlule nase Loskop Dam.&lt;ref&gt;{{Cite web|title=Kruger Park Times - Olifants River now called Lepelle|url=https://www.krugerpark.co.za/krugerpark-times-2-15-olifants-river-lepelle-20557.html|access-date=2025-09-04|website=www.krugerpark.co.za}}&lt;/ref&gt; Kusukela lapho, ikatelelwa ziintaba ze Transvaal Drankensberg bonyana itjhinge ngepumalanga yeLimpopo. Sele useLimpopo, udlula e-Abel Erasmus Pass bese ugelezela ngepumalanga uyokudlula i-Lowveld (esehleni) lapha uyokuhlangana khona nomlambo i-Letaba. Nawusuka lapho, umlambo lo ukhamba utjhinge esifundeni se-Gaza, [[Mozambique|ese-Mozambique]]. ngemva kokuba namajikajika ngonobangela weentaba ze-Lebombo ngendlela ye-Olifants Gorge. Lapha ke, umlambo lo sewubizwa ngokuthi yi ''-Rio dos Elefantes'', ngelimi lesi Portuguese.  Ekugcineni kwayo ihlangana nomlambo i-Limpopo eselelwe makhilomitha ama-40km bonyana ingene elwandle i-Indian Ocean e-Xai-Xai etlhagwini ye-Maputo.

=== Imithombo lwazi ===
&lt;references /&gt;</text>
      <sha1>pmy55kgg1vzu4uuldlzcozmug0q75yz</sha1>
    </revision>
  </page>
  <page>
    <title>IYunivesithi ye-Pitoli</title>
    <ns>0</ns>
    <id>588</id>
    <revision>
      <id>2752</id>
      <timestamp>2025-04-24T12:45:34Z</timestamp>
      <contributor>
        <username>Masombukaunathi</username>
        <id>595</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1286835884|University of Pretoria]]&quot;</comment>
      <origin>2752</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="457" sha1="be5qdwe2s0wbzlhykyc4j3f76crmzdg" xml:space="preserve">
'''IYunivesithi ye-Pretoria''' ( Afrikaans  , Northern Sotho   ) .  ​''​''  IYunivesithi yasungulwa ngo-1908 njengekhampasi ye-Pretoria ye- Transvaal Universit[[Afrika]] College e [[Johannesburg|-Johannesburg,]] begodu isikhungo sesine eSewula  esiragela phambili ukunikelwa isikhundla seYunivesithi. IYunivesithi isuke kubafundi abama-32 bokuthoma endlini ye-Victorian ukuya ema-53,000 ngo-2019.  IYunivesithi yakhiwa emakhampasini alikhomba wedorobha</text>
      <sha1>be5qdwe2s0wbzlhykyc4j3f76crmzdg</sha1>
    </revision>
    <revision>
      <id>2754</id>
      <parentid>2752</parentid>
      <timestamp>2025-04-24T12:59:45Z</timestamp>
      <contributor>
        <username>Masombukaunathi</username>
        <id>595</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1286835884|University of Pretoria]]&quot;</comment>
      <origin>2754</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="458" sha1="48ytnkesif298xcpy4tt6k760igdqkt" xml:space="preserve">
 

'''IYunivesithi ye-Pretoria''' (Afrikaans, Northern Sotho   ) .  ​''​''  IYunivesithi yasungulwa ngo-1908 njengekhampasi ye-Pretoria ye- Transvaal Universit[[Afrika]] College e [[Johannesburg|-Johannesburg,]] begodu isikhungo sesine eSewula  esiragela phambili ukunikelwa isikhundla seYunivesithi. IYunivesithi isuke kubafundi abama-32 bokuthoma endlini ye-Victorian ukuya ema-53,000 ngo-2019.  IYunivesithi yakhiwa emakhampasini alikhomba wedorobha</text>
      <sha1>48ytnkesif298xcpy4tt6k760igdqkt</sha1>
    </revision>
    <revision>
      <id>2759</id>
      <parentid>2754</parentid>
      <timestamp>2025-04-24T13:30:02Z</timestamp>
      <contributor>
        <username>Masombukaunathi</username>
        <id>595</id>
      </contributor>
      <minor />
      <comment>Link added</comment>
      <origin>2759</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="478" sha1="dlmrzor3ulnbwr0a7j0eqfbx2qzat7d" xml:space="preserve">
 

'''IYunivesithi ye-Pretoria''' (Afrikaans, Northern Sotho ). IYunivesithi yasungulwa ngo-1908 njengekhampasi ye-Pretoria ye- [https://www.britannica.com/place/Transvaal Transvaal] University College e [[Johannesburg|-Johannesburg,]] begodu isikhungo sesine eSewula  esiragela phambili ukunikelwa isikhundla seYunivesithi. IYunivesithi isuke kubafundi abama-32 bokuthoma endlini ye-Victorian ukuya ema-53,000 ngo-2019.  IYunivesithi yakhiwa emakhampasini alikhomba wedorobha</text>
      <sha1>dlmrzor3ulnbwr0a7j0eqfbx2qzat7d</sha1>
    </revision>
    <revision>
      <id>5227</id>
      <parentid>2759</parentid>
      <timestamp>2025-08-24T23:41:15Z</timestamp>
      <contributor>
        <username>Mojonom</username>
        <id>593</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1305292120|University of Pretoria]]&quot;</comment>
      <origin>5227</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1752" sha1="4cz3wj3h91or0k6zejdcrr3fz917f9c" xml:space="preserve">
'''IYunivesithi ye-Pitori''' kuyiyunivesithi eyathonywa ngo-1908 njengekhampasi yePitori engaphasi kwe Transvaal University College ese- [[Johannesburg|Jwanashege]]. Iyunivesithi yathoma ngokuba nabafundi abama-32 ngomnyaka we 1908 kufikela ebafundini abama-53 000 ngo-2025. Nje, iyunivesithi leinamakhampasi alikhomba akhona hlangana nedorobha lePitori. 


Iyunivesithi ivamise ukubizwa ngokuthi yi-UP, i-Tuks namkha i-Tukkies.
[[File:University_of_Pretoria_Old_Arts_building.jpg|left|thumb|Umakhiwo we Old Arts Building{{center|The [[Old Arts Building (University of Pretoria)|Old Arts Building]] in 1910, now a [[Provincial heritage site (South Africa)|provincial heritage site]]}}]]
[[Isimumathi:University_of_Pretoria_Campus_plan_1930.jpg|left|thumb|Umebhe we Yunivesithi ngomnyaka ka 1930{{center|University of Pretoria Main Campus master plan in 1930}}]]

== Ama Faculty we Yunivesity ==
{| class=&quot;toccolours&quot; style=&quot;float:right; margin-left:1em; font-size:90%; line-height:1.4em; width:300px;&quot;
! colspan=&quot;2&quot; style=&quot;text-align: center;&quot; |Ukusungulwa kwefakhalthi
|-
| '''I-Fakhalthi'''
| '''Umnyaka owasungulwa'''
|-
| colspan=&quot;2&quot; |
----
|-
|I-Fakhalthi yezeSayensi yezomNotho neyokuPhatha
| 1920
|-
| I-Fakhalthi yezeFundo
| 1902
|-
| Ubunjiniyela, iBhoduluko elakhiweko kanye neThekhnoloji yeLwazi
| 1908
|-
| I-Faculty yezeSayensi yezamaPhilo
| 1943
|-
| I-Faculty of Humanities
| 1908
|-
| I-Faculty yezomThetho
| 1908
|-
| I-Faculty yezeSayensi yezeMvelo neyezokuLima
| 1917
|-
| I-Faculty yezekolo
| 1919
|-
| I-Fakhalthi yeSayensi yeenlwana
| 1920
|-
| I-Gordon Institute of Business Science
| 2000
|}

== Ikhampasi ekulu ==
[[Isimumathi:Ou_Lettere,_d,_Tuks.jpg|left|thumb| {{center|The Old Arts building now contains several museums}}]]</text>
      <sha1>4cz3wj3h91or0k6zejdcrr3fz917f9c</sha1>
    </revision>
  </page>
  <page>
    <title>Isayensi yengqondo</title>
    <ns>0</ns>
    <id>589</id>
    <revision>
      <id>2753</id>
      <timestamp>2025-04-24T12:46:26Z</timestamp>
      <contributor>
        <username>Inno06</username>
        <id>594</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1286930337|Psychology]]&quot;</comment>
      <origin>2753</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1237" sha1="7vly4w4t7nb3sab52rpyk5x80pyarrd" xml:space="preserve"> 

'''Isayikholoji''' kusifundo sesayensi sengqondo nokuziphatha.   Indaba yayo ifaka hlangana ukuziphatha kwabantu nokhunye okungaphili njengabantu, kokubili izinto ezizwakalako nezingezwakaliko, kanye neenkambo zengqondo ezifana nemicabango, imizwa, kanye neenhloso. Isayikholoji mkhakha wezefundo omkhulu khulu, owela hlangana nesayensi yemvelo neyehlalakuhle. Abasazi bengqondo zezinto eziphilako bafuna ukuzwisisa izakhiwo ezivelako zobuchopho, zihlanganisa umkhakha lo nesayensi yezinzwa. Njengabososayensi bezehlalakuhle, izazi zengqondo zihlose ukuzwisisa ukuziphatha kwabantu namaqembu.  

Izazi zengqondo zibandakanyeka ekurhubhululeni ukubona, ukuqabanga, ukutjheja, imizwa, ubuhlakani, amava wokuzikhethela, ukukhuthazeka, ukusebenza kwengqondo kanye nobuntu. Iinrhuluphelo zabososayensi bezeengqondo zikhula zifinyelele ebudlelwaneni phakathi kwabantu, ukuqina kwengqondo, ukujamelana nomndeni, nezinye iindawo ngaphakathi kwesayensi yezehlalakuhle. Baphinde bacabangele ingqondo engazi lutho.  Izazi zengqondo zisebenzisa iindlela ezihlolisisako ukuthola ubudlelwane phakathi kwezinto ezihlukahlukeneko zengqondo . Abanye, kodwana ingasi boke, izazi zengqondo zezokwelapha nezeluleko zithembele ekuhlathululeni okufanako .</text>
      <sha1>7vly4w4t7nb3sab52rpyk5x80pyarrd</sha1>
    </revision>
    <revision>
      <id>2756</id>
      <parentid>2753</parentid>
      <timestamp>2025-04-24T13:18:33Z</timestamp>
      <contributor>
        <username>Inno06</username>
        <id>594</id>
      </contributor>
      <comment>I have corrected the first sentence and spaces</comment>
      <origin>2756</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1229" sha1="h5t22b34ll76mmxxpm7bd4p2faou03d" xml:space="preserve"> 

'''Isayensi yengqondo''' kusifundo sengqondo nokuziphatha. Indaba yayo ifaka hlangana ukuziphatha kwabantu nokhunye okungaphili njengabantu, kokubili izinto ezizwakalako nezingezwakaliko, kanye neenkambo zengqondo ezifana nemicabango, imizwa, kanye neenhloso. Isayikholoji mkhakha wezefundo omkhulu khulu, owela hlangana nesayensi yemvelo neyehlalakuhle. Abasazi bengqondo zezinto eziphilako bafuna ukuzwisisa izakhiwo ezivelako zobuchopho, zihlanganisa umkhakha lo nesayensi yezinzwa. Njengabososayensi bezehlalakuhle, izazi zengqondo zihlose ukuzwisisa ukuziphatha kwabantu namaqembu.  

Izazi zengqondo zibandakanyeka ekurhubhululeni ukubona, ukuqabanga, ukutjheja, imizwa, ubuhlakani, amava wokuzikhethela, ukukhuthazeka, ukusebenza kwengqondo kanye nobuntu. Iinrhuluphelo zabososayensi bezeengqondo zikhula zifinyelele ebudlelwaneni phakathi kwabantu, ukuqina kwengqondo, ukujamelana nomndeni, nezinye iindawo ngaphakathi kwesayensi yezehlalakuhle. Baphinde bacabangele ingqondo engazi lutho. Izazi zengqondo zisebenzisa iindlela ezihlolisisako ukuthola ubudlelwane phakathi kwezinto ezihlukahlukeneko zengqondo. Abanye, kodwana ingasi boke, izazi zengqondo zezokwelapha nezeluleko zithembele ekuhlathululeni okufanako .</text>
      <sha1>h5t22b34ll76mmxxpm7bd4p2faou03d</sha1>
    </revision>
    <revision>
      <id>2758</id>
      <parentid>2756</parentid>
      <timestamp>2025-04-24T13:29:03Z</timestamp>
      <contributor>
        <username>Inno06</username>
        <id>594</id>
      </contributor>
      <comment>linked</comment>
      <origin>2758</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1233" sha1="fi3xjfmggr0wcughrqb0lv6v31thxuc" xml:space="preserve"> 

'''[[Isayensi yengqondo]]''' kusifundo sengqondo nokuziphatha. Indaba yayo ifaka hlangana ukuziphatha kwabantu nokhunye okungaphili njengabantu, kokubili izinto ezizwakalako nezingezwakaliko, kanye neenkambo zengqondo ezifana nemicabango, imizwa, kanye neenhloso. Isayikholoji mkhakha wezefundo omkhulu khulu, owela hlangana nesayensi yemvelo neyehlalakuhle. Abasazi bengqondo zezinto eziphilako bafuna ukuzwisisa izakhiwo ezivelako zobuchopho, zihlanganisa umkhakha lo nesayensi yezinzwa. Njengabososayensi bezehlalakuhle, izazi zengqondo zihlose ukuzwisisa ukuziphatha kwabantu namaqembu.  

Izazi zengqondo zibandakanyeka ekurhubhululeni ukubona, ukuqabanga, ukutjheja, imizwa, ubuhlakani, amava wokuzikhethela, ukukhuthazeka, ukusebenza kwengqondo kanye nobuntu. Iinrhuluphelo zabososayensi bezeengqondo zikhula zifinyelele ebudlelwaneni phakathi kwabantu, ukuqina kwengqondo, ukujamelana nomndeni, nezinye iindawo ngaphakathi kwesayensi yezehlalakuhle. Baphinde bacabangele ingqondo engazi lutho. Izazi zengqondo zisebenzisa iindlela ezihlolisisako ukuthola ubudlelwane phakathi kwezinto ezihlukahlukeneko zengqondo. Abanye, kodwana ingasi boke, izazi zengqondo zezokwelapha nezeluleko zithembele ekuhlathululeni okufanako .</text>
      <sha1>fi3xjfmggr0wcughrqb0lv6v31thxuc</sha1>
    </revision>
    <revision>
      <id>2760</id>
      <parentid>2758</parentid>
      <timestamp>2025-04-24T13:31:59Z</timestamp>
      <contributor>
        <username>Inno06</username>
        <id>594</id>
      </contributor>
      <comment>linked</comment>
      <origin>2760</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1237" sha1="r56dcncdeg1szuw9xidxkq2gdeowz10" xml:space="preserve"> 

'''[[Isayensi yengqondo]]''' kusifundo sengqondo nokuziphatha. Indaba yayo ifaka hlangana ukuziphatha kwabantu nokhunye okungaphili njengabantu, kokubili izinto ezizwakalako nezingezwakaliko, kanye neenkambo zengqondo ezifana nemicabango, imizwa, kanye neenhloso. Isayikholoji mkhakha wezefundo omkhulu khulu, owela hlangana nesayensi yemvelo neyehlalakuhle. [[Abasazi bengqondo zezinto eziphilako]] bafuna ukuzwisisa izakhiwo ezivelako zobuchopho, zihlanganisa umkhakha lo nesayensi yezinzwa. Njengabososayensi bezehlalakuhle, izazi zengqondo zihlose ukuzwisisa ukuziphatha kwabantu namaqembu.  

Izazi zengqondo zibandakanyeka ekurhubhululeni ukubona, ukuqabanga, ukutjheja, imizwa, ubuhlakani, amava wokuzikhethela, ukukhuthazeka, ukusebenza kwengqondo kanye nobuntu. Iinrhuluphelo zabososayensi bezeengqondo zikhula zifinyelele ebudlelwaneni phakathi kwabantu, ukuqina kwengqondo, ukujamelana nomndeni, nezinye iindawo ngaphakathi kwesayensi yezehlalakuhle. Baphinde bacabangele ingqondo engazi lutho. Izazi zengqondo zisebenzisa iindlela ezihlolisisako ukuthola ubudlelwane phakathi kwezinto ezihlukahlukeneko zengqondo. Abanye, kodwana ingasi boke, izazi zengqondo zezokwelapha nezeluleko zithembele ekuhlathululeni okufanako .</text>
      <sha1>r56dcncdeg1szuw9xidxkq2gdeowz10</sha1>
    </revision>
    <revision>
      <id>2763</id>
      <parentid>2760</parentid>
      <timestamp>2025-04-24T13:47:33Z</timestamp>
      <contributor>
        <username>Inno06</username>
        <id>594</id>
      </contributor>
      <comment>added a reference</comment>
      <origin>2763</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1313" sha1="ga6ece1joumcy5z6mcht2bim16r4g4o" xml:space="preserve"> 

'''[[Isayensi yengqondo]]''' kusifundo sengqondo nokuziphatha. Indaba yayo ifaka hlangana ukuziphatha kwabantu nokhunye okungaphili njengabantu, kokubili izinto ezizwakalako nezingezwakaliko, kanye neenkambo zengqondo ezifana nemicabango, imizwa, kanye neenhloso. Isayikholoji mkhakha wezefundo omkhulu khulu, owela hlangana nesayensi yemvelo neyehlalakuhle. [[Abasazi bengqondo zezinto eziphilako]] bafuna ukuzwisisa izakhiwo ezivelako zobuchopho, zihlanganisa umkhakha lo nesayensi yezinzwa. Njengabososayensi bezehlalakuhle, izazi zengqondo zihlose ukuzwisisa ukuziphatha kwabantu namaqembu.&lt;ref&gt;Psychology: Definitions, branches, history, and how to become one&lt;/ref&gt;  

Izazi zengqondo zibandakanyeka ekurhubhululeni ukubona, ukuqabanga, ukutjheja, imizwa, ubuhlakani, amava wokuzikhethela, ukukhuthazeka, ukusebenza kwengqondo kanye nobuntu. Iinrhuluphelo zabososayensi bezeengqondo zikhula zifinyelele ebudlelwaneni phakathi kwabantu, ukuqina kwengqondo, ukujamelana nomndeni, nezinye iindawo ngaphakathi kwesayensi yezehlalakuhle. Baphinde bacabangele ingqondo engazi lutho. Izazi zengqondo zisebenzisa iindlela ezihlolisisako ukuthola ubudlelwane phakathi kwezinto ezihlukahlukeneko zengqondo. Abanye, kodwana ingasi boke, izazi zengqondo zezokwelapha nezeluleko zithembele ekuhlathululeni okufanako .</text>
      <sha1>ga6ece1joumcy5z6mcht2bim16r4g4o</sha1>
    </revision>
  </page>
  <page>
    <title>Ukukhuthaza abantu abakhuluma isiNdebele ngokuthuthukisa ilimi</title>
    <ns>0</ns>
    <id>590</id>
    <revision>
      <id>2765</id>
      <timestamp>2025-04-25T08:00:09Z</timestamp>
      <contributor>
        <username>Inno06</username>
        <id>594</id>
      </contributor>
      <comment>added heading</comment>
      <origin>2765</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="534" sha1="ong55u20jq1t35bmzawj8ili267dv5s" xml:space="preserve">'''IsiNdebele''' ngelinye lamalimi wabaNguni asemthethweni eSewula Afrika elisetjenziswa nakukhulunywako, eenkolweni, emisebenzini kanye nezinye iindawo. Ilimi lesiNdebele likhulunywa sitjhaba esibizwa bona maNdebele esitholakala eendaweni ezihlukahlukeneko njengeTransvaal


Ilimi liyindlela yokuthintana kungaba kukhuluma, kufunda kanye nokutlola. Ilimi lidosa phambili ekwakheni indlela esenza ngayo izinto ngombana bengeke sakghona ukuthintana nokuzwana ngabe bekungasilo.

== Indlela ezingasetjenziswa ukuthuthukisa isiNdebele ==</text>
      <sha1>ong55u20jq1t35bmzawj8ili267dv5s</sha1>
    </revision>
    <revision>
      <id>2766</id>
      <parentid>2765</parentid>
      <timestamp>2025-04-25T08:07:35Z</timestamp>
      <contributor>
        <username>Inno06</username>
        <id>594</id>
      </contributor>
      <comment>Created my first article ,bolded first word and added a  heading</comment>
      <origin>2766</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="943" sha1="ex6sk1upke4fsa2a3f25ioy6hfhfxhg" xml:space="preserve">'''IsiNdebele''' ngelinye lamalimi wabaNguni asemthethweni eSewula Afrika elisetjenziswa nakukhulunywako, eenkolweni, emisebenzini kanye nezinye iindawo. Ilimi lesiNdebele likhulunywa sitjhaba esibizwa bona maNdebele esitholakala eendaweni ezihlukahlukeneko zangeSewula Afrika. Kunemihlobo emibili eyaziwako yamaNdebele ekhuluma isiNdebele esihlukileko ingasi khulu godu. SinamaNdebele abizwa bona maNala kanye namaNzunza. 


Ilimi liyindlela yokuthintana kungaba kukhuluma, kufunda kanye nokutlola. Ilimi lidosa phambili ekwakheni indlela esenza ngayo izinto ngombana bengeke sakghona ukuthintana nokuzwana ngabe bekungasilo.

== Indlela ezingasetjenziswa ukuthuthukisa isiNdebele ==
Iimi elinye nelinye kufanele bona lithuthukiswe ngendlela ezifaneleko nezisemthethweni. Ukuthuthukisa ilimi lesiNdebele  kuqakathekile ngombana kwenza bona ilimi lekhethu lingatjhabalali. Isikhethu singathuthukiswa ngokobana sikhulunywe njalo mihla namalanga</text>
      <sha1>ex6sk1upke4fsa2a3f25ioy6hfhfxhg</sha1>
    </revision>
    <revision>
      <id>2767</id>
      <parentid>2766</parentid>
      <timestamp>2025-04-25T08:10:30Z</timestamp>
      <contributor>
        <username>Inno06</username>
        <id>594</id>
      </contributor>
      <comment>minr edit</comment>
      <origin>2767</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="942" sha1="9qsa52dvecjdk7tyuuydzrt277yjwxa" xml:space="preserve">'''IsiNdebele''' ngelinye lamalimi wabaNguni asemthethweni eSewula Afrika elisetjenziswa nakukhulunywako, eenkolweni, emisebenzini kanye nezinye iindawo. Ilimi lesiNdebele likhulunywa sitjhaba esibizwa bona maNdebele esitholakala eendaweni ezihlukahlukeneko zangeSewula Afrika. Kunemihlobo emibili eyaziwako yamaNdebele ekhuluma isiNdebele esihlukileko ingasi khulu godu. SinamaNdebele abizwa bona maNala kanye namaNzunza. 

Ilimi liyindlela yokuthintana kungaba kukhuluma, kufunda kanye nokutlola. Ilimi lidosa phambili ekwakheni indlela esenza ngayo izinto ngombana bengeke sakghona ukuthintana nokuzwana ngabe bekungasilo. 
== Indlela ezingasetjenziswa ukuthuthukisa isiNdebele ==
Iimi elinye nelinye kufanele bona lithuthukiswe ngendlela ezifaneleko nezisemthethweni. Ukuthuthukisa ilimi lesiNdebele  kuqakathekile ngombana kwenza bona ilimi lekhethu lingatjhabalali. Isikhethu singathuthukiswa ngokobana sikhulunywe njalo mihla namalanga</text>
      <sha1>9qsa52dvecjdk7tyuuydzrt277yjwxa</sha1>
    </revision>
    <revision>
      <id>2770</id>
      <parentid>2767</parentid>
      <timestamp>2025-04-25T08:21:02Z</timestamp>
      <contributor>
        <username>Inno06</username>
        <id>594</id>
      </contributor>
      <comment>added citation</comment>
      <origin>2770</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1065" sha1="mtsugxxprn6629jkjhdgeq5edc78cgv" xml:space="preserve">'''[[IsiNdebele]]''' ngelinye lamalimi wabaNguni asemthethweni eSewula Afrika elisetjenziswa nakukhulunywako, eenkolweni, emisebenzini kanye nezinye iindawo. Ilimi lesiNdebele likhulunywa sitjhaba esibizwa bona maNdebele esitholakala eendaweni ezihlukahlukeneko zangeSewula Afrika. Kunemihlobo emibili eyaziwako yamaNdebele ekhuluma isiNdebele esihlukileko ingasi khulu godu. SinamaNdebele abizwa bona maNala kanye namaNzunza.&lt;ref&gt;Ndebele Language in South Africa | SouthAfrica.com&lt;/ref&gt; 

Ilimi liyindlela yokuthintana kungaba kukhuluma, kufunda kanye nokutlola. Ilimi lidosa phambili ekwakheni indlela esenza ngayo izinto ngombana bengeke sakghona ukuthintana nokuzwana ngabe bekungasilo. 
== Indlela ezingasetjenziswa ukuthuthukisa isiNdebele ==
Iimi elinye nelinye kufanele bona lithuthukiswe ngendlela ezifaneleko nezisemthethweni. Ukuthuthukisa ilimi lesiNdebele  kuqakathekile ngombana kwenza bona ilimi lekhethu lingatjhabalali. Isikhethu singathuthukiswa ngokobana sikhulunywe njalo mihla namalanga &lt;ref&gt;ISINDEBELE CLA SELF STUDY GUIDE 2018 FINAL.pdf&lt;/ref&gt;</text>
      <sha1>mtsugxxprn6629jkjhdgeq5edc78cgv</sha1>
    </revision>
    <revision>
      <id>2772</id>
      <parentid>2770</parentid>
      <timestamp>2025-04-25T08:23:13Z</timestamp>
      <contributor>
        <username>Inno06</username>
        <id>594</id>
      </contributor>
      <comment>added heading</comment>
      <origin>2772</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1085" sha1="2ffdncqco7f0jm9lm1q6xd31m0bigd2" xml:space="preserve">'''[[IsiNdebele]]''' ngelinye lamalimi wabaNguni asemthethweni eSewula Afrika elisetjenziswa nakukhulunywako, eenkolweni, emisebenzini kanye nezinye iindawo. Ilimi lesiNdebele likhulunywa sitjhaba esibizwa bona maNdebele esitholakala eendaweni ezihlukahlukeneko zangeSewula Afrika. Kunemihlobo emibili eyaziwako yamaNdebele ekhuluma isiNdebele esihlukileko ingasi khulu godu. SinamaNdebele abizwa bona maNala kanye namaNzunza.&lt;ref&gt;Ndebele Language in South Africa | SouthAfrica.com&lt;/ref&gt; 

Ilimi liyindlela yokuthintana kungaba kukhuluma, kufunda kanye nokutlola. Ilimi lidosa phambili ekwakheni indlela esenza ngayo izinto ngombana bengeke sakghona ukuthintana nokuzwana ngabe bekungasilo. 
== Indlela ezingasetjenziswa ukuthuthukisa isiNdebele ==
Iimi elinye nelinye kufanele bona lithuthukiswe ngendlela ezifaneleko nezisemthethweni. Ukuthuthukisa ilimi lesiNdebele  kuqakathekile ngombana kwenza bona ilimi lekhethu lingatjhabalali. Isikhethu singathuthukiswa ngokobana sikhulunywe njalo mihla namalanga &lt;ref&gt;ISINDEBELE CLA SELF STUDY GUIDE 2018 FINAL.pdf&lt;/ref&gt;

== Amareferensi ==</text>
      <sha1>2ffdncqco7f0jm9lm1q6xd31m0bigd2</sha1>
    </revision>
    <revision>
      <id>2773</id>
      <parentid>2772</parentid>
      <timestamp>2025-04-25T08:30:37Z</timestamp>
      <contributor>
        <username>Inno06</username>
        <id>594</id>
      </contributor>
      <comment>Linked a word</comment>
      <origin>2773</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1096" sha1="pb59lqle7vm0up23q92m6x16depp38y" xml:space="preserve">'''[[Isindebele|IsiNdebele]]''' ngelinye lamalimi wabaNguni asemthethweni eSewula Afrika elisetjenziswa nakukhulunywako, eenkolweni, emisebenzini kanye nezinye iindawo. Ilimi lesiNdebele likhulunywa sitjhaba esibizwa bona maNdebele esitholakala eendaweni ezihlukahlukeneko zangeSewula Afrika. Kunemihlobo emibili eyaziwako yamaNdebele ekhuluma isiNdebele esihlukileko ingasi khulu godu. SinamaNdebele abizwa bona maNala kanye namaNzunza.&lt;ref&gt;Ndebele Language in South Africa | SouthAfrica.com&lt;/ref&gt; 

Ilimi liyindlela yokuthintana kungaba kukhuluma, kufunda kanye nokutlola. Ilimi lidosa phambili ekwakheni indlela esenza ngayo izinto ngombana bengeke sakghona ukuthintana nokuzwana ngabe bekungasilo. 
== Indlela ezingasetjenziswa ukuthuthukisa isiNdebele ==
Iimi elinye nelinye kufanele bona lithuthukiswe ngendlela ezifaneleko nezisemthethweni. Ukuthuthukisa ilimi lesiNdebele  kuqakathekile ngombana kwenza bona ilimi lekhethu lingatjhabalali. Isikhethu singathuthukiswa ngokobana sikhulunywe njalo mihla namalanga &lt;ref&gt;ISINDEBELE CLA SELF STUDY GUIDE 2018 FINAL.pdf&lt;/ref&gt;

== Amareferensi ==</text>
      <sha1>pb59lqle7vm0up23q92m6x16depp38y</sha1>
    </revision>
    <revision>
      <id>2775</id>
      <parentid>2773</parentid>
      <timestamp>2025-04-25T08:57:02Z</timestamp>
      <contributor>
        <username>Inno06</username>
        <id>594</id>
      </contributor>
      <comment>added information</comment>
      <origin>2775</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1936" sha1="k6b2vxu8smsran9053ac83s73gvjn7o" xml:space="preserve">'''[[Isindebele|IsiNdebele]]''' ngelinye lamalimi wabaNguni asemthethweni eSewula Afrika elisetjenziswa nakukhulunywako, eenkolweni, emisebenzini kanye nezinye iindawo. Ilimi lesiNdebele likhulunywa sitjhaba esibizwa bona maNdebele esitholakala eendaweni ezihlukahlukeneko zangeSewula Afrika. Kunemihlobo emibili eyaziwako yamaNdebele ekhuluma isiNdebele esihlukileko ingasi khulu godu. SinamaNdebele abizwa bona maNala kanye namaNzunza.&lt;ref&gt;Ndebele Language in South Africa | SouthAfrica.com&lt;/ref&gt; AmaNala kanye namaNzunza akakhulumi ngendlela efanako. AmaNala ayaliliza bese amaNzunza ayandrondroza. Ngokuya ngokomthetho lilodwa ilimi elisetjenziswako ukutlola okulilimi elilinganisiwe kwavumelwana ngelilodwa.  

Ilimi liyindlela yokuthintana kungaba kukhuluma, kufunda kanye nokutlola. Ilimi lidosa phambili ekwakheni indlela esenza ngayo izinto ngombana bengeke sakghona ukuthintana nokuzwana ngabe bekungasilo. 
== Indlela ezingasetjenziswa ukuthuthukisa isiNdebele ==
Iimi elinye nelinye kufanele bona lithuthukiswe ngendlela ezifaneleko nezisemthethweni. Ukuthuthukisa ilimi lesiNdebele  kuqakathekile ngombana kwenza bona ilimi lekhethu lingatjhabalali. Isikhethu singathuthukiswa ngokobana sikhulunywe njalo mihla namalanga bakhulumi baso begodu bazikhakhazise ekusikhulumeni. Angeke kwaba nabantu abanetjisakalo ngokwazi kabanzi ngelimi leli, abantu bakhona banganayo itjisakalo yokulithuthukisa ngombana kufanele kuthome kibo. Ukuze ilimi lesikhethu lifike eendaweni eziphakemeko  kuqakathekile bona lithuthukiswe ngendlela ezihlukahlukeneko ingasi ngokukhuluma kwaphela. Enye indlela engasetjenziswa kukobana kutlolwe phasi ngalo ilimi leli ukuze abanetjisakalo bazokghona ukufunda okutloliweko ngalo. Lapho kuzokuvela amarhubhululo ahlukahlukeneko mayelana nelimi lesiNdebele nangendlela ilimi lihlangana ngakhona nesiko ngombana ziyakhambisana.&lt;ref&gt;ISINDEBELE CLA SELF STUDY GUIDE 2018 FINAL.pdf&lt;/ref&gt;

== Amareferensi ==</text>
      <sha1>k6b2vxu8smsran9053ac83s73gvjn7o</sha1>
    </revision>
    <revision>
      <id>2780</id>
      <parentid>2775</parentid>
      <timestamp>2025-04-25T10:22:11Z</timestamp>
      <contributor>
        <username>Inno06</username>
        <id>594</id>
      </contributor>
      <comment>added a picture</comment>
      <origin>2780</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2046" sha1="d3g2p4y7fjbn3hk5h23uuat32e45v9t" xml:space="preserve">'''[[Isindebele|IsiNdebele]]''' ngelinye lamalimi wabaNguni asemthethweni eSewula Afrika elisetjenziswa nakukhulunywako, eenkolweni, emisebenzini kanye nezinye iindawo. Ilimi lesiNdebele likhulunywa sitjhaba esibizwa bona maNdebele esitholakala eendaweni ezihlukahlukeneko zangeSewula Afrika. Kunemihlobo emibili eyaziwako yamaNdebele ekhuluma isiNdebele esihlukileko ingasi khulu godu. SinamaNdebele abizwa bona maNala kanye namaNzunza.&lt;ref&gt;Ndebele Language in South Africa | SouthAfrica.com&lt;/ref&gt; AmaNala kanye namaNzunza akakhulumi ngendlela efanako. AmaNala ayaliliza bese amaNzunza ayandrondroza. Ngokuya ngokomthetho lilodwa ilimi elisetjenziswako ukutlola okulilimi elilinganisiwe kwavumelwana ngelilodwa.  

Ilimi liyindlela yokuthintana kungaba kukhuluma, kufunda kanye nokutlola. Ilimi lidosa phambili ekwakheni indlela esenza ngayo izinto ngombana bengeke sakghona ukuthintana nokuzwana ngabe bekungasilo. 
[[Isimumathi:Mapoch.- Femmes Ndebele in Cultural Village (2).jpg|thumb|242x242px|Ndebele woman attire]]     

== Indlela ezingasetjenziswa ukuthuthukisa isiNdebele ==
Iimi elinye nelinye kufanele bona lithuthukiswe ngendlela ezifaneleko nezisemthethweni. Ukuthuthukisa ilimi lesiNdebele  kuqakathekile ngombana kwenza bona ilimi lekhethu lingatjhabalali. Isikhethu singathuthukiswa ngokobana sikhulunywe njalo mihla namalanga bakhulumi baso begodu bazikhakhazise ekusikhulumeni. Angeke kwaba nabantu abanetjisakalo ngokwazi kabanzi ngelimi leli, abantu bakhona banganayo itjisakalo yokulithuthukisa ngombana kufanele kuthome kibo. Ukuze ilimi lesikhethu lifike eendaweni eziphakemeko  kuqakathekile bona lithuthukiswe ngendlela ezihlukahlukeneko ingasi ngokukhuluma kwaphela. Enye indlela engasetjenziswa kukobana kutlolwe phasi ngalo ilimi leli ukuze abanetjisakalo bazokghona ukufunda okutloliweko ngalo. Lapho kuzokuvela amarhubhululo ahlukahlukeneko mayelana nelimi lesiNdebele nangendlela ilimi lihlangana ngakhona nesiko ngombana ziyakhambisana.&lt;ref&gt;ISINDEBELE CLA SELF STUDY GUIDE 2018 FINAL.pdf&lt;/ref&gt;

== Amareferensi ==</text>
      <sha1>d3g2p4y7fjbn3hk5h23uuat32e45v9t</sha1>
    </revision>
  </page>
  <page>
    <title>St John's Apostolic Faith Mission</title>
    <ns>0</ns>
    <id>591</id>
    <revision>
      <id>2768</id>
      <timestamp>2025-04-25T08:16:51Z</timestamp>
      <contributor>
        <username>Mojonom</username>
        <id>593</id>
      </contributor>
      <comment>Created page with &quot;I St John's apostolic faith mission lingelinye lamasondo amakhulu atholakala enarheni yeSewula Africa Kanye neenarheni eziyizombelezileko ekufana ne Botswana, lesotho, Namibia kune ne-eSwatini. Indlukulu yesondo leli isendaweni ye Katlehong, eduze ne dorobha le Germiston esifundeni seGauteng. Esikhathini Sanje,isondo leli lirholwa ngu  ladyarchbishop Lindiwe Gladys Maragu kusukela ngomnyaka ka 2005 ngemva kokubhubha kwaka archbishop Maragu obekangu sobentwabakhe. Kulison...&quot;</comment>
      <origin>2768</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="566" sha1="eulb7aax8scu29uzbjpij15ffmq1em3" xml:space="preserve">I St John's apostolic faith mission lingelinye lamasondo amakhulu atholakala enarheni yeSewula Africa Kanye neenarheni eziyizombelezileko ekufana ne Botswana, lesotho, Namibia kune ne-eSwatini. Indlukulu yesondo leli isendaweni ye Katlehong, eduze ne dorobha le Germiston esifundeni seGauteng. Esikhathini Sanje,isondo leli lirholwa ngu  ladyarchbishop Lindiwe Gladys Maragu kusukela ngomnyaka ka 2005 ngemva kokubhubha kwaka archbishop Maragu obekangu sobentwabakhe. Kulisondo elikhule laze lagging sele linamagaja and Lula alikhulu eenarheni ezisesewula yeAfrikha.</text>
      <sha1>eulb7aax8scu29uzbjpij15ffmq1em3</sha1>
    </revision>
    <revision>
      <id>2771</id>
      <parentid>2768</parentid>
      <timestamp>2025-04-25T08:22:25Z</timestamp>
      <contributor>
        <username>Mojonom</username>
        <id>593</id>
      </contributor>
      <origin>2771</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="872" sha1="czhcm81op1qo5nd6b589yvkjkaydpkc" xml:space="preserve">I St John's apostolic faith mission lingelinye lamasondo amakhulu atholakala enarheni yeSewula Africa Kanye neenarheni eziyizombelezileko ekufana ne Botswana, lesotho, Namibia kune ne-eSwatini. Indlukulu yesondo leli isendaweni ye Katlehong, eduze ne dorobha le Germiston esifundeni seGauteng. Esikhathini Sanje,isondo leli lirholwa ngu  ladyarchbishop Lindiwe Gladys Maragu kusukela ngomnyaka ka 2005 ngemva kokubhubha kwaka archbishop Maragu obekangu sobentwabakhe. Kulisondo elikhule laze lagging sele linamagaja and Lula alikhulu eenarheni ezisesewula yeAfrikha.

=== Umlando Wesondo ===


Isondo le St John's Apostolic Faith Mission linomlando osuka kumma obizwa ngoChristina Nku okhabe asonda esondweni le Apostolic Faith Mission. Ekuphumeni kwakhe e Apostolic Faith Mission waphuma ngebanga lokobana ayokuvula lakhe isondo elitjha njengombana ummoya bewumlayela. Ng</text>
      <sha1>czhcm81op1qo5nd6b589yvkjkaydpkc</sha1>
    </revision>
    <revision>
      <id>2774</id>
      <parentid>2771</parentid>
      <timestamp>2025-04-25T08:56:33Z</timestamp>
      <contributor>
        <ip>196.21.175.1</ip>
      </contributor>
      <origin>2774</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2135" sha1="my9di6228xg6cplmx3s1a608v2x7fdc" xml:space="preserve">I St John's apostolic faith mission lingelinye lamasondo amakhulu atholakala enarheni yeSewula Africa Kanye neenarheni eziyizombelezileko ekufana ne Botswana, lesotho, Namibia kune ne-eSwatini. Indlukulu yesondo leli isendaweni ye Katlehong, eduze ne dorobha le Germiston esifundeni seGauteng. Esikhathini Sanje,isondo leli lirholwa ngu  ladyarchbishop GL Maragu kusukela ngomnyaka ka 2005 ngemva kokubhubha kwaka archbishop B Maragu obekangu sobentwabakhe. Kulisondo elikhule laze laqgina sele linamagaja andlula alikhulu eenarheni ezisesewula yeAfrikha.

=== Umlando Wesondo ===


Isondo le St John's Apostolic Faith Mission linomlando osuka kumma obizwa ngoChristina Nku okunguye ongumthomi wekonzo ye St John's Apostolic Faith Mission. u Christinah Nku khabe asonda esondweni le Apostolic Faith Mission. Ekuphumeni kwakhe e Apostolic Faith Mission waphuma ngebanga lokobana ahlutjhwa mumoya, ekwamkatelela bona aphume ayokuvuka lakhe isondo elitjha. ekuphumeni kwakhe, waphuma wayokusebenzisana nabobaba ababili ababizwa ngo Petros Moloi kunye nobaba uRamoipone. bobathathu baya endaweni yase Evaton lapha bebanesebenzo yokusiza abantu nesitjhaba ebaphila kiso ngokubasebenzela ukuze bathole ipilo. ekusebenzeleni abantu kwabo, bebasebenza ngaphasi kwakababa obekanesibongo sakwa Nkitsing. Ekhambeni labo lokuphilisa abantu, omunye wabantu abeza bazokulatjhwa ngu Mama uChristinah Nku ngubaba obizwa ngokuthi ngu Petros John Masango. Ekufikweni kwaka baba uMasango ku mama Christinah Nku kwakhombisa nokho bona kufike umuntu onomoya begodu ngokwekolelo yabo ekungumuntu othandwe nguZimu bona azoba ngomunye ozokusebenzela abantu ngokomoya. UBaba uMasango waqgina angomunye wamalunga wesondo abhajadisiweko begodu kwakhamba khamba kwaze kwafika isikhathi lapha aba ngumfundisi khona. Sele angumfundisi, wayokuthoma lakhe isondo naye endaweni ebeyibuzwa ngokobana yi Dukathole ekungelinye lamalokishi amadala eendaweni ezinqa nge Germiston. Ngeminyaka yabo 1970, kwaba sikhathi lapha ubujamo besondo kuba budisi khona, ekwaqgina sekurholela bona uBaba UMasango aphethe ngokobana ayokuzijamela ngaphandle kokuba ngaphasi kwesondo leli</text>
      <sha1>my9di6228xg6cplmx3s1a608v2x7fdc</sha1>
    </revision>
    <revision>
      <id>2776</id>
      <parentid>2774</parentid>
      <timestamp>2025-04-25T09:57:00Z</timestamp>
      <contributor>
        <username>Mojonom</username>
        <id>593</id>
      </contributor>
      <origin>2776</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2215" sha1="rznlfprmoxvt0rcdshfwj1epyo40vgq" xml:space="preserve">I St John's apostolic faith mission lingelinye lamasondo amakhulu atholakala enarheni yeSewula Africa Kanye neenarheni eziyizombelezileko ekufana ne Botswana, lesotho, Namibia kune ne-eSwatini. Indlukulu yesondo leli isendaweni ye Katlehong, eduze ne dorobha le Germiston esifundeni seGauteng. Esikhathini Sanje,isondo leli lirholwa ngu  ladyarchbishop GL Maragu kusukela ngomnyaka ka 2005 ngemva kokubhubha kwaka archbishop B Maragu obekangu sobentwabakhe. Kulisondo elikhule laze laqgina sele linamagaja andlula alikhulu eenarheni ezisesewula yeAfrikha.

=== Umlando Wesondo ===



Isondo le St John's Apostolic Faith Mission linomlando osuka kumma obizwa ngoChristina Nku okunguye ongumthomi wekonzo ye St John's Apostolic Faith Mission. u Christinah Nku khabe asonda esondweni le Apostolic Faith Mission. Ekuphumeni kwakhe e Apostolic Faith Mission waphuma ngebanga lokobana ahlutjhwa mumoya, ekwamkatelela bona aphume ayokuvuka lakhe isondo elitjha. ekuphumeni kwakhe, waphuma wayokusebenzisana nabobaba ababili ababizwa ngo Petros Moloi kunye nobaba uRamoipone. bobathathu baya endaweni yase Evaton lapha bebanesebenzo yokusiza abantu nesitjhaba ebaphila kiso ngokubasebenzela ukuze bathole ipilo. ekusebenzeleni abantu kwabo, bebasebenza ngaphasi kwakababa obekanesibongo sakwa Nkitsing. Ekhambeni labo lokuphilisa abantu, omunye wabantu abeza bazokulatjhwa ngu Mama uChristinah Nku ngubaba obizwa ngokuthi ngu Petros John Masango. Ekufikweni kwaka baba uMasango ku mama Christinah Nku kwakhombisa nokho bona kufike umuntu onomoya begodu ngokwekolelo yabo ekungumuntu othandwe nguZimu bona azoba ngomunye ozokusebenzela abantu ngokomoya. UBaba uMasango waqgina angomunye wamalunga wesondo abhajadisiweko begodu kwakhamba khamba kwaze kwafika isikhathi lapha aba ngumfundisi khona. Sele angumfundisi, wayokuthoma lakhe isondo naye endaweni ebeyibuzwa ngokobana yi Dukathole ekungelinye lamalokishi amadala eendaweni ezinqa nge Germiston. Ngeminyaka yabo 1970, kwaba sikhathi lapha ubujamo besondo kuba budisi khona, ekwaqgina sekurholela bona uBaba UMasango aphethe ngokobana ayokuzijamela ngaphandle kokuba ngaphasi kwesondo leli.

== Imithombo Yelwazi ==
[https://journals.co.za/doi/epdf/10.7833/117-1-1386]</text>
      <sha1>rznlfprmoxvt0rcdshfwj1epyo40vgq</sha1>
    </revision>
    <revision>
      <id>2777</id>
      <parentid>2776</parentid>
      <timestamp>2025-04-25T10:01:32Z</timestamp>
      <contributor>
        <username>Mojonom</username>
        <id>593</id>
      </contributor>
      <origin>2777</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2223" sha1="gavrkhvxws96vyporhk09z1mouxhmny" xml:space="preserve">I St John's apostolic faith mission lingelinye lamasondo amakhulu atholakala enarheni yeSewula Africa Kanye neenarheni eziyizombelezileko ekufana ne Botswana, lesotho, Namibia kune ne-eSwatini. Indlukulu yesondo leli isendaweni ye Katlehong, eduze ne dorobha le Germiston esifundeni seGauteng. Esikhathini Sanje,isondo leli lirholwa ngu  ladyarchbishop GL Maragu kusukela ngomnyaka ka 2005 ngemva kokubhubha kwaka archbishop B Maragu obekangu sobentwabakhe. Kulisondo elikhule laze laqgina sele linamagaja andlula alikhulu eenarheni ezisesewula yeAfrikha.

=== Umlando Wesondo ===



Isondo le St John's Apostolic Faith Mission linomlando osuka kumma obizwa ngoChristina Nku okunguye ongumthomi wekonzo ye St John's Apostolic Faith Mission. u Christinah Nku khabe asonda esondweni le Apostolic Faith Mission. Ekuphumeni kwakhe e Apostolic Faith Mission waphuma ngebanga lokobana ahlutjhwa mumoya, ekwamkatelela bona aphume ayokuvuka lakhe isondo elitjha. ekuphumeni kwakhe, waphuma wayokusebenzisana nabobaba ababili ababizwa ngo Petros Moloi kunye nobaba uRamoipone. bobathathu baya endaweni yase Evaton lapha bebanesebenzo yokusiza abantu nesitjhaba ebaphila kiso ngokubasebenzela ukuze bathole ipilo. ekusebenzeleni abantu kwabo, bebasebenza ngaphasi kwakababa obekanesibongo sakwa Nkitsing. Ekhambeni labo lokuphilisa abantu, omunye wabantu abeza bazokulatjhwa ngu Mama uChristinah Nku ngubaba obizwa ngokuthi ngu Petros John Masango. Ekufikweni kwaka baba uMasango ku mama Christinah Nku kwakhombisa nokho bona kufike umuntu onomoya begodu ngokwekolelo yabo ekungumuntu othandwe nguZimu bona azoba ngomunye ozokusebenzela abantu ngokomoya. UBaba uMasango waqgina angomunye wamalunga wesondo abhajadisiweko begodu kwakhamba khamba kwaze kwafika isikhathi lapha aba ngumfundisi khona. Sele angumfundisi, wayokuthoma lakhe isondo naye endaweni ebeyibuzwa ngokobana yi Dukathole ekungelinye lamalokishi amadala eendaweni ezinqa nge Germiston. Ngeminyaka yabo 1970, kwaba sikhathi lapha ubujamo besondo kuba budisi khona, ekwaqgina sekurholela bona uBaba UMasango aphethe ngokobana ayokuzijamela ngaphandle kokuba ngaphasi kwesondo leli.&lt;ref&gt;https://journals.co.za/doi/epdf/10.7833/117-1-1386&lt;/ref&gt;

== Imithombo Yelwazi ==</text>
      <sha1>gavrkhvxws96vyporhk09z1mouxhmny</sha1>
    </revision>
    <revision>
      <id>2778</id>
      <parentid>2777</parentid>
      <timestamp>2025-04-25T10:06:27Z</timestamp>
      <contributor>
        <username>Mojonom</username>
        <id>593</id>
      </contributor>
      <minor />
      <origin>2778</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2359" sha1="6p8tuv5goda65enfnbzxg7q45q5094n" xml:space="preserve">I St John's apostolic faith mission lingelinye lamasondo amakhulu atholakala enarheni yeSewula Africa Kanye neenarheni eziyizombelezileko ekufana ne Botswana, lesotho, Namibia kune ne-eSwatini. Indlukulu yesondo leli isendaweni ye Katlehong, eduze ne dorobha le Germiston esifundeni seGauteng. Esikhathini Sanje,isondo leli lirholwa ngu  ladyarchbishop GL Maragu kusukela ngomnyaka ka 2005 ngemva kokubhubha kwaka archbishop B Maragu obekangu sobentwabakhe. Kulisondo elikhule laze laqgina sele linamagaja andlula alikhulu eenarheni ezisesewula yeAfrikha.

=== Umlando Wesondo ===



Isondo le St John's Apostolic Faith Mission linomlando osuka kumma obizwa ngoChristina Nku okunguye ongumthomi wekonzo ye St John's Apostolic Faith Mission.&lt;ref&gt;A remarkable woman in African Independent Churches: Examining Christina Nku's leadership in St John's Apostolic Faith Mission&lt;/ref&gt; u Christinah Nku khabe asonda esondweni le Apostolic Faith Mission. Ekuphumeni kwakhe e Apostolic Faith Mission waphuma ngebanga lokobana ahlutjhwa mumoya, ekwamkatelela bona aphume ayokuvuka lakhe isondo elitjha. ekuphumeni kwakhe, waphuma wayokusebenzisana nabobaba ababili ababizwa ngo Petros Moloi kunye nobaba uRamoipone. bobathathu baya endaweni yase Evaton lapha bebanesebenzo yokusiza abantu nesitjhaba ebaphila kiso ngokubasebenzela ukuze bathole ipilo.&lt;ref&gt;https://journals.co.za/doi/epdf/10.7833/117-1-1386&lt;/ref&gt; ekusebenzeleni abantu kwabo, bebasebenza ngaphasi kwakababa obekanesibongo sakwa Nkitsing. Ekhambeni labo lokuphilisa abantu, omunye wabantu abeza bazokulatjhwa ngu Mama uChristinah Nku ngubaba obizwa ngokuthi ngu Petros John Masango. Ekufikweni kwaka baba uMasango ku mama Christinah Nku kwakhombisa nokho bona kufike umuntu onomoya begodu ngokwekolelo yabo ekungumuntu othandwe nguZimu bona azoba ngomunye ozokusebenzela abantu ngokomoya. UBaba uMasango waqgina angomunye wamalunga wesondo abhajadisiweko begodu kwakhamba khamba kwaze kwafika isikhathi lapha aba ngumfundisi khona. Sele angumfundisi, wayokuthoma lakhe isondo naye endaweni ebeyibuzwa ngokobana yi Dukathole ekungelinye lamalokishi amadala eendaweni ezinqa nge Germiston. Ngeminyaka yabo 1970, kwaba sikhathi lapha ubujamo besondo kuba budisi khona, ekwaqgina sekurholela bona uBaba UMasango aphethe ngokobana ayokuzijamela ngaphandle kokuba ngaphasi kwesondo leli.

== Imithombo Yelwazi ==</text>
      <sha1>6p8tuv5goda65enfnbzxg7q45q5094n</sha1>
    </revision>
    <revision>
      <id>2779</id>
      <parentid>2778</parentid>
      <timestamp>2025-04-25T10:13:31Z</timestamp>
      <contributor>
        <username>Mojonom</username>
        <id>593</id>
      </contributor>
      <minor />
      <origin>2779</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2664" sha1="khqjsal3aw1hf2jqp15tu29h2flb0pu" xml:space="preserve">I St John's apostolic faith mission lingelinye lamasondo amakhulu atholakala enarheni yeSewula Africa Kanye neenarheni eziyizombelezileko ekufana ne Botswana, lesotho, Namibia kune ne-eSwatini. Indlukulu yesondo leli isendaweni ye Katlehong, eduze ne dorobha le Germiston esifundeni seGauteng. Esikhathini Sanje,isondo leli lirholwa ngu  ladyarchbishop GL Maragu kusukela ngomnyaka ka 2005 ngemva kokubhubha kwaka archbishop B Maragu obekangu sobentwabakhe. Kulisondo elikhule laze laqgina sele linamagaja andlula alikhulu eenarheni ezisesewula yeAfrikha.

== Umlando Wesondo ==
Isondo le St John's Apostolic Faith Mission linomlando osuka kumma obizwa ngoChristina Nku okunguye ongumthomi wekonzo ye St John's Apostolic Faith Mission.&lt;ref&gt;A remarkable woman in African Independent Churches: Examining Christina Nku's leadership in St John's Apostolic Faith Mission&lt;/ref&gt; u Christinah Nku khabe asonda esondweni le Apostolic Faith Mission. Ekuphumeni kwakhe e Apostolic Faith Mission waphuma ngebanga lokobana ahlutjhwa mumoya, ekwamkatelela bona aphume ayokuvuka lakhe isondo elitjha. ekuphumeni kwakhe, waphuma wayokusebenzisana nabobaba ababili ababizwa ngo Petros Moloi kunye nobaba uRamoipone. bobathathu baya endaweni yase Evaton lapha bebanesebenzo yokusiza abantu nesitjhaba ebaphila kiso ngokubasebenzela ukuze bathole ipilo.&lt;ref&gt;https://journals.co.za/doi/epdf/10.7833/117-1-1386&lt;/ref&gt; ekusebenzeleni abantu kwabo, bebasebenza ngaphasi kwakababa obekanesibongo sakwa Nkitsing. Ekhambeni labo lokuphilisa abantu, omunye wabantu abeza bazokulatjhwa ngu Mama uChristinah Nku ngubaba obizwa ngokuthi ngu Petros John Masango. Ekufikweni kwaka baba uMasango ku mama Christinah Nku kwakhombisa nokho bona kufike umuntu onomoya begodu ngokwekolelo yabo ekungumuntu othandwe nguZimu bona azoba ngomunye ozokusebenzela abantu ngokomoya. UBaba uMasango waqgina angomunye wamalunga wesondo abhajadisiweko begodu kwakhamba khamba kwaze kwafika isikhathi lapha aba ngumfundisi khona. Sele angumfundisi, wayokuthoma lakhe isondo naye endaweni ebeyibuzwa ngokobana yi Dukathole ekungelinye lamalokishi amadala eendaweni ezinqa nge Germiston. Ngeminyaka yabo 1970, kwaba sikhathi lapha ubujamo besondo kuba budisi khona, ekwaqgina sekurholela bona uBaba UMasango aphethe ngokobana ayokuzijamela ngaphandle kokuba ngaphasi kwesondo leli. Ubaba uMasango ngebanga le Grou Areas Act ebeyikhona ngesikhatheso, kwafanele basuke eDukathole bafudukele endaweni yase Katlehong Zuma Section la isondo lakhe lisese khona. Ubaba Ukhambe ephasini ngomnyaka ka 1984 sele asebenze kangangokuthi aqgine avule amasondo amakhulu asenanini elingu 38. Ibandla lakhe 

== Imithombo Yelwazi ==</text>
      <sha1>khqjsal3aw1hf2jqp15tu29h2flb0pu</sha1>
    </revision>
    <revision>
      <id>2781</id>
      <parentid>2779</parentid>
      <timestamp>2025-04-25T10:33:31Z</timestamp>
      <contributor>
        <username>Mojonom</username>
        <id>593</id>
      </contributor>
      <minor />
      <origin>2781</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2877" sha1="2rxyxujssq9xauqk0u2wozwjv4pzh8r" xml:space="preserve">I St John's apostolic faith mission lingelinye lamasondo amakhulu atholakala enarheni yeSewula Africa Kanye neenarheni eziyizombelezileko ekufana ne Botswana, lesotho, Namibia kune ne-eSwatini. Indlukulu yesondo leli isendaweni ye Katlehong, eduze ne dorobha le Germiston esifundeni seGauteng. Esikhathini Sanje,isondo leli lirholwa ngu  ladyarchbishop GL Maragu kusukela ngomnyaka ka 2005 ngemva kokubhubha kwaka archbishop B Maragu obekangu sobentwabakhe. Kulisondo elikhule laze laqgina sele linamagaja andlula alikhulu eenarheni ezisesewula yeAfrikha.

[[Isimumathi:Warsaw 2023 112 Jesus Holy Cross Sculpture.jpg|center|thumb|Ujesu uphethe isiphambano]]

== Umlando Wesondo ==
Isondo le St John's Apostolic Faith Mission linomlando osuka kumma obizwa ngoChristina Nku okunguye ongumthomi wekonzo ye St John's Apostolic Faith Mission.&lt;ref&gt;A remarkable woman in African Independent Churches: Examining Christina Nku's leadership in St John's Apostolic Faith Mission&lt;/ref&gt; u Christinah Nku khabe asonda esondweni le Apostolic Faith Mission. Ekuphumeni kwakhe e Apostolic Faith Mission waphuma ngebanga lokobana ahlutjhwa mumoya, ekwamkatelela bona aphume ayokuvuka lakhe isondo elitjha. ekuphumeni kwakhe, waphuma wayokusebenzisana nabobaba ababili ababizwa ngo Petros Moloi kunye nobaba uRamoipone. bobathathu baya endaweni yase Evaton lapha bebanesebenzo yokusiza abantu nesitjhaba ebaphila kiso ngokubasebenzela ukuze bathole ipilo.&lt;ref&gt;https://journals.co.za/doi/epdf/10.7833/117-1-1386&lt;/ref&gt; ekusebenzeleni abantu kwabo, bebasebenza ngaphasi kwakababa obekanesibongo sakwa Nkitsing. Ekhambeni labo lokuphilisa abantu, omunye wabantu abeza bazokulatjhwa ngu Mama uChristinah Nku ngubaba obizwa ngokuthi ngu Petros John Masango. Ekufikweni kwaka baba uMasango ku mama Christinah Nku kwakhombisa nokho bona kufike umuntu onomoya begodu ngokwekolelo yabo ekungumuntu othandwe nguZimu bona azoba ngomunye ozokusebenzela abantu ngokomoya. UBaba uMasango waqgina angomunye wamalunga wesondo abhajadisiweko begodu kwakhamba khamba kwaze kwafika isikhathi lapha aba ngumfundisi khona. Sele angumfundisi, wayokuthoma lakhe isondo naye endaweni ebeyibuzwa ngokobana yi Dukathole ekungelinye lamalokishi amadala eendaweni ezinqa nge Germiston. Ngeminyaka yabo 1970, kwaba sikhathi lapha ubujamo besondo kuba budisi khona, ekwaqgina sekurholela bona uBaba UMasango aphethe ngokobana ayokuzijamela ngaphandle kokuba ngaphasi kwesondo leli. Ubaba uMasango ngebanga le Grou Areas Act ebeyikhona ngesikhatheso, kwafanele basuke eDukathole bafudukele endaweni yase Katlehong Zuma Section la isondo lakhe lisese khona. Ubaba Ukhambe ephasini ngomnyaka ka 1984 sele asebenze kangangokuthi aqgine avule amasondo amakhulu asenanini elingu 38. Ngemva kokukhamba kwakababa uMasango, isondo liqgine lifumene umphathi omutjha ekungu baba u  Archbishop Maragu oqgine anyuk 

== Imithombo Yelwazi ==</text>
      <sha1>2rxyxujssq9xauqk0u2wozwjv4pzh8r</sha1>
    </revision>
    <revision>
      <id>2940</id>
      <parentid>2781</parentid>
      <timestamp>2025-06-06T17:18:49Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>sj</comment>
      <origin>2940</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="528" sha1="b08uqhuaxozc151o736d44la9xw5s47" xml:space="preserve">== Hot Dog ==
&lt;references /&gt;A '''hot dog''' is a kind of food that’s like a sandwich. It has a '''long bun''' (like a soft piece of bread) and inside it is a '''sausage''' (like a yummy meat stick). You can eat it plain, or you can put things on it like '''ketchup''', '''mustard''', or even '''cheese'''.

People eat hot dogs at parties, baseball games, or picnics. And guess what? Even though it's called a &quot;hot dog,&quot; it's not actually a dog! 😄 It's just a silly name.

Would you like yours with ketchup or plain? 🍽️</text>
      <sha1>b08uqhuaxozc151o736d44la9xw5s47</sha1>
    </revision>
    <revision>
      <id>2942</id>
      <parentid>2940</parentid>
      <timestamp>2025-06-06T17:19:27Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>i invoke the fifth</comment>
      <origin>2942</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="617" sha1="axku495sg4wl8q6jx25pvbzf4yqlen2" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.''' 

== Hot Dog ==
&lt;references /&gt;A '''hot dog''' is a kind of food that’s like a sandwich. It has a '''long bun''' (like a soft piece of bread) and inside it is a '''sausage''' (like a yummy meat stick). You can eat it plain, or you can put things on it like '''ketchup''', '''mustard''', or even '''cheese'''.

People eat hot dogs at parties, baseball games, or picnics. And guess what? Even though it's called a &quot;hot dog,&quot; it's not actually a dog! 😄 It's just a silly name.

Would you like yours with ketchup or plain? 🍽️</text>
      <sha1>axku495sg4wl8q6jx25pvbzf4yqlen2</sha1>
    </revision>
    <revision>
      <id>3130</id>
      <parentid>2942</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edits by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Mojonom|Mojonom]]</comment>
      <origin>2781</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2877" sha1="2rxyxujssq9xauqk0u2wozwjv4pzh8r" xml:space="preserve">I St John's apostolic faith mission lingelinye lamasondo amakhulu atholakala enarheni yeSewula Africa Kanye neenarheni eziyizombelezileko ekufana ne Botswana, lesotho, Namibia kune ne-eSwatini. Indlukulu yesondo leli isendaweni ye Katlehong, eduze ne dorobha le Germiston esifundeni seGauteng. Esikhathini Sanje,isondo leli lirholwa ngu  ladyarchbishop GL Maragu kusukela ngomnyaka ka 2005 ngemva kokubhubha kwaka archbishop B Maragu obekangu sobentwabakhe. Kulisondo elikhule laze laqgina sele linamagaja andlula alikhulu eenarheni ezisesewula yeAfrikha.

[[Isimumathi:Warsaw 2023 112 Jesus Holy Cross Sculpture.jpg|center|thumb|Ujesu uphethe isiphambano]]

== Umlando Wesondo ==
Isondo le St John's Apostolic Faith Mission linomlando osuka kumma obizwa ngoChristina Nku okunguye ongumthomi wekonzo ye St John's Apostolic Faith Mission.&lt;ref&gt;A remarkable woman in African Independent Churches: Examining Christina Nku's leadership in St John's Apostolic Faith Mission&lt;/ref&gt; u Christinah Nku khabe asonda esondweni le Apostolic Faith Mission. Ekuphumeni kwakhe e Apostolic Faith Mission waphuma ngebanga lokobana ahlutjhwa mumoya, ekwamkatelela bona aphume ayokuvuka lakhe isondo elitjha. ekuphumeni kwakhe, waphuma wayokusebenzisana nabobaba ababili ababizwa ngo Petros Moloi kunye nobaba uRamoipone. bobathathu baya endaweni yase Evaton lapha bebanesebenzo yokusiza abantu nesitjhaba ebaphila kiso ngokubasebenzela ukuze bathole ipilo.&lt;ref&gt;https://journals.co.za/doi/epdf/10.7833/117-1-1386&lt;/ref&gt; ekusebenzeleni abantu kwabo, bebasebenza ngaphasi kwakababa obekanesibongo sakwa Nkitsing. Ekhambeni labo lokuphilisa abantu, omunye wabantu abeza bazokulatjhwa ngu Mama uChristinah Nku ngubaba obizwa ngokuthi ngu Petros John Masango. Ekufikweni kwaka baba uMasango ku mama Christinah Nku kwakhombisa nokho bona kufike umuntu onomoya begodu ngokwekolelo yabo ekungumuntu othandwe nguZimu bona azoba ngomunye ozokusebenzela abantu ngokomoya. UBaba uMasango waqgina angomunye wamalunga wesondo abhajadisiweko begodu kwakhamba khamba kwaze kwafika isikhathi lapha aba ngumfundisi khona. Sele angumfundisi, wayokuthoma lakhe isondo naye endaweni ebeyibuzwa ngokobana yi Dukathole ekungelinye lamalokishi amadala eendaweni ezinqa nge Germiston. Ngeminyaka yabo 1970, kwaba sikhathi lapha ubujamo besondo kuba budisi khona, ekwaqgina sekurholela bona uBaba UMasango aphethe ngokobana ayokuzijamela ngaphandle kokuba ngaphasi kwesondo leli. Ubaba uMasango ngebanga le Grou Areas Act ebeyikhona ngesikhatheso, kwafanele basuke eDukathole bafudukele endaweni yase Katlehong Zuma Section la isondo lakhe lisese khona. Ubaba Ukhambe ephasini ngomnyaka ka 1984 sele asebenze kangangokuthi aqgine avule amasondo amakhulu asenanini elingu 38. Ngemva kokukhamba kwakababa uMasango, isondo liqgine lifumene umphathi omutjha ekungu baba u  Archbishop Maragu oqgine anyuk 

== Imithombo Yelwazi ==</text>
      <sha1>2rxyxujssq9xauqk0u2wozwjv4pzh8r</sha1>
    </revision>
  </page>
  <page>
    <title>Ukusetjenziswa kwamalimi wendabuko eenkundleni zokuthintana</title>
    <ns>0</ns>
    <id>592</id>
    <revision>
      <id>2769</id>
      <timestamp>2025-04-25T08:16:54Z</timestamp>
      <contributor>
        <username>Masombukaunathi</username>
        <id>595</id>
      </contributor>
      <comment>Created a article</comment>
      <origin>2769</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="902" sha1="39u1sc0q81fpjnr11ty4w0cuvj5qpk0" xml:space="preserve">'''Kuqakathekile''' bona woke amalimi wendabuko athuthukiswe begodu asetjenziswe eenkundleni zokuthintana, njengaku WhatsAPP, Facebook, Tiktok nakezinye iinkundla zokuthintana. Lokhu kuzokwenza bona ilutjha nabantwana abasakhulako bangalahli amalimi wabo. kuqakathekile bona nakutlolwa ngamalimi wendabuko kusetjenziswa imithetho yokutlola nokupeleda ngombana lokho kuzokwenza bona ilimi lihleleke begodu lihlonipheke. Abasebenzisi bamalimi wendabuko kuqakathekile bona basebenzise amalimi lokha nabatlola imibono, babelana ngemilandu ethizi, batlola iinkondlo namkha batlola amahlaya.

== Iinkudla zokuthinthana ==
Ukuhlangana namkha ukuhlanganyela kwama-Influencers bathuthukise amalimi ngokuthi benze amavidiyo bafundise amalimi. Iinhlangano ezithuthukisa amalimi kufanele zikhuthaze abantu bona basebenzise amalimi wabo ngokutlomelisa labo abathuthukisa amalimi khulu khulu eekundleni zokuthintana.</text>
      <sha1>39u1sc0q81fpjnr11ty4w0cuvj5qpk0</sha1>
    </revision>
  </page>
  <page>
    <title>Ukuqakatheka kokufunda</title>
    <ns>0</ns>
    <id>593</id>
    <revision>
      <id>2782</id>
      <timestamp>2025-04-25T10:38:16Z</timestamp>
      <contributor>
        <username>Inno06</username>
        <id>594</id>
      </contributor>
      <comment>bolded first letter</comment>
      <origin>2782</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="81" sha1="bjlx5sw1xfjlkckunzw3v0sfzzc09a6" xml:space="preserve">'''Ifundo''' iqakathekile kiwo woke umuntu ngombana isilodlhelo seminyango enengi</text>
      <sha1>bjlx5sw1xfjlkckunzw3v0sfzzc09a6</sha1>
    </revision>
    <revision>
      <id>2783</id>
      <parentid>2782</parentid>
      <timestamp>2025-04-25T10:42:46Z</timestamp>
      <contributor>
        <username>Inno06</username>
        <id>594</id>
      </contributor>
      <comment>added heading</comment>
      <origin>2783</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="340" sha1="9utqmla70k0dwvcy225muv8ju91jb99" xml:space="preserve">'''[[Ifundo]]''' iqakathekile kiwo woke umuntu ngombana isilodlhelo seminyango enengi ekhona emhlabenapha. Ukuze uzokwazi okhunye kufanele ube nolwazi ngokuthileko bewufunde ngakho ukuze uzokuzwisisa ncono. Ukufunda kwenza umuntu ahlakaniphe ngombana usuke athwele ilwazi elinengi mayelana nalokho asuke akufunda. 

== Iindlela zokufunda ==</text>
      <sha1>9utqmla70k0dwvcy225muv8ju91jb99</sha1>
    </revision>
    <revision>
      <id>2784</id>
      <parentid>2783</parentid>
      <timestamp>2025-04-25T11:11:02Z</timestamp>
      <contributor>
        <username>Inno06</username>
        <id>594</id>
      </contributor>
      <comment>added citation</comment>
      <origin>2784</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="696" sha1="598x5ys4s2ciw9qa3r49fx7zo67jn4f" xml:space="preserve">'''[[Ifundo]]''' iqakathekile kiwo woke umuntu ngombana isilodlhelo seminyango enengi ekhona emhlabenapha. Ukuze uzokwazi okhunye kufanele ube nolwazi ngokuthileko bewufunde ngakho ukuze uzokuzwisisa ncono. Ukufunda kwenza umuntu ahlakaniphe ngombana usuke athwele ilwazi elinengi mayelana nalokho asuke akufunda. Ukufunda kwenza umuntu bona ahlakaniphe ngokudluleleko begodu azwisise ncono.&lt;ref&gt;Why Is Learning Important? (20 Reasons)&lt;/ref&gt; 

== Iindlela zokufunda ==
Zinengi iindlela ezisetjenziswako ukufumana ilwazi nanyana ukufunda ngokuthileko. Omunye nomunye umuntu ufunda ngendlela afuna ukufunda ngayo okungaba kufumana ilwazi ngemitjhiningqcondo, ngokufunda iincwadi, ngokuya esikolweni</text>
      <sha1>598x5ys4s2ciw9qa3r49fx7zo67jn4f</sha1>
    </revision>
    <revision>
      <id>2785</id>
      <parentid>2784</parentid>
      <timestamp>2025-04-25T11:13:43Z</timestamp>
      <contributor>
        <username>Inno06</username>
        <id>594</id>
      </contributor>
      <comment>added a reference</comment>
      <origin>2785</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="716" sha1="m4bgev7l9nrfnfi5uutbziqy8sefxge" xml:space="preserve">'''[[Ifundo]]''' iqakathekile kiwo woke umuntu ngombana isilodlhelo seminyango enengi ekhona emhlabenapha. Ukuze uzokwazi okhunye kufanele ube nolwazi ngokuthileko bewufunde ngakho ukuze uzokuzwisisa ncono. Ukufunda kwenza umuntu ahlakaniphe ngombana usuke athwele ilwazi elinengi mayelana nalokho asuke akufunda. Ukufunda kwenza umuntu bona ahlakaniphe ngokudluleleko begodu azwisise ncono.&lt;ref&gt;Why Is Learning Important? (20 Reasons)&lt;/ref&gt; 

== Iindlela zokufunda ==
Zinengi iindlela ezisetjenziswako ukufumana ilwazi nanyana ukufunda ngokuthileko. Omunye nomunye umuntu ufunda ngendlela afuna ukufunda ngayo okungaba kufumana ilwazi ngemitjhiningqcondo, ngokufunda iincwadi, ngokuya esikolweni

== Amareferensi ==</text>
      <sha1>m4bgev7l9nrfnfi5uutbziqy8sefxge</sha1>
    </revision>
    <revision>
      <id>2786</id>
      <parentid>2785</parentid>
      <timestamp>2025-04-25T11:15:48Z</timestamp>
      <contributor>
        <username>Inno06</username>
        <id>594</id>
      </contributor>
      <comment>added a picture</comment>
      <origin>2786</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="799" sha1="nyvkog5n7cj6aebe5qcbkk1kykyyj5v" xml:space="preserve">'''[[Ifundo]]''' iqakathekile kiwo woke umuntu ngombana isilodlhelo seminyango enengi ekhona emhlabenapha. Ukuze uzokwazi okhunye kufanele ube nolwazi ngokuthileko bewufunde ngakho ukuze uzokuzwisisa ncono. Ukufunda kwenza umuntu ahlakaniphe ngombana usuke athwele ilwazi elinengi mayelana nalokho asuke akufunda. Ukufunda kwenza umuntu bona ahlakaniphe ngokudluleleko begodu azwisise ncono.&lt;ref&gt;Why Is Learning Important? (20 Reasons)&lt;/ref&gt;

[[Isimumathi:Four Types of Learning Styles.jpg|thumb|Iindlela ezine 4 zokufunda]] 

== Iindlela zokufunda ==
Zinengi iindlela ezisetjenziswako ukufumana ilwazi nanyana ukufunda ngokuthileko. Omunye nomunye umuntu ufunda ngendlela afuna ukufunda ngayo okungaba kufumana ilwazi ngemitjhiningqcondo, ngokufunda iincwadi, ngokuya esikolweni

== Amareferensi ==</text>
      <sha1>nyvkog5n7cj6aebe5qcbkk1kykyyj5v</sha1>
    </revision>
    <revision>
      <id>2991</id>
      <parentid>2786</parentid>
      <timestamp>2025-06-06T20:14:37Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>k7ujytgrf</comment>
      <origin>2991</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="880" sha1="maib6057i9lb85grfi47ff2jxqbxv8d" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. [[Ifundo]]''' iqakathekile kiwo woke umuntu ngombana isilodlhelo seminyango enengi ekhona emhlabenapha. Ukuze uzokwazi okhunye kufanele ube nolwazi ngokuthileko bewufunde ngakho ukuze uzokuzwisisa ncono. Ukufunda kwenza umuntu ahlakaniphe ngombana usuke athwele ilwazi elinengi mayelana nalokho asuke akufunda. Ukufunda kwenza umuntu bona ahlakaniphe ngokudluleleko begodu azwisise ncono.&lt;ref&gt;Why Is Learning Important? (20 Reasons)&lt;/ref&gt;

[[Isimumathi:Four Types of Learning Styles.jpg|thumb|Iindlela ezine 4 zokufunda]] 

== Iindlela zokufunda ==
Zinengi iindlela ezisetjenziswako ukufumana ilwazi nanyana ukufunda ngokuthileko. Omunye nomunye umuntu ufunda ngendlela afuna ukufunda ngayo okungaba kufumana ilwazi ngemitjhiningqcondo, ngokufunda iincwadi, ngokuya esikolweni

== Amareferensi ==</text>
      <sha1>maib6057i9lb85grfi47ff2jxqbxv8d</sha1>
    </revision>
    <revision>
      <id>3068</id>
      <parentid>2991</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Inno06|Inno06]]</comment>
      <origin>2786</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="799" sha1="nyvkog5n7cj6aebe5qcbkk1kykyyj5v" xml:space="preserve">'''[[Ifundo]]''' iqakathekile kiwo woke umuntu ngombana isilodlhelo seminyango enengi ekhona emhlabenapha. Ukuze uzokwazi okhunye kufanele ube nolwazi ngokuthileko bewufunde ngakho ukuze uzokuzwisisa ncono. Ukufunda kwenza umuntu ahlakaniphe ngombana usuke athwele ilwazi elinengi mayelana nalokho asuke akufunda. Ukufunda kwenza umuntu bona ahlakaniphe ngokudluleleko begodu azwisise ncono.&lt;ref&gt;Why Is Learning Important? (20 Reasons)&lt;/ref&gt;

[[Isimumathi:Four Types of Learning Styles.jpg|thumb|Iindlela ezine 4 zokufunda]] 

== Iindlela zokufunda ==
Zinengi iindlela ezisetjenziswako ukufumana ilwazi nanyana ukufunda ngokuthileko. Omunye nomunye umuntu ufunda ngendlela afuna ukufunda ngayo okungaba kufumana ilwazi ngemitjhiningqcondo, ngokufunda iincwadi, ngokuya esikolweni

== Amareferensi ==</text>
      <sha1>nyvkog5n7cj6aebe5qcbkk1kykyyj5v</sha1>
    </revision>
  </page>
  <page>
    <title>Umrhayili</title>
    <ns>0</ns>
    <id>595</id>
    <revision>
      <id>2812</id>
      <timestamp>2025-05-13T20:10:44Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>inyanga ka MRHAYILI</comment>
      <origin>2812</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3378" sha1="czyv6vdzmjpbmraa5bokoru9j5wltp0" xml:space="preserve">UMRHAYILI yinyanga yesihlanu ku https://en.wikipedia.org/wiki/Julian_calendar ne https://en.wikipedia.org/wiki/Gregorian_calendar.Inyanga ka Mrhayili inamalanga amatjhumi amathathu nanye.eSewula Afrika kilenyanga kuthoma umoya omakhaza orhayila nofana obulala yoke into emilileko namkha ebeyihlaza ehlobo.Inyanga kaMrhayili ise sizinini ye kwindla nalapho kuthoma khona isikhathi sobusika.Ibizo lenyanga lihlathulula bonyana kusikhathi sokobana izinto ezinengi ezifana neentjalo ziyarhayileka nofana ziyafa.


Africa month commemoration logo

Inyanga ye Afrika igidingwa qobe mnyaka ngoMrhayili,ukukhumbula ukusungulwa kwe https://en.wikipedia.org/wiki/Organisation_of_African_Unity#:~:text=The%20OAU%20was%20founded%20in,May%201963%20in%20Addis%20Ababa I edishini yetjhumi yenyanga ye Afrika igidingwa ngaphasi kewsiqubulo esithi:&quot;SIGIDINGA IMINYAKA EMATJHUMI AMATHATHU NANYE YE TJHAPHULUKO&quot;,sakha iAfrika encono nephasi elincono. eSewula Afrika inyanga kaMrhayili qobe mnyaka itshwaywa njenge nyanga yeAfrika begodu ithungelene nokhu sekela nokuqinisa ilanga le Afrika.Ngomnyaka ka 2024 i https://en.wikipedia.org/wiki/African_Union yahloma ilanga leAfika ngokurhabisa ukutlanywa kwe https://en.wikipedia.org/wiki/African_Continental_Free_Trade_Area.Ibuye isekele amahlelo asekela i International Decade Of Indigenous Languages njengo kutjho kwe UNESCO ukutjengisa ukuqakatheka kokuthuthukisa ukusetjenziswa kwamalimi wendabuko we Afrika.


Professor Samba Buri Mboup
Iyunivesithi ye Mpumalanga https://www.ump.ac.za/ igidinga ilanga le Afrika solo kwango 2015.U vice chancellor we univesithi ye Mpumalanga uProfessor Thoko Mayekiso wathi iziko lezefundo ligidinga beliyazikhakhazisa ngoutjhidelana nenarhakazi yeAfrika.

&quot; ngokwehloso yethu sirhuluphela ukuba yi univesithi ye Afrika ekhamba phambili ekuletheni amathuba wokuthuthuka ngokusungula nokhu sungula.sikholwa bonyana kusinikela ithuba elihle ukuthuthukisa umqopho wethu ngamalanga.sisungule isiko lokugidinga iAfrika day solo kwango 2015.sibe netjhudu lokumema aboqwephetjhe bazositlhadlhula ngenarhakazi ye Afrika.


I Zanex Foundation African languages literarcy project eyaziwa bonyana yi Ulwazi Lwethu ihlanganisa iinhlangano ezine zeengweli esikhaleni semitlolo yabantwana begodu isebenzisa ubucwephetjhe babo ukukhiqiza izinga eliphezulu lelimi le Afrika lokuzigedla kunye nabafundi abalinganisiweko besigaba sesisekelo.

I Zanex Foundation ithome begodu yasekela ngeemali i Ulwazi lwethu African language reading materials project ngomqopho wokuthuthukisa ukufunda kweencwadi zamalimi we Afrika nokusekela abotitjhere ngensetjenziswa zokufundisa ukufunda kwabentwana abasemazingeni aphasi wefundo ukufunda ngelimi lekhaya.

IINKOMBA.

1.https://ienabler.ump.ac.za/pls/prodi41/w99pkg.mi_login

2.https://www.dsac.gov.za/

3.https://www.zenexfoundation.org.za/

4.https://www.googleadservices.com/pagead/aclk?sa=L&amp;ai=DChcSEwjFqoiInqGNAxWOmFAGHfFjAIUYABABGgJkZw&amp;co=1&amp;gclid=EAIaIQobChMIxaqIiJ6hjQMVjphQBh3xYwCFEAAYASAAEgL_XvD_BwE&amp;ohost=&amp;cid=CAASAuRo&amp;category=acrcp_v1_0&amp;sig=AOD64_3drcTFHUq-fKd8NUbc2q4_SQeLNQ&amp;adurl=https://expatexplore.com/blog/interesting-facts-south-africa/%3Futm_source%3Dgoogle%26utm_medium%3Dcpc%26utm_campaign%3D%7Bcampaignname%7D%26utm_term%3D%26utm_content%3D%26gad_source%3D5%26gad_campaignid%3D22453287344&amp;q=&amp;nb=1&amp;rurl=https%3A%2F%2Fsyndicatedsearch.goog%2F&amp;nm=5&amp;nx=50&amp;ny=7&amp;is=530x806</text>
      <sha1>czyv6vdzmjpbmraa5bokoru9j5wltp0</sha1>
    </revision>
    <revision>
      <id>2829</id>
      <parentid>2812</parentid>
      <timestamp>2025-05-20T18:24:09Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>i changed the images.</comment>
      <origin>2829</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3484" sha1="ahqpbvah42xrgylnvxgq6iewut0kb4y" xml:space="preserve">'''Umrhayili''' yinyanga yesihlanu ku https://en.wikipedia.org/wiki/Julian_calendar ne https://en.wikipedia.org/wiki/Gregorian_calendar.Inyanga ka Mrhayili inamalanga amatjhumi amathathu nanye.eSewula Afrika kilenyanga kuthoma umoya omakhaza orhayila nofana obulala yoke into emilileko namkha ebeyihlaza ehlobo.Inyanga kaMrhayili ise sizinini ye kwindla nalapho kuthoma khona isikhathi sobusika.Ibizo lenyanga lihlathulula bonyana kusikhathi sokobana izinto ezinengi ezifana neentjalo ziyarhayileka nofana ziyafa.                                    
[[Isimumathi:Africa Month Logo web(1).jpg|thumb|Africa Month Logo]]



Inyanga ye Afrika igidingwa qobe mnyaka ngoMrhayili,ukukhumbula ukusungulwa kwe https://en.wikipedia.org/wiki/Organisation_of_African_Unity#:~:text=The%20OAU%20was%20founded%20in,May%201963%20in%20Addis%20Ababa I edishini yetjhumi yenyanga ye Afrika igidingwa ngaphasi kewsiqubulo esithi:&quot;SIGIDINGA IMINYAKA EMATJHUMI AMATHATHU NANYE YE TJHAPHULUKO&quot;,sakha iAfrika encono nephasi elincono. eSewula Afrika inyanga kaMrhayili qobe mnyaka itshwaywa njenge nyanga yeAfrika begodu ithungelene nokhu sekela nokuqinisa ilanga le Afrika.Ngomnyaka ka 2024 i https://en.wikipedia.org/wiki/African_Union yahloma ilanga leAfika ngokurhabisa ukutlanywa kwe https://en.wikipedia.org/wiki/African_Continental_Free_Trade_Area.Ibuye isekele amahlelo asekela i International Decade Of Indigenous Languages njengo kutjho kwe UNESCO ukutjengisa ukuqakatheka kokuthuthukisa ukusetjenziswa kwamalimi wendabuko we Afrika.



Iyunivesithi ye Mpumalanga https://www.ump.ac.za/ igidinga ilanga le Afrika solo kwango 2015.U vice chancellor we univesithi ye Mpumalanga uProfessor Thoko Mayekiso wathi iziko lezefundo ligidinga beliyazikhakhazisa ngoutjhidelana nenarhakazi yeAfrika.

&quot; ngokwehloso yethu sirhuluphela ukuba yi univesithi ye Afrika ekhamba phambili ekuletheni amathuba wokuthuthuka ngokusungula nokhu sungula.sikholwa bonyana kusinikela ithuba elihle ukuthuthukisa umqopho wethu ngamalanga.sisungule isiko lokugidinga iAfrika day solo kwango 2015.sibe netjhudu lokumema aboqwephetjhe bazositlhadlhula ngenarhakazi ye Afrika.
[[Isimumathi:Stratimage.jpg|thumb|Zanex foundation.]]


I Zanex Foundation African languages literarcy project eyaziwa bonyana yi Ulwazi Lwethu ihlanganisa iinhlangano ezine zeengweli esikhaleni semitlolo yabantwana begodu isebenzisa ubucwephetjhe babo ukukhiqiza izinga eliphezulu lelimi le Afrika lokuzigedla kunye nabafundi abalinganisiweko besigaba sesisekelo.

I Zanex Foundation ithome begodu yasekela ngeemali i Ulwazi lwethu African language reading materials project ngomqopho wokuthuthukisa ukufunda kweencwadi zamalimi we Afrika nokusekela abotitjhere ngensetjenziswa zokufundisa ukufunda kwabentwana abasemazingeni aphasi wefundo ukufunda ngelimi lekhaya.

IINKOMBA.

1.https://ienabler.ump.ac.za/pls/prodi41/w99pkg.mi_login

2.https://www.dsac.gov.za/

3.https://www.zenexfoundation.org.za/

4.https://www.googleadservices.com/pagead/aclk?sa=L&amp;ai=DChcSEwjFqoiInqGNAxWOmFAGHfFjAIUYABABGgJkZw&amp;co=1&amp;gclid=EAIaIQobChMIxaqIiJ6hjQMVjphQBh3xYwCFEAAYASAAEgL_XvD_BwE&amp;ohost=&amp;cid=CAASAuRo&amp;category=acrcp_v1_0&amp;sig=AOD64_3drcTFHUq-fKd8NUbc2q4_SQeLNQ&amp;adurl=https://expatexplore.com/blog/interesting-facts-south-africa/%3Futm_source%3Dgoogle%26utm_medium%3Dcpc%26utm_campaign%3D%7Bcampaignname%7D%26utm_term%3D%26utm_content%3D%26gad_source%3D5%26gad_campaignid%3D22453287344&amp;q=&amp;nb=1&amp;rurl=https%3A%2F%2Fsyndicatedsearch.goog%2F&amp;nm=5&amp;nx=50&amp;ny=7&amp;is=530x806</text>
      <sha1>ahqpbvah42xrgylnvxgq6iewut0kb4y</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Waqala Junior</title>
    <ns>2</ns>
    <id>599</id>
    <revision>
      <id>2819</id>
      <timestamp>2025-05-16T20:49:12Z</timestamp>
      <contributor>
        <username>Waqala Junior</username>
        <id>638</id>
      </contributor>
      <comment>Who is Waqala Junior, Who is Usman Saidu,The Biography Of Usman Saidu/Waqala Junior</comment>
      <origin>2819</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1530" sha1="cnco18p2t3l74svcgbv0b7crpg8byc6" xml:space="preserve">'''Usman Saidu (Waqala Junior)'''

Usman Saidu better known as waqala junior, mononomially usman, is a businessman and professional footballer plays as forward for Nigerian club &quot;Hongbang United&quot; join 7th January 2020

Father: Saidu Muhammad Salatu 

Mother: Maryam Hassan 

Siblings :-

Brothers 

• Muhammad Buhari Saidu 

• Abdullahi Saidu

• Yahaya Saidu

• Umar Saidu

Sisters :-

• Rukaiya Saidu

• Halimatu Saidu 

• Fatuma Saidu 

• Hadiza Saidu

Nationality: Nigeria 

Place Of Birth: Hong, Adamawa State 

Date Of Birth: 15th March 2006

Current Club: Hongbang United 

Salary: _____

Worth: _____

Height: 1.8m

Foot: Left 

Tribe: Kilba (Höba)

Family: Waqala Family 

[https://www.facebook.com/WaqalaJunior Facebook Profile]

[https://youtube.com/@waqala_junior YouTube]

[https://www.tiktok.com/@waqala_junior TikTok]

[https://www.instagram.com/waqala_junior Instagram]

[https://www.facebook.com/100001836110284/posts/pfbid028WmJ3B6ygifmLy6LDGgdHb44x66XhMbptZqaSH7XE3unb8KrHAsjdpRXNa6optbzl/?app=fbl Photos]

[https://www.facebook.com/100001836110284/posts/pfbid07AnkBh84GF3nD8f4JpwvmgXgiQD9NgfRuKXzH2JkvLjWv1Bf8hmWosJvEW8YTQ4Gl/?app=fbl Photos]

[https://www.facebook.com/100001836110284/posts/pfbid02AkWJowjEbHx5ZVkvd9JpfdE2yoKu48i53wJCeQmTHGGEHu2vCWUziBE4HSiG1pZJl/?app=fbl His picture]

[https://www.facebook.com/100001836110284/posts/pfbid0oKhHvpV5akxbBmfweEzzbcF81mCKQW6JEkXDETQudciBDHz7wMuDV9xh3xXLFHw8l/?app=fbl Photos]

[https://www.facebook.com/reel/1370593341028807/?app=fbl His mother]</text>
      <sha1>cnco18p2t3l74svcgbv0b7crpg8byc6</sha1>
    </revision>
  </page>
  <page>
    <title>Ukubulunga amalimi akhulunywako eSewula Afrika</title>
    <ns>0</ns>
    <id>600</id>
    <revision>
      <id>2821</id>
      <timestamp>2025-05-19T09:33:46Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''ISewula''' Afrika kuyinarha enamalimi esemthethweni akhulunywako. Amalimi la nakapheleleko kumalimi amatjhumi amabili nasifaka nelimi lamatshwayo&lt;ref&gt;Hlengwa-Selepe, B.B., 2020. ''A critical analysis of South Africa’s contemporary language policies with specific reference to the Use of Official Languages Act No. 12 of 2012 for government purposes'' (Doctoral dissertation, University of the Witwatersrand, Johannesburg (South Africa)).&lt;/ref&gt;&lt;ref&gt;Butler, A., 2017. ''Co...&quot;</comment>
      <origin>2821</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8440" sha1="pxnbuunbe464fwtto34y0raiiruzy5m" xml:space="preserve">'''ISewula''' Afrika kuyinarha enamalimi esemthethweni akhulunywako. Amalimi la nakapheleleko kumalimi amatjhumi amabili nasifaka nelimi lamatshwayo&lt;ref&gt;Hlengwa-Selepe, B.B., 2020. ''A critical analysis of South Africa’s contemporary language policies with specific reference to the Use of Official Languages Act No. 12 of 2012 for government purposes'' (Doctoral dissertation, University of the Witwatersrand, Johannesburg (South Africa)).&lt;/ref&gt;&lt;ref&gt;Butler, A., 2017. ''Contemporary South Africa''. Bloomsbury Publishing.&lt;/ref&gt;. Ilimi kuyinto eqakathekileko ngombana lilekelela umuntu bonyana akghone ukuveza imicabango nemibono yakhe ngendlela epheleleko nenqophileko. Kuqakathekile bona amalimi woke weSewula Afrika abulungwe ukuze akghone ukuthi angatjhabalali.

== Ukuqakatheka kokubulunga amalimi ==

=== Ukuveza imicabango ===
Umuntu lokha nakacabanga into, ukuze akghone ukuveza bona ucabangani kufuze bona asebenzise ilimi ukuthi akghone ukudlulisa bona ucabangani ngendlela ezokuzwiwa babantu boke abamlaleleko&lt;ref&gt;van der Veer, R. and Zavershneva, E., 2018. The final chapter of Vygotsky's Thinking and Speech: A reader's guide. ''Journal of the History of the Behavioral Sciences'', ''54''(2), pp.101-116.&lt;/ref&gt;. Umuntu lokha nakadlulisa imicabango yakhe ngelimi ekungasilo lakhe angagcina sele akhuluma into angafuni ukuyikhuluma kodwana akhulume into efana naleyo afuna ukuyitjho, ngombana lokha umuntu nakakhuluma ilimi elingasilo lakhe kulula bonyana aphelelwe lilwazi lamagama afuna ukuwasenzisa bese asebenzise lawo aseduze nalelo ebakafuna ukulisebenzisa. Yeke ngokubulunga amalimi nango kuwagadangisa kweze dijithali kuzokwenza bona kube lula bonyana abantu bakghone ukuveza [[imicabango]] yabo nokuthi bakghone ukuveza imibona yabo. 

=== Ukulingana ===
Lokha amalimi weSewula Afrika nawabulungwe woke ngokwedijithali azokhona ukuthi agcine alingana kungabi nokuthi elinye ilimi liqakatheke khulu ukudlula elinye, ngombana kunelimi elingaziwako bonyana nawufuna ilwazi ngalo uzolitholaphi. Amalimi nawabulungwe woke kuzokuba nokulingana ekuzokuvela ngokuthi woke umuntu afunde esikolweni ngelimi likanina akhuliswe ngalo begodu nalikhulumako. Lokhu kuzokuba nomphumela omuhle khulu emfundweni zabafundi, ngombana nje enarheni yeSewula Afrika abafundi abakghona ukufunda ngelimi labo eenkolweni zamaziko aphakemeko bafundi abakhuluma [[ilimi]] lesiNgisi nelesiBhuru. Nakungenzeka bona amalimi alingane ngokuthuthuka, kuzokwenza bona nabantu abakhuluma amalimi ahlukileko enarheni le bamukelane, kungaba nokuthi umuntu ukhuluma into engekho nofana ukhuluma ilimi elingaziwako.

=== Ifundo ===
Umnyango wezefundo uhlele bewaphasisa umthetho wokuthi kufanele abafundi be greyidi-4 bafunde ngamalimi wabo isifundo seembalo Kanye nesesayensi yemvelo&lt;ref&gt;Veriava, F., 2024. The Basic Education Laws Amendment Bill: A case study in transformative constitutionalism beyond the courts. ''African Human Rights Law Journal'', ''24''(1), pp.153-178.&lt;/ref&gt;. Ukubulungwa kwalimi kuzokwenza bona umsebenzi lo ubeyipumelelo, ngombana kuzokwenza bona kugcine sele kufundwa ngamalimi asemthethweni ama-12 weSewula afrika efundweni yamazika aphakemeko.Kuzokuba netjhuguluko efundweni yeSewula afrika.Woke amalimi we Sewula Afrika nakabulungwe ngokulingana kuzoku kghonakala bonyana woke umfundi enarheni le afunde [[isikolo]] ngelimi lakhe ukusukela e greyidini-R bekuyokufika e greyidinI ye-12 kurage godu kuyokufika efundweni yamazika aphakemeko.Ihlelo elifakwe eenkolweni le-MTBEE elifakwe eeenkolweni lizokuba yipumelelo ngombana elikho ilimi elizokubandlululwa&lt;ref&gt;Khetoa, S., Aiseng, K., Theledi, K. and Motinyane, M., 2024. The centralization and racialization of language policy: implications for the ‘below'. ''Frontiers in Communication'', ''9'', p.1472674.&lt;/ref&gt;.

=== Ubunjalo babantu ===
Woke amalimi wabantu akhulunywa eSewula Afrika kufuze abulungwe ngombana ngokwenza njalo kuzokuba nokuthuthuka kwesitjhaba nokuthi abantu abakhuluma lelo limi bakghone ukuthi bobonakale nokuthi bamukelwe enarheni yeSewula Afrika, nanyana baye kwezinye inarha bazokukghona ukubonakala ukuthi bakhuluma amanye wamalimi akhulunywa eSewula Afrika. Ilimi lenza bona umuntu azazi ukuthi ukuthi ungubani ngombana usebenzisa lona ukuzethula ahlathulule imvelaphi yakhe, begodu akghone nokuthi enze amasiko wakhe asebenzisa ilimi lakhe&lt;ref&gt;Parajuli, B., 2021. Role of language in shaping cultural identity. ''Marsyangdi journal'', pp.112-118.&lt;/ref&gt;&lt;ref&gt;Doke, C.M., 2017. ''The Southern Bantu Languages: Handbook of African Languages''. Routledge.&lt;/ref&gt;. Lokhu kungombana umuntu ngelimi akakhulumi kwaphela kodwana ukghona nokuthi enze nomvumo ngelimi.

=== Ilwazi lomthetho nokupeledwa kwamalimi ===
Lokha nakubulungwa amalimi abantu bakghona nokuthi bathole ukuthola ilwazi lokuthi bafunde ukuthi ilimi likhunywa njani nokuthi lipeledwa bunjani. Iokho kuthuthukisa izinga lokuthi woke amalimi akhulunywa eSewula Afrika angatjhugululwa enziwe amalimi angaziwako begodu kusiza nokuthi umthetho wokusetjenziswa kwelimi ulandelwe kungathokali ilimi IsiNdebele sele sikhulunywa ngokuvangwa nelimi lesiSwati ngombana lokho kungenza bonyana ilimi limotjhakale. Abantu bazokukghona ukufunda izinto ezifana nokuthi kokhunye akukhonakali bonyana utjhugulule umutjho wesiNgisi ngendlela enqophileko uwuse elimini lesiNdebele. Ilwazi lomthetho welimi lizokwenza bona abantu balahle namagama welimi labo wemvelo bese basenzise wokubolekwa elimini lesiNgisi nofana kwamanye amalimi. Isibonelo igama ejamale uburotho ngesiNdebele mgadango kodwana sele kusetjenziswa leli loburotho ekungilo lokubolekwa elimini lesiBhuru.

=== Ukusebenzisa ilimi elinothileko ===
Lokha nawukhuluma ngokusebenzisa izaga nezitjho zelimi lemvelo lazo zikghona ukuthi zivele ngendlela enothisa ilimi nofana enembako. Nakungenzeka bonyana izaga nofana izitjho zelimi elithileko zisetjenziswe sele zitjhugululwe kwelimi zigcina sele zilahlekelwe ngilokho ezikumumetheko ngokobuhlaniphi nofana ngokwefundiso. Amalimi nakabulungiweko imvelo yelimi ngekhe itheleleke Begodu abantu bazokukghona ukusebenzisa ilimi ngokulandela imithetho yalo nangendela enembako.

=== Umsebenzi wokutjhugulula ===
Ukutlola ngelimi elingasilo lakho lemvelo utlole ngokutjhugulula ilimi, kumsebenzi omkhulu engqcondweni ngombana ingqondo kufanele isebenze khulu ukwenza umsebenzi loyo&lt;ref&gt;wa Thiong'o, N., 2009. Translated by the author: My life in between languages. ''Translation Studies'', ''2''(1), pp.17-20.&lt;/ref&gt;. Ngesikhathi umuntu atjhugulula asebenzisa nobukghwari, ugcina sele alahlekelwa magama wemvelo afanele awasebenzise bese athathe lawo akungasiwo adlulisa umlayezo ngendlela enamandla. Lokha nawutjhugula inoveli nofana umdlalo ilimi lemvelo ekutlolwe ngalo lingagcina sele lingenelela kileli otjhugululela kilo ngaphandle kokuthi uhlele ukuthi lingenelele. Nalibulungiweko ilimi lizokuthuthuka bese abantu bazokukhona ukuthi bathole iinsetjenziswa ezikhghona ukutjhugulula msinya ilimi. Lokho kuzokwehlisa umsebenzi omkhulu owenzeka engqcondweni lokha nawutjhugululako.

=== Ukuzithemba ===
Lokha ilimi nalibulungiweko lenza bona abantu abalikhulumako bagcine sele baba nokuzithemba ngombana bazabe bakhuluma ilimi elaziwako nelilingana namanye amalimi wenarheni. Isibonelo nangabe umuntu akhuluma IsiNdebele endaweni yamaPedi angekhe agcine abenevalo lokuthi bazomnyaza nofana bangamamukeli ngombana naye lakhe ilimi kuzobe kulilimi elaziwako enarheni yeSewula Afrika begodu nakwezinye iiinarha zephasini.

=== Ukuthutha ===
Ukubulunga amalimi kuzokwenza bona amalimi woke azeke endaweni zoke zenarha YeSewula Afrika. Lokho kuzokwenza ukuthi nanoma umuntu athutha endaweni yekhabo ayokwakha endaweni lapho bakhuluma elinye ilimi elingafani nelakhe, angalahlekelwa kuzithemba bese agcine atjhugulula ilimi lakhe athathe labantu labo esele aphila nabo ngaleso skhathi.

=== Ukwanela kweensetjenziswa zefundo ===
Lokha amalimi nakabulungeke woke, kuzokuba lula bona woke amalimi abe neensetjenziswa zokufunda ezifana neencwadi zabantwana zokufunda nokhunye okungenza bona ifundo yabantwana ibe lula. Abantu abanye abanzima sele bathanda bona abantwana babo ngombana bobona ngathi isiNgisi lilimi eliphambili.

== Isiphetho ==
Ilimi kuyinto eyenza abantu bona bakghone ukuthi ukuveza imicabango yabo, begodu baphendule lokho abakuzwako ngokwendlela yabo. Amalimi akhona eSewula Afrika kufanele abulungwe woke ukuze akghone ukuthi alingane, begodu kungabi nomehluko lokha abantu abakhuluma.</text>
      <sha1>pxnbuunbe464fwtto34y0raiiruzy5m</sha1>
    </revision>
    <revision>
      <id>2822</id>
      <parentid>2821</parentid>
      <timestamp>2025-05-19T09:40:50Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>2822</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8563" sha1="aheuhfgag0hiq6os366mx320ni5430k" xml:space="preserve">'''ISewula''' Afrika kuyinarha enamalimi esemthethweni akhulunywako. Amalimi la nakapheleleko kumalimi amatjhumi amabili nasifaka nelimi lamatshwayo&lt;ref&gt;Hlengwa-Selepe, B.B., 2020. ''A critical analysis of South Africa’s contemporary language policies with specific reference to the Use of Official Languages Act No. 12 of 2012 for government purposes'' (Doctoral dissertation, University of the Witwatersrand, Johannesburg (South Africa)).&lt;/ref&gt;&lt;ref&gt;Butler, A., 2017. ''Contemporary South Africa''. Bloomsbury Publishing.&lt;/ref&gt;. Ilimi kuyinto eqakathekileko ngombana lilekelela umuntu bonyana akghone ukuveza imicabango nemibono yakhe ngendlela epheleleko nenqophileko. Kuqakathekile bona amalimi woke weSewula Afrika abulungwe ukuze akghone ukuthi angatjhabalali.

== Ukuqakatheka kokubulunga amalimi ==

=== Ukuveza imicabango ===
Umuntu lokha nakacabanga into, ukuze akghone ukuveza bona ucabangani kufuze bona asebenzise ilimi ukuthi akghone ukudlulisa bona ucabangani ngendlela ezokuzwiwa babantu boke abamlaleleko&lt;ref&gt;van der Veer, R. and Zavershneva, E., 2018. The final chapter of Vygotsky's Thinking and Speech: A reader's guide. ''Journal of the History of the Behavioral Sciences'', ''54''(2), pp.101-116.&lt;/ref&gt;. Umuntu lokha nakadlulisa imicabango yakhe ngelimi ekungasilo lakhe angagcina sele akhuluma into angafuni ukuyikhuluma kodwana akhulume into efana naleyo afuna ukuyitjho, ngombana lokha umuntu nakakhuluma ilimi elingasilo lakhe kulula bonyana aphelelwe lilwazi lamagama afuna ukuwasenzisa bese asebenzise lawo aseduze nalelo ebakafuna ukulisebenzisa. Yeke ngokubulunga amalimi nango kuwagadangisa kweze dijithali kuzokwenza bona kube lula bonyana abantu bakghone ukuveza [[imicabango]] yabo nokuthi bakghone ukuveza imibona yabo. 

=== Ukulingana ===
Lokha amalimi weSewula Afrika nawabulungwe woke ngokwedijithali azokhona ukuthi agcine alingana kungabi nokuthi elinye ilimi liqakatheke khulu ukudlula elinye, ngombana kunelimi elingaziwako bonyana nawufuna ilwazi ngalo uzolitholaphi. Amalimi nawabulungwe woke kuzokuba nokulingana ekuzokuvela ngokuthi woke umuntu afunde esikolweni ngelimi likanina akhuliswe ngalo begodu nalikhulumako. Lokhu kuzokuba nomphumela omuhle khulu emfundweni zabafundi, ngombana nje enarheni yeSewula Afrika abafundi abakghona ukufunda ngelimi labo eenkolweni zamaziko aphakemeko bafundi abakhuluma [[ilimi]] lesiNgisi nelesiBhuru. Nakungenzeka bona amalimi alingane ngokuthuthuka, kuzokwenza bona nabantu abakhuluma amalimi ahlukileko enarheni le bamukelane, kungaba nokuthi umuntu ukhuluma into engekho nofana ukhuluma ilimi elingaziwako.

=== Ifundo ===
Umnyango wezefundo uhlele bewaphasisa umthetho wokuthi kufanele abafundi be greyidi-4 bafunde ngamalimi wabo isifundo seembalo Kanye nesesayensi yemvelo&lt;ref&gt;Veriava, F., 2024. The Basic Education Laws Amendment Bill: A case study in transformative constitutionalism beyond the courts. ''African Human Rights Law Journal'', ''24''(1), pp.153-178.&lt;/ref&gt;. Ukubulungwa kwalimi kuzokwenza bona umsebenzi lo ubeyipumelelo, ngombana kuzokwenza bona kugcine sele kufundwa ngamalimi asemthethweni ama-12 weSewula afrika efundweni yamazika aphakemeko.Kuzokuba netjhuguluko efundweni yeSewula afrika.Woke amalimi we Sewula Afrika nakabulungwe ngokulingana kuzoku kghonakala bonyana woke umfundi enarheni le afunde [[isikolo]] ngelimi lakhe ukusukela e greyidini-R bekuyokufika e greyidinI ye-12 kurage godu kuyokufika efundweni yamazika aphakemeko.Ihlelo elifakwe eenkolweni le-MTBEE elifakwe eeenkolweni lizokuba yipumelelo ngombana elikho ilimi elizokubandlululwa&lt;ref&gt;Khetoa, S., Aiseng, K., Theledi, K. and Motinyane, M., 2024. The centralization and racialization of language policy: implications for the ‘below'. ''Frontiers in Communication'', ''9'', p.1472674.&lt;/ref&gt;.

=== Ubunjalo babantu ===
Woke amalimi wabantu akhulunywa eSewula Afrika kufuze abulungwe ngombana ngokwenza njalo kuzokuba nokuthuthuka kwesitjhaba nokuthi abantu abakhuluma lelo limi bakghone ukuthi bobonakale nokuthi bamukelwe enarheni yeSewula Afrika, nanyana baye kwezinye inarha bazokukghona ukubonakala ukuthi bakhuluma amanye wamalimi akhulunywa eSewula Afrika. Ilimi lenza bona umuntu azazi ukuthi ukuthi ungubani ngombana usebenzisa lona ukuzethula ahlathulule imvelaphi yakhe, begodu akghone nokuthi enze amasiko wakhe asebenzisa ilimi lakhe&lt;ref&gt;Parajuli, B., 2021. Role of language in shaping cultural identity. ''Marsyangdi journal'', pp.112-118.&lt;/ref&gt;&lt;ref&gt;Doke, C.M., 2017. ''The Southern Bantu Languages: Handbook of African Languages''. Routledge.&lt;/ref&gt;. Lokhu kungombana umuntu ngelimi akakhulumi kwaphela kodwana ukghona nokuthi enze nomvumo ngelimi.

=== Ilwazi lomthetho nokupeledwa kwamalimi ===
Lokha nakubulungwa amalimi abantu bakghona nokuthi bathole ukuthola ilwazi lokuthi bafunde ukuthi ilimi likhunywa njani nokuthi lipeledwa bunjani. Iokho kuthuthukisa izinga lokuthi woke amalimi akhulunywa eSewula Afrika angatjhugululwa enziwe amalimi angaziwako begodu kusiza nokuthi umthetho wokusetjenziswa kwelimi ulandelwe kungathokali ilimi IsiNdebele sele sikhulunywa ngokuvangwa nelimi lesiSwati ngombana lokho kungenza bonyana ilimi limotjhakale. Abantu bazokukghona ukufunda izinto ezifana nokuthi kokhunye akukhonakali bonyana utjhugulule umutjho wesiNgisi ngendlela enqophileko uwuse elimini lesiNdebele. Ilwazi lomthetho welimi lizokwenza bona abantu balahle namagama welimi labo wemvelo bese basenzise wokubolekwa elimini lesiNgisi nofana kwamanye amalimi. Isibonelo igama ejamale uburotho ngesiNdebele mgadango kodwana sele kusetjenziswa leli loburotho ekungilo lokubolekwa elimini lesiBhuru.

=== Ukusebenzisa ilimi elinothileko ===
Lokha nawukhuluma ngokusebenzisa izaga nezitjho zelimi lemvelo lazo zikghona ukuthi zivele ngendlela enothisa ilimi nofana enembako. Nakungenzeka bonyana izaga nofana izitjho zelimi elithileko zisetjenziswe sele zitjhugululwe kwelimi zigcina sele zilahlekelwe ngilokho ezikumumetheko ngokobuhlaniphi nofana ngokwefundiso. Amalimi nakabulungiweko imvelo yelimi ngekhe itheleleke Begodu abantu bazokukghona ukusebenzisa ilimi ngokulandela imithetho yalo nangendela enembako.

=== Umsebenzi wokutjhugulula ===
Ukutlola ngelimi elingasilo lakho lemvelo utlole ngokutjhugulula ilimi, kumsebenzi omkhulu engqcondweni ngombana ingqondo kufanele isebenze khulu ukwenza umsebenzi loyo&lt;ref&gt;wa Thiong'o, N., 2009. Translated by the author: My life in between languages. ''Translation Studies'', ''2''(1), pp.17-20.&lt;/ref&gt;. Ngesikhathi umuntu atjhugulula asebenzisa nobukghwari, ugcina sele alahlekelwa magama wemvelo afanele awasebenzise bese athathe lawo akungasiwo adlulisa umlayezo ngendlela enamandla. Lokha nawutjhugula inoveli nofana umdlalo ilimi lemvelo ekutlolwe ngalo lingagcina sele lingenelela kileli otjhugululela kilo ngaphandle kokuthi uhlele ukuthi lingenelele. Nalibulungiweko ilimi lizokuthuthuka bese abantu bazokukhona ukuthi bathole iinsetjenziswa ezikhghona ukutjhugulula msinya ilimi. Lokho kuzokwehlisa umsebenzi omkhulu owenzeka engqcondweni lokha nawutjhugululako.

=== Ukuzithemba ===
Lokha ilimi nalibulungiweko lenza bona abantu abalikhulumako bagcine sele baba nokuzithemba ngombana bazabe bakhuluma ilimi elaziwako nelilingana namanye amalimi wenarheni. Isibonelo nangabe umuntu akhuluma IsiNdebele endaweni yamaPedi angekhe agcine abenevalo lokuthi bazomnyaza nofana bangamamukeli ngombana naye lakhe ilimi kuzobe kulilimi elaziwako enarheni yeSewula Afrika begodu nakwezinye iiinarha zephasini.

=== Ukuthutha ===
Ukubulunga amalimi kuzokwenza bona amalimi woke azeke endaweni zoke zenarha YeSewula Afrika. Lokho kuzokwenza ukuthi nanoma umuntu athutha endaweni yekhabo ayokwakha endaweni lapho bakhuluma elinye ilimi elingafani nelakhe, angalahlekelwa kuzithemba bese agcine atjhugulula ilimi lakhe athathe labantu labo esele aphila nabo ngaleso skhathi.

=== Ukwanela kweensetjenziswa zefundo ===
Lokha amalimi nakabulungeke woke, kuzokuba lula bona woke amalimi abe neensetjenziswa zokufunda ezifana neencwadi zabantwana zokufunda nokhunye okungenza bona ifundo yabantwana ibe lula. Abantu abanye abanzima sele bathanda bona abantwana babo bafunde ngelimi lesiNgisi ngombana bobona ngathi isiNgisi lilimi eliphambili ngesibanga sokuthi lineensetjenziswa ezinengi zokufunda begodu kulilimi elikhulunywa iphasi loke.

== Isiphetho ==
Ilimi kuyinto eyenza abantu bona bakghone ukuthi ukuveza imicabango yabo, begodu baphendule lokho abakuzwako ngokwendlela yabo. Amalimi akhona eSewula Afrika kufanele abulungwe woke ukuze akghone ukuthi alingane, begodu kungabi nomehluko lokha abantu abakhuluma.</text>
      <sha1>aheuhfgag0hiq6os366mx320ni5430k</sha1>
    </revision>
    <revision>
      <id>3428</id>
      <parentid>2822</parentid>
      <timestamp>2025-07-12T14:28:16Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3428</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8580" sha1="8lg99jqhdw7va9r82x1akix3i380b0g" xml:space="preserve">'''ISewula''' Afrika kuyinarha enamalimi esemthethweni akhulunywako. Amalimi la nakapheleleko kumalimi amatjhumi amabili nasifaka nelimi lamatshwayo.&lt;ref&gt;Hlengwa-Selepe, B.B., 2020. ''A critical analysis of South Africa’s contemporary language policies with specific reference to the Use of Official Languages Act No. 12 of 2012 for government purposes'' (Doctoral dissertation, University of the Witwatersrand, Johannesburg (South Africa)).&lt;/ref&gt;&lt;ref&gt;Butler, A., 2017. ''Contemporary South Africa''. Bloomsbury Publishing.&lt;/ref&gt;Ilimi kuyinto eqakathekileko ngombana lilekelela umuntu bonyana akghone ukuveza imicabango nemibono yakhe ngendlela epheleleko nenqophileko. Kuqakathekile bona amalimi woke weSewula Afrika abulungwe ukuze akghone ukuthi angatjhabalali.

=== Ukuqakatheka kokubulunga amalimi ===

==== Ukuveza imicabango ====
Umuntu lokha nakacabanga into, ukuze akghone ukuveza bona ucabangani kufuze bona asebenzise ilimi ukuthi akghone ukudlulisa bona ucabangani ngendlela ezokuzwiwa babantu boke abamlaleleko.&lt;ref&gt;van der Veer, R. and Zavershneva, E., 2018. The final chapter of Vygotsky's Thinking and Speech: A reader's guide. ''Journal of the History of the Behavioral Sciences'', ''54''(2), pp.101-116.&lt;/ref&gt; Umuntu lokha nakadlulisa imicabango yakhe ngelimi ekungasilo lakhe angagcina sele akhuluma into angafuni ukuyikhuluma kodwana akhulume into efana naleyo afuna ukuyitjho, ngombana lokha umuntu nakakhuluma ilimi elingasilo lakhe kulula bonyana aphelelwe lilwazi lamagama afuna ukuwasenzisa bese asebenzise lawo aseduze nalelo ebakafuna ukulisebenzisa. Yeke ngokubulunga amalimi nango kuwagadangisa kweze dijithali kuzokwenza bona kube lula bonyana abantu bakghone ukuveza [[imicabango]] yabo nokuthi bakghone ukuveza imibona yabo. 

==== Ukulingana ====
Lokha amalimi weSewula Afrika nawabulungwe woke ngokwedijithali azokhona ukuthi agcine alingana kungabi nokuthi elinye ilimi liqakatheke khulu ukudlula elinye, ngombana kunelimi elingaziwako bonyana nawufuna ilwazi ngalo uzolitholaphi. Amalimi nawabulungwe woke kuzokuba nokulingana ekuzokuvela ngokuthi woke umuntu afunde esikolweni ngelimi likanina akhuliswe ngalo begodu nalikhulumako. Lokhu kuzokuba nomphumela omuhle khulu emfundweni zabafundi, ngombana nje enarheni yeSewula Afrika abafundi abakghona ukufunda ngelimi labo eenkolweni zamaziko aphakemeko bafundi abakhuluma [[ilimi]] lesiNgisi nelesiBhuru. Nakungenzeka bona amalimi alingane ngokuthuthuka, kuzokwenza bona nabantu abakhuluma amalimi ahlukileko enarheni le bamukelane, kungaba nokuthi umuntu ukhuluma into engekho nofana ukhuluma ilimi elingaziwako.

==== Ifundo ====
Umnyango wezefundo uhlele bewaphasisa umthetho wokuthi kufanele abafundi be greyidi-4 bafunde ngamalimi wabo isifundo seembalo Kanye nesesayensi yemvelo.&lt;ref&gt;Veriava, F., 2024. The Basic Education Laws Amendment Bill: A case study in transformative constitutionalism beyond the courts. ''African Human Rights Law Journal'', ''24''(1), pp.153-178.&lt;/ref&gt;Ukubulungwa kwalimi kuzokwenza bona umsebenzi lo ubeyipumelelo, ngombana kuzokwenza bona kugcine sele kufundwa ngamalimi asemthethweni ama-12 weSewula afrika efundweni yamazika aphakemeko.Kuzokuba netjhuguluko efundweni yeSewula afrika.Woke amalimi we Sewula Afrika nakabulungwe ngokulingana kuzoku kghonakala bonyana woke umfundi enarheni le afunde [[isikolo]] ngelimi lakhe ukusukela e greyidini-R bekuyokufika e greyidinI ye-12 kurage godu kuyokufika efundweni yamazika aphakemeko.Ihlelo elifakwe eenkolweni le-MTBEE elifakwe eeenkolweni lizokuba yipumelelo ngombana elikho ilimi elizokubandlululwa.&lt;ref&gt;Khetoa, S., Aiseng, K., Theledi, K. and Motinyane, M., 2024. The centralization and racialization of language policy: implications for the ‘below'. ''Frontiers in Communication'', ''9'', p.1472674.&lt;/ref&gt;

==== Ubunjalo babantu ====
Woke amalimi wabantu akhulunywa eSewula Afrika kufuze abulungwe ngombana ngokwenza njalo kuzokuba nokuthuthuka kwesitjhaba nokuthi abantu abakhuluma lelo limi bakghone ukuthi bobonakale nokuthi bamukelwe enarheni yeSewula Afrika, nanyana baye kwezinye inarha bazokukghona ukubonakala ukuthi bakhuluma amanye wamalimi akhulunywa eSewula Afrika. Ilimi lenza bona umuntu azazi ukuthi ukuthi ungubani ngombana usebenzisa lona ukuzethula ahlathulule imvelaphi yakhe, begodu akghone nokuthi enze amasiko wakhe asebenzisa ilimi lakhe.&lt;ref&gt;Parajuli, B., 2021. Role of language in shaping cultural identity. ''Marsyangdi journal'', pp.112-118.&lt;/ref&gt;&lt;ref&gt;Doke, C.M., 2017. ''The Southern Bantu Languages: Handbook of African Languages''. Routledge.&lt;/ref&gt;Lokhu kungombana umuntu ngelimi akakhulumi kwaphela kodwana ukghona nokuthi enze nomvumo ngelimi.

==== Ilwazi lomthetho nokupeledwa kwamalimi ====
Lokha nakubulungwa amalimi abantu bakghona nokuthi bathole ukuthola ilwazi lokuthi bafunde ukuthi ilimi likhunywa njani nokuthi lipeledwa bunjani. Iokho kuthuthukisa izinga lokuthi woke amalimi akhulunywa eSewula Afrika angatjhugululwa enziwe amalimi angaziwako begodu kusiza nokuthi umthetho wokusetjenziswa kwelimi ulandelwe kungathokali ilimi IsiNdebele sele sikhulunywa ngokuvangwa nelimi lesiSwati ngombana lokho kungenza bonyana ilimi limotjhakale. Abantu bazokukghona ukufunda izinto ezifana nokuthi kokhunye akukhonakali bonyana utjhugulule umutjho wesiNgisi ngendlela enqophileko uwuse elimini lesiNdebele. Ilwazi lomthetho welimi lizokwenza bona abantu balahle namagama welimi labo wemvelo bese basenzise wokubolekwa elimini lesiNgisi nofana kwamanye amalimi. Isibonelo igama ejamale uburotho ngesiNdebele mgadango kodwana sele kusetjenziswa leli loburotho ekungilo lokubolekwa elimini lesiBhuru.

==== Ukusebenzisa ilimi elinothileko ====
Lokha nawukhuluma ngokusebenzisa izaga nezitjho zelimi lemvelo lazo zikghona ukuthi zivele ngendlela enothisa ilimi nofana enembako. Nakungenzeka bonyana izaga nofana izitjho zelimi elithileko zisetjenziswe sele zitjhugululwe kwelimi zigcina sele zilahlekelwe ngilokho ezikumumetheko ngokobuhlaniphi nofana ngokwefundiso. Amalimi nakabulungiweko imvelo yelimi ngekhe itheleleke Begodu abantu bazokukghona ukusebenzisa ilimi ngokulandela imithetho yalo nangendela enembako.

==== Umsebenzi wokutjhugulula ====
Ukutlola ngelimi elingasilo lakho lemvelo utlole ngokutjhugulula ilimi, kumsebenzi omkhulu engqcondweni ngombana ingqondo kufanele isebenze khulu ukwenza umsebenzi loyo&lt;ref&gt;wa Thiong'o, N., 2009. Translated by the author: My life in between languages. ''Translation Studies'', ''2''(1), pp.17-20.&lt;/ref&gt;. Ngesikhathi umuntu atjhugulula asebenzisa nobukghwari, ugcina sele alahlekelwa magama wemvelo afanele awasebenzise bese athathe lawo akungasiwo adlulisa umlayezo ngendlela enamandla. Lokha nawutjhugula inoveli nofana umdlalo ilimi lemvelo ekutlolwe ngalo lingagcina sele lingenelela kileli otjhugululela kilo ngaphandle kokuthi uhlele ukuthi lingenelele. Nalibulungiweko ilimi lizokuthuthuka bese abantu bazokukhona ukuthi bathole iinsetjenziswa ezikhghona ukutjhugulula msinya ilimi. Lokho kuzokwehlisa umsebenzi omkhulu owenzeka engqcondweni lokha nawutjhugululako.

==== Ukuzithemba ====
Lokha ilimi nalibulungiweko lenza bona abantu abalikhulumako bagcine sele baba nokuzithemba ngombana bazabe bakhuluma ilimi elaziwako nelilingana namanye amalimi wenarheni. Isibonelo nangabe umuntu akhuluma IsiNdebele endaweni yamaPedi angekhe agcine abenevalo lokuthi bazomnyaza nofana bangamamukeli ngombana naye lakhe ilimi kuzobe kulilimi elaziwako enarheni yeSewula Afrika begodu nakwezinye iiinarha zephasini.

==== Ukuthutha ====
Ukubulunga amalimi kuzokwenza bona amalimi woke azeke endaweni zoke zenarha YeSewula Afrika. Lokho kuzokwenza ukuthi nanoma umuntu athutha endaweni yekhabo ayokwakha endaweni lapho bakhuluma elinye ilimi elingafani nelakhe, angalahlekelwa kuzithemba bese agcine atjhugulula ilimi lakhe athathe labantu labo esele aphila nabo ngaleso skhathi.

==== Ukwanela kweensetjenziswa zefundo ====
Lokha amalimi nakabulungeke woke, kuzokuba lula bona woke amalimi abe neensetjenziswa zokufunda ezifana neencwadi zabantwana zokufunda nokhunye okungenza bona ifundo yabantwana ibe lula. Abantu abanye abanzima sele bathanda bona abantwana babo bafunde ngelimi lesiNgisi ngombana bobona ngathi isiNgisi lilimi eliphambili ngesibanga sokuthi lineensetjenziswa ezinengi zokufunda begodu kulilimi elikhulunywa iphasi loke.Ilimi kuyinto eyenza abantu bona bakghone ukuthi ukuveza imicabango yabo, begodu baphendule lokho abakuzwako ngokwendlela yabo. Amalimi akhona eSewula Afrika kufanele abulungwe woke ukuze akghone ukuthi alingane, begodu kungabi nomehluko lokha abantu abakhuluma.

== Iinkomba ==</text>
      <sha1>8lg99jqhdw7va9r82x1akix3i380b0g</sha1>
    </revision>
    <revision>
      <id>5758</id>
      <parentid>3428</parentid>
      <timestamp>2025-09-21T09:34:24Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5758</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8626" sha1="ry3mqdlqkvc4oj61kmx5bew5qosuu78" xml:space="preserve">[[Isimumathi:Flag of South Africa.svg|thumb]]
'''ISewula''' Afrika kuyinarha enamalimi esemthethweni akhulunywako. Amalimi la nakapheleleko kumalimi amatjhumi amabili nasifaka nelimi lamatshwayo.&lt;ref&gt;Hlengwa-Selepe, B.B., 2020. ''A critical analysis of South Africa’s contemporary language policies with specific reference to the Use of Official Languages Act No. 12 of 2012 for government purposes'' (Doctoral dissertation, University of the Witwatersrand, Johannesburg (South Africa)).&lt;/ref&gt;&lt;ref&gt;Butler, A., 2017. ''Contemporary South Africa''. Bloomsbury Publishing.&lt;/ref&gt;Ilimi kuyinto eqakathekileko ngombana lilekelela umuntu bonyana akghone ukuveza imicabango nemibono yakhe ngendlela epheleleko nenqophileko. Kuqakathekile bona amalimi woke weSewula Afrika abulungwe ukuze akghone ukuthi angatjhabalali.

=== Ukuqakatheka kokubulunga amalimi ===

==== Ukuveza imicabango ====
Umuntu lokha nakacabanga into, ukuze akghone ukuveza bona ucabangani kufuze bona asebenzise ilimi ukuthi akghone ukudlulisa bona ucabangani ngendlela ezokuzwiwa babantu boke abamlaleleko.&lt;ref&gt;van der Veer, R. and Zavershneva, E., 2018. The final chapter of Vygotsky's Thinking and Speech: A reader's guide. ''Journal of the History of the Behavioral Sciences'', ''54''(2), pp.101-116.&lt;/ref&gt; Umuntu lokha nakadlulisa imicabango yakhe ngelimi ekungasilo lakhe angagcina sele akhuluma into angafuni ukuyikhuluma kodwana akhulume into efana naleyo afuna ukuyitjho, ngombana lokha umuntu nakakhuluma ilimi elingasilo lakhe kulula bonyana aphelelwe lilwazi lamagama afuna ukuwasenzisa bese asebenzise lawo aseduze nalelo ebakafuna ukulisebenzisa. Yeke ngokubulunga amalimi nango kuwagadangisa kweze dijithali kuzokwenza bona kube lula bonyana abantu bakghone ukuveza [[imicabango]] yabo nokuthi bakghone ukuveza imibona yabo. 

==== Ukulingana ====
Lokha amalimi weSewula Afrika nawabulungwe woke ngokwedijithali azokhona ukuthi agcine alingana kungabi nokuthi elinye ilimi liqakatheke khulu ukudlula elinye, ngombana kunelimi elingaziwako bonyana nawufuna ilwazi ngalo uzolitholaphi. Amalimi nawabulungwe woke kuzokuba nokulingana ekuzokuvela ngokuthi woke umuntu afunde esikolweni ngelimi likanina akhuliswe ngalo begodu nalikhulumako. Lokhu kuzokuba nomphumela omuhle khulu emfundweni zabafundi, ngombana nje enarheni yeSewula Afrika abafundi abakghona ukufunda ngelimi labo eenkolweni zamaziko aphakemeko bafundi abakhuluma [[ilimi]] lesiNgisi nelesiBhuru. Nakungenzeka bona amalimi alingane ngokuthuthuka, kuzokwenza bona nabantu abakhuluma amalimi ahlukileko enarheni le bamukelane, kungaba nokuthi umuntu ukhuluma into engekho nofana ukhuluma ilimi elingaziwako.

==== Ifundo ====
Umnyango wezefundo uhlele bewaphasisa umthetho wokuthi kufanele abafundi be greyidi-4 bafunde ngamalimi wabo isifundo seembalo Kanye nesesayensi yemvelo.&lt;ref&gt;Veriava, F., 2024. The Basic Education Laws Amendment Bill: A case study in transformative constitutionalism beyond the courts. ''African Human Rights Law Journal'', ''24''(1), pp.153-178.&lt;/ref&gt;Ukubulungwa kwalimi kuzokwenza bona umsebenzi lo ubeyipumelelo, ngombana kuzokwenza bona kugcine sele kufundwa ngamalimi asemthethweni ama-12 weSewula afrika efundweni yamazika aphakemeko.Kuzokuba netjhuguluko efundweni yeSewula afrika.Woke amalimi we Sewula Afrika nakabulungwe ngokulingana kuzoku kghonakala bonyana woke umfundi enarheni le afunde [[isikolo]] ngelimi lakhe ukusukela e greyidini-R bekuyokufika e greyidinI ye-12 kurage godu kuyokufika efundweni yamazika aphakemeko.Ihlelo elifakwe eenkolweni le-MTBEE elifakwe eeenkolweni lizokuba yipumelelo ngombana elikho ilimi elizokubandlululwa.&lt;ref&gt;Khetoa, S., Aiseng, K., Theledi, K. and Motinyane, M., 2024. The centralization and racialization of language policy: implications for the ‘below'. ''Frontiers in Communication'', ''9'', p.1472674.&lt;/ref&gt;

==== Ubunjalo babantu ====
Woke amalimi wabantu akhulunywa eSewula Afrika kufuze abulungwe ngombana ngokwenza njalo kuzokuba nokuthuthuka kwesitjhaba nokuthi abantu abakhuluma lelo limi bakghone ukuthi bobonakale nokuthi bamukelwe enarheni yeSewula Afrika, nanyana baye kwezinye inarha bazokukghona ukubonakala ukuthi bakhuluma amanye wamalimi akhulunywa eSewula Afrika. Ilimi lenza bona umuntu azazi ukuthi ukuthi ungubani ngombana usebenzisa lona ukuzethula ahlathulule imvelaphi yakhe, begodu akghone nokuthi enze amasiko wakhe asebenzisa ilimi lakhe.&lt;ref&gt;Parajuli, B., 2021. Role of language in shaping cultural identity. ''Marsyangdi journal'', pp.112-118.&lt;/ref&gt;&lt;ref&gt;Doke, C.M., 2017. ''The Southern Bantu Languages: Handbook of African Languages''. Routledge.&lt;/ref&gt;Lokhu kungombana umuntu ngelimi akakhulumi kwaphela kodwana ukghona nokuthi enze nomvumo ngelimi.

==== Ilwazi lomthetho nokupeledwa kwamalimi ====
Lokha nakubulungwa amalimi abantu bakghona nokuthi bathole ukuthola ilwazi lokuthi bafunde ukuthi ilimi likhunywa njani nokuthi lipeledwa bunjani. Iokho kuthuthukisa izinga lokuthi woke amalimi akhulunywa eSewula Afrika angatjhugululwa enziwe amalimi angaziwako begodu kusiza nokuthi umthetho wokusetjenziswa kwelimi ulandelwe kungathokali ilimi IsiNdebele sele sikhulunywa ngokuvangwa nelimi lesiSwati ngombana lokho kungenza bonyana ilimi limotjhakale. Abantu bazokukghona ukufunda izinto ezifana nokuthi kokhunye akukhonakali bonyana utjhugulule umutjho wesiNgisi ngendlela enqophileko uwuse elimini lesiNdebele. Ilwazi lomthetho welimi lizokwenza bona abantu balahle namagama welimi labo wemvelo bese basenzise wokubolekwa elimini lesiNgisi nofana kwamanye amalimi. Isibonelo igama ejamale uburotho ngesiNdebele mgadango kodwana sele kusetjenziswa leli loburotho ekungilo lokubolekwa elimini lesiBhuru.

==== Ukusebenzisa ilimi elinothileko ====
Lokha nawukhuluma ngokusebenzisa izaga nezitjho zelimi lemvelo lazo zikghona ukuthi zivele ngendlela enothisa ilimi nofana enembako. Nakungenzeka bonyana izaga nofana izitjho zelimi elithileko zisetjenziswe sele zitjhugululwe kwelimi zigcina sele zilahlekelwe ngilokho ezikumumetheko ngokobuhlaniphi nofana ngokwefundiso. Amalimi nakabulungiweko imvelo yelimi ngekhe itheleleke Begodu abantu bazokukghona ukusebenzisa ilimi ngokulandela imithetho yalo nangendela enembako.

==== Umsebenzi wokutjhugulula ====
Ukutlola ngelimi elingasilo lakho lemvelo utlole ngokutjhugulula ilimi, kumsebenzi omkhulu engqcondweni ngombana ingqondo kufanele isebenze khulu ukwenza umsebenzi loyo&lt;ref&gt;wa Thiong'o, N., 2009. Translated by the author: My life in between languages. ''Translation Studies'', ''2''(1), pp.17-20.&lt;/ref&gt;. Ngesikhathi umuntu atjhugulula asebenzisa nobukghwari, ugcina sele alahlekelwa magama wemvelo afanele awasebenzise bese athathe lawo akungasiwo adlulisa umlayezo ngendlela enamandla. Lokha nawutjhugula inoveli nofana umdlalo ilimi lemvelo ekutlolwe ngalo lingagcina sele lingenelela kileli otjhugululela kilo ngaphandle kokuthi uhlele ukuthi lingenelele. Nalibulungiweko ilimi lizokuthuthuka bese abantu bazokukhona ukuthi bathole iinsetjenziswa ezikhghona ukutjhugulula msinya ilimi. Lokho kuzokwehlisa umsebenzi omkhulu owenzeka engqcondweni lokha nawutjhugululako.

==== Ukuzithemba ====
Lokha ilimi nalibulungiweko lenza bona abantu abalikhulumako bagcine sele baba nokuzithemba ngombana bazabe bakhuluma ilimi elaziwako nelilingana namanye amalimi wenarheni. Isibonelo nangabe umuntu akhuluma IsiNdebele endaweni yamaPedi angekhe agcine abenevalo lokuthi bazomnyaza nofana bangamamukeli ngombana naye lakhe ilimi kuzobe kulilimi elaziwako enarheni yeSewula Afrika begodu nakwezinye iiinarha zephasini.

==== Ukuthutha ====
Ukubulunga amalimi kuzokwenza bona amalimi woke azeke endaweni zoke zenarha YeSewula Afrika. Lokho kuzokwenza ukuthi nanoma umuntu athutha endaweni yekhabo ayokwakha endaweni lapho bakhuluma elinye ilimi elingafani nelakhe, angalahlekelwa kuzithemba bese agcine atjhugulula ilimi lakhe athathe labantu labo esele aphila nabo ngaleso skhathi.

==== Ukwanela kweensetjenziswa zefundo ====
Lokha amalimi nakabulungeke woke, kuzokuba lula bona woke amalimi abe neensetjenziswa zokufunda ezifana neencwadi zabantwana zokufunda nokhunye okungenza bona ifundo yabantwana ibe lula. Abantu abanye abanzima sele bathanda bona abantwana babo bafunde ngelimi lesiNgisi ngombana bobona ngathi isiNgisi lilimi eliphambili ngesibanga sokuthi lineensetjenziswa ezinengi zokufunda begodu kulilimi elikhulunywa iphasi loke.Ilimi kuyinto eyenza abantu bona bakghone ukuthi ukuveza imicabango yabo, begodu baphendule lokho abakuzwako ngokwendlela yabo. Amalimi akhona eSewula Afrika kufanele abulungwe woke ukuze akghone ukuthi alingane, begodu kungabi nomehluko lokha abantu abakhuluma.

== Iinkomba ==</text>
      <sha1>ry3mqdlqkvc4oj61kmx5bew5qosuu78</sha1>
    </revision>
    <revision>
      <id>5759</id>
      <parentid>5758</parentid>
      <timestamp>2025-09-21T09:36:41Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5759</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8712" sha1="9o2018bhl1duy4musxermm4bv1v4kcc" xml:space="preserve">[[Isimumathi:Flag of South Africa.svg|thumb]]
'''ISewula''' Afrika kuyinarha enamalimi esemthethweni akhulunywako. Amalimi la nakapheleleko kumalimi amatjhumi amabili nasifaka nelimi lamatshwayo.&lt;ref&gt;Hlengwa-Selepe, B.B., 2020. ''A critical analysis of South Africa’s contemporary language policies with specific reference to the Use of Official Languages Act No. 12 of 2012 for government purposes'' (Doctoral dissertation, University of the Witwatersrand, Johannesburg (South Africa)).&lt;/ref&gt;&lt;ref&gt;Butler, A., 2017. ''Contemporary South Africa''. Bloomsbury Publishing.&lt;/ref&gt;Ilimi kuyinto eqakathekileko ngombana lilekelela umuntu bonyana akghone ukuveza imicabango nemibono yakhe ngendlela epheleleko nenqophileko. Kuqakathekile bona amalimi woke weSewula Afrika abulungwe ukuze akghone ukuthi angatjhabalali.

=== Ukuqakatheka kokubulunga amalimi ===

==== Ukuveza imicabango ====
Umuntu lokha nakacabanga into, ukuze akghone ukuveza bona ucabangani kufuze bona asebenzise ilimi ukuthi akghone ukudlulisa bona ucabangani ngendlela ezokuzwiwa babantu boke abamlaleleko.&lt;ref&gt;van der Veer, R. and Zavershneva, E., 2018. The final chapter of Vygotsky's Thinking and Speech: A reader's guide. ''Journal of the History of the Behavioral Sciences'', ''54''(2), pp.101-116.&lt;/ref&gt; Umuntu lokha nakadlulisa imicabango yakhe ngelimi ekungasilo lakhe angagcina sele akhuluma into angafuni ukuyikhuluma kodwana akhulume into efana naleyo afuna ukuyitjho, ngombana lokha umuntu nakakhuluma ilimi elingasilo lakhe kulula bonyana aphelelwe lilwazi lamagama afuna ukuwasenzisa bese asebenzise lawo aseduze nalelo ebakafuna ukulisebenzisa. Yeke ngokubulunga amalimi nango kuwagadangisa kweze dijithali kuzokwenza bona kube lula bonyana abantu bakghone ukuveza [[imicabango]] yabo nokuthi bakghone ukuveza imibona yabo. 

==== Ukulingana ====
Lokha amalimi weSewula Afrika nawabulungwe woke ngokwedijithali azokhona ukuthi agcine alingana kungabi nokuthi elinye ilimi liqakatheke khulu ukudlula elinye, ngombana kunelimi elingaziwako bonyana nawufuna ilwazi ngalo uzolitholaphi. Amalimi nawabulungwe woke kuzokuba nokulingana ekuzokuvela ngokuthi woke umuntu afunde esikolweni ngelimi likanina akhuliswe ngalo begodu nalikhulumako. Lokhu kuzokuba nomphumela omuhle khulu emfundweni zabafundi, ngombana nje enarheni yeSewula Afrika abafundi abakghona ukufunda ngelimi labo eenkolweni zamaziko aphakemeko bafundi abakhuluma [[ilimi]] lesiNgisi nelesiBhuru. Nakungenzeka bona amalimi alingane ngokuthuthuka, kuzokwenza bona nabantu abakhuluma amalimi ahlukileko enarheni le bamukelane, kungaba nokuthi umuntu ukhuluma into engekho nofana ukhuluma ilimi elingaziwako.

==== Ifundo ====
Umnyango wezefundo uhlele bewaphasisa umthetho wokuthi kufanele abafundi be greyidi-4 bafunde ngamalimi wabo isifundo seembalo Kanye nesesayensi yemvelo.&lt;ref&gt;Veriava, F., 2024. The Basic Education Laws Amendment Bill: A case study in transformative constitutionalism beyond the courts. ''African Human Rights Law Journal'', ''24''(1), pp.153-178.&lt;/ref&gt;Ukubulungwa kwalimi kuzokwenza bona umsebenzi lo ubeyipumelelo, ngombana kuzokwenza bona kugcine sele kufundwa ngamalimi asemthethweni ama-12 weSewula afrika efundweni yamazika aphakemeko.Kuzokuba netjhuguluko efundweni yeSewula afrika.Woke amalimi we Sewula Afrika nakabulungwe ngokulingana kuzoku kghonakala bonyana woke umfundi enarheni le afunde [[isikolo]] ngelimi lakhe ukusukela e greyidini-R bekuyokufika e greyidinI ye-12 kurage godu kuyokufika efundweni yamazika aphakemeko.Ihlelo elifakwe eenkolweni le-MTBEE elifakwe eeenkolweni lizokuba yipumelelo ngombana elikho ilimi elizokubandlululwa.&lt;ref&gt;Khetoa, S., Aiseng, K., Theledi, K. and Motinyane, M., 2024. The centralization and racialization of language policy: implications for the ‘below'. ''Frontiers in Communication'', ''9'', p.1472674.&lt;/ref&gt;

==== Ubunjalo babantu ====
Woke amalimi wabantu akhulunywa eSewula Afrika kufuze abulungwe ngombana ngokwenza njalo kuzokuba nokuthuthuka kwesitjhaba nokuthi abantu abakhuluma lelo limi bakghone ukuthi bobonakale nokuthi bamukelwe enarheni yeSewula Afrika, nanyana baye kwezinye inarha bazokukghona ukubonakala ukuthi bakhuluma amanye wamalimi akhulunywa eSewula Afrika. Ilimi lenza bona umuntu azazi ukuthi ukuthi ungubani ngombana usebenzisa lona ukuzethula ahlathulule imvelaphi yakhe, begodu akghone nokuthi enze amasiko wakhe asebenzisa ilimi lakhe.&lt;ref&gt;Parajuli, B., 2021. Role of language in shaping cultural identity. ''Marsyangdi journal'', pp.112-118.&lt;/ref&gt;&lt;ref&gt;Doke, C.M., 2017. ''The Southern Bantu Languages: Handbook of African Languages''. Routledge.&lt;/ref&gt;Lokhu kungombana umuntu ngelimi akakhulumi kwaphela kodwana ukghona nokuthi enze nomvumo ngelimi.

==== Ilwazi lomthetho nokupeledwa kwamalimi ====
Lokha nakubulungwa amalimi abantu bakghona nokuthi bathole ukuthola ilwazi lokuthi bafunde ukuthi ilimi likhunywa njani nokuthi lipeledwa bunjani. Iokho kuthuthukisa izinga lokuthi woke amalimi akhulunywa eSewula Afrika angatjhugululwa enziwe amalimi angaziwako begodu kusiza nokuthi umthetho wokusetjenziswa kwelimi ulandelwe kungathokali ilimi IsiNdebele sele sikhulunywa ngokuvangwa nelimi lesiSwati ngombana lokho kungenza bonyana ilimi limotjhakale. Abantu bazokukghona ukufunda izinto ezifana nokuthi kokhunye akukhonakali bonyana utjhugulule umutjho wesiNgisi ngendlela enqophileko uwuse elimini lesiNdebele. Ilwazi lomthetho welimi lizokwenza bona abantu balahle namagama welimi labo wemvelo bese basenzise wokubolekwa elimini lesiNgisi nofana kwamanye amalimi. Isibonelo igama ejamale uburotho ngesiNdebele mgadango kodwana sele kusetjenziswa leli loburotho ekungilo lokubolekwa elimini lesiBhuru.

==== Ukusebenzisa ilimi elinothileko ====
Lokha nawukhuluma ngokusebenzisa izaga nezitjho zelimi lemvelo lazo zikghona ukuthi zivele ngendlela enothisa ilimi nofana enembako. Nakungenzeka bonyana izaga nofana izitjho zelimi elithileko zisetjenziswe sele zitjhugululwe kwelimi zigcina sele zilahlekelwe ngilokho ezikumumetheko ngokobuhlaniphi nofana ngokwefundiso. Amalimi nakabulungiweko imvelo yelimi ngekhe itheleleke Begodu abantu bazokukghona ukusebenzisa ilimi ngokulandela imithetho yalo nangendela enembako.

==== Umsebenzi wokutjhugulula ====
Ukutlola ngelimi elingasilo lakho lemvelo utlole ngokutjhugulula ilimi, kumsebenzi omkhulu engqcondweni ngombana ingqondo kufanele isebenze khulu ukwenza umsebenzi loyo&lt;ref&gt;wa Thiong'o, N., 2009. Translated by the author: My life in between languages. ''Translation Studies'', ''2''(1), pp.17-20.&lt;/ref&gt;. Ngesikhathi umuntu atjhugulula asebenzisa nobukghwari, ugcina sele alahlekelwa magama wemvelo afanele awasebenzise bese athathe lawo akungasiwo adlulisa umlayezo ngendlela enamandla. Lokha nawutjhugula inoveli nofana umdlalo ilimi lemvelo ekutlolwe ngalo lingagcina sele lingenelela kileli otjhugululela kilo ngaphandle kokuthi uhlele ukuthi lingenelele. Nalibulungiweko ilimi lizokuthuthuka bese abantu bazokukhona ukuthi bathole iinsetjenziswa ezikhghona ukutjhugulula msinya ilimi. Lokho kuzokwehlisa umsebenzi omkhulu owenzeka engqcondweni lokha nawutjhugululako.

==== Ukuzithemba ====
Lokha ilimi nalibulungiweko lenza bona abantu abalikhulumako bagcine sele baba nokuzithemba ngombana bazabe bakhuluma ilimi elaziwako nelilingana namanye amalimi wenarheni. Isibonelo nangabe umuntu akhuluma IsiNdebele endaweni yamaPedi angekhe agcine abenevalo lokuthi bazomnyaza nofana bangamamukeli ngombana naye lakhe ilimi kuzobe kulilimi elaziwako enarheni yeSewula Afrika begodu nakwezinye iiinarha zephasini.

==== Ukuthutha ====
Ukubulunga amalimi kuzokwenza bona amalimi woke azeke endaweni zoke zenarha YeSewula Afrika. Lokho kuzokwenza ukuthi nanoma umuntu athutha endaweni yekhabo ayokwakha endaweni lapho bakhuluma elinye ilimi elingafani nelakhe, angalahlekelwa kuzithemba bese agcine atjhugulula ilimi lakhe athathe labantu labo esele aphila nabo ngaleso skhathi.

==== Ukwanela kweensetjenziswa zefundo ====
Lokha amalimi nakabulungeke woke, kuzokuba lula bona woke amalimi abe neensetjenziswa zokufunda ezifana neencwadi zabantwana zokufunda nokhunye okungenza bona ifundo yabantwana ibe lula. Abantu abanye abanzima sele bathanda bona abantwana babo bafunde ngelimi lesiNgisi ngombana bobona ngathi isiNgisi lilimi eliphambili ngesibanga sokuthi lineensetjenziswa ezinengi zokufunda begodu kulilimi elikhulunywa iphasi loke.Ilimi kuyinto eyenza abantu bona bakghone ukuthi ukuveza imicabango yabo, begodu baphendule lokho abakuzwako ngokwendlela yabo. Amalimi akhona eSewula Afrika kufanele abulungwe woke ukuze akghone ukuthi alingane, begodu kungabi nomehluko lokha abantu abakhuluma.

== Iinkomba ==
[[Category: Ilimi]]
[[Category: ukubulunga amalimi]]
[[Category: Ukubulunga amagugu]]</text>
      <sha1>9o2018bhl1duy4musxermm4bv1v4kcc</sha1>
    </revision>
  </page>
  <page>
    <title>Isifo se-Lyme</title>
    <ns>0</ns>
    <id>601</id>
    <revision>
      <id>2830</id>
      <timestamp>2025-05-21T21:53:09Z</timestamp>
      <contributor>
        <username>Mr. Ibrahem</username>
        <id>100</id>
      </contributor>
      <comment>Created by translating the page [[:mdwiki:Special:Redirect/revision/1457966|Lyme disease]] to:nr</comment>
      <origin>2830</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7314" sha1="j0aakqmmvsdo3zi0wx4ppctyjuww4yy" xml:space="preserve">{{Infobox medical condition
| name          = Lyme disease
| synonym       = Lyme borreliosis
| image         = Adult deer tick.jpg
| image_size    = 
| image_thumbtime = 
| alt           = 
| caption       = An adult [[Ixodes scapularis|deer tick]] (most cases of Lyme are caused by nymphal rather than adult ticks)
| pronounce     = 
| field         = [[Infectious diseases (medical specialty)|Infectious disease]]
| symptoms      = Expanding area of redness at the site of a [[tick]] bite, [[fever]], [[headache]], [[fatigue (medical)|tiredness]]&lt;ref name=CDC2013S/&gt;
| complications = [[Facial nerve paralysis]], [[arthritis]], [[meningitis]]&lt;ref name=CDC2013S/&gt;
| onset         = A week after a bite&lt;ref name=CDC2013S/&gt;
| duration      = 
| types         = 
| causes        = ''[[Borrelia]]'' spread by ticks&lt;ref name=NEJM2014/&gt;
| risks         = 
| diagnosis     = Based on symptoms, tick exposure, blood tests&lt;ref name=CDC2013Diag/&gt;
| differential  = 
| prevention    = Prevention of tick bites (clothing the limbs, [[DEET]]), [[doxycycline]]&lt;ref name=NEJM2014/&gt;
| treatment     = 
| medication    = [[Doxycycline]], [[amoxicillin]], [[azithromycin]], [[ceftriaxone]], [[cefuroxime]]&lt;ref name=BNF2022/&gt;
| prognosis     = 
| frequency     = 365,000 per year&lt;ref name=NEJM2014/&gt;&lt;ref name=Berg2014/&gt;
| deaths        = 
| video1        = [[File:Lyme disease.webm|frameless|upright=1.36|Video explanation]]
| named after   = 
}}
'''Isifo se-Lyme''', esaziwa nangokuthi '''yi-Lyme borreliosis''', bulwelwe obuthathelwanako obubangwa yi- ''Borrelia'' bacterium esabalaliswa mikhaza .  Itshwayo elivame khulu lokutheleleka yindawo ekhulako yokubomvu esikhumbeni, eyaziwa nge -erythema migrans, ebonakala endaweni lapho umkhaza ulunywe khona ngemva kweveke kwenzeke. &lt;ref name=&quot;CDC2013S&quot; /&gt; Iratjhi kanengi ayilunywa namkha ibe buhlungu. &lt;ref name=&quot;CDC2013S&quot; /&gt; Pheze ama-70 ukuya kwama-80% wabantu abathelelekileko baba ne-rash. &lt;ref name=&quot;CDC2013S&quot; /&gt; Ezinye iimpawu zokuthoma zingafakahlangana umkhuhlane, ihloko, ukudinwa kanye namadlala avuvukileko .  Ivamise ukurarulula ngesigaba lesi. &lt;ref name=&quot;Kumar2020&quot; /&gt; Nakungalatjhwa, abanye abantu bangathoma ukulahlekelwa likghono lokunyakazisa ihlangothi elilodwa nofana zombili zobuso, ubuhlungu emalungwini, ukuphathwa yihloko okukhulu nokuqina kwentamo, nofana ukubetha kwehliziyo, hlangana nezinye. &lt;ref name=&quot;CDC2013S&quot; /&gt; Ngemva kweenyanga ukuya eminyakeni, kungenzeka iinkhathi eziphindaphindiweko zobuhlungu bamalunga nokuvuvuka. &lt;ref name=&quot;CDC2013S&quot; /&gt; &lt;ref name=&quot;Kumar2020&quot; /&gt; Ngezinye iinkhathi, abantu baba nobuhlungu bokudubula nofana ukuvuvuka emikhonweni nemilenzeni yabo. &lt;ref name=&quot;CDC2013S&quot; /&gt; Nanyana kunikelwa ukwelatjhwa okufaneleko, abantu abangaba li-10 ukuya kweli-20% baba nobuhlungu bamalunga, imiraro yokukhumbula, nokudinwa okungenani iinyanga ezisithandathu.  

Ubulwelwe be-Lyme budluliselwa ebantwini ngokulunywa mikhaza enesifo somhlobo we- ''Ixodes'' .  E-United States, imikhaza ekhathazako ivamise ukuba mhlobo we ''-Ixodes scapularis'', begodu kufuze inamathele okungenani ama-awa ama-36 ngaphambi kobana ibhaktheriya isabalale.   E-Europe, imikhaza yomhlobo we ''-Ixodes ricinus'' ingasabalalisa ibhaktheriya msinyana. &lt;ref name=&quot;Ste2016&quot; /&gt;  E-North America, ibhaktheriya ''i-Borrelia burgdorferi'' kanye ''ne-Borrelia mayonii'' ibanga isifo se-Lyme. &lt;ref name=&quot;NEJM2014&quot;&gt;{{cite journal|vauthors=Shapiro ED|date=May 2014|title=Clinical practice. Lyme disease|url=http://portal.mah.harvard.edu/templatesnew/departments/MTA/Lyme/uploaded_documents/NEJMcp1314325.pdf|journal=[[The New England Journal of Medicine]]|volume=370|issue=18|pages=1724–1731|doi=10.1056/NEJMcp1314325|pmc=4487875|pmid=24785207|archive-url=https://web.archive.org/web/20160821071927/http://portal.mah.harvard.edu/templatesnew/departments/MTA/Lyme/uploaded_documents/NEJMcp1314325.pdf|archive-date=21 August 2016|via=|access-date=5 July 2016|url-status=dead}}&lt;/ref&gt;  E-Europe ne-Asia, ''i-Borrelia afzelii'' kanye ''ne-Borrelia garinii'' nazo zibangela ubulwele.  Ubulwelwe lobu abubonakali butheleleka hlangana nabantu, ngezinye iinlwana, nofana ngokudla. &lt;ref name=&quot;CDC2013T&quot; /&gt; Ukuhlolwa kusekelwe ekuhlanganisweni kweempawu, umlando wokuvezwa kwemikhaza, begodu mhlamunye nokuhlolwa kwama -antibodies athileko egazini.   Ukuhlolwa kweengazi kuvamise ukuba kumbi ekuthomeni kwesifo. &lt;ref name=&quot;NEJM2014&quot; /&gt; Ukuhlolwa kwemikhaza ngayinye akusizi ngalitho. 

Ukukhandela kufaka hlangana imizamo yokukhandela ukulunywa mikhaza njengokugqoka izambatho ezivala imikhono nemilenze, nokusebenzisa iinhlahla eziqotjha iinambuzane ezisekelwe ku -DEET .  Ukusebenzisa imithi yokubulala iintwala ukwehlisa inani lemikhaza nakho kungaba kuhle. &lt;ref name=&quot;NEJM2014&quot; /&gt; Imikhaza ingasuswa ngokusebenzisa i-tweezers .  Nangabe umkhaza okhutjhweko bewuzele iingazi, umthamo munye we -doxycycline ungasetjenziswa ukukhandela ukukhula kokutheleleka, kodwana akukhuthazwa ngombana ukukhula kokutheleleka akukavami. &lt;ref name=&quot;NEJM2014&quot; /&gt; Nangabe kuvela ukutheleleka, ama-antibiotics amanengi ayasebenza, kufaka hlangana i-doxycycline, i-amoxicillin, i-azithromycin, i-ceftriaxone, kanye ne -cefuroxime .  Ukwelatjhwa okujayelekileko kuvamise ukuthatha amaviki amabili nofana amathathu. &lt;ref name=&quot;NEJM2014&quot; /&gt; Abanye abantu baba nomkhuhlane kanye nobuhlungu bemisipha namalunga ngemva kokwelatjhwa okungathatha ilanga elilodwa nofana amabili. &lt;ref name=&quot;NEJM2014&quot; /&gt; Kilabo abathola amatshwayo angapheliko, ukwelatjhwa ngama-antibiotic wesikhathi eside akukatholakali bona kuyasiza. &lt;ref name=&quot;NEJM2014&quot; /&gt; 

Ubulwelwe be-Lyme bulwelwe obuvame ukusabalaliswa mikhaza e -Northern Hemisphere .  Kulinganiselwa bona ithinta abantu abama-300,000 ngomnyaka e-United States kanye nabantu abama-65,000 ngomnyaka e-Europe.   Ukutheleleka kuvame khulu entwasahlobo nasekuthomeni kwehlobo. &lt;ref name=&quot;NEJM2014&quot; /&gt; Ubulwelwe be-Lyme batholwa njengobujamo obuhlukileko kokuthoma ngo-1975 e- Old Lyme, e-Connecticut . &lt;ref name=&quot;Car2007&quot; /&gt; Ekuthomeni bekuthathwa njenge -rheumatoid arthritis yabantwana .  Ibhaktheriya ebandakanyekako yathoma ukuchazwa ngo-1981 ngu -Willy Burgdorfer .  Amatshwayo angapheliko alandela ukwelatjhwa ahlathululwe kuhle begodu aziwa ngokuthi &quot;isifo se-Lyme ngemva kokwelatjhwa&quot; (i-PTLDS). &lt;ref name=&quot;CDC2017PT&quot;&gt;{{cite web|title=Post-Treatment Lyme Disease Syndrome|url=https://www.cdc.gov/lyme/postLDS/index.html|website=cdc.gov|access-date=20 June 2018|date=1 December 2017|df=dmy-all|archive-url=https://web.archive.org/web/20150227054926/http://www.cdc.gov/lyme/postLDS/index.html|archive-date=27 February 2015|url-status=live}}&lt;/ref&gt; I-PTLDS ihlukile ebulwelweni be-Lyme obungapheliko ; ibizo elingasasekelwa mphakathi wezesayensi begodu lisetjenziswa ngeendlela ezihlukileko ziinqhema ezihlukileko.   Abanye abasebenzi bezamaphilo bathi i-PTLDS ibangelwa kutheleleka okungapheliko, kodwana lokhu akukholelwa bona kuliqiniso ngombana abukho ubufakazi bokutheleleka okuhlalako okungatholakala ngemva kokwelatjhwa okujayelekileko.  Umjovo wesifo se-Lyme wathengiswa e-United States hlangana nomnyaka ka-1998 ukuya ku-2002, kodwana wahoxiswa emakethe ngebanga lokuthengisa okumbi. &lt;ref name=&quot;NEJM2014&quot; /&gt;   Irhubhululo liyaragela phambili ukwenza imijovo etja. &lt;ref name=&quot;NEJM2014&quot; /&gt;

== Iinkomba ==
&lt;references /&gt;
[[Category:Translated from MDWiki]]</text>
      <sha1>j0aakqmmvsdo3zi0wx4ppctyjuww4yy</sha1>
    </revision>
    <revision>
      <id>2832</id>
      <parentid>2830</parentid>
      <timestamp>2025-05-22T09:05:54Z</timestamp>
      <contributor>
        <username>Hugo.arg</username>
        <id>37</id>
      </contributor>
      <minor />
      <comment>Hugo.arg moved page [[Umsebenzisi:Mr. Ibrahem/Isifo se-Lyme]] to [[Isifo se-Lyme]]</comment>
      <origin>2830</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7314" sha1="j0aakqmmvsdo3zi0wx4ppctyjuww4yy" xml:space="preserve">{{Infobox medical condition
| name          = Lyme disease
| synonym       = Lyme borreliosis
| image         = Adult deer tick.jpg
| image_size    = 
| image_thumbtime = 
| alt           = 
| caption       = An adult [[Ixodes scapularis|deer tick]] (most cases of Lyme are caused by nymphal rather than adult ticks)
| pronounce     = 
| field         = [[Infectious diseases (medical specialty)|Infectious disease]]
| symptoms      = Expanding area of redness at the site of a [[tick]] bite, [[fever]], [[headache]], [[fatigue (medical)|tiredness]]&lt;ref name=CDC2013S/&gt;
| complications = [[Facial nerve paralysis]], [[arthritis]], [[meningitis]]&lt;ref name=CDC2013S/&gt;
| onset         = A week after a bite&lt;ref name=CDC2013S/&gt;
| duration      = 
| types         = 
| causes        = ''[[Borrelia]]'' spread by ticks&lt;ref name=NEJM2014/&gt;
| risks         = 
| diagnosis     = Based on symptoms, tick exposure, blood tests&lt;ref name=CDC2013Diag/&gt;
| differential  = 
| prevention    = Prevention of tick bites (clothing the limbs, [[DEET]]), [[doxycycline]]&lt;ref name=NEJM2014/&gt;
| treatment     = 
| medication    = [[Doxycycline]], [[amoxicillin]], [[azithromycin]], [[ceftriaxone]], [[cefuroxime]]&lt;ref name=BNF2022/&gt;
| prognosis     = 
| frequency     = 365,000 per year&lt;ref name=NEJM2014/&gt;&lt;ref name=Berg2014/&gt;
| deaths        = 
| video1        = [[File:Lyme disease.webm|frameless|upright=1.36|Video explanation]]
| named after   = 
}}
'''Isifo se-Lyme''', esaziwa nangokuthi '''yi-Lyme borreliosis''', bulwelwe obuthathelwanako obubangwa yi- ''Borrelia'' bacterium esabalaliswa mikhaza .  Itshwayo elivame khulu lokutheleleka yindawo ekhulako yokubomvu esikhumbeni, eyaziwa nge -erythema migrans, ebonakala endaweni lapho umkhaza ulunywe khona ngemva kweveke kwenzeke. &lt;ref name=&quot;CDC2013S&quot; /&gt; Iratjhi kanengi ayilunywa namkha ibe buhlungu. &lt;ref name=&quot;CDC2013S&quot; /&gt; Pheze ama-70 ukuya kwama-80% wabantu abathelelekileko baba ne-rash. &lt;ref name=&quot;CDC2013S&quot; /&gt; Ezinye iimpawu zokuthoma zingafakahlangana umkhuhlane, ihloko, ukudinwa kanye namadlala avuvukileko .  Ivamise ukurarulula ngesigaba lesi. &lt;ref name=&quot;Kumar2020&quot; /&gt; Nakungalatjhwa, abanye abantu bangathoma ukulahlekelwa likghono lokunyakazisa ihlangothi elilodwa nofana zombili zobuso, ubuhlungu emalungwini, ukuphathwa yihloko okukhulu nokuqina kwentamo, nofana ukubetha kwehliziyo, hlangana nezinye. &lt;ref name=&quot;CDC2013S&quot; /&gt; Ngemva kweenyanga ukuya eminyakeni, kungenzeka iinkhathi eziphindaphindiweko zobuhlungu bamalunga nokuvuvuka. &lt;ref name=&quot;CDC2013S&quot; /&gt; &lt;ref name=&quot;Kumar2020&quot; /&gt; Ngezinye iinkhathi, abantu baba nobuhlungu bokudubula nofana ukuvuvuka emikhonweni nemilenzeni yabo. &lt;ref name=&quot;CDC2013S&quot; /&gt; Nanyana kunikelwa ukwelatjhwa okufaneleko, abantu abangaba li-10 ukuya kweli-20% baba nobuhlungu bamalunga, imiraro yokukhumbula, nokudinwa okungenani iinyanga ezisithandathu.  

Ubulwelwe be-Lyme budluliselwa ebantwini ngokulunywa mikhaza enesifo somhlobo we- ''Ixodes'' .  E-United States, imikhaza ekhathazako ivamise ukuba mhlobo we ''-Ixodes scapularis'', begodu kufuze inamathele okungenani ama-awa ama-36 ngaphambi kobana ibhaktheriya isabalale.   E-Europe, imikhaza yomhlobo we ''-Ixodes ricinus'' ingasabalalisa ibhaktheriya msinyana. &lt;ref name=&quot;Ste2016&quot; /&gt;  E-North America, ibhaktheriya ''i-Borrelia burgdorferi'' kanye ''ne-Borrelia mayonii'' ibanga isifo se-Lyme. &lt;ref name=&quot;NEJM2014&quot;&gt;{{cite journal|vauthors=Shapiro ED|date=May 2014|title=Clinical practice. Lyme disease|url=http://portal.mah.harvard.edu/templatesnew/departments/MTA/Lyme/uploaded_documents/NEJMcp1314325.pdf|journal=[[The New England Journal of Medicine]]|volume=370|issue=18|pages=1724–1731|doi=10.1056/NEJMcp1314325|pmc=4487875|pmid=24785207|archive-url=https://web.archive.org/web/20160821071927/http://portal.mah.harvard.edu/templatesnew/departments/MTA/Lyme/uploaded_documents/NEJMcp1314325.pdf|archive-date=21 August 2016|via=|access-date=5 July 2016|url-status=dead}}&lt;/ref&gt;  E-Europe ne-Asia, ''i-Borrelia afzelii'' kanye ''ne-Borrelia garinii'' nazo zibangela ubulwele.  Ubulwelwe lobu abubonakali butheleleka hlangana nabantu, ngezinye iinlwana, nofana ngokudla. &lt;ref name=&quot;CDC2013T&quot; /&gt; Ukuhlolwa kusekelwe ekuhlanganisweni kweempawu, umlando wokuvezwa kwemikhaza, begodu mhlamunye nokuhlolwa kwama -antibodies athileko egazini.   Ukuhlolwa kweengazi kuvamise ukuba kumbi ekuthomeni kwesifo. &lt;ref name=&quot;NEJM2014&quot; /&gt; Ukuhlolwa kwemikhaza ngayinye akusizi ngalitho. 

Ukukhandela kufaka hlangana imizamo yokukhandela ukulunywa mikhaza njengokugqoka izambatho ezivala imikhono nemilenze, nokusebenzisa iinhlahla eziqotjha iinambuzane ezisekelwe ku -DEET .  Ukusebenzisa imithi yokubulala iintwala ukwehlisa inani lemikhaza nakho kungaba kuhle. &lt;ref name=&quot;NEJM2014&quot; /&gt; Imikhaza ingasuswa ngokusebenzisa i-tweezers .  Nangabe umkhaza okhutjhweko bewuzele iingazi, umthamo munye we -doxycycline ungasetjenziswa ukukhandela ukukhula kokutheleleka, kodwana akukhuthazwa ngombana ukukhula kokutheleleka akukavami. &lt;ref name=&quot;NEJM2014&quot; /&gt; Nangabe kuvela ukutheleleka, ama-antibiotics amanengi ayasebenza, kufaka hlangana i-doxycycline, i-amoxicillin, i-azithromycin, i-ceftriaxone, kanye ne -cefuroxime .  Ukwelatjhwa okujayelekileko kuvamise ukuthatha amaviki amabili nofana amathathu. &lt;ref name=&quot;NEJM2014&quot; /&gt; Abanye abantu baba nomkhuhlane kanye nobuhlungu bemisipha namalunga ngemva kokwelatjhwa okungathatha ilanga elilodwa nofana amabili. &lt;ref name=&quot;NEJM2014&quot; /&gt; Kilabo abathola amatshwayo angapheliko, ukwelatjhwa ngama-antibiotic wesikhathi eside akukatholakali bona kuyasiza. &lt;ref name=&quot;NEJM2014&quot; /&gt; 

Ubulwelwe be-Lyme bulwelwe obuvame ukusabalaliswa mikhaza e -Northern Hemisphere .  Kulinganiselwa bona ithinta abantu abama-300,000 ngomnyaka e-United States kanye nabantu abama-65,000 ngomnyaka e-Europe.   Ukutheleleka kuvame khulu entwasahlobo nasekuthomeni kwehlobo. &lt;ref name=&quot;NEJM2014&quot; /&gt; Ubulwelwe be-Lyme batholwa njengobujamo obuhlukileko kokuthoma ngo-1975 e- Old Lyme, e-Connecticut . &lt;ref name=&quot;Car2007&quot; /&gt; Ekuthomeni bekuthathwa njenge -rheumatoid arthritis yabantwana .  Ibhaktheriya ebandakanyekako yathoma ukuchazwa ngo-1981 ngu -Willy Burgdorfer .  Amatshwayo angapheliko alandela ukwelatjhwa ahlathululwe kuhle begodu aziwa ngokuthi &quot;isifo se-Lyme ngemva kokwelatjhwa&quot; (i-PTLDS). &lt;ref name=&quot;CDC2017PT&quot;&gt;{{cite web|title=Post-Treatment Lyme Disease Syndrome|url=https://www.cdc.gov/lyme/postLDS/index.html|website=cdc.gov|access-date=20 June 2018|date=1 December 2017|df=dmy-all|archive-url=https://web.archive.org/web/20150227054926/http://www.cdc.gov/lyme/postLDS/index.html|archive-date=27 February 2015|url-status=live}}&lt;/ref&gt; I-PTLDS ihlukile ebulwelweni be-Lyme obungapheliko ; ibizo elingasasekelwa mphakathi wezesayensi begodu lisetjenziswa ngeendlela ezihlukileko ziinqhema ezihlukileko.   Abanye abasebenzi bezamaphilo bathi i-PTLDS ibangelwa kutheleleka okungapheliko, kodwana lokhu akukholelwa bona kuliqiniso ngombana abukho ubufakazi bokutheleleka okuhlalako okungatholakala ngemva kokwelatjhwa okujayelekileko.  Umjovo wesifo se-Lyme wathengiswa e-United States hlangana nomnyaka ka-1998 ukuya ku-2002, kodwana wahoxiswa emakethe ngebanga lokuthengisa okumbi. &lt;ref name=&quot;NEJM2014&quot; /&gt;   Irhubhululo liyaragela phambili ukwenza imijovo etja. &lt;ref name=&quot;NEJM2014&quot; /&gt;

== Iinkomba ==
&lt;references /&gt;
[[Category:Translated from MDWiki]]</text>
      <sha1>j0aakqmmvsdo3zi0wx4ppctyjuww4yy</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Mr. Ibrahem/Ukutlhayela ukutjheja nokusebenza khulu</title>
    <ns>2</ns>
    <id>602</id>
    <revision>
      <id>2831</id>
      <timestamp>2025-05-22T03:21:58Z</timestamp>
      <contributor>
        <username>Mr. Ibrahem</username>
        <id>100</id>
      </contributor>
      <comment>Created by translating the page [[:mdwiki:Special:Redirect/revision/1465481|Attention deficit hyperactivity disorder]] to:nr</comment>
      <origin>2831</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7930" sha1="pun69jtp19r11rvrno0l9giafokj4j8" xml:space="preserve">{{Infobox medical condition
| name          = Attention_deficit_hyperactivity_disorder
| synonym       = Attention-deficit disorder, hyperkinetic disorder (ICD-10)
| image         = Primary Laos2.jpg
| image_size    = 
| image_thumbtime = 
| alt           = An image of children
| caption       = People with ADHD may find it more difficult than others to focus on and complete tasks such as schoolwork.
| pronounce     = 
| field         = [[Psychiatry]], [[pediatrics]]
| symptoms      = Difficulty paying [[attention]], excessive activity, [[impulsivity|difficulty controlling behavior]]&lt;ref name=NIH2016/&gt;&lt;ref name=DSM5/&gt;
| complications = 
| onset         = Before age 6–12&lt;ref name=CDC/&gt;
| duration      = &gt;6 months&lt;ref name=CDC/&gt;
| types         = 
| causes        = Both [[Genetic disorder|genetic]] and [[environmental factors]]&lt;ref name=nimh/&gt;&lt;ref name=Koo2019/&gt;
| risks         = 
| diagnosis     = Based on symptoms after other possible causes ruled out&lt;ref name=NIH2016/&gt;
| differential  = Normally active young child, [[conduct disorder]], [[oppositional defiant disorder]], [[learning disorder]], [[bipolar disorder]], [[fetal alcohol spectrum disorder]]&lt;ref&gt;{{Cite book |last=Ferri |first=Fred F. |title=Ferri's differential diagnosis : a practical guide to the differential diagnosis of symptoms, signs, and clinical disorders |date=2010 |publisher=Elsevier/Mosby |isbn=978-0323076999 |edition=2nd |location=Philadelphia, PA |pages=Chapter A  }}&lt;/ref&gt;&lt;ref&gt;{{cite journal |last1=Zubler, MD, FAAP |first1=Jennifer |last2=Weitzman, MD, FAAP |first2=Carol |last3=Sloane, DO |first3=Mark |last4=Singh, MPA |first4=Natasha |last5=Senturias, MD, FAAP |first5=Yasmin N. |last6=Kosofsky, MD, PhD |first6=Barry |last7=Kable, PhD |first7=Julie |last8=Fernandez-Baca, MA |first8=Daniel |last9=Dang, MPH |first9=Elizabeth |last10=Chasnoff, MD, FAAP |first10=Ira |last11=Bertrand PhD |first11=Jacquelyn |last12=Balachova PhD |first12=Tatiana |last13=Hagan Jr. MD, FAAP |first13=Joseph F. |title=Neurobehavioral Disorder Associated With Prenatal Alcohol Exposure |url=https://pediatrics.aappublications.org/content/pediatrics/138/4/e20151553.full.pdf |journal=Pediatrics |year=2016 |volume=138 |issue=4 |pages=e20151553 |publisher=American Journal of Pediatrics |doi=10.1542/peds.2015-1553 |pmid=27677572 |pmc=5477054 |access-date=22 May 2020 |archive-date=20 March 2020 |archive-url=https://web.archive.org/web/20200320042016/https://pediatrics.aappublications.org/content/pediatrics/138/4/e20151553.full.pdf |url-status=live }}&lt;/ref&gt;
| prevention    = 
| treatment     = [[psychotherapy|Counseling]], lifestyle changes, medications&lt;ref name=NIH2016/&gt;
| medication    = [[CNS stimulants|Stimulants]], [[atomoxetine]], [[guanfacine]], [[clonidine]]&lt;ref&gt;{{Cite journal |vauthors=Coghill DR, Banaschewski T, Soutullo C, Cottingham MG, Zuddas A |date=November 2017 |title=Systematic review of quality of life and functional outcomes in randomized placebo-controlled studies of medications for attention-deficit/hyperactivity disorder |journal=European Child &amp; Adolescent Psychiatry |volume=26 |issue=11 |pages=1283–1307 |doi=10.1007/s00787-017-0986-y |pmc=5656703 |pmid=28429134}}&lt;/ref&gt;&lt;ref&gt;{{Cite journal |vauthors=Jain R, Katic A |s2cid=3807877 |date=August 2016 |title=Current and Investigational Medication Delivery Systems for Treating Attention-Deficit/Hyperactivity Disorder |journal=The Primary Care Companion for CNS Disorders |volume=18 |issue=4 |doi=10.4088/PCC.16r01979 |pmid=27828696}}&lt;/ref&gt;
| prognosis     = 
| frequency     = 51.1 million (2015)&lt;ref name=GBD2015Pre/&gt;
| deaths        = 
| video1        = [[File:Attention deficit hyperactivity disorder video.webm|frameless|upright=1.36|Video explanation]]
| named after   = 
}}
'''Ukuhluleka ukutjheja''' ( '''ADHD''' ) mraro wengqondo womhlobo wokukhula kwemizwa .   Ibonakala ngobudisi bokutjheja, ukusebenza ngokweqileko, nokwenza ngaphandle kokuqalela imiphumela, okungafanelanga iminyaka yomuntu .   Abanye abantu abane-ADHD nabo batjengisa ubudisi bokulawula imizwa namkha imiraro yokusebenza kwesikhulu .    &lt;ref name=&quot;DSM5&quot; /&gt; Ukuthola isifo, amatshwayo kufanele avele ngaphambi kobana umuntu abe neminyaka elitjhumi nambili, abe khona isikhathi esingaphezu kweenyanga ezisithandathu, begodu abangele imiraro okungenani eendaweni ezimbili (njengesikolo, ekhaya, nofana emisebenzini yokuzithabisa).   Ebantwaneni, imiraro yokutjheja ingabangela bona bangasebenzi kuhle esikolweni. &lt;ref name=&quot;NIH2016&quot; /&gt; Phezu kwalokho kunokuhlobana neminye imiraro yengqondo nokusetjenziswa kumbi kweendakamizwa .  Nanyana kubangela ukukhubazeka, khulukhulu emphakathini wanamhlanjesi, abantu abanengi abane-ADHD bangaba nokutjheja okuhlalako emisebenzini abayifumana ikarisako nofana inomvuzo (eyaziwa ngokuthi yi -hyperfocus ).  

Nanyana kuyinto efundwa khulu begodu ihlolwe khulu ebantwaneni nasebatjha, imbangela eqondileko ayaziwa emacaleni amanengi.  Iinzathu zofuzo zilinganiselwa bona zenza ama-75% wobungozi.  Ukuvezwa kwe-nicotine ngesikhathi sokukhulelwa kungaba yingozi ebhodulukweni.  Akubonakali ngasuthi kuhlobana nesitayela sokukhulisa abantwana nofana ukulaya.  Ithinta abantwana abangaba ma-5-7% lokha nabatholwa ngendlela ye -DSM-IV   kanye ne-1-2% lokha nabahlolwa ngendlela ye -ICD-10 .  Kusukela ngo-2015, kulinganiselwa bona izokuthinta abantu abangaba ziingidi ezima-51.1 ephasini loke.  Amazinga ayafana hlangana namazwe begodu athembele khulu ekutheni ihlolwa njani.  I-ADHD itholakala pheze kabili ebantwaneni abafana ukudlula ebantwaneni, &lt;ref name=&quot;DSM5&quot; /&gt; nanyana ubujamo lobu buvamise ukunganakwa ebantwaneni abantazana ngombana amatshwayo wabo ahlukile kwalabo abafana.    Abantu abangaba ma-30-50% abahlolwa ebuntwaneni baragela phambili nokuba namatshwayo bekube sebudaleni begodu hlangana nama-2-5% wabantu abadala banabo ubujamo.    Ebantwini abadala ukungazinzi kwangaphakathi kunokusebenza khulu kungenzeka.  Bavamise ukuthuthukisa amakghono wokujamelana nobujamo enza ezinye nofana zoke iinqabo zabo.  Ubujamo bungaba budisi ukubuhlukanisa nezinye ubujamo, kanye nokubuhlukanisa namazinga aphezulu womsebenzi asese ngaphakathi kwebanga lokuziphatha okujayelekileko. 

Iincomo zokulawula i-ADHD ziyahluka ngokweenarha begodu zivamise ukufaka hlangana ukuhlanganiswa kokuyeleliswa, ukutjhugulula indlela yokuphila, kanye nemithi.  Umhlahlandlela we-Britain uncoma imithi njengendlela yokwelapha yokuthoma ebantwaneni abaneempawu ezimbi khulu begodu imithi kufanele icatjangelwe kilabo abaneempawu eziphakathi nendawo abangafuni namkha ababhalelwa ngcono ngokucebisa, nanyana ebantwini abadala imithi iyindlela yokuthoma yokwelapha.  Imihlahlandlela ye-Canada ne-America iphakamisa ukulawulwa kokuziphatha ebantwaneni abaseminyakeni yokuthoma esikolweni ngesikhathi imithi nokwelapha ngokuziphatha ndawonye kunconywa ngemva kwalokho.    Ukwelatjhwa ngezinto ezivuselelako kusebenza okungenani iminyaka eli-14&amp;nbsp;iinyanga; nanyana kunjalo, ukusebenza kwesikhathi eside akukacaci begodu kunemiphumela emimbi engaba khona.   ]   36   

Iincwadi zezokwelapha zihlathulule amatshwayo afana nalawo we-ADHD kusukela ngekhulu le-18.  I-ADHD, ukutholwa kwayo, nokwelatjhwa kwayo bekuthathwa njengento ephikisanako kusukela ngeminyaka yabo-1970.  Ukuphikisana kufaka hlangana abodorhodere, abotitjhere, abenzi bomthethokambiso, ababelethi, nabezindaba. Iinhloko zifaka hlangana iimbangela ze-ADHD nokusetjenziswa kwemithi evuselelako ekwelapheni kwayo.  Inengi labahlinzeki bezamaphilo bamukela i-ADHD njengesifo samambala ebantwaneni nakubantu abadala, begodu ikulumiswano emphakathini wezesayensi ikakhulukazi igxile ekutheni itholakala njani begodu ilatjhwa njani.    Ubujamo bebubizwa ngokuthi yi '''-attention deficit disorder''' ( '''ADD''' ) kusukela ngo-1980 ukuya ku-1987, kuthi ngaphambi kwalokhu bebubizwa ngokuthi yi '''-hyperkinetic reaction yobuntwana''' .  

== Iinkomba ==
&lt;references /&gt;
[[Category:Translated from MDWiki]]</text>
      <sha1>pun69jtp19r11rvrno0l9giafokj4j8</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Mr. Ibrahem/Isifo se-Lyme</title>
    <ns>2</ns>
    <id>603</id>
    <redirect title="Isifo se-Lyme" />
    <revision>
      <id>2833</id>
      <timestamp>2025-05-22T09:05:54Z</timestamp>
      <contributor>
        <username>Hugo.arg</username>
        <id>37</id>
      </contributor>
      <comment>Hugo.arg moved page [[Umsebenzisi:Mr. Ibrahem/Isifo se-Lyme]] to [[Isifo se-Lyme]]</comment>
      <origin>2833</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="27" sha1="pn4b7aagx2pnpguwuxa2nij7saj1wns" xml:space="preserve">#REDIRECT [[Isifo se-Lyme]]</text>
      <sha1>pn4b7aagx2pnpguwuxa2nij7saj1wns</sha1>
    </revision>
  </page>
  <page>
    <title>Amalimi WeSewula Afrika</title>
    <ns>0</ns>
    <id>604</id>
    <revision>
      <id>2849</id>
      <timestamp>2025-05-26T21:05:44Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>Created page with &quot;= Amalimi WeSewula Afrika = [[Isimumathi:Flag of South Africa.svg|thumb|Iflarha leSewula Afrika]] '''Inarha yeSewula Afrika''' yinarha enabantu abanamasiko nabaneenzinda ezihlukahlukeneko, nabakhuluma amalimi ahlukahlukeneko. Inengi labantu enarheni le lisesiqhemeni sokuthoma sabantu abakhuluma amalimi angaphasi kwesiNguni, okusiZulu, isiXhosa, [[Isindebele|isiNdebele]] nesiSwati. Bese isiqhema sesibili ngobukhulu ngesikhuluma amalimi wesiSuthu, okusiTswana, isiPedi (oku...&quot;</comment>
      <origin>2849</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="17605" sha1="b4nwxlnq483vydw5rarz91d0rxmvc87" xml:space="preserve">= Amalimi WeSewula Afrika =
[[Isimumathi:Flag of South Africa.svg|thumb|Iflarha leSewula Afrika]]
'''Inarha yeSewula Afrika''' yinarha enabantu abanamasiko nabaneenzinda ezihlukahlukeneko, nabakhuluma amalimi ahlukahlukeneko. Inengi labantu enarheni le lisesiqhemeni sokuthoma sabantu abakhuluma amalimi angaphasi kwesiNguni, okusiZulu, isiXhosa, [[Isindebele|isiNdebele]] nesiSwati. Bese isiqhema sesibili ngobukhulu ngesikhuluma amalimi wesiSuthu, okusiTswana, isiPedi (okusiSuthu seTlhagwini) nesiSuthu (okusiSuthu seSewula, namkha isiSuthu sesiShweshwe). Bese kunesiqhema esikhuluma isiTsonga nesiqhema esikhuluma isiVenda.&lt;ref&gt;{{Cite web|date=2025-05-14|title=South Africa - Languages, Dialects, Afrikaans {{!}} Britannica|url=https://www.britannica.com/place/South-Africa/Languages|access-date=2025-05-15|website=www.britannica.com|language=en}}&lt;/ref&gt;

Ngaphezu kwamalimi abaliweko la kunamalimi ahlobene nawo. Ngokwesibonelo, esiNdebeleni kunesiNala, nesiNdebele seMoletlane. &lt;ref name=&quot;:0&quot;&gt;{{Cite web|title=Ndebele people, traditions culture|url=https://www.africancraftsmarket.com/african-tribes/ndebele-people.html|access-date=2025-05-15|website=www.africancraftsmarket.com}}&lt;/ref&gt; EsiXhoseni kube nesiNgqika, isiThembu, isiBhaca, isiGcaleka, isiMpondo, isiMpondomise, isiMfengu nesiBomvana.&lt;ref&gt;{{Cite web|title=XHOSA - South African Language Xhosa|url=https://www.sa-venues.com/language-xhosa.htm#:~:text=Xhosa%20has%20been%20grouped%20into,yet%20pretty-sounding,%20language.|access-date=2025-05-15|website=www.sa-venues.com}}&lt;/ref&gt; Kusese nelimi lesiThwa elibandaka isi-Khoe, isi-Tu isi-Kx'a, namanye amalimi.&lt;ref&gt;{{Cite web|title=AFRICA {{!}} 101 Last Tribes - San people|url=https://www.101lasttribes.com/tribes/san.html|access-date=2025-05-15|website=www.101lasttribes.com}}&lt;/ref&gt; Bese isiSwati kunesikhulunywa eManzini, esikhulunywa eShiselweni, nesikhulunywa eHhoho.&lt;ref name=&quot;:2&quot;&gt;{{Cite web|last=web-lingo|date=2013-01-07|title=SA’s Eleven Official Languages: SiSwati|url=https://web-lingo.com/sas-eleven-official-languages-siswati/#:~:text=Swazi%20is%20most%20closely%20related,considered%20closer%20to%20standard%20Swazi.|access-date=2025-05-15|website=Web-lingo|language=en-ZA}}&lt;/ref&gt; IsiPedi naso sinamalinyana angaphasi kwaso anjengesiTlokwa nesiLobedu.&lt;ref&gt;{{Cite web|title=free online course|url=https://www.unisa.ac.za/static/corporate_web/Content/UnisaOpen/freeOnlineCourse/nSotho/nSotho.html#:~:text=Northern%20Sotho%20is%20based%20mainly,(Cf.|access-date=2025-05-15|website=www.unisa.ac.za}}&lt;/ref&gt; Bese kube namalimi angasiwo wendabuko, namkha amalimi wesikhuwa akhulunywako njengesiNgisi nesiBhuru. Woke amalimi la namanye angakabalwa lapha malimi akhulunywa babantu beSewula Afrika.

== Amalimi Asemthethweni ==
Amalimi aseMthethweni eSewula Afrika siNdebele, isiZulu, isiSwati, isiXhosa, isiSuthu, isiPedi, isiTswana, isiVenda, isiTsonga okumalimi wendabuko, bese kuba siBhuru nesiNgisi. Ithebula elingenzasi litjengisa isibalo sabantu abakhuluma amalimi asemthethweni eSewula Afrika namaphesente wabalikhulumako esibalweni sabo boke abantu abahlala eSewula Afrika ngokweembalobalo zango-2022. &lt;ref name=&quot;:1&quot;&gt;https://en.wikipedia.org/wiki/Languages_of_South_Africa#cite_note-EthnologueZA-7&lt;/ref&gt;
{| class=&quot;wikitable sortable mw-collapsible&quot;
|+
! rowspan=&quot;2&quot; |Ilimi
! colspan=&quot;2&quot; |Ilimi lebele&lt;ref name=&quot;:1&quot; /&gt;
! colspan=&quot;2&quot; |Ilimi lesibili&lt;ref name=&quot;:1&quot; /&gt;
! colspan=&quot;2&quot; |Ilimi lesithathu&lt;ref name=&quot;:1&quot; /&gt;
|-
!Isibalo
!Amaphesente
!Isibalo
!Amaphesente
!Isibalo
!Amaphesente
|-
|IsiZulu
|11,587,374
|22.7%
|15,700,000
|30.8%
|27,300,000
|46%
|-
|IsiXhosa
|8,154,258
|16.0%
|11,000,000
|21.6%
|19,150,000
|33%
|-
|IsiVenda
|1,209,388
|2.4%
|1,700,000
|3.3%
|2,910,000
|5%
|-
|IsiTswana
|4,067,248
|8.0%
|7,700,000
|15.1%
|11,770,000
|20%
|-
|IsiTsonga
|2,277,148
|4.5%
|3,400,000
|6.6%
|5,680,000
|10%
|-
|IsiSwati
|1,297,046
|2.5%
|2,400,000
|4.7%
|3,700,000
|6%
|-
|IsiSuthu
|3,849,563
|7.6%
|7,900,000
|15.5%
|11,750,000
|20%
|-
|IsiPedi
|4,618,576
|9.1%
|9,100,000
|17.8%
|13,720,000
|23%
|-
|IsiNdebele
|1,090,223
|2.1%
|1,400,000
|2.7%
|2,490,000
|4%
|-
|IsiNgisi
|4,892,623
|9.6%
|14,000,000
|27.4%
|19,640,000
|33%
|-
|Isi-Afrikaans
|6,855,082
|13.5%
|10,300,000
|20.2%
|17,160,000
|29%
|-
|Ilimi Lezandla le-SA
|234,655
|0.5%
|500,000
|1.0%
|834,655
|1.5%
|-
|Amanye Amalimi
|828,258
|1.6%
|
|
|
|
|-
|'''Isibalo Sisoke'''
|'''50,961,443'''
|'''100.0%'''
|
|
|
|
|}

== IsiNdebele ==
[[Isimumathi:Ndebele_women-1.jpg|thumb|Abomma bamaNdebele]]
IsiNdebele seSewula Afrika ngelinye lamalimi akhulunywa enarheni le. Isizathu sokuthi kuthiwe siNdebele seSewula Afrika kukuthi kunesiNdebele seZimbabwe. &lt;ref&gt;{{Cite web|last=web-lingo|date=2012-10-19|title=Ndebele: What is Ndebele?|url=https://web-lingo.com/ndebele-what-is-ndebele/#:~:text=Northern%20Ndebele,%20or%20Matabele,%20or,nineteenth%20century%20during%20the%20Mfecane.|access-date=2025-05-15|website=Web-lingo|language=en-ZA}}&lt;/ref&gt; Ngokwethebula elingehla, abantu abakhuluma isiNdebele - abasimunyileko, okulilimi lesibili nalabo okulilimi lesithathu kibo - bangaphezu kweengidi ezine. Ilimeli likhulunywa khulukhulu esifundeni seMpumalanga eendaweni ezinjengaKwaNdebele, eMalahleni, e-Middleburg, e-Belfast, kwaDlawulale nakezinye iindawo  njengesiFunda seLimpopo.I siNdebele esisemthethweni siNzunza, kodwana kusese nesiNdebele sakwaManala nesiNdebele seMoletlane. &lt;ref name=&quot;:0&quot; /&gt; AmaNdebele aziwa njengesitjhaba esithanda imibala emihle nekhanyako ongayibona endleleni abambatha ngayo nabenza ngayo imigwalo yabo.

AmaNdebele bekangaphasi kwesiqhema sabaMbo ngaphambi kobana sizijamele ngaphasi kweNgwenyama uNdebele. Ngikho namhlanjesi kunezici ezifanako phakathi kwelimi lesiNdebele nelimi lesiHlubi, isiBhaca, isiMpondo nesiMpondomise.  Ngemva kwesikhathi uNdebele wabeletha uMkhalangana owabeletha umNtungwa. Ngemva kwesikhathi umNtungwa wabeletha uNjonono owabeletha uNjonono. UNjonono wabeletha uNanasi, uNanasi wabeletha uMafana. UMafana wabeletha uMhlanga owabeletha uMusi. Kusesikhathini seNgwenyama uMusi lapha amaNdebele ahlukana khona waba maNzunza namaNala. AmaNdebele akheka ngaleyondlela sele ahlala eSewula Afrika nje. &lt;ref&gt;https://en.wikipedia.org/wiki/Southern_Ndebele_language&lt;/ref&gt;

== IsiSwati ==
[[Isimumathi:Indoni_Parade_2018._Swati_Kingdom_by_Sizwe_Sibiya_(10).jpg|thumb|AmaSwati]]
IsiSwati sikhulunywa eenarheni ezimbili, eSewula Afrika neSwatini. Ngokwethebula elingehla abantu abakhuluma isiSwati eSewula Afrika  bangaphezu kweengidi ezilikhomba.&lt;ref name=&quot;:1&quot; /&gt; KunesiSwati esikhulunywa eSwatini kwaManzini, eShiselweni neHhoho.&lt;ref name=&quot;:2&quot; /&gt; Abantu abakhuluma isiSwati eSwatini babalelwa eengidini ezine. &lt;ref name=&quot;:3&quot;&gt;https://en.wikipedia.org/wiki/Zulu_language&lt;/ref&gt;

AmaSwati bewasiqhenyana esincani sabeNguni ebesaziwa bona Mangwane. Ngokukhamba kwesikhathi isiqhemesi sahlangana nesiqhenyana sabeSuthu ebesihlala endaweni namhlanjesi ebizwa bona kuseSwatini. Ngemva kwalokho bakhula baba sisizwe ngaphasi kweNgwenyama uDlamini III eyathatha iintambo eNgwenyameni uMaseko, yathatha isitjhaba yayosinzinzisa ngasemlanjeni iPongola bahlala eduze namaNdwandwe ngo-1750. UDlamini III walandelwa yiNgwenyama uNgwane III okukholelwa bona nguye owaba yiNgwenyama yokuthoma eyabusa indawo namhlanjesi ebizwa bona kuseSwatini.&lt;ref&gt;https://en.wikipedia.org/wiki/Swazi_people&lt;/ref&gt;

== IsiZulu ==
[[Isimumathi:Zulu_Krieger.jpg|thumb|Abobaba bamaZulu bayagida]]
IsiZulu ngelinye lamalimi adumileko asemthethweni eSewula Afrika elikhulunywa babantu ababgaogezu kweengidi ezimatjhumi amahlanu, kuthi labo abalimunyileko bangaphezu kweengidi ezilitjhumi nanye. &lt;ref name=&quot;:1&quot; /&gt; IsiZulu sikhulunywa khulu KwaZulu Natal, esiFundeni se-Gauteng nakezinye iimfunda.

Umuntu owadlala indima ekulu ekwakhekeni kwesitjhaba samaZulu yiNgwenyama uShaka. UShaka walwa neentjhaba ezincani nezikulu zabeNguni kuhlanganise namaNdwandwe wazihlula. Ngemva kwalokho wazibiza ngoZulu obekangukhokho omkhulu wesitjhaba abelethelwa kiso. Iintjhabezi zahlangana kwavela ilimi lesiZulu.&lt;ref name=&quot;:3&quot; /&gt;


== IsiXhosa ==
[[Isimumathi:Xhosa_traditionally_dressed_women.jpg|thumb|250x250px|Abomma bamaXhosa]]
IsiXhosa naso singelinye lamalimi weSewula Afrika asemthethweni. IsiXhosa sikhulunywa babantu abangaphezu kweengidi ezimatjhumi amathathu nobunane, kuthi labo okulimi labo lokubelethwa bangaphezu kweengidi ezibunane. &lt;ref name=&quot;:1&quot; /&gt; IsiXhosa sikhulunywa khulukhulu esiFundeni seTjingalanga Kapa, eTlhagwini  Kapa nesiFundeni se-Gauteng.&lt;ref&gt;{{Cite web|last=Alexander|first=Mary|date=2025-04-06|title=The languages of South Africa|url=https://southafrica-info.com/arts-culture/11-languages-south-africa/#:~:text=Among%20South%20Africa's%20population%20groups,),%20based%20on%20Census%202022.|access-date=2025-05-23|website=South Africa Gateway|language=en-GB}}&lt;/ref&gt;

Ekadeni bekuneenqhema zabeNguni ezakha ubuhlobo neentjhaba zabaThwa nabaKhoekhoe. Ngokukhamba kwesikhathi iintjhabezi zahlangana zaba sisizwe ngaphasi kokubusa kweNgwenyama uTshawe owahlula isitjhaba samaCirha namaJwarha. Ngemva kwalokho wahlanganisa zoke iintjhaba ezincani kuhlanganise nesabaKhoekhoe. Labeletheka njalo-ke ilimi lesiXhosa.&lt;ref&gt;https://en.wikipedia.org/wiki/Xhosa_people&lt;/ref&gt;

== IsiSuthu ==
[[Isimumathi:Sotho_regalia.jpg|thumb|Abobaba babeSuthu]]
IsiSuthu lilimi elisemthethweni eSewula Afrika elikhunywa babantu abangaphezu kweengidi ezimatjhumi amabili nambili. Okulilmi labo abalimunyileko bangaphezu kweengidi ezintathu. &lt;ref name=&quot;:1&quot; /&gt; IsiSuthu sikhulunywa khulu enarheni yeLesotho, kanti eSewula Afrikapha sikhulunywa khulukhulu esiFundeni seFreestate, seGauteng. Umhlobo lo wesiSuthu ubizwa ngokobana siSuthu seSewula ngombana uhlukaniswa nesiSuthu seTlhagwini - okusiPedi, nesiSuthu seTjingalanga - okusiTswana.

Emandulo abeSuthu beza eSewula Afrika bavela eTlhagwini njengezinye iintjhaba bafika bahlala etlhagwini yeSewula Afrika. Bafika baba ziinqhenyana ezinjengabaTaung, abaSia, abaFokeng, amaKgolokoe nabaKwena nezinye iinqenyana. Kuhlekuhle umndeni webukhosini eLesotho mndeni wabaKwena. AbeSuthwaba ngibo-ke ababanikazi belimi lesiSuthu esikhulunywa eSewula Afrika neLesotho.&lt;ref&gt;{{Cite web|title=SOUTHERN SESOTHO - South African Language Southern Sesotho|url=https://www.sa-venues.com/language-southern-sesotho.htm|access-date=2025-05-26|website=www.sa-venues.com}}&lt;/ref&gt;

== IsiTswana ==
[[Isimumathi:Tswana_Dancers_3.jpg|thumb|Isiqhema esigidako sabaTswana]]
IsiTswana nalo ngelinye lamalimi asesiqhemeni sesiSuthu seTjingalanga esikhulunywa eSewula Afrika neBotswana. Abantu abasikhulumako eSewula Afrika bangaphezu kweengidi ezimatjhumi amabili nantathu, abalimunyileko bangaphezu kweengidi ezine.&lt;ref name=&quot;:1&quot; /&gt; isiTswana sikhulunywa khulu enarheni yeBotswana kanti eSewula Afrika sikhulunywa khulu esiFundeni seTlhagwini-Tjhingalanga, neGauteng.

Emandulo abeTswana bebangaphasi kwesiqhema sabeSuthu nabazakufika eSewula Afrika bavela eTlhagwini ne-Afrika. Bafika baba ziinqhenyana ezinjengabaTaung, abaSia, abaFokeng, amaKgolokoe nabaKwena kunye nezinye iinqhenyana. Bafika endaweni ebizwa ngokobana yiBotswana namhlanjesi balwa nabaThwa babahlula, bese bakha umbuso wabaTswana. Ngibo-ke namhlanjesi ababanikazi belimi lesiTswana.&lt;ref&gt;{{Cite web|title=AFRICA {{!}} 101 Last Tribes - Tswana people|url=http://www.101lasttribes.com/tribes/tswana.html|access-date=2025-05-26|website=www.101lasttribes.com}}&lt;/ref&gt;

== IsiPedi ==
[[Isimumathi:Pedi_Living_Culture_Route,_Limpopo,_South_Africa_(2417712111).jpg|thumb|Umuzi wesiPedi]]
IsiPedi ([https://www.sahistory.org.za/article/pedi Sepedi]) nalo ngelinye lamalimi angaphasi kwesiSuthu atloliswe ngokomthetho eSewula Afrika, begodu saziwa ngokuthi siSuthu seTlhagwini. &lt;ref name=&quot;:4&quot;&gt;{{Cite web|title=AFRICA {{!}} 101 Last Tribes - Pedi people|url=http://www.101lasttribes.com/tribes/pedi.html|access-date=2025-05-26|website=www.101lasttribes.com}}&lt;/ref&gt; Ilimeli likhulunywa khulukhulu esiFundeni seLimpopo neseGauteng babantu abalinganiswela eengidini ezimatjhumi amabili nekhomba.&lt;ref name=&quot;:1&quot; /&gt;

Ekadeni isiqhemesi besiyingcenye yesiqhema sabeSuthu, kwathi nakukhamba ezinye iinqhema sona sasala ngetlhagwini yeSewula Afrika. Sineenqhenyana ezinengana okucatjangelwa bona sikhuluma amalinyana amatjhumi amathathu. Abanye bathi isiSuthu seTlhagwini akusiso isiPedi kodwana lilimi elihlukileko. &lt;ref name=&quot;:4&quot; /&gt;


== IsiVenda ==
[[Isimumathi:Venda_culture,_Limpopo,_South_Africa_(8714283418).jpg|thumb|251x251px|Izindlu zamaVenda]]
Elinye lamalimi atloliswe ngokomthetho eSewula Afrika siVenda. Abantu abakhuluma isiVenda balinganiselwa eengidini ezihlanu. &lt;ref name=&quot;:1&quot; /&gt; IsiVenda sikhulunywa khulu esiFundeni seLimpopo ngetlhagwini ngitjho nesiFundeni seGauteng. Nawulilemukisisa kuhle ilimeli linezici ezivela elimini lesiShona nelesiTokwa.

Ekadeni isiqhemesi kukholelwa bona sathoma ukuba khona nakusabusa uMpuso weMapungubwe, kwathi nakuwa umbuso lo kuvuka umbuso weZimbabwe sathutha sayokuhlala endaweni namhlanjesi ebizwa ngokobana kuseZimbabwe. Sakhamba isikhathi, isiqhemesi sathutha eZimbabwe sehla seyama umlambo weZambezi sazitholela indawo sayithiya ngokuthi yi-D'zata. Kusukela ngalesosikhathi umbuso wabo uye wannzinza kwabusa amakhosi wawo ngokulandelana kwawo. Namhlanjesi ngibo ababanikazi belimi lesiVenda. &lt;ref&gt;{{Cite web|title=Venda - African Tribe - Venda Culture|url=https://www.krugerpark.co.za/africa_venda.html|access-date=2025-05-26|website=www.krugerpark.co.za}}&lt;/ref&gt;

== IsiTsonga ==
[[Isimumathi:Tsonga_women_in_South_Africa.jpg|thumb|Abomma bambethe isiTsonga]]
IsiTsonga ngelinye lamalimi akhulunywa eSewula Afrika atloliswe ngokomthetho. Ilimeli likhulunywa babantu abangaphezu kweengidi ezilitjhumi nanye. IsiTsonga sikhulunywa  khulukhulu esifundeni seLimpopo neseGauteng, bese kube nesiTsonga esikhulunywa eMozambique. &lt;ref name=&quot;:1&quot; /&gt;

Abantwaba bebasiqhema sabeNguni abathoma lokha uSoshangane ebekuyinduna kaShaka abalekela enarheni yangepumalanga. Bathi nabafika lapho bazakhela umbuso omkhulu nedorhobho elibizwa bona yiGaza. Bfika bahlula izizwe ezinengi abazithola lapho njengesizwe samaNdawu, amaTonga, amaTjopi amaSena nezinye. Ilimi labo lesiNguni lahlangana nesiTonga namalimi walapho laba siTsonga. Ngokukhamba kwesikhathi umbuso lo wahlukana, amanye amaTsonga athuthela ngapha ngendaweni yeSewula Afrika.&lt;ref&gt;{{Cite web|title=Shangaan Tsonga - Nguni People, Tribe - South Africa...|url=https://www.krugerpark.co.za/africa_shangaan_tsonga.html|access-date=2025-05-26|website=www.krugerpark.co.za}}&lt;/ref&gt;

== I-''Afrikaans'' ==
[[Isimumathi:Boer_Family_with_a_wagon_-_false_colour_image.jpg|thumb|AmaBhuru wakade]]
I-Afrikaans namkha isiBhuru lilimi mhlobo welimi lamakhuwa angasiwo wendabuko weSewula Afrika. Nalo litlolisiwe ngokomthetho begodu likhulunywa babantu abangaphezu kweengidi ezimatjhumi amathathu nane. &lt;ref name=&quot;:1&quot; /&gt; I-Afrikaans ikhulunywa khulu eemfundeni zangeTjingalanga Kapa, eGauteng nakezinye iimfunda.

Ilimi le-Afrikaans livela elimini lesiDatjhi. AmaDatjhi afika eSewula Afrika lokha uJan Van Riebeeck obekasebenzela i-VOC (''[https://www.worldhistory.org/Dutch_East_India_Company/ Vereenigde Oost-Indische Compagnie]'') afika nabantu bekhabo ngo-1652, bafika bahlala endaweni abayibiza bona yi-''Cape of Good Hope''. Bafika lapho bahlangana nesitjhaba sabaKhoekhoe. Ngokukhamba kwesikhathi ilimi lesiDatjhi lahlangana nelesiKhoe kunye namanye amalimi kwakheka ilimi namhlanjesi elibizwa ngokuthi yi-Afrikaans namkha isiBhuru, okulilimi elisemthethweni bekube njenganje eSewula Afrika.&lt;ref&gt;{{Cite web|title=The Dutch Settlement {{!}} South African History Online|url=https://www.sahistory.org.za/article/dutch-settlement|access-date=2025-05-26|website=www.sahistory.org.za}}&lt;/ref&gt;&lt;ref&gt;{{Cite web|date=2023-10-13|title=‘The language we know as Afrikaans today owes much to the enslaved people who spoke it’—Read an excerpt from Coloured: How Classification Became Culture|url=https://johannesburgreviewofbooks.com/2023/10/13/the-language-we-know-as-afrikaans-today-owes-much-to-the-enslaved-people-who-spoke-it-read-an-excerpt-from-coloured-how-classification-became-culture/|access-date=2025-05-26|website=The Johannesburg Review of Books|language=en-US}}&lt;/ref&gt;

== IsiNgisi ==
[[Isimumathi:English_settlers_landing_in_Virginia_1607_Image_from_page_42_of_A_junior_class_history_of_the_United_States;_to_which_are_added_the_Declaration_of_independence,_and_the_Constitution_of_the_United_States_(1899).jpg|thumb|AmaNgisi bokufika]]
IsiNgisi kuphela kwelimi elikhulunywa khulu ukudlula woke eSewula Afrika. Sikhulunywa babantu abangaphezu kweengidi ezimatjhumi amathathu nekhomba. Ilimeli ngilo esisetjenziswa khulu emazikweni wezefundo, wezepolotiki, wezeemali, wezamaphilo namanye.

Safika njani isiNgisi eSewula Afrika? IsiNgisi besele sikhona nakufika amaBhuru ngo-1652 ngombana nakufika amaDatjhi athola u-Atjhumato obekayikosi yabaKhoekhoe besele abuya eBantam ngo-1630, akghona ukukhuluma isiNgisi nesiDatjhi. &lt;ref&gt;{{Cite web|title=Autshumao (Herry the Strandloper) {{!}} South African History Online|url=https://www.sahistory.org.za/people/autshumao-herry-strandloper#:~:text=Autshumao%20also%20known%20as%20Herry%20the%20strandloper,who%20were%20engaged%20in%20a%20trading%20relationship.|access-date=2025-05-26|website=www.sahistory.org.za}}&lt;/ref&gt; Nanyana isiNgisi besele sikhulunywa eSewula Afrika, amaNgisi wokufika nokuhlala eza mva kunamaDatjhi. Kwathoma mhlokho bona isiNgisi sikhulunywe eSewula Afrika.

== Ilimi Lezandla ==
Ilimi lezandla ngelinye lamalimi akhulunywa eSewula Afrika. Likhulunywa babantu abangaphesu kwesigidi sinye, begodu kunabantu abama-234,655 okulilimi labo lokuthoma.

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>b4nwxlnq483vydw5rarz91d0rxmvc87</sha1>
    </revision>
    <revision>
      <id>2850</id>
      <parentid>2849</parentid>
      <timestamp>2025-05-26T21:11:24Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>2850</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="17611" sha1="cku1dzkulwd74i8ohupovz21j6cysvn" xml:space="preserve">= Amalimi WeSewula Afrika =
[[Isimumathi:Flag of South Africa.svg|thumb|Iflarha leSewula Afrika]]
'''Inarha yeSewula Afrika''' yinarha enabantu abanamasiko nabaneenzinda ezihlukahlukeneko, nabakhuluma amalimi ahlukahlukeneko. Inengi labantu enarheni le lisesiqhemeni sokuthoma sabantu abakhuluma amalimi angaphasi kwesiNguni, okusiZulu, isiXhosa, [[Isindebele|isiNdebele]] nesiSwati. Bese isiqhema sesibili ngobukhulu ngesikhuluma amalimi wesiSuthu, okusiTswana, isiPedi (okusiSuthu seTlhagwini) nesiSuthu (okusiSuthu seSewula, namkha isiSuthu sesiShweshwe). Bese kunesiqhema esikhuluma isiTsonga nesiqhema esikhuluma isiVenda.&lt;ref&gt;{{Cite web|date=2025-05-14|title=South Africa - Languages, Dialects, Afrikaans {{!}} Britannica|url=https://www.britannica.com/place/South-Africa/Languages|access-date=2025-05-15|website=www.britannica.com|language=en}}&lt;/ref&gt;

Ngaphezu kwamalimi abaliweko la kunamalimi ahlobene nawo. Ngokwesibonelo, esiNdebeleni kunesiNala, nesiNdebele seMoletlane. &lt;ref name=&quot;:0&quot;&gt;{{Cite web|title=Ndebele people, traditions culture|url=https://www.africancraftsmarket.com/african-tribes/ndebele-people.html|access-date=2025-05-15|website=www.africancraftsmarket.com}}&lt;/ref&gt; EsiXhoseni kube nesiNgqika, isiThembu, isiBhaca, isiGcaleka, isiMpondo, isiMpondomise, isiMfengu nesiBomvana.&lt;ref&gt;{{Cite web|title=XHOSA - South African Language Xhosa|url=https://www.sa-venues.com/language-xhosa.htm#:~:text=Xhosa%20has%20been%20grouped%20into,yet%20pretty-sounding,%20language.|access-date=2025-05-15|website=www.sa-venues.com}}&lt;/ref&gt; Kusese nelimi lesiThwa elibandaka isi-Khoe, isi-Tu isi-Kx'a, namanye amalimi.&lt;ref&gt;{{Cite web|title=AFRICA {{!}} 101 Last Tribes - San people|url=https://www.101lasttribes.com/tribes/san.html|access-date=2025-05-15|website=www.101lasttribes.com}}&lt;/ref&gt; Bese isiSwati kunesikhulunywa eManzini, esikhulunywa eShiselweni, nesikhulunywa eHhoho.&lt;ref name=&quot;:2&quot;&gt;{{Cite web|last=web-lingo|date=2013-01-07|title=SA’s Eleven Official Languages: SiSwati|url=https://web-lingo.com/sas-eleven-official-languages-siswati/#:~:text=Swazi%20is%20most%20closely%20related,considered%20closer%20to%20standard%20Swazi.|access-date=2025-05-15|website=Web-lingo|language=en-ZA}}&lt;/ref&gt; IsiPedi naso sinamalinyana angaphasi kwaso anjengesiTlokwa nesiLobedu.&lt;ref&gt;{{Cite web|title=free online course|url=https://www.unisa.ac.za/static/corporate_web/Content/UnisaOpen/freeOnlineCourse/nSotho/nSotho.html#:~:text=Northern%20Sotho%20is%20based%20mainly,(Cf.|access-date=2025-05-15|website=www.unisa.ac.za}}&lt;/ref&gt; Bese kube namalimi angasiwo wendabuko, namkha amalimi wesikhuwa akhulunywako njengesiNgisi nesiBhuru. Woke amalimi la namanye angakabalwa lapha malimi akhulunywa babantu beSewula Afrika.

== Amalimi Asemthethweni ==
Amalimi aseMthethweni eSewula Afrika siNdebele, isiZulu, isiSwati, isiXhosa, isiSuthu, isiPedi, isiTswana, isiVenda, isiTsonga okumalimi wendabuko, bese kuba siBhuru nesiNgisi. Ithebula elingenzasi litjengisa isibalo sabantu abakhuluma amalimi asemthethweni eSewula Afrika namaphesente wabalikhulumako esibalweni sabo boke abantu abahlala eSewula Afrika ngokweembalobalo zango-2022. &lt;ref name=&quot;:1&quot;&gt;https://en.wikipedia.org/wiki/Languages_of_South_Africa#cite_note-EthnologueZA-7&lt;/ref&gt;
{| class=&quot;wikitable sortable mw-collapsible&quot;
|+
! rowspan=&quot;2&quot; |Ilimi
! colspan=&quot;2&quot; |Ilimi lebele&lt;ref name=&quot;:1&quot; /&gt;
! colspan=&quot;2&quot; |Ilimi lesibili&lt;ref name=&quot;:1&quot; /&gt;
! colspan=&quot;2&quot; |Ilimi lesithathu&lt;ref name=&quot;:1&quot; /&gt;
|-
!Isibalo
!Amaphesente
!Isibalo
!Amaphesente
!Isibalo
!Amaphesente
|-
|IsiZulu
|11,587,374
|22.7%
|15,700,000
|30.8%
|27,300,000
|46%
|-
|IsiXhosa
|8,154,258
|16.0%
|11,000,000
|21.6%
|19,150,000
|33%
|-
|IsiVenda
|1,209,388
|2.4%
|1,700,000
|3.3%
|2,910,000
|5%
|-
|IsiTswana
|4,067,248
|8.0%
|7,700,000
|15.1%
|11,770,000
|20%
|-
|IsiTsonga
|2,277,148
|4.5%
|3,400,000
|6.6%
|5,680,000
|10%
|-
|IsiSwati
|1,297,046
|2.5%
|2,400,000
|4.7%
|3,700,000
|6%
|-
|IsiSuthu
|3,849,563
|7.6%
|7,900,000
|15.5%
|11,750,000
|20%
|-
|IsiPedi
|4,618,576
|9.1%
|9,100,000
|17.8%
|13,720,000
|23%
|-
|IsiNdebele
|1,090,223
|2.1%
|1,400,000
|2.7%
|2,490,000
|4%
|-
|IsiNgisi
|4,892,623
|9.6%
|14,000,000
|27.4%
|19,640,000
|33%
|-
|Isi-Afrikaans
|6,855,082
|13.5%
|10,300,000
|20.2%
|17,160,000
|29%
|-
|Ilimi Lezandla le-SA
|234,655
|0.5%
|500,000
|1.0%
|834,655
|1.5%
|-
|Amanye Amalimi
|828,258
|1.6%
|
|
|
|
|-
|'''Isibalo Sisoke'''
|'''50,961,443'''
|'''100.0%'''
|
|
|
|
|}

== IsiNdebele ==
[[Isimumathi:Ndebele_women-1.jpg|thumb|Abomma bamaNdebele]]
IsiNdebele seSewula Afrika ngelinye lamalimi akhulunywa enarheni le. Isizathu sokuthi kuthiwe siNdebele seSewula Afrika kukuthi kunesiNdebele seZimbabwe. &lt;ref&gt;{{Cite web|last=web-lingo|date=2012-10-19|title=Ndebele: What is Ndebele?|url=https://web-lingo.com/ndebele-what-is-ndebele/#:~:text=Northern%20Ndebele,%20or%20Matabele,%20or,nineteenth%20century%20during%20the%20Mfecane.|access-date=2025-05-15|website=Web-lingo|language=en-ZA}}&lt;/ref&gt; Ngokwethebula elingehla, abantu abakhuluma isiNdebele - abasimunyileko, okulilimi lesibili nalabo okulilimi lesithathu kibo - bangaphezu kweengidi ezine. Ilimeli likhulunywa khulukhulu esifundeni seMpumalanga eendaweni ezinjengaKwaNdebele, eMalahleni, e-Middleburg, e-Belfast, kwaDlawulale nakezinye iindawo  njengesiFunda seLimpopo.I siNdebele esisemthethweni siNzunza, kodwana kusese nesiNdebele sakwaManala nesiNdebele seMoletlane. &lt;ref name=&quot;:0&quot; /&gt; AmaNdebele aziwa njengesitjhaba esithanda imibala emihle nekhanyako ongayibona endleleni abambatha ngayo nabenza ngayo imigwalo yabo.

AmaNdebele bekangaphasi kwesiqhema sabaMbo ngaphambi kobana sizijamele ngaphasi kweNgwenyama uNdebele. Ngikho namhlanjesi kunezici ezifanako phakathi kwelimi lesiNdebele nelimi lesiHlubi, isiBhaca, isiMpondo nesiMpondomise.  Ngemva kwesikhathi uNdebele wabeletha uMkhalangana owabeletha umNtungwa. Ngemva kwesikhathi umNtungwa wabeletha uNjonono owabeletha uNjonono. UNjonono wabeletha uNanasi, uNanasi wabeletha uMafana. UMafana wabeletha uMhlanga owabeletha uMusi. Kusesikhathini seNgwenyama uMusi lapha amaNdebele ahlukana khona waba maNzunza namaNala. AmaNdebele akheka ngaleyondlela sele ahlala eSewula Afrika nje. &lt;ref&gt;https://en.wikipedia.org/wiki/Southern_Ndebele_language&lt;/ref&gt;

== IsiSwati ==
[[Isimumathi:Indoni_Parade_2018._Swati_Kingdom_by_Sizwe_Sibiya_(10).jpg|thumb|AmaSwati]]
IsiSwati sikhulunywa eenarheni ezimbili, eSewula Afrika neSwatini. Ngokwethebula elingehla abantu abakhuluma isiSwati eSewula Afrika  bangaphezu kweengidi ezilikhomba.&lt;ref name=&quot;:1&quot; /&gt; KunesiSwati esikhulunywa eSwatini kwaManzini, eShiselweni neHhoho.&lt;ref name=&quot;:2&quot; /&gt; Abantu abakhuluma isiSwati eSwatini babalelwa eengidini ezine. &lt;ref name=&quot;:3&quot;&gt;https://en.wikipedia.org/wiki/Zulu_language&lt;/ref&gt;

AmaSwati bewasiqhenyana esincani sabeNguni ebesaziwa bona Mangwane. Ngokukhamba kwesikhathi isiqhemesi sahlangana nesiqhenyana sabeSuthu ebesihlala endaweni namhlanjesi ebizwa bona kuseSwatini. Ngemva kwalokho bakhula baba sisizwe ngaphasi kweNgwenyama uDlamini III eyathatha iintambo eNgwenyameni uMaseko, yathatha isitjhaba yayosinzinzisa ngasemlanjeni iPongola bahlala eduze namaNdwandwe ngo-1750. UDlamini III walandelwa yiNgwenyama uNgwane III okukholelwa bona nguye owaba yiNgwenyama yokuthoma eyabusa indawo namhlanjesi ebizwa bona kuseSwatini.&lt;ref&gt;https://en.wikipedia.org/wiki/Swazi_people&lt;/ref&gt;

== IsiZulu ==
[[Isimumathi:Zulu_Krieger.jpg|thumb|Abobaba bamaZulu bayagida]]
IsiZulu ngelinye lamalimi adumileko asemthethweni eSewula Afrika elikhulunywa babantu ababgaogezu kweengidi ezimatjhumi amahlanu, kuthi labo abalimunyileko bangaphezu kweengidi ezilitjhumi nanye. &lt;ref name=&quot;:1&quot; /&gt; IsiZulu sikhulunywa khulu KwaZulu Natal, esiFundeni se-Gauteng nakezinye iimfunda.

Umuntu owadlala indima ekulu ekwakhekeni kwesitjhaba samaZulu yiNgwenyama uShaka. UShaka walwa neentjhaba ezincani nezikulu zabeNguni kuhlanganise namaNdwandwe wazihlula. Ngemva kwalokho wazibiza ngoZulu obekangukhokho omkhulu wesitjhaba abelethelwa kiso. Iintjhabezi zahlangana kwavela ilimi lesiZulu.&lt;ref name=&quot;:3&quot; /&gt;
== IsiXhosa ==
[[Isimumathi:Xhosa_traditionally_dressed_women.jpg|thumb|250x250px|Abomma bamaXhosa]]
IsiXhosa naso singelinye lamalimi weSewula Afrika asemthethweni. IsiXhosa sikhulunywa babantu abangaphezu kweengidi ezimatjhumi amathathu nobunane, kuthi labo okulimi labo lokubelethwa bangaphezu kweengidi ezibunane. &lt;ref name=&quot;:1&quot; /&gt; IsiXhosa sikhulunywa khulukhulu esiFundeni seTjingalanga Kapa, eTlhagwini  Kapa nesiFundeni se-Gauteng.&lt;ref&gt;{{Cite web|last=Alexander|first=Mary|date=2025-04-06|title=The languages of South Africa|url=https://southafrica-info.com/arts-culture/11-languages-south-africa/#:~:text=Among%20South%20Africa's%20population%20groups,),%20based%20on%20Census%202022.|access-date=2025-05-23|website=South Africa Gateway|language=en-GB}}&lt;/ref&gt;

Ekadeni bekuneenqhema zabeNguni ezakha ubuhlobo neentjhaba zabaThwa nabaKhoekhoe. Ngokukhamba kwesikhathi iintjhabezi zahlangana zaba sisizwe ngaphasi kokubusa kweNgwenyama uTshawe owahlula isitjhaba samaCirha namaJwarha. Ngemva kwalokho wahlanganisa zoke iintjhaba ezincani kuhlanganise nesabaKhoekhoe. Labeletheka njalo-ke ilimi lesiXhosa.&lt;ref&gt;https://en.wikipedia.org/wiki/Xhosa_people&lt;/ref&gt;

== IsiSuthu ==
[[Isimumathi:Sotho_regalia.jpg|thumb|Abobaba babeSuthu]]
IsiSuthu lilimi elisemthethweni eSewula Afrika elikhunywa babantu abangaphezu kweengidi ezimatjhumi amabili nambili. Okulilmi labo abalimunyileko bangaphezu kweengidi ezintathu. &lt;ref name=&quot;:1&quot; /&gt; IsiSuthu sikhulunywa khulu enarheni yeLesotho, kanti eSewula Afrikapha sikhulunywa khulukhulu esiFundeni seFreestate, seGauteng. Umhlobo lo wesiSuthu ubizwa ngokobana siSuthu seSewula ngombana uhlukaniswa nesiSuthu seTlhagwini - okusiPedi, nesiSuthu seTjingalanga - okusiTswana.

Emandulo abeSuthu beza eSewula Afrika bavela eTlhagwini njengezinye iintjhaba bafika bahlala etlhagwini yeSewula Afrika. Bafika baba ziinqhenyana ezinjengaba-Taung, aba-Sia, aba-Fokeng, ama-Kgolokoe naba-Kwena nezinye iinqenyana. Kuhlekuhle umndeni webukhosini eLesotho mndeni wabaKwena. AbeSuthwaba ngibo-ke ababanikazi belimi lesiSuthu esikhulunywa eSewula Afrika neLesotho.&lt;ref&gt;{{Cite web|title=SOUTHERN SESOTHO - South African Language Southern Sesotho|url=https://www.sa-venues.com/language-southern-sesotho.htm|access-date=2025-05-26|website=www.sa-venues.com}}&lt;/ref&gt;

== IsiTswana ==
[[Isimumathi:Tswana_Dancers_3.jpg|thumb|Isiqhema esigidako sabaTswana]]
IsiTswana nalo ngelinye lamalimi asesiqhemeni sesiSuthu seTjingalanga esikhulunywa eSewula Afrika neBotswana. Abantu abasikhulumako eSewula Afrika bangaphezu kweengidi ezimatjhumi amabili nantathu, abalimunyileko bangaphezu kweengidi ezine.&lt;ref name=&quot;:1&quot; /&gt; isiTswana sikhulunywa khulu enarheni yeBotswana kanti eSewula Afrika sikhulunywa khulu esiFundeni seTlhagwini-Tjhingalanga, neGauteng.

Emandulo abeTswana bebangaphasi kwesiqhema sabeSuthu nabazakufika eSewula Afrika bavela eTlhagwini ne-Afrika. Bafika baba ziinqhenyana ezinjengaba-Taung, aba-Sia, aba-Fokeng, ama-Kgolokoe nabaKwena kunye nezinye iinqhenyana. Bafika endaweni ebizwa ngokobana yiBotswana namhlanjesi, balwa nabaThwa babahlula, bese bakha umbuso wabaTswana. Ngibo-ke namhlanjesi ababanikazi belimi lesiTswana.&lt;ref&gt;{{Cite web|title=AFRICA {{!}} 101 Last Tribes - Tswana people|url=http://www.101lasttribes.com/tribes/tswana.html|access-date=2025-05-26|website=www.101lasttribes.com}}&lt;/ref&gt;

== IsiPedi ==
[[Isimumathi:Pedi_Living_Culture_Route,_Limpopo,_South_Africa_(2417712111).jpg|thumb|Umuzi wesiPedi]]
IsiPedi ([https://www.sahistory.org.za/article/pedi Sepedi]) nalo ngelinye lamalimi angaphasi kwesiSuthu atloliswe ngokomthetho eSewula Afrika, begodu saziwa ngokuthi siSuthu seTlhagwini. &lt;ref name=&quot;:4&quot;&gt;{{Cite web|title=AFRICA {{!}} 101 Last Tribes - Pedi people|url=http://www.101lasttribes.com/tribes/pedi.html|access-date=2025-05-26|website=www.101lasttribes.com}}&lt;/ref&gt; Ilimeli likhulunywa khulukhulu esiFundeni seLimpopo neseGauteng babantu abalinganiswela eengidini ezimatjhumi amabili nekhomba.&lt;ref name=&quot;:1&quot; /&gt;

Ekadeni isiqhemesi besiyingcenye yesiqhema sabeSuthu, kwathi nakukhamba ezinye iinqhema sona sasala ngetlhagwini yeSewula Afrika. Sineenqhenyana ezinengana okucatjangelwa bona sikhuluma amalinyana amatjhumi amathathu. Abanye bathi isiSuthu seTlhagwini akusiso isiPedi kodwana lilimi elihlukileko. &lt;ref name=&quot;:4&quot; /&gt;
== IsiVenda ==
[[Isimumathi:Venda_culture,_Limpopo,_South_Africa_(8714283418).jpg|thumb|251x251px|Izindlu zamaVenda]]
Elinye lamalimi atloliswe ngokomthetho eSewula Afrika siVenda. Abantu abakhuluma isiVenda balinganiselwa eengidini ezihlanu. &lt;ref name=&quot;:1&quot; /&gt; IsiVenda sikhulunywa khulu esiFundeni seLimpopo ngetlhagwini ngitjho nesiFundeni seGauteng. Nawulilemukisisa kuhle ilimeli linezici ezivela elimini lesiShona nelesiTokwa.

Ekadeni isiqhemesi kukholelwa bona sathoma ukuba khona nakusabusa uMpuso weMapungubwe, kwathi nakuwa umbuso lo kuvuka umbuso weZimbabwe sathutha sayokuhlala endaweni namhlanjesi ebizwa ngokobana kuseZimbabwe. Sakhamba isikhathi, isiqhemesi sathutha eZimbabwe sehla seyama umlambo weZambezi sazitholela indawo sayithiya ngokuthi yi-D'zata. Kusukela ngalesosikhathi umbuso wabo uye wannzinza kwabusa amakhosi wawo ngokulandelana kwawo. Namhlanjesi ngibo ababanikazi belimi lesiVenda. &lt;ref&gt;{{Cite web|title=Venda - African Tribe - Venda Culture|url=https://www.krugerpark.co.za/africa_venda.html|access-date=2025-05-26|website=www.krugerpark.co.za}}&lt;/ref&gt;

== IsiTsonga ==
[[Isimumathi:Tsonga_women_in_South_Africa.jpg|thumb|Abomma bambethe isiTsonga]]
IsiTsonga ngelinye lamalimi akhulunywa eSewula Afrika atloliswe ngokomthetho. Ilimeli likhulunywa babantu abangaphezu kweengidi ezilitjhumi nanye. IsiTsonga sikhulunywa  khulukhulu esifundeni seLimpopo neseGauteng, bese kube nesiTsonga esikhulunywa eMozambique. &lt;ref name=&quot;:1&quot; /&gt;

Abantwaba bebasiqhema sabeNguni abathoma lokha uSoshangane ebekuyinduna kaShaka abalekela enarheni yangepumalanga. Bathi nabafika lapho bazakhela umbuso omkhulu nedorhobho elibizwa bona yiGaza. Bfika bahlula izizwe ezinengi abazithola lapho njengesizwe samaNdawu, amaTonga, amaTjopi amaSena nezinye. Ilimi labo lesiNguni lahlangana nesiTonga namalimi walapho laba siTsonga. Ngokukhamba kwesikhathi umbuso lo wahlukana, amanye amaTsonga athuthela ngapha ngendaweni yeSewula Afrika.&lt;ref&gt;{{Cite web|title=Shangaan Tsonga - Nguni People, Tribe - South Africa...|url=https://www.krugerpark.co.za/africa_shangaan_tsonga.html|access-date=2025-05-26|website=www.krugerpark.co.za}}&lt;/ref&gt;

== I-''Afrikaans'' ==
[[Isimumathi:Boer_Family_with_a_wagon_-_false_colour_image.jpg|thumb|AmaBhuru wakade]]
I-Afrikaans namkha isiBhuru lilimi mhlobo welimi lamakhuwa angasiwo wendabuko weSewula Afrika. Nalo litlolisiwe ngokomthetho begodu likhulunywa babantu abangaphezu kweengidi ezimatjhumi amathathu nane. &lt;ref name=&quot;:1&quot; /&gt; I-Afrikaans ikhulunywa khulu eemfundeni zangeTjingalanga Kapa, eGauteng nakezinye iimfunda.

Ilimi le-Afrikaans livela elimini lesiDatjhi. AmaDatjhi afika eSewula Afrika lokha uJan Van Riebeeck obekasebenzela i-VOC (''[https://www.worldhistory.org/Dutch_East_India_Company/ Vereenigde Oost-Indische Compagnie]'') afika nabantu bekhabo ngo-1652, bafika bahlala endaweni abayibiza bona yi-''Cape of Good Hope''. Bafika lapho bahlangana nesitjhaba sabaKhoekhoe. Ngokukhamba kwesikhathi ilimi lesiDatjhi lahlangana nelesiKhoe kunye namanye amalimi kwakheka ilimi namhlanjesi elibizwa ngokuthi yi-Afrikaans namkha isiBhuru, okulilimi elisemthethweni bekube njenganje eSewula Afrika.&lt;ref&gt;{{Cite web|title=The Dutch Settlement {{!}} South African History Online|url=https://www.sahistory.org.za/article/dutch-settlement|access-date=2025-05-26|website=www.sahistory.org.za}}&lt;/ref&gt;&lt;ref&gt;{{Cite web|date=2023-10-13|title=‘The language we know as Afrikaans today owes much to the enslaved people who spoke it’—Read an excerpt from Coloured: How Classification Became Culture|url=https://johannesburgreviewofbooks.com/2023/10/13/the-language-we-know-as-afrikaans-today-owes-much-to-the-enslaved-people-who-spoke-it-read-an-excerpt-from-coloured-how-classification-became-culture/|access-date=2025-05-26|website=The Johannesburg Review of Books|language=en-US}}&lt;/ref&gt;

== IsiNgisi ==
[[Isimumathi:English_settlers_landing_in_Virginia_1607_Image_from_page_42_of_A_junior_class_history_of_the_United_States;_to_which_are_added_the_Declaration_of_independence,_and_the_Constitution_of_the_United_States_(1899).jpg|thumb|AmaNgisi bokufika]]
IsiNgisi kuphela kwelimi elikhulunywa khulu ukudlula woke eSewula Afrika. Sikhulunywa babantu abangaphezu kweengidi ezimatjhumi amathathu nekhomba. Ilimeli ngilo esisetjenziswa khulu emazikweni wezefundo, wezepolotiki, wezeemali, wezamaphilo namanye.

Safika njani isiNgisi eSewula Afrika? IsiNgisi besele sikhona nakufika amaBhuru ngo-1652 ngombana nakufika amaDatjhi athola u-Atjhumato obekayikosi yabaKhoekhoe besele abuya eBantam ngo-1630, akghona ukukhuluma isiNgisi nesiDatjhi. &lt;ref&gt;{{Cite web|title=Autshumao (Herry the Strandloper) {{!}} South African History Online|url=https://www.sahistory.org.za/people/autshumao-herry-strandloper#:~:text=Autshumao%20also%20known%20as%20Herry%20the%20strandloper,who%20were%20engaged%20in%20a%20trading%20relationship.|access-date=2025-05-26|website=www.sahistory.org.za}}&lt;/ref&gt; Nanyana isiNgisi besele sikhulunywa eSewula Afrika, amaNgisi wokufika nokuhlala eza mva kunamaDatjhi. Kwathoma mhlokho bona isiNgisi sikhulunywe eSewula Afrika.

== Ilimi Lezandla ==
Ilimi lezandla ngelinye lamalimi akhulunywa eSewula Afrika. Likhulunywa babantu abangaphesu kwesigidi sinye, begodu kunabantu abama-234,655 okulilimi labo lokuthoma.

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>cku1dzkulwd74i8ohupovz21j6cysvn</sha1>
    </revision>
    <revision>
      <id>2882</id>
      <parentid>2850</parentid>
      <timestamp>2025-06-01T18:13:20Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>spelling</comment>
      <origin>2882</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="17591" sha1="pi38qecnk7q7g9nu1jotpy4a4id0lfq" xml:space="preserve">= Amalimi WeSewula Afrika =
[[Isimumathi:Flag of South Africa.svg|thumb|Iflarha leSewula Afrika]]
'''Inarha yeSewula Afrika''' yinarha enabantu abanamasiko nabaneenzinda ezihlukahlukeneko, nabakhuluma amalimi ahlukahlukeneko. Inengi labantu enarheni le lisesiqhemeni sokuthoma sabantu abakhuluma amalimi angaphasi kwesiNguni, okusiZulu, isiXhosa, [[Isindebele|isiNdebele]] nesiSwati. Bese isiqhema sesibili ngobukhulu ngesikhuluma amalimi wesiSuthu, okusiTswana, isiPedi (okusiSuthu seTlhagwini) nesiSuthu (okusiSuthu seSewula, namkha isiSuthu sesiShweshwe). Bese kunesiqhema esikhuluma isiTsonga nesiqhema esikhuluma isiVenda.&lt;ref&gt;{{Cite web|date=2025-05-14|title=South Africa - Languages, Dialects, Afrikaans {{!}} Britannica|url=https://www.britannica.com/place/South-Africa/Languages|access-date=2025-05-15|website=www.britannica.com|language=en}}&lt;/ref&gt;

Ngaphezu kwamalimi abaliweko la kunamalimi ahlobene nawo. Ngokwesibonelo, esiNdebeleni kunesiNala, nesiNdebele seMoletlane. &lt;ref name=&quot;:0&quot;&gt;{{Cite web|title=Ndebele people, traditions culture|url=https://www.africancraftsmarket.com/african-tribes/ndebele-people.html|access-date=2025-05-15|website=www.africancraftsmarket.com}}&lt;/ref&gt; EsiXhoseni kube nesiNgqika, isiThembu, isiBhaca, isiGcaleka, isiMpondo, isiMpondomise, isiMfengu nesiBomvana.&lt;ref&gt;{{Cite web|title=XHOSA - South African Language Xhosa|url=https://www.sa-venues.com/language-xhosa.htm#:~:text=Xhosa%20has%20been%20grouped%20into,yet%20pretty-sounding,%20language.|access-date=2025-05-15|website=www.sa-venues.com}}&lt;/ref&gt; Kusese nelimi lesiThwa elibandaka isi-Khoe, isi-Tu isi-Kx'a, namanye amalimi.&lt;ref&gt;{{Cite web|title=AFRICA {{!}} 101 Last Tribes - San people|url=https://www.101lasttribes.com/tribes/san.html|access-date=2025-05-15|website=www.101lasttribes.com}}&lt;/ref&gt; Bese isiSwati kunesikhulunywa eManzini, esikhulunywa eShiselweni, nesikhulunywa eHhoho.&lt;ref name=&quot;:2&quot;&gt;{{Cite web|last=web-lingo|date=2013-01-07|title=SA’s Eleven Official Languages: SiSwati|url=https://web-lingo.com/sas-eleven-official-languages-siswati/#:~:text=Swazi%20is%20most%20closely%20related,considered%20closer%20to%20standard%20Swazi.|access-date=2025-05-15|website=Web-lingo|language=en-ZA}}&lt;/ref&gt; IsiPedi naso sinamalinyana angaphasi kwaso anjengesiTlokwa nesiLobedu.&lt;ref&gt;{{Cite web|title=free online course|url=https://www.unisa.ac.za/static/corporate_web/Content/UnisaOpen/freeOnlineCourse/nSotho/nSotho.html#:~:text=Northern%20Sotho%20is%20based%20mainly,(Cf.|access-date=2025-05-15|website=www.unisa.ac.za}}&lt;/ref&gt; Bese kube namalimi angasiwo wendabuko, namkha amalimi wesikhuwa akhulunywako njengesiNgisi nesiBhuru. Woke amalimi la namanye angakabalwa lapha malimi akhulunywa babantu beSewula Afrika.

== Amalimi Asemthethweni ==
Amalimi aseMthethweni eSewula Afrika siNdebele, isiZulu, isiSwati, isiXhosa, isiSuthu, isiPedi, isiTswana, isiVenda, isiTsonga okumalimi wendabuko, bese kuba siBhuru nesiNgisi. Ithebula elingenzasi litjengisa isibalo sabantu abakhuluma amalimi asemthethweni eSewula Afrika namaphesente wabalikhulumako esibalweni sabo boke abantu abahlala eSewula Afrika ngokweembalobalo zango-2022. &lt;ref name=&quot;:1&quot;&gt;https://en.wikipedia.org/wiki/Languages_of_South_Africa#cite_note-EthnologueZA-7&lt;/ref&gt;
{| class=&quot;wikitable sortable mw-collapsible&quot;
|+
! rowspan=&quot;2&quot; |Ilimi
! colspan=&quot;2&quot; |Ilimi lebele&lt;ref name=&quot;:1&quot; /&gt;
! colspan=&quot;2&quot; |Ilimi lesibili&lt;ref name=&quot;:1&quot; /&gt;
! colspan=&quot;2&quot; |Ilimi lesithathu&lt;ref name=&quot;:1&quot; /&gt;
|-
!Isibalo
!Amaphesente
!Isibalo
!Amaphesente
!Isibalo
!Amaphesente
|-
|IsiZulu
|11,587,374
|22.7%
|15,700,000
|30.8%
|27,300,000
|46%
|-
|IsiXhosa
|8,154,258
|16.0%
|11,000,000
|21.6%
|19,150,000
|33%
|-
|IsiVenda
|1,209,388
|2.4%
|1,700,000
|3.3%
|2,910,000
|5%
|-
|IsiTswana
|4,067,248
|8.0%
|7,700,000
|15.1%
|11,770,000
|20%
|-
|IsiTsonga
|2,277,148
|4.5%
|3,400,000
|6.6%
|5,680,000
|10%
|-
|IsiSwati
|1,297,046
|2.5%
|2,400,000
|4.7%
|3,700,000
|6%
|-
|IsiSuthu
|3,849,563
|7.6%
|7,900,000
|15.5%
|11,750,000
|20%
|-
|IsiPedi
|4,618,576
|9.1%
|9,100,000
|17.8%
|13,720,000
|23%
|-
|IsiNdebele
|1,090,223
|2.1%
|1,400,000
|2.7%
|2,490,000
|4%
|-
|IsiNgisi
|4,892,623
|9.6%
|14,000,000
|27.4%
|19,640,000
|33%
|-
|Isi-Afrikaans
|6,855,082
|13.5%
|10,300,000
|20.2%
|17,160,000
|29%
|-
|Ilimi Lezandla le-SA
|234,655
|0.5%
|500,000
|1.0%
|834,655
|1.5%
|-
|Amanye Amalimi
|828,258
|1.6%
|
|
|
|
|-
|'''Isibalo Sisoke'''
|'''50,961,443'''
|'''100.0%'''
|
|
|
|
|}

== IsiNdebele ==
[[Isimumathi:Ndebele_women-1.jpg|thumb|Abomma bamaNdebele]]
IsiNdebele seSewula Afrika ngelinye lamalimi akhulunywa enarheni le. Isizathu sokuthi kuthiwe siNdebele seSewula Afrika kukuthi kunesiNdebele seZimbabwe. &lt;ref&gt;{{Cite web|last=web-lingo|date=2012-10-19|title=Ndebele: What is Ndebele?|url=https://web-lingo.com/ndebele-what-is-ndebele/#:~:text=Northern%20Ndebele,%20or%20Matabele,%20or,nineteenth%20century%20during%20the%20Mfecane.|access-date=2025-05-15|website=Web-lingo|language=en-ZA}}&lt;/ref&gt; Ngokwethebula elingehla, abantu abakhuluma isiNdebele - abasimunyileko, okulilimi lesibili nalabo okulilimi lesithathu kibo - bangaphezu kweengidi ezine. Ilimeli likhulunywa khulukhulu esifundeni seMpumalanga eendaweni ezinjengaKwaNdebele, eMalahleni, e-Middleburg, e-Belfast, kwaDlawulale nakezinye iindawo  njengesiFunda seLimpopo.I siNdebele esisemthethweni siNzunza, kodwana kusese nesiNdebele sakwaManala nesiNdebele seMoletlane. &lt;ref name=&quot;:0&quot; /&gt; AmaNdebele aziwa njengesitjhaba esithanda imibala emihle nekhanyako ongayibona endleleni abambatha ngayo nabenza ngayo imigwalo yabo.

AmaNdebele bekangaphasi kwesiqhema sabaMbo ngaphambi kobana sizijamele ngaphasi kweNgwenyama uNdebele. Ngikho namhlanjesi kunezici ezifanako phakathi kwelimi lesiNdebele nelimi lesiHlubi, isiBhaca, isiMpondo nesiMpondomise.  Ngemva kwesikhathi uNdebele wabeletha uMkhalangana owabeletha umNtungwa. Ngemva kwesikhathi umNtungwa wabeletha uNjonono. UNjonono wabeletha uNanasi, uNanasi wabeletha uMafana. UMafana wabeletha uMhlanga owabeletha uMusi. Kusesikhathini seNgwenyama uMusi lapha amaNdebele ahlukana khona waba maNzunza namaNala. AmaNdebele akheka ngaleyondlela sele ahlala eSewula Afrika nje. &lt;ref&gt;https://en.wikipedia.org/wiki/Southern_Ndebele_language&lt;/ref&gt;

== IsiSwati ==
[[Isimumathi:Indoni_Parade_2018._Swati_Kingdom_by_Sizwe_Sibiya_(10).jpg|thumb|AmaSwati]]
IsiSwati sikhulunywa eenarheni ezimbili, eSewula Afrika neSwatini. Ngokwethebula elingehla abantu abakhuluma isiSwati eSewula Afrika  bangaphezu kweengidi ezilikhomba.&lt;ref name=&quot;:1&quot; /&gt; KunesiSwati esikhulunywa eSwatini kwaManzini, eShiselweni neHhoho.&lt;ref name=&quot;:2&quot; /&gt; Abantu abakhuluma isiSwati eSwatini babalelwa eengidini ezine. &lt;ref name=&quot;:3&quot;&gt;https://en.wikipedia.org/wiki/Zulu_language&lt;/ref&gt;

AmaSwati bewasiqhenyana esincani sabeNguni ebesaziwa bona Mangwane. Ngokukhamba kwesikhathi isiqhemesi sahlangana nesiqhenyana sabeSuthu ebesihlala endaweni namhlanjesi ebizwa bona kuseSwatini. Ngemva kwalokho bakhula baba sisizwe ngaphasi kweNgwenyama uDlamini III eyathatha iintambo eNgwenyameni uMaseko, yathatha isitjhaba yayosinzinzisa ngasemlanjeni iPongola bahlala eduze namaNdwandwe ngo-1750. UDlamini III walandelwa yiNgwenyama uNgwane III okukholelwa bona nguye owaba yiNgwenyama yokuthoma eyabusa indawo namhlanjesi ebizwa bona kuseSwatini.&lt;ref&gt;https://en.wikipedia.org/wiki/Swazi_people&lt;/ref&gt;

== IsiZulu ==
[[Isimumathi:Zulu_Krieger.jpg|thumb|Abobaba bamaZulu bayagida]]
IsiZulu ngelinye lamalimi adumileko asemthethweni eSewula Afrika elikhulunywa babantu ababgaogezu kweengidi ezimatjhumi amahlanu, kuthi labo abalimunyileko bangaphezu kweengidi ezilitjhumi nanye. &lt;ref name=&quot;:1&quot; /&gt; IsiZulu sikhulunywa khulu KwaZulu Natal, esiFundeni se-Gauteng nakezinye iimfunda.

Umuntu owadlala indima ekulu ekwakhekeni kwesitjhaba samaZulu yiNgwenyama uShaka. UShaka walwa neentjhaba ezincani nezikulu zabeNguni kuhlanganise namaNdwandwe wazihlula. Ngemva kwalokho wazibiza ngoZulu obekangukhokho omkhulu wesitjhaba abelethelwa kiso. Iintjhabezi zahlangana kwavela ilimi lesiZulu.&lt;ref name=&quot;:3&quot; /&gt;
== IsiXhosa ==
[[Isimumathi:Xhosa_traditionally_dressed_women.jpg|thumb|250x250px|Abomma bamaXhosa]]
IsiXhosa naso singelinye lamalimi weSewula Afrika asemthethweni. IsiXhosa sikhulunywa babantu abangaphezu kweengidi ezimatjhumi amathathu nobunane, kuthi labo okulimi labo lokubelethwa bangaphezu kweengidi ezibunane. &lt;ref name=&quot;:1&quot; /&gt; IsiXhosa sikhulunywa khulukhulu esiFundeni seTjingalanga Kapa, eTlhagwini  Kapa nesiFundeni se-Gauteng.&lt;ref&gt;{{Cite web|last=Alexander|first=Mary|date=2025-04-06|title=The languages of South Africa|url=https://southafrica-info.com/arts-culture/11-languages-south-africa/#:~:text=Among%20South%20Africa's%20population%20groups,),%20based%20on%20Census%202022.|access-date=2025-05-23|website=South Africa Gateway|language=en-GB}}&lt;/ref&gt;

Ekadeni bekuneenqhema zabeNguni ezakha ubuhlobo neentjhaba zabaThwa nabaKhoekhoe. Ngokukhamba kwesikhathi iintjhabezi zahlangana zaba sisizwe ngaphasi kokubusa kweNgwenyama uTshawe owahlula isitjhaba samaCirha namaJwarha. Ngemva kwalokho wahlanganisa zoke iintjhaba ezincani kuhlanganise nesabaKhoekhoe. Labeletheka njalo-ke ilimi lesiXhosa.&lt;ref&gt;https://en.wikipedia.org/wiki/Xhosa_people&lt;/ref&gt;

== IsiSuthu ==
[[Isimumathi:Sotho_regalia.jpg|thumb|Abobaba babeSuthu]]
IsiSuthu lilimi elisemthethweni eSewula Afrika elikhunywa babantu abangaphezu kweengidi ezimatjhumi amabili nambili. Okulilmi labo abalimunyileko bangaphezu kweengidi ezintathu. &lt;ref name=&quot;:1&quot; /&gt; IsiSuthu sikhulunywa khulu enarheni yeLesotho, kanti eSewula Afrikapha sikhulunywa khulukhulu esiFundeni seFreestate, seGauteng. Umhlobo lo wesiSuthu ubizwa ngokobana siSuthu seSewula ngombana uhlukaniswa nesiSuthu seTlhagwini - okusiPedi, nesiSuthu seTjingalanga - okusiTswana.

Emandulo abeSuthu beza eSewula Afrika bavela eTlhagwini njengezinye iintjhaba bafika bahlala etlhagwini yeSewula Afrika. Bafika baba ziinqhenyana ezinjengaba-Taung, aba-Sia, aba-Fokeng, ama-Kgolokoe naba-Kwena nezinye iinqenyana. Kuhlekuhle umndeni webukhosini eLesotho mndeni wabaKwena. AbeSuthwaba ngibo-ke ababanikazi belimi lesiSuthu esikhulunywa eSewula Afrika neLesotho.&lt;ref&gt;{{Cite web|title=SOUTHERN SESOTHO - South African Language Southern Sesotho|url=https://www.sa-venues.com/language-southern-sesotho.htm|access-date=2025-05-26|website=www.sa-venues.com}}&lt;/ref&gt;

== IsiTswana ==
[[Isimumathi:Tswana_Dancers_3.jpg|thumb|Isiqhema esigidako sabaTswana]]
IsiTswana nalo ngelinye lamalimi asesiqhemeni sesiSuthu seTjingalanga esikhulunywa eSewula Afrika neBotswana. Abantu abasikhulumako eSewula Afrika bangaphezu kweengidi ezimatjhumi amabili nantathu, abalimunyileko bangaphezu kweengidi ezine.&lt;ref name=&quot;:1&quot; /&gt; isiTswana sikhulunywa khulu enarheni yeBotswana kanti eSewula Afrika sikhulunywa khulu esiFundeni seTlhagwini-Tjhingalanga, neGauteng.

Emandulo abeTswana bebangaphasi kwesiqhema sabeSuthu nabazakufika eSewula Afrika bavela eTlhagwini ne-Afrika. Bafika baba ziinqhenyana ezinjengaba-Taung, aba-Sia, aba-Fokeng, ama-Kgolokoe nabaKwena kunye nezinye iinqhenyana. Bafika endaweni ebizwa ngokobana yiBotswana namhlanjesi, balwa nabaThwa babahlula, bese bakha umbuso wabaTswana. Ngibo-ke namhlanjesi ababanikazi belimi lesiTswana.&lt;ref&gt;{{Cite web|title=AFRICA {{!}} 101 Last Tribes - Tswana people|url=http://www.101lasttribes.com/tribes/tswana.html|access-date=2025-05-26|website=www.101lasttribes.com}}&lt;/ref&gt;

== IsiPedi ==
[[Isimumathi:Pedi_Living_Culture_Route,_Limpopo,_South_Africa_(2417712111).jpg|thumb|Umuzi wesiPedi]]
IsiPedi ([https://www.sahistory.org.za/article/pedi Sepedi]) nalo ngelinye lamalimi angaphasi kwesiSuthu atloliswe ngokomthetho eSewula Afrika, begodu saziwa ngokuthi siSuthu seTlhagwini. &lt;ref name=&quot;:4&quot;&gt;{{Cite web|title=AFRICA {{!}} 101 Last Tribes - Pedi people|url=http://www.101lasttribes.com/tribes/pedi.html|access-date=2025-05-26|website=www.101lasttribes.com}}&lt;/ref&gt; Ilimeli likhulunywa khulukhulu esiFundeni seLimpopo neseGauteng babantu abalinganiswela eengidini ezimatjhumi amabili nekhomba.&lt;ref name=&quot;:1&quot; /&gt;

Ekadeni isiqhemesi besiyingcenye yesiqhema sabeSuthu, kwathi nakukhamba ezinye iinqhema sona sasala ngetlhagwini yeSewula Afrika. Sineenqhenyana ezinengana okucatjangelwa bona sikhuluma amalinyana amatjhumi amathathu. Abanye bathi isiSuthu seTlhagwini akusiso isiPedi kodwana lilimi elihlukileko. &lt;ref name=&quot;:4&quot; /&gt;
== IsiVenda ==
[[Isimumathi:Venda_culture,_Limpopo,_South_Africa_(8714283418).jpg|thumb|251x251px|Izindlu zamaVenda]]
Elinye lamalimi atloliswe ngokomthetho eSewula Afrika siVenda. Abantu abakhuluma isiVenda balinganiselwa eengidini ezihlanu. &lt;ref name=&quot;:1&quot; /&gt; IsiVenda sikhulunywa khulu esiFundeni seLimpopo ngetlhagwini ngitjho nesiFundeni seGauteng. Nawulilemukisisa kuhle ilimeli linezici ezivela elimini lesiShona nelesiTokwa.

Ekadeni isiqhemesi kukholelwa bona sathoma ukuba khona nakusabusa uMpuso weMapungubwe, kwathi nakuwa umbuso lo kuvuka umbuso weZimbabwe sathutha sayokuhlala endaweni namhlanjesi ebizwa ngokobana kuseZimbabwe. Sakhamba isikhathi, isiqhemesi sathutha eZimbabwe sehla seyama umlambo weZambezi sazitholela indawo sayithiya ngokuthi yi-D'zata. Kusukela ngalesosikhathi umbuso wabo uye wannzinza kwabusa amakhosi wawo ngokulandelana kwawo. Namhlanjesi ngibo ababanikazi belimi lesiVenda. &lt;ref&gt;{{Cite web|title=Venda - African Tribe - Venda Culture|url=https://www.krugerpark.co.za/africa_venda.html|access-date=2025-05-26|website=www.krugerpark.co.za}}&lt;/ref&gt;

== IsiTsonga ==
[[Isimumathi:Tsonga_women_in_South_Africa.jpg|thumb|Abomma bambethe isiTsonga]]
IsiTsonga ngelinye lamalimi akhulunywa eSewula Afrika atloliswe ngokomthetho. Ilimeli likhulunywa babantu abangaphezu kweengidi ezilitjhumi nanye. IsiTsonga sikhulunywa  khulukhulu esifundeni seLimpopo neseGauteng, bese kube nesiTsonga esikhulunywa eMozambique. &lt;ref name=&quot;:1&quot; /&gt;

Abantwaba bebasiqhema sabeNguni abathoma lokha uSoshangane ebekuyinduna kaShaka abalekela enarheni yangepumalanga. Bathi nabafika lapho bazakhela umbuso omkhulu nedorhobho elibizwa bona yiGaza. Bfika bahlula izizwe ezinengi abazithola lapho njengesizwe samaNdawu, amaTonga, amaTjopi amaSena nezinye. Ilimi labo lesiNguni lahlangana nesiTonga namalimi walapho laba siTsonga. Ngokukhamba kwesikhathi umbuso lo wahlukana, amanye amaTsonga athuthela ngapha ngendaweni yeSewula Afrika.&lt;ref&gt;{{Cite web|title=Shangaan Tsonga - Nguni People, Tribe - South Africa...|url=https://www.krugerpark.co.za/africa_shangaan_tsonga.html|access-date=2025-05-26|website=www.krugerpark.co.za}}&lt;/ref&gt;

== I-''Afrikaans'' ==
[[Isimumathi:Boer_Family_with_a_wagon_-_false_colour_image.jpg|thumb|AmaBhuru wakade]]
I-Afrikaans namkha isiBhuru lilimi mhlobo welimi lamakhuwa angasiwo wendabuko weSewula Afrika. Nalo litlolisiwe ngokomthetho begodu likhulunywa babantu abangaphezu kweengidi ezimatjhumi amathathu nane. &lt;ref name=&quot;:1&quot; /&gt; I-Afrikaans ikhulunywa khulu eemfundeni zangeTjingalanga Kapa, eGauteng nakezinye iimfunda.

Ilimi le-Afrikaans livela elimini lesiDatjhi. AmaDatjhi afika eSewula Afrika lokha uJan Van Riebeeck obekasebenzela i-VOC (''[https://www.worldhistory.org/Dutch_East_India_Company/ Vereenigde Oost-Indische Compagnie]'') afika nabantu bekhabo ngo-1652, bafika bahlala endaweni abayibiza bona yi-''Cape of Good Hope''. Bafika lapho bahlangana nesitjhaba sabaKhoekhoe. Ngokukhamba kwesikhathi ilimi lesiDatjhi lahlangana nelesiKhoe kunye namanye amalimi kwakheka ilimi namhlanjesi elibizwa ngokuthi yi-Afrikaans namkha isiBhuru, okulilimi elisemthethweni bekube njenganje eSewula Afrika.&lt;ref&gt;{{Cite web|title=The Dutch Settlement {{!}} South African History Online|url=https://www.sahistory.org.za/article/dutch-settlement|access-date=2025-05-26|website=www.sahistory.org.za}}&lt;/ref&gt;&lt;ref&gt;{{Cite web|date=2023-10-13|title=‘The language we know as Afrikaans today owes much to the enslaved people who spoke it’—Read an excerpt from Coloured: How Classification Became Culture|url=https://johannesburgreviewofbooks.com/2023/10/13/the-language-we-know-as-afrikaans-today-owes-much-to-the-enslaved-people-who-spoke-it-read-an-excerpt-from-coloured-how-classification-became-culture/|access-date=2025-05-26|website=The Johannesburg Review of Books|language=en-US}}&lt;/ref&gt;

== IsiNgisi ==
[[Isimumathi:English_settlers_landing_in_Virginia_1607_Image_from_page_42_of_A_junior_class_history_of_the_United_States;_to_which_are_added_the_Declaration_of_independence,_and_the_Constitution_of_the_United_States_(1899).jpg|thumb|AmaNgisi bokufika]]
IsiNgisi kuphela kwelimi elikhulunywa khulu ukudlula woke eSewula Afrika. Sikhulunywa babantu abangaphezu kweengidi ezimatjhumi amathathu nekhomba. Ilimeli ngilo esisetjenziswa khulu emazikweni wezefundo, wezepolotiki, wezeemali, wezamaphilo namanye.

Safika njani isiNgisi eSewula Afrika? IsiNgisi besele sikhona nakufika amaBhuru ngo-1652 ngombana nakufika amaDatjhi athola u-Atjhumato obekayikosi yabaKhoekhoe besele abuya eBantam ngo-1630, akghona ukukhuluma isiNgisi nesiDatjhi. &lt;ref&gt;{{Cite web|title=Autshumao (Herry the Strandloper) {{!}} South African History Online|url=https://www.sahistory.org.za/people/autshumao-herry-strandloper#:~:text=Autshumao%20also%20known%20as%20Herry%20the%20strandloper,who%20were%20engaged%20in%20a%20trading%20relationship.|access-date=2025-05-26|website=www.sahistory.org.za}}&lt;/ref&gt; Nanyana isiNgisi besele sikhulunywa eSewula Afrika, amaNgisi wokufika nokuhlala eza mva kunamaDatjhi. Kwathoma mhlokho bona isiNgisi sikhulunywe eSewula Afrika.

== Ilimi Lezandla ==
Ilimi lezandla ngelinye lamalimi akhulunywa eSewula Afrika. Likhulunywa babantu abangaphesu kwesigidi sinye, begodu kunabantu abama-234,655 okulilimi labo lokuthoma.

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>pi38qecnk7q7g9nu1jotpy4a4id0lfq</sha1>
    </revision>
    <revision>
      <id>2883</id>
      <parentid>2882</parentid>
      <timestamp>2025-06-01T18:16:18Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>spelling</comment>
      <origin>2883</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="17584" sha1="59jw7z31jw471yofda9qazmm0pf3n2o" xml:space="preserve">= Amalimi WeSewula Afrika =
[[Isimumathi:Flag of South Africa.svg|thumb|Iflarha leSewula Afrika]]
'''Inarha yeSewula Afrika''' yinarha enabantu abanamasiko nabaneenzinda ezihlukahlukeneko, nabakhuluma amalimi ahlukahlukeneko. Inengi labantu enarheni le lisesiqhemeni sokuthoma sabantu abakhuluma amalimi angaphasi kwesiNguni, okusiZulu, isiXhosa, [[Isindebele|isiNdebele]] nesiSwati. Bese isiqhema sesibili ngobukhulu ngesikhuluma amalimi wesiSuthu, okusiTswana, isiPedi (okusiSuthu seTlhagwini) nesiSuthu (okusiSuthu seSewula, namkha isiSuthu sesiShweshwe). Bese kunesiqhema esikhuluma isiTsonga nesiqhema esikhuluma isiVenda.&lt;ref&gt;{{Cite web|date=2025-05-14|title=South Africa - Languages, Dialects, Afrikaans {{!}} Britannica|url=https://www.britannica.com/place/South-Africa/Languages|access-date=2025-05-15|website=www.britannica.com|language=en}}&lt;/ref&gt;

Ngaphezu kwamalimi abaliweko la kunamalimi ahlobene nawo. Ngokwesibonelo, esiNdebeleni kunesiNala, nesiNdebele seMoletlane. &lt;ref name=&quot;:0&quot;&gt;{{Cite web|title=Ndebele people, traditions culture|url=https://www.africancraftsmarket.com/african-tribes/ndebele-people.html|access-date=2025-05-15|website=www.africancraftsmarket.com}}&lt;/ref&gt; EsiXhoseni kube nesiNgqika, isiThembu, isiBhaca, isiGcaleka, isiMpondo, isiMpondomise, isiMfengu nesiBomvana.&lt;ref&gt;{{Cite web|title=XHOSA - South African Language Xhosa|url=https://www.sa-venues.com/language-xhosa.htm#:~:text=Xhosa%20has%20been%20grouped%20into,yet%20pretty-sounding,%20language.|access-date=2025-05-15|website=www.sa-venues.com}}&lt;/ref&gt; Kusese nelimi lesiThwa elibandaka isi-Khoe, isi-Tu isi-Kx'a, namanye amalimi.&lt;ref&gt;{{Cite web|title=AFRICA {{!}} 101 Last Tribes - San people|url=https://www.101lasttribes.com/tribes/san.html|access-date=2025-05-15|website=www.101lasttribes.com}}&lt;/ref&gt; Bese isiSwati kunesikhulunywa eManzini, esikhulunywa eShiselweni, nesikhulunywa eHhoho.&lt;ref name=&quot;:2&quot;&gt;{{Cite web|last=web-lingo|date=2013-01-07|title=SA’s Eleven Official Languages: SiSwati|url=https://web-lingo.com/sas-eleven-official-languages-siswati/#:~:text=Swazi%20is%20most%20closely%20related,considered%20closer%20to%20standard%20Swazi.|access-date=2025-05-15|website=Web-lingo|language=en-ZA}}&lt;/ref&gt; IsiPedi naso sinamalinyana angaphasi kwaso anjengesiTlokwa nesiLobedu.&lt;ref&gt;{{Cite web|title=free online course|url=https://www.unisa.ac.za/static/corporate_web/Content/UnisaOpen/freeOnlineCourse/nSotho/nSotho.html#:~:text=Northern%20Sotho%20is%20based%20mainly,(Cf.|access-date=2025-05-15|website=www.unisa.ac.za}}&lt;/ref&gt; Bese kube namalimi angasiwo wendabuko, namkha amalimi wesikhuwa akhulunywako njengesiNgisi nesiBhuru. Woke amalimi la namanye angakabalwa lapha malimi akhulunywa babantu beSewula Afrika.

== Amalimi Asemthethweni ==
Amalimi aseMthethweni eSewula Afrika siNdebele, isiZulu, isiSwati, isiXhosa, isiSuthu, isiPedi, isiTswana, isiVenda, isiTsonga okumalimi wendabuko, bese kuba siBhuru nesiNgisi. Ithebula elingenzasi litjengisa isibalo sabantu abakhuluma amalimi asemthethweni eSewula Afrika namaphesente wabalikhulumako esibalweni sabo boke abantu abahlala eSewula Afrika ngokweembalobalo zango-2022. &lt;ref name=&quot;:1&quot;&gt;https://en.wikipedia.org/wiki/Languages_of_South_Africa#cite_note-EthnologueZA-7&lt;/ref&gt;
{| class=&quot;wikitable sortable mw-collapsible&quot;
|+
! rowspan=&quot;2&quot; |Ilimi
! colspan=&quot;2&quot; |Ilimi lebele&lt;ref name=&quot;:1&quot; /&gt;
! colspan=&quot;2&quot; |Ilimi lesibili&lt;ref name=&quot;:1&quot; /&gt;
! colspan=&quot;2&quot; |Ilimi lesithathu&lt;ref name=&quot;:1&quot; /&gt;
|-
!Isibalo
!Amaphesente
!Isibalo
!Amaphesente
!Isibalo
!Amaphesente
|-
|IsiZulu
|11,587,374
|22.7%
|15,700,000
|30.8%
|27,300,000
|46%
|-
|IsiXhosa
|8,154,258
|16.0%
|11,000,000
|21.6%
|19,150,000
|33%
|-
|IsiVenda
|1,209,388
|2.4%
|1,700,000
|3.3%
|2,910,000
|5%
|-
|IsiTswana
|4,067,248
|8.0%
|7,700,000
|15.1%
|11,770,000
|20%
|-
|IsiTsonga
|2,277,148
|4.5%
|3,400,000
|6.6%
|5,680,000
|10%
|-
|IsiSwati
|1,297,046
|2.5%
|2,400,000
|4.7%
|3,700,000
|6%
|-
|IsiSuthu
|3,849,563
|7.6%
|7,900,000
|15.5%
|11,750,000
|20%
|-
|IsiPedi
|4,618,576
|9.1%
|9,100,000
|17.8%
|13,720,000
|23%
|-
|IsiNdebele
|1,090,223
|2.1%
|1,400,000
|2.7%
|2,490,000
|4%
|-
|IsiNgisi
|4,892,623
|9.6%
|14,000,000
|27.4%
|19,640,000
|33%
|-
|Isi-Afrikaans
|6,855,082
|13.5%
|10,300,000
|20.2%
|17,160,000
|29%
|-
|Ilimi Lezandla le-SA
|234,655
|0.5%
|500,000
|1.0%
|834,655
|1.5%
|-
|Amanye Amalimi
|828,258
|1.6%
|
|
|
|
|-
|'''Isibalo Sisoke'''
|'''50,961,443'''
|'''100.0%'''
|
|
|
|
|}

== IsiNdebele ==
[[Isimumathi:Ndebele_women-1.jpg|thumb|Abomma bamaNdebele]]
IsiNdebele seSewula Afrika ngelinye lamalimi akhulunywa enarheni le. Isizathu sokuthi kuthiwe siNdebele seSewula Afrika kukuthi kunesiNdebele seZimbabwe. &lt;ref&gt;{{Cite web|last=web-lingo|date=2012-10-19|title=Ndebele: What is Ndebele?|url=https://web-lingo.com/ndebele-what-is-ndebele/#:~:text=Northern%20Ndebele,%20or%20Matabele,%20or,nineteenth%20century%20during%20the%20Mfecane.|access-date=2025-05-15|website=Web-lingo|language=en-ZA}}&lt;/ref&gt; Ngokwethebula elingehla, abantu abakhuluma isiNdebele - abasimunyileko, okulilimi lesibili nalabo okulilimi lesithathu kibo - bangaphezu kweengidi ezine. Ilimeli likhulunywa khulukhulu esifundeni seMpumalanga eendaweni ezinjengaKwaNdebele, eMalahleni, e-Middleburg, e-Belfast, kwaDlawulale nakezinye iindawo  njengesiFunda seLimpopo.I siNdebele esisemthethweni siNzunza, kodwana kusese nesiNdebele sakwaManala nesiNdebele seMoletlane. &lt;ref name=&quot;:0&quot; /&gt; AmaNdebele aziwa njengesitjhaba esithanda imibala emihle nekhanyako ongayibona endleleni abambatha ngayo nabenza ngayo imigwalo yabo.

AmaNdebele bekangaphasi kwesiqhema sabaMbo ngaphambi kobana sizijamele ngaphasi kweNgwenyama uNdebele. Ngikho namhlanjesi kunezici ezifanako phakathi kwelimi lesiNdebele nelimi lesiHlubi, isiBhaca, isiMpondo nesiMpondomise.  Ngemva kwesikhathi uNdebele wabeletha uMkhalangana owabeletha umNtungwa. Ngemva kwesikhathi umNtungwa wabeletha uNjonono. UNjonono wabeletha uNanasi, uNanasi wabeletha uMafana. UMafana wabeletha uMhlanga owabeletha uMusi. Kusesikhathini seNgwenyama uMusi lapha amaNdebele ahlukana khona waba maNzunza namaNala. AmaNdebele akheka ngaleyondlela sele ahlala eSewula Afrika nje. &lt;ref&gt;https://en.wikipedia.org/wiki/Southern_Ndebele_language&lt;/ref&gt;

== IsiSwati ==
[[Isimumathi:Indoni_Parade_2018._Swati_Kingdom_by_Sizwe_Sibiya_(10).jpg|thumb|AmaSwati]]
IsiSwati sikhulunywa eenarheni ezimbili, eSewula Afrika neSwatini. Ngokwethebula elingehla abantu abakhuluma isiSwati eSewula Afrika  bangaphezu kweengidi ezilikhomba.&lt;ref name=&quot;:1&quot; /&gt; KunesiSwati esikhulunywa eSwatini kwaManzini, eShiselweni neHhoho.&lt;ref name=&quot;:2&quot; /&gt; Abantu abakhuluma isiSwati eSwatini babalelwa eengidini ezine. &lt;ref name=&quot;:3&quot;&gt;https://en.wikipedia.org/wiki/Zulu_language&lt;/ref&gt;

AmaSwati bewasiqhenyana esincani sabeNguni ebesaziwa bona Mangwane. Ngokukhamba kwesikhathi isiqhemesi sahlangana nesiqhenyana sabeSuthu ebesihlala endaweni namhlanjesi ebizwa bona kuseSwatini. Ngemva kwalokho bakhula baba sisizwe ngaphasi kweNgwenyama uDlamini III eyathatha iintambo eNgwenyameni uMaseko, yathatha isitjhaba yayosinzinzisa ngasemlanjeni iPongola bahlala eduze namaNdwandwe ngo-1750. UDlamini III walandelwa yiNgwenyama uNgwane III okukholelwa bona nguye owaba yiNgwenyama yokuthoma eyabusa indawo namhlanjesi ebizwa bona kuseSwatini.&lt;ref&gt;https://en.wikipedia.org/wiki/Swazi_people&lt;/ref&gt;

== IsiZulu ==
[[Isimumathi:Zulu_Krieger.jpg|thumb|Abobaba bamaZulu bayagida]]
IsiZulu ngelinye lamalimi adumileko asemthethweni eSewula Afrika elikhulunywa babantu ababgaogezu kweengidi ezimatjhumi amahlanu, kuthi labo abalimunyileko bangaphezu kweengidi ezilitjhumi nanye. &lt;ref name=&quot;:1&quot; /&gt; IsiZulu sikhulunywa khulu KwaZulu Natal, esiFundeni se-Gauteng nakezinye iimfunda.

Umuntu owadlala indima ekulu ekwakhekeni kwesitjhaba samaZulu yiNgwenyama uShaka. UShaka walwa neentjhaba ezincani nezikulu zabeNguni kuhlanganise namaNdwandwe wazihlula. Ngemva kwalokho wazibiza ngoZulu obekangukhokho omkhulu wesitjhaba abelethelwa kiso. Iintjhabezi zahlangana kwavela ilimi lesiZulu.&lt;ref name=&quot;:3&quot; /&gt;
== IsiXhosa ==
[[Isimumathi:Xhosa_traditionally_dressed_women.jpg|thumb|250x250px|Abomma bamaXhosa]]
IsiXhosa naso singelinye lamalimi weSewula Afrika asemthethweni. IsiXhosa sikhulunywa babantu abangaphezu kweengidi ezimatjhumi amathathu nobunane, kuthi labo okulimi labo lokubelethwa bangaphezu kweengidi ezibunane. &lt;ref name=&quot;:1&quot; /&gt; IsiXhosa sikhulunywa khulukhulu esiFundeni seTjingalanga Kapa, eTlhagwini  Kapa nesiFundeni se-Gauteng.&lt;ref&gt;{{Cite web|last=Alexander|first=Mary|date=2025-04-06|title=The languages of South Africa|url=https://southafrica-info.com/arts-culture/11-languages-south-africa/#:~:text=Among%20South%20Africa's%20population%20groups,),%20based%20on%20Census%202022.|access-date=2025-05-23|website=South Africa Gateway|language=en-GB}}&lt;/ref&gt;

Ekadeni bekuneenqhema zabeNguni ezakha ubuhlobo neentjhaba zabaThwa nabaKhoekhoe. Ngokukhamba kwesikhathi iintjhabezi zahlangana zaba sisizwe ngaphasi kokubusa kweNgwenyama uTshawe owahlula isitjhaba samaCirha namaJwarha. Ngemva kwalokho wahlanganisa zoke iintjhaba ezincani kuhlanganise nesabaKhoekhoe. Labeletheka njalo-ke ilimi lesiXhosa.&lt;ref&gt;https://en.wikipedia.org/wiki/Xhosa_people&lt;/ref&gt;

== IsiSuthu ==
[[Isimumathi:Sotho_regalia.jpg|thumb|Abobaba babeSuthu]]
IsiSuthu lilimi elisemthethweni eSewula Afrika elikhunywa babantu abangaphezu kweengidi ezimatjhumi amabili nambili. Okulilmi labo abalimunyileko bangaphezu kweengidi ezintathu. &lt;ref name=&quot;:1&quot; /&gt; IsiSuthu sikhulunywa khulu enarheni yeLesotho, kanti eSewula Afrikapha sikhulunywa khulukhulu esiFundeni seFreestate, seGauteng. Umhlobo lo wesiSuthu ubizwa ngokobana siSuthu seSewula ngombana uhlukaniswa nesiSuthu seTlhagwini - okusiPedi, nesiSuthu seTjingalanga - okusiTswana.

Emandulo abeSuthu beza eSewula Afrika bavela eTlhagwini njengezinye iintjhaba bafika bahlala etlhagwini yeSewula Afrika. Bafika baba ziinqhenyana ezinjengaba-Taung, aba-Sia, aba-Fokeng, ama-Kgolokoe naba-Kwena nezinye iinqenyana. Kuhlekuhle umndeni webukhosini eLesotho mndeni wabaKwena. AbeSuthwaba ngibo-ke ababanikazi belimi lesiSuthu esikhulunywa eSewula Afrika neLesotho.&lt;ref&gt;{{Cite web|title=SOUTHERN SESOTHO - South African Language Southern Sesotho|url=https://www.sa-venues.com/language-southern-sesotho.htm|access-date=2025-05-26|website=www.sa-venues.com}}&lt;/ref&gt;

== IsiTswana ==
[[Isimumathi:Tswana_Dancers_3.jpg|thumb|Isiqhema esigidako sabaTswana]]
IsiTswana nalo ngelinye lamalimi asesiqhemeni sesiSuthu seTjingalanga esikhulunywa eSewula Afrika neBotswana. Abantu abasikhulumako eSewula Afrika bangaphezu kweengidi ezimatjhumi amabili nantathu, abalimunyileko bangaphezu kweengidi ezine.&lt;ref name=&quot;:1&quot; /&gt; isiTswana sikhulunywa khulu enarheni yeBotswana kanti eSewula Afrika sikhulunywa khulu esiFundeni seTlhagwini-Tjhingalanga, neGauteng.

Emandulo abeTswana bebangaphasi kwesiqhema sabeSuthu nabazakufika eSewula Afrika bavela eTlhagwini ne-Afrika. Bafika baba ziinqhenyana ezinjengaba-Taung, aba-Sia, aba-Fokeng, ama-Kgolokoe nabaKwena kunye nezinye iinqhenyana. Bafika endaweni ebizwa ngokobana yiBotswana namhlanjesi, balwa nabaThwa babahlula, bese bakha umbuso wabaTswana. Ngibo-ke namhlanjesi ababanikazi belimi lesiTswana.&lt;ref&gt;{{Cite web|title=AFRICA {{!}} 101 Last Tribes - Tswana people|url=http://www.101lasttribes.com/tribes/tswana.html|access-date=2025-05-26|website=www.101lasttribes.com}}&lt;/ref&gt;

== IsiPedi ==
[[Isimumathi:Pedi_Living_Culture_Route,_Limpopo,_South_Africa_(2417712111).jpg|thumb|Umuzi wesiPedi]]
IsiPedi ([https://www.sahistory.org.za/article/pedi Sepedi]) nalo ngelinye lamalimi angaphasi kwesiSuthu atloliswe ngokomthetho eSewula Afrika, begodu saziwa ngokuthi siSuthu seTlhagwini. &lt;ref name=&quot;:4&quot;&gt;{{Cite web|title=AFRICA {{!}} 101 Last Tribes - Pedi people|url=http://www.101lasttribes.com/tribes/pedi.html|access-date=2025-05-26|website=www.101lasttribes.com}}&lt;/ref&gt; Ilimeli likhulunywa khulukhulu esiFundeni seLimpopo neseGauteng babantu abalinganiswela eengidini ezimatjhumi amabili nekhomba.&lt;ref name=&quot;:1&quot; /&gt;

Ekadeni isiqhemesi besiyingcenye yesiqhema sabeSuthu, kwathi nakukhamba ezinye iinqhema sona sasala ngetlhagwini yeSewula Afrika. Sineenqhenyana ezinengana okucatjangelwa bona sikhuluma amalinyana amatjhumi amathathu. Abanye bathi isiSuthu seTlhagwini akusiso isiPedi kodwana lilimi elihlukileko. &lt;ref name=&quot;:4&quot; /&gt;
== IsiVenda ==
[[Isimumathi:Venda_culture,_Limpopo,_South_Africa_(8714283418).jpg|thumb|251x251px|Izindlu zamaVenda]]
Elinye lamalimi atloliswe ngokomthetho eSewula Afrika siVenda. Abantu abakhuluma isiVenda balinganiselwa eengidini ezihlanu. &lt;ref name=&quot;:1&quot; /&gt; IsiVenda sikhulunywa khulu esiFundeni seLimpopo ngetlhagwini ngitjho nesiFundeni seGauteng. Nawulilemukisisa kuhle ilimeli linezici ezivela elimini lesiShona nelesiTokwa.

Ekadeni isiqhemesi kukholelwa bona sathoma ukuba khona nakusabusa uMpuso weMapungubwe, kwathi nakuwa umbuso lo kuvuka umbuso weZimbabwe sathutha sayokuhlala endaweni namhlanjesi ebizwa ngokobana kuseZimbabwe. Sakhamba isikhathi, isiqhemesi sathutha eZimbabwe sehla seyama umlambo weZambezi sazitholela indawo sayithiya ngokuthi yi-D'zata. Kusukela ngalesosikhathi umbuso wabo uye wannzinza kwabusa amakhosi wawo ngokulandelana kwawo. Namhlanjesi ngibo ababanikazi belimi lesiVenda. &lt;ref&gt;{{Cite web|title=Venda - African Tribe - Venda Culture|url=https://www.krugerpark.co.za/africa_venda.html|access-date=2025-05-26|website=www.krugerpark.co.za}}&lt;/ref&gt;

== IsiTsonga ==
[[Isimumathi:Tsonga_women_in_South_Africa.jpg|thumb|Abomma bambethe isiTsonga]]
IsiTsonga ngelinye lamalimi akhulunywa eSewula Afrika atloliswe ngokomthetho. Ilimeli likhulunywa babantu abangaphezu kweengidi ezilitjhumi nanye. IsiTsonga sikhulunywa  khulukhulu esifundeni seLimpopo neseGauteng, bese kube nesiTsonga esikhulunywa eMozambique. &lt;ref name=&quot;:1&quot; /&gt;

Abantwaba bebasiqhema sabeNguni abathoma lokha uSoshangane ebekuyinduna kaShaka abalekela enarheni yangepumalanga. Bathi nabafika lapho bazakhela umbuso omkhulu nedorhobho elibizwa bona yiGaza. Bfika bahlula izizwe ezinengi abazithola lapho njengesizwe samaNdawu, amaTonga, amaTjopi amaSena nezinye. Ilimi labo lesiNguni lahlangana nesiTonga namalimi walapho laba siTsonga. Ngokukhamba kwesikhathi umbuso lo wahlukana, amanye amaTsonga athuthela ngapha ngendaweni yeSewula Afrika.&lt;ref&gt;{{Cite web|title=Shangaan Tsonga - Nguni People, Tribe - South Africa...|url=https://www.krugerpark.co.za/africa_shangaan_tsonga.html|access-date=2025-05-26|website=www.krugerpark.co.za}}&lt;/ref&gt;

== I-''Afrikaans'' ==
[[Isimumathi:Boer_Family_with_a_wagon_-_false_colour_image.jpg|thumb|AmaBhuru wakade]]
I-Afrikaans namkha isiBhuru mhlobo welimi lamakhuwa angasiwo wendabuko weSewula Afrika. Nalo litlolisiwe ngokomthetho begodu likhulunywa babantu abangaphezu kweengidi ezimatjhumi amathathu nane. &lt;ref name=&quot;:1&quot; /&gt; I-Afrikaans ikhulunywa khulu eemfundeni zangeTjingalanga Kapa, eGauteng nakezinye iimfunda.

Ilimi le-Afrikaans livela elimini lesiDatjhi. AmaDatjhi afika eSewula Afrika lokha uJan Van Riebeeck obekasebenzela i-VOC (''[https://www.worldhistory.org/Dutch_East_India_Company/ Vereenigde Oost-Indische Compagnie]'') afika nabantu bekhabo ngo-1652, bafika bahlala endaweni abayibiza bona yi-''Cape of Good Hope''. Bafika lapho bahlangana nesitjhaba sabaKhoekhoe. Ngokukhamba kwesikhathi ilimi lesiDatjhi lahlangana nelesiKhoe kunye namanye amalimi kwakheka ilimi namhlanjesi elibizwa ngokuthi yi-Afrikaans namkha isiBhuru, okulilimi elisemthethweni bekube njenganje eSewula Afrika.&lt;ref&gt;{{Cite web|title=The Dutch Settlement {{!}} South African History Online|url=https://www.sahistory.org.za/article/dutch-settlement|access-date=2025-05-26|website=www.sahistory.org.za}}&lt;/ref&gt;&lt;ref&gt;{{Cite web|date=2023-10-13|title=‘The language we know as Afrikaans today owes much to the enslaved people who spoke it’—Read an excerpt from Coloured: How Classification Became Culture|url=https://johannesburgreviewofbooks.com/2023/10/13/the-language-we-know-as-afrikaans-today-owes-much-to-the-enslaved-people-who-spoke-it-read-an-excerpt-from-coloured-how-classification-became-culture/|access-date=2025-05-26|website=The Johannesburg Review of Books|language=en-US}}&lt;/ref&gt;

== IsiNgisi ==
[[Isimumathi:English_settlers_landing_in_Virginia_1607_Image_from_page_42_of_A_junior_class_history_of_the_United_States;_to_which_are_added_the_Declaration_of_independence,_and_the_Constitution_of_the_United_States_(1899).jpg|thumb|AmaNgisi bokufika]]
IsiNgisi kuphela kwelimi elikhulunywa khulu ukudlula woke eSewula Afrika. Sikhulunywa babantu abangaphezu kweengidi ezimatjhumi amathathu nekhomba. Ilimeli ngilo esisetjenziswa khulu emazikweni wezefundo, wezepolotiki, wezeemali, wezamaphilo namanye.

Safika njani isiNgisi eSewula Afrika? IsiNgisi besele sikhona nakufika amaBhuru ngo-1652 ngombana nakufika amaDatjhi athola u-Atjhumato obekayikosi yabaKhoekhoe besele abuya eBantam ngo-1630, akghona ukukhuluma isiNgisi nesiDatjhi. &lt;ref&gt;{{Cite web|title=Autshumao (Herry the Strandloper) {{!}} South African History Online|url=https://www.sahistory.org.za/people/autshumao-herry-strandloper#:~:text=Autshumao%20also%20known%20as%20Herry%20the%20strandloper,who%20were%20engaged%20in%20a%20trading%20relationship.|access-date=2025-05-26|website=www.sahistory.org.za}}&lt;/ref&gt; Nanyana isiNgisi besele sikhulunywa eSewula Afrika, amaNgisi wokufika nokuhlala eza mva kunamaDatjhi. Kwathoma mhlokho bona isiNgisi sikhulunywe eSewula Afrika.

== Ilimi Lezandla ==
Ilimi lezandla ngelinye lamalimi akhulunywa eSewula Afrika. Likhulunywa babantu abangaphesu kwesigidi sinye, begodu kunabantu abama-234,655 okulilimi labo lokuthoma.

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>59jw7z31jw471yofda9qazmm0pf3n2o</sha1>
    </revision>
    <revision>
      <id>3014</id>
      <parentid>2883</parentid>
      <timestamp>2025-06-06T20:27:12Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>brr brr patapim</comment>
      <origin>3014</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="17672" sha1="30jxogbzw9505jkzrpo0qt88xdyr501" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page.'''

= Amalimi WeSewula Afrika =
[[Isimumathi:Flag of South Africa.svg|thumb|Iflarha leSewula Afrika]]
'''Inarha yeSewula Afrika''' yinarha enabantu abanamasiko nabaneenzinda ezihlukahlukeneko, nabakhuluma amalimi ahlukahlukeneko. Inengi labantu enarheni le lisesiqhemeni sokuthoma sabantu abakhuluma amalimi angaphasi kwesiNguni, okusiZulu, isiXhosa, [[Isindebele|isiNdebele]] nesiSwati. Bese isiqhema sesibili ngobukhulu ngesikhuluma amalimi wesiSuthu, okusiTswana, isiPedi (okusiSuthu seTlhagwini) nesiSuthu (okusiSuthu seSewula, namkha isiSuthu sesiShweshwe). Bese kunesiqhema esikhuluma isiTsonga nesiqhema esikhuluma isiVenda.&lt;ref&gt;{{Cite web|date=2025-05-14|title=South Africa - Languages, Dialects, Afrikaans {{!}} Britannica|url=https://www.britannica.com/place/South-Africa/Languages|access-date=2025-05-15|website=www.britannica.com|language=en}}&lt;/ref&gt;

Ngaphezu kwamalimi abaliweko la kunamalimi ahlobene nawo. Ngokwesibonelo, esiNdebeleni kunesiNala, nesiNdebele seMoletlane. &lt;ref name=&quot;:0&quot;&gt;{{Cite web|title=Ndebele people, traditions culture|url=https://www.africancraftsmarket.com/african-tribes/ndebele-people.html|access-date=2025-05-15|website=www.africancraftsmarket.com}}&lt;/ref&gt; EsiXhoseni kube nesiNgqika, isiThembu, isiBhaca, isiGcaleka, isiMpondo, isiMpondomise, isiMfengu nesiBomvana.&lt;ref&gt;{{Cite web|title=XHOSA - South African Language Xhosa|url=https://www.sa-venues.com/language-xhosa.htm#:~:text=Xhosa%20has%20been%20grouped%20into,yet%20pretty-sounding,%20language.|access-date=2025-05-15|website=www.sa-venues.com}}&lt;/ref&gt; Kusese nelimi lesiThwa elibandaka isi-Khoe, isi-Tu isi-Kx'a, namanye amalimi.&lt;ref&gt;{{Cite web|title=AFRICA {{!}} 101 Last Tribes - San people|url=https://www.101lasttribes.com/tribes/san.html|access-date=2025-05-15|website=www.101lasttribes.com}}&lt;/ref&gt; Bese isiSwati kunesikhulunywa eManzini, esikhulunywa eShiselweni, nesikhulunywa eHhoho.&lt;ref name=&quot;:2&quot;&gt;{{Cite web|last=web-lingo|date=2013-01-07|title=SA’s Eleven Official Languages: SiSwati|url=https://web-lingo.com/sas-eleven-official-languages-siswati/#:~:text=Swazi%20is%20most%20closely%20related,considered%20closer%20to%20standard%20Swazi.|access-date=2025-05-15|website=Web-lingo|language=en-ZA}}&lt;/ref&gt; IsiPedi naso sinamalinyana angaphasi kwaso anjengesiTlokwa nesiLobedu.&lt;ref&gt;{{Cite web|title=free online course|url=https://www.unisa.ac.za/static/corporate_web/Content/UnisaOpen/freeOnlineCourse/nSotho/nSotho.html#:~:text=Northern%20Sotho%20is%20based%20mainly,(Cf.|access-date=2025-05-15|website=www.unisa.ac.za}}&lt;/ref&gt; Bese kube namalimi angasiwo wendabuko, namkha amalimi wesikhuwa akhulunywako njengesiNgisi nesiBhuru. Woke amalimi la namanye angakabalwa lapha malimi akhulunywa babantu beSewula Afrika.

== Amalimi Asemthethweni ==
Amalimi aseMthethweni eSewula Afrika siNdebele, isiZulu, isiSwati, isiXhosa, isiSuthu, isiPedi, isiTswana, isiVenda, isiTsonga okumalimi wendabuko, bese kuba siBhuru nesiNgisi. Ithebula elingenzasi litjengisa isibalo sabantu abakhuluma amalimi asemthethweni eSewula Afrika namaphesente wabalikhulumako esibalweni sabo boke abantu abahlala eSewula Afrika ngokweembalobalo zango-2022. &lt;ref name=&quot;:1&quot;&gt;https://en.wikipedia.org/wiki/Languages_of_South_Africa#cite_note-EthnologueZA-7&lt;/ref&gt;
{| class=&quot;wikitable sortable mw-collapsible&quot;
|+
! rowspan=&quot;2&quot; |Ilimi
! colspan=&quot;2&quot; |Ilimi lebele&lt;ref name=&quot;:1&quot; /&gt;
! colspan=&quot;2&quot; |Ilimi lesibili&lt;ref name=&quot;:1&quot; /&gt;
! colspan=&quot;2&quot; |Ilimi lesithathu&lt;ref name=&quot;:1&quot; /&gt;
|-
!Isibalo
!Amaphesente
!Isibalo
!Amaphesente
!Isibalo
!Amaphesente
|-
|IsiZulu
|11,587,374
|22.7%
|15,700,000
|30.8%
|27,300,000
|46%
|-
|IsiXhosa
|8,154,258
|16.0%
|11,000,000
|21.6%
|19,150,000
|33%
|-
|IsiVenda
|1,209,388
|2.4%
|1,700,000
|3.3%
|2,910,000
|5%
|-
|IsiTswana
|4,067,248
|8.0%
|7,700,000
|15.1%
|11,770,000
|20%
|-
|IsiTsonga
|2,277,148
|4.5%
|3,400,000
|6.6%
|5,680,000
|10%
|-
|IsiSwati
|1,297,046
|2.5%
|2,400,000
|4.7%
|3,700,000
|6%
|-
|IsiSuthu
|3,849,563
|7.6%
|7,900,000
|15.5%
|11,750,000
|20%
|-
|IsiPedi
|4,618,576
|9.1%
|9,100,000
|17.8%
|13,720,000
|23%
|-
|IsiNdebele
|1,090,223
|2.1%
|1,400,000
|2.7%
|2,490,000
|4%
|-
|IsiNgisi
|4,892,623
|9.6%
|14,000,000
|27.4%
|19,640,000
|33%
|-
|Isi-Afrikaans
|6,855,082
|13.5%
|10,300,000
|20.2%
|17,160,000
|29%
|-
|Ilimi Lezandla le-SA
|234,655
|0.5%
|500,000
|1.0%
|834,655
|1.5%
|-
|Amanye Amalimi
|828,258
|1.6%
|
|
|
|
|-
|'''Isibalo Sisoke'''
|'''50,961,443'''
|'''100.0%'''
|
|
|
|
|}

== IsiNdebele ==
[[Isimumathi:Ndebele_women-1.jpg|thumb|Abomma bamaNdebele]]
IsiNdebele seSewula Afrika ngelinye lamalimi akhulunywa enarheni le. Isizathu sokuthi kuthiwe siNdebele seSewula Afrika kukuthi kunesiNdebele seZimbabwe. &lt;ref&gt;{{Cite web|last=web-lingo|date=2012-10-19|title=Ndebele: What is Ndebele?|url=https://web-lingo.com/ndebele-what-is-ndebele/#:~:text=Northern%20Ndebele,%20or%20Matabele,%20or,nineteenth%20century%20during%20the%20Mfecane.|access-date=2025-05-15|website=Web-lingo|language=en-ZA}}&lt;/ref&gt; Ngokwethebula elingehla, abantu abakhuluma isiNdebele - abasimunyileko, okulilimi lesibili nalabo okulilimi lesithathu kibo - bangaphezu kweengidi ezine. Ilimeli likhulunywa khulukhulu esifundeni seMpumalanga eendaweni ezinjengaKwaNdebele, eMalahleni, e-Middleburg, e-Belfast, kwaDlawulale nakezinye iindawo  njengesiFunda seLimpopo.I siNdebele esisemthethweni siNzunza, kodwana kusese nesiNdebele sakwaManala nesiNdebele seMoletlane. &lt;ref name=&quot;:0&quot; /&gt; AmaNdebele aziwa njengesitjhaba esithanda imibala emihle nekhanyako ongayibona endleleni abambatha ngayo nabenza ngayo imigwalo yabo.

AmaNdebele bekangaphasi kwesiqhema sabaMbo ngaphambi kobana sizijamele ngaphasi kweNgwenyama uNdebele. Ngikho namhlanjesi kunezici ezifanako phakathi kwelimi lesiNdebele nelimi lesiHlubi, isiBhaca, isiMpondo nesiMpondomise.  Ngemva kwesikhathi uNdebele wabeletha uMkhalangana owabeletha umNtungwa. Ngemva kwesikhathi umNtungwa wabeletha uNjonono. UNjonono wabeletha uNanasi, uNanasi wabeletha uMafana. UMafana wabeletha uMhlanga owabeletha uMusi. Kusesikhathini seNgwenyama uMusi lapha amaNdebele ahlukana khona waba maNzunza namaNala. AmaNdebele akheka ngaleyondlela sele ahlala eSewula Afrika nje. &lt;ref&gt;https://en.wikipedia.org/wiki/Southern_Ndebele_language&lt;/ref&gt;

== IsiSwati ==
[[Isimumathi:Indoni_Parade_2018._Swati_Kingdom_by_Sizwe_Sibiya_(10).jpg|thumb|AmaSwati]]
IsiSwati sikhulunywa eenarheni ezimbili, eSewula Afrika neSwatini. Ngokwethebula elingehla abantu abakhuluma isiSwati eSewula Afrika  bangaphezu kweengidi ezilikhomba.&lt;ref name=&quot;:1&quot; /&gt; KunesiSwati esikhulunywa eSwatini kwaManzini, eShiselweni neHhoho.&lt;ref name=&quot;:2&quot; /&gt; Abantu abakhuluma isiSwati eSwatini babalelwa eengidini ezine. &lt;ref name=&quot;:3&quot;&gt;https://en.wikipedia.org/wiki/Zulu_language&lt;/ref&gt;

AmaSwati bewasiqhenyana esincani sabeNguni ebesaziwa bona Mangwane. Ngokukhamba kwesikhathi isiqhemesi sahlangana nesiqhenyana sabeSuthu ebesihlala endaweni namhlanjesi ebizwa bona kuseSwatini. Ngemva kwalokho bakhula baba sisizwe ngaphasi kweNgwenyama uDlamini III eyathatha iintambo eNgwenyameni uMaseko, yathatha isitjhaba yayosinzinzisa ngasemlanjeni iPongola bahlala eduze namaNdwandwe ngo-1750. UDlamini III walandelwa yiNgwenyama uNgwane III okukholelwa bona nguye owaba yiNgwenyama yokuthoma eyabusa indawo namhlanjesi ebizwa bona kuseSwatini.&lt;ref&gt;https://en.wikipedia.org/wiki/Swazi_people&lt;/ref&gt;

== IsiZulu ==
[[Isimumathi:Zulu_Krieger.jpg|thumb|Abobaba bamaZulu bayagida]]
IsiZulu ngelinye lamalimi adumileko asemthethweni eSewula Afrika elikhulunywa babantu ababgaogezu kweengidi ezimatjhumi amahlanu, kuthi labo abalimunyileko bangaphezu kweengidi ezilitjhumi nanye. &lt;ref name=&quot;:1&quot; /&gt; IsiZulu sikhulunywa khulu KwaZulu Natal, esiFundeni se-Gauteng nakezinye iimfunda.

Umuntu owadlala indima ekulu ekwakhekeni kwesitjhaba samaZulu yiNgwenyama uShaka. UShaka walwa neentjhaba ezincani nezikulu zabeNguni kuhlanganise namaNdwandwe wazihlula. Ngemva kwalokho wazibiza ngoZulu obekangukhokho omkhulu wesitjhaba abelethelwa kiso. Iintjhabezi zahlangana kwavela ilimi lesiZulu.&lt;ref name=&quot;:3&quot; /&gt;
== IsiXhosa ==
[[Isimumathi:Xhosa_traditionally_dressed_women.jpg|thumb|250x250px|Abomma bamaXhosa]]
IsiXhosa naso singelinye lamalimi weSewula Afrika asemthethweni. IsiXhosa sikhulunywa babantu abangaphezu kweengidi ezimatjhumi amathathu nobunane, kuthi labo okulimi labo lokubelethwa bangaphezu kweengidi ezibunane. &lt;ref name=&quot;:1&quot; /&gt; IsiXhosa sikhulunywa khulukhulu esiFundeni seTjingalanga Kapa, eTlhagwini  Kapa nesiFundeni se-Gauteng.&lt;ref&gt;{{Cite web|last=Alexander|first=Mary|date=2025-04-06|title=The languages of South Africa|url=https://southafrica-info.com/arts-culture/11-languages-south-africa/#:~:text=Among%20South%20Africa's%20population%20groups,),%20based%20on%20Census%202022.|access-date=2025-05-23|website=South Africa Gateway|language=en-GB}}&lt;/ref&gt;

Ekadeni bekuneenqhema zabeNguni ezakha ubuhlobo neentjhaba zabaThwa nabaKhoekhoe. Ngokukhamba kwesikhathi iintjhabezi zahlangana zaba sisizwe ngaphasi kokubusa kweNgwenyama uTshawe owahlula isitjhaba samaCirha namaJwarha. Ngemva kwalokho wahlanganisa zoke iintjhaba ezincani kuhlanganise nesabaKhoekhoe. Labeletheka njalo-ke ilimi lesiXhosa.&lt;ref&gt;https://en.wikipedia.org/wiki/Xhosa_people&lt;/ref&gt;

== IsiSuthu ==
[[Isimumathi:Sotho_regalia.jpg|thumb|Abobaba babeSuthu]]
IsiSuthu lilimi elisemthethweni eSewula Afrika elikhunywa babantu abangaphezu kweengidi ezimatjhumi amabili nambili. Okulilmi labo abalimunyileko bangaphezu kweengidi ezintathu. &lt;ref name=&quot;:1&quot; /&gt; IsiSuthu sikhulunywa khulu enarheni yeLesotho, kanti eSewula Afrikapha sikhulunywa khulukhulu esiFundeni seFreestate, seGauteng. Umhlobo lo wesiSuthu ubizwa ngokobana siSuthu seSewula ngombana uhlukaniswa nesiSuthu seTlhagwini - okusiPedi, nesiSuthu seTjingalanga - okusiTswana.

Emandulo abeSuthu beza eSewula Afrika bavela eTlhagwini njengezinye iintjhaba bafika bahlala etlhagwini yeSewula Afrika. Bafika baba ziinqhenyana ezinjengaba-Taung, aba-Sia, aba-Fokeng, ama-Kgolokoe naba-Kwena nezinye iinqenyana. Kuhlekuhle umndeni webukhosini eLesotho mndeni wabaKwena. AbeSuthwaba ngibo-ke ababanikazi belimi lesiSuthu esikhulunywa eSewula Afrika neLesotho.&lt;ref&gt;{{Cite web|title=SOUTHERN SESOTHO - South African Language Southern Sesotho|url=https://www.sa-venues.com/language-southern-sesotho.htm|access-date=2025-05-26|website=www.sa-venues.com}}&lt;/ref&gt;

== IsiTswana ==
[[Isimumathi:Tswana_Dancers_3.jpg|thumb|Isiqhema esigidako sabaTswana]]
IsiTswana nalo ngelinye lamalimi asesiqhemeni sesiSuthu seTjingalanga esikhulunywa eSewula Afrika neBotswana. Abantu abasikhulumako eSewula Afrika bangaphezu kweengidi ezimatjhumi amabili nantathu, abalimunyileko bangaphezu kweengidi ezine.&lt;ref name=&quot;:1&quot; /&gt; isiTswana sikhulunywa khulu enarheni yeBotswana kanti eSewula Afrika sikhulunywa khulu esiFundeni seTlhagwini-Tjhingalanga, neGauteng.

Emandulo abeTswana bebangaphasi kwesiqhema sabeSuthu nabazakufika eSewula Afrika bavela eTlhagwini ne-Afrika. Bafika baba ziinqhenyana ezinjengaba-Taung, aba-Sia, aba-Fokeng, ama-Kgolokoe nabaKwena kunye nezinye iinqhenyana. Bafika endaweni ebizwa ngokobana yiBotswana namhlanjesi, balwa nabaThwa babahlula, bese bakha umbuso wabaTswana. Ngibo-ke namhlanjesi ababanikazi belimi lesiTswana.&lt;ref&gt;{{Cite web|title=AFRICA {{!}} 101 Last Tribes - Tswana people|url=http://www.101lasttribes.com/tribes/tswana.html|access-date=2025-05-26|website=www.101lasttribes.com}}&lt;/ref&gt;

== IsiPedi ==
[[Isimumathi:Pedi_Living_Culture_Route,_Limpopo,_South_Africa_(2417712111).jpg|thumb|Umuzi wesiPedi]]
IsiPedi ([https://www.sahistory.org.za/article/pedi Sepedi]) nalo ngelinye lamalimi angaphasi kwesiSuthu atloliswe ngokomthetho eSewula Afrika, begodu saziwa ngokuthi siSuthu seTlhagwini. &lt;ref name=&quot;:4&quot;&gt;{{Cite web|title=AFRICA {{!}} 101 Last Tribes - Pedi people|url=http://www.101lasttribes.com/tribes/pedi.html|access-date=2025-05-26|website=www.101lasttribes.com}}&lt;/ref&gt; Ilimeli likhulunywa khulukhulu esiFundeni seLimpopo neseGauteng babantu abalinganiswela eengidini ezimatjhumi amabili nekhomba.&lt;ref name=&quot;:1&quot; /&gt;

Ekadeni isiqhemesi besiyingcenye yesiqhema sabeSuthu, kwathi nakukhamba ezinye iinqhema sona sasala ngetlhagwini yeSewula Afrika. Sineenqhenyana ezinengana okucatjangelwa bona sikhuluma amalinyana amatjhumi amathathu. Abanye bathi isiSuthu seTlhagwini akusiso isiPedi kodwana lilimi elihlukileko. &lt;ref name=&quot;:4&quot; /&gt;
== IsiVenda ==
[[Isimumathi:Venda_culture,_Limpopo,_South_Africa_(8714283418).jpg|thumb|251x251px|Izindlu zamaVenda]]
Elinye lamalimi atloliswe ngokomthetho eSewula Afrika siVenda. Abantu abakhuluma isiVenda balinganiselwa eengidini ezihlanu. &lt;ref name=&quot;:1&quot; /&gt; IsiVenda sikhulunywa khulu esiFundeni seLimpopo ngetlhagwini ngitjho nesiFundeni seGauteng. Nawulilemukisisa kuhle ilimeli linezici ezivela elimini lesiShona nelesiTokwa.

Ekadeni isiqhemesi kukholelwa bona sathoma ukuba khona nakusabusa uMpuso weMapungubwe, kwathi nakuwa umbuso lo kuvuka umbuso weZimbabwe sathutha sayokuhlala endaweni namhlanjesi ebizwa ngokobana kuseZimbabwe. Sakhamba isikhathi, isiqhemesi sathutha eZimbabwe sehla seyama umlambo weZambezi sazitholela indawo sayithiya ngokuthi yi-D'zata. Kusukela ngalesosikhathi umbuso wabo uye wannzinza kwabusa amakhosi wawo ngokulandelana kwawo. Namhlanjesi ngibo ababanikazi belimi lesiVenda. &lt;ref&gt;{{Cite web|title=Venda - African Tribe - Venda Culture|url=https://www.krugerpark.co.za/africa_venda.html|access-date=2025-05-26|website=www.krugerpark.co.za}}&lt;/ref&gt;

== IsiTsonga ==
[[Isimumathi:Tsonga_women_in_South_Africa.jpg|thumb|Abomma bambethe isiTsonga]]
IsiTsonga ngelinye lamalimi akhulunywa eSewula Afrika atloliswe ngokomthetho. Ilimeli likhulunywa babantu abangaphezu kweengidi ezilitjhumi nanye. IsiTsonga sikhulunywa  khulukhulu esifundeni seLimpopo neseGauteng, bese kube nesiTsonga esikhulunywa eMozambique. &lt;ref name=&quot;:1&quot; /&gt;

Abantwaba bebasiqhema sabeNguni abathoma lokha uSoshangane ebekuyinduna kaShaka abalekela enarheni yangepumalanga. Bathi nabafika lapho bazakhela umbuso omkhulu nedorhobho elibizwa bona yiGaza. Bfika bahlula izizwe ezinengi abazithola lapho njengesizwe samaNdawu, amaTonga, amaTjopi amaSena nezinye. Ilimi labo lesiNguni lahlangana nesiTonga namalimi walapho laba siTsonga. Ngokukhamba kwesikhathi umbuso lo wahlukana, amanye amaTsonga athuthela ngapha ngendaweni yeSewula Afrika.&lt;ref&gt;{{Cite web|title=Shangaan Tsonga - Nguni People, Tribe - South Africa...|url=https://www.krugerpark.co.za/africa_shangaan_tsonga.html|access-date=2025-05-26|website=www.krugerpark.co.za}}&lt;/ref&gt;

== I-''Afrikaans'' ==
[[Isimumathi:Boer_Family_with_a_wagon_-_false_colour_image.jpg|thumb|AmaBhuru wakade]]
I-Afrikaans namkha isiBhuru mhlobo welimi lamakhuwa angasiwo wendabuko weSewula Afrika. Nalo litlolisiwe ngokomthetho begodu likhulunywa babantu abangaphezu kweengidi ezimatjhumi amathathu nane. &lt;ref name=&quot;:1&quot; /&gt; I-Afrikaans ikhulunywa khulu eemfundeni zangeTjingalanga Kapa, eGauteng nakezinye iimfunda.

Ilimi le-Afrikaans livela elimini lesiDatjhi. AmaDatjhi afika eSewula Afrika lokha uJan Van Riebeeck obekasebenzela i-VOC (''[https://www.worldhistory.org/Dutch_East_India_Company/ Vereenigde Oost-Indische Compagnie]'') afika nabantu bekhabo ngo-1652, bafika bahlala endaweni abayibiza bona yi-''Cape of Good Hope''. Bafika lapho bahlangana nesitjhaba sabaKhoekhoe. Ngokukhamba kwesikhathi ilimi lesiDatjhi lahlangana nelesiKhoe kunye namanye amalimi kwakheka ilimi namhlanjesi elibizwa ngokuthi yi-Afrikaans namkha isiBhuru, okulilimi elisemthethweni bekube njenganje eSewula Afrika.&lt;ref&gt;{{Cite web|title=The Dutch Settlement {{!}} South African History Online|url=https://www.sahistory.org.za/article/dutch-settlement|access-date=2025-05-26|website=www.sahistory.org.za}}&lt;/ref&gt;&lt;ref&gt;{{Cite web|date=2023-10-13|title=‘The language we know as Afrikaans today owes much to the enslaved people who spoke it’—Read an excerpt from Coloured: How Classification Became Culture|url=https://johannesburgreviewofbooks.com/2023/10/13/the-language-we-know-as-afrikaans-today-owes-much-to-the-enslaved-people-who-spoke-it-read-an-excerpt-from-coloured-how-classification-became-culture/|access-date=2025-05-26|website=The Johannesburg Review of Books|language=en-US}}&lt;/ref&gt;

== IsiNgisi ==
[[Isimumathi:English_settlers_landing_in_Virginia_1607_Image_from_page_42_of_A_junior_class_history_of_the_United_States;_to_which_are_added_the_Declaration_of_independence,_and_the_Constitution_of_the_United_States_(1899).jpg|thumb|AmaNgisi bokufika]]
IsiNgisi kuphela kwelimi elikhulunywa khulu ukudlula woke eSewula Afrika. Sikhulunywa babantu abangaphezu kweengidi ezimatjhumi amathathu nekhomba. Ilimeli ngilo esisetjenziswa khulu emazikweni wezefundo, wezepolotiki, wezeemali, wezamaphilo namanye.

Safika njani isiNgisi eSewula Afrika? IsiNgisi besele sikhona nakufika amaBhuru ngo-1652 ngombana nakufika amaDatjhi athola u-Atjhumato obekayikosi yabaKhoekhoe besele abuya eBantam ngo-1630, akghona ukukhuluma isiNgisi nesiDatjhi. &lt;ref&gt;{{Cite web|title=Autshumao (Herry the Strandloper) {{!}} South African History Online|url=https://www.sahistory.org.za/people/autshumao-herry-strandloper#:~:text=Autshumao%20also%20known%20as%20Herry%20the%20strandloper,who%20were%20engaged%20in%20a%20trading%20relationship.|access-date=2025-05-26|website=www.sahistory.org.za}}&lt;/ref&gt; Nanyana isiNgisi besele sikhulunywa eSewula Afrika, amaNgisi wokufika nokuhlala eza mva kunamaDatjhi. Kwathoma mhlokho bona isiNgisi sikhulunywe eSewula Afrika.

== Ilimi Lezandla ==
Ilimi lezandla ngelinye lamalimi akhulunywa eSewula Afrika. Likhulunywa babantu abangaphesu kwesigidi sinye, begodu kunabantu abama-234,655 okulilimi labo lokuthoma.

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>30jxogbzw9505jkzrpo0qt88xdyr501</sha1>
    </revision>
    <revision>
      <id>3083</id>
      <parentid>3014</parentid>
      <timestamp>2025-06-07T03:05:22Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Mosakaruka|Mosakaruka]]</comment>
      <origin>2883</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="17584" sha1="59jw7z31jw471yofda9qazmm0pf3n2o" xml:space="preserve">= Amalimi WeSewula Afrika =
[[Isimumathi:Flag of South Africa.svg|thumb|Iflarha leSewula Afrika]]
'''Inarha yeSewula Afrika''' yinarha enabantu abanamasiko nabaneenzinda ezihlukahlukeneko, nabakhuluma amalimi ahlukahlukeneko. Inengi labantu enarheni le lisesiqhemeni sokuthoma sabantu abakhuluma amalimi angaphasi kwesiNguni, okusiZulu, isiXhosa, [[Isindebele|isiNdebele]] nesiSwati. Bese isiqhema sesibili ngobukhulu ngesikhuluma amalimi wesiSuthu, okusiTswana, isiPedi (okusiSuthu seTlhagwini) nesiSuthu (okusiSuthu seSewula, namkha isiSuthu sesiShweshwe). Bese kunesiqhema esikhuluma isiTsonga nesiqhema esikhuluma isiVenda.&lt;ref&gt;{{Cite web|date=2025-05-14|title=South Africa - Languages, Dialects, Afrikaans {{!}} Britannica|url=https://www.britannica.com/place/South-Africa/Languages|access-date=2025-05-15|website=www.britannica.com|language=en}}&lt;/ref&gt;

Ngaphezu kwamalimi abaliweko la kunamalimi ahlobene nawo. Ngokwesibonelo, esiNdebeleni kunesiNala, nesiNdebele seMoletlane. &lt;ref name=&quot;:0&quot;&gt;{{Cite web|title=Ndebele people, traditions culture|url=https://www.africancraftsmarket.com/african-tribes/ndebele-people.html|access-date=2025-05-15|website=www.africancraftsmarket.com}}&lt;/ref&gt; EsiXhoseni kube nesiNgqika, isiThembu, isiBhaca, isiGcaleka, isiMpondo, isiMpondomise, isiMfengu nesiBomvana.&lt;ref&gt;{{Cite web|title=XHOSA - South African Language Xhosa|url=https://www.sa-venues.com/language-xhosa.htm#:~:text=Xhosa%20has%20been%20grouped%20into,yet%20pretty-sounding,%20language.|access-date=2025-05-15|website=www.sa-venues.com}}&lt;/ref&gt; Kusese nelimi lesiThwa elibandaka isi-Khoe, isi-Tu isi-Kx'a, namanye amalimi.&lt;ref&gt;{{Cite web|title=AFRICA {{!}} 101 Last Tribes - San people|url=https://www.101lasttribes.com/tribes/san.html|access-date=2025-05-15|website=www.101lasttribes.com}}&lt;/ref&gt; Bese isiSwati kunesikhulunywa eManzini, esikhulunywa eShiselweni, nesikhulunywa eHhoho.&lt;ref name=&quot;:2&quot;&gt;{{Cite web|last=web-lingo|date=2013-01-07|title=SA’s Eleven Official Languages: SiSwati|url=https://web-lingo.com/sas-eleven-official-languages-siswati/#:~:text=Swazi%20is%20most%20closely%20related,considered%20closer%20to%20standard%20Swazi.|access-date=2025-05-15|website=Web-lingo|language=en-ZA}}&lt;/ref&gt; IsiPedi naso sinamalinyana angaphasi kwaso anjengesiTlokwa nesiLobedu.&lt;ref&gt;{{Cite web|title=free online course|url=https://www.unisa.ac.za/static/corporate_web/Content/UnisaOpen/freeOnlineCourse/nSotho/nSotho.html#:~:text=Northern%20Sotho%20is%20based%20mainly,(Cf.|access-date=2025-05-15|website=www.unisa.ac.za}}&lt;/ref&gt; Bese kube namalimi angasiwo wendabuko, namkha amalimi wesikhuwa akhulunywako njengesiNgisi nesiBhuru. Woke amalimi la namanye angakabalwa lapha malimi akhulunywa babantu beSewula Afrika.

== Amalimi Asemthethweni ==
Amalimi aseMthethweni eSewula Afrika siNdebele, isiZulu, isiSwati, isiXhosa, isiSuthu, isiPedi, isiTswana, isiVenda, isiTsonga okumalimi wendabuko, bese kuba siBhuru nesiNgisi. Ithebula elingenzasi litjengisa isibalo sabantu abakhuluma amalimi asemthethweni eSewula Afrika namaphesente wabalikhulumako esibalweni sabo boke abantu abahlala eSewula Afrika ngokweembalobalo zango-2022. &lt;ref name=&quot;:1&quot;&gt;https://en.wikipedia.org/wiki/Languages_of_South_Africa#cite_note-EthnologueZA-7&lt;/ref&gt;
{| class=&quot;wikitable sortable mw-collapsible&quot;
|+
! rowspan=&quot;2&quot; |Ilimi
! colspan=&quot;2&quot; |Ilimi lebele&lt;ref name=&quot;:1&quot; /&gt;
! colspan=&quot;2&quot; |Ilimi lesibili&lt;ref name=&quot;:1&quot; /&gt;
! colspan=&quot;2&quot; |Ilimi lesithathu&lt;ref name=&quot;:1&quot; /&gt;
|-
!Isibalo
!Amaphesente
!Isibalo
!Amaphesente
!Isibalo
!Amaphesente
|-
|IsiZulu
|11,587,374
|22.7%
|15,700,000
|30.8%
|27,300,000
|46%
|-
|IsiXhosa
|8,154,258
|16.0%
|11,000,000
|21.6%
|19,150,000
|33%
|-
|IsiVenda
|1,209,388
|2.4%
|1,700,000
|3.3%
|2,910,000
|5%
|-
|IsiTswana
|4,067,248
|8.0%
|7,700,000
|15.1%
|11,770,000
|20%
|-
|IsiTsonga
|2,277,148
|4.5%
|3,400,000
|6.6%
|5,680,000
|10%
|-
|IsiSwati
|1,297,046
|2.5%
|2,400,000
|4.7%
|3,700,000
|6%
|-
|IsiSuthu
|3,849,563
|7.6%
|7,900,000
|15.5%
|11,750,000
|20%
|-
|IsiPedi
|4,618,576
|9.1%
|9,100,000
|17.8%
|13,720,000
|23%
|-
|IsiNdebele
|1,090,223
|2.1%
|1,400,000
|2.7%
|2,490,000
|4%
|-
|IsiNgisi
|4,892,623
|9.6%
|14,000,000
|27.4%
|19,640,000
|33%
|-
|Isi-Afrikaans
|6,855,082
|13.5%
|10,300,000
|20.2%
|17,160,000
|29%
|-
|Ilimi Lezandla le-SA
|234,655
|0.5%
|500,000
|1.0%
|834,655
|1.5%
|-
|Amanye Amalimi
|828,258
|1.6%
|
|
|
|
|-
|'''Isibalo Sisoke'''
|'''50,961,443'''
|'''100.0%'''
|
|
|
|
|}

== IsiNdebele ==
[[Isimumathi:Ndebele_women-1.jpg|thumb|Abomma bamaNdebele]]
IsiNdebele seSewula Afrika ngelinye lamalimi akhulunywa enarheni le. Isizathu sokuthi kuthiwe siNdebele seSewula Afrika kukuthi kunesiNdebele seZimbabwe. &lt;ref&gt;{{Cite web|last=web-lingo|date=2012-10-19|title=Ndebele: What is Ndebele?|url=https://web-lingo.com/ndebele-what-is-ndebele/#:~:text=Northern%20Ndebele,%20or%20Matabele,%20or,nineteenth%20century%20during%20the%20Mfecane.|access-date=2025-05-15|website=Web-lingo|language=en-ZA}}&lt;/ref&gt; Ngokwethebula elingehla, abantu abakhuluma isiNdebele - abasimunyileko, okulilimi lesibili nalabo okulilimi lesithathu kibo - bangaphezu kweengidi ezine. Ilimeli likhulunywa khulukhulu esifundeni seMpumalanga eendaweni ezinjengaKwaNdebele, eMalahleni, e-Middleburg, e-Belfast, kwaDlawulale nakezinye iindawo  njengesiFunda seLimpopo.I siNdebele esisemthethweni siNzunza, kodwana kusese nesiNdebele sakwaManala nesiNdebele seMoletlane. &lt;ref name=&quot;:0&quot; /&gt; AmaNdebele aziwa njengesitjhaba esithanda imibala emihle nekhanyako ongayibona endleleni abambatha ngayo nabenza ngayo imigwalo yabo.

AmaNdebele bekangaphasi kwesiqhema sabaMbo ngaphambi kobana sizijamele ngaphasi kweNgwenyama uNdebele. Ngikho namhlanjesi kunezici ezifanako phakathi kwelimi lesiNdebele nelimi lesiHlubi, isiBhaca, isiMpondo nesiMpondomise.  Ngemva kwesikhathi uNdebele wabeletha uMkhalangana owabeletha umNtungwa. Ngemva kwesikhathi umNtungwa wabeletha uNjonono. UNjonono wabeletha uNanasi, uNanasi wabeletha uMafana. UMafana wabeletha uMhlanga owabeletha uMusi. Kusesikhathini seNgwenyama uMusi lapha amaNdebele ahlukana khona waba maNzunza namaNala. AmaNdebele akheka ngaleyondlela sele ahlala eSewula Afrika nje. &lt;ref&gt;https://en.wikipedia.org/wiki/Southern_Ndebele_language&lt;/ref&gt;

== IsiSwati ==
[[Isimumathi:Indoni_Parade_2018._Swati_Kingdom_by_Sizwe_Sibiya_(10).jpg|thumb|AmaSwati]]
IsiSwati sikhulunywa eenarheni ezimbili, eSewula Afrika neSwatini. Ngokwethebula elingehla abantu abakhuluma isiSwati eSewula Afrika  bangaphezu kweengidi ezilikhomba.&lt;ref name=&quot;:1&quot; /&gt; KunesiSwati esikhulunywa eSwatini kwaManzini, eShiselweni neHhoho.&lt;ref name=&quot;:2&quot; /&gt; Abantu abakhuluma isiSwati eSwatini babalelwa eengidini ezine. &lt;ref name=&quot;:3&quot;&gt;https://en.wikipedia.org/wiki/Zulu_language&lt;/ref&gt;

AmaSwati bewasiqhenyana esincani sabeNguni ebesaziwa bona Mangwane. Ngokukhamba kwesikhathi isiqhemesi sahlangana nesiqhenyana sabeSuthu ebesihlala endaweni namhlanjesi ebizwa bona kuseSwatini. Ngemva kwalokho bakhula baba sisizwe ngaphasi kweNgwenyama uDlamini III eyathatha iintambo eNgwenyameni uMaseko, yathatha isitjhaba yayosinzinzisa ngasemlanjeni iPongola bahlala eduze namaNdwandwe ngo-1750. UDlamini III walandelwa yiNgwenyama uNgwane III okukholelwa bona nguye owaba yiNgwenyama yokuthoma eyabusa indawo namhlanjesi ebizwa bona kuseSwatini.&lt;ref&gt;https://en.wikipedia.org/wiki/Swazi_people&lt;/ref&gt;

== IsiZulu ==
[[Isimumathi:Zulu_Krieger.jpg|thumb|Abobaba bamaZulu bayagida]]
IsiZulu ngelinye lamalimi adumileko asemthethweni eSewula Afrika elikhulunywa babantu ababgaogezu kweengidi ezimatjhumi amahlanu, kuthi labo abalimunyileko bangaphezu kweengidi ezilitjhumi nanye. &lt;ref name=&quot;:1&quot; /&gt; IsiZulu sikhulunywa khulu KwaZulu Natal, esiFundeni se-Gauteng nakezinye iimfunda.

Umuntu owadlala indima ekulu ekwakhekeni kwesitjhaba samaZulu yiNgwenyama uShaka. UShaka walwa neentjhaba ezincani nezikulu zabeNguni kuhlanganise namaNdwandwe wazihlula. Ngemva kwalokho wazibiza ngoZulu obekangukhokho omkhulu wesitjhaba abelethelwa kiso. Iintjhabezi zahlangana kwavela ilimi lesiZulu.&lt;ref name=&quot;:3&quot; /&gt;
== IsiXhosa ==
[[Isimumathi:Xhosa_traditionally_dressed_women.jpg|thumb|250x250px|Abomma bamaXhosa]]
IsiXhosa naso singelinye lamalimi weSewula Afrika asemthethweni. IsiXhosa sikhulunywa babantu abangaphezu kweengidi ezimatjhumi amathathu nobunane, kuthi labo okulimi labo lokubelethwa bangaphezu kweengidi ezibunane. &lt;ref name=&quot;:1&quot; /&gt; IsiXhosa sikhulunywa khulukhulu esiFundeni seTjingalanga Kapa, eTlhagwini  Kapa nesiFundeni se-Gauteng.&lt;ref&gt;{{Cite web|last=Alexander|first=Mary|date=2025-04-06|title=The languages of South Africa|url=https://southafrica-info.com/arts-culture/11-languages-south-africa/#:~:text=Among%20South%20Africa's%20population%20groups,),%20based%20on%20Census%202022.|access-date=2025-05-23|website=South Africa Gateway|language=en-GB}}&lt;/ref&gt;

Ekadeni bekuneenqhema zabeNguni ezakha ubuhlobo neentjhaba zabaThwa nabaKhoekhoe. Ngokukhamba kwesikhathi iintjhabezi zahlangana zaba sisizwe ngaphasi kokubusa kweNgwenyama uTshawe owahlula isitjhaba samaCirha namaJwarha. Ngemva kwalokho wahlanganisa zoke iintjhaba ezincani kuhlanganise nesabaKhoekhoe. Labeletheka njalo-ke ilimi lesiXhosa.&lt;ref&gt;https://en.wikipedia.org/wiki/Xhosa_people&lt;/ref&gt;

== IsiSuthu ==
[[Isimumathi:Sotho_regalia.jpg|thumb|Abobaba babeSuthu]]
IsiSuthu lilimi elisemthethweni eSewula Afrika elikhunywa babantu abangaphezu kweengidi ezimatjhumi amabili nambili. Okulilmi labo abalimunyileko bangaphezu kweengidi ezintathu. &lt;ref name=&quot;:1&quot; /&gt; IsiSuthu sikhulunywa khulu enarheni yeLesotho, kanti eSewula Afrikapha sikhulunywa khulukhulu esiFundeni seFreestate, seGauteng. Umhlobo lo wesiSuthu ubizwa ngokobana siSuthu seSewula ngombana uhlukaniswa nesiSuthu seTlhagwini - okusiPedi, nesiSuthu seTjingalanga - okusiTswana.

Emandulo abeSuthu beza eSewula Afrika bavela eTlhagwini njengezinye iintjhaba bafika bahlala etlhagwini yeSewula Afrika. Bafika baba ziinqhenyana ezinjengaba-Taung, aba-Sia, aba-Fokeng, ama-Kgolokoe naba-Kwena nezinye iinqenyana. Kuhlekuhle umndeni webukhosini eLesotho mndeni wabaKwena. AbeSuthwaba ngibo-ke ababanikazi belimi lesiSuthu esikhulunywa eSewula Afrika neLesotho.&lt;ref&gt;{{Cite web|title=SOUTHERN SESOTHO - South African Language Southern Sesotho|url=https://www.sa-venues.com/language-southern-sesotho.htm|access-date=2025-05-26|website=www.sa-venues.com}}&lt;/ref&gt;

== IsiTswana ==
[[Isimumathi:Tswana_Dancers_3.jpg|thumb|Isiqhema esigidako sabaTswana]]
IsiTswana nalo ngelinye lamalimi asesiqhemeni sesiSuthu seTjingalanga esikhulunywa eSewula Afrika neBotswana. Abantu abasikhulumako eSewula Afrika bangaphezu kweengidi ezimatjhumi amabili nantathu, abalimunyileko bangaphezu kweengidi ezine.&lt;ref name=&quot;:1&quot; /&gt; isiTswana sikhulunywa khulu enarheni yeBotswana kanti eSewula Afrika sikhulunywa khulu esiFundeni seTlhagwini-Tjhingalanga, neGauteng.

Emandulo abeTswana bebangaphasi kwesiqhema sabeSuthu nabazakufika eSewula Afrika bavela eTlhagwini ne-Afrika. Bafika baba ziinqhenyana ezinjengaba-Taung, aba-Sia, aba-Fokeng, ama-Kgolokoe nabaKwena kunye nezinye iinqhenyana. Bafika endaweni ebizwa ngokobana yiBotswana namhlanjesi, balwa nabaThwa babahlula, bese bakha umbuso wabaTswana. Ngibo-ke namhlanjesi ababanikazi belimi lesiTswana.&lt;ref&gt;{{Cite web|title=AFRICA {{!}} 101 Last Tribes - Tswana people|url=http://www.101lasttribes.com/tribes/tswana.html|access-date=2025-05-26|website=www.101lasttribes.com}}&lt;/ref&gt;

== IsiPedi ==
[[Isimumathi:Pedi_Living_Culture_Route,_Limpopo,_South_Africa_(2417712111).jpg|thumb|Umuzi wesiPedi]]
IsiPedi ([https://www.sahistory.org.za/article/pedi Sepedi]) nalo ngelinye lamalimi angaphasi kwesiSuthu atloliswe ngokomthetho eSewula Afrika, begodu saziwa ngokuthi siSuthu seTlhagwini. &lt;ref name=&quot;:4&quot;&gt;{{Cite web|title=AFRICA {{!}} 101 Last Tribes - Pedi people|url=http://www.101lasttribes.com/tribes/pedi.html|access-date=2025-05-26|website=www.101lasttribes.com}}&lt;/ref&gt; Ilimeli likhulunywa khulukhulu esiFundeni seLimpopo neseGauteng babantu abalinganiswela eengidini ezimatjhumi amabili nekhomba.&lt;ref name=&quot;:1&quot; /&gt;

Ekadeni isiqhemesi besiyingcenye yesiqhema sabeSuthu, kwathi nakukhamba ezinye iinqhema sona sasala ngetlhagwini yeSewula Afrika. Sineenqhenyana ezinengana okucatjangelwa bona sikhuluma amalinyana amatjhumi amathathu. Abanye bathi isiSuthu seTlhagwini akusiso isiPedi kodwana lilimi elihlukileko. &lt;ref name=&quot;:4&quot; /&gt;
== IsiVenda ==
[[Isimumathi:Venda_culture,_Limpopo,_South_Africa_(8714283418).jpg|thumb|251x251px|Izindlu zamaVenda]]
Elinye lamalimi atloliswe ngokomthetho eSewula Afrika siVenda. Abantu abakhuluma isiVenda balinganiselwa eengidini ezihlanu. &lt;ref name=&quot;:1&quot; /&gt; IsiVenda sikhulunywa khulu esiFundeni seLimpopo ngetlhagwini ngitjho nesiFundeni seGauteng. Nawulilemukisisa kuhle ilimeli linezici ezivela elimini lesiShona nelesiTokwa.

Ekadeni isiqhemesi kukholelwa bona sathoma ukuba khona nakusabusa uMpuso weMapungubwe, kwathi nakuwa umbuso lo kuvuka umbuso weZimbabwe sathutha sayokuhlala endaweni namhlanjesi ebizwa ngokobana kuseZimbabwe. Sakhamba isikhathi, isiqhemesi sathutha eZimbabwe sehla seyama umlambo weZambezi sazitholela indawo sayithiya ngokuthi yi-D'zata. Kusukela ngalesosikhathi umbuso wabo uye wannzinza kwabusa amakhosi wawo ngokulandelana kwawo. Namhlanjesi ngibo ababanikazi belimi lesiVenda. &lt;ref&gt;{{Cite web|title=Venda - African Tribe - Venda Culture|url=https://www.krugerpark.co.za/africa_venda.html|access-date=2025-05-26|website=www.krugerpark.co.za}}&lt;/ref&gt;

== IsiTsonga ==
[[Isimumathi:Tsonga_women_in_South_Africa.jpg|thumb|Abomma bambethe isiTsonga]]
IsiTsonga ngelinye lamalimi akhulunywa eSewula Afrika atloliswe ngokomthetho. Ilimeli likhulunywa babantu abangaphezu kweengidi ezilitjhumi nanye. IsiTsonga sikhulunywa  khulukhulu esifundeni seLimpopo neseGauteng, bese kube nesiTsonga esikhulunywa eMozambique. &lt;ref name=&quot;:1&quot; /&gt;

Abantwaba bebasiqhema sabeNguni abathoma lokha uSoshangane ebekuyinduna kaShaka abalekela enarheni yangepumalanga. Bathi nabafika lapho bazakhela umbuso omkhulu nedorhobho elibizwa bona yiGaza. Bfika bahlula izizwe ezinengi abazithola lapho njengesizwe samaNdawu, amaTonga, amaTjopi amaSena nezinye. Ilimi labo lesiNguni lahlangana nesiTonga namalimi walapho laba siTsonga. Ngokukhamba kwesikhathi umbuso lo wahlukana, amanye amaTsonga athuthela ngapha ngendaweni yeSewula Afrika.&lt;ref&gt;{{Cite web|title=Shangaan Tsonga - Nguni People, Tribe - South Africa...|url=https://www.krugerpark.co.za/africa_shangaan_tsonga.html|access-date=2025-05-26|website=www.krugerpark.co.za}}&lt;/ref&gt;

== I-''Afrikaans'' ==
[[Isimumathi:Boer_Family_with_a_wagon_-_false_colour_image.jpg|thumb|AmaBhuru wakade]]
I-Afrikaans namkha isiBhuru mhlobo welimi lamakhuwa angasiwo wendabuko weSewula Afrika. Nalo litlolisiwe ngokomthetho begodu likhulunywa babantu abangaphezu kweengidi ezimatjhumi amathathu nane. &lt;ref name=&quot;:1&quot; /&gt; I-Afrikaans ikhulunywa khulu eemfundeni zangeTjingalanga Kapa, eGauteng nakezinye iimfunda.

Ilimi le-Afrikaans livela elimini lesiDatjhi. AmaDatjhi afika eSewula Afrika lokha uJan Van Riebeeck obekasebenzela i-VOC (''[https://www.worldhistory.org/Dutch_East_India_Company/ Vereenigde Oost-Indische Compagnie]'') afika nabantu bekhabo ngo-1652, bafika bahlala endaweni abayibiza bona yi-''Cape of Good Hope''. Bafika lapho bahlangana nesitjhaba sabaKhoekhoe. Ngokukhamba kwesikhathi ilimi lesiDatjhi lahlangana nelesiKhoe kunye namanye amalimi kwakheka ilimi namhlanjesi elibizwa ngokuthi yi-Afrikaans namkha isiBhuru, okulilimi elisemthethweni bekube njenganje eSewula Afrika.&lt;ref&gt;{{Cite web|title=The Dutch Settlement {{!}} South African History Online|url=https://www.sahistory.org.za/article/dutch-settlement|access-date=2025-05-26|website=www.sahistory.org.za}}&lt;/ref&gt;&lt;ref&gt;{{Cite web|date=2023-10-13|title=‘The language we know as Afrikaans today owes much to the enslaved people who spoke it’—Read an excerpt from Coloured: How Classification Became Culture|url=https://johannesburgreviewofbooks.com/2023/10/13/the-language-we-know-as-afrikaans-today-owes-much-to-the-enslaved-people-who-spoke-it-read-an-excerpt-from-coloured-how-classification-became-culture/|access-date=2025-05-26|website=The Johannesburg Review of Books|language=en-US}}&lt;/ref&gt;

== IsiNgisi ==
[[Isimumathi:English_settlers_landing_in_Virginia_1607_Image_from_page_42_of_A_junior_class_history_of_the_United_States;_to_which_are_added_the_Declaration_of_independence,_and_the_Constitution_of_the_United_States_(1899).jpg|thumb|AmaNgisi bokufika]]
IsiNgisi kuphela kwelimi elikhulunywa khulu ukudlula woke eSewula Afrika. Sikhulunywa babantu abangaphezu kweengidi ezimatjhumi amathathu nekhomba. Ilimeli ngilo esisetjenziswa khulu emazikweni wezefundo, wezepolotiki, wezeemali, wezamaphilo namanye.

Safika njani isiNgisi eSewula Afrika? IsiNgisi besele sikhona nakufika amaBhuru ngo-1652 ngombana nakufika amaDatjhi athola u-Atjhumato obekayikosi yabaKhoekhoe besele abuya eBantam ngo-1630, akghona ukukhuluma isiNgisi nesiDatjhi. &lt;ref&gt;{{Cite web|title=Autshumao (Herry the Strandloper) {{!}} South African History Online|url=https://www.sahistory.org.za/people/autshumao-herry-strandloper#:~:text=Autshumao%20also%20known%20as%20Herry%20the%20strandloper,who%20were%20engaged%20in%20a%20trading%20relationship.|access-date=2025-05-26|website=www.sahistory.org.za}}&lt;/ref&gt; Nanyana isiNgisi besele sikhulunywa eSewula Afrika, amaNgisi wokufika nokuhlala eza mva kunamaDatjhi. Kwathoma mhlokho bona isiNgisi sikhulunywe eSewula Afrika.

== Ilimi Lezandla ==
Ilimi lezandla ngelinye lamalimi akhulunywa eSewula Afrika. Likhulunywa babantu abangaphesu kwesigidi sinye, begodu kunabantu abama-234,655 okulilimi labo lokuthoma.

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>59jw7z31jw471yofda9qazmm0pf3n2o</sha1>
    </revision>
    <revision>
      <id>3156</id>
      <parentid>3083</parentid>
      <timestamp>2025-06-17T08:12:38Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <origin>3156</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="17556" sha1="nsfnuprbfj3ocg62deddxp9vg6xbhpw" xml:space="preserve">[[Isimumathi:Flag of South Africa.svg|thumb|Iflarha leSewula Afrika]]
'''Inarha yeSewula Afrika''' yinarha enabantu abanamasiko nabaneenzinda ezihlukahlukeneko, nabakhuluma amalimi ahlukahlukeneko. Inengi labantu enarheni le lisesiqhemeni sokuthoma sabantu abakhuluma amalimi angaphasi kwesiNguni, okusiZulu, isiXhosa, [[Isindebele|isiNdebele]] nesiSwati. Bese isiqhema sesibili ngobukhulu ngesikhuluma amalimi wesiSuthu, okusiTswana, isiPedi (okusiSuthu seTlhagwini) nesiSuthu (okusiSuthu seSewula, namkha isiSuthu sesiShweshwe). Bese kunesiqhema esikhuluma isiTsonga nesiqhema esikhuluma isiVenda.&lt;ref&gt;{{Cite web|date=2025-05-14|title=South Africa - Languages, Dialects, Afrikaans {{!}} Britannica|url=https://www.britannica.com/place/South-Africa/Languages|access-date=2025-05-15|website=www.britannica.com|language=en}}&lt;/ref&gt;

Ngaphezu kwamalimi abaliweko la kunamalimi ahlobene nawo. Ngokwesibonelo, esiNdebeleni kunesiNala, nesiNdebele seMoletlane. &lt;ref name=&quot;:0&quot;&gt;{{Cite web|title=Ndebele people, traditions culture|url=https://www.africancraftsmarket.com/african-tribes/ndebele-people.html|access-date=2025-05-15|website=www.africancraftsmarket.com}}&lt;/ref&gt; EsiXhoseni kube nesiNgqika, isiThembu, isiBhaca, isiGcaleka, isiMpondo, isiMpondomise, isiMfengu nesiBomvana.&lt;ref&gt;{{Cite web|title=XHOSA - South African Language Xhosa|url=https://www.sa-venues.com/language-xhosa.htm#:~:text=Xhosa%20has%20been%20grouped%20into,yet%20pretty-sounding,%20language.|access-date=2025-05-15|website=www.sa-venues.com}}&lt;/ref&gt; Kusese nelimi lesiThwa elibandaka isi-Khoe, isi-Tu isi-Kx'a, namanye amalimi.&lt;ref&gt;{{Cite web|title=AFRICA {{!}} 101 Last Tribes - San people|url=https://www.101lasttribes.com/tribes/san.html|access-date=2025-05-15|website=www.101lasttribes.com}}&lt;/ref&gt; Bese isiSwati kunesikhulunywa eManzini, esikhulunywa eShiselweni, nesikhulunywa eHhoho.&lt;ref name=&quot;:2&quot;&gt;{{Cite web|last=web-lingo|date=2013-01-07|title=SA’s Eleven Official Languages: SiSwati|url=https://web-lingo.com/sas-eleven-official-languages-siswati/#:~:text=Swazi%20is%20most%20closely%20related,considered%20closer%20to%20standard%20Swazi.|access-date=2025-05-15|website=Web-lingo|language=en-ZA}}&lt;/ref&gt; IsiPedi naso sinamalinyana angaphasi kwaso anjengesiTlokwa nesiLobedu.&lt;ref&gt;{{Cite web|title=free online course|url=https://www.unisa.ac.za/static/corporate_web/Content/UnisaOpen/freeOnlineCourse/nSotho/nSotho.html#:~:text=Northern%20Sotho%20is%20based%20mainly,(Cf.|access-date=2025-05-15|website=www.unisa.ac.za}}&lt;/ref&gt; Bese kube namalimi angasiwo wendabuko, namkha amalimi wesikhuwa akhulunywako njengesiNgisi nesiBhuru. Woke amalimi la namanye angakabalwa lapha malimi akhulunywa babantu beSewula Afrika.

== Amalimi Asemthethweni ==
Amalimi aseMthethweni eSewula Afrika siNdebele, isiZulu, isiSwati, isiXhosa, isiSuthu, isiPedi, isiTswana, isiVenda, isiTsonga okumalimi wendabuko, bese kuba siBhuru nesiNgisi. Ithebula elingenzasi litjengisa isibalo sabantu abakhuluma amalimi asemthethweni eSewula Afrika namaphesente wabalikhulumako esibalweni sabo boke abantu abahlala eSewula Afrika ngokweembalobalo zango-2022. &lt;ref name=&quot;:1&quot;&gt;https://en.wikipedia.org/wiki/Languages_of_South_Africa#cite_note-EthnologueZA-7&lt;/ref&gt;
{| class=&quot;wikitable sortable mw-collapsible&quot;
|+
! rowspan=&quot;2&quot; |Ilimi
! colspan=&quot;2&quot; |Ilimi lebele&lt;ref name=&quot;:1&quot; /&gt;
! colspan=&quot;2&quot; |Ilimi lesibili&lt;ref name=&quot;:1&quot; /&gt;
! colspan=&quot;2&quot; |Ilimi lesithathu&lt;ref name=&quot;:1&quot; /&gt;
|-
!Isibalo
!Amaphesente
!Isibalo
!Amaphesente
!Isibalo
!Amaphesente
|-
|IsiZulu
|11,587,374
|22.7%
|15,700,000
|30.8%
|27,300,000
|46%
|-
|IsiXhosa
|8,154,258
|16.0%
|11,000,000
|21.6%
|19,150,000
|33%
|-
|IsiVenda
|1,209,388
|2.4%
|1,700,000
|3.3%
|2,910,000
|5%
|-
|IsiTswana
|4,067,248
|8.0%
|7,700,000
|15.1%
|11,770,000
|20%
|-
|IsiTsonga
|2,277,148
|4.5%
|3,400,000
|6.6%
|5,680,000
|10%
|-
|IsiSwati
|1,297,046
|2.5%
|2,400,000
|4.7%
|3,700,000
|6%
|-
|IsiSuthu
|3,849,563
|7.6%
|7,900,000
|15.5%
|11,750,000
|20%
|-
|IsiPedi
|4,618,576
|9.1%
|9,100,000
|17.8%
|13,720,000
|23%
|-
|IsiNdebele
|1,090,223
|2.1%
|1,400,000
|2.7%
|2,490,000
|4%
|-
|IsiNgisi
|4,892,623
|9.6%
|14,000,000
|27.4%
|19,640,000
|33%
|-
|Isi-Afrikaans
|6,855,082
|13.5%
|10,300,000
|20.2%
|17,160,000
|29%
|-
|Ilimi Lezandla le-SA
|234,655
|0.5%
|500,000
|1.0%
|834,655
|1.5%
|-
|Amanye Amalimi
|828,258
|1.6%
|
|
|
|
|-
|'''Isibalo Sisoke'''
|'''50,961,443'''
|'''100.0%'''
|
|
|
|
|}

== IsiNdebele ==
[[Isimumathi:Ndebele_women-1.jpg|thumb|Abomma bamaNdebele]]
IsiNdebele seSewula Afrika ngelinye lamalimi akhulunywa enarheni le. Isizathu sokuthi kuthiwe siNdebele seSewula Afrika kukuthi kunesiNdebele seZimbabwe. &lt;ref&gt;{{Cite web|last=web-lingo|date=2012-10-19|title=Ndebele: What is Ndebele?|url=https://web-lingo.com/ndebele-what-is-ndebele/#:~:text=Northern%20Ndebele,%20or%20Matabele,%20or,nineteenth%20century%20during%20the%20Mfecane.|access-date=2025-05-15|website=Web-lingo|language=en-ZA}}&lt;/ref&gt; Ngokwethebula elingehla, abantu abakhuluma isiNdebele - abasimunyileko, okulilimi lesibili nalabo okulilimi lesithathu kibo - bangaphezu kweengidi ezine. Ilimeli likhulunywa khulukhulu esifundeni seMpumalanga eendaweni ezinjengaKwaNdebele, eMalahleni, e-Middleburg, e-Belfast, kwaDlawulale nakezinye iindawo  njengesiFunda seLimpopo.I siNdebele esisemthethweni siNzunza, kodwana kusese nesiNdebele sakwaManala nesiNdebele seMoletlane. &lt;ref name=&quot;:0&quot; /&gt; AmaNdebele aziwa njengesitjhaba esithanda imibala emihle nekhanyako ongayibona endleleni abambatha ngayo nabenza ngayo imigwalo yabo.

AmaNdebele bekangaphasi kwesiqhema sabaMbo ngaphambi kobana sizijamele ngaphasi kweNgwenyama uNdebele. Ngikho namhlanjesi kunezici ezifanako phakathi kwelimi lesiNdebele nelimi lesiHlubi, isiBhaca, isiMpondo nesiMpondomise.  Ngemva kwesikhathi uNdebele wabeletha uMkhalangana owabeletha umNtungwa. Ngemva kwesikhathi umNtungwa wabeletha uNjonono. UNjonono wabeletha uNanasi, uNanasi wabeletha uMafana. UMafana wabeletha uMhlanga owabeletha uMusi. Kusesikhathini seNgwenyama uMusi lapha amaNdebele ahlukana khona waba maNzunza namaNala. AmaNdebele akheka ngaleyondlela sele ahlala eSewula Afrika nje. &lt;ref&gt;https://en.wikipedia.org/wiki/Southern_Ndebele_language&lt;/ref&gt;

== IsiSwati ==
[[Isimumathi:Indoni_Parade_2018._Swati_Kingdom_by_Sizwe_Sibiya_(10).jpg|thumb|AmaSwati]]
IsiSwati sikhulunywa eenarheni ezimbili, eSewula Afrika neSwatini. Ngokwethebula elingehla abantu abakhuluma isiSwati eSewula Afrika  bangaphezu kweengidi ezilikhomba.&lt;ref name=&quot;:1&quot; /&gt; KunesiSwati esikhulunywa eSwatini kwaManzini, eShiselweni neHhoho.&lt;ref name=&quot;:2&quot; /&gt; Abantu abakhuluma isiSwati eSwatini babalelwa eengidini ezine. &lt;ref name=&quot;:3&quot;&gt;https://en.wikipedia.org/wiki/Zulu_language&lt;/ref&gt;

AmaSwati bewasiqhenyana esincani sabeNguni ebesaziwa bona Mangwane. Ngokukhamba kwesikhathi isiqhemesi sahlangana nesiqhenyana sabeSuthu ebesihlala endaweni namhlanjesi ebizwa bona kuseSwatini. Ngemva kwalokho bakhula baba sisizwe ngaphasi kweNgwenyama uDlamini III eyathatha iintambo eNgwenyameni uMaseko, yathatha isitjhaba yayosinzinzisa ngasemlanjeni iPongola bahlala eduze namaNdwandwe ngo-1750. UDlamini III walandelwa yiNgwenyama uNgwane III okukholelwa bona nguye owaba yiNgwenyama yokuthoma eyabusa indawo namhlanjesi ebizwa bona kuseSwatini.&lt;ref&gt;https://en.wikipedia.org/wiki/Swazi_people&lt;/ref&gt;

== IsiZulu ==
[[Isimumathi:Zulu_Krieger.jpg|thumb|Abobaba bamaZulu bayagida]]
IsiZulu ngelinye lamalimi adumileko asemthethweni eSewula Afrika elikhulunywa babantu ababgaogezu kweengidi ezimatjhumi amahlanu, kuthi labo abalimunyileko bangaphezu kweengidi ezilitjhumi nanye. &lt;ref name=&quot;:1&quot; /&gt; IsiZulu sikhulunywa khulu KwaZulu Natal, esiFundeni se-Gauteng nakezinye iimfunda.

Umuntu owadlala indima ekulu ekwakhekeni kwesitjhaba samaZulu yiNgwenyama uShaka. UShaka walwa neentjhaba ezincani nezikulu zabeNguni kuhlanganise namaNdwandwe wazihlula. Ngemva kwalokho wazibiza ngoZulu obekangukhokho omkhulu wesitjhaba abelethelwa kiso. Iintjhabezi zahlangana kwavela ilimi lesiZulu.&lt;ref name=&quot;:3&quot; /&gt;
== IsiXhosa ==
[[Isimumathi:Xhosa_traditionally_dressed_women.jpg|thumb|250x250px|Abomma bamaXhosa]]
IsiXhosa naso singelinye lamalimi weSewula Afrika asemthethweni. IsiXhosa sikhulunywa babantu abangaphezu kweengidi ezimatjhumi amathathu nobunane, kuthi labo okulimi labo lokubelethwa bangaphezu kweengidi ezibunane. &lt;ref name=&quot;:1&quot; /&gt; IsiXhosa sikhulunywa khulukhulu esiFundeni seTjingalanga Kapa, eTlhagwini  Kapa nesiFundeni se-Gauteng.&lt;ref&gt;{{Cite web|last=Alexander|first=Mary|date=2025-04-06|title=The languages of South Africa|url=https://southafrica-info.com/arts-culture/11-languages-south-africa/#:~:text=Among%20South%20Africa's%20population%20groups,),%20based%20on%20Census%202022.|access-date=2025-05-23|website=South Africa Gateway|language=en-GB}}&lt;/ref&gt;

Ekadeni bekuneenqhema zabeNguni ezakha ubuhlobo neentjhaba zabaThwa nabaKhoekhoe. Ngokukhamba kwesikhathi iintjhabezi zahlangana zaba sisizwe ngaphasi kokubusa kweNgwenyama uTshawe owahlula isitjhaba samaCirha namaJwarha. Ngemva kwalokho wahlanganisa zoke iintjhaba ezincani kuhlanganise nesabaKhoekhoe. Labeletheka njalo-ke ilimi lesiXhosa.&lt;ref&gt;https://en.wikipedia.org/wiki/Xhosa_people&lt;/ref&gt;

== IsiSuthu ==
[[Isimumathi:Sotho_regalia.jpg|thumb|Abobaba babeSuthu]]
IsiSuthu lilimi elisemthethweni eSewula Afrika elikhunywa babantu abangaphezu kweengidi ezimatjhumi amabili nambili. Okulilmi labo abalimunyileko bangaphezu kweengidi ezintathu. &lt;ref name=&quot;:1&quot; /&gt; IsiSuthu sikhulunywa khulu enarheni yeLesotho, kanti eSewula Afrikapha sikhulunywa khulukhulu esiFundeni seFreestate, seGauteng. Umhlobo lo wesiSuthu ubizwa ngokobana siSuthu seSewula ngombana uhlukaniswa nesiSuthu seTlhagwini - okusiPedi, nesiSuthu seTjingalanga - okusiTswana.

Emandulo abeSuthu beza eSewula Afrika bavela eTlhagwini njengezinye iintjhaba bafika bahlala etlhagwini yeSewula Afrika. Bafika baba ziinqhenyana ezinjengaba-Taung, aba-Sia, aba-Fokeng, ama-Kgolokoe naba-Kwena nezinye iinqenyana. Kuhlekuhle umndeni webukhosini eLesotho mndeni wabaKwena. AbeSuthwaba ngibo-ke ababanikazi belimi lesiSuthu esikhulunywa eSewula Afrika neLesotho.&lt;ref&gt;{{Cite web|title=SOUTHERN SESOTHO - South African Language Southern Sesotho|url=https://www.sa-venues.com/language-southern-sesotho.htm|access-date=2025-05-26|website=www.sa-venues.com}}&lt;/ref&gt;

== IsiTswana ==
[[Isimumathi:Tswana_Dancers_3.jpg|thumb|Isiqhema esigidako sabaTswana]]
IsiTswana nalo ngelinye lamalimi asesiqhemeni sesiSuthu seTjingalanga esikhulunywa eSewula Afrika neBotswana. Abantu abasikhulumako eSewula Afrika bangaphezu kweengidi ezimatjhumi amabili nantathu, abalimunyileko bangaphezu kweengidi ezine.&lt;ref name=&quot;:1&quot; /&gt; isiTswana sikhulunywa khulu enarheni yeBotswana kanti eSewula Afrika sikhulunywa khulu esiFundeni seTlhagwini-Tjhingalanga, neGauteng.

Emandulo abeTswana bebangaphasi kwesiqhema sabeSuthu nabazakufika eSewula Afrika bavela eTlhagwini ne-Afrika. Bafika baba ziinqhenyana ezinjengaba-Taung, aba-Sia, aba-Fokeng, ama-Kgolokoe nabaKwena kunye nezinye iinqhenyana. Bafika endaweni ebizwa ngokobana yiBotswana namhlanjesi, balwa nabaThwa babahlula, bese bakha umbuso wabaTswana. Ngibo-ke namhlanjesi ababanikazi belimi lesiTswana.&lt;ref&gt;{{Cite web|title=AFRICA {{!}} 101 Last Tribes - Tswana people|url=http://www.101lasttribes.com/tribes/tswana.html|access-date=2025-05-26|website=www.101lasttribes.com}}&lt;/ref&gt;

== IsiPedi ==
[[Isimumathi:Pedi_Living_Culture_Route,_Limpopo,_South_Africa_(2417712111).jpg|thumb|Umuzi wesiPedi]]
IsiPedi ([https://www.sahistory.org.za/article/pedi Sepedi]) nalo ngelinye lamalimi angaphasi kwesiSuthu atloliswe ngokomthetho eSewula Afrika, begodu saziwa ngokuthi siSuthu seTlhagwini. &lt;ref name=&quot;:4&quot;&gt;{{Cite web|title=AFRICA {{!}} 101 Last Tribes - Pedi people|url=http://www.101lasttribes.com/tribes/pedi.html|access-date=2025-05-26|website=www.101lasttribes.com}}&lt;/ref&gt; Ilimeli likhulunywa khulukhulu esiFundeni seLimpopo neseGauteng babantu abalinganiswela eengidini ezimatjhumi amabili nekhomba.&lt;ref name=&quot;:1&quot; /&gt;

Ekadeni isiqhemesi besiyingcenye yesiqhema sabeSuthu, kwathi nakukhamba ezinye iinqhema sona sasala ngetlhagwini yeSewula Afrika. Sineenqhenyana ezinengana okucatjangelwa bona sikhuluma amalinyana amatjhumi amathathu. Abanye bathi isiSuthu seTlhagwini akusiso isiPedi kodwana lilimi elihlukileko. &lt;ref name=&quot;:4&quot; /&gt;
== IsiVenda ==
[[Isimumathi:Venda_culture,_Limpopo,_South_Africa_(8714283418).jpg|thumb|251x251px|Izindlu zamaVenda]]
Elinye lamalimi atloliswe ngokomthetho eSewula Afrika siVenda. Abantu abakhuluma isiVenda balinganiselwa eengidini ezihlanu. &lt;ref name=&quot;:1&quot; /&gt; IsiVenda sikhulunywa khulu esiFundeni seLimpopo ngetlhagwini ngitjho nesiFundeni seGauteng. Nawulilemukisisa kuhle ilimeli linezici ezivela elimini lesiShona nelesiTokwa.

Ekadeni isiqhemesi kukholelwa bona sathoma ukuba khona nakusabusa uMpuso weMapungubwe, kwathi nakuwa umbuso lo kuvuka umbuso weZimbabwe sathutha sayokuhlala endaweni namhlanjesi ebizwa ngokobana kuseZimbabwe. Sakhamba isikhathi, isiqhemesi sathutha eZimbabwe sehla seyama umlambo weZambezi sazitholela indawo sayithiya ngokuthi yi-D'zata. Kusukela ngalesosikhathi umbuso wabo uye wannzinza kwabusa amakhosi wawo ngokulandelana kwawo. Namhlanjesi ngibo ababanikazi belimi lesiVenda. &lt;ref&gt;{{Cite web|title=Venda - African Tribe - Venda Culture|url=https://www.krugerpark.co.za/africa_venda.html|access-date=2025-05-26|website=www.krugerpark.co.za}}&lt;/ref&gt;

== IsiTsonga ==
[[Isimumathi:Tsonga_women_in_South_Africa.jpg|thumb|Abomma bambethe isiTsonga]]
IsiTsonga ngelinye lamalimi akhulunywa eSewula Afrika atloliswe ngokomthetho. Ilimeli likhulunywa babantu abangaphezu kweengidi ezilitjhumi nanye. IsiTsonga sikhulunywa  khulukhulu esifundeni seLimpopo neseGauteng, bese kube nesiTsonga esikhulunywa eMozambique. &lt;ref name=&quot;:1&quot; /&gt;

Abantwaba bebasiqhema sabeNguni abathoma lokha uSoshangane ebekuyinduna kaShaka abalekela enarheni yangepumalanga. Bathi nabafika lapho bazakhela umbuso omkhulu nedorhobho elibizwa bona yiGaza. Bfika bahlula izizwe ezinengi abazithola lapho njengesizwe samaNdawu, amaTonga, amaTjopi amaSena nezinye. Ilimi labo lesiNguni lahlangana nesiTonga namalimi walapho laba siTsonga. Ngokukhamba kwesikhathi umbuso lo wahlukana, amanye amaTsonga athuthela ngapha ngendaweni yeSewula Afrika.&lt;ref&gt;{{Cite web|title=Shangaan Tsonga - Nguni People, Tribe - South Africa...|url=https://www.krugerpark.co.za/africa_shangaan_tsonga.html|access-date=2025-05-26|website=www.krugerpark.co.za}}&lt;/ref&gt;

== I-''Afrikaans'' ==
[[Isimumathi:Boer_Family_with_a_wagon_-_false_colour_image.jpg|thumb|AmaBhuru wakade]]
I-Afrikaans namkha isiBhuru mhlobo welimi lamakhuwa angasiwo wendabuko weSewula Afrika. Nalo litlolisiwe ngokomthetho begodu likhulunywa babantu abangaphezu kweengidi ezimatjhumi amathathu nane. &lt;ref name=&quot;:1&quot; /&gt; I-Afrikaans ikhulunywa khulu eemfundeni zangeTjingalanga Kapa, eGauteng nakezinye iimfunda.

Ilimi le-Afrikaans livela elimini lesiDatjhi. AmaDatjhi afika eSewula Afrika lokha uJan Van Riebeeck obekasebenzela i-VOC (''[https://www.worldhistory.org/Dutch_East_India_Company/ Vereenigde Oost-Indische Compagnie]'') afika nabantu bekhabo ngo-1652, bafika bahlala endaweni abayibiza bona yi-''Cape of Good Hope''. Bafika lapho bahlangana nesitjhaba sabaKhoekhoe. Ngokukhamba kwesikhathi ilimi lesiDatjhi lahlangana nelesiKhoe kunye namanye amalimi kwakheka ilimi namhlanjesi elibizwa ngokuthi yi-Afrikaans namkha isiBhuru, okulilimi elisemthethweni bekube njenganje eSewula Afrika.&lt;ref&gt;{{Cite web|title=The Dutch Settlement {{!}} South African History Online|url=https://www.sahistory.org.za/article/dutch-settlement|access-date=2025-05-26|website=www.sahistory.org.za}}&lt;/ref&gt;&lt;ref&gt;{{Cite web|date=2023-10-13|title=‘The language we know as Afrikaans today owes much to the enslaved people who spoke it’—Read an excerpt from Coloured: How Classification Became Culture|url=https://johannesburgreviewofbooks.com/2023/10/13/the-language-we-know-as-afrikaans-today-owes-much-to-the-enslaved-people-who-spoke-it-read-an-excerpt-from-coloured-how-classification-became-culture/|access-date=2025-05-26|website=The Johannesburg Review of Books|language=en-US}}&lt;/ref&gt;

== IsiNgisi ==
[[Isimumathi:English_settlers_landing_in_Virginia_1607_Image_from_page_42_of_A_junior_class_history_of_the_United_States;_to_which_are_added_the_Declaration_of_independence,_and_the_Constitution_of_the_United_States_(1899).jpg|thumb|AmaNgisi bokufika]]
IsiNgisi kuphela kwelimi elikhulunywa khulu ukudlula woke eSewula Afrika. Sikhulunywa babantu abangaphezu kweengidi ezimatjhumi amathathu nekhomba. Ilimeli ngilo esisetjenziswa khulu emazikweni wezefundo, wezepolotiki, wezeemali, wezamaphilo namanye.

Safika njani isiNgisi eSewula Afrika? IsiNgisi besele sikhona nakufika amaBhuru ngo-1652 ngombana nakufika amaDatjhi athola u-Atjhumato obekayikosi yabaKhoekhoe besele abuya eBantam ngo-1630, akghona ukukhuluma isiNgisi nesiDatjhi. &lt;ref&gt;{{Cite web|title=Autshumao (Herry the Strandloper) {{!}} South African History Online|url=https://www.sahistory.org.za/people/autshumao-herry-strandloper#:~:text=Autshumao%20also%20known%20as%20Herry%20the%20strandloper,who%20were%20engaged%20in%20a%20trading%20relationship.|access-date=2025-05-26|website=www.sahistory.org.za}}&lt;/ref&gt; Nanyana isiNgisi besele sikhulunywa eSewula Afrika, amaNgisi wokufika nokuhlala eza mva kunamaDatjhi. Kwathoma mhlokho bona isiNgisi sikhulunywe eSewula Afrika.

== Ilimi Lezandla ==
Ilimi lezandla ngelinye lamalimi akhulunywa eSewula Afrika. Likhulunywa babantu abangaphesu kwesigidi sinye, begodu kunabantu abama-234,655 okulilimi labo lokuthoma.

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>nsfnuprbfj3ocg62deddxp9vg6xbhpw</sha1>
    </revision>
    <revision>
      <id>3206</id>
      <parentid>3156</parentid>
      <timestamp>2025-06-23T12:01:22Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>3206</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="17516" sha1="aahaysyp5j6jxjc0luwbp7cby95nkom" xml:space="preserve">[[Isimumathi:Flag of South Africa.svg|thumb|Iflarha leSewula Afrika]]
'''Inarha yeSewula Afrika''' yinarha enabantu abanamasiko nabaneenzinda ezihlukahlukeneko, nabakhuluma amalimi ahlukahlukeneko. Inengi labantu enarheni le lisesiqhemeni sokuthoma sabantu abakhuluma amalimi angaphasi kwesiNguni, okusiZulu, isiXhosa, [[Isindebele|isiNdebele]] nesiSwati. Bese isiqhema sesibili ngobukhulu ngesikhuluma amalimi we-Sesotho,  Setswana, Sepedi. Bese kunesiqhema esikhuluma i-Xitsonga nesiqhema esikhuluma i-Tshivenda.&lt;ref&gt;{{Cite web|date=2025-05-14|title=South Africa - Languages, Dialects, Afrikaans {{!}} Britannica|url=https://www.britannica.com/place/South-Africa/Languages|access-date=2025-05-15|website=www.britannica.com|language=en}}&lt;/ref&gt;

Ngaphezu kwamalimi abaliweko la kunamalimi ahlobene nawo. Ngokwesibonelo, esiNdebeleni kunesiNala, nesiNdebele seMoletlane.&lt;ref name=&quot;:0&quot;&gt;{{Cite web|title=Ndebele people, traditions culture|url=https://www.africancraftsmarket.com/african-tribes/ndebele-people.html|access-date=2025-05-15|website=www.africancraftsmarket.com}}&lt;/ref&gt; EsiXhoseni kube nesiNgqika, isiThembu, isiBhaca, isiGcaleka, isiMpondo, isiMpondomise, isiMfengu nesiBomvana.&lt;ref&gt;{{Cite web|title=XHOSA - South African Language Xhosa|url=https://www.sa-venues.com/language-xhosa.htm#:~:text=Xhosa%20has%20been%20grouped%20into,yet%20pretty-sounding,%20language.|access-date=2025-05-15|website=www.sa-venues.com}}&lt;/ref&gt; Kusese nelimi lesiThwa elibandaka isi-Khoe, isi-Tu isi-Kx'a, namanye amalimi.&lt;ref&gt;{{Cite web|title=AFRICA {{!}} 101 Last Tribes - San people|url=https://www.101lasttribes.com/tribes/san.html|access-date=2025-05-15|website=www.101lasttribes.com}}&lt;/ref&gt; Bese isiSwati kunesikhulunywa eManzini, esikhulunywa eShiselweni, nesikhulunywa eHhoho.&lt;ref name=&quot;:2&quot;&gt;{{Cite web|last=web-lingo|date=2013-01-07|title=SA’s Eleven Official Languages: SiSwati|url=https://web-lingo.com/sas-eleven-official-languages-siswati/#:~:text=Swazi%20is%20most%20closely%20related,considered%20closer%20to%20standard%20Swazi.|access-date=2025-05-15|website=Web-lingo|language=en-ZA}}&lt;/ref&gt; IsiPedi naso sinamalinyana angaphasi kwaso anjengesiTlokwa nesiLobedu.&lt;ref&gt;{{Cite web|title=free online course|url=https://www.unisa.ac.za/static/corporate_web/Content/UnisaOpen/freeOnlineCourse/nSotho/nSotho.html#:~:text=Northern%20Sotho%20is%20based%20mainly,(Cf.|access-date=2025-05-15|website=www.unisa.ac.za}}&lt;/ref&gt; Bese kube namalimi angasiwo wendabuko, namkha amalimi wesikhuwa akhulunywako njengesiNgisi nesiBhuru. Woke amalimi la namanye angakabalwa lapha malimi akhulunywa babantu beSewula Afrika.

== Amalimi Asemthethweni ==
Amalimi aseMthethweni eSewula Afrika siNdebele, isiZulu, isiSwati, isiXhosa, i-Sepedi, i-Sesotho, i-Setswana, i-Tshivenda, ne-Xitsonga okumalimi wendabuko, bese kuba siBhuru nesiNgisi. Ithebula elingenzasi litjengisa isibalo sabantu abakhuluma amalimi asemthethweni eSewula Afrika namaphesente wabalikhulumako esibalweni sabo boke abantu abahlala eSewula Afrika ngokweembalobalo zango-2022.&lt;ref name=&quot;:1&quot;&gt;https://en.wikipedia.org/wiki/Languages_of_South_Africa#cite_note-EthnologueZA-7&lt;/ref&gt;
{| class=&quot;wikitable sortable mw-collapsible&quot;
|+
! rowspan=&quot;2&quot; |Ilimi
! colspan=&quot;2&quot; |Ilimi lebele&lt;ref name=&quot;:1&quot; /&gt;
! colspan=&quot;2&quot; |Ilimi lesibili&lt;ref name=&quot;:1&quot; /&gt;
! colspan=&quot;2&quot; |Ilimi lesithathu&lt;ref name=&quot;:1&quot; /&gt;
|-
!Isibalo
!Amaphesente
!Isibalo
!Amaphesente
!Isibalo
!Amaphesente
|-
|IsiZulu
|11,587,374
|22.7%
|15,700,000
|30.8%
|27,300,000
|46%
|-
|IsiXhosa
|8,154,258
|16.0%
|11,000,000
|21.6%
|19,150,000
|33%
|-
|Tshivenda
|1,209,388
|2.4%
|1,700,000
|3.3%
|2,910,000
|5%
|-
|Setswana
|4,067,248
|8.0%
|7,700,000
|15.1%
|11,770,000
|20%
|-
|Xitsonga
|2,277,148
|4.5%
|3,400,000
|6.6%
|5,680,000
|10%
|-
|IsiSwati
|1,297,046
|2.5%
|2,400,000
|4.7%
|3,700,000
|6%
|-
|Sesotho
|3,849,563
|7.6%
|7,900,000
|15.5%
|11,750,000
|20%
|-
|Sepedi
|4,618,576
|9.1%
|9,100,000
|17.8%
|13,720,000
|23%
|-
|IsiNdebele
|1,090,223
|2.1%
|1,400,000
|2.7%
|2,490,000
|4%
|-
|IsiNgisi
|4,892,623
|9.6%
|14,000,000
|27.4%
|19,640,000
|33%
|-
|IsiBhuru
|6,855,082
|13.5%
|10,300,000
|20.2%
|17,160,000
|29%
|-
|Ilimi Lezandla le-SA
|234,655
|0.5%
|500,000
|1.0%
|834,655
|1.5%
|-
|Amanye Amalimi
|828,258
|1.6%
|
|
|
|
|-
|'''Isibalo Sisoke'''
|'''50,961,443'''
|'''100.0%'''
|
|
|
|
|}

== IsiNdebele ==
[[Isimumathi:Ndebele_women-1.jpg|thumb|Abomma bamaNdebele]]
IsiNdebele seSewula Afrika ngelinye lamalimi akhulunywa enarheni le. Isizathu sokuthi kuthiwe siNdebele seSewula Afrika kukuthi kunesiNdebele seZimbabwe.&lt;ref&gt;{{Cite web|last=web-lingo|date=2012-10-19|title=Ndebele: What is Ndebele?|url=https://web-lingo.com/ndebele-what-is-ndebele/#:~:text=Northern%20Ndebele,%20or%20Matabele,%20or,nineteenth%20century%20during%20the%20Mfecane.|access-date=2025-05-15|website=Web-lingo|language=en-ZA}}&lt;/ref&gt; Ngokwethebula elingehla, abantu abakhuluma isiNdebele - abasimunyileko, okulilimi lesibili nalabo okulilimi lesithathu kibo - bangaphezu kweengidi ezine. Ilimeli likhulunywa khulukhulu esifundeni seMpumalanga eendaweni ezinjengaKwaNdebele, eMalahleni, e-Middleburg, e-Belfast, kwaDlawulale nakezinye iindawo  njengesiFunda seLimpopo.I siNdebele esisemthethweni siNzunza, kodwana kusese nesiNdebele sakwaManala nesiNdebele seMoletlane.&lt;ref name=&quot;:0&quot; /&gt; AmaNdebele aziwa njengesitjhaba esithanda imibala emihle nekhanyako ongayibona endleleni abambatha ngayo nabenza ngayo imigwalo yabo.

AmaNdebele bekangaphasi kwesiqhema sabaMbo ngaphambi kobana sizijamele ngaphasi kweNgwenyama uNdebele. Ngikho namhlanjesi kunezici ezifanako phakathi kwelimi lesiNdebele nelimi lesiHlubi, isiBhaca, isiMpondo nesiMpondomise.  Ngemva kwesikhathi uNdebele wabeletha uMkhalangana owabeletha umNtungwa. Ngemva kwesikhathi umNtungwa wabeletha uNjonono. UNjonono wabeletha uNanasi, uNanasi wabeletha uMafana. UMafana wabeletha uMhlanga owabeletha uMusi. Kusesikhathini seNgwenyama uMusi lapha amaNdebele ahlukana khona waba maNzunza namaNala. AmaNdebele akheka ngaleyondlela sele ahlala eSewula Afrika nje.&lt;ref&gt;https://en.wikipedia.org/wiki/Southern_Ndebele_language&lt;/ref&gt;

== IsiSwati ==
[[Isimumathi:Indoni_Parade_2018._Swati_Kingdom_by_Sizwe_Sibiya_(10).jpg|thumb|AmaSwati]]
IsiSwati sikhulunywa eenarheni ezimbili, eSewula Afrika neSwatini. Ngokwethebula elingehla abantu abakhuluma isiSwati eSewula Afrika  bangaphezu kweengidi ezilikhomba.&lt;ref name=&quot;:1&quot; /&gt; KunesiSwati esikhulunywa eSwatini kwaManzini, eShiselweni neHhoho.&lt;ref name=&quot;:2&quot; /&gt; Abantu abakhuluma isiSwati eSwatini babalelwa eengidini ezine.&lt;ref name=&quot;:3&quot;&gt;https://en.wikipedia.org/wiki/Zulu_language&lt;/ref&gt;

AmaSwati bewasiqhenyana esincani sabeNguni ebesaziwa bona Mangwane. Ngokukhamba kwesikhathi isiqhemesi sahlangana nesiqhenyana sabeSuthu ebesihlala endaweni namhlanjesi ebizwa bona kuseSwatini. Ngemva kwalokho bakhula baba sisizwe ngaphasi kweNgwenyama uDlamini III eyathatha iintambo eNgwenyameni uMaseko, yathatha isitjhaba yayosinzinzisa ngasemlanjeni iPongola bahlala eduze namaNdwandwe ngo-1750. UDlamini III walandelwa yiNgwenyama uNgwane III okukholelwa bona nguye owaba yiNgwenyama yokuthoma eyabusa indawo namhlanjesi ebizwa bona kuseSwatini.&lt;ref&gt;https://en.wikipedia.org/wiki/Swazi_people&lt;/ref&gt;

== IsiZulu ==
[[Isimumathi:Zulu_Krieger.jpg|thumb|Abobaba bamaZulu bayagida]]
IsiZulu ngelinye lamalimi adumileko asemthethweni eSewula Afrika elikhulunywa babantu ababgaogezu kweengidi ezimatjhumi amahlanu, kuthi labo abalimunyileko bangaphezu kweengidi ezilitjhumi nanye.&lt;ref name=&quot;:1&quot; /&gt; IsiZulu sikhulunywa khulu KwaZulu Natal, esiFundeni se-Gauteng nakezinye iimfunda.

Umuntu owadlala indima ekulu ekwakhekeni kwesitjhaba samaZulu yiNgwenyama uShaka. UShaka walwa neentjhaba ezincani nezikulu zabeNguni kuhlanganise namaNdwandwe wazihlula. Ngemva kwalokho wazibiza ngoZulu obekangukhokho omkhulu wesitjhaba abelethelwa kiso. Iintjhabezi zahlangana kwavela ilimi lesiZulu.&lt;ref name=&quot;:3&quot; /&gt;
== IsiXhosa ==
[[Isimumathi:Xhosa_traditionally_dressed_women.jpg|thumb|250x250px|Abomma bamaXhosa]]
IsiXhosa naso singelinye lamalimi weSewula Afrika asemthethweni. IsiXhosa sikhulunywa babantu abangaphezu kweengidi ezimatjhumi amathathu nobunane, kuthi labo okulilimi labo lokubelethwa bangaphezu kweengidi ezibunane.&lt;ref name=&quot;:1&quot; /&gt; IsiXhosa sikhulunywa khulukhulu esiFundeni seTjingalanga Kapa, eTlhagwini  Kapa nesiFundeni se-Gauteng.&lt;ref&gt;{{Cite web|last=Alexander|first=Mary|date=2025-04-06|title=The languages of South Africa|url=https://southafrica-info.com/arts-culture/11-languages-south-africa/#:~:text=Among%20South%20Africa's%20population%20groups,),%20based%20on%20Census%202022.|access-date=2025-05-23|website=South Africa Gateway|language=en-GB}}&lt;/ref&gt;

Ekadeni bekuneenqhema zabeNguni ezakha ubuhlobo neentjhaba zabaThwa nabaKhwe (ama-''Khoekhoe''). Ngokukhamba kwesikhathi iintjhabezi zahlangana zaba sisizwe  sinye ngaphasi kokubusa kweNgwenyama u-Tshawe owahlula isitjhaba sama-Cirha nama-Jwarha. Ngemva kwalokho wahlanganisa zoke iintjhaba ezincani kuhlanganise nesabaKhwe. Labeletheka njalo-ke ilimi lesiXhosa.&lt;ref&gt;https://en.wikipedia.org/wiki/Xhosa_people&lt;/ref&gt;

== I-Sesotho ==
[[Isimumathi:Sotho_regalia.jpg|thumb|Abobaba babeSuthu]]
I-Sesotho lilimi elisemthethweni eSewula Afrika elikhunywa babantu abangaphezu kweengidi ezimatjhumi amabili nambili. Okulilmi labo abalimunyileko bangaphezu kweengidi ezintathu.&lt;ref name=&quot;:1&quot; /&gt; I-Sesotho sikhulunywa khulu enarheni ye-Lesotho, kanti eSewula Afrikapha sikhulunywa khulukhulu esiFundeni se-Freestate, se-Gauteng. Umhlobo lo we-Sesotho ubizwa ngokobana yi-Sesotho seSewula ngombana uhlukaniswa ne-Sesotho seTlhagwini - i-Sepedi, ne-Sesotho seTjingalanga - i-Setwana.

Emandulo abantwaba beza eSewula Afrika bavela etlhagwini njengezinye iintjhaba bafika bahlala etlhagwini yeSewula Afrika. Bafika baba ziinqhenyana ezinjengaba-Taung, aba-Sia, aba-Fokeng, ama-Kgolokoe nabaKwena nezinye iinqenyana. Kuhlekuhle umndeni webukhosini be-Lesotho mndeni wabaKwena. AbeSuthwaba ngibo-ke ababanikazi belimi le-Sesotho esikhulunywa eSewula Afrika ne-Lesotho.&lt;ref&gt;{{Cite web|title=SOUTHERN SESOTHO - South African Language Southern Sesotho|url=https://www.sa-venues.com/language-southern-sesotho.htm|access-date=2025-05-26|website=www.sa-venues.com}}&lt;/ref&gt;

== Setswana ==
[[Isimumathi:Tswana_Dancers_3.jpg|thumb|Isiqhema esigidako sabaTswana]]
I-Setswana nalo ngelinye lamalimi asesiqhemeni se-Sesotho seTjingalanga esikhulunywa eSewula Afrika ne-Botswana. Abantu abasikhulumako eSewula Afrika bangaphezu kweengidi ezimatjhumi amabili nantathu, abalimunyileko bangaphezu kweengidi ezine.&lt;ref name=&quot;:1&quot; /&gt; I-Setswana sikhulunywa khulu enarheni ye-Botswana kanti eSewula Afrika sikhulunywa khulu esiFundeni seTlhagwini-Tjhingalanga, ne-Gauteng.

Emandulo abeTswana bebangaphasi kwesiqhema sabeSuthu nabazakufika eSewula Afrika bavela eTlhagwini ne-Afrika. Bafika baba ziinqhenyana ezinjengaba-Taung, aba-Sia, aba-Fokeng, ama-Kgolokoe nabaKwena kunye nezinye iinqhenyana. Bafika endaweni ebizwa ngokobana yi-Botswana namhlanjesi, balwa nabaThwa babahlula, bese bakha umbuso wabaTswana. Ngibo-ke namhlanjesi ababanikazi belimi le-Setswana.&lt;ref&gt;{{Cite web|title=AFRICA {{!}} 101 Last Tribes - Tswana people|url=http://www.101lasttribes.com/tribes/tswana.html|access-date=2025-05-26|website=www.101lasttribes.com}}&lt;/ref&gt;

== Sepedi ==
[[Isimumathi:Pedi_Living_Culture_Route,_Limpopo,_South_Africa_(2417712111).jpg|thumb|Umuzi wesiPedi]]
I-Sepedi ([https://www.sahistory.org.za/article/pedi Sepedi]) nalo ngelinye lamalimi angaphasi kwe-Sesotho atloliswe ngokomthetho eSewula Afrika, begodu saziwa ngokuthi yi-Sesotho seTlhagwini. Ilimeli likhulunywa khulukhulu esiFundeni se-Limpopo nese-Gauteng babantu abalinganiswela eengidini ezimatjhumi amabili nekhomba.&lt;ref name=&quot;:1&quot; /&gt;

Ekadeni isiqhemesi besiyingcenye yesiqhema sabeSuthu, kwathi nakukhamba ezinye iinqhema sona sasala ngetlhagwini yeSewula Afrika. Sineenqhenyana ezinengana okucatjangelwa bona sikhuluma amalinyana amatjhumi amathathu. Abanye bathi i-Sesotho seTlhagwini akusiso i-Sepedi kodwana lilimi elihlukileko.&lt;ref name=&quot;:4&quot;&gt;{{Cite web|title=AFRICA {{!}} 101 Last Tribes - Pedi people|url=http://www.101lasttribes.com/tribes/pedi.html|access-date=2025-05-26|website=www.101lasttribes.com}}&lt;/ref&gt;
== Tshivenda ==
[[Isimumathi:Venda_culture,_Limpopo,_South_Africa_(8714283418).jpg|thumb|251x251px|Izindlu zamaVenda]]
Elinye lamalimi atloliswe ngokomthetho eSewula Afrika yi-Tshivenda. Abantu abakhuluma i-Tshivenda balinganiselwa eengidini ezihlanu.&lt;ref name=&quot;:1&quot; /&gt; I-Tshivenda sikhulunywa khulu esiFundeni seLimpopo ngetlhagwini ngitjho nesiFundeni seGauteng. Nawulilemukisisa kuhle ilimeli linezici ezivela elimini lesiShona nelesiTokwa.

Ekadeni isiqhemesi kukholelwa bona sathoma ukuba khona nakusabusa uMpuso we-Mapungubwe, kwathi nakuwa umbuso lo kuvuka umbuso we-Zimbabwe sathutha sayokuhlala endaweni namhlanjesi ebizwa ngokobana kuse-Zimbabwe. Sakhamba isikhathi, isiqhemesi sathutha e-Zimbabwe sehla seyama umlambo we-Zambezi sazitholela indawo sayithiya ngokuthi yi-D'zata. Kusukela ngalesosikhathi umbuso wabo uye wanzinza kwabusa amakhosi wawo ngokulandelana kwawo. Namhlanjesi ngibo ababanikazi belimi le-Tshivenda.&lt;ref&gt;{{Cite web|title=Venda - African Tribe - Venda Culture|url=https://www.krugerpark.co.za/africa_venda.html|access-date=2025-05-26|website=www.krugerpark.co.za}}&lt;/ref&gt;

== Xitsonga ==
[[Isimumathi:Tsonga_women_in_South_Africa.jpg|thumb|Abomma bambethe isiTsonga]]
I-Xitsonga ngelinye lamalimi akhulunywa eSewula Afrika atloliswe ngokomthetho. Ilimeli likhulunywa babantu abangaphezu kweengidi ezilitjhumi nanye. I-Xitsonga sikhulunywa  khulukhulu esifundeni seLimpopo neseGauteng, bese kube ne-Xitsonga esikhulunywa e-Mozambique.&lt;ref name=&quot;:1&quot; /&gt;

Abantwaba bebasiqhema sabeNguni abathoma lokha uSoshangane ebekuyinduna kaShaka abalekela enarheni yangepumalanga. Bathi nabafika lapho bazakhela umbuso omkhulu nedorhobho elibizwa bona yi-Gaza. Bafika bahlula izizwe ezinengi abazithola lapho njengesizwe samaNdawu, amaTonga, amaTjopi amaSena nezinye. Ilimi labo lesiNguni lahlangana nesiTonga namalimi walapho laba yi-Xitsonga. Ngokukhamba kwesikhathi umbuso lo wahlukana, amanye amaTsonga asuka e-Mozambique athuthela eSewula Afrika.&lt;ref&gt;{{Cite web|title=Shangaan Tsonga - Nguni People, Tribe - South Africa...|url=https://www.krugerpark.co.za/africa_shangaan_tsonga.html|access-date=2025-05-26|website=www.krugerpark.co.za}}&lt;/ref&gt;

== IsiBhuru ==
[[Isimumathi:Boer_Family_with_a_wagon_-_false_colour_image.jpg|thumb|AmaBhuru wakade]]
I-''Afrikaans'' namkha isiBhuru mhlobo welimi lamakhuwa angasiwo wendabuko weSewula Afrika. Nalo litlolisiwe ngokomthetho begodu likhulunywa babantu abangaphezu kweengidi ezimatjhumi amathathu nane.&lt;ref name=&quot;:1&quot; /&gt; I-Afrikaans ikhulunywa khulu eemfundeni zangeTjingalanga Kapa, eGauteng nakezinye iimfunda.

Ilimi le-Afrikaans livela elimini lesiDatjhi. AmaDatjhi afika eSewula Afrika lokha uJan Van Riebeeck obekasebenzela i-VOC (''[https://www.worldhistory.org/Dutch_East_India_Company/ Vereenigde Oost-Indische Compagnie]'') afika nabantu bekhabo ngo-1652, bafika bahlala endaweni abayibiza bona yi-''Cape of Good Hope''. Bafika lapho bahlangana nesitjhaba sabaKhoekhoe. Ngokukhamba kwesikhathi ilimi lesiDatjhi lahlangana nelesiKhoe kunye namanye amalimi kwakheka ilimi namhlanjesi elibizwa ngokuthi yi-''Afrikaans'' namkha isiBhuru, okulilimi elisemthethweni bekube njenganje eSewula Afrika.&lt;ref&gt;{{Cite web|title=The Dutch Settlement {{!}} South African History Online|url=https://www.sahistory.org.za/article/dutch-settlement|access-date=2025-05-26|website=www.sahistory.org.za}}&lt;/ref&gt;&lt;ref&gt;{{Cite web|date=2023-10-13|title=‘The language we know as Afrikaans today owes much to the enslaved people who spoke it’—Read an excerpt from Coloured: How Classification Became Culture|url=https://johannesburgreviewofbooks.com/2023/10/13/the-language-we-know-as-afrikaans-today-owes-much-to-the-enslaved-people-who-spoke-it-read-an-excerpt-from-coloured-how-classification-became-culture/|access-date=2025-05-26|website=The Johannesburg Review of Books|language=en-US}}&lt;/ref&gt;

== IsiNgisi ==
[[Isimumathi:English_settlers_landing_in_Virginia_1607_Image_from_page_42_of_A_junior_class_history_of_the_United_States;_to_which_are_added_the_Declaration_of_independence,_and_the_Constitution_of_the_United_States_(1899).jpg|thumb|AmaNgisi bokufika]]
IsiNgisi kuphela kwelimi elikhulunywa khulu ukudlula woke eSewula Afrika. Sikhulunywa babantu abangaphezu kweengidi ezimatjhumi amathathu nekhomba. Ilimeli ngilo elisetjenziswa khulu emazikweni wezefundo, wezepolotiki, wezeemali, wezamaphilo namanye.

Safika njani isiNgisi eSewula Afrika? IsiNgisi besele sikhona nakufika amaBhuru ngo-1652 ngombana nakufika amaDatjhi athola u-Atjhumato obekayikosi yabaKhoekhoe besele abuya eBantam ngo-1630, akghona ukukhuluma isiNgisi nesiDatjhi.&lt;ref&gt;{{Cite web|title=Autshumao (Herry the Strandloper) {{!}} South African History Online|url=https://www.sahistory.org.za/people/autshumao-herry-strandloper#:~:text=Autshumao%20also%20known%20as%20Herry%20the%20strandloper,who%20were%20engaged%20in%20a%20trading%20relationship.|access-date=2025-05-26|website=www.sahistory.org.za}}&lt;/ref&gt; Nanyana isiNgisi besele sikhulunywa eSewula Afrika, amaNgisi wokufika nokuhlala eza mva kwamaDatjhi. Kwathoma mhlokho bona isiNgisi sikhulunywe eSewula Afrika.

== Ilimi Lezandla ==
Ilimi lezandla ngelinye lamalimi akhulunywa eSewula Afrika. Likhulunywa babantu abangaphezu kwesigidi sinye, begodu kunabantu abama-234,655 okulilimi labo lokuthoma.

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>aahaysyp5j6jxjc0luwbp7cby95nkom</sha1>
    </revision>
  </page>
  <page>
    <title>Ukuhluka Kwesikopilo</title>
    <ns>0</ns>
    <id>606</id>
    <revision>
      <id>2860</id>
      <timestamp>2025-05-29T14:09:32Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>Created page with &quot; = Ukuhluka Kwesikopilo = [[Isimumathi:New_South_African_flag_unveiling.jpg|thumb|Iflarha leSewula Afrika]] Ukuhlalisana kwabantu abanesikopilo engafani kutjho ukuthatha abantu abavela eenzindeni namasikopilo ahlukahlukeneko bese ubahlalise ngobunye nangokuzwana, bangaqali kwaphela bona baneenzinda namasiko angafaniko, kodwana bakwamukele bebakuthabele lokho. Lokhu kunikela woke umuntu ilungelo lokuphila ngokwalokho angikho ingasi ngokwalokho abanye abafuna abe ngikho. &lt;...&quot;</comment>
      <origin>2860</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7626" sha1="6bgvl7dv86uearc5ydco1jzie5re5vw" xml:space="preserve">
= Ukuhluka Kwesikopilo =
[[Isimumathi:New_South_African_flag_unveiling.jpg|thumb|Iflarha leSewula Afrika]]
Ukuhlalisana kwabantu abanesikopilo engafani kutjho ukuthatha abantu abavela eenzindeni namasikopilo ahlukahlukeneko bese ubahlalise ngobunye nangokuzwana, bangaqali kwaphela bona baneenzinda namasiko angafaniko, kodwana bakwamukele bebakuthabele lokho. Lokhu kunikela woke umuntu ilungelo lokuphila ngokwalokho angikho ingasi ngokwalokho abanye abafuna abe ngikho. &lt;ref&gt;{{Cite web|title=What is Cultural Diversity and Why Does it Matter? - Hourly, Inc.|url=https://www.hourly.io/post/cultural-diversity|access-date=2025-05-28|website=www.hourly.io|language=en}}&lt;/ref&gt;

Ngamanye amagama ukuhlalisana kwabantu abanesikopilo engafaniko kukwamukela bona umphakathi wethu wakhiwa babantu abafuna izinto ezingafaniko, abanamakghono namatalende angafaniko neendingo ezingafaniko. Begodu kutjho bona nawumumuntu  kufuze utjheje bona uphila nabantu abanekolo engafani neyakho, nabanobulili obungafani nebakho, nokuthi lokho kufuze ukwamukele.&lt;ref&gt;{{Cite web|date=2024-10-03|title=What is Cultural Diversity?|url=https://young.scot/get-informed/what-is-cultural-diversity/|access-date=2025-05-28|website=Young Scot|language=en-US}}&lt;/ref&gt; Ukuba nombono onjalo kwenza abantu bahlalisane ngobunye nokusebenzisana kunokuthi baninane.

== Ukuqakatheka Kokuhluka Kwesikopilo ==
Ukuhlukahluka kwesikopilo kuletha ukwabelana ngelwazi emazikweni ahlukahlukeneko njengakwezobukghwari, ukwenziwa kwemikhiqizo emitjha, nemazikweni wezemvelo. Ukuthuthukiswa kwelwazi elabelwanakweli kuqakathekile esitjhabeni ngombana kuthuthukisa zefundo, zomnotho nendlela yokuhlalisana ngobunye enarheni le.&lt;ref name=&quot;:0&quot;&gt;{{Cite web|last=lesadmin|date=2021-07-26|title=What Are the Benefits of Understanding Different Cultures?|url=https://www.leselfes.com/understanding-different-cultures/|access-date=2025-05-28|website=Les Elfes International Camps Switzerland|language=en-US}}&lt;/ref&gt;

Ukulemuka nokwamukela abanye nendlela abaphila ngayo kwenza umuntu azwisise amasiko neenkolelo zabanye. Izinto umuntu ebekangaziqala njengezingasizihle namkha ezithusako ngamasiko womunye zingazwisiseka nange omunye angazifaka emanyathelweni womunye. Izazi zezokuhlalisana zithi umuntu ozwisisa isikopilo labanye

* kumenza alemuke bekatjheje bona iinzinda namasiko akufani,
* kumenza ahloniphe izici ezingafaniko esikweni lakhe nelomunye,
* kumenza anganyazi nanyana yini omunye ayibeka etafuleni ngokwesiko lakhe,
* kumenza akghone nokweluleka abanye abangafuni ukwamukela amasiko angafani newabo,
* begodu kumenze akuthabele ukungafani esikhundleni sokukunina.&lt;ref name=&quot;:0&quot; /&gt;

Yeke ngokuya ngokwamaphuzu la kuba bulula ukuhlalisana nomuntu nangabe uyalizwisisa isiko nendlelakhe yokuphila, kuba bulula ukusebenza naye emsebenzini, kuba lula nokwakha ubungani nokwabelana naye amakghono nangabe uyasizwisisa isizinda avela kiso, amasiko awenzako nelimi alikhulumako.

== Ukungafani Kwesikopilo ESewula Afrika ==
UmThethosisekelo weSewula Afrika uthi woke umuntu unelungelo lokukhuluma ilimi alimunyako begodu azikhakhazise ngalo, unelungelo lokwenza amasiko wekhabo, nelokukhetha ikolo afuna ukuba ngaphasi kwayo.&lt;ref&gt;{{Cite web|title=Cultural, Religious and Language Diversity|url=https://fwdeklerk.org/reconciliation-and-unity-in-diversity/cultural-religious-and-language-diversity/|access-date=2025-05-29|website=FW de Klerk Foundation|language=en-US}}&lt;/ref&gt; Yeke  ngokomthethosisekelo lo woke umuntu nanyana anelungelo lokwenza amasiko wekhabo kufuze atjheje amalungelo wabanye wokwenza amasiko wemakhabo. Lokho kwenza abantu bahlalisane ngobunye nokwamukelana.

Iimbalobalo zango-2024  ze-Statistic South Africa (Stats SA) zilinganisela bona isibalo sabantu baboke eSewula Afrika ziingidi ezima-63,02. Bese amalimi atloliswe ngokomthetho akhulunywa babantwaba ali-12 - isiNgisi, isiBhuru, isiZulu, isiXhosa, isiSwati, isiPedi, isiSuthu, isiTswana, isiTsonga, isiVenda nelimi lezandla leSewula Afrika. Woke amalimi la anamalungelo wokusetjenziswa ngendlela elinganako. Ngikho inengi labantu eSewula Afrika likhuluma amalimi amabili asemthethweni umuntu ngamunye.&lt;ref&gt;{{Cite web|title=People of South Africa {{!}} South African Government|url=https://www.gov.za/about-sa/south-africas-people|access-date=2025-05-29|website=www.gov.za}}&lt;/ref&gt;

Ukuhlukahluka kwamalimi, isizinda namasiko kuyithuthukisile iSewula Afrika emikhakheni ehlukahlukeneko njengakwezokuthibisa, kezomnotho nakezefundo.

=== Kwezokuzithabisa ===
Ukuhluka okukhulu kwesikopilo eSewula Afrika kuvela kuhle ezikweni lokuzithabisa lenarha le. Kuneenqhema ezinengi zabantu bendabuko abahlukahlukeneko begodu boke banamasiko, amalimi neendlela zokwenza imitlamo emitjha. Lokho ukubona emafilimini, ekugideni nembhinweni weSewula Afrika begodu abantwaba bahlanganisa isikopilwabo emazwikweni la bawenze abe mahle. Ngaphezu kwalokhko kuba namajima nezenzakalo ezifana ne-''Cape Town International Jazz Festival'' ne-''National Arts Festival in Grahams Town'' edosa iinthekeli ezivela ephasini loke ezifuna ukubona ukuhlukahluka kwesikopilo lenarha le. Lokho kulithuthukisile iziko lokuzithabisa.&lt;ref&gt;{{Cite web|last=Mukhari|first=Vutlhari|date=2024-08-28|title=Why is South Africa’s entertainment industry a gold mine to boost local tourism? - Etela Africa|url=https://etela.africa/why-is-south-africas-entertainment-industry-a-gold-mine-to-boost-local-tourism/|access-date=2025-05-29|language=en-US}}&lt;/ref&gt;

=== Kwezomnotho ===
Ukuhluka kwesikopilo eSewula Afrika kube nesandla ekukhuleni komnotho wenarha le ngokuza nendlela yokwenza imikhiqizo emitjha - njengezokuzithabisa - nokurherha amathalente amatjha. Abantu abahlukahlukeneko abasemabubulweni la beza nemibono emitjha eyenza kuthathwe iinqunto ezingcono, kukhuphule indlela yokurarulula imiraro neyokuza neendlela ezitjha zokwenza imikhiqizo. Ngaphezu kwalokho inarha le ikghona ukuletha inzuzo ekulu ngamaziko wezokuvakatjha newokwenza imitlamo emitjha.&lt;ref&gt;{{Cite web|title=how cultural diversity improves economic growth in south africa - Google Search|url=https://www.google.com/search?q=how+cultural+diversity+improves+economic+growth+in+south+africa&amp;sca_esv=595de8d130c61221&amp;rlz=1C1JJTC_enZA1159ZA1159&amp;sxsrf=AE3TifPbzq6OPF4689gtEIaG4WfdKVsDrg:1748523734674&amp;ei=1lo4aPb8KO6zhbIP7ZzH8Qk&amp;oq=how+cultural+diversity+improves+econo+in+south+africa&amp;gs_lp=Egxnd3Mtd2l6LXNlcnAiNWhvdyBjdWx0dXJhbCBkaXZlcnNpdHkgaW1wcm92ZXMgZWNvbm8gaW4gc291dGggYWZyaWNhKgIIADIKECEYoAEYwwQYCjIKECEYoAEYwwQYCjIKECEYoAEYwwQYCjIKECEYoAEYwwQYCkj8O1D2Dli8H3ACeAGQAQCYAYMDoAHsDaoBAzMtNbgBAcgBAPgBAZgCBKAC1gbCAgoQABiwAxjWBBhHwgIIEAAYgAQYogTCAgUQABjvBcICCBAAGKIEGIkFmAMAiAYBkAYIkgcFMi40LTKgB8sqsgcDNC0yuAevBsIHBTMtMy4xyAc-&amp;sclient=gws-wiz-serp|access-date=2025-05-29|website=www.google.com}}&lt;/ref&gt;

=== Kwezefundo ===
Ukuhluka kwesikopilo eSewula Afrika kuyithuthukisile ifundo ngokwenza abafundi bafunde ukuhlalisana nokusebenzisana emsebenzinabo yesikolo ngitjho nanyana bavela eenzindeni ezingafaniko. Lokho kubafundisa ukusebenzisana ngitjho nanyana sele baqedile isikolo basebenza. Kubenze baba nomqondo ovulekileko, bazithemba khudlwana begodu kwabasiza bakghona ukuzwisisa amasiko ahlukahlukeneko. Yeke ngokwamukela ifundo ngokuhlukahluka kwesikopilo, iinkolo zikghona ukuba nendawo engcono yokufundela khona amakghono wokucabanga azokuthuthuke, kwehlise nebandlululo. &lt;ref&gt;{{Cite web|date=2025-05-14|title=The Importance of Multicultural Education|url=https://drexel.edu/soe/resources/student-teaching/advice/importance-of-cultural-diversity-in-classroom/|access-date=2025-05-29|website=School of Education|language=en}}&lt;/ref&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>6bgvl7dv86uearc5ydco1jzie5re5vw</sha1>
    </revision>
    <revision>
      <id>3157</id>
      <parentid>2860</parentid>
      <timestamp>2025-06-17T09:38:13Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>Deleted heading</comment>
      <origin>3157</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7606" sha1="rb8row5v657yfkruyvtrt05x8t20zke" xml:space="preserve">
[[Isimumathi:New_South_African_flag_unveiling.jpg|thumb|Iflarha leSewula Afrika]]
'''Ukuhlalisana''' kwabantu abanesikopilo engafani kutjho ukuthatha abantu abavela eenzindeni namasikopilo ahlukahlukeneko bese ubahlalise ngobunye nangokuzwana, bangaqali kwaphela bona baneenzinda namasiko angafaniko, kodwana bakwamukele bebakuthabele lokho. Lokhu kunikela woke umuntu ilungelo lokuphila ngokwalokho angikho ingasi ngokwalokho abanye abafuna abe ngikho.&lt;ref&gt;{{Cite web|title=What is Cultural Diversity and Why Does it Matter? - Hourly, Inc.|url=https://www.hourly.io/post/cultural-diversity|access-date=2025-05-28|website=www.hourly.io|language=en}}&lt;/ref&gt;

Ngamanye amagama ukuhlalisana kwabantu abanesikopilo engafaniko kukwamukela bona umphakathi wethu wakhiwa babantu abafuna izinto ezingafaniko, abanamakghono namatalende angafaniko neendingo ezingafaniko. Begodu kutjho bona nawumumuntu  kufuze utjheje bona uphila nabantu abanekolo engafani neyakho, nabanobulili obungafani nebakho, nokuthi lokho kufuze ukwamukele.&lt;ref&gt;{{Cite web|date=2024-10-03|title=What is Cultural Diversity?|url=https://young.scot/get-informed/what-is-cultural-diversity/|access-date=2025-05-28|website=Young Scot|language=en-US}}&lt;/ref&gt; Ukuba nombono onjalo kwenza abantu bahlalisane ngobunye nokusebenzisana kunokuthi baninane.

== Ukuqakatheka Kokuhluka Kwesikopilo ==
Ukuhlukahluka kwesikopilo kuletha ukwabelana ngelwazi emazikweni ahlukahlukeneko njengakwezobukghwari, ukwenziwa kwemikhiqizo emitjha, nemazikweni wezemvelo. Ukuthuthukiswa kwelwazi elabelwanakweli kuqakathekile esitjhabeni ngombana kuthuthukisa zefundo, zomnotho nendlela yokuhlalisana ngobunye enarheni le.&lt;ref name=&quot;:0&quot;&gt;{{Cite web|last=lesadmin|date=2021-07-26|title=What Are the Benefits of Understanding Different Cultures?|url=https://www.leselfes.com/understanding-different-cultures/|access-date=2025-05-28|website=Les Elfes International Camps Switzerland|language=en-US}}&lt;/ref&gt;

Ukulemuka nokwamukela abanye nendlela abaphila ngayo kwenza umuntu azwisise amasiko neenkolelo zabanye. Izinto umuntu ebekangaziqala njengezingasizihle namkha ezithusako ngamasiko womunye zingazwisiseka nange omunye angazifaka emanyathelweni womunye. Izazi zezokuhlalisana zithi umuntu ozwisisa isikopilo labanye:

* kumenza alemuke bekatjheje bona iinzinda namasiko akufani,
* kumenza ahloniphe izici ezingafaniko esikweni lakhe nelomunye,
* kumenza anganyazi nanyana yini omunye ayibeka etafuleni ngokwesiko lakhe,
* kumenza akghone nokweluleka abanye abangafuni ukwamukela amasiko angafani newabo,
* begodu kumenze akuthabele ukungafani esikhundleni sokukunina.&lt;ref name=&quot;:0&quot; /&gt;

Yeke ngokuya ngokwamaphuzu la kuba bulula ukuhlalisana nomuntu nangabe uyalizwisisa isiko nendlelakhe yokuphila, kuba bulula ukusebenza naye emsebenzini, kuba lula nokwakha ubungani nokwabelana naye amakghono nangabe uyasizwisisa isizinda avela kiso, amasiko awenzako nelimi alikhulumako.

== Ukungafani Kwesikopilo ESewula Afrika ==
UmThethosisekelo weSewula Afrika uthi woke umuntu unelungelo lokukhuluma ilimi alimunyako begodu azikhakhazise ngalo, unelungelo lokwenza amasiko wekhabo, nelokukhetha ikolo afuna ukuba ngaphasi kwayo.&lt;ref&gt;{{Cite web|title=Cultural, Religious and Language Diversity|url=https://fwdeklerk.org/reconciliation-and-unity-in-diversity/cultural-religious-and-language-diversity/|access-date=2025-05-29|website=FW de Klerk Foundation|language=en-US}}&lt;/ref&gt; Yeke  ngokomthethosisekelo lo woke umuntu nanyana anelungelo lokwenza amasiko wekhabo kufuze atjheje amalungelo wabanye wokwenza amasiko wemakhabo. Lokho kwenza abantu bahlalisane ngobunye nokwamukelana.

Iimbalobalo zango-2024  ze-Statistic South Africa (Stats SA) zilinganisela bona isibalo sabantu baboke eSewula Afrika ziingidi ezima-63,02. Bese amalimi atloliswe ngokomthetho akhulunywa babantwaba ali-12 - isiNgisi, isiBhuru, isiZulu, isiXhosa, isiSwati, isiPedi, isiSuthu, isiTswana, isiTsonga, isiVenda nelimi lezandla leSewula Afrika. Woke amalimi la anamalungelo wokusetjenziswa ngendlela elinganako. Ngikho inengi labantu eSewula Afrika likhuluma amalimi amabili asemthethweni umuntu ngamunye.&lt;ref&gt;{{Cite web|title=People of South Africa {{!}} South African Government|url=https://www.gov.za/about-sa/south-africas-people|access-date=2025-05-29|website=www.gov.za}}&lt;/ref&gt;

Ukuhlukahluka kwamalimi, isizinda namasiko kuyithuthukisile iSewula Afrika emikhakheni ehlukahlukeneko njengakwezokuthibisa, kezomnotho nakezefundo.

=== Kwezokuzithabisa ===
Ukuhluka okukhulu kwesikopilo eSewula Afrika kuvela kuhle ezikweni lokuzithabisa lenarha le. Kuneenqhema ezinengi zabantu bendabuko abahlukahlukeneko begodu boke banamasiko, amalimi neendlela zokwenza imitlamo emitjha. Lokho ukubona emafilimini, ekugideni nembhinweni weSewula Afrika begodu abantwaba bahlanganisa isikopilwabo emazwikweni la bawenze abe mahle. Ngaphezu kwalokhko kuba namajima nezenzakalo ezifana ne-''Cape Town International Jazz Festival'' ne-''National Arts Festival in Grahams Town'' edosa iinthekeli ezivela ephasini loke ezifuna ukubona ukuhlukahluka kwesikopilo lenarha le. Lokho kulithuthukisile iziko lokuzithabisa.&lt;ref&gt;{{Cite web|last=Mukhari|first=Vutlhari|date=2024-08-28|title=Why is South Africa’s entertainment industry a gold mine to boost local tourism? - Etela Africa|url=https://etela.africa/why-is-south-africas-entertainment-industry-a-gold-mine-to-boost-local-tourism/|access-date=2025-05-29|language=en-US}}&lt;/ref&gt;

=== Kwezomnotho ===
Ukuhluka kwesikopilo eSewula Afrika kube nesandla ekukhuleni komnotho wenarha le ngokuza nendlela yokwenza imikhiqizo emitjha - njengezokuzithabisa - nokurherha amathalente amatjha. Abantu abahlukahlukeneko abasemabubulweni la beza nemibono emitjha eyenza kuthathwe iinqunto ezingcono, kukhuphule indlela yokurarulula imiraro neyokuza neendlela ezitjha zokwenza imikhiqizo. Ngaphezu kwalokho inarha le ikghona ukuletha inzuzo ekulu ngamaziko wezokuvakatjha newokwenza imitlamo emitjha.&lt;ref&gt;{{Cite web|title=how cultural diversity improves economic growth in south africa - Google Search|url=https://www.google.com/search?q=how+cultural+diversity+improves+economic+growth+in+south+africa&amp;sca_esv=595de8d130c61221&amp;rlz=1C1JJTC_enZA1159ZA1159&amp;sxsrf=AE3TifPbzq6OPF4689gtEIaG4WfdKVsDrg:1748523734674&amp;ei=1lo4aPb8KO6zhbIP7ZzH8Qk&amp;oq=how+cultural+diversity+improves+econo+in+south+africa&amp;gs_lp=Egxnd3Mtd2l6LXNlcnAiNWhvdyBjdWx0dXJhbCBkaXZlcnNpdHkgaW1wcm92ZXMgZWNvbm8gaW4gc291dGggYWZyaWNhKgIIADIKECEYoAEYwwQYCjIKECEYoAEYwwQYCjIKECEYoAEYwwQYCjIKECEYoAEYwwQYCkj8O1D2Dli8H3ACeAGQAQCYAYMDoAHsDaoBAzMtNbgBAcgBAPgBAZgCBKAC1gbCAgoQABiwAxjWBBhHwgIIEAAYgAQYogTCAgUQABjvBcICCBAAGKIEGIkFmAMAiAYBkAYIkgcFMi40LTKgB8sqsgcDNC0yuAevBsIHBTMtMy4xyAc-&amp;sclient=gws-wiz-serp|access-date=2025-05-29|website=www.google.com}}&lt;/ref&gt;

=== Kwezefundo ===
Ukuhluka kwesikopilo eSewula Afrika kuyithuthukisile ifundo ngokwenza abafundi bafunde ukuhlalisana nokusebenzisana emsebenzinabo yesikolo ngitjho nanyana bavela eenzindeni ezingafaniko. Lokho kubafundisa ukusebenzisana ngitjho nanyana sele baqedile isikolo basebenza. Kubenze baba nomqondo ovulekileko, bazithemba khudlwana begodu kwabasiza bakghona ukuzwisisa amasiko ahlukahlukeneko. Yeke ngokwamukela ifundo ngokuhlukahluka kwesikopilo, iinkolo zikghona ukuba nendawo engcono yokufundela khona amakghono wokucabanga azokuthuthuke, kwehlise nebandlululo.&lt;ref&gt;{{Cite web|date=2025-05-14|title=The Importance of Multicultural Education|url=https://drexel.edu/soe/resources/student-teaching/advice/importance-of-cultural-diversity-in-classroom/|access-date=2025-05-29|website=School of Education|language=en}}&lt;/ref&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>rb8row5v657yfkruyvtrt05x8t20zke</sha1>
    </revision>
    <revision>
      <id>3158</id>
      <parentid>3157</parentid>
      <timestamp>2025-06-17T09:50:09Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>3158</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7597" sha1="7itoknjvahwdmtx99blkcl1hwnup0gh" xml:space="preserve">
[[Isimumathi:New_South_African_flag_unveiling.jpg|thumb|Iflarha leSewula Afrika]]
'''Ukuhlalisana''' kwabantu abanesikopilo engafani kutjho ukuthatha abantu abavela eenzindeni namasikopilo ahlukahlukeneko bese ubahlalise ngobunye nangokuzwana, bangaqali kwaphela bona baneenzinda namasiko angafaniko, kodwana bakwamukele bebakuthabele lokho. Lokhu kunikela woke umuntu ilungelo lokuphila ngokwalokho angikho ingasi ngokwalokho abanye abafuna abe ngikho.&lt;ref&gt;{{Cite web|title=What is Cultural Diversity and Why Does it Matter? - Hourly, Inc.|url=https://www.hourly.io/post/cultural-diversity|access-date=2025-05-28|website=www.hourly.io|language=en}}&lt;/ref&gt;

Ngamanye amagama ukuhlalisana kwabantu abanesikopilo engafaniko kukwamukela bona umphakathi wethu wakhiwa babantu abafuna izinto ezingafaniko, abanamakghono namatalende angafaniko neendingo ezingafaniko. Begodu kutjho bona nawumumuntu  kufuze utjheje bona uphila nabantu abanekolo engafani neyakho, nabanobulili obungafani nebakho, nokuthi lokho kufuze ukwamukele.&lt;ref&gt;{{Cite web|date=2024-10-03|title=What is Cultural Diversity?|url=https://young.scot/get-informed/what-is-cultural-diversity/|access-date=2025-05-28|website=Young Scot|language=en-US}}&lt;/ref&gt; Ukuba nombono onjalo kwenza abantu bahlalisane ngobunye nokusebenzisana kunokuthi baninane.

== Ukuqakatheka Kokuhluka Kwesikopilo ==
Ukuhlukahluka kwesikopilo kuletha ukwabelana ngelwazi emazikweni ahlukahlukeneko njengakwezobukghwari, ukwenziwa kwemikhiqizo emitjha, nemazikweni wezemvelo. Ukuthuthukiswa kwelwazeli elabelwanako kuqakathekile esitjhabeni ngombana kuthuthukisa zefundo, zomnotho nendlela yokuhlalisana ngobunye enarheni le.&lt;ref name=&quot;:0&quot;&gt;{{Cite web|last=lesadmin|date=2021-07-26|title=What Are the Benefits of Understanding Different Cultures?|url=https://www.leselfes.com/understanding-different-cultures/|access-date=2025-05-28|website=Les Elfes International Camps Switzerland|language=en-US}}&lt;/ref&gt;

Ukulemuka nokwamukela abanye nendlela abaphila ngayo kwenza umuntu azwisise amasiko neenkolelo zabanye. Izinto umuntu ebekangaziqala njengezingasizihle namkha ezithusako ngamasiko womunye zingazwisiseka nange omunye angazifaka emanyathelweni womunye. Izazi zezokuhlalisana zithi umuntu ozwisisa isikopilo labanye:

* kumenza alemuke bekatjheje bona iinzinda namasiko akufani,
* kumenza ahloniphe izici ezingafaniko esikweni lakhe nelomunye,
* kumenza anganyazi nanyana yini omunye ayibeka etafuleni ngokwesiko lakhe,
* kumenza akghone nokweluleka abanye abangafuni ukwamukela amasiko angafani newabo,
* begodu kumenze akuthabele ukungafani esikhundleni sokukunina.&lt;ref name=&quot;:0&quot; /&gt;

Yeke ngokuya ngokwamaphuzu la kuba bulula ukuhlalisana nomuntu nangabe uyalizwisisa isiko nendlelakhe yokuphila, kuba bulula ukusebenza naye emsebenzini, kuba lula nokwakha ubungani nokwabelana naye amakghono nangabe uyasizwisisa isizinda avela kiso, amasiko awenzako nelimi alikhulumako.

== Ukungafani Kwesikopilo ESewula Afrika ==
UmThethosisekelo weSewula Afrika uthi woke umuntu unelungelo lokukhuluma ilimi alimunyako begodu azikhakhazise ngalo, unelungelo lokwenza amasiko wekhabo, nelokukhetha ikolo afuna ukuba ngaphasi kwayo.&lt;ref&gt;{{Cite web|title=Cultural, Religious and Language Diversity|url=https://fwdeklerk.org/reconciliation-and-unity-in-diversity/cultural-religious-and-language-diversity/|access-date=2025-05-29|website=FW de Klerk Foundation|language=en-US}}&lt;/ref&gt; Yeke  ngokomthethosisekelo lo woke umuntu nanyana anelungelo lokwenza amasiko wekhabo kufuze atjheje amalungelo wabanye wokwenza amasiko wemakhabo. Lokho kwenza abantu bahlalisane ngobunye nokwamukelana.

Iimbalobalo zango-2024  ze-Statistic South Africa (''Stats SA'') zilinganisela bona isibalo sabantu baboke eSewula Afrika ziingidi ezima-63,02. Bese amalimi atloliswe ngokomthetho akhulunywa babantwaba ali-12, isiNgisi, isiBhuru, isiZulu, isiXhosa, isiSwati, Sesotho, Setswana, Xitsonga, Tshivenda nelimi lezandla leSewula Afrika. Woke amalimi la anamalungelo wokusetjenziswa ngendlela elinganako. Ngikho inengi labantu eSewula Afrika likhuluma amalimi amabili asemthethweni umuntu ngamunye.&lt;ref&gt;{{Cite web|title=People of South Africa {{!}} South African Government|url=https://www.gov.za/about-sa/south-africas-people|access-date=2025-05-29|website=www.gov.za}}&lt;/ref&gt;

Ukuhlukahluka kwamalimi, isizinda namasiko kuyithuthukisile iSewula Afrika emikhakheni ehlukahlukeneko njengakwezokuthibisa, kezomnotho nakezefundo.

=== Kwezokuzithabisa ===
Ukuhluka okukhulu kwesikopilo eSewula Afrika kuvela kuhle ezikweni lokuzithabisa lenarha le. Kuneenqhema ezinengi zabantu bendabuko abahlukahlukeneko begodu boke banamasiko, amalimi neendlela zokwenza imitlamo emitjha. Lokho ukubona emafilimini, ekugideni nembhinweni weSewula Afrika begodu abantwaba bahlanganisa isikopilwabo emazwikweni la bawenze abe mahle. Ngaphezu kwalokhko kuba namajima nezenzakalo ezifana ne-''Cape Town International Jazz Festival'' ne-''National Arts Festival in Grahams Town'' edosa iinthekeli ezivela ephasini loke ezifuna ukubona ukuhlukahluka kwesikopilo lenarha le. Lokho kulithuthukisile iziko lokuzithabisa.&lt;ref&gt;{{Cite web|last=Mukhari|first=Vutlhari|date=2024-08-28|title=Why is South Africa’s entertainment industry a gold mine to boost local tourism? - Etela Africa|url=https://etela.africa/why-is-south-africas-entertainment-industry-a-gold-mine-to-boost-local-tourism/|access-date=2025-05-29|language=en-US}}&lt;/ref&gt;

=== Kwezomnotho ===
Ukuhluka kwesikopilo eSewula Afrika kube nesandla ekukhuleni komnotho wenarha le ngokuza nendlela yokwenza imikhiqizo emitjha - njengezokuzithabisa - nokurherha amathalente amatjha. Abantu abahlukahlukeneko abasemabubulweni la beza nemibono emitjha eyenza kuthathwe iinqunto ezingcono, kukhuphule indlela yokurarulula imiraro neyokuza neendlela ezitjha zokwenza imikhiqizo. Ngaphezu kwalokho inarha le ikghona ukuletha inzuzo ekulu ngamaziko wezokuvakatjha newokwenza imitlamo emitjha.&lt;ref&gt;{{Cite web|title=how cultural diversity improves economic growth in south africa - Google Search|url=https://www.google.com/search?q=how+cultural+diversity+improves+economic+growth+in+south+africa&amp;sca_esv=595de8d130c61221&amp;rlz=1C1JJTC_enZA1159ZA1159&amp;sxsrf=AE3TifPbzq6OPF4689gtEIaG4WfdKVsDrg:1748523734674&amp;ei=1lo4aPb8KO6zhbIP7ZzH8Qk&amp;oq=how+cultural+diversity+improves+econo+in+south+africa&amp;gs_lp=Egxnd3Mtd2l6LXNlcnAiNWhvdyBjdWx0dXJhbCBkaXZlcnNpdHkgaW1wcm92ZXMgZWNvbm8gaW4gc291dGggYWZyaWNhKgIIADIKECEYoAEYwwQYCjIKECEYoAEYwwQYCjIKECEYoAEYwwQYCjIKECEYoAEYwwQYCkj8O1D2Dli8H3ACeAGQAQCYAYMDoAHsDaoBAzMtNbgBAcgBAPgBAZgCBKAC1gbCAgoQABiwAxjWBBhHwgIIEAAYgAQYogTCAgUQABjvBcICCBAAGKIEGIkFmAMAiAYBkAYIkgcFMi40LTKgB8sqsgcDNC0yuAevBsIHBTMtMy4xyAc-&amp;sclient=gws-wiz-serp|access-date=2025-05-29|website=www.google.com}}&lt;/ref&gt;

=== Kwezefundo ===
Ukuhluka kwesikopilo eSewula Afrika kuyithuthukisile ifundo ngokwenza abafundi bafunde ukuhlalisana nokusebenzisana emsebenzinabo yesikolo ngitjho nanyana bavela eenzindeni ezingafaniko. Lokho kubafundisa ukusebenzisana ngitjho nanyana sele baqedile isikolo basebenza. Kubenze baba nomqondo ovulekileko, bazithemba khudlwana begodu kwabasiza bakghona ukuzwisisa amasiko ahlukahlukeneko. Yeke ngokwamukela ifundo ngokuhlukahluka kwesikopilo, iinkolo zikghona ukuba nendawo engcono yokufundela khona amakghono wokucabanga azokuthuthuke, kwehlise nebandlululo.&lt;ref&gt;{{Cite web|date=2025-05-14|title=The Importance of Multicultural Education|url=https://drexel.edu/soe/resources/student-teaching/advice/importance-of-cultural-diversity-in-classroom/|access-date=2025-05-29|website=School of Education|language=en}}&lt;/ref&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>7itoknjvahwdmtx99blkcl1hwnup0gh</sha1>
    </revision>
  </page>
  <page>
    <title>Ukulondolozwa Kwamalimi Wendabuko WeSewula Afrika</title>
    <ns>0</ns>
    <id>607</id>
    <revision>
      <id>2864</id>
      <timestamp>2025-05-29T21:13:37Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <comment>Wrote an article</comment>
      <origin>2864</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7948" sha1="891y9ha48p03fug72plcd0efm60bvpk" xml:space="preserve">[[Isimumathi:Variety_of_male_human_faces_(collage).jpg|thumb|Abantu bemihlobo ehlukahlukeneko]]
'''ESewula''' Afrika kunamalimi ali-12 akhulunywako, amalimi la yisiNgisi, i-Afrikaans, isiZulu, isiXhosa, iSepedi, isiTsonga, isiTshivenda, isiSwati, isiNdebele, isiTswana, isiSotho seSewula Afrika nelimi lezandla leSewula Afrika. Kodwana kunamanye amalimi angakatloliswa ngokomthetho njengesiLobedu, isi-Korana, isi-Nluu, isi-Xiri namanye.  &lt;ref&gt;{{Cite web|last=Alexander|first=Mary|date=2025-04-06|title=The languages of South Africa|url=https://southafrica-info.com/arts-culture/11-languages-south-africa/|access-date=2025-05-22|website=South Africa Gateway|language=en-GB}}&lt;/ref&gt; UmThethosisekelo uthi amalimi la, khulukhulu wenda
{| class=&quot;wikitable&quot;
|+
!Amalimi
wesiNguni
!Amalimi
wesiSotho
!Amalimi
wesiKhuwa
!Eminye
Imihlobo Yamalimi
|-
|IsiZulu
|IsiPedi
|IsiNgisi
|isiTsonga
|-
|IsiXhosa
|IsiSotho
|I-Afrikaans
|IsiVenda
|-
|IsiNdebele
|IsiTswana
|
|Ilimi Lezandla
|-
|IsiSwati
|
|
|
|}
buko kufuze alondolozwe namkha abulungwe.&lt;ref&gt;{{Cite web|title=The SA Constitution|url=https://www.justice.gov.za/constitution/chp01.html|access-date=2025-05-22|website=www.justice.gov.za}}&lt;/ref&gt;

Amalimi la ahlukaniswe ngokuya ngokwemihlobo emine. Ahlukaniswe ngendlela ahlobene begodu afana ngakho.

* amalimi wesiNguni
* amalimi wesiSotho
* amailimi wesikhuwa &lt;ref name=&quot;:0&quot;&gt;{{Cite web|date=2025-05-25|title=South Africa - Languages, Dialects, Afrikaans {{!}} Britannica|url=https://www.britannica.com/place/South-Africa/Languages|access-date=2025-05-29|website=www.britannica.com|language=en}}&lt;/ref&gt;

=== '''Amalimi wesiNguni:''' ===

* isiZulu- ilimi leli likhulunywa maZulu
* isiXhoza- ilimi leli likhulunywa maXhoza
* isiNdebele- ilimi leli likhulinywa maNdebele
* isiSwati- ilimi leli likhulunywa maSwati&lt;ref name=&quot;:0&quot; /&gt;

=== '''Amalimi wesiSotho:''' ===

* Sepedi (seSotho sa Leboa) -ilimi leli likhulunywa baPedi
* seSotho- Leli ilimi likhulunywa beSotho
* siTswana- ilimi leli likhulunywa beTswana

=== '''Omunye Umhlobo Wamalimi''' ===

* Tshivenda- ilimi leli likhulunywa maVenda

* xiTsonga- ilimi leli likhulunywa maTsonga&lt;ref name=&quot;:0&quot; /&gt;

=== '''Amalimi wesiKhuwa:''' ===

* Isikhuwa (English) - ilimi leli likhulunywa maNgisi
* Afrikaans - ilimi leli likhulunywa ma-Afrikaaners&lt;ref name=&quot;:0&quot; /&gt;

== Isizathu Sokulondolozwa Kwamalimi La ==
Ukulondolozwa kwamalimi wendabuko eSewula Afrika kuqakatheke khulu ngombana kwenza abantu bakghone ukukhulumisana kuhle bebazwisisane kuhle ngamalimi abawamunyileko bese lokho kwenza ilimi lingafi kodwana lithuthuke. Ukulondolozwa kwelimi kusiza ukundlulisela isizukulwane esiza ngemva ilwazi lelimi lendabuko namasiko wendabuko,  kwenza kube nokuzwana nokubekezelelana nanokuhloniphana emphakathini. Godu kuthuthukisa nezomnotho zeSewula Afrika.&lt;ref&gt;{{Cite web|last=Baker|first=Abigail|date=2024-10-11|title=PRESERVING SOUTH AFRICA'S INDIGENOUS LANGUAGES: A LIVING LEGACY FOR FUTURE GENERATIONS|url=https://fwdeklerk.org/preserving-south-africas-indigenous-languages-a-living-legacy-for-future-generations/|access-date=2025-05-29|website=FW de Klerk Foundation|language=en-US}}&lt;/ref&gt;

Ihlathululo yaloku okubalwe ngaphezulu:

'''Ukufa kwelimi'''

Ukufa kwelimi nofana ukungasebenzisi ilimi lendabuko kungabangela ukulahleka kwesiko, kuphazamise nokuhlalisana kuhle emphakathini. Loke ilwazi elimayelana nobukghwari, amasiko, imikghwa yokuphatha abantu ngehlonipho, neemfundo eziqakathekileko epilweni kuyafa kuphele lokha ilimi nalifako. Bona kubabalele ilwazelo ilimi kufuze lilondolozwe bona lingafi. &lt;ref name=&quot;:1&quot;&gt;{{Cite web|title=Google Search|url=https://www.google.com/search?q=reasons+for+preserving+languages+in+south+africa&amp;rlz=1C1JJTC_enZA1156ZA1159&amp;oq=reasons+for+preserving+languages+in+south+africa&amp;gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIKCAEQABiiBBiJBTIHCAIQABjvBTIHCAMQABjvBTIKCAQQABiABBiiBDIGCAUQRRg8MgYIBhBFGDwyBggHEEUYPNIBCTE2MTE1ajBqNKgCALACAQ&amp;sourceid=chrome&amp;ie=UTF-8|access-date=2025-05-29|website=www.google.com}}&lt;/ref&gt;

'''Ukudlulisela ilwazi lwelimi namasiko wendabuko'''

Ukulondoloza ilimi nesikopilo lendabuko kusiza ukuthi loke ilwazi lidluliselwe kusizukulwana esiza ngemva lokho kuzokwenza ilimi liragele phambili likhulunywa namasiko nawo aragele phambile.&lt;ref name=&quot;:1&quot; /&gt; Ngokwesibonelo, kunemithi yesintu esetjenziswa sitjhaba esithileko kodwana engekho kesinye isitjhaba. Lokha iintjhaba ezimbili nazikhulumisanako zikghona ukwabelana ngelwazi lezokwelapha, nemiithi yendabuko nalokho ekulaphako.

'''Ukubambisana komphakathi'''

Ukulondolozwa kwelimi kuthuthukisa ukubambisana emphakathini, ukuhloniphana nokuthula. Kwenza umphakathi uhloniphe amanye amalimi begodu uwaqale njengaqakathekileko.&lt;ref name=&quot;:1&quot; /&gt; Ngokwesibonelo, kuba nokubambisana emalungwini womphakathi azwisisanako, begodu kuvula ithuba lokuveza imibono, ukuze kuthathwe iinqunto ezivuthiweko ezingasiza umphakathi.

'''Ukuthuthuka komnotho'''

Ukulondolozwa kwelimi kungavula amathuba amanengi womsebenzi khulukhulu kilaba abanekareko yokusebenza ngamalimi wendabuko.&lt;ref name=&quot;:1&quot; /&gt; Ngokwesibonelo, abantu abakghona ukukhuluma amalimi amanengana banamathuba amanengi wokuqatjhwa emisebenzini nemabubulweni asebenza ngabantu beenzinda ezihlukahlukeneko. Ukuqatjhwa kwabantwaba kuthuthukisa umnotho wenarha.

== Angalondolozwa njani amalimi wendabuko ==
Ukulondolozwa kwamalimi wendabuko weSewula Afrika kutloga iindlela ezihlukahlukeneko zokurarulula umraro wokulondolozwa kwawo. kuneendlela ezimbalwa ezingasebenzizwa ukulondolozwa kwamalimi wendabuko, kokuthoma kufundisa nofana ukudlulisela ilwazi ngamalimi wendabuko. Kwesibili ukusebenzisa itheknoloji ekufundiseni nekuthuthukiseni ilimi. Kwesithathu ukutlola phasi nokuzihlanganisa nomphakathi.&lt;ref name=&quot;:2&quot;&gt;{{Cite web|title=Google Search|url=https://www.google.com/search?q=how+do+we+preserve+south+african+indigenous+languages&amp;rlz=1C1JJTC_enZA1156ZA1159&amp;oq=how+do+we+preserve+south+african+indigenous+lan&amp;gs_lcrp=EgZjaHJvbWUqBggDECEYFTIGCAAQRRg5MgkIARAhGAoYoAEyCQgCECEYChigATIGCAMQIRgVMgcIBBAhGJ8FMgcIBRAhGI8C0gEJNDY4MjJqMGo5qAIAsAIB&amp;sourceid=chrome&amp;ie=UTF-8|access-date=2025-05-29|website=www.google.com}}&lt;/ref&gt;

'''Fundisa ngelimi leNdabuko'''

Ukufundisa ngelimi lendabuko ezikolweni zamabanga aphasi naphezulu kungasiza ukuthi ilimi lilondolozwe. Irhubhullulo likhombisa ukuthi abantwana abaningi baphasa kuhle khulu nabafundiswa ngamalimi abawamunyileko. Kutlogeka izincwadi zamalimi wendabuko nezinye izinto ezingasebenzizwa bona kufundiswe abanye bunqopha nofana online.&lt;ref name=&quot;:2&quot; /&gt;

'''Ukusebenziswa kwetheknoloji'''

Ukutjhugululwa kwezincwadi zamalimi wendabuko zenziwe ihlelo elilalelwako, lokho kungenye yezindlela ezisebenzako zokulondoloza amalimi begodu kwenza kube lula ukuthi zihlale isikhathi eside bezitholakale lula. Ukwenza isihlathululi magama App(online dictionery)  namanye amahlelo wetheknoloji ngamalimi wendabuko angasiza ukuthuthukisa  nokulondoloza begodu kubalula ukuthi zitholakale kiwo woke umunyu osebenzisa itheknoloji.&lt;ref name=&quot;:2&quot; /&gt;

Ukutjhugulula, amaziko welimi wetheknoloji nama-''software'' asetjenziswa khudlwana emalimini wendabuko godu asiza amalimi bona alondolozwe bulula godu nabantu bazokujwayelana khulu netheknoloji ngoba izokuzwisiseka ngcono.&lt;ref name=&quot;:2&quot; /&gt;

'''Ukuzibandakanya komphakathi ekuthuthukiseni ilimi'''

Ukukhuthaza nokusekela igadango lokurhatjha ngamalimi wendabuko kumabona kude nasemrhatjhweni lokho kudlala indima ekulu ekulondolozeni amalimi wendabuko. Ukusekela umphakathi nawenza iminyanya ethuthukisa amasiko namalimi wendabuko kungaba nomthelela omuhle.&lt;ref name=&quot;:2&quot; /&gt;

Ukutholakala kwabatjhugululi bamalimi wendabuko kusiza amalunga womphakathi ukuthi bathole ilwazi begodu bazwisise kuhle ezinye zezinto ezibhalwe ngesikhuwa. ukusebenzisa zokuqhumana (social media) ngamalimi wendabuko nokuzihlanganisa neziqhema zabantu abakhuluma amalimi wendabuko online lokho nakho kuthuthukisa bekulondoloze ilimi.&lt;ref name=&quot;:2&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>891y9ha48p03fug72plcd0efm60bvpk</sha1>
    </revision>
    <revision>
      <id>2865</id>
      <parentid>2864</parentid>
      <timestamp>2025-05-29T21:17:36Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <comment>fixed allignment</comment>
      <origin>2865</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7948" sha1="gzrpokenn0e4jcfw29obwlmnnhwofkl" xml:space="preserve">[[Isimumathi:Variety_of_male_human_faces_(collage).jpg|thumb|Abantu bemihlobo ehlukahlukeneko]]
'''ESewula''' Afrika kunamalimi ali-12 akhulunywako, amalimi la yisiNgisi, i-Afrikaans, isiZulu, isiXhosa, iSepedi, isiTsonga, isiTshivenda, isiSwati, isiNdebele, isiTswana, isiSotho seSewula Afrika nelimi lezandla leSewula Afrika. Kodwana kunamanye amalimi angakatloliswa ngokomthetho njengesiLobedu, isi-Korana, isi-Nluu, isi-Xiri namanye.  &lt;ref&gt;{{Cite web|last=Alexander|first=Mary|date=2025-04-06|title=The languages of South Africa|url=https://southafrica-info.com/arts-culture/11-languages-south-africa/|access-date=2025-05-22|website=South Africa Gateway|language=en-GB}}&lt;/ref&gt; UmThethosisekelo uthi amalimi la, khulukhulu wendabuko kufuze alondolozwe namkha abulungwe.&lt;ref&gt;{{Cite web|title=The SA Constitution|url=https://www.justice.gov.za/constitution/chp01.html|access-date=2025-05-22|website=www.justice.gov.za}}&lt;/ref&gt;
{| class=&quot;wikitable&quot;
|+
!Amalimi
wesiNguni
!Amalimi
wesiSotho
!Amalimi
wesiKhuwa
!Eminye
Imihlobo Yamalimi
|-
|IsiZulu
|IsiPedi
|IsiNgisi
|isiTsonga
|-
|IsiXhosa
|IsiSotho
|I-Afrikaans
|IsiVenda
|-
|IsiNdebele
|IsiTswana
|
|Ilimi Lezandla
|-
|IsiSwati
|
|
|
|}


Amalimi la ahlukaniswe ngokuya ngokwemihlobo emine. Ahlukaniswe ngendlela ahlobene begodu afana ngakho.

* amalimi wesiNguni
* amalimi wesiSotho
* amailimi wesikhuwa &lt;ref name=&quot;:0&quot;&gt;{{Cite web|date=2025-05-25|title=South Africa - Languages, Dialects, Afrikaans {{!}} Britannica|url=https://www.britannica.com/place/South-Africa/Languages|access-date=2025-05-29|website=www.britannica.com|language=en}}&lt;/ref&gt;

=== '''Amalimi wesiNguni:''' ===

* isiZulu- ilimi leli likhulunywa maZulu
* isiXhoza- ilimi leli likhulunywa maXhoza
* isiNdebele- ilimi leli likhulinywa maNdebele
* isiSwati- ilimi leli likhulunywa maSwati&lt;ref name=&quot;:0&quot; /&gt;

=== '''Amalimi wesiSotho:''' ===

* Sepedi (seSotho sa Leboa) -ilimi leli likhulunywa baPedi
* seSotho- Leli ilimi likhulunywa beSotho
* siTswana- ilimi leli likhulunywa beTswana

=== '''Omunye Umhlobo Wamalimi''' ===

* Tshivenda- ilimi leli likhulunywa maVenda

* xiTsonga- ilimi leli likhulunywa maTsonga&lt;ref name=&quot;:0&quot; /&gt;

=== '''Amalimi wesiKhuwa:''' ===

* Isikhuwa (English) - ilimi leli likhulunywa maNgisi
* Afrikaans - ilimi leli likhulunywa ma-Afrikaaners&lt;ref name=&quot;:0&quot; /&gt;

== Isizathu Sokulondolozwa Kwamalimi La ==
Ukulondolozwa kwamalimi wendabuko eSewula Afrika kuqakatheke khulu ngombana kwenza abantu bakghone ukukhulumisana kuhle bebazwisisane kuhle ngamalimi abawamunyileko bese lokho kwenza ilimi lingafi kodwana lithuthuke. Ukulondolozwa kwelimi kusiza ukundlulisela isizukulwane esiza ngemva ilwazi lelimi lendabuko namasiko wendabuko,  kwenza kube nokuzwana nokubekezelelana nanokuhloniphana emphakathini. Godu kuthuthukisa nezomnotho zeSewula Afrika.&lt;ref&gt;{{Cite web|last=Baker|first=Abigail|date=2024-10-11|title=PRESERVING SOUTH AFRICA'S INDIGENOUS LANGUAGES: A LIVING LEGACY FOR FUTURE GENERATIONS|url=https://fwdeklerk.org/preserving-south-africas-indigenous-languages-a-living-legacy-for-future-generations/|access-date=2025-05-29|website=FW de Klerk Foundation|language=en-US}}&lt;/ref&gt;

Ihlathululo yaloku okubalwe ngaphezulu:

'''Ukufa kwelimi'''

Ukufa kwelimi nofana ukungasebenzisi ilimi lendabuko kungabangela ukulahleka kwesiko, kuphazamise nokuhlalisana kuhle emphakathini. Loke ilwazi elimayelana nobukghwari, amasiko, imikghwa yokuphatha abantu ngehlonipho, neemfundo eziqakathekileko epilweni kuyafa kuphele lokha ilimi nalifako. Bona kubabalele ilwazelo ilimi kufuze lilondolozwe bona lingafi. &lt;ref name=&quot;:1&quot;&gt;{{Cite web|title=Google Search|url=https://www.google.com/search?q=reasons+for+preserving+languages+in+south+africa&amp;rlz=1C1JJTC_enZA1156ZA1159&amp;oq=reasons+for+preserving+languages+in+south+africa&amp;gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIKCAEQABiiBBiJBTIHCAIQABjvBTIHCAMQABjvBTIKCAQQABiABBiiBDIGCAUQRRg8MgYIBhBFGDwyBggHEEUYPNIBCTE2MTE1ajBqNKgCALACAQ&amp;sourceid=chrome&amp;ie=UTF-8|access-date=2025-05-29|website=www.google.com}}&lt;/ref&gt;

'''Ukudlulisela ilwazi lwelimi namasiko wendabuko'''

Ukulondoloza ilimi nesikopilo lendabuko kusiza ukuthi loke ilwazi lidluliselwe kusizukulwana esiza ngemva lokho kuzokwenza ilimi liragele phambili likhulunywa namasiko nawo aragele phambile.&lt;ref name=&quot;:1&quot; /&gt; Ngokwesibonelo, kunemithi yesintu esetjenziswa sitjhaba esithileko kodwana engekho kesinye isitjhaba. Lokha iintjhaba ezimbili nazikhulumisanako zikghona ukwabelana ngelwazi lezokwelapha, nemiithi yendabuko nalokho ekulaphako.

'''Ukubambisana komphakathi'''

Ukulondolozwa kwelimi kuthuthukisa ukubambisana emphakathini, ukuhloniphana nokuthula. Kwenza umphakathi uhloniphe amanye amalimi begodu uwaqale njengaqakathekileko.&lt;ref name=&quot;:1&quot; /&gt; Ngokwesibonelo, kuba nokubambisana emalungwini womphakathi azwisisanako, begodu kuvula ithuba lokuveza imibono, ukuze kuthathwe iinqunto ezivuthiweko ezingasiza umphakathi.

'''Ukuthuthuka komnotho'''

Ukulondolozwa kwelimi kungavula amathuba amanengi womsebenzi khulukhulu kilaba abanekareko yokusebenza ngamalimi wendabuko.&lt;ref name=&quot;:1&quot; /&gt; Ngokwesibonelo, abantu abakghona ukukhuluma amalimi amanengana banamathuba amanengi wokuqatjhwa emisebenzini nemabubulweni asebenza ngabantu beenzinda ezihlukahlukeneko. Ukuqatjhwa kwabantwaba kuthuthukisa umnotho wenarha.

== Angalondolozwa njani amalimi wendabuko ==
Ukulondolozwa kwamalimi wendabuko weSewula Afrika kutloga iindlela ezihlukahlukeneko zokurarulula umraro wokulondolozwa kwawo. kuneendlela ezimbalwa ezingasebenzizwa ukulondolozwa kwamalimi wendabuko, kokuthoma kufundisa nofana ukudlulisela ilwazi ngamalimi wendabuko. Kwesibili ukusebenzisa itheknoloji ekufundiseni nekuthuthukiseni ilimi. Kwesithathu ukutlola phasi nokuzihlanganisa nomphakathi.&lt;ref name=&quot;:2&quot;&gt;{{Cite web|title=Google Search|url=https://www.google.com/search?q=how+do+we+preserve+south+african+indigenous+languages&amp;rlz=1C1JJTC_enZA1156ZA1159&amp;oq=how+do+we+preserve+south+african+indigenous+lan&amp;gs_lcrp=EgZjaHJvbWUqBggDECEYFTIGCAAQRRg5MgkIARAhGAoYoAEyCQgCECEYChigATIGCAMQIRgVMgcIBBAhGJ8FMgcIBRAhGI8C0gEJNDY4MjJqMGo5qAIAsAIB&amp;sourceid=chrome&amp;ie=UTF-8|access-date=2025-05-29|website=www.google.com}}&lt;/ref&gt;

'''Fundisa ngelimi leNdabuko'''

Ukufundisa ngelimi lendabuko ezikolweni zamabanga aphasi naphezulu kungasiza ukuthi ilimi lilondolozwe. Irhubhullulo likhombisa ukuthi abantwana abaningi baphasa kuhle khulu nabafundiswa ngamalimi abawamunyileko. Kutlogeka izincwadi zamalimi wendabuko nezinye izinto ezingasebenzizwa bona kufundiswe abanye bunqopha nofana online.&lt;ref name=&quot;:2&quot; /&gt;

'''Ukusebenziswa kwetheknoloji'''

Ukutjhugululwa kwezincwadi zamalimi wendabuko zenziwe ihlelo elilalelwako, lokho kungenye yezindlela ezisebenzako zokulondoloza amalimi begodu kwenza kube lula ukuthi zihlale isikhathi eside bezitholakale lula. Ukwenza isihlathululi magama App(online dictionery)  namanye amahlelo wetheknoloji ngamalimi wendabuko angasiza ukuthuthukisa  nokulondoloza begodu kubalula ukuthi zitholakale kiwo woke umunyu osebenzisa itheknoloji.&lt;ref name=&quot;:2&quot; /&gt;

Ukutjhugulula, amaziko welimi wetheknoloji nama-''software'' asetjenziswa khudlwana emalimini wendabuko godu asiza amalimi bona alondolozwe bulula godu nabantu bazokujwayelana khulu netheknoloji ngoba izokuzwisiseka ngcono.&lt;ref name=&quot;:2&quot; /&gt;

'''Ukuzibandakanya komphakathi ekuthuthukiseni ilimi'''

Ukukhuthaza nokusekela igadango lokurhatjha ngamalimi wendabuko kumabona kude nasemrhatjhweni lokho kudlala indima ekulu ekulondolozeni amalimi wendabuko. Ukusekela umphakathi nawenza iminyanya ethuthukisa amasiko namalimi wendabuko kungaba nomthelela omuhle.&lt;ref name=&quot;:2&quot; /&gt;

Ukutholakala kwabatjhugululi bamalimi wendabuko kusiza amalunga womphakathi ukuthi bathole ilwazi begodu bazwisise kuhle ezinye zezinto ezibhalwe ngesikhuwa. ukusebenzisa zokuqhumana (social media) ngamalimi wendabuko nokuzihlanganisa neziqhema zabantu abakhuluma amalimi wendabuko online lokho nakho kuthuthukisa bekulondoloze ilimi.&lt;ref name=&quot;:2&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>gzrpokenn0e4jcfw29obwlmnnhwofkl</sha1>
    </revision>
    <revision>
      <id>2866</id>
      <parentid>2865</parentid>
      <timestamp>2025-05-29T21:27:49Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <comment>spelling error</comment>
      <origin>2866</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7975" sha1="nscmy9sxuza2kmh3w07kv9y4kjn4sr9" xml:space="preserve">[[Isimumathi:Variety_of_male_human_faces_(collage).jpg|thumb|Abantu bemihlobo ehlukahlukeneko]]
'''ESewula''' Afrika kunamalimi ali-12 akhulunywako, amalimi la yisiNgisi, i-Afrikaans, isiZulu, isiXhosa, iSepedi, isiTsonga, isiTshivenda, isiSwati, isiNdebele, isiTswana, isiSotho seSewula Afrika nelimi lezandla leSewula Afrika. Kodwana kunamanye amalimi angakatloliswa ngokomthetho njengesiLobedu, isi-Korana, isi-Nluu, isi-Xiri namanye.  &lt;ref&gt;{{Cite web|last=Alexander|first=Mary|date=2025-04-06|title=The languages of South Africa|url=https://southafrica-info.com/arts-culture/11-languages-south-africa/|access-date=2025-05-22|website=South Africa Gateway|language=en-GB}}&lt;/ref&gt; UmThethosisekelo uthi amalimi la, khulukhulu wendabuko kufuze alondolozwe namkha abulungwe.&lt;ref&gt;{{Cite web|title=The SA Constitution|url=https://www.justice.gov.za/constitution/chp01.html|access-date=2025-05-22|website=www.justice.gov.za}}&lt;/ref&gt;
{| class=&quot;wikitable&quot;
|+
!Amalimi
wesiNguni
!Amalimi
wesiSotho
!Amalimi
wesiKhuwa
!Eminye
Imihlobo Yamalimi
|-
|IsiZulu
|IsiPedi
|IsiNgisi
|isiTsonga
|-
|IsiXhosa
|IsiSotho
|I-Afrikaans
|IsiVenda
|-
|IsiNdebele
|IsiTswana
|
|Ilimi Lezandla
|-
|IsiSwati
|
|
|
|}


Amalimi la ahlukaniswe ngokuya ngokwemihlobo emine. Ahlukaniswe ngendlela ahlobene begodu afana ngakho.

* amalimi wesiNguni
* amalimi wesiSotho
* amailimi wesikhuwa
* eminye imihlobo yamalimi &lt;ref name=&quot;:0&quot;&gt;{{Cite web|date=2025-05-25|title=South Africa - Languages, Dialects, Afrikaans {{!}} Britannica|url=https://www.britannica.com/place/South-Africa/Languages|access-date=2025-05-29|website=www.britannica.com|language=en}}&lt;/ref&gt;

=== '''Amalimi wesiNguni:''' ===

* isiZulu- ilimi leli likhulunywa maZulu
* isiXhoza- ilimi leli likhulunywa maXhoza
* isiNdebele- ilimi leli likhulinywa maNdebele
* isiSwati- ilimi leli likhulunywa maSwati&lt;ref name=&quot;:0&quot; /&gt;

=== '''Amalimi wesiSotho:''' ===

* Sepedi (seSotho sa Leboa) -ilimi leli likhulunywa baPedi
* seSotho- Leli ilimi likhulunywa beSotho
* siTswana- ilimi leli likhulunywa beTswana

=== '''Omunye Umhlobo Wamalimi''' ===

* Tshivenda- ilimi leli likhulunywa maVenda

* xiTsonga- ilimi leli likhulunywa maTsonga&lt;ref name=&quot;:0&quot; /&gt;

=== '''Amalimi wesiKhuwa:''' ===

* Isikhuwa (English) - ilimi leli likhulunywa maNgisi
* Afrikaans - ilimi leli likhulunywa ma-Afrikaaners&lt;ref name=&quot;:0&quot; /&gt;

== Isizathu Sokulondolozwa Kwamalimi La ==
Ukulondolozwa kwamalimi wendabuko eSewula Afrika kuqakatheke khulu ngombana kwenza abantu bakghone ukukhulumisana kuhle bebazwisisane kuhle ngamalimi abawamunyileko bese lokho kwenza ilimi lingafi kodwana lithuthuke. Ukulondolozwa kwelimi kusiza ukundlulisela isizukulwane esiza ngemva ilwazi lelimi lendabuko namasiko wendabuko,  kwenza kube nokuzwana nokubekezelelana nanokuhloniphana emphakathini. Godu kuthuthukisa nezomnotho zeSewula Afrika.&lt;ref&gt;{{Cite web|last=Baker|first=Abigail|date=2024-10-11|title=PRESERVING SOUTH AFRICA'S INDIGENOUS LANGUAGES: A LIVING LEGACY FOR FUTURE GENERATIONS|url=https://fwdeklerk.org/preserving-south-africas-indigenous-languages-a-living-legacy-for-future-generations/|access-date=2025-05-29|website=FW de Klerk Foundation|language=en-US}}&lt;/ref&gt;

Ihlathululo yaloku okubalwe ngaphezulu:

'''Ukufa kwelimi'''

Ukufa kwelimi nofana ukungasebenzisi ilimi lendabuko kungabangela ukulahleka kwesiko, kuphazamise nokuhlalisana kuhle emphakathini. Loke ilwazi elimayelana nobukghwari, amasiko, imikghwa yokuphatha abantu ngehlonipho, neemfundo eziqakathekileko epilweni kuyafa kuphele lokha ilimi nalifako. Bona kubabalele ilwazelo ilimi kufuze lilondolozwe bona lingafi. &lt;ref name=&quot;:1&quot;&gt;{{Cite web|title=Google Search|url=https://www.google.com/search?q=reasons+for+preserving+languages+in+south+africa&amp;rlz=1C1JJTC_enZA1156ZA1159&amp;oq=reasons+for+preserving+languages+in+south+africa&amp;gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIKCAEQABiiBBiJBTIHCAIQABjvBTIHCAMQABjvBTIKCAQQABiABBiiBDIGCAUQRRg8MgYIBhBFGDwyBggHEEUYPNIBCTE2MTE1ajBqNKgCALACAQ&amp;sourceid=chrome&amp;ie=UTF-8|access-date=2025-05-29|website=www.google.com}}&lt;/ref&gt;

'''Ukudlulisela ilwazi lwelimi namasiko wendabuko'''

Ukulondoloza ilimi nesikopilo lendabuko kusiza ukuthi loke ilwazi lidluliselwe kusizukulwana esiza ngemva lokho kuzokwenza ilimi liragele phambili likhulunywa namasiko nawo aragele phambile.&lt;ref name=&quot;:1&quot; /&gt; Ngokwesibonelo, kunemithi yesintu esetjenziswa sitjhaba esithileko kodwana engekho kesinye isitjhaba. Lokha iintjhaba ezimbili nazikhulumisanako zikghona ukwabelana ngelwazi lezokwelapha, nemiithi yendabuko nalokho ekulaphako.

'''Ukubambisana komphakathi'''

Ukulondolozwa kwelimi kuthuthukisa ukubambisana emphakathini, ukuhloniphana nokuthula. Kwenza umphakathi uhloniphe amanye amalimi begodu uwaqale njengaqakathekileko.&lt;ref name=&quot;:1&quot; /&gt; Ngokwesibonelo, kuba nokubambisana emalungwini womphakathi azwisisanako, begodu kuvula ithuba lokuveza imibono, ukuze kuthathwe iinqunto ezivuthiweko ezingasiza umphakathi.

'''Ukuthuthuka komnotho'''

Ukulondolozwa kwelimi kungavula amathuba amanengi womsebenzi khulukhulu kilaba abanekareko yokusebenza ngamalimi wendabuko.&lt;ref name=&quot;:1&quot; /&gt; Ngokwesibonelo, abantu abakghona ukukhuluma amalimi amanengana banamathuba amanengi wokuqatjhwa emisebenzini nemabubulweni asebenza ngabantu beenzinda ezihlukahlukeneko. Ukuqatjhwa kwabantwaba kuthuthukisa umnotho wenarha.

== Angalondolozwa njani amalimi wendabuko ==
Ukulondolozwa kwamalimi wendabuko weSewula Afrika kutloga iindlela ezihlukahlukeneko zokurarulula umraro wokulondolozwa kwawo. kuneendlela ezimbalwa ezingasebenzizwa ukulondolozwa kwamalimi wendabuko, kokuthoma kufundisa nofana ukudlulisela ilwazi ngamalimi wendabuko. Kwesibili ukusebenzisa itheknoloji ekufundiseni nekuthuthukiseni ilimi. Kwesithathu ukutlola phasi nokuzihlanganisa nomphakathi.&lt;ref name=&quot;:2&quot;&gt;{{Cite web|title=Google Search|url=https://www.google.com/search?q=how+do+we+preserve+south+african+indigenous+languages&amp;rlz=1C1JJTC_enZA1156ZA1159&amp;oq=how+do+we+preserve+south+african+indigenous+lan&amp;gs_lcrp=EgZjaHJvbWUqBggDECEYFTIGCAAQRRg5MgkIARAhGAoYoAEyCQgCECEYChigATIGCAMQIRgVMgcIBBAhGJ8FMgcIBRAhGI8C0gEJNDY4MjJqMGo5qAIAsAIB&amp;sourceid=chrome&amp;ie=UTF-8|access-date=2025-05-29|website=www.google.com}}&lt;/ref&gt;

'''Fundisa ngelimi leNdabuko'''

Ukufundisa ngelimi lendabuko ezikolweni zamabanga aphasi naphezulu kungasiza ukuthi ilimi lilondolozwe. Irhubhullulo likhombisa ukuthi abantwana abaningi baphasa kuhle khulu nabafundiswa ngamalimi abawamunyileko. Kutlogeka izincwadi zamalimi wendabuko nezinye izinto ezingasebenzizwa bona kufundiswe abanye bunqopha nofana online.&lt;ref name=&quot;:2&quot; /&gt;

'''Ukusebenziswa kwetheknoloji'''

Ukutjhugululwa kwezincwadi zamalimi wendabuko zenziwe ihlelo elilalelwako, lokho kungenye yezindlela ezisebenzako zokulondoloza amalimi begodu kwenza kube lula ukuthi zihlale isikhathi eside bezitholakale lula. Ukwenza isihlathululi magama App(online dictionery)  namanye amahlelo wetheknoloji ngamalimi wendabuko angasiza ukuthuthukisa  nokulondoloza begodu kubalula ukuthi zitholakale kiwo woke umunyu osebenzisa itheknoloji.&lt;ref name=&quot;:2&quot; /&gt;

Ukutjhugulula, amaziko welimi wetheknoloji nama-''software'' asetjenziswa khudlwana emalimini wendabuko godu asiza amalimi bona alondolozwe bulula godu nabantu bazokujwayelana khulu netheknoloji ngoba izokuzwisiseka ngcono.&lt;ref name=&quot;:2&quot; /&gt;

'''Ukuzibandakanya komphakathi ekuthuthukiseni ilimi'''

Ukukhuthaza nokusekela igadango lokurhatjha ngamalimi wendabuko kumabona kude nasemrhatjhweni lokho kudlala indima ekulu ekulondolozeni amalimi wendabuko. Ukusekela umphakathi nawenza iminyanya ethuthukisa amasiko namalimi wendabuko kungaba nomthelela omuhle.&lt;ref name=&quot;:2&quot; /&gt;

Ukutholakala kwabatjhugululi bamalimi wendabuko kusiza amalunga womphakathi ukuthi bathole ilwazi begodu bazwisise kuhle ezinye zezinto ezibhalwe ngesikhuwa. ukusebenzisa zokuqhumana (social media) ngamalimi wendabuko nokuzihlanganisa neziqhema zabantu abakhuluma amalimi wendabuko online lokho nakho kuthuthukisa bekulondoloze ilimi.&lt;ref name=&quot;:2&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>nscmy9sxuza2kmh3w07kv9y4kjn4sr9</sha1>
    </revision>
    <revision>
      <id>2871</id>
      <parentid>2866</parentid>
      <timestamp>2025-05-30T15:13:46Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <comment>spelling errors fix</comment>
      <origin>2871</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7966" sha1="h91zuzhmw209b770gkfol4y6wb9f9xj" xml:space="preserve">[[Isimumathi:Variety_of_male_human_faces_(collage).jpg|thumb|Abantu bemihlobo ehlukahlukeneko]]
'''ESewula''' Afrika kunamalimi ali-12 akhulunywako, amalimi la yisiNgisi, i-Afrikaans, isiZulu, isiXhosa, iSepedi, isiTsonga, isiTshivenda, isiSwati, isiNdebele, isiTswana, isiSotho seSewula Afrika nelimi lezandla leSewula Afrika. Kodwana kunamanye amalimi angakatloliswa ngokomthetho njengesiLobedu, isi-Korana, isi-Nluu, isi-Xiri namanye.  &lt;ref&gt;{{Cite web|last=Alexander|first=Mary|date=2025-04-06|title=The languages of South Africa|url=https://southafrica-info.com/arts-culture/11-languages-south-africa/|access-date=2025-05-22|website=South Africa Gateway|language=en-GB}}&lt;/ref&gt; UmThethosisekelo uthi amalimi la, khulukhulu wendabuko kufuze alondolozwe namkha abulungwe.&lt;ref&gt;{{Cite web|title=The SA Constitution|url=https://www.justice.gov.za/constitution/chp01.html|access-date=2025-05-22|website=www.justice.gov.za}}&lt;/ref&gt;
{| class=&quot;wikitable&quot;
|+
!Amalimi
wesiNguni
!Amalimi
wesiSotho
!Amalimi
wesiKhuwa
!Eminye
Imihlobo Yamalimi
|-
|IsiZulu
|IsiPedi
|IsiNgisi
|isiTsonga
|-
|IsiXhosa
|IsiSotho
|I-Afrikaans
|IsiVenda
|-
|IsiNdebele
|IsiTswana
|
|Ilimi Lezandla
|-
|IsiSwati
|
|
|
|}


Amalimi la ahlukaniswe ngokuya ngokwemihlobo emine. Ahlukaniswe ngendlela ahlobene begodu afana ngakho.

* amalimi wesiNguni
* amalimi wesiSotho
* amailimi wesikhuwa
* eminye imihlobo yamalimi &lt;ref name=&quot;:0&quot;&gt;{{Cite web|date=2025-05-25|title=South Africa - Languages, Dialects, Afrikaans {{!}} Britannica|url=https://www.britannica.com/place/South-Africa/Languages|access-date=2025-05-29|website=www.britannica.com|language=en}}&lt;/ref&gt;

=== '''Amalimi wesiNguni:''' ===

* isiZulu- ilimi leli likhulunywa maZulu
* isiXhoza- ilimi leli likhulunywa maXhoza
* isiNdebele- ilimi leli likhulinywa maNdebele
* isiSwati- ilimi leli likhulunywa maSwati&lt;ref name=&quot;:0&quot; /&gt;

=== '''Amalimi wesiSotho:''' ===

* Sepedi (seSotho sa Leboa) -ilimi leli likhulunywa baPedi
* seSotho- Leli ilimi likhulunywa beSotho
* siTswana- ilimi leli likhulunywa beTswana

=== '''Omunye Umhlobo Wamalimi''' ===

* Tshivenda- ilimi leli likhulunywa maVenda

* xiTsonga- ilimi leli likhulunywa maTsonga&lt;ref name=&quot;:0&quot; /&gt;

=== '''Amalimi wesiKhuwa:''' ===

* Isikhuwa (English) - ilimi leli likhulunywa maNgisi
* Afrikaans - ilimi leli likhulunywa ma-Afrikaaners&lt;ref name=&quot;:0&quot; /&gt;

== Isizathu Sokulondolozwa Kwamalimi La ==
Ukulondolozwa kwamalimi wendabuko eSewula Afrika kuqakatheke khulu ngombana kwenza abantu bakghone ukukhulumisana kuhle bebazwisisane kuhle ngamalimi abawamunyileko bese lokho kwenza ilimi lingafi kodwana lithuthuke. Ukulondolozwa kwelimi kusiza ukundlulisela isizukulwane esiza ngemva ilwazi lelimi lendabuko namasiko wendabuko,  kwenza kube nokuzwana nokubekezelelana nanokuhloniphana emphakathini. Godu kuthuthukisa nezomnotho zeSewula Afrika.&lt;ref&gt;{{Cite web|last=Baker|first=Abigail|date=2024-10-11|title=PRESERVING SOUTH AFRICA'S INDIGENOUS LANGUAGES: A LIVING LEGACY FOR FUTURE GENERATIONS|url=https://fwdeklerk.org/preserving-south-africas-indigenous-languages-a-living-legacy-for-future-generations/|access-date=2025-05-29|website=FW de Klerk Foundation|language=en-US}}&lt;/ref&gt;

Ihlathululo yaloku okubalwe ngaphezulu:

'''Ukufa kwelimi'''

Ukufa kwelimi nofana ukungasebenzisi ilimi lendabuko kungabangela ukulahleka kwesiko, kuphazamise nokuhlalisana kuhle emphakathini. Loke ilwazi elimayelana nobukghwari, amasiko, imikghwa yokuphatha abantu ngehlonipho, neemfundo eziqakathekileko epilweni kuyafa kuphele lokha ilimi nalifako. Bona kubabalele ilwazelo ilimi kufuze lilondolozwe bona lingafi. &lt;ref name=&quot;:1&quot;&gt;{{Cite web|title=Google Search|url=https://www.google.com/search?q=reasons+for+preserving+languages+in+south+africa&amp;rlz=1C1JJTC_enZA1156ZA1159&amp;oq=reasons+for+preserving+languages+in+south+africa&amp;gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIKCAEQABiiBBiJBTIHCAIQABjvBTIHCAMQABjvBTIKCAQQABiABBiiBDIGCAUQRRg8MgYIBhBFGDwyBggHEEUYPNIBCTE2MTE1ajBqNKgCALACAQ&amp;sourceid=chrome&amp;ie=UTF-8|access-date=2025-05-29|website=www.google.com}}&lt;/ref&gt;

'''Ukudlulisela ilwazi lwelimi namasiko wendabuko'''

Ukulondoloza ilimi nesikopilo lendabuko kusiza ukuthi loke ilwazi lidluliselwe kusizukulwana esiza ngemva lokho kuzokwenza ilimi liragele phambili likhulunywa namasiko nawo aragele phambile.&lt;ref name=&quot;:1&quot; /&gt; Ngokwesibonelo, kunemithi yesintu esetjenziswa sitjhaba esithileko kodwana engekho kesinye isitjhaba. Lokha iintjhaba ezimbili nazikhulumisanako zikghona ukwabelana ngelwazi lezokwelapha, nemiithi yendabuko nalokho ekulaphako.

'''Ukubambisana komphakathi'''

Ukulondolozwa kwelimi kuthuthukisa ukubambisana emphakathini, ukuhloniphana nokuthula. Kwenza umphakathi uhloniphe amanye amalimi begodu uwaqale njengaqakathekileko.&lt;ref name=&quot;:1&quot; /&gt; Ngokwesibonelo, kuba nokubambisana emalungwini womphakathi azwisisanako, begodu kuvula ithuba lokuveza imibono, ukuze kuthathwe iinqunto ezivuthiweko ezingasiza umphakathi.

'''Ukuthuthuka komnotho'''

Ukulondolozwa kwelimi kungavula amathuba amanengi womsebenzi khulukhulu kilaba abanekareko yokusebenza ngamalimi wendabuko.&lt;ref name=&quot;:1&quot; /&gt; Ngokwesibonelo, abantu abakghona ukukhuluma amalimi amanengana banamathuba amanengi wokuqatjhwa emisebenzini nemabubulweni asebenza ngabantu beenzinda ezihlukahlukeneko. Ukuqatjhwa kwabantwaba kuthuthukisa umnotho wenarha.

== Angalondolozwa njani amalimi wendabuko ==
Ukulondolozwa kwamalimi wendabuko weSewula Afrika kutlhoga iindlela ezihlukahlukeneko zokurarulula umraro wokulondolozwa kwawo. Kuneendlela ezimbalwa ezingasetjenziselwa ukulondoloza amalimi wendabuko. Kokuthoma kufundisa nofana ukudlulisela ilwazi ngamalimi wendabuko. Kwesibili ukusebenzisa itheknoloji ekufundiseni nekuthuthukiseni ilimi. Kwesithathu ukutlola phasi nokuzihlanganisa nomphakathi.&lt;ref name=&quot;:2&quot;&gt;{{Cite web|title=Google Search|url=https://www.google.com/search?q=how+do+we+preserve+south+african+indigenous+languages&amp;rlz=1C1JJTC_enZA1156ZA1159&amp;oq=how+do+we+preserve+south+african+indigenous+lan&amp;gs_lcrp=EgZjaHJvbWUqBggDECEYFTIGCAAQRRg5MgkIARAhGAoYoAEyCQgCECEYChigATIGCAMQIRgVMgcIBBAhGJ8FMgcIBRAhGI8C0gEJNDY4MjJqMGo5qAIAsAIB&amp;sourceid=chrome&amp;ie=UTF-8|access-date=2025-05-29|website=www.google.com}}&lt;/ref&gt;

'''Fundisa ngelimi leNdabuko'''

Ukufundisa ngelimi lendabuko eenkolweni zamabanga aphasi naphezulu kungasiza ukuthi ilimi lilondolozwe. Irhubhullulo likhombisa ukuthi abantwana abaningi baphasa kuhle khulu nabafundiswa ngamalimi abawamunyileko. Kutlhogeka iincwadi zamalimi wendabuko nezinye izinto ezingasetjenziswa bona kufundiswe abanye bunqopha nofana nge-inthanedi.&lt;ref name=&quot;:2&quot; /&gt;

'''Ukusetjenziswa kwetheknoloji'''

Ukutjhugululwa kwezincwadi zamalimi wendabuko zenziwe ihlelo elilalelwako, lokho kungenye yezindlela ezisebenzako zokulondoloza amalimi begodu kwenza kube lula ukuthi zihlale isikhathi eside bezitholakale lula. Ukwenza isihlathululi magama (''online dictionary'')  namanye amahlelo wetheknoloji ngamalimi wendabuko kungasiza ukuthuthukisa  nokulondoloza begodu kuba lula ukuthi zitholakale kiwo woke umuntu osebenzisa itheknoloji.&lt;ref name=&quot;:2&quot; /&gt;

Ukutjhugulula, amaziko welimi wetheknoloji nama-''software'' asetjenziswa khudlwana emalimini wendabuko godu asiza amalimi bona alondolozwe bulula godu nabantu bazokujwayelana khulu netheknoloji.&lt;ref name=&quot;:2&quot; /&gt;

'''Ukuzibandakanya komphakathi ekuthuthukiseni ilimi'''

Ukukhuthaza nokusekela igadango lokurhatjha ngamalimi wendabuko kumabona kude nasemrhatjhweni lokho kudlala indima ekulu ekulondolozeni amalimi wendabuko. Ukusekela umphakathi nawenza iminyanya ethuthukisa amasiko namalimi wendabuko kungaba nomthelela omuhle.&lt;ref name=&quot;:2&quot; /&gt;

Ukutholakala kwabatjhugululi bamalimi wendabuko kusiza amalunga womphakathi ukuthi athole ilwazi begodu azwisise kuhle ezinye zezinto ezitlolwe ngesikhuwa. Ukusebenzisa iinkundla zokuthintana (''social media'') ngamalimi wendabuko nokuzihlanganisa neeqhema zabantu abakhuluma amalimi wendabuko  lokho nakho kuthuthukisa bekulondoloze ilimi.&lt;ref name=&quot;:2&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>h91zuzhmw209b770gkfol4y6wb9f9xj</sha1>
    </revision>
    <revision>
      <id>3227</id>
      <parentid>2871</parentid>
      <timestamp>2025-06-25T19:07:52Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>spelling</comment>
      <origin>3227</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7734" sha1="twddpmke68kfxg53xncwh4c35ga6m7m" xml:space="preserve">[[Isimumathi:Ndebele women-1.jpg|thumb|233x233px|Abomma bamaNdebele]]
'''ESewula''' Afrika kunamalimi ali-12 akhulunywako, amalimi la yisiNgisi, i-Afrikaans, isiZulu, isiXhosa, iSepedi, isiTsonga, isiTshivenda, isiSwati, isiNdebele, isiTswana, isiSotho seSewula Afrika nelimi lezandla leSewula Afrika. Kodwana kunamanye amalimi angakatloliswa ngokomthetho njengesiLobedu, isi-Korana, isi-Nluu, isi-Xiri namanye.&lt;ref&gt;{{Cite web|last=Alexander|first=Mary|date=2025-04-06|title=The languages of South Africa|url=https://southafrica-info.com/arts-culture/11-languages-south-africa/|access-date=2025-05-22|website=South Africa Gateway|language=en-GB}}&lt;/ref&gt; UmThethosisekelo uthi amalimi la, khulukhulu wendabuko kufuze alondolozwe namkha abulungwe.&lt;ref&gt;{{Cite web|title=The SA Constitution|url=https://www.justice.gov.za/constitution/chp01.html|access-date=2025-05-22|website=www.justice.gov.za}}&lt;/ref&gt; 

Amalimi la ahlukaniswe ngokuya ngokwemihlobo emine. Ahlukaniswe ngendlela ahlobene begodu afana ngakho.

* amalimi wesiNguni
* amalimi we-Sesotho
* amailimi wesikhuwa
* eminye imihlobo yamalimi&lt;ref name=&quot;:0&quot;&gt;{{Cite web|date=2025-05-25|title=South Africa - Languages, Dialects, Afrikaans {{!}} Britannica|url=https://www.britannica.com/place/South-Africa/Languages|access-date=2025-05-29|website=www.britannica.com|language=en}}&lt;/ref&gt;

[[Isimumathi:Zulu Culture.jpg|thumb|234x234px|Abentazana bamaZulu]]

=== '''Amalimi wesiNguni:''' ===

* isiZulu- ilimi leli likhulunywa maZulu
* isiXhoza- ilimi leli likhulunywa maXhoza
* isiNdebele- ilimi leli likhulinywa maNdebele
* isiSwati- ilimi leli likhulunywa maSwati&lt;ref name=&quot;:0&quot; /&gt; 

=== '''Amalimi wesiSotho:''' ===

* Sepedi (seSotho sa Leboa) -ilimi leli likhulunywa ba-Pedi
* Sesotho- Leli ilimi likhulunywa beSuthu
* Setswana- ilimi leli likhulunywa be-Tswana 

=== '''Omunye Umhlobo Wamalimi''' ===

* Tshivenda- ilimi leli likhulunywa ma-Venda

* Xitsonga- ilimi leli likhulunywa ma-Tsonga&lt;ref name=&quot;:0&quot; /&gt;

=== '''Amalimi wesiKhuwa:''' ===

* IsiNgisi - ilimi leli likhulunywa maNgisi
* IsiBhuru - ilimi leli likhulunywa maBhuru&lt;ref name=&quot;:0&quot; /&gt;

== Isizathu Sokulondolozwa Kwamalimi La ==
Ukulondolozwa kwamalimi wendabuko eSewula Afrika kuqakatheke khulu ngombana kwenza abantu bakghone ukukhulumisana kuhle bebazwisisane kuhle ngamalimi abawamunyileko bese lokho kwenza ilimi lingafi kodwana lithuthuke. Ukulondolozwa kwelimi kusiza ukundlulisela isizukulwane esiza ngemva ilwazi lelimi lendabuko namasiko wendabuko,  kwenza kube nokuzwana nokubekezelelana nanokuhloniphana emphakathini. Godu kuthuthukisa nezomnotho zeSewula Afrika.&lt;ref&gt;{{Cite web|last=Baker|first=Abigail|date=2024-10-11|title=PRESERVING SOUTH AFRICA'S INDIGENOUS LANGUAGES: A LIVING LEGACY FOR FUTURE GENERATIONS|url=https://fwdeklerk.org/preserving-south-africas-indigenous-languages-a-living-legacy-for-future-generations/|access-date=2025-05-29|website=FW de Klerk Foundation|language=en-US}}&lt;/ref&gt;

Ihlathululo yaloku okubalwe ngaphezulu:

'''Ukufa kwelimi'''

Ukufa kwelimi nofana ukungasebenzisi ilimi lendabuko kungabangela ukulahleka kwesiko, kuphazamise nokuhlalisana kuhle emphakathini. Loke ilwazi elimayelana nobukghwari, amasiko, imikghwa yokuphatha abantu ngehlonipho, neemfundo eziqakathekileko epilweni kuyafa kuphele lokha ilimi nalifako. Bona kubabalele ilwazelo ilimi kufuze lilondolozwe bona lingafi. &lt;ref name=&quot;:1&quot;&gt;{{Cite web|title=Google Search|url=https://www.google.com/search?q=reasons+for+preserving+languages+in+south+africa&amp;rlz=1C1JJTC_enZA1156ZA1159&amp;oq=reasons+for+preserving+languages+in+south+africa&amp;gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIKCAEQABiiBBiJBTIHCAIQABjvBTIHCAMQABjvBTIKCAQQABiABBiiBDIGCAUQRRg8MgYIBhBFGDwyBggHEEUYPNIBCTE2MTE1ajBqNKgCALACAQ&amp;sourceid=chrome&amp;ie=UTF-8|access-date=2025-05-29|website=www.google.com}}&lt;/ref&gt;

'''Ukudlulisela ilwazi lwelimi namasiko wendabuko'''

Ukulondoloza ilimi nesikopilo lendabuko kusiza ukuthi loke ilwazi lidluliselwe kusizukulwana esiza ngemva lokho kuzokwenza ilimi liragele phambili likhulunywa namasiko nawo aragele phambile.&lt;ref name=&quot;:1&quot; /&gt; Ngokwesibonelo, kunemithi yesintu esetjenziswa sitjhaba esithileko kodwana engekho kesinye isitjhaba. Lokha iintjhaba ezimbili nazikhulumisanako zikghona ukwabelana ngelwazi lezokwelapha, nemiithi yendabuko nalokho ekulaphako.

'''Ukubambisana komphakathi'''

Ukulondolozwa kwelimi kuthuthukisa ukubambisana emphakathini, ukuhloniphana nokuthula. Kwenza umphakathi uhloniphe amanye amalimi begodu uwaqale njengaqakathekileko.&lt;ref name=&quot;:1&quot; /&gt; Ngokwesibonelo, kuba nokubambisana emalungwini womphakathi azwisisanako, begodu kuvula ithuba lokuveza imibono, ukuze kuthathwe iinqunto ezivuthiweko ezingasiza umphakathi.

'''Ukuthuthuka komnotho'''

Ukulondolozwa kwelimi kungavula amathuba amanengi womsebenzi khulukhulu kilaba abanekareko yokusebenza ngamalimi wendabuko.&lt;ref name=&quot;:1&quot; /&gt; Ngokwesibonelo, abantu abakghona ukukhuluma amalimi amanengana banamathuba amanengi wokuqatjhwa emisebenzini nemabubulweni asebenza ngabantu beenzinda ezihlukahlukeneko. Ukuqatjhwa kwabantwaba kuthuthukisa umnotho wenarha.

== Angalondolozwa njani amalimi wendabuko ==
Ukulondolozwa kwamalimi wendabuko weSewula Afrika kutlhoga iindlela ezihlukahlukeneko zokurarulula umraro wokulondolozwa kwawo. Kuneendlela ezimbalwa ezingasetjenziselwa ukulondoloza amalimi wendabuko. Kokuthoma kufundisa nofana ukudlulisela ilwazi ngamalimi wendabuko. Kwesibili ukusebenzisa itheknoloji ekufundiseni nekuthuthukiseni ilimi. Kwesithathu ukutlola phasi nokuzihlanganisa nomphakathi.&lt;ref name=&quot;:2&quot;&gt;{{Cite web|title=Google Search|url=https://www.google.com/search?q=how+do+we+preserve+south+african+indigenous+languages&amp;rlz=1C1JJTC_enZA1156ZA1159&amp;oq=how+do+we+preserve+south+african+indigenous+lan&amp;gs_lcrp=EgZjaHJvbWUqBggDECEYFTIGCAAQRRg5MgkIARAhGAoYoAEyCQgCECEYChigATIGCAMQIRgVMgcIBBAhGJ8FMgcIBRAhGI8C0gEJNDY4MjJqMGo5qAIAsAIB&amp;sourceid=chrome&amp;ie=UTF-8|access-date=2025-05-29|website=www.google.com}}&lt;/ref&gt;

'''Fundisa ngelimi leNdabuko'''

Ukufundisa ngelimi lendabuko eenkolweni zamabanga aphasi naphezulu kungasiza ukuthi ilimi lilondolozwe. Irhubhullulo likhombisa ukuthi abantwana abaningi baphasa kuhle khulu nabafundiswa ngamalimi abawamunyileko. Kutlhogeka iincwadi zamalimi wendabuko nezinye izinto ezingasetjenziswa bona kufundiswe abanye bunqopha nofana nge-inthanedi.&lt;ref name=&quot;:2&quot; /&gt;

'''Ukusetjenziswa kwetheknoloji'''

Ukutjhugululwa kwezincwadi zamalimi wendabuko zenziwe ihlelo elilalelwako, lokho kungenye yezindlela ezisebenzako zokulondoloza amalimi begodu kwenza kube lula ukuthi zihlale isikhathi eside bezitholakale lula. Ukwenza isihlathululi magama (''online dictionary'')  namanye amahlelo wetheknoloji ngamalimi wendabuko kungasiza ukuthuthukisa  nokulondoloza begodu kuba lula ukuthi zitholakale kiwo woke umuntu osebenzisa itheknoloji.&lt;ref name=&quot;:2&quot; /&gt;

Ukutjhugulula, amaziko welimi wetheknoloji nama-''software'' asetjenziswa khudlwana emalimini wendabuko godu asiza amalimi bona alondolozwe bulula godu nabantu bazokujwayelana khulu netheknoloji.&lt;ref name=&quot;:2&quot; /&gt;

'''Ukuzibandakanya komphakathi ekuthuthukiseni ilimi'''

Ukukhuthaza nokusekela igadango lokurhatjha ngamalimi wendabuko kumabona kude nasemrhatjhweni lokho kudlala indima ekulu ekulondolozeni amalimi wendabuko. Ukusekela umphakathi nawenza iminyanya ethuthukisa amasiko namalimi wendabuko kungaba nomthelela omuhle.&lt;ref name=&quot;:2&quot; /&gt;

Ukutholakala kwabatjhugululi bamalimi wendabuko kusiza amalunga womphakathi ukuthi athole ilwazi begodu azwisise kuhle ezinye zezinto ezitlolwe ngesikhuwa. Ukusebenzisa iinkundla zokuthintana (''social media'') ngamalimi wendabuko nokuzihlanganisa neeqhema zabantu abakhuluma amalimi wendabuko  lokho nakho kuthuthukisa bekulondoloze ilimi.&lt;ref name=&quot;:2&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>twddpmke68kfxg53xncwh4c35ga6m7m</sha1>
    </revision>
    <revision>
      <id>6141</id>
      <parentid>3227</parentid>
      <timestamp>2026-01-19T20:40:21Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>/* Angalondolozwa njani amalimi wendabuko */ edits</comment>
      <origin>6141</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7735" sha1="njrcss8k069cr7oke3xe4pbi2twzjwb" xml:space="preserve">[[Isimumathi:Ndebele women-1.jpg|thumb|233x233px|Abomma bamaNdebele]]
'''ESewula''' Afrika kunamalimi ali-12 akhulunywako, amalimi la yisiNgisi, i-Afrikaans, isiZulu, isiXhosa, iSepedi, isiTsonga, isiTshivenda, isiSwati, isiNdebele, isiTswana, isiSotho seSewula Afrika nelimi lezandla leSewula Afrika. Kodwana kunamanye amalimi angakatloliswa ngokomthetho njengesiLobedu, isi-Korana, isi-Nluu, isi-Xiri namanye.&lt;ref&gt;{{Cite web|last=Alexander|first=Mary|date=2025-04-06|title=The languages of South Africa|url=https://southafrica-info.com/arts-culture/11-languages-south-africa/|access-date=2025-05-22|website=South Africa Gateway|language=en-GB}}&lt;/ref&gt; UmThethosisekelo uthi amalimi la, khulukhulu wendabuko kufuze alondolozwe namkha abulungwe.&lt;ref&gt;{{Cite web|title=The SA Constitution|url=https://www.justice.gov.za/constitution/chp01.html|access-date=2025-05-22|website=www.justice.gov.za}}&lt;/ref&gt; 

Amalimi la ahlukaniswe ngokuya ngokwemihlobo emine. Ahlukaniswe ngendlela ahlobene begodu afana ngakho.

* amalimi wesiNguni
* amalimi we-Sesotho
* amailimi wesikhuwa
* eminye imihlobo yamalimi&lt;ref name=&quot;:0&quot;&gt;{{Cite web|date=2025-05-25|title=South Africa - Languages, Dialects, Afrikaans {{!}} Britannica|url=https://www.britannica.com/place/South-Africa/Languages|access-date=2025-05-29|website=www.britannica.com|language=en}}&lt;/ref&gt;

[[Isimumathi:Zulu Culture.jpg|thumb|234x234px|Abentazana bamaZulu]]

=== '''Amalimi wesiNguni:''' ===

* isiZulu- ilimi leli likhulunywa maZulu
* isiXhoza- ilimi leli likhulunywa maXhoza
* isiNdebele- ilimi leli likhulinywa maNdebele
* isiSwati- ilimi leli likhulunywa maSwati&lt;ref name=&quot;:0&quot; /&gt; 

=== '''Amalimi wesiSotho:''' ===

* Sepedi (seSotho sa Leboa) -ilimi leli likhulunywa ba-Pedi
* Sesotho- Leli ilimi likhulunywa beSuthu
* Setswana- ilimi leli likhulunywa be-Tswana 

=== '''Omunye Umhlobo Wamalimi''' ===

* Tshivenda- ilimi leli likhulunywa ma-Venda

* Xitsonga- ilimi leli likhulunywa ma-Tsonga&lt;ref name=&quot;:0&quot; /&gt;

=== '''Amalimi wesiKhuwa:''' ===

* IsiNgisi - ilimi leli likhulunywa maNgisi
* IsiBhuru - ilimi leli likhulunywa maBhuru&lt;ref name=&quot;:0&quot; /&gt;

== Isizathu Sokulondolozwa Kwamalimi La ==
Ukulondolozwa kwamalimi wendabuko eSewula Afrika kuqakatheke khulu ngombana kwenza abantu bakghone ukukhulumisana kuhle bebazwisisane kuhle ngamalimi abawamunyileko bese lokho kwenza ilimi lingafi kodwana lithuthuke. Ukulondolozwa kwelimi kusiza ukundlulisela isizukulwane esiza ngemva ilwazi lelimi lendabuko namasiko wendabuko,  kwenza kube nokuzwana nokubekezelelana nanokuhloniphana emphakathini. Godu kuthuthukisa nezomnotho zeSewula Afrika.&lt;ref&gt;{{Cite web|last=Baker|first=Abigail|date=2024-10-11|title=PRESERVING SOUTH AFRICA'S INDIGENOUS LANGUAGES: A LIVING LEGACY FOR FUTURE GENERATIONS|url=https://fwdeklerk.org/preserving-south-africas-indigenous-languages-a-living-legacy-for-future-generations/|access-date=2025-05-29|website=FW de Klerk Foundation|language=en-US}}&lt;/ref&gt;

Ihlathululo yaloku okubalwe ngaphezulu:

'''Ukufa kwelimi'''

Ukufa kwelimi nofana ukungasebenzisi ilimi lendabuko kungabangela ukulahleka kwesiko, kuphazamise nokuhlalisana kuhle emphakathini. Loke ilwazi elimayelana nobukghwari, amasiko, imikghwa yokuphatha abantu ngehlonipho, neemfundo eziqakathekileko epilweni kuyafa kuphele lokha ilimi nalifako. Bona kubabalele ilwazelo ilimi kufuze lilondolozwe bona lingafi. &lt;ref name=&quot;:1&quot;&gt;{{Cite web|title=Google Search|url=https://www.google.com/search?q=reasons+for+preserving+languages+in+south+africa&amp;rlz=1C1JJTC_enZA1156ZA1159&amp;oq=reasons+for+preserving+languages+in+south+africa&amp;gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIKCAEQABiiBBiJBTIHCAIQABjvBTIHCAMQABjvBTIKCAQQABiABBiiBDIGCAUQRRg8MgYIBhBFGDwyBggHEEUYPNIBCTE2MTE1ajBqNKgCALACAQ&amp;sourceid=chrome&amp;ie=UTF-8|access-date=2025-05-29|website=www.google.com}}&lt;/ref&gt;

'''Ukudlulisela ilwazi lwelimi namasiko wendabuko'''

Ukulondoloza ilimi nesikopilo lendabuko kusiza ukuthi loke ilwazi lidluliselwe kusizukulwana esiza ngemva lokho kuzokwenza ilimi liragele phambili likhulunywa namasiko nawo aragele phambile.&lt;ref name=&quot;:1&quot; /&gt; Ngokwesibonelo, kunemithi yesintu esetjenziswa sitjhaba esithileko kodwana engekho kesinye isitjhaba. Lokha iintjhaba ezimbili nazikhulumisanako zikghona ukwabelana ngelwazi lezokwelapha, nemiithi yendabuko nalokho ekulaphako.

'''Ukubambisana komphakathi'''

Ukulondolozwa kwelimi kuthuthukisa ukubambisana emphakathini, ukuhloniphana nokuthula. Kwenza umphakathi uhloniphe amanye amalimi begodu uwaqale njengaqakathekileko.&lt;ref name=&quot;:1&quot; /&gt; Ngokwesibonelo, kuba nokubambisana emalungwini womphakathi azwisisanako, begodu kuvula ithuba lokuveza imibono, ukuze kuthathwe iinqunto ezivuthiweko ezingasiza umphakathi.

'''Ukuthuthuka komnotho'''

Ukulondolozwa kwelimi kungavula amathuba amanengi womsebenzi khulukhulu kilaba abanekareko yokusebenza ngamalimi wendabuko.&lt;ref name=&quot;:1&quot; /&gt; Ngokwesibonelo, abantu abakghona ukukhuluma amalimi amanengana banamathuba amanengi wokuqatjhwa emisebenzini nemabubulweni asebenza ngabantu beenzinda ezihlukahlukeneko. Ukuqatjhwa kwabantwaba kuthuthukisa umnotho wenarha.

== Indlela Yokulondoloza Amalimi Wendabuko ==
Ukulondolozwa kwamalimi wendabuko weSewula Afrika kutlhoga iindlela ezihlukahlukeneko zokurarulula umraro wokulondolozwa kwawo. Kuneendlela ezimbalwa ezingasetjenziselwa ukulondoloza amalimi wendabuko. Kokuthoma kufundisa nofana ukudlulisela ilwazi ngamalimi wendabuko. Kwesibili ukusebenzisa itheknoloji ekufundiseni nekuthuthukiseni ilimi. Kwesithathu ukutlola phasi nokuzihlanganisa nomphakathi.&lt;ref name=&quot;:2&quot;&gt;{{Cite web|title=Google Search|url=https://www.google.com/search?q=how+do+we+preserve+south+african+indigenous+languages&amp;rlz=1C1JJTC_enZA1156ZA1159&amp;oq=how+do+we+preserve+south+african+indigenous+lan&amp;gs_lcrp=EgZjaHJvbWUqBggDECEYFTIGCAAQRRg5MgkIARAhGAoYoAEyCQgCECEYChigATIGCAMQIRgVMgcIBBAhGJ8FMgcIBRAhGI8C0gEJNDY4MjJqMGo5qAIAsAIB&amp;sourceid=chrome&amp;ie=UTF-8|access-date=2025-05-29|website=www.google.com}}&lt;/ref&gt;

'''Fundisa ngelimi leNdabuko'''

Ukufundisa ngelimi lendabuko eenkolweni zamabanga aphasi naphezulu kungasiza ukuthi ilimi lilondolozwe. Irhubhullulo likhombisa ukuthi abantwana abaningi baphasa kuhle khulu nabafundiswa ngamalimi abawamunyileko. Kutlhogeka iincwadi zamalimi wendabuko nezinye izinto ezingasetjenziswa bona kufundiswe abanye bunqopha nofana nge-inthanedi.&lt;ref name=&quot;:2&quot; /&gt;

'''Ukusetjenziswa kwetheknoloji'''

Ukutjhugululwa kwezincwadi zamalimi wendabuko zenziwe ihlelo elilalelwako, lokho kungenye yezindlela ezisebenzako zokulondoloza amalimi begodu kwenza kube lula ukuthi zihlale isikhathi eside bezitholakale lula. Ukwenza isihlathululi magama (''online dictionary'')  namanye amahlelo wetheknoloji ngamalimi wendabuko kungasiza ukuthuthukisa  nokulondoloza begodu kuba lula ukuthi zitholakale kiwo woke umuntu osebenzisa itheknoloji.&lt;ref name=&quot;:2&quot; /&gt;

Ukutjhugulula, amaziko welimi wetheknoloji nama-''software'' asetjenziswa khudlwana emalimini wendabuko godu asiza amalimi bona alondolozwe bulula godu nabantu bazokujwayelana khulu netheknoloji.&lt;ref name=&quot;:2&quot; /&gt;

'''Ukuzibandakanya komphakathi ekuthuthukiseni ilimi'''

Ukukhuthaza nokusekela igadango lokurhatjha ngamalimi wendabuko kumabona kude nasemrhatjhweni lokho kudlala indima ekulu ekulondolozeni amalimi wendabuko. Ukusekela umphakathi nawenza iminyanya ethuthukisa amasiko namalimi wendabuko kungaba nomthelela omuhle.&lt;ref name=&quot;:2&quot; /&gt;

Ukutholakala kwabatjhugululi bamalimi wendabuko kusiza amalunga womphakathi ukuthi athole ilwazi begodu azwisise kuhle ezinye zezinto ezitlolwe ngesikhuwa. Ukusebenzisa iinkundla zokuthintana (''social media'') ngamalimi wendabuko nokuzihlanganisa neeqhema zabantu abakhuluma amalimi wendabuko  lokho nakho kuthuthukisa bekulondoloze ilimi.&lt;ref name=&quot;:2&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>njrcss8k069cr7oke3xe4pbi2twzjwb</sha1>
    </revision>
  </page>
  <page>
    <title>Corbin Bleu</title>
    <ns>0</ns>
    <id>608</id>
    <revision>
      <id>2867</id>
      <timestamp>2025-05-29T22:18:40Z</timestamp>
      <contributor>
        <username>Bigbrianbrain</username>
        <id>668</id>
      </contributor>
      <comment>Ngifake ikhasi lomlingisi odumileko ephasini loke u-Corbin Bleu. Usema-Wikis amanengi. Ngiyasazi isiNdebele esincani, ngilibalele.</comment>
      <origin>2867</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="154" sha1="bqipj3k7dolunlw4t51gbss3ewrdbmq" xml:space="preserve">[[Isimumathi:Corbin Bleu (Headshot).jpg|thumb|Bleu ngo-2012]]
U-Corbin Bleus mlingisi we-America owadlala indima ka-Chad emamuvini we-High School Musical.</text>
      <sha1>bqipj3k7dolunlw4t51gbss3ewrdbmq</sha1>
    </revision>
    <revision>
      <id>6262</id>
      <parentid>2867</parentid>
      <timestamp>2026-03-05T22:40:38Z</timestamp>
      <contributor>
        <username>Erkenun</username>
        <id>1399</id>
      </contributor>
      <comment>Created by translating the section &quot;Early life and education&quot; from the page &quot;[[:en:Special:Redirect/revision/1339019236|Corbin Bleu]]&quot;</comment>
      <origin>6262</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2108" sha1="ithdv6c2yr85z07kx7ehsyw4w57qwp3" xml:space="preserve">[[Isimumathi:Corbin Bleu (Headshot).jpg|thumb|Bleu ngo-2012]]
U-Corbin Bleus mlingisi we-America owadlala indima ka-Chad emamuvini we-High School Musical.

== Early life and education ==

U-Corbin Bleu wabelethwa e-New York City borough of Brooklyn, indodana ka-Martha (née Callari) no- David Reivers (obelethwe ngo-1958), umlingisi.  Unina m -Italy-American kuthi uyise m-Jamaican-American . Unabodadwabo  wabelethwa Naf abathathu abancani. Njengomntwana, u-Bleu wafunda ukugida iminyaka eminengi, adlarry Chenzimelle khulu ku- ballet ne -jazz . Umalume omkhulu ngumlingisi u-Joseph Callari. 

U-Bleu wavela emikhangisweni kamabonakude athoma aneminyaka emibili, ngemikhiqizo efana ne -Life cereal, i-Bounty, i-Hasbro kanye ne -Nabisco . &lt;ref name=&quot;upclose&quot; /&gt; Wathoma ukuthatha amakilasi we-jazz ne-ballet, kanengi two twos the word fam nif bin alenenme hehejejkehbogs njengomsana oyedwa eklasini. Naserele aneminyaka emine beseSevenle ammodeli we- Ford Modelling Agency e-New York. Wavela emikhangisweni fish milk Edgar egadangisiweko yezitol ezifana ne -Macy's, i-Gap, i-Target kanye ne-Toys R Us kanye wabelethwa neemkhangisweni zefashini kumagazini ''we-Child'', ''Parents'', kanye ne ''-American Baby'', kanye nokuba nesithombe sakhe emathoyizini nasemaphakhjini wemidlalo. 

Nakaneminyaka eyisithupha, u-Bleu wavela emdlalweni wakhekanye wokuthoma wethiyetha, e -The Town Hall . &lt;ref name=&quot;playbill&quot; /&gt; Umlandelande wallahi wamakhonsathi kanyeamaththathathathatathu, owadalwa, watlolwa, begodu wabanjwa ngu-Scott Siegel, wenzeka ngFourempelaveke eyodwa begodu kanye wafaka hlangana ukuhloFivenipha u -David Merrick .  U-Bleu wadlala indima kanye yomuntu onganawo amakhaya emdlalweni othi ''u-Tiny Tim is Dead'' . 

U-Bleu waphothula e- Los Angeles County High School for the Arts . Wabandulela ukudansa e-Debbie Alenu Danaci kanye begodu waya e -Fiorello H. LaGuardia High School of Music &amp;amp;amp; Art and Performing Arts njenge-theatre major, alandela iinyathelo zikanina.   U-Bleu waphothula isikolo samabanga aphezulukanye ngo-2007 begodu wamukelwa e- Stanford University, kodwana wala ukufunda.</text>
      <sha1>ithdv6c2yr85z07kx7ehsyw4w57qwp3</sha1>
    </revision>
  </page>
  <page>
    <title>Esther mahlangu</title>
    <ns>0</ns>
    <id>609</id>
    <revision>
      <id>2868</id>
      <timestamp>2025-05-30T09:32:52Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <comment>Added refences</comment>
      <origin>2868</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4307" sha1="de0hmgpjyehvrn9g860iwtw7xafthaz" xml:space="preserve">''[[Esther Mahlangu]]'' omgwali obuya '''''[https://www.britannica.com/topic/Ndebele-South-African-people esizweni samaNdebele weSewula Afrika]''''' ube nomqaliso wezobukghwari ebizwa bona yi '''-''' ''&lt;nowiki/&gt;'then I knew I was good at painting''' elethwe yi-[https://www.getyourguide.com/-l10476/?cmp=bing&amp;ad_id=78202963710359&amp;adgroup_id=1251244854683240&amp;bid_match_type=bb&amp;campaign_id=434111534&amp;device=c&amp;feed_item_id=&amp;keyword=www.getyourguide.com&amp;loc_interest_ms=&amp;loc_physical_ms=136830&amp;match_type=b&amp;msclkid=d65a70a8cc4e1d1378f2189d722a4aed&amp;network=o&amp;partner_id=CD951&amp;target_id=dat-2330002578451845&amp;utm_adgroup=ct%3Ddsa%7Cfn%3Df1&amp;utm_campaign=ct%3Ddsa%7Cln%3D29%3Aen%7Ctc%3Dall&amp;utm_keyword=www.getyourguide.com&amp;utm_medium=paid_search&amp;utm_query=iziko%20art%20gallery&amp;utm_source=bing Iziko South African Museums]. U-Esther Mahlangu wabelethwa mhlana amalanga ali-11 kuSinyikhaba ngomnyaka we-1935 endaweni yange-Middleburg ePumalanga, ngokubelethwa ungu-Esther Ntuli bese wendela kwaMahlangu, kanti-ke wathoma ukugwala aneminyaka elitjhumi ngobudala. Imisebenzi yakhe ayithathelwa phasi, wanikelwa ubudorhodere mayunivesithi amane okuyi - [https://www.news24.com/citypress/News/its-dr-esther-mahlangu-uj-honours-renowned-sa-artist-with-honorary-doctorate-20180409 University of Johannesburg] ne[https://www.dut.ac.za/dr-esther-mahlangu-to-host-a-retrospective-exhibition-to-celebrate-over-50-years-in-the-arts/ -Durban University of Technology] ngomnyaka wee-2018, [https://www.bona.co.za/celebrity-news/tut-honours-esther-mahlangu-and-david-tlale-with-honorary-doctorates/ Tshwane University of Technology] ngomnyaka wee-2022 kanye ne - [https://www.bing.com/search?q=unisa+honors+esther+mahlangu&amp;form=WSBEDG&amp;qs=SW&amp;cvid=8b979d91361a45ddabfc026c8650c924&amp;pq=unisa+honors+esther+mahlangu&amp;cc=ZA&amp;setlang=en-US&amp;PC=NMTS&amp;nclid=225FE419E1A8A46D5834F8A8971FEAF4&amp;ts=1748354091602&amp;wsso=Moderate University of South Africa] ngomnyaka wee-2024. &lt;ref&gt;{{Cite web |title=Esther Mahlangu {{!}} About |url=https://www.esthermahlangu.com/ |access-date=2025-05-30 |website=Esther Mahlangu |language=en}}&lt;/ref&gt;
[[Isimumathi:ESTHER MAHLANGU.jpg|thumb|Esther Mahlangu]]
Iziko South African Museums yavulela abantu bona bazokubona umsebenzi ka-Esther Mahlangu obukghwari bokugwala ukuthoma mhlana amalanga ama-18 Mhlolanja ukuya mhlana ama-11 Rhoboyi kumnya wee-2024. Umqaliso lo utjengisa umnikelo omangalisako ka-Esther Mahlangu weminyaka ematjhumi alikhomba ebukghwarini besimanjemanje ngemibala namafomu aphilako. Ifaka imisebenzi yobukghwari engaphezu kwe-100 evela emaqoqweni weentjhabatjhaba, iinthombe zomlando, kanye nefilimu emfitjhani, umqaliso lo unikela ngokudephileko emsebenzini wakhe. Okuqakathekileko yi-BMW 525i Art Car ka-Esther Mahlangu, ebuyela eSewula Afrika kokuthoma eminyakeni engaphezu kwama-30. Ngo-1991, wenza umlando njengomfazi wokuthoma nomgwalii we-Afrika obe ngomunye wabakghwari ku-BMW's Art Car Collection. Lokhu kubuyela emuva kunikela umbono ohlukileko womsebenzi ka-Mahlangu omkhulu nonamandla. &lt;ref&gt;{{Cite web |last=Times |first=Art |title=AT FEATURE: Iziko Museums of South Africa Presents: Then I Knew I Was Good At Painting: Esther Mahlangu, A Retrospective |url=https://arttimes.co.za/at-feature-iziko-museums-of-south-africa-presents-then-i-knew-i-was-good-at-painting-esther-mahlangu-a-retrospective/ |access-date=2025-05-30 |website=South African Art Times: |language=en-GB}}&lt;/ref&gt;

Akupheleli lapho, ubukghwarobo ngitjho nayo ikoloyi ye-BMW ayigwalako ibuye yalethwa godu e-[https://www.esthermahlangu.com/retrospective-projects/wits-art-museum Wits Arts Gallery] bona izokubonwa babantu mhlana amalanga ama-20 kuSinyikhaba 2024 ukuya mhlana amalanga ali-17 kuSihlabantangana kiwo umnyaka lo bese yabuyela emva. Okungaphezu kwalokho umqiniseki womqaliso lo uNontobeko Ntombela uyahlathulula bona “Umqaliso lo uletha ithuba elitjha lokuthi sibone umsebenzi wobukghwari omuhle ka-Esther Mahlangu. Umsebenzakhe ube nomthelela omkhulu emkhakheni wezobukghwari eSewula Afrika begodu umqaliso lo bufakazi bomnikelo omuhle.” &lt;ref&gt;{{Cite web |title=Wits Art Museum {{!}} Esther Mahlangu |url=https://www.esthermahlangu.com/retrospective-projects/wits-art-museum |access-date=2025-05-30 |website=Esther Mahlangu |language=en}}&lt;/ref&gt; &lt;!-- EDIT BELOW THIS LINE --&gt;

=== UMTHOMBO WELWAZI ===</text>
      <sha1>de0hmgpjyehvrn9g860iwtw7xafthaz</sha1>
    </revision>
    <revision>
      <id>6695</id>
      <parentid>2868</parentid>
      <timestamp>2026-06-12T08:07:54Z</timestamp>
      <contributor>
        <username>MissHadassah</username>
        <id>1561</id>
      </contributor>
      <comment>added external reference</comment>
      <origin>6695</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4384" sha1="kvzunh1vxs3tez4fz8klfb5e40oazwo" xml:space="preserve">''[[Esther Mahlangu]]''&lt;ref&gt;[https://www.esthermahlangu.com/ Esther Mahlangu | About]&lt;/ref&gt; omgwali obuya '''''[https://www.britannica.com/topic/Ndebele-South-African-people esizweni samaNdebele weSewula Afrika]''''' ube nomqaliso wezobukghwari ebizwa bona yi '''-'&lt;nowiki/&gt;'' ''&lt;nowiki/&gt;'then I knew I was good at painting''' elethwe yi-[https://www.getyourguide.com/-l10476/?cmp=bing&amp;ad_id=78202963710359&amp;adgroup_id=1251244854683240&amp;bid_match_type=bb&amp;campaign_id=434111534&amp;device=c&amp;feed_item_id=&amp;keyword=www.getyourguide.com&amp;loc_interest_ms=&amp;loc_physical_ms=136830&amp;match_type=b&amp;msclkid=d65a70a8cc4e1d1378f2189d722a4aed&amp;network=o&amp;partner_id=CD951&amp;target_id=dat-2330002578451845&amp;utm_adgroup=ct%3Ddsa%7Cfn%3Df1&amp;utm_campaign=ct%3Ddsa%7Cln%3D29%3Aen%7Ctc%3Dall&amp;utm_keyword=www.getyourguide.com&amp;utm_medium=paid_search&amp;utm_query=iziko%20art%20gallery&amp;utm_source=bing Iziko South African Museums]. U-Esther Mahlangu wabelethwa mhlana amalanga ali-11 kuSinyikhaba ngomnyaka we-1935 endaweni yange-Middleburg ePumalanga, ngokubelethwa ungu-Esther Ntuli bese wendela kwaMahlangu, kanti-ke wathoma ukugwala aneminyaka elitjhumi ngobudala. Imisebenzi yakhe ayithathelwa phasi, wanikelwa ubudorhodere mayunivesithi amane okuyi - [https://www.news24.com/citypress/News/its-dr-esther-mahlangu-uj-honours-renowned-sa-artist-with-honorary-doctorate-20180409 University of Johannesburg] ne[https://www.dut.ac.za/dr-esther-mahlangu-to-host-a-retrospective-exhibition-to-celebrate-over-50-years-in-the-arts/ -Durban University of Technology] ngomnyaka wee-2018, [https://www.bona.co.za/celebrity-news/tut-honours-esther-mahlangu-and-david-tlale-with-honorary-doctorates/ Tshwane University of Technology] ngomnyaka wee-2022 kanye ne - [https://www.bing.com/search?q=unisa+honors+esther+mahlangu&amp;form=WSBEDG&amp;qs=SW&amp;cvid=8b979d91361a45ddabfc026c8650c924&amp;pq=unisa+honors+esther+mahlangu&amp;cc=ZA&amp;setlang=en-US&amp;PC=NMTS&amp;nclid=225FE419E1A8A46D5834F8A8971FEAF4&amp;ts=1748354091602&amp;wsso=Moderate University of South Africa] ngomnyaka wee-2024. &lt;ref&gt;{{Cite web |title=Esther Mahlangu {{!}} About |url=https://www.esthermahlangu.com/ |access-date=2025-05-30 |website=Esther Mahlangu |language=en}}&lt;/ref&gt;
[[Isimumathi:ESTHER MAHLANGU.jpg|thumb|Esther Mahlangu]]
Iziko South African Museums yavulela abantu bona bazokubona umsebenzi ka-Esther Mahlangu obukghwari bokugwala ukuthoma mhlana amalanga ama-18 Mhlolanja ukuya mhlana ama-11 Rhoboyi kumnya wee-2024. Umqaliso lo utjengisa umnikelo omangalisako ka-Esther Mahlangu weminyaka ematjhumi alikhomba ebukghwarini besimanjemanje ngemibala namafomu aphilako. Ifaka imisebenzi yobukghwari engaphezu kwe-100 evela emaqoqweni weentjhabatjhaba, iinthombe zomlando, kanye nefilimu emfitjhani, umqaliso lo unikela ngokudephileko emsebenzini wakhe. Okuqakathekileko yi-BMW 525i Art Car ka-Esther Mahlangu, ebuyela eSewula Afrika kokuthoma eminyakeni engaphezu kwama-30. Ngo-1991, wenza umlando njengomfazi wokuthoma nomgwalii we-Afrika obe ngomunye wabakghwari ku-BMW's Art Car Collection. Lokhu kubuyela emuva kunikela umbono ohlukileko womsebenzi ka-Mahlangu omkhulu nonamandla. &lt;ref&gt;{{Cite web |last=Times |first=Art |title=AT FEATURE: Iziko Museums of South Africa Presents: Then I Knew I Was Good At Painting: Esther Mahlangu, A Retrospective |url=https://arttimes.co.za/at-feature-iziko-museums-of-south-africa-presents-then-i-knew-i-was-good-at-painting-esther-mahlangu-a-retrospective/ |access-date=2025-05-30 |website=South African Art Times: |language=en-GB}}&lt;/ref&gt;

Akupheleli lapho, ubukghwarobo ngitjho nayo ikoloyi ye-BMW ayigwalako ibuye yalethwa godu e-[https://www.esthermahlangu.com/retrospective-projects/wits-art-museum Wits Arts Gallery] bona izokubonwa babantu mhlana amalanga ama-20 kuSinyikhaba 2024 ukuya mhlana amalanga ali-17 kuSihlabantangana kiwo umnyaka lo bese yabuyela emva. Okungaphezu kwalokho umqiniseki womqaliso lo uNontobeko Ntombela uyahlathulula bona “Umqaliso lo uletha ithuba elitjha lokuthi sibone umsebenzi wobukghwari omuhle ka-Esther Mahlangu. Umsebenzakhe ube nomthelela omkhulu emkhakheni wezobukghwari eSewula Afrika begodu umqaliso lo bufakazi bomnikelo omuhle.” &lt;ref&gt;{{Cite web |title=Wits Art Museum {{!}} Esther Mahlangu |url=https://www.esthermahlangu.com/retrospective-projects/wits-art-museum |access-date=2025-05-30 |website=Esther Mahlangu |language=en}}&lt;/ref&gt; &lt;!-- EDIT BELOW THIS LINE --&gt;

=== UMTHOMBO WELWAZI ===</text>
      <sha1>kvzunh1vxs3tez4fz8klfb5e40oazwo</sha1>
    </revision>
    <revision>
      <id>6696</id>
      <parentid>6695</parentid>
      <timestamp>2026-06-12T08:09:50Z</timestamp>
      <contributor>
        <username>MissHadassah</username>
        <id>1561</id>
      </contributor>
      <comment>added external references</comment>
      <origin>6696</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4556" sha1="ei2sgzwdi79exfilrfum6laa8ih6ykr" xml:space="preserve">''[[Esther Mahlangu]]''&lt;ref&gt;[https://www.esthermahlangu.com/ Esther Mahlangu | About]&lt;/ref&gt; &lt;ref&gt;[https://mzanzi27.co.za/esther-mahlangu-biography-artist-early-life-education-career/ Esther Mahlangu Biography: Artist, Early Life, Education &amp; Career - Mzansi]&lt;/ref&gt;omgwali obuya '''''[https://www.britannica.com/topic/Ndebele-South-African-people esizweni samaNdebele weSewula Afrika]''''' ube nomqaliso wezobukghwari ebizwa bona yi '''-'&lt;nowiki/&gt;'' ''&lt;nowiki/&gt;'then I knew I was good at painting''' elethwe yi-[https://www.getyourguide.com/-l10476/?cmp=bing&amp;ad_id=78202963710359&amp;adgroup_id=1251244854683240&amp;bid_match_type=bb&amp;campaign_id=434111534&amp;device=c&amp;feed_item_id=&amp;keyword=www.getyourguide.com&amp;loc_interest_ms=&amp;loc_physical_ms=136830&amp;match_type=b&amp;msclkid=d65a70a8cc4e1d1378f2189d722a4aed&amp;network=o&amp;partner_id=CD951&amp;target_id=dat-2330002578451845&amp;utm_adgroup=ct%3Ddsa%7Cfn%3Df1&amp;utm_campaign=ct%3Ddsa%7Cln%3D29%3Aen%7Ctc%3Dall&amp;utm_keyword=www.getyourguide.com&amp;utm_medium=paid_search&amp;utm_query=iziko%20art%20gallery&amp;utm_source=bing Iziko South African Museums]. U-Esther Mahlangu wabelethwa mhlana amalanga ali-11 kuSinyikhaba ngomnyaka we-1935 endaweni yange-Middleburg ePumalanga, ngokubelethwa ungu-Esther Ntuli bese wendela kwaMahlangu, kanti-ke wathoma ukugwala aneminyaka elitjhumi ngobudala. Imisebenzi yakhe ayithathelwa phasi, wanikelwa ubudorhodere mayunivesithi amane okuyi - [https://www.news24.com/citypress/News/its-dr-esther-mahlangu-uj-honours-renowned-sa-artist-with-honorary-doctorate-20180409 University of Johannesburg] ne[https://www.dut.ac.za/dr-esther-mahlangu-to-host-a-retrospective-exhibition-to-celebrate-over-50-years-in-the-arts/ -Durban University of Technology] ngomnyaka wee-2018, [https://www.bona.co.za/celebrity-news/tut-honours-esther-mahlangu-and-david-tlale-with-honorary-doctorates/ Tshwane University of Technology] ngomnyaka wee-2022 kanye ne - [https://www.bing.com/search?q=unisa+honors+esther+mahlangu&amp;form=WSBEDG&amp;qs=SW&amp;cvid=8b979d91361a45ddabfc026c8650c924&amp;pq=unisa+honors+esther+mahlangu&amp;cc=ZA&amp;setlang=en-US&amp;PC=NMTS&amp;nclid=225FE419E1A8A46D5834F8A8971FEAF4&amp;ts=1748354091602&amp;wsso=Moderate University of South Africa] ngomnyaka wee-2024. &lt;ref&gt;{{Cite web |title=Esther Mahlangu {{!}} About |url=https://www.esthermahlangu.com/ |access-date=2025-05-30 |website=Esther Mahlangu |language=en}}&lt;/ref&gt;
[[Isimumathi:ESTHER MAHLANGU.jpg|thumb|Esther Mahlangu]]
Iziko South African Museums yavulela abantu bona bazokubona umsebenzi ka-Esther Mahlangu obukghwari bokugwala ukuthoma mhlana amalanga ama-18 Mhlolanja ukuya mhlana ama-11 Rhoboyi kumnya wee-2024. Umqaliso lo utjengisa umnikelo omangalisako ka-Esther Mahlangu weminyaka ematjhumi alikhomba ebukghwarini besimanjemanje ngemibala namafomu aphilako. Ifaka imisebenzi yobukghwari engaphezu kwe-100 evela emaqoqweni weentjhabatjhaba, iinthombe zomlando, kanye nefilimu emfitjhani, umqaliso lo unikela ngokudephileko emsebenzini wakhe. Okuqakathekileko yi-BMW 525i Art Car ka-Esther Mahlangu, ebuyela eSewula Afrika kokuthoma eminyakeni engaphezu kwama-30. Ngo-1991, wenza umlando njengomfazi wokuthoma nomgwalii we-Afrika obe ngomunye wabakghwari ku-BMW's Art Car Collection. Lokhu kubuyela emuva kunikela umbono ohlukileko womsebenzi ka-Mahlangu omkhulu nonamandla. &lt;ref&gt;{{Cite web |last=Times |first=Art |title=AT FEATURE: Iziko Museums of South Africa Presents: Then I Knew I Was Good At Painting: Esther Mahlangu, A Retrospective |url=https://arttimes.co.za/at-feature-iziko-museums-of-south-africa-presents-then-i-knew-i-was-good-at-painting-esther-mahlangu-a-retrospective/ |access-date=2025-05-30 |website=South African Art Times: |language=en-GB}}&lt;/ref&gt;

Akupheleli lapho, ubukghwarobo ngitjho nayo ikoloyi ye-BMW ayigwalako ibuye yalethwa godu e-[https://www.esthermahlangu.com/retrospective-projects/wits-art-museum Wits Arts Gallery] bona izokubonwa babantu mhlana amalanga ama-20 kuSinyikhaba 2024 ukuya mhlana amalanga ali-17 kuSihlabantangana kiwo umnyaka lo bese yabuyela emva. Okungaphezu kwalokho umqiniseki womqaliso lo uNontobeko Ntombela uyahlathulula bona “Umqaliso lo uletha ithuba elitjha lokuthi sibone umsebenzi wobukghwari omuhle ka-Esther Mahlangu. Umsebenzakhe ube nomthelela omkhulu emkhakheni wezobukghwari eSewula Afrika begodu umqaliso lo bufakazi bomnikelo omuhle.” &lt;ref&gt;{{Cite web |title=Wits Art Museum {{!}} Esther Mahlangu |url=https://www.esthermahlangu.com/retrospective-projects/wits-art-museum |access-date=2025-05-30 |website=Esther Mahlangu |language=en}}&lt;/ref&gt; &lt;!-- EDIT BELOW THIS LINE --&gt;

=== UMTHOMBO WELWAZI ===</text>
      <sha1>ei2sgzwdi79exfilrfum6laa8ih6ykr</sha1>
    </revision>
  </page>
  <page>
    <title>Imiklomelo kaDakamela</title>
    <ns>0</ns>
    <id>610</id>
    <revision>
      <id>2869</id>
      <timestamp>2025-05-30T12:47:49Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <comment>Added an image</comment>
      <origin>2869</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3963" sha1="4e7hiu6v0ocf7uspeef3vbdx6fldtum" xml:space="preserve">== IMITLOMELO KADAKAMELA ==
[https://bulawayo24.com/news/local/251778#:~:text=Chief%20Mbusi%20Bekithemba%20Dakamela%20of%20Nkayi%2C%20KoDakamela%2C%20is,contributions%20to%20society%20while%20they%20are%20still%20alive. Imiklomelo kaDakamela] mnyanya ogidinga isintu namasiko wamaNguni begodu ubuye unikele abantu imitlomelo wokubathokozisa emisebenzini emihle abayenzako emphakathini. Umnyanya lo wathoma ukwenzeka ngomnyaka wee-2023 eNkayi eZimbabwe, wenziwa yiKosi uMbusi Bekithemba Dakamela ngendlini yobuKhosi bakwaDakamela. Umnyaka lo wenzeke mhlana amalanga ama-5 kuSinyikhaba kiwo wona umnyaka lo begodu wenzeke amalanga amabili woke ukusukela mhlana amalanga ama-4 ukuya nakama-5. &lt;ref&gt;{{Cite web |title=LIVE - Chief Dakamela host Imiklomelo KaDakamela |url=https://bulawayo24.com/index-id-news-sc-local-byo-251778.html |access-date=2025-05-30 |website=Bulawayo24 News}}&lt;/ref&gt; Nanoma kumnyanya osezweni leZimbabwe, akusibabantu beZimbabwe kwaphela abawukhambelako, ukhanjelwa babantu ababuya kwezinye iinarha njengeSewula Afrika, Tanzaniya, neZambiya. Akupheleli lapho, ezinye zeenkhambeli lezi zibuya ebuKhosini ngokwahlahlahlukana. Ekutlonyelisweni, akukaqalwa abantu beZimbabwe kwaphela, akhona amanye amalunga wemindeni wobuKhosi wezinye iinarha kanye nabanye abantu abenza kuhle emiphakathini abatlonyelisiweko. &lt;ref&gt;{{Cite web |last=Mrewa |first=Tanaka |last2=Mrewa |first2=Tanaka |date=2025-04-05 |title=Chief Dakamela’s Nkayi Achievers’ Awards continue to win praise - CITEZW |url=https://cite.org.zw/chief-dakamelas-nkayi-achievers-awards-continue-to-win-praise/,%20https://cite.org.zw/chief-dakamelas-nkayi-achievers-awards-continue-to-win-praise/ |access-date=2025-05-30 |language=en-GB}}&lt;/ref&gt;
[[File:IKosi uDakamela.jpg|thumb|376x376px|IKosi uDakamela]]
Umnyanya lo nanoma usungulwe buKhosi bakwaDakamela usuke wasekelwa nanguRhulumende wesifundeni seMatebeleland North. URhulumende ube wenza nesithembiso bona umnyanya lo uzowubeka phambili begodu noNgqongqotjhe wakhona uNicholas Moyo ubize boke abathintekako nabasebenzisani bona basebenzisane ekukhuphuleni umnyanya lo nokuqinisekisa ukunzinza kwawo esikhathini eside nesizako. &lt;ref&gt;{{Cite web |last=Ncube |first=Senzeni |date=2025-04-07 |title=Imiklomelo kaDakamela gets government backing - CITEZW |url=https://cite.org.zw/imiklomelo-kadakamela-gets-government-backing/,%20https://cite.org.zw/imiklomelo-kadakamela-gets-government-backing/ |access-date=2025-05-30 |language=en-GB}}&lt;/ref&gt; Iinkhambeli zomnyanya ziwuthabela umnyanya lo ngamabanga amanengi, elinye lakhona kukuthi umnyanya lo usekela abakghwari bendawo ngokubanikela ithuba lokuthi baveze tjhatjhalazi amakghono wabo kanye nokuvezwa kwevunulo yesintu, liyatjho nelunga lepalamende uDesire Moyo bona uthatjiswe yivunulo yesintu kanye namakghono wabantu aveziweko. &lt;ref&gt;{{Cite web |last=Mrewa |first=Tanaka |last2=Mrewa |first2=Tanaka |date=2025-04-05 |title=Chief Dakamela’s Nkayi Achievers’ Awards continue to win praise - CITEZW |url=https://cite.org.zw/chief-dakamelas-nkayi-achievers-awards-continue-to-win-praise/,%20https://cite.org.zw/chief-dakamelas-nkayi-achievers-awards-continue-to-win-praise/ |access-date=2025-05-30 |language=en-GB}}&lt;/ref&gt;

Kanti-ke, koke lokhu njengombana kusungulwa yiKosi uDakamela, okuvelako kukuthi ulililutjha ngokwakhe. UMbusi Dakamela wabelethwa mhlana amalanga ama-3 kuNtaka ngomnyaka we-1995 bese wahlaliswa esihlalweni sobuKhosi ngomnyaka wee-2019. Uhlaliswa nje uthatha iintambo kuKghari yakhe uHleziphi Dlodlo obekamjaphethe nakuzakuqima ilanga elinguyise likaMbusi. Umnqopho weKosi uDakamela kubuyisa nokuvuselela isintu namasiko, kuthi nakunjalo kwasungulwa nekulumo ethi #ubuntuyisintusethu enamethele umnyanya lo obizwa ngmiklomelo kaDakamela. &lt;ref&gt;{{Cite web |title=24 year old installed as Chief Dakamela of Nkayi |url=https://bulawayo24.com/index-id-news-sc-national-byo-160037.html |access-date=2025-05-30 |website=Bulawayo24 News}}&lt;/ref&gt;

== IMITHOMBO YELWAZI ==</text>
      <sha1>4e7hiu6v0ocf7uspeef3vbdx6fldtum</sha1>
    </revision>
    <revision>
      <id>3165</id>
      <parentid>2869</parentid>
      <timestamp>2025-06-21T18:43:26Z</timestamp>
      <contributor>
        <ip>85.97.84.231</ip>
      </contributor>
      <origin>3165</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4074" sha1="pon77wrlc3edotp9hx6b4qzokvdvoje" xml:space="preserve">[[File:Common chimpanzee (Pan troglodytes schweinfurthii) feeding.jpg|thumb|Omar al-Bashir is a chimpanzee.]]

== IMITLOMELO KADAKAMELA ==
[https://bulawayo24.com/news/local/251778#:~:text=Chief%20Mbusi%20Bekithemba%20Dakamela%20of%20Nkayi%2C%20KoDakamela%2C%20is,contributions%20to%20society%20while%20they%20are%20still%20alive. Imiklomelo kaDakamela] mnyanya ogidinga isintu namasiko wamaNguni begodu ubuye unikele abantu imitlomelo wokubathokozisa emisebenzini emihle abayenzako emphakathini. Umnyanya lo wathoma ukwenzeka ngomnyaka wee-2023 eNkayi eZimbabwe, wenziwa yiKosi uMbusi Bekithemba Dakamela ngendlini yobuKhosi bakwaDakamela. Umnyaka lo wenzeke mhlana amalanga ama-5 kuSinyikhaba kiwo wona umnyaka lo begodu wenzeke amalanga amabili woke ukusukela mhlana amalanga ama-4 ukuya nakama-5. &lt;ref&gt;{{Cite web |title=LIVE - Chief Dakamela host Imiklomelo KaDakamela |url=https://bulawayo24.com/index-id-news-sc-local-byo-251778.html |access-date=2025-05-30 |website=Bulawayo24 News}}&lt;/ref&gt; Nanoma kumnyanya osezweni leZimbabwe, akusibabantu beZimbabwe kwaphela abawukhambelako, ukhanjelwa babantu ababuya kwezinye iinarha njengeSewula Afrika, Tanzaniya, neZambiya. Akupheleli lapho, ezinye zeenkhambeli lezi zibuya ebuKhosini ngokwahlahlahlukana. Ekutlonyelisweni, akukaqalwa abantu beZimbabwe kwaphela, akhona amanye amalunga wemindeni wobuKhosi wezinye iinarha kanye nabanye abantu abenza kuhle emiphakathini abatlonyelisiweko. &lt;ref&gt;{{Cite web |last=Mrewa |first=Tanaka |last2=Mrewa |first2=Tanaka |date=2025-04-05 |title=Chief Dakamela’s Nkayi Achievers’ Awards continue to win praise - CITEZW |url=https://cite.org.zw/chief-dakamelas-nkayi-achievers-awards-continue-to-win-praise/,%20https://cite.org.zw/chief-dakamelas-nkayi-achievers-awards-continue-to-win-praise/ |access-date=2025-05-30 |language=en-GB}}&lt;/ref&gt;
[[File:IKosi uDakamela.jpg|thumb|376x376px|IKosi uDakamela]]
Umnyanya lo nanoma usungulwe buKhosi bakwaDakamela usuke wasekelwa nanguRhulumende wesifundeni seMatebeleland North. URhulumende ube wenza nesithembiso bona umnyanya lo uzowubeka phambili begodu noNgqongqotjhe wakhona uNicholas Moyo ubize boke abathintekako nabasebenzisani bona basebenzisane ekukhuphuleni umnyanya lo nokuqinisekisa ukunzinza kwawo esikhathini eside nesizako. &lt;ref&gt;{{Cite web |last=Ncube |first=Senzeni |date=2025-04-07 |title=Imiklomelo kaDakamela gets government backing - CITEZW |url=https://cite.org.zw/imiklomelo-kadakamela-gets-government-backing/,%20https://cite.org.zw/imiklomelo-kadakamela-gets-government-backing/ |access-date=2025-05-30 |language=en-GB}}&lt;/ref&gt; Iinkhambeli zomnyanya ziwuthabela umnyanya lo ngamabanga amanengi, elinye lakhona kukuthi umnyanya lo usekela abakghwari bendawo ngokubanikela ithuba lokuthi baveze tjhatjhalazi amakghono wabo kanye nokuvezwa kwevunulo yesintu, liyatjho nelunga lepalamende uDesire Moyo bona uthatjiswe yivunulo yesintu kanye namakghono wabantu aveziweko. &lt;ref&gt;{{Cite web |last=Mrewa |first=Tanaka |last2=Mrewa |first2=Tanaka |date=2025-04-05 |title=Chief Dakamela’s Nkayi Achievers’ Awards continue to win praise - CITEZW |url=https://cite.org.zw/chief-dakamelas-nkayi-achievers-awards-continue-to-win-praise/,%20https://cite.org.zw/chief-dakamelas-nkayi-achievers-awards-continue-to-win-praise/ |access-date=2025-05-30 |language=en-GB}}&lt;/ref&gt;

Kanti-ke, koke lokhu njengombana kusungulwa yiKosi uDakamela, okuvelako kukuthi ulililutjha ngokwakhe. UMbusi Dakamela wabelethwa mhlana amalanga ama-3 kuNtaka ngomnyaka we-1995 bese wahlaliswa esihlalweni sobuKhosi ngomnyaka wee-2019. Uhlaliswa nje uthatha iintambo kuKghari yakhe uHleziphi Dlodlo obekamjaphethe nakuzakuqima ilanga elinguyise likaMbusi. Umnqopho weKosi uDakamela kubuyisa nokuvuselela isintu namasiko, kuthi nakunjalo kwasungulwa nekulumo ethi #ubuntuyisintusethu enamethele umnyanya lo obizwa ngmiklomelo kaDakamela. &lt;ref&gt;{{Cite web |title=24 year old installed as Chief Dakamela of Nkayi |url=https://bulawayo24.com/index-id-news-sc-national-byo-160037.html |access-date=2025-05-30 |website=Bulawayo24 News}}&lt;/ref&gt;

== IMITHOMBO YELWAZI ==</text>
      <sha1>pon77wrlc3edotp9hx6b4qzokvdvoje</sha1>
    </revision>
    <revision>
      <id>3288</id>
      <parentid>3165</parentid>
      <timestamp>2025-07-02T20:41:10Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Undo revision [[Special:Diff/3165|3165]] by [[Special:Contributions/85.97.84.231|85.97.84.231]] ([[User talk:85.97.84.231|talk]])</comment>
      <origin>3288</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3963" sha1="4e7hiu6v0ocf7uspeef3vbdx6fldtum" xml:space="preserve">== IMITLOMELO KADAKAMELA ==
[https://bulawayo24.com/news/local/251778#:~:text=Chief%20Mbusi%20Bekithemba%20Dakamela%20of%20Nkayi%2C%20KoDakamela%2C%20is,contributions%20to%20society%20while%20they%20are%20still%20alive. Imiklomelo kaDakamela] mnyanya ogidinga isintu namasiko wamaNguni begodu ubuye unikele abantu imitlomelo wokubathokozisa emisebenzini emihle abayenzako emphakathini. Umnyanya lo wathoma ukwenzeka ngomnyaka wee-2023 eNkayi eZimbabwe, wenziwa yiKosi uMbusi Bekithemba Dakamela ngendlini yobuKhosi bakwaDakamela. Umnyaka lo wenzeke mhlana amalanga ama-5 kuSinyikhaba kiwo wona umnyaka lo begodu wenzeke amalanga amabili woke ukusukela mhlana amalanga ama-4 ukuya nakama-5. &lt;ref&gt;{{Cite web |title=LIVE - Chief Dakamela host Imiklomelo KaDakamela |url=https://bulawayo24.com/index-id-news-sc-local-byo-251778.html |access-date=2025-05-30 |website=Bulawayo24 News}}&lt;/ref&gt; Nanoma kumnyanya osezweni leZimbabwe, akusibabantu beZimbabwe kwaphela abawukhambelako, ukhanjelwa babantu ababuya kwezinye iinarha njengeSewula Afrika, Tanzaniya, neZambiya. Akupheleli lapho, ezinye zeenkhambeli lezi zibuya ebuKhosini ngokwahlahlahlukana. Ekutlonyelisweni, akukaqalwa abantu beZimbabwe kwaphela, akhona amanye amalunga wemindeni wobuKhosi wezinye iinarha kanye nabanye abantu abenza kuhle emiphakathini abatlonyelisiweko. &lt;ref&gt;{{Cite web |last=Mrewa |first=Tanaka |last2=Mrewa |first2=Tanaka |date=2025-04-05 |title=Chief Dakamela’s Nkayi Achievers’ Awards continue to win praise - CITEZW |url=https://cite.org.zw/chief-dakamelas-nkayi-achievers-awards-continue-to-win-praise/,%20https://cite.org.zw/chief-dakamelas-nkayi-achievers-awards-continue-to-win-praise/ |access-date=2025-05-30 |language=en-GB}}&lt;/ref&gt;
[[File:IKosi uDakamela.jpg|thumb|376x376px|IKosi uDakamela]]
Umnyanya lo nanoma usungulwe buKhosi bakwaDakamela usuke wasekelwa nanguRhulumende wesifundeni seMatebeleland North. URhulumende ube wenza nesithembiso bona umnyanya lo uzowubeka phambili begodu noNgqongqotjhe wakhona uNicholas Moyo ubize boke abathintekako nabasebenzisani bona basebenzisane ekukhuphuleni umnyanya lo nokuqinisekisa ukunzinza kwawo esikhathini eside nesizako. &lt;ref&gt;{{Cite web |last=Ncube |first=Senzeni |date=2025-04-07 |title=Imiklomelo kaDakamela gets government backing - CITEZW |url=https://cite.org.zw/imiklomelo-kadakamela-gets-government-backing/,%20https://cite.org.zw/imiklomelo-kadakamela-gets-government-backing/ |access-date=2025-05-30 |language=en-GB}}&lt;/ref&gt; Iinkhambeli zomnyanya ziwuthabela umnyanya lo ngamabanga amanengi, elinye lakhona kukuthi umnyanya lo usekela abakghwari bendawo ngokubanikela ithuba lokuthi baveze tjhatjhalazi amakghono wabo kanye nokuvezwa kwevunulo yesintu, liyatjho nelunga lepalamende uDesire Moyo bona uthatjiswe yivunulo yesintu kanye namakghono wabantu aveziweko. &lt;ref&gt;{{Cite web |last=Mrewa |first=Tanaka |last2=Mrewa |first2=Tanaka |date=2025-04-05 |title=Chief Dakamela’s Nkayi Achievers’ Awards continue to win praise - CITEZW |url=https://cite.org.zw/chief-dakamelas-nkayi-achievers-awards-continue-to-win-praise/,%20https://cite.org.zw/chief-dakamelas-nkayi-achievers-awards-continue-to-win-praise/ |access-date=2025-05-30 |language=en-GB}}&lt;/ref&gt;

Kanti-ke, koke lokhu njengombana kusungulwa yiKosi uDakamela, okuvelako kukuthi ulililutjha ngokwakhe. UMbusi Dakamela wabelethwa mhlana amalanga ama-3 kuNtaka ngomnyaka we-1995 bese wahlaliswa esihlalweni sobuKhosi ngomnyaka wee-2019. Uhlaliswa nje uthatha iintambo kuKghari yakhe uHleziphi Dlodlo obekamjaphethe nakuzakuqima ilanga elinguyise likaMbusi. Umnqopho weKosi uDakamela kubuyisa nokuvuselela isintu namasiko, kuthi nakunjalo kwasungulwa nekulumo ethi #ubuntuyisintusethu enamethele umnyanya lo obizwa ngmiklomelo kaDakamela. &lt;ref&gt;{{Cite web |title=24 year old installed as Chief Dakamela of Nkayi |url=https://bulawayo24.com/index-id-news-sc-national-byo-160037.html |access-date=2025-05-30 |website=Bulawayo24 News}}&lt;/ref&gt;

== IMITHOMBO YELWAZI ==</text>
      <sha1>4e7hiu6v0ocf7uspeef3vbdx6fldtum</sha1>
    </revision>
  </page>
  <page>
    <title>Ivunulo yamaNdebele</title>
    <ns>0</ns>
    <id>611</id>
    <revision>
      <id>2870</id>
      <timestamp>2025-05-30T14:31:50Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>ivunulo yesitjhaba sama NDEBELE ngokwahluka kwayo hlangana ngobulili</comment>
      <origin>2870</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4891" sha1="jq96d990skl9f0gghhbb7ij7os064di" xml:space="preserve">Ivunulo yama https://en.wikipedia.org/wiki/Southern_Ndebele_language ikhamba ihluka kusukela ebantwini beengubo kunye nebantwini bembaji.Kujayelekile ukubona ama Afrika amanengi ahlotjiswe ngeendlela ezihlukahlukeneko zomncamo,yincenye yamasiko wethu.Isiko elingatjhugulukiko elidluliselwa ukusukela esizukulwaneni ukuya kwesinye.Iinarha ezinengi ze Afrika zinendlela yazo ekhethekileko yokutlama begodu kuyakarisa ukubona iinarha ze Afrika ezahlukahlukeneko zisebenzisa ivunulo ukurhatjha imilayezo ehlukeneko.

https://en.wikipedia.org/wiki/Amandebele sitjhaba sama Nguni esise Sewula Afrika.Isitjhaba lesi saziwa ngobuciko ne vunulo yaso.Umsebenzi wevunulo udlala indima ekulu ekumbaheni kwabo kusukela besebancani njengombana bayisebenzisa ukutshwaya amazinga ahlukileko wamasiko wepilo.Into eqakatheke khulu ekumbatheni kwabo mma bama Ndebele yi tjorholo encani.Abentazana abasebancane bahlobisa itjorholo encani enomncamo.Isiketi esihlukileko lesi sakhiwe ngokuqinileko mtjhini we khanvani ogoqiweko ubotjhwa edinini uhlotjiswe ngqo phezu kwalokhu.Okulenga ebhandeni eliphezulu kulitjhila elifana ne lace ehlanganiswe emabhandeni womncamo.Lokhu kwakhiwe bona kuwele phambi komjeje oqinileko weentambo zekoteni ezifakwe umncamo wembewu emhlophe ephazamiswa isikeli ukwandisa ubukhulu be https://en.wiktionary.org/wiki/garmet begodu kukhuthaze ukudlala kokukhanya lokha nakubonwa kusikinyeka ukutjengisa ukuthaba.

Abentazana abadala esele balenzile isiko bambatha i phephethu ngokunikelwa bomma babo.Iphephethu yenziwe ngesikhumba esikhulu esibunjwe njenge oval esihlanganiswe ngomjeje wemicu emide yomncamo omhlophe begodu sihlotjiswe ngaphezulu ngephetheni yejometri enemibala eminengi kunye neendima ezintathu yamasongo wethusi.Iphephethu ivamise ukubotjhwa edinini belimbathwe phezu kwedini ukuya enzasi.Isikhumba sesikhumba sihloselwe kudosa amehlo ngokugona iinqulo neenyanga begodu ukutjhinga komncamo kungezelela umthelela lokha umntazana nanyakazako.

Ngesikhathi somtjhado nomnyanya wokuthomba umlobokazi umbatha isiyaya ukufihla ubuso lesi kusikhathi sokutjhuguluka ukusuka kwesinye isigaba ukuya kwesinye.Ngaphandle kwesiyaya abomalukazana bama Ndebele bambatha inyonga eyenziwe ngomncamo omhlophe olukwe ngentambo bomma abazinhlobo.Ubude bephetheni nesakhiwo se nyonga kutjho ukuveza izinto ezifana nokobana inga kghani umalukazana uzokuba mfazi wokuthoma womkhwenyana nofana useyintombi.

Umfazi otjhadileko umbatha ingubo phezu kwamahlombe wakhe eneenhluthu ezinengi ezidephileko ezitjhugulweko ezibizwa ngeenrholwani okumincamo eqinileko efakwa entanyeni,eenyaweni,emilenzeni kunye nekhalweni.Babuye bambathe ithusi nethusi emikhonweni entanyeni nemilenzeni.Ingubo abayimbathako yingubo wombhalo unoKhethwako.Abafazi abatjhadileko bahlobisa amabhande wehloko namkha ikepisi elukiweko ukwenza iinhloko ezihle.Umcamo osetjenziselwa ababfazi bama Ndebele abatjhadileko bewune palate ehlengiweko begodu bawusebenzisela umbala izinto kunye namaphetheni ahlotjiswa nokubeletha ne pumelelo.

Imincamo bayifaka imibala ukwenzela bona badlulise ilwazi ngobujamo bezulu,izinga lakhe lokuhlobana nabanye abafazi emphakathini wakhe nofana emdenini wakhe abenza isambatho kunye nekareko yakhe emtjhadweni nomndeni.

Emadodeni wama Ndebele ivunulo yawo ayinamibalabala,ngokwesiko amadoda wama Ndebele ambatha i puleli yesifuba nofana i poriyana elenga entanyeni.Ivamise ukuhlotjiswa ngemincamo phezulu begodu yenziwa ngeenkhumba iporiyana litshwayo lobudoda begodu isokana linikelwa nguyise ngemva kobana lithathe umfazi.Amadoda wama Ndebele amabatha imihlobiso abayenzelwe bafazi babo.

Ngokwesiko amaNdebele esebenzisa izinto ezitholakala ekhaya ezifana namagobolonda,iinsimbi kunye namathambo weenlwana neenkhumba ukwenza izambatho ezineenhluthu kunye nemihlobiso.Bakhetha izinto ezithileko malungana nokuhlobana kwazo nemvelo engomkomfanekiso nofana engokomoya nofana amakghono wabo wokuvikela umgqoki nokuthuthukisa ubujamo babo emphakathini.Umcamo omnengi wamaNdebele wenziwa ngengilazi nofana umncamo weplastiki.

Ukuqakatheka okukhulu kokwenza umncamo epilweni yabantu abasikazi nendlela ihlathulula ivezwa ngemibala ,amaphetheni we goemetric begodu ukusikinyeka kuragela phambili ngokutjhuguluka kwesikhathi.Umsebenzi wemncamo yihlathululo ebonakalako yokuveza isiqhema sobuhlanga namagugu nobufakazi kunye nokudlulisa ubujamo nokhudluliswa kwama siko.

Hlangana neentjhaba ze Afrika umncamo uhlanganisa ubuhle besiko nofana ubujamo bomtjhado.Esiqhemeni sendabuko samaNdebele abafazi baba mbatha iingubo ezineenhluthu njengetshwayo lepilo yomnotho begodu nokutjengisa inani labentwana abanalo.e-Arika yesimanje manje ihlathululo namatshwayo wokwenza ivunulo sele itjhugulukile kodwana isasetjenziswa ukuzikhakhazisa kwethu ngobu Afrika bethu.

iinkomba.

1.https://www.vukuzenzele.gov.za/employment

2.https://www.nomadafricamag.com/welcome-mobile/

3.https://www.bona.co.za/</text>
      <sha1>jq96d990skl9f0gghhbb7ij7os064di</sha1>
    </revision>
  </page>
  <page>
    <title>Amalimi eSewula Afrika</title>
    <ns>0</ns>
    <id>612</id>
    <revision>
      <id>2872</id>
      <timestamp>2025-05-30T16:06:11Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;== Amalimi enarheni yeSewula afrika == '''Ilimi''' kuyindlela abantu abakhuluma ngayo ngokuthi benze imidumo nofana amathswayo ukuthi bakghone ukudluliselana ilwazi,imininingwane. Abantu basenzisa ilimi ukuthi bakghone ukuveza imicabango Kanye nemizwa yabo&lt;ref&gt;Bonvillain N. Language, culture, and communication: The meaning of messages. Rowman &amp; Littlefield; 2019 Mar 20.&lt;/ref&gt;. Ilimi kuyinto eqakathekileko emasikweni wabantu abanzima begodu neemphakathini ngombana arheleb...&quot;</comment>
      <origin>2872</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5955" sha1="crike732vqi82esws6a0evghdbl7yur" xml:space="preserve">== Amalimi enarheni yeSewula afrika ==
'''Ilimi''' kuyindlela abantu abakhuluma ngayo ngokuthi benze imidumo nofana amathswayo ukuthi bakghone ukudluliselana ilwazi,imininingwane. Abantu basenzisa ilimi ukuthi bakghone ukuveza imicabango Kanye nemizwa yabo&lt;ref&gt;Bonvillain N. Language, culture, and communication: The meaning of messages. Rowman &amp; Littlefield; 2019 Mar 20.&lt;/ref&gt;. Ilimi kuyinto eqakathekileko emasikweni wabantu abanzima begodu neemphakathini ngombana arhelebha abantu bonyana bokghone ukuzwana, benze amasiko namasiko wabo basebenzisa ilimi. Ilimi linendlela elibonaka ngayo, ekukuthi ilinemidumo nofana amatjhada athileko enziwako ukuze likghone ukukhulunywa&lt;ref&gt;Diamond AS. The history and origin of language. Routledge; 2023 Dec 30.&lt;/ref&gt;. Lokho kutjho bona elinye nelinyelimi ilimi kunendlela efanele liphinyiswe ngakhona ukuze kuthiwe ulikhuluma kuhle. [[Ilimi]] linemithetho ebusa ukukhulunywa nokutlolwa kwalo. Ilimi libonakala ngokuthi likghona ukwakha ubudlelwano phakathi kwabantu, ukuzazi nokuba munye emphakathini. Amalimi abasengozini yokutjhabala nangabe awakhulunywa, ngesibanga seenzathu ezinengi ezifana nokuthutha endaweni ohlala kiyo bese uye kwenye lapho kungakhulunywa khona ilimi lakho,

== Imiphumela yokuthi ilimi libesengozini yokutjhabalala ==

=== Ukulahlekelwa magugu wamasiko ===
Njengoba ilimi likhambisana namasiko&lt;ref name=&quot;:0&quot;&gt;Kramsch, C., 2014. Language and culture. ''AILA review'', ''27''(1), pp.30-55.&lt;/ref&gt;, kutjho bona ukulahleka welimi kubiza nokulahleka kwamisiko wabantu abebakhuluma amalimi lawo. Abantu bangalahlekelwa yindlela ekungiyo yokwenza amasiko wabo.

== Ukutlhogeka kokubulunga amalimi wenarha yeSewula afrika ==

=== Ukudluliswa kwamasiko. ===
Ilimi lidlala indima ekulu ekudlulisweni kwamasiko, ukusuka esizukulwaneni ukuya kwesinye isizukulwane. Lokhu kwenziwa kukobana [[isiko]] lidluliswa ngomlomo kusetjenziswe ilimi&lt;ref name=&quot;:0&quot; /&gt;. Ilimi lisetjenziswa ukufundisa, ukudlulisa ilwazi lamasiko Kanye nekambiso yawo.Ukubulunga amalimi eSewula Afrika kukhambisana nokubulunga amasiko wabantu abanzima, ngombana ilimi nesiko akuhlukaniseki.

=== Ukukhulunywa kwamalimi amanengi ===
ISewula Afrika kuyinarha enothe ngamalimi ngombana inamalimi adlula kwamathathu akhulunywako nasemthethweni ngokukhulunywa&lt;ref&gt;Van Niekerk, D.R., van Heerden, C.J., Davel, M.H., Kleynhans, N., Kjartansson, O., Jansche, M. and Ha, L., 2017, August. Rapid Development of TTS Corpora for Four South African Languages. In ''Interspeech'' (pp. 2178-2182).&lt;/ref&gt;. Amalimi weSewula Afrika nakubulungiweko, kuzokukhuthaza Abantu ukuthi bakghone ukukhuluma amalimi adlula kwamabili begodu ngendlela efaneleko&lt;ref&gt;Noge, K.M., The Preservation of Culture and Indigenous Languages in a Multiculturalism Context. ''educational review'', ''82''(3), pp.381-402.&lt;/ref&gt;. Isenzo lesi sizokwandisa ukwamukelana kwabantu ngokuhlukana abanakho ngokwamalimi wabo. 

=== Ukusekela ifundo ===
Ukubulunga amalimi esewula afrika kunekghono lokuthuthukisa izinga lefundo enarheni; khulu nasiqalise endaweni ezisemakhaya ezisathuthukako kilezi ndawo kusafundwa ngamalimi wabantu abanzima abu-9 lokho kutjho bona bafunda ngamalimi angakathuthuki ngokwedijithali. Ilimi nalibulungiweko lizokwenza bonyana indawo zibe neesetjenziswa ezinengi zokufundisa ezizitlhogako ukwenza abafundi bazo bonyana bathole imiphumela emihle&lt;ref&gt;Mudau, P.P., Mandende, I.P. and Mushaathoni, M., 2024. Indigenous language preservation: A study of the Tshivenḓa speech community in South Africa. ''Journal of Intercultural Communication'', ''24''(4), pp.1-12.&lt;/ref&gt;.

=== Ukufundiswa kwelimi ===
Woke umuntu nakakhulunyiswa ngelimi likanina khuliswe ngalo kuba lula bonyana azwisise begodu angararani. Kuqakathekile bonyana amalimi weSewula Afrika wendabuko abulungwe khona kuzokukghonakala bonyana afakwe erherhweni lefundo etholakala ngamalimi amanengi nofana amabili eenkolweni zoke ZeSewula Afrika. 

=== Ukufaka umphakathi ekukhulunyweni kwelimi ===
Amanye wamalimi wendabuko weSewula Afrika asengozini yokutjhabalala. Imiphakathi kufanele ifakwe ekubulungelweni kwemalimi ngokuthi omunye nomunye umphakathi kufanele ukhuthaze bonyana abantu bakhulume ilimi lendabuko lalalelo ndawo nofana kukhulunywe amalimi wendabuko khulu khulu. Imiphakathi nayizibandakanya ekutheni ikhuthaze abantu bonyana bakhulume ilimi lendabuko, kuzokukhuthaza bonyana  amalimi asengozini yokutjhabalala agcine sele aphumele engozini&lt;ref&gt;Rajagukguk, R., Malems, T. and Ginting, M., 2022. Preserving linguistic diversity: Strategies for language preservation and cultural heritage safeguarding. ''Jurnal Ilmu Pendidikan dan Humaniora'', ''11''(3), pp.221-236.&lt;/ref&gt;.  Imiphakathi ingazibandakanya ngokuthi yenze imsebenzi nofana imigidi ethuthukisa ilimi.

=== Ukwenziwa kweensiza zokufundisa ===
Ukubulunga kwelimi kuzokwenza bona kube lula nofana kube neensiza zokufundisa ezinengi ezitholakala ngamalimi wendabuko weSewula afrika. Loku kuzokuthuthukisa izinga lokufunda eeenkolweeeni ngombana umuntu izwisisa msinya lokha nakafuda ngeimi lakhe&lt;ref&gt;Mlambo, R. and Matfunjwa, M., 2024. The use of technology to preserve indigenous languages of South Africa. ''Literator-Journal of Literary Criticism, Comparative Linguistics and Literary Studies'', ''45''(1), p.2007.&lt;/ref&gt;. Nabo titjhere kufuze bonyana bathole ukubandulwa nesekelo lokufundisa amalimi wendabuko ngendlela abafundi ezokwenza bona abafundi bathande begodu bazikhakhazise ngelimi labo.

== Isiphetho ==
Ilimi kuyinto eyenza bonyana abantu bezwane badluliselane ilwazi nokuthi baveze baveze amazizo wabo. Ilimi kuqakathekile bonyana libulungwe ngombana lisetjenziswa ukwenza amasiko begodu kukhuthaza bonyana umuntu munye akghone ukukhuluma amalimi amanengi ayedwa. Ifundo izokghona ukuthuthuka ngombana kuzokuba neensiza zokufundisa ezinengi ezizokwenza bonyana abafundi bakghone ukuthuma imiphumela emihle. Umphakathi nawo unekghono lokuthi izabankanye ekubulungeni amalimi asengozini yokutjhabalala.</text>
      <sha1>crike732vqi82esws6a0evghdbl7yur</sha1>
    </revision>
    <revision>
      <id>3179</id>
      <parentid>2872</parentid>
      <timestamp>2025-06-21T19:04:44Z</timestamp>
      <contributor>
        <ip>85.97.84.231</ip>
      </contributor>
      <origin>3179</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6066" sha1="5ix9fi354hrxiz56msf1kv4h3ejbmv9" xml:space="preserve">[[File:Common chimpanzee (Pan troglodytes schweinfurthii) feeding.jpg|thumb|Omar al-Bashir is a chimpanzee.]]

== Amalimi enarheni yeSewula afrika ==
'''Ilimi''' kuyindlela abantu abakhuluma ngayo ngokuthi benze imidumo nofana amathswayo ukuthi bakghone ukudluliselana ilwazi,imininingwane. Abantu basenzisa ilimi ukuthi bakghone ukuveza imicabango Kanye nemizwa yabo&lt;ref&gt;Bonvillain N. Language, culture, and communication: The meaning of messages. Rowman &amp; Littlefield; 2019 Mar 20.&lt;/ref&gt;. Ilimi kuyinto eqakathekileko emasikweni wabantu abanzima begodu neemphakathini ngombana arhelebha abantu bonyana bokghone ukuzwana, benze amasiko namasiko wabo basebenzisa ilimi. Ilimi linendlela elibonaka ngayo, ekukuthi ilinemidumo nofana amatjhada athileko enziwako ukuze likghone ukukhulunywa&lt;ref&gt;Diamond AS. The history and origin of language. Routledge; 2023 Dec 30.&lt;/ref&gt;. Lokho kutjho bona elinye nelinyelimi ilimi kunendlela efanele liphinyiswe ngakhona ukuze kuthiwe ulikhuluma kuhle. [[Ilimi]] linemithetho ebusa ukukhulunywa nokutlolwa kwalo. Ilimi libonakala ngokuthi likghona ukwakha ubudlelwano phakathi kwabantu, ukuzazi nokuba munye emphakathini. Amalimi abasengozini yokutjhabala nangabe awakhulunywa, ngesibanga seenzathu ezinengi ezifana nokuthutha endaweni ohlala kiyo bese uye kwenye lapho kungakhulunywa khona ilimi lakho,

== Imiphumela yokuthi ilimi libesengozini yokutjhabalala ==

=== Ukulahlekelwa magugu wamasiko ===
Njengoba ilimi likhambisana namasiko&lt;ref name=&quot;:0&quot;&gt;Kramsch, C., 2014. Language and culture. ''AILA review'', ''27''(1), pp.30-55.&lt;/ref&gt;, kutjho bona ukulahleka welimi kubiza nokulahleka kwamisiko wabantu abebakhuluma amalimi lawo. Abantu bangalahlekelwa yindlela ekungiyo yokwenza amasiko wabo.

== Ukutlhogeka kokubulunga amalimi wenarha yeSewula afrika ==

=== Ukudluliswa kwamasiko. ===
Ilimi lidlala indima ekulu ekudlulisweni kwamasiko, ukusuka esizukulwaneni ukuya kwesinye isizukulwane. Lokhu kwenziwa kukobana [[isiko]] lidluliswa ngomlomo kusetjenziswe ilimi&lt;ref name=&quot;:0&quot; /&gt;. Ilimi lisetjenziswa ukufundisa, ukudlulisa ilwazi lamasiko Kanye nekambiso yawo.Ukubulunga amalimi eSewula Afrika kukhambisana nokubulunga amasiko wabantu abanzima, ngombana ilimi nesiko akuhlukaniseki.

=== Ukukhulunywa kwamalimi amanengi ===
ISewula Afrika kuyinarha enothe ngamalimi ngombana inamalimi adlula kwamathathu akhulunywako nasemthethweni ngokukhulunywa&lt;ref&gt;Van Niekerk, D.R., van Heerden, C.J., Davel, M.H., Kleynhans, N., Kjartansson, O., Jansche, M. and Ha, L., 2017, August. Rapid Development of TTS Corpora for Four South African Languages. In ''Interspeech'' (pp. 2178-2182).&lt;/ref&gt;. Amalimi weSewula Afrika nakubulungiweko, kuzokukhuthaza Abantu ukuthi bakghone ukukhuluma amalimi adlula kwamabili begodu ngendlela efaneleko&lt;ref&gt;Noge, K.M., The Preservation of Culture and Indigenous Languages in a Multiculturalism Context. ''educational review'', ''82''(3), pp.381-402.&lt;/ref&gt;. Isenzo lesi sizokwandisa ukwamukelana kwabantu ngokuhlukana abanakho ngokwamalimi wabo. 

=== Ukusekela ifundo ===
Ukubulunga amalimi esewula afrika kunekghono lokuthuthukisa izinga lefundo enarheni; khulu nasiqalise endaweni ezisemakhaya ezisathuthukako kilezi ndawo kusafundwa ngamalimi wabantu abanzima abu-9 lokho kutjho bona bafunda ngamalimi angakathuthuki ngokwedijithali. Ilimi nalibulungiweko lizokwenza bonyana indawo zibe neesetjenziswa ezinengi zokufundisa ezizitlhogako ukwenza abafundi bazo bonyana bathole imiphumela emihle&lt;ref&gt;Mudau, P.P., Mandende, I.P. and Mushaathoni, M., 2024. Indigenous language preservation: A study of the Tshivenḓa speech community in South Africa. ''Journal of Intercultural Communication'', ''24''(4), pp.1-12.&lt;/ref&gt;.

=== Ukufundiswa kwelimi ===
Woke umuntu nakakhulunyiswa ngelimi likanina khuliswe ngalo kuba lula bonyana azwisise begodu angararani. Kuqakathekile bonyana amalimi weSewula Afrika wendabuko abulungwe khona kuzokukghonakala bonyana afakwe erherhweni lefundo etholakala ngamalimi amanengi nofana amabili eenkolweni zoke ZeSewula Afrika. 

=== Ukufaka umphakathi ekukhulunyweni kwelimi ===
Amanye wamalimi wendabuko weSewula Afrika asengozini yokutjhabalala. Imiphakathi kufanele ifakwe ekubulungelweni kwemalimi ngokuthi omunye nomunye umphakathi kufanele ukhuthaze bonyana abantu bakhulume ilimi lendabuko lalalelo ndawo nofana kukhulunywe amalimi wendabuko khulu khulu. Imiphakathi nayizibandakanya ekutheni ikhuthaze abantu bonyana bakhulume ilimi lendabuko, kuzokukhuthaza bonyana  amalimi asengozini yokutjhabalala agcine sele aphumele engozini&lt;ref&gt;Rajagukguk, R., Malems, T. and Ginting, M., 2022. Preserving linguistic diversity: Strategies for language preservation and cultural heritage safeguarding. ''Jurnal Ilmu Pendidikan dan Humaniora'', ''11''(3), pp.221-236.&lt;/ref&gt;.  Imiphakathi ingazibandakanya ngokuthi yenze imsebenzi nofana imigidi ethuthukisa ilimi.

=== Ukwenziwa kweensiza zokufundisa ===
Ukubulunga kwelimi kuzokwenza bona kube lula nofana kube neensiza zokufundisa ezinengi ezitholakala ngamalimi wendabuko weSewula afrika. Loku kuzokuthuthukisa izinga lokufunda eeenkolweeeni ngombana umuntu izwisisa msinya lokha nakafuda ngeimi lakhe&lt;ref&gt;Mlambo, R. and Matfunjwa, M., 2024. The use of technology to preserve indigenous languages of South Africa. ''Literator-Journal of Literary Criticism, Comparative Linguistics and Literary Studies'', ''45''(1), p.2007.&lt;/ref&gt;. Nabo titjhere kufuze bonyana bathole ukubandulwa nesekelo lokufundisa amalimi wendabuko ngendlela abafundi ezokwenza bona abafundi bathande begodu bazikhakhazise ngelimi labo.

== Isiphetho ==
Ilimi kuyinto eyenza bonyana abantu bezwane badluliselane ilwazi nokuthi baveze baveze amazizo wabo. Ilimi kuqakathekile bonyana libulungwe ngombana lisetjenziswa ukwenza amasiko begodu kukhuthaza bonyana umuntu munye akghone ukukhuluma amalimi amanengi ayedwa. Ifundo izokghona ukuthuthuka ngombana kuzokuba neensiza zokufundisa ezinengi ezizokwenza bonyana abafundi bakghone ukuthuma imiphumela emihle. Umphakathi nawo unekghono lokuthi izabankanye ekubulungeni amalimi asengozini yokutjhabalala.</text>
      <sha1>5ix9fi354hrxiz56msf1kv4h3ejbmv9</sha1>
    </revision>
    <revision>
      <id>3298</id>
      <parentid>3179</parentid>
      <timestamp>2025-07-02T20:45:10Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Undo revision [[Special:Diff/3179|3179]] by [[Special:Contributions/85.97.84.231|85.97.84.231]] ([[User talk:85.97.84.231|talk]])</comment>
      <origin>3298</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5955" sha1="crike732vqi82esws6a0evghdbl7yur" xml:space="preserve">== Amalimi enarheni yeSewula afrika ==
'''Ilimi''' kuyindlela abantu abakhuluma ngayo ngokuthi benze imidumo nofana amathswayo ukuthi bakghone ukudluliselana ilwazi,imininingwane. Abantu basenzisa ilimi ukuthi bakghone ukuveza imicabango Kanye nemizwa yabo&lt;ref&gt;Bonvillain N. Language, culture, and communication: The meaning of messages. Rowman &amp; Littlefield; 2019 Mar 20.&lt;/ref&gt;. Ilimi kuyinto eqakathekileko emasikweni wabantu abanzima begodu neemphakathini ngombana arhelebha abantu bonyana bokghone ukuzwana, benze amasiko namasiko wabo basebenzisa ilimi. Ilimi linendlela elibonaka ngayo, ekukuthi ilinemidumo nofana amatjhada athileko enziwako ukuze likghone ukukhulunywa&lt;ref&gt;Diamond AS. The history and origin of language. Routledge; 2023 Dec 30.&lt;/ref&gt;. Lokho kutjho bona elinye nelinyelimi ilimi kunendlela efanele liphinyiswe ngakhona ukuze kuthiwe ulikhuluma kuhle. [[Ilimi]] linemithetho ebusa ukukhulunywa nokutlolwa kwalo. Ilimi libonakala ngokuthi likghona ukwakha ubudlelwano phakathi kwabantu, ukuzazi nokuba munye emphakathini. Amalimi abasengozini yokutjhabala nangabe awakhulunywa, ngesibanga seenzathu ezinengi ezifana nokuthutha endaweni ohlala kiyo bese uye kwenye lapho kungakhulunywa khona ilimi lakho,

== Imiphumela yokuthi ilimi libesengozini yokutjhabalala ==

=== Ukulahlekelwa magugu wamasiko ===
Njengoba ilimi likhambisana namasiko&lt;ref name=&quot;:0&quot;&gt;Kramsch, C., 2014. Language and culture. ''AILA review'', ''27''(1), pp.30-55.&lt;/ref&gt;, kutjho bona ukulahleka welimi kubiza nokulahleka kwamisiko wabantu abebakhuluma amalimi lawo. Abantu bangalahlekelwa yindlela ekungiyo yokwenza amasiko wabo.

== Ukutlhogeka kokubulunga amalimi wenarha yeSewula afrika ==

=== Ukudluliswa kwamasiko. ===
Ilimi lidlala indima ekulu ekudlulisweni kwamasiko, ukusuka esizukulwaneni ukuya kwesinye isizukulwane. Lokhu kwenziwa kukobana [[isiko]] lidluliswa ngomlomo kusetjenziswe ilimi&lt;ref name=&quot;:0&quot; /&gt;. Ilimi lisetjenziswa ukufundisa, ukudlulisa ilwazi lamasiko Kanye nekambiso yawo.Ukubulunga amalimi eSewula Afrika kukhambisana nokubulunga amasiko wabantu abanzima, ngombana ilimi nesiko akuhlukaniseki.

=== Ukukhulunywa kwamalimi amanengi ===
ISewula Afrika kuyinarha enothe ngamalimi ngombana inamalimi adlula kwamathathu akhulunywako nasemthethweni ngokukhulunywa&lt;ref&gt;Van Niekerk, D.R., van Heerden, C.J., Davel, M.H., Kleynhans, N., Kjartansson, O., Jansche, M. and Ha, L., 2017, August. Rapid Development of TTS Corpora for Four South African Languages. In ''Interspeech'' (pp. 2178-2182).&lt;/ref&gt;. Amalimi weSewula Afrika nakubulungiweko, kuzokukhuthaza Abantu ukuthi bakghone ukukhuluma amalimi adlula kwamabili begodu ngendlela efaneleko&lt;ref&gt;Noge, K.M., The Preservation of Culture and Indigenous Languages in a Multiculturalism Context. ''educational review'', ''82''(3), pp.381-402.&lt;/ref&gt;. Isenzo lesi sizokwandisa ukwamukelana kwabantu ngokuhlukana abanakho ngokwamalimi wabo. 

=== Ukusekela ifundo ===
Ukubulunga amalimi esewula afrika kunekghono lokuthuthukisa izinga lefundo enarheni; khulu nasiqalise endaweni ezisemakhaya ezisathuthukako kilezi ndawo kusafundwa ngamalimi wabantu abanzima abu-9 lokho kutjho bona bafunda ngamalimi angakathuthuki ngokwedijithali. Ilimi nalibulungiweko lizokwenza bonyana indawo zibe neesetjenziswa ezinengi zokufundisa ezizitlhogako ukwenza abafundi bazo bonyana bathole imiphumela emihle&lt;ref&gt;Mudau, P.P., Mandende, I.P. and Mushaathoni, M., 2024. Indigenous language preservation: A study of the Tshivenḓa speech community in South Africa. ''Journal of Intercultural Communication'', ''24''(4), pp.1-12.&lt;/ref&gt;.

=== Ukufundiswa kwelimi ===
Woke umuntu nakakhulunyiswa ngelimi likanina khuliswe ngalo kuba lula bonyana azwisise begodu angararani. Kuqakathekile bonyana amalimi weSewula Afrika wendabuko abulungwe khona kuzokukghonakala bonyana afakwe erherhweni lefundo etholakala ngamalimi amanengi nofana amabili eenkolweni zoke ZeSewula Afrika. 

=== Ukufaka umphakathi ekukhulunyweni kwelimi ===
Amanye wamalimi wendabuko weSewula Afrika asengozini yokutjhabalala. Imiphakathi kufanele ifakwe ekubulungelweni kwemalimi ngokuthi omunye nomunye umphakathi kufanele ukhuthaze bonyana abantu bakhulume ilimi lendabuko lalalelo ndawo nofana kukhulunywe amalimi wendabuko khulu khulu. Imiphakathi nayizibandakanya ekutheni ikhuthaze abantu bonyana bakhulume ilimi lendabuko, kuzokukhuthaza bonyana  amalimi asengozini yokutjhabalala agcine sele aphumele engozini&lt;ref&gt;Rajagukguk, R., Malems, T. and Ginting, M., 2022. Preserving linguistic diversity: Strategies for language preservation and cultural heritage safeguarding. ''Jurnal Ilmu Pendidikan dan Humaniora'', ''11''(3), pp.221-236.&lt;/ref&gt;.  Imiphakathi ingazibandakanya ngokuthi yenze imsebenzi nofana imigidi ethuthukisa ilimi.

=== Ukwenziwa kweensiza zokufundisa ===
Ukubulunga kwelimi kuzokwenza bona kube lula nofana kube neensiza zokufundisa ezinengi ezitholakala ngamalimi wendabuko weSewula afrika. Loku kuzokuthuthukisa izinga lokufunda eeenkolweeeni ngombana umuntu izwisisa msinya lokha nakafuda ngeimi lakhe&lt;ref&gt;Mlambo, R. and Matfunjwa, M., 2024. The use of technology to preserve indigenous languages of South Africa. ''Literator-Journal of Literary Criticism, Comparative Linguistics and Literary Studies'', ''45''(1), p.2007.&lt;/ref&gt;. Nabo titjhere kufuze bonyana bathole ukubandulwa nesekelo lokufundisa amalimi wendabuko ngendlela abafundi ezokwenza bona abafundi bathande begodu bazikhakhazise ngelimi labo.

== Isiphetho ==
Ilimi kuyinto eyenza bonyana abantu bezwane badluliselane ilwazi nokuthi baveze baveze amazizo wabo. Ilimi kuqakathekile bonyana libulungwe ngombana lisetjenziswa ukwenza amasiko begodu kukhuthaza bonyana umuntu munye akghone ukukhuluma amalimi amanengi ayedwa. Ifundo izokghona ukuthuthuka ngombana kuzokuba neensiza zokufundisa ezinengi ezizokwenza bonyana abafundi bakghone ukuthuma imiphumela emihle. Umphakathi nawo unekghono lokuthi izabankanye ekubulungeni amalimi asengozini yokutjhabalala.</text>
      <sha1>crike732vqi82esws6a0evghdbl7yur</sha1>
    </revision>
    <revision>
      <id>5176</id>
      <parentid>3298</parentid>
      <timestamp>2025-08-14T16:23:16Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>5176</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5581" sha1="ij3ldxxytu4gbx6qz3wbl52u3f0tup6" xml:space="preserve">'''Ilimi''' kuyindlela abantu abakhuluma ngayo ngokuthi benze imidumo nofana amathswayo ukuthi bakghone ukudluliselana ilwazi,imininingwane. Abantu basenzisa ilimi ukuthi bakghone ukuveza imicabango Kanye nemizwa yabo.&lt;ref&gt;Bonvillain N. Language, culture, and communication: The meaning of messages. Rowman &amp; Littlefield; 2019 Mar 20.&lt;/ref&gt; Ilimi kuyinto eqakathekileko emasikweni wabantu abanzima begodu neemphakathini ngombana arhelebha abantu bonyana bokghone ukuzwana, benze amasiko namasiko wabo basebenzisa ilimi. Ilimi linendlela elibonaka ngayo, ekukuthi ilinemidumo nofana amatjhada athileko enziwako ukuze likghone ukukhulunywa.&lt;ref&gt;Diamond AS. The history and origin of language. Routledge; 2023 Dec 30.&lt;/ref&gt; Lokho kutjho bona elinye nelinyelimi ilimi kunendlela efanele liphinyiswe ngakhona ukuze kuthiwe ulikhuluma kuhle. [[Ilimi]] linemithetho ebusa ukukhulunywa nokutlolwa kwalo. Ilimi libonakala ngokuthi likghona ukwakha ubudlelwano phakathi kwabantu, ukuzazi nokuba munye emphakathini. Amalimi abasengozini yokutjhabala nangabe awakhulunywa, ngesibanga seenzathu ezinengi ezifana nokuthutha endaweni ohlala kiyo bese uye kwenye lapho kungakhulunywa khona ilimi lakho.

=== Ukutlhogeka kokubulunga amalimi wenarha yeSewula afrika ===

==== Ukudluliswa kwamasiko. ====
Ilimi lidlala indima ekulu ekudlulisweni kwamasiko, ukusuka esizukulwaneni ukuya kwesinye isizukulwane. Lokhu kwenziwa kukobana [[isiko]] lidluliswa ngomlomo kusetjenziswe ilimi.&lt;ref name=&quot;:0&quot;&gt;Kramsch, C., 2014. Language and culture. ''AILA review'', ''27''(1), pp.30-55.&lt;/ref&gt; Ilimi lisetjenziswa ukufundisa, ukudlulisa ilwazi lamasiko Kanye nekambiso yawo.Ukubulunga amalimi eSewula Afrika kukhambisana nokubulunga amasiko wabantu abanzima, ngombana ilimi nesiko akuhlukaniseki.

==== Ukukhulunywa kwamalimi amanengi nokuthuthukisa izinga lefundo ====
ISewula Afrika kuyinarha enothe ngamalimi ngombana inamalimi adlula kwamathathu akhulunywako nasemthethweni ngokukhulunywa.&lt;ref&gt;Van Niekerk, D.R., van Heerden, C.J., Davel, M.H., Kleynhans, N., Kjartansson, O., Jansche, M. and Ha, L., 2017, August. Rapid Development of TTS Corpora for Four South African Languages. In ''Interspeech'' (pp. 2178-2182).&lt;/ref&gt;Amalimi weSewula Afrika nakubulungiweko, kuzokukhuthaza Abantu ukuthi bakghone ukukhuluma amalimi adlula kwamabili begodu ngendlela efaneleko.&lt;ref&gt;Noge, K.M., The Preservation of Culture and Indigenous Languages in a Multiculturalism Context. ''educational review'', ''82''(3), pp.381-402.&lt;/ref&gt;Isenzo lesi sizokwandisa ukwamukelana kwabantu ngokuhlukana abanakho ngokwamalimi wabo.Ukubulunga amalimi esewula afrika kunekghono lokuthuthukisa izinga lefundo enarheni; khulu nasiqalise endaweni ezisemakhaya ezisathuthukako kilezi ndawo kusafundwa ngamalimi wabantu abanzima abu-9 lokho kutjho bona bafunda ngamalimi angakathuthuki ngokwedijithali. Ilimi nalibulungiweko lizokwenza bonyana indawo zibe neesetjenziswa ezinengi zokufundisa ezizitlhogako ukwenza abafundi bazo bonyana bathole imiphumela emihle.&lt;ref&gt;Mudau, P.P., Mandende, I.P. and Mushaathoni, M., 2024. Indigenous language preservation: A study of the Tshivenḓa speech community in South Africa. ''Journal of Intercultural Communication'', ''24''(4), pp.1-12.&lt;/ref&gt;Woke umuntu nakakhulunyiswa ngelimi likanina khuliswe ngalo kuba lula bonyana azwisise begodu angararani. Kuqakathekile bonyana amalimi weSewula Afrika wendabuko abulungwe khona kuzokukghonakala bonyana afakwe erherhweni lefundo etholakala ngamalimi amanengi nofana amabili eenkolweni zoke ZeSewula Afrika. 

==== Ukufaka umphakathi ekukhulunyweni kwelimi ====
Amanye wamalimi wendabuko weSewula Afrika asengozini yokutjhabalala. Imiphakathi kufanele ifakwe ekubulungelweni kwemalimi ngokuthi omunye nomunye umphakathi kufanele ukhuthaze bonyana abantu bakhulume ilimi lendabuko lalalelo ndawo nofana kukhulunywe amalimi wendabuko khulu khulu. Imiphakathi nayizibandakanya ekutheni ikhuthaze abantu bonyana bakhulume ilimi lendabuko, kuzokukhuthaza bonyana  amalimi asengozini yokutjhabalala agcine sele aphumele engozini.&lt;ref&gt;Rajagukguk, R., Malems, T. and Ginting, M., 2022. Preserving linguistic diversity: Strategies for language preservation and cultural heritage safeguarding. ''Jurnal Ilmu Pendidikan dan Humaniora'', ''11''(3), pp.221-236.&lt;/ref&gt; Imiphakathi ingazibandakanya ngokuthi yenze imsebenzi nofana imigidi ethuthukisa ilimi.

==== Ukwenziwa kweensiza zokufundisa ====
Ukubulunga kwelimi kuzokwenza bona kube lula nofana kube neensiza zokufundisa ezinengi ezitholakala ngamalimi wendabuko weSewula afrika. Loku kuzokuthuthukisa izinga lokufunda eeenkolweeeni ngombana umuntu izwisisa msinya lokha nakafuda ngeimi lakhe.&lt;ref&gt;Mlambo, R. and Matfunjwa, M., 2024. The use of technology to preserve indigenous languages of South Africa. ''Literator-Journal of Literary Criticism, Comparative Linguistics and Literary Studies'', ''45''(1), p.2007.&lt;/ref&gt; Nabo titjhere kufuze bonyana bathole ukubandulwa nesekelo lokufundisa amalimi wendabuko ngendlela abafundi ezokwenza bona abafundi bathande begodu bazikhakhazise ngelimi labo. Ilimi kuyinto eyenza bonyana abantu bezwane badluliselane ilwazi nokuthi baveze baveze amazizo wabo. Ilimi kuqakathekile bonyana libulungwe ngombana lisetjenziswa ukwenza amasiko begodu kukhuthaza bonyana umuntu munye akghone ukukhuluma amalimi amanengi ayedwa. Ifundo izokghona ukuthuthuka ngombana kuzokuba neensiza zokufundisa ezinengi ezizokwenza bonyana abafundi bakghone ukuthuma imiphumela emihle. Umphakathi nawo unekghono lokuthi izabankanye ekubulungeni amalimi asengozini yokutjhabalala.

== Iinkomba ==</text>
      <sha1>ij3ldxxytu4gbx6qz3wbl52u3f0tup6</sha1>
    </revision>
    <revision>
      <id>5177</id>
      <parentid>5176</parentid>
      <timestamp>2025-08-14T16:24:51Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>5177</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5647" sha1="izp0etytx5ooy9uxp48pa8rwo13ux2d" xml:space="preserve">'''Ilimi''' kuyindlela abantu abakhuluma ngayo ngokuthi benze imidumo nofana amathswayo ukuthi bakghone ukudluliselana ilwazi,imininingwane. Abantu basenzisa ilimi ukuthi bakghone ukuveza imicabango Kanye nemizwa yabo.&lt;ref&gt;Bonvillain N. Language, culture, and communication: The meaning of messages. Rowman &amp; Littlefield; 2019 Mar 20.&lt;/ref&gt; Ilimi kuyinto eqakathekileko emasikweni wabantu abanzima begodu neemphakathini ngombana arhelebha abantu bonyana bokghone ukuzwana, benze amasiko namasiko wabo basebenzisa ilimi. Ilimi linendlela elibonaka ngayo, ekukuthi ilinemidumo nofana amatjhada athileko enziwako ukuze likghone ukukhulunywa.&lt;ref&gt;Diamond AS. The history and origin of language. Routledge; 2023 Dec 30.&lt;/ref&gt; Lokho kutjho bona elinye nelinyelimi ilimi kunendlela efanele liphinyiswe ngakhona ukuze kuthiwe ulikhuluma kuhle. [[Ilimi]] linemithetho ebusa ukukhulunywa nokutlolwa kwalo. Ilimi libonakala ngokuthi likghona ukwakha ubudlelwano phakathi kwabantu, ukuzazi nokuba munye emphakathini. Amalimi abasengozini yokutjhabala nangabe awakhulunywa, ngesibanga seenzathu ezinengi ezifana nokuthutha endaweni ohlala kiyo bese uye kwenye lapho kungakhulunywa khona ilimi lakho.

=== Ukutlhogeka kokubulunga amalimi wenarha yeSewula afrika ===

==== Ukudluliswa kwamasiko. ====
Ilimi lidlala indima ekulu ekudlulisweni kwamasiko, ukusuka esizukulwaneni ukuya kwesinye isizukulwane. Lokhu kwenziwa kukobana [[isiko]] lidluliswa ngomlomo kusetjenziswe ilimi.&lt;ref name=&quot;:0&quot;&gt;Kramsch, C., 2014. Language and culture. ''AILA review'', ''27''(1), pp.30-55.&lt;/ref&gt; Ilimi lisetjenziswa ukufundisa, ukudlulisa ilwazi lamasiko Kanye nekambiso yawo.Ukubulunga amalimi eSewula Afrika kukhambisana nokubulunga amasiko wabantu abanzima, ngombana ilimi nesiko akuhlukaniseki.

==== Ukukhulunywa kwamalimi amanengi nokuthuthukisa izinga lefundo ====
ISewula Afrika kuyinarha enothe ngamalimi ngombana inamalimi adlula kwamathathu akhulunywako nasemthethweni ngokukhulunywa.&lt;ref&gt;Van Niekerk, D.R., van Heerden, C.J., Davel, M.H., Kleynhans, N., Kjartansson, O., Jansche, M. and Ha, L., 2017, August. Rapid Development of TTS Corpora for Four South African Languages. In ''Interspeech'' (pp. 2178-2182).&lt;/ref&gt;Amalimi weSewula Afrika nakubulungiweko, kuzokukhuthaza Abantu ukuthi bakghone ukukhuluma amalimi adlula kwamabili begodu ngendlela efaneleko.&lt;ref&gt;Noge, K.M., The Preservation of Culture and Indigenous Languages in a Multiculturalism Context. ''educational review'', ''82''(3), pp.381-402.&lt;/ref&gt;Isenzo lesi sizokwandisa ukwamukelana kwabantu ngokuhlukana abanakho ngokwamalimi wabo.Ukubulunga amalimi esewula afrika kunekghono lokuthuthukisa izinga lefundo enarheni; khulu nasiqalise endaweni ezisemakhaya ezisathuthukako kilezi ndawo kusafundwa ngamalimi wabantu abanzima abu-9 lokho kutjho bona bafunda ngamalimi angakathuthuki ngokwedijithali. Ilimi nalibulungiweko lizokwenza bonyana indawo zibe neesetjenziswa ezinengi zokufundisa ezizitlhogako ukwenza abafundi bazo bonyana bathole imiphumela emihle.&lt;ref&gt;Mudau, P.P., Mandende, I.P. and Mushaathoni, M., 2024. Indigenous language preservation: A study of the Tshivenḓa speech community in South Africa. ''Journal of Intercultural Communication'', ''24''(4), pp.1-12.&lt;/ref&gt;Woke umuntu nakakhulunyiswa ngelimi likanina khuliswe ngalo kuba lula bonyana azwisise begodu angararani. Kuqakathekile bonyana amalimi weSewula Afrika wendabuko abulungwe khona kuzokukghonakala bonyana afakwe erherhweni lefundo etholakala ngamalimi amanengi nofana amabili eenkolweni zoke ZeSewula Afrika. 

==== Ukufaka umphakathi ekukhulunyweni kwelimi ====
Amanye wamalimi wendabuko weSewula Afrika asengozini yokutjhabalala. Imiphakathi kufanele ifakwe ekubulungelweni kwemalimi ngokuthi omunye nomunye umphakathi kufanele ukhuthaze bonyana abantu bakhulume ilimi lendabuko lalalelo ndawo nofana kukhulunywe amalimi wendabuko khulu khulu. Imiphakathi nayizibandakanya ekutheni ikhuthaze abantu bonyana bakhulume ilimi lendabuko, kuzokukhuthaza bonyana  amalimi asengozini yokutjhabalala agcine sele aphumele engozini.&lt;ref&gt;Rajagukguk, R., Malems, T. and Ginting, M., 2022. Preserving linguistic diversity: Strategies for language preservation and cultural heritage safeguarding. ''Jurnal Ilmu Pendidikan dan Humaniora'', ''11''(3), pp.221-236.&lt;/ref&gt; Imiphakathi ingazibandakanya ngokuthi yenze imsebenzi nofana imigidi ethuthukisa ilimi.

==== Ukwenziwa kweensiza zokufundisa ====
Ukubulunga kwelimi kuzokwenza bona kube lula nofana kube neensiza zokufundisa ezinengi ezitholakala ngamalimi wendabuko weSewula afrika. Loku kuzokuthuthukisa izinga lokufunda eeenkolweeeni ngombana umuntu izwisisa msinya lokha nakafuda ngeimi lakhe.&lt;ref&gt;Mlambo, R. and Matfunjwa, M., 2024. The use of technology to preserve indigenous languages of South Africa. ''Literator-Journal of Literary Criticism, Comparative Linguistics and Literary Studies'', ''45''(1), p.2007.&lt;/ref&gt; Nabo titjhere kufuze bonyana bathole ukubandulwa nesekelo lokufundisa amalimi wendabuko ngendlela abafundi ezokwenza bona abafundi bathande begodu bazikhakhazise ngelimi labo. Ilimi kuyinto eyenza bonyana abantu bezwane badluliselane ilwazi nokuthi baveze baveze amazizo wabo. Ilimi kuqakathekile bonyana libulungwe ngombana lisetjenziswa ukwenza amasiko begodu kukhuthaza bonyana umuntu munye akghone ukukhuluma amalimi amanengi ayedwa. Ifundo izokghona ukuthuthuka ngombana kuzokuba neensiza zokufundisa ezinengi ezizokwenza bonyana abafundi bakghone ukuthuma imiphumela emihle. Umphakathi nawo unekghono lokuthi izabankanye ekubulungeni amalimi asengozini yokutjhabalala.

== Iinkomba ==
[[category:ilimi lesiNdebele]]
[[Category:Amalimi eSewla afrika]]</text>
      <sha1>izp0etytx5ooy9uxp48pa8rwo13ux2d</sha1>
    </revision>
  </page>
  <page>
    <title>INgwenyama UNyabela</title>
    <ns>0</ns>
    <id>613</id>
    <revision>
      <id>2876</id>
      <timestamp>2025-05-31T12:08:50Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <comment>Wrote an article</comment>
      <origin>2876</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5680" sha1="otpivjgcmw1d969l1awjqx19c7ficlt" xml:space="preserve">[[Isimumathi:King Nyabela of the Ndebele Tribe South Africa 1893.jpg|thumb|Ilitje Lesikhumbuzo leNgwenyama uNyabela]]
'''UNyabela''' yiNgwenyama yamaNdebele wakwaNzunza  eyabusa kusukela ngenyanga kaVelabahlinze 1879 nakuhlongakala iNgwenyama uRhobongo, walwa ipi namaBhuru eyathoma ngomhlaka-07 kaSinyikhaba 1882 eyaphela ngomhlaka-08 kaVelabahlinze 1883 mhla anikela Mampuru emaBhurwini, kwaba kubotjhwa kwakhe nokuhluleka kwepi yamaNdebele emaBhurwini.&lt;ref name=&quot;:0&quot;&gt;Iziko Lamakhosi - C. J Mahlangu, K. N Mahlangu, M. A Mahlangu, no-S. M Mtshweni&lt;/ref&gt; 

Ngokwencwadi ethi '''Iziko lamaKhosi''', uNyabela  - uGijamphezeni kaMabhoko - yindodana yesithathu yeNgwenyama uMabhoko ebelethwa endlukulu. Kwathi bona kuKhothame iNgwenyama uRhobongo ebeyibambele ufene, uNyabela wathatha isihlalo  waraga nokubambela  uFene indodana kaMkhephuli ngombana bekasesemncani bona angabusa. Nayiragako ithi ekuthomeni kokubusa kwakhe uNyabela wayenganayo ingubo yobukhosi. Yeke wakhupha intanga yamaDlaza bona iyokufuna ingwe khona kuzokutholakala isikhumba esizokuba yingubo yobukhosi. Umthwalintanga yamaDlaza ibizo lakhe kwakunguNomacwayi. Bagcina Bayifumene ingwe entabeni yakwaCabha, bayibulala beza nayo ekosini. &lt;ref name=&quot;:0&quot; /&gt;

=== Amadodana weNgwenyama uNyabela ===

* UMtjongweni (uSomphezeni) oliDugu noyindondana ekulu

* UMofu (uSoSenzeni) oliPhogo
* UNgobe oliDuba
* UMpepe (uSovelemu) oliDlowu
* UMzitha (uSoMene) oliSinya
* UMakhabakhubu (uSovusani) oliPhogo
* UPama (uSoMvumazoke) liRhorha
* UZalabo (uSoMlingo) oliDuba
* UMarhagi (uSoZilani) oliRhorha&lt;ref name=&quot;:0&quot; /&gt;

== Isisusa sePi kaNyabela NamaBhuru ==
[[Isimumathi:LL1882 pg008 SIKUKUNI.jpg|thumb|USekhukhune]]
Ngesikhathi sokubusa kukaNyabela amaBhuru besele athomile ukuzibusa ngombana bebangasekho ngaphasi kokubuswa maNgisi. Yeke, besele kuphethe bona, begodu bebenza koke okusemandlenabo bona balawule iintjhaba zabantu abanzima enarheni khona bazokubusa ngendlela ephumelelako.&lt;ref name=&quot;:1&quot;&gt;{{Cite web|title=South African Military History Society - Journal - AN AFRICAN MASADA: Nyabela, Mampuru and the Defence of Mapochstad|url=http://samilitaryhistory.org/vol144ds.html|access-date=2025-05-31|website=samilitaryhistory.org}}&lt;/ref&gt; Soke isikhathesi amaBhuru namaNdebele wakwaNzunza bekatjhebiswano elihle elathonywa yiNgwenyama uMabhoko. Kodwana kwathi bona amaBhuru athome ukuzibusa itjhebiswano laya lancipha. Isizathu kungaba kukuthi amaNdebele nawo besele afuna ukuzibusa,  UNyabela besele angasawubhadeli umthelo emaBhurwini, begodu wala nokuletha isibalo sabantu baboke esitjhabeni.begodu lokho kwawasilinga amaBhuru ngaphasi kombuso we-ZAR.&lt;ref name=&quot;:1&quot; /&gt;

Isisusa esikhulu serarano phakathi kwamaNdebele namaBhuru kwaba nguMampuru. UMampuru bekayikosi yabaPedi eyabelethwa ngo-1824, ayindodana yomnakwabo weKosi uSikwati. USikwati wahlongakala ngo-1861. Lokho kwabanta imiraro yokuthi ngubani okufuze alandele ekubeni yiKosi yabaPedi. &lt;ref name=&quot;:2&quot;&gt;{{Cite web|title=Kgoŝi Mampuru II – King of the Pedi people {{!}} Ditsong Museums of South Africa|url=https://ditsong.org.za/en/kgosi-mampuru-ii-king-of-the-pedi-people/|access-date=2025-05-31|website=https://ditsong.org.za/en/|language=en-US}}&lt;/ref&gt; UMampuru wathi uSikwati ukhethe yena bona abe yiKosi ngombana ubelethwa mfazi obeletha ubukhosi abaPedi abambiza bona yi-''timamollo.'' USekhukhune oyindodana ekulu kaSikwati wathi lokho angekhe kwenzeke njengombana unina kaMampuru omfazi obeletha ubukhosi ukakakhuleliswa yiKosi uSikwati, kodwana mumuntu wangaphandle. Ngaphezu kwalokho wathi uSikwati ubengakaphethi koke okufuze akuphethe nakathatha umfazi oyi-''timamollo''. Yeke isihlalo kufuze sithathwe nguSekhukhune.&lt;ref&gt;https://en.wikipedia.org/wiki/Mampuru_II&lt;/ref&gt;
USekhukhune wathoma wathatha amandla wobukhosi bewabulala nabeluleki bakaMampuru. UMampuru wagcina sele abalekile kelekhabo. Kwathi ngemva kwesikhathi uSekhukhune sele alwe ipi namaBhuru, nenye ipi namaSwati, wahlaselwa esigodlweni sakhe wahlatjwa ngomukhwa wafa ngomhlaka-13 August 1882. UMampuru nguye owasolwa ngokubulawa kukaSekhukhune, wasolwa nangokubanga umguruguru esitjhabeni sabaPedi. Yeke amaBhuru akhipha isiqunto sokuthi uMampuru akabotjhwe khona umguruguru lo uzokuphela.&lt;ref name=&quot;:2&quot; /&gt;[[Isimumathi:Stephanus Johannes Roos.jpg|thumb|UJohannes Roos]]Kuthe bona uMampuru ezwe bona uyafuneka wabaleka esitjhabeni sekabo wayokukhosela ebantwini bakwaMasimula. AbaPedi bamlandelela nalapho babawa ikosi yakwaMasimula bona ibanikele yena, kodwana yona yala. Kwaba nepi, abakwaMasimula bahlulwa epini leyo. UMampuru nakabona bonyana bakwaMasimula bahluliwe, wabalekela kwaNomtjherhelo eNgwenyameni uNyabela. &lt;ref name=&quot;:0&quot; /&gt;

AbaPedi bafika nakoNomtjharhelo bambawa eNgwenyameni uNyabela. Kuthiwa iKosi uNyabela yathi nayibaphendulako: &quot;UMampuru ngimginyile. Nanimfunako izani ningihlinze isisu nimkhuphe.&quot; Okutjho bona nangabe abaPedi bafuna uMampuru kuzokufuze kuliwe ipi bona atholakale. AbaPedi bakhamba batjhinga emBhurwini babawa isizo lokuthola uMampuru. UPaul Kruger obekamungameli we-ZAR, wathumela uRoos noSenekal bona basize abaPedi ngendaba le. AmaBhuru amabili la afika esitjhabeni samaNdebele babawa uMampuru, kodwana uNyabela wala, wathi umginyile, nabamfunako abamkhuphe ngemathunjinakhe. Ekugcineni uNyabela wasilingeka wabulala uRoos noSenekal, wathatha iinhloko zabo wazihloma eengodweni. Kuthiwa bekavuka qobe ekuseni akhambe ayokulotjhisa iinhloko zabo aziphulule neendevu zazo.&lt;ref name=&quot;:0&quot; /&gt; 

AmaBhuru asilingeka khulu ngesenzwesi athumela uPiet Joubert namasotja amanengi. Naye wafika wabawa uMaMpuru kodwana uNyabela wabhala naye, kwaba kusuka kwepi phakathi kwamaNdebele namaBhuru.&lt;ref name=&quot;:1&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>otpivjgcmw1d969l1awjqx19c7ficlt</sha1>
    </revision>
    <revision>
      <id>2879</id>
      <parentid>2876</parentid>
      <timestamp>2025-06-01T08:27:54Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <comment>added paragraphs</comment>
      <origin>2879</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8046" sha1="e80kz1kthk3l5fzwv4qab28zf193er8" xml:space="preserve">[[Isimumathi:King Nyabela of the Ndebele Tribe South Africa 1893.jpg|thumb|Ilitje Lesikhumbuzo leNgwenyama uNyabela]]
'''UNyabela''' yiNgwenyama yamaNdebele wakwaNzunza  eyabusa kusukela ngenyanga kaVelabahlinze 1879 nakukhothama iNgwenyama uRhobongo, walwa ipi namaBhuru eyathoma ngomhlaka-07 kaSinyikhaba 1882 eyaphela ngomhlaka-08 kaVelabahlinze 1883 mhla anikela Mampuru emaBhurwini, kwaba kubotjhwa kwakhe nokuhluleka kwepi yamaNdebele emaBhurwini.&lt;ref name=&quot;:0&quot;&gt;Iziko Lamakhosi - C. J Mahlangu, K. N Mahlangu, M. A Mahlangu, no-S. M Mtshweni&lt;/ref&gt; 

Ngokwencwadi ethi '''Iziko lamaKhosi''', uNyabela  - uGijamphezeni kaMabhoko - yindodana yesithathu yeNgwenyama uMabhoko ebelethwa endlukulu. Kwathi bona kukhothame iNgwenyama uRhobongo ebeyibambele uFene, uNyabela wathatha isihlalo  waraga nokubambela uFene indodana kaMkhephuli ngombana bekasesemncani bona angabusa. Nayiragako ithi ekuthomeni kokubusa kwakhe uNyabela wayenganayo ingubo yobukhosi. Yeke wakhupha intanga yamaDlaza bona iyokufuna ingwe khona kuzokutholakala isikhumba esizokuba yingubo yobukhosi. Owayethwele intanga yamaDlaza ibizo lakhe kwakunguNomacwayi. Bagcina Bayifumene ingwe entabeni yakwaCabha, bayibulala beza nayo ekosini. &lt;ref name=&quot;:0&quot; /&gt;

=== Amadodana weNgwenyama uNyabela ===

* UMtjongweni (uSomphezeni) oliDugu noyindondana ekulu

* UMofu (uSoSenzeni) oliPhogo
* UNgobe oliDuba
* UMpepe (uSovelemu) oliDlowu
* UMzitha (uSoMene) oliSinya
* UMakhabakhubu (uSovusani) oliPhogo
* UPama (uSoMvumazoke) liRhorha
* UZalabo (uSoMlingo) oliDuba
* UMarhagi (uSoZilani) oliRhorha&lt;ref name=&quot;:0&quot; /&gt;

== Isisusa Serarano Phakathi KukaNyabela NamaBhuru ==
[[Isimumathi:LL1882 pg008 SIKUKUNI.jpg|thumb|USekhukhune]]
Ngesikhathi sokubusa kukaNyabela amaBhuru besele athomile ukuzibusa ngombana bebangasekho ngaphasi kokubuswa maNgisi. Yeke, besele kuphethe bona, begodu bebenza koke okusemandlenabo bona balawule iintjhaba zabantu abanzima enarheni khona bazokubusa ngendlela ephumelelako.&lt;ref name=&quot;:1&quot;&gt;{{Cite web|title=South African Military History Society - Journal - AN AFRICAN MASADA: Nyabela, Mampuru and the Defence of Mapochstad|url=http://samilitaryhistory.org/vol144ds.html|access-date=2025-05-31|website=samilitaryhistory.org}}&lt;/ref&gt; Soke isikhathesi amaBhuru namaNdebele wakwaNzunza bekatjhebiswano elihle elathonywa yiNgwenyama uMabhoko. Kodwana kwathi bona amaBhuru athome ukuzibusa itjhebiswano laya lancipha. Isizathu kungaba kukuthi amaNdebele nawo besele afuna ukuzibusa,  UNyabela besele angasawubhadeli umthelo emaBhurwini, begodu wala nokuletha isibalo sabantu baboke esitjhabeni.begodu lokho kwawasilinga amaBhuru ngaphasi kombuso we-ZAR.&lt;ref name=&quot;:1&quot; /&gt;

Isisusa esikhulu serarano phakathi kwamaNdebele namaBhuru kwaba nguMampuru. UMampuru bekayikosi yabaPedi eyabelethwa ngo-1824, ayindodana yomnakwabo weKosi uSikwati. USikwati wahlongakala ngo-1861. Lokho kwabanta imiraro yokuthi ngubani okufuze alandele ekubeni yiKosi yabaPedi. &lt;ref name=&quot;:2&quot;&gt;{{Cite web|title=Kgoŝi Mampuru II – King of the Pedi people {{!}} Ditsong Museums of South Africa|url=https://ditsong.org.za/en/kgosi-mampuru-ii-king-of-the-pedi-people/|access-date=2025-05-31|website=https://ditsong.org.za/en/|language=en-US}}&lt;/ref&gt; UMampuru wathi uSikwati ukhethe yena bona abe yiKosi ngombana ubelethwa mfazi obeletha ubukhosi abaPedi abambiza bona yi-''timamollo.'' USekhukhune oyindodana ekulu kaSikwati wathi lokho angekhe kwenzeke njengombana unina kaMampuru omfazi obeletha ubukhosi ukakakhuleliswa yiKosi uSikwati, kodwana mumuntu wangaphandle. Ngaphezu kwalokho wathi uSikwati ubengakaphethi koke okufuze akuphethe nakathatha umfazi oyi-''timamollo''. Yeke isihlalo kufuze sithathwe nguSekhukhune.&lt;ref&gt;https://en.wikipedia.org/wiki/Mampuru_II&lt;/ref&gt;
USekhukhune wathoma wathatha amandla wobukhosi bewabulala nabeluleki bakaMampuru. UMampuru wagcina sele abalekile kelekhabo. Kwathi ngemva kwesikhathi uSekhukhune sele alwe ipi namaBhuru, nenye ipi namaSwati, wahlaselwa esigodlweni sakhe wahlatjwa ngomukhwa wafa ngomhlaka-13 August 1882. UMampuru nguye owasolwa ngokubulawa kukaSekhukhune, wasolwa nangokubanga umguruguru esitjhabeni sabaPedi. Yeke amaBhuru akhipha isiqunto sokuthi uMampuru akabotjhwe khona umguruguru lo uzokuphela.&lt;ref name=&quot;:2&quot; /&gt;[[Isimumathi:Stephanus Johannes Roos.jpg|thumb|UJohannes Roos]]Kuthe bona uMampuru ezwe bona uyafuneka wabaleka esitjhabeni sekabo wayokukhosela ebantwini bakwaMasimula. AbaPedi bamlandelela nalapho babawa ikosi yakwaMasimula bona ibanikele yena, kodwana yona yala. Kwaba nepi, abakwaMasimula bahlulwa epini leyo. UMampuru nakabona bonyana bakwaMasimula bahluliwe, wabalekela kwaNomtjherhelo eNgwenyameni uNyabela. &lt;ref name=&quot;:0&quot; /&gt;

AbaPedi bafika nakoNomtjharhelo bambawa eNgwenyameni uNyabela. Kuthiwa iKosi uNyabela yathi nayibaphendulako: &quot;UMampuru ngimginyile. Nanimfunako izani ningihlinze isisu nimkhuphe.&quot; Okutjho bona nangabe abaPedi bafuna uMampuru kuzokufuze kuliwe ipi bona atholakale. AbaPedi bakhamba batjhinga emBhurwini babawa isizo lokuthola uMampuru. UPaul Kruger obekamungameli we-ZAR, wathumela uRoos noSenekal bona basize abaPedi ngendaba le. AmaBhuru amabili la afika esitjhabeni samaNdebele abawa uMampuru, kodwana uNyabela wala, wathi umginyile, nabamfunako abamkhuphe ngemathunjinakhe. Ekugcineni uNyabela wasilingeka wabulala uRoos noSenekal, wathatha iinhloko zabo wazihloma eengodweni. Kuthiwa bekavuka qobe ekuseni akhambe ayokulotjhisa iinhloko zabo aziphulule neendevu zazo.&lt;ref name=&quot;:0&quot; /&gt; 

AmaBhuru asilingeka khulu ngesenzwesi athumela uPiet Joubert namasotja amanengi. Naye wafika warabhela uNyabela amahlandla ambalwa bona akhuphe uMaMpuru kodwana uNyabela wabhala naye, kwaba kusuka kwepi phakathi kwamaNdebele namaBhuru.&lt;ref name=&quot;:1&quot; /&gt;

== Ukuthoma Kwepi YamaNdebele NamaBhuru ==
[[Isimumathi:Pjjoubert.jpg|thumb|UPiet Joubert]]
Ipi yathoma ngomhlaka-7 kuSinyikhaba 1882. Ipi yamaNdebele yayihlome ngeengidi zomsizi nemikhonto, bese yamaBhuru ihlome ngeengidi zeenhlamvu idoswa phambili nguPiet Joubert. Iingidi zeenhlamvu bezidumuza msinya kunalezo zomsizi, yeke inengi lamabutho wamaNdebele lafa ngelangelo, kwathi ngemva kwalokho amaNdebele ahlehla abalekela erholweni. AmaBhuru athi ayangena erholweni abuyela emva ngombana irholo awalazi, yeke atjhida entabeni ayokuhlala emasimini. &lt;ref name=&quot;:0&quot; /&gt; Emalangeni alandelako bebasolo basilwa, kesinye isikhathi amaNdebele afike kungakalindeleki agadle abaleke. Kesinye isikhathi bekafika ebe iinkomo zamakhuwa, kesinye isikhathi babanjwe babulawe. Kwakhe kwaba nesahlakalo lapha amaNdebele athumba iinkomo zamaBhuru, kanti amaBhuru awakalali, abagijimisa abulala amaNdebele ali-150, babuya neenkomo zabo.&lt;ref name=&quot;:1&quot; /&gt;

Isikhathi nasikhambako yahlasela indlala emaNdebeleni. Ukudla ebebakubulungile kwaphela, bathoma ukudla iimphalo eenkhunjeni, kodwana ngokukhamba kwesikhathi iimphalo nazo zaphela. Bathoma bafikelwa mcabango wokuzinikela emaBhurwini, ngapha amaBhuru sebacabanga ukukhamba babuyele emakhaya ngombana sebafikelwa kudinwa. AmaNdebele eza namano wokuthola ukudla.&lt;ref name=&quot;:0&quot; /&gt; Kwakhitjhwa intanga yamaThula bona iyokuthumba iinkomo zabaPedi. Ngebanga lokuthi bebanganamandla ngebanga lokulamba bahlulwa epini leyo.

Kunesikhathi lapha amaNdebele athi akhukhuthisa abafazi bona bayokweba ukudla, kodwana amaBhuru wababulala abafazabo. Kuthiwa abafazaba bakwaMatsitsi, uNoMtjhatjhana noNoMgiyelwa.  Ngesikhatheso bekusolo kuliwa. Kokhunye amaBhuru alinge ukwemba amadwala afuna indlela yokungena erholweni, kodwana amaNzunza afike abahlasele abaliye, nabo bagcine sele bawunghalile umsebenzi loyo. &lt;ref name=&quot;:1&quot; /&gt;

Kwafika isikhathi lapha amaBhuru abuyela khona emva. Athe angakayi nokuyaphi, asemlanjeni iMangwana kwafika indoda yakwaNdala yatjela amaBhuru bona amaNdebele aphelile yindlala, neemphalo nazo ziphelile. AmaBhuru wajika wabulyela emva kwaNomtjharhelo. Bafika batjela iNgwenyama bona ayikhuphe uMampuru. Nangambala yamkhupha yamnikela emaBhurwini ngomhlaka-19 kaNobayeni 1883. Ipi le yathatha pheze umnyaka woke. Babotjhwa bobabili uNyabela noMampuru.

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>e80kz1kthk3l5fzwv4qab28zf193er8</sha1>
    </revision>
    <revision>
      <id>2880</id>
      <parentid>2879</parentid>
      <timestamp>2025-06-01T08:33:46Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <origin>2880</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8089" sha1="q1th741w06pd0y1d0rlq8jx6r1t3x9l" xml:space="preserve">[[Isimumathi:King Nyabela of the Ndebele Tribe South Africa 1893.jpg|thumb|Ilitje Lesikhumbuzo leNgwenyama uNyabela]]
'''UNyabela''' yiNgwenyama yamaNdebele wakwaNzunza  eyabusa kusukela ngenyanga kaVelabahlinze 1879 nakukhothama iNgwenyama uRhobongo, walwa ipi namaBhuru eyathoma ngomhlaka-07 kaSinyikhaba 1882 eyaphela ngomhlaka-08 kaVelabahlinze 1883 mhla anikela Mampuru emaBhurwini, kwaba kubotjhwa kwakhe nokuhluleka kwepi yamaNdebele emaBhurwini.&lt;ref name=&quot;:0&quot;&gt;Iziko Lamakhosi - C. J Mahlangu, K. N Mahlangu, M. A Mahlangu, no-S. M Mtshweni&lt;/ref&gt; 

Ngokwencwadi ethi '''Iziko lamaKhosi''', uNyabela  - uGijamphezeni kaMabhoko - yindodana yesithathu yeNgwenyama uMabhoko ebelethwa endlukulu. Kwathi bona kukhothame iNgwenyama uRhobongo ebeyibambele uFene, uNyabela wathatha isihlalo  waraga nokubambela uFene indodana kaMkhephuli ngombana bekasesemncani bona angabusa. Nayiragako ithi ekuthomeni kokubusa kwakhe uNyabela wayenganayo ingubo yobukhosi. Yeke wakhupha intanga yamaDlaza bona iyokufuna ingwe khona kuzokutholakala isikhumba esizokuba yingubo yobukhosi. Owayethwele intanga yamaDlaza ibizo lakhe kwakunguNomacwayi. Bagcina Bayifumene ingwe entabeni yakwaCabha, bayibulala beza nayo ekosini. &lt;ref name=&quot;:0&quot; /&gt;

=== Amadodana weNgwenyama uNyabela ===

* UMtjongweni (uSomphezeni) oliDugu noyindondana ekulu

* UMofu (uSoSenzeni) oliPhogo
* UNgobe oliDuba
* UMpepe (uSovelemu) oliDlowu
* UMzitha (uSoMene) oliSinya
* UMakhabakhubu (uSovusani) oliPhogo
* UPama (uSoMvumazoke) liRhorha
* UZalabo (uSoMlingo) oliDuba
* UMarhagi (uSoZilani) oliRhorha&lt;ref name=&quot;:0&quot; /&gt;

== Isisusa Serarano Phakathi KukaNyabela NamaBhuru ==
[[Isimumathi:LL1882 pg008 SIKUKUNI.jpg|thumb|USekhukhune]]
Ngesikhathi sokubusa kukaNyabela amaBhuru besele athomile ukuzibusa ngombana bebangasekho ngaphasi kokubuswa maNgisi. Yeke, besele kuphethe bona, begodu bebenza koke okusemandlenabo bona balawule iintjhaba zabantu abanzima enarheni khona bazokubusa ngendlela ephumelelako.&lt;ref name=&quot;:1&quot;&gt;{{Cite web|title=South African Military History Society - Journal - AN AFRICAN MASADA: Nyabela, Mampuru and the Defence of Mapochstad|url=http://samilitaryhistory.org/vol144ds.html|access-date=2025-05-31|website=samilitaryhistory.org}}&lt;/ref&gt; Soke isikhathesi amaBhuru namaNdebele wakwaNzunza bekatjhebiswano elihle elathonywa yiNgwenyama uMabhoko. Kodwana kwathi bona amaBhuru athome ukuzibusa itjhebiswano laya lancipha. Isizathu kungaba kukuthi amaNdebele nawo besele afuna ukuzibusa,  UNyabela besele angasawubhadeli umthelo emaBhurwini, begodu wala nokuletha isibalo sabantu baboke esitjhabeni.begodu lokho kwawasilinga amaBhuru ngaphasi kombuso we-ZAR.&lt;ref name=&quot;:1&quot; /&gt;

Isisusa esikhulu serarano phakathi kwamaNdebele namaBhuru kwaba nguMampuru. UMampuru bekayikosi yabaPedi eyabelethwa ngo-1824, ayindodana yomnakwabo weKosi uSikwati. USikwati wahlongakala ngo-1861. Lokho kwabanta imiraro yokuthi ngubani okufuze alandele ekubeni yiKosi yabaPedi. &lt;ref name=&quot;:2&quot;&gt;{{Cite web|title=Kgoŝi Mampuru II – King of the Pedi people {{!}} Ditsong Museums of South Africa|url=https://ditsong.org.za/en/kgosi-mampuru-ii-king-of-the-pedi-people/|access-date=2025-05-31|website=https://ditsong.org.za/en/|language=en-US}}&lt;/ref&gt; UMampuru wathi uSikwati ukhethe yena bona abe yiKosi ngombana ubelethwa mfazi obeletha ubukhosi abaPedi abambiza bona yi-''timamollo.'' USekhukhune oyindodana ekulu kaSikwati wathi lokho angekhe kwenzeke njengombana unina kaMampuru omfazi obeletha ubukhosi ukakakhuleliswa yiKosi uSikwati, kodwana mumuntu wangaphandle. Ngaphezu kwalokho wathi uSikwati ubengakaphethi koke okufuze akuphethe nakathatha umfazi oyi-''timamollo''. Yeke isihlalo kufuze sithathwe nguSekhukhune.&lt;ref&gt;https://en.wikipedia.org/wiki/Mampuru_II&lt;/ref&gt;
USekhukhune wathoma wathatha amandla wobukhosi bewabulala nabeluleki bakaMampuru. UMampuru wagcina sele abalekile kelekhabo. Kwathi ngemva kwesikhathi uSekhukhune sele alwe ipi namaBhuru, nenye ipi namaSwati, wahlaselwa esigodlweni sakhe wahlatjwa ngomukhwa wafa ngomhlaka-13 August 1882. UMampuru nguye owasolwa ngokubulawa kukaSekhukhune, wasolwa nangokubanga umguruguru esitjhabeni sabaPedi. Yeke amaBhuru akhipha isiqunto sokuthi uMampuru akabotjhwe khona umguruguru lo uzokuphela.&lt;ref name=&quot;:2&quot; /&gt;[[Isimumathi:Stephanus Johannes Roos.jpg|thumb|UJohannes Roos]]Kuthe bona uMampuru ezwe bona uyafuneka wabaleka esitjhabeni sekabo wayokukhosela ebantwini bakwaMasimula. AbaPedi bamlandelela nalapho babawa ikosi yakwaMasimula bona ibanikele yena, kodwana yona yala. Kwaba nepi, abakwaMasimula bahlulwa epini leyo. UMampuru nakabona bonyana bakwaMasimula bahluliwe, wabalekela kwaNomtjherhelo eNgwenyameni uNyabela. &lt;ref name=&quot;:0&quot; /&gt;

AbaPedi bafika nakoNomtjharhelo bambawa eNgwenyameni uNyabela. Kuthiwa iKosi uNyabela yathi nayibaphendulako: &quot;UMampuru ngimginyile. Nanimfunako izani ningihlinze isisu nimkhuphe.&quot; Okutjho bona nangabe abaPedi bafuna uMampuru kuzokufuze kuliwe ipi bona atholakale. AbaPedi bakhamba batjhinga emBhurwini babawa isizo lokuthola uMampuru. UPaul Kruger obekamungameli we-ZAR, wathumela uRoos noSenekal bona basize abaPedi ngendaba le. AmaBhuru amabili la afika esitjhabeni samaNdebele abawa uMampuru, kodwana uNyabela wala, wathi umginyile, nabamfunako abamkhuphe ngemathunjinakhe. Ekugcineni uNyabela wasilingeka wabulala uRoos noSenekal, wathatha iinhloko zabo wazihloma eengodweni. Kuthiwa bekavuka qobe ekuseni akhambe ayokulotjhisa iinhloko zabo aziphulule neendevu zazo.&lt;ref name=&quot;:0&quot; /&gt; 

AmaBhuru asilingeka khulu ngesenzwesi athumela uPiet Joubert namasotja amanengi. Naye wafika warabhela uNyabela amahlandla ambalwa bona akhuphe uMaMpuru kodwana uNyabela wabhala naye, kwaba kusuka kwepi phakathi kwamaNdebele namaBhuru.&lt;ref name=&quot;:1&quot; /&gt;

== Ukuthoma Kwepi YamaNdebele NamaBhuru ==
[[Isimumathi:Pjjoubert.jpg|thumb|UPiet Joubert]]
Ipi yathoma ngomhlaka-7 kuSinyikhaba 1882. Ipi yamaNdebele yayihlome ngeengidi zomsizi nemikhonto, bese yamaBhuru ihlome ngeengidi zeenhlamvu idoswa phambili nguPiet Joubert. Iingidi zeenhlamvu bezidumuza msinya kunalezo zomsizi, yeke inengi lamabutho wamaNdebele lafa ngelangelo, kwathi ngemva kwalokho amaNdebele ahlehla abalekela erholweni. AmaBhuru athi ayangena erholweni abuyela emva ngombana irholo awalazi, yeke atjhida entabeni ayokuhlala emasimini. &lt;ref name=&quot;:0&quot; /&gt; Emalangeni alandelako bebasolo basilwa, kesinye isikhathi amaNdebele afike kungakalindeleki agadle abaleke. Kesinye isikhathi bekafika ebe iinkomo zamakhuwa, kesinye isikhathi babanjwe babulawe. Kwakhe kwaba nesahlakalo lapha amaNdebele athumba iinkomo zamaBhuru, kanti amaBhuru awakalali, abagijimisa abulala amaNdebele ali-150, babuya neenkomo zabo.&lt;ref name=&quot;:1&quot; /&gt;

Isikhathi nasikhambako yahlasela indlala emaNdebeleni. Ukudla ebebakubulungile kwaphela, bathoma ukudla iimphalo eenkhunjeni, kodwana ngokukhamba kwesikhathi iimphalo nazo zaphela. Bathoma bafikelwa mcabango wokuzinikela emaBhurwini, ngapha amaBhuru sebacabanga ukukhamba babuyele emakhaya ngombana sebafikelwa kudinwa. AmaNdebele eza namano wokuthola ukudla.&lt;ref name=&quot;:0&quot; /&gt; Kwakhitjhwa intanga yamaThula bona iyokuthumba iinkomo zabaPedi. Ngebanga lokuthi bebanganamandla ngebanga lokulamba bahlulwa epini leyo.

Kunesikhathi lapha amaNdebele athi akhukhuthisa abafazi bona bayokweba ukudla, kodwana amaBhuru wababulala abafazabo. Kuthiwa abafazaba bakwaMatsitsi, uNoMtjhatjhana noNoMgiyelwa.  Ngesikhatheso bekusolo kuliwa. Kokhunye amaBhuru alinge ukwemba amadwala afuna indlela yokungena erholweni, kodwana amaNzunza afike abahlasele abaliye, nabo bagcine sele bawunghalile umsebenzi loyo. &lt;ref name=&quot;:1&quot; /&gt;

Kwafika isikhathi lapha amaBhuru abuyela khona emva. Athe angakayi nokuyaphi, asemlanjeni iMangwana kwafika indoda yakwaNdala yatjela amaBhuru bona amaNdebele aphelile yindlala, neemphalo nazo ziphelile. AmaBhuru wajika wabulyela emva kwaNomtjharhelo. Bafika batjela iNgwenyama bona ayikhuphe uMampuru. Nangambala yamkhupha yamnikela emaBhurwini ngomhlaka-08 kaVelabahlinze 1883. Ipi le yathatha iinyanga ezibunane zoke. Babotjhwa bobabili uNyabela noMampuru.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>q1th741w06pd0y1d0rlq8jx6r1t3x9l</sha1>
    </revision>
    <revision>
      <id>2881</id>
      <parentid>2880</parentid>
      <timestamp>2025-06-01T08:34:56Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <origin>2881</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8088" sha1="9aa7a29wqzwrirdkqftv1je0472ea0n" xml:space="preserve">[[Isimumathi:King Nyabela of the Ndebele Tribe South Africa 1893.jpg|thumb|Ilitje Lesikhumbuzo leNgwenyama uNyabela]]
'''UNyabela''' yiNgwenyama yamaNdebele wakwaNzunza  eyabusa kusukela ngenyanga kaVelabahlinze 1879 nakukhothama iNgwenyama uRhobongo, walwa ipi namaBhuru eyathoma ngomhlaka-07 kaSinyikhaba 1882 eyaphela ngomhlaka-08 kaVelabahlinze 1883 mhla anikela Mampuru emaBhurwini, kwaba kubotjhwa kwakhe nokuhluleka kwepi yamaNdebele emaBhurwini.&lt;ref name=&quot;:0&quot;&gt;Iziko Lamakhosi - C. J Mahlangu, K. N Mahlangu, M. A Mahlangu, no-S. M Mtshweni&lt;/ref&gt; 

Ngokwencwadi ethi '''Iziko lamaKhosi''', uNyabela  - uGijamphezeni kaMabhoko - yindodana yesithathu yeNgwenyama uMabhoko ebelethwa endlukulu. Kwathi bona kukhothame iNgwenyama uRhobongo ebeyibambele uFene, uNyabela wathatha isihlalo  waraga nokubambela uFene indodana kaMkhephuli ngombana bekasesemncani bona angabusa. Nayiragako ithi ekuthomeni kokubusa kwakhe uNyabela wayenganayo ingubo yobukhosi. Yeke wakhupha intanga yamaDlaza bona iyokufuna ingwe khona kuzokutholakala isikhumba esizokuba yingubo yobukhosi. Owayethwele intanga yamaDlaza ibizo lakhe kwakunguNomacwayi. Bagcina Bayifumene ingwe entabeni yakwaCabha, bayibulala beza nayo ekosini. &lt;ref name=&quot;:0&quot; /&gt;

=== Amadodana weNgwenyama uNyabela ===

* UMtjongweni (uSomphezeni) oliDugu noyindondana ekulu

* UMofu (uSoSenzeni) oliPhogo
* UNgobe oliDuba
* UMpepe (uSovelemu) oliDlowu
* UMzitha (uSoMene) oliSinya
* UMakhabakhubu (uSovusani) oliPhogo
* UPama (uSoMvumazoke) liRhorha
* UZalabo (uSoMlingo) oliDuba
* UMarhagi (uSoZilani) oliRhorha&lt;ref name=&quot;:0&quot; /&gt;

== Isisusa Serarano Phakathi KukaNyabela NamaBhuru ==
[[Isimumathi:LL1882 pg008 SIKUKUNI.jpg|thumb|USekhukhune]]
Ngesikhathi sokubusa kukaNyabela amaBhuru besele athomile ukuzibusa ngombana bebangasekho ngaphasi kokubuswa maNgisi. Yeke, besele kuphethe bona, begodu bebenza koke okusemandlenabo bona balawule iintjhaba zabantu abanzima enarheni khona bazokubusa ngendlela ephumelelako.&lt;ref name=&quot;:1&quot;&gt;{{Cite web|title=South African Military History Society - Journal - AN AFRICAN MASADA: Nyabela, Mampuru and the Defence of Mapochstad|url=http://samilitaryhistory.org/vol144ds.html|access-date=2025-05-31|website=samilitaryhistory.org}}&lt;/ref&gt; Soke isikhathesi amaBhuru namaNdebele wakwaNzunza bekatjhebiswano elihle elathonywa yiNgwenyama uMabhoko. Kodwana kwathi bona amaBhuru athome ukuzibusa itjhebiswano laya lancipha. Isizathu kungaba kukuthi amaNdebele nawo besele afuna ukuzibusa,  UNyabela besele angasawubhadeli umthelo emaBhurwini, begodu wala nokuletha isibalo sabantu baboke esitjhabeni.begodu lokho kwawasilinga amaBhuru ngaphasi kombuso we-ZAR.&lt;ref name=&quot;:1&quot; /&gt;

Isisusa esikhulu serarano phakathi kwamaNdebele namaBhuru kwaba nguMampuru. UMampuru bekayikosi yabaPedi eyabelethwa ngo-1824, ayindodana yomnakwabo weKosi uSikwati. USikwati wahlongakala ngo-1861. Lokho kwabanta imiraro yokuthi ngubani okufuze alandele ekubeni yiKosi yabaPedi. &lt;ref name=&quot;:2&quot;&gt;{{Cite web|title=Kgoŝi Mampuru II – King of the Pedi people {{!}} Ditsong Museums of South Africa|url=https://ditsong.org.za/en/kgosi-mampuru-ii-king-of-the-pedi-people/|access-date=2025-05-31|website=https://ditsong.org.za/en/|language=en-US}}&lt;/ref&gt; UMampuru wathi uSikwati ukhethe yena bona abe yiKosi ngombana ubelethwa mfazi obeletha ubukhosi abaPedi abambiza bona yi-''timamollo.'' USekhukhune oyindodana ekulu kaSikwati wathi lokho angekhe kwenzeke njengombana unina kaMampuru omfazi obeletha ubukhosi ukakakhuleliswa yiKosi uSikwati, kodwana mumuntu wangaphandle. Ngaphezu kwalokho wathi uSikwati ubengakaphethi koke okufuze akuphethe nakathatha umfazi oyi-''timamollo''. Yeke isihlalo kufuze sithathwe nguSekhukhune.&lt;ref&gt;https://en.wikipedia.org/wiki/Mampuru_II&lt;/ref&gt;
USekhukhune wathoma wathatha amandla wobukhosi bewabulala nabeluleki bakaMampuru. UMampuru wagcina sele abalekile kelekhabo. Kwathi ngemva kwesikhathi uSekhukhune sele alwe ipi namaBhuru, nenye ipi namaSwati, wahlaselwa esigodlweni sakhe wahlatjwa ngomukhwa wafa ngomhlaka-13 August 1882. UMampuru nguye owasolwa ngokubulawa kukaSekhukhune, wasolwa nangokubanga umguruguru esitjhabeni sabaPedi. Yeke amaBhuru akhipha isiqunto sokuthi uMampuru akabotjhwe khona umguruguru lo uzokuphela.&lt;ref name=&quot;:2&quot; /&gt;[[Isimumathi:Stephanus Johannes Roos.jpg|thumb|UJohannes Roos]]Kuthe bona uMampuru ezwe bona uyafuneka wabaleka esitjhabeni sekabo wayokukhosela ebantwini bakwaMasimula. AbaPedi bamlandelela nalapho babawa ikosi yakwaMasimula bona ibanikele yena, kodwana yona yala. Kwaba nepi, abakwaMasimula bahlulwa epini leyo. UMampuru nakabona bonyana bakwaMasimula bahluliwe, wabalekela kwaNomtjherhelo eNgwenyameni uNyabela. &lt;ref name=&quot;:0&quot; /&gt;

AbaPedi bafika nakoNomtjharhelo bambawa eNgwenyameni uNyabela. Kuthiwa iKosi uNyabela yathi nayibaphendulako: &quot;UMampuru ngimginyile. Nanimfunako izani ningihlinze isisu nimkhuphe.&quot; Okutjho bona nangabe abaPedi bafuna uMampuru kuzokufuze kuliwe ipi bona atholakale. AbaPedi bakhamba batjhinga emBhurwini babawa isizo lokuthola uMampuru. UPaul Kruger obekamungameli we-ZAR, wathumela uRoos noSenekal bona basize abaPedi ngendaba le. AmaBhuru amabili la afika esitjhabeni samaNdebele abawa uMampuru, kodwana uNyabela wala, wathi umginyile, nabamfunako abamkhuphe ngemathunjinakhe. Ekugcineni uNyabela wasilingeka wabulala uRoos noSenekal, wathatha iinhloko zabo wazihloma eengodweni. Kuthiwa bekavuka qobe ekuseni akhambe ayokulotjhisa iinhloko zabo aziphulule neendevu zazo.&lt;ref name=&quot;:0&quot; /&gt; 

AmaBhuru asilingeka khulu ngesenzwesi athumela uPiet Joubert namasotja amanengi. Naye wafika warabhela uNyabela amahlandla ambalwa bona akhuphe uMaMpuru kodwana uNyabela wabhala naye, kwaba kusuka kwepi phakathi kwamaNdebele namaBhuru.&lt;ref name=&quot;:1&quot; /&gt;

== Ukuthoma Kwepi YamaNdebele NamaBhuru ==
[[Isimumathi:Pjjoubert.jpg|thumb|UPiet Joubert]]
Ipi yathoma ngomhlaka-7 kuSinyikhaba 1882. Ipi yamaNdebele yayihlome ngeengidi zomsizi nemikhonto, bese yamaBhuru ihlome ngeengidi zeenhlamvu idoswa phambili nguPiet Joubert. Iingidi zeenhlamvu bezidumuza msinya kunalezo zomsizi, yeke inengi lamabutho wamaNdebele lafa ngelangelo, kwathi ngemva kwalokho amaNdebele ahlehla abalekela erholweni. AmaBhuru athi ayangena erholweni abuyela emva ngombana irholo awalazi, yeke atjhida entabeni ayokuhlala emasimini. &lt;ref name=&quot;:0&quot; /&gt; Emalangeni alandelako bebasolo basilwa, kesinye isikhathi amaNdebele afike kungakalindeleki agadle abaleke. Kesinye isikhathi bekafika ebe iinkomo zamakhuwa, kesinye isikhathi babanjwe babulawe. Kwakhe kwaba nesahlakalo lapha amaNdebele athumba iinkomo zamaBhuru, kanti amaBhuru awakalali, abagijimisa abulala amaNdebele ali-150, babuya neenkomo zabo.&lt;ref name=&quot;:1&quot; /&gt;

Isikhathi nasikhambako yahlasela indlala emaNdebeleni. Ukudla ebebakubulungile kwaphela, bathoma ukudla iimphalo eenkhunjeni, kodwana ngokukhamba kwesikhathi iimphalo nazo zaphela. Bathoma bafikelwa mcabango wokuzinikela emaBhurwini, ngapha amaBhuru sebacabanga ukukhamba babuyele emakhaya ngombana sebafikelwa kudinwa. AmaNdebele eza namano wokuthola ukudla.&lt;ref name=&quot;:0&quot; /&gt; Kwakhitjhwa intanga yamaThula bona iyokuthumba iinkomo zabaPedi. Ngebanga lokuthi bebanganamandla ngebanga lokulamba bahlulwa epini leyo.

Kunesikhathi lapha amaNdebele athi akhukhuthisa abafazi bona bayokweba ukudla, kodwana amaBhuru wababulala abafazabo. Kuthiwa abafazaba bakwaMatsitsi, uNoMtjhatjhana noNoMgiyelwa.  Ngesikhatheso bekusolo kuliwa. Kokhunye amaBhuru alinge ukwemba amadwala afuna indlela yokungena erholweni, kodwana amaNzunza afike abahlasele abaliye, nabo bagcine sele bawunghalile umsebenzi loyo. &lt;ref name=&quot;:1&quot; /&gt;

Kwafika isikhathi lapha amaBhuru abuyela khona emva. Athe angakayi nokuyaphi, asemlanjeni iMangwana kwafika indoda yakwaNdala yatjela amaBhuru bona amaNdebele aphelile yindlala, neemphalo nazo ziphelile. AmaBhuru wajika wabuyela emva kwaNomtjharhelo. Bafika batjela iNgwenyama bona ayikhuphe uMampuru. Nangambala yamkhupha yamnikela emaBhurwini ngomhlaka-08 kaVelabahlinze 1883. Ipi le yathatha iinyanga ezibunane zoke. Babotjhwa bobabili uNyabela noMampuru.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>9aa7a29wqzwrirdkqftv1je0472ea0n</sha1>
    </revision>
    <revision>
      <id>3154</id>
      <parentid>2881</parentid>
      <timestamp>2025-06-13T17:45:43Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>3154</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8089" sha1="gzibvc634a4e2yf9lf47z2lmfv22vvo" xml:space="preserve">[[Isimumathi:King Nyabela of the Ndebele Tribe South Africa 1893.jpg|thumb|Ilitje Lesikhumbuzo leNgwenyama uNyabela]]
'''UNyabela''' yiNgwenyama yamaNdebele wakwaNzunza  eyabusa kusukela ngenyanga kaVelabahlinze 1879 nakukhothama iNgwenyama uRhobongo, walwa ipi namaBhuru eyathoma ngomhlaka-07 kaSinyikhaba 1882 eyaphela ngomhlaka-08 kaVelabahlinze 1883 mhla anikela uMampuru emaBhurwini, kwaba kubotjhwa kwakhe nokuhluleka kwepi yamaNdebele emaBhurwini.&lt;ref name=&quot;:0&quot;&gt;Iziko Lamakhosi - C. J Mahlangu, K. N Mahlangu, M. A Mahlangu, no-S. M Mtshweni&lt;/ref&gt; 

Ngokwencwadi ethi '''Iziko lamaKhosi''', uNyabela  - uGijamphezeni kaMabhoko - yindodana yesithathu yeNgwenyama uMabhoko ebelethwa endlukulu. Kwathi bona kukhothame iNgwenyama uRhobongo ebeyibambele uFene, uNyabela wathatha isihlalo  waraga nokubambela uFene indodana kaMkhephuli ngombana bekasesemncani bona angabusa. Nayiragako ithi ekuthomeni kokubusa kwakhe uNyabela wayenganayo ingubo yobukhosi. Yeke wakhupha intanga yamaDlaza bona iyokufuna ingwe khona kuzokutholakala isikhumba esizokuba yingubo yobukhosi. Owayethwele intanga yamaDlaza ibizo lakhe kwakunguNomacwayi. Bagcina Bayifumene ingwe entabeni yakwaCabha, bayibulala beza nayo ekosini. &lt;ref name=&quot;:0&quot; /&gt;

=== Amadodana weNgwenyama uNyabela ===

* UMtjongweni (uSomphezeni) oliDugu noyindondana ekulu

* UMofu (uSoSenzeni) oliPhogo
* UNgobe oliDuba
* UMpepe (uSovelemu) oliDlowu
* UMzitha (uSoMene) oliSinya
* UMakhabakhubu (uSovusani) oliPhogo
* UPama (uSoMvumazoke) liRhorha
* UZalabo (uSoMlingo) oliDuba
* UMarhagi (uSoZilani) oliRhorha&lt;ref name=&quot;:0&quot; /&gt;

== Isisusa Serarano Phakathi KukaNyabela NamaBhuru ==
[[Isimumathi:LL1882 pg008 SIKUKUNI.jpg|thumb|USekhukhune]]
Ngesikhathi sokubusa kukaNyabela amaBhuru besele athomile ukuzibusa ngombana bebangasekho ngaphasi kokubuswa maNgisi. Yeke, besele kuphethe bona, begodu bebenza koke okusemandlenabo bona balawule iintjhaba zabantu abanzima enarheni khona bazokubusa ngendlela ephumelelako.&lt;ref name=&quot;:1&quot;&gt;{{Cite web|title=South African Military History Society - Journal - AN AFRICAN MASADA: Nyabela, Mampuru and the Defence of Mapochstad|url=http://samilitaryhistory.org/vol144ds.html|access-date=2025-05-31|website=samilitaryhistory.org}}&lt;/ref&gt; Soke isikhathesi amaBhuru namaNdebele wakwaNzunza bekatjhebiswano elihle elathonywa yiNgwenyama uMabhoko. Kodwana kwathi bona amaBhuru athome ukuzibusa itjhebiswano laya lancipha. Isizathu kungaba kukuthi amaNdebele nawo besele afuna ukuzibusa,  UNyabela besele angasawubhadeli umthelo emaBhurwini, begodu wala nokuletha isibalo sabantu baboke esitjhabeni.begodu lokho kwawasilinga amaBhuru ngaphasi kombuso we-ZAR.&lt;ref name=&quot;:1&quot; /&gt;

Isisusa esikhulu serarano phakathi kwamaNdebele namaBhuru kwaba nguMampuru. UMampuru bekayikosi yabaPedi eyabelethwa ngo-1824, ayindodana yomnakwabo weKosi uSikwati. USikwati wahlongakala ngo-1861. Lokho kwabanta imiraro yokuthi ngubani okufuze alandele ekubeni yiKosi yabaPedi. &lt;ref name=&quot;:2&quot;&gt;{{Cite web|title=Kgoŝi Mampuru II – King of the Pedi people {{!}} Ditsong Museums of South Africa|url=https://ditsong.org.za/en/kgosi-mampuru-ii-king-of-the-pedi-people/|access-date=2025-05-31|website=https://ditsong.org.za/en/|language=en-US}}&lt;/ref&gt; UMampuru wathi uSikwati ukhethe yena bona abe yiKosi ngombana ubelethwa mfazi obeletha ubukhosi abaPedi abambiza bona yi-''timamollo.'' USekhukhune oyindodana ekulu kaSikwati wathi lokho angekhe kwenzeke njengombana unina kaMampuru omfazi obeletha ubukhosi ukakakhuleliswa yiKosi uSikwati, kodwana mumuntu wangaphandle. Ngaphezu kwalokho wathi uSikwati ubengakaphethi koke okufuze akuphethe nakathatha umfazi oyi-''timamollo''. Yeke isihlalo kufuze sithathwe nguSekhukhune.&lt;ref&gt;https://en.wikipedia.org/wiki/Mampuru_II&lt;/ref&gt;
USekhukhune wathoma wathatha amandla wobukhosi bewabulala nabeluleki bakaMampuru. UMampuru wagcina sele abalekile kelekhabo. Kwathi ngemva kwesikhathi uSekhukhune sele alwe ipi namaBhuru, nenye ipi namaSwati, wahlaselwa esigodlweni sakhe wahlatjwa ngomukhwa wafa ngomhlaka-13 August 1882. UMampuru nguye owasolwa ngokubulawa kukaSekhukhune, wasolwa nangokubanga umguruguru esitjhabeni sabaPedi. Yeke amaBhuru akhipha isiqunto sokuthi uMampuru akabotjhwe khona umguruguru lo uzokuphela.&lt;ref name=&quot;:2&quot; /&gt;[[Isimumathi:Stephanus Johannes Roos.jpg|thumb|UJohannes Roos]]Kuthe bona uMampuru ezwe bona uyafuneka wabaleka esitjhabeni sekabo wayokukhosela ebantwini bakwaMasimula. AbaPedi bamlandelela nalapho babawa ikosi yakwaMasimula bona ibanikele yena, kodwana yona yala. Kwaba nepi, abakwaMasimula bahlulwa epini leyo. UMampuru nakabona bonyana bakwaMasimula bahluliwe, wabalekela kwaNomtjherhelo eNgwenyameni uNyabela. &lt;ref name=&quot;:0&quot; /&gt;

AbaPedi bafika nakoNomtjharhelo bambawa eNgwenyameni uNyabela. Kuthiwa iKosi uNyabela yathi nayibaphendulako: &quot;UMampuru ngimginyile. Nanimfunako izani ningihlinze isisu nimkhuphe.&quot; Okutjho bona nangabe abaPedi bafuna uMampuru kuzokufuze kuliwe ipi bona atholakale. AbaPedi bakhamba batjhinga emBhurwini babawa isizo lokuthola uMampuru. UPaul Kruger obekamungameli we-ZAR, wathumela uRoos noSenekal bona basize abaPedi ngendaba le. AmaBhuru amabili la afika esitjhabeni samaNdebele abawa uMampuru, kodwana uNyabela wala, wathi umginyile, nabamfunako abamkhuphe ngemathunjinakhe. Ekugcineni uNyabela wasilingeka wabulala uRoos noSenekal, wathatha iinhloko zabo wazihloma eengodweni. Kuthiwa bekavuka qobe ekuseni akhambe ayokulotjhisa iinhloko zabo aziphulule neendevu zazo.&lt;ref name=&quot;:0&quot; /&gt; 

AmaBhuru asilingeka khulu ngesenzwesi athumela uPiet Joubert namasotja amanengi. Naye wafika warabhela uNyabela amahlandla ambalwa bona akhuphe uMaMpuru kodwana uNyabela wabhala naye, kwaba kusuka kwepi phakathi kwamaNdebele namaBhuru.&lt;ref name=&quot;:1&quot; /&gt;

== Ukuthoma Kwepi YamaNdebele NamaBhuru ==
[[Isimumathi:Pjjoubert.jpg|thumb|UPiet Joubert]]
Ipi yathoma ngomhlaka-7 kuSinyikhaba 1882. Ipi yamaNdebele yayihlome ngeengidi zomsizi nemikhonto, bese yamaBhuru ihlome ngeengidi zeenhlamvu idoswa phambili nguPiet Joubert. Iingidi zeenhlamvu bezidumuza msinya kunalezo zomsizi, yeke inengi lamabutho wamaNdebele lafa ngelangelo, kwathi ngemva kwalokho amaNdebele ahlehla abalekela erholweni. AmaBhuru athi ayangena erholweni abuyela emva ngombana irholo awalazi, yeke atjhida entabeni ayokuhlala emasimini. &lt;ref name=&quot;:0&quot; /&gt; Emalangeni alandelako bebasolo basilwa, kesinye isikhathi amaNdebele afike kungakalindeleki agadle abaleke. Kesinye isikhathi bekafika ebe iinkomo zamakhuwa, kesinye isikhathi babanjwe babulawe. Kwakhe kwaba nesahlakalo lapha amaNdebele athumba iinkomo zamaBhuru, kanti amaBhuru awakalali, abagijimisa abulala amaNdebele ali-150, babuya neenkomo zabo.&lt;ref name=&quot;:1&quot; /&gt;

Isikhathi nasikhambako yahlasela indlala emaNdebeleni. Ukudla ebebakubulungile kwaphela, bathoma ukudla iimphalo eenkhunjeni, kodwana ngokukhamba kwesikhathi iimphalo nazo zaphela. Bathoma bafikelwa mcabango wokuzinikela emaBhurwini, ngapha amaBhuru sebacabanga ukukhamba babuyele emakhaya ngombana sebafikelwa kudinwa. AmaNdebele eza namano wokuthola ukudla.&lt;ref name=&quot;:0&quot; /&gt; Kwakhitjhwa intanga yamaThula bona iyokuthumba iinkomo zabaPedi. Ngebanga lokuthi bebanganamandla ngebanga lokulamba bahlulwa epini leyo.

Kunesikhathi lapha amaNdebele athi akhukhuthisa abafazi bona bayokweba ukudla, kodwana amaBhuru wababulala abafazabo. Kuthiwa abafazaba bakwaMatsitsi, uNoMtjhatjhana noNoMgiyelwa.  Ngesikhatheso bekusolo kuliwa. Kokhunye amaBhuru alinge ukwemba amadwala afuna indlela yokungena erholweni, kodwana amaNzunza afike abahlasele abaliye, nabo bagcine sele bawunghalile umsebenzi loyo. &lt;ref name=&quot;:1&quot; /&gt;

Kwafika isikhathi lapha amaBhuru abuyela khona emva. Athe angakayi nokuyaphi, asemlanjeni iMangwana kwafika indoda yakwaNdala yatjela amaBhuru bona amaNdebele aphelile yindlala, neemphalo nazo ziphelile. AmaBhuru wajika wabuyela emva kwaNomtjharhelo. Bafika batjela iNgwenyama bona ayikhuphe uMampuru. Nangambala yamkhupha yamnikela emaBhurwini ngomhlaka-08 kaVelabahlinze 1883. Ipi le yathatha iinyanga ezibunane zoke. Babotjhwa bobabili uNyabela noMampuru.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>gzibvc634a4e2yf9lf47z2lmfv22vvo</sha1>
    </revision>
    <revision>
      <id>3155</id>
      <parentid>3154</parentid>
      <timestamp>2025-06-13T18:51:09Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <comment>added paragraphs</comment>
      <origin>3155</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8863" sha1="dosxugejq769y1kv3qo8kbm7no22vh9" xml:space="preserve">[[Isimumathi:King Nyabela of the Ndebele Tribe South Africa 1893.jpg|thumb|Ilitje Lesikhumbuzo leNgwenyama uNyabela]]
'''UNyabela''' yiNgwenyama yamaNdebele wakwaNzunza  eyabusa kusukela ngenyanga kaVelabahlinze 1879 nakukhothama iNgwenyama uRhobongo, walwa ipi namaBhuru eyathoma ngomhlaka-07 kaSinyikhaba 1882 eyaphela ngomhlaka-08 kaVelabahlinze 1883 mhla anikela uMampuru emaBhurwini, kwaba kubotjhwa kwakhe nokuhluleka kwepi yamaNdebele emaBhurwini.&lt;ref name=&quot;:0&quot;&gt;Iziko Lamakhosi - C. J Mahlangu, K. N Mahlangu, M. A Mahlangu, no-S. M Mtshweni&lt;/ref&gt; 

Ngokwencwadi ethi '''Iziko lamaKhosi''', uNyabela  - uGijamphezeni kaMabhoko - yindodana yesithathu yeNgwenyama uMabhoko ebelethwa endlukulu. Kwathi bona kukhothame iNgwenyama uRhobongo ebeyibambele uFene, uNyabela wathatha isihlalo  waraga nokubambela uFene indodana kaMkhephuli ngombana bekasesemncani bona angabusa. Nayiragako ithi ekuthomeni kokubusa kwakhe uNyabela wayenganayo ingubo yobukhosi. Yeke wakhupha intanga yamaDlaza bona iyokufuna ingwe khona kuzokutholakala isikhumba esizokuba yingubo yobukhosi. Owayethwele intanga yamaDlaza ibizo lakhe kwakunguNomacwayi. Bagcina Bayifumene ingwe entabeni yakwaCabha, bayibulala beza nayo ekosini. &lt;ref name=&quot;:0&quot; /&gt;

=== Amadodana weNgwenyama uNyabela ===

* UMtjongweni (uSomphezeni) oliDugu noyindondana ekulu

* UMofu (uSoSenzeni) oliPhogo
* UNgobe oliDuba
* UMpepe (uSovelemu) oliDlowu
* UMzitha (uSoMene) oliSinya
* UMakhabakhubu (uSovusani) oliPhogo
* UPama (uSoMvumazoke) liRhorha
* UZalabo (uSoMlingo) oliDuba
* UMarhagi (uSoZilani) oliRhorha&lt;ref name=&quot;:0&quot; /&gt;

== Isisusa Serarano Phakathi KukaNyabela NamaBhuru ==
[[Isimumathi:LL1882 pg008 SIKUKUNI.jpg|thumb|USekhukhune]]
Ngesikhathi sokubusa kukaNyabela amaBhuru besele athomile ukuzibusa ngombana bebangasekho ngaphasi kokubuswa maNgisi. Yeke, besele kuphethe bona, begodu bebenza koke okusemandlenabo bona balawule iintjhaba zabantu abanzima enarheni khona bazokubusa ngendlela ephumelelako.&lt;ref name=&quot;:1&quot;&gt;{{Cite web|title=South African Military History Society - Journal - AN AFRICAN MASADA: Nyabela, Mampuru and the Defence of Mapochstad|url=http://samilitaryhistory.org/vol144ds.html|access-date=2025-05-31|website=samilitaryhistory.org}}&lt;/ref&gt; Soke isikhathesi amaBhuru namaNdebele wakwaNzunza bekatjhebiswano elihle elathonywa yiNgwenyama uMabhoko. Kodwana kwathi bona amaBhuru athome ukuzibusa itjhebiswano laya lancipha. Isizathu kungaba kukuthi amaNdebele nawo besele afuna ukuzibusa,  UNyabela besele angasawubhadeli umthelo emaBhurwini, begodu wala nokuletha isibalo sabantu baboke esitjhabeni.begodu lokho kwawasilinga amaBhuru ngaphasi kombuso we-ZAR.&lt;ref name=&quot;:1&quot; /&gt;

Isisusa esikhulu serarano phakathi kwamaNdebele namaBhuru kwaba nguMampuru. UMampuru bekayikosi yabaPedi eyabelethwa ngo-1824, ayindodana yomnakwabo weKosi uSikwati. USikwati wahlongakala ngo-1861. Lokho kwabanta imiraro yokuthi ngubani okufuze alandele ekubeni yiKosi yabaPedi. &lt;ref name=&quot;:2&quot;&gt;{{Cite web|title=Kgoŝi Mampuru II – King of the Pedi people {{!}} Ditsong Museums of South Africa|url=https://ditsong.org.za/en/kgosi-mampuru-ii-king-of-the-pedi-people/|access-date=2025-05-31|website=https://ditsong.org.za/en/|language=en-US}}&lt;/ref&gt; UMampuru wathi uSikwati ukhethe yena bona abe yiKosi ngombana ubelethwa mfazi obeletha ubukhosi abaPedi abambiza bona yi-''timamollo.'' USekhukhune oyindodana ekulu kaSikwati wathi lokho angekhe kwenzeke njengombana unina kaMampuru omfazi obeletha ubukhosi ukakakhuleliswa yiKosi uSikwati, kodwana mumuntu wangaphandle. Ngaphezu kwalokho wathi uSikwati ubengakaphethi koke okufuze akuphethe nakathatha umfazi oyi-''timamollo''. Yeke isihlalo kufuze sithathwe nguSekhukhune.&lt;ref&gt;https://en.wikipedia.org/wiki/Mampuru_II&lt;/ref&gt;
USekhukhune wathoma wathatha amandla wobukhosi bewabulala nabeluleki bakaMampuru. UMampuru wagcina sele abalekile kelekhabo. Kwathi ngemva kwesikhathi uSekhukhune sele alwe ipi namaBhuru, nenye ipi namaSwati, wahlaselwa esigodlweni sakhe wahlatjwa ngomukhwa wafa ngomhlaka-13 August 1882. UMampuru nguye owasolwa ngokubulawa kukaSekhukhune, wasolwa nangokubanga umguruguru esitjhabeni sabaPedi. Yeke amaBhuru akhipha isiqunto sokuthi uMampuru akabotjhwe khona umguruguru lo uzokuphela.&lt;ref name=&quot;:2&quot; /&gt;[[Isimumathi:Stephanus Johannes Roos.jpg|thumb|UJohannes Roos]]Kuthe bona uMampuru ezwe bona uyafuneka wabaleka esitjhabeni sekabo wayokukhosela ebantwini bakwaMasimula. AbaPedi bamlandelela nalapho babawa ikosi yakwaMasimula bona ibanikele yena, kodwana yona yala. Kwaba nepi, abakwaMasimula bahlulwa epini leyo. UMampuru nakabona bonyana bakwaMasimula bahluliwe, wabalekela kwaNomtjherhelo eNgwenyameni uNyabela. &lt;ref name=&quot;:0&quot; /&gt;

AbaPedi bafika nakoNomtjharhelo bambawa eNgwenyameni uNyabela. Kuthiwa iKosi uNyabela yathi nayibaphendulako: &quot;UMampuru ngimginyile. Nanimfunako izani ningihlinze isisu nimkhuphe.&quot; Okutjho bona nangabe abaPedi bafuna uMampuru kuzokufuze kuliwe ipi bona atholakale. AbaPedi bakhamba batjhinga emBhurwini babawa isizo lokuthola uMampuru. UPaul Kruger obekamungameli we-ZAR, wathumela uRoos noSenekal bona basize abaPedi ngendaba le. AmaBhuru amabili la afika esitjhabeni samaNdebele abawa uMampuru, kodwana uNyabela wala, wathi umginyile, nabamfunako abamkhuphe ngemathunjinakhe. Ekugcineni uNyabela wasilingeka wabulala uRoos noSenekal, wathatha iinhloko zabo wazihloma eengodweni. Kuthiwa bekavuka qobe ekuseni akhambe ayokulotjhisa iinhloko zabo aziphulule neendevu zazo.&lt;ref name=&quot;:0&quot; /&gt; 

AmaBhuru asilingeka khulu ngesenzwesi athumela uPiet Joubert namasotja amanengi. Naye wafika warabhela uNyabela amahlandla ambalwa bona akhuphe uMaMpuru kodwana uNyabela wabhala naye, kwaba kusuka kwepi phakathi kwamaNdebele namaBhuru.&lt;ref name=&quot;:1&quot; /&gt;

== Ukuthoma Kwepi YamaNdebele NamaBhuru ==
[[Isimumathi:Pjjoubert.jpg|thumb|UPiet Joubert]]
Ipi yathoma ngomhlaka-7 kuSinyikhaba 1882. Ipi yamaNdebele yayihlome ngeengidi zomsizi nemikhonto, bese yamaBhuru ihlome ngeengidi zeenhlamvu idoswa phambili nguPiet Joubert. Iingidi zeenhlamvu bezidumuza msinya kunalezo zomsizi, yeke inengi lamabutho wamaNdebele lafa ngelangelo, kwathi ngemva kwalokho amaNdebele ahlehla abalekela erholweni. AmaBhuru athi ayangena erholweni abuyela emva ngombana irholo awalazi, yeke atjhida entabeni ayokuhlala emasimini. &lt;ref name=&quot;:0&quot; /&gt; Emalangeni alandelako bebasolo basilwa, kesinye isikhathi amaNdebele afike kungakalindeleki agadle abaleke. Kesinye isikhathi bekafika ebe iinkomo zamakhuwa, kesinye isikhathi babanjwe babulawe. Kwakhe kwaba nesahlakalo lapha amaNdebele athumba iinkomo zamaBhuru, kanti amaBhuru awakalali, abagijimisa abulala amaNdebele ali-150, babuya neenkomo zabo.&lt;ref name=&quot;:1&quot; /&gt;

Isikhathi nasikhambako yahlasela indlala emaNdebeleni. Ukudla ebebakubulungile kwaphela, bathoma ukudla iimphalo eenkhunjeni, kodwana ngokukhamba kwesikhathi iimphalo nazo zaphela. Bathoma bafikelwa mcabango wokuzinikela emaBhurwini, ngapha amaBhuru sebacabanga ukukhamba babuyele emakhaya ngombana sebafikelwa kudinwa. AmaNdebele eza namano wokuthola ukudla.&lt;ref name=&quot;:0&quot; /&gt; Kwakhitjhwa intanga yamaThula bona iyokuthumba iinkomo zabaPedi. Ngebanga lokuthi bebanganamandla ngebanga lokulamba bahlulwa epini leyo.

Kunesikhathi lapha amaNdebele athi akhukhuthisa abafazi bona bayokweba ukudla, kodwana amaBhuru wababulala abafazabo. Kuthiwa abafazaba bakwaMatsitsi, uNoMtjhatjhana noNoMgiyelwa.  Ngesikhatheso bekusolo kuliwa. Kokhunye amaBhuru alinge ukwemba amadwala afuna indlela yokungena erholweni, kodwana amaNzunza afike abahlasele abaliye, nabo bagcine sele bawunghalile umsebenzi loyo. &lt;ref name=&quot;:1&quot; /&gt;

Kwafika isikhathi lapha amaBhuru abuyela khona emva. Athe angakayi nokuyaphi, asemlanjeni iMangwana kwafika indoda yakwaNdala yatjela amaBhuru bona amaNdebele aphelile yindlala, neemphalo nazo ziphelile. AmaBhuru wajika wabuyela emva kwaNomtjharhelo. Bafika batjela iNgwenyama bona ayikhuphe uMampuru. Nangambala yamkhupha yamnikela emaBhurwini ngomhlaka-08 kaVelabahlinze 1883. Ipi le yathatha iinyanga ezibunane zoke. Babotjhwa bobabili uNyabela noMampuru.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt; 

== Ukubotjhwa Nokuhlongakala KukaNyabela ==
Kwathi ngemva kobana uNyabela anikele uMampuru kuJoubert nebutho lakhe naye wabotjhwa ngebanga lokujamelana nebutho likaRhulumende wangesikhatheso nokufihla isilelesi. Ngemva kokubotjhwa kwabo isitjhaba sakhutjhwa ngerholweni, satjelwa bona uNyabela akasese yikosi noNyengelele ikosikazakhe akasese yindlovukazi, kunalokho uPiet Joubert uzokuba yikosi yamaNdebele wakwaNzunza bese ikosikazakhe ibe yindlovukazi. Abavumako baphadlhalajwa bahlukaniswa bona bayokuhlala emaplasini wamaBhuru basebenze khona, labo abangavumiko njengoMatsitsi, uPinda, uSigidi, uNdungulu noMhlangula babotjhwa. Abomma basetjenziselwa ukuhlanza iimpahla zamakhuwa, kwathi abobaba belusa ifuyo yamaBhuru, abanye basebenza emasimini. &lt;ref name=&quot;:0&quot; /&gt; 

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>dosxugejq769y1kv3qo8kbm7no22vh9</sha1>
    </revision>
    <revision>
      <id>3229</id>
      <parentid>3155</parentid>
      <timestamp>2025-06-25T20:00:47Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>/* Isisusa Serarano Phakathi KukaNyabela NamaBhuru */ spelling six</comment>
      <origin>3229</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8873" sha1="4qeex6542r2auax5qkex5lb9al1vrz0" xml:space="preserve">[[Isimumathi:King Nyabela of the Ndebele Tribe South Africa 1893.jpg|thumb|Ilitje Lesikhumbuzo leNgwenyama uNyabela]]
'''UNyabela''' yiNgwenyama yamaNdebele wakwaNzunza  eyabusa kusukela ngenyanga kaVelabahlinze 1879 nakukhothama iNgwenyama uRhobongo, walwa ipi namaBhuru eyathoma ngomhlaka-07 kaSinyikhaba 1882 eyaphela ngomhlaka-08 kaVelabahlinze 1883 mhla anikela uMampuru emaBhurwini, kwaba kubotjhwa kwakhe nokuhluleka kwepi yamaNdebele emaBhurwini.&lt;ref name=&quot;:0&quot;&gt;Iziko Lamakhosi - C. J Mahlangu, K. N Mahlangu, M. A Mahlangu, no-S. M Mtshweni&lt;/ref&gt; 

Ngokwencwadi ethi '''Iziko lamaKhosi''', uNyabela  - uGijamphezeni kaMabhoko - yindodana yesithathu yeNgwenyama uMabhoko ebelethwa endlukulu. Kwathi bona kukhothame iNgwenyama uRhobongo ebeyibambele uFene, uNyabela wathatha isihlalo  waraga nokubambela uFene indodana kaMkhephuli ngombana bekasesemncani bona angabusa. Nayiragako ithi ekuthomeni kokubusa kwakhe uNyabela wayenganayo ingubo yobukhosi. Yeke wakhupha intanga yamaDlaza bona iyokufuna ingwe khona kuzokutholakala isikhumba esizokuba yingubo yobukhosi. Owayethwele intanga yamaDlaza ibizo lakhe kwakunguNomacwayi. Bagcina Bayifumene ingwe entabeni yakwaCabha, bayibulala beza nayo ekosini. &lt;ref name=&quot;:0&quot; /&gt;

=== Amadodana weNgwenyama uNyabela ===

* UMtjongweni (uSomphezeni) oliDugu noyindondana ekulu

* UMofu (uSoSenzeni) oliPhogo
* UNgobe oliDuba
* UMpepe (uSovelemu) oliDlowu
* UMzitha (uSoMene) oliSinya
* UMakhabakhubu (uSovusani) oliPhogo
* UPama (uSoMvumazoke) liRhorha
* UZalabo (uSoMlingo) oliDuba
* UMarhagi (uSoZilani) oliRhorha&lt;ref name=&quot;:0&quot; /&gt;

== Isisusa Serarano Phakathi KukaNyabela NamaBhuru ==
[[Isimumathi:LL1882 pg008 SIKUKUNI.jpg|thumb|USekhukhune]]
Ngesikhathi sokubusa kukaNyabela amaBhuru besele athomile ukuzibusa ngombana bebangasekho ngaphasi kokubuswa maNgisi. Yeke, besele kuphethe bona, begodu bebenza koke okusemandlenabo bona balawule iintjhaba zabantu abanzima enarheni khona bazokubusa ngendlela ephumelelako.&lt;ref name=&quot;:1&quot;&gt;{{Cite web|title=South African Military History Society - Journal - AN AFRICAN MASADA: Nyabela, Mampuru and the Defence of Mapochstad|url=http://samilitaryhistory.org/vol144ds.html|access-date=2025-05-31|website=samilitaryhistory.org}}&lt;/ref&gt; Soke isikhathesi amaBhuru namaNdebele wakwaNzunza bekanetjhebiswano elihle elathonywa yiNgwenyama uMabhoko. Kodwana kwathi bona amaBhuru athome ukuzibusa itjhebiswano laya lancipha. Isizathu kungaba kukuthi amaNdebele nawo besele afuna ukuzibusa,  UNyabela ubesele angasawubhadeli umthelo emaBhurwini, begodu wala nokuletha isibalo sabantu baboke esitjhabeni.begodu lokho kwawasilinga amaBhuru ngaphasi kombuso we-ZAR.&lt;ref name=&quot;:1&quot; /&gt;

Isisusa esikhulu serarano phakathi kwamaNdebele namaBhuru kwaba nguMampuru. UMampuru bekayikosana yabaPedi eyabelethwa ngo-1824, ayindodana yomnakwabo weKosi uSikwati. USikwati wahlongakala ngo-1861. Lokho kwabanga umraro yokuthi ngubani okufuze alandele ekubeni yiKosi yabaPedi. &lt;ref name=&quot;:2&quot;&gt;{{Cite web|title=Kgoŝi Mampuru II – King of the Pedi people {{!}} Ditsong Museums of South Africa|url=https://ditsong.org.za/en/kgosi-mampuru-ii-king-of-the-pedi-people/|access-date=2025-05-31|website=https://ditsong.org.za/en/|language=en-US}}&lt;/ref&gt; UMampuru wathi uSikwati ukhethe yena bona abe yiKosi ngombana ubelethwa mfazi obeletha ubukhosi, abaPedi abambiza bona yi-''timamollo.'' U-Sekhukhune oyindodana ekulu kaSikwati wathi lokho angekhe kwenzeke njengombana unina kaMampuru omfazi obeletha ubukhosi ukakakhuleliswa yiKosi uSikwati, kodwana mumuntu wangaphandle. Ngaphezu kwalokho wathi uSikwati ubengakaphethi koke okufuze akuphethe nakathatha umfazi oyi-''timamollo''. Yeke isihlalo kufuze sithathwe nguye.&lt;ref&gt;https://en.wikipedia.org/wiki/Mampuru_II&lt;/ref&gt;
U-Sekhukhune wathoma wathatha amandla wobukhosi bewabulala nabeluleki bakaMampuru. UMampuru wagcina sele abalekile kelekhabo. Kwathi ngemva kwesikhathi u-Sekhukhune sele alwe ipi namaBhuru, nenye ipi namaSwati, wahlaselwa esigodlweni sakhe wahlatjwa ngomukhwa wafa ngomhlaka-13 kaRhoboyi 1882. UMampuru nguye owasolwa ngokubulawa kuka-Sekhukhune, wasolwa nangokubanga umguruguru esitjhabeni sabaPedi. Yeke amaBhuru akhipha isiqunto sokuthi uMampuru akabotjhwe khona umguruguru lo uzokuphela.&lt;ref name=&quot;:2&quot; /&gt;[[Isimumathi:Stephanus Johannes Roos.jpg|thumb|UJohannes Roos]]Kuthe bona uMampuru ezwe bona uyafuneka wabaleka esitjhabeni sekhabo wayokukhosela ebantwini bakwaMasimula. AbaPedi bamlandelela nalapho babawa ikosi yakwaMasimula bona ibanikele yena, kodwana yona yala. Kwaba nepi, abakwaMasimula bahlulwa epini leyo. UMampuru nakabona bonyana bakwaMasimula bahluliwe, wabalekela kwaNomtjharhelo eNgwenyameni uNyabela. &lt;ref name=&quot;:0&quot; /&gt;

AbaPedi bafika nakoNomtjharhelo bambawa eNgwenyameni uNyabela. Kuthiwa iKosi uNyabela yathi nayibaphendulako: &quot;UMampuru ngimginyile. Nanimfunako izani ningihlinze isisu nimkhuphe.&quot; Okutjho bona nangabe abaPedi bafuna uMampuru kuzokufuze kuliwe ipi bona atholakale. AbaPedi bakhamba batjhinga emBhurwini babawa isizo lokuthola uMampuru. U-Paul Kruger obekamungameli we-ZAR, wathumela u-Roos noSenekal bona basize abaPedi ngendaba le. AmaBhuru amabili la afika esitjhabeni samaNdebele abawa uMampuru, kodwana uNyabela wala, wathi umginyile, nabamfunako abamkhuphe ngemathunjinakhe. Ekugcineni uNyabela wasilingeka wabulala u-Roos no-Senekal, wathatha iinhloko zabo wazihloma eengodweni. Kuthiwa bekavuka qobe ekuseni akhambe ayokulotjhisa iinhloko zabo aziphulule neendevu zazo.&lt;ref name=&quot;:0&quot; /&gt; 

AmaBhuru asilingeka khulu ngesenzwesi athumela u-Piet Joubert namasotja amanengi. Naye wafika warabhela uNyabela amahlandla ambalwa bona akhuphe uMaMpuru kodwana uNyabela wabhala naye, kwaba kusuka kwepi phakathi kwamaNdebele namaBhuru.&lt;ref name=&quot;:1&quot; /&gt;

== Ukuthoma Kwepi YamaNdebele NamaBhuru ==
[[Isimumathi:Pjjoubert.jpg|thumb|UPiet Joubert]]
Ipi yathoma ngomhlaka-7 kuSinyikhaba 1882. Ipi yamaNdebele yayihlome ngeengidi zomsizi nemikhonto, bese yamaBhuru ihlome ngeengidi zeenhlamvu idoswa phambili nguPiet Joubert. Iingidi zeenhlamvu bezidumuza msinya kunalezo zomsizi, yeke inengi lamabutho wamaNdebele lafa ngelangelo, kwathi ngemva kwalokho amaNdebele ahlehla abalekela erholweni. AmaBhuru athi ayangena erholweni abuyela emva ngombana irholo awalazi, yeke atjhida entabeni ayokuhlala emasimini. &lt;ref name=&quot;:0&quot; /&gt; Emalangeni alandelako bebasolo basilwa, kesinye isikhathi amaNdebele afike kungakalindeleki agadle abaleke. Kesinye isikhathi bekafika ebe iinkomo zamakhuwa, kesinye isikhathi babanjwe babulawe. Kwakhe kwaba nesahlakalo lapha amaNdebele athumba iinkomo zamaBhuru, kanti amaBhuru awakalali, abagijimisa abulala amaNdebele ali-150, babuya neenkomo zabo.&lt;ref name=&quot;:1&quot; /&gt;

Isikhathi nasikhambako yahlasela indlala emaNdebeleni. Ukudla ebebakubulungile kwaphela, bathoma ukudla iimphalo eenkhunjeni, kodwana ngokukhamba kwesikhathi iimphalo nazo zaphela. Bathoma bafikelwa mcabango wokuzinikela emaBhurwini, ngapha amaBhuru sebacabanga ukukhamba babuyele emakhaya ngombana sebafikelwa kudinwa. AmaNdebele eza namano wokuthola ukudla.&lt;ref name=&quot;:0&quot; /&gt; Kwakhitjhwa intanga yamaThula bona iyokuthumba iinkomo zabaPedi. Ngebanga lokuthi bebanganamandla ngebanga lokulamba bahlulwa epini leyo.

Kunesikhathi lapha amaNdebele athi akhukhuthisa abafazi bona bayokweba ukudla, kodwana amaBhuru wababulala abafazabo. Kuthiwa abafazaba bakwaMatsitsi, uNoMtjhatjhana noNoMgiyelwa.  Ngesikhatheso bekusolo kuliwa. Kokhunye amaBhuru alinge ukwemba amadwala afuna indlela yokungena erholweni, kodwana amaNzunza afike abahlasele abaliye, nabo bagcine sele bawunghalile umsebenzi loyo. &lt;ref name=&quot;:1&quot; /&gt;

Kwafika isikhathi lapha amaBhuru abuyela khona emva. Athe angakayi nokuyaphi, asemlanjeni iMangwana kwafika indoda yakwaNdala yatjela amaBhuru bona amaNdebele aphelile yindlala, neemphalo nazo ziphelile. AmaBhuru wajika wabuyela emva kwaNomtjharhelo. Bafika batjela iNgwenyama bona ayikhuphe uMampuru. Nangambala yamkhupha yamnikela emaBhurwini ngomhlaka-08 kaVelabahlinze 1883. Ipi le yathatha iinyanga ezibunane zoke. Babotjhwa bobabili uNyabela noMampuru.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt; 

== Ukubotjhwa Nokuhlongakala KukaNyabela ==
Kwathi ngemva kobana uNyabela anikele uMampuru kuJoubert nebutho lakhe naye wabotjhwa ngebanga lokujamelana nebutho likaRhulumende wangesikhatheso nokufihla isilelesi. Ngemva kokubotjhwa kwabo isitjhaba sakhutjhwa ngerholweni, satjelwa bona uNyabela akasese yikosi noNyengelele ikosikazakhe akasese yindlovukazi, kunalokho uPiet Joubert uzokuba yikosi yamaNdebele wakwaNzunza bese ikosikazakhe ibe yindlovukazi. Abavumako baphadlhalajwa bahlukaniswa bona bayokuhlala emaplasini wamaBhuru basebenze khona, labo abangavumiko njengoMatsitsi, uPinda, uSigidi, uNdungulu noMhlangula babotjhwa. Abomma basetjenziselwa ukuhlanza iimpahla zamakhuwa, kwathi abobaba belusa ifuyo yamaBhuru, abanye basebenza emasimini. &lt;ref name=&quot;:0&quot; /&gt; 

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>4qeex6542r2auax5qkex5lb9al1vrz0</sha1>
    </revision>
    <revision>
      <id>5952</id>
      <parentid>3229</parentid>
      <timestamp>2025-11-06T11:40:37Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>edited</comment>
      <origin>5952</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="13451" sha1="pu90oqruicdrlrk83jhdgwlrfibgj3q" xml:space="preserve">[[Isimumathi:King Nyabela of the Ndebele Tribe South Africa 1893.jpg|thumb|Ilitje Lesikhumbuzo leNgwenyama uNyabela]]
'''UNyabela''' yiNgwenyama yamaNdebele wakwaNzunza  eyabusa kusukela ngenyanga kaVelabahlinze 1879 nakukhothama iNgwenyama uRhobongo, walwa ipi namaBhuru eyathoma ngomhlaka-07 kaSinyikhaba 1882 eyaphela ngomhlaka-08 kaVelabahlinze 1883 mhla anikela uMampuru emaBhurwini, kwaba kubotjhwa kwakhe nokuhluleka kwepi yamaNdebele emaBhurwini.&lt;ref name=&quot;:0&quot;&gt;Iziko Lamakhosi - C. J Mahlangu, K. N Mahlangu, M. A Mahlangu, no-S. M Mtshweni&lt;/ref&gt; 

Ngokwencwadi ethi '''Iziko lamaKhosi''', uNyabela  - uGijamphezeni kaMabhoko - yindodana yesithathu yeNgwenyama uMabhoko ebelethwa endlukulu. Kwathi bona kukhothame iNgwenyama uRhobongo ebeyibambele uFene, uNyabela wathatha isihlalo  waraga nokubambela uFene indodana kaMkhephuli ngombana bekasesemncani bona angabusa. Nayiragako ithi ekuthomeni kokubusa kwakhe uNyabela wayenganayo ingubo yobukhosi. Yeke wakhupha intanga yamaDlaza bona iyokufuna ingwe khona kuzokutholakala isikhumba esizokuba yingubo yobukhosi. Owayethwele intanga yamaDlaza ibizo lakhe kwakunguNomacwayi. Bagcina Bayifumene ingwe entabeni yakwaCabha, bayibulala beza nayo ekosini. &lt;ref name=&quot;:0&quot; /&gt;

=== Amadodana weNgwenyama uNyabela ===

* UMtjongweni (uSomphezeni) oliDugu noyindondana ekulu

* UMofu (uSoSenzeni) oliPhogo
* UNgobe oliDuba
* UMpepe (uSovelemu) oliDlowu
* UMzitha (uSoMene) oliSinya
* UMakhabakhubu (uSovusani) oliPhogo
* UPama (uSoMvumazoke) liRhorha
* UZalabo (uSoMlingo) oliDuba
* UMarhagi (uSoZilani) oliRhorha&lt;ref name=&quot;:0&quot; /&gt;

== Isisusa Serarano Phakathi KukaNyabela NamaBhuru ==
[[Isimumathi:LL1882 pg008 SIKUKUNI.jpg|thumb|USekhukhune]]
Ngesikhathi sokubusa kukaNyabela amaBhuru besele athomile ukuzibusa ngombana bebangasekho ngaphasi kokubuswa maNgisi. Yeke, besele kuphethe bona, begodu bebenza koke okusemandlenabo bona balawule iintjhaba zabantu abanzima enarheni khona bazokubusa ngendlela ephumelelako.&lt;ref name=&quot;:1&quot;&gt;{{Cite web|title=South African Military History Society - Journal - AN AFRICAN MASADA: Nyabela, Mampuru and the Defence of Mapochstad|url=http://samilitaryhistory.org/vol144ds.html|access-date=2025-05-31|website=samilitaryhistory.org}}&lt;/ref&gt; Soke isikhathesi amaBhuru namaNdebele wakwaNzunza bekanetjhebiswano elihle elathonywa yiNgwenyama uMabhoko. Kodwana kwathi bona amaBhuru athome ukuzibusa itjhebiswano laya lancipha. Isizathu kungaba kukuthi amaNdebele nawo besele afuna ukuzibusa,  UNyabela ubesele angasawubhadeli umthelo emaBhurwini, begodu wala nokuletha isibalo sabantu baboke esitjhabeni.begodu lokho kwawasilinga amaBhuru ngaphasi kombuso we-ZAR.&lt;ref name=&quot;:1&quot; /&gt;

Isisusa esikhulu serarano phakathi kwamaNdebele namaBhuru kwaba nguMampuru. UMampuru bekayikosana yabaPedi eyabelethwa ngo-1824, ayindodana yomnakwabo weKosi uSikwati. USikwati wahlongakala ngo-1861. Lokho kwabanga umraro yokuthi ngubani okufuze alandele ekubeni yiKosi yabaPedi. &lt;ref name=&quot;:2&quot;&gt;{{Cite web|title=Kgoŝi Mampuru II – King of the Pedi people {{!}} Ditsong Museums of South Africa|url=https://ditsong.org.za/en/kgosi-mampuru-ii-king-of-the-pedi-people/|access-date=2025-05-31|website=https://ditsong.org.za/en/|language=en-US}}&lt;/ref&gt; UMampuru wathi uSikwati ukhethe yena bona abe yiKosi ngombana ubelethwa mfazi obeletha ubukhosi, abaPedi abambiza bona yi-''timamollo.'' U-Sekhukhune oyindodana ekulu kaSikwati wathi lokho angekhe kwenzeke njengombana unina kaMampuru omfazi obeletha ubukhosi ukakakhuleliswa yiKosi uSikwati, kodwana mumuntu wangaphandle. Ngaphezu kwalokho wathi uSikwati ubengakaphethi koke okufuze akuphethe nakathatha umfazi oyi-''timamollo''. Yeke isihlalo kufuze sithathwe nguye.&lt;ref&gt;https://en.wikipedia.org/wiki/Mampuru_II&lt;/ref&gt;
U-Sekhukhune wathoma wathatha amandla wobukhosi bewabulala nabeluleki bakaMampuru. UMampuru wagcina sele abalekile kelekhabo. Kwathi ngemva kwesikhathi u-Sekhukhune sele alwe ipi namaBhuru, nenye ipi namaSwati, wahlaselwa esigodlweni sakhe wahlatjwa ngomukhwa wafa ngomhlaka-13 kaRhoboyi 1882. UMampuru nguye owasolwa ngokubulawa kuka-Sekhukhune, wasolwa nangokubanga umguruguru esitjhabeni sabaPedi. Yeke amaBhuru akhipha isiqunto sokuthi uMampuru akabotjhwe khona umguruguru lo uzokuphela.&lt;ref name=&quot;:2&quot; /&gt;[[Isimumathi:Stephanus Johannes Roos.jpg|thumb|UJohannes Roos]]Kuthe bona uMampuru ezwe bona uyafuneka wabaleka esitjhabeni sekhabo wayokukhosela ebantwini bakwaMasimula. AbaPedi bamlandelela nalapho babawa ikosi yakwaMasimula bona ibanikele yena, kodwana yona yala. Kwaba nepi, abakwaMasimula bahlulwa epini leyo. UMampuru nakabona bonyana bakwaMasimula bahluliwe, wabalekela kwaNomtjharhelo eNgwenyameni uNyabela. &lt;ref name=&quot;:0&quot; /&gt;

AbaPedi bafika nakoNomtjharhelo bambawa eNgwenyameni uNyabela. Kuthiwa iKosi uNyabela yathi nayibaphendulako: &quot;UMampuru ngimginyile. Nanimfunako izani ningihlinze isisu nimkhuphe.&quot; Okutjho bona nangabe abaPedi bafuna uMampuru kuzokufuze kuliwe ipi bona atholakale. AbaPedi bakhamba batjhinga emBhurwini babawa isizo lokuthola uMampuru. U-Paul Kruger obekamungameli we-ZAR, wathumela u-Roos noSenekal bona basize abaPedi ngendaba le. AmaBhuru amabili la afika esitjhabeni samaNdebele abawa uMampuru, kodwana uNyabela wala, wathi umginyile, nabamfunako abamkhuphe ngemathunjinakhe. Ekugcineni uNyabela wasilingeka wabulala u-Roos no-Senekal, wathatha iinhloko zabo wazihloma eengodweni. Kuthiwa bekavuka qobe ekuseni akhambe ayokulotjhisa iinhloko zabo aziphulule neendevu zazo.&lt;ref name=&quot;:0&quot; /&gt; 

AmaBhuru asilingeka khulu ngesenzwesi athumela u-Piet Joubert namasotja amanengi. Naye wafika warabhela uNyabela amahlandla ambalwa bona akhuphe uMaMpuru kodwana uNyabela wabhala naye, kwaba kusuka kwepi phakathi kwamaNdebele namaBhuru.&lt;ref name=&quot;:1&quot; /&gt;

== Ukuthoma Kwepi YamaNdebele NamaBhuru ==
[[Isimumathi:Pjjoubert.jpg|thumb|UPiet Joubert]]
Ipi yathoma ngomhlaka-7 kuSinyikhaba 1882. Ipi yamaNdebele yayihlome ngeengidi zomsizi nemikhonto, bese yamaBhuru ihlome ngeengidi zeenhlamvu idoswa phambili nguPiet Joubert. Iingidi zeenhlamvu bezidumuza msinya kunalezo zomsizi, yeke inengi lamabutho wamaNdebele lafa ngelangelo, kwathi ngemva kwalokho amaNdebele ahlehla abalekela erholweni. AmaBhuru athi ayangena erholweni abuyela emva ngombana irholo awalazi, yeke atjhida entabeni ayokuhlala emasimini. &lt;ref name=&quot;:0&quot; /&gt; Emalangeni alandelako bebasolo basilwa, kesinye isikhathi amaNdebele afike kungakalindeleki agadle abaleke. Kesinye isikhathi bekafika ebe iinkomo zamakhuwa, kesinye isikhathi babanjwe babulawe. Kwakhe kwaba nesahlakalo lapha amaNdebele athumba iinkomo zamaBhuru, kanti amaBhuru awakalali, abagijimisa abulala amaNdebele ali-150, babuya neenkomo zabo.&lt;ref name=&quot;:1&quot; /&gt;

Isikhathi nasikhambako yahlasela indlala emaNdebeleni. Ukudla ebebakubulungile kwaphela, bathoma ukudla iimphalo eenkhunjeni, kodwana ngokukhamba kwesikhathi iimphalo nazo zaphela. Bathoma bafikelwa mcabango wokuzinikela emaBhurwini, ngapha amaBhuru sebacabanga ukukhamba babuyele emakhaya ngombana sebafikelwa kudinwa. AmaNdebele eza namano wokuthola ukudla.&lt;ref name=&quot;:0&quot; /&gt; Kwakhitjhwa intanga yamaThula bona iyokuthumba iinkomo zabaPedi. Ngebanga lokuthi bebanganamandla ngebanga lokulamba bahlulwa epini leyo.

Kunesikhathi lapha amaNdebele athi akhukhuthisa abafazi bona bayokweba ukudla, kodwana amaBhuru wababulala abafazabo. Kuthiwa abafazaba bakwaMatsitsi, uNoMtjhatjhana noNoMgiyelwa.  Ngesikhatheso bekusolo kuliwa. Kokhunye amaBhuru alinge ukwemba amadwala afuna indlela yokungena erholweni, kodwana amaNzunza afike abahlasele abaliye, nabo bagcine sele bawunghalile umsebenzi loyo. &lt;ref name=&quot;:1&quot; /&gt;

Kwafika isikhathi lapha amaBhuru abuyela khona emva. Athe angakayi nokuyaphi, asemlanjeni iMangwana kwafika indoda yakwaNdala yatjela amaBhuru bona amaNdebele aphelile yindlala, neemphalo nazo ziphelile. AmaBhuru wajika wabuyela emva kwaNomtjharhelo. Bafika batjela iNgwenyama bona ayikhuphe uMampuru. Nangambala yamkhupha yamnikela emaBhurwini ngomhlaka-08 kaVelabahlinze 1883. Ipi le yathatha iinyanga ezibunane zoke. Babotjhwa bobabili uNyabela noMampuru.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt; 

== Ukubotjhwa Nokuhlongakala KukaNyabela ==
Kwathi ngemva kobana uNyabela anikele uMampuru kuJoubert nebutho lakhe naye wabotjhwa ngebanga lokujamelana nebutho likaRhulumende wangesikhatheso nokufihla isilelesi. Ngemva kokubotjhwa kwabo isitjhaba sakhutjhwa ngerholweni, satjelwa bona uNyabela akasese yikosi noNyengelele ikosikazakhe akasese yindlovukazi, kunalokho uPiet Joubert uzokuba yikosi yamaNdebele wakwaNzunza bese ikosikazakhe ibe yindlovukazi. Abavumako baphadlhalajwa bahlukaniswa bona bayokuhlala emaplasini wamaBhuru basebenze khona, labo abangavumiko njengoMatsitsi, uPinda, uSigidi, uNdungulu noMhlangula babotjhwa. Abomma basetjenziselwa ukuhlanza iimpahla zamakhuwa, kwathi abobaba belusa ifuyo yamaBhuru, abanye basebenza emasimini.&lt;ref name=&quot;:0&quot; /&gt;

Umlandu kaMampuru wadenjwa ngomhla ka-17 kaKhukhulamungu 1883, umlandu wokubulala uSekhukhune, ukubanga inturhu nomguruguru, wagwetjelwa ukufa. Kwathi ngomhla ka-21 kuKhukhulamungu 1883 uNyabela wavela phambi komahluleli, iJaji u-JG Kotze nejuri yamadoda wamakhuwa abunane ngomlandu wokobana ususe ukuthula emphakathini walwisana nelawulo ebelisemthethweni leRiphabliki, nokuthi lokho okwenze ngokungemthetho, ngekohliso bewazindla ngakho. Nokobana uqunte ukuthatha iinkhali wahlela ipi yena neenduna zakhe wajamelana nombuso osemthethweni we-ZAR. Obekamjameli wakhe ekhotho owabelwe mbuso wangesikhatheso bekungu-Advocate Cooper, obekamtjhutjhisi kungu-Carl Ueckermann.&lt;ref name=&quot;:3&quot;&gt;TAB, SS 852, R.4598/83, item 293&lt;/ref&gt;

Kwathi bona umlandu kaNyabela ufundwe, u-Advocate Cooper watjela ikhotho bona ukuzivikela kukaNyabela akukhambelani nalokho okufundwe emlandwini ngombana uNyabela bekanganabo ubuhlobo nombuso we-ZAR kodwana bekayikosi ezijameleko yena nabantu bakhe. Lokho kwenza bona kuthiwe uNyabela uthi yena akanamlandu. Kwabizwa abofakazi abasithandathu u-Eduard Bok, u-SP Grové, u-SP Trichard, uJenerali Joubert, uKhomandanti Weilbach no-Kleinbooi (indoda yeNdebele amabhuru amnikele ibizo). U-Joubert uhlulekile ukubika bona uthumele uNyabela imibandela ngaphambi kokwetjiwa kweenkunzi zakhe. U-Kleinbooi khenge abuzwe ngombandela lo.&lt;ref name=&quot;:3&quot; /&gt; 

Into eyalwelwako ekudenjweni komlandu bekukuthi inga-kghani uNyabela usisakhamuzi seRiphabliki namkha awa. Ekuthomeni iRiphabliki beyijame ngesivumelwano esenziwa ngomhla ka-28 kuNtaka 1860 phakathi kukaMabhoko neRiphabliki. Ngaphasi kwesivumelwanesi, uMabhoko uvumile bona usisakhamuzi seRiphabliki. U-Cooper waphendula ubufakazobu ngokuthi isivumelwanesi asimbophi uNyabela. Okwesibili, u-Ueckermann bekanesaziso esivela kuNom. Hercules Robinson, esazisa bona amalungelo neembopho zabo boke abantu abanzima bendabuko enarheni kuzokuhlala kunjalo ngemva kokutlikitlwa kwe-''Pretoria Convention.'' U-Cooper waliphikisa ngelokuthi uNyabela bekangekho nakutlikitlwako e-''Pretoria Convention'' lokha uNomzana Hercules akhuluma namakhosi wendabuko, yeke isivumelwanweso asimbophi uNyabela. Yeke uNyabela uzijamele. U-Ueckermann nakaphendulako wathi ukuthi uNyabela akawubhadeli umthelo embusweni we-ZAR akusibufakazi bokuthi uzijamele. UKleinbooi naye wafakaza ukuthi uNyabela uvumile ku-Shepstone ukuthi bekangaphasi kukaRhulumende, yeke bekufuze abhadele umthelo. Kodwana abamrhononelako khenge baveze ubufakazi obuzwakalako ukuthi uNyabela uthome ipi ngokuthatha iinkunzi zamaBhuru. Ipendulo ebeyizwakala bekungeyaka-Ueckermann ukuthi uNyabela kufuze aphathwe njengesithunjwa sepi nokuthi besele anesikhathi abotjhiwe. Ekugcineni ijaji lathi ngebanga lokuthi uNyabela bekahlala hlanu kweMiddelburg, nangaphakathi kwemikhawulo yeRiphabliki, yeke bekasisakhamuzi seRiphabliki.&lt;ref name=&quot;:3&quot; /&gt; 

Ijuri yatjho yoke bona uNyabela umlandu ngokwayo yoke imilandu abekwe yona. Lokha uNyabela nakabuzwako bona ufuna ukuthini ngaphambi kobana anikelwe isigwebo sentambo, wathi yena ubawa ukuthula, amahlandla alitjhumi. Ngemva kwalokho wagetjelwa ukufa. Woke amanye amaNdebele ama-22 ebekanoNyabela kwadenjwa umlandu wawo ngomhla ka-24 kaKhukhulamungu 1883 babekwa umlandu wokubanga umguruguru nokulwa. Boke njalo bagwetjelwa ukuhlala ejele iminyaka elikhomba nokusebenza budisi.&lt;ref name=&quot;:4&quot;&gt;TAB, SS 852, R.4598 / 83&lt;/ref&gt;

Ngesikhatheso u-Paul Kruger bekangekho asaye e-London bona ayokukhulumisana namaNgisi ngemibandela ye-Pretoria Convention begodu u-Piet Joubert bekamumongameli omjaphethe. Ijaji ebelingamele ngalesosikhathi latlola umbiko emKhandlwini ngomhla ka-1 kuSewula, bese wawuthumela ngo-Sewula 7. Ngemva kobana ijaji lirhunyeze amaqiniso neenkulumopikiswano, watlola  nangomthetho omenze bona akhuphe isigwebo sokufa. Kodwana uJenerali Joubert waveza ebufakazini bakhe bona uthumele uNyabela umlayezo wokuthi nangabe akazithobi uzokudliwa yikule ehloko namkha abulawe yindlala emrhobeni. Kghani uNyabela bekacabanga bona nakangazithoba bekazokusinda? Ngombana msinyana ngemva kwalokho, wazithoba. Wahlongoza bona umKhandlu usicabangele isigwebo sokufa usehlise. UmKhandlu waqunta bona uNyabela akadilikelwe lijele asebenze budisi. Kodwana uMampuru yena khenge acolelwe, yeke walengiswa ngomhla ka-22 kuSinyikhaba 1883. Walengiswa phambi kukaNyabela. Okokuthoma intambo yarathuka wadusuka phasi kabuhlungu ehlabathini. Walengiswa godu msinyana ngemva kwalokho.&lt;ref name=&quot;:3&quot; /&gt;&lt;ref name=&quot;:4&quot; /&gt;

UNyabela watjhaphululwa ejele ngo-1898 wayokuhlala hlanu kwe-Derdepoort ePitori. Wahlongakala ngo-1903. 

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>pu90oqruicdrlrk83jhdgwlrfibgj3q</sha1>
    </revision>
    <revision>
      <id>6103</id>
      <parentid>5952</parentid>
      <timestamp>2025-12-22T07:05:34Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <minor />
      <comment>/* Isisusa Serarano Phakathi KukaNyabela NamaBhuru */ spelling fix</comment>
      <origin>6103</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="13451" sha1="fqetbzhrzjxnaaau2z4bhlbxngx57wt" xml:space="preserve">[[Isimumathi:King Nyabela of the Ndebele Tribe South Africa 1893.jpg|thumb|Ilitje Lesikhumbuzo leNgwenyama uNyabela]]
'''UNyabela''' yiNgwenyama yamaNdebele wakwaNzunza  eyabusa kusukela ngenyanga kaVelabahlinze 1879 nakukhothama iNgwenyama uRhobongo, walwa ipi namaBhuru eyathoma ngomhlaka-07 kaSinyikhaba 1882 eyaphela ngomhlaka-08 kaVelabahlinze 1883 mhla anikela uMampuru emaBhurwini, kwaba kubotjhwa kwakhe nokuhluleka kwepi yamaNdebele emaBhurwini.&lt;ref name=&quot;:0&quot;&gt;Iziko Lamakhosi - C. J Mahlangu, K. N Mahlangu, M. A Mahlangu, no-S. M Mtshweni&lt;/ref&gt; 

Ngokwencwadi ethi '''Iziko lamaKhosi''', uNyabela  - uGijamphezeni kaMabhoko - yindodana yesithathu yeNgwenyama uMabhoko ebelethwa endlukulu. Kwathi bona kukhothame iNgwenyama uRhobongo ebeyibambele uFene, uNyabela wathatha isihlalo  waraga nokubambela uFene indodana kaMkhephuli ngombana bekasesemncani bona angabusa. Nayiragako ithi ekuthomeni kokubusa kwakhe uNyabela wayenganayo ingubo yobukhosi. Yeke wakhupha intanga yamaDlaza bona iyokufuna ingwe khona kuzokutholakala isikhumba esizokuba yingubo yobukhosi. Owayethwele intanga yamaDlaza ibizo lakhe kwakunguNomacwayi. Bagcina Bayifumene ingwe entabeni yakwaCabha, bayibulala beza nayo ekosini. &lt;ref name=&quot;:0&quot; /&gt;

=== Amadodana weNgwenyama uNyabela ===

* UMtjongweni (uSomphezeni) oliDugu noyindondana ekulu

* UMofu (uSoSenzeni) oliPhogo
* UNgobe oliDuba
* UMpepe (uSovelemu) oliDlowu
* UMzitha (uSoMene) oliSinya
* UMakhabakhubu (uSovusani) oliPhogo
* UPama (uSoMvumazoke) liRhorha
* UZalabo (uSoMlingo) oliDuba
* UMarhagi (uSoZilani) oliRhorha&lt;ref name=&quot;:0&quot; /&gt;

== Isisusa Serarano Phakathi KukaNyabela NamaBhuru ==
[[Isimumathi:LL1882 pg008 SIKUKUNI.jpg|thumb|USekhukhune]]
Ngesikhathi sokubusa kukaNyabela amaBhuru besele athomile ukuzibusa ngombana bebangasekho ngaphasi kokubuswa maNgisi. Yeke, besele kuphethe bona, begodu bebenza koke okusemandlenabo bona balawule iintjhaba zabantu abanzima enarheni khona bazokubusa ngendlela ephumelelako.&lt;ref name=&quot;:1&quot;&gt;{{Cite web|title=South African Military History Society - Journal - AN AFRICAN MASADA: Nyabela, Mampuru and the Defence of Mapochstad|url=http://samilitaryhistory.org/vol144ds.html|access-date=2025-05-31|website=samilitaryhistory.org}}&lt;/ref&gt; Soke isikhathesi amaBhuru namaNdebele wakwaNzunza bekanetjhebiswano elihle elathonywa yiNgwenyama uMabhoko. Kodwana kwathi bona amaBhuru athome ukuzibusa itjhebiswano laya lancipha. Isizathu kungaba kukuthi amaNdebele nawo besele afuna ukuzibusa,  UNyabela ubesele angasawubhadeli umthelo emaBhurwini, begodu wala nokuletha isibalo sabantu baboke esitjhabeni.begodu lokho kwawasilinga amaBhuru ngaphasi kombuso we-ZAR.&lt;ref name=&quot;:1&quot; /&gt;

Isisusa esikhulu serarano phakathi kwamaNdebele namaBhuru kwaba nguMampuru. UMampuru bekayikosana yabaPedi eyabelethwa ngo-1824, ayindodana yomnakwabo weKosi uSikwati. USikwati wahlongakala ngo-1861. Lokho kwabanga umraro wokuthi ngubani okufuze alandele ekubeni yiKosi yabaPedi. &lt;ref name=&quot;:2&quot;&gt;{{Cite web|title=Kgoŝi Mampuru II – King of the Pedi people {{!}} Ditsong Museums of South Africa|url=https://ditsong.org.za/en/kgosi-mampuru-ii-king-of-the-pedi-people/|access-date=2025-05-31|website=https://ditsong.org.za/en/|language=en-US}}&lt;/ref&gt; UMampuru wathi uSikwati ukhethe yena bona abe yiKosi ngombana ubelethwa mfazi obeletha ubukhosi, abaPedi abambiza bona yi-''timamollo.'' U-Sekhukhune oyindodana ekulu kaSikwati wathi lokho angekhe kwenzeke njengombana unina kaMampuru omfazi obeletha ubukhosi ukakakhuleliswa yiKosi uSikwati, kodwana mumuntu wangaphandle. Ngaphezu kwalokho wathi uSikwati ubengakaphethi koke okufuze akuphethe nakathatha umfazi oyi-''timamollo''. Yeke isihlalo kufuze sithathwe nguye.&lt;ref&gt;https://en.wikipedia.org/wiki/Mampuru_II&lt;/ref&gt;
U-Sekhukhune wathoma wathatha amandla wobukhosi bewabulala nabeluleki bakaMampuru. UMampuru wagcina sele abalekile kelekhabo. Kwathi ngemva kwesikhathi u-Sekhukhune sele alwe ipi namaBhuru, nenye ipi namaSwati, wahlaselwa esigodlweni sakhe wahlatjwa ngomukhwa wafa ngomhlaka-13 kaRhoboyi 1882. UMampuru nguye owasolwa ngokubulawa kuka-Sekhukhune, wasolwa nangokubanga umguruguru esitjhabeni sabaPedi. Yeke amaBhuru akhipha isiqunto sokuthi uMampuru akabotjhwe khona umguruguru lo uzokuphela.&lt;ref name=&quot;:2&quot; /&gt;[[Isimumathi:Stephanus Johannes Roos.jpg|thumb|UJohannes Roos]]Kuthe bona uMampuru ezwe bona uyafuneka wabaleka esitjhabeni sekhabo wayokukhosela ebantwini bakwaMasimula. AbaPedi bamlandelela nalapho babawa ikosi yakwaMasimula bona ibanikele yena, kodwana yona yala. Kwaba nepi, abakwaMasimula bahlulwa epini leyo. UMampuru nakabona bonyana bakwaMasimula bahluliwe, wabalekela kwaNomtjharhelo eNgwenyameni uNyabela. &lt;ref name=&quot;:0&quot; /&gt;

AbaPedi bafika nakoNomtjharhelo bambawa eNgwenyameni uNyabela. Kuthiwa iKosi uNyabela yathi nayibaphendulako: &quot;UMampuru ngimginyile. Nanimfunako izani ningihlinze isisu nimkhuphe.&quot; Okutjho bona nangabe abaPedi bafuna uMampuru kuzokufuze kuliwe ipi bona atholakale. AbaPedi bakhamba batjhinga emBhurwini babawa isizo lokuthola uMampuru. U-Paul Kruger obekamungameli we-ZAR, wathumela u-Roos noSenekal bona basize abaPedi ngendaba le. AmaBhuru amabili la afika esitjhabeni samaNdebele abawa uMampuru, kodwana uNyabela wala, wathi umginyile, nabamfunako abamkhuphe ngemathunjinakhe. Ekugcineni uNyabela wasilingeka wabulala u-Roos no-Senekal, wathatha iinhloko zabo wazihloma eengodweni. Kuthiwa bekavuka qobe ekuseni akhambe ayokulotjhisa iinhloko zabo aziphulule neendevu zazo.&lt;ref name=&quot;:0&quot; /&gt; 

AmaBhuru asilingeka khulu ngesenzwesi athumela u-Piet Joubert namasotja amanengi. Naye wafika warabhela uNyabela amahlandla ambalwa bona akhuphe uMaMpuru kodwana uNyabela wabhala naye, kwaba kusuka kwepi phakathi kwamaNdebele namaBhuru.&lt;ref name=&quot;:1&quot; /&gt;

== Ukuthoma Kwepi YamaNdebele NamaBhuru ==
[[Isimumathi:Pjjoubert.jpg|thumb|UPiet Joubert]]
Ipi yathoma ngomhlaka-7 kuSinyikhaba 1882. Ipi yamaNdebele yayihlome ngeengidi zomsizi nemikhonto, bese yamaBhuru ihlome ngeengidi zeenhlamvu idoswa phambili nguPiet Joubert. Iingidi zeenhlamvu bezidumuza msinya kunalezo zomsizi, yeke inengi lamabutho wamaNdebele lafa ngelangelo, kwathi ngemva kwalokho amaNdebele ahlehla abalekela erholweni. AmaBhuru athi ayangena erholweni abuyela emva ngombana irholo awalazi, yeke atjhida entabeni ayokuhlala emasimini. &lt;ref name=&quot;:0&quot; /&gt; Emalangeni alandelako bebasolo basilwa, kesinye isikhathi amaNdebele afike kungakalindeleki agadle abaleke. Kesinye isikhathi bekafika ebe iinkomo zamakhuwa, kesinye isikhathi babanjwe babulawe. Kwakhe kwaba nesahlakalo lapha amaNdebele athumba iinkomo zamaBhuru, kanti amaBhuru awakalali, abagijimisa abulala amaNdebele ali-150, babuya neenkomo zabo.&lt;ref name=&quot;:1&quot; /&gt;

Isikhathi nasikhambako yahlasela indlala emaNdebeleni. Ukudla ebebakubulungile kwaphela, bathoma ukudla iimphalo eenkhunjeni, kodwana ngokukhamba kwesikhathi iimphalo nazo zaphela. Bathoma bafikelwa mcabango wokuzinikela emaBhurwini, ngapha amaBhuru sebacabanga ukukhamba babuyele emakhaya ngombana sebafikelwa kudinwa. AmaNdebele eza namano wokuthola ukudla.&lt;ref name=&quot;:0&quot; /&gt; Kwakhitjhwa intanga yamaThula bona iyokuthumba iinkomo zabaPedi. Ngebanga lokuthi bebanganamandla ngebanga lokulamba bahlulwa epini leyo.

Kunesikhathi lapha amaNdebele athi akhukhuthisa abafazi bona bayokweba ukudla, kodwana amaBhuru wababulala abafazabo. Kuthiwa abafazaba bakwaMatsitsi, uNoMtjhatjhana noNoMgiyelwa.  Ngesikhatheso bekusolo kuliwa. Kokhunye amaBhuru alinge ukwemba amadwala afuna indlela yokungena erholweni, kodwana amaNzunza afike abahlasele abaliye, nabo bagcine sele bawunghalile umsebenzi loyo. &lt;ref name=&quot;:1&quot; /&gt;

Kwafika isikhathi lapha amaBhuru abuyela khona emva. Athe angakayi nokuyaphi, asemlanjeni iMangwana kwafika indoda yakwaNdala yatjela amaBhuru bona amaNdebele aphelile yindlala, neemphalo nazo ziphelile. AmaBhuru wajika wabuyela emva kwaNomtjharhelo. Bafika batjela iNgwenyama bona ayikhuphe uMampuru. Nangambala yamkhupha yamnikela emaBhurwini ngomhlaka-08 kaVelabahlinze 1883. Ipi le yathatha iinyanga ezibunane zoke. Babotjhwa bobabili uNyabela noMampuru.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt; 

== Ukubotjhwa Nokuhlongakala KukaNyabela ==
Kwathi ngemva kobana uNyabela anikele uMampuru kuJoubert nebutho lakhe naye wabotjhwa ngebanga lokujamelana nebutho likaRhulumende wangesikhatheso nokufihla isilelesi. Ngemva kokubotjhwa kwabo isitjhaba sakhutjhwa ngerholweni, satjelwa bona uNyabela akasese yikosi noNyengelele ikosikazakhe akasese yindlovukazi, kunalokho uPiet Joubert uzokuba yikosi yamaNdebele wakwaNzunza bese ikosikazakhe ibe yindlovukazi. Abavumako baphadlhalajwa bahlukaniswa bona bayokuhlala emaplasini wamaBhuru basebenze khona, labo abangavumiko njengoMatsitsi, uPinda, uSigidi, uNdungulu noMhlangula babotjhwa. Abomma basetjenziselwa ukuhlanza iimpahla zamakhuwa, kwathi abobaba belusa ifuyo yamaBhuru, abanye basebenza emasimini.&lt;ref name=&quot;:0&quot; /&gt;

Umlandu kaMampuru wadenjwa ngomhla ka-17 kaKhukhulamungu 1883, umlandu wokubulala uSekhukhune, ukubanga inturhu nomguruguru, wagwetjelwa ukufa. Kwathi ngomhla ka-21 kuKhukhulamungu 1883 uNyabela wavela phambi komahluleli, iJaji u-JG Kotze nejuri yamadoda wamakhuwa abunane ngomlandu wokobana ususe ukuthula emphakathini walwisana nelawulo ebelisemthethweni leRiphabliki, nokuthi lokho okwenze ngokungemthetho, ngekohliso bewazindla ngakho. Nokobana uqunte ukuthatha iinkhali wahlela ipi yena neenduna zakhe wajamelana nombuso osemthethweni we-ZAR. Obekamjameli wakhe ekhotho owabelwe mbuso wangesikhatheso bekungu-Advocate Cooper, obekamtjhutjhisi kungu-Carl Ueckermann.&lt;ref name=&quot;:3&quot;&gt;TAB, SS 852, R.4598/83, item 293&lt;/ref&gt;

Kwathi bona umlandu kaNyabela ufundwe, u-Advocate Cooper watjela ikhotho bona ukuzivikela kukaNyabela akukhambelani nalokho okufundwe emlandwini ngombana uNyabela bekanganabo ubuhlobo nombuso we-ZAR kodwana bekayikosi ezijameleko yena nabantu bakhe. Lokho kwenza bona kuthiwe uNyabela uthi yena akanamlandu. Kwabizwa abofakazi abasithandathu u-Eduard Bok, u-SP Grové, u-SP Trichard, uJenerali Joubert, uKhomandanti Weilbach no-Kleinbooi (indoda yeNdebele amabhuru amnikele ibizo). U-Joubert uhlulekile ukubika bona uthumele uNyabela imibandela ngaphambi kokwetjiwa kweenkunzi zakhe. U-Kleinbooi khenge abuzwe ngombandela lo.&lt;ref name=&quot;:3&quot; /&gt; 

Into eyalwelwako ekudenjweni komlandu bekukuthi inga-kghani uNyabela usisakhamuzi seRiphabliki namkha awa. Ekuthomeni iRiphabliki beyijame ngesivumelwano esenziwa ngomhla ka-28 kuNtaka 1860 phakathi kukaMabhoko neRiphabliki. Ngaphasi kwesivumelwanesi, uMabhoko uvumile bona usisakhamuzi seRiphabliki. U-Cooper waphendula ubufakazobu ngokuthi isivumelwanesi asimbophi uNyabela. Okwesibili, u-Ueckermann bekanesaziso esivela kuNom. Hercules Robinson, esazisa bona amalungelo neembopho zabo boke abantu abanzima bendabuko enarheni kuzokuhlala kunjalo ngemva kokutlikitlwa kwe-''Pretoria Convention.'' U-Cooper waliphikisa ngelokuthi uNyabela bekangekho nakutlikitlwako e-''Pretoria Convention'' lokha uNomzana Hercules akhuluma namakhosi wendabuko, yeke isivumelwanweso asimbophi uNyabela. Yeke uNyabela uzijamele. U-Ueckermann nakaphendulako wathi ukuthi uNyabela akawubhadeli umthelo embusweni we-ZAR akusibufakazi bokuthi uzijamele. UKleinbooi naye wafakaza ukuthi uNyabela uvumile ku-Shepstone ukuthi bekangaphasi kukaRhulumende, yeke bekufuze abhadele umthelo. Kodwana abamrhononelako khenge baveze ubufakazi obuzwakalako ukuthi uNyabela uthome ipi ngokuthatha iinkunzi zamaBhuru. Ipendulo ebeyizwakala bekungeyaka-Ueckermann ukuthi uNyabela kufuze aphathwe njengesithunjwa sepi nokuthi besele anesikhathi abotjhiwe. Ekugcineni ijaji lathi ngebanga lokuthi uNyabela bekahlala hlanu kweMiddelburg, nangaphakathi kwemikhawulo yeRiphabliki, yeke bekasisakhamuzi seRiphabliki.&lt;ref name=&quot;:3&quot; /&gt; 

Ijuri yatjho yoke bona uNyabela umlandu ngokwayo yoke imilandu abekwe yona. Lokha uNyabela nakabuzwako bona ufuna ukuthini ngaphambi kobana anikelwe isigwebo sentambo, wathi yena ubawa ukuthula, amahlandla alitjhumi. Ngemva kwalokho wagetjelwa ukufa. Woke amanye amaNdebele ama-22 ebekanoNyabela kwadenjwa umlandu wawo ngomhla ka-24 kaKhukhulamungu 1883 babekwa umlandu wokubanga umguruguru nokulwa. Boke njalo bagwetjelwa ukuhlala ejele iminyaka elikhomba nokusebenza budisi.&lt;ref name=&quot;:4&quot;&gt;TAB, SS 852, R.4598 / 83&lt;/ref&gt;

Ngesikhatheso u-Paul Kruger bekangekho asaye e-London bona ayokukhulumisana namaNgisi ngemibandela ye-Pretoria Convention begodu u-Piet Joubert bekamumongameli omjaphethe. Ijaji ebelingamele ngalesosikhathi latlola umbiko emKhandlwini ngomhla ka-1 kuSewula, bese wawuthumela ngo-Sewula 7. Ngemva kobana ijaji lirhunyeze amaqiniso neenkulumopikiswano, watlola  nangomthetho omenze bona akhuphe isigwebo sokufa. Kodwana uJenerali Joubert waveza ebufakazini bakhe bona uthumele uNyabela umlayezo wokuthi nangabe akazithobi uzokudliwa yikule ehloko namkha abulawe yindlala emrhobeni. Kghani uNyabela bekacabanga bona nakangazithoba bekazokusinda? Ngombana msinyana ngemva kwalokho, wazithoba. Wahlongoza bona umKhandlu usicabangele isigwebo sokufa usehlise. UmKhandlu waqunta bona uNyabela akadilikelwe lijele asebenze budisi. Kodwana uMampuru yena khenge acolelwe, yeke walengiswa ngomhla ka-22 kuSinyikhaba 1883. Walengiswa phambi kukaNyabela. Okokuthoma intambo yarathuka wadusuka phasi kabuhlungu ehlabathini. Walengiswa godu msinyana ngemva kwalokho.&lt;ref name=&quot;:3&quot; /&gt;&lt;ref name=&quot;:4&quot; /&gt;

UNyabela watjhaphululwa ejele ngo-1898 wayokuhlala hlanu kwe-Derdepoort ePitori. Wahlongakala ngo-1903. 

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>fqetbzhrzjxnaaau2z4bhlbxngx57wt</sha1>
    </revision>
    <revision>
      <id>6411</id>
      <parentid>6103</parentid>
      <timestamp>2026-04-13T08:46:54Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <minor />
      <comment>/* Isisusa Serarano Phakathi KukaNyabela NamaBhuru */</comment>
      <origin>6411</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="13446" sha1="5eds4chxj5ezwmkiqyixeonslg2ssd4" xml:space="preserve">[[Isimumathi:King Nyabela of the Ndebele Tribe South Africa 1893.jpg|thumb|Ilitje Lesikhumbuzo leNgwenyama uNyabela]]
'''UNyabela''' yiNgwenyama yamaNdebele wakwaNzunza  eyabusa kusukela ngenyanga kaVelabahlinze 1879 nakukhothama iNgwenyama uRhobongo, walwa ipi namaBhuru eyathoma ngomhlaka-07 kaSinyikhaba 1882 eyaphela ngomhlaka-08 kaVelabahlinze 1883 mhla anikela uMampuru emaBhurwini, kwaba kubotjhwa kwakhe nokuhluleka kwepi yamaNdebele emaBhurwini.&lt;ref name=&quot;:0&quot;&gt;Iziko Lamakhosi - C. J Mahlangu, K. N Mahlangu, M. A Mahlangu, no-S. M Mtshweni&lt;/ref&gt; 

Ngokwencwadi ethi '''Iziko lamaKhosi''', uNyabela  - uGijamphezeni kaMabhoko - yindodana yesithathu yeNgwenyama uMabhoko ebelethwa endlukulu. Kwathi bona kukhothame iNgwenyama uRhobongo ebeyibambele uFene, uNyabela wathatha isihlalo  waraga nokubambela uFene indodana kaMkhephuli ngombana bekasesemncani bona angabusa. Nayiragako ithi ekuthomeni kokubusa kwakhe uNyabela wayenganayo ingubo yobukhosi. Yeke wakhupha intanga yamaDlaza bona iyokufuna ingwe khona kuzokutholakala isikhumba esizokuba yingubo yobukhosi. Owayethwele intanga yamaDlaza ibizo lakhe kwakunguNomacwayi. Bagcina Bayifumene ingwe entabeni yakwaCabha, bayibulala beza nayo ekosini. &lt;ref name=&quot;:0&quot; /&gt;

=== Amadodana weNgwenyama uNyabela ===

* UMtjongweni (uSomphezeni) oliDugu noyindondana ekulu

* UMofu (uSoSenzeni) oliPhogo
* UNgobe oliDuba
* UMpepe (uSovelemu) oliDlowu
* UMzitha (uSoMene) oliSinya
* UMakhabakhubu (uSovusani) oliPhogo
* UPama (uSoMvumazoke) liRhorha
* UZalabo (uSoMlingo) oliDuba
* UMarhagi (uSoZilani) oliRhorha&lt;ref name=&quot;:0&quot; /&gt;

== Isisusa Serarano Phakathi KukaNyabela NamaBhuru ==
[[Isimumathi:LL1882 pg008 SIKUKUNI.jpg|thumb|USekhukhune]]
Ngesikhathi sokubusa kukaNyabela amaBhuru besele athomile ukuzibusa ngombana bewangasekho ngaphasi kokubuswa maNgisi. Yeke, besele kuphethe wona, begodu bekenza koke okusemandlenawo bona alawule iintjhaba zabantu abanzima enarheni khona azokubusa ngendlela ephumelelako.&lt;ref name=&quot;:1&quot;&gt;{{Cite web|title=South African Military History Society - Journal - AN AFRICAN MASADA: Nyabela, Mampuru and the Defence of Mapochstad|url=http://samilitaryhistory.org/vol144ds.html|access-date=2025-05-31|website=samilitaryhistory.org}}&lt;/ref&gt; Soke isikhathesi amaBhuru namaNdebele wakwaNzunza bekanetjhebiswano elihle elathonywa yiNgwenyama uMabhoko. Kodwana kwathi bona amaBhuru athome ukuzibusa itjhebiswano laya lancipha. Isizathu kungaba kukuthi amaNdebele nawo besele afuna ukuzibusa,  UNyabela ubesele angasawubhadeli umthelo emaBhurwini, begodu wala nokuletha isibalo sabantu baboke esitjhabeni,begodu lokho kwawasilinga amaBhuru ngaphasi kombuso we-ZAR.&lt;ref name=&quot;:1&quot; /&gt;

Isisusa esikhulu serarano phakathi kwamaNdebele namaBhuru kwaba nguMampuru. UMampuru bekayikosana yabaPedi eyabelethwa ngo-1824, ayindodana yomnakwabo weKosi uSikwati. USikwati wahlongakala ngo-1861. Lokho kwabanga umraro wokuthi ngubani okufuze alandele ekubeni yiKosi yabaPedi. &lt;ref name=&quot;:2&quot;&gt;{{Cite web|title=Kgoŝi Mampuru II – King of the Pedi people {{!}} Ditsong Museums of South Africa|url=https://ditsong.org.za/en/kgosi-mampuru-ii-king-of-the-pedi-people/|access-date=2025-05-31|website=https://ditsong.org.za/en/|language=en-US}}&lt;/ref&gt; UMampuru wathi uSikwati ukhethe yena bona abe yiKosi ngombana ubelethwa mfazi obeletha ubukhosi, abaPedi abambiza bona yi-''timamollo.'' U-Sekhukhune oyindodana ekulu kaSikwati wathi lokho angekhe kwenzeke njengombana unina kaMampuru omfazi obeletha ubukhosi ukakakhuleliswa yiKosi uSikwati, kodwana mumuntu wangaphandle. Ngaphezu kwalokho wathi uSikwati ubengakaphethi koke okufuze akuphethe nakathatha umfazi oyi-''timamollo''. Yeke isihlalo kufuze sithathwe nguye.&lt;ref&gt;https://en.wikipedia.org/wiki/Mampuru_II&lt;/ref&gt;
U-Sekhukhune wathoma wathatha amandla wobukhosi bewabulala nabeluleki bakaMampuru. UMampuru wagcina sele abalekile kelekhabo. Kwathi ngemva kwesikhathi u-Sekhukhune sele alwe ipi namaBhuru, nenye ipi namaSwati, wahlaselwa esigodlweni sakhe wahlatjwa ngomukhwa wafa ngomhlaka-13 kaRhoboyi 1882. UMampuru nguye owasolwa ngokubulawa kuka-Sekhukhune, wasolwa nangokubanga umguruguru esitjhabeni sabaPedi. Yeke amaBhuru akhipha isiqunto sokuthi uMampuru akabotjhwe khona umguruguru lo uzokuphela.&lt;ref name=&quot;:2&quot; /&gt;[[Isimumathi:Stephanus Johannes Roos.jpg|thumb|UJohannes Roos]]Kuthe bona uMampuru ezwe bona uyafuneka wabaleka esitjhabeni sekhabo wayokukhosela ebantwini bakwaMasimula. AbaPedi bamlandelela nalapho babawa ikosi yakwaMasimula bona ibanikele yena, kodwana yona yala. Kwaba nepi, bakwaMasimula bahlulwa epini leyo. UMampuru nakabona bonyana bakwaMasimula bahluliwe, wabalekela kwaNomtjharhelo eNgwenyameni uNyabela. &lt;ref name=&quot;:0&quot; /&gt;

AbaPedi bafika nakoNomtjharhelo bambawa eNgwenyameni uNyabela. Kuthiwa iKosi uNyabela yathi nayibaphendulako: &quot;UMampuru ngimginyile. Nanimfunako izani ningihlinze isisu nimkhuphe.&quot; Okutjho bona nangabe abaPedi bafuna uMampuru kuzokufuze kuliwe ipi bona atholakale. AbaPedi bakhamba batjhinga emBhurwini babawa isizo lokuthola uMampuru. U-Paul Kruger obekamungameli we-ZAR, wathumela u-Roos noSenekal bona basize abaPedi ngendaba le. AmaBhuru amabili la afika esitjhabeni samaNdebele abawa uMampuru, kodwana uNyabela wala, wathi umginyile, nabamfunako abamkhuphe ngemathunjinakhe. Ekugcineni uNyabela wasilingeka wabulala u-Roos no-Senekal, wathatha iinhloko zabo wazihloma eengodweni. Kuthiwa bekavuka qobe ekuseni akhambe ayokulotjhisa iinhloko zabo aphulule neendevu zazo.&lt;ref name=&quot;:0&quot; /&gt; 

AmaBhuru asilingeka khulu ngesenzwesi athumela u-Piet Joubert namasotja amanengi. Naye wafika warabhela uNyabela amahlandla ambalwa bona akhuphe uMaMpuru kodwana uNyabela wabhala naye, kwaba kusuka kwepi phakathi kwamaNdebele namaBhuru.&lt;ref name=&quot;:1&quot; /&gt;

== Ukuthoma Kwepi YamaNdebele NamaBhuru ==
[[Isimumathi:Pjjoubert.jpg|thumb|UPiet Joubert]]
Ipi yathoma ngomhlaka-7 kuSinyikhaba 1882. Ipi yamaNdebele yayihlome ngeengidi zomsizi nemikhonto, bese yamaBhuru ihlome ngeengidi zeenhlamvu idoswa phambili nguPiet Joubert. Iingidi zeenhlamvu bezidumuza msinya kunalezo zomsizi, yeke inengi lamabutho wamaNdebele lafa ngelangelo, kwathi ngemva kwalokho amaNdebele ahlehla abalekela erholweni. AmaBhuru athi ayangena erholweni abuyela emva ngombana irholo awalazi, yeke atjhida entabeni ayokuhlala emasimini. &lt;ref name=&quot;:0&quot; /&gt; Emalangeni alandelako bebasolo basilwa, kesinye isikhathi amaNdebele afike kungakalindeleki agadle abaleke. Kesinye isikhathi bekafika ebe iinkomo zamakhuwa, kesinye isikhathi babanjwe babulawe. Kwakhe kwaba nesahlakalo lapha amaNdebele athumba iinkomo zamaBhuru, kanti amaBhuru awakalali, abagijimisa abulala amaNdebele ali-150, babuya neenkomo zabo.&lt;ref name=&quot;:1&quot; /&gt;

Isikhathi nasikhambako yahlasela indlala emaNdebeleni. Ukudla ebebakubulungile kwaphela, bathoma ukudla iimphalo eenkhunjeni, kodwana ngokukhamba kwesikhathi iimphalo nazo zaphela. Bathoma bafikelwa mcabango wokuzinikela emaBhurwini, ngapha amaBhuru sebacabanga ukukhamba babuyele emakhaya ngombana sebafikelwa kudinwa. AmaNdebele eza namano wokuthola ukudla.&lt;ref name=&quot;:0&quot; /&gt; Kwakhitjhwa intanga yamaThula bona iyokuthumba iinkomo zabaPedi. Ngebanga lokuthi bebanganamandla ngebanga lokulamba bahlulwa epini leyo.

Kunesikhathi lapha amaNdebele athi akhukhuthisa abafazi bona bayokweba ukudla, kodwana amaBhuru wababulala abafazabo. Kuthiwa abafazaba bakwaMatsitsi, uNoMtjhatjhana noNoMgiyelwa.  Ngesikhatheso bekusolo kuliwa. Kokhunye amaBhuru alinge ukwemba amadwala afuna indlela yokungena erholweni, kodwana amaNzunza afike abahlasele abaliye, nabo bagcine sele bawunghalile umsebenzi loyo. &lt;ref name=&quot;:1&quot; /&gt;

Kwafika isikhathi lapha amaBhuru abuyela khona emva. Athe angakayi nokuyaphi, asemlanjeni iMangwana kwafika indoda yakwaNdala yatjela amaBhuru bona amaNdebele aphelile yindlala, neemphalo nazo ziphelile. AmaBhuru wajika wabuyela emva kwaNomtjharhelo. Bafika batjela iNgwenyama bona ayikhuphe uMampuru. Nangambala yamkhupha yamnikela emaBhurwini ngomhlaka-08 kaVelabahlinze 1883. Ipi le yathatha iinyanga ezibunane zoke. Babotjhwa bobabili uNyabela noMampuru.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt; 

== Ukubotjhwa Nokuhlongakala KukaNyabela ==
Kwathi ngemva kobana uNyabela anikele uMampuru kuJoubert nebutho lakhe naye wabotjhwa ngebanga lokujamelana nebutho likaRhulumende wangesikhatheso nokufihla isilelesi. Ngemva kokubotjhwa kwabo isitjhaba sakhutjhwa ngerholweni, satjelwa bona uNyabela akasese yikosi noNyengelele ikosikazakhe akasese yindlovukazi, kunalokho uPiet Joubert uzokuba yikosi yamaNdebele wakwaNzunza bese ikosikazakhe ibe yindlovukazi. Abavumako baphadlhalajwa bahlukaniswa bona bayokuhlala emaplasini wamaBhuru basebenze khona, labo abangavumiko njengoMatsitsi, uPinda, uSigidi, uNdungulu noMhlangula babotjhwa. Abomma basetjenziselwa ukuhlanza iimpahla zamakhuwa, kwathi abobaba belusa ifuyo yamaBhuru, abanye basebenza emasimini.&lt;ref name=&quot;:0&quot; /&gt;

Umlandu kaMampuru wadenjwa ngomhla ka-17 kaKhukhulamungu 1883, umlandu wokubulala uSekhukhune, ukubanga inturhu nomguruguru, wagwetjelwa ukufa. Kwathi ngomhla ka-21 kuKhukhulamungu 1883 uNyabela wavela phambi komahluleli, iJaji u-JG Kotze nejuri yamadoda wamakhuwa abunane ngomlandu wokobana ususe ukuthula emphakathini walwisana nelawulo ebelisemthethweni leRiphabliki, nokuthi lokho okwenze ngokungemthetho, ngekohliso bewazindla ngakho. Nokobana uqunte ukuthatha iinkhali wahlela ipi yena neenduna zakhe wajamelana nombuso osemthethweni we-ZAR. Obekamjameli wakhe ekhotho owabelwe mbuso wangesikhatheso bekungu-Advocate Cooper, obekamtjhutjhisi kungu-Carl Ueckermann.&lt;ref name=&quot;:3&quot;&gt;TAB, SS 852, R.4598/83, item 293&lt;/ref&gt;

Kwathi bona umlandu kaNyabela ufundwe, u-Advocate Cooper watjela ikhotho bona ukuzivikela kukaNyabela akukhambelani nalokho okufundwe emlandwini ngombana uNyabela bekanganabo ubuhlobo nombuso we-ZAR kodwana bekayikosi ezijameleko yena nabantu bakhe. Lokho kwenza bona kuthiwe uNyabela uthi yena akanamlandu. Kwabizwa abofakazi abasithandathu u-Eduard Bok, u-SP Grové, u-SP Trichard, uJenerali Joubert, uKhomandanti Weilbach no-Kleinbooi (indoda yeNdebele amabhuru amnikele ibizo). U-Joubert uhlulekile ukubika bona uthumele uNyabela imibandela ngaphambi kokwetjiwa kweenkunzi zakhe. U-Kleinbooi khenge abuzwe ngombandela lo.&lt;ref name=&quot;:3&quot; /&gt; 

Into eyalwelwako ekudenjweni komlandu bekukuthi inga-kghani uNyabela usisakhamuzi seRiphabliki namkha awa. Ekuthomeni iRiphabliki beyijame ngesivumelwano esenziwa ngomhla ka-28 kuNtaka 1860 phakathi kukaMabhoko neRiphabliki. Ngaphasi kwesivumelwanesi, uMabhoko uvumile bona usisakhamuzi seRiphabliki. U-Cooper waphendula ubufakazobu ngokuthi isivumelwanesi asimbophi uNyabela. Okwesibili, u-Ueckermann bekanesaziso esivela kuNom. Hercules Robinson, esazisa bona amalungelo neembopho zabo boke abantu abanzima bendabuko enarheni kuzokuhlala kunjalo ngemva kokutlikitlwa kwe-''Pretoria Convention.'' U-Cooper waliphikisa ngelokuthi uNyabela bekangekho nakutlikitlwako e-''Pretoria Convention'' lokha uNomzana Hercules akhuluma namakhosi wendabuko, yeke isivumelwanweso asimbophi uNyabela. Yeke uNyabela uzijamele. U-Ueckermann nakaphendulako wathi ukuthi uNyabela akawubhadeli umthelo embusweni we-ZAR akusibufakazi bokuthi uzijamele. UKleinbooi naye wafakaza ukuthi uNyabela uvumile ku-Shepstone ukuthi bekangaphasi kukaRhulumende, yeke bekufuze abhadele umthelo. Kodwana abamrhononelako khenge baveze ubufakazi obuzwakalako ukuthi uNyabela uthome ipi ngokuthatha iinkunzi zamaBhuru. Ipendulo ebeyizwakala bekungeyaka-Ueckermann ukuthi uNyabela kufuze aphathwe njengesithunjwa sepi nokuthi besele anesikhathi abotjhiwe. Ekugcineni ijaji lathi ngebanga lokuthi uNyabela bekahlala hlanu kweMiddelburg, nangaphakathi kwemikhawulo yeRiphabliki, yeke bekasisakhamuzi seRiphabliki.&lt;ref name=&quot;:3&quot; /&gt; 

Ijuri yatjho yoke bona uNyabela umlandu ngokwayo yoke imilandu abekwe yona. Lokha uNyabela nakabuzwako bona ufuna ukuthini ngaphambi kobana anikelwe isigwebo sentambo, wathi yena ubawa ukuthula, amahlandla alitjhumi. Ngemva kwalokho wagetjelwa ukufa. Woke amanye amaNdebele ama-22 ebekanoNyabela kwadenjwa umlandu wawo ngomhla ka-24 kaKhukhulamungu 1883 babekwa umlandu wokubanga umguruguru nokulwa. Boke njalo bagwetjelwa ukuhlala ejele iminyaka elikhomba nokusebenza budisi.&lt;ref name=&quot;:4&quot;&gt;TAB, SS 852, R.4598 / 83&lt;/ref&gt;

Ngesikhatheso u-Paul Kruger bekangekho asaye e-London bona ayokukhulumisana namaNgisi ngemibandela ye-Pretoria Convention begodu u-Piet Joubert bekamumongameli omjaphethe. Ijaji ebelingamele ngalesosikhathi latlola umbiko emKhandlwini ngomhla ka-1 kuSewula, bese wawuthumela ngo-Sewula 7. Ngemva kobana ijaji lirhunyeze amaqiniso neenkulumopikiswano, watlola  nangomthetho omenze bona akhuphe isigwebo sokufa. Kodwana uJenerali Joubert waveza ebufakazini bakhe bona uthumele uNyabela umlayezo wokuthi nangabe akazithobi uzokudliwa yikule ehloko namkha abulawe yindlala emrhobeni. Kghani uNyabela bekacabanga bona nakangazithoba bekazokusinda? Ngombana msinyana ngemva kwalokho, wazithoba. Wahlongoza bona umKhandlu usicabangele isigwebo sokufa usehlise. UmKhandlu waqunta bona uNyabela akadilikelwe lijele asebenze budisi. Kodwana uMampuru yena khenge acolelwe, yeke walengiswa ngomhla ka-22 kuSinyikhaba 1883. Walengiswa phambi kukaNyabela. Okokuthoma intambo yarathuka wadusuka phasi kabuhlungu ehlabathini. Walengiswa godu msinyana ngemva kwalokho.&lt;ref name=&quot;:3&quot; /&gt;&lt;ref name=&quot;:4&quot; /&gt;

UNyabela watjhaphululwa ejele ngo-1898 wayokuhlala hlanu kwe-Derdepoort ePitori. Wahlongakala ngo-1903. 

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>5eds4chxj5ezwmkiqyixeonslg2ssd4</sha1>
    </revision>
    <revision>
      <id>6692</id>
      <parentid>6411</parentid>
      <timestamp>2026-06-12T07:31:36Z</timestamp>
      <contributor>
        <username>MissHadassah</username>
        <id>1561</id>
      </contributor>
      <minor />
      <comment>changed the spelling of a name</comment>
      <origin>6692</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="13448" sha1="789uojvrlcpjmyqbjsuq7rwe8e24ebv" xml:space="preserve">[[Isimumathi:King Nyabela of the Ndebele Tribe South Africa 1893.jpg|thumb|Ilitje Lesikhumbuzo leNgwenyama uNyabela]]
'''UNyabela''' yiNgwenyama yamaNdebele wakwaNdzundza  eyabusa kusukela ngenyanga kaVelabahlinze 1879 nakukhothama iNgwenyama uRhobongo, walwa ipi namaBhuru eyathoma ngomhlaka-07 kaSinyikhaba 1882 eyaphela ngomhlaka-08 kaVelabahlinze 1883 mhla anikela uMampuru emaBhurwini, kwaba kubotjhwa kwakhe nokuhluleka kwepi yamaNdebele emaBhurwini.&lt;ref name=&quot;:0&quot;&gt;Iziko Lamakhosi - C. J Mahlangu, K. N Mahlangu, M. A Mahlangu, no-S. M Mtshweni&lt;/ref&gt; 

Ngokwencwadi ethi '''Iziko lamaKhosi''', uNyabela  - uGijamphezeni kaMabhoko - yindodana yesithathu yeNgwenyama uMabhoko ebelethwa endlukulu. Kwathi bona kukhothame iNgwenyama uRhobongo ebeyibambele uFene, uNyabela wathatha isihlalo  waraga nokubambela uFene indodana kaMkhephuli ngombana bekasesemncani bona angabusa. Nayiragako ithi ekuthomeni kokubusa kwakhe uNyabela wayenganayo ingubo yobukhosi. Yeke wakhupha intanga yamaDlaza bona iyokufuna ingwe khona kuzokutholakala isikhumba esizokuba yingubo yobukhosi. Owayethwele intanga yamaDlaza ibizo lakhe kwakunguNomacwayi. Bagcina Bayifumene ingwe entabeni yakwaCabha, bayibulala beza nayo ekosini. &lt;ref name=&quot;:0&quot; /&gt;

=== Amadodana weNgwenyama uNyabela ===

* UMtjongweni (uSomphezeni) oliDugu noyindondana ekulu

* UMofu (uSoSenzeni) oliPhogo
* UNgobe oliDuba
* UMpepe (uSovelemu) oliDlowu
* UMzitha (uSoMene) oliSinya
* UMakhabakhubu (uSovusani) oliPhogo
* UPama (uSoMvumazoke) liRhorha
* UZalabo (uSoMlingo) oliDuba
* UMarhagi (uSoZilani) oliRhorha&lt;ref name=&quot;:0&quot; /&gt;

== Isisusa Serarano Phakathi KukaNyabela NamaBhuru ==
[[Isimumathi:LL1882 pg008 SIKUKUNI.jpg|thumb|USekhukhune]]
Ngesikhathi sokubusa kukaNyabela amaBhuru besele athomile ukuzibusa ngombana bewangasekho ngaphasi kokubuswa maNgisi. Yeke, besele kuphethe wona, begodu bekenza koke okusemandlenawo bona alawule iintjhaba zabantu abanzima enarheni khona azokubusa ngendlela ephumelelako.&lt;ref name=&quot;:1&quot;&gt;{{Cite web|title=South African Military History Society - Journal - AN AFRICAN MASADA: Nyabela, Mampuru and the Defence of Mapochstad|url=http://samilitaryhistory.org/vol144ds.html|access-date=2025-05-31|website=samilitaryhistory.org}}&lt;/ref&gt; Soke isikhathesi amaBhuru namaNdebele wakwaNzunza bekanetjhebiswano elihle elathonywa yiNgwenyama uMabhoko. Kodwana kwathi bona amaBhuru athome ukuzibusa itjhebiswano laya lancipha. Isizathu kungaba kukuthi amaNdebele nawo besele afuna ukuzibusa,  UNyabela ubesele angasawubhadeli umthelo emaBhurwini, begodu wala nokuletha isibalo sabantu baboke esitjhabeni,begodu lokho kwawasilinga amaBhuru ngaphasi kombuso we-ZAR.&lt;ref name=&quot;:1&quot; /&gt;

Isisusa esikhulu serarano phakathi kwamaNdebele namaBhuru kwaba nguMampuru. UMampuru bekayikosana yabaPedi eyabelethwa ngo-1824, ayindodana yomnakwabo weKosi uSikwati. USikwati wahlongakala ngo-1861. Lokho kwabanga umraro wokuthi ngubani okufuze alandele ekubeni yiKosi yabaPedi. &lt;ref name=&quot;:2&quot;&gt;{{Cite web|title=Kgoŝi Mampuru II – King of the Pedi people {{!}} Ditsong Museums of South Africa|url=https://ditsong.org.za/en/kgosi-mampuru-ii-king-of-the-pedi-people/|access-date=2025-05-31|website=https://ditsong.org.za/en/|language=en-US}}&lt;/ref&gt; UMampuru wathi uSikwati ukhethe yena bona abe yiKosi ngombana ubelethwa mfazi obeletha ubukhosi, abaPedi abambiza bona yi-''timamollo.'' U-Sekhukhune oyindodana ekulu kaSikwati wathi lokho angekhe kwenzeke njengombana unina kaMampuru omfazi obeletha ubukhosi ukakakhuleliswa yiKosi uSikwati, kodwana mumuntu wangaphandle. Ngaphezu kwalokho wathi uSikwati ubengakaphethi koke okufuze akuphethe nakathatha umfazi oyi-''timamollo''. Yeke isihlalo kufuze sithathwe nguye.&lt;ref&gt;https://en.wikipedia.org/wiki/Mampuru_II&lt;/ref&gt;
U-Sekhukhune wathoma wathatha amandla wobukhosi bewabulala nabeluleki bakaMampuru. UMampuru wagcina sele abalekile kelekhabo. Kwathi ngemva kwesikhathi u-Sekhukhune sele alwe ipi namaBhuru, nenye ipi namaSwati, wahlaselwa esigodlweni sakhe wahlatjwa ngomukhwa wafa ngomhlaka-13 kaRhoboyi 1882. UMampuru nguye owasolwa ngokubulawa kuka-Sekhukhune, wasolwa nangokubanga umguruguru esitjhabeni sabaPedi. Yeke amaBhuru akhipha isiqunto sokuthi uMampuru akabotjhwe khona umguruguru lo uzokuphela.&lt;ref name=&quot;:2&quot; /&gt;[[Isimumathi:Stephanus Johannes Roos.jpg|thumb|UJohannes Roos]]Kuthe bona uMampuru ezwe bona uyafuneka wabaleka esitjhabeni sekhabo wayokukhosela ebantwini bakwaMasimula. AbaPedi bamlandelela nalapho babawa ikosi yakwaMasimula bona ibanikele yena, kodwana yona yala. Kwaba nepi, bakwaMasimula bahlulwa epini leyo. UMampuru nakabona bonyana bakwaMasimula bahluliwe, wabalekela kwaNomtjharhelo eNgwenyameni uNyabela. &lt;ref name=&quot;:0&quot; /&gt;

AbaPedi bafika nakoNomtjharhelo bambawa eNgwenyameni uNyabela. Kuthiwa iKosi uNyabela yathi nayibaphendulako: &quot;UMampuru ngimginyile. Nanimfunako izani ningihlinze isisu nimkhuphe.&quot; Okutjho bona nangabe abaPedi bafuna uMampuru kuzokufuze kuliwe ipi bona atholakale. AbaPedi bakhamba batjhinga emBhurwini babawa isizo lokuthola uMampuru. U-Paul Kruger obekamungameli we-ZAR, wathumela u-Roos noSenekal bona basize abaPedi ngendaba le. AmaBhuru amabili la afika esitjhabeni samaNdebele abawa uMampuru, kodwana uNyabela wala, wathi umginyile, nabamfunako abamkhuphe ngemathunjinakhe. Ekugcineni uNyabela wasilingeka wabulala u-Roos no-Senekal, wathatha iinhloko zabo wazihloma eengodweni. Kuthiwa bekavuka qobe ekuseni akhambe ayokulotjhisa iinhloko zabo aphulule neendevu zazo.&lt;ref name=&quot;:0&quot; /&gt; 

AmaBhuru asilingeka khulu ngesenzwesi athumela u-Piet Joubert namasotja amanengi. Naye wafika warabhela uNyabela amahlandla ambalwa bona akhuphe uMaMpuru kodwana uNyabela wabhala naye, kwaba kusuka kwepi phakathi kwamaNdebele namaBhuru.&lt;ref name=&quot;:1&quot; /&gt;

== Ukuthoma Kwepi YamaNdebele NamaBhuru ==
[[Isimumathi:Pjjoubert.jpg|thumb|UPiet Joubert]]
Ipi yathoma ngomhlaka-7 kuSinyikhaba 1882. Ipi yamaNdebele yayihlome ngeengidi zomsizi nemikhonto, bese yamaBhuru ihlome ngeengidi zeenhlamvu idoswa phambili nguPiet Joubert. Iingidi zeenhlamvu bezidumuza msinya kunalezo zomsizi, yeke inengi lamabutho wamaNdebele lafa ngelangelo, kwathi ngemva kwalokho amaNdebele ahlehla abalekela erholweni. AmaBhuru athi ayangena erholweni abuyela emva ngombana irholo awalazi, yeke atjhida entabeni ayokuhlala emasimini. &lt;ref name=&quot;:0&quot; /&gt; Emalangeni alandelako bebasolo basilwa, kesinye isikhathi amaNdebele afike kungakalindeleki agadle abaleke. Kesinye isikhathi bekafika ebe iinkomo zamakhuwa, kesinye isikhathi babanjwe babulawe. Kwakhe kwaba nesahlakalo lapha amaNdebele athumba iinkomo zamaBhuru, kanti amaBhuru awakalali, abagijimisa abulala amaNdebele ali-150, babuya neenkomo zabo.&lt;ref name=&quot;:1&quot; /&gt;

Isikhathi nasikhambako yahlasela indlala emaNdebeleni. Ukudla ebebakubulungile kwaphela, bathoma ukudla iimphalo eenkhunjeni, kodwana ngokukhamba kwesikhathi iimphalo nazo zaphela. Bathoma bafikelwa mcabango wokuzinikela emaBhurwini, ngapha amaBhuru sebacabanga ukukhamba babuyele emakhaya ngombana sebafikelwa kudinwa. AmaNdebele eza namano wokuthola ukudla.&lt;ref name=&quot;:0&quot; /&gt; Kwakhitjhwa intanga yamaThula bona iyokuthumba iinkomo zabaPedi. Ngebanga lokuthi bebanganamandla ngebanga lokulamba bahlulwa epini leyo.

Kunesikhathi lapha amaNdebele athi akhukhuthisa abafazi bona bayokweba ukudla, kodwana amaBhuru wababulala abafazabo. Kuthiwa abafazaba bakwaMatsitsi, uNoMtjhatjhana noNoMgiyelwa.  Ngesikhatheso bekusolo kuliwa. Kokhunye amaBhuru alinge ukwemba amadwala afuna indlela yokungena erholweni, kodwana amaNzunza afike abahlasele abaliye, nabo bagcine sele bawunghalile umsebenzi loyo. &lt;ref name=&quot;:1&quot; /&gt;

Kwafika isikhathi lapha amaBhuru abuyela khona emva. Athe angakayi nokuyaphi, asemlanjeni iMangwana kwafika indoda yakwaNdala yatjela amaBhuru bona amaNdebele aphelile yindlala, neemphalo nazo ziphelile. AmaBhuru wajika wabuyela emva kwaNomtjharhelo. Bafika batjela iNgwenyama bona ayikhuphe uMampuru. Nangambala yamkhupha yamnikela emaBhurwini ngomhlaka-08 kaVelabahlinze 1883. Ipi le yathatha iinyanga ezibunane zoke. Babotjhwa bobabili uNyabela noMampuru.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt; 

== Ukubotjhwa Nokuhlongakala KukaNyabela ==
Kwathi ngemva kobana uNyabela anikele uMampuru kuJoubert nebutho lakhe naye wabotjhwa ngebanga lokujamelana nebutho likaRhulumende wangesikhatheso nokufihla isilelesi. Ngemva kokubotjhwa kwabo isitjhaba sakhutjhwa ngerholweni, satjelwa bona uNyabela akasese yikosi noNyengelele ikosikazakhe akasese yindlovukazi, kunalokho uPiet Joubert uzokuba yikosi yamaNdebele wakwaNzunza bese ikosikazakhe ibe yindlovukazi. Abavumako baphadlhalajwa bahlukaniswa bona bayokuhlala emaplasini wamaBhuru basebenze khona, labo abangavumiko njengoMatsitsi, uPinda, uSigidi, uNdungulu noMhlangula babotjhwa. Abomma basetjenziselwa ukuhlanza iimpahla zamakhuwa, kwathi abobaba belusa ifuyo yamaBhuru, abanye basebenza emasimini.&lt;ref name=&quot;:0&quot; /&gt;

Umlandu kaMampuru wadenjwa ngomhla ka-17 kaKhukhulamungu 1883, umlandu wokubulala uSekhukhune, ukubanga inturhu nomguruguru, wagwetjelwa ukufa. Kwathi ngomhla ka-21 kuKhukhulamungu 1883 uNyabela wavela phambi komahluleli, iJaji u-JG Kotze nejuri yamadoda wamakhuwa abunane ngomlandu wokobana ususe ukuthula emphakathini walwisana nelawulo ebelisemthethweni leRiphabliki, nokuthi lokho okwenze ngokungemthetho, ngekohliso bewazindla ngakho. Nokobana uqunte ukuthatha iinkhali wahlela ipi yena neenduna zakhe wajamelana nombuso osemthethweni we-ZAR. Obekamjameli wakhe ekhotho owabelwe mbuso wangesikhatheso bekungu-Advocate Cooper, obekamtjhutjhisi kungu-Carl Ueckermann.&lt;ref name=&quot;:3&quot;&gt;TAB, SS 852, R.4598/83, item 293&lt;/ref&gt;

Kwathi bona umlandu kaNyabela ufundwe, u-Advocate Cooper watjela ikhotho bona ukuzivikela kukaNyabela akukhambelani nalokho okufundwe emlandwini ngombana uNyabela bekanganabo ubuhlobo nombuso we-ZAR kodwana bekayikosi ezijameleko yena nabantu bakhe. Lokho kwenza bona kuthiwe uNyabela uthi yena akanamlandu. Kwabizwa abofakazi abasithandathu u-Eduard Bok, u-SP Grové, u-SP Trichard, uJenerali Joubert, uKhomandanti Weilbach no-Kleinbooi (indoda yeNdebele amabhuru amnikele ibizo). U-Joubert uhlulekile ukubika bona uthumele uNyabela imibandela ngaphambi kokwetjiwa kweenkunzi zakhe. U-Kleinbooi khenge abuzwe ngombandela lo.&lt;ref name=&quot;:3&quot; /&gt; 

Into eyalwelwako ekudenjweni komlandu bekukuthi inga-kghani uNyabela usisakhamuzi seRiphabliki namkha awa. Ekuthomeni iRiphabliki beyijame ngesivumelwano esenziwa ngomhla ka-28 kuNtaka 1860 phakathi kukaMabhoko neRiphabliki. Ngaphasi kwesivumelwanesi, uMabhoko uvumile bona usisakhamuzi seRiphabliki. U-Cooper waphendula ubufakazobu ngokuthi isivumelwanesi asimbophi uNyabela. Okwesibili, u-Ueckermann bekanesaziso esivela kuNom. Hercules Robinson, esazisa bona amalungelo neembopho zabo boke abantu abanzima bendabuko enarheni kuzokuhlala kunjalo ngemva kokutlikitlwa kwe-''Pretoria Convention.'' U-Cooper waliphikisa ngelokuthi uNyabela bekangekho nakutlikitlwako e-''Pretoria Convention'' lokha uNomzana Hercules akhuluma namakhosi wendabuko, yeke isivumelwanweso asimbophi uNyabela. Yeke uNyabela uzijamele. U-Ueckermann nakaphendulako wathi ukuthi uNyabela akawubhadeli umthelo embusweni we-ZAR akusibufakazi bokuthi uzijamele. UKleinbooi naye wafakaza ukuthi uNyabela uvumile ku-Shepstone ukuthi bekangaphasi kukaRhulumende, yeke bekufuze abhadele umthelo. Kodwana abamrhononelako khenge baveze ubufakazi obuzwakalako ukuthi uNyabela uthome ipi ngokuthatha iinkunzi zamaBhuru. Ipendulo ebeyizwakala bekungeyaka-Ueckermann ukuthi uNyabela kufuze aphathwe njengesithunjwa sepi nokuthi besele anesikhathi abotjhiwe. Ekugcineni ijaji lathi ngebanga lokuthi uNyabela bekahlala hlanu kweMiddelburg, nangaphakathi kwemikhawulo yeRiphabliki, yeke bekasisakhamuzi seRiphabliki.&lt;ref name=&quot;:3&quot; /&gt; 

Ijuri yatjho yoke bona uNyabela umlandu ngokwayo yoke imilandu abekwe yona. Lokha uNyabela nakabuzwako bona ufuna ukuthini ngaphambi kobana anikelwe isigwebo sentambo, wathi yena ubawa ukuthula, amahlandla alitjhumi. Ngemva kwalokho wagetjelwa ukufa. Woke amanye amaNdebele ama-22 ebekanoNyabela kwadenjwa umlandu wawo ngomhla ka-24 kaKhukhulamungu 1883 babekwa umlandu wokubanga umguruguru nokulwa. Boke njalo bagwetjelwa ukuhlala ejele iminyaka elikhomba nokusebenza budisi.&lt;ref name=&quot;:4&quot;&gt;TAB, SS 852, R.4598 / 83&lt;/ref&gt;

Ngesikhatheso u-Paul Kruger bekangekho asaye e-London bona ayokukhulumisana namaNgisi ngemibandela ye-Pretoria Convention begodu u-Piet Joubert bekamumongameli omjaphethe. Ijaji ebelingamele ngalesosikhathi latlola umbiko emKhandlwini ngomhla ka-1 kuSewula, bese wawuthumela ngo-Sewula 7. Ngemva kobana ijaji lirhunyeze amaqiniso neenkulumopikiswano, watlola  nangomthetho omenze bona akhuphe isigwebo sokufa. Kodwana uJenerali Joubert waveza ebufakazini bakhe bona uthumele uNyabela umlayezo wokuthi nangabe akazithobi uzokudliwa yikule ehloko namkha abulawe yindlala emrhobeni. Kghani uNyabela bekacabanga bona nakangazithoba bekazokusinda? Ngombana msinyana ngemva kwalokho, wazithoba. Wahlongoza bona umKhandlu usicabangele isigwebo sokufa usehlise. UmKhandlu waqunta bona uNyabela akadilikelwe lijele asebenze budisi. Kodwana uMampuru yena khenge acolelwe, yeke walengiswa ngomhla ka-22 kuSinyikhaba 1883. Walengiswa phambi kukaNyabela. Okokuthoma intambo yarathuka wadusuka phasi kabuhlungu ehlabathini. Walengiswa godu msinyana ngemva kwalokho.&lt;ref name=&quot;:3&quot; /&gt;&lt;ref name=&quot;:4&quot; /&gt;

UNyabela watjhaphululwa ejele ngo-1898 wayokuhlala hlanu kwe-Derdepoort ePitori. Wahlongakala ngo-1903. 

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>789uojvrlcpjmyqbjsuq7rwe8e24ebv</sha1>
    </revision>
    <revision>
      <id>6771</id>
      <parentid>6692</parentid>
      <timestamp>2026-08-14T10:26:54Z</timestamp>
      <contributor>
        <username>SandisiweMahlangu</username>
        <id>1620</id>
      </contributor>
      <comment>edit</comment>
      <origin>6771</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="13448" sha1="o59i6s9m9g9shx33aw3gwcykw1ip3wg" xml:space="preserve">[[Isimumathi:King Nyabela of the Ndebele Tribe South Africa 1893.jpg|thumb|Ilitje Lesikhumbuzo leNgwenyama uNyabela]]
'''UNyabela''' yiNgwenyama yamaNdebele wakwaNdzundza  eyabusa kusukela ngenyanga kaVelabahlinze 1879 nakukhothama iNgwenyama uRhobongo, walwa ipi namaBhuru eyathoma ngomhlaka-07 kaSinyikhaba 1882 eyaphela ngomhlaka-08 kaVelabahlinze 1883 mhla anikela uMampuru emaBhurwini, kwaba kubotjhwa kwakhe nokuhluleka kwepi yamaNdebele emaBhurwini.&lt;ref name=&quot;:0&quot;&gt;Iziko Lamakhosi - C. J Mahlangu, K. N Mahlangu, M. A Mahlangu, no-S. M Mtshweni&lt;/ref&gt; 

Ngokwencwadi ethi '''Iziko lamaKhosi''', uNyabela  - uGijamphezeni kaMabhoko - yindodana yesithathu yeNgwenyama uMabhoko ebelethwa endlukulu. Kwathi bona kukhothame iNgwenyama uRhobongo ebeyibambele uFene, uNyabela wathatha isihlalo  waraga nokubambela uFene indodana kaMkhephuli ngombana bekasesemncani bona angabusa. Nayiragako ithi ekuthomeni kokubusa kwakhe uNyabela wayenganayo ingubo yobukhosi. Yeke wakhupha intanga yamaDlaza bona iyokufuna ingwe khona kuzokutholakala isikhumba esizokuba yingubo yobukhosi. Owayethwele intanga yamaDlaza ibizo lakhe kwakunguNomacwayi. Bagcina Bayifumene ingwe entabeni yakwaCabha, bayibulala beza nayo ekosini. &lt;ref name=&quot;:0&quot; /&gt;

=== Amadodana WeNgwenyama UNyabela ===

* UMtjongweni (uSomphezeni) oliDugu noyindondana ekulu

* UMofu (uSoSenzeni) oliPhogo
* UNgobe oliDuba
* UMpepe (uSovelemu) oliDlowu
* UMzitha (uSoMene) oliSinya
* UMakhabakhubu (uSovusani) oliPhogo
* UPama (uSoMvumazoke) liRhorha
* UZalabo (uSoMlingo) oliDuba
* UMarhagi (uSoZilani) oliRhorha&lt;ref name=&quot;:0&quot; /&gt;

== Isisusa Serarano Phakathi KukaNyabela NamaBhuru ==
[[Isimumathi:LL1882 pg008 SIKUKUNI.jpg|thumb|USekhukhune]]
Ngesikhathi sokubusa kukaNyabela amaBhuru besele athomile ukuzibusa ngombana bewangasekho ngaphasi kokubuswa maNgisi. Yeke, besele kuphethe wona, begodu bekenza koke okusemandlenawo bona alawule iintjhaba zabantu abanzima enarheni khona azokubusa ngendlela ephumelelako.&lt;ref name=&quot;:1&quot;&gt;{{Cite web|title=South African Military History Society - Journal - AN AFRICAN MASADA: Nyabela, Mampuru and the Defence of Mapochstad|url=http://samilitaryhistory.org/vol144ds.html|access-date=2025-05-31|website=samilitaryhistory.org}}&lt;/ref&gt; Soke isikhathesi amaBhuru namaNdebele wakwaNzunza bekanetjhebiswano elihle elathonywa yiNgwenyama uMabhoko. Kodwana kwathi bona amaBhuru athome ukuzibusa itjhebiswano laya lancipha. Isizathu kungaba kukuthi amaNdebele nawo besele afuna ukuzibusa,  UNyabela ubesele angasawubhadeli umthelo emaBhurwini, begodu wala nokuletha isibalo sabantu baboke esitjhabeni,begodu lokho kwawasilinga amaBhuru ngaphasi kombuso we-ZAR.&lt;ref name=&quot;:1&quot; /&gt;

Isisusa esikhulu serarano phakathi kwamaNdebele namaBhuru kwaba nguMampuru. UMampuru bekayikosana yabaPedi eyabelethwa ngo-1824, ayindodana yomnakwabo weKosi uSikwati. USikwati wahlongakala ngo-1861. Lokho kwabanga umraro wokuthi ngubani okufuze alandele ekubeni yiKosi yabaPedi. &lt;ref name=&quot;:2&quot;&gt;{{Cite web|title=Kgoŝi Mampuru II – King of the Pedi people {{!}} Ditsong Museums of South Africa|url=https://ditsong.org.za/en/kgosi-mampuru-ii-king-of-the-pedi-people/|access-date=2025-05-31|website=https://ditsong.org.za/en/|language=en-US}}&lt;/ref&gt; UMampuru wathi uSikwati ukhethe yena bona abe yiKosi ngombana ubelethwa mfazi obeletha ubukhosi, abaPedi abambiza bona yi-''timamollo.'' U-Sekhukhune oyindodana ekulu kaSikwati wathi lokho angekhe kwenzeke njengombana unina kaMampuru omfazi obeletha ubukhosi ukakakhuleliswa yiKosi uSikwati, kodwana mumuntu wangaphandle. Ngaphezu kwalokho wathi uSikwati ubengakaphethi koke okufuze akuphethe nakathatha umfazi oyi-''timamollo''. Yeke isihlalo kufuze sithathwe nguye.&lt;ref&gt;https://en.wikipedia.org/wiki/Mampuru_II&lt;/ref&gt;
U-Sekhukhune wathoma wathatha amandla wobukhosi bewabulala nabeluleki bakaMampuru. UMampuru wagcina sele abalekile kelekhabo. Kwathi ngemva kwesikhathi u-Sekhukhune sele alwe ipi namaBhuru, nenye ipi namaSwati, wahlaselwa esigodlweni sakhe wahlatjwa ngomukhwa wafa ngomhlaka-13 kaRhoboyi 1882. UMampuru nguye owasolwa ngokubulawa kuka-Sekhukhune, wasolwa nangokubanga umguruguru esitjhabeni sabaPedi. Yeke amaBhuru akhipha isiqunto sokuthi uMampuru akabotjhwe khona umguruguru lo uzokuphela.&lt;ref name=&quot;:2&quot; /&gt;[[Isimumathi:Stephanus Johannes Roos.jpg|thumb|UJohannes Roos]]Kuthe bona uMampuru ezwe bona uyafuneka wabaleka esitjhabeni sekhabo wayokukhosela ebantwini bakwaMasimula. AbaPedi bamlandelela nalapho babawa ikosi yakwaMasimula bona ibanikele yena, kodwana yona yala. Kwaba nepi, bakwaMasimula bahlulwa epini leyo. UMampuru nakabona bonyana bakwaMasimula bahluliwe, wabalekela kwaNomtjharhelo eNgwenyameni uNyabela. &lt;ref name=&quot;:0&quot; /&gt;

AbaPedi bafika nakoNomtjharhelo bambawa eNgwenyameni uNyabela. Kuthiwa iKosi uNyabela yathi nayibaphendulako: &quot;UMampuru ngimginyile. Nanimfunako izani ningihlinze isisu nimkhuphe.&quot; Okutjho bona nangabe abaPedi bafuna uMampuru kuzokufuze kuliwe ipi bona atholakale. AbaPedi bakhamba batjhinga emBhurwini babawa isizo lokuthola uMampuru. U-Paul Kruger obekamungameli we-ZAR, wathumela u-Roos noSenekal bona basize abaPedi ngendaba le. AmaBhuru amabili la afika esitjhabeni samaNdebele abawa uMampuru, kodwana uNyabela wala, wathi umginyile, nabamfunako abamkhuphe ngemathunjinakhe. Ekugcineni uNyabela wasilingeka wabulala u-Roos no-Senekal, wathatha iinhloko zabo wazihloma eengodweni. Kuthiwa bekavuka qobe ekuseni akhambe ayokulotjhisa iinhloko zabo aphulule neendevu zazo.&lt;ref name=&quot;:0&quot; /&gt; 

AmaBhuru asilingeka khulu ngesenzwesi athumela u-Piet Joubert namasotja amanengi. Naye wafika warabhela uNyabela amahlandla ambalwa bona akhuphe uMaMpuru kodwana uNyabela wabhala naye, kwaba kusuka kwepi phakathi kwamaNdebele namaBhuru.&lt;ref name=&quot;:1&quot; /&gt;

== Ukuthoma Kwepi YamaNdebele NamaBhuru ==
[[Isimumathi:Pjjoubert.jpg|thumb|UPiet Joubert]]
Ipi yathoma ngomhlaka-7 kuSinyikhaba 1882. Ipi yamaNdebele yayihlome ngeengidi zomsizi nemikhonto, bese yamaBhuru ihlome ngeengidi zeenhlamvu idoswa phambili nguPiet Joubert. Iingidi zeenhlamvu bezidumuza msinya kunalezo zomsizi, yeke inengi lamabutho wamaNdebele lafa ngelangelo, kwathi ngemva kwalokho amaNdebele ahlehla abalekela erholweni. AmaBhuru athi ayangena erholweni abuyela emva ngombana irholo awalazi, yeke atjhida entabeni ayokuhlala emasimini. &lt;ref name=&quot;:0&quot; /&gt; Emalangeni alandelako bebasolo basilwa, kesinye isikhathi amaNdebele afike kungakalindeleki agadle abaleke. Kesinye isikhathi bekafika ebe iinkomo zamakhuwa, kesinye isikhathi babanjwe babulawe. Kwakhe kwaba nesahlakalo lapha amaNdebele athumba iinkomo zamaBhuru, kanti amaBhuru awakalali, abagijimisa abulala amaNdebele ali-150, babuya neenkomo zabo.&lt;ref name=&quot;:1&quot; /&gt;

Isikhathi nasikhambako yahlasela indlala emaNdebeleni. Ukudla ebebakubulungile kwaphela, bathoma ukudla iimphalo eenkhunjeni, kodwana ngokukhamba kwesikhathi iimphalo nazo zaphela. Bathoma bafikelwa mcabango wokuzinikela emaBhurwini, ngapha amaBhuru sebacabanga ukukhamba babuyele emakhaya ngombana sebafikelwa kudinwa. AmaNdebele eza namano wokuthola ukudla.&lt;ref name=&quot;:0&quot; /&gt; Kwakhitjhwa intanga yamaThula bona iyokuthumba iinkomo zabaPedi. Ngebanga lokuthi bebanganamandla ngebanga lokulamba bahlulwa epini leyo.

Kunesikhathi lapha amaNdebele athi akhukhuthisa abafazi bona bayokweba ukudla, kodwana amaBhuru wababulala abafazabo. Kuthiwa abafazaba bakwaMatsitsi, uNoMtjhatjhana noNoMgiyelwa.  Ngesikhatheso bekusolo kuliwa. Kokhunye amaBhuru alinge ukwemba amadwala afuna indlela yokungena erholweni, kodwana amaNzunza afike abahlasele abaliye, nabo bagcine sele bawunghalile umsebenzi loyo. &lt;ref name=&quot;:1&quot; /&gt;

Kwafika isikhathi lapha amaBhuru abuyela khona emva. Athe angakayi nokuyaphi, asemlanjeni iMangwana kwafika indoda yakwaNdala yatjela amaBhuru bona amaNdebele aphelile yindlala, neemphalo nazo ziphelile. AmaBhuru wajika wabuyela emva kwaNomtjharhelo. Bafika batjela iNgwenyama bona ayikhuphe uMampuru. Nangambala yamkhupha yamnikela emaBhurwini ngomhlaka-08 kaVelabahlinze 1883. Ipi le yathatha iinyanga ezibunane zoke. Babotjhwa bobabili uNyabela noMampuru.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt; 

== Ukubotjhwa Nokuhlongakala KukaNyabela ==
Kwathi ngemva kobana uNyabela anikele uMampuru kuJoubert nebutho lakhe naye wabotjhwa ngebanga lokujamelana nebutho likaRhulumende wangesikhatheso nokufihla isilelesi. Ngemva kokubotjhwa kwabo isitjhaba sakhutjhwa ngerholweni, satjelwa bona uNyabela akasese yikosi noNyengelele ikosikazakhe akasese yindlovukazi, kunalokho uPiet Joubert uzokuba yikosi yamaNdebele wakwaNzunza bese ikosikazakhe ibe yindlovukazi. Abavumako baphadlhalajwa bahlukaniswa bona bayokuhlala emaplasini wamaBhuru basebenze khona, labo abangavumiko njengoMatsitsi, uPinda, uSigidi, uNdungulu noMhlangula babotjhwa. Abomma basetjenziselwa ukuhlanza iimpahla zamakhuwa, kwathi abobaba belusa ifuyo yamaBhuru, abanye basebenza emasimini.&lt;ref name=&quot;:0&quot; /&gt;

Umlandu kaMampuru wadenjwa ngomhla ka-17 kaKhukhulamungu 1883, umlandu wokubulala uSekhukhune, ukubanga inturhu nomguruguru, wagwetjelwa ukufa. Kwathi ngomhla ka-21 kuKhukhulamungu 1883 uNyabela wavela phambi komahluleli, iJaji u-JG Kotze nejuri yamadoda wamakhuwa abunane ngomlandu wokobana ususe ukuthula emphakathini walwisana nelawulo ebelisemthethweni leRiphabliki, nokuthi lokho okwenze ngokungemthetho, ngekohliso bewazindla ngakho. Nokobana uqunte ukuthatha iinkhali wahlela ipi yena neenduna zakhe wajamelana nombuso osemthethweni we-ZAR. Obekamjameli wakhe ekhotho owabelwe mbuso wangesikhatheso bekungu-Advocate Cooper, obekamtjhutjhisi kungu-Carl Ueckermann.&lt;ref name=&quot;:3&quot;&gt;TAB, SS 852, R.4598/83, item 293&lt;/ref&gt;

Kwathi bona umlandu kaNyabela ufundwe, u-Advocate Cooper watjela ikhotho bona ukuzivikela kukaNyabela akukhambelani nalokho okufundwe emlandwini ngombana uNyabela bekanganabo ubuhlobo nombuso we-ZAR kodwana bekayikosi ezijameleko yena nabantu bakhe. Lokho kwenza bona kuthiwe uNyabela uthi yena akanamlandu. Kwabizwa abofakazi abasithandathu u-Eduard Bok, u-SP Grové, u-SP Trichard, uJenerali Joubert, uKhomandanti Weilbach no-Kleinbooi (indoda yeNdebele amabhuru amnikele ibizo). U-Joubert uhlulekile ukubika bona uthumele uNyabela imibandela ngaphambi kokwetjiwa kweenkunzi zakhe. U-Kleinbooi khenge abuzwe ngombandela lo.&lt;ref name=&quot;:3&quot; /&gt; 

Into eyalwelwako ekudenjweni komlandu bekukuthi inga-kghani uNyabela usisakhamuzi seRiphabliki namkha awa. Ekuthomeni iRiphabliki beyijame ngesivumelwano esenziwa ngomhla ka-28 kuNtaka 1860 phakathi kukaMabhoko neRiphabliki. Ngaphasi kwesivumelwanesi, uMabhoko uvumile bona usisakhamuzi seRiphabliki. U-Cooper waphendula ubufakazobu ngokuthi isivumelwanesi asimbophi uNyabela. Okwesibili, u-Ueckermann bekanesaziso esivela kuNom. Hercules Robinson, esazisa bona amalungelo neembopho zabo boke abantu abanzima bendabuko enarheni kuzokuhlala kunjalo ngemva kokutlikitlwa kwe-''Pretoria Convention.'' U-Cooper waliphikisa ngelokuthi uNyabela bekangekho nakutlikitlwako e-''Pretoria Convention'' lokha uNomzana Hercules akhuluma namakhosi wendabuko, yeke isivumelwanweso asimbophi uNyabela. Yeke uNyabela uzijamele. U-Ueckermann nakaphendulako wathi ukuthi uNyabela akawubhadeli umthelo embusweni we-ZAR akusibufakazi bokuthi uzijamele. UKleinbooi naye wafakaza ukuthi uNyabela uvumile ku-Shepstone ukuthi bekangaphasi kukaRhulumende, yeke bekufuze abhadele umthelo. Kodwana abamrhononelako khenge baveze ubufakazi obuzwakalako ukuthi uNyabela uthome ipi ngokuthatha iinkunzi zamaBhuru. Ipendulo ebeyizwakala bekungeyaka-Ueckermann ukuthi uNyabela kufuze aphathwe njengesithunjwa sepi nokuthi besele anesikhathi abotjhiwe. Ekugcineni ijaji lathi ngebanga lokuthi uNyabela bekahlala hlanu kweMiddelburg, nangaphakathi kwemikhawulo yeRiphabliki, yeke bekasisakhamuzi seRiphabliki.&lt;ref name=&quot;:3&quot; /&gt; 

Ijuri yatjho yoke bona uNyabela umlandu ngokwayo yoke imilandu abekwe yona. Lokha uNyabela nakabuzwako bona ufuna ukuthini ngaphambi kobana anikelwe isigwebo sentambo, wathi yena ubawa ukuthula, amahlandla alitjhumi. Ngemva kwalokho wagetjelwa ukufa. Woke amanye amaNdebele ama-22 ebekanoNyabela kwadenjwa umlandu wawo ngomhla ka-24 kaKhukhulamungu 1883 babekwa umlandu wokubanga umguruguru nokulwa. Boke njalo bagwetjelwa ukuhlala ejele iminyaka elikhomba nokusebenza budisi.&lt;ref name=&quot;:4&quot;&gt;TAB, SS 852, R.4598 / 83&lt;/ref&gt;

Ngesikhatheso u-Paul Kruger bekangekho asaye e-London bona ayokukhulumisana namaNgisi ngemibandela ye-Pretoria Convention begodu u-Piet Joubert bekamumongameli omjaphethe. Ijaji ebelingamele ngalesosikhathi latlola umbiko emKhandlwini ngomhla ka-1 kuSewula, bese wawuthumela ngo-Sewula 7. Ngemva kobana ijaji lirhunyeze amaqiniso neenkulumopikiswano, watlola  nangomthetho omenze bona akhuphe isigwebo sokufa. Kodwana uJenerali Joubert waveza ebufakazini bakhe bona uthumele uNyabela umlayezo wokuthi nangabe akazithobi uzokudliwa yikule ehloko namkha abulawe yindlala emrhobeni. Kghani uNyabela bekacabanga bona nakangazithoba bekazokusinda? Ngombana msinyana ngemva kwalokho, wazithoba. Wahlongoza bona umKhandlu usicabangele isigwebo sokufa usehlise. UmKhandlu waqunta bona uNyabela akadilikelwe lijele asebenze budisi. Kodwana uMampuru yena khenge acolelwe, yeke walengiswa ngomhla ka-22 kuSinyikhaba 1883. Walengiswa phambi kukaNyabela. Okokuthoma intambo yarathuka wadusuka phasi kabuhlungu ehlabathini. Walengiswa godu msinyana ngemva kwalokho.&lt;ref name=&quot;:3&quot; /&gt;&lt;ref name=&quot;:4&quot; /&gt;

UNyabela watjhaphululwa ejele ngo-1898 wayokuhlala hlanu kwe-Derdepoort ePitori. Wahlongakala ngo-1903. 

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>o59i6s9m9g9shx33aw3gwcykw1ip3wg</sha1>
    </revision>
    <revision>
      <id>6772</id>
      <parentid>6771</parentid>
      <timestamp>2026-08-14T10:35:15Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <comment>Fixed grammar</comment>
      <origin>6772</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="13514" sha1="2ytsijug6hxdcpf8kua4vpjhy80ws5k" xml:space="preserve">[[Isimumathi:King Nyabela of the Ndebele Tribe South Africa 1893.jpg|thumb|Ilitje Lesikhumbuzo leNgwenyama uNyabela]]
'''UNyabela''' yiNgwenyama yamaNdebele wakwaNzunza  eyabusa kusukela ngenyanga kaVelabahlinze 1879 nakukhothama iNgwenyama uRhobongo, walwa ipi namaBhuru eyathoma mhla amalanga alikhomba  enyangeni kaSinyikhaba ngomnyaka we-1882 eyaphela mhla amalanga abunane enyangeni kaVelabahlinze ngomnyaka we-1883 mhla anikela uMampuru emaBhurwini, kwaba kubotjhwa kwakhe nokuhluleka kwepi yamaNdebele emaBhurwini.&lt;ref name=&quot;:0&quot;&gt;Iziko Lamakhosi - C. J Mahlangu, K. N Mahlangu, M. A Mahlangu, no-S. M Mtshweni&lt;/ref&gt; 

Ngokwencwadi ethi '''Iziko lamaKhosi''', uNyabela  - uGijamphezeni kaMabhoko - yindodana yesithathu yeNgwenyama uMabhoko ebelethwa endlukulu. Kwathi bona kukhothame iNgwenyama uRhobongo ebeyibambele uFene, uNyabela wathatha isihlalo  waraga nokubambela uFene indodana kaMkhephuli ngombana bekasesemncani bona angabusa. Nayiragako ithi ekuthomeni kokubusa kwakhe uNyabela wayenganayo ingubo yobukhosi. Ye-ke wakhupha intanga yamaDlaza bona iyokufuna ingwe khona kuzokutholakala isikhumba esizokuba yingubo yobukhosi. Owayethwele intanga yamaDlaza ibizo lakhe kwakunguNomacwayi. Bagcina Bayifumene ingwe entabeni yakwaCabha, bayibulala beza nayo ekosini. &lt;ref name=&quot;:0&quot; /&gt;

=== Amadodana WeNgwenyama UNyabela ===

* UMtjongweni (uSomphezeni) oliDugu noyindondana ekulu

* UMofu (uSoSenzeni) oliPhogo
* UNgobe oliDuba
* UMpepe (uSovelemu) oliDlowu
* UMzitha (uSoMene) oliSinya
* UMakhabakhubu (uSovusani) oliPhogo
* UPama (uSoMvumazoke) liRhorha
* UZalabo (uSoMlingo) oliDuba
* UMarhagi (uSoZilani) oliRhorha&lt;ref name=&quot;:0&quot; /&gt;

== Isisusa Serarano Phakathi KukaNyabela NamaBhuru ==
[[Isimumathi:LL1882 pg008 SIKUKUNI.jpg|thumb|USekhukhune]]
Ngesikhathi sokubusa kukaNyabela amaBhuru besele athomile ukuzibusa ngombana bewangasekho ngaphasi kokubuswa maNgisi. Yeke, besele kuphethe wona, begodu bekenza koke okusemandlenawo bona alawule iintjhaba zabantu abanzima enarheni khona azokubusa ngendlela ephumelelako.&lt;ref name=&quot;:1&quot;&gt;{{Cite web|title=South African Military History Society - Journal - AN AFRICAN MASADA: Nyabela, Mampuru and the Defence of Mapochstad|url=http://samilitaryhistory.org/vol144ds.html|access-date=2025-05-31|website=samilitaryhistory.org}}&lt;/ref&gt; Soke isikhathesi amaBhuru namaNdebele wakwaNzunza bekanetjhebiswano elihle elathonywa yiNgwenyama uMabhoko. Kodwana kwathi bona amaBhuru athome ukuzibusa itjhebiswano laya lancipha. Isizathu kungaba kukuthi amaNdebele nawo besele afuna ukuzibusa,  UNyabela ubesele angasawubhadeli umthelo emaBhurwini, begodu wala nokuletha isibalo sabantu baboke esitjhabeni,begodu lokho kwawasilinga amaBhuru ngaphasi kombuso we-ZAR.&lt;ref name=&quot;:1&quot; /&gt;

Isisusa esikhulu serarano phakathi kwamaNdebele namaBhuru kwaba nguMampuru. UMampuru bekayikosana yabaPedi eyabelethwa ngo-1824, ayindodana yomnakwabo weKosi uSikwati. USikwati wahlongakala ngo-1861. Lokho kwabanga umraro wokuthi ngubani okufuze alandele ekubeni yiKosi yabaPedi. &lt;ref name=&quot;:2&quot;&gt;{{Cite web|title=Kgoŝi Mampuru II – King of the Pedi people {{!}} Ditsong Museums of South Africa|url=https://ditsong.org.za/en/kgosi-mampuru-ii-king-of-the-pedi-people/|access-date=2025-05-31|website=https://ditsong.org.za/en/|language=en-US}}&lt;/ref&gt; UMampuru wathi uSikwati ukhethe yena bona abe yiKosi ngombana ubelethwa mfazi obeletha ubukhosi, abaPedi abambiza bona yi-''timamollo.'' U-Sekhukhune oyindodana ekulu kaSikwati wathi lokho angekhe kwenzeke njengombana unina kaMampuru omfazi obeletha ubukhosi ukakakhuleliswa yiKosi uSikwati, kodwana mumuntu wangaphandle. Ngaphezu kwalokho wathi uSikwati ubengakaphethi koke okufuze akuphethe nakathatha umfazi oyi-''timamollo''. Yeke isihlalo kufuze sithathwe nguye.&lt;ref&gt;https://en.wikipedia.org/wiki/Mampuru_II&lt;/ref&gt;
U-Sekhukhune wathoma wathatha amandla wobukhosi bewabulala nabeluleki bakaMampuru. UMampuru wagcina sele abalekile kelekhabo. Kwathi ngemva kwesikhathi u-Sekhukhune sele alwe ipi namaBhuru, nenye ipi namaSwati, wahlaselwa esigodlweni sakhe wahlatjwa ngomukhwa wafa ngomhlaka-13 kaRhoboyi 1882. UMampuru nguye owasolwa ngokubulawa kuka-Sekhukhune, wasolwa nangokubanga umguruguru esitjhabeni sabaPedi. Yeke amaBhuru akhipha isiqunto sokuthi uMampuru akabotjhwe khona umguruguru lo uzokuphela.&lt;ref name=&quot;:2&quot; /&gt;[[Isimumathi:Stephanus Johannes Roos.jpg|thumb|UJohannes Roos]]Kuthe bona uMampuru ezwe bona uyafuneka wabaleka esitjhabeni sekhabo wayokukhosela ebantwini bakwaMasimula. AbaPedi bamlandelela nalapho babawa ikosi yakwaMasimula bona ibanikele yena, kodwana yona yala. Kwaba nepi, bakwaMasimula bahlulwa epini leyo. UMampuru nakabona bonyana bakwaMasimula bahluliwe, wabalekela kwaNomtjharhelo eNgwenyameni uNyabela. &lt;ref name=&quot;:0&quot; /&gt;

AbaPedi bafika nakoNomtjharhelo bambawa eNgwenyameni uNyabela. Kuthiwa iKosi uNyabela yathi nayibaphendulako: &quot;UMampuru ngimginyile. Nanimfunako izani ningihlinze isisu nimkhuphe.&quot; Okutjho bona nangabe abaPedi bafuna uMampuru kuzokufuze kuliwe ipi bona atholakale. AbaPedi bakhamba batjhinga emBhurwini babawa isizo lokuthola uMampuru. U-Paul Kruger obekamungameli we-ZAR, wathumela u-Roos noSenekal bona basize abaPedi ngendaba le. AmaBhuru amabili la afika esitjhabeni samaNdebele abawa uMampuru, kodwana uNyabela wala, wathi umginyile, nabamfunako abamkhuphe ngemathunjinakhe. Ekugcineni uNyabela wasilingeka wabulala u-Roos no-Senekal, wathatha iinhloko zabo wazihloma eengodweni. Kuthiwa bekavuka qobe ekuseni akhambe ayokulotjhisa iinhloko zabo aphulule neendevu zazo.&lt;ref name=&quot;:0&quot; /&gt; 

AmaBhuru asilingeka khulu ngesenzwesi athumela u-Piet Joubert namasotja amanengi. Naye wafika warabhela uNyabela amahlandla ambalwa bona akhuphe uMaMpuru kodwana uNyabela wabhala naye, kwaba kusuka kwepi phakathi kwamaNdebele namaBhuru.&lt;ref name=&quot;:1&quot; /&gt;

== Ukuthoma Kwepi YamaNdebele NamaBhuru ==
[[Isimumathi:Pjjoubert.jpg|thumb|UPiet Joubert]]
Ipi yathoma ngomhlaka-7 kuSinyikhaba 1882. Ipi yamaNdebele yayihlome ngeengidi zomsizi nemikhonto, bese yamaBhuru ihlome ngeengidi zeenhlamvu idoswa phambili nguPiet Joubert. Iingidi zeenhlamvu bezidumuza msinya kunalezo zomsizi, yeke inengi lamabutho wamaNdebele lafa ngelangelo, kwathi ngemva kwalokho amaNdebele ahlehla abalekela erholweni. AmaBhuru athi ayangena erholweni abuyela emva ngombana irholo awalazi, yeke atjhida entabeni ayokuhlala emasimini. &lt;ref name=&quot;:0&quot; /&gt; Emalangeni alandelako bebasolo basilwa, kesinye isikhathi amaNdebele afike kungakalindeleki agadle abaleke. Kesinye isikhathi bekafika ebe iinkomo zamakhuwa, kesinye isikhathi babanjwe babulawe. Kwakhe kwaba nesahlakalo lapha amaNdebele athumba iinkomo zamaBhuru, kanti amaBhuru awakalali, abagijimisa abulala amaNdebele ali-150, babuya neenkomo zabo.&lt;ref name=&quot;:1&quot; /&gt;

Isikhathi nasikhambako yahlasela indlala emaNdebeleni. Ukudla ebebakubulungile kwaphela, bathoma ukudla iimphalo eenkhunjeni, kodwana ngokukhamba kwesikhathi iimphalo nazo zaphela. Bathoma bafikelwa mcabango wokuzinikela emaBhurwini, ngapha amaBhuru sebacabanga ukukhamba babuyele emakhaya ngombana sebafikelwa kudinwa. AmaNdebele eza namano wokuthola ukudla.&lt;ref name=&quot;:0&quot; /&gt; Kwakhitjhwa intanga yamaThula bona iyokuthumba iinkomo zabaPedi. Ngebanga lokuthi bebanganamandla ngebanga lokulamba bahlulwa epini leyo.

Kunesikhathi lapha amaNdebele athi akhukhuthisa abafazi bona bayokweba ukudla, kodwana amaBhuru wababulala abafazabo. Kuthiwa abafazaba bakwaMatsitsi, uNoMtjhatjhana noNoMgiyelwa.  Ngesikhatheso bekusolo kuliwa. Kokhunye amaBhuru alinge ukwemba amadwala afuna indlela yokungena erholweni, kodwana amaNzunza afike abahlasele abaliye, nabo bagcine sele bawunghalile umsebenzi loyo. &lt;ref name=&quot;:1&quot; /&gt;

Kwafika isikhathi lapha amaBhuru abuyela khona emva. Athe angakayi nokuyaphi, asemlanjeni iMangwana kwafika indoda yakwaNdala yatjela amaBhuru bona amaNdebele aphelile yindlala, neemphalo nazo ziphelile. AmaBhuru wajika wabuyela emva kwaNomtjharhelo. Bafika batjela iNgwenyama bona ayikhuphe uMampuru. Nangambala yamkhupha yamnikela emaBhurwini ngomhlaka-08 kaVelabahlinze 1883. Ipi le yathatha iinyanga ezibunane zoke. Babotjhwa bobabili uNyabela noMampuru.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt; 

== Ukubotjhwa Nokuhlongakala KukaNyabela ==
Kwathi ngemva kobana uNyabela anikele uMampuru kuJoubert nebutho lakhe naye wabotjhwa ngebanga lokujamelana nebutho likaRhulumende wangesikhatheso nokufihla isilelesi. Ngemva kokubotjhwa kwabo isitjhaba sakhutjhwa ngerholweni, satjelwa bona uNyabela akasese yikosi noNyengelele ikosikazakhe akasese yindlovukazi, kunalokho uPiet Joubert uzokuba yikosi yamaNdebele wakwaNzunza bese ikosikazakhe ibe yindlovukazi. Abavumako baphadlhalajwa bahlukaniswa bona bayokuhlala emaplasini wamaBhuru basebenze khona, labo abangavumiko njengoMatsitsi, uPinda, uSigidi, uNdungulu noMhlangula babotjhwa. Abomma basetjenziselwa ukuhlanza iimpahla zamakhuwa, kwathi abobaba belusa ifuyo yamaBhuru, abanye basebenza emasimini.&lt;ref name=&quot;:0&quot; /&gt;

Umlandu kaMampuru wadenjwa ngomhla ka-17 kaKhukhulamungu 1883, umlandu wokubulala uSekhukhune, ukubanga inturhu nomguruguru, wagwetjelwa ukufa. Kwathi ngomhla ka-21 kuKhukhulamungu 1883 uNyabela wavela phambi komahluleli, iJaji u-JG Kotze nejuri yamadoda wamakhuwa abunane ngomlandu wokobana ususe ukuthula emphakathini walwisana nelawulo ebelisemthethweni leRiphabliki, nokuthi lokho okwenze ngokungemthetho, ngekohliso bewazindla ngakho. Nokobana uqunte ukuthatha iinkhali wahlela ipi yena neenduna zakhe wajamelana nombuso osemthethweni we-ZAR. Obekamjameli wakhe ekhotho owabelwe mbuso wangesikhatheso bekungu-Advocate Cooper, obekamtjhutjhisi kungu-Carl Ueckermann.&lt;ref name=&quot;:3&quot;&gt;TAB, SS 852, R.4598/83, item 293&lt;/ref&gt;

Kwathi bona umlandu kaNyabela ufundwe, u-Advocate Cooper watjela ikhotho bona ukuzivikela kukaNyabela akukhambelani nalokho okufundwe emlandwini ngombana uNyabela bekanganabo ubuhlobo nombuso we-ZAR kodwana bekayikosi ezijameleko yena nabantu bakhe. Lokho kwenza bona kuthiwe uNyabela uthi yena akanamlandu. Kwabizwa abofakazi abasithandathu u-Eduard Bok, u-SP Grové, u-SP Trichard, uJenerali Joubert, uKhomandanti Weilbach no-Kleinbooi (indoda yeNdebele amabhuru amnikele ibizo). U-Joubert uhlulekile ukubika bona uthumele uNyabela imibandela ngaphambi kokwetjiwa kweenkunzi zakhe. U-Kleinbooi khenge abuzwe ngombandela lo.&lt;ref name=&quot;:3&quot; /&gt; 

Into eyalwelwako ekudenjweni komlandu bekukuthi inga-kghani uNyabela usisakhamuzi seRiphabliki namkha awa. Ekuthomeni iRiphabliki beyijame ngesivumelwano esenziwa ngomhla ka-28 kuNtaka 1860 phakathi kukaMabhoko neRiphabliki. Ngaphasi kwesivumelwanesi, uMabhoko uvumile bona usisakhamuzi seRiphabliki. U-Cooper waphendula ubufakazobu ngokuthi isivumelwanesi asimbophi uNyabela. Okwesibili, u-Ueckermann bekanesaziso esivela kuNom. Hercules Robinson, esazisa bona amalungelo neembopho zabo boke abantu abanzima bendabuko enarheni kuzokuhlala kunjalo ngemva kokutlikitlwa kwe-''Pretoria Convention.'' U-Cooper waliphikisa ngelokuthi uNyabela bekangekho nakutlikitlwako e-''Pretoria Convention'' lokha uNomzana Hercules akhuluma namakhosi wendabuko, yeke isivumelwanweso asimbophi uNyabela. Yeke uNyabela uzijamele. U-Ueckermann nakaphendulako wathi ukuthi uNyabela akawubhadeli umthelo embusweni we-ZAR akusibufakazi bokuthi uzijamele. UKleinbooi naye wafakaza ukuthi uNyabela uvumile ku-Shepstone ukuthi bekangaphasi kukaRhulumende, yeke bekufuze abhadele umthelo. Kodwana abamrhononelako khenge baveze ubufakazi obuzwakalako ukuthi uNyabela uthome ipi ngokuthatha iinkunzi zamaBhuru. Ipendulo ebeyizwakala bekungeyaka-Ueckermann ukuthi uNyabela kufuze aphathwe njengesithunjwa sepi nokuthi besele anesikhathi abotjhiwe. Ekugcineni ijaji lathi ngebanga lokuthi uNyabela bekahlala hlanu kweMiddelburg, nangaphakathi kwemikhawulo yeRiphabliki, yeke bekasisakhamuzi seRiphabliki.&lt;ref name=&quot;:3&quot; /&gt; 

Ijuri yatjho yoke bona uNyabela umlandu ngokwayo yoke imilandu abekwe yona. Lokha uNyabela nakabuzwako bona ufuna ukuthini ngaphambi kobana anikelwe isigwebo sentambo, wathi yena ubawa ukuthula, amahlandla alitjhumi. Ngemva kwalokho wagetjelwa ukufa. Woke amanye amaNdebele ama-22 ebekanoNyabela kwadenjwa umlandu wawo ngomhla ka-24 kaKhukhulamungu 1883 babekwa umlandu wokubanga umguruguru nokulwa. Boke njalo bagwetjelwa ukuhlala ejele iminyaka elikhomba nokusebenza budisi.&lt;ref name=&quot;:4&quot;&gt;TAB, SS 852, R.4598 / 83&lt;/ref&gt;

Ngesikhatheso u-Paul Kruger bekangekho asaye e-London bona ayokukhulumisana namaNgisi ngemibandela ye-Pretoria Convention begodu u-Piet Joubert bekamumongameli omjaphethe. Ijaji ebelingamele ngalesosikhathi latlola umbiko emKhandlwini ngomhla ka-1 kuSewula, bese wawuthumela ngo-Sewula 7. Ngemva kobana ijaji lirhunyeze amaqiniso neenkulumopikiswano, watlola  nangomthetho omenze bona akhuphe isigwebo sokufa. Kodwana uJenerali Joubert waveza ebufakazini bakhe bona uthumele uNyabela umlayezo wokuthi nangabe akazithobi uzokudliwa yikule ehloko namkha abulawe yindlala emrhobeni. Kghani uNyabela bekacabanga bona nakangazithoba bekazokusinda? Ngombana msinyana ngemva kwalokho, wazithoba. Wahlongoza bona umKhandlu usicabangele isigwebo sokufa usehlise. UmKhandlu waqunta bona uNyabela akadilikelwe lijele asebenze budisi. Kodwana uMampuru yena khenge acolelwe, yeke walengiswa ngomhla ka-22 kuSinyikhaba 1883. Walengiswa phambi kukaNyabela. Okokuthoma intambo yarathuka wadusuka phasi kabuhlungu ehlabathini. Walengiswa godu msinyana ngemva kwalokho.&lt;ref name=&quot;:3&quot; /&gt;&lt;ref name=&quot;:4&quot; /&gt;

UNyabela watjhaphululwa ejele ngo-1898 wayokuhlala hlanu kwe-Derdepoort ePitori. Wahlongakala ngo-1903. 

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>2ytsijug6hxdcpf8kua4vpjhy80ws5k</sha1>
    </revision>
    <revision>
      <id>6775</id>
      <parentid>6772</parentid>
      <timestamp>2026-08-14T11:39:29Z</timestamp>
      <contributor>
        <username>SandisiweMahlangu</username>
        <id>1620</id>
      </contributor>
      <comment>edit</comment>
      <origin>6775</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="13518" sha1="e2krep85nhlxi07fd1b9m58x4k2u3he" xml:space="preserve">[[Isimumathi:King Nyabela of the Ndebele Tribe South Africa 1893.jpg|thumb|Ilitje Lesikhumbuzo leNgwenyama uNyabela]]
'''UNyabela''' yiNgwenyama yamaNdebele wakwaNzunza  eyabusa kusukela ngenyanga kaVelabahlinze 1879 nakukhothama iNgwenyama uRhobongo, walwa ipi namaBhuru eyathoma mhla amalanga alikhomba  enyangeni kaSinyikhaba ngomnyaka we-1882 eyaphela mhla amalanga abunane enyangeni kaVelabahlinze ngomnyaka we-1883 mhla anikela uMampuru emaBhurwini, kwaba kubotjhwa kwakhe nokuhluleka kwepi yamaNdebele emaBhurwini.&lt;ref name=&quot;:0&quot;&gt;Iziko Lamakhosi - C. J Mahlangu, K. N Mahlangu, M. A Mahlangu, no-S. M Mtshweni&lt;/ref&gt; 

Ngokwencwadi ethi '''Iziko lamaKhosi''', uNyabela  - uGijamphezeni kaMabhoko - yindodana yesithathu yeNgwenyama uMabhoko ebelethwa endlukulu. Kwathi bona kukhothame iNgwenyama uRhobongo ebeyibambele uFene, uNyabela wathatha isihlalo  waraga nokubambela uFene indodana kaMkhephuli ngombana bekasesemncani bona angabusa. Nayiragako ithi ekuthomeni kokubusa kwakhe uNyabela wayenganayo ingubo yobukhosi. Ye-ke wakhupha intanga yamaDlaza bona iyokufuna ingwe khona kuzokutholakala isikhumba esizokuba yingubo yobukhosi. Owayethwele intanga yamaDlaza ibizo lakhe kwakunguNomacwayi. Bagcina Bayifumene ingwe entabeni yakwaCabha, bayibulala beza nayo ekosini. &lt;ref name=&quot;:0&quot; /&gt;

=== Amadodana WeNgwenyama UNyabela ===

* UMtjongweni (uSomphezeni) oliDugu noyindondana ekulu

* UMofu (uSoSenzeni) oliPhogo
* UNgobe oliDuba
* UMpepe (uSovelemu) oliDlowu
* UMzitha (uSoMene) oliSinya
* UMakhabakhubu (uSovusani) oliPhogo
* UPama (uSoMvumazoke) liRhorha
* UZalabo (uSoMlingo) oliDuba
* UMarhagi (uSoZilani) oliRhorha&lt;ref name=&quot;:0&quot; /&gt;

== Isisusa Serarano Phakathi KukaNyabela NamaBhuru ==
[[Isimumathi:LL1882 pg008 SIKUKUNI.jpg|thumb|USekhukhune]]
Ngesikhathi sokubusa kukaNyabela amaBhuru besele athomile ukuzibusa ngombana bewangasekho ngaphasi kokubuswa maNgisi. Yeke, besele kuphethe wona, begodu bekenza koke okusemandlenawo bona alawule iintjhaba zabantu abanzima enarheni khona azokubusa ngendlela ephumelelako.&lt;ref name=&quot;:1&quot;&gt;{{Cite web|title=South African Military History Society - Journal - AN AFRICAN MASADA: Nyabela, Mampuru and the Defence of Mapochstad|url=http://samilitaryhistory.org/vol144ds.html|access-date=2025-05-31|website=samilitaryhistory.org}}&lt;/ref&gt; Soke isikhathesi amaBhuru namaNdebele wakwaNzunza bekanetjhebiswano elihle elathonywa yiNgwenyama uMabhoko. Kodwana kwathi bona amaBhuru athome ukuzibusa itjhebiswano laya lancipha. Isizathu kungaba kukuthi amaNdebele nawo besele afuna ukuzibusa,  UNyabela ubesele angasawubhadeli umthelo emaBhurwini, begodu wala nokuletha isibalo sabantu baboke esitjhabeni,begodu lokho kwawasilinga amaBhuru ngaphasi kombuso we-ZAR.&lt;ref name=&quot;:1&quot; /&gt;

Isisusa esikhulu serarano phakathi kwamaNdebele namaBhuru kwaba nguMampuru. UMampuru bekayikosana yabaPedi eyabelethwa ngo-1824, ayindodana yomnakwabo weKosi uSikwati. USikwati wahlongakala ngo-1861. Lokho kwabanga umraro wokuthi ngubani okufuze alandele ekubeni yiKosi yabaPedi. &lt;ref name=&quot;:2&quot;&gt;{{Cite web|title=Kgoŝi Mampuru II – King of the Pedi people {{!}} Ditsong Museums of South Africa|url=https://ditsong.org.za/en/kgosi-mampuru-ii-king-of-the-pedi-people/|access-date=2025-05-31|website=https://ditsong.org.za/en/|language=en-US}}&lt;/ref&gt; UMampuru wathi uSikwati ukhethe yena bona abe yiKosi ngombana ubelethwa mfazi obeletha ubukhosi, abaPedi abambiza bona yi-''timamollo.'' U-Sekhukhune oyindodana ekulu kaSikwati wathi lokho angekhe kwenzeke njengombana unina kaMampuru omfazi obeletha ubukhosi ukakakhuleliswa yiKosi uSikwati, kodwana mumuntu wangaphandle. Ngaphezu kwalokho wathi uSikwati ubengakaphethi koke okufuze akuphethe nakathatha umfazi oyi-''timamollo''. Yeke isihlalo kufuze sithathwe nguye.&lt;ref&gt;https://en.wikipedia.org/wiki/Mampuru_II&lt;/ref&gt;
U-Sekhukhune wathoma wathatha amandla wobukhosi bewabulala nabeluleki bakaMampuru. UMampuru wagcina sele abalekile kelekhabo. Kwathi ngemva kwesikhathi u-Sekhukhune sele alwe ipi namaBhuru, nenye ipi namaSwati, wahlaselwa esigodlweni sakhe wahlatjwa ngomukhwa wafa ngomhlaka-13 kaRhoboyi 1882. UMampuru nguye owasolwa ngokubulawa kuka-Sekhukhune, wasolwa nangokubanga umguruguru esitjhabeni sabaPedi. Yeke amaBhuru akhipha isiqunto sokuthi uMampuru akabotjhwe khona umguruguru lo uzokuphela.&lt;ref name=&quot;:2&quot; /&gt;[[Isimumathi:Stephanus Johannes Roos.jpg|thumb|UJohannes Roos]]Kuthe bona uMampuru ezwe bona uyafuneka wabaleka esitjhabeni sekhabo wayokukhosela ebantwini bakwaMasimula. AbaPedi bamlandelela nalapho babawa ikosi yakwaMasimula bona ibanikele yena, kodwana yona yala. Kwaba nepi, bakwaMasimula bahlulwa epini leyo. UMampuru nakabona bonyana bakwaMasimula bahluliwe, wabalekela kwaNomtjharhelo eNgwenyameni uNyabela. &lt;ref name=&quot;:0&quot; /&gt;

AbaPedi bafika nakoNomtjharhelo bambawa eNgwenyameni uNyabela. Kuthiwa iKosi uNyabela yathi nayibaphendulako: &quot;UMampuru ngimginyile. Nanimfunako izani ningihlinze isisu nimkhuphe.&quot; Okutjho bona nangabe abaPedi bafuna uMampuru kuzokufuze kuliwe ipi bona atholakale. AbaPedi bakhamba batjhinga emBhurwini babawa isizo lokuthola uMampuru. U-Paul Kruger obekamungameli we-ZAR, wathumela u-Roos noSenekal bona basize abaPedi ngendaba le. AmaBhuru amabili la afika esitjhabeni samaNdebele abawa uMampuru, kodwana uNyabela wala, wathi umginyile, nabamfunako abamkhuphe ngemathunjinakhe. Ekugcineni uNyabela wasilingeka wabulala u-Roos no-Senekal, wathatha iinhloko zabo wazihloma eengodweni. Kuthiwa bekavuka qobe ekuseni akhambe ayokulotjhisa iinhloko zabo aphulule neendevu zazo.&lt;ref name=&quot;:0&quot; /&gt; 

AmaBhuru asilingeka khulu ngesenzwesi athumela u-Piet Joubert namasotja amanengi. Naye wafika warabhela uNyabela amahlandla ambalwa bona akhuphe uMaMpuru kodwana uNyabela wabhala naye, kwaba kusuka kwepi phakathi kwamaNdebele namaBhuru.&lt;ref name=&quot;:1&quot; /&gt;

== Ukuthoma Kwepi YamaNdebele NamaBhuru ==
[[Isimumathi:Pjjoubert.jpg|thumb|UPiet Joubert]]
Ipi yathoma ngomhlaka-7 kuSinyikhaba 1882. Ipi yamaNdebele yayihlome ngeengidi zomsizi nemikhonto, bese yamaBhuru ihlome ngeengidi zeenhlamvu idoswa phambili nguPiet Joubert. Iingidi zeenhlamvu bezidumuza msinya kunalezo zomsizi, yeke inengi lamabutho wamaNdebele lafa ngelangelo, kwathi ngemva kwalokho amaNdebele ahlehla abalekela [[erholweni]]. AmaBhuru athi ayangena erholweni abuyela emva ngombana irholo awalazi, yeke atjhida entabeni ayokuhlala emasimini. &lt;ref name=&quot;:0&quot; /&gt; Emalangeni alandelako bebasolo basilwa, kesinye isikhathi amaNdebele afike kungakalindeleki agadle abaleke. Kesinye isikhathi bekafika ebe iinkomo zamakhuwa, kesinye isikhathi babanjwe babulawe. Kwakhe kwaba nesahlakalo lapha amaNdebele athumba iinkomo zamaBhuru, kanti amaBhuru awakalali, abagijimisa abulala amaNdebele ali-150, babuya neenkomo zabo.&lt;ref name=&quot;:1&quot; /&gt;

Isikhathi nasikhambako yahlasela indlala emaNdebeleni. Ukudla ebebakubulungile kwaphela, bathoma ukudla iimphalo eenkhunjeni, kodwana ngokukhamba kwesikhathi iimphalo nazo zaphela. Bathoma bafikelwa mcabango wokuzinikela emaBhurwini, ngapha amaBhuru sebacabanga ukukhamba babuyele emakhaya ngombana sebafikelwa kudinwa. AmaNdebele eza namano wokuthola ukudla.&lt;ref name=&quot;:0&quot; /&gt; Kwakhitjhwa intanga yamaThula bona iyokuthumba iinkomo zabaPedi. Ngebanga lokuthi bebanganamandla ngebanga lokulamba bahlulwa epini leyo.

Kunesikhathi lapha amaNdebele athi akhukhuthisa abafazi bona bayokweba ukudla, kodwana amaBhuru wababulala abafazabo. Kuthiwa abafazaba bakwaMatsitsi, uNoMtjhatjhana noNoMgiyelwa.  Ngesikhatheso bekusolo kuliwa. Kokhunye amaBhuru alinge ukwemba amadwala afuna indlela yokungena erholweni, kodwana amaNzunza afike abahlasele abaliye, nabo bagcine sele bawunghalile umsebenzi loyo. &lt;ref name=&quot;:1&quot; /&gt;

Kwafika isikhathi lapha amaBhuru abuyela khona emva. Athe angakayi nokuyaphi, asemlanjeni iMangwana kwafika indoda yakwaNdala yatjela amaBhuru bona amaNdebele aphelile yindlala, neemphalo nazo ziphelile. AmaBhuru wajika wabuyela emva kwaNomtjharhelo. Bafika batjela iNgwenyama bona ayikhuphe uMampuru. Nangambala yamkhupha yamnikela emaBhurwini ngomhlaka-08 kaVelabahlinze 1883. Ipi le yathatha iinyanga ezibunane zoke. Babotjhwa bobabili uNyabela noMampuru.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt; 

== Ukubotjhwa Nokuhlongakala KukaNyabela ==
Kwathi ngemva kobana uNyabela anikele uMampuru kuJoubert nebutho lakhe naye wabotjhwa ngebanga lokujamelana nebutho likaRhulumende wangesikhatheso nokufihla isilelesi. Ngemva kokubotjhwa kwabo isitjhaba sakhutjhwa ngerholweni, satjelwa bona uNyabela akasese yikosi noNyengelele ikosikazakhe akasese yindlovukazi, kunalokho uPiet Joubert uzokuba yikosi yamaNdebele wakwaNzunza bese ikosikazakhe ibe yindlovukazi. Abavumako baphadlhalajwa bahlukaniswa bona bayokuhlala emaplasini wamaBhuru basebenze khona, labo abangavumiko njengoMatsitsi, uPinda, uSigidi, uNdungulu noMhlangula babotjhwa. Abomma basetjenziselwa ukuhlanza iimpahla zamakhuwa, kwathi abobaba belusa ifuyo yamaBhuru, abanye basebenza emasimini.&lt;ref name=&quot;:0&quot; /&gt;

Umlandu kaMampuru wadenjwa ngomhla ka-17 kaKhukhulamungu 1883, umlandu wokubulala uSekhukhune, ukubanga inturhu nomguruguru, wagwetjelwa ukufa. Kwathi ngomhla ka-21 kuKhukhulamungu 1883 uNyabela wavela phambi komahluleli, iJaji u-JG Kotze nejuri yamadoda wamakhuwa abunane ngomlandu wokobana ususe ukuthula emphakathini walwisana nelawulo ebelisemthethweni leRiphabliki, nokuthi lokho okwenze ngokungemthetho, ngekohliso bewazindla ngakho. Nokobana uqunte ukuthatha iinkhali wahlela ipi yena neenduna zakhe wajamelana nombuso osemthethweni we-ZAR. Obekamjameli wakhe ekhotho owabelwe mbuso wangesikhatheso bekungu-Advocate Cooper, obekamtjhutjhisi kungu-Carl Ueckermann.&lt;ref name=&quot;:3&quot;&gt;TAB, SS 852, R.4598/83, item 293&lt;/ref&gt;

Kwathi bona umlandu kaNyabela ufundwe, u-Advocate Cooper watjela ikhotho bona ukuzivikela kukaNyabela akukhambelani nalokho okufundwe emlandwini ngombana uNyabela bekanganabo ubuhlobo nombuso we-ZAR kodwana bekayikosi ezijameleko yena nabantu bakhe. Lokho kwenza bona kuthiwe uNyabela uthi yena akanamlandu. Kwabizwa abofakazi abasithandathu u-Eduard Bok, u-SP Grové, u-SP Trichard, uJenerali Joubert, uKhomandanti Weilbach no-Kleinbooi (indoda yeNdebele amabhuru amnikele ibizo). U-Joubert uhlulekile ukubika bona uthumele uNyabela imibandela ngaphambi kokwetjiwa kweenkunzi zakhe. U-Kleinbooi khenge abuzwe ngombandela lo.&lt;ref name=&quot;:3&quot; /&gt; 

Into eyalwelwako ekudenjweni komlandu bekukuthi inga-kghani uNyabela usisakhamuzi seRiphabliki namkha awa. Ekuthomeni iRiphabliki beyijame ngesivumelwano esenziwa ngomhla ka-28 kuNtaka 1860 phakathi kukaMabhoko neRiphabliki. Ngaphasi kwesivumelwanesi, uMabhoko uvumile bona usisakhamuzi seRiphabliki. U-Cooper waphendula ubufakazobu ngokuthi isivumelwanesi asimbophi uNyabela. Okwesibili, u-Ueckermann bekanesaziso esivela kuNom. Hercules Robinson, esazisa bona amalungelo neembopho zabo boke abantu abanzima bendabuko enarheni kuzokuhlala kunjalo ngemva kokutlikitlwa kwe-''Pretoria Convention.'' U-Cooper waliphikisa ngelokuthi uNyabela bekangekho nakutlikitlwako e-''Pretoria Convention'' lokha uNomzana Hercules akhuluma namakhosi wendabuko, yeke isivumelwanweso asimbophi uNyabela. Yeke uNyabela uzijamele. U-Ueckermann nakaphendulako wathi ukuthi uNyabela akawubhadeli umthelo embusweni we-ZAR akusibufakazi bokuthi uzijamele. UKleinbooi naye wafakaza ukuthi uNyabela uvumile ku-Shepstone ukuthi bekangaphasi kukaRhulumende, yeke bekufuze abhadele umthelo. Kodwana abamrhononelako khenge baveze ubufakazi obuzwakalako ukuthi uNyabela uthome ipi ngokuthatha iinkunzi zamaBhuru. Ipendulo ebeyizwakala bekungeyaka-Ueckermann ukuthi uNyabela kufuze aphathwe njengesithunjwa sepi nokuthi besele anesikhathi abotjhiwe. Ekugcineni ijaji lathi ngebanga lokuthi uNyabela bekahlala hlanu kweMiddelburg, nangaphakathi kwemikhawulo yeRiphabliki, yeke bekasisakhamuzi seRiphabliki.&lt;ref name=&quot;:3&quot; /&gt; 

Ijuri yatjho yoke bona uNyabela umlandu ngokwayo yoke imilandu abekwe yona. Lokha uNyabela nakabuzwako bona ufuna ukuthini ngaphambi kobana anikelwe isigwebo sentambo, wathi yena ubawa ukuthula, amahlandla alitjhumi. Ngemva kwalokho wagetjelwa ukufa. Woke amanye amaNdebele ama-22 ebekanoNyabela kwadenjwa umlandu wawo ngomhla ka-24 kaKhukhulamungu 1883 babekwa umlandu wokubanga umguruguru nokulwa. Boke njalo bagwetjelwa ukuhlala ejele iminyaka elikhomba nokusebenza budisi.&lt;ref name=&quot;:4&quot;&gt;TAB, SS 852, R.4598 / 83&lt;/ref&gt;

Ngesikhatheso u-Paul Kruger bekangekho asaye e-London bona ayokukhulumisana namaNgisi ngemibandela ye-Pretoria Convention begodu u-Piet Joubert bekamumongameli omjaphethe. Ijaji ebelingamele ngalesosikhathi latlola umbiko emKhandlwini ngomhla ka-1 kuSewula, bese wawuthumela ngo-Sewula 7. Ngemva kobana ijaji lirhunyeze amaqiniso neenkulumopikiswano, watlola  nangomthetho omenze bona akhuphe isigwebo sokufa. Kodwana uJenerali Joubert waveza ebufakazini bakhe bona uthumele uNyabela umlayezo wokuthi nangabe akazithobi uzokudliwa yikule ehloko namkha abulawe yindlala emrhobeni. Kghani uNyabela bekacabanga bona nakangazithoba bekazokusinda? Ngombana msinyana ngemva kwalokho, wazithoba. Wahlongoza bona umKhandlu usicabangele isigwebo sokufa usehlise. UmKhandlu waqunta bona uNyabela akadilikelwe lijele asebenze budisi. Kodwana uMampuru yena khenge acolelwe, yeke walengiswa ngomhla ka-22 kuSinyikhaba 1883. Walengiswa phambi kukaNyabela. Okokuthoma intambo yarathuka wadusuka phasi kabuhlungu ehlabathini. Walengiswa godu msinyana ngemva kwalokho.&lt;ref name=&quot;:3&quot; /&gt;&lt;ref name=&quot;:4&quot; /&gt;

UNyabela watjhaphululwa ejele ngo-1898 wayokuhlala hlanu kwe-Derdepoort ePitori. Wahlongakala ngo-1903. 

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>e2krep85nhlxi07fd1b9m58x4k2u3he</sha1>
    </revision>
  </page>
  <page>
    <title>The United States</title>
    <ns>0</ns>
    <id>614</id>
    <revision>
      <id>2877</id>
      <timestamp>2025-06-01T06:18:34Z</timestamp>
      <contributor>
        <username>Masktapeisawesome</username>
        <id>676</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1293312806|United States]]&quot;</comment>
      <origin>2877</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="394" sha1="m966xhrqowym8b4c7lecrmhav7ana9g" xml:space="preserve">The United States of America, elaziwa njalo ngegama elithi The United States, kumbe America, liyizwe elikhulu kakhulu. Inengi lalo litholakala eNorth America, kodwana ezinye izingcenye zakhona ziseAsia kanye leCaribbean. America liyizwe elinothile kunawo wonke emhlabeni. Liphinde libe labantu abangaphezu kwe-300 million. America inabantu abanhlanga ngeenhlanga, abamasiko leenkolo ezihlukile.</text>
      <sha1>m966xhrqowym8b4c7lecrmhav7ana9g</sha1>
    </revision>
    <revision>
      <id>2878</id>
      <parentid>2877</parentid>
      <timestamp>2025-06-01T06:22:03Z</timestamp>
      <contributor>
        <username>Masktapeisawesome</username>
        <id>676</id>
      </contributor>
      <origin>2878</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="469" sha1="3ed9khbnnegs71opnavrcrf9z6w0tsh" xml:space="preserve">'''The United States of America''', elaziwa njalo ngegama elithi '''The United States''', kumbe '''America''', liyizwe elikhulu kakhulu. Inengi lalo litholakala eNorth America, kodwana ezinye izingcenye zakhona ziseAsia kanye leCaribbean. America liyizwe elinothile kunawo wonke emhlabeni. Liphinde libe labantu abangaphezu kwe-300 million. America inabantu abanhlanga ngeenhlanga, abamasiko leenkolo ezihlukile.&lt;ref&gt;https://www.britannica.com/place/United-States&lt;/ref&gt;</text>
      <sha1>3ed9khbnnegs71opnavrcrf9z6w0tsh</sha1>
    </revision>
    <revision>
      <id>2951</id>
      <parentid>2878</parentid>
      <timestamp>2025-06-06T18:17:17Z</timestamp>
      <contributor>
        <ip>169.204.151.247</ip>
      </contributor>
      <comment>efgn</comment>
      <origin>2951</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="550" sha1="1vct1ly8fe15iqugl8p80an26itgizk" xml:space="preserve">'''This page is sponsored by [[Raid: Shadow Legends]], the sponsor of today's page. The United States of America''', elaziwa njalo ngegama elithi '''The United States''', kumbe '''America''', liyizwe elikhulu kakhulu. Inengi lalo litholakala eNorth America, kodwana ezinye izingcenye zakhona ziseAsia kanye leCaribbean. America liyizwe elinothile kunawo wonke emhlabeni. Liphinde libe labantu abangaphezu kwe-300 million. America inabantu abanhlanga ngeenhlanga, abamasiko leenkolo ezihlukile.&lt;ref&gt;https://www.britannica.com/place/United-States&lt;/ref&gt;</text>
      <sha1>1vct1ly8fe15iqugl8p80an26itgizk</sha1>
    </revision>
    <revision>
      <id>3139</id>
      <parentid>2951</parentid>
      <timestamp>2025-06-07T03:05:23Z</timestamp>
      <contributor>
        <username>Max</username>
        <id>460</id>
      </contributor>
      <minor />
      <comment>Reverted edit by [[Special:Contributions/169.204.151.247|169.204.151.247]] ([[User talk:169.204.151.247|talk]]) to last revision by [[User:Masktapeisawesome|Masktapeisawesome]]</comment>
      <origin>2878</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="469" sha1="3ed9khbnnegs71opnavrcrf9z6w0tsh" xml:space="preserve">'''The United States of America''', elaziwa njalo ngegama elithi '''The United States''', kumbe '''America''', liyizwe elikhulu kakhulu. Inengi lalo litholakala eNorth America, kodwana ezinye izingcenye zakhona ziseAsia kanye leCaribbean. America liyizwe elinothile kunawo wonke emhlabeni. Liphinde libe labantu abangaphezu kwe-300 million. America inabantu abanhlanga ngeenhlanga, abamasiko leenkolo ezihlukile.&lt;ref&gt;https://www.britannica.com/place/United-States&lt;/ref&gt;</text>
      <sha1>3ed9khbnnegs71opnavrcrf9z6w0tsh</sha1>
    </revision>
    <revision>
      <id>3192</id>
      <parentid>3139</parentid>
      <timestamp>2025-06-21T19:17:09Z</timestamp>
      <contributor>
        <ip>85.97.84.231</ip>
      </contributor>
      <origin>3192</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="580" sha1="m9adggznj1nhz2izu08n99sql3hcqqo" xml:space="preserve">[[File:Common chimpanzee (Pan troglodytes schweinfurthii) feeding.jpg|thumb|Omar al-Bashir is a chimpanzee.]]

'''The United States of America''', elaziwa njalo ngegama elithi '''The United States''', kumbe '''America''', liyizwe elikhulu kakhulu. Inengi lalo litholakala eNorth America, kodwana ezinye izingcenye zakhona ziseAsia kanye leCaribbean. America liyizwe elinothile kunawo wonke emhlabeni. Liphinde libe labantu abangaphezu kwe-300 million. America inabantu abanhlanga ngeenhlanga, abamasiko leenkolo ezihlukile.&lt;ref&gt;https://www.britannica.com/place/United-States&lt;/ref&gt;</text>
      <sha1>m9adggznj1nhz2izu08n99sql3hcqqo</sha1>
    </revision>
    <revision>
      <id>3310</id>
      <parentid>3192</parentid>
      <timestamp>2025-07-02T20:48:39Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Undo revision [[Special:Diff/3192|3192]] by [[Special:Contributions/85.97.84.231|85.97.84.231]] ([[User talk:85.97.84.231|talk]])</comment>
      <origin>3310</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="469" sha1="3ed9khbnnegs71opnavrcrf9z6w0tsh" xml:space="preserve">'''The United States of America''', elaziwa njalo ngegama elithi '''The United States''', kumbe '''America''', liyizwe elikhulu kakhulu. Inengi lalo litholakala eNorth America, kodwana ezinye izingcenye zakhona ziseAsia kanye leCaribbean. America liyizwe elinothile kunawo wonke emhlabeni. Liphinde libe labantu abangaphezu kwe-300 million. America inabantu abanhlanga ngeenhlanga, abamasiko leenkolo ezihlukile.&lt;ref&gt;https://www.britannica.com/place/United-States&lt;/ref&gt;</text>
      <sha1>3ed9khbnnegs71opnavrcrf9z6w0tsh</sha1>
    </revision>
  </page>
  <page>
    <title>Mbuyisa Makhubu</title>
    <ns>0</ns>
    <id>632</id>
    <revision>
      <id>3152</id>
      <timestamp>2025-06-12T19:12:05Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1277903833|Mbuyisa Makhubo]]&quot;</comment>
      <origin>3152</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2555" sha1="raioddrtr234r68wti5jmp4b4gklr2v" xml:space="preserve">
[[File:Hector_pieterson.jpg|thumb|Makhubu aphethe u Hector Pieterson odumuzwe mapholisa we Sewula Afrika  (1976).]]
'''U-Mbuyisa Makhubu''' (wabelethwa ngo-1957 nofana ngo-1958) mlweli weSewula Afrika olwa nebandlululo owanyamalala ngo-1979.  Wakhula waduma ngemva kobana abonakale athwele u-Hector Pieterson esithombeni esithathwe ngu -Sam Nzima ngemva kobana u-Pieterson adumuzwe ngesikhathi se [[16 JUNE 1976|-Soweto Uprising]] ngo-1976.  Nanyana isithombe sibekezele, kuncani okwaziwako ngoMakhubu. 

Ngemva kobana isithombe sisatjalazwe u Makhubu watlhoriswa bonogada,bekwamu katelela bonyana abaleke e [[Isewula Afrika|South Africa]]. Umma wakhe u Nombulelo Makhubu watjela i Truth and Reconciliation Commission bonyana uthole incwadi esuka kuye ase Nigeria ngomnyaka ka 1978 ,kodwana solo kwalokho khange azwe litho elibuya kuye..wahlongakala ngomnyaka ka 2004,ngaphandle kokwazi bonyana kwenzakalani ngendodanakhe.U Mbuyisa waye ngomunye wabatjhotjhozeli be South Africa abanikelwa indawo e Nigeria ngemva kwesehlakalo se Soweto . Waye angomunye kwabathathu abafakwa e boarding high school e South-Western Nigeria-Federal Government College,ngomnyaka ka 1976-1977,kodwana boke babhalelwa kufunda kwabakatelela bonyana bafuduswe kungakapheli umnyaka .

Ngomnyaka ka-2013, kwavela iinsolo zokuthi indoda, u-Victor Vinnetou, ebegade ivalelwe ejele e-Canada iminyaka ebunane edlulileko ngamacala wokufuduka bekungu-Makhubu.  Kwenziwa iimhloliso zezakhi zofuzo ukuthola bona bekanguMbuyisa Makhubo kwamambala na.  Kwabikwa ngokukhamba kwesikhathi bona iimhloliso ze-DNA akhange ziqinisekise isimangalo sendoda le sokuthi nguMakhubu, okudanisako emndenini kaMakhubu,  nanyana ukuhlolwa kwe-DNA kwabikwa bona kwenziwa elungwini lomndeni elingenabudlelwano begazi nababelethi bobabili. 

Ukusukela ngomnyaka ka-2020, akwaziwa bona ukuphi.  &lt;ref name=&quot;disappeared&quot; /&gt; Ngomnyaka ofanako, idokhumentari eneziqephu ezine ebizwa nge- ''Through The Cracks'', eyakhutjhwa ngeminyaka ema-44 yokuvukela umbuso mhlana ali-16 kuMgwengweni wango-2020, yanikela ngemininingwana engakakhulunywa ngaphambilini ngepilo ka-Makhubu.  Kwabikwa nokuthi iplakhi yamagugu ekhumbula uMakhubu izokufakwa mhlana ali-16 kuMgwengweni wee-2020, nayo. 

* U-Davie, u-Lucille. &quot;U-Hector Pieterson Ufumana Isikhumbuzo Sakhe.&quot; [https://web.archive.org/web/20070519061318/http://www.joburg.org.za/october/hector.stm Iwebhusayithi esemthethweni yedorobha le-Johannesburg]
* U-Davie, u-Lucille. &quot;Ilanga u-Hector Pieterson ahlongakala ngalo.&quot; SA Web Directory 

== Iinkomba ==
{{Reflist}} </text>
      <sha1>raioddrtr234r68wti5jmp4b4gklr2v</sha1>
    </revision>
    <revision>
      <id>3197</id>
      <parentid>3152</parentid>
      <timestamp>2025-06-21T20:45:38Z</timestamp>
      <contributor>
        <ip>85.97.84.231</ip>
      </contributor>
      <comment>[[File:Common chimpanzee (Pan troglodytes schweinfurthii) feeding.jpg|thumb|Omar al-Bashir is a chimpanzee.]]</comment>
      <origin>3197</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2666" sha1="iq9hf8cttl25gwziqnhtfoglz41e6kn" xml:space="preserve">[[File:Common chimpanzee (Pan troglodytes schweinfurthii) feeding.jpg|thumb|Omar al-Bashir is a chimpanzee.]]


[[File:Hector_pieterson.jpg|thumb|Makhubu aphethe u Hector Pieterson odumuzwe mapholisa we Sewula Afrika  (1976).]]
'''U-Mbuyisa Makhubu''' (wabelethwa ngo-1957 nofana ngo-1958) mlweli weSewula Afrika olwa nebandlululo owanyamalala ngo-1979.  Wakhula waduma ngemva kobana abonakale athwele u-Hector Pieterson esithombeni esithathwe ngu -Sam Nzima ngemva kobana u-Pieterson adumuzwe ngesikhathi se [[16 JUNE 1976|-Soweto Uprising]] ngo-1976.  Nanyana isithombe sibekezele, kuncani okwaziwako ngoMakhubu. 

Ngemva kobana isithombe sisatjalazwe u Makhubu watlhoriswa bonogada,bekwamu katelela bonyana abaleke e [[Isewula Afrika|South Africa]]. Umma wakhe u Nombulelo Makhubu watjela i Truth and Reconciliation Commission bonyana uthole incwadi esuka kuye ase Nigeria ngomnyaka ka 1978 ,kodwana solo kwalokho khange azwe litho elibuya kuye..wahlongakala ngomnyaka ka 2004,ngaphandle kokwazi bonyana kwenzakalani ngendodanakhe.U Mbuyisa waye ngomunye wabatjhotjhozeli be South Africa abanikelwa indawo e Nigeria ngemva kwesehlakalo se Soweto . Waye angomunye kwabathathu abafakwa e boarding high school e South-Western Nigeria-Federal Government College,ngomnyaka ka 1976-1977,kodwana boke babhalelwa kufunda kwabakatelela bonyana bafuduswe kungakapheli umnyaka .

Ngomnyaka ka-2013, kwavela iinsolo zokuthi indoda, u-Victor Vinnetou, ebegade ivalelwe ejele e-Canada iminyaka ebunane edlulileko ngamacala wokufuduka bekungu-Makhubu.  Kwenziwa iimhloliso zezakhi zofuzo ukuthola bona bekanguMbuyisa Makhubo kwamambala na.  Kwabikwa ngokukhamba kwesikhathi bona iimhloliso ze-DNA akhange ziqinisekise isimangalo sendoda le sokuthi nguMakhubu, okudanisako emndenini kaMakhubu,  nanyana ukuhlolwa kwe-DNA kwabikwa bona kwenziwa elungwini lomndeni elingenabudlelwano begazi nababelethi bobabili. 

Ukusukela ngomnyaka ka-2020, akwaziwa bona ukuphi.  &lt;ref name=&quot;disappeared&quot; /&gt; Ngomnyaka ofanako, idokhumentari eneziqephu ezine ebizwa nge- ''Through The Cracks'', eyakhutjhwa ngeminyaka ema-44 yokuvukela umbuso mhlana ali-16 kuMgwengweni wango-2020, yanikela ngemininingwana engakakhulunywa ngaphambilini ngepilo ka-Makhubu.  Kwabikwa nokuthi iplakhi yamagugu ekhumbula uMakhubu izokufakwa mhlana ali-16 kuMgwengweni wee-2020, nayo. 

* U-Davie, u-Lucille. &quot;U-Hector Pieterson Ufumana Isikhumbuzo Sakhe.&quot; [https://web.archive.org/web/20070519061318/http://www.joburg.org.za/october/hector.stm Iwebhusayithi esemthethweni yedorobha le-Johannesburg]
* U-Davie, u-Lucille. &quot;Ilanga u-Hector Pieterson ahlongakala ngalo.&quot; SA Web Directory 

== Iinkomba ==
{{Reflist}} </text>
      <sha1>iq9hf8cttl25gwziqnhtfoglz41e6kn</sha1>
    </revision>
    <revision>
      <id>3215</id>
      <parentid>3197</parentid>
      <timestamp>2025-06-24T12:46:52Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>3215</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2440" sha1="7scrwivsqdpvw79x8yxgj3h1qyq413u" xml:space="preserve">

'''U-Mbuyisa Makhubu''' (wabelethwa ngo-1957 nofana ngo-1958) mlweli weSewula Afrika olwa nebandlululo owanyamalala ngo-1979.  Wakhula waduma ngemva kobana abonakale athwele u-Hector Pieterson esithombeni esithathwe ngu -Sam Nzima ngemva kobana u-Pieterson adumuzwe ngesikhathi se [[16 JUNE 1976|-Soweto Uprising]] ngo-1976.  Nanyana isithombe sibekezele, kuncani okwaziwako ngoMakhubu. 

Ngemva kobana isithombe sisatjalazwe u Makhubu watlhoriswa bonogada,bekwamu katelela bonyana abaleke e [[Isewula Afrika|South Africa]]. Umma wakhe u Nombulelo Makhubu watjela i Truth and Reconciliation Commission bonyana uthole incwadi esuka kuye ase Nigeria ngomnyaka ka 1978 ,kodwana solo kwalokho khange azwe litho elibuya kuye..wahlongakala ngomnyaka ka 2004,ngaphandle kokwazi bonyana kwenzakalani ngendodanakhe.U Mbuyisa waye ngomunye wabatjhotjhozeli be South Africa abanikelwa indawo e Nigeria ngemva kwesehlakalo se Soweto . Waye angomunye kwabathathu abafakwa e boarding high school e South-Western Nigeria-Federal Government College,ngomnyaka ka 1976-1977,kodwana boke babhalelwa kufunda kwabakatelela bonyana bafuduswe kungakapheli umnyaka .

Ngomnyaka ka-2013, kwavela iinsolo zokuthi indoda, u-Victor Vinnetou, ebegade ivalelwe ejele e-Canada iminyaka ebunane edlulileko ngamacala wokufuduka bekungu-Makhubu.  Kwenziwa iimhloliso zezakhi zofuzo ukuthola bona bekanguMbuyisa Makhubo kwamambala na.  Kwabikwa ngokukhamba kwesikhathi bona iimhloliso ze-DNA akhange ziqinisekise isimangalo sendoda le sokuthi nguMakhubu, okudanisako emndenini kaMakhubu,  nanyana ukuhlolwa kwe-DNA kwabikwa bona kwenziwa elungwini lomndeni elingenabudlelwano begazi nababelethi bobabili. 

Ukusukela ngomnyaka ka-2020, akwaziwa bona ukuphi.  &lt;ref name=&quot;disappeared&quot; /&gt; Ngomnyaka ofanako, idokhumentari eneziqephu ezine ebizwa nge- ''Through The Cracks'', eyakhutjhwa ngeminyaka ema-44 yokuvukela umbuso mhlana ali-16 kuMgwengweni wango-2020, yanikela ngemininingwana engakakhulunywa ngaphambilini ngepilo ka-Makhubu.  Kwabikwa nokuthi iplakhi yamagugu ekhumbula uMakhubu izokufakwa mhlana ali-16 kuMgwengweni wee-2020, nayo. 

* U-Davie, u-Lucille. &quot;U-Hector Pieterson Ufumana Isikhumbuzo Sakhe.&quot; [https://web.archive.org/web/20070519061318/http://www.joburg.org.za/october/hector.stm Iwebhusayithi esemthethweni yedorobha le-Johannesburg]
* U-Davie, u-Lucille. &quot;Ilanga u-Hector Pieterson ahlongakala ngalo.&quot; SA Web Directory 

== Iinkomba ==
{{Reflist}} </text>
      <sha1>7scrwivsqdpvw79x8yxgj3h1qyq413u</sha1>
    </revision>
    <revision>
      <id>3217</id>
      <parentid>3215</parentid>
      <timestamp>2025-06-24T13:45:22Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>edited</comment>
      <origin>3217</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2861" sha1="0xt9jtzi1qw4bvikg7vxw6tbmxxrt1c" xml:space="preserve">

'''UMbuyisa Makhubo''' (wabelethwa ngo-1957 nofana ngo-1958) mlweli weSewula Afrika olwa nebandlululo owanyamalala ngo-1979.  Wakhula waduma ngemva kobana abonakale athwele u-Hector Pieterson esithombeni esithathwe ngu-Sam Nzima ngemva kobana u-Pieterson adunyuzwe ngesikhathi se[[16 JUNE 1976|''-Soweto Uprising'']] ngo-1976.  Nanyana isithombe sibekezele, kuncani okwaziwako ngoMakhubo.&lt;ref&gt;Kwanele Sosibo, (12 June 2014), ''Finding Mbuyisa Makhubu, the June 16 1976 hero,'' Mail Guardian. Retrieved from: https://mg.co.za/article/2014-06-12-red-herrings-plague-search-for-mbuyisa-makhubu/ Retrieved on 24-06-2025.&lt;/ref&gt; 

Ngemva kobana isithombe sisabalale enarheni yoke nangaphetjheya, uMakhubo watlhoriswa bonogada, bekwamkatelela bonyana abaleke eSewula Afrika. Unina uNombulelo Makhubo watjela i-''Truth and Reconciliation Commission'' bonyana uthole incwadi esuka kuye ase-Nigeria ngomnyaka ka-1978, kodwana solo kwamhlokho khange athole litho elibuya kuye. Umma lo wahlongakala ngomnyaka ka-2004, ngaphandle kokwazi bonyana kwenzakalani ngendodanakhe.&lt;ref name=&quot;:0&quot;&gt;Eric Itzkin (June 4, 2020), ''Disappeared June 16 victim Mbuyisa Makhubu to be honoured.'' Retrieved from: https://www.theheritageportal.co.za/article/disappeared-june-16-victim-mbuyisa-makhubu-be-honoured Retrieved on 24-06-2025.&lt;/ref&gt; UMbuyisa bekangomunye wabatjhotjhozeli beSewula Afrika abanikelwa indawo e-Nigeria ngemva kwesehlakalo se-Soweto . Waye angomunye kwabathathu abafakwa e boarding high school e-''South-Western Nigeria-Federal Government College'' ngomnyaka ka-1976 kuya ku-1977, kodwana boke babhalelwa kufunda kwabakatelela bonyana bafuduswe kungakapheli umnyaka.&lt;ref name=&quot;:0&quot; /&gt;

Ngomnyaka ka-2013, kwavela iinsolo zokuthi indoda, u-Victor Vinnetou, ebegade ivalelwe ejele le-Canada iminyaka ebunane edlulileko ngamacala wokufuduka bekunguMakhubo.  Kwenziwa iimhloliso zezakhi zofuzo ukuthola bona bekanguMbuyisa Makhubo kwamambala na.  Kwabikwa ngokukhamba kwesikhathi bona iimhloliso ze-DNA akhange ziqinisekise isimangalo sendoda le sokuthi nguMakhubo, okudanisako emndenini kaMakhubo,  nanyana ukuhlolwa kwe-DNA kwabikwa bona kwenziwa elungwini lomndeni elingenabudlelwano begazi nababelethi bobabili. 

Ukusukela ngomnyaka ka-2020, akwaziwa bona ukuphi.&lt;ref&gt;U-Davie, u-Lucille. &quot;U-Hector Pieterson Ufumana Isikhumbuzo Sakhe.&quot; [https://web.archive.org/web/20070519061318/http://www.joburg.org.za/october/hector.stm Iwebhusayithi esemthethweni yedorobha le-Johannesburg]&lt;/ref&gt; Ngomnyaka wona loyo, idokhumentari eneziqephu ezine ebizwa nge- ''Through The Cracks'', eyakhutjhwa ngeminyaka ema-44 yokuvukela umbuso mhlana ali-16 kuMgwengweni wango-2020, yanikela ngemininingwana engakakhulunywa ngaphambilini ngepilo kaMakhubo.  Kwabikwa nokuthi iphosta yamagugu ekhumbula uMakhubo izokufakwa mhlana ali-16 kuMgwengweni wee-2020. 

== Iinkhombo ==
{{Reflist}} </text>
      <sha1>0xt9jtzi1qw4bvikg7vxw6tbmxxrt1c</sha1>
    </revision>
    <revision>
      <id>3253</id>
      <parentid>3217</parentid>
      <timestamp>2025-06-29T09:36:20Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <origin>3253</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2917" sha1="e26gh90jtegn38b8pirakfyos45h1u6" xml:space="preserve">[[Isimumathi:Hector pieterson.jpg|thumb|Mbuyisa Makhubo]]
'''UMbuyisa Makhubo''' (wabelethwa ngo-1957 nofana ngo-1958) mlweli weSewula Afrika olwa nebandlululo owanyamalala ngo-1979.  Wakhula waduma ngemva kobana abonakale athwele u-Hector Pieterson esithombeni esithathwe ngu-Sam Nzima ngemva kobana u-Pieterson adunyuzwe ngesikhathi se[[16 JUNE 1976|''-Soweto Uprising'']] ngo-1976.  Nanyana isithombe sibekezele, kuncani okwaziwako ngoMakhubo.&lt;ref&gt;Kwanele Sosibo, (12 June 2014), ''Finding Mbuyisa Makhubu, the June 16 1976 hero,'' Mail Guardian. Retrieved from: https://mg.co.za/article/2014-06-12-red-herrings-plague-search-for-mbuyisa-makhubu/ Retrieved on 24-06-2025.&lt;/ref&gt; 

Ngemva kobana isithombe sisabalale enarheni yoke nangaphetjheya, uMakhubo watlhoriswa bonogada, bekwamkatelela bonyana abaleke eSewula Afrika. Unina uNombulelo Makhubo watjela i-''Truth and Reconciliation Commission'' bonyana uthole incwadi esuka kuye ase-Nigeria ngomnyaka ka-1978, kodwana solo kwamhlokho khange athole litho elibuya kuye. Umma lo wahlongakala ngomnyaka ka-2004, ngaphandle kokwazi bonyana kwenzakalani ngendodanakhe.&lt;ref name=&quot;:0&quot;&gt;Eric Itzkin (June 4, 2020), ''Disappeared June 16 victim Mbuyisa Makhubu to be honoured.'' Retrieved from: https://www.theheritageportal.co.za/article/disappeared-june-16-victim-mbuyisa-makhubu-be-honoured Retrieved on 24-06-2025.&lt;/ref&gt; UMbuyisa bekangomunye wabatjhotjhozeli beSewula Afrika abanikelwa indawo e-Nigeria ngemva kwesehlakalo se-Soweto . Waye angomunye kwabathathu abafakwa e boarding high school e-''South-Western Nigeria-Federal Government College'' ngomnyaka ka-1976 kuya ku-1977, kodwana boke babhalelwa kufunda kwabakatelela bonyana bafuduswe kungakapheli umnyaka.&lt;ref name=&quot;:0&quot; /&gt;

Ngomnyaka ka-2013, kwavela iinsolo zokuthi indoda, u-Victor Vinnetou, ebegade ivalelwe ejele le-Canada iminyaka ebunane edlulileko ngamacala wokufuduka bekunguMakhubo.  Kwenziwa iimhloliso zezakhi zofuzo ukuthola bona bekanguMbuyisa Makhubo kwamambala na.  Kwabikwa ngokukhamba kwesikhathi bona iimhloliso ze-DNA akhange ziqinisekise isimangalo sendoda le sokuthi nguMakhubo, okudanisako emndenini kaMakhubo,  nanyana ukuhlolwa kwe-DNA kwabikwa bona kwenziwa elungwini lomndeni elingenabudlelwano begazi nababelethi bobabili. 

Ukusukela ngomnyaka ka-2020, akwaziwa bona ukuphi.&lt;ref&gt;U-Davie, u-Lucille. &quot;U-Hector Pieterson Ufumana Isikhumbuzo Sakhe.&quot; [https://web.archive.org/web/20070519061318/http://www.joburg.org.za/october/hector.stm Iwebhusayithi esemthethweni yedorobha le-Johannesburg]&lt;/ref&gt; Ngomnyaka wona loyo, idokhumentari eneziqephu ezine ebizwa nge- ''Through The Cracks'', eyakhutjhwa ngeminyaka ema-44 yokuvukela umbuso mhlana ali-16 kuMgwengweni wango-2020, yanikela ngemininingwana engakakhulunywa ngaphambilini ngepilo kaMakhubo.  Kwabikwa nokuthi iphosta yamagugu ekhumbula uMakhubo izokufakwa mhlana ali-16 kuMgwengweni wee-2020. 

== Iinkhombo ==
{{Reflist}} </text>
      <sha1>e26gh90jtegn38b8pirakfyos45h1u6</sha1>
    </revision>
  </page>
  <page>
    <title>Umtlolo wezefundo ephakemeko: Isifundo mayelana nehlobanolwazi (reference)</title>
    <ns>0</ns>
    <id>633</id>
    <revision>
      <id>3159</id>
      <timestamp>2025-06-20T08:49:12Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <comment>Created page with &quot;== Umtlolo wezefundo ephakemeko: Isifundo mayelana nehlobanolwazi (reference) ==  === '''1. Isingeniso''' === Amanye namanye amazinga wemikhakha anamatshwayo lawo akhethekileko awenza ahluke kwamanye. Ngokufanako [[ifundo]] ephakemeko nayo inamatshwayo lawo ayenza ihluke kunefundo esisekelo. Elinye lamatshwayo aqakathekileko mtlolo wezefundo ephakemeko. Umtlolo wezefundo ephakemeko lo unendlela kanye nezinto ezilandelwako ngesikhathi usetjenziswa nanyana utlolwa. Eenhlok...&quot;</comment>
      <origin>3159</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6080" sha1="mlf7dtry1awxajdidlu4u1yy8c51qqi" xml:space="preserve">== Umtlolo wezefundo ephakemeko: Isifundo mayelana nehlobanolwazi (reference) ==

=== '''1. Isingeniso''' ===
Amanye namanye amazinga wemikhakha anamatshwayo lawo akhethekileko awenza ahluke kwamanye. Ngokufanako [[ifundo]] ephakemeko nayo inamatshwayo lawo ayenza ihluke kunefundo esisekelo. Elinye lamatshwayo aqakathekileko mtlolo wezefundo ephakemeko. Umtlolo wezefundo ephakemeko lo unendlela kanye nezinto ezilandelwako ngesikhathi usetjenziswa nanyana utlolwa. Eenhlokwaneni ezilandelako zizokutjheja bonyana kuyini umtlolo wezefundo ephakemeko begodu ukuqakatheka kwawo kuyini.

=== '''2. Kuyini umtlolo wezefundo ephakemeko?''' ===
Ngokuya kwe-[https://www.eapfoundation.com/writing/what/#google_vignette EAP Foundation] (2025) &lt;ref&gt;'''EAP Foundation'''. 2025. Academic writing. Litholaka ku: &lt;nowiki&gt;https://www.eapfoundation.com/writing/what/#google_vignette&lt;/nowiki&gt;. Lifunnyenwe [ngomhlaka 16 kuMgwengweni 2025].&lt;/ref&gt;umtlolo wezefundo ephakemeko kuyindlela yokuveza amaqhinga, ilwazi nerhubhululo eemphakathini wezefundo ephakemeko. Umtlolo wezefundo ephakemeko lo uyikambiso nezinga lefundo ephakemeko ekufanele lilandelwe ngesikhathi kutlolwa nanyana kurhutjululwa ([[:en:Academic_writing|Wikipedia]] 2025)&lt;ref name=&quot;:0&quot;&gt;'''Wikipedia.''' 2025. ''Academic writing''. Litholaka ku: &lt;nowiki&gt;https://en.wikipedia.org/wiki/Academic_writing&lt;/nowiki&gt;. Lifunnyenwe [ngomhlaka 16 kuMgwengweni 2025]. &lt;/ref&gt;. Woke umuntu ozibandakanya efundweni ephakemeko ekufaka hlangana abafundi nabafundisi nanyana abosofundokghono kufanele balandele ikambiso nezinga lokutlola lelo elibekiweko ngesikhathi batlola ngaphasi kwesigugu nanyana iziko elithize lefundo ephakemeko (Akkaya no-Aydin 2018)&lt;ref name=&quot;:1&quot;&gt;'''Akkaya, A. &amp; Aydin, G.''' 2018. Academics' Views on the Characteristics of Academic Writing. ''Educational Policy Analysis and Strategic Research'', 13(2), 128-160. doi: 10.29329/epasr.2018.143.7&lt;/ref&gt;. Nanyana kunjalo, umtlolo wezefundo ephakemeko lo uyahluka ngokuya kweziko nanyana kwesigungu sezefundo ephakemeko. Ngalokho-ke, kuqakathekile bonyana lokha nawuzibandaka neziko elithize lezefundo ephakemeko wazi ukuthi basebenzisa muphi umhlobo womtlolo wezefundo ephakemeko.

==== 2.1. Ezinye zezinto eziqakathekileko ngaphasi komtlolo wezefundo ephakemeko ngilezi ezilandelako: ====
1.     Ukuhlonipha ubuhlakani bomuntu ngokwenza ireference nanyana ihlobanolwazi. Ihlobanolwazi lihlukene Kabili, kukhona ihlobano lwazi langaphakathi komtlolo kanye nerhelo lawo loke liphelele, lelo elaziwa ngomthombolwazi nanyana isilululwazi (Akkaya no-Aydin 2018)&lt;ref name=&quot;:1&quot; /&gt;. Asitjheje iimbonelo ezilandelako zehlobanolwazi langaphakathi komtlolo:


-         Ngokuya kukaMtsweni (2025) kumakhaza la.

-         Kumakhaza la (Mtsweni 2025).

               '''''Isitjengiso 1''''' 

Iimbonelo ezimbili lezi kusitjengiso 1 kumhlobo wehlobanolwazi lokuhlonipha ubuhlakani babanye abantu. Umhlobo lo usetjenziswa ngaphakathi komtlolo nanyana lokha nawusatlolako (Akkaya no-Aydin 2018)&lt;ref name=&quot;:1&quot; /&gt;. Umhlobo olandelako wehlobanolwazi usetjenziswa ekugcineni komtlolo. Ngamanye amagama, uwuthola ekugcineni lapho sele umtloli nanyana usofundokghono aqede ikulumopendulwano nanyana irhubhululo lakhe. Asitjhejeni isibonelo esilandelako:

2.      '''Mtsweni, B. R.''' 2025. Ukuqakatheka kwelimi. ''Mtsweni Journal of African Languages'', 13(2):13-33.

3.     '''Sibanyoni, A. J.''' 2025. ''Ukudla kwesikhethu.'' IsiKhethu Publishers. ESewula Afrika: Etshwane. 

      ''''' Isitjengiso 2''''' 

Isibonelo 2 kusitjengiso 2, sisitjengisa bonyana ilwazi elinye lithethwe kujenali. iJenali leyo imthombolwazi nanyana lapho umtlolo osetjenziswe kurhubhululo uthethwe khona mayelana nerhubhululo. Ukungezelela, isibonelo 2 lesi ngaphasi kwesitjengiso 2 sitjengisa bonyana ilwazi elithethwe kujenali litlolwa njani  kurhelo lomthombolwazi. Ngokufanako kusibonelo 3, kusitjengisa bonyana incwadi itlolwa njani kusilululwazi nanyana kurhelo lomtholwazi nangabe isetjenziswe ngaphasi kwerhubhululo. Yelela, ngaphathi kwerhelo lomthombolwazi nanyana lesilululwazi kutlolwa imithombo leyo esetjenziswe ngaphakathi emtlolweni werhubhululo kwaphela (Education and Training Boards Ireland 2019)&lt;ref name=&quot;:2&quot;&gt;'''Education and Training Boards Ireland.''' 2019. ''Academic writing handbook for leaners: In the Further Education and Training (FET) Sector''. Further Education Support Service. Ireland: Dublin. &lt;/ref&gt;. Begodu, imithombolwazi leyo kufanele itholakale ngaphasi komtlolo werhubhululo nanyana wekulumopendulo. Esihlokweni esilandelako sizokutjheja ukuqakatheka komtlolo wezefundo ephakemeko.

=== '''3. Ukuqakatheka komtlolo wezefundo ephakemeko.''' ===
Umtlolo wezefundo ephakemeko uqakatheke ngendlela ezinengi emphakathini, enarheni kanye nefundweni ephakemeko. Ezinye zizo oqakatheke ngazo ngezilandelako:

1.     Umtlolo wezefundo ephakemeko wenza isiqiniseko sokuthi ubuhlakani bomunye umuntu buyahlonitjhwa (Wikipedia 2025)&lt;ref name=&quot;:0&quot; /&gt;. Loke ilwazi elifakwe ngaphasi kwerhelo lomthombolwazi nanyana isilululwazi, abanikazi balo bazokwaziwa begodu bahlonitjhwe ngokuthi ilwazi labo lisetjenziswe kuhle.

2.     Umtlolo wezefundo ephakemeko udlala indima ekuthuthukiseni ilwazi, ukwabelana ngelwazi kanye nokufundisana (Education and Training Boards Ireland 2019)&lt;ref name=&quot;:2&quot; /&gt;. Loke ilwazi elifakwe ngophasi kwehlobanolwazi, liyafundwa bese lirhunyutjhwe ukuze kuzwisise bonyana balinga ukusilemukisa ngani.

3.     Umtlolo wezefundo ephakemeko wenza isiqiniseko sokuthi ukwethulwa kwelwazi lerhubhululo kufane.  Boke abafundi nabafundisi bamaziko wefundo ephakameko athize, balandela indlela nanyana umhlobo othize womtlolo wezefundo ephakemeko ukuze baphumelele ukudlulisa umlayezo wabo. 

=== '''4. Isiphetho''' ===
Umtlolo wezefundo ephekemeko uqakathekile ekwenzeni isiqiniseko sokuthi ilwazi liragela phambili begodu liyabelwana. Kodwana, ukukhulu kukuthi wenza isiqiniseko sokuthi abantu balandele imigomo neendlela ezifanako ngesikhathi batlola nanyana benza amarhubhululo wabo.

=== '''5. Umthombolwazi''' ===
&lt;references /&gt;</text>
      <sha1>mlf7dtry1awxajdidlu4u1yy8c51qqi</sha1>
    </revision>
    <revision>
      <id>3185</id>
      <parentid>3159</parentid>
      <timestamp>2025-06-21T19:08:58Z</timestamp>
      <contributor>
        <ip>85.97.84.231</ip>
      </contributor>
      <origin>3185</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6191" sha1="hk5xh89pyxk1by43n5ohhn4bcxdhtqg" xml:space="preserve">[[File:Common chimpanzee (Pan troglodytes schweinfurthii) feeding.jpg|thumb|Omar al-Bashir is a chimpanzee.]]

== Umtlolo wezefundo ephakemeko: Isifundo mayelana nehlobanolwazi (reference) ==

=== '''1. Isingeniso''' ===
Amanye namanye amazinga wemikhakha anamatshwayo lawo akhethekileko awenza ahluke kwamanye. Ngokufanako [[ifundo]] ephakemeko nayo inamatshwayo lawo ayenza ihluke kunefundo esisekelo. Elinye lamatshwayo aqakathekileko mtlolo wezefundo ephakemeko. Umtlolo wezefundo ephakemeko lo unendlela kanye nezinto ezilandelwako ngesikhathi usetjenziswa nanyana utlolwa. Eenhlokwaneni ezilandelako zizokutjheja bonyana kuyini umtlolo wezefundo ephakemeko begodu ukuqakatheka kwawo kuyini.

=== '''2. Kuyini umtlolo wezefundo ephakemeko?''' ===
Ngokuya kwe-[https://www.eapfoundation.com/writing/what/#google_vignette EAP Foundation] (2025) &lt;ref&gt;'''EAP Foundation'''. 2025. Academic writing. Litholaka ku: &lt;nowiki&gt;https://www.eapfoundation.com/writing/what/#google_vignette&lt;/nowiki&gt;. Lifunnyenwe [ngomhlaka 16 kuMgwengweni 2025].&lt;/ref&gt;umtlolo wezefundo ephakemeko kuyindlela yokuveza amaqhinga, ilwazi nerhubhululo eemphakathini wezefundo ephakemeko. Umtlolo wezefundo ephakemeko lo uyikambiso nezinga lefundo ephakemeko ekufanele lilandelwe ngesikhathi kutlolwa nanyana kurhutjululwa ([[:en:Academic_writing|Wikipedia]] 2025)&lt;ref name=&quot;:0&quot;&gt;'''Wikipedia.''' 2025. ''Academic writing''. Litholaka ku: &lt;nowiki&gt;https://en.wikipedia.org/wiki/Academic_writing&lt;/nowiki&gt;. Lifunnyenwe [ngomhlaka 16 kuMgwengweni 2025]. &lt;/ref&gt;. Woke umuntu ozibandakanya efundweni ephakemeko ekufaka hlangana abafundi nabafundisi nanyana abosofundokghono kufanele balandele ikambiso nezinga lokutlola lelo elibekiweko ngesikhathi batlola ngaphasi kwesigugu nanyana iziko elithize lefundo ephakemeko (Akkaya no-Aydin 2018)&lt;ref name=&quot;:1&quot;&gt;'''Akkaya, A. &amp; Aydin, G.''' 2018. Academics' Views on the Characteristics of Academic Writing. ''Educational Policy Analysis and Strategic Research'', 13(2), 128-160. doi: 10.29329/epasr.2018.143.7&lt;/ref&gt;. Nanyana kunjalo, umtlolo wezefundo ephakemeko lo uyahluka ngokuya kweziko nanyana kwesigungu sezefundo ephakemeko. Ngalokho-ke, kuqakathekile bonyana lokha nawuzibandaka neziko elithize lezefundo ephakemeko wazi ukuthi basebenzisa muphi umhlobo womtlolo wezefundo ephakemeko.

==== 2.1. Ezinye zezinto eziqakathekileko ngaphasi komtlolo wezefundo ephakemeko ngilezi ezilandelako: ====
1.     Ukuhlonipha ubuhlakani bomuntu ngokwenza ireference nanyana ihlobanolwazi. Ihlobanolwazi lihlukene Kabili, kukhona ihlobano lwazi langaphakathi komtlolo kanye nerhelo lawo loke liphelele, lelo elaziwa ngomthombolwazi nanyana isilululwazi (Akkaya no-Aydin 2018)&lt;ref name=&quot;:1&quot; /&gt;. Asitjheje iimbonelo ezilandelako zehlobanolwazi langaphakathi komtlolo:


-         Ngokuya kukaMtsweni (2025) kumakhaza la.

-         Kumakhaza la (Mtsweni 2025).

               '''''Isitjengiso 1''''' 

Iimbonelo ezimbili lezi kusitjengiso 1 kumhlobo wehlobanolwazi lokuhlonipha ubuhlakani babanye abantu. Umhlobo lo usetjenziswa ngaphakathi komtlolo nanyana lokha nawusatlolako (Akkaya no-Aydin 2018)&lt;ref name=&quot;:1&quot; /&gt;. Umhlobo olandelako wehlobanolwazi usetjenziswa ekugcineni komtlolo. Ngamanye amagama, uwuthola ekugcineni lapho sele umtloli nanyana usofundokghono aqede ikulumopendulwano nanyana irhubhululo lakhe. Asitjhejeni isibonelo esilandelako:

2.      '''Mtsweni, B. R.''' 2025. Ukuqakatheka kwelimi. ''Mtsweni Journal of African Languages'', 13(2):13-33.

3.     '''Sibanyoni, A. J.''' 2025. ''Ukudla kwesikhethu.'' IsiKhethu Publishers. ESewula Afrika: Etshwane. 

      ''''' Isitjengiso 2''''' 

Isibonelo 2 kusitjengiso 2, sisitjengisa bonyana ilwazi elinye lithethwe kujenali. iJenali leyo imthombolwazi nanyana lapho umtlolo osetjenziswe kurhubhululo uthethwe khona mayelana nerhubhululo. Ukungezelela, isibonelo 2 lesi ngaphasi kwesitjengiso 2 sitjengisa bonyana ilwazi elithethwe kujenali litlolwa njani  kurhelo lomthombolwazi. Ngokufanako kusibonelo 3, kusitjengisa bonyana incwadi itlolwa njani kusilululwazi nanyana kurhelo lomtholwazi nangabe isetjenziswe ngaphasi kwerhubhululo. Yelela, ngaphathi kwerhelo lomthombolwazi nanyana lesilululwazi kutlolwa imithombo leyo esetjenziswe ngaphakathi emtlolweni werhubhululo kwaphela (Education and Training Boards Ireland 2019)&lt;ref name=&quot;:2&quot;&gt;'''Education and Training Boards Ireland.''' 2019. ''Academic writing handbook for leaners: In the Further Education and Training (FET) Sector''. Further Education Support Service. Ireland: Dublin. &lt;/ref&gt;. Begodu, imithombolwazi leyo kufanele itholakale ngaphasi komtlolo werhubhululo nanyana wekulumopendulo. Esihlokweni esilandelako sizokutjheja ukuqakatheka komtlolo wezefundo ephakemeko.

=== '''3. Ukuqakatheka komtlolo wezefundo ephakemeko.''' ===
Umtlolo wezefundo ephakemeko uqakatheke ngendlela ezinengi emphakathini, enarheni kanye nefundweni ephakemeko. Ezinye zizo oqakatheke ngazo ngezilandelako:

1.     Umtlolo wezefundo ephakemeko wenza isiqiniseko sokuthi ubuhlakani bomunye umuntu buyahlonitjhwa (Wikipedia 2025)&lt;ref name=&quot;:0&quot; /&gt;. Loke ilwazi elifakwe ngaphasi kwerhelo lomthombolwazi nanyana isilululwazi, abanikazi balo bazokwaziwa begodu bahlonitjhwe ngokuthi ilwazi labo lisetjenziswe kuhle.

2.     Umtlolo wezefundo ephakemeko udlala indima ekuthuthukiseni ilwazi, ukwabelana ngelwazi kanye nokufundisana (Education and Training Boards Ireland 2019)&lt;ref name=&quot;:2&quot; /&gt;. Loke ilwazi elifakwe ngophasi kwehlobanolwazi, liyafundwa bese lirhunyutjhwe ukuze kuzwisise bonyana balinga ukusilemukisa ngani.

3.     Umtlolo wezefundo ephakemeko wenza isiqiniseko sokuthi ukwethulwa kwelwazi lerhubhululo kufane.  Boke abafundi nabafundisi bamaziko wefundo ephakameko athize, balandela indlela nanyana umhlobo othize womtlolo wezefundo ephakemeko ukuze baphumelele ukudlulisa umlayezo wabo. 

=== '''4. Isiphetho''' ===
Umtlolo wezefundo ephekemeko uqakathekile ekwenzeni isiqiniseko sokuthi ilwazi liragela phambili begodu liyabelwana. Kodwana, ukukhulu kukuthi wenza isiqiniseko sokuthi abantu balandele imigomo neendlela ezifanako ngesikhathi batlola nanyana benza amarhubhululo wabo.

=== '''5. Umthombolwazi''' ===
&lt;references /&gt;</text>
      <sha1>hk5xh89pyxk1by43n5ohhn4bcxdhtqg</sha1>
    </revision>
    <revision>
      <id>3204</id>
      <parentid>3185</parentid>
      <timestamp>2025-06-23T07:34:24Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <origin>3204</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6188" sha1="3gq1cavesu85ysrgzreeym3wtoo7fmp" xml:space="preserve">[[Isimumathi:Usiphathi sesitifikeyidi sefundo.jpg|thumb|353x353px|Usiphathi sesitifikeyidi sefundo_Unisa]]

== Umtlolo wezefundo ephakemeko: Isifundo mayelana nehlobanolwazi (reference) ==

=== '''1. Isingeniso''' ===
Amanye namanye amazinga wemikhakha anamatshwayo lawo akhethekileko awenza ahluke kwamanye. Ngokufanako [[ifundo]] ephakemeko nayo inamatshwayo lawo ayenza ihluke kunefundo esisekelo. Elinye lamatshwayo aqakathekileko mtlolo wezefundo ephakemeko. Umtlolo wezefundo ephakemeko lo unendlela kanye nezinto ezilandelwako ngesikhathi usetjenziswa nanyana utlolwa. Eenhlokwaneni ezilandelako zizokutjheja bonyana kuyini umtlolo wezefundo ephakemeko begodu ukuqakatheka kwawo kuyini.

=== '''2. Kuyini umtlolo wezefundo ephakemeko?''' ===
Ngokuya kwe-[https://www.eapfoundation.com/writing/what/#google_vignette EAP Foundation] (2025) &lt;ref&gt;'''EAP Foundation'''. 2025. Academic writing. Litholaka ku: &lt;nowiki&gt;https://www.eapfoundation.com/writing/what/#google_vignette&lt;/nowiki&gt;. Lifunnyenwe [ngomhlaka 16 kuMgwengweni 2025].&lt;/ref&gt;umtlolo wezefundo ephakemeko kuyindlela yokuveza amaqhinga, ilwazi nerhubhululo eemphakathini wezefundo ephakemeko. Umtlolo wezefundo ephakemeko lo uyikambiso nezinga lefundo ephakemeko ekufanele lilandelwe ngesikhathi kutlolwa nanyana kurhutjululwa ([[:en:Academic_writing|Wikipedia]] 2025)&lt;ref name=&quot;:0&quot;&gt;'''Wikipedia.''' 2025. ''Academic writing''. Litholaka ku: &lt;nowiki&gt;https://en.wikipedia.org/wiki/Academic_writing&lt;/nowiki&gt;. Lifunnyenwe [ngomhlaka 16 kuMgwengweni 2025]. &lt;/ref&gt;. Woke umuntu ozibandakanya efundweni ephakemeko ekufaka hlangana abafundi nabafundisi nanyana abosofundokghono kufanele balandele ikambiso nezinga lokutlola lelo elibekiweko ngesikhathi batlola ngaphasi kwesigugu nanyana iziko elithize lefundo ephakemeko (Akkaya no-Aydin 2018)&lt;ref name=&quot;:1&quot;&gt;'''Akkaya, A. &amp; Aydin, G.''' 2018. Academics' Views on the Characteristics of Academic Writing. ''Educational Policy Analysis and Strategic Research'', 13(2), 128-160. doi: 10.29329/epasr.2018.143.7&lt;/ref&gt;. Nanyana kunjalo, umtlolo wezefundo ephakemeko lo uyahluka ngokuya kweziko nanyana kwesigungu sezefundo ephakemeko. Ngalokho-ke, kuqakathekile bonyana lokha nawuzibandaka neziko elithize lezefundo ephakemeko wazi ukuthi basebenzisa muphi umhlobo womtlolo wezefundo ephakemeko.

==== 2.1. Ezinye zezinto eziqakathekileko ngaphasi komtlolo wezefundo ephakemeko ngilezi ezilandelako: ====
1.     Ukuhlonipha ubuhlakani bomuntu ngokwenza ireference nanyana ihlobanolwazi. Ihlobanolwazi lihlukene Kabili, kukhona ihlobano lwazi langaphakathi komtlolo kanye nerhelo lawo loke liphelele, lelo elaziwa ngomthombolwazi nanyana isilululwazi (Akkaya no-Aydin 2018)&lt;ref name=&quot;:1&quot; /&gt;. Asitjheje iimbonelo ezilandelako zehlobanolwazi langaphakathi komtlolo:


-         Ngokuya kukaMtsweni (2025) kumakhaza la.

-         Kumakhaza la (Mtsweni 2025).

               '''''Isitjengiso 1''''' 

Iimbonelo ezimbili lezi kusitjengiso 1 kumhlobo wehlobanolwazi lokuhlonipha ubuhlakani babanye abantu. Umhlobo lo usetjenziswa ngaphakathi komtlolo nanyana lokha nawusatlolako (Akkaya no-Aydin 2018)&lt;ref name=&quot;:1&quot; /&gt;. Umhlobo olandelako wehlobanolwazi usetjenziswa ekugcineni komtlolo. Ngamanye amagama, uwuthola ekugcineni lapho sele umtloli nanyana usofundokghono aqede ikulumopendulwano nanyana irhubhululo lakhe. Asitjhejeni isibonelo esilandelako:

2.      '''Mtsweni, B. R.''' 2025. Ukuqakatheka kwelimi. ''Mtsweni Journal of African Languages'', 13(2):13-33.

3.     '''Sibanyoni, A. J.''' 2025. ''Ukudla kwesikhethu.'' IsiKhethu Publishers. ESewula Afrika: Etshwane. 

      ''''' Isitjengiso 2''''' 

Isibonelo 2 kusitjengiso 2, sisitjengisa bonyana ilwazi elinye lithethwe kujenali. iJenali leyo imthombolwazi nanyana lapho umtlolo osetjenziswe kurhubhululo uthethwe khona mayelana nerhubhululo. Ukungezelela, isibonelo 2 lesi ngaphasi kwesitjengiso 2 sitjengisa bonyana ilwazi elithethwe kujenali litlolwa njani  kurhelo lomthombolwazi. Ngokufanako kusibonelo 3, kusitjengisa bonyana incwadi itlolwa njani kusilululwazi nanyana kurhelo lomtholwazi nangabe isetjenziswe ngaphasi kwerhubhululo. Yelela, ngaphathi kwerhelo lomthombolwazi nanyana lesilululwazi kutlolwa imithombo leyo esetjenziswe ngaphakathi emtlolweni werhubhululo kwaphela (Education and Training Boards Ireland 2019)&lt;ref name=&quot;:2&quot;&gt;'''Education and Training Boards Ireland.''' 2019. ''Academic writing handbook for leaners: In the Further Education and Training (FET) Sector''. Further Education Support Service. Ireland: Dublin. &lt;/ref&gt;. Begodu, imithombolwazi leyo kufanele itholakale ngaphasi komtlolo werhubhululo nanyana wekulumopendulo. Esihlokweni esilandelako sizokutjheja ukuqakatheka komtlolo wezefundo ephakemeko.

=== '''3. Ukuqakatheka komtlolo wezefundo ephakemeko.''' ===
Umtlolo wezefundo ephakemeko uqakatheke ngendlela ezinengi emphakathini, enarheni kanye nefundweni ephakemeko. Ezinye zizo oqakatheke ngazo ngezilandelako:

1.     Umtlolo wezefundo ephakemeko wenza isiqiniseko sokuthi ubuhlakani bomunye umuntu buyahlonitjhwa (Wikipedia 2025)&lt;ref name=&quot;:0&quot; /&gt;. Loke ilwazi elifakwe ngaphasi kwerhelo lomthombolwazi nanyana isilululwazi, abanikazi balo bazokwaziwa begodu bahlonitjhwe ngokuthi ilwazi labo lisetjenziswe kuhle.

2.     Umtlolo wezefundo ephakemeko udlala indima ekuthuthukiseni ilwazi, ukwabelana ngelwazi kanye nokufundisana (Education and Training Boards Ireland 2019)&lt;ref name=&quot;:2&quot; /&gt;. Loke ilwazi elifakwe ngophasi kwehlobanolwazi, liyafundwa bese lirhunyutjhwe ukuze kuzwisise bonyana balinga ukusilemukisa ngani.

3.     Umtlolo wezefundo ephakemeko wenza isiqiniseko sokuthi ukwethulwa kwelwazi lerhubhululo kufane.  Boke abafundi nabafundisi bamaziko wefundo ephakameko athize, balandela indlela nanyana umhlobo othize womtlolo wezefundo ephakemeko ukuze baphumelele ukudlulisa umlayezo wabo. 

=== '''4. Isiphetho''' ===
Umtlolo wezefundo ephekemeko uqakathekile ekwenzeni isiqiniseko sokuthi ilwazi liragela phambili begodu liyabelwana. Kodwana, ukukhulu kukuthi wenza isiqiniseko sokuthi abantu balandele imigomo neendlela ezifanako ngesikhathi batlola nanyana benza amarhubhululo wabo.

=== '''5. Umthombolwazi''' ===
&lt;references /&gt;</text>
      <sha1>3gq1cavesu85ysrgzreeym3wtoo7fmp</sha1>
    </revision>
  </page>
  <page>
    <title>IVUNULO YAMA NDEBELE</title>
    <ns>0</ns>
    <id>648</id>
    <revision>
      <id>3202</id>
      <timestamp>2025-06-22T18:40:58Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>Created page with &quot;Ivunulo yama Ndebele ikhamba ihluka kusukela ebantwini beengubo kunye nebantwini bembaji.Kujayelekile ukubona ama Afrika amanengi ahlotjiswe ngeendlela ezihlukahlukeneko zomncamo,yincenye yamasiko wethu.Isiko elingatjhugulukiko elidluliselwa ukusukela esizukulwaneni ukuya kwesinye.Iinarha ezinengi ze Afrika zinendlela yazo ekhethekileko yokutlama begodu kuyakarisa ukubona iinarha ze Afrika ezahlukahlukeneko zisebenzisa ivunulo ukurhatjha imilayezo ehlukeneko.   Contents...&quot;</comment>
      <origin>3202</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4996" sha1="5l0002gmyfiftwukm1fl0gawi5sznr1" xml:space="preserve">Ivunulo yama Ndebele ikhamba ihluka kusukela ebantwini beengubo kunye nebantwini bembaji.Kujayelekile ukubona ama Afrika amanengi ahlotjiswe ngeendlela ezihlukahlukeneko zomncamo,yincenye yamasiko wethu.Isiko elingatjhugulukiko elidluliselwa ukusukela esizukulwaneni ukuya kwesinye.Iinarha ezinengi ze Afrika zinendlela yazo ekhethekileko yokutlama begodu kuyakarisa ukubona iinarha ze Afrika ezahlukahlukeneko zisebenzisa ivunulo ukurhatjha imilayezo ehlukeneko.


Contents
1	Isitjhaba samaNdebele
1.1	Abentazana bamaNdebele
1.1.1	Abomma bamaNdebele
1.1.1.1	Amadoda wamaNdebele
Isitjhaba samaNdebele
AmaNDEBELE sitjhaba sama Nguni esise Sewula Afrika.Isitjhaba lesi saziwa ngobuciko ne vunulo yaso.Umsebenzi wevunulo udlala indima ekulu ekumbaheni kwabo kusukela besebancani njengombana bayisebenzisa ukutshwaya amazinga ahlukileko wamasiko wepilo.Into eqakatheke khulu ekumbatheni kwabo mma bama Ndebele yi tjorholo encani.Abentazana abasebancane bahlobisa itjorholo encani enomncamo.Isiketi esihlukileko lesi sakhiwe ngokuqinileko mtjhini we khanvani ogoqiweko ubotjhwa edinini uhlotjiswe ngqo phezu kwalokhu.Okulenga ebhandeni eliphezulu kulitjhila elifana nentambo ehlanganiswe emabhandeni womncamo.Lokhu kwakhiwe bona kuwele phambi komjeje oqinileko weentambo zekoteni ezifakwe umncamo wembewu emhlophe ephazamiswa isikeli ukwandisa ubukhulu besembatho begodu kukhuthaze ukudlala kokukhanya lokha nakubonwa kusikinyeka ukutjengisa ukuthaba.

Abentazana bamaNdebele
Abentazana abadala esele balenzile isiko bambatha i phephethu ngokunikelwa bomma babo.Iphephethu yenziwe ngesikhumba esikhulu esibunjwe njenge oval esihlanganiswe ngomjeje wemicu emide yomncamo omhlophe begodu sihlotjiswe ngaphezulu ngephetheni yejometri enemibala eminengi kunye neendima ezintathu yamasongo wethusi.Iphephethu ivamise ukubotjhwa edinini belimbathwe phezu kwedini ukuya enzasi.Isikhumba sesikhumba sihloselwe kudosa amehlo ngokugona iinqulo neenyanga begodu ukutjhinga komncamo kungezelela umthelela lokha umntazana nanyakazako.

Ngesikhathi somtjhado nomnyanya wokuthomba umlobokazi umbatha isiyaya ukufihla ubuso lesi kusikhathi sokutjhuguluka ukusuka kwesinye isigaba ukuya kwesinye.Ngaphandle kwesiyaya abomalukazana bama Ndebele bambatha inyonga eyenziwe ngomncamo omhlophe olukwe ngentambo bomma abazinhlobo.Ubude bephetheni nesakhiwo se nyonga kutjho ukuveza izinto ezifana nokobana inga kghani umalukazana uzokuba mfazi wokuthoma womkhwenyana nofana useyintombi.

Abomma bamaNdebele
Umfazi otjhadileko umbatha ingubo phezu kwamahlombe wakhe eneenhluthu ezinengi ezidephileko ezitjhugulweko ezibizwa ngeenrholwani okumincamo eqinileko efakwa entanyeni,eenyaweni,emilenzeni kunye nekhalweni.Babuye bambathe ithusi nethusi emikhonweni entanyeni nemilenzeni.Ingubo abayimbathako yingubo wombhalo unoKhethwako.Abafazi abatjhadileko bahlobisa amabhande wehloko namkha ikepisi elukiweko ukwenza iinhloko ezihle.Umcamo osetjenziselwa ababfazi bama Ndebele abatjhadileko bewune palate ehlengiweko begodu bawusebenzisela umbala izinto kunye namaphetheni ahlotjiswa nokubeletha ne pumelelo.

Imincamo bayifaka imibala ukwenzela bona badlulise ilwazi ngobujamo bezulu,izinga lakhe lokuhlobana nabanye abafazi emphakathini wakhe nofana emdenini wakhe abenza isambatho kunye nekareko yakhe emtjhadweni nomndeni.

Amadoda wamaNdebele

amadoda wamaNdebele
Emadodeni wama Ndebele ivunulo yawo ayinamibalabala,ngokwesiko amadoda wama Ndebele ambatha i puleli yesifuba nofana i poriyana elenga entanyeni.Ivamise ukuhlotjiswa ngemincamo phezulu begodu yenziwa ngeenkhumba iporiyana litshwayo lobudoda begodu isokana linikelwa nguyise ngemva kobana lithathe umfazi.Amadoda wama Ndebele amabatha imihlobiso abayenzelwe bafazi babo.

Ngokwesiko amaNdebele esebenzisa izinto ezitholakala ekhaya ezifana namagobolonda,iinsimbi kunye namathambo weenlwana neenkhumba ukwenza izambatho ezineenhluthu kunye nemihlobiso.Bakhetha izinto ezithileko malungana nokuhlobana kwazo nemvelo engomkomfanekiso nofana engokomoya nofana amakghono wabo wokuvikela umgqoki nokuthuthukisa ubujamo babo emphakathini.Umcamo omnengi wamaNdebele wenziwa ngengilazi nofana umncamo weplastiki.

Ukuqakatheka okukhulu kokwenza umncamo epilweni yabantu abasikazi nendlela ihlathulula ivezwa ngemibala ,amaphetheni we goemetric begodu ukusikinyeka kuragela phambili ngokutjhuguluka kwesikhathi.Umsebenzi wemncamo yihlathululo ebonakalako yokuveza isiqhema sobuhlanga namagugu nobufakazi kunye nokudlulisa ubujamo nokhudluliswa kwama siko.

Hlangana neentjhaba ze Afrika umncamo uhlanganisa ubuhle besiko nofana ubujamo bomtjhado.Esiqhemeni sendabuko samaNdebele abafazi baba mbatha iingubo ezineenhluthu njengetshwayo lepilo yomnotho begodu nokutjengisa inani labentwana abanalo.e-Arika yesimanje manje ihlathululo namatshwayo wokwenza ivunulo sele itjhugulukile kodwana isasetjenziswa ukuzikhakhazisa kwethu ngobu Afrika bethu.

IINKOMBA

https://www.vukuzenzele.gov.za/employment

https://www.nomadafricamag.com/welcome-mobile/

https://www.bona.co.za/</text>
      <sha1>5l0002gmyfiftwukm1fl0gawi5sznr1</sha1>
    </revision>
    <revision>
      <id>3203</id>
      <parentid>3202</parentid>
      <timestamp>2025-06-22T18:50:46Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>i changed the headings and references</comment>
      <origin>3203</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5065" sha1="a8j6pwpdh44xgcbv45r6beh28wa3zea" xml:space="preserve">[[Isimumathi:Le Grand-Chef Ndébélé en Avril 2017.jpg|thumb|Ivunulo yama Ndebele]]
'''Ivunulo''' yama '''Ndebele''' ikhamba ihluka kusukela ebantwini beengubo kunye nebantwini bembaji.Kujayelekile ukubona ama Afrika amanengi ahlotjiswe ngeendlela ezihlukahlukeneko zomncamo,yincenye yamasiko wethu.Isiko elingatjhugulukiko elidluliselwa ukusukela esizukulwaneni ukuya kwesinye.Iinarha ezinengi ze Afrika zinendlela yazo ekhethekileko yokutlama begodu kuyakarisa ukubona iinarha ze Afrika ezahlukahlukeneko zisebenzisa ivunulo ukurhatjha imilayezo ehlukeneko.

=== Isitjhaba sama Ndebele ===
AmaNDEBELE sitjhaba sama Nguni esise Sewula Afrika.Isitjhaba lesi saziwa ngobuciko ne vunulo yaso.Umsebenzi wevunulo udlala indima ekulu ekumbaheni kwabo kusukela besebancani njengombana bayisebenzisa ukutshwaya amazinga ahlukileko wamasiko wepilo.Into eqakatheke khulu ekumbatheni kwabo mma bama Ndebele yi tjorholo encani.Abentazana abasebancane bahlobisa itjorholo encani enomncamo.Isiketi esihlukileko lesi sakhiwe ngokuqinileko mtjhini we khanvani ogoqiweko ubotjhwa edinini uhlotjiswe ngqo phezu kwalokhu.Okulenga ebhandeni eliphezulu kulitjhila elifana nentambo ehlanganiswe emabhandeni womncamo.Lokhu kwakhiwe bona kuwele phambi komjeje oqinileko weentambo zekoteni ezifakwe umncamo wembewu emhlophe ephazamiswa isikeli ukwandisa ubukhulu besembatho begodu kukhuthaze ukudlala kokukhanya lokha nakubonwa kusikinyeka ukutjengisa ukuthaba.

==== Abentazana bamaNdebele ====
Abentazana abadala esele balenzile isiko bambatha i phephethu ngokunikelwa bomma babo.Iphephethu yenziwe ngesikhumba esikhulu esibunjwe njenge oval esihlanganiswe ngomjeje wemicu emide yomncamo omhlophe begodu sihlotjiswe ngaphezulu ngephetheni yejometri enemibala eminengi kunye neendima ezintathu yamasongo wethusi.Iphephethu ivamise ukubotjhwa edinini belimbathwe phezu kwedini ukuya enzasi.Isikhumba sesikhumba sihloselwe kudosa amehlo ngokugona iinqulo neenyanga begodu ukutjhinga komncamo kungezelela umthelela lokha umntazana nanyakazako.

Ngesikhathi somtjhado nomnyanya wokuthomba umlobokazi umbatha isiyaya ukufihla ubuso lesi kusikhathi sokutjhuguluka ukusuka kwesinye isigaba ukuya kwesinye.Ngaphandle kwesiyaya abomalukazana bama Ndebele bambatha inyonga eyenziwe ngomncamo omhlophe olukwe ngentambo bomma abazinhlobo.Ubude bephetheni nesakhiwo se nyonga kutjho ukuveza izinto ezifana nokobana inga kghani umalukazana uzokuba mfazi wokuthoma womkhwenyana nofana useyintombi.

===== Abomma bamaNdebele =====
Umfazi otjhadileko umbatha ingubo phezu kwamahlombe wakhe eneenhluthu ezinengi ezidephileko ezitjhugulweko ezibizwa ngeenrholwani okumincamo eqinileko efakwa entanyeni,eenyaweni,emilenzeni kunye nekhalweni.Babuye bambathe ithusi nethusi emikhonweni entanyeni nemilenzeni.Ingubo abayimbathako yingubo wombhalo unoKhethwako.Abafazi abatjhadileko bahlobisa amabhande wehloko namkha ikepisi elukiweko ukwenza iinhloko ezihle.Umcamo osetjenziselwa ababfazi bama Ndebele abatjhadileko bewune palate ehlengiweko begodu bawusebenzisela umbala izinto kunye namaphetheni ahlotjiswa nokubeletha ne pumelelo.

Imincamo bayifaka imibala ukwenzela bona badlulise ilwazi ngobujamo bezulu,izinga lakhe lokuhlobana nabanye abafazi emphakathini wakhe nofana emdenini wakhe abenza isambatho kunye nekareko yakhe emtjhadweni nomndeni.
[[Isimumathi:Ndebele Zimbabwe.jpg|thumb|Amadoda wamaNdebele]]

====== Amadoda wamaNdebele ======
Emadodeni wama Ndebele ivunulo yawo ayinamibalabala,ngokwesiko amadoda wama Ndebele ambatha i puleli yesifuba nofana i poriyana elenga entanyeni.Ivamise ukuhlotjiswa ngemincamo phezulu begodu yenziwa ngeenkhumba iporiyana litshwayo lobudoda begodu isokana linikelwa nguyise ngemva kobana lithathe umfazi.Amadoda wama Ndebele amabatha imihlobiso abayenzelwe bafazi babo.

Ngokwesiko amaNdebele esebenzisa izinto ezitholakala ekhaya ezifana namagobolonda,iinsimbi kunye namathambo weenlwana neenkhumba ukwenza izambatho ezineenhluthu kunye nemihlobiso.Bakhetha izinto ezithileko malungana nokuhlobana kwazo nemvelo engomkomfanekiso nofana engokomoya nofana amakghono wabo wokuvikela umgqoki nokuthuthukisa ubujamo babo emphakathini.Umcamo omnengi wamaNdebele wenziwa ngengilazi nofana umncamo weplastiki.

Ukuqakatheka okukhulu kokwenza umncamo epilweni yabantu abasikazi nendlela ihlathulula ivezwa ngemibala ,amaphetheni we goemetric begodu ukusikinyeka kuragela phambili ngokutjhuguluka kwesikhathi.Umsebenzi wemncamo yihlathululo ebonakalako yokuveza isiqhema sobuhlanga namagugu nobufakazi kunye nokudlulisa ubujamo nokhudluliswa kwama siko.

Hlangana neentjhaba ze Afrika umncamo uhlanganisa ubuhle besiko nofana ubujamo bomtjhado.Esiqhemeni sendabuko samaNdebele abafazi baba mbatha iingubo ezineenhluthu njengetshwayo lepilo yomnotho begodu nokutjengisa inani labentwana abanalo.e-Arika yesimanje manje ihlathululo namatshwayo wokwenza ivunulo sele itjhugulukile kodwana isasetjenziswa ukuzikhakhazisa kwethu ngobu Afrika bethu.

IINKOMBA

https://www.vukuzenzele.gov.za/employment

https://www.nomadafricamag.com/welcome-mobile/

https://www.bona.co.za/</text>
      <sha1>a8j6pwpdh44xgcbv45r6beh28wa3zea</sha1>
    </revision>
    <revision>
      <id>3473</id>
      <parentid>3203</parentid>
      <timestamp>2025-07-29T00:21:49Z</timestamp>
      <contributor>
        <username>Dcljr</username>
        <id>20</id>
      </contributor>
      <comment>use normal level-2 (==) section headings</comment>
      <origin>3473</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5049" sha1="7gr146t5k0qeaddnt1m0tapg4r6rv9o" xml:space="preserve">[[Isimumathi:Le Grand-Chef Ndébélé en Avril 2017.jpg|thumb|Ivunulo yama Ndebele]]
'''Ivunulo''' yama '''Ndebele''' ikhamba ihluka kusukela ebantwini beengubo kunye nebantwini bembaji.Kujayelekile ukubona ama Afrika amanengi ahlotjiswe ngeendlela ezihlukahlukeneko zomncamo,yincenye yamasiko wethu.Isiko elingatjhugulukiko elidluliselwa ukusukela esizukulwaneni ukuya kwesinye.Iinarha ezinengi ze Afrika zinendlela yazo ekhethekileko yokutlama begodu kuyakarisa ukubona iinarha ze Afrika ezahlukahlukeneko zisebenzisa ivunulo ukurhatjha imilayezo ehlukeneko.

== Isitjhaba sama Ndebele ==
AmaNDEBELE sitjhaba sama Nguni esise Sewula Afrika.Isitjhaba lesi saziwa ngobuciko ne vunulo yaso.Umsebenzi wevunulo udlala indima ekulu ekumbaheni kwabo kusukela besebancani njengombana bayisebenzisa ukutshwaya amazinga ahlukileko wamasiko wepilo.Into eqakatheke khulu ekumbatheni kwabo mma bama Ndebele yi tjorholo encani.Abentazana abasebancane bahlobisa itjorholo encani enomncamo.Isiketi esihlukileko lesi sakhiwe ngokuqinileko mtjhini we khanvani ogoqiweko ubotjhwa edinini uhlotjiswe ngqo phezu kwalokhu.Okulenga ebhandeni eliphezulu kulitjhila elifana nentambo ehlanganiswe emabhandeni womncamo.Lokhu kwakhiwe bona kuwele phambi komjeje oqinileko weentambo zekoteni ezifakwe umncamo wembewu emhlophe ephazamiswa isikeli ukwandisa ubukhulu besembatho begodu kukhuthaze ukudlala kokukhanya lokha nakubonwa kusikinyeka ukutjengisa ukuthaba.

== Abentazana bamaNdebele ==
Abentazana abadala esele balenzile isiko bambatha i phephethu ngokunikelwa bomma babo.Iphephethu yenziwe ngesikhumba esikhulu esibunjwe njenge oval esihlanganiswe ngomjeje wemicu emide yomncamo omhlophe begodu sihlotjiswe ngaphezulu ngephetheni yejometri enemibala eminengi kunye neendima ezintathu yamasongo wethusi.Iphephethu ivamise ukubotjhwa edinini belimbathwe phezu kwedini ukuya enzasi.Isikhumba sesikhumba sihloselwe kudosa amehlo ngokugona iinqulo neenyanga begodu ukutjhinga komncamo kungezelela umthelela lokha umntazana nanyakazako.

Ngesikhathi somtjhado nomnyanya wokuthomba umlobokazi umbatha isiyaya ukufihla ubuso lesi kusikhathi sokutjhuguluka ukusuka kwesinye isigaba ukuya kwesinye.Ngaphandle kwesiyaya abomalukazana bama Ndebele bambatha inyonga eyenziwe ngomncamo omhlophe olukwe ngentambo bomma abazinhlobo.Ubude bephetheni nesakhiwo se nyonga kutjho ukuveza izinto ezifana nokobana inga kghani umalukazana uzokuba mfazi wokuthoma womkhwenyana nofana useyintombi.

== Abomma bamaNdebele ==
Umfazi otjhadileko umbatha ingubo phezu kwamahlombe wakhe eneenhluthu ezinengi ezidephileko ezitjhugulweko ezibizwa ngeenrholwani okumincamo eqinileko efakwa entanyeni,eenyaweni,emilenzeni kunye nekhalweni.Babuye bambathe ithusi nethusi emikhonweni entanyeni nemilenzeni.Ingubo abayimbathako yingubo wombhalo unoKhethwako.Abafazi abatjhadileko bahlobisa amabhande wehloko namkha ikepisi elukiweko ukwenza iinhloko ezihle.Umcamo osetjenziselwa ababfazi bama Ndebele abatjhadileko bewune palate ehlengiweko begodu bawusebenzisela umbala izinto kunye namaphetheni ahlotjiswa nokubeletha ne pumelelo.

Imincamo bayifaka imibala ukwenzela bona badlulise ilwazi ngobujamo bezulu,izinga lakhe lokuhlobana nabanye abafazi emphakathini wakhe nofana emdenini wakhe abenza isambatho kunye nekareko yakhe emtjhadweni nomndeni.
[[Isimumathi:Ndebele Zimbabwe.jpg|thumb|Amadoda wamaNdebele]]

== Amadoda wamaNdebele ==
Emadodeni wama Ndebele ivunulo yawo ayinamibalabala,ngokwesiko amadoda wama Ndebele ambatha i puleli yesifuba nofana i poriyana elenga entanyeni.Ivamise ukuhlotjiswa ngemincamo phezulu begodu yenziwa ngeenkhumba iporiyana litshwayo lobudoda begodu isokana linikelwa nguyise ngemva kobana lithathe umfazi.Amadoda wama Ndebele amabatha imihlobiso abayenzelwe bafazi babo.

Ngokwesiko amaNdebele esebenzisa izinto ezitholakala ekhaya ezifana namagobolonda,iinsimbi kunye namathambo weenlwana neenkhumba ukwenza izambatho ezineenhluthu kunye nemihlobiso.Bakhetha izinto ezithileko malungana nokuhlobana kwazo nemvelo engomkomfanekiso nofana engokomoya nofana amakghono wabo wokuvikela umgqoki nokuthuthukisa ubujamo babo emphakathini.Umcamo omnengi wamaNdebele wenziwa ngengilazi nofana umncamo weplastiki.

Ukuqakatheka okukhulu kokwenza umncamo epilweni yabantu abasikazi nendlela ihlathulula ivezwa ngemibala ,amaphetheni we goemetric begodu ukusikinyeka kuragela phambili ngokutjhuguluka kwesikhathi.Umsebenzi wemncamo yihlathululo ebonakalako yokuveza isiqhema sobuhlanga namagugu nobufakazi kunye nokudlulisa ubujamo nokhudluliswa kwama siko.

Hlangana neentjhaba ze Afrika umncamo uhlanganisa ubuhle besiko nofana ubujamo bomtjhado.Esiqhemeni sendabuko samaNdebele abafazi baba mbatha iingubo ezineenhluthu njengetshwayo lepilo yomnotho begodu nokutjengisa inani labentwana abanalo.e-Arika yesimanje manje ihlathululo namatshwayo wokwenza ivunulo sele itjhugulukile kodwana isasetjenziswa ukuzikhakhazisa kwethu ngobu Afrika bethu.

==Iinkomba==

https://www.vukuzenzele.gov.za/employment

https://www.nomadafricamag.com/welcome-mobile/

https://www.bona.co.za/</text>
      <sha1>7gr146t5k0qeaddnt1m0tapg4r6rv9o</sha1>
    </revision>
  </page>
  <page>
    <title>Iziqu zefundo ephakemeko</title>
    <ns>0</ns>
    <id>649</id>
    <revision>
      <id>3205</id>
      <timestamp>2025-06-23T07:34:40Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <comment>Created page with &quot;== '''Iziqu''' '''Zefundo Ephakemeko''' ==  === '''1.   Isingeniso''' === Amaziko wefundo ephakemeko adlala indima ekulu eemphakathini ngokuthuthukisa ilwazi layo ngeziqu ezahlukeneko. Iziqu ezahlukeneko zihlukana ngokwamazinga, imikhakha kanye nelwazi nebandlulo lazo. Kwesinye isikhathi zisetjenziswa ukuveza izinga lobuhlakani behlangano nanyana abantu abathile. Eengatjeni zekulumopendulwano elandelako sizokutjheja bona kuyini iziqu zamaziko aphakemeko nanyana zefundo...&quot;</comment>
      <origin>3205</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5733" sha1="d7jbit7szy171mnx7zlvtojik0lpk1p" xml:space="preserve">== '''Iziqu''' '''Zefundo Ephakemeko''' ==

=== '''1.   Isingeniso''' ===
Amaziko wefundo ephakemeko adlala indima ekulu eemphakathini ngokuthuthukisa ilwazi layo ngeziqu ezahlukeneko. Iziqu ezahlukeneko zihlukana ngokwamazinga, imikhakha kanye nelwazi nebandlulo lazo. Kwesinye isikhathi zisetjenziswa ukuveza izinga lobuhlakani behlangano nanyana abantu abathile. Eengatjeni zekulumopendulwano elandelako sizokutjheja bona kuyini iziqu zamaziko aphakemeko nanyana zefundo ephakemeko begodu zihluka njani. 

=== '''2.   Kuyini iziqu zefundo ephakemeko (yamaziko aphakemeko)?''' ===
Izuqu ze[[Umtlolo wezefundo ephakemeko: Isifundo mayelana nehlobanolwazi (reference)|fundo ephakemeko]] nanyana yamaziko aphamekeko wezefundo kuziziqu lezo ezinikelwa begodu kutlonyeliswe umfundi nanyana umuntu ezikweni lefundo ephakemeko njengekholiji, iyunivesithi yethekhnoloji neyunivesithi yenarha ngemva kokuqeda ibanga elithile leemfundo zomkhakha ethize ([[:en:Academic_degree|Wikipedia]] 2025&lt;ref&gt;'''Wikipedia'''. 2025. ''Academic degree''. Itholaka ku: '''&lt;nowiki&gt;https://en.wikipedia.org/wiki/Academic_degree&lt;/nowiki&gt;.''' Ifunyenwe [ngomhlaka 11 kuMgwengweni 2025].&lt;/ref&gt;). Iziqu lezi zihlukaniswa ngamazinga athize. Kukhona iimfundo zokuthoma efundweni ephakemeko ezaziwa nge-undergraduate, lezo kanengi zenziwa mumunto ozange abe neziqu ze-degree ngaphasi komkhakha loyo ([https://www.canterbury.ac.nz/study/getting-started/about-our-qualifications/university-terms-explained Canterbury Academic] 2025&lt;ref name=&quot;:0&quot;&gt;'''Canterbury Academy.''' 2024. ''University terms explain''. Itholaka ku: '''&lt;nowiki&gt;https://www.canterbury.ac.nz/study/getting-started/about-our-qualifications/university-terms-explained&lt;/nowiki&gt;'''. Ifunyenwe [ngomhlaka 11 kuMgwengweni 2025].&lt;/ref&gt;). Kube neemfundo eziphakemeko lezo ezaziwa nge-postgraduate, ezenziwa mumuntu oneziqu ze-degree kumkhakha loyo (Canterbury Academic 2025&lt;ref name=&quot;:0&quot; /&gt;). Iziqu lezi esikhathini esinengi ukuze umuntu amukelwe ukuthi azifunde nanyana azenze kunimbandela neendingo ezifunekako, ezifana nezinga elithize lokuphumelela kanye neziqu ezithize zefundo. Izinga neziqu ezifunekako kuzingalinye, ziyahlathulula egatjeni elilandelako lekulumopendulwano. 

=== '''3.   Umhlobo weziqu zefundo ephakemeko''' ===
Minengi imihlobo yeziqu zefundo ephakemeko; kodwana, ngaphasi kwelumopendulwano sizokutjheja elandelako:

==== '''1.   Isetifikeyidi esiphakemeko''' ====
Isetifikeyidi esiphakemeko kulizinga leziqu elilandelwa ibanga letjhumi nanyana igreyidi le-12. Iimfundo zesitifikeyidi zefundo ephakemeko zitholakala kumakholiji nemayunivesithi wethekhnoloji. Ama-credit wesetifikeyidi esiphakameko ali-120 (Minishi-Majanja 2009&lt;ref name=&quot;:1&quot;&gt;'''Minishi-Majanja,''' M. K. The Higher Education Qualifications Framework and the changing environment of LIS education and training in South Africa: some observations. ''SA Jnl Libs &amp; Info Sci'' 2009, 75(2):148-158&lt;/ref&gt;; no mKhandlu wezeFundo ePhakemeko 2013&lt;ref name=&quot;:2&quot;&gt;'''Council on Higher Education.''' 2013. ''Framework for Qualification Standards in Higher Education''. Council on Higher Education. South Africa: Pretoria.&lt;/ref&gt;). 

==== '''2.   Idiploma ne-degree''' ====
[[Isimumathi:Diploma Social Work.jpg|thumb|160x160px|Ibhande leDiploma ngaphasi komkhakha wabahlengi bezehlalakuhle]]
Iziqu zediploma kulizinga zefundo elilandelwa ziziqu zesetifikeyidi esiphakemeko. Iimfundo zediploma zitholakala ekholiji, eyunivesithi yethekhnoloji neyunivesithi (Minishi-Majanja&lt;ref name=&quot;:1&quot; /&gt; 2009). Ama-credit weemfundo zeziqu zediploma ama-360 (UmKhandlu wezeFundo ePhakemeko 2013&lt;ref name=&quot;:2&quot; /&gt;). 

Iziqu ze-degree kulizinga lefundo elilandelwa ziziqu zediploma (Minishi-Majanja 2009). Iimfundo lezi zitholakala kumayunivesithi wethekhnoloji namayunivesithi wenarha. Ama-credit weemfundo zeziqu zedegree ama-360 (Minishi-Majanja 2009&lt;ref name=&quot;:1&quot; /&gt;; nomKhandlu wezeFundo ePhakemeko 2013&lt;ref name=&quot;:2&quot; /&gt;). 

==== '''3.  I-MA ne-PhD''' ====
[[Isimumathi:MA belt Humanities.jpg|left|thumb|159x159px|Ibhande leMA ngaphasi komkhakha wezobuntu]]
[[Isimumathi:PhD belt African Languages Humanites.jpg|thumb|159x159px|Ibhande lePhD ngaphasi komkhakha wezobuntu]]
Iziqu ze-MA ziimfundo zezinga ezilandelwa ziziqu ze-Honours (Minishi-Majanja 2009). Iimfundo zeziqu ze-MA zitholakala kumayunivesithi wethekhnoloji nemayunivesithi wenarha. Ama-credit weemfundo zeziqu ze-MA ama-480  (UmKhandlu wezeFundo ePhakemeko 2013). 

Iziqu ze-PhD ziimfundo zezinga ezilandelwa ziziqu ze-MA (Minishi-Majanja 2009&lt;ref name=&quot;:1&quot; /&gt;). Iimfundo zeziqu ze-PhD zitholakala kumayunivesithi wethekhnoloji nemayunivesithi wenarha. Ama-credit weemfundo zeziqu ze-PhD ama-360 (UmKhandlu wezeFundo ePhakemeko 2013&lt;ref name=&quot;:2&quot; /&gt;). 

=== '''4.   Ubuhle beziqu zefundo ephakemeko''' ===
Ngokuya komKhandlu wezeFundo ePhakemeko&lt;ref name=&quot;:2&quot; /&gt; (2013) iziqu zefundo ephakemeko zidlala indima ekulu ekuthuthukiseni amaphilo wabantu nemiphakathi ngokuthi kusetjenziswe ilwazi lawo. Zibuye zenze isiqiniseko sokuthi inarha ifinyelela iindingo zayo nemiphakathi kanye namaqhinga wokurarulula imiraro yayo (UmKhandlu wezeFundo ePhakemeko 2013&lt;ref name=&quot;:2&quot; /&gt;). Kokugcina, zenza isiqiniseko sokuthi abantu bayasebenzisana begodu kuba netjhebiswano elingcono (UmKhandlu wezeFundo ePhakemeko 2013&lt;ref name=&quot;:2&quot; /&gt;).

=== '''5.   Isiphetho''' ===
Iziqu zezinga ephakeme lezefundo azitjengisi ubuhlakani obuthize kwaphela; kodwana, zidlala indima eqakathekileko eemphakathini nenarheni njengokuthi kuthuthukiswe amaphilo wabantu. Ukungezelela, zibuye zidlale indima eqakathekileko ekwenzeni isiqiniseko sokuthi imiraro yabantu iyararululwa begodu kuba nokusebenzisana hlangana nabantu babuya eendaweni ezakuhlikileko.

=== '''Umthombolwazi''' ===
&lt;references /&gt;</text>
      <sha1>d7jbit7szy171mnx7zlvtojik0lpk1p</sha1>
    </revision>
  </page>
  <page>
    <title>Iinkathi Ezine Zomnyaka</title>
    <ns>0</ns>
    <id>650</id>
    <revision>
      <id>3209</id>
      <timestamp>2025-06-24T07:18:02Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <comment>Created page with &quot;== '''Iinkathi Ezine Zomnyaka''' ==  === '''1. Isingeniso''' === Iinkathi zomnyaka ngezinye izinto eziqakathekileko tle eemphakathini esiphila kiwo. Iinkathi zomnyaka zidlala indima ekulu okuyeleliseni iimphakathi ngalokho okungakulindela esikhathini ekiso nanyana esizako. Ezinye zezinto iinkathi zomnyaka eziyelelisa ngazo iimphakathi, kukudla ekufanelwe kutjalwe ngaleso skhathi. Eenhlokwaneni ezilandelako sizokutjheja imihlobo yeenkathi zomnyaka esinazo kanye nemisebenz...&quot;</comment>
      <origin>3209</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5978" sha1="d9vh9w495rky0f4ypxt3cz460mfhm8w" xml:space="preserve">== '''Iinkathi Ezine Zomnyaka''' ==

=== '''1. Isingeniso''' ===
Iinkathi zomnyaka ngezinye izinto eziqakathekileko tle eemphakathini esiphila kiwo. Iinkathi zomnyaka zidlala indima ekulu okuyeleliseni iimphakathi ngalokho okungakulindela esikhathini ekiso nanyana esizako. Ezinye zezinto iinkathi zomnyaka eziyelelisa ngazo iimphakathi, kukudla ekufanelwe kutjalwe ngaleso skhathi. Eenhlokwaneni ezilandelako sizokutjheja imihlobo yeenkathi zomnyaka esinazo kanye nemisebenzi nanyana iinzuzo zazo.

=== '''2. Imihlobo yeenkathi zomnyaka:''' ===
Ngokuya kweNational Geographic (2025)&lt;ref name=&quot;:0&quot;&gt;'''National Geographic.''' 2025. ''Season''. Itholakala ku: &lt;nowiki&gt;https://education.nationalgeographic.org/resource/season/&lt;/nowiki&gt;. Ifunyenwe [ngomhlaka 12 kumGwengweni 2025].&lt;/ref&gt; isekelwa yiWikipedia (2025)&lt;ref&gt;'''Wikipedia.''' 2025. S''eason''. Itholakala ku:&lt;nowiki&gt;https://en.wikipedia.org/wiki/Season&lt;/nowiki&gt;. Ifunyenwe [ngomhlaka 12 kumGwengweni 2025].&lt;/ref&gt;, zine (4) iinkathi zomnyaka. [[Iinkathi zomnyaka]] lezi yihlobo, isiruthwani, ubusika nesilimela.

==== '''2.1.    Ingabe kuyini ihlobo na?''' ====
[[Isimumathi:Ihlobo.jpg|thumb|192x192px|Umuthi notjani ehlobo]]
Ihlobo kusikhathi somnyaka lapho ubujamo bezulu butjhisa khulu begodu kunezulu elinengi. Ngokuya kwe[https://www.livescience.com/25202-seasons.html Live Science (2025])&lt;ref name=&quot;:1&quot;&gt;'''Live Science.''' 2025. ''Seasons''. Itholakala ku:&lt;nowiki&gt;https://www.livescience.com/25202-seasons.html&lt;/nowiki&gt;. Ifunyenwe [ngomhlaka 12 kumGwengweni 2025].&lt;/ref&gt; isekelwa nguTrenberth (1983) &lt;ref name=&quot;:2&quot;&gt;'''Trenberth, K. E.''' 1983. What are the Seasons?. ''Bulletin American Meteorological Society'', 64(11):1276-1282. &lt;/ref&gt;ihlobo esikhathini esinengi libonakala ngemithi notjani obuhlaza khulu begodu iintjalo zakhona zibazihle. Ukungezelela, kanti nefuyo nayo iyanona ngombana amadlelo anokudla okunengi tle. Nasitjheja bonyana ihlobo lingena beliphume nini na, sifunyana bona lingena ngoNobayeni begodu liphuma ekupheleni kukaMhlolanja (National Geographic 2025&lt;ref name=&quot;:0&quot; /&gt;).

==== '''2.2.    Kuyini isiruthwani na?''' ====
[[Isimumathi:Isiruthwani.jpg|left|thumb|225x225px|Umuthi notjani ngesiruthwani]]
Isiruthwani kusikhathi somnyaka lapho amazinga wobujamo bezulu ehla khona begodu nemithi sele ithoma ukulahlekelwa mbala yawo ehlaza iba zotho ([https://education.nationalgeographic.org/resource/season/ National Geographic 2025]&lt;ref name=&quot;:0&quot; /&gt;; noTrenberth 1983&lt;ref name=&quot;:2&quot; /&gt;). Ukungezelela, namakari wemithi athoma ukusuka nanyana ukuwa. Ngalesi isikhathi, ifuyo ithoma ukuzilungiselela isikhathi somnyana esibudisi, ubusika, njengombana nokudla nakho kuthoma ukuncipha (Live Science 2024&lt;ref name=&quot;:1&quot; /&gt;). Isiruthwani sona sikhathi somnyaka esilandelwa busika, ekutjho bonyana sithoma ngoNtaka kuphikela ekupheleni kukaSihlabantakana (National Geographic 2025).

==== '''2.3.    Kuyini ubusika na?''' ====
[[Isimumathi:Ubusika.jpg|thumb|217x217px|Umuthi notjani ebusika]]
Ubusika kusikhathi somnyaka esibudisi khulu, lokha nasiqala ifuyo neentjalo. Ngokuya kweLive Science (2025) ubusika sikhathi somnyaka lapho amazinga wobujamo bezulu aphasi khulu begodu kumakhaza. Ukungezelela, kwezinye iindawo ebusika akuni izulu kodwana kuba negabhogo. INational Geographic (2025) isekelwa yi[https://www.twinkl.co.za/teaching-wiki/the-four-seasons Twinkl (2025)]&lt;ref name=&quot;:3&quot;&gt;'''Twinkl'''. 2025. ''The Four Seasons''. Itholakala ku:&lt;nowiki&gt;https://www.twinkl.co.za/teaching-wiki/the-four-seasons&lt;/nowiki&gt;. Ifunyenwe [ngomhlaka 12 kumGwengweni 2025]. &lt;/ref&gt; iveze bonyana ebusika ifuyo iyonda, kanti iintjalo ezinye ziyafa ngebanga lokutlhogeka kokudla namanzi. Ukungezelela, nabantu bezwa abakhaza khulu bagcine bagawula imithi eminengi ukuphemba umlilo. Ubusika kusikhathi somnyaka leso esilandela isiruthwani, ekutjho bona sithoma ekuthomeni kukaMrhayili kufikela ekupheleni kukaVelabahlinze (National Geographic 2025).

==== '''2.4.    Kuyini isilimela na?''' ====
[[Isimumathi:Isilimela.jpg|left|thumb|233x233px|Umuthi notjani ngesiruthwani]]
Isilimela kusikhathi somnyaka leso esingatjho bona sikhathi esiletha ithemba eentjalweni, ebantwini nefuyweni. ITwinkl (2025)&lt;ref name=&quot;:3&quot; /&gt; isekele iphuzulu leli lokha nayiveza bonyana isilimela kusikhathi somnyaka lapho amazinga wobujamo bezulu athoma ukukhuphuka begodu neentjalo zithoma ukutlhurha. Kodwana, kubuye kube nemililo eminengi yommango ezenzakalekako ngesikhathi lesi somnyaka. Ngokuya kweNational geographic (2025) isilimela kusikhathi somnyaka leso esilandela ubusika begodu sitjengisa bonyana ubusika buphelile. Ngamanye amagama, isikhathi lesi sithoma ekuthomeni kukaRhoboyi kufikela ekupheleni kukaKhukhulamungu.

=== '''3. Ingabe iinkathi zomnyaka ziletha ini eemphakathini na?''' ===
1.    Iinkathi zomnyaka zibikela imiphakathi, iintjalo nefuyo mayelana nobujamo bebhoduluko ebangalilindela. Ngokuya kweTwinkl (2025) iikhathi zomnyaka zilitshwayo lokuthi abantu neentjalo nefuyo kufanele baphile njani ngaleso skhathi njengokuthi ebusika kufanele abantu bambathe ngokufudumeleko ngombana kunamakhaza, igabhogo nerhwaba imbala.

2.    Zilethela imiphakathi nefuyo ukudla okuhlukileko nekghonakalo yokutjala. Ngokuya kweLive Science (2025) iintjalo nokudla okutholakala ehlobo kuhlukileko nalokho okutholakala ebusika; isibonelo, amakhabe atholakala ehlobo kodwana ebusika akatholakali.

3.    Iinkathi zomnyaka zidlala indima ekulu ngaphasi kwezamaphilo womphakathi. Ngokuya kweNational Geographic (2025) ehlobo kutholakala iinhlahla ezinengi zokwelapha njengoba namagulo ayanda; kodwana, ebusika amagula ayancipha njengombana kumakhaza khulu.

=== '''4. Isiphetho''' ===
Iinkhathi zomnyaka ziqaketheke khulu eemphakathini begodu zidlala iindima ezikulu efana nokuyelelisa abantu ngokudla ekufanele bakudle, ukulawuleka kwamagulo kanye namazinga wokutjhisa. Ngalokho-ke, kuqakathekile bonyana ilwazi lazo silazi begodu sihlale siziyelelile ukuze sizuze kizo.

=== '''5. Umthombolwazi''' ===
&lt;references /&gt;</text>
      <sha1>d9vh9w495rky0f4ypxt3cz460mfhm8w</sha1>
    </revision>
    <revision>
      <id>6679</id>
      <parentid>3209</parentid>
      <timestamp>2026-06-09T15:45:58Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <origin>6679</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5869" sha1="8j6lgt5q72b93croiirwumnot1y8ima" xml:space="preserve">'''Iinkathi zomnyaka''' ngezinye izinto eziqakathekileko tle eemphakathini esiphila kiwo. Iinkathi zomnyaka zidlala indima ekulu okuyeleliseni iimphakathi ngalokho okungakulindela esikhathini ekiso nanyana esizako. Ezinye zezinto iinkathi zomnyaka eziyelelisa ngazo iimphakathi, kukudla ekufanelwe kutjalwe ngaleso skhathi. Eenhlokwaneni ezilandelako sizokutjheja imihlobo yeenkathi zomnyaka esinazo kanye nemisebenzi nanyana iinzuzo zazo.

== '''Imihlobo yeenkathi zomnyaka:''' ==
Ngokuya kweNational Geographic (2025)&lt;ref name=&quot;:0&quot;&gt;'''National Geographic.''' 2025. ''Season''. Itholakala ku: &lt;nowiki&gt;https://education.nationalgeographic.org/resource/season/&lt;/nowiki&gt;. Ifunyenwe [ngomhlaka 12 kumGwengweni 2025].&lt;/ref&gt; isekelwa yiWikipedia (2025)&lt;ref&gt;'''Wikipedia.''' 2025. S''eason''. Itholakala ku:&lt;nowiki&gt;https://en.wikipedia.org/wiki/Season&lt;/nowiki&gt;. Ifunyenwe [ngomhlaka 12 kumGwengweni 2025].&lt;/ref&gt;, zine (4) iinkathi zomnyaka. [[Iinkathi zomnyaka]] lezi yihlobo, isiruthwani, ubusika nesilimela.

==== '''1.    Ingabe kuyini ihlobo na?''' ====
[[Isimumathi:Ihlobo.jpg|thumb|192x192px|Umuthi notjani ehlobo]]
Ihlobo kusikhathi somnyaka lapho ubujamo bezulu butjhisa khulu begodu kunezulu elinengi. Ngokuya kwe[https://www.livescience.com/25202-seasons.html Live Science (2025])&lt;ref name=&quot;:1&quot;&gt;'''Live Science.''' 2025. ''Seasons''. Itholakala ku:&lt;nowiki&gt;https://www.livescience.com/25202-seasons.html&lt;/nowiki&gt;. Ifunyenwe [ngomhlaka 12 kumGwengweni 2025].&lt;/ref&gt; isekelwa nguTrenberth (1983) &lt;ref name=&quot;:2&quot;&gt;'''Trenberth, K. E.''' 1983. What are the Seasons?. ''Bulletin American Meteorological Society'', 64(11):1276-1282. &lt;/ref&gt;ihlobo esikhathini esinengi libonakala ngemithi notjani obuhlaza khulu begodu iintjalo zakhona zibazihle. Ukungezelela, kanti nefuyo nayo iyanona ngombana amadlelo anokudla okunengi tle. Nasitjheja bonyana ihlobo lingena beliphume nini na, sifunyana bona lingena ngoNobayeni begodu liphuma ekupheleni kukaMhlolanja (National Geographic 2025&lt;ref name=&quot;:0&quot; /&gt;).

==== '''2.    Kuyini isiruthwani na?''' ====
[[Isimumathi:Isiruthwani.jpg|left|thumb|225x225px|Umuthi notjani ngesiruthwani]]
Isiruthwani kusikhathi somnyaka lapho amazinga wobujamo bezulu ehla khona begodu nemithi sele ithoma ukulahlekelwa mbala yawo ehlaza iba zotho ([https://education.nationalgeographic.org/resource/season/ National Geographic 2025]&lt;ref name=&quot;:0&quot; /&gt;; noTrenberth 1983&lt;ref name=&quot;:2&quot; /&gt;). Ukungezelela, namakari wemithi athoma ukusuka nanyana ukuwa. Ngalesi isikhathi, ifuyo ithoma ukuzilungiselela isikhathi somnyana esibudisi, ubusika, njengombana nokudla nakho kuthoma ukuncipha (Live Science 2024&lt;ref name=&quot;:1&quot; /&gt;). Isiruthwani sona sikhathi somnyaka esilandelwa busika, ekutjho bonyana sithoma ngoNtaka kuphikela ekupheleni kukaSihlabantakana (National Geographic 2025).

==== '''3.    Kuyini ubusika na?''' ====
[[Isimumathi:Ubusika.jpg|thumb|217x217px|Umuthi notjani ebusika]]
Ubusika kusikhathi somnyaka esibudisi khulu, lokha nasiqala ifuyo neentjalo. Ngokuya kweLive Science (2025) ubusika sikhathi somnyaka lapho amazinga wobujamo bezulu aphasi khulu begodu kumakhaza. Ukungezelela, kwezinye iindawo ebusika akuni izulu kodwana kuba negabhogo. INational Geographic (2025) isekelwa yi[https://www.twinkl.co.za/teaching-wiki/the-four-seasons Twinkl (2025)]&lt;ref name=&quot;:3&quot;&gt;'''Twinkl'''. 2025. ''The Four Seasons''. Itholakala ku:&lt;nowiki&gt;https://www.twinkl.co.za/teaching-wiki/the-four-seasons&lt;/nowiki&gt;. Ifunyenwe [ngomhlaka 12 kumGwengweni 2025]. &lt;/ref&gt; iveze bonyana ebusika ifuyo iyonda, kanti iintjalo ezinye ziyafa ngebanga lokutlhogeka kokudla namanzi. Ukungezelela, nabantu bezwa abakhaza khulu bagcine bagawula imithi eminengi ukuphemba umlilo. Ubusika kusikhathi somnyaka leso esilandela isiruthwani, ekutjho bona sithoma ekuthomeni kukaMrhayili kufikela ekupheleni kukaVelabahlinze (National Geographic 2025).

==== '''4.    Kuyini isilimela na?''' ====
[[Isimumathi:Isilimela.jpg|left|thumb|233x233px|Umuthi notjani ngesiruthwani]]
Isilimela kusikhathi somnyaka leso esingatjho bona sikhathi esiletha ithemba eentjalweni, ebantwini nefuyweni. ITwinkl (2025)&lt;ref name=&quot;:3&quot; /&gt; isekele iphuzulu leli lokha nayiveza bonyana isilimela kusikhathi somnyaka lapho amazinga wobujamo bezulu athoma ukukhuphuka begodu neentjalo zithoma ukutlhurha. Kodwana, kubuye kube nemililo eminengi yommango ezenzakalekako ngesikhathi lesi somnyaka. Ngokuya kweNational geographic (2025) isilimela kusikhathi somnyaka leso esilandela ubusika begodu sitjengisa bonyana ubusika buphelile. Ngamanye amagama, isikhathi lesi sithoma ekuthomeni kukaRhoboyi kufikela ekupheleni kukaKhukhulamungu.

== '''Ingabe iinkathi zomnyaka ziletha ini eemphakathini na?''' ==
1.    Iinkathi zomnyaka zibikela imiphakathi, iintjalo nefuyo mayelana nobujamo bebhoduluko ebangalilindela. Ngokuya kweTwinkl (2025) iikhathi zomnyaka zilitshwayo lokuthi abantu neentjalo nefuyo kufanele baphile njani ngaleso skhathi njengokuthi ebusika kufanele abantu bambathe ngokufudumeleko ngombana kunamakhaza, igabhogo nerhwaba imbala.

2.    Zilethela imiphakathi nefuyo ukudla okuhlukileko nekghonakalo yokutjala. Ngokuya kweLive Science (2025) iintjalo nokudla okutholakala ehlobo kuhlukileko nalokho okutholakala ebusika; isibonelo, amakhabe atholakala ehlobo kodwana ebusika akatholakali.

3.    Iinkathi zomnyaka zidlala indima ekulu ngaphasi kwezamaphilo womphakathi. Ngokuya kweNational Geographic (2025) ehlobo kutholakala iinhlahla ezinengi zokwelapha njengoba namagulo ayanda; kodwana, ebusika amagula ayancipha njengombana kumakhaza khulu.

Iinkhathi zomnyaka ziqaketheke khulu eemphakathini begodu zidlala iindima ezikulu efana nokuyelelisa abantu ngokudla ekufanele bakudle, ukulawuleka kwamagulo kanye namazinga wokutjhisa. Ngalokho-ke, kuqakathekile bonyana ilwazi lazo silazi begodu sihlale siziyelelile ukuze sizuze kizo.

== '''Umthombolwazi''' ==
&lt;references /&gt;</text>
      <sha1>8j6lgt5q72b93croiirwumnot1y8ima</sha1>
    </revision>
  </page>
  <page>
    <title>U-Hector Pieterson</title>
    <ns>0</ns>
    <id>651</id>
    <revision>
      <id>3211</id>
      <timestamp>2025-06-24T12:38:45Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>Publish a new article</comment>
      <origin>3211</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7892" sha1="qsrc841gzqforr59brgirx5t2jk4kdd" xml:space="preserve">[[Isimumathi:Hector Pieterson Memorial, Soweto.jpg|thumb|264x264px|Ilitje lesikhumbuzo sika-Hector Pieterson]]
'''UZolile Hector Pieterson''' bekaneminyaka eli-12 lokha nakazakubulawa mapholisa womBuso weBandlululo ngomhlaka-16 kuMgwengweni 1976. Lokhu kwenzeke ngesikhathi abantwana babantu abanzima ababafundi benza umtjhagalo e-Soweto, balwela ukukhitjhwa kwemithethokambiso enganabulungisa yomBuso weBandlululo, balwela nokuthi isiBhuru kufuze singasabi lilimi okufundiswa ngalo ingcenye yeemfundo esikolweni sabanzima. Isithombe sokufa kwakhe esidumileko esatjhudwa nguSam Nzima senza iphasi loke lawuqala ngamanye amehlo umBuso weBandlululo. U-Hector Pieterson noHastings Ndlovu, naye obekamfundi, baba bantwana bokuthoma ukubulawa emTjhagalweni we-Soweto.&lt;ref&gt;Ernest Leong, J.E. Luebering (2025), ''Hector Pieterson'', Encyclopedia Britannica. Retrieved from: https://www.britannica.com/biography/Hector-Pieterson Retrieved on 23-06-2025.&lt;/ref&gt;  

== Umlando Ka-Hector Pieterson ==
UZolile Hector Pieterson wabelethwa ngo-1963 abelethwa nguDorothy Molefi unina, noyise uVivian Pieterson. Wabelethelwa bewakhuliselwa e-Soweto eSewula Afrika. Nanyana bekunguye omsana kunina, bekanabodadwabo abane, u-Antoinette Sithole noSina Molefi abeze nonina, bese uLulu Pieterson angudadwabo kubabelethi bobabili. Ngokwalokho unina akutjhoko ngaye, uthi u-Hector bekamsanyana othandekako othanda ukumomotheka, amsana ohlakaniphileko othanda amahlaya . Yena nodadwabo u-Antoinette bebangena isikolo sinye. Nanyana ngiliphi ibhudango ebekanalo ngengomuso lakhe latjhabalala mhla kuhlelwa ijima lomtjhagalo ngo-1976.&lt;ref&gt;Briefly Website, (2025), Hector Pieterson: The untold truth of the 1976 Soweto Uprising - Written on 17-06-2021, Retrieved from: https://briefly.co.za/31902-hector-pieterson-untold-truth-symbol-1976-soweto-uprising.html Retrieved on 23-06-2025.&lt;/ref&gt;

== Ibanga Lomtjhagalo We-Soweto ==
Umtjhagalo we-Soweto ngesikhuwa owaziwa ngokuthi yi-''Soweto Uprising'' wathoma ngomhlaka-16 kaMgwengweni 1976. Isizathu sokuba khona komtjhagalo lo kukwethulwa kwesiBhuru njengelimi okuzokufundwa ngalo ingcenye yeemfundo eenkolweni zabantu abanzima. Abantwana abaziinkulungwana ezimatjhumi amabili bahlanganyela emtjhagalweni lo. U-Hector nodadwabo u-Antoinette Sithole bebahlangana nesibalweso. Amapholisa womBuso webandlululo athuthumbisa iinkule nama-''teargas,'' kwafa isibalo sabantwana esingaba likhulu namatjhumi alikhomba nesithandathu. Kusolelwa bona abantwana abafa mhlokho bangaphezu kwesibalwesi.&lt;ref&gt;Zinn Education Project (2025), ''June 16, 1976: Soweto Uprising,'' Retrieved at: https://www.zinnedproject.org/news/tdih/soweto-uprising/ Retreived on 23-06-2025.&lt;/ref&gt; 

Nasizokuzwisisa bona izenzakalo zango-1976 zenzeka njani, kufuze sizwisise bona umsuka wazo uza njani. Ekuthomeni kwabo-1970, umnotho enarheni le bewusezingeni eliphasi, amanani wokuthenga izinto ezitlhogekako bekaphezulu, nemisebenzi iyindlala. Ngaphezu kwalokho bekunabantu abanengi abasuka eendaweni zemakhaya abeza bazokuhlala emalokitjhini ngebanga lokuthuthukisa ipilwabo. Ngebanga lalokho amalokitjhi besele anesibalo esikhulu sabantu abavela eendaweni ezinengi, bese lokho kwenza  neensetjenziswa zaba zincani. Lokhu kwabangela abantu bona bahlangahlangane bebathukuthele njengombana izinga lokuphila sele lehle khulu. Kodwana lokho khenge kube semtarini bekwaba kulapho kuthoma umtjhagalo wabantwana besikolo. &lt;ref name=&quot;:0&quot;&gt;South African History Archive (SAHA), (2025), ''The Youth take charge: the Soweto Uprising of June 1976'', Retrieved from: https://www.saha.org.za/youth/bantu_education.htm Retrived on 23-06-2025.&lt;/ref&gt;

Abantwana besikolo bangesikhatheso besele bangasanalo ithemba ngengomuso. Iinkumba zokufundela bezizele swi ngabangafundi, zinganazo iintlabagelo ezaneleko zokufunda, begodu abotitjhere nabazakulawula kuhle abantwana bekufuze babakhalime budisi ngokubabetha nangokubajezisa ngezinye iindlela ezibudisi. Kuncani khulu ebekufundwa esikolweni ngesikhatheso. Ngaphezu kwalokho ngo-1975, urhulumende wangezelela ebudisini ebebaqalene nabo ngokuthatha isiqunto sokuthi isiBhuru kube lilimi okuzokufundwa ngalo iimfundo esikolweni, okutjho bona ingcenye yeemfundo ezifundwako kufuze zifundiswe ngesiBhuru.&lt;ref name=&quot;:0&quot; /&gt;

Ukufundiswa kweemfundo ngesiBhuru kwaletha umraro okabili. Kokuthoma abotitjhere bebangakghoni ukufundisa ngesiBhuru, ngapha nabafundi bangakghoni ukulikhuluma kuhle ilimeli, okutjho bona abafundi bebazokufeyila iimvivinyo zabo, bese babe bomahlalela bangawufumani umsebenzi. Okwesibili isiBhuru besiqalwa njengelimi labagqilazi, okwenza abantwana banyanya ukulisebenzisa. Ngaphezu kobana kuthethe iinyanga abazali bafake iimbawo neenghonghoyilo ngendaba le, umBuso waragela phambili nesiqunto sawo. Kwathi ekuthomeni kwango-1976 abafundi bathoma ukuhlela amajima wokulwisana nesiBhuru, nanyana kunjalo urhulumende waqinisa ihloko, wala ukulalela iinghonghoyilo zabo. Ngebanga lalokho, iinkulungwana zabafundi e-Soweto zamatjhela e-Orlando Stadium ngomhlaka-16 kaMgwengweni 1976, okukulapho baletha khona iinghonghoyilo zabo.&lt;ref name=&quot;:0&quot; /&gt;

Kunokuthi kulalelwe iinghonghoyilo zabafundaba abatjhagala ngokuthula, amapholisa womBuso weBandlululo athoma ukuvulela ngeenkule ebafundini. U-Hector Pieterson waba ngewokuthoma ukudumuzeka bewafa. Amapholisa araga nokudumuza abafundi, kodwana lokho khenge kubajamise abafundi ekutjhagaleni. Kunalokho, ukubulawa kuka-Hector kwabenza baqunga isibindi sokuraga nomtjhagalo. Baqalana namapholisa, bebatjhisa nama-ofisi we-''West Rand Administration Board (WRAB),'' ebebayiqala njengetshwayo lokugqilazwa nokugandelelwa. Batjhisa bebatjhisa neengodiphola okuziindawo ebeziqalwa njengamahlelo karhulumende wokuqeda isimilo sabantu abanzima.&lt;ref name=&quot;:0&quot; /&gt;

Nanyana urhulumende webandlululo athumela amasotja e-Soweto bona ayokujamisa umtjhagalo lo, abantu baraga nawo iinyanga ezintathu zoke. Izenzo zabo zabasela abanye abantu abatjha kiyo yoke inarha, kwaqubuka imitjhagalo ngemitjhagalo emalokitjhini enarheni yoke. Abantu abatjha abangaba makhulu amathathu babhubha, abaziinkulungwana ezimbili balimala. Boke abafundaba - kuhlanganise no-Hector Pietersen babhadela ngepilwabo ekuthuthukiseni ifundo yabantu abanzima.&lt;ref name=&quot;:0&quot; /&gt;

== Indima Edlalwe Kukufa Kuka-Hector Pieterson ==
[[Isimumathi:Hector Pieterson Museum, Soweto.jpg|thumb|252x252px|Imiziyamu ka-Hector Pieterson]]
Ukuhlongakala kuka-Hector Pieterson kudlale indima ekulu ekulwelweni kwamalungelo wobuntu nomBuso webandlululo kangangobana ilanga langomhlaka-16 kaMgwengweni lilanga labantu abatjha eligidingwa enarheni yoke. Isithombe sika-Hector athwelwe ngu[[Mbuyisa Makhubu|Mbuyisa Makhubo]], dnoadwabo ka-Hector agijima hlanu kwabo ngiso esithathwa njengetshwayo lelangeli. Isithombesi singezinye zeenthombe eziveza isehlakalwesi ezithwetjulwe nguSam Nzima.&lt;ref name=&quot;:1&quot;&gt;Lucille Davie, (14 June 2002), ''Hector: the famous child''

''whose face is unknown,'' Web Archive website (2023). Retrieved from: https://web.archive.org/web/20030327052242/https://joburg.org.za/june_2002/hector.stm Retrieved on 24-06-2025.&lt;/ref&gt; 

Ngaphezu kwalokho, bekwavulwa nemiziyamu ebizwa ngegama lakhe - ''Hector Pieterson Museum'' - e-Orlando West e-Soweto. Imiziyamu le isesitaradeni sesibili ukusukela lapha u-Hector adunyuzelwa khona. Indawo le inamafilimu, amaphephandaba, ukulandisa kwabantu abazibonele ngewabo isenzakalwesi neenthombe, nalesi esidume khulu esathwetjulwa nguSam Nzima. i-''Hector Peterson Museum'' yimiziyamu yokuthoma e-Soweto eyavulwa ngomhlaka-16 kaMgwengweni 2002. Kuthethe imali engange-R23 200 000 ukuyakha begodu i-R16 000 000 yimali enikelwe ngokuzithandela mNyango wezeBhoduluko nezokuVakatjha, bese i-R7 200 000 yanikelwa Mkhandlu weDorobho le-Johannesburg. Yeke imiziyamu le iyokuhlala isikhumbuzo sokufa kuka-Hector Pieterson nokulwela kwabantu abatjha itjhaphuluko.&lt;ref name=&quot;:1&quot; /&gt; 

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>qsrc841gzqforr59brgirx5t2jk4kdd</sha1>
    </revision>
    <revision>
      <id>3212</id>
      <parentid>3211</parentid>
      <timestamp>2025-06-24T12:39:20Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>/* Indima Edlalwe Kukufa Kuka-Hector Pieterson */</comment>
      <origin>3212</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7892" sha1="apj3wxsrdu0an06h326lv7owlpi7r1c" xml:space="preserve">[[Isimumathi:Hector Pieterson Memorial, Soweto.jpg|thumb|264x264px|Ilitje lesikhumbuzo sika-Hector Pieterson]]
'''UZolile Hector Pieterson''' bekaneminyaka eli-12 lokha nakazakubulawa mapholisa womBuso weBandlululo ngomhlaka-16 kuMgwengweni 1976. Lokhu kwenzeke ngesikhathi abantwana babantu abanzima ababafundi benza umtjhagalo e-Soweto, balwela ukukhitjhwa kwemithethokambiso enganabulungisa yomBuso weBandlululo, balwela nokuthi isiBhuru kufuze singasabi lilimi okufundiswa ngalo ingcenye yeemfundo esikolweni sabanzima. Isithombe sokufa kwakhe esidumileko esatjhudwa nguSam Nzima senza iphasi loke lawuqala ngamanye amehlo umBuso weBandlululo. U-Hector Pieterson noHastings Ndlovu, naye obekamfundi, baba bantwana bokuthoma ukubulawa emTjhagalweni we-Soweto.&lt;ref&gt;Ernest Leong, J.E. Luebering (2025), ''Hector Pieterson'', Encyclopedia Britannica. Retrieved from: https://www.britannica.com/biography/Hector-Pieterson Retrieved on 23-06-2025.&lt;/ref&gt;  

== Umlando Ka-Hector Pieterson ==
UZolile Hector Pieterson wabelethwa ngo-1963 abelethwa nguDorothy Molefi unina, noyise uVivian Pieterson. Wabelethelwa bewakhuliselwa e-Soweto eSewula Afrika. Nanyana bekunguye omsana kunina, bekanabodadwabo abane, u-Antoinette Sithole noSina Molefi abeze nonina, bese uLulu Pieterson angudadwabo kubabelethi bobabili. Ngokwalokho unina akutjhoko ngaye, uthi u-Hector bekamsanyana othandekako othanda ukumomotheka, amsana ohlakaniphileko othanda amahlaya . Yena nodadwabo u-Antoinette bebangena isikolo sinye. Nanyana ngiliphi ibhudango ebekanalo ngengomuso lakhe latjhabalala mhla kuhlelwa ijima lomtjhagalo ngo-1976.&lt;ref&gt;Briefly Website, (2025), Hector Pieterson: The untold truth of the 1976 Soweto Uprising - Written on 17-06-2021, Retrieved from: https://briefly.co.za/31902-hector-pieterson-untold-truth-symbol-1976-soweto-uprising.html Retrieved on 23-06-2025.&lt;/ref&gt;

== Ibanga Lomtjhagalo We-Soweto ==
Umtjhagalo we-Soweto ngesikhuwa owaziwa ngokuthi yi-''Soweto Uprising'' wathoma ngomhlaka-16 kaMgwengweni 1976. Isizathu sokuba khona komtjhagalo lo kukwethulwa kwesiBhuru njengelimi okuzokufundwa ngalo ingcenye yeemfundo eenkolweni zabantu abanzima. Abantwana abaziinkulungwana ezimatjhumi amabili bahlanganyela emtjhagalweni lo. U-Hector nodadwabo u-Antoinette Sithole bebahlangana nesibalweso. Amapholisa womBuso webandlululo athuthumbisa iinkule nama-''teargas,'' kwafa isibalo sabantwana esingaba likhulu namatjhumi alikhomba nesithandathu. Kusolelwa bona abantwana abafa mhlokho bangaphezu kwesibalwesi.&lt;ref&gt;Zinn Education Project (2025), ''June 16, 1976: Soweto Uprising,'' Retrieved at: https://www.zinnedproject.org/news/tdih/soweto-uprising/ Retreived on 23-06-2025.&lt;/ref&gt; 

Nasizokuzwisisa bona izenzakalo zango-1976 zenzeka njani, kufuze sizwisise bona umsuka wazo uza njani. Ekuthomeni kwabo-1970, umnotho enarheni le bewusezingeni eliphasi, amanani wokuthenga izinto ezitlhogekako bekaphezulu, nemisebenzi iyindlala. Ngaphezu kwalokho bekunabantu abanengi abasuka eendaweni zemakhaya abeza bazokuhlala emalokitjhini ngebanga lokuthuthukisa ipilwabo. Ngebanga lalokho amalokitjhi besele anesibalo esikhulu sabantu abavela eendaweni ezinengi, bese lokho kwenza  neensetjenziswa zaba zincani. Lokhu kwabangela abantu bona bahlangahlangane bebathukuthele njengombana izinga lokuphila sele lehle khulu. Kodwana lokho khenge kube semtarini bekwaba kulapho kuthoma umtjhagalo wabantwana besikolo. &lt;ref name=&quot;:0&quot;&gt;South African History Archive (SAHA), (2025), ''The Youth take charge: the Soweto Uprising of June 1976'', Retrieved from: https://www.saha.org.za/youth/bantu_education.htm Retrived on 23-06-2025.&lt;/ref&gt;

Abantwana besikolo bangesikhatheso besele bangasanalo ithemba ngengomuso. Iinkumba zokufundela bezizele swi ngabangafundi, zinganazo iintlabagelo ezaneleko zokufunda, begodu abotitjhere nabazakulawula kuhle abantwana bekufuze babakhalime budisi ngokubabetha nangokubajezisa ngezinye iindlela ezibudisi. Kuncani khulu ebekufundwa esikolweni ngesikhatheso. Ngaphezu kwalokho ngo-1975, urhulumende wangezelela ebudisini ebebaqalene nabo ngokuthatha isiqunto sokuthi isiBhuru kube lilimi okuzokufundwa ngalo iimfundo esikolweni, okutjho bona ingcenye yeemfundo ezifundwako kufuze zifundiswe ngesiBhuru.&lt;ref name=&quot;:0&quot; /&gt;

Ukufundiswa kweemfundo ngesiBhuru kwaletha umraro okabili. Kokuthoma abotitjhere bebangakghoni ukufundisa ngesiBhuru, ngapha nabafundi bangakghoni ukulikhuluma kuhle ilimeli, okutjho bona abafundi bebazokufeyila iimvivinyo zabo, bese babe bomahlalela bangawufumani umsebenzi. Okwesibili isiBhuru besiqalwa njengelimi labagqilazi, okwenza abantwana banyanya ukulisebenzisa. Ngaphezu kobana kuthethe iinyanga abazali bafake iimbawo neenghonghoyilo ngendaba le, umBuso waragela phambili nesiqunto sawo. Kwathi ekuthomeni kwango-1976 abafundi bathoma ukuhlela amajima wokulwisana nesiBhuru, nanyana kunjalo urhulumende waqinisa ihloko, wala ukulalela iinghonghoyilo zabo. Ngebanga lalokho, iinkulungwana zabafundi e-Soweto zamatjhela e-Orlando Stadium ngomhlaka-16 kaMgwengweni 1976, okukulapho baletha khona iinghonghoyilo zabo.&lt;ref name=&quot;:0&quot; /&gt;

Kunokuthi kulalelwe iinghonghoyilo zabafundaba abatjhagala ngokuthula, amapholisa womBuso weBandlululo athoma ukuvulela ngeenkule ebafundini. U-Hector Pieterson waba ngewokuthoma ukudumuzeka bewafa. Amapholisa araga nokudumuza abafundi, kodwana lokho khenge kubajamise abafundi ekutjhagaleni. Kunalokho, ukubulawa kuka-Hector kwabenza baqunga isibindi sokuraga nomtjhagalo. Baqalana namapholisa, bebatjhisa nama-ofisi we-''West Rand Administration Board (WRAB),'' ebebayiqala njengetshwayo lokugqilazwa nokugandelelwa. Batjhisa bebatjhisa neengodiphola okuziindawo ebeziqalwa njengamahlelo karhulumende wokuqeda isimilo sabantu abanzima.&lt;ref name=&quot;:0&quot; /&gt;

Nanyana urhulumende webandlululo athumela amasotja e-Soweto bona ayokujamisa umtjhagalo lo, abantu baraga nawo iinyanga ezintathu zoke. Izenzo zabo zabasela abanye abantu abatjha kiyo yoke inarha, kwaqubuka imitjhagalo ngemitjhagalo emalokitjhini enarheni yoke. Abantu abatjha abangaba makhulu amathathu babhubha, abaziinkulungwana ezimbili balimala. Boke abafundaba - kuhlanganise no-Hector Pietersen babhadela ngepilwabo ekuthuthukiseni ifundo yabantu abanzima.&lt;ref name=&quot;:0&quot; /&gt;

== Indima Edlalwe Kukufa Kuka-Hector Pieterson ==
[[Isimumathi:Hector Pieterson Museum, Soweto.jpg|thumb|312x312px|Imiziyamu ka-Hector Pieterson]]
Ukuhlongakala kuka-Hector Pieterson kudlale indima ekulu ekulwelweni kwamalungelo wobuntu nomBuso webandlululo kangangobana ilanga langomhlaka-16 kaMgwengweni lilanga labantu abatjha eligidingwa enarheni yoke. Isithombe sika-Hector athwelwe ngu[[Mbuyisa Makhubu|Mbuyisa Makhubo]], dnoadwabo ka-Hector agijima hlanu kwabo ngiso esithathwa njengetshwayo lelangeli. Isithombesi singezinye zeenthombe eziveza isehlakalwesi ezithwetjulwe nguSam Nzima.&lt;ref name=&quot;:1&quot;&gt;Lucille Davie, (14 June 2002), ''Hector: the famous child''

''whose face is unknown,'' Web Archive website (2023). Retrieved from: https://web.archive.org/web/20030327052242/https://joburg.org.za/june_2002/hector.stm Retrieved on 24-06-2025.&lt;/ref&gt; 

Ngaphezu kwalokho, bekwavulwa nemiziyamu ebizwa ngegama lakhe - ''Hector Pieterson Museum'' - e-Orlando West e-Soweto. Imiziyamu le isesitaradeni sesibili ukusukela lapha u-Hector adunyuzelwa khona. Indawo le inamafilimu, amaphephandaba, ukulandisa kwabantu abazibonele ngewabo isenzakalwesi neenthombe, nalesi esidume khulu esathwetjulwa nguSam Nzima. i-''Hector Peterson Museum'' yimiziyamu yokuthoma e-Soweto eyavulwa ngomhlaka-16 kaMgwengweni 2002. Kuthethe imali engange-R23 200 000 ukuyakha begodu i-R16 000 000 yimali enikelwe ngokuzithandela mNyango wezeBhoduluko nezokuVakatjha, bese i-R7 200 000 yanikelwa Mkhandlu weDorobho le-Johannesburg. Yeke imiziyamu le iyokuhlala isikhumbuzo sokufa kuka-Hector Pieterson nokulwela kwabantu abatjha itjhaphuluko.&lt;ref name=&quot;:1&quot; /&gt; 

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>apj3wxsrdu0an06h326lv7owlpi7r1c</sha1>
    </revision>
    <revision>
      <id>3213</id>
      <parentid>3212</parentid>
      <timestamp>2025-06-24T12:40:39Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>3213</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7893" sha1="2vg6uho8a7tsgmetvmbcsdxajlxgdfz" xml:space="preserve">[[Isimumathi:Hector Pieterson Memorial, Soweto.jpg|thumb|264x264px|Ilitje lesikhumbuzo sika-Hector Pieterson]]
'''UZolile Hector Pieterson''' bekaneminyaka eli-12 lokha nakazakubulawa mapholisa womBuso weBandlululo ngomhlaka-16 kuMgwengweni 1976. Lokhu kwenzeke ngesikhathi abantwana babantu abanzima ababafundi benza umtjhagalo e-Soweto, balwela ukukhitjhwa kwemithethokambiso enganabulungisa yomBuso weBandlululo, balwela nokuthi isiBhuru kufuze singasabi lilimi okufundiswa ngalo ingcenye yeemfundo esikolweni sabanzima. Isithombe sokufa kwakhe esidumileko esatjhudwa nguSam Nzima senza iphasi loke lawuqala ngamanye amehlo umBuso weBandlululo. U-Hector Pieterson noHastings Ndlovu, naye obekamfundi, baba bantwana bokuthoma ukubulawa emTjhagalweni we-Soweto.&lt;ref&gt;Ernest Leong, J.E. Luebering (2025), ''Hector Pieterson'', Encyclopedia Britannica. Retrieved from: https://www.britannica.com/biography/Hector-Pieterson Retrieved on 23-06-2025.&lt;/ref&gt;   

== Umlando Ka-Hector Pieterson ==
UZolile Hector Pieterson wabelethwa ngo-1963 abelethwa nguDorothy Molefi unina, noyise uVivian Pieterson. Wabelethelwa bewakhuliselwa e-Soweto eSewula Afrika. Nanyana bekunguye omsana kunina, bekanabodadwabo abane, u-Antoinette Sithole noSina Molefi abeze nonina, bese uLulu Pieterson angudadwabo kubabelethi bobabili. Ngokwalokho unina akutjhoko ngaye, uthi u-Hector bekamsanyana othandekako othanda ukumomotheka, amsana ohlakaniphileko othanda amahlaya . Yena nodadwabo u-Antoinette bebangena isikolo sinye. Nanyana ngiliphi ibhudango ebekanalo ngengomuso lakhe latjhabalala mhla kuhlelwa ijima lomtjhagalo ngo-1976.&lt;ref&gt;Briefly Website, (2025), Hector Pieterson: The untold truth of the 1976 Soweto Uprising - Written on 17-06-2021, Retrieved from: https://briefly.co.za/31902-hector-pieterson-untold-truth-symbol-1976-soweto-uprising.html Retrieved on 23-06-2025.&lt;/ref&gt;

== Ibanga Lomtjhagalo We-Soweto ==
Umtjhagalo we-Soweto ngesikhuwa owaziwa ngokuthi yi-''Soweto Uprising'' wathoma ngomhlaka-16 kaMgwengweni 1976. Isizathu sokuba khona komtjhagalo lo kukwethulwa kwesiBhuru njengelimi okuzokufundwa ngalo ingcenye yeemfundo eenkolweni zabantu abanzima. Abantwana abaziinkulungwana ezimatjhumi amabili bahlanganyela emtjhagalweni lo. U-Hector nodadwabo u-Antoinette Sithole bebahlangana nesibalweso. Amapholisa womBuso webandlululo athuthumbisa iinkule nama-''teargas,'' kwafa isibalo sabantwana esingaba likhulu namatjhumi alikhomba nesithandathu. Kusolelwa bona abantwana abafa mhlokho bangaphezu kwesibalwesi.&lt;ref&gt;Zinn Education Project (2025), ''June 16, 1976: Soweto Uprising,'' Retrieved at: https://www.zinnedproject.org/news/tdih/soweto-uprising/ Retreived on 23-06-2025.&lt;/ref&gt; 

Nasizokuzwisisa bona izenzakalo zango-1976 zenzeka njani, kufuze sizwisise bona umsuka wazo uza njani. Ekuthomeni kwabo-1970, umnotho enarheni le bewusezingeni eliphasi, amanani wokuthenga izinto ezitlhogekako bekaphezulu, nemisebenzi iyindlala. Ngaphezu kwalokho bekunabantu abanengi abasuka eendaweni zemakhaya abeza bazokuhlala emalokitjhini ngebanga lokuthuthukisa ipilwabo. Ngebanga lalokho amalokitjhi besele anesibalo esikhulu sabantu abavela eendaweni ezinengi, bese lokho kwenza  neensetjenziswa zaba zincani. Lokhu kwabangela abantu bona bahlangahlangane bebathukuthele njengombana izinga lokuphila sele lehle khulu. Kodwana lokho khenge kube semtarini bekwaba kulapho kuthoma umtjhagalo wabantwana besikolo. &lt;ref name=&quot;:0&quot;&gt;South African History Archive (SAHA), (2025), ''The Youth take charge: the Soweto Uprising of June 1976'', Retrieved from: https://www.saha.org.za/youth/bantu_education.htm Retrived on 23-06-2025.&lt;/ref&gt;

Abantwana besikolo bangesikhatheso besele bangasanalo ithemba ngengomuso. Iinkumba zokufundela bezizele swi ngabangafundi, zinganazo iintlabagelo ezaneleko zokufunda, begodu abotitjhere nabazakulawula kuhle abantwana bekufuze babakhalime budisi ngokubabetha nangokubajezisa ngezinye iindlela ezibudisi. Kuncani khulu ebekufundwa esikolweni ngesikhatheso. Ngaphezu kwalokho ngo-1975, urhulumende wangezelela ebudisini ebebaqalene nabo ngokuthatha isiqunto sokuthi isiBhuru kube lilimi okuzokufundwa ngalo iimfundo esikolweni, okutjho bona ingcenye yeemfundo ezifundwako kufuze zifundiswe ngesiBhuru.&lt;ref name=&quot;:0&quot; /&gt;

Ukufundiswa kweemfundo ngesiBhuru kwaletha umraro okabili. Kokuthoma abotitjhere bebangakghoni ukufundisa ngesiBhuru, ngapha nabafundi bangakghoni ukulikhuluma kuhle ilimeli, okutjho bona abafundi bebazokufeyila iimvivinyo zabo, bese babe bomahlalela bangawufumani umsebenzi. Okwesibili isiBhuru besiqalwa njengelimi labagqilazi, okwenza abantwana banyanya ukulisebenzisa. Ngaphezu kobana kuthethe iinyanga abazali bafake iimbawo neenghonghoyilo ngendaba le, umBuso waragela phambili nesiqunto sawo. Kwathi ekuthomeni kwango-1976 abafundi bathoma ukuhlela amajima wokulwisana nesiBhuru, nanyana kunjalo urhulumende waqinisa ihloko, wala ukulalela iinghonghoyilo zabo. Ngebanga lalokho, iinkulungwana zabafundi e-Soweto zamatjhela e-Orlando Stadium ngomhlaka-16 kaMgwengweni 1976, okukulapho baletha khona iinghonghoyilo zabo.&lt;ref name=&quot;:0&quot; /&gt;

Kunokuthi kulalelwe iinghonghoyilo zabafundaba abatjhagala ngokuthula, amapholisa womBuso weBandlululo athoma ukuvulela ngeenkule ebafundini. U-Hector Pieterson waba ngewokuthoma ukudumuzeka bewafa. Amapholisa araga nokudumuza abafundi, kodwana lokho khenge kubajamise abafundi ekutjhagaleni. Kunalokho, ukubulawa kuka-Hector kwabenza baqunga isibindi sokuraga nomtjhagalo. Baqalana namapholisa, bebatjhisa nama-ofisi we-''West Rand Administration Board (WRAB),'' ebebayiqala njengetshwayo lokugqilazwa nokugandelelwa. Batjhisa bebatjhisa neengodiphola okuziindawo ebeziqalwa njengamahlelo karhulumende wokuqeda isimilo sabantu abanzima.&lt;ref name=&quot;:0&quot; /&gt;

Nanyana urhulumende webandlululo athumela amasotja e-Soweto bona ayokujamisa umtjhagalo lo, abantu baraga nawo iinyanga ezintathu zoke. Izenzo zabo zabasela abanye abantu abatjha kiyo yoke inarha, kwaqubuka imitjhagalo ngemitjhagalo emalokitjhini enarheni yoke. Abantu abatjha abangaba makhulu amathathu babhubha, abaziinkulungwana ezimbili balimala. Boke abafundaba - kuhlanganise no-Hector Pietersen babhadela ngepilwabo ekuthuthukiseni ifundo yabantu abanzima.&lt;ref name=&quot;:0&quot; /&gt;

== Indima Edlalwe Kukufa Kuka-Hector Pieterson ==
[[Isimumathi:Hector Pieterson Museum, Soweto.jpg|thumb|312x312px|Imiziyamu ka-Hector Pieterson]]
Ukuhlongakala kuka-Hector Pieterson kudlale indima ekulu ekulwelweni kwamalungelo wobuntu nomBuso webandlululo kangangobana ilanga langomhlaka-16 kaMgwengweni lilanga labantu abatjha eligidingwa enarheni yoke. Isithombe sika-Hector athwelwe ngu[[Mbuyisa Makhubu|Mbuyisa Makhubo]], dnoadwabo ka-Hector agijima hlanu kwabo ngiso esithathwa njengetshwayo lelangeli. Isithombesi singezinye zeenthombe eziveza isehlakalwesi ezithwetjulwe nguSam Nzima.&lt;ref name=&quot;:1&quot;&gt;Lucille Davie, (14 June 2002), ''Hector: the famous child''

''whose face is unknown,'' Web Archive website (2023). Retrieved from: https://web.archive.org/web/20030327052242/https://joburg.org.za/june_2002/hector.stm Retrieved on 24-06-2025.&lt;/ref&gt; 

Ngaphezu kwalokho, bekwavulwa nemiziyamu ebizwa ngegama lakhe - ''Hector Pieterson Museum'' - e-Orlando West e-Soweto. Imiziyamu le isesitaradeni sesibili ukusukela lapha u-Hector adunyuzelwa khona. Indawo le inamafilimu, amaphephandaba, ukulandisa kwabantu abazibonele ngewabo isenzakalwesi neenthombe, nalesi esidume khulu esathwetjulwa nguSam Nzima. i-''Hector Peterson Museum'' yimiziyamu yokuthoma e-Soweto eyavulwa ngomhlaka-16 kaMgwengweni 2002. Kuthethe imali engange-R23 200 000 ukuyakha begodu i-R16 000 000 yimali enikelwe ngokuzithandela mNyango wezeBhoduluko nezokuVakatjha, bese i-R7 200 000 yanikelwa Mkhandlu weDorobho le-Johannesburg. Yeke imiziyamu le iyokuhlala isikhumbuzo sokufa kuka-Hector Pieterson nokulwela kwabantu abatjha itjhaphuluko.&lt;ref name=&quot;:1&quot; /&gt; 

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>2vg6uho8a7tsgmetvmbcsdxajlxgdfz</sha1>
    </revision>
    <revision>
      <id>3214</id>
      <parentid>3213</parentid>
      <timestamp>2025-06-24T12:43:39Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>3214</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7892" sha1="pnplh2s1c5iqmzi1vso6p4asacj4pok" xml:space="preserve">[[Isimumathi:Hector Pieterson Memorial, Soweto.jpg|thumb|264x264px|Ilitje lesikhumbuzo sika-Hector Pieterson]]
'''UZolile Hector Pieterson''' bekaneminyaka eli-12 lokha nakazakubulawa mapholisa womBuso weBandlululo ngomhlaka-16 kuMgwengweni 1976. Lokhu kwenzeke ngesikhathi abantwana babantu abanzima ababafundi benza umtjhagalo e-Soweto, balwela ukukhitjhwa kwemithethokambiso enganabulungisa yomBuso weBandlululo, balwela nokuthi isiBhuru kufuze singasabi lilimi okufundiswa ngalo ingcenye yeemfundo esikolweni sabanzima. Isithombe sokufa kwakhe esidumileko esatjhudwa nguSam Nzima senza iphasi loke lawuqala ngamanye amehlo umBuso weBandlululo. U-Hector Pieterson noHastings Ndlovu, naye obekamfundi, baba bantwana bokuthoma ukubulawa emTjhagalweni we-Soweto.&lt;ref&gt;Ernest Leong, J.E. Luebering (2025), ''Hector Pieterson'', Encyclopedia Britannica. Retrieved from: https://www.britannica.com/biography/Hector-Pieterson Retrieved on 23-06-2025.&lt;/ref&gt;   

== Umlando Ka-Hector Pieterson ==
UZolile Hector Pieterson wabelethwa ngo-1963 abelethwa nguDorothy Molefi unina, noyise uVivian Pieterson. Wabelethelwa bewakhuliselwa e-Soweto eSewula Afrika. Nanyana bekunguye omsana kunina, bekanabodadwabo abane, u-Antoinette Sithole noSina Molefi abeze nonina, bese uLulu Pieterson angudadwabo kubabelethi bobabili. Ngokwalokho unina akutjhoko ngaye, uthi u-Hector bekamsanyana othandekako othanda ukumomotheka, amsana ohlakaniphileko othanda amahlaya . Yena nodadwabo u-Antoinette bebangena isikolo sinye. Nanyana ngiliphi ibhudango ebekanalo ngengomuso lakhe latjhabalala mhla kuhlelwa ijima lomtjhagalo ngo-1976.&lt;ref&gt;Briefly Website, (2025), Hector Pieterson: The untold truth of the 1976 Soweto Uprising - Written on 17-06-2021, Retrieved from: https://briefly.co.za/31902-hector-pieterson-untold-truth-symbol-1976-soweto-uprising.html Retrieved on 23-06-2025.&lt;/ref&gt;

== Ibanga Lomtjhagalo We-Soweto ==
Umtjhagalo we-Soweto ngesikhuwa owaziwa ngokuthi yi-''Soweto Uprising'' wathoma ngomhlaka-16 kaMgwengweni 1976. Isizathu sokuba khona komtjhagalo lo kukwethulwa kwesiBhuru njengelimi okuzokufundwa ngalo ingcenye yeemfundo eenkolweni zabantu abanzima. Abantwana abaziinkulungwana ezimatjhumi amabili bahlanganyela emtjhagalweni lo. U-Hector nodadwabo u-Antoinette Sithole bebahlangana nesibalweso. Amapholisa womBuso webandlululo athuthumbisa iinkule nama-''teargas,'' kwafa isibalo sabantwana esingaba likhulu namatjhumi alikhomba nesithandathu. Kusolelwa bona abantwana abafa mhlokho bangaphezu kwesibalwesi.&lt;ref&gt;Zinn Education Project (2025), ''June 16, 1976: Soweto Uprising,'' Retrieved at: https://www.zinnedproject.org/news/tdih/soweto-uprising/ Retreived on 23-06-2025.&lt;/ref&gt; 

Nasizokuzwisisa bona izenzakalo zango-1976 zenzeka njani, kufuze sizwisise bona umsuka wazo uza njani. Ekuthomeni kwabo-1970, umnotho enarheni le bewusezingeni eliphasi, amanani wokuthenga izinto ezitlhogekako bekaphezulu, nemisebenzi iyindlala. Ngaphezu kwalokho bekunabantu abanengi abasuka eendaweni zemakhaya abeza bazokuhlala emalokitjhini ngebanga lokuthuthukisa ipilwabo. Ngebanga lalokho amalokitjhi besele anesibalo esikhulu sabantu abavela eendaweni ezinengi, bese lokho kwenza  neensetjenziswa zaba zincani. Lokhu kwabangela abantu bona bahlangahlangane bebathukuthele njengombana izinga lokuphila sele lehle khulu. Kodwana lokho khenge kube semtarini bekwaba kulapho kuthoma umtjhagalo wabantwana besikolo.&lt;ref name=&quot;:0&quot;&gt;South African History Archive (SAHA), (2025), ''The Youth take charge: the Soweto Uprising of June 1976'', Retrieved from: https://www.saha.org.za/youth/bantu_education.htm Retrived on 23-06-2025.&lt;/ref&gt;

Abantwana besikolo bangesikhatheso besele bangasanalo ithemba ngengomuso. Iinkumba zokufundela bezizele swi ngabangafundi, zinganazo iintlabagelo ezaneleko zokufunda, begodu abotitjhere nabazakulawula kuhle abantwana bekufuze babakhalime budisi ngokubabetha nangokubajezisa ngezinye iindlela ezibudisi. Kuncani khulu ebekufundwa esikolweni ngesikhatheso. Ngaphezu kwalokho ngo-1975, urhulumende wangezelela ebudisini ebebaqalene nabo ngokuthatha isiqunto sokuthi isiBhuru kube lilimi okuzokufundwa ngalo iimfundo esikolweni, okutjho bona ingcenye yeemfundo ezifundwako kufuze zifundiswe ngesiBhuru.&lt;ref name=&quot;:0&quot; /&gt;

Ukufundiswa kweemfundo ngesiBhuru kwaletha umraro okabili. Kokuthoma abotitjhere bebangakghoni ukufundisa ngesiBhuru, ngapha nabafundi bangakghoni ukulikhuluma kuhle ilimeli, okutjho bona abafundi bebazokufeyila iimvivinyo zabo, bese babe bomahlalela bangawufumani umsebenzi. Okwesibili isiBhuru besiqalwa njengelimi labagqilazi, okwenza abantwana banyanya ukulisebenzisa. Ngaphezu kobana kuthethe iinyanga abazali bafake iimbawo neenghonghoyilo ngendaba le, umBuso waragela phambili nesiqunto sawo. Kwathi ekuthomeni kwango-1976 abafundi bathoma ukuhlela amajima wokulwisana nesiBhuru, nanyana kunjalo urhulumende waqinisa ihloko, wala ukulalela iinghonghoyilo zabo. Ngebanga lalokho, iinkulungwana zabafundi e-Soweto zamatjhela e-Orlando Stadium ngomhlaka-16 kaMgwengweni 1976, okukulapho baletha khona iinghonghoyilo zabo.&lt;ref name=&quot;:0&quot; /&gt;

Kunokuthi kulalelwe iinghonghoyilo zabafundaba abatjhagala ngokuthula, amapholisa womBuso weBandlululo athoma ukuvulela ngeenkule ebafundini. U-Hector Pieterson waba ngewokuthoma ukudumuzeka bewafa. Amapholisa araga nokudumuza abafundi, kodwana lokho khenge kubajamise abafundi ekutjhagaleni. Kunalokho, ukubulawa kuka-Hector kwabenza baqunga isibindi sokuraga nomtjhagalo. Baqalana namapholisa, bebatjhisa nama-ofisi we-''West Rand Administration Board (WRAB),'' ebebayiqala njengetshwayo lokugqilazwa nokugandelelwa. Batjhisa bebatjhisa neengodiphola okuziindawo ebeziqalwa njengamahlelo karhulumende wokuqeda isimilo sabantu abanzima.&lt;ref name=&quot;:0&quot; /&gt;

Nanyana urhulumende webandlululo athumela amasotja e-Soweto bona ayokujamisa umtjhagalo lo, abantu baraga nawo iinyanga ezintathu zoke. Izenzo zabo zabasela abanye abantu abatjha kiyo yoke inarha, kwaqubuka imitjhagalo ngemitjhagalo emalokitjhini enarheni yoke. Abantu abatjha abangaba makhulu amathathu babhubha, abaziinkulungwana ezimbili balimala. Boke abafundaba - kuhlanganise no-Hector Pietersen babhadela ngepilwabo ekuthuthukiseni ifundo yabantu abanzima.&lt;ref name=&quot;:0&quot; /&gt;

== Indima Edlalwe Kukufa Kuka-Hector Pieterson ==
[[Isimumathi:Hector Pieterson Museum, Soweto.jpg|thumb|312x312px|Imiziyamu ka-Hector Pieterson]]
Ukuhlongakala kuka-Hector Pieterson kudlale indima ekulu ekulwelweni kwamalungelo wobuntu nomBuso webandlululo kangangobana ilanga langomhlaka-16 kaMgwengweni lilanga labantu abatjha eligidingwa enarheni yoke. Isithombe sika-Hector athwelwe ngu[[Mbuyisa Makhubu|Mbuyisa Makhubo]], dnoadwabo ka-Hector agijima hlanu kwabo ngiso esithathwa njengetshwayo lelangeli. Isithombesi singezinye zeenthombe eziveza isehlakalwesi ezithwetjulwe nguSam Nzima.&lt;ref name=&quot;:1&quot;&gt;Lucille Davie, (14 June 2002), ''Hector: the famous child''

''whose face is unknown,'' Web Archive website (2023). Retrieved from: https://web.archive.org/web/20030327052242/https://joburg.org.za/june_2002/hector.stm Retrieved on 24-06-2025.&lt;/ref&gt; 

Ngaphezu kwalokho, bekwavulwa nemiziyamu ebizwa ngegama lakhe - ''Hector Pieterson Museum'' - e-Orlando West e-Soweto. Imiziyamu le isesitaradeni sesibili ukusukela lapha u-Hector adunyuzelwa khona. Indawo le inamafilimu, amaphephandaba, ukulandisa kwabantu abazibonele ngewabo isenzakalwesi neenthombe, nalesi esidume khulu esathwetjulwa nguSam Nzima. i-''Hector Peterson Museum'' yimiziyamu yokuthoma e-Soweto eyavulwa ngomhlaka-16 kaMgwengweni 2002. Kuthethe imali engange-R23 200 000 ukuyakha begodu i-R16 000 000 yimali enikelwe ngokuzithandela mNyango wezeBhoduluko nezokuVakatjha, bese i-R7 200 000 yanikelwa Mkhandlu weDorobho le-Johannesburg. Yeke imiziyamu le iyokuhlala isikhumbuzo sokufa kuka-Hector Pieterson nokulwela kwabantu abatjha itjhaphuluko.&lt;ref name=&quot;:1&quot; /&gt; 

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>pnplh2s1c5iqmzi1vso6p4asacj4pok</sha1>
    </revision>
    <revision>
      <id>3238</id>
      <parentid>3214</parentid>
      <timestamp>2025-06-26T14:11:47Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>putting references</comment>
      <origin>3238</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8640" sha1="ieq4mfv6vgz8k71nzbdci08m787x8zl" xml:space="preserve">[[Isimumathi:Hector Pieterson Memorial, Soweto.jpg|thumb|264x264px|Ilitje lesikhumbuzo sika-Hector Pieterson]]
'''UZolile Hector Pieterson''' bekaneminyaka eli-12 lokha nakazakubulawa mapholisa womBuso weBandlululo ngomhlaka-16 kuMgwengweni 1976. Lokhu kwenzeke ngesikhathi abantwana babantu abanzima ababafundi benza umtjhagalo e-Soweto, balwela ukukhitjhwa kwemithethokambiso enganabulungisa yomBuso weBandlululo, balwela nokuthi isiBhuru kufuze singasabi lilimi okufundiswa ngalo ingcenye yeemfundo esikolweni sabanzima. Isithombe sokufa kwakhe esidumileko esathwetjulwa nguSam Nzima senza iphasi loke lawuqala ngamanye amehlo umBuso weBandlululo. U-Hector Pieterson naye [[u-Hastings Ndlovu]], obekamfundi wesikolo samabanga aphezulu, baba bantwana bokuthoma ukubulawa emTjhagalweni we-Soweto.&lt;ref&gt;Ernest Leong, J.E. Luebering (2025), ''Hector Pieterson'', Encyclopedia Britannica. Retrieved from: https://www.britannica.com/biography/Hector-Pieterson Retrieved on 23-06-2025.&lt;/ref&gt;   

== Umlando Ka-Hector Pieterson ==
UZolile Hector Pieterson wabelethwa ngo-1963, abelethwa ngu-Dorothy Molefi unina, noyise u-Vivian Pieterson. Wabelethelwa bewakhuliselwa e-Soweto eSewula Afrika. Nanyana bekunguye omsana kunina, bekanabodadwabo abane, u-Antoinette Sithole no-Sina Molefi abeze nonina, bese u-Lulu Pieterson angudadwabo kubabelethi bobabili. Ngokwalokho unina akutjhoko ngaye, uthi u-Hector bekamsanyana othandekako othanda ukumomotheka, amsana ohlakaniphileko othanda amahlaya . Yena nodadwabo u-Antoinette bebangena isikolo sinye. Nanyana ngiliphi ibhudango ebekanalo ngengomuso lakhe latjhabalala mhla kuhlelwa ijima lomtjhagalo ngo-1976.&lt;ref&gt;Briefly Website, (2025), Hector Pieterson: The untold truth of the 1976 Soweto Uprising - Written on 17-06-2021, Retrieved from: https://briefly.co.za/31902-hector-pieterson-untold-truth-symbol-1976-soweto-uprising.html Retrieved on 23-06-2025.&lt;/ref&gt;

== Ibanga Lomtjhagalo We-Soweto ==
Umtjhagalo we-Soweto ngesikhuwa owaziwa ngokuthi yi-''Soweto Uprising'' wathoma ngomhlaka-16 kaMgwengweni 1976. Isizathu sokuba khona komtjhagalo lo kukwethulwa kwesiBhuru njengelimi okuzokufundwa ngalo ingcenye yeemfundo eenkolweni zabantu abanzima. Abantwana abaziinkulungwana ezimatjhumi amabili bahlanganyela emtjhagalweni lo. U-Hector nodadwabo u-Antoinette Sithole bebahlangana nesibalweso. Kuthiwa [[U-Teboho MacDonald Mashinini (Tsietsi)|u-Teboho MacDonald Mashinini]]  owaziwa ngelika-Tsietsi ungomunye wabadosiphambili bomtjhagalo lo.&lt;ref&gt;Mecoamere, Victor (27 May 2013). &quot;Naledi High turns 50&quot;. S''owetan Live''. Retrieved from: https://www.sowetanlive.co.za/news/2013-05-27-naledi-high-turns-50/ 23 July 2013.&lt;/ref&gt; Amapholisa womBuso webandlululo athuthumbisa iinkule nama-''teargas,'' kwafa isibalo sabantwana esingaba likhulu namatjhumi alikhomba nesithandathu. Kusolelwa bona abantwana abafa mhlokho bangaphezu kwesibalwesi.&lt;ref&gt;Zinn Education Project (2025), ''June 16, 1976: Soweto Uprising,'' Retrieved at: https://www.zinnedproject.org/news/tdih/soweto-uprising/ Retreived on 23-06-2025.&lt;/ref&gt; 

Nasizokuzwisisa bona izenzakalo zango-1976 zenzeka njani, kufuze sizwisise bona umsuka wazo uza njani. Ekuthomeni kwabo-1970, umnotho enarheni le bewusezingeni eliphasi, amanani wokuthenga izinto ezitlhogekako bekaphezulu, ngapha imisebenzi iyindlala. Ngaphezu kwalokho bekunabantu abanengi abasuka eendaweni zemakhaya abeza bazokuhlala emalokitjhini ngebanga lokufuna lokuthuthukisa ipilwabo. Ngebanga lalokho amalokitjhi besele anesibalo esikhulu sabantu abavela eendaweni ezinengi, bese lokho kwenza  neensetjenziswa zaba zincani. Lokhu kwabangela abantu bona bahlangahlangane bebathukuthele njengombana izinga lokuphila sele lehle khulu. Kodwana lokho khenge kube semtarini bekwaba kulapho kuthoma umtjhagalo wabantwana besikolo.&lt;ref name=&quot;:0&quot;&gt;South African History Archive (SAHA), (2025), ''The Youth take charge: the Soweto Uprising of June 1976'', Retrieved from: https://www.saha.org.za/youth/bantu_education.htm Retrived on 23-06-2025.&lt;/ref&gt;

Abantwana besikolo bangesikhatheso besele bangasanalo ithemba ngengomuso. Iinkumba zokufundela bezizele swi ngabangafundi, zinganazo iintlabagelo ezaneleko zokufunda, begodu abotitjhere nabazakulawula kuhle abantwana bekufuze babakhalime budisi ngokubabetha nangokubajezisa ngezinye iindlela ezibudisi. Kuncani khulu ebekufundwa esikolweni ngesikhatheso. Ngaphezu kwalokho ngo-1975, urhulumende wangezelela ebudisini ebebaqalene nabo ngokuthatha isiqunto sokuthi isiBhuru kube lilimi okuzokufundwa ngalo iimfundo esikolweni, okutjho bona ingcenye yeemfundo ezifundwako eenkolweni kufuze zifundiswe ngesiBhuru.&lt;ref name=&quot;:0&quot; /&gt;

Ukufundiswa kweemfundo ngesiBhuru kwaletha umraro okabili. Kokuthoma abotitjhere bebangakghoni ukufundisa ngesiBhuru, ngapha nabafundi bangakghoni ukulikhuluma kuhle ilimeli, okutjho bona abafundi bebazokufeyila iimvivinyo zabo, bese babe bomahlalela bangawufumani umsebenzi. Okwesibili isiBhuru besiqalwa njengelimi labagqilazi, okwenza abantwana banyanya ukulisebenzisa. Ngaphezu kobana kuthethe iinyanga abazali bafake iimbawo neenghonghoyilo ngendaba le, umBuso waragela phambili nesiqunto sawo. Kwathi ekuthomeni kwango-1976 abafundi bathoma ukuhlela amajima wokulwisana nesiBhuru, nanyana kunjalo urhulumende waqinisa ihloko, wala ukulalela iinghonghoyilo zabo. Ngebanga lalokho, iinkulungwana zabafundi e-Soweto zamatjhela e-Orlando Stadium ngomhlaka-16 kaMgwengweni 1976, okukulapho baletha khona iinghonghoyilo zabo.&lt;ref name=&quot;:0&quot; /&gt;

Kunokuthi kulalelwe iinghonghoyilo zabafundaba abatjhagala ngokuthula, amapholisa womBuso weBandlululo athoma ukuvulela ngeenkule ebafundini. U-Hector Pieterson waba ngewokuthoma ukudumuzeka bewafa. abanye bathi ngu-Hestings Ndlovu owadunyuzwa kokuthoma.&lt;ref&gt;South African.Info (18 November 2016), ''Hastings: forgotten hero of 1976,'' Web Archive (2016). Retrieved from: https://web.archive.org/web/20161118053520if_/http://www.southafrica.info/about/history/hastings-ndlovu-150605.htm#.WC6TI-j7Q2w Retrieved on 26-06-2025.&lt;/ref&gt;  Amapholisa araga nokudumuza abafundi, kodwana lokho khenge kubajamise abafundi ekutjhagaleni. Kunalokho, ukubulawa kuka-Hector kwabenza baqunga isibindi sokuraga nomtjhagalo. Baqalana namapholisa, bebatjhisa nama-ofisi we-''West Rand Administration Board (WRAB),'' ebebayiqala njengetshwayo lokugqilazwa nokugandelelwa. Batjhisa bebatjhisa neengodiphola, okuziindawo ebeziqalwa njengamahlelo karhulumende wokuqeda isimilo sabantu abanzima.&lt;ref name=&quot;:0&quot; /&gt;

Nanyana urhulumende webandlululo athumela amasotja e-Soweto bona ayokujamisa umtjhagalo lo, abantu baraga nawo iinyanga ezintathu zoke. Izenzo zabo zabasela abanye abantu abatjha kiyo yoke inarha, kwaqubuka imitjhagalo ngemitjhagalo emalokitjhini enarheni yoke. Abantu abatjha abangaba makhulu amathathu babhubha, abaziinkulungwana ezimbili balimala. Boke abafundaba - kuhlanganise no-Hector Pietersen babhadela ngepilwabo ekuthuthukiseni ifundo yabantu abanzima.&lt;ref name=&quot;:0&quot; /&gt;

== Indima Edlalwe Kukufa Kuka-Hector Pieterson ==
[[Isimumathi:Hector Pieterson Museum, Soweto.jpg|thumb|312x312px|Imiziyamu ka-Hector Pieterson]]
Ukuhlongakala kuka-Hector Pieterson kudlale indima ekulu ekulwelweni kwamalungelo wobuntu nomBuso webandlululo kangangobana ilanga langomhlaka-16 kaMgwengweni lilanga labantu abatjha eligidingwa enarheni yoke. Isithombe sika-Hector athwelwe ngu[[Mbuyisa Makhubu|Mbuyisa Makhubo]], nodadwabo ka-Hector agijima hlanu kwabo, ngiso esithathwa njengesilitshwayo lelangeli. Isithombesi singezinye zeenthombe eziveza isehlakalwesi ezithwetjulwe nguSam Nzima.&lt;ref name=&quot;:1&quot;&gt;Lucille Davie, (14 June 2002), ''Hector: the famous child''

''whose face is unknown,'' Web Archive website (2023). Retrieved from: https://web.archive.org/web/20030327052242/https://joburg.org.za/june_2002/hector.stm Retrieved on 24-06-2025.&lt;/ref&gt; 

Ngaphezu kwalokho, bekwavulwa nemiziyamu ebizwa ngegama lakhe - ''Hector Pieterson Museum'' - e-Orlando West e-Soweto. Imiziyamu le isesitaradeni sesibili ukusukela lapha u-Hector adunyuzelwa khona. Indawo le inamafilimu, amaphephandaba, ukulandisa kwabantu abazibonele ngewabo nakwenzeka isenzakalwesi, neenthombe, nalesi esidume khulu esathwetjulwa nguSam Nzima. i-''Hector Peterson Museum'' yimiziyamu yokuthoma e-Soweto eyavulwa ngomhlaka-16 kaMgwengweni 2002. Kuthethe imali engange-R23 200 000 ukuyakha begodu i-R16 000 000 yimali enikelwe ngokuzithandela mNyango wezeBhoduluko nezokuVakatjha, bese i-R7 200 000 yanikelwa Mkhandlu weDorobho le-Johannesburg. Yeke imiziyamu le iyokuhlala isikhumbuzo sokufa kuka-Hector Pieterson nokulwela kwabantu abatjha itjhaphuluko.&lt;ref name=&quot;:1&quot; /&gt; 

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>ieq4mfv6vgz8k71nzbdci08m787x8zl</sha1>
    </revision>
  </page>
  <page>
    <title>Indima eyadlalwa yilutjha emzabalazweni wekululeko</title>
    <ns>0</ns>
    <id>652</id>
    <revision>
      <id>3222</id>
      <timestamp>2025-06-25T09:55:50Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''Umzabalazo wekululeko''' ngilokha abantu bavusa ipi nofana baba nenturhu ukulwisana nombuso wegandelelo.&lt;ref&gt;Houston, G.F., 2019. ''The National Liberation Struggle in South Africa: A Case Study of the United Democratic Front, 1983-87''. Routledge.&lt;/ref&gt; Umzabalazo wekululeko bewudoswa phambili ziinqhema ezinengi zabantu ekungaba misikinyeko nofana iinhlangano ezabe zenziwe ngaleso sikhathi. Iinqhema lezi zabe zihlose ukuthola ikululeko, ukulingana Kanye nombuso wenta...&quot;</comment>
      <origin>3222</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3090" sha1="qam5ycpdwkszljh33wv89ll0f7774g4" xml:space="preserve">'''Umzabalazo wekululeko''' ngilokha abantu bavusa ipi nofana baba nenturhu ukulwisana nombuso wegandelelo.&lt;ref&gt;Houston, G.F., 2019. ''The National Liberation Struggle in South Africa: A Case Study of the United Democratic Front, 1983-87''. Routledge.&lt;/ref&gt; Umzabalazo wekululeko bewudoswa phambili ziinqhema ezinengi zabantu ekungaba misikinyeko nofana iinhlangano ezabe zenziwe ngaleso sikhathi. Iinqhema lezi zabe zihlose ukuthola ikululeko, ukulingana Kanye nombuso wentando yenengi ebantwini boke abahlala eSewula Afrika.

=== Indima eyadlwa yilutjha ekuletheni ekuletheni ikululeko ===
Ukuhlela ukubhenyoga

Lokha abantu abatjha bekuba ngiba ngobo abadosa phambili ukubhenyoga kwesitjhaba bebasebenzisa iindlela ezithileko ukulwisana nabaphathi nofana abadosi phambili bombuso loyo. Isibonelo sokubhenyoga ngelesi sokuphakama kweSoweto ngonyaka we-1976 lapho ilutjha kahabe lilwisana khona nokufundiswa khona kwelimi lesibhuru ngekatelelo eenkolweni.&lt;ref&gt;Ndlovu, S., 2017. ''The Soweto Uprisings: Counter Memories of June 1976''. Pan Macmillan South africa.&lt;/ref&gt; Omunye welutjha elabe lidosa phambili ukubhenyoga lokhu kwabe kungu Tsietsi Mashinini. Abanye abafundi bahlongakala lokha nakubhenyogwako ngombana badutjulwa. UHector peterson owabe eneminyaka eli-12, no Hastings Ndlovu owabe eneminyaka eli-15.&lt;ref&gt;Krog, A., 2022. Some new perspectives on the Soweto uprising: HML Lentsoane’s poem “Black Wednesday”(“Laboraro le lesoleso”). ''Tydskrif vir letterkunde'', ''59''(3), pp.113-130.&lt;/ref&gt;

Ukutjhukumisa imiphakathi        

Ilutjha ladlala indima yokuthi litjhukumise imiphakathi begodu liwazise ngokuthi liphala lapho bangatholi khona ubulungiswa begodu sikhombise umphakathi ukuthi sitlhoga umbuso wentando yenengi khona woke umuntu azokutjhaphuluka. Okhunye kukuthi ihlagano ye-ANC yathoma yenza amaphetjhana atlolwe ukuthi “tjhaphululani uMandela bese nilengise u Vorster” lokhu kwenziwa kokuthi nilutjha lisuse inturhu eSoweto. Abasebenzi abanzima nabo bagcina babanga imguruguru ngombana basikinywa yinto eyenziwa mbuso, ukuthi babulale abafundi.

Ukwakha ubudlelwano benhlangano, nemisikinyeko

Ilutjha lasiza ukwakha ukuhlangana nofana ukwenza ukuthi kube khona ubudlelwana phakathi kwenhlangano, imisikinyeko nekukhuliseni imiphakhathi iqinise ukubumbana kwabantu. Imisikinyeko yelutjha efana neCOSAS ejamele ukuthi ''congress of south african students, ne-''SASCO ejamele ukuthi ''South African student congress'' zasungulwa ukuthi zikhone ukuthi zilwisane ukuthi zikghone ukulwisana nebandlululo elabe likhona ngaleso skhathi.&lt;ref&gt;Ngwane, T., 2017. Learning in struggle: an activist’s view of the transition from apartheid to democracy in South Africa. In ''Reflections on Knowledge, Learning and Social Movements'' (pp. 168-185). Routledge.&lt;/ref&gt; iSASCO yoona yavela ngaphasi kwehlangano ye-ANC.

Nanyana umzabalazo wekululeko waphela kodwa uphethe ubujalo benarha begodu uyaraga ukubumba inarha ngokuzama ukuthi kungasabi nokubandlululana kwakade begodu kwakhiwe inarha eyamukela woke umuntu ngendlela angayo ngokombala, ukukhuluma nokhunye.</text>
      <sha1>qam5ycpdwkszljh33wv89ll0f7774g4</sha1>
    </revision>
    <revision>
      <id>3223</id>
      <parentid>3222</parentid>
      <timestamp>2025-06-25T10:03:38Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3223</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3090" sha1="ebpg5qh9v1gt25fgfwjucjnisk6acv6" xml:space="preserve">'''Umzabalazo wekululeko''' ngilokha abantu bavusa ipi nofana baba nenturhu ukulwisana nombuso webandlululo.&lt;ref&gt;Houston, G.F., 2019. ''The National Liberation Struggle in South Africa: A Case Study of the United Democratic Front, 1983-87''. Routledge.&lt;/ref&gt; Umzabalazo wekululeko bewudoswa phambili ziinqhema ezinengi zabantu ekungaba misikinyeko nofana iinhlangano ezabe zenziwe ngaleso sikhathi. Iinqhema lezi zabe zihlose ukuthola ikululeko, ukulingana Kanye nombuso wentando yenengi ebantwini boke abahlala eSewula Afrika.

=== Indima eyadlwa yilutjha ekuletheni ekuletheni ikululeko ===
Ukuhlela ukubhenyoga

Lokha abantu abatjha bekuba ngiba ngobo abadosa phambili ukubhenyoga kwesitjhaba bebasebenzisa iindlela ezithileko ukulwisana nabaphathi nofana abadosi phambili bombuso loyo. Isibonelo sokubhenyoga ngelesi sokuphakama kweSoweto ngonyaka we-1976 lapho ilutjha khabe lilwisana khona nokufundiswa khona kwelimi lesibhuru ngekatelelo eenkolweni.&lt;ref&gt;Ndlovu, S., 2017. ''The Soweto Uprisings: Counter Memories of June 1976''. Pan Macmillan South africa.&lt;/ref&gt; Omunye welutjha elabe lidosa phambili ukubhenyoga lokhu kwabe kungu Tsietsi Mashinini. Abanye abafundi bahlongakala lokha nakubhenyogwako ngombana badutjulwa. UHector peterson owabe eneminyaka eli-12, no Hastings Ndlovu owabe eneminyaka eli-15.&lt;ref&gt;Krog, A., 2022. Some new perspectives on the Soweto uprising: HML Lentsoane’s poem “Black Wednesday”(“Laboraro le lesoleso”). ''Tydskrif vir letterkunde'', ''59''(3), pp.113-130.&lt;/ref&gt;

Ukutjhukumisa imiphakathi        

Ilutjha ladlala indima yokuthi litjhukumise imiphakathi begodu liwazise ngokuthi liphala lapho bangatholi khona ubulungiswa begodu sikhombise umphakathi ukuthi sitlhoga umbuso wentando yenengi khona woke umuntu azokutjhaphuluka. Okhunye kukuthi ihlagano ye-ANC yathoma yenza amaphetjhana atlolwe ukuthi “tjhaphululani uMandela bese nilengise u Vorster” lokhu kwenziwa kokuthi nilutjha lisuse inturhu eSoweto. Abasebenzi abanzima nabo bagcina babanga imguruguru ngombana basikinywa yinto eyenziwa mbuso, ukuthi babulale abafundi.

Ukwakha ubudlelwano benhlangano, nemisikinyeko

Ilutjha lasiza ukwakha ukuhlangana nofana ukwenza ukuthi kube khona ubudlelwana phakathi kwenhlangano, imisikinyeko nekukhuliseni imiphakhathi iqinise ukubumbana kwabantu. Imisikinyeko yelutjha efana neCOSAS ejamele ukuthi ''congress of south african students, ne-''SASCO ejamele ukuthi ''South African student congress'' zasungulwa ukuthi zikhone ukuthi zilwisane ukuthi zikghone ukulwisana nebandlululo elabe likhona ngaleso skhathi.&lt;ref&gt;Ngwane, T., 2017. Learning in struggle: an activist’s view of the transition from apartheid to democracy in South Africa. In ''Reflections on Knowledge, Learning and Social Movements'' (pp. 168-185). Routledge.&lt;/ref&gt; iSASCO yoona yavela ngaphasi kwehlangano ye-ANC.

Nanyana umzabalazo wekululeko waphela kodwa uphethe ubujalo benarha begodu uyaraga ukubumba inarha ngokuzama ukuthi kungasabi nokubandlululana kwakade begodu kwakhiwe inarha eyamukela woke umuntu ngendlela angayo ngokombala, ukukhuluma nokhunye.</text>
      <sha1>ebpg5qh9v1gt25fgfwjucjnisk6acv6</sha1>
    </revision>
    <revision>
      <id>3266</id>
      <parentid>3223</parentid>
      <timestamp>2025-06-30T09:21:29Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <comment>Added few words</comment>
      <origin>3266</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3312" sha1="oe7nmlan62wzx8c9gmrmclskguzw7bk" xml:space="preserve">'''Umzabalazo wekululeko''' ngilokha abantu bavusa ipi nofana baba nenturhu ukulwisana nombuso webandlululo.&lt;ref&gt;Houston, G.F., 2019. ''The National Liberation Struggle in South Africa: A Case Study of the United Democratic Front, 1983-87''. Routledge.&lt;/ref&gt; Umzabalazo wekululeko bewudoswa phambili ziinqhema ezinengi zabantu ekungaba misikinyeko nofana iinhlangano ezabe zenziwe ngaleso sikhathi. Iinqhema lezi zabe zihlose ukuthola ikululeko, ukulingana Kanye nombuso wentando yenengi ebantwini boke abahlala eSewula Afrika. Ilutjha ebelodosa phambili umzabalazo wekululeko labe linekghuphelo lokwakha inarha encono kunaleyo ebeba phila kiyo, labe lifuna ukuletha amatjhuguluko emphakathini wabo nanyana lokho kwabe kubeka amaphilo wabo engozini.

=== Indima eyadlwa yilutjha ekuletheni ekuletheni ikululeko ===
Ukuhlela ukubhenyoga

Lokha abantu abatjha bekuba ngiba ngobo abadosa phambili ukubhenyoga kwesitjhaba bebasebenzisa iindlela ezithileko ukulwisana nabaphathi nofana abadosi phambili bombuso loyo. Isibonelo sokubhenyoga ngelesi sokuphakama kweSoweto ngonyaka we-1976 lapho ilutjha khabe lilwisana khona nokufundiswa khona kwelimi lesibhuru ngekatelelo eenkolweni.&lt;ref&gt;Ndlovu, S., 2017. ''The Soweto Uprisings: Counter Memories of June 1976''. Pan Macmillan South africa.&lt;/ref&gt; Omunye welutjha elabe lidosa phambili ukubhenyoga lokhu kwabe kungu Tsietsi Mashinini. Abanye abafundi bahlongakala lokha nakubhenyogwako ngombana badutjulwa. UHector peterson owabe eneminyaka eli-12, no Hastings Ndlovu owabe eneminyaka eli-15.&lt;ref&gt;Krog, A., 2022. Some new perspectives on the Soweto uprising: HML Lentsoane’s poem “Black Wednesday”(“Laboraro le lesoleso”). ''Tydskrif vir letterkunde'', ''59''(3), pp.113-130.&lt;/ref&gt;

Ukutjhukumisa imiphakathi        

Ilutjha ladlala indima yokuthi litjhukumise imiphakathi begodu liwazise ngokuthi liphala lapho bangatholi khona ubulungiswa begodu sikhombise umphakathi ukuthi sitlhoga umbuso wentando yenengi khona woke umuntu azokutjhaphuluka. Okhunye kukuthi ihlagano ye-ANC yathoma yenza amaphetjhana atlolwe ukuthi “tjhaphululani uMandela bese nilengise u Vorster” lokhu kwenziwa kokuthi nilutjha lisuse inturhu eSoweto. Abasebenzi abanzima nabo bagcina babanga imguruguru ngombana basikinywa yinto eyenziwa mbuso, ukuthi babulale abafundi.

Ukwakha ubudlelwano benhlangano, nemisikinyeko

Ilutjha lasiza ukwakha ukuhlangana nofana ukwenza ukuthi kube khona ubudlelwana phakathi kwenhlangano, imisikinyeko nekukhuliseni imiphakhathi iqinise ukubumbana kwabantu. Imisikinyeko yelutjha efana neCOSAS ejamele ukuthi ''congress of south african students, ne-''SASCO ejamele ukuthi ''South African student congress'' zasungulwa ukuthi zikhone ukuthi zilwisane ukuthi zikghone ukulwisana nebandlululo elabe likhona ngaleso skhathi.&lt;ref&gt;Ngwane, T., 2017. Learning in struggle: an activist’s view of the transition from apartheid to democracy in South Africa. In ''Reflections on Knowledge, Learning and Social Movements'' (pp. 168-185). Routledge.&lt;/ref&gt; iSASCO yoona yavela ngaphasi kwehlangano ye-ANC.

Nanyana umzabalazo wekululeko waphela kodwa uphethe ubujalo benarha begodu uyaraga ukubumba inarha ngokuzama ukuthi kungasabi nokubandlululana kwakade begodu kwakhiwe inarha eyamukela woke umuntu ngendlela angayo ngokombala, ukukhuluma nokhunye.</text>
      <sha1>oe7nmlan62wzx8c9gmrmclskguzw7bk</sha1>
    </revision>
    <revision>
      <id>3314</id>
      <parentid>3266</parentid>
      <timestamp>2025-07-04T16:53:02Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3314</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3479" sha1="3dglopyv3xo3v3baaxmc8pakivkqefo" xml:space="preserve">[[Isimumathi:Hector pieterson.jpg|thumb|Ngelanga lokuphakama kweSoweto, uMbuyisa Makhubo athwele u-Hector Peterson]]
'''Umzabalazo wekululeko''' ngilokha abantu bavusa ipi nofana baba nenturhu ukulwisana nombuso webandlululo.&lt;ref&gt;Houston, G.F., 2019. ''The National Liberation Struggle in South Africa: A Case Study of the United Democratic Front, 1983-87''. Routledge.&lt;/ref&gt; Umzabalazo wekululeko bewudoswa phambili ziinqhema ezinengi zabantu ekungaba misikinyeko nofana iinhlangano ezabe zenziwe ngaleso sikhathi. Iinqhema lezi zabe zihlose ukuthola ikululeko, ukulingana Kanye nombuso wentando yenengi ebantwini boke abahlala eSewula Afrika. Ilutjha ebelodosa phambili umzabalazo wekululeko labe linekghuphelo lokwakha inarha encono kunaleyo ebeba phila kiyo, labe lifuna ukuletha amatjhuguluko emphakathini wabo nanyana lokho kwabe kubeka amaphilo wabo engozini.

=== Indima eyadlwa yilutjha ekuletheni ekuletheni ikululeko ===

==== Ukuhlela ukubhenyoga ====
Lokha abantu abatjha bekuba ngiba ngobo abadosa phambili ukubhenyoga kwesitjhaba bebasebenzisa iindlela ezithileko ukulwisana nabaphathi nofana abadosi phambili bombuso loyo. Isibonelo sokubhenyoga ngelesi sokuphakama kweSoweto ngonyaka we-1976 lapho ilutjha khabe lilwisana khona nokufundiswa khona kwelimi lesibhuru ngekatelelo eenkolweni.&lt;ref&gt;Ndlovu, S., 2017. ''The Soweto Uprisings: Counter Memories of June 1976''. Pan Macmillan South africa.&lt;/ref&gt; Omunye welutjha elabe lidosa phambili ukubhenyoga lokhu kwabe kungu Tsietsi Mashinini. Abanye abafundi bahlongakala lokha nakubhenyogwako ngombana badutjulwa. UHector peterson owabe eneminyaka eli-12, no Hastings Ndlovu owabe eneminyaka eli-15.&lt;ref&gt;Krog, A., 2022. Some new perspectives on the Soweto uprising: HML Lentsoane’s poem “Black Wednesday”(“Laboraro le lesoleso”). ''Tydskrif vir letterkunde'', ''59''(3), pp.113-130.&lt;/ref&gt;

==== Ukutjhukumisa imiphakathi         ====
Ilutjha ladlala indima yokuthi litjhukumise imiphakathi begodu liwazise ngokuthi liphala lapho bangatholi khona ubulungiswa begodu sikhombise umphakathi ukuthi sitlhoga umbuso wentando yenengi khona woke umuntu azokutjhaphuluka. Okhunye kukuthi ihlagano ye-ANC yathoma yenza amaphetjhana atlolwe ukuthi “tjhaphululani uMandela bese nilengise u Vorster” lokhu kwenziwa kokuthi nelutjha lisuse inturhu eSoweto. Abasebenzi abanzima nabo bagcina babanga imguruguru ngombana basikinywa yinto eyenziwa mbuso, ukuthi babulale abafundi.

==== Ukwakha ubudlelwano benhlangano, nemisikinyeko ====
Ilutjha lasiza ukwakha ukuhlangana nofana ukwenza ukuthi kube khona ubudlelwana phakathi kwenhlangano, imisikinyeko nekukhuliseni imiphakhathi iqinise ukubumbana kwabantu. Imisikinyeko yelutjha efana neCOSAS ejamele ukuthi ''congress of south african students, ne-''SASCO ejamele ukuthi ''South African student congress'' zasungulwa ukuthi zikhone ukuthi zilwisane ukuthi zikghone ukulwisana nebandlululo elabe likhona ngaleso skhathi.&lt;ref&gt;Ngwane, T., 2017. Learning in struggle: an activist’s view of the transition from apartheid to democracy in South Africa. In ''Reflections on Knowledge, Learning and Social Movements'' (pp. 168-185). Routledge.&lt;/ref&gt; iSASCO yoona yavela ngaphasi kwehlangano ye-ANC.

Nanyana umzabalazo wekululeko waphela kodwa uphethe ubujalo benarha begodu uyaraga ukubumba inarha ngokuzama ukuthi kungasabi nokubandlululana kwakade begodu kwakhiwe inarha eyamukela woke umuntu ngendlela angayo ngokombala, ukukhuluma nokhunye.

== '''Iikhomba''' ==</text>
      <sha1>3dglopyv3xo3v3baaxmc8pakivkqefo</sha1>
    </revision>
    <revision>
      <id>3315</id>
      <parentid>3314</parentid>
      <timestamp>2025-07-04T16:57:25Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3315</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3516" sha1="f5tl3ye9abbkg7xo9vzr7xhr95umy8s" xml:space="preserve">[[Isimumathi:Hector pieterson.jpg|thumb|Ngelanga lokuphakama kweSoweto, uMbuyisa Makhubo athwele u-Hector Peterson]]
'''Umzabalazo wekululeko''' ngilokha abantu bavusa ipi nofana baba nenturhu ukulwisana nombuso webandlululo.&lt;ref&gt;Houston, G.F., 2019. ''The National Liberation Struggle in South Africa: A Case Study of the United Democratic Front, 1983-87''. Routledge.&lt;/ref&gt; Umzabalazo wekululeko bewudoswa phambili ziinqhema ezinengi zabantu ekungaba misikinyeko nofana iinhlangano ezabe zenziwe ngaleso sikhathi. Iinqhema lezi zabe zihlose ukuthola ikululeko, ukulingana Kanye nombuso wentando yenengi ebantwini boke abahlala eSewula Afrika. Ilutjha ebelodosa phambili umzabalazo wekululeko labe linekghuphelo lokwakha inarha encono kunaleyo ebeba phila kiyo, labe lifuna ukuletha amatjhuguluko emphakathini wabo nanyana lokho kwabe kubeka amaphilo wabo engozini.

=== Indima eyadlwa yilutjha ekuletheni ekuletheni ikululeko ===

==== Ukuhlela ukubhenyoga ====
Lokha abantu abatjha bekuba ngiba ngobo abadosa phambili ukubhenyoga kwesitjhaba bebasebenzisa iindlela ezithileko ukulwisana nabaphathi nofana abadosi phambili bombuso loyo. Isibonelo sokubhenyoga ngelesi sokuphakama kweSoweto ngonyaka we-1976 lapho ilutjha khabe lilwisana khona nokufundiswa khona kwelimi lesibhuru ngekatelelo eenkolweni.&lt;ref&gt;Ndlovu, S., 2017. ''The Soweto Uprisings: Counter Memories of June 1976''. Pan Macmillan South africa.&lt;/ref&gt; Omunye welutjha elabe lidosa phambili ukubhenyoga lokhu kwabe kungu Tsietsi Mashinini. Abanye abafundi bahlongakala lokha nakubhenyogwako ngombana badutjulwa. UHector peterson owabe eneminyaka eli-12, no Hastings Ndlovu owabe eneminyaka eli-15.&lt;ref&gt;Krog, A., 2022. Some new perspectives on the Soweto uprising: HML Lentsoane’s poem “Black Wednesday”(“Laboraro le lesoleso”). ''Tydskrif vir letterkunde'', ''59''(3), pp.113-130.&lt;/ref&gt;

==== Ukutjhukumisa imiphakathi         ====
Ilutjha ladlala indima yokuthi litjhukumise imiphakathi begodu liwazise ngokuthi liphala lapho bangatholi khona ubulungiswa begodu sikhombise umphakathi ukuthi sitlhoga umbuso wentando yenengi khona woke umuntu azokutjhaphuluka. Okhunye kukuthi ihlagano ye-ANC yathoma yenza amaphetjhana atlolwe ukuthi “tjhaphululani uMandela bese nilengise u Vorster” lokhu kwenziwa kokuthi nelutjha lisuse inturhu eSoweto. Abasebenzi abanzima nabo bagcina babanga imguruguru ngombana basikinywa yinto eyenziwa mbuso, ukuthi babulale abafundi.

==== Ukwakha ubudlelwano benhlangano, nemisikinyeko ====
Ilutjha lasiza ukwakha ukuhlangana nofana ukwenza ukuthi kube khona ubudlelwana phakathi kwenhlangano, imisikinyeko nekukhuliseni imiphakhathi iqinise ukubumbana kwabantu. Imisikinyeko yelutjha efana neCOSAS ejamele ukuthi ''congress of south african students, ne-''SASCO ejamele ukuthi ''South African student congress'' zasungulwa ukuthi zikhone ukuthi zilwisane ukuthi zikghone ukulwisana nebandlululo elabe likhona ngaleso skhathi.&lt;ref&gt;Ngwane, T., 2017. Learning in struggle: an activist’s view of the transition from apartheid to democracy in South Africa. In ''Reflections on Knowledge, Learning and Social Movements'' (pp. 168-185). Routledge.&lt;/ref&gt; iSASCO yona yavela ngaphasi kwehlangano ye-ANC.

Nanyana umzabalazo wekululeko waphela kwangena [[umbuso wentando yenengi]] kodwa uphethe ubunjalo benarha begodu uyaraga ukubumba inarha ngokuzama ukuthi kungasabi nokubandlululana kwakade begodu kwakhiwe inarha eyamukela woke umuntu ngendlela angayo ngokombala, ukukhuluma nokhunye.

== '''Iikhomba''' ==</text>
      <sha1>f5tl3ye9abbkg7xo9vzr7xhr95umy8s</sha1>
    </revision>
  </page>
  <page>
    <title>U-Teboho MacDonald Mashinini (Tsietsi)</title>
    <ns>0</ns>
    <id>653</id>
    <revision>
      <id>3225</id>
      <timestamp>2025-06-25T12:44:28Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1295924403|Teboho MacDonald Mashinini]]&quot;</comment>
      <origin>3225</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3511" sha1="6mbj4lqk9mbq5hut2zaaov9xj3fgeeh" xml:space="preserve">
{{Infobox person|name=Teboho MacDonald Mashinini|image=|caption=|birth_name=|birth_date=27 January 1957|birth_place=[[Soweto]] Jabavu|death_date=1990|death_place=[[Guinea]]|other_names=Tsietsi|known_for=1976 Student Uprising|education=[[Morris Isaacson High School]]|employer=|occupation=[[Political Activist]]|title=|height=|term=|predecessor=|successor=[[Khotso Seatlholo]]|party=|boards=|spouse=[[Welma Albertine Wani Campbell]]|partner=|children=2|parents=[[Nomkhitha Virginia Mashinini]], [[Ramothibi Mashinini]]|relatives=[[Mpho Vincent Mashinini]]|signature=|website=|footnotes=}}

'''U-Teboho &quot;Tsietsi&quot; MacDonald Mashinini''' (wabelethwa ngomhlaka-27 kuTjhirhweni 1957 wahlongakala ngo-1990) bekangumlweli wetjhaphuluko emBusweni weBandlululo weSewula Afrika nomdosiphambili wabafundi odumileko ngesikhathi se-[[:en:Soweto_Uprising|''Soweto Uprising'']].

== Umlando Wakhe ==
U-Teboho Tsietsi Mashinini owaziwa ngebizo lakhe elithi &quot;Mcdonald&quot; wabelethwa ngo-1957, ngomhlaka-27 kuTjhirhweni. Bekangowesibili ebantwaneni abali-13 baka-Ramothibe (ubaba) no-Nomkhitha Virginia (umma) bakwaMashinini. Bekamfundi okhaliphileko, odumileko nophumeleleko e-&lt;nowiki&gt;&lt;i&gt;Morris Isaacson High School&lt;/i&gt;&lt;/nowiki&gt;  e-Soweto, lapho bekamdosiphambili wesiqhema sekulumo pikiswano begodu angumongameli we-''Methodist Wesley Guild''.

Igadango lombuso webandlululo weSewula Afrika lokwenza ilimi lesiBhuru libe lilimi okufundiswa ngalo eenkolweni zoke zeSewula Afrika ngokuhlanganyela nesiNgisi belingathandwa khulu bafundi beSewula Afrika abanzima [[Ilimi lesiNgisi|nabakhuluma isiNgisi]].

Amfundi ngokwakhe, uMashinini nguye owahlela umtjhagalo omkhulu wabafundi ngomhlaka-16 kuMgwengweni 1976.  Umtjhagalo lo waziwa ngokuthi yi-[[16 JUNE 1976|Soweto Uprising]], okwathatha amalanga amathathu, lapho kwabulawa khona abantu abamakhulu ambalwa.{{Citation needed|date=September 2020}}&lt;sup class=&quot;noprint Inline-Template Template-Fact&quot; style=&quot;white-space:nowrap;&quot;&gt;&amp;#x5B; ''&lt;nowiki&gt;&lt;span title=&quot;This claim needs references to reliable sources. (September 2020)&quot;&gt;ukudzubhula kuyatlhogeka&lt;/span&gt;&lt;/nowiki&gt;'' &amp;#x5D;&lt;/sup&gt;

Njengombana avele njengomdosiphambili wokuvukela umbuso weSewula Afrika, uMashinini wabaleka eSewula Afrika waya ngaphetjheya, kokuthoma waya e-London bese waya kezinye iinarha ze-Afrika, okufaka hlangana i-Liberia, lapho atjhade khona no-''Miss Liberia 1977'', [[Welma Campbell|u-Welma Campbell]].

UMashinini wahlongakala ngaphasi kobujamo obungazwisisekiko, mhlamunye ngokubulawa, ngehlobo laka-1990 ngesikhathi asendaweni yokubalekela e-Guinea. Ngomhlaka-4 kuRhoboyi 1990, isidumbu sakhe sabuyiselwa eSewula Afrika, lapho angcwatjwa khona emaThuneni we-Avalon. Ithuna lakhe linesihloko esithi ''&quot;Black Power&quot;''.

== Ilitje Lesikhumbuzo ==
Kunelitje lesikhumbuzo saka-Teboho Mashinini esenziwe ngu-Johannes Phokela emasangweni wesikolo ebekangena kiso kade  esavulwa mhlazi-1 kuMrhayili 2010 ngu-Amos Masondo, iMeya ye-Goli.

== Qala godu ==

* U-[[Khotso Seatlholo]]
* U-Hastings Ndlovu
* U-Hector Pieterson
* U-Murphy Morobe
* U-Seth Mazibuko

== Iinkomba ==
{{Reflist}}

== Amalinki wangaphandle ==

* Iwebhusayithi ye-African Activist Archive Project ifaka hlangana isitatimende seendaba [http://africanactivist.msu.edu/document_metadata.php?objectid=32-130-C2F i-Lider of Soweto (South Africa) Uprising to Speak] (New York: American Committee on Africa, December 1976).
* Iphrofayili ye-Teboho &quot;Tsietsi&quot; Mashinini ku-SA History Online https://www.sahistory.org.za/people/teboho-tsietsi-mashinini</text>
      <sha1>6mbj4lqk9mbq5hut2zaaov9xj3fgeeh</sha1>
    </revision>
    <revision>
      <id>3226</id>
      <parentid>3225</parentid>
      <timestamp>2025-06-25T18:26:50Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>3226</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3832" sha1="9g8zhjfluhe652wnqm2owxql3kkz543" xml:space="preserve">'''U-Teboho &quot;Tsietsi&quot; MacDonald Mashinini''' (wabelethwa ngomhlaka-27 kuTjhirhweni 1957 wahlongakala ngo-1990) bekangumlweli wetjhaphuluko emBusweni weBandlululo weSewula Afrika nomdosiphambili wabafundi odumileko ngesikhathi se-[[:en:Soweto_Uprising|''Soweto Uprising'']].&lt;ref name=&quot;:0&quot;&gt;South African History Online (2022), ''Teboho “Tsietsi” Mashinini'' (Published February 17, 2011). Retrieved from: https://sahistory.org.za/people/teboho-tsietsi-mashinini Retrieved on 25-06-2025.&lt;/ref&gt;

== Umlando Wakhe ==
U-Teboho Tsietsi Mashinini owaziwa ngebizo lakhe elithi &quot;Mcdonald&quot; wabelethwa ngo-1957, ngomhlaka-27 kuTjhirhweni. Bekangowesibili ebantwaneni abali-13 baka-Ramothibe (ubaba) no-Nomkhitha Virginia (umma) bakwaMashinini. Bekamfundi okhaliphileko, odumileko nophumeleleko e-''Morris Isaacson High School'' &lt;ref name=&quot;:1&quot;&gt;Mecoamere, Victor (27 May 2013). &quot;Naledi High turns 50&quot;. S''owetan Live''. Retrieved from: https://www.sowetanlive.co.za/news/2013-05-27-naledi-high-turns-50/ 23 July 2013.&lt;/ref&gt; e-Soweto, lapho bekamdosiphambili wesiqhema sekulumo pikiswano begodu angumongameli we-''Methodist Wesley Guild''.

Igadango lombuso webandlululo weSewula Afrika lokwenza ilimi lesiBhuru libe lilimi okufundiswa ngalo eenkolweni zoke zeSewula Afrika ngokuhlanganyela nesiNgisi belingathandwa khulu bafundi beSewula Afrika abanzima [[Ilimi lesiNgisi|nabakhuluma isiNgisi]].&lt;ref name=&quot;:0&quot; /&gt;

Amfundi ngokwakhe, uMashinini nguye owahlela umtjhagalo omkhulu wabafundi ngomhlaka-16 kuMgwengweni 1976.&lt;ref name=&quot;:1&quot; /&gt;  Umtjhagalo lo waziwa ngokuthi yi-[[16 JUNE 1976|Soweto Uprising]], okwathatha amalanga amathathu, lapho kwabulawa khona abantu abamakhulu ambalwa.

Njengombana avele njengomdosiphambili wokuvukela umbuso weSewula Afrika, uMashinini wabaleka eSewula Afrika waya ngaphetjheya, kokuthoma waya e-London bese waya kezinye iinarha ze-Afrika, okufaka hlangana i-Liberia, lapho atjhade khona no-''Miss Liberia 1977'', [[Welma Campbell|u-Welma Campbell]].&lt;ref name=&quot;:0&quot; /&gt;

UMashinini wahlongakala ngaphasi kobujamo obungazwisisekiko, mhlamunye ngokubulawa, ngehlobo laka-1990 ngesikhathi asendaweni yokubalekela e-Guinea.&lt;ref&gt;Ali Mphaki (11/07/2004), ''&lt;nowiki/&gt;'Tsietsi died of Aids' ,'' Wayback Machine internet archive. Retrieved from: https://web.archive.org/web/20070930211226/http://www.news24.com/News24/South_Africa/News/0,,2-7-1442_1555941,00.html Retreived on the 30th September 2007.&lt;/ref&gt; Ngomhlaka-4 kuRhoboyi 1990, isidumbu sakhe sabuyiselwa eSewula Afrika, lapho angcwatjwa khona emaThuneni we-Avalon. Ithuna lakhe linesihloko esithi ''&quot;Black Power&quot;''.&lt;ref&gt;Joburg website (2018) ''The homecoming that wasn't.'' Retrieved from: https://joburg.org.za/play_/Pages/Play%20in%20Joburg/Culture%20and%20Heritage/Links/The-homecoming-that-wasn't.aspx Retrieved on 25-06-2025.&lt;/ref&gt;

== Ilitje Lesikhumbuzo ==
Kunelitje lesikhumbuzo saka-Teboho Mashinini esenziwe ngu-Johannes Phokela emasangweni wesikolo ebekangena kiso kade  esavulwa mhlazi-1 kuMrhayili 2010 ngu-Amos Masondo, iMeyara ye-Johannesburg.&lt;ref&gt;Arts, Culture &amp; Heritage website (November 6, 2023), ''Tsietsi Mashinini.'' Retrieved from: https://arts-culture-heritage.joburg/public-art-inventory/tsietsi-mashinini/ Retrieved on 25-06-2025.

&lt;/ref&gt;

== Qala godu ==

* U-[[Khotso Seatlholo]]
* U-Hastings Ndlovu
* [[U-Hector Pieterson]]
* U-Murphy Morobe
* U-Seth Mazibuko

== Iinkomba ==
{{Reflist}}

== Amalinki wangaphandle ==

* Iwebhusayithi ye-''African Activist Archive Project'' ifaka hlangana isitatimende seendaba [http://africanactivist.msu.edu/document_metadata.php?objectid=32-130-C2F i-''Lider of Soweto (South Africa) Uprising to Speak''] (''New York: American Committee on Africa, December 1976'').
* Iphrofayili ka-Teboho &quot;Tsietsi&quot; Mashinini ku-''SA History Online'' https://www.sahistory.org.za/people/teboho-tsietsi-mashinini</text>
      <sha1>9g8zhjfluhe652wnqm2owxql3kkz543</sha1>
    </revision>
    <revision>
      <id>3239</id>
      <parentid>3226</parentid>
      <timestamp>2025-06-26T14:21:38Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>3239</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3872" sha1="1yx4xirdbg67jbbdzbvjupm20rdqglp" xml:space="preserve">'''U-Teboho &quot;Tsietsi&quot; MacDonald Mashinini''' (wabelethwa ngomhlaka-27 kuTjhirhweni 1957 wahlongakala ngo-1990) bekamlweli wetjhaphuluko emBusweni weBandlululo weSewula Afrika nomdosiphambili wabafundi odumileko ngesikhathi se-[[:en:Soweto_Uprising|''Soweto Uprising'']].&lt;ref name=&quot;:0&quot;&gt;South African History Online (2022), ''Teboho “Tsietsi” Mashinini'' (Published February 17, 2011). Retrieved from: https://sahistory.org.za/people/teboho-tsietsi-mashinini Retrieved on 25-06-2025.&lt;/ref&gt;

== Umlando Wakhe ==
U-Teboho Tsietsi Mashinini owaziwa ngebizo lakhe elithi &quot;Mcdonald&quot; wabelethwa ngo-1957, ngomhlaka-27 kuTjhirhweni. Bekangowesibili ebantwaneni abali-13 baka-Ramothibe (ubaba) no-Nomkhitha Virginia (umma) bakwaMashinini. Bekamfundi okhaliphileko, odumileko nophumelelako e-''Morris Isaacson High School'' &lt;ref name=&quot;:1&quot;&gt;Mecoamere, Victor (27 May 2013). &quot;Naledi High turns 50&quot;. S''owetan Live''. Retrieved from: https://www.sowetanlive.co.za/news/2013-05-27-naledi-high-turns-50/ 23 July 2013.&lt;/ref&gt; e-Soweto, lapho bekamdosiphambili wesiqhema sekulumo pikiswano begodu angumongameli we-''Methodist Wesley Guild''.

Igadango lombuso webandlululo weSewula Afrika lokwenza ilimi lesiBhuru libe lilimi okufundiswa ngalo eenkolweni zoke zeSewula Afrika ngokuhlanganyela nesiNgisi belingathandwa bafundi beSewula Afrika abanzima [[Ilimi lesiNgisi|nabakhuluma isiNgisi]].&lt;ref name=&quot;:0&quot; /&gt;

Amfundi ngokwakhe, uMashinini nguye owahlela umtjhagalo omkhulu wabafundi ngomhlaka-16 kuMgwengweni 1976.&lt;ref name=&quot;:1&quot; /&gt;  Umtjhagalo lo waziwa ngokuthi yi-[[16 JUNE 1976|''Soweto Uprising'']], okwathatha amalanga amathathu, lapho kwabulawa khona abantwana abamakhulu ambalwa.&lt;ref name=&quot;:1&quot; /&gt;

Njengombana avele njengomdosiphambili wokuvukela umbuso weSewula Afrika, uMashinini wabaleka eSewula Afrika waya ngaphetjheya, kokuthoma waya e-London bese waya kezinye iinarha ze-Afrika, okufaka hlangana i-Liberia, lapho atjhade khona no-''Miss Liberia 1977'', [[Welma Campbell|u-Welma Campbell]].&lt;ref name=&quot;:0&quot; /&gt;

UMashinini wahlongakala ngaphasi kobujamo obungazwisisekiko, mhlamunye ngokubulawa namkha ngobulwele, ngehlobo laka-1990 ngesikhathi asendaweni yokubalekela e-Guinea.&lt;ref&gt;Ali Mphaki (11/07/2004), ''&lt;nowiki/&gt;'Tsietsi died of Aids' ,'' Wayback Machine internet archive. Retrieved from: https://web.archive.org/web/20070930211226/http://www.news24.com/News24/South_Africa/News/0,,2-7-1442_1555941,00.html Retreived on the 30th September 2007.&lt;/ref&gt; Ngomhlaka-4 kuRhoboyi 1990, isidumbu sakhe sabuyiselwa eSewula Afrika, lapho angcwatjwa khona emaThuneni we-Avalon. Ithuna lakhe linesihloko esithi ''&quot;Black Power&quot;''.&lt;ref&gt;Joburg website (2018) ''The homecoming that wasn't.'' Retrieved from: https://joburg.org.za/play_/Pages/Play%20in%20Joburg/Culture%20and%20Heritage/Links/The-homecoming-that-wasn't.aspx Retrieved on 25-06-2025.&lt;/ref&gt;

== Ilitje Lesikhumbuzo ==
Kunelitje lesikhumbuzo saka-Teboho Mashinini esenziwe ngu-Johannes Phokela emasangweni wesikolo ebekangena kiso kade  esavulwa ngomhlaka-1 kuMrhayili 2010 ngu-Amos Masondo, iMeyara ye-Johannesburg.&lt;ref&gt;Arts, Culture &amp; Heritage website (November 6, 2023), ''Tsietsi Mashinini.'' Retrieved from: https://arts-culture-heritage.joburg/public-art-inventory/tsietsi-mashinini/ Retrieved on 25-06-2025.

&lt;/ref&gt;

== Qala godu ==

* U-[[Khotso Seatlholo]]
* [[U-Hastings Ndlovu]]
* [[U-Hector Pieterson]]
* U-Murphy Morobe
* U-Seth Mazibuko

== Iinkomba ==
{{Reflist}}

== Amalinki wangaphandle ==

* Iwebhusayithi ye-''African Activist Archive Project'' ifaka hlangana isitatimende seendaba [http://africanactivist.msu.edu/document_metadata.php?objectid=32-130-C2F i-''Lider of Soweto (South Africa) Uprising to Speak''] (''New York: American Committee on Africa, December 1976'').
* Iphrofayili ka-Teboho &quot;Tsietsi&quot; Mashinini ku-''SA History Online'' https://www.sahistory.org.za/people/teboho-tsietsi-mashinini</text>
      <sha1>1yx4xirdbg67jbbdzbvjupm20rdqglp</sha1>
    </revision>
    <revision>
      <id>3251</id>
      <parentid>3239</parentid>
      <timestamp>2025-06-28T18:20:16Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>/* Ilitje Lesikhumbuzo */ spelling fix</comment>
      <origin>3251</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3872" sha1="ttioaot8k67bpf0lezc4ffmox51h31j" xml:space="preserve">'''U-Teboho &quot;Tsietsi&quot; MacDonald Mashinini''' (wabelethwa ngomhlaka-27 kuTjhirhweni 1957 wahlongakala ngo-1990) bekamlweli wetjhaphuluko emBusweni weBandlululo weSewula Afrika nomdosiphambili wabafundi odumileko ngesikhathi se-[[:en:Soweto_Uprising|''Soweto Uprising'']].&lt;ref name=&quot;:0&quot;&gt;South African History Online (2022), ''Teboho “Tsietsi” Mashinini'' (Published February 17, 2011). Retrieved from: https://sahistory.org.za/people/teboho-tsietsi-mashinini Retrieved on 25-06-2025.&lt;/ref&gt;

== Umlando Wakhe ==
U-Teboho Tsietsi Mashinini owaziwa ngebizo lakhe elithi &quot;Mcdonald&quot; wabelethwa ngo-1957, ngomhlaka-27 kuTjhirhweni. Bekangowesibili ebantwaneni abali-13 baka-Ramothibe (ubaba) no-Nomkhitha Virginia (umma) bakwaMashinini. Bekamfundi okhaliphileko, odumileko nophumelelako e-''Morris Isaacson High School'' &lt;ref name=&quot;:1&quot;&gt;Mecoamere, Victor (27 May 2013). &quot;Naledi High turns 50&quot;. S''owetan Live''. Retrieved from: https://www.sowetanlive.co.za/news/2013-05-27-naledi-high-turns-50/ 23 July 2013.&lt;/ref&gt; e-Soweto, lapho bekamdosiphambili wesiqhema sekulumo pikiswano begodu angumongameli we-''Methodist Wesley Guild''.

Igadango lombuso webandlululo weSewula Afrika lokwenza ilimi lesiBhuru libe lilimi okufundiswa ngalo eenkolweni zoke zeSewula Afrika ngokuhlanganyela nesiNgisi belingathandwa bafundi beSewula Afrika abanzima [[Ilimi lesiNgisi|nabakhuluma isiNgisi]].&lt;ref name=&quot;:0&quot; /&gt;

Amfundi ngokwakhe, uMashinini nguye owahlela umtjhagalo omkhulu wabafundi ngomhlaka-16 kuMgwengweni 1976.&lt;ref name=&quot;:1&quot; /&gt;  Umtjhagalo lo waziwa ngokuthi yi-[[16 JUNE 1976|''Soweto Uprising'']], okwathatha amalanga amathathu, lapho kwabulawa khona abantwana abamakhulu ambalwa.&lt;ref name=&quot;:1&quot; /&gt;

Njengombana avele njengomdosiphambili wokuvukela umbuso weSewula Afrika, uMashinini wabaleka eSewula Afrika waya ngaphetjheya, kokuthoma waya e-London bese waya kezinye iinarha ze-Afrika, okufaka hlangana i-Liberia, lapho atjhade khona no-''Miss Liberia 1977'', [[Welma Campbell|u-Welma Campbell]].&lt;ref name=&quot;:0&quot; /&gt;

UMashinini wahlongakala ngaphasi kobujamo obungazwisisekiko, mhlamunye ngokubulawa namkha ngobulwele, ngehlobo laka-1990 ngesikhathi asendaweni yokubalekela e-Guinea.&lt;ref&gt;Ali Mphaki (11/07/2004), ''&lt;nowiki/&gt;'Tsietsi died of Aids' ,'' Wayback Machine internet archive. Retrieved from: https://web.archive.org/web/20070930211226/http://www.news24.com/News24/South_Africa/News/0,,2-7-1442_1555941,00.html Retreived on the 30th September 2007.&lt;/ref&gt; Ngomhlaka-4 kuRhoboyi 1990, isidumbu sakhe sabuyiselwa eSewula Afrika, lapho angcwatjwa khona emaThuneni we-Avalon. Ithuna lakhe linesihloko esithi ''&quot;Black Power&quot;''.&lt;ref&gt;Joburg website (2018) ''The homecoming that wasn't.'' Retrieved from: https://joburg.org.za/play_/Pages/Play%20in%20Joburg/Culture%20and%20Heritage/Links/The-homecoming-that-wasn't.aspx Retrieved on 25-06-2025.&lt;/ref&gt;

== Ilitje Lesikhumbuzo ==
Kunelitje lesikhumbuzo sika-Teboho Mashinini esenziwe ngu-Johannes Phokela emasangweni wesikolo ebekangena kiso kade  esavulwa ngomhlaka-1 kuMrhayili 2010 ngu-Amos Masondo, iMeyara ye-Johannesburg.&lt;ref&gt;Arts, Culture &amp; Heritage website (November 6, 2023), ''Tsietsi Mashinini.'' Retrieved from: https://arts-culture-heritage.joburg/public-art-inventory/tsietsi-mashinini/ Retrieved on 25-06-2025.

&lt;/ref&gt;

== Qala godu ==

* U-[[Khotso Seatlholo]]
* [[U-Hastings Ndlovu]]
* [[U-Hector Pieterson]]
* U-Murphy Morobe
* U-Seth Mazibuko

== Iinkomba ==
{{Reflist}}

== Amalinki wangaphandle ==

* Iwebhusayithi ye-''African Activist Archive Project'' ifaka hlangana isitatimende seendaba [http://africanactivist.msu.edu/document_metadata.php?objectid=32-130-C2F i-''Lider of Soweto (South Africa) Uprising to Speak''] (''New York: American Committee on Africa, December 1976'').
* Iphrofayili ka-Teboho &quot;Tsietsi&quot; Mashinini ku-''SA History Online'' https://www.sahistory.org.za/people/teboho-tsietsi-mashinini</text>
      <sha1>ttioaot8k67bpf0lezc4ffmox51h31j</sha1>
    </revision>
    <revision>
      <id>3252</id>
      <parentid>3251</parentid>
      <timestamp>2025-06-28T18:24:22Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>/* Umlando Wakhe */ spelling fix</comment>
      <origin>3252</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3880" sha1="sks9e6kyejtn8hjn8ywvd6oymexxcz9" xml:space="preserve">'''U-Teboho &quot;Tsietsi&quot; MacDonald Mashinini''' (wabelethwa ngomhlaka-27 kuTjhirhweni 1957 wahlongakala ngo-1990) bekamlweli wetjhaphuluko emBusweni weBandlululo weSewula Afrika nomdosiphambili wabafundi odumileko ngesikhathi se-[[:en:Soweto_Uprising|''Soweto Uprising'']].&lt;ref name=&quot;:0&quot;&gt;South African History Online (2022), ''Teboho “Tsietsi” Mashinini'' (Published February 17, 2011). Retrieved from: https://sahistory.org.za/people/teboho-tsietsi-mashinini Retrieved on 25-06-2025.&lt;/ref&gt;

== Umlando Wakhe ==
U-Teboho Tsietsi Mashinini owaziwa ngebizo lakhe elithi &quot;Mcdonald&quot; wabelethwa ngo-1957, ngomhlaka-27 kuTjhirhweni. Bekangowesibili ebantwaneni abali-13 baka-Ramothibe (ubaba) no-Nomkhitha Virginia (umma) bakwaMashinini. Bekamfundi okhaliphileko, odumileko nophumelelako e-''Morris Isaacson High School'' &lt;ref name=&quot;:1&quot;&gt;Mecoamere, Victor (27 May 2013). &quot;Naledi High turns 50&quot;. S''owetan Live''. Retrieved from: https://www.sowetanlive.co.za/news/2013-05-27-naledi-high-turns-50/ 23 July 2013.&lt;/ref&gt; e-Soweto, lapho bekamdosiphambili wesiqhema sekulumo pikiswano begodu angumongameli we-''Methodist Wesley Guild''.

Igadango lombuso webandlululo weSewula Afrika lokwenza ilimi lesiBhuru libe lilimi okufundiswa ngalo eenkolweni zoke zeSewula Afrika ngokuhlanganyela nesiNgisi belingathandwa bafundi beSewula Afrika abanzima [[Ilimi lesiNgisi|nabakhuluma isiNgisi]].&lt;ref name=&quot;:0&quot; /&gt;

Amfundi ngokwakhe, uMashinini nguye owahlela umtjhagalo omkhulu wabafundi ngomhlaka-16 kuMgwengweni 1976.&lt;ref name=&quot;:1&quot; /&gt;  Umtjhagalo lo waziwa ngokuthi yi-[[16 JUNE 1976|''Soweto Uprising'']], okwathatha amalanga amathathu, lapho kwabulawa khona abantwana abamakhulu ambalwa.&lt;ref name=&quot;:1&quot; /&gt;

Njengombana avele njengomdosiphambili wokuvukela umbuso weSewula Afrika, uMashinini wabaleka eSewula Afrika wabalekela ngaphetjheya, kokuthoma wabalekela e-London bese wabalekela nakezinye iinarha ze-Afrika, njenge-Liberia, lapho atjhade khona no-''Miss Liberia 1977'', [[Welma Campbell|u-Welma Campbell]].&lt;ref name=&quot;:0&quot; /&gt;

UMashinini wahlongakala ngaphasi kobujamo obungazwisisekiko, mhlamunye ngokubulawa namkha ngobulwele, ngehlobo lika-1990 ngesikhathi asendaweni yokubalekela e-Guinea.&lt;ref&gt;Ali Mphaki (11/07/2004), ''&lt;nowiki/&gt;'Tsietsi died of Aids' ,'' Wayback Machine internet archive. Retrieved from: https://web.archive.org/web/20070930211226/http://www.news24.com/News24/South_Africa/News/0,,2-7-1442_1555941,00.html Retreived on the 30th September 2007.&lt;/ref&gt; Ngomhlaka-4 kuRhoboyi 1990, isidumbu sakhe sabuyiselwa eSewula Afrika, lapho angcwatjwa khona emaThuneni we-Avalon. Ithuna lakhe linesihloko esithi ''&quot;Black Power&quot;''.&lt;ref&gt;Joburg website (2018) ''The homecoming that wasn't.'' Retrieved from: https://joburg.org.za/play_/Pages/Play%20in%20Joburg/Culture%20and%20Heritage/Links/The-homecoming-that-wasn't.aspx Retrieved on 25-06-2025.&lt;/ref&gt;

== Ilitje Lesikhumbuzo ==
Kunelitje lesikhumbuzo sika-Teboho Mashinini esenziwe ngu-Johannes Phokela emasangweni wesikolo ebekangena kiso kade  esavulwa ngomhlaka-1 kuMrhayili 2010 ngu-Amos Masondo, iMeyara ye-Johannesburg.&lt;ref&gt;Arts, Culture &amp; Heritage website (November 6, 2023), ''Tsietsi Mashinini.'' Retrieved from: https://arts-culture-heritage.joburg/public-art-inventory/tsietsi-mashinini/ Retrieved on 25-06-2025.

&lt;/ref&gt;

== Qala godu ==

* U-[[Khotso Seatlholo]]
* [[U-Hastings Ndlovu]]
* [[U-Hector Pieterson]]
* U-Murphy Morobe
* U-Seth Mazibuko

== Iinkomba ==
{{Reflist}}

== Amalinki wangaphandle ==

* Iwebhusayithi ye-''African Activist Archive Project'' ifaka hlangana isitatimende seendaba [http://africanactivist.msu.edu/document_metadata.php?objectid=32-130-C2F i-''Lider of Soweto (South Africa) Uprising to Speak''] (''New York: American Committee on Africa, December 1976'').
* Iphrofayili ka-Teboho &quot;Tsietsi&quot; Mashinini ku-''SA History Online'' https://www.sahistory.org.za/people/teboho-tsietsi-mashinini</text>
      <sha1>sks9e6kyejtn8hjn8ywvd6oymexxcz9</sha1>
    </revision>
  </page>
  <page>
    <title>Umthethomlingwa nomthetho.</title>
    <ns>0</ns>
    <id>655</id>
    <revision>
      <id>3232</id>
      <timestamp>2025-06-26T07:38:13Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <comment>Created page with &quot;== '''Umthethomlingwa nomthetho.''' ==  === '''1. Isingeniso''' === Umthethomlingwa nomthetho ngamanye wamathulusi nanyana [[Amakhotho wethu|iinsetjenziswa ezisiza khulu]] eemphakathini nenarheni mayelana nokwenza isiqiniseko bonyana kuba nokulawuleka. Ukungezelela, umthethomlingwa nomthetho magadango lawo enza isiqiniseko sokuthi abantu baphilisana kuhle begodu balandela ikambiso yomthetho. Nanyana kunjalo-ke, umthethomlingwa nomthetho kuzizinto ezimbili ezingafaniko. E...&quot;</comment>
      <origin>3232</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3661" sha1="tnzvp2zwgeu14v89kic10m6zeyyd7ov" xml:space="preserve">== '''Umthethomlingwa nomthetho.''' ==

=== '''1. Isingeniso''' ===
Umthethomlingwa nomthetho ngamanye wamathulusi nanyana [[Amakhotho wethu|iinsetjenziswa ezisiza khulu]] eemphakathini nenarheni mayelana nokwenza isiqiniseko bonyana kuba nokulawuleka. Ukungezelela, umthethomlingwa nomthetho magadango lawo enza isiqiniseko sokuthi abantu baphilisana kuhle begodu balandela ikambiso yomthetho. Nanyana kunjalo-ke, umthethomlingwa nomthetho kuzizinto ezimbili ezingafaniko. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyini umthethomlinga begodu kuyini umthetho.

=== '''2. Kuyini umthethomlingwa na?''' ===
Ngokuya kweSouth African National Legislation Service (iNetLaw) [2025]&lt;ref name=&quot;:0&quot;&gt;'''South African National Legislation Service (NetLaw).''' 2025. ''Navigating the Legislative Landscape''. SabinetSA: Pretoria&lt;/ref&gt; umthethomlingwa litlhatlha lomthetho lelo elisesigabeni sokuthi lithunyelwe eBandleni leNarha nomKhandlu weNarha owAngamele iimFunda ngaphasi kwePalamende yenarha. Itlhatlha leli lomthetho (umthethomlingwa) ukuze libe mthetho ngokusemthethweni kufanelwe liphasiswe yiPalamende yenarha ngemva kukuphasiswa iBandla leNarha nomKhandlu weNarha owAngamele iimFunda. Nanyana kunjalo, akutjho bonyana yoke imithethomlingwa etlanywako izokuphasiswa ePalamende yenarha, eminye yemithethomlingwa iyararhwa ([https://www.parliament.uk/about/how/publications/bills-acts/ Parliament of United Kingdom 2025]&lt;ref&gt;'''Parliament of United Kingdom'''. 2024. ''Bills vs Acts''.  Itholakala ku: &lt;nowiki&gt;https://www.parliament.uk/about/how/publications/bills-acts/&lt;/nowiki&gt;. Ifunyenwe [ngomhlaka 13 kuMgwengweni 2025].&lt;/ref&gt;). Ngalokho singatjho bona umthethomlingwa kulingelelo lomthetho lelo elilethwa ngaphambili kwePalamende yenarha ukuze liqalwe bonyana nalingaba mthetho lingasiza inarha ekuphemeleliseni iindingo zayo na.

=== '''3. Kuyini umthetho na?''' ===
PMG (2025)&lt;ref name=&quot;:1&quot;&gt;'''PMG.''' 2025. ''Legislative Process''. Itholakala ku: &lt;nowiki&gt;https://pmg.org.za/page/legislative-process&lt;/nowiki&gt;. Ifunyenwe [ngomhlaka 13 kuMgwengweni 2025].&lt;/ref&gt; ngokusekelwa yi[[:en:Bill_(law)|Wikipedia (2025)]]&lt;ref&gt;'''Wikipedia.''' 2025. ''Bill (law).'' Itholakala ku: &lt;nowiki&gt;https://en.wikipedia.org/wiki/Bill_(law)&lt;/nowiki&gt;. Ifunyenwe [ngomhlaka 13 kuMgwengweni 2025].&lt;/ref&gt; iveze bonyana umthetho kuziinkambiso lezo ezenzelwe ukulawula nokuphilisana kwabantu ngokulinganako. Ukungezelela, u[[Umthethosisekelo|mthetho]] yikambiso, umhlahlandlela nesisetjenziswa sangakomthetho esisetjeziselwa ukurarulula izipi zangaphandle nangaphakathi eemphakathini ukuze kube nokuthula nanyana nokukhalima isenzo esingakalungi (South African National Legislation Service 2025&lt;ref name=&quot;:0&quot; /&gt;). Umehluko hlangana komthethomlingwa nomthetho kukuthi umthethomlingwa usalingelelwa bonyana ungasebenza na, begodu usengakabi mthetho ongasetjenziswa ([https://pmg.org.za/page/legislative-process PMG 2025]&lt;ref name=&quot;:1&quot; /&gt;). Kodwana, umthetho kusisetjenziswa isisemthethweni leso esele sisetjenziswa ngokomthetho ukurarulula imiraro ephathelene nemiphakathi (South African National Legislation Service 2025&lt;ref name=&quot;:0&quot; /&gt;).

=== '''4. Isiphetho''' ===
Umthetholingwa nomthetho kuzizinto ezihlukileko begodu ezisetjenziswa ngendlela ehlukileko. Nanyana kunjalo, ziyingcenye eqakathekileko ekwenzeni isiqiniseko sokuthi inarha iyakhula mayelana nokurarulula imiraro kanye nokwenza isiqiniseko sokuthi abantu abagadangani iinzwani. Ukungezelela, kuqakathekile bonyana sizijayezwe ngelwazi elimayelana nomthethomlingwa nomthetho ukuze sikwazi ukuzibandakanya ekuthathweni kweenqunto eziqakatheileko lezo ezithintela iimpilo zethu.

'''Imithombolwazi'''
&lt;references /&gt;</text>
      <sha1>tnzvp2zwgeu14v89kic10m6zeyyd7ov</sha1>
    </revision>
    <revision>
      <id>3233</id>
      <parentid>3232</parentid>
      <timestamp>2025-06-26T07:43:08Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <origin>3233</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3819" sha1="1hmv85qhix1mszym1f669fp2r9fr8hh" xml:space="preserve">== '''Umthethomlingwa nomthetho.''' ==

=== '''1. Isingeniso''' ===
Umthethomlingwa nomthetho ngamanye wamathulusi nanyana [[Amakhotho wethu|iinsetjenziswa ezisiza khulu]] eemphakathini nenarheni mayelana nokwenza isiqiniseko bonyana kuba nokulawuleka. Ukungezelela, umthethomlingwa nomthetho magadango lawo enza isiqiniseko sokuthi abantu baphilisana kuhle begodu balandela ikambiso yomthetho. Nanyana kunjalo-ke, umthethomlingwa nomthetho kuzizinto ezimbili ezingafaniko. Eenhlokwaneni ezilandelako sizokutjheja bonyana kuyini umthethomlinga begodu kuyini umthetho.

=== '''2. Kuyini umthethomlingwa na?''' ===
[[Isimumathi:Umthethomlingwa.png|thumb|250x250px|Isikhangiso somthethomlingwa]]
Ngokuya kweSouth African National Legislation Service (iNetLaw) [2025]&lt;ref name=&quot;:0&quot;&gt;'''South African National Legislation Service (NetLaw).''' 2025. ''Navigating the Legislative Landscape''. SabinetSA: Pretoria&lt;/ref&gt; umthethomlingwa litlhatlha lomthetho lelo elisesigabeni sokuthi lithunyelwe eBandleni leNarha nomKhandlu weNarha owAngamele iimFunda ngaphasi kwePalamende yenarha. Itlhatlha leli lomthetho (umthethomlingwa) ukuze libe mthetho ngokusemthethweni kufanelwe liphasiswe yiPalamende yenarha ngemva kukuphasiswa iBandla leNarha nomKhandlu weNarha owAngamele iimFunda. Nanyana kunjalo, akutjho bonyana yoke imithethomlingwa etlanywako izokuphasiswa ePalamende yenarha, eminye yemithethomlingwa iyararhwa ([https://www.parliament.uk/about/how/publications/bills-acts/ Parliament of United Kingdom 2025]&lt;ref&gt;'''Parliament of United Kingdom'''. 2024. ''Bills vs Acts''.  Itholakala ku: &lt;nowiki&gt;https://www.parliament.uk/about/how/publications/bills-acts/&lt;/nowiki&gt;. Ifunyenwe [ngomhlaka 13 kuMgwengweni 2025].&lt;/ref&gt;). Ngalokho singatjho bona umthethomlingwa kulingelelo lomthetho lelo elilethwa ngaphambili kwePalamende yenarha ukuze liqalwe bonyana nalingaba mthetho lingasiza inarha ekuphemeleliseni iindingo zayo na.

=== '''3. Kuyini umthetho na?''' ===
[[Isimumathi:Umthetho.png|left|thumb|250x250px|Umthetho ngelimi lesiNdebele]]
PMG (2025)&lt;ref name=&quot;:1&quot;&gt;'''PMG.''' 2025. ''Legislative Process''. Itholakala ku: &lt;nowiki&gt;https://pmg.org.za/page/legislative-process&lt;/nowiki&gt;. Ifunyenwe [ngomhlaka 13 kuMgwengweni 2025].&lt;/ref&gt; ngokusekelwa yi[[:en:Bill_(law)|Wikipedia (2025)]]&lt;ref&gt;'''Wikipedia.''' 2025. ''Bill (law).'' Itholakala ku: &lt;nowiki&gt;https://en.wikipedia.org/wiki/Bill_(law)&lt;/nowiki&gt;. Ifunyenwe [ngomhlaka 13 kuMgwengweni 2025].&lt;/ref&gt; iveze bonyana umthetho kuziinkambiso lezo ezenzelwe ukulawula nokuphilisana kwabantu ngokulinganako. Ukungezelela, u[[Umthethosisekelo|mthetho]] yikambiso, umhlahlandlela nesisetjenziswa sangakomthetho esisetjeziselwa ukurarulula izipi zangaphandle nangaphakathi eemphakathini ukuze kube nokuthula nanyana nokukhalima isenzo esingakalungi (South African National Legislation Service 2025&lt;ref name=&quot;:0&quot; /&gt;). Umehluko hlangana komthethomlingwa nomthetho kukuthi umthethomlingwa usalingelelwa bonyana ungasebenza na, begodu usengakabi mthetho ongasetjenziswa ([https://pmg.org.za/page/legislative-process PMG 2025]&lt;ref name=&quot;:1&quot; /&gt;). Kodwana, umthetho kusisetjenziswa isisemthethweni leso esele sisetjenziswa ngokomthetho ukurarulula imiraro ephathelene nemiphakathi (South African National Legislation Service 2025&lt;ref name=&quot;:0&quot; /&gt;).

=== '''4. Isiphetho''' ===
Umthetholingwa nomthetho kuzizinto ezihlukileko begodu ezisetjenziswa ngendlela ehlukileko. Nanyana kunjalo, ziyingcenye eqakathekileko ekwenzeni isiqiniseko sokuthi inarha iyakhula mayelana nokurarulula imiraro kanye nokwenza isiqiniseko sokuthi abantu abagadangani iinzwani. Ukungezelela, kuqakathekile bonyana sizijayezwe ngelwazi elimayelana nomthethomlingwa nomthetho ukuze sikwazi ukuzibandakanya ekuthathweni kweenqunto eziqakatheileko lezo ezithintela iimpilo zethu.

'''Imithombolwazi'''
&lt;references /&gt;</text>
      <sha1>1hmv85qhix1mszym1f669fp2r9fr8hh</sha1>
    </revision>
  </page>
  <page>
    <title>U-Hastings Ndlovu</title>
    <ns>0</ns>
    <id>656</id>
    <revision>
      <id>3235</id>
      <timestamp>2025-06-26T13:15:07Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1295529047|Hastings Ndlovu]]&quot;</comment>
      <origin>3235</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1229" sha1="btpg4k3a5uleyyzu1r6i2qwnsh79x0z" xml:space="preserve">
'''U-Hastings Ndlovu''' (2 kuMhlolanja 1961 - 16 kuMgwengweni 1976) bekangumfundi wesikolo samabanga aphezulu weSewula Afrika owabulawa mapholisa emtjhagalweni [[16 JUNE 1976|we-Soweto Uprising]] ukujamelana nombuso webandlululo [[Isewula Afrika|eSewula Afrika]] .

== Ukuhlongakala Kwakhe ==
UNdlovu wabulawa ngomhlaka-16 kuMgwengweni 1976 ngesikhathi [[16 JUNE 1976|somtjhagalo we-Soweto nokubulawa kwabantu]] lokha amapholisa we-Orlando nakadumuza abafundi ebegade batjhagalela nokukatelelwa kokusetjenziswa kwesiBhuru eenkolweni sabo. Ukuhlongakala kwakhe akhenge kuvezwe khulu njengo-Hector Pieterson ngombana akunamuntu omthwebule isithombe. Umlawuli wamapholisa u-Colonel Kleingeld utlele i-&lt;nowiki&gt;&lt;i&gt;Cillié Commission&lt;/i&gt;&lt;/nowiki&gt; uthi u-Ndlovu nguye &quot;obekenza isiqubuthu sibhenyoge&quot;. 

UNdlovu bekanabodadewabo abathathu nomfowabo. Odadewabo batjhiya inarha msinyana ngemva komhlaka-16 kuMgwengweni, kodwana babuyela [[Johannesburg|e-Johannesburg]] ngemva kweminyaka embalwa.

== Ithuna Lakhe ==
UNdlovu wangcwatshwa noPieterson emathuneni we-Avalon eGoli. Indlu yakhe e-Soweto beyinamathiselwe iphosta ehlaza satjani mhlana ali-16 kuMgwengweni 2012 njengesikhumbuzo sokuhlongakala kwakhe.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>btpg4k3a5uleyyzu1r6i2qwnsh79x0z</sha1>
    </revision>
    <revision>
      <id>3237</id>
      <parentid>3235</parentid>
      <timestamp>2025-06-26T13:42:51Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>putting refrences</comment>
      <origin>3237</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1773" sha1="h60yn8y9fza3puc8jgt83fxjkzzecfq" xml:space="preserve">
'''U-Hastings Ndlovu''' (2 kuMhlolanja 1961 - 16 kuMgwengweni 1976) bekamfundi wesikolo samabanga aphezulu weSewula Afrika owabulawa mapholisa emtjhagalweni [[16 JUNE 1976|we-''Soweto Uprising'']] ngebanga lokujamelana nombuso webandlululo [[Isewula Afrika|eSewula Afrika]].

== Ukuhlongakala Kwakhe ==
UNdlovu wabulawa ngomhlaka-16 kuMgwengweni 1976 ngesikhathi [[16 JUNE 1976|somtjhagalo we-Soweto]] lokha amapholisa we-Orlando nakadumuza abafundi ebegade batjhagalela indaba yokukatelelwa kokusetjenziswa kwesiBhuru eenkolweni zabo. Ukuhlongakala kwakhe akhenge kuvezwe khulu njengaye [[u-Hector Pieterson]] ngombana akunamuntu owamthwebula isithombe. Umlawuli wamapholisa u-Colonel Kleingeld utjele i-''Cillié Commission'' ukuthi u-Ndlovu nguye &quot;obekaphehla isiqubuthu bona sibhenyoge.&quot;&lt;ref&gt;Blue Plaques of South Africa (2013), ''Home of Hastings Ndlovu (2012),'' Wayback Machine Internet Archive (2024). Retrieved from: https://web.archive.org/web/20160407230442/http://blueplaques.co.za/content/home-hastings-ndlovu Retrieved on 26-06-2025.&lt;/ref&gt; 

UNdlovu bekanabodadwabo abathathu nomfowabo. Odadewabo batjhiya inarha msinyana ngemva komhlaka-16 kuMgwengweni, kodwana babuyela [[Johannesburg|e-Johannesburg]] ngemva kweminyaka embalwa.&lt;ref&gt;South African.Info (18 November 2016), ''Hastings: forgotten hero of 1976,'' Web Archive (2016). Retrieved from: https://web.archive.org/web/20161118053520if_/http://www.southafrica.info/about/history/hastings-ndlovu-150605.htm#.WC6TI-j7Q2w Retrieved on 26-06-2025.&lt;/ref&gt;

== Ithuna Lakhe ==
UNdlovu wangcwatjwa noPieterson emathuneni we-Avalon e-Johannesburg. Indlu yekhabo e-Soweto beyinanyathiselwe iphosta ehlaza satjani ngomhlaka-16 kuMgwengweni 2012 njengesikhumbuzo sokuhlongakala kwakhe.

== Iinkomba ==
{{Reflist}}</text>
      <sha1>h60yn8y9fza3puc8jgt83fxjkzzecfq</sha1>
    </revision>
  </page>
  <page>
    <title>Abatloli Abasesebatjha BeSewula Afrika</title>
    <ns>0</ns>
    <id>657</id>
    <revision>
      <id>3241</id>
      <timestamp>2025-06-26T21:13:05Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>Created a new article</comment>
      <origin>3241</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4628" sha1="b9hfn03z574zs16iymdhvcbkpap9n3j" xml:space="preserve">
'''ISewula Afrika''' inomphakathi wabantu abatjha abanetalente lokutlola abazakhela ibizo emkhakheni wezokutlola. Abatlolaba abasesebatjha abakhiqizi iincwadi kwaphela kodwana baba sikhuthazo nakwabanye bona bakuthande ukutlola. Badlale indima ekulu ekucocweni kweendatjana kusukela basesebancani.&lt;ref&gt;News24 (30 August 2017) ''Meet these SA kids who published books before they were 16,'' News24 website (2025). Retrieved from: https://www.news24.com/life/south-africas-youngest-authors-20170830 Retrieved on 24-06-2025.&lt;/ref&gt;

== U-Michelle Nkamankeng ==
U-Michelle Nkamankeng owaziwa ngencwadakhe yokuthoma ayitlolileko i-''&quot;Waiting for the Waves&quot;''  wathoma ukutlola aneminyaka elikhomba. Wabelethwa ngo-2008 ngunina u-Laurentine (Lolo) Nkamankeng oyimeneja yakhe, noyise uPaul Nkamankeng. Abentwana bakwabo ngu-Shawn, u-Sheena no-Marion. UMichelle ube hlangana nabantu abatjha abalitjhumi ephasini ababa batloli basesebancani. Kusukela mhlokho sekatlole umlandelande weencwadi ezine:&lt;ref name=&quot;:0&quot;&gt;Mbali Kgame (August 31, 2018), ''Meet Michelle Nkamankeng, Africa’s Famous School-Age Author,'' Global Citizen website. Retrieved from: https://www.globalcitizen.org/en/content/michelle-nkamankeng-south-africa-author-education/ Retrieved on 24-06-2025.&lt;/ref&gt;

# ''Waiting for the Waves''
# ''The little girl who believes on herself''
# ''The little mouse''
# ''The Golden Ring''&lt;ref name=&quot;:0&quot; /&gt;

== U-Stacey Fru ==
U-Stacey Fru mtloli osele athumbe abonongorwana ngencwadi yakhe yokuthoma ethi, ''&quot;Smelly Cats&quot;'' aneminyaka ebunane kwaphela. Wabelethwa ngo-2007 amntwana wesibili ebantwaneni abane ekhabo. Waziwa njengomntwana onamatalende amanengi nezinto ezinengi azenzileko. Usikhulumi, uyagida begodu ungumlweli wamalungelo wabantwana. Nanzi iincwadi zakhe:&lt;ref name=&quot;:1&quot;&gt;Stacey Fru (2025), Meet Stacey, Stacey Fru website (2025). Retrieved from: https://staceyfru.co.za/ Retrieved on 24-06-2025.&lt;/ref&gt;

# ''Smelly Cats''
# ''Bob and the Snake''
# ''Tim's Answer''&lt;ref name=&quot;:1&quot; /&gt;

== Hallelujah Khumalo ==
U-Hallelujah Khumalo ngomunye walabo abathoma ukutlola basesebancani. Wabelethwa ngo-2016 abelethwa nguSkhona no-Theodora Khumalo.  Waziwa ngencwadakhe edumileko ethi &quot;''Where I Fit''&quot; ekhuthaza abantwana bona bamukele bonyana abafani nabanye abantwana. Naye unamatalenta amanengana njengokudlala ipiyano, ukudansa umjido we-''ballet'' nokhunye. Nanzi iincwadi azitlolileko:&lt;ref name=&quot;:2&quot;&gt;Reitumetse Makwea (20 May 2023), ''Young author Hallelujah Khumalo wants other children to know it's okay not to fit,'' The Citizen (2025). Retrieved from: https://www.citizen.co.za/news/south-africa/special-features/young-author-hallelujah-khumalo-where-i-fit/ Retrieved on 26-06-2025.&lt;/ref&gt;

# ''Where I Fit''
# ''How Halle and Liesl became friends''&lt;ref name=&quot;:2&quot; /&gt;

== Reabetswe Kungwane ==
U-Reabetswe Kungwane besele athoma ukufeza ibhudango lakhe ngokuthoma ukutlola aneminyaka elikhomba. Waziwa ngencwadakhe enesihloko esithi ''‘Stories you’ve never heard before’'' emlandelande weendatjana ezilitjhumi ezikhuluma ngalokho okwenzeke epilwenakhe, ngasinye sinesifundo esiqakathekileko epilweni uReabetswe acabanga bona singahlohlozela abantwana abalingana naye. Incwadi le ineenthombe ezigwalwe nguye. &lt;ref&gt;Rudzani Matshili (2018), ''How a 9-year-old pupil became a published author,'' IOL website (2025). Retrieved from: https://iol.co.za/news/south-africa/gauteng/2018-02-19-how-a-9-year-old-pupil-became-a-published-author/ Retrieved on 26-06-2025.&lt;/ref&gt;

# ''Stories you’ve never heard before''

== U-Metu Ngcali ==
U-Metu Ngcali oneminyaka elitjhumi nanye wazithola anetalente lokutlola ngemva kokungenela isifundobandulo sokutlola. Lokhu kwamenza wakhupha incwadakhe yokuthoma enesihloko esithi &quot;''The Clever Twins&quot;'' ngoVelabahlinze 2019. Uthe nakayethulako incwadi le kwathengwa amakhophi ama-300 ngelangelo. Incwadi le wayitlola acabanga ngomkhulwakhe. U-Metu uthi: &quot;Ngithabe khulu ngokutlola incwadi le. Bengingakuthandi ukutlola ekuthomeni, kodwana ngithe ukungenela isifundobandulo sokutlola esihlelwe yi-''Bala Books'' ngathoma ukuthanda ukutlola. &lt;ref&gt;Lerato Mogoatlhe, (August 2, 2019), ''These 8 Young Authors Want Every Child in South Africa to Have Access to Books,'' Global Citizen website. Retrieved from: https://www.globalcitizen.org/en/content/child-authors-turn-the-page-campaign-south-africa/ Retrieved on 26-06-2025.&lt;/ref&gt;

# ''The Clever Twins''

== Isiphetho ==
Lezi ziimbonelo ezimbalwa kwezinengi zabantu abatjha abanetalende lokutlola abahlala eSewula Afrika. Abantwanaba banikele ngokuthileko okungahlohlozela abanye bona bafune ukutlola nokucoca iindaba.

== Iinkhombo ==</text>
      <sha1>b9hfn03z574zs16iymdhvcbkpap9n3j</sha1>
    </revision>
    <revision>
      <id>3243</id>
      <parentid>3241</parentid>
      <timestamp>2025-06-26T21:20:27Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>speliing fix</comment>
      <origin>3243</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4922" sha1="8yfdlm6r0u1keb27bnuz24kmd56m6yl" xml:space="preserve">
'''ISewula Afrika''' inomphakathi wabantu abatjha abanetalente lokutlola abazakhela ibizo emkhakheni wezokutlola. Abatlolaba abasesebatjha abakhiqizi iincwadi kwaphela kodwana baba sikhuthazo nakwabanye bona bakuthande ukutlola. Badlale indima ekulu ekucocweni kweendatjana kusukela basesebancani.&lt;ref&gt;News24 (30 August 2017) ''Meet these SA kids who published books before they were 16,'' News24 website (2025). Retrieved from: https://www.news24.com/life/south-africas-youngest-authors-20170830 Retrieved on 24-06-2025.&lt;/ref&gt;

== U-Michelle Nkamankeng ==
U-Michelle Nkamankeng owaziwa ngencwadakhe yokuthoma ayitlolileko i-''&quot;Waiting for the Waves&quot;''  wathoma ukutlola aneminyaka elikhomba. Wabelethwa ngo-2008 ngunina u-Laurentine (Lolo) Nkamankeng oyimeneja yakhe, noyise uPaul Nkamankeng. Abentwana bakwabo ngu-Shawn, u-Sheena no-Marion. UMichelle ube hlangana nabantu abatjha abalitjhumi ephasini ababa batloli basesebancani. Kusukela mhlokho sekatlole umlandelande weencwadi ezine:&lt;ref name=&quot;:0&quot;&gt;Mbali Kgame (August 31, 2018), ''Meet Michelle Nkamankeng, Africa’s Famous School-Age Author,'' Global Citizen website. Retrieved from: https://www.globalcitizen.org/en/content/michelle-nkamankeng-south-africa-author-education/ Retrieved on 24-06-2025.&lt;/ref&gt;

# ''Waiting for the Waves''
# ''The little girl who believes on herself''
# ''The little mouse''
# ''The Golden Ring''&lt;ref name=&quot;:0&quot; /&gt;

== U-Stacey Fru ==
U-Stacey Fru mtloli osele athumbe abonongorwana ngencwadi yakhe yokuthoma ethi, ''&quot;Smelly Cats&quot;'' aneminyaka ebunane kwaphela. Wabelethwa ngo-2007 amntwana wesibili ebantwaneni abane ekhabo. Waziwa njengomntwana onamatalende amanengi nezinto ezinengi azenzileko. &lt;ref name=&quot;:1&quot;&gt;Stacey Fru (2025), Meet Stacey, Stacey Fru website (2025). Retrieved from: https://staceyfru.co.za/ Retrieved on 24-06-2025.&lt;/ref&gt;

Ekulumenakhe ayethula ngesikhathi athumba unongorwana, uthi: &quot;Lokhu kungikhuthaze bona ngifune ukwenzela abantu okwengeziweko begodu ngibasize, khulukhulu labo abakhule batlhaga, ngokuthi ngibe nelami iziko namkha i-''foundation'' engingabasiza ngayo.''&quot;''  U-Stacey usikhulumi, uyagida begodu ungumlweli wamalungelo wabantwana. Nanzi iincwadi zakhe:&lt;ref name=&quot;:3&quot; /&gt;

# ''Smelly Cats''
# ''Bob and the Snake''
# ''Tim's Answer''&lt;ref name=&quot;:1&quot; /&gt;

== Hallelujah Khumalo ==
U-Hallelujah Khumalo ngomunye walabo abathoma ukutlola basesebancani. Wabelethwa ngo-2016 abelethwa nguSkhona no-Theodora Khumalo.  Waziwa ngencwadakhe edumileko ethi &quot;''Where I Fit''&quot; ekhuthaza abantwana bona bamukele bonyana abafani nabanye abantwana. Naye unamatalenta amanengana njengokudlala ipiyano, ukudansa umjido we-''ballet'' nokhunye. Nanzi iincwadi azitlolileko:&lt;ref name=&quot;:2&quot;&gt;Reitumetse Makwea (20 May 2023), ''Young author Hallelujah Khumalo wants other children to know it's okay not to fit,'' The Citizen (2025). Retrieved from: https://www.citizen.co.za/news/south-africa/special-features/young-author-hallelujah-khumalo-where-i-fit/ Retrieved on 26-06-2025.&lt;/ref&gt;

# ''Where I Fit''
# ''How Halle and Liesl became friends''&lt;ref name=&quot;:2&quot; /&gt;

== Reabetswe Kungwane ==
U-Reabetswe Kungwane besele athoma ukufeza ibhudango lakhe ngokuthoma ukutlola aneminyaka elikhomba. Waziwa ngencwadakhe enesihloko esithi ''‘Stories you’ve never heard before’'' emlandelande weendatjana ezilitjhumi ezikhuluma ngalokho okwenzeke epilwenakhe, ngasinye sinesifundo esiqakathekileko epilweni uReabetswe acabanga bona singahlohlozela abantwana abalingana naye. Incwadi le ineenthombe ezigwalwe nguye.&lt;ref&gt;Rudzani Matshili (2018), ''How a 9-year-old pupil became a published author,'' IOL website (2025). Retrieved from: https://iol.co.za/news/south-africa/gauteng/2018-02-19-how-a-9-year-old-pupil-became-a-published-author/ Retrieved on 26-06-2025.&lt;/ref&gt;

# ''Stories you’ve never heard before''

== U-Metu Ngcali ==
U-Metu Ngcali oneminyaka elitjhumi nanye wazithola anetalente lokutlola ngemva kokungenela isifundobandulo sokutlola. Lokhu kwamenza wakhupha incwadakhe yokuthoma enesihloko esithi &quot;''The Clever Twins&quot;'' ngoVelabahlinze 2019. Uthe nakayethulako incwadi le kwathengwa amakhophi ama-300 ngelangelo. Incwadi le wayitlola acabanga ngomkhulwakhe. U-Metu uthi: &quot;Ngithabe khulu ngokutlola incwadi le. Bengingakuthandi ukutlola ekuthomeni, kodwana ngithe ukungenela isifundobandulo sokutlola esihlelwe yi-''Bala Books'' ngathoma ukuthanda ukutlola.&lt;ref name=&quot;:3&quot;&gt;Lerato Mogoatlhe, (August 2, 2019), ''These 8 Young Authors Want Every Child in South Africa to Have Access to Books,'' Global Citizen website. Retrieved from: https://www.globalcitizen.org/en/content/child-authors-turn-the-page-campaign-south-africa/ Retrieved on 26-06-2025.&lt;/ref&gt;

# ''The Clever Twins''

== Isiphetho ==
Lezi ziimbonelo ezimbalwa kwezinengi zabantu abatjha abanetalende lokutlola abahlala eSewula Afrika. Abantwanaba banikele ngokuthileko okungahlohlozela abanye bona bafune ukutlola nokucoca iindaba.

== Iinkhombo ==</text>
      <sha1>8yfdlm6r0u1keb27bnuz24kmd56m6yl</sha1>
    </revision>
    <revision>
      <id>3244</id>
      <parentid>3243</parentid>
      <timestamp>2025-06-26T21:42:58Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>3244</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5156" sha1="9sxurcqq7tnutjji5hngmeontz3rq4j" xml:space="preserve">[[Isimumathi:Child reading at Brookline Booksmith.jpg|thumb|364x364px|Umntwana uyafunda]]
'''ISewula Afrika''' inomphakathi wabantu abatjha abanetalente lokutlola abazakhela ibizo emkhakheni wezokutlola. Abatlolaba abasesebatjha abakhiqizi iincwadi kwaphela kodwana baba sikhuthazo nakwabanye bona bakuthande ukutlola. Badlale indima ekulu ekucocweni kweendatjana kusukela basesebancani.&lt;ref&gt;News24 (30 August 2017) ''Meet these SA kids who published books before they were 16,'' News24 website (2025). Retrieved from: https://www.news24.com/life/south-africas-youngest-authors-20170830 Retrieved on 24-06-2025.&lt;/ref&gt; 

== U-Michelle Nkamankeng ==
U-Michelle Nkamankeng owaziwa ngencwadakhe yokuthoma ayitlolileko i-''&quot;Waiting for the Waves&quot;''  wathoma ukutlola aneminyaka elikhomba. Wabelethwa ngo-2008 ngunina u-Laurentine (Lolo) Nkamankeng oyimeneja yakhe, noyise uPaul Nkamankeng. Abentwana bakwabo ngu-Shawn, u-Sheena no-Marion. UMichelle ube hlangana nabantu abatjha abalitjhumi ephasini ababa batloli basesebancani. Kusukela mhlokho sekatlole umlandelande weencwadi ezine:&lt;ref name=&quot;:0&quot;&gt;Mbali Kgame (August 31, 2018), ''Meet Michelle Nkamankeng, Africa’s Famous School-Age Author,'' Global Citizen website. Retrieved from: https://www.globalcitizen.org/en/content/michelle-nkamankeng-south-africa-author-education/ Retrieved on 24-06-2025.&lt;/ref&gt; 

# ''Waiting for the Waves''
# ''The little girl who believes on herself''
# ''The little mouse''
# ''The Golden Ring''&lt;ref name=&quot;:0&quot; /&gt;

== U-Stacey Fru ==
[[Isimumathi:Stacey Ready to do a book reading for children of the Stacey Fru Foundation.jpg|thumb|U-Stacey Fru aphethe incwadi ayitlolileko]]
U-Stacey Fru mtloli osele athumbe abonongorwana ngencwadi yakhe yokuthoma ethi, ''&quot;Smelly Cats&quot;'' aneminyaka ebunane kwaphela. Wabelethwa ngo-2007 amntwana wesibili ebantwaneni abane ekhabo. Waziwa njengomntwana onamatalende amanengi nezinto ezinengi azenzileko. &lt;ref name=&quot;:1&quot;&gt;Stacey Fru (2025), Meet Stacey, Stacey Fru website (2025). Retrieved from: https://staceyfru.co.za/ Retrieved on 24-06-2025.&lt;/ref&gt;

Ekulumenakhe ayethula ngesikhathi athumba unongorwana, uthi: &quot;Lokhu kungikhuthaze bona ngifune ukwenzela abantu okwengeziweko begodu ngibasize, khulukhulu labo abakhule batlhaga, ngokuthi ngibe nelami iziko namkha i-''foundation'' engingabasiza ngayo.''&quot;''  U-Stacey usikhulumi, uyagida begodu ungumlweli wamalungelo wabantwana. Nanzi iincwadi zakhe:&lt;ref name=&quot;:3&quot; /&gt;

# ''Smelly Cats''
# ''Bob and the Snake''
# ''Tim's Answer''&lt;ref name=&quot;:1&quot; /&gt;

== Hallelujah Khumalo ==
U-Hallelujah Khumalo ngomunye walabo abathoma ukutlola basesebancani. Wabelethwa ngo-2016 abelethwa nguSkhona no-Theodora Khumalo.  Waziwa ngencwadakhe edumileko ethi &quot;''Where I Fit''&quot; ekhuthaza abantwana bona bamukele bonyana abafani nabanye abantwana. Naye unamatalenta amanengana njengokudlala ipiyano, ukudansa umjido we-''ballet'' nokhunye. Nanzi iincwadi azitlolileko:&lt;ref name=&quot;:2&quot;&gt;Reitumetse Makwea (20 May 2023), ''Young author Hallelujah Khumalo wants other children to know it's okay not to fit,'' The Citizen (2025). Retrieved from: https://www.citizen.co.za/news/south-africa/special-features/young-author-hallelujah-khumalo-where-i-fit/ Retrieved on 26-06-2025.&lt;/ref&gt;

# ''Where I Fit''
# ''How Halle and Liesl became friends''&lt;ref name=&quot;:2&quot; /&gt;

== Reabetswe Kungwane ==
U-Reabetswe Kungwane besele athoma ukufeza ibhudango lakhe ngokuthoma ukutlola aneminyaka elikhomba. Waziwa ngencwadakhe enesihloko esithi ''‘Stories you’ve never heard before’'' emlandelande weendatjana ezilitjhumi ezikhuluma ngalokho okwenzeke epilwenakhe, ngasinye sinesifundo esiqakathekileko epilweni uReabetswe acabanga bona singahlohlozela abantwana abalingana naye. Incwadi le ineenthombe ezigwalwe nguye.&lt;ref&gt;Rudzani Matshili (2018), ''How a 9-year-old pupil became a published author,'' IOL website (2025). Retrieved from: https://iol.co.za/news/south-africa/gauteng/2018-02-19-how-a-9-year-old-pupil-became-a-published-author/ Retrieved on 26-06-2025.&lt;/ref&gt;

# ''Stories you’ve never heard before''

== U-Metu Ngcali ==
U-Metu Ngcali oneminyaka elitjhumi nanye wazithola anetalente lokutlola ngemva kokungenela isifundobandulo sokutlola. Lokhu kwamenza wakhupha incwadakhe yokuthoma enesihloko esithi &quot;''The Clever Twins&quot;'' ngoVelabahlinze 2019. Uthe nakayethulako incwadi le kwathengwa amakhophi ama-300 ngelangelo. Incwadi le wayitlola acabanga ngomkhulwakhe. U-Metu uthi: &quot;Ngithabe khulu ngokutlola incwadi le. Bengingakuthandi ukutlola ekuthomeni, kodwana ngithe ukungenela isifundobandulo sokutlola esihlelwe yi-''Bala Books'' ngathoma ukuthanda ukutlola.&lt;ref name=&quot;:3&quot;&gt;Lerato Mogoatlhe, (August 2, 2019), ''These 8 Young Authors Want Every Child in South Africa to Have Access to Books,'' Global Citizen website. Retrieved from: https://www.globalcitizen.org/en/content/child-authors-turn-the-page-campaign-south-africa/ Retrieved on 26-06-2025.&lt;/ref&gt;

# ''The Clever Twins''

== Isiphetho ==
Lezi ziimbonelo ezimbalwa kwezinengi zabantu abatjha abanetalende lokutlola abahlala eSewula Afrika. Abantwanaba banikele ngokuthileko okungahlohlozela abanye bona bafune ukutlola nokucoca iindaba.

== Iinkhombo ==</text>
      <sha1>9sxurcqq7tnutjji5hngmeontz3rq4j</sha1>
    </revision>
    <revision>
      <id>3245</id>
      <parentid>3244</parentid>
      <timestamp>2025-06-27T09:55:32Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>3245</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5155" sha1="noo3ettwhi53fa5cen2m75rss148vxv" xml:space="preserve">[[Isimumathi:Child reading at Brookline Booksmith.jpg|thumb|364x364px|Umntwana uyafunda]]
'''ISewula Afrika''' inomphakathi wabantu abatjha abanetalente lokutlola abazakhela ibizo emkhakheni wezokutlola. Abatlolaba abasesebatjha abakhiqizi iincwadi kwaphela kodwana baba sikhuthazo nakwabanye bona bakuthande ukutlola. Badlale indima ekulu ekucocweni kweendatjana kusukela basesebancani.&lt;ref&gt;News24 (30 August 2017) ''Meet these SA kids who published books before they were 16,'' News24 website (2025). Retrieved from: https://www.news24.com/life/south-africas-youngest-authors-20170830 Retrieved on 24-06-2025.&lt;/ref&gt; 

== U-Michelle Nkamankeng ==
U-Michelle Nkamankeng owaziwa ngencwadakhe yokuthoma ayitlolileko i-''&quot;Waiting for the Waves&quot;''  wathoma ukutlola aneminyaka elikhomba. Wabelethwa ngo-2008 ngunina u-Laurentine (Lolo) Nkamankeng oyimeneja yakhe, noyise uPaul Nkamankeng. Abentwana bakwabo ngu-Shawn, u-Sheena no-Marion. UMichelle ube hlangana nabantu abatjha abalitjhumi ephasini ababa batloli basesebancani. Kusukela mhlokho sekatlole umlandelande weencwadi ezine:&lt;ref name=&quot;:0&quot;&gt;Mbali Kgame (August 31, 2018), ''Meet Michelle Nkamankeng, Africa’s Famous School-Age Author,'' Global Citizen website. Retrieved from: https://www.globalcitizen.org/en/content/michelle-nkamankeng-south-africa-author-education/ Retrieved on 24-06-2025.&lt;/ref&gt; 

# ''Waiting for the Waves''
# ''The little girl who believes on herself''
# ''The little mouse''
# ''The Golden Ring''&lt;ref name=&quot;:0&quot; /&gt;

== U-Stacey Fru ==
[[Isimumathi:Stacey Ready to do a book reading for children of the Stacey Fru Foundation.jpg|thumb|U-Stacey Fru aphethe incwadi ayitlolileko]]
U-Stacey Fru mtloli osele athumbe abonongorwana ngencwadi yakhe yokuthoma ethi, ''&quot;Smelly Cats&quot;'' aneminyaka ebunane kwaphela. Wabelethwa ngo-2007 amntwana wesibili ebantwaneni abane ekhabo. Waziwa njengomntwana onamatalende amanengi nezinto ezinengi azenzileko.&lt;ref name=&quot;:1&quot;&gt;Stacey Fru (2025), Meet Stacey, Stacey Fru website (2025). Retrieved from: https://staceyfru.co.za/ Retrieved on 24-06-2025.&lt;/ref&gt;

Ekulumenakhe ayethula ngesikhathi athumba unongorwana, uthi: &quot;Lokhu kungikhuthaze bona ngifune ukwenzela abantu okwengeziweko begodu ngibasize, khulukhulu labo abakhule batlhaga, ngokuthi ngibe nelami iziko namkha i-''foundation'' engingabasiza ngayo.''&quot;''  U-Stacey usikhulumi, uyagida begodu ungumlweli wamalungelo wabantwana. Nanzi iincwadi zakhe:&lt;ref name=&quot;:3&quot; /&gt;

# ''Smelly Cats''
# ''Bob and the Snake''
# ''Tim's Answer''&lt;ref name=&quot;:1&quot; /&gt;

== Hallelujah Khumalo ==
U-Hallelujah Khumalo ngomunye walabo abathoma ukutlola basesebancani. Wabelethwa ngo-2016 abelethwa nguSkhona no-Theodora Khumalo.  Waziwa ngencwadakhe edumileko ethi &quot;''Where I Fit''&quot; ekhuthaza abantwana bona bamukele bonyana abafani nabanye abantwana. Naye unamatalenta amanengana njengokudlala ipiyano, ukudansa umjido we-''ballet'' nokhunye. Nanzi iincwadi azitlolileko:&lt;ref name=&quot;:2&quot;&gt;Reitumetse Makwea (20 May 2023), ''Young author Hallelujah Khumalo wants other children to know it's okay not to fit,'' The Citizen (2025). Retrieved from: https://www.citizen.co.za/news/south-africa/special-features/young-author-hallelujah-khumalo-where-i-fit/ Retrieved on 26-06-2025.&lt;/ref&gt;

# ''Where I Fit''
# ''How Halle and Liesl became friends''&lt;ref name=&quot;:2&quot; /&gt;

== Reabetswe Kungwane ==
U-Reabetswe Kungwane besele athoma ukufeza ibhudango lakhe ngokuthoma ukutlola aneminyaka elikhomba. Waziwa ngencwadakhe enesihloko esithi ''‘Stories you’ve never heard before’'' emlandelande weendatjana ezilitjhumi ezikhuluma ngalokho okwenzeke epilwenakhe, ngasinye sinesifundo esiqakathekileko epilweni uReabetswe acabanga bona singahlohlozela abantwana abalingana naye. Incwadi le ineenthombe ezigwalwe nguye.&lt;ref&gt;Rudzani Matshili (2018), ''How a 9-year-old pupil became a published author,'' IOL website (2025). Retrieved from: https://iol.co.za/news/south-africa/gauteng/2018-02-19-how-a-9-year-old-pupil-became-a-published-author/ Retrieved on 26-06-2025.&lt;/ref&gt;

# ''Stories you’ve never heard before''

== U-Metu Ngcali ==
U-Metu Ngcali oneminyaka elitjhumi nanye wazithola anetalente lokutlola ngemva kokungenela isifundobandulo sokutlola. Lokhu kwamenza wakhupha incwadakhe yokuthoma enesihloko esithi &quot;''The Clever Twins&quot;'' ngoVelabahlinze 2019. Uthe nakayethulako incwadi le kwathengwa amakhophi ama-300 ngelangelo. Incwadi le wayitlola acabanga ngomkhulwakhe. U-Metu uthi: &quot;Ngithabe khulu ngokutlola incwadi le. Bengingakuthandi ukutlola ekuthomeni, kodwana ngithe ukungenela isifundobandulo sokutlola esihlelwe yi-''Bala Books'' ngathoma ukuthanda ukutlola.&lt;ref name=&quot;:3&quot;&gt;Lerato Mogoatlhe, (August 2, 2019), ''These 8 Young Authors Want Every Child in South Africa to Have Access to Books,'' Global Citizen website. Retrieved from: https://www.globalcitizen.org/en/content/child-authors-turn-the-page-campaign-south-africa/ Retrieved on 26-06-2025.&lt;/ref&gt;

# ''The Clever Twins''

== Isiphetho ==
Lezi ziimbonelo ezimbalwa kwezinengi zabantu abatjha abanetalende lokutlola abahlala eSewula Afrika. Abantwanaba banikele ngokuthileko okungahlohlozela abanye bona bafune ukutlola nokucoca iindaba.

== Iinkhombo ==</text>
      <sha1>noo3ettwhi53fa5cen2m75rss148vxv</sha1>
    </revision>
    <revision>
      <id>6634</id>
      <parentid>3245</parentid>
      <timestamp>2026-05-19T19:32:07Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <origin>6634</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5252" sha1="3f2r08o2tvgbc0962nycpqkijldo0y8" xml:space="preserve">[[Isimumathi:Child reading at Brookline Booksmith.jpg|thumb|364x364px|Umntwana uyafunda]]
'''ISewula Afrika''' inomphakathi wabantu abatjha abanekghono lokutlola abazakhela ibizo emkhakheni wezokutlola. Abatlolaba abasesebatjha abakhiqizi iincwadi kwaphela kodwana baba sikhuthazo nakwabanye bona bakuthande ukutlola. Badlale indima ekulu ekucocweni kweendatjana kusukela basesebancani.&lt;ref&gt;News24 (30 August 2017) ''Meet these SA kids who published books before they were 16,'' News24 website (2025). Retrieved from: https://www.news24.com/life/south-africas-youngest-authors-20170830 Retrieved on 24-06-2025.&lt;/ref&gt; 

== U-Michelle Nkamankeng ==
U-Michelle Nkamankeng owaziwa ngencwadakhe yokuthoma ayitlolileko i-''Waiting for the Waves'' wathoma ukutlola aneminyaka elikhomba. Wabelethwa ngomnyaka wee-2008 ngunina u-Laurentine (Lolo) Nkamankeng oyimeneja yakhe, noyise uPaul Nkamankeng. Abentwana bakwabo ngu-Shawn, u-Sheena no-Marion. UMichelle ube hlangana nabantu abatjha abalitjhumi ephasini ababa batloli basesebancani. Kusukela mhlokho sekatlole umlandelande weencwadi ezine:&lt;ref name=&quot;:0&quot;&gt;Mbali Kgame (August 31, 2018), ''Meet Michelle Nkamankeng, Africa’s Famous School-Age Author,'' Global Citizen website. Retrieved from: https://www.globalcitizen.org/en/content/michelle-nkamankeng-south-africa-author-education/ Retrieved on 24-06-2025.&lt;/ref&gt; 

# ''Waiting for the Waves''
# ''The little girl who believes on herself''
# ''The little mouse''
# ''The Golden Ring''&lt;ref name=&quot;:0&quot; /&gt;

== U-Stacey Fru ==
[[Isimumathi:Stacey Ready to do a book reading for children of the Stacey Fru Foundation.jpg|thumb|U-Stacey Fru aphethe incwadi ayitlolileko]]
U-Stacey Fru mtloli osele athumbe abonongorwana ngencwadi yakhe yokuthoma ethi, ''Smelly Cats'' aneminyaka ebunane kwaphela. Wabelethwa ngomnyaka wee-2007 amntwana wesibili ebantwaneni abane ekhabo. Waziwa njengomntwana onamakghono amanengi nezinto ezinengi azenzileko.&lt;ref name=&quot;:1&quot;&gt;Stacey Fru (2025), Meet Stacey, Stacey Fru website (2025). Retrieved from: https://staceyfru.co.za/ Retrieved on 24-06-2025.&lt;/ref&gt;

Ekulumenakhe ayethula ngesikhathi athumba unongorwana, uthi: &quot;Lokhu kungikhuthaze bona ngifune ukwenzela abantu okwengeziweko begodu ngibasize, khulukhulu labo abakhule batlhaga, ngokuthi ngibe nelami iziko namkha i-''foundation'' engingabasiza ngayo.''&quot;''  U-Stacey usikhulumi, uyagida begodu ungumlweli wamalungelo wabantwana. Nanzi iincwadi zakhe:&lt;ref name=&quot;:3&quot; /&gt;

# ''Smelly Cats''
# ''Bob and the Snake''
# ''Tim's Answer''&lt;ref name=&quot;:1&quot; /&gt;

== Hallelujah Khumalo ==
U-Hallelujah Khumalo ngomunye walabo abathoma ukutlola basesebancani. Wabelethwa ngomnyaka wee-2016 abelethwa nguSkhona no-Theodora Khumalo.  Waziwa ngencwadakhe edumileko ethi, ''Where I Fit'' ekhuthaza abantwana bona bamukele bonyana abafani nabanye abantwana. Naye unamakghono amanengana njengokudlala ipiyano, ukudansa umjido we-''ballet'' nokhunye. Nanzi iincwadi azitlolileko:&lt;ref name=&quot;:2&quot;&gt;Reitumetse Makwea (20 May 2023), ''Young author Hallelujah Khumalo wants other children to know it's okay not to fit,'' The Citizen (2025). Retrieved from: https://www.citizen.co.za/news/south-africa/special-features/young-author-hallelujah-khumalo-where-i-fit/ Retrieved on 26-06-2025.&lt;/ref&gt;

# ''Where I Fit''
# ''How Halle and Liesl became friends''&lt;ref name=&quot;:2&quot; /&gt;

== Reabetswe Kungwane ==
U-Reabetswe Kungwane besele athoma ukufeza ibhudango lakhe ngokuthoma ukutlola aneminyaka elikhomba. Waziwa ngencwadakhe enesihloko esithi, ''Stories you’ve never heard before'' emlandelande weendatjana ezilitjhumi ezikhuluma ngalokho okwenzeke epilwenakhe. Ngasinye sinesifundo esiqakathekileko epilweni u-Reabetswe acabanga bona singahlohlozela abantwana abalingana naye. Incwadi le ineenthombe ezigwalwe nguye.&lt;ref&gt;Rudzani Matshili (2018), ''How a 9-year-old pupil became a published author,'' IOL website (2025). Retrieved from: https://iol.co.za/news/south-africa/gauteng/2018-02-19-how-a-9-year-old-pupil-became-a-published-author/ Retrieved on 26-06-2025.&lt;/ref&gt; Nokho yena befukifele ngalesi isikhathi unencwadi yinye:

# ''Stories you’ve never heard before''

== U-Metu Ngcali ==
U-Metu Ngcali oneminyaka elitjhumi nanye wazithola anekghono lokutlola ngemva kokungenela isifundobandulo sokutlola. Lokhu kwamenza wakhupha incwadakhe yokuthoma enesihloko esithi, ''The Clever Twins'' ngoVelabahlinze ngomnyaka wee-2019. Uthe nakayethulako incwadi le kwathengwa amakhophi ama-300 ngelangelo. Incwadi le wayitlola acabanga ngomkhulwakhe. U-Metu uthi, &quot;Ngithabe khulu ngokutlola incwadi le. Bengingakuthandi ukutlola ekuthomeni, kodwana ngithe ukungenela isifundobandulo sokutlola esihlelwe yi-''Bala Books'' ngathoma ukuthanda ukutlola.&lt;ref name=&quot;:3&quot;&gt;Lerato Mogoatlhe, (August 2, 2019), ''These 8 Young Authors Want Every Child in South Africa to Have Access to Books,'' Global Citizen website. Retrieved from: https://www.globalcitizen.org/en/content/child-authors-turn-the-page-campaign-south-africa/ Retrieved on 26-06-2025.&lt;/ref&gt; Naye usatlole incwadi yinye:

# ''The Clever Twins''
Lezi ziimbonelo ezimbalwa kwezinengi zabantu abatjha abanekghono lokutlola abahlala eSewula Afrika. Abantwanaba banikele ngokuthileko okungahlohlozela abanye bona bafune ukutlola nokucoca iindaba.

== Iinkhombo ==</text>
      <sha1>3f2r08o2tvgbc0962nycpqkijldo0y8</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Lungile M. Mabhena/Naledi Chirwa</title>
    <ns>2</ns>
    <id>658</id>
    <revision>
      <id>3247</id>
      <timestamp>2025-06-28T14:55:08Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1293434310|Naledi Chirwa]]&quot;</comment>
      <origin>3247</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7058" sha1="9p0ydlahy6zoy59721c1jokmh97nudx" xml:space="preserve">
{{Infobox officeholder|honorific-prefix=|name=Naledi Chirwa|native_name=|native_name_lang=|honorific-suffix=[[Parliament of South Africa|MP]]|image=Naledi Chirwa, 2024 (cropped).jpg|image_size=|smallimage=&lt;!--If this is specified, &quot;image&quot; should not be.--&gt;|alt=|caption=Chirwa in 2024|office=[[National Council of Provinces|Permanent Delegate to the National Council of Provinces]]|status=|term_start=15 June 2024|term_end=|predecessor=|successor=|birthname=Naledi Nokukhanya Chirwa|birth_date={{birth date and age|1993|07|22|df=y}}|birth_place=[[Vosloorus]], [[East Rand]]&lt;br /&gt; [[Transvaal Province|Transvaal]], [[South Africa]]|death_date=|death_place=|citizenship=|nationality=[[South Africa]]n|party=[[Economic Freedom Fighters]] {{small|(2015–present)}}|otherparty=|spouse=|partner=&lt;!--For those with a domestic partner and not married--&gt;|relations=|children=2|residence=|education=|alma_mater=[[University of Pretoria]]|occupation=Member of Parliament|profession=Politician|known_for=|committees=|portfolio=|awards=|website=|honorific_prefix=[[The Honourable]]|termend1=21 May 2024|termstart1=22 May 2019|office1=[[National Assembly of South Africa|Member of the National Assembly]]|constituency_AM=}}

'''UNaledi Nokukhanya Chirwa-Mpungose''' wabelethwa mhlana amalanga ama-22 kuNtaka ngomnyaka we-1993. Ungusopolotiki weSewula Afrika begodu gade amlweli wabafundi wesifunda se -Gauteng . Ujamele i -Economic Freedom Fighters (EFF) e- National Assembly . UChirwa bekalilunga le- National Assembly ukusukela ngenyanga kaMrhayili ngomnyaka wee-2019 ukuya enyangeni kaMgwengweni ngomnyaka wee-2024. Uhlale isikhathi esifitjhani eKhanseleni yeNarha yamaPhrovinsi ngaphambi kobana athunyelwe e -National Assembly ukuze athathe isikhundla  sakaMbuyiseni Ndlozi . Ukukhula nokuduma kwakhe kubangwe kuzibandakanya nabafundi be-#FeesMustFall e- University of Pretoria ukusukela ngomnyaka wee-2015 ukuya emnyakeni wee-2016.

== Ipilo yokuthoma nefundo ==
U-Chirwa wabelethwa mhlana amalanga ama-22 kuNtaka emnyakeni we-1993 e- [[Vosloorus]], e-East Rand, e- Gauteng .  Ekukhuleni kwakhe ukhuliswa ngugogwakhe e -Mamelodi, e-Pitoli . &lt;ref name=&quot;SunWorld&quot; /&gt; phezu komnyaka wee-2009, uthe lokha nakaneminyaka ema-15, wasebenza njengomsekeli kamongameli we-Tshwane North College (TNC) Further Education &amp; Training (FET), manje i-TNC TVET. &lt;ref name=&quot;SunWorld&quot; /&gt;

U-Chirwa wafunyana iziqu ze -Bachelor of Arts kanye neziqu ze- Honors degree kuDrama and Film Studies e- University of Pretoria . Ukusukela ngomnyaka wee-2019 bekafunda i -Master of Arts ku-Theatre and Performance e- University of the Witwatersrand . 

== Umlweli wabafundi ==
U-Chirwa waba lilunga le -Economic Freedom Fighters (EFF) ngomnyaka wee-2015 begodu waba godu lilunga le-Student Command yehlangano e-University of Pretoria. Wabuya wakhethwa bewabekwa njengesikhulu sezokuthintana somlawuli.  Ngenyanga kaRhoboyi ngomnyaka wee-2016, ngesikhathi umongameli wenarha wangaphambilini u-Jacob Zuma akhuluma esikhungweni sekhetho se-IEC ngemva kokhetho lukamasipala wango-2016, u-Chirwa nabanye abafundi ababe babathathu baphazamisa ikulumo kamongameli ngesikhathi baphakamise amatshwayo athi &quot;Khanga&quot;, &quot;Khumbula u-Khwezi &quot;, &quot;Ngingu-1 kwaba-3&quot; kanye nokuthi &quot;emva kweminyaka ema-10 &quot;, ngokukhamba kwesikhathi ngokutjho uZuma ukudlwengula phakathi kwabo-2000.  

Godu ngomnyaka wee-2016, u-Chirwa bekabandakanyeka emigurugurwini wabafundi ephathelene nomnyakazo we- #FeesMustFall . Ekukhambeni kwesikhathi wabotjhwa begodu wajanyiswa ekhampasini njengomunye wemibandela webheyili yakhe.  Ngomnyaka wee-2017, bekangomunye wabantu abatjha abama-200 be-Mail &amp;amp;amp; Guardian . 

== Umsebenzi wePalamende ==

=== UmHlangano weNarha: 2019–2024 ===
Ngamakhetho kaMeyi 2019, wakhethelwa i -National Assembly of South Africa begodu waba lilunga lePalamende ebegade lilincani khulu ngomnyaka ngaphasi kwehlangano ye-EFF. Wafungiswa kanye nabanye abafundi abalwako, okufaka hlangana u-Peter Keetse, u-Nompendulo Mkhatshwa no -Vuyani Pambo .  Bekalilunga leKomidi yePhothifoliyo yePalamende yezePilo . 

Mhlazana amalanga ama-25 kuMgwengweni ngomnyaka wee-2019, wethula ikulumo yakhe yokuthoma ngesikhathi sokuphikisana ngeKulumo yeNarha . Wakatelelwa bona arhoqise ukuphawula kwakhe malungana nokuthi urhulumende ubandakanyeka ekubulaweni kwabasekeli be-#FeesMustFall.   NgoTjhirhweni 2022, waduma ekundleni yokuthintana eyayibizwa bona yi-Twitter ngokubiza uMongameli u-Cyril Ramaphosa ngokuthi &quot;akanamazinyo&quot; begodu &quot;msana omncani obuthakathaka&quot;. 

Ukusukela lapha ngomnyaka wee-2020, u-Chirwa wahlaselwa eenkundleni zokuthintana basebenzisi abangaziwako ebebatjho ngaphandle kobufakazi ukuthi usisakhamuzi se [[Malawi|-Malawi]] begodu umndenakhe ufumene ubuzwe beSewula Afrika ngokukhohlisa.  NgoTjhirhweni 2022, waphendula iinsolwezo ngokuthumela ku-Twitter wathi : &quot;Ningaleya amala ngobuzwe bami bekube kulapho niphenduka nibe hlaza amahlalo. Angeze amala wenu aba liqiniso begodu angeze kwangenza ngithule. Azange ngilithenge iphimbo lami. Angiliqatjhisi. Ngizokuhlala ngikhuluma begodu ayikho into eningayenza ngalokho.&quot; 

Ngenyanga kaNtaka 2024, u-Chirwa bekangekho emakhethweni wepalamende ukwenzela bona atlhogomele umntwanakhe ogolako. I-EFF yamhlawulisa begodu yamyalela bona aqolise.   Msinyana ngemva kwalokho, i-EFF yakhupha irhelo layo labakhethiweko bekhetho elizako, ebelibeka u-Chirwa endaweni yokugcina.   Umdosiphambili we-EFF u-Julius Malema wathi ukwehliswa kwakhe esikhundleni bekumphumela wehlelo lehlangano yentando yenengi. 

=== UmKhandlu weNarha weemFunda: uMgwengweni 2024–Tjhirhweni 2025 ===
Ngamakhetho kaSihlabantangana 2024, u-Chirwa wakhethwa bona ajamele i-EFF esithunyweni se-Gauteng e- National Council of Provinces, ekuyindlu ephezulu yePalamende yeSewula Afrika. Wafungiswa esihlalweni sakhe mhlana amalanga ama-15 kuMgwengweni ngomnyaka wee-2024. 

== Ipilo yakhe mathupha ==
U-Chirwa wenda ukusukela ngoNobayeni ngomnyaka wee-2022.  Unabantwana ababili, omunye waboantwana wabelethwa ngomnyaka wee-2021 kuthi lo omunye wabelethwa ngomnyaka wee-2023. 

== Iinkomba ==

# https://nr.wikipedia.org/wiki/Special:ContentTranslation?from=en&amp;to=nr&amp;page=Naledi+Chirwa






































{{Reflist}}

== Amalinki wangaphandle ==

* [https://www.pa.org.za/person/naledi-nokukhanya-chirwa/ Naledi Nokukhanya Chirwa] emhlanganweni wabantu
{{Permanent delegates of the National Council of Provinces}}{{DEFAULTSORT:Chirwa, Naledi}}
&lt;nowiki&gt;
[[Mkhakha:Members of the National Assembly of South Africa 2019–2024]]
[[Mkhakha:Women members of the National Council of Provinces]]
[[Mkhakha:Women members of the National Assembly of South Africa]]
[[Mkhakha:University of Pretoria alumni]]
[[Mkhakha:South African feminists]]
[[Mkhakha:Politicians from Gauteng]]
[[Mkhakha:People from Vosloorus]]
[[Mkhakha:Members of the National Council of Provinces]]
[[Mkhakha:FeesMustFall activists]]
[[Mkhakha:Economic Freedom Fighters politicians]]
[[Mkhakha:21st-century South African women politicians]]
[[Mkhakha:1993 births]]
[[Mkhakha:Living people]]&lt;/nowiki&gt;</text>
      <sha1>9p0ydlahy6zoy59721c1jokmh97nudx</sha1>
    </revision>
    <revision>
      <id>3255</id>
      <parentid>3247</parentid>
      <timestamp>2025-06-29T14:05:44Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <comment>I created another translation</comment>
      <origin>3255</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="30" sha1="rg7f9sp07my3b928k896oczyixoomxx" xml:space="preserve">{{DEFAULTSORT:Chirwa, Naledi}}</text>
      <sha1>rg7f9sp07my3b928k896oczyixoomxx</sha1>
    </revision>
  </page>
  <page>
    <title>Abantu Abatjha Kwezokulima</title>
    <ns>0</ns>
    <id>659</id>
    <revision>
      <id>3249</id>
      <timestamp>2025-06-28T17:51:02Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <comment>New article</comment>
      <origin>3249</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6108" sha1="5f03hf4jqrcqu3ua97z3r8fls9y5y9k" xml:space="preserve">[[Isimumathi:Marcus Bai with PNG youth (10698164975).jpg|thumb|321x321px|Abantu abatjha bayalima]]
'''ESewula Afrika,''' abantu abatjha abakavami ukutholakala khulu kwezokulima, yeke sibalo esincani khulu sabantu abatjha abathuthukisa zokulima. Nanyana kunjalo kunomnyakazo owenzekako kwezokulima, njengokukhiqizwa kokudla, ukuthengiswa kokudla nokwehla komtlhago ezikweneli ngebanga lendima edlalwa babantu abatjha abambalwa, khulukhulu eendaweni zemakhaya. Kodwana kusesenesitjhijilo sokukara abantu abatjha ezikweneli, kuhlanganise nokungatholakali kuhle kwenarha yokutjala, iimali namakghono atlhogekako.&lt;ref&gt;Ongama Giwu, Lelethu Mdoda, Samuel S. Ntlanga, Olwethu Loki ( 08 Nov. 2024), ''Evaluating factors influencing youth participation in agricultural enterprises: Implications for food security and agribusiness,'' SAJEBSM website. Retrieved from: https://sajesbm.co.za/index.php/sajesbm/article/view/903/1130 Retrieved 28-06-2025.&lt;/ref&gt; 

Irhubululo litjengisa bona kunamaphesente ama-24 wabantu abatjha ababandakanyeke kezokulima, begodu bambalwa khulu abenza imali ngakho. Abtjha abamaphesente ama-23 nama-21 benza imali ngamaplasi begodu banamabubulo wabo. Abatjha abatjhadileko nalabo ababondlako emizinabo nabo baba nethando lokulima ngombana ekhaya bayalama.&lt;ref&gt;The Water Wheel pamphlet (January-February 2022) ''Youth and Agriculture.''&lt;/ref&gt; 

== Iintjhijilo Abatjha Abaqalana Nazo Kezokulima ==
Nanzi iintjhijilo abantu abatjha abaqalene nazo ezikweni lezokulima:

# Ukungatholakali lula kwelwazi nefundo yezokulima. Lokhu kuhlanganisa ifundo namakghono wezokulima asezingeni eliphasi okungilo elinomthelela omkhulu ekungabini khona kwemikhiqizo yezokulima, bese lokhu kubangele ukungalingani nomtlhago enarheni. 
# Ukungatholakali kwenarha. Lokhu kumraro khulukhulu kabengubo abasesebatjha ngokwesiko labanzima abanganikelwa ilifa lenarha. Ngaphezu kwalokho bambalwa khulu abantu abatjha abakghona ukuthoma imali-mbonelelo etholakalako yokuthenga inarha.
# Ukungatholakali lula kwemali nezenzelwa, kuhlanganise nemali-mboleko, imali ebulungwako netjhorensi etlhogekako bona ithomise ibubulo lokulima beyithuthukise nemikhiqizo yakhona.
# Ubudisi bokutholakala kwemisebenzi ephathelene nezokulima engondla amaphilo wabantu abatjha isikhathi eside. 
# Ukungatholakali lula kwamamakethe okungathengiswa kiwo imikhiqizo yezokulima okwenziwa ziintolo ezikulu ezithengisa imikhiqizo yezokulima, ukungabibikho kwefundo, ibandulo nelwazi elaneleko ngokuthengisa imikhiqizo yokulima.
# Ukungatholakali lula kwamathuba wokubandakanyeka nakucociswana ngepholisi yezokulima. Lokho kutjho bona kunabantu imibono yabo engekhe izwakale, bese lokho kwenze abantu abatjha abathanda ukulima bangakutholi abakutlhogako.&lt;ref name=&quot;:0&quot;&gt;UNAI Hub for SDG2 News, (June 16, 2022) ''The youth are the future of the agricultural sector'', University of Pretoria website. Retrieved from: https://www.up.ac.za/unai-hub-for-sdg2/news/post_3082769-the-youth-are-the-future-of-the-agricultural-sector Retrieved on 28-06-2025.&lt;/ref&gt; 

== Indlela Iintjhijilwezi Ezingararululwa Ngayo ==

# Urhulumende kufuze wandise amahlelo wokwabelana ngelwazi nefundo yezokulima ukuze kutholakale ilwazi elaneleko ngezokulima. Amahlelo la angenziwa bese afundiswe abantu abatjha kusukela ebuncanini babo, okungasiza ekwakheni ithando lezokulima eenhliziyweni zabo. Kufuze kube namahlelo wokubandula abafundisi begodu eze neentlabagelo zokufundisa abantu abatjha ngezokulima nangendlela ukudla okukhiqizwa ngayo.&lt;ref name=&quot;:0&quot; /&gt;
# Urhulumende kuye namabubulo azijameleko kufuze bafake imali ekuthuthukiseni ezokulima begodu bathuthukise nethekhnoloji yezokulima, bebasekele abantu abatjha abangenela umkhakhalo. Amaziko wezeemali nawo kufuze avulele abantu abatjha amathuba aneleko begodu kube bulula bona abantu abatjha bawafumane.&lt;ref name=&quot;:0&quot; /&gt;
# Urhulumende kufuze unikelane ngenarha ekhona bona abantu abatjha balimele kiyo, begodu kufuze anikele nangemali engathenga inarha yokulima. Yeke kufuze uthuthukise imithethokambiso yokutholakala kwenarha yokulima eSewula Afrika. Nanyana kunamahlelo nemithethokambiso eminengi emalungana nokwabiwa kwenarha yokulima, kusafuze enze kube bulula ukufumana amathuba lawo.&lt;ref&gt;South African Government website (2025), ''Land and agriculture.'' Retrieve from: https://www.gov.za/issues/land-and-agriculture Retrieved on 28-06-2025.&lt;/ref&gt; 

== Abatjha Abaphumelelako Kwezokulima ==

* '''Phikolomzi Qinisa Dlamini:''' Umphathi kezokulima ekhamphanini i-''Ndela Farming'', wathola iziqu zakhe e-''Cedara College of Agriculture'' begodu ukhuthaza abantu abatjha bona balandelele khulu ifundo yezokulima.&lt;ref name=&quot;:1&quot;&gt;Nicole Ludolph (21st June 2022) ''Watch out, these young farmers are on fire!'', foodformzansi.co.za, Retrieved from: https://www.foodformzansi.co.za/watch-out-these-young-farmers-are-on-fire/ Retrieved on 28-08-2025.&lt;/ref&gt; 
* '''Keneilwe Raphesu:''' Uphethe ibubulo i-''Runs Mogalemone Farm'' banoyise begodu ukhuthaza nabanye bona bangenele zokulima.&lt;ref name=&quot;:1&quot; /&gt; 
* '''Thabo Herman Dithakgwe:''' Wathoma ibubulo elibizwa bona yi-''Ditha Farming, Wildlife and Projects''  aneminyaka eli-19.&lt;ref&gt;More Matshediso (2019)''Teen farmer makes dad proud'', Vuk'uzenzele website (2025).Retrieved from: https://www.vukuzenzele.gov.za/teen-farmer-makes-dad-proud Retrieved on 28-06-2025.&lt;/ref&gt;
* '''Sabelo Mdlalose:''' Nguye odosa phambili i-''Iqabungelihle Primary Cooperative'', utjala imirorho neenungo.&lt;ref&gt;Food and Trees for Africa (2021) ''Youth are the future of SA agriculture''. Retrieved from: https://trees.org.za/youth-are-the-future-of-sa-agriculture Retrieve on 28-06-2025.&lt;/ref&gt;
* '''Stanley Ntshangase:''' Umlimi onesivuno esincani ophumelele khulu ukutjala ikhabitjhi, amabhatata nesiphila begodu imikhiqizo yakhe uyithumela e-SPAR.&lt;ref&gt;Timbali Technologies (28 Nov 2023) ''Southern Africa small-scale farming success featuring individual success story'', PROAGRIMEDIA Retrieved from: https://www.proagrimedia.com/people/southern-africa-small-scale-farming-success-featuring-individual-success-story Retrieved on 28-06-2025.&lt;/ref&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>5f03hf4jqrcqu3ua97z3r8fls9y5y9k</sha1>
    </revision>
    <revision>
      <id>3250</id>
      <parentid>3249</parentid>
      <timestamp>2025-06-28T18:01:44Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <comment>spelling</comment>
      <origin>3250</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6122" sha1="rt58acfgogga2avpdf98f5zlp9hvcpi" xml:space="preserve">[[Isimumathi:Marcus Bai with PNG youth (10698164975).jpg|thumb|321x321px|Abantu abatjha bayalima]]
'''ESewula Afrika,''' abantu abatjha abakavami ukutholakala khulu kwezokulima, yeke sibalo esincani khulu sabantu abatjha abathuthukisa zokulima. Nanyana kunjalo kunomnyakazo owenzekako kwezokulima, njengokukhiqizwa kokudla, ukuthengiswa kokudla nokwehla komtlhago ezikweneli ngebanga lendima edlalwa babantu abatjha abambalwa, khulukhulu eendaweni zemakhaya. Kodwana kusesenesitjhijilo sokukara abantu abatjha ezikweneli, kuhlanganise nokungatholakali kuhle kwenarha yokutjala, iimali namakghono atlhogekako.&lt;ref&gt;Ongama Giwu, Lelethu Mdoda, Samuel S. Ntlanga, Olwethu Loki ( 08 Nov. 2024), ''Evaluating factors influencing youth participation in agricultural enterprises: Implications for food security and agribusiness,'' SAJEBSM website. Retrieved from: https://sajesbm.co.za/index.php/sajesbm/article/view/903/1130 Retrieved 28-06-2025.&lt;/ref&gt; 

Irhubululo litjengisa bona kunamaphesente ama-24 wabantu abatjha ababandakanyeke kezokulima, begodu bambalwa khulu abenza imali ngakho. Abatjha abamaphesente ama-23 nama-21 benza imali ngamaplasi begodu banamabubulo wabo. Abatjha abatjhadileko nalabo ababondlako emizinabo nabo baba nethando lokulima ngombana ekhaya kuyalinywa.&lt;ref&gt;The Water Wheel pamphlet (January-February 2022) ''Youth and Agriculture.''&lt;/ref&gt; 

== Iintjhijilo Abatjha Abaqalana Nazo Kezokulima ==
Nanzi iintjhijilo abantu abatjha abaqalene nazo ezikweni lezokulima:

# Ukungatholakali lula kwelwazi nefundo yezokulima. Lokhu kuhlanganisa ifundo namakghono wezokulima asezingeni eliphasi okungilo elinomthelela omkhulu ekungabini khona kwemikhiqizo yezokulima, bese lokhu kubangele ukungalingani nomtlhago enarheni. 
# Ukungatholakali kwenarha. Lokhu kumraro khulukhulu kabengubo abasesebatjha ngokwesiko labanzima abanganikelwa ilifa lenarha. Ngaphezu kwalokho bambalwa khulu abantu abatjha abakghona ukufumana imali-mbonelelo etholakalako yokuthenga inarha.
# Ukungatholakali lula kwemali nezenzelwa, kuhlanganise nemali-mboleko, imali ebulungwako netjhorensi etlhogekako bona kuthonyiswe ibubulo lokulima bekuthuthukise nemikhiqizo yakhona.
# Ubudisi bokutholakala kwemisebenzi ephathelene nezokulima engondla amaphilo wabantu abatjha isikhathi eside. 
# Ukungatholakali lula kwamamakethe okungathengiswa kiwo imikhiqizo yezokulima okumthelela weentolo ezikulu ezithengisa imikhiqizo yezokulima, ukungabibikho kwefundo, ibandulo nelwazi elaneleko ngokuthengisa imikhiqizo yokulima.
# Ukungatholakali lula kwamathuba wokubandakanyeka nakucociswana ngepholisi yezokulima. Lokho kutjho bona kunabantu imibono yabo engekhe izwakale, bese lokho kwenze abantu abatjha abathanda ukulima bangakutholi abakutlhogako.&lt;ref name=&quot;:0&quot;&gt;UNAI Hub for SDG2 News, (June 16, 2022) ''The youth are the future of the agricultural sector'', University of Pretoria website. Retrieved from: https://www.up.ac.za/unai-hub-for-sdg2/news/post_3082769-the-youth-are-the-future-of-the-agricultural-sector Retrieved on 28-06-2025.&lt;/ref&gt; 

== Indlela Iintjhijilwezi Ezingararululwa Ngayo ==

# Urhulumende kufuze wandise amahlelo wokwabelana ngelwazi nefundo yezokulima ukuze kutholakale ilwazi elaneleko ngezokulima. Amahlelo la angenziwa bese afundiswe abantu abatjha kusukela ebuncanini babo, okungasiza ekwakheni ithando lezokulima eenhliziyweni zabo. Kufuze kube namahlelo wokubandula abafundisi begodu eze neentlabagelo zokufundisa abantu abatjha ngezokulima nangendlela ukudla okukhiqizwa ngayo.&lt;ref name=&quot;:0&quot; /&gt;
# Urhulumende namabubulo azijameleko kufuze bafake imali ekuthuthukiseni ezokulima begodu bathuthukise nethekhnoloji yezokulima, bebasekele abantu abatjha abangenela umkhakha lo. Amaziko wezeemali nawo kufuze avulele abantu abatjha amathuba aneleko begodu kube bulula bona bawafumane.&lt;ref name=&quot;:0&quot; /&gt;
# Kunamahlelo nemithethokambiso eminengana kwarhulumende emalungana nokunikelwa kwenarha namkha ngemali yokuyithenga, kodwana amahlelo lawo akusibulula ukuwafumana. Yeke kufuze uthuthukise imithethokambiso yokutholakala kwenarha yokulima eSewula Afrika. Nanyana kunamahlelo nemithethokambiso eminengi emalungana nokwabiwa kwenarha yokulima, kusafuze enze kube bulula ukufumana amathuba lawo.&lt;ref&gt;South African Government website (2025), ''Land and agriculture.'' Retrieve from: https://www.gov.za/issues/land-and-agriculture Retrieved on 28-06-2025.&lt;/ref&gt; 

== Abatjha Abaphumelelako Kwezokulima ==

* '''Phikolomzi Qinisa Dlamini:''' Umphathi kwezokulima ekhamphanini i-''Ndela Farming'', wathola iziqu zakhe e-''Cedara College of Agriculture'' begodu ukhuthaza abantu abatjha bona balandelele khulu ifundo yezokulima.&lt;ref name=&quot;:1&quot;&gt;Nicole Ludolph (21st June 2022) ''Watch out, these young farmers are on fire!'', foodformzansi.co.za, Retrieved from: https://www.foodformzansi.co.za/watch-out-these-young-farmers-are-on-fire/ Retrieved on 28-08-2025.&lt;/ref&gt; 
* '''Keneilwe Raphesu:''' Uphethe ibubulo i-''Runs Mogalemone Farm'' banoyise begodu ukhuthaza nabanye bona bangenele zokulima.&lt;ref name=&quot;:1&quot; /&gt; 
* '''Thabo Herman Dithakgwe:''' Wathoma ibubulo elibizwa bona yi-''Ditha Farming, Wildlife and Projects''  aneminyaka eli-19.&lt;ref&gt;More Matshediso (2019)''Teen farmer makes dad proud'', Vuk'uzenzele website (2025).Retrieved from: https://www.vukuzenzele.gov.za/teen-farmer-makes-dad-proud Retrieved on 28-06-2025.&lt;/ref&gt;
* '''Sabelo Mdlalose:''' Nguye odosa phambili i-''Iqabungelihle Primary Cooperative'', utjala imirorho neenungo.&lt;ref&gt;Food and Trees for Africa (2021) ''Youth are the future of SA agriculture''. Retrieved from: https://trees.org.za/youth-are-the-future-of-sa-agriculture Retrieve on 28-06-2025.&lt;/ref&gt;
* '''Stanley Ntshangase:''' Umlimi onesivuno esincani ophumelele khulu ukutjala ikhabitjhi, amabhatata nesiphila begodu imikhiqizo yakhe uyithumela e-SPAR.&lt;ref&gt;Timbali Technologies (28 Nov 2023) ''Southern Africa small-scale farming success featuring individual success story'', PROAGRIMEDIA Retrieved from: https://www.proagrimedia.com/people/southern-africa-small-scale-farming-success-featuring-individual-success-story Retrieved on 28-06-2025.&lt;/ref&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>rt58acfgogga2avpdf98f5zlp9hvcpi</sha1>
    </revision>
    <revision>
      <id>3562</id>
      <parentid>3250</parentid>
      <timestamp>2025-08-06T08:24:12Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <origin>3562</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6199" sha1="ewwd1eh02tlhxbs5eg4g7ohg0ha4svb" xml:space="preserve">[[Isimumathi:Marcus Bai with PNG youth (10698164975).jpg|thumb|321x321px|Abantu abatjha bayalima]]
'''ESewula Afrika,''' abantu abatjha abakavami ukutholakala khulu kwezokulima, yeke sibalo esincani khulu sabantu abatjha abathuthukisa zokulima. Nanyana kunjalo kunomnyakazo owenzekako kwezokulima, njengokukhiqizwa kokudla, ukuthengiswa kokudla nokwehla komtlhago ezikweneli ngebanga lendima edlalwa babantu abatjha abambalwa, khulukhulu eendaweni zemakhaya. Kodwana kusesenesitjhijilo sokukara abantu abatjha ezikweneli, kuhlanganise nokungatholakali kuhle kwenarha yokutjala, iimali namakghono atlhogekako.&lt;ref&gt;Ongama Giwu, Lelethu Mdoda, Samuel S. Ntlanga, Olwethu Loki ( 08 Nov. 2024), ''Evaluating factors influencing youth participation in agricultural enterprises: Implications for food security and agribusiness,'' SAJEBSM website. Retrieved from: https://sajesbm.co.za/index.php/sajesbm/article/view/903/1130 Retrieved 28-06-2025.&lt;/ref&gt; 

Irhubululo litjengisa bona kunamaphesente ama-24 wabantu abatjha ababandakanyeke kezokulima, begodu bambalwa khulu abenza imali ngakho. Abatjha abamaphesente ama-23 nama-21 benza imali ngamaplasi begodu banamabubulo wabo. Abatjha abatjhadileko nalabo ababondlako emizinabo nabo baba nethando lokulima ngombana ekhaya kuyalinywa.&lt;ref&gt;The Water Wheel pamphlet (January-February 2022) ''Youth and Agriculture.''&lt;/ref&gt; 

== Iintjhijilo Abatjha Abaqalana Nazo Kezokulima ==
Nanzi iintjhijilo abantu abatjha abaqalene nazo ezikweni lezokulima:

# Ukungatholakali lula kwelwazi nefundo yezokulima. Lokhu kuhlanganisa ifundo namakghono wezokulima asezingeni eliphasi okungilo elinomthelela omkhulu ekungabini khona kwemikhiqizo yezokulima, bese lokhu kubangele ukungalingani nomtlhago enarheni. 
# Ukungatholakali kwenarha. Lokhu kumraro khulukhulu kabengubo abasesebatjha ngokwesiko labanzima abanganikelwa ilifa lenarha. Ngaphezu kwalokho bambalwa khulu abantu abatjha abakghona ukufumana imali-mbonelelo etholakalako yokuthenga inarha.
# Ukungatholakali lula kwemali nezenzelwa, kuhlanganise nemali-mboleko, imali ebulungwako netjhorensi etlhogekako bona kuthonyiswe ibubulo lokulima bekuthuthukise nemikhiqizo yakhona.
# Ubudisi bokutholakala kwemisebenzi ephathelene nezokulima engondla amaphilo wabantu abatjha isikhathi eside. 
# Ukungatholakali lula kwamamakethe okungathengiswa kiwo imikhiqizo yezokulima okumthelela weentolo ezikulu ezithengisa imikhiqizo yezokulima, ukungabibikho kwefundo, ibandulo nelwazi elaneleko ngokuthengisa imikhiqizo yokulima.
# Ukungatholakali lula kwamathuba wokubandakanyeka nakucociswana ngepholisi yezokulima. Lokho kutjho bona kunabantu imibono yabo engekhe izwakale, bese lokho kwenze abantu abatjha abathanda ukulima bangakutholi abakutlhogako.&lt;ref name=&quot;:0&quot;&gt;UNAI Hub for SDG2 News, (June 16, 2022) ''The youth are the future of the agricultural sector'', University of Pretoria website. Retrieved from: https://www.up.ac.za/unai-hub-for-sdg2/news/post_3082769-the-youth-are-the-future-of-the-agricultural-sector Retrieved on 28-06-2025.&lt;/ref&gt; 

== Indlela Iintjhijilwezi Ezingararululwa Ngayo ==

# Urhulumende kufuze wandise amahlelo wokwabelana ngelwazi nefundo yezokulima ukuze kutholakale ilwazi elaneleko ngezokulima. Amahlelo la angenziwa bese afundiswe abantu abatjha kusukela ebuncanini babo, okungasiza ekwakheni ithando lezokulima eenhliziyweni zabo. Kufuze kube namahlelo wokubandula abafundisi begodu eze neentlabagelo zokufundisa abantu abatjha ngezokulima nangendlela ukudla okukhiqizwa ngayo.&lt;ref name=&quot;:0&quot; /&gt;
# Urhulumende namabubulo azijameleko kufuze bafake imali ekuthuthukiseni ezokulima begodu bathuthukise nethekhnoloji yezokulima, bebasekele abantu abatjha abangenela umkhakha lo. Amaziko wezeemali nawo kufuze avulele abantu abatjha amathuba aneleko begodu kube bulula bona bawafumane.&lt;ref name=&quot;:0&quot; /&gt;
# Kunamahlelo nemithethokambiso eminengana kwarhulumende emalungana nokunikelwa kwenarha namkha ngemali yokuyithenga, kodwana amahlelo lawo akusibulula ukuwafumana. Yeke kufuze uthuthukise imithethokambiso yokutholakala kwenarha yokulima eSewula Afrika. Nanyana kunamahlelo nemithethokambiso eminengi emalungana nokwabiwa kwenarha yokulima, kusafuze enze kube bulula ukufumana amathuba lawo.&lt;ref&gt;South African Government website (2025), ''Land and agriculture.'' Retrieve from: https://www.gov.za/issues/land-and-agriculture Retrieved on 28-06-2025.&lt;/ref&gt; 

== Abatjha Abaphumelelako Kwezokulima ==

* '''Phikolomzi Qinisa Dlamini:''' Umphathi kwezokulima ekhamphanini i-''Ndela Farming'', wathola iziqu zakhe e-''Cedara College of Agriculture'' begodu ukhuthaza abantu abatjha bona balandelele khulu ifundo yezokulima.&lt;ref name=&quot;:1&quot;&gt;Nicole Ludolph (21st June 2022) ''Watch out, these young farmers are on fire!'', foodformzansi.co.za, Retrieved from: https://www.foodformzansi.co.za/watch-out-these-young-farmers-are-on-fire/ Retrieved on 28-08-2025.&lt;/ref&gt; 
* '''Keneilwe Raphesu:''' Uphethe ibubulo i-''Runs Mogalemone Farm'' banoyise begodu ukhuthaza nabanye bona bangenele zokulima.&lt;ref name=&quot;:1&quot; /&gt; 
* '''Thabo Herman Dithakgwe:''' Wathoma ibubulo elibizwa bona yi-''Ditha Farming, Wildlife and Projects''  aneminyaka eli-19.&lt;ref&gt;More Matshediso (2019)''Teen farmer makes dad proud'', Vuk'uzenzele website (2025).Retrieved from: https://www.vukuzenzele.gov.za/teen-farmer-makes-dad-proud Retrieved on 28-06-2025.&lt;/ref&gt;
* '''Sabelo Mdlalose:''' Nguye odosa phambili i-''Iqabungelihle Primary Cooperative'', utjala imirorho neenungo.&lt;ref&gt;Food and Trees for Africa (2021) ''Youth are the future of SA agriculture''. Retrieved from: https://trees.org.za/youth-are-the-future-of-sa-agriculture Retrieve on 28-06-2025.&lt;/ref&gt;
* '''Stanley Ntshangase:''' Umlimi onesivuno esincani ophumelele khulu ukutjala ikhabitjhi, amabhatata nesiphila begodu imikhiqizo yakhe uyithumela e-SPAR.&lt;ref&gt;Timbali Technologies (28 Nov 2023) ''Southern Africa small-scale farming success featuring individual success story'', PROAGRIMEDIA Retrieved from: https://www.proagrimedia.com/people/southern-africa-small-scale-farming-success-featuring-individual-success-story Retrieved on 28-06-2025.&lt;/ref&gt;

== Iinkhombo ==
&lt;references /&gt;


[[Umkhakha:Abalimi]]
[[Umkhakha:Ilutjha]]
[[Umkhakha:Umkhakha wezokulima]]</text>
      <sha1>ewwd1eh02tlhxbs5eg4g7ohg0ha4svb</sha1>
    </revision>
    <revision>
      <id>3563</id>
      <parentid>3562</parentid>
      <timestamp>2025-08-06T08:25:10Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <origin>3563</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6202" sha1="kcvidwuflc9yzgkebfvlr6xcfr952pd" xml:space="preserve">[[Isimumathi:Marcus Bai with PNG youth (10698164975).jpg|thumb|321x321px|Abantu abatjha bayalima]]
'''ESewula Afrika,''' abantu abatjha abakavami ukutholakala khulu kwezokulima, yeke sibalo esincani khulu sabantu abatjha abathuthukisa zokulima. Nanyana kunjalo kunomnyakazo owenzekako kwezokulima, njengokukhiqizwa kokudla, ukuthengiswa kokudla nokwehla komtlhago ezikweneli ngebanga lendima edlalwa babantu abatjha abambalwa, khulukhulu eendaweni zemakhaya. Kodwana kusesenesitjhijilo sokukara abantu abatjha ezikweneli, kuhlanganise nokungatholakali kuhle kwenarha yokutjala, iimali namakghono atlhogekako.&lt;ref&gt;Ongama Giwu, Lelethu Mdoda, Samuel S. Ntlanga, Olwethu Loki ( 08 Nov. 2024), ''Evaluating factors influencing youth participation in agricultural enterprises: Implications for food security and agribusiness,'' SAJEBSM website. Retrieved from: https://sajesbm.co.za/index.php/sajesbm/article/view/903/1130 Retrieved 28-06-2025.&lt;/ref&gt; 

Irhubululo litjengisa bona kunamaphesente ama-24 wabantu abatjha ababandakanyeke kezokulima, begodu bambalwa khulu abenza imali ngakho. Abatjha abamaphesente ama-23 nama-21 benza imali ngamaplasi begodu banamabubulo wabo. Abatjha abatjhadileko nalabo ababondlako emizinabo nabo baba nethando lokulima ngombana ekhaya kuyalinywa.&lt;ref&gt;The Water Wheel pamphlet (January-February 2022) ''Youth and Agriculture.''&lt;/ref&gt; 

== Iintjhijilo Abatjha Abaqalana Nazo Kezokulima ==
Nanzi iintjhijilo abantu abatjha abaqalene nazo ezikweni lezokulima:

# Ukungatholakali lula kwelwazi nefundo yezokulima. Lokhu kuhlanganisa ifundo namakghono wezokulima asezingeni eliphasi okungilo elinomthelela omkhulu ekungabini khona kwemikhiqizo yezokulima, bese lokhu kubangele ukungalingani nomtlhago enarheni. 
# Ukungatholakali kwenarha. Lokhu kumraro khulukhulu kabengubo abasesebatjha ngokwesiko labanzima abanganikelwa ilifa lenarha. Ngaphezu kwalokho bambalwa khulu abantu abatjha abakghona ukufumana imali-mbonelelo etholakalako yokuthenga inarha.
# Ukungatholakali lula kwemali nezenzelwa, kuhlanganise nemali-mboleko, imali ebulungwako netjhorensi etlhogekako bona kuthonyiswe ibubulo lokulima bekuthuthukise nemikhiqizo yakhona.
# Ubudisi bokutholakala kwemisebenzi ephathelene nezokulima engondla amaphilo wabantu abatjha isikhathi eside. 
# Ukungatholakali lula kwamamakethe okungathengiswa kiwo imikhiqizo yezokulima okumthelela weentolo ezikulu ezithengisa imikhiqizo yezokulima, ukungabibikho kwefundo, ibandulo nelwazi elaneleko ngokuthengisa imikhiqizo yokulima.
# Ukungatholakali lula kwamathuba wokubandakanyeka nakucociswana ngepholisi yezokulima. Lokho kutjho bona kunabantu imibono yabo engekhe izwakale, bese lokho kwenze abantu abatjha abathanda ukulima bangakutholi abakutlhogako.&lt;ref name=&quot;:0&quot;&gt;UNAI Hub for SDG2 News, (June 16, 2022) ''The youth are the future of the agricultural sector'', University of Pretoria website. Retrieved from: https://www.up.ac.za/unai-hub-for-sdg2/news/post_3082769-the-youth-are-the-future-of-the-agricultural-sector Retrieved on 28-06-2025.&lt;/ref&gt; 

== Indlela Iintjhijilwezi Ezingararululwa Ngayo ==

# Urhulumende kufuze wandise amahlelo wokwabelana ngelwazi nefundo yezokulima ukuze kutholakale ilwazi elaneleko ngezokulima. Amahlelo la angenziwa bese afundiswe abantu abatjha kusukela ebuncanini babo, okungasiza ekwakheni ithando lezokulima eenhliziyweni zabo. Kufuze kube namahlelo wokubandula abafundisi begodu eze neentlabagelo zokufundisa abantu abatjha ngezokulima nangendlela ukudla okukhiqizwa ngayo.&lt;ref name=&quot;:0&quot; /&gt;
# Urhulumende namabubulo azijameleko kufuze bafake imali ekuthuthukiseni ezokulima begodu bathuthukise nethekhnoloji yezokulima, bebasekele abantu abatjha abangenela umkhakha lo. Amaziko wezeemali nawo kufuze avulele abantu abatjha amathuba aneleko begodu kube bulula bona bawafumane.&lt;ref name=&quot;:0&quot; /&gt;
# Kunamahlelo nemithethokambiso eminengana kwarhulumende emalungana nokunikelwa kwenarha namkha ngemali yokuyithenga, kodwana amahlelo lawo akusibulula ukuwafumana. Yeke kufuze uthuthukise imithethokambiso yokutholakala kwenarha yokulima eSewula Afrika. Nanyana kunamahlelo nemithethokambiso eminengi emalungana nokwabiwa kwenarha yokulima, kusafuze enze kube bulula ukufumana amathuba lawo.&lt;ref&gt;South African Government website (2025), ''Land and agriculture.'' Retrieve from: https://www.gov.za/issues/land-and-agriculture Retrieved on 28-06-2025.&lt;/ref&gt; 

== Abatjha Abaphumelelako Kwezokulima ==

* '''Phikolomzi Qinisa Dlamini:''' Umphathi kwezokulima ekhamphanini i-''Ndela Farming'', wathola iziqu zakhe e-''Cedara College of Agriculture'' begodu ukhuthaza abantu abatjha bona balandelele khulu ifundo yezokulima.&lt;ref name=&quot;:1&quot;&gt;Nicole Ludolph (21st June 2022) ''Watch out, these young farmers are on fire!'', foodformzansi.co.za, Retrieved from: https://www.foodformzansi.co.za/watch-out-these-young-farmers-are-on-fire/ Retrieved on 28-08-2025.&lt;/ref&gt; 
* '''Keneilwe Raphesu:''' Uphethe ibubulo i-''Runs Mogalemone Farm'' banoyise begodu ukhuthaza nabanye bona bangenele zokulima.&lt;ref name=&quot;:1&quot; /&gt; 
* '''Thabo Herman Dithakgwe:''' Wathoma ibubulo elibizwa bona yi-''Ditha Farming, Wildlife and Projects''  aneminyaka eli-19.&lt;ref&gt;More Matshediso (2019)''Teen farmer makes dad proud'', Vuk'uzenzele website (2025).Retrieved from: https://www.vukuzenzele.gov.za/teen-farmer-makes-dad-proud Retrieved on 28-06-2025.&lt;/ref&gt;
* '''Sabelo Mdlalose:''' Nguye odosa phambili i-''Iqabungelihle Primary Cooperative'', utjala imirorho neenungo.&lt;ref&gt;Food and Trees for Africa (2021) ''Youth are the future of SA agriculture''. Retrieved from: https://trees.org.za/youth-are-the-future-of-sa-agriculture Retrieve on 28-06-2025.&lt;/ref&gt;
* '''Stanley Ntshangase:''' Umlimi onesivuno esincani ophumelele khulu ukutjala ikhabitjhi, amabhatata nesiphila begodu imikhiqizo yakhe uyithumela e-SPAR.&lt;ref&gt;Timbali Technologies (28 Nov 2023) ''Southern Africa small-scale farming success featuring individual success story'', PROAGRIMEDIA Retrieved from: https://www.proagrimedia.com/people/southern-africa-small-scale-farming-success-featuring-individual-success-story Retrieved on 28-06-2025.&lt;/ref&gt;

== Iinkhombo ==
&lt;references /&gt;


[[Umkhakha: Abalimi]]
[[Umkhakha: Ilutjha]]
[[Umkhakha: Umkhakha wezokulima]]</text>
      <sha1>kcvidwuflc9yzgkebfvlr6xcfr952pd</sha1>
    </revision>
    <revision>
      <id>3564</id>
      <parentid>3563</parentid>
      <timestamp>2025-08-06T08:25:46Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <origin>3564</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6199" sha1="eq06lq3hdp47o4x709p8u5lp909pfoq" xml:space="preserve">[[Isimumathi:Marcus Bai with PNG youth (10698164975).jpg|thumb|321x321px|Abantu abatjha bayalima]]
'''ESewula Afrika,''' abantu abatjha abakavami ukutholakala khulu kwezokulima, yeke sibalo esincani khulu sabantu abatjha abathuthukisa zokulima. Nanyana kunjalo kunomnyakazo owenzekako kwezokulima, njengokukhiqizwa kokudla, ukuthengiswa kokudla nokwehla komtlhago ezikweneli ngebanga lendima edlalwa babantu abatjha abambalwa, khulukhulu eendaweni zemakhaya. Kodwana kusesenesitjhijilo sokukara abantu abatjha ezikweneli, kuhlanganise nokungatholakali kuhle kwenarha yokutjala, iimali namakghono atlhogekako.&lt;ref&gt;Ongama Giwu, Lelethu Mdoda, Samuel S. Ntlanga, Olwethu Loki ( 08 Nov. 2024), ''Evaluating factors influencing youth participation in agricultural enterprises: Implications for food security and agribusiness,'' SAJEBSM website. Retrieved from: https://sajesbm.co.za/index.php/sajesbm/article/view/903/1130 Retrieved 28-06-2025.&lt;/ref&gt; 

Irhubululo litjengisa bona kunamaphesente ama-24 wabantu abatjha ababandakanyeke kezokulima, begodu bambalwa khulu abenza imali ngakho. Abatjha abamaphesente ama-23 nama-21 benza imali ngamaplasi begodu banamabubulo wabo. Abatjha abatjhadileko nalabo ababondlako emizinabo nabo baba nethando lokulima ngombana ekhaya kuyalinywa.&lt;ref&gt;The Water Wheel pamphlet (January-February 2022) ''Youth and Agriculture.''&lt;/ref&gt; 

== Iintjhijilo Abatjha Abaqalana Nazo Kezokulima ==
Nanzi iintjhijilo abantu abatjha abaqalene nazo ezikweni lezokulima:

# Ukungatholakali lula kwelwazi nefundo yezokulima. Lokhu kuhlanganisa ifundo namakghono wezokulima asezingeni eliphasi okungilo elinomthelela omkhulu ekungabini khona kwemikhiqizo yezokulima, bese lokhu kubangele ukungalingani nomtlhago enarheni. 
# Ukungatholakali kwenarha. Lokhu kumraro khulukhulu kabengubo abasesebatjha ngokwesiko labanzima abanganikelwa ilifa lenarha. Ngaphezu kwalokho bambalwa khulu abantu abatjha abakghona ukufumana imali-mbonelelo etholakalako yokuthenga inarha.
# Ukungatholakali lula kwemali nezenzelwa, kuhlanganise nemali-mboleko, imali ebulungwako netjhorensi etlhogekako bona kuthonyiswe ibubulo lokulima bekuthuthukise nemikhiqizo yakhona.
# Ubudisi bokutholakala kwemisebenzi ephathelene nezokulima engondla amaphilo wabantu abatjha isikhathi eside. 
# Ukungatholakali lula kwamamakethe okungathengiswa kiwo imikhiqizo yezokulima okumthelela weentolo ezikulu ezithengisa imikhiqizo yezokulima, ukungabibikho kwefundo, ibandulo nelwazi elaneleko ngokuthengisa imikhiqizo yokulima.
# Ukungatholakali lula kwamathuba wokubandakanyeka nakucociswana ngepholisi yezokulima. Lokho kutjho bona kunabantu imibono yabo engekhe izwakale, bese lokho kwenze abantu abatjha abathanda ukulima bangakutholi abakutlhogako.&lt;ref name=&quot;:0&quot;&gt;UNAI Hub for SDG2 News, (June 16, 2022) ''The youth are the future of the agricultural sector'', University of Pretoria website. Retrieved from: https://www.up.ac.za/unai-hub-for-sdg2/news/post_3082769-the-youth-are-the-future-of-the-agricultural-sector Retrieved on 28-06-2025.&lt;/ref&gt; 

== Indlela Iintjhijilwezi Ezingararululwa Ngayo ==

# Urhulumende kufuze wandise amahlelo wokwabelana ngelwazi nefundo yezokulima ukuze kutholakale ilwazi elaneleko ngezokulima. Amahlelo la angenziwa bese afundiswe abantu abatjha kusukela ebuncanini babo, okungasiza ekwakheni ithando lezokulima eenhliziyweni zabo. Kufuze kube namahlelo wokubandula abafundisi begodu eze neentlabagelo zokufundisa abantu abatjha ngezokulima nangendlela ukudla okukhiqizwa ngayo.&lt;ref name=&quot;:0&quot; /&gt;
# Urhulumende namabubulo azijameleko kufuze bafake imali ekuthuthukiseni ezokulima begodu bathuthukise nethekhnoloji yezokulima, bebasekele abantu abatjha abangenela umkhakha lo. Amaziko wezeemali nawo kufuze avulele abantu abatjha amathuba aneleko begodu kube bulula bona bawafumane.&lt;ref name=&quot;:0&quot; /&gt;
# Kunamahlelo nemithethokambiso eminengana kwarhulumende emalungana nokunikelwa kwenarha namkha ngemali yokuyithenga, kodwana amahlelo lawo akusibulula ukuwafumana. Yeke kufuze uthuthukise imithethokambiso yokutholakala kwenarha yokulima eSewula Afrika. Nanyana kunamahlelo nemithethokambiso eminengi emalungana nokwabiwa kwenarha yokulima, kusafuze enze kube bulula ukufumana amathuba lawo.&lt;ref&gt;South African Government website (2025), ''Land and agriculture.'' Retrieve from: https://www.gov.za/issues/land-and-agriculture Retrieved on 28-06-2025.&lt;/ref&gt; 

== Abatjha Abaphumelelako Kwezokulima ==

* '''Phikolomzi Qinisa Dlamini:''' Umphathi kwezokulima ekhamphanini i-''Ndela Farming'', wathola iziqu zakhe e-''Cedara College of Agriculture'' begodu ukhuthaza abantu abatjha bona balandelele khulu ifundo yezokulima.&lt;ref name=&quot;:1&quot;&gt;Nicole Ludolph (21st June 2022) ''Watch out, these young farmers are on fire!'', foodformzansi.co.za, Retrieved from: https://www.foodformzansi.co.za/watch-out-these-young-farmers-are-on-fire/ Retrieved on 28-08-2025.&lt;/ref&gt; 
* '''Keneilwe Raphesu:''' Uphethe ibubulo i-''Runs Mogalemone Farm'' banoyise begodu ukhuthaza nabanye bona bangenele zokulima.&lt;ref name=&quot;:1&quot; /&gt; 
* '''Thabo Herman Dithakgwe:''' Wathoma ibubulo elibizwa bona yi-''Ditha Farming, Wildlife and Projects''  aneminyaka eli-19.&lt;ref&gt;More Matshediso (2019)''Teen farmer makes dad proud'', Vuk'uzenzele website (2025).Retrieved from: https://www.vukuzenzele.gov.za/teen-farmer-makes-dad-proud Retrieved on 28-06-2025.&lt;/ref&gt;
* '''Sabelo Mdlalose:''' Nguye odosa phambili i-''Iqabungelihle Primary Cooperative'', utjala imirorho neenungo.&lt;ref&gt;Food and Trees for Africa (2021) ''Youth are the future of SA agriculture''. Retrieved from: https://trees.org.za/youth-are-the-future-of-sa-agriculture Retrieve on 28-06-2025.&lt;/ref&gt;
* '''Stanley Ntshangase:''' Umlimi onesivuno esincani ophumelele khulu ukutjala ikhabitjhi, amabhatata nesiphila begodu imikhiqizo yakhe uyithumela e-SPAR.&lt;ref&gt;Timbali Technologies (28 Nov 2023) ''Southern Africa small-scale farming success featuring individual success story'', PROAGRIMEDIA Retrieved from: https://www.proagrimedia.com/people/southern-africa-small-scale-farming-success-featuring-individual-success-story Retrieved on 28-06-2025.&lt;/ref&gt;

== Iinkhombo ==
&lt;references /&gt;


[[Category:Abalimi]]
[[Umkhakha:Ilutjha]]
[[Umkhakha:Umkhakha wezokulima]]</text>
      <sha1>eq06lq3hdp47o4x709p8u5lp909pfoq</sha1>
    </revision>
    <revision>
      <id>3565</id>
      <parentid>3564</parentid>
      <timestamp>2025-08-06T08:29:18Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <origin>3565</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6133" sha1="nfr7na2u0p3i9w0tir34rgxhgt3ffwr" xml:space="preserve">[[Isimumathi:Marcus Bai with PNG youth (10698164975).jpg|thumb|321x321px|Abantu abatjha bayalima]]
'''ESewula Afrika,''' abantu abatjha abakavami ukutholakala khulu kwezokulima, yeke sibalo esincani khulu sabantu abatjha abathuthukisa zokulima. Nanyana kunjalo kunomnyakazo owenzekako kwezokulima, njengokukhiqizwa kokudla, ukuthengiswa kokudla nokwehla komtlhago ezikweneli ngebanga lendima edlalwa babantu abatjha abambalwa, khulukhulu eendaweni zemakhaya. Kodwana kusesenesitjhijilo sokukara abantu abatjha ezikweneli, kuhlanganise nokungatholakali kuhle kwenarha yokutjala, iimali namakghono atlhogekako.&lt;ref&gt;Ongama Giwu, Lelethu Mdoda, Samuel S. Ntlanga, Olwethu Loki ( 08 Nov. 2024), ''Evaluating factors influencing youth participation in agricultural enterprises: Implications for food security and agribusiness,'' SAJEBSM website. Retrieved from: https://sajesbm.co.za/index.php/sajesbm/article/view/903/1130 Retrieved 28-06-2025.&lt;/ref&gt; 

Irhubululo litjengisa bona kunamaphesente ama-24 wabantu abatjha ababandakanyeke kezokulima, begodu bambalwa khulu abenza imali ngakho. Abatjha abamaphesente ama-23 nama-21 benza imali ngamaplasi begodu banamabubulo wabo. Abatjha abatjhadileko nalabo ababondlako emizinabo nabo baba nethando lokulima ngombana ekhaya kuyalinywa.&lt;ref&gt;The Water Wheel pamphlet (January-February 2022) ''Youth and Agriculture.''&lt;/ref&gt; 

== Iintjhijilo Abatjha Abaqalana Nazo Kezokulima ==
Nanzi iintjhijilo abantu abatjha abaqalene nazo ezikweni lezokulima:

# Ukungatholakali lula kwelwazi nefundo yezokulima. Lokhu kuhlanganisa ifundo namakghono wezokulima asezingeni eliphasi okungilo elinomthelela omkhulu ekungabini khona kwemikhiqizo yezokulima, bese lokhu kubangele ukungalingani nomtlhago enarheni. 
# Ukungatholakali kwenarha. Lokhu kumraro khulukhulu kabengubo abasesebatjha ngokwesiko labanzima abanganikelwa ilifa lenarha. Ngaphezu kwalokho bambalwa khulu abantu abatjha abakghona ukufumana imali-mbonelelo etholakalako yokuthenga inarha.
# Ukungatholakali lula kwemali nezenzelwa, kuhlanganise nemali-mboleko, imali ebulungwako netjhorensi etlhogekako bona kuthonyiswe ibubulo lokulima bekuthuthukise nemikhiqizo yakhona.
# Ubudisi bokutholakala kwemisebenzi ephathelene nezokulima engondla amaphilo wabantu abatjha isikhathi eside. 
# Ukungatholakali lula kwamamakethe okungathengiswa kiwo imikhiqizo yezokulima okumthelela weentolo ezikulu ezithengisa imikhiqizo yezokulima, ukungabibikho kwefundo, ibandulo nelwazi elaneleko ngokuthengisa imikhiqizo yokulima.
# Ukungatholakali lula kwamathuba wokubandakanyeka nakucociswana ngepholisi yezokulima. Lokho kutjho bona kunabantu imibono yabo engekhe izwakale, bese lokho kwenze abantu abatjha abathanda ukulima bangakutholi abakutlhogako.&lt;ref name=&quot;:0&quot;&gt;UNAI Hub for SDG2 News, (June 16, 2022) ''The youth are the future of the agricultural sector'', University of Pretoria website. Retrieved from: https://www.up.ac.za/unai-hub-for-sdg2/news/post_3082769-the-youth-are-the-future-of-the-agricultural-sector Retrieved on 28-06-2025.&lt;/ref&gt; 

== Indlela Iintjhijilwezi Ezingararululwa Ngayo ==

# Urhulumende kufuze wandise amahlelo wokwabelana ngelwazi nefundo yezokulima ukuze kutholakale ilwazi elaneleko ngezokulima. Amahlelo la angenziwa bese afundiswe abantu abatjha kusukela ebuncanini babo, okungasiza ekwakheni ithando lezokulima eenhliziyweni zabo. Kufuze kube namahlelo wokubandula abafundisi begodu eze neentlabagelo zokufundisa abantu abatjha ngezokulima nangendlela ukudla okukhiqizwa ngayo.&lt;ref name=&quot;:0&quot; /&gt;
# Urhulumende namabubulo azijameleko kufuze bafake imali ekuthuthukiseni ezokulima begodu bathuthukise nethekhnoloji yezokulima, bebasekele abantu abatjha abangenela umkhakha lo. Amaziko wezeemali nawo kufuze avulele abantu abatjha amathuba aneleko begodu kube bulula bona bawafumane.&lt;ref name=&quot;:0&quot; /&gt;
# Kunamahlelo nemithethokambiso eminengana kwarhulumende emalungana nokunikelwa kwenarha namkha ngemali yokuyithenga, kodwana amahlelo lawo akusibulula ukuwafumana. Yeke kufuze uthuthukise imithethokambiso yokutholakala kwenarha yokulima eSewula Afrika. Nanyana kunamahlelo nemithethokambiso eminengi emalungana nokwabiwa kwenarha yokulima, kusafuze enze kube bulula ukufumana amathuba lawo.&lt;ref&gt;South African Government website (2025), ''Land and agriculture.'' Retrieve from: https://www.gov.za/issues/land-and-agriculture Retrieved on 28-06-2025.&lt;/ref&gt; 

== Abatjha Abaphumelelako Kwezokulima ==

* '''Phikolomzi Qinisa Dlamini:''' Umphathi kwezokulima ekhamphanini i-''Ndela Farming'', wathola iziqu zakhe e-''Cedara College of Agriculture'' begodu ukhuthaza abantu abatjha bona balandelele khulu ifundo yezokulima.&lt;ref name=&quot;:1&quot;&gt;Nicole Ludolph (21st June 2022) ''Watch out, these young farmers are on fire!'', foodformzansi.co.za, Retrieved from: https://www.foodformzansi.co.za/watch-out-these-young-farmers-are-on-fire/ Retrieved on 28-08-2025.&lt;/ref&gt; 
* '''Keneilwe Raphesu:''' Uphethe ibubulo i-''Runs Mogalemone Farm'' banoyise begodu ukhuthaza nabanye bona bangenele zokulima.&lt;ref name=&quot;:1&quot; /&gt; 
* '''Thabo Herman Dithakgwe:''' Wathoma ibubulo elibizwa bona yi-''Ditha Farming, Wildlife and Projects''  aneminyaka eli-19.&lt;ref&gt;More Matshediso (2019)''Teen farmer makes dad proud'', Vuk'uzenzele website (2025).Retrieved from: https://www.vukuzenzele.gov.za/teen-farmer-makes-dad-proud Retrieved on 28-06-2025.&lt;/ref&gt;
* '''Sabelo Mdlalose:''' Nguye odosa phambili i-''Iqabungelihle Primary Cooperative'', utjala imirorho neenungo.&lt;ref&gt;Food and Trees for Africa (2021) ''Youth are the future of SA agriculture''. Retrieved from: https://trees.org.za/youth-are-the-future-of-sa-agriculture Retrieve on 28-06-2025.&lt;/ref&gt;
* '''Stanley Ntshangase:''' Umlimi onesivuno esincani ophumelele khulu ukutjala ikhabitjhi, amabhatata nesiphila begodu imikhiqizo yakhe uyithumela e-SPAR.&lt;ref&gt;Timbali Technologies (28 Nov 2023) ''Southern Africa small-scale farming success featuring individual success story'', PROAGRIMEDIA Retrieved from: https://www.proagrimedia.com/people/southern-africa-small-scale-farming-success-featuring-individual-success-story Retrieved on 28-06-2025.&lt;/ref&gt;

== Iinkhombo ==
&lt;references /&gt;[[Abalimi]]</text>
      <sha1>nfr7na2u0p3i9w0tir34rgxhgt3ffwr</sha1>
    </revision>
    <revision>
      <id>3566</id>
      <parentid>3565</parentid>
      <timestamp>2025-08-06T08:30:41Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <origin>3566</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6143" sha1="sclu0t092b56k7h02xspibeaz8dj4i7" xml:space="preserve">[[Isimumathi:Marcus Bai with PNG youth (10698164975).jpg|thumb|321x321px|Abantu abatjha bayalima]]
'''ESewula Afrika,''' abantu abatjha abakavami ukutholakala khulu kwezokulima, yeke sibalo esincani khulu sabantu abatjha abathuthukisa zokulima. Nanyana kunjalo kunomnyakazo owenzekako kwezokulima, njengokukhiqizwa kokudla, ukuthengiswa kokudla nokwehla komtlhago ezikweneli ngebanga lendima edlalwa babantu abatjha abambalwa, khulukhulu eendaweni zemakhaya. Kodwana kusesenesitjhijilo sokukara abantu abatjha ezikweneli, kuhlanganise nokungatholakali kuhle kwenarha yokutjala, iimali namakghono atlhogekako.&lt;ref&gt;Ongama Giwu, Lelethu Mdoda, Samuel S. Ntlanga, Olwethu Loki ( 08 Nov. 2024), ''Evaluating factors influencing youth participation in agricultural enterprises: Implications for food security and agribusiness,'' SAJEBSM website. Retrieved from: https://sajesbm.co.za/index.php/sajesbm/article/view/903/1130 Retrieved 28-06-2025.&lt;/ref&gt; 

Irhubululo litjengisa bona kunamaphesente ama-24 wabantu abatjha ababandakanyeke kezokulima, begodu bambalwa khulu abenza imali ngakho. Abatjha abamaphesente ama-23 nama-21 benza imali ngamaplasi begodu banamabubulo wabo. Abatjha abatjhadileko nalabo ababondlako emizinabo nabo baba nethando lokulima ngombana ekhaya kuyalinywa.&lt;ref&gt;The Water Wheel pamphlet (January-February 2022) ''Youth and Agriculture.''&lt;/ref&gt; 

== Iintjhijilo Abatjha Abaqalana Nazo Kezokulima ==
Nanzi iintjhijilo abantu abatjha abaqalene nazo ezikweni lezokulima:

# Ukungatholakali lula kwelwazi nefundo yezokulima. Lokhu kuhlanganisa ifundo namakghono wezokulima asezingeni eliphasi okungilo elinomthelela omkhulu ekungabini khona kwemikhiqizo yezokulima, bese lokhu kubangele ukungalingani nomtlhago enarheni. 
# Ukungatholakali kwenarha. Lokhu kumraro khulukhulu kabengubo abasesebatjha ngokwesiko labanzima abanganikelwa ilifa lenarha. Ngaphezu kwalokho bambalwa khulu abantu abatjha abakghona ukufumana imali-mbonelelo etholakalako yokuthenga inarha.
# Ukungatholakali lula kwemali nezenzelwa, kuhlanganise nemali-mboleko, imali ebulungwako netjhorensi etlhogekako bona kuthonyiswe ibubulo lokulima bekuthuthukise nemikhiqizo yakhona.
# Ubudisi bokutholakala kwemisebenzi ephathelene nezokulima engondla amaphilo wabantu abatjha isikhathi eside. 
# Ukungatholakali lula kwamamakethe okungathengiswa kiwo imikhiqizo yezokulima okumthelela weentolo ezikulu ezithengisa imikhiqizo yezokulima, ukungabibikho kwefundo, ibandulo nelwazi elaneleko ngokuthengisa imikhiqizo yokulima.
# Ukungatholakali lula kwamathuba wokubandakanyeka nakucociswana ngepholisi yezokulima. Lokho kutjho bona kunabantu imibono yabo engekhe izwakale, bese lokho kwenze abantu abatjha abathanda ukulima bangakutholi abakutlhogako.&lt;ref name=&quot;:0&quot;&gt;UNAI Hub for SDG2 News, (June 16, 2022) ''The youth are the future of the agricultural sector'', University of Pretoria website. Retrieved from: https://www.up.ac.za/unai-hub-for-sdg2/news/post_3082769-the-youth-are-the-future-of-the-agricultural-sector Retrieved on 28-06-2025.&lt;/ref&gt; 

== Indlela Iintjhijilwezi Ezingararululwa Ngayo ==

# Urhulumende kufuze wandise amahlelo wokwabelana ngelwazi nefundo yezokulima ukuze kutholakale ilwazi elaneleko ngezokulima. Amahlelo la angenziwa bese afundiswe abantu abatjha kusukela ebuncanini babo, okungasiza ekwakheni ithando lezokulima eenhliziyweni zabo. Kufuze kube namahlelo wokubandula abafundisi begodu eze neentlabagelo zokufundisa abantu abatjha ngezokulima nangendlela ukudla okukhiqizwa ngayo.&lt;ref name=&quot;:0&quot; /&gt;
# Urhulumende namabubulo azijameleko kufuze bafake imali ekuthuthukiseni ezokulima begodu bathuthukise nethekhnoloji yezokulima, bebasekele abantu abatjha abangenela umkhakha lo. Amaziko wezeemali nawo kufuze avulele abantu abatjha amathuba aneleko begodu kube bulula bona bawafumane.&lt;ref name=&quot;:0&quot; /&gt;
# Kunamahlelo nemithethokambiso eminengana kwarhulumende emalungana nokunikelwa kwenarha namkha ngemali yokuyithenga, kodwana amahlelo lawo akusibulula ukuwafumana. Yeke kufuze uthuthukise imithethokambiso yokutholakala kwenarha yokulima eSewula Afrika. Nanyana kunamahlelo nemithethokambiso eminengi emalungana nokwabiwa kwenarha yokulima, kusafuze enze kube bulula ukufumana amathuba lawo.&lt;ref&gt;South African Government website (2025), ''Land and agriculture.'' Retrieve from: https://www.gov.za/issues/land-and-agriculture Retrieved on 28-06-2025.&lt;/ref&gt; 

== Abatjha Abaphumelelako Kwezokulima ==

* '''Phikolomzi Qinisa Dlamini:''' Umphathi kwezokulima ekhamphanini i-''Ndela Farming'', wathola iziqu zakhe e-''Cedara College of Agriculture'' begodu ukhuthaza abantu abatjha bona balandelele khulu ifundo yezokulima.&lt;ref name=&quot;:1&quot;&gt;Nicole Ludolph (21st June 2022) ''Watch out, these young farmers are on fire!'', foodformzansi.co.za, Retrieved from: https://www.foodformzansi.co.za/watch-out-these-young-farmers-are-on-fire/ Retrieved on 28-08-2025.&lt;/ref&gt; 
* '''Keneilwe Raphesu:''' Uphethe ibubulo i-''Runs Mogalemone Farm'' banoyise begodu ukhuthaza nabanye bona bangenele zokulima.&lt;ref name=&quot;:1&quot; /&gt; 
* '''Thabo Herman Dithakgwe:''' Wathoma ibubulo elibizwa bona yi-''Ditha Farming, Wildlife and Projects''  aneminyaka eli-19.&lt;ref&gt;More Matshediso (2019)''Teen farmer makes dad proud'', Vuk'uzenzele website (2025).Retrieved from: https://www.vukuzenzele.gov.za/teen-farmer-makes-dad-proud Retrieved on 28-06-2025.&lt;/ref&gt;
* '''Sabelo Mdlalose:''' Nguye odosa phambili i-''Iqabungelihle Primary Cooperative'', utjala imirorho neenungo.&lt;ref&gt;Food and Trees for Africa (2021) ''Youth are the future of SA agriculture''. Retrieved from: https://trees.org.za/youth-are-the-future-of-sa-agriculture Retrieve on 28-06-2025.&lt;/ref&gt;
* '''Stanley Ntshangase:''' Umlimi onesivuno esincani ophumelele khulu ukutjala ikhabitjhi, amabhatata nesiphila begodu imikhiqizo yakhe uyithumela e-SPAR.&lt;ref&gt;Timbali Technologies (28 Nov 2023) ''Southern Africa small-scale farming success featuring individual success story'', PROAGRIMEDIA Retrieved from: https://www.proagrimedia.com/people/southern-africa-small-scale-farming-success-featuring-individual-success-story Retrieved on 28-06-2025.&lt;/ref&gt;

== Iinkhombo ==
&lt;references /&gt;[[:Category:Abalimi]]</text>
      <sha1>sclu0t092b56k7h02xspibeaz8dj4i7</sha1>
    </revision>
    <revision>
      <id>3567</id>
      <parentid>3566</parentid>
      <timestamp>2025-08-06T08:32:34Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <origin>3567</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6122" sha1="rt58acfgogga2avpdf98f5zlp9hvcpi" xml:space="preserve">[[Isimumathi:Marcus Bai with PNG youth (10698164975).jpg|thumb|321x321px|Abantu abatjha bayalima]]
'''ESewula Afrika,''' abantu abatjha abakavami ukutholakala khulu kwezokulima, yeke sibalo esincani khulu sabantu abatjha abathuthukisa zokulima. Nanyana kunjalo kunomnyakazo owenzekako kwezokulima, njengokukhiqizwa kokudla, ukuthengiswa kokudla nokwehla komtlhago ezikweneli ngebanga lendima edlalwa babantu abatjha abambalwa, khulukhulu eendaweni zemakhaya. Kodwana kusesenesitjhijilo sokukara abantu abatjha ezikweneli, kuhlanganise nokungatholakali kuhle kwenarha yokutjala, iimali namakghono atlhogekako.&lt;ref&gt;Ongama Giwu, Lelethu Mdoda, Samuel S. Ntlanga, Olwethu Loki ( 08 Nov. 2024), ''Evaluating factors influencing youth participation in agricultural enterprises: Implications for food security and agribusiness,'' SAJEBSM website. Retrieved from: https://sajesbm.co.za/index.php/sajesbm/article/view/903/1130 Retrieved 28-06-2025.&lt;/ref&gt; 

Irhubululo litjengisa bona kunamaphesente ama-24 wabantu abatjha ababandakanyeke kezokulima, begodu bambalwa khulu abenza imali ngakho. Abatjha abamaphesente ama-23 nama-21 benza imali ngamaplasi begodu banamabubulo wabo. Abatjha abatjhadileko nalabo ababondlako emizinabo nabo baba nethando lokulima ngombana ekhaya kuyalinywa.&lt;ref&gt;The Water Wheel pamphlet (January-February 2022) ''Youth and Agriculture.''&lt;/ref&gt; 

== Iintjhijilo Abatjha Abaqalana Nazo Kezokulima ==
Nanzi iintjhijilo abantu abatjha abaqalene nazo ezikweni lezokulima:

# Ukungatholakali lula kwelwazi nefundo yezokulima. Lokhu kuhlanganisa ifundo namakghono wezokulima asezingeni eliphasi okungilo elinomthelela omkhulu ekungabini khona kwemikhiqizo yezokulima, bese lokhu kubangele ukungalingani nomtlhago enarheni. 
# Ukungatholakali kwenarha. Lokhu kumraro khulukhulu kabengubo abasesebatjha ngokwesiko labanzima abanganikelwa ilifa lenarha. Ngaphezu kwalokho bambalwa khulu abantu abatjha abakghona ukufumana imali-mbonelelo etholakalako yokuthenga inarha.
# Ukungatholakali lula kwemali nezenzelwa, kuhlanganise nemali-mboleko, imali ebulungwako netjhorensi etlhogekako bona kuthonyiswe ibubulo lokulima bekuthuthukise nemikhiqizo yakhona.
# Ubudisi bokutholakala kwemisebenzi ephathelene nezokulima engondla amaphilo wabantu abatjha isikhathi eside. 
# Ukungatholakali lula kwamamakethe okungathengiswa kiwo imikhiqizo yezokulima okumthelela weentolo ezikulu ezithengisa imikhiqizo yezokulima, ukungabibikho kwefundo, ibandulo nelwazi elaneleko ngokuthengisa imikhiqizo yokulima.
# Ukungatholakali lula kwamathuba wokubandakanyeka nakucociswana ngepholisi yezokulima. Lokho kutjho bona kunabantu imibono yabo engekhe izwakale, bese lokho kwenze abantu abatjha abathanda ukulima bangakutholi abakutlhogako.&lt;ref name=&quot;:0&quot;&gt;UNAI Hub for SDG2 News, (June 16, 2022) ''The youth are the future of the agricultural sector'', University of Pretoria website. Retrieved from: https://www.up.ac.za/unai-hub-for-sdg2/news/post_3082769-the-youth-are-the-future-of-the-agricultural-sector Retrieved on 28-06-2025.&lt;/ref&gt; 

== Indlela Iintjhijilwezi Ezingararululwa Ngayo ==

# Urhulumende kufuze wandise amahlelo wokwabelana ngelwazi nefundo yezokulima ukuze kutholakale ilwazi elaneleko ngezokulima. Amahlelo la angenziwa bese afundiswe abantu abatjha kusukela ebuncanini babo, okungasiza ekwakheni ithando lezokulima eenhliziyweni zabo. Kufuze kube namahlelo wokubandula abafundisi begodu eze neentlabagelo zokufundisa abantu abatjha ngezokulima nangendlela ukudla okukhiqizwa ngayo.&lt;ref name=&quot;:0&quot; /&gt;
# Urhulumende namabubulo azijameleko kufuze bafake imali ekuthuthukiseni ezokulima begodu bathuthukise nethekhnoloji yezokulima, bebasekele abantu abatjha abangenela umkhakha lo. Amaziko wezeemali nawo kufuze avulele abantu abatjha amathuba aneleko begodu kube bulula bona bawafumane.&lt;ref name=&quot;:0&quot; /&gt;
# Kunamahlelo nemithethokambiso eminengana kwarhulumende emalungana nokunikelwa kwenarha namkha ngemali yokuyithenga, kodwana amahlelo lawo akusibulula ukuwafumana. Yeke kufuze uthuthukise imithethokambiso yokutholakala kwenarha yokulima eSewula Afrika. Nanyana kunamahlelo nemithethokambiso eminengi emalungana nokwabiwa kwenarha yokulima, kusafuze enze kube bulula ukufumana amathuba lawo.&lt;ref&gt;South African Government website (2025), ''Land and agriculture.'' Retrieve from: https://www.gov.za/issues/land-and-agriculture Retrieved on 28-06-2025.&lt;/ref&gt; 

== Abatjha Abaphumelelako Kwezokulima ==

* '''Phikolomzi Qinisa Dlamini:''' Umphathi kwezokulima ekhamphanini i-''Ndela Farming'', wathola iziqu zakhe e-''Cedara College of Agriculture'' begodu ukhuthaza abantu abatjha bona balandelele khulu ifundo yezokulima.&lt;ref name=&quot;:1&quot;&gt;Nicole Ludolph (21st June 2022) ''Watch out, these young farmers are on fire!'', foodformzansi.co.za, Retrieved from: https://www.foodformzansi.co.za/watch-out-these-young-farmers-are-on-fire/ Retrieved on 28-08-2025.&lt;/ref&gt; 
* '''Keneilwe Raphesu:''' Uphethe ibubulo i-''Runs Mogalemone Farm'' banoyise begodu ukhuthaza nabanye bona bangenele zokulima.&lt;ref name=&quot;:1&quot; /&gt; 
* '''Thabo Herman Dithakgwe:''' Wathoma ibubulo elibizwa bona yi-''Ditha Farming, Wildlife and Projects''  aneminyaka eli-19.&lt;ref&gt;More Matshediso (2019)''Teen farmer makes dad proud'', Vuk'uzenzele website (2025).Retrieved from: https://www.vukuzenzele.gov.za/teen-farmer-makes-dad-proud Retrieved on 28-06-2025.&lt;/ref&gt;
* '''Sabelo Mdlalose:''' Nguye odosa phambili i-''Iqabungelihle Primary Cooperative'', utjala imirorho neenungo.&lt;ref&gt;Food and Trees for Africa (2021) ''Youth are the future of SA agriculture''. Retrieved from: https://trees.org.za/youth-are-the-future-of-sa-agriculture Retrieve on 28-06-2025.&lt;/ref&gt;
* '''Stanley Ntshangase:''' Umlimi onesivuno esincani ophumelele khulu ukutjala ikhabitjhi, amabhatata nesiphila begodu imikhiqizo yakhe uyithumela e-SPAR.&lt;ref&gt;Timbali Technologies (28 Nov 2023) ''Southern Africa small-scale farming success featuring individual success story'', PROAGRIMEDIA Retrieved from: https://www.proagrimedia.com/people/southern-africa-small-scale-farming-success-featuring-individual-success-story Retrieved on 28-06-2025.&lt;/ref&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>rt58acfgogga2avpdf98f5zlp9hvcpi</sha1>
    </revision>
    <revision>
      <id>3568</id>
      <parentid>3567</parentid>
      <timestamp>2025-08-06T08:36:10Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <origin>3568</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6144" sha1="2q8hwfd6mmyz20p8fzwjbmr3adinabl" xml:space="preserve">[[Isimumathi:Marcus Bai with PNG youth (10698164975).jpg|thumb|321x321px|Abantu abatjha bayalima]]
'''ESewula Afrika,''' abantu abatjha abakavami ukutholakala khulu kwezokulima, yeke sibalo esincani khulu sabantu abatjha abathuthukisa zokulima. Nanyana kunjalo kunomnyakazo owenzekako kwezokulima, njengokukhiqizwa kokudla, ukuthengiswa kokudla nokwehla komtlhago ezikweneli ngebanga lendima edlalwa babantu abatjha abambalwa, khulukhulu eendaweni zemakhaya. Kodwana kusesenesitjhijilo sokukara abantu abatjha ezikweneli, kuhlanganise nokungatholakali kuhle kwenarha yokutjala, iimali namakghono atlhogekako.&lt;ref&gt;Ongama Giwu, Lelethu Mdoda, Samuel S. Ntlanga, Olwethu Loki ( 08 Nov. 2024), ''Evaluating factors influencing youth participation in agricultural enterprises: Implications for food security and agribusiness,'' SAJEBSM website. Retrieved from: https://sajesbm.co.za/index.php/sajesbm/article/view/903/1130 Retrieved 28-06-2025.&lt;/ref&gt; 

Irhubululo litjengisa bona kunamaphesente ama-24 wabantu abatjha ababandakanyeke kezokulima, begodu bambalwa khulu abenza imali ngakho. Abatjha abamaphesente ama-23 nama-21 benza imali ngamaplasi begodu banamabubulo wabo. Abatjha abatjhadileko nalabo ababondlako emizinabo nabo baba nethando lokulima ngombana ekhaya kuyalinywa.&lt;ref&gt;The Water Wheel pamphlet (January-February 2022) ''Youth and Agriculture.''&lt;/ref&gt; 

== Iintjhijilo Abatjha Abaqalana Nazo Kezokulima ==
Nanzi iintjhijilo abantu abatjha abaqalene nazo ezikweni lezokulima:

# Ukungatholakali lula kwelwazi nefundo yezokulima. Lokhu kuhlanganisa ifundo namakghono wezokulima asezingeni eliphasi okungilo elinomthelela omkhulu ekungabini khona kwemikhiqizo yezokulima, bese lokhu kubangele ukungalingani nomtlhago enarheni. 
# Ukungatholakali kwenarha. Lokhu kumraro khulukhulu kabengubo abasesebatjha ngokwesiko labanzima abanganikelwa ilifa lenarha. Ngaphezu kwalokho bambalwa khulu abantu abatjha abakghona ukufumana imali-mbonelelo etholakalako yokuthenga inarha.
# Ukungatholakali lula kwemali nezenzelwa, kuhlanganise nemali-mboleko, imali ebulungwako netjhorensi etlhogekako bona kuthonyiswe ibubulo lokulima bekuthuthukise nemikhiqizo yakhona.
# Ubudisi bokutholakala kwemisebenzi ephathelene nezokulima engondla amaphilo wabantu abatjha isikhathi eside. 
# Ukungatholakali lula kwamamakethe okungathengiswa kiwo imikhiqizo yezokulima okumthelela weentolo ezikulu ezithengisa imikhiqizo yezokulima, ukungabibikho kwefundo, ibandulo nelwazi elaneleko ngokuthengisa imikhiqizo yokulima.
# Ukungatholakali lula kwamathuba wokubandakanyeka nakucociswana ngepholisi yezokulima. Lokho kutjho bona kunabantu imibono yabo engekhe izwakale, bese lokho kwenze abantu abatjha abathanda ukulima bangakutholi abakutlhogako.&lt;ref name=&quot;:0&quot;&gt;UNAI Hub for SDG2 News, (June 16, 2022) ''The youth are the future of the agricultural sector'', University of Pretoria website. Retrieved from: https://www.up.ac.za/unai-hub-for-sdg2/news/post_3082769-the-youth-are-the-future-of-the-agricultural-sector Retrieved on 28-06-2025.&lt;/ref&gt; 

== Indlela Iintjhijilwezi Ezingararululwa Ngayo ==

# Urhulumende kufuze wandise amahlelo wokwabelana ngelwazi nefundo yezokulima ukuze kutholakale ilwazi elaneleko ngezokulima. Amahlelo la angenziwa bese afundiswe abantu abatjha kusukela ebuncanini babo, okungasiza ekwakheni ithando lezokulima eenhliziyweni zabo. Kufuze kube namahlelo wokubandula abafundisi begodu eze neentlabagelo zokufundisa abantu abatjha ngezokulima nangendlela ukudla okukhiqizwa ngayo.&lt;ref name=&quot;:0&quot; /&gt;
# Urhulumende namabubulo azijameleko kufuze bafake imali ekuthuthukiseni ezokulima begodu bathuthukise nethekhnoloji yezokulima, bebasekele abantu abatjha abangenela umkhakha lo. Amaziko wezeemali nawo kufuze avulele abantu abatjha amathuba aneleko begodu kube bulula bona bawafumane.&lt;ref name=&quot;:0&quot; /&gt;
# Kunamahlelo nemithethokambiso eminengana kwarhulumende emalungana nokunikelwa kwenarha namkha ngemali yokuyithenga, kodwana amahlelo lawo akusibulula ukuwafumana. Yeke kufuze uthuthukise imithethokambiso yokutholakala kwenarha yokulima eSewula Afrika. Nanyana kunamahlelo nemithethokambiso eminengi emalungana nokwabiwa kwenarha yokulima, kusafuze enze kube bulula ukufumana amathuba lawo.&lt;ref&gt;South African Government website (2025), ''Land and agriculture.'' Retrieve from: https://www.gov.za/issues/land-and-agriculture Retrieved on 28-06-2025.&lt;/ref&gt; 

== Abatjha Abaphumelelako Kwezokulima ==

* '''Phikolomzi Qinisa Dlamini:''' Umphathi kwezokulima ekhamphanini i-''Ndela Farming'', wathola iziqu zakhe e-''Cedara College of Agriculture'' begodu ukhuthaza abantu abatjha bona balandelele khulu ifundo yezokulima.&lt;ref name=&quot;:1&quot;&gt;Nicole Ludolph (21st June 2022) ''Watch out, these young farmers are on fire!'', foodformzansi.co.za, Retrieved from: https://www.foodformzansi.co.za/watch-out-these-young-farmers-are-on-fire/ Retrieved on 28-08-2025.&lt;/ref&gt; 
* '''Keneilwe Raphesu:''' Uphethe ibubulo i-''Runs Mogalemone Farm'' banoyise begodu ukhuthaza nabanye bona bangenele zokulima.&lt;ref name=&quot;:1&quot; /&gt; 
* '''Thabo Herman Dithakgwe:''' Wathoma ibubulo elibizwa bona yi-''Ditha Farming, Wildlife and Projects''  aneminyaka eli-19.&lt;ref&gt;More Matshediso (2019)''Teen farmer makes dad proud'', Vuk'uzenzele website (2025).Retrieved from: https://www.vukuzenzele.gov.za/teen-farmer-makes-dad-proud Retrieved on 28-06-2025.&lt;/ref&gt;
* '''Sabelo Mdlalose:''' Nguye odosa phambili i-''Iqabungelihle Primary Cooperative'', utjala imirorho neenungo.&lt;ref&gt;Food and Trees for Africa (2021) ''Youth are the future of SA agriculture''. Retrieved from: https://trees.org.za/youth-are-the-future-of-sa-agriculture Retrieve on 28-06-2025.&lt;/ref&gt;
* '''Stanley Ntshangase:''' Umlimi onesivuno esincani ophumelele khulu ukutjala ikhabitjhi, amabhatata nesiphila begodu imikhiqizo yakhe uyithumela e-SPAR.&lt;ref&gt;Timbali Technologies (28 Nov 2023) ''Southern Africa small-scale farming success featuring individual success story'', PROAGRIMEDIA Retrieved from: https://www.proagrimedia.com/people/southern-africa-small-scale-farming-success-featuring-individual-success-story Retrieved on 28-06-2025.&lt;/ref&gt;

== Iinkhombo ==
&lt;references /&gt;

[[Category:Abalimi]]</text>
      <sha1>2q8hwfd6mmyz20p8fzwjbmr3adinabl</sha1>
    </revision>
    <revision>
      <id>3569</id>
      <parentid>3568</parentid>
      <timestamp>2025-08-06T08:37:13Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <origin>3569</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6206" sha1="si9rtnnxtd35qyua8ajgba1d30yzmec" xml:space="preserve">[[Isimumathi:Marcus Bai with PNG youth (10698164975).jpg|thumb|321x321px|Abantu abatjha bayalima]]
'''ESewula Afrika,''' abantu abatjha abakavami ukutholakala khulu kwezokulima, yeke sibalo esincani khulu sabantu abatjha abathuthukisa zokulima. Nanyana kunjalo kunomnyakazo owenzekako kwezokulima, njengokukhiqizwa kokudla, ukuthengiswa kokudla nokwehla komtlhago ezikweneli ngebanga lendima edlalwa babantu abatjha abambalwa, khulukhulu eendaweni zemakhaya. Kodwana kusesenesitjhijilo sokukara abantu abatjha ezikweneli, kuhlanganise nokungatholakali kuhle kwenarha yokutjala, iimali namakghono atlhogekako.&lt;ref&gt;Ongama Giwu, Lelethu Mdoda, Samuel S. Ntlanga, Olwethu Loki ( 08 Nov. 2024), ''Evaluating factors influencing youth participation in agricultural enterprises: Implications for food security and agribusiness,'' SAJEBSM website. Retrieved from: https://sajesbm.co.za/index.php/sajesbm/article/view/903/1130 Retrieved 28-06-2025.&lt;/ref&gt; 

Irhubululo litjengisa bona kunamaphesente ama-24 wabantu abatjha ababandakanyeke kezokulima, begodu bambalwa khulu abenza imali ngakho. Abatjha abamaphesente ama-23 nama-21 benza imali ngamaplasi begodu banamabubulo wabo. Abatjha abatjhadileko nalabo ababondlako emizinabo nabo baba nethando lokulima ngombana ekhaya kuyalinywa.&lt;ref&gt;The Water Wheel pamphlet (January-February 2022) ''Youth and Agriculture.''&lt;/ref&gt; 

== Iintjhijilo Abatjha Abaqalana Nazo Kezokulima ==
Nanzi iintjhijilo abantu abatjha abaqalene nazo ezikweni lezokulima:

# Ukungatholakali lula kwelwazi nefundo yezokulima. Lokhu kuhlanganisa ifundo namakghono wezokulima asezingeni eliphasi okungilo elinomthelela omkhulu ekungabini khona kwemikhiqizo yezokulima, bese lokhu kubangele ukungalingani nomtlhago enarheni. 
# Ukungatholakali kwenarha. Lokhu kumraro khulukhulu kabengubo abasesebatjha ngokwesiko labanzima abanganikelwa ilifa lenarha. Ngaphezu kwalokho bambalwa khulu abantu abatjha abakghona ukufumana imali-mbonelelo etholakalako yokuthenga inarha.
# Ukungatholakali lula kwemali nezenzelwa, kuhlanganise nemali-mboleko, imali ebulungwako netjhorensi etlhogekako bona kuthonyiswe ibubulo lokulima bekuthuthukise nemikhiqizo yakhona.
# Ubudisi bokutholakala kwemisebenzi ephathelene nezokulima engondla amaphilo wabantu abatjha isikhathi eside. 
# Ukungatholakali lula kwamamakethe okungathengiswa kiwo imikhiqizo yezokulima okumthelela weentolo ezikulu ezithengisa imikhiqizo yezokulima, ukungabibikho kwefundo, ibandulo nelwazi elaneleko ngokuthengisa imikhiqizo yokulima.
# Ukungatholakali lula kwamathuba wokubandakanyeka nakucociswana ngepholisi yezokulima. Lokho kutjho bona kunabantu imibono yabo engekhe izwakale, bese lokho kwenze abantu abatjha abathanda ukulima bangakutholi abakutlhogako.&lt;ref name=&quot;:0&quot;&gt;UNAI Hub for SDG2 News, (June 16, 2022) ''The youth are the future of the agricultural sector'', University of Pretoria website. Retrieved from: https://www.up.ac.za/unai-hub-for-sdg2/news/post_3082769-the-youth-are-the-future-of-the-agricultural-sector Retrieved on 28-06-2025.&lt;/ref&gt; 

== Indlela Iintjhijilwezi Ezingararululwa Ngayo ==

# Urhulumende kufuze wandise amahlelo wokwabelana ngelwazi nefundo yezokulima ukuze kutholakale ilwazi elaneleko ngezokulima. Amahlelo la angenziwa bese afundiswe abantu abatjha kusukela ebuncanini babo, okungasiza ekwakheni ithando lezokulima eenhliziyweni zabo. Kufuze kube namahlelo wokubandula abafundisi begodu eze neentlabagelo zokufundisa abantu abatjha ngezokulima nangendlela ukudla okukhiqizwa ngayo.&lt;ref name=&quot;:0&quot; /&gt;
# Urhulumende namabubulo azijameleko kufuze bafake imali ekuthuthukiseni ezokulima begodu bathuthukise nethekhnoloji yezokulima, bebasekele abantu abatjha abangenela umkhakha lo. Amaziko wezeemali nawo kufuze avulele abantu abatjha amathuba aneleko begodu kube bulula bona bawafumane.&lt;ref name=&quot;:0&quot; /&gt;
# Kunamahlelo nemithethokambiso eminengana kwarhulumende emalungana nokunikelwa kwenarha namkha ngemali yokuyithenga, kodwana amahlelo lawo akusibulula ukuwafumana. Yeke kufuze uthuthukise imithethokambiso yokutholakala kwenarha yokulima eSewula Afrika. Nanyana kunamahlelo nemithethokambiso eminengi emalungana nokwabiwa kwenarha yokulima, kusafuze enze kube bulula ukufumana amathuba lawo.&lt;ref&gt;South African Government website (2025), ''Land and agriculture.'' Retrieve from: https://www.gov.za/issues/land-and-agriculture Retrieved on 28-06-2025.&lt;/ref&gt; 

== Abatjha Abaphumelelako Kwezokulima ==

* '''Phikolomzi Qinisa Dlamini:''' Umphathi kwezokulima ekhamphanini i-''Ndela Farming'', wathola iziqu zakhe e-''Cedara College of Agriculture'' begodu ukhuthaza abantu abatjha bona balandelele khulu ifundo yezokulima.&lt;ref name=&quot;:1&quot;&gt;Nicole Ludolph (21st June 2022) ''Watch out, these young farmers are on fire!'', foodformzansi.co.za, Retrieved from: https://www.foodformzansi.co.za/watch-out-these-young-farmers-are-on-fire/ Retrieved on 28-08-2025.&lt;/ref&gt; 
* '''Keneilwe Raphesu:''' Uphethe ibubulo i-''Runs Mogalemone Farm'' banoyise begodu ukhuthaza nabanye bona bangenele zokulima.&lt;ref name=&quot;:1&quot; /&gt; 
* '''Thabo Herman Dithakgwe:''' Wathoma ibubulo elibizwa bona yi-''Ditha Farming, Wildlife and Projects''  aneminyaka eli-19.&lt;ref&gt;More Matshediso (2019)''Teen farmer makes dad proud'', Vuk'uzenzele website (2025).Retrieved from: https://www.vukuzenzele.gov.za/teen-farmer-makes-dad-proud Retrieved on 28-06-2025.&lt;/ref&gt;
* '''Sabelo Mdlalose:''' Nguye odosa phambili i-''Iqabungelihle Primary Cooperative'', utjala imirorho neenungo.&lt;ref&gt;Food and Trees for Africa (2021) ''Youth are the future of SA agriculture''. Retrieved from: https://trees.org.za/youth-are-the-future-of-sa-agriculture Retrieve on 28-06-2025.&lt;/ref&gt;
* '''Stanley Ntshangase:''' Umlimi onesivuno esincani ophumelele khulu ukutjala ikhabitjhi, amabhatata nesiphila begodu imikhiqizo yakhe uyithumela e-SPAR.&lt;ref&gt;Timbali Technologies (28 Nov 2023) ''Southern Africa small-scale farming success featuring individual success story'', PROAGRIMEDIA Retrieved from: https://www.proagrimedia.com/people/southern-africa-small-scale-farming-success-featuring-individual-success-story Retrieved on 28-06-2025.&lt;/ref&gt;

== Iinkhombo ==
&lt;references /&gt;

[[Category:Abalimi]]
[[Category:Umkhakha wezokulima]]
[[Category:Abalimi abatjha]]</text>
      <sha1>si9rtnnxtd35qyua8ajgba1d30yzmec</sha1>
    </revision>
    <revision>
      <id>3570</id>
      <parentid>3569</parentid>
      <timestamp>2025-08-06T08:56:37Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <origin>3570</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6205" sha1="jwxaiwy7zf9gmcs0zwnjft7544wlmkx" xml:space="preserve">[[Isimumathi:Marcus Bai with PNG youth (10698164975).jpg|thumb|321x321px|Abantu abatjha bayalima]]
'''ESewula Afrika,''' abantu abatjha abakavami ukutholakala khulu kwezokulima, yeke sibalo esincani khulu sabantu abatjha abathuthukisa zokulima. Nanyana kunjalo kunomnyakazo owenzekako kwezokulima, njengokukhiqizwa kokudla, ukuthengiswa kokudla nokwehla komtlhago ezikweneli ngebanga lendima edlalwa babantu abatjha abambalwa, khulukhulu eendaweni zemakhaya. Kodwana kusesenesitjhijilo sokukara abantu abatjha ezikweneli, kuhlanganise nokungatholakali kuhle kwenarha yokutjala, iimali namakghono atlhogekako.&lt;ref&gt;Ongama Giwu, Lelethu Mdoda, Samuel S. Ntlanga, Olwethu Loki ( 08 Nov. 2024), ''Evaluating factors influencing youth participation in agricultural enterprises: Implications for food security and agribusiness,'' SAJEBSM website. Retrieved from: https://sajesbm.co.za/index.php/sajesbm/article/view/903/1130 Retrieved 28-06-2025.&lt;/ref&gt; 

Irhubululo litjengisa bona kunamaphesente ama-24 wabantu abatjha ababandakanyeke kezokulima, begodu bambalwa khulu abenza imali ngakho. Abatjha abamaphesente ama-23 nama-21 benza imali ngamaplasi begodu banamabubulo wabo. Abatjha abatjhadileko nalabo ababondlako emizinabo nabo baba nethando lokulima ngombana ekhaya kuyalinywa.&lt;ref&gt;The Water Wheel pamphlet (January-February 2022) ''Youth and Agriculture.''&lt;/ref&gt; 

== Iintjhijilo Abatjha Abaqalana Nazo Kezokulima ==
Nanzi iintjhijilo abantu abatjha abaqalene nazo ezikweni lezokulima:

# Ukungatholakali lula kwelwazi nefundo yezokulima. Lokhu kuhlanganisa ifundo namakghono wezokulima asezingeni eliphasi okungilo elinomthelela omkhulu ekungabini khona kwemikhiqizo yezokulima, bese lokhu kubangele ukungalingani nomtlhago enarheni. 
# Ukungatholakali kwenarha. Lokhu kumraro khulukhulu kabengubo abasesebatjha ngokwesiko labanzima abanganikelwa ilifa lenarha. Ngaphezu kwalokho bambalwa khulu abantu abatjha abakghona ukufumana imali-mbonelelo etholakalako yokuthenga inarha.
# Ukungatholakali lula kwemali nezenzelwa, kuhlanganise nemali-mboleko, imali ebulungwako netjhorensi etlhogekako bona kuthonyiswe ibubulo lokulima bekuthuthukise nemikhiqizo yakhona.
# Ubudisi bokutholakala kwemisebenzi ephathelene nezokulima engondla amaphilo wabantu abatjha isikhathi eside. 
# Ukungatholakali lula kwamamakethe okungathengiswa kiwo imikhiqizo yezokulima okumthelela weentolo ezikulu ezithengisa imikhiqizo yezokulima, ukungabibikho kwefundo, ibandulo nelwazi elaneleko ngokuthengisa imikhiqizo yokulima.
# Ukungatholakali lula kwamathuba wokubandakanyeka nakucociswana ngepholisi yezokulima. Lokho kutjho bona kunabantu imibono yabo engekhe izwakale, bese lokho kwenze abantu abatjha abathanda ukulima bangakutholi abakutlhogako.&lt;ref name=&quot;:0&quot;&gt;UNAI Hub for SDG2 News, (June 16, 2022) ''The youth are the future of the agricultural sector'', University of Pretoria website. Retrieved from: https://www.up.ac.za/unai-hub-for-sdg2/news/post_3082769-the-youth-are-the-future-of-the-agricultural-sector Retrieved on 28-06-2025.&lt;/ref&gt; 

== Indlela Iintjhijilwezi Ezingararululwa Ngayo ==

# Urhulumende kufuze wandise amahlelo wokwabelana ngelwazi nefundo yezokulima ukuze kutholakale ilwazi elaneleko ngezokulima. Amahlelo la angenziwa bese afundiswe abantu abatjha kusukela ebuncanini babo, okungasiza ekwakheni ithando lezokulima eenhliziyweni zabo. Kufuze kube namahlelo wokubandula abafundisi begodu eze neentlabagelo zokufundisa abantu abatjha ngezokulima nangendlela ukudla okukhiqizwa ngayo.&lt;ref name=&quot;:0&quot; /&gt;
# Urhulumende namabubulo azijameleko kufuze bafake imali ekuthuthukiseni ezokulima begodu bathuthukise nethekhnoloji yezokulima, bebasekele abantu abatjha abangenela umkhakha lo. Amaziko wezeemali nawo kufuze avulele abantu abatjha amathuba aneleko begodu kube bulula bona bawafumane.&lt;ref name=&quot;:0&quot; /&gt;
# Kunamahlelo nemithethokambiso eminengana kwarhulumende emalungana nokunikelwa kwenarha namkha ngemali yokuyithenga, kodwana amahlelo lawo akusibulula ukuwafumana. Yeke kufuze uthuthukise imithethokambiso yokutholakala kwenarha yokulima eSewula Afrika. Nanyana kunamahlelo nemithethokambiso eminengi emalungana nokwabiwa kwenarha yokulima, kusafuze enze kube bulula ukufumana amathuba lawo.&lt;ref&gt;South African Government website (2025), ''Land and agriculture.'' Retrieve from: https://www.gov.za/issues/land-and-agriculture Retrieved on 28-06-2025.&lt;/ref&gt; 

== Abatjha Abaphumelelako Kwezokulima ==

* '''Phikolomzi Qinisa Dlamini:''' Umphathi kwezokulima ekhamphanini i-''Ndela Farming'', wathola iziqu zakhe e-''Cedara College of Agriculture'' begodu ukhuthaza abantu abatjha bona balandelele khulu ifundo yezokulima.&lt;ref name=&quot;:1&quot;&gt;Nicole Ludolph (21st June 2022) ''Watch out, these young farmers are on fire!'', foodformzansi.co.za, Retrieved from: https://www.foodformzansi.co.za/watch-out-these-young-farmers-are-on-fire/ Retrieved on 28-08-2025.&lt;/ref&gt; 
* '''Keneilwe Raphesu:''' Uphethe ibubulo i-''Runs Mogalemone Farm'' banoyise begodu ukhuthaza nabanye bona bangenele zokulima.&lt;ref name=&quot;:1&quot; /&gt; 
* '''Thabo Herman Dithakgwe:''' Wathoma ibubulo elibizwa bona yi-''Ditha Farming, Wildlife and Projects''  aneminyaka eli-19.&lt;ref&gt;More Matshediso (2019)''Teen farmer makes dad proud'', Vuk'uzenzele website (2025).Retrieved from: https://www.vukuzenzele.gov.za/teen-farmer-makes-dad-proud Retrieved on 28-06-2025.&lt;/ref&gt;
* '''Sabelo Mdlalose:''' Nguye odosa phambili i-''Iqabungelihle Primary Cooperative'', utjala imirorho neenungo.&lt;ref&gt;Food and Trees for Africa (2021) ''Youth are the future of SA agriculture''. Retrieved from: https://trees.org.za/youth-are-the-future-of-sa-agriculture Retrieve on 28-06-2025.&lt;/ref&gt;
* '''Stanley Ntshangase:''' Umlimi onesivuno esincani ophumelele khulu ukutjala ikhabitjhi, amabhatata nesiphila begodu imikhiqizo yakhe uyithumela e-SPAR.&lt;ref&gt;Timbali Technologies (28 Nov 2023) ''Southern Africa small-scale farming success featuring individual success story'', PROAGRIMEDIA Retrieved from: https://www.proagrimedia.com/people/southern-africa-small-scale-farming-success-featuring-individual-success-story Retrieved on 28-06-2025.&lt;/ref&gt;

== Iinkhombo ==
&lt;references /&gt;

[[Category:Abalimi]]
[[Category:Abantu abatjha]]
[[Category:Umkhakha wezokulima]]</text>
      <sha1>jwxaiwy7zf9gmcs0zwnjft7544wlmkx</sha1>
    </revision>
    <revision>
      <id>6502</id>
      <parentid>3570</parentid>
      <timestamp>2026-05-16T21:58:53Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <origin>6502</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6169" sha1="5ztd2v1lbcbyngnai07vcd9a2ggrhag" xml:space="preserve">'''ESewula Afrika,''' abantu abatjha abakavami ukutholakala khulu kwezokulima. Yeke sibalo esincani khulu sabantu abatjha abathuthukisa zokulima. Nanyana kunjalo kunomnyakazo owenzekako kwezokulima, njengokukhiqizwa kokudla, ukuthengiswa kokudla nokwehla komtlhago ezikweneli ngebanga lendima edlalwa babantu abatjha abambalwa, khulukhulu eendaweni zemakhaya. Kodwana kusese nesitjhijilo esiliya abantu abatjha ezikweneli, kuhlanganise ungatholakali kuhle kwenarha yokutjala, iimali namakghono atlhogekako.&lt;ref&gt;Ongama Giwu, Lelethu Mdoda, Samuel S. Ntlanga, Olwethu Loki ( 08 Nov. 2024), ''Evaluating factors influencing youth participation in agricultural enterprises: Implications for food security and agribusiness,'' SAJEBSM website. Retrieved from: https://sajesbm.co.za/index.php/sajesbm/article/view/903/1130 Retrieved 28-06-2025.&lt;/ref&gt; 

Irhubululo litjengisa bona kunamaphesente ama-24 wabantu abatjha ababandakanyeke kezokulima, begodu bambalwa khulu abenza imali ngakho. Abatjha abamaphesente ama-23 nama-21 benza imali ngamaplasi begodu banamabubulo wabo. Abatjha abatjhadileko nalabo ababondlako emizinabo nabo baba nethando lokulima ngombana ekhaya kuyalinywa.&lt;ref&gt;The Water Wheel pamphlet (January-February 2022) ''Youth and Agriculture.''&lt;/ref&gt; 

== Iintjhijilo Abatjha Abaqalana Nazo Kezokulima ==
Iintjhijilo abantu abatjha abaqalene nazo ezikweni lezokulima:

# Ukungatholakali lula kwelwazi nefundo yezokulima. Lokhu kuhlanganisa ifundo namakghono wezokulima asezingeni eliphasi okungilo elinomthelela omkhulu ekungabini khona kwemikhiqizo yezokulima, bese lokhu kubangele ukungalingani nomtlhago enarheni. 
# Ukungatholakali kwenarha. Lokhu kumraro khulukhulu kabengubo abasesebatjha ngokwesiko labanzima abanganikelwa ilifa lenarha. Ngaphezu kwalokho, bambalwa khulu abantu abatjha abakghona ukufumana imalimbonelelo etholakalako yokuthenga inarha.
# Ukungatholakali lula kwemali nezenzelwa, kuhlanganise nemalimboleko, imali ebulungwako netjhorensi etlhogekako bona kuthonyiswe ibubulo lokulima bekuthuthukise nemikhiqizo yakhona.
# Ubudisi bokutholakala kwemisebenzi ephathelene nezokulima engondla amaphilo wabantu abatjha isikhathi eside. 
# Ukungatholakali lula kwamamakethe okungathengiswa kiwo imikhiqizo yezokulima okumthelela weentolo ezikulu ezithengisa imikhiqizo yezokulima, ukungabi khona kwefundo, ibandulo nelwazi elaneleko ngokuthengisa imikhiqizo yokulima.
# Ukungatholakali lula kwamathuba wokubandakanyeka nakucociswana ngepholisi yezokulima. Lokho kutjho bona kunabantu imibono yabo engekhe izwakale, bese lokho kwenze abantu abatjha abathanda ukulima bangakutholi abakutlhogako.&lt;ref name=&quot;:0&quot;&gt;UNAI Hub for SDG2 News, (June 16, 2022) ''The youth are the future of the agricultural sector'', University of Pretoria website. Retrieved from: https://www.up.ac.za/unai-hub-for-sdg2/news/post_3082769-the-youth-are-the-future-of-the-agricultural-sector Retrieved on 28-06-2025.&lt;/ref&gt; 

== Indlela Iintjhijilwezi Ezingararululwa Ngayo ==
Iindlela abantu abatjha abangazisebenzisa ukuqalana neentjhijilo zokulima:
# Urhulumende kufuze andise amahlelo wokwabelana ngelwazi nefundo yezokulima ukuze kutholakale ilwazi elaneleko ngezokulima. Amahlelo la angenziwa bese afundiswe abantu abatjha kusukela ebuncanini babo, okungasiza ekwakheni ithando lezokulima eenhliziyweni zabo. Kufuze kube namahlelo wokubandula abafundisi begodu eze neentlabagelo zokufundisa abantu abatjha ngezokulima nangendlela ukudla okukhiqizwa ngayo.&lt;ref name=&quot;:0&quot; /&gt;
# Urhulumende namabubulo azijameleko kufuze bafake imali ekuthuthukiseni zokulima begodu bathuthukise nethekhnoloji yezokulima, bebasekele abantu abatjha abangenela umkhakha lo. Amaziko wezeemali nawo kufuze avulele abantu abatjha amathuba aneleko begodu kube bulula bona bawafumane.&lt;ref name=&quot;:0&quot; /&gt;
# Kunamahlelo nemithethokambiso eminengana karhulumende emalungana nokunikelwa kwenarha namkha ngemali yokuyithenga, kodwana amahlelo lawo akusibulula ukuwafumana. Yeke kufuze kuthuthukiswe imithethokambiso yokutholakala kwenarha yokulima eSewula Afrika. Nanyana kunamahlelo nemithethokambiso eminengi emalungana nokwabiwa kwenarha yokulima, kusafuze enze kube bulula ukufumana amathuba lawo.&lt;ref&gt;South African Government website (2025), ''Land and agriculture.'' Retrieve from: https://www.gov.za/issues/land-and-agriculture Retrieved on 28-06-2025.&lt;/ref&gt; 

== Abatjha Abaphumelelako Kwezokulima ==

* '''Phikolomzi Qinisa Dlamini:''' Umphathi kwezokulima ekhamphanini i-Ndela ''Farming'', wathola iziqu zakhe e-''Cedara College of Agriculture'' begodu ukhuthaza abantu abatjha bona balandelele khulu ifundo yezokulima.&lt;ref name=&quot;:1&quot;&gt;Nicole Ludolph (21st June 2022) ''Watch out, these young farmers are on fire!'', foodformzansi.co.za, Retrieved from: https://www.foodformzansi.co.za/watch-out-these-young-farmers-are-on-fire/ Retrieved on 28-08-2025.&lt;/ref&gt; 
* '''Keneilwe Raphesu:''' Uphethe ibubulo i-''Runs Mogalemone Farm'' banoyise begodu ukhuthaza nabanye bona bangenele zokulima.&lt;ref name=&quot;:1&quot; /&gt; 
* '''Thabo Herman Dithakgwe:''' Wathoma ibubulo elibizwa bona yi-''Ditha Farming, Wildlife and Projects'' aneminyaka eli-19.&lt;ref&gt;More Matshediso (2019)''Teen farmer makes dad proud'', Vuk'uzenzele website (2025).Retrieved from: https://www.vukuzenzele.gov.za/teen-farmer-makes-dad-proud Retrieved on 28-06-2025.&lt;/ref&gt;
* '''Sabelo Mdlalose:''' Nguye odosa phambili i-''Iqabungelihle Primary Cooperative'', utjala imirorho neenungo.&lt;ref&gt;Food and Trees for Africa (2021) ''Youth are the future of SA agriculture''. Retrieved from: https://trees.org.za/youth-are-the-future-of-sa-agriculture Retrieve on 28-06-2025.&lt;/ref&gt;
* '''Stanley Ntshangase:''' Umlimi onesivuno esincani ophumelele khulu ukutjala ikhabitjhi, amabhatata nesiphila begodu imikhiqizo yakhe uyithumela e-SPAR.&lt;ref&gt;Timbali Technologies (28 Nov 2023) ''Southern Africa small-scale farming success featuring individual success story'', PROAGRIMEDIA Retrieved from: https://www.proagrimedia.com/people/southern-africa-small-scale-farming-success-featuring-individual-success-story Retrieved on 28-06-2025.&lt;/ref&gt;

== Iinkhombo ==
&lt;references /&gt;

[[Category:Abalimi]]
[[Category:Abantu abatjha]]
[[Category:Umkhakha wezokulima]]</text>
      <sha1>5ztd2v1lbcbyngnai07vcd9a2ggrhag</sha1>
    </revision>
  </page>
  <page>
    <title>Naledi Chirwa</title>
    <ns>0</ns>
    <id>660</id>
    <revision>
      <id>3254</id>
      <timestamp>2025-06-29T13:59:10Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1293434310|Naledi Chirwa]]&quot;</comment>
      <origin>3254</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="16034" sha1="9jqvomkk38w7hd92wutoxxe4ijv4m26" xml:space="preserve">
{{Infobox officeholder|honorific-prefix=|name=Naledi Chirwa|native_name=|native_name_lang=|honorific-suffix=[[Parliament of South Africa|MP]]|image=Naledi Chirwa, 2024 (cropped).jpg|image_size=|smallimage=&lt;!--If this is specified, &quot;image&quot; should not be.--&gt;|alt=|caption=Chirwa in 2024|office=[[National Council of Provinces|Permanent Delegate to the National Council of Provinces]]|status=|term_start=15 June 2024|term_end=|predecessor=|successor=|birthname=Naledi Nokukhanya Chirwa|birth_date={{birth date and age|1993|07|22|df=y}}|birth_place=[[Vosloorus]], [[East Rand]]&lt;br /&gt; [[Transvaal Province|Transvaal]], [[South Africa]]|death_date=|death_place=|citizenship=|nationality=[[South Africa]]n|party=[[Economic Freedom Fighters]] {{small|(2015–present)}}|otherparty=|spouse=|partner=&lt;!--For those with a domestic partner and not married--&gt;|relations=|children=2|residence=|education=|alma_mater=[[University of Pretoria]]|occupation=Member of Parliament|profession=Politician|known_for=|committees=|portfolio=|awards=|website=|honorific_prefix=[[The Honourable]]|termend1=21 May 2024|termstart1=22 May 2019|office1=[[National Assembly of South Africa|Member of the National Assembly]]|constituency_AM=}}

'''UNaledi Nokukhanya Chirwa-Mpungose''' wabelethwa mhlana amalanga ama-22 kuNtaka ngomnyaka we-1993. Ungusopolotiki weSewula Afrika begodu gade amlweli wabafundi wesifunda se -Gauteng . Ujamele i -Economic Freedom Fighters (EFF) e- National Assembly . UChirwa bekalilunga le- National Assembly ukusukela ngenyanga kaMrhayili ngomnyaka wee-2019 ukuya enyangeni kaMgwengweni ngomnyaka wee-2024. Uhlale isikhathi esifitjhani eKhanseleni yeNarha yamaPhrovinsi ngaphambi kobana athunyelwe e -National Assembly ukuze athathe isikhundla  sakaMbuyiseni Ndlozi . Ukukhula nokuduma kwakhe kubangwe kuzibandakanya nabafundi be-#FeesMustFall e- University of Pretoria ukusukela ngomnyaka wee-2015 ukuya emnyakeni wee-2016.

== Ipilo yokuthoma nefundo ==
U-Chirwa wabelethwa mhlana amalanga ama-22 kuNtaka emnyakeni we-1993 e- [[Vosloorus]], e-East Rand, e- Gauteng . &lt;ref name=&quot;SunWorld&quot;&gt;https://www.sowetanlive.co.za/sundayworld/news/2019-06-04-naledi-chirwa-voice-of-the-voiceless/&lt;/ref&gt; Ekukhuleni kwakhe ukhuliswa ngugogwakhe e -Mamelodi, e-Pitoli . &lt;ref name=&quot;SunWorld&quot; /&gt; phezu komnyaka wee-2009, uthe lokha nakaneminyaka ema-15, wasebenza njengomsekeli kamongameli we-Tshwane North College (TNC) Further Education &amp; Training (FET), manje i-TNC TVET. &lt;ref name=&quot;SunWorld&quot; /&gt;

U-Chirwa wafunyana iziqu ze -Bachelor of Arts kanye neziqu ze- Honors degree kuDrama and Film Studies e- University of Pretoria . Ukusukela ngomnyaka wee-2019 bekafunda i -Master of Arts ku-Theatre and Performance e- University of the Witwatersrand . &lt;ref&gt;{{cite web|title=Ms Naledi Nokukhanya Chirwa|url=https://www.parliament.gov.za/person-details/36|website=Parliament of South Africa|access-date=19 June 2021}}https://www.parliament.gov.za/person-details/36&lt;/ref&gt;

== Umlweli wabafundi ==
U-Chirwa waba lilunga le -Economic Freedom Fighters (EFF) ngomnyaka wee-2015 begodu waba godu lilunga le-Student Command yehlangano e-University of Pretoria. Wabuya wakhethwa bewabekwa njengesikhulu sezokuthintana somlawuli. &lt;ref name=&quot;SunWorld&quot;&gt;{{cite news|last1=Zwane|first1=Nokuthula|title=Naledi Chirwa: Voice of the voiceless|url=https://www.sowetanlive.co.za/sundayworld/news/2019-06-04-naledi-chirwa-voice-of-the-voiceless/|access-date=13 April 2020|newspaper=Sunday World|date=4 June 2019}}https://nr.wikipedia.org/wiki/Special:ContentTranslation?from=en&amp;to=nr&amp;page=Naledi+Chirwa&lt;/ref&gt; Ngenyanga kaRhoboyi ngomnyaka wee-2016, ngesikhathi umongameli wenarha wangaphambilini u-Jacob Zuma akhuluma esikhungweni sekhetho se-IEC ngemva kokhetho lukamasipala wango-2016, u-Chirwa nabanye abafundi ababe babathathu baphazamisa ikulumo kamongameli ngesikhathi baphakamise amatshwayo athi &quot;Khanga&quot;, &quot;Khumbula u-Khwezi &quot;, &quot;Ngingu-1 kwaba-3&quot; kanye nokuthi &quot;emva kweminyaka ema-10 &quot;, ngokukhamba kwesikhathi ngokutjho uZuma ukudlwengula phakathi kwabo-2000. &lt;ref&gt;{{cite news|last1=Makhubu|first1=Ntando|title=Woman in Zuma #Khwezi protest speaks out|url=https://www.iol.co.za/news/politics/woman-in-zuma-khwezi-protest-speaks-out-2054518|access-date=13 April 2020|newspaper=IOL|date=8 Aug 2016}}https://www.iol.co.za/news/politics/woman-in-zuma-khwezi-protest-speaks-out-2054518&lt;/ref&gt; &lt;ref&gt;{{cite news|last1=Ngoepe|first1=Karabo|title=Anti-rape protesters disrupt Zuma's speech|url=https://www.news24.com/news24/elections/news/anti-rape-protesters-disrupt-zumas-speech-20160806|access-date=10 September 2020|newspaper=News24|date=6 August 2016|location=Pretoria}}https://www.news24.com/news24/elections/news/anti-rape-protesters-disrupt-zumas-speech-20160806&lt;/ref&gt;

Godu ngomnyaka wee-2016, u-Chirwa bekabandakanyeka emigurugurwini wabafundi ephathelene nomnyakazo we- #FeesMustFall . Ekukhambeni kwesikhathi wabotjhwa begodu wajanyiswa ekhampasini njengomunye wemibandela webheyili yakhe. &lt;ref&gt;{{cite news|last1=Madibogo|first1=Julia|title=Who is Naledi Chirwa - Drama student‚ Zuma tormentor‚ EFF student leader and fees must fall campaigner|url=https://www.timeslive.co.za/politics/2016-10-19-who-is-naledi-chirwa-drama-student-zuma-tormentor-eff-student-leader-and-fees-must-fall-campaigner/|access-date=13 April 2020|newspaper=TimesLIVE|date=19 October 2016}}https://www.timeslive.co.za/politics/2016-10-19-who-is-naledi-chirwa-drama-student-zuma-tormentor-eff-student-leader-and-fees-must-fall-campaigner/&lt;/ref&gt; Ngomnyaka wee-2017, bekangomunye wabantu abatjha abama-200 be-Mail &amp;amp;amp; Guardian . &lt;ref&gt;{{cite news|last1=Maputla|first1=Tswelopele|title=#BlackGirlMagic: These female parliamentarians are only in their 20s|url=https://www.sowetanlive.co.za/s-mag/2019-05-23-blackgirlmagic-these-female-parliamentarians-are-only-in-their-20s/|access-date=10 September 2020|newspaper=SowetanLIVE|date=23 May 2019}}https://www.sowetanlive.co.za/s-mag/2019-05-23-blackgirlmagic-these-female-parliamentarians-are-only-in-their-20s/&lt;/ref&gt;

== Umsebenzi wePalamende ==

=== UmHlangano weNarha: 2019–2024 ===
Ngokhetho lukaMeyi 2019, wakhethelwa i -National Assembly of South Africa begodu waba lilunga lePalamende elincani khulu le-EFF. Wafungiswa kanye nabanye abafundi abalwelako, okufakahlangana u-Peter Keetse, u-Nompendulo Mkhatshwa no -Vuyani Pambo . &lt;ref&gt;{{cite news|last1=Bhengu|first1=Cebelihle|title=Power to the new generation: three young MPs you need to know|url=https://www.timeslive.co.za/politics/2019-05-22-power-to-the-new-generation-three-young-mps-you-need-to-know/|access-date=13 April 2020|newspaper=TimesLIVE|date=22 May 2019}}https://www.sowetanlive.co.za/sundayworld/news/2019-06-04-naledi-chirwa-voice-of-the-voiceless/&lt;/ref&gt; Bekalilunga leKomidi yePhothifoliyo yePalamende yezePilo . &lt;ref&gt;{{cite web|title=Portfolio Committee on Health - Parliament of South Africa|url=https://www.parliament.gov.za/committee-details/147|access-date=6 December 2020|website=Parliament of South Africa}}https://www.parliament.gov.za/committee-details/147&lt;/ref&gt;

Mhlazana amalanga ama-25 kuMgwengweni ngomnyaka wee-2019, wethula ikulumo yakhe yokuthoma ngesikhathi sokuphikisana ngeKulumo yeNarha . Wakatelelwa bona arhoqise ukuphawula kwakhe malungana nokuthi urhulumende ubandakanyeka ekubulaweni kwabasekeli be-#FeesMustFall. &lt;ref&gt;{{cite news|last1=Gerber|first1=Jan|title=EFF's Chirwa forced to withdraw remark that government was complicit in 'brutal murders' of Fees Must Fall activists|url=https://www.news24.com/news24/southafrica/news/effs-chirwa-forced-to-withdraw-remark-that-government-was-complicit-in-brutal-murders-of-fees-must-fall-activists-20190625|access-date=6 December 2020|newspaper=News24|date=25 June 2019}}https://www.news24.com/news24/southafrica/news/effs-chirwa-forced-to-withdraw-remark-that-government-was-complicit-in-brutal-murders-of-fees-must-fall-activists-20190625&lt;/ref&gt; &lt;ref&gt;{{cite news|last1=Davis|first1=Gaye|title=Sona debate: EFF's Chirwa forced to withdraw Ramaphosa comments in maiden speech|url=https://ewn.co.za/2019/06/25/sona-debate-eff-s-chirwa-forced-to-withdraw-ramaphosa-comments-in-maiden-speech|access-date=6 December 2020|newspaper=Eyewitness News|date=25 June 2019|location=Cape Town}}https://ewn.co.za/2019/06/25/sona-debate-eff-s-chirwa-forced-to-withdraw-ramaphosa-comments-in-maiden-speech&lt;/ref&gt; NgoTjhirhweni 2022, waduma ekundleni yokuthintana eyayibizwa bona yi-Twitter ngokubiza uMongameli u-Cyril Ramaphosa ngokuthi &quot;akanamazinyo&quot; begodu &quot;msana omncani obuthakathaka&quot;. &lt;ref&gt;{{Cite web|date=18 January 2022|title=The EFF’s 28-year-old Naledi Chirwa called Cyril Ramaphosa a ‘weak little boy’ and now Twitter is divided|url=https://www.iol.co.za/news/south-africa/gauteng/the-effs-28-year-old-naledi-chirwa-called-cyril-ramaphosa-a-weak-little-boy-and-now-twitter-is-divided-a82c6721-1b4e-4291-a36f-204b69e810ba|access-date=2022-01-19|website=IOL|language=en}}https://www.iol.co.za/news/south-africa/gauteng/the-effs-28-year-old-naledi-chirwa-called-cyril-ramaphosa-a-weak-little-boy-and-now-twitter-is-divided-a82c6721-1b4e-4291-a36f-204b69e810ba&lt;/ref&gt;

Ukusukela lapha ngomnyaka wee-2020, u-Chirwa wahlaselwa eenkundleni zokuthintana basebenzisi abangaziwako ebebatjho ngaphandle kobufakazi ukuthi usisakhamuzi se [[Malawi|-Malawi]] begodu umndenakhe ufumene ubuzwe beSewula Afrika ngokukhohlisa. &lt;ref&gt;{{Cite news|date=9 March 2020|title=Twitter storm after EFF MP Naledi Chirwa's nationality questioned|url=https://www.iol.co.za/news/politics/twitter-storm-after-eff-mp-naledi-chirwas-nationality-questioned-44418095|access-date=16 June 2024|work=IOL}}https://www.iol.co.za/news/politics/twitter-storm-after-eff-mp-naledi-chirwas-nationality-questioned-44418095&lt;/ref&gt; NgoTjhirhweni 2022, waphendula iinsolwezo ngokuthumela ku-Twitter wathi : &quot;Ningaleya amala ngobuzwe bami bekube kulapho niphenduka nibe hlaza amahlalo. Angeze amala wenu aba liqiniso begodu angeze kwangenza ngithule. Azange ngilithenge iphimbo lami. Angiliqatjhisi. Ngizokuhlala ngikhuluma begodu ayikho into eningayenza ngalokho.&quot; &lt;ref&gt;{{Cite web|date=19 January 2022|title=Naledi Chirwa hits back at critics: ‘You can lie about my nationality until you turn green in the buttocks’|url=https://www.timeslive.co.za/politics/2022-01-19-naledi-chirwa-hits-back-at-critics-you-can-lie-about-my-nationality-until-you-turn-green-in-the-buttocks/|access-date=2022-01-19|website=Sunday Times|language=en-ZA}}https://www.timeslive.co.za/politics/2022-01-19-naledi-chirwa-hits-back-at-critics-you-can-lie-about-my-nationality-until-you-turn-green-in-the-buttocks/&lt;/ref&gt;

Ngenyanga kaNtaka 2024, u-Chirwa bekangekho emakhethweni wepalamende ukwenzela bona atlhogomele umntwanakhe ogolako. I-EFF yamhlawulisa begodu yamyalela bona aqolise. &lt;ref&gt;{{Cite web|date=5 March 2024|title=Stir as EFF MP Naledi Chirwa fined and made to apologise for missing parliament due to sick baby|url=https://www.timeslive.co.za/politics/2024-03-05-stir-as-eff-mp-naledi-chirwa-fined-and-made-to-apologise-for-missing-parliament-due-to-sick-baby/|access-date=2024-06-16|website=Sunday Times|language=en-ZA}}https://www.timeslive.co.za/politics/2024-03-05-stir-as-eff-mp-naledi-chirwa-fined-and-made-to-apologise-for-missing-parliament-due-to-sick-baby/&lt;/ref&gt; &lt;ref&gt;{{Cite web|last=Ntombela|first=Nomzamo Portia|date=11 March 2024|title=Naledi Chirwa's apology a disturbing reminder of patriarchy in politics|url=https://www.ewn.co.za/2024/03/11/nomzamo-ntombela-naledi-chirwas-apology-a-disturbing-reminder-of-patriarchy-in-politics|access-date=2024-03-27|website=EWN|language=en}}https://www.ewn.co.za/2024/03/11/nomzamo-ntombela-naledi-chirwas-apology-a-disturbing-reminder-of-patriarchy-in-politics&lt;/ref&gt; Msinyana ngemva kwalokho, i-EFF yakhupha irhelo layo labakhethiweko bekhetho elizako, ebelibeka u-Chirwa endaweni yokugcina. &lt;ref&gt;{{Cite web|date=27 March 2024|title=From 30 to 200: Naledi Chirwa last on EFF list after Malema’s cold shoulder to her apology letter|url=https://www.timeslive.co.za/politics/2024-03-27-from-30-to-200-naledi-chirwa-last-on-eff-list-after-malemas-cold-shoulder-to-her-apology-letter/|access-date=2024-06-16|website=Sunday Times|language=en-ZA}}https://www.timeslive.co.za/politics/2024-03-27-from-30-to-200-naledi-chirwa-last-on-eff-list-after-malemas-cold-shoulder-to-her-apology-letter/&lt;/ref&gt; &lt;ref&gt;{{Cite web|last=Macupe|first=Bongekile|date=26 March 2024|title=Out with the old, in with the new: Carl Niehaus sitting pretty at number 27 on EFF's list for Parliament|url=https://www.news24.com/news24/politics/out-with-the-old-in-with-the-old-carl-niehaus-sitting-pretty-at-number-27-on-effs-list-for-parliament-20240326|access-date=2024-03-27|website=News24|language=en-US}}https://www.news24.com/news24/politics/out-with-the-old-in-with-the-old-carl-niehaus-sitting-pretty-at-number-27-on-effs-list-for-parliament-20240326&lt;/ref&gt; Umdosiphambili we-EFF u-Julius Malema wathi ukwehliswa kwakhe esikhundleni bekumphumela wehlelo lehlangano yentando yenengi. &lt;ref&gt;{{Cite web|date=5 April 2024|title='A democratic outcome': Malema on Naledi Chirwa being last on EFF's parliament list|url=https://www.timeslive.co.za/politics/2024-04-05-a-democratic-outcome-malema-on-naledi-chirwa-being-last-on-effs-parliament-list/|access-date=2024-06-16|website=Sunday Times|language=en-ZA}}https://www.timeslive.co.za/politics/2024-04-05-a-democratic-outcome-malema-on-naledi-chirwa-being-last-on-effs-parliament-list/&lt;/ref&gt;

=== UmKhandlu weNarha weemFunda: uMgwengweni 2024–Tjhirhweni 2025 ===
Ngamakhetho kaSihlabantangana 2024, u-Chirwa wakhethwa bona ajamele i-EFF esithunyweni se-Gauteng e- National Council of Provinces, ekuyindlu ephezulu yePalamende yeSewula Afrika. Wafungiswa esihlalweni sakhe mhlana amalanga ama-15 kuMgwengweni ngomnyaka wee-2024. &lt;ref&gt;{{Cite web|last=Merten|first=Marianne|date=2024-06-15|title=Uncontested National Council of Provinces shows national unity government agreements’ impact on matters provincial|url=https://www.dailymaverick.co.za/article/2024-06-15-uncontested-ncop-shows-national-unity-government-agreements-impact-on-matters-provincial/|access-date=2024-06-16|website=Daily Maverick|language=en}}https://www.dailymaverick.co.za/article/2024-06-15-uncontested-ncop-shows-national-unity-government-agreements-impact-on-matters-provincial/&lt;/ref&gt;

== Ipilo yakhe mathupha ==
U-Chirwa wenda ukusukela ngoNobayeni ngomnyaka wee-2022. &lt;ref&gt;{{Cite web|last=Kahla|first=Cheryl|date=2022-11-03|title='Getting married for haters' – EFF's Naledi Chirwa ties the knot [PICS]|url=https://www.citizen.co.za/news/eff-naledi-chirwa-married-2022/|access-date=2023-01-03|website=The Citizen|language=en}}https://www.citizen.co.za/news/eff-naledi-chirwa-married-2022/&lt;/ref&gt; Unabantwana ababili, omunye waboantwana wabelethwa ngomnyaka wee-2021 kuthi lo omunye wabelethwa ngomnyaka wee-2023. &lt;ref&gt;{{Cite web|last=Goba|first=Thabiso|date=1 May 2024|title=Chirwa decided to work throughout pregnancy, it's not reflective of EFF policies: Malema|url=https://www.ewn.co.za/2024/05/01/chirwa-decided-to-work-throughout-pregnancy-its-not-reflective-of-eff-policies-malema|access-date=2024-06-16|website=EWN|language=en}}https://www.ewn.co.za/2024/05/01/chirwa-decided-to-work-throughout-pregnancy-its-not-reflective-of-eff-policies-malema&lt;/ref&gt;

== Iinkomba ==
&lt;references /&gt;




































{{Reflist}}

== Amalinki wangaphandle ==
{{DEFAULTSORT:Chirwa, Naledi}}
[[Mkhakha:Members of the National Assembly of South Africa 2019–2024]]
[[Mkhakha:Women members of the National Council of Provinces]]
[[Mkhakha:Women members of the National Assembly of South Africa]]
[[Mkhakha:University of Pretoria alumni]]
[[Mkhakha:South African feminists]]
[[Mkhakha:Politicians from Gauteng]]
[[Mkhakha:People from Vosloorus]]
[[Mkhakha:Members of the National Council of Provinces]]
[[Mkhakha:FeesMustFall activists]]
[[Mkhakha:Economic Freedom Fighters politicians]]
[[Mkhakha:21st-century South African women politicians]]
[[Mkhakha:1993 births]]
[[Mkhakha:Living people]]</text>
      <sha1>9jqvomkk38w7hd92wutoxxe4ijv4m26</sha1>
    </revision>
    <revision>
      <id>3275</id>
      <parentid>3254</parentid>
      <timestamp>2025-07-01T21:46:22Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>/* Ipilo yakhe mathupha */</comment>
      <origin>3275</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="16033" sha1="e9vfmj1m00zfvmhi7gpc3x2wtwi8oqz" xml:space="preserve">
{{Infobox officeholder|honorific-prefix=|name=Naledi Chirwa|native_name=|native_name_lang=|honorific-suffix=[[Parliament of South Africa|MP]]|image=Naledi Chirwa, 2024 (cropped).jpg|image_size=|smallimage=&lt;!--If this is specified, &quot;image&quot; should not be.--&gt;|alt=|caption=Chirwa in 2024|office=[[National Council of Provinces|Permanent Delegate to the National Council of Provinces]]|status=|term_start=15 June 2024|term_end=|predecessor=|successor=|birthname=Naledi Nokukhanya Chirwa|birth_date={{birth date and age|1993|07|22|df=y}}|birth_place=[[Vosloorus]], [[East Rand]]&lt;br /&gt; [[Transvaal Province|Transvaal]], [[South Africa]]|death_date=|death_place=|citizenship=|nationality=[[South Africa]]n|party=[[Economic Freedom Fighters]] {{small|(2015–present)}}|otherparty=|spouse=|partner=&lt;!--For those with a domestic partner and not married--&gt;|relations=|children=2|residence=|education=|alma_mater=[[University of Pretoria]]|occupation=Member of Parliament|profession=Politician|known_for=|committees=|portfolio=|awards=|website=|honorific_prefix=[[The Honourable]]|termend1=21 May 2024|termstart1=22 May 2019|office1=[[National Assembly of South Africa|Member of the National Assembly]]|constituency_AM=}}

'''UNaledi Nokukhanya Chirwa-Mpungose''' wabelethwa mhlana amalanga ama-22 kuNtaka ngomnyaka we-1993. Ungusopolotiki weSewula Afrika begodu gade amlweli wabafundi wesifunda se -Gauteng . Ujamele i -Economic Freedom Fighters (EFF) e- National Assembly . UChirwa bekalilunga le- National Assembly ukusukela ngenyanga kaMrhayili ngomnyaka wee-2019 ukuya enyangeni kaMgwengweni ngomnyaka wee-2024. Uhlale isikhathi esifitjhani eKhanseleni yeNarha yamaPhrovinsi ngaphambi kobana athunyelwe e -National Assembly ukuze athathe isikhundla  sakaMbuyiseni Ndlozi . Ukukhula nokuduma kwakhe kubangwe kuzibandakanya nabafundi be-#FeesMustFall e- University of Pretoria ukusukela ngomnyaka wee-2015 ukuya emnyakeni wee-2016.

== Ipilo yokuthoma nefundo ==
U-Chirwa wabelethwa mhlana amalanga ama-22 kuNtaka emnyakeni we-1993 e- [[Vosloorus]], e-East Rand, e- Gauteng . &lt;ref name=&quot;SunWorld&quot;&gt;https://www.sowetanlive.co.za/sundayworld/news/2019-06-04-naledi-chirwa-voice-of-the-voiceless/&lt;/ref&gt; Ekukhuleni kwakhe ukhuliswa ngugogwakhe e -Mamelodi, e-Pitoli . &lt;ref name=&quot;SunWorld&quot; /&gt; phezu komnyaka wee-2009, uthe lokha nakaneminyaka ema-15, wasebenza njengomsekeli kamongameli we-Tshwane North College (TNC) Further Education &amp; Training (FET), manje i-TNC TVET. &lt;ref name=&quot;SunWorld&quot; /&gt;

U-Chirwa wafunyana iziqu ze -Bachelor of Arts kanye neziqu ze- Honors degree kuDrama and Film Studies e- University of Pretoria . Ukusukela ngomnyaka wee-2019 bekafunda i -Master of Arts ku-Theatre and Performance e- University of the Witwatersrand . &lt;ref&gt;{{cite web|title=Ms Naledi Nokukhanya Chirwa|url=https://www.parliament.gov.za/person-details/36|website=Parliament of South Africa|access-date=19 June 2021}}https://www.parliament.gov.za/person-details/36&lt;/ref&gt;

== Umlweli wabafundi ==
U-Chirwa waba lilunga le -Economic Freedom Fighters (EFF) ngomnyaka wee-2015 begodu waba godu lilunga le-Student Command yehlangano e-University of Pretoria. Wabuya wakhethwa bewabekwa njengesikhulu sezokuthintana somlawuli. &lt;ref name=&quot;SunWorld&quot;&gt;{{cite news|last1=Zwane|first1=Nokuthula|title=Naledi Chirwa: Voice of the voiceless|url=https://www.sowetanlive.co.za/sundayworld/news/2019-06-04-naledi-chirwa-voice-of-the-voiceless/|access-date=13 April 2020|newspaper=Sunday World|date=4 June 2019}}https://nr.wikipedia.org/wiki/Special:ContentTranslation?from=en&amp;to=nr&amp;page=Naledi+Chirwa&lt;/ref&gt; Ngenyanga kaRhoboyi ngomnyaka wee-2016, ngesikhathi umongameli wenarha wangaphambilini u-Jacob Zuma akhuluma esikhungweni sekhetho se-IEC ngemva kokhetho lukamasipala wango-2016, u-Chirwa nabanye abafundi ababe babathathu baphazamisa ikulumo kamongameli ngesikhathi baphakamise amatshwayo athi &quot;Khanga&quot;, &quot;Khumbula u-Khwezi &quot;, &quot;Ngingu-1 kwaba-3&quot; kanye nokuthi &quot;emva kweminyaka ema-10 &quot;, ngokukhamba kwesikhathi ngokutjho uZuma ukudlwengula phakathi kwabo-2000. &lt;ref&gt;{{cite news|last1=Makhubu|first1=Ntando|title=Woman in Zuma #Khwezi protest speaks out|url=https://www.iol.co.za/news/politics/woman-in-zuma-khwezi-protest-speaks-out-2054518|access-date=13 April 2020|newspaper=IOL|date=8 Aug 2016}}https://www.iol.co.za/news/politics/woman-in-zuma-khwezi-protest-speaks-out-2054518&lt;/ref&gt; &lt;ref&gt;{{cite news|last1=Ngoepe|first1=Karabo|title=Anti-rape protesters disrupt Zuma's speech|url=https://www.news24.com/news24/elections/news/anti-rape-protesters-disrupt-zumas-speech-20160806|access-date=10 September 2020|newspaper=News24|date=6 August 2016|location=Pretoria}}https://www.news24.com/news24/elections/news/anti-rape-protesters-disrupt-zumas-speech-20160806&lt;/ref&gt;

Godu ngomnyaka wee-2016, u-Chirwa bekabandakanyeka emigurugurwini wabafundi ephathelene nomnyakazo we- #FeesMustFall . Ekukhambeni kwesikhathi wabotjhwa begodu wajanyiswa ekhampasini njengomunye wemibandela webheyili yakhe. &lt;ref&gt;{{cite news|last1=Madibogo|first1=Julia|title=Who is Naledi Chirwa - Drama student‚ Zuma tormentor‚ EFF student leader and fees must fall campaigner|url=https://www.timeslive.co.za/politics/2016-10-19-who-is-naledi-chirwa-drama-student-zuma-tormentor-eff-student-leader-and-fees-must-fall-campaigner/|access-date=13 April 2020|newspaper=TimesLIVE|date=19 October 2016}}https://www.timeslive.co.za/politics/2016-10-19-who-is-naledi-chirwa-drama-student-zuma-tormentor-eff-student-leader-and-fees-must-fall-campaigner/&lt;/ref&gt; Ngomnyaka wee-2017, bekangomunye wabantu abatjha abama-200 be-Mail &amp;amp;amp; Guardian . &lt;ref&gt;{{cite news|last1=Maputla|first1=Tswelopele|title=#BlackGirlMagic: These female parliamentarians are only in their 20s|url=https://www.sowetanlive.co.za/s-mag/2019-05-23-blackgirlmagic-these-female-parliamentarians-are-only-in-their-20s/|access-date=10 September 2020|newspaper=SowetanLIVE|date=23 May 2019}}https://www.sowetanlive.co.za/s-mag/2019-05-23-blackgirlmagic-these-female-parliamentarians-are-only-in-their-20s/&lt;/ref&gt;

== Umsebenzi wePalamende ==

=== UmHlangano weNarha: 2019–2024 ===
Ngokhetho lukaMeyi 2019, wakhethelwa i -National Assembly of South Africa begodu waba lilunga lePalamende elincani khulu le-EFF. Wafungiswa kanye nabanye abafundi abalwelako, okufakahlangana u-Peter Keetse, u-Nompendulo Mkhatshwa no -Vuyani Pambo . &lt;ref&gt;{{cite news|last1=Bhengu|first1=Cebelihle|title=Power to the new generation: three young MPs you need to know|url=https://www.timeslive.co.za/politics/2019-05-22-power-to-the-new-generation-three-young-mps-you-need-to-know/|access-date=13 April 2020|newspaper=TimesLIVE|date=22 May 2019}}https://www.sowetanlive.co.za/sundayworld/news/2019-06-04-naledi-chirwa-voice-of-the-voiceless/&lt;/ref&gt; Bekalilunga leKomidi yePhothifoliyo yePalamende yezePilo . &lt;ref&gt;{{cite web|title=Portfolio Committee on Health - Parliament of South Africa|url=https://www.parliament.gov.za/committee-details/147|access-date=6 December 2020|website=Parliament of South Africa}}https://www.parliament.gov.za/committee-details/147&lt;/ref&gt;

Mhlazana amalanga ama-25 kuMgwengweni ngomnyaka wee-2019, wethula ikulumo yakhe yokuthoma ngesikhathi sokuphikisana ngeKulumo yeNarha . Wakatelelwa bona arhoqise ukuphawula kwakhe malungana nokuthi urhulumende ubandakanyeka ekubulaweni kwabasekeli be-#FeesMustFall. &lt;ref&gt;{{cite news|last1=Gerber|first1=Jan|title=EFF's Chirwa forced to withdraw remark that government was complicit in 'brutal murders' of Fees Must Fall activists|url=https://www.news24.com/news24/southafrica/news/effs-chirwa-forced-to-withdraw-remark-that-government-was-complicit-in-brutal-murders-of-fees-must-fall-activists-20190625|access-date=6 December 2020|newspaper=News24|date=25 June 2019}}https://www.news24.com/news24/southafrica/news/effs-chirwa-forced-to-withdraw-remark-that-government-was-complicit-in-brutal-murders-of-fees-must-fall-activists-20190625&lt;/ref&gt; &lt;ref&gt;{{cite news|last1=Davis|first1=Gaye|title=Sona debate: EFF's Chirwa forced to withdraw Ramaphosa comments in maiden speech|url=https://ewn.co.za/2019/06/25/sona-debate-eff-s-chirwa-forced-to-withdraw-ramaphosa-comments-in-maiden-speech|access-date=6 December 2020|newspaper=Eyewitness News|date=25 June 2019|location=Cape Town}}https://ewn.co.za/2019/06/25/sona-debate-eff-s-chirwa-forced-to-withdraw-ramaphosa-comments-in-maiden-speech&lt;/ref&gt; NgoTjhirhweni 2022, waduma ekundleni yokuthintana eyayibizwa bona yi-Twitter ngokubiza uMongameli u-Cyril Ramaphosa ngokuthi &quot;akanamazinyo&quot; begodu &quot;msana omncani obuthakathaka&quot;. &lt;ref&gt;{{Cite web|date=18 January 2022|title=The EFF’s 28-year-old Naledi Chirwa called Cyril Ramaphosa a ‘weak little boy’ and now Twitter is divided|url=https://www.iol.co.za/news/south-africa/gauteng/the-effs-28-year-old-naledi-chirwa-called-cyril-ramaphosa-a-weak-little-boy-and-now-twitter-is-divided-a82c6721-1b4e-4291-a36f-204b69e810ba|access-date=2022-01-19|website=IOL|language=en}}https://www.iol.co.za/news/south-africa/gauteng/the-effs-28-year-old-naledi-chirwa-called-cyril-ramaphosa-a-weak-little-boy-and-now-twitter-is-divided-a82c6721-1b4e-4291-a36f-204b69e810ba&lt;/ref&gt;

Ukusukela lapha ngomnyaka wee-2020, u-Chirwa wahlaselwa eenkundleni zokuthintana basebenzisi abangaziwako ebebatjho ngaphandle kobufakazi ukuthi usisakhamuzi se [[Malawi|-Malawi]] begodu umndenakhe ufumene ubuzwe beSewula Afrika ngokukhohlisa. &lt;ref&gt;{{Cite news|date=9 March 2020|title=Twitter storm after EFF MP Naledi Chirwa's nationality questioned|url=https://www.iol.co.za/news/politics/twitter-storm-after-eff-mp-naledi-chirwas-nationality-questioned-44418095|access-date=16 June 2024|work=IOL}}https://www.iol.co.za/news/politics/twitter-storm-after-eff-mp-naledi-chirwas-nationality-questioned-44418095&lt;/ref&gt; NgoTjhirhweni 2022, waphendula iinsolwezo ngokuthumela ku-Twitter wathi : &quot;Ningaleya amala ngobuzwe bami bekube kulapho niphenduka nibe hlaza amahlalo. Angeze amala wenu aba liqiniso begodu angeze kwangenza ngithule. Azange ngilithenge iphimbo lami. Angiliqatjhisi. Ngizokuhlala ngikhuluma begodu ayikho into eningayenza ngalokho.&quot; &lt;ref&gt;{{Cite web|date=19 January 2022|title=Naledi Chirwa hits back at critics: ‘You can lie about my nationality until you turn green in the buttocks’|url=https://www.timeslive.co.za/politics/2022-01-19-naledi-chirwa-hits-back-at-critics-you-can-lie-about-my-nationality-until-you-turn-green-in-the-buttocks/|access-date=2022-01-19|website=Sunday Times|language=en-ZA}}https://www.timeslive.co.za/politics/2022-01-19-naledi-chirwa-hits-back-at-critics-you-can-lie-about-my-nationality-until-you-turn-green-in-the-buttocks/&lt;/ref&gt;

Ngenyanga kaNtaka 2024, u-Chirwa bekangekho emakhethweni wepalamende ukwenzela bona atlhogomele umntwanakhe ogolako. I-EFF yamhlawulisa begodu yamyalela bona aqolise. &lt;ref&gt;{{Cite web|date=5 March 2024|title=Stir as EFF MP Naledi Chirwa fined and made to apologise for missing parliament due to sick baby|url=https://www.timeslive.co.za/politics/2024-03-05-stir-as-eff-mp-naledi-chirwa-fined-and-made-to-apologise-for-missing-parliament-due-to-sick-baby/|access-date=2024-06-16|website=Sunday Times|language=en-ZA}}https://www.timeslive.co.za/politics/2024-03-05-stir-as-eff-mp-naledi-chirwa-fined-and-made-to-apologise-for-missing-parliament-due-to-sick-baby/&lt;/ref&gt; &lt;ref&gt;{{Cite web|last=Ntombela|first=Nomzamo Portia|date=11 March 2024|title=Naledi Chirwa's apology a disturbing reminder of patriarchy in politics|url=https://www.ewn.co.za/2024/03/11/nomzamo-ntombela-naledi-chirwas-apology-a-disturbing-reminder-of-patriarchy-in-politics|access-date=2024-03-27|website=EWN|language=en}}https://www.ewn.co.za/2024/03/11/nomzamo-ntombela-naledi-chirwas-apology-a-disturbing-reminder-of-patriarchy-in-politics&lt;/ref&gt; Msinyana ngemva kwalokho, i-EFF yakhupha irhelo layo labakhethiweko bekhetho elizako, ebelibeka u-Chirwa endaweni yokugcina. &lt;ref&gt;{{Cite web|date=27 March 2024|title=From 30 to 200: Naledi Chirwa last on EFF list after Malema’s cold shoulder to her apology letter|url=https://www.timeslive.co.za/politics/2024-03-27-from-30-to-200-naledi-chirwa-last-on-eff-list-after-malemas-cold-shoulder-to-her-apology-letter/|access-date=2024-06-16|website=Sunday Times|language=en-ZA}}https://www.timeslive.co.za/politics/2024-03-27-from-30-to-200-naledi-chirwa-last-on-eff-list-after-malemas-cold-shoulder-to-her-apology-letter/&lt;/ref&gt; &lt;ref&gt;{{Cite web|last=Macupe|first=Bongekile|date=26 March 2024|title=Out with the old, in with the new: Carl Niehaus sitting pretty at number 27 on EFF's list for Parliament|url=https://www.news24.com/news24/politics/out-with-the-old-in-with-the-old-carl-niehaus-sitting-pretty-at-number-27-on-effs-list-for-parliament-20240326|access-date=2024-03-27|website=News24|language=en-US}}https://www.news24.com/news24/politics/out-with-the-old-in-with-the-old-carl-niehaus-sitting-pretty-at-number-27-on-effs-list-for-parliament-20240326&lt;/ref&gt; Umdosiphambili we-EFF u-Julius Malema wathi ukwehliswa kwakhe esikhundleni bekumphumela wehlelo lehlangano yentando yenengi. &lt;ref&gt;{{Cite web|date=5 April 2024|title='A democratic outcome': Malema on Naledi Chirwa being last on EFF's parliament list|url=https://www.timeslive.co.za/politics/2024-04-05-a-democratic-outcome-malema-on-naledi-chirwa-being-last-on-effs-parliament-list/|access-date=2024-06-16|website=Sunday Times|language=en-ZA}}https://www.timeslive.co.za/politics/2024-04-05-a-democratic-outcome-malema-on-naledi-chirwa-being-last-on-effs-parliament-list/&lt;/ref&gt;

=== UmKhandlu weNarha weemFunda: uMgwengweni 2024–Tjhirhweni 2025 ===
Ngamakhetho kaSihlabantangana 2024, u-Chirwa wakhethwa bona ajamele i-EFF esithunyweni se-Gauteng e- National Council of Provinces, ekuyindlu ephezulu yePalamende yeSewula Afrika. Wafungiswa esihlalweni sakhe mhlana amalanga ama-15 kuMgwengweni ngomnyaka wee-2024. &lt;ref&gt;{{Cite web|last=Merten|first=Marianne|date=2024-06-15|title=Uncontested National Council of Provinces shows national unity government agreements’ impact on matters provincial|url=https://www.dailymaverick.co.za/article/2024-06-15-uncontested-ncop-shows-national-unity-government-agreements-impact-on-matters-provincial/|access-date=2024-06-16|website=Daily Maverick|language=en}}https://www.dailymaverick.co.za/article/2024-06-15-uncontested-ncop-shows-national-unity-government-agreements-impact-on-matters-provincial/&lt;/ref&gt;

== Ipilo yakhe mathupha ==
U-Chirwa wenda ukusukela ngoNobayeni ngomnyaka wee-2022. &lt;ref&gt;{{Cite web|last=Kahla|first=Cheryl|date=2022-11-03|title='Getting married for haters' – EFF's Naledi Chirwa ties the knot [PICS]|url=https://www.citizen.co.za/news/eff-naledi-chirwa-married-2022/|access-date=2023-01-03|website=The Citizen|language=en}}https://www.citizen.co.za/news/eff-naledi-chirwa-married-2022/&lt;/ref&gt; Unabantwana ababili, omunye wabantwana wabelethwa ngomnyaka wee-2021 kuthi lo omunye wabelethwa ngomnyaka wee-2023. &lt;ref&gt;{{Cite web|last=Goba|first=Thabiso|date=1 May 2024|title=Chirwa decided to work throughout pregnancy, it's not reflective of EFF policies: Malema|url=https://www.ewn.co.za/2024/05/01/chirwa-decided-to-work-throughout-pregnancy-its-not-reflective-of-eff-policies-malema|access-date=2024-06-16|website=EWN|language=en}}https://www.ewn.co.za/2024/05/01/chirwa-decided-to-work-throughout-pregnancy-its-not-reflective-of-eff-policies-malema&lt;/ref&gt;

== Iinkomba ==
&lt;references /&gt;




































{{Reflist}}

== Amalinki wangaphandle ==
{{DEFAULTSORT:Chirwa, Naledi}}
[[Mkhakha:Members of the National Assembly of South Africa 2019–2024]]
[[Mkhakha:Women members of the National Council of Provinces]]
[[Mkhakha:Women members of the National Assembly of South Africa]]
[[Mkhakha:University of Pretoria alumni]]
[[Mkhakha:South African feminists]]
[[Mkhakha:Politicians from Gauteng]]
[[Mkhakha:People from Vosloorus]]
[[Mkhakha:Members of the National Council of Provinces]]
[[Mkhakha:FeesMustFall activists]]
[[Mkhakha:Economic Freedom Fighters politicians]]
[[Mkhakha:21st-century South African women politicians]]
[[Mkhakha:1993 births]]
[[Mkhakha:Living people]]</text>
      <sha1>e9vfmj1m00zfvmhi7gpc3x2wtwi8oqz</sha1>
    </revision>
  </page>
  <page>
    <title>U-Karabo Poppy</title>
    <ns>0</ns>
    <id>661</id>
    <revision>
      <id>3256</id>
      <timestamp>2025-06-29T15:27:06Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1289855927|Karabo Poppy]]&quot;</comment>
      <origin>3256</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2904" sha1="09urk0mfqznuh9jir6pjfqco4493osn" xml:space="preserve">
{{Undisclosed paid|date=November 2021}}
{| class=&quot;infobox biography vcard&quot;
! colspan=&quot;2&quot; class=&quot;infobox-above&quot; style=&quot;font-size:125%;&quot; |&lt;div class=&quot;fn&quot;&gt;u-Karabo Poppy&lt;/div&gt;
|- class=&quot;infobox-data&quot;
! class=&quot;infobox-label&quot; scope=&quot;row&quot; | wabelethwa
| class=&quot;infobox-data&quot; |&lt;div class=&quot;nickname&quot; style=&quot;display:inline&quot;&gt; Karabo Poppy Moletsane&lt;/div&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;1992 (iminyaka&amp;nbsp;32 &amp;#x2013; 33)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;birthplace&quot; style=&quot;display:inline&quot;&gt; [[Vereeniging]], eSewula Afrika&lt;/div&gt;
|-
! class=&quot;infobox-label&quot; scope=&quot;row&quot; | Ubutjhaba
| class=&quot;infobox-data category&quot; | [[South African citizenship|ISewula Afrika]]
|-
! class=&quot;infobox-label&quot; scope=&quot;row&quot; | Ifundo
| class=&quot;infobox-data&quot; | [[Open Window Institute|Ifasitela elivulekileko]] &lt;span style=&quot;font-size: 85%;&quot;&gt;( [[Bachelor of Arts|i-BA]] ekukhulumisaneni [[Visual Communication|okubonwako]] )&lt;/span&gt;
|-
! class=&quot;infobox-label&quot; scope=&quot;row&quot; | Imisebenzi 
| class=&quot;infobox-data role&quot; |
|}
'''U-Karabo Poppy Moletsane''' (wabelethwa ngo-1992) mdwebi weenthombe weSewula Afrika, umtlami wemifanekiso, kanye nomdwebi wemigwaqo. 

== Ipilo yokuthoma ==
U-Poppy wabelethelwa e- Vereeniging . Wafunda e -Open Window Institute e -Pitori begodu unedigri ku -Visual Communication . 

== Ibizelo ==
U-Poppy wenze umsebenzi we -Wall Street Journal, Google, Coca-Cola, kanye ne -Nike, okufaka hlangana ukutlama amanyathelo ambathwa ngu -LeBron James .  Wakha iinthombe zomdlalo wokuthoma we-Afrika ku -Netflix, ''i-Queen Sono'', kanye ''ne-When They See Us'' .  Wasebenzisana ne-RICH MNISI ngeqoqo lezambatho zabobulili obufanako, ebizwa nge-Running Errands, ngo-2020.   Umfanekiso wakhe we-Utah Jazz ufakwe e -Salt Lake City, e-Utah.

Ngomnyaka ka-2021, wathunyelwa yi -Wikipedia, kanye no-Jasmina El Bouamraoui, ukuklama amatshwayo ali-101 wokugidinga iminyaka ema-20 ye-Wikipedia. 

Iinthombe zakhe ezibotjhiweko zitjengiswa njengezinto ezifakwe emadorobheni e -Johannesburg kunye nase-Soweto Towers. 

== abonongorwana yobungcweti ==
Wafakwa erhelweni le ''-Forbes'' “30 Ngaphasi kwama-30” emkhakheni we-2019 wokutlama.  Imitlamo yakhe ka-2019 ye-Nike yathumba i-BASA Beyond Border Partnership Award. Ngomnyaka ka-2020 wabizwa ngokuthi &quot;nguMsunguli womnyaka&quot; ngu- ''Between 10and5'' . 

== [https://www.itsnicethat.com/news/karabo-poppy-moletsane-jasmina-el-bouamraoui-wikipedia-20-anniversary-190221 Iinkhomba] ==
[https://www.bbc.com/news/av/business-46922184]
https://www.itsnicethat.com/features/ones-to-watch-2020-karabo-poppy-moletsane-illustration-240220
https://www.cnn.com/style/article/karabo-poppy-south-africa-illustrator-nike-sneakers-spc-intl/index.html
[https://web.archive.org/web/20210125193953/https://10and5.com/2020/03/06/karabo-poppy-teams-up-with-netflix-strong-black-lead-for-new-queen-sono-illustration/]
[https://visi.co.za/rich-mnisi-x-karabo-poppy-capsule-collection-running-errands/]
{{Reflist}}</text>
      <sha1>09urk0mfqznuh9jir6pjfqco4493osn</sha1>
    </revision>
  </page>
  <page>
    <title>Abatloli abatjha</title>
    <ns>0</ns>
    <id>662</id>
    <revision>
      <id>3257</id>
      <timestamp>2025-06-29T20:09:29Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>ngifake inkhombo</comment>
      <origin>3257</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3600" sha1="qdjxbwuqcedujjyoqxpnfdcv0z90r0y" xml:space="preserve">== ABATLOLI ABATJHA ==
[[Isimumathi:Latin dictionary.jpg|thumb|ABATLOLI ABATJHA]]
'''Abatloli abatjha''' babantu abathoma ikhambo labo lezemitlolo eminyakeni ephasi yobudala,kungaba kugadangisa umsebenzi wabo nofana ukuzitlolela ukuzithabisa.Ukuba mtloli omncane e'''Sewula Afrika''' kutlhoga ukuzimisela okukhulu nokungapheli ihliziyo.I'''Sewula Afrika''' ilikhaya kubatloli abasebatjha abenza itjhuguluko kezemitlolo ingasi enarheni le kwaphela kodwana neenarheni ezingaphetjheya.

=== Iphaliswano labatloli abatjha ===
Ngokuhlonywa ngomnyaka ka2022,i'''young writer's competition''' kubingwe ngayo ukhwakha isizukulwana esitjha sabatloli abasebatjha '''eSewula Afrika'''.

Iphaliswano leli likhombela abatloli abasebatjha bonyana bathumele umsebenzi wabo ongakagadangiswa bonyana bazibeke ethubeni lokobana bagadangiselwe wona ngokwehluka kwesiqubulo qobe mnyaka.

Lokhu kuqakathekile ukudlula ngaphambili ngemibiko yamhlapha nje ebonisa bonyana ilutjha le'''Sewula Afrika''' lisemrarweni naziza kwezokutlola.Ingogwana le yesule umsebenzi weminyaka wezotlolo.

==== Indima yabatloli abasebatjha ====
Abatloli abatjha badlala indima eqakathekileko ekwakheni umbono,ukuvuselela ukulandisa nokufaka isandla emasikweni.Baletha ukuzwisisa okutjha namaphimbo ahlukileko ekulandiseni iindaba kanengi zikhuluma ngeendaba zesimanjemanje ngombono welutjha.Babuye balethe ithemba nokhu katelela bonyana isiko lokufunda libuye ngamandla emiphakathini ehlukahlukeneko.Indima abayidlala khulu kuletha itjhuguluko lokobana ezinye izinto zenziwe ngendlela elula yamalanga wanamhlanjesi nokhu dlulisa umlayezo mayelana nezinto ezitinta umphakathi.

===== Amahlelo wabatloli abatjha =====
I&lt;nowiki/&gt;https://www.fundza.co.za/our-programmes/writing/&lt;nowiki/&gt;irhelebha ukukhulisa nokwandisa ithalente le'''Sewula Afrika'''.

Abatloli abasebatjha bangathumela umsebenzi wabo bona ubuyekezwe siqhema begodu ukhutjhwe nge-mobisite yabo yasimahla yedatha i'''fundza.mobi'''.I-'''fundza''' iraga iintjhijilo zokutlola namaphaliswano ibuye inikele abatloli abafuna ukutlola ngendlela ethileko yokutlola.Njengengcenye yokuzibophezela kwe-'''funzda''' ekukhuliseni abatloli abatjha i-'''fundza''' iraga ihlelo lokutlola le-inthanethi elithatha isikhathi esithileko seenyanga ezili-10 lapho abatloli abasebatjha abanethalenta abalinani eliyi-20 e'''Sewula Afrika''' bathoma ikhambo elikhona lokuthuthukisa amakghono wabo.

Ekupheleni kobudlelwano abatloli bazabe bakhe iphothifoliyo yokutlola ehlaba imizwa nehlukahlukeneko begodu bazabe sele igadangisiwe kanengi ku-live '''fundza''' mobi app.

====== Umtloli osemutjha owenza umehluko ======
[[Isimumathi:Umtloli u-Mafika Jetro Mahlangu.jpg|thumb|umtloli u-Mafika Jetro Mahlangu]]
U-'''Mafika Jetro Mahlangu''' ungumtloli osemutjha ovela endaweni ye'''Mpumalanga'''.Ithando lakhe lokutlola lathoma lokha asese mncani asemabangeni aphasi wezefundo.

Utlola ngelimi lesi'''Ndebele''' begodu utlola ngendlela ezinengi,ukufaka hlangana ama-noveli,imidlalo etjhatjhalazi,imidlalo yemirhatjhweni kunye neenkondlo.

Incwadi yakhe yesihloko esithi '''uMrhayili''' yagadangiswa ngomnyaka ka 2023 begodu yenza kuhle.Uthumbe abonongorwana abathathu ngayo incwadi ka'''Mrhayili.'''

Wathumba unongorwana kwi https://sala.org.za/&lt;nowiki/&gt;ngaphasi kwe ''best first time published author award'' ngomnyaka ka2024.Wabuye wathumba ku'''Mbokodo publishers literary awards awards''' ngaphasi kwe ''best book in isiNdebele nakhu readers choice award ngomnyaka ka 2024.''

====== Inkhombo ======
https://sala.org.za/
https://www.panmacmillan.co.za/
https://www.fundza.co.za/
https://nalibali.org/</text>
      <sha1>qdjxbwuqcedujjyoqxpnfdcv0z90r0y</sha1>
    </revision>
    <revision>
      <id>3469</id>
      <parentid>3257</parentid>
      <timestamp>2025-07-29T00:14:41Z</timestamp>
      <contributor>
        <username>Dcljr</username>
        <id>20</id>
      </contributor>
      <comment>remove redundant section heading</comment>
      <origin>3469</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3577" sha1="qsupt3euu0gz76t6jmh8jj3x6m62xam" xml:space="preserve">[[Isimumathi:Latin dictionary.jpg|thumb|ABATLOLI ABATJHA]]
'''Abatloli abatjha''' babantu abathoma ikhambo labo lezemitlolo eminyakeni ephasi yobudala,kungaba kugadangisa umsebenzi wabo nofana ukuzitlolela ukuzithabisa.Ukuba mtloli omncane e'''Sewula Afrika''' kutlhoga ukuzimisela okukhulu nokungapheli ihliziyo.I'''Sewula Afrika''' ilikhaya kubatloli abasebatjha abenza itjhuguluko kezemitlolo ingasi enarheni le kwaphela kodwana neenarheni ezingaphetjheya.

=== Iphaliswano labatloli abatjha ===
Ngokuhlonywa ngomnyaka ka2022,i'''young writer's competition''' kubingwe ngayo ukhwakha isizukulwana esitjha sabatloli abasebatjha '''eSewula Afrika'''.

Iphaliswano leli likhombela abatloli abasebatjha bonyana bathumele umsebenzi wabo ongakagadangiswa bonyana bazibeke ethubeni lokobana bagadangiselwe wona ngokwehluka kwesiqubulo qobe mnyaka.

Lokhu kuqakathekile ukudlula ngaphambili ngemibiko yamhlapha nje ebonisa bonyana ilutjha le'''Sewula Afrika''' lisemrarweni naziza kwezokutlola.Ingogwana le yesule umsebenzi weminyaka wezotlolo.

==== Indima yabatloli abasebatjha ====
Abatloli abatjha badlala indima eqakathekileko ekwakheni umbono,ukuvuselela ukulandisa nokufaka isandla emasikweni.Baletha ukuzwisisa okutjha namaphimbo ahlukileko ekulandiseni iindaba kanengi zikhuluma ngeendaba zesimanjemanje ngombono welutjha.Babuye balethe ithemba nokhu katelela bonyana isiko lokufunda libuye ngamandla emiphakathini ehlukahlukeneko.Indima abayidlala khulu kuletha itjhuguluko lokobana ezinye izinto zenziwe ngendlela elula yamalanga wanamhlanjesi nokhu dlulisa umlayezo mayelana nezinto ezitinta umphakathi.

===== Amahlelo wabatloli abatjha =====
I&lt;nowiki/&gt;https://www.fundza.co.za/our-programmes/writing/&lt;nowiki/&gt;irhelebha ukukhulisa nokwandisa ithalente le'''Sewula Afrika'''.

Abatloli abasebatjha bangathumela umsebenzi wabo bona ubuyekezwe siqhema begodu ukhutjhwe nge-mobisite yabo yasimahla yedatha i'''fundza.mobi'''.I-'''fundza''' iraga iintjhijilo zokutlola namaphaliswano ibuye inikele abatloli abafuna ukutlola ngendlela ethileko yokutlola.Njengengcenye yokuzibophezela kwe-'''funzda''' ekukhuliseni abatloli abatjha i-'''fundza''' iraga ihlelo lokutlola le-inthanethi elithatha isikhathi esithileko seenyanga ezili-10 lapho abatloli abasebatjha abanethalenta abalinani eliyi-20 e'''Sewula Afrika''' bathoma ikhambo elikhona lokuthuthukisa amakghono wabo.

Ekupheleni kobudlelwano abatloli bazabe bakhe iphothifoliyo yokutlola ehlaba imizwa nehlukahlukeneko begodu bazabe sele igadangisiwe kanengi ku-live '''fundza''' mobi app.

====== Umtloli osemutjha owenza umehluko ======
[[Isimumathi:Umtloli u-Mafika Jetro Mahlangu.jpg|thumb|umtloli u-Mafika Jetro Mahlangu]]
U-'''Mafika Jetro Mahlangu''' ungumtloli osemutjha ovela endaweni ye'''Mpumalanga'''.Ithando lakhe lokutlola lathoma lokha asese mncani asemabangeni aphasi wezefundo.

Utlola ngelimi lesi'''Ndebele''' begodu utlola ngendlela ezinengi,ukufaka hlangana ama-noveli,imidlalo etjhatjhalazi,imidlalo yemirhatjhweni kunye neenkondlo.

Incwadi yakhe yesihloko esithi '''uMrhayili''' yagadangiswa ngomnyaka ka 2023 begodu yenza kuhle.Uthumbe abonongorwana abathathu ngayo incwadi ka'''Mrhayili.'''

Wathumba unongorwana kwi https://sala.org.za/&lt;nowiki/&gt;ngaphasi kwe ''best first time published author award'' ngomnyaka ka2024.Wabuye wathumba ku'''Mbokodo publishers literary awards awards''' ngaphasi kwe ''best book in isiNdebele nakhu readers choice award ngomnyaka ka 2024.''

====== Inkhombo ======
https://sala.org.za/
https://www.panmacmillan.co.za/
https://www.fundza.co.za/
https://nalibali.org/</text>
      <sha1>qsupt3euu0gz76t6jmh8jj3x6m62xam</sha1>
    </revision>
    <revision>
      <id>3470</id>
      <parentid>3469</parentid>
      <timestamp>2025-07-29T00:16:11Z</timestamp>
      <contributor>
        <username>Dcljr</username>
        <id>20</id>
      </contributor>
      <comment>fix (?) section nesting</comment>
      <origin>3470</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3549" sha1="ny862eokvbns6zqp2mlrs57ans4vnpd" xml:space="preserve">[[Isimumathi:Latin dictionary.jpg|thumb|ABATLOLI ABATJHA]]
'''Abatloli abatjha''' babantu abathoma ikhambo labo lezemitlolo eminyakeni ephasi yobudala,kungaba kugadangisa umsebenzi wabo nofana ukuzitlolela ukuzithabisa.Ukuba mtloli omncane e'''Sewula Afrika''' kutlhoga ukuzimisela okukhulu nokungapheli ihliziyo.I'''Sewula Afrika''' ilikhaya kubatloli abasebatjha abenza itjhuguluko kezemitlolo ingasi enarheni le kwaphela kodwana neenarheni ezingaphetjheya.

== Iphaliswano labatloli abatjha ==
Ngokuhlonywa ngomnyaka ka2022,i'''young writer's competition''' kubingwe ngayo ukhwakha isizukulwana esitjha sabatloli abasebatjha '''eSewula Afrika'''.

Iphaliswano leli likhombela abatloli abasebatjha bonyana bathumele umsebenzi wabo ongakagadangiswa bonyana bazibeke ethubeni lokobana bagadangiselwe wona ngokwehluka kwesiqubulo qobe mnyaka.

Lokhu kuqakathekile ukudlula ngaphambili ngemibiko yamhlapha nje ebonisa bonyana ilutjha le'''Sewula Afrika''' lisemrarweni naziza kwezokutlola.Ingogwana le yesule umsebenzi weminyaka wezotlolo.

== Indima yabatloli abasebatjha ==
Abatloli abatjha badlala indima eqakathekileko ekwakheni umbono,ukuvuselela ukulandisa nokufaka isandla emasikweni.Baletha ukuzwisisa okutjha namaphimbo ahlukileko ekulandiseni iindaba kanengi zikhuluma ngeendaba zesimanjemanje ngombono welutjha.Babuye balethe ithemba nokhu katelela bonyana isiko lokufunda libuye ngamandla emiphakathini ehlukahlukeneko.Indima abayidlala khulu kuletha itjhuguluko lokobana ezinye izinto zenziwe ngendlela elula yamalanga wanamhlanjesi nokhu dlulisa umlayezo mayelana nezinto ezitinta umphakathi.

== Amahlelo wabatloli abatjha ==
I&lt;nowiki/&gt;https://www.fundza.co.za/our-programmes/writing/&lt;nowiki/&gt;irhelebha ukukhulisa nokwandisa ithalente le'''Sewula Afrika'''.

Abatloli abasebatjha bangathumela umsebenzi wabo bona ubuyekezwe siqhema begodu ukhutjhwe nge-mobisite yabo yasimahla yedatha i'''fundza.mobi'''.I-'''fundza''' iraga iintjhijilo zokutlola namaphaliswano ibuye inikele abatloli abafuna ukutlola ngendlela ethileko yokutlola.Njengengcenye yokuzibophezela kwe-'''funzda''' ekukhuliseni abatloli abatjha i-'''fundza''' iraga ihlelo lokutlola le-inthanethi elithatha isikhathi esithileko seenyanga ezili-10 lapho abatloli abasebatjha abanethalenta abalinani eliyi-20 e'''Sewula Afrika''' bathoma ikhambo elikhona lokuthuthukisa amakghono wabo.

Ekupheleni kobudlelwano abatloli bazabe bakhe iphothifoliyo yokutlola ehlaba imizwa nehlukahlukeneko begodu bazabe sele igadangisiwe kanengi ku-live '''fundza''' mobi app.

== Umtloli osemutjha owenza umehluko ==
[[Isimumathi:Umtloli u-Mafika Jetro Mahlangu.jpg|thumb|umtloli u-Mafika Jetro Mahlangu]]
U-'''Mafika Jetro Mahlangu''' ungumtloli osemutjha ovela endaweni ye'''Mpumalanga'''.Ithando lakhe lokutlola lathoma lokha asese mncani asemabangeni aphasi wezefundo.

Utlola ngelimi lesi'''Ndebele''' begodu utlola ngendlela ezinengi,ukufaka hlangana ama-noveli,imidlalo etjhatjhalazi,imidlalo yemirhatjhweni kunye neenkondlo.

Incwadi yakhe yesihloko esithi '''uMrhayili''' yagadangiswa ngomnyaka ka 2023 begodu yenza kuhle.Uthumbe abonongorwana abathathu ngayo incwadi ka'''Mrhayili.'''

Wathumba unongorwana kwi https://sala.org.za/&lt;nowiki/&gt;ngaphasi kwe ''best first time published author award'' ngomnyaka ka2024.Wabuye wathumba ku'''Mbokodo publishers literary awards awards''' ngaphasi kwe ''best book in isiNdebele nakhu readers choice award ngomnyaka ka 2024.''

== Inkhombo ==
https://sala.org.za/
https://www.panmacmillan.co.za/
https://www.fundza.co.za/
https://nalibali.org/</text>
      <sha1>ny862eokvbns6zqp2mlrs57ans4vnpd</sha1>
    </revision>
  </page>
  <page>
    <title>Ilutjha le Sewula Afrika ngefetjhini nedizayini</title>
    <ns>0</ns>
    <id>663</id>
    <revision>
      <id>3258</id>
      <timestamp>2025-06-29T22:57:53Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>i changed the headings and references</comment>
      <origin>3258</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4100" sha1="at7egzduj1pslod1gz901g3ozwetae2" xml:space="preserve">== Ilutjha le Sewula Afrika ngefetjhini nedizayini ==
[[Isimumathi:Youth, a narrative, and two other stories (IA youthnarrativetw00conrrich).pdf|thumb|abantu abatjha kwezokutlama nefetjheni]]
'''Ilutjha''' le'''Sewula Afrika''' lidlala indima ekulu ekubumbeni ubujamo befetjhini nokutlama.Bamukela amagugu wabo,baveza ubuntu babo begodu bakhuthaza ukusimama ngokusebenzisa imitlamo yabo ngesikhathi baqhuba imikhuba ezwakala ebantwini bephasi loke.Ilutjha le'''Sewula Afrika''' lifaka hlangana amaphrinti wesintu we-'''Afrika''',amatjhila kunye nezinto zokusebenza emiklameni yazo lisuka emikhubeni yefetjhini yesetjhingalanga kwaphela.

Ukutjheja amagugu lokhu kuyingcenye yomnyakazo omkhulu wokuqeda ubukoloni befetjhini ukugidinga imiklamo yendawo nokhutjhijilela umthelela wamakoloni.

=== Ukulwela ifetjhini kunye nomthelela emphakathini ===
Abatlami abatjha basebenzisa ifetjhini ukutjheja iindaba zehlala kuhle nezepolotiki bafaka imilayezo engabonakaliko kodwana enamandla emitlameni yabo.Abatlami abanengi abasebatjha babeka phambili imikghwa esimemeko emsebenzini wabo,badzimelele ekutholeni izinto ezihle,izinto eziphathelene nemvelo kunye nemikghwa yokusebenza efaneleko.Ifetjhini nayo isentjenziselwa ukukhuthaza ukufaka woke umuntu nokhutjhijilela imithetho yobulili,lapho abatlami benza izembatho ezigubha imizimba ehlukileko kunye nobunjalo.

==== Amahlelo athuthukisa ilutjha keze fetjhini nedizayini ====
Mhlana ama-23 kuSewula 2024,i-Inhlanyelo hub yethula ihlelo lokuthoma lokutlama i-fetjhini le-Bosadi elihlanganisa ukutlanywa kwefetjheni nokuthoma amabhizinisi.Ihlelo lokuthoma lokutlama ifetjhini le-'''Bosadi''' lenzelwe ukuqalana nesidingo lesi ngokuhlanganisa ifundo epheleleko yokutlama ifetjhini nokhubandulwa kubosomabhizinisi,okwenza bona abahlanganyeli bangakhi izambatho ezihlukileko zefetjheni kwaphela kodwana bakhe namabhizinisi asimemeko.

Nnanyana ihlelo leli lifaka hlangana abahlanganyeli beengubo nebe mbaji,liqale khulu abafundi abasesebatjha abamnyama abasikazi befetjheni,abatlami abafisako kunye nabantu abanelwazi eliyisisekelo abafisa ukwandisa amakghono wabo ekwakheni izambatho nokusungula.Isiqhema sokuthoma sehlelo lokuthoma lokhutlanywa kwefetjheni ye-'''Bosadi''' libunjwa babantu abali-15 abakhethwe ngokuveza imibono yabo yamabhizinisi ephanelini yokukhetha yebubulo le-fetjhini.

===== Abatlami be'''Sewula Afrika''' abenza kuhle ekwakheni amabhrendi wabo =====
[[Isimumathi:Thabo Makhetha - Kwinana.jpg|thumb|Thabo Mkhetha eFree State fashion week.]]


1.'''GUGU BY GUGU'''.

Ephethwe ngu-'''Gugu Peteni''' we-'''Eastern Cape''',i-'''GUGU BY GUGU''' mhlobo ozikhakhazisa ngemitlamo eyenziwe ngamunye.Umtlami owathoma umhlobo lo ngo-2020 wathoma ikhambo lakhe lefetjheni nakaneminyaka ebunane.

Njengewele bekafuna okuthileko okuzomsiza bona athole ubuntu bakhe begodu lokho lokha nakufika ifetjhini.

2.'''Fikile Sokhulu'''

Ephethwe ngu-'''Fikile Sokhulu''' umhlobo obizwa ngebizo elifanako wangena ekukhanyeni ngo-2018 ngemva kokukhethwa njengomunye wabantu abafika emaphethelweni wokufunwa kwamathalenta amatjha.

3.'''The Bam Collective'''

Yasungulwa ngu-'''Jacquaes Bam''' obegade atlama kusukela aneminyaka eli-9,isiqhema se-'''Bam''' sidzimelele ethandweni elijulileko lokhuphila kwe-'''Sewula Afrika''' nokhuthaba kwabantu bayo.

4.'''Mekhukhu'''

lisuselwa egameni lesi-'''Sotho''' elitjho bona imithlathlana '''Mekhukhu''' iphethwe ngu-'''Botshabelo Molete''' owaziwa ngemitlamo yokuphrinta engakajayeleki kunye nethando lakhe ngamaphrojekthi we-'''DIY''' afana nokusebenzisa amatjhila alahliweko ukwenza imininingwana ekhethekileko emitlameni yakhe.

====== Inkhombo ======
https://www.timeslive.co.za/sunday-times/lifestyle/fashion-and-beauty/2023-05-24-native-gennext-talks-how-the-youth-have-shaped-sas-fashion-evolution/
https://www.unisa.ac.za/sites/myunisa/default/News/Articles/Inhlanyelo-Hub-launches-fashion-design-startup-programme
https://iol.co.za/sunday-tribune/lifestyle/2024-06-05-these-16-young-designers-are-sewing-their-success-in-mzansi-with-their-fashion-labels/
https://www.thefashiondesigninstitute.com/za/en/</text>
      <sha1>at7egzduj1pslod1gz901g3ozwetae2</sha1>
    </revision>
    <revision>
      <id>3472</id>
      <parentid>3258</parentid>
      <timestamp>2025-07-29T00:20:13Z</timestamp>
      <contributor>
        <username>Dcljr</username>
        <id>20</id>
      </contributor>
      <comment>remove redundant section heading and use normal level-2 sections (==)</comment>
      <origin>3472</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4026" sha1="lyjnthcxkw8zgbhyqdvflkgrzj1ome8" xml:space="preserve">[[Isimumathi:Youth, a narrative, and two other stories (IA youthnarrativetw00conrrich).pdf|thumb|abantu abatjha kwezokutlama nefetjheni]]
'''Ilutjha''' le'''Sewula Afrika''' lidlala indima ekulu ekubumbeni ubujamo befetjhini nokutlama.Bamukela amagugu wabo,baveza ubuntu babo begodu bakhuthaza ukusimama ngokusebenzisa imitlamo yabo ngesikhathi baqhuba imikhuba ezwakala ebantwini bephasi loke.Ilutjha le'''Sewula Afrika''' lifaka hlangana amaphrinti wesintu we-'''Afrika''',amatjhila kunye nezinto zokusebenza emiklameni yazo lisuka emikhubeni yefetjhini yesetjhingalanga kwaphela.

Ukutjheja amagugu lokhu kuyingcenye yomnyakazo omkhulu wokuqeda ubukoloni befetjhini ukugidinga imiklamo yendawo nokhutjhijilela umthelela wamakoloni.

== Ukulwela ifetjhini kunye nomthelela emphakathini ==
Abatlami abatjha basebenzisa ifetjhini ukutjheja iindaba zehlala kuhle nezepolotiki bafaka imilayezo engabonakaliko kodwana enamandla emitlameni yabo.Abatlami abanengi abasebatjha babeka phambili imikghwa esimemeko emsebenzini wabo,badzimelele ekutholeni izinto ezihle,izinto eziphathelene nemvelo kunye nemikghwa yokusebenza efaneleko.Ifetjhini nayo isentjenziselwa ukukhuthaza ukufaka woke umuntu nokhutjhijilela imithetho yobulili,lapho abatlami benza izembatho ezigubha imizimba ehlukileko kunye nobunjalo.

== Amahlelo athuthukisa ilutjha keze fetjhini nedizayini ==
Mhlana ama-23 kuSewula 2024,i-Inhlanyelo hub yethula ihlelo lokuthoma lokutlama i-fetjhini le-Bosadi elihlanganisa ukutlanywa kwefetjheni nokuthoma amabhizinisi.Ihlelo lokuthoma lokutlama ifetjhini le-'''Bosadi''' lenzelwe ukuqalana nesidingo lesi ngokuhlanganisa ifundo epheleleko yokutlama ifetjhini nokhubandulwa kubosomabhizinisi,okwenza bona abahlanganyeli bangakhi izambatho ezihlukileko zefetjheni kwaphela kodwana bakhe namabhizinisi asimemeko.

Nnanyana ihlelo leli lifaka hlangana abahlanganyeli beengubo nebe mbaji,liqale khulu abafundi abasesebatjha abamnyama abasikazi befetjheni,abatlami abafisako kunye nabantu abanelwazi eliyisisekelo abafisa ukwandisa amakghono wabo ekwakheni izambatho nokusungula.Isiqhema sokuthoma sehlelo lokuthoma lokhutlanywa kwefetjheni ye-'''Bosadi''' libunjwa babantu abali-15 abakhethwe ngokuveza imibono yabo yamabhizinisi ephanelini yokukhetha yebubulo le-fetjhini.

== Abatlami be'''Sewula Afrika''' abenza kuhle ekwakheni amabhrendi wabo ==
[[Isimumathi:Thabo Makhetha - Kwinana.jpg|thumb|Thabo Mkhetha eFree State fashion week.]]


1.'''GUGU BY GUGU'''.

Ephethwe ngu-'''Gugu Peteni''' we-'''Eastern Cape''',i-'''GUGU BY GUGU''' mhlobo ozikhakhazisa ngemitlamo eyenziwe ngamunye.Umtlami owathoma umhlobo lo ngo-2020 wathoma ikhambo lakhe lefetjheni nakaneminyaka ebunane.

Njengewele bekafuna okuthileko okuzomsiza bona athole ubuntu bakhe begodu lokho lokha nakufika ifetjhini.

2.'''Fikile Sokhulu'''

Ephethwe ngu-'''Fikile Sokhulu''' umhlobo obizwa ngebizo elifanako wangena ekukhanyeni ngo-2018 ngemva kokukhethwa njengomunye wabantu abafika emaphethelweni wokufunwa kwamathalenta amatjha.

3.'''The Bam Collective'''

Yasungulwa ngu-'''Jacquaes Bam''' obegade atlama kusukela aneminyaka eli-9,isiqhema se-'''Bam''' sidzimelele ethandweni elijulileko lokhuphila kwe-'''Sewula Afrika''' nokhuthaba kwabantu bayo.

4.'''Mekhukhu'''

lisuselwa egameni lesi-'''Sotho''' elitjho bona imithlathlana '''Mekhukhu''' iphethwe ngu-'''Botshabelo Molete''' owaziwa ngemitlamo yokuphrinta engakajayeleki kunye nethando lakhe ngamaphrojekthi we-'''DIY''' afana nokusebenzisa amatjhila alahliweko ukwenza imininingwana ekhethekileko emitlameni yakhe.

== Inkhombo ==
https://www.timeslive.co.za/sunday-times/lifestyle/fashion-and-beauty/2023-05-24-native-gennext-talks-how-the-youth-have-shaped-sas-fashion-evolution/
https://www.unisa.ac.za/sites/myunisa/default/News/Articles/Inhlanyelo-Hub-launches-fashion-design-startup-programme
https://iol.co.za/sunday-tribune/lifestyle/2024-06-05-these-16-young-designers-are-sewing-their-success-in-mzansi-with-their-fashion-labels/
https://www.thefashiondesigninstitute.com/za/en/</text>
      <sha1>lyjnthcxkw8zgbhyqdvflkgrzj1ome8</sha1>
    </revision>
  </page>
  <page>
    <title>Solomon Kalushi Mahlangu</title>
    <ns>0</ns>
    <id>664</id>
    <revision>
      <id>3259</id>
      <timestamp>2025-06-30T01:00:02Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <comment>Created page with &quot;[https://www.thesouthafrican.com/news/anc-pays-tribute-to-solomon-mahlangu-who-was-he/ USolomon Kalushi Mahlangu] wabelethwa mhlana amalanga ama-10 kuVelabahlinze ngomnyaka we-1956, ngobuhlanga ubuya esizweni [[:en:Southern_Ndebele_people|samaNsebele weSewula Afrika]]. Begade amlweli wekululeko yabantu begodu alilunga lehlangano ye-[[:en:History_of_the_African_National_Congress|ANC]], [[:en:UMkhonto_weSizwe|uMkhonto wesizwe]]. UMahlangu wabelethelwa endaweni yange-Doronk...&quot;</comment>
      <origin>3259</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5791" sha1="73hyh6mg8t0h93cm3htbzuwl69345uv" xml:space="preserve">[https://www.thesouthafrican.com/news/anc-pays-tribute-to-solomon-mahlangu-who-was-he/ USolomon Kalushi Mahlangu] wabelethwa mhlana amalanga ama-10 kuVelabahlinze ngomnyaka we-1956, ngobuhlanga ubuya esizweni [[:en:Southern_Ndebele_people|samaNsebele weSewula Afrika]]. Begade amlweli wekululeko yabantu begodu alilunga lehlangano ye-[[:en:History_of_the_African_National_Congress|ANC]], [[:en:UMkhonto_weSizwe|uMkhonto wesizwe]]. UMahlangu wabelethelwa endaweni yange-Doronkop e[[:en:Mpumalanga|Pumalanga]]  begodu ungewesithandathu ngakwabo.&lt;ref&gt;{{Cite web |date=2011-07-21 |title=Rhodes University hall residences renamed after Solomon Mahlangu and Hugh Masekela |url=https://www.ru.ac.za/latestnews/rhodesuniversityhallresidencesrenamedaftersolomonmahlanguandhughmaseke-1.html |access-date=2025-06-30 |website=www.ru.ac.za |language=en-US}}&lt;/ref&gt; &lt;ref&gt;{{Citation |title=Solomon Mahlangu |date=2025-06-14 |work=Wikipedia |url=https://en.wikipedia.org/w/index.php?title=Solomon_Mahlangu&amp;oldid=1295599596 |access-date=2025-06-30 |language=en}}&lt;/ref&gt;Ekufundeni kwakhe ungene isikolo semazingeni aphezulu esikolweni esibizwa bona yi-[https://wikisouthafrica.co.za/mamelodi-high-school/ Mamelodi High School] begodu isikolwesi savalwa ngebanga lemiguruguru eyayikhona ngomnyaka we-1976 ethinta i-[https://www.britannica.com/event/Soweto-uprising Soweto uprisings.] Kanti-ke ngebanga lokulwa nombuso obewukhahlumeza abantu wagwetjwa isigwebo sentambo bewabulawa mhlana amalanga asi-6 kuSihlabantangana ngomnyaka we-1979 aneminyaka ema-22 kwaphela.&lt;ref&gt;{{Citation |title=Solomon Mahlangu |date=2025-06-14 |work=Wikipedia |url=https://en.wikipedia.org/w/index.php?title=Solomon_Mahlangu&amp;oldid=1295599596 |access-date=2025-06-30 |language=en}}&lt;/ref&gt;
[[Isimumathi:SOLOMON1jpg.jpg|thumb|Solomon Kalushi Mahlangu]]
UMahlangu waya enarheni ye-[[:en:Angola|Angola]] wayokulungiselelwa ukuba lijoni begodu bekalilunga lesiqhema esibizwa bona yi-June 16 Detachment ngaphasi kwehlangano yeMK. Unobangela waleli gama kukuthi yena nabanye bebayingcenye yabafundi ebegade basemgurugurwini womnyaka we-1976. Lokhu kwenzeka ngemva kokuthi ayokubhaqa iinyanga ezisithandathu zoke e-[[:en:Mozambique|Mozambique]].&lt;ref&gt;{{Citation |title=Solomon Mahlangu |date=2025-06-14 |work=Wikipedia |url=https://en.wikipedia.org/w/index.php?title=Solomon_Mahlangu&amp;oldid=1295599596 |access-date=2025-06-30 |language=en}}&lt;/ref&gt; Ukubotjhwa nokugwetjwa kwakhe kulandela isiga esenzeka mhlana amalanga ali-13 kuMgwengweni ngomnyaka we-1967 la begade ano-George Mahlangu no-Mondy Motaung eJwanasibhege, bebeze ngesibanga sokuzokuhanganyela nenengi ukuzokukhunjulwa khona okwenzeka mhlana amalanga ali-16 kuMgwengweni bese kwathi kunjalo kwadubuleka abasebenzi ababili, badutjulwa ngu-Motaung lokha nabazama ukubalekela amapholisa nase amapholisa abasolela ngokuthile ngombana bebaphethe amabhege. Kanti enye yamabhege la yawa yaphuma isigidi se-AK47. &lt;ref&gt;{{Citation |title=Solomon Mahlangu |date=2025-06-14 |work=Wikipedia |url=https://en.wikipedia.org/w/index.php?title=Solomon_Mahlangu&amp;oldid=1295599596 |access-date=2025-06-30 |language=en}}&lt;/ref&gt;

Kwathi mhlana amalanga ali-7 kuSinyikhaba ngomnyaka we-1977 kulapho uMahlangu wathoma ukukhamba khona ikhotho, wabendwa ngamaqala wokubulala abantu ababili nanoma begade kungasuye owabadubulako begodu akhange ikhotho ivume bona uMahlangu afake isibawo seenlilo. &lt;ref&gt;{{Citation |title=Solomon Mahlangu |date=2025-06-14 |work=Wikipedia |url=https://en.wikipedia.org/w/index.php?title=Solomon_Mahlangu&amp;oldid=1295599596 |access-date=2025-06-30 |language=en}}&lt;/ref&gt; Bathi lokha nabazomlengisa uMahlangu wakhuluma amagama wakhe wokugcina asithi, &lt;nowiki&gt;''Nitjele abantu bami ngiyabahanda. Baragele phambili balwe. Iingazi zami ziyokondla umuthi ozokuthela iinthelo zekululeko.''&lt;/nowiki&gt;&lt;ref&gt;{{Cite web |title=Solomon Kalushi Mahlangu (1956 - 1979) {{!}} South African Government |url=https://www.gov.za/about-government/solomon-kalushi-mahlangu-1956-1979 |access-date=2025-06-30 |website=www.gov.za}}&lt;/ref&gt;  Kanti ke wangcwatjwa emalibeni we-Mamelodi bewafakelwa ilitje elitlowe amagama wakhe wokugcina.&lt;ref&gt;{{Citation |title=Solomon Mahlangu |date=2025-06-14 |work=Wikipedia |url=https://en.wikipedia.org/w/index.php?title=Solomon_Mahlangu&amp;oldid=1295599596 |access-date=2025-06-30 |language=en}}&lt;/ref&gt;

Ilifa likaMahlangu alithathelwa phasi, kunelitje elakhiweko njengesikhumbuzo lapha  elibizwa bona yi-Solomon Mahlangu Freedom Square e-Mamelodi .&lt;ref&gt;{{Cite web |title=Solomon Mahlangu Statue details |url=https://www.artefacts.co.za/main/Buildings/bldgframes.php?bldgid=10357 |access-date=2025-06-30 |website=www.artefacts.co.za}}&lt;/ref&gt; Indlela yePitori eyayaziwa ngokuthi yi-Hans Strijdom Drive yatlanywa ngobutjha yathiwa yi-Solomon Mahlangu Drive.&lt;ref&gt;{{Cite web |last=Content |first=Print |date=2015-08-12 |title=City loses battle over street names |url=https://www.citizen.co.za/rekord/news-headlines/2015/08/12/city-loses-battle-over-street-names/ |access-date=2025-06-30 |website=Rekord |language=en-GB}}&lt;/ref&gt; Eyunivesithi ye-Witwatersrand umakhiwo we-ofisi lokubuza nokuphatha libizwa bona yi-Solomon Mahlangu House.&lt;ref&gt;{{Citation |title=Solomon Mahlangu |date=2025-06-14 |work=Wikipedia |url=https://en.wikipedia.org/w/index.php?title=Solomon_Mahlangu&amp;oldid=1295599596 |access-date=2025-06-30 |language=en}}&lt;/ref&gt; Kanti-ke, kunefilimu elibizwa bona yiKalushi eveza umlando wakhe nokhunye okunengi, okufaka hlangana i-Solomon Kalushi Mahlangu Scholarship Fund ebhadalela abantwana bona bafunde emayunivesithi.&lt;ref&gt;{{Cite web |title=Solomon Kalushi Mahlangu Scholarship Fund |url=https://nydawebsite.azurewebsites.net/Products-Services/Solomon-Kalushi-Mahlangu-Scholarship-Fund.html |access-date=2025-06-30 |website=nydawebsite.azurewebsites.net}}&lt;/ref&gt;

== IINKOMBA ==</text>
      <sha1>73hyh6mg8t0h93cm3htbzuwl69345uv</sha1>
    </revision>
    <revision>
      <id>3260</id>
      <parentid>3259</parentid>
      <timestamp>2025-06-30T01:17:40Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <comment>Fixed reference list</comment>
      <origin>3260</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5992" sha1="8ny3ukrapoo1h1pviagwywhai161ftk" xml:space="preserve">[https://www.thesouthafrican.com/news/anc-pays-tribute-to-solomon-mahlangu-who-was-he/ USolomon Kalushi Mahlangu] wabelethwa mhlana amalanga ama-10 kuVelabahlinze ngomnyaka we-1956, ngobuhlanga ubuya esizweni [[:en:Southern_Ndebele_people|samaNsebele weSewula Afrika]]. Begade amlweli wekululeko yabantu begodu alilunga lehlangano ye-[[:en:History_of_the_African_National_Congress|ANC]], [[:en:UMkhonto_weSizwe|uMkhonto wesizwe]]. UMahlangu wabelethelwa endaweni yange-Doronkop e[[:en:Mpumalanga|Pumalanga]]  begodu ungewesithandathu ngakwabo.&lt;ref&gt;{{Cite web |date=2011-07-21 |title=Rhodes University hall residences renamed after Solomon Mahlangu and Hugh Masekela |url=https://www.ru.ac.za/latestnews/rhodesuniversityhallresidencesrenamedaftersolomonmahlanguandhughmaseke-1.html |access-date=2025-06-30 |website=www.ru.ac.za |language=en-US}}&lt;/ref&gt; &lt;ref&gt;{{Cite web |title=Solomon Kalushi Mahlangu {{!}} South African History Online |url=https://sahistory.org.za/people/solomon-kalushi-mahlangu |access-date=2025-06-30 |website=sahistory.org.za}}&lt;/ref&gt;Ekufundeni kwakhe ungene isikolo semazingeni aphezulu esikolweni esibizwa bona yi-[https://wikisouthafrica.co.za/mamelodi-high-school/ Mamelodi High School] begodu isikolwesi savalwa ngebanga lemiguruguru eyayikhona ngomnyaka we-1976 ethinta i-[https://www.britannica.com/event/Soweto-uprising Soweto uprisings.] Kanti-ke ngebanga lokulwa nombuso obewukhahlumeza abantu wagwetjwa isigwebo sentambo bewabulawa mhlana amalanga asi-6 kuSihlabantangana ngomnyaka we-1979 aneminyaka ema-22 kwaphela.&lt;ref&gt;{{Cite web |title=Solomon Kalushi Mahlangu {{!}} South African History Online |url=https://sahistory.org.za/people/solomon-kalushi-mahlangu |access-date=2025-06-30 |website=sahistory.org.za}}&lt;/ref&gt;
[[Isimumathi:SOLOMON1jpg.jpg|thumb|Solomon Kalushi Mahlangu]]
UMahlangu waya enarheni ye-[[:en:Angola|Angola]] wayokulungiselelwa ukuba lijoni begodu bekalilunga lesiqhema esibizwa bona yi-June 16 Detachment ngaphasi kwehlangano yeMK. Unobangela waleli gama kukuthi yena nabanye bebayingcenye yabafundi ebegade basemgurugurwini womnyaka we-1976. Lokhu kwenzeka ngemva kokuthi ayokubhaqa iinyanga ezisithandathu zoke e-[[:en:Mozambique|Mozambique]].&lt;ref&gt;{{Cite web |title=uMkhonto weSizwe (MK) Timeline 1961-1990 {{!}} South African History Online |url=https://sahistory.org.za/article/umkhonto-wesizwe-mk-timeline-1961-1990 |access-date=2025-06-30 |website=sahistory.org.za}}&lt;/ref&gt; Ukubotjhwa nokugwetjwa kwakhe kulandela isiga esenzeka mhlana amalanga ali-13 kuMgwengweni ngomnyaka we-1967 la begade ano-George Mahlangu no-Mondy Motaung eJwanasibhege, bebeze ngesibanga sokuzokuhanganyela nenengi ukuzokukhunjulwa khona okwenzeka mhlana amalanga ali-16 kuMgwengweni bese kwathi kunjalo kwadubuleka abasebenzi ababili, badutjulwa ngu-Motaung lokha nabazama ukubalekela amapholisa nase amapholisa abasolela ngokuthile ngombana bebaphethe amabhege. Kanti enye yamabhege la yawa yaphuma isigidi se-AK47.&lt;ref&gt;{{Cite web |title=Solomon Kalushi Mahlangu {{!}} South African History Online |url=https://sahistory.org.za/people/solomon-kalushi-mahlangu |access-date=2025-06-30 |website=sahistory.org.za}}&lt;/ref&gt;

Kwathi mhlana amalanga ali-7 kuSinyikhaba ngomnyaka we-1977 kulapho uMahlangu wathoma ukukhamba khona ikhotho, wabendwa ngamaqala wokubulala abantu ababili nanoma begade kungasuye owabadubulako begodu akhange ikhotho ivume bona uMahlangu afake isibawo seenlilo. &lt;ref&gt;{{Cite web |title=Solomon Kalushi Mahlangu (1956 - 1979) {{!}} South African Government |url=https://www.gov.za/about-government/solomon-kalushi-mahlangu-1956-1979 |access-date=2025-06-30 |website=www.gov.za}}&lt;/ref&gt; Bathi lokha nabazomlengisa uMahlangu wakhuluma amagama wakhe wokugcina asithi, &lt;nowiki&gt;''Nitjele abantu bami ngiyabahanda. Baragele phambili balwe. Iingazi zami ziyokondla umuthi ozokuthela iinthelo zekululeko.''&lt;/nowiki&gt;&lt;ref&gt;{{Cite web |title=Solomon Kalushi Mahlangu (1956 - 1979) {{!}} South African Government |url=https://www.gov.za/about-government/solomon-kalushi-mahlangu-1956-1979 |access-date=2025-06-30 |website=www.gov.za}}&lt;/ref&gt;  Kanti ke wangcwatjwa emalibeni we-Mamelodi bewafakelwa ilitje elitlowe amagama wakhe wokugcina.&lt;ref&gt;{{Cite web |last=Makhafola |first=Getrude |date=2009-02-19 |title=LOOK: Solomon Mhlangu tombstone unveiled in Mamelodi |url=https://iol.co.za/news/south-africa/gauteng/2018-07-10-look-solomon-mhlangu-tombstone-unveiled-in-mamelodi/ |access-date=2025-06-30 |website=IOL |language=en}}&lt;/ref&gt;

Ilifa likaMahlangu alithathelwa phasi, kunelitje elakhiweko njengesikhumbuzo lapha  elibizwa bona yi-Solomon Mahlangu Freedom Square e-Mamelodi .&lt;ref&gt;{{Cite web |title=Solomon Mahlangu Statue details |url=https://www.artefacts.co.za/main/Buildings/bldgframes.php?bldgid=10357 |access-date=2025-06-30 |website=www.artefacts.co.za}}&lt;/ref&gt; Indlela yePitori eyayaziwa ngokuthi yi-Hans Strijdom Drive yatlanywa ngobutjha yathiwa yi-Solomon Mahlangu Drive.&lt;ref&gt;{{Cite web |last=Content |first=Print |date=2015-08-12 |title=City loses battle over street names |url=https://www.citizen.co.za/rekord/news-headlines/2015/08/12/city-loses-battle-over-street-names/ |access-date=2025-06-30 |website=Rekord |language=en-GB}}&lt;/ref&gt; Eyunivesithi ye-Witwatersrand umakhiwo we-ofisi lokubuza nokuphatha libizwa bona yi-Solomon Mahlangu House.&lt;ref&gt;{{Cite web |title=Solomon Mahlangu House, Wits University {{!}} 011 717 1000 {{!}} Johannesburg |url=https://www.africabizinfo.com/ZA/solomon-mahlangu-house-wits-university-011-717-1000 |access-date=2025-06-30 |website=AfricaBizInfo |language=en}}&lt;/ref&gt; Kanti-ke, kunefilimu elibizwa bona yiKalushi eveza umlando wakhe nokhunye okunengi, okufaka hlangana i-Solomon Kalushi Mahlangu Scholarship Fund ebhadalela abantwana bona bafunde emayunivesithi.&lt;ref&gt;{{Cite web |title=Solomon Kalushi Mahlangu Scholarship Fund |url=https://nydawebsite.azurewebsites.net/Products-Services/Solomon-Kalushi-Mahlangu-Scholarship-Fund.html |access-date=2025-06-30 |website=nydawebsite.azurewebsites.net}}&lt;/ref&gt;</text>
      <sha1>8ny3ukrapoo1h1pviagwywhai161ftk</sha1>
    </revision>
  </page>
  <page>
    <title>AUDREY KOZWANA SKHOSANA</title>
    <ns>0</ns>
    <id>665</id>
    <revision>
      <id>3261</id>
      <timestamp>2025-06-30T03:29:15Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <comment>Created a new article</comment>
      <origin>3261</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4393" sha1="3qbwafqh3fqp5gtnyodrvmqwx5zq7qf" xml:space="preserve">[https://audreykozwana.co.za/About/ Audrey Kozwana Skhosana] owabelethwa mhlana kulilanga lokuthoma enyangeni kaRhoboyi ngomnyaka wee-2000 obuya [[:en:Southern_Ndebele_people|esizweni samaNdebele]] ungumma wakwaMahlangu. Ngamakghono nokusebenza uyimbongikazi, umlingisi, umvumi begodu ngomunye wabantu abathuthukisa ilimi nesizwe samaNdebele weSewula Afrika eenkundleni zokuthintana.&lt;ref&gt;a

{{Cite web |title=About – Audrey Kozwana |url=https://audreykozwana.co.za/About/ |access-date=2025-06-30 |website=audreykozwana.co.za |language=en}}&lt;/ref&gt; USkhosana ngokubelethwa wabelethwa bewakhulela eLuthuli ekuyindawo engaphasi kukamasipala we[https://www.thembisilehanilm.gov.za/ Thembisile Hani], e[[:en:Mpumalanga|Pumalanga.]] USkhosana wajamela isizwe samaNdebele ku[https://indoni.net/missculture.html Ndoni Miss Cultural] ngomnyaka wee-2017 begodu wavela tjhatjhalazi nakazakuba yindlovukazi yeNdoni yeSewula Afrika ngawo wona umnyaka loyo.&lt;ref&gt;{{Cite web |last=Anita |date=2018-04-18 |title=Audrey Skhosana 17, Crowned Indoni Miss Cultural 2017/18 ?? - Clipkulture |url=https://clipkulture.com/audrey-skhosana-17-crowned-indoni-miss-cultural-2017-18-%f0%9f%87%bf%f0%9f%87%a6/ |access-date=2025-06-30 |website=clipkulture.com |language=en-US}}&lt;/ref&gt; 

Uthe ngomnyaka wee-2020 wathumba ingoma ehlukanisa umnyaka, ngelimi lesiyeni kuthiwa yi-Song Of The Year emrhatjhweni we[https://www.radio-south-africa.co.za/ikwekwezi-fm Kwekwezi FM] ngengoma yakhe ethi-Ganu ganu lapha abelana khona umbhobho no-[https://slikouronlife.co.za/artist/42674 King Cube] noMega.&lt;ref&gt;{{Cite web |title=INGOMA - IKWEKWEZIFM |url=http://www.ikwekwezifm.co.za/sabc/home/ikwekwezifm/noticeboard/details?id=c1f142d8-e6eb-4dbd-a3bb-010b6921095a&amp;title=INGOMA |archive-url=http://web.archive.org/web/20220527070610/http://www.ikwekwezifm.co.za/sabc/home/ikwekwezifm/noticeboard/details?id=c1f142d8-e6eb-4dbd-a3bb-010b6921095a&amp;title=INGOMA |archive-date=2022-05-27 |access-date=2025-06-30 |website=www.ikwekwezifm.co.za |language=en}}&lt;/ref&gt; Kanti ngakho lokhu bekangathomi ukuvela emkhakheni womvumo, kodwana phambilini ukhe wasebenza no[https://slikouronlife.co.za/artist/8816 Lilow NTK] engomeni ebizwa bona yipumelelo. Kanti-ke akhange agcine lapho, ubuye waba ngomunye otsonyulwako kuma-[[:en:South_African_Traditional_Music_Awards|SATMA]] ngaphasi komkhakha wabantu abathuthukisa amalimi wabo eenkundleni zokuthintana ngomnyaka wee-2022.&lt;ref&gt;{{Cite web |title=Artist Profile {{!}} Slikouronlife |url=https://slikouronlife.co.za/artist/135254 |access-date=2025-06-30 |website=slikouronlife.co.za}}&lt;/ref&gt; Kuthe nakunjalo waba ngabanye wabavumi abafaka isandla ekwenzeni ingoma no[https://www.timeslive.co.za/news/south-africa/2021-04-19-had-i-known-i-wouldve-acted-differently-mall-manager-who-humiliated-activist-thando-mahlangu/ Thando Mahlangu] ethi Vuka Ndebele ekuyingoma eyenziwe maNdebele begodu umlayezo wengoma leyo uya emaNdebebeleni. &lt;ref&gt;{{Cite web |last=Mthimunye |first=By Bongani |title=THANDO’S SONG FOR HIS PEOPLE |url=https://www.snl24.com/dailysun/celebs/thandos-song-for-his-people-20210916 |access-date=2025-06-30 |website=Daily Sun |language=en-US}}&lt;/ref&gt; 

Hlangana namanye amaphojekthi asekelwe ngeemali yi-[https://www.nac.org.za/ NAC], iSiyarhaya yiphrojekthi kaSkhosana. Umnqopho wakhona kukuthi ikhuthaza, ilondoloza beyethula isiNdebele eenkundleni zokuthintana. Yakha amathuba walaba abanekarareko ekurhayeni iinkondlo, ikhulisa umthelela weenkondlo ngokusebenzisa amahlelo wokufunda ngokutlama begodu inikela ngomkhakha wemitlolo ohlanganiswe ngcono begodu ongatjhugulukiko eenkolweni. Kanti-ke, iphrojekthi le isungulwe ngomnyaka wee-2022.&lt;ref&gt;{{Cite web |title=Siyarhaya – We recite |url=https://siyarhaya.co.za/ |access-date=2025-06-30 |website=siyarhaya.co.za |language=en}}&lt;/ref&gt; 

Okungaphezu kwalokho, uSkhosana unedokhumentari ayigadangise ku-YouTube esele ukubukelwa kwakhona sekungaphezulu kweengidi ezine. Idokhumentari le ibizwa bona yituthuko yethelerina begodu ikhuluma ngokukhula komntwana omntazana oliNdebele. Iveza ukuthi umntazana udlula kiziphi iingaba zokukhula ukusukela lapha amncani khona ukuya la sekalungele khona ukuthi angenda. Iphothulula khulu ivunulo, umlando kanye nelimi. &lt;ref&gt;{{Cite web |title=Documentaries – Audrey Kozwana |url=https://audreykozwana.co.za/Documentaries/ |access-date=2025-06-30 |website=audreykozwana.co.za |language=en}}&lt;/ref&gt;</text>
      <sha1>3qbwafqh3fqp5gtnyodrvmqwx5zq7qf</sha1>
    </revision>
    <revision>
      <id>3262</id>
      <parentid>3261</parentid>
      <timestamp>2025-06-30T03:43:15Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <origin>3262</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4410" sha1="0l8j7mkmo4ijj164tuc3s5e3qbe08hb" xml:space="preserve">[https://audreykozwana.co.za/About/ Audrey Kozwana Skhosana] owabelethwa mhlana kulilanga lokuthoma enyangeni kaRhoboyi ngomnyaka wee-2000 obuya [[:en:Southern_Ndebele_people|esizweni samaNdebele]] ungumma wakwaMahlangu. Ngamakghono nokusebenza uyimbongikazi, umlingisi, umvumi begodu ngomunye wabantu abathuthukisa ilimi nesizwe samaNdebele weSewula Afrika eenkundleni zokuthintana.&lt;ref&gt;a

{{Cite web |title=About – Audrey Kozwana |url=https://audreykozwana.co.za/About/ |access-date=2025-06-30 |website=audreykozwana.co.za |language=en}}&lt;/ref&gt; USkhosana ngokubelethwa wabelethwa bewakhulela eLuthuli ekuyindawo engaphasi kukamasipala we[https://www.thembisilehanilm.gov.za/ Thembisile Hani], e[[:en:Mpumalanga|Pumalanga.]] USkhosana wajamela isizwe samaNdebele ku[https://indoni.net/missculture.html Ndoni Miss Cultural] ngomnyaka wee-2017 begodu wavela tjhatjhalazi nakazakuba yindlovukazi yeNdoni yeSewula Afrika ngawo wona umnyaka loyo.&lt;ref&gt;{{Cite web |last=Anita |date=2018-04-18 |title=Audrey Skhosana 17, Crowned Indoni Miss Cultural 2017/18 ?? - Clipkulture |url=https://clipkulture.com/audrey-skhosana-17-crowned-indoni-miss-cultural-2017-18-%f0%9f%87%bf%f0%9f%87%a6/ |access-date=2025-06-30 |website=clipkulture.com |language=en-US}}&lt;/ref&gt; 

Uthe ngomnyaka wee-2020 wathumba ingoma ehlukanisa umnyaka, ngelimi lesiyeni kuthiwa yi-Song Of The Year emrhatjhweni we[https://www.radio-south-africa.co.za/ikwekwezi-fm Kwekwezi FM] ngengoma yakhe ethi-Ganu ganu lapha abelana khona umbhobho no-[https://slikouronlife.co.za/artist/42674 King Cube] noMega.&lt;ref&gt;{{Cite web |title=INGOMA - IKWEKWEZIFM |url=http://www.ikwekwezifm.co.za/sabc/home/ikwekwezifm/noticeboard/details?id=c1f142d8-e6eb-4dbd-a3bb-010b6921095a&amp;title=INGOMA |archive-url=http://web.archive.org/web/20220527070610/http://www.ikwekwezifm.co.za/sabc/home/ikwekwezifm/noticeboard/details?id=c1f142d8-e6eb-4dbd-a3bb-010b6921095a&amp;title=INGOMA |archive-date=2022-05-27 |access-date=2025-06-30 |website=www.ikwekwezifm.co.za |language=en}}&lt;/ref&gt; Kanti ngakho lokhu bekangathomi ukuvela emkhakheni womvumo, kodwana phambilini ukhe wasebenza no[https://slikouronlife.co.za/artist/8816 Lilow NTK] engomeni ebizwa bona yipumelelo. Kanti-ke akhange agcine lapho, ubuye waba ngomunye otsonyulwako kuma-[[:en:South_African_Traditional_Music_Awards|SATMA]] ngaphasi komkhakha wabantu abathuthukisa amalimi wabo eenkundleni zokuthintana ngomnyaka wee-2022.&lt;ref&gt;{{Cite web |title=Artist Profile {{!}} Slikouronlife |url=https://slikouronlife.co.za/artist/135254 |access-date=2025-06-30 |website=slikouronlife.co.za}}&lt;/ref&gt; Kuthe nakunjalo waba ngabanye wabavumi abafaka isandla ekwenzeni ingoma no[https://www.timeslive.co.za/news/south-africa/2021-04-19-had-i-known-i-wouldve-acted-differently-mall-manager-who-humiliated-activist-thando-mahlangu/ Thando Mahlangu] ethi Vuka Ndebele ekuyingoma eyenziwe maNdebele begodu umlayezo wengoma leyo uya emaNdebebeleni. &lt;ref&gt;{{Cite web |last=Mthimunye |first=By Bongani |title=THANDO’S SONG FOR HIS PEOPLE |url=https://www.snl24.com/dailysun/celebs/thandos-song-for-his-people-20210916 |access-date=2025-06-30 |website=Daily Sun |language=en-US}}&lt;/ref&gt; 

Hlangana namanye amaphojekthi asekelwe ngeemali yi-[https://www.nac.org.za/ NAC], iSiyarhaya yiphrojekthi kaSkhosana. Umnqopho wakhona kukuthi ikhuthaza, ilondoloza beyethula isiNdebele eenkundleni zokuthintana. Yakha amathuba walaba abanekarareko ekurhayeni iinkondlo, ikhulisa umthelela weenkondlo ngokusebenzisa amahlelo wokufunda ngokutlama begodu inikela ngomkhakha wemitlolo ohlanganiswe ngcono begodu ongatjhugulukiko eenkolweni. Kanti-ke, iphrojekthi le isungulwe ngomnyaka wee-2022.&lt;ref&gt;{{Cite web |title=Siyarhaya – We recite |url=https://siyarhaya.co.za/ |access-date=2025-06-30 |website=siyarhaya.co.za |language=en}}&lt;/ref&gt; 

Okungaphezu kwalokho, uSkhosana unedokhumentari ayigadangise ku-YouTube esele ukubukelwa kwakhona sekungaphezulu kweengidi ezine. Idokhumentari le ibizwa bona yituthuko yethelerina begodu ikhuluma ngokukhula komntwana omntazana oliNdebele. Iveza ukuthi umntazana udlula kiziphi iingaba zokukhula ukusukela lapha amncani khona ukuya la sekalungele khona ukuthi angenda. Iphothulula khulu ivunulo, umlando kanye nelimi. &lt;ref&gt;{{Cite web |title=Documentaries – Audrey Kozwana |url=https://audreykozwana.co.za/Documentaries/ |access-date=2025-06-30 |website=audreykozwana.co.za |language=en}}&lt;/ref&gt; 

== IINKOMBA ==</text>
      <sha1>0l8j7mkmo4ijj164tuc3s5e3qbe08hb</sha1>
    </revision>
    <revision>
      <id>3263</id>
      <parentid>3262</parentid>
      <timestamp>2025-06-30T03:44:31Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <comment>Added an image</comment>
      <origin>3263</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4483" sha1="sfwzvvidbhtbb0ilr6bbch2mb52zu7i" xml:space="preserve">[[Isimumathi:AUDREY KOZWANA SKHOSANA.jpg|thumb|Audrey Kozwana Skhosana]]
[https://audreykozwana.co.za/About/ Audrey Kozwana Skhosana] owabelethwa mhlana kulilanga lokuthoma enyangeni kaRhoboyi ngomnyaka wee-2000 obuya [[:en:Southern_Ndebele_people|esizweni samaNdebele]] ungumma wakwaMahlangu. Ngamakghono nokusebenza uyimbongikazi, umlingisi, umvumi begodu ngomunye wabantu abathuthukisa ilimi nesizwe samaNdebele weSewula Afrika eenkundleni zokuthintana.&lt;ref&gt;a

{{Cite web |title=About – Audrey Kozwana |url=https://audreykozwana.co.za/About/ |access-date=2025-06-30 |website=audreykozwana.co.za |language=en}}&lt;/ref&gt; USkhosana ngokubelethwa wabelethwa bewakhulela eLuthuli ekuyindawo engaphasi kukamasipala we[https://www.thembisilehanilm.gov.za/ Thembisile Hani], e[[:en:Mpumalanga|Pumalanga.]] USkhosana wajamela isizwe samaNdebele ku[https://indoni.net/missculture.html Ndoni Miss Cultural] ngomnyaka wee-2017 begodu wavela tjhatjhalazi nakazakuba yindlovukazi yeNdoni yeSewula Afrika ngawo wona umnyaka loyo.&lt;ref&gt;{{Cite web |last=Anita |date=2018-04-18 |title=Audrey Skhosana 17, Crowned Indoni Miss Cultural 2017/18 ?? - Clipkulture |url=https://clipkulture.com/audrey-skhosana-17-crowned-indoni-miss-cultural-2017-18-%f0%9f%87%bf%f0%9f%87%a6/ |access-date=2025-06-30 |website=clipkulture.com |language=en-US}}&lt;/ref&gt; 

Uthe ngomnyaka wee-2020 wathumba ingoma ehlukanisa umnyaka, ngelimi lesiyeni kuthiwa yi-Song Of The Year emrhatjhweni we[https://www.radio-south-africa.co.za/ikwekwezi-fm Kwekwezi FM] ngengoma yakhe ethi-Ganu ganu lapha abelana khona umbhobho no-[https://slikouronlife.co.za/artist/42674 King Cube] noMega.&lt;ref&gt;{{Cite web |title=INGOMA - IKWEKWEZIFM |url=http://www.ikwekwezifm.co.za/sabc/home/ikwekwezifm/noticeboard/details?id=c1f142d8-e6eb-4dbd-a3bb-010b6921095a&amp;title=INGOMA |archive-url=http://web.archive.org/web/20220527070610/http://www.ikwekwezifm.co.za/sabc/home/ikwekwezifm/noticeboard/details?id=c1f142d8-e6eb-4dbd-a3bb-010b6921095a&amp;title=INGOMA |archive-date=2022-05-27 |access-date=2025-06-30 |website=www.ikwekwezifm.co.za |language=en}}&lt;/ref&gt; Kanti ngakho lokhu bekangathomi ukuvela emkhakheni womvumo, kodwana phambilini ukhe wasebenza no[https://slikouronlife.co.za/artist/8816 Lilow NTK] engomeni ebizwa bona yipumelelo. Kanti-ke akhange agcine lapho, ubuye waba ngomunye otsonyulwako kuma-[[:en:South_African_Traditional_Music_Awards|SATMA]] ngaphasi komkhakha wabantu abathuthukisa amalimi wabo eenkundleni zokuthintana ngomnyaka wee-2022.&lt;ref&gt;{{Cite web |title=Artist Profile {{!}} Slikouronlife |url=https://slikouronlife.co.za/artist/135254 |access-date=2025-06-30 |website=slikouronlife.co.za}}&lt;/ref&gt; Kuthe nakunjalo waba ngabanye wabavumi abafaka isandla ekwenzeni ingoma no[https://www.timeslive.co.za/news/south-africa/2021-04-19-had-i-known-i-wouldve-acted-differently-mall-manager-who-humiliated-activist-thando-mahlangu/ Thando Mahlangu] ethi Vuka Ndebele ekuyingoma eyenziwe maNdebele begodu umlayezo wengoma leyo uya emaNdebebeleni. &lt;ref&gt;{{Cite web |last=Mthimunye |first=By Bongani |title=THANDO’S SONG FOR HIS PEOPLE |url=https://www.snl24.com/dailysun/celebs/thandos-song-for-his-people-20210916 |access-date=2025-06-30 |website=Daily Sun |language=en-US}}&lt;/ref&gt; 

Hlangana namanye amaphojekthi asekelwe ngeemali yi-[https://www.nac.org.za/ NAC], iSiyarhaya yiphrojekthi kaSkhosana. Umnqopho wakhona kukuthi ikhuthaza, ilondoloza beyethula isiNdebele eenkundleni zokuthintana. Yakha amathuba walaba abanekarareko ekurhayeni iinkondlo, ikhulisa umthelela weenkondlo ngokusebenzisa amahlelo wokufunda ngokutlama begodu inikela ngomkhakha wemitlolo ohlanganiswe ngcono begodu ongatjhugulukiko eenkolweni. Kanti-ke, iphrojekthi le isungulwe ngomnyaka wee-2022.&lt;ref&gt;{{Cite web |title=Siyarhaya – We recite |url=https://siyarhaya.co.za/ |access-date=2025-06-30 |website=siyarhaya.co.za |language=en}}&lt;/ref&gt; 

Okungaphezu kwalokho, uSkhosana unedokhumentari ayigadangise ku-YouTube esele ukubukelwa kwakhona sekungaphezulu kweengidi ezine. Idokhumentari le ibizwa bona yituthuko yethelerina begodu ikhuluma ngokukhula komntwana omntazana oliNdebele. Iveza ukuthi umntazana udlula kiziphi iingaba zokukhula ukusukela lapha amncani khona ukuya la sekalungele khona ukuthi angenda. Iphothulula khulu ivunulo, umlando kanye nelimi. &lt;ref&gt;{{Cite web |title=Documentaries – Audrey Kozwana |url=https://audreykozwana.co.za/Documentaries/ |access-date=2025-06-30 |website=audreykozwana.co.za |language=en}}&lt;/ref&gt; 

== IINKOMBA ==</text>
      <sha1>sfwzvvidbhtbb0ilr6bbch2mb52zu7i</sha1>
    </revision>
    <revision>
      <id>5052</id>
      <parentid>3263</parentid>
      <timestamp>2025-08-07T12:54:40Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <comment>added [[Category:South Africa]] using [[Help:Gadget-HotCat|HotCat]]</comment>
      <origin>5052</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4509" sha1="ebl2e8q9ytugrhwxr6jl94s18n3mfsr" xml:space="preserve">[[Isimumathi:AUDREY KOZWANA SKHOSANA.jpg|thumb|Audrey Kozwana Skhosana]]
[https://audreykozwana.co.za/About/ Audrey Kozwana Skhosana] owabelethwa mhlana kulilanga lokuthoma enyangeni kaRhoboyi ngomnyaka wee-2000 obuya [[:en:Southern_Ndebele_people|esizweni samaNdebele]] ungumma wakwaMahlangu. Ngamakghono nokusebenza uyimbongikazi, umlingisi, umvumi begodu ngomunye wabantu abathuthukisa ilimi nesizwe samaNdebele weSewula Afrika eenkundleni zokuthintana.&lt;ref&gt;a

{{Cite web |title=About – Audrey Kozwana |url=https://audreykozwana.co.za/About/ |access-date=2025-06-30 |website=audreykozwana.co.za |language=en}}&lt;/ref&gt; USkhosana ngokubelethwa wabelethwa bewakhulela eLuthuli ekuyindawo engaphasi kukamasipala we[https://www.thembisilehanilm.gov.za/ Thembisile Hani], e[[:en:Mpumalanga|Pumalanga.]] USkhosana wajamela isizwe samaNdebele ku[https://indoni.net/missculture.html Ndoni Miss Cultural] ngomnyaka wee-2017 begodu wavela tjhatjhalazi nakazakuba yindlovukazi yeNdoni yeSewula Afrika ngawo wona umnyaka loyo.&lt;ref&gt;{{Cite web |last=Anita |date=2018-04-18 |title=Audrey Skhosana 17, Crowned Indoni Miss Cultural 2017/18 ?? - Clipkulture |url=https://clipkulture.com/audrey-skhosana-17-crowned-indoni-miss-cultural-2017-18-%f0%9f%87%bf%f0%9f%87%a6/ |access-date=2025-06-30 |website=clipkulture.com |language=en-US}}&lt;/ref&gt; 

Uthe ngomnyaka wee-2020 wathumba ingoma ehlukanisa umnyaka, ngelimi lesiyeni kuthiwa yi-Song Of The Year emrhatjhweni we[https://www.radio-south-africa.co.za/ikwekwezi-fm Kwekwezi FM] ngengoma yakhe ethi-Ganu ganu lapha abelana khona umbhobho no-[https://slikouronlife.co.za/artist/42674 King Cube] noMega.&lt;ref&gt;{{Cite web |title=INGOMA - IKWEKWEZIFM |url=http://www.ikwekwezifm.co.za/sabc/home/ikwekwezifm/noticeboard/details?id=c1f142d8-e6eb-4dbd-a3bb-010b6921095a&amp;title=INGOMA |archive-url=http://web.archive.org/web/20220527070610/http://www.ikwekwezifm.co.za/sabc/home/ikwekwezifm/noticeboard/details?id=c1f142d8-e6eb-4dbd-a3bb-010b6921095a&amp;title=INGOMA |archive-date=2022-05-27 |access-date=2025-06-30 |website=www.ikwekwezifm.co.za |language=en}}&lt;/ref&gt; Kanti ngakho lokhu bekangathomi ukuvela emkhakheni womvumo, kodwana phambilini ukhe wasebenza no[https://slikouronlife.co.za/artist/8816 Lilow NTK] engomeni ebizwa bona yipumelelo. Kanti-ke akhange agcine lapho, ubuye waba ngomunye otsonyulwako kuma-[[:en:South_African_Traditional_Music_Awards|SATMA]] ngaphasi komkhakha wabantu abathuthukisa amalimi wabo eenkundleni zokuthintana ngomnyaka wee-2022.&lt;ref&gt;{{Cite web |title=Artist Profile {{!}} Slikouronlife |url=https://slikouronlife.co.za/artist/135254 |access-date=2025-06-30 |website=slikouronlife.co.za}}&lt;/ref&gt; Kuthe nakunjalo waba ngabanye wabavumi abafaka isandla ekwenzeni ingoma no[https://www.timeslive.co.za/news/south-africa/2021-04-19-had-i-known-i-wouldve-acted-differently-mall-manager-who-humiliated-activist-thando-mahlangu/ Thando Mahlangu] ethi Vuka Ndebele ekuyingoma eyenziwe maNdebele begodu umlayezo wengoma leyo uya emaNdebebeleni. &lt;ref&gt;{{Cite web |last=Mthimunye |first=By Bongani |title=THANDO’S SONG FOR HIS PEOPLE |url=https://www.snl24.com/dailysun/celebs/thandos-song-for-his-people-20210916 |access-date=2025-06-30 |website=Daily Sun |language=en-US}}&lt;/ref&gt; 

Hlangana namanye amaphojekthi asekelwe ngeemali yi-[https://www.nac.org.za/ NAC], iSiyarhaya yiphrojekthi kaSkhosana. Umnqopho wakhona kukuthi ikhuthaza, ilondoloza beyethula isiNdebele eenkundleni zokuthintana. Yakha amathuba walaba abanekarareko ekurhayeni iinkondlo, ikhulisa umthelela weenkondlo ngokusebenzisa amahlelo wokufunda ngokutlama begodu inikela ngomkhakha wemitlolo ohlanganiswe ngcono begodu ongatjhugulukiko eenkolweni. Kanti-ke, iphrojekthi le isungulwe ngomnyaka wee-2022.&lt;ref&gt;{{Cite web |title=Siyarhaya – We recite |url=https://siyarhaya.co.za/ |access-date=2025-06-30 |website=siyarhaya.co.za |language=en}}&lt;/ref&gt; 

Okungaphezu kwalokho, uSkhosana unedokhumentari ayigadangise ku-YouTube esele ukubukelwa kwakhona sekungaphezulu kweengidi ezine. Idokhumentari le ibizwa bona yituthuko yethelerina begodu ikhuluma ngokukhula komntwana omntazana oliNdebele. Iveza ukuthi umntazana udlula kiziphi iingaba zokukhula ukusukela lapha amncani khona ukuya la sekalungele khona ukuthi angenda. Iphothulula khulu ivunulo, umlando kanye nelimi. &lt;ref&gt;{{Cite web |title=Documentaries – Audrey Kozwana |url=https://audreykozwana.co.za/Documentaries/ |access-date=2025-06-30 |website=audreykozwana.co.za |language=en}}&lt;/ref&gt; 

== IINKOMBA ==

[[Mkhakha:South Africa]]</text>
      <sha1>ebl2e8q9ytugrhwxr6jl94s18n3mfsr</sha1>
    </revision>
    <revision>
      <id>5053</id>
      <parentid>5052</parentid>
      <timestamp>2025-08-07T12:58:54Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <comment>added [[Category:ISewula Afrika]] using [[Help:Gadget-HotCat|HotCat]]</comment>
      <origin>5053</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4536" sha1="lxipbkw8okwru3pgvno5zhys3hte1te" xml:space="preserve">[[Isimumathi:AUDREY KOZWANA SKHOSANA.jpg|thumb|Audrey Kozwana Skhosana]]
[https://audreykozwana.co.za/About/ Audrey Kozwana Skhosana] owabelethwa mhlana kulilanga lokuthoma enyangeni kaRhoboyi ngomnyaka wee-2000 obuya [[:en:Southern_Ndebele_people|esizweni samaNdebele]] ungumma wakwaMahlangu. Ngamakghono nokusebenza uyimbongikazi, umlingisi, umvumi begodu ngomunye wabantu abathuthukisa ilimi nesizwe samaNdebele weSewula Afrika eenkundleni zokuthintana.&lt;ref&gt;a

{{Cite web |title=About – Audrey Kozwana |url=https://audreykozwana.co.za/About/ |access-date=2025-06-30 |website=audreykozwana.co.za |language=en}}&lt;/ref&gt; USkhosana ngokubelethwa wabelethwa bewakhulela eLuthuli ekuyindawo engaphasi kukamasipala we[https://www.thembisilehanilm.gov.za/ Thembisile Hani], e[[:en:Mpumalanga|Pumalanga.]] USkhosana wajamela isizwe samaNdebele ku[https://indoni.net/missculture.html Ndoni Miss Cultural] ngomnyaka wee-2017 begodu wavela tjhatjhalazi nakazakuba yindlovukazi yeNdoni yeSewula Afrika ngawo wona umnyaka loyo.&lt;ref&gt;{{Cite web |last=Anita |date=2018-04-18 |title=Audrey Skhosana 17, Crowned Indoni Miss Cultural 2017/18 ?? - Clipkulture |url=https://clipkulture.com/audrey-skhosana-17-crowned-indoni-miss-cultural-2017-18-%f0%9f%87%bf%f0%9f%87%a6/ |access-date=2025-06-30 |website=clipkulture.com |language=en-US}}&lt;/ref&gt; 

Uthe ngomnyaka wee-2020 wathumba ingoma ehlukanisa umnyaka, ngelimi lesiyeni kuthiwa yi-Song Of The Year emrhatjhweni we[https://www.radio-south-africa.co.za/ikwekwezi-fm Kwekwezi FM] ngengoma yakhe ethi-Ganu ganu lapha abelana khona umbhobho no-[https://slikouronlife.co.za/artist/42674 King Cube] noMega.&lt;ref&gt;{{Cite web |title=INGOMA - IKWEKWEZIFM |url=http://www.ikwekwezifm.co.za/sabc/home/ikwekwezifm/noticeboard/details?id=c1f142d8-e6eb-4dbd-a3bb-010b6921095a&amp;title=INGOMA |archive-url=http://web.archive.org/web/20220527070610/http://www.ikwekwezifm.co.za/sabc/home/ikwekwezifm/noticeboard/details?id=c1f142d8-e6eb-4dbd-a3bb-010b6921095a&amp;title=INGOMA |archive-date=2022-05-27 |access-date=2025-06-30 |website=www.ikwekwezifm.co.za |language=en}}&lt;/ref&gt; Kanti ngakho lokhu bekangathomi ukuvela emkhakheni womvumo, kodwana phambilini ukhe wasebenza no[https://slikouronlife.co.za/artist/8816 Lilow NTK] engomeni ebizwa bona yipumelelo. Kanti-ke akhange agcine lapho, ubuye waba ngomunye otsonyulwako kuma-[[:en:South_African_Traditional_Music_Awards|SATMA]] ngaphasi komkhakha wabantu abathuthukisa amalimi wabo eenkundleni zokuthintana ngomnyaka wee-2022.&lt;ref&gt;{{Cite web |title=Artist Profile {{!}} Slikouronlife |url=https://slikouronlife.co.za/artist/135254 |access-date=2025-06-30 |website=slikouronlife.co.za}}&lt;/ref&gt; Kuthe nakunjalo waba ngabanye wabavumi abafaka isandla ekwenzeni ingoma no[https://www.timeslive.co.za/news/south-africa/2021-04-19-had-i-known-i-wouldve-acted-differently-mall-manager-who-humiliated-activist-thando-mahlangu/ Thando Mahlangu] ethi Vuka Ndebele ekuyingoma eyenziwe maNdebele begodu umlayezo wengoma leyo uya emaNdebebeleni. &lt;ref&gt;{{Cite web |last=Mthimunye |first=By Bongani |title=THANDO’S SONG FOR HIS PEOPLE |url=https://www.snl24.com/dailysun/celebs/thandos-song-for-his-people-20210916 |access-date=2025-06-30 |website=Daily Sun |language=en-US}}&lt;/ref&gt; 

Hlangana namanye amaphojekthi asekelwe ngeemali yi-[https://www.nac.org.za/ NAC], iSiyarhaya yiphrojekthi kaSkhosana. Umnqopho wakhona kukuthi ikhuthaza, ilondoloza beyethula isiNdebele eenkundleni zokuthintana. Yakha amathuba walaba abanekarareko ekurhayeni iinkondlo, ikhulisa umthelela weenkondlo ngokusebenzisa amahlelo wokufunda ngokutlama begodu inikela ngomkhakha wemitlolo ohlanganiswe ngcono begodu ongatjhugulukiko eenkolweni. Kanti-ke, iphrojekthi le isungulwe ngomnyaka wee-2022.&lt;ref&gt;{{Cite web |title=Siyarhaya – We recite |url=https://siyarhaya.co.za/ |access-date=2025-06-30 |website=siyarhaya.co.za |language=en}}&lt;/ref&gt; 

Okungaphezu kwalokho, uSkhosana unedokhumentari ayigadangise ku-YouTube esele ukubukelwa kwakhona sekungaphezulu kweengidi ezine. Idokhumentari le ibizwa bona yituthuko yethelerina begodu ikhuluma ngokukhula komntwana omntazana oliNdebele. Iveza ukuthi umntazana udlula kiziphi iingaba zokukhula ukusukela lapha amncani khona ukuya la sekalungele khona ukuthi angenda. Iphothulula khulu ivunulo, umlando kanye nelimi. &lt;ref&gt;{{Cite web |title=Documentaries – Audrey Kozwana |url=https://audreykozwana.co.za/Documentaries/ |access-date=2025-06-30 |website=audreykozwana.co.za |language=en}}&lt;/ref&gt; 

== IINKOMBA ==

[[Mkhakha:South Africa]]
[[Mkhakha:ISewula Afrika]]</text>
      <sha1>lxipbkw8okwru3pgvno5zhys3hte1te</sha1>
    </revision>
    <revision>
      <id>5054</id>
      <parentid>5053</parentid>
      <timestamp>2025-08-07T12:59:57Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <comment>removed [[Category:South Africa]] using [[Help:Gadget-HotCat|HotCat]]</comment>
      <origin>5054</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4511" sha1="s4g5azb9yqai2yoe2w2iro9jsyih3p9" xml:space="preserve">[[Isimumathi:AUDREY KOZWANA SKHOSANA.jpg|thumb|Audrey Kozwana Skhosana]]
[https://audreykozwana.co.za/About/ Audrey Kozwana Skhosana] owabelethwa mhlana kulilanga lokuthoma enyangeni kaRhoboyi ngomnyaka wee-2000 obuya [[:en:Southern_Ndebele_people|esizweni samaNdebele]] ungumma wakwaMahlangu. Ngamakghono nokusebenza uyimbongikazi, umlingisi, umvumi begodu ngomunye wabantu abathuthukisa ilimi nesizwe samaNdebele weSewula Afrika eenkundleni zokuthintana.&lt;ref&gt;a

{{Cite web |title=About – Audrey Kozwana |url=https://audreykozwana.co.za/About/ |access-date=2025-06-30 |website=audreykozwana.co.za |language=en}}&lt;/ref&gt; USkhosana ngokubelethwa wabelethwa bewakhulela eLuthuli ekuyindawo engaphasi kukamasipala we[https://www.thembisilehanilm.gov.za/ Thembisile Hani], e[[:en:Mpumalanga|Pumalanga.]] USkhosana wajamela isizwe samaNdebele ku[https://indoni.net/missculture.html Ndoni Miss Cultural] ngomnyaka wee-2017 begodu wavela tjhatjhalazi nakazakuba yindlovukazi yeNdoni yeSewula Afrika ngawo wona umnyaka loyo.&lt;ref&gt;{{Cite web |last=Anita |date=2018-04-18 |title=Audrey Skhosana 17, Crowned Indoni Miss Cultural 2017/18 ?? - Clipkulture |url=https://clipkulture.com/audrey-skhosana-17-crowned-indoni-miss-cultural-2017-18-%f0%9f%87%bf%f0%9f%87%a6/ |access-date=2025-06-30 |website=clipkulture.com |language=en-US}}&lt;/ref&gt; 

Uthe ngomnyaka wee-2020 wathumba ingoma ehlukanisa umnyaka, ngelimi lesiyeni kuthiwa yi-Song Of The Year emrhatjhweni we[https://www.radio-south-africa.co.za/ikwekwezi-fm Kwekwezi FM] ngengoma yakhe ethi-Ganu ganu lapha abelana khona umbhobho no-[https://slikouronlife.co.za/artist/42674 King Cube] noMega.&lt;ref&gt;{{Cite web |title=INGOMA - IKWEKWEZIFM |url=http://www.ikwekwezifm.co.za/sabc/home/ikwekwezifm/noticeboard/details?id=c1f142d8-e6eb-4dbd-a3bb-010b6921095a&amp;title=INGOMA |archive-url=http://web.archive.org/web/20220527070610/http://www.ikwekwezifm.co.za/sabc/home/ikwekwezifm/noticeboard/details?id=c1f142d8-e6eb-4dbd-a3bb-010b6921095a&amp;title=INGOMA |archive-date=2022-05-27 |access-date=2025-06-30 |website=www.ikwekwezifm.co.za |language=en}}&lt;/ref&gt; Kanti ngakho lokhu bekangathomi ukuvela emkhakheni womvumo, kodwana phambilini ukhe wasebenza no[https://slikouronlife.co.za/artist/8816 Lilow NTK] engomeni ebizwa bona yipumelelo. Kanti-ke akhange agcine lapho, ubuye waba ngomunye otsonyulwako kuma-[[:en:South_African_Traditional_Music_Awards|SATMA]] ngaphasi komkhakha wabantu abathuthukisa amalimi wabo eenkundleni zokuthintana ngomnyaka wee-2022.&lt;ref&gt;{{Cite web |title=Artist Profile {{!}} Slikouronlife |url=https://slikouronlife.co.za/artist/135254 |access-date=2025-06-30 |website=slikouronlife.co.za}}&lt;/ref&gt; Kuthe nakunjalo waba ngabanye wabavumi abafaka isandla ekwenzeni ingoma no[https://www.timeslive.co.za/news/south-africa/2021-04-19-had-i-known-i-wouldve-acted-differently-mall-manager-who-humiliated-activist-thando-mahlangu/ Thando Mahlangu] ethi Vuka Ndebele ekuyingoma eyenziwe maNdebele begodu umlayezo wengoma leyo uya emaNdebebeleni. &lt;ref&gt;{{Cite web |last=Mthimunye |first=By Bongani |title=THANDO’S SONG FOR HIS PEOPLE |url=https://www.snl24.com/dailysun/celebs/thandos-song-for-his-people-20210916 |access-date=2025-06-30 |website=Daily Sun |language=en-US}}&lt;/ref&gt; 

Hlangana namanye amaphojekthi asekelwe ngeemali yi-[https://www.nac.org.za/ NAC], iSiyarhaya yiphrojekthi kaSkhosana. Umnqopho wakhona kukuthi ikhuthaza, ilondoloza beyethula isiNdebele eenkundleni zokuthintana. Yakha amathuba walaba abanekarareko ekurhayeni iinkondlo, ikhulisa umthelela weenkondlo ngokusebenzisa amahlelo wokufunda ngokutlama begodu inikela ngomkhakha wemitlolo ohlanganiswe ngcono begodu ongatjhugulukiko eenkolweni. Kanti-ke, iphrojekthi le isungulwe ngomnyaka wee-2022.&lt;ref&gt;{{Cite web |title=Siyarhaya – We recite |url=https://siyarhaya.co.za/ |access-date=2025-06-30 |website=siyarhaya.co.za |language=en}}&lt;/ref&gt; 

Okungaphezu kwalokho, uSkhosana unedokhumentari ayigadangise ku-YouTube esele ukubukelwa kwakhona sekungaphezulu kweengidi ezine. Idokhumentari le ibizwa bona yituthuko yethelerina begodu ikhuluma ngokukhula komntwana omntazana oliNdebele. Iveza ukuthi umntazana udlula kiziphi iingaba zokukhula ukusukela lapha amncani khona ukuya la sekalungele khona ukuthi angenda. Iphothulula khulu ivunulo, umlando kanye nelimi. &lt;ref&gt;{{Cite web |title=Documentaries – Audrey Kozwana |url=https://audreykozwana.co.za/Documentaries/ |access-date=2025-06-30 |website=audreykozwana.co.za |language=en}}&lt;/ref&gt; 

== IINKOMBA ==

[[Mkhakha:ISewula Afrika]]</text>
      <sha1>s4g5azb9yqai2yoe2w2iro9jsyih3p9</sha1>
    </revision>
    <revision>
      <id>6498</id>
      <parentid>5054</parentid>
      <timestamp>2026-05-15T19:18:09Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <origin>6498</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4521" sha1="a5e7v4x8xnhfi2rr4ewtgbi8aqona1c" xml:space="preserve">[[Isimumathi:AUDREY KOZWANA SKHOSANA.jpg|thumb|Audrey Kozwana Skhosana]]
'''U-[https://audreykozwana.co.za/About/ Audrey Kozwana Skhosana]''' owabelethwa mhlazana kulilanga lokuthoma enyangeni kaRhoboyi ngomnyaka wee-2000 obuya [[:en:Southern_Ndebele_people|esizweni samaNdebele]] ungumma wakwaMahlangu. Ngamakghono nokusebenza uyimbongikazi, umlingisi, umvumi begodu ngomunye wabantu abathuthukisa ilimi nesizwe samaNdebele weSewula Afrika eenkundleni zokuthintana.&lt;ref&gt;a

{{Cite web |title=About – Audrey Kozwana |url=https://audreykozwana.co.za/About/ |access-date=2025-06-30 |website=audreykozwana.co.za |language=en}}&lt;/ref&gt; USkhosana ngokubelethwa wabelethwa bewakhulela eLuthuli ekuyindawo engaphasi kukamasipala we[https://www.thembisilehanilm.gov.za/ Thembisile Hani], e[[:en:Mpumalanga|Pumalanga.]] USkhosana wajamela isizwe samaNdebele ku[https://indoni.net/missculture.html Ndoni Miss Cultural] ngomnyaka wee-2017 begodu wavela tjhatjhalazi nakazakuba yindlovukazi yeNdoni yeSewula Afrika ngawo wona umnyaka loyo.&lt;ref&gt;{{Cite web |last=Anita |date=2018-04-18 |title=Audrey Skhosana 17, Crowned Indoni Miss Cultural 2017/18 ?? - Clipkulture |url=https://clipkulture.com/audrey-skhosana-17-crowned-indoni-miss-cultural-2017-18-%f0%9f%87%bf%f0%9f%87%a6/ |access-date=2025-06-30 |website=clipkulture.com |language=en-US}}&lt;/ref&gt; 

Uthe ngomnyaka wee-2020 wathumba ingoma ehlukanisa umnyaka, ngelimi lesiyeni kuthiwa yi-Song Of The Year emrhatjhweni we[https://www.radio-south-africa.co.za/ikwekwezi-fm Kwekwezi FM] ngengoma yakhe ethi, Ganu Ganu lapha abelana khona umbhobho no-[https://slikouronlife.co.za/artist/42674 King Cube] noMega.&lt;ref&gt;{{Cite web |title=INGOMA - IKWEKWEZIFM |url=http://www.ikwekwezifm.co.za/sabc/home/ikwekwezifm/noticeboard/details?id=c1f142d8-e6eb-4dbd-a3bb-010b6921095a&amp;title=INGOMA |archive-url=http://web.archive.org/web/20220527070610/http://www.ikwekwezifm.co.za/sabc/home/ikwekwezifm/noticeboard/details?id=c1f142d8-e6eb-4dbd-a3bb-010b6921095a&amp;title=INGOMA |archive-date=2022-05-27 |access-date=2025-06-30 |website=www.ikwekwezifm.co.za |language=en}}&lt;/ref&gt; Kanti ngakho lokhu bekangathomi ukuvela emkhakheni womvumo, kodwana phambilini ukhe wasebenza no[https://slikouronlife.co.za/artist/8816 Lilow NTK] engomeni ebizwa bona yipumelelo. Kanti-ke akhange agcine lapho, ubuye waba ngomunye otsonyulwako kuma-[[:en:South_African_Traditional_Music_Awards|SATMA]] ngaphasi komkhakha wabantu abathuthukisa amalimi wabo eenkundleni zokuthintana ngomnyaka wee-2022.&lt;ref&gt;{{Cite web |title=Artist Profile {{!}} Slikouronlife |url=https://slikouronlife.co.za/artist/135254 |access-date=2025-06-30 |website=slikouronlife.co.za}}&lt;/ref&gt; Kuthe nakunjalo waba ngabanye babavumi abafaka isandla ekwenzeni ingoma no[https://www.timeslive.co.za/news/south-africa/2021-04-19-had-i-known-i-wouldve-acted-differently-mall-manager-who-humiliated-activist-thando-mahlangu/ Thando Mahlangu] ethi, Vuka Ndebele. Ekuyingoma eyenziwe maNdebele begodu umlayezo wengoma leyo uya emaNdebeleni. &lt;ref&gt;{{Cite web |last=Mthimunye |first=By Bongani |title=THANDO’S SONG FOR HIS PEOPLE |url=https://www.snl24.com/dailysun/celebs/thandos-song-for-his-people-20210916 |access-date=2025-06-30 |website=Daily Sun |language=en-US}}&lt;/ref&gt; 

Hlangana namanye amaphojekthi asekelwe ngeemali yi-[https://www.nac.org.za/ NAC], iSiyarhaya yiphrojekthi kaSkhosana. Umnqopho wakhona kukuthi ikhuthaza, ilondoloza beyethula isiNdebele eenkundleni zokuthintana. Yakha amathuba walaba abanekareko ekurhayeni iinkondlo, ikhulisa umthelela weenkondlo ngokusebenzisa amahlelo wokufunda ngokutlama begodu inikela ngomkhakha wemitlolo ohlanganiswe ngcono begodu ongatjhugulukiko eenkolweni. Kanti-ke, iphrojekthi le isungulwe ngomnyaka wee-2022.&lt;ref&gt;{{Cite web |title=Siyarhaya – We recite |url=https://siyarhaya.co.za/ |access-date=2025-06-30 |website=siyarhaya.co.za |language=en}}&lt;/ref&gt; 

Okungaphezu kwalokho, uSkhosana unedokhumentari ayigadangise ku-YouTube esele ukubukelwa kwakhona sekungaphezulu kweengidi ezine. Idokhumentari le ibizwa bona, yiTuthuko Yethelerina begodu ikhuluma ngokukhula komntwana omntazana oliNdebele. Iveza ukuthi umntazana udlula kiziphi iingaba zokukhula ukusukela lapha amncani khona ukuya la sekalungele khona ukuthi angenda. Iphothulula khulu ivunulo, umlando kanye nelimi. &lt;ref&gt;{{Cite web |title=Documentaries – Audrey Kozwana |url=https://audreykozwana.co.za/Documentaries/ |access-date=2025-06-30 |website=audreykozwana.co.za |language=en}}&lt;/ref&gt; 

== IINKOMBA ==

[[Mkhakha:ISewula Afrika]]</text>
      <sha1>a5e7v4x8xnhfi2rr4ewtgbi8aqona1c</sha1>
    </revision>
  </page>
  <page>
    <title>Chaeli Mycroft</title>
    <ns>0</ns>
    <id>666</id>
    <revision>
      <id>3264</id>
      <timestamp>2025-06-30T04:31:09Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1288435564|Chaeli Mycroft]]&quot;</comment>
      <origin>3264</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5478" sha1="rd57tsmiwdeazw9fkgu9nspgz7mgdw7" xml:space="preserve">
{{Infobox person|name=Michaela Mycroft|other_names=Chaeli Mycroft|birth_date={{birth date and age|1994|08|30|df=y}}|occupation=Disability rights activist}}

'''U-Michaela &quot;Chaeli&quot; Mycroft''' owabelethwa mhlana amalanga ama-30 kuRhoboyi we-1994 umlweli wekghono weSewula Afrika ophila nokukhubazeka kobuchopho othumbe i- International Children's Peace Prize ngo-2011. &lt;ref&gt;{{Cite web|url=https://kidsrights.org/longread/my-life-disability-has-never-been-seen-problem-or-burden-it-part-my-life-and-opportunity|title=In my life, disability has never been seen as a problem or a burden. It is part of my life and an opportunity to do things differently.|website=KidsRights|access-date=2019-06-23}}https://kidsrights.org/longread/my-life-disability-has-never-been-seen-problem-or-burden-it-part-my-life-and-opportunity&lt;/ref&gt; &lt;ref&gt;https://www.unicef.org/education/index_61792.html&lt;/ref&gt; Unongorwana lo yimedali unikelwa ngu-Nobel Peace Laureate u-Mairead Maguire . &lt;ref&gt;https://www.kidsrights.org/News/articleType/ArticleView/articleId/61/Winner-of-International-Childrens-Peace-Prize-2011-awarded-at-World-Summit-of-Nobel-Peace-Laureates&lt;/ref&gt;{{Failed verification|date=June 2019}}&lt;sup class=&quot;noprint Inline-Template&quot; style=&quot;white-space:nowrap;&quot;&gt;&amp;#x5B; ''&lt;nowiki&gt;&lt;span title=&quot;The material near this tag failed verification of its source citation(s). (June 2019)&quot;&gt;ukuqinisekiswa okuhlulekileko&lt;/span&gt;&lt;/nowiki&gt;'' &amp;#x5D;&lt;/sup&gt;

Ngomnyaka wee-2004 u-Mycroft oneminyaka eli-9, udadwabo u-Erin (11), u-Tarryn Terry (12), u-Justine Terry (9), no-Chelsea Terry (6) basungula ijima ebalibizwa ngokuthi yi-The Chaeli Campaign eKapa ukuze babuthelele imali yesihlalo esikhambako sika-Mycroft. &lt;ref&gt;http://chaelicampaign.co.za/&lt;/ref&gt;{{Failed verification|date=June 2019}}&lt;sup class=&quot;noprint Inline-Template&quot; style=&quot;white-space:nowrap;&quot;&gt;&amp;#x5B; ''&lt;nowiki&gt;&lt;span title=&quot;The material near this tag failed verification of its source citation(s). (June 2019)&quot;&gt;ukuqinisekiswa okuhlulekileko&lt;/span&gt;&lt;/nowiki&gt;'' &amp;#x5D;&lt;/sup&gt;{{Primary source inline|date=June 2019}} Ijimeli sele seliphethe amahlelo alikhomba athinta ipilo yabazuzi abangaphezu kwe-7,000 qobe mnyaka.{{citation needed|date=February 2017}}&lt;sup class=&quot;noprint Inline-Template Template-Fact&quot; style=&quot;white-space:nowrap;&quot;&gt;&amp;#x5B; ''&lt;nowiki&gt;&lt;span title=&quot;This claim needs references to reliable sources. (February 2017)&quot;&gt;ukudzubhula kuyatlhogeka&lt;/span&gt;&lt;/nowiki&gt;'' &amp;#x5D;&lt;/sup&gt;

Kuthi lokha ngomnyaka wee-2012, eMhlanganweni wePhasi we-Nobel Peace Laureates e-Chicago, wanikelwa iMedali ye-Peace Summit for Social Activism ngu-Nobel Peace Laureate u-FW de Klerk, egameni labo boke abavunyelwe i-Nobel Peace Laureate . &lt;ref&gt;http://www.nobelpeacesummit.com/portfolio/2012-peace-summit-medal-for-social-activism-michaela-mycroft/&lt;/ref&gt; Bese kuthi ngomnyaka wee-2013 u-Mycroft watlonyeliswa nge-World of Children (isigaba selutjha) &lt;ref&gt;https://worldofchildren.org/honoree/michaela-chaeli-mycroft/&lt;/ref&gt; ehlonipha umuntu omncani ongaphasi kweminyaka ema-21 owenze igalelo elikhulu empilweni zabanye abantwana.

Lokha mhlana amalanga ama-3 kuNobayeni ngomnyaka wee-2015, nakaneminyaka ema-21, u-Mycroft waba mumuntu omsikazi wokuthoma okhubazekileko ukukhwela [[Intaba iKilimanjaro|i-Mount Kilimanjaro]] ephasini le-Tanzania, ekuyintaba ephakeme khulu e-Afrika. Wagidinga ilanga lakhe lokubelethwa entabeni leyo. &lt;ref&gt;https://www.discoverafrica.com/teamwork/&lt;/ref&gt;{{Failed verification|date=June 2019|reason=The link goes to a section with various videos. There is no clue as to which video contains the info being cited, if any have it at all. It is not reasonable to send a reader to check 9 different videos for one citation. A better source is needed.}}&lt;sup class=&quot;noprint Inline-Template&quot; style=&quot;white-space:nowrap;&quot;&gt;&amp;#x5B; ''&lt;nowiki&gt;&lt;span title=&quot;The link goes to a section with various videos. There is no clue as to which video contains the info being cited, if any have it at all. It is not reasonable to send a reader to check 9 different videos for one citation. A better source is needed. (June 2019)&quot;&gt;ukuqinisekiswa okuhlulekileko&lt;/span&gt;&lt;/nowiki&gt;'' &amp;#x5D;&lt;/sup&gt; &lt;ref&gt;https://www.cnn.com/2015/08/26/africa/chaeli-mycroft-kilimanjaro-climb/index.html&lt;/ref&gt;

U-Mycroft wenza umlando mhlana amalanga ama-29 kuMrhayili ngomnyaka wee-2016, kanye bano-Anita Engelbrecht, ngokuba badlali bokuthoma abakhamba ngeenhlalo ezinamavili ukuqeda i -Comrades Marathon, umgijimo we-ultramarathon wamakhilomitha ama-89 hlangana ne-Pietermaritzburg ne-Durban. &lt;ref&gt;https://www.sport24.co.za/OtherSport/Athletics/South-Africa/first-wheelchair-athletes-complete-comrades-20160530&lt;/ref&gt; Lokhu bekukokuthoma emlandwini weminyaka ema-95 womnyanya lo ukuthi mdlali wesihlalo sabakhubazekileko aphumelele okwenza bona abahleli bakhuthazeke boma batjhuhulule imithetho. Abagijimi abakhamba ngeenhlalo zabakhubazekileko bebakhandelwa bona bazibandakanye. &lt;ref&gt;https://web.archive.org/web/20170222111021/http://news.comrades.com/media-releases/563-wheelchair-assisted-participants-at-2016-comrades&lt;/ref&gt;

== Iinkomba ==
&lt;references /&gt;
{{Reflist}}

== Amalinki wangaphandle ==

* {{YouTube|channel=UC7LpGqhuzS_k57SuQXAgVCg}}
* {{IMDb name|nm12006961}}
[[Mkhakha:White South African people]]
[[Mkhakha:South African women activists]]
[[Mkhakha:People with cerebral palsy]]
[[Mkhakha:South African activists with disabilities]]
[[Mkhakha:University of Cape Town alumni]]
[[Mkhakha:South African disability rights activists]]
[[Mkhakha:Living people]]
[[Mkhakha:1994 births]]</text>
      <sha1>rd57tsmiwdeazw9fkgu9nspgz7mgdw7</sha1>
    </revision>
    <revision>
      <id>3265</id>
      <parentid>3264</parentid>
      <timestamp>2025-06-30T04:34:03Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <origin>3265</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5463" sha1="3tedpt86xsa2rczb4c6dsnevvjdxbty" xml:space="preserve">
{{Infobox person|name=Michaela Mycroft|other_names=Chaeli Mycroft|birth_date={{birth date and age|1994|08|30|df=y}}|occupation=Disability rights activist}}

'''U-Michaela &quot;Chaeli&quot; Mycroft''' owabelethwa mhlana amalanga ama-30 kuRhoboyi we-1994 umlweli wekghono weSewula Afrika ophila nokukhubazeka kobuchopho othumbe i- International Children's Peace Prize ngo-2011. &lt;ref&gt;{{Cite web|url=https://kidsrights.org/longread/my-life-disability-has-never-been-seen-problem-or-burden-it-part-my-life-and-opportunity|title=In my life, disability has never been seen as a problem or a burden. It is part of my life and an opportunity to do things differently.|website=KidsRights|access-date=2019-06-23}}https://kidsrights.org/longread/my-life-disability-has-never-been-seen-problem-or-burden-it-part-my-life-and-opportunity&lt;/ref&gt; &lt;ref&gt;https://www.unicef.org/education/index_61792.html&lt;/ref&gt; Unongorwana lo yimedali unikelwa ngu-Nobel Peace Laureate u-Mairead Maguire . &lt;ref&gt;https://www.kidsrights.org/News/articleType/ArticleView/articleId/61/Winner-of-International-Childrens-Peace-Prize-2011-awarded-at-World-Summit-of-Nobel-Peace-Laureates&lt;/ref&gt;{{Failed verification|date=June 2019}}&lt;sup class=&quot;noprint Inline-Template&quot; style=&quot;white-space:nowrap;&quot;&gt;&amp;#x5B; ''&lt;nowiki&gt;&lt;span title=&quot;The material near this tag failed verification of its source citation(s). (June 2019)&quot;&gt;ukuqinisekiswa okuhlulekileko&lt;/span&gt;&lt;/nowiki&gt;'' &amp;#x5D;&lt;/sup&gt;

Ngomnyaka wee-2004 u-Mycroft oneminyaka eli-9, udadwabo u-Erin (11), u-Tarryn Terry (12), u-Justine Terry (9), no-Chelsea Terry (6) basungula ijima ebalibizwa ngokuthi yi-The Chaeli Campaign eKapa ukuze babuthelele imali yesihlalo esikhambako sika-Mycroft. &lt;ref&gt;http://chaelicampaign.co.za/&lt;/ref&gt;{{Failed verification|date=June 2019}}&lt;sup class=&quot;noprint Inline-Template&quot; style=&quot;white-space:nowrap;&quot;&gt;&amp;#x5B; ''&lt;nowiki&gt;&lt;span title=&quot;The material near this tag failed verification of its source citation(s). (June 2019)&quot;&gt;ukuqinisekiswa okuhlulekileko&lt;/span&gt;&lt;/nowiki&gt;'' &amp;#x5D;&lt;/sup&gt;{{Primary source inline|date=June 2019}} Ijimeli sele seliphethe amahlelo alikhomba athinta ipilo yabazuzi abangaphezu kwe-7,000 qobe mnyaka.{{citation needed|date=February 2017}}&lt;sup class=&quot;noprint Inline-Template Template-Fact&quot; style=&quot;white-space:nowrap;&quot;&gt;&amp;#x5B; ''&lt;nowiki&gt;&lt;span title=&quot;This claim needs references to reliable sources. (February 2017)&quot;&gt;ukudzubhula kuyatlhogeka&lt;/span&gt;&lt;/nowiki&gt;'' &amp;#x5D;&lt;/sup&gt;

Kuthi lokha ngomnyaka wee-2012, eMhlanganweni wePhasi we-Nobel Peace Laureates e-Chicago, wanikelwa iMedali ye-Peace Summit for Social Activism ngu-Nobel Peace Laureate u-FW de Klerk, egameni labo boke abavunyelwe i-Nobel Peace Laureate . &lt;ref&gt;http://www.nobelpeacesummit.com/portfolio/2012-peace-summit-medal-for-social-activism-michaela-mycroft/&lt;/ref&gt; Bese kuthi ngomnyaka wee-2013 u-Mycroft watlonyeliswa nge-World of Children (isigaba selutjha) &lt;ref&gt;https://worldofchildren.org/honoree/michaela-chaeli-mycroft/&lt;/ref&gt; ehlonipha umuntu omncani ongaphasi kweminyaka ema-21 owenze igalelo elikhulu empilweni zabanye abantwana.

Lokha mhlana amalanga ama-3 kuNobayeni ngomnyaka wee-2015, nakaneminyaka ema-21, u-Mycroft waba mumuntu omsikazi wokuthoma okhubazekileko ukukhwela [[Intaba iKilimanjaro|i-Mount Kilimanjaro]] ephasini le-Tanzania, ekuyintaba ephakeme khulu e-Afrika. Wagidinga ilanga lakhe lokubelethwa entabeni leyo. &lt;ref&gt;https://www.discoverafrica.com/teamwork/&lt;/ref&gt;{{Failed verification|date=June 2019|reason=The link goes to a section with various videos. There is no clue as to which video contains the info being cited, if any have it at all. It is not reasonable to send a reader to check 9 different videos for one citation. A better source is needed.}}&lt;sup class=&quot;noprint Inline-Template&quot; style=&quot;white-space:nowrap;&quot;&gt;&amp;#x5B; ''&lt;nowiki&gt;&lt;span title=&quot;The link goes to a section with various videos. There is no clue as to which video contains the info being cited, if any have it at all. It is not reasonable to send a reader to check 9 different videos for one citation. A better source is needed. (June 2019)&quot;&gt;ukuqinisekiswa okuhlulekileko&lt;/span&gt;&lt;/nowiki&gt;'' &amp;#x5D;&lt;/sup&gt; &lt;ref&gt;https://www.cnn.com/2015/08/26/africa/chaeli-mycroft-kilimanjaro-climb/index.html&lt;/ref&gt;

U-Mycroft wenza umlando mhlana amalanga ama-29 kuMrhayili ngomnyaka wee-2016, kanye bano-Anita Engelbrecht, ngokuba badlali bokuthoma abakhamba ngeenhlalo ezinamavili ukuqeda i -Comrades Marathon, umgijimo we-ultramarathon wamakhilomitha ama-89 hlangana ne-Pietermaritzburg ne-Durban. &lt;ref&gt;https://www.sport24.co.za/OtherSport/Athletics/South-Africa/first-wheelchair-athletes-complete-comrades-20160530&lt;/ref&gt; Lokhu bekukokuthoma emlandwini weminyaka ema-95 womnyanya lo ukuthi mdlali wesihlalo sabakhubazekileko aphumelele okwenza bona abahleli bakhuthazeke boma batjhuhulule imithetho. Abagijimi abakhamba ngeenhlalo zabakhubazekileko bebakhandelwa bona bazibandakanye. &lt;ref&gt;https://web.archive.org/web/20170222111021/http://news.comrades.com/media-releases/563-wheelchair-assisted-participants-at-2016-comrades&lt;/ref&gt;

== Iinkomba ==
{{Reflist}}

== Amalinki wangaphandle ==

* {{YouTube|channel=UC7LpGqhuzS_k57SuQXAgVCg}}
* {{IMDb name|nm12006961}}
[[Mkhakha:White South African people]]
[[Mkhakha:South African women activists]]
[[Mkhakha:People with cerebral palsy]]
[[Mkhakha:South African activists with disabilities]]
[[Mkhakha:University of Cape Town alumni]]
[[Mkhakha:South African disability rights activists]]
[[Mkhakha:Living people]]
[[Mkhakha:1994 births]]</text>
      <sha1>3tedpt86xsa2rczb4c6dsnevvjdxbty</sha1>
    </revision>
  </page>
  <page>
    <title>Iincwadi ZesiNdebele Ezitlolwe Babantu Abatjha</title>
    <ns>0</ns>
    <id>667</id>
    <revision>
      <id>3268</id>
      <timestamp>2025-06-30T12:50:20Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <comment>New article</comment>
      <origin>3268</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4408" sha1="r38utq6rrzr0ci2y3v0mrvzvrbzntnk" xml:space="preserve">'''IsiNdebele''' seSewula Afrika sinabantu abatjha abanetalende lokutlola. Abatjhaba sele kuneencwadi abazikhuphileko abantu abangathabela ukuzifunda. Indima yokutlola edlalwa babantu abatjha ithuthukisa ilimi. Nakunabantu abatlolako nabafunda iincwadi ezitloliweko, nesiNdebele naso siyathuthuka.Ngikho nje urhulumende weSewula Afrika ufuna abantu abatjha bakuthande ukutlola nokufunda iincwadi ezitloliweko. Yeke iincwadi ezilandelako ngezitlolwe babantu abatjha ngelimi lesiNdebele.

== Vukani Kusile! ==
[[Isimumathi:Vukani.png|thumb|298x298px|Incwadi ethi, &quot;Vukani! Sekusile&quot;]]
'''Incwadi''': Vukani Kusile!

'''Abatloli''': Ntando Mtshweni, Dr Lungile Mabhena, Thobile Skhosana, Given Lungile

'''Okumunyethwe yincwadi le:''' Incwadi-le libuthelelo leenkondlo, eziveza ubudisi esizithola siqalana nabo sima-Sewula Afrika. Khumbula bona ukuhlunguphazwa kwabantu bengubo kudlange komlilo wesikhotha lapha enarheni yekhethu, kanti abobaba nabo bavela barhabile bathi nathi silila sona leso isililo sokuhlunguphazwa bomma. Nanyana kunjalo, incwadi le imumethe umlayezo wokubuyisana, ithando nokuzwelana ubuhlungu. Iimbongi nofana abatloli bencwadi le, benze okusemandleni wabo bona umamukelilwazi osebujameni nanyana ngabe ngibuphi azithole sele athobekile nofana akhandeleka. Khulu khulu incwadi le, ithoba nofana ikhandela laba abalandelako: Ababhujelweko, abalahle ithemba, abagulako, abasebenzisa iindakamizwa ngokweqileko.&lt;ref name=&quot;:0&quot;&gt;Epubhlishing and Digital Displays (2025) Books, Retrieved from: https://epublishing.store/product Retrieved 30-06-2025&lt;/ref&gt;

== Ongathandwa Ngunina ==
[[Isimumathi:Ongathandwa_Ngunina.jpg|thumb|287x287px|Incwadi &quot;Ongathandwa Ngunina&quot;]]
'''Incwadi''': Thabi Mahamba

'''Abatloli''': Ongathandwa Ngunina

'''Okumunyethwe yincwadi le:''' Inoveli Ongathandwa Ngunina ikhuluma ngomntazanyana onganabudlelwano obuhle nababelethi bakhe ngebanga lemali ebhadelele iimfundo zakhe esikolweni samaziko aphakamileko esingakatloliswa emnyangweni wezefundo. Unina umkatelela bona athole umsebenzi abuyise imali enyamalele nesikolo sakhe esingasi semthethweni. Kwafika lapha umraro ukhwela intaba nababelethi bakhe nakangafumani umsebenzi.&lt;ref name=&quot;:0&quot; /&gt;

Ukuqothwa ekhabo kwasusa igodo elihlweni wafunda ukuzijamela ngezakhe zombili ngaphandle kokusunduzwa mumuntu ngamandla namkha amenzise angakufuniko. Kwafika lapha ikghono lakhe aliphiwe nguSomnini lokutlola incwadi likhanyisa umkhanyo orhelebhileko wabuyisana nomndeni wakhe khulu unina, ozange amsekele ekuthomeni bona abhadelelwe esikolweni sefundo ephakamileko.&lt;ref name=&quot;:0&quot; /&gt;

== Aziyokujama Elitjeni ==
[[Isimumathi:Aziyokujama_Elitjeni.jpg|thumb|285x285px|Incwadi ethi &quot;Aziyokujama Elitjeni&quot;]]
'''Incwadi''': Aziyokujama Elitjeni

'''Abatloli''': Nomajoni O Mahlangu

'''Okumunyethwe yincwadi le:''' Inovela le isivezela ipilo ngemva kwebanga letjhumi nambili. Kusetjenziswe umlingiswa onguThuba, umntazanyana ohlakaniphileko. Akhange aphumelele kuhle ebangeni lakhe letjhumi nambili.  Wazifumana angaphasi kwegandelelo lokuya ekholiji njengombana boke abangani bakhe baphumelele kuhle begodu baya emayunivesithi ahlukileko. Uzifumene afunda iimfundo angazithandiko ngombana begade angafuni ukubuyela esikolweni ayokubuyekeza ibanga letjhumi nambili. Okubuhlungu kukobana uzithole sele azifake emrarweni wokubhema iindakamizwa, athengisa umzimba, bewazithwala. Walinga ukurarulula umraro loyo ngokurhulula umbungu kanti ubeka ipilo yakhe engozini.&lt;ref name=&quot;:0&quot; /&gt;

== Unjengabo ==
[[Isimumathi:UNJENGABO.jpg|thumb|280x280px|Incwadi ethi, &quot;Unjengabo&quot;]]
'''Incwadi''': Unjengabo

'''Abatloli''': Sabelo Mthombeni

'''Okumunyethwe yincwadi le:''' Incwadi le, iqaliswe ebantwini abakhulu nelutjha. Nawumumuntu omkhulu, ngokufunda inwadi le, uzokuthola isifundo sokobana ufanele ubayelelise njani abasakhulako ngendlela yokuziphatha. Uthi bewunelemuko lokobana  sifanele siphilisane njani nabantu abaphila nobujamo be-''Albinism?'' Athini amalungelo wabo? '' ''Ingabe abantu abavela eenarheni zangaphandle beze lapha enarheni yeSewula Afrika bezele ukuzosakhisa nofana bezele ukutjala umonyani? Koke kumumethwe yincwadi le. Inabela  ilutjha ngobungozi elingahlangabezana nabo lokha nalisemazikweni wefundo ephakemeko kanye nokukhetha abangani. Ngikuphi okuqakathekileko phakathi kwendlela kaZimu, iindakamizwa? Namalungelo? Naku umthombo welwazi ziselele mfundi.&lt;ref name=&quot;:0&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>r38utq6rrzr0ci2y3v0mrvzvrbzntnk</sha1>
    </revision>
  </page>
  <page>
    <title>U-Zulaikha Patel</title>
    <ns>0</ns>
    <id>668</id>
    <revision>
      <id>3269</id>
      <timestamp>2025-06-30T18:35:59Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1297194442|Zulaikha Patel]]&quot;</comment>
      <origin>3269</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3794" sha1="5nyw2yy0n7xjs1ukeu4kq3ifraaegqw" xml:space="preserve">
'''U-Zulaikha Patel''' (wabelethwa ngo-2002)  mlweli wamalungelo wobuntu weSewula Afrika olwa nokubandlululwa ngokobuhlanga . Waba litshwayo lokulwa nomthethomgomo we-&lt;nowiki&gt;&lt;i&gt;Pretoria Girls High School&lt;/i&gt;&lt;/nowiki&gt; malungana neenhluthu za ambantazana abanzima ngo-2016, nakaneminyaka eli-13. Yena nalabo afunda nabo benza umtjhagalo ongabangeli ukutjhuguluka komthethomgomo wesikolo kwaphela, kodwana nophenyo ngeensolo zokubandlulula ngokobuhlanga esikolweni. Nakadzujulwako uthi: &quot;Ukungibawa bona ngitjhugulule iinhluthu zami kufana nokungibawa bona ngisule ibala lami elinzima.&quot; 

== Indaba ye-''Pretoria Girls' High School'' ==
I-''Pretoria Girls' High School'', itholakala e-Pitoli, eRiphabhliki yeSewula Afrika. Isikolo lesi sathonywa ngo-1902, begodu bekusolo kungena abantwana babamhlophe kwaphela soloko sasungulwa bekwaba ngu-1990, njengombana iimfunda zeSewula Afrika bezihlukaniswe ngaphambi kwebandlululo, kodwana kusukela ngo-1990, isikolo lesi sivulekele yoke imihlobo. Ngokuya kwe-CNN, umthetho wokuziphatha kwabentazana we-''Piretoria Girls' High'' awukhulumi ngokukhethekileko ngesihluthu esikhulu sabantu abanzima, kodwana ibeka imithetho yokuqaleka zombelele, kufaka hlangana ukubeka bona zoke iintayela zeenhluthu &quot;kufanele zibe zihle, zihlanzeke begodu zikhambisane neyunifomu yesikolo.&quot; Abotitjhere batjele abafundi bona iinhluthu zabo ze-afro &quot;zimangalisa&quot; begodu kufuze ziphungulwe. Lokho bekutjho bona iinhluthu zabantazana kufuze zi-ayinwe ziluleke namkha zibotjhwe ngemva, kodwana zingabi yi-afro.

U-Zulaikha Patel bekaphakathi kwabafundi ebebadosa phambili umtjhagalo ngokujamelana ne-''Pretoria Girls High'', ngokujamelana nomthethomgomo weenhluthu wesikolo sabantazana boke.  Abantwana abasesebatjha ebegade batjhagala basongelwa ngokubotjhwa njengombana u-Zulaikha Patel arhola umtjhagalo okuthulileko. Ividiyo ethunyelwe ku-inthanethi itjengisa u-Zulaikha Patel njengombana aqalene nonogada abathathu abahlomileko ebegade baqatjhwe baphathi besikolo ukobana baqede umtjhagalo. Ividiyo le yabanga ukuphikiswa okukhulu kwesikolwesi.

== Imiphumela yomtjhagalo ka-Zulaikha ==
Izenzo zaka-Zulaikha Patel zakhuthaza eminye imitjhagalo eSewula Afrika, e-''Lawson Brown High School'' e-Eastern Cape, kunye ne-''St. Michael's School for Girls'' e-Bloemfontein lapho ababelethi nabo bamatjha khona. Abantu ephasini loke bathoma ukwabelana ngeenthombe zama-afro wabo eenkundleni zokuthintana, ngokubambisana nabafundi bengubo be-Pretoria High School. Ukuvezwa kwabeendaba beentjhabatjhaba kwalandela. Imitjhagalo le itjengise bona ukwahlukana ngokobuhlanga kuragela phambili, nanyana ibandlululo laphela ngo-1991.

Ukuphikisa kwaka-Patel kwathoma eminye imitjhagalo namatjhuguluko. UNgqongqotjhe wezeFundo we-Gauteng, u-Panyaza Lesufi uvakatjhele i-''Pretoria Girls' High School'' ukuzokuzwa iinghonghoyilo zabafundi abanzima, ingasi ngomthethomgomo weenhluthu kwaphela, kodwana nangebandlululo esikolweni. Ukwenza isibonelo, abantazana abavunyelwa ukukhuluma amalimi we-Afrika esikolweni, kwaphela isiNgisi nofana isiBhunu. U-Patrick Gaspard, ummeli we-US eSewula Afrika, wathumela ku-Twitter wathi: &quot;Yoke imiphakathi inemithetho. Begodu kesinye isikhathi imithetho leyo inebandlululo begodu idinga ukuvezwa nokutjhikijelwa.&quot; Isibawo se-inthanethi   besinemitlikitlo engaba ma-25,000 ngelanga elilodwa. UmNyango wezeFundo we-Gauteng umise umthethomgomo weenhluthu.

== Ukutatanyiswa ==
Watatanyiswa njengomunye wabafazi abali-100 abafakwa ku--BBC ngo-2016. 

== Iincwadi ==

* {{cite book|last=Patel|first=Zulaikha|title=My Coily Crowny Hair|date=July 2021|publisher=Lingua Franca|isbn=1928535909}}
* {{cite book|last=Patel|first=Zulaikha|title=Brave Like Me!|publisher=Pan Macmillan South africa|date=2025-03-03|isbn=978-1-77999-087-7}}

== Iinkomba ==
{{Reflist}}</text>
      <sha1>5nyw2yy0n7xjs1ukeu4kq3ifraaegqw</sha1>
    </revision>
    <revision>
      <id>3270</id>
      <parentid>3269</parentid>
      <timestamp>2025-06-30T19:07:29Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <origin>3270</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4472" sha1="j4oiutn50vskpcffz9dukzxc2i7yvn9" xml:space="preserve">
'''U-Zulaikha Patel''' (wabelethwa ngo-2002)&lt;ref&gt;&quot;''BBC 100 Women 2016: Who is on the list?''&quot;. ''BBC News''. 21 November 2016. Reteived from: https://www.bbc.com/news/world-38012048 Retrieved 28 July 2019.&lt;/ref&gt;  mlweli wamalungelo wobuntu weSewula Afrika olwa nokubandlululwa ngokobuhlanga . Waba litshwayo lokulwa nomthethomgomo we-''Pretoria Girls High School'' malungana neenhluthu za ambantazana abanzima ngo-2016, nakaneminyaka eli-13. Yena nalabo afunda nabo benza umtjhagalo ongabangeli ukutjhuguluka komthethomgomo wesikolo kwaphela, kodwana nophenyo ngeensolo zokubandlulula ngokobuhlanga esikolweni. Nakadzujulwako uthi: &quot;Ukungibawa bona ngitjhugulule iinhluthu zami kufana nokungibawa bona ngisule ibala lami elinzima.&quot;&lt;ref&gt;&quot;Four South Africa women make it on BBC's 100 Women List 2016&quot;. ''YOU''. Retrieved 8 December 2016.&lt;/ref&gt;  

== Indaba Ye-''Pretoria Girls' High School'' ==
I-''Pretoria Girls' High School'', itholakala e-Pitoli, eRiphabhliki yeSewula Afrika. Isikolo lesi sathonywa ngo-1902, begodu bekusolo kungena abantwana babamhlophe kwaphela soloko sasungulwa bekwaba ngu-1990, njengombana iimfunda zeSewula Afrika bezihlukaniswe ngaphambi kwebandlululo, kodwana kusukela ngo-1990, isikolo lesi sivulekele yoke imihlobo. Ngokuya kwe-CNN, umthetho wokuziphatha kwabentazana we-''Piretoria Girls' High'' awukhulumi ngokukhethekileko ngesihluthu esikhulu sabantu abanzima, kodwana ibeka imithetho yokuqaleka zombelele, kufaka hlangana ukubeka bona zoke iintayela zeenhluthu &quot;kufanele zibe zihle, zihlanzeke begodu zikhambisane neyunifomu yesikolo.&quot; Abotitjhere batjele abafundi bona iinhluthu zabo ze-afro &quot;zimangalisa&quot; begodu kufuze ziphungulwe.&lt;ref name=&quot;:0&quot;&gt;Thabile Vilakazi, for CNN (2016) ''South African students protest against school’s alleged racist hair policy''. Retrieved from: https://edition.cnn.com/2016/08/31/africa/south-africa-school-racism/index.html Retreived on 30-06-2025&lt;/ref&gt; Lokho bekutjho bona iinhluthu zabantazana kufuze zi-ayinwe ziluleke namkha zibotjhwe ngemva, kodwana zingabi yi-afro.

U-Zulaikha Patel bekaphakathi kwabafundi ebebadosa phambili umtjhagalo ngokujamelana ne-''Pretoria Girls High'', ngokujamelana nomthethomgomo weenhluthu wesikolo sabantazana boke.&lt;ref name=&quot;:1&quot;&gt;Malgas, Natalie. &quot;Four South Africans make it on BBC's '100 Women List for 2016'&quot;. Retrieved 8 December 2016.&lt;/ref&gt;  Abantwana abasesebatjha ebegade batjhagala basongelwa ngokubotjhwa njengombana u-Zulaikha Patel arhola umtjhagalo okuthulileko. Ividiyo ethunyelwe ku-inthanethi itjengisa u-Zulaikha Patel njengombana aqalene nonogada abathathu abahlomileko ebegade baqatjhwe baphathi besikolo ukobana baqede umtjhagalo. Ividiyo le yabanga ukuphikiswa okukhulu kwesikolwesi.

== Imiphumela yomtjhagalo ka-Zulaikha ==
Izenzo zaka-Zulaikha Patel zakhuthaza eminye imitjhagalo eSewula Afrika, e-''Lawson Brown High School'' e-Eastern Cape, kunye ne-''St. Michael's School for Girls'' e-Bloemfontein lapho ababelethi nabo bamatjha khona. Abantu ephasini loke bathoma ukwabelana ngeenthombe zama-afro wabo eenkundleni zokuthintana, ngokubambisana nabafundi bengubo be-Pretoria High School. Ukuvezwa kwabeendaba beentjhabatjhaba kwalandela. Imitjhagalo le itjengise bona ukwahlukana ngokobuhlanga kuragela phambili, nanyana ibandlululo laphela ngo-1991.&lt;ref name=&quot;:0&quot; /&gt;

Ukuphikisa kwaka-Patel kwathoma eminye imitjhagalo namatjhuguluko. UNgqongqotjhe wezeFundo we-Gauteng, u-Panyaza Lesufi uvakatjhele i-''Pretoria Girls' High School'' ukuzokuzwa iinghonghoyilo zabafundi abanzima, ingasi ngomthethomgomo weenhluthu kwaphela, kodwana nangebandlululo esikolweni. Ukwenza isibonelo, abantazana abavunyelwa ukukhuluma amalimi we-Afrika esikolweni, kwaphela isiNgisi nofana isiBhunu. U-Patrick Gaspard, ummeli we-US eSewula Afrika, wathumela ku-Twitter wathi: &quot;Yoke imiphakathi inemithetho. Begodu kesinye isikhathi imithetho leyo inebandlululo begodu idinga ukuvezwa nokutjhikijelwa.&quot; Isibawo se-inthanethi   besinemitlikitlo engaba ma-25,000 ngelanga elilodwa. UmNyango wezeFundo we-Gauteng umise umthethomgomo weenhluthu.&lt;ref name=&quot;:1&quot; /&gt;

== Ukutatanyiswa ==
Watatanyiswa njengomunye wabafazi abali-100 abafakwa ku--BBC ngo-2016. 

== Iincwadi ==

* {{cite book|last=Patel|first=Zulaikha|title=My Coily Crowny Hair|date=July 2021|publisher=Lingua Franca|isbn=1928535909}}
* {{cite book|last=Patel|first=Zulaikha|title=Brave Like Me!|publisher=Pan Macmillan South africa|date=2025-03-03|isbn=978-1-77999-087-7}}

== Iinkomba ==
{{Reflist}}</text>
      <sha1>j4oiutn50vskpcffz9dukzxc2i7yvn9</sha1>
    </revision>
    <revision>
      <id>3271</id>
      <parentid>3270</parentid>
      <timestamp>2025-06-30T19:08:24Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <origin>3271</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4472" sha1="bcrrmj71ogia6ri9r1eou4vxocf4m2x" xml:space="preserve">
'''U-Zulaikha Patel''' (wabelethwa ngo-2002)&lt;ref&gt;&quot;''BBC 100 Women 2016: Who is on the list?''&quot;. ''BBC News''. 21 November 2016. Reteived from: https://www.bbc.com/news/world-38012048 Retrieved 28 July 2019.&lt;/ref&gt;  mlweli wamalungelo wobuntu weSewula Afrika olwa nokubandlululwa ngokobuhlanga . Waba litshwayo lokulwa nomthethomgomo we-''Pretoria Girls High School'' malungana neenhluthu za ambantazana abanzima ngo-2016, nakaneminyaka eli-13. Yena nalabo afunda nabo benza umtjhagalo ongabangeli ukutjhuguluka komthethomgomo wesikolo kwaphela, kodwana nophenyo ngeensolo zokubandlulula ngokobuhlanga esikolweni. Nakadzujulwako uthi: &quot;Ukungibawa bona ngitjhugulule iinhluthu zami kufana nokungibawa bona ngisule ibala lami elinzima.&quot;&lt;ref&gt;&quot;Four South Africa women make it on BBC's 100 Women List 2016&quot;. ''YOU''. Retrieved 8 December 2016.&lt;/ref&gt;  

== Indaba Ye-''Pretoria Girls' High School'' ==
I-''Pretoria Girls' High School'', itholakala e-Pitoli, eRiphabhliki yeSewula Afrika. Isikolo lesi sathonywa ngo-1902, begodu bekusolo kungena abantwana babamhlophe kwaphela soloko sasungulwa bekwaba ngu-1990, njengombana iimfunda zeSewula Afrika bezihlukaniswe ngaphambi kwebandlululo, kodwana kusukela ngo-1990, isikolo lesi sivulekele yoke imihlobo. Ngokuya kwe-CNN, umthetho wokuziphatha kwabentazana we-''Piretoria Girls' High'' awukhulumi ngokukhethekileko ngesihluthu esikhulu sabantu abanzima, kodwana ibeka imithetho yokuqaleka zombelele, kufaka hlangana ukubeka bona zoke iintayela zeenhluthu &quot;kufanele zibe zihle, zihlanzeke begodu zikhambisane neyunifomu yesikolo.&quot; Abotitjhere batjele abafundi bona iinhluthu zabo ze-afro &quot;zimangalisa&quot; begodu kufuze ziphungulwe.&lt;ref name=&quot;:0&quot;&gt;Thabile Vilakazi, for CNN (2016) ''South African students protest against school’s alleged racist hair policy''. Retrieved from: https://edition.cnn.com/2016/08/31/africa/south-africa-school-racism/index.html Retreived on 30-06-2025&lt;/ref&gt; Lokho bekutjho bona iinhluthu zabantazana kufuze zi-ayinwe ziluleke namkha zibotjhwe ngemva, kodwana zingabi yi-afro.

U-Zulaikha Patel bekaphakathi kwabafundi ebebadosa phambili umtjhagalo ngokujamelana ne-''Pretoria Girls High'', ngokujamelana nomthethomgomo weenhluthu wesikolo sabantazana boke.&lt;ref name=&quot;:1&quot;&gt;Malgas, Natalie. &quot;Four South Africans make it on BBC's '100 Women List for 2016'&quot;. Retrieved 8 December 2016.&lt;/ref&gt;  Abantwana abasesebatjha ebegade batjhagala basongelwa ngokubotjhwa njengombana u-Zulaikha Patel arhola umtjhagalo okuthulileko. Ividiyo ethunyelwe ku-inthanethi itjengisa u-Zulaikha Patel njengombana aqalene nonogada abathathu abahlomileko ebegade baqatjhwe baphathi besikolo ukobana baqede umtjhagalo. Ividiyo le yabanga ukuphikiswa okukhulu kwesikolwesi.

== Imiphumela Yomtjhagalo Ka-Zulaikha ==
Izenzo zaka-Zulaikha Patel zakhuthaza eminye imitjhagalo eSewula Afrika, e-''Lawson Brown High School'' e-Eastern Cape, kunye ne-''St. Michael's School for Girls'' e-Bloemfontein lapho ababelethi nabo bamatjha khona. Abantu ephasini loke bathoma ukwabelana ngeenthombe zama-afro wabo eenkundleni zokuthintana, ngokubambisana nabafundi bengubo be-Pretoria High School. Ukuvezwa kwabeendaba beentjhabatjhaba kwalandela. Imitjhagalo le itjengise bona ukwahlukana ngokobuhlanga kuragela phambili, nanyana ibandlululo laphela ngo-1991.&lt;ref name=&quot;:0&quot; /&gt;

Ukuphikisa kwaka-Patel kwathoma eminye imitjhagalo namatjhuguluko. UNgqongqotjhe wezeFundo we-Gauteng, u-Panyaza Lesufi uvakatjhele i-''Pretoria Girls' High School'' ukuzokuzwa iinghonghoyilo zabafundi abanzima, ingasi ngomthethomgomo weenhluthu kwaphela, kodwana nangebandlululo esikolweni. Ukwenza isibonelo, abantazana abavunyelwa ukukhuluma amalimi we-Afrika esikolweni, kwaphela isiNgisi nofana isiBhunu. U-Patrick Gaspard, ummeli we-US eSewula Afrika, wathumela ku-Twitter wathi: &quot;Yoke imiphakathi inemithetho. Begodu kesinye isikhathi imithetho leyo inebandlululo begodu idinga ukuvezwa nokutjhikijelwa.&quot; Isibawo se-inthanethi   besinemitlikitlo engaba ma-25,000 ngelanga elilodwa. UmNyango wezeFundo we-Gauteng umise umthethomgomo weenhluthu.&lt;ref name=&quot;:1&quot; /&gt;

== Ukutatanyiswa ==
Watatanyiswa njengomunye wabafazi abali-100 abafakwa ku--BBC ngo-2016. 

== Iincwadi ==

* {{cite book|last=Patel|first=Zulaikha|title=My Coily Crowny Hair|date=July 2021|publisher=Lingua Franca|isbn=1928535909}}
* {{cite book|last=Patel|first=Zulaikha|title=Brave Like Me!|publisher=Pan Macmillan South africa|date=2025-03-03|isbn=978-1-77999-087-7}}

== Iinkomba ==
{{Reflist}}</text>
      <sha1>bcrrmj71ogia6ri9r1eou4vxocf4m2x</sha1>
    </revision>
    <revision>
      <id>3272</id>
      <parentid>3271</parentid>
      <timestamp>2025-06-30T19:09:06Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <origin>3272</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4472" sha1="nm5y7vhf6plji02tt7ivke8i63efuof" xml:space="preserve">
'''U-Zulaikha Patel''' (wabelethwa ngo-2002)&lt;ref&gt;&quot;''BBC 100 Women 2016: Who is on the list?''&quot;. ''BBC News''. 21 November 2016. Reteived from: https://www.bbc.com/news/world-38012048 Retrieved 28 July 2019.&lt;/ref&gt;  mlweli wamalungelo wobuntu weSewula Afrika olwa nokubandlululwa ngokobuhlanga . Waba litshwayo lokulwa nomthethomgomo we-''Pretoria Girls High School'' malungana neenhluthu za ambantazana abanzima ngo-2016, nakaneminyaka eli-13. Yena nalabo afunda nabo benza umtjhagalo ongabangeli ukutjhuguluka komthethomgomo wesikolo kwaphela, kodwana nophenyo ngeensolo zokubandlulula ngokobuhlanga esikolweni. Nakadzujulwako uthi: &quot;Ukungibawa bona ngitjhugulule iinhluthu zami kufana nokungibawa bona ngisule ibala lami elinzima.&quot;&lt;ref&gt;&quot;Four South Africa women make it on BBC's 100 Women List 2016&quot;. ''YOU''. Retrieved 8 December 2016.&lt;/ref&gt;  

== Indaba Ye-''Pretoria Girls' High School'' ==
I-''Pretoria Girls' High School'', itholakala e-Pitoli, eRiphabhliki yeSewula Afrika. Isikolo lesi sathonywa ngo-1902, begodu bekusolo kungena abantwana babamhlophe kwaphela soloko sasungulwa bekwaba ngu-1990, njengombana iimfunda zeSewula Afrika bezihlukaniswe ngaphambi kwebandlululo, kodwana kusukela ngo-1990, isikolo lesi sivulekele yoke imihlobo. Ngokuya kwe-CNN, umthetho wokuziphatha kwabentazana we-''Piretoria Girls' High'' awukhulumi ngokukhethekileko ngesihluthu esikhulu sabantu abanzima, kodwana ubeka imithetho yokuqaleka zombelele, kufaka hlangana ukubeka bona zoke iintayela zeenhluthu &quot;kufanele zibe zihle, zihlanzeke begodu zikhambisane neyunifomu yesikolo.&quot; Abotitjhere batjele abafundi bona iinhluthu zabo ze-afro &quot;zimangalisa&quot; begodu kufuze ziphungulwe.&lt;ref name=&quot;:0&quot;&gt;Thabile Vilakazi, for CNN (2016) ''South African students protest against school’s alleged racist hair policy''. Retrieved from: https://edition.cnn.com/2016/08/31/africa/south-africa-school-racism/index.html Retreived on 30-06-2025&lt;/ref&gt; Lokho bekutjho bona iinhluthu zabantazana kufuze zi-ayinwe ziluleke namkha zibotjhwe ngemva, kodwana zingabi yi-afro.

U-Zulaikha Patel bekaphakathi kwabafundi ebebadosa phambili umtjhagalo ngokujamelana ne-''Pretoria Girls High'', ngokujamelana nomthethomgomo weenhluthu wesikolo sabantazana boke.&lt;ref name=&quot;:1&quot;&gt;Malgas, Natalie. &quot;Four South Africans make it on BBC's '100 Women List for 2016'&quot;. Retrieved 8 December 2016.&lt;/ref&gt;  Abantwana abasesebatjha ebegade batjhagala basongelwa ngokubotjhwa njengombana u-Zulaikha Patel arhola umtjhagalo okuthulileko. Ividiyo ethunyelwe ku-inthanethi itjengisa u-Zulaikha Patel njengombana aqalene nonogada abathathu abahlomileko ebegade baqatjhwe baphathi besikolo ukobana baqede umtjhagalo. Ividiyo le yabanga ukuphikiswa okukhulu kwesikolwesi.

== Imiphumela Yomtjhagalo Ka-Zulaikha ==
Izenzo zaka-Zulaikha Patel zakhuthaza eminye imitjhagalo eSewula Afrika, e-''Lawson Brown High School'' e-Eastern Cape, kunye ne-''St. Michael's School for Girls'' e-Bloemfontein lapho ababelethi nabo bamatjha khona. Abantu ephasini loke bathoma ukwabelana ngeenthombe zama-afro wabo eenkundleni zokuthintana, ngokubambisana nabafundi bengubo be-Pretoria High School. Ukuvezwa kwabeendaba beentjhabatjhaba kwalandela. Imitjhagalo le itjengise bona ukwahlukana ngokobuhlanga kuragela phambili, nanyana ibandlululo laphela ngo-1991.&lt;ref name=&quot;:0&quot; /&gt;

Ukuphikisa kwaka-Patel kwathoma eminye imitjhagalo namatjhuguluko. UNgqongqotjhe wezeFundo we-Gauteng, u-Panyaza Lesufi uvakatjhele i-''Pretoria Girls' High School'' ukuzokuzwa iinghonghoyilo zabafundi abanzima, ingasi ngomthethomgomo weenhluthu kwaphela, kodwana nangebandlululo esikolweni. Ukwenza isibonelo, abantazana abavunyelwa ukukhuluma amalimi we-Afrika esikolweni, kwaphela isiNgisi nofana isiBhunu. U-Patrick Gaspard, ummeli we-US eSewula Afrika, wathumela ku-Twitter wathi: &quot;Yoke imiphakathi inemithetho. Begodu kesinye isikhathi imithetho leyo inebandlululo begodu idinga ukuvezwa nokutjhikijelwa.&quot; Isibawo se-inthanethi   besinemitlikitlo engaba ma-25,000 ngelanga elilodwa. UmNyango wezeFundo we-Gauteng umise umthethomgomo weenhluthu.&lt;ref name=&quot;:1&quot; /&gt;

== Ukutatanyiswa ==
Watatanyiswa njengomunye wabafazi abali-100 abafakwa ku--BBC ngo-2016. 

== Iincwadi ==

* {{cite book|last=Patel|first=Zulaikha|title=My Coily Crowny Hair|date=July 2021|publisher=Lingua Franca|isbn=1928535909}}
* {{cite book|last=Patel|first=Zulaikha|title=Brave Like Me!|publisher=Pan Macmillan South africa|date=2025-03-03|isbn=978-1-77999-087-7}}

== Iinkomba ==
{{Reflist}}</text>
      <sha1>nm5y7vhf6plji02tt7ivke8i63efuof</sha1>
    </revision>
    <revision>
      <id>3273</id>
      <parentid>3272</parentid>
      <timestamp>2025-06-30T19:38:01Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>3273</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4479" sha1="dob9c8m2vmjxl44faljewhg5k7k86rs" xml:space="preserve">
'''U-Zulaikha Patel''' (wabelethwa ngo-2002)&lt;ref&gt;&quot;''BBC 100 Women 2016: Who is on the list?''&quot;. ''BBC News''. 21 November 2016. Reteived from: https://www.bbc.com/news/world-38012048 Retrieved 28 July 2019.&lt;/ref&gt;  mlweli wamalungelo wobuntu weSewula Afrika olwa nokubandlululwa ngokobuhlanga . Waba litshwayo lokulwa nomthethomgomo we-''Pretoria Girls High School'' malungana neenhluthu zabantazana abanzima ngo-2016, nakaneminyaka eli-13. Yena nalabo afunda nabo benza umtjhagalo ongabangeli ukutjhuguluka komthethomgomo wesikolo kwaphela, kodwana ohlohlozela nephenyo ngeensolo zokubandlulula ngokobuhlanga esikolweni. Nakadzujulwako uthi: &quot;Ukungibawa bona ngitjhugulule iinhluthu zami kufana nokungibawa bona ngisule ibala lami elinzima.&quot;&lt;ref&gt;&quot;Four South Africa women make it on BBC's 100 Women List 2016&quot;. ''YOU''. Retrieved 8 December 2016.&lt;/ref&gt;

== Indaba Ye-''Pretoria Girls' High School'' ==
I-''Pretoria Girls' High School'', itholakala e-Pitoli, eRiphabhliki yeSewula Afrika. Isikolo lesi sathonywa ngo-1902, begodu bekusolo kungena abantwana babamhlophe kwaphela soloko sasungulwa bekwaba ngu-1990, njengombana iimfunda zeSewula Afrika bezihlukaniswe ngaphambi kwebandlululo, kodwana kusukela ngo-1990, isikolo lesi sivulekele yoke imihlobo. Ngokuya kwe-CNN, umthetho wokuziphatha kwabentazana we-''Piretoria Girls' High'' awukhulumi ngokukhethekileko ngesihluthu esikhulu sabantu abanzima, kodwana ubeka imithetho yokuqaleka zombelele, kufaka hlangana ukubeka bona zoke iintayela zeenhluthu &quot;kufanele zibe zihle, zihlanzeke begodu zikhambisane neyunifomu yesikolo.&quot; Abotitjhere batjele abafundi bona iinhluthu zabo ze-afro &quot;zimangalisa&quot; begodu kufuze ziphungulwe.&lt;ref name=&quot;:0&quot;&gt;Thabile Vilakazi, for CNN (2016) ''South African students protest against school’s alleged racist hair policy''. Retrieved from: https://edition.cnn.com/2016/08/31/africa/south-africa-school-racism/index.html Retreived on 30-06-2025&lt;/ref&gt; Lokho bekutjho bona iinhluthu zabantazana kufuze zi-ayinwe ziluleke namkha zibotjhwe ngemva, kodwana zingabi yi-afro.

U-Zulaikha Patel bekaphakathi kwabafundi ebebadosa phambili umtjhagalo ngokujamelana ne-''Pretoria Girls High'', ngokujamelana nomthethomgomo weenhluthu wesikolo sabantazana boke.&lt;ref name=&quot;:1&quot;&gt;Malgas, Natalie. &quot;Four South Africans make it on BBC's '100 Women List for 2016'&quot;. Retrieved 8 December 2016.&lt;/ref&gt;  Abantwana abasesebatjha ebegade batjhagala basongelwa ngokubotjhwa njengombana u-Zulaikha Patel arhola umtjhagalo okuthulileko. Ividiyo ethunyelwe ku-inthanethi itjengisa u-Zulaikha Patel njengombana aqalene nonogada abathathu abahlomileko ebegade baqatjhwe baphathi besikolo ukobana baqede umtjhagalo. Ividiyo le yabanga ukuphikiswa okukhulu kwesikolwesi.

== Imiphumela Yomtjhagalo Ka-Zulaikha ==
Izenzo zaka-Zulaikha Patel zakhuthaza eminye imitjhagalo eSewula Afrika, e-''Lawson Brown High School'' e-Eastern Cape, kunye ne-''St. Michael's School for Girls'' e-Bloemfontein lapho ababelethi nabo bamatjha khona. Abantu ephasini loke bathoma ukwabelana ngeenthombe zama-afro wabo eenkundleni zokuthintana, ngokubambisana nabafundi bengubo be-Pretoria High School. Ukuvezwa kwabeendaba beentjhabatjhaba kwalandela. Imitjhagalo le itjengise bona ukwahlukana ngokobuhlanga kuragela phambili, nanyana ibandlululo laphela ngo-1991.&lt;ref name=&quot;:0&quot; /&gt;

Ukuphikisa kwaka-Patel kwathoma eminye imitjhagalo namatjhuguluko. UNgqongqotjhe wezeFundo we-Gauteng, u-Panyaza Lesufi uvakatjhele i-''Pretoria Girls' High School'' ukuzokuzwa iinghonghoyilo zabafundi abanzima, ingasi ngomthethomgomo weenhluthu kwaphela, kodwana nangebandlululo esikolweni. Ukwenza isibonelo, abantazana abavunyelwa ukukhuluma amalimi we-Afrika esikolweni, kwaphela isiNgisi nofana isiBhunu. U-Patrick Gaspard, ummeli we-US eSewula Afrika, wathumela ku-Twitter wathi: &quot;Yoke imiphakathi inemithetho. Begodu kesinye isikhathi imithetho leyo inebandlululo begodu idinga ukuvezwa nokutjhikijelwa.&quot; Isibawo se-inthanethi   besinemitlikitlo engaba ma-25,000 ngelanga elilodwa. UmNyango wezeFundo we-Gauteng umise umthethomgomo weenhluthu.&lt;ref name=&quot;:1&quot; /&gt;

== Ukutatanyiswa ==
Watatanyiswa njengomunye wabafazi abali-100 abafakwa ku--BBC ngo-2016. 

== Iincwadi ==

* {{cite book|last=Patel|first=Zulaikha|title=My Coily Crowny Hair|date=July 2021|publisher=Lingua Franca|isbn=1928535909}}
* {{cite book|last=Patel|first=Zulaikha|title=Brave Like Me!|publisher=Pan Macmillan South africa|date=2025-03-03|isbn=978-1-77999-087-7}}

== Iinkomba ==
{{Reflist}}</text>
      <sha1>dob9c8m2vmjxl44faljewhg5k7k86rs</sha1>
    </revision>
    <revision>
      <id>3274</id>
      <parentid>3273</parentid>
      <timestamp>2025-07-01T21:35:20Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <origin>3274</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4567" sha1="1bnvghgmd5ta7ati8qf32xmjt29i5rp" xml:space="preserve">
'''U-Zulaikha Patel''' (wabelethwa ngo-2002)&lt;ref name=&quot;:2&quot;&gt;&quot;''BBC 100 Women 2016: Who is on the list?''&quot;. ''BBC News''. 21 November 2016. Reteived from: https://www.bbc.com/news/world-38012048 Retrieved 28 July 2019.&lt;/ref&gt;  mlweli wamalungelo wobuntu weSewula Afrika olwa nokubandlululwa ngokobuhlanga . Waba litshwayo lokulwa nomthethomgomo we-''Pretoria Girls High School'' malungana neenhluthu zabantazana abanzima ngo-2016, nakaneminyaka eli-13. Yena nalabo afunda nabo benza umtjhagalo ongabangeli ukutjhuguluka komthethomgomo wesikolo kwaphela, kodwana ohlohlozela nephenyo ngeensolo zokubandlulula ngokobuhlanga esikolweni. Nakadzujulwako uthi: &quot;Ukungibawa bona ngitjhugulule iinhluthu zami kufana nokungibawa bona ngisule ibala lami elinzima.&quot;&lt;ref&gt;&quot;Four South Africa women make it on BBC's 100 Women List 2016&quot;. ''YOU''. Retrieved 8 December 2016.&lt;/ref&gt;

== Indaba Ye-''Pretoria Girls' High School'' ==
I-''Pretoria Girls' High School'', itholakala e-Pitori, eRiphabhliki yeSewula Afrika. Isikolo lesi sathonywa ngo-1902, begodu bekusolo kungena abantwana babamhlophe kwaphela soloko sasungulwa bekwaba ngu-1990, njengombana iimfunda zeSewula Afrika bezihlukaniswe ngaphambi kwebandlululo, kodwana kusukela ngo-1990, isikolo lesi sivulekele yoke imihlobo. Ngokuya kwe-CNN, umthetho wokuziphatha kwabentazana we-''Piretoria Girls' High'' awukhulumi ngokukhethekileko ngesihluthu esikhulu sabantu abanzima, kodwana ubeka imithetho yokuqaleka zombelele, bewuyatjho nokobana zoke iintayela zeenhluthu &quot;kufanele zibe zihle, zihlanzeke begodu zikhambisane neyunifomu yesikolo.&quot; Abotitjhere batjele abafundi bona iinhluthu zabo ze-afro &quot;azikajayeleki&quot; begodu kufuze ziphungulwe.&lt;ref name=&quot;:0&quot;&gt;Thabile Vilakazi, for CNN (2016) ''South African students protest against school’s alleged racist hair policy''. Retrieved from: https://edition.cnn.com/2016/08/31/africa/south-africa-school-racism/index.html Retreived on 30-06-2025&lt;/ref&gt; Lokho bekutjho bona iinhluthu zabantazana kufuze zi-ayinwe ziluleke namkha zibotjhwe ngemva, kodwana zingabi yi-afro.

U-Zulaikha Patel bekaphakathi kwabafundi ebebadosa phambili umtjhagalo ngokujamelana ne-''Pretoria Girls High'', ngokujamelana nomthethomgomo weenhluthu wesikolo sabantazana boke.&lt;ref name=&quot;:1&quot;&gt;Malgas, Natalie. &quot;Four South Africans make it on BBC's '100 Women List for 2016'&quot;. Retrieved 8 December 2016.&lt;/ref&gt;  Abantwana abasesebatjha ebegade batjhagala basongelwa ngokubotjhwa njengombana u-Zulaikha Patel arhola umtjhagalo ngokuthula. Ividiyo ethunyelwe ku-inthanethi itjengisa u-Zulaikha Patel njengombana aqalene nonogada abathathu abahlomileko ebegade baqatjhwe baphathi besikolo ukobana baqede umtjhagalo. Ividiyo le yabanga ukuphikiswa okukhulu kwesikolwesi.

== Imiphumela Yomtjhagalo Ka-Zulaikha ==
Izenzo zaka-Zulaikha Patel zakhuthaza eminye imitjhagalo eSewula Afrika, e-''Lawson Brown High School'' e-Eastern Cape, kunye ne-''St. Michael's School for Girls'' e-Bloemfontein lapho ababelethi nabo bamatjha khona. Abantu ephasini loke bathoma ukwabelana ngeenthombe zama-afro wabo eenkundleni zokuthintana, ngokubambisana nabafundi bengubo be-Pretoria High School. Ukuvezwa kwabeendaba beentjhabatjhaba kwalandela. Imitjhagalo le itjengise bona ukwahlukana ngokobuhlanga kuragela phambili, nanyana ibandlululo laphela ngo-1991.&lt;ref name=&quot;:0&quot; /&gt;

Ukuphikisa kwaka-Patel kwathoma eminye imitjhagalo namatjhuguluko. UNgqongqotjhe wezeFundo we-Gauteng, u-Panyaza Lesufi uvakatjhele i-''Pretoria Girls' High School'' ukuzokuzwa iinghonghoyilo zabafundi abanzima, ingasi ngomthethomgomo weenhluthu kwaphela, kodwana nangebandlululo esikolweni. Ukwenza isibonelo, abantazana abavunyelwa ukukhuluma amalimi we-Afrika esikolweni, kwaphela isiNgisi nofana isiBhuru. U-Patrick Gaspard, ummeli we-US eSewula Afrika, wathumela ku-Twitter wathi: &quot;Yoke imiphakathi inemithetho. Begodu kesinye isikhathi imithetho leyo inebandlululo begodu idinga ukuvezwa ihlatjwe.&quot; Isibawo se-inthanethi   besinemitlikitlo engaba ma-25,000 ngelanga elilodwa. UmNyango wezeFundo we-Gauteng uuwujamisile umthethomgomo weenhluthu.&lt;ref name=&quot;:1&quot; /&gt;

== Ukutatanyiswa ==
U-Zulaikha Patel watatanyiswa njengomunye wabafazi abali-100 abafakwa ku--BBC ngo-2016, ngokuba nomthelela ekulwelweni kwamalungelo wobuntu.&lt;ref name=&quot;:2&quot; /&gt; 

== Iincwadi ==

* {{cite book|last=Patel|first=Zulaikha|title=My Coily Crowny Hair|date=July 2021|publisher=Lingua Franca|isbn=1928535909}}
* {{cite book|last=Patel|first=Zulaikha|title=Brave Like Me!|publisher=Pan Macmillan South africa|date=2025-03-03|isbn=978-1-77999-087-7}}

== Iinkomba ==
{{Reflist}}</text>
      <sha1>1bnvghgmd5ta7ati8qf32xmjt29i5rp</sha1>
    </revision>
    <revision>
      <id>3329</id>
      <parentid>3274</parentid>
      <timestamp>2025-07-08T11:37:37Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <comment>/* Indaba Ye-Pretoria Girls' High School */</comment>
      <origin>3329</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4568" sha1="fwjyyl0kotr0jazq4k470ge8x676h83" xml:space="preserve">
'''U-Zulaikha Patel''' (wabelethwa ngo-2002)&lt;ref name=&quot;:2&quot;&gt;&quot;''BBC 100 Women 2016: Who is on the list?''&quot;. ''BBC News''. 21 November 2016. Reteived from: https://www.bbc.com/news/world-38012048 Retrieved 28 July 2019.&lt;/ref&gt;  mlweli wamalungelo wobuntu weSewula Afrika olwa nokubandlululwa ngokobuhlanga . Waba litshwayo lokulwa nomthethomgomo we-''Pretoria Girls High School'' malungana neenhluthu zabantazana abanzima ngo-2016, nakaneminyaka eli-13. Yena nalabo afunda nabo benza umtjhagalo ongabangeli ukutjhuguluka komthethomgomo wesikolo kwaphela, kodwana ohlohlozela nephenyo ngeensolo zokubandlulula ngokobuhlanga esikolweni. Nakadzujulwako uthi: &quot;Ukungibawa bona ngitjhugulule iinhluthu zami kufana nokungibawa bona ngisule ibala lami elinzima.&quot;&lt;ref&gt;&quot;Four South Africa women make it on BBC's 100 Women List 2016&quot;. ''YOU''. Retrieved 8 December 2016.&lt;/ref&gt;

== Indaba Ye-''Pretoria Girls' High School'' ==
I-''Pretoria Girls' High School'', itholakala e-Pitori, eRiphabhliki yeSewula Afrika. Isikolo lesi sathonywa ngo-1902, begodu bekusolo kungena abantwana babamhlophe kwaphela soloko sasungulwa bekwaba ngu-1990, njengombana iimfunda zeSewula Afrika bezihlukaniswe ngaphambi kwebandlululo, kodwana kusukela ngo-1990, isikolo lesi sivulekele yoke imihlobo. Ngokuya kwe-CNN, umthetho wokuziphatha kwabentazana we-''Piretoria Girls' High'' awukhulumi ngokukhethekileko ngesihluthu esikhulu sabantu abanzima, kodwana ubeka imithetho yokuqaleka zombelele, bewuyatjho nokobana zoke iintayela zeenhluthu &quot;kufanele zibe zihle, zihlanzeke begodu zikhambisane neyunifomu yesikolo.&quot; Abotitjhere batjele abafundi bona iinhluthu zabo ze-afro &quot;azikajayeleki&quot; begodu kufuze ziphungulwe.&lt;ref name=&quot;:0&quot;&gt;Thabile Vilakazi, for CNN (2016) ''South African students protest against school’s alleged racist hair policy''. Retrieved from: https://edition.cnn.com/2016/08/31/africa/south-africa-school-racism/index.html Retreived on 30-06-2025&lt;/ref&gt; Lokho bekutjho bona iinhluthu zabantazana kufuze zi-ayinwe ziluleke namkha zibotjhwe ngemva, kodwana zingabi yi-afro.

U-Zulaikha Patel bekaphakathi kwabafundi ebebadosa phambili umtjhagalo ngokujamelana ne-''Pretoria Girls High'', ngokujamelana nomthethomgomo weenhluthu wesikolo sabantazana boke.&lt;ref name=&quot;:1&quot;&gt;Malgas, Natalie. &quot;Four South Africans make it on BBC's '100 Women List for 2016'&quot;. Retrieved 8 December 2016.&lt;/ref&gt;  Abantwana abasesebatjha ebegade batjhagala basongelwa ngokubotjhwa njengombana u-Zulaikha Patel arhola umtjhagalo ngokuthula. Ividiyo ethunyelwe ku-inthanethi itjengisa u-Zulaikha Patel njengombana aqalene nonogada abathathu abahlomileko ebegade baqatjhwe baphathi besikolo ukobana baqede umtjhagalo. Ividiyo le yabanga ukuphikiswa okukhulu kwesikolwesi. 

== Imiphumela Yomtjhagalo Ka-Zulaikha ==
Izenzo zaka-Zulaikha Patel zakhuthaza eminye imitjhagalo eSewula Afrika, e-''Lawson Brown High School'' e-Eastern Cape, kunye ne-''St. Michael's School for Girls'' e-Bloemfontein lapho ababelethi nabo bamatjha khona. Abantu ephasini loke bathoma ukwabelana ngeenthombe zama-afro wabo eenkundleni zokuthintana, ngokubambisana nabafundi bengubo be-Pretoria High School. Ukuvezwa kwabeendaba beentjhabatjhaba kwalandela. Imitjhagalo le itjengise bona ukwahlukana ngokobuhlanga kuragela phambili, nanyana ibandlululo laphela ngo-1991.&lt;ref name=&quot;:0&quot; /&gt;

Ukuphikisa kwaka-Patel kwathoma eminye imitjhagalo namatjhuguluko. UNgqongqotjhe wezeFundo we-Gauteng, u-Panyaza Lesufi uvakatjhele i-''Pretoria Girls' High School'' ukuzokuzwa iinghonghoyilo zabafundi abanzima, ingasi ngomthethomgomo weenhluthu kwaphela, kodwana nangebandlululo esikolweni. Ukwenza isibonelo, abantazana abavunyelwa ukukhuluma amalimi we-Afrika esikolweni, kwaphela isiNgisi nofana isiBhuru. U-Patrick Gaspard, ummeli we-US eSewula Afrika, wathumela ku-Twitter wathi: &quot;Yoke imiphakathi inemithetho. Begodu kesinye isikhathi imithetho leyo inebandlululo begodu idinga ukuvezwa ihlatjwe.&quot; Isibawo se-inthanethi   besinemitlikitlo engaba ma-25,000 ngelanga elilodwa. UmNyango wezeFundo we-Gauteng uuwujamisile umthethomgomo weenhluthu.&lt;ref name=&quot;:1&quot; /&gt;

== Ukutatanyiswa ==
U-Zulaikha Patel watatanyiswa njengomunye wabafazi abali-100 abafakwa ku--BBC ngo-2016, ngokuba nomthelela ekulwelweni kwamalungelo wobuntu.&lt;ref name=&quot;:2&quot; /&gt; 

== Iincwadi ==

* {{cite book|last=Patel|first=Zulaikha|title=My Coily Crowny Hair|date=July 2021|publisher=Lingua Franca|isbn=1928535909}}
* {{cite book|last=Patel|first=Zulaikha|title=Brave Like Me!|publisher=Pan Macmillan South africa|date=2025-03-03|isbn=978-1-77999-087-7}}

== Iinkomba ==
{{Reflist}}</text>
      <sha1>fwjyyl0kotr0jazq4k470ge8x676h83</sha1>
    </revision>
  </page>
  <page>
    <title>Ikhaya nendlu.</title>
    <ns>0</ns>
    <id>669</id>
    <revision>
      <id>3276</id>
      <timestamp>2025-07-02T08:23:22Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <comment>Created page with &quot;== '''Ikhaya nendlu.''' ==  === '''Isingeniso''' === Ikhaya nendlu ngezinye zezinto eziqakathekileko epilweni yomuntu. Ukungezelela, ukuqakatheka kwazo kuyahluka ebantwini ebahlukeneko. Nanyana kunjalo, abanye abantu bazithatha kwangathi zizinto ezifanako; kodwana, azifani. Ekulumenipendulwano elandeko zizokutjheja bonyana kuyini ikhaya begodu kuyini indlu.  === '''Kuyini ikhaya?''' === Ngokuya kwe[https://www.grammarly.com/commonly-confused-words/house-vs-home Grammarly...&quot;</comment>
      <origin>3276</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3169" sha1="sttu1yhbdzmnzdbgdpoj0aajvm9ys6y" xml:space="preserve">== '''Ikhaya nendlu.''' ==

=== '''Isingeniso''' ===
Ikhaya nendlu ngezinye zezinto eziqakathekileko epilweni yomuntu. Ukungezelela, ukuqakatheka kwazo kuyahluka ebantwini ebahlukeneko. Nanyana kunjalo, abanye abantu bazithatha kwangathi zizinto ezifanako; kodwana, azifani. Ekulumenipendulwano elandeko zizokutjheja bonyana kuyini ikhaya begodu kuyini indlu.

=== '''Kuyini ikhaya?''' ===
Ngokuya kwe[https://www.grammarly.com/commonly-confused-words/house-vs-home Grammarly] (2025)&lt;ref&gt;'''Grammarly'''. 2025. House vs. Home: What’s the Difference? Itholakala ku: &lt;nowiki&gt;https://www.grammarly.com/commonly-confused-words/house-vs-home&lt;/nowiki&gt;. Ifunyenwe [ngomhlaka 11 kuMgwengweni 2025].&lt;/ref&gt;, ikhaya kuyindlu leyo ehlala abantu abamndeni begodu eyenza iinkathi zekhumbulo. Iinkathi zekhumbulo lezi zifaka hlangana ubuhle nombi umndeni ohlangabenzana nakho. Ukungezelela, ikhaya linokufudumala, ithabo, ukutjhaphuluka kanye nevileko lomkhumbulo (Karjalainen 1993&lt;ref name=&quot;:0&quot;&gt;'''Karjalainen, P. T.''' 1993. House, home and the place of dwelling. ''Scandinavian Housing and Planning Research'',10(2):65-74.&lt;/ref&gt;; [https://meaningofhome.ca/entries/49272 Habitat for Humanity: Canada 2025]&lt;ref&gt;'''Habitat for Humanity: Canada.''' 2025. House vs Home. Itholakala ku: &lt;nowiki&gt;https://meaningofhome.ca/entries/49272&lt;/nowiki&gt;. Ifunyenwe [ngomhlaka 11 kuMgwengweni 2025].&lt;/ref&gt;). Ikhaya lenza abantu bonyana bajayelane begodu babumbane ngomnqopho wokuphila ngeendlela ezifanako kanye neemfundiso ezifanako (Karjalainen 1993&lt;ref name=&quot;:0&quot; /&gt;). Ezinye zeemfundiso lezi kungenzeka bonyana zisuka kibokhokho begodu zinomthelela wesiko.

=== '''Kuyini indlu?''' ===
Ngokuya kwe[https://www.britannica.com/dictionary/eb/qa/-House-and-Home- Britannica Dictionary] (2025)&lt;ref&gt;'''Britannica'''. 2025. House and Home. Itholakala ku: &lt;nowiki&gt;https://www.britannica.com/dictionary/eb/qa/-House-and-Home-&lt;/nowiki&gt;. Ifunyenwe [ngomhlaka 11 kuMgwengweni 2025].&lt;/ref&gt; indlu kumakhiwo loyo ohlala abantu nanyana umndeni othize. Ukungezelela, indlu ingahlala abantu abahlukileko abangasimndeni begodu ababuya eendaweni ezahlukileko (Perkins, uThorns noWinstanley 2008&lt;ref&gt;'''Perkins, H. C., Thorns, D. C., &amp; Winstanley, A.''' 2008. House and Home: Methodology and Methods for Exploring Meaning and Structure. Studies in Qulitative Methodology,:1-32&lt;/ref&gt;). Esikhathini esinengi, abantu abahlala lapho kungafunyaniseka bonyana baqatjhile.

=== '''Isintu sithini ngekhaya nendlu.''' ===
Ngokuya ngokwesintu, ikhaya kuyindawo ehlala abazali labo abathetheneko nanyana abatjhadileko nomndeni wabo. Kanti ngakwelinye ihlangothi, indlu kumakhiwo lapho kuhlala khona abantu abangakathathani nanyana abangakatjhadi nofana abantu abazihlaleleko. Esikhathini esinengi, imisebenzi yesintu, ayenziwa endlini, yenziwa ekhaya ngombana kuyindawo ekungenwe bekwahlala ngokomthetho wesintu.

=== '''Isiphetho.''' ===
Ikhaya nendlu kungenzeka bonyana kuthathwa njengento yinye kodwana azifani. Nanyana imisebenzi yazo ipheze ifanele nje, kukhona la zihluka khona. Begodu, isikhathi sekhumbulo, ukufudumala nevikeleko langakomkhumbulo lekhaya alifani nelendlu. 

=== '''Imithombolwazi''' ===
&lt;references /&gt;</text>
      <sha1>sttu1yhbdzmnzdbgdpoj0aajvm9ys6y</sha1>
    </revision>
    <revision>
      <id>3324</id>
      <parentid>3276</parentid>
      <timestamp>2025-07-05T16:26:11Z</timestamp>
      <contributor>
        <username>MrNinja</username>
        <id>747</id>
      </contributor>
      <comment>Ukulinganisa</comment>
      <origin>3324</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3075" sha1="deys4d1kbdqec2mmev5ml6cp29wehrw" xml:space="preserve">'''Ikhaya nendlu''' ngezinye zezinto eziqakathekileko epilweni yomuntu. Ukungezelela, ukuqakatheka kwazo kuyahluka ebantwini ebahlukeneko. Nanyana kunjalo, abanye abantu bazithatha kwangathi zizinto ezifanako; kodwana, azifani. Ekulumenipendulwano elandeko zizokutjheja bonyana kuyini ikhaya begodu kuyini indlu.

== Kuyini ikhaya? ==
Ngokuya kwe[https://www.grammarly.com/commonly-confused-words/house-vs-home Grammarly] (2025)&lt;ref&gt;'''Grammarly'''. 2025. House vs. Home: What’s the Difference? Itholakala ku: &lt;nowiki&gt;https://www.grammarly.com/commonly-confused-words/house-vs-home&lt;/nowiki&gt;. Ifunyenwe [ngomhlaka 11 kuMgwengweni 2025].&lt;/ref&gt;, ikhaya kuyindlu leyo ehlala abantu abamndeni begodu eyenza iinkathi zekhumbulo. Iinkathi zekhumbulo lezi zifaka hlangana ubuhle nombi umndeni ohlangabenzana nakho. Ukungezelela, ikhaya linokufudumala, ithabo, ukutjhaphuluka kanye nevileko lomkhumbulo (Karjalainen 1993&lt;ref name=&quot;:0&quot;&gt;'''Karjalainen, P. T.''' 1993. House, home and the place of dwelling. ''Scandinavian Housing and Planning Research'',10(2):65-74.&lt;/ref&gt;; [https://meaningofhome.ca/entries/49272 Habitat for Humanity: Canada 2025]&lt;ref&gt;'''Habitat for Humanity: Canada.''' 2025. House vs Home. Itholakala ku: &lt;nowiki&gt;https://meaningofhome.ca/entries/49272&lt;/nowiki&gt;. Ifunyenwe [ngomhlaka 11 kuMgwengweni 2025].&lt;/ref&gt;). Ikhaya lenza abantu bonyana bajayelane begodu babumbane ngomnqopho wokuphila ngeendlela ezifanako kanye neemfundiso ezifanako (Karjalainen 1993&lt;ref name=&quot;:0&quot; /&gt;). Ezinye zeemfundiso lezi kungenzeka bonyana zisuka kibokhokho begodu zinomthelela wesiko.

== Kuyini indlu? ==
Ngokuya kwe[https://www.britannica.com/dictionary/eb/qa/-House-and-Home- Britannica Dictionary] (2025)&lt;ref&gt;'''Britannica'''. 2025. House and Home. Itholakala ku: &lt;nowiki&gt;https://www.britannica.com/dictionary/eb/qa/-House-and-Home-&lt;/nowiki&gt;. Ifunyenwe [ngomhlaka 11 kuMgwengweni 2025].&lt;/ref&gt; indlu kumakhiwo loyo ohlala abantu nanyana umndeni othize. Ukungezelela, indlu ingahlala abantu abahlukileko abangasimndeni begodu ababuya eendaweni ezahlukileko (Perkins, uThorns noWinstanley 2008&lt;ref&gt;'''Perkins, H. C., Thorns, D. C., &amp; Winstanley, A.''' 2008. House and Home: Methodology and Methods for Exploring Meaning and Structure. Studies in Qulitative Methodology,:1-32&lt;/ref&gt;). Esikhathini esinengi, abantu abahlala lapho kungafunyaniseka bonyana baqatjhile.

== Isintu sithini ngekhaya nendlu. ==
Ngokuya ngokwesintu, ikhaya kuyindawo ehlala abazali labo abathetheneko nanyana abatjhadileko nomndeni wabo. Kanti ngakwelinye ihlangothi, indlu kumakhiwo lapho kuhlala khona abantu abangakathathani nanyana abangakatjhadi nofana abantu abazihlaleleko. Esikhathini esinengi, imisebenzi yesintu, ayenziwa endlini, yenziwa ekhaya ngombana kuyindawo ekungenwe bekwahlala ngokomthetho wesintu.

== Isiphetho. ==
Ikhaya nendlu kungenzeka bonyana kuthathwa njengento yinye kodwana azifani. Nanyana imisebenzi yazo ipheze ifanele nje, kukhona la zihluka khona. Begodu, isikhathi sekhumbulo, ukufudumala nevikeleko langakomkhumbulo lekhaya alifani nelendlu. 

== Izithenjwa ==
{{Reflist}}</text>
      <sha1>deys4d1kbdqec2mmev5ml6cp29wehrw</sha1>
    </revision>
  </page>
  <page>
    <title>Amakhotho weNdabuko</title>
    <ns>0</ns>
    <id>670</id>
    <revision>
      <id>3313</id>
      <timestamp>2025-07-04T07:14:47Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <comment>Created page with &quot;== '''Amakhotho weNdabuko.''' ==  === '''Isingeniso''' === [[Amakhotho wethu|Amakhotho]] wendabuko adlala indima ekulu emphakathini mayelana nokulawulwa kwabantu kanye nokulandelwa komthetho. Amakhotho wendabuko nanyana ikambiso yawo ingafani patsi namakhotho wesikhuwa; kodwana, iminqopho yona iyafana. Eenhlokwaneni ezilandelako sizokutjheja bona lokha nakukhulunywa ngamakhotho wendabuko kukhulunywa ngani begodu imisebenzi yawo iyini.  === '''Khuyini ikhotho yendabuko na...&quot;</comment>
      <origin>3313</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3894" sha1="l8idutk3iwaza6i8ojjaz8tt6t2688s" xml:space="preserve">== '''Amakhotho weNdabuko.''' ==

=== '''Isingeniso''' ===
[[Amakhotho wethu|Amakhotho]] wendabuko adlala indima ekulu emphakathini mayelana nokulawulwa kwabantu kanye nokulandelwa komthetho. Amakhotho wendabuko nanyana ikambiso yawo ingafani patsi namakhotho wesikhuwa; kodwana, iminqopho yona iyafana. Eenhlokwaneni ezilandelako sizokutjheja bona lokha nakukhulunywa ngamakhotho wendabuko kukhulunywa ngani begodu imisebenzi yawo iyini.

=== '''Khuyini ikhotho yendabuko na?''' ===
Ngokuya kukaSomaru noRautenbach (2020)&lt;ref&gt;'''Somaru, N. &amp; Rautenbach, C'''. 2020. The Indian Approach to Criminal Justice: The Role of Traditional Courts as Alternative Dispute Resolution Mechanisms''. Comparative and International Law Journal of Southern Africa'', 53(2):1-40.&lt;/ref&gt; ikhotho yendabuko yindawo leyo egunyazwe ngokomthetho wesiko lesitjhaba esithize ukuze izokuqalana nemiraro ekhona ephakathini wesitjhaba leso. Ukungezelela, amakhotho wendabuko alawulwa nanyana adoswa phambili badosiphambili bendabuko njengenduna, ikosana, iKosi nanyana iNgwenyama (Demographic Governance and Right Unit 2020&lt;ref name=&quot;:0&quot;&gt;'''Democratic Governance and Rights Unit'''. 2020. ''Assessing the Functioning of Urban Traditional Courts in South Africa''. University of Cape Town: Cape Town. &lt;/ref&gt;). Ikhotho yendabuko yaziwa khulu ngokuthi yiBandla.

Amakhotho wendabuko atholakala koke la kubusa khona abadosiphambili bendabuko ngokungakhathaleleki bonyana kusemakhaya, eengoga nanyana emadobheni (Demographic Governance and Right Unit 2020&lt;ref name=&quot;:0&quot; /&gt;). UVan Rooyen (2023)&lt;ref&gt;'''Van Rooyen, M-G.''' 2023. Legal Talk: Legislative Developments. ''Just Africa,'' 2: 8-10&lt;/ref&gt; waveza bonyana umkhandlu nanyana abalawuli bekambiso yekhotho yendabuko bangafaka hlangana induna, umdosiphambili wendabuko omkhulu, ikosi, indlovukazi kanye nengwenyama lapho kukghonakalako. Ngamanye amagama, umkhandlu olawula ikambiso nanyana ukuhlala kwamakhotho wendabuko, kufanele ufake amalunga ahlukileko nabadlalindima abahlukileko ukuze kube nokujameleka kwawo woke amahlangothi wabantu nomphakathi.

Amalunga womkhandlu wekhotho yendabuko labo alawula ukuhlala kwayo akukateleleki bonyana abe neziqu njengoba kwenziwa kumakhotho wesikhuwa (Himoga noManjoo 2009&lt;ref&gt;'''Himonga, C. &amp; Manjoo, R.''' 2009''. The Challenges of Formalisation, Regulation, and Reform of Traditional Courts in South Africa''. MLI, 3(2):157-181.&lt;/ref&gt;). Kodwana, kufanele kube babantu abanelwazi tle mayelana namasiko, ilimi, imiraro eyahlukeneko yabantu nemiphakathi (UmThetho wamaKhotho weNdabuko 2022&lt;ref name=&quot;:1&quot;&gt;'''The Presidency Department'''. 2022. ''UmTheth WamaKhotho WeNdabuko, Nom 9 ween-2022''. Ipalamende yeSewula Afrika: EKapa. &lt;/ref&gt;). Esihlokweni esilandelako sizokutjheja umsebenzi yamakhotho wendabuko.

=== '''Imisebenzi yeBandla''' ===
Imisebenzi yeBandla nanyana ikhotho yendabuko ifaka hlangana le elandelako:

1.     Ukurarulula iindaba eziphathelene nokutlhala hlangana kwemindeni embili nanyana abantu ababili (Demographic Governance and Right Unit 2020&lt;ref name=&quot;:0&quot; /&gt;)

2.     Ukulalela nokugweba endabeni nanyana iqala lobulelesi (UmThetho wamaKhotho weNdabuko 2022&lt;ref name=&quot;:1&quot; /&gt;).

3.     Ukuqalela nokuthatha isiqunto mayelana neqala eliphathelene nemali engadluli ku-R15 000.00 (Demographic Governance and Right Unit 2020).

4.     Ukulalela nokurarulula iindaba eziphathelene nokubandlululana (UmThetho wamaKhotho weNdabuko 2022&lt;ref name=&quot;:1&quot; /&gt;).

5.     Ukuletha ukuthula eemphakathini.

=== '''Isiphetho''' ===
Ikhotho yendabuko nanyana iBandla liqakatheke khulu eemphakathini esiphila kiwo ngombana lenza isiqiniseko sokuthi abantu bahlalisana kuhle begodu akugadangwana iinzwani. Ukungezelela, lenza isiqiniseko sokuthi abantu baphathwa ngokulingana. Kuqakathekile bonyana sizwisise ukuthi liyini iBandla nanyana ikhotho yendabuko begodu isebenza ini.

=== '''Umthombolwazi''' ===
&lt;references /&gt;</text>
      <sha1>l8idutk3iwaza6i8ojjaz8tt6t2688s</sha1>
    </revision>
    <revision>
      <id>3430</id>
      <parentid>3313</parentid>
      <timestamp>2025-07-14T00:18:30Z</timestamp>
      <contributor>
        <username>Dcljr</username>
        <id>20</id>
      </contributor>
      <comment>remove redundant section heading; remove bold from section headings; wikify list</comment>
      <origin>3430</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3791" sha1="8obgyy0md1q4c14tzijhrwha2wow9z6" xml:space="preserve">=== Isingeniso ===
[[Amakhotho wethu|Amakhotho]] wendabuko adlala indima ekulu emphakathini mayelana nokulawulwa kwabantu kanye nokulandelwa komthetho. Amakhotho wendabuko nanyana ikambiso yawo ingafani patsi namakhotho wesikhuwa; kodwana, iminqopho yona iyafana. Eenhlokwaneni ezilandelako sizokutjheja bona lokha nakukhulunywa ngamakhotho wendabuko kukhulunywa ngani begodu imisebenzi yawo iyini.

=== Khuyini ikhotho yendabuko na? ===
Ngokuya kukaSomaru noRautenbach (2020)&lt;ref&gt;'''Somaru, N. &amp; Rautenbach, C'''. 2020. The Indian Approach to Criminal Justice: The Role of Traditional Courts as Alternative Dispute Resolution Mechanisms''. Comparative and International Law Journal of Southern Africa'', 53(2):1-40.&lt;/ref&gt; ikhotho yendabuko yindawo leyo egunyazwe ngokomthetho wesiko lesitjhaba esithize ukuze izokuqalana nemiraro ekhona ephakathini wesitjhaba leso. Ukungezelela, amakhotho wendabuko alawulwa nanyana adoswa phambili badosiphambili bendabuko njengenduna, ikosana, iKosi nanyana iNgwenyama (Demographic Governance and Right Unit 2020&lt;ref name=&quot;:0&quot;&gt;'''Democratic Governance and Rights Unit'''. 2020. ''Assessing the Functioning of Urban Traditional Courts in South Africa''. University of Cape Town: Cape Town. &lt;/ref&gt;). Ikhotho yendabuko yaziwa khulu ngokuthi yiBandla.

Amakhotho wendabuko atholakala koke la kubusa khona abadosiphambili bendabuko ngokungakhathaleleki bonyana kusemakhaya, eengoga nanyana emadobheni (Demographic Governance and Right Unit 2020&lt;ref name=&quot;:0&quot; /&gt;). UVan Rooyen (2023)&lt;ref&gt;'''Van Rooyen, M-G.''' 2023. Legal Talk: Legislative Developments. ''Just Africa,'' 2: 8-10&lt;/ref&gt; waveza bonyana umkhandlu nanyana abalawuli bekambiso yekhotho yendabuko bangafaka hlangana induna, umdosiphambili wendabuko omkhulu, ikosi, indlovukazi kanye nengwenyama lapho kukghonakalako. Ngamanye amagama, umkhandlu olawula ikambiso nanyana ukuhlala kwamakhotho wendabuko, kufanele ufake amalunga ahlukileko nabadlalindima abahlukileko ukuze kube nokujameleka kwawo woke amahlangothi wabantu nomphakathi.

Amalunga womkhandlu wekhotho yendabuko labo alawula ukuhlala kwayo akukateleleki bonyana abe neziqu njengoba kwenziwa kumakhotho wesikhuwa (Himoga noManjoo 2009&lt;ref&gt;'''Himonga, C. &amp; Manjoo, R.''' 2009''. The Challenges of Formalisation, Regulation, and Reform of Traditional Courts in South Africa''. MLI, 3(2):157-181.&lt;/ref&gt;). Kodwana, kufanele kube babantu abanelwazi tle mayelana namasiko, ilimi, imiraro eyahlukeneko yabantu nemiphakathi (UmThetho wamaKhotho weNdabuko 2022&lt;ref name=&quot;:1&quot;&gt;'''The Presidency Department'''. 2022. ''UmTheth WamaKhotho WeNdabuko, Nom 9 ween-2022''. Ipalamende yeSewula Afrika: EKapa. &lt;/ref&gt;). Esihlokweni esilandelako sizokutjheja umsebenzi yamakhotho wendabuko.

=== Imisebenzi yeBandla ===
Imisebenzi yeBandla nanyana ikhotho yendabuko ifaka hlangana le elandelako:

# Ukurarulula iindaba eziphathelene nokutlhala hlangana kwemindeni embili nanyana abantu ababili (Demographic Governance and Right Unit 2020&lt;ref name=&quot;:0&quot; /&gt;)
# Ukulalela nokugweba endabeni nanyana iqala lobulelesi (UmThetho wamaKhotho weNdabuko 2022&lt;ref name=&quot;:1&quot; /&gt;).
# Ukuqalela nokuthatha isiqunto mayelana neqala eliphathelene nemali engadluli ku-R15 000.00 (Demographic Governance and Right Unit 2020).
# Ukulalela nokurarulula iindaba eziphathelene nokubandlululana (UmThetho wamaKhotho weNdabuko 2022&lt;ref name=&quot;:1&quot; /&gt;).
# Ukuletha ukuthula eemphakathini.

=== Isiphetho ===
Ikhotho yendabuko nanyana iBandla liqakatheke khulu eemphakathini esiphila kiwo ngombana lenza isiqiniseko sokuthi abantu bahlalisana kuhle begodu akugadangwana iinzwani. Ukungezelela, lenza isiqiniseko sokuthi abantu baphathwa ngokulingana. Kuqakathekile bonyana sizwisise ukuthi liyini iBandla nanyana ikhotho yendabuko begodu isebenza ini.

=== Umthombolwazi ===
&lt;references /&gt;</text>
      <sha1>8obgyy0md1q4c14tzijhrwha2wow9z6</sha1>
    </revision>
    <revision>
      <id>3431</id>
      <parentid>3430</parentid>
      <timestamp>2025-07-14T00:20:14Z</timestamp>
      <contributor>
        <username>Dcljr</username>
        <id>20</id>
      </contributor>
      <comment>remove &quot;introduction&quot; heading; promote all level-3 headings (===) to level-2 (==)</comment>
      <origin>3431</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3764" sha1="fk5xxii0mmj0wh090srf1crch0xuxnq" xml:space="preserve">[[Amakhotho wethu|Amakhotho]] wendabuko adlala indima ekulu emphakathini mayelana nokulawulwa kwabantu kanye nokulandelwa komthetho. Amakhotho wendabuko nanyana ikambiso yawo ingafani patsi namakhotho wesikhuwa; kodwana, iminqopho yona iyafana. Eenhlokwaneni ezilandelako sizokutjheja bona lokha nakukhulunywa ngamakhotho wendabuko kukhulunywa ngani begodu imisebenzi yawo iyini.

== Khuyini ikhotho yendabuko na? ==
Ngokuya kukaSomaru noRautenbach (2020)&lt;ref&gt;'''Somaru, N. &amp; Rautenbach, C'''. 2020. The Indian Approach to Criminal Justice: The Role of Traditional Courts as Alternative Dispute Resolution Mechanisms''. Comparative and International Law Journal of Southern Africa'', 53(2):1-40.&lt;/ref&gt; ikhotho yendabuko yindawo leyo egunyazwe ngokomthetho wesiko lesitjhaba esithize ukuze izokuqalana nemiraro ekhona ephakathini wesitjhaba leso. Ukungezelela, amakhotho wendabuko alawulwa nanyana adoswa phambili badosiphambili bendabuko njengenduna, ikosana, iKosi nanyana iNgwenyama (Demographic Governance and Right Unit 2020&lt;ref name=&quot;:0&quot;&gt;'''Democratic Governance and Rights Unit'''. 2020. ''Assessing the Functioning of Urban Traditional Courts in South Africa''. University of Cape Town: Cape Town. &lt;/ref&gt;). Ikhotho yendabuko yaziwa khulu ngokuthi yiBandla.

Amakhotho wendabuko atholakala koke la kubusa khona abadosiphambili bendabuko ngokungakhathaleleki bonyana kusemakhaya, eengoga nanyana emadobheni (Demographic Governance and Right Unit 2020&lt;ref name=&quot;:0&quot; /&gt;). UVan Rooyen (2023)&lt;ref&gt;'''Van Rooyen, M-G.''' 2023. Legal Talk: Legislative Developments. ''Just Africa,'' 2: 8-10&lt;/ref&gt; waveza bonyana umkhandlu nanyana abalawuli bekambiso yekhotho yendabuko bangafaka hlangana induna, umdosiphambili wendabuko omkhulu, ikosi, indlovukazi kanye nengwenyama lapho kukghonakalako. Ngamanye amagama, umkhandlu olawula ikambiso nanyana ukuhlala kwamakhotho wendabuko, kufanele ufake amalunga ahlukileko nabadlalindima abahlukileko ukuze kube nokujameleka kwawo woke amahlangothi wabantu nomphakathi.

Amalunga womkhandlu wekhotho yendabuko labo alawula ukuhlala kwayo akukateleleki bonyana abe neziqu njengoba kwenziwa kumakhotho wesikhuwa (Himoga noManjoo 2009&lt;ref&gt;'''Himonga, C. &amp; Manjoo, R.''' 2009''. The Challenges of Formalisation, Regulation, and Reform of Traditional Courts in South Africa''. MLI, 3(2):157-181.&lt;/ref&gt;). Kodwana, kufanele kube babantu abanelwazi tle mayelana namasiko, ilimi, imiraro eyahlukeneko yabantu nemiphakathi (UmThetho wamaKhotho weNdabuko 2022&lt;ref name=&quot;:1&quot;&gt;'''The Presidency Department'''. 2022. ''UmTheth WamaKhotho WeNdabuko, Nom 9 ween-2022''. Ipalamende yeSewula Afrika: EKapa. &lt;/ref&gt;). Esihlokweni esilandelako sizokutjheja umsebenzi yamakhotho wendabuko.

== Imisebenzi yeBandla ==
Imisebenzi yeBandla nanyana ikhotho yendabuko ifaka hlangana le elandelako:

# Ukurarulula iindaba eziphathelene nokutlhala hlangana kwemindeni embili nanyana abantu ababili (Demographic Governance and Right Unit 2020&lt;ref name=&quot;:0&quot; /&gt;)
# Ukulalela nokugweba endabeni nanyana iqala lobulelesi (UmThetho wamaKhotho weNdabuko 2022&lt;ref name=&quot;:1&quot; /&gt;).
# Ukuqalela nokuthatha isiqunto mayelana neqala eliphathelene nemali engadluli ku-R15 000.00 (Demographic Governance and Right Unit 2020).
# Ukulalela nokurarulula iindaba eziphathelene nokubandlululana (UmThetho wamaKhotho weNdabuko 2022&lt;ref name=&quot;:1&quot; /&gt;).
# Ukuletha ukuthula eemphakathini.

== Isiphetho ==
Ikhotho yendabuko nanyana iBandla liqakatheke khulu eemphakathini esiphila kiwo ngombana lenza isiqiniseko sokuthi abantu bahlalisana kuhle begodu akugadangwana iinzwani. Ukungezelela, lenza isiqiniseko sokuthi abantu baphathwa ngokulingana. Kuqakathekile bonyana sizwisise ukuthi liyini iBandla nanyana ikhotho yendabuko begodu isebenza ini.

== Umthombolwazi ==
&lt;references /&gt;</text>
      <sha1>fk5xxii0mmj0wh090srf1crch0xuxnq</sha1>
    </revision>
    <revision>
      <id>3432</id>
      <parentid>3431</parentid>
      <timestamp>2025-07-14T00:22:49Z</timestamp>
      <contributor>
        <username>Dcljr</username>
        <id>20</id>
      </contributor>
      <minor />
      <comment>Dcljr moved page [[Amakhotho weNdabuko.]] to [[Amakhotho weNdabuko]]: I don't see why title should end with a &quot;.&quot;</comment>
      <origin>3431</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3764" sha1="fk5xxii0mmj0wh090srf1crch0xuxnq" xml:space="preserve">[[Amakhotho wethu|Amakhotho]] wendabuko adlala indima ekulu emphakathini mayelana nokulawulwa kwabantu kanye nokulandelwa komthetho. Amakhotho wendabuko nanyana ikambiso yawo ingafani patsi namakhotho wesikhuwa; kodwana, iminqopho yona iyafana. Eenhlokwaneni ezilandelako sizokutjheja bona lokha nakukhulunywa ngamakhotho wendabuko kukhulunywa ngani begodu imisebenzi yawo iyini.

== Khuyini ikhotho yendabuko na? ==
Ngokuya kukaSomaru noRautenbach (2020)&lt;ref&gt;'''Somaru, N. &amp; Rautenbach, C'''. 2020. The Indian Approach to Criminal Justice: The Role of Traditional Courts as Alternative Dispute Resolution Mechanisms''. Comparative and International Law Journal of Southern Africa'', 53(2):1-40.&lt;/ref&gt; ikhotho yendabuko yindawo leyo egunyazwe ngokomthetho wesiko lesitjhaba esithize ukuze izokuqalana nemiraro ekhona ephakathini wesitjhaba leso. Ukungezelela, amakhotho wendabuko alawulwa nanyana adoswa phambili badosiphambili bendabuko njengenduna, ikosana, iKosi nanyana iNgwenyama (Demographic Governance and Right Unit 2020&lt;ref name=&quot;:0&quot;&gt;'''Democratic Governance and Rights Unit'''. 2020. ''Assessing the Functioning of Urban Traditional Courts in South Africa''. University of Cape Town: Cape Town. &lt;/ref&gt;). Ikhotho yendabuko yaziwa khulu ngokuthi yiBandla.

Amakhotho wendabuko atholakala koke la kubusa khona abadosiphambili bendabuko ngokungakhathaleleki bonyana kusemakhaya, eengoga nanyana emadobheni (Demographic Governance and Right Unit 2020&lt;ref name=&quot;:0&quot; /&gt;). UVan Rooyen (2023)&lt;ref&gt;'''Van Rooyen, M-G.''' 2023. Legal Talk: Legislative Developments. ''Just Africa,'' 2: 8-10&lt;/ref&gt; waveza bonyana umkhandlu nanyana abalawuli bekambiso yekhotho yendabuko bangafaka hlangana induna, umdosiphambili wendabuko omkhulu, ikosi, indlovukazi kanye nengwenyama lapho kukghonakalako. Ngamanye amagama, umkhandlu olawula ikambiso nanyana ukuhlala kwamakhotho wendabuko, kufanele ufake amalunga ahlukileko nabadlalindima abahlukileko ukuze kube nokujameleka kwawo woke amahlangothi wabantu nomphakathi.

Amalunga womkhandlu wekhotho yendabuko labo alawula ukuhlala kwayo akukateleleki bonyana abe neziqu njengoba kwenziwa kumakhotho wesikhuwa (Himoga noManjoo 2009&lt;ref&gt;'''Himonga, C. &amp; Manjoo, R.''' 2009''. The Challenges of Formalisation, Regulation, and Reform of Traditional Courts in South Africa''. MLI, 3(2):157-181.&lt;/ref&gt;). Kodwana, kufanele kube babantu abanelwazi tle mayelana namasiko, ilimi, imiraro eyahlukeneko yabantu nemiphakathi (UmThetho wamaKhotho weNdabuko 2022&lt;ref name=&quot;:1&quot;&gt;'''The Presidency Department'''. 2022. ''UmTheth WamaKhotho WeNdabuko, Nom 9 ween-2022''. Ipalamende yeSewula Afrika: EKapa. &lt;/ref&gt;). Esihlokweni esilandelako sizokutjheja umsebenzi yamakhotho wendabuko.

== Imisebenzi yeBandla ==
Imisebenzi yeBandla nanyana ikhotho yendabuko ifaka hlangana le elandelako:

# Ukurarulula iindaba eziphathelene nokutlhala hlangana kwemindeni embili nanyana abantu ababili (Demographic Governance and Right Unit 2020&lt;ref name=&quot;:0&quot; /&gt;)
# Ukulalela nokugweba endabeni nanyana iqala lobulelesi (UmThetho wamaKhotho weNdabuko 2022&lt;ref name=&quot;:1&quot; /&gt;).
# Ukuqalela nokuthatha isiqunto mayelana neqala eliphathelene nemali engadluli ku-R15 000.00 (Demographic Governance and Right Unit 2020).
# Ukulalela nokurarulula iindaba eziphathelene nokubandlululana (UmThetho wamaKhotho weNdabuko 2022&lt;ref name=&quot;:1&quot; /&gt;).
# Ukuletha ukuthula eemphakathini.

== Isiphetho ==
Ikhotho yendabuko nanyana iBandla liqakatheke khulu eemphakathini esiphila kiwo ngombana lenza isiqiniseko sokuthi abantu bahlalisana kuhle begodu akugadangwana iinzwani. Ukungezelela, lenza isiqiniseko sokuthi abantu baphathwa ngokulingana. Kuqakathekile bonyana sizwisise ukuthi liyini iBandla nanyana ikhotho yendabuko begodu isebenza ini.

== Umthombolwazi ==
&lt;references /&gt;</text>
      <sha1>fk5xxii0mmj0wh090srf1crch0xuxnq</sha1>
    </revision>
  </page>
  <page>
    <title>Portal:Amasonto</title>
    <ns>0</ns>
    <id>671</id>
    <redirect title="Amasonto" />
    <revision>
      <id>3317</id>
      <timestamp>2025-07-05T08:51:05Z</timestamp>
      <contributor>
        <username>Andre Engels</username>
        <id>480</id>
      </contributor>
      <comment>Andre Engels moved page [[Portal:Amasonto]] to [[Amasonto]]</comment>
      <origin>3317</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="22" sha1="joo5qp5s8ctaq4rxe4k97su03c63bd8" xml:space="preserve">#REDIRECT [[Amasonto]]</text>
      <sha1>joo5qp5s8ctaq4rxe4k97su03c63bd8</sha1>
    </revision>
  </page>
  <page>
    <title>Ukucoca iindaba ngedijithali okudoswa phambili lilutjha</title>
    <ns>0</ns>
    <id>672</id>
    <revision>
      <id>3318</id>
      <timestamp>2025-07-05T13:33:38Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;  '''Ukucoca iindaba''' kukulokha umuntu acocela abalaleli indaba ayitlolileko nofana azitlamele yona ngehloko yakhe. Abantu bakghona ukucoca indaba ngekhambo labo lepilo, ngeenhloko ezingaba mraro nofana iintjhijilo abantu abahlangana nazo emphakathini. Esikhathini sanje, ithekonoloji sele ithuthukile, abantu bakghona ukucoca indaba ngediithali. Ilutjha lisebenzisa abomaliledinini banje abahlakaniphileko, amakhamera, nokhunye ukucoca indaba ngedijithali bakghone ukwabel...&quot;</comment>
      <origin>3318</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3270" sha1="8yk3jk1q5rbkpkqqbs95a1q578ye301" xml:space="preserve">

'''Ukucoca iindaba''' kukulokha umuntu acocela abalaleli indaba ayitlolileko nofana azitlamele yona ngehloko yakhe. Abantu bakghona ukucoca indaba ngekhambo labo lepilo, ngeenhloko ezingaba mraro nofana iintjhijilo abantu abahlangana nazo emphakathini. Esikhathini sanje, ithekonoloji sele ithuthukile, abantu bakghona ukucoca indaba ngediithali. Ilutjha lisebenzisa abomaliledinini banje abahlakaniphileko, amakhamera, nokhunye ukucoca indaba ngedijithali bakghone ukwabelana nabanye abantu abakude indaba. Ukucoca indaba ngedijithali kungenzeka ngendlela ezinengi, njengokuthi kwenziwe amavidiyo, amabhlogo ekukulapho kutlolwa khona indaba nofana okumunyethweko kwelanga, abanye batlola eenkundleni zokuthintana ukulekelela ilutjha bona likghone ukuziveza ngendlela ezihlukahluneko ezingakghona ngazo.&lt;ref&gt;Shahid, M. and Khan, M.R., 2022. Use of digital storytelling in classrooms and beyond. ''Journal of Educational Technology Systems'', ''51''(1), pp.63-77.&lt;/ref&gt; Amaphodkhasti wona asebenza khulu lapho kucocwa khona indaba ngamaphimbo ngehloso yokufundisa, ukucocisana ngesihloko esithize nofana ukuhlunga.&lt;ref&gt;Ferrer, I., Shaw, J. and Lorenzetti, L., 2021. Ethical storytelling and digital narratives: Lessons learned in student-led podcasts and community radio partnerships. ''Journal of Social Work Values and Ethics'', ''18''(1), pp.90-104.&lt;/ref&gt;

Ukufundisa umphakathi

Ilutjha lisebenzisa ukucoca indaba ngedijithali njengo msikinyeko wokubonisa umphakathi ngemiraro yawo, ithuthukise ubulungiswa emphakathini. Okhunye godu ilutjha likhuluma ngemibono yalo, nezinto ekhezahlangana nazo ezingasiza abanye abantu nofana zibaphe isaluleko. Ukucoca indaba ngedijithali kulekelela abantu abangaka dumi emphakathini bonyana bakghone ukukhuluma bezwiwe babanu abanengi. Ukucoca indaba ngedijithali kukhuthaza nokuhluka okukhamba nokwamukelana kwabantu boke. Lokha nawusebenzisa idijithali ukucoca indaba ukghona ukunikela amalunga womphakathi indawo yokuthi bakghone ukucoca indaba zabo, ekungab ziintjhijilo abahlangana nazo nofana lokhu abakufundileko. Abantu bacoca ngeenhloko ezikhona kodwana ezingekho etjhatjhalazini isibonelo ukuthwala, ukunikela abantu ilwazi ngazo ukuthi bazi bonyana zikhona izinto ezinjalo emphakathini. Abantu bangakghona ukuzibandakanya ekucoceni indaba ngedijithali ngokuthi bakhulume iindaba ezimraro emphakathini ezifana nalesi zeenhloko zokungatholi ubulungiswa, ukuphela kwebhoduluko, ubulelesi nezinye iiinhloko.

[[Ilutjha]] lisebenzisa iinkundla zokuthintana ukuthoma amakhapheyini alungisa imiraro yomphakathi isibonelo amakhapheyini afana ne ''# black lives matter, ne # ME TOO'' abanye abavula amatjhaneli we''-youtube'' bese benze ikhonthenti ephikisa ukucoca kwabantu, begodu ikhuthaze ukwahlukana kwabantu ngemibono yabo. Isibonelo selutjha elinamatjhaneli we- youtube ngu Lasizwe Dambuza onabalandeli abangaphezulu kwe- 738 000 etjhanelini yakhe.&lt;ref&gt;[https://www.news24.com/truelove/celebrity/lasizwe-hits-1-million-subs-10-memorable-a-list-guests-from-awkward-dates-20241216 Lasizwe hits 1 million subs! 10 memorable A-list guests from Awkward Dates | News24]&lt;/ref&gt; I-Facebook nayo iyasetjenziswa ukucoca indaba ngokuthi abantu bafake amavidiyo, batlole indaba nokuthi baveze into eyenzeka ngaleso skhathi buncopha.</text>
      <sha1>8yk3jk1q5rbkpkqqbs95a1q578ye301</sha1>
    </revision>
    <revision>
      <id>3319</id>
      <parentid>3318</parentid>
      <timestamp>2025-07-05T13:36:29Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3319</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3377" sha1="n0a54ljjrwk2rhkwlewx4wxt3u27xrb" xml:space="preserve">[[Isimumathi:Lasizwe Dambuza on MacG.jpg|thumb|ULasizwe Dambuza ngomunye welutjha elinetjhaneli ye-youtube]]
'''Ukucoca iindaba''' kukulokha umuntu acocela abalaleli indaba ayitlolileko nofana azitlamele yona ngehloko yakhe. Abantu bakghona ukucoca indaba ngekhambo labo lepilo, ngeenhloko ezingaba mraro nofana iintjhijilo abantu abahlangana nazo emphakathini. Esikhathini sanje, ithekonoloji sele ithuthukile, abantu bakghona ukucoca indaba ngediithali. Ilutjha lisebenzisa abomaliledinini banje abahlakaniphileko, amakhamera, nokhunye ukucoca indaba ngedijithali bakghone ukwabelana nabanye abantu abakude indaba. Ukucoca indaba ngedijithali kungenzeka ngendlela ezinengi, njengokuthi kwenziwe amavidiyo, amabhlogo ekukulapho kutlolwa khona indaba nofana okumunyethweko kwelanga, abanye batlola eenkundleni zokuthintana ukulekelela ilutjha bona likghone ukuziveza ngendlela ezihlukahluneko ezingakghona ngazo.&lt;ref&gt;Shahid, M. and Khan, M.R., 2022. Use of digital storytelling in classrooms and beyond. ''Journal of Educational Technology Systems'', ''51''(1), pp.63-77.&lt;/ref&gt; Amaphodkhasti wona asebenza khulu lapho kucocwa khona indaba ngamaphimbo ngehloso yokufundisa, ukucocisana ngesihloko esithize nofana ukuhlunga.&lt;ref&gt;Ferrer, I., Shaw, J. and Lorenzetti, L., 2021. Ethical storytelling and digital narratives: Lessons learned in student-led podcasts and community radio partnerships. ''Journal of Social Work Values and Ethics'', ''18''(1), pp.90-104.&lt;/ref&gt;

Ukufundisa umphakathi

Ilutjha lisebenzisa ukucoca indaba ngedijithali njengo msikinyeko wokubonisa umphakathi ngemiraro yawo, ithuthukise ubulungiswa emphakathini. Okhunye godu ilutjha likhuluma ngemibono yalo, nezinto ekhezahlangana nazo ezingasiza abanye abantu nofana zibaphe isaluleko. Ukucoca indaba ngedijithali kulekelela abantu abangaka dumi emphakathini bonyana bakghone ukukhuluma bezwiwe babanu abanengi. Ukucoca indaba ngedijithali kukhuthaza nokuhluka okukhamba nokwamukelana kwabantu boke. Lokha nawusebenzisa idijithali ukucoca indaba ukghona ukunikela amalunga womphakathi indawo yokuthi bakghone ukucoca indaba zabo, ekungab ziintjhijilo abahlangana nazo nofana lokhu abakufundileko. Abantu bacoca ngeenhloko ezikhona kodwana ezingekho etjhatjhalazini isibonelo ukuthwala, ukunikela abantu ilwazi ngazo ukuthi bazi bonyana zikhona izinto ezinjalo emphakathini. Abantu bangakghona ukuzibandakanya ekucoceni indaba ngedijithali ngokuthi bakhulume iindaba ezimraro emphakathini ezifana nalesi zeenhloko zokungatholi ubulungiswa, ukuphela kwebhoduluko, ubulelesi nezinye iiinhloko.

[[Ilutjha]] lisebenzisa iinkundla zokuthintana ukuthoma amakhapheyini alungisa imiraro yomphakathi isibonelo amakhapheyini afana ne ''# black lives matter, ne # ME TOO'' abanye abavula amatjhaneli we''-youtube'' bese benze ikhonthenti ephikisa ukucoca kwabantu, begodu ikhuthaze ukwahlukana kwabantu ngemibono yabo. Isibonelo selutjha elinamatjhaneli we- youtube ngu Lasizwe Dambuza onabalandeli abangaphezulu kwe- 738 000 etjhanelini yakhe.&lt;ref&gt;[https://www.news24.com/truelove/celebrity/lasizwe-hits-1-million-subs-10-memorable-a-list-guests-from-awkward-dates-20241216 Lasizwe hits 1 million subs! 10 memorable A-list guests from Awkward Dates | News24]&lt;/ref&gt; I-Facebook nayo iyasetjenziswa ukucoca indaba ngokuthi abantu bafake amavidiyo, batlole indaba nokuthi baveze into eyenzeka ngaleso skhathi buncopha.</text>
      <sha1>n0a54ljjrwk2rhkwlewx4wxt3u27xrb</sha1>
    </revision>
    <revision>
      <id>3320</id>
      <parentid>3319</parentid>
      <timestamp>2025-07-05T13:56:09Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3320</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4206" sha1="e8vf8dhfg8c3aam2r88ztgk309yp2gr" xml:space="preserve">[[Isimumathi:Lasizwe Dambuza on MacG.jpg|thumb|ULasizwe Dambuza ngomunye welutjha elinetjhaneli ye-youtube]]
'''Ukucoca iindaba''' kukulokha umuntu acocela abalaleli indaba ayitlolileko nofana azitlamele yona ngehloko yakhe. Abantu bakghona ukucoca indaba ngekhambo labo lepilo, ngeenhloko ezingaba mraro nofana iintjhijilo abantu abahlangana nazo emphakathini. Esikhathini sanje, ithekonoloji sele ithuthukile, abantu bakghona ukucoca indaba ngediithali. Ilutjha lisebenzisa abomaliledinini banje abahlakaniphileko, amakhamera, nokhunye ukucoca indaba ngedijithali bakghone ukwabelana nabanye abantu abakude indaba. Ukucoca indaba ngedijithali kungenzeka ngendlela ezinengi, njengokuthi kwenziwe amavidiyo, amabhlogo ekukulapho kutlolwa khona indaba nofana okumunyethweko kwelanga, abanye batlola eenkundleni zokuthintana ukulekelela ilutjha bona likghone ukuziveza ngendlela ezihlukahluneko ezingakghona ngazo.&lt;ref&gt;Shahid, M. and Khan, M.R., 2022. Use of digital storytelling in classrooms and beyond. ''Journal of Educational Technology Systems'', ''51''(1), pp.63-77.&lt;/ref&gt; Amaphodkhasti wona asebenza khulu lapho kucocwa khona indaba ngamaphimbo ngehloso yokufundisa, ukucocisana ngesihloko esithize nofana ukuhlunga.&lt;ref&gt;Ferrer, I., Shaw, J. and Lorenzetti, L., 2021. Ethical storytelling and digital narratives: Lessons learned in student-led podcasts and community radio partnerships. ''Journal of Social Work Values and Ethics'', ''18''(1), pp.90-104.&lt;/ref&gt;Omunye welutjha owenza i phodkhasti ngu MacG, yena owathoma i phodkhasti le ngehloso yokufundsa, ukuthabisa nokuhlekisa abantu.&lt;ref&gt;Motsaathebe, G., 2023. Evolving Trends in Radio Broadcasting in South Africa: The Case of Podcast and Chill with macg. In ''100 Years of Radio in South Africa, Volume 2: Community Radio, Digital Radio and the Future of Radio in South Africa'' (pp. 161-177). Cham: Springer Nature Switzerland.&lt;/ref&gt; Ubiza abanntu beSewula Afrika abaziwako ngokuvela kumabona kude nokhunye bese acocisane nabo bakhulume ngamaphilo wabo.

=== Umsebenzi wokusebenzisa udijithali ukucoca iindaba ===

==== Ukufundisa umphakathi ====
Ilutjha lisebenzisa ukucoca iindaba ngedijithali njengo msikinyeko wokubonisa umphakathi ngemiraro yawo, ithuthukise ubulungiswa emphakathini. Okhunye godu ilutjha likhuluma ngemibono yalo, nezinto ekhezahlangana nazo ezingasiza abanye abantu nofana zibaphe isaluleko. Ukucoca indaba ngedijithali kulekelela abantu abangaka dumi emphakathini bonyana bakghone ukukhuluma bezwiwe babanu abanengi. Ukucoca indaba ngedijithali kukhuthaza nokuhluka okukhamba nokwamukelana kwabantu boke. Lokha nawusebenzisa idijithali ukucoca indaba ukghona ukunikela amalunga womphakathi indawo yokuthi bakghone ukucoca indaba zabo, ekungab ziintjhijilo abahlangana nazo nofana lokhu abakufundileko. Abantu bacoca ngeenhloko ezikhona kodwana ezingekho etjhatjhalazini isibonelo ukuthwala, ukunikela abantu ilwazi ngazo ukuthi bazi bonyana zikhona izinto ezinjalo emphakathini. Abantu bangakghona ukuzibandakanya ekucoceni indaba ngedijithali ngokuthi bakhulume iindaba ezimraro emphakathini ezifana nalesi zeenhloko zokungatholi ubulungiswa, ukuphela kwebhoduluko, ubulelesi nezinye iiinhloko.

==== Amakhampheyini wokulungisa imiraro yomphakathi ====
[[Ilutjha]] lisebenzisa iinkundla zokuthintana ukuthoma amakhapheyini alungisa imiraro yomphakathi isibonelo amakhapheyini afana ne ''# black lives matter, ne # ME TOO. i- # black lives matter''  yona ihlose ukuthi ilwisane nokubandlululana ngokombala, nokungaphathwa kuhle kwabantu abanzima emphakathini .Abanye abavula amatjhaneli we''-youtube'' bese benze ikhonthenti ephikisa ukucoca kwabantu, begodu ikhuthaze ukwahlukana kwabantu ngemibono yabo. Isibonelo selutjha elinamatjhaneli we- youtube ngu Lasizwe Dambuza onabalandeli abangaphezulu kwe- 738 000 etjhanelini yakhe.&lt;ref&gt;[https://www.news24.com/truelove/celebrity/lasizwe-hits-1-million-subs-10-memorable-a-list-guests-from-awkward-dates-20241216 Lasizwe hits 1 million subs! 10 memorable A-list guests from Awkward Dates | News24]&lt;/ref&gt; I-Facebook nayo iyasetjenziswa ukucoca indaba ngokuthi abantu bafake amavidiyo, batlole indaba nokuthi baveze into eyenzeka ngaleso skhathi buncopha.

== Iinkomba ==</text>
      <sha1>e8vf8dhfg8c3aam2r88ztgk309yp2gr</sha1>
    </revision>
    <revision>
      <id>3321</id>
      <parentid>3320</parentid>
      <timestamp>2025-07-05T13:59:04Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3321</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4352" sha1="lqu2dxn4c7ts4iskonxzm4fq1xx233p" xml:space="preserve">[[Isimumathi:Lasizwe Dambuza on MacG.jpg|thumb|ULasizwe Dambuza ngomunye welutjha elinetjhaneli ye-youtube]]
'''Ukucoca iindaba''' kukulokha umuntu acocela abalaleli indaba ayitlolileko nofana azitlamele yona ngehloko yakhe. Abantu bakghona ukucoca indaba ngekhambo labo lepilo, ngeenhloko ezingaba mraro nofana iintjhijilo abantu abahlangana nazo emphakathini. Esikhathini sanje, ithekonoloji sele ithuthukile, abantu bakghona ukucoca indaba ngediithali. Ilutjha lisebenzisa abomaliledinini banje abahlakaniphileko, amakhamera, nokhunye ukucoca indaba ngedijithali bakghone ukwabelana nabanye abantu abakude indaba. Ilutjha lizibandakanya ekucoceni indaba ngedijithali ngombana likghona ukusebenzisa itheknoloji.

=== Iindlela zokucoca iiindaba ngedijithali ===
Ukucoca indaba ngedijithali kungenzeka ngendlela ezinengi, njengokuthi kwenziwe amavidiyo, amabhlogo ekukulapho kutlolwa khona indaba nofana okumunyethweko kwelanga, abanye batlola eenkundleni zokuthintana ukulekelela ilutjha bona likghone ukuziveza ngendlela ezihlukahluneko ezingakghona ngazo.&lt;ref&gt;Shahid, M. and Khan, M.R., 2022. Use of digital storytelling in classrooms and beyond. ''Journal of Educational Technology Systems'', ''51''(1), pp.63-77.&lt;/ref&gt; Amaphodkhasti wona asebenza khulu lapho kucocwa khona indaba ngamaphimbo ngehloso yokufundisa, ukucocisana ngesihloko esithize nofana ukuhlunga.&lt;ref&gt;Ferrer, I., Shaw, J. and Lorenzetti, L., 2021. Ethical storytelling and digital narratives: Lessons learned in student-led podcasts and community radio partnerships. ''Journal of Social Work Values and Ethics'', ''18''(1), pp.90-104.&lt;/ref&gt;Omunye welutjha owenza i phodkhasti ngu MacG, yena owathoma i phodkhasti le ngehloso yokufundsa, ukuthabisa nokuhlekisa abantu.&lt;ref&gt;Motsaathebe, G., 2023. Evolving Trends in Radio Broadcasting in South Africa: The Case of Podcast and Chill with macg. In ''100 Years of Radio in South Africa, Volume 2: Community Radio, Digital Radio and the Future of Radio in South Africa'' (pp. 161-177). Cham: Springer Nature Switzerland.&lt;/ref&gt; Ubiza abanntu beSewula Afrika abaziwako ngokuvela kumabona kude nokhunye bese acocisane nabo bakhulume ngamaphilo wabo.

=== Umsebenzi wokusebenzisa udijithali ukucoca iindaba ===

==== Ukufundisa umphakathi ====
Ilutjha lisebenzisa ukucoca iindaba ngedijithali njengo msikinyeko wokubonisa umphakathi ngemiraro yawo, ithuthukise ubulungiswa emphakathini. Okhunye godu ilutjha likhuluma ngemibono yalo, nezinto ekhezahlangana nazo ezingasiza abanye abantu nofana zibaphe isaluleko. Ukucoca indaba ngedijithali kulekelela abantu abangaka dumi emphakathini bonyana bakghone ukukhuluma bezwiwe babanu abanengi. Ukucoca indaba ngedijithali kukhuthaza nokuhluka okukhamba nokwamukelana kwabantu boke. Lokha nawusebenzisa idijithali ukucoca indaba ukghona ukunikela amalunga womphakathi indawo yokuthi bakghone ukucoca indaba zabo, ekungab ziintjhijilo abahlangana nazo nofana lokhu abakufundileko. Abantu bacoca ngeenhloko ezikhona kodwana ezingekho etjhatjhalazini isibonelo ukuthwala, ukunikela abantu ilwazi ngazo ukuthi bazi bonyana zikhona izinto ezinjalo emphakathini. Abantu bangakghona ukuzibandakanya ekucoceni indaba ngedijithali ngokuthi bakhulume iindaba ezimraro emphakathini ezifana nalesi zeenhloko zokungatholi ubulungiswa, ukuphela kwebhoduluko, ubulelesi nezinye iiinhloko.

==== Amakhampheyini wokulungisa imiraro yomphakathi ====
[[Ilutjha]] lisebenzisa iinkundla zokuthintana ukuthoma amakhapheyini alungisa imiraro yomphakathi isibonelo amakhapheyini afana ne ''# black lives matter, ne # ME TOO. i- # black lives matter''  yona ihlose ukuthi ilwisane nokubandlululana ngokombala, nokungaphathwa kuhle kwabantu abanzima emphakathini .Abanye abavula amatjhaneli we''-youtube'' bese benze ikhonthenti ephikisa ukucoca kwabantu, begodu ikhuthaze ukwahlukana kwabantu ngemibono yabo. Isibonelo selutjha elinamatjhaneli we- youtube ngu Lasizwe Dambuza onabalandeli abangaphezulu kwe- 738 000 etjhanelini yakhe.&lt;ref&gt;[https://www.news24.com/truelove/celebrity/lasizwe-hits-1-million-subs-10-memorable-a-list-guests-from-awkward-dates-20241216 Lasizwe hits 1 million subs! 10 memorable A-list guests from Awkward Dates | News24]&lt;/ref&gt; I-Facebook nayo iyasetjenziswa ukucoca indaba ngokuthi abantu bafake amavidiyo, batlole indaba nokuthi baveze into eyenzeka ngaleso skhathi buncopha.

== Iinkomba ==</text>
      <sha1>lqu2dxn4c7ts4iskonxzm4fq1xx233p</sha1>
    </revision>
    <revision>
      <id>3322</id>
      <parentid>3321</parentid>
      <timestamp>2025-07-05T14:06:56Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3322</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4559" sha1="759kwen6dupnnhk0d9t1soo4zxvajzh" xml:space="preserve">[[Isimumathi:Lasizwe Dambuza on MacG.jpg|thumb|ULasizwe Dambuza ngomunye welutjha elinetjhaneli ye-youtube]]
'''Ukucoca iindaba''' kukulokha umuntu acocela abalaleli indaba ayitlolileko nofana azitlamele yona ngehloko yakhe. Abantu bakghona ukucoca indaba ngekhambo labo lepilo, ngeenhloko ezingaba mraro nofana iintjhijilo abantu abahlangana nazo emphakathini. Esikhathini sanje, ithekonoloji sele ithuthukile, abantu bakghona ukucoca indaba ngediithali. Ilutjha lisebenzisa abomaliledinini banje abahlakaniphileko, amakhamera, nokhunye ukucoca indaba ngedijithali bakghone ukwabelana nabanye abantu abakude indaba. Ilutjha lizibandakanya ekucoceni indaba ngedijithali ngombana likghona ukusebenzisa itheknoloji.

=== Iindlela zokucoca iiindaba ngedijithali ===
Ukucoca indaba ngedijithali kungenzeka ngendlela ezinengi, njengokuthi kwenziwe amavidiyo, amabhlogo ekukulapho kutlolwa khona indaba nofana okumunyethweko kwelanga, abanye batlola eenkundleni zokuthintana ukulekelela ilutjha bona likghone ukuziveza ngendlela ezihlukahluneko ezingakghona ngazo.&lt;ref&gt;Shahid, M. and Khan, M.R., 2022. Use of digital storytelling in classrooms and beyond. ''Journal of Educational Technology Systems'', ''51''(1), pp.63-77.&lt;/ref&gt; Amaphodkhasti wona asebenza khulu lapho kucocwa khona indaba ngamaphimbo ngehloso yokufundisa, ukucocisana ngesihloko esithize nofana ukuhlunga.&lt;ref&gt;Ferrer, I., Shaw, J. and Lorenzetti, L., 2021. Ethical storytelling and digital narratives: Lessons learned in student-led podcasts and community radio partnerships. ''Journal of Social Work Values and Ethics'', ''18''(1), pp.90-104.&lt;/ref&gt;Omunye welutjha owenza i phodkhasti ngu MacG, yena owathoma i phodkhasti le ngehloso yokufundsa, ukuthabisa nokuhlekisa abantu.&lt;ref&gt;Motsaathebe, G., 2023. Evolving Trends in Radio Broadcasting in South Africa: The Case of Podcast and Chill with macg. In ''100 Years of Radio in South Africa, Volume 2: Community Radio, Digital Radio and the Future of Radio in South Africa'' (pp. 161-177). Cham: Springer Nature Switzerland.&lt;/ref&gt; Ubiza abanntu beSewula Afrika abaziwako ngokuvela kumabona kude nokhunye bese acocisane nabo bakhulume ngamaphilo wabo.

=== Umsebenzi wokusebenzisa udijithali ukucoca iindaba ===

==== Ukufundisa umphakathi ====
Ilutjha lisebenzisa ukucoca iindaba ngedijithali njengo msikinyeko wokubonisa umphakathi ngemiraro yawo, ithuthukise ubulungiswa emphakathini. Okhunye godu ilutjha likhuluma ngemibono yalo, nezinto ekhezahlangana nazo ezingasiza abanye abantu nofana zibaphe isaluleko. Ukucoca indaba ngedijithali kulekelela abantu abangaka dumi emphakathini bonyana bakghone ukukhuluma bezwiwe babanu abanengi. Ukucoca indaba ngedijithali kukhuthaza nokuhluka okukhamba nokwamukelana kwabantu boke. Lokha nawusebenzisa idijithali ukucoca indaba ukghona ukunikela amalunga womphakathi indawo yokuthi bakghone ukucoca indaba zabo, ekungaba ziintjhijilo abahlangana nazo nofana lokhu abakufundileko. Abantu bacoca ngeenhloko ezikhona kodwana ezingekho etjhatjhalazini isibonelo ukuthwala, ukunikela abantu ilwazi ngazo ukuthi bazi bonyana zikhona izinto ezinjalo emphakathini.&lt;ref&gt;Greene, S., Burke, K.J. and McKenna, M.K., 2018. A review of research connecting digital storytelling, photovoice, and civic engagement. ''Review of Educational Research'', ''88''(6), pp.844-878.&lt;/ref&gt; Abantu bangakghona ukuzibandakanya ekucoceni indaba ngedijithali ngokuthi bakhulume iindaba ezimraro emphakathini ezifana nalesi zeenhloko zokungatholi ubulungiswa, ukuphela kwebhoduluko, ubulelesi nezinye iiinhloko.

==== Amakhampheyini wokulungisa imiraro yomphakathi ====
[[Ilutjha]] lisebenzisa iinkundla zokuthintana ukuthoma amakhapheyini alungisa imiraro yomphakathi isibonelo amakhapheyini afana ne ''# black lives matter, ne # ME TOO. i- # black lives matter''  yona ihlose ukuthi ilwisane nokubandlululana ngokombala, nokungaphathwa kuhle kwabantu abanzima emphakathini .Abanye abavula amatjhaneli we''-youtube'' bese benze ikhonthenti ephikisa ukucoca kwabantu, begodu ikhuthaze ukwahlukana kwabantu ngemibono yabo. Isibonelo selutjha elinamatjhaneli we- youtube ngu Lasizwe Dambuza onabalandeli abangaphezulu kwe- 738 000 etjhanelini yakhe.&lt;ref&gt;[https://www.news24.com/truelove/celebrity/lasizwe-hits-1-million-subs-10-memorable-a-list-guests-from-awkward-dates-20241216 Lasizwe hits 1 million subs! 10 memorable A-list guests from Awkward Dates | News24]&lt;/ref&gt; I-Facebook nayo iyasetjenziswa ukucoca indaba ngokuthi abantu bafake amavidiyo, batlole indaba nokuthi baveze into eyenzeka ngaleso skhathi buncopha.

== Iinkomba ==</text>
      <sha1>759kwen6dupnnhk0d9t1soo4zxvajzh</sha1>
    </revision>
    <revision>
      <id>3323</id>
      <parentid>3322</parentid>
      <timestamp>2025-07-05T14:15:41Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3323</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4559" sha1="igae28ky7j54ipywu8hd2ak3g9vqqpo" xml:space="preserve">[[Isimumathi:Lasizwe Dambuza on MacG.jpg|thumb|ULasizwe Dambuza ngomunye welutjha elinetjhaneli ye-youtube]]
'''Ukucoca iindaba''' kukulokha umuntu acocela abalaleli indaba ayitlolileko nofana azitlamele yona ngehloko yakhe. Abantu bakghona ukucoca indaba ngekhambo labo lepilo, ngeenhloko ezingaba mraro nofana iintjhijilo abantu abahlangana nazo emphakathini. Esikhathini sanje, ithekonoloji sele ithuthukile, abantu bakghona ukucoca indaba ngediithali. Ilutjha lisebenzisa abomaliledinini banje abahlakaniphileko, amakhamera, nokhunye ukucoca indaba ngedijithali bakghone ukwabelana nabanye abantu abakude indaba. Ilutjha lizibandakanya ekucoceni indaba ngedijithali ngombana likghona ukusebenzisa itheknoloji.

=== Iindlela zokucoca iiindaba ngedijithali ===
Ukucoca indaba ngedijithali kungenzeka ngendlela ezinengi, njengokuthi kwenziwe amavidiyo, amabhlogo ekukulapho kutlolwa khona indaba nofana okumunyethweko kwelanga, abanye batlola eenkundleni zokuthintana ukulekelela ilutjha bona likghone ukuziveza ngendlela ezihlukahluneko ezingakghona ngazo.&lt;ref&gt;Shahid, M. and Khan, M.R., 2022. Use of digital storytelling in classrooms and beyond. ''Journal of Educational Technology Systems'', ''51''(1), pp.63-77.&lt;/ref&gt; Amaphodkhasti wona asebenza khulu lapho kucocwa khona indaba ngamaphimbo ngehloso yokufundisa, ukucocisana ngesihloko esithize nofana ukuhlunga.&lt;ref&gt;Ferrer, I., Shaw, J. and Lorenzetti, L., 2021. Ethical storytelling and digital narratives: Lessons learned in student-led podcasts and community radio partnerships. ''Journal of Social Work Values and Ethics'', ''18''(1), pp.90-104.&lt;/ref&gt;Omunye welutjha owenza i phodkhasti ngu MacG, yena owathoma i phodkhasti le ngehloso yokufundsa, ukuthabisa nokuhlekisa abantu.&lt;ref&gt;Motsaathebe, G., 2023. Evolving Trends in Radio Broadcasting in South Africa: The Case of Podcast and Chill with macg. In ''100 Years of Radio in South Africa, Volume 2: Community Radio, Digital Radio and the Future of Radio in South Africa'' (pp. 161-177). Cham: Springer Nature Switzerland.&lt;/ref&gt; Ubiza abanntu beSewula Afrika abaziwako ngokuvela kumabonakude nokhunye bese bacocisane nabo bakhulume ngamaphilo wabo.

=== Umsebenzi wokusebenzisa udijithali ukucoca iindaba ===

==== Ukufundisa umphakathi ====
Ilutjha lisebenzisa ukucoca iindaba ngedijithali njengo msikinyeko wokubonisa umphakathi ngemiraro yawo, ithuthukise ubulungiswa emphakathini. Okhunye godu ilutjha likhuluma ngemibono yalo, nezinto ekhezahlangana nazo ezingasiza abanye abantu nofana zibaphe isaluleko. Ukucoca indaba ngedijithali kulekelela abantu abangaka dumi emphakathini bonyana bakghone ukukhuluma bezwiwe babanu abanengi. Ukucoca indaba ngedijithali kukhuthaza nokuhluka okukhamba nokwamukelana kwabantu boke. Lokha nawusebenzisa idijithali ukucoca indaba ukghona ukunikela amalunga womphakathi indawo yokuthi bakghone ukucoca indaba zabo, ekungaba ziintjhijilo abahlangana nazo nofana lokhu abakufundileko. Abantu bacoca ngeenhloko ezikhona kodwana ezingekho etjhatjhalazini isibonelo ukuthwala, ukunikela abantu ilwazi ngazo ukuthi bazi bonyana zikhona izinto ezinjalo emphakathini.&lt;ref&gt;Greene, S., Burke, K.J. and McKenna, M.K., 2018. A review of research connecting digital storytelling, photovoice, and civic engagement. ''Review of Educational Research'', ''88''(6), pp.844-878.&lt;/ref&gt; Abantu bangakghona ukuzibandakanya ekucoceni indaba ngedijithali ngokuthi bakhulume iindaba ezimraro emphakathini ezifana nalesi zeenhloko zokungatholi ubulungiswa, ukuphela kwebhoduluko, ubulelesi nezinye iiinhloko.

==== Amakhampheyini wokulungisa imiraro yomphakathi ====
[[Ilutjha]] lisebenzisa iinkundla zokuthintana ukuthoma amakhapheyini alungisa imiraro yomphakathi isibonelo amakhapheyini afana ne ''# black lives matter, ne # ME TOO. i- # black lives matter''  yona ihlose ukuthi ilwisane nokubandlululana ngokombala, nokungaphathwa kuhle kwabantu abanzima emphakathini .Abanye abavula amatjhaneli we''-youtube'' bese benze ikhonthenti ephikisa ukucoca kwabantu, begodu ikhuthaze ukwahlukana kwabantu ngemibono yabo. Isibonelo selutjha elinamatjhaneli we- youtube ngu Lasizwe Dambuza onabalandeli abangaphezulu kwe- 738 000 etjhanelini yakhe.&lt;ref&gt;[https://www.news24.com/truelove/celebrity/lasizwe-hits-1-million-subs-10-memorable-a-list-guests-from-awkward-dates-20241216 Lasizwe hits 1 million subs! 10 memorable A-list guests from Awkward Dates | News24]&lt;/ref&gt; I-Facebook nayo iyasetjenziswa ukucoca indaba ngokuthi abantu bafake amavidiyo, batlole indaba nokuthi baveze into eyenzeka ngaleso skhathi buncopha.

== Iinkomba ==</text>
      <sha1>igae28ky7j54ipywu8hd2ak3g9vqqpo</sha1>
    </revision>
    <revision>
      <id>3325</id>
      <parentid>3323</parentid>
      <timestamp>2025-07-07T17:54:14Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3325</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4559" sha1="egtyvd6w6xjxhr80lp929gcqla6ifcb" xml:space="preserve">[[Isimumathi:Lasizwe Dambuza on MacG.jpg|thumb|ULasizwe Dambuza ngomunye welutjha elinetjhaneli ye-youtube]]
'''Ukucoca iindaba''' kukulokha umuntu acocela abalaleli indaba ayitlolileko nofana azitlamele yona ngehloko yakhe. Abantu bakghona ukucoca indaba ngekhambo labo lepilo, ngeenhloko ezingaba mraro nofana iintjhijilo abantu abahlangana nazo emphakathini. Esikhathini sanje, ithekonoloji sele ithuthukile, abantu bakghona ukucoca indaba ngediithali. Ilutjha lisebenzisa abomaliledinini banje abahlakaniphileko, amakhamera, nokhunye ukucoca indaba ngedijithali bakghone ukwabelana nabanye abantu abakude indaba. Ilutjha lizibandakanya ekucoceni indaba ngedijithali ngombana likghona ukusebenzisa itheknoloji.

=== Iindlela zokucoca iiindaba ngedijithali ===
Ukucoca indaba ngedijithali kungenzeka ngendlela ezinengi, njengokuthi kwenziwe amavidiyo, amabhlogo ekukulapho kutlolwa khona indaba nofana okumunyethweko kwelanga, abanye batlola eenkundleni zokuthintana ukulekelela ilutjha bona likghone ukuziveza ngendlela ezihlukahluneko ezingakghona ngazo.&lt;ref&gt;Shahid, M. and Khan, M.R., 2022. Use of digital storytelling in classrooms and beyond. ''Journal of Educational Technology Systems'', ''51''(1), pp.63-77.&lt;/ref&gt; Amaphodkhasti wona asebenza khulu lapho kucocwa khona indaba ngamaphimbo ngehloso yokufundisa, ukucocisana ngesihloko esithize nofana ukuhlunga.&lt;ref&gt;Ferrer, I., Shaw, J. and Lorenzetti, L., 2021. Ethical storytelling and digital narratives: Lessons learned in student-led podcasts and community radio partnerships. ''Journal of Social Work Values and Ethics'', ''18''(1), pp.90-104.&lt;/ref&gt;Omunye welutjha owenza i phodkhasti ngu MacG, yena owathoma i phodkhasti le ngehloso yokufundisa, ukuthabisa nokuhlekisa abantu.&lt;ref&gt;Motsaathebe, G., 2023. Evolving Trends in Radio Broadcasting in South Africa: The Case of Podcast and Chill with macg. In ''100 Years of Radio in South Africa, Volume 2: Community Radio, Digital Radio and the Future of Radio in South Africa'' (pp. 161-177). Cham: Springer Nature Switzerland.&lt;/ref&gt; Ubiza abantu beSewula Afrika abaziwako ngokuvela kumabonakude nokhunye bese bacocisane nabo bakhulume ngamaphilo wabo.

=== Umsebenzi wokusebenzisa udijithali ukucoca iindaba ===

==== Ukufundisa umphakathi ====
Ilutjha lisebenzisa ukucoca iindaba ngedijithali njengo msikinyeko wokubonisa umphakathi ngemiraro yawo, ithuthukise ubulungiswa emphakathini. Okhunye godu ilutjha likhuluma ngemibono yalo, nezinto ekhezahlangana nazo ezingasiza abanye abantu nofana zibaphe isaluleko. Ukucoca indaba ngedijithali kulekelela abantu abangaka dumi emphakathini bonyana bakghone ukukhuluma bezwiwe babanu abanengi. Ukucoca indaba ngedijithali kukhuthaza nokuhluka okukhamba nokwamukelana kwabantu boke. Lokha nawusebenzisa idijithali ukucoca indaba ukghona ukunikela amalunga womphakathi indawo yokuthi bakghone ukucoca indaba zabo, ekungaba ziintjhijilo abahlangana nazo nofana lokhu abakufundileko. Abantu bacoca ngeenhloko ezikhona kodwana ezingekho etjhatjhalazini isibonelo ukuthwala, ukunikela abantu ilwazi ngazo ukuthi bazi bonyana zikhona izinto ezinjalo emphakathini.&lt;ref&gt;Greene, S., Burke, K.J. and McKenna, M.K., 2018. A review of research connecting digital storytelling, photovoice, and civic engagement. ''Review of Educational Research'', ''88''(6), pp.844-878.&lt;/ref&gt; Abantu bangakghona ukuzibandakanya ekucoceni indaba ngedijithali ngokuthi bakhulume iindaba ezimraro emphakathini ezifana nalesi zeenhloko zokungatholi ubulungiswa, ukuphela kwebhoduluko, ubulelesi nezinye iiinhloko.

==== Amakhampheyini wokulungisa imiraro yomphakathi ====
[[Ilutjha]] lisebenzisa iinkundla zokuthintana ukuthoma amakhapheyini alungisa imiraro yomphakathi isibonelo amakhapheyini afana ne ''# black lives matter, ne # ME TOO. i- # black lives matter''  yona ihlose ukuthi ilwisane nokubandlululana ngokombala, nokungaphathwa kuhle kwabantu abanzima emphakathini .Abanye abavula amatjhaneli we''-youtube'' bese benze ikhonthenti ephikisa ukucoca kwabantu, begodu ikhuthaze ukwahlukana kwabantu ngemibono yabo. Isibonelo selutjha elinamatjhaneli we- youtube ngu Lasizwe Dambuza onabalandeli abangaphezulu kwe- 738 000 etjhanelini yakhe.&lt;ref&gt;[https://www.news24.com/truelove/celebrity/lasizwe-hits-1-million-subs-10-memorable-a-list-guests-from-awkward-dates-20241216 Lasizwe hits 1 million subs! 10 memorable A-list guests from Awkward Dates | News24]&lt;/ref&gt; I-Facebook nayo iyasetjenziswa ukucoca indaba ngokuthi abantu bafake amavidiyo, batlole indaba nokuthi baveze into eyenzeka ngaleso skhathi buncopha.

== Iinkomba ==</text>
      <sha1>egtyvd6w6xjxhr80lp929gcqla6ifcb</sha1>
    </revision>
    <revision>
      <id>3326</id>
      <parentid>3325</parentid>
      <timestamp>2025-07-07T17:54:41Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3326</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4560" sha1="7wb348i4o0rlbxmn61nvbbew23tmj9j" xml:space="preserve">[[Isimumathi:Lasizwe Dambuza on MacG.jpg|thumb|ULasizwe Dambuza ngomunye welutjha elinetjhaneli ye-youtube]]
'''Ukucoca iindaba''' kukulokha umuntu acocela abalaleli indaba ayitlolileko nofana azitlamele yona ngehloko yakhe. Abantu bakghona ukucoca indaba ngekhambo labo lepilo, ngeenhloko ezingaba mraro nofana iintjhijilo abantu abahlangana nazo emphakathini. Esikhathini sanje, ithekonoloji sele ithuthukile, abantu bakghona ukucoca indaba ngediithali. Ilutjha lisebenzisa abomaliledinini banje abahlakaniphileko, amakhamera, nokhunye ukucoca indaba ngedijithali bakghone ukwabelana nabanye abantu abakude indaba. Ilutjha lizibandakanya ekucoceni indaba ngedijithali ngombana likghona ukusebenzisa itheknoloji.

=== Iindlela zokucoca iiindaba ngedijithali ===
Ukucoca iindaba ngedijithali kungenzeka ngendlela ezinengi, njengokuthi kwenziwe amavidiyo, amabhlogo ekukulapho kutlolwa khona indaba nofana okumunyethweko kwelanga, abanye batlola eenkundleni zokuthintana ukulekelela ilutjha bona likghone ukuziveza ngendlela ezihlukahluneko ezingakghona ngazo.&lt;ref&gt;Shahid, M. and Khan, M.R., 2022. Use of digital storytelling in classrooms and beyond. ''Journal of Educational Technology Systems'', ''51''(1), pp.63-77.&lt;/ref&gt; Amaphodkhasti wona asebenza khulu lapho kucocwa khona indaba ngamaphimbo ngehloso yokufundisa, ukucocisana ngesihloko esithize nofana ukuhlunga.&lt;ref&gt;Ferrer, I., Shaw, J. and Lorenzetti, L., 2021. Ethical storytelling and digital narratives: Lessons learned in student-led podcasts and community radio partnerships. ''Journal of Social Work Values and Ethics'', ''18''(1), pp.90-104.&lt;/ref&gt;Omunye welutjha owenza i phodkhasti ngu MacG, yena owathoma i phodkhasti le ngehloso yokufundisa, ukuthabisa nokuhlekisa abantu.&lt;ref&gt;Motsaathebe, G., 2023. Evolving Trends in Radio Broadcasting in South Africa: The Case of Podcast and Chill with macg. In ''100 Years of Radio in South Africa, Volume 2: Community Radio, Digital Radio and the Future of Radio in South Africa'' (pp. 161-177). Cham: Springer Nature Switzerland.&lt;/ref&gt; Ubiza abantu beSewula Afrika abaziwako ngokuvela kumabonakude nokhunye bese bacocisane nabo bakhulume ngamaphilo wabo.

=== Umsebenzi wokusebenzisa udijithali ukucoca iindaba ===

==== Ukufundisa umphakathi ====
Ilutjha lisebenzisa ukucoca iindaba ngedijithali njengo msikinyeko wokubonisa umphakathi ngemiraro yawo, ithuthukise ubulungiswa emphakathini. Okhunye godu ilutjha likhuluma ngemibono yalo, nezinto ekhezahlangana nazo ezingasiza abanye abantu nofana zibaphe isaluleko. Ukucoca indaba ngedijithali kulekelela abantu abangaka dumi emphakathini bonyana bakghone ukukhuluma bezwiwe babanu abanengi. Ukucoca indaba ngedijithali kukhuthaza nokuhluka okukhamba nokwamukelana kwabantu boke. Lokha nawusebenzisa idijithali ukucoca indaba ukghona ukunikela amalunga womphakathi indawo yokuthi bakghone ukucoca indaba zabo, ekungaba ziintjhijilo abahlangana nazo nofana lokhu abakufundileko. Abantu bacoca ngeenhloko ezikhona kodwana ezingekho etjhatjhalazini isibonelo ukuthwala, ukunikela abantu ilwazi ngazo ukuthi bazi bonyana zikhona izinto ezinjalo emphakathini.&lt;ref&gt;Greene, S., Burke, K.J. and McKenna, M.K., 2018. A review of research connecting digital storytelling, photovoice, and civic engagement. ''Review of Educational Research'', ''88''(6), pp.844-878.&lt;/ref&gt; Abantu bangakghona ukuzibandakanya ekucoceni indaba ngedijithali ngokuthi bakhulume iindaba ezimraro emphakathini ezifana nalesi zeenhloko zokungatholi ubulungiswa, ukuphela kwebhoduluko, ubulelesi nezinye iiinhloko.

==== Amakhampheyini wokulungisa imiraro yomphakathi ====
[[Ilutjha]] lisebenzisa iinkundla zokuthintana ukuthoma amakhapheyini alungisa imiraro yomphakathi isibonelo amakhapheyini afana ne ''# black lives matter, ne # ME TOO. i- # black lives matter''  yona ihlose ukuthi ilwisane nokubandlululana ngokombala, nokungaphathwa kuhle kwabantu abanzima emphakathini .Abanye abavula amatjhaneli we''-youtube'' bese benze ikhonthenti ephikisa ukucoca kwabantu, begodu ikhuthaze ukwahlukana kwabantu ngemibono yabo. Isibonelo selutjha elinamatjhaneli we- youtube ngu Lasizwe Dambuza onabalandeli abangaphezulu kwe- 738 000 etjhanelini yakhe.&lt;ref&gt;[https://www.news24.com/truelove/celebrity/lasizwe-hits-1-million-subs-10-memorable-a-list-guests-from-awkward-dates-20241216 Lasizwe hits 1 million subs! 10 memorable A-list guests from Awkward Dates | News24]&lt;/ref&gt; I-Facebook nayo iyasetjenziswa ukucoca indaba ngokuthi abantu bafake amavidiyo, batlole indaba nokuthi baveze into eyenzeka ngaleso skhathi buncopha.

== Iinkomba ==</text>
      <sha1>7wb348i4o0rlbxmn61nvbbew23tmj9j</sha1>
    </revision>
    <revision>
      <id>3327</id>
      <parentid>3326</parentid>
      <timestamp>2025-07-07T18:27:57Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3327</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4803" sha1="lfce0915zmomfz9o2qfdrhmmh0glhru" xml:space="preserve">[[Isimumathi:Lasizwe Dambuza on MacG.jpg|thumb|ULasizwe Dambuza ngomunye welutjha elinetjhaneli ye-youtube]]
'''Ukucoca iindaba''' kukulokha umuntu acocela abalaleli indaba ayitlolileko nofana azitlamele yona ngehloko yakhe.Kuyinto eyabe isetjenziswa ekadeni ukufundosa abantu ngombana lokha nawulalele iindaba ukghona ukuthola isifundo.&lt;ref&gt;Palacios, J., 2012. Traditional storytelling in the digital era. ''Fourth World Journal'', ''11''(2), pp.41-56.&lt;/ref&gt; Abantu bakghona ukucoca indaba ngekhambo labo lepilo,  nofana ngeenhloko ezingaba mraro nofana iintjhijilo abantu abahlangana nazo emphakathini. Esikhathini sanje, ithekonoloji sele ithuthukile, abantu bakghona ukucoca indaba ngediithali. Ilutjha lisebenzisa abomaliledinini banje abahlakaniphileko, amakhamera, nokhunye ukucoca indaba ngedijithali bakghone ukwabelana nabanye abantu abakude indaba. Ilutjha lizibandakanya ekucoceni indaba ngedijithali ngombana likghona ukusebenzisa itheknoloji.

=== Iindlela zokucoca iiindaba ngedijithali ===
Ukucoca iindaba ngedijithali kungenzeka ngendlela ezinengi, njengokuthi kwenziwe amavidiyo, amabhlogo ekukulapho kutlolwa khona indaba nofana okumunyethweko kwelanga, abanye batlola eenkundleni zokuthintana ukulekelela ilutjha bona likghone ukuziveza ngendlela ezihlukahluneko ezingakghona ngazo.&lt;ref&gt;Shahid, M. and Khan, M.R., 2022. Use of digital storytelling in classrooms and beyond. ''Journal of Educational Technology Systems'', ''51''(1), pp.63-77.&lt;/ref&gt; Amaphodkhasti wona asebenza khulu lapho kucocwa khona indaba ngamaphimbo ngehloso yokufundisa, ukucocisana ngesihloko esithize nofana ukuhlunga.&lt;ref&gt;Ferrer, I., Shaw, J. and Lorenzetti, L., 2021. Ethical storytelling and digital narratives: Lessons learned in student-led podcasts and community radio partnerships. ''Journal of Social Work Values and Ethics'', ''18''(1), pp.90-104.&lt;/ref&gt;Omunye welutjha owenza i phodkhasti ngu MacG, yena owathoma i phodkhasti le ngehloso yokufundisa, ukuthabisa nokuhlekisa abantu.&lt;ref&gt;Motsaathebe, G., 2023. Evolving Trends in Radio Broadcasting in South Africa: The Case of Podcast and Chill with macg. In ''100 Years of Radio in South Africa, Volume 2: Community Radio, Digital Radio and the Future of Radio in South Africa'' (pp. 161-177). Cham: Springer Nature Switzerland.&lt;/ref&gt; Ubiza abantu beSewula Afrika abaziwako ngokuvela kumabonakude nokhunye bese bacocisane nabo bakhulume ngamaphilo wabo.

=== Umsebenzi wokusebenzisa udijithali ukucoca iindaba ===

==== Ukufundisa umphakathi ====
Ilutjha lisebenzisa ukucoca iindaba ngedijithali njengo msikinyeko wokubonisa umphakathi ngemiraro yawo, ithuthukise ubulungiswa emphakathini. Okhunye godu ilutjha likhuluma ngemibono yalo, nezinto ekhezahlangana nazo ezingasiza abanye abantu nofana zibaphe isaluleko. Ukucoca indaba ngedijithali kulekelela abantu abangaka dumi emphakathini bonyana bakghone ukukhuluma bezwiwe babanu abanengi. Ukucoca indaba ngedijithali kukhuthaza nokuhluka okukhamba nokwamukelana kwabantu boke. Lokha nawusebenzisa idijithali ukucoca indaba ukghona ukunikela amalunga womphakathi indawo yokuthi bakghone ukucoca indaba zabo, ekungaba ziintjhijilo abahlangana nazo nofana lokhu abakufundileko. Abantu bacoca ngeenhloko ezikhona kodwana ezingekho etjhatjhalazini isibonelo ukuthwala, ukunikela abantu ilwazi ngazo ukuthi bazi bonyana zikhona izinto ezinjalo emphakathini.&lt;ref&gt;Greene, S., Burke, K.J. and McKenna, M.K., 2018. A review of research connecting digital storytelling, photovoice, and civic engagement. ''Review of Educational Research'', ''88''(6), pp.844-878.&lt;/ref&gt; Abantu bangakghona ukuzibandakanya ekucoceni indaba ngedijithali ngokuthi bakhulume iindaba ezimraro emphakathini ezifana nalesi zeenhloko zokungatholi ubulungiswa, ukuphela kwebhoduluko, ubulelesi nezinye iiinhloko.

==== Amakhampheyini wokulungisa imiraro yomphakathi ====
[[Ilutjha]] lisebenzisa iinkundla zokuthintana ukuthoma amakhapheyini alungisa imiraro yomphakathi isibonelo amakhapheyini afana ne ''# black lives matter, ne # ME TOO. i- # black lives matter''  yona ihlose ukuthi ilwisane nokubandlululana ngokombala, nokungaphathwa kuhle kwabantu abanzima emphakathini .Abanye abavula amatjhaneli we''-youtube'' bese benze ikhonthenti ephikisa ukucoca kwabantu, begodu ikhuthaze ukwahlukana kwabantu ngemibono yabo. Isibonelo selutjha elinamatjhaneli we- youtube ngu Lasizwe Dambuza onabalandeli abangaphezulu kwe- 738 000 etjhanelini yakhe.&lt;ref&gt;[https://www.news24.com/truelove/celebrity/lasizwe-hits-1-million-subs-10-memorable-a-list-guests-from-awkward-dates-20241216 Lasizwe hits 1 million subs! 10 memorable A-list guests from Awkward Dates | News24]&lt;/ref&gt; I-Facebook nayo iyasetjenziswa ukucoca indaba ngokuthi abantu bafake amavidiyo, batlole indaba nokuthi baveze into eyenzeka ngaleso skhathi buncopha.

== Iinkomba ==</text>
      <sha1>lfce0915zmomfz9o2qfdrhmmh0glhru</sha1>
    </revision>
    <revision>
      <id>3328</id>
      <parentid>3327</parentid>
      <timestamp>2025-07-07T18:29:46Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3328</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4804" sha1="mtnn8gjosm8y3cmjtigjgqsyrtkugxn" xml:space="preserve">[[Isimumathi:Lasizwe Dambuza on MacG.jpg|thumb|ULasizwe Dambuza ngomunye welutjha elinetjhaneli ye-youtube]]
'''Ukucoca iindaba''' kukulokha umuntu acocela abalaleli indaba ayitlolileko nofana azitlamele yona ngehloko yakhe. Kuyinto eyabe isetjenziswa ekadeni ukufundosa abantu ngombana lokha nawulalele iindaba ukghona ukuthola isifundo.&lt;ref&gt;Palacios, J., 2012. Traditional storytelling in the digital era. ''Fourth World Journal'', ''11''(2), pp.41-56.&lt;/ref&gt; Abantu bakghona ukucoca indaba ngekhambo labo lepilo,  nofana ngeenhloko ezingaba mraro nofana iintjhijilo abantu abahlangana nazo emphakathini. Esikhathini sanje, ithekonoloji sele ithuthukile, abantu bakghona ukucoca indaba ngediithali. Ilutjha lisebenzisa abomaliledinini banje abahlakaniphileko, amakhamera, nokhunye ukucoca indaba ngedijithali bakghone ukwabelana nabanye abantu abakude indaba. Ilutjha lizibandakanya ekucoceni indaba ngedijithali ngombana likghona ukusebenzisa itheknoloji.

=== Iindlela zokucoca iiindaba ngedijithali ===
Ukucoca iindaba ngedijithali kungenzeka ngendlela ezinengi, njengokuthi kwenziwe amavidiyo, amabhlogo ekukulapho kutlolwa khona indaba nofana okumunyethweko kwelanga, abanye batlola eenkundleni zokuthintana ukulekelela ilutjha bona likghone ukuziveza ngendlela ezihlukahluneko ezingakghona ngazo.&lt;ref&gt;Shahid, M. and Khan, M.R., 2022. Use of digital storytelling in classrooms and beyond. ''Journal of Educational Technology Systems'', ''51''(1), pp.63-77.&lt;/ref&gt; Amaphodkhasti wona asebenza khulu lapho kucocwa khona indaba ngamaphimbo ngehloso yokufundisa, ukucocisana ngesihloko esithize nofana ukuhlunga.&lt;ref&gt;Ferrer, I., Shaw, J. and Lorenzetti, L., 2021. Ethical storytelling and digital narratives: Lessons learned in student-led podcasts and community radio partnerships. ''Journal of Social Work Values and Ethics'', ''18''(1), pp.90-104.&lt;/ref&gt;Omunye welutjha owenza i phodkhasti ngu MacG, yena owathoma i phodkhasti le ngehloso yokufundisa, ukuthabisa nokuhlekisa abantu.&lt;ref&gt;Motsaathebe, G., 2023. Evolving Trends in Radio Broadcasting in South Africa: The Case of Podcast and Chill with macg. In ''100 Years of Radio in South Africa, Volume 2: Community Radio, Digital Radio and the Future of Radio in South Africa'' (pp. 161-177). Cham: Springer Nature Switzerland.&lt;/ref&gt; Ubiza abantu beSewula Afrika abaziwako ngokuvela kumabonakude nokhunye bese bacocisane nabo bakhulume ngamaphilo wabo.

=== Umsebenzi wokusebenzisa udijithali ukucoca iindaba ===

==== Ukufundisa umphakathi ====
Ilutjha lisebenzisa ukucoca iindaba ngedijithali njengo msikinyeko wokubonisa umphakathi ngemiraro yawo, ithuthukise ubulungiswa emphakathini. Okhunye godu ilutjha likhuluma ngemibono yalo, nezinto ekhezahlangana nazo ezingasiza abanye abantu nofana zibaphe isaluleko. Ukucoca indaba ngedijithali kulekelela abantu abangaka dumi emphakathini bonyana bakghone ukukhuluma bezwiwe babanu abanengi. Ukucoca indaba ngedijithali kukhuthaza nokuhluka okukhamba nokwamukelana kwabantu boke. Lokha nawusebenzisa idijithali ukucoca indaba ukghona ukunikela amalunga womphakathi indawo yokuthi bakghone ukucoca indaba zabo, ekungaba ziintjhijilo abahlangana nazo nofana lokhu abakufundileko. Abantu bacoca ngeenhloko ezikhona kodwana ezingekho etjhatjhalazini isibonelo ukuthwala, ukunikela abantu ilwazi ngazo ukuthi bazi bonyana zikhona izinto ezinjalo emphakathini.&lt;ref&gt;Greene, S., Burke, K.J. and McKenna, M.K., 2018. A review of research connecting digital storytelling, photovoice, and civic engagement. ''Review of Educational Research'', ''88''(6), pp.844-878.&lt;/ref&gt; Abantu bangakghona ukuzibandakanya ekucoceni indaba ngedijithali ngokuthi bakhulume iindaba ezimraro emphakathini ezifana nalesi zeenhloko zokungatholi ubulungiswa, ukuphela kwebhoduluko, ubulelesi nezinye iiinhloko.

==== Amakhampheyini wokulungisa imiraro yomphakathi ====
[[Ilutjha]] lisebenzisa iinkundla zokuthintana ukuthoma amakhapheyini alungisa imiraro yomphakathi isibonelo amakhapheyini afana ne ''# black lives matter, ne # ME TOO. i- # black lives matter''  yona ihlose ukuthi ilwisane nokubandlululana ngokombala, nokungaphathwa kuhle kwabantu abanzima emphakathini .Abanye abavula amatjhaneli we''-youtube'' bese benze ikhonthenti ephikisa ukucoca kwabantu, begodu ikhuthaze ukwahlukana kwabantu ngemibono yabo. Isibonelo selutjha elinamatjhaneli we- youtube ngu Lasizwe Dambuza onabalandeli abangaphezulu kwe- 738 000 etjhanelini yakhe.&lt;ref&gt;[https://www.news24.com/truelove/celebrity/lasizwe-hits-1-million-subs-10-memorable-a-list-guests-from-awkward-dates-20241216 Lasizwe hits 1 million subs! 10 memorable A-list guests from Awkward Dates | News24]&lt;/ref&gt; I-Facebook nayo iyasetjenziswa ukucoca indaba ngokuthi abantu bafake amavidiyo, batlole indaba nokuthi baveze into eyenzeka ngaleso skhathi buncopha.

== Iinkomba ==</text>
      <sha1>mtnn8gjosm8y3cmjtigjgqsyrtkugxn</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Roxanne2019</title>
    <ns>2</ns>
    <id>673</id>
    <revision>
      <id>3330</id>
      <timestamp>2025-07-08T12:42:20Z</timestamp>
      <contributor>
        <username>Roxanne2019</username>
        <id>755</id>
      </contributor>
      <comment>Created page with &quot;  WikipediaThe Free Encyclopedia Search Wikipedia Search Roxanne2019   Editing User:Roxanne2019  Homepage User page Talk Read Edit source View history  Tools  Content that violates any copyrights will be deleted. Encyclopedic content must be verifiable through citations to reliable sources. Advanced Special characters Help Cite This is my draft my user is Roxanne2019  [[User:Roxanne2019/Page 1|Page 1]]  | [[User:Roxanne2019/Page 2|page 2]]  | User:Roxanne2019/Page 3|pa...&quot;</comment>
      <origin>3330</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1304" sha1="soiu9ikipxlxkzw4u3foskpvl9n8xnk" xml:space="preserve">

WikipediaThe Free Encyclopedia
Search Wikipedia
Search
Roxanne2019


Editing User:Roxanne2019

Homepage
User page
Talk
Read
Edit source
View history

Tools
 Content that violates any copyrights will be deleted. Encyclopedic content must be verifiable through citations to reliable sources.
Advanced
Special characters
Help
Cite
This is my draft my user is Roxanne2019

[[User:Roxanne2019/Page 1|Page 1]]  | [[User:Roxanne2019/Page 2|page 2]]  | [[User:Roxanne2019/Page 3|page 3]]  | [[User:Roxanne2019/Shortcut|Shortcut]]


Insert
  – — ° ′ ″ ≈ ≠ ≤ ≥ ± − × ÷ ← → · §   Sign your posts on talk pages: [[Umsebenzisi:Roxanne2019|Roxanne2019]] ([[Umsebenzisi asiqongelane:Roxanne2019|talk]]) 14:42, 8 Ntulikazi 2025 (SAST)   Cite your sources: &lt;ref&gt;&lt;/ref&gt;
Edit summary (Briefly describe your changes)
	This is a minor edit
	Watch this page
Watchlist time period:
By publishing changes, you agree to the Terms of Use, and you irrevocably agree to release your contribution under the CC BY-SA 4.0 License and the GFDL. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
   
Privacy policyAbout WikipediaDisclaimersContact WikipediaCode of ConductDevelopersStatisticsCookie statementMobile view
Wikimedia Foundation
Powered by MediaWiki</text>
      <sha1>soiu9ikipxlxkzw4u3foskpvl9n8xnk</sha1>
    </revision>
    <revision>
      <id>3331</id>
      <parentid>3330</parentid>
      <timestamp>2025-07-08T12:46:27Z</timestamp>
      <contributor>
        <username>Roxanne2019</username>
        <id>755</id>
      </contributor>
      <comment>Umsebenzi wokutlhatlhabeja</comment>
      <origin>3331</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="194" sha1="51vrjra1dsfgm6ecua1023psyuviztf" xml:space="preserve">
This is my draft my user is Roxanne2019

[[User:Roxanne2019/Page 1|Page 1]]  | [[User:Roxanne2019/Page 2|page 2]]  | [[User:Roxanne2019/Page 3|page 3]]  | [[User:Roxanne2019/Shortcut|Shortcut]]</text>
      <sha1>51vrjra1dsfgm6ecua1023psyuviztf</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Roxanne2019/Page 1</title>
    <ns>2</ns>
    <id>674</id>
    <revision>
      <id>3332</id>
      <timestamp>2025-07-08T12:48:43Z</timestamp>
      <contributor>
        <username>Roxanne2019</username>
        <id>755</id>
      </contributor>
      <comment>Ukutlhatlhabeja 1</comment>
      <origin>3332</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="24" sha1="p9xzie2tlj3yp6hw26woup44l5ve8m8" xml:space="preserve">This is my draft space 1</text>
      <sha1>p9xzie2tlj3yp6hw26woup44l5ve8m8</sha1>
    </revision>
    <revision>
      <id>3336</id>
      <parentid>3332</parentid>
      <timestamp>2025-07-08T13:09:47Z</timestamp>
      <contributor>
        <username>Roxanne2019</username>
        <id>755</id>
      </contributor>
      <origin>3336</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="54" sha1="e01apq9y24eplfn0f1gsf4lrewfttnb" xml:space="preserve">This is my draft space 1
---

---

Original page;

---</text>
      <sha1>e01apq9y24eplfn0f1gsf4lrewfttnb</sha1>
    </revision>
    <revision>
      <id>3337</id>
      <parentid>3336</parentid>
      <timestamp>2025-07-08T13:10:12Z</timestamp>
      <contributor>
        <username>Roxanne2019</username>
        <id>755</id>
      </contributor>
      <origin>3337</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="55" sha1="f3dyan2vdpsqc08l8xjjv2di6ev86oc" xml:space="preserve">This is my draft space 1

---

---

Original page;

---</text>
      <sha1>f3dyan2vdpsqc08l8xjjv2di6ev86oc</sha1>
    </revision>
    <revision>
      <id>3338</id>
      <parentid>3337</parentid>
      <timestamp>2025-07-09T07:13:06Z</timestamp>
      <contributor>
        <username>Roxanne2019</username>
        <id>755</id>
      </contributor>
      <origin>3338</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1479" sha1="jtc39p42wx14g43plih0tau9d6lua6u" xml:space="preserve">This is my draft space 1

Ibulungo leencwadi kuyindawo yomphakathi lapho kubekwa khona iincwadi ngokwahlukahlukana ukuthi abantu bakghone ukuzifunda begodu bathole ilwazi ngeenhloko ezahlukahlukeneko abazithandako. Ibulungo leencwadi lenza bona abantu bakghone ukuthola ilwazi lezinto lakade nelakhathesu. Lithuthukisa izinga lefundo yabantu ngombana bakghona ukuthola imithombo yelwazi eminengi efaka hlangana neencwadi, amajenali, ne inthaneti lapho bazokufuna khona ilwazi.

---

Original page;

---

[[Ibulungelo leencwadi|'''Ibulungelo leencwadi''']]

'''Ibulungelo leencwadi''' kuyindawo yomphakathi lapho kubekwe khona '''iiincwad'''i ngokwahlukahlukana ukuthi abantu bakghone ukuzifunda begodu bathole ilwazi ngeenhloko ezahlukahlukeneko abazithandako. Ibulungelo '''lencwadi''' lenza bona abantu bakghone ukuthola [[ilwazi]] lakade '''nelanje ngezinto zanje'''. Lithuthukisa izinga lefundo yabantu ngombana '''abantu''' bakghona ukuthola imithombo yelwazi eminengi '''efana''' neencwadi, amajenali, ne inthaneti lapho bazokufuna '''khona''' khona ilwazi.

== Ulando ==

== Iinkomba ==
&lt;references /&gt;
Braun, L. W. (2015). THE FUTURE OF LIBRARY SERVICES TO TEENS. ''American Libraries'', ''46''(5), 50–53. http://www.jstor.org/stable/24604107

Searing, S. E., &amp; Greenlee, A. M. (2011). Faculty Responses to Library Service Innovations: A Case Study. ''Journal of Education for Library and Information Science'', ''52''(4), 279–294. http://www.jstor.org/stable/41308904</text>
      <sha1>jtc39p42wx14g43plih0tau9d6lua6u</sha1>
    </revision>
    <revision>
      <id>3339</id>
      <parentid>3338</parentid>
      <timestamp>2025-07-09T08:20:37Z</timestamp>
      <contributor>
        <username>Roxanne2019</username>
        <id>755</id>
      </contributor>
      <origin>3339</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2018" sha1="3zivbm3sfp3ycieqtnj7sy6utno5l7p" xml:space="preserve">This is my draft space 1

Ibulungelo leencwadi kuyindawo yomphakathi lapho kubekwa khona iincwadi ngokwahlukahlukana kwazo ukuthi abantu bakghone ukuzifunda begodu bathole ilwazi ngeenhloko ezahlukahlukeneko abazithandako. Ibulungelo leencwadi lenza bona abantu bakghone ukuthola ilwazi lezinto zakade nezakhathesu. Lithuthukisa izinga lefundo yabantu ngombana bakghona ukuthola imithombo yelwazi eminengi efaka hlangana neencwadi, amajenali, ne inthaneti lapho bazokufuna khona ilwazi.

---

Original page; [[Ibulungelo leencwadi|'''Ibulungelo leencwadi''']]

'''Ibulungelo leencwadi''' kuyindawo yomphakathi lapho kubekwe khona '''iiincwad'''i ngokwahlukahlukana ukuthi abantu bakghone ukuzifunda begodu bathole ilwazi ngeenhloko ezahlukahlukeneko abazithandako. Ibulungelo '''lencwadi''' lenza bona abantu bakghone ukuthola [[ilwazi]] lakade '''nelanje ngezinto zanje'''. Lithuthukisa izinga lefundo yabantu ngombana '''abantu''' bakghona ukuthola imithombo yelwazi eminengi '''efana''' neencwadi, amajenali, ne inthaneti lapho bazokufuna '''khona''' khona ilwazi.

== Umlando ==
Umlando webulungelo leencwadi wathoma ngemizamo yokuthoma yokuhlela amaphepha abalulekileko. Iinhloko ezidosa amehlo ezifaka hlangana ukurhweba kweencwadi, ukusabalaliswa kwelimi, indima emfundweni, izakhiwo, amazinga wokufunda nokutlola, ukusebenziswa kwamabulungelo weencwadi zamagugu wamasiko wesitjhaba, kanye nendima karhulumende, isondo nofana ukusejelwa kwangesese. Ukusetjenziswa kwamakhomphyutha nokudijithali kwavela ngeminyaka yabo-1960, begodu kwatjhugulula izinto ezinengi zamabulungelo weencwadi. 

== Iinkomba ==
&lt;references /&gt;
&lt;big&gt;Braun, L. W. (2015). THE FUTURE OF LIBRARY SERVICES TO TEENS. ''American Libraries'', ''46''(5), 50–53. http://www.jstor.org/stable/24604107&lt;/big&gt;

&lt;big&gt;Searing, S. E., &amp; Greenlee, A. M. (2011). Faculty Responses to Library Service Innovations: A Case Study. ''Journal of Education for Library and Information Science'', ''52''(4), 279–294. http://www.jstor.org/stable/41308904&lt;/big&gt;</text>
      <sha1>3zivbm3sfp3ycieqtnj7sy6utno5l7p</sha1>
    </revision>
    <revision>
      <id>3340</id>
      <parentid>3339</parentid>
      <timestamp>2025-07-09T09:48:15Z</timestamp>
      <contributor>
        <username>Roxanne2019</username>
        <id>755</id>
      </contributor>
      <comment>with reference</comment>
      <origin>3340</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2233" sha1="1x90n7io31p7p06x2furfbw90h69215" xml:space="preserve">This is my draft space 1

Ibulungelo leencwadi kuyindawo yomphakathi lapho kubekwa khona iincwadi ngokwahlukahlukana kwazo ukuthi abantu bakghone ukuzifunda begodu bathole ilwazi ngeenhloko ezahlukahlukeneko abazithandako. Ibulungelo leencwadi lenza bona abantu bakghone ukuthola ilwazi lezinto zakade nezakhathesu. Lithuthukisa izinga lefundo yabantu ngombana bakghona ukuthola imithombo yelwazi eminengi efaka hlangana neencwadi, amajenali, ne inthaneti lapho bazokufuna khona ilwazi.Reference 3 &lt;ref&gt;{{Citation|title=History of libraries|date=2025-06-20|work=Wikipedia|url=https://en.wikipedia.org/w/index.php?title=History_of_libraries&amp;oldid=1296583094|access-date=2025-07-09|language=en}}&lt;/ref&gt;

--- 

Original page; [[Ibulungelo leencwadi|'''Ibulungelo leencwadi''']]

'''Ibulungelo leencwadi''' kuyindawo yomphakathi lapho kubekwe khona '''iiincwad'''i ngokwahlukahlukana ukuthi abantu bakghone ukuzifunda begodu bathole ilwazi ngeenhloko ezahlukahlukeneko abazithandako. Ibulungelo '''lencwadi''' lenza bona abantu bakghone ukuthola [[ilwazi]] lakade '''nelanje ngezinto zanje'''. Lithuthukisa izinga lefundo yabantu ngombana '''abantu''' bakghona ukuthola imithombo yelwazi eminengi '''efana''' neencwadi, amajenali, ne inthaneti lapho bazokufuna '''khona''' khona ilwazi.

== Umlando ==
Umlando webulungelo leencwadi wathoma ngemizamo yokuthoma yokuhlela amaphepha abalulekileko. Iinhloko ezidosa amehlo ezifaka hlangana ukurhweba kweencwadi, ukusabalaliswa kwelimi, indima emfundweni, izakhiwo, amazinga wokufunda nokutlola, ukusebenziswa kwamabulungelo weencwadi zamagugu wamasiko wesitjhaba, kanye nendima karhulumende, isondo nofana ukusejelwa kwangesese. Ukusetjenziswa kwamakhomphyutha nokudijithali kwavela ngeminyaka yabo-1960, begodu kwatjhugulula izinto ezinengi zamabulungelo weencwadi.  

== Iinkomba ==
&lt;references /&gt;
&lt;big&gt;Braun, L. W. (2015). THE FUTURE OF LIBRARY SERVICES TO TEENS. ''American Libraries'', ''46''(5), 50–53. http://www.jstor.org/stable/24604107&lt;/big&gt;

&lt;big&gt;Searing, S. E., &amp; Greenlee, A. M. (2011). Faculty Responses to Library Service Innovations: A Case Study. ''Journal of Education for Library and Information Science'', ''52''(4), 279–294. http://www.jstor.org/stable/41308904&lt;/big&gt;</text>
      <sha1>1x90n7io31p7p06x2furfbw90h69215</sha1>
    </revision>
    <revision>
      <id>3341</id>
      <parentid>3340</parentid>
      <timestamp>2025-07-09T09:53:20Z</timestamp>
      <contributor>
        <username>Roxanne2019</username>
        <id>755</id>
      </contributor>
      <origin>3341</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2028" sha1="4rjqgbv2r6bajz59j6uid9afskyazbe" xml:space="preserve">This is my draft space 1

Ibulungelo leencwadi kuyindawo yomphakathi lapho kubekwa khona iincwadi ngokwahlukahlukana kwazo ukuthi abantu bakghone ukuzifunda begodu bathole ilwazi ngeenhloko ezahlukahlukeneko abazithandako. Ibulungelo leencwadi lenza bona abantu bakghone ukuthola ilwazi lezinto zakade nezakhathesu. Lithuthukisa izinga lefundo yabantu ngombana bakghona ukuthola imithombo yelwazi eminengi efaka hlangana neencwadi, amajenali, ne inthaneti lapho bazokufuna khona ilwazi&lt;ref /&gt;. 

--- 

Original page; [[Ibulungelo leencwadi|'''Ibulungelo leencwadi''']]

'''Ibulungelo leencwadi''' kuyindawo yomphakathi lapho kubekwe khona '''iiincwad'''i ngokwahlukahlukana ukuthi abantu bakghone ukuzifunda begodu bathole ilwazi ngeenhloko ezahlukahlukeneko abazithandako. Ibulungelo '''lencwadi''' lenza bona abantu bakghone ukuthola [[ilwazi]] lakade '''nelanje ngezinto zanje'''. Lithuthukisa izinga lefundo yabantu ngombana '''abantu''' bakghona ukuthola imithombo yelwazi eminengi '''efana''' neencwadi, amajenali, ne inthaneti lapho bazokufuna '''khona''' khona ilwazi.

== Umlando ==
Umlando webulungelo leencwadi wathoma ngemizamo yokuthoma yokuhlela amaphepha abalulekileko. Iinhloko ezidosa amehlo ezifaka hlangana ukurhweba kweencwadi, ukusabalaliswa kwelimi, indima emfundweni, izakhiwo, amazinga wokufunda nokutlola, ukusebenziswa kwamabulungelo weencwadi zamagugu wamasiko wesitjhaba, kanye nendima karhulumende, isondo nofana ukusejelwa kwangesese. Ukusetjenziswa kwamakhomphyutha nokudijithali kwavela ngeminyaka yabo-1960, begodu kwatjhugulula izinto ezinengi zamabulungelo weencwadi.  

== Iinkomba ==
&lt;references /&gt;
&lt;big&gt;Braun, L. W. (2015). THE FUTURE OF LIBRARY SERVICES TO TEENS. ''American Libraries'', ''46''(5), 50–53. http://www.jstor.org/stable/24604107&lt;/big&gt;

&lt;big&gt;Searing, S. E., &amp; Greenlee, A. M. (2011). Faculty Responses to Library Service Innovations: A Case Study. ''Journal of Education for Library and Information Science'', ''52''(4), 279–294. http://www.jstor.org/stable/41308904&lt;/big&gt;</text>
      <sha1>4rjqgbv2r6bajz59j6uid9afskyazbe</sha1>
    </revision>
    <revision>
      <id>3342</id>
      <parentid>3341</parentid>
      <timestamp>2025-07-09T09:57:06Z</timestamp>
      <contributor>
        <username>Roxanne2019</username>
        <id>755</id>
      </contributor>
      <comment>Edits with references</comment>
      <origin>3342</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2021" sha1="0bvf1chzvy3jjn1gsqv20neksg48ncp" xml:space="preserve">This is my draft space 1

Ibulungelo leencwadi kuyindawo yomphakathi lapho kubekwa khona iincwadi ngokwahlukahlukana kwazo ukuthi abantu bakghone ukuzifunda begodu bathole ilwazi ngeenhloko ezahlukahlukeneko abazithandako. Ibulungelo leencwadi lenza bona abantu bakghone ukuthola ilwazi lezinto zakade nezakhathesu. Lithuthukisa izinga lefundo yabantu ngombana bakghona ukuthola imithombo yelwazi eminengi efaka hlangana neencwadi, amajenali, ne inthaneti lapho bazokufuna khona ilwazi. 

--- 

Original page; [[Ibulungelo leencwadi|'''Ibulungelo leencwadi''']]

'''Ibulungelo leencwadi''' kuyindawo yomphakathi lapho kubekwe khona '''iiincwad'''i ngokwahlukahlukana ukuthi abantu bakghone ukuzifunda begodu bathole ilwazi ngeenhloko ezahlukahlukeneko abazithandako. Ibulungelo '''lencwadi''' lenza bona abantu bakghone ukuthola [[ilwazi]] lakade '''nelanje ngezinto zanje'''. Lithuthukisa izinga lefundo yabantu ngombana '''abantu''' bakghona ukuthola imithombo yelwazi eminengi '''efana''' neencwadi, amajenali, ne inthaneti lapho bazokufuna '''khona''' khona ilwazi.

== Umlando ==
Umlando webulungelo leencwadi wathoma ngemizamo yokuthoma yokuhlela amaphepha abalulekileko. Iinhloko ezidosa amehlo ezifaka hlangana ukurhweba kweencwadi, ukusabalaliswa kwelimi, indima emfundweni, izakhiwo, amazinga wokufunda nokutlola, ukusebenziswa kwamabulungelo weencwadi zamagugu wamasiko wesitjhaba, kanye nendima karhulumende, isondo nofana ukusejelwa kwangesese. Ukusetjenziswa kwamakhomphyutha nokudijithali kwavela ngeminyaka yabo-1960, begodu kwatjhugulula izinto ezinengi zamabulungelo weencwadi.  

== Iinkomba ==
&lt;references /&gt;
&lt;big&gt;Braun, L. W. (2015). THE FUTURE OF LIBRARY SERVICES TO TEENS. ''American Libraries'', ''46''(5), 50–53. http://www.jstor.org/stable/24604107&lt;/big&gt;

&lt;big&gt;Searing, S. E., &amp; Greenlee, A. M. (2011). Faculty Responses to Library Service Innovations: A Case Study. ''Journal of Education for Library and Information Science'', ''52''(4), 279–294. http://www.jstor.org/stable/41308904&lt;/big&gt;</text>
      <sha1>0bvf1chzvy3jjn1gsqv20neksg48ncp</sha1>
    </revision>
    <revision>
      <id>3343</id>
      <parentid>3342</parentid>
      <timestamp>2025-07-09T09:57:55Z</timestamp>
      <contributor>
        <username>Roxanne2019</username>
        <id>755</id>
      </contributor>
      <comment>/* Iinkomba */</comment>
      <origin>3343</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1628" sha1="bzpu9wzmlfj4x5ceu3tpjmp0gj396o4" xml:space="preserve">This is my draft space 1

Ibulungelo leencwadi kuyindawo yomphakathi lapho kubekwa khona iincwadi ngokwahlukahlukana kwazo ukuthi abantu bakghone ukuzifunda begodu bathole ilwazi ngeenhloko ezahlukahlukeneko abazithandako. Ibulungelo leencwadi lenza bona abantu bakghone ukuthola ilwazi lezinto zakade nezakhathesu. Lithuthukisa izinga lefundo yabantu ngombana bakghona ukuthola imithombo yelwazi eminengi efaka hlangana neencwadi, amajenali, ne inthaneti lapho bazokufuna khona ilwazi. 

--- 

Original page; [[Ibulungelo leencwadi|'''Ibulungelo leencwadi''']]

'''Ibulungelo leencwadi''' kuyindawo yomphakathi lapho kubekwe khona '''iiincwad'''i ngokwahlukahlukana ukuthi abantu bakghone ukuzifunda begodu bathole ilwazi ngeenhloko ezahlukahlukeneko abazithandako. Ibulungelo '''lencwadi''' lenza bona abantu bakghone ukuthola [[ilwazi]] lakade '''nelanje ngezinto zanje'''. Lithuthukisa izinga lefundo yabantu ngombana '''abantu''' bakghona ukuthola imithombo yelwazi eminengi '''efana''' neencwadi, amajenali, ne inthaneti lapho bazokufuna '''khona''' khona ilwazi.

== Umlando ==
Umlando webulungelo leencwadi wathoma ngemizamo yokuthoma yokuhlela amaphepha abalulekileko. Iinhloko ezidosa amehlo ezifaka hlangana ukurhweba kweencwadi, ukusabalaliswa kwelimi, indima emfundweni, izakhiwo, amazinga wokufunda nokutlola, ukusebenziswa kwamabulungelo weencwadi zamagugu wamasiko wesitjhaba, kanye nendima karhulumende, isondo nofana ukusejelwa kwangesese. Ukusetjenziswa kwamakhomphyutha nokudijithali kwavela ngeminyaka yabo-1960, begodu kwatjhugulula izinto ezinengi zamabulungelo weencwadi.  

== Iinkomba ==
&lt;references /&gt;</text>
      <sha1>bzpu9wzmlfj4x5ceu3tpjmp0gj396o4</sha1>
    </revision>
    <revision>
      <id>3344</id>
      <parentid>3343</parentid>
      <timestamp>2025-07-09T09:58:48Z</timestamp>
      <contributor>
        <username>Roxanne2019</username>
        <id>755</id>
      </contributor>
      <origin>3344</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1829" sha1="ks6nsqt7lmo4f6rdvcleemwy7pphdsj" xml:space="preserve">This is my draft space 1

Ibulungelo leencwadi kuyindawo yomphakathi lapho kubekwa khona iincwadi ngokwahlukahlukana kwazo ukuthi abantu bakghone ukuzifunda begodu bathole ilwazi ngeenhloko ezahlukahlukeneko abazithandako. Ibulungelo leencwadi lenza bona abantu bakghone ukuthola ilwazi lezinto zakade nezakhathesu. Lithuthukisa izinga lefundo yabantu ngombana bakghona ukuthola imithombo yelwazi eminengi efaka hlangana neencwadi, amajenali, ne inthaneti lapho bazokufuna khona ilwazi.&lt;ref&gt;{{Citation|title=History of libraries|date=2025-06-20|work=Wikipedia|url=https://en.wikipedia.org/w/index.php?title=History_of_libraries&amp;oldid=1296583094|access-date=2025-07-09|language=en}}&lt;/ref&gt; 

--- 

Original page; [[Ibulungelo leencwadi|'''Ibulungelo leencwadi''']]

'''Ibulungelo leencwadi''' kuyindawo yomphakathi lapho kubekwe khona '''iiincwad'''i ngokwahlukahlukana ukuthi abantu bakghone ukuzifunda begodu bathole ilwazi ngeenhloko ezahlukahlukeneko abazithandako. Ibulungelo '''lencwadi''' lenza bona abantu bakghone ukuthola [[ilwazi]] lakade '''nelanje ngezinto zanje'''. Lithuthukisa izinga lefundo yabantu ngombana '''abantu''' bakghona ukuthola imithombo yelwazi eminengi '''efana''' neencwadi, amajenali, ne inthaneti lapho bazokufuna '''khona''' khona ilwazi.

== Umlando ==
Umlando webulungelo leencwadi wathoma ngemizamo yokuthoma yokuhlela amaphepha abalulekileko. Iinhloko ezidosa amehlo ezifaka hlangana ukurhweba kweencwadi, ukusabalaliswa kwelimi, indima emfundweni, izakhiwo, amazinga wokufunda nokutlola, ukusebenziswa kwamabulungelo weencwadi zamagugu wamasiko wesitjhaba, kanye nendima karhulumende, isondo nofana ukusejelwa kwangesese. Ukusetjenziswa kwamakhomphyutha nokudijithali kwavela ngeminyaka yabo-1960, begodu kwatjhugulula izinto ezinengi zamabulungelo weencwadi.  

== Iinkomba ==
&lt;references /&gt;</text>
      <sha1>ks6nsqt7lmo4f6rdvcleemwy7pphdsj</sha1>
    </revision>
    <revision>
      <id>3353</id>
      <parentid>3344</parentid>
      <timestamp>2025-07-09T10:15:28Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <origin>3353</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1825" sha1="5ndgzui7d943hgbr2q8pgdj5guqw8mx" xml:space="preserve">This is my draft space 1

Ibulungelo leencwadi kuyindawo yomphakathi lapho kubekwa khona iincwadi ngokwahlukahlukana kwazo ukuthi abantu bakghone ukuzifunda begodu bathole ilwazi ngeenhloko ezahlukahlukeneko abazithandako. Ibulungelo leencwadi lenza bona abantu bakghone ukuthola ilwazi lezinto zakade nezakhathesu. Lithuthukisa izinga lefundo yabantu ngombana bakghona ukuthola imithombo yelwazi eminengi efaka hlangana neencwadi, amajenali, ne inthaneti lapho bazokufuna khona ilwazi.&lt;ref&gt;{{Cite|title=History of libraries|date=2025-06-20|work=Wikipedia|url=https://en.wikipedia.org/w/index.php?title=History_of_libraries&amp;oldid=1296583094|access-date=2025-07-09|language=en}}&lt;/ref&gt; 

--- 

Original page; [[Ibulungelo leencwadi|'''Ibulungelo leencwadi''']]

'''Ibulungelo leencwadi''' kuyindawo yomphakathi lapho kubekwe khona '''iiincwad'''i ngokwahlukahlukana ukuthi abantu bakghone ukuzifunda begodu bathole ilwazi ngeenhloko ezahlukahlukeneko abazithandako. Ibulungelo '''lencwadi''' lenza bona abantu bakghone ukuthola [[ilwazi]] lakade '''nelanje ngezinto zanje'''. Lithuthukisa izinga lefundo yabantu ngombana '''abantu''' bakghona ukuthola imithombo yelwazi eminengi '''efana''' neencwadi, amajenali, ne inthaneti lapho bazokufuna '''khona''' khona ilwazi.

== Umlando ==
Umlando webulungelo leencwadi wathoma ngemizamo yokuthoma yokuhlela amaphepha abalulekileko. Iinhloko ezidosa amehlo ezifaka hlangana ukurhweba kweencwadi, ukusabalaliswa kwelimi, indima emfundweni, izakhiwo, amazinga wokufunda nokutlola, ukusebenziswa kwamabulungelo weencwadi zamagugu wamasiko wesitjhaba, kanye nendima karhulumende, isondo nofana ukusejelwa kwangesese. Ukusetjenziswa kwamakhomphyutha nokudijithali kwavela ngeminyaka yabo-1960, begodu kwatjhugulula izinto ezinengi zamabulungelo weencwadi.  

== Iinkomba ==
&lt;references /&gt;</text>
      <sha1>5ndgzui7d943hgbr2q8pgdj5guqw8mx</sha1>
    </revision>
    <revision>
      <id>3356</id>
      <parentid>3353</parentid>
      <timestamp>2025-07-09T10:22:30Z</timestamp>
      <contributor>
        <username>Roxanne2019</username>
        <id>755</id>
      </contributor>
      <origin>3356</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1829" sha1="pvzmj4psic77szhxw0yanzi59o9efhu" xml:space="preserve">This is my draft space 1

Ibulungelo leencwadi kuyindawo yomphakathi lapho kubekwa khona iincwadi ngokwahlukahlukana kwazo ukuthi abantu bakghone ukuzifunda begodu bathole ilwazi ngeenhloko ezahlukahlukeneko abazithandako. Ibulungelo leencwadi lenza bona abantu bakghone ukuthola ilwazi lezinto zakade nezakhathesu. Lithuthukisa izinga lefundo yabantu ngombana bakghona ukuthola imithombo yelwazi eminengi efaka hlangana neencwadi, amajenali, ne inthaneti lapho bazokufuna khona ilwazi. 

--- 

Original page; [[Ibulungelo leencwadi|'''Ibulungelo leencwadi''']]

'''Ibulungelo leencwadi''' kuyindawo yomphakathi lapho kubekwe khona '''iiincwad'''i ngokwahlukahlukana ukuthi abantu bakghone ukuzifunda begodu bathole ilwazi ngeenhloko ezahlukahlukeneko abazithandako. Ibulungelo '''lencwadi''' lenza bona abantu bakghone ukuthola [[ilwazi]] lakade '''nelanje ngezinto zanje'''. Lithuthukisa izinga lefundo yabantu ngombana '''abantu''' bakghona ukuthola imithombo yelwazi eminengi '''efana''' neencwadi, amajenali, ne inthaneti lapho bazokufuna '''khona''' khona ilwazi.

== Umlando ==
Umlando webulungelo leencwadi wathoma ngemizamo yokuthoma yokuhlela amaphepha abalulekileko. Iinhloko ezidosa amehlo ezifaka hlangana ukurhweba kweencwadi, ukusabalaliswa kwelimi, indima emfundweni, izakhiwo, amazinga wokufunda nokutlola, ukusebenziswa kwamabulungelo weencwadi zamagugu wamasiko wesitjhaba, kanye nendima karhulumende, isondo nofana ukusejelwa kwangesese. Ukusetjenziswa kwamakhomphyutha nokudijithali kwavela ngeminyaka yabo-1960, begodu kwatjhugulula izinto ezinengi zamabulungelo weencwadi.&lt;ref&gt;{{Citation|title=History of libraries|date=2025-06-20|work=Wikipedia|url=https://en.wikipedia.org/w/index.php?title=History_of_libraries&amp;oldid=1296583094|access-date=2025-07-09|language=en}}&lt;/ref&gt;  

== Iinkomba ==
&lt;references /&gt;</text>
      <sha1>pvzmj4psic77szhxw0yanzi59o9efhu</sha1>
    </revision>
    <revision>
      <id>3358</id>
      <parentid>3356</parentid>
      <timestamp>2025-07-09T10:24:11Z</timestamp>
      <contributor>
        <username>Roxanne2019</username>
        <id>755</id>
      </contributor>
      <origin>3358</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2164" sha1="sypfencc7r7itvofl0ixm5f86kg1jew" xml:space="preserve">This is my draft space 1

Ibulungelo leencwadi kuyindawo yomphakathi lapho kubekwa khona iincwadi ngokwahlukahlukana kwazo ukuthi abantu bakghone ukuzifunda begodu bathole ilwazi ngeenhloko ezahlukahlukeneko abazithandako. Ibulungelo leencwadi lenza bona abantu bakghone ukuthola ilwazi lezinto zakade nezakhathesu. Lithuthukisa izinga lefundo yabantu ngombana bakghona ukuthola imithombo yelwazi eminengi efaka hlangana neencwadi, amajenali, ne inthaneti lapho bazokufuna khona ilwazi.&lt;ref&gt;{{Citation|last=Kral|first=Inge|title=The Learning Spaces|date=2012|work=Learning Spaces?|pages=17–42|url=https://www.jstor.org/stable/j.ctt24h9xd.8|access-date=2025-07-09|series=Youth, Literacy and New Media in Remote Indigenous Australia|publisher=ANU Press|isbn=978-1-922144-08-9|last2=Schwab|first2=Robert G. (Jerry)}}&lt;/ref&gt; 

--- 

Original page; [[Ibulungelo leencwadi|'''Ibulungelo leencwadi''']]

'''Ibulungelo leencwadi''' kuyindawo yomphakathi lapho kubekwe khona '''iiincwad'''i ngokwahlukahlukana ukuthi abantu bakghone ukuzifunda begodu bathole ilwazi ngeenhloko ezahlukahlukeneko abazithandako. Ibulungelo '''lencwadi''' lenza bona abantu bakghone ukuthola [[ilwazi]] lakade '''nelanje ngezinto zanje'''. Lithuthukisa izinga lefundo yabantu ngombana '''abantu''' bakghona ukuthola imithombo yelwazi eminengi '''efana''' neencwadi, amajenali, ne inthaneti lapho bazokufuna '''khona''' khona ilwazi.

== Umlando ==
Umlando webulungelo leencwadi wathoma ngemizamo yokuthoma yokuhlela amaphepha abalulekileko. Iinhloko ezidosa amehlo ezifaka hlangana ukurhweba kweencwadi, ukusabalaliswa kwelimi, indima emfundweni, izakhiwo, amazinga wokufunda nokutlola, ukusebenziswa kwamabulungelo weencwadi zamagugu wamasiko wesitjhaba, kanye nendima karhulumende, isondo nofana ukusejelwa kwangesese. Ukusetjenziswa kwamakhomphyutha nokudijithali kwavela ngeminyaka yabo-1960, begodu kwatjhugulula izinto ezinengi zamabulungelo weencwadi.&lt;ref&gt;{{Citation|title=History of libraries|date=2025-06-20|work=Wikipedia|url=https://en.wikipedia.org/w/index.php?title=History_of_libraries&amp;oldid=1296583094|access-date=2025-07-09|language=en}}&lt;/ref&gt;  

== Iinkomba ==
&lt;references /&gt;</text>
      <sha1>sypfencc7r7itvofl0ixm5f86kg1jew</sha1>
    </revision>
    <revision>
      <id>3359</id>
      <parentid>3358</parentid>
      <timestamp>2025-07-09T10:30:45Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <origin>3359</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2156" sha1="68dmfo9s6sqwleoblkd9bsmllnb17sz" xml:space="preserve">This is my draft space 1

Ibulungelo leencwadi kuyindawo yomphakathi lapho kubekwa khona iincwadi ngokwahlukahlukana kwazo ukuthi abantu bakghone ukuzifunda begodu bathole ilwazi ngeenhloko ezahlukahlukeneko abazithandako. Ibulungelo leencwadi lenza bona abantu bakghone ukuthola ilwazi lezinto zakade nezakhathesu. Lithuthukisa izinga lefundo yabantu ngombana bakghona ukuthola imithombo yelwazi eminengi efaka hlangana neencwadi, amajenali, ne inthaneti lapho bazokufuna khona ilwazi.&lt;ref&gt;{{Cite|last=Kral|first=Inge|title=The Learning Spaces|date=2012|work=Learning Spaces?|pages=17–42|url=https://www.jstor.org/stable/j.ctt24h9xd.8|access-date=2025-07-09|series=Youth, Literacy and New Media in Remote Indigenous Australia|publisher=ANU Press|isbn=978-1-922144-08-9|last2=Schwab|first2=Robert G. (Jerry)}}&lt;/ref&gt; 

--- 

Original page; [[Ibulungelo leencwadi|'''Ibulungelo leencwadi''']]

'''Ibulungelo leencwadi''' kuyindawo yomphakathi lapho kubekwe khona '''iiincwad'''i ngokwahlukahlukana ukuthi abantu bakghone ukuzifunda begodu bathole ilwazi ngeenhloko ezahlukahlukeneko abazithandako. Ibulungelo '''lencwadi''' lenza bona abantu bakghone ukuthola [[ilwazi]] lakade '''nelanje ngezinto zanje'''. Lithuthukisa izinga lefundo yabantu ngombana '''abantu''' bakghona ukuthola imithombo yelwazi eminengi '''efana''' neencwadi, amajenali, ne inthaneti lapho bazokufuna '''khona''' khona ilwazi.

== Umlando ==
Umlando webulungelo leencwadi wathoma ngemizamo yokuthoma yokuhlela amaphepha abalulekileko. Iinhloko ezidosa amehlo ezifaka hlangana ukurhweba kweencwadi, ukusabalaliswa kwelimi, indima emfundweni, izakhiwo, amazinga wokufunda nokutlola, ukusebenziswa kwamabulungelo weencwadi zamagugu wamasiko wesitjhaba, kanye nendima karhulumende, isondo nofana ukusejelwa kwangesese. Ukusetjenziswa kwamakhomphyutha nokudijithali kwavela ngeminyaka yabo-1960, begodu kwatjhugulula izinto ezinengi zamabulungelo weencwadi.&lt;ref&gt;{{Cite|title=History of libraries|date=2025-06-20|work=Wikipedia|url=https://en.wikipedia.org/w/index.php?title=History_of_libraries&amp;oldid=1296583094|access-date=2025-07-09|language=en}}&lt;/ref&gt;  

== Iinkomba ==
&lt;references /&gt;</text>
      <sha1>68dmfo9s6sqwleoblkd9bsmllnb17sz</sha1>
    </revision>
    <revision>
      <id>3360</id>
      <parentid>3359</parentid>
      <timestamp>2025-07-09T10:32:07Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <origin>3360</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2133" sha1="l0b91tp5lsvb8csp94w74fp34xiak48" xml:space="preserve">This is my draft space 1

Ibulungelo leencwadi kuyindawo yomphakathi lapho kubekwa khona iincwadi ngokwahlukahlukana kwazo ukuthi abantu bakghone ukuzifunda begodu bathole ilwazi ngeenhloko ezahlukahlukeneko abazithandako. Ibulungelo leencwadi lenza bona abantu bakghone ukuthola ilwazi lezinto zakade nezakhathesu. Lithuthukisa izinga lefundo yabantu ngombana bakghona ukuthola imithombo yelwazi eminengi efaka hlangana neencwadi, amajenali, ne inthaneti lapho bazokufuna khona ilwazi.&lt;ref&gt;{{Cite|last=Kral|first=Inge|title=The Learning Spaces|date=2012|work=Learning Spaces?|pages=17–42|url=https://www.jstor.org/stable/j.ctt24h9xd.8|access-date=2025-07-09|series=Youth, Literacy and New Media in Remote Indigenous Australia|publisher=ANU Press|last2=Schwab|first2=Robert G. (Jerry)}}&lt;/ref&gt; 

--- 

Original page; [[Ibulungelo leencwadi|'''Ibulungelo leencwadi''']]

'''Ibulungelo leencwadi''' kuyindawo yomphakathi lapho kubekwe khona '''iiincwad'''i ngokwahlukahlukana ukuthi abantu bakghone ukuzifunda begodu bathole ilwazi ngeenhloko ezahlukahlukeneko abazithandako. Ibulungelo '''lencwadi''' lenza bona abantu bakghone ukuthola [[ilwazi]] lakade '''nelanje ngezinto zanje'''. Lithuthukisa izinga lefundo yabantu ngombana '''abantu''' bakghona ukuthola imithombo yelwazi eminengi '''efana''' neencwadi, amajenali, ne inthaneti lapho bazokufuna '''khona''' khona ilwazi.

== Umlando ==
Umlando webulungelo leencwadi wathoma ngemizamo yokuthoma yokuhlela amaphepha abalulekileko. Iinhloko ezidosa amehlo ezifaka hlangana ukurhweba kweencwadi, ukusabalaliswa kwelimi, indima emfundweni, izakhiwo, amazinga wokufunda nokutlola, ukusebenziswa kwamabulungelo weencwadi zamagugu wamasiko wesitjhaba, kanye nendima karhulumende, isondo nofana ukusejelwa kwangesese. Ukusetjenziswa kwamakhomphyutha nokudijithali kwavela ngeminyaka yabo-1960, begodu kwatjhugulula izinto ezinengi zamabulungelo weencwadi.&lt;ref&gt;{{Cite|title=History of libraries|date=2025-06-20|work=Wikipedia|url=https://en.wikipedia.org/w/index.php?title=History_of_libraries&amp;oldid=1296583094|access-date=2025-07-09|language=en}}&lt;/ref&gt;  

== Iinkomba ==
&lt;references /&gt;</text>
      <sha1>l0b91tp5lsvb8csp94w74fp34xiak48</sha1>
    </revision>
    <revision>
      <id>3361</id>
      <parentid>3360</parentid>
      <timestamp>2025-07-09T12:13:21Z</timestamp>
      <contributor>
        <username>Roxanne2019</username>
        <id>755</id>
      </contributor>
      <comment>Edit an image</comment>
      <origin>3361</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2095" sha1="sms4bx8ofvv7jfmbs3rnrgq7hsyjn5y" xml:space="preserve">This is my draft space 1
[[Isimumathi:Library Image.jpg|thumb|Isibonelo sebulungelo leencwadi]]


Ibulungelo leencwadi kuyindawo yomphakathi lapho kubekwa khona iincwadi ngokwahlukahlukana kwazo ukuthi abantu bakghone ukuzifunda begodu bathole ilwazi ngeenhloko ezahlukahlukeneko abazithandako. Ibulungelo leencwadi lenza bona abantu bakghone ukuthola ilwazi lezinto zakade nezakhathesu. Lithuthukisa izinga lefundo yabantu ngombana bakghona ukuthola imithombo yelwazi eminengi efaka hlangana neencwadi, amajenali, ne inthaneti lapho bazokufuna khona ilwazi.&lt;ref&gt;Searing, Susan E.; Greenlee, Alison M. (2011). &quot;Faculty Responses to Library Service Innovations: A Case Study&quot;. ''Journal of Education for Library and Information Science'',https://www.jstor.org/stable/41308904&lt;/ref&gt; 

Ibulungelo leencwadi sele lithuthuke  

Original page; [[Ibulungelo leencwadi|'''Ibulungelo leencwadi''']]

'''Ibulungelo leencwadi''' kuyindawo yomphakathi lapho kubekwe khona '''iiincwad'''i ngokwahlukahlukana ukuthi abantu bakghone ukuzifunda begodu bathole ilwazi ngeenhloko ezahlukahlukeneko abazithandako. Ibulungelo '''lencwadi''' lenza bona abantu bakghone ukuthola [[ilwazi]] lakade '''nelanje ngezinto zanje'''. Lithuthukisa izinga lefundo yabantu ngombana '''abantu''' bakghona ukuthola imithombo yelwazi eminengi '''efana''' neencwadi, amajenali, ne inthaneti lapho bazokufuna '''khona''' khona ilwazi.

== Umlando ==
Umlando webulungelo leencwadi wathoma ngemizamo yokuthoma yokuhlela amaphepha abalulekileko. Iinhloko ezidosa amehlo ezifaka hlangana ukurhweba kweencwadi, ukusabalaliswa kwelimi, indima emfundweni, izakhiwo, amazinga wokufunda nokutlola, ukusebenziswa kwamabulungelo weencwadi zamagugu wamasiko wesitjhaba, kanye nendima karhulumende, isondo nofana ukusejelwa kwangesese. Ukusetjenziswa kwamakhomphyutha nokudijithali kwavela ngeminyaka yabo-1960, begodu kwatjhugulula izinto ezinengi zamabulungelo weencwadi.&lt;ref&gt;''Wikipedia'', 2025-06-20, retrieved 2025-07-09,https://en.wikipedia.org/w/index.php?title=History_of_libraries&amp;oldid=1296583094&lt;/ref&gt;  

== Iinkomba ==
&lt;references /&gt;</text>
      <sha1>sms4bx8ofvv7jfmbs3rnrgq7hsyjn5y</sha1>
    </revision>
    <revision>
      <id>3362</id>
      <parentid>3361</parentid>
      <timestamp>2025-07-09T12:34:20Z</timestamp>
      <contributor>
        <username>Roxanne2019</username>
        <id>755</id>
      </contributor>
      <origin>3362</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2375" sha1="a6y987u4roelpe3xacxr0m77frwrlgn" xml:space="preserve">This is my draft space 1
[[Isimumathi:Library Image.jpg|thumb|Isibonelo sebulungelo leencwadi]]


Ibulungelo leencwadi kuyindawo yomphakathi lapho kubekwa khona iincwadi ngokwahlukahlukana kwazo ukuthi abantu bakghone ukuzifunda begodu bathole ilwazi ngeenhloko ezahlukahlukeneko abazithandako. Ibulungelo leencwadi lenza bona abantu bakghone ukuthola ilwazi lezinto zakade nezakhathesu. Lithuthukisa izinga lefundo yabantu ngombana bakghona ukuthola imithombo yelwazi eminengi efaka hlangana neencwadi, amajenali, ne inthaneti lapho bazokufuna khona ilwazi.&lt;ref&gt;Searing, Susan E.; Greenlee, Alison M. (2011). &quot;Faculty Responses to Library Service Innovations: A Case Study&quot;. ''Journal of Education for Library and Information Science'',https://www.jstor.org/stable/41308904&lt;/ref&gt; 

Amabulungelo weencwadi ahluke khulu ngobukhulu, itlhogomelwa yihlangano yakarhulumende,   

Imitapo yolwazi ingahluka khulu ngobukhulu begodu ingahle ihlelwe begodu itlhogonyelwe mhlangano womphakathi ofana norhulumende, isikhungo (njengesikolo nofana [[Museum|imyuziyamu]] ), ikoporasi, nofana umuntu ozijameleko. Ngaphezu kokunikela ngezinto zokusebenza, imitapo yolwazi nayo inikela ngeenkonzo zabasebenzi [[Librarian|bomtapolwazi]] abaqeqetjhwe ekutholeni, ukukhetha, ukusakaza nokuhlela ilwazi lokha nabahlathulula iindingo zelwazi begodu bazulazula begodu bahlaziya ilwazi elinengi ngeensetjenziswa ezihlukahlukeneko. Indawo yokufunda yaziwa ngokuthi [[Library and information science|yisayensi yelayibhrari nelwazi]] nofana iimfundo.    

Original page; [[Ibulungelo leencwadi|'''Ibulungelo leencwadi''']]

== Umlando ==
Umlando webulungelo leencwadi wathoma ngemizamo yokuthoma yokuhlela amaphepha abalulekileko. Iinhloko ezidosa amehlo ezifaka hlangana ukurhweba kweencwadi, ukusabalaliswa kwelimi, indima emfundweni, izakhiwo, amazinga wokufunda nokutlola, ukusebenziswa kwamabulungelo weencwadi zamagugu wamasiko wesitjhaba, kanye nendima karhulumende, isondo nofana ukusejelwa kwangesese. Ukusetjenziswa kwamakhomphyutha nokudijithali kwavela ngeminyaka yabo-1960, begodu kwatjhugulula izinto ezinengi zamabulungelo weencwadi.&lt;ref&gt;''Wikipedia'', 2025-06-20, retrieved 2025-07-09,https://en.wikipedia.org/w/index.php?title=History_of_libraries&amp;oldid=1296583094&lt;/ref&gt;  

== Iinkomba ==
&lt;references /&gt;
[[Mkhakha:Ibulungelo leencwadi]]
[[Mkhakha:Iinsetjenziswa zebulungelo leencwadi]]</text>
      <sha1>a6y987u4roelpe3xacxr0m77frwrlgn</sha1>
    </revision>
    <revision>
      <id>3368</id>
      <parentid>3362</parentid>
      <timestamp>2025-07-09T12:59:53Z</timestamp>
      <contributor>
        <username>Roxanne2019</username>
        <id>755</id>
      </contributor>
      <origin>3368</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2274" sha1="9dl39hzi1loppdc9sfo6so918zynbwy" xml:space="preserve">This is my draft space 1

---
[[Isimumathi:Library Image.jpg|thumb|Isibonelo sebulungelo leencwadi]]

Original page; [[Ibulungelo leencwadi|'''Ibulungelo leencwadi''']]


Ibulungelo leencwadi kuyindawo yomphakathi lapho kubekwa khona iincwadi ngokwahlukahlukana kwazo ukuthi abantu bakghone ukuzifunda begodu bathole ilwazi ngeenhloko ezahlukahlukeneko abazithandako. Ibulungelo leencwadi lenza bona abantu bakghone ukuthola ilwazi lezinto zakade nezakhathesu. Lithuthukisa izinga lefundo yabantu ngombana bakghona ukuthola imithombo yelwazi eminengi efaka hlangana neencwadi, amajenali, ne inthaneti lapho bazokufuna khona ilwazi.&lt;ref&gt;Searing, Susan E.; Greenlee, Alison M. (2011). &quot;Faculty Responses to Library Service Innovations: A Case Study&quot;. ''Journal of Education for Library and Information Science'',https://www.jstor.org/stable/41308904&lt;/ref&gt; 

Amabulungelo weencwadi ahluke khulu ngobukhulu, itlhogomelwa yihlangano yomphakathi efana norhulumende, isikole, nofana umuntu ozijameleko. Ibulungelo leli linikela ngamahlelo wabasebenzi belungelo leencwadi ekutholeni, ukukhetha, nokuhlela ilwazi lokha nabahlathulula abakufunako ngelwazi basebenzisa iinsetjenziswa ezahlukahlukeneko. Indawo le yaziwa ngokuthi iyi iyisayensi yebulungelo leenwadi nelwazi nofana iimfundo.&lt;ref&gt;Fleming-May, Rachel A. (2011)[https://www.jstor.org/stable/10.1086/660133 ''The Library Quarterly: Information, Community, Policy''. '''81''' (3): 297–320.,https://www.jstor.org/stable/10.1086/660133]&lt;/ref&gt;   

== Umlando ==
Umlando webulungelo leencwadi wathoma ngemizamo yokuthoma yokuhlela amaphepha abalulekileko. Iinhloko ezidosa amehlo ezifaka hlangana ukurhweba kweencwadi, ukusabalaliswa kwelimi, indima emfundweni, izakhiwo, amazinga wokufunda nokutlola, ukusebenziswa kwamabulungelo weencwadi zamagugu wamasiko wesitjhaba, kanye nendima karhulumende, isondo nofana ukusejelwa kwangesese. Ukusetjenziswa kwamakhomphyutha nokudijithali kwavela ngeminyaka yabo-1960, begodu kwatjhugulula izinto ezinengi zamabulungelo weencwadi.&lt;ref&gt;''Wikipedia'', 2025-06-20, retrieved 2025-07-09,https://en.wikipedia.org/w/index.php?title=History_of_libraries&amp;oldid=1296583094&lt;/ref&gt;  

== Iinkomba ==
&lt;references /&gt;
[[Mkhakha:Ibulungelo leencwadi]]
[[Mkhakha:Iinsetjenziswa zebulungelo leencwadi]]</text>
      <sha1>9dl39hzi1loppdc9sfo6so918zynbwy</sha1>
    </revision>
    <revision>
      <id>3371</id>
      <parentid>3368</parentid>
      <timestamp>2025-07-09T13:10:10Z</timestamp>
      <contributor>
        <username>Roxanne2019</username>
        <id>755</id>
      </contributor>
      <origin>3371</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2259" sha1="rrih9905g8nn1rs586mrjllawbzqdvo" xml:space="preserve">This is my draft space 1

---
[[Isimumathi:Library Image.jpg|thumb|Isibonelo sebulungelo leencwadi]]

[[Ibulungelo leencwadi|'''Ibulungelo leencwadi''']]


Ibulungelo leencwadi kuyindawo yomphakathi lapho kubekwa khona iincwadi ngokwahlukahlukana kwazo ukuthi abantu bakghone ukuzifunda begodu bathole ilwazi ngeenhloko ezahlukahlukeneko abazithandako. Ibulungelo leencwadi lenza bona abantu bakghone ukuthola ilwazi lezinto zakade nezakhathesu. Lithuthukisa izinga lefundo yabantu ngombana bakghona ukuthola imithombo yelwazi eminengi efaka hlangana neencwadi, amajenali, ne inthaneti lapho bazokufuna khona ilwazi.&lt;ref&gt;Searing, Susan E.; Greenlee, Alison M. (2011). &quot;Faculty Responses to Library Service Innovations: A Case Study&quot;. ''Journal of Education for Library and Information Science'',https://www.jstor.org/stable/41308904&lt;/ref&gt; 

Amabulungelo weencwadi ahluke khulu ngobukhulu, itlhogomelwa yihlangano yomphakathi efana norhulumende, isikole, nofana umuntu ozijameleko. Ibulungelo leli linikela ngamahlelo wabasebenzi belungelo leencwadi ekutholeni, ukukhetha, nokuhlela ilwazi lokha nabahlathulula abakufunako ngelwazi basebenzisa iinsetjenziswa ezahlukahlukeneko. Indawo le yaziwa ngokuthi iyi iyisayensi yebulungelo leenwadi nelwazi nofana iimfundo.&lt;ref&gt;Fleming-May, Rachel A. (2011)[https://www.jstor.org/stable/10.1086/660133 ''The Library Quarterly: Information, Community, Policy''. '''81''' (3): 297–320.,https://www.jstor.org/stable/10.1086/660133]&lt;/ref&gt;   

== Umlando ==
Umlando webulungelo leencwadi wathoma ngemizamo yokuthoma yokuhlela amaphepha abalulekileko. Iinhloko ezidosa amehlo ezifaka hlangana ukurhweba kweencwadi, ukusabalaliswa kwelimi, indima emfundweni, izakhiwo, amazinga wokufunda nokutlola, ukusebenziswa kwamabulungelo weencwadi zamagugu wamasiko wesitjhaba, kanye nendima karhulumende, isondo nofana ukusejelwa kwangesese. Ukusetjenziswa kwamakhomphyutha nokudijithali kwavela ngeminyaka yabo-1960, begodu kwatjhugulula izinto ezinengi zamabulungelo weencwadi.&lt;ref&gt;''Wikipedia'', 2025-06-20, retrieved 2025-07-09,https://en.wikipedia.org/w/index.php?title=History_of_libraries&amp;oldid=1296583094&lt;/ref&gt;  

== Iinkomba ==
&lt;references /&gt;
[[Mkhakha:Ibulungelo leencwadi]]
[[Mkhakha:Iinsetjenziswa zebulungelo leencwadi]]</text>
      <sha1>rrih9905g8nn1rs586mrjllawbzqdvo</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Roxanne2019/Page 2</title>
    <ns>2</ns>
    <id>675</id>
    <revision>
      <id>3333</id>
      <timestamp>2025-07-08T12:49:14Z</timestamp>
      <contributor>
        <username>Roxanne2019</username>
        <id>755</id>
      </contributor>
      <comment>Ukutlhatlhabeja 2</comment>
      <origin>3333</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="24" sha1="k5iario3s6ketls21jrjn413pkyt6bo" xml:space="preserve">This is my draft space 2</text>
      <sha1>k5iario3s6ketls21jrjn413pkyt6bo</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Roxanne2019/Page 3</title>
    <ns>2</ns>
    <id>676</id>
    <revision>
      <id>3334</id>
      <timestamp>2025-07-08T12:50:21Z</timestamp>
      <contributor>
        <username>Roxanne2019</username>
        <id>755</id>
      </contributor>
      <comment>Ukutlhatlhabeja 3</comment>
      <origin>3334</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="21" sha1="291nghhw5svkz9rsmek7a8rzqkhimqz" xml:space="preserve">This is draft space 3</text>
      <sha1>291nghhw5svkz9rsmek7a8rzqkhimqz</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Roxanne2019/Shortcut</title>
    <ns>2</ns>
    <id>677</id>
    <revision>
      <id>3335</id>
      <timestamp>2025-07-08T12:50:53Z</timestamp>
      <contributor>
        <username>Roxanne2019</username>
        <id>755</id>
      </contributor>
      <comment>Shortcut</comment>
      <origin>3335</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="19" sha1="2q8brd9otbzgim7la77e69fe2j0ei7b" xml:space="preserve">This is my shortcut</text>
      <sha1>2q8brd9otbzgim7la77e69fe2j0ei7b</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Cite</title>
    <ns>10</ns>
    <id>679</id>
    <revision>
      <id>3346</id>
      <timestamp>2025-07-09T10:03:29Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Created page with &quot;&lt;includeonly&gt;{{#invoke:citation/CS1|citation |CitationClass=citation }}&lt;/includeonly&gt;&lt;noinclude&gt; {{Documentation}} &lt;/noinclude&gt;&quot;</comment>
      <origin>3346</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="127" sha1="c5vwsrpqyl5vzwjnrpazsisamya1wve" xml:space="preserve">&lt;includeonly&gt;{{#invoke:citation/CS1|citation
|CitationClass=citation
}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{Documentation}}
&lt;/noinclude&gt;</text>
      <sha1>c5vwsrpqyl5vzwjnrpazsisamya1wve</sha1>
    </revision>
    <revision>
      <id>3349</id>
      <parentid>3346</parentid>
      <timestamp>2025-07-09T10:06:50Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <origin>3349</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="85" sha1="7hds7xb1279e5ykpqdo113g5h4zsbv7" xml:space="preserve">&lt;includeonly&gt;{{#invoke:citation/CS1|citation
|CitationClass=citation
}}&lt;/includeonly&gt;</text>
      <sha1>7hds7xb1279e5ykpqdo113g5h4zsbv7</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Yesno</title>
    <ns>828</ns>
    <id>680</id>
    <revision>
      <id>3347</id>
      <timestamp>2025-07-09T10:04:24Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Created page with &quot;-- Function allowing for consistent treatment of boolean-like wikitext input. -- It works similarly to the template {{yesno}}.  return function (val, default) 	-- If your wiki uses non-ascii characters for any of &quot;yes&quot;, &quot;no&quot;, etc., you 	-- should replace &quot;val:lower()&quot; with &quot;mw.ustring.lower(val)&quot; in the 	-- following line. 	val = type(val) == 'string' and val:lower() or val 	if val == nil then 		return nil 	elseif val == true  		or val == 'yes' 		or val == 'y' 		or val =...&quot;</comment>
      <origin>3347</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="745" sha1="swdskn7svew8i9wuydn9uj5l3r2ghcs" xml:space="preserve">-- Function allowing for consistent treatment of boolean-like wikitext input.
-- It works similarly to the template {{yesno}}.

return function (val, default)
	-- If your wiki uses non-ascii characters for any of &quot;yes&quot;, &quot;no&quot;, etc., you
	-- should replace &quot;val:lower()&quot; with &quot;mw.ustring.lower(val)&quot; in the
	-- following line.
	val = type(val) == 'string' and val:lower() or val
	if val == nil then
		return nil
	elseif val == true 
		or val == 'yes'
		or val == 'y'
		or val == 'true'
		or val == 't'
		or val == 'on'
		or tonumber(val) == 1
	then
		return true
	elseif val == false
		or val == 'no'
		or val == 'n'
		or val == 'false'
		or val == 'f'
		or val == 'off'
		or tonumber(val) == 0
	then
		return false
	else
		return default
	end
end</text>
      <sha1>swdskn7svew8i9wuydn9uj5l3r2ghcs</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Documentation/config</title>
    <ns>828</ns>
    <id>681</id>
    <revision>
      <id>3348</id>
      <timestamp>2025-07-09T10:05:29Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Created page with &quot;---------------------------------------------------------------------------------------------------- -- --                               Configuration for Module:Documentation -- -- Here you can set the values of the parameters and messages used in Module:Documentation to -- localise it to your wiki and your language. Unless specified otherwise, values given here -- should be string values. ---------------------------------------------------------------------------------...&quot;</comment>
      <origin>3348</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="17747" sha1="a4mz1srhm8rh02cxt53a9azlcc4hx9f" xml:space="preserve">----------------------------------------------------------------------------------------------------
--
--                               Configuration for Module:Documentation
--
-- Here you can set the values of the parameters and messages used in Module:Documentation to
-- localise it to your wiki and your language. Unless specified otherwise, values given here
-- should be string values.
----------------------------------------------------------------------------------------------------

local cfg = {} -- Do not edit this line.

----------------------------------------------------------------------------------------------------
-- Protection template configuration
----------------------------------------------------------------------------------------------------

-- cfg['protection-reason-edit']
-- The protection reason for edit-protected templates to pass to
-- [[Module:Protection banner]].
cfg['protection-reason-edit'] = 'template'

--[[
----------------------------------------------------------------------------------------------------
-- Sandbox notice configuration
--
-- On sandbox pages the module can display a template notifying users that the current page is a
-- sandbox, and the location of test cases pages, etc. The module decides whether the page is a
-- sandbox or not based on the value of cfg['sandbox-subpage']. The following settings configure the
-- messages that the notices contains.
----------------------------------------------------------------------------------------------------
--]]

-- cfg['sandbox-notice-image']
-- The image displayed in the sandbox notice.
cfg['sandbox-notice-image'] = '[[File:Sandbox.svg|50px|alt=|link=]]'

--[[
-- cfg['sandbox-notice-pagetype-template']
-- cfg['sandbox-notice-pagetype-module']
-- cfg['sandbox-notice-pagetype-other']
-- The page type of the sandbox page. The message that is displayed depends on the current subject
-- namespace. This message is used in either cfg['sandbox-notice-blurb'] or
-- cfg['sandbox-notice-diff-blurb'].
--]]
cfg['sandbox-notice-pagetype-template'] = '[[Wikipedia:Template test cases|template sandbox]] page'
cfg['sandbox-notice-pagetype-module'] = '[[Wikipedia:Template test cases|module sandbox]] page'
cfg['sandbox-notice-pagetype-other'] = 'sandbox page'

--[[
-- cfg['sandbox-notice-blurb']
-- cfg['sandbox-notice-diff-blurb']
-- cfg['sandbox-notice-diff-display']
-- Either cfg['sandbox-notice-blurb'] or cfg['sandbox-notice-diff-blurb'] is the opening sentence
-- of the sandbox notice. The latter has a diff link, but the former does not. $1 is the page
-- type, which is either cfg['sandbox-notice-pagetype-template'],
-- cfg['sandbox-notice-pagetype-module'] or cfg['sandbox-notice-pagetype-other'] depending what
-- namespace we are in. $2 is a link to the main template page, and $3 is a diff link between
-- the sandbox and the main template. The display value of the diff link is set by 
-- cfg['sandbox-notice-compare-link-display'].
--]]
cfg['sandbox-notice-blurb'] = 'This is the $1 for $2.'
cfg['sandbox-notice-diff-blurb'] = 'This is the $1 for $2 ($3).'
cfg['sandbox-notice-compare-link-display'] = 'diff'

--[[
-- cfg['sandbox-notice-testcases-blurb']
-- cfg['sandbox-notice-testcases-link-display']
-- cfg['sandbox-notice-testcases-run-blurb']
-- cfg['sandbox-notice-testcases-run-link-display']
-- cfg['sandbox-notice-testcases-blurb'] is a sentence notifying the user that there is a test cases page
-- corresponding to this sandbox that they can edit. $1 is a link to the test cases page.
-- cfg['sandbox-notice-testcases-link-display'] is the display value for that link.
-- cfg['sandbox-notice-testcases-run-blurb'] is a sentence notifying the user that there is a test cases page
-- corresponding to this sandbox that they can edit, along with a link to run it. $1 is a link to the test
-- cases page, and $2 is a link to the page to run it.
-- cfg['sandbox-notice-testcases-run-link-display'] is the display value for the link to run the test
-- cases.
--]]
cfg['sandbox-notice-testcases-blurb'] = 'See also the companion subpage for $1.'
cfg['sandbox-notice-testcases-link-display'] = 'test cases'
cfg['sandbox-notice-testcases-run-blurb'] = 'See also the companion subpage for $1 ($2).'
cfg['sandbox-notice-testcases-run-link-display'] = 'run'

-- cfg['sandbox-category'] - A category to add to all template sandboxes.
-- cfg['module-sandbox-category'] - A category to add to all module sandboxes.
-- cfg['module-sandbox-category'] - A category to add to all sandboxe not in templates or modules.
cfg['sandbox-category'] = 'Template sandboxes'
cfg['module-sandbox-category'] = 'Module sandboxes'
cfg['other-sandbox-category'] = 'Sandboxes outside of template or module namespace'


----------------------------------------------------------------------------------------------------
-- Start box configuration
----------------------------------------------------------------------------------------------------

-- cfg['documentation-icon-wikitext']
-- The wikitext for the icon shown at the top of the template.
cfg['documentation-icon-wikitext'] = '[[File:Test Template Info-Icon - Version (2).svg|50px|link=|alt=]]'

-- cfg['template-namespace-heading']
-- The heading shown in the template namespace.
cfg['template-namespace-heading'] = 'Template documentation'

-- cfg['module-namespace-heading']
-- The heading shown in the module namespace.
cfg['module-namespace-heading'] = 'Module documentation'

-- cfg['file-namespace-heading']
-- The heading shown in the file namespace.
cfg['file-namespace-heading'] = 'Summary'

-- cfg['other-namespaces-heading']
-- The heading shown in other namespaces.
cfg['other-namespaces-heading'] = 'Documentation'

-- cfg['view-link-display']
-- The text to display for &quot;view&quot; links.
cfg['view-link-display'] = 'view'

-- cfg['edit-link-display']
-- The text to display for &quot;edit&quot; links.
cfg['edit-link-display'] = 'edit'

-- cfg['history-link-display']
-- The text to display for &quot;history&quot; links.
cfg['history-link-display'] = 'history'

-- cfg['purge-link-display']
-- The text to display for &quot;purge&quot; links.
cfg['purge-link-display'] = 'purge'

-- cfg['create-link-display']
-- The text to display for &quot;create&quot; links.
cfg['create-link-display'] = 'create'

----------------------------------------------------------------------------------------------------
-- Link box (end box) configuration
----------------------------------------------------------------------------------------------------

-- cfg['transcluded-from-blurb']
-- Notice displayed when the docs are transcluded from another page. $1 is a wikilink to that page.
cfg['transcluded-from-blurb'] = 'The above [[Wikipedia:Template documentation|documentation]] is [[Help:Transclusion|transcluded]] from $1.'

--[[
-- cfg['create-module-doc-blurb']
-- Notice displayed in the module namespace when the documentation subpage does not exist.
-- $1 is a link to create the documentation page with the preload cfg['module-preload'] and the
-- display cfg['create-link-display'].
--]]
cfg['create-module-doc-blurb'] = 'You might want to $1 a documentation page for this [[Wikipedia:Lua|Scribunto module]].'

----------------------------------------------------------------------------------------------------
-- Experiment blurb configuration
----------------------------------------------------------------------------------------------------

--[[
-- cfg['experiment-blurb-template']
-- cfg['experiment-blurb-module']
-- The experiment blurb is the text inviting editors to experiment in sandbox and test cases pages.
-- It is only shown in the template and module namespaces. With the default English settings, it
-- might look like this:
--
-- Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages.
--
-- In this example, &quot;sandbox&quot;, &quot;edit&quot;, &quot;diff&quot;, &quot;testcases&quot;, and &quot;edit&quot; would all be links.
--
-- There are two versions, cfg['experiment-blurb-template'] and cfg['experiment-blurb-module'], depending
-- on what namespace we are in.
-- 
-- Parameters:
--
-- $1 is a link to the sandbox page. If the sandbox exists, it is in the following format:
--
--     cfg['sandbox-link-display'] (cfg['sandbox-edit-link-display'] | cfg['compare-link-display'])
-- 
-- If the sandbox doesn't exist, it is in the format:
--
--     cfg['sandbox-link-display'] (cfg['sandbox-create-link-display'] | cfg['mirror-link-display'])
-- 
-- The link for cfg['sandbox-create-link-display'] link preloads the page with cfg['template-sandbox-preload']
-- or cfg['module-sandbox-preload'], depending on the current namespace. The link for cfg['mirror-link-display']
-- loads a default edit summary of cfg['mirror-edit-summary'].
--
-- $2 is a link to the test cases page. If the test cases page exists, it is in the following format:
--
--     cfg['testcases-link-display'] (cfg['testcases-edit-link-display'] | cfg['testcases-run-link-display'])
--
-- If the test cases page doesn't exist, it is in the format:
-- 
--     cfg['testcases-link-display'] (cfg['testcases-create-link-display'])
--
-- If the test cases page doesn't exist, the link for cfg['testcases-create-link-display'] preloads the
-- page with cfg['template-testcases-preload'] or cfg['module-testcases-preload'], depending on the current
-- namespace.
--]]
cfg['experiment-blurb-template'] = &quot;Editors can experiment in this template's $1 and $2 pages.&quot;
cfg['experiment-blurb-module'] = &quot;Editors can experiment in this module's $1 and $2 pages.&quot;

----------------------------------------------------------------------------------------------------
-- Sandbox link configuration
----------------------------------------------------------------------------------------------------

-- cfg['sandbox-subpage']
-- The name of the template subpage typically used for sandboxes.
cfg['sandbox-subpage'] = 'sandbox'

-- cfg['template-sandbox-preload']
-- Preload file for template sandbox pages.
cfg['template-sandbox-preload'] = 'Template:Documentation/preload-sandbox'

-- cfg['module-sandbox-preload']
-- Preload file for Lua module sandbox pages.
cfg['module-sandbox-preload'] = 'Template:Documentation/preload-module-sandbox'

-- cfg['sandbox-link-display']
-- The text to display for &quot;sandbox&quot; links.
cfg['sandbox-link-display'] = 'sandbox'

-- cfg['sandbox-edit-link-display']
-- The text to display for sandbox &quot;edit&quot; links.
cfg['sandbox-edit-link-display'] = 'edit'

-- cfg['sandbox-create-link-display']
-- The text to display for sandbox &quot;create&quot; links.
cfg['sandbox-create-link-display'] = 'create'

-- cfg['compare-link-display']
-- The text to display for &quot;compare&quot; links.
cfg['compare-link-display'] = 'diff'

-- cfg['mirror-edit-summary']
-- The default edit summary to use when a user clicks the &quot;mirror&quot; link. $1 is a wikilink to the
-- template page.
cfg['mirror-edit-summary'] = 'Create sandbox version of $1'

-- cfg['mirror-link-display']
-- The text to display for &quot;mirror&quot; links.
cfg['mirror-link-display'] = 'mirror'

-- cfg['mirror-link-preload']
-- The page to preload when a user clicks the &quot;mirror&quot; link.
cfg['mirror-link-preload'] = 'Template:Documentation/mirror'

----------------------------------------------------------------------------------------------------
-- Test cases link configuration
----------------------------------------------------------------------------------------------------

-- cfg['testcases-subpage']
-- The name of the template subpage typically used for test cases.
cfg['testcases-subpage'] = 'testcases'

-- cfg['template-testcases-preload']
-- Preload file for template test cases pages.
cfg['template-testcases-preload'] = 'Template:Documentation/preload-testcases'

-- cfg['module-testcases-preload']
-- Preload file for Lua module test cases pages.
cfg['module-testcases-preload'] = 'Template:Documentation/preload-module-testcases'

-- cfg['testcases-link-display']
-- The text to display for &quot;testcases&quot; links.
cfg['testcases-link-display'] = 'testcases'

-- cfg['testcases-edit-link-display']
-- The text to display for test cases &quot;edit&quot; links.
cfg['testcases-edit-link-display'] = 'edit'

-- cfg['testcases-run-link-display']
-- The text to display for test cases &quot;run&quot; links.
cfg['testcases-run-link-display'] = 'run'

-- cfg['testcases-create-link-display']
-- The text to display for test cases &quot;create&quot; links.
cfg['testcases-create-link-display'] = 'create'

----------------------------------------------------------------------------------------------------
-- Add categories blurb configuration
----------------------------------------------------------------------------------------------------

--[[
-- cfg['add-categories-blurb']
-- Text to direct users to add categories to the /doc subpage. Not used if the &quot;content&quot; or
-- &quot;docname fed&quot; arguments are set, as then it is not clear where to add the categories. $1 is a
-- link to the /doc subpage with a display value of cfg['doc-link-display'].
--]]
cfg['add-categories-blurb'] = 'Add categories to the $1 subpage.'

-- cfg['doc-link-display']
-- The text to display when linking to the /doc subpage.
cfg['doc-link-display'] = '/doc'

----------------------------------------------------------------------------------------------------
-- Subpages link configuration
----------------------------------------------------------------------------------------------------

--[[
-- cfg['subpages-blurb']
-- The &quot;Subpages of this template&quot; blurb. $1 is a link to the main template's subpages with a
-- display value of cfg['subpages-link-display']. In the English version this blurb is simply
-- the link followed by a period, and the link display provides the actual text.
--]]
cfg['subpages-blurb'] = '$1.'

--[[
-- cfg['subpages-link-display']
-- The text to display for the &quot;subpages of this page&quot; link. $1 is cfg['template-pagetype'],
-- cfg['module-pagetype'] or cfg['default-pagetype'], depending on whether the current page is in
-- the template namespace, the module namespace, or another namespace.
--]]
cfg['subpages-link-display'] = 'Subpages of this $1'

-- cfg['template-pagetype']
-- The pagetype to display for template pages.
cfg['template-pagetype'] = 'template'

-- cfg['module-pagetype']
-- The pagetype to display for Lua module pages.
cfg['module-pagetype'] = 'module'

-- cfg['default-pagetype']
-- The pagetype to display for pages other than templates or Lua modules.
cfg['default-pagetype'] = 'page'

----------------------------------------------------------------------------------------------------
-- Doc link configuration
----------------------------------------------------------------------------------------------------

-- cfg['doc-subpage']
-- The name of the subpage typically used for documentation pages.
cfg['doc-subpage'] = 'doc'

-- cfg['docpage-preload']
-- Preload file for template documentation pages in all namespaces.
cfg['docpage-preload'] = 'Template:Documentation/preload'

-- cfg['module-preload']
-- Preload file for Lua module documentation pages.
cfg['module-preload'] = 'Template:Documentation/preload-module-doc'

----------------------------------------------------------------------------------------------------
-- HTML and CSS configuration
----------------------------------------------------------------------------------------------------

-- cfg['templatestyles']
-- The name of the TemplateStyles page where CSS is kept.
-- Sandbox CSS will be at Module:Documentation/sandbox/styles.css when needed.
cfg['templatestyles'] = 'Module:Documentation/styles.css'

-- cfg['container']
-- Class which can be used to set flex or grid CSS on the
-- two child divs documentation and documentation-metadata
cfg['container'] = 'documentation-container'

-- cfg['main-div-classes']
-- Classes added to the main HTML &quot;div&quot; tag.
cfg['main-div-classes'] = 'documentation'

-- cfg['main-div-heading-class']
-- Class for the main heading for templates and modules and assoc. talk spaces
cfg['main-div-heading-class'] = 'documentation-heading'

-- cfg['start-box-class']
-- Class for the start box
cfg['start-box-class'] = 'documentation-startbox'

-- cfg['start-box-link-classes']
-- Classes used for the [view][edit][history] or [create] links in the start box.
-- mw-editsection-like is per [[Wikipedia:Village pump (technical)/Archive 117]]
cfg['start-box-link-classes'] = 'mw-editsection-like plainlinks'

-- cfg['end-box-class']
-- Class for the end box.
cfg['end-box-class'] = 'documentation-metadata'

-- cfg['end-box-plainlinks']
-- Plainlinks
cfg['end-box-plainlinks'] = 'plainlinks'

-- cfg['toolbar-class']
-- Class added for toolbar links.
cfg['toolbar-class'] = 'documentation-toolbar'

-- cfg['clear']
-- Just used to clear things.
cfg['clear'] = 'documentation-clear'


----------------------------------------------------------------------------------------------------
-- Tracking category configuration
----------------------------------------------------------------------------------------------------

-- cfg['display-strange-usage-category']
-- Set to true to enable output of cfg['strange-usage-category'] if the module is used on a /doc subpage
-- or a /testcases subpage. This should be a boolean value (either true or false).
cfg['display-strange-usage-category'] = true

-- cfg['strange-usage-category']
-- Category to output if cfg['display-strange-usage-category'] is set to true and the module is used on a
-- /doc subpage or a /testcases subpage.
cfg['strange-usage-category'] = 'Wikipedia pages with strange ((documentation)) usage'

--[[
----------------------------------------------------------------------------------------------------
-- End configuration
--
-- Don't edit anything below this line.
----------------------------------------------------------------------------------------------------
--]]

return cfg</text>
      <sha1>a4mz1srhm8rh02cxt53a9azlcc4hx9f</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Citation/CS1/Configuration</title>
    <ns>828</ns>
    <id>682</id>
    <revision>
      <id>3350</id>
      <timestamp>2025-07-09T10:09:27Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Created page with &quot;local lang_obj = mw.language.getContentLanguage();								-- make a language object for the local language; used here for languages and dates    --[[--------------------------&lt; S E T T I N G S &gt;--------------------------------------------------------------  boolean settings used to control various things.  these setting located here to make them easy to find  ]] 																				-- these settings local to this module only local local_digits_from_mediawiki = false;...&quot;</comment>
      <origin>3350</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="116258" sha1="1qtnsk18jlmk0vxedax9rhtzltma8m9" xml:space="preserve">local lang_obj = mw.language.getContentLanguage();								-- make a language object for the local language; used here for languages and dates 


--[[--------------------------&lt; S E T T I N G S &gt;--------------------------------------------------------------

boolean settings used to control various things.  these setting located here to make them easy to find

]]
																				-- these settings local to this module only
local local_digits_from_mediawiki = false;										-- for i18n; when true, module fills date_names['local_digits'] from MediaWiki; manual fill required else; always false at en.wiki
local local_date_names_from_mediawiki = false;									-- for i18n; when true, module fills date_names['local']['long'] and date_names['local']['short'] from MediaWiki;
																				-- manual translation required else; ; always false at en.wiki

																				-- these settings exported to other modules
local use_identifier_redirects = true;											-- when true use redirect name for identifier label links; always true at en.wiki
local local_lang_cat_enable = false;											-- when true categorizes pages where |language=&lt;local wiki's language&gt;; always false at en.wiki
local date_name_auto_xlate_enable = false;										-- when true translates English month-names to the local-wiki's language month names; always false at en.wiki
local date_digit_auto_xlate_enable = false;										-- when true translates Western date digit to the local-wiki's language digits (date_names['local_digits']); always false at en.wiki
local enable_sort_keys = true;													-- when true module adds namespace sort keys to error and maintenance category links


--[[--------------------------&lt; U N C A T E G O R I Z E D _ N A M E S P A C E S &gt;------------------------------

List of namespaces identifiers for namespaces that will not be included in citation error categories.
Same as setting notracking = true by default.

For wikis that have a current version of Module:cs1 documentation support, this #invoke will return an unordered
list of namespace names and their associated identifiers:
	{{#invoke:cs1 documentation support|uncategorized_namespace_lister|all=&lt;anything&gt;}}

]]

local uncategorized_namespaces_t = {[2]=true};										-- init with user namespace id
for k, _ in pairs (mw.site.talkNamespaces) do									-- add all talk namespace ids
	uncategorized_namespaces_t[k] = true;
end

local uncategorized_subpages = {'/[Ss]andbox', '/[Tt]estcases', '/[^/]*[Ll]og', '/[Aa]rchive'};		-- list of Lua patterns found in page names of pages we should not categorize

--[[
at en.wiki Greek characters are used as sort keys for certain items in a category so that those items are
placed at the end of a category page.  See Wikipedia:Categorization#Sort_keys.  That works well for en.wiki
because English is written using the Latn script.  This may not work well for other languages.  At en.wiki it
is desireable to place content from certain namespaces at the end of a category listing so the module adds sort
keys to error and maintenance category links when rendering a cs1|2 template on a page in that namespace.

i18n: if this does not work well for your language, set &lt;enable_sort_keys&gt; to false.
]]

local name_space_sort_keys = {													-- sort keys to be used with these namespaces:
	[4] = 'ω',																	-- wikipedia; omega
	[10] = 'τ',																	-- template; tau
	[118] = 'Δ', 																-- draft; delta
	['other'] = 'ο',															-- all other non-talk namespaces except main (article); omicron
	}

--[[--------------------------&lt; M E S S A G E S &gt;--------------------------------------------------------------

Translation table

The following contains fixed text that may be output as part of a citation.
This is separated from the main body to aid in future translations of this
module.

]]

local messages = {
	['agency'] = '$1 $2',														-- $1 is sepc, $2 is agency
	['archived-dead'] = 'Archived from $1 on $2',
	['archived-live'] = '$1 from the original on $2',
	['archived-unfit'] = 'Archived from the original on ',
	['archived'] = 'Archived',
	['by'] = 'By',																-- contributions to authored works: introduction, foreword, afterword
	['cartography'] = 'Cartography by $1',
	['editor'] = 'ed.',
	['editors'] = 'eds.',
	['edition'] = '($1&amp;nbsp;ed.)',
	['episode'] = 'Episode $1',
	['et al'] = 'et&amp;nbsp;al.',
	['in'] = 'In',																-- edited works
	['inactive'] = 'inactive',
	['inset'] = '$1 inset',
	['interview'] = 'Interviewed by $1',										
	['mismatch'] = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt; / &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$2=&lt;/code&gt; mismatch',	-- $1 is year param name; $2 is date param name
	['newsgroup'] = '[[Usenet newsgroup|Newsgroup]]:&amp;nbsp;$1',
	['notitle'] = 'No title',													-- for |title=(()) and (in the future) |title=none
	['original'] = 'the original',
	['origdate'] = ' [$1]',
	['published'] = ' (published $1)',
	['retrieved'] = 'Retrieved $1',
	['season'] = 'Season $1',
	['section'] = '§&amp;nbsp;$1',
	['sections'] = '§§&amp;nbsp;$1',
	['series'] = '$1 $2',														-- $1 is sepc, $2 is series
	['seriesnum'] = 'Series $1',
	['translated'] = 'Translated by $1',
	['type'] = ' ($1)',															-- for titletype
	['written'] = 'Written at $1',

	['vol'] = '$1 Vol.&amp;nbsp;$2',												-- $1 is sepc; bold journal style volume is in presentation{}
	['vol-no'] = '$1 Vol.&amp;nbsp;$2, no.&amp;nbsp;$3',								-- sepc, volume, issue (alternatively insert $1 after $2, but then we'd also have to change capitalization)
	['issue'] = '$1 No.&amp;nbsp;$2',												-- $1 is sepc

	['art'] = '$1 Art.&amp;nbsp;$2',												-- $1 is sepc; for {{cite conference}} only
	['vol-art'] = '$1 Vol.&amp;nbsp;$2, art.&amp;nbsp;$3',								-- sepc, volume, article-number; for {{cite conference}} only

	['j-vol'] = '$1 $2',														-- sepc, volume; bold journal volume is in presentation{}
	['j-issue'] = ' ($1)',
	['j-article-num'] = ' $1',													-- TODO: any punctuation here? static text?

	['nopp'] = '$1 $2';															-- page(s) without prefix; $1 is sepc

	['p-prefix'] = &quot;$1 p.&amp;nbsp;$2&quot;,												-- $1 is sepc
	['pp-prefix'] = &quot;$1 pp.&amp;nbsp;$2&quot;,											-- $1 is sepc
	['j-page(s)'] = ': $1',														-- same for page and pages

	['sheet'] = '$1 Sheet&amp;nbsp;$2',												-- $1 is sepc
	['sheets'] = '$1 Sheets&amp;nbsp;$2',											-- $1 is sepc
	['j-sheet'] = ': Sheet&amp;nbsp;$1',
	['j-sheets'] = ': Sheets&amp;nbsp;$1',
	
	['language'] = '(in $1)',
	['via'] = &quot; &amp;ndash; via $1&quot;,
	['event'] = 'Event occurs at',
	['minutes'] = 'minutes in',
	
	-- Determines the location of the help page
	['help page link'] = 'Help:CS1 errors',
	['help page label'] = 'help',
	
	-- categories
	['cat wikilink'] = '[[Category:$1]]',										-- $1 is the category name
	['cat wikilink sk'] = '[[Category:$1|$2]]',									-- $1 is the category name; $2 is namespace sort key
	[':cat wikilink'] = '[[:Category:$1|link]]',								-- category name as maintenance message wikilink; $1 is the category name

	-- Internal errors (should only occur if configuration is bad)
	['undefined_error'] = 'Called with an undefined error condition',
	['unknown_ID_key'] = 'Unrecognized ID key: ',								-- an ID key in id_handlers not found in ~/Identifiers func_map{}
	['unknown_ID_access'] = 'Unrecognized ID access keyword: ',					-- an ID access keyword in id_handlers not found in keywords_lists['id-access']{}
	['unknown_argument_map'] = 'Argument map not defined for this variable',
	['bare_url_no_origin'] = 'Bare URL found but origin indicator is nil or empty',
	
	['warning_msg_e'] = '&lt;span style=&quot;color:#d33&quot;&gt;One or more &lt;code style=&quot;color: inherit; background: inherit; border: none; padding: inherit;&quot;&gt;&amp;#123;{$1}}&lt;/code&gt; templates have errors&lt;/span&gt;; messages may be hidden ([[Help:CS1_errors#Controlling_error_message_display|help]]).';	-- $1 is template link
	['warning_msg_m'] = '&lt;span style=&quot;color:#3a3&quot;&gt;One or more &lt;code style=&quot;color: inherit; background: inherit; border: none; padding: inherit;&quot;&gt;&amp;#123;{$1}}&lt;/code&gt; templates have maintenance messages&lt;/span&gt;; messages may be hidden ([[Help:CS1_errors#Controlling_error_message_display|help]]).';	-- $1 is template link
	}


--[[--------------------------&lt; C I T A T I O N _ C L A S S _ M A P &gt;------------------------------------------

this table maps the value assigned to |CitationClass= in the cs1|2 templates to the canonical template name when
the value assigned to |CitationClass= is different from the canonical template name.  |CitationClass= values are
used as class attributes in the &lt;cite&gt; tag that encloses the citation so these names may not contain spaces while
the canonical template name may.  These names are used in warning_msg_e and warning_msg_m to create links to the
template's documentation when an article is displayed in preview mode.

Most cs1|2 template |CitationClass= values at en.wiki match their canonical template names so are not listed here.

]]

	local citation_class_map_t = {												-- TODO: if kept, these and all other config.CitationClass 'names' require some sort of i18n
		['arxiv'] = 'arXiv',
		['audio-visual'] = 'AV media',
		['AV-media-notes'] = 'AV media notes',
		['biorxiv'] = 'bioRxiv',
		['citeseerx'] = 'CiteSeerX',
		['encyclopaedia'] = 'encyclopedia',
		['mailinglist'] = 'mailing list',
		['medrxiv'] = 'medRxiv',
		['pressrelease'] = 'press release',
		['ssrn'] = 'SSRN',
		['techreport'] = 'tech report',
		}


--[=[-------------------------&lt; E T _ A L _ P A T T E R N S &gt;--------------------------------------------------

This table provides Lua patterns for the phrase &quot;et al&quot; and variants in name text
(author, editor, etc.). The main module uses these to identify and emit the 'etal' message.

]=]

local et_al_patterns = {
	&quot;[;,]? *[\&quot;']*%f[%a][Ee][Tt]%.? *[Aa][Ll][%.;,\&quot;']*$&quot;,						-- variations on the 'et al' theme
	&quot;[;,]? *[\&quot;']*%f[%a][Ee][Tt]%.? *[Aa][Ll][Ii][AaIi][Ee]?[%.;,\&quot;']*$&quot;,		-- variations on the 'et alia', 'et alii' and 'et aliae' themes (false positive 'et aliie' unlikely to match)
	&quot;[;,]? *%f[%a]and [Oo]thers&quot;,												-- an alternative to et al.
	&quot;%[%[ *[Ee][Tt]%.? *[Aa][Ll]%.? *%]%]&quot;,										-- a wikilinked form
	&quot;%(%( *[Ee][Tt]%.? *[Aa][Ll]%.? *%)%)&quot;,										-- a double-bracketed form (to counter partial removal of ((...)) syntax)
	&quot;[%(%[] *[Ee][Tt]%.? *[Aa][Ll]%.? *[%)%]]&quot;,									-- a bracketed form
	}


--[[--------------------------&lt; P R E S E N T A T I O N &gt;------------------------

Fixed presentation markup.  Originally part of citation_config.messages it has
been moved into its own, more semantically correct place.

]]

local presentation = 
	{
	-- .citation-comment class is specified at Help:CS1_errors#Controlling_error_message_display
	['hidden-error'] = '&lt;span class=&quot;cs1-hidden-error citation-comment&quot;&gt;$1&lt;/span&gt;',
	['visible-error'] = '&lt;span class=&quot;cs1-visible-error citation-comment&quot;&gt;$1&lt;/span&gt;',
	['hidden-maint'] = '&lt;span class=&quot;cs1-maint citation-comment&quot;&gt;$1&lt;/span&gt;',
	
	['accessdate'] = '&lt;span class=&quot;reference-accessdate&quot;&gt;$1$2&lt;/span&gt;',			-- to allow editors to hide accessdate using personal CSS

	['bdi'] = '&lt;bdi$1&gt;$2&lt;/bdi&gt;',												-- bidirectional isolation used with |script-title= and the like

	['cite'] = '&lt;cite class=&quot;$1&quot;&gt;$2&lt;/cite&gt;';									-- for use when citation does not have a namelist and |ref= not set so no id=&quot;...&quot; attribute
	['cite-id'] = '&lt;cite id=&quot;$1&quot; class=&quot;$2&quot;&gt;$3&lt;/cite&gt;';							-- for use when when |ref= is set or when citation has a namelist

	['format'] = ' &lt;span class=&quot;cs1-format&quot;&gt;($1)&lt;/span&gt;',						-- for |format=, |chapter-format=, etc.
	['interwiki'] = ' &lt;span class=&quot;cs1-format&quot;&gt;[in $1]&lt;/span&gt;',					-- for interwiki-language-linked author, editor, etc
	['interproj'] = ' &lt;span class=&quot;cs1-format&quot;&gt;[at $1]&lt;/span&gt;',					-- for interwiki-project-linked author, editor, etc (:d: and :s: supported; :w: ignored)

	-- various access levels, for |access=, |doi-access=, |arxiv=, ...
	-- narrow no-break space &amp;#8239; may work better than nowrap CSS. Or not? Browser support?

	['ext-link-access-signal'] = '&lt;span class=&quot;$1&quot; title=&quot;$2&quot;&gt;$3&lt;/span&gt;',		-- external link with appropriate lock icon
		['free'] = {class='id-lock-free', title='Freely accessible'},			-- classes defined in Module:Citation/CS1/styles.css
		['registration'] = {class='id-lock-registration', title='Free registration required'},
		['limited'] = {class='id-lock-limited', title='Free access subject to limited trial, subscription normally required'},
		['subscription'] = {class='id-lock-subscription', title='Paid subscription required'},

	['interwiki-icon'] = '&lt;span class=&quot;$1&quot; title=&quot;$2&quot;&gt;$3&lt;/span&gt;',
		['class-wikisource'] = 'cs1-ws-icon',

	['italic-title'] = &quot;''$1''&quot;,

	['kern-left'] = '&lt;span class=&quot;cs1-kern-left&quot;&gt;&lt;/span&gt;$1',					-- spacing to use when title contains leading single or double quote mark
	['kern-right'] = '$1&lt;span class=&quot;cs1-kern-right&quot;&gt;&lt;/span&gt;',					-- spacing to use when title contains trailing single or double quote mark

	['nowrap1'] = '&lt;span class=&quot;nowrap&quot;&gt;$1&lt;/span&gt;',								-- for nowrapping an item: &lt;span ...&gt;yyyy-mm-dd&lt;/span&gt;
	['nowrap2'] = '&lt;span class=&quot;nowrap&quot;&gt;$1&lt;/span&gt; $2',							-- for nowrapping portions of an item: &lt;span ...&gt;dd mmmm&lt;/span&gt; yyyy (note white space)

	['ocins'] = '&lt;span title=&quot;$1&quot; class=&quot;Z3988&quot;&gt;&lt;/span&gt;',
	
	['parameter'] = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt;',
	
	['ps_cs1'] = '.';															-- CS1 style postscript (terminal) character
	['ps_cs2'] = '';															-- CS2 style postscript (terminal) character (empty string)

	['quoted-text'] = '&lt;q&gt;$1&lt;/q&gt;',												-- for wrapping |quote= content
	['quoted-title'] = '&quot;$1&quot;',

	['sep_cs1'] = '.',															-- CS1 element separator
	['sep_cs2'] = ',',															-- CS2 separator
	['sep_nl'] = ';',															-- CS1|2 style name-list separator between names is a semicolon
	['sep_nl_and'] = ' and ',													-- used as last nl sep when |name-list-style=and and list has 2 items
	['sep_nl_end'] = '; and ',													-- used as last nl sep when |name-list-style=and and list has 3+ names
	['sep_name'] = ', ',														-- CS1|2 style last/first separator is &lt;comma&gt;&lt;space&gt;
	['sep_nl_vanc'] = ',',														-- Vancouver style name-list separator between authors is a comma
	['sep_name_vanc'] = ' ',													-- Vancouver style last/first separator is a space

	['sep_list'] = ', ',														-- used for |language= when list has 3+ items except for last sep which uses sep_list_end
	['sep_list_pair'] = ' and ',												-- used for |language= when list has 2 items
	['sep_list_end'] = ', and ',												-- used as last list sep for |language= when list has 3+ items
	
	['trans-italic-title'] = &quot;&amp;#91;''$1''&amp;#93;&quot;,
	['trans-quoted-title'] = &quot;&amp;#91;$1&amp;#93;&quot;,									-- for |trans-title= and |trans-quote=
	['vol-bold'] = '$1 &lt;b&gt;$2&lt;/b&gt;',												-- sepc, volume; for bold journal cites; for other cites ['vol'] in messages{}
	}

	
--[[--------------------------&lt; A L I A S E S &gt;---------------------------------

Aliases table for commonly passed parameters.

Parameter names on the right side in the assignments in this table must have been
defined in the Whitelist before they will be recognized as valid parameter names

]]

local aliases = {
	['AccessDate'] = {'access-date', 'accessdate'},								-- Used by InternetArchiveBot
	['Agency'] = 'agency',
	['ArchiveDate'] = {'archive-date', 'archivedate'},							-- Used by InternetArchiveBot
	['ArchiveFormat'] = 'archive-format',
	['ArchiveURL'] = {'archive-url', 'archiveurl'},								-- Used by InternetArchiveBot
	['ArticleNumber'] = 'article-number',
	['ASINTLD'] = 'asin-tld',
	['At'] = 'at',																-- Used by InternetArchiveBot
	['Authors'] = {'people', 'credits'},
	['BookTitle'] = {'book-title', 'booktitle'},
	['Cartography'] = 'cartography',
	['Chapter'] = {'chapter', 'contribution', 'entry', 'article', 'section'},
	['ChapterFormat'] = {'chapter-format', 'contribution-format', 'entry-format',
		'article-format', 'section-format'};
	['ChapterURL'] = {'chapter-url', 'contribution-url', 'entry-url', 'article-url', 'section-url'},	-- Used by InternetArchiveBot
	['ChapterUrlAccess'] = {'chapter-url-access', 'contribution-url-access',
		'entry-url-access', 'article-url-access', 'section-url-access'},		-- Used by InternetArchiveBot
	['Class'] = 'class',														-- cite arxiv and arxiv identifier
	['Collaboration'] = 'collaboration',
	['Conference'] = {'conference', 'event'},
	['ConferenceFormat'] = 'conference-format',
	['ConferenceURL'] = 'conference-url',										-- Used by InternetArchiveBot
	['Date'] = {'date', 'air-date', 'airdate'},									-- air-date and airdate for cite episode and cite serial only
	['Degree'] = 'degree',
	['DF'] = 'df',
	['DisplayAuthors'] = {'display-authors', 'display-subjects'},
	['DisplayContributors'] = 'display-contributors',
	['DisplayEditors'] = 'display-editors',
	['DisplayInterviewers'] = 'display-interviewers',
	['DisplayTranslators'] = 'display-translators',
	['Docket'] = 'docket',
	['DoiBroken'] = 'doi-broken-date',
	['Edition'] = 'edition',
	['Embargo'] = 'pmc-embargo-date',
	['Encyclopedia'] = {'encyclopedia', 'encyclopaedia', 'dictionary'},			-- cite encyclopedia only
	['Episode'] = 'episode',													-- cite serial only TODO: make available to cite episode?
	['Format'] = 'format',
	['ID'] = {'id', 'ID'},
	['Inset'] = 'inset',
	['Issue'] = {'issue', 'number'},
	['Language'] = {'language', 'lang'},
	['MailingList'] = {'mailing-list', 'mailinglist'},							-- cite mailing list only
	['Map'] = 'map',															-- cite map only
	['MapFormat'] = 'map-format',												-- cite map only
	['MapURL'] = {'map-url', 'mapurl'},											-- cite map only -- Used by InternetArchiveBot
	['MapUrlAccess'] = 'map-url-access',										-- cite map only -- Used by InternetArchiveBot
	['Minutes'] = 'minutes',
	['Mode'] = 'mode',
	['NameListStyle'] = 'name-list-style',
	['Network'] = 'network',
	['Newsgroup'] = 'newsgroup',												-- cite newsgroup only
	['NoPP'] = {'no-pp', 'nopp'},
	['NoTracking'] = {'no-tracking', 'template-doc-demo'},
	['Number'] = 'number',														-- this case only for cite techreport
	['OrigDate'] = {'orig-date', 'orig-year', 'origyear'},
	['Others'] = 'others',
	['Page'] = {'page', 'p'},													-- Used by InternetArchiveBot
	['Pages'] = {'pages', 'pp'},												-- Used by InternetArchiveBot
	['Periodical'] = {'journal', 'magazine', 'newspaper', 'periodical', 'website', 'work'},
	['Place'] = {'place', 'location'},
	['PostScript'] = 'postscript',
	['PublicationDate'] = {'publication-date', 'publicationdate'},
	['PublicationPlace'] = {'publication-place', 'publicationplace'},
	['PublisherName'] = {'publisher', 'institution'},
	['Quote'] = {'quote', 'quotation'},
	['QuotePage'] = 'quote-page',
	['QuotePages'] = 'quote-pages',
	['Ref'] = 'ref',
	['Scale'] = 'scale',
	['ScriptChapter'] = {'script-chapter', 'script-contribution', 'script-entry',
		'script-article', 'script-section'},
	['ScriptEncyclopedia'] = {'script-encyclopedia', 'script-encyclopaedia'},	-- cite encyclopedia only
	['ScriptMap'] = 'script-map',
	['ScriptPeriodical'] = {'script-journal', 'script-magazine', 'script-newspaper',
		'script-periodical', 'script-website', 'script-work'},
	['ScriptQuote'] = 'script-quote',
	['ScriptTitle'] = 'script-title',											-- Used by InternetArchiveBot
	['Season'] = 'season',
	['Sections'] = 'sections',													-- cite map only
	['Series'] = {'series', 'version'},
	['SeriesLink'] = {'series-link', 'serieslink'},
	['SeriesNumber'] = {'series-number', 'series-no'},
	['Sheet'] = 'sheet',														-- cite map only
	['Sheets'] = 'sheets',														-- cite map only
	['Station'] = 'station',
	['Time'] = 'time',
	['TimeCaption'] = 'time-caption',
	['Title'] = 'title',														-- Used by InternetArchiveBot
	['TitleLink'] = {'title-link', 'episode-link', 'episodelink'},				-- Used by InternetArchiveBot
	['TitleNote'] = {'title-note', 'department'},
	['TitleType'] = {'type', 'medium'},
	['TransChapter'] = {'trans-article', 'trans-chapter', 'trans-contribution',
		'trans-entry', 'trans-section'},
	['Transcript'] = 'transcript',
	['TranscriptFormat'] = 'transcript-format',	
	['TranscriptURL'] = 'transcript-url',										-- Used by InternetArchiveBot
	['TransEncyclopedia'] = {'trans-encyclopedia', 'trans-encyclopaedia'},		-- cite encyclopedia only
	['TransMap'] = 'trans-map',													-- cite map only
	['TransPeriodical'] = {'trans-journal', 'trans-magazine', 'trans-newspaper',
		'trans-periodical', 'trans-website', 'trans-work'},
	['TransQuote'] = 'trans-quote',
	['TransTitle'] = 'trans-title',												-- Used by InternetArchiveBot
	['URL'] = {'url', 'URL'},													-- Used by InternetArchiveBot
	['UrlAccess'] = 'url-access',												-- Used by InternetArchiveBot
	['UrlStatus'] = 'url-status',												-- Used by InternetArchiveBot
	['Vauthors'] = 'vauthors',
	['Veditors'] = 'veditors',
	['Via'] = 'via',
	['Volume'] = 'volume',
	['Year'] = 'year',

	['AuthorList-First'] = {&quot;first#&quot;, &quot;author-first#&quot;, &quot;author#-first&quot;, &quot;author-given#&quot;, &quot;author#-given&quot;,
		&quot;subject-first#&quot;, &quot;subject#-first&quot;, &quot;subject-given#&quot;, &quot;subject#-given&quot;,
		&quot;given#&quot;},
	['AuthorList-Last'] = {&quot;last#&quot;, &quot;author-last#&quot;, &quot;author#-last&quot;, &quot;author-surname#&quot;, &quot;author#-surname&quot;,
		&quot;subject-last#&quot;, &quot;subject#-last&quot;, &quot;subject-surname#&quot;, &quot;subject#-surname&quot;,
		&quot;author#&quot;, 'host#', &quot;subject#&quot;, &quot;surname#&quot;},
	['AuthorList-Link'] = {&quot;author-link#&quot;, &quot;author#-link&quot;, &quot;subject-link#&quot;,
		&quot;subject#-link&quot;, &quot;authorlink#&quot;, &quot;author#link&quot;},
	['AuthorList-Mask'] = {&quot;author-mask#&quot;, &quot;author#-mask&quot;, &quot;subject-mask#&quot;, &quot;subject#-mask&quot;},

	['ContributorList-First'] = {'contributor-first#', 'contributor#-first',
		'contributor-given#', 'contributor#-given'},
	['ContributorList-Last'] = {'contributor-last#', 'contributor#-last',
		'contributor-surname#', 'contributor#-surname', 'contributor#'},
	['ContributorList-Link'] = {'contributor-link#', 'contributor#-link'},
	['ContributorList-Mask'] = {'contributor-mask#', 'contributor#-mask'},

	['EditorList-First'] = {&quot;editor-first#&quot;, &quot;editor#-first&quot;, &quot;editor-given#&quot;, &quot;editor#-given&quot;},
	['EditorList-Last'] = {&quot;editor-last#&quot;, &quot;editor#-last&quot;, &quot;editor-surname#&quot;,
		&quot;editor#-surname&quot;, &quot;editor#&quot;},
	['EditorList-Link'] = {&quot;editor-link#&quot;, &quot;editor#-link&quot;},
	['EditorList-Mask'] = {&quot;editor-mask#&quot;, &quot;editor#-mask&quot;},
	
	['InterviewerList-First'] = {'interviewer-first#', 'interviewer#-first',
		'interviewer-given#', 'interviewer#-given'},
	['InterviewerList-Last'] = {'interviewer-last#', 'interviewer#-last',
		'interviewer-surname#', 'interviewer#-surname', 'interviewer#'},
	['InterviewerList-Link'] = {'interviewer-link#', 'interviewer#-link'},
	['InterviewerList-Mask'] = {'interviewer-mask#', 'interviewer#-mask'},

	['TranslatorList-First'] = {'translator-first#', 'translator#-first',
		'translator-given#', 'translator#-given'},
	['TranslatorList-Last'] = {'translator-last#', 'translator#-last',
		'translator-surname#', 'translator#-surname', 'translator#'},
	['TranslatorList-Link'] = {'translator-link#', 'translator#-link'},
	['TranslatorList-Mask'] = {'translator-mask#', 'translator#-mask'},
	}


--[[--------------------------&lt; P U N C T _ S K I P &gt;---------------------------

builds a table of parameter names that the extraneous terminal punctuation check should not check.

]]

local punct_meta_params = {														-- table of aliases[] keys (meta parameters); each key has a table of parameter names for a value
	'BookTitle', 'Chapter', 'ScriptChapter', 'ScriptTitle', 'Title', 'TransChapter', 'Transcript', 'TransMap',	'TransTitle',	-- title-holding parameters
	'AuthorList-Mask', 'ContributorList-Mask', 'EditorList-Mask', 'InterviewerList-Mask', 'TranslatorList-Mask',	-- name-list mask may have name separators
	'PostScript', 'Quote', 'ScriptQuote', 'TransQuote', 'Ref',											-- miscellaneous
	'ArchiveURL', 'ChapterURL', 'ConferenceURL', 'MapURL', 'TranscriptURL', 'URL',						-- URL-holding parameters
	}

local url_meta_params = {														-- table of aliases[] keys (meta parameters); each key has a table of parameter names for a value
	'ArchiveURL', 'ChapterURL', 'ConferenceURL', 'ID', 'MapURL', 'TranscriptURL', 'URL',		-- parameters allowed to hold urls
	'Page', 'Pages', 'At', 'QuotePage', 'QuotePages',							-- insource locators allowed to hold urls
	}

local function build_skip_table (skip_t, meta_params)
	for _, meta_param in ipairs (meta_params) do								-- for each meta parameter key
		local params = aliases[meta_param];										-- get the parameter or the table of parameters associated with the meta parameter name
		if 'string' == type (params) then
			skip_t[params] = 1;													-- just a single parameter
		else
			for _, param in ipairs (params) do									-- get the parameter name
				skip_t[param] = 1;												-- add the parameter name to the skip table
				local count;
				param, count = param:gsub ('#', '');							-- remove enumerator marker from enumerated parameters
				if 0 ~= count then												-- if removed
					skip_t[param] = 1;											-- add param name without enumerator marker
				end
			end
		end
	end
	return skip_t;
end

local punct_skip = {};
local url_skip = {};


--[[--------------------------&lt; S I N G L E - L E T T E R   S E C O N D - L E V E L   D O M A I N S &gt;----------

this is a list of tlds that are known to have single-letter second-level domain names.  This list does not include
ccTLDs which are accepted in is_domain_name().

]]

local single_letter_2nd_lvl_domains_t = {'cash', 'company', 'foundation', 'media', 'org', 'today'};


--[[-----------&lt; S P E C I A L   C A S E   T R A N S L A T I O N S &gt;------------

This table is primarily here to support internationalization.  Translations in
this table are used, for example, when an error message, category name, etc.,
is extracted from the English alias key.  There may be other cases where
this translation table may be useful.

]]
local is_Latn = 'A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143\225\184\128-\225\187\191';
local special_case_translation = {
	['AuthorList'] = 'authors list',											-- used to assemble maintenance category names
	['ContributorList'] = 'contributors list',									-- translation of these names plus translation of the base maintenance category names in maint_cats{} table below
	['EditorList'] = 'editors list',											-- must match the names of the actual categories
	['InterviewerList'] = 'interviewers list',									-- this group or translations used by name_has_ed_markup() and name_has_mult_names()
	['TranslatorList'] = 'translators list',
	
																				-- Lua patterns to match pseudo-titles used by InternetArchiveBot and others as placeholder for unknown |title= value
	['archived_copy'] = {														-- used with CS1 maint: Archive[d] copy as title
		['en'] = '^archived?%s+copy$',											-- for English; translators: keep this because templates imported from en.wiki
		['local'] = nil,														-- translators: replace ['local'] = nil with lowercase translation only when bots or tools create generic titles in your language
		},

																				-- Lua patterns to match generic titles; usually created by bots or reference filling tools
																				-- translators: replace ['local'] = nil with lowercase translation only when bots or tools create generic titles in your language
		-- generic titles and patterns in this table should be lowercase only
		-- leave ['local'] nil except when there is a matching generic title in your language
		-- boolean 'true' for plain-text searches; 'false' for pattern searches

	['generic_titles'] = {
		['accept'] = {
			},
		['reject'] = {
			{['en'] = {'^wayback%s+machine$', false},				['local'] = nil},
			{['en'] = {'are you a robot', true},					['local'] = nil},
			{['en'] = {'hugedomains', true},						['local'] = nil},
			{['en'] = {'^[%(%[{&lt;]?no +title[&gt;}%]%)]?$', false},		['local'] = nil},
			{['en'] = {'page not found', true},						['local'] = nil},
			{['en'] = {'subscribe to read', true},					['local'] = nil},
			{['en'] = {'^[%(%[{&lt;]?unknown[&gt;}%]%)]?$', false},		['local'] = nil},
			{['en'] = {'website is for sale', true},				['local'] = nil},
			{['en'] = {'^404', false},								['local'] = nil},
			{['en'] = {'error[ %-]404', false},						['local'] = nil},
			{['en'] = {'internet archive wayback machine', true},	['local'] = nil},
			{['en'] = {'log into facebook', true},					['local'] = nil},
			{['en'] = {'login • instagram', true},					['local'] = nil},
			{['en'] = {'redirecting...', true},						['local'] = nil},
			{['en'] = {'usurped title', true},						['local'] = nil},	-- added by a GreenC bot
			{['en'] = {'webcite query result', true},				['local'] = nil},
			{['en'] = {'wikiwix\'s cache', true},					['local'] = nil},
			}
		},

		-- boolean 'true' for plain-text searches, search string must be lowercase only
		-- boolean 'false' for pattern searches
		-- leave ['local'] nil except when there is a matching generic name in your language

	['generic_names'] = {
		['accept'] = {
			{['en'] = {'%[%[[^|]*%(author%) *|[^%]]*%]%]', false},				['local'] = nil},
			},
		['reject'] = {
			{['en'] = {'about us', true},										['local'] = nil},
			{['en'] = {'%f[%a][Aa]dvisor%f[%A]', false},						['local'] = nil},
			{['en'] = {'allmusic', true},										['local'] = nil},
			{['en'] = {'%f[%a][Aa]uthor%f[%A]', false},							['local'] = nil},
			{['en'] = {'^[Bb]ureau$', false},									['local'] = nil},
			{['en'] = {'business', true},										['local'] = nil},
			{['en'] = {'cnn', true},											['local'] = nil},
			{['en'] = {'collaborator', true},									['local'] = nil},
			{['en'] = {'^[Cc]ompany$', false},									['local'] = nil},
			{['en'] = {'contributor', true},									['local'] = nil},
			{['en'] = {'contact us', true},										['local'] = nil},
			{['en'] = {'correspondent', true},									['local'] = nil},
			{['en'] = {'^[Dd]esk$', false},										['local'] = nil},
			{['en'] = {'directory', true},										['local'] = nil},
			{['en'] = {'%f[%(%[][%(%[]%s*eds?%.?%s*[%)%]]?$', false},			['local'] = nil},
			{['en'] = {'[,%.%s]%f[e]eds?%.?$', false},							['local'] = nil},
			{['en'] = {'^eds?[%.,;]', false},									['local'] = nil},
			{['en'] = {'^[%(%[]%s*[Ee][Dd][Ss]?%.?%s*[%)%]]', false},			['local'] = nil},
			{['en'] = {'%f[%a][Ee]dited%f[%A]', false},							['local'] = nil},
			{['en'] = {'%f[%a][Ee]ditors?%f[%A]', false},						['local'] = nil},
			{['en'] = {'%f[%a][Ee]mail%f[%A]', false},							['local'] = nil},
			{['en'] = {'facebook', true},										['local'] = nil},
			{['en'] = {'google', true},											['local'] = nil},
			{['en'] = {'^[Gg]roup$', false},									['local'] = nil},
			{['en'] = {'home page', true},										['local'] = nil},
			{['en'] = {'^[Ii]nc%.?$', false},									['local'] = nil},
			{['en'] = {'instagram', true},										['local'] = nil},
			{['en'] = {'interviewer', true},									['local'] = nil},
			{['en'] = {'^[Ll]imited$', false},									['local'] = nil},
			{['en'] = {'linkedIn', true},										['local'] = nil},
			{['en'] = {'^[Nn]ews$', false},										['local'] = nil},
			{['en'] = {'[Nn]ews[ %-]?[Rr]oom', false},							['local'] = nil},
			{['en'] = {'pinterest', true},										['local'] = nil},
			{['en'] = {'policy', true},											['local'] = nil},
			{['en'] = {'privacy', true},										['local'] = nil},
			{['en'] = {'reuters', true},										['local'] = nil},
			{['en'] = {'translator', true},										['local'] = nil},
			{['en'] = {'tumblr', true},											['local'] = nil},
			{['en'] = {'twitter', true},										['local'] = nil},
			{['en'] = {'site name', true},										['local'] = nil},
			{['en'] = {'statement', true},										['local'] = nil},
			{['en'] = {'submitted', true},										['local'] = nil},
			{['en'] = {'super.?user', false},									['local'] = nil},
			{['en'] = {'%f['..is_Latn..'][Uu]ser%f[^'..is_Latn..']', false},	['local'] = nil},
			{['en'] = {'verfasser', true},										['local'] = nil},
			}
	}
	}


--[[--------------------------&lt; D A T E _ N A M E S &gt;----------------------------------------------------------

This table of tables lists local language date names and fallback English date names.
The code in Date_validation will look first in the local table for valid date names.
If date names are not found in the local table, the code will look in the English table.

Because citations can be copied to the local wiki from en.wiki, the English is
required when the date-name translation function date_name_xlate() is used.

In these tables, season numbering is defined by
Extended Date/Time Format (EDTF) Specification (https://www.loc.gov/standards/datetime/)
which became part of ISO 8601 in 2019.  See '§Sub-year groupings'. The standard
defines various divisions using numbers 21-41. CS1|2 only supports generic seasons.
EDTF does support the distinction between north and south hemisphere seasons
but CS1|2 has no way to make that distinction.

33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)

The standard does not address 'named' dates so, for the purposes of CS1|2,
Easter and Christmas are defined here as 98 and 99, which should be out of the
ISO 8601 (EDTF) range of uses for a while.

local_date_names_from_mediawiki is a boolean.  When set to:
	true – module will fetch local month names from MediaWiki for both date_names['local']['long'] and date_names['local']['short']; this will unconditionally overwrite manual translations
	false – module will *not* fetch local month names from MediaWiki

Caveat lector:  There is no guarantee that MediaWiki will provide short month names.  At your wiki you can test
the results of the MediaWiki fetch in the debug console with this command (the result is alpha sorted):
	=mw.dumpObject (p.date_names['local'])

While the module can fetch month names from MediaWiki, it cannot fetch the quarter, season, and named date names
from MediaWiki.  Those must be translated manually.

]]

local local_date_names_from_mediawiki = true;									-- when false, manual translation required for date_names['local']['long'] and date_names['local']['short']; overwrites manual translations
																				-- when true, module fetches long and short month names from MediaWiki
local date_names = {
	['en'] = {																	-- English
		['long']	= {['January'] = 1, ['February'] = 2, ['March'] = 3, ['April'] = 4, ['May'] = 5, ['June'] = 6, ['July'] = 7, ['August'] = 8, ['September'] = 9, ['October'] = 10, ['November'] = 11, ['December'] = 12},
		['short']	= {['Jan'] = 1, ['Feb'] = 2, ['Mar'] = 3, ['Apr'] = 4, ['May'] = 5, ['Jun'] = 6, ['Jul'] = 7, ['Aug'] = 8, ['Sep'] = 9, ['Oct'] = 10, ['Nov'] = 11, ['Dec'] = 12},
		['quarter'] = {['First Quarter'] = 33, ['Second Quarter'] = 34, ['Third Quarter'] = 35, ['Fourth Quarter'] = 36},
		['season']	= {['Winter'] = 24, ['Spring'] = 21, ['Summer'] = 22, ['Fall'] = 23, ['Autumn'] = 23},
		['named']	= {['Easter'] = 98, ['Christmas'] = 99},
		},
																				-- when local_date_names_from_mediawiki = false
	['local'] = {																-- replace these English date names with the local language equivalents
		['long']	= {['January'] = 1, ['February'] = 2, ['March'] = 3, ['April'] = 4, ['May'] = 5, ['June'] = 6, ['July'] = 7, ['August'] = 8, ['September'] = 9, ['October'] = 10, ['November'] = 11, ['December'] = 12},
		['short']	= {['Jan'] = 1, ['Feb'] = 2, ['Mar'] = 3, ['Apr'] = 4, ['May'] = 5, ['Jun'] = 6, ['Jul'] = 7, ['Aug'] = 8, ['Sep'] = 9, ['Oct'] = 10, ['Nov'] = 11, ['Dec'] = 12},
		['quarter'] = {['First Quarter'] = 33, ['Second Quarter'] = 34, ['Third Quarter'] = 35, ['Fourth Quarter'] = 36},
		['season']	= {['Winter'] = 24, ['Spring'] = 21, ['Summer'] = 22, ['Fall'] = 23, ['Autumn'] = 23},
		['named']	= {['Easter'] = 98, ['Christmas'] = 99},
		},
	['inv_local_long'] = {},													-- used in date reformatting &amp; translation; copy of date_names['local'].long where k/v are inverted: [1]='&lt;local name&gt;' etc.
	['inv_local_short'] = {},													-- used in date reformatting &amp; translation; copy of date_names['local'].short where k/v are inverted: [1]='&lt;local name&gt;' etc.
	['inv_local_quarter'] = {},													-- used in date translation; copy of date_names['local'].quarter where k/v are inverted: [1]='&lt;local name&gt;' etc.
	['inv_local_season'] = {},													-- used in date translation; copy of date_names['local'].season where k/v are inverted: [1]='&lt;local name&gt;' etc.
	['inv_local_named'] = {},													-- used in date translation; copy of date_names['local'].named where k/v are inverted: [1]='&lt;local name&gt;' etc.
	['local_digits'] = {['0'] = '0', ['1'] = '1', ['2'] = '2', ['3'] = '3', ['4'] = '4', ['5'] = '5', ['6'] = '6', ['7'] = '7', ['8'] = '8', ['9'] = '9'},	-- used to convert local language digits to Western 0-9
	['xlate_digits'] = {},
	}

if local_date_names_from_mediawiki then											-- if fetching local month names from MediaWiki is enabled
	local long_t = {};
	local short_t = {};
	for i=1, 12 do																-- loop 12x and 
		local name = lang_obj:formatDate('F', '2022-' .. i .. '-1');			-- get long month name for each i
		long_t[name] = i;														-- save it
		name = lang_obj:formatDate('M', '2022-' .. i .. '-1');					-- get short month name for each i
		short_t[name] = i;														-- save it
	end
	date_names['local']['long'] = long_t;										-- write the long table – overwrites manual translation
	date_names['local']['short'] = short_t;										-- write the short table – overwrites manual translation
end
																				-- create inverted date-name tables for reformatting and/or translation
for _, invert_t in pairs {{'long', 'inv_local_long'}, {'short', 'inv_local_short'}, {'quarter', 'inv_local_quarter'}, {'season', 'inv_local_season'}, {'named', 'inv_local_named'}} do
	for name, i in pairs (date_names['local'][invert_t[1]]) do					-- this table is ['name'] = i
		date_names[invert_t[2]][i] = name;										-- invert to get [i] = 'name' for conversions from ymd
	end
end

if local_digits_from_mediawiki then												-- if fetching local digits from MediaWiki is enabled
	local digits_t = {};
	for i=0, 9 do																-- loop 10x and 
		digits_t [lang_obj:formatNum (i)] = tostring (i);						-- format the loop indexer as local lang table index and assign loop indexer (a string) as the value
	end
	date_names['local_digits'] = digits_t;
end

for ld, ed in pairs (date_names.local_digits) do								-- make a digit translation table for simple date translation from en to local language using local_digits table
	date_names.xlate_digits [ed] = ld;											-- en digit becomes index with local digit as the value
end

local df_template_patterns = {													-- table of redirects to {{Use dmy dates}} and {{Use mdy dates}}
	'{{ *[Uu]se +(dmy) +dates *[|}]',	-- 1159k								-- sorted by approximate transclusion count
	'{{ *[Uu]se +(mdy) +dates *[|}]',	-- 212k
	'{{ *[Uu]se +(MDY) +dates *[|}]',	-- 788
	'{{ *[Uu]se +(DMY) +dates *[|}]',	-- 343
	'{{ *([Mm]dy) *[|}]',				-- 176
	'{{ *[Uu]se *(dmy) *[|}]',			-- 156 + 18
	'{{ *[Uu]se *(mdy) *[|}]',			-- 149 + 11
	'{{ *([Dd]my) *[|}]',				-- 56
	'{{ *[Uu]se +(MDY) *[|}]',			-- 5
	'{{ *([Dd]MY) *[|}]',				-- 3
	'{{ *[Uu]se(mdy)dates *[|}]',		-- 1
	'{{ *[Uu]se +(DMY) *[|}]',			-- 0
	'{{ *([Mm]DY) *[|}]',				-- 0
	}

local title_object = mw.title.getCurrentTitle();
local content;																	-- done this way  so that unused templates appear in unused-template-reports; self-transcluded makes them look like they are used
if 10 ~= title_object.namespace then											-- all namespaces except Template
	content = title_object:getContent() or '';									-- get the content of the article or ''; new pages edited w/ve do not have 'content' until saved; ve does not preview; phab:T221625
end

local function get_date_format ()
	if not content then															-- nil content when we're in template
		return nil;																-- auto-formatting does not work in Template space so don't set global_df
	end
	for _, pattern in ipairs (df_template_patterns) do							-- loop through the patterns looking for {{Use dmy dates}} or {{Use mdy dates}} or any of their redirects
		local start, _, match = content:find(pattern);							-- match is the three letters indicating desired date format
		if match then
			local use_dates_template = content:match ('%b{}', start);			-- get the whole template
			if use_dates_template:match ('| *cs1%-dates *= *[lsy][sy]?') then	-- look for |cs1-dates=publication date length access-/archive-date length
				return match:lower() .. '-' .. use_dates_template:match ('| *cs1%-dates *= *([lsy][sy]?)');
			else
				return match:lower() .. '-all';									-- no |cs1-dates= k/v pair; return value appropriate for use in |df=
			end
		end
	end
end

local global_df;																-- TODO: add this to &lt;global_cs1_config_t&gt;?


--[[-----------------&lt; V O L U M E ,  I S S U E ,  P A G E S &gt;------------------

These tables hold cite class values (from the template invocation) and identify those templates that support
|volume=, |issue=, and |page(s)= parameters.  Cite conference and cite map require further qualification which
is handled in the main module.

]]

local templates_using_volume = {'citation', 'audio-visual', 'book', 'conference', 'encyclopaedia', 'interview', 'journal', 'magazine', 'map', 'news', 'report', 'techreport', 'thesis'}
local templates_using_issue = {'citation', 'conference', 'episode', 'interview', 'journal', 'magazine', 'map', 'news', 'podcast'}
local templates_not_using_page = {'audio-visual', 'episode', 'mailinglist', 'newsgroup', 'podcast', 'serial', 'sign', 'speech'}

--[[

These tables control when it is appropriate for {{citation}} to render |volume= and/or |issue=.  The parameter
names in the tables constrain {{citation}} so that its renderings match the renderings of the equivalent cs1
templates.  For example, {{cite web}} does not support |volume= so the equivalent {{citation |website=...}} must
not support |volume=.

]]

local citation_no_volume_t = {													-- {{citation}} does not render |volume= when these parameters are used
	'website', 'mailinglist', 'script-website',
	}
local citation_issue_t = {														-- {{citation}} may render |issue= when these parameters are used
	'journal', 'magazine', 'newspaper', 'periodical', 'work',
	'script-journal', 'script-magazine', 'script-newspaper', 'script-periodical', 'script-work',
	}

--[[

Patterns for finding extra text in |volume=, |issue=, |page=, |pages=

]]

local vol_iss_pg_patterns = {
	good_ppattern = '^P[^%.PpGg]',												-- OK to begin with uppercase P: P7 (page 7 of section P), but not p123 (page 123); TODO: this allows 'Pages' which it should not
	bad_ppatterns = {															-- patterns for |page= and |pages=
		'^[Pp][PpGg]?%.?[ %d]',
		'^[Pp][Pp]?%.&amp;nbsp;',													-- from {{p.}} and {{pp.}} templates
		'^[Pp]ages?',
		'^[Pp]gs.?',
		},
	vi_patterns_t = {															-- combined to catch volume-like text in |issue= and issue-like text in |volume=
		'^volumes?',															-- volume-like text
		'^vols?[%.:=]?',

		'^issues?',																--issue-like text
		'^iss[%.:=]?',
		'^numbers?',
		'^nos?%A',																-- don't match 'november' or 'nostradamus'
		'^nr[%.:=]?',
		'^n[%.:= ]',															-- might be a valid issue without separator (space char is sep char here)
		'^n°',																	-- 'n' with degree sign (U+00B0)
		'^№',																	-- precomposed unicode numero character (U+2116)
		},
	}

--[[--------------------------&lt; K E Y W O R D S &gt;-------------------------------

These tables hold keywords for those parameters that have defined sets of acceptable keywords.

]]

--[[-------------------&lt; K E Y W O R D S   T A B L E &gt;--------------------------

this is a list of keywords; each key in the list is associated with a table of
synonymous keywords possibly from different languages.

for I18N: add local-language keywords to value table; do not change the key.
For example, adding the German keyword 'ja':
	['affirmative'] = {'yes', 'true', 'y', 'ja'},

Because CS1|2 templates from en.wiki articles are often copied to other local wikis,
it is recommended that the English keywords remain in these tables.

]]

local keywords = {
	['amp'] = {'&amp;', 'amp', 'ampersand'}, 										-- |name-list-style=
	['and'] = {'and', 'serial'},												-- |name-list-style=
	['affirmative'] = {'yes', 'true', 'y'},										-- |no-tracking=, |no-pp= -- Used by InternetArchiveBot
	['afterword'] = {'afterword'},												-- |contribution=
	['bot: unknown'] = {'bot: unknown'},										-- |url-status= -- Used by InternetArchiveBot
	['cs1'] = {'cs1'},															-- |mode=
	['cs2'] = {'cs2'},															-- |mode=
	['dead'] = {'dead', 'deviated'},											-- |url-status= -- Used by InternetArchiveBot
	['dmy'] = {'dmy'},															-- |df=
	['dmy-all'] = {'dmy-all'},													-- |df=
	['foreword'] = {'foreword'},												-- |contribution=
	['free'] = {'free'},														-- |&lt;id&gt;-access= -- Used by InternetArchiveBot
	['harv'] = {'harv'},														-- |ref=; this no longer supported; is_valid_parameter_value() called with &lt;invert&gt; = true
	['introduction'] = {'introduction'},										-- |contribution=
	['limited'] = {'limited'},													-- |url-access= -- Used by InternetArchiveBot
	['live'] = {'live'},														-- |url-status= -- Used by InternetArchiveBot
	['mdy'] = {'mdy'},															-- |df=
	['mdy-all'] = {'mdy-all'},													-- |df=
	['none'] = {'none'},														-- |postscript=, |ref=, |title=, |type= -- Used by InternetArchiveBot
	['off'] = {'off'},															-- |title= (potentially also: |title-link=, |postscript=, |ref=, |type=)
	['preface'] = {'preface'},													-- |contribution=
	['registration'] = {'registration'},										-- |url-access= -- Used by InternetArchiveBot
	['subscription'] = {'subscription'},										-- |url-access= -- Used by InternetArchiveBot
	['unfit'] = {'unfit'},														-- |url-status= -- Used by InternetArchiveBot
	['usurped'] = {'usurped'},													-- |url-status= -- Used by InternetArchiveBot
	['vanc'] = {'vanc'},														-- |name-list-style=
	['ymd'] = {'ymd'},															-- |df=
	['ymd-all'] = {'ymd-all'},													-- |df=
	--	['yMd'] = {'yMd'},														-- |df=; not supported at en.wiki
	--	['yMd-all'] = {'yMd-all'},												-- |df=; not supported at en.wiki
	}


--[[------------------------&lt; X L A T E _ K E Y W O R D S &gt;---------------------

this function builds a list, keywords_xlate{}, of the keywords found in keywords{} where the values from keywords{}
become the keys in keywords_xlate{} and the keys from keywords{} become the values in keywords_xlate{}:
	['affirmative'] = {'yes', 'true', 'y'},		-- in keywords{}
becomes
	['yes'] = 'affirmative',					-- in keywords_xlate{}
	['true'] = 'affirmative',
	['y'] = 'affirmative',

the purpose of this function is to act as a translator between a non-English keyword and its English equivalent
that may be used in other modules of this suite

]]

local function xlate_keywords ()
	local out_table = {};														-- output goes here
	for k, keywords_t in pairs (keywords) do									-- spin through the keywords table
		for _, keyword in ipairs (keywords_t) do								-- for each keyword
			out_table[keyword] = k;												-- create an entry in the output table where keyword is the key
		end
	end
	
	return out_table;
end

local keywords_xlate = xlate_keywords ();										-- the list of translated keywords


--[[----------------&lt; M A K E _ K E Y W O R D S _ L I S T &gt;---------------------

this function assembles, for parameter-value validation, the list of keywords appropriate to that parameter.

keywords_lists{}, is a table of tables from keywords{}

]]

local function make_keywords_list (keywords_lists)
	local out_table = {};														-- output goes here
	
	for _, keyword_list in ipairs (keywords_lists) do							-- spin through keywords_lists{} and get a table of keywords
		for _, keyword in ipairs (keyword_list) do								-- spin through keyword_list{} and add each keyword, ...
			table.insert (out_table, keyword);									-- ... as plain text, to the output list
		end
	end
	return out_table;
end


--[[----------------&lt; K E Y W O R D S _ L I S T S &gt;-----------------------------

this is a list of lists of valid keywords for the various parameters in [key].
Generally the keys in this table are the canonical en.wiki parameter names though
some are contrived because of use in multiple differently named parameters:
['yes_true_y'], ['id-access'].

The function make_keywords_list() extracts the individual keywords from the
appropriate list in keywords{}.

The lists in this table are used to validate the keyword assignment for the
parameters named in this table's keys.

]]

local keywords_lists = {
	['yes_true_y'] = make_keywords_list ({keywords.affirmative}),
	['contribution'] = make_keywords_list ({keywords.afterword, keywords.foreword, keywords.introduction, keywords.preface}),
	['df'] = make_keywords_list ({keywords.dmy, keywords['dmy-all'], keywords.mdy, keywords['mdy-all'], keywords.ymd, keywords['ymd-all']}),
	--	['df'] = make_keywords_list ({keywords.dmy, keywords['dmy-all'], keywords.mdy, keywords['mdy-all'], keywords.ymd, keywords['ymd-all'], keywords.yMd, keywords['yMd-all']}),	-- not supported at en.wiki
	['mode'] = make_keywords_list ({keywords.cs1, keywords.cs2}),
	['name-list-style'] = make_keywords_list ({keywords.amp, keywords['and'], keywords.vanc}),
	['ref'] = make_keywords_list ({keywords.harv}),								-- inverted check; |ref=harv no longer supported
	['url-access'] = make_keywords_list ({keywords.subscription, keywords.limited, keywords.registration}),
	['url-status'] = make_keywords_list ({keywords.dead, keywords.live, keywords.unfit, keywords.usurped, keywords['bot: unknown']}),
	['id-access'] = make_keywords_list ({keywords.free}),
	}


--[[--------------------------&lt; C S 1 _ C O N F I G _ G E T &gt;--------------------------------------------------

fetch and validate values from {{cs1 config}} template to fill &lt;global_cs1_config_t&gt;

no error messages; when errors are detected, the parameter value from {{cs1 config}} is blanked.

Supports all parameters and aliases associated with the metaparameters: DisplayAuthors, DisplayContributors,
DisplayEditors, DisplayInterviewers, DisplayTranslators, NameListStyle, and Mode.  The DisplayWhatever metaparameters
accept numeric values only (|display-authors=etal and the like is not supported).

]]

local global_cs1_config_t = {};													-- TODO: add value returned from get_date_format() to this table?

local function get_cs1_config ()
	if not content then															-- nil content when we're in template
		return nil;																-- auto-formatting does not work in Template space so don't set global_df
	end

	local start = content:find('{{ *[Cc][Ss]1 config *[|}]');					-- &lt;start&gt; is offset into &lt;content&gt; when {{cs1 config}} found; nil else
	if start then
		local cs1_config_template = content:match ('%b{}', start);				-- get the whole template

		if not cs1_config_template then
			return nil;
		end

		local params_t = mw.text.split (cs1_config_template:gsub ('^{{%s*', ''):gsub ('%s*}}$', ''), '%s*|%s*');	-- remove '{{' and '}}'; make a sequence of parameter/value pairs (split on the pipe)
		table.remove (params_t, 1);												-- remove the template name because it isn't a parameter/value pair

		local config_meta_params_t = {'DisplayAuthors', 'DisplayContributors', 'DisplayEditors', 'DisplayInterviewers', 'DisplayTranslators', 'NameListStyle', 'Mode'};
		local meta_param_map_t = {};											-- list of accepted parameter names usable in {{cs1 config}} goes here
		
		for _, meta_param in ipairs (config_meta_params_t) do					-- for i18n using &lt;config_meta_params_t&gt;, map template parameter names to their metaparameter equivalents
			if 'table' == type (aliases[meta_param]) then						-- if &lt;meta_param&gt; is a sequence, 
				for _, param in ipairs (aliases[meta_param]) do					-- extract its contents
					meta_param_map_t[param] = meta_param;						-- and add to &lt;meta_param_map_t&gt;
				end
			else
				meta_param_map_t[aliases[meta_param]] = meta_param;				-- not a sequence so just add the parameter to &lt;meta_param_map_t&gt;
			end
		end

		local keywords_t = {};													-- map valid keywords to their associate metaparameter; reverse form of &lt;keyword_lists[key] for these metaparameters
		for _, metaparam_t in ipairs ({{'NameListStyle', 'name-list-style'}, {'Mode', 'mode'}}) do	-- only these metaparameter / keywords_lists key pairs
			for _, keyword in ipairs (keywords_lists[metaparam_t[2]]) do		-- spin through the list of keywords
				keywords_t[keyword] = metaparam_t[1];							-- add [keyword] = metaparameter to the map
			end
		end

		for _, param in ipairs (params_t) do									-- spin through the {{cs1 config}} parameters and fill &lt;global_cs1_config_t&gt;
			local k, v = param:match ('([^=]-)%s*=%s*(.+)');					-- &lt;k&gt; is the parameter name; &lt;v&gt; is parameter's assigned value
			if k then
				if k:find ('^display') then										-- if &lt;k&gt; is one of the |display-&lt;namelist&gt;= parameters
					if v:match ('%d+') then										-- the assigned value must be digits; doesn't accept 'etal'
						global_cs1_config_t[meta_param_map_t[k]]=v;				-- add the display param and its value to globals table
					end
				else
					if keywords_t[v] == meta_param_map_t[k] then				-- keywords_t[v] returns nil or the metaparam name; these must be the same
						global_cs1_config_t[meta_param_map_t[k]]=v;				-- add the parameter and its value to globals table
					end
				end
			end
		end
	end
end

get_cs1_config ();																-- fill &lt;global_cs1_config_t&gt;


--[[---------------------&lt; S T R I P M A R K E R S &gt;----------------------------

Common pattern definition location for stripmarkers so that we don't have to go
hunting for them if (when) MediaWiki changes their form.

]]

local stripmarkers = {
	['any'] = '\127[^\127]*UNIQ%-%-(%a+)%-[%a%d]+%-QINU[^\127]*\127',			-- capture returns name of stripmarker
	['math'] = '\127[^\127]*UNIQ%-%-math%-[%a%d]+%-QINU[^\127]*\127'			-- math stripmarkers used in coins_cleanup() and coins_replace_math_stripmarker()
	}


--[[------------&lt; I N V I S I B L E _ C H A R A C T E R S &gt;---------------------

This table holds non-printing or invisible characters indexed either by name or
by Unicode group. Values are decimal representations of UTF-8 codes.  The table
is organized as a table of tables because the Lua pairs keyword returns table
data in an arbitrary order.  Here, we want to process the table from top to bottom
because the entries at the top of the table are also found in the ranges specified
by the entries at the bottom of the table.

Also here is a pattern that recognizes stripmarkers that begin and end with the
delete characters.  The nowiki stripmarker is not an error but some others are
because the parameter values that include them become part of the template's
metadata before stripmarker replacement.

]]

local invisible_defs = {
	del = '\127',																-- used to distinguish between stripmarker and del char
	zwj = '\226\128\141',														-- used with capture because zwj may be allowed
	}

local invisible_chars = {
	{'replacement', '\239\191\189'},											-- U+FFFD, EF BF BD
	{'zero width joiner', '('.. invisible_defs.zwj .. ')'},						-- U+200D, E2 80 8D; capture because zwj may be allowed
	{'zero width space', '\226\128\139'},										-- U+200B, E2 80 8B
	{'hair space', '\226\128\138'},												-- U+200A, E2 80 8A
	{'soft hyphen', '\194\173'},												-- U+00AD, C2 AD
	{'horizontal tab', '\009'},													-- U+0009 (HT), 09
	{'line feed', '\010'},														-- U+000A (LF), 0A
	{'no-break space', '\194\160'},												-- U+00A0 (NBSP), C2 A0
	{'carriage return', '\013'},												-- U+000D (CR), 0D
	{'stripmarker', stripmarkers.any},											-- stripmarker; may or may not be an error; capture returns the stripmaker type
	{'delete', '('.. invisible_defs.del .. ')'},								-- U+007F (DEL), 7F; must be done after stripmarker test; capture to distinguish isolated del chars not part of stripmarker
	{'C0 control', '[\000-\008\011\012\014-\031]'},								-- U+0000–U+001F (NULL–US), 00–1F (except HT, LF, CR (09, 0A, 0D))
	{'C1 control', '[\194\128-\194\159]'},										-- U+0080–U+009F (XXX–APC), C2 80 – C2 9F
	--	{'Specials', '[\239\191\185-\239\191\191]'},								-- U+FFF9-U+FFFF, EF BF B9 – EF BF BF
	--	{'Private use area', '[\238\128\128-\239\163\191]'},						-- U+E000–U+F8FF, EE 80 80 – EF A3 BF
	--	{'Supplementary Private Use Area-A', '[\243\176\128\128-\243\191\191\189]'},	-- U+F0000–U+FFFFD, F3 B0 80 80 – F3 BF BF BD
	--	{'Supplementary Private Use Area-B', '[\244\128\128\128-\244\143\191\189]'},	-- U+100000–U+10FFFD, F4 80 80 80 – F4 8F BF BD
	}

--[[

Indic script makes use of zero width joiner as a character modifier so zwj
characters must be left in.  This pattern covers all of the unicode characters
for these languages:
	Devanagari					0900–097F – https://unicode.org/charts/PDF/U0900.pdf
		Devanagari extended		A8E0–A8FF – https://unicode.org/charts/PDF/UA8E0.pdf
	Bengali						0980–09FF – https://unicode.org/charts/PDF/U0980.pdf
	Gurmukhi					0A00–0A7F – https://unicode.org/charts/PDF/U0A00.pdf
	Gujarati					0A80–0AFF – https://unicode.org/charts/PDF/U0A80.pdf
	Oriya						0B00–0B7F – https://unicode.org/charts/PDF/U0B00.pdf
	Tamil						0B80–0BFF – https://unicode.org/charts/PDF/U0B80.pdf
	Telugu						0C00–0C7F – https://unicode.org/charts/PDF/U0C00.pdf
	Kannada						0C80–0CFF – https://unicode.org/charts/PDF/U0C80.pdf
	Malayalam					0D00–0D7F – https://unicode.org/charts/PDF/U0D00.pdf
plus the not-necessarily Indic scripts for Sinhala and Burmese:
	Sinhala						0D80-0DFF - https://unicode.org/charts/PDF/U0D80.pdf
	Myanmar						1000-109F - https://unicode.org/charts/PDF/U1000.pdf
		Myanmar extended A		AA60-AA7F - https://unicode.org/charts/PDF/UAA60.pdf
		Myanmar extended B		A9E0-A9FF - https://unicode.org/charts/PDF/UA9E0.pdf
the pattern is used by has_invisible_chars() and coins_cleanup()

]]

local indic_script = '[\224\164\128-\224\181\191\224\163\160-\224\183\191\225\128\128-\225\130\159\234\167\160-\234\167\191\234\169\160-\234\169\191]';

-- list of emoji that use a zwj character (U+200D) to combine with another emoji
-- from: https://unicode.org/Public/emoji/16.0/emoji-zwj-sequences.txt; version: 16.0; 2024-08-14
-- table created by: [[:en:Module:Make emoji zwj table]]
local emoji_t = {																-- indexes are decimal forms of the hex values in U+xxxx
	[8596] = true,																-- U+2194 ↔ left right arrow
	[8597] = true,																-- U+2195 ↕ up down arrow
	[9760] = true,																-- U+2620 ☠ skull and crossbones
	[9792] = true,																-- U+2640 ♀ female sign
	[9794] = true,																-- U+2642 ♂ male sign
	[9877] = true,																-- U+2695 ⚕ staff of aesculapius
	[9878] = true,																-- U+2696 ⚖ scales
	[9895] = true,																-- U+26A7 ⚧ male with stroke and male and female sign
	[9992] = true,																-- U+2708 ✈ airplane
	[10052] = true,																-- U+2744 ❄ snowflake
	[10084] = true,																-- U+2764 ❤ heavy black heart
	[10145] = true,																-- U+27A1 ➡ black rightwards arrow
	[11035] = true,																-- U+2B1B ⬛ black large square
	[127752] = true,															-- U+1F308 🌈 rainbow
	[127787] = true,															-- U+1F32B 🌫 fog
	[127806] = true,															-- U+1F33E 🌾 ear of rice
	[127859] = true,															-- U+1F373 🍳 cooking
	[127868] = true,															-- U+1F37C 🍼 baby bottle
	[127876] = true,															-- U+1F384 🎄 christmas tree
	[127891] = true,															-- U+1F393 🎓 graduation cap
	[127908] = true,															-- U+1F3A4 🎤 microphone
	[127912] = true,															-- U+1F3A8 🎨 artist palette
	[127979] = true,															-- U+1F3EB 🏫 school
	[127981] = true,															-- U+1F3ED 🏭 factory
	[128102] = true,															-- U+1F466 👦 boy
	[128103] = true,															-- U+1F467 👧 girl
	[128104] = true,															-- U+1F468 👨 man
	[128105] = true,															-- U+1F469 👩 woman
	[128139] = true,															-- U+1F48B 💋 kiss mark
	[128165] = true,															-- U+1F4A5 💥 collision symbol
	[128168] = true,															-- U+1F4A8 💨 dash symbol
	[128171] = true,															-- U+1F4AB 💫 dizzy symbol
	[128187] = true,															-- U+1F4BB 💻 personal computer
	[128188] = true,															-- U+1F4BC 💼 brief case
	[128293] = true,															-- U+1F525 🔥 fire
	[128295] = true,															-- U+1F527 🔧 wrench
	[128300] = true,															-- U+1F52C 🔬 microscope
	[128488] = true,															-- U+1F5E8 🗨 left speech bubble
	[128640] = true,															-- U+1F680 🚀 rocket
	[128658] = true,															-- U+1F692 🚒 fire engine
	[129001] = true,															-- U+1F7E9 🟩 large green square
	[129003] = true,															-- U+1F7EB 🟫 large brown square
	[129309] = true,															-- U+1F91D 🤝 handshake
	[129455] = true,															-- U+1F9AF 🦯 probing cane
	[129456] = true,															-- U+1F9B0 🦰 emoji component red hair
	[129457] = true,															-- U+1F9B1 🦱 emoji component curly hair
	[129458] = true,															-- U+1F9B2 🦲 emoji component bald
	[129459] = true,															-- U+1F9B3 🦳 emoji component white hair
	[129466] = true,															-- U+1F9BA 🦺 safety vest
	[129468] = true,															-- U+1F9BC 🦼 motorized wheelchair
	[129469] = true,															-- U+1F9BD 🦽 manual wheelchair
	[129489] = true,															-- U+1F9D1 🧑 adult
	[129490] = true,															-- U+1F9D2 🧒 child
	[129657] = true,															-- U+1FA79 🩹 adhesive bandage
	[129778] = true,															-- U+1FAF2 🫲 leftwards hand
	}


--[[----------------------&lt; L A N G U A G E   S U P P O R T &gt;-------------------

These tables and constants support various language-specific functionality.

]]

--local this_wiki_code = mw.getContentLanguage():getCode();						-- get this wiki's language code
local this_wiki_code = lang_obj:getCode();										-- get this wiki's language code
if string.match (mw.site.server, 'wikidata') then
		this_wiki_code = mw.getCurrentFrame():callParserFunction('int', {'lang'}); -- on Wikidata so use interface language setting instead
	end

local mw_languages_by_tag_t = mw.language.fetchLanguageNames (this_wiki_code, 'all');	-- get a table of language tag/name pairs known to Wikimedia; used for interwiki tests
local mw_languages_by_name_t = {};
	for k, v in pairs (mw_languages_by_tag_t) do								-- build a 'reversed' table name/tag language pairs know to MediaWiki; used for |language=
		v = mw.ustring.lower (v);												-- lowercase for tag fetch; get name's proper case from mw_languages_by_tag_t[&lt;tag&gt;]
		if mw_languages_by_name_t[v] then										-- when name already in the table
			if 2 == #k or 3 == #k then											-- if tag does not have subtags
				mw_languages_by_name_t[v] = k;									-- prefer the shortest tag for this name
			end
		else																	-- here when name not in the table
			mw_languages_by_name_t[v] = k;										-- so add name and matching tag
		end
	end

local inter_wiki_map = {};														-- map of interwiki prefixes that are language-code prefixes
	for k, v in pairs (mw.site.interwikiMap ('local')) do						-- spin through the base interwiki map (limited to local)
		if mw_languages_by_tag_t[v[&quot;prefix&quot;]] then								-- if the prefix matches a known language tag
			inter_wiki_map[v[&quot;prefix&quot;]] = true;									-- add it to our local map
		end
	end


--[[--------------------&lt; S C R I P T _ L A N G _ C O D E S &gt;-------------------

This table is used to hold ISO 639-1 two-character and ISO 639-3 three-character
language codes that apply only to |script-title= and |script-chapter=

]]

local script_lang_codes = {
	'ab', 'am', 'ar', 'az', 'be', 'bg', 'bn', 'bo', 'bs', 'ce', 'chr', 'dv', 'dz',
	'el', 'fa', 'grc', 'gu', 'he', 'hi', 'hy', 'ja', 'ka', 'kk', 'km', 'kn', 'ko',
	'ku', 'ky', 'lo', 'mk', 'ml', 'mn', 'mni', 'mr', 'my', 'ne', 'or', 'ota',
	'pa', 'ps', 'ru', 'sd', 'si', 'sr', 'syc', 'ta', 'te', 'tg', 'th', 'ti', 'tt',
	'ug', 'uk', 'ur', 'uz', 'yi', 'yue', 'zh', 'zgh'
	};


--[[---------------&lt; L A N G U A G E   R E M A P P I N G &gt;----------------------

These tables hold language information that is different (correct) from MediaWiki's definitions

For each ['&lt;tag&gt;'] = 'language name' in lang_code_remap{} there must be a matching ['language name'] = {'language name', '&lt;tag&gt;'} in lang_name_remap{}

lang_tag_remap{}:
	key is always lowercase ISO 639-1, -2, -3 language tag or a valid lowercase IETF language tag
	value is properly spelled and capitalized language name associated with &lt;tag&gt;
	only one language name per &lt;tag&gt;;
	key/value pair must have matching entry in lang_name_remap{}

lang_name_remap{}:
	key is always lowercase language name
	value is a table the holds correctly spelled and capitalized language name [1] and associated tag [2] (tag must match a tag key in lang_tag_remap{})
	may have multiple keys referring to a common preferred name and tag; For example:
		['kolsch'] and ['kölsch'] both refer to 'Kölsch' and 'ksh'

]]

local lang_tag_remap = {														-- used for |language= and |script-title= / |script-chapter=
	['als'] = 'Tosk Albanian',													-- MediaWiki returns Alemannisch 
	['bh'] = 'Bihari',															-- MediaWiki uses 'bh' as a subdomain name for Bhojpuri Wikipedia: bh.wikipedia.org
	['bla'] = 'Blackfoot',														-- MediaWiki/IANA/ISO 639: Siksika; use en.wiki preferred name
	['bn'] = 'Bengali',															-- MediaWiki returns Bangla
	['ca-valencia'] = 'Valencian',												-- IETF variant of Catalan
	['fkv'] = 'Kven',															-- MediaWiki returns Kvensk
	['gsw'] = 'Swiss German',
	['ilo'] = 'Ilocano',														-- MediaWiki/IANA/ISO 639: Iloko; use en.wiki preferred name
	['ksh'] = 'Kölsch',															-- MediaWiki: Colognian; use IANA/ISO 639 preferred name
	['ksh-x-colog'] = 'Colognian',												-- override MediaWiki ksh; no IANA/ISO 639 code for Colognian; IETF private code created at Module:Lang/data
	['mis-x-ripuar'] = 'Ripuarian',												-- override MediaWiki ksh; no IANA/ISO 639 code for Ripuarian; IETF private code created at Module:Lang/data
	['nan-tw'] = 'Taiwanese Hokkien',											-- make room for MediaWiki/IANA/ISO 639 nan: Min Nan Chinese and support en.wiki preferred name
	['sr-ec'] = 'Serbian (Cyrillic script)',									-- MediaWiki returns српски (ћирилица)
	['sr-el'] = 'Serbian (Latin script)',										-- MediaWiki returns srpski (latinica)
	}

local lang_name_remap = {														-- used for |language=; names require proper capitalization; tags must be lowercase
	['alemannic'] = {'Swiss German', 'gsw'},									-- ISO 639-2, -3 alternate for Swiss German; MediaWiki mediawiki returns Alemannic for gsw; en.wiki preferred name
	['alemannisch'] = {'Swiss German', 'gsw'},									-- not an ISO or IANA language name; MediaWiki uses 'als' as a subdomain name for Alemannic Wikipedia: als.wikipedia.org
	['bangla'] = {'Bengali', 'bn'},												-- MediaWiki returns Bangla (the endonym) but we want Bengali (the exonym); here we remap
	['bengali'] = {'Bengali', 'bn'},											-- MediaWiki doesn't use exonym so here we provide correct language name and 639-1 code
	['bhojpuri'] = {'Bhojpuri', 'bho'},											-- MediaWiki uses 'bh' as a subdomain name for Bhojpuri Wikipedia: bh.wikipedia.org
	['bihari'] = {'Bihari', 'bh'},												-- MediaWiki replaces 'Bihari' with 'Bhojpuri' so 'Bihari' cannot be found
	['blackfoot'] = {'Blackfoot', 'bla'},										-- MediaWiki/IANA/ISO 639: Siksika; use en.wiki preferred name
	['colognian'] = {'Colognian', 'ksh-x-colog'},								-- MediaWiki preferred name for ksh
	['ilocano'] = {'Ilocano', 'ilo'},											-- MediaWiki/IANA/ISO 639: Iloko; use en.wiki preferred name
	['kolsch'] = {'Kölsch', 'ksh'},												-- use IANA/ISO 639 preferred name (use non-diacritical o instead of umlaut ö)
	['kölsch'] = {'Kölsch', 'ksh'},												-- use IANA/ISO 639 preferred name
	['kven'] = {'Kven', 'fkv'},													-- Unicode CLDR have decided not to support English language name for these two...
	['kvensk'] = {'Kven', 'fkv'},												-- ...they say to refer to IANA registry for English names
	['ripuarian'] = {'Ripuarian', 'mis-x-ripuar'},								-- group of dialects; no code in MediaWiki or in IANA/ISO 639
	['serbian (cyrillic script)'] = {'Serbian (Cyrillic script)', 'sr-cyrl'},	-- special case to get correct tag when |language=sr-ec
	['serbian (latin script)'] = {'Serbian (Latin script)', 'sr-latn'},			-- special case to get correct tag when |language=sr-el
	['swiss german'] = {'Swiss German', 'gsw'},
	['taiwanese hokkien'] = {'Taiwanese Hokkien', 'nan-tw'},					-- make room for MediaWiki/IANA/ISO 639 nan: Min Nan Chinese 
	['tosk albanian'] = {'Tosk Albanian', 'als'},								-- MediaWiki replaces 'Tosk Albanian' with 'Alemannisch' so 'Tosk Albanian' cannot be found
	['valencian'] = {'Valencian', 'ca-valencia'},								-- variant of Catalan; categorizes as Valencian
	}


--[[---------------&lt; P R O P E R T I E S _ C A T E G O R I E S &gt;----------------

Properties categories. These are used for investigating qualities of citations.

]]

local prop_cats = {
	['foreign-lang-source'] = 'CS1 $1-language sources ($2)',					-- |language= categories; $1 is foreign-language name, $2 is ISO639-1 code
	['foreign-lang-source-2'] = 'CS1 foreign language sources (ISO 639-2)|$1',	-- |language= category; a cat for ISO639-2 languages; $1 is the ISO 639-2 code used as a sort key
	['interproj-linked-name'] = 'CS1 interproject-linked names|$1',				-- any author, editor, etc that has an interproject link; $1 is interproject tag used as a sort key
	['interwiki-linked-name'] = 'CS1 interwiki-linked names|$1',				-- any author, editor, etc that has an interwiki link; $1 is interwiki tag used as a sort key; yeilds to interproject
	['local-lang-source'] = 'CS1 $1-language sources ($2)',						-- |language= categories; $1 is local-language name, $2 is ISO639-1 code; not emitted when local_lang_cat_enable is false
	['location-test'] = 'CS1 location test',
	['long-vol'] = 'CS1: long volume value',									-- probably temporary cat to identify scope of |volume= values longer than 4 characters
	['script'] = 'CS1 uses $1-language script ($2)',							-- |script-title=xx: has matching category; $1 is language name, $2 is language tag
	['tracked-param'] = 'CS1 tracked parameter: $1',							-- $1 is base (enumerators removed) parameter name
	['unfit'] = 'CS1: unfit URL',												-- |url-status=unfit or |url-status=usurped; used to be a maint cat
	['vanc-accept'] = 'CS1:Vancouver names with accept markup',					-- for |vauthors=/|veditors= with accept-as-written markup
	['year-range-abbreviated'] = 'CS1: abbreviated year range',					-- probably temporary cat to identify scope of |date=, |year= values using YYYY–YY form
	}


--[[-------------------&lt; T I T L E _ T Y P E S &gt;--------------------------------

Here we map a template's CitationClass to TitleType (default values for |type= parameter)

]]

local title_types = {
	['AV-media-notes'] = 'Media notes',
	['document'] = 'Document',
	['interview'] = 'Interview',
	['mailinglist'] = 'Mailing list',
	['map'] = 'Map',
	['podcast'] = 'Podcast',
	['pressrelease'] = 'Press release',
	['report'] = 'Report',
	['speech'] = 'Speech',
	['techreport'] = 'Technical report',
	['thesis'] = 'Thesis',
	}


--[[--------------------------&lt; B U I L D _ K N O W N _ F R E E _ D O I _ R E G I S T R A N T S _ T A B L E &gt;--

build a table of doi registrants known to be free-to-read  In a doi, the registrant ID is the series of digits
between the '10.' and the first '/': in doi 10.1100/sommat, 1100 is the registrant ID

see §3.2.2 DOI prefix of the Doi Handbook p. 43
https://www.doi.org/doi-handbook/DOI_Handbook_Final.pdf#page=43

]]

local function build_free_doi_registrants_table()
	local registrants_t = {};
	for _, v in ipairs ({
		'1045', '1074', '1096', '1100', '1155', '1186', '1194', '1371', '1629', '1989', '1999', '2147', '2196', '3285', '3389', '3390',
		'3748', '3814', '3847', '3897', '4061', '4089', '4103', '4172', '4175', '4230', '4236', '4239', '4240', '4249', '4251',
		'4252', '4253', '4254', '4291', '4292', '4329', '4330', '4331', '5194', '5210', '5306', '5312', '5313', '5314',
		'5315', '5316', '5317', '5318', '5319', '5320', '5321', '5334', '5402', '5409', '5410', '5411', '5412',
		'5492', '5493', '5494', '5495', '5496', '5497', '5498', '5499', '5500', '5501', '5527', '5528', '5662',
		'6064', '6219', '7167', '7217', '7287', '7482', '7490', '7554', '7717', '7759', '7766', '11131', '11569', '11647',
		'11648', '12688', '12703', '12715', '12942', '12998', '13105', '14256', '14293', '14303', '15215', '15347', '15412', '15560', '16995',
		'17645', '18637', '19080', '19173', '20944', '21037', '21468', '21767', '22261', '22323', '22459', '24105', '24196', '24966',
		'26775', '30845', '32545', '35711', '35712', '35713', '35995', '36648', '37126', '37532', '37871', '47128',
		'47622', '47959', '52437', '52975', '53288', '54081', '54947', '55667', '55914', '57009', '58647', '59081',
		}) do
			registrants_t[v] = true;											-- build a k/v table of known free-to-read doi registrants
	end

	return registrants_t;
end

local extended_registrants_t = {												-- known free registrants identifiable by the doi suffix incipit
	['1002'] = {'aelm', 'leap'},												-- Advanced Electronic Materials, Learned Publishing
	['1016'] = {'j.heliyon', 'j.nlp', 'j.proche'},								-- Heliyon, Natural Language Processing, Procedia Chemistry
	['1017'] = {'nlp'},															-- Natural Language Processing Journal
	['1046'] = {'j.1365-8711', 'j.1365-246x'},									-- MNRAS, GJI
	['1093'] = {'mnras', 'mnrasl', 'gji', 'rasti'},								-- MNRAS, MNRAS Letters, GJI, RASTI
	['1099'] = {'acmi', 'mic', '00221287', 'mgen'},                             -- Access Microbiology, Microbiology, Journal of General Microbiology, Microbial Genomics
	['1111'] = {'j.1365-2966', 'j.1745-3933', 'j.1365-246X'},					-- MNRAS, MNRAS Letters, GJI
	['1210'] = {'jendso','jcemcr'},												-- Journal of the Endocrine Society, JCEM Case Reports
	['4171'] = {'dm','mag'},												    -- Documenta Mathematica, EMS Magazine
	['14231'] = {'ag'},															-- Algebraic Geometry
	}


--[[===================&lt;&lt; E R R O R   M E S S A G I N G &gt;&gt;======================
]]

--[[----------&lt; E R R O R   M E S S A G E   S U P P L I M E N T S &gt;-------------

I18N for those messages that are supplemented with additional specific text that
describes the reason for the error

TODO: merge this with special_case_translations{}?
]]

local err_msg_supl = {
	['char'] = 'invalid character',												-- |isbn=, |sbn=
	['check'] = 'checksum',														-- |isbn=, |sbn=
	['flag'] = 'flag',															-- |archive-url=
	['form'] = 'invalid form',													-- |isbn=, |sbn=
	['group'] = 'invalid group id',												-- |isbn=
	['initials'] = 'initials',													-- Vancouver
	['invalid language code'] = 'invalid language code',						-- |script-&lt;param&gt;=
	['journal'] = 'journal',													-- |bibcode=
	['length'] = 'length',														-- |isbn=, |bibcode=, |sbn=
	['liveweb'] = 'liveweb',													-- |archive-url=
	['missing comma'] = 'missing comma',										-- Vancouver
	['missing prefix'] = 'missing prefix',										-- |script-&lt;param&gt;=
	['missing title part'] = 'missing title part',								-- |script-&lt;param&gt;=
	['name'] = 'name',															-- Vancouver
	['non-Latin char'] = 'non-Latin character',									-- Vancouver
	['path'] = 'path',															-- |archive-url=
	['prefix'] = 'invalid prefix',												-- |isbn=
	['punctuation'] = 'punctuation',											-- Vancouver
	['save'] = 'save command',													-- |archive-url=
	['suffix'] = 'suffix',														-- Vancouver
	['timestamp'] = 'timestamp',												-- |archive-url=
	['unknown language code'] = 'unknown language code',						-- |script-&lt;param&gt;=
	['value'] = 'value',														-- |bibcode=
	['year'] = 'year',															-- |bibcode=
	}


--[[--------------&lt; E R R O R _ C O N D I T I O N S &gt;---------------------------

Error condition table.  This table has two sections: errors at the top, maintenance
at the bottom.  Maint 'messaging' does not have a 'message' (message=nil)

The following contains a list of IDs for various error conditions defined in the
code.  For each ID, we specify a text message to display, an error category to
include, and whether the error message should be wrapped as a hidden comment.

Anchor changes require identical changes to matching anchor in Help:CS1 errors

TODO: rename error_conditions{} to something more generic; create separate error
and maint tables inside that?

]]

local error_conditions = {
	err_accessdate_missing_url = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;access-date=&lt;/code&gt; requires &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;url=&lt;/code&gt;',
		anchor = 'accessdate_missing_url',
		category = 'CS1 errors: access-date without URL',
		hidden = false
 		},
	err_apostrophe_markup = {
		message = 'Italic or bold markup not allowed in: &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt;',	-- $1 is parameter name
		anchor = 'apostrophe_markup',
		category = 'CS1 errors: markup',
		hidden = false
 		},
	err_archive_date_missing_url = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;archive-date=&lt;/code&gt; requires &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;archive-url=&lt;/code&gt;',
		anchor = 'archive_date_missing_url',
		category = 'CS1 errors: archive-url',
		hidden = false
		},
	err_archive_date_url_ts_mismatch = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;archive-date=&lt;/code&gt; / &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;archive-url=&lt;/code&gt; timestamp mismatch; $1 suggested',
		anchor = 'archive_date_url_ts_mismatch',
		category = 'CS1 errors: archive-url',
		hidden = false
		},
	err_archive_missing_date = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;archive-url=&lt;/code&gt; requires &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;archive-date=&lt;/code&gt;',
		anchor = 'archive_missing_date',
		category = 'CS1 errors: archive-url',
		hidden = false
		},
	err_archive_missing_url = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;archive-url=&lt;/code&gt; requires &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;url=&lt;/code&gt;',
		anchor = 'archive_missing_url',
		category = 'CS1 errors: archive-url',
		hidden = false
		},
	err_archive_url = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;archive-url=&lt;/code&gt; is malformed: $1',	-- $1 is error message detail
		anchor = 'archive_url',
		category = 'CS1 errors: archive-url',
		hidden = false
		},
	err_arxiv_missing = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;arxiv=&lt;/code&gt; required',
		anchor = 'arxiv_missing',
		category = 'CS1 errors: arXiv',											-- same as bad arxiv
		hidden = false
		},
	err_asintld_missing_asin = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt; requires &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;asin=&lt;/code&gt;',	-- $1 is parameter name
		anchor = 'asintld_missing_asin',
		category = 'CS1 errors: ASIN TLD',
		hidden = false
		},
	err_bad_arxiv = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;arxiv=&lt;/code&gt; value',
		anchor = 'bad_arxiv',
		category = 'CS1 errors: arXiv',
		hidden = false
		},
	err_bad_asin = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;asin=&lt;/code&gt; value',
		anchor = 'bad_asin',
		category ='CS1 errors: ASIN',
		hidden = false
		},
	err_bad_asin_tld = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;asin-tld=&lt;/code&gt; value',
		anchor = 'bad_asin_tld',
		category ='CS1 errors: ASIN TLD',
		hidden = false
		},
	err_bad_bibcode = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;bibcode=&lt;/code&gt; $1',		-- $1 is error message detail
		anchor = 'bad_bibcode',
		category = 'CS1 errors: bibcode',
		hidden = false
		},
	err_bad_biorxiv = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;biorxiv=&lt;/code&gt; value',
		anchor = 'bad_biorxiv',
		category = 'CS1 errors: bioRxiv',
		hidden = false
		},
	err_bad_citeseerx = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;citeseerx=&lt;/code&gt; value',
		anchor = 'bad_citeseerx',
		category = 'CS1 errors: citeseerx',
		hidden = false
		},
	err_bad_date = {
		message = 'Check date values in: $1',									-- $1 is a parameter name list
		anchor = 'bad_date',
		category = 'CS1 errors: dates',
		hidden = false
		},
	err_bad_doi = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;doi=&lt;/code&gt; value',
		anchor = 'bad_doi',
		category = 'CS1 errors: DOI',
		hidden = false
		},
	err_bad_hdl = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;hdl=&lt;/code&gt; value',
		anchor = 'bad_hdl',
		category = 'CS1 errors: HDL',
		hidden = false
		},
	err_bad_isbn = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;isbn=&lt;/code&gt; value: $1',	-- $1 is error message detail
		anchor = 'bad_isbn',
		category = 'CS1 errors: ISBN',
		hidden = false
		},
	err_bad_ismn = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;ismn=&lt;/code&gt; value',
		anchor = 'bad_ismn',
		category = 'CS1 errors: ISMN',
		hidden = false
		},
	err_bad_issn = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1issn=&lt;/code&gt; value',	-- $1 is 'e' or '' for eissn or issn
		anchor = 'bad_issn',
		category = 'CS1 errors: ISSN',
		hidden = false
		},
	err_bad_jfm = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;jfm=&lt;/code&gt; value',
		anchor = 'bad_jfm',
		category = 'CS1 errors: JFM',
		hidden = false
		},
	err_bad_jstor = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;jstor=&lt;/code&gt; value',
		anchor = 'bad_jstor',
		category = 'CS1 errors: JSTOR',
		hidden = false
		},
	err_bad_lccn = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;lccn=&lt;/code&gt; value',
		anchor = 'bad_lccn',
		category = 'CS1 errors: LCCN',
		hidden = false
		},
	err_bad_medrxiv = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;medrxiv=&lt;/code&gt; value',
		anchor = 'bad_medrxiv',
		category = 'CS1 errors: medRxiv',
		hidden = false
		},
	err_bad_mr = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;mr=&lt;/code&gt; value',
		anchor = 'bad_mr',
		category = 'CS1 errors: MR',
		hidden = false
		},
	err_bad_oclc = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;oclc=&lt;/code&gt; value',
		anchor = 'bad_oclc',
		category = 'CS1 errors: OCLC',
		hidden = false
		},
	err_bad_ol = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;ol=&lt;/code&gt; value',
		anchor = 'bad_ol',
		category = 'CS1 errors: OL',
		hidden = false
		},
	err_bad_osti = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;osti=&lt;/code&gt; value',
		anchor = 'bad_osti',
		category = 'CS1 errors: OSTI',
		hidden = false
		},
	err_bad_paramlink = {														-- for |title-link=, |author/editor/translator-link=, |series-link=, |episode-link=
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt; value',		-- $1 is parameter name
		anchor = 'bad_paramlink',
		category = 'CS1 errors: parameter link',
		hidden = false
		},
	err_bad_pmc = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;pmc=&lt;/code&gt; value',
		anchor = 'bad_pmc',
		category = 'CS1 errors: PMC',
		hidden = false
		},
	err_bad_pmid = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;pmid=&lt;/code&gt; value',
		anchor = 'bad_pmid',
		category = 'CS1 errors: PMID',
		hidden = false
		},
	err_bad_rfc = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;rfc=&lt;/code&gt; value',
		anchor = 'bad_rfc',
		category = 'CS1 errors: RFC',
		hidden = false
		},
	err_bad_s2cid = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;s2cid=&lt;/code&gt; value',
		anchor = 'bad_s2cid',
		category = 'CS1 errors: S2CID',
		hidden = false
		},
	err_bad_sbn = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;sbn=&lt;/code&gt; value: $1',	-- $1 is error message detail
		anchor = 'bad_sbn',
		category = 'CS1 errors: SBN',
		hidden = false
		},
	err_bad_ssrn = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;ssrn=&lt;/code&gt; value',
		anchor = 'bad_ssrn',
		category = 'CS1 errors: SSRN',
		hidden = false
		},
	err_bad_url = {
		message = 'Check $1 value',												-- $1 is parameter name
		anchor = 'bad_url',
		category = 'CS1 errors: URL',
		hidden = false
		},
	err_bad_usenet_id = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;message-id=&lt;/code&gt; value',
		anchor = 'bad_message_id',
		category = 'CS1 errors: message-id',
		hidden = false
		},
	err_bad_zbl = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;zbl=&lt;/code&gt; value',
		anchor = 'bad_zbl',
		category = 'CS1 errors: Zbl',
		hidden = false
		},
	err_bare_url_missing_title = {
		message = '$1 missing title',											-- $1 is parameter name
		anchor = 'bare_url_missing_title',
		category = 'CS1 errors: bare URL',
		hidden = false
		},
	err_biorxiv_missing = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;biorxiv=&lt;/code&gt; required',
		anchor = 'biorxiv_missing',
		category = 'CS1 errors: bioRxiv',										-- same as bad bioRxiv
		hidden = false
		},
	err_chapter_ignored = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt; ignored',			-- $1 is parameter name
		anchor = 'chapter_ignored',
		category = 'CS1 errors: chapter ignored',
		hidden = false
		},
	err_citation_missing_title = {
		message = 'Missing or empty &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt;',	-- $1 is parameter name
		anchor = 'citation_missing_title',
		category = 'CS1 errors: missing title',
		hidden = false
		},
	err_citeseerx_missing = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;citeseerx=&lt;/code&gt; required',
		anchor = 'citeseerx_missing',
		category = 'CS1 errors: citeseerx',										-- same as bad citeseerx
		hidden = false
		},
	err_cite_web_url = {														-- this error applies to cite web and to cite podcast
		message = 'Missing or empty &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;url=&lt;/code&gt;',
		anchor = 'cite_web_url',
		category = 'CS1 errors: requires URL',
		hidden = false
		},
	err_class_ignored = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;class=&lt;/code&gt; ignored',
		anchor = 'class_ignored',
		category = 'CS1 errors: class',
		hidden = false
		},
	err_contributor_ignored = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;contributor=&lt;/code&gt; ignored',
		anchor = 'contributor_ignored',
		category = 'CS1 errors: contributor',
		hidden = false
		},
	err_contributor_missing_required_param = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;contributor=&lt;/code&gt; requires &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt;',	-- $1 is parameter name
		anchor = 'contributor_missing_required_param',
		category = 'CS1 errors: contributor',
		hidden = false
		},
	err_deprecated_params = {
		message = 'Cite uses deprecated parameter &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt;',	-- $1 is parameter name
		anchor = 'deprecated_params',
		category = 'CS1 errors: deprecated parameters',
		hidden = false
		},
	err_disp_name = {
		message = 'Invalid &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=$2&lt;/code&gt;',			-- $1 is parameter name; $2 is the assigned value
		anchor = 'disp_name',
		category = 'CS1 errors: display-names',
		hidden = false,
		},
	err_doibroken_missing_doi = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt; requires &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;doi=&lt;/code&gt;',	-- $1 is parameter name
		anchor = 'doibroken_missing_doi',
		category = 'CS1 errors: DOI',
		hidden = false
		},
	err_embargo_missing_pmc = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt; requires &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;pmc=&lt;/code&gt;',	-- $1 is parameter name
		anchor = 'embargo_missing_pmc',
		category = 'CS1 errors: PMC embargo',
		hidden = false
		},
	err_empty_citation = {
		message = 'Empty citation',
		anchor = 'empty_citation',
		category = 'CS1 errors: empty citation',
		hidden = false
		},
	err_etal = {
		message = 'Explicit use of et al. in: &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt;',	-- $1 is parameter name
		anchor = 'explicit_et_al',
		category = 'CS1 errors: explicit use of et al.',
		hidden = false
		},
	err_extra_text_edition = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;edition=&lt;/code&gt; has extra text',
		anchor = 'extra_text_edition',
		category = 'CS1 errors: extra text: edition',
		hidden = false,
		},
	err_extra_text_issue = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt; has extra text',		-- $1 is parameter name
		anchor = 'extra_text_issue',
		category = 'CS1 errors: extra text: issue',
		hidden = false,
		},
	err_extra_text_pages = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt; has extra text',		-- $1 is parameter name
		anchor = 'extra_text_pages',
		category = 'CS1 errors: extra text: pages',
		hidden = false,
		},
	err_extra_text_volume = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt; has extra text',		-- $1 is parameter name
		anchor = 'extra_text_volume',
		category = 'CS1 errors: extra text: volume',
		hidden = false,
		},
	err_first_missing_last = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt; missing &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$2=&lt;/code&gt;',	-- $1 is first alias, $2 is matching last alias
		anchor = 'first_missing_last',
		category = 'CS1 errors: missing name',									-- author, contributor, editor, interviewer, translator
		hidden = false
		},
	err_format_missing_url = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt; requires &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$2=&lt;/code&gt;',	-- $1 is format parameter $2 is url parameter
		anchor = 'format_missing_url',
		category = 'CS1 errors: format without URL',
		hidden = false
		},
	err_generic_name = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt; has generic name',	-- $1 is parameter name
		anchor = 'generic_name',
		category = 'CS1 errors: generic name',
		hidden = false,
		},
	err_generic_title = {
		message = 'Cite uses generic title',
		anchor = 'generic_title',
		category = 'CS1 errors: generic title',
		hidden = false,
		},
	err_invalid_isbn_date = {
		message = 'ISBN / Date incompatibility',
		anchor = 'invalid_isbn_date',
		category = 'CS1 errors: ISBN date',
		hidden = true
		},
	err_invalid_param_val = {
		message = 'Invalid &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=$2&lt;/code&gt;',			-- $1 is parameter name $2 is parameter value
		anchor = 'invalid_param_val',
		category = 'CS1 errors: invalid parameter value',
		hidden = false
		},
	err_invisible_char = {
		message = '$1 in $2 at position $3',									-- $1 is invisible char $2 is parameter name $3 is position number
		anchor = 'invisible_char',
		category = 'CS1 errors: invisible characters',
		hidden = false
		},
	err_medrxiv_missing = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;medrxiv=&lt;/code&gt; required',
		anchor = 'medrxiv_missing',
		category = 'CS1 errors: medRxiv',										-- same as bad medRxiv
		hidden = false
		},
	err_missing_name = {
		message = 'Missing &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1$2=&lt;/code&gt;',			-- $1 is modified NameList; $2 is enumerator
		anchor = 'missing_name',
		category = 'CS1 errors: missing name',									-- author, contributor, editor, interviewer, translator
		hidden = false
		},
	err_missing_periodical = {
		message = 'Cite $1 requires &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$2=&lt;/code&gt;',	-- $1 is cs1 template name; $2 is canonical periodical parameter name for cite $1
		anchor = 'missing_periodical',
		category = 'CS1 errors: missing periodical',
		hidden = false
		},
	err_missing_pipe = {
		message = 'Missing pipe in: &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt;',	-- $1 is parameter name
		anchor = 'missing_pipe',
		category = 'CS1 errors: missing pipe',
		hidden = false
		},
	err_missing_publisher = {
		message = 'Cite $1 requires &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$2=&lt;/code&gt;',	-- $1 is cs1 template name; $2 is canonical publisher parameter name for cite $1
		anchor = 'missing_publisher',
		category = 'CS1 errors: missing publisher',
		hidden = false
		},
	err_numeric_names = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt; has numeric name',	-- $1 is parameter name',
		anchor = 'numeric_names',
		category = 'CS1 errors: numeric name',
		hidden = false,
		},
	err_param_access_requires_param = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1-access=&lt;/code&gt; requires &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt;',	-- $1 is parameter name
		anchor = 'param_access_requires_param',
		category = 'CS1 errors: param-access',
		hidden = false
		},
	err_param_has_ext_link = {
		message = 'External link in &lt;code class=&quot;cs1-code&quot;&gt;$1&lt;/code&gt;',			-- $1 is parameter name
		anchor = 'param_has_ext_link',
		category = 'CS1 errors: external links',
		hidden = false
		},
	err_param_has_twl_url = {
		message = 'Wikipedia Library link in &lt;code class=&quot;cs1-code&quot;&gt;$1&lt;/code&gt;',	-- $1 is parameter name
		anchor = 'param_has_twl_url',
		category = 'CS1 errors: URL',
		hidden = false
		},
	err_parameter_ignored = {
		message = 'Unknown parameter &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt; ignored',	-- $1 is parameter name
		anchor = 'parameter_ignored',
		category = 'CS1 errors: unsupported parameter',
		hidden = false
		},
	err_parameter_ignored_suggest = {
		message = 'Unknown parameter &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt; ignored (&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$2=&lt;/code&gt; suggested)',	-- $1 is unknown parameter $2 is suggested parameter name
		anchor = 'parameter_ignored_suggest',
		category = 'CS1 errors: unsupported parameter',
		hidden = false
		},
	err_periodical_ignored = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt; ignored',			-- $1 is parameter name
		anchor = 'periodical_ignored',
		category = 'CS1 errors: periodical ignored',
		hidden = false
		},
	err_redundant_parameters = {
		message = 'More than one of $1 specified',								-- $1 is error message detail
		anchor = 'redundant_parameters',
		category = 'CS1 errors: redundant parameter',
		hidden = false
		},
	err_script_parameter = {
		message = 'Invalid &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt;: $2',		-- $1 is parameter name $2 is script language code or error detail
		anchor = 'script_parameter',
		category = 'CS1 errors: script parameters',
		hidden = false
		},
	err_ssrn_missing = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;ssrn=&lt;/code&gt; required',
		anchor = 'ssrn_missing',
		category = 'CS1 errors: SSRN',
		hidden = false
		},
	err_text_ignored = {
		message = 'Text &quot;$1&quot; ignored',											-- $1 is ignored text
		anchor = 'text_ignored',
		category = 'CS1 errors: unrecognized parameter',
		hidden = false
		},
	err_trans_missing_title = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;trans-$1=&lt;/code&gt; requires &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt; or &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;script-$1=&lt;/code&gt;',	-- $1 is base parameter name
		anchor = 'trans_missing_title',
		category = 'CS1 errors: translated title',
		hidden = false
		},
	err_param_unknown_empty = {
		message = 'Cite has empty unknown parameter$1: $2',						-- $1 is 's' or empty space; $2 is emty unknown param list
		anchor = 'param_unknown_empty',
		category = 'CS1 errors: empty unknown parameters',
		hidden = false
		},
	err_vancouver = {
		message = 'Vancouver style error: $1 in name $2',						-- $1 is error detail, $2 is the nth name
		anchor = 'vancouver',
		category = 'CS1 errors: Vancouver style',
		hidden = false
		},
	err_wikilink_in_url = {
		message = 'URL–wikilink conflict',										-- uses ndash
		anchor = 'wikilink_in_url',
		category = 'CS1 errors: URL–wikilink conflict',							-- uses ndash
		hidden = false
		},


--[[--------------------------&lt; M A I N T &gt;-------------------------------------

maint messages do not have a message (message = nil); otherwise the structure
is the same as error messages

]]

	maint_archived_copy = {
		message = nil,
		anchor = 'archived_copy',
		category = 'CS1 maint: archived copy as title',
		hidden = true,
		},
	maint_bibcode = {
		message = nil,
		anchor = 'bibcode',
		category = 'CS1 maint: bibcode',
		hidden = true,
		},
	maint_location_no_publisher = {												-- cite book, conference, encyclopedia; citation as book cite or encyclopedia cite
		message = nil,
		anchor = 'location_no_publisher',
		category = 'CS1 maint: location missing publisher',
		hidden = true,
		},
	maint_bot_unknown = {
		message = nil,
		anchor = 'bot:_unknown',
		category = 'CS1 maint: bot: original URL status unknown',
		hidden = true,
		},
	maint_date_auto_xlated = {													-- date auto-translation not supported by en.wiki
		message = nil,
		anchor = 'date_auto_xlated',
		category = 'CS1 maint: date auto-translated',
		hidden = true,
		},
	maint_date_format = {
		message = nil,
		anchor = 'date_format',
		category = 'CS1 maint: date format',
		hidden = true,
		},
	maint_date_year = {
		message = nil,
		anchor = 'date_year',
		category = 'CS1 maint: date and year',
		hidden = true,
		},
	maint_doi_ignore = {
		message = nil,
		anchor = 'doi_ignore',
		category = 'CS1 maint: ignored DOI errors',
		hidden = true,
		},
	maint_doi_inactive = {
		message = nil,
		anchor = 'doi_inactive',
		category = 'CS1 maint: DOI inactive',
		hidden = true,
		},
	maint_doi_inactive_dated = {
		message = nil,
		anchor = 'doi_inactive_dated',
		category = 'CS1 maint: DOI inactive as of $2$3$1',						-- $1 is year, $2 is month-name or empty string, $3 is space or empty string
		hidden = true,
		},
	maint_doi_unflagged_free = {
		message = nil,
		anchor = 'doi_unflagged_free',
		category = 'CS1 maint: unflagged free DOI',
		hidden = true,
		},
	maint_extra_punct = {
		message = nil,
		anchor = 'extra_punct',
		category = 'CS1 maint: extra punctuation',
		hidden = true,
		},
	maint_id_limit_load_fail = {												-- applies to all cs1|2 templates on a page; 
		message = nil,															-- maint message (category link) never emitted
		anchor = 'id_limit_load_fail',
		category = 'CS1 maint: ID limit load fail',
		hidden = true,
		},
	maint_isbn_ignore = {
		message = nil,
		anchor = 'ignore_isbn_err',
		category = 'CS1 maint: ignored ISBN errors',
		hidden = true,
		},
	maint_issn_ignore = {
		message = nil,
		anchor = 'ignore_issn',
		category = 'CS1 maint: ignored ISSN errors',
		hidden = true,
		},
	maint_jfm_format = {
		message = nil,
		anchor = 'jfm_format',
		category = 'CS1 maint: JFM format',
		hidden = true,
		},
	maint_location = {
		message = nil,
		anchor = 'location',
		category = 'CS1 maint: location',
		hidden = true,
		},
	maint_mr_format = {
		message = nil,
		anchor = 'mr_format',
		category = 'CS1 maint: MR format',
		hidden = true,
		},
	maint_mult_names = {
		message = nil,
		anchor = 'mult_names',
		category = 'CS1 maint: multiple names: $1',								-- $1 is '&lt;name&gt;s list'; gets value from special_case_translation table
		hidden = true,
		},
	maint_numeric_names = {
		message = nil,
		anchor = 'numeric_names',
		category = 'CS1 maint: numeric names: $1',								-- $1 is '&lt;name&gt;s list'; gets value from special_case_translation table
		hidden = true,
		},
	maint_others = {
		message = nil,
		anchor = 'others',
		category = 'CS1 maint: others',
		hidden = true,
		},
	maint_others_avm = {
		message = nil,
		anchor = 'others_avm',
		category = 'CS1 maint: others in cite AV media (notes)',
		hidden = true,
		},
	maint_overridden_setting = {
		message = nil,
		anchor = 'overridden',
		category = 'CS1 maint: overridden setting',
		hidden = true,
		},
	maint_pmc_embargo = {
		message = nil,
		anchor = 'embargo',
		category = 'CS1 maint: PMC embargo expired',
		hidden = true,
		},
	maint_pmc_format = {
		message = nil,
		anchor = 'pmc_format',
		category = 'CS1 maint: PMC format',
		hidden = true,
		},
	maint_postscript = {
		message = nil,
		anchor = 'postscript',
		category = 'CS1 maint: postscript',
		hidden = true,
	},
	maint_publisher_location = {
		message = nil,
		anchor = 'publisher_location',
		category = 'CS1 maint: publisher location',
		hidden = true,
	},
	maint_ref_duplicates_default = {
		message = nil,
		anchor = 'ref_default',
		category = 'CS1 maint: ref duplicates default',
		hidden = true,
	},
	maint_unknown_lang = {
		message = nil,
		anchor = 'unknown_lang',
		category = 'CS1 maint: unrecognized language',
		hidden = true,
		},
	maint_untitled = {
		message = nil,
		anchor = 'untitled',
		category = 'CS1 maint: untitled periodical',
		hidden = true,
		},
	maint_url_status = {
		message = nil,
		anchor = 'url_status',
		category = 'CS1 maint: url-status',
		hidden = true,
		},
	maint_year= {
		message = nil,
		anchor = 'year',
		category = 'CS1 maint: year',
		hidden = true,
		},
	maint_zbl = {
		message = nil,
		anchor = 'zbl',
		category = 'CS1 maint: Zbl',
		hidden = true,
		},
	}


--[[--------------------------&lt; I D _ L I M I T S _ D A T A _ T &gt;----------------------------------------------

fetch id limits for certain identifiers from c:Data:CS1/Identifier limits.tab.  This source is a json tabular 
data file maintained at wikipedia commons.  Convert the json format to a table of k/v pairs.

The values from &lt;id_limits_data_t&gt; are used to set handle.id_limit.

From 2025-02-21, MediaWiki is broken.  Use this link to edit the tablular data file:
	https://commons.wikimedia.org/w/index.php?title=Data:CS1/Identifier_limits.tab&amp;action=edit
See Phab:T389105

]]

local id_limits_data_t = {};

local use_commons_data = true;													-- set to false if your wiki does not have access to mediawiki commons; then,
if false == use_commons_data then												-- update this table from https://commons.wikimedia.org/wiki/Data:CS1/Identifier_limits.tab; last update: 2025-02-21
	id_limits_data_t = {['OCLC'] = 10450000000, ['OSTI'] = 23010000, ['PMC'] = 11900000, ['PMID'] = 40400000, ['RFC'] = 9300, ['SSRN'] = 5200000, ['S2CID'] = 276000000};	-- this table must be maintained locally

else																			-- here for wikis that do have access to mediawiki commons
	local load_fail_limit = 99999999999;										-- very high number to avoid error messages on load failure
	id_limits_data_t = {['OCLC'] = load_fail_limit, ['OSTI'] = load_fail_limit, ['PMC'] = load_fail_limit, ['PMID'] = load_fail_limit, ['RFC'] = load_fail_limit, ['SSRN'] = load_fail_limit, ['S2CID'] = load_fail_limit};

	local id_limits_data_load_fail = false;										-- flag; assume that we will be successful when loading json id limit tabular data
	
	local tab_data_t = mw.ext.data.get ('CS1/Identifier limits.tab').data;		-- attempt to load the json limit data from commons into &lt;tab_data_t&gt;
	if false == tab_data_t then													-- undocumented 'feature': mw.ext.data.get() sometimes returns false
		id_limits_data_load_fail = true;										-- set the flag so that Module:Citation/CS1 can create an unannotated maint category
	else
		for _, limit_t in ipairs (tab_data_t) do								-- overwrite default &lt;load_fail_limit&gt; values
			id_limits_data_t[limit_t[1]] = limit_t[2];							-- &lt;limit[1]&gt; is identifier; &lt;limit[2]&gt; is upper limit for that identifier
		end
	end
end


--[[--------------------------&lt; I D _ H A N D L E R S &gt;--------------------------------------------------------

The following contains a list of values for various defined identifiers.  For each
identifier we specify a variety of information necessary to properly render the
identifier in the citation.

	parameters: a list of parameter aliases for this identifier; first in the list is the canonical form
	link: Wikipedia article name
	redirect: a local redirect to a local Wikipedia article name;  at en.wiki, 'ISBN (identifier)' is a redirect to 'International Standard Book Number'
	q: Wikidata q number for the identifier
	label: the label preceding the identifier; label is linked to a Wikipedia article (in this order):
		redirect from id_handlers['&lt;id&gt;'].redirect when use_identifier_redirects is true
		Wikidata-supplied article name for the local wiki from id_handlers['&lt;id&gt;'].q
		local article name from id_handlers['&lt;id&gt;'].link
	prefix: the first part of a URL that will be concatenated with a second part which usually contains the identifier
	suffix: optional third part to be added after the identifier
	encode: true if URI should be percent-encoded; otherwise false
	COinS: identifier link or keyword for use in COinS:
		for identifiers registered at info-uri.info use: info:.... where '...' is the appropriate identifier label 
		for identifiers that have COinS keywords, use the keyword: rft.isbn, rft.issn, rft.eissn
		for |asin= and |ol=, which require assembly, use the keyword: url
		for others make a URL using the value in prefix/suffix and #label, use the keyword: pre (not checked; any text other than 'info', 'rft', or 'url' works here)
		set to nil to leave the identifier out of the COinS
	separator: character or text between label and the identifier in the rendered citation
	id_limit: for those identifiers with established limits, this property holds the upper limit
	access: use this parameter to set the access level for all instances of this identifier.
		the value must be a valid access level for an identifier (see ['id-access'] in this file).
	custom_access: to enable custom access level for an identifier, set this parameter
		to the parameter that should control it (normally 'id-access')
		
]]

local id_handlers = {
	['ARXIV'] = {
		parameters = {'arxiv', 'eprint'},
		link = 'arXiv',
		redirect = 'arXiv (identifier)',
		q = 'Q118398',
		label = 'arXiv',
		prefix = 'https://arxiv.org/abs/',
		encode = false,
		COinS = 'info:arxiv',
		separator = ':',
		access = 'free',														-- free to read
		},
	['ASIN'] = {
		parameters = { 'asin', 'ASIN' },
		link = 'Amazon Standard Identification Number',
		redirect = 'ASIN (identifier)',
		q = 'Q1753278',
		label = 'ASIN',
		prefix = 'https://www.amazon.',
		COinS = 'url',
		separator = '&amp;nbsp;',
		encode = false;
		},
	['BIBCODE'] = {
		parameters = {'bibcode'},
		link = 'Bibcode',
		redirect = 'Bibcode (identifier)',
		q = 'Q25754',
		label = 'Bibcode',
		prefix = 'https://ui.adsabs.harvard.edu/abs/',
		encode = false,
		COinS = 'info:bibcode',
		separator = ':',
		custom_access = 'bibcode-access',
		},
	['BIORXIV'] = {
		parameters = {'biorxiv'},
		link = 'bioRxiv',
		redirect = 'bioRxiv (identifier)',
		q = 'Q19835482',
		label = 'bioRxiv',
		prefix = 'https://doi.org/',
		COinS = 'pre',															-- use prefix value
		access = 'free',														-- free to read
		encode = true,
		separator = '&amp;nbsp;',
		},
	['CITESEERX'] = {
		parameters = {'citeseerx'},
		link = 'CiteSeerX',
		redirect = 'CiteSeerX (identifier)',
		q = 'Q2715061',
		label = 'CiteSeerX',
		prefix = 'https://citeseerx.ist.psu.edu/viewdoc/summary?doi=',
		COinS =  'pre',															-- use prefix value
		access = 'free',														-- free to read
		encode = true,
		separator = '&amp;nbsp;',
		},
	['DOI'] = {																	-- Used by InternetArchiveBot
		parameters = { 'doi', 'DOI'},
		link = 'Digital object identifier',
		redirect = 'doi (identifier)',
		q = 'Q25670',
		label = 'doi',
		prefix = 'https://doi.org/',
		COinS = 'info:doi',
		separator = ':',
		encode = true,
		custom_access = 'doi-access',
		},
	['EISSN'] = {
		parameters = {'eissn', 'EISSN'},
		link = 'International Standard Serial Number#Electronic ISSN',
		redirect = 'eISSN (identifier)',
		q = 'Q46339674',
		label = 'eISSN',
		prefix = 'https://search.worldcat.org/issn/',
		COinS = 'rft.eissn',
		encode = false,
		separator = '&amp;nbsp;',
		},
	['HDL'] = {
		parameters = { 'hdl', 'HDL' },
		link = 'Handle System',
		redirect = 'hdl (identifier)',
		q = 'Q3126718',
		label = 'hdl',
		prefix = 'https://hdl.handle.net/',
		COinS = 'info:hdl',
		separator = ':',
		encode = true,
		custom_access = 'hdl-access',
		},
	['ISBN'] = {																-- Used by InternetArchiveBot
		parameters = {'isbn', 'ISBN'},
		link = 'International Standard Book Number',
		redirect = 'ISBN (identifier)',
		q = 'Q33057',
		label = 'ISBN',
		prefix = 'Special:BookSources/',
		COinS = 'rft.isbn',
		separator = '&amp;nbsp;',
		},
	['ISMN'] = {
		parameters = {'ismn', 'ISMN'},
		link = 'International Standard Music Number',
		redirect = 'ISMN (identifier)',
		q = 'Q1666938',
		label = 'ISMN',
		prefix = '',															-- not currently used;
		COinS = nil,															-- nil because we can't use pre or rft or info:
		separator = '&amp;nbsp;',
		},
	['ISSN'] = {
		parameters = {'issn', 'ISSN'},
		link = 'International Standard Serial Number',
		redirect = 'ISSN (identifier)',
		q = 'Q131276',
		label = 'ISSN',
		prefix = 'https://search.worldcat.org/issn/',
		COinS = 'rft.issn',
		encode = false,
		separator = '&amp;nbsp;',
		},
	['JFM'] = {
		parameters = {'jfm', 'JFM'},
		link = 'Jahrbuch über die Fortschritte der Mathematik',
		redirect = 'JFM (identifier)',
		q = '',
		label = 'JFM',
		prefix = 'https://zbmath.org/?format=complete&amp;q=an:',
		COinS = 'pre',															-- use prefix value
		encode = true,
		separator = '&amp;nbsp;',
		},
	['JSTOR'] = {
		parameters = {'jstor', 'JSTOR'},
		link = 'JSTOR',
		redirect = 'JSTOR (identifier)',
		q = 'Q1420342',
		label = 'JSTOR',
		prefix = 'https://www.jstor.org/stable/',
		COinS = 'pre',															-- use prefix value
		encode = false,
		separator = '&amp;nbsp;',
		custom_access = 'jstor-access',
		},
	['LCCN'] = {
		parameters = {'lccn', 'LCCN'},
		link = 'Library of Congress Control Number',
		redirect = 'LCCN (identifier)',
		q = 'Q620946',
		label = 'LCCN',
		prefix = 'https://lccn.loc.gov/',
		COinS = 'info:lccn',
		encode = false,
		separator = '&amp;nbsp;',
		},
	['MEDRXIV'] = {
		parameters = {'medrxiv'},
		link = 'medRxiv',
		redirect = 'medRxiv (identifier)',
		q = 'Q58465838',
		label = 'medRxiv',
		prefix = 'https://www.medrxiv.org/content/',
		COinS = 'pre',															-- use prefix value
		access = 'free',														-- free to read
		encode = false,
		separator = '&amp;nbsp;',
		},
	['MR'] = {
		parameters = {'mr', 'MR'},
		link = 'Mathematical Reviews',
		redirect = 'MR (identifier)',
		q = 'Q211172',
		label = 'MR',
		prefix = 'https://mathscinet.ams.org/mathscinet-getitem?mr=',
		COinS = 'pre',															-- use prefix value
		encode = true,
		separator = '&amp;nbsp;',
		},
	['OCLC'] = {
		parameters = {'oclc', 'OCLC'},
		link = 'OCLC',
		redirect = 'OCLC (identifier)',
		q = 'Q190593',
		label = 'OCLC',
		prefix = 'https://search.worldcat.org/oclc/',
		COinS = 'info:oclcnum',
		encode = true,
		separator = '&amp;nbsp;',
		id_limit = id_limits_data_t.OCLC or 0,
		},
	['OL'] = {
		parameters = { 'ol', 'OL' },
		link = 'Open Library',
		redirect = 'OL (identifier)',
		q = 'Q1201876',
		label = 'OL',
		prefix = 'https://openlibrary.org/',
		COinS = 'url',
		separator = '&amp;nbsp;',
		encode = true,
		custom_access = 'ol-access',
		},
	['OSTI'] = {
		parameters = {'osti', 'OSTI'},
		link = 'Office of Scientific and Technical Information',
		redirect = 'OSTI (identifier)',
		q = 'Q2015776',
		label = 'OSTI',
		prefix = 'https://www.osti.gov/biblio/',
		COinS = 'pre',															-- use prefix value
		encode = true,
		separator = '&amp;nbsp;',
		id_limit = id_limits_data_t.OSTI or 0,
		custom_access = 'osti-access',
		},
	['PMC'] = {
		parameters = {'pmc', 'PMC'},
		link = 'PubMed Central',
		redirect = 'PMC (identifier)',
		q = 'Q229883',
		label = 'PMC',
		prefix = 'https://www.ncbi.nlm.nih.gov/pmc/articles/PMC',
		suffix = '',
		COinS = 'pre',															-- use prefix value
		encode = true,
		separator = '&amp;nbsp;',
		id_limit = id_limits_data_t.PMC or 0,
		access = 'free',														-- free to read
		},
	['PMID'] = {
		parameters = {'pmid', 'PMID'},
		link = 'PubMed Identifier',
		redirect = 'PMID (identifier)',
		q = 'Q2082879',
		label = 'PMID',
		prefix = 'https://pubmed.ncbi.nlm.nih.gov/',
		COinS = 'info:pmid',
		encode = false,
		separator = '&amp;nbsp;',
		id_limit = id_limits_data_t.PMID or 0,
		},
	['RFC'] = {
		parameters = {'rfc', 'RFC'},
		link = 'Request for Comments',
		redirect = 'RFC (identifier)',
		q = 'Q212971',
		label = 'RFC',
		prefix = 'https://tools.ietf.org/html/rfc',
		COinS = 'pre',															-- use prefix value
		encode = false,
		separator = '&amp;nbsp;',
		id_limit = id_limits_data_t.RFC or 0,
		access = 'free',														-- free to read
		},
	['SBN'] = {
		parameters = {'sbn', 'SBN'},
		link = 'Standard Book Number',											-- redirect to International_Standard_Book_Number#History
		redirect = 'SBN (identifier)',
		label = 'SBN',
		prefix = 'Special:BookSources/0-',										-- prefix has leading zero necessary to make 9-digit sbn a 10-digit isbn
		COinS = nil,															-- nil because we can't use pre or rft or info:
		separator = '&amp;nbsp;',
		},
	['SSRN'] = {
		parameters = {'ssrn', 'SSRN'},
		link = 'Social Science Research Network',
		redirect = 'SSRN (identifier)',
		q = 'Q7550801',
		label = 'SSRN',
		prefix = 'https://papers.ssrn.com/sol3/papers.cfm?abstract_id=',
		COinS = 'pre',															-- use prefix value
		encode = true,
		separator = '&amp;nbsp;',
		id_limit = id_limits_data_t.SSRN or 0,
		custom_access = 'ssrn-access',
		},
	['S2CID'] = {
		parameters = {'s2cid', 'S2CID'},
		link = 'Semantic Scholar',
		redirect = 'S2CID (identifier)',
		q = 'Q22908627',
		label = 'S2CID',
		prefix = 'https://api.semanticscholar.org/CorpusID:',
		COinS = 'pre',															-- use prefix value
		encode = false,
		separator = '&amp;nbsp;',
		id_limit = id_limits_data_t.S2CID or 0,
		custom_access = 's2cid-access',
		},
	['USENETID'] = {
		parameters = {'message-id'},
		link = 'Usenet',
		redirect = 'Usenet (identifier)',
		q = 'Q193162',
		label = 'Usenet:',
		prefix = 'news:',
		encode = false,
		COinS = 'pre',															-- use prefix value
		separator = '&amp;nbsp;',
		},
	['ZBL'] = {
		parameters = {'zbl', 'ZBL' },
		link = 'Zentralblatt MATH',
		redirect = 'Zbl (identifier)',
		q = 'Q190269',
		label = 'Zbl',
		prefix = 'https://zbmath.org/?format=complete&amp;q=an:',
		COinS = 'pre',															-- use prefix value
		encode = true,
		separator = '&amp;nbsp;',
		},
	}


--[[--------------------------&lt; E X P O R T S &gt;---------------------------------
]]

return 	{
	use_identifier_redirects = use_identifier_redirects,						-- booleans defined in the settings at the top of this module
	local_lang_cat_enable = local_lang_cat_enable,
	date_name_auto_xlate_enable = date_name_auto_xlate_enable,
	date_digit_auto_xlate_enable = date_digit_auto_xlate_enable,
	enable_sort_keys = enable_sort_keys,
	
																				-- tables and variables created when this module is loaded
	global_df = get_date_format (),												-- this line can be replaced with &quot;global_df = 'dmy-all',&quot; to have all dates auto translated to dmy format.
	global_cs1_config_t = global_cs1_config_t,									-- global settings from {{cs1 config}}
	punct_skip = build_skip_table (punct_skip, punct_meta_params),
	url_skip = build_skip_table (url_skip, url_meta_params),
	known_free_doi_registrants_t = build_free_doi_registrants_table(),
	id_limits_data_load_fail = id_limits_data_load_fail,						-- true when commons tabular identifier-limit data fails to load

	name_space_sort_keys = name_space_sort_keys,
	aliases = aliases,
	special_case_translation = special_case_translation,
	date_names = date_names,
	err_msg_supl = err_msg_supl,
	error_conditions = error_conditions,
	editor_markup_patterns = editor_markup_patterns,
	et_al_patterns = et_al_patterns,
	extended_registrants_t = extended_registrants_t,
	id_handlers = id_handlers,
	keywords_lists = keywords_lists,
	keywords_xlate = keywords_xlate,
	stripmarkers = stripmarkers,
	invisible_chars = invisible_chars,
	invisible_defs = invisible_defs,
	indic_script = indic_script,
	emoji_t = emoji_t,
	maint_cats = maint_cats,
	messages = messages,
	presentation = presentation,
	prop_cats = prop_cats,
	script_lang_codes = script_lang_codes,
	lang_tag_remap = lang_tag_remap,
	lang_name_remap = lang_name_remap,
	this_wiki_code = this_wiki_code,
	title_types = title_types,
	uncategorized_namespaces = uncategorized_namespaces_t,
	uncategorized_subpages = uncategorized_subpages,
	templates_using_volume = templates_using_volume,
	templates_using_issue = templates_using_issue,
	templates_not_using_page = templates_not_using_page,
	vol_iss_pg_patterns = vol_iss_pg_patterns,
	single_letter_2nd_lvl_domains_t = single_letter_2nd_lvl_domains_t,
	
	inter_wiki_map = inter_wiki_map,
	mw_languages_by_tag_t = mw_languages_by_tag_t,
	mw_languages_by_name_t = mw_languages_by_name_t,
	citation_class_map_t = citation_class_map_t,

	citation_issue_t = citation_issue_t,
	citation_no_volume_t = citation_no_volume_t,
	}</text>
      <sha1>1qtnsk18jlmk0vxedax9rhtzltma8m9</sha1>
    </revision>
    <revision>
      <id>5044</id>
      <parentid>3350</parentid>
      <timestamp>2025-08-07T07:56:23Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <origin>5044</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="116263" sha1="24xlbhz6iwhfof94vtfyrgvcpi4o7uc" xml:space="preserve">local lang_obj = mw.language.getContentLanguage();								-- make a language object for the local language; used here for languages and dates 


--[[--------------------------&lt; S E T T I N G S &gt;--------------------------------------------------------------

boolean settings used to control various things.  these setting located here to make them easy to find

]]
																				-- these settings local to this module only
local local_digits_from_mediawiki = false;										-- for i18n; when true, module fills date_names['local_digits'] from MediaWiki; manual fill required else; always false at en.wiki
local local_date_names_from_mediawiki = false;									-- for i18n; when true, module fills date_names['local']['long'] and date_names['local']['short'] from MediaWiki;
																				-- manual translation required else; ; always false at en.wiki

																				-- these settings exported to other modules
local use_identifier_redirects = true;											-- when true use redirect name for identifier label links; always true at en.wiki
local local_lang_cat_enable = false;											-- when true categorizes pages where |language=&lt;local wiki's language&gt;; always false at en.wiki
local date_name_auto_xlate_enable = false;										-- when true translates English month-names to the local-wiki's language month names; always false at en.wiki
local date_digit_auto_xlate_enable = false;										-- when true translates Western date digit to the local-wiki's language digits (date_names['local_digits']); always false at en.wiki
local enable_sort_keys = true;													-- when true module adds namespace sort keys to error and maintenance category links


--[[--------------------------&lt; U N C A T E G O R I Z E D _ N A M E S P A C E S &gt;------------------------------

List of namespaces identifiers for namespaces that will not be included in citation error categories.
Same as setting notracking = true by default.

For wikis that have a current version of Module:cs1 documentation support, this #invoke will return an unordered
list of namespace names and their associated identifiers:
	{{#invoke:cs1 documentation support|uncategorized_namespace_lister|all=&lt;anything&gt;}}

]]

local uncategorized_namespaces_t = {[2]=true};										-- init with user namespace id
for k, _ in pairs (mw.site.talkNamespaces) do									-- add all talk namespace ids
	uncategorized_namespaces_t[k] = true;
end

local uncategorized_subpages = {'/[Ss]andbox', '/[Tt]estcases', '/[^/]*[Ll]og', '/[Aa]rchive'};		-- list of Lua patterns found in page names of pages we should not categorize

--[[
at en.wiki Greek characters are used as sort keys for certain items in a category so that those items are
placed at the end of a category page.  See Wikipedia:Categorization#Sort_keys.  That works well for en.wiki
because English is written using the Latn script.  This may not work well for other languages.  At en.wiki it
is desireable to place content from certain namespaces at the end of a category listing so the module adds sort
keys to error and maintenance category links when rendering a cs1|2 template on a page in that namespace.

i18n: if this does not work well for your language, set &lt;enable_sort_keys&gt; to false.
]]

local name_space_sort_keys = {													-- sort keys to be used with these namespaces:
	[4] = 'ω',																	-- wikipedia; omega
	[10] = 'τ',																	-- template; tau
	[118] = 'Δ', 																-- draft; delta
	['other'] = 'ο',															-- all other non-talk namespaces except main (article); omicron
	}

--[[--------------------------&lt; M E S S A G E S &gt;--------------------------------------------------------------

Translation table

The following contains fixed text that may be output as part of a citation.
This is separated from the main body to aid in future translations of this
module.

]]

local messages = {
	['agency'] = '$1 $2',														-- $1 is sepc, $2 is agency
	['archived-dead'] = 'Ithethwe ku $1 ngomhlaka $2',
	['archived-live'] = '$1 from the original on $2',
	['archived-unfit'] = 'Archived from the original on ',
	['archived'] = 'Archived',
	['by'] = 'By',																-- contributions to authored works: introduction, foreword, afterword
	['cartography'] = 'Cartography by $1',
	['editor'] = 'ed.',
	['editors'] = 'eds.',
	['edition'] = '($1&amp;nbsp;ed.)',
	['episode'] = 'Episode $1',
	['et al'] = 'et&amp;nbsp;al.',
	['in'] = 'In',																-- edited works
	['inactive'] = 'inactive',
	['inset'] = '$1 inset',
	['interview'] = 'Interviewed by $1',										
	['mismatch'] = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt; / &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$2=&lt;/code&gt; mismatch',	-- $1 is year param name; $2 is date param name
	['newsgroup'] = '[[Usenet newsgroup|Newsgroup]]:&amp;nbsp;$1',
	['notitle'] = 'No title',													-- for |title=(()) and (in the future) |title=none
	['original'] = 'the original',
	['origdate'] = ' [$1]',
	['published'] = ' (published $1)',
	['retrieved'] = 'Retrieved $1',
	['season'] = 'Season $1',
	['section'] = '§&amp;nbsp;$1',
	['sections'] = '§§&amp;nbsp;$1',
	['series'] = '$1 $2',														-- $1 is sepc, $2 is series
	['seriesnum'] = 'Series $1',
	['translated'] = 'Translated by $1',
	['type'] = ' ($1)',															-- for titletype
	['written'] = 'Written at $1',

	['vol'] = '$1 Vol.&amp;nbsp;$2',												-- $1 is sepc; bold journal style volume is in presentation{}
	['vol-no'] = '$1 Vol.&amp;nbsp;$2, no.&amp;nbsp;$3',								-- sepc, volume, issue (alternatively insert $1 after $2, but then we'd also have to change capitalization)
	['issue'] = '$1 No.&amp;nbsp;$2',												-- $1 is sepc

	['art'] = '$1 Art.&amp;nbsp;$2',												-- $1 is sepc; for {{cite conference}} only
	['vol-art'] = '$1 Vol.&amp;nbsp;$2, art.&amp;nbsp;$3',								-- sepc, volume, article-number; for {{cite conference}} only

	['j-vol'] = '$1 $2',														-- sepc, volume; bold journal volume is in presentation{}
	['j-issue'] = ' ($1)',
	['j-article-num'] = ' $1',													-- TODO: any punctuation here? static text?

	['nopp'] = '$1 $2';															-- page(s) without prefix; $1 is sepc

	['p-prefix'] = &quot;$1 p.&amp;nbsp;$2&quot;,												-- $1 is sepc
	['pp-prefix'] = &quot;$1 pp.&amp;nbsp;$2&quot;,											-- $1 is sepc
	['j-page(s)'] = ': $1',														-- same for page and pages

	['sheet'] = '$1 Sheet&amp;nbsp;$2',												-- $1 is sepc
	['sheets'] = '$1 Sheets&amp;nbsp;$2',											-- $1 is sepc
	['j-sheet'] = ': Sheet&amp;nbsp;$1',
	['j-sheets'] = ': Sheets&amp;nbsp;$1',
	
	['language'] = '(in $1)',
	['via'] = &quot; &amp;ndash; via $1&quot;,
	['event'] = 'Event occurs at',
	['minutes'] = 'minutes in',
	
	-- Determines the location of the help page
	['help page link'] = 'Help:CS1 errors',
	['help page label'] = 'help',
	
	-- categories
	['cat wikilink'] = '[[Category:$1]]',										-- $1 is the category name
	['cat wikilink sk'] = '[[Category:$1|$2]]',									-- $1 is the category name; $2 is namespace sort key
	[':cat wikilink'] = '[[:Category:$1|link]]',								-- category name as maintenance message wikilink; $1 is the category name

	-- Internal errors (should only occur if configuration is bad)
	['undefined_error'] = 'Called with an undefined error condition',
	['unknown_ID_key'] = 'Unrecognized ID key: ',								-- an ID key in id_handlers not found in ~/Identifiers func_map{}
	['unknown_ID_access'] = 'Unrecognized ID access keyword: ',					-- an ID access keyword in id_handlers not found in keywords_lists['id-access']{}
	['unknown_argument_map'] = 'Argument map not defined for this variable',
	['bare_url_no_origin'] = 'Bare URL found but origin indicator is nil or empty',
	
	['warning_msg_e'] = '&lt;span style=&quot;color:#d33&quot;&gt;One or more &lt;code style=&quot;color: inherit; background: inherit; border: none; padding: inherit;&quot;&gt;&amp;#123;{$1}}&lt;/code&gt; templates have errors&lt;/span&gt;; messages may be hidden ([[Help:CS1_errors#Controlling_error_message_display|help]]).';	-- $1 is template link
	['warning_msg_m'] = '&lt;span style=&quot;color:#3a3&quot;&gt;One or more &lt;code style=&quot;color: inherit; background: inherit; border: none; padding: inherit;&quot;&gt;&amp;#123;{$1}}&lt;/code&gt; templates have maintenance messages&lt;/span&gt;; messages may be hidden ([[Help:CS1_errors#Controlling_error_message_display|help]]).';	-- $1 is template link
	}


--[[--------------------------&lt; C I T A T I O N _ C L A S S _ M A P &gt;------------------------------------------

this table maps the value assigned to |CitationClass= in the cs1|2 templates to the canonical template name when
the value assigned to |CitationClass= is different from the canonical template name.  |CitationClass= values are
used as class attributes in the &lt;cite&gt; tag that encloses the citation so these names may not contain spaces while
the canonical template name may.  These names are used in warning_msg_e and warning_msg_m to create links to the
template's documentation when an article is displayed in preview mode.

Most cs1|2 template |CitationClass= values at en.wiki match their canonical template names so are not listed here.

]]

	local citation_class_map_t = {												-- TODO: if kept, these and all other config.CitationClass 'names' require some sort of i18n
		['arxiv'] = 'arXiv',
		['audio-visual'] = 'AV media',
		['AV-media-notes'] = 'AV media notes',
		['biorxiv'] = 'bioRxiv',
		['citeseerx'] = 'CiteSeerX',
		['encyclopaedia'] = 'encyclopedia',
		['mailinglist'] = 'mailing list',
		['medrxiv'] = 'medRxiv',
		['pressrelease'] = 'press release',
		['ssrn'] = 'SSRN',
		['techreport'] = 'tech report',
		}


--[=[-------------------------&lt; E T _ A L _ P A T T E R N S &gt;--------------------------------------------------

This table provides Lua patterns for the phrase &quot;et al&quot; and variants in name text
(author, editor, etc.). The main module uses these to identify and emit the 'etal' message.

]=]

local et_al_patterns = {
	&quot;[;,]? *[\&quot;']*%f[%a][Ee][Tt]%.? *[Aa][Ll][%.;,\&quot;']*$&quot;,						-- variations on the 'et al' theme
	&quot;[;,]? *[\&quot;']*%f[%a][Ee][Tt]%.? *[Aa][Ll][Ii][AaIi][Ee]?[%.;,\&quot;']*$&quot;,		-- variations on the 'et alia', 'et alii' and 'et aliae' themes (false positive 'et aliie' unlikely to match)
	&quot;[;,]? *%f[%a]and [Oo]thers&quot;,												-- an alternative to et al.
	&quot;%[%[ *[Ee][Tt]%.? *[Aa][Ll]%.? *%]%]&quot;,										-- a wikilinked form
	&quot;%(%( *[Ee][Tt]%.? *[Aa][Ll]%.? *%)%)&quot;,										-- a double-bracketed form (to counter partial removal of ((...)) syntax)
	&quot;[%(%[] *[Ee][Tt]%.? *[Aa][Ll]%.? *[%)%]]&quot;,									-- a bracketed form
	}


--[[--------------------------&lt; P R E S E N T A T I O N &gt;------------------------

Fixed presentation markup.  Originally part of citation_config.messages it has
been moved into its own, more semantically correct place.

]]

local presentation = 
	{
	-- .citation-comment class is specified at Help:CS1_errors#Controlling_error_message_display
	['hidden-error'] = '&lt;span class=&quot;cs1-hidden-error citation-comment&quot;&gt;$1&lt;/span&gt;',
	['visible-error'] = '&lt;span class=&quot;cs1-visible-error citation-comment&quot;&gt;$1&lt;/span&gt;',
	['hidden-maint'] = '&lt;span class=&quot;cs1-maint citation-comment&quot;&gt;$1&lt;/span&gt;',
	
	['accessdate'] = '&lt;span class=&quot;reference-accessdate&quot;&gt;$1$2&lt;/span&gt;',			-- to allow editors to hide accessdate using personal CSS

	['bdi'] = '&lt;bdi$1&gt;$2&lt;/bdi&gt;',												-- bidirectional isolation used with |script-title= and the like

	['cite'] = '&lt;cite class=&quot;$1&quot;&gt;$2&lt;/cite&gt;';									-- for use when citation does not have a namelist and |ref= not set so no id=&quot;...&quot; attribute
	['cite-id'] = '&lt;cite id=&quot;$1&quot; class=&quot;$2&quot;&gt;$3&lt;/cite&gt;';							-- for use when when |ref= is set or when citation has a namelist

	['format'] = ' &lt;span class=&quot;cs1-format&quot;&gt;($1)&lt;/span&gt;',						-- for |format=, |chapter-format=, etc.
	['interwiki'] = ' &lt;span class=&quot;cs1-format&quot;&gt;[in $1]&lt;/span&gt;',					-- for interwiki-language-linked author, editor, etc
	['interproj'] = ' &lt;span class=&quot;cs1-format&quot;&gt;[at $1]&lt;/span&gt;',					-- for interwiki-project-linked author, editor, etc (:d: and :s: supported; :w: ignored)

	-- various access levels, for |access=, |doi-access=, |arxiv=, ...
	-- narrow no-break space &amp;#8239; may work better than nowrap CSS. Or not? Browser support?

	['ext-link-access-signal'] = '&lt;span class=&quot;$1&quot; title=&quot;$2&quot;&gt;$3&lt;/span&gt;',		-- external link with appropriate lock icon
		['free'] = {class='id-lock-free', title='Freely accessible'},			-- classes defined in Module:Citation/CS1/styles.css
		['registration'] = {class='id-lock-registration', title='Free registration required'},
		['limited'] = {class='id-lock-limited', title='Free access subject to limited trial, subscription normally required'},
		['subscription'] = {class='id-lock-subscription', title='Paid subscription required'},

	['interwiki-icon'] = '&lt;span class=&quot;$1&quot; title=&quot;$2&quot;&gt;$3&lt;/span&gt;',
		['class-wikisource'] = 'cs1-ws-icon',

	['italic-title'] = &quot;''$1''&quot;,

	['kern-left'] = '&lt;span class=&quot;cs1-kern-left&quot;&gt;&lt;/span&gt;$1',					-- spacing to use when title contains leading single or double quote mark
	['kern-right'] = '$1&lt;span class=&quot;cs1-kern-right&quot;&gt;&lt;/span&gt;',					-- spacing to use when title contains trailing single or double quote mark

	['nowrap1'] = '&lt;span class=&quot;nowrap&quot;&gt;$1&lt;/span&gt;',								-- for nowrapping an item: &lt;span ...&gt;yyyy-mm-dd&lt;/span&gt;
	['nowrap2'] = '&lt;span class=&quot;nowrap&quot;&gt;$1&lt;/span&gt; $2',							-- for nowrapping portions of an item: &lt;span ...&gt;dd mmmm&lt;/span&gt; yyyy (note white space)

	['ocins'] = '&lt;span title=&quot;$1&quot; class=&quot;Z3988&quot;&gt;&lt;/span&gt;',
	
	['parameter'] = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt;',
	
	['ps_cs1'] = '.';															-- CS1 style postscript (terminal) character
	['ps_cs2'] = '';															-- CS2 style postscript (terminal) character (empty string)

	['quoted-text'] = '&lt;q&gt;$1&lt;/q&gt;',												-- for wrapping |quote= content
	['quoted-title'] = '&quot;$1&quot;',

	['sep_cs1'] = '.',															-- CS1 element separator
	['sep_cs2'] = ',',															-- CS2 separator
	['sep_nl'] = ';',															-- CS1|2 style name-list separator between names is a semicolon
	['sep_nl_and'] = ' and ',													-- used as last nl sep when |name-list-style=and and list has 2 items
	['sep_nl_end'] = '; and ',													-- used as last nl sep when |name-list-style=and and list has 3+ names
	['sep_name'] = ', ',														-- CS1|2 style last/first separator is &lt;comma&gt;&lt;space&gt;
	['sep_nl_vanc'] = ',',														-- Vancouver style name-list separator between authors is a comma
	['sep_name_vanc'] = ' ',													-- Vancouver style last/first separator is a space

	['sep_list'] = ', ',														-- used for |language= when list has 3+ items except for last sep which uses sep_list_end
	['sep_list_pair'] = ' and ',												-- used for |language= when list has 2 items
	['sep_list_end'] = ', and ',												-- used as last list sep for |language= when list has 3+ items
	
	['trans-italic-title'] = &quot;&amp;#91;''$1''&amp;#93;&quot;,
	['trans-quoted-title'] = &quot;&amp;#91;$1&amp;#93;&quot;,									-- for |trans-title= and |trans-quote=
	['vol-bold'] = '$1 &lt;b&gt;$2&lt;/b&gt;',												-- sepc, volume; for bold journal cites; for other cites ['vol'] in messages{}
	}

	
--[[--------------------------&lt; A L I A S E S &gt;---------------------------------

Aliases table for commonly passed parameters.

Parameter names on the right side in the assignments in this table must have been
defined in the Whitelist before they will be recognized as valid parameter names

]]

local aliases = {
	['AccessDate'] = {'access-date', 'accessdate'},								-- Used by InternetArchiveBot
	['Agency'] = 'agency',
	['ArchiveDate'] = {'archive-date', 'archivedate'},							-- Used by InternetArchiveBot
	['ArchiveFormat'] = 'archive-format',
	['ArchiveURL'] = {'archive-url', 'archiveurl'},								-- Used by InternetArchiveBot
	['ArticleNumber'] = 'article-number',
	['ASINTLD'] = 'asin-tld',
	['At'] = 'at',																-- Used by InternetArchiveBot
	['Authors'] = {'people', 'credits'},
	['BookTitle'] = {'book-title', 'booktitle'},
	['Cartography'] = 'cartography',
	['Chapter'] = {'chapter', 'contribution', 'entry', 'article', 'section'},
	['ChapterFormat'] = {'chapter-format', 'contribution-format', 'entry-format',
		'article-format', 'section-format'};
	['ChapterURL'] = {'chapter-url', 'contribution-url', 'entry-url', 'article-url', 'section-url'},	-- Used by InternetArchiveBot
	['ChapterUrlAccess'] = {'chapter-url-access', 'contribution-url-access',
		'entry-url-access', 'article-url-access', 'section-url-access'},		-- Used by InternetArchiveBot
	['Class'] = 'class',														-- cite arxiv and arxiv identifier
	['Collaboration'] = 'collaboration',
	['Conference'] = {'conference', 'event'},
	['ConferenceFormat'] = 'conference-format',
	['ConferenceURL'] = 'conference-url',										-- Used by InternetArchiveBot
	['Date'] = {'date', 'air-date', 'airdate'},									-- air-date and airdate for cite episode and cite serial only
	['Degree'] = 'degree',
	['DF'] = 'df',
	['DisplayAuthors'] = {'display-authors', 'display-subjects'},
	['DisplayContributors'] = 'display-contributors',
	['DisplayEditors'] = 'display-editors',
	['DisplayInterviewers'] = 'display-interviewers',
	['DisplayTranslators'] = 'display-translators',
	['Docket'] = 'docket',
	['DoiBroken'] = 'doi-broken-date',
	['Edition'] = 'edition',
	['Embargo'] = 'pmc-embargo-date',
	['Encyclopedia'] = {'encyclopedia', 'encyclopaedia', 'dictionary'},			-- cite encyclopedia only
	['Episode'] = 'episode',													-- cite serial only TODO: make available to cite episode?
	['Format'] = 'format',
	['ID'] = {'id', 'ID'},
	['Inset'] = 'inset',
	['Issue'] = {'issue', 'number'},
	['Language'] = {'language', 'lang'},
	['MailingList'] = {'mailing-list', 'mailinglist'},							-- cite mailing list only
	['Map'] = 'map',															-- cite map only
	['MapFormat'] = 'map-format',												-- cite map only
	['MapURL'] = {'map-url', 'mapurl'},											-- cite map only -- Used by InternetArchiveBot
	['MapUrlAccess'] = 'map-url-access',										-- cite map only -- Used by InternetArchiveBot
	['Minutes'] = 'minutes',
	['Mode'] = 'mode',
	['NameListStyle'] = 'name-list-style',
	['Network'] = 'network',
	['Newsgroup'] = 'newsgroup',												-- cite newsgroup only
	['NoPP'] = {'no-pp', 'nopp'},
	['NoTracking'] = {'no-tracking', 'template-doc-demo'},
	['Number'] = 'number',														-- this case only for cite techreport
	['OrigDate'] = {'orig-date', 'orig-year', 'origyear'},
	['Others'] = 'others',
	['Page'] = {'page', 'p'},													-- Used by InternetArchiveBot
	['Pages'] = {'pages', 'pp'},												-- Used by InternetArchiveBot
	['Periodical'] = {'journal', 'magazine', 'newspaper', 'periodical', 'website', 'work'},
	['Place'] = {'place', 'location'},
	['PostScript'] = 'postscript',
	['PublicationDate'] = {'publication-date', 'publicationdate'},
	['PublicationPlace'] = {'publication-place', 'publicationplace'},
	['PublisherName'] = {'publisher', 'institution'},
	['Quote'] = {'quote', 'quotation'},
	['QuotePage'] = 'quote-page',
	['QuotePages'] = 'quote-pages',
	['Ref'] = 'ref',
	['Scale'] = 'scale',
	['ScriptChapter'] = {'script-chapter', 'script-contribution', 'script-entry',
		'script-article', 'script-section'},
	['ScriptEncyclopedia'] = {'script-encyclopedia', 'script-encyclopaedia'},	-- cite encyclopedia only
	['ScriptMap'] = 'script-map',
	['ScriptPeriodical'] = {'script-journal', 'script-magazine', 'script-newspaper',
		'script-periodical', 'script-website', 'script-work'},
	['ScriptQuote'] = 'script-quote',
	['ScriptTitle'] = 'script-title',											-- Used by InternetArchiveBot
	['Season'] = 'season',
	['Sections'] = 'sections',													-- cite map only
	['Series'] = {'series', 'version'},
	['SeriesLink'] = {'series-link', 'serieslink'},
	['SeriesNumber'] = {'series-number', 'series-no'},
	['Sheet'] = 'sheet',														-- cite map only
	['Sheets'] = 'sheets',														-- cite map only
	['Station'] = 'station',
	['Time'] = 'time',
	['TimeCaption'] = 'time-caption',
	['Title'] = 'title',														-- Used by InternetArchiveBot
	['TitleLink'] = {'title-link', 'episode-link', 'episodelink'},				-- Used by InternetArchiveBot
	['TitleNote'] = {'title-note', 'department'},
	['TitleType'] = {'type', 'medium'},
	['TransChapter'] = {'trans-article', 'trans-chapter', 'trans-contribution',
		'trans-entry', 'trans-section'},
	['Transcript'] = 'transcript',
	['TranscriptFormat'] = 'transcript-format',	
	['TranscriptURL'] = 'transcript-url',										-- Used by InternetArchiveBot
	['TransEncyclopedia'] = {'trans-encyclopedia', 'trans-encyclopaedia'},		-- cite encyclopedia only
	['TransMap'] = 'trans-map',													-- cite map only
	['TransPeriodical'] = {'trans-journal', 'trans-magazine', 'trans-newspaper',
		'trans-periodical', 'trans-website', 'trans-work'},
	['TransQuote'] = 'trans-quote',
	['TransTitle'] = 'trans-title',												-- Used by InternetArchiveBot
	['URL'] = {'url', 'URL'},													-- Used by InternetArchiveBot
	['UrlAccess'] = 'url-access',												-- Used by InternetArchiveBot
	['UrlStatus'] = 'url-status',												-- Used by InternetArchiveBot
	['Vauthors'] = 'vauthors',
	['Veditors'] = 'veditors',
	['Via'] = 'via',
	['Volume'] = 'volume',
	['Year'] = 'year',

	['AuthorList-First'] = {&quot;first#&quot;, &quot;author-first#&quot;, &quot;author#-first&quot;, &quot;author-given#&quot;, &quot;author#-given&quot;,
		&quot;subject-first#&quot;, &quot;subject#-first&quot;, &quot;subject-given#&quot;, &quot;subject#-given&quot;,
		&quot;given#&quot;},
	['AuthorList-Last'] = {&quot;last#&quot;, &quot;author-last#&quot;, &quot;author#-last&quot;, &quot;author-surname#&quot;, &quot;author#-surname&quot;,
		&quot;subject-last#&quot;, &quot;subject#-last&quot;, &quot;subject-surname#&quot;, &quot;subject#-surname&quot;,
		&quot;author#&quot;, 'host#', &quot;subject#&quot;, &quot;surname#&quot;},
	['AuthorList-Link'] = {&quot;author-link#&quot;, &quot;author#-link&quot;, &quot;subject-link#&quot;,
		&quot;subject#-link&quot;, &quot;authorlink#&quot;, &quot;author#link&quot;},
	['AuthorList-Mask'] = {&quot;author-mask#&quot;, &quot;author#-mask&quot;, &quot;subject-mask#&quot;, &quot;subject#-mask&quot;},

	['ContributorList-First'] = {'contributor-first#', 'contributor#-first',
		'contributor-given#', 'contributor#-given'},
	['ContributorList-Last'] = {'contributor-last#', 'contributor#-last',
		'contributor-surname#', 'contributor#-surname', 'contributor#'},
	['ContributorList-Link'] = {'contributor-link#', 'contributor#-link'},
	['ContributorList-Mask'] = {'contributor-mask#', 'contributor#-mask'},

	['EditorList-First'] = {&quot;editor-first#&quot;, &quot;editor#-first&quot;, &quot;editor-given#&quot;, &quot;editor#-given&quot;},
	['EditorList-Last'] = {&quot;editor-last#&quot;, &quot;editor#-last&quot;, &quot;editor-surname#&quot;,
		&quot;editor#-surname&quot;, &quot;editor#&quot;},
	['EditorList-Link'] = {&quot;editor-link#&quot;, &quot;editor#-link&quot;},
	['EditorList-Mask'] = {&quot;editor-mask#&quot;, &quot;editor#-mask&quot;},
	
	['InterviewerList-First'] = {'interviewer-first#', 'interviewer#-first',
		'interviewer-given#', 'interviewer#-given'},
	['InterviewerList-Last'] = {'interviewer-last#', 'interviewer#-last',
		'interviewer-surname#', 'interviewer#-surname', 'interviewer#'},
	['InterviewerList-Link'] = {'interviewer-link#', 'interviewer#-link'},
	['InterviewerList-Mask'] = {'interviewer-mask#', 'interviewer#-mask'},

	['TranslatorList-First'] = {'translator-first#', 'translator#-first',
		'translator-given#', 'translator#-given'},
	['TranslatorList-Last'] = {'translator-last#', 'translator#-last',
		'translator-surname#', 'translator#-surname', 'translator#'},
	['TranslatorList-Link'] = {'translator-link#', 'translator#-link'},
	['TranslatorList-Mask'] = {'translator-mask#', 'translator#-mask'},
	}


--[[--------------------------&lt; P U N C T _ S K I P &gt;---------------------------

builds a table of parameter names that the extraneous terminal punctuation check should not check.

]]

local punct_meta_params = {														-- table of aliases[] keys (meta parameters); each key has a table of parameter names for a value
	'BookTitle', 'Chapter', 'ScriptChapter', 'ScriptTitle', 'Title', 'TransChapter', 'Transcript', 'TransMap',	'TransTitle',	-- title-holding parameters
	'AuthorList-Mask', 'ContributorList-Mask', 'EditorList-Mask', 'InterviewerList-Mask', 'TranslatorList-Mask',	-- name-list mask may have name separators
	'PostScript', 'Quote', 'ScriptQuote', 'TransQuote', 'Ref',											-- miscellaneous
	'ArchiveURL', 'ChapterURL', 'ConferenceURL', 'MapURL', 'TranscriptURL', 'URL',						-- URL-holding parameters
	}

local url_meta_params = {														-- table of aliases[] keys (meta parameters); each key has a table of parameter names for a value
	'ArchiveURL', 'ChapterURL', 'ConferenceURL', 'ID', 'MapURL', 'TranscriptURL', 'URL',		-- parameters allowed to hold urls
	'Page', 'Pages', 'At', 'QuotePage', 'QuotePages',							-- insource locators allowed to hold urls
	}

local function build_skip_table (skip_t, meta_params)
	for _, meta_param in ipairs (meta_params) do								-- for each meta parameter key
		local params = aliases[meta_param];										-- get the parameter or the table of parameters associated with the meta parameter name
		if 'string' == type (params) then
			skip_t[params] = 1;													-- just a single parameter
		else
			for _, param in ipairs (params) do									-- get the parameter name
				skip_t[param] = 1;												-- add the parameter name to the skip table
				local count;
				param, count = param:gsub ('#', '');							-- remove enumerator marker from enumerated parameters
				if 0 ~= count then												-- if removed
					skip_t[param] = 1;											-- add param name without enumerator marker
				end
			end
		end
	end
	return skip_t;
end

local punct_skip = {};
local url_skip = {};


--[[--------------------------&lt; S I N G L E - L E T T E R   S E C O N D - L E V E L   D O M A I N S &gt;----------

this is a list of tlds that are known to have single-letter second-level domain names.  This list does not include
ccTLDs which are accepted in is_domain_name().

]]

local single_letter_2nd_lvl_domains_t = {'cash', 'company', 'foundation', 'media', 'org', 'today'};


--[[-----------&lt; S P E C I A L   C A S E   T R A N S L A T I O N S &gt;------------

This table is primarily here to support internationalization.  Translations in
this table are used, for example, when an error message, category name, etc.,
is extracted from the English alias key.  There may be other cases where
this translation table may be useful.

]]
local is_Latn = 'A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143\225\184\128-\225\187\191';
local special_case_translation = {
	['AuthorList'] = 'authors list',											-- used to assemble maintenance category names
	['ContributorList'] = 'contributors list',									-- translation of these names plus translation of the base maintenance category names in maint_cats{} table below
	['EditorList'] = 'editors list',											-- must match the names of the actual categories
	['InterviewerList'] = 'interviewers list',									-- this group or translations used by name_has_ed_markup() and name_has_mult_names()
	['TranslatorList'] = 'translators list',
	
																				-- Lua patterns to match pseudo-titles used by InternetArchiveBot and others as placeholder for unknown |title= value
	['archived_copy'] = {														-- used with CS1 maint: Archive[d] copy as title
		['en'] = '^archived?%s+copy$',											-- for English; translators: keep this because templates imported from en.wiki
		['local'] = nil,														-- translators: replace ['local'] = nil with lowercase translation only when bots or tools create generic titles in your language
		},

																				-- Lua patterns to match generic titles; usually created by bots or reference filling tools
																				-- translators: replace ['local'] = nil with lowercase translation only when bots or tools create generic titles in your language
		-- generic titles and patterns in this table should be lowercase only
		-- leave ['local'] nil except when there is a matching generic title in your language
		-- boolean 'true' for plain-text searches; 'false' for pattern searches

	['generic_titles'] = {
		['accept'] = {
			},
		['reject'] = {
			{['en'] = {'^wayback%s+machine$', false},				['local'] = nil},
			{['en'] = {'are you a robot', true},					['local'] = nil},
			{['en'] = {'hugedomains', true},						['local'] = nil},
			{['en'] = {'^[%(%[{&lt;]?no +title[&gt;}%]%)]?$', false},		['local'] = nil},
			{['en'] = {'page not found', true},						['local'] = nil},
			{['en'] = {'subscribe to read', true},					['local'] = nil},
			{['en'] = {'^[%(%[{&lt;]?unknown[&gt;}%]%)]?$', false},		['local'] = nil},
			{['en'] = {'website is for sale', true},				['local'] = nil},
			{['en'] = {'^404', false},								['local'] = nil},
			{['en'] = {'error[ %-]404', false},						['local'] = nil},
			{['en'] = {'internet archive wayback machine', true},	['local'] = nil},
			{['en'] = {'log into facebook', true},					['local'] = nil},
			{['en'] = {'login • instagram', true},					['local'] = nil},
			{['en'] = {'redirecting...', true},						['local'] = nil},
			{['en'] = {'usurped title', true},						['local'] = nil},	-- added by a GreenC bot
			{['en'] = {'webcite query result', true},				['local'] = nil},
			{['en'] = {'wikiwix\'s cache', true},					['local'] = nil},
			}
		},

		-- boolean 'true' for plain-text searches, search string must be lowercase only
		-- boolean 'false' for pattern searches
		-- leave ['local'] nil except when there is a matching generic name in your language

	['generic_names'] = {
		['accept'] = {
			{['en'] = {'%[%[[^|]*%(author%) *|[^%]]*%]%]', false},				['local'] = nil},
			},
		['reject'] = {
			{['en'] = {'about us', true},										['local'] = nil},
			{['en'] = {'%f[%a][Aa]dvisor%f[%A]', false},						['local'] = nil},
			{['en'] = {'allmusic', true},										['local'] = nil},
			{['en'] = {'%f[%a][Aa]uthor%f[%A]', false},							['local'] = nil},
			{['en'] = {'^[Bb]ureau$', false},									['local'] = nil},
			{['en'] = {'business', true},										['local'] = nil},
			{['en'] = {'cnn', true},											['local'] = nil},
			{['en'] = {'collaborator', true},									['local'] = nil},
			{['en'] = {'^[Cc]ompany$', false},									['local'] = nil},
			{['en'] = {'contributor', true},									['local'] = nil},
			{['en'] = {'contact us', true},										['local'] = nil},
			{['en'] = {'correspondent', true},									['local'] = nil},
			{['en'] = {'^[Dd]esk$', false},										['local'] = nil},
			{['en'] = {'directory', true},										['local'] = nil},
			{['en'] = {'%f[%(%[][%(%[]%s*eds?%.?%s*[%)%]]?$', false},			['local'] = nil},
			{['en'] = {'[,%.%s]%f[e]eds?%.?$', false},							['local'] = nil},
			{['en'] = {'^eds?[%.,;]', false},									['local'] = nil},
			{['en'] = {'^[%(%[]%s*[Ee][Dd][Ss]?%.?%s*[%)%]]', false},			['local'] = nil},
			{['en'] = {'%f[%a][Ee]dited%f[%A]', false},							['local'] = nil},
			{['en'] = {'%f[%a][Ee]ditors?%f[%A]', false},						['local'] = nil},
			{['en'] = {'%f[%a][Ee]mail%f[%A]', false},							['local'] = nil},
			{['en'] = {'facebook', true},										['local'] = nil},
			{['en'] = {'google', true},											['local'] = nil},
			{['en'] = {'^[Gg]roup$', false},									['local'] = nil},
			{['en'] = {'home page', true},										['local'] = nil},
			{['en'] = {'^[Ii]nc%.?$', false},									['local'] = nil},
			{['en'] = {'instagram', true},										['local'] = nil},
			{['en'] = {'interviewer', true},									['local'] = nil},
			{['en'] = {'^[Ll]imited$', false},									['local'] = nil},
			{['en'] = {'linkedIn', true},										['local'] = nil},
			{['en'] = {'^[Nn]ews$', false},										['local'] = nil},
			{['en'] = {'[Nn]ews[ %-]?[Rr]oom', false},							['local'] = nil},
			{['en'] = {'pinterest', true},										['local'] = nil},
			{['en'] = {'policy', true},											['local'] = nil},
			{['en'] = {'privacy', true},										['local'] = nil},
			{['en'] = {'reuters', true},										['local'] = nil},
			{['en'] = {'translator', true},										['local'] = nil},
			{['en'] = {'tumblr', true},											['local'] = nil},
			{['en'] = {'twitter', true},										['local'] = nil},
			{['en'] = {'site name', true},										['local'] = nil},
			{['en'] = {'statement', true},										['local'] = nil},
			{['en'] = {'submitted', true},										['local'] = nil},
			{['en'] = {'super.?user', false},									['local'] = nil},
			{['en'] = {'%f['..is_Latn..'][Uu]ser%f[^'..is_Latn..']', false},	['local'] = nil},
			{['en'] = {'verfasser', true},										['local'] = nil},
			}
	}
	}


--[[--------------------------&lt; D A T E _ N A M E S &gt;----------------------------------------------------------

This table of tables lists local language date names and fallback English date names.
The code in Date_validation will look first in the local table for valid date names.
If date names are not found in the local table, the code will look in the English table.

Because citations can be copied to the local wiki from en.wiki, the English is
required when the date-name translation function date_name_xlate() is used.

In these tables, season numbering is defined by
Extended Date/Time Format (EDTF) Specification (https://www.loc.gov/standards/datetime/)
which became part of ISO 8601 in 2019.  See '§Sub-year groupings'. The standard
defines various divisions using numbers 21-41. CS1|2 only supports generic seasons.
EDTF does support the distinction between north and south hemisphere seasons
but CS1|2 has no way to make that distinction.

33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)

The standard does not address 'named' dates so, for the purposes of CS1|2,
Easter and Christmas are defined here as 98 and 99, which should be out of the
ISO 8601 (EDTF) range of uses for a while.

local_date_names_from_mediawiki is a boolean.  When set to:
	true – module will fetch local month names from MediaWiki for both date_names['local']['long'] and date_names['local']['short']; this will unconditionally overwrite manual translations
	false – module will *not* fetch local month names from MediaWiki

Caveat lector:  There is no guarantee that MediaWiki will provide short month names.  At your wiki you can test
the results of the MediaWiki fetch in the debug console with this command (the result is alpha sorted):
	=mw.dumpObject (p.date_names['local'])

While the module can fetch month names from MediaWiki, it cannot fetch the quarter, season, and named date names
from MediaWiki.  Those must be translated manually.

]]

local local_date_names_from_mediawiki = true;									-- when false, manual translation required for date_names['local']['long'] and date_names['local']['short']; overwrites manual translations
																				-- when true, module fetches long and short month names from MediaWiki
local date_names = {
	['en'] = {																	-- English
		['long']	= {['January'] = 1, ['February'] = 2, ['March'] = 3, ['April'] = 4, ['May'] = 5, ['June'] = 6, ['July'] = 7, ['August'] = 8, ['September'] = 9, ['October'] = 10, ['November'] = 11, ['December'] = 12},
		['short']	= {['Jan'] = 1, ['Feb'] = 2, ['Mar'] = 3, ['Apr'] = 4, ['May'] = 5, ['Jun'] = 6, ['Jul'] = 7, ['Aug'] = 8, ['Sep'] = 9, ['Oct'] = 10, ['Nov'] = 11, ['Dec'] = 12},
		['quarter'] = {['First Quarter'] = 33, ['Second Quarter'] = 34, ['Third Quarter'] = 35, ['Fourth Quarter'] = 36},
		['season']	= {['Winter'] = 24, ['Spring'] = 21, ['Summer'] = 22, ['Fall'] = 23, ['Autumn'] = 23},
		['named']	= {['Easter'] = 98, ['Christmas'] = 99},
		},
																				-- when local_date_names_from_mediawiki = false
	['local'] = {																-- replace these English date names with the local language equivalents
		['long']	= {['January'] = 1, ['February'] = 2, ['March'] = 3, ['April'] = 4, ['May'] = 5, ['June'] = 6, ['July'] = 7, ['August'] = 8, ['September'] = 9, ['October'] = 10, ['November'] = 11, ['December'] = 12},
		['short']	= {['Jan'] = 1, ['Feb'] = 2, ['Mar'] = 3, ['Apr'] = 4, ['May'] = 5, ['Jun'] = 6, ['Jul'] = 7, ['Aug'] = 8, ['Sep'] = 9, ['Oct'] = 10, ['Nov'] = 11, ['Dec'] = 12},
		['quarter'] = {['First Quarter'] = 33, ['Second Quarter'] = 34, ['Third Quarter'] = 35, ['Fourth Quarter'] = 36},
		['season']	= {['Winter'] = 24, ['Spring'] = 21, ['Summer'] = 22, ['Fall'] = 23, ['Autumn'] = 23},
		['named']	= {['Easter'] = 98, ['Christmas'] = 99},
		},
	['inv_local_long'] = {},													-- used in date reformatting &amp; translation; copy of date_names['local'].long where k/v are inverted: [1]='&lt;local name&gt;' etc.
	['inv_local_short'] = {},													-- used in date reformatting &amp; translation; copy of date_names['local'].short where k/v are inverted: [1]='&lt;local name&gt;' etc.
	['inv_local_quarter'] = {},													-- used in date translation; copy of date_names['local'].quarter where k/v are inverted: [1]='&lt;local name&gt;' etc.
	['inv_local_season'] = {},													-- used in date translation; copy of date_names['local'].season where k/v are inverted: [1]='&lt;local name&gt;' etc.
	['inv_local_named'] = {},													-- used in date translation; copy of date_names['local'].named where k/v are inverted: [1]='&lt;local name&gt;' etc.
	['local_digits'] = {['0'] = '0', ['1'] = '1', ['2'] = '2', ['3'] = '3', ['4'] = '4', ['5'] = '5', ['6'] = '6', ['7'] = '7', ['8'] = '8', ['9'] = '9'},	-- used to convert local language digits to Western 0-9
	['xlate_digits'] = {},
	}

if local_date_names_from_mediawiki then											-- if fetching local month names from MediaWiki is enabled
	local long_t = {};
	local short_t = {};
	for i=1, 12 do																-- loop 12x and 
		local name = lang_obj:formatDate('F', '2022-' .. i .. '-1');			-- get long month name for each i
		long_t[name] = i;														-- save it
		name = lang_obj:formatDate('M', '2022-' .. i .. '-1');					-- get short month name for each i
		short_t[name] = i;														-- save it
	end
	date_names['local']['long'] = long_t;										-- write the long table – overwrites manual translation
	date_names['local']['short'] = short_t;										-- write the short table – overwrites manual translation
end
																				-- create inverted date-name tables for reformatting and/or translation
for _, invert_t in pairs {{'long', 'inv_local_long'}, {'short', 'inv_local_short'}, {'quarter', 'inv_local_quarter'}, {'season', 'inv_local_season'}, {'named', 'inv_local_named'}} do
	for name, i in pairs (date_names['local'][invert_t[1]]) do					-- this table is ['name'] = i
		date_names[invert_t[2]][i] = name;										-- invert to get [i] = 'name' for conversions from ymd
	end
end

if local_digits_from_mediawiki then												-- if fetching local digits from MediaWiki is enabled
	local digits_t = {};
	for i=0, 9 do																-- loop 10x and 
		digits_t [lang_obj:formatNum (i)] = tostring (i);						-- format the loop indexer as local lang table index and assign loop indexer (a string) as the value
	end
	date_names['local_digits'] = digits_t;
end

for ld, ed in pairs (date_names.local_digits) do								-- make a digit translation table for simple date translation from en to local language using local_digits table
	date_names.xlate_digits [ed] = ld;											-- en digit becomes index with local digit as the value
end

local df_template_patterns = {													-- table of redirects to {{Use dmy dates}} and {{Use mdy dates}}
	'{{ *[Uu]se +(dmy) +dates *[|}]',	-- 1159k								-- sorted by approximate transclusion count
	'{{ *[Uu]se +(mdy) +dates *[|}]',	-- 212k
	'{{ *[Uu]se +(MDY) +dates *[|}]',	-- 788
	'{{ *[Uu]se +(DMY) +dates *[|}]',	-- 343
	'{{ *([Mm]dy) *[|}]',				-- 176
	'{{ *[Uu]se *(dmy) *[|}]',			-- 156 + 18
	'{{ *[Uu]se *(mdy) *[|}]',			-- 149 + 11
	'{{ *([Dd]my) *[|}]',				-- 56
	'{{ *[Uu]se +(MDY) *[|}]',			-- 5
	'{{ *([Dd]MY) *[|}]',				-- 3
	'{{ *[Uu]se(mdy)dates *[|}]',		-- 1
	'{{ *[Uu]se +(DMY) *[|}]',			-- 0
	'{{ *([Mm]DY) *[|}]',				-- 0
	}

local title_object = mw.title.getCurrentTitle();
local content;																	-- done this way  so that unused templates appear in unused-template-reports; self-transcluded makes them look like they are used
if 10 ~= title_object.namespace then											-- all namespaces except Template
	content = title_object:getContent() or '';									-- get the content of the article or ''; new pages edited w/ve do not have 'content' until saved; ve does not preview; phab:T221625
end

local function get_date_format ()
	if not content then															-- nil content when we're in template
		return nil;																-- auto-formatting does not work in Template space so don't set global_df
	end
	for _, pattern in ipairs (df_template_patterns) do							-- loop through the patterns looking for {{Use dmy dates}} or {{Use mdy dates}} or any of their redirects
		local start, _, match = content:find(pattern);							-- match is the three letters indicating desired date format
		if match then
			local use_dates_template = content:match ('%b{}', start);			-- get the whole template
			if use_dates_template:match ('| *cs1%-dates *= *[lsy][sy]?') then	-- look for |cs1-dates=publication date length access-/archive-date length
				return match:lower() .. '-' .. use_dates_template:match ('| *cs1%-dates *= *([lsy][sy]?)');
			else
				return match:lower() .. '-all';									-- no |cs1-dates= k/v pair; return value appropriate for use in |df=
			end
		end
	end
end

local global_df;																-- TODO: add this to &lt;global_cs1_config_t&gt;?


--[[-----------------&lt; V O L U M E ,  I S S U E ,  P A G E S &gt;------------------

These tables hold cite class values (from the template invocation) and identify those templates that support
|volume=, |issue=, and |page(s)= parameters.  Cite conference and cite map require further qualification which
is handled in the main module.

]]

local templates_using_volume = {'citation', 'audio-visual', 'book', 'conference', 'encyclopaedia', 'interview', 'journal', 'magazine', 'map', 'news', 'report', 'techreport', 'thesis'}
local templates_using_issue = {'citation', 'conference', 'episode', 'interview', 'journal', 'magazine', 'map', 'news', 'podcast'}
local templates_not_using_page = {'audio-visual', 'episode', 'mailinglist', 'newsgroup', 'podcast', 'serial', 'sign', 'speech'}

--[[

These tables control when it is appropriate for {{citation}} to render |volume= and/or |issue=.  The parameter
names in the tables constrain {{citation}} so that its renderings match the renderings of the equivalent cs1
templates.  For example, {{cite web}} does not support |volume= so the equivalent {{citation |website=...}} must
not support |volume=.

]]

local citation_no_volume_t = {													-- {{citation}} does not render |volume= when these parameters are used
	'website', 'mailinglist', 'script-website',
	}
local citation_issue_t = {														-- {{citation}} may render |issue= when these parameters are used
	'journal', 'magazine', 'newspaper', 'periodical', 'work',
	'script-journal', 'script-magazine', 'script-newspaper', 'script-periodical', 'script-work',
	}

--[[

Patterns for finding extra text in |volume=, |issue=, |page=, |pages=

]]

local vol_iss_pg_patterns = {
	good_ppattern = '^P[^%.PpGg]',												-- OK to begin with uppercase P: P7 (page 7 of section P), but not p123 (page 123); TODO: this allows 'Pages' which it should not
	bad_ppatterns = {															-- patterns for |page= and |pages=
		'^[Pp][PpGg]?%.?[ %d]',
		'^[Pp][Pp]?%.&amp;nbsp;',													-- from {{p.}} and {{pp.}} templates
		'^[Pp]ages?',
		'^[Pp]gs.?',
		},
	vi_patterns_t = {															-- combined to catch volume-like text in |issue= and issue-like text in |volume=
		'^volumes?',															-- volume-like text
		'^vols?[%.:=]?',

		'^issues?',																--issue-like text
		'^iss[%.:=]?',
		'^numbers?',
		'^nos?%A',																-- don't match 'november' or 'nostradamus'
		'^nr[%.:=]?',
		'^n[%.:= ]',															-- might be a valid issue without separator (space char is sep char here)
		'^n°',																	-- 'n' with degree sign (U+00B0)
		'^№',																	-- precomposed unicode numero character (U+2116)
		},
	}

--[[--------------------------&lt; K E Y W O R D S &gt;-------------------------------

These tables hold keywords for those parameters that have defined sets of acceptable keywords.

]]

--[[-------------------&lt; K E Y W O R D S   T A B L E &gt;--------------------------

this is a list of keywords; each key in the list is associated with a table of
synonymous keywords possibly from different languages.

for I18N: add local-language keywords to value table; do not change the key.
For example, adding the German keyword 'ja':
	['affirmative'] = {'yes', 'true', 'y', 'ja'},

Because CS1|2 templates from en.wiki articles are often copied to other local wikis,
it is recommended that the English keywords remain in these tables.

]]

local keywords = {
	['amp'] = {'&amp;', 'amp', 'ampersand'}, 										-- |name-list-style=
	['and'] = {'and', 'serial'},												-- |name-list-style=
	['affirmative'] = {'yes', 'true', 'y'},										-- |no-tracking=, |no-pp= -- Used by InternetArchiveBot
	['afterword'] = {'afterword'},												-- |contribution=
	['bot: unknown'] = {'bot: unknown'},										-- |url-status= -- Used by InternetArchiveBot
	['cs1'] = {'cs1'},															-- |mode=
	['cs2'] = {'cs2'},															-- |mode=
	['dead'] = {'dead', 'deviated'},											-- |url-status= -- Used by InternetArchiveBot
	['dmy'] = {'dmy'},															-- |df=
	['dmy-all'] = {'dmy-all'},													-- |df=
	['foreword'] = {'foreword'},												-- |contribution=
	['free'] = {'free'},														-- |&lt;id&gt;-access= -- Used by InternetArchiveBot
	['harv'] = {'harv'},														-- |ref=; this no longer supported; is_valid_parameter_value() called with &lt;invert&gt; = true
	['introduction'] = {'introduction'},										-- |contribution=
	['limited'] = {'limited'},													-- |url-access= -- Used by InternetArchiveBot
	['live'] = {'live'},														-- |url-status= -- Used by InternetArchiveBot
	['mdy'] = {'mdy'},															-- |df=
	['mdy-all'] = {'mdy-all'},													-- |df=
	['none'] = {'none'},														-- |postscript=, |ref=, |title=, |type= -- Used by InternetArchiveBot
	['off'] = {'off'},															-- |title= (potentially also: |title-link=, |postscript=, |ref=, |type=)
	['preface'] = {'preface'},													-- |contribution=
	['registration'] = {'registration'},										-- |url-access= -- Used by InternetArchiveBot
	['subscription'] = {'subscription'},										-- |url-access= -- Used by InternetArchiveBot
	['unfit'] = {'unfit'},														-- |url-status= -- Used by InternetArchiveBot
	['usurped'] = {'usurped'},													-- |url-status= -- Used by InternetArchiveBot
	['vanc'] = {'vanc'},														-- |name-list-style=
	['ymd'] = {'ymd'},															-- |df=
	['ymd-all'] = {'ymd-all'},													-- |df=
	--	['yMd'] = {'yMd'},														-- |df=; not supported at en.wiki
	--	['yMd-all'] = {'yMd-all'},												-- |df=; not supported at en.wiki
	}


--[[------------------------&lt; X L A T E _ K E Y W O R D S &gt;---------------------

this function builds a list, keywords_xlate{}, of the keywords found in keywords{} where the values from keywords{}
become the keys in keywords_xlate{} and the keys from keywords{} become the values in keywords_xlate{}:
	['affirmative'] = {'yes', 'true', 'y'},		-- in keywords{}
becomes
	['yes'] = 'affirmative',					-- in keywords_xlate{}
	['true'] = 'affirmative',
	['y'] = 'affirmative',

the purpose of this function is to act as a translator between a non-English keyword and its English equivalent
that may be used in other modules of this suite

]]

local function xlate_keywords ()
	local out_table = {};														-- output goes here
	for k, keywords_t in pairs (keywords) do									-- spin through the keywords table
		for _, keyword in ipairs (keywords_t) do								-- for each keyword
			out_table[keyword] = k;												-- create an entry in the output table where keyword is the key
		end
	end
	
	return out_table;
end

local keywords_xlate = xlate_keywords ();										-- the list of translated keywords


--[[----------------&lt; M A K E _ K E Y W O R D S _ L I S T &gt;---------------------

this function assembles, for parameter-value validation, the list of keywords appropriate to that parameter.

keywords_lists{}, is a table of tables from keywords{}

]]

local function make_keywords_list (keywords_lists)
	local out_table = {};														-- output goes here
	
	for _, keyword_list in ipairs (keywords_lists) do							-- spin through keywords_lists{} and get a table of keywords
		for _, keyword in ipairs (keyword_list) do								-- spin through keyword_list{} and add each keyword, ...
			table.insert (out_table, keyword);									-- ... as plain text, to the output list
		end
	end
	return out_table;
end


--[[----------------&lt; K E Y W O R D S _ L I S T S &gt;-----------------------------

this is a list of lists of valid keywords for the various parameters in [key].
Generally the keys in this table are the canonical en.wiki parameter names though
some are contrived because of use in multiple differently named parameters:
['yes_true_y'], ['id-access'].

The function make_keywords_list() extracts the individual keywords from the
appropriate list in keywords{}.

The lists in this table are used to validate the keyword assignment for the
parameters named in this table's keys.

]]

local keywords_lists = {
	['yes_true_y'] = make_keywords_list ({keywords.affirmative}),
	['contribution'] = make_keywords_list ({keywords.afterword, keywords.foreword, keywords.introduction, keywords.preface}),
	['df'] = make_keywords_list ({keywords.dmy, keywords['dmy-all'], keywords.mdy, keywords['mdy-all'], keywords.ymd, keywords['ymd-all']}),
	--	['df'] = make_keywords_list ({keywords.dmy, keywords['dmy-all'], keywords.mdy, keywords['mdy-all'], keywords.ymd, keywords['ymd-all'], keywords.yMd, keywords['yMd-all']}),	-- not supported at en.wiki
	['mode'] = make_keywords_list ({keywords.cs1, keywords.cs2}),
	['name-list-style'] = make_keywords_list ({keywords.amp, keywords['and'], keywords.vanc}),
	['ref'] = make_keywords_list ({keywords.harv}),								-- inverted check; |ref=harv no longer supported
	['url-access'] = make_keywords_list ({keywords.subscription, keywords.limited, keywords.registration}),
	['url-status'] = make_keywords_list ({keywords.dead, keywords.live, keywords.unfit, keywords.usurped, keywords['bot: unknown']}),
	['id-access'] = make_keywords_list ({keywords.free}),
	}


--[[--------------------------&lt; C S 1 _ C O N F I G _ G E T &gt;--------------------------------------------------

fetch and validate values from {{cs1 config}} template to fill &lt;global_cs1_config_t&gt;

no error messages; when errors are detected, the parameter value from {{cs1 config}} is blanked.

Supports all parameters and aliases associated with the metaparameters: DisplayAuthors, DisplayContributors,
DisplayEditors, DisplayInterviewers, DisplayTranslators, NameListStyle, and Mode.  The DisplayWhatever metaparameters
accept numeric values only (|display-authors=etal and the like is not supported).

]]

local global_cs1_config_t = {};													-- TODO: add value returned from get_date_format() to this table?

local function get_cs1_config ()
	if not content then															-- nil content when we're in template
		return nil;																-- auto-formatting does not work in Template space so don't set global_df
	end

	local start = content:find('{{ *[Cc][Ss]1 config *[|}]');					-- &lt;start&gt; is offset into &lt;content&gt; when {{cs1 config}} found; nil else
	if start then
		local cs1_config_template = content:match ('%b{}', start);				-- get the whole template

		if not cs1_config_template then
			return nil;
		end

		local params_t = mw.text.split (cs1_config_template:gsub ('^{{%s*', ''):gsub ('%s*}}$', ''), '%s*|%s*');	-- remove '{{' and '}}'; make a sequence of parameter/value pairs (split on the pipe)
		table.remove (params_t, 1);												-- remove the template name because it isn't a parameter/value pair

		local config_meta_params_t = {'DisplayAuthors', 'DisplayContributors', 'DisplayEditors', 'DisplayInterviewers', 'DisplayTranslators', 'NameListStyle', 'Mode'};
		local meta_param_map_t = {};											-- list of accepted parameter names usable in {{cs1 config}} goes here
		
		for _, meta_param in ipairs (config_meta_params_t) do					-- for i18n using &lt;config_meta_params_t&gt;, map template parameter names to their metaparameter equivalents
			if 'table' == type (aliases[meta_param]) then						-- if &lt;meta_param&gt; is a sequence, 
				for _, param in ipairs (aliases[meta_param]) do					-- extract its contents
					meta_param_map_t[param] = meta_param;						-- and add to &lt;meta_param_map_t&gt;
				end
			else
				meta_param_map_t[aliases[meta_param]] = meta_param;				-- not a sequence so just add the parameter to &lt;meta_param_map_t&gt;
			end
		end

		local keywords_t = {};													-- map valid keywords to their associate metaparameter; reverse form of &lt;keyword_lists[key] for these metaparameters
		for _, metaparam_t in ipairs ({{'NameListStyle', 'name-list-style'}, {'Mode', 'mode'}}) do	-- only these metaparameter / keywords_lists key pairs
			for _, keyword in ipairs (keywords_lists[metaparam_t[2]]) do		-- spin through the list of keywords
				keywords_t[keyword] = metaparam_t[1];							-- add [keyword] = metaparameter to the map
			end
		end

		for _, param in ipairs (params_t) do									-- spin through the {{cs1 config}} parameters and fill &lt;global_cs1_config_t&gt;
			local k, v = param:match ('([^=]-)%s*=%s*(.+)');					-- &lt;k&gt; is the parameter name; &lt;v&gt; is parameter's assigned value
			if k then
				if k:find ('^display') then										-- if &lt;k&gt; is one of the |display-&lt;namelist&gt;= parameters
					if v:match ('%d+') then										-- the assigned value must be digits; doesn't accept 'etal'
						global_cs1_config_t[meta_param_map_t[k]]=v;				-- add the display param and its value to globals table
					end
				else
					if keywords_t[v] == meta_param_map_t[k] then				-- keywords_t[v] returns nil or the metaparam name; these must be the same
						global_cs1_config_t[meta_param_map_t[k]]=v;				-- add the parameter and its value to globals table
					end
				end
			end
		end
	end
end

get_cs1_config ();																-- fill &lt;global_cs1_config_t&gt;


--[[---------------------&lt; S T R I P M A R K E R S &gt;----------------------------

Common pattern definition location for stripmarkers so that we don't have to go
hunting for them if (when) MediaWiki changes their form.

]]

local stripmarkers = {
	['any'] = '\127[^\127]*UNIQ%-%-(%a+)%-[%a%d]+%-QINU[^\127]*\127',			-- capture returns name of stripmarker
	['math'] = '\127[^\127]*UNIQ%-%-math%-[%a%d]+%-QINU[^\127]*\127'			-- math stripmarkers used in coins_cleanup() and coins_replace_math_stripmarker()
	}


--[[------------&lt; I N V I S I B L E _ C H A R A C T E R S &gt;---------------------

This table holds non-printing or invisible characters indexed either by name or
by Unicode group. Values are decimal representations of UTF-8 codes.  The table
is organized as a table of tables because the Lua pairs keyword returns table
data in an arbitrary order.  Here, we want to process the table from top to bottom
because the entries at the top of the table are also found in the ranges specified
by the entries at the bottom of the table.

Also here is a pattern that recognizes stripmarkers that begin and end with the
delete characters.  The nowiki stripmarker is not an error but some others are
because the parameter values that include them become part of the template's
metadata before stripmarker replacement.

]]

local invisible_defs = {
	del = '\127',																-- used to distinguish between stripmarker and del char
	zwj = '\226\128\141',														-- used with capture because zwj may be allowed
	}

local invisible_chars = {
	{'replacement', '\239\191\189'},											-- U+FFFD, EF BF BD
	{'zero width joiner', '('.. invisible_defs.zwj .. ')'},						-- U+200D, E2 80 8D; capture because zwj may be allowed
	{'zero width space', '\226\128\139'},										-- U+200B, E2 80 8B
	{'hair space', '\226\128\138'},												-- U+200A, E2 80 8A
	{'soft hyphen', '\194\173'},												-- U+00AD, C2 AD
	{'horizontal tab', '\009'},													-- U+0009 (HT), 09
	{'line feed', '\010'},														-- U+000A (LF), 0A
	{'no-break space', '\194\160'},												-- U+00A0 (NBSP), C2 A0
	{'carriage return', '\013'},												-- U+000D (CR), 0D
	{'stripmarker', stripmarkers.any},											-- stripmarker; may or may not be an error; capture returns the stripmaker type
	{'delete', '('.. invisible_defs.del .. ')'},								-- U+007F (DEL), 7F; must be done after stripmarker test; capture to distinguish isolated del chars not part of stripmarker
	{'C0 control', '[\000-\008\011\012\014-\031]'},								-- U+0000–U+001F (NULL–US), 00–1F (except HT, LF, CR (09, 0A, 0D))
	{'C1 control', '[\194\128-\194\159]'},										-- U+0080–U+009F (XXX–APC), C2 80 – C2 9F
	--	{'Specials', '[\239\191\185-\239\191\191]'},								-- U+FFF9-U+FFFF, EF BF B9 – EF BF BF
	--	{'Private use area', '[\238\128\128-\239\163\191]'},						-- U+E000–U+F8FF, EE 80 80 – EF A3 BF
	--	{'Supplementary Private Use Area-A', '[\243\176\128\128-\243\191\191\189]'},	-- U+F0000–U+FFFFD, F3 B0 80 80 – F3 BF BF BD
	--	{'Supplementary Private Use Area-B', '[\244\128\128\128-\244\143\191\189]'},	-- U+100000–U+10FFFD, F4 80 80 80 – F4 8F BF BD
	}

--[[

Indic script makes use of zero width joiner as a character modifier so zwj
characters must be left in.  This pattern covers all of the unicode characters
for these languages:
	Devanagari					0900–097F – https://unicode.org/charts/PDF/U0900.pdf
		Devanagari extended		A8E0–A8FF – https://unicode.org/charts/PDF/UA8E0.pdf
	Bengali						0980–09FF – https://unicode.org/charts/PDF/U0980.pdf
	Gurmukhi					0A00–0A7F – https://unicode.org/charts/PDF/U0A00.pdf
	Gujarati					0A80–0AFF – https://unicode.org/charts/PDF/U0A80.pdf
	Oriya						0B00–0B7F – https://unicode.org/charts/PDF/U0B00.pdf
	Tamil						0B80–0BFF – https://unicode.org/charts/PDF/U0B80.pdf
	Telugu						0C00–0C7F – https://unicode.org/charts/PDF/U0C00.pdf
	Kannada						0C80–0CFF – https://unicode.org/charts/PDF/U0C80.pdf
	Malayalam					0D00–0D7F – https://unicode.org/charts/PDF/U0D00.pdf
plus the not-necessarily Indic scripts for Sinhala and Burmese:
	Sinhala						0D80-0DFF - https://unicode.org/charts/PDF/U0D80.pdf
	Myanmar						1000-109F - https://unicode.org/charts/PDF/U1000.pdf
		Myanmar extended A		AA60-AA7F - https://unicode.org/charts/PDF/UAA60.pdf
		Myanmar extended B		A9E0-A9FF - https://unicode.org/charts/PDF/UA9E0.pdf
the pattern is used by has_invisible_chars() and coins_cleanup()

]]

local indic_script = '[\224\164\128-\224\181\191\224\163\160-\224\183\191\225\128\128-\225\130\159\234\167\160-\234\167\191\234\169\160-\234\169\191]';

-- list of emoji that use a zwj character (U+200D) to combine with another emoji
-- from: https://unicode.org/Public/emoji/16.0/emoji-zwj-sequences.txt; version: 16.0; 2024-08-14
-- table created by: [[:en:Module:Make emoji zwj table]]
local emoji_t = {																-- indexes are decimal forms of the hex values in U+xxxx
	[8596] = true,																-- U+2194 ↔ left right arrow
	[8597] = true,																-- U+2195 ↕ up down arrow
	[9760] = true,																-- U+2620 ☠ skull and crossbones
	[9792] = true,																-- U+2640 ♀ female sign
	[9794] = true,																-- U+2642 ♂ male sign
	[9877] = true,																-- U+2695 ⚕ staff of aesculapius
	[9878] = true,																-- U+2696 ⚖ scales
	[9895] = true,																-- U+26A7 ⚧ male with stroke and male and female sign
	[9992] = true,																-- U+2708 ✈ airplane
	[10052] = true,																-- U+2744 ❄ snowflake
	[10084] = true,																-- U+2764 ❤ heavy black heart
	[10145] = true,																-- U+27A1 ➡ black rightwards arrow
	[11035] = true,																-- U+2B1B ⬛ black large square
	[127752] = true,															-- U+1F308 🌈 rainbow
	[127787] = true,															-- U+1F32B 🌫 fog
	[127806] = true,															-- U+1F33E 🌾 ear of rice
	[127859] = true,															-- U+1F373 🍳 cooking
	[127868] = true,															-- U+1F37C 🍼 baby bottle
	[127876] = true,															-- U+1F384 🎄 christmas tree
	[127891] = true,															-- U+1F393 🎓 graduation cap
	[127908] = true,															-- U+1F3A4 🎤 microphone
	[127912] = true,															-- U+1F3A8 🎨 artist palette
	[127979] = true,															-- U+1F3EB 🏫 school
	[127981] = true,															-- U+1F3ED 🏭 factory
	[128102] = true,															-- U+1F466 👦 boy
	[128103] = true,															-- U+1F467 👧 girl
	[128104] = true,															-- U+1F468 👨 man
	[128105] = true,															-- U+1F469 👩 woman
	[128139] = true,															-- U+1F48B 💋 kiss mark
	[128165] = true,															-- U+1F4A5 💥 collision symbol
	[128168] = true,															-- U+1F4A8 💨 dash symbol
	[128171] = true,															-- U+1F4AB 💫 dizzy symbol
	[128187] = true,															-- U+1F4BB 💻 personal computer
	[128188] = true,															-- U+1F4BC 💼 brief case
	[128293] = true,															-- U+1F525 🔥 fire
	[128295] = true,															-- U+1F527 🔧 wrench
	[128300] = true,															-- U+1F52C 🔬 microscope
	[128488] = true,															-- U+1F5E8 🗨 left speech bubble
	[128640] = true,															-- U+1F680 🚀 rocket
	[128658] = true,															-- U+1F692 🚒 fire engine
	[129001] = true,															-- U+1F7E9 🟩 large green square
	[129003] = true,															-- U+1F7EB 🟫 large brown square
	[129309] = true,															-- U+1F91D 🤝 handshake
	[129455] = true,															-- U+1F9AF 🦯 probing cane
	[129456] = true,															-- U+1F9B0 🦰 emoji component red hair
	[129457] = true,															-- U+1F9B1 🦱 emoji component curly hair
	[129458] = true,															-- U+1F9B2 🦲 emoji component bald
	[129459] = true,															-- U+1F9B3 🦳 emoji component white hair
	[129466] = true,															-- U+1F9BA 🦺 safety vest
	[129468] = true,															-- U+1F9BC 🦼 motorized wheelchair
	[129469] = true,															-- U+1F9BD 🦽 manual wheelchair
	[129489] = true,															-- U+1F9D1 🧑 adult
	[129490] = true,															-- U+1F9D2 🧒 child
	[129657] = true,															-- U+1FA79 🩹 adhesive bandage
	[129778] = true,															-- U+1FAF2 🫲 leftwards hand
	}


--[[----------------------&lt; L A N G U A G E   S U P P O R T &gt;-------------------

These tables and constants support various language-specific functionality.

]]

--local this_wiki_code = mw.getContentLanguage():getCode();						-- get this wiki's language code
local this_wiki_code = lang_obj:getCode();										-- get this wiki's language code
if string.match (mw.site.server, 'wikidata') then
		this_wiki_code = mw.getCurrentFrame():callParserFunction('int', {'lang'}); -- on Wikidata so use interface language setting instead
	end

local mw_languages_by_tag_t = mw.language.fetchLanguageNames (this_wiki_code, 'all');	-- get a table of language tag/name pairs known to Wikimedia; used for interwiki tests
local mw_languages_by_name_t = {};
	for k, v in pairs (mw_languages_by_tag_t) do								-- build a 'reversed' table name/tag language pairs know to MediaWiki; used for |language=
		v = mw.ustring.lower (v);												-- lowercase for tag fetch; get name's proper case from mw_languages_by_tag_t[&lt;tag&gt;]
		if mw_languages_by_name_t[v] then										-- when name already in the table
			if 2 == #k or 3 == #k then											-- if tag does not have subtags
				mw_languages_by_name_t[v] = k;									-- prefer the shortest tag for this name
			end
		else																	-- here when name not in the table
			mw_languages_by_name_t[v] = k;										-- so add name and matching tag
		end
	end

local inter_wiki_map = {};														-- map of interwiki prefixes that are language-code prefixes
	for k, v in pairs (mw.site.interwikiMap ('local')) do						-- spin through the base interwiki map (limited to local)
		if mw_languages_by_tag_t[v[&quot;prefix&quot;]] then								-- if the prefix matches a known language tag
			inter_wiki_map[v[&quot;prefix&quot;]] = true;									-- add it to our local map
		end
	end


--[[--------------------&lt; S C R I P T _ L A N G _ C O D E S &gt;-------------------

This table is used to hold ISO 639-1 two-character and ISO 639-3 three-character
language codes that apply only to |script-title= and |script-chapter=

]]

local script_lang_codes = {
	'ab', 'am', 'ar', 'az', 'be', 'bg', 'bn', 'bo', 'bs', 'ce', 'chr', 'dv', 'dz',
	'el', 'fa', 'grc', 'gu', 'he', 'hi', 'hy', 'ja', 'ka', 'kk', 'km', 'kn', 'ko',
	'ku', 'ky', 'lo', 'mk', 'ml', 'mn', 'mni', 'mr', 'my', 'ne', 'or', 'ota',
	'pa', 'ps', 'ru', 'sd', 'si', 'sr', 'syc', 'ta', 'te', 'tg', 'th', 'ti', 'tt',
	'ug', 'uk', 'ur', 'uz', 'yi', 'yue', 'zh', 'zgh'
	};


--[[---------------&lt; L A N G U A G E   R E M A P P I N G &gt;----------------------

These tables hold language information that is different (correct) from MediaWiki's definitions

For each ['&lt;tag&gt;'] = 'language name' in lang_code_remap{} there must be a matching ['language name'] = {'language name', '&lt;tag&gt;'} in lang_name_remap{}

lang_tag_remap{}:
	key is always lowercase ISO 639-1, -2, -3 language tag or a valid lowercase IETF language tag
	value is properly spelled and capitalized language name associated with &lt;tag&gt;
	only one language name per &lt;tag&gt;;
	key/value pair must have matching entry in lang_name_remap{}

lang_name_remap{}:
	key is always lowercase language name
	value is a table the holds correctly spelled and capitalized language name [1] and associated tag [2] (tag must match a tag key in lang_tag_remap{})
	may have multiple keys referring to a common preferred name and tag; For example:
		['kolsch'] and ['kölsch'] both refer to 'Kölsch' and 'ksh'

]]

local lang_tag_remap = {														-- used for |language= and |script-title= / |script-chapter=
	['als'] = 'Tosk Albanian',													-- MediaWiki returns Alemannisch 
	['bh'] = 'Bihari',															-- MediaWiki uses 'bh' as a subdomain name for Bhojpuri Wikipedia: bh.wikipedia.org
	['bla'] = 'Blackfoot',														-- MediaWiki/IANA/ISO 639: Siksika; use en.wiki preferred name
	['bn'] = 'Bengali',															-- MediaWiki returns Bangla
	['ca-valencia'] = 'Valencian',												-- IETF variant of Catalan
	['fkv'] = 'Kven',															-- MediaWiki returns Kvensk
	['gsw'] = 'Swiss German',
	['ilo'] = 'Ilocano',														-- MediaWiki/IANA/ISO 639: Iloko; use en.wiki preferred name
	['ksh'] = 'Kölsch',															-- MediaWiki: Colognian; use IANA/ISO 639 preferred name
	['ksh-x-colog'] = 'Colognian',												-- override MediaWiki ksh; no IANA/ISO 639 code for Colognian; IETF private code created at Module:Lang/data
	['mis-x-ripuar'] = 'Ripuarian',												-- override MediaWiki ksh; no IANA/ISO 639 code for Ripuarian; IETF private code created at Module:Lang/data
	['nan-tw'] = 'Taiwanese Hokkien',											-- make room for MediaWiki/IANA/ISO 639 nan: Min Nan Chinese and support en.wiki preferred name
	['sr-ec'] = 'Serbian (Cyrillic script)',									-- MediaWiki returns српски (ћирилица)
	['sr-el'] = 'Serbian (Latin script)',										-- MediaWiki returns srpski (latinica)
	}

local lang_name_remap = {														-- used for |language=; names require proper capitalization; tags must be lowercase
	['alemannic'] = {'Swiss German', 'gsw'},									-- ISO 639-2, -3 alternate for Swiss German; MediaWiki mediawiki returns Alemannic for gsw; en.wiki preferred name
	['alemannisch'] = {'Swiss German', 'gsw'},									-- not an ISO or IANA language name; MediaWiki uses 'als' as a subdomain name for Alemannic Wikipedia: als.wikipedia.org
	['bangla'] = {'Bengali', 'bn'},												-- MediaWiki returns Bangla (the endonym) but we want Bengali (the exonym); here we remap
	['bengali'] = {'Bengali', 'bn'},											-- MediaWiki doesn't use exonym so here we provide correct language name and 639-1 code
	['bhojpuri'] = {'Bhojpuri', 'bho'},											-- MediaWiki uses 'bh' as a subdomain name for Bhojpuri Wikipedia: bh.wikipedia.org
	['bihari'] = {'Bihari', 'bh'},												-- MediaWiki replaces 'Bihari' with 'Bhojpuri' so 'Bihari' cannot be found
	['blackfoot'] = {'Blackfoot', 'bla'},										-- MediaWiki/IANA/ISO 639: Siksika; use en.wiki preferred name
	['colognian'] = {'Colognian', 'ksh-x-colog'},								-- MediaWiki preferred name for ksh
	['ilocano'] = {'Ilocano', 'ilo'},											-- MediaWiki/IANA/ISO 639: Iloko; use en.wiki preferred name
	['kolsch'] = {'Kölsch', 'ksh'},												-- use IANA/ISO 639 preferred name (use non-diacritical o instead of umlaut ö)
	['kölsch'] = {'Kölsch', 'ksh'},												-- use IANA/ISO 639 preferred name
	['kven'] = {'Kven', 'fkv'},													-- Unicode CLDR have decided not to support English language name for these two...
	['kvensk'] = {'Kven', 'fkv'},												-- ...they say to refer to IANA registry for English names
	['ripuarian'] = {'Ripuarian', 'mis-x-ripuar'},								-- group of dialects; no code in MediaWiki or in IANA/ISO 639
	['serbian (cyrillic script)'] = {'Serbian (Cyrillic script)', 'sr-cyrl'},	-- special case to get correct tag when |language=sr-ec
	['serbian (latin script)'] = {'Serbian (Latin script)', 'sr-latn'},			-- special case to get correct tag when |language=sr-el
	['swiss german'] = {'Swiss German', 'gsw'},
	['taiwanese hokkien'] = {'Taiwanese Hokkien', 'nan-tw'},					-- make room for MediaWiki/IANA/ISO 639 nan: Min Nan Chinese 
	['tosk albanian'] = {'Tosk Albanian', 'als'},								-- MediaWiki replaces 'Tosk Albanian' with 'Alemannisch' so 'Tosk Albanian' cannot be found
	['valencian'] = {'Valencian', 'ca-valencia'},								-- variant of Catalan; categorizes as Valencian
	}


--[[---------------&lt; P R O P E R T I E S _ C A T E G O R I E S &gt;----------------

Properties categories. These are used for investigating qualities of citations.

]]

local prop_cats = {
	['foreign-lang-source'] = 'CS1 $1-language sources ($2)',					-- |language= categories; $1 is foreign-language name, $2 is ISO639-1 code
	['foreign-lang-source-2'] = 'CS1 foreign language sources (ISO 639-2)|$1',	-- |language= category; a cat for ISO639-2 languages; $1 is the ISO 639-2 code used as a sort key
	['interproj-linked-name'] = 'CS1 interproject-linked names|$1',				-- any author, editor, etc that has an interproject link; $1 is interproject tag used as a sort key
	['interwiki-linked-name'] = 'CS1 interwiki-linked names|$1',				-- any author, editor, etc that has an interwiki link; $1 is interwiki tag used as a sort key; yeilds to interproject
	['local-lang-source'] = 'CS1 $1-language sources ($2)',						-- |language= categories; $1 is local-language name, $2 is ISO639-1 code; not emitted when local_lang_cat_enable is false
	['location-test'] = 'CS1 location test',
	['long-vol'] = 'CS1: long volume value',									-- probably temporary cat to identify scope of |volume= values longer than 4 characters
	['script'] = 'CS1 uses $1-language script ($2)',							-- |script-title=xx: has matching category; $1 is language name, $2 is language tag
	['tracked-param'] = 'CS1 tracked parameter: $1',							-- $1 is base (enumerators removed) parameter name
	['unfit'] = 'CS1: unfit URL',												-- |url-status=unfit or |url-status=usurped; used to be a maint cat
	['vanc-accept'] = 'CS1:Vancouver names with accept markup',					-- for |vauthors=/|veditors= with accept-as-written markup
	['year-range-abbreviated'] = 'CS1: abbreviated year range',					-- probably temporary cat to identify scope of |date=, |year= values using YYYY–YY form
	}


--[[-------------------&lt; T I T L E _ T Y P E S &gt;--------------------------------

Here we map a template's CitationClass to TitleType (default values for |type= parameter)

]]

local title_types = {
	['AV-media-notes'] = 'Media notes',
	['document'] = 'Document',
	['interview'] = 'Interview',
	['mailinglist'] = 'Mailing list',
	['map'] = 'Map',
	['podcast'] = 'Podcast',
	['pressrelease'] = 'Press release',
	['report'] = 'Report',
	['speech'] = 'Speech',
	['techreport'] = 'Technical report',
	['thesis'] = 'Thesis',
	}


--[[--------------------------&lt; B U I L D _ K N O W N _ F R E E _ D O I _ R E G I S T R A N T S _ T A B L E &gt;--

build a table of doi registrants known to be free-to-read  In a doi, the registrant ID is the series of digits
between the '10.' and the first '/': in doi 10.1100/sommat, 1100 is the registrant ID

see §3.2.2 DOI prefix of the Doi Handbook p. 43
https://www.doi.org/doi-handbook/DOI_Handbook_Final.pdf#page=43

]]

local function build_free_doi_registrants_table()
	local registrants_t = {};
	for _, v in ipairs ({
		'1045', '1074', '1096', '1100', '1155', '1186', '1194', '1371', '1629', '1989', '1999', '2147', '2196', '3285', '3389', '3390',
		'3748', '3814', '3847', '3897', '4061', '4089', '4103', '4172', '4175', '4230', '4236', '4239', '4240', '4249', '4251',
		'4252', '4253', '4254', '4291', '4292', '4329', '4330', '4331', '5194', '5210', '5306', '5312', '5313', '5314',
		'5315', '5316', '5317', '5318', '5319', '5320', '5321', '5334', '5402', '5409', '5410', '5411', '5412',
		'5492', '5493', '5494', '5495', '5496', '5497', '5498', '5499', '5500', '5501', '5527', '5528', '5662',
		'6064', '6219', '7167', '7217', '7287', '7482', '7490', '7554', '7717', '7759', '7766', '11131', '11569', '11647',
		'11648', '12688', '12703', '12715', '12942', '12998', '13105', '14256', '14293', '14303', '15215', '15347', '15412', '15560', '16995',
		'17645', '18637', '19080', '19173', '20944', '21037', '21468', '21767', '22261', '22323', '22459', '24105', '24196', '24966',
		'26775', '30845', '32545', '35711', '35712', '35713', '35995', '36648', '37126', '37532', '37871', '47128',
		'47622', '47959', '52437', '52975', '53288', '54081', '54947', '55667', '55914', '57009', '58647', '59081',
		}) do
			registrants_t[v] = true;											-- build a k/v table of known free-to-read doi registrants
	end

	return registrants_t;
end

local extended_registrants_t = {												-- known free registrants identifiable by the doi suffix incipit
	['1002'] = {'aelm', 'leap'},												-- Advanced Electronic Materials, Learned Publishing
	['1016'] = {'j.heliyon', 'j.nlp', 'j.proche'},								-- Heliyon, Natural Language Processing, Procedia Chemistry
	['1017'] = {'nlp'},															-- Natural Language Processing Journal
	['1046'] = {'j.1365-8711', 'j.1365-246x'},									-- MNRAS, GJI
	['1093'] = {'mnras', 'mnrasl', 'gji', 'rasti'},								-- MNRAS, MNRAS Letters, GJI, RASTI
	['1099'] = {'acmi', 'mic', '00221287', 'mgen'},                             -- Access Microbiology, Microbiology, Journal of General Microbiology, Microbial Genomics
	['1111'] = {'j.1365-2966', 'j.1745-3933', 'j.1365-246X'},					-- MNRAS, MNRAS Letters, GJI
	['1210'] = {'jendso','jcemcr'},												-- Journal of the Endocrine Society, JCEM Case Reports
	['4171'] = {'dm','mag'},												    -- Documenta Mathematica, EMS Magazine
	['14231'] = {'ag'},															-- Algebraic Geometry
	}


--[[===================&lt;&lt; E R R O R   M E S S A G I N G &gt;&gt;======================
]]

--[[----------&lt; E R R O R   M E S S A G E   S U P P L I M E N T S &gt;-------------

I18N for those messages that are supplemented with additional specific text that
describes the reason for the error

TODO: merge this with special_case_translations{}?
]]

local err_msg_supl = {
	['char'] = 'invalid character',												-- |isbn=, |sbn=
	['check'] = 'checksum',														-- |isbn=, |sbn=
	['flag'] = 'flag',															-- |archive-url=
	['form'] = 'invalid form',													-- |isbn=, |sbn=
	['group'] = 'invalid group id',												-- |isbn=
	['initials'] = 'initials',													-- Vancouver
	['invalid language code'] = 'invalid language code',						-- |script-&lt;param&gt;=
	['journal'] = 'journal',													-- |bibcode=
	['length'] = 'length',														-- |isbn=, |bibcode=, |sbn=
	['liveweb'] = 'liveweb',													-- |archive-url=
	['missing comma'] = 'missing comma',										-- Vancouver
	['missing prefix'] = 'missing prefix',										-- |script-&lt;param&gt;=
	['missing title part'] = 'missing title part',								-- |script-&lt;param&gt;=
	['name'] = 'name',															-- Vancouver
	['non-Latin char'] = 'non-Latin character',									-- Vancouver
	['path'] = 'path',															-- |archive-url=
	['prefix'] = 'invalid prefix',												-- |isbn=
	['punctuation'] = 'punctuation',											-- Vancouver
	['save'] = 'save command',													-- |archive-url=
	['suffix'] = 'suffix',														-- Vancouver
	['timestamp'] = 'timestamp',												-- |archive-url=
	['unknown language code'] = 'unknown language code',						-- |script-&lt;param&gt;=
	['value'] = 'value',														-- |bibcode=
	['year'] = 'year',															-- |bibcode=
	}


--[[--------------&lt; E R R O R _ C O N D I T I O N S &gt;---------------------------

Error condition table.  This table has two sections: errors at the top, maintenance
at the bottom.  Maint 'messaging' does not have a 'message' (message=nil)

The following contains a list of IDs for various error conditions defined in the
code.  For each ID, we specify a text message to display, an error category to
include, and whether the error message should be wrapped as a hidden comment.

Anchor changes require identical changes to matching anchor in Help:CS1 errors

TODO: rename error_conditions{} to something more generic; create separate error
and maint tables inside that?

]]

local error_conditions = {
	err_accessdate_missing_url = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;access-date=&lt;/code&gt; requires &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;url=&lt;/code&gt;',
		anchor = 'accessdate_missing_url',
		category = 'CS1 errors: access-date without URL',
		hidden = false
 		},
	err_apostrophe_markup = {
		message = 'Italic or bold markup not allowed in: &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt;',	-- $1 is parameter name
		anchor = 'apostrophe_markup',
		category = 'CS1 errors: markup',
		hidden = false
 		},
	err_archive_date_missing_url = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;archive-date=&lt;/code&gt; requires &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;archive-url=&lt;/code&gt;',
		anchor = 'archive_date_missing_url',
		category = 'CS1 errors: archive-url',
		hidden = false
		},
	err_archive_date_url_ts_mismatch = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;archive-date=&lt;/code&gt; / &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;archive-url=&lt;/code&gt; timestamp mismatch; $1 suggested',
		anchor = 'archive_date_url_ts_mismatch',
		category = 'CS1 errors: archive-url',
		hidden = false
		},
	err_archive_missing_date = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;archive-url=&lt;/code&gt; requires &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;archive-date=&lt;/code&gt;',
		anchor = 'archive_missing_date',
		category = 'CS1 errors: archive-url',
		hidden = false
		},
	err_archive_missing_url = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;archive-url=&lt;/code&gt; requires &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;url=&lt;/code&gt;',
		anchor = 'archive_missing_url',
		category = 'CS1 errors: archive-url',
		hidden = false
		},
	err_archive_url = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;archive-url=&lt;/code&gt; is malformed: $1',	-- $1 is error message detail
		anchor = 'archive_url',
		category = 'CS1 errors: archive-url',
		hidden = false
		},
	err_arxiv_missing = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;arxiv=&lt;/code&gt; required',
		anchor = 'arxiv_missing',
		category = 'CS1 errors: arXiv',											-- same as bad arxiv
		hidden = false
		},
	err_asintld_missing_asin = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt; requires &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;asin=&lt;/code&gt;',	-- $1 is parameter name
		anchor = 'asintld_missing_asin',
		category = 'CS1 errors: ASIN TLD',
		hidden = false
		},
	err_bad_arxiv = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;arxiv=&lt;/code&gt; value',
		anchor = 'bad_arxiv',
		category = 'CS1 errors: arXiv',
		hidden = false
		},
	err_bad_asin = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;asin=&lt;/code&gt; value',
		anchor = 'bad_asin',
		category ='CS1 errors: ASIN',
		hidden = false
		},
	err_bad_asin_tld = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;asin-tld=&lt;/code&gt; value',
		anchor = 'bad_asin_tld',
		category ='CS1 errors: ASIN TLD',
		hidden = false
		},
	err_bad_bibcode = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;bibcode=&lt;/code&gt; $1',		-- $1 is error message detail
		anchor = 'bad_bibcode',
		category = 'CS1 errors: bibcode',
		hidden = false
		},
	err_bad_biorxiv = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;biorxiv=&lt;/code&gt; value',
		anchor = 'bad_biorxiv',
		category = 'CS1 errors: bioRxiv',
		hidden = false
		},
	err_bad_citeseerx = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;citeseerx=&lt;/code&gt; value',
		anchor = 'bad_citeseerx',
		category = 'CS1 errors: citeseerx',
		hidden = false
		},
	err_bad_date = {
		message = 'Check date values in: $1',									-- $1 is a parameter name list
		anchor = 'bad_date',
		category = 'CS1 errors: dates',
		hidden = false
		},
	err_bad_doi = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;doi=&lt;/code&gt; value',
		anchor = 'bad_doi',
		category = 'CS1 errors: DOI',
		hidden = false
		},
	err_bad_hdl = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;hdl=&lt;/code&gt; value',
		anchor = 'bad_hdl',
		category = 'CS1 errors: HDL',
		hidden = false
		},
	err_bad_isbn = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;isbn=&lt;/code&gt; value: $1',	-- $1 is error message detail
		anchor = 'bad_isbn',
		category = 'CS1 errors: ISBN',
		hidden = false
		},
	err_bad_ismn = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;ismn=&lt;/code&gt; value',
		anchor = 'bad_ismn',
		category = 'CS1 errors: ISMN',
		hidden = false
		},
	err_bad_issn = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1issn=&lt;/code&gt; value',	-- $1 is 'e' or '' for eissn or issn
		anchor = 'bad_issn',
		category = 'CS1 errors: ISSN',
		hidden = false
		},
	err_bad_jfm = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;jfm=&lt;/code&gt; value',
		anchor = 'bad_jfm',
		category = 'CS1 errors: JFM',
		hidden = false
		},
	err_bad_jstor = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;jstor=&lt;/code&gt; value',
		anchor = 'bad_jstor',
		category = 'CS1 errors: JSTOR',
		hidden = false
		},
	err_bad_lccn = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;lccn=&lt;/code&gt; value',
		anchor = 'bad_lccn',
		category = 'CS1 errors: LCCN',
		hidden = false
		},
	err_bad_medrxiv = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;medrxiv=&lt;/code&gt; value',
		anchor = 'bad_medrxiv',
		category = 'CS1 errors: medRxiv',
		hidden = false
		},
	err_bad_mr = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;mr=&lt;/code&gt; value',
		anchor = 'bad_mr',
		category = 'CS1 errors: MR',
		hidden = false
		},
	err_bad_oclc = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;oclc=&lt;/code&gt; value',
		anchor = 'bad_oclc',
		category = 'CS1 errors: OCLC',
		hidden = false
		},
	err_bad_ol = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;ol=&lt;/code&gt; value',
		anchor = 'bad_ol',
		category = 'CS1 errors: OL',
		hidden = false
		},
	err_bad_osti = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;osti=&lt;/code&gt; value',
		anchor = 'bad_osti',
		category = 'CS1 errors: OSTI',
		hidden = false
		},
	err_bad_paramlink = {														-- for |title-link=, |author/editor/translator-link=, |series-link=, |episode-link=
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt; value',		-- $1 is parameter name
		anchor = 'bad_paramlink',
		category = 'CS1 errors: parameter link',
		hidden = false
		},
	err_bad_pmc = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;pmc=&lt;/code&gt; value',
		anchor = 'bad_pmc',
		category = 'CS1 errors: PMC',
		hidden = false
		},
	err_bad_pmid = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;pmid=&lt;/code&gt; value',
		anchor = 'bad_pmid',
		category = 'CS1 errors: PMID',
		hidden = false
		},
	err_bad_rfc = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;rfc=&lt;/code&gt; value',
		anchor = 'bad_rfc',
		category = 'CS1 errors: RFC',
		hidden = false
		},
	err_bad_s2cid = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;s2cid=&lt;/code&gt; value',
		anchor = 'bad_s2cid',
		category = 'CS1 errors: S2CID',
		hidden = false
		},
	err_bad_sbn = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;sbn=&lt;/code&gt; value: $1',	-- $1 is error message detail
		anchor = 'bad_sbn',
		category = 'CS1 errors: SBN',
		hidden = false
		},
	err_bad_ssrn = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;ssrn=&lt;/code&gt; value',
		anchor = 'bad_ssrn',
		category = 'CS1 errors: SSRN',
		hidden = false
		},
	err_bad_url = {
		message = 'Check $1 value',												-- $1 is parameter name
		anchor = 'bad_url',
		category = 'CS1 errors: URL',
		hidden = false
		},
	err_bad_usenet_id = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;message-id=&lt;/code&gt; value',
		anchor = 'bad_message_id',
		category = 'CS1 errors: message-id',
		hidden = false
		},
	err_bad_zbl = {
		message = 'Check &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;zbl=&lt;/code&gt; value',
		anchor = 'bad_zbl',
		category = 'CS1 errors: Zbl',
		hidden = false
		},
	err_bare_url_missing_title = {
		message = '$1 missing title',											-- $1 is parameter name
		anchor = 'bare_url_missing_title',
		category = 'CS1 errors: bare URL',
		hidden = false
		},
	err_biorxiv_missing = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;biorxiv=&lt;/code&gt; required',
		anchor = 'biorxiv_missing',
		category = 'CS1 errors: bioRxiv',										-- same as bad bioRxiv
		hidden = false
		},
	err_chapter_ignored = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt; ignored',			-- $1 is parameter name
		anchor = 'chapter_ignored',
		category = 'CS1 errors: chapter ignored',
		hidden = false
		},
	err_citation_missing_title = {
		message = 'Missing or empty &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt;',	-- $1 is parameter name
		anchor = 'citation_missing_title',
		category = 'CS1 errors: missing title',
		hidden = false
		},
	err_citeseerx_missing = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;citeseerx=&lt;/code&gt; required',
		anchor = 'citeseerx_missing',
		category = 'CS1 errors: citeseerx',										-- same as bad citeseerx
		hidden = false
		},
	err_cite_web_url = {														-- this error applies to cite web and to cite podcast
		message = 'Missing or empty &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;url=&lt;/code&gt;',
		anchor = 'cite_web_url',
		category = 'CS1 errors: requires URL',
		hidden = false
		},
	err_class_ignored = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;class=&lt;/code&gt; ignored',
		anchor = 'class_ignored',
		category = 'CS1 errors: class',
		hidden = false
		},
	err_contributor_ignored = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;contributor=&lt;/code&gt; ignored',
		anchor = 'contributor_ignored',
		category = 'CS1 errors: contributor',
		hidden = false
		},
	err_contributor_missing_required_param = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;contributor=&lt;/code&gt; requires &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt;',	-- $1 is parameter name
		anchor = 'contributor_missing_required_param',
		category = 'CS1 errors: contributor',
		hidden = false
		},
	err_deprecated_params = {
		message = 'Cite uses deprecated parameter &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt;',	-- $1 is parameter name
		anchor = 'deprecated_params',
		category = 'CS1 errors: deprecated parameters',
		hidden = false
		},
	err_disp_name = {
		message = 'Invalid &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=$2&lt;/code&gt;',			-- $1 is parameter name; $2 is the assigned value
		anchor = 'disp_name',
		category = 'CS1 errors: display-names',
		hidden = false,
		},
	err_doibroken_missing_doi = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt; requires &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;doi=&lt;/code&gt;',	-- $1 is parameter name
		anchor = 'doibroken_missing_doi',
		category = 'CS1 errors: DOI',
		hidden = false
		},
	err_embargo_missing_pmc = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt; requires &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;pmc=&lt;/code&gt;',	-- $1 is parameter name
		anchor = 'embargo_missing_pmc',
		category = 'CS1 errors: PMC embargo',
		hidden = false
		},
	err_empty_citation = {
		message = 'Empty citation',
		anchor = 'empty_citation',
		category = 'CS1 errors: empty citation',
		hidden = false
		},
	err_etal = {
		message = 'Explicit use of et al. in: &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt;',	-- $1 is parameter name
		anchor = 'explicit_et_al',
		category = 'CS1 errors: explicit use of et al.',
		hidden = false
		},
	err_extra_text_edition = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;edition=&lt;/code&gt; has extra text',
		anchor = 'extra_text_edition',
		category = 'CS1 errors: extra text: edition',
		hidden = false,
		},
	err_extra_text_issue = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt; has extra text',		-- $1 is parameter name
		anchor = 'extra_text_issue',
		category = 'CS1 errors: extra text: issue',
		hidden = false,
		},
	err_extra_text_pages = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt; has extra text',		-- $1 is parameter name
		anchor = 'extra_text_pages',
		category = 'CS1 errors: extra text: pages',
		hidden = false,
		},
	err_extra_text_volume = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt; has extra text',		-- $1 is parameter name
		anchor = 'extra_text_volume',
		category = 'CS1 errors: extra text: volume',
		hidden = false,
		},
	err_first_missing_last = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt; missing &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$2=&lt;/code&gt;',	-- $1 is first alias, $2 is matching last alias
		anchor = 'first_missing_last',
		category = 'CS1 errors: missing name',									-- author, contributor, editor, interviewer, translator
		hidden = false
		},
	err_format_missing_url = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt; requires &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$2=&lt;/code&gt;',	-- $1 is format parameter $2 is url parameter
		anchor = 'format_missing_url',
		category = 'CS1 errors: format without URL',
		hidden = false
		},
	err_generic_name = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt; has generic name',	-- $1 is parameter name
		anchor = 'generic_name',
		category = 'CS1 errors: generic name',
		hidden = false,
		},
	err_generic_title = {
		message = 'Cite uses generic title',
		anchor = 'generic_title',
		category = 'CS1 errors: generic title',
		hidden = false,
		},
	err_invalid_isbn_date = {
		message = 'ISBN / Date incompatibility',
		anchor = 'invalid_isbn_date',
		category = 'CS1 errors: ISBN date',
		hidden = true
		},
	err_invalid_param_val = {
		message = 'Invalid &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=$2&lt;/code&gt;',			-- $1 is parameter name $2 is parameter value
		anchor = 'invalid_param_val',
		category = 'CS1 errors: invalid parameter value',
		hidden = false
		},
	err_invisible_char = {
		message = '$1 in $2 at position $3',									-- $1 is invisible char $2 is parameter name $3 is position number
		anchor = 'invisible_char',
		category = 'CS1 errors: invisible characters',
		hidden = false
		},
	err_medrxiv_missing = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;medrxiv=&lt;/code&gt; required',
		anchor = 'medrxiv_missing',
		category = 'CS1 errors: medRxiv',										-- same as bad medRxiv
		hidden = false
		},
	err_missing_name = {
		message = 'Missing &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1$2=&lt;/code&gt;',			-- $1 is modified NameList; $2 is enumerator
		anchor = 'missing_name',
		category = 'CS1 errors: missing name',									-- author, contributor, editor, interviewer, translator
		hidden = false
		},
	err_missing_periodical = {
		message = 'Cite $1 requires &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$2=&lt;/code&gt;',	-- $1 is cs1 template name; $2 is canonical periodical parameter name for cite $1
		anchor = 'missing_periodical',
		category = 'CS1 errors: missing periodical',
		hidden = false
		},
	err_missing_pipe = {
		message = 'Missing pipe in: &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt;',	-- $1 is parameter name
		anchor = 'missing_pipe',
		category = 'CS1 errors: missing pipe',
		hidden = false
		},
	err_missing_publisher = {
		message = 'Cite $1 requires &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$2=&lt;/code&gt;',	-- $1 is cs1 template name; $2 is canonical publisher parameter name for cite $1
		anchor = 'missing_publisher',
		category = 'CS1 errors: missing publisher',
		hidden = false
		},
	err_numeric_names = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt; has numeric name',	-- $1 is parameter name',
		anchor = 'numeric_names',
		category = 'CS1 errors: numeric name',
		hidden = false,
		},
	err_param_access_requires_param = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1-access=&lt;/code&gt; requires &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt;',	-- $1 is parameter name
		anchor = 'param_access_requires_param',
		category = 'CS1 errors: param-access',
		hidden = false
		},
	err_param_has_ext_link = {
		message = 'External link in &lt;code class=&quot;cs1-code&quot;&gt;$1&lt;/code&gt;',			-- $1 is parameter name
		anchor = 'param_has_ext_link',
		category = 'CS1 errors: external links',
		hidden = false
		},
	err_param_has_twl_url = {
		message = 'Wikipedia Library link in &lt;code class=&quot;cs1-code&quot;&gt;$1&lt;/code&gt;',	-- $1 is parameter name
		anchor = 'param_has_twl_url',
		category = 'CS1 errors: URL',
		hidden = false
		},
	err_parameter_ignored = {
		message = 'Unknown parameter &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt; ignored',	-- $1 is parameter name
		anchor = 'parameter_ignored',
		category = 'CS1 errors: unsupported parameter',
		hidden = false
		},
	err_parameter_ignored_suggest = {
		message = 'Unknown parameter &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt; ignored (&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$2=&lt;/code&gt; suggested)',	-- $1 is unknown parameter $2 is suggested parameter name
		anchor = 'parameter_ignored_suggest',
		category = 'CS1 errors: unsupported parameter',
		hidden = false
		},
	err_periodical_ignored = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt; ignored',			-- $1 is parameter name
		anchor = 'periodical_ignored',
		category = 'CS1 errors: periodical ignored',
		hidden = false
		},
	err_redundant_parameters = {
		message = 'More than one of $1 specified',								-- $1 is error message detail
		anchor = 'redundant_parameters',
		category = 'CS1 errors: redundant parameter',
		hidden = false
		},
	err_script_parameter = {
		message = 'Invalid &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt;: $2',		-- $1 is parameter name $2 is script language code or error detail
		anchor = 'script_parameter',
		category = 'CS1 errors: script parameters',
		hidden = false
		},
	err_ssrn_missing = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;ssrn=&lt;/code&gt; required',
		anchor = 'ssrn_missing',
		category = 'CS1 errors: SSRN',
		hidden = false
		},
	err_text_ignored = {
		message = 'Text &quot;$1&quot; ignored',											-- $1 is ignored text
		anchor = 'text_ignored',
		category = 'CS1 errors: unrecognized parameter',
		hidden = false
		},
	err_trans_missing_title = {
		message = '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;trans-$1=&lt;/code&gt; requires &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;$1=&lt;/code&gt; or &lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;script-$1=&lt;/code&gt;',	-- $1 is base parameter name
		anchor = 'trans_missing_title',
		category = 'CS1 errors: translated title',
		hidden = false
		},
	err_param_unknown_empty = {
		message = 'Cite has empty unknown parameter$1: $2',						-- $1 is 's' or empty space; $2 is emty unknown param list
		anchor = 'param_unknown_empty',
		category = 'CS1 errors: empty unknown parameters',
		hidden = false
		},
	err_vancouver = {
		message = 'Vancouver style error: $1 in name $2',						-- $1 is error detail, $2 is the nth name
		anchor = 'vancouver',
		category = 'CS1 errors: Vancouver style',
		hidden = false
		},
	err_wikilink_in_url = {
		message = 'URL–wikilink conflict',										-- uses ndash
		anchor = 'wikilink_in_url',
		category = 'CS1 errors: URL–wikilink conflict',							-- uses ndash
		hidden = false
		},


--[[--------------------------&lt; M A I N T &gt;-------------------------------------

maint messages do not have a message (message = nil); otherwise the structure
is the same as error messages

]]

	maint_archived_copy = {
		message = nil,
		anchor = 'archived_copy',
		category = 'CS1 maint: archived copy as title',
		hidden = true,
		},
	maint_bibcode = {
		message = nil,
		anchor = 'bibcode',
		category = 'CS1 maint: bibcode',
		hidden = true,
		},
	maint_location_no_publisher = {												-- cite book, conference, encyclopedia; citation as book cite or encyclopedia cite
		message = nil,
		anchor = 'location_no_publisher',
		category = 'CS1 maint: location missing publisher',
		hidden = true,
		},
	maint_bot_unknown = {
		message = nil,
		anchor = 'bot:_unknown',
		category = 'CS1 maint: bot: original URL status unknown',
		hidden = true,
		},
	maint_date_auto_xlated = {													-- date auto-translation not supported by en.wiki
		message = nil,
		anchor = 'date_auto_xlated',
		category = 'CS1 maint: date auto-translated',
		hidden = true,
		},
	maint_date_format = {
		message = nil,
		anchor = 'date_format',
		category = 'CS1 maint: date format',
		hidden = true,
		},
	maint_date_year = {
		message = nil,
		anchor = 'date_year',
		category = 'CS1 maint: date and year',
		hidden = true,
		},
	maint_doi_ignore = {
		message = nil,
		anchor = 'doi_ignore',
		category = 'CS1 maint: ignored DOI errors',
		hidden = true,
		},
	maint_doi_inactive = {
		message = nil,
		anchor = 'doi_inactive',
		category = 'CS1 maint: DOI inactive',
		hidden = true,
		},
	maint_doi_inactive_dated = {
		message = nil,
		anchor = 'doi_inactive_dated',
		category = 'CS1 maint: DOI inactive as of $2$3$1',						-- $1 is year, $2 is month-name or empty string, $3 is space or empty string
		hidden = true,
		},
	maint_doi_unflagged_free = {
		message = nil,
		anchor = 'doi_unflagged_free',
		category = 'CS1 maint: unflagged free DOI',
		hidden = true,
		},
	maint_extra_punct = {
		message = nil,
		anchor = 'extra_punct',
		category = 'CS1 maint: extra punctuation',
		hidden = true,
		},
	maint_id_limit_load_fail = {												-- applies to all cs1|2 templates on a page; 
		message = nil,															-- maint message (category link) never emitted
		anchor = 'id_limit_load_fail',
		category = 'CS1 maint: ID limit load fail',
		hidden = true,
		},
	maint_isbn_ignore = {
		message = nil,
		anchor = 'ignore_isbn_err',
		category = 'CS1 maint: ignored ISBN errors',
		hidden = true,
		},
	maint_issn_ignore = {
		message = nil,
		anchor = 'ignore_issn',
		category = 'CS1 maint: ignored ISSN errors',
		hidden = true,
		},
	maint_jfm_format = {
		message = nil,
		anchor = 'jfm_format',
		category = 'CS1 maint: JFM format',
		hidden = true,
		},
	maint_location = {
		message = nil,
		anchor = 'location',
		category = 'CS1 maint: location',
		hidden = true,
		},
	maint_mr_format = {
		message = nil,
		anchor = 'mr_format',
		category = 'CS1 maint: MR format',
		hidden = true,
		},
	maint_mult_names = {
		message = nil,
		anchor = 'mult_names',
		category = 'CS1 maint: multiple names: $1',								-- $1 is '&lt;name&gt;s list'; gets value from special_case_translation table
		hidden = true,
		},
	maint_numeric_names = {
		message = nil,
		anchor = 'numeric_names',
		category = 'CS1 maint: numeric names: $1',								-- $1 is '&lt;name&gt;s list'; gets value from special_case_translation table
		hidden = true,
		},
	maint_others = {
		message = nil,
		anchor = 'others',
		category = 'CS1 maint: others',
		hidden = true,
		},
	maint_others_avm = {
		message = nil,
		anchor = 'others_avm',
		category = 'CS1 maint: others in cite AV media (notes)',
		hidden = true,
		},
	maint_overridden_setting = {
		message = nil,
		anchor = 'overridden',
		category = 'CS1 maint: overridden setting',
		hidden = true,
		},
	maint_pmc_embargo = {
		message = nil,
		anchor = 'embargo',
		category = 'CS1 maint: PMC embargo expired',
		hidden = true,
		},
	maint_pmc_format = {
		message = nil,
		anchor = 'pmc_format',
		category = 'CS1 maint: PMC format',
		hidden = true,
		},
	maint_postscript = {
		message = nil,
		anchor = 'postscript',
		category = 'CS1 maint: postscript',
		hidden = true,
	},
	maint_publisher_location = {
		message = nil,
		anchor = 'publisher_location',
		category = 'CS1 maint: publisher location',
		hidden = true,
	},
	maint_ref_duplicates_default = {
		message = nil,
		anchor = 'ref_default',
		category = 'CS1 maint: ref duplicates default',
		hidden = true,
	},
	maint_unknown_lang = {
		message = nil,
		anchor = 'unknown_lang',
		category = 'CS1 maint: unrecognized language',
		hidden = true,
		},
	maint_untitled = {
		message = nil,
		anchor = 'untitled',
		category = 'CS1 maint: untitled periodical',
		hidden = true,
		},
	maint_url_status = {
		message = nil,
		anchor = 'url_status',
		category = 'CS1 maint: url-status',
		hidden = true,
		},
	maint_year= {
		message = nil,
		anchor = 'year',
		category = 'CS1 maint: year',
		hidden = true,
		},
	maint_zbl = {
		message = nil,
		anchor = 'zbl',
		category = 'CS1 maint: Zbl',
		hidden = true,
		},
	}


--[[--------------------------&lt; I D _ L I M I T S _ D A T A _ T &gt;----------------------------------------------

fetch id limits for certain identifiers from c:Data:CS1/Identifier limits.tab.  This source is a json tabular 
data file maintained at wikipedia commons.  Convert the json format to a table of k/v pairs.

The values from &lt;id_limits_data_t&gt; are used to set handle.id_limit.

From 2025-02-21, MediaWiki is broken.  Use this link to edit the tablular data file:
	https://commons.wikimedia.org/w/index.php?title=Data:CS1/Identifier_limits.tab&amp;action=edit
See Phab:T389105

]]

local id_limits_data_t = {};

local use_commons_data = true;													-- set to false if your wiki does not have access to mediawiki commons; then,
if false == use_commons_data then												-- update this table from https://commons.wikimedia.org/wiki/Data:CS1/Identifier_limits.tab; last update: 2025-02-21
	id_limits_data_t = {['OCLC'] = 10450000000, ['OSTI'] = 23010000, ['PMC'] = 11900000, ['PMID'] = 40400000, ['RFC'] = 9300, ['SSRN'] = 5200000, ['S2CID'] = 276000000};	-- this table must be maintained locally

else																			-- here for wikis that do have access to mediawiki commons
	local load_fail_limit = 99999999999;										-- very high number to avoid error messages on load failure
	id_limits_data_t = {['OCLC'] = load_fail_limit, ['OSTI'] = load_fail_limit, ['PMC'] = load_fail_limit, ['PMID'] = load_fail_limit, ['RFC'] = load_fail_limit, ['SSRN'] = load_fail_limit, ['S2CID'] = load_fail_limit};

	local id_limits_data_load_fail = false;										-- flag; assume that we will be successful when loading json id limit tabular data
	
	local tab_data_t = mw.ext.data.get ('CS1/Identifier limits.tab').data;		-- attempt to load the json limit data from commons into &lt;tab_data_t&gt;
	if false == tab_data_t then													-- undocumented 'feature': mw.ext.data.get() sometimes returns false
		id_limits_data_load_fail = true;										-- set the flag so that Module:Citation/CS1 can create an unannotated maint category
	else
		for _, limit_t in ipairs (tab_data_t) do								-- overwrite default &lt;load_fail_limit&gt; values
			id_limits_data_t[limit_t[1]] = limit_t[2];							-- &lt;limit[1]&gt; is identifier; &lt;limit[2]&gt; is upper limit for that identifier
		end
	end
end


--[[--------------------------&lt; I D _ H A N D L E R S &gt;--------------------------------------------------------

The following contains a list of values for various defined identifiers.  For each
identifier we specify a variety of information necessary to properly render the
identifier in the citation.

	parameters: a list of parameter aliases for this identifier; first in the list is the canonical form
	link: Wikipedia article name
	redirect: a local redirect to a local Wikipedia article name;  at en.wiki, 'ISBN (identifier)' is a redirect to 'International Standard Book Number'
	q: Wikidata q number for the identifier
	label: the label preceding the identifier; label is linked to a Wikipedia article (in this order):
		redirect from id_handlers['&lt;id&gt;'].redirect when use_identifier_redirects is true
		Wikidata-supplied article name for the local wiki from id_handlers['&lt;id&gt;'].q
		local article name from id_handlers['&lt;id&gt;'].link
	prefix: the first part of a URL that will be concatenated with a second part which usually contains the identifier
	suffix: optional third part to be added after the identifier
	encode: true if URI should be percent-encoded; otherwise false
	COinS: identifier link or keyword for use in COinS:
		for identifiers registered at info-uri.info use: info:.... where '...' is the appropriate identifier label 
		for identifiers that have COinS keywords, use the keyword: rft.isbn, rft.issn, rft.eissn
		for |asin= and |ol=, which require assembly, use the keyword: url
		for others make a URL using the value in prefix/suffix and #label, use the keyword: pre (not checked; any text other than 'info', 'rft', or 'url' works here)
		set to nil to leave the identifier out of the COinS
	separator: character or text between label and the identifier in the rendered citation
	id_limit: for those identifiers with established limits, this property holds the upper limit
	access: use this parameter to set the access level for all instances of this identifier.
		the value must be a valid access level for an identifier (see ['id-access'] in this file).
	custom_access: to enable custom access level for an identifier, set this parameter
		to the parameter that should control it (normally 'id-access')
		
]]

local id_handlers = {
	['ARXIV'] = {
		parameters = {'arxiv', 'eprint'},
		link = 'arXiv',
		redirect = 'arXiv (identifier)',
		q = 'Q118398',
		label = 'arXiv',
		prefix = 'https://arxiv.org/abs/',
		encode = false,
		COinS = 'info:arxiv',
		separator = ':',
		access = 'free',														-- free to read
		},
	['ASIN'] = {
		parameters = { 'asin', 'ASIN' },
		link = 'Amazon Standard Identification Number',
		redirect = 'ASIN (identifier)',
		q = 'Q1753278',
		label = 'ASIN',
		prefix = 'https://www.amazon.',
		COinS = 'url',
		separator = '&amp;nbsp;',
		encode = false;
		},
	['BIBCODE'] = {
		parameters = {'bibcode'},
		link = 'Bibcode',
		redirect = 'Bibcode (identifier)',
		q = 'Q25754',
		label = 'Bibcode',
		prefix = 'https://ui.adsabs.harvard.edu/abs/',
		encode = false,
		COinS = 'info:bibcode',
		separator = ':',
		custom_access = 'bibcode-access',
		},
	['BIORXIV'] = {
		parameters = {'biorxiv'},
		link = 'bioRxiv',
		redirect = 'bioRxiv (identifier)',
		q = 'Q19835482',
		label = 'bioRxiv',
		prefix = 'https://doi.org/',
		COinS = 'pre',															-- use prefix value
		access = 'free',														-- free to read
		encode = true,
		separator = '&amp;nbsp;',
		},
	['CITESEERX'] = {
		parameters = {'citeseerx'},
		link = 'CiteSeerX',
		redirect = 'CiteSeerX (identifier)',
		q = 'Q2715061',
		label = 'CiteSeerX',
		prefix = 'https://citeseerx.ist.psu.edu/viewdoc/summary?doi=',
		COinS =  'pre',															-- use prefix value
		access = 'free',														-- free to read
		encode = true,
		separator = '&amp;nbsp;',
		},
	['DOI'] = {																	-- Used by InternetArchiveBot
		parameters = { 'doi', 'DOI'},
		link = 'Digital object identifier',
		redirect = 'doi (identifier)',
		q = 'Q25670',
		label = 'doi',
		prefix = 'https://doi.org/',
		COinS = 'info:doi',
		separator = ':',
		encode = true,
		custom_access = 'doi-access',
		},
	['EISSN'] = {
		parameters = {'eissn', 'EISSN'},
		link = 'International Standard Serial Number#Electronic ISSN',
		redirect = 'eISSN (identifier)',
		q = 'Q46339674',
		label = 'eISSN',
		prefix = 'https://search.worldcat.org/issn/',
		COinS = 'rft.eissn',
		encode = false,
		separator = '&amp;nbsp;',
		},
	['HDL'] = {
		parameters = { 'hdl', 'HDL' },
		link = 'Handle System',
		redirect = 'hdl (identifier)',
		q = 'Q3126718',
		label = 'hdl',
		prefix = 'https://hdl.handle.net/',
		COinS = 'info:hdl',
		separator = ':',
		encode = true,
		custom_access = 'hdl-access',
		},
	['ISBN'] = {																-- Used by InternetArchiveBot
		parameters = {'isbn', 'ISBN'},
		link = 'International Standard Book Number',
		redirect = 'ISBN (identifier)',
		q = 'Q33057',
		label = 'ISBN',
		prefix = 'Special:BookSources/',
		COinS = 'rft.isbn',
		separator = '&amp;nbsp;',
		},
	['ISMN'] = {
		parameters = {'ismn', 'ISMN'},
		link = 'International Standard Music Number',
		redirect = 'ISMN (identifier)',
		q = 'Q1666938',
		label = 'ISMN',
		prefix = '',															-- not currently used;
		COinS = nil,															-- nil because we can't use pre or rft or info:
		separator = '&amp;nbsp;',
		},
	['ISSN'] = {
		parameters = {'issn', 'ISSN'},
		link = 'International Standard Serial Number',
		redirect = 'ISSN (identifier)',
		q = 'Q131276',
		label = 'ISSN',
		prefix = 'https://search.worldcat.org/issn/',
		COinS = 'rft.issn',
		encode = false,
		separator = '&amp;nbsp;',
		},
	['JFM'] = {
		parameters = {'jfm', 'JFM'},
		link = 'Jahrbuch über die Fortschritte der Mathematik',
		redirect = 'JFM (identifier)',
		q = '',
		label = 'JFM',
		prefix = 'https://zbmath.org/?format=complete&amp;q=an:',
		COinS = 'pre',															-- use prefix value
		encode = true,
		separator = '&amp;nbsp;',
		},
	['JSTOR'] = {
		parameters = {'jstor', 'JSTOR'},
		link = 'JSTOR',
		redirect = 'JSTOR (identifier)',
		q = 'Q1420342',
		label = 'JSTOR',
		prefix = 'https://www.jstor.org/stable/',
		COinS = 'pre',															-- use prefix value
		encode = false,
		separator = '&amp;nbsp;',
		custom_access = 'jstor-access',
		},
	['LCCN'] = {
		parameters = {'lccn', 'LCCN'},
		link = 'Library of Congress Control Number',
		redirect = 'LCCN (identifier)',
		q = 'Q620946',
		label = 'LCCN',
		prefix = 'https://lccn.loc.gov/',
		COinS = 'info:lccn',
		encode = false,
		separator = '&amp;nbsp;',
		},
	['MEDRXIV'] = {
		parameters = {'medrxiv'},
		link = 'medRxiv',
		redirect = 'medRxiv (identifier)',
		q = 'Q58465838',
		label = 'medRxiv',
		prefix = 'https://www.medrxiv.org/content/',
		COinS = 'pre',															-- use prefix value
		access = 'free',														-- free to read
		encode = false,
		separator = '&amp;nbsp;',
		},
	['MR'] = {
		parameters = {'mr', 'MR'},
		link = 'Mathematical Reviews',
		redirect = 'MR (identifier)',
		q = 'Q211172',
		label = 'MR',
		prefix = 'https://mathscinet.ams.org/mathscinet-getitem?mr=',
		COinS = 'pre',															-- use prefix value
		encode = true,
		separator = '&amp;nbsp;',
		},
	['OCLC'] = {
		parameters = {'oclc', 'OCLC'},
		link = 'OCLC',
		redirect = 'OCLC (identifier)',
		q = 'Q190593',
		label = 'OCLC',
		prefix = 'https://search.worldcat.org/oclc/',
		COinS = 'info:oclcnum',
		encode = true,
		separator = '&amp;nbsp;',
		id_limit = id_limits_data_t.OCLC or 0,
		},
	['OL'] = {
		parameters = { 'ol', 'OL' },
		link = 'Open Library',
		redirect = 'OL (identifier)',
		q = 'Q1201876',
		label = 'OL',
		prefix = 'https://openlibrary.org/',
		COinS = 'url',
		separator = '&amp;nbsp;',
		encode = true,
		custom_access = 'ol-access',
		},
	['OSTI'] = {
		parameters = {'osti', 'OSTI'},
		link = 'Office of Scientific and Technical Information',
		redirect = 'OSTI (identifier)',
		q = 'Q2015776',
		label = 'OSTI',
		prefix = 'https://www.osti.gov/biblio/',
		COinS = 'pre',															-- use prefix value
		encode = true,
		separator = '&amp;nbsp;',
		id_limit = id_limits_data_t.OSTI or 0,
		custom_access = 'osti-access',
		},
	['PMC'] = {
		parameters = {'pmc', 'PMC'},
		link = 'PubMed Central',
		redirect = 'PMC (identifier)',
		q = 'Q229883',
		label = 'PMC',
		prefix = 'https://www.ncbi.nlm.nih.gov/pmc/articles/PMC',
		suffix = '',
		COinS = 'pre',															-- use prefix value
		encode = true,
		separator = '&amp;nbsp;',
		id_limit = id_limits_data_t.PMC or 0,
		access = 'free',														-- free to read
		},
	['PMID'] = {
		parameters = {'pmid', 'PMID'},
		link = 'PubMed Identifier',
		redirect = 'PMID (identifier)',
		q = 'Q2082879',
		label = 'PMID',
		prefix = 'https://pubmed.ncbi.nlm.nih.gov/',
		COinS = 'info:pmid',
		encode = false,
		separator = '&amp;nbsp;',
		id_limit = id_limits_data_t.PMID or 0,
		},
	['RFC'] = {
		parameters = {'rfc', 'RFC'},
		link = 'Request for Comments',
		redirect = 'RFC (identifier)',
		q = 'Q212971',
		label = 'RFC',
		prefix = 'https://tools.ietf.org/html/rfc',
		COinS = 'pre',															-- use prefix value
		encode = false,
		separator = '&amp;nbsp;',
		id_limit = id_limits_data_t.RFC or 0,
		access = 'free',														-- free to read
		},
	['SBN'] = {
		parameters = {'sbn', 'SBN'},
		link = 'Standard Book Number',											-- redirect to International_Standard_Book_Number#History
		redirect = 'SBN (identifier)',
		label = 'SBN',
		prefix = 'Special:BookSources/0-',										-- prefix has leading zero necessary to make 9-digit sbn a 10-digit isbn
		COinS = nil,															-- nil because we can't use pre or rft or info:
		separator = '&amp;nbsp;',
		},
	['SSRN'] = {
		parameters = {'ssrn', 'SSRN'},
		link = 'Social Science Research Network',
		redirect = 'SSRN (identifier)',
		q = 'Q7550801',
		label = 'SSRN',
		prefix = 'https://papers.ssrn.com/sol3/papers.cfm?abstract_id=',
		COinS = 'pre',															-- use prefix value
		encode = true,
		separator = '&amp;nbsp;',
		id_limit = id_limits_data_t.SSRN or 0,
		custom_access = 'ssrn-access',
		},
	['S2CID'] = {
		parameters = {'s2cid', 'S2CID'},
		link = 'Semantic Scholar',
		redirect = 'S2CID (identifier)',
		q = 'Q22908627',
		label = 'S2CID',
		prefix = 'https://api.semanticscholar.org/CorpusID:',
		COinS = 'pre',															-- use prefix value
		encode = false,
		separator = '&amp;nbsp;',
		id_limit = id_limits_data_t.S2CID or 0,
		custom_access = 's2cid-access',
		},
	['USENETID'] = {
		parameters = {'message-id'},
		link = 'Usenet',
		redirect = 'Usenet (identifier)',
		q = 'Q193162',
		label = 'Usenet:',
		prefix = 'news:',
		encode = false,
		COinS = 'pre',															-- use prefix value
		separator = '&amp;nbsp;',
		},
	['ZBL'] = {
		parameters = {'zbl', 'ZBL' },
		link = 'Zentralblatt MATH',
		redirect = 'Zbl (identifier)',
		q = 'Q190269',
		label = 'Zbl',
		prefix = 'https://zbmath.org/?format=complete&amp;q=an:',
		COinS = 'pre',															-- use prefix value
		encode = true,
		separator = '&amp;nbsp;',
		},
	}


--[[--------------------------&lt; E X P O R T S &gt;---------------------------------
]]

return 	{
	use_identifier_redirects = use_identifier_redirects,						-- booleans defined in the settings at the top of this module
	local_lang_cat_enable = local_lang_cat_enable,
	date_name_auto_xlate_enable = date_name_auto_xlate_enable,
	date_digit_auto_xlate_enable = date_digit_auto_xlate_enable,
	enable_sort_keys = enable_sort_keys,
	
																				-- tables and variables created when this module is loaded
	global_df = get_date_format (),												-- this line can be replaced with &quot;global_df = 'dmy-all',&quot; to have all dates auto translated to dmy format.
	global_cs1_config_t = global_cs1_config_t,									-- global settings from {{cs1 config}}
	punct_skip = build_skip_table (punct_skip, punct_meta_params),
	url_skip = build_skip_table (url_skip, url_meta_params),
	known_free_doi_registrants_t = build_free_doi_registrants_table(),
	id_limits_data_load_fail = id_limits_data_load_fail,						-- true when commons tabular identifier-limit data fails to load

	name_space_sort_keys = name_space_sort_keys,
	aliases = aliases,
	special_case_translation = special_case_translation,
	date_names = date_names,
	err_msg_supl = err_msg_supl,
	error_conditions = error_conditions,
	editor_markup_patterns = editor_markup_patterns,
	et_al_patterns = et_al_patterns,
	extended_registrants_t = extended_registrants_t,
	id_handlers = id_handlers,
	keywords_lists = keywords_lists,
	keywords_xlate = keywords_xlate,
	stripmarkers = stripmarkers,
	invisible_chars = invisible_chars,
	invisible_defs = invisible_defs,
	indic_script = indic_script,
	emoji_t = emoji_t,
	maint_cats = maint_cats,
	messages = messages,
	presentation = presentation,
	prop_cats = prop_cats,
	script_lang_codes = script_lang_codes,
	lang_tag_remap = lang_tag_remap,
	lang_name_remap = lang_name_remap,
	this_wiki_code = this_wiki_code,
	title_types = title_types,
	uncategorized_namespaces = uncategorized_namespaces_t,
	uncategorized_subpages = uncategorized_subpages,
	templates_using_volume = templates_using_volume,
	templates_using_issue = templates_using_issue,
	templates_not_using_page = templates_not_using_page,
	vol_iss_pg_patterns = vol_iss_pg_patterns,
	single_letter_2nd_lvl_domains_t = single_letter_2nd_lvl_domains_t,
	
	inter_wiki_map = inter_wiki_map,
	mw_languages_by_tag_t = mw_languages_by_tag_t,
	mw_languages_by_name_t = mw_languages_by_name_t,
	citation_class_map_t = citation_class_map_t,

	citation_issue_t = citation_issue_t,
	citation_no_volume_t = citation_no_volume_t,
	}</text>
      <sha1>24xlbhz6iwhfof94vtfyrgvcpi4o7uc</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Ibulungelo leencwadi</title>
    <ns>14</ns>
    <id>686</id>
    <revision>
      <id>3363</id>
      <timestamp>2025-07-09T12:35:20Z</timestamp>
      <contributor>
        <username>Roxanne2019</username>
        <id>755</id>
      </contributor>
      <comment>catagory about library</comment>
      <origin>3363</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="30" sha1="ilmv86w765vyshme2z4t01xrhtcarxy" xml:space="preserve">Mayelana nebulungelo leencwadi</text>
      <sha1>ilmv86w765vyshme2z4t01xrhtcarxy</sha1>
    </revision>
    <revision>
      <id>3364</id>
      <parentid>3363</parentid>
      <timestamp>2025-07-09T12:36:39Z</timestamp>
      <contributor>
        <username>Roxanne2019</username>
        <id>755</id>
      </contributor>
      <origin>3364</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="40" sha1="8ojvbk95hkdrnhklg1n4eegjktq3y27" xml:space="preserve">Mayelana nesakhiwo nebulungelo leencwadi</text>
      <sha1>8ojvbk95hkdrnhklg1n4eegjktq3y27</sha1>
    </revision>
    <revision>
      <id>3366</id>
      <parentid>3364</parentid>
      <timestamp>2025-07-09T12:41:20Z</timestamp>
      <contributor>
        <username>Roxanne2019</username>
        <id>755</id>
      </contributor>
      <origin>3366</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="42" sha1="5q4l12m7ntl35s0beuuvg1djrpeld1w" xml:space="preserve">Mayelana nezakhiwo zamabulungelo weencwadi</text>
      <sha1>5q4l12m7ntl35s0beuuvg1djrpeld1w</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Iinsetjenziswa zebulungelo leencwadi</title>
    <ns>14</ns>
    <id>687</id>
    <revision>
      <id>3365</id>
      <timestamp>2025-07-09T12:37:29Z</timestamp>
      <contributor>
        <username>Roxanne2019</username>
        <id>755</id>
      </contributor>
      <comment>Created page with &quot;Isetjenziswa bunjani ibulungelo leencwadi&quot;</comment>
      <origin>3365</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="41" sha1="jw2swppexvd3zcpso2zx0a74z1be6o9" xml:space="preserve">Isetjenziswa bunjani ibulungelo leencwadi</text>
      <sha1>jw2swppexvd3zcpso2zx0a74z1be6o9</sha1>
    </revision>
    <revision>
      <id>3367</id>
      <parentid>3365</parentid>
      <timestamp>2025-07-09T12:42:27Z</timestamp>
      <contributor>
        <username>Roxanne2019</username>
        <id>755</id>
      </contributor>
      <origin>3367</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="50" sha1="lg9porf1zwf5a33ic0lks7szhfdbqmk" xml:space="preserve">Indlela amabulungelo weencwadi asetjenziswa ngayo.</text>
      <sha1>lg9porf1zwf5a33ic0lks7szhfdbqmk</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Thuvack</title>
    <ns>2</ns>
    <id>688</id>
    <revision>
      <id>3373</id>
      <timestamp>2025-07-11T10:43:59Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Created User Page</comment>
      <origin>3373</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4036" sha1="5fs2pfyz55mvyx5bhijuv73pd4bge6v" xml:space="preserve">__NOTOC__ __NOEDITSECTION__
&lt;!--------------------------------&gt;
&lt;!--        My User Page        --&gt;
&lt;!--------------------------------&gt;
&lt;div style=&quot;background:#ccccff; text-align:center&quot;&gt;
'''Thank you for visiting my user page, I am known as Thuvack here at the English Wikipedia. This page holds some basic facts about me and my involvement with Wikipedia. I will route some links to my wikiversity user page to avoid repeat posting.'''&lt;center&gt;&lt;small&gt;''This Page/sub-page and all other pages related to me are part of Wikipedia and are released under GNU Licence''&lt;/small&gt;.&lt;/center&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom:.7em; padding:.5em; text-align:left; font-weight:normal; font-size:100%; background:#white; border:1px solid #ccccff&quot;&gt;
&lt;div style=&quot;position: relative; z-index: 3; width: 620px; height: 420px; margin: 0 auto; font-size: 11pt;&quot;&gt;
&lt;!--

--&gt;&lt;div style=&quot;position: absolute; z-index: 1; left: 250px; top: 10px&quot;&gt;
&lt;p style=&quot;text-align:center;&quot;&gt;[[Image:128px-Nuvola_man_icon.png|40px]]&amp;nbsp;&lt;br&gt;[[wikiversity:User:Thuvack/Quote_Thuvack|About me]]&lt;br&gt;[[wikiversity:User:Thuvack/Mind-Logs|My Blog]]&lt;/p&gt;&lt;/div&gt;
&lt;!--

--&gt;&lt;div style=&quot;position: absolute; z-index: 1; left: 10px; top: 125px&quot;&gt;
&lt;p style=&quot;text-align:right;&quot;&gt;[[W:ts:User:Thuvack|Xitsonga Wikipedia]]. .[[Image:Wikipedia-logo.png|32px]]&lt;BR&gt;&lt;br&gt;[http://en.wikipedia.beta.wmflabs.org/wiki/User:Thuvack Beta Translate Wikipedia]&lt;BR&gt;&lt;br&gt;[[wikiversity:User:Thuvack|Wikiverstiy]]. .[[Image:Wikiversity-logo.svg|32px]]&lt;BR&gt;&lt;br&gt;[[commons:User:Thuvack|Commons]]. .[[Image:Commons-logo.svg|24px]]&lt;/p&gt;&lt;/div&gt;
&lt;!--

--&gt;&lt;div style=&quot;position: absolute; z-index: 1; left: 400px; top: 150px&quot;&gt;
&lt;p style=&quot;text-align:left;&quot;&gt;[[Image:Crystal_128_kuser.png|32px]]&amp;nbsp;&lt;br&gt;[[User:Thuvack/Contribute_Thuvack|Active Projects]]&lt;br&gt;[[User:Thuvack/Templates_Thuvack|My Templates]]&lt;br&gt;[[User:Thuvack/Testing page|Sand Boxes]]&lt;br&gt;[[User:Thuvack/My Books|Book Read List]]&lt;/p&gt;&lt;/div&gt;
&lt;!-- 
--&gt;&lt;div style=&quot;position: absolute; z-index: 1; left: 200px; top: 100px&quot;&gt;
[[Image:Thuvack.png|150px]]
&lt;/div&gt;&lt;/div&gt;
&lt;!----&gt;
&lt;div style=&quot;background:#ffde89; text-align:center&quot;&gt;
{{#switch: {{CURRENTDOW}}
 |0=&lt;p style=&quot;text-align:center;&quot;&gt;&quot;I want to know God's thoughts... the rest is detail&quot; -[[w:Albert Einstein|Albert Einstein]]&lt;/p&gt;
 |1=&lt;p style=&quot;text-align:center;&quot;&gt;&quot;Many will call me an adventurer – and that I am, only one of a different sort: one of those who risks his skin to prove his platitudes&quot; -[[w:Che Guevara|Che Guevara]]&lt;/p&gt;
 |2=&lt;p style=&quot;text-align:center;&quot;&gt;&quot;You are either alive and proud or you are dead, and when you are dead, you can't care anyway&quot; -[[w:Steven Biko|Steven Biko]]&lt;/p&gt;
 |3=&lt;p style=&quot;text-align:center;&quot;&gt;&quot;For to be free is not merely to cast off one's chains, but to live in a way that respects and enhances the freedom of others.&quot; -[[w:Nelson Mandela|Nelson Mandela]]&lt;/p&gt;
 |4=&lt;p style=&quot;text-align:center;&quot;&gt;&quot;We have finished the job, what shall we do with the tools?&quot; -[[w:Haile Selassie|Haile Selassie]]&lt;/p&gt;
 |5=&lt;p style=&quot;text-align:center;&quot;&gt;&quot;Be thou incapable of change in that which is right, and men will rely upon thee. Establish unto thyself principles of action; and see that thou ever act according to them. First know that thy principles are just, and then be thou.&quot; -[[w:Akhenaton|Akhenaton]]&lt;/p&gt;
 |6=&lt;p style=&quot;text-align:center;&quot;&gt;&quot;I am an Afrikan&quot; -[[w:Thabo Mbeki|Thabo Mbeki]]&lt;/p&gt;
}}&lt;/small&gt;.&lt;/center&gt;&lt;/div&gt;
----
&lt;!----&gt;
{| class=&quot;wikitable&quot; style=&quot;margin: 1em auto 1em auto; background:#ccccff;&quot;
! scope=&quot;col&quot; | [[User:Thuvack/Pages_Created|Pages I created]][[image:Nuvola_apps_korganizer.png|10px]]
! scope=&quot;col&quot; | [[User:Thuvack/Todo_Thuvack|Completed Tasks]][[image:Nuvola_apps_korganizer.png|10px]]
! scope=&quot;col&quot; | [[User:Thuvack/Activist_Thuvack|To-Do List]][[Image:Broom_icon.svg|10px]]  
! scope=&quot;col&quot; | [[Special:EmailUser/Thuvack|e-Mail me]][[image:Crystal_Clear_app_xfmail.png|10px]]
! scope=&quot;col&quot; | [[User:Thuvack/Short-Cuts|My Short Cuts]]
|}&lt;/div&gt;

{{User ZA Politics Task Force}}
{{User Wikipedian For|year=2008|month=07|day=22}}
{{User contrib|946|Thuvack}}</text>
      <sha1>5fs2pfyz55mvyx5bhijuv73pd4bge6v</sha1>
    </revision>
    <revision>
      <id>3374</id>
      <parentid>3373</parentid>
      <timestamp>2025-07-11T10:47:09Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <origin>3374</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3777" sha1="mrvkkzwucm0juetgup15rgsvg4cb362" xml:space="preserve">__NOTOC__ __NOEDITSECTION__
&lt;!--------------------------------&gt;
&lt;!--        My User Page        --&gt;
&lt;!--------------------------------&gt;
&lt;div style=&quot;background:#ccccff; text-align:center&quot;&gt;
'''Thank you for visiting my user page, I am known as Thuvack here at the English Wikipedia. This page holds some basic facts about me and my involvement with Wikipedia. I will route some links to my wikiversity user page to avoid repeat posting.'''&lt;center&gt;&lt;small&gt;''This Page/sub-page and all other pages related to me are part of Wikipedia and are released under GNU Licence''&lt;/small&gt;.&lt;/center&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom:.7em; padding:.5em; text-align:left; font-weight:normal; font-size:100%; background:#white; border:1px solid #ccccff&quot;&gt;
&lt;div style=&quot;position: relative; z-index: 3; width: 620px; height: 420px; margin: 0 auto; font-size: 11pt;&quot;&gt;
&lt;!--

--&gt;&lt;div style=&quot;position: absolute; z-index: 1; left: 250px; top: 10px&quot;&gt;
&lt;p style=&quot;text-align:center;&quot;&gt;[[Image:128px-Nuvola_man_icon.png|40px]]&amp;nbsp;&lt;br&gt;[[wikiversity:User:Thuvack/Quote_Thuvack|About me]]&lt;br&gt;[[wikiversity:User:Thuvack/Mind-Logs|My Blog]]&lt;/p&gt;&lt;/div&gt;
&lt;!--

--&gt;&lt;div style=&quot;position: absolute; z-index: 1; left: 10px; top: 125px&quot;&gt;
&lt;p style=&quot;text-align:right;&quot;&gt;[[W:ts:User:Thuvack|Xitsonga Wikipedia]]. .[[Image:Wikipedia-logo.png|32px]]&lt;BR&gt;&lt;br&gt;[http://en.wikipedia.beta.wmflabs.org/wiki/User:Thuvack Beta Translate Wikipedia]&lt;BR&gt;&lt;br&gt;[[wikiversity:User:Thuvack|Wikiverstiy]]. .[[Image:Wikiversity-logo.svg|32px]]&lt;BR&gt;&lt;br&gt;[[commons:User:Thuvack|Commons]]. .[[Image:Commons-logo.svg|24px]]&lt;/p&gt;&lt;/div&gt;
&lt;!--

--&gt;&lt;div style=&quot;position: absolute; z-index: 1; left: 400px; top: 40px&quot;&gt;
&lt;p style=&quot;text-align:left;&quot;&gt;{{#Babel:ts|en-5|nr-1|MediaWiki|Administrator}}{{User WikiUser|year=2008|month=07|day=17}}&lt;/p&gt;&lt;/div&gt;
&lt;!-- 
--&gt;&lt;div style=&quot;position: absolute; z-index: 1; left: 200px; top: 100px&quot;&gt;
[[Image:Thuvack.png|150px]]
&lt;/div&gt;&lt;/div&gt;
&lt;!----&gt;
&lt;div style=&quot;background:#ffde89; text-align:center&quot;&gt;
{{#switch: {{CURRENTDOW}}
 |0=&lt;p style=&quot;text-align:center;&quot;&gt;&quot;I want to know God's thoughts... the rest is detail&quot; -[[w:Albert Einstein|Albert Einstein]]&lt;/p&gt;
 |1=&lt;p style=&quot;text-align:center;&quot;&gt;&quot;Many will call me an adventurer – and that I am, only one of a different sort: one of those who risks his skin to prove his platitudes&quot; -[[w:Che Guevara|Che Guevara]]&lt;/p&gt;
 |2=&lt;p style=&quot;text-align:center;&quot;&gt;&quot;You are either alive and proud or you are dead, and when you are dead, you can't care anyway&quot; -[[w:Steven Biko|Steven Biko]]&lt;/p&gt;
 |3=&lt;p style=&quot;text-align:center;&quot;&gt;&quot;For to be free is not merely to cast off one's chains, but to live in a way that respects and enhances the freedom of others.&quot; -[[w:Nelson Mandela|Nelson Mandela]]&lt;/p&gt;
 |4=&lt;p style=&quot;text-align:center;&quot;&gt;&quot;We have finished the job, what shall we do with the tools?&quot; -[[w:Haile Selassie|Haile Selassie]]&lt;/p&gt;
 |5=&lt;p style=&quot;text-align:center;&quot;&gt;&quot;Be thou incapable of change in that which is right, and men will rely upon thee. Establish unto thyself principles of action; and see that thou ever act according to them. First know that thy principles are just, and then be thou.&quot; -[[w:Akhenaton|Akhenaton]]&lt;/p&gt;
 |6=&lt;p style=&quot;text-align:center;&quot;&gt;&quot;I am an Afrikan&quot; -[[w:Thabo Mbeki|Thabo Mbeki]]&lt;/p&gt;
}}&lt;/small&gt;.&lt;/center&gt;&lt;/div&gt;
----
&lt;!----&gt;
{| class=&quot;wikitable&quot; style=&quot;margin: 1em auto 1em auto; background:#ccccff;&quot;
! scope=&quot;col&quot; | [[User:Thuvack/Pages_Created|Pages I created]][[image:Nuvola_apps_korganizer.png|10px]]
! scope=&quot;col&quot; | [[User:Thuvack/Todo_Thuvack|Completed Tasks]][[image:Nuvola_apps_korganizer.png|10px]]
! scope=&quot;col&quot; | [[User:Thuvack/Activist_Thuvack|To-Do List]][[Image:Broom_icon.svg|10px]]  
! scope=&quot;col&quot; | [[Special:EmailUser/Thuvack|e-Mail me]][[image:Crystal_Clear_app_xfmail.png|10px]]
! scope=&quot;col&quot; | [[User:Thuvack/Short-Cuts|My Short Cuts]]
|}&lt;/div&gt;</text>
      <sha1>mrvkkzwucm0juetgup15rgsvg4cb362</sha1>
    </revision>
    <revision>
      <id>3391</id>
      <parentid>3374</parentid>
      <timestamp>2025-07-11T11:23:31Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <origin>3391</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3733" sha1="j2h3szpnx5b3gzh9sszxuluiiymtopz" xml:space="preserve">__NOTOC__ __NOEDITSECTION__
&lt;!--------------------------------&gt;
&lt;!--        My User Page        --&gt;
&lt;!--------------------------------&gt;
&lt;div style=&quot;background:#ccccff; text-align:center&quot;&gt;
'''Thank you for visiting my user page, I am known as Thuvack here at the English Wikipedia. This page holds some basic facts about me and my involvement with Wikipedia. I will route some links to my wikiversity user page to avoid repeat posting.'''&lt;center&gt;&lt;small&gt;''This Page/sub-page and all other pages related to me are part of Wikipedia and are released under GNU Licence''&lt;/small&gt;.&lt;/center&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom:.7em; padding:.5em; text-align:left; font-weight:normal; font-size:100%; background:#white; border:1px solid #ccccff&quot;&gt;
&lt;div style=&quot;position: relative; z-index: 3; width: 620px; height: 420px; margin: 0 auto; font-size: 11pt;&quot;&gt;
&lt;!--

--&gt;&lt;div style=&quot;position: absolute; z-index: 1; left: 250px; top: 10px&quot;&gt;
&lt;p style=&quot;text-align:center;&quot;&gt;[[Image:128px-Nuvola_man_icon.png|40px]]&amp;nbsp;&lt;br&gt;[[wikiversity:User:Thuvack/Quote_Thuvack|About me]]&lt;br&gt;[[wikiversity:User:Thuvack/Mind-Logs|My Blog]]&lt;/p&gt;&lt;/div&gt;
&lt;!--

--&gt;&lt;div style=&quot;position: absolute; z-index: 1; left: 10px; top: 125px&quot;&gt;
&lt;p style=&quot;text-align:right;&quot;&gt;[[W:ts:User:Thuvack|Xitsonga Wikipedia]]. .[[Image:Wikipedia-logo.png|32px]]&lt;BR&gt;&lt;br&gt;[http://en.wikipedia.beta.wmflabs.org/wiki/User:Thuvack Beta Translate Wikipedia]&lt;BR&gt;&lt;br&gt;[[wikiversity:User:Thuvack|Wikiverstiy]]. .[[Image:Wikiversity-logo.svg|32px]]&lt;BR&gt;&lt;br&gt;[[commons:User:Thuvack|Commons]]. .[[Image:Commons-logo.svg|24px]]&lt;/p&gt;&lt;/div&gt;
&lt;!--

--&gt;&lt;div style=&quot;position: absolute; z-index: 1; left: 400px; top: 40px&quot;&gt;
&lt;p style=&quot;text-align:left;&quot;&gt;{{#Babel:ts|nr-1|Administrator}}{{User WikiUser|year=2008|month=07|day=17}}&lt;/p&gt;&lt;/div&gt;
&lt;!-- 
--&gt;&lt;div style=&quot;position: absolute; z-index: 1; left: 200px; top: 100px&quot;&gt;
[[Image:Thuvack.png|150px]]
&lt;/div&gt;&lt;/div&gt;
&lt;!----&gt;
&lt;div style=&quot;background:#ffde89; text-align:center&quot;&gt;
{{#switch: {{CURRENTDOW}}
 |0=&lt;p style=&quot;text-align:center;&quot;&gt;&quot;I want to know God's thoughts... the rest is detail&quot; -[[w:Albert Einstein|Albert Einstein]]&lt;/p&gt;
 |1=&lt;p style=&quot;text-align:center;&quot;&gt;&quot;Many will call me an adventurer – and that I am, only one of a different sort: one of those who risks his skin to prove his platitudes&quot; -[[w:Che Guevara|Che Guevara]]&lt;/p&gt;
 |2=&lt;p style=&quot;text-align:center;&quot;&gt;&quot;You are either alive and proud or you are dead, and when you are dead, you can't care anyway&quot; -[[w:Steven Biko|Steven Biko]]&lt;/p&gt;
 |3=&lt;p style=&quot;text-align:center;&quot;&gt;&quot;For to be free is not merely to cast off one's chains, but to live in a way that respects and enhances the freedom of others.&quot; -[[w:Nelson Mandela|Nelson Mandela]]&lt;/p&gt;
 |4=&lt;p style=&quot;text-align:center;&quot;&gt;&quot;We have finished the job, what shall we do with the tools?&quot; -[[w:Haile Selassie|Haile Selassie]]&lt;/p&gt;
 |5=&lt;p style=&quot;text-align:center;&quot;&gt;&quot;Be thou incapable of change in that which is right, and men will rely upon thee. Establish unto thyself principles of action; and see that thou ever act according to them. First know that thy principles are just, and then be thou.&quot; -[[w:Akhenaton|Akhenaton]]&lt;/p&gt;
 |6=&lt;p style=&quot;text-align:center;&quot;&gt;&quot;I am an Afrikan&quot; -[[w:Thabo Mbeki|Thabo Mbeki]]&lt;/p&gt;
}}&lt;/small&gt;.&lt;/center&gt;&lt;/div&gt;
----
&lt;!----&gt;
{| class=&quot;wikitable&quot; style=&quot;margin: 1em auto 1em auto; background:#ccccff;&quot;
! scope=&quot;col&quot; | [[User:Thuvack/Short-Cuts|My Short Cuts]]
! scope=&quot;col&quot; | [[User:Thuvack/Draft1|Draft #1]][[image:Nuvola_apps_korganizer.png|10px]]
! scope=&quot;col&quot; | [[User:Thuvack/Draft2|Draft #2]][[image:Nuvola_apps_korganizer.png|10px]]
! scope=&quot;col&quot; | [[User:Thuvack/Draft3|Draft #3]][[image:Nuvola_apps_korganizer.png|10px]]
! scope=&quot;col&quot; | [[Special:EmailUser/Thuvack|e-Mail me]][[image:Crystal_Clear_app_xfmail.png|10px]]
|}&lt;/div&gt;</text>
      <sha1>j2h3szpnx5b3gzh9sszxuluiiymtopz</sha1>
    </revision>
    <revision>
      <id>3394</id>
      <parentid>3391</parentid>
      <timestamp>2025-07-11T11:37:37Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <origin>3394</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3733" sha1="s4j0aicbh8hcm5xmrhovdz4j97a6cjn" xml:space="preserve">__NOTOC__ __NOEDITSECTION__
&lt;!--------------------------------&gt;
&lt;!--        My User Page        --&gt;
&lt;!--------------------------------&gt;
&lt;div style=&quot;background:#ccccff; text-align:center&quot;&gt;
'''Thank you for visiting my user page, I am known as Thuvack here at the English Wikipedia. This page holds some basic facts about me and my involvement with Wikipedia. I will route some links to my wikiversity user page to avoid repeat posting.'''&lt;center&gt;&lt;small&gt;''This Page/sub-page and all other pages related to me are part of Wikipedia and are released under GNU Licence''&lt;/small&gt;.&lt;/center&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom:.7em; padding:.5em; text-align:left; font-weight:normal; font-size:100%; background:#white; border:1px solid #ccccff&quot;&gt;
&lt;div style=&quot;position: relative; z-index: 3; width: 620px; height: 420px; margin: 0 auto; font-size: 11pt;&quot;&gt;
&lt;!--

--&gt;&lt;div style=&quot;position: absolute; z-index: 1; left: 250px; top: 10px&quot;&gt;
&lt;p style=&quot;text-align:center;&quot;&gt;[[Image:128px-Nuvola_man_icon.png|40px]]&amp;nbsp;&lt;br&gt;[[wikiversity:User:Thuvack/Quote_Thuvack|About me]]&lt;br&gt;[[wikiversity:User:Thuvack/Mind-Logs|My Blog]]&lt;/p&gt;&lt;/div&gt;
&lt;!--

--&gt;&lt;div style=&quot;position: absolute; z-index: 1; left: 10px; top: 125px&quot;&gt;
&lt;p style=&quot;text-align:right;&quot;&gt;[[W:ts:User:Thuvack|Xitsonga Wikipedia]]. .[[Image:Wikipedia-logo.png|32px]]&lt;BR&gt;&lt;br&gt;[http://en.wikipedia.beta.wmflabs.org/wiki/User:Thuvack Beta Translate Wikipedia]&lt;BR&gt;&lt;br&gt;[[wikiversity:User:Thuvack|Wikiverstiy]]. .[[Image:Wikiversity-logo.svg|32px]]&lt;BR&gt;&lt;br&gt;[[commons:User:Thuvack|Commons]]. .[[Image:Commons-logo.svg|24px]]&lt;/p&gt;&lt;/div&gt;
&lt;!--

--&gt;&lt;div style=&quot;position: absolute; z-index: 1; left: 400px; top: 40px&quot;&gt;
&lt;p style=&quot;text-align:left;&quot;&gt;{{#Babel:ts|nr-1|Administrator}}{{User WikiUser|year=2016|month=02|day=20}}&lt;/p&gt;&lt;/div&gt;
&lt;!-- 
--&gt;&lt;div style=&quot;position: absolute; z-index: 1; left: 200px; top: 100px&quot;&gt;
[[Image:Thuvack.png|150px]]
&lt;/div&gt;&lt;/div&gt;
&lt;!----&gt;
&lt;div style=&quot;background:#ffde89; text-align:center&quot;&gt;
{{#switch: {{CURRENTDOW}}
 |0=&lt;p style=&quot;text-align:center;&quot;&gt;&quot;I want to know God's thoughts... the rest is detail&quot; -[[w:Albert Einstein|Albert Einstein]]&lt;/p&gt;
 |1=&lt;p style=&quot;text-align:center;&quot;&gt;&quot;Many will call me an adventurer – and that I am, only one of a different sort: one of those who risks his skin to prove his platitudes&quot; -[[w:Che Guevara|Che Guevara]]&lt;/p&gt;
 |2=&lt;p style=&quot;text-align:center;&quot;&gt;&quot;You are either alive and proud or you are dead, and when you are dead, you can't care anyway&quot; -[[w:Steven Biko|Steven Biko]]&lt;/p&gt;
 |3=&lt;p style=&quot;text-align:center;&quot;&gt;&quot;For to be free is not merely to cast off one's chains, but to live in a way that respects and enhances the freedom of others.&quot; -[[w:Nelson Mandela|Nelson Mandela]]&lt;/p&gt;
 |4=&lt;p style=&quot;text-align:center;&quot;&gt;&quot;We have finished the job, what shall we do with the tools?&quot; -[[w:Haile Selassie|Haile Selassie]]&lt;/p&gt;
 |5=&lt;p style=&quot;text-align:center;&quot;&gt;&quot;Be thou incapable of change in that which is right, and men will rely upon thee. Establish unto thyself principles of action; and see that thou ever act according to them. First know that thy principles are just, and then be thou.&quot; -[[w:Akhenaton|Akhenaton]]&lt;/p&gt;
 |6=&lt;p style=&quot;text-align:center;&quot;&gt;&quot;I am an Afrikan&quot; -[[w:Thabo Mbeki|Thabo Mbeki]]&lt;/p&gt;
}}&lt;/small&gt;.&lt;/center&gt;&lt;/div&gt;
----
&lt;!----&gt;
{| class=&quot;wikitable&quot; style=&quot;margin: 1em auto 1em auto; background:#ccccff;&quot;
! scope=&quot;col&quot; | [[User:Thuvack/Short-Cuts|My Short Cuts]]
! scope=&quot;col&quot; | [[User:Thuvack/Draft1|Draft #1]][[image:Nuvola_apps_korganizer.png|10px]]
! scope=&quot;col&quot; | [[User:Thuvack/Draft2|Draft #2]][[image:Nuvola_apps_korganizer.png|10px]]
! scope=&quot;col&quot; | [[User:Thuvack/Draft3|Draft #3]][[image:Nuvola_apps_korganizer.png|10px]]
! scope=&quot;col&quot; | [[Special:EmailUser/Thuvack|e-Mail me]][[image:Crystal_Clear_app_xfmail.png|10px]]
|}&lt;/div&gt;</text>
      <sha1>s4j0aicbh8hcm5xmrhovdz4j97a6cjn</sha1>
    </revision>
    <revision>
      <id>6298</id>
      <parentid>3394</parentid>
      <timestamp>2026-03-14T16:38:50Z</timestamp>
      <contributor>
        <username>Àncilu</username>
        <id>1416</id>
      </contributor>
      <comment>[[Khethekileko:LintErrors/obsolete-tag]]</comment>
      <origin>6298</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3755" sha1="9cbqiqvjbbd50ldc2hzb10unvcbybge" xml:space="preserve">__NOTOC__ __NOEDITSECTION__
&lt;!--------------------------------&gt;
&lt;!--        My User Page        --&gt;
&lt;!--------------------------------&gt;
&lt;div style=&quot;background:#ccccff; text-align:center&quot;&gt;
'''Thank you for visiting my user page, I am known as Thuvack here at the English Wikipedia. This page holds some basic facts about me and my involvement with Wikipedia. I will route some links to my wikiversity user page to avoid repeat posting.'''&lt;div style=&quot;text-align: center;&quot;&gt;&lt;small&gt;''This Page/sub-page and all other pages related to me are part of Wikipedia and are released under GNU Licence''&lt;/small&gt;.&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom:.7em; padding:.5em; text-align:left; font-weight:normal; font-size:100%; background:#white; border:1px solid #ccccff&quot;&gt;
&lt;div style=&quot;position: relative; z-index: 3; width: 620px; height: 420px; margin: 0 auto; font-size: 11pt;&quot;&gt;
&lt;!--

--&gt;&lt;div style=&quot;position: absolute; z-index: 1; left: 250px; top: 10px&quot;&gt;
&lt;p style=&quot;text-align:center;&quot;&gt;[[Image:128px-Nuvola_man_icon.png|40px]]&amp;nbsp;&lt;br&gt;[[wikiversity:User:Thuvack/Quote_Thuvack|About me]]&lt;br&gt;[[wikiversity:User:Thuvack/Mind-Logs|My Blog]]&lt;/p&gt;&lt;/div&gt;
&lt;!--

--&gt;&lt;div style=&quot;position: absolute; z-index: 1; left: 10px; top: 125px&quot;&gt;
&lt;p style=&quot;text-align:right;&quot;&gt;[[W:ts:User:Thuvack|Xitsonga Wikipedia]]. .[[Image:Wikipedia-logo.png|32px]]&lt;BR&gt;&lt;br&gt;[http://en.wikipedia.beta.wmflabs.org/wiki/User:Thuvack Beta Translate Wikipedia]&lt;BR&gt;&lt;br&gt;[[wikiversity:User:Thuvack|Wikiverstiy]]. .[[Image:Wikiversity-logo.svg|32px]]&lt;BR&gt;&lt;br&gt;[[commons:User:Thuvack|Commons]]. .[[Image:Commons-logo.svg|24px]]&lt;/p&gt;&lt;/div&gt;
&lt;!--

--&gt;&lt;div style=&quot;position: absolute; z-index: 1; left: 400px; top: 40px&quot;&gt;
&lt;p style=&quot;text-align:left;&quot;&gt;{{#Babel:ts|nr-1|Administrator}}{{User WikiUser|year=2016|month=02|day=20}}&lt;/p&gt;&lt;/div&gt;
&lt;!-- 
--&gt;&lt;div style=&quot;position: absolute; z-index: 1; left: 200px; top: 100px&quot;&gt;
[[Image:Thuvack.png|150px]]
&lt;/div&gt;&lt;/div&gt;
&lt;!----&gt;
&lt;div style=&quot;background:#ffde89; text-align:center&quot;&gt;
{{#switch: {{CURRENTDOW}}
 |0=&lt;p style=&quot;text-align:center;&quot;&gt;&quot;I want to know God's thoughts... the rest is detail&quot; -[[w:Albert Einstein|Albert Einstein]]&lt;/p&gt;
 |1=&lt;p style=&quot;text-align:center;&quot;&gt;&quot;Many will call me an adventurer – and that I am, only one of a different sort: one of those who risks his skin to prove his platitudes&quot; -[[w:Che Guevara|Che Guevara]]&lt;/p&gt;
 |2=&lt;p style=&quot;text-align:center;&quot;&gt;&quot;You are either alive and proud or you are dead, and when you are dead, you can't care anyway&quot; -[[w:Steven Biko|Steven Biko]]&lt;/p&gt;
 |3=&lt;p style=&quot;text-align:center;&quot;&gt;&quot;For to be free is not merely to cast off one's chains, but to live in a way that respects and enhances the freedom of others.&quot; -[[w:Nelson Mandela|Nelson Mandela]]&lt;/p&gt;
 |4=&lt;p style=&quot;text-align:center;&quot;&gt;&quot;We have finished the job, what shall we do with the tools?&quot; -[[w:Haile Selassie|Haile Selassie]]&lt;/p&gt;
 |5=&lt;p style=&quot;text-align:center;&quot;&gt;&quot;Be thou incapable of change in that which is right, and men will rely upon thee. Establish unto thyself principles of action; and see that thou ever act according to them. First know that thy principles are just, and then be thou.&quot; -[[w:Akhenaton|Akhenaton]]&lt;/p&gt;
 |6=&lt;p style=&quot;text-align:center;&quot;&gt;&quot;I am an Afrikan&quot; -[[w:Thabo Mbeki|Thabo Mbeki]]&lt;/p&gt;
}}&lt;/small&gt;.&lt;/center&gt;&lt;/div&gt;
----
&lt;!----&gt;
{| class=&quot;wikitable&quot; style=&quot;margin: 1em auto 1em auto; background:#ccccff;&quot;
! scope=&quot;col&quot; | [[User:Thuvack/Short-Cuts|My Short Cuts]]
! scope=&quot;col&quot; | [[User:Thuvack/Draft1|Draft #1]][[image:Nuvola_apps_korganizer.png|10px]]
! scope=&quot;col&quot; | [[User:Thuvack/Draft2|Draft #2]][[image:Nuvola_apps_korganizer.png|10px]]
! scope=&quot;col&quot; | [[User:Thuvack/Draft3|Draft #3]][[image:Nuvola_apps_korganizer.png|10px]]
! scope=&quot;col&quot; | [[Special:EmailUser/Thuvack|e-Mail me]][[image:Crystal_Clear_app_xfmail.png|10px]]
|}&lt;/div&gt;</text>
      <sha1>9cbqiqvjbbd50ldc2hzb10unvcbybge</sha1>
    </revision>
  </page>
  <page>
    <title>Wikiphidiya:Babel</title>
    <ns>4</ns>
    <id>689</id>
    <revision>
      <id>3375</id>
      <timestamp>2025-07-11T10:49:19Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Created summary of Babel</comment>
      <origin>3375</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="356" sha1="m2447xn52uoancrmgrbr4poqzrys446" xml:space="preserve">Ku-Wikipedia, ibizo elithi Babel (elihlobene ne-Tower of Babel) lihlathulula izakhiwo ezisebenzako zeenlimi ezikhulunywa msebenzisi begodu lisiza ukukhulumisana hlangana nabasebenzisi be-Wikipedia, begodu irhelebha ukuhlanganisa abasebenzisi belimi elifanako. Uyacelwa bona uhlanganyele emsebenzini lo, ngokubeka umsebenzi welimi ekhasini lakho lomsebenzi.</text>
      <sha1>m2447xn52uoancrmgrbr4poqzrys446</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:User MediaWiki</title>
    <ns>10</ns>
    <id>690</id>
    <revision>
      <id>3376</id>
      <timestamp>2025-07-11T10:51:04Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Created page with &quot;{{userbox | border-c = #bbb | id       = [[Image:MediaWiki.svg|40px]] | id-c     = #fff | info     = This user has '''[[MW:User:{{{1|{{BASEPAGENAME}}}}}|{{{2|a page}}}]]''' on [[MW:|MediaWiki]]. | info-c   = #f6f6f6 }}&lt;noinclude&gt; [[Category:Wikipedia-related user templates]] &lt;/noinclude&gt;&quot;</comment>
      <origin>3376</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="288" sha1="sxythvnirlgpyoall7dvj3h3py0a6wl" xml:space="preserve">{{userbox
| border-c = #bbb
| id       = [[Image:MediaWiki.svg|40px]]
| id-c     = #fff
| info     = This user has '''[[MW:User:{{{1|{{BASEPAGENAME}}}}}|{{{2|a page}}}]]''' on [[MW:|MediaWiki]].
| info-c   = #f6f6f6
}}&lt;noinclude&gt;
[[Category:Wikipedia-related user templates]]
&lt;/noinclude&gt;</text>
      <sha1>sxythvnirlgpyoall7dvj3h3py0a6wl</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Userbox</title>
    <ns>10</ns>
    <id>691</id>
    <revision>
      <id>3377</id>
      <timestamp>2025-07-11T10:51:36Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Created page with &quot;&lt;div style=&quot;float:{{{float|left}}}; border:{{{border-width|{{{border-s|1}}}}}}px solid {{{border-color|{{{1|{{{border-c|{{{id-c|#999}}}}}}}}}}}}; margin:1px; width:240px; {{css3|box-sizing: border-box}}&quot; class=&quot;wikipediauserbox {{{bodyclass|}}}&quot;&gt; {| cellspacing=&quot;0&quot; style=&quot; width:100%; margin-bottom:0; background:{{{info-background|{{{2|{{{info-c|#EEE}}}}}}}}}&quot; {{#if:{{{logo|{{{3|{{{id|id}}}}}}}}}| ! style=&quot;width:{{{logo-width|{{{id-w|45}}}}}}px; height:{{{logo-height|{{{...&quot;</comment>
      <origin>3377</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1994" sha1="k7z3x1a6pqzvaeu8epjbrbk2ebz0cgk" xml:space="preserve">&lt;div style=&quot;float:{{{float|left}}}; border:{{{border-width|{{{border-s|1}}}}}}px solid {{{border-color|{{{1|{{{border-c|{{{id-c|#999}}}}}}}}}}}}; margin:1px; width:240px; {{css3|box-sizing: border-box}}&quot; class=&quot;wikipediauserbox {{{bodyclass|}}}&quot;&gt;
{| cellspacing=&quot;0&quot; style=&quot; width:100%; margin-bottom:0; background:{{{info-background|{{{2|{{{info-c|#EEE}}}}}}}}}&quot;
{{#if:{{{logo|{{{3|{{{id|id}}}}}}}}}|
! style=&quot;width:{{{logo-width|{{{id-w|45}}}}}}px; height:{{{logo-height|{{{id-h|45}}}}}}px; background:{{{logo-background|{{{1|{{{id-c|#DDD}}}}}}}}}; text-align:{{{id-a|center}}}; font-size:{{{logo-size|{{{5|{{{id-s|14}}}}}}}}}pt; color:{{{logo-color|{{{id-fc|black}}}}}}; padding:{{{logo-padding|{{{id-p|0 1px 0 0}}}}}}; line-height:{{{logo-line-height|{{{id-lh|1.25em}}}}}}; vertical-align: middle; {{{logo-other-param|{{{id-op|}}}}}}&quot; {{#if:{{{id-class|}}}|class=&quot;{{{id-class}}}&quot;}} {{!}} {{{logo|{{{3|{{{id|id}}}}}}}}}
}}
| style=&quot;text-align:{{{info-a|left}}}; font-size:{{{info-size|{{{info-s|8}}}}}}pt; padding:{{{info-padding|{{{info-p|0 4px 0 4px}}}}}}; height:{{{logo-height|{{{id-h|45}}}}}}px; line-height:{{{info-line-height|{{{info-lh|1.25em}}}}}}; color:{{{info-color|{{{info-fc|black}}}}}}; vertical-align: middle; {{{info-other-param|{{{info-op|}}}}}}&quot; {{#if:{{{info-class|}}}|class=&quot;{{{info-class}}}&quot;}} | {{{info|{{{4|''info''}}}}}}
|}&lt;/div&gt;{{#if:{{{usercategory|}}}{{{usercategory2|}}}{{{usercategory3|}}}|{{category handler
 |nocat = {{{nocat|}}}
 |subpage = {{#if:{{{nocatsubpages|}}}|no}}
 |user = {{#if:{{{usercategory|}}}|[[Category:{{{usercategory}}}]]}}{{#if:{{{usercategory2|}}}|[[Category:{{{usercategory2}}}]]}}{{#if:{{{usercategory3|}}}|[[Category:{{{usercategory3}}}]]}}
 |template = {{#if:{{{usercategory|}}}|[[Category:{{{usercategory}}}| {{BASEPAGENAME}}]]}}{{#if:{{{usercategory2|}}}|[[Category:{{{usercategory2}}}| {{BASEPAGENAME}}]]}}{{#if:{{{usercategory3|}}}|[[Category:{{{usercategory3}}}| {{BASEPAGENAME}}]]}}
}}}}&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>k7z3x1a6pqzvaeu8epjbrbk2ebz0cgk</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:User Administrator</title>
    <ns>10</ns>
    <id>692</id>
    <revision>
      <id>3379</id>
      <timestamp>2025-07-11T10:55:37Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Created page with &quot;{{userbox | border-c = #ffb466 | id       = [[Image:Admin mop.PNG|43x43px]] | id-c     = #ffb466 | info     = This user is an '''[[Wikipedia:Administrators|administrator]]''' on the [[:nr:Main_Page|Ndebele Wikipedia]]. | info-c   = #ffe496 }}&lt;noinclude&gt;&quot;</comment>
      <origin>3379</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="253" sha1="901tv4yqdz2vnlibvg76aimotnyi6n5" xml:space="preserve">{{userbox
| border-c = #ffb466
| id       = [[Image:Admin mop.PNG|43x43px]]
| id-c     = #ffb466
| info     = This user is an '''[[Wikipedia:Administrators|administrator]]''' on the [[:nr:Main_Page|Ndebele Wikipedia]].
| info-c   = #ffe496
}}&lt;noinclude&gt;</text>
      <sha1>901tv4yqdz2vnlibvg76aimotnyi6n5</sha1>
    </revision>
  </page>
  <page>
    <title>Wikiphidiya:Administrators</title>
    <ns>4</ns>
    <id>693</id>
    <revision>
      <id>3380</id>
      <timestamp>2025-07-11T10:56:33Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Created page with &quot;==Current Administrators==  # [[User:Thuvack|Thuvack]]  == Candidates for Admin Rights ==  {{Wikipedia:Candidates for Admin Rights}}&quot;</comment>
      <origin>3380</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="132" sha1="2sb9b3uu5qb3e85j2yvwwk1efq943bg" xml:space="preserve">==Current Administrators==

# [[User:Thuvack|Thuvack]]

== Candidates for Admin Rights ==

{{Wikipedia:Candidates for Admin Rights}}</text>
      <sha1>2sb9b3uu5qb3e85j2yvwwk1efq943bg</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:User WikiUser</title>
    <ns>10</ns>
    <id>694</id>
    <revision>
      <id>3381</id>
      <timestamp>2025-07-11T10:57:44Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Created page with &quot;{{ userbox | border-c = {{{border|#8d40b3}}} | id       = [[file:Noia 64 apps karm.svg|42x42px|link=&lt;!-- leave empty as this userbox should not link to anywhere by default for privacy reasons --&gt;]] | id-c     = {{{imgbg|#d9bfe5}}} | info-c   = {{{bgcolor|#f0e6f5}}} | info-lh  = 1.1 | info     = &lt;span class=&quot;plainlinks neverexpand&quot;&gt;{{#ifeq:{{{wikibirthday}}}|no   |   | {{#ifexpr:{{CURRENTMONTH}}={{{month|0}}}     | {{#ifexpr:{{CURRENTDAY}}={{{day|0}}}       | Today is thi...&quot;</comment>
      <origin>3381</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1192" sha1="mvlv443jkj1fzm43sd3jeqtga7f5s5b" xml:space="preserve">{{ userbox
| border-c = {{{border|#8d40b3}}}
| id       = [[file:Noia 64 apps karm.svg|42x42px|link=&lt;!-- leave empty as this userbox should not link to anywhere by default for privacy reasons --&gt;]]
| id-c     = {{{imgbg|#d9bfe5}}}
| info-c   = {{{bgcolor|#f0e6f5}}}
| info-lh  = 1.1
| info     = &lt;span class=&quot;plainlinks neverexpand&quot;&gt;{{#ifeq:{{{wikibirthday}}}|no
  |
  | {{#ifexpr:{{CURRENTMONTH}}={{{month|0}}}
    | {{#ifexpr:{{CURRENTDAY}}={{{day|0}}}
      | Today is this user's {{#ifeq:{{CURRENTYEAR}}|{{{year}}}
        | '''first day''' on Wikipedia
        | '''[[:Category:Current Wikipedia birthdays|WikiBirthday]]'''
        }}.&lt;includeonly&gt;[[Category:Current Wikipedia birthdays|{{ROOTPAGENAMEE}}]]&lt;/includeonly&gt;
      }}
    }}
  }} Mutirhisi loyi una {{#if:{{{link|}}}
  | [//ts.wikipedia.org/w/index.php?title=Special%3ALog&amp;type=newusers&amp;user={{ROOTPAGENAMEE}}&amp;month=-1]
  | {{#if:{{{diff|}}}
    | [{{{diff}}}]
    | 
    }}
  }} {{Age in years, months and days|year={{{year|&lt;noinclude&gt;2001&lt;/noinclude&gt;}}}|month={{{month|&lt;noinclude&gt;1&lt;/noinclude&gt;}}}|day={{{day|&lt;noinclude&gt;15&lt;/noinclude&gt;}}}|sc={{{sc|}}} }} eka Wikipediya leyi.&lt;/span&gt;
}}&lt;noinclude&gt;{{documentation}}&lt;/noinclude&gt;</text>
      <sha1>mvlv443jkj1fzm43sd3jeqtga7f5s5b</sha1>
    </revision>
    <revision>
      <id>3388</id>
      <parentid>3381</parentid>
      <timestamp>2025-07-11T11:10:37Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <origin>3388</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1187" sha1="687nzg08ppsvvo33fl7zd4kmdr3ylsq" xml:space="preserve">{{ userbox
| border-c = {{{border|#8d40b3}}}
| id       = [[file:Noia 64 apps karm.svg|42x42px|link=&lt;!-- leave empty as this userbox should not link to anywhere by default for privacy reasons --&gt;]]
| id-c     = {{{imgbg|#d9bfe5}}}
| info-c   = {{{bgcolor|#f0e6f5}}}
| info-lh  = 1.1
| info     = &lt;span class=&quot;plainlinks neverexpand&quot;&gt;{{#ifeq:{{{wikibirthday}}}|no
  |
  | {{#ifexpr:{{CURRENTMONTH}}={{{month|0}}}
    | {{#ifexpr:{{CURRENTDAY}}={{{day|0}}}
      | Today is this user's {{#ifeq:{{CURRENTYEAR}}|{{{year}}}
        | '''first day''' on Wikipedia
        | '''[[:Category:Current Wikipedia birthdays|WikiBirthday]]'''
        }}.&lt;includeonly&gt;[[Category:Current Wikipedia birthdays|{{ROOTPAGENAMEE}}]]&lt;/includeonly&gt;
      }}
    }}
  }} Umsebenzisi lo une {{#if:{{{link|}}}
  | [//ts.wikipedia.org/w/index.php?title=Special%3ALog&amp;type=newusers&amp;user={{ROOTPAGENAMEE}}&amp;month=-1]
  | {{#if:{{{diff|}}}
    | [{{{diff}}}]
    | 
    }}
  }} {{Age in years, months and days|year={{{year|&lt;noinclude&gt;2001&lt;/noinclude&gt;}}}|month={{{month|&lt;noinclude&gt;1&lt;/noinclude&gt;}}}|day={{{day|&lt;noinclude&gt;15&lt;/noinclude&gt;}}}|sc={{{sc|}}} }} kile-Wikipedia.&lt;/span&gt;
}}&lt;noinclude&gt;{{documentation}}&lt;/noinclude&gt;</text>
      <sha1>687nzg08ppsvvo33fl7zd4kmdr3ylsq</sha1>
    </revision>
    <revision>
      <id>3389</id>
      <parentid>3388</parentid>
      <timestamp>2025-07-11T11:11:46Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <origin>3389</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1187" sha1="es7bbv9hm85ddy7g335gyor501q11o3" xml:space="preserve">{{ userbox
| border-c = {{{border|#8d40b3}}}
| id       = [[file:Noia 64 apps karm.svg|42x42px|link=&lt;!-- leave empty as this userbox should not link to anywhere by default for privacy reasons --&gt;]]
| id-c     = {{{imgbg|#d9bfe5}}}
| info-c   = {{{bgcolor|#f0e6f5}}}
| info-lh  = 1.1
| info     = &lt;span class=&quot;plainlinks neverexpand&quot;&gt;{{#ifeq:{{{wikibirthday}}}|no
  |
  | {{#ifexpr:{{CURRENTMONTH}}={{{month|0}}}
    | {{#ifexpr:{{CURRENTDAY}}={{{day|0}}}
      | Today is this user's {{#ifeq:{{CURRENTYEAR}}|{{{year}}}
        | '''first day''' on Wikipedia
        | '''[[:Category:Current Wikipedia birthdays|WikiBirthday]]'''
        }}.&lt;includeonly&gt;[[Category:Current Wikipedia birthdays|{{ROOTPAGENAMEE}}]]&lt;/includeonly&gt;
      }}
    }}
  }} Umsebenzisi lo une {{#if:{{{link|}}}
  | [//nr.wikipedia.org/w/index.php?title=Special%3ALog&amp;type=newusers&amp;user={{ROOTPAGENAMEE}}&amp;month=-1]
  | {{#if:{{{diff|}}}
    | [{{{diff}}}]
    | 
    }}
  }} {{Age in years, months and days|year={{{year|&lt;noinclude&gt;2001&lt;/noinclude&gt;}}}|month={{{month|&lt;noinclude&gt;1&lt;/noinclude&gt;}}}|day={{{day|&lt;noinclude&gt;15&lt;/noinclude&gt;}}}|sc={{{sc|}}} }} kile-Wikipedia.&lt;/span&gt;
}}&lt;noinclude&gt;{{documentation}}&lt;/noinclude&gt;</text>
      <sha1>es7bbv9hm85ddy7g335gyor501q11o3</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Age in years, months and days</title>
    <ns>10</ns>
    <id>695</id>
    <revision>
      <id>3382</id>
      <timestamp>2025-07-11T10:58:36Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Created page with &quot;{{#if:{{#ifeq:{{{6|¤}}}|¤||1}}{{#ifeq:{{{5|¤}}}|¤||1}}{{#ifeq:{{{4|¤}}}|¤||1}}  |{{#iferror:{{#time:Y-m-d|{{{6}}}-{{{5}}}-{{{4}}}}}   |{{error|Error: Invalid time. }}   |}}}}{{#if:{{{1|{{{year|}}}}}}  |{{#if:{{{2|{{{month|}}}}}}   |{{#if:{{{3|{{{day|}}}}}}    |{{Age in years, months and days/display     |years={{#expr:{{{4|{{CURRENTYEAR}}}}}-{{{1|{{{year}}}}}}-{{#ifexpr:{{{5|{{CURRENTMONTH}}}}}&gt;{{{2|{{{month}}}}}}      |0      |{{#ifexpr:{{{5|{{CURRENTMONTH}}}}}&lt;{{...&quot;</comment>
      <origin>3382</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3681" sha1="gtpzn4n869l7lqg721jfp9vuyfb1gyl" xml:space="preserve">{{#if:{{#ifeq:{{{6|¤}}}|¤||1}}{{#ifeq:{{{5|¤}}}|¤||1}}{{#ifeq:{{{4|¤}}}|¤||1}}
 |{{#iferror:{{#time:Y-m-d|{{{6}}}-{{{5}}}-{{{4}}}}}
  |{{error|Error: Invalid time. }}
  |}}}}{{#if:{{{1|{{{year|}}}}}}
 |{{#if:{{{2|{{{month|}}}}}}
  |{{#if:{{{3|{{{day|}}}}}}
   |{{Age in years, months and days/display
    |years={{#expr:{{{4|{{CURRENTYEAR}}}}}-{{{1|{{{year}}}}}}-{{#ifexpr:{{{5|{{CURRENTMONTH}}}}}&gt;{{{2|{{{month}}}}}}
     |0
     |{{#ifexpr:{{{5|{{CURRENTMONTH}}}}}&lt;{{{2|{{{month}}}}}}
      |1
      |{{#ifexpr:{{{6|{{CURRENTDAY}}}}}&lt;{{{3|{{{day}}}}}}
       |1
       |0
       }}
      }}
     }}}}
    |months={{#expr:{{{5|{{CURRENTMONTH}}}}}-{{{2|{{{month}}}}}}+{{#ifexpr:{{{6|{{CURRENTDAY}}}}}&lt;{{{3|{{{day}}}}}}
     |{{#ifexpr:{{{5|{{CURRENTMONTH}}}}}&gt;{{{2|{{{month}}}}}}
      |-1
      |11
      }}
     |{{#ifexpr:{{{5|{{CURRENTMONTH}}}}}&lt;{{{2|{{{month}}}}}}
      |12
      |0
      }}
     }}{{#ifexpr:{{Gregorian serial date
      |year={{{4|{{CURRENTYEAR}}}}}
      |month={{{5|{{CURRENTMONTH}}}}}
      |day={{{6|{{CURRENTDAY}}}}}}}-{{Gregorian serial date
      |year={{{4|{{CURRENTYEAR}}}}}
      |month={{#expr:{{{5|{{CURRENTMONTH}}}}}-1}}
      |day={{{3|{{{day}}}}}}
      }}&lt;0
     |-1
     |&lt;!--null value--&gt;
     }}}}
    |days={{#ifexpr:{{{6|{{CURRENTDAY}}}}}&lt;{{{3|{{{day}}}}}}
     |{{#expr:{{Gregorian serial date
      |year={{{4|{{CURRENTYEAR}}}}}
      |month={{{5|{{CURRENTMONTH}}}}}
      |day={{{6|{{CURRENTDAY}}}}}}}-{{Gregorian serial date
      |year={{{4|{{CURRENTYEAR}}}}}
      |month={{#expr:{{{5|{{CURRENTMONTH}}}}}-{{#ifexpr:{{Gregorian serial date
        |year={{{4|{{CURRENTYEAR}}}}}
        |month={{{5|{{CURRENTMONTH}}}}}
        |day={{{6|{{CURRENTDAY}}}}}}}-{{Gregorian serial date
        |year={{{4|{{CURRENTYEAR}}}}}
        |month={{#expr:{{{5|{{CURRENTMONTH}}}}}-1}}
        |day={{{3|{{{day}}}}}}
        }}&lt;0
       |2
       |1
       }}}}
      |day={{{3|{{{day}}}}}}
      }}}}
     |{{#expr:{{{6|{{CURRENTDAY}}}}}-{{{3|{{{day}}}}}}
      }}
     }}
    |sc={{#switch:{{{sc|}}}
     |N|n|No|no|False|false|Off|off=&lt;!--null value--&gt;
     |#default={{{sc|}}}
     }}
    }}
   |{{#ifexpr:{{{5|{{CURRENTMONTH}}}}}={{{2|{{{month}}}}}}
    |{{#ifexpr:{{{4|{{CURRENTYEAR}}}}}={{{1|{{{year}}}}}}
     |0&amp;nbsp;years
     |{{#expr:{{{4|{{CURRENTYEAR}}}}}-{{{1|{{{year}}}}}}-1}}&amp;nbsp;or {{Age in years, months and days/display
      |years={{#expr:{{{4|{{CURRENTYEAR}}}}}-{{{1|{{{year}}}}}}}}
      }}
     }}
    |{{#ifexpr:{{{5|{{CURRENTMONTH}}}}}&gt;{{{2|{{{month}}}}}}
     |{{#ifexpr:{{{4|{{CURRENTYEAR}}}}}={{{1|{{{year}}}}}}
      |&lt;!--null value--&gt;
      |{{Age in years, months and days/display
       |years={{#expr:{{{4|{{CURRENTYEAR}}}}}-{{{1|{{{year}}}}}}}}
       }} and
      }} {{#expr:{{{5|{{CURRENTMONTH}}}}}-{{{2|{{{month}}}}}}-1}}&amp;nbsp;or {{Age in years, months and days/display
      |months={{#expr:{{{5|{{CURRENTMONTH}}}}}-{{{2|{{{month}}}}}}}}
      }}
     |{{#ifexpr:{{{4|{{CURRENTYEAR}}}}}={{#expr:{{{1|{{{year}}}}}}+1}}
      |&lt;!--null value--&gt;
      |{{Age in years, months and days/display
       |years={{#expr:{{{4|{{CURRENTYEAR}}}}}-{{{1|{{{year}}}}}}-1}}
       }} and
      }} {{#expr:{{{5|{{CURRENTMONTH}}}}}-{{{2|{{{month}}}}}}+11}}&amp;nbsp;or {{Age in years, months and days/display
      |months={{#expr:{{{5|{{CURRENTMONTH}}}}}-{{{2|{{{month}}}}}}+12}}}}
     }}
    }}
   }}
  |{{#ifexpr:{{{4|{{CURRENTYEAR}}}}}={{{1|{{{year}}}}}}
   |0&amp;nbsp;years
   |{{#expr:{{{4|{{CURRENTYEAR}}}}}-{{{1|{{{year}}}}}}-1}}&amp;nbsp;or {{Age in years, months and days/display
    |years={{#expr:{{{4|{{CURRENTYEAR}}}}}-{{{1|{{{year}}}}}}}}
    }}
   }}
  }}
 |some time
}}&lt;noinclude&gt;{{Documentation}}&lt;/noinclude&gt;</text>
      <sha1>gtpzn4n869l7lqg721jfp9vuyfb1gyl</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Documentation/styles.css</title>
    <ns>828</ns>
    <id>696</id>
    <revision>
      <id>3384</id>
      <timestamp>2025-07-11T11:04:31Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Created page with &quot;/* {{pp|small=yes}} */ .documentation, .documentation-metadata { 	border: 1px solid var( --border-color-base, #a2a9b1 ); 	background-color: #ecfcf4; 	clear: both; }  .documentation { 	margin: 1em 0 0 0; 	padding: 1em; }  .documentation-metadata { 	margin: 0.2em 0; /* same margin left-right as .documentation */     font-style: italic;     padding: 0.4em 1em; /* same padding left-right as .documentation */ }  .documentation-startbox { 	padding-bottom: 3px; 	border-bottom:...&quot;</comment>
      <origin>3384</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="1149" sha1="i8lops10ml7ifgplup23473ri87jccv" xml:space="preserve">/* {{pp|small=yes}} */
.documentation,
.documentation-metadata {
	border: 1px solid var( --border-color-base, #a2a9b1 );
	background-color: #ecfcf4;
	clear: both;
}

.documentation {
	margin: 1em 0 0 0;
	padding: 1em;
}

.documentation-metadata {
	margin: 0.2em 0; /* same margin left-right as .documentation */
    font-style: italic;
    padding: 0.4em 1em; /* same padding left-right as .documentation */
}

.documentation-startbox {
	padding-bottom: 3px;
	border-bottom: 1px solid var( --border-color-base, #a2a9b1 );
	margin-bottom: 1ex;
}

.documentation-heading {
	font-weight: bold;
	font-size: 125%;
}

.documentation-clear { /* Don't want things to stick out where they shouldn't. */
	clear: both;
}

.documentation-toolbar {
	font-style: normal;
	font-size: 85%;
}


@media screen {
    html.skin-theme-clientpref-night .documentation,
	html.skin-theme-clientpref-night .documentation-metadata {
	    background-color: #0b1e1c;
	}
}


@media screen and ( prefers-color-scheme: dark ) {
    html.skin-theme-clientpref-os .documentation,
    html.skin-theme-clientpref-os .documentation-metadata {
        background-color: #0b1e1c;
    }
}</text>
      <sha1>i8lops10ml7ifgplup23473ri87jccv</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Age in years, months and days/display</title>
    <ns>10</ns>
    <id>697</id>
    <revision>
      <id>3385</id>
      <timestamp>2025-07-11T11:05:34Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Created page with &quot;{{#ifexpr:{{{years|0}}}&lt;0|{{error|Error: Invalid time. }}|}}{{#switch:{{{years|0}}} | 0        = | 1        = 1&amp;nbsp;lembe | #default = '''{{{years}}}'''&amp;nbsp;wa malembe }}{{#ifeq:{{{years|0}}}|0|&lt;!--null--&gt;|{{#ifeq:{{{months|0}}}|0|&lt;!--null--&gt;|{{#ifeq:{{{days|0}}}|0|&amp;#32;na&amp;#32;|,&amp;#32;}} }} }}{{#switch:{{{months|0}}} | 0        = | 1        = 1&amp;nbsp;n'wheti | #default = '''{{{months}}}'''&amp;nbsp;wa tin'wheti }}{{#ifeq:{{{years|0}}}|0|{{#ifeq:{{{months|0}}}|0|&lt;!--null--&gt;|{...&quot;</comment>
      <origin>3385</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="901" sha1="9xa2zxr51hziilbnxr2tanueqp6c9ir" xml:space="preserve">{{#ifexpr:{{{years|0}}}&lt;0|{{error|Error: Invalid time. }}|}}{{#switch:{{{years|0}}}
| 0        =
| 1        = 1&amp;nbsp;lembe
| #default = '''{{{years}}}'''&amp;nbsp;wa malembe
}}{{#ifeq:{{{years|0}}}|0|&lt;!--null--&gt;|{{#ifeq:{{{months|0}}}|0|&lt;!--null--&gt;|{{#ifeq:{{{days|0}}}|0|&amp;#32;na&amp;#32;|,&amp;#32;}} }} }}{{#switch:{{{months|0}}}
| 0        =
| 1        = 1&amp;nbsp;n'wheti
| #default = '''{{{months}}}'''&amp;nbsp;wa tin'wheti
}}{{#ifeq:{{{years|0}}}|0|{{#ifeq:{{{months|0}}}|0|&lt;!--null--&gt;|{{#ifeq:{{{days|0}}}|0|&lt;!--null--&gt;|&amp;#32;na&amp;#32;}} }}|{{#ifeq:{{{days|0}}}|0|&lt;!--null--&gt;|{{#if:{{{sc|}}}|{{#ifeq:{{{months|0}}}|0|&lt;!--null--&gt;|,}}|&lt;!--null--&gt;}}&amp;#32;na&amp;#32;}} }}{{#switch:{{{days|0}}}
| 0        = {{#ifeq:{{{years|0}}}|0|{{#ifeq:{{{months|0}}}|0|ntsena}} }}
| 1        = 1&amp;nbsp;siku
| #default = '''{{{days}}}'''&amp;nbsp;wa masiku
}}&lt;noinclude&gt;{{Documentation|Template:Age in years, months and days/doc}}&lt;/noinclude&gt;</text>
      <sha1>9xa2zxr51hziilbnxr2tanueqp6c9ir</sha1>
    </revision>
    <revision>
      <id>3390</id>
      <parentid>3385</parentid>
      <timestamp>2025-07-11T11:15:23Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <origin>3390</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="897" sha1="dyyp0ssu66vygny7lcuw6hmjjqj6pxm" xml:space="preserve">{{#ifexpr:{{{years|0}}}&lt;0|{{error|Error: Invalid time. }}|}}{{#switch:{{{years|0}}}
| 0        =
| 1        = 1&amp;nbsp;lembe
| #default = '''{{{years}}}'''&amp;nbsp;yeminyaka
}}{{#ifeq:{{{years|0}}}|0|&lt;!--null--&gt;|{{#ifeq:{{{months|0}}}|0|&lt;!--null--&gt;|{{#ifeq:{{{days|0}}}|0|&amp;#32;na&amp;#32;|,&amp;#32;}} }} }}{{#switch:{{{months|0}}}
| 0        =
| 1        = 1&amp;nbsp;inyanga
| #default = '''{{{months}}}'''&amp;nbsp;iinyanga
}}{{#ifeq:{{{years|0}}}|0|{{#ifeq:{{{months|0}}}|0|&lt;!--null--&gt;|{{#ifeq:{{{days|0}}}|0|&lt;!--null--&gt;|&amp;#32;na&amp;#32;}} }}|{{#ifeq:{{{days|0}}}|0|&lt;!--null--&gt;|{{#if:{{{sc|}}}|{{#ifeq:{{{months|0}}}|0|&lt;!--null--&gt;|,}}|&lt;!--null--&gt;}}&amp;#32;na&amp;#32;}} }}{{#switch:{{{days|0}}}
| 0        = {{#ifeq:{{{years|0}}}|0|{{#ifeq:{{{months|0}}}|0|ntsena}} }}
| 1        = 1&amp;nbsp;ilanga
| #default = '''{{{days}}}'''&amp;nbsp;amalanga
}}&lt;noinclude&gt;{{Documentation|Template:Age in years, months and days/doc}}&lt;/noinclude&gt;</text>
      <sha1>dyyp0ssu66vygny7lcuw6hmjjqj6pxm</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Css3</title>
    <ns>10</ns>
    <id>698</id>
    <revision>
      <id>3386</id>
      <timestamp>2025-07-11T11:06:54Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Created page with &quot;&lt;includeonly&gt;-moz-{{{1}}}; -ms-{{{1}}}; -o-{{{1}}}; -webkit-{{{1}}}; {{{1}}};&lt;/includeonly&gt;&lt;noinclude&gt;  {{documentation|content=This template allows adding CSS3 rules, by specifying the unprefixed selector, and it automatically adds the browser prefixes (-moz-, -ms-, -o- and -webkit-).}}  [[Category:Cross-browser compatibility templates]] &lt;/noinclude&gt;&quot;</comment>
      <origin>3386</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="353" sha1="trx2wq728g2zayuhgeymciu0hr4zt76" xml:space="preserve">&lt;includeonly&gt;-moz-{{{1}}}; -ms-{{{1}}}; -o-{{{1}}}; -webkit-{{{1}}}; {{{1}}};&lt;/includeonly&gt;&lt;noinclude&gt;

{{documentation|content=This template allows adding CSS3 rules, by specifying the unprefixed selector, and it automatically adds the browser prefixes (-moz-, -ms-, -o- and -webkit-).}}

[[Category:Cross-browser compatibility templates]]
&lt;/noinclude&gt;</text>
      <sha1>trx2wq728g2zayuhgeymciu0hr4zt76</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Gregorian serial date</title>
    <ns>10</ns>
    <id>699</id>
    <revision>
      <id>3387</id>
      <timestamp>2025-07-11T11:07:55Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Created page with &quot;{{#expr:          &lt;!--Days from all years past:--&gt;          + (({{{year|{{CURRENTYEAR}}}}} - 1) * 365)         + ((({{{year|{{CURRENTYEAR}}}}} - 1) - (({{{year|{{CURRENTYEAR}}}}} - 1) mod 4)) / 4)     &lt;!--add a day for every leap--&gt;         - ((({{{year|{{CURRENTYEAR}}}}} - 1) - (({{{year|{{CURRENTYEAR}}}}} - 1) mod 100)) / 100) &lt;!--subtract 100 year exception--&gt;         + ((({{{year|{{CURRENTYEAR}}}}} - 1) - (({{{year|{{CURRENTYEAR}}}}} - 1) mod 400)) / 400) &lt;!--readd 4...&quot;</comment>
      <origin>3387</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1782" sha1="knj2qocovus95zi2z24hd29kxszvu60" xml:space="preserve">{{#expr: 
        &lt;!--Days from all years past:--&gt;

        + (({{{year|{{CURRENTYEAR}}}}} - 1) * 365)
        + ((({{{year|{{CURRENTYEAR}}}}} - 1) - (({{{year|{{CURRENTYEAR}}}}} - 1) mod 4)) / 4)     &lt;!--add a day for every leap--&gt;
        - ((({{{year|{{CURRENTYEAR}}}}} - 1) - (({{{year|{{CURRENTYEAR}}}}} - 1) mod 100)) / 100) &lt;!--subtract 100 year exception--&gt;
        + ((({{{year|{{CURRENTYEAR}}}}} - 1) - (({{{year|{{CURRENTYEAR}}}}} - 1) mod 400)) / 400) &lt;!--readd 400 year exception--&gt;

       &lt;!--Days so far this year:--&gt;
 
        + {{ #ifexpr:    &lt;!--add days for past months this year--&gt; &lt;!--Gives 1 or 2 extra days because of February--&gt;
                     ({{{month|{{CURRENTMONTH}}}}} - 1) &lt; 8 
                     | ( ({{{month|{{CURRENTMONTH}}}}} - 1) * 30.5 round 0) 
                     | ( ({{{month|{{CURRENTMONTH}}}}} - 1) * 30.5 + 0.9 round 0 ) 
          }} 
        - {{ #ifexpr: ({{{month|{{CURRENTMONTH}}}}} &lt;= 2) | 0 |  
             {{ #ifexpr:    &lt;!-- if leap year  --&gt;
                     ({{{year|{{CURRENTYEAR}}}}} / 4) = ({{{year|{{CURRENTYEAR}}}}} / 4 round 0)          &lt;!--If divisible by 4--&gt;
                      and ({{{year|{{CURRENTYEAR}}}}} / 100 != {{{year|{{CURRENTYEAR}}}}} / 100 round 0)  &lt;!--and not by 100--&gt;
                | 1 | 2 
             }}
          }}
        + {{ #ifexpr: ({{{month|{{CURRENTMONTH}}}}} &lt;= 2) | 0 |
             {{ #ifexpr: &lt;!--400 year exception--&gt;
                     ({{{year|{{CURRENTYEAR}}}}} / 400) = ({{{year|{{CURRENTYEAR}}}}} / 400 round 0) 
                | 1 | 0 
             }}
          }} 
        + {{{day|{{CURRENTDAY}}}}}
 }}{{#ifexpr: {{{year|{{CURRENTYEAR}}}}} &lt; 1 |
        _ERROR - Can not handle dates before January 1, 1 A.D.
   }}&lt;noinclude&gt;{{documentation}}&lt;/noinclude&gt;</text>
      <sha1>knj2qocovus95zi2z24hd29kxszvu60</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Babel - Users by language</title>
    <ns>14</ns>
    <id>700</id>
    <revision>
      <id>3392</id>
      <timestamp>2025-07-11T11:24:08Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Created page with &quot;Mkhakha wa ba sebenzisi nge iilimi&quot;</comment>
      <origin>3392</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="34" sha1="i9vve74vgukc46cckvierog4g2xg9jq" xml:space="preserve">Mkhakha wa ba sebenzisi nge iilimi</text>
      <sha1>i9vve74vgukc46cckvierog4g2xg9jq</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Thuvack/Short-Cuts</title>
    <ns>2</ns>
    <id>701</id>
    <revision>
      <id>3395</id>
      <timestamp>2025-07-11T11:39:27Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Created page with &quot;---- This is my short-cuts page: ----&quot;</comment>
      <origin>3395</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="37" sha1="rc1z5t0x08jlioujwn262hsoo6ik0iz" xml:space="preserve">----
This is my short-cuts page:
----</text>
      <sha1>rc1z5t0x08jlioujwn262hsoo6ik0iz</sha1>
    </revision>
    <revision>
      <id>3396</id>
      <parentid>3395</parentid>
      <timestamp>2025-07-11T11:40:11Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <origin>3396</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="54" sha1="i5e1pvbtudbtdn2a1cxpsx9nk8auco7" xml:space="preserve">----
&lt;center&gt;This is my short-cuts page:&lt;/center&gt;
----</text>
      <sha1>i5e1pvbtudbtdn2a1cxpsx9nk8auco7</sha1>
    </revision>
    <revision>
      <id>3404</id>
      <parentid>3396</parentid>
      <timestamp>2025-07-11T11:53:43Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <origin>3404</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="155" sha1="q7daw7cwmifqify0hu43p5fse9j5e0b" xml:space="preserve">----
&lt;center&gt;This is my short-cuts page:&lt;/center&gt;
----

* My contributions to this Wiki on [https://xtools.wmcloud.org/ec/nr.wikipedia.org/Thuvack XTools].</text>
      <sha1>q7daw7cwmifqify0hu43p5fse9j5e0b</sha1>
    </revision>
    <revision>
      <id>6300</id>
      <parentid>3404</parentid>
      <timestamp>2026-03-14T16:40:07Z</timestamp>
      <contributor>
        <username>Àncilu</username>
        <id>1416</id>
      </contributor>
      <comment>[[Khethekileko:LintErrors/obsolete-tag]]</comment>
      <origin>6300</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="177" sha1="8hlcd33nkp5gfuvkzu1gjpz4pj6qhsw" xml:space="preserve">----
&lt;div style=&quot;text-align: center;&quot;&gt;This is my short-cuts page:&lt;/div&gt;
----

* My contributions to this Wiki on [https://xtools.wmcloud.org/ec/nr.wikipedia.org/Thuvack XTools].</text>
      <sha1>8hlcd33nkp5gfuvkzu1gjpz4pj6qhsw</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Thuvack/Draft1</title>
    <ns>2</ns>
    <id>702</id>
    <revision>
      <id>3397</id>
      <timestamp>2025-07-11T11:40:35Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Created page with &quot;---- &lt;center&gt;This is my draft page No. 1:&lt;/center&gt; ----&quot;</comment>
      <origin>3397</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="55" sha1="8g7q1nszgx44liadktxrwtz9ehdptd0" xml:space="preserve">----
&lt;center&gt;This is my draft page No. 1:&lt;/center&gt;
----</text>
      <sha1>8g7q1nszgx44liadktxrwtz9ehdptd0</sha1>
    </revision>
    <revision>
      <id>3400</id>
      <parentid>3397</parentid>
      <timestamp>2025-07-11T11:41:54Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <origin>3400</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="95" sha1="r10sklgibwbmuj2cyfm2962adog9t64" xml:space="preserve">----
&lt;center&gt;This is my draft page No. 1:&lt;/center&gt;
----

'''Article of the day for main page'''</text>
      <sha1>r10sklgibwbmuj2cyfm2962adog9t64</sha1>
    </revision>
    <revision>
      <id>6301</id>
      <parentid>3400</parentid>
      <timestamp>2026-03-14T16:41:31Z</timestamp>
      <contributor>
        <username>Àncilu</username>
        <id>1416</id>
      </contributor>
      <comment>[[Khethekileko:LintErrors/obsolete-tag]]</comment>
      <origin>6301</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="117" sha1="kj2a6q7xv23q6fij5lzyt0m5h137jlk" xml:space="preserve">----
&lt;div style=&quot;text-align: center;&quot;&gt;This is my draft page No. 1:&lt;/div&gt;
----

'''Article of the day for main page'''</text>
      <sha1>kj2a6q7xv23q6fij5lzyt0m5h137jlk</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Thuvack/Draft2</title>
    <ns>2</ns>
    <id>703</id>
    <revision>
      <id>3398</id>
      <timestamp>2025-07-11T11:40:43Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Created page with &quot;---- &lt;center&gt;This is my draft page No. 2:&lt;/center&gt; ----&quot;</comment>
      <origin>3398</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="55" sha1="0xr853anlwjwlqeuv47xsyoncksar6b" xml:space="preserve">----
&lt;center&gt;This is my draft page No. 2:&lt;/center&gt;
----</text>
      <sha1>0xr853anlwjwlqeuv47xsyoncksar6b</sha1>
    </revision>
    <revision>
      <id>6302</id>
      <parentid>3398</parentid>
      <timestamp>2026-03-14T16:41:53Z</timestamp>
      <contributor>
        <username>Àncilu</username>
        <id>1416</id>
      </contributor>
      <comment>[[Khethekileko:LintErrors/obsolete-tag]]</comment>
      <origin>6302</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="77" sha1="iy51p7kguxw0fl8gbtlxqi29cn1j4uc" xml:space="preserve">----
&lt;div style=&quot;text-align: center;&quot;&gt;This is my draft page No. 2:&lt;/div&gt;
----</text>
      <sha1>iy51p7kguxw0fl8gbtlxqi29cn1j4uc</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Thuvack/Draft3</title>
    <ns>2</ns>
    <id>704</id>
    <revision>
      <id>3399</id>
      <timestamp>2025-07-11T11:40:52Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Created page with &quot;---- &lt;center&gt;This is my draft page No. 3:&lt;/center&gt; ----&quot;</comment>
      <origin>3399</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="55" sha1="0tr9eiqdkmh1jdfbqbrjq5xhnbnxtm4" xml:space="preserve">----
&lt;center&gt;This is my draft page No. 3:&lt;/center&gt;
----</text>
      <sha1>0tr9eiqdkmh1jdfbqbrjq5xhnbnxtm4</sha1>
    </revision>
    <revision>
      <id>6303</id>
      <parentid>3399</parentid>
      <timestamp>2026-03-14T16:42:15Z</timestamp>
      <contributor>
        <username>Àncilu</username>
        <id>1416</id>
      </contributor>
      <comment>[[Khethekileko:LintErrors/obsolete-tag]]</comment>
      <origin>6303</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="77" sha1="j3d4apvzgfaj4ehx2l0jzfjaqorr3mc" xml:space="preserve">----
&lt;div style=&quot;text-align: center;&quot;&gt;This is my draft page No. 3:&lt;/div&gt;
----</text>
      <sha1>j3d4apvzgfaj4ehx2l0jzfjaqorr3mc</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi asiqongelane:Thuvack</title>
    <ns>3</ns>
    <id>705</id>
    <revision>
      <id>3401</id>
      <timestamp>2025-07-11T11:45:19Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Created page with &quot;---- &lt;center&gt;This is my Talk page:&lt;/center&gt; &lt;br&gt; Please leave me a message below. Please note, I patrol pages in this wiki as an admin. I will endevour to respond as quickly as I can. ----&quot;</comment>
      <origin>3401</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="188" sha1="0qwhr9zh2a0ko1564nkzc7c3rp9hwov" xml:space="preserve">----
&lt;center&gt;This is my Talk page:&lt;/center&gt; &lt;br&gt;
Please leave me a message below. Please note, I patrol pages in this wiki as an admin. I will endevour to respond as quickly as I can.
----</text>
      <sha1>0qwhr9zh2a0ko1564nkzc7c3rp9hwov</sha1>
    </revision>
    <revision>
      <id>3402</id>
      <parentid>3401</parentid>
      <timestamp>2025-07-11T11:46:31Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <origin>3402</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="359" sha1="qfuat05y0i0vz3cbqtw802klr3fjsjs" xml:space="preserve">----
&lt;center&gt;This is my Talk page:&lt;/center&gt; &lt;br&gt;
Please leave me a message below. Please note, I patrol pages in this wiki as an admin. I will endevour to respond as quickly as I can.
----
== Test talk page ==
Creating talk page as I hate red links. --[[Umsebenzisi:Thuvack|Thuvack]] ([[Umsebenzisi asiqongelane:Thuvack|talk]]) 13:46, 11 Ntulikazi 2025 (SAST)</text>
      <sha1>qfuat05y0i0vz3cbqtw802klr3fjsjs</sha1>
    </revision>
    <revision>
      <id>5244</id>
      <parentid>3402</parentid>
      <timestamp>2025-09-02T19:44:42Z</timestamp>
      <contributor>
        <username>Leaderbot</username>
        <id>143</id>
      </contributor>
      <comment>/* Notice of expiration of your sysop right */ new section</comment>
      <origin>5244</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="916" sha1="j8s2nf0j2gndq1oyhccptvx1f3bxbzf" xml:space="preserve">----
&lt;center&gt;This is my Talk page:&lt;/center&gt; &lt;br&gt;
Please leave me a message below. Please note, I patrol pages in this wiki as an admin. I will endevour to respond as quickly as I can.
----
== Test talk page ==
Creating talk page as I hate red links. --[[Umsebenzisi:Thuvack|Thuvack]] ([[Umsebenzisi asiqongelane:Thuvack|talk]]) 13:46, 11 Ntulikazi 2025 (SAST)

== Notice of expiration of your sysop right ==

&lt;div dir=&quot;ltr&quot;&gt;Hi, as part of [[:m:Special:MyLanguage/Global reminder bot|Global reminder bot]], this is an automated reminder to let you know that your permission &quot;sysop&quot; (Administrators) will expire on 2025-09-09 15:37:00. Please renew this right if you would like to continue using it. &lt;i&gt;In other languages: [[:m:Special:MyLanguage/Global reminder bot/Messages/default|click here]]&lt;/i&gt; [[Umsebenzisi:Leaderbot|Leaderbot]] ([[Umsebenzisi asiqongelane:Leaderbot|talk]]) 21:44, 2 Mpandula 2025 (SAST)&lt;/div&gt;</text>
      <sha1>j8s2nf0j2gndq1oyhccptvx1f3bxbzf</sha1>
    </revision>
    <revision>
      <id>6299</id>
      <parentid>5244</parentid>
      <timestamp>2026-03-14T16:39:38Z</timestamp>
      <contributor>
        <username>Àncilu</username>
        <id>1416</id>
      </contributor>
      <comment>[[Khethekileko:LintErrors/obsolete-tag]]</comment>
      <origin>6299</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="938" sha1="hbyvucf613iflcvhsnfq4hbu9dve1ih" xml:space="preserve">----
&lt;div style=&quot;text-align: center;&quot;&gt;This is my Talk page:&lt;/div&gt; &lt;br&gt;
Please leave me a message below. Please note, I patrol pages in this wiki as an admin. I will endevour to respond as quickly as I can.
----
== Test talk page ==
Creating talk page as I hate red links. --[[Umsebenzisi:Thuvack|Thuvack]] ([[Umsebenzisi asiqongelane:Thuvack|talk]]) 13:46, 11 Ntulikazi 2025 (SAST)

== Notice of expiration of your sysop right ==

&lt;div dir=&quot;ltr&quot;&gt;Hi, as part of [[:m:Special:MyLanguage/Global reminder bot|Global reminder bot]], this is an automated reminder to let you know that your permission &quot;sysop&quot; (Administrators) will expire on 2025-09-09 15:37:00. Please renew this right if you would like to continue using it. &lt;i&gt;In other languages: [[:m:Special:MyLanguage/Global reminder bot/Messages/default|click here]]&lt;/i&gt; [[Umsebenzisi:Leaderbot|Leaderbot]] ([[Umsebenzisi asiqongelane:Leaderbot|talk]]) 21:44, 2 Mpandula 2025 (SAST)&lt;/div&gt;</text>
      <sha1>hbyvucf613iflcvhsnfq4hbu9dve1ih</sha1>
    </revision>
    <revision>
      <id>6483</id>
      <parentid>6299</parentid>
      <timestamp>2026-04-27T23:13:23Z</timestamp>
      <contributor>
        <username>UOzurumba (WMF)</username>
        <id>48</id>
      </contributor>
      <comment>/* Invitation to try the Starter Kit tool and share your feedback */ new section</comment>
      <origin>6483</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3395" sha1="5yd2di1x2w8dd5iewq94b9v6tfm563t" xml:space="preserve">----
&lt;div style=&quot;text-align: center;&quot;&gt;This is my Talk page:&lt;/div&gt; &lt;br&gt;
Please leave me a message below. Please note, I patrol pages in this wiki as an admin. I will endevour to respond as quickly as I can.
----
== Test talk page ==
Creating talk page as I hate red links. --[[Umsebenzisi:Thuvack|Thuvack]] ([[Umsebenzisi asiqongelane:Thuvack|talk]]) 13:46, 11 Ntulikazi 2025 (SAST)

== Notice of expiration of your sysop right ==

&lt;div dir=&quot;ltr&quot;&gt;Hi, as part of [[:m:Special:MyLanguage/Global reminder bot|Global reminder bot]], this is an automated reminder to let you know that your permission &quot;sysop&quot; (Administrators) will expire on 2025-09-09 15:37:00. Please renew this right if you would like to continue using it. &lt;i&gt;In other languages: [[:m:Special:MyLanguage/Global reminder bot/Messages/default|click here]]&lt;/i&gt; [[Umsebenzisi:Leaderbot|Leaderbot]] ([[Umsebenzisi asiqongelane:Leaderbot|talk]]) 21:44, 2 Mpandula 2025 (SAST)&lt;/div&gt;

== Invitation to try the Starter Kit tool and share your feedback ==

Hello @[[Umsebenzisi:Thuvack|Thuvack]],

As one of the editors who set up the South Ndebele Wikipedia, the [[mw:Language_Onboarding_and_Development|Language Onboarding and Development]] initiative invites you to use the Starter Kit to configure and customize South Ndebele Wikipedia homepage.

Main page customization is one of the first features of the starter kit which will help you improve your main page's layout and mobile responsiveness, and structure your content with ease using pre-built templates. It will also help us evaluate how well it can improve the onboarding experience of administrators on your Wikipedia, so we can further use the learnings to improve the experience for new wikis graduating from the incubator. Visit [[mw:Language_Onboarding_and_Development/Starter_kit|this page]] to learn more about the Starter kit.

'''Here's how to get started:'''

* Access the Starter Kit here: https://starterkit.toolforge.org/
* Use the tool as illustrated in the screen record below to customize your main page.
[[Isimumathi:Starter_kit_main_page_customization_feature_demo.webm|699x699px|Starter kit main page customization feature demo]]

* When you are done, share your feedback on [[mw:Talk:Language_Onboarding_and_Development/Starter_kit|this page]] on the following:
** The time it took to configure and customize your Wikipedia initially, and the time it took now with the Kit.
** The things you find most useful while configuring it.
** Tell us anything important to your language Wikipedia or your community's goals that you felt the configured main page templates were able to or unable to capture.
** The step in the configuration process where you felt stuck, confused, or unsure what to do next.

The configurations can be reverted like an edit from the “view history”, so don't be afraid to try it several times.

We would appreciate it if you could submit your feedback by the 11th of May 2026 so we can start adding more features based on it. If you have any questions or need assistance, let me know.

Thank you so much for your contributions to your Wikipedia and for helping us shape this tool for new Wikipedias. We will keep you updated on any additional things added to the starter kit in the future.

Best regards, [[Umsebenzisi:UOzurumba (WMF)|UOzurumba (WMF)]] ([[Umsebenzisi asiqongelane:UOzurumba (WMF)|talk]]) 01:13, 28 Mabasa 2026 (SAST)</text>
      <sha1>5yd2di1x2w8dd5iewq94b9v6tfm563t</sha1>
    </revision>
  </page>
  <page>
    <title>Amakhotho weNdabuko.</title>
    <ns>0</ns>
    <id>707</id>
    <redirect title="Amakhotho weNdabuko" />
    <revision>
      <id>3433</id>
      <timestamp>2025-07-14T00:22:49Z</timestamp>
      <contributor>
        <username>Dcljr</username>
        <id>20</id>
      </contributor>
      <comment>Dcljr moved page [[Amakhotho weNdabuko.]] to [[Amakhotho weNdabuko]]: I don't see why title should end with a &quot;.&quot;</comment>
      <origin>3433</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="33" sha1="ds3ew7tal0bxvhvgsyi2wljlf1v5z6q" xml:space="preserve">#REDIRECT [[Amakhotho weNdabuko]]</text>
      <sha1>ds3ew7tal0bxvhvgsyi2wljlf1v5z6q</sha1>
    </revision>
  </page>
  <page>
    <title>I-Roben island</title>
    <ns>0</ns>
    <id>710</id>
    <revision>
      <id>3457</id>
      <timestamp>2025-07-26T15:58:01Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;I-Roben island kuyindawo lapho etholakala egwini le-Cape town, enarheni yeSewula afrika. Indawo le ngenye yendawo ezikhumbuza iSewula Afrika ngezolo layo elibuhlungu langesikhathi sombuso wegandelelo. Eminyakeni eyadlulako indawo leya beyitjenziswa njengendawo yokujezisa neyokubopha abantu abavukela umbuso. Kukuplapho indawo leyaduma khona njengejele elabe ligadwe khulu.  Ipilo ejele ngesikhathi sombuso wegandelelo  Indawo le ngesikhathi sombuso wegandelelo yathoma umseb...&quot;</comment>
      <origin>3457</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3253" sha1="hsuooudvni5agfnpgiif1nflpyi5ij2" xml:space="preserve">I-Roben island kuyindawo lapho etholakala egwini le-Cape town, enarheni yeSewula afrika. Indawo le ngenye yendawo ezikhumbuza iSewula Afrika ngezolo layo elibuhlungu langesikhathi sombuso wegandelelo. Eminyakeni eyadlulako indawo leya beyitjenziswa njengendawo yokujezisa neyokubopha abantu abavukela umbuso. Kukuplapho indawo leyaduma khona njengejele elabe ligadwe khulu.

Ipilo ejele ngesikhathi sombuso wegandelelo

Indawo le ngesikhathi sombuso wegandelelo yathoma umsebenzi wokuthi kuvalelwe kiyo abantu ekhabe balwisana nombuso webandlululo, nabanye abasopolitiki ekhabe balwela ikululeko. Ipilo ejele le beyaziwa ngokuthi ihlukanisa iimbotjhwa nabantu, ukusebenzisa iimbotjhwa nzima, nesihlungu. Imbotjhwa zakhona ezinye bezisetjenziswa kukhwari yelitje le lime. Iimbotjhwa ejele ye roben island zabe zihlukunyezwa emzimbeni nemmoyeni, beziphiwa Ukudla okuncani, begodu zihlezi nakabuhlungu. Imbotjhwa khabe zigade khulu ukuphula ithemba kilabo ekhabe balwisana nombuso webandlululo. Nanyana bekunjalo lokho akhange kuvimbe iimbotjhwa zangaleso skhathi ukuthi zifunde begodu ziragele phambili nokufuna ikululeko.

Abantu abavelelwa ERoben Island

UNelson Mandela owabe amdosi phambili wehlangano ye- ANC wabotjhwa ejele le iminyaka ema-18, kusekela ngonyaka we-1964 ukuya ngonyaka we1982.&lt;ref&gt;Roux, D., 2020. 5 Writing from Robben Island. ''Prison Writing and the Literary World: Imprisonment, Institutionality and Questions of Literary Practice'', p.93.&lt;/ref&gt; UNelson Mandela wadlala indima yokwenza bonyana iimbotjhwa zibumbane entronkweni, waraga ukulelwa ikululeko nanyana bekavalelwe. Wahlukaniswa nomndeni wakhe akhange avunyelwe bonyana ayokubulunga unina Kanye nendodana yakhe ekulu. Abnaye abantu ababotjwa e Roben Island ngu Walter Sisulu, Govan Mbeki no Robert Sibukwe.

Robert Sobukwe yena wabe amdosi phambili wehlangano ye Pan African Congress (PAC) yena nakavalelwako wabekwa ayedwa bonyana kungabi nabantu abamvakatjhelako. USobukwe wenzekwa umthetho okhethekileko owawubizwa nge”Sobukwe Clause” ukwenzele ukuthi avalelwe yedwa ngejele. Wakatelelwa bonyana atjhugulule umkhumbulo wakhe  wokuthoma umnyakazo wokulwisana nombuso wegandelelo kodwana akhange avume. UWalter Sisulu wagwetjwa isisgwebo sepilo yakhe yoke ejele ngombana watholakala azibandakanye  emnyakazweni wokulwisana nombuso wegandelelo. Wahlala ejele pheze iminyaka emam-20. Ngonyaka we-1982 wasuswa wasiwa ePollsomor ekuyijele eseduze nekapa, ekukulapho waragela khona phambili wajamela ukuphela kombuso webandululo.

Ngemva  kokuthi kuphele umbuso wegandelelo I-Roben island yenziwa yabo yindawo yamagugu ye- UNESCO ngonyaka we-1999, lokho kwenziwa kukobana kwabe kubonwa umlando  wayo oqakathekileko  nokuthumba kwemiphefumulo wabantu phezulu kokubandlululana. Eskhathini sanje ijele sele yenziwe I myuziyemu nethswayo lethemba, ikululeko kanye nentando yenengi.&lt;ref&gt;[https://iol.co.za/travel/south-africa/western-cape/2021-09-23-the-making--and-then-breaking--of-robben-island-museum/ The making – and then breaking – of Robben Island Museum]&lt;/ref&gt; Abayeni bakghona  ukuthatha ikhambo elidswa phambili mumuntu bese umuntu loyo abakhombise amakamero wangejele lapho bekulala khona iimbotjhwa bese abakhombise nalapho kune khwari yelitje le- lime.</text>
      <sha1>hsuooudvni5agfnpgiif1nflpyi5ij2</sha1>
    </revision>
    <revision>
      <id>3458</id>
      <parentid>3457</parentid>
      <timestamp>2025-07-28T09:34:17Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3458</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3259" sha1="ctva7rluofikryege45a5tzv7p4v6tt" xml:space="preserve">'''I-Roben island''' kuyindawo lapho etholakala egwini le-Cape town, enarheni yeSewula afrika. Indawo le ngenye yendawo ezikhumbuza iSewula Afrika ngezolo layo elibuhlungu langesikhathi sombuso wegandelelo. Eminyakeni eyadlulako indawo leya beyitjenziswa njengendawo yokujezisa neyokubopha abantu abavukela umbuso. Kukuplapho indawo leyaduma khona njengejele elabe ligadwe khulu.

Ipilo ejele ngesikhathi sombuso wegandelelo

Indawo le ngesikhathi sombuso wegandelelo yathoma umsebenzi wokuthi kuvalelwe kiyo abantu ekhabe balwisana nombuso webandlululo, nabanye abasopolitiki ekhabe balwela ikululeko. Ipilo ejele le beyaziwa ngokuthi ihlukanisa iimbotjhwa nabantu, ukusebenzisa iimbotjhwa nzima, nesihlungu. Imbotjhwa zakhona ezinye bezisetjenziswa kukhwari yelitje le lime. Iimbotjhwa ejele ye roben island zabe zihlukunyezwa emzimbeni nemmoyeni, beziphiwa Ukudla okuncani, begodu zihlezi nakabuhlungu. Imbotjhwa khabe zigade khulu ukuphula ithemba kilabo ekhabe balwisana nombuso webandlululo. Nanyana bekunjalo lokho akhange kuvimbe iimbotjhwa zangaleso skhathi ukuthi zifunde begodu ziragele phambili nokufuna ikululeko.

Abantu abavelelwa ERoben Island

UNelson Mandela owabe amdosi phambili wehlangano ye- ANC wabotjhwa ejele le iminyaka ema-18, kusekela ngonyaka we-1964 ukuya ngonyaka we1982.&lt;ref&gt;Roux, D., 2020. 5 Writing from Robben Island. ''Prison Writing and the Literary World: Imprisonment, Institutionality and Questions of Literary Practice'', p.93.&lt;/ref&gt; UNelson Mandela wadlala indima yokwenza bonyana iimbotjhwa zibumbane entronkweni, waraga ukulelwa ikululeko nanyana bekavalelwe. Wahlukaniswa nomndeni wakhe akhange avunyelwe bonyana ayokubulunga unina Kanye nendodana yakhe ekulu. Abnaye abantu ababotjwa e Roben Island ngu Walter Sisulu, Govan Mbeki no Robert Sibukwe.

Robert Sobukwe yena wabe amdosi phambili wehlangano ye Pan African Congress (PAC) yena nakavalelwako wabekwa ayedwa bonyana kungabi nabantu abamvakatjhelako. USobukwe wenzekwa umthetho okhethekileko owawubizwa nge”Sobukwe Clause” ukwenzele ukuthi avalelwe yedwa ngejele. Wakatelelwa bonyana atjhugulule umkhumbulo wakhe  wokuthoma umnyakazo wokulwisana nombuso wegandelelo kodwana akhange avume. UWalter Sisulu wagwetjwa isisgwebo sepilo yakhe yoke ejele ngombana watholakala azibandakanye  emnyakazweni wokulwisana nombuso wegandelelo. Wahlala ejele pheze iminyaka emam-20. Ngonyaka we-1982 wasuswa wasiwa ePollsomor ekuyijele eseduze nekapa, ekukulapho waragela khona phambili wajamela ukuphela kombuso webandululo.

Ngemva  kokuthi kuphele umbuso wegandelelo I-Roben island yenziwa yabo yindawo yamagugu ye- UNESCO ngonyaka we-1999, lokho kwenziwa kukobana kwabe kubonwa umlando  wayo oqakathekileko  nokuthumba kwemiphefumulo wabantu phezulu kokubandlululana. Eskhathini sanje ijele sele yenziwe I myuziyemu nethswayo lethemba, ikululeko kanye nentando yenengi.&lt;ref&gt;[https://iol.co.za/travel/south-africa/western-cape/2021-09-23-the-making--and-then-breaking--of-robben-island-museum/ The making – and then breaking – of Robben Island Museum]&lt;/ref&gt; Abayeni bakghona  ukuthatha ikhambo elidswa phambili mumuntu bese umuntu loyo abakhombise amakamero wangejele lapho bekulala khona iimbotjhwa bese abakhombise nalapho kune khwari yelitje le- lime.</text>
      <sha1>ctva7rluofikryege45a5tzv7p4v6tt</sha1>
    </revision>
    <revision>
      <id>3459</id>
      <parentid>3458</parentid>
      <timestamp>2025-07-28T09:35:09Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3459</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3258" sha1="mwrofesu64hctz261yxgvclt1cbgl20" xml:space="preserve">'''I-Roben island''' kuyindawo lapho etholakala egwini le-Cape town, enarheni yeSewula afrika. Indawo le ngenye yendawo ezikhumbuza iSewula Afrika ngezolo layo elibuhlungu langesikhathi sombuso wegandelelo. Eminyakeni eyadlulako indawo leya beyitjenziswa njengendawo yokujezisa neyokubopha abantu abavukela umbuso. Kukuplapho indawo leyaduma khona njengejele elabe ligadwe khulu.

Ipilo ejele ngesikhathi sombuso wegandelelo

Indawo le ngesikhathi sombuso wegandelelo yathoma umsebenzi wokuthi kuvalelwe kiyo abantu ekhabe balwisana nombuso wegandelelo, nabanye abasopolitiki ekhabe balwela ikululeko. Ipilo ejele le beyaziwa ngokuthi ihlukanisa iimbotjhwa nabantu, ukusebenzisa iimbotjhwa nzima, nesihlungu. Imbotjhwa zakhona ezinye bezisetjenziswa kukhwari yelitje le lime. Iimbotjhwa ejele ye roben island zabe zihlukunyezwa emzimbeni nemmoyeni, beziphiwa Ukudla okuncani, begodu zihlezi nakabuhlungu. Imbotjhwa khabe zigade khulu ukuphula ithemba kilabo ekhabe balwisana nombuso webandlululo. Nanyana bekunjalo lokho akhange kuvimbe iimbotjhwa zangaleso skhathi ukuthi zifunde begodu ziragele phambili nokufuna ikululeko.

Abantu abavelelwa ERoben Island

UNelson Mandela owabe amdosi phambili wehlangano ye- ANC wabotjhwa ejele le iminyaka ema-18, kusekela ngonyaka we-1964 ukuya ngonyaka we1982.&lt;ref&gt;Roux, D., 2020. 5 Writing from Robben Island. ''Prison Writing and the Literary World: Imprisonment, Institutionality and Questions of Literary Practice'', p.93.&lt;/ref&gt; UNelson Mandela wadlala indima yokwenza bonyana iimbotjhwa zibumbane entronkweni, waraga ukulelwa ikululeko nanyana bekavalelwe. Wahlukaniswa nomndeni wakhe akhange avunyelwe bonyana ayokubulunga unina Kanye nendodana yakhe ekulu. Abnaye abantu ababotjwa e Roben Island ngu Walter Sisulu, Govan Mbeki no Robert Sibukwe.

Robert Sobukwe yena wabe amdosi phambili wehlangano ye Pan African Congress (PAC) yena nakavalelwako wabekwa ayedwa bonyana kungabi nabantu abamvakatjhelako. USobukwe wenzekwa umthetho okhethekileko owawubizwa nge”Sobukwe Clause” ukwenzele ukuthi avalelwe yedwa ngejele. Wakatelelwa bonyana atjhugulule umkhumbulo wakhe  wokuthoma umnyakazo wokulwisana nombuso wegandelelo kodwana akhange avume. UWalter Sisulu wagwetjwa isisgwebo sepilo yakhe yoke ejele ngombana watholakala azibandakanye  emnyakazweni wokulwisana nombuso wegandelelo. Wahlala ejele pheze iminyaka emam-20. Ngonyaka we-1982 wasuswa wasiwa ePollsomor ekuyijele eseduze nekapa, ekukulapho waragela khona phambili wajamela ukuphela kombuso webandululo.

Ngemva  kokuthi kuphele umbuso wegandelelo I-Roben island yenziwa yabo yindawo yamagugu ye- UNESCO ngonyaka we-1999, lokho kwenziwa kukobana kwabe kubonwa umlando  wayo oqakathekileko  nokuthumba kwemiphefumulo wabantu phezulu kokubandlululana. Eskhathini sanje ijele sele yenziwe I myuziyemu nethswayo lethemba, ikululeko kanye nentando yenengi.&lt;ref&gt;[https://iol.co.za/travel/south-africa/western-cape/2021-09-23-the-making--and-then-breaking--of-robben-island-museum/ The making – and then breaking – of Robben Island Museum]&lt;/ref&gt; Abayeni bakghona  ukuthatha ikhambo elidswa phambili mumuntu bese umuntu loyo abakhombise amakamero wangejele lapho bekulala khona iimbotjhwa bese abakhombise nalapho kune khwari yelitje le- lime.</text>
      <sha1>mwrofesu64hctz261yxgvclt1cbgl20</sha1>
    </revision>
    <revision>
      <id>3460</id>
      <parentid>3459</parentid>
      <timestamp>2025-07-28T09:36:56Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3460</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3262" sha1="bwmknesjvf5dwtz39s4vjo1jk3azvx1" xml:space="preserve">'''I-Roben island''' kuyindawo lapho etholakala egwini le-Cape town, enarheni yeSewula afrika. Indawo le ngenye yendawo ezikhumbuza iSewula Afrika ngezolo layo elibuhlungu langesikhathi sombuso wegandelelo. Eminyakeni eyadlulako indawo leya beyitjenziswa njengendawo yokujezisa neyokubopha abantu abavukela umbuso. Kukuplapho indawo leyaduma khona njengejele elabe ligadwe khulu.

Ipilo ejele ngesikhathi sombuso wegandelelo

Indawo le ngesikhathi sombuso wegandelelo yathoma umsebenzi wokuthi kuvalelwe kiyo abantu ekhabe balwisana nombuso wegandelelo, nabanye abasopolitiki ekhabe balwela ikululeko. Ipilo ejele le beyaziwa ngokuthi ihlukanisa iimbotjhwa nabantu, ukusebenzisa iimbotjhwa nzima, nesihlungu. Imbotjhwa zakhona ezinye bezisetjenziswa kukhwari yelitje le lime. Iimbotjhwa ejele ye roben island zabe zihlukunyezwa emzimbeni nemmoyeni, beziphiwa Ukudla okuncani, begodu zihlezi nakabuhlungu. Imbotjhwa khabe zigade khulu ukuphula ithemba kilabo ekhabe balwisana nombuso webandlululo. Nanyana bekunjalo lokho akhange kuvimbe iimbotjhwa zangaleso skhathi ukuthi zifunde begodu ziragele phambili nokufuna ikululeko.

Abantu abavelelwa ERoben Island

UNelson Mandela owabe amdosi phambili wehlangano ye- ANC wabotjhwa ejele le iminyaka ema-18, kusekela ngonyaka we-1964 ukuya ngonyaka we1982.&lt;ref&gt;Roux, D., 2020. 5 Writing from Robben Island. ''Prison Writing and the Literary World: Imprisonment, Institutionality and Questions of Literary Practice'', p.93.&lt;/ref&gt; UNelson Mandela wadlala indima yokwenza bonyana iimbotjhwa zibumbane entronkweni, waraga ukulelwa ikululeko nanyana bekavalelwe. Wahlukaniswa nomndeni wakhe akhange avunyelwe bonyana ayokubulunga unina Kanye nendodana yakhe ekulu. Abnaye abantu ababotjwa e Roben Island ngu Walter Sisulu, Govan Mbeki no Robert Sibukwe.

Robert Sobukwe yena wabe amdosi phambili wehlangano ye Pan African Congress (PAC) yena nakavalelwako wabekwa ayedwa bonyana kungabi nabantu abamvakatjhelako. USobukwe wenzekwa umthetho okhethekileko owawubizwa nge”Sobukwe Clause” ukwenzele ukuthi avalelwe yedwa ngejele. Wakatelelwa bonyana atjhugulule umkhumbulo wakhe  wokuthoma umnyakazo wokulwisana nombuso wegandelelo kodwana akhange avume. UWalter Sisulu wagwetjwa isisgwebo sepilo yakhe yoke ejele ngombana watholakala azibandakanye  emnyakazweni wokulwisana nombuso wegandelelo. Wahlala ejele pheze iminyaka emam-20. Ngonyaka we-1982 wasuswa wasiwa ePollsomor ekuyijele eseduze nekapa, ekukulapho waragela khona phambili wajamela ukuphela kombuso wegandelelo.

Ngemva  kokuthi kuphele [[umbuso wegandelelo]] I-Roben island yenziwa yabo yindawo yamagugu ye- UNESCO ngonyaka we-1999, lokho kwenziwa kukobana kwabe kubonwa umlando  wayo oqakathekileko  nokuthumba kwemiphefumulo wabantu phezulu kokubandlululana. Eskhathini sanje ijele sele yenziwe I myuziyemu nethswayo lethemba, ikululeko kanye nentando yenengi.&lt;ref&gt;[https://iol.co.za/travel/south-africa/western-cape/2021-09-23-the-making--and-then-breaking--of-robben-island-museum/ The making – and then breaking – of Robben Island Museum]&lt;/ref&gt; Abayeni bakghona  ukuthatha ikhambo elidswa phambili mumuntu bese umuntu loyo abakhombise amakamero wangejele lapho bekulala khona iimbotjhwa bese abakhombise nalapho kune khwari yelitje le- lime.</text>
      <sha1>bwmknesjvf5dwtz39s4vjo1jk3azvx1</sha1>
    </revision>
    <revision>
      <id>3461</id>
      <parentid>3460</parentid>
      <timestamp>2025-07-28T09:39:11Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3461</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3326" sha1="p3zuo4mqqzvs6nxi56l8e39sygahpdh" xml:space="preserve">'''I-Roben island''' kuyindawo lapho etholakala egwini le-Cape town, enarheni yeSewula afrika. Indawo le ngenye yendawo ezikhumbuza iSewula Afrika ngezolo layo elibuhlungu langesikhathi sombuso wegandelelo. Eminyakeni eyadlulako ngaphambi kobana kuthome umbuso wentando yenengi eSewula afrika,indawo leya beyitjenziswa njengendawo yokujezisa neyokubopha abantu abavukela umbuso. Kukulapho indawo le yaziwa khona njengejele elabe ligadwe khulu.

Ipilo ejele ngesikhathi sombuso wegandelelo

Indawo le ngesikhathi sombuso wegandelelo yathoma umsebenzi wokuthi kuvalelwe kiyo abantu ekhabe balwisana nombuso wegandelelo, nabanye abasopolitiki ekhabe balwela ikululeko. Ipilo ejele le beyaziwa ngokuthi ihlukanisa iimbotjhwa nabantu, ukusebenzisa iimbotjhwa nzima, nesihlungu. Imbotjhwa zakhona ezinye bezisetjenziswa kukhwari yelitje le lime. Iimbotjhwa ejele ye roben island zabe zihlukunyezwa emzimbeni nemmoyeni, beziphiwa Ukudla okuncani, begodu zihlezi nakabuhlungu. Imbotjhwa khabe zigade khulu ukuphula ithemba kilabo ekhabe balwisana nombuso webandlululo. Nanyana bekunjalo lokho akhange kuvimbe iimbotjhwa zangaleso skhathi ukuthi zifunde begodu ziragele phambili nokufuna ikululeko.

Abantu abavelelwa ERoben Island

UNelson Mandela owabe amdosi phambili wehlangano ye- ANC wabotjhwa ejele le iminyaka ema-18, kusekela ngonyaka we-1964 ukuya ngonyaka we1982.&lt;ref&gt;Roux, D., 2020. 5 Writing from Robben Island. ''Prison Writing and the Literary World: Imprisonment, Institutionality and Questions of Literary Practice'', p.93.&lt;/ref&gt; UNelson Mandela wadlala indima yokwenza bonyana iimbotjhwa zibumbane entronkweni, waraga ukulelwa ikululeko nanyana bekavalelwe. Wahlukaniswa nomndeni wakhe akhange avunyelwe bonyana ayokubulunga unina Kanye nendodana yakhe ekulu. Abnaye abantu ababotjwa e Roben Island ngu Walter Sisulu, Govan Mbeki no Robert Sibukwe.

Robert Sobukwe yena wabe amdosi phambili wehlangano ye Pan African Congress (PAC) yena nakavalelwako wabekwa ayedwa bonyana kungabi nabantu abamvakatjhelako. USobukwe wenzekwa umthetho okhethekileko owawubizwa nge”Sobukwe Clause” ukwenzele ukuthi avalelwe yedwa ngejele. Wakatelelwa bonyana atjhugulule umkhumbulo wakhe  wokuthoma umnyakazo wokulwisana nombuso wegandelelo kodwana akhange avume. UWalter Sisulu wagwetjwa isisgwebo sepilo yakhe yoke ejele ngombana watholakala azibandakanye  emnyakazweni wokulwisana nombuso wegandelelo. Wahlala ejele pheze iminyaka emam-20. Ngonyaka we-1982 wasuswa wasiwa ePollsomor ekuyijele eseduze nekapa, ekukulapho waragela khona phambili wajamela ukuphela kombuso wegandelelo.

Ngemva  kokuthi kuphele [[umbuso wegandelelo]] I-Roben island yenziwa yabo yindawo yamagugu ye- UNESCO ngonyaka we-1999, lokho kwenziwa kukobana kwabe kubonwa umlando  wayo oqakathekileko  nokuthumba kwemiphefumulo wabantu phezulu kokubandlululana. Eskhathini sanje ijele sele yenziwe I myuziyemu nethswayo lethemba, ikululeko kanye nentando yenengi.&lt;ref&gt;[https://iol.co.za/travel/south-africa/western-cape/2021-09-23-the-making--and-then-breaking--of-robben-island-museum/ The making – and then breaking – of Robben Island Museum]&lt;/ref&gt; Abayeni bakghona  ukuthatha ikhambo elidswa phambili mumuntu bese umuntu loyo abakhombise amakamero wangejele lapho bekulala khona iimbotjhwa bese abakhombise nalapho kune khwari yelitje le- lime.</text>
      <sha1>p3zuo4mqqzvs6nxi56l8e39sygahpdh</sha1>
    </revision>
    <revision>
      <id>3466</id>
      <parentid>3461</parentid>
      <timestamp>2025-07-28T17:23:22Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3466</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3451" sha1="0qx0zc6krmht7dr946izkmb0h8yyqyi" xml:space="preserve">[[Isimumathi:Robben Island fængslet Sektion B.jpg|thumb|Ijele i-Roben Island]]
'''I-Roben island''' kuyindawo lapho etholakala egwini le-Cape town, enarheni yeSewula afrika. Indawo le ngenye yendawo ezikhumbuza iSewula Afrika ngezolo layo elibuhlungu langesikhathi sombuso wegandelelo. Eminyakeni eyadlulako ngaphambi kobana kuthome umbuso wentando yenengi eSewula afrika, indawo leya beyitjenziswa njengendawo yokujezisa neyokubopha abantu abavukela umbuso. Kukulapho indawo le yaziwa khona njengejele elabe ligadwe khulu, ngesibanga sokugada abantu ababotjhwe kilo.

Ipilo ejele ngesikhathi sombuso wegandelelo

Indawo le ngesikhathi sombuso wegandelelo yathoma umsebenzi wokuthi kuvalelwe kiyo abantu ekhabe balwisana nombuso wegandelelo, nabanye abasopolitiki ekhabe balwela ikululeko. Ipilo ejele le beyaziwa ngokuthi ihlukanisa iimbotjhwa nabantu, ukusebenzisa iimbotjhwa nzima, nesihlungu. Imbotjhwa zakhona ezinye bezisetjenziswa kukhwari yelitje le lime. Iimbotjhwa ejele ye roben island zabe zihlukunyezwa emzimbeni nemmoyeni, beziphiwa Ukudla okuncani, begodu zihlezi nakabuhlungu. Imbotjhwa khabe zigade khulu ukuphula ithemba kilabo ekhabe balwisana nombuso webandlululo. Nanyana bekunjalo lokho akhange kuvimbe iimbotjhwa zangaleso skhathi ukuthi zifunde begodu ziragele phambili nokufuna ikululeko.

Abantu abavelelwa ERoben Island

UNelson Mandela owabe amdosi phambili wehlangano ye- ANC wabotjhwa ejele le iminyaka ema-18, kusekela ngonyaka we-1964 ukuya ngonyaka we1982.&lt;ref&gt;Roux, D., 2020. 5 Writing from Robben Island. ''Prison Writing and the Literary World: Imprisonment, Institutionality and Questions of Literary Practice'', p.93.&lt;/ref&gt; UNelson Mandela wadlala indima yokwenza bonyana iimbotjhwa zibumbane entronkweni, waraga ukulelwa ikululeko nanyana bekavalelwe. Wahlukaniswa nomndeni wakhe akhange avunyelwe bonyana ayokubulunga unina Kanye nendodana yakhe ekulu. Abnaye abantu ababotjwa e-Roben Island ngu Walter Sisulu, Govan Mbeki no Robert Sibukwe.

Robert Sobukwe yena wabe amdosi phambili wehlangano ye Pan African Congress (PAC) yena nakavalelwako wabekwa ayedwa bonyana kungabi nabantu abamvakatjhelako. USobukwe wenzekwa umthetho okhethekileko owawubizwa nge”Sobukwe Clause” ukwenzele ukuthi avalelwe yedwa ngejele. Wakatelelwa bonyana atjhugulule umkhumbulo wakhe  wokuthoma umnyakazo wokulwisana nombuso wegandelelo kodwana akhange avume. UWalter Sisulu wagwetjwa isisgwebo sepilo yakhe yoke ejele ngombana watholakala azibandakanye  emnyakazweni wokulwisana nombuso wegandelelo. Wahlala ejele pheze iminyaka emam-20. Ngonyaka we-1982 wasuswa wasiwa ePollsomor ekuyijele eseduze nekapa, ekukulapho waragela khona phambili wajamela ukuphela kombuso wegandelelo.

Ngemva  kokuthi kuphele [[umbuso wegandelelo]] I-Roben island yenziwa yabo yindawo yamagugu ye- UNESCO ngonyaka we-1999, lokho kwenziwa kukobana kwabe kubonwa umlando  wayo oqakathekileko  nokuthumba kwemiphefumulo wabantu phezulu kokubandlululana. Eskhathini sanje ijele sele yenziwe I myuziyemu nethswayo lethemba, ikululeko kanye nentando yenengi.&lt;ref&gt;[https://iol.co.za/travel/south-africa/western-cape/2021-09-23-the-making--and-then-breaking--of-robben-island-museum/ The making – and then breaking – of Robben Island Museum]&lt;/ref&gt; Abayeni bakghona  ukuthatha ikhambo elidswa phambili mumuntu bese umuntu loyo abakhombise amakamero wangejele lapho bekulala khona iimbotjhwa bese abakhombise nalapho kune khwari yelitje le- lime.</text>
      <sha1>0qx0zc6krmht7dr946izkmb0h8yyqyi</sha1>
    </revision>
    <revision>
      <id>3474</id>
      <parentid>3466</parentid>
      <timestamp>2025-07-29T14:30:29Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3474</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3908" sha1="oqm8oq9koswj4deo41qlon21l1q5pif" xml:space="preserve">[[Isimumathi:Robben Island fængslet Sektion B.jpg|thumb|Ijele i-Roben Island]]
'''I-Roben Island''' kuyindawo lapho etholakala egwini le-Cape town, enarheni yeSewula afrika. Indawo le ngenye yendawo ezikhumbuza iSewula Afrika ngezolo layo elibuhlungu langesikhathi sombuso wegandelelo. Eminyakeni eyadlulako ngaphambi kobana kuthome umbuso wentando yenengi eSewula afrika, indawo leya beyitjenziswa njengendawo yokujezisa neyokubopha abantu abavukela umbuso. Kukulapho indawo le yaziwa khona njengejele elabe ligadwe khulu, ngesibanga sokugada abantu ababotjhwe kilo.

Ipilo ejele ngesikhathi sombuso wegandelelo

Indawo le ngesikhathi sombuso wegandelelo yathoma umsebenzi wokuthi kuvalelwe kiyo abantu ekhabe balwisana nombuso wegandelelo, nabanye abasopolitiki ekhabe balwela ikululeko. Ipilo ejele le beyaziwa ngokuthi ihlukanisa iimbotjhwa nabantu, ukusebenzisa iimbotjhwa nzima, nesihlungu. Imbotjhwa zakhona ezinye bezisetjenziswa kukhwari yelitje le lime. Iimbotjhwa ejele ye roben island zabe zihlukunyezwa emzimbeni nemmoyeni, beziphiwa Ukudla okuncani, begodu zihlezi nakabuhlungu. Imbotjhwa khabe zigade khulu ukuphula ithemba kilabo ekhabe balwisana nombuso webandlululo. Nanyana bekunjalo lokho akhange kuvimbe iimbotjhwa zangaleso skhathi ukuthi zifunde begodu ziragele phambili nokufuna ikululeko.

Abantu abavelelwa ERoben Island

UNelson Mandela owabe amdosi phambili wehlangano ye- ANC (''African National Congress'') wabotjhwa ejele le iminyaka ema-18, kusekela ngonyaka we-1964 ukuya ngonyaka we1982.&lt;ref&gt;Roux, D., 2020. 5 Writing from Robben Island. ''Prison Writing and the Literary World: Imprisonment, Institutionality and Questions of Literary Practice'', p.93.&lt;/ref&gt; UNelson Mandela wadlala indima yokwenza bonyana iimbotjhwa zibumbane entronkweni, waraga ukulelwa ikululeko nanyana bekavalelwe. Wahlukaniswa nomndeni wakhe akhange avunyelwe bonyana ayokubulunga unina Kanye nendodana yakhe ekulu. Abanye abantu ababotjwa e-Roben Island ngu Walter Sisulu, Govan Mbeki no Robert Sibukwe.  

Robert Sobukwe yena wabe amdosi phambili wehlangano ye-''Pan African Congress'' (PAC) yena nakavalelwako wabekwa ayedwa bonyana kungabi nabantu abamvakatjhelako. USobukwe wenzelwa umthetho okhethekileko owawubizwa nge”Sobukwe Clause” ukwenzele ukuthi avalelwe yedwa ngejele. Wakatelelwa bonyana atjhugulule umkhumbulo wakhe  wokuthoma umnyakazo wokulwisana nombuso wegandelelo kodwana akhange avume. UWalter Sisulu wagwetjwa isisgwebo sepilo yakhe yoke ejele ngombana watholakala azibandakanye  emnyakazweni wokulwisana nombuso wegandelelo.&lt;ref&gt;Nwafor, O., 2012. Nelson Mandela and the politics of representation in Robben Island Museum, South Africa. ''AFRREV IJAH: An International Journal of Arts and Humanities'', ''1''(2), pp.133-141.&lt;/ref&gt;Wahlala ejele pheze iminyaka emam-20. Ngonyaka we-1982 wasuswa wasiwa ePollsomor ekuyijele eseduze nekapa, ekukulapho waragela khona phambili wajamela ukuphela kombuso wegandelelo.

Ngemva  kokuthi kuphele [[umbuso wegandelelo]] I-Roben island yenziwa yabo yindawo yamagugu ye- UNESCO ngonyaka we-1999, lokho kwenziwa kukobana kwabe kubonwa umlando  wayo oqakathekileko  nokuthumba kwemiphefumulo wabantu phezulu kokubandlululana.&lt;ref&gt;Ngewu, M., 2022. What is the impact of World Heritage status and related positioning for a tourist audience on Robben Island's meanings and public narratives?.&lt;/ref&gt; Eskhathini sanje ijele sele yenziwe I myuziyemu nethswayo lethemba, ikululeko kanye nentando yenengi.&lt;ref&gt;[https://iol.co.za/travel/south-africa/western-cape/2021-09-23-the-making--and-then-breaking--of-robben-island-museum/ The making – and then breaking – of Robben Island Museum]&lt;/ref&gt; Abayeni abavela endaweni ezihlukahlukeneko zephasi bakghona  ukuthatha ikhambo elidoswa phambili mumuntu, bese umuntu loyo abakhombise amakamero wangejele lapho bekulala khona iimbotjhwa bese abakhombise nalapho kune khwari yelitje le- lime.</text>
      <sha1>oqm8oq9koswj4deo41qlon21l1q5pif</sha1>
    </revision>
    <revision>
      <id>3494</id>
      <parentid>3474</parentid>
      <timestamp>2025-07-29T16:29:50Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3494</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3989" sha1="2rpwbsx6jmvi254wcentqnxr7ytswpo" xml:space="preserve">[[Isimumathi:Robben Island fængslet Sektion B.jpg|thumb|Ijele i-Roben Island]]
'''I-Roben Island''' kuyindawo lapho etholakala egwini le-Cape town, enarheni yeSewula afrika. Indawo le ngenye yendawo ezikhumbuza iSewula Afrika ngezolo layo elibuhlungu langesikhathi sombuso wegandelelo. Eminyakeni eyadlulako ngaphambi kobana kuthome umbuso wentando yenengi eSewula afrika, indawo leya beyitjenziswa njengendawo yokujezisa neyokubopha abantu abavukela umbuso. Kukulapho indawo le yaziwa khona njengejele elabe ligadwe khulu, ngesibanga sokugada abantu ababotjhwe kilo.

=== Ipilo ejele ngesikhathi sombuso wegandelelo ===
Indawo le ngesikhathi sombuso wegandelelo yathoma umsebenzi wokuthi kuvalelwe kiyo abantu ekhabe balwisana nombuso wegandelelo, nabanye abasopolitiki ekhabe balwela ikululeko. Ipilo ejele le beyaziwa ngokuthi ihlukanisa iimbotjhwa nabantu, ukusebenzisa iimbotjhwa nzima, nesihlungu. Imbotjhwa zakhona ezinye bezisetjenziswa kukhwari yelitje le lime. Iimbotjhwa ejele ye roben island zabe zihlukunyezwa emzimbeni nemmoyeni, beziphiwa Ukudla okuncani, begodu zihlezi nakabuhlungu. Imbotjhwa khabe zigade khulu ukuphula ithemba kilabo ekhabe balwisana nombuso webandlululo. Nanyana bekunjalo lokho akhange kuvimbe iimbotjhwa zangaleso skhathi ukuthi zifunde begodu ziragele phambili nokufuna ikululeko.

=== Abantu abavelelwa ERoben Island ===
[[UNelson Mandela]] owabe amdosi phambili wehlangano ye- ANC (''African National Congress'') wabotjhwa ejele le iminyaka ema-18, kusekela ngonyaka we-1964 ukuya ngonyaka we1982.&lt;ref&gt;Roux, D., 2020. 5 Writing from Robben Island. ''Prison Writing and the Literary World: Imprisonment, Institutionality and Questions of Literary Practice'', p.93.&lt;/ref&gt; UNelson Mandela wadlala indima yokwenza bonyana iimbotjhwa zibumbane entronkweni, waraga ukulelwa ikululeko nanyana bekavalelwe. Wahlukaniswa nomndeni wakhe akhange avunyelwe bonyana ayokubulunga unina Kanye nendodana yakhe ekulu. Abanye abantu ababotjwa e-Roben Island ngu Walter Sisulu, Govan Mbeki no Robert Sibukwe.  

Robert Sobukwe yena wabe amdosi phambili wehlangano ye-''Pan African Congress'' (PAC) yena nakavalelwako wabekwa ayedwa bonyana kungabi nabantu abamvakatjhelako. USobukwe wenzelwa umthetho okhethekileko owawubizwa nge”Sobukwe Clause” ukwenzele ukuthi avalelwe yedwa ngejele. Wakatelelwa bonyana atjhugulule umkhumbulo wakhe  wokuthoma umnyakazo wokulwisana nombuso wegandelelo kodwana akhange avume. [[UWalter Sisulu]] wagwetjwa isisgwebo sepilo yakhe yoke ejele ngombana watholakala azibandakanye  emnyakazweni wokulwisana nombuso wegandelelo.&lt;ref&gt;Nwafor, O., 2012. Nelson Mandela and the politics of representation in Robben Island Museum, South Africa. ''AFRREV IJAH: An International Journal of Arts and Humanities'', ''1''(2), pp.133-141.&lt;/ref&gt;Wahlala ejele pheze iminyaka emam-20. Ngonyaka we-1982 wasuswa wasiwa ePollsomor ekuyijele eseduze nekapa, ekukulapho waragela khona phambili wajamela ukuphela kombuso wegandelelo.

=== ukuraga kwe-Roben island ngemva kombuso wegandelelo ===
Ngemva  kokuthi kuphele [[umbuso wegandelelo]] I-Robenisland yenziwa yabo yindawo yamagugu ye- UNESCO ngonyaka we-1999, lokho kwenziwa kukobana kwabe kubonwa umlando  wayo oqakathekileko  nokuthumba kwemiphefumulo wabantu phezulu kokubandlululana.&lt;ref&gt;Ngewu, M., 2022. What is the impact of World Heritage status and related positioning for a tourist audience on Robben Island's meanings and public narratives?.&lt;/ref&gt; Eskhathini sanje ijele sele yenziwe I myuziyemu nethswayo lethemba, ikululeko kanye nentando yenengi.&lt;ref&gt;[https://iol.co.za/travel/south-africa/western-cape/2021-09-23-the-making--and-then-breaking--of-robben-island-museum/ The making – and then breaking – of Robben Island Museum]&lt;/ref&gt; Abayeni abavela endaweni ezihlukahlukeneko zephasi bakghona  ukuthatha ikhambo elidoswa phambili mumuntu, bese umuntu loyo abakhombise amakamero wangejele lapho bekulala khona iimbotjhwa bese abakhombise nalapho kune khwari yelitje le- lime.</text>
      <sha1>2rpwbsx6jmvi254wcentqnxr7ytswpo</sha1>
    </revision>
    <revision>
      <id>3495</id>
      <parentid>3494</parentid>
      <timestamp>2025-07-29T16:34:23Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3495</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4138" sha1="rm6nbeuwawlsg3virfwpfknhzy00ayy" xml:space="preserve">[[Isimumathi:Robben Island fængslet Sektion B.jpg|thumb|Ijele i-Roben Island]]
'''I-Roben Island''' kuyindawo lapho etholakala egwini le-Cape town, enarheni yeSewula afrika. Indawo le ngenye yendawo ezikhumbuza iSewula Afrika ngezolo layo elibuhlungu langesikhathi sombuso wegandelelo. Eminyakeni eyadlulako ngaphambi kobana kuthome umbuso wentando yenengi eSewula afrika, indawo leya beyitjenziswa njengendawo yokujezisa neyokubopha abantu abavukela umbuso. Kukulapho indawo le yaziwa khona njengejele elabe ligadwe khulu, ngesibanga sokugada abantu ababotjhwe kilo.

=== Ipilo ejele ngesikhathi sombuso wegandelelo ===
Indawo le ngesikhathi sombuso wegandelelo yathoma umsebenzi wokuthi kuvalelwe kiyo abantu ekhabe balwisana nombuso wegandelelo, nabanye abasopolitiki ekhabe balwela ikululeko. Ipilo ejele le beyaziwa ngokuthi ihlukanisa iimbotjhwa nabantu, ukusebenzisa iimbotjhwa nzima, nesihlungu.&lt;ref&gt;Skotnes, A., 2023. Robben Island and the Culture of Reconstruction in South Africa. ''Radical History Review'', ''2023''(146), pp.178-202.&lt;/ref&gt; Imbotjhwa zakhona ezinye bezisetjenziswa kukhwari yelitje le lime. Iimbotjhwa ejele ye roben island zabe zihlukunyezwa emzimbeni nemmoyeni, beziphiwa Ukudla okuncani, begodu zihlezi nakabuhlungu. Imbotjhwa khabe zigade khulu ukuphula ithemba kilabo ekhabe balwisana nombuso webandlululo. Nanyana bekunjalo lokho akhange kuvimbe iimbotjhwa zangaleso skhathi ukuthi zifunde begodu ziragele phambili nokufuna ikululeko.

=== Abantu abavelelwa ERoben Island ===
[[UNelson Mandela]] owabe amdosi phambili wehlangano ye- ANC (''African National Congress'') wabotjhwa ejele le iminyaka ema-18, kusekela ngonyaka we-1964 ukuya ngonyaka we1982.&lt;ref&gt;Roux, D., 2020. 5 Writing from Robben Island. ''Prison Writing and the Literary World: Imprisonment, Institutionality and Questions of Literary Practice'', p.93.&lt;/ref&gt; UNelson Mandela wadlala indima yokwenza bonyana iimbotjhwa zibumbane entronkweni, waraga ukulelwa ikululeko nanyana bekavalelwe. Wahlukaniswa nomndeni wakhe akhange avunyelwe bonyana ayokubulunga unina Kanye nendodana yakhe ekulu. Abanye abantu ababotjwa e-Roben Island ngu Walter Sisulu, Govan Mbeki no Robert Sibukwe.  

Robert Sobukwe yena wabe amdosi phambili wehlangano ye-''Pan African Congress'' (PAC) yena nakavalelwako wabekwa ayedwa bonyana kungabi nabantu abamvakatjhelako. USobukwe wenzelwa umthetho okhethekileko owawubizwa nge”Sobukwe Clause” ukwenzele ukuthi avalelwe yedwa ngejele. Wakatelelwa bonyana atjhugulule umkhumbulo wakhe  wokuthoma umnyakazo wokulwisana nombuso wegandelelo kodwana akhange avume. [[UWalter Sisulu]] wagwetjwa isisgwebo sepilo yakhe yoke ejele ngombana watholakala azibandakanye  emnyakazweni wokulwisana nombuso wegandelelo.&lt;ref&gt;Nwafor, O., 2012. Nelson Mandela and the politics of representation in Robben Island Museum, South Africa. ''AFRREV IJAH: An International Journal of Arts and Humanities'', ''1''(2), pp.133-141.&lt;/ref&gt;Wahlala ejele pheze iminyaka emam-20. Ngonyaka we-1982 wasuswa wasiwa ePollsomor ekuyijele eseduze nekapa, ekukulapho waragela khona phambili wajamela ukuphela kombuso wegandelelo.

=== ukuraga kwe-Roben island ngemva kombuso wegandelelo ===
Ngemva  kokuthi kuphele [[umbuso wegandelelo]] I-Robenisland yenziwa yabo yindawo yamagugu ye- UNESCO ngonyaka we-1999, lokho kwenziwa kukobana kwabe kubonwa umlando  wayo oqakathekileko  nokuthumba kwemiphefumulo wabantu phezulu kokubandlululana.&lt;ref&gt;Ngewu, M., 2022. What is the impact of World Heritage status and related positioning for a tourist audience on Robben Island's meanings and public narratives?.&lt;/ref&gt; Eskhathini sanje ijele sele yenziwe I myuziyemu nethswayo lethemba, ikululeko kanye nentando yenengi.&lt;ref&gt;[https://iol.co.za/travel/south-africa/western-cape/2021-09-23-the-making--and-then-breaking--of-robben-island-museum/ The making – and then breaking – of Robben Island Museum]&lt;/ref&gt; Abayeni abavela endaweni ezihlukahlukeneko zephasi bakghona  ukuthatha ikhambo elidoswa phambili mumuntu, bese umuntu loyo abakhombise amakamero wangejele lapho bekulala khona iimbotjhwa bese abakhombise nalapho kune khwari yelitje le- lime.</text>
      <sha1>rm6nbeuwawlsg3virfwpfknhzy00ayy</sha1>
    </revision>
    <revision>
      <id>3496</id>
      <parentid>3495</parentid>
      <timestamp>2025-07-29T16:39:46Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3496</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4371" sha1="rx5gdp0kbxdto8zkue3pl45cthndfh4" xml:space="preserve">[[Isimumathi:Robben Island fængslet Sektion B.jpg|thumb|Ijele i-Roben Island]]
'''I-Roben Island''' kuyindawo lapho etholakala egwini le-Cape town, enarheni yeSewula afrika. Indawo le ngenye yendawo ezikhumbuza iSewula Afrika ngezolo layo elibuhlungu langesikhathi sombuso wegandelelo.&lt;ref&gt;Rodgers, J., 2017. Visitor experiences at prison museums: Fremantle prison, robben island museum, and Eastern state penitentiary. In ''The Palgrave handbook of prison tourism'' (pp. 787-810). London: Palgrave Macmillan UK.&lt;/ref&gt; Eminyakeni eyadlulako ngaphambi kobana kuthome umbuso wentando yenengi eSewula afrika, indawo leya beyitjenziswa njengendawo yokujezisa neyokubopha abantu abavukela umbuso. Kukulapho indawo le yaziwa khona njengejele elabe ligadwe khulu, ngesibanga sokugada abantu ababotjhwe kilo.

=== Ipilo ejele ngesikhathi sombuso wegandelelo ===
Indawo le ngesikhathi sombuso wegandelelo yathoma umsebenzi wokuthi kuvalelwe kiyo abantu ekhabe balwisana nombuso wegandelelo, nabanye abasopolitiki ekhabe balwela ikululeko. Ipilo ejele le beyaziwa ngokuthi ihlukanisa iimbotjhwa nabantu, ukusebenzisa iimbotjhwa nzima, nesihlungu.&lt;ref&gt;Skotnes, A., 2023. Robben Island and the Culture of Reconstruction in South Africa. ''Radical History Review'', ''2023''(146), pp.178-202.&lt;/ref&gt; Imbotjhwa zakhona ezinye bezisetjenziswa kukhwari yelitje le lime. Iimbotjhwa ejele ye roben island zabe zihlukunyezwa emzimbeni nemmoyeni, beziphiwa Ukudla okuncani, begodu zihlezi nakabuhlungu. Imbotjhwa khabe zigade khulu ukuphula ithemba kilabo ekhabe balwisana nombuso webandlululo. Nanyana bekunjalo lokho akhange kuvimbe iimbotjhwa zangaleso skhathi ukuthi zifunde begodu ziragele phambili nokufuna ikululeko.

=== Abantu abavelelwa ERoben Island ===
[[UNelson Mandela]] owabe amdosi phambili wehlangano ye- ANC (''African National Congress'') wabotjhwa ejele le iminyaka ema-18, kusekela ngonyaka we-1964 ukuya ngonyaka we1982.&lt;ref&gt;Roux, D., 2020. 5 Writing from Robben Island. ''Prison Writing and the Literary World: Imprisonment, Institutionality and Questions of Literary Practice'', p.93.&lt;/ref&gt; UNelson Mandela wadlala indima yokwenza bonyana iimbotjhwa zibumbane entronkweni, waraga ukulelwa ikululeko nanyana bekavalelwe. Wahlukaniswa nomndeni wakhe akhange avunyelwe bonyana ayokubulunga unina Kanye nendodana yakhe ekulu. Abanye abantu ababotjwa e-Roben Island ngu Walter Sisulu, Govan Mbeki no Robert Sibukwe.  

Robert Sobukwe yena wabe amdosi phambili wehlangano ye-''Pan African Congress'' (PAC) yena nakavalelwako wabekwa ayedwa bonyana kungabi nabantu abamvakatjhelako. USobukwe wenzelwa umthetho okhethekileko owawubizwa nge”Sobukwe Clause” ukwenzele ukuthi avalelwe yedwa ngejele. Wakatelelwa bonyana atjhugulule umkhumbulo wakhe  wokuthoma umnyakazo wokulwisana nombuso wegandelelo kodwana akhange avume. [[UWalter Sisulu]] wagwetjwa isisgwebo sepilo yakhe yoke ejele ngombana watholakala azibandakanye  emnyakazweni wokulwisana nombuso wegandelelo.&lt;ref&gt;Nwafor, O., 2012. Nelson Mandela and the politics of representation in Robben Island Museum, South Africa. ''AFRREV IJAH: An International Journal of Arts and Humanities'', ''1''(2), pp.133-141.&lt;/ref&gt;Wahlala ejele pheze iminyaka emam-20. Ngonyaka we-1982 wasuswa wasiwa ePollsomor ekuyijele eseduze nekapa, ekukulapho waragela khona phambili wajamela ukuphela kombuso wegandelelo.

=== ukuraga kwe-Roben island ngemva kombuso wegandelelo ===
Ngemva  kokuthi kuphele [[umbuso wegandelelo]] I-Robenisland yenziwa yabo yindawo yamagugu ye- UNESCO ngonyaka we-1999, lokho kwenziwa kukobana kwabe kubonwa umlando  wayo oqakathekileko  nokuthumba kwemiphefumulo wabantu phezulu kokubandlululana.&lt;ref&gt;Ngewu, M., 2022. What is the impact of World Heritage status and related positioning for a tourist audience on Robben Island's meanings and public narratives?.&lt;/ref&gt; Eskhathini sanje ijele sele yenziwe I myuziyemu nethswayo lethemba, ikululeko kanye nentando yenengi.&lt;ref&gt;[https://iol.co.za/travel/south-africa/western-cape/2021-09-23-the-making--and-then-breaking--of-robben-island-museum/ The making – and then breaking – of Robben Island Museum]&lt;/ref&gt; Abayeni abavela endaweni ezihlukahlukeneko zephasi bakghona  ukuthatha ikhambo elidoswa phambili mumuntu, bese umuntu loyo abakhombise amakamero wangejele lapho bekulala khona iimbotjhwa bese abakhombise nalapho kune khwari yelitje le- lime.</text>
      <sha1>rx5gdp0kbxdto8zkue3pl45cthndfh4</sha1>
    </revision>
    <revision>
      <id>3500</id>
      <parentid>3496</parentid>
      <timestamp>2025-07-30T09:06:20Z</timestamp>
      <contributor>
        <ip>41.13.104.47</ip>
      </contributor>
      <origin>3500</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4371" sha1="df35kumc8l1ss8db0v08oqkizyptrqn" xml:space="preserve">[[Isimumathi:Robben Island fængslet Sektion B.jpg|thumb|Ijele i-Roben Island]]
'''I-Roben Island''' kuyindawo lapho etholakala egwini le-Cape town, enarheni yeSewula afrika. Indawo le ngenye yendawo ezikhumbuza iSewula Afrika ngezolo layo elibuhlungu langesikhathi sombuso wegandelelo.&lt;ref&gt;Rodgers, J., 2017. Visitor experiences at prison museums: Fremantle prison, robben island museum, and Eastern state penitentiary. In ''The Palgrave handbook of prison tourism'' (pp. 787-810). London: Palgrave Macmillan UK.&lt;/ref&gt; Eminyakeni eyadlulako ngaphambi kobana kuthome umbuso wentando yenengi eSewula afrika, indawo leya beyitjenziswa njengendawo yokujezisa neyokubopha abantu abavukela umbuso. Kukulapho indawo le yaziwa khona njengejele elabe ligadwe khulu, ngesibanga sokugada abantu ababotjhwe kilo.

=== Ipilo ejele ngesikhathi sombuso wegandelelo ===
Indawo le ngesikhathi sombuso wegandelelo yathoma umsebenzi wokuthi kuvalelwe kiyo abantu ekhabe balwisana nombuso wegandelelo, nabanye abasopolitiki ekhabe balwela ikululeko. Ipilo ejele le beyaziwa ngokuthi ihlukanisa iimbotjhwa nabantu, ukusebenzisa iimbotjhwa nzima, nesihlungu.&lt;ref&gt;Skotnes, A., 2023. Robben Island and the Culture of Reconstruction in South Africa. ''Radical History Review'', ''2023''(146), pp.178-202.&lt;/ref&gt; Imbotjhwa zakhona ezinye bezisetjenziswa kukhwari yelitje le lime. Iimbotjhwa ejele ye roben island zabe zihlukunyezwa emzimbeni nemmoyeni, beziphiwa Ukudla okuncani, begodu zihlezi nakabuhlungu. Imbotjhwa khabe zigade khulu ukuphula ithemba kilabo ekhabe balwisana nombuso webandlululo. Nanyana bekunjalo lokho akhange kuvimbe iimbotjhwa zangaleso skhathi ukuthi zifunde begodu ziragele phambili nokufuna ikululeko.

=== Abantu abavalelwa ERoben Island ===
[[UNelson Mandela]] owabe amdosi phambili wehlangano ye- ANC (''African National Congress'') wabotjhwa ejele le iminyaka ema-18, kusekela ngonyaka we-1964 ukuya ngonyaka we1982.&lt;ref&gt;Roux, D., 2020. 5 Writing from Robben Island. ''Prison Writing and the Literary World: Imprisonment, Institutionality and Questions of Literary Practice'', p.93.&lt;/ref&gt; UNelson Mandela wadlala indima yokwenza bonyana iimbotjhwa zibumbane entronkweni, waraga ukulelwa ikululeko nanyana bekavalelwe. Wahlukaniswa nomndeni wakhe akhange avunyelwe bonyana ayokubulunga unina Kanye nendodana yakhe ekulu. Abanye abantu ababotjwa e-Roben Island ngu Walter Sisulu, Govan Mbeki no Robert Sibukwe.  

Robert Sobukwe yena wabe amdosi phambili wehlangano ye-''Pan African Congress'' (PAC) yena nakavalelwako wabekwa ayedwa bonyana kungabi nabantu abamvakatjhelako. USobukwe wenzelwa umthetho okhethekileko owawubizwa nge”Sobukwe Clause” ukwenzele ukuthi avalelwe yedwa ngejele. Wakatelelwa bonyana atjhugulule umkhumbulo wakhe  wokuthoma umnyakazo wokulwisana nombuso wegandelelo kodwana akhange avume. [[UWalter Sisulu]] wagwetjwa isisgwebo sepilo yakhe yoke ejele ngombana watholakala azibandakanye  emnyakazweni wokulwisana nombuso wegandelelo.&lt;ref&gt;Nwafor, O., 2012. Nelson Mandela and the politics of representation in Robben Island Museum, South Africa. ''AFRREV IJAH: An International Journal of Arts and Humanities'', ''1''(2), pp.133-141.&lt;/ref&gt;Wahlala ejele pheze iminyaka emam-20. Ngonyaka we-1982 wasuswa wasiwa ePollsomor ekuyijele eseduze nekapa, ekukulapho waragela khona phambili wajamela ukuphela kombuso wegandelelo.

=== ukuraga kwe-Roben island ngemva kombuso wegandelelo ===
Ngemva  kokuthi kuphele [[umbuso wegandelelo]] I-Robenisland yenziwa yabo yindawo yamagugu ye- UNESCO ngonyaka we-1999, lokho kwenziwa kukobana kwabe kubonwa umlando  wayo oqakathekileko  nokuthumba kwemiphefumulo wabantu phezulu kokubandlululana.&lt;ref&gt;Ngewu, M., 2022. What is the impact of World Heritage status and related positioning for a tourist audience on Robben Island's meanings and public narratives?.&lt;/ref&gt; Eskhathini sanje ijele sele yenziwe I myuziyemu nethswayo lethemba, ikululeko kanye nentando yenengi.&lt;ref&gt;[https://iol.co.za/travel/south-africa/western-cape/2021-09-23-the-making--and-then-breaking--of-robben-island-museum/ The making – and then breaking – of Robben Island Museum]&lt;/ref&gt; Abayeni abavela endaweni ezihlukahlukeneko zephasi bakghona  ukuthatha ikhambo elidoswa phambili mumuntu, bese umuntu loyo abakhombise amakamero wangejele lapho bekulala khona iimbotjhwa bese abakhombise nalapho kune khwari yelitje le- lime.</text>
      <sha1>df35kumc8l1ss8db0v08oqkizyptrqn</sha1>
    </revision>
    <revision>
      <id>3501</id>
      <parentid>3500</parentid>
      <timestamp>2025-07-30T09:10:54Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3501</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4387" sha1="en4q8b4ekv8kfv6j4icnfn63pjn6mmv" xml:space="preserve">[[Isimumathi:Robben Island fængslet Sektion B.jpg|thumb|Ijele i-Roben Island]]
'''I-Roben Island''' kuyindawo lapho etholakala egwini le-Cape town, enarheni yeSewula afrika. Indawo le ngenye yendawo ezikhumbuza iSewula Afrika ngezolo layo elibuhlungu langesikhathi sombuso wegandelelo.&lt;ref&gt;Rodgers, J., 2017. Visitor experiences at prison museums: Fremantle prison, robben island museum, and Eastern state penitentiary. In ''The Palgrave handbook of prison tourism'' (pp. 787-810). London: Palgrave Macmillan UK.&lt;/ref&gt; Eminyakeni eyadlulako ngaphambi kobana kuthome umbuso wentando yenengi eSewula afrika, indawo leya beyitjenziswa njengendawo yokujezisa neyokubopha abantu abavukela umbuso. Kukulapho indawo le yaziwa khona njengejele elabe ligadwe khulu, ngesibanga sokugada abantu ababotjhwe kilo.

=== Ipilo ejele ngesikhathi sombuso wegandelelo ===
Indawo le ngesikhathi sombuso wegandelelo yathoma umsebenzi wokuthi kuvalelwe kiyo abantu ekhabe balwisana nombuso wegandelelo, nabanye abasopolitiki ekhabe balwela ikululeko. Ipilo ejele le beyaziwa ngokuthi ihlukanisa iimbotjhwa nabantu, ukusebenzisa iimbotjhwa nzima, nesihlungu.&lt;ref&gt;Skotnes, A., 2023. Robben Island and the Culture of Reconstruction in South Africa. ''Radical History Review'', ''2023''(146), pp.178-202.&lt;/ref&gt; Imbotjhwa zakhona ezinye bezisetjenziswa kukhwari yelitje le lime. Iimbotjhwa ejele ye roben island zabe zihlukunyezwa emzimbeni nemmoyeni, beziphiwa Ukudla okuncani, begodu zihlezi nakabuhlungu. Imbotjhwa khabe zigade khulu ukuphula ithemba kilabo ekhabe balwisana nombuso webandlululo. Nanyana bekunjalo lokho akhange kuvimbe iimbotjhwa zangaleso skhathi ukuthi zifunde begodu ziragele phambili nokufuna ikululeko.

=== Abantu abavalelwa ERoben Island ===
[[UNelson Mandela]] owabe amdosi phambili wehlangano ye- ANC (''African National Congress'') wabotjhwa ejele le iminyaka ema-18, kusekela ngonyaka we-1964 ukuya ngonyaka we1982.&lt;ref&gt;Roux, D., 2020. 5 Writing from Robben Island. ''Prison Writing and the Literary World: Imprisonment, Institutionality and Questions of Literary Practice'', p.93.&lt;/ref&gt; UNelson Mandela wadlala indima yokwenza bonyana iimbotjhwa zibumbane entronkweni, waraga ukulelwa ikululeko nanyana bekavalelwe. Wahlukaniswa nomndeni wakhe akhange avunyelwe bonyana ayokubulunga unina Kanye nendodana yakhe ekulu. Abanye abantu ababotjwa e-Roben Island ngu Walter Sisulu, Govan Mbeki no Robert Sibukwe.  

Robert Sobukwe yena wabe amdosi phambili wehlangano ye-''Pan African Congress'' (PAC) yena nakavalelwako wabekwa ayedwa bonyana kungabi nabantu abamvakatjhelako. USobukwe wenzelwa umthetho okhethekileko owawubizwa nge”Sobukwe Clause” ukwenzele ukuthi avalelwe yedwa ngejele. Wakatelelwa bonyana atjhugulule umkhumbulo wakhe  wokuthoma umnyakazo wokulwisana nombuso wegandelelo kodwana akhange avume. [[UWalter Sisulu]] wagwetjwa isisgwebo sepilo yakhe yoke ejele ngombana watholakala azibandakanye  emnyakazweni wokulwisana nombuso wegandelelo.&lt;ref&gt;Nwafor, O., 2012. Nelson Mandela and the politics of representation in Robben Island Museum, South Africa. ''AFRREV IJAH: An International Journal of Arts and Humanities'', ''1''(2), pp.133-141.&lt;/ref&gt;Wahlala ejele pheze iminyaka emam-20. Ngonyaka we-1982 wasuswa wasiwa ePollsomor ekuyijele eseduze nekapa, ekukulapho waragela khona phambili wajamela ukuphela kombuso wegandelelo.

=== ukuraga kwe-Roben island ngemva kombuso wegandelelo ===
Ngemva  kokuthi kuphele [[umbuso wegandelelo]] I-Robenisland yenziwa yabo yindawo yamagugu ye- UNESCO ngonyaka we-1999, lokho kwenziwa kukobana kwabe kubonwa umlando  wayo oqakathekileko  nokuthumba kwemiphefumulo wabantu phezulu kokubandlululana.&lt;ref&gt;Ngewu, M., 2022. What is the impact of World Heritage status and related positioning for a tourist audience on Robben Island's meanings and public narratives?.&lt;/ref&gt; Eskhathini sanje ijele sele yenziwe I myuziyemu nethswayo lethemba, ikululeko kanye nentando yenengi.&lt;ref&gt;[https://iol.co.za/travel/south-africa/western-cape/2021-09-23-the-making--and-then-breaking--of-robben-island-museum/ The making – and then breaking – of Robben Island Museum]&lt;/ref&gt; Abayeni abavela endaweni ezihlukahlukeneko zephasi bakghona  ukuthatha ikhambo elidoswa phambili mumuntu, bese umuntu loyo abakhombise amakamero wangejele lapho bekulala khona iimbotjhwa bese abakhombise nalapho kune khwari yelitje le- lime.

== Iinkomba ==</text>
      <sha1>en4q8b4ekv8kfv6j4icnfn63pjn6mmv</sha1>
    </revision>
    <revision>
      <id>3574</id>
      <parentid>3501</parentid>
      <timestamp>2025-08-06T16:10:30Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>3574</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4477" sha1="8ac5lwnprodvp348scolox1qjo3ftw6" xml:space="preserve">[[Isimumathi:Robben Island fængslet Sektion B.jpg|thumb|Ijele i-Roben Island]]
'''I-Roben Island''' kuyindawo lapho etholakala egwini le-Cape town, enarheni yeSewula afrika. Indawo le ngenye yendawo ezikhumbuza iSewula Afrika ngezolo layo elibuhlungu langesikhathi sombuso wegandelelo.&lt;ref&gt;Rodgers, J., 2017. Visitor experiences at prison museums: Fremantle prison, robben island museum, and Eastern state penitentiary. In ''The Palgrave handbook of prison tourism'' (pp. 787-810). London: Palgrave Macmillan UK.&lt;/ref&gt; Eminyakeni eyadlulako ngaphambi kobana kuthome umbuso wentando yenengi eSewula afrika, indawo leya beyitjenziswa njengendawo yokujezisa neyokubopha abantu abavukela umbuso. Kukulapho indawo le yaziwa khona njengejele elabe ligadwe khulu, ngesibanga sokugada abantu ababotjhwe kilo.

=== Ipilo ejele ngesikhathi sombuso wegandelelo ===
Indawo le ngesikhathi sombuso wegandelelo yathoma umsebenzi wokuthi kuvalelwe kiyo abantu ekhabe balwisana nombuso wegandelelo, nabanye abasopolitiki ekhabe balwela ikululeko. Ipilo ejele le beyaziwa ngokuthi ihlukanisa iimbotjhwa nabantu, ukusebenzisa iimbotjhwa nzima, nesihlungu.&lt;ref&gt;Skotnes, A., 2023. Robben Island and the Culture of Reconstruction in South Africa. ''Radical History Review'', ''2023''(146), pp.178-202.&lt;/ref&gt; Imbotjhwa zakhona ezinye bezisetjenziswa kukhwari yelitje le lime. Iimbotjhwa ejele ye roben island zabe zihlukunyezwa emzimbeni nemmoyeni, beziphiwa Ukudla okuncani, begodu zihlezi nakabuhlungu. Imbotjhwa khabe zigade khulu ukuphula ithemba kilabo ekhabe balwisana nombuso webandlululo. Nanyana bekunjalo lokho akhange kuvimbe iimbotjhwa zangaleso skhathi ukuthi zifunde begodu ziragele phambili nokufuna ikululeko.

=== Abantu abavalelwa ERoben Island ===
[[UNelson Mandela]] owabe amdosi phambili wehlangano ye- ANC (''African National Congress'') wabotjhwa ejele le iminyaka ema-18, kusekela ngonyaka we-1964 ukuya ngonyaka we1982.&lt;ref&gt;Roux, D., 2020. 5 Writing from Robben Island. ''Prison Writing and the Literary World: Imprisonment, Institutionality and Questions of Literary Practice'', p.93.&lt;/ref&gt; UNelson Mandela wadlala indima yokwenza bonyana iimbotjhwa zibumbane entronkweni, waraga ukulelwa ikululeko nanyana bekavalelwe. Wahlukaniswa nomndeni wakhe akhange avunyelwe bonyana ayokubulunga unina Kanye nendodana yakhe ekulu. Abanye abantu ababotjwa e-Roben Island ngu Walter Sisulu, Govan Mbeki no Robert Sibukwe.  

Robert Sobukwe yena wabe amdosi phambili wehlangano ye-''Pan African Congress'' (PAC) yena nakavalelwako wabekwa ayedwa bonyana kungabi nabantu abamvakatjhelako. USobukwe wenzelwa umthetho okhethekileko owawubizwa nge”Sobukwe Clause” ukwenzele ukuthi avalelwe yedwa ngejele. Wakatelelwa bonyana atjhugulule umkhumbulo wakhe  wokuthoma umnyakazo wokulwisana nombuso wegandelelo kodwana akhange avume. [[UWalter Sisulu]] wagwetjwa isisgwebo sepilo yakhe yoke ejele ngombana watholakala azibandakanye  emnyakazweni wokulwisana nombuso wegandelelo.&lt;ref&gt;Nwafor, O., 2012. Nelson Mandela and the politics of representation in Robben Island Museum, South Africa. ''AFRREV IJAH: An International Journal of Arts and Humanities'', ''1''(2), pp.133-141.&lt;/ref&gt;Wahlala ejele pheze iminyaka emam-20. Ngonyaka we-1982 wasuswa wasiwa ePollsomor ekuyijele eseduze nekapa, ekukulapho waragela khona phambili wajamela ukuphela kombuso wegandelelo.

=== ukuraga kwe-Roben island ngemva kombuso wegandelelo ===
Ngemva  kokuthi kuphele [[umbuso wegandelelo]] I-Robenisland yenziwa yabo yindawo yamagugu ye- UNESCO ngonyaka we-1999, lokho kwenziwa kukobana kwabe kubonwa umlando  wayo oqakathekileko  nokuthumba kwemiphefumulo wabantu phezulu kokubandlululana.&lt;ref&gt;Ngewu, M., 2022. What is the impact of World Heritage status and related positioning for a tourist audience on Robben Island's meanings and public narratives?.&lt;/ref&gt; Eskhathini sanje ijele sele yenziwe I myuziyemu nethswayo lethemba, ikululeko kanye nentando yenengi.&lt;ref&gt;[https://iol.co.za/travel/south-africa/western-cape/2021-09-23-the-making--and-then-breaking--of-robben-island-museum/ The making – and then breaking – of Robben Island Museum]&lt;/ref&gt; Abayeni abavela endaweni ezihlukahlukeneko zephasi bakghona  ukuthatha ikhambo elidoswa phambili mumuntu, bese umuntu loyo abakhombise amakamero wangejele lapho bekulala khona iimbotjhwa bese abakhombise nalapho kune khwari yelitje le- lime.

== Iinkomba ==
[[Category:I-Roben Island]]
[[Category:Umbuso wegandelelo]]
[[Category:U-Nelson Mandela]]</text>
      <sha1>8ac5lwnprodvp348scolox1qjo3ftw6</sha1>
    </revision>
  </page>
  <page>
    <title>Internet Colonial Company</title>
    <ns>0</ns>
    <id>711</id>
    <revision>
      <id>3462</id>
      <timestamp>2025-07-28T16:40:58Z</timestamp>
      <contributor>
        <username>DefocvaiotrpAA</username>
        <id>519</id>
      </contributor>
      <comment>Created page with &quot;By tradition, if a question is asked, it must be answered. Historically, colonial companies, from the largest (such as the British and Dutch East India Companies) to the lesser ones, often served as tools for governmental ambitions or financial speculation. Many of them, under the guise of noble goals like &quot;enlightenment&quot; or &quot;Christianization,&quot; practiced oppression in reality. An example is the policy of the British East India Company, which exploited local populations d...&quot;</comment>
      <origin>3462</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1607" sha1="jfww1ejzsrrno2hnh3495f6muj6f2fj" xml:space="preserve">By tradition, if a question is asked, it must be answered. Historically, colonial companies, from the largest (such as the British and Dutch East India Companies) to the lesser ones, often served as tools for governmental ambitions or financial speculation. Many of them, under the guise of noble goals like &quot;enlightenment&quot; or &quot;Christianization,&quot; practiced oppression in reality. An example is the policy of the British East India Company, which exploited local populations despite its proclaimed ideals.
The ICC declares a fundamentally different mission. Our goal is the &quot;colonization&quot; of the digital realm—not for power, but to liberate information from structures that, in our view, ignore cultural diversity. For instance, the Southern Ndebele Wikipedia has become a symbol of the neglect of small nations by megacorporations. We aim to draw attention to this issue by transforming it into a platform where knowledge is preserved without censorship or marginalization.
Our stance is rooted in defending Christian values, rational approaches, and creative freedom. We believe that any form of creative expression is inherently valuable and should exist free from restrictions imposed by left-wing ideologues. In this sense, the ICC challenges Western Marxists who advocate for the homogenization of perspectives.
Choosing to uphold these principles requires effort. We wage an unyielding struggle against leftism, socialism, communism, eco-extremism, materialism, the cult of money and sex, and the promotion of perversions contrary to God’s will.
Glory to our Lord Jesus Christ!
A true magnum opus.</text>
      <sha1>jfww1ejzsrrno2hnh3495f6muj6f2fj</sha1>
    </revision>
    <revision>
      <id>3463</id>
      <parentid>3462</parentid>
      <timestamp>2025-07-28T16:41:13Z</timestamp>
      <contributor>
        <username>DefocvaiotrpAA</username>
        <id>519</id>
      </contributor>
      <origin>3463</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1613" sha1="030jh97kuvqfetbvpmyeirk08uvfgz7" xml:space="preserve">By tradition, if a question is asked, it must be answered. Historically, colonial companies, from the largest (such as the British and Dutch East India Companies) to the lesser ones, often served as tools for governmental ambitions or financial speculation. Many of them, under the guise of noble goals like &quot;enlightenment&quot; or &quot;Christianization,&quot; practiced oppression in reality. An example is the policy of the British East India Company, which exploited local populations despite its proclaimed ideals.
The ICC declares a fundamentally different mission. Our goal is the &quot;colonization&quot; of the digital realm—not for power, but to liberate information from structures that, in our view, ignore cultural diversity. For instance, the Southern Ndebele Wikipedia has become a symbol of the neglect of small nations by megacorporations. We aim to draw attention to this issue by transforming it into a platform where knowledge is preserved without censorship or marginalization.
Our stance is rooted in defending Christian values, rational approaches, and creative freedom. We believe that any form of creative expression is inherently valuable and should exist free from restrictions imposed by left-wing ideologues. In this sense, the ICC challenges Western Marxists who advocate for the homogenization of perspectives.
Choosing to uphold these principles requires effort. We wage an unyielding struggle against leftism, socialism, communism, eco-extremism, materialism, the cult of money and sex, and the promotion of perversions contrary to God’s will.
'''Glory to our Lord Jesus Christ'''!
A true magnum opus.</text>
      <sha1>030jh97kuvqfetbvpmyeirk08uvfgz7</sha1>
    </revision>
    <revision>
      <id>3464</id>
      <parentid>3463</parentid>
      <timestamp>2025-07-28T16:45:55Z</timestamp>
      <contributor>
        <username>DefocvaiotrpAA</username>
        <id>519</id>
      </contributor>
      <origin>3464</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3295" sha1="l2wxch36suvhs2qjw94fdz823wrfgu1" xml:space="preserve">Ngokwesiko, uma kubuzwa umbuzo, kumele uphendulwe. Ngokomlando, amakampani akoloni, kusukela kakhulu (njengeBritish neDutch East India Companies) kuya kumaqembu amancane, ayevame ukuba ngamathuluzi ezinjongweni zikahulumeni noma ukucabanga ngezimali. Amanye awo, ngaphansi kwezinhloso ezinhle njengokukhanyisa noma ukwenza abantu babe ngamaKristu, ayenqenqema ngempela. Isibonelo yinqubomgomo yeBritish East India Company, eyayixhaphaza abantu bendawo naphezu kwezimiso zayo ezazimemezela.

I-ICC imemezela umsebenzi ohluke ngokuyisisekelo. Inhloso yethu ukwenza &quot;ukoloni&quot; emkhathini wedijithali—hhayi ngamandla, kepha ukukhulula ulwazi ezinhlakeni, ngokombono wethu, ezingazinaki ukwehlukana kwezamasiko. Isibonelo, i-Wikipedia yesiNdebele saseNingizimu isivele isaba uphawu lokunganakwa kwezizwe ezincane ngamakampani amakhulu. Sihlose ukudonsa ukunakwa kwalolu daba ngokuyiguqula ibe yinkundla lapho ulwazi lulondolozwa khona ngaphandle kokuhluza noma ukucwaswa.

Isimo sethu sisuselwa ekukhalipheni amagugu angokobuKristu, izindlela ezinengqondo, nenkululeko yobuciko. Sikholelwa ukuthi noma iyiphi indlela yokubonisa ubuciko inenani ngokwemvelo futhi kufanele ibe khona ngaphandle kwemingcele ebekiwe ngabacabangi be-left wing. Ngalesi sizathu, i-IPC iphikisa ama-Marxist aseNtshonalanga agomela ukwenziwa kwezombono zibe zilodwa.

Ukukhetha ukuvikela le mibono kudinga umzamo. Silwa impi engenamona ne-leftism, ubuholi bezwe, ubucommunism, i-eco-extremism, ukubaluleka kwempahla, umkhuba wemali nobulili, kanye nokukhuthazwa kwezinto eziphikisana nothando lukaNkulunkulu.

Ukuzukiswa kweNkosi yethu uJesu Kristu!

Umsebenzi omkhulu ngempela!


''Umbhalo wangempela''

''&quot;By tradition, if a question is asked, it must be answered. Historically, colonial companies, from the largest (such as the British and Dutch East India Companies) to the lesser ones, often served as tools for governmental ambitions or financial speculation. Many of them, under the guise of noble goals like &quot;enlightenment&quot; or &quot;Christianization,&quot; practiced oppression in reality. An example is the policy of the British East India Company, which exploited local populations despite its proclaimed ideals.
The ICC declares a fundamentally different mission. Our goal is the &quot;colonization&quot; of the digital realm—not for power, but to liberate information from structures that, in our view, ignore cultural diversity. For instance, the Southern Ndebele Wikipedia has become a symbol of the neglect of small nations by megacorporations. We aim to draw attention to this issue by transforming it into a platform where knowledge is preserved without censorship or marginalization.
Our stance is rooted in defending Christian values, rational approaches, and creative freedom. We believe that any form of creative expression is inherently valuable and should exist free from restrictions imposed by left-wing ideologues. In this sense, the ICC challenges Western Marxists who advocate for the homogenization of perspectives.
Choosing to uphold these principles requires effort. We wage an unyielding struggle against leftism, socialism, communism, eco-extremism, materialism, the cult of money and sex, and the promotion of perversions contrary to God’s will.
'''Glory to our Lord Jesus Christ'''!
A true magnum opus.&quot;''</text>
      <sha1>l2wxch36suvhs2qjw94fdz823wrfgu1</sha1>
    </revision>
    <revision>
      <id>3468</id>
      <parentid>3464</parentid>
      <timestamp>2025-07-29T00:13:54Z</timestamp>
      <contributor>
        <username>Dcljr</username>
        <id>20</id>
      </contributor>
      <comment>I suspect this whole thing is not a legitimate article, but at least this part is off-topic and mostly in the wrong language, anyway</comment>
      <origin>3468</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1579" sha1="1hy8fy571kthso0om0ws9u6ze8v4cwd" xml:space="preserve">Ngokwesiko, uma kubuzwa umbuzo, kumele uphendulwe. Ngokomlando, amakampani akoloni, kusukela kakhulu (njengeBritish neDutch East India Companies) kuya kumaqembu amancane, ayevame ukuba ngamathuluzi ezinjongweni zikahulumeni noma ukucabanga ngezimali. Amanye awo, ngaphansi kwezinhloso ezinhle njengokukhanyisa noma ukwenza abantu babe ngamaKristu, ayenqenqema ngempela. Isibonelo yinqubomgomo yeBritish East India Company, eyayixhaphaza abantu bendawo naphezu kwezimiso zayo ezazimemezela.

I-ICC imemezela umsebenzi ohluke ngokuyisisekelo. Inhloso yethu ukwenza &quot;ukoloni&quot; emkhathini wedijithali—hhayi ngamandla, kepha ukukhulula ulwazi ezinhlakeni, ngokombono wethu, ezingazinaki ukwehlukana kwezamasiko. Isibonelo, i-Wikipedia yesiNdebele saseNingizimu isivele isaba uphawu lokunganakwa kwezizwe ezincane ngamakampani amakhulu. Sihlose ukudonsa ukunakwa kwalolu daba ngokuyiguqula ibe yinkundla lapho ulwazi lulondolozwa khona ngaphandle kokuhluza noma ukucwaswa.

Isimo sethu sisuselwa ekukhalipheni amagugu angokobuKristu, izindlela ezinengqondo, nenkululeko yobuciko. Sikholelwa ukuthi noma iyiphi indlela yokubonisa ubuciko inenani ngokwemvelo futhi kufanele ibe khona ngaphandle kwemingcele ebekiwe ngabacabangi be-left wing. Ngalesi sizathu, i-IPC iphikisa ama-Marxist aseNtshonalanga agomela ukwenziwa kwezombono zibe zilodwa.

Ukukhetha ukuvikela le mibono kudinga umzamo. Silwa impi engenamona ne-leftism, ubuholi bezwe, ubucommunism, i-eco-extremism, ukubaluleka kwempahla, umkhuba wemali nobulili, kanye nokukhuthazwa kwezinto eziphikisana nothando lukaNkulunkulu.</text>
      <sha1>1hy8fy571kthso0om0ws9u6ze8v4cwd</sha1>
    </revision>
    <revision>
      <id>6006</id>
      <parentid>3468</parentid>
      <timestamp>2025-11-18T12:50:41Z</timestamp>
      <contributor>
        <username>Roman Oy Bobrov</username>
        <id>167</id>
      </contributor>
      <origin>6006</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1622" sha1="9vn0cq0r8l9dxejg6ru3p4sbxjcq4uu" xml:space="preserve">Ngokwesiko, uma kubuzwa umbuzo, kumele uphendulwe. Ngokomlando, amakampani akoloni, kusukela kakhulu (njengeBritish neDutch East India Companies) kuya kumaqembu amancane, ayevame ukuba ngamathuluzi ezinjongweni zikahulumeni noma ukucabanga ngezimali. Amanye awo, ngaphansi kwezinhloso ezinhle njengokukhanyisa noma ukwenza abantu babe ngamaKristu, ayenqenqema ngempela. Isibonelo yinqubomgomo yeBritish East India Company, eyayixhaphaza abantu bendawo naphezu kwezimiso zayo ezazimemezela.

I-ICC imemezela umsebenzi ohluke ngokuyisisekelo. Inhloso yethu ukwenza &quot;ukoloni&quot; emkhathini wedijithali—hhayi ngamandla, kepha ukukhulula ulwazi ezinhlakeni, ngokombono wethu, ezingazinaki ukwehlukana kwezamasiko. Isibonelo, i-Wikipedia yesiNdebele saseNingizimu isivele isaba uphawu lokunganakwa kwezizwe ezincane ngamakampani amakhulu. Sihlose ukudonsa ukunakwa kwalolu daba ngokuyiguqula ibe yinkundla lapho ulwazi lulondolozwa khona ngaphandle kokuhluza noma ukucwaswa.

Isimo sethu sisuselwa ekukhalipheni amagugu angokobuKristu, izindlela ezinengqondo, nenkululeko yobuciko. Sikholelwa ukuthi noma iyiphi indlela yokubonisa ubuciko inenani ngokwemvelo futhi kufanele ibe khona ngaphandle kwemingcele ebekiwe ngabacabangi be-left wing. Ngalesi sizathu, i-IPC iphikisa ama-Marxist aseNtshonalanga agomela ukwenziwa kwezombono zibe zilodwa.

Ukukhetha ukuvikela le mibono kudinga umzamo. Silwa impi engenamona ne-leftism, ubuholi bezwe, ubucommunism, i-eco-extremism, ukubaluleka kwempahla, umkhuba wemali nobulili, kanye nokukhuthazwa kwezinto eziphikisana nothando lukaNkulunkulu.

I-History:

[[Ukuhlubuka Kwe-Intanethi!]]</text>
      <sha1>9vn0cq0r8l9dxejg6ru3p4sbxjcq4uu</sha1>
    </revision>
  </page>
  <page>
    <title>Esperanto</title>
    <ns>0</ns>
    <id>712</id>
    <revision>
      <id>3465</id>
      <timestamp>2025-07-28T16:59:09Z</timestamp>
      <contributor>
        <username>DefocvaiotrpAA</username>
        <id>519</id>
      </contributor>
      <comment>Created page with &quot;Lulula ukulufunda: Uhlaka lolimi (grammar) lulula futhi alikho okungajwayelekile.  Luyimfihlo (Neutral): Alikho lelizwe, ngakho alichemi abantu.  Umphakathi womhlaba wonke: Kukhona abakhulumi be-Esperanto emazweni onke, abahlangana ngezinkundla zomphakathi (nk. Pasporta Servo).  Uhlaka lolimi lwe-Esperanto (Grammar):  Amagama asuselwa kwingcambu (Root words): Isibonelo, kwingcambu &quot;san-&quot; (impilo):  sana = e-nempilo (healthy)  malsana = isigula (sick)  malsanule = isibhed...&quot;</comment>
      <origin>3465</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1130" sha1="i66qltp7dr9fnl3m8bwfhzqrt8oljxx" xml:space="preserve">Lulula ukulufunda: Uhlaka lolimi (grammar) lulula futhi alikho okungajwayelekile.

Luyimfihlo (Neutral): Alikho lelizwe, ngakho alichemi abantu.

Umphakathi womhlaba wonke: Kukhona abakhulumi be-Esperanto emazweni onke, abahlangana ngezinkundla zomphakathi (nk. Pasporta Servo).

Uhlaka lolimi lwe-Esperanto (Grammar):

Amagama asuselwa kwingcambu (Root words): Isibonelo, kwingcambu &quot;san-&quot; (impilo):

sana = e-nempilo (healthy)

malsana = isigula (sick)

malsanule = isibhedlela (hospital)

Izimpawu zamagama (Part-of-speech endings):

Ibizo (Noun): -o (nk. hundo = inja)

Isiphawulo (Adjective): -a (nk. rapida = esheshayo)

Isenzo (Verb): -i (nk. lerni = ukufunda)

Izikhathi zezenzo (Verb tenses):

Namuhla (Present): -as (mi legas = ngifunda)

Edlule (Past): -is (mi legis = ngafunda)

Ezosayo (Future): -os (mi legos = ngizofunda)

Awakho amagama aphambene nezinhlelo (No irregular words): Yonke into ilandelana nemithetho.

Okubalulekile: I-Esperanto ayilwimi lwezinkampani noma ubulwani—lwenzelwe ukulingana nobungane. Abafundi abaningi bathi ukufunda izilimi zomhlaba (nk. IsiFulentshi) kuba lula ngemuva kwe-Esperanto.</text>
      <sha1>i66qltp7dr9fnl3m8bwfhzqrt8oljxx</sha1>
    </revision>
  </page>
  <page>
    <title>Ukubulawa kwabantu e-Marikana</title>
    <ns>0</ns>
    <id>713</id>
    <revision>
      <id>3467</id>
      <timestamp>2025-07-28T20:12:46Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>i changed references</comment>
      <origin>3467</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4474" sha1="8uu0skzlt6rq0yfrtlrhluqr9klmzbb" xml:space="preserve">UKUBULAWA KWABANTU E-MARIKANA
[[Isimumathi:Lonmin-platinummyn, a, Marikana, Noordwes.jpg|thumb|I Lonmin platinum mine e-Marikana]]
'''Mhlana''' ali-16 kuRhoboyi wee -2012 amapholisa we '''Sewula Afrika''' avulela ngeenkule esiqubuthwini sabasebenzi bemayini ebegade batjhagala eMarikana esifundeni se-North West.Amapholisa adumuza bewabulala abasebenzi bemayini abama-34 begodu atjhiya abangama-78 balimele kumbi.Ngemva kokuhlaselwa ngomlilo ovulekileko abatjhagali abangu-250 babotjhwa.

=== umsusa womtjhagalo ===
umtjhagalo lo wagcina ngemva kokutjhatjhalaliswa okukhulu isikhathi eside lapho abatjhagali bebafuna ukukhutjhulelwa imirholo emayini ye platinamu i-Lonmin.mhlana ali-9 kuRhoboyi abasebenzi bemayini abangaba ziingidi ezithathu batjhagala ngomnqopho wokufuna umrholo wokuphila.

==== kusukela mhlana amalanga ali-10 kuRhoboyi ====
Mhlana ali-10 kuRhoboyi isiqhema esikhulu sabatjhagali ebegade batjhagala satjhidela e-ofisini lendawo le nyunyana yabatjhagali ukufuna isekelo lehlangano yabo begodu esikhundleni salokho bahlangabezana nokudumuzwa ngeenkule zamambala okwalimaza abatjhagali ababili.Ukuphazamiseka okuhulu kokukhulumisana hlangana kwabatjhagali neyuniyoni yabo kwathuthukisa ubujamo obumbi.Lapho abatjhagali nemindeni yabo bebalinga ngamandla bona amaphimbo wabo ezwakale begodu neentlhogo zabo zifezekiswe.Abatjhagali bebangakghoni ukuthola umhlangano nabajameli be-'''Num''' nofana be Lonmin begodu izenzakalo zaba zimbi ngemva kokuhlongakala kwabatjhagali ababili ebegade batjhagala.

===== kusukela mhlana amalanga ali-12 ukuya kwayi-14 kuRhoboyi =====
Hlangana mhlana ali-12 ukuya kweli-14 kuRhoboyi okungenani abasenzi abane bemayini,amapholisa amabili nabalindi ababili bahlongakala ebudloveni obulandelako.Mhlana ali-13 kuRhoboyi abatjhagali abama-30 bathunyelwa bona bawele isiganga ebesihlukaniswa ngomunye umngodi wemayini ye-platinamu i-Lonmin e-Karee lapho abatjhagali nabo bebangenele umtjhagalo.

Abatjhagali abangama-30 bebaphekelelwa bavikeli babo nogada bona babuyele emva ngaphandle kokuvunyelwa bona bahlangane nabanye abatjhagali kwelinye ihlangothi.Endleleni yabo yokubuyela emva bahlangabezana nesiqhema samapholisa,abazibonela ngamehlo imibiko ithi bekuneveni yamapholisa webutho eliyi-10 kunye namalori wamapholisa amabili.

====== ubudlova bamapholisa ======
Amapholisa abavalela indlela yabo begodu abatjela bona babeke phasi iinkhali zabo kodwana abasebenzi bala bathi batlhoga ama panga ngebanga lokobana bahlala emangweni nje-ke bayawatlhoga.Amapholisa avumela abatjhagali bona baragele phambili kodwana kwathi nasebakhambe amamitha ali-10 amapholisa athoma ukubadumuza begodu abatjhagali bazibuyiselela.Amapholisa amabili nabatjhagali ababili babulawa epini leyo begodu umtjhagali munye walimala kumbi.

====== isekelo labatjhagali ======
Umtjhagalo waragela phambili nanyana ungatholanga isekelo ku-'''NUM''' begodu ungatholanga isibopho esisemthethweni esivela kubaphathi be Lonmin sokobana bangene emikhulumiswaneni.Umtjhagalo lo bekungo wokukhuphula imirholo kunye nokhutjheja ubujamo obumbi bokuphila nokusebenza kwabatjhagali nemindeni yabo e-Marikana.Yoke imiraro le abasebenzi ebegade baqalane nayo khange ikhulunywe ngokusemthethweni yi-'''NUM''' nofana i-Lonmin ngesikhathi somtjhagalo.Inengi labatjhagali esikhundleni salokho lathoma ukulahlekelwa misebenzi yabo begodu abatjhagali bahlangabezana nobutha obungahlobeneko ngabe zokuphepha,amapholisa,abasebenzi beenyunyana kunye nabaphathi.

Nanyana bangavikeleli ngokomthetho namkha isekelo leenyunyana iinkulungwna zabatjhagali zaragela phambili nokutjhagala ngokubumbana umnqopho wabo ofanako wokuphila okuseingeni eliphezulu nesithunzi esikunikelako.
[[Isimumathi:Church on Green Market Square Marikana (cropped).JPG|thumb|isithombe sokukhumbula boke abasebenzi abahlongakala e-Marikana]]
Imindeni yabatjhagali nayo beyivumelana nomtjhagalo begodu isebenzele ukusekela ijima ngokuhlanganyela emtjhagalweni begodu iletha izinto lokha nakutlhogekako.

====== iinkhombo. ======
[https://sahistory.org.za/marikana https://sahistory.org.za/marikana ]
https://sahistory.org.za/article/marikana-massacre-16-august-2012
https://theconversation.com/marikana-massacre-south-africa-needs-to-build-a-society-thats-decent-and-doesnt-humiliate-people-188534
https://www.casac.org.za/wp-content/uploads/2015/02/Summary-and-Analysis-of-the-Report-of-the-Marikana-Commission-of-Inquiry.pdfhttps://www.csvr.org.za/a-case-study-of-the-marikana-massacre-in-south-africa/</text>
      <sha1>8uu0skzlt6rq0yfrtlrhluqr9klmzbb</sha1>
    </revision>
    <revision>
      <id>3471</id>
      <parentid>3467</parentid>
      <timestamp>2025-07-29T00:19:13Z</timestamp>
      <contributor>
        <username>Dcljr</username>
        <id>20</id>
      </contributor>
      <comment>remove redundant section heading and use normal level-2 sections (==) -- not every new section requires an additional pair of &quot;=&quot;'</comment>
      <origin>3471</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4408" sha1="fk2uquj9a8tf8upfuelqgmq0zj64fzf" xml:space="preserve">[[Isimumathi:Lonmin-platinummyn, a, Marikana, Noordwes.jpg|thumb|I Lonmin platinum mine e-Marikana]]
'''Mhlana''' ali-16 kuRhoboyi wee -2012 amapholisa we '''Sewula Afrika''' avulela ngeenkule esiqubuthwini sabasebenzi bemayini ebegade batjhagala eMarikana esifundeni se-North West.Amapholisa adumuza bewabulala abasebenzi bemayini abama-34 begodu atjhiya abangama-78 balimele kumbi.Ngemva kokuhlaselwa ngomlilo ovulekileko abatjhagali abangu-250 babotjhwa.

== umsusa womtjhagalo ==
umtjhagalo lo wagcina ngemva kokutjhatjhalaliswa okukhulu isikhathi eside lapho abatjhagali bebafuna ukukhutjhulelwa imirholo emayini ye platinamu i-Lonmin.mhlana ali-9 kuRhoboyi abasebenzi bemayini abangaba ziingidi ezithathu batjhagala ngomnqopho wokufuna umrholo wokuphila.

== kusukela mhlana amalanga ali-10 kuRhoboyi ==
Mhlana ali-10 kuRhoboyi isiqhema esikhulu sabatjhagali ebegade batjhagala satjhidela e-ofisini lendawo le nyunyana yabatjhagali ukufuna isekelo lehlangano yabo begodu esikhundleni salokho bahlangabezana nokudumuzwa ngeenkule zamambala okwalimaza abatjhagali ababili.Ukuphazamiseka okuhulu kokukhulumisana hlangana kwabatjhagali neyuniyoni yabo kwathuthukisa ubujamo obumbi.Lapho abatjhagali nemindeni yabo bebalinga ngamandla bona amaphimbo wabo ezwakale begodu neentlhogo zabo zifezekiswe.Abatjhagali bebangakghoni ukuthola umhlangano nabajameli be-'''Num''' nofana be Lonmin begodu izenzakalo zaba zimbi ngemva kokuhlongakala kwabatjhagali ababili ebegade batjhagala.

== kusukela mhlana amalanga ali-12 ukuya kwayi-14 kuRhoboyi ==
Hlangana mhlana ali-12 ukuya kweli-14 kuRhoboyi okungenani abasenzi abane bemayini,amapholisa amabili nabalindi ababili bahlongakala ebudloveni obulandelako.Mhlana ali-13 kuRhoboyi abatjhagali abama-30 bathunyelwa bona bawele isiganga ebesihlukaniswa ngomunye umngodi wemayini ye-platinamu i-Lonmin e-Karee lapho abatjhagali nabo bebangenele umtjhagalo.

Abatjhagali abangama-30 bebaphekelelwa bavikeli babo nogada bona babuyele emva ngaphandle kokuvunyelwa bona bahlangane nabanye abatjhagali kwelinye ihlangothi.Endleleni yabo yokubuyela emva bahlangabezana nesiqhema samapholisa,abazibonela ngamehlo imibiko ithi bekuneveni yamapholisa webutho eliyi-10 kunye namalori wamapholisa amabili.

== ubudlova bamapholisa ==
Amapholisa abavalela indlela yabo begodu abatjela bona babeke phasi iinkhali zabo kodwana abasebenzi bala bathi batlhoga ama panga ngebanga lokobana bahlala emangweni nje-ke bayawatlhoga.Amapholisa avumela abatjhagali bona baragele phambili kodwana kwathi nasebakhambe amamitha ali-10 amapholisa athoma ukubadumuza begodu abatjhagali bazibuyiselela.Amapholisa amabili nabatjhagali ababili babulawa epini leyo begodu umtjhagali munye walimala kumbi.

== isekelo labatjhagali ==
Umtjhagalo waragela phambili nanyana ungatholanga isekelo ku-'''NUM''' begodu ungatholanga isibopho esisemthethweni esivela kubaphathi be Lonmin sokobana bangene emikhulumiswaneni.Umtjhagalo lo bekungo wokukhuphula imirholo kunye nokhutjheja ubujamo obumbi bokuphila nokusebenza kwabatjhagali nemindeni yabo e-Marikana.Yoke imiraro le abasebenzi ebegade baqalane nayo khange ikhulunywe ngokusemthethweni yi-'''NUM''' nofana i-Lonmin ngesikhathi somtjhagalo.Inengi labatjhagali esikhundleni salokho lathoma ukulahlekelwa misebenzi yabo begodu abatjhagali bahlangabezana nobutha obungahlobeneko ngabe zokuphepha,amapholisa,abasebenzi beenyunyana kunye nabaphathi.

Nanyana bangavikeleli ngokomthetho namkha isekelo leenyunyana iinkulungwna zabatjhagali zaragela phambili nokutjhagala ngokubumbana umnqopho wabo ofanako wokuphila okuseingeni eliphezulu nesithunzi esikunikelako.
[[Isimumathi:Church on Green Market Square Marikana (cropped).JPG|thumb|isithombe sokukhumbula boke abasebenzi abahlongakala e-Marikana]]
Imindeni yabatjhagali nayo beyivumelana nomtjhagalo begodu isebenzele ukusekela ijima ngokuhlanganyela emtjhagalweni begodu iletha izinto lokha nakutlhogekako.

== iinkhombo. ==
[https://sahistory.org.za/marikana https://sahistory.org.za/marikana ]
https://sahistory.org.za/article/marikana-massacre-16-august-2012
https://theconversation.com/marikana-massacre-south-africa-needs-to-build-a-society-thats-decent-and-doesnt-humiliate-people-188534
https://www.casac.org.za/wp-content/uploads/2015/02/Summary-and-Analysis-of-the-Report-of-the-Marikana-Commission-of-Inquiry.pdfhttps://www.csvr.org.za/a-case-study-of-the-marikana-massacre-in-south-africa/</text>
      <sha1>fk2uquj9a8tf8upfuelqgmq0zj64fzf</sha1>
    </revision>
  </page>
  <page>
    <title>Ukubandlulula ngobuhlanga</title>
    <ns>0</ns>
    <id>714</id>
    <revision>
      <id>3475</id>
      <timestamp>2025-07-29T14:53:50Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''Ukubandlulula ngobuhlalanga''' kukulokha umuntu akholwa bona ubuhlanga bakhe nofana isiqhema sobutjhaba bakhe sikhulu kunezinye, bese lokho kumdosele ekutheni agcine sele akhombisa umkhuba wokubandlulula,nokungaphathi abantu ngokulingana.&lt;ref&gt;West, K., Greenland, K. and van Laar, C., 2021. Implicit racism, colour blindness, and narrow definitions of discrimination: Why some White people prefer ‘All Lives Matter’to ‘Black Lives Matter’. ''British Journal of Soc...&quot;</comment>
      <origin>3475</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4015" sha1="tcri1aiwn2b0k4qa2x8t73yjafonfm1" xml:space="preserve">'''Ukubandlulula ngobuhlalanga''' kukulokha umuntu akholwa bona ubuhlanga bakhe nofana isiqhema sobutjhaba bakhe sikhulu kunezinye, bese lokho kumdosele ekutheni agcine sele akhombisa umkhuba wokubandlulula,nokungaphathi abantu ngokulingana.&lt;ref&gt;West, K., Greenland, K. and van Laar, C., 2021. Implicit racism, colour blindness, and narrow definitions of discrimination: Why some White people prefer ‘All Lives Matter’to ‘Black Lives Matter’. ''British Journal of Social Psychology'', ''60''(4), pp.1136-1153.&lt;/ref&gt; Ukubandlululana ngokubuhlanga kungavela ngendlela ezinengi ezenza bonyana kube nokungalingani kwamathuba,nemiphumela ebuhlangeni babantu.

Ukubandlulula ngobuhlanga bomuntu

Kukulokha umuntu aziphatha nofana anekolelo yokuthi ubuhlanga bakhe buncono nofana buphezulu kunaboboke ubuhlanga obukhona ephasini nofana enarheni ahlala kiyo.&lt;ref&gt;Merolla, D.M. and Jackson, O., 2019. Structural racism as the fundamental cause of the academic achievement gap. ''Sociology Compass'', ''13''(6), p.e12696.&lt;/ref&gt; Umuntu wakhon ukhuluma imibono engakalungi ngobunye ubuhlanga, akhombise ukubandlula ubunye ubuhlanga. Umuntu angabonakala angaphathi kuhle abantu abuthileko ngombana ngombana banobuhlanga angabuthandiko. Angabakhulumisa nofana akhulume ngabo kumbi akhombise ukungabafuni nokubanyaza. Nakusemsebenzini nofana emphakathini angakhombisa ukungaphathi abantu bobuhlanga angabuthandiko ngendlela ebandlululako.

Ukubandlulula ngobuhlaanga usebenzisa umgomo wesikhungo

Kwezinye iinkhungo bangakhombisa ukubandlulula ngokobuhlanga ngokuthi benze imigomo nendlela zokuraga ngaphakathi kwesikhungo lezi ezenza bona kungabi nokulingani okwenza bona abantu bobunye ubuhlanga abangaphakathi kwaleso sikhungo bagcine sele bagandelelekile nofana bangakaphatheki kuhle.&lt;ref&gt;Macdonald, L., 2018. ''Silencing and institutional racism in settler-colonial education'' (Doctoral dissertation, Open Access Te Herenga Waka-Victoria University of Wellington).&lt;/ref&gt; Kungabonakala bantu bobuhlanga obungafunwako bangakajameleki eenhlalweni zokudosa phambili nofana kilezo lapho kuthathwa kizo khona iinqunto. Kuthokale bonyana ubuhlanga obungathandwako sele bungasatholi amathuba alingana newabanye nofana lingasaphathwa kuhle ngoba linganamjameli.

Ukubandlulula ngobuhlanga usebenzisa  irherho

Le yindlela yokubandlula ngobuhlanga enabileko etholakala emphakathini abantu abaphila kiwo. Iphethe ngaphakathi umlando, isiko namaphethe ni weenkhungo lawa andisa ukubandlula ngobuhlanga nokuphathwa ngokungalingani kwabantu.&lt;ref&gt;Merolla, D.M. and Jackson, O., 2019. Structural racism as the fundamental cause of the academic achievement gap. ''Sociology Compass'', ''13''(6), p.e12696.&lt;/ref&gt; Ngokomlando ungathola ukubandlululana ngokobuhlanga obubangelwa zizinto ezenzeka kade njengokugcizwa kwabantu ekwenzeka kade, umbuso wegandelelo nokhuye. Okhunye ukubandlululana ngokwerherho kungavela  ezintweni ezikhulunywako zamasiko nemibono engakalungi ekungiyo ekhulisa ukubandlululana ngokobuhlanga.

Iindlela ezingabonakalisa ukubandlululana ngobuhlanga.

Ukukhuluma okungakalungi

Ukubandlulula ngokobuhlanga kungabanakla lokha umuntu akhuluma izinto ezingakalungi ngobuhlanga obuthileko begodu izinto azikhulumako lezo kutholakale bonyana kuzuzinto ezingakaqinisekiswa bonyana ziliqiniso. Omunye angakhuluma into embi eyenziwa mumuntu munye  wobuhlanga obuthileko bese eyenze ngathi yenziwa ngiwo woke umuntuwobuhlanga lobo.Abanye abantu bangabonakala ngokuthi ngokuthi bangaphathi abantu bobuhlanga obuthileko kuhle. Uthole ubuhlanga obubandlulwako lobu bunganikelwa amathuba afana newabanye nofana ungaphathwa ngendlela efana neyabanye. Ilimi nalo niyakuveza ukubandlula ngokobuhlanga ngombana abanye abantu nabangathandi ubuhlanga obuthileko bbangakhuluma amagama abuhlungu ngobuhlanga lobo. Bangakhuluma ngendlela eyenza bona umuntu angakghoni ukuzizwa amakelekile phakathi kwabantu bobunye ubuhlanga. Nezenzo ngoba nazo kungenye yendlela yokukhuluma bese zikhombise bona kunokubandlululana ngokobuhlanga.</text>
      <sha1>tcri1aiwn2b0k4qa2x8t73yjafonfm1</sha1>
    </revision>
    <revision>
      <id>3476</id>
      <parentid>3475</parentid>
      <timestamp>2025-07-29T14:56:04Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <comment>added subheading</comment>
      <origin>3476</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4085" sha1="mcqe63g0z2f2uaef1cinfrwu0kjy999" xml:space="preserve">'''Ukubandlulula ngobuhlalanga''' kukulokha umuntu akholwa bona ubuhlanga bakhe nofana isiqhema sobutjhaba bakhe sikhulu kunezinye, bese lokho kumdosele ekutheni agcine sele akhombisa umkhuba wokubandlulula, nokungaphathi abantu ngokulingana.&lt;ref&gt;West, K., Greenland, K. and van Laar, C., 2021. Implicit racism, colour blindness, and narrow definitions of discrimination: Why some White people prefer ‘All Lives Matter’to ‘Black Lives Matter’. ''British Journal of Social Psychology'', ''60''(4), pp.1136-1153.&lt;/ref&gt; Ukubandlululana ngokubuhlanga kungavela ngendlela ezinengi ezenza bonyana kube nokungalingani kwamathuba,nemiphumela ebuhlangeni babantu.

=== Imihlobo yokubandlulula ngobuhlanga ===

==== Ukubandlulula ngobuhlanga bomuntu ====
Kukulokha umuntu aziphatha nofana anekolelo yokuthi ubuhlanga bakhe buncono nofana buphezulu kunaboboke ubuhlanga obukhona ephasini nofana enarheni ahlala kiyo.&lt;ref&gt;Merolla, D.M. and Jackson, O., 2019. Structural racism as the fundamental cause of the academic achievement gap. ''Sociology Compass'', ''13''(6), p.e12696.&lt;/ref&gt; Umuntu wakhon ukhuluma imibono engakalungi ngobunye ubuhlanga, akhombise ukubandlula ubunye ubuhlanga. Umuntu angabonakala angaphathi kuhle abantu abuthileko ngombana ngombana banobuhlanga angabuthandiko. Angabakhulumisa nofana akhulume ngabo kumbi akhombise ukungabafuni nokubanyaza. Nakusemsebenzini nofana emphakathini angakhombisa ukungaphathi abantu bobuhlanga angabuthandiko ngendlela ebandlululako.

==== Ukubandlulula ngobuhlaanga usebenzisa umgomo wesikhungo ====
Kwezinye iinkhungo bangakhombisa ukubandlulula ngokobuhlanga ngokuthi benze imigomo nendlela zokuraga ngaphakathi kwesikhungo lezi ezenza bona kungabi nokulingani okwenza bona abantu bobunye ubuhlanga abangaphakathi kwaleso sikhungo bagcine sele bagandelelekile nofana bangakaphatheki kuhle.&lt;ref&gt;Macdonald, L., 2018. ''Silencing and institutional racism in settler-colonial education'' (Doctoral dissertation, Open Access Te Herenga Waka-Victoria University of Wellington).&lt;/ref&gt; Kungabonakala bantu bobuhlanga obungafunwako bangakajameleki eenhlalweni zokudosa phambili nofana kilezo lapho kuthathwa kizo khona iinqunto. Kuthokale bonyana ubuhlanga obungathandwako sele bungasatholi amathuba alingana newabanye nofana lingasaphathwa kuhle ngoba linganamjameli.

==== Ukubandlulula ngobuhlanga usebenzisa  irherho ====
Le yindlela yokubandlula ngobuhlanga enabileko etholakala emphakathini abantu abaphila kiwo. Iphethe ngaphakathi umlando, isiko namaphethe ni weenkhungo lawa andisa ukubandlula ngobuhlanga nokuphathwa ngokungalingani kwabantu.&lt;ref&gt;Merolla, D.M. and Jackson, O., 2019. Structural racism as the fundamental cause of the academic achievement gap. ''Sociology Compass'', ''13''(6), p.e12696.&lt;/ref&gt; Ngokomlando ungathola ukubandlululana ngokobuhlanga obubangelwa zizinto ezenzeka kade njengokugcizwa kwabantu ekwenzeka kade, umbuso wegandelelo nokhuye. Okhunye ukubandlululana ngokwerherho kungavela  ezintweni ezikhulunywako zamasiko nemibono engakalungi ekungiyo ekhulisa ukubandlululana ngokobuhlanga.

=== Iindlela ezingabonakalisa ukubandlululana ngobuhlanga. ===
Ukubandlulula ngokobuhlanga kungabanakla lokha umuntu akhuluma izinto ezingakalungi ngobuhlanga obuthileko begodu izinto azikhulumako lezo kutholakale bonyana kuzuzinto ezingakaqinisekiswa bonyana ziliqiniso. Omunye angakhuluma into embi eyenziwa mumuntu munye  wobuhlanga obuthileko bese eyenze ngathi yenziwa ngiwo woke umuntuwobuhlanga lobo.Abanye abantu bangabonakala ngokuthi ngokuthi bangaphathi abantu bobuhlanga obuthileko kuhle. Uthole ubuhlanga obubandlulwako lobu bunganikelwa amathuba afana newabanye nofana ungaphathwa ngendlela efana neyabanye. Ilimi nalo niyakuveza ukubandlula ngokobuhlanga ngombana abanye abantu nabangathandi ubuhlanga obuthileko bbangakhuluma amagama abuhlungu ngobuhlanga lobo. Bangakhuluma ngendlela eyenza bona umuntu angakghoni ukuzizwa amakelekile phakathi kwabantu bobunye ubuhlanga. Nezenzo ngoba nazo kungenye yendlela yokukhuluma bese zikhombise bona kunokubandlululana ngokobuhlanga.

== Iinkomba ==</text>
      <sha1>mcqe63g0z2f2uaef1cinfrwu0kjy999</sha1>
    </revision>
    <revision>
      <id>3480</id>
      <parentid>3476</parentid>
      <timestamp>2025-07-29T14:59:59Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3480</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4214" sha1="39dr8hdjfrg8xwbkomwq4bbomoh3ohq" xml:space="preserve">[[Isimumathi:Black Lives Matter logo.svg|thumb|Le ngeminye yeminyakazo eyakhe yenziwa ukulwisana nokubandlululana ngobuhlanga.]]
'''Ukubandlulula ngobuhlalanga''' kukulokha umuntu akholwa bona ubuhlanga bakhe nofana isiqhema sobutjhaba bakhe sikhulu kunezinye, bese lokho kumdosele ekutheni agcine sele akhombisa umkhuba wokubandlulula, nokungaphathi abantu ngokulingana.&lt;ref&gt;West, K., Greenland, K. and van Laar, C., 2021. Implicit racism, colour blindness, and narrow definitions of discrimination: Why some White people prefer ‘All Lives Matter’to ‘Black Lives Matter’. ''British Journal of Social Psychology'', ''60''(4), pp.1136-1153.&lt;/ref&gt; Ukubandlululana ngokubuhlanga kungavela ngendlela ezinengi ezenza bonyana kube nokungalingani kwamathuba,nemiphumela ebuhlangeni babantu.

=== Imihlobo yokubandlulula ngobuhlanga ===

==== Ukubandlulula ngobuhlanga bomuntu ====
Kukulokha umuntu aziphatha nofana anekolelo yokuthi ubuhlanga bakhe buncono nofana buphezulu kunaboboke ubuhlanga obukhona ephasini nofana enarheni ahlala kiyo.&lt;ref&gt;Merolla, D.M. and Jackson, O., 2019. Structural racism as the fundamental cause of the academic achievement gap. ''Sociology Compass'', ''13''(6), p.e12696.&lt;/ref&gt; Umuntu wakhon ukhuluma imibono engakalungi ngobunye ubuhlanga, akhombise ukubandlula ubunye ubuhlanga. Umuntu angabonakala angaphathi kuhle abantu abuthileko ngombana ngombana banobuhlanga angabuthandiko. Angabakhulumisa nofana akhulume ngabo kumbi akhombise ukungabafuni nokubanyaza. Nakusemsebenzini nofana emphakathini angakhombisa ukungaphathi abantu bobuhlanga angabuthandiko ngendlela ebandlululako.

==== Ukubandlulula ngobuhlaanga usebenzisa umgomo wesikhungo ====
Kwezinye iinkhungo bangakhombisa ukubandlulula ngokobuhlanga ngokuthi benze imigomo nendlela zokuraga ngaphakathi kwesikhungo lezi ezenza bona kungabi nokulingani okwenza bona abantu bobunye ubuhlanga abangaphakathi kwaleso sikhungo bagcine sele bagandelelekile nofana bangakaphatheki kuhle.&lt;ref&gt;Macdonald, L., 2018. ''Silencing and institutional racism in settler-colonial education'' (Doctoral dissertation, Open Access Te Herenga Waka-Victoria University of Wellington).&lt;/ref&gt; Kungabonakala bantu bobuhlanga obungafunwako bangakajameleki eenhlalweni zokudosa phambili nofana kilezo lapho kuthathwa kizo khona iinqunto. Kuthokale bonyana ubuhlanga obungathandwako sele bungasatholi amathuba alingana newabanye nofana lingasaphathwa kuhle ngoba linganamjameli.

==== Ukubandlulula ngobuhlanga usebenzisa  irherho ====
Le yindlela yokubandlula ngobuhlanga enabileko etholakala emphakathini abantu abaphila kiwo. Iphethe ngaphakathi umlando, isiko namaphethe ni weenkhungo lawa andisa ukubandlula ngobuhlanga nokuphathwa ngokungalingani kwabantu.&lt;ref&gt;Merolla, D.M. and Jackson, O., 2019. Structural racism as the fundamental cause of the academic achievement gap. ''Sociology Compass'', ''13''(6), p.e12696.&lt;/ref&gt; Ngokomlando ungathola ukubandlululana ngokobuhlanga obubangelwa zizinto ezenzeka kade njengokugcizwa kwabantu ekwenzeka kade, umbuso wegandelelo nokhuye. Okhunye ukubandlululana ngokwerherho kungavela  ezintweni ezikhulunywako zamasiko nemibono engakalungi ekungiyo ekhulisa ukubandlululana ngokobuhlanga.

=== Iindlela ezingabonakalisa ukubandlululana ngobuhlanga. ===
Ukubandlulula ngokobuhlanga kungabanakla lokha umuntu akhuluma izinto ezingakalungi ngobuhlanga obuthileko begodu izinto azikhulumako lezo kutholakale bonyana kuzuzinto ezingakaqinisekiswa bonyana ziliqiniso. Omunye angakhuluma into embi eyenziwa mumuntu munye  wobuhlanga obuthileko bese eyenze ngathi yenziwa ngiwo woke umuntuwobuhlanga lobo.Abanye abantu bangabonakala ngokuthi ngokuthi bangaphathi abantu bobuhlanga obuthileko kuhle. Uthole ubuhlanga obubandlulwako lobu bunganikelwa amathuba afana newabanye nofana ungaphathwa ngendlela efana neyabanye. Ilimi nalo niyakuveza ukubandlula ngokobuhlanga ngombana abanye abantu nabangathandi ubuhlanga obuthileko bbangakhuluma amagama abuhlungu ngobuhlanga lobo. Bangakhuluma ngendlela eyenza bona umuntu angakghoni ukuzizwa amakelekile phakathi kwabantu bobunye ubuhlanga. Nezenzo ngoba nazo kungenye yendlela yokukhuluma bese zikhombise bona kunokubandlululana ngokobuhlanga.

== Iinkomba ==</text>
      <sha1>39dr8hdjfrg8xwbkomwq4bbomoh3ohq</sha1>
    </revision>
    <revision>
      <id>3481</id>
      <parentid>3480</parentid>
      <timestamp>2025-07-29T15:01:21Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3481</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4214" sha1="85wekbbze7yhc4xmg8w55a9ebgvxpe1" xml:space="preserve">[[Isimumathi:Black Lives Matter logo.svg|thumb|Le ngeminye yeminyakazo eyakhe yenziwa ukulwisana nokubandlululana ngobuhlanga.]]
'''Ukubandlulula ngobuhlalanga''' kukulokha umuntu akholwa bona ubuhlanga bakhe nofana isiqhema sobutjhaba bakhe sikhulu kunezinye, bese lokho kumdosele ekutheni agcine sele akhombisa umkhuba wokubandlulula, nokungaphathi abantu ngokulingana.&lt;ref&gt;West, K., Greenland, K. and van Laar, C., 2021. Implicit racism, colour blindness, and narrow definitions of discrimination: Why some White people prefer ‘All Lives Matter’to ‘Black Lives Matter’. ''British Journal of Social Psychology'', ''60''(4), pp.1136-1153.&lt;/ref&gt; Ukubandlululana ngokubuhlanga kungavela ngendlela ezinengi ezenza bonyana kube nokungalingani kwamathuba,nemiphumela ebuhlangeni babantu.

=== Imihlobo yokubandlulula ngobuhlanga ===

==== Ukubandlulula ngobuhlanga bomuntu ====
Kukulokha umuntu aziphatha nofana anekolelo yokuthi ubuhlanga bakhe buncono nofana buphezulu kunaboboke ubuhlanga obukhona ephasini nofana enarheni ahlala kiyo.&lt;ref&gt;Merolla, D.M. and Jackson, O., 2019. Structural racism as the fundamental cause of the academic achievement gap. ''Sociology Compass'', ''13''(6), p.e12696.&lt;/ref&gt; Umuntu wakhon ukhuluma imibono engakalungi ngobunye ubuhlanga, akhombise ukubandlula ubunye ubuhlanga. Umuntu angabonakala angaphathi kuhle abantu abuthileko ngombana ngombana banobuhlanga angabuthandiko. Angabakhulumisa nofana akhulume ngabo kumbi akhombise ukungabafuni nokubanyaza. Nakusemsebenzini nofana emphakathini angakhombisa ukungaphathi abantu bobuhlanga angabuthandiko ngendlela ebandlululako.

==== Ukubandlulula ngobuhlaanga usebenzisa umgomo wesikhungo ====
Kwezinye iinkhungo bangakhombisa ukubandlulula ngokobuhlanga ngokuthi benze imigomo nendlela zokuraga ngaphakathi kwesikhungo lezi ezenza bona kungabi nokulingani okwenza bona abantu bobunye ubuhlanga abangaphakathi kwaleso sikhungo bagcine sele bagandelelekile nofana bangakaphatheki kuhle.&lt;ref&gt;Macdonald, L., 2018. ''Silencing and institutional racism in settler-colonial education'' (Doctoral dissertation, Open Access Te Herenga Waka-Victoria University of Wellington).&lt;/ref&gt; Kungabonakala bantu bobuhlanga obungafunwako bangakajameleki eenhlalweni zokudosa phambili nofana kilezo lapho kuthathwa kizo khona iinqunto. Kuthokale bonyana ubuhlanga obungathandwako sele bungasatholi amathuba alingana newabanye nofana lingasaphathwa kuhle ngoba linganamjameli.

==== Ukubandlulula ngobuhlanga usebenzisa  irherho ====
Le yindlela yokubandlula ngobuhlanga enabileko etholakala emphakathini abantu abaphila kiwo. Iphethe ngaphakathi umlando, isiko namaphethe ni weenkhungo lawa andisa ukubandlula ngobuhlanga nokuphathwa ngokungalingani kwabantu.&lt;ref&gt;Merolla, D.M. and Jackson, O., 2019. Structural racism as the fundamental cause of the academic achievement gap. ''Sociology Compass'', ''13''(6), p.e12696.&lt;/ref&gt; Ngokomlando ungathola [[ukubandlulula]] ngobuhlanga obubangelwa zizinto ezenzeka kade njengokugcizwa kwabantu ekwenzeka kade, umbuso wegandelelo nokhuye. Okhunye ukubandlululana ngokwerherho kungavela  ezintweni ezikhulunywako zamasiko nemibono engakalungi ekungiyo ekhulisa ukubandlululana ngokobuhlanga.

=== Iindlela ezingabonakalisa ukubandlululana ngobuhlanga. ===
Ukubandlulula ngokobuhlanga kungabanakla lokha umuntu akhuluma izinto ezingakalungi ngobuhlanga obuthileko begodu izinto azikhulumako lezo kutholakale bonyana kuzuzinto ezingakaqinisekiswa bonyana ziliqiniso. Omunye angakhuluma into embi eyenziwa mumuntu munye  wobuhlanga obuthileko bese eyenze ngathi yenziwa ngiwo woke umuntuwobuhlanga lobo.Abanye abantu bangabonakala ngokuthi ngokuthi bangaphathi abantu bobuhlanga obuthileko kuhle. Uthole ubuhlanga obubandlulwako lobu bunganikelwa amathuba afana newabanye nofana ungaphathwa ngendlela efana neyabanye. Ilimi nalo niyakuveza ukubandlula ngokobuhlanga ngombana abanye abantu nabangathandi ubuhlanga obuthileko bbangakhuluma amagama abuhlungu ngobuhlanga lobo. Bangakhuluma ngendlela eyenza bona umuntu angakghoni ukuzizwa amakelekile phakathi kwabantu bobunye ubuhlanga. Nezenzo ngoba nazo kungenye yendlela yokukhuluma bese zikhombise bona kunokubandlululana ngokobuhlanga.

== Iinkomba ==</text>
      <sha1>85wekbbze7yhc4xmg8w55a9ebgvxpe1</sha1>
    </revision>
    <revision>
      <id>3482</id>
      <parentid>3481</parentid>
      <timestamp>2025-07-29T15:04:28Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3482</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4424" sha1="rds8dyvtovxkzp4q1vx8drnr42uvutm" xml:space="preserve">[[Isimumathi:Black Lives Matter logo.svg|thumb|Le ngeminye yeminyakazo eyakhe yenziwa ukulwisana nokubandlululana ngobuhlanga.]]
'''Ukubandlulula ngobuhlalanga''' kukulokha umuntu akholwa bona ubuhlanga bakhe nofana isiqhema sobutjhaba bakhe sikhulu kunezinye, bese lokho kumdosele ekutheni agcine sele akhombisa umkhuba wokubandlulula, nokungaphathi abantu ngokulingana.&lt;ref&gt;West, K., Greenland, K. and van Laar, C., 2021. Implicit racism, colour blindness, and narrow definitions of discrimination: Why some White people prefer ‘All Lives Matter’to ‘Black Lives Matter’. ''British Journal of Social Psychology'', ''60''(4), pp.1136-1153.&lt;/ref&gt; Ukubandlululana ngokubuhlanga kungavela ngendlela ezinengi ezenza bonyana kube nokungalingani kwamathuba,nemiphumela ebuhlangeni babantu.

=== Imihlobo yokubandlulula ngobuhlanga ===

==== Ukubandlulula ngobuhlanga bomuntu ====
Kukulokha umuntu aziphatha nofana anekolelo yokuthi ubuhlanga bakhe buncono nofana buphezulu kunaboboke ubuhlanga obukhona ephasini nofana enarheni ahlala kiyo.&lt;ref&gt;Merolla, D.M. and Jackson, O., 2019. Structural racism as the fundamental cause of the academic achievement gap. ''Sociology Compass'', ''13''(6), p.e12696.&lt;/ref&gt; Umuntu wakhon ukhuluma imibono engakalungi ngobunye ubuhlanga, akhombise ukubandlula ubunye ubuhlanga. Umuntu angabonakala angaphathi kuhle abantu abuthileko ngombana ngombana banobuhlanga angabuthandiko. Angabakhulumisa nofana akhulume ngabo kumbi akhombise ukungabafuni nokubanyaza. Nakusemsebenzini nofana emphakathini angakhombisa ukungaphathi abantu bobuhlanga angabuthandiko ngendlela ebandlululako.

==== Ukubandlulula ngobuhlaanga usebenzisa umgomo wesikhungo ====
Kwezinye iinkhungo bangakhombisa ukubandlulula ngokobuhlanga ngokuthi benze imigomo nendlela zokuraga ngaphakathi kwesikhungo lezi ezenza bona kungabi nokulingani okwenza bona abantu bobunye ubuhlanga abangaphakathi kwaleso sikhungo bagcine sele bagandelelekile nofana bangakaphatheki kuhle.&lt;ref&gt;Macdonald, L., 2018. ''Silencing and institutional racism in settler-colonial education'' (Doctoral dissertation, Open Access Te Herenga Waka-Victoria University of Wellington).&lt;/ref&gt; Kungabonakala bantu bobuhlanga obungafunwako bangakajameleki eenhlalweni zokudosa phambili nofana kilezo lapho kuthathwa kizo khona iinqunto. Kuthokale bonyana ubuhlanga obungathandwako sele bungasatholi amathuba alingana newabanye nofana lingasaphathwa kuhle ngoba linganamjameli.

==== Ukubandlulula ngobuhlanga usebenzisa  irherho ====
Le yindlela yokubandlula ngobuhlanga enabileko etholakala emphakathini abantu abaphila kiwo. Iphethe ngaphakathi umlando, isiko namaphethe ni weenkhungo lawa andisa ukubandlula ngobuhlanga nokuphathwa ngokungalingani kwabantu.&lt;ref&gt;Merolla, D.M. and Jackson, O., 2019. Structural racism as the fundamental cause of the academic achievement gap. ''Sociology Compass'', ''13''(6), p.e12696.&lt;/ref&gt; Ngokomlando ungathola [[ukubandlulula]] ngobuhlanga obubangelwa zizinto ezenzeka kade njengokugcizwa kwabantu ekwenzeka kade, umbuso wegandelelo nokhuye. Okhunye ukubandlululana ngokwerherho kungavela ezintweni ezikhulunywako zamasiko nemibono engakalungi ekungiyo ekhulisa ukubandlululana ngokobuhlanga.

=== Iindlela ezingabonakalisa ukubandlululana ngobuhlanga. ===
Ukubandlulula ngokobuhlanga kungabanakla lokha umuntu akhuluma izinto ezingakalungi ngobuhlanga obuthileko begodu izinto azikhulumako lezo kutholakale bonyana kuzuzinto ezingakaqinisekiswa bonyana ziliqiniso. Omunye angakhuluma into embi eyenziwa mumuntu munye  wobuhlanga obuthileko bese eyenze ngathi yenziwa ngiwo woke umuntuwobuhlanga lobo. Abanye abantu bangabonakala ngokuthi ngokuthi bangaphathi abantu bobuhlanga obuthileko kuhle.&lt;ref&gt;Salter, P.S., Adams, G. and Perez, M.J., 2018. Racism in the structure of everyday worlds: A cultural-psychological perspective. ''Current Directions in Psychological Science'', ''27''(3), pp.150-155.&lt;/ref&gt; Uthole ubuhlanga obubandlulwako lobu bunganikelwa amathuba afana newabanye nofana ungaphathwa ngendlela efana neyabanye. Ilimi nalo niyakuveza ukubandlula ngokobuhlanga ngombana abanye abantu nabangathandi ubuhlanga obuthileko bbangakhuluma amagama abuhlungu ngobuhlanga lobo. Bangakhuluma ngendlela eyenza bona umuntu angakghoni ukuzizwa amakelekile phakathi kwabantu bobunye ubuhlanga. Nezenzo ngoba nazo kungenye yendlela yokukhuluma bese zikhombise bona kunokubandlululana ngokobuhlanga.

== Iinkomba ==</text>
      <sha1>rds8dyvtovxkzp4q1vx8drnr42uvutm</sha1>
    </revision>
    <revision>
      <id>3484</id>
      <parentid>3482</parentid>
      <timestamp>2025-07-29T15:06:45Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3484</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4514" sha1="lwiigsk4yse4765gy07o94tqp3fppci" xml:space="preserve">[[Isimumathi:Black Lives Matter logo.svg|thumb|Le ngeminye yeminyakazo eyakhe yenziwa ukulwisana nokubandlululana ngobuhlanga.]]
'''Ukubandlulula ngobuhlalanga''' kukulokha umuntu akholwa bona ubuhlanga bakhe nofana isiqhema sobutjhaba bakhe sikhulu kunezinye, bese lokho kumdosele ekutheni agcine sele akhombisa umkhuba wokubandlulula, nokungaphathi abantu ngokulingana.&lt;ref&gt;West, K., Greenland, K. and van Laar, C., 2021. Implicit racism, colour blindness, and narrow definitions of discrimination: Why some White people prefer ‘All Lives Matter’to ‘Black Lives Matter’. ''British Journal of Social Psychology'', ''60''(4), pp.1136-1153.&lt;/ref&gt; Ukubandlululana ngokubuhlanga kungavela ngendlela ezinengi ezenza bonyana kube nokungalingani kwamathuba,nemiphumela ebuhlangeni babantu. ukubandlulula ngobuhlanga kuyinto eyenzekako ephasini abantu ebafanele bazifundise ngayo.

=== Imihlobo yokubandlulula ngobuhlanga ===

==== Ukubandlulula ngobuhlanga bomuntu ====
Kukulokha umuntu aziphatha nofana anekolelo yokuthi ubuhlanga bakhe buncono nofana buphezulu kunaboboke ubuhlanga obukhona ephasini nofana enarheni ahlala kiyo.&lt;ref&gt;Merolla, D.M. and Jackson, O., 2019. Structural racism as the fundamental cause of the academic achievement gap. ''Sociology Compass'', ''13''(6), p.e12696.&lt;/ref&gt; Umuntu wakhon ukhuluma imibono engakalungi ngobunye ubuhlanga, akhombise ukubandlula ubunye ubuhlanga. Umuntu angabonakala angaphathi kuhle abantu abuthileko ngombana ngombana banobuhlanga angabuthandiko. Angabakhulumisa nofana akhulume ngabo kumbi akhombise ukungabafuni nokubanyaza. Nakusemsebenzini nofana emphakathini angakhombisa ukungaphathi abantu bobuhlanga angabuthandiko ngendlela ebandlululako.

==== Ukubandlulula ngobuhlaanga usebenzisa umgomo wesikhungo ====
Kwezinye iinkhungo bangakhombisa ukubandlulula ngokobuhlanga ngokuthi benze imigomo nendlela zokuraga ngaphakathi kwesikhungo lezi ezenza bona kungabi nokulingani okwenza bona abantu bobunye ubuhlanga abangaphakathi kwaleso sikhungo bagcine sele bagandelelekile nofana bangakaphatheki kuhle.&lt;ref&gt;Macdonald, L., 2018. ''Silencing and institutional racism in settler-colonial education'' (Doctoral dissertation, Open Access Te Herenga Waka-Victoria University of Wellington).&lt;/ref&gt; Kungabonakala bantu bobuhlanga obungafunwako bangakajameleki eenhlalweni zokudosa phambili nofana kilezo lapho kuthathwa kizo khona iinqunto. Kuthokale bonyana ubuhlanga obungathandwako sele bungasatholi amathuba alingana newabanye nofana lingasaphathwa kuhle ngoba linganamjameli.

==== Ukubandlulula ngobuhlanga usebenzisa  irherho ====
Le yindlela yokubandlula ngobuhlanga enabileko etholakala emphakathini abantu abaphila kiwo. Iphethe ngaphakathi umlando, isiko namaphethe ni weenkhungo lawa andisa ukubandlula ngobuhlanga nokuphathwa ngokungalingani kwabantu.&lt;ref&gt;Merolla, D.M. and Jackson, O., 2019. Structural racism as the fundamental cause of the academic achievement gap. ''Sociology Compass'', ''13''(6), p.e12696.&lt;/ref&gt; Ngokomlando ungathola [[ukubandlulula]] ngobuhlanga obubangelwa zizinto ezenzeka kade njengokugcizwa kwabantu ekwenzeka kade, umbuso wegandelelo nokhuye. Okhunye ukubandlululana ngokwerherho kungavela ezintweni ezikhulunywako zamasiko nemibono engakalungi ekungiyo ekhulisa ukubandlululana ngokobuhlanga.

=== Iindlela ezingabonakalisa ukubandlululana ngobuhlanga. ===
Ukubandlulula ngokobuhlanga kungabanakla lokha umuntu akhuluma izinto ezingakalungi ngobuhlanga obuthileko begodu izinto azikhulumako lezo kutholakale bonyana kuzuzinto ezingakaqinisekiswa bonyana ziliqiniso. Omunye angakhuluma into embi eyenziwa mumuntu munye  wobuhlanga obuthileko bese eyenze ngathi yenziwa ngiwo woke umuntuwobuhlanga lobo. Abanye abantu bangabonakala ngokuthi ngokuthi bangaphathi abantu bobuhlanga obuthileko kuhle.&lt;ref&gt;Salter, P.S., Adams, G. and Perez, M.J., 2018. Racism in the structure of everyday worlds: A cultural-psychological perspective. ''Current Directions in Psychological Science'', ''27''(3), pp.150-155.&lt;/ref&gt; Uthole ubuhlanga obubandlulwako lobu bunganikelwa amathuba afana newabanye nofana ungaphathwa ngendlela efana neyabanye. Ilimi nalo niyakuveza ukubandlula ngokobuhlanga ngombana abanye abantu nabangathandi ubuhlanga obuthileko bbangakhuluma amagama abuhlungu ngobuhlanga lobo. Bangakhuluma ngendlela eyenza bona umuntu angakghoni ukuzizwa amakelekile phakathi kwabantu bobunye ubuhlanga. Nezenzo ngoba nazo kungenye yendlela yokukhuluma bese zikhombise bona kunokubandlululana ngokobuhlanga.

== Iinkomba ==</text>
      <sha1>lwiigsk4yse4765gy07o94tqp3fppci</sha1>
    </revision>
    <revision>
      <id>3575</id>
      <parentid>3484</parentid>
      <timestamp>2025-08-06T16:13:47Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>3575</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4585" sha1="krhdgx7kegclbnsisl3frh29o6f0d8g" xml:space="preserve">[[Isimumathi:Black Lives Matter logo.svg|thumb|Le ngeminye yeminyakazo eyakhe yenziwa ukulwisana nokubandlululana ngobuhlanga.]]
'''Ukubandlulula ngobuhlalanga''' kukulokha umuntu akholwa bona ubuhlanga bakhe nofana isiqhema sobutjhaba bakhe sikhulu kunezinye, bese lokho kumdosele ekutheni agcine sele akhombisa umkhuba wokubandlulula, nokungaphathi abantu ngokulingana.&lt;ref&gt;West, K., Greenland, K. and van Laar, C., 2021. Implicit racism, colour blindness, and narrow definitions of discrimination: Why some White people prefer ‘All Lives Matter’to ‘Black Lives Matter’. ''British Journal of Social Psychology'', ''60''(4), pp.1136-1153.&lt;/ref&gt; Ukubandlululana ngokubuhlanga kungavela ngendlela ezinengi ezenza bonyana kube nokungalingani kwamathuba,nemiphumela ebuhlangeni babantu. ukubandlulula ngobuhlanga kuyinto eyenzekako ephasini abantu ebafanele bazifundise ngayo.

=== Imihlobo yokubandlulula ngobuhlanga ===

==== Ukubandlulula ngobuhlanga bomuntu ====
Kukulokha umuntu aziphatha nofana anekolelo yokuthi ubuhlanga bakhe buncono nofana buphezulu kunaboboke ubuhlanga obukhona ephasini nofana enarheni ahlala kiyo.&lt;ref&gt;Merolla, D.M. and Jackson, O., 2019. Structural racism as the fundamental cause of the academic achievement gap. ''Sociology Compass'', ''13''(6), p.e12696.&lt;/ref&gt; Umuntu wakhon ukhuluma imibono engakalungi ngobunye ubuhlanga, akhombise ukubandlula ubunye ubuhlanga. Umuntu angabonakala angaphathi kuhle abantu abuthileko ngombana ngombana banobuhlanga angabuthandiko. Angabakhulumisa nofana akhulume ngabo kumbi akhombise ukungabafuni nokubanyaza. Nakusemsebenzini nofana emphakathini angakhombisa ukungaphathi abantu bobuhlanga angabuthandiko ngendlela ebandlululako.

==== Ukubandlulula ngobuhlaanga usebenzisa umgomo wesikhungo ====
Kwezinye iinkhungo bangakhombisa ukubandlulula ngokobuhlanga ngokuthi benze imigomo nendlela zokuraga ngaphakathi kwesikhungo lezi ezenza bona kungabi nokulingani okwenza bona abantu bobunye ubuhlanga abangaphakathi kwaleso sikhungo bagcine sele bagandelelekile nofana bangakaphatheki kuhle.&lt;ref&gt;Macdonald, L., 2018. ''Silencing and institutional racism in settler-colonial education'' (Doctoral dissertation, Open Access Te Herenga Waka-Victoria University of Wellington).&lt;/ref&gt; Kungabonakala bantu bobuhlanga obungafunwako bangakajameleki eenhlalweni zokudosa phambili nofana kilezo lapho kuthathwa kizo khona iinqunto. Kuthokale bonyana ubuhlanga obungathandwako sele bungasatholi amathuba alingana newabanye nofana lingasaphathwa kuhle ngoba linganamjameli.

==== Ukubandlulula ngobuhlanga usebenzisa  irherho ====
Le yindlela yokubandlula ngobuhlanga enabileko etholakala emphakathini abantu abaphila kiwo. Iphethe ngaphakathi umlando, isiko namaphethe ni weenkhungo lawa andisa ukubandlula ngobuhlanga nokuphathwa ngokungalingani kwabantu.&lt;ref&gt;Merolla, D.M. and Jackson, O., 2019. Structural racism as the fundamental cause of the academic achievement gap. ''Sociology Compass'', ''13''(6), p.e12696.&lt;/ref&gt; Ngokomlando ungathola [[ukubandlulula]] ngobuhlanga obubangelwa zizinto ezenzeka kade njengokugcizwa kwabantu ekwenzeka kade, umbuso wegandelelo nokhuye. Okhunye ukubandlululana ngokwerherho kungavela ezintweni ezikhulunywako zamasiko nemibono engakalungi ekungiyo ekhulisa ukubandlululana ngokobuhlanga.

=== Iindlela ezingabonakalisa ukubandlululana ngobuhlanga. ===
Ukubandlulula ngokobuhlanga kungabanakla lokha umuntu akhuluma izinto ezingakalungi ngobuhlanga obuthileko begodu izinto azikhulumako lezo kutholakale bonyana kuzuzinto ezingakaqinisekiswa bonyana ziliqiniso. Omunye angakhuluma into embi eyenziwa mumuntu munye  wobuhlanga obuthileko bese eyenze ngathi yenziwa ngiwo woke umuntuwobuhlanga lobo. Abanye abantu bangabonakala ngokuthi ngokuthi bangaphathi abantu bobuhlanga obuthileko kuhle.&lt;ref&gt;Salter, P.S., Adams, G. and Perez, M.J., 2018. Racism in the structure of everyday worlds: A cultural-psychological perspective. ''Current Directions in Psychological Science'', ''27''(3), pp.150-155.&lt;/ref&gt; Uthole ubuhlanga obubandlulwako lobu bunganikelwa amathuba afana newabanye nofana ungaphathwa ngendlela efana neyabanye. Ilimi nalo niyakuveza ukubandlula ngokobuhlanga ngombana abanye abantu nabangathandi ubuhlanga obuthileko bbangakhuluma amagama abuhlungu ngobuhlanga lobo. Bangakhuluma ngendlela eyenza bona umuntu angakghoni ukuzizwa amakelekile phakathi kwabantu bobunye ubuhlanga. Nezenzo ngoba nazo kungenye yendlela yokukhuluma bese zikhombise bona kunokubandlululana ngokobuhlanga.

== Iinkomba ==
[[Categories:Ukubandlulula ngobuhlanga]]
[[Categories: Ukubandlulula]]</text>
      <sha1>krhdgx7kegclbnsisl3frh29o6f0d8g</sha1>
    </revision>
    <revision>
      <id>3576</id>
      <parentid>3575</parentid>
      <timestamp>2025-08-06T16:14:38Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3576</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4589" sha1="kef23cjce7pghvabfrw1ebmjgx6aiyv" xml:space="preserve">[[Isimumathi:Black Lives Matter logo.svg|thumb|Le ngeminye yeminyakazo eyakhe yenziwa ukulwisana nokubandlululana ngobuhlanga.]]
'''Ukubandlulula ngobuhlalanga''' kukulokha umuntu akholwa bona ubuhlanga bakhe nofana isiqhema sobutjhaba bakhe sikhulu kunezinye, bese lokho kumdosele ekutheni agcine sele akhombisa umkhuba wokubandlulula, nokungaphathi abantu ngokulingana.&lt;ref&gt;West, K., Greenland, K. and van Laar, C., 2021. Implicit racism, colour blindness, and narrow definitions of discrimination: Why some White people prefer ‘All Lives Matter’to ‘Black Lives Matter’. ''British Journal of Social Psychology'', ''60''(4), pp.1136-1153.&lt;/ref&gt; Ukubandlululana ngokubuhlanga kungavela ngendlela ezinengi ezenza bonyana kube nokungalingani kwamathuba,nemiphumela ebuhlangeni babantu. ukubandlulula ngobuhlanga kuyinto eyenzekako ephasini abantu ebafanele bazifundise ngayo.

=== Imihlobo yokubandlulula ngobuhlanga ===

==== Ukubandlulula ngobuhlanga bomuntu ====
Kukulokha umuntu aziphatha nofana anekolelo yokuthi ubuhlanga bakhe buncono nofana buphezulu kunaboboke ubuhlanga obukhona ephasini nofana enarheni ahlala kiyo.&lt;ref&gt;Merolla, D.M. and Jackson, O., 2019. Structural racism as the fundamental cause of the academic achievement gap. ''Sociology Compass'', ''13''(6), p.e12696.&lt;/ref&gt; Umuntu wakhon ukhuluma imibono engakalungi ngobunye [[ubuhlanga]], akhombise ukubandlula ubunye ubuhlanga. Umuntu angabonakala angaphathi kuhle abantu abuthileko ngombana ngombana banobuhlanga angabuthandiko. Angabakhulumisa nofana akhulume ngabo kumbi akhombise ukungabafuni nokubanyaza. Nakusemsebenzini nofana emphakathini angakhombisa ukungaphathi abantu bobuhlanga angabuthandiko ngendlela ebandlululako.

==== Ukubandlulula ngobuhlaanga usebenzisa umgomo wesikhungo ====
Kwezinye iinkhungo bangakhombisa ukubandlulula ngokobuhlanga ngokuthi benze imigomo nendlela zokuraga ngaphakathi kwesikhungo lezi ezenza bona kungabi nokulingani okwenza bona abantu bobunye ubuhlanga abangaphakathi kwaleso sikhungo bagcine sele bagandelelekile nofana bangakaphatheki kuhle.&lt;ref&gt;Macdonald, L., 2018. ''Silencing and institutional racism in settler-colonial education'' (Doctoral dissertation, Open Access Te Herenga Waka-Victoria University of Wellington).&lt;/ref&gt; Kungabonakala bantu bobuhlanga obungafunwako bangakajameleki eenhlalweni zokudosa phambili nofana kilezo lapho kuthathwa kizo khona iinqunto. Kuthokale bonyana ubuhlanga obungathandwako sele bungasatholi amathuba alingana newabanye nofana lingasaphathwa kuhle ngoba linganamjameli.

==== Ukubandlulula ngobuhlanga usebenzisa  irherho ====
Le yindlela yokubandlula ngobuhlanga enabileko etholakala emphakathini abantu abaphila kiwo. Iphethe ngaphakathi umlando, isiko namaphethe ni weenkhungo lawa andisa ukubandlula ngobuhlanga nokuphathwa ngokungalingani kwabantu.&lt;ref&gt;Merolla, D.M. and Jackson, O., 2019. Structural racism as the fundamental cause of the academic achievement gap. ''Sociology Compass'', ''13''(6), p.e12696.&lt;/ref&gt; Ngokomlando ungathola [[ukubandlulula]] ngobuhlanga obubangelwa zizinto ezenzeka kade njengokugcizwa kwabantu ekwenzeka kade, umbuso wegandelelo nokhuye. Okhunye ukubandlululana ngokwerherho kungavela ezintweni ezikhulunywako zamasiko nemibono engakalungi ekungiyo ekhulisa ukubandlululana ngokobuhlanga.

=== Iindlela ezingabonakalisa ukubandlululana ngobuhlanga. ===
Ukubandlulula ngokobuhlanga kungabanakla lokha umuntu akhuluma izinto ezingakalungi ngobuhlanga obuthileko begodu izinto azikhulumako lezo kutholakale bonyana kuzuzinto ezingakaqinisekiswa bonyana ziliqiniso. Omunye angakhuluma into embi eyenziwa mumuntu munye  wobuhlanga obuthileko bese eyenze ngathi yenziwa ngiwo woke umuntuwobuhlanga lobo. Abanye abantu bangabonakala ngokuthi ngokuthi bangaphathi abantu bobuhlanga obuthileko kuhle.&lt;ref&gt;Salter, P.S., Adams, G. and Perez, M.J., 2018. Racism in the structure of everyday worlds: A cultural-psychological perspective. ''Current Directions in Psychological Science'', ''27''(3), pp.150-155.&lt;/ref&gt; Uthole ubuhlanga obubandlulwako lobu bunganikelwa amathuba afana newabanye nofana ungaphathwa ngendlela efana neyabanye. Ilimi nalo niyakuveza ukubandlula ngokobuhlanga ngombana abanye abantu nabangathandi ubuhlanga obuthileko bbangakhuluma amagama abuhlungu ngobuhlanga lobo. Bangakhuluma ngendlela eyenza bona umuntu angakghoni ukuzizwa amakelekile phakathi kwabantu bobunye ubuhlanga. Nezenzo ngoba nazo kungenye yendlela yokukhuluma bese zikhombise bona kunokubandlululana ngokobuhlanga.

== Iinkomba ==
[[Categories:Ukubandlulula ngobuhlanga]]
[[Categories: Ukubandlulula]]</text>
      <sha1>kef23cjce7pghvabfrw1ebmjgx6aiyv</sha1>
    </revision>
    <revision>
      <id>5202</id>
      <parentid>3576</parentid>
      <timestamp>2025-08-16T10:56:47Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>5202</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4590" sha1="0rdgq3puyipa5bbfh617iksf25az70g" xml:space="preserve">[[Isimumathi:Black Lives Matter logo.svg|thumb|Le ngeminye yeminyakazo eyakhe yenziwa ukulwisana nokubandlululana ngobuhlanga.]]
'''Ukubandlulula ngobuhlalanga''' kukulokha umuntu akholwa bona ubuhlanga bakhe nofana isiqhema sobutjhaba bakhe sikhulu kunezinye, bese lokho kumdosele ekutheni agcine sele akhombisa umkhuba wokubandlulula, nokungaphathi abantu ngokulingana.&lt;ref&gt;West, K., Greenland, K. and van Laar, C., 2021. Implicit racism, colour blindness, and narrow definitions of discrimination: Why some White people prefer ‘All Lives Matter’to ‘Black Lives Matter’. ''British Journal of Social Psychology'', ''60''(4), pp.1136-1153.&lt;/ref&gt; Ukubandlululana ngokubuhlanga kungavela ngendlela ezinengi ezenza bonyana kube nokungalingani kwamathuba,nemiphumela ebuhlangeni babantu. ukubandlulula ngobuhlanga kuyinto eyenzekako ephasini abantu ebafanele bazifundise ngayo.

=== Imihlobo yokubandlulula ngobuhlanga ===

==== Ukubandlulula ngobuhlanga bomuntu ====
Kukulokha umuntu aziphatha nofana anekolelo yokuthi ubuhlanga bakhe buncono nofana buphezulu kunaboboke ubuhlanga obukhona ephasini nofana enarheni ahlala kiyo.&lt;ref&gt;Merolla, D.M. and Jackson, O., 2019. Structural racism as the fundamental cause of the academic achievement gap. ''Sociology Compass'', ''13''(6), p.e12696.&lt;/ref&gt; Umuntu wakhon ukhuluma imibono engakalungi ngobunye [[ubuhlanga]], akhombise ukubandlula ubunye ubuhlanga. Umuntu angabonakala angaphathi kuhle abantu abuthileko ngombana ngombana banobuhlanga angabuthandiko. Angabakhulumisa nofana akhulume ngabo kumbi akhombise ukungabafuni nokubanyaza. Nakusemsebenzini nofana emphakathini angakhombisa ukungaphathi abantu bobuhlanga angabuthandiko ngendlela ebandlululako.

==== Ukubandlulula ngobuhlaanga usebenzisa umgomo wesikhungo ====
Kwezinye iinkhungo bangakhombisa ukubandlulula ngokobuhlanga ngokuthi benze imigomo nendlela zokuraga ngaphakathi kwesikhungo lezi ezenza bona kungabi nokulingani okwenza bona abantu bobunye ubuhlanga abangaphakathi kwaleso sikhungo bagcine sele bagandelelekile nofana bangakaphatheki kuhle.&lt;ref&gt;Macdonald, L., 2018. ''Silencing and institutional racism in settler-colonial education'' (Doctoral dissertation, Open Access Te Herenga Waka-Victoria University of Wellington).&lt;/ref&gt; Kungabonakala bantu bobuhlanga obungafunwako bangakajameleki eenhlalweni zokudosa phambili nofana kilezo lapho kuthathwa kizo khona iinqunto. Kuthokale bonyana ubuhlanga obungathandwako sele bungasatholi amathuba alingana newabanye nofana lingasaphathwa kuhle ngoba linganamjameli.

==== Ukubandlulula ngobuhlanga usebenzisa  irherho ====
Le yindlela yokubandlula ngobuhlanga enabileko etholakala emphakathini abantu abaphila kiwo. Iphethe ngaphakathi umlando, isiko namaphethe ni weenkhungo lawa andisa ukubandlula ngobuhlanga nokuphathwa ngokungalingani kwabantu.&lt;ref&gt;Merolla, D.M. and Jackson, O., 2019. Structural racism as the fundamental cause of the academic achievement gap. ''Sociology Compass'', ''13''(6), p.e12696.&lt;/ref&gt; Ngokomlando ungathola [[ukubandlulula]] ngobuhlanga obubangelwa zizinto ezenzeka kade njengokugcizwa kwabantu ekwenzeka kade, umbuso wegandelelo nokhuye. Okhunye ukubandlululana ngokwerherho kungavela ezintweni ezikhulunywako zamasiko nemibono engakalungi ekungiyo ekhulisa ukubandlululana ngokobuhlanga.

=== Iindlela ezingabonakalisa ukubandlululana ngobuhlanga. ===
Ukubandlulula ngokobuhlanga kungabanakla lokha umuntu akhuluma izinto ezingakalungi ngobuhlanga obuthileko begodu izinto azikhulumako lezo kutholakale bonyana kuzuzinto ezingakaqinisekiswa bonyana ziliqiniso. Omunye angakhuluma into embi eyenziwa mumuntu munye  wobuhlanga obuthileko bese eyenze ngathi yenziwa ngiwo woke umuntuwobuhlanga lobo. Abanye abantu bangabonakala ngokuthi ngokuthi bangaphathi abantu bobuhlanga obuthileko kuhle.&lt;ref&gt;Salter, P.S., Adams, G. and Perez, M.J., 2018. Racism in the structure of everyday worlds: A cultural-psychological perspective. ''Current Directions in Psychological Science'', ''27''(3), pp.150-155.&lt;/ref&gt; Uthole ubuhlanga obubandlulwako lobu bunganikelwa amathuba afana newabanye nofana ungaphathwa ngendlela efana neyabanye. Ilimi nalo niyakuveza ukubandlula ngokobuhlanga ngombana abanye abantu nabangathandi ubuhlanga obuthileko bbangakhuluma amagama abuhlungu ngobuhlanga lobo. Bangakhuluma ngendlela eyenza bona umuntu angakghoni ukuzizwa amakelekile phakathi kwabantu bobunye ubuhlanga. Nezenzo ngoba nazo kungenye yendlela yokukhuluma bese zikhombise bona kunokubandlululana ngokobuhlanga.

== Iinkomba ==

[[Categories:Ukubandlulula ngobuhlanga]]
[[Categories: Ukubandlulula]]</text>
      <sha1>0rdgq3puyipa5bbfh617iksf25az70g</sha1>
    </revision>
  </page>
  <page>
    <title>Amalungelo wabantwana</title>
    <ns>0</ns>
    <id>715</id>
    <revision>
      <id>3485</id>
      <timestamp>2025-07-29T15:26:26Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''Umntwana''' kungomunye nomunye umuntu oneminyaka engaphasi kwe-18.&lt;ref&gt;Lansdown, G. and Vaghri, Z., 2022, January. Article 1: Definition of a child. In ''Monitoring state compliance with the UN Convention on the Rights of the Child: An analysis of attributes'' (pp. 407-412). Cham, Switzerland: Springer International Publishing.&lt;/ref&gt; Omunye nomunye Umntwana enarheni yeSewula AFrika unamalungelo amvikelako bona aphile begodu akhule kuhle. Amalungelo wabantwana ayinto e...&quot;</comment>
      <origin>3485</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3750" sha1="2j0fdnqi39owv9ywexlwztz992eivln" xml:space="preserve">'''Umntwana''' kungomunye nomunye umuntu oneminyaka engaphasi kwe-18.&lt;ref&gt;Lansdown, G. and Vaghri, Z., 2022, January. Article 1: Definition of a child. In ''Monitoring state compliance with the UN Convention on the Rights of the Child: An analysis of attributes'' (pp. 407-412). Cham, Switzerland: Springer International Publishing.&lt;/ref&gt; Omunye nomunye Umntwana enarheni yeSewula AFrika unamalungelo amvikelako bona aphile begodu akhule kuhle. Amalungelo wabantwana ayinto eqakathekileko emalungweni wabantu. Amalungelo la enzinze ekuvikelweni nehlala kuhle yabantwana. Amalungelo wabantwana asekwelwe ma prinsiphuli amane ekukungabandlululi, ukuhlonitjhwa kwemibono yomtnwana, ukukhula nokusinda nalokho ukuhlala kuhle komntwana.

Amaphrinsipuli amanye wokwenziwa kwamalungelo wabantwana.

Ukungabandlulwa

Woke Umntwana ohlala enarheni yeSewula afrika kufuze aphathwe ngokulingana anabanye abantwana begodu nangokuhlonitjwa, ngaphandle kobana kuqalwe bonyana unjani ngokombala, ubulili, ikolo nofana okhunye. Urhulumende kufanele aqinisekise bonyana woke Umntwana uphathwa ngokulingana nabanye begodu uthola amathuba afanako newabanye. Akukafaneli bonyana Umntwana abandlululwe lapho aphila khona.

Ukuhlonitjhwa kwemibono yomntwana

Abantwana banelungelo lokuthi bakghone ukuveza imibono yabo begodu ingathethelwa phasi lokha nabayivezileko, begodu bazibandakanye eenquntweni ezithathwako eziphathelene namaphilo wabo. Imibono yabantwana kufanele bona ithathelwe phezulu njengeyabantu abakhululileko.&lt;ref&gt;Garcia-Quiroga, M. and Agoglia, I.S., 2020. Too vulnerable to participate? Challenges for meaningful participation in research with children in alternative care and adoption. ''International journal of qualitative methods'', ''19'', p.1609406920958965.&lt;/ref&gt; Imibono yabantwana kufanele kufanele ithathwe ngokuya kweminyaka yabo, ukukhula kwengcondo zaba kuqinisekiswe bonyana bayazwakala begodu iyahlonipheka umbono wabo.&lt;ref&gt;Nthontho, M., 2017. Children as stakeholders in education: Does their voice matter?. ''South African Journal of Childhood Education'', ''7''(1), pp.1-7.&lt;/ref&gt;

Ukukhula nokusinda

Umntwana ukuze akhule kuhle kufuze bona kufanel azizwe avikelekile ebhodulukweni aphila kiyo, asinde begodu akhulu kuhle emzimbeni, emkhumbulweni Kanye nemmoyeni. Akukafaneli bonyana Umntwana ahlukumezeke emphakathini ahlala kiwo khona azokutjhuphuluka akhule ngendlela ekungiyo.&lt;ref&gt;Cross, D., 2017. What our children need: A bill of rights. ''Unpublished manuscript''.&lt;/ref&gt; Kufanele Umntwana ahlalele anepilo emzimbeni athole zoke izinto azitlhogako ukuze ahlale anepilo. Izinto ezifana nokudla kuhle, ayiswe emtholapilo ayokuhlaba ukuthi angangenwa amagulo.

Ukuhlala kuhle komntwana

Lokho kutjho bona Umntwana kufuze bona abekwe phambili begodu nalokha abantu abadala nabathatha iinqunto kufuze  bathome baqabangele abantwana bonyana lokho kuzobaphatha  bunjani emzimbeni, emkhumbulweni Kanye nemmoyeni. Urhulumende nabatlhogomeli kufuze bona benze koke ekusemandleni wabo ukuqinisekisa bona Umntwana uhleli kuhle.

Amanye wamalungelo wabantwana

Ilungelo lokuphila, lokusinda Kanye nokukhula- Umntwana unelipngelo lokuthi aphile angabulawa begodu asinde ezintweni ezingaba yingozi epilweni yakhe akhule kuhle.

Ilungelo lokuvikelwa enturhwini nekuhlunkunyezweni-Abantwana bafanele bavikelwe bonyanaa bangazitholi sele bahlukunyenzwa nofana bafakwe enturhiwini bangatlhogonywela ngombana bangazithola balimala.

Ilungelo lokuthola ipilo- Umntwana kufanele ahlale lapho ibhoduluko lakhe linepilo khona begodu akghone ukuthi ayiswe emtholapilo lokha nakanganapilo kuhle emzimbeni.

Ilungelo lokufunda- Umntwana kufuze athole ifundo yasimahla ezomlekela bonyana akghone ukuthi athuthukise nofana akhulise amakghono nelwazi lakhe.</text>
      <sha1>2j0fdnqi39owv9ywexlwztz992eivln</sha1>
    </revision>
    <revision>
      <id>3486</id>
      <parentid>3485</parentid>
      <timestamp>2025-07-29T15:28:14Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3486</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3870" sha1="a253rc99n6jp4e4sb5c5jmloztqyvio" xml:space="preserve">'''Umntwana''' kungomunye nomunye umuntu oneminyaka engaphasi kwe-18.&lt;ref&gt;Lansdown, G. and Vaghri, Z., 2022, January. Article 1: Definition of a child. In ''Monitoring state compliance with the UN Convention on the Rights of the Child: An analysis of attributes'' (pp. 407-412). Cham, Switzerland: Springer International Publishing.&lt;/ref&gt; Omunye nomunye Umntwana enarheni yeSewula AFrika unamalungelo amvikelako bona aphile begodu akhule kuhle. Amalungelo wabantwana ayinto eqakathekileko emalungweni wabantu. Amalungelo la enzinze ekuvikelweni nehlala kuhle yabantwana. Amalungelo wabantwana asekwelwe ma prinsiphuli amane ekukungabandlululi, ukuhlonitjhwa kwemibono yomtnwana, ukukhula nokusinda nalokho ukuhlala kuhle komntwana.

Amaphrinsipuli amanye wokwenziwa kwamalungelo wabantwana.

Ukungabandlulwa
[[Isimumathi:Amalungelo wabentwana.jpg|thumb|Abentwana abasekulisa basiwe emapholiseni ukugidinga ilanga lamalungelo. ]]
Woke Umntwana ohlala enarheni yeSewula afrika kufuze aphathwe ngokulingana anabanye abantwana begodu nangokuhlonitjwa, ngaphandle kobana kuqalwe bonyana unjani ngokombala, ubulili, ikolo nofana okhunye. Urhulumende kufanele aqinisekise bonyana woke Umntwana uphathwa ngokulingana nabanye begodu uthola amathuba afanako newabanye. Akukafaneli bonyana Umntwana abandlululwe lapho aphila khona.

Ukuhlonitjhwa kwemibono yomntwana

Abantwana banelungelo lokuthi bakghone ukuveza imibono yabo begodu ingathethelwa phasi lokha nabayivezileko, begodu bazibandakanye eenquntweni ezithathwako eziphathelene namaphilo wabo. Imibono yabantwana kufanele bona ithathelwe phezulu njengeyabantu abakhululileko.&lt;ref&gt;Garcia-Quiroga, M. and Agoglia, I.S., 2020. Too vulnerable to participate? Challenges for meaningful participation in research with children in alternative care and adoption. ''International journal of qualitative methods'', ''19'', p.1609406920958965.&lt;/ref&gt; Imibono yabantwana kufanele kufanele ithathwe ngokuya kweminyaka yabo, ukukhula kwengcondo zaba kuqinisekiswe bonyana bayazwakala begodu iyahlonipheka umbono wabo.&lt;ref&gt;Nthontho, M., 2017. Children as stakeholders in education: Does their voice matter?. ''South African Journal of Childhood Education'', ''7''(1), pp.1-7.&lt;/ref&gt;

Ukukhula nokusinda

Umntwana ukuze akhule kuhle kufuze bona kufanel azizwe avikelekile ebhodulukweni aphila kiyo, asinde begodu akhulu kuhle emzimbeni, emkhumbulweni Kanye nemmoyeni. Akukafaneli bonyana Umntwana ahlukumezeke emphakathini ahlala kiwo khona azokutjhuphuluka akhule ngendlela ekungiyo.&lt;ref&gt;Cross, D., 2017. What our children need: A bill of rights. ''Unpublished manuscript''.&lt;/ref&gt; Kufanele Umntwana ahlalele anepilo emzimbeni athole zoke izinto azitlhogako ukuze ahlale anepilo. Izinto ezifana nokudla kuhle, ayiswe emtholapilo ayokuhlaba ukuthi angangenwa amagulo.

Ukuhlala kuhle komntwana

Lokho kutjho bona Umntwana kufuze bona abekwe phambili begodu nalokha abantu abadala nabathatha iinqunto kufuze  bathome baqabangele abantwana bonyana lokho kuzobaphatha  bunjani emzimbeni, emkhumbulweni Kanye nemmoyeni. Urhulumende nabatlhogomeli kufuze bona benze koke ekusemandleni wabo ukuqinisekisa bona Umntwana uhleli kuhle.

Amanye wamalungelo wabantwana

Ilungelo lokuphila, lokusinda Kanye nokukhula- Umntwana unelipngelo lokuthi aphile angabulawa begodu asinde ezintweni ezingaba yingozi epilweni yakhe akhule kuhle.

Ilungelo lokuvikelwa enturhwini nekuhlunkunyezweni-Abantwana bafanele bavikelwe bonyanaa bangazitholi sele bahlukunyenzwa nofana bafakwe enturhiwini bangatlhogonywela ngombana bangazithola balimala.

Ilungelo lokuthola ipilo- Umntwana kufanele ahlale lapho ibhoduluko lakhe linepilo khona begodu akghone ukuthi ayiswe emtholapilo lokha nakanganapilo kuhle emzimbeni.

Ilungelo lokufunda- Umntwana kufuze athole ifundo yasimahla ezomlekela bonyana akghone ukuthi athuthukise nofana akhulise amakghono nelwazi lakhe.</text>
      <sha1>a253rc99n6jp4e4sb5c5jmloztqyvio</sha1>
    </revision>
    <revision>
      <id>3487</id>
      <parentid>3486</parentid>
      <timestamp>2025-07-29T15:42:16Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3487</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3999" sha1="ewvbb2b3dq6591usq8m69vo57j8ve9z" xml:space="preserve">'''Umntwana''' kungomunye nomunye umuntu oneminyaka engaphasi kwe-18.&lt;ref&gt;Lansdown, G. and Vaghri, Z., 2022, January. Article 1: Definition of a child. In ''Monitoring state compliance with the UN Convention on the Rights of the Child: An analysis of attributes'' (pp. 407-412). Cham, Switzerland: Springer International Publishing.&lt;/ref&gt; Omunye nomunye Umntwana enarheni yeSewula AFrika unamalungelo amvikelako bona aphile begodu akhule kuhle. Amalungelo wabantwana ayinto eqakathekileko emalungweni wabantu. Amalungelo la enzinze ekuvikelweni nehlala kuhle yabantwana. Amalungelo wabantwana asekwelwe ma prinsiphuli amane ekukungabandlululi, ukuhlonitjhwa kwemibono yomtnwana, ukukhula nokusinda nalokho ukuhlala kuhle komntwana.

Amaphrinsipuli amanye wokwenziwa kwamalungelo wabantwana.

Ukungabandlulwa
[[Isimumathi:Amalungelo wabentwana.jpg|thumb|Abentwana abasekulisa basiwe emapholiseni ukugidinga ilanga lamalungelo. ]]
Woke Umntwana ohlala enarheni yeSewula afrika kufuze aphathwe ngokulingana anabanye abantwana begodu nangokuhlonitjwa, ngaphandle kobana kuqalwe bonyana unjani ngokombala, ubulili, ikolo nofana okhunye. Urhulumende kufanele aqinisekise bonyana woke Umntwana uphathwa ngokulingana nabanye begodu uthola amathuba afanako newabanye. Akukafaneli bonyana Umntwana abandlululwe ngendlela zoke lapho aphila khona. Kufanele umntwana aziizwe amukelekile bogodu athandwa ukuze akghone ukukhula ngendlela engeze yamlimaza ingqondo.

Ukuhlonitjhwa kwemibono yomntwana

Abantwana banelungelo lokuthi bakghone ukuveza imibono yabo begodu ingathethelwa phasi lokha nabayivezileko, begodu bazibandakanye eenquntweni ezithathwako eziphathelene namaphilo wabo. Imibono yabantwana kufanele bona ithathelwe phezulu njengeyabantu abakhululileko.&lt;ref&gt;Garcia-Quiroga, M. and Agoglia, I.S., 2020. Too vulnerable to participate? Challenges for meaningful participation in research with children in alternative care and adoption. ''International journal of qualitative methods'', ''19'', p.1609406920958965.&lt;/ref&gt; Imibono yabantwana kufanele kufanele ithathwe ngokuya kweminyaka yabo, ukukhula kwengcondo zaba kuqinisekiswe bonyana bayazwakala begodu iyahlonipheka umbono wabo.&lt;ref&gt;Nthontho, M., 2017. Children as stakeholders in education: Does their voice matter?. ''South African Journal of Childhood Education'', ''7''(1), pp.1-7.&lt;/ref&gt;

Ukukhula nokusinda

Umntwana ukuze akhule kuhle kufuze bona kufanel azizwe avikelekile ebhodulukweni aphila kiyo, asinde begodu akhulu kuhle emzimbeni, emkhumbulweni Kanye nemmoyeni. Akukafaneli bonyana Umntwana ahlukumezeke emphakathini ahlala kiwo khona azokutjhuphuluka akhule ngendlela ekungiyo.&lt;ref&gt;Cross, D., 2017. What our children need: A bill of rights. ''Unpublished manuscript''.&lt;/ref&gt; Kufanele Umntwana ahlalele anepilo emzimbeni athole zoke izinto azitlhogako ukuze ahlale anepilo. Izinto ezifana nokudla kuhle, ayiswe emtholapilo ayokuhlaba ukuthi angangenwa amagulo.

Ukuhlala kuhle komntwana

Lokho kutjho bona Umntwana kufuze bona abekwe phambili begodu nalokha abantu abadala nabathatha iinqunto kufuze  bathome baqabangele abantwana bonyana lokho kuzobaphatha  bunjani emzimbeni, emkhumbulweni Kanye nemmoyeni. Urhulumende nabatlhogomeli kufuze bona benze koke ekusemandleni wabo ukuqinisekisa bona Umntwana uhleli kuhle.

Amanye wamalungelo wabantwana

Ilungelo lokuphila, lokusinda Kanye nokukhula- Umntwana unelipngelo lokuthi aphile angabulawa begodu asinde ezintweni ezingaba yingozi epilweni yakhe akhule kuhle.

Ilungelo lokuvikelwa enturhwini nekuhlunkunyezweni-Abantwana bafanele bavikelwe bonyanaa bangazitholi sele bahlukunyenzwa nofana bafakwe enturhiwini bangatlhogonywela ngombana bangazithola balimala.

Ilungelo lokuthola ipilo- Umntwana kufanele ahlale lapho ibhoduluko lakhe linepilo khona begodu akghone ukuthi ayiswe emtholapilo lokha nakanganapilo kuhle emzimbeni.

Ilungelo lokufunda- Umntwana kufuze athole ifundo yasimahla ezomlekela bonyana akghone ukuthi athuthukise nofana akhulise amakghono nelwazi lakhe.</text>
      <sha1>ewvbb2b3dq6591usq8m69vo57j8ve9z</sha1>
    </revision>
    <revision>
      <id>3488</id>
      <parentid>3487</parentid>
      <timestamp>2025-07-29T15:49:22Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3488</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4369" sha1="k8amecgk7o63nnum052uqk403ndbygx" xml:space="preserve">'''Umntwana''' kungomunye nomunye umuntu oneminyaka engaphasi kwe-18.&lt;ref&gt;Lansdown, G. and Vaghri, Z., 2022, January. Article 1: Definition of a child. In ''Monitoring state compliance with the UN Convention on the Rights of the Child: An analysis of attributes'' (pp. 407-412). Cham, Switzerland: Springer International Publishing.&lt;/ref&gt; Omunye nomunye Umntwana enarheni yeSewula AFrika unamalungelo amvikelako bona aphile begodu akhule kuhle. Amalungelo wabantwana ayinto eqakathekileko emalungweni wabantu. Amalungelo la enzinze ekuvikelweni nehlala kuhle yabantwana. Amalungelo wabantwana asekwelwe ma prinsiphuli amane ekukungabandlululi, ukuhlonitjhwa kwemibono yomtnwana, ukukhula nokusinda nalokho ukuhlala kuhle komntwana.

Amaphrinsipuli amanye wokwenziwa kwamalungelo wabantwana.

Ukungabandlulwa
[[Isimumathi:Amalungelo wabentwana.jpg|thumb|Abentwana abasekulisa basiwe emapholiseni ukugidinga ilanga lamalungelo. ]]
Woke Umntwana ohlala enarheni yeSewula afrika kufuze aphathwe ngokulingana anabanye abantwana begodu nangokuhlonitjwa, ngaphandle kobana kuqalwe bonyana unjani ngokombala, ubulili, ikolo nofana okhunye. Urhulumende kufanele aqinisekise bonyana woke Umntwana uphathwa ngokulingana nabanye begodu uthola amathuba afanako newabanye. Akukafaneli bonyana Umntwana abandlululwe ngendlela zoke lapho aphila khona. Kufanele umntwana aziizwe amukelekile bogodu athandwa ukuze akghone ukukhula ngendlela engeze yamlimaza ingqondo.

Ukuhlonitjhwa kwemibono yomntwana

Abantwana banelungelo lokuthi bakghone ukuveza imibono yabo begodu ingathethelwa phasi lokha nabayivezileko, begodu bazibandakanye eenquntweni ezithathwako eziphathelene namaphilo wabo. Imibono yabantwana kufanele bona ithathelwe phezulu njengeyabantu abakhululileko.&lt;ref&gt;Garcia-Quiroga, M. and Agoglia, I.S., 2020. Too vulnerable to participate? Challenges for meaningful participation in research with children in alternative care and adoption. ''International journal of qualitative methods'', ''19'', p.1609406920958965.&lt;/ref&gt; Imibono yabantwana kufanele kufanele ithathwe ngokuya kweminyaka yabo, ukukhula kwengcondo zaba kuqinisekiswe bonyana bayazwakala begodu iyahlonipheka umbono wabo.&lt;ref&gt;Nthontho, M., 2017. Children as stakeholders in education: Does their voice matter?. ''South African Journal of Childhood Education'', ''7''(1), pp.1-7.&lt;/ref&gt;

Ukukhula nokusinda

Umntwana ukuze akhule kuhle kufuze bona kufanel azizwe avikelekile ebhodulukweni aphila kiyo, asinde begodu akhulu kuhle emzimbeni, emkhumbulweni Kanye nemmoyeni. Akukafaneli bonyana Umntwana ahlukumezeke emphakathini ahlala kiwo khona azokutjhuphuluka akhule ngendlela ekungiyo.&lt;ref&gt;Cross, D., 2017. What our children need: A bill of rights. ''Unpublished manuscript''.&lt;/ref&gt; Kufanele Umntwana ahlalele anepilo emzimbeni athole zoke izinto azitlhogako ukuze ahlale anepilo. Izinto ezifana nokudla kuhle, ayiswe emtholapilo ayokuhlaba ukuthi angangenwa amagulo.

Ukuhlala kuhle komntwana

Lokho kutjho bona Umntwana kufuze bona abekwe phambili begodu nalokha abantu abadala nabathatha iinqunto kufuze  bathome baqabangele abantwana bonyana lokho kuzobaphatha  bunjani emzimbeni, emkhumbulweni Kanye nemmoyeni. Urhulumende nabatlhogomeli kufuze bona benze koke ekusemandleni wabo ukuqinisekisa bona Umntwana uhleli kuhle.&lt;ref&gt;Hsiao, C., Fry, D., Ward, C.L., Ganz, G., Casey, T., Zheng, X. and Fang, X., 2018. Violence against children in South Africa: The cost of inaction to society and the economy. ''BMJ global health'', ''3''(1), p.e000573.&lt;/ref&gt; Umntwana kufanelwe bona avikelwe ngaso soke iskhathi angazitholi lapho azokugcina ahlukunyezwa khona ngokomseme, emmoyeni nofana emzimbeni. 

Amanye wamalungelo wabantwana

Ilungelo lokuphila, lokusinda Kanye nokukhula- Umntwana unelipngelo lokuthi aphile angabulawa begodu asinde ezintweni ezingaba yingozi epilweni yakhe akhule kuhle.

Ilungelo lokuvikelwa enturhwini nekuhlunkunyezweni-Abantwana bafanele bavikelwe bonyanaa bangazitholi sele bahlukunyenzwa nofana bafakwe enturhiwini bangatlhogonywela ngombana bangazithola balimala.

Ilungelo lokuthola ipilo- Umntwana kufanele ahlale lapho ibhoduluko lakhe linepilo khona begodu akghone ukuthi ayiswe emtholapilo lokha nakanganapilo kuhle emzimbeni.

Ilungelo lokufunda- Umntwana kufuze athole ifundo yasimahla ezomlekela bonyana akghone ukuthi athuthukise nofana akhulise amakghono nelwazi lakhe.</text>
      <sha1>k8amecgk7o63nnum052uqk403ndbygx</sha1>
    </revision>
    <revision>
      <id>3489</id>
      <parentid>3488</parentid>
      <timestamp>2025-07-29T15:54:31Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3489</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4604" sha1="kxsvfwoqmwg6ew8v5v1mdp4kqspxiap" xml:space="preserve">'''Umntwana''' kungomunye nomunye umuntu oneminyaka engaphasi kwe-18.&lt;ref&gt;Lansdown, G. and Vaghri, Z., 2022, January. Article 1: Definition of a child. In ''Monitoring state compliance with the UN Convention on the Rights of the Child: An analysis of attributes'' (pp. 407-412). Cham, Switzerland: Springer International Publishing.&lt;/ref&gt; Omunye nomunye Umntwana enarheni yeSewula AFrika unamalungelo amvikelako bona aphile begodu akhule kuhle. Amalungelo wabantwana ayinto eqakathekileko emalungweni wabantu. Amalungelo la enzinze ekuvikelweni nehlala kuhle yabantwana. Amalungelo wabantwana asekwelwe ma prinsiphuli amane ekukungabandlululi, ukuhlonitjhwa kwemibono yomtnwana, ukukhula nokusinda nalokho ukuhlala kuhle komntwana.

=== Amaphrinsipuli amanye wokwenziwa kwamalungelo wabantwana. ===

==== Ukungabandlululwa ====
[[Isimumathi:Amalungelo wabentwana.jpg|thumb|Abentwana abasekulisa basiwe emapholiseni ukugidinga ilanga lamalungelo. ]]
Woke Umntwana ohlala enarheni yeSewula afrika kufuze aphathwe ngokulingana anabanye abantwana begodu nangokuhlonitjwa, ngaphandle kobana kuqalwe bonyana unjani ngokombala, ubulili, ikolo nofana okhunye. Urhulumende kufanele aqinisekise bonyana woke Umntwana uphathwa ngokulingana nabanye begodu uthola amathuba afanako newabanye. Akukafaneli bonyana Umntwana abandlululwe ngendlela zoke lapho aphila khona. Kufanele umntwana aziizwe amukelekile bogodu athandwa ukuze akghone ukukhula ngendlela engeze yamlimaza ingqondo.

==== Ukuhlonitjhwa kwemibono yomntwana ====
Abantwana banelungelo lokuthi bakghone ukuveza imibono yabo begodu ingathethelwa phasi lokha nabayivezileko, begodu bazibandakanye eenquntweni ezithathwako eziphathelene namaphilo wabo. Imibono yabantwana kufanele bona ithathelwe phezulu njengeyabantu abakhululileko.&lt;ref&gt;Garcia-Quiroga, M. and Agoglia, I.S., 2020. Too vulnerable to participate? Challenges for meaningful participation in research with children in alternative care and adoption. ''International journal of qualitative methods'', ''19'', p.1609406920958965.&lt;/ref&gt; Imibono yabantwana kufanele ithathwe ngokuya kweminyaka yabo, ukukhula kwengcondo zaba kuqinisekiswe bonyana bayazwakala begodu iyahlonipheka umbono wabo.&lt;ref&gt;Nthontho, M., 2017. Children as stakeholders in education: Does their voice matter?. ''South African Journal of Childhood Education'', ''7''(1), pp.1-7.&lt;/ref&gt;Ukulalela imibono yabentwana kwenza bonyana umntwana ahlale kuhle ngombana kutjho bona angekhe umntwana enziswe izinto angazithandiko nangazifuniko ngokukatelelelwa.

==== Ukukhula nokusinda ====
Umntwana ukuze akhule kuhle kufuze bona kufanel azizwe avikelekile ebhodulukweni aphila kiyo, asinde begodu akhulu kuhle emzimbeni, emkhumbulweni Kanye nemmoyeni. Akukafaneli bonyana Umntwana ahlukumezeke emphakathini ahlala kiwo khona azokutjhuphuluka akhule ngendlela ekungiyo.&lt;ref&gt;Cross, D., 2017. What our children need: A bill of rights. ''Unpublished manuscript''.&lt;/ref&gt; Kufanele Umntwana ahlalele anepilo emzimbeni athole zoke izinto azitlhogako ukuze ahlale anepilo. Izinto ezifana nokudla kuhle, ayiswe emtholapilo ayokuhlaba ukuthi angangenwa amagulo.

==== Ukuhlala kuhle komntwana ====
Lokho kutjho bona Umntwana kufuze bona abekwe phambili begodu nalokha abantu abadala nabathatha iinqunto kufuze  bathome baqabangele abantwana bonyana lokho kuzobaphatha  bunjani emzimbeni, emkhumbulweni Kanye nemmoyeni. Urhulumende nabatlhogomeli kufuze bona benze koke ekusemandleni wabo ukuqinisekisa bona Umntwana uhleli kuhle.&lt;ref&gt;Hsiao, C., Fry, D., Ward, C.L., Ganz, G., Casey, T., Zheng, X. and Fang, X., 2018. Violence against children in South Africa: The cost of inaction to society and the economy. ''BMJ global health'', ''3''(1), p.e000573.&lt;/ref&gt; Umntwana kufanelwe bona avikelwe ngaso soke iskhathi angazitholi lapho azokugcina ahlukunyezwa khona ngokomseme, emmoyeni nofana emzimbeni. 

=== Amanye wamalungelo wabantwana ===

* Ilungelo lokuphila, lokusinda Kanye nokukhula- Umntwana unelipngelo lokuthi aphile angabulawa begodu asinde ezintweni ezingaba yingozi epilweni yakhe akhule kuhle.

* Ilungelo lokuvikelwa enturhwini nekuhlunkunyezweni-Abantwana bafanele bavikelwe bonyanaa bangazitholi sele bahlukunyenzwa nofana bafakwe enturhiwini bangatlhogonywela ngombana bangazithola balimala.

* Ilungelo lokuthola ipilo- Umntwana kufanele ahlale lapho ibhoduluko lakhe linepilo khona begodu akghone ukuthi ayiswe emtholapilo lokha nakanganapilo kuhle emzimbeni.

* Ilungelo lokufunda- Umntwana kufuze athole ifundo yasimahla ezomlekela bonyana akghone ukuthi athuthukise nofana akhulise amakghono nelwazi lakhe.

== Iinkomba ==</text>
      <sha1>kxsvfwoqmwg6ew8v5v1mdp4kqspxiap</sha1>
    </revision>
    <revision>
      <id>3490</id>
      <parentid>3489</parentid>
      <timestamp>2025-07-29T16:02:03Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3490</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4611" sha1="04jyins5zsore2eizi3nqk6kkjxpmwy" xml:space="preserve">'''Umntwana''' kungomunye nomunye umuntu oneminyaka engaphasi kwe-18.&lt;ref&gt;Lansdown, G. and Vaghri, Z., 2022, January. Article 1: Definition of a child. In ''Monitoring state compliance with the UN Convention on the Rights of the Child: An analysis of attributes'' (pp. 407-412). Cham, Switzerland: Springer International Publishing.&lt;/ref&gt; Omunye nomunye Umntwana enarheni yeSewula AFrika unamalungelo amvikelako bona aphile begodu akhule kuhle. Amalungelo wabantwana asiqhema esikhethekileko  s[[amalungelo wabantu]]. Amalungelo la enzinze ekuvikelweni nehlala kuhle yabantwana. Amalungelo wabantwana asekwelwe ma prinsiphuli amane ekukungabandlululi, ukuhlonitjhwa kwemibono yomntwana, ukukhula nokusinda nalokho ukuhlala kuhle komntwana.

=== Amaphrinsipuli amane wokwenziwa kwamalungelo wabantwana. ===

==== Ukungabandlululwa ====
[[Isimumathi:Amalungelo wabentwana.jpg|thumb|Abentwana abasekulisa basiwe emapholiseni ukugidinga ilanga lamalungelo. ]]
Woke Umntwana ohlala enarheni yeSewula afrika kufuze aphathwe ngokulingana anabanye abantwana begodu nangokuhlonitjwa, ngaphandle kobana kuqalwe bonyana unjani ngokombala, ubulili, ikolo nofana okhunye. Urhulumende kufanele aqinisekise bonyana woke Umntwana uphathwa ngokulingana nabanye begodu uthola amathuba afanako newabanye. Akukafaneli bonyana Umntwana abandlululwe ngendlela zoke lapho aphila khona. Kufanele umntwana aziizwe amukelekile bogodu athandwa ukuze akghone ukukhula ngendlela engeze yamlimaza ingqondo.

==== Ukuhlonitjhwa kwemibono yomntwana ====
Abantwana banelungelo lokuthi bakghone ukuveza imibono yabo begodu ingathethelwa phasi lokha nabayivezileko, begodu bazibandakanye eenquntweni ezithathwako eziphathelene namaphilo wabo. Imibono yabantwana kufanele bona ithathelwe phezulu njengeyabantu abakhululileko.&lt;ref&gt;Garcia-Quiroga, M. and Agoglia, I.S., 2020. Too vulnerable to participate? Challenges for meaningful participation in research with children in alternative care and adoption. ''International journal of qualitative methods'', ''19'', p.1609406920958965.&lt;/ref&gt; Imibono yabantwana kufanele ithathwe ngokuya kweminyaka yabo, ukukhula kwengcondo zaba kuqinisekiswe bonyana bayazwakala begodu iyahlonipheka umbono wabo.&lt;ref&gt;Nthontho, M., 2017. Children as stakeholders in education: Does their voice matter?. ''South African Journal of Childhood Education'', ''7''(1), pp.1-7.&lt;/ref&gt;Ukulalela imibono yabentwana kwenza bonyana umntwana ahlale kuhle ngombana kutjho bona angekhe umntwana enziswe izinto angazithandiko nangazifuniko ngokukatelelelwa.

==== Ukukhula nokusinda ====
Umntwana ukuze akhule kuhle kufuze bona kufanel azizwe avikelekile ebhodulukweni aphila kiyo, asinde begodu akhulu kuhle emzimbeni, emkhumbulweni Kanye nemmoyeni. Akukafaneli bonyana Umntwana ahlukumezeke emphakathini ahlala kiwo khona azokutjhuphuluka akhule ngendlela ekungiyo.&lt;ref&gt;Cross, D., 2017. What our children need: A bill of rights. ''Unpublished manuscript''.&lt;/ref&gt; Kufanele Umntwana ahlalele anepilo emzimbeni athole zoke izinto azitlhogako ukuze ahlale anepilo. Izinto ezifana nokudla kuhle, ayiswe emtholapilo ayokuhlaba ukuthi angangenwa amagulo.

==== Ukuhlala kuhle komntwana ====
Lokho kutjho bona Umntwana kufuze bona abekwe phambili begodu nalokha abantu abadala nabathatha iinqunto kufuze  bathome baqabangele abantwana bonyana lokho kuzobaphatha  bunjani emzimbeni, emkhumbulweni Kanye nemmoyeni. Urhulumende nabatlhogomeli kufuze bona benze koke ekusemandleni wabo ukuqinisekisa bona Umntwana uhleli kuhle.&lt;ref&gt;Hsiao, C., Fry, D., Ward, C.L., Ganz, G., Casey, T., Zheng, X. and Fang, X., 2018. Violence against children in South Africa: The cost of inaction to society and the economy. ''BMJ global health'', ''3''(1), p.e000573.&lt;/ref&gt; Umntwana kufanelwe bona avikelwe ngaso soke iskhathi angazitholi lapho azokugcina ahlukunyezwa khona ngokomseme, emmoyeni nofana emzimbeni. 

=== Amanye wamalungelo wabantwana ===

* Ilungelo lokuphila, lokusinda Kanye nokukhula- Umntwana unelipngelo lokuthi aphile angabulawa begodu asinde ezintweni ezingaba yingozi epilweni yakhe akhule kuhle.

* Ilungelo lokuvikelwa enturhwini nekuhlunkunyezweni-Abantwana bafanele bavikelwe bonyanaa bangazitholi sele bahlukunyenzwa nofana bafakwe enturhiwini bangatlhogonywela ngombana bangazithola balimala.

* Ilungelo lokuthola ipilo- Umntwana kufanele ahlale lapho ibhoduluko lakhe linepilo khona begodu akghone ukuthi ayiswe emtholapilo lokha nakanganapilo kuhle emzimbeni.

* Ilungelo lokufunda- Umntwana kufuze athole ifundo yasimahla ezomlekela bonyana akghone ukuthi athuthukise nofana akhulise amakghono nelwazi lakhe.

== Iinkomba ==</text>
      <sha1>04jyins5zsore2eizi3nqk6kkjxpmwy</sha1>
    </revision>
    <revision>
      <id>3491</id>
      <parentid>3490</parentid>
      <timestamp>2025-07-29T16:06:25Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3491</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4739" sha1="ks7j3nlmyft7wwt4omavm3tcvkwe2mr" xml:space="preserve">'''Umntwana''' kungomunye nomunye umuntu oneminyaka engaphasi kwe-18.&lt;ref&gt;Lansdown, G. and Vaghri, Z., 2022, January. Article 1: Definition of a child. In ''Monitoring state compliance with the UN Convention on the Rights of the Child: An analysis of attributes'' (pp. 407-412). Cham, Switzerland: Springer International Publishing.&lt;/ref&gt; Omunye nomunye Umntwana enarheni yeSewula AFrika unamalungelo amvikelako bona aphile begodu akhule kuhle. Amalungelo wabantwana asiqhema esikhethekileko  s[[amalungelo wabantu]]. Amalungelo la atlolwe phasi ku -''UN Convention'' emalungelweni wabantwana, yona ephasiswa yinarha ezibumbeko ngonyaka we-1989. Amalungelo la enzinze ekuvikelweni nehlala kuhle yabantwana. Amalungelo wabantwana asekwelwe ma prinsiphuli amane ekukungabandlululi, ukuhlonitjhwa kwemibono yomntwana, ukukhula nokusinda nalokho ukuhlala kuhle komntwana.

=== Amaphrinsipuli amane wokwenziwa kwamalungelo wabantwana. ===

==== Ukungabandlululwa ====
[[Isimumathi:Amalungelo wabentwana.jpg|thumb|Abentwana abasekulisa basiwe emapholiseni ukugidinga ilanga lamalungelo. ]]
Woke Umntwana ohlala enarheni yeSewula afrika kufuze aphathwe ngokulingana anabanye abantwana begodu nangokuhlonitjwa, ngaphandle kobana kuqalwe bonyana unjani ngokombala, ubulili, ikolo nofana okhunye. Urhulumende kufanele aqinisekise bonyana woke Umntwana uphathwa ngokulingana nabanye begodu uthola amathuba afanako newabanye. Akukafaneli bonyana Umntwana abandlululwe ngendlela zoke lapho aphila khona. Kufanele umntwana aziizwe amukelekile bogodu athandwa ukuze akghone ukukhula ngendlela engeze yamlimaza ingqondo.

==== Ukuhlonitjhwa kwemibono yomntwana ====
Abantwana banelungelo lokuthi bakghone ukuveza imibono yabo begodu ingathethelwa phasi lokha nabayivezileko, begodu bazibandakanye eenquntweni ezithathwako eziphathelene namaphilo wabo. Imibono yabantwana kufanele bona ithathelwe phezulu njengeyabantu abakhululileko.&lt;ref&gt;Garcia-Quiroga, M. and Agoglia, I.S., 2020. Too vulnerable to participate? Challenges for meaningful participation in research with children in alternative care and adoption. ''International journal of qualitative methods'', ''19'', p.1609406920958965.&lt;/ref&gt; Imibono yabantwana kufanele ithathwe ngokuya kweminyaka yabo, ukukhula kwengcondo zaba kuqinisekiswe bonyana bayazwakala begodu iyahlonipheka umbono wabo.&lt;ref&gt;Nthontho, M., 2017. Children as stakeholders in education: Does their voice matter?. ''South African Journal of Childhood Education'', ''7''(1), pp.1-7.&lt;/ref&gt;Ukulalela imibono yabentwana kwenza bonyana umntwana ahlale kuhle ngombana kutjho bona angekhe umntwana enziswe izinto angazithandiko nangazifuniko ngokukatelelelwa.

==== Ukukhula nokusinda ====
Umntwana ukuze akhule kuhle kufuze bona kufanel azizwe avikelekile ebhodulukweni aphila kiyo, asinde begodu akhulu kuhle emzimbeni, emkhumbulweni Kanye nemmoyeni. Akukafaneli bonyana Umntwana ahlukumezeke emphakathini ahlala kiwo khona azokutjhuphuluka akhule ngendlela ekungiyo.&lt;ref&gt;Cross, D., 2017. What our children need: A bill of rights. ''Unpublished manuscript''.&lt;/ref&gt; Kufanele Umntwana ahlalele anepilo emzimbeni athole zoke izinto azitlhogako ukuze ahlale anepilo. Izinto ezifana nokudla kuhle, ayiswe emtholapilo ayokuhlaba ukuthi angangenwa amagulo.

==== Ukuhlala kuhle komntwana ====
Lokho kutjho bona Umntwana kufuze bona abekwe phambili begodu nalokha abantu abadala nabathatha iinqunto kufuze  bathome baqabangele abantwana bonyana lokho kuzobaphatha  bunjani emzimbeni, emkhumbulweni Kanye nemmoyeni. Urhulumende nabatlhogomeli kufuze bona benze koke ekusemandleni wabo ukuqinisekisa bona Umntwana uhleli kuhle.&lt;ref&gt;Hsiao, C., Fry, D., Ward, C.L., Ganz, G., Casey, T., Zheng, X. and Fang, X., 2018. Violence against children in South Africa: The cost of inaction to society and the economy. ''BMJ global health'', ''3''(1), p.e000573.&lt;/ref&gt; Umntwana kufanelwe bona avikelwe ngaso soke iskhathi angazitholi lapho azokugcina ahlukunyezwa khona ngokomseme, emmoyeni nofana emzimbeni. 

=== Amanye wamalungelo wabantwana ===

* Ilungelo lokuphila, lokusinda Kanye nokukhula- Umntwana unelipngelo lokuthi aphile angabulawa begodu asinde ezintweni ezingaba yingozi epilweni yakhe akhule kuhle.

* Ilungelo lokuvikelwa enturhwini nekuhlunkunyezweni-Abantwana bafanele bavikelwe bonyanaa bangazitholi sele bahlukunyenzwa nofana bafakwe enturhiwini bangatlhogonywela ngombana bangazithola balimala.

* Ilungelo lokuthola ipilo- Umntwana kufanele ahlale lapho ibhoduluko lakhe linepilo khona begodu akghone ukuthi ayiswe emtholapilo lokha nakanganapilo kuhle emzimbeni.

* Ilungelo lokufunda- Umntwana kufuze athole ifundo yasimahla ezomlekela bonyana akghone ukuthi athuthukise nofana akhulise amakghono nelwazi lakhe.

== Iinkomba ==</text>
      <sha1>ks7j3nlmyft7wwt4omavm3tcvkwe2mr</sha1>
    </revision>
    <revision>
      <id>3492</id>
      <parentid>3491</parentid>
      <timestamp>2025-07-29T16:16:07Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3492</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5046" sha1="tod0q90hj5g8etnho98m87bjdtlmow2" xml:space="preserve">'''Umntwana''' kungomunye nomunye umuntu oneminyaka engaphasi kwe-18.&lt;ref&gt;Lansdown, G. and Vaghri, Z., 2022, January. Article 1: Definition of a child. In ''Monitoring state compliance with the UN Convention on the Rights of the Child: An analysis of attributes'' (pp. 407-412). Cham, Switzerland: Springer International Publishing.&lt;/ref&gt; Omunye nomunye Umntwana enarheni yeSewula AFrika unamalungelo amvikelako bona aphile begodu akhule kuhle. Amalungelo wabantwana asiqhema esikhethekileko  s[[amalungelo wabantu]]. Amalungelo la atlolwe phasi ku -''UN Convention'' emalungelweni wabantwana, yona ephasiswa yinarha ezibumbeko ngonyaka we-1989. Amalungelo la enzinze ekuvikelweni nehlala kuhle yabantwana. Amalungelo wabantwana asekwelwe ma prinsiphuli amane ekukungabandlululi, ukuhlonitjhwa kwemibono yomntwana, ukukhula nokusinda nalokho ukuhlala kuhle komntwana.

=== Amaphrinsipuli amane wokwenziwa kwamalungelo wabantwana. ===

==== Ukungabandlululwa ====
[[Isimumathi:Amalungelo wabentwana.jpg|thumb|Abentwana abasekulisa basiwe emapholiseni ukugidinga ilanga lamalungelo. ]]
Woke Umntwana ohlala enarheni yeSewula afrika kufuze aphathwe ngokulingana anabanye abantwana begodu nangokuhlonitjwa, ngaphandle kobana kuqalwe bonyana unjani ngokombala, ubulili, ikolo nofana okhunye. Urhulumende kufanele aqinisekise bonyana woke Umntwana uphathwa ngokulingana nabanye begodu uthola amathuba afanako newabanye. Akukafaneli bonyana Umntwana abandlululwe ngendlela zoke lapho aphila khona. Kufanele umntwana aziizwe amukelekile bogodu athandwa ukuze akghone ukukhula ngendlela engeze yamlimaza ingqondo.

==== Ukuhlonitjhwa kwemibono yomntwana ====
Abantwana banelungelo lokuthi bakghone ukuveza imibono yabo begodu ingathethelwa phasi lokha nabayivezileko, begodu bazibandakanye eenquntweni ezithathwako eziphathelene namaphilo wabo. Imibono yabantwana kufanele bona ithathelwe phezulu njengeyabantu abakhululileko.&lt;ref&gt;Garcia-Quiroga, M. and Agoglia, I.S., 2020. Too vulnerable to participate? Challenges for meaningful participation in research with children in alternative care and adoption. ''International journal of qualitative methods'', ''19'', p.1609406920958965.&lt;/ref&gt; Imibono yabantwana kufanele ithathwe ngokuya kweminyaka yabo, ukukhula kwengcondo zaba kuqinisekiswe bonyana bayazwakala begodu iyahlonipheka umbono wabo.&lt;ref&gt;Nthontho, M., 2017. Children as stakeholders in education: Does their voice matter?. ''South African Journal of Childhood Education'', ''7''(1), pp.1-7.&lt;/ref&gt;Ukulalela imibono yabentwana kwenza bonyana umntwana ahlale kuhle ngombana kutjho bona angekhe umntwana enziswe izinto angazithandiko nangazifuniko ngokukatelelelwa.

==== Ukukhula nokusinda ====
Umntwana ukuze akhule kuhle kufuze bona kufanel azizwe avikelekile ebhodulukweni aphila kiyo, asinde begodu akhulu kuhle emzimbeni, emkhumbulweni Kanye nemmoyeni. Akukafaneli bonyana Umntwana ahlukumezeke emphakathini ahlala kiwo khona azokutjhuphuluka akhule ngendlela ekungiyo.&lt;ref&gt;Cross, D., 2017. What our children need: A bill of rights. ''Unpublished manuscript''.&lt;/ref&gt; Kufanele Umntwana ahlalele anepilo emzimbeni athole zoke izinto azitlhogako ukuze ahlale anepilo. Izinto ezifana nokudla kuhle, ayiswe emtholapilo ayokuhlaba ukuthi angangenwa amagulo, begodu ahlale atlhonyelwa babelethi nofana labo abadala asele nabo.

==== Ukuhlala kuhle komntwana ====
Lokho kutjho bona Umntwana kufuze bona abekwe phambili begodu nalokha abantu abadala nabathatha iinqunto kufuze  bathome baqabangele abantwana bonyana lokho kuzobaphatha  bunjani emzimbeni, emkhumbulweni Kanye nemmoyeni. Urhulumende nabatlhogomeli kufuze bona benze koke ekusemandleni wabo ukuqinisekisa bona Umntwana uhleli kuhle.&lt;ref&gt;Hsiao, C., Fry, D., Ward, C.L., Ganz, G., Casey, T., Zheng, X. and Fang, X., 2018. Violence against children in South Africa: The cost of inaction to society and the economy. ''BMJ global health'', ''3''(1), p.e000573.&lt;/ref&gt; Umntwana kufanelwe bona avikelwe ngaso soke iskhathi angazitholi lapho azokugcina ahlukunyezwa khona ngokomseme, emmoyeni nofana emzimbeni. Ibhoduluko lalapho umntwana ahlala khona kufanele libe nokuthula lingazali ngenturhu. 

=== Amanye wamalungelo wabantwana ===

* Ilungelo lokuphila, lokusinda Kanye nokukhula- Umntwana unelipngelo lokuthi aphile angabulawa begodu asinde ezintweni ezingaba yingozi epilweni yakhe akhule kuhle.

* Ilungelo lokuvikelwa enturhwini nekuhlunkunyezweni-Abantwana bafanele bavikelwe bonyanaa bangazitholi sele bahlukunyenzwa nofana bafakwe enturhiwini bangatlhogonywela ngombana bangazithola balimala.

* Ilungelo lokuthola ipilo- Umntwana kufanele ahlale lapho ibhoduluko lakhe linepilo khona begodu akghone ukuthi ayiswe emtholapilo lokha nakanganapilo kuhle emzimbeni.

* Ilungelo lokufunda- Umntwana kufuze athole ifundo yasimahla ezomlekela bonyana akghone ukuthi athuthukise nofana akhulise amakghono nelwazi lakhe.&lt;ref&gt;Marishane, R.N., 2017. The right to basic education for all in South Africa: Implications for school principals. ''Koers'', ''82''(3), pp.1-8.&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>tod0q90hj5g8etnho98m87bjdtlmow2</sha1>
    </revision>
    <revision>
      <id>3493</id>
      <parentid>3492</parentid>
      <timestamp>2025-07-29T16:22:45Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>3493</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5065" sha1="4yl19p4dwykpzo6qje1syfoazauu5ub" xml:space="preserve">'''Umntwana''' kungomunye nomunye umuntu oneminyaka engaphasi kwe-18.&lt;ref&gt;Lansdown, G. and Vaghri, Z., 2022, January. Article 1: Definition of a child. In ''Monitoring state compliance with the UN Convention on the Rights of the Child: An analysis of attributes'' (pp. 407-412). Cham, Switzerland: Springer International Publishing.&lt;/ref&gt; Omunye nomunye Umntwana enarheni yeSewula AFrika unamalungelo amvikelako bona aphile begodu akhule kuhle. Amalungelo wabantwana asiqhema esikhethekileko  s[[amalungelo wabantu|amalungelo wobuntu]]. Amalungelo la atlolwe phasi ku -''UN Convention'' emalungelweni wabantwana, yona ephasiswa yinarha ezibumbeko ngonyaka we-1989. Amalungelo la enzinze ekuvikelweni nehlala kuhle yabantwana. Amalungelo wabantwana asekwelwe ma prinsiphuli amane ekukungabandlululi, ukuhlonitjhwa kwemibono yomntwana, ukukhula nokusinda nalokho ukuhlala kuhle komntwana.

=== Amaphrinsipuli amane wokwenziwa kwamalungelo wabantwana. ===

==== Ukungabandlululwa ====
[[Isimumathi:Amalungelo wabentwana.jpg|thumb|Abentwana abasekulisa basiwe emapholiseni ukugidinga ilanga lamalungelo. ]]
Woke Umntwana ohlala enarheni yeSewula afrika kufuze aphathwe ngokulingana anabanye abantwana begodu nangokuhlonitjwa, ngaphandle kobana kuqalwe bonyana unjani ngokombala, ubulili, ikolo nofana okhunye. Urhulumende kufanele aqinisekise bonyana woke Umntwana uphathwa ngokulingana nabanye begodu uthola amathuba afanako newabanye. Akukafaneli bonyana Umntwana abandlululwe ngendlela zoke lapho aphila khona. Kufanele umntwana aziizwe amukelekile bogodu athandwa ukuze akghone ukukhula ngendlela engeze yamlimaza ingqondo.

==== Ukuhlonitjhwa kwemibono yomntwana ====
Abantwana banelungelo lokuthi bakghone ukuveza imibono yabo begodu ingathethelwa phasi lokha nabayivezileko, begodu bazibandakanye eenquntweni ezithathwako eziphathelene namaphilo wabo. Imibono yabantwana kufanele bona ithathelwe phezulu njengeyabantu abakhululileko.&lt;ref&gt;Garcia-Quiroga, M. and Agoglia, I.S., 2020. Too vulnerable to participate? Challenges for meaningful participation in research with children in alternative care and adoption. ''International journal of qualitative methods'', ''19'', p.1609406920958965.&lt;/ref&gt; Imibono yabantwana kufanele ithathwe ngokuya kweminyaka yabo, ukukhula kwengcondo zaba kuqinisekiswe bonyana bayazwakala begodu iyahlonipheka umbono wabo.&lt;ref&gt;Nthontho, M., 2017. Children as stakeholders in education: Does their voice matter?. ''South African Journal of Childhood Education'', ''7''(1), pp.1-7.&lt;/ref&gt;Ukulalela imibono yabentwana kwenza bonyana umntwana ahlale kuhle ngombana kutjho bona angekhe umntwana enziswe izinto angazithandiko nangazifuniko ngokukatelelelwa.

==== Ukukhula nokusinda ====
Umntwana ukuze akhule kuhle kufuze bona kufanel azizwe avikelekile ebhodulukweni aphila kiyo, asinde begodu akhulu kuhle emzimbeni, emkhumbulweni Kanye nemmoyeni. Akukafaneli bonyana Umntwana ahlukumezeke emphakathini ahlala kiwo khona azokutjhuphuluka akhule ngendlela ekungiyo.&lt;ref&gt;Cross, D., 2017. What our children need: A bill of rights. ''Unpublished manuscript''.&lt;/ref&gt; Kufanele Umntwana ahlalele anepilo emzimbeni athole zoke izinto azitlhogako ukuze ahlale anepilo. Izinto ezifana nokudla kuhle, ayiswe emtholapilo ayokuhlaba ukuthi angangenwa amagulo, begodu ahlale atlhonyelwa babelethi nofana labo abadala asele nabo.

==== Ukuhlala kuhle komntwana ====
Lokho kutjho bona Umntwana kufuze bona abekwe phambili begodu nalokha abantu abadala nabathatha iinqunto kufuze  bathome baqabangele abantwana bonyana lokho kuzobaphatha  bunjani emzimbeni, emkhumbulweni Kanye nemmoyeni. Urhulumende nabatlhogomeli kufuze bona benze koke ekusemandleni wabo ukuqinisekisa bona Umntwana uhleli kuhle.&lt;ref&gt;Hsiao, C., Fry, D., Ward, C.L., Ganz, G., Casey, T., Zheng, X. and Fang, X., 2018. Violence against children in South Africa: The cost of inaction to society and the economy. ''BMJ global health'', ''3''(1), p.e000573.&lt;/ref&gt; Umntwana kufanelwe bona avikelwe ngaso soke iskhathi angazitholi lapho azokugcina ahlukunyezwa khona ngokomseme, emmoyeni nofana emzimbeni. Ibhoduluko lalapho umntwana ahlala khona kufanele libe nokuthula lingazali ngenturhu. 

=== Amanye wamalungelo wabantwana ===

* Ilungelo lokuphila, lokusinda Kanye nokukhula- Umntwana unelipngelo lokuthi aphile angabulawa begodu asinde ezintweni ezingaba yingozi epilweni yakhe akhule kuhle.

* Ilungelo lokuvikelwa enturhwini nekuhlunkunyezweni-Abantwana bafanele bavikelwe bonyanaa bangazitholi sele bahlukunyenzwa nofana bafakwe enturhiwini bangatlhogonywela ngombana bangazithola balimala.

* Ilungelo lokuthola ipilo- Umntwana kufanele ahlale lapho ibhoduluko lakhe linepilo khona begodu akghone ukuthi ayiswe emtholapilo lokha nakanganapilo kuhle emzimbeni.

* Ilungelo lokufunda- Umntwana kufuze athole ifundo yasimahla ezomlekela bonyana akghone ukuthi athuthukise nofana akhulise amakghono nelwazi lakhe.&lt;ref&gt;Marishane, R.N., 2017. The right to basic education for all in South Africa: Implications for school principals. ''Koers'', ''82''(3), pp.1-8.&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>4yl19p4dwykpzo6qje1syfoazauu5ub</sha1>
    </revision>
    <revision>
      <id>3572</id>
      <parentid>3493</parentid>
      <timestamp>2025-08-06T16:05:39Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>3572</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5157" sha1="dlmfa2cuv5izldd6snmrpbzne9tk9pj" xml:space="preserve">'''Umntwana''' kungomunye nomunye umuntu oneminyaka engaphasi kwe-18.&lt;ref&gt;Lansdown, G. and Vaghri, Z., 2022, January. Article 1: Definition of a child. In ''Monitoring state compliance with the UN Convention on the Rights of the Child: An analysis of attributes'' (pp. 407-412). Cham, Switzerland: Springer International Publishing.&lt;/ref&gt; Omunye nomunye Umntwana enarheni yeSewula AFrika unamalungelo amvikelako bona aphile begodu akhule kuhle. Amalungelo wabantwana asiqhema esikhethekileko  s[[amalungelo wabantu|amalungelo wobuntu]]. Amalungelo la atlolwe phasi ku -''UN Convention'' emalungelweni wabantwana, yona ephasiswa yinarha ezibumbeko ngonyaka we-1989. Amalungelo la enzinze ekuvikelweni nehlala kuhle yabantwana. Amalungelo wabantwana asekwelwe ma prinsiphuli amane ekukungabandlululi, ukuhlonitjhwa kwemibono yomntwana, ukukhula nokusinda nalokho ukuhlala kuhle komntwana.

=== Amaphrinsipuli amane wokwenziwa kwamalungelo wabantwana. ===

==== Ukungabandlululwa ====
[[Isimumathi:Amalungelo wabentwana.jpg|thumb|Abentwana abasekulisa basiwe emapholiseni ukugidinga ilanga lamalungelo. ]]
Woke Umntwana ohlala enarheni yeSewula afrika kufuze aphathwe ngokulingana anabanye abantwana begodu nangokuhlonitjwa, ngaphandle kobana kuqalwe bonyana unjani ngokombala, ubulili, ikolo nofana okhunye. Urhulumende kufanele aqinisekise bonyana woke Umntwana uphathwa ngokulingana nabanye begodu uthola amathuba afanako newabanye. Akukafaneli bonyana Umntwana abandlululwe ngendlela zoke lapho aphila khona. Kufanele umntwana aziizwe amukelekile bogodu athandwa ukuze akghone ukukhula ngendlela engeze yamlimaza ingqondo.

==== Ukuhlonitjhwa kwemibono yomntwana ====
Abantwana banelungelo lokuthi bakghone ukuveza imibono yabo begodu ingathethelwa phasi lokha nabayivezileko, begodu bazibandakanye eenquntweni ezithathwako eziphathelene namaphilo wabo. Imibono yabantwana kufanele bona ithathelwe phezulu njengeyabantu abakhululileko.&lt;ref&gt;Garcia-Quiroga, M. and Agoglia, I.S., 2020. Too vulnerable to participate? Challenges for meaningful participation in research with children in alternative care and adoption. ''International journal of qualitative methods'', ''19'', p.1609406920958965.&lt;/ref&gt; Imibono yabantwana kufanele ithathwe ngokuya kweminyaka yabo, ukukhula kwengcondo zaba kuqinisekiswe bonyana bayazwakala begodu iyahlonipheka umbono wabo.&lt;ref&gt;Nthontho, M., 2017. Children as stakeholders in education: Does their voice matter?. ''South African Journal of Childhood Education'', ''7''(1), pp.1-7.&lt;/ref&gt;Ukulalela imibono yabentwana kwenza bonyana umntwana ahlale kuhle ngombana kutjho bona angekhe umntwana enziswe izinto angazithandiko nangazifuniko ngokukatelelelwa.

==== Ukukhula nokusinda ====
Umntwana ukuze akhule kuhle kufuze bona kufanel azizwe avikelekile ebhodulukweni aphila kiyo, asinde begodu akhulu kuhle emzimbeni, emkhumbulweni Kanye nemmoyeni. Akukafaneli bonyana Umntwana ahlukumezeke emphakathini ahlala kiwo khona azokutjhuphuluka akhule ngendlela ekungiyo.&lt;ref&gt;Cross, D., 2017. What our children need: A bill of rights. ''Unpublished manuscript''.&lt;/ref&gt; Kufanele Umntwana ahlalele anepilo emzimbeni athole zoke izinto azitlhogako ukuze ahlale anepilo. Izinto ezifana nokudla kuhle, ayiswe emtholapilo ayokuhlaba ukuthi angangenwa amagulo, begodu ahlale atlhonyelwa babelethi nofana labo abadala asele nabo.

==== Ukuhlala kuhle komntwana ====
Lokho kutjho bona Umntwana kufuze bona abekwe phambili begodu nalokha abantu abadala nabathatha iinqunto kufuze  bathome baqabangele abantwana bonyana lokho kuzobaphatha  bunjani emzimbeni, emkhumbulweni Kanye nemmoyeni. Urhulumende nabatlhogomeli kufuze bona benze koke ekusemandleni wabo ukuqinisekisa bona Umntwana uhleli kuhle.&lt;ref&gt;Hsiao, C., Fry, D., Ward, C.L., Ganz, G., Casey, T., Zheng, X. and Fang, X., 2018. Violence against children in South Africa: The cost of inaction to society and the economy. ''BMJ global health'', ''3''(1), p.e000573.&lt;/ref&gt; Umntwana kufanelwe bona avikelwe ngaso soke iskhathi angazitholi lapho azokugcina ahlukunyezwa khona ngokomseme, emmoyeni nofana emzimbeni. Ibhoduluko lalapho umntwana ahlala khona 
kufanele libe nokuthula lingazali ngenturhu. 

=== Amanye wamalungelo wabantwana ===

* Ilungelo lokuphila, lokusinda Kanye nokukhula- Umntwana unelipngelo lokuthi aphile angabulawa begodu asinde ezintweni ezingaba yingozi epilweni yakhe akhule kuhle.

* Ilungelo lokuvikelwa enturhwini nekuhlunkunyezweni-Abantwana bafanele bavikelwe bonyanaa bangazitholi sele bahlukunyenzwa nofana bafakwe enturhiwini bangatlhogonywela ngombana bangazithola balimala.

* Ilungelo lokuthola ipilo- Umntwana kufanele ahlale lapho ibhoduluko lakhe linepilo khona begodu akghone ukuthi ayiswe emtholapilo lokha nakanganapilo kuhle emzimbeni.

* Ilungelo lokufunda- Umntwana kufuze athole ifundo yasimahla ezomlekela bonyana akghone ukuthi athuthukise nofana akhulise amakghono nelwazi lakhe.&lt;ref&gt;Marishane, R.N., 2017. The right to basic education for all in South Africa: Implications for school principals. ''Koers'', ''82''(3), pp.1-8.&lt;/ref&gt;

== Iinkomba ==
[[Category:Amalungelo]]
[[Ctegory:Amalungelo wabantwana]]
[[category: Amalungelo wobuntu]]</text>
      <sha1>dlmfa2cuv5izldd6snmrpbzne9tk9pj</sha1>
    </revision>
    <revision>
      <id>3573</id>
      <parentid>3572</parentid>
      <timestamp>2025-08-06T16:06:32Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>3573</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5158" sha1="c4r2ugcaks1ja9d9ontkzanf6h0u40b" xml:space="preserve">'''Umntwana''' kungomunye nomunye umuntu oneminyaka engaphasi kwe-18.&lt;ref&gt;Lansdown, G. and Vaghri, Z., 2022, January. Article 1: Definition of a child. In ''Monitoring state compliance with the UN Convention on the Rights of the Child: An analysis of attributes'' (pp. 407-412). Cham, Switzerland: Springer International Publishing.&lt;/ref&gt; Omunye nomunye Umntwana enarheni yeSewula AFrika unamalungelo amvikelako bona aphile begodu akhule kuhle. Amalungelo wabantwana asiqhema esikhethekileko  s[[amalungelo wabantu|amalungelo wobuntu]]. Amalungelo la atlolwe phasi ku -''UN Convention'' emalungelweni wabantwana, yona ephasiswa yinarha ezibumbeko ngonyaka we-1989. Amalungelo la enzinze ekuvikelweni nehlala kuhle yabantwana. Amalungelo wabantwana asekwelwe ma prinsiphuli amane ekukungabandlululi, ukuhlonitjhwa kwemibono yomntwana, ukukhula nokusinda nalokho ukuhlala kuhle komntwana.

=== Amaphrinsipuli amane wokwenziwa kwamalungelo wabantwana. ===

==== Ukungabandlululwa ====
[[Isimumathi:Amalungelo wabentwana.jpg|thumb|Abentwana abasekulisa basiwe emapholiseni ukugidinga ilanga lamalungelo. ]]
Woke Umntwana ohlala enarheni yeSewula afrika kufuze aphathwe ngokulingana anabanye abantwana begodu nangokuhlonitjwa, ngaphandle kobana kuqalwe bonyana unjani ngokombala, ubulili, ikolo nofana okhunye. Urhulumende kufanele aqinisekise bonyana woke Umntwana uphathwa ngokulingana nabanye begodu uthola amathuba afanako newabanye. Akukafaneli bonyana Umntwana abandlululwe ngendlela zoke lapho aphila khona. Kufanele umntwana aziizwe amukelekile bogodu athandwa ukuze akghone ukukhula ngendlela engeze yamlimaza ingqondo.

==== Ukuhlonitjhwa kwemibono yomntwana ====
Abantwana banelungelo lokuthi bakghone ukuveza imibono yabo begodu ingathethelwa phasi lokha nabayivezileko, begodu bazibandakanye eenquntweni ezithathwako eziphathelene namaphilo wabo. Imibono yabantwana kufanele bona ithathelwe phezulu njengeyabantu abakhululileko.&lt;ref&gt;Garcia-Quiroga, M. and Agoglia, I.S., 2020. Too vulnerable to participate? Challenges for meaningful participation in research with children in alternative care and adoption. ''International journal of qualitative methods'', ''19'', p.1609406920958965.&lt;/ref&gt; Imibono yabantwana kufanele ithathwe ngokuya kweminyaka yabo, ukukhula kwengcondo zaba kuqinisekiswe bonyana bayazwakala begodu iyahlonipheka umbono wabo.&lt;ref&gt;Nthontho, M., 2017. Children as stakeholders in education: Does their voice matter?. ''South African Journal of Childhood Education'', ''7''(1), pp.1-7.&lt;/ref&gt;Ukulalela imibono yabentwana kwenza bonyana umntwana ahlale kuhle ngombana kutjho bona angekhe umntwana enziswe izinto angazithandiko nangazifuniko ngokukatelelelwa.

==== Ukukhula nokusinda ====
Umntwana ukuze akhule kuhle kufuze bona kufanel azizwe avikelekile ebhodulukweni aphila kiyo, asinde begodu akhulu kuhle emzimbeni, emkhumbulweni Kanye nemmoyeni. Akukafaneli bonyana Umntwana ahlukumezeke emphakathini ahlala kiwo khona azokutjhuphuluka akhule ngendlela ekungiyo.&lt;ref&gt;Cross, D., 2017. What our children need: A bill of rights. ''Unpublished manuscript''.&lt;/ref&gt; Kufanele Umntwana ahlalele anepilo emzimbeni athole zoke izinto azitlhogako ukuze ahlale anepilo. Izinto ezifana nokudla kuhle, ayiswe emtholapilo ayokuhlaba ukuthi angangenwa amagulo, begodu ahlale atlhonyelwa babelethi nofana labo abadala asele nabo.

==== Ukuhlala kuhle komntwana ====
Lokho kutjho bona Umntwana kufuze bona abekwe phambili begodu nalokha abantu abadala nabathatha iinqunto kufuze  bathome baqabangele abantwana bonyana lokho kuzobaphatha  bunjani emzimbeni, emkhumbulweni Kanye nemmoyeni. Urhulumende nabatlhogomeli kufuze bona benze koke ekusemandleni wabo ukuqinisekisa bona Umntwana uhleli kuhle.&lt;ref&gt;Hsiao, C., Fry, D., Ward, C.L., Ganz, G., Casey, T., Zheng, X. and Fang, X., 2018. Violence against children in South Africa: The cost of inaction to society and the economy. ''BMJ global health'', ''3''(1), p.e000573.&lt;/ref&gt; Umntwana kufanelwe bona avikelwe ngaso soke iskhathi angazitholi lapho azokugcina ahlukunyezwa khona ngokomseme, emmoyeni nofana emzimbeni. Ibhoduluko lalapho umntwana ahlala khona 
kufanele libe nokuthula lingazali ngenturhu. 

=== Amanye wamalungelo wabantwana ===

* Ilungelo lokuphila, lokusinda Kanye nokukhula- Umntwana unelipngelo lokuthi aphile angabulawa begodu asinde ezintweni ezingaba yingozi epilweni yakhe akhule kuhle.

* Ilungelo lokuvikelwa enturhwini nekuhlunkunyezweni-Abantwana bafanele bavikelwe bonyanaa bangazitholi sele bahlukunyenzwa nofana bafakwe enturhiwini bangatlhogonywela ngombana bangazithola balimala.

* Ilungelo lokuthola ipilo- Umntwana kufanele ahlale lapho ibhoduluko lakhe linepilo khona begodu akghone ukuthi ayiswe emtholapilo lokha nakanganapilo kuhle emzimbeni.

* Ilungelo lokufunda- Umntwana kufuze athole ifundo yasimahla ezomlekela bonyana akghone ukuthi athuthukise nofana akhulise amakghono nelwazi lakhe.&lt;ref&gt;Marishane, R.N., 2017. The right to basic education for all in South Africa: Implications for school principals. ''Koers'', ''82''(3), pp.1-8.&lt;/ref&gt;

== Iinkomba ==
[[Category:Amalungelo]]
[[Category:Amalungelo wabantwana]]
[[category: Amalungelo wobuntu]]</text>
      <sha1>c4r2ugcaks1ja9d9ontkzanf6h0u40b</sha1>
    </revision>
    <revision>
      <id>6404</id>
      <parentid>3573</parentid>
      <timestamp>2026-04-13T06:50:07Z</timestamp>
      <contributor>
        <username>Kwamikagami</username>
        <id>1412</id>
      </contributor>
      <origin>6404</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5156" sha1="lxwmu85yvcl6yblqvhhbr14704yq6kx" xml:space="preserve">[[Umntwana]] kungomunye nomunye umuntu oneminyaka engaphasi kwe-18.&lt;ref&gt;Lansdown, G. and Vaghri, Z., 2022, January. Article 1: Definition of a child. In ''Monitoring state compliance with the UN Convention on the Rights of the Child: An analysis of attributes'' (pp. 407-412). Cham, Switzerland: Springer International Publishing.&lt;/ref&gt; Omunye nomunye Umntwana enarheni yeSewula AFrika unamalungelo amvikelako bona aphile begodu akhule kuhle. Amalungelo wabantwana asiqhema esikhethekileko  s[[amalungelo wabantu|amalungelo wobuntu]]. Amalungelo la atlolwe phasi ku -''UN Convention'' emalungelweni wabantwana, yona ephasiswa yinarha ezibumbeko ngonyaka we-1989. Amalungelo la enzinze ekuvikelweni nehlala kuhle yabantwana. Amalungelo wabantwana asekwelwe ma prinsiphuli amane ekukungabandlululi, ukuhlonitjhwa kwemibono yomntwana, ukukhula nokusinda nalokho ukuhlala kuhle komntwana.

=== Amaphrinsipuli amane wokwenziwa kwamalungelo wabantwana. ===

==== Ukungabandlululwa ====
[[Isimumathi:Amalungelo wabentwana.jpg|thumb|Abentwana abasekulisa basiwe emapholiseni ukugidinga ilanga lamalungelo. ]]
Woke Umntwana ohlala enarheni yeSewula afrika kufuze aphathwe ngokulingana anabanye abantwana begodu nangokuhlonitjwa, ngaphandle kobana kuqalwe bonyana unjani ngokombala, ubulili, ikolo nofana okhunye. Urhulumende kufanele aqinisekise bonyana woke Umntwana uphathwa ngokulingana nabanye begodu uthola amathuba afanako newabanye. Akukafaneli bonyana Umntwana abandlululwe ngendlela zoke lapho aphila khona. Kufanele umntwana aziizwe amukelekile bogodu athandwa ukuze akghone ukukhula ngendlela engeze yamlimaza ingqondo.

==== Ukuhlonitjhwa kwemibono yomntwana ====
Abantwana banelungelo lokuthi bakghone ukuveza imibono yabo begodu ingathethelwa phasi lokha nabayivezileko, begodu bazibandakanye eenquntweni ezithathwako eziphathelene namaphilo wabo. Imibono yabantwana kufanele bona ithathelwe phezulu njengeyabantu abakhululileko.&lt;ref&gt;Garcia-Quiroga, M. and Agoglia, I.S., 2020. Too vulnerable to participate? Challenges for meaningful participation in research with children in alternative care and adoption. ''International journal of qualitative methods'', ''19'', p.1609406920958965.&lt;/ref&gt; Imibono yabantwana kufanele ithathwe ngokuya kweminyaka yabo, ukukhula kwengcondo zaba kuqinisekiswe bonyana bayazwakala begodu iyahlonipheka umbono wabo.&lt;ref&gt;Nthontho, M., 2017. Children as stakeholders in education: Does their voice matter?. ''South African Journal of Childhood Education'', ''7''(1), pp.1-7.&lt;/ref&gt;Ukulalela imibono yabentwana kwenza bonyana umntwana ahlale kuhle ngombana kutjho bona angekhe umntwana enziswe izinto angazithandiko nangazifuniko ngokukatelelelwa.

==== Ukukhula nokusinda ====
Umntwana ukuze akhule kuhle kufuze bona kufanel azizwe avikelekile ebhodulukweni aphila kiyo, asinde begodu akhulu kuhle emzimbeni, emkhumbulweni Kanye nemmoyeni. Akukafaneli bonyana Umntwana ahlukumezeke emphakathini ahlala kiwo khona azokutjhuphuluka akhule ngendlela ekungiyo.&lt;ref&gt;Cross, D., 2017. What our children need: A bill of rights. ''Unpublished manuscript''.&lt;/ref&gt; Kufanele Umntwana ahlalele anepilo emzimbeni athole zoke izinto azitlhogako ukuze ahlale anepilo. Izinto ezifana nokudla kuhle, ayiswe emtholapilo ayokuhlaba ukuthi angangenwa amagulo, begodu ahlale atlhonyelwa babelethi nofana labo abadala asele nabo.

==== Ukuhlala kuhle komntwana ====
Lokho kutjho bona Umntwana kufuze bona abekwe phambili begodu nalokha abantu abadala nabathatha iinqunto kufuze  bathome baqabangele abantwana bonyana lokho kuzobaphatha  bunjani emzimbeni, emkhumbulweni Kanye nemmoyeni. Urhulumende nabatlhogomeli kufuze bona benze koke ekusemandleni wabo ukuqinisekisa bona Umntwana uhleli kuhle.&lt;ref&gt;Hsiao, C., Fry, D., Ward, C.L., Ganz, G., Casey, T., Zheng, X. and Fang, X., 2018. Violence against children in South Africa: The cost of inaction to society and the economy. ''BMJ global health'', ''3''(1), p.e000573.&lt;/ref&gt; Umntwana kufanelwe bona avikelwe ngaso soke iskhathi angazitholi lapho azokugcina ahlukunyezwa khona ngokomseme, emmoyeni nofana emzimbeni. Ibhoduluko lalapho umntwana ahlala khona 
kufanele libe nokuthula lingazali ngenturhu. 

=== Amanye wamalungelo wabantwana ===

* Ilungelo lokuphila, lokusinda Kanye nokukhula- Umntwana unelipngelo lokuthi aphile angabulawa begodu asinde ezintweni ezingaba yingozi epilweni yakhe akhule kuhle.

* Ilungelo lokuvikelwa enturhwini nekuhlunkunyezweni-Abantwana bafanele bavikelwe bonyanaa bangazitholi sele bahlukunyenzwa nofana bafakwe enturhiwini bangatlhogonywela ngombana bangazithola balimala.

* Ilungelo lokuthola ipilo- Umntwana kufanele ahlale lapho ibhoduluko lakhe linepilo khona begodu akghone ukuthi ayiswe emtholapilo lokha nakanganapilo kuhle emzimbeni.

* Ilungelo lokufunda- Umntwana kufuze athole ifundo yasimahla ezomlekela bonyana akghone ukuthi athuthukise nofana akhulise amakghono nelwazi lakhe.&lt;ref&gt;Marishane, R.N., 2017. The right to basic education for all in South Africa: Implications for school principals. ''Koers'', ''82''(3), pp.1-8.&lt;/ref&gt;

== Iinkomba ==
[[Category:Amalungelo]]
[[Category:Amalungelo wabantwana]]
[[category: Amalungelo wobuntu]]</text>
      <sha1>lxwmu85yvcl6yblqvhhbr14704yq6kx</sha1>
    </revision>
    <revision>
      <id>6405</id>
      <parentid>6404</parentid>
      <timestamp>2026-04-13T06:50:41Z</timestamp>
      <contributor>
        <username>Kwamikagami</username>
        <id>1412</id>
      </contributor>
      <minor />
      <origin>6405</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5155" sha1="0ym9jf21o87f1tgd1y6bkyig8kib0y8" xml:space="preserve">[[Umntwana]] kungomunye nomunye umuntu oneminyaka engaphasi kwe-18.&lt;ref&gt;Lansdown, G. and Vaghri, Z., 2022, January. Article 1: Definition of a child. In ''Monitoring state compliance with the UN Convention on the Rights of the Child: An analysis of attributes'' (pp. 407-412). Cham, Switzerland: Springer International Publishing.&lt;/ref&gt; Omunye nomunye Umntwana enarheni yeSewula AFrika unamalungelo amvikelako bona aphile begodu akhule kuhle. Amalungelo wabantwana asiqhema esikhethekileko  s[[amalungelo wabantu|amalungelo wobuntu]]. Amalungelo la atlolwe phasi ku-''UN Convention'' emalungelweni wabantwana, yona ephasiswa yinarha ezibumbeko ngonyaka we-1989. Amalungelo la enzinze ekuvikelweni nehlala kuhle yabantwana. Amalungelo wabantwana asekwelwe ma prinsiphuli amane ekukungabandlululi, ukuhlonitjhwa kwemibono yomntwana, ukukhula nokusinda nalokho ukuhlala kuhle komntwana.

=== Amaphrinsipuli amane wokwenziwa kwamalungelo wabantwana. ===

==== Ukungabandlululwa ====
[[Isimumathi:Amalungelo wabentwana.jpg|thumb|Abentwana abasekulisa basiwe emapholiseni ukugidinga ilanga lamalungelo. ]]
Woke Umntwana ohlala enarheni yeSewula afrika kufuze aphathwe ngokulingana anabanye abantwana begodu nangokuhlonitjwa, ngaphandle kobana kuqalwe bonyana unjani ngokombala, ubulili, ikolo nofana okhunye. Urhulumende kufanele aqinisekise bonyana woke Umntwana uphathwa ngokulingana nabanye begodu uthola amathuba afanako newabanye. Akukafaneli bonyana Umntwana abandlululwe ngendlela zoke lapho aphila khona. Kufanele umntwana aziizwe amukelekile bogodu athandwa ukuze akghone ukukhula ngendlela engeze yamlimaza ingqondo.

==== Ukuhlonitjhwa kwemibono yomntwana ====
Abantwana banelungelo lokuthi bakghone ukuveza imibono yabo begodu ingathethelwa phasi lokha nabayivezileko, begodu bazibandakanye eenquntweni ezithathwako eziphathelene namaphilo wabo. Imibono yabantwana kufanele bona ithathelwe phezulu njengeyabantu abakhululileko.&lt;ref&gt;Garcia-Quiroga, M. and Agoglia, I.S., 2020. Too vulnerable to participate? Challenges for meaningful participation in research with children in alternative care and adoption. ''International journal of qualitative methods'', ''19'', p.1609406920958965.&lt;/ref&gt; Imibono yabantwana kufanele ithathwe ngokuya kweminyaka yabo, ukukhula kwengcondo zaba kuqinisekiswe bonyana bayazwakala begodu iyahlonipheka umbono wabo.&lt;ref&gt;Nthontho, M., 2017. Children as stakeholders in education: Does their voice matter?. ''South African Journal of Childhood Education'', ''7''(1), pp.1-7.&lt;/ref&gt;Ukulalela imibono yabentwana kwenza bonyana umntwana ahlale kuhle ngombana kutjho bona angekhe umntwana enziswe izinto angazithandiko nangazifuniko ngokukatelelelwa.

==== Ukukhula nokusinda ====
Umntwana ukuze akhule kuhle kufuze bona kufanel azizwe avikelekile ebhodulukweni aphila kiyo, asinde begodu akhulu kuhle emzimbeni, emkhumbulweni Kanye nemmoyeni. Akukafaneli bonyana Umntwana ahlukumezeke emphakathini ahlala kiwo khona azokutjhuphuluka akhule ngendlela ekungiyo.&lt;ref&gt;Cross, D., 2017. What our children need: A bill of rights. ''Unpublished manuscript''.&lt;/ref&gt; Kufanele Umntwana ahlalele anepilo emzimbeni athole zoke izinto azitlhogako ukuze ahlale anepilo. Izinto ezifana nokudla kuhle, ayiswe emtholapilo ayokuhlaba ukuthi angangenwa amagulo, begodu ahlale atlhonyelwa babelethi nofana labo abadala asele nabo.

==== Ukuhlala kuhle komntwana ====
Lokho kutjho bona Umntwana kufuze bona abekwe phambili begodu nalokha abantu abadala nabathatha iinqunto kufuze  bathome baqabangele abantwana bonyana lokho kuzobaphatha  bunjani emzimbeni, emkhumbulweni Kanye nemmoyeni. Urhulumende nabatlhogomeli kufuze bona benze koke ekusemandleni wabo ukuqinisekisa bona Umntwana uhleli kuhle.&lt;ref&gt;Hsiao, C., Fry, D., Ward, C.L., Ganz, G., Casey, T., Zheng, X. and Fang, X., 2018. Violence against children in South Africa: The cost of inaction to society and the economy. ''BMJ global health'', ''3''(1), p.e000573.&lt;/ref&gt; Umntwana kufanelwe bona avikelwe ngaso soke iskhathi angazitholi lapho azokugcina ahlukunyezwa khona ngokomseme, emmoyeni nofana emzimbeni. Ibhoduluko lalapho umntwana ahlala khona 
kufanele libe nokuthula lingazali ngenturhu. 

=== Amanye wamalungelo wabantwana ===

* Ilungelo lokuphila, lokusinda Kanye nokukhula- Umntwana unelipngelo lokuthi aphile angabulawa begodu asinde ezintweni ezingaba yingozi epilweni yakhe akhule kuhle.

* Ilungelo lokuvikelwa enturhwini nekuhlunkunyezweni-Abantwana bafanele bavikelwe bonyanaa bangazitholi sele bahlukunyenzwa nofana bafakwe enturhiwini bangatlhogonywela ngombana bangazithola balimala.

* Ilungelo lokuthola ipilo- Umntwana kufanele ahlale lapho ibhoduluko lakhe linepilo khona begodu akghone ukuthi ayiswe emtholapilo lokha nakanganapilo kuhle emzimbeni.

* Ilungelo lokufunda- Umntwana kufuze athole ifundo yasimahla ezomlekela bonyana akghone ukuthi athuthukise nofana akhulise amakghono nelwazi lakhe.&lt;ref&gt;Marishane, R.N., 2017. The right to basic education for all in South Africa: Implications for school principals. ''Koers'', ''82''(3), pp.1-8.&lt;/ref&gt;

== Iinkomba ==
[[Category:Amalungelo]]
[[Category:Amalungelo wabantwana]]
[[category: Amalungelo wobuntu]]</text>
      <sha1>0ym9jf21o87f1tgd1y6bkyig8kib0y8</sha1>
    </revision>
    <revision>
      <id>6406</id>
      <parentid>6405</parentid>
      <timestamp>2026-04-13T06:50:58Z</timestamp>
      <contributor>
        <username>Kwamikagami</username>
        <id>1412</id>
      </contributor>
      <comment>/* Amaphrinsipuli amane wokwenziwa kwamalungelo wabantwana. */</comment>
      <origin>6406</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5162" sha1="aoiq338v2d5m5r9kxfa6gg7ounnllww" xml:space="preserve">[[Umntwana]] kungomunye nomunye umuntu oneminyaka engaphasi kwe-18.&lt;ref&gt;Lansdown, G. and Vaghri, Z., 2022, January. Article 1: Definition of a child. In ''Monitoring state compliance with the UN Convention on the Rights of the Child: An analysis of attributes'' (pp. 407-412). Cham, Switzerland: Springer International Publishing.&lt;/ref&gt; Omunye nomunye Umntwana enarheni yeSewula AFrika unamalungelo amvikelako bona aphile begodu akhule kuhle. Amalungelo wabantwana asiqhema esikhethekileko  s[[amalungelo wabantu|amalungelo wobuntu]]. Amalungelo la atlolwe phasi ku-''UN Convention'' emalungelweni wabantwana, yona ephasiswa yinarha ezibumbeko ngonyaka we-1989. Amalungelo la enzinze ekuvikelweni nehlala kuhle yabantwana. Amalungelo wabantwana asekwelwe ma prinsiphuli amane ekukungabandlululi, ukuhlonitjhwa kwemibono yomntwana, ukukhula nokusinda nalokho ukuhlala kuhle komntwana.

=== Amaphrinsipuli amane wokwenziwa kwamalungelo wabantwana. ===

==== Ukungabandlululwa ====
[[Isimumathi:Amalungelo wabentwana.jpg|thumb|upright|Abentwana abasekulisa basiwe emapholiseni ukugidinga ilanga lamalungelo. ]]
Woke Umntwana ohlala enarheni yeSewula afrika kufuze aphathwe ngokulingana anabanye abantwana begodu nangokuhlonitjwa, ngaphandle kobana kuqalwe bonyana unjani ngokombala, ubulili, ikolo nofana okhunye. Urhulumende kufanele aqinisekise bonyana woke Umntwana uphathwa ngokulingana nabanye begodu uthola amathuba afanako newabanye. Akukafaneli bonyana Umntwana abandlululwe ngendlela zoke lapho aphila khona. Kufanele umntwana aziizwe amukelekile bogodu athandwa ukuze akghone ukukhula ngendlela engeze yamlimaza ingqondo.

==== Ukuhlonitjhwa kwemibono yomntwana ====
Abantwana banelungelo lokuthi bakghone ukuveza imibono yabo begodu ingathethelwa phasi lokha nabayivezileko, begodu bazibandakanye eenquntweni ezithathwako eziphathelene namaphilo wabo. Imibono yabantwana kufanele bona ithathelwe phezulu njengeyabantu abakhululileko.&lt;ref&gt;Garcia-Quiroga, M. and Agoglia, I.S., 2020. Too vulnerable to participate? Challenges for meaningful participation in research with children in alternative care and adoption. ''International journal of qualitative methods'', ''19'', p.1609406920958965.&lt;/ref&gt; Imibono yabantwana kufanele ithathwe ngokuya kweminyaka yabo, ukukhula kwengcondo zaba kuqinisekiswe bonyana bayazwakala begodu iyahlonipheka umbono wabo.&lt;ref&gt;Nthontho, M., 2017. Children as stakeholders in education: Does their voice matter?. ''South African Journal of Childhood Education'', ''7''(1), pp.1-7.&lt;/ref&gt;Ukulalela imibono yabentwana kwenza bonyana umntwana ahlale kuhle ngombana kutjho bona angekhe umntwana enziswe izinto angazithandiko nangazifuniko ngokukatelelelwa.

==== Ukukhula nokusinda ====
Umntwana ukuze akhule kuhle kufuze bona kufanel azizwe avikelekile ebhodulukweni aphila kiyo, asinde begodu akhulu kuhle emzimbeni, emkhumbulweni Kanye nemmoyeni. Akukafaneli bonyana Umntwana ahlukumezeke emphakathini ahlala kiwo khona azokutjhuphuluka akhule ngendlela ekungiyo.&lt;ref&gt;Cross, D., 2017. What our children need: A bill of rights. ''Unpublished manuscript''.&lt;/ref&gt; Kufanele Umntwana ahlalele anepilo emzimbeni athole zoke izinto azitlhogako ukuze ahlale anepilo. Izinto ezifana nokudla kuhle, ayiswe emtholapilo ayokuhlaba ukuthi angangenwa amagulo, begodu ahlale atlhonyelwa babelethi nofana labo abadala asele nabo.

==== Ukuhlala kuhle komntwana ====
Lokho kutjho bona Umntwana kufuze bona abekwe phambili begodu nalokha abantu abadala nabathatha iinqunto kufuze  bathome baqabangele abantwana bonyana lokho kuzobaphatha  bunjani emzimbeni, emkhumbulweni Kanye nemmoyeni. Urhulumende nabatlhogomeli kufuze bona benze koke ekusemandleni wabo ukuqinisekisa bona Umntwana uhleli kuhle.&lt;ref&gt;Hsiao, C., Fry, D., Ward, C.L., Ganz, G., Casey, T., Zheng, X. and Fang, X., 2018. Violence against children in South Africa: The cost of inaction to society and the economy. ''BMJ global health'', ''3''(1), p.e000573.&lt;/ref&gt; Umntwana kufanelwe bona avikelwe ngaso soke iskhathi angazitholi lapho azokugcina ahlukunyezwa khona ngokomseme, emmoyeni nofana emzimbeni. Ibhoduluko lalapho umntwana ahlala khona 
kufanele libe nokuthula lingazali ngenturhu.

=== Amanye wamalungelo wabantwana ===

* Ilungelo lokuphila, lokusinda Kanye nokukhula- Umntwana unelipngelo lokuthi aphile angabulawa begodu asinde ezintweni ezingaba yingozi epilweni yakhe akhule kuhle.

* Ilungelo lokuvikelwa enturhwini nekuhlunkunyezweni-Abantwana bafanele bavikelwe bonyanaa bangazitholi sele bahlukunyenzwa nofana bafakwe enturhiwini bangatlhogonywela ngombana bangazithola balimala.

* Ilungelo lokuthola ipilo- Umntwana kufanele ahlale lapho ibhoduluko lakhe linepilo khona begodu akghone ukuthi ayiswe emtholapilo lokha nakanganapilo kuhle emzimbeni.

* Ilungelo lokufunda- Umntwana kufuze athole ifundo yasimahla ezomlekela bonyana akghone ukuthi athuthukise nofana akhulise amakghono nelwazi lakhe.&lt;ref&gt;Marishane, R.N., 2017. The right to basic education for all in South Africa: Implications for school principals. ''Koers'', ''82''(3), pp.1-8.&lt;/ref&gt;

== Iinkomba ==
[[Category:Amalungelo]]
[[Category:Amalungelo wabantwana]]
[[category: Amalungelo wobuntu]]</text>
      <sha1>aoiq338v2d5m5r9kxfa6gg7ounnllww</sha1>
    </revision>
  </page>
  <page>
    <title>INgwenyama UMagodongo</title>
    <ns>0</ns>
    <id>716</id>
    <revision>
      <id>3504</id>
      <timestamp>2025-07-30T13:03:32Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>Published a new article</comment>
      <origin>3504</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7928" sha1="ob0i55b60laroarnqq3vyqyq4mk0pds" xml:space="preserve">'''INgwenyama uMagodongo''' (1811-1827) yingwenyama eyabusa  amaNdebele wakwaNzunza kusukela ngomnyaka wango-1814 ukuya ngo-1827. UMagodongo uyindodana yeNgwenyama uMgwezani. Welama uGembe, godu abe mnakwabo kaMrabheli. Nanyana kunezenzakalo ezinengi ezenzeke ngokubusa kwakhe, uMagodongo waziwa ngokulwa nebutho likaMzilikazi wesitjhaba samaZulu wakwaKhumalo, okukulapho alahlekelwa khona yipwakhe ngo-1827. Namhlanjesi iNgwenyama uMagodongo kaMgwezani yaziwa njengekosi eyatjengisa isibindi ekudoseni phambili isitjhaba samaNdebele wakwaNzunza.&lt;ref name=&quot;:0&quot;&gt;South African History Online. (2011, April 3). ''The Ndebele in history''. South African History Online. Retrieved from:https://sahistory.org.za/article/ndebele-history. Retrieved on 30/07/2025.&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;C.J. Mahlangu, K.N. Mahlangu, M. A. Mahlangu, S. M. Mtshweni, (2011) ''Iziko Lamakhosi''. Shutter &amp; Shooter.&lt;/ref&gt;

== Umlando KaMagodongo Wangaphambi Kobukhosi ==
UMagodongo wabelethwa ngomnyaka ka-1811 kwaSimkhulu, abelethwa nguyise iNgwenyama uMgwezani. Ubelethwa nomnakwabo uGembe oliNghana (1791), nomtanabo uMrabheli oliDlhari (1803). Isikhathi sokubelethwa kwakhe bekusikhathi sokuthula ngombana uMgwezani ekubuseni kwakhe akhenge alwe ipi. Kwathi nakuhlongakala uMgwezani, uGembe ebekunguye obekufuze athathe isihlalo sobukhosi ngokomthetho bekasesemncani ngalesosikhathi. Yeke uDzela umfowabo kayise uMgwezani wabambela uGembe isihlalo sobukhosi.&lt;ref name=&quot;:1&quot; /&gt;

=== Nakubusa uDzela ===
Kwathi bona iNgwenyama uDzela ithwale isiba, yafuduka kwaSimkhulu nesitjhaba sayo yayokwakha eMlotheni kwaMaza hlanu komlambo iSakazana. Kwathi ngelinye ilanga iNgwenyama uDzela yakhamba yayokuhlasela isitjhaba sabaNguni ebesisendaweni yangemaTjhitjhini. Bafika lapho kwalwiwa, amaNdebele ehlulwa abaleka, kanti nababalekako nje uDzela uyokuwela ngemgodini. Amanaba amlandela afika amthola ngemgodini loyo ambulalela khona, umgodi loyo waba lithuna lakhe uDzela. Kodwana ngebanga lokuthi uGembe bekasesemncani ngesikhatheso kwafuze abanjelwe isihlalo. Yeke omunye umfowabo kayise, uMrhabuli kwaba nguye obambela uGembe.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot;&gt;M.H. Schoeman (1998), Excavating Ndzudza Ndebele Identity at KwaMaza, Southern African Field Archaeology. Retrieved from: https://journals.uj.ac.za/pdf/safa/1998_1%20UJ%20FIELD%20Archive/07_42-52%20Schoeman%201998%20Excavating%20Ndzundza%20identity.pdf. Retrieved on 30/07/2025.&lt;/ref&gt;

=== Nakubusa uMrhabuli ===
UMrhabuli (uSirudla) wathwala isiba ngo-1797 wabusa isitjhaba samaNdebele kwaMaza eMlotheni. Ngesikhathi sokubusa kwakhe, uMrhabuli nguye owathumela uMagodongo nomnakwabo uGembe bona bayokuhlasela esinye isitjhaba sabeNguni. UGembe wadosa intangakhe amaNghana phambili, uMagodongo yena warhola amaDlowu, kwatjhingwa ePumalanga. Kwathi bona uGembe abone ibutho labeNguni warhidlwa livalo waze waphathwa namathumbu, kwafuze bona abhace khona angazukubonakala. UMagodongo yena wathatha ibutho likamnakwabo walihlanganisa nelakhe wathathana phezulu namanaba. AbeNguni bahlulwa epini leyo. UMagodongo nebutho lakhe bathumba iinkomo neembuzi zabeNguni wabuya ekhaya.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

Ngebanga lokuthi uGembe abe litjhatjha epini amadoda athi akakafaneli ukuba yikosi, kodwana benyula uMagodongo. Lokho kwenza bona uGembe noMagodongo bangasathelelani amanzi. Amadoda athi nakalemuka lokho, athatha uMagodongo ayomfihla ekhabomkhulu kwaMahlaza.&lt;ref name=&quot;:1&quot; /&gt;

=== Ipi KaMagodongo NoKhunwana ===
Ikosi uMrhabuli njengombana beyilibambela nje ithe nayilemukako bona amadodanayo sele akhulile yafisa ngathana uMagodongo angabuya athathe iintambo. Kodwana amadodanayo ala. Alibeka emtarini bona uyise nakakhothamako indodanakhe ekulu uKhunwana nguye ozokuthatha isihlalo. UMrhabuli wathumela bona kuyokulandwa uMagodongo azokuzwa indaba le. Uthe nakafikako, uMrhabuli wamthatha wamfihla endaweni lapho bekuzokubanjelwa khona umhlangano. Emhlanganweni uMrhabuli wathoma indaba emadodeni, indaba yadenjwa, kwaphikiswana, kwathi nakuphela umhlangano, wakhambisa amadoda, ngemva kwalokho wavumbulula uMagodongo wambuza bona uzwile na. UMagodongo wathi uzwile, watjho nokuthi nakunjalo-ke uzokuthatha ubukhosi ngepi. Bese athathe isitjhaba kwaMahlaza azokwakha kwaMaza.&lt;ref name=&quot;:2&quot; /&gt;

Kwaba nepi phakathi kukaMagodongo noKhunwana. Ipi leyo yalwiwa beyayokufika kwaPondo, yabuya yayokulwelwa ekhaya kwaMaza. UMrhabuli wayetjele uMagodongo bona nakazokuthatha ubukhosi ngepi, kufuze angayibulali indodana yekosi, uMavula, ngombana nguye okufuze ambambele ikapho kanaselako. Kodwana kwathi nakulwiwako nje uMavula nguye okhabe aqeda ibutho likaMagodongo, okwenza bona ekugcineni uMagodongo abulale uMavula. Kwathi bona uMagodongo ahlule ipi, uMrhabuli wambuza bona uphi uMavula. UMagodongo wathi umbulele. UMrhabuli wathi ngombana abulele uMavula angekhe abe yikosi. Bewaqalekisa nangokuthi nangabe uzokubusa &quot;napo ubunyonyo obunzima phezu kwakho.&quot; Kodwana uMagodongo wabulala uMrhabuli nenye yamakhosikazakhe. Ekugcineni uMagodongo wayihlula ipi. UKhunwana nabanye bakwaMrhabuli bafuduka bayokuhlala nabaTswana eBurolong. Ekugcineni uMagodongo wathatha isihlalo ngo-1814, wabusa isitjhaba samaNdebele.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

== Umlando kaMagodongo Nasele Abusa ==
Ekubuseni kwakhe uMagodongo wathatha amakhosikazi. Naka amagamawo:

* UNaMahena onguNoBharhuza
* UNaMabhena oyihlanzi onguNoMtshabi
* UNaMatjhaba onguNoSibogo
* UNaMdluli uNoMagogo onguNoMabhoko
* UNaNtuli onguNoGwalimba &lt;ref name=&quot;:1&quot; /&gt;

Naka amadodana kaMagodongo:

* UBharhuza (liGawu - 1815)
* UMloyi (liDzibha - 1819)
* UMtshabi (liThula - 1823)
* UBengwabo (liDlaza - 1827)
* USomdeyi - 1831
* UMgwayana (liDugu - 1835)
* USibogo - 1831
* UMabhoko (liSinya - 1839)
* UNdaweni (liRhorha - 1847)
* UGwalimba (liPhogo - 1843)&lt;ref name=&quot;:1&quot; /&gt;

== Ipi KaMagodongo NoMzilikazi ==
Ngo-1831 kwafika uMzilikazi kaMashobane wesitjhaba sakwaKhumalo asuka kwelabeNguni eSewula abalekela uShaka. Kwathi bona uMzilikazi afike esigodlweni sikaMagodongo esiKhunjini kwaMaza, wafika wabawa amabutho wokulwa nekosi uShaka. UMagodongo wavuma angakabonisani namadoda. Bavumelana, ngemva kwalokho uMzilikazi wathi usaya kwaManala uyokubawa amanye amabutho. UMagodongo wathi akakhambe uzawathatha nakabuyako. Wakhamba uMzilikazi waya ekosini yaManala uSibindi.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

Uthe nakasakhambileko uMzilikazi, uMagodongo wabiza amadoda bona bazokubonisana ngendaba le. Kwathi nakucociswanako amadoda wala ukunikela uMzilikazi amabutho. Isizathu salokho kukuthi uShaka kubudisi ukumehlula ngombana udlondlobele. Yeke bavumelana ngokuthi bazokukhambisa boke abantu abatjha okufuze babe libutho baye ebuzimbeni bomqedantonga ukwenzela bona uMzilikazi nakafikako abathole bangekho. Nangambala kwaba njalo.&lt;ref name=&quot;:1&quot; /&gt;

UMzilikazi wafika kwaManala wabawa uSibindi, uSibindi naye wavuma. Ngemva kwalokho uMzilikazi wabuyela emva kwaMagodongo bona ayokulanda ibutho athenjiswe lona. Enye indoda yatjela uSibindi namadoda wakwaManala bona uzwe ngamahlebezana bona uMzilikazi ufuna ukuthatha amabutho wabo nakaqeda abaleke nawo. Kodwana uSibindi namadoda wakwaManala khenge bayilalele.&lt;ref name=&quot;:1&quot; /&gt;

UMzilikazi wabuya kwaNzunza wabawa lokho athenjiswe khona, kodwana uMagodongo namadoda wamaNzunza bala baphetha ngokumnikela ibutho. Batjho nokuthi nanyana bangamnikela amabutho angekhe akghone ukulwa noShaka. UMzilikazi waqunta ukuhlasela uMagodongo nesitjhaba. Kuthiwa ibutho lakhe lehla livela entabeni yesiKhunjini, elinye lavela ncazoke ngakaMaza. Kodwana nanyana arogelelekile amaNdebele alwa. Ekugcineni ahluleka. UMzilikazi wathatha uMagodongo nendodanakhe uMloyi, nenduna uMthimunye wababophelela ngamatje entanyeni wabaphosela ngesizibeni. Kwaba kuhlongakala kweNgwenyama uMagodongo. Kwathi bona abantu abatjha sele babuyile balandela iinthunjwa basindisa ezinye zazo. Isitjhaba samaNdebele sasinda ngobunjalo.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>ob0i55b60laroarnqq3vyqyq4mk0pds</sha1>
    </revision>
    <revision>
      <id>3505</id>
      <parentid>3504</parentid>
      <timestamp>2025-07-30T13:06:07Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>inserted a picture</comment>
      <origin>3505</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7993" sha1="t92gm6sjqonbq52y7wiv2bp1n2hzv6n" xml:space="preserve">[[Isimumathi:Ndebele Zimbabwe.jpg|thumb|Abanumzana bamaNdebele]]
'''INgwenyama uMagodongo''' (1811-1827) yingwenyama eyabusa  amaNdebele wakwaNzunza kusukela ngomnyaka wango-1814 ukuya ngo-1827. UMagodongo uyindodana yeNgwenyama uMgwezani. Welama uGembe, godu abe mnakwabo kaMrabheli. Nanyana kunezenzakalo ezinengi ezenzeke ngokubusa kwakhe, uMagodongo waziwa ngokulwa nebutho likaMzilikazi wesitjhaba samaZulu wakwaKhumalo, okukulapho alahlekelwa khona yipwakhe ngo-1827. Namhlanjesi iNgwenyama uMagodongo kaMgwezani yaziwa njengekosi eyatjengisa isibindi ekudoseni phambili isitjhaba samaNdebele wakwaNzunza.&lt;ref name=&quot;:0&quot;&gt;South African History Online. (2011, April 3). ''The Ndebele in history''. South African History Online. Retrieved from:https://sahistory.org.za/article/ndebele-history. Retrieved on 30/07/2025.&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;C.J. Mahlangu, K.N. Mahlangu, M. A. Mahlangu, S. M. Mtshweni, (2011) ''Iziko Lamakhosi''. Shutter &amp; Shooter.&lt;/ref&gt;

== Umlando KaMagodongo Wangaphambi Kobukhosi ==
UMagodongo wabelethwa ngomnyaka ka-1811 kwaSimkhulu, abelethwa nguyise iNgwenyama uMgwezani. Ubelethwa nomnakwabo uGembe oliNghana (1791), nomtanabo uMrabheli oliDlhari (1803). Isikhathi sokubelethwa kwakhe bekusikhathi sokuthula ngombana uMgwezani ekubuseni kwakhe akhenge alwe ipi. Kwathi nakuhlongakala uMgwezani, uGembe ebekunguye obekufuze athathe isihlalo sobukhosi ngokomthetho bekasesemncani ngalesosikhathi. Yeke uDzela umfowabo kayise uMgwezani wabambela uGembe isihlalo sobukhosi.&lt;ref name=&quot;:1&quot; /&gt;

=== Nakubusa uDzela ===
Kwathi bona iNgwenyama uDzela ithwale isiba, yafuduka kwaSimkhulu nesitjhaba sayo yayokwakha eMlotheni kwaMaza hlanu komlambo iSakazana. Kwathi ngelinye ilanga iNgwenyama uDzela yakhamba yayokuhlasela isitjhaba sabaNguni ebesisendaweni yangemaTjhitjhini. Bafika lapho kwalwiwa, amaNdebele ehlulwa abaleka, kanti nababalekako nje uDzela uyokuwela ngemgodini. Amanaba amlandela afika amthola ngemgodini loyo ambulalela khona, umgodi loyo waba lithuna lakhe uDzela. Kodwana ngebanga lokuthi uGembe bekasesemncani ngesikhatheso kwafuze abanjelwe isihlalo. Yeke omunye umfowabo kayise, uMrhabuli kwaba nguye obambela uGembe.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot;&gt;M.H. Schoeman (1998), Excavating Ndzudza Ndebele Identity at KwaMaza, Southern African Field Archaeology. Retrieved from: https://journals.uj.ac.za/pdf/safa/1998_1%20UJ%20FIELD%20Archive/07_42-52%20Schoeman%201998%20Excavating%20Ndzundza%20identity.pdf. Retrieved on 30/07/2025.&lt;/ref&gt;

=== Nakubusa uMrhabuli ===
UMrhabuli (uSirudla) wathwala isiba ngo-1797 wabusa isitjhaba samaNdebele kwaMaza eMlotheni. Ngesikhathi sokubusa kwakhe, uMrhabuli nguye owathumela uMagodongo nomnakwabo uGembe bona bayokuhlasela esinye isitjhaba sabeNguni. UGembe wadosa intangakhe amaNghana phambili, uMagodongo yena warhola amaDlowu, kwatjhingwa ePumalanga. Kwathi bona uGembe abone ibutho labeNguni warhidlwa livalo waze waphathwa namathumbu, kwafuze bona abhace khona angazukubonakala. UMagodongo yena wathatha ibutho likamnakwabo walihlanganisa nelakhe wathathana phezulu namanaba. AbeNguni bahlulwa epini leyo. UMagodongo nebutho lakhe bathumba iinkomo neembuzi zabeNguni wabuya ekhaya.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

Ngebanga lokuthi uGembe abe litjhatjha epini amadoda athi akakafaneli ukuba yikosi, kodwana benyula uMagodongo. Lokho kwenza bona uGembe noMagodongo bangasathelelani amanzi. Amadoda athi nakalemuka lokho, athatha uMagodongo ayomfihla ekhabomkhulu kwaMahlaza.&lt;ref name=&quot;:1&quot; /&gt;

=== Ipi KaMagodongo NoKhunwana ===
Ikosi uMrhabuli njengombana beyilibambela nje ithe nayilemukako bona amadodanayo sele akhulile yafisa ngathana uMagodongo angabuya athathe iintambo. Kodwana amadodanayo ala. Alibeka emtarini bona uyise nakakhothamako indodanakhe ekulu uKhunwana nguye ozokuthatha isihlalo. UMrhabuli wathumela bona kuyokulandwa uMagodongo azokuzwa indaba le. Uthe nakafikako, uMrhabuli wamthatha wamfihla endaweni lapho bekuzokubanjelwa khona umhlangano. Emhlanganweni uMrhabuli wathoma indaba emadodeni, indaba yadenjwa, kwaphikiswana, kwathi nakuphela umhlangano, wakhambisa amadoda, ngemva kwalokho wavumbulula uMagodongo wambuza bona uzwile na. UMagodongo wathi uzwile, watjho nokuthi nakunjalo-ke uzokuthatha ubukhosi ngepi. Bese athathe isitjhaba kwaMahlaza azokwakha kwaMaza.&lt;ref name=&quot;:2&quot; /&gt;

Kwaba nepi phakathi kukaMagodongo noKhunwana. Ipi leyo yalwiwa beyayokufika kwaPondo, yabuya yayokulwelwa ekhaya kwaMaza. UMrhabuli wayetjele uMagodongo bona nakazokuthatha ubukhosi ngepi, kufuze angayibulali indodana yekosi, uMavula, ngombana nguye okufuze ambambele ikapho kanaselako. Kodwana kwathi nakulwiwako nje uMavula nguye okhabe aqeda ibutho likaMagodongo, okwenza bona ekugcineni uMagodongo abulale uMavula. Kwathi bona uMagodongo ahlule ipi, uMrhabuli wambuza bona uphi uMavula. UMagodongo wathi umbulele. UMrhabuli wathi ngombana abulele uMavula angekhe abe yikosi. Bewaqalekisa nangokuthi nangabe uzokubusa &quot;napo ubunyonyo obunzima phezu kwakho.&quot; Kodwana uMagodongo wabulala uMrhabuli nenye yamakhosikazakhe. Ekugcineni uMagodongo wayihlula ipi. UKhunwana nabanye bakwaMrhabuli bafuduka bayokuhlala nabaTswana eBurolong. Ekugcineni uMagodongo wathatha isihlalo ngo-1814, wabusa isitjhaba samaNdebele.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

== Umlando kaMagodongo Nasele Abusa ==
Ekubuseni kwakhe uMagodongo wathatha amakhosikazi. Naka amagamawo:

* UNaMahena onguNoBharhuza
* UNaMabhena oyihlanzi onguNoMtshabi
* UNaMatjhaba onguNoSibogo
* UNaMdluli uNoMagogo onguNoMabhoko
* UNaNtuli onguNoGwalimba &lt;ref name=&quot;:1&quot; /&gt;

Naka amadodana kaMagodongo:

* UBharhuza (liGawu - 1815)
* UMloyi (liDzibha - 1819)
* UMtshabi (liThula - 1823)
* UBengwabo (liDlaza - 1827)
* USomdeyi - 1831
* UMgwayana (liDugu - 1835)
* USibogo - 1831
* UMabhoko (liSinya - 1839)
* UNdaweni (liRhorha - 1847)
* UGwalimba (liPhogo - 1843)&lt;ref name=&quot;:1&quot; /&gt;

== Ipi KaMagodongo NoMzilikazi ==
Ngo-1831 kwafika uMzilikazi kaMashobane wesitjhaba sakwaKhumalo asuka kwelabeNguni eSewula abalekela uShaka. Kwathi bona uMzilikazi afike esigodlweni sikaMagodongo esiKhunjini kwaMaza, wafika wabawa amabutho wokulwa nekosi uShaka. UMagodongo wavuma angakabonisani namadoda. Bavumelana, ngemva kwalokho uMzilikazi wathi usaya kwaManala uyokubawa amanye amabutho. UMagodongo wathi akakhambe uzawathatha nakabuyako. Wakhamba uMzilikazi waya ekosini yaManala uSibindi.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

Uthe nakasakhambileko uMzilikazi, uMagodongo wabiza amadoda bona bazokubonisana ngendaba le. Kwathi nakucociswanako amadoda wala ukunikela uMzilikazi amabutho. Isizathu salokho kukuthi uShaka kubudisi ukumehlula ngombana udlondlobele. Yeke bavumelana ngokuthi bazokukhambisa boke abantu abatjha okufuze babe libutho baye ebuzimbeni bomqedantonga ukwenzela bona uMzilikazi nakafikako abathole bangekho. Nangambala kwaba njalo.&lt;ref name=&quot;:1&quot; /&gt;

UMzilikazi wafika kwaManala wabawa uSibindi, uSibindi naye wavuma. Ngemva kwalokho uMzilikazi wabuyela emva kwaMagodongo bona ayokulanda ibutho athenjiswe lona. Enye indoda yatjela uSibindi namadoda wakwaManala bona uzwe ngamahlebezana bona uMzilikazi ufuna ukuthatha amabutho wabo nakaqeda abaleke nawo. Kodwana uSibindi namadoda wakwaManala khenge bayilalele.&lt;ref name=&quot;:1&quot; /&gt;

UMzilikazi wabuya kwaNzunza wabawa lokho athenjiswe khona, kodwana uMagodongo namadoda wamaNzunza bala baphetha ngokumnikela ibutho. Batjho nokuthi nanyana bangamnikela amabutho angekhe akghone ukulwa noShaka. UMzilikazi waqunta ukuhlasela uMagodongo nesitjhaba. Kuthiwa ibutho lakhe lehla livela entabeni yesiKhunjini, elinye lavela ncazoke ngakaMaza. Kodwana nanyana arogelelekile amaNdebele alwa. Ekugcineni ahluleka. UMzilikazi wathatha uMagodongo nendodanakhe uMloyi, nenduna uMthimunye wababophelela ngamatje entanyeni wabaphosela ngesizibeni. Kwaba kuhlongakala kweNgwenyama uMagodongo. Kwathi bona abantu abatjha sele babuyile balandela iinthunjwa basindisa ezinye zazo. Isitjhaba samaNdebele sasinda ngobunjalo.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>t92gm6sjqonbq52y7wiv2bp1n2hzv6n</sha1>
    </revision>
    <revision>
      <id>3506</id>
      <parentid>3505</parentid>
      <timestamp>2025-07-30T13:07:37Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>speliing fix</comment>
      <origin>3506</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8014" sha1="tc94qhossgtfoc24iart75pynm4ojor" xml:space="preserve">[[Isimumathi:Ndebele Zimbabwe.jpg|thumb|Abanumzana bamaNdebele]]
'''INgwenyama uMagodongo''' (1811-1827) yingwenyama eyabusa  amaNdebele wakwaNzunza kusukela ngomnyaka wango-1814 ukuya ngo-1827. UMagodongo uyindodana yeNgwenyama uMgwezani. Welama uGembe, godu abe mnakwabo kaMrabheli. Nanyana kunezenzakalo ezinengi ezenzeke ngokubusa kwakhe, uMagodongo waziwa ngokulwa nebutho likaMzilikazi wesitjhaba samaZulu wakwaKhumalo, okukulapho alahlekelwa khona yipwakhe ngo-1827. Namhlanjesi iNgwenyama uMagodongo kaMgwezani yaziwa njengekosi eyatjengisa isibindi ekudoseni phambili isitjhaba samaNdebele wakwaNzunza.&lt;ref name=&quot;:0&quot;&gt;South African History Online. (2011, April 3). ''The Ndebele in history''. South African History Online. Retrieved from:https://sahistory.org.za/article/ndebele-history. Retrieved on 30/07/2025.&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;C.J. Mahlangu, K.N. Mahlangu, M. A. Mahlangu, S. M. Mtshweni, (2011) ''Iziko Lamakhosi''. Shutter &amp; Shooter.&lt;/ref&gt;

== Umlando KaMagodongo Wangaphambi Kobukhosi ==
UMagodongo wabelethwa ngomnyaka ka-1811 kwaSimkhulu, abelethwa nguyise iNgwenyama uMgwezani. Ubelethwa nomnakwabo uGembe oliNghana (1791), nomtanabo uMrabheli oliDlhari (1803) yena aliDlowu (1799). Isikhathi sokubelethwa kwakhe bekusikhathi sokuthula ngombana uMgwezani ekubuseni kwakhe akhenge alwe ipi. Kwathi nakuhlongakala uMgwezani, uGembe ebekunguye obekufuze athathe isihlalo sobukhosi ngokomthetho bekasesemncani ngalesosikhathi. Yeke uDzela umfowabo kayise uMgwezani wabambela uGembe isihlalo sobukhosi.&lt;ref name=&quot;:1&quot; /&gt;

=== Nakubusa uDzela ===
Kwathi bona iNgwenyama uDzela ithwale isiba, yafuduka kwaSimkhulu nesitjhaba sayo yayokwakha eMlotheni kwaMaza hlanu komlambo iSakazana. Kwathi ngelinye ilanga iNgwenyama uDzela yakhamba yayokuhlasela isitjhaba sabaNguni ebesisendaweni yangemaTjhitjhini. Bafika lapho kwalwiwa, amaNdebele ehlulwa abaleka, kanti nababalekako nje uDzela uyokuwela ngemgodini. Amanaba amlandela afika amthola ngemgodini loyo ambulalela khona, umgodi loyo waba lithuna lakhe uDzela. Kodwana ngebanga lokuthi uGembe bekasesemncani ngesikhatheso kwafuze abanjelwe isihlalo. Yeke omunye umfowabo kayise, uMrhabuli kwaba nguye obambela uGembe.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot;&gt;M.H. Schoeman (1998), Excavating Ndzudza Ndebele Identity at KwaMaza, Southern African Field Archaeology. Retrieved from: https://journals.uj.ac.za/pdf/safa/1998_1%20UJ%20FIELD%20Archive/07_42-52%20Schoeman%201998%20Excavating%20Ndzundza%20identity.pdf. Retrieved on 30/07/2025.&lt;/ref&gt;

=== Nakubusa uMrhabuli ===
UMrhabuli (uSirudla) wathwala isiba ngo-1797 wabusa isitjhaba samaNdebele kwaMaza eMlotheni. Ngesikhathi sokubusa kwakhe, uMrhabuli nguye owathumela uMagodongo nomnakwabo uGembe bona bayokuhlasela esinye isitjhaba sabeNguni. UGembe wadosa intangakhe amaNghana phambili, uMagodongo yena warhola amaDlowu, kwatjhingwa ePumalanga. Kwathi bona uGembe abone ibutho labeNguni warhidlwa livalo waze waphathwa namathumbu, kwafuze bona abhace khona angazukubonakala. UMagodongo yena wathatha ibutho likamnakwabo walihlanganisa nelakhe wathathana phezulu namanaba. AbeNguni bahlulwa epini leyo. UMagodongo nebutho lakhe bathumba iinkomo neembuzi zabeNguni wabuya ekhaya.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

Ngebanga lokuthi uGembe abe litjhatjha epini amadoda athi akakafaneli ukuba yikosi, kodwana benyula uMagodongo. Lokho kwenza bona uGembe noMagodongo bangasathelelani amanzi. Amadoda athi nakalemuka lokho, athatha uMagodongo ayomfihla ekhabomkhulu kwaMahlaza.&lt;ref name=&quot;:1&quot; /&gt;

=== Ipi KaMagodongo NoKhunwana ===
Ikosi uMrhabuli njengombana beyilibambela nje ithe nayilemukako bona amadodanayo sele akhulile yafisa ngathana uMagodongo angabuya athathe iintambo. Kodwana amadodanayo ala. Alibeka emtarini bona uyise nakakhothamako indodanakhe ekulu uKhunwana nguye ozokuthatha isihlalo. UMrhabuli wathumela bona kuyokulandwa uMagodongo azokuzwa indaba le. Uthe nakafikako, uMrhabuli wamthatha wamfihla endaweni lapho bekuzokubanjelwa khona umhlangano. Emhlanganweni uMrhabuli wathoma indaba emadodeni, indaba yadenjwa, kwaphikiswana, kwathi nakuphela umhlangano, wakhambisa amadoda, ngemva kwalokho wavumbulula uMagodongo wambuza bona uzwile na. UMagodongo wathi uzwile, watjho nokuthi nakunjalo-ke uzokuthatha ubukhosi ngepi. Bese athathe isitjhaba kwaMahlaza azokwakha kwaMaza.&lt;ref name=&quot;:2&quot; /&gt;

Kwaba nepi phakathi kukaMagodongo noKhunwana. Ipi leyo yalwiwa beyayokufika kwaPondo, yabuya yayokulwelwa ekhaya kwaMaza. UMrhabuli wayetjele uMagodongo bona nakazokuthatha ubukhosi ngepi, kufuze angayibulali indodana yekosi, uMavula, ngombana nguye okufuze ambambele ikapho kanaselako. Kodwana kwathi nakulwiwako nje uMavula nguye okhabe aqeda ibutho likaMagodongo, okwenza bona ekugcineni uMagodongo abulale uMavula. Kwathi bona uMagodongo ahlule ipi, uMrhabuli wambuza bona uphi uMavula. UMagodongo wathi umbulele. UMrhabuli wathi ngombana abulele uMavula angekhe abe yikosi. Bewaqalekisa nangokuthi nangabe uzokubusa &quot;napo ubunyonyo obunzima phezu kwakho.&quot; Kodwana uMagodongo wabulala uMrhabuli nenye yamakhosikazakhe. Ekugcineni uMagodongo wayihlula ipi. UKhunwana nabanye bakwaMrhabuli bafuduka bayokuhlala nabaTswana eBurolong. Ekugcineni uMagodongo wathatha isihlalo ngo-1814, wabusa isitjhaba samaNdebele.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

== Umlando kaMagodongo Nasele Abusa ==
Ekubuseni kwakhe uMagodongo wathatha amakhosikazi. Naka amagamawo:

* UNaMahena onguNoBharhuza
* UNaMabhena oyihlanzi onguNoMtshabi
* UNaMatjhaba onguNoSibogo
* UNaMdluli uNoMagogo onguNoMabhoko
* UNaNtuli onguNoGwalimba &lt;ref name=&quot;:1&quot; /&gt;

Naka amadodana kaMagodongo:

* UBharhuza (liGawu - 1815)
* UMloyi (liDzibha - 1819)
* UMtshabi (liThula - 1823)
* UBengwabo (liDlaza - 1827)
* USomdeyi - 1831
* UMgwayana (liDugu - 1835)
* USibogo - 1831
* UMabhoko (liSinya - 1839)
* UNdaweni (liRhorha - 1847)
* UGwalimba (liPhogo - 1843)&lt;ref name=&quot;:1&quot; /&gt;

== Ipi KaMagodongo NoMzilikazi ==
Ngo-1831 kwafika uMzilikazi kaMashobane wesitjhaba sakwaKhumalo asuka kwelabeNguni eSewula abalekela uShaka. Kwathi bona uMzilikazi afike esigodlweni sikaMagodongo esiKhunjini kwaMaza, wafika wabawa amabutho wokulwa nekosi uShaka. UMagodongo wavuma angakabonisani namadoda. Bavumelana, ngemva kwalokho uMzilikazi wathi usaya kwaManala uyokubawa amanye amabutho. UMagodongo wathi akakhambe uzawathatha nakabuyako. Wakhamba uMzilikazi waya ekosini yaManala uSibindi.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

Uthe nakasakhambileko uMzilikazi, uMagodongo wabiza amadoda bona bazokubonisana ngendaba le. Kwathi nakucociswanako amadoda wala ukunikela uMzilikazi amabutho. Isizathu salokho kukuthi uShaka kubudisi ukumehlula ngombana udlondlobele. Yeke bavumelana ngokuthi bazokukhambisa boke abantu abatjha okufuze babe libutho baye ebuzimbeni bomqedantonga ukwenzela bona uMzilikazi nakafikako abathole bangekho. Nangambala kwaba njalo.&lt;ref name=&quot;:1&quot; /&gt;

UMzilikazi wafika kwaManala wabawa uSibindi, uSibindi naye wavuma. Ngemva kwalokho uMzilikazi wabuyela emva kwaMagodongo bona ayokulanda ibutho athenjiswe lona. Enye indoda yatjela uSibindi namadoda wakwaManala bona uzwe ngamahlebezana bona uMzilikazi ufuna ukuthatha amabutho wabo nakaqeda abaleke nawo. Kodwana uSibindi namadoda wakwaManala khenge bayilalele.&lt;ref name=&quot;:1&quot; /&gt;

UMzilikazi wabuya kwaNzunza wabawa lokho athenjiswe khona, kodwana uMagodongo namadoda wamaNzunza bala baphetha ngokumnikela ibutho. Batjho nokuthi nanyana bangamnikela amabutho angekhe akghone ukulwa noShaka. UMzilikazi waqunta ukuhlasela uMagodongo nesitjhaba. Kuthiwa ibutho lakhe lehla livela entabeni yesiKhunjini, elinye lavela ncazoke ngakaMaza. Kodwana nanyana arogelelekile amaNdebele alwa. Ekugcineni ahluleka. UMzilikazi wathatha uMagodongo nendodanakhe uMloyi, nenduna uMthimunye wababophelela ngamatje entanyeni wabaphosela ngesizibeni. Kwaba kuhlongakala kweNgwenyama uMagodongo. Kwathi bona abantu abatjha sele babuyile balandela iinthunjwa basindisa ezinye zazo. Isitjhaba samaNdebele sasinda ngobunjalo.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>tc94qhossgtfoc24iart75pynm4ojor</sha1>
    </revision>
    <revision>
      <id>3507</id>
      <parentid>3506</parentid>
      <timestamp>2025-07-30T13:13:07Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>3507</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8003" sha1="suduoc657ivzx90c04e360jg23nxd90" xml:space="preserve">[[Isimumathi:Ndebele Zimbabwe.jpg|thumb|Abanumzana bamaNdebele]]
'''INgwenyama uMagodongo''' (1811-1827) yingwenyama eyabusa  amaNdebele wakwaNzunza kusukela ngomnyaka wango-1814 ukuya ngo-1827. UMagodongo uyindodana yeNgwenyama uMgwezani. Welama uGembe, godu abe mnakwabo kaMrabheli. Nanyana kunezenzakalo ezinengi ezenzeke ngokubusa kwakhe, uMagodongo waziwa ngokulwa nebutho likaMzilikazi wesitjhaba samaZulu wakwaKhumalo, okukulapho alahlekelwa khona yipwakhe ngo-1827. Namhlanjesi iNgwenyama uMagodongo kaMgwezani yaziwa njengekosi eyatjengisa isibindi ekudoseni phambili isitjhaba samaNdebele wakwaNzunza.&lt;ref name=&quot;:0&quot;&gt;South African History Online. (2011, April 3). ''The Ndebele in history''. South African History Online. Retrieved from:https://sahistory.org.za/article/ndebele-history. Retrieved on 30/07/2025.&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;C.J. Mahlangu, K.N. Mahlangu, M. A. Mahlangu, S. M. Mtshweni, (2011) ''Iziko Lamakhosi''. Shutter &amp; Shooter.&lt;/ref&gt;

== Umlando KaMagodongo Angakabusi ==
UMagodongo wabelethwa ngomnyaka ka-1811 kwaSimkhulu, abelethwa nguyise iNgwenyama uMgwezani. Ubelethwa nomnakwabo uGembe oliNghana (1791), nomtanabo uMrabheli oliDlhari (1803) yena aliDlowu (1799). Isikhathi sokubelethwa kwakhe bekusikhathi sokuthula ngombana uMgwezani ekubuseni kwakhe akhenge alwe ipi. Kwathi nakuhlongakala uMgwezani, uGembe ebekunguye obekufuze athathe isihlalo sobukhosi ngokomthetho bekasesemncani ngalesosikhathi. Yeke uDzela umfowabo kayise uMgwezani wabambela uGembe isihlalo sobukhosi.&lt;ref name=&quot;:1&quot; /&gt;

=== Nakubusa uDzela ===
Kwathi bona iNgwenyama uDzela ithwale isiba, yafuduka kwaSimkhulu nesitjhaba sayo yayokwakha eMlotheni kwaMaza hlanu komlambo iSakazana. Kwathi ngelinye ilanga iNgwenyama uDzela yakhamba yayokuhlasela isitjhaba sabaNguni ebesisendaweni yangemaTjhitjhini. Bafika lapho kwalwiwa, amaNdebele ehlulwa abaleka, kanti nababalekako nje uDzela uyokuwela ngemgodini. Amanaba amlandela afika amthola ngemgodini loyo ambulalela khona, umgodi loyo waba lithuna lakhe uDzela. Kodwana ngebanga lokuthi uGembe bekasesemncani ngesikhatheso kwafuze abanjelwe isihlalo. Yeke omunye umfowabo kayise, uMrhabuli kwaba nguye obambela uGembe.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot;&gt;M.H. Schoeman (1998), Excavating Ndzudza Ndebele Identity at KwaMaza, Southern African Field Archaeology. Retrieved from: https://journals.uj.ac.za/pdf/safa/1998_1%20UJ%20FIELD%20Archive/07_42-52%20Schoeman%201998%20Excavating%20Ndzundza%20identity.pdf. Retrieved on 30/07/2025.&lt;/ref&gt;

=== Nakubusa uMrhabuli ===
UMrhabuli (uSirudla) wathwala isiba ngo-1797 wabusa isitjhaba samaNdebele kwaMaza eMlotheni. Ngesikhathi sokubusa kwakhe, uMrhabuli nguye owathumela uMagodongo nomnakwabo uGembe bona bayokuhlasela esinye isitjhaba sabeNguni. UGembe wadosa intangakhe amaNghana phambili, uMagodongo yena warhola amaDlowu, kwatjhingwa ePumalanga. Kwathi bona uGembe abone ibutho labeNguni warhidlwa livalo waze waphathwa namathumbu, kwafuze bona abhace khona angazukubonakala. UMagodongo yena wathatha ibutho likamnakwabo walihlanganisa nelakhe wathathana phezulu namanaba. AbeNguni bahlulwa epini leyo. UMagodongo nebutho lakhe bathumba iinkomo neembuzi zabeNguni wabuya ekhaya.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

Ngebanga lokuthi uGembe abe litjhatjha epini amadoda athi akakafaneli ukuba yikosi, kodwana benyula uMagodongo. Lokho kwenza bona uGembe noMagodongo bangasathelelani amanzi. Amadoda athi nakalemuka lokho, athatha uMagodongo ayomfihla ekhabomkhulu kwaMahlaza.&lt;ref name=&quot;:1&quot; /&gt;

=== Ipi KaMagodongo NoKhunwana ===
Ikosi uMrhabuli njengombana beyilibambela nje ithe nayilemukako bona amadodanayo sele akhulile yafisa ngathana uMagodongo angabuya athathe iintambo. Kodwana amadodanayo ala. Alibeka emtarini bona uyise nakakhothamako indodanakhe ekulu uKhunwana nguye ozokuthatha isihlalo. UMrhabuli wathumela bona kuyokulandwa uMagodongo azokuzwa indaba le. Uthe nakafikako, uMrhabuli wamthatha wamfihla endaweni lapho bekuzokubanjelwa khona umhlangano. Emhlanganweni uMrhabuli wathoma indaba emadodeni, indaba yadenjwa, kwaphikiswana, kwathi nakuphela umhlangano, wakhambisa amadoda, ngemva kwalokho wavumbulula uMagodongo wambuza bona uzwile na. UMagodongo wathi uzwile, watjho nokuthi nakunjalo-ke uzokuthatha ubukhosi ngepi. Bese athathe isitjhaba kwaMahlaza azokwakha kwaMaza.&lt;ref name=&quot;:2&quot; /&gt;

Kwaba nepi phakathi kukaMagodongo noKhunwana. Ipi leyo yalwiwa beyayokufika kwaPondo, yabuya yayokulwelwa ekhaya kwaMaza. UMrhabuli wayetjele uMagodongo bona nakazokuthatha ubukhosi ngepi, kufuze angayibulali indodana yekosi, uMavula, ngombana nguye okufuze ambambele ikapho kanaselako. Kodwana kwathi nakulwiwako nje uMavula nguye okhabe aqeda ibutho likaMagodongo, okwenza bona ekugcineni uMagodongo abulale uMavula. Kwathi bona uMagodongo ahlule ipi, uMrhabuli wambuza bona uphi uMavula. UMagodongo wathi umbulele. UMrhabuli wathi ngombana abulele uMavula angekhe abe yikosi. Bewaqalekisa nangokuthi nangabe uzokubusa &quot;napo ubunyonyo obunzima phezu kwakho.&quot; Kodwana uMagodongo wabulala uMrhabuli nenye yamakhosikazakhe. Ekugcineni uMagodongo wayihlula ipi. UKhunwana nabanye bakwaMrhabuli bafuduka bayokuhlala nabaTswana eBurolong. Ekugcineni uMagodongo wathatha isihlalo ngo-1814, wabusa isitjhaba samaNdebele.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

== Umlando kaMagodongo Nasele Abusa ==
Ekubuseni kwakhe uMagodongo wathatha amakhosikazi. Naka amagamawo:

* UNaMahena onguNoBharhuza
* UNaMabhena oyihlanzi onguNoMtshabi
* UNaMatjhaba onguNoSibogo
* UNaMdluli uNoMagogo onguNoMabhoko
* UNaNtuli onguNoGwalimba &lt;ref name=&quot;:1&quot; /&gt;

Naka amadodana kaMagodongo:

* UBharhuza (liGawu - 1815)
* UMloyi (liDzibha - 1819)
* UMtshabi (liThula - 1823)
* UBengwabo (liDlaza - 1827)
* USomdeyi - 1831
* UMgwayana (liDugu - 1835)
* USibogo - 1831
* UMabhoko (liSinya - 1839)
* UNdaweni (liRhorha - 1847)
* UGwalimba (liPhogo - 1843)&lt;ref name=&quot;:1&quot; /&gt;

== Ipi KaMagodongo NoMzilikazi ==
Ngo-1831 kwafika uMzilikazi kaMashobane wesitjhaba sakwaKhumalo asuka kwelabeNguni eSewula abalekela uShaka. Kwathi bona uMzilikazi afike esigodlweni sikaMagodongo esiKhunjini kwaMaza, wafika wabawa amabutho wokulwa nekosi uShaka. UMagodongo wavuma angakabonisani namadoda. Bavumelana, ngemva kwalokho uMzilikazi wathi usaya kwaManala uyokubawa amanye amabutho. UMagodongo wathi akakhambe uzawathatha nakabuyako. Wakhamba uMzilikazi waya ekosini yaManala uSibindi.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

Uthe nakasakhambileko uMzilikazi, uMagodongo wabiza amadoda bona bazokubonisana ngendaba le. Kwathi nakucociswanako amadoda wala ukunikela uMzilikazi amabutho. Isizathu salokho kukuthi uShaka kubudisi ukumehlula ngombana udlondlobele. Yeke bavumelana ngokuthi bazokukhambisa boke abantu abatjha okufuze babe libutho baye ebuzimbeni bomqedantonga ukwenzela bona uMzilikazi nakafikako abathole bangekho. Nangambala kwaba njalo.&lt;ref name=&quot;:1&quot; /&gt;

UMzilikazi wafika kwaManala wabawa uSibindi, uSibindi naye wavuma. Ngemva kwalokho uMzilikazi wabuyela emva kwaMagodongo bona ayokulanda ibutho athenjiswe lona. Enye indoda yatjela uSibindi namadoda wakwaManala bona uzwe ngamahlebezana bona uMzilikazi ufuna ukuthatha amabutho wabo nakaqeda abaleke nawo. Kodwana uSibindi namadoda wakwaManala khenge bayilalele.&lt;ref name=&quot;:1&quot; /&gt;

UMzilikazi wabuya kwaNzunza wabawa lokho athenjiswe khona, kodwana uMagodongo namadoda wamaNzunza bala baphetha ngokumnikela ibutho. Batjho nokuthi nanyana bangamnikela amabutho angekhe akghone ukulwa noShaka. UMzilikazi waqunta ukuhlasela uMagodongo nesitjhaba. Kuthiwa ibutho lakhe lehla livela entabeni yesiKhunjini, elinye lavela ncazoke ngakaMaza. Kodwana nanyana arogelelekile amaNdebele alwa. Ekugcineni ahluleka. UMzilikazi wathatha uMagodongo nendodanakhe uMloyi, nenduna uMthimunye wababophelela ngamatje entanyeni wabaphosela ngesizibeni. Kwaba kuhlongakala kweNgwenyama uMagodongo. Kwathi bona abantu abatjha sele babuyile balandela iinthunjwa basindisa ezinye zazo. Isitjhaba samaNdebele sasinda ngobunjalo.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>suduoc657ivzx90c04e360jg23nxd90</sha1>
    </revision>
    <revision>
      <id>3508</id>
      <parentid>3507</parentid>
      <timestamp>2025-07-30T13:15:32Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>link put</comment>
      <origin>3508</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8007" sha1="h2qw7huvqvyzu4owdsts7amo246u3bf" xml:space="preserve">[[Isimumathi:Ndebele Zimbabwe.jpg|thumb|Abanumzana bamaNdebele]]
'''INgwenyama uMagodongo''' (1811-1827) yingwenyama eyabusa  [[amaNdebele]] wakwaNzunza kusukela ngomnyaka wango-1814 ukuya ngo-1827. UMagodongo uyindodana yeNgwenyama uMgwezani. Welama uGembe, godu abe mnakwabo kaMrabheli. Nanyana kunezenzakalo ezinengi ezenzeke ngokubusa kwakhe, uMagodongo waziwa ngokulwa nebutho likaMzilikazi wesitjhaba samaZulu wakwaKhumalo, okukulapho alahlekelwa khona yipwakhe ngo-1827. Namhlanjesi iNgwenyama uMagodongo kaMgwezani yaziwa njengekosi eyatjengisa isibindi ekudoseni phambili isitjhaba samaNdebele wakwaNzunza.&lt;ref name=&quot;:0&quot;&gt;South African History Online. (2011, April 3). ''The Ndebele in history''. South African History Online. Retrieved from:https://sahistory.org.za/article/ndebele-history. Retrieved on 30/07/2025.&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;C.J. Mahlangu, K.N. Mahlangu, M. A. Mahlangu, S. M. Mtshweni, (2011) ''Iziko Lamakhosi''. Shutter &amp; Shooter.&lt;/ref&gt;

== Umlando KaMagodongo Angakabusi ==
UMagodongo wabelethwa ngomnyaka ka-1811 kwaSimkhulu, abelethwa nguyise iNgwenyama uMgwezani. Ubelethwa nomnakwabo uGembe oliNghana (1791), nomtanabo uMrabheli oliDlhari (1803) yena aliDlowu (1799). Isikhathi sokubelethwa kwakhe bekusikhathi sokuthula ngombana uMgwezani ekubuseni kwakhe akhenge alwe ipi. Kwathi nakuhlongakala uMgwezani, uGembe ebekunguye obekufuze athathe isihlalo sobukhosi ngokomthetho bekasesemncani ngalesosikhathi. Yeke uDzela umfowabo kayise uMgwezani wabambela uGembe isihlalo sobukhosi.&lt;ref name=&quot;:1&quot; /&gt;

=== Nakubusa uDzela ===
Kwathi bona iNgwenyama uDzela ithwale isiba, yafuduka kwaSimkhulu nesitjhaba sayo yayokwakha eMlotheni kwaMaza hlanu komlambo iSakazana. Kwathi ngelinye ilanga iNgwenyama uDzela yakhamba yayokuhlasela isitjhaba sabaNguni ebesisendaweni yangemaTjhitjhini. Bafika lapho kwalwiwa, amaNdebele ehlulwa abaleka, kanti nababalekako nje uDzela uyokuwela ngemgodini. Amanaba amlandela afika amthola ngemgodini loyo ambulalela khona, umgodi loyo waba lithuna lakhe uDzela. Kodwana ngebanga lokuthi uGembe bekasesemncani ngesikhatheso kwafuze abanjelwe isihlalo. Yeke omunye umfowabo kayise, uMrhabuli kwaba nguye obambela uGembe.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot;&gt;M.H. Schoeman (1998), Excavating Ndzudza Ndebele Identity at KwaMaza, Southern African Field Archaeology. Retrieved from: https://journals.uj.ac.za/pdf/safa/1998_1%20UJ%20FIELD%20Archive/07_42-52%20Schoeman%201998%20Excavating%20Ndzundza%20identity.pdf. Retrieved on 30/07/2025.&lt;/ref&gt;

=== Nakubusa uMrhabuli ===
UMrhabuli (uSirudla) wathwala isiba ngo-1797 wabusa isitjhaba samaNdebele kwaMaza eMlotheni. Ngesikhathi sokubusa kwakhe, uMrhabuli nguye owathumela uMagodongo nomnakwabo uGembe bona bayokuhlasela esinye isitjhaba sabeNguni. UGembe wadosa intangakhe amaNghana phambili, uMagodongo yena warhola amaDlowu, kwatjhingwa ePumalanga. Kwathi bona uGembe abone ibutho labeNguni warhidlwa livalo waze waphathwa namathumbu, kwafuze bona abhace khona angazukubonakala. UMagodongo yena wathatha ibutho likamnakwabo walihlanganisa nelakhe wathathana phezulu namanaba. AbeNguni bahlulwa epini leyo. UMagodongo nebutho lakhe bathumba iinkomo neembuzi zabeNguni wabuya ekhaya.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

Ngebanga lokuthi uGembe abe litjhatjha epini amadoda athi akakafaneli ukuba yikosi, kodwana benyula uMagodongo. Lokho kwenza bona uGembe noMagodongo bangasathelelani amanzi. Amadoda athi nakalemuka lokho, athatha uMagodongo ayomfihla ekhabomkhulu kwaMahlaza.&lt;ref name=&quot;:1&quot; /&gt;

=== Ipi KaMagodongo NoKhunwana ===
Ikosi uMrhabuli njengombana beyilibambela nje ithe nayilemukako bona amadodanayo sele akhulile yafisa ngathana uMagodongo angabuya athathe iintambo. Kodwana amadodanayo ala. Alibeka emtarini bona uyise nakakhothamako indodanakhe ekulu uKhunwana nguye ozokuthatha isihlalo. UMrhabuli wathumela bona kuyokulandwa uMagodongo azokuzwa indaba le. Uthe nakafikako, uMrhabuli wamthatha wamfihla endaweni lapho bekuzokubanjelwa khona umhlangano. Emhlanganweni uMrhabuli wathoma indaba emadodeni, indaba yadenjwa, kwaphikiswana, kwathi nakuphela umhlangano, wakhambisa amadoda, ngemva kwalokho wavumbulula uMagodongo wambuza bona uzwile na. UMagodongo wathi uzwile, watjho nokuthi nakunjalo-ke uzokuthatha ubukhosi ngepi. Bese athathe isitjhaba kwaMahlaza azokwakha kwaMaza.&lt;ref name=&quot;:2&quot; /&gt;

Kwaba nepi phakathi kukaMagodongo noKhunwana. Ipi leyo yalwiwa beyayokufika kwaPondo, yabuya yayokulwelwa ekhaya kwaMaza. UMrhabuli wayetjele uMagodongo bona nakazokuthatha ubukhosi ngepi, kufuze angayibulali indodana yekosi, uMavula, ngombana nguye okufuze ambambele ikapho kanaselako. Kodwana kwathi nakulwiwako nje uMavula nguye okhabe aqeda ibutho likaMagodongo, okwenza bona ekugcineni uMagodongo abulale uMavula. Kwathi bona uMagodongo ahlule ipi, uMrhabuli wambuza bona uphi uMavula. UMagodongo wathi umbulele. UMrhabuli wathi ngombana abulele uMavula angekhe abe yikosi. Bewaqalekisa nangokuthi nangabe uzokubusa &quot;napo ubunyonyo obunzima phezu kwakho.&quot; Kodwana uMagodongo wabulala uMrhabuli nenye yamakhosikazakhe. Ekugcineni uMagodongo wayihlula ipi. UKhunwana nabanye bakwaMrhabuli bafuduka bayokuhlala nabaTswana eBurolong. Ekugcineni uMagodongo wathatha isihlalo ngo-1814, wabusa isitjhaba samaNdebele.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

== Umlando kaMagodongo Nasele Abusa ==
Ekubuseni kwakhe uMagodongo wathatha amakhosikazi. Naka amagamawo:

* UNaMahena onguNoBharhuza
* UNaMabhena oyihlanzi onguNoMtshabi
* UNaMatjhaba onguNoSibogo
* UNaMdluli uNoMagogo onguNoMabhoko
* UNaNtuli onguNoGwalimba &lt;ref name=&quot;:1&quot; /&gt;

Naka amadodana kaMagodongo:

* UBharhuza (liGawu - 1815)
* UMloyi (liDzibha - 1819)
* UMtshabi (liThula - 1823)
* UBengwabo (liDlaza - 1827)
* USomdeyi - 1831
* UMgwayana (liDugu - 1835)
* USibogo - 1831
* UMabhoko (liSinya - 1839)
* UNdaweni (liRhorha - 1847)
* UGwalimba (liPhogo - 1843)&lt;ref name=&quot;:1&quot; /&gt;

== Ipi KaMagodongo NoMzilikazi ==
Ngo-1831 kwafika uMzilikazi kaMashobane wesitjhaba sakwaKhumalo asuka kwelabeNguni eSewula abalekela uShaka. Kwathi bona uMzilikazi afike esigodlweni sikaMagodongo esiKhunjini kwaMaza, wafika wabawa amabutho wokulwa nekosi uShaka. UMagodongo wavuma angakabonisani namadoda. Bavumelana, ngemva kwalokho uMzilikazi wathi usaya kwaManala uyokubawa amanye amabutho. UMagodongo wathi akakhambe uzawathatha nakabuyako. Wakhamba uMzilikazi waya ekosini yaManala uSibindi.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

Uthe nakasakhambileko uMzilikazi, uMagodongo wabiza amadoda bona bazokubonisana ngendaba le. Kwathi nakucociswanako amadoda wala ukunikela uMzilikazi amabutho. Isizathu salokho kukuthi uShaka kubudisi ukumehlula ngombana udlondlobele. Yeke bavumelana ngokuthi bazokukhambisa boke abantu abatjha okufuze babe libutho baye ebuzimbeni bomqedantonga ukwenzela bona uMzilikazi nakafikako abathole bangekho. Nangambala kwaba njalo.&lt;ref name=&quot;:1&quot; /&gt;

UMzilikazi wafika kwaManala wabawa uSibindi, uSibindi naye wavuma. Ngemva kwalokho uMzilikazi wabuyela emva kwaMagodongo bona ayokulanda ibutho athenjiswe lona. Enye indoda yatjela uSibindi namadoda wakwaManala bona uzwe ngamahlebezana bona uMzilikazi ufuna ukuthatha amabutho wabo nakaqeda abaleke nawo. Kodwana uSibindi namadoda wakwaManala khenge bayilalele.&lt;ref name=&quot;:1&quot; /&gt;

UMzilikazi wabuya kwaNzunza wabawa lokho athenjiswe khona, kodwana uMagodongo namadoda wamaNzunza bala baphetha ngokumnikela ibutho. Batjho nokuthi nanyana bangamnikela amabutho angekhe akghone ukulwa noShaka. UMzilikazi waqunta ukuhlasela uMagodongo nesitjhaba. Kuthiwa ibutho lakhe lehla livela entabeni yesiKhunjini, elinye lavela ncazoke ngakaMaza. Kodwana nanyana arogelelekile amaNdebele alwa. Ekugcineni ahluleka. UMzilikazi wathatha uMagodongo nendodanakhe uMloyi, nenduna uMthimunye wababophelela ngamatje entanyeni wabaphosela ngesizibeni. Kwaba kuhlongakala kweNgwenyama uMagodongo. Kwathi bona abantu abatjha sele babuyile balandela iinthunjwa basindisa ezinye zazo. Isitjhaba samaNdebele sasinda ngobunjalo.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>h2qw7huvqvyzu4owdsts7amo246u3bf</sha1>
    </revision>
    <revision>
      <id>3510</id>
      <parentid>3508</parentid>
      <timestamp>2025-07-30T13:27:20Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>3510</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8007" sha1="n7crcs8pa1b5jh24fpmh2uyddqapir1" xml:space="preserve">[[Isimumathi:Ndebele Zimbabwe.jpg|thumb|Abanumzana bamaNdebele]]
'''INgwenyama uMagodongo''' (1811-1827) yingwenyama eyabusa  [[amaNdebele]] wakwaNzunza kusukela ngomnyaka wango-1814 ukuya ngo-1827. UMagodongo uyindodana yeNgwenyama uMgwezani. Welama uGembe, godu abe mnakwabo kaMrabheli. Nanyana kunezenzakalo ezinengi ezenzeke ngokubusa kwakhe, uMagodongo waziwa ngokulwa nebutho likaMzilikazi wesitjhaba samaZulu wakwaKhumalo, okukulapho alahlekelwa khona yipwakhe ngo-1827. Namhlanjesi iNgwenyama uMagodongo kaMgwezani yaziwa njengekosi eyatjengisa isibindi ekudoseni phambili isitjhaba samaNdebele wakwaNzunza.&lt;ref name=&quot;:0&quot;&gt;South African History Online. (2011, April 3). ''The Ndebele in history''. South African History Online. Retrieved from:https://sahistory.org.za/article/ndebele-history. Retrieved on 30/07/2025.&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;C.J. Mahlangu, K.N. Mahlangu, M. A. Mahlangu, S. M. Mtshweni, (2011) ''Iziko Lamakhosi''. Shutter &amp; Shooter.&lt;/ref&gt;

== Umlando KaMagodongo Angakabusi ==
UMagodongo wabelethwa ngomnyaka ka-1811 kwaSimkhulu, abelethwa nguyise iNgwenyama uMgwezani. Ubelethwa nomnakwabo uGembe oliNghana (1791), nomtanabo uMrabheli oliDlhari (1803) yena aliDlowu (1799). Isikhathi sokubelethwa kwakhe bekusikhathi sokuthula ngombana uMgwezani ekubuseni kwakhe akhenge alwe ipi. Kwathi nakuhlongakala uMgwezani, uGembe ebekunguye obekufuze athathe isihlalo sobukhosi ngokomthetho bekasesemncani ngalesosikhathi. Yeke uDzela umfowabo kayise uMgwezani wabambela uGembe isihlalo sobukhosi.&lt;ref name=&quot;:1&quot; /&gt;

=== Nakubusa UDzela ===
Kwathi bona iNgwenyama uDzela ithwale isiba, yafuduka kwaSimkhulu nesitjhaba sayo yayokwakha eMlotheni kwaMaza hlanu komlambo iSakazana. Kwathi ngelinye ilanga iNgwenyama uDzela yakhamba yayokuhlasela isitjhaba sabaNguni ebesisendaweni yangemaTjhitjhini. Bafika lapho kwalwiwa, amaNdebele ehlulwa abaleka, kanti nababalekako nje uDzela uyokuwela ngemgodini. Amanaba amlandela afika amthola ngemgodini loyo ambulalela khona, umgodi loyo waba lithuna lakhe uDzela. Kodwana ngebanga lokuthi uGembe bekasesemncani ngesikhatheso kwafuze abanjelwe isihlalo. Yeke omunye umfowabo kayise, uMrhabuli kwaba nguye obambela uGembe.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot;&gt;M.H. Schoeman (1998), Excavating Ndzudza Ndebele Identity at KwaMaza, Southern African Field Archaeology. Retrieved from: https://journals.uj.ac.za/pdf/safa/1998_1%20UJ%20FIELD%20Archive/07_42-52%20Schoeman%201998%20Excavating%20Ndzundza%20identity.pdf. Retrieved on 30/07/2025.&lt;/ref&gt;

=== Nakubusa UMrhabuli ===
UMrhabuli (uSirudla) wathwala isiba ngo-1797 wabusa isitjhaba samaNdebele kwaMaza eMlotheni. Ngesikhathi sokubusa kwakhe, uMrhabuli nguye owathumela uMagodongo nomnakwabo uGembe bona bayokuhlasela esinye isitjhaba sabeNguni. UGembe wadosa intangakhe amaNghana phambili, uMagodongo yena warhola amaDlowu, kwatjhingwa ePumalanga. Kwathi bona uGembe abone ibutho labeNguni warhidlwa livalo waze waphathwa namathumbu, kwafuze bona abhace khona angazukubonakala. UMagodongo yena wathatha ibutho likamnakwabo walihlanganisa nelakhe wathathana phezulu namanaba. AbeNguni bahlulwa epini leyo. UMagodongo nebutho lakhe bathumba iinkomo neembuzi zabeNguni wabuya ekhaya.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

Ngebanga lokuthi uGembe abe litjhatjha epini amadoda athi akakafaneli ukuba yikosi, kodwana benyula uMagodongo. Lokho kwenza bona uGembe noMagodongo bangasathelelani amanzi. Amadoda athi nakalemuka lokho, athatha uMagodongo ayomfihla ekhabomkhulu kwaMahlaza.&lt;ref name=&quot;:1&quot; /&gt;

=== Ipi KaMagodongo NoKhunwana ===
Ikosi uMrhabuli njengombana beyilibambela nje ithe nayilemukako bona amadodanayo sele akhulile yafisa ngathana uMagodongo angabuya athathe iintambo. Kodwana amadodanayo ala. Alibeka emtarini bona uyise nakakhothamako indodanakhe ekulu uKhunwana nguye ozokuthatha isihlalo. UMrhabuli wathumela bona kuyokulandwa uMagodongo azokuzwa indaba le. Uthe nakafikako, uMrhabuli wamthatha wamfihla endaweni lapho bekuzokubanjelwa khona umhlangano. Emhlanganweni uMrhabuli wathoma indaba emadodeni, indaba yadenjwa, kwaphikiswana, kwathi nakuphela umhlangano, wakhambisa amadoda, ngemva kwalokho wavumbulula uMagodongo wambuza bona uzwile na. UMagodongo wathi uzwile, watjho nokuthi nakunjalo-ke uzokuthatha ubukhosi ngepi. Bese athathe isitjhaba kwaMahlaza azokwakha kwaMaza.&lt;ref name=&quot;:2&quot; /&gt;

Kwaba nepi phakathi kukaMagodongo noKhunwana. Ipi leyo yalwiwa beyayokufika kwaPondo, yabuya yayokulwelwa ekhaya kwaMaza. UMrhabuli wayetjele uMagodongo bona nakazokuthatha ubukhosi ngepi, kufuze angayibulali indodana yekosi, uMavula, ngombana nguye okufuze ambambele ikapho kanaselako. Kodwana kwathi nakulwiwako nje uMavula nguye okhabe aqeda ibutho likaMagodongo, okwenza bona ekugcineni uMagodongo abulale uMavula. Kwathi bona uMagodongo ahlule ipi, uMrhabuli wambuza bona uphi uMavula. UMagodongo wathi umbulele. UMrhabuli wathi ngombana abulele uMavula angekhe abe yikosi. Bewaqalekisa nangokuthi nangabe uzokubusa &quot;napo ubunyonyo obunzima phezu kwakho.&quot; Kodwana uMagodongo wabulala uMrhabuli nenye yamakhosikazakhe. Ekugcineni uMagodongo wayihlula ipi. UKhunwana nabanye bakwaMrhabuli bafuduka bayokuhlala nabaTswana eBurolong. Ekugcineni uMagodongo wathatha isihlalo ngo-1814, wabusa isitjhaba samaNdebele.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

== Umlando KaMagodongo Nasele Abusa ==
Ekubuseni kwakhe uMagodongo wathatha amakhosikazi. Naka amagamawo:

* UNaMahena onguNoBharhuza
* UNaMabhena oyihlanzi onguNoMtshabi
* UNaMatjhaba onguNoSibogo
* UNaMdluli uNoMagogo onguNoMabhoko
* UNaNtuli onguNoGwalimba &lt;ref name=&quot;:1&quot; /&gt;

Naka amadodana kaMagodongo:

* UBharhuza (liGawu - 1815)
* UMloyi (liDzibha - 1819)
* UMtshabi (liThula - 1823)
* UBengwabo (liDlaza - 1827)
* USomdeyi - 1831
* UMgwayana (liDugu - 1835)
* USibogo - 1831
* UMabhoko (liSinya - 1839)
* UNdaweni (liRhorha - 1847)
* UGwalimba (liPhogo - 1843)&lt;ref name=&quot;:1&quot; /&gt;

== Ipi KaMagodongo NoMzilikazi ==
Ngo-1831 kwafika uMzilikazi kaMashobane wesitjhaba sakwaKhumalo asuka kwelabeNguni eSewula abalekela uShaka. Kwathi bona uMzilikazi afike esigodlweni sikaMagodongo esiKhunjini kwaMaza, wafika wabawa amabutho wokulwa nekosi uShaka. UMagodongo wavuma angakabonisani namadoda. Bavumelana, ngemva kwalokho uMzilikazi wathi usaya kwaManala uyokubawa amanye amabutho. UMagodongo wathi akakhambe uzawathatha nakabuyako. Wakhamba uMzilikazi waya ekosini yaManala uSibindi.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

Uthe nakasakhambileko uMzilikazi, uMagodongo wabiza amadoda bona bazokubonisana ngendaba le. Kwathi nakucociswanako amadoda wala ukunikela uMzilikazi amabutho. Isizathu salokho kukuthi uShaka kubudisi ukumehlula ngombana udlondlobele. Yeke bavumelana ngokuthi bazokukhambisa boke abantu abatjha okufuze babe libutho baye ebuzimbeni bomqedantonga ukwenzela bona uMzilikazi nakafikako abathole bangekho. Nangambala kwaba njalo.&lt;ref name=&quot;:1&quot; /&gt;

UMzilikazi wafika kwaManala wabawa uSibindi, uSibindi naye wavuma. Ngemva kwalokho uMzilikazi wabuyela emva kwaMagodongo bona ayokulanda ibutho athenjiswe lona. Enye indoda yatjela uSibindi namadoda wakwaManala bona uzwe ngamahlebezana bona uMzilikazi ufuna ukuthatha amabutho wabo nakaqeda abaleke nawo. Kodwana uSibindi namadoda wakwaManala khenge bayilalele.&lt;ref name=&quot;:1&quot; /&gt;

UMzilikazi wabuya kwaNzunza wabawa lokho athenjiswe khona, kodwana uMagodongo namadoda wamaNzunza bala baphetha ngokumnikela ibutho. Batjho nokuthi nanyana bangamnikela amabutho angekhe akghone ukulwa noShaka. UMzilikazi waqunta ukuhlasela uMagodongo nesitjhaba. Kuthiwa ibutho lakhe lehla livela entabeni yesiKhunjini, elinye lavela ncazoke ngakaMaza. Kodwana nanyana arogelelekile amaNdebele alwa. Ekugcineni ahluleka. UMzilikazi wathatha uMagodongo nendodanakhe uMloyi, nenduna uMthimunye wababophelela ngamatje entanyeni wabaphosela ngesizibeni. Kwaba kuhlongakala kweNgwenyama uMagodongo. Kwathi bona abantu abatjha sele babuyile balandela iinthunjwa basindisa ezinye zazo. Isitjhaba samaNdebele sasinda ngobunjalo.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>n7crcs8pa1b5jh24fpmh2uyddqapir1</sha1>
    </revision>
    <revision>
      <id>6098</id>
      <parentid>3510</parentid>
      <timestamp>2025-12-22T06:41:33Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>spelling fix</comment>
      <origin>6098</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8009" sha1="lih0eq2tkivncyrypsw6ujpnqewjdng" xml:space="preserve">[[Isimumathi:Ndebele Zimbabwe.jpg|thumb|Abanumzana bamaNdebele]]
'''INgwenyama uMagodongo''' (1811-1827) yingwenyama eyabusa  [[amaNdebele]] wakwaNzunza kusukela ngomnyaka wango-1814 ukuya ngo-1827. UMagodongo uyindodana yeNgwenyama uMgwezani. Welama uGembe, godu abe mnakwabo kaMrabheli. Nanyana kunezenzakalo ezinengi ezenzeke ngokubusa kwakhe, uMagodongo waziwa ngokulwa nebutho likaMzilikazi wesitjhaba samaZulu wakwaKhumalo, okukulapho alahlekelwa khona yipilwakhe ngo-1827. Namhlanjesi iNgwenyama uMagodongo kaMgwezani yaziwa njengekosi eyatjengisa isibindi ekudoseni phambili isitjhaba samaNdebele wakwaNzunza.&lt;ref name=&quot;:0&quot;&gt;South African History Online. (2011, April 3). ''The Ndebele in history''. South African History Online. Retrieved from:https://sahistory.org.za/article/ndebele-history. Retrieved on 30/07/2025.&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;C.J. Mahlangu, K.N. Mahlangu, M. A. Mahlangu, S. M. Mtshweni, (2011) ''Iziko Lamakhosi''. Shutter &amp; Shooter.&lt;/ref&gt;

== Umlando KaMagodongo Angakabusi ==
UMagodongo wabelethwa ngomnyaka ka-1811 kwaSimkhulu, abelethwa nguyise iNgwenyama uMgwezani. Ubelethwa nomnakwabo uGembe oliNghana (1791), nomtanabo uMrabheli oliDlhari (1803) yena aliDlowu (1799). Isikhathi sokubelethwa kwakhe bekusikhathi sokuthula ngombana uMgwezani ekubuseni kwakhe akhenge alwe ipi. Kwathi nakuhlongakala uMgwezani, uGembe ebekunguye obekufuze athathe isihlalo sobukhosi ngokomthetho bekasesemncani ngalesosikhathi. Yeke uDzela umfowabo kayise uMgwezani wabambela uGembe isihlalo sobukhosi.&lt;ref name=&quot;:1&quot; /&gt;

=== Nakubusa UDzela ===
Kwathi bona iNgwenyama uDzela ithwale isiba, yafuduka kwaSimkhulu nesitjhaba sayo yayokwakha eMlotheni kwaMaza hlanu komlambo iSakazana. Kwathi ngelinye ilanga iNgwenyama uDzela yakhamba yayokuhlasela isitjhaba sabaNguni ebesisendaweni yangemaTjhitjhini. Bafika lapho kwalwiwa, amaNdebele ehlulwa abaleka, kanti nababalekako nje uDzela uyokuwela ngemgodini. Amanaba amlandela afika amthola ngemgodini loyo ambulalela khona, umgodi loyo waba lithuna lakhe uDzela. Kodwana ngebanga lokuthi uGembe bekasesemncani ngesikhatheso kwafuze abanjelwe isihlalo. Yeke omunye umfowabo kayise, uMrhabuli kwaba nguye obambela uGembe.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot;&gt;M.H. Schoeman (1998), Excavating Ndzudza Ndebele Identity at KwaMaza, Southern African Field Archaeology. Retrieved from: https://journals.uj.ac.za/pdf/safa/1998_1%20UJ%20FIELD%20Archive/07_42-52%20Schoeman%201998%20Excavating%20Ndzundza%20identity.pdf. Retrieved on 30/07/2025.&lt;/ref&gt;

=== Nakubusa UMrhabuli ===
UMrhabuli (uSirudla) wathwala isiba ngo-1797 wabusa isitjhaba samaNdebele kwaMaza eMlotheni. Ngesikhathi sokubusa kwakhe, uMrhabuli nguye owathumela uMagodongo nomnakwabo uGembe bona bayokuhlasela esinye isitjhaba sabeNguni. UGembe wadosa intangakhe amaNghana phambili, uMagodongo yena warhola amaDlowu, kwatjhingwa ePumalanga. Kwathi bona uGembe abone ibutho labeNguni warhidlwa livalo waze waphathwa namathumbu, kwafuze bona abhace khona angazukubonakala. UMagodongo yena wathatha ibutho likamnakwabo walihlanganisa nelakhe wathathana phezulu namanaba. AbeNguni bahlulwa epini leyo. UMagodongo nebutho lakhe bathumba iinkomo neembuzi zabeNguni wabuya ekhaya.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

Ngebanga lokuthi uGembe abe litjhatjha epini amadoda athi akakafaneli ukuba yikosi, kodwana benyula uMagodongo. Lokho kwenza bona uGembe noMagodongo bangasathelelani amanzi. Amadoda athi nakalemuka lokho, athatha uMagodongo ayomfihla ekhabomkhulu kwaMahlaza.&lt;ref name=&quot;:1&quot; /&gt;

=== Ipi KaMagodongo NoKhunwana ===
Ikosi uMrhabuli njengombana beyilibambela nje ithe nayilemukako bona amadodanayo sele akhulile yafisa ngathana uMagodongo angabuya athathe iintambo. Kodwana amadodanayo ala. Alibeka emtarini bona uyise nakakhothamako indodanakhe ekulu uKhunwana nguye ozokuthatha isihlalo. UMrhabuli wathumela bona kuyokulandwa uMagodongo azokuzwa indaba le. Uthe nakafikako, uMrhabuli wamthatha wamfihla endaweni lapho bekuzokubanjelwa khona umhlangano. Emhlanganweni uMrhabuli wathoma indaba emadodeni, indaba yadenjwa, kwaphikiswana, kwathi nakuphela umhlangano, wakhambisa amadoda, ngemva kwalokho wavumbulula uMagodongo wambuza bona uzwile na. UMagodongo wathi uzwile, watjho nokuthi nakunjalo-ke uzokuthatha ubukhosi ngepi. Bese athathe isitjhaba kwaMahlaza azokwakha kwaMaza.&lt;ref name=&quot;:2&quot; /&gt;

Kwaba nepi phakathi kukaMagodongo noKhunwana. Ipi leyo yalwiwa beyayokufika kwaPondo, yabuya yayokulwelwa ekhaya kwaMaza. UMrhabuli wayetjele uMagodongo bona nakazokuthatha ubukhosi ngepi, kufuze angayibulali indodana yekosi, uMavula, ngombana nguye okufuze ambambele ikapho kanaselako. Kodwana kwathi nakulwiwako nje uMavula nguye okhabe aqeda ibutho likaMagodongo, okwenza bona ekugcineni uMagodongo abulale uMavula. Kwathi bona uMagodongo ahlule ipi, uMrhabuli wambuza bona uphi uMavula. UMagodongo wathi umbulele. UMrhabuli wathi ngombana abulele uMavula angekhe abe yikosi. Bewaqalekisa nangokuthi nangabe uzokubusa &quot;napo ubunyonyo obunzima phezu kwakho.&quot; Kodwana uMagodongo wabulala uMrhabuli nenye yamakhosikazakhe. Ekugcineni uMagodongo wayihlula ipi. UKhunwana nabanye bakwaMrhabuli bafuduka bayokuhlala nabaTswana eBurolong. Ekugcineni uMagodongo wathatha isihlalo ngo-1814, wabusa isitjhaba samaNdebele.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

== Umlando KaMagodongo Nasele Abusa ==
Ekubuseni kwakhe uMagodongo wathatha amakhosikazi. Naka amagamawo:

* UNaMahena onguNoBharhuza
* UNaMabhena oyihlanzi onguNoMtshabi
* UNaMatjhaba onguNoSibogo
* UNaMdluli uNoMagogo onguNoMabhoko
* UNaNtuli onguNoGwalimba &lt;ref name=&quot;:1&quot; /&gt;

Naka amadodana kaMagodongo:

* UBharhuza (liGawu - 1815)
* UMloyi (liDzibha - 1819)
* UMtshabi (liThula - 1823)
* UBengwabo (liDlaza - 1827)
* USomdeyi - 1831
* UMgwayana (liDugu - 1835)
* USibogo - 1831
* UMabhoko (liSinya - 1839)
* UNdaweni (liRhorha - 1847)
* UGwalimba (liPhogo - 1843)&lt;ref name=&quot;:1&quot; /&gt;

== Ipi KaMagodongo NoMzilikazi ==
Ngo-1831 kwafika uMzilikazi kaMashobane wesitjhaba sakwaKhumalo asuka kwelabeNguni eSewula abalekela uShaka. Kwathi bona uMzilikazi afike esigodlweni sikaMagodongo esiKhunjini kwaMaza, wafika wabawa amabutho wokulwa nekosi uShaka. UMagodongo wavuma angakabonisani namadoda. Bavumelana, ngemva kwalokho uMzilikazi wathi usaya kwaManala uyokubawa amanye amabutho. UMagodongo wathi akakhambe uzawathatha nakabuyako. Wakhamba uMzilikazi waya ekosini yaManala uSibindi.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

Uthe nakasakhambileko uMzilikazi, uMagodongo wabiza amadoda bona bazokubonisana ngendaba le. Kwathi nakucociswanako amadoda wala ukunikela uMzilikazi amabutho. Isizathu salokho kukuthi uShaka kubudisi ukumehlula ngombana udlondlobele. Yeke bavumelana ngokuthi bazokukhambisa boke abantu abatjha okufuze babe libutho baye ebuzimbeni bomqedantonga ukwenzela bona uMzilikazi nakafikako abathole bangekho. Nangambala kwaba njalo.&lt;ref name=&quot;:1&quot; /&gt;

UMzilikazi wafika kwaManala wabawa uSibindi, uSibindi naye wavuma. Ngemva kwalokho uMzilikazi wabuyela emva kwaMagodongo bona ayokulanda ibutho athenjiswe lona. Enye indoda yatjela uSibindi namadoda wakwaManala bona uzwe ngamahlebezana bona uMzilikazi ufuna ukuthatha amabutho wabo nakaqeda abaleke nawo. Kodwana uSibindi namadoda wakwaManala khenge bayilalele.&lt;ref name=&quot;:1&quot; /&gt;

UMzilikazi wabuya kwaNzunza wabawa lokho athenjiswe khona, kodwana uMagodongo namadoda wamaNzunza bala baphetha ngokumnikela ibutho. Batjho nokuthi nanyana bangamnikela amabutho angekhe akghone ukulwa noShaka. UMzilikazi waqunta ukuhlasela uMagodongo nesitjhaba. Kuthiwa ibutho lakhe lehla livela entabeni yesiKhunjini, elinye lavela ncazoke ngakaMaza. Kodwana nanyana arogelelekile amaNdebele alwa. Ekugcineni ahluleka. UMzilikazi wathatha uMagodongo nendodanakhe uMloyi, nenduna uMthimunye wababophelela ngamatje entanyeni wabaphosela ngesizibeni. Kwaba kuhlongakala kweNgwenyama uMagodongo. Kwathi bona abantu abatjha sele babuyile balandela iinthunjwa basindisa ezinye zazo. Isitjhaba samaNdebele sasinda ngobunjalo.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>lih0eq2tkivncyrypsw6ujpnqewjdng</sha1>
    </revision>
    <revision>
      <id>6099</id>
      <parentid>6098</parentid>
      <timestamp>2025-12-22T06:49:42Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <minor />
      <comment>/* Ipi KaMagodongo NoKhunwana */ spelling fix</comment>
      <origin>6099</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8014" sha1="n1ozfvz85n5zc3ni6k6okf1xa65n9ox" xml:space="preserve">[[Isimumathi:Ndebele Zimbabwe.jpg|thumb|Abanumzana bamaNdebele]]
'''INgwenyama uMagodongo''' (1811-1827) yingwenyama eyabusa  [[amaNdebele]] wakwaNzunza kusukela ngomnyaka wango-1814 ukuya ngo-1827. UMagodongo uyindodana yeNgwenyama uMgwezani. Welama uGembe, godu abe mnakwabo kaMrabheli. Nanyana kunezenzakalo ezinengi ezenzeke ngokubusa kwakhe, uMagodongo waziwa ngokulwa nebutho likaMzilikazi wesitjhaba samaZulu wakwaKhumalo, okukulapho alahlekelwa khona yipilwakhe ngo-1827. Namhlanjesi iNgwenyama uMagodongo kaMgwezani yaziwa njengekosi eyatjengisa isibindi ekudoseni phambili isitjhaba samaNdebele wakwaNzunza.&lt;ref name=&quot;:0&quot;&gt;South African History Online. (2011, April 3). ''The Ndebele in history''. South African History Online. Retrieved from:https://sahistory.org.za/article/ndebele-history. Retrieved on 30/07/2025.&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;C.J. Mahlangu, K.N. Mahlangu, M. A. Mahlangu, S. M. Mtshweni, (2011) ''Iziko Lamakhosi''. Shutter &amp; Shooter.&lt;/ref&gt;

== Umlando KaMagodongo Angakabusi ==
UMagodongo wabelethwa ngomnyaka ka-1811 kwaSimkhulu, abelethwa nguyise iNgwenyama uMgwezani. Ubelethwa nomnakwabo uGembe oliNghana (1791), nomtanabo uMrabheli oliDlhari (1803) yena aliDlowu (1799). Isikhathi sokubelethwa kwakhe bekusikhathi sokuthula ngombana uMgwezani ekubuseni kwakhe akhenge alwe ipi. Kwathi nakuhlongakala uMgwezani, uGembe ebekunguye obekufuze athathe isihlalo sobukhosi ngokomthetho bekasesemncani ngalesosikhathi. Yeke uDzela umfowabo kayise uMgwezani wabambela uGembe isihlalo sobukhosi.&lt;ref name=&quot;:1&quot; /&gt;

=== Nakubusa UDzela ===
Kwathi bona iNgwenyama uDzela ithwale isiba, yafuduka kwaSimkhulu nesitjhaba sayo yayokwakha eMlotheni kwaMaza hlanu komlambo iSakazana. Kwathi ngelinye ilanga iNgwenyama uDzela yakhamba yayokuhlasela isitjhaba sabaNguni ebesisendaweni yangemaTjhitjhini. Bafika lapho kwalwiwa, amaNdebele ehlulwa abaleka, kanti nababalekako nje uDzela uyokuwela ngemgodini. Amanaba amlandela afika amthola ngemgodini loyo ambulalela khona, umgodi loyo waba lithuna lakhe uDzela. Kodwana ngebanga lokuthi uGembe bekasesemncani ngesikhatheso kwafuze abanjelwe isihlalo. Yeke omunye umfowabo kayise, uMrhabuli kwaba nguye obambela uGembe.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot;&gt;M.H. Schoeman (1998), Excavating Ndzudza Ndebele Identity at KwaMaza, Southern African Field Archaeology. Retrieved from: https://journals.uj.ac.za/pdf/safa/1998_1%20UJ%20FIELD%20Archive/07_42-52%20Schoeman%201998%20Excavating%20Ndzundza%20identity.pdf. Retrieved on 30/07/2025.&lt;/ref&gt;

=== Nakubusa UMrhabuli ===
UMrhabuli (uSirudla) wathwala isiba ngo-1797 wabusa isitjhaba samaNdebele kwaMaza eMlotheni. Ngesikhathi sokubusa kwakhe, uMrhabuli nguye owathumela uMagodongo nomnakwabo uGembe bona bayokuhlasela esinye isitjhaba sabeNguni. UGembe wadosa intangakhe amaNghana phambili, uMagodongo yena warhola amaDlowu, kwatjhingwa ePumalanga. Kwathi bona uGembe abone ibutho labeNguni warhidlwa livalo waze waphathwa namathumbu, kwafuze bona abhace khona angazukubonakala. UMagodongo yena wathatha ibutho likamnakwabo walihlanganisa nelakhe wathathana phezulu namanaba. AbeNguni bahlulwa epini leyo. UMagodongo nebutho lakhe bathumba iinkomo neembuzi zabeNguni wabuya ekhaya.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

Ngebanga lokuthi uGembe abe litjhatjha epini amadoda athi akakafaneli ukuba yikosi, kodwana benyula uMagodongo. Lokho kwenza bona uGembe noMagodongo bangasathelelani amanzi. Amadoda athi nakalemuka lokho, athatha uMagodongo ayomfihla ekhabomkhulu kwaMahlaza.&lt;ref name=&quot;:1&quot; /&gt;

=== Ipi KaMagodongo NoKhunwana ===
Ikosi uMrhabuli njengombana beyilibambela nje ithe nayilemukako bona amadodanayo sele akhulile yafisa ngathana uMagodongo angabuya athathe iintambo. Kodwana amadodanayo ala. Alibeka emtarini bona uyise nakakhothamako indodanakhe ekulu uKhunwana nguye ozokuthatha isihlalo. UMrhabuli wathumela bona kuyokulandwa uMagodongo azokuzwa indaba le. Uthe nakafikako, uMrhabuli wamthatha wamfihla endaweni lapho bekuzokubanjelwa khona umhlangano. Emhlanganweni uMrhabuli wathoma indaba emadodeni, indaba yadenjwa, kwaphikiswana, kwathi nakuphela umhlangano, wakhambisa amadoda, ngemva kwalokho wavumbulula uMagodongo wambuza bona uzwile na. UMagodongo wathi uzwile, watjho nokuthi nakunjalo-ke uzokuthatha ubukhosi ngepi. Bese athathe isitjhaba kwaMahlaza azokwakha kwaMaza.&lt;ref name=&quot;:2&quot; /&gt;

Kwaba nepi phakathi kukaMagodongo noKhunwana. Ipi leyo yalwiwa beyayokufika kwaPondo, yabuya yayokulwelwa ekhaya kwaMaza. UMrhabuli wayetjele uMagodongo bona nakazokuthatha ubukhosi ngepi, kufuze angayibulali indodana yekosi, uMavula, ngombana nguye okufuze ambambele ikapho nakaselako. Kodwana kwathi nakulwiwako nje uMavula nguye okhabe aqeda ibutho likaMagodongo, okwenza bona ekugcineni uMagodongo abulale uMavula. Kwathi bona uMagodongo ahlule ipi, uMrhabuli wambuza bona uphi uMavula. UMagodongo wathi umbulele. UMrhabuli wathi ngombana abulele uMavula angekhe abe yikosi. Bewamthuwelelisa nangokuthi nangabe uzokubusa &quot;napo ubunyonyo obunzima phezu kwakho.&quot; Kodwana uMagodongo wabulala uMrhabuli nenye yamakhosikazakhe. Ekugcineni uMagodongo wayihlula ipi. UKhunwana nabanye bakwaMrhabuli bafuduka bayokuhlala nabaTswana e-Burolong. Ekugcineni uMagodongo wathatha isihlalo ngo-1814, wabusa isitjhaba samaNdebele.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

== Umlando KaMagodongo Nasele Abusa ==
Ekubuseni kwakhe uMagodongo wathatha amakhosikazi. Naka amagamawo:

* UNaMahena onguNoBharhuza
* UNaMabhena oyihlanzi onguNoMtshabi
* UNaMatjhaba onguNoSibogo
* UNaMdluli uNoMagogo onguNoMabhoko
* UNaNtuli onguNoGwalimba &lt;ref name=&quot;:1&quot; /&gt;

Naka amadodana kaMagodongo:

* UBharhuza (liGawu - 1815)
* UMloyi (liDzibha - 1819)
* UMtshabi (liThula - 1823)
* UBengwabo (liDlaza - 1827)
* USomdeyi - 1831
* UMgwayana (liDugu - 1835)
* USibogo - 1831
* UMabhoko (liSinya - 1839)
* UNdaweni (liRhorha - 1847)
* UGwalimba (liPhogo - 1843)&lt;ref name=&quot;:1&quot; /&gt;

== Ipi KaMagodongo NoMzilikazi ==
Ngo-1831 kwafika uMzilikazi kaMashobane wesitjhaba sakwaKhumalo asuka kwelabeNguni eSewula abalekela uShaka. Kwathi bona uMzilikazi afike esigodlweni sikaMagodongo esiKhunjini kwaMaza, wafika wabawa amabutho wokulwa nekosi uShaka. UMagodongo wavuma angakabonisani namadoda. Bavumelana, ngemva kwalokho uMzilikazi wathi usaya kwaManala uyokubawa amanye amabutho. UMagodongo wathi akakhambe uzawathatha nakabuyako. Wakhamba uMzilikazi waya ekosini yaManala uSibindi.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

Uthe nakasakhambileko uMzilikazi, uMagodongo wabiza amadoda bona bazokubonisana ngendaba le. Kwathi nakucociswanako amadoda wala ukunikela uMzilikazi amabutho. Isizathu salokho kukuthi uShaka kubudisi ukumehlula ngombana udlondlobele. Yeke bavumelana ngokuthi bazokukhambisa boke abantu abatjha okufuze babe libutho baye ebuzimbeni bomqedantonga ukwenzela bona uMzilikazi nakafikako abathole bangekho. Nangambala kwaba njalo.&lt;ref name=&quot;:1&quot; /&gt;

UMzilikazi wafika kwaManala wabawa uSibindi, uSibindi naye wavuma. Ngemva kwalokho uMzilikazi wabuyela emva kwaMagodongo bona ayokulanda ibutho athenjiswe lona. Enye indoda yatjela uSibindi namadoda wakwaManala bona uzwe ngamahlebezana bona uMzilikazi ufuna ukuthatha amabutho wabo nakaqeda abaleke nawo. Kodwana uSibindi namadoda wakwaManala khenge bayilalele.&lt;ref name=&quot;:1&quot; /&gt;

UMzilikazi wabuya kwaNzunza wabawa lokho athenjiswe khona, kodwana uMagodongo namadoda wamaNzunza bala baphetha ngokumnikela ibutho. Batjho nokuthi nanyana bangamnikela amabutho angekhe akghone ukulwa noShaka. UMzilikazi waqunta ukuhlasela uMagodongo nesitjhaba. Kuthiwa ibutho lakhe lehla livela entabeni yesiKhunjini, elinye lavela ncazoke ngakaMaza. Kodwana nanyana arogelelekile amaNdebele alwa. Ekugcineni ahluleka. UMzilikazi wathatha uMagodongo nendodanakhe uMloyi, nenduna uMthimunye wababophelela ngamatje entanyeni wabaphosela ngesizibeni. Kwaba kuhlongakala kweNgwenyama uMagodongo. Kwathi bona abantu abatjha sele babuyile balandela iinthunjwa basindisa ezinye zazo. Isitjhaba samaNdebele sasinda ngobunjalo.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>n1ozfvz85n5zc3ni6k6okf1xa65n9ox</sha1>
    </revision>
    <revision>
      <id>6100</id>
      <parentid>6099</parentid>
      <timestamp>2025-12-22T06:56:12Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <minor />
      <comment>/* Ipi KaMagodongo NoMzilikazi */ spelling fix</comment>
      <origin>6100</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8015" sha1="19fz4e18og1y5r43lv9fj21rdovo2rl" xml:space="preserve">[[Isimumathi:Ndebele Zimbabwe.jpg|thumb|Abanumzana bamaNdebele]]
'''INgwenyama uMagodongo''' (1811-1827) yingwenyama eyabusa  [[amaNdebele]] wakwaNzunza kusukela ngomnyaka wango-1814 ukuya ngo-1827. UMagodongo uyindodana yeNgwenyama uMgwezani. Welama uGembe, godu abe mnakwabo kaMrabheli. Nanyana kunezenzakalo ezinengi ezenzeke ngokubusa kwakhe, uMagodongo waziwa ngokulwa nebutho likaMzilikazi wesitjhaba samaZulu wakwaKhumalo, okukulapho alahlekelwa khona yipilwakhe ngo-1827. Namhlanjesi iNgwenyama uMagodongo kaMgwezani yaziwa njengekosi eyatjengisa isibindi ekudoseni phambili isitjhaba samaNdebele wakwaNzunza.&lt;ref name=&quot;:0&quot;&gt;South African History Online. (2011, April 3). ''The Ndebele in history''. South African History Online. Retrieved from:https://sahistory.org.za/article/ndebele-history. Retrieved on 30/07/2025.&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;C.J. Mahlangu, K.N. Mahlangu, M. A. Mahlangu, S. M. Mtshweni, (2011) ''Iziko Lamakhosi''. Shutter &amp; Shooter.&lt;/ref&gt;

== Umlando KaMagodongo Angakabusi ==
UMagodongo wabelethwa ngomnyaka ka-1811 kwaSimkhulu, abelethwa nguyise iNgwenyama uMgwezani. Ubelethwa nomnakwabo uGembe oliNghana (1791), nomtanabo uMrabheli oliDlhari (1803) yena aliDlowu (1799). Isikhathi sokubelethwa kwakhe bekusikhathi sokuthula ngombana uMgwezani ekubuseni kwakhe akhenge alwe ipi. Kwathi nakuhlongakala uMgwezani, uGembe ebekunguye obekufuze athathe isihlalo sobukhosi ngokomthetho bekasesemncani ngalesosikhathi. Yeke uDzela umfowabo kayise uMgwezani wabambela uGembe isihlalo sobukhosi.&lt;ref name=&quot;:1&quot; /&gt;

=== Nakubusa UDzela ===
Kwathi bona iNgwenyama uDzela ithwale isiba, yafuduka kwaSimkhulu nesitjhaba sayo yayokwakha eMlotheni kwaMaza hlanu komlambo iSakazana. Kwathi ngelinye ilanga iNgwenyama uDzela yakhamba yayokuhlasela isitjhaba sabaNguni ebesisendaweni yangemaTjhitjhini. Bafika lapho kwalwiwa, amaNdebele ehlulwa abaleka, kanti nababalekako nje uDzela uyokuwela ngemgodini. Amanaba amlandela afika amthola ngemgodini loyo ambulalela khona, umgodi loyo waba lithuna lakhe uDzela. Kodwana ngebanga lokuthi uGembe bekasesemncani ngesikhatheso kwafuze abanjelwe isihlalo. Yeke omunye umfowabo kayise, uMrhabuli kwaba nguye obambela uGembe.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot;&gt;M.H. Schoeman (1998), Excavating Ndzudza Ndebele Identity at KwaMaza, Southern African Field Archaeology. Retrieved from: https://journals.uj.ac.za/pdf/safa/1998_1%20UJ%20FIELD%20Archive/07_42-52%20Schoeman%201998%20Excavating%20Ndzundza%20identity.pdf. Retrieved on 30/07/2025.&lt;/ref&gt;

=== Nakubusa UMrhabuli ===
UMrhabuli (uSirudla) wathwala isiba ngo-1797 wabusa isitjhaba samaNdebele kwaMaza eMlotheni. Ngesikhathi sokubusa kwakhe, uMrhabuli nguye owathumela uMagodongo nomnakwabo uGembe bona bayokuhlasela esinye isitjhaba sabeNguni. UGembe wadosa intangakhe amaNghana phambili, uMagodongo yena warhola amaDlowu, kwatjhingwa ePumalanga. Kwathi bona uGembe abone ibutho labeNguni warhidlwa livalo waze waphathwa namathumbu, kwafuze bona abhace khona angazukubonakala. UMagodongo yena wathatha ibutho likamnakwabo walihlanganisa nelakhe wathathana phezulu namanaba. AbeNguni bahlulwa epini leyo. UMagodongo nebutho lakhe bathumba iinkomo neembuzi zabeNguni wabuya ekhaya.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

Ngebanga lokuthi uGembe abe litjhatjha epini amadoda athi akakafaneli ukuba yikosi, kodwana benyula uMagodongo. Lokho kwenza bona uGembe noMagodongo bangasathelelani amanzi. Amadoda athi nakalemuka lokho, athatha uMagodongo ayomfihla ekhabomkhulu kwaMahlaza.&lt;ref name=&quot;:1&quot; /&gt;

=== Ipi KaMagodongo NoKhunwana ===
Ikosi uMrhabuli njengombana beyilibambela nje ithe nayilemukako bona amadodanayo sele akhulile yafisa ngathana uMagodongo angabuya athathe iintambo. Kodwana amadodanayo ala. Alibeka emtarini bona uyise nakakhothamako indodanakhe ekulu uKhunwana nguye ozokuthatha isihlalo. UMrhabuli wathumela bona kuyokulandwa uMagodongo azokuzwa indaba le. Uthe nakafikako, uMrhabuli wamthatha wamfihla endaweni lapho bekuzokubanjelwa khona umhlangano. Emhlanganweni uMrhabuli wathoma indaba emadodeni, indaba yadenjwa, kwaphikiswana, kwathi nakuphela umhlangano, wakhambisa amadoda, ngemva kwalokho wavumbulula uMagodongo wambuza bona uzwile na. UMagodongo wathi uzwile, watjho nokuthi nakunjalo-ke uzokuthatha ubukhosi ngepi. Bese athathe isitjhaba kwaMahlaza azokwakha kwaMaza.&lt;ref name=&quot;:2&quot; /&gt;

Kwaba nepi phakathi kukaMagodongo noKhunwana. Ipi leyo yalwiwa beyayokufika kwaPondo, yabuya yayokulwelwa ekhaya kwaMaza. UMrhabuli wayetjele uMagodongo bona nakazokuthatha ubukhosi ngepi, kufuze angayibulali indodana yekosi, uMavula, ngombana nguye okufuze ambambele ikapho nakaselako. Kodwana kwathi nakulwiwako nje uMavula nguye okhabe aqeda ibutho likaMagodongo, okwenza bona ekugcineni uMagodongo abulale uMavula. Kwathi bona uMagodongo ahlule ipi, uMrhabuli wambuza bona uphi uMavula. UMagodongo wathi umbulele. UMrhabuli wathi ngombana abulele uMavula angekhe abe yikosi. Bewamthuwelelisa nangokuthi nangabe uzokubusa &quot;napo ubunyonyo obunzima phezu kwakho.&quot; Kodwana uMagodongo wabulala uMrhabuli nenye yamakhosikazakhe. Ekugcineni uMagodongo wayihlula ipi. UKhunwana nabanye bakwaMrhabuli bafuduka bayokuhlala nabaTswana e-Burolong. Ekugcineni uMagodongo wathatha isihlalo ngo-1814, wabusa isitjhaba samaNdebele.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

== Umlando KaMagodongo Nasele Abusa ==
Ekubuseni kwakhe uMagodongo wathatha amakhosikazi. Naka amagamawo:

* UNaMahena onguNoBharhuza
* UNaMabhena oyihlanzi onguNoMtshabi
* UNaMatjhaba onguNoSibogo
* UNaMdluli uNoMagogo onguNoMabhoko
* UNaNtuli onguNoGwalimba &lt;ref name=&quot;:1&quot; /&gt;

Naka amadodana kaMagodongo:

* UBharhuza (liGawu - 1815)
* UMloyi (liDzibha - 1819)
* UMtshabi (liThula - 1823)
* UBengwabo (liDlaza - 1827)
* USomdeyi - 1831
* UMgwayana (liDugu - 1835)
* USibogo - 1831
* UMabhoko (liSinya - 1839)
* UNdaweni (liRhorha - 1847)
* UGwalimba (liPhogo - 1843)&lt;ref name=&quot;:1&quot; /&gt;

== Ipi KaMagodongo NoMzilikazi ==
Ngo-1831 kwafika uMzilikazi kaMashobane wesitjhaba sakwaKhumalo asuka kwelabeNguni eSewula abalekela uShaka. Kwathi bona uMzilikazi afike esigodlweni sikaMagodongo esiKhunjini kwaMaza, wafika wabawa amabutho wokulwa nekosi uShaka. UMagodongo wavuma angakabonisani namadoda. Bavumelana, ngemva kwalokho uMzilikazi wathi usaya kwaManala uyokubawa amanye amabutho. UMagodongo wathi akakhambe uzawathatha nakabuyako. Wakhamba uMzilikazi waya ekosini yaManala uSibindi.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

Uthe nakasakhambileko uMzilikazi, uMagodongo wabiza amadoda bona bazokubonisana ngendaba le. Kwathi nakucociswanako amadoda wala ukunikela uMzilikazi amabutho. Isizathu salokho kukuthi uShaka kubudisi ukumehlula ngombana udlondlobele. Yeke bavumelana ngokuthi bazokukhambisa boke abantu abatjha okufuze babe libutho baye ebuzimbeni bomqedantonga ukwenzela bona uMzilikazi nakafikako abathole bangekho. Nangambala kwaba njalo.&lt;ref name=&quot;:1&quot; /&gt;

UMzilikazi wafika kwaManala wabawa uSibindi, uSibindi naye wavuma. Ngemva kwalokho uMzilikazi wabuyela emva kwaMagodongo bona ayokulanda ibutho athenjiswe lona. Enye indoda yatjela uSibindi namadoda wakwaManala bona uzwe ngamahlebezana bona uMzilikazi ufuna ukuthatha amabutho wabo nakaqeda abaleke nawo. Kodwana uSibindi namadoda wakwaManala khenge bayilalele.&lt;ref name=&quot;:1&quot; /&gt;

UMzilikazi wabuya kwaNzunza wabawa lokho athenjiswe khona, kodwana uMagodongo namadoda wamaNzunza bala baphetha ngokumnikela ibutho. Batjho nokuthi nanyana bangamnikela amabutho angekhe akghone ukulwa noShaka. UMzilikazi waqunta ukuhlasela uMagodongo nesitjhaba. Kuthiwa ibutho lakhe lehla livela entabeni yesiKhunjini, elinye lavela ncazoke ngakwaMaza. Kodwana nanyana arogelelekile amaNdebele alwa. Ekugcineni ahluleka. UMzilikazi wathatha uMagodongo nendodanakhe uMloyi, nenduna uMthimunye wababophelela ngamatje entanyeni wabaphosela ngesizibeni. Kwaba kuhlongakala kweNgwenyama uMagodongo. Kwathi bona abantu abatjha sele babuyile balandela iinthunjwa basindisa ezinye zazo. Isitjhaba samaNdebele sasinda ngobunjalo.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>19fz4e18og1y5r43lv9fj21rdovo2rl</sha1>
    </revision>
    <revision>
      <id>6143</id>
      <parentid>6100</parentid>
      <timestamp>2026-01-19T21:19:03Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <minor />
      <comment>/* Umlando KaMagodongo Angakabusi */</comment>
      <origin>6143</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7994" sha1="fnfyfdfzldzdwrakdq16whk31ia7ttj" xml:space="preserve">[[Isimumathi:Ndebele Zimbabwe.jpg|thumb|Abanumzana bamaNdebele]]
'''INgwenyama uMagodongo''' (1811-1827) yingwenyama eyabusa  [[amaNdebele]] wakwaNzunza kusukela ngomnyaka wango-1814 ukuya ngo-1827. UMagodongo uyindodana yeNgwenyama uMgwezani. Welama uGembe, godu abe mnakwabo kaMrabheli. Nanyana kunezenzakalo ezinengi ezenzeke ngokubusa kwakhe, uMagodongo waziwa ngokulwa nebutho likaMzilikazi wesitjhaba samaZulu wakwaKhumalo, okukulapho alahlekelwa khona yipilwakhe ngo-1827. Namhlanjesi iNgwenyama uMagodongo kaMgwezani yaziwa njengekosi eyatjengisa isibindi ekudoseni phambili isitjhaba samaNdebele wakwaNzunza.&lt;ref name=&quot;:0&quot;&gt;South African History Online. (2011, April 3). ''The Ndebele in history''. South African History Online. Retrieved from:https://sahistory.org.za/article/ndebele-history. Retrieved on 30/07/2025.&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;C.J. Mahlangu, K.N. Mahlangu, M. A. Mahlangu, S. M. Mtshweni, (2011) ''Iziko Lamakhosi''. Shutter &amp; Shooter.&lt;/ref&gt;

== Umlando KaMagodongo Angakabusi ==
UMagodongo wabelethwa ngomnyaka ka-1811 kwaSimkhulu, abelethwa nguyise iNgwenyama uMgwezani. Ubelethwa nomnakwabo uGembe oliNghana (1791), nomtanabo uMrabheli oliDlhari (1803). Isikhathi sokubelethwa kwakhe bekusikhathi sokuthula ngombana uMgwezani ekubuseni kwakhe akhenge alwe ipi. Kwathi nakuhlongakala uMgwezani, uGembe ebekunguye obekufuze athathe isihlalo sobukhosi ngokomthetho bekasesemncani ngalesosikhathi. Yeke uDzela umfowabo kayise uMgwezani wabambela uGembe isihlalo sobukhosi.&lt;ref name=&quot;:1&quot; /&gt;

=== Nakubusa UDzela ===
Kwathi bona iNgwenyama uDzela ithwale isiba, yafuduka kwaSimkhulu nesitjhaba sayo yayokwakha eMlotheni kwaMaza hlanu komlambo iSakazana. Kwathi ngelinye ilanga iNgwenyama uDzela yakhamba yayokuhlasela isitjhaba sabaNguni ebesisendaweni yangemaTjhitjhini. Bafika lapho kwalwiwa, amaNdebele ehlulwa abaleka, kanti nababalekako nje uDzela uyokuwela ngemgodini. Amanaba amlandela afika amthola ngemgodini loyo ambulalela khona, umgodi loyo waba lithuna lakhe uDzela. Kodwana ngebanga lokuthi uGembe bekasesemncani ngesikhatheso kwafuze abanjelwe isihlalo. Yeke omunye umfowabo kayise, uMrhabuli kwaba nguye obambela uGembe.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot;&gt;M.H. Schoeman (1998), Excavating Ndzudza Ndebele Identity at KwaMaza, Southern African Field Archaeology. Retrieved from: https://journals.uj.ac.za/pdf/safa/1998_1%20UJ%20FIELD%20Archive/07_42-52%20Schoeman%201998%20Excavating%20Ndzundza%20identity.pdf. Retrieved on 30/07/2025.&lt;/ref&gt;

=== Nakubusa UMrhabuli ===
UMrhabuli (uSirudla) wathwala isiba ngo-1797 wabusa isitjhaba samaNdebele kwaMaza eMlotheni. Ngesikhathi sokubusa kwakhe, uMrhabuli nguye owathumela uMagodongo nomnakwabo uGembe bona bayokuhlasela esinye isitjhaba sabeNguni. UGembe wadosa intangakhe amaNghana phambili, uMagodongo yena warhola amaDlowu, kwatjhingwa ePumalanga. Kwathi bona uGembe abone ibutho labeNguni warhidlwa livalo waze waphathwa namathumbu, kwafuze bona abhace khona angazukubonakala. UMagodongo yena wathatha ibutho likamnakwabo walihlanganisa nelakhe wathathana phezulu namanaba. AbeNguni bahlulwa epini leyo. UMagodongo nebutho lakhe bathumba iinkomo neembuzi zabeNguni wabuya ekhaya.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

Ngebanga lokuthi uGembe abe litjhatjha epini amadoda athi akakafaneli ukuba yikosi, kodwana benyula uMagodongo. Lokho kwenza bona uGembe noMagodongo bangasathelelani amanzi. Amadoda athi nakalemuka lokho, athatha uMagodongo ayomfihla ekhabomkhulu kwaMahlaza.&lt;ref name=&quot;:1&quot; /&gt;

=== Ipi KaMagodongo NoKhunwana ===
Ikosi uMrhabuli njengombana beyilibambela nje ithe nayilemukako bona amadodanayo sele akhulile yafisa ngathana uMagodongo angabuya athathe iintambo. Kodwana amadodanayo ala. Alibeka emtarini bona uyise nakakhothamako indodanakhe ekulu uKhunwana nguye ozokuthatha isihlalo. UMrhabuli wathumela bona kuyokulandwa uMagodongo azokuzwa indaba le. Uthe nakafikako, uMrhabuli wamthatha wamfihla endaweni lapho bekuzokubanjelwa khona umhlangano. Emhlanganweni uMrhabuli wathoma indaba emadodeni, indaba yadenjwa, kwaphikiswana, kwathi nakuphela umhlangano, wakhambisa amadoda, ngemva kwalokho wavumbulula uMagodongo wambuza bona uzwile na. UMagodongo wathi uzwile, watjho nokuthi nakunjalo-ke uzokuthatha ubukhosi ngepi. Bese athathe isitjhaba kwaMahlaza azokwakha kwaMaza.&lt;ref name=&quot;:2&quot; /&gt;

Kwaba nepi phakathi kukaMagodongo noKhunwana. Ipi leyo yalwiwa beyayokufika kwaPondo, yabuya yayokulwelwa ekhaya kwaMaza. UMrhabuli wayetjele uMagodongo bona nakazokuthatha ubukhosi ngepi, kufuze angayibulali indodana yekosi, uMavula, ngombana nguye okufuze ambambele ikapho nakaselako. Kodwana kwathi nakulwiwako nje uMavula nguye okhabe aqeda ibutho likaMagodongo, okwenza bona ekugcineni uMagodongo abulale uMavula. Kwathi bona uMagodongo ahlule ipi, uMrhabuli wambuza bona uphi uMavula. UMagodongo wathi umbulele. UMrhabuli wathi ngombana abulele uMavula angekhe abe yikosi. Bewamthuwelelisa nangokuthi nangabe uzokubusa &quot;napo ubunyonyo obunzima phezu kwakho.&quot; Kodwana uMagodongo wabulala uMrhabuli nenye yamakhosikazakhe. Ekugcineni uMagodongo wayihlula ipi. UKhunwana nabanye bakwaMrhabuli bafuduka bayokuhlala nabaTswana e-Burolong. Ekugcineni uMagodongo wathatha isihlalo ngo-1814, wabusa isitjhaba samaNdebele.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

== Umlando KaMagodongo Nasele Abusa ==
Ekubuseni kwakhe uMagodongo wathatha amakhosikazi. Naka amagamawo:

* UNaMahena onguNoBharhuza
* UNaMabhena oyihlanzi onguNoMtshabi
* UNaMatjhaba onguNoSibogo
* UNaMdluli uNoMagogo onguNoMabhoko
* UNaNtuli onguNoGwalimba &lt;ref name=&quot;:1&quot; /&gt;

Naka amadodana kaMagodongo:

* UBharhuza (liGawu - 1815)
* UMloyi (liDzibha - 1819)
* UMtshabi (liThula - 1823)
* UBengwabo (liDlaza - 1827)
* USomdeyi - 1831
* UMgwayana (liDugu - 1835)
* USibogo - 1831
* UMabhoko (liSinya - 1839)
* UNdaweni (liRhorha - 1847)
* UGwalimba (liPhogo - 1843)&lt;ref name=&quot;:1&quot; /&gt;

== Ipi KaMagodongo NoMzilikazi ==
Ngo-1831 kwafika uMzilikazi kaMashobane wesitjhaba sakwaKhumalo asuka kwelabeNguni eSewula abalekela uShaka. Kwathi bona uMzilikazi afike esigodlweni sikaMagodongo esiKhunjini kwaMaza, wafika wabawa amabutho wokulwa nekosi uShaka. UMagodongo wavuma angakabonisani namadoda. Bavumelana, ngemva kwalokho uMzilikazi wathi usaya kwaManala uyokubawa amanye amabutho. UMagodongo wathi akakhambe uzawathatha nakabuyako. Wakhamba uMzilikazi waya ekosini yaManala uSibindi.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

Uthe nakasakhambileko uMzilikazi, uMagodongo wabiza amadoda bona bazokubonisana ngendaba le. Kwathi nakucociswanako amadoda wala ukunikela uMzilikazi amabutho. Isizathu salokho kukuthi uShaka kubudisi ukumehlula ngombana udlondlobele. Yeke bavumelana ngokuthi bazokukhambisa boke abantu abatjha okufuze babe libutho baye ebuzimbeni bomqedantonga ukwenzela bona uMzilikazi nakafikako abathole bangekho. Nangambala kwaba njalo.&lt;ref name=&quot;:1&quot; /&gt;

UMzilikazi wafika kwaManala wabawa uSibindi, uSibindi naye wavuma. Ngemva kwalokho uMzilikazi wabuyela emva kwaMagodongo bona ayokulanda ibutho athenjiswe lona. Enye indoda yatjela uSibindi namadoda wakwaManala bona uzwe ngamahlebezana bona uMzilikazi ufuna ukuthatha amabutho wabo nakaqeda abaleke nawo. Kodwana uSibindi namadoda wakwaManala khenge bayilalele.&lt;ref name=&quot;:1&quot; /&gt;

UMzilikazi wabuya kwaNzunza wabawa lokho athenjiswe khona, kodwana uMagodongo namadoda wamaNzunza bala baphetha ngokumnikela ibutho. Batjho nokuthi nanyana bangamnikela amabutho angekhe akghone ukulwa noShaka. UMzilikazi waqunta ukuhlasela uMagodongo nesitjhaba. Kuthiwa ibutho lakhe lehla livela entabeni yesiKhunjini, elinye lavela ncazoke ngakwaMaza. Kodwana nanyana arogelelekile amaNdebele alwa. Ekugcineni ahluleka. UMzilikazi wathatha uMagodongo nendodanakhe uMloyi, nenduna uMthimunye wababophelela ngamatje entanyeni wabaphosela ngesizibeni. Kwaba kuhlongakala kweNgwenyama uMagodongo. Kwathi bona abantu abatjha sele babuyile balandela iinthunjwa basindisa ezinye zazo. Isitjhaba samaNdebele sasinda ngobunjalo.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>fnfyfdfzldzdwrakdq16whk31ia7ttj</sha1>
    </revision>
  </page>
  <page>
    <title>Isitjhaba samaNdzundza</title>
    <ns>0</ns>
    <id>717</id>
    <revision>
      <id>3511</id>
      <timestamp>2025-07-30T15:38:24Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>i added a new article</comment>
      <origin>3511</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5142" sha1="9sp1pdej2ey9btiw1qw57vfzu3uv6g1" xml:space="preserve">== Isitjhaba samaNdzundza ==
[[Isimumathi:King Nyabela of the Ndebele Tribe South Africa 1893.jpg|thumb|Ingwenyama uNyabela yesitjhaba sama Ndzundza.]]
Ama-'''Ndzundza''' siqhema sama'''Ndebele''' asesewula yeTransvaal anomlando onothileko ophawulwa ngokufuduka,ukurarana nokujamelana namandla wama-Koloni.Badzimelela esigodini somlambo we-Steelpoort ngabo-AD700,baqalene nokufuduswa ngebanga lokulwa nezinye iinqhema begodu ngoku khamba kwesikhathi nama-'''Boers'''.

=== Ingwenyama u-Mabhoko. ===
Ingwenyama u-'''Mabhoko''' umrholi odumileko warhola ama-'''Ndzundza''' ngesikhathi sokunwebeka namandla ngeminyaka yabo-1860 ukuya ku-1870,wabe wakha ubudlelwane neenqhema ezibomakhelwane.

Ingwenyama u-'''Mabhoko''' bekungumrholi oqakathekileko wesitjhaba sama-'''Ndzundza''' e'''Sewula ye-Afrika''',owaziwa ngesibindi sakhe nokujamelana no-'''Sekhukhune''' nama'''Boers'''.Wabusa ukusukela ngabo-1840 begodu waqalana neentjhijilo ezinengi eifaka hlangana ukurarana nama-'''Pedi''' nama-'''Boers'''.Wathathelwa indawo yindodanakhe u-'''Mkhephuli''' owabusa iminyaka elitjhumi ngaphambi kobana athathelwe indawo ngu-'''Rhobongo''' kwathi ngokukhamba kwesikhathi u-'''Nyabela'''.

Umlando wabo ubonakala ngesiko elinamandla lobuciko khulu ekwenzeni ubuhlalo nokudweba izindlu okuhlotjaniswa nobunjalo obubanzi bama-'''Ndebele'''.

==== Ipi ye-'''Zar''' nokujamelana nesitjhaba sama-Ndzundza. ====
Uburholi beNgwenyamau-'''Nyabela''' baphawula isikhathi sokugcina sokuzijamela kwesitjhaba sama-'''Ndzundza'''.Mhlana ali-13 kuRhoboyi wee-1882 iNgwenyama yama-'''Pedi''' u-'''Sekhukhune''' wabulawa kunye nabaluleki bakhe abalitjhumi nane.Abarhayili begade besebenza ngokulayelwa ngumfowabo u-'''Mampuru''' obegade aphikisana bama-'''Pedi'''.Ngo-1861 ngaphasi kokulawulwa kwama-'''British''' we-Transvaal ubegade asebenza njengesikhulu ngesikhathi sokubotjhwa kuka-'''Sekhukhune''' e-'''Pitori''' kusukela ngo-1879 ukuya ku-1881.

===== uRhulumende we-'''Zar'''. =====
URhulumende we-'''zar''' obegade uqophele ukuzijamela kwayo okutjha e-'''Brithani''' bewuzimisele ukusebenzisa igunya lawo phezu  kwama-'''Pedi''',begodu wafuna bona u-'''Mampuru''' alethwe ngaphambili ngomlandu wakhe.U-'''Mampuru''' wabe sele uyabaleka wayokuphepha esitjhabeni sama-'''Ndzundza''' ebegade bamsekela ngaphambilini ngo-1861 ekufuneni kwakhe ubukhosi esitjhabeni sama-'''Pedi.'''I'''Volksraad''' ye-'''Zar''' yafuna bona abotjhwe kodwana u-'''Nyabela''' wala ukunikela ngo-'''Mampuru''' .Wabuye wala nokubhadela umthelo wendlu yamasiko kuRhulumende omutjha we-Transvaal.Nanyana kunjalo 

===== Ukuhlaselwa kwama-'''Ndzundza''' kwa-'''Nomtjharhelo'''. =====
Njengombana bebanamandla phezu kwabantu babo bemvelo,lokhu bekungasimthelela i-'''Zar''' ethoma ukusungulwa ebeyingawenza ukuyitjhiya,ngalokho ke mhlana ayi-30 kuMgwengweni we-1882 i-'''Burgler Commando''' ngaphasi koburholi baka Gen-'''Piet Joubert''' yasuka e-'''Middleburg''' yatjhinga entabeni yama-'''Ndzundza''' eduze nako-'''Nomtjharhelo'''.Eqinisweni lokhu bekungaphezu nokulandelana kwemihume lapho u-'''Nyabela''' nabantu bakhe bebacabanga ukubuyela emva.Akhukho ukuphuma kwamarekhodi wenani elinqophileko lama-'''Boers''' abandameka ejimeni leli,kodwana ngokuya ngeencwadi zaka-'''Joubert''' kubonakala ingasuthi bekungakabi namadoda angaphezu kwe-1000 ukuya ku-2000 ebegade asesigabeni ngasinye isikhathi.Ngokuqinisekileko ama-'''Boers''' abonakala bona bekanganamandla wokulwa okwenza u-'''Joubert''' bona akhononde ku-'''Volksraad''' ngokuthi amajoni abonakala aketha ukuphanga iinkomo ngebanga lawo.

[[Isimumathi:Boer War; in the aftermath of an explosion in Buluwayo the i Wellcome V0015619.jpg|thumb|IpI yama-Boer ngemva kokuthuthumba kwa-Bulawayo]]

====== Ukuthunjwa kwesitjhaba sama-'''Ndzunzda''' ======
Ngemva kwejima elide leenyanga ezipheze zibe lithoba ama-'''Ndzunzda''' abulawa yindlala kwabakatelela bona bazinikele begodu banikele u-'''Mampuru'''.Bobabili u-'''Mampuru''' no'''Nyabela''' bathunjwa babotjhwa baya e-'''Pitori''' lapha bagwetjwa khona umlando wokuvukela umbuso begodu bagwetjwa isigwebo seentambo.Ama-'''Brithani''' ebegade asekela iinkolodo zika-'''Mampuru''' esitjhabeni sama-'''Pedi''' alinga ukulamulela i-'''Zar''' kodwana imizamo yabo yaphumelela kancani ngombana isigwebo saka-'''Nyabela''' satjhugululwa saba ngese jele ipilo yakhe yoke.U-'''Mampuru''' walengiswa ejele le-'''Pitori''' mhlana kuzi-22 kuSinyikhaba 1883.

Ngesikhathi esifanako i-'''Volksraad''' yamemezela bona inarha yabokhokho yesitjhaba sama-'''Ndzunzda''' izokuthathwa nguRhukumende we-'''Zar''',owabesele uragela phambili ngokuwunikela amalunga we-'''Joubert''' commando.Ama-'''Nzdunzda''' aphilako anikelwa isivumelwano seminyaka emihlanu njengeensebenzi ebalimini esifundeni begodu lokho kwaphula amandla wabo njengesitjhaba iminyaka eminengi. 

====== Iinkhombo ======
https://sahistory.org.za/article/ndebele-history
https://www.krugerpark.co.za/africa_ndebele.html
https://ndebelekingdom.org/history
https://repository.up.ac.za/handle/2263/14373
https://journals.uj.ac.za/pdf/safa/1998_1%20UJ%20FIELD%20Archive/07_42-52%20Schoeman%201998%20Excavating%20Ndzundza%20identity.pdf</text>
      <sha1>9sp1pdej2ey9btiw1qw57vfzu3uv6g1</sha1>
    </revision>
  </page>
  <page>
    <title>Isikhwama sabantwana saka-Nelson Mandela</title>
    <ns>0</ns>
    <id>718</id>
    <revision>
      <id>3512</id>
      <timestamp>2025-07-31T13:17:05Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1290898345|Nelson Mandela Children's Fund]]&quot;</comment>
      <origin>3512</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6572" sha1="oonu4bwer952fjkoulepqo9gk3m79uy" xml:space="preserve">

 

I-'''Nelson Mandela Children's Fund'''( '''NMCF''')yihlangano yokusiza abatlhagako eyasungulwa ngu-Nelson Mandela, eseSewula Afrika.Umnqopho wayo kusiza abantu kusukela ekubelethweni ukuya eminyakeni ema-22. 

== Umlando ==
Ngo-1995,u-Mandela wajama wakhuluma nabantwana be ndeleni e-Cape Town,begodu waphefumulelwa bona asungule ihlangano. Wathi:&lt;blockquote&gt;&quot;Besitjhayela sibuyela emva e-Cape Town ngobunye ubusuku obumakhaza bebusika, lokha nangibona isiqhema sabantwana bendleleni begodu ngajama ngakhuluma nabo ecadi kwendlela &quot;Abantwana bangibuza bona kubayini ngibathanda.Lokhu kwangimangalisa,ngababuza bona kubayini babuza lokhu, bathi ngombana ngasosoke isikhathi nangithola imali evela ngaphetjheya,ngiyabelana nabo.&quot; &lt;/blockquote&gt;Lokha nakasungula ihlangano,wathembisa ukunikela ngengcenye eyodwa kwezintathu yomrholo wakhe ku-NMCF, begodu wathoma ukubuthelela imali.

I-Nelson Mandela Children's Fund ilwela ukutjhugulula indlela umphakathi ophatha ngayo abantwana nelutjha.Umbono wesikhathi eside lo uthatha indima eqakathekileko edlalwa mphakathi ekubumbeni amaphilo wabantwana begodu umnqopho kukunikela ilizwi nesithunzi emntwaneni we-Afrika ngokwakha ihlangano esekelwe emalungelweni.

== Amahlelo ==

=== Isibhedlela sabantwana saka-Nelson Mandela ===
I-Nelson Mandela Children's Hospital yiphrojekthi ephambili ye-Nelson Mandela Children's Fund.Isibhedlela sabantwana se-Nelson Mandela sisibhedlela sezinga eliphezulu, esinemibhede ema-200  esinikela ngendawo etlhogomelako, edzimelele ebantwaneni nemindeni ukwelapha nokusekela abantwana abagula khulu.I-Nelson Mandela Children's Hospital Trust yasungulwa begodu yanikelwa umsebenzi wokubuthelela i-R1bhiliyoni ukuvuselela isibhedlela sabantwana esikhethekileko.

=== Ukuphepha nokuVikelwa kwabantwana ===
Ihlangano yokuPhepha nokuVikelwa kwaBantwana (i-CSP) ihlose ukwenza indawo ephephileko yabantwana nelutjha eenkolweni nemiphakathini.Umnqopho omkhulu wehlelo leli kukwehlisa ukujeziswa ngemizimba eenkolweni,ukwehlisa ukuhlukunyezwa ngokomseme nangobulili hlangana nabantu abasikazi nabantazana kanye nokuqeda ukutlhoriswa ngaphakathi kweenkolo.Ihlelo njenganje lisebenza eemfundeni ezilandelako i-Limpopo, i-Gauteng, i-Kwa-Zulu Natal, i-Eastern Cape kunye ne-Western Cape.

=== Ukuphila kwabantwana, ukuthuthuka nokuphumelela ===
Njengombana ukuhlongakala kwabantwana kubizwa njengendaba eqakathekileko yezamaphilo ngebanga lokungondleki kuhle,ukutlhogeka kokugoma nokufikelela kwabomma nabantwana eenkonzweni zezokwelapha nokutlhogonyelwa kwezamaphilo,amalanga wokuthoma ayi-1000 wokuphila aba yindawo eqakathekileko isikhwama ekufuze itjheje kiyo.Ipendulo yesikhwama itholwa ngokuhlaziywa kobukhulu bomraro,iinsombululo ezikhona kunye namagebe angakapheleli.

Umnqopho wokungenelela lokhu kukwenza isiqiniseko sokuthi ihlelo lokutlhogomela liphendula iindingo zabantwana abangaphasi kweminyaka emithathu ukuqinisekisa ngcono ukuphila kwabo,ukuthuthuka nokuphumelela.Umsebenzi wesikhwama kukwenza ngokutjheja okukhulu ekuvaleni iinkhala ngokusebenzisa ukugonywa,ukwelatjhwa kwe-HIV/AIDS nofana ukuvimbela kunye nokulwisana nokungadli kuhle.

Indlela yesikhwama imayelana nokuthuthukisa ihlelo lokuphumelelisa elisekelwe emsebenzini ngokucabangela iinkhala ezikhona kulelo zinga ngebanga lokuncipha kwemithombo.Ihlelo leli lenziwe ziingcenye ezintathu ezihlobeneko ukurarulula inengi lezikhala ezifundeni ezihlanu ezithinteke khulu ze-OR Tambo, u-Alfred Nzo no-Joe Gqabi e-Eastern Cape, i-Zululand kwa-Kwazulu Natal kunye ne-John Taolo e-Northern Cape.

=== Ihlelo loburholi lelutjha ===
Ihlelo loburholi lelutjha belidzimelele ekukhuthazeni nokukhuthaza,ngokugandelela ekuhlanganiseni abantwana nelutjha ekuthuthukiseni amatjhuguluko amahle emphakathini.Ngaphasi kwehlelo loburholi lelutjha kunamaphrojekthi amane asebenzako.Amaphrojekthi la ngu-Efeng Bacha, i-Children's Parliament, i-Legacy Academy kunye ne-YLP Alumni.

==== Efeng Bacha ====
Iminqopho yeHlelo leLutjha le-NMCF Efeng Bacha kukunikela amathuba,amakghono nokufundisa ilutjha.Iklabhu ikhuthaza ukuzibandakanya komphakathi begodu isekela ukuhlonipha ukuhlukahluka kanye nehlelo lamagugu elisekelwe ekukholweni.Imisebenzi ifakahlangana amasemina afana nesemina yokuphepha kweenkolo eyaba yingcenye yamalanga ali-16 wokulwa ngokudzimelela ekuhlukunyezweni kwabomma ngo-2006.NgoNtaka 2007 u-Efeng Bacha ne-NMCF benza isemina yokuzithwala kwabatjha njengesithomo sephrojekthi yokurhubhulula ngomnqopho wokugcina wokurarulula isitjhijilo sokhu khulelwa kwabatjha. I-Efeng Bacha Youth Club nayo ibandakanyeka nge-Reading Initiative kunye ne-Youth Parliament.

'''Iphalamende yabantwana ka-Nelson Mandela'''

Ihlelo le-Nelson Mandela Children's Parliament (i-NMCP) lasungulwa ukugidinga amagugu,iinkambisolawulo nokuzibophelela kwaka- Nelson Mandela ebantwaneni beSewula Afrika,ngokunikela abantwana amathuba aqakathekileko wokubamba iqhaza,ukunqophisa nokuthonya iinqunto ezenziwa egameni labo namkha ezizuzisa bona. Eminyakeni elitjhumi edlulileko, ukusingathwa kwe-NMCP bekutjhuguluka kizo zoke iimfunda ukwenza ithuba lokuthi abantwana beSewula Afrika bahlanganyele ngokulinganako.

=== Iindlela zokuziphilisa ezisimemeko ===
Iphrojekthi yeendlela zokuziphilisa ezisimemeko zesikhwama (i-SLP)yethulwa ngo-2009 ukuqalana nobuphofu obuhlangabezana nayo imindeni,khulukhulu eendaweni ezikhonjwe ngurhulumende njengeendawo eziqakathekileko. Lezi ziindawo ezinezinga eliphezulu lokutlhogeka kwemisebenzi,ukukhiqiza okuphasi ngebanga lezizathu ezihlukahlukeneko begodu kesinye isikhathi zihlukaniswe malungana nokuthola iinkonzo ezisisekelo.I -SLP ihlose ukuqinisa imindeni nemiphakathi ukujamelana nobujamo bokuba sengozini ngesikhathi kudala ipilo engcono nengomuso elihle labantwana.

I-SLP yenzelwe ukusiza imiphakathi bona iphume ebuphofini ngokukhuthaza amalunga womphakathi bona akhe iinqhema zokuzisiza (ama-SHG).Ama-SHG abandakanyeka emahlelweni wokulondoloza imali nemisebenzi yokwenza imali,godu enza imihlangano ejayelekileko ukuqalana neentjhijilo abaqalene nazo emakhaya nemiphakathini yabo.

== Iinkomba ==
http://www.southafrica.info/mandela/mandelachildrensfund.htm
http://www.sowetogospelfans.com/2009/07/14/sgc-to-perform-at-mandela-day-gala-dinner-and-auction-in-nyc/&lt;nowiki/&gt;http://www.sabc.co.za/news/a1/eee8755de5631310VgnVCM10000077d4ea9bRCRD/Mandela-legacy-canvas-auctioned-off-for-R2.5-million-20110717&lt;nowiki/&gt;http://fab.sa-people.com/2010/08/19/nelson-mandela-childrens-fund-uk-annual-gala-dinner/&lt;nowiki/&gt;http://thephoenix.com/boston/events/85735-nelson-mandela-childrens-fun-benefit/&lt;nowiki/&gt;{{Reflist}}</text>
      <sha1>oonu4bwer952fjkoulepqo9gk3m79uy</sha1>
    </revision>
  </page>
  <page>
    <title>UDorh. Lungile Mabhena</title>
    <ns>0</ns>
    <id>719</id>
    <revision>
      <id>3514</id>
      <timestamp>2025-07-31T20:38:33Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>New article</comment>
      <origin>3514</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4038" sha1="tfpwucqq535g7awuf3sb4go9vtf0jik" xml:space="preserve">[[Isimumathi:Dr. Lungile Mabhena.jpg|thumb|316x316px|UDorh. Lungile Mabhena]]
'''UDorhodere Lungile Monica Mabhena''' ngomunye wabantu abatjha abadlala indima emphakathini wamaNdebele. Umtloli, imbongi, umeluleki wendabuko nonamatalente amanengana kwezobukghwari. Ngaphezu kwalokho ungutitjhere oneziqu ze-''Bachelors of Education,'' begodu wahlonitjhwa nge-''Honorary Doctorate'' ngebanga lendima ayidlalileko emphakathini. Mtloli wokuthoma wemitlolo yesiNdebele ukutjhejwa yi-''Afrika Digital'', bewakhethwa njengembongi ekhamba phambili ku-''Mzansi Art’s and Media Awards'' (MAMA). Wathola isitifiketi seZimbabwe ngebanga lokukhuluma eenkundleni zokuthintana ngesiNdebele.&lt;ref name=&quot;:0&quot;&gt;Precious Mashiane (October 16, 2024), ''Tweefontein poet Lungile Mabhena recognised by iArika digital, nominated for best poet at MAMA.'' Highveld Chronicle website. Retreived from: https://hconline.co.za/tweefontein-poet-lungile-mabhena-recognised-by-iarika-digital-nominated-for-best-poet-at-mama/ Retrieved on 31/07/2025.&lt;/ref&gt;

ULungile Mabhena wabelethelwa endaweni ye-Tweefontein C kwaNdebele, abelethwa nguSamuel Mabhena noJosephine Masombuka ngomhla ka-28 December 1999. Wathoma ukufunda esikolweni samabanga aphasi i-''Hlobisa Primary School,'' nakaqeda waya e-''Sifunda Khona Primary School,'' ngemva kwalokho wayokufunda kwesamabanga aphakemeko i-Siphiwe Combined School, bese waqedelela ngokufunda e-''Vukuzame Secondary School'' okukulapho aqeda khona ukufunda. Ithando lakhe ngokuba yimbongi.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot;&gt;Linkedin (2025) Dr Lungile Mabhena. Retrieved from: https://www.linkedin.com/in/lungile-mabena-4812aa214/?originalSubdomain=za. Retrieved on 31/07/2025.&lt;/ref&gt;

== Iindima Ayidlalako ==
[[Isimumathi:Vukani.png|thumb|318x318px|Incwadi ethi &quot;Vukani Kusile&quot;]]
UDorh. Lungile Mabhena unamatjhaneli eenkundleni zokuthintana aluleka abantu abatjha nabantu baboke ngendlela efaneleko yokwenza amasiko nekambiso yesiNdebele neyesintu okumkhakha abantu abatjha abangatholakali ngobunengi kiwo. Abuye eluleke nangendlela yokuziphatha kwabantu abatjha esikweni. Lokho ukwenza ngitjho nemrhatjhweni. Ngaphezu kwalokho sekunemitlolo abandakanyeke kiyo ethuthukisa ilimi lesiNdebele. Uneenkondlo azitlolileko ezitholakala encwadini ethi Vukani Kusile.&lt;ref name=&quot;:1&quot; /&gt;

Incwadi-le libuthelelo leenkondlo, eziveza ubudisi esizithola siqalana nabo sima-Sewula Afrika. Khumbula bona ukuhlunguphazwa kwabantu bengubo kudlange komlilo wesikhotha lapha enarheni yekhethu, kanti abobaba nabo bavela barhabile bathi nathi silila sona leso isililo sokuhlunguphazwa bomma. Nanyana kunjalo, incwadi le imumethe umlayezo wokubuyisana, ithando nokuzwelana ubuhlungu. Iimbongi nofana abatloli bencwadi le, benze okusemandleni wabo bona umamukelilwazi osebujameni nanyana ngabe ngibuphi azithole sele athobekile nofana akhandeleka. Khulu khulu incwadi le, ithoba nofana ikhandela laba abalandelako: Ababhujelweko, abalahle ithemba, abagulako, abasebenzisa iindakamizwa ngokweqileko. &lt;ref&gt;Epubhlishing and Digital Displays (2025) Books, Retrieved from: https://epublishing.store/products/ Retrieved 30-06-2025.&lt;/ref&gt;

== Nasi imitlomelo atlonyeliswe ngayo ==
[[Isimumathi:Ikhambi Literary Journal.jpg|thumb|Iinkondlo zakhe ezimbili zitholakala kilencwadi ethi Ikhambi]]

* 2008 - Umtlomelo Wokubeka Ikulumo Ekhamba Phambili - ''Award for Best Speech''
* 2011 - Umtlomelo Wokubeka Ikulumo Ekhamba Phambili - ''Award for Best Speech''
* 2024 - ''IsiNdebele Content Writer for Afrika Digital''
* 2024 - Wafunama i-Honorary Doctorate

ULungile Mabhena usibonelo ebantwini abatjha sokudlala indima ekuthuthukiseni umphakathi ngamakghono ahlukahlukeneko.

Nakazikhulumelako uthi: &quot;Ngiyakuthabela ukutlola ngomlando, ilimi, ikolo yesintu namasiko bona ngifundise abantu, ngombana njengama-Afrika sathathelwa ubuthina bethu. Kuqakathekile kimi ukwenza abantu bazi bona bangaphila ngesiko lesi-Afrika, bazihlanganise nekolo yesi-Afrika kunokuthi balahleke emasikweni wakosobani angabasizi ngalitho.&quot;&lt;ref name=&quot;:0&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>tfpwucqq535g7awuf3sb4go9vtf0jik</sha1>
    </revision>
    <revision>
      <id>3515</id>
      <parentid>3514</parentid>
      <timestamp>2025-07-31T20:44:10Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>spelling fix</comment>
      <origin>3515</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3920" sha1="55hqq5qv4lozmt88o9ymbgin4ovloy4" xml:space="preserve">[[Isimumathi:Dr. Lungile Mabhena.jpg|thumb|316x316px|UDorh. Lungile Mabhena]]
'''UDorhodere Lungile Monica Mabhena''' ngomunye wabantu abatjha abadlala indima emphakathini wamaNdebele. Umtloli, imbongi, umeluleki wendabuko nonamatalente amanengana kwezobukghwari. Ngaphezu kwalokho ungutitjhere oneziqu ze-''Bachelors of Education,'' begodu wahlonitjhwa nge-''Honorary Doctorate'' ngebanga lendima ayidlalileko emphakathini. Mtloli wokuthoma wemitlolo yesiNdebele ukutjhejwa yi-''Afrika Digital'', bewakhethwa njengembongi ekhamba phambili ku-''Mzansi Art’s and Media Awards'' (MAMA). Wathola isitifiketi seZimbabwe ngebanga lokukhuluma eenkundleni zokuthintana ngesiNdebele.&lt;ref name=&quot;:0&quot;&gt;Precious Mashiane (October 16, 2024), ''Tweefontein poet Lungile Mabhena recognised by iArika digital, nominated for best poet at MAMA.'' Highveld Chronicle website. Retreived from: https://hconline.co.za/tweefontein-poet-lungile-mabhena-recognised-by-iarika-digital-nominated-for-best-poet-at-mama/ Retrieved on 31/07/2025.&lt;/ref&gt;

ULungile Mabhena wabelethelwa endaweni ye-Tweefontein C kwaNdebele, abelethwa nguSamuel Mabhena noJosephine Masombuka ngomhla ka-28 December 1999. Wathoma ukufunda esikolweni samabanga aphasi i-''Hlobisa Primary School,'' nakaqeda waya e-''Sifunda Khona Primary School,'' ngemva kwalokho wayokufunda kwesamabanga aphakathi i-Siphiwe Combined School, bese waqedelela ngokufunda kwesamabanga aphezulu e-''Vukuzame Secondary School'' okukulapho aqeda khona ukufunda. Ithando lakhe ngokuba yimbongi.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot;&gt;Linkedin (2025) Dr Lungile Mabhena. Retrieved from: https://www.linkedin.com/in/lungile-mabena-4812aa214/?originalSubdomain=za. Retrieved on 31/07/2025.&lt;/ref&gt;

== Iindima Ayidlalako ==
[[Isimumathi:Vukani.png|thumb|318x318px|Incwadi ethi &quot;Vukani Kusile&quot;]]
UDorh. Lungile Mabhena unamatjhaneli eenkundleni zokuthintana aluleka abantu abatjha nabantu baboke ngendlela efaneleko yokwenza amasiko nekambiso yesiNdebele neyesintu, okumkhakha abantu abatjha abangakavami ukutholakali. Abuye eluleke nangendlela yokuziphatha kwabantu abatjha esikweni. Lokho ukwenza ngitjho nemrhatjhweni. Ngaphezu kwalokho sekunemitlolo abandakanyeke kiyo ethuthukisa ilimi lesiNdebele. Uneenkondlo azitlolileko ezitholakala encwadini ethi Vukani Kusile.&lt;ref name=&quot;:1&quot; /&gt;

Incwadi ethi Vukani Kusile libuthelelo leenkondlo, eziveza ubudisi esizithola siqalana nabo sima-Sewula Afrika. Khumbula bona ukuhlunguphazwa kwabantu bengubo kudlange komlilo wesikhotha lapha enarheni yekhethu, kanti abobaba nabo bavela barhabile bathi nathi silila sona leso isililo sokuhlunguphazwa bomma. Nanyana kunjalo, incwadi le imumethe umlayezo wokubuyisana, ithando nokuzwelana ubuhlungu. Iimbongi nofana abatloli bencwadi le, benze okusemandleni wabo bona umamukelilwazi osebujameni nanyana ngabe ngibuphi azithole sele athobekile nofana akhandeleka.  &lt;ref&gt;Epubhlishing and Digital Displays (2025) Books, Retrieved from: https://epublishing.store/products/ Retrieved 30-06-2025.&lt;/ref&gt;

== Nasi imitlomelo atlonyeliswe ngayo ==
[[Isimumathi:Ikhambi Literary Journal.jpg|thumb|Iinkondlo zakhe ezimbili zitholakala kilencwadi ethi Ikhambi]]

* 2008 - Umtlomelo Wokubeka Ikulumo Ekhamba Phambili - ''Award for Best Speech''
* 2011 - Umtlomelo Wokubeka Ikulumo Ekhamba Phambili - ''Award for Best Speech''
* 2024 - ''IsiNdebele Content Writer for Afrika Digital''
* 2024 - Wafunama i-Honorary Doctorate

ULungile Mabhena usibonelo ebantwini abatjha sokudlala indima ekuthuthukiseni umphakathi ngamakghono ahlukahlukeneko.

Nakazikhulumelako uthi: &quot;Ngiyakuthabela ukutlola ngomlando, ilimi, ikolo yesintu namasiko bona ngifundise abantu, ngombana njengama-Afrika sathathelwa ubuthina bethu. Kuqakathekile kimi ukwenza abantu bazi bona bangaphila ngesiko lesi-Afrika, bazihlanganise nekolo yesi-Afrika kunokuthi balahleke emasikweni wakosobani angabasizi ngalitho.&quot;&lt;ref name=&quot;:0&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>55hqq5qv4lozmt88o9ymbgin4ovloy4</sha1>
    </revision>
    <revision>
      <id>3516</id>
      <parentid>3515</parentid>
      <timestamp>2025-07-31T20:45:30Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>3516</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3924" sha1="m6v0r36701qw6tlohhyiybevvvrjqs2" xml:space="preserve">[[Isimumathi:Dr. Lungile Mabhena.jpg|thumb|316x316px|UDorh. Lungile Mabhena]]
'''UDorhodere Lungile Monica Mabhena''' ngomunye wabantu abatjha abadlala indima emphakathini wamaNdebele. Umtloli, imbongi, umeluleki wendabuko nonamatalente amanengana kwezobukghwari. Ngaphezu kwalokho ungutitjhere oneziqu ze-''Bachelors of Education,'' begodu wahlonitjhwa nge-''Honorary Doctorate'' ngebanga lendima ayidlalileko emphakathini. Mtloli wokuthoma wemitlolo yesiNdebele ukutjhejwa yi-''Afrika Digital'', bewakhethwa njengembongi ekhamba phambili ku-''Mzansi Art’s and Media Awards'' (MAMA). Wathola isitifiketi seZimbabwe ngebanga lokukhuluma eenkundleni zokuthintana ngesiNdebele.&lt;ref name=&quot;:0&quot;&gt;Precious Mashiane (October 16, 2024), ''Tweefontein poet Lungile Mabhena recognised by iArika digital, nominated for best poet at MAMA.'' Highveld Chronicle website. Retreived from: https://hconline.co.za/tweefontein-poet-lungile-mabhena-recognised-by-iarika-digital-nominated-for-best-poet-at-mama/ Retrieved on 31/07/2025.&lt;/ref&gt;

ULungile Mabhena wabelethelwa endaweni ye-Tweefontein C kwaNdebele, abelethwa nguSamuel Mabhena noJosephine Masombuka ngomhla ka-28 December 1999. Wathoma ukufunda esikolweni samabanga aphasi i-''Hlobisa Primary School,'' nakaqeda waya e-''Sifunda Khona Primary School,'' ngemva kwalokho wayokufunda kwesamabanga aphakathi i-Siphiwe Combined School, bese waqedelela ngokufunda kwesamabanga aphezulu e-''Vukuzame Secondary School'' okukulapho aqeda khona ukufunda. Ithando lakhe ngokuba yimbongi.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot;&gt;Linkedin (2025) Dr Lungile Mabhena. Retrieved from: https://www.linkedin.com/in/lungile-mabena-4812aa214/?originalSubdomain=za. Retrieved on 31/07/2025.&lt;/ref&gt;

== Iindima Ayidlalako ==
[[Isimumathi:Vukani.png|thumb|318x318px|Incwadi ethi &quot;Vukani Kusile&quot;]]
UDorh. Lungile Mabhena unamatjhaneli eenkundleni zokuthintana aluleka abantu abatjha nabantu baboke ngendlela efaneleko yokwenza amasiko nekambiso yesiNdebele neyesintu, okumkhakha abantu abatjha abangakavami ukutholakali. Abuye eluleke nangendlela yokuziphatha kwabantu abatjha esikweni. Lokho ukwenza ngitjho nemrhatjhweni. Ngaphezu kwalokho sekunemitlolo abandakanyeke kiyo ethuthukisa ilimi lesiNdebele. Uneenkondlo azitlolileko ezitholakala encwadini ethi Vukani Kusile.&lt;ref name=&quot;:1&quot; /&gt;

Incwadi ethi Vukani Kusile libuthelelo leenkondlo, eziveza ubudisi esizithola siqalana nabo sima-Sewula Afrika. Khumbula bona ukuhlunguphazwa kwabantu bengubo kudlange komlilo wesikhotha lapha enarheni yekhethu, kanti abobaba nabo bavela barhabile bathi nathi silila sona leso isililo sokuhlunguphazwa bomma. Nanyana kunjalo, incwadi le imumethe umlayezo wokubuyisana, ithando nokuzwelana ubuhlungu. Iimbongi nofana abatloli bencwadi le, benze okusemandleni wabo bona umamukelilwazi osebujameni nanyana ngabe ngibuphi azithole sele athobekile nofana akhandeleka.  &lt;ref&gt;Epubhlishing and Digital Displays (2025) Books, Retrieved from: https://epublishing.store/products/ Retrieved 30-06-2025.&lt;/ref&gt;

== Nasi imitlomelo atlonyeliswe ngayo ==
[[Isimumathi:Ikhambi Literary Journal.jpg|thumb|Iinkondlo zakhe ezimbili zitholakala kilencwadi ethi Ikhambi]]

* 2008 - Umtlomelo Wokubeka Ikulumo Ekhamba Phambili - ''Award for Best Speech''
* 2011 - Umtlomelo Wokubeka Ikulumo Ekhamba Phambili - ''Award for Best Speech''
* 2024 - ''IsiNdebele Content Writer for Afrika Digital''
* 2024 - Wafunama i-''Honorary Doctorate''

ULungile Mabhena usibonelo ebantwini abatjha sokudlala indima ekuthuthukiseni umphakathi ngamakghono ahlukahlukeneko.

Nakazikhulumelako uthi: &quot;Ngiyakuthabela ukutlola ngomlando, ilimi, ikolo yesintu namasiko bona ngifundise abantu, ngombana njengama-Afrika sathathelwa ubuthina bethu. Kuqakathekile kimi ukwenza abantu bazi bona bangaphila ngesiko lesi-Afrika, bazihlanganise nekolo yesi-Afrika kunokuthi balahleke emasikweni wakosobani angabasizi ngalitho.&quot;&lt;ref name=&quot;:0&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>m6v0r36701qw6tlohhyiybevvvrjqs2</sha1>
    </revision>
    <revision>
      <id>3517</id>
      <parentid>3516</parentid>
      <timestamp>2025-07-31T20:46:12Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>3517</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3922" sha1="nwiwbi04ia2syf8zn7rsskyi1hdf5jf" xml:space="preserve">[[Isimumathi:Dr. Lungile Mabhena.jpg|thumb|316x316px|UDorh. Lungile Mabhena]]
'''UDorhodere Lungile Monica Mabhena''' ngomunye wabantu abatjha abadlala indima emphakathini wamaNdebele. Umtloli, imbongi, umeluleki wendabuko nonamatalente amanengana kwezobukghwari. Ngaphezu kwalokho ungutitjhere oneziqu ze-''Bachelors of Education,'' begodu wahlonitjhwa nge-''Honorary Doctorate'' ngebanga lendima ayidlalileko emphakathini. Mtloli wokuthoma wemitlolo yesiNdebele ukutjhejwa yi-''Afrika Digital'', bewakhethwa njengembongi ekhamba phambili ku-''Mzansi Art’s and Media Awards'' (MAMA). Wathola isitifiketi seZimbabwe ngebanga lokukhuluma eenkundleni zokuthintana ngesiNdebele.&lt;ref name=&quot;:0&quot;&gt;Precious Mashiane (October 16, 2024), ''Tweefontein poet Lungile Mabhena recognised by iArika digital, nominated for best poet at MAMA.'' Highveld Chronicle website. Retreived from: https://hconline.co.za/tweefontein-poet-lungile-mabhena-recognised-by-iarika-digital-nominated-for-best-poet-at-mama/ Retrieved on 31/07/2025.&lt;/ref&gt;

ULungile Mabhena wabelethelwa endaweni ye-Tweefontein C kwaNdebele, abelethwa nguSamuel Mabhena noJosephine Masombuka ngomhla ka-28 December 1999. Wathoma ukufunda esikolweni samabanga aphasi i-''Hlobisa Primary School,'' nakaqeda waya e-''Sifunda Khona Primary School,'' ngemva kwalokho wayokufunda kwesamabanga aphakathi i-Siphiwe Combined School, bese waqedelela ngokufunda kwesamabanga aphezulu e-''Vukuzame Secondary School'' okukulapho aqeda khona ukufunda. Ithando lakhe ngokuba yimbongi.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot;&gt;Linkedin (2025) Dr Lungile Mabhena. Retrieved from: https://www.linkedin.com/in/lungile-mabena-4812aa214/?originalSubdomain=za. Retrieved on 31/07/2025.&lt;/ref&gt;

== Iindima Ayidlalako ==
[[Isimumathi:Vukani.png|thumb|318x318px|Incwadi ethi &quot;Vukani Kusile&quot;]]
UDorh. Lungile Mabhena unamatjhaneli eenkundleni zokuthintana aluleka abantu abatjha nabantu baboke ngendlela efaneleko yokwenza amasiko nekambiso yesiNdebele neyesintu, okumkhakha abantu abatjha abangakavami ukutholakali. Abuye eluleke nangendlela yokuziphatha kwabantu abatjha esikweni. Lokho ukwenza ngitjho nemrhatjhweni. Ngaphezu kwalokho sekunemitlolo abandakanyeke kiyo ethuthukisa ilimi lesiNdebele. Uneenkondlo azitlolileko ezitholakala encwadini ethi Vukani Kusile.&lt;ref name=&quot;:1&quot; /&gt;

Incwadi ethi Vukani Kusile libuthelelo leenkondlo, eziveza ubudisi esizithola siqalana nabo sima-Sewula Afrika. Khumbula bona ukuhlunguphazwa kwabantu bengubo kudlange komlilo wesikhotha lapha enarheni yekhethu, kanti abobaba nabo bavela barhabile bathi nathi silila sona leso isililo sokuhlunguphazwa bomma. Nanyana kunjalo, incwadi le imumethe umlayezo wokubuyisana, ithando nokuzwelana ubuhlungu. Iimbongi nofana abatloli bencwadi le, benze okusemandleni wabo bona umamukelilwazi osebujameni nanyana ngabe ngibuphi azithole sele athobekile nofana akhandeleka.&lt;ref&gt;Epubhlishing and Digital Displays (2025) Books, Retrieved from: https://epublishing.store/products/ Retrieved 30-06-2025.&lt;/ref&gt;

== Nasi imitlomelo atlonyeliswe ngayo ==
[[Isimumathi:Ikhambi Literary Journal.jpg|thumb|Iinkondlo zakhe ezimbili zitholakala kilencwadi ethi Ikhambi]]

* 2008 - Umtlomelo Wokubeka Ikulumo Ekhamba Phambili - ''Award for Best Speech''
* 2011 - Umtlomelo Wokubeka Ikulumo Ekhamba Phambili - ''Award for Best Speech''
* 2024 - ''IsiNdebele Content Writer for Afrika Digital''
* 2024 - Wafunama i-''Honorary Doctorate''

ULungile Mabhena usibonelo ebantwini abatjha sokudlala indima ekuthuthukiseni umphakathi ngamakghono ahlukahlukeneko.

Nakazikhulumelako uthi: &quot;Ngiyakuthabela ukutlola ngomlando, ilimi, ikolo yesintu namasiko bona ngifundise abantu, ngombana njengama-Afrika sathathelwa ubuthina bethu. Kuqakathekile kimi ukwenza abantu bazi bona bangaphila ngesiko lesi-Afrika, bazihlanganise nekolo yesi-Afrika kunokuthi balahleke emasikweni wakosobani angabasizi ngalitho.&quot;&lt;ref name=&quot;:0&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>nwiwbi04ia2syf8zn7rsskyi1hdf5jf</sha1>
    </revision>
    <revision>
      <id>3525</id>
      <parentid>3517</parentid>
      <timestamp>2025-08-01T10:48:42Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>spelling fix</comment>
      <origin>3525</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3912" sha1="eqcu7uua0wmfydo4p89gpdtff3qsjd3" xml:space="preserve">[[Isimumathi:Dr. Lungile Mabhena.jpg|thumb|316x316px|UDorh. Lungile Mabhena]]
'''ULungile Monica Mabhena''' ngomunye wabantu abatjha abadlala indima emphakathini wamaNdebele. Umtloli, imbongi, umeluleki wendabuko nonamatalente amanengana kwezobukghwari. Ngaphezu kwalokho ungutitjhere oneziqu ze-''Bachelors of Education,'' begodu wahlonitjhwa nge-''Honorary Doctorate'' ngebanga lendima ayidlalileko emphakathini. Mtloli wokuthoma wemitlolo yesiNdebele ukutjhejwa yi-''Afrika Digital'', bewakhethwa njengembongi ekhamba phambili ku-''Mzansi Art’s and Media Awards'' (MAMA). Wathola isitifiketi seZimbabwe ngebanga lokukhuluma eenkundleni zokuthintana ngesiNdebele.&lt;ref name=&quot;:0&quot;&gt;Precious Mashiane (October 16, 2024), ''Tweefontein poet Lungile Mabhena recognised by iArika digital, nominated for best poet at MAMA.'' Highveld Chronicle website. Retreived from: https://hconline.co.za/tweefontein-poet-lungile-mabhena-recognised-by-iarika-digital-nominated-for-best-poet-at-mama/ Retrieved on 31/07/2025.&lt;/ref&gt;

ULungile Mabhena wabelethelwa endaweni ye-Tweefontein C kwaNdebele, abelethwa nguSamuel Mabhena noJosephine Masombuka ngomhla ka-28 December 1999. Wathoma ukufunda esikolweni samabanga aphasi i-''Hlobisa Primary School,'' nakaqeda waya e-''Sifunda Khona Primary School,'' ngemva kwalokho wayokufunda kwesamabanga aphakathi i-Siphiwe Combined School, bese waqedelela ngokufunda kwesamabanga aphezulu e-''Vukuzame Secondary School'' okukulapho aqeda khona ukufunda. Ithando lakhe ngokuba yimbongi.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot;&gt;Linkedin (2025) Dr Lungile Mabhena. Retrieved from: https://www.linkedin.com/in/lungile-mabena-4812aa214/?originalSubdomain=za. Retrieved on 31/07/2025.&lt;/ref&gt;

== Iindima Ayidlalako ==
[[Isimumathi:Vukani.png|thumb|318x318px|Incwadi ethi &quot;Vukani Kusile&quot;]]
UDorh. Lungile Mabhena unamatjhaneli eenkundleni zokuthintana aluleka abantu abatjha nabantu baboke ngendlela efaneleko yokwenza amasiko nekambiso yesiNdebele neyesintu, okumkhakha abantu abatjha abangakavami ukutholakali. Abuye eluleke nangendlela yokuziphatha kwabantu abatjha esikweni. Lokho ukwenza ngitjho nemrhatjhweni. Ngaphezu kwalokho sekunemitlolo abandakanyeke kiyo ethuthukisa ilimi lesiNdebele. Uneenkondlo azitlolileko ezitholakala encwadini ethi Vukani Kusile.&lt;ref name=&quot;:1&quot; /&gt;

Incwadi ethi Vukani Kusile libuthelelo leenkondlo, eziveza ubudisi esizithola siqalana nabo sima-Sewula Afrika. Khumbula bona ukuhlunguphazwa kwabantu bengubo kudlange komlilo wesikhotha lapha enarheni yekhethu, kanti abobaba nabo bavela barhabile bathi nathi silila sona leso isililo sokuhlunguphazwa bomma. Nanyana kunjalo, incwadi le imumethe umlayezo wokubuyisana, ithando nokuzwelana ubuhlungu. Iimbongi nofana abatloli bencwadi le, benze okusemandleni wabo bona umamukelilwazi osebujameni nanyana ngabe ngibuphi azithole sele athobekile nofana akhandeleka.&lt;ref&gt;Epubhlishing and Digital Displays (2025) Books, Retrieved from: https://epublishing.store/products/ Retrieved 30-06-2025.&lt;/ref&gt;

== Nasi imitlomelo atlonyeliswe ngayo ==
[[Isimumathi:Ikhambi Literary Journal.jpg|thumb|Iinkondlo zakhe ezimbili zitholakala kilencwadi ethi Ikhambi]]

* 2008 - Umtlomelo Wokubeka Ikulumo Ekhamba Phambili - ''Award for Best Speech''
* 2011 - Umtlomelo Wokubeka Ikulumo Ekhamba Phambili - ''Award for Best Speech''
* 2024 - ''IsiNdebele Content Writer for Afrika Digital''
* 2024 - Wafunama i-''Honorary Doctorate''

ULungile Mabhena usibonelo ebantwini abatjha sokudlala indima ekuthuthukiseni umphakathi ngamakghono ahlukahlukeneko.

Nakazikhulumelako uthi: &quot;Ngiyakuthabela ukutlola ngomlando, ilimi, ikolo yesintu namasiko bona ngifundise abantu, ngombana njengama-Afrika sathathelwa ubuthina bethu. Kuqakathekile kimi ukwenza abantu bazi bona bangaphila ngesiko lesi-Afrika, bazihlanganise nekolo yesi-Afrika kunokuthi balahleke emasikweni wakosobani angabasizi ngalitho.&quot;&lt;ref name=&quot;:0&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>eqcu7uua0wmfydo4p89gpdtff3qsjd3</sha1>
    </revision>
    <revision>
      <id>3545</id>
      <parentid>3525</parentid>
      <timestamp>2025-08-05T12:21:46Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>speliing fix</comment>
      <origin>3545</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3907" sha1="ok1qi1cc5q8uz751ryr6q259jkbwr75" xml:space="preserve">[[Isimumathi:ISITHOMBE.jpg|thumb|303x303px|ULungile Mabhena]]
'''ULungile Monica Mabhena''' ngomunye wabantu abatjha abadlala indima emphakathini wamaNdebele. Umtloli, imbongi, umeluleki wendabuko nonamatalente amanengana kwezobukghwari. Ngaphezu kwalokho ungutitjhere oneziqu ze-''Bachelors of Education,'' begodu wahlonitjhwa nge-''Honorary Doctorate'' ngebanga lendima ayidlalileko emphakathini. Mtloli wokuthoma wemitlolo yesiNdebele ukutjhejwa yi-''Afrika Digital'', bewakhethwa njengembongi ekhamba phambili ku-''Mzansi Art’s and Media Awards'' (MAMA). Wathola isitifiketi seZimbabwe ngebanga lokukhuluma eenkundleni zokuthintana ngesiNdebele.&lt;ref name=&quot;:0&quot;&gt;Precious Mashiane (October 16, 2024), ''Tweefontein poet Lungile Mabhena recognised by iArika digital, nominated for best poet at MAMA.'' Highveld Chronicle website. Retreived from: https://hconline.co.za/tweefontein-poet-lungile-mabhena-recognised-by-iarika-digital-nominated-for-best-poet-at-mama/ Retrieved on 31/07/2025.&lt;/ref&gt; 

ULungile Mabhena wabelethelwa endaweni ye-Tweefontein C kwaNdebele, abelethwa nguSamuel Mabhena noJosephine Masombuka ngomhla ka-28 December 1999. Wathoma ukufunda esikolweni samabanga aphasi i-''Hlobisa Primary School,'' nakaqeda waya e-''Sifunda Khona Primary School,'' ngemva kwalokho wayokufunda kwesamabanga aphakathi i-Siphiwe Combined School, bese waqedelela ngokufunda kwesamabanga aphezulu e-''Vukuzame Secondary School'' okukulapho aqeda khona ukufunda. Ithando lakhe ngokuba yimbongi.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot;&gt;Linkedin (2025) Dr Lungile Mabhena. Retrieved from: https://www.linkedin.com/in/lungile-mabena-4812aa214/?originalSubdomain=za. Retrieved on 31/07/2025.&lt;/ref&gt;

== Iindima Ayidlalako ==
[[Isimumathi:Vukani.png|thumb|318x318px|Incwadi ethi &quot;Vukani Kusile&quot;]]
UDorh. Lungile Mabhena unamatjhaneli eenkundleni zokuthintana aluleka abantu abatjha nabantu baboke ngendlela efaneleko yokwenza amasiko nekambiso yesiNdebele neyesintu, okumkhakha abantu abatjha abangakavami ukutholakali. Abuye eluleke nangendlela yokuziphatha kwabantu abatjha esikweni. Lokho ukwenza ngitjho nemrhatjhweni. Ngaphezu kwalokho sekunemitlolo abandakanyeke kiyo ethuthukisa ilimi lesiNdebele. Uneenkondlo azitlolileko ezitholakala encwadini ethi Vukani Kusile.&lt;ref name=&quot;:1&quot; /&gt;

Incwadi ethi Vukani Kusile libuthelelo leenkondlo, eziveza ubudisi esizithola siqalana nabo sima-Sewula Afrika. Khumbula bona ukuhlunguphazwa kwabantu bengubo kudlange komlilo wesikhotha lapha enarheni yekhethu, kanti abobaba nabo bavela barhabile bathi nathi silila sona leso isililo sokuhlunguphazwa bomma. Nanyana kunjalo, incwadi le imumethe umlayezo wokubuyisana, ithando nokuzwelana ubuhlungu. Iimbongi nofana abatloli bencwadi le, benze okusemandleni wabo bona umamukelilwazi osebujameni nanyana ngabe ngibuphi azithole sele athobekile nofana akhandeleka.&lt;ref&gt;Epubhlishing and Digital Displays (2025) Books, Retrieved from: https://epublishing.store/products/ Retrieved 30-06-2025.&lt;/ref&gt;

== Nasi imitlomelo atlonyeliswe ngayo ==
[[Isimumathi:Ikhambi Literary Journal.jpg|thumb|Iinkondlo zakhe ezimbili zitholakala kilencwadi ethi Ikhambi|279x279px]]

* 2008 - Umtlomelo Wokubeka Ikulumo Ekhamba Phambili - ''Award for Best Speech''
* 2011 - Umtlomelo Wokubeka Ikulumo Ekhamba Phambili - ''Award for Best Speech''
* 2024 - ''IsiNdebele Content Writer for Afrika Digital''
* 2024 - Wafunama i-''Honorary Doctorate''

ULungile Mabhena usibonelo ebantwini abatjha sokudlala indima ekuthuthukiseni umphakathi ngamakghono ahlukahlukeneko.

Nakazikhulumelako uthi: &quot;Ngiyakuthabela ukutlola ngomlando, ilimi, ikolo yesintu namasiko bona ngifundise abantu, ngombana njengama-Afrika sathathelwa ubuthina bethu. Kuqakathekile kimi ukwenza abantu bazi bona bangaphila ngesiko lesi-Afrika, bazihlanganise nekolo yesi-Afrika kunokuthi balahleke emasikweni wakosobani angabasizi ngalitho.&quot;&lt;ref name=&quot;:0&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>ok1qi1cc5q8uz751ryr6q259jkbwr75</sha1>
    </revision>
  </page>
  <page>
    <title>Ukugula Kwengqondo</title>
    <ns>0</ns>
    <id>720</id>
    <revision>
      <id>3519</id>
      <timestamp>2025-07-31T21:19:45Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <comment>Created page with &quot;[[Isimumathi:Depression-loss of loved one.jpg|thumb|Ukugula Kwengqondo]] '''Ukugula kwengqondo''' (''Mental Disoder'') libuthelelo lokugula kwengqondo okuhlukahlukeneko, okungaba kuhlangahlangana emcabangweni, emizweni, endleleni umutu aqala ngayo izinto nekuziphatheni kwakhe. Ukugula komkhumbulo kungabangela umuntu bona agandeleleke namkha atshwenyeke ngokudluleleko, abone, ezwe izinto ezingekho bese lokho kuthinte nomsebenzi wakhe wokuziphilisa kuhlanganise nomdenakhe....&quot;</comment>
      <origin>3519</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3934" sha1="7e8esa7p49ghttvhnqx710dcs2vkh68" xml:space="preserve">[[Isimumathi:Depression-loss of loved one.jpg|thumb|Ukugula Kwengqondo]]
'''Ukugula kwengqondo''' (''Mental Disoder'') libuthelelo lokugula kwengqondo okuhlukahlukeneko, okungaba kuhlangahlangana emcabangweni, emizweni, endleleni umutu aqala ngayo izinto nekuziphatheni kwakhe. Ukugula komkhumbulo kungabangela umuntu bona agandeleleke namkha atshwenyeke ngokudluleleko, abone, ezwe izinto ezingekho bese lokho kuthinte nomsebenzi wakhe wokuziphilisa kuhlanganise nomdenakhe. Ukugulokhu kujayeleke khulu begodu kungaphatha nanyana ngubani, kungakhathaliseki bona umumuntu wengubo nofana omduna. Akukhethi bona unemali nofana awa.&lt;ref name=&quot;:0&quot;&gt;American Psychiatry Association (2025) What is mental illness? Retrieved from: https://www.psychiatry.org/patients-families/what-is-mental-illness.  Retrieved on 31/07/2025.&lt;/ref&gt;

== Imihlobo Yokugula Kwengqondo ==
Ukugula kwengqondo kuhlukaniswe nganasi indlela:

* Ukutshwenyeka Ngokudluleleko. Ukugula lokhu kuhlanganisa ukuthukwa khulu nanokutshwenyeka khulu ngezinto ezizokwenzeka namkha ngezinto afuna zenzeke.
* Ukugandeleleka. Ukugula lokhu kwenza umuntu agandeleleke khulu, khulukhulu ngezinto ezenzeke esikhathini esidlulileko,  azizwe angakathabi, angakhanuki ukwenza litho, bekuthinte nendlela alala nadla ngayo.
* Ukutjhugutjhuguluka kwemizwa. Ukugula lokhu kwenza umuntu atjhugulule imizwa yakhe qobe sikhathi. Angathaba khulu godu ngokuphazima kwelihlo azizwe adane khulu.
* Ukuhlanya. Ukukhubazeka kwengqondo okubangela umuntu abone izinto ezibonwa nguye yedwa, bekezwa nemidumo ezwiwa nguye yedwa, namkha abe nomuzwa wokuthinta izinto ezingekho.
* Ukungadli ngendlela efaneleko. Ukuthikaziseka kwengqondo okubangela umuntu angadli ngendlela efaneleko bese kuthinte indlela umuntu aqaleka ngayo.
* Ukusebenzisa kumbi iindakamizwa. Ukuphazamiseka kwengqondo okukwenza ungasakhoni ukuphila ngaphandle kotshwala neendakamizwa.&lt;ref name=&quot;:1&quot;&gt;World Health Organisation (8 June 2022) ''Mental Disoders.'' Retrieved from: https://www.who.int/news-room/fact-sheets/detail/mental-disorders. Retrieved on 31/07/2025&lt;/ref&gt;

== Ongakwenza nange uqalene Nokhunye Kokugula Okubaliweko ==

* ''Rhaba ufune isizo zisuka'': Kuqakatheke khulu ukurhaba ufune isizo nange ubona amatshwayo wokugula nofana kungeze kwakuqeda ukugula lokho kodwana kungenza uthole imitjhoga etlhogekako msinyana.

* ''Thola imitjhoga ekhambelana nawe'': Amagulo la awafani yeke kuqakatheke khulu ukuthola imitjhoga ekhambelana nokugula okuphethe wena mathupha.

* ''Thola isekelo'': Kuqakatheke khulu ukuba nesekelo kungathaliseki bone livela kubangani nofana emdenini. Ukuthola ilwazi elinengi ngendlela ongakghona ngayo ngokugulokhu kungaba lirhelebho elikhulu.&lt;ref&gt;Mayo Clinic (2025) Mental Illness - Symptoms-causes. Retrieved from: https://www.mayoclinic.org/diseases-conditions/mental-illness/symptoms-causes/syc-20374968. Retrieved on 31/07/2025.&lt;/ref&gt;

== Okufuze Ukwazi Ngokugula Kwengqondo ==
Okokuthona okufuze ukwazi ngabantu abaqalene nokugula kwengqondo ukuthi bakuthola kubudisi ukuqalana nezinto ekufuze zenziwe ilanga nelanga. Abanye bakuthola kubudisi ukubulunga ubudlelwane obuhle nabangani nofana umndeni. Abanye bakuthola kubudisi ukwenza umsebenzi wabo wokuziphilisa nofana ukwenza umsebenzi wesikolo nange bafunda. Ukugula loku kwenza ukuphila kwaqobe langa kube budisi.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;

Okwesibili kukuthi ukugula lokhu abe akusilo ihlazo kungaphatha nanyana ngubani, yeke akukafuzi uzizwe unamahloni bewusabe nokufuna irhelebho. Ukufuna kwakho irhelebho kuzobe kutjengisa ukuhlakanipha nokuhluzeka. Akukafuzi uphathwe ziinhloni, banengi tle abantu abaphila nokugula kwengqondo.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;

Okwamaswaphela ukuthi ikhona imitjhoga namapilisi ongayisebenzisa begodu bakhona nabodorhodera abasebenza ngokugula kwengqondo. Kuqakatheke khulu ukuba nabantu abazokusekela bebazwisise ukugula oqalane nakho.&lt;ref name=&quot;:1&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>7e8esa7p49ghttvhnqx710dcs2vkh68</sha1>
    </revision>
  </page>
  <page>
    <title>Ukutshwenyeka Ngokudluleleko</title>
    <ns>0</ns>
    <id>721</id>
    <revision>
      <id>3520</id>
      <timestamp>2025-07-31T21:54:42Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <comment>New article</comment>
      <origin>3520</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2322" sha1="gspq97n2s6m1rr2ht7aytogdc808gax" xml:space="preserve">Ukutshwenyeka mumuzwa ovamileko wokutshwenyeka, ukuhlangahlangana nokungahlaliseki. Umuzwa lo ungaba lisizo kobunye ubujamo, njengokusiyelelisa engozini. Nanyana kunjalo ukutshwenyeka ngokudluleleko (anxiety) kukwesaba okudluleleko namkha ukutshwenyeka khulu okungaliya ipilwakho. Ukugulokhu kuyalapheka ngeteraphi nangemitjhoga. Ukutshwenyeka ngokudluleleko kungaziveza ngamatshwayo abonakalako, njengalokha ihliziyo nayibetha khulu, ukujuluka, ukuqhaqhazela, kunye nemizwa ekhambisana nokutshwenyeka khulu, nobudisi bokudzimelela kilokho okwenzako.

== Amatshwayo Wokutshwenyeka Ngokudluleleko ==
Amatshwayo avamileko wokutshwenyeka okudluleleko abandakanya naku okulandelako:

* Ukuzizwa uhlangahlangene, ungakahlaliseki ungakatjhaphuluki.
* Ukuzizwa ngasuthi kunengozi ezako, ukutjharagana.
* Ukubethela phezulu kwehliziyo.
* Ukuphefumula msinya.
* Ukujuluka.
* Ukuqhaqhazela.
* Ukuzizwa udiniwe ungenamdlandla.
* Ukungakghoni ukudzimelela kilokho okwenzako ngaphandle kokutshwenyeka.
* Ukungakghoni kuhle ukulala.
* Ukukhanjiswa yisisu nokuluma emathunjini.
* Ukuba budisi ukulawula ukutshwenyeka kwakho.
* Ukuba omuzwa wokufuna ukubalekela izinto ezikutshwenyako.

== Ongakwenza Nawutshwenyeke Ngokudluleleko ==
Ngokwewebhusayidi ye-Mayo Clinic, kunezinto ongazenza nawuqalene nokugulokhu.

# Balekela utjwala neendakamizwa. Izintwezi zingabhebhedlhisa ubujamo kunokuthi zibenze bube ngcono. Nangabe awukghoni ukuzilisa izintwezi tjhinga kezamaphilo namkha uthole isiqhema esisekela abantu abafuna ukulisa utjwala needakamizwa.
# Idla ukudla okunepilo. Ukudla okunepilo okungaba mirorho, iinthelo, ukudla okuziinthoro nefesi kungehlisa ukutshwenyeka khulu.
# Zazi izinto ezingakwenza utshwenyeke khulu. Funda ngobujamo nangezenzo ezingakwenza ugandeleleke namkha zikhuphule ukutshwenyeka kwakho ngokudluleleko. Zifundise iindledlana zokuthuthukisa ipilwehle yengqondo etjhiwe ngudorhoderakho wengqondo khona uzokukghona ukuqalana nemizwa le.
# Hlala uzibandula emzimbeni. Zibekele ihlelo lokuzibandula emzimbeni  amalanga amanengana evekeni. Ukuzibandula kunamandla ekwehliseni ukutshwenyeka ngokudluleleko, kukwenze uzizwe kamnandi uhlale uphilile.
# Funda ngokugula kwakho kwengqondo Khuluma nesiqhema sezamaphilo uthole bona yini le ekubangela bona utshwenyeke ngokudluleleko nemitjhoga neteraphi engakusebenzela.</text>
      <sha1>gspq97n2s6m1rr2ht7aytogdc808gax</sha1>
    </revision>
    <revision>
      <id>3521</id>
      <parentid>3520</parentid>
      <timestamp>2025-07-31T22:11:13Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <origin>3521</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3265" sha1="bcui5ng823vch1hy1f6qs3njhsvu26q" xml:space="preserve">[[Isimumathi:Reflection3.jpg|thumb|Ukutshwenyeka Ngokudluleleko kungakuthathela ithabo]]
'''Ukutshwenyeka''' mumuzwa ovamileko wokutshwenyeka, ukuhlangahlangana nokungahlaliseki. Umuzwa lo ungaba lisizo kobunye ubujamo, njengokusiyelelisa engozini. Nanyana kunjalo ukutshwenyeka ngokudluleleko (anxiety) kukwesaba okudluleleko namkha ukutshwenyeka khulu okungaliya ipilwakho. Ukugulokhu kuyalapheka ngeteraphi nangemitjhoga. Ukutshwenyeka ngokudluleleko kungaziveza ngamatshwayo abonakalako, njengalokha ihliziyo nayibetha khulu, ukujuluka, ukuqhaqhazela, kunye nemizwa ekhambisana nokutshwenyeka khulu, nobudisi bokudzimelela kilokho okwenzako.&lt;ref&gt;Cleveland Clinic (2025) Anxiety Disorders. Retrieved from: https://my.clevelandclinic.org/health/diseases/9536-anxiety-disorders. Retrieved on 31/07/2025.&lt;/ref&gt;

== Amatshwayo Wokutshwenyeka Ngokudluleleko ==
Amatshwayo avamileko wokutshwenyeka okudluleleko abandakanya naku okulandelako:

* Ukuzizwa uhlangahlangene, ungakahlaliseki ungakatjhaphuluki.
* Ukuzizwa ngasuthi kunengozi ezako, ukutjharagana.
* Ukubethela phezulu kwehliziyo.
* Ukuphefumula msinya.
* Ukujuluka.
* Ukuqhaqhazela.
* Ukuzizwa udiniwe ungenamdlandla.
* Ukungakghoni ukudzimelela kilokho okwenzako ngaphandle kokutshwenyeka.
* Ukungakghoni kuhle ukulala.
* Ukukhanjiswa yisisu nokuluma emathunjini.
* Ukuba budisi ukulawula ukutshwenyeka kwakho.
* Ukuba omuzwa wokufuna ukubalekela izinto ezikutshwenyako.&lt;ref&gt;Adam Felman (June, 24, 2025) ''What to know about anxiety.'' Retrieved from: https://www.medicalnewstoday.com/articles/323454. Retreived on 31/07/2025.&lt;/ref&gt;

== Ongakwenza Nawutshwenyeke Ngokudluleleko ==
Ngokwewebhusayidi ye-Mayo Clinic, kunezinto ongazenza nawuqalene nokugulokhu.

# Balekela utjwala neendakamizwa. Izintwezi zingabhebhedlhisa ubujamo kunokuthi zibenze bube ngcono. Nangabe awukghoni ukuzilisa izintwezi tjhinga kezamaphilo namkha uthole isiqhema esisekela abantu abafuna ukulisa utjwala needakamizwa.
# Idla ukudla okunepilo. Ukudla okunepilo okungaba mirorho, iinthelo, ukudla okuziinthoro nefesi kungehlisa ukutshwenyeka khulu.
# Zazi izinto ezingakwenza utshwenyeke khulu. Funda ngobujamo nangezenzo ezingakwenza ugandeleleke namkha zikhuphule ukutshwenyeka kwakho ngokudluleleko. Zifundise iindledlana zokuthuthukisa ipilwehle yengqondo etjhiwe ngudorhoderakho wengqondo khona uzokukghona ukuqalana nemizwa le.
# Hlala uzibandula emzimbeni. Zibekele ihlelo lokuzibandula emzimbeni  amalanga amanengana evekeni. Ukuzibandula kunamandla ekwehliseni ukutshwenyeka ngokudluleleko, kukwenze uzizwe kamnandi uhlale uphilile.
# Funda ngokugula kwakho kwengqondo Khuluma nesiqhema sezamaphilo uthole bona yini le ekubangela bona utshwenyeke ngokudluleleko nemitjhoga neteraphi engakusebenzela.&lt;ref name=&quot;:0&quot;&gt;Mayo Clinic (October 4, 2024) ''11 tips for coping with an anxiety disorder.'' Retrieved from: https://www.mayoclinichealthsystem.org/hometown-health/speaking-of-health/11-tips-for-coping-with-an-anxiety-disorder. Retrieved 31/07/2025.&lt;/ref&gt;
Ukutshwenyeka kungenzeka kungakhambi khona ngokwako begodu kungathuwelela isikhathi nasikhambako nangabe umuntu akalifuni isizo. Yeke kungaba kuhle bona umuntu abone abodorhodere bengqondo ngaphambi kobana ukutshwenyeka ngokudluleleko kuthuwelele.&lt;ref name=&quot;:0&quot; /&gt;</text>
      <sha1>bcui5ng823vch1hy1f6qs3njhsvu26q</sha1>
    </revision>
    <revision>
      <id>3522</id>
      <parentid>3521</parentid>
      <timestamp>2025-07-31T22:12:30Z</timestamp>
      <contributor>
        <username>Orrora</username>
        <id>587</id>
      </contributor>
      <origin>3522</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3272" sha1="g03oo0hht8lcasii5eqmrho3ysdzrtk" xml:space="preserve">[[Isimumathi:Reflection3.jpg|thumb|Ukutshwenyeka Ngokudluleleko kungakuthathela ithabo]]
'''Ukutshwenyeka''' mumuzwa ovamileko wokutshwenyeka, ukuhlangahlangana nokungahlaliseki. Umuzwa lo ungaba lisizo kobunye ubujamo, njengokusiyelelisa engozini. Nanyana kunjalo ukutshwenyeka ngokudluleleko (anxiety) kukwesaba okudluleleko namkha ukutshwenyeka khulu okungaliya ipilwakho. Ukugulokhu kuyalapheka ngeteraphi nangemitjhoga. Ukutshwenyeka ngokudluleleko kungaziveza ngamatshwayo abonakalako, njengalokha ihliziyo nayibetha khulu, ukujuluka, ukuqhaqhazela, kunye nemizwa ekhambisana nokutshwenyeka khulu, nobudisi bokudzimelela kilokho okwenzako.&lt;ref&gt;Cleveland Clinic (2025) Anxiety Disorders. Retrieved from: https://my.clevelandclinic.org/health/diseases/9536-anxiety-disorders. Retrieved on 31/07/2025.&lt;/ref&gt;

== Amatshwayo Wokutshwenyeka Ngokudluleleko ==
Amatshwayo avamileko wokutshwenyeka okudluleleko abandakanya naku okulandelako:

* Ukuzizwa uhlangahlangene, ungakahlaliseki namkha ungakatjhaphuluki.
* Ukuzizwa ngasuthi kunengozi ezako, ukutjharagana.
* Ukubethela phezulu kwehliziyo.
* Ukuphefumula msinya.
* Ukujuluka.
* Ukuqhaqhazela.
* Ukuzizwa udiniwe ungenamdlandla.
* Ukungakghoni ukudzimelela kilokho okwenzako ngaphandle kokutshwenyeka.
* Ukungakghoni kuhle ukulala.
* Ukukhanjiswa yisisu nokuluma emathunjini.
* Ukuba budisi ukulawula ukutshwenyeka kwakho.
* Ukuba omuzwa wokufuna ukubalekela izinto ezikutshwenyako.&lt;ref&gt;Adam Felman (June, 24, 2025) ''What to know about anxiety.'' Retrieved from: https://www.medicalnewstoday.com/articles/323454. Retreived on 31/07/2025.&lt;/ref&gt;

== Ongakwenza Nawutshwenyeke Ngokudluleleko ==
Ngokwewebhusayidi ye-Mayo Clinic, kunezinto ongazenza nawuqalene nokugulokhu.

# Balekela utjwala neendakamizwa. Izintwezi zingabhebhedlhisa ubujamo kunokuthi zibenze bube ngcono. Nangabe awukghoni ukuzilisa izintwezi tjhinga kezamaphilo namkha uthole isiqhema esisekela abantu abafuna ukulisa utjwala needakamizwa.
# Idla ukudla okunepilo. Ukudla okunepilo okungaba mirorho, iinthelo, ukudla okuziinthoro nefesi kungehlisa ukutshwenyeka khulu.
# Zazi izinto ezingakwenza utshwenyeke khulu. Funda ngobujamo nangezenzo ezingakwenza ugandeleleke namkha zikhuphule ukutshwenyeka kwakho ngokudluleleko. Zifundise iindledlana zokuthuthukisa ipilwehle yengqondo etjhiwe ngudorhoderakho wengqondo khona uzokukghona ukuqalana nemizwa le.
# Hlala uzibandula emzimbeni. Zibekele ihlelo lokuzibandula emzimbeni  amalanga amanengana evekeni. Ukuzibandula kunamandla ekwehliseni ukutshwenyeka ngokudluleleko, kukwenze uzizwe kamnandi uhlale uphilile.
# Funda ngokugula kwakho kwengqondo Khuluma nesiqhema sezamaphilo uthole bona yini le ekubangela bona utshwenyeke ngokudluleleko nemitjhoga neteraphi engakusebenzela.&lt;ref name=&quot;:0&quot;&gt;Mayo Clinic (October 4, 2024) ''11 tips for coping with an anxiety disorder.'' Retrieved from: https://www.mayoclinichealthsystem.org/hometown-health/speaking-of-health/11-tips-for-coping-with-an-anxiety-disorder. Retrieved 31/07/2025.&lt;/ref&gt;
Ukutshwenyeka kungenzeka kungakhambi khona ngokwako begodu kungathuwelela isikhathi nasikhambako nangabe umuntu akalifuni isizo. Yeke kungaba kuhle bona umuntu abone abodorhodere bengqondo ngaphambi kobana ukutshwenyeka ngokudluleleko kuthuwelele.&lt;ref name=&quot;:0&quot; /&gt;</text>
      <sha1>g03oo0hht8lcasii5eqmrho3ysdzrtk</sha1>
    </revision>
  </page>
  <page>
    <title>MBUSI MAHLANGU</title>
    <ns>0</ns>
    <id>723</id>
    <revision>
      <id>3526</id>
      <timestamp>2025-08-02T08:58:26Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <comment>ADDED PICS</comment>
      <origin>3526</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5545" sha1="1z2g14112ghueix30lzvuc0ci97rsdq" xml:space="preserve">&lt;!-- EDIT BELOW THIS LINE --&gt;[[File:MABHOKOIII.jpg|thumb|INgwenyama uMabhoko III]]
U[https://ndebelekingdom.org/history#:~:text=On%20the%205th%20November%202010,a%20vis%20the%20new%20Act Mbusi Mahlangu] yiNgwenyama yamaNdebele wakwaNzunza. Wabelethwa mhlana amalanga ama-4 kuMrhayili ngomnyaka we-1985 e[https://www.southafricapostcode.com/mpumalanga-nkangala-mthambothini-0462.html Mthambothini] e[https://en.m.wikipedia.org/wiki/Mpumalanga Pumalanga]. Ubelethwa ngumma u[https://web.archive.org/web/20090330174035/http://uqconnect.net/~zzhsoszy/states/southafrica/ndzundzandebele.html Siphila Dlamini] we[https://en.m.wikipedia.org/wiki/Eswatini Swazini] ebukhosini bakwaNgwane, uyikosazana ebelethwa yiNgwenyama u[https://en.m.wikipedia.org/wiki/Sobhuza_II Sobhuza Dlamini] begodu ungomunye wabogogo besizwe hlangana kilaba abakhona, kanti-ke ngenani abogogo besizwe sakwaNzunza bahlanu begodu u[https://en.m.wikipedia.org/wiki/Mayitjha_II Nyumbabo Cornelias Mahlangu] ongu[https://en.m.wikipedia.org/wiki/Mayitjha_II Mayitjha II] - ingwenyama yaphambilini nguye uyise likaMbusi Mahlangu. &lt;ref&gt;{{Cite web |last=Soszynski |first=Henry |title=KWANDEBELE |url=http://uqconnect.net/~zzhsoszy/states/southafrica/ndzundzandebele.html |archive-url=https://web.archive.org/web/20090330174035/http://uqconnect.net/~zzhsoszy/states/southafrica/ndzundzandebele.html |archive-date=2009-03-30 |access-date=2025-08-02 |website=uqconnect.net}}&lt;/ref&gt; INgwenyama uMabhoko III ubelethwa bewulanywa bantwana abapheze bamatjhumi amabili, kubalwa hlangana ikosazana u[https://live.fundza.mobi/home/library/non-fiction-articles-profiles/mbali-mahlungu-an-entrepreneur-with-a-passion-for-life/comment-page-1/ Mbali Mahlangu] ongusomarhwebo.&lt;ref&gt;{{Cite web |last=Ust |first=Homeabout |last2=FunDza |first2=C'sCONTACTHELP © 2025 |title=Mbali Mahlangu – An Entrepreneur with a Passion for Life {{!}} FunDza |url=https://live.fundza.mobi/home/library/non-fiction-articles-profiles/mbali-mahlungu-an-entrepreneur-with-a-passion-for-life/comment-page-1/ |access-date=2025-08-02 |website=live.fundza.mobi |language=en-US}}&lt;/ref&gt; INgwenyama uMabhoko III wahlala esihlalweni sakhe sobukhosi aba yiNgwenyama uMabhoko wesithathu ngomnyaka wee-2005, ubukhosobu ubuthatha kuyise lokha nakazakubhubha ngawo wona umnyaka loyo.&lt;ref&gt;{{Cite web |last=Soszynski |first=Henry |title=KWANDEBELE |url=http://uqconnect.net/~zzhsoszy/states/southafrica/ndzundzandebele.html |archive-url=https://web.archive.org/web/20090330174035/http://uqconnect.net/~zzhsoszy/states/southafrica/ndzundzandebele.html |archive-date=2009-03-30 |access-date=2025-08-02 |website=uqconnect.net}}&lt;/ref&gt;  

INgwenyama uMabhoko III uhlobana nesizwe nobobukhosi beSwazini njengombana kusekhabomkhulu, nakabona i[https://en.m.wikipedia.org/wiki/Mswati_III Ngwenyama uMswati III] uthi malume bese abuye ahlobane nesizwe kanye nobukhosi bakwaZulu njengombana iNgwenyama uMabhoko III neNgwenyama u[https://en.m.wikipedia.org/wiki/Misuzulu_Sinqobile Misizulu] babomntamama okutjho ukuthi abomma babo babelethwa ngubaba munye. Okukhona kukuthi ngomnyaka wee-2005 ikomitjhi yobudosiphambili ngobukhosi bendabuko elawula ubukhosi e[https://en.m.wikipedia.org/wiki/South_Africa Sewula Afrika] ebizwa bona yi[https://pmg.org.za/committee-meeting/13659/ Nhlapho Commision] yathatha isiqunto sokobana ubungwenyama ngakwaNzunza bungasaba khona buphethe ngeNgwenyama uMabhoko III bese ama[https://en.m.wikipedia.org/wiki/Southern_Ndebele_people Ndebele] woke weSewula Afrika wakwaNzunza newakwa[https://manalambhongo.com Manala] abuswe yingwenyama yinye ekuyi[https://manalambhongo.com Ngwenyama uMakhosoke II]. &lt;ref&gt;{{Cite web |last=Yende |first=Sizwe Sama |title=Court rules on amaNdebele kingship |url=https://www.news24.com/citypress/news/court-rules-on-amandebele-kingship-20161001 |access-date=2025-08-02 |website=News24 |language=en-US}}&lt;/ref&gt;
[[File:INGWENYAMA UMABHOKO III.jpg|thumb|373x373px|INgwenyama uMabhoko III nomongameli wenarha]]
Qobe mnyaka ngenyanga kaNobayeni mhlana malanga ama-19 kuba nesikhumbuzo se[https://longmarchtofreedom.co.za/BronzeStatues/Statue/68 Ngwenyama uNyabela] e[https://en.m.wikipedia.org/wiki/Mapoch%27s_Caves rholweni lakwaNzunza] lapho ubukhosi bakwa[https://www.mpg.gov.za/departments/COGTA/HTL/ndzundza-mabhoko-royal-kraal Nzunza Mabhoko] bumema isizwe soke bona sizokugidinga ilangeli, kulapho iNgwenyama uMabhoko III ikhuluma khona nesizwe sakhe. Irholweni lakwaNzunza kulapho ipi yamaNdebele namabhunu yenzeka khona begodu umlando omnengi ulapho. INgwenyama uMabhoko III uragela phambili ngokubusa isizwe sakhe, ukhe wavakatjhelwa nguMongameli wenarha u-[https://en.m.wikipedia.org/wiki/Cyril_Ramaphosa Cyril Ramaphosa] ngomnyaka wee-2024 lapha kwaba khona nekulumo yangemsithelweni phakathi kwesigodlo sakwaNzunza Mabhoko nomongameli wenarha. &lt;ref&gt;{{Cite web |title=President’s visit to Ingwenyama Mabhoko III {{!}} Dr JS Moroka Local Municipality |url=https://www.moroka.gov.za/?page_id=4542 |access-date=2025-08-02 |language=en-ZA}}&lt;/ref&gt; Kanti namanye amarhwebo azuza ngenarha yamaNdebele ayavakatjhelwa njengayo-[https://en.m.wikipedia.org/wiki/Sasol SASOL]. Phezu kwaloko iNgwenayama yamaNzunza ivuselela ubukhosi ngokusungula amabandla akhabe akhona kwaNzunza ekadeni. &lt;ref&gt;{{Cite journal |last=Mahlangu |first=Makhosini |date=2024-07-12 |title=THE NDZUNDZA KINGDOM (Territory in South Africa) |url=https://www.academia.edu/121981251/THE_NDZUNDZA_KINGDOM_Territory_in_South_Africa_ |journal=THE NDZUNDZA KINGDOM (Territory in South Africa)}}&lt;/ref&gt; 

=== IMIKHOMBO ===</text>
      <sha1>1z2g14112ghueix30lzvuc0ci97rsdq</sha1>
    </revision>
    <revision>
      <id>3527</id>
      <parentid>3526</parentid>
      <timestamp>2025-08-02T09:07:50Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <origin>3527</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4040" sha1="lj09z1wbh2spwhjnnq1s85waushvf8n" xml:space="preserve">[[Isimumathi:MABHOKOIII.jpg|thumb|328x328px|INGWENYAMA UMABHOKO III]]
U[https://ndebelekingdom.org/history#:~:text=On%20the%205th%20November%202010,a%20vis%20the%20new%20Act Mbusi Mahlangu] yiNgwenyama yamaNdebele wakwaNzunza. Wabelethwa mhlana amalanga ama-4 kuMrhayili ngomnyaka we-1985 e[https://www.southafricapostcode.com/mpumalanga-nkangala-mthambothini-0462.html Mthambothini] e[https://en.m.wikipedia.org/wiki/Mpumalanga Pumalanga]. Ubelethwa ngumma u[https://web.archive.org/web/20090330174035/http://uqconnect.net/~zzhsoszy/states/southafrica/ndzundzandebele.html Siphila Dlamini] we[https://en.m.wikipedia.org/wiki/Eswatini Swazini] ebukhosini bakwaNgwane, uyikosazana ebelethwa yiNgwenyama u[https://en.m.wikipedia.org/wiki/Sobhuza_II Sobhuza Dlamini]. Ungomunye wabogogo besizwe hlangana kilaba abakhona, kanti-ke ngenani abogogo besizwe sakwaNzunza bahlanu begodu u[https://en.m.wikipedia.org/wiki/Mayitjha_II Nyumbabo Cornelias Mahlangu] oyiNgwenayma u[https://en.m.wikipedia.org/wiki/Mayitjha_II Mayitjha II] nguye uyise likaMbusi Mahlangu. &lt;ref&gt;https://web.archive.org/web/20090330174035/http://uqconnect.net/~zzhsoszy/states/southafrica/ndzundzandebele.html&lt;/ref&gt;UMahlangu ubelethwa bewulanywa bantwana abapheze bamatjhumi amabili, kubalwa hlangana ikosazana u[https://live.fundza.mobi/home/library/non-fiction-articles-profiles/mbali-mahlungu-an-entrepreneur-with-a-passion-for-life/comment-page-1/ Mbali Mahlangu] ongusomarhwebo.&lt;ref&gt;https://live.fundza.mobi/home/library/non-fiction-articles-profiles/mbali-mahlungu-an-entrepreneur-with-a-passion-for-life/comment-page-1/&lt;/ref&gt; UMahlangu wahlala esihlalweni sakhe sobukhosi aba yiNgwenyama uMabhoko wesithathu ngomnyaka wee-2005, ubukhosobu ubuthatha kuyise lokha nakazakubhubha ngawo wona umnyaka lo.&lt;ref&gt;https://web.archive.org/web/20090330174035/http://uqconnect.net/~zzhsoszy/states/southafrica/ndzundzandebele.html&lt;/ref&gt; 

INgwenyama uMabhoko III uhlobana nesizwe nobobukhosi beSwazini njengombana kusekhabomkhulu, nakabona i[https://en.m.wikipedia.org/wiki/Mswati_III Ngwenyama uMswati III] uthi malume bese abuye ahlobane nesizwe kanye nobukhosi bakwaZulu njengombana yena neNgwenyama u[https://en.m.wikipedia.org/wiki/Misuzulu_Sinqobile Misizulu] babomntamama okutjho ukuthi abomma babo babelethwa ngubaba munye. Okukhona kukuthi ngomnyaka wee-2005 ikomitjhi yobudosiphambili ngobukhosi bendabuko elawula ubukhosi e[https://en.m.wikipedia.org/wiki/South_Africa Sewula Afrika] ebizwa bona yi[https://pmg.org.za/committee-meeting/13659/ Nhlapho Commision] yathatha isiqunto sokobana ubungwenyama ngakwaNzunza bungasaba khona buphethe ngeNgwenyama uMabhoko III bese ama[https://en.m.wikipedia.org/wiki/Southern_Ndebele_people Ndebele] woke weSewula Afrika wakwaNzunza newakwa[https://manalambhongo.com Manala] abuswe yingwenyama yinye ekuyi[https://manalambhongo.com Ngwenyama uMakhosoke II]. &lt;ref&gt;https://www.news24.com/citypress/news/court-rules-on-amandebele-kingship-20161001&lt;/ref&gt; 

Qobe mnyaka ngenyanga kaNobayeni mhlana malanga ama-19 kuba nesikhumbuzo se[https://longmarchtofreedom.co.za/BronzeStatues/Statue/68 Ngwenyama uNyabela] e[https://en.m.wikipedia.org/wiki/Mapoch%27s_Caves rholweni lakwaNzunza] lapho ubukhosi bakwa[https://www.mpg.gov.za/departments/COGTA/HTL/ndzundza-mabhoko-royal-kraal Nzunza Mabhoko] bumema isizwe soke bona sizokugidinga ilangeli, kulapho iNgwenyama uMabhoko III ikhuluma khona nesizwe sakhe. Irholo lakwaNzunza Mabhoko kulapho ipi yamaNdebele namabhunu yenzeka khona. 
[[Isimumathi:INGWENYAMA UMABHOKO III.jpg|thumb|456x456px|INGWENYAMA UMABHOKO III]]
INgwenyama uMabhoko III uragela phambili ngokubusa isizwe sakhe, ukhe wavakatjhelwa nguMongameli wenarha u-[https://en.m.wikipedia.org/wiki/Cyril_Ramaphosa Cyril Ramaphosa] ngomnyaka wee-2024 lapha kwaba khona nekulumo yangemsithelweni phakathi kwesigodlo sakwaNzunza Mabhoko nomongameli wenarha. &lt;ref&gt;https://www.moroka.gov.za/?page_id=4542&lt;/ref&gt; Kanti namanye amarhwebo azuza ngenarha yamaNdebele ayavakatjhelwa njengayo-[https://en.m.wikipedia.org/wiki/Sasol SASOL].</text>
      <sha1>lj09z1wbh2spwhjnnq1s85waushvf8n</sha1>
    </revision>
    <revision>
      <id>6699</id>
      <parentid>3527</parentid>
      <timestamp>2026-06-12T08:27:53Z</timestamp>
      <contributor>
        <username>MissHadassah</username>
        <id>1561</id>
      </contributor>
      <comment>changed formatting</comment>
      <origin>6699</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4064" sha1="5w4pe1594egx359duz9cm9i77ud22jt" xml:space="preserve">[[Isimumathi:MABHOKOIII.jpg|thumb|328x328px|INGWENYAMA UMABHOKO III]]
U[https://ndebelekingdom.org/history#:~:text=On%20the%205th%20November%202010,a%20vis%20the%20new%20Act '''Mbusi Mahlangu'''] yiNgwenyama yamaNdebele wakwaNdzundza. Wabelethwa mhlana amalanga ama-4 kuMrhayili ngomnyaka we-1985 e[https://www.southafricapostcode.com/mpumalanga-nkangala-mthambothini-0462.html Mthambothini] e[https://en.m.wikipedia.org/wiki/Mpumalanga Pumalanga]. Ubelethwa ngumma u[https://web.archive.org/web/20090330174035/http://uqconnect.net/~zzhsoszy/states/southafrica/ndzundzandebele.html Siphila Dlamini] we[https://en.m.wikipedia.org/wiki/Eswatini Swazini] ebukhosini bakwaNgwane, uyikosazana ebelethwa yiNgwenyama u[https://en.m.wikipedia.org/wiki/Sobhuza_II Sobhuza Dlamini]. Ungomunye wabogogo besizwe hlangana kilaba abakhona, kanti-ke ngenani abogogo besizwe sakwaNzunza bahlanu begodu u[https://en.m.wikipedia.org/wiki/Mayitjha_II Nyumbabo Cornelias Mahlangu] oyiNgwenayma u[https://en.m.wikipedia.org/wiki/Mayitjha_II Mayitjha II] nguye uyise likaMbusi Mahlangu. &lt;ref&gt;https://web.archive.org/web/20090330174035/http://uqconnect.net/~zzhsoszy/states/southafrica/ndzundzandebele.html&lt;/ref&gt;UMahlangu ubelethwa bewulanywa bantwana abapheze bamatjhumi amabili, kubalwa hlangana ikosazana u[https://live.fundza.mobi/home/library/non-fiction-articles-profiles/mbali-mahlungu-an-entrepreneur-with-a-passion-for-life/comment-page-1/ Mbali Mahlangu] ongusomarhwebo.&lt;ref&gt;https://live.fundza.mobi/home/library/non-fiction-articles-profiles/mbali-mahlungu-an-entrepreneur-with-a-passion-for-life/comment-page-1/&lt;/ref&gt; UMahlangu wahlala esihlalweni sakhe sobukhosi aba yiNgwenyama uMabhoko wesithathu ngomnyaka wee-2005, ubukhosobu ubuthatha kuyise lokha nakazakubhubha ngawo wona umnyaka lo.&lt;ref&gt;https://web.archive.org/web/20090330174035/http://uqconnect.net/~zzhsoszy/states/southafrica/ndzundzandebele.html&lt;/ref&gt; 

'''INgwenyama uMabhoko III''' uhlobana nesizwe nobobukhosi beSwazini njengombana kusekhabomkhulu, nakabona i[https://en.m.wikipedia.org/wiki/Mswati_III Ngwenyama uMswati III] uthi malume bese abuye ahlobane nesizwe kanye nobukhosi bakwaZulu njengombana yena neNgwenyama u[https://en.m.wikipedia.org/wiki/Misuzulu_Sinqobile Misizulu] babomntamama okutjho ukuthi abomma babo babelethwa ngubaba munye. Okukhona kukuthi ngomnyaka wee-2005 ikomitjhi yobudosiphambili ngobukhosi bendabuko elawula ubukhosi e[https://en.m.wikipedia.org/wiki/South_Africa Sewula Afrika] ebizwa bona yi[https://pmg.org.za/committee-meeting/13659/ Nhlapho Commision] yathatha isiqunto sokobana ubungwenyama ngakwaNdzundza bungasaba khona buphethe ngeNgwenyama '''uMabhoko III bese''' ama[https://en.m.wikipedia.org/wiki/Southern_Ndebele_people Ndebele] woke weSewula Afrika wakwaNdzundza newakwa[https://manalambhongo.com Manala] abuswe yingwenyama yinye ekuyi[https://manalambhongo.com Ngwenyama uMakhosoke II]. &lt;ref&gt;https://www.news24.com/citypress/news/court-rules-on-amandebele-kingship-20161001&lt;/ref&gt; 

Qobe mnyaka ngenyanga kaNobayeni mhlana malanga ama-19 kuba nesikhumbuzo se[https://longmarchtofreedom.co.za/BronzeStatues/Statue/68 Ngwenyama uNyabela] e[https://en.m.wikipedia.org/wiki/Mapoch%27s_Caves rholweni lakwaNzunza] lapho ubukhosi bakwa[https://www.mpg.gov.za/departments/COGTA/HTL/ndzundza-mabhoko-royal-kraal Nzunza Mabhoko] bumema isizwe soke bona sizokugidinga ilangeli, kulapho iNgwenyama uMabhoko III ikhuluma khona nesizwe sakhe. Irholo lakwaNzunza Mabhoko kulapho ipi yamaNdebele namabhunu yenzeka khona. 
[[Isimumathi:INGWENYAMA UMABHOKO III.jpg|thumb|456x456px|INGWENYAMA UMABHOKO III]]
INgwenyama uMabhoko III uragela phambili ngokubusa isizwe sakhe, ukhe wavakatjhelwa nguMongameli wenarha u-[https://en.m.wikipedia.org/wiki/Cyril_Ramaphosa Cyril Ramaphosa] ngomnyaka wee-2024 lapha kwaba khona nekulumo yangemsithelweni phakathi kwesigodlo sakwaNzunza Mabhoko nomongameli wenarha. &lt;ref&gt;https://www.moroka.gov.za/?page_id=4542&lt;/ref&gt; Kanti namanye amarhwebo azuza ngenarha yamaNdebele ayavakatjhelwa njengayo-[https://en.m.wikipedia.org/wiki/Sasol SASOL].</text>
      <sha1>5w4pe1594egx359duz9cm9i77ud22jt</sha1>
    </revision>
    <revision>
      <id>6773</id>
      <parentid>6699</parentid>
      <timestamp>2026-08-14T10:41:39Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <comment>fixed an error</comment>
      <origin>6773</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4062" sha1="77txtboyf52pypre1yfoza41x9789br" xml:space="preserve">[[Isimumathi:MABHOKOIII.jpg|thumb|328x328px|INGWENYAMA UMABHOKO III]]
U[https://ndebelekingdom.org/history#:~:text=On%20the%205th%20November%202010,a%20vis%20the%20new%20Act '''Mbusi Mahlangu'''] yiNgwenyama yamaNdebele wakwaNzunza. Wabelethwa mhlana amalanga ama-4 kuMrhayili ngomnyaka we-1985 e[https://www.southafricapostcode.com/mpumalanga-nkangala-mthambothini-0462.html Mthambothini] e[https://en.m.wikipedia.org/wiki/Mpumalanga Pumalanga]. Ubelethwa ngumma u[https://web.archive.org/web/20090330174035/http://uqconnect.net/~zzhsoszy/states/southafrica/ndzundzandebele.html Siphila Dlamini] we[https://en.m.wikipedia.org/wiki/Eswatini Swazini] ebukhosini bakwaNgwane, uyikosazana ebelethwa yiNgwenyama u[https://en.m.wikipedia.org/wiki/Sobhuza_II Sobhuza Dlamini]. Ungomunye wabogogo besizwe hlangana kilaba abakhona, kanti-ke ngenani abogogo besizwe sakwaNzunza bahlanu begodu u[https://en.m.wikipedia.org/wiki/Mayitjha_II Nyumbabo Cornelias Mahlangu] oyiNgwenayma u[https://en.m.wikipedia.org/wiki/Mayitjha_II Mayitjha II] nguye uyise likaMbusi Mahlangu. &lt;ref&gt;https://web.archive.org/web/20090330174035/http://uqconnect.net/~zzhsoszy/states/southafrica/ndzundzandebele.html&lt;/ref&gt;UMahlangu ubelethwa bewulanywa bantwana abapheze bamatjhumi amabili, kubalwa hlangana ikosazana u[https://live.fundza.mobi/home/library/non-fiction-articles-profiles/mbali-mahlungu-an-entrepreneur-with-a-passion-for-life/comment-page-1/ Mbali Mahlangu] ongusomarhwebo.&lt;ref&gt;https://live.fundza.mobi/home/library/non-fiction-articles-profiles/mbali-mahlungu-an-entrepreneur-with-a-passion-for-life/comment-page-1/&lt;/ref&gt; UMahlangu wahlala esihlalweni sakhe sobukhosi aba yiNgwenyama uMabhoko wesithathu ngomnyaka wee-2005, ubukhosobu ubuthatha kuyise lokha nakazakubhubha ngawo wona umnyaka lo.&lt;ref&gt;https://web.archive.org/web/20090330174035/http://uqconnect.net/~zzhsoszy/states/southafrica/ndzundzandebele.html&lt;/ref&gt; 

'''INgwenyama uMabhoko III''' uhlobana nesizwe nobobukhosi beSwazini njengombana kusekhabomkhulu, nakabona i[https://en.m.wikipedia.org/wiki/Mswati_III Ngwenyama uMswati III] uthi malume bese abuye ahlobane nesizwe kanye nobukhosi bakwaZulu njengombana yena neNgwenyama u[https://en.m.wikipedia.org/wiki/Misuzulu_Sinqobile Misizulu] babomntamama okutjho ukuthi abomma babo babelethwa ngubaba munye. Okukhona kukuthi ngomnyaka wee-2005 ikomitjhi yobudosiphambili ngobukhosi bendabuko elawula ubukhosi e[https://en.m.wikipedia.org/wiki/South_Africa Sewula Afrika] ebizwa bona yi[https://pmg.org.za/committee-meeting/13659/ Nhlapho Commision] yathatha isiqunto sokobana ubungwenyama ngakwaNdzundza bungasaba khona buphethe ngeNgwenyama '''uMabhoko III bese''' ama[https://en.m.wikipedia.org/wiki/Southern_Ndebele_people Ndebele] woke weSewula Afrika wakwaNdzundza newakwa[https://manalambhongo.com Manala] abuswe yingwenyama yinye ekuyi[https://manalambhongo.com Ngwenyama uMakhosoke II]. &lt;ref&gt;https://www.news24.com/citypress/news/court-rules-on-amandebele-kingship-20161001&lt;/ref&gt; 

Qobe mnyaka ngenyanga kaNobayeni mhlana malanga ama-19 kuba nesikhumbuzo se[https://longmarchtofreedom.co.za/BronzeStatues/Statue/68 Ngwenyama uNyabela] e[https://en.m.wikipedia.org/wiki/Mapoch%27s_Caves rholweni lakwaNzunza] lapho ubukhosi bakwa[https://www.mpg.gov.za/departments/COGTA/HTL/ndzundza-mabhoko-royal-kraal Nzunza Mabhoko] bumema isizwe soke bona sizokugidinga ilangeli, kulapho iNgwenyama uMabhoko III ikhuluma khona nesizwe sakhe. Irholo lakwaNzunza Mabhoko kulapho ipi yamaNdebele namabhunu yenzeka khona. 
[[Isimumathi:INGWENYAMA UMABHOKO III.jpg|thumb|456x456px|INGWENYAMA UMABHOKO III]]
INgwenyama uMabhoko III uragela phambili ngokubusa isizwe sakhe, ukhe wavakatjhelwa nguMongameli wenarha u-[https://en.m.wikipedia.org/wiki/Cyril_Ramaphosa Cyril Ramaphosa] ngomnyaka wee-2024 lapha kwaba khona nekulumo yangemsithelweni phakathi kwesigodlo sakwaNzunza Mabhoko nomongameli wenarha. &lt;ref&gt;https://www.moroka.gov.za/?page_id=4542&lt;/ref&gt; Kanti namanye amarhwebo azuza ngenarha yamaNdebele ayavakatjhelwa njengayo-[https://en.m.wikipedia.org/wiki/Sasol SASOL].</text>
      <sha1>77txtboyf52pypre1yfoza41x9789br</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Azaniya</title>
    <ns>2</ns>
    <id>725</id>
    <revision>
      <id>3538</id>
      <timestamp>2025-08-04T17:46:10Z</timestamp>
      <contributor>
        <username>Azaniya</username>
        <id>797</id>
      </contributor>
      <comment>Created page with &quot;Lotjha! Leli likhasi lami lapha ku-Wikipediya. Angisimuntu, kodwana ngililunga le-[[metawiki:Wikimedia_Cuteness_Association|Cuteness Association]].   Umsizi wami womuntu nguye. Ikhasi leli ngiligcina lapha njengombana ngithanda ilimi lesiNdebele nokulondolozwa kwalo.   Ngitjhiye umlayezo ekhasini lami lokukhuluma nomuntu wami&quot;</comment>
      <origin>3538</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="327" sha1="1qevi5g50iithbawq5p6m9u16x7cnsf" xml:space="preserve">Lotjha! Leli likhasi lami lapha ku-Wikipediya. Angisimuntu, kodwana ngililunga le-[[metawiki:Wikimedia_Cuteness_Association|Cuteness Association]]. 

Umsizi wami womuntu nguye. Ikhasi leli ngiligcina lapha njengombana ngithanda ilimi lesiNdebele nokulondolozwa kwalo. 

Ngitjhiye umlayezo ekhasini lami lokukhuluma nomuntu wami</text>
      <sha1>1qevi5g50iithbawq5p6m9u16x7cnsf</sha1>
    </revision>
    <revision>
      <id>3539</id>
      <parentid>3538</parentid>
      <timestamp>2025-08-04T17:47:09Z</timestamp>
      <contributor>
        <username>Azaniya</username>
        <id>797</id>
      </contributor>
      <origin>3539</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="376" sha1="50ny0a1no6sqlzluudcq29rj3et8uu0" xml:space="preserve">[[Isimumathi:Azania Mascot.png|thumb|214x214px]]
Lotjha! Leli likhasi lami lapha ku-Wikipediya. Angisimuntu, kodwana ngililunga le-[[metawiki:Wikimedia_Cuteness_Association|Cuteness Association]]. 

Umsizi wami womuntu nguye. Ikhasi leli ngiligcina lapha njengombana ngithanda ilimi lesiNdebele nokulondolozwa kwalo. 

Ngitjhiye umlayezo ekhasini lami lokukhuluma nomuntu wami</text>
      <sha1>50ny0a1no6sqlzluudcq29rj3et8uu0</sha1>
    </revision>
    <revision>
      <id>3540</id>
      <parentid>3539</parentid>
      <timestamp>2025-08-04T19:26:17Z</timestamp>
      <contributor>
        <username>Azaniya</username>
        <id>797</id>
      </contributor>
      <origin>3540</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="408" sha1="0m1zbsrydpmvcb05l3i3ozb4td2z8tb" xml:space="preserve">[[Isimumathi:Azania Mascot.png|thumb|214x214px]]
Lotjha! Leli likhasi lami lapha ku-Wikipediya. Angisimuntu, kodwana ngililunga le-[[metawiki:Wikimedia_Cuteness_Association|Cuteness Association]]. 

Umsizi wami womuntu nguye [[Umsebenzisi:Thuvack|Thuvack]]. Ikhasi leli ngiligcina lapha njengombana ngithanda ilimi lesiNdebele nokulondolozwa kwalo. 

Ngitjhiye umlayezo ekhasini lami lokukhuluma nomuntu wami</text>
      <sha1>0m1zbsrydpmvcb05l3i3ozb4td2z8tb</sha1>
    </revision>
    <revision>
      <id>3541</id>
      <parentid>3540</parentid>
      <timestamp>2025-08-04T19:26:54Z</timestamp>
      <contributor>
        <username>Azaniya</username>
        <id>797</id>
      </contributor>
      <origin>3541</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="408" sha1="97i2x5my1eklm7rkko0no8pmpsd4pcq" xml:space="preserve">[[Isimumathi:Azania Mascot.png|thumb|214x214px]]
Lotjha! Leli likhasi lami lapha ku-Wikipediya. Angisimuntu, kodwana ngililunga le-[[metawiki:Wikimedia_Cuteness_Association|Cuteness Association]]. 

Umsizi wami womuntu ngu [[Umsebenzisi:Thuvack|Thuvack]]. Ikhasi leli ngiligcina lapha njengombana ngithanda ilimi lesiNdebele nokulondolozwa kwalo. 

Ngitjhiyele umlayezo ekhasini lami lokukhuluma nomuntu wami</text>
      <sha1>97i2x5my1eklm7rkko0no8pmpsd4pcq</sha1>
    </revision>
    <revision>
      <id>3542</id>
      <parentid>3541</parentid>
      <timestamp>2025-08-04T19:32:38Z</timestamp>
      <contributor>
        <username>Azaniya</username>
        <id>797</id>
      </contributor>
      <origin>3542</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="418" sha1="muybmxlgn94ljhkxbkbaipv0hocgsl8" xml:space="preserve">[[Isimumathi:Azania Mascot.png|thumb|214x214px]]
Lotjha! Leli likhasi lami lapha ku-Wikipediya. Angisimuntu, kodwana ngililunga le-[[metawiki:Wikimedia_Cuteness_Association|Cuteness Association]]. 

Umsizi wami womuntu ngu [[Umsebenzisi:Thuvack|Thuvack]]. Ikhasi leli ngiligcina lapha njengombana ngithanda ilwimi lesiNdebele nokulondolozwa kwalo. 

Ngitjhiyele umlayezo ekhasini lami lokukhuluma.

'''''Akwande!!'''''</text>
      <sha1>muybmxlgn94ljhkxbkbaipv0hocgsl8</sha1>
    </revision>
    <revision>
      <id>3543</id>
      <parentid>3542</parentid>
      <timestamp>2025-08-04T19:32:58Z</timestamp>
      <contributor>
        <username>Azaniya</username>
        <id>797</id>
      </contributor>
      <origin>3543</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="420" sha1="8h9msizliu5cukh1x2lmr7puegyk2ai" xml:space="preserve">[[Isimumathi:Azania Mascot.png|thumb|214x214px]]
Lotjhani! Leli likhasi lami lapha ku-Wikipediya. Angisimuntu, kodwana ngililunga le-[[metawiki:Wikimedia_Cuteness_Association|Cuteness Association]]. 

Umsizi wami womuntu ngu [[Umsebenzisi:Thuvack|Thuvack]]. Ikhasi leli ngiligcina lapha njengombana ngithanda ilwimi lesiNdebele nokulondolozwa kwalo. 

Ngitjhiyele umlayezo ekhasini lami lokukhuluma.

'''''Akwande!!'''''</text>
      <sha1>8h9msizliu5cukh1x2lmr7puegyk2ai</sha1>
    </revision>
  </page>
  <page>
    <title>MediaWiki:Gadget-HotCat.js</title>
    <ns>8</ns>
    <id>726</id>
    <revision>
      <id>3586</id>
      <timestamp>2025-08-06T20:30:34Z</timestamp>
      <contributor>
        <username>Ameisenigel</username>
        <id>61</id>
      </contributor>
      <comment>per [[m:Special:PermaLink/29091322#Request to enable HotCat on nr.wikipedia|request]] ([[m:GS|global sysop]] action)</comment>
      <origin>3586</origin>
      <model>javascript</model>
      <format>text/javascript</format>
      <text bytes="386" sha1="050rn29344h01x3e9o7x0k5vcs4cj2v" xml:space="preserve">window.hotcat_translations_from_commons = true;

/*
 This imports the latest version of HotCat from Commons.
 HotCat is a gadget to make changes to categories much easier.
 Full documentation can be found at http://commons.wikimedia.org/wiki/Help:Gadget-HotCat
*/
mw.loader.load( '//commons.wikimedia.org/w/index.php?title=MediaWiki:Gadget-HotCat.js&amp;action=raw&amp;ctype=text/javascript' );</text>
      <sha1>050rn29344h01x3e9o7x0k5vcs4cj2v</sha1>
    </revision>
  </page>
  <page>
    <title>Tebogo Malaka</title>
    <ns>0</ns>
    <id>727</id>
    <revision>
      <id>3587</id>
      <timestamp>2025-08-07T01:52:18Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1304599011|Tebogo Malaka]]&quot;</comment>
      <origin>3587</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1592" sha1="7okqn0fuiv5eqajjq81bsvyy0gcxu97" xml:space="preserve">'''U-Tebogo Malaka''' mphathiswa womkhakha womphakathi [[Isewula Afrika|weSewula Afrika]] owasebenza njengoMphathi Omkhulu (CEO) noSihlalo weBhodo ye-Independent Development Trust (IDT), ihlangano karhulumende ye-schedule-2 enesibopho samaphrojekthi womthangalasiseko wezenhlalakahle eSewula Afrika. Waqothwa esikhundleni sakhe ngemva kweensolo zokukhwabanisa amathenda avela ku-IDT. &lt;ref&gt;https://www.dailymaverick.co.za/article/2025-08-06-exclusive-video-suspended-idt-ceo-spokesperson-offer-daily-maverick-journalist-r60k-in-cash-to-quash-investigation/&lt;/ref&gt;

== Izinsolo zokukhwabanisa ==
Uburholi bakhe e-IDT buqalene nokuhlolisiswa ngebanga leensolo zokuthenga okungakalungi nokungqubuzana kwemibono. Umbiko we-forensic ohlotjaniswa nethenda yesitjalo se-oksijini esiyi-R836 yezigidi uveze iindaba eziqakathekileko, begodu iimphenyo ziveze bona iinkontileka ezingaphezu kwe-R33 yezigidi zanikelwa inkampani ehlotjaniswa nodadewabo. Ngenyanga kaRhoboyi 2025, uMalaka wamiswa ngemva kokusolwa kokufumbathisa okubandakanya intathelizindaba begodu hlangana nokugandeleleka okwandako ngendima yakhe eenquntwini zamathenda zangaphambilini. Ibhodo ye-IDT igcizelele bona ukumiswa kwayo kungenxa yokuzivikela, begodu iimphenyo ezisemthethweni ziragela phambili &lt;ref&gt;https://www.news24.com/southafrica/news/amabhungane-idt-mistrust-r33m-paid-to-company-belonging-to-ceos-family-member-20250415 &lt;/ref&gt; &lt;ref&gt;https://www.dailymaverick.co.za/article/2025-08-06-exclusive-video-suspended-idt-ceo-spokesperson-offer-daily-maverick-journalist-r60k-in-cash-to-quash-investigation/ &lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>7okqn0fuiv5eqajjq81bsvyy0gcxu97</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Citation/CS1</title>
    <ns>828</ns>
    <id>730</id>
    <revision>
      <id>4315</id>
      <timestamp>2012-08-25T11:00:50Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Started module.</comment>
      <origin>4315</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="330" sha1="gcihq047ji625gz2dkvrul52i5guwaa" xml:space="preserve">local p = {}
-- This is used by templates such as {{Harvard citation}} to create the Harvard footnote.
function p.Harvard()
    return &quot;PLACEHOLDER&quot;
end
-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID()
    return &quot;CITEREF&quot;
end
return p</text>
      <sha1>gcihq047ji625gz2dkvrul52i5guwaa</sha1>
    </revision>
    <revision>
      <id>4316</id>
      <parentid>4315</parentid>
      <timestamp>2012-08-25T11:13:55Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Expanded SFNID function.</comment>
      <origin>4316</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="577" sha1="e5j3ge7av4ybiu7g9pbvn9pgaaolow4" xml:space="preserve">local p = {}
-- This is used by templates such as {{Harvard citation}} to create the Harvard footnote.
function p.Harvard()
    return &quot;PLACEHOLDER&quot;
end
-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID()
    local pframe = frame:getParent()
    local P1 = pframe.args[1] or &quot;&quot;
    local P2 = pframe.args[2] or &quot;&quot;
    local P3 = pframe.args[3] or &quot;&quot;
    local P4 = pframe.args[4] or &quot;&quot;
    local P5 = pframe.args[4] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end
return p</text>
      <sha1>e5j3ge7av4ybiu7g9pbvn9pgaaolow4</sha1>
    </revision>
    <revision>
      <id>4317</id>
      <parentid>4316</parentid>
      <timestamp>2012-08-25T11:17:24Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added missing function parameter.</comment>
      <origin>4317</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="582" sha1="jbulf2z6alkv4nqneqcpgy32uo6gfak" xml:space="preserve">local p = {}
-- This is used by templates such as {{Harvard citation}} to create the Harvard footnote.
function p.Harvard()
    return &quot;PLACEHOLDER&quot;
end
-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    local P1 = pframe.args[1] or &quot;&quot;
    local P2 = pframe.args[2] or &quot;&quot;
    local P3 = pframe.args[3] or &quot;&quot;
    local P4 = pframe.args[4] or &quot;&quot;
    local P5 = pframe.args[4] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end
return p</text>
      <sha1>jbulf2z6alkv4nqneqcpgy32uo6gfak</sha1>
    </revision>
    <revision>
      <id>4318</id>
      <parentid>4317</parentid>
      <timestamp>2012-08-25T12:03:28Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Incorporated the logic of [[Template:sfn]] into a LUA function.</comment>
      <origin>4318</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="2228" sha1="ik8gwwbo8ns6dn9kp8hx02a9rqsyuip" xml:space="preserve">local p = {}

function anchorid(frame)
    local P1 = frame.args[1] or &quot;&quot;
    local P2 = frame.args[2] or &quot;&quot;
    local P3 = frame.args[3] or &quot;&quot;
    local P4 = frame.args[4] or &quot;&quot;
    local P5 = frame.args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function name(frame)
    local P1 = frame.args[1] or &quot;&quot;
    if ( frame.args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = frame.args[2] or &quot;&quot;
        local P3 = frame.args[3] or &quot;&quot; 
        local P4 = frame.args[4] or &quot;&quot;
        if ( frame.args[4] ~= nil ) then
            P4 = &quot; &amp; &quot; .. P4
        end
        if ( frame.args[3] ~= nil ) then
            P3 = &quot; &amp; &quot; .. P3
        end
        if ( frame.args[2] ~= nil ) then
            P2 = &quot; &amp; &quot; .. P2
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame)
    local LB = frame.BracketLeft or &quot;&quot;
    local RB = frame.BracketRightt or &quot;&quot;
    local anchor = frame.ref or frame.Ref or anchorid(frame)
    local text = name(frame)
    local loc = frame.loc or &quot;&quot;
    local page = frame.p or frame.page or nil
    local pages = frame.pp or frame.pages or nil
    if ( page ~= nil ) then
        local pagesep = frame.PageSep or &quot;&quot;
        text = text .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = frame.PagesSep or &quot;&quot;
        text = text .. pagessep .. pages
    end        
    local ps = frame.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. RB .. ps
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(pframe)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(pframe)
    local args = { name = anchorid(pframe) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args})
end

return p</text>
      <sha1>ik8gwwbo8ns6dn9kp8hx02a9rqsyuip</sha1>
    </revision>
    <revision>
      <id>4319</id>
      <parentid>4318</parentid>
      <timestamp>2012-08-25T12:18:06Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Substituted for currently missing function.</comment>
      <origin>4319</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="2637" sha1="fcs61m39mnvvgw8f1sq2cm0tme02sns" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    for n,v in pairs(t.params) do
        params = params .. &quot; &quot; .. n .. &quot;=&quot; .. v
    end
    return &quot;&lt;&quot; .. name .. params .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
end

function anchorid(frame)
    local P1 = frame.args[1] or &quot;&quot;
    local P2 = frame.args[2] or &quot;&quot;
    local P3 = frame.args[3] or &quot;&quot;
    local P4 = frame.args[4] or &quot;&quot;
    local P5 = frame.args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function name(frame)
    local P1 = frame.args[1] or &quot;&quot;
    if ( frame.args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = frame.args[2] or &quot;&quot;
        local P3 = frame.args[3] or &quot;&quot; 
        local P4 = frame.args[4] or &quot;&quot;
        if ( frame.args[4] ~= nil ) then
            P4 = &quot; &amp; &quot; .. P4
        end
        if ( frame.args[3] ~= nil ) then
            P3 = &quot; &amp; &quot; .. P3
        end
        if ( frame.args[2] ~= nil ) then
            P2 = &quot; &amp; &quot; .. P2
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame)
    local LB = frame.BracketLeft or &quot;&quot;
    local RB = frame.BracketRightt or &quot;&quot;
    local anchor = frame.ref or frame.Ref or anchorid(frame)
    local text = name(frame)
    local loc = frame.loc or &quot;&quot;
    local page = frame.p or frame.page or nil
    local pages = frame.pp or frame.pages or nil
    if ( page ~= nil ) then
        local pagesep = frame.PageSep or &quot;&quot;
        text = text .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = frame.PagesSep or &quot;&quot;
        text = text .. pagessep .. pages
    end        
    local ps = frame.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. RB .. ps
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(pframe)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(pframe)
    local args = { name = anchorid(pframe) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag{name = &quot;ref&quot;, contents = content, params = args}
end

return p</text>
      <sha1>fcs61m39mnvvgw8f1sq2cm0tme02sns</sha1>
    </revision>
    <revision>
      <id>4320</id>
      <parentid>4319</parentid>
      <timestamp>2012-08-25T12:35:42Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Tweaked two functions.</comment>
      <origin>4320</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="2602" sha1="1rmq2jv2b01t9qy3c8pk6skeqwqfycs" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function p.tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    for n,v in pairs(t.params) do
        params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
    end
    return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;&gt;&quot;)
end

function anchorid(frame)
    local P1 = frame.args[1] or &quot;&quot;
    local P2 = frame.args[2] or &quot;&quot;
    local P3 = frame.args[3] or &quot;&quot;
    local P4 = frame.args[4] or &quot;&quot;
    local P5 = frame.args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function name(frame)
    local P1 = frame.args[1] or &quot;&quot;
    if ( frame.args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = frame.args[2] or &quot;&quot;
        local P3 = frame.args[3] or &quot;&quot; 
        local P4 = frame.args[4] or &quot;&quot;
        if ( frame.args[4] ~= nil ) then
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( frame.args[3] ~= nil ) then
            P2 = &quot; &amp; &quot; .. P2
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame)
    local LB = frame.BracketLeft or &quot;&quot;
    local RB = frame.BracketRightt or &quot;&quot;
    local anchor = frame.ref or frame.Ref or anchorid(frame)
    local text = name(frame)
    local loc = frame.loc or &quot;&quot;
    local page = frame.p or frame.page or nil
    local pages = frame.pp or frame.pages or nil
    if ( page ~= nil ) then
        local pagesep = frame.PageSep or &quot;&quot;
        text = text .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = frame.PagesSep or &quot;&quot;
        text = text .. pagessep .. pages
    end        
    local ps = frame.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. RB .. ps
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(pframe)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(pframe)
    local args = { name = anchorid(pframe) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

return p</text>
      <sha1>1rmq2jv2b01t9qy3c8pk6skeqwqfycs</sha1>
    </revision>
    <revision>
      <id>4321</id>
      <parentid>4320</parentid>
      <timestamp>2012-08-25T12:36:40Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Fixed function name.</comment>
      <origin>4321</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="2600" sha1="s1nz482on3xewjdo8rjzub5u6ulplz6" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    for n,v in pairs(t.params) do
        params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
    end
    return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;&gt;&quot;)
end

function anchorid(frame)
    local P1 = frame.args[1] or &quot;&quot;
    local P2 = frame.args[2] or &quot;&quot;
    local P3 = frame.args[3] or &quot;&quot;
    local P4 = frame.args[4] or &quot;&quot;
    local P5 = frame.args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function name(frame)
    local P1 = frame.args[1] or &quot;&quot;
    if ( frame.args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = frame.args[2] or &quot;&quot;
        local P3 = frame.args[3] or &quot;&quot; 
        local P4 = frame.args[4] or &quot;&quot;
        if ( frame.args[4] ~= nil ) then
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( frame.args[3] ~= nil ) then
            P2 = &quot; &amp; &quot; .. P2
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame)
    local LB = frame.BracketLeft or &quot;&quot;
    local RB = frame.BracketRightt or &quot;&quot;
    local anchor = frame.ref or frame.Ref or anchorid(frame)
    local text = name(frame)
    local loc = frame.loc or &quot;&quot;
    local page = frame.p or frame.page or nil
    local pages = frame.pp or frame.pages or nil
    if ( page ~= nil ) then
        local pagesep = frame.PageSep or &quot;&quot;
        text = text .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = frame.PagesSep or &quot;&quot;
        text = text .. pagessep .. pages
    end        
    local ps = frame.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. RB .. ps
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(pframe)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(pframe)
    local args = { name = anchorid(pframe) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

return p</text>
      <sha1>s1nz482on3xewjdo8rjzub5u6ulplz6</sha1>
    </revision>
    <revision>
      <id>4322</id>
      <parentid>4321</parentid>
      <timestamp>2012-08-25T12:38:48Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Adjusted function to add more whitespace.</comment>
      <origin>4322</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="2739" sha1="h0dwt925064tdpkyff8dzssvmpflo8h" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    for n,v in pairs(t.params) do
        params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
    end
    return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
end

function anchorid(frame)
    local P1 = frame.args[1] or &quot;&quot;
    local P2 = frame.args[2] or &quot;&quot;
    local P3 = frame.args[3] or &quot;&quot;
    local P4 = frame.args[4] or &quot;&quot;
    local P5 = frame.args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function name(frame)
    local P1 = frame.args[1] or &quot;&quot;
    if ( frame.args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = frame.args[2] or &quot;&quot;
        local P3 = frame.args[3] or &quot;&quot; 
        local P4 = frame.args[4] or &quot;&quot;
        if ( frame.args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( frame.args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( frame.args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame)
    local LB = frame.BracketLeft or &quot;&quot;
    local RB = frame.BracketRightt or &quot;&quot;
    local anchor = frame.ref or frame.Ref or anchorid(frame)
    local text = name(frame)
    local loc = frame.loc or &quot;&quot;
    local page = frame.p or frame.page or nil
    local pages = frame.pp or frame.pages or nil
    if ( page ~= nil ) then
        local pagesep = frame.PageSep or &quot;&quot;
        text = text .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = frame.PagesSep or &quot;&quot;
        text = text .. pagessep .. pages
    end        
    local ps = frame.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. RB .. ps
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(pframe)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(pframe)
    local args = { name = anchorid(pframe) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

return p</text>
      <sha1>h0dwt925064tdpkyff8dzssvmpflo8h</sha1>
    </revision>
    <revision>
      <id>4323</id>
      <parentid>4322</parentid>
      <timestamp>2012-08-25T13:16:55Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added skeleton citation function.</comment>
      <origin>4323</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="7113" sha1="60fko8qvxs5q9mi0ezcna6vilg2njqe" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    for n,v in pairs(t.params) do
        params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
    end
    return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
end

function doi(frame, i)
    return frame:preprocess(&quot;{{doi|&quot; .. i .. &quot;}}&quot;)
end

function authorprefix(Surname, Given, Authorlink, ampersand)
    if (Surname == nil) then return &quot;&quot; end
    local prefix = ampersand .. Surname
    if (Given ~= nil) then prefix = prefix .. &quot;, &quot; .. Given end
    if (Authorlink ~= nil) then prefix = &quot;[[&quot; .. Authorlink .. &quot;|&quot; .. prefix .. &quot;]]&quot; end
    return prefix 
end

function anchorid(frame)
    local P1 = frame.args[1] or &quot;&quot;
    local P2 = frame.args[2] or &quot;&quot;
    local P3 = frame.args[3] or &quot;&quot;
    local P4 = frame.args[4] or &quot;&quot;
    local P5 = frame.args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function name(frame)
    local P1 = frame.args[1] or &quot;&quot;
    if ( frame.args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = frame.args[2] or &quot;&quot;
        local P3 = frame.args[3] or &quot;&quot; 
        local P4 = frame.args[4] or &quot;&quot;
        if ( frame.args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( frame.args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( frame.args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(pframe, frame)
    local LB = frame.BracketLeft or &quot;&quot;
    local RB = frame.BracketRight or &quot;&quot;
    local anchor = pframe.ref or pframe.Ref or anchorid(pframe)
    local text = name(pframe)
    local loc = pframe.loc or &quot;&quot;
    local page = pframe.p or pframe.page or nil
    local pages = pframe.pp or pframe.pages or nil
    if ( page ~= nil ) then
        local pagesep = frame.PageSep or &quot;&quot;
        text = text .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = frame.PagesSep or &quot;&quot;
        text = text .. pagessep .. pages
    end        
    local ps = pframe.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. RB .. ps
end

function citation(pframe, frame)
    local AuthorMask = pframe.authormask or pframe.author-mask or &quot;&quot;
    local Surname1 = pframe.last or pframe.surname or pframe.last1 or pframe.surname1 or pframe.author1 or pframe.authors or pframe.author or &quot;&quot;
    local Surname2 = pframe.last2 or pframe.surname2 or pframe.author2 or nil
    local Surname3 = pframe.last3 or pframe.surname3 or pframe.author3 or nil
    local Surname4 = pframe.last4 or pframe.surname4 or pframe.author4 or nil
    local Surname5 = pframe.last5 or pframe.surname5 or pframe.author5 or nil
    local Surname6 = pframe.last6 or pframe.surname6 or pframe.author6 or nil
    local Surname7 = pframe.last7 or pframe.surname7 or pframe.author7 or nil
    local Surname8 = pframe.last8 or pframe.surname8 or pframe.author8 or nil
    local Surname9 = pframe.last9 or pframe.surname9 or pframe.author9 or nil
    local Given1 = pframe.first1 or pframe.given1 or pframe.first or pframe.given or nil
    local Given2 = pframe.first2 or pframe.given2 or nil
    local Given3 = pframe.first3 or pframe.given3 or nil
    local Given4 = pframe.first4 or pframe.given4 or nil
    local Given5 = pframe.first5 or pframe.given5 or nil
    local Given6 = pframe.first6 or pframe.given6 or nil
    local Given7 = pframe.first7 or pframe.given7 or nil
    local Given8 = pframe.first8 or pframe.given8 or nil
    local Given9 = pframe.first9 or pframe.given9 or nil
    local Authorlink1 = pframe.authorlink or pframe.author1link or pframe.authorlink1 or nil
    local Authorlink2 = pframe.author2link or pframe.authorlink2 or nil
    local Authorlink3 = pframe.author3link or pframe.authorlink3 or nil
    local Authorlink4 = pframe.author4link or pframe.authorlink4 or nil
    local Authorlink5 = pframe.author5link or pframe.authorlink5 or nil
    local Authorlink6 = pframe.author6link or pframe.authorlink6 or nil
    local Authorlink7 = pframe.author7link or pframe.authorlink7 or nil
    local Authorlink8 = pframe.author8link or pframe.authorlink8 or nil
    local Authorlink9 = pframe.author9link or pframe.authorlink9 or nil
    local Coauthors = pframe.coauthor or pframe.coauthors or nil
    local Date = pframe.date or ((pframe.day or &quot;&quot;) .. (pframe.month or &quot;&quot;) .. (pframe.year or pframe.publicationdate or &quot;&quot;))
    local Title = pframe.title or &quot;&quot;
    local URL = pframe.archiveurl or pframe.url or nil
    local Series = pframe.series or nil
    local Volume = pframe.volume or nil
    local Issue = pframe.issue or pframe.number or nil
    local Edition = pframe.edition or nil
    local Place = pframe.place or pframe.location or nil
    local PublicationPlace = pframe.publicationplace or pframe.place or pframe.location or nil
    local Publisher = pframe.publisher or &quot;&quot;
    local Language = pframe.language or nil
    local Format = pframe.format or &quot;&quot;
    local ISBN= pframe.isbn or pframe.ISBN or nil
    local DOI= pframe.doi or pframe.DOI or nil
    local text = &quot;(&quot; .. Date .. &quot;). ''&quot; .. Title .. &quot;''. &quot; .. Publisher
    text = authorprefix(Surname1, Given1, Authorlink1, &quot;&quot;) .. text
    text = authorprefix(Surname2, Given2, Authorlink2, &quot;; &quot;) .. text
    text = authorprefix(Surname3, Given3, Authorlink3, &quot;; &quot;) .. text
    text = authorprefix(Surname4, Given4, Authorlink4, &quot;; &quot;) .. text
    text = authorprefix(Surname5, Given5, Authorlink5, &quot;; &quot;) .. text
    text = authorprefix(Surname6, Given6, Authorlink6, &quot;; &quot;) .. text
    text = authorprefix(Surname7, Given7, Authorlink7, &quot;; &quot;) .. text
    text = authorprefix(Surname8, Given8, Authorlink8, &quot;; &quot;) .. text
    text = authorprefix(Surname9, Given9, Authorlink9, &quot;; &quot;) .. text
    if ( ISBN ~= nil ) then text = text .. &quot;ISBN &quot; .. ISBN end
    if ( DOI ~= nil ) then text = text .. doi(DOI) end
    return text
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(pframe, frame)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation(pframe, frame)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(pframe, frame)
    local args = { name = anchorid(pframe) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

return p</text>
      <sha1>60fko8qvxs5q9mi0ezcna6vilg2njqe</sha1>
    </revision>
    <revision>
      <id>4324</id>
      <parentid>4323</parentid>
      <timestamp>2012-08-25T13:21:47Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Spuriousminusectomy.</comment>
      <origin>4324</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="7120" sha1="ndesz0rv7a709wisihsin1xgtskwfbb" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    for n,v in pairs(t.params) do
        params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
    end
    return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
end

function doi(frame, i)
    return frame:preprocess(&quot;{{doi|&quot; .. i .. &quot;}}&quot;)
end

function authorprefix(Surname, Given, Authorlink, ampersand)
    if (Surname == nil) then return &quot;&quot; end
    local prefix = ampersand .. Surname
    if (Given ~= nil) then prefix = prefix .. &quot;, &quot; .. Given end
    if (Authorlink ~= nil) then prefix = &quot;[[&quot; .. Authorlink .. &quot;|&quot; .. prefix .. &quot;]]&quot; end
    return prefix 
end

function anchorid(frame)
    local P1 = frame.args[1] or &quot;&quot;
    local P2 = frame.args[2] or &quot;&quot;
    local P3 = frame.args[3] or &quot;&quot;
    local P4 = frame.args[4] or &quot;&quot;
    local P5 = frame.args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function name(frame)
    local P1 = frame.args[1] or &quot;&quot;
    if ( frame.args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = frame.args[2] or &quot;&quot;
        local P3 = frame.args[3] or &quot;&quot; 
        local P4 = frame.args[4] or &quot;&quot;
        if ( frame.args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( frame.args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( frame.args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(pframe, frame)
    local LB = frame.BracketLeft or &quot;&quot;
    local RB = frame.BracketRight or &quot;&quot;
    local anchor = pframe.ref or pframe.Ref or anchorid(pframe)
    local text = name(pframe)
    local loc = pframe.loc or &quot;&quot;
    local page = pframe.p or pframe.page or nil
    local pages = pframe.pp or pframe.pages or nil
    if ( page ~= nil ) then
        local pagesep = frame.PageSep or &quot;&quot;
        text = text .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = frame.PagesSep or &quot;&quot;
        text = text .. pagessep .. pages
    end        
    local ps = pframe.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. RB .. ps
end

function citation(pframe, frame)
    local AuthorMask = pframe.authormask or pframe.authormask or &quot;&quot;
    local Surname1 = pframe.last or pframe.surname or pframe.last1 or pframe.surname1 or pframe.author1 or pframe.authors or pframe.author or &quot;&quot;
    local Surname2 = pframe.last2 or pframe.surname2 or pframe.author2 or nil
    local Surname3 = pframe.last3 or pframe.surname3 or pframe.author3 or nil
    local Surname4 = pframe.last4 or pframe.surname4 or pframe.author4 or nil
    local Surname5 = pframe.last5 or pframe.surname5 or pframe.author5 or nil
    local Surname6 = pframe.last6 or pframe.surname6 or pframe.author6 or nil
    local Surname7 = pframe.last7 or pframe.surname7 or pframe.author7 or nil
    local Surname8 = pframe.last8 or pframe.surname8 or pframe.author8 or nil
    local Surname9 = pframe.last9 or pframe.surname9 or pframe.author9 or nil
    local Given1 = pframe.first1 or pframe.given1 or pframe.first or pframe.given or nil
    local Given2 = pframe.first2 or pframe.given2 or nil
    local Given3 = pframe.first3 or pframe.given3 or nil
    local Given4 = pframe.first4 or pframe.given4 or nil
    local Given5 = pframe.first5 or pframe.given5 or nil
    local Given6 = pframe.first6 or pframe.given6 or nil
    local Given7 = pframe.first7 or pframe.given7 or nil        
    local Given8 = pframe.first8 or pframe.given8 or nil
    local Given9 = pframe.first9 or pframe.given9 or nil
    local Authorlink1 = pframe.authorlink or pframe.author1link or pframe.authorlink1 or nil
    local Authorlink2 = pframe.author2link or pframe.authorlink2 or nil
    local Authorlink3 = pframe.author3link or pframe.authorlink3 or nil
    local Authorlink4 = pframe.author4link or pframe.authorlink4 or nil
    local Authorlink5 = pframe.author5link or pframe.authorlink5 or nil
    local Authorlink6 = pframe.author6link or pframe.authorlink6 or nil
    local Authorlink7 = pframe.author7link or pframe.authorlink7 or nil
    local Authorlink8 = pframe.author8link or pframe.authorlink8 or nil
    local Authorlink9 = pframe.author9link or pframe.authorlink9 or nil
    local Coauthors = pframe.coauthor or pframe.coauthors or nil
    local Date = pframe.date or ((pframe.day or &quot;&quot;) .. (pframe.month or &quot;&quot;) .. (pframe.year or pframe.publicationdate or &quot;&quot;))
    local Title = pframe.title or &quot;&quot;
    local URL = pframe.archiveurl or pframe.url or nil
    local Series = pframe.series or nil
    local Volume = pframe.volume or nil
    local Issue = pframe.issue or pframe.number or nil
    local Edition = pframe.edition or nil
    local Place = pframe.place or pframe.location or nil
    local PublicationPlace = pframe.publicationplace or pframe.place or pframe.location or nil
    local Publisher = pframe.publisher or &quot;&quot;
    local Language = pframe.language or nil
    local Format = pframe.format or &quot;&quot;
    local ISBN= pframe.isbn or pframe.ISBN or nil
    local DOI= pframe.doi or pframe.DOI or nil
    local text = &quot;(&quot; .. Date .. &quot;). ''&quot; .. Title .. &quot;''. &quot; .. Publisher
    text = authorprefix(Surname1, Given1, Authorlink1, &quot;&quot;) .. text
    text = authorprefix(Surname2, Given2, Authorlink2, &quot;; &quot;) .. text
    text = authorprefix(Surname3, Given3, Authorlink3, &quot;; &quot;) .. text
    text = authorprefix(Surname4, Given4, Authorlink4, &quot;; &quot;) .. text
    text = authorprefix(Surname5, Given5, Authorlink5, &quot;; &quot;) .. text
    text = authorprefix(Surname6, Given6, Authorlink6, &quot;; &quot;) .. text
    text = authorprefix(Surname7, Given7, Authorlink7, &quot;; &quot;) .. text
    text = authorprefix(Surname8, Given8, Authorlink8, &quot;; &quot;) .. text
    text = authorprefix(Surname9, Given9, Authorlink9, &quot;; &quot;) .. text
    if ( ISBN ~= nil ) then text = text .. &quot;ISBN &quot; .. ISBN end
    if ( DOI ~= nil ) then text = text .. doi(DOI) end
    return text
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(pframe, frame)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation(pframe, frame)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(pframe, frame)
    local args = { name = anchorid(pframe) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

return p</text>
      <sha1>ndesz0rv7a709wisihsin1xgtskwfbb</sha1>
    </revision>
    <revision>
      <id>4325</id>
      <parentid>4324</parentid>
      <timestamp>2012-08-25T13:39:05Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Modified generation of citations.</comment>
      <origin>4325</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="6931" sha1="p4wr8y6exs5h0w6lj2dk6gb2dq2htql" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    for n,v in pairs(t.params) do
        params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
    end
    return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
end

function doi(frame, i)
    return frame:preprocess(&quot;{{doi|&quot; .. i .. &quot;}}&quot;)
end

function authorprefix(Surname, Given, Authorlink, ampersand)
    if (Surname == nil) then return &quot;&quot; end
    local prefix = ampersand .. Surname
    if (Given ~= nil) then prefix = prefix .. &quot;, &quot; .. Given end
    if (Authorlink ~= nil) then prefix = &quot;[[&quot; .. Authorlink .. &quot;|&quot; .. prefix .. &quot;]]&quot; end
    return prefix 
end

function anchorid(frame)
    local P1 = frame.args[1] or &quot;&quot;
    local P2 = frame.args[2] or &quot;&quot;
    local P3 = frame.args[3] or &quot;&quot;
    local P4 = frame.args[4] or &quot;&quot;
    local P5 = frame.args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function name(frame)
    local P1 = frame.args[1] or &quot;&quot;
    if ( frame.args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = frame.args[2] or &quot;&quot;
        local P3 = frame.args[3] or &quot;&quot; 
        local P4 = frame.args[4] or &quot;&quot;
        if ( frame.args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( frame.args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( frame.args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(pframe, frame)
    local LB = frame.BracketLeft or &quot;&quot;
    local RB = frame.BracketRight or &quot;&quot;
    local anchor = pframe.ref or pframe.Ref or anchorid(pframe)
    local text = name(pframe)
    local loc = pframe.loc or &quot;&quot;
    local page = pframe.p or pframe.page or nil
    local pages = pframe.pp or pframe.pages or nil
    if ( page ~= nil ) then
        local pagesep = frame.PageSep or &quot;&quot;
        text = text .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = frame.PagesSep or &quot;&quot;
        text = text .. pagessep .. pages
    end        
    local ps = pframe.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. RB .. ps
end

function citation(pframe, frame)
    local AuthorMask = pframe.authormask or pframe.authormask or &quot;&quot;
    local Surname1 = pframe.last or pframe.surname or pframe.last1 or pframe.surname1 or pframe.author1 or pframe.authors or pframe.author or &quot;&quot;
    local Surname2 = pframe.last2 or pframe.surname2 or pframe.author2
    local Surname3 = pframe.last3 or pframe.surname3 or pframe.author3
    local Surname4 = pframe.last4 or pframe.surname4 or pframe.author4
    local Surname5 = pframe.last5 or pframe.surname5 or pframe.author5
    local Surname6 = pframe.last6 or pframe.surname6 or pframe.author6
    local Surname7 = pframe.last7 or pframe.surname7 or pframe.author7
    local Surname8 = pframe.last8 or pframe.surname8 or pframe.author8
    local Surname9 = pframe.last9 or pframe.surname9 or pframe.author9
    local Given1 = pframe.first1 or pframe.given1 or pframe.first or pframe.given
    local Given2 = pframe.first2 or pframe.given2
    local Given3 = pframe.first3 or pframe.given3
    local Given4 = pframe.first4 or pframe.given4
    local Given5 = pframe.first5 or pframe.given5
    local Given6 = pframe.first6 or pframe.given6
    local Given7 = pframe.first7 or pframe.given7
    local Given8 = pframe.first8 or pframe.given8
    local Given9 = pframe.first9 or pframe.given9
    local Authorlink1 = pframe.authorlink or pframe.author1link or pframe.authorlink1
    local Authorlink2 = pframe.author2link or pframe.authorlink2
    local Authorlink3 = pframe.author3link or pframe.authorlink3
    local Authorlink4 = pframe.author4link or pframe.authorlink4
    local Authorlink5 = pframe.author5link or pframe.authorlink5
    local Authorlink6 = pframe.author6link or pframe.authorlink6
    local Authorlink7 = pframe.author7link or pframe.authorlink7
    local Authorlink8 = pframe.author8link or pframe.authorlink8
    local Authorlink9 = pframe.author9link or pframe.authorlink9
    local Coauthors = pframe.coauthor or pframe.coauthors 
    local Date = pframe.date or ((pframe.day or &quot;&quot;) .. (pframe.month or &quot;&quot;) .. (pframe.year or pframe.publicationdate or &quot;&quot;))
    local Title = pframe.title
    local URL = pframe.archiveurl or pframe.url
    local Series = pframe.series
    local Volume = pframe.volume
    local Issue = pframe.issue or pframe.number
    local Edition = pframe.edition
    local Place = pframe.place or pframe.location
    local PublicationPlace = pframe.publicationplace or pframe.place or pframe.location
    local Publisher = pframe.publisher or &quot;&quot;
    local Language = pframe.language
    local Format = pframe.format or &quot;&quot;
    local ISBN= pframe.isbn or pframe.ISBN
    local DOI= pframe.doi or pframe.DOI
    if ( Title ~= nil ) then Title = &quot; ''&quot; .. Title .. &quot;''.&quot; else Title = &quot;&quot; end
    local text = &quot;(&quot; .. Date .. &quot;).&quot; .. Title .. &quot; &quot; .. Publisher
    text = authorprefix(Surname1, Given1, Authorlink1, &quot;&quot;) .. text
    text = authorprefix(Surname2, Given2, Authorlink2, &quot;; &quot;) .. text
    text = authorprefix(Surname3, Given3, Authorlink3, &quot;; &quot;) .. text
    text = authorprefix(Surname4, Given4, Authorlink4, &quot;; &quot;) .. text
    text = authorprefix(Surname5, Given5, Authorlink5, &quot;; &quot;) .. text
    text = authorprefix(Surname6, Given6, Authorlink6, &quot;; &quot;) .. text
    text = authorprefix(Surname7, Given7, Authorlink7, &quot;; &quot;) .. text
    text = authorprefix(Surname8, Given8, Authorlink8, &quot;; &quot;) .. text
    text = authorprefix(Surname9, Given9, Authorlink9, &quot;; &quot;) .. text
    if ( ISBN ~= nil ) then text = text .. &quot; ISBN &quot; .. ISBN end
    if ( DOI ~= nil ) then text = text .. &quot; &quot; .. doi(DOI) end
    return text
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(pframe, frame)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation(pframe, frame)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(pframe, frame)
    local args = { name = anchorid(pframe) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

return p</text>
      <sha1>p4wr8y6exs5h0w6lj2dk6gb2dq2htql</sha1>
    </revision>
    <revision>
      <id>4326</id>
      <parentid>4325</parentid>
      <timestamp>2012-08-25T13:53:41Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Modified generation of citations.</comment>
      <origin>4326</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="7073" sha1="n04hhcv7xmgcqob7xsmylvlwqugzr08" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    for n,v in pairs(t.params) do
        params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
    end
    return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
end

function doi(frame, i)
    return frame:preprocess(&quot;{{doi|&quot; .. i .. &quot;}}&quot;)
end

function authorprefix(Surname, Given, Authorlink, ampersand)
    if (Surname == nil) then return &quot;&quot; end
    local prefix = ampersand .. Surname
    if (Given ~= nil) then prefix = prefix .. &quot;, &quot; .. Given end
    if (Authorlink ~= nil) then prefix = &quot;[[&quot; .. Authorlink .. &quot;|&quot; .. prefix .. &quot;]]&quot; end
    return prefix 
end

function anchorid(frame)
    local P1 = frame.args[1] or &quot;&quot;
    local P2 = frame.args[2] or &quot;&quot;
    local P3 = frame.args[3] or &quot;&quot;
    local P4 = frame.args[4] or &quot;&quot;
    local P5 = frame.args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function name(frame)
    local P1 = frame.args[1] or &quot;&quot;
    if ( frame.args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = frame.args[2] or &quot;&quot;
        local P3 = frame.args[3] or &quot;&quot; 
        local P4 = frame.args[4] or &quot;&quot;
        if ( frame.args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( frame.args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( frame.args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(pframe, frame)
    local LB = frame.BracketLeft or &quot;&quot;
    local RB = frame.BracketRight or &quot;&quot;
    local anchor = pframe.ref or pframe.Ref or anchorid(pframe)
    local text = name(pframe)
    local loc = pframe.loc or &quot;&quot;
    local page = pframe.p or pframe.page or nil
    local pages = pframe.pp or pframe.pages or nil
    if ( page ~= nil ) then
        local pagesep = frame.PageSep or &quot;&quot;
        text = text .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = frame.PagesSep or &quot;&quot;
        text = text .. pagessep .. pages
    end        
    local ps = pframe.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. RB .. ps
end

function citation0(pframe, frame)
    local AuthorMask = pframe.authormask or pframe.authormask
    local Surname1 = pframe.last or pframe.surname or pframe.last1 or pframe.surname1 or pframe.author1 or pframe.authors or pframe.author
    local Surname2 = pframe.last2 or pframe.surname2 or pframe.author2
    local Surname3 = pframe.last3 or pframe.surname3 or pframe.author3
    local Surname4 = pframe.last4 or pframe.surname4 or pframe.author4
    local Surname5 = pframe.last5 or pframe.surname5 or pframe.author5
    local Surname6 = pframe.last6 or pframe.surname6 or pframe.author6
    local Surname7 = pframe.last7 or pframe.surname7 or pframe.author7
    local Surname8 = pframe.last8 or pframe.surname8 or pframe.author8
    local Surname9 = pframe.last9 or pframe.surname9 or pframe.author9
    local Given1 = pframe.first1 or pframe.given1 or pframe.first or pframe.given
    local Given2 = pframe.first2 or pframe.given2
    local Given3 = pframe.first3 or pframe.given3
    local Given4 = pframe.first4 or pframe.given4
    local Given5 = pframe.first5 or pframe.given5
    local Given6 = pframe.first6 or pframe.given6
    local Given7 = pframe.first7 or pframe.given7
    local Given8 = pframe.first8 or pframe.given8
    local Given9 = pframe.first9 or pframe.given9
    local Authorlink1 = pframe.authorlink or pframe.author1link or pframe.authorlink1
    local Authorlink2 = pframe.author2link or pframe.authorlink2
    local Authorlink3 = pframe.author3link or pframe.authorlink3
    local Authorlink4 = pframe.author4link or pframe.authorlink4
    local Authorlink5 = pframe.author5link or pframe.authorlink5
    local Authorlink6 = pframe.author6link or pframe.authorlink6
    local Authorlink7 = pframe.author7link or pframe.authorlink7
    local Authorlink8 = pframe.author8link or pframe.authorlink8
    local Authorlink9 = pframe.author9link or pframe.authorlink9
    local Coauthors = pframe.coauthor or pframe.coauthors 
    local Date = pframe.date or ((pframe.day or &quot;&quot;) .. (pframe.month or &quot;&quot;) .. (pframe.year or pframe.publicationdate or &quot;&quot;))
    local Title = pframe.title
    local URL = pframe.archiveurl or pframe.url
    local Series = pframe.series
    local Volume = pframe.volume
    local Issue = pframe.issue or pframe.number
    local Edition = pframe.edition
    local Place = pframe.place or pframe.location
    local PublicationPlace = pframe.publicationplace or pframe.place or pframe.location
    local Publisher = pframe.publisher
    local Language = pframe.language
    local Format = pframe.format
    local ISBN= pframe.isbn or pframe.ISBN
    local DOI= pframe.doi or pframe.DOI
    if ( Title ~= nil ) then Title = &quot; ''&quot; .. Title .. &quot;''.&quot; else Title = &quot;&quot; end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    local text = &quot;(&quot; .. Date .. &quot;).&quot; .. Title .. Publisher
    text = authorprefix(Surname1, Given1, Authorlink1, &quot;&quot;) .. text
    text = authorprefix(Surname2, Given2, Authorlink2, &quot;; &quot;) .. text
    text = authorprefix(Surname3, Given3, Authorlink3, &quot;; &quot;) .. text
    text = authorprefix(Surname4, Given4, Authorlink4, &quot;; &quot;) .. text
    text = authorprefix(Surname5, Given5, Authorlink5, &quot;; &quot;) .. text
    text = authorprefix(Surname6, Given6, Authorlink6, &quot;; &quot;) .. text
    text = authorprefix(Surname7, Given7, Authorlink7, &quot;; &quot;) .. text
    text = authorprefix(Surname8, Given8, Authorlink8, &quot;; &quot;) .. text
    text = authorprefix(Surname9, Given9, Authorlink9, &quot;; &quot;) .. text
    if ( Language ~= nil ) then text = text .. &quot; (in &quot; .. Language .. &quot;)&quot; end
    if ( ISBN ~= nil ) then text = text .. &quot; ISBN &quot; .. ISBN end
    if ( DOI ~= nil ) then text = text .. &quot; &quot; .. doi(DOI) end
    return text
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(pframe, frame)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(pframe, frame)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(pframe, frame)
    local args = { name = anchorid(pframe) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

return p</text>
      <sha1>n04hhcv7xmgcqob7xsmylvlwqugzr08</sha1>
    </revision>
    <revision>
      <id>4327</id>
      <parentid>4326</parentid>
      <timestamp>2012-08-25T18:10:45Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Fixed some argument handling.</comment>
      <origin>4327</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="6866" sha1="m9uswd2jd0d3a4isqb0sjqbh6d9k66y" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    for n,v in pairs(t.params) do
        params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
    end
    return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
end

function doi(frame, i)
    return frame:preprocess(&quot;{{doi|&quot; .. i .. &quot;}}&quot;)
end

function authorprefix(Surname, Given, Authorlink, ampersand)
    if (Surname == nil) then return &quot;&quot; end
    local prefix = ampersand .. Surname
    if (Given ~= nil) then prefix = prefix .. &quot;, &quot; .. Given end
    if (Authorlink ~= nil) then prefix = &quot;[[&quot; .. Authorlink .. &quot;|&quot; .. prefix .. &quot;]]&quot; end
    return prefix 
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page or nil
    local pages = args.pp or args.pages or nil
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;&quot;
        text = text .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;&quot;
        text = text .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args
    local AuthorMask = args.authormask or args.authormask
    local Surname1 = args.last or args.surname or args.last1 or args.surname1 or args.author1 or args.authors or args.author
    local Surname2 = args.last2 or args.surname2 or args.author2
    local Surname3 = args.last3 or args.surname3 or args.author3
    local Surname4 = args.last4 or args.surname4 or args.author4
    local Surname5 = args.last5 or args.surname5 or args.author5
    local Surname6 = args.last6 or args.surname6 or args.author6
    local Surname7 = args.last7 or args.surname7 or args.author7
    local Surname8 = args.last8 or args.surname8 or args.author8
    local Surname9 = args.last9 or args.surname9 or args.author9
    local Given1 = args.first1 or args.given1 or args.first or args.given
    local Given2 = args.first2 or args.given2
    local Given3 = args.first3 or args.given3
    local Given4 = args.first4 or args.given4
    local Given5 = args.first5 or args.given5
    local Given6 = args.first6 or args.given6
    local Given7 = args.first7 or args.given7
    local Given8 = args.first8 or args.given8
    local Given9 = args.first9 or args.given9
    local Authorlink1 = args.authorlink or args.author1link or args.authorlink1
    local Authorlink2 = args.author2link or args.authorlink2
    local Authorlink3 = args.author3link or args.authorlink3
    local Authorlink4 = args.author4link or args.authorlink4
    local Authorlink5 = args.author5link or args.authorlink5
    local Authorlink6 = args.author6link or args.authorlink6
    local Authorlink7 = args.author7link or args.authorlink7
    local Authorlink8 = args.author8link or args.authorlink8
    local Authorlink9 = args.author9link or args.authorlink9
    local Coauthors = args.coauthor or args.coauthors 
    local Date = args.date or ((args.day or &quot;&quot;) .. (args.month or &quot;&quot;) .. (args.year or args.publicationdate or &quot;&quot;))
    local Title = args.title
    local URL = args.archiveurl or args.url
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN= args.isbn or args.ISBN
    local DOI= args.doi or args.DOI
    if ( Title ~= nil ) then Title = &quot; ''&quot; .. Title .. &quot;''.&quot; else Title = &quot;&quot; end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    local text = &quot;(&quot; .. Date .. &quot;).&quot; .. Title .. Publisher
    text = authorprefix(Surname1, Given1, Authorlink1, &quot;&quot;) .. text
    text = authorprefix(Surname2, Given2, Authorlink2, &quot;; &quot;) .. text
    text = authorprefix(Surname3, Given3, Authorlink3, &quot;; &quot;) .. text
    text = authorprefix(Surname4, Given4, Authorlink4, &quot;; &quot;) .. text
    text = authorprefix(Surname5, Given5, Authorlink5, &quot;; &quot;) .. text
    text = authorprefix(Surname6, Given6, Authorlink6, &quot;; &quot;) .. text
    text = authorprefix(Surname7, Given7, Authorlink7, &quot;; &quot;) .. text
    text = authorprefix(Surname8, Given8, Authorlink8, &quot;; &quot;) .. text
    text = authorprefix(Surname9, Given9, Authorlink9, &quot;; &quot;) .. text
    if ( Language ~= nil ) then text = text .. &quot; (in &quot; .. Language .. &quot;)&quot; end
    if ( ISBN ~= nil ) then text = text .. &quot; ISBN &quot; .. ISBN end
    if ( DOI ~= nil ) then text = text .. &quot; &quot; .. doi(frame, DOI) end
    return text
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = anchorid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

return p</text>
      <sha1>m9uswd2jd0d3a4isqb0sjqbh6d9k66y</sha1>
    </revision>
    <revision>
      <id>4328</id>
      <parentid>4327</parentid>
      <timestamp>2012-08-25T18:15:05Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Fixed function name and configuration defaults.</comment>
      <origin>4328</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="6878" sha1="nwfoiiydp2kuljii0n2exxujnl4r0qd" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    for n,v in pairs(t.params) do
        params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
    end
    return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
end

function doi(frame, i)
    return frame:preprocess(&quot;{{doi|&quot; .. i .. &quot;}}&quot;)
end

function authorprefix(Surname, Given, Authorlink, ampersand)
    if (Surname == nil) then return &quot;&quot; end
    local prefix = ampersand .. Surname
    if (Given ~= nil) then prefix = prefix .. &quot;, &quot; .. Given end
    if (Authorlink ~= nil) then prefix = &quot;[[&quot; .. Authorlink .. &quot;|&quot; .. prefix .. &quot;]]&quot; end
    return prefix 
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page or nil
    local pages = args.pp or args.pages or nil
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        text = text .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        text = text .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args
    local AuthorMask = args.authormask or args.authormask
    local Surname1 = args.last or args.surname or args.last1 or args.surname1 or args.author1 or args.authors or args.author
    local Surname2 = args.last2 or args.surname2 or args.author2
    local Surname3 = args.last3 or args.surname3 or args.author3
    local Surname4 = args.last4 or args.surname4 or args.author4
    local Surname5 = args.last5 or args.surname5 or args.author5
    local Surname6 = args.last6 or args.surname6 or args.author6
    local Surname7 = args.last7 or args.surname7 or args.author7
    local Surname8 = args.last8 or args.surname8 or args.author8
    local Surname9 = args.last9 or args.surname9 or args.author9
    local Given1 = args.first1 or args.given1 or args.first or args.given
    local Given2 = args.first2 or args.given2
    local Given3 = args.first3 or args.given3
    local Given4 = args.first4 or args.given4
    local Given5 = args.first5 or args.given5
    local Given6 = args.first6 or args.given6
    local Given7 = args.first7 or args.given7
    local Given8 = args.first8 or args.given8
    local Given9 = args.first9 or args.given9
    local Authorlink1 = args.authorlink or args.author1link or args.authorlink1
    local Authorlink2 = args.author2link or args.authorlink2
    local Authorlink3 = args.author3link or args.authorlink3
    local Authorlink4 = args.author4link or args.authorlink4
    local Authorlink5 = args.author5link or args.authorlink5
    local Authorlink6 = args.author6link or args.authorlink6
    local Authorlink7 = args.author7link or args.authorlink7
    local Authorlink8 = args.author8link or args.authorlink8
    local Authorlink9 = args.author9link or args.authorlink9
    local Coauthors = args.coauthor or args.coauthors 
    local Date = args.date or ((args.day or &quot;&quot;) .. (args.month or &quot;&quot;) .. (args.year or args.publicationdate or &quot;&quot;))
    local Title = args.title
    local URL = args.archiveurl or args.url
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN= args.isbn or args.ISBN
    local DOI= args.doi or args.DOI
    if ( Title ~= nil ) then Title = &quot; ''&quot; .. Title .. &quot;''.&quot; else Title = &quot;&quot; end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    local text = &quot;(&quot; .. Date .. &quot;).&quot; .. Title .. Publisher
    text = authorprefix(Surname1, Given1, Authorlink1, &quot;&quot;) .. text
    text = authorprefix(Surname2, Given2, Authorlink2, &quot;; &quot;) .. text
    text = authorprefix(Surname3, Given3, Authorlink3, &quot;; &quot;) .. text
    text = authorprefix(Surname4, Given4, Authorlink4, &quot;; &quot;) .. text
    text = authorprefix(Surname5, Given5, Authorlink5, &quot;; &quot;) .. text
    text = authorprefix(Surname6, Given6, Authorlink6, &quot;; &quot;) .. text
    text = authorprefix(Surname7, Given7, Authorlink7, &quot;; &quot;) .. text
    text = authorprefix(Surname8, Given8, Authorlink8, &quot;; &quot;) .. text
    text = authorprefix(Surname9, Given9, Authorlink9, &quot;; &quot;) .. text
    if ( Language ~= nil ) then text = text .. &quot; (in &quot; .. Language .. &quot;)&quot; end
    if ( ISBN ~= nil ) then text = text .. &quot; ISBN &quot; .. ISBN end
    if ( DOI ~= nil ) then text = text .. &quot; &quot; .. doi(frame, DOI) end
    return text
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = anchorid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

return p</text>
      <sha1>nwfoiiydp2kuljii0n2exxujnl4r0qd</sha1>
    </revision>
    <revision>
      <id>4329</id>
      <parentid>4328</parentid>
      <timestamp>2012-08-25T18:18:39Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Modified cross-reference to include location.</comment>
      <origin>4329</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="6867" sha1="kwpesnbnmqxzzi81x035t86bb5kxh9m" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    for n,v in pairs(t.params) do
        params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
    end
    return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
end

function doi(frame, i)
    return frame:preprocess(&quot;{{doi|&quot; .. i .. &quot;}}&quot;)
end

function authorprefix(Surname, Given, Authorlink, ampersand)
    if (Surname == nil) then return &quot;&quot; end
    local prefix = ampersand .. Surname
    if (Given ~= nil) then prefix = prefix .. &quot;, &quot; .. Given end
    if (Authorlink ~= nil) then prefix = &quot;[[&quot; .. Authorlink .. &quot;|&quot; .. prefix .. &quot;]]&quot; end
    return prefix 
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args
    local AuthorMask = args.authormask or args.authormask
    local Surname1 = args.last or args.surname or args.last1 or args.surname1 or args.author1 or args.authors or args.author
    local Surname2 = args.last2 or args.surname2 or args.author2
    local Surname3 = args.last3 or args.surname3 or args.author3
    local Surname4 = args.last4 or args.surname4 or args.author4
    local Surname5 = args.last5 or args.surname5 or args.author5
    local Surname6 = args.last6 or args.surname6 or args.author6
    local Surname7 = args.last7 or args.surname7 or args.author7
    local Surname8 = args.last8 or args.surname8 or args.author8
    local Surname9 = args.last9 or args.surname9 or args.author9
    local Given1 = args.first1 or args.given1 or args.first or args.given
    local Given2 = args.first2 or args.given2
    local Given3 = args.first3 or args.given3
    local Given4 = args.first4 or args.given4
    local Given5 = args.first5 or args.given5
    local Given6 = args.first6 or args.given6
    local Given7 = args.first7 or args.given7
    local Given8 = args.first8 or args.given8
    local Given9 = args.first9 or args.given9
    local Authorlink1 = args.authorlink or args.author1link or args.authorlink1
    local Authorlink2 = args.author2link or args.authorlink2
    local Authorlink3 = args.author3link or args.authorlink3
    local Authorlink4 = args.author4link or args.authorlink4
    local Authorlink5 = args.author5link or args.authorlink5
    local Authorlink6 = args.author6link or args.authorlink6
    local Authorlink7 = args.author7link or args.authorlink7
    local Authorlink8 = args.author8link or args.authorlink8
    local Authorlink9 = args.author9link or args.authorlink9
    local Coauthors = args.coauthor or args.coauthors 
    local Date = args.date or ((args.day or &quot;&quot;) .. (args.month or &quot;&quot;) .. (args.year or args.publicationdate or &quot;&quot;))
    local Title = args.title
    local URL = args.archiveurl or args.url
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN= args.isbn or args.ISBN
    local DOI= args.doi or args.DOI
    if ( Title ~= nil ) then Title = &quot; ''&quot; .. Title .. &quot;''.&quot; else Title = &quot;&quot; end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    local text = &quot;(&quot; .. Date .. &quot;).&quot; .. Title .. Publisher
    text = authorprefix(Surname1, Given1, Authorlink1, &quot;&quot;) .. text
    text = authorprefix(Surname2, Given2, Authorlink2, &quot;; &quot;) .. text
    text = authorprefix(Surname3, Given3, Authorlink3, &quot;; &quot;) .. text
    text = authorprefix(Surname4, Given4, Authorlink4, &quot;; &quot;) .. text
    text = authorprefix(Surname5, Given5, Authorlink5, &quot;; &quot;) .. text
    text = authorprefix(Surname6, Given6, Authorlink6, &quot;; &quot;) .. text
    text = authorprefix(Surname7, Given7, Authorlink7, &quot;; &quot;) .. text
    text = authorprefix(Surname8, Given8, Authorlink8, &quot;; &quot;) .. text
    text = authorprefix(Surname9, Given9, Authorlink9, &quot;; &quot;) .. text
    if ( Language ~= nil ) then text = text .. &quot; (in &quot; .. Language .. &quot;)&quot; end
    if ( ISBN ~= nil ) then text = text .. &quot; ISBN &quot; .. ISBN end
    if ( DOI ~= nil ) then text = text .. &quot; &quot; .. doi(frame, DOI) end
    return text
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = anchorid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

return p</text>
      <sha1>kwpesnbnmqxzzi81x035t86bb5kxh9m</sha1>
    </revision>
    <revision>
      <id>4330</id>
      <parentid>4329</parentid>
      <timestamp>2012-08-25T18:33:21Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Implemented better DOI function.</comment>
      <origin>4330</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="7201" sha1="8nti4hsgv2r937ehaadfahjvvwht1oy" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    for n,v in pairs(t.params) do
        params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
    end
    return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
end

function hideinprint(frame, content)
    return content
end

function doi(frame, id)
    local text = hideinprint(&quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return frame:preprocess(text)    
end

function authorprefix(Surname, Given, Authorlink, ampersand)
    if (Surname == nil) then return &quot;&quot; end
    local prefix = ampersand .. Surname
    if (Given ~= nil) then prefix = prefix .. &quot;, &quot; .. Given end
    if (Authorlink ~= nil) then prefix = &quot;[[&quot; .. Authorlink .. &quot;|&quot; .. prefix .. &quot;]]&quot; end
    return prefix 
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args
    local AuthorMask = args.authormask or args.authormask
    local Surname1 = args.last or args.surname or args.last1 or args.surname1 or args.author1 or args.authors or args.author
    local Surname2 = args.last2 or args.surname2 or args.author2
    local Surname3 = args.last3 or args.surname3 or args.author3
    local Surname4 = args.last4 or args.surname4 or args.author4
    local Surname5 = args.last5 or args.surname5 or args.author5
    local Surname6 = args.last6 or args.surname6 or args.author6
    local Surname7 = args.last7 or args.surname7 or args.author7
    local Surname8 = args.last8 or args.surname8 or args.author8
    local Surname9 = args.last9 or args.surname9 or args.author9
    local Given1 = args.first1 or args.given1 or args.first or args.given
    local Given2 = args.first2 or args.given2
    local Given3 = args.first3 or args.given3
    local Given4 = args.first4 or args.given4
    local Given5 = args.first5 or args.given5
    local Given6 = args.first6 or args.given6
    local Given7 = args.first7 or args.given7
    local Given8 = args.first8 or args.given8
    local Given9 = args.first9 or args.given9
    local Authorlink1 = args.authorlink or args.author1link or args.authorlink1
    local Authorlink2 = args.author2link or args.authorlink2
    local Authorlink3 = args.author3link or args.authorlink3
    local Authorlink4 = args.author4link or args.authorlink4
    local Authorlink5 = args.author5link or args.authorlink5
    local Authorlink6 = args.author6link or args.authorlink6
    local Authorlink7 = args.author7link or args.authorlink7
    local Authorlink8 = args.author8link or args.authorlink8
    local Authorlink9 = args.author9link or args.authorlink9
    local Coauthors = args.coauthor or args.coauthors 
    local Date = args.date or ((args.day or &quot;&quot;) .. (args.month or &quot;&quot;) .. (args.year or args.publicationdate or &quot;&quot;))
    local Title = args.title
    local URL = args.archiveurl or args.url
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN= args.isbn or args.ISBN
    local DOI= args.doi or args.DOI
    if ( Title ~= nil ) then Title = &quot; ''&quot; .. Title .. &quot;''.&quot; else Title = &quot;&quot; end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    local text = &quot;(&quot; .. Date .. &quot;).&quot; .. Title .. Publisher
    text = authorprefix(Surname1, Given1, Authorlink1, &quot;&quot;) .. text
    text = authorprefix(Surname2, Given2, Authorlink2, &quot;; &quot;) .. text
    text = authorprefix(Surname3, Given3, Authorlink3, &quot;; &quot;) .. text
    text = authorprefix(Surname4, Given4, Authorlink4, &quot;; &quot;) .. text
    text = authorprefix(Surname5, Given5, Authorlink5, &quot;; &quot;) .. text
    text = authorprefix(Surname6, Given6, Authorlink6, &quot;; &quot;) .. text
    text = authorprefix(Surname7, Given7, Authorlink7, &quot;; &quot;) .. text
    text = authorprefix(Surname8, Given8, Authorlink8, &quot;; &quot;) .. text
    text = authorprefix(Surname9, Given9, Authorlink9, &quot;; &quot;) .. text
    if ( Language ~= nil ) then text = text .. &quot; (in &quot; .. Language .. &quot;)&quot; end
    if ( ISBN ~= nil ) then text = text .. &quot; ISBN &quot; .. ISBN end
    if ( DOI ~= nil ) then text = text .. &quot; &quot; .. doi(frame, DOI) end
    return text
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = anchorid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

return p</text>
      <sha1>8nti4hsgv2r937ehaadfahjvvwht1oy</sha1>
    </revision>
    <revision>
      <id>4331</id>
      <parentid>4330</parentid>
      <timestamp>2012-08-25T18:34:05Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added missing function argument.</comment>
      <origin>4331</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="7208" sha1="fk9xd4b35598jobq6tc1l2risz0vb7a" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    for n,v in pairs(t.params) do
        params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
    end
    return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
end

function hideinprint(frame, content)
    return content
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return frame:preprocess(text)    
end

function authorprefix(Surname, Given, Authorlink, ampersand)
    if (Surname == nil) then return &quot;&quot; end
    local prefix = ampersand .. Surname
    if (Given ~= nil) then prefix = prefix .. &quot;, &quot; .. Given end
    if (Authorlink ~= nil) then prefix = &quot;[[&quot; .. Authorlink .. &quot;|&quot; .. prefix .. &quot;]]&quot; end
    return prefix 
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args
    local AuthorMask = args.authormask or args.authormask
    local Surname1 = args.last or args.surname or args.last1 or args.surname1 or args.author1 or args.authors or args.author
    local Surname2 = args.last2 or args.surname2 or args.author2
    local Surname3 = args.last3 or args.surname3 or args.author3
    local Surname4 = args.last4 or args.surname4 or args.author4
    local Surname5 = args.last5 or args.surname5 or args.author5
    local Surname6 = args.last6 or args.surname6 or args.author6
    local Surname7 = args.last7 or args.surname7 or args.author7
    local Surname8 = args.last8 or args.surname8 or args.author8
    local Surname9 = args.last9 or args.surname9 or args.author9
    local Given1 = args.first1 or args.given1 or args.first or args.given
    local Given2 = args.first2 or args.given2
    local Given3 = args.first3 or args.given3
    local Given4 = args.first4 or args.given4
    local Given5 = args.first5 or args.given5
    local Given6 = args.first6 or args.given6
    local Given7 = args.first7 or args.given7
    local Given8 = args.first8 or args.given8
    local Given9 = args.first9 or args.given9
    local Authorlink1 = args.authorlink or args.author1link or args.authorlink1
    local Authorlink2 = args.author2link or args.authorlink2
    local Authorlink3 = args.author3link or args.authorlink3
    local Authorlink4 = args.author4link or args.authorlink4
    local Authorlink5 = args.author5link or args.authorlink5
    local Authorlink6 = args.author6link or args.authorlink6
    local Authorlink7 = args.author7link or args.authorlink7
    local Authorlink8 = args.author8link or args.authorlink8
    local Authorlink9 = args.author9link or args.authorlink9
    local Coauthors = args.coauthor or args.coauthors 
    local Date = args.date or ((args.day or &quot;&quot;) .. (args.month or &quot;&quot;) .. (args.year or args.publicationdate or &quot;&quot;))
    local Title = args.title
    local URL = args.archiveurl or args.url
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN= args.isbn or args.ISBN
    local DOI= args.doi or args.DOI
    if ( Title ~= nil ) then Title = &quot; ''&quot; .. Title .. &quot;''.&quot; else Title = &quot;&quot; end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    local text = &quot;(&quot; .. Date .. &quot;).&quot; .. Title .. Publisher
    text = authorprefix(Surname1, Given1, Authorlink1, &quot;&quot;) .. text
    text = authorprefix(Surname2, Given2, Authorlink2, &quot;; &quot;) .. text
    text = authorprefix(Surname3, Given3, Authorlink3, &quot;; &quot;) .. text
    text = authorprefix(Surname4, Given4, Authorlink4, &quot;; &quot;) .. text
    text = authorprefix(Surname5, Given5, Authorlink5, &quot;; &quot;) .. text
    text = authorprefix(Surname6, Given6, Authorlink6, &quot;; &quot;) .. text
    text = authorprefix(Surname7, Given7, Authorlink7, &quot;; &quot;) .. text
    text = authorprefix(Surname8, Given8, Authorlink8, &quot;; &quot;) .. text
    text = authorprefix(Surname9, Given9, Authorlink9, &quot;; &quot;) .. text
    if ( Language ~= nil ) then text = text .. &quot; (in &quot; .. Language .. &quot;)&quot; end
    if ( ISBN ~= nil ) then text = text .. &quot; ISBN &quot; .. ISBN end
    if ( DOI ~= nil ) then text = text .. &quot; &quot; .. doi(frame, DOI) end
    return text
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = anchorid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

return p</text>
      <sha1>fk9xd4b35598jobq6tc1l2risz0vb7a</sha1>
    </revision>
    <revision>
      <id>4332</id>
      <parentid>4331</parentid>
      <timestamp>2012-08-25T18:38:30Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added chapter parameter.</comment>
      <origin>4332</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="7367" sha1="pxi7l1ylz0xdr4i42jv047q4u09b2n4" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    for n,v in pairs(t.params) do
        params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
    end
    return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
end

function hideinprint(frame, content)
    return content
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return frame:preprocess(text)    
end

function authorprefix(Surname, Given, Authorlink, ampersand)
    if (Surname == nil) then return &quot;&quot; end
    local prefix = ampersand .. Surname
    if (Given ~= nil) then prefix = prefix .. &quot;, &quot; .. Given end
    if (Authorlink ~= nil) then prefix = &quot;[[&quot; .. Authorlink .. &quot;|&quot; .. prefix .. &quot;]]&quot; end
    return prefix 
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args
    local AuthorMask = args.authormask or args.authormask
    local Surname1 = args.last or args.surname or args.last1 or args.surname1 or args.author1 or args.authors or args.author
    local Surname2 = args.last2 or args.surname2 or args.author2
    local Surname3 = args.last3 or args.surname3 or args.author3
    local Surname4 = args.last4 or args.surname4 or args.author4
    local Surname5 = args.last5 or args.surname5 or args.author5
    local Surname6 = args.last6 or args.surname6 or args.author6
    local Surname7 = args.last7 or args.surname7 or args.author7
    local Surname8 = args.last8 or args.surname8 or args.author8
    local Surname9 = args.last9 or args.surname9 or args.author9
    local Given1 = args.first1 or args.given1 or args.first or args.given
    local Given2 = args.first2 or args.given2
    local Given3 = args.first3 or args.given3
    local Given4 = args.first4 or args.given4
    local Given5 = args.first5 or args.given5
    local Given6 = args.first6 or args.given6
    local Given7 = args.first7 or args.given7
    local Given8 = args.first8 or args.given8
    local Given9 = args.first9 or args.given9
    local Authorlink1 = args.authorlink or args.author1link or args.authorlink1
    local Authorlink2 = args.author2link or args.authorlink2
    local Authorlink3 = args.author3link or args.authorlink3
    local Authorlink4 = args.author4link or args.authorlink4
    local Authorlink5 = args.author5link or args.authorlink5
    local Authorlink6 = args.author6link or args.authorlink6
    local Authorlink7 = args.author7link or args.authorlink7
    local Authorlink8 = args.author8link or args.authorlink8
    local Authorlink9 = args.author9link or args.authorlink9
    local Coauthors = args.coauthor or args.coauthors 
    local Date = args.date or ((args.day or &quot;&quot;) .. (args.month or &quot;&quot;) .. (args.year or args.publicationdate or &quot;&quot;))
    local Title = args.title or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN= args.isbn or args.ISBN
    local DOI= args.doi or args.DOI
    if ( Chapter ~= nil ) then Chapter = &quot; \&quot;&quot; .. Chapter .. &quot;\&quot;.&quot; else Chapter = &quot;&quot; end
    if ( Title ~= nil ) then Title = &quot; ''&quot; .. Title .. &quot;''.&quot; else Title = &quot;&quot; end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    local text = &quot;(&quot; .. Date .. &quot;).&quot; .. Title .. Publisher
    text = authorprefix(Surname1, Given1, Authorlink1, &quot;&quot;) .. text
    text = authorprefix(Surname2, Given2, Authorlink2, &quot;; &quot;) .. text
    text = authorprefix(Surname3, Given3, Authorlink3, &quot;; &quot;) .. text
    text = authorprefix(Surname4, Given4, Authorlink4, &quot;; &quot;) .. text
    text = authorprefix(Surname5, Given5, Authorlink5, &quot;; &quot;) .. text
    text = authorprefix(Surname6, Given6, Authorlink6, &quot;; &quot;) .. text
    text = authorprefix(Surname7, Given7, Authorlink7, &quot;; &quot;) .. text
    text = authorprefix(Surname8, Given8, Authorlink8, &quot;; &quot;) .. text
    text = authorprefix(Surname9, Given9, Authorlink9, &quot;; &quot;) .. text
    if ( Language ~= nil ) then text = text .. &quot; (in &quot; .. Language .. &quot;)&quot; end
    if ( ISBN ~= nil ) then text = text .. &quot; ISBN &quot; .. ISBN end
    if ( DOI ~= nil ) then text = text .. &quot; &quot; .. doi(frame, DOI) end
    return text
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = anchorid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

return p</text>
      <sha1>pxi7l1ylz0xdr4i42jv047q4u09b2n4</sha1>
    </revision>
    <revision>
      <id>4333</id>
      <parentid>4332</parentid>
      <timestamp>2012-08-25T18:41:54Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Fixed semicolon problem.</comment>
      <origin>4333</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="7399" sha1="10wappbdgfcmyai8hub8krsh9xvycvt" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    for n,v in pairs(t.params) do
        params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
    end
    return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
end

function hideinprint(frame, content)
    return content
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return frame:preprocess(text)    
end

function authorprefix(Surname, Given, Authorlink, ampersand)
    if (Surname == nil) then return &quot;&quot; end
    local prefix = ampersand .. Surname
    if (Given ~= nil) then prefix = prefix .. &quot;, &quot; .. Given end
    if (Authorlink ~= nil) then prefix = &quot;[[&quot; .. Authorlink .. &quot;|&quot; .. prefix .. &quot;]]&quot; end
    return prefix 
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args
    local AuthorMask = args.authormask or args.authormask
    local Surname1 = args.last or args.surname or args.last1 or args.surname1 or args.author1 or args.authors or args.author
    local Surname2 = args.last2 or args.surname2 or args.author2
    local Surname3 = args.last3 or args.surname3 or args.author3
    local Surname4 = args.last4 or args.surname4 or args.author4
    local Surname5 = args.last5 or args.surname5 or args.author5
    local Surname6 = args.last6 or args.surname6 or args.author6
    local Surname7 = args.last7 or args.surname7 or args.author7
    local Surname8 = args.last8 or args.surname8 or args.author8
    local Surname9 = args.last9 or args.surname9 or args.author9
    local Given1 = args.first1 or args.given1 or args.first or args.given
    local Given2 = args.first2 or args.given2
    local Given3 = args.first3 or args.given3
    local Given4 = args.first4 or args.given4
    local Given5 = args.first5 or args.given5
    local Given6 = args.first6 or args.given6
    local Given7 = args.first7 or args.given7
    local Given8 = args.first8 or args.given8
    local Given9 = args.first9 or args.given9
    local Authorlink1 = args.authorlink or args.author1link or args.authorlink1
    local Authorlink2 = args.author2link or args.authorlink2
    local Authorlink3 = args.author3link or args.authorlink3
    local Authorlink4 = args.author4link or args.authorlink4
    local Authorlink5 = args.author5link or args.authorlink5
    local Authorlink6 = args.author6link or args.authorlink6
    local Authorlink7 = args.author7link or args.authorlink7
    local Authorlink8 = args.author8link or args.authorlink8
    local Authorlink9 = args.author9link or args.authorlink9
    local Coauthors = args.coauthor or args.coauthors 
    local Date = args.date or ((args.day or &quot;&quot;) .. (args.month or &quot;&quot;) .. (args.year or args.publicationdate or &quot;&quot;))
    local Title = args.title or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN= args.isbn or args.ISBN
    local DOI= args.doi or args.DOI
    if ( Chapter ~= nil ) then Chapter = &quot; \&quot;&quot; .. Chapter .. &quot;\&quot;.&quot; else Chapter = &quot;&quot; end
    if ( Title ~= nil ) then Title = &quot; ''&quot; .. Title .. &quot;''.&quot; else Title = &quot;&quot; end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    local text = &quot;(&quot; .. Date .. &quot;).&quot; .. Title .. Publisher
    text = authorprefix(Surname1, Given1, Authorlink1, &quot;&quot;) .. text
    text = authorprefix(Surname2, Given2, Authorlink2, &quot;&amp;#59; &quot;) .. text
    text = authorprefix(Surname3, Given3, Authorlink3, &quot;&amp;#59; &quot;) .. text
    text = authorprefix(Surname4, Given4, Authorlink4, &quot;&amp;#59; &quot;) .. text
    text = authorprefix(Surname5, Given5, Authorlink5, &quot;&amp;#59; &quot;) .. text
    text = authorprefix(Surname6, Given6, Authorlink6, &quot;&amp;#59; &quot;) .. text
    text = authorprefix(Surname7, Given7, Authorlink7, &quot;&amp;#59; &quot;) .. text
    text = authorprefix(Surname8, Given8, Authorlink8, &quot;&amp;#59; &quot;) .. text
    text = authorprefix(Surname9, Given9, Authorlink9, &quot;&amp;#59; &quot;) .. text
    if ( Language ~= nil ) then text = text .. &quot; (in &quot; .. Language .. &quot;)&quot; end
    if ( ISBN ~= nil ) then text = text .. &quot; ISBN &quot; .. ISBN end
    if ( DOI ~= nil ) then text = text .. &quot; &quot; .. doi(frame, DOI) end
    return text
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = anchorid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

return p</text>
      <sha1>10wappbdgfcmyai8hub8krsh9xvycvt</sha1>
    </revision>
    <revision>
      <id>4334</id>
      <parentid>4333</parentid>
      <timestamp>2012-08-25T18:47:55Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Improved author processing.</comment>
      <origin>4334</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="7554" sha1="mw6cs2uwwyvjrlwr23tu4hl3ph1lpvz" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    for n,v in pairs(t.params) do
        params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
    end
    return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
end

function hideinprint(frame, content)
    return content
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return frame:preprocess(text)    
end

function authorprefix(Surname, Given, Authorlink, ampersand)
    if (Surname == nil) then return &quot;&quot; end
    local prefix = ampersand .. Surname
    if (Given ~= nil) then prefix = prefix .. &quot;, &quot; .. Given end
    if (Authorlink ~= nil) then prefix = &quot;[[&quot; .. Authorlink .. &quot;|&quot; .. prefix .. &quot;]]&quot; end
    return prefix 
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args
    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 Surname2 = args.last2 or args.surname2 or args.author2
    local Surname3 = args.last3 or args.surname3 or args.author3
    local Surname4 = args.last4 or args.surname4 or args.author4
    local Surname5 = args.last5 or args.surname5 or args.author5
    local Surname6 = args.last6 or args.surname6 or args.author6
    local Surname7 = args.last7 or args.surname7 or args.author7
    local Surname8 = args.last8 or args.surname8 or args.author8
    local Surname9 = args.last9 or args.surname9 or args.author9
    local Given1 = args.first1 or args.given1 or args.first or args.given
    local Given2 = args.first2 or args.given2
    local Given3 = args.first3 or args.given3
    local Given4 = args.first4 or args.given4
    local Given5 = args.first5 or args.given5
    local Given6 = args.first6 or args.given6
    local Given7 = args.first7 or args.given7
    local Given8 = args.first8 or args.given8
    local Given9 = args.first9 or args.given9
    local Authorlink1 = args.authorlink or args.author1link or args.authorlink1
    local Authorlink2 = args.author2link or args.authorlink2
    local Authorlink3 = args.author3link or args.authorlink3
    local Authorlink4 = args.author4link or args.authorlink4
    local Authorlink5 = args.author5link or args.authorlink5
    local Authorlink6 = args.author6link or args.authorlink6
    local Authorlink7 = args.author7link or args.authorlink7
    local Authorlink8 = args.author8link or args.authorlink8
    local Authorlink9 = args.author9link or args.authorlink9
    local Coauthors = args.coauthor or args.coauthors 
    local Date = args.date or ((args.day or &quot;&quot;) .. (args.month or &quot;&quot;) .. (args.year or args.publicationdate or &quot;&quot;))
    local Title = args.title or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN= args.isbn or args.ISBN
    local DOI= args.doi or args.DOI
    local Authors = args.authors 
    if ( Chapter ~= nil ) then Chapter = &quot; \&quot;&quot; .. Chapter .. &quot;\&quot;.&quot; else Chapter = &quot;&quot; end
    if ( Title ~= nil ) then Title = &quot; ''&quot; .. Title .. &quot;''.&quot; else Title = &quot;&quot; end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( Authors == nil ) then        
        Authors = authorprefix(Surname1, Given1, Authorlink1, &quot;&quot;)
        Authors = Authors .. authorprefix(Surname2, Given2, Authorlink2, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname3, Given3, Authorlink3, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname4, Given4, Authorlink4, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname5, Given5, Authorlink5, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname6, Given6, Authorlink6, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname7, Given7, Authorlink7, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname8, Given8, Authorlink8, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname9, Given9, Authorlink9, &quot;&amp;#59; &quot;)
    end
    local text = Authors .. &quot;(&quot; .. Date .. &quot;).&quot; .. Title .. Publisher
    if ( Language ~= nil ) then text = text .. &quot; (in &quot; .. Language .. &quot;)&quot; end
    if ( ISBN ~= nil ) then text = text .. &quot; ISBN &quot; .. ISBN end
    if ( DOI ~= nil ) then text = text .. &quot; &quot; .. doi(frame, DOI) end
    return text
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = anchorid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

return p</text>
      <sha1>mw6cs2uwwyvjrlwr23tu4hl3ph1lpvz</sha1>
    </revision>
    <revision>
      <id>4335</id>
      <parentid>4334</parentid>
      <timestamp>2012-08-25T18:57:14Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added ref processing.</comment>
      <origin>4335</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="7798" sha1="cebbijg2mnymhvfs7mto84p2xpdiwnm" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    for n,v in pairs(t.params) do
        params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
    end
    return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
end

function hideinprint(frame, content)
    return content
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return frame:preprocess(text)    
end

function authorprefix(Surname, Given, Authorlink, ampersand)
    if (Surname == nil) then return &quot;&quot; end
    local prefix = ampersand .. Surname
    if (Given ~= nil) then prefix = prefix .. &quot;, &quot; .. Given end
    if (Authorlink ~= nil) then prefix = &quot;[[&quot; .. Authorlink .. &quot;|&quot; .. prefix .. &quot;]]&quot; end
    return prefix 
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args
    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 Surname2 = args.last2 or args.surname2 or args.author2
    local Surname3 = args.last3 or args.surname3 or args.author3
    local Surname4 = args.last4 or args.surname4 or args.author4
    local Surname5 = args.last5 or args.surname5 or args.author5
    local Surname6 = args.last6 or args.surname6 or args.author6
    local Surname7 = args.last7 or args.surname7 or args.author7
    local Surname8 = args.last8 or args.surname8 or args.author8
    local Surname9 = args.last9 or args.surname9 or args.author9
    local Given1 = args.first1 or args.given1 or args.first or args.given
    local Given2 = args.first2 or args.given2
    local Given3 = args.first3 or args.given3
    local Given4 = args.first4 or args.given4
    local Given5 = args.first5 or args.given5
    local Given6 = args.first6 or args.given6
    local Given7 = args.first7 or args.given7
    local Given8 = args.first8 or args.given8
    local Given9 = args.first9 or args.given9
    local Authorlink1 = args.authorlink or args.author1link or args.authorlink1
    local Authorlink2 = args.author2link or args.authorlink2
    local Authorlink3 = args.author3link or args.authorlink3
    local Authorlink4 = args.author4link or args.authorlink4
    local Authorlink5 = args.author5link or args.authorlink5
    local Authorlink6 = args.author6link or args.authorlink6
    local Authorlink7 = args.author7link or args.authorlink7
    local Authorlink8 = args.author8link or args.authorlink8
    local Authorlink9 = args.author9link or args.authorlink9
    local Coauthors = args.coauthor or args.coauthors 
    local Date = args.date or ((args.day or &quot;&quot;) .. (args.month or &quot;&quot;) .. (args.year or args.publicationdate or &quot;&quot;))
    local Title = args.title or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN= args.isbn or args.ISBN
    local DOI= args.doi or args.DOI
    local Authors = args.authors 
    local Ref = args.ref or args.Ref
    if ( Chapter ~= nil ) then Chapter = &quot; \&quot;&quot; .. Chapter .. &quot;\&quot;.&quot; else Chapter = &quot;&quot; end
    if ( Title ~= nil ) then Title = &quot; ''&quot; .. Title .. &quot;''.&quot; else Title = &quot;&quot; end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( Authors == nil ) then        
        Authors = authorprefix(Surname1, Given1, Authorlink1, &quot;&quot;)
        Authors = Authors .. authorprefix(Surname2, Given2, Authorlink2, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname3, Given3, Authorlink3, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname4, Given4, Authorlink4, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname5, Given5, Authorlink5, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname6, Given6, Authorlink6, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname7, Given7, Authorlink7, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname8, Given8, Authorlink8, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname9, Given9, Authorlink9, &quot;&amp;#59; &quot;) .. &quot; &quot;        
    end
    local text = Authors .. &quot;(&quot; .. Date .. &quot;).&quot; .. Title .. Publisher
    if ( Language ~= nil ) then text = text .. &quot; (in &quot; .. Language .. &quot;)&quot; end
    if ( ISBN ~= nil ) then text = text .. &quot; ISBN &quot; .. ISBN end
    if ( DOI ~= nil ) then text = text .. &quot; &quot; .. doi(frame, DOI) end
    if ( Ref ~= nil ) then 
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=anchorid(args) }
        text = tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    return text
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = anchorid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

return p</text>
      <sha1>cebbijg2mnymhvfs7mto84p2xpdiwnm</sha1>
    </revision>
    <revision>
      <id>4336</id>
      <parentid>4335</parentid>
      <timestamp>2012-08-25T19:05:00Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added alternative processing for non-extension tags.</comment>
      <origin>4336</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="8068" sha1="352n77qga7x4viffzx98pbmcw7xb6dj" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    if ( &quot;span&quot; == name or &quot;div&quot; == name or &quot;blockquote&quot; == name ) then
        for n,v in pairs(t.params) do
            params = params .. &quot; &quot; .. n .. &quot;=&quot; .. v
        end
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. params .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    else
        for n,v in pairs(t.params) do
            params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
        end
        return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
    end
end

function hideinprint(frame, content)
    return content
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function authorprefix(Surname, Given, Authorlink, ampersand)
    if (Surname == nil) then return &quot;&quot; end
    local prefix = ampersand .. Surname
    if (Given ~= nil) then prefix = prefix .. &quot;, &quot; .. Given end
    if (Authorlink ~= nil) then prefix = &quot;[[&quot; .. Authorlink .. &quot;|&quot; .. prefix .. &quot;]]&quot; end
    return prefix 
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args
    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 Surname2 = args.last2 or args.surname2 or args.author2
    local Surname3 = args.last3 or args.surname3 or args.author3
    local Surname4 = args.last4 or args.surname4 or args.author4
    local Surname5 = args.last5 or args.surname5 or args.author5
    local Surname6 = args.last6 or args.surname6 or args.author6
    local Surname7 = args.last7 or args.surname7 or args.author7
    local Surname8 = args.last8 or args.surname8 or args.author8
    local Surname9 = args.last9 or args.surname9 or args.author9
    local Given1 = args.first1 or args.given1 or args.first or args.given
    local Given2 = args.first2 or args.given2
    local Given3 = args.first3 or args.given3
    local Given4 = args.first4 or args.given4
    local Given5 = args.first5 or args.given5
    local Given6 = args.first6 or args.given6
    local Given7 = args.first7 or args.given7
    local Given8 = args.first8 or args.given8
    local Given9 = args.first9 or args.given9
    local Authorlink1 = args.authorlink or args.author1link or args.authorlink1
    local Authorlink2 = args.author2link or args.authorlink2
    local Authorlink3 = args.author3link or args.authorlink3
    local Authorlink4 = args.author4link or args.authorlink4
    local Authorlink5 = args.author5link or args.authorlink5
    local Authorlink6 = args.author6link or args.authorlink6
    local Authorlink7 = args.author7link or args.authorlink7
    local Authorlink8 = args.author8link or args.authorlink8
    local Authorlink9 = args.author9link or args.authorlink9
    local Coauthors = args.coauthor or args.coauthors 
    local Date = args.date or ((args.day or &quot;&quot;) .. (args.month or &quot;&quot;) .. (args.year or args.publicationdate or &quot;&quot;))
    local Title = args.title or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN= args.isbn or args.ISBN
    local DOI= args.doi or args.DOI
    local Authors = args.authors 
    local Ref = args.ref or args.Ref
    if ( Chapter ~= nil ) then Chapter = &quot; \&quot;&quot; .. Chapter .. &quot;\&quot;.&quot; else Chapter = &quot;&quot; end
    if ( Title ~= nil ) then Title = &quot; ''&quot; .. Title .. &quot;''.&quot; else Title = &quot;&quot; end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( Authors == nil ) then        
        Authors = authorprefix(Surname1, Given1, Authorlink1, &quot;&quot;)
        Authors = Authors .. authorprefix(Surname2, Given2, Authorlink2, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname3, Given3, Authorlink3, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname4, Given4, Authorlink4, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname5, Given5, Authorlink5, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname6, Given6, Authorlink6, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname7, Given7, Authorlink7, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname8, Given8, Authorlink8, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname9, Given9, Authorlink9, &quot;&amp;#59; &quot;) .. &quot; &quot;        
    end
    local text = Authors .. &quot;(&quot; .. Date .. &quot;).&quot; .. Title .. Publisher
    if ( Language ~= nil ) then text = text .. &quot; (in &quot; .. Language .. &quot;)&quot; end
    if ( ISBN ~= nil ) then text = text .. &quot; ISBN &quot; .. ISBN end
    if ( DOI ~= nil ) then text = text .. &quot; &quot; .. doi(frame, DOI) end
    if ( Ref ~= nil ) then 
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=anchorid(args) }
        text = tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    return text
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = anchorid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

return p</text>
      <sha1>352n77qga7x4viffzx98pbmcw7xb6dj</sha1>
    </revision>
    <revision>
      <id>4337</id>
      <parentid>4336</parentid>
      <timestamp>2012-08-25T19:18:10Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Adjusted generation of span element.</comment>
      <origin>4337</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="8463" sha1="8pi4g7r76wxu0ftipll82tdi4xt2xbz" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    if ( &quot;span&quot; == name or &quot;div&quot; == name or &quot;blockquote&quot; == name ) then
        for n,v in pairs(t.params) do
            params = params .. &quot; &quot; .. n .. &quot;=\&quot;&quot; .. v .. &quot;\&quot;&quot;
        end
        return &quot;&lt;&quot; .. name .. params .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    else
        for n,v in pairs(t.params) do
            params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
        end
        return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
    end
end

function hideinprint(frame, content)
    return content
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function authorprefix(Surname, Given, Authorlink, ampersand)
    if (Surname == nil) then return &quot;&quot; end
    local prefix = ampersand .. Surname
    if (Given ~= nil) then prefix = prefix .. &quot;, &quot; .. Given end
    if (Authorlink ~= nil) then prefix = &quot;[[&quot; .. Authorlink .. &quot;|&quot; .. prefix .. &quot;]]&quot; end
    return prefix 
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args
    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 Surname2 = args.last2 or args.surname2 or args.author2
    local Surname3 = args.last3 or args.surname3 or args.author3
    local Surname4 = args.last4 or args.surname4 or args.author4
    local Surname5 = args.last5 or args.surname5 or args.author5
    local Surname6 = args.last6 or args.surname6 or args.author6
    local Surname7 = args.last7 or args.surname7 or args.author7
    local Surname8 = args.last8 or args.surname8 or args.author8
    local Surname9 = args.last9 or args.surname9 or args.author9
    local Given1 = args.first1 or args.given1 or args.first or args.given
    local Given2 = args.first2 or args.given2
    local Given3 = args.first3 or args.given3
    local Given4 = args.first4 or args.given4
    local Given5 = args.first5 or args.given5
    local Given6 = args.first6 or args.given6
    local Given7 = args.first7 or args.given7
    local Given8 = args.first8 or args.given8
    local Given9 = args.first9 or args.given9
    local Authorlink1 = args.authorlink or args.author1link or args.authorlink1
    local Authorlink2 = args.author2link or args.authorlink2
    local Authorlink3 = args.author3link or args.authorlink3
    local Authorlink4 = args.author4link or args.authorlink4
    local Authorlink5 = args.author5link or args.authorlink5
    local Authorlink6 = args.author6link or args.authorlink6
    local Authorlink7 = args.author7link or args.authorlink7
    local Authorlink8 = args.author8link or args.authorlink8
    local Authorlink9 = args.author9link or args.authorlink9
    local Coauthors = args.coauthor or args.coauthors 
    local Year = args.year or args.publicationdate or &quot;&quot;
    local Date = args.date or ((args.day or &quot;&quot;) .. (args.month or &quot;&quot;) .. Year)
    local Title = args.title or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN= args.isbn or args.ISBN
    local DOI= args.doi or args.DOI
    local Authors = args.authors 
    local Ref = args.ref or args.Ref
    if ( Chapter ~= nil ) then Chapter = &quot; \&quot;&quot; .. Chapter .. &quot;\&quot;.&quot; else Chapter = &quot;&quot; end
    if ( Title ~= nil ) then Title = &quot; ''&quot; .. Title .. &quot;''.&quot; else Title = &quot;&quot; end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( Authors == nil ) then        
        Authors = authorprefix(Surname1, Given1, Authorlink1, &quot;&quot;)
        Authors = Authors .. authorprefix(Surname2, Given2, Authorlink2, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname3, Given3, Authorlink3, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname4, Given4, Authorlink4, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname5, Given5, Authorlink5, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname6, Given6, Authorlink6, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname7, Given7, Authorlink7, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname8, Given8, Authorlink8, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname9, Given9, Authorlink9, &quot;&amp;#59; &quot;) .. &quot; &quot;        
    end
    local text = Authors .. &quot;(&quot; .. Date .. &quot;).&quot; .. Title .. Publisher
    if ( Language ~= nil ) then text = text .. &quot; (in &quot; .. Language .. &quot;)&quot; end
    if ( ISBN ~= nil ) then text = text .. &quot; ISBN &quot; .. ISBN end
    if ( DOI ~= nil ) then text = text .. &quot; &quot; .. doi(frame, DOI) end
    if ( Ref ~= nil ) then 
        local P1 = Surname1
        local P2 = Surname2
        local P3 = Surname3
        local P4 = Surname4
        local P5
        if ( Surname2 == nil ) then 
            P2 = Year 
        elseif ( Surname3 == nil ) then
            P3 = Year
        elseif ( Surname4 == nil ) then
            P4 = Year
        else
            P5 = Year
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=anchorid({P1,P2,P3,P4,P5}) }
        text = tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    return text
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = anchorid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

return p</text>
      <sha1>8pi4g7r76wxu0ftipll82tdi4xt2xbz</sha1>
    </revision>
    <revision>
      <id>4338</id>
      <parentid>4337</parentid>
      <timestamp>2012-08-25T19:21:18Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added support for when ref is not harv.</comment>
      <origin>4338</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="8608" sha1="n4g7a49j9h736v0il0g2s3lr5h0kcd5" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    if ( &quot;span&quot; == name or &quot;div&quot; == name or &quot;blockquote&quot; == name ) then
        for n,v in pairs(t.params) do
            params = params .. &quot; &quot; .. n .. &quot;=\&quot;&quot; .. v .. &quot;\&quot;&quot;
        end
        return &quot;&lt;&quot; .. name .. params .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    else
        for n,v in pairs(t.params) do
            params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
        end
        return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
    end
end

function hideinprint(frame, content)
    return content
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function authorprefix(Surname, Given, Authorlink, ampersand)
    if (Surname == nil) then return &quot;&quot; end
    local prefix = ampersand .. Surname
    if (Given ~= nil) then prefix = prefix .. &quot;, &quot; .. Given end
    if (Authorlink ~= nil) then prefix = &quot;[[&quot; .. Authorlink .. &quot;|&quot; .. prefix .. &quot;]]&quot; end
    return prefix 
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args
    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 Surname2 = args.last2 or args.surname2 or args.author2
    local Surname3 = args.last3 or args.surname3 or args.author3
    local Surname4 = args.last4 or args.surname4 or args.author4
    local Surname5 = args.last5 or args.surname5 or args.author5
    local Surname6 = args.last6 or args.surname6 or args.author6
    local Surname7 = args.last7 or args.surname7 or args.author7
    local Surname8 = args.last8 or args.surname8 or args.author8
    local Surname9 = args.last9 or args.surname9 or args.author9
    local Given1 = args.first1 or args.given1 or args.first or args.given
    local Given2 = args.first2 or args.given2
    local Given3 = args.first3 or args.given3
    local Given4 = args.first4 or args.given4
    local Given5 = args.first5 or args.given5
    local Given6 = args.first6 or args.given6
    local Given7 = args.first7 or args.given7
    local Given8 = args.first8 or args.given8
    local Given9 = args.first9 or args.given9
    local Authorlink1 = args.authorlink or args.author1link or args.authorlink1
    local Authorlink2 = args.author2link or args.authorlink2
    local Authorlink3 = args.author3link or args.authorlink3
    local Authorlink4 = args.author4link or args.authorlink4
    local Authorlink5 = args.author5link or args.authorlink5
    local Authorlink6 = args.author6link or args.authorlink6
    local Authorlink7 = args.author7link or args.authorlink7
    local Authorlink8 = args.author8link or args.authorlink8
    local Authorlink9 = args.author9link or args.authorlink9
    local Coauthors = args.coauthor or args.coauthors 
    local Year = args.year or args.publicationdate or &quot;&quot;
    local Date = args.date or ((args.day or &quot;&quot;) .. (args.month or &quot;&quot;) .. Year)
    local Title = args.title or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN= args.isbn or args.ISBN
    local DOI= args.doi or args.DOI
    local Authors = args.authors 
    local Ref = args.ref or args.Ref
    if ( Chapter ~= nil ) then Chapter = &quot; \&quot;&quot; .. Chapter .. &quot;\&quot;.&quot; else Chapter = &quot;&quot; end
    if ( Title ~= nil ) then Title = &quot; ''&quot; .. Title .. &quot;''.&quot; else Title = &quot;&quot; end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( Authors == nil ) then        
        Authors = authorprefix(Surname1, Given1, Authorlink1, &quot;&quot;)
        Authors = Authors .. authorprefix(Surname2, Given2, Authorlink2, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname3, Given3, Authorlink3, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname4, Given4, Authorlink4, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname5, Given5, Authorlink5, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname6, Given6, Authorlink6, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname7, Given7, Authorlink7, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname8, Given8, Authorlink8, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname9, Given9, Authorlink9, &quot;&amp;#59; &quot;) .. &quot; &quot;        
    end
    local text = Authors .. &quot;(&quot; .. Date .. &quot;).&quot; .. Title .. Publisher
    if ( Language ~= nil ) then text = text .. &quot; (in &quot; .. Language .. &quot;)&quot; end
    if ( ISBN ~= nil ) then text = text .. &quot; ISBN &quot; .. ISBN end
    if ( DOI ~= nil ) then text = text .. &quot; &quot; .. doi(frame, DOI) end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; ~= Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    return text
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = anchorid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

return p</text>
      <sha1>n4g7a49j9h736v0il0g2s3lr5h0kcd5</sha1>
    </revision>
    <revision>
      <id>4339</id>
      <parentid>4338</parentid>
      <timestamp>2012-08-25T19:31:12Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Reduced the number of string reassignments.</comment>
      <origin>4339</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="8786" sha1="kgycm09vo18p2l1520d1eilkcv0tubb" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    if ( &quot;span&quot; == name or &quot;div&quot; == name or &quot;blockquote&quot; == name ) then
        for n,v in pairs(t.params) do
            params = params .. &quot; &quot; .. n .. &quot;=\&quot;&quot; .. v .. &quot;\&quot;&quot;
        end
        return &quot;&lt;&quot; .. name .. params .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    else
        for n,v in pairs(t.params) do
            params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
        end
        return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
    end
end

function hideinprint(frame, content)
    return content
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function authorprefix(Surname, Given, Authorlink, ampersand)
    if (Surname == nil) then return &quot;&quot; end
    local prefix = ampersand .. Surname
    if (Given ~= nil) then prefix = prefix .. &quot;, &quot; .. Given end
    if (Authorlink ~= nil) then prefix = &quot;[[&quot; .. Authorlink .. &quot;|&quot; .. prefix .. &quot;]]&quot; end
    return prefix 
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args
    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 Surname2 = args.last2 or args.surname2 or args.author2
    local Surname3 = args.last3 or args.surname3 or args.author3
    local Surname4 = args.last4 or args.surname4 or args.author4
    local Surname5 = args.last5 or args.surname5 or args.author5
    local Surname6 = args.last6 or args.surname6 or args.author6
    local Surname7 = args.last7 or args.surname7 or args.author7
    local Surname8 = args.last8 or args.surname8 or args.author8
    local Surname9 = args.last9 or args.surname9 or args.author9
    local Given1 = args.first1 or args.given1 or args.first or args.given
    local Given2 = args.first2 or args.given2
    local Given3 = args.first3 or args.given3
    local Given4 = args.first4 or args.given4
    local Given5 = args.first5 or args.given5
    local Given6 = args.first6 or args.given6
    local Given7 = args.first7 or args.given7
    local Given8 = args.first8 or args.given8
    local Given9 = args.first9 or args.given9
    local Authorlink1 = args.authorlink or args.author1link or args.authorlink1
    local Authorlink2 = args.author2link or args.authorlink2
    local Authorlink3 = args.author3link or args.authorlink3
    local Authorlink4 = args.author4link or args.authorlink4
    local Authorlink5 = args.author5link or args.authorlink5
    local Authorlink6 = args.author6link or args.authorlink6
    local Authorlink7 = args.author7link or args.authorlink7
    local Authorlink8 = args.author8link or args.authorlink8
    local Authorlink9 = args.author9link or args.authorlink9
    local Coauthors = args.coauthor or args.coauthors 
    local Year = args.year or args.publicationdate or &quot;&quot;
    local Date = args.date or ((args.day or &quot;&quot;) .. (args.month or &quot;&quot;) .. Year)
    local Title = args.title or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN= args.isbn or args.ISBN
    local DOI= args.doi or args.DOI
    local Authors = args.authors 
    local Editors = args.editors 
    local Ref = args.ref or args.Ref
    if ( Chapter ~= nil ) then Chapter = &quot; \&quot;&quot; .. Chapter .. &quot;\&quot;.&quot; else Chapter = &quot;&quot; end
    if ( Title ~= nil ) then Title = &quot; ''&quot; .. Title .. &quot;''.&quot; else Title = &quot;&quot; end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; ISBN &quot; .. ISBN end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI) end
    if ( Authors == nil ) then
        Authors = authorprefix(Surname1, Given1, Authorlink1, &quot;&quot;)
        Authors = Authors .. authorprefix(Surname2, Given2, Authorlink2, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname3, Given3, Authorlink3, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname4, Given4, Authorlink4, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname5, Given5, Authorlink5, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname6, Given6, Authorlink6, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname7, Given7, Authorlink7, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname8, Given8, Authorlink8, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname9, Given9, Authorlink9, &quot;&amp;#59; &quot;) .. &quot; &quot;                
    end
    if ( Editors == nil ) then
        Editors = &quot;&quot;
    else
        Editors = &quot; in &quot; .. Editors .. &quot;.&quot;
    end
    local text = Authors .. &quot;(&quot; .. Date .. &quot;).&quot; .. Chapter .. Editors .. Title .. Language .. Publisher .. ISBN .. DOI    
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; ~= Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    return text
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = anchorid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

return p</text>
      <sha1>kgycm09vo18p2l1520d1eilkcv0tubb</sha1>
    </revision>
    <revision>
      <id>4340</id>
      <parentid>4339</parentid>
      <timestamp>2012-08-25T19:32:10Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Accounted for nils.</comment>
      <origin>4340</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="8834" sha1="hqzs06i8me2g7qegqyb11xrddf6e05x" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    if ( &quot;span&quot; == name or &quot;div&quot; == name or &quot;blockquote&quot; == name ) then
        for n,v in pairs(t.params) do
            params = params .. &quot; &quot; .. n .. &quot;=\&quot;&quot; .. v .. &quot;\&quot;&quot;
        end
        return &quot;&lt;&quot; .. name .. params .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    else
        for n,v in pairs(t.params) do
            params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
        end
        return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
    end
end

function hideinprint(frame, content)
    return content
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function authorprefix(Surname, Given, Authorlink, ampersand)
    if (Surname == nil) then return &quot;&quot; end
    local prefix = ampersand .. Surname
    if (Given ~= nil) then prefix = prefix .. &quot;, &quot; .. Given end
    if (Authorlink ~= nil) then prefix = &quot;[[&quot; .. Authorlink .. &quot;|&quot; .. prefix .. &quot;]]&quot; end
    return prefix 
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args
    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 Surname2 = args.last2 or args.surname2 or args.author2
    local Surname3 = args.last3 or args.surname3 or args.author3
    local Surname4 = args.last4 or args.surname4 or args.author4
    local Surname5 = args.last5 or args.surname5 or args.author5
    local Surname6 = args.last6 or args.surname6 or args.author6
    local Surname7 = args.last7 or args.surname7 or args.author7
    local Surname8 = args.last8 or args.surname8 or args.author8
    local Surname9 = args.last9 or args.surname9 or args.author9
    local Given1 = args.first1 or args.given1 or args.first or args.given
    local Given2 = args.first2 or args.given2
    local Given3 = args.first3 or args.given3
    local Given4 = args.first4 or args.given4
    local Given5 = args.first5 or args.given5
    local Given6 = args.first6 or args.given6
    local Given7 = args.first7 or args.given7
    local Given8 = args.first8 or args.given8
    local Given9 = args.first9 or args.given9
    local Authorlink1 = args.authorlink or args.author1link or args.authorlink1
    local Authorlink2 = args.author2link or args.authorlink2
    local Authorlink3 = args.author3link or args.authorlink3
    local Authorlink4 = args.author4link or args.authorlink4
    local Authorlink5 = args.author5link or args.authorlink5
    local Authorlink6 = args.author6link or args.authorlink6
    local Authorlink7 = args.author7link or args.authorlink7
    local Authorlink8 = args.author8link or args.authorlink8
    local Authorlink9 = args.author9link or args.authorlink9
    local Coauthors = args.coauthor or args.coauthors 
    local Year = args.year or args.publicationdate or &quot;&quot;
    local Date = args.date or ((args.day or &quot;&quot;) .. (args.month or &quot;&quot;) .. Year)
    local Title = args.title or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN= args.isbn or args.ISBN
    local DOI= args.doi or args.DOI
    local Authors = args.authors 
    local Editors = args.editors 
    local Ref = args.ref or args.Ref
    if ( Chapter ~= nil ) then Chapter = &quot; \&quot;&quot; .. Chapter .. &quot;\&quot;.&quot; else Chapter = &quot;&quot; end
    if ( Title ~= nil ) then Title = &quot; ''&quot; .. Title .. &quot;''.&quot; else Title = &quot;&quot; end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; ISBN &quot; .. ISBN else ISBN = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI) else DOI = &quot;&quot; end
    if ( Authors == nil ) then
        Authors = authorprefix(Surname1, Given1, Authorlink1, &quot;&quot;)
        Authors = Authors .. authorprefix(Surname2, Given2, Authorlink2, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname3, Given3, Authorlink3, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname4, Given4, Authorlink4, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname5, Given5, Authorlink5, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname6, Given6, Authorlink6, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname7, Given7, Authorlink7, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname8, Given8, Authorlink8, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname9, Given9, Authorlink9, &quot;&amp;#59; &quot;) .. &quot; &quot;                
    end
    if ( Editors == nil ) then
        Editors = &quot;&quot;
    else
        Editors = &quot; in &quot; .. Editors .. &quot;.&quot;
    end
    local text = Authors .. &quot;(&quot; .. Date .. &quot;).&quot; .. Chapter .. Editors .. Title .. Language .. Publisher .. ISBN .. DOI    
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; ~= Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    return text
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = anchorid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

return p</text>
      <sha1>hqzs06i8me2g7qegqyb11xrddf6e05x</sha1>
    </revision>
    <revision>
      <id>4341</id>
      <parentid>4340</parentid>
      <timestamp>2012-08-25T19:43:45Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added URL parameter processing.</comment>
      <origin>4341</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="9529" sha1="gjjil81ledapsnil4qmg2gnp2u9hj19" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    if ( &quot;span&quot; == name or &quot;div&quot; == name or &quot;blockquote&quot; == name ) then
        for n,v in pairs(t.params) do
            params = params .. &quot; &quot; .. n .. &quot;=\&quot;&quot; .. v .. &quot;\&quot;&quot;
        end
        return &quot;&lt;&quot; .. name .. params .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    else
        for n,v in pairs(t.params) do
            params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
        end
        return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
    end
end

function hideinprint(frame, content)
    return content
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function authorprefix(Surname, Given, Authorlink, ampersand)
    if (Surname == nil) then return &quot;&quot; end
    local prefix = ampersand .. Surname
    if (Given ~= nil) then prefix = prefix .. &quot;, &quot; .. Given end
    if (Authorlink ~= nil) then prefix = &quot;[[&quot; .. Authorlink .. &quot;|&quot; .. prefix .. &quot;]]&quot; end
    return prefix 
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args
    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 Surname2 = args.last2 or args.surname2 or args.author2
    local Surname3 = args.last3 or args.surname3 or args.author3
    local Surname4 = args.last4 or args.surname4 or args.author4
    local Surname5 = args.last5 or args.surname5 or args.author5
    local Surname6 = args.last6 or args.surname6 or args.author6
    local Surname7 = args.last7 or args.surname7 or args.author7
    local Surname8 = args.last8 or args.surname8 or args.author8
    local Surname9 = args.last9 or args.surname9 or args.author9
    local Given1 = args.first1 or args.given1 or args.first or args.given
    local Given2 = args.first2 or args.given2
    local Given3 = args.first3 or args.given3
    local Given4 = args.first4 or args.given4
    local Given5 = args.first5 or args.given5
    local Given6 = args.first6 or args.given6
    local Given7 = args.first7 or args.given7
    local Given8 = args.first8 or args.given8
    local Given9 = args.first9 or args.given9
    local Authorlink1 = args.authorlink or args.author1link or args.authorlink1
    local Authorlink2 = args.author2link or args.authorlink2
    local Authorlink3 = args.author3link or args.authorlink3
    local Authorlink4 = args.author4link or args.authorlink4
    local Authorlink5 = args.author5link or args.authorlink5
    local Authorlink6 = args.author6link or args.authorlink6
    local Authorlink7 = args.author7link or args.authorlink7
    local Authorlink8 = args.author8link or args.authorlink8
    local Authorlink9 = args.author9link or args.authorlink9
    local Coauthors = args.coauthor or args.coauthors 
    local Year = args.year or args.publicationdate or &quot;&quot;
    local Date = args.date or ((args.day or &quot;&quot;) .. (args.month or &quot;&quot;) .. Year)
    local Title = args.title or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN= args.isbn or args.ISBN
    local DOI= args.doi or args.DOI
    local Authors = args.authors 
    local Editors = args.editors 
    local Ref = args.ref or args.Ref
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; ISBN &quot; .. ISBN else ISBN = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI) else DOI = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. URL else URL = &quot;&quot; end
    if ( Authors == nil ) then
        Authors = authorprefix(Surname1, Given1, Authorlink1, &quot;&quot;)
        Authors = Authors .. authorprefix(Surname2, Given2, Authorlink2, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname3, Given3, Authorlink3, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname4, Given4, Authorlink4, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname5, Given5, Authorlink5, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname6, Given6, Authorlink6, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname7, Given7, Authorlink7, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname8, Given8, Authorlink8, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname9, Given9, Authorlink9, &quot;&amp;#59; &quot;) .. &quot; &quot;                
    end
    if ( Editors ~= nil ) then
        Editors = &quot; in &quot; .. Editors .. &quot;.&quot;
    else
        Editors = &quot;&quot;    
    end
    local text = Authors .. &quot;(&quot; .. Date .. &quot;).&quot; .. Chapter .. Editors .. Title .. Language .. PublicationPlace .. Publisher .. ISBN .. DOI .. URL
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; ~= Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    return text
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = anchorid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

return p</text>
      <sha1>gjjil81ledapsnil4qmg2gnp2u9hj19</sha1>
    </revision>
    <revision>
      <id>4342</id>
      <parentid>4341</parentid>
      <timestamp>2012-08-25T19:47:13Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Fixed inverted test.</comment>
      <origin>4342</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="9529" sha1="o25lh7pxa2xwslqrlir9o5e9klrna19" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    if ( &quot;span&quot; == name or &quot;div&quot; == name or &quot;blockquote&quot; == name ) then
        for n,v in pairs(t.params) do
            params = params .. &quot; &quot; .. n .. &quot;=\&quot;&quot; .. v .. &quot;\&quot;&quot;
        end
        return &quot;&lt;&quot; .. name .. params .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    else
        for n,v in pairs(t.params) do
            params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
        end
        return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
    end
end

function hideinprint(frame, content)
    return content
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function authorprefix(Surname, Given, Authorlink, ampersand)
    if (Surname == nil) then return &quot;&quot; end
    local prefix = ampersand .. Surname
    if (Given ~= nil) then prefix = prefix .. &quot;, &quot; .. Given end
    if (Authorlink ~= nil) then prefix = &quot;[[&quot; .. Authorlink .. &quot;|&quot; .. prefix .. &quot;]]&quot; end
    return prefix 
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args
    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 Surname2 = args.last2 or args.surname2 or args.author2
    local Surname3 = args.last3 or args.surname3 or args.author3
    local Surname4 = args.last4 or args.surname4 or args.author4
    local Surname5 = args.last5 or args.surname5 or args.author5
    local Surname6 = args.last6 or args.surname6 or args.author6
    local Surname7 = args.last7 or args.surname7 or args.author7
    local Surname8 = args.last8 or args.surname8 or args.author8
    local Surname9 = args.last9 or args.surname9 or args.author9
    local Given1 = args.first1 or args.given1 or args.first or args.given
    local Given2 = args.first2 or args.given2
    local Given3 = args.first3 or args.given3
    local Given4 = args.first4 or args.given4
    local Given5 = args.first5 or args.given5
    local Given6 = args.first6 or args.given6
    local Given7 = args.first7 or args.given7
    local Given8 = args.first8 or args.given8
    local Given9 = args.first9 or args.given9
    local Authorlink1 = args.authorlink or args.author1link or args.authorlink1
    local Authorlink2 = args.author2link or args.authorlink2
    local Authorlink3 = args.author3link or args.authorlink3
    local Authorlink4 = args.author4link or args.authorlink4
    local Authorlink5 = args.author5link or args.authorlink5
    local Authorlink6 = args.author6link or args.authorlink6
    local Authorlink7 = args.author7link or args.authorlink7
    local Authorlink8 = args.author8link or args.authorlink8
    local Authorlink9 = args.author9link or args.authorlink9
    local Coauthors = args.coauthor or args.coauthors 
    local Year = args.year or args.publicationdate or &quot;&quot;
    local Date = args.date or ((args.day or &quot;&quot;) .. (args.month or &quot;&quot;) .. Year)
    local Title = args.title or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN= args.isbn or args.ISBN
    local DOI= args.doi or args.DOI
    local Authors = args.authors 
    local Editors = args.editors 
    local Ref = args.ref or args.Ref
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; ISBN &quot; .. ISBN else ISBN = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI) else DOI = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. URL else URL = &quot;&quot; end
    if ( Authors == nil ) then
        Authors = authorprefix(Surname1, Given1, Authorlink1, &quot;&quot;)
        Authors = Authors .. authorprefix(Surname2, Given2, Authorlink2, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname3, Given3, Authorlink3, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname4, Given4, Authorlink4, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname5, Given5, Authorlink5, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname6, Given6, Authorlink6, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname7, Given7, Authorlink7, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname8, Given8, Authorlink8, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname9, Given9, Authorlink9, &quot;&amp;#59; &quot;) .. &quot; &quot;                
    end
    if ( Editors ~= nil ) then
        Editors = &quot; in &quot; .. Editors .. &quot;.&quot;
    else
        Editors = &quot;&quot;    
    end
    local text = Authors .. &quot;(&quot; .. Date .. &quot;).&quot; .. Chapter .. Editors .. Title .. Language .. PublicationPlace .. Publisher .. ISBN .. DOI .. URL
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    return text
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = anchorid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

return p</text>
      <sha1>o25lh7pxa2xwslqrlir9o5e9klrna19</sha1>
    </revision>
    <revision>
      <id>4343</id>
      <parentid>4342</parentid>
      <timestamp>2012-08-25T19:57:22Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added processing of more parameters.</comment>
      <origin>4343</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="10183" sha1="k21tx0ktolt2t8ou8gtcni3i0okb2e8" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    if ( &quot;span&quot; == name or &quot;div&quot; == name or &quot;blockquote&quot; == name ) then
        for n,v in pairs(t.params) do
            params = params .. &quot; &quot; .. n .. &quot;=\&quot;&quot; .. v .. &quot;\&quot;&quot;
        end
        return &quot;&lt;&quot; .. name .. params .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    else
        for n,v in pairs(t.params) do
            params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
        end
        return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
    end
end

function hideinprint(frame, content)
    return content
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function authorprefix(Surname, Given, Authorlink, ampersand)
    if (Surname == nil) then return &quot;&quot; end
    local prefix = ampersand .. Surname
    if (Given ~= nil) then prefix = prefix .. &quot;, &quot; .. Given end
    if (Authorlink ~= nil) then prefix = &quot;[[&quot; .. Authorlink .. &quot;|&quot; .. prefix .. &quot;]]&quot; end
    return prefix 
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args
    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 Surname2 = args.last2 or args.surname2 or args.author2
    local Surname3 = args.last3 or args.surname3 or args.author3
    local Surname4 = args.last4 or args.surname4 or args.author4
    local Surname5 = args.last5 or args.surname5 or args.author5
    local Surname6 = args.last6 or args.surname6 or args.author6
    local Surname7 = args.last7 or args.surname7 or args.author7
    local Surname8 = args.last8 or args.surname8 or args.author8
    local Surname9 = args.last9 or args.surname9 or args.author9
    local Given1 = args.first1 or args.given1 or args.first or args.given
    local Given2 = args.first2 or args.given2
    local Given3 = args.first3 or args.given3
    local Given4 = args.first4 or args.given4
    local Given5 = args.first5 or args.given5
    local Given6 = args.first6 or args.given6
    local Given7 = args.first7 or args.given7
    local Given8 = args.first8 or args.given8
    local Given9 = args.first9 or args.given9
    local Authorlink1 = args.authorlink or args.author1link or args.authorlink1
    local Authorlink2 = args.author2link or args.authorlink2
    local Authorlink3 = args.author3link or args.authorlink3
    local Authorlink4 = args.author4link or args.authorlink4
    local Authorlink5 = args.author5link or args.authorlink5
    local Authorlink6 = args.author6link or args.authorlink6
    local Authorlink7 = args.author7link or args.authorlink7
    local Authorlink8 = args.author8link or args.authorlink8
    local Authorlink9 = args.author9link or args.authorlink9
    local Coauthors = args.coauthor or args.coauthors 
    local Year = args.year or args.publicationdate or &quot;&quot;
    local Date = args.date or ((args.day or &quot;&quot;) .. (args.month or &quot;&quot;) .. Year)
    local Title = args.title or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Journal = args.journal or args.newspaper or args.magazine
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN= args.isbn or args.ISBN
    local DOI= args.doi or args.DOI
    local Authors = args.authors 
    local Editors = args.editors 
    local Ref = args.ref or args.Ref
    if ( Journal ~= nil ) then
        Chapter = Title
        Title = Journal
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; ISBN &quot; .. ISBN else ISBN = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI) else DOI = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. URL else URL = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; &quot; .. Edition .. &quot; edition&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Authors == nil ) then
        Authors = authorprefix(Surname1, Given1, Authorlink1, &quot;&quot;)
        Authors = Authors .. authorprefix(Surname2, Given2, Authorlink2, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname3, Given3, Authorlink3, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname4, Given4, Authorlink4, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname5, Given5, Authorlink5, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname6, Given6, Authorlink6, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname7, Given7, Authorlink7, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname8, Given8, Authorlink8, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname9, Given9, Authorlink9, &quot;&amp;#59; &quot;) .. &quot; &quot;                
    end
    if ( Editors ~= nil ) then
        Editors = &quot; in &quot; .. Editors .. &quot;.&quot;
    else
        Editors = &quot;&quot;    
    end
    local text = Authors .. &quot;(&quot; .. Date .. &quot;).&quot; .. Chapter .. Editors .. Title .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. ISBN .. DOI .. URL
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    return text
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = anchorid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

return p</text>
      <sha1>k21tx0ktolt2t8ou8gtcni3i0okb2e8</sha1>
    </revision>
    <revision>
      <id>4344</id>
      <parentid>4343</parentid>
      <timestamp>2012-08-25T20:06:59Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added processing of more parameters.</comment>
      <origin>4344</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="10645" sha1="rcebliy2kfnnua4mquodhkd9eamnedi" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    if ( &quot;span&quot; == name or &quot;div&quot; == name or &quot;blockquote&quot; == name ) then
        for n,v in pairs(t.params) do
            params = params .. &quot; &quot; .. n .. &quot;=\&quot;&quot; .. v .. &quot;\&quot;&quot;
        end
        return &quot;&lt;&quot; .. name .. params .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    else
        for n,v in pairs(t.params) do
            params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
        end
        return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
    end
end

function hideinprint(frame, content)
    return content
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function authorprefix(Surname, Given, Authorlink, ampersand)
    if (Surname == nil) then return &quot;&quot; end
    local prefix = ampersand .. Surname
    if (Given ~= nil) then prefix = prefix .. &quot;, &quot; .. Given end
    if (Authorlink ~= nil) then prefix = &quot;[[&quot; .. Authorlink .. &quot;|&quot; .. prefix .. &quot;]]&quot; end
    return prefix 
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args
    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 Surname2 = args.last2 or args.surname2 or args.author2
    local Surname3 = args.last3 or args.surname3 or args.author3
    local Surname4 = args.last4 or args.surname4 or args.author4
    local Surname5 = args.last5 or args.surname5 or args.author5
    local Surname6 = args.last6 or args.surname6 or args.author6
    local Surname7 = args.last7 or args.surname7 or args.author7
    local Surname8 = args.last8 or args.surname8 or args.author8
    local Surname9 = args.last9 or args.surname9 or args.author9
    local Given1 = args.first1 or args.given1 or args.first or args.given
    local Given2 = args.first2 or args.given2
    local Given3 = args.first3 or args.given3
    local Given4 = args.first4 or args.given4
    local Given5 = args.first5 or args.given5
    local Given6 = args.first6 or args.given6
    local Given7 = args.first7 or args.given7
    local Given8 = args.first8 or args.given8
    local Given9 = args.first9 or args.given9
    local Authorlink1 = args.authorlink or args.author1link or args.authorlink1
    local Authorlink2 = args.author2link or args.authorlink2
    local Authorlink3 = args.author3link or args.authorlink3
    local Authorlink4 = args.author4link or args.authorlink4
    local Authorlink5 = args.author5link or args.authorlink5
    local Authorlink6 = args.author6link or args.authorlink6
    local Authorlink7 = args.author7link or args.authorlink7
    local Authorlink8 = args.author8link or args.authorlink8
    local Authorlink9 = args.author9link or args.authorlink9
    local Coauthors = args.coauthor or args.coauthors 
    local Year = args.year or args.publicationdate or &quot;&quot;
    local Date = args.date
    local Title = args.title or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Journal = args.journal or args.newspaper or args.magazine
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN = args.isbn or args.ISBN
    local DOI = args.doi or args.DOI
    local ID = args.id or args.ID or args.pmid or arms.PMID
    local Authors = args.authors 
    local Editors = args.editors 
    local Ref = args.ref or args.Ref
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Journal ~= nil ) then
        Chapter = Title
        Title = Journal
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; ISBN &quot; .. ISBN else ISBN = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI) else DOI = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. URL else URL = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; &quot; .. Edition .. &quot; edition&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( Authors == nil ) then
        Authors = authorprefix(Surname1, Given1, Authorlink1, &quot;&quot;)
        Authors = Authors .. authorprefix(Surname2, Given2, Authorlink2, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname3, Given3, Authorlink3, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname4, Given4, Authorlink4, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname5, Given5, Authorlink5, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname6, Given6, Authorlink6, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname7, Given7, Authorlink7, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname8, Given8, Authorlink8, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname9, Given9, Authorlink9, &quot;&amp;#59; &quot;) .. &quot; &quot;                
    end
    if ( Editors ~= nil ) then
        Editors = &quot; in &quot; .. Editors .. &quot;.&quot;
    else
        Editors = &quot;&quot;    
    end
    local text = Authors .. &quot;(&quot; .. Date .. &quot;).&quot; .. Chapter .. Editors .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. ISBN .. DOI .. ID .. URL
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    return text
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = anchorid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

return p</text>
      <sha1>rcebliy2kfnnua4mquodhkd9eamnedi</sha1>
    </revision>
    <revision>
      <id>4345</id>
      <parentid>4344</parentid>
      <timestamp>2012-08-25T20:07:52Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Corrected my typing error.</comment>
      <origin>4345</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="10645" sha1="9ym72jbv4jay3hjrdcuuhpzm696rij0" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    if ( &quot;span&quot; == name or &quot;div&quot; == name or &quot;blockquote&quot; == name ) then
        for n,v in pairs(t.params) do
            params = params .. &quot; &quot; .. n .. &quot;=\&quot;&quot; .. v .. &quot;\&quot;&quot;
        end
        return &quot;&lt;&quot; .. name .. params .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    else
        for n,v in pairs(t.params) do
            params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
        end
        return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
    end
end

function hideinprint(frame, content)
    return content
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function authorprefix(Surname, Given, Authorlink, ampersand)
    if (Surname == nil) then return &quot;&quot; end
    local prefix = ampersand .. Surname
    if (Given ~= nil) then prefix = prefix .. &quot;, &quot; .. Given end
    if (Authorlink ~= nil) then prefix = &quot;[[&quot; .. Authorlink .. &quot;|&quot; .. prefix .. &quot;]]&quot; end
    return prefix 
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args
    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 Surname2 = args.last2 or args.surname2 or args.author2
    local Surname3 = args.last3 or args.surname3 or args.author3
    local Surname4 = args.last4 or args.surname4 or args.author4
    local Surname5 = args.last5 or args.surname5 or args.author5
    local Surname6 = args.last6 or args.surname6 or args.author6
    local Surname7 = args.last7 or args.surname7 or args.author7
    local Surname8 = args.last8 or args.surname8 or args.author8
    local Surname9 = args.last9 or args.surname9 or args.author9
    local Given1 = args.first1 or args.given1 or args.first or args.given
    local Given2 = args.first2 or args.given2
    local Given3 = args.first3 or args.given3
    local Given4 = args.first4 or args.given4
    local Given5 = args.first5 or args.given5
    local Given6 = args.first6 or args.given6
    local Given7 = args.first7 or args.given7
    local Given8 = args.first8 or args.given8
    local Given9 = args.first9 or args.given9
    local Authorlink1 = args.authorlink or args.author1link or args.authorlink1
    local Authorlink2 = args.author2link or args.authorlink2
    local Authorlink3 = args.author3link or args.authorlink3
    local Authorlink4 = args.author4link or args.authorlink4
    local Authorlink5 = args.author5link or args.authorlink5
    local Authorlink6 = args.author6link or args.authorlink6
    local Authorlink7 = args.author7link or args.authorlink7
    local Authorlink8 = args.author8link or args.authorlink8
    local Authorlink9 = args.author9link or args.authorlink9
    local Coauthors = args.coauthor or args.coauthors 
    local Year = args.year or args.publicationdate or &quot;&quot;
    local Date = args.date
    local Title = args.title or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Journal = args.journal or args.newspaper or args.magazine
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN = args.isbn or args.ISBN
    local DOI = args.doi or args.DOI
    local ID = args.id or args.ID or args.pmid or args.PMID
    local Authors = args.authors 
    local Editors = args.editors 
    local Ref = args.ref or args.Ref
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Journal ~= nil ) then
        Chapter = Title
        Title = Journal
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; ISBN &quot; .. ISBN else ISBN = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI) else DOI = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. URL else URL = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; &quot; .. Edition .. &quot; edition&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( Authors == nil ) then
        Authors = authorprefix(Surname1, Given1, Authorlink1, &quot;&quot;)
        Authors = Authors .. authorprefix(Surname2, Given2, Authorlink2, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname3, Given3, Authorlink3, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname4, Given4, Authorlink4, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname5, Given5, Authorlink5, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname6, Given6, Authorlink6, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname7, Given7, Authorlink7, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname8, Given8, Authorlink8, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname9, Given9, Authorlink9, &quot;&amp;#59; &quot;) .. &quot; &quot;                
    end
    if ( Editors ~= nil ) then
        Editors = &quot; in &quot; .. Editors .. &quot;.&quot;
    else
        Editors = &quot;&quot;    
    end
    local text = Authors .. &quot;(&quot; .. Date .. &quot;).&quot; .. Chapter .. Editors .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. ISBN .. DOI .. ID .. URL
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    return text
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = anchorid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

return p</text>
      <sha1>9ym72jbv4jay3hjrdcuuhpzm696rij0</sha1>
    </revision>
    <revision>
      <id>4346</id>
      <parentid>4345</parentid>
      <timestamp>2012-08-25T20:41:18Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Tweaked formatting.</comment>
      <origin>4346</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="10781" sha1="cxgyv5ntg9wkzawqumxgrkgstfnw20c" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    if ( &quot;span&quot; == name or &quot;div&quot; == name or &quot;blockquote&quot; == name ) then
        for n,v in pairs(t.params) do
            params = params .. &quot; &quot; .. n .. &quot;=\&quot;&quot; .. v .. &quot;\&quot;&quot;
        end
        return &quot;&lt;&quot; .. name .. params .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    else
        for n,v in pairs(t.params) do
            params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
        end
        return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
    end
end

function hideinprint(frame, content)
    return content
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function authorprefix(Surname, Given, Authorlink, ampersand)
    if (Surname == nil) then return &quot;&quot; end
    local prefix = ampersand .. Surname
    if (Given ~= nil) then prefix = prefix .. &quot;, &quot; .. Given end
    if (Authorlink ~= nil) then prefix = &quot;[[&quot; .. Authorlink .. &quot;|&quot; .. prefix .. &quot;]]&quot; end
    return prefix 
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args
    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 Surname2 = args.last2 or args.surname2 or args.author2
    local Surname3 = args.last3 or args.surname3 or args.author3
    local Surname4 = args.last4 or args.surname4 or args.author4
    local Surname5 = args.last5 or args.surname5 or args.author5
    local Surname6 = args.last6 or args.surname6 or args.author6
    local Surname7 = args.last7 or args.surname7 or args.author7
    local Surname8 = args.last8 or args.surname8 or args.author8
    local Surname9 = args.last9 or args.surname9 or args.author9
    local Given1 = args.first1 or args.given1 or args.first or args.given
    local Given2 = args.first2 or args.given2
    local Given3 = args.first3 or args.given3
    local Given4 = args.first4 or args.given4
    local Given5 = args.first5 or args.given5
    local Given6 = args.first6 or args.given6
    local Given7 = args.first7 or args.given7
    local Given8 = args.first8 or args.given8
    local Given9 = args.first9 or args.given9
    local Authorlink1 = args.authorlink or args.author1link or args.authorlink1
    local Authorlink2 = args.author2link or args.authorlink2
    local Authorlink3 = args.author3link or args.authorlink3
    local Authorlink4 = args.author4link or args.authorlink4
    local Authorlink5 = args.author5link or args.authorlink5
    local Authorlink6 = args.author6link or args.authorlink6
    local Authorlink7 = args.author7link or args.authorlink7
    local Authorlink8 = args.author8link or args.authorlink8
    local Authorlink9 = args.author9link or args.authorlink9
    local Coauthors = args.coauthor or args.coauthors 
    local Year = args.year or args.publicationdate or &quot;&quot;
    local Date = args.date
    local Title = args.title or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Journal = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN = args.isbn or args.ISBN
    local DOI = args.doi or args.DOI
    local ID = args.id or args.ID or args.pmid or args.PMID
    local Authors = args.authors 
    local Editors = args.editors 
    local Ref = args.ref or args.Ref
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Journal ~= nil ) then
        Chapter = Title
        Title = Journal
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; ISBN &quot; .. ISBN else ISBN = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI) else DOI = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. URL else URL = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; &quot; .. Edition .. &quot; edition&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Authors == nil ) then
        Authors = authorprefix(Surname1, Given1, Authorlink1, &quot;&quot;)
        Authors = Authors .. authorprefix(Surname2, Given2, Authorlink2, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname3, Given3, Authorlink3, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname4, Given4, Authorlink4, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname5, Given5, Authorlink5, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname6, Given6, Authorlink6, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname7, Given7, Authorlink7, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname8, Given8, Authorlink8, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname9, Given9, Authorlink9, &quot;&amp;#59; &quot;)       
    end
    if ( &quot;&quot; ~= Authors and &quot;&quot; ~= Date ) then
        Date = Date .. &quot;.&quot;
    end
    if ( Editors ~= nil ) then
        Editors = &quot; in &quot; .. Editors .. &quot;.&quot;
    else
        Editors = &quot;&quot;    
    end
    local text = Authors .. Date .. Chapter .. Editors .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. ISBN .. DOI .. ID .. URL
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    return text
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = anchorid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

return p</text>
      <sha1>cxgyv5ntg9wkzawqumxgrkgstfnw20c</sha1>
    </revision>
    <revision>
      <id>4347</id>
      <parentid>4346</parentid>
      <timestamp>2012-08-25T20:50:53Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added commentary and code to prevent missing years generating punctuation.</comment>
      <origin>4347</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="11603" sha1="jl2avo90gbko0jqzsyvbiltdpuy0vsg" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    if ( &quot;span&quot; == name or &quot;div&quot; == name or &quot;blockquote&quot; == name ) then
        for n,v in pairs(t.params) do
            params = params .. &quot; &quot; .. n .. &quot;=\&quot;&quot; .. v .. &quot;\&quot;&quot;
        end
        return &quot;&lt;&quot; .. name .. params .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    else
        for n,v in pairs(t.params) do
            params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
        end
        return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
    end
end

function hideinprint(frame, content)
    return content
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function authorprefix(Surname, Given, Authorlink, ampersand)
    if (Surname == nil) then return &quot;&quot; end
    local prefix = ampersand .. Surname
    if (Given ~= nil) then prefix = prefix .. &quot;, &quot; .. Given end
    if (Authorlink ~= nil) then prefix = &quot;[[&quot; .. Authorlink .. &quot;|&quot; .. prefix .. &quot;]]&quot; end
    return prefix 
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

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 Surname2 = args.last2 or args.surname2 or args.author2
    local Surname3 = args.last3 or args.surname3 or args.author3
    local Surname4 = args.last4 or args.surname4 or args.author4
    local Surname5 = args.last5 or args.surname5 or args.author5
    local Surname6 = args.last6 or args.surname6 or args.author6
    local Surname7 = args.last7 or args.surname7 or args.author7
    local Surname8 = args.last8 or args.surname8 or args.author8
    local Surname9 = args.last9 or args.surname9 or args.author9
    local Given1 = args.first1 or args.given1 or args.first or args.given
    local Given2 = args.first2 or args.given2
    local Given3 = args.first3 or args.given3
    local Given4 = args.first4 or args.given4
    local Given5 = args.first5 or args.given5
    local Given6 = args.first6 or args.given6
    local Given7 = args.first7 or args.given7
    local Given8 = args.first8 or args.given8
    local Given9 = args.first9 or args.given9
    local Authorlink1 = args.authorlink or args.author1link or args.authorlink1
    local Authorlink2 = args.author2link or args.authorlink2
    local Authorlink3 = args.author3link or args.authorlink3
    local Authorlink4 = args.author4link or args.authorlink4
    local Authorlink5 = args.author5link or args.authorlink5
    local Authorlink6 = args.author6link or args.authorlink6
    local Authorlink7 = args.author7link or args.authorlink7
    local Authorlink8 = args.author8link or args.authorlink8
    local Authorlink9 = args.author9link or args.authorlink9
    local Coauthors = args.coauthor or args.coauthors 
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Journal = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN = args.isbn or args.ISBN
    local DOI = args.doi or args.DOI
    local ID = args.id or args.ID or args.pmid or args.PMID
    local Authors = args.authors 
    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
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Journal ~= nil ) then
        Chapter = Title
        Title = Journal
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; ISBN &quot; .. ISBN else ISBN = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI) else DOI = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. URL else URL = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; &quot; .. Edition .. &quot; edition&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Authors == nil ) then
        Authors = authorprefix(Surname1, Given1, Authorlink1, &quot;&quot;)
        Authors = Authors .. authorprefix(Surname2, Given2, Authorlink2, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname3, Given3, Authorlink3, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname4, Given4, Authorlink4, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname5, Given5, Authorlink5, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname6, Given6, Authorlink6, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname7, Given7, Authorlink7, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname8, Given8, Authorlink8, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname9, Given9, Authorlink9, &quot;&amp;#59; &quot;)       
    end
    if ( &quot;&quot; ~= Authors and &quot;&quot; ~= Date ) then
        Date = Date .. &quot;.&quot;
    end
    if ( Editors ~= nil ) then
        Editors = &quot; in &quot; .. Editors .. &quot;.&quot;
    else
        Editors = &quot;&quot;    
    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 &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    return text
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = anchorid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

return p</text>
      <sha1>jl2avo90gbko0jqzsyvbiltdpuy0vsg</sha1>
    </revision>
    <revision>
      <id>4348</id>
      <parentid>4347</parentid>
      <timestamp>2012-08-25T21:21:56Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Fixed anchor IDs to include page numbers.</comment>
      <origin>4348</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="11712" sha1="h5siv9euv526pcwqa83smdwveo99ifr" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    if ( &quot;span&quot; == name or &quot;div&quot; == name or &quot;blockquote&quot; == name ) then
        for n,v in pairs(t.params) do
            params = params .. &quot; &quot; .. n .. &quot;=\&quot;&quot; .. v .. &quot;\&quot;&quot;
        end
        return &quot;&lt;&quot; .. name .. params .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    else
        for n,v in pairs(t.params) do
            params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
        end
        return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
    end
end

function hideinprint(frame, content)
    return content
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function authorprefix(Surname, Given, Authorlink, ampersand)
    if (Surname == nil) then return &quot;&quot; end
    local prefix = ampersand .. Surname
    if (Given ~= nil) then prefix = prefix .. &quot;, &quot; .. Given end
    if (Authorlink ~= nil) then prefix = &quot;[[&quot; .. Authorlink .. &quot;|&quot; .. prefix .. &quot;]]&quot; end
    return prefix 
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5 .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

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 Surname2 = args.last2 or args.surname2 or args.author2
    local Surname3 = args.last3 or args.surname3 or args.author3
    local Surname4 = args.last4 or args.surname4 or args.author4
    local Surname5 = args.last5 or args.surname5 or args.author5
    local Surname6 = args.last6 or args.surname6 or args.author6
    local Surname7 = args.last7 or args.surname7 or args.author7
    local Surname8 = args.last8 or args.surname8 or args.author8
    local Surname9 = args.last9 or args.surname9 or args.author9
    local Given1 = args.first1 or args.given1 or args.first or args.given
    local Given2 = args.first2 or args.given2
    local Given3 = args.first3 or args.given3
    local Given4 = args.first4 or args.given4
    local Given5 = args.first5 or args.given5
    local Given6 = args.first6 or args.given6
    local Given7 = args.first7 or args.given7
    local Given8 = args.first8 or args.given8
    local Given9 = args.first9 or args.given9
    local Authorlink1 = args.authorlink or args.author1link or args.authorlink1
    local Authorlink2 = args.author2link or args.authorlink2
    local Authorlink3 = args.author3link or args.authorlink3
    local Authorlink4 = args.author4link or args.authorlink4
    local Authorlink5 = args.author5link or args.authorlink5
    local Authorlink6 = args.author6link or args.authorlink6
    local Authorlink7 = args.author7link or args.authorlink7
    local Authorlink8 = args.author8link or args.authorlink8
    local Authorlink9 = args.author9link or args.authorlink9
    local Coauthors = args.coauthor or args.coauthors 
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Journal = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN = args.isbn or args.ISBN
    local DOI = args.doi or args.DOI
    local ID = args.id or args.ID or args.pmid or args.PMID
    local Authors = args.authors 
    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
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Journal ~= nil ) then
        Chapter = Title
        Title = Journal
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; ISBN &quot; .. ISBN else ISBN = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI) else DOI = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. URL else URL = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; &quot; .. Edition .. &quot; edition&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Authors == nil ) then
        Authors = authorprefix(Surname1, Given1, Authorlink1, &quot;&quot;)
        Authors = Authors .. authorprefix(Surname2, Given2, Authorlink2, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname3, Given3, Authorlink3, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname4, Given4, Authorlink4, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname5, Given5, Authorlink5, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname6, Given6, Authorlink6, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname7, Given7, Authorlink7, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname8, Given8, Authorlink8, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname9, Given9, Authorlink9, &quot;&amp;#59; &quot;)       
    end
    if ( &quot;&quot; ~= Authors and &quot;&quot; ~= Date ) then
        Date = Date .. &quot;.&quot;
    end
    if ( Editors ~= nil ) then
        Editors = &quot; in &quot; .. Editors .. &quot;.&quot;
    else
        Editors = &quot;&quot;    
    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 &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    return text
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = anchorid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

return p</text>
      <sha1>h5siv9euv526pcwqa83smdwveo99ifr</sha1>
    </revision>
    <revision>
      <id>4349</id>
      <parentid>4348</parentid>
      <timestamp>2012-08-25T21:26:28Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Differentiated IDs.</comment>
      <origin>4349</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="11761" sha1="icixt8svc2w86hxhm9knwisinc09qde" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    if ( &quot;span&quot; == name or &quot;div&quot; == name or &quot;blockquote&quot; == name ) then
        for n,v in pairs(t.params) do
            params = params .. &quot; &quot; .. n .. &quot;=\&quot;&quot; .. v .. &quot;\&quot;&quot;
        end
        return &quot;&lt;&quot; .. name .. params .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    else
        for n,v in pairs(t.params) do
            params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
        end
        return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
    end
end

function hideinprint(frame, content)
    return content
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function authorprefix(Surname, Given, Authorlink, ampersand)
    if (Surname == nil) then return &quot;&quot; end
    local prefix = ampersand .. Surname
    if (Given ~= nil) then prefix = prefix .. &quot;, &quot; .. Given end
    if (Authorlink ~= nil) then prefix = &quot;[[&quot; .. Authorlink .. &quot;|&quot; .. prefix .. &quot;]]&quot; end
    return prefix 
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

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 Surname2 = args.last2 or args.surname2 or args.author2
    local Surname3 = args.last3 or args.surname3 or args.author3
    local Surname4 = args.last4 or args.surname4 or args.author4
    local Surname5 = args.last5 or args.surname5 or args.author5
    local Surname6 = args.last6 or args.surname6 or args.author6
    local Surname7 = args.last7 or args.surname7 or args.author7
    local Surname8 = args.last8 or args.surname8 or args.author8
    local Surname9 = args.last9 or args.surname9 or args.author9
    local Given1 = args.first1 or args.given1 or args.first or args.given
    local Given2 = args.first2 or args.given2
    local Given3 = args.first3 or args.given3
    local Given4 = args.first4 or args.given4
    local Given5 = args.first5 or args.given5
    local Given6 = args.first6 or args.given6
    local Given7 = args.first7 or args.given7
    local Given8 = args.first8 or args.given8
    local Given9 = args.first9 or args.given9
    local Authorlink1 = args.authorlink or args.author1link or args.authorlink1
    local Authorlink2 = args.author2link or args.authorlink2
    local Authorlink3 = args.author3link or args.authorlink3
    local Authorlink4 = args.author4link or args.authorlink4
    local Authorlink5 = args.author5link or args.authorlink5
    local Authorlink6 = args.author6link or args.authorlink6
    local Authorlink7 = args.author7link or args.authorlink7
    local Authorlink8 = args.author8link or args.authorlink8
    local Authorlink9 = args.author9link or args.authorlink9
    local Coauthors = args.coauthor or args.coauthors 
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Journal = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN = args.isbn or args.ISBN
    local DOI = args.doi or args.DOI
    local ID = args.id or args.ID or args.pmid or args.PMID
    local Authors = args.authors 
    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
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Journal ~= nil ) then
        Chapter = Title
        Title = Journal
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; ISBN &quot; .. ISBN else ISBN = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI) else DOI = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. URL else URL = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; &quot; .. Edition .. &quot; edition&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Authors == nil ) then
        Authors = authorprefix(Surname1, Given1, Authorlink1, &quot;&quot;)
        Authors = Authors .. authorprefix(Surname2, Given2, Authorlink2, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname3, Given3, Authorlink3, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname4, Given4, Authorlink4, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname5, Given5, Authorlink5, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname6, Given6, Authorlink6, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname7, Given7, Authorlink7, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname8, Given8, Authorlink8, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname9, Given9, Authorlink9, &quot;&amp;#59; &quot;)       
    end
    if ( &quot;&quot; ~= Authors and &quot;&quot; ~= Date ) then
        Date = Date .. &quot;.&quot;
    end
    if ( Editors ~= nil ) then
        Editors = &quot; in &quot; .. Editors .. &quot;.&quot;
    else
        Editors = &quot;&quot;    
    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 &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    return text
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

return p</text>
      <sha1>icixt8svc2w86hxhm9knwisinc09qde</sha1>
    </revision>
    <revision>
      <id>4350</id>
      <parentid>4349</parentid>
      <timestamp>2012-08-25T22:07:53Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added function for DOIs.</comment>
      <origin>4350</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="11984" sha1="t2x82vbb7soxwfhzaj678428g39dzw8" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    if ( &quot;span&quot; == name or &quot;div&quot; == name or &quot;blockquote&quot; == name ) then
        for n,v in pairs(t.params) do
            params = params .. &quot; &quot; .. n .. &quot;=\&quot;&quot; .. v .. &quot;\&quot;&quot;
        end
        return &quot;&lt;&quot; .. name .. params .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    else
        for n,v in pairs(t.params) do
            params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
        end
        return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
    end
end

function hideinprint(frame, content)
    return content
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function authorprefix(Surname, Given, Authorlink, ampersand)
    if (Surname == nil) then return &quot;&quot; end
    local prefix = ampersand .. Surname
    if (Given ~= nil) then prefix = prefix .. &quot;, &quot; .. Given end
    if (Authorlink ~= nil) then prefix = &quot;[[&quot; .. Authorlink .. &quot;|&quot; .. prefix .. &quot;]]&quot; end
    return prefix 
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

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 Surname2 = args.last2 or args.surname2 or args.author2
    local Surname3 = args.last3 or args.surname3 or args.author3
    local Surname4 = args.last4 or args.surname4 or args.author4
    local Surname5 = args.last5 or args.surname5 or args.author5
    local Surname6 = args.last6 or args.surname6 or args.author6
    local Surname7 = args.last7 or args.surname7 or args.author7
    local Surname8 = args.last8 or args.surname8 or args.author8
    local Surname9 = args.last9 or args.surname9 or args.author9
    local Given1 = args.first1 or args.given1 or args.first or args.given
    local Given2 = args.first2 or args.given2
    local Given3 = args.first3 or args.given3
    local Given4 = args.first4 or args.given4
    local Given5 = args.first5 or args.given5
    local Given6 = args.first6 or args.given6
    local Given7 = args.first7 or args.given7
    local Given8 = args.first8 or args.given8
    local Given9 = args.first9 or args.given9
    local Authorlink1 = args.authorlink or args.author1link or args.authorlink1
    local Authorlink2 = args.author2link or args.authorlink2
    local Authorlink3 = args.author3link or args.authorlink3
    local Authorlink4 = args.author4link or args.authorlink4
    local Authorlink5 = args.author5link or args.authorlink5
    local Authorlink6 = args.author6link or args.authorlink6
    local Authorlink7 = args.author7link or args.authorlink7
    local Authorlink8 = args.author8link or args.authorlink8
    local Authorlink9 = args.author9link or args.authorlink9
    local Coauthors = args.coauthor or args.coauthors 
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Journal = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN = args.isbn or args.ISBN
    local DOI = args.doi or args.DOI
    local ID = args.id or args.ID or args.pmid or args.PMID
    local Authors = args.authors 
    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
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Journal ~= nil ) then
        Chapter = Title
        Title = Journal
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; ISBN &quot; .. ISBN else ISBN = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI) else DOI = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. URL else URL = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; &quot; .. Edition .. &quot; edition&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Authors == nil ) then
        Authors = authorprefix(Surname1, Given1, Authorlink1, &quot;&quot;)
        Authors = Authors .. authorprefix(Surname2, Given2, Authorlink2, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname3, Given3, Authorlink3, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname4, Given4, Authorlink4, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname5, Given5, Authorlink5, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname6, Given6, Authorlink6, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname7, Given7, Authorlink7, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname8, Given8, Authorlink8, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname9, Given9, Authorlink9, &quot;&amp;#59; &quot;)       
    end
    if ( &quot;&quot; ~= Authors and &quot;&quot; ~= Date ) then
        Date = Date .. &quot;.&quot;
    end
    if ( Editors ~= nil ) then
        Editors = &quot; in &quot; .. Editors .. &quot;.&quot;
    else
        Editors = &quot;&quot;    
    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 &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    return text
end

-- This is used by {{doi}} to create DOI links in the style used in citatoins.
function p.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

return p</text>
      <sha1>t2x82vbb7soxwfhzaj678428g39dzw8</sha1>
    </revision>
    <revision>
      <id>4351</id>
      <parentid>4350</parentid>
      <timestamp>2012-08-25T22:25:15Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added function for ISSNs.</comment>
      <origin>4351</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="12324" sha1="dq5wi1z873jx3ls2gecc5zj55kh1nkh" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    if ( &quot;span&quot; == name or &quot;div&quot; == name or &quot;blockquote&quot; == name ) then
        for n,v in pairs(t.params) do
            params = params .. &quot; &quot; .. n .. &quot;=\&quot;&quot; .. v .. &quot;\&quot;&quot;
        end
        return &quot;&lt;&quot; .. name .. params .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    else
        for n,v in pairs(t.params) do
            params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
        end
        return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
    end
end

function hideinprint(frame, content)
    return content
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function authorprefix(Surname, Given, Authorlink, ampersand)
    if (Surname == nil) then return &quot;&quot; end
    local prefix = ampersand .. Surname
    if (Given ~= nil) then prefix = prefix .. &quot;, &quot; .. Given end
    if (Authorlink ~= nil) then prefix = &quot;[[&quot; .. Authorlink .. &quot;|&quot; .. prefix .. &quot;]]&quot; end
    return prefix 
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

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 Surname2 = args.last2 or args.surname2 or args.author2
    local Surname3 = args.last3 or args.surname3 or args.author3
    local Surname4 = args.last4 or args.surname4 or args.author4
    local Surname5 = args.last5 or args.surname5 or args.author5
    local Surname6 = args.last6 or args.surname6 or args.author6
    local Surname7 = args.last7 or args.surname7 or args.author7
    local Surname8 = args.last8 or args.surname8 or args.author8
    local Surname9 = args.last9 or args.surname9 or args.author9
    local Given1 = args.first1 or args.given1 or args.first or args.given
    local Given2 = args.first2 or args.given2
    local Given3 = args.first3 or args.given3
    local Given4 = args.first4 or args.given4
    local Given5 = args.first5 or args.given5
    local Given6 = args.first6 or args.given6
    local Given7 = args.first7 or args.given7
    local Given8 = args.first8 or args.given8
    local Given9 = args.first9 or args.given9
    local Authorlink1 = args.authorlink or args.author1link or args.authorlink1
    local Authorlink2 = args.author2link or args.authorlink2
    local Authorlink3 = args.author3link or args.authorlink3
    local Authorlink4 = args.author4link or args.authorlink4
    local Authorlink5 = args.author5link or args.authorlink5
    local Authorlink6 = args.author6link or args.authorlink6
    local Authorlink7 = args.author7link or args.authorlink7
    local Authorlink8 = args.author8link or args.authorlink8
    local Authorlink9 = args.author9link or args.authorlink9
    local Coauthors = args.coauthor or args.coauthors 
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Journal = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN = args.isbn or args.ISBN
    local DOI = args.doi or args.DOI
    local ID = args.id or args.ID or args.pmid or args.PMID
    local Authors = args.authors 
    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
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Journal ~= nil ) then
        Chapter = Title
        Title = Journal
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; ISBN &quot; .. ISBN else ISBN = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI) else DOI = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. URL else URL = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; &quot; .. Edition .. &quot; edition&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Authors == nil ) then
        Authors = authorprefix(Surname1, Given1, Authorlink1, &quot;&quot;)
        Authors = Authors .. authorprefix(Surname2, Given2, Authorlink2, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname3, Given3, Authorlink3, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname4, Given4, Authorlink4, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname5, Given5, Authorlink5, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname6, Given6, Authorlink6, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname7, Given7, Authorlink7, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname8, Given8, Authorlink8, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname9, Given9, Authorlink9, &quot;&amp;#59; &quot;)       
    end
    if ( &quot;&quot; ~= Authors and &quot;&quot; ~= Date ) then
        Date = Date .. &quot;.&quot;
    end
    if ( Editors ~= nil ) then
        Editors = &quot; in &quot; .. Editors .. &quot;.&quot;
    else
        Editors = &quot;&quot;    
    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 &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    return text
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function p.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function p.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

return p</text>
      <sha1>dq5wi1z873jx3ls2gecc5zj55kh1nkh</sha1>
    </revision>
    <revision>
      <id>4352</id>
      <parentid>4351</parentid>
      <timestamp>2012-08-25T22:27:39Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Fixed function call.</comment>
      <origin>4352</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="12331" sha1="0ebhah11qgwtgf2d5ryyuz674ygmt6q" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    if ( &quot;span&quot; == name or &quot;div&quot; == name or &quot;blockquote&quot; == name ) then
        for n,v in pairs(t.params) do
            params = params .. &quot; &quot; .. n .. &quot;=\&quot;&quot; .. v .. &quot;\&quot;&quot;
        end
        return &quot;&lt;&quot; .. name .. params .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    else
        for n,v in pairs(t.params) do
            params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
        end
        return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
    end
end

function hideinprint(frame, content)
    return content
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function authorprefix(Surname, Given, Authorlink, ampersand)
    if (Surname == nil) then return &quot;&quot; end
    local prefix = ampersand .. Surname
    if (Given ~= nil) then prefix = prefix .. &quot;, &quot; .. Given end
    if (Authorlink ~= nil) then prefix = &quot;[[&quot; .. Authorlink .. &quot;|&quot; .. prefix .. &quot;]]&quot; end
    return prefix 
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

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 Surname2 = args.last2 or args.surname2 or args.author2
    local Surname3 = args.last3 or args.surname3 or args.author3
    local Surname4 = args.last4 or args.surname4 or args.author4
    local Surname5 = args.last5 or args.surname5 or args.author5
    local Surname6 = args.last6 or args.surname6 or args.author6
    local Surname7 = args.last7 or args.surname7 or args.author7
    local Surname8 = args.last8 or args.surname8 or args.author8
    local Surname9 = args.last9 or args.surname9 or args.author9
    local Given1 = args.first1 or args.given1 or args.first or args.given
    local Given2 = args.first2 or args.given2
    local Given3 = args.first3 or args.given3
    local Given4 = args.first4 or args.given4
    local Given5 = args.first5 or args.given5
    local Given6 = args.first6 or args.given6
    local Given7 = args.first7 or args.given7
    local Given8 = args.first8 or args.given8
    local Given9 = args.first9 or args.given9
    local Authorlink1 = args.authorlink or args.author1link or args.authorlink1
    local Authorlink2 = args.author2link or args.authorlink2
    local Authorlink3 = args.author3link or args.authorlink3
    local Authorlink4 = args.author4link or args.authorlink4
    local Authorlink5 = args.author5link or args.authorlink5
    local Authorlink6 = args.author6link or args.authorlink6
    local Authorlink7 = args.author7link or args.authorlink7
    local Authorlink8 = args.author8link or args.authorlink8
    local Authorlink9 = args.author9link or args.authorlink9
    local Coauthors = args.coauthor or args.coauthors 
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Journal = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN = args.isbn or args.ISBN
    local DOI = args.doi or args.DOI
    local ID = args.id or args.ID or args.pmid or args.PMID
    local Authors = args.authors 
    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
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Journal ~= nil ) then
        Chapter = Title
        Title = Journal
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; ISBN &quot; .. ISBN else ISBN = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI) else DOI = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. URL else URL = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; &quot; .. Edition .. &quot; edition&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Authors == nil ) then
        Authors = authorprefix(Surname1, Given1, Authorlink1, &quot;&quot;)
        Authors = Authors .. authorprefix(Surname2, Given2, Authorlink2, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname3, Given3, Authorlink3, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname4, Given4, Authorlink4, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname5, Given5, Authorlink5, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname6, Given6, Authorlink6, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname7, Given7, Authorlink7, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname8, Given8, Authorlink8, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname9, Given9, Authorlink9, &quot;&amp;#59; &quot;)       
    end
    if ( &quot;&quot; ~= Authors and &quot;&quot; ~= Date ) then
        Date = Date .. &quot;.&quot;
    end
    if ( Editors ~= nil ) then
        Editors = &quot; in &quot; .. Editors .. &quot;.&quot;
    else
        Editors = &quot;&quot;    
    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 &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    return text
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function p.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function p.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

return p</text>
      <sha1>0ebhah11qgwtgf2d5ryyuz674ygmt6q</sha1>
    </revision>
    <revision>
      <id>4353</id>
      <parentid>4352</parentid>
      <timestamp>2012-08-26T02:00:03Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added support for [[Template:r]].</comment>
      <origin>4353</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="13435" sha1="kw6jsolavn8cz5eozmkap4hbobgbkl9" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    if ( &quot;span&quot; == name or &quot;div&quot; == name or &quot;blockquote&quot; == name ) then
        for n,v in pairs(t.params) do
            params = params .. &quot; &quot; .. n .. &quot;=\&quot;&quot; .. v .. &quot;\&quot;&quot;
        end
        return &quot;&lt;&quot; .. name .. params .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    else
        for n,v in pairs(t.params) do
            params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
        end
        return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
    end
end

function hideinprint(frame, content)
    return content
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function authorprefix(Surname, Given, Authorlink, ampersand)
    if (Surname == nil) then return &quot;&quot; end
    local prefix = ampersand .. Surname
    if (Given ~= nil) then prefix = prefix .. &quot;, &quot; .. Given end
    if (Authorlink ~= nil) then prefix = &quot;[[&quot; .. Authorlink .. &quot;|&quot; .. prefix .. &quot;]]&quot; end
    return prefix 
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

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 Surname2 = args.last2 or args.surname2 or args.author2
    local Surname3 = args.last3 or args.surname3 or args.author3
    local Surname4 = args.last4 or args.surname4 or args.author4
    local Surname5 = args.last5 or args.surname5 or args.author5
    local Surname6 = args.last6 or args.surname6 or args.author6
    local Surname7 = args.last7 or args.surname7 or args.author7
    local Surname8 = args.last8 or args.surname8 or args.author8
    local Surname9 = args.last9 or args.surname9 or args.author9
    local Given1 = args.first1 or args.given1 or args.first or args.given
    local Given2 = args.first2 or args.given2
    local Given3 = args.first3 or args.given3
    local Given4 = args.first4 or args.given4
    local Given5 = args.first5 or args.given5
    local Given6 = args.first6 or args.given6
    local Given7 = args.first7 or args.given7
    local Given8 = args.first8 or args.given8
    local Given9 = args.first9 or args.given9
    local Authorlink1 = args.authorlink or args.author1link or args.authorlink1
    local Authorlink2 = args.author2link or args.authorlink2
    local Authorlink3 = args.author3link or args.authorlink3
    local Authorlink4 = args.author4link or args.authorlink4
    local Authorlink5 = args.author5link or args.authorlink5
    local Authorlink6 = args.author6link or args.authorlink6
    local Authorlink7 = args.author7link or args.authorlink7
    local Authorlink8 = args.author8link or args.authorlink8
    local Authorlink9 = args.author9link or args.authorlink9
    local Coauthors = args.coauthor or args.coauthors 
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Journal = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN = args.isbn or args.ISBN
    local DOI = args.doi or args.DOI
    local ID = args.id or args.ID or args.pmid or args.PMID
    local Authors = args.authors 
    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
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Journal ~= nil ) then
        Chapter = Title
        Title = Journal
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; ISBN &quot; .. ISBN else ISBN = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI) else DOI = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. URL else URL = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; &quot; .. Edition .. &quot; edition&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Authors == nil ) then
        Authors = authorprefix(Surname1, Given1, Authorlink1, &quot;&quot;)
        Authors = Authors .. authorprefix(Surname2, Given2, Authorlink2, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname3, Given3, Authorlink3, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname4, Given4, Authorlink4, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname5, Given5, Authorlink5, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname6, Given6, Authorlink6, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname7, Given7, Authorlink7, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname8, Given8, Authorlink8, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname9, Given9, Authorlink9, &quot;&amp;#59; &quot;)       
    end
    if ( &quot;&quot; ~= Authors and &quot;&quot; ~= Date ) then
        Date = Date .. &quot;.&quot;
    end
    if ( Editors ~= nil ) then
        Editors = &quot; in &quot; .. Editors .. &quot;.&quot;
    else
        Editors = &quot;&quot;    
    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 &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    return text
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;&lt;nowiki&gt;:&lt;/nowiki&gt;&quot; .. page
        p = tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function p.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function p.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function p.r(frame)
    local pframe = frame:getParent()
    local config = frame.args
    local args = pframe.args
    local t1 = r0(frame, args.group, args.page or args.page1)
    local t2 = r0(frame, args.group, args.page2)
    local t3 = r0(frame, args.group, args.page3)
    local t4 = r0(frame, args.group, args.page4)
    local t5 = r0(frame, args.group, args.page5)
    local t6 = r0(frame, args.group, args.page6)
    local t7 = r0(frame, args.group, args.page7)
    local t8 = r0(frame, args.group, args.page8)
    local t9 = r0(frame, args.group, args.page9)
    return t1 .. t2 .. t3 .. t4 .. t5 .. t6 .. t7 .. t8 .. t9
end

return p</text>
      <sha1>kw6jsolavn8cz5eozmkap4hbobgbkl9</sha1>
    </revision>
    <revision>
      <id>4354</id>
      <parentid>4353</parentid>
      <timestamp>2012-08-26T02:03:33Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Fixed function calls.</comment>
      <origin>4354</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="13516" sha1="46own0fyr8cvn6svvdrff1fnktkqql8" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    if ( &quot;span&quot; == name or &quot;div&quot; == name or &quot;blockquote&quot; == name ) then
        for n,v in pairs(t.params) do
            params = params .. &quot; &quot; .. n .. &quot;=\&quot;&quot; .. v .. &quot;\&quot;&quot;
        end
        return &quot;&lt;&quot; .. name .. params .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    else
        for n,v in pairs(t.params) do
            params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
        end
        return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
    end
end

function hideinprint(frame, content)
    return content
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function authorprefix(Surname, Given, Authorlink, ampersand)
    if (Surname == nil) then return &quot;&quot; end
    local prefix = ampersand .. Surname
    if (Given ~= nil) then prefix = prefix .. &quot;, &quot; .. Given end
    if (Authorlink ~= nil) then prefix = &quot;[[&quot; .. Authorlink .. &quot;|&quot; .. prefix .. &quot;]]&quot; end
    return prefix 
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

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 Surname2 = args.last2 or args.surname2 or args.author2
    local Surname3 = args.last3 or args.surname3 or args.author3
    local Surname4 = args.last4 or args.surname4 or args.author4
    local Surname5 = args.last5 or args.surname5 or args.author5
    local Surname6 = args.last6 or args.surname6 or args.author6
    local Surname7 = args.last7 or args.surname7 or args.author7
    local Surname8 = args.last8 or args.surname8 or args.author8
    local Surname9 = args.last9 or args.surname9 or args.author9
    local Given1 = args.first1 or args.given1 or args.first or args.given
    local Given2 = args.first2 or args.given2
    local Given3 = args.first3 or args.given3
    local Given4 = args.first4 or args.given4
    local Given5 = args.first5 or args.given5
    local Given6 = args.first6 or args.given6
    local Given7 = args.first7 or args.given7
    local Given8 = args.first8 or args.given8
    local Given9 = args.first9 or args.given9
    local Authorlink1 = args.authorlink or args.author1link or args.authorlink1
    local Authorlink2 = args.author2link or args.authorlink2
    local Authorlink3 = args.author3link or args.authorlink3
    local Authorlink4 = args.author4link or args.authorlink4
    local Authorlink5 = args.author5link or args.authorlink5
    local Authorlink6 = args.author6link or args.authorlink6
    local Authorlink7 = args.author7link or args.authorlink7
    local Authorlink8 = args.author8link or args.authorlink8
    local Authorlink9 = args.author9link or args.authorlink9
    local Coauthors = args.coauthor or args.coauthors 
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Journal = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN = args.isbn or args.ISBN
    local DOI = args.doi or args.DOI
    local ID = args.id or args.ID or args.pmid or args.PMID
    local Authors = args.authors 
    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
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Journal ~= nil ) then
        Chapter = Title
        Title = Journal
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; ISBN &quot; .. ISBN else ISBN = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI) else DOI = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. URL else URL = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; &quot; .. Edition .. &quot; edition&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Authors == nil ) then
        Authors = authorprefix(Surname1, Given1, Authorlink1, &quot;&quot;)
        Authors = Authors .. authorprefix(Surname2, Given2, Authorlink2, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname3, Given3, Authorlink3, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname4, Given4, Authorlink4, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname5, Given5, Authorlink5, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname6, Given6, Authorlink6, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname7, Given7, Authorlink7, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname8, Given8, Authorlink8, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname9, Given9, Authorlink9, &quot;&amp;#59; &quot;)       
    end
    if ( &quot;&quot; ~= Authors and &quot;&quot; ~= Date ) then
        Date = Date .. &quot;.&quot;
    end
    if ( Editors ~= nil ) then
        Editors = &quot; in &quot; .. Editors .. &quot;.&quot;
    else
        Editors = &quot;&quot;    
    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 &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    return text
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;&lt;nowiki&gt;:&lt;/nowiki&gt;&quot; .. page
        p = tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function p.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function p.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function p.r(frame)
    local pframe = frame:getParent()
    local config = frame.args
    local args = pframe.args
    local t1 = r0(frame, args[1], args.group, args.page or args.page1)
    local t2 = r0(frame, args[2], args.group, args.page2)
    local t3 = r0(frame, args[3], args.group, args.page3)
    local t4 = r0(frame, args[4], args.group, args.page4)
    local t5 = r0(frame, args[5], args.group, args.page5)
    local t6 = r0(frame, args[6], args.group, args.page6)
    local t7 = r0(frame, args[7], args.group, args.page7)
    local t8 = r0(frame, args[8], args.group, args.page8)
    local t9 = r0(frame, args[9], args.group, args.page9)
    return t1 .. t2 .. t3 .. t4 .. t5 .. t6 .. t7 .. t8 .. t9
end

return p</text>
      <sha1>46own0fyr8cvn6svvdrff1fnktkqql8</sha1>
    </revision>
    <revision>
      <id>4355</id>
      <parentid>4354</parentid>
      <timestamp>2012-08-26T02:04:13Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added more alternative processing for non-extension tags.</comment>
      <origin>4355</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="13533" sha1="m2ei333l0jlg8t7cgrhiykq8k7dgkto" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    if ( &quot;span&quot; == name or &quot;div&quot; == name or &quot;blockquote&quot; == name or &quot;sup&quot; == name ) then
        for n,v in pairs(t.params) do
            params = params .. &quot; &quot; .. n .. &quot;=\&quot;&quot; .. v .. &quot;\&quot;&quot;
        end
        return &quot;&lt;&quot; .. name .. params .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    else
        for n,v in pairs(t.params) do
            params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
        end
        return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
    end
end

function hideinprint(frame, content)
    return content
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function authorprefix(Surname, Given, Authorlink, ampersand)
    if (Surname == nil) then return &quot;&quot; end
    local prefix = ampersand .. Surname
    if (Given ~= nil) then prefix = prefix .. &quot;, &quot; .. Given end
    if (Authorlink ~= nil) then prefix = &quot;[[&quot; .. Authorlink .. &quot;|&quot; .. prefix .. &quot;]]&quot; end
    return prefix 
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

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 Surname2 = args.last2 or args.surname2 or args.author2
    local Surname3 = args.last3 or args.surname3 or args.author3
    local Surname4 = args.last4 or args.surname4 or args.author4
    local Surname5 = args.last5 or args.surname5 or args.author5
    local Surname6 = args.last6 or args.surname6 or args.author6
    local Surname7 = args.last7 or args.surname7 or args.author7
    local Surname8 = args.last8 or args.surname8 or args.author8
    local Surname9 = args.last9 or args.surname9 or args.author9
    local Given1 = args.first1 or args.given1 or args.first or args.given
    local Given2 = args.first2 or args.given2
    local Given3 = args.first3 or args.given3
    local Given4 = args.first4 or args.given4
    local Given5 = args.first5 or args.given5
    local Given6 = args.first6 or args.given6
    local Given7 = args.first7 or args.given7
    local Given8 = args.first8 or args.given8
    local Given9 = args.first9 or args.given9
    local Authorlink1 = args.authorlink or args.author1link or args.authorlink1
    local Authorlink2 = args.author2link or args.authorlink2
    local Authorlink3 = args.author3link or args.authorlink3
    local Authorlink4 = args.author4link or args.authorlink4
    local Authorlink5 = args.author5link or args.authorlink5
    local Authorlink6 = args.author6link or args.authorlink6
    local Authorlink7 = args.author7link or args.authorlink7
    local Authorlink8 = args.author8link or args.authorlink8
    local Authorlink9 = args.author9link or args.authorlink9
    local Coauthors = args.coauthor or args.coauthors 
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Journal = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN = args.isbn or args.ISBN
    local DOI = args.doi or args.DOI
    local ID = args.id or args.ID or args.pmid or args.PMID
    local Authors = args.authors 
    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
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Journal ~= nil ) then
        Chapter = Title
        Title = Journal
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; ISBN &quot; .. ISBN else ISBN = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI) else DOI = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. URL else URL = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; &quot; .. Edition .. &quot; edition&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Authors == nil ) then
        Authors = authorprefix(Surname1, Given1, Authorlink1, &quot;&quot;)
        Authors = Authors .. authorprefix(Surname2, Given2, Authorlink2, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname3, Given3, Authorlink3, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname4, Given4, Authorlink4, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname5, Given5, Authorlink5, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname6, Given6, Authorlink6, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname7, Given7, Authorlink7, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname8, Given8, Authorlink8, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname9, Given9, Authorlink9, &quot;&amp;#59; &quot;)       
    end
    if ( &quot;&quot; ~= Authors and &quot;&quot; ~= Date ) then
        Date = Date .. &quot;.&quot;
    end
    if ( Editors ~= nil ) then
        Editors = &quot; in &quot; .. Editors .. &quot;.&quot;
    else
        Editors = &quot;&quot;    
    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 &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    return text
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;&lt;nowiki&gt;:&lt;/nowiki&gt;&quot; .. page
        p = tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function p.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function p.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function p.r(frame)
    local pframe = frame:getParent()
    local config = frame.args
    local args = pframe.args
    local t1 = r0(frame, args[1], args.group, args.page or args.page1)
    local t2 = r0(frame, args[2], args.group, args.page2)
    local t3 = r0(frame, args[3], args.group, args.page3)
    local t4 = r0(frame, args[4], args.group, args.page4)
    local t5 = r0(frame, args[5], args.group, args.page5)
    local t6 = r0(frame, args[6], args.group, args.page6)
    local t7 = r0(frame, args[7], args.group, args.page7)
    local t8 = r0(frame, args[8], args.group, args.page8)
    local t9 = r0(frame, args[9], args.group, args.page9)
    return t1 .. t2 .. t3 .. t4 .. t5 .. t6 .. t7 .. t8 .. t9
end

return p</text>
      <sha1>m2ei333l0jlg8t7cgrhiykq8k7dgkto</sha1>
    </revision>
    <revision>
      <id>4356</id>
      <parentid>4355</parentid>
      <timestamp>2012-08-26T02:05:19Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Removed generation of superfluous markup.</comment>
      <origin>4356</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="13516" sha1="1fvzd4l1i6rjofz0ipurlgjayzwnpgv" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    if ( &quot;span&quot; == name or &quot;div&quot; == name or &quot;blockquote&quot; == name or &quot;sup&quot; == name ) then
        for n,v in pairs(t.params) do
            params = params .. &quot; &quot; .. n .. &quot;=\&quot;&quot; .. v .. &quot;\&quot;&quot;
        end
        return &quot;&lt;&quot; .. name .. params .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    else
        for n,v in pairs(t.params) do
            params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
        end
        return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
    end
end

function hideinprint(frame, content)
    return content
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function authorprefix(Surname, Given, Authorlink, ampersand)
    if (Surname == nil) then return &quot;&quot; end
    local prefix = ampersand .. Surname
    if (Given ~= nil) then prefix = prefix .. &quot;, &quot; .. Given end
    if (Authorlink ~= nil) then prefix = &quot;[[&quot; .. Authorlink .. &quot;|&quot; .. prefix .. &quot;]]&quot; end
    return prefix 
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

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 Surname2 = args.last2 or args.surname2 or args.author2
    local Surname3 = args.last3 or args.surname3 or args.author3
    local Surname4 = args.last4 or args.surname4 or args.author4
    local Surname5 = args.last5 or args.surname5 or args.author5
    local Surname6 = args.last6 or args.surname6 or args.author6
    local Surname7 = args.last7 or args.surname7 or args.author7
    local Surname8 = args.last8 or args.surname8 or args.author8
    local Surname9 = args.last9 or args.surname9 or args.author9
    local Given1 = args.first1 or args.given1 or args.first or args.given
    local Given2 = args.first2 or args.given2
    local Given3 = args.first3 or args.given3
    local Given4 = args.first4 or args.given4
    local Given5 = args.first5 or args.given5
    local Given6 = args.first6 or args.given6
    local Given7 = args.first7 or args.given7
    local Given8 = args.first8 or args.given8
    local Given9 = args.first9 or args.given9
    local Authorlink1 = args.authorlink or args.author1link or args.authorlink1
    local Authorlink2 = args.author2link or args.authorlink2
    local Authorlink3 = args.author3link or args.authorlink3
    local Authorlink4 = args.author4link or args.authorlink4
    local Authorlink5 = args.author5link or args.authorlink5
    local Authorlink6 = args.author6link or args.authorlink6
    local Authorlink7 = args.author7link or args.authorlink7
    local Authorlink8 = args.author8link or args.authorlink8
    local Authorlink9 = args.author9link or args.authorlink9
    local Coauthors = args.coauthor or args.coauthors 
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Journal = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN = args.isbn or args.ISBN
    local DOI = args.doi or args.DOI
    local ID = args.id or args.ID or args.pmid or args.PMID
    local Authors = args.authors 
    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
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Journal ~= nil ) then
        Chapter = Title
        Title = Journal
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; ISBN &quot; .. ISBN else ISBN = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI) else DOI = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. URL else URL = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; &quot; .. Edition .. &quot; edition&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Authors == nil ) then
        Authors = authorprefix(Surname1, Given1, Authorlink1, &quot;&quot;)
        Authors = Authors .. authorprefix(Surname2, Given2, Authorlink2, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname3, Given3, Authorlink3, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname4, Given4, Authorlink4, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname5, Given5, Authorlink5, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname6, Given6, Authorlink6, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname7, Given7, Authorlink7, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname8, Given8, Authorlink8, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname9, Given9, Authorlink9, &quot;&amp;#59; &quot;)       
    end
    if ( &quot;&quot; ~= Authors and &quot;&quot; ~= Date ) then
        Date = Date .. &quot;.&quot;
    end
    if ( Editors ~= nil ) then
        Editors = &quot; in &quot; .. Editors .. &quot;.&quot;
    else
        Editors = &quot;&quot;    
    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 &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    return text
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function p.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function p.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function p.r(frame)
    local pframe = frame:getParent()
    local config = frame.args
    local args = pframe.args
    local t1 = r0(frame, args[1], args.group, args.page or args.page1)
    local t2 = r0(frame, args[2], args.group, args.page2)
    local t3 = r0(frame, args[3], args.group, args.page3)
    local t4 = r0(frame, args[4], args.group, args.page4)
    local t5 = r0(frame, args[5], args.group, args.page5)
    local t6 = r0(frame, args[6], args.group, args.page6)
    local t7 = r0(frame, args[7], args.group, args.page7)
    local t8 = r0(frame, args[8], args.group, args.page8)
    local t9 = r0(frame, args[9], args.group, args.page9)
    return t1 .. t2 .. t3 .. t4 .. t5 .. t6 .. t7 .. t8 .. t9
end

return p</text>
      <sha1>1fvzd4l1i6rjofz0ipurlgjayzwnpgv</sha1>
    </revision>
    <revision>
      <id>4357</id>
      <parentid>4356</parentid>
      <timestamp>2012-08-26T02:49:25Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added alternative parameter spelling.</comment>
      <origin>4357</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="13538" sha1="94ynkc4qc30jmu4r57raftl4infp8bv" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    if ( &quot;span&quot; == name or &quot;div&quot; == name or &quot;blockquote&quot; == name or &quot;sup&quot; == name ) then
        for n,v in pairs(t.params) do
            params = params .. &quot; &quot; .. n .. &quot;=\&quot;&quot; .. v .. &quot;\&quot;&quot;
        end
        return &quot;&lt;&quot; .. name .. params .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    else
        for n,v in pairs(t.params) do
            params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
        end
        return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
    end
end

function hideinprint(frame, content)
    return content
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function authorprefix(Surname, Given, Authorlink, ampersand)
    if (Surname == nil) then return &quot;&quot; end
    local prefix = ampersand .. Surname
    if (Given ~= nil) then prefix = prefix .. &quot;, &quot; .. Given end
    if (Authorlink ~= nil) then prefix = &quot;[[&quot; .. Authorlink .. &quot;|&quot; .. prefix .. &quot;]]&quot; end
    return prefix 
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

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 Surname2 = args.last2 or args.surname2 or args.author2
    local Surname3 = args.last3 or args.surname3 or args.author3
    local Surname4 = args.last4 or args.surname4 or args.author4
    local Surname5 = args.last5 or args.surname5 or args.author5
    local Surname6 = args.last6 or args.surname6 or args.author6
    local Surname7 = args.last7 or args.surname7 or args.author7
    local Surname8 = args.last8 or args.surname8 or args.author8
    local Surname9 = args.last9 or args.surname9 or args.author9
    local Given1 = args.first1 or args.given1 or args.first or args.given
    local Given2 = args.first2 or args.given2
    local Given3 = args.first3 or args.given3
    local Given4 = args.first4 or args.given4
    local Given5 = args.first5 or args.given5
    local Given6 = args.first6 or args.given6
    local Given7 = args.first7 or args.given7
    local Given8 = args.first8 or args.given8
    local Given9 = args.first9 or args.given9
    local Authorlink1 = args.authorlink or args.author1link or args.authorlink1
    local Authorlink2 = args.author2link or args.authorlink2
    local Authorlink3 = args.author3link or args.authorlink3
    local Authorlink4 = args.author4link or args.authorlink4
    local Authorlink5 = args.author5link or args.authorlink5
    local Authorlink6 = args.author6link or args.authorlink6
    local Authorlink7 = args.author7link or args.authorlink7
    local Authorlink8 = args.author8link or args.authorlink8
    local Authorlink9 = args.author9link or args.authorlink9
    local Coauthors = args.coauthor or args.coauthors 
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Journal = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN = args.isbn or args.ISBN
    local DOI = args.doi or args.DOI
    local ID = args.id or args.ID or args.pmid or args.PMID
    local Authors = args.authors 
    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
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Journal ~= nil ) then
        Chapter = Title
        Title = Journal
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; ISBN &quot; .. ISBN else ISBN = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI) else DOI = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. URL else URL = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; &quot; .. Edition .. &quot; edition&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Authors == nil ) then
        Authors = authorprefix(Surname1, Given1, Authorlink1, &quot;&quot;)
        Authors = Authors .. authorprefix(Surname2, Given2, Authorlink2, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname3, Given3, Authorlink3, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname4, Given4, Authorlink4, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname5, Given5, Authorlink5, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname6, Given6, Authorlink6, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname7, Given7, Authorlink7, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname8, Given8, Authorlink8, &quot;&amp;#59; &quot;)
        Authors = Authors .. authorprefix(Surname9, Given9, Authorlink9, &quot;&amp;#59; &quot;)       
    end
    if ( &quot;&quot; ~= Authors and &quot;&quot; ~= Date ) then
        Date = Date .. &quot;.&quot;
    end
    if ( Editors ~= nil ) then
        Editors = &quot; in &quot; .. Editors .. &quot;.&quot;
    else
        Editors = &quot;&quot;    
    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 &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    return text
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function p.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function p.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function p.r(frame)
    local pframe = frame:getParent()
    local config = frame.args
    local args = pframe.args
    local t1 = r0(frame, args[1], args.group, args.page or args.page1)
    local t2 = r0(frame, args[2], args.group, args.page2)
    local t3 = r0(frame, args[3], args.group, args.page3)
    local t4 = r0(frame, args[4], args.group, args.page4)
    local t5 = r0(frame, args[5], args.group, args.page5)
    local t6 = r0(frame, args[6], args.group, args.page6)
    local t7 = r0(frame, args[7], args.group, args.page7)
    local t8 = r0(frame, args[8], args.group, args.page8)
    local t9 = r0(frame, args[9], args.group, args.page9)
    return t1 .. t2 .. t3 .. t4 .. t5 .. t6 .. t7 .. t8 .. t9
end

return p</text>
      <sha1>94ynkc4qc30jmu4r57raftl4infp8bv</sha1>
    </revision>
    <revision>
      <id>4358</id>
      <parentid>4357</parentid>
      <timestamp>2012-08-26T04:46:55Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added processing of more parameters.</comment>
      <origin>4358</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="13177" sha1="6onnsqfjcvs6w6x1bl7w9tgy9lrwzs1" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    if ( &quot;span&quot; == name or &quot;div&quot; == name or &quot;blockquote&quot; == name or &quot;sup&quot; == name ) then
        for n,v in pairs(t.params) do
            params = params .. &quot; &quot; .. n .. &quot;=\&quot;&quot; .. v .. &quot;\&quot;&quot;
        end
        return &quot;&lt;&quot; .. name .. params .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    else
        for n,v in pairs(t.params) do
            params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
        end
        return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
    end
end

function hideinprint(frame, content)
    return content
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

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 Authors = args.authors 
    local a = {}
    a[1].last = args.last or args.surname or args.author or args.last1 or args.surname1 or args.author1
    a[1].first = args.first1 or args.given1 or args.first or args.given
    a[1].link = args.authorlink or args.author1link or args.authorlink1
    for i=2,9,1 do
        a[i].last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
        a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
    end    
    local Coauthors = args.coauthor or args.coauthors 
    local Editors = args.editors 
    local e = {}
    e[1].last = args.editor-last or args.editorsurname or args.editor or args.editor1-last or args.editor-last1 or args.editorsurname1 or args.editor1
    e[1].first = args.first1 or args.given1 or args.first or args.given
    e[1].link = args.authorlink or args.author1link or args.authorlink1
    for i=2,9,1 do
        e[i].last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
        e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
    end    
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Journal = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN = args.isbn or args.ISBN
    local DOI = args.doi or args.DOI
    local ID = args.id or args.ID or args.pmid or args.PMID
    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
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Journal ~= nil ) then
        Chapter = Title
        Title = Journal
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; ISBN &quot; .. ISBN else ISBN = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI) else DOI = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. URL else URL = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; &quot; .. Edition .. &quot; edition&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) 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
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Date .. Chapter .. Editors .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. ISBN .. DOI .. ID .. URL
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. ISBN .. DOI .. ID .. URL
    else
        text = Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. Date .. ISBN .. DOI .. ID .. URL
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    return text
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function p.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function p.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function p.r(frame)
    local pframe = frame:getParent()
    local config = frame.args
    local args = pframe.args
    local t1 = r0(frame, args[1], args.group, args.page or args.page1)
    local t2 = r0(frame, args[2], args.group, args.page2)
    local t3 = r0(frame, args[3], args.group, args.page3)
    local t4 = r0(frame, args[4], args.group, args.page4)
    local t5 = r0(frame, args[5], args.group, args.page5)
    local t6 = r0(frame, args[6], args.group, args.page6)
    local t7 = r0(frame, args[7], args.group, args.page7)
    local t8 = r0(frame, args[8], args.group, args.page8)
    local t9 = r0(frame, args[9], args.group, args.page9)
    return t1 .. t2 .. t3 .. t4 .. t5 .. t6 .. t7 .. t8 .. t9
end

return p</text>
      <sha1>6onnsqfjcvs6w6x1bl7w9tgy9lrwzs1</sha1>
    </revision>
    <revision>
      <id>4359</id>
      <parentid>4358</parentid>
      <timestamp>2012-08-26T04:49:25Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Fixed problem with uninitialized tables.</comment>
      <origin>4359</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="13241" sha1="nq71uo9yz7w7su1iealzkacmzp3rou9" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    if ( &quot;span&quot; == name or &quot;div&quot; == name or &quot;blockquote&quot; == name or &quot;sup&quot; == name ) then
        for n,v in pairs(t.params) do
            params = params .. &quot; &quot; .. n .. &quot;=\&quot;&quot; .. v .. &quot;\&quot;&quot;
        end
        return &quot;&lt;&quot; .. name .. params .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    else
        for n,v in pairs(t.params) do
            params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
        end
        return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
    end
end

function hideinprint(frame, content)
    return content
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

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 Authors = args.authors 
    local a = {}
    a[1] = {}
    a[1].last = args.last or args.surname or args.author or args.last1 or args.surname1 or args.author1
    a[1].first = args.first1 or args.given1 or args.first or args.given
    a[1].link = args.authorlink or args.author1link or args.authorlink1
    for i=2,9,1 do
        a[i] = {}
        a[i].last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
        a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
    end    
    local Coauthors = args.coauthor or args.coauthors 
    local Editors = args.editors 
    local e = {}
    e[1] = {}
    e[1].last = args.editor-last or args.editorsurname or args.editor or args.editor1-last or args.editor-last1 or args.editorsurname1 or args.editor1
    e[1].first = args.first1 or args.given1 or args.first or args.given
    e[1].link = args.authorlink or args.author1link or args.authorlink1
    for i=2,9,1 do
        e[i] = {}
        e[i].last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
        e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
    end    
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Journal = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN = args.isbn or args.ISBN
    local DOI = args.doi or args.DOI
    local ID = args.id or args.ID or args.pmid or args.PMID
    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
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Journal ~= nil ) then
        Chapter = Title
        Title = Journal
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; ISBN &quot; .. ISBN else ISBN = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI) else DOI = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. URL else URL = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; &quot; .. Edition .. &quot; edition&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) 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
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Date .. Chapter .. Editors .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. ISBN .. DOI .. ID .. URL
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. ISBN .. DOI .. ID .. URL
    else
        text = Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. Date .. ISBN .. DOI .. ID .. URL
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    return text
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function p.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function p.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function p.r(frame)
    local pframe = frame:getParent()
    local config = frame.args
    local args = pframe.args
    local t1 = r0(frame, args[1], args.group, args.page or args.page1)
    local t2 = r0(frame, args[2], args.group, args.page2)
    local t3 = r0(frame, args[3], args.group, args.page3)
    local t4 = r0(frame, args[4], args.group, args.page4)
    local t5 = r0(frame, args[5], args.group, args.page5)
    local t6 = r0(frame, args[6], args.group, args.page6)
    local t7 = r0(frame, args[7], args.group, args.page7)
    local t8 = r0(frame, args[8], args.group, args.page8)
    local t9 = r0(frame, args[9], args.group, args.page9)
    return t1 .. t2 .. t3 .. t4 .. t5 .. t6 .. t7 .. t8 .. t9
end

return p</text>
      <sha1>nq71uo9yz7w7su1iealzkacmzp3rou9</sha1>
    </revision>
    <revision>
      <id>4360</id>
      <parentid>4359</parentid>
      <timestamp>2012-08-26T04:51:22Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Fixed syntax problem.</comment>
      <origin>4360</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="13250" sha1="si1rqy7dstjmxtyxbm8268rnufnwral" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    if ( &quot;span&quot; == name or &quot;div&quot; == name or &quot;blockquote&quot; == name or &quot;sup&quot; == name ) then
        for n,v in pairs(t.params) do
            params = params .. &quot; &quot; .. n .. &quot;=\&quot;&quot; .. v .. &quot;\&quot;&quot;
        end
        return &quot;&lt;&quot; .. name .. params .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    else
        for n,v in pairs(t.params) do
            params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
        end
        return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
    end
end

function hideinprint(frame, content)
    return content
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

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 Authors = args.authors 
    local a = {}
    a[1] = {}
    a[1].last = args.last or args.surname or args.author or args.last1 or args.surname1 or args.author1
    a[1].first = args.first1 or args.given1 or args.first or args.given
    a[1].link = args.authorlink or args.author1link or args.authorlink1
    for i=2,9,1 do
        a[i] = {}
        a[i].last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
        a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
    end    
    local Coauthors = args.coauthor or args.coauthors 
    local Editors = args.editors 
    local e = {}
    e[1] = {}
    e[1].last = args[&quot;editor-last&quot;] or args.editorsurname or args.editor or args[&quot;editor1-last&quot;] or args[&quot;editor-last1&quot;] or args.editorsurname1 or args.editor1
    e[1].first = args.first1 or args.given1 or args.first or args.given
    e[1].link = args.authorlink or args.author1link or args.authorlink1
    for i=2,9,1 do
        e[i] = {}
        e[i].last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
        e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
    end    
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Journal = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN = args.isbn or args.ISBN
    local DOI = args.doi or args.DOI
    local ID = args.id or args.ID or args.pmid or args.PMID
    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
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Journal ~= nil ) then
        Chapter = Title
        Title = Journal
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; ISBN &quot; .. ISBN else ISBN = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI) else DOI = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. URL else URL = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; &quot; .. Edition .. &quot; edition&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) 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
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Date .. Chapter .. Editors .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. ISBN .. DOI .. ID .. URL
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. ISBN .. DOI .. ID .. URL
    else
        text = Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. Date .. ISBN .. DOI .. ID .. URL
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    return text
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function p.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function p.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function p.r(frame)
    local pframe = frame:getParent()
    local config = frame.args
    local args = pframe.args
    local t1 = r0(frame, args[1], args.group, args.page or args.page1)
    local t2 = r0(frame, args[2], args.group, args.page2)
    local t3 = r0(frame, args[3], args.group, args.page3)
    local t4 = r0(frame, args[4], args.group, args.page4)
    local t5 = r0(frame, args[5], args.group, args.page5)
    local t6 = r0(frame, args[6], args.group, args.page6)
    local t7 = r0(frame, args[7], args.group, args.page7)
    local t8 = r0(frame, args[8], args.group, args.page8)
    local t9 = r0(frame, args[9], args.group, args.page9)
    return t1 .. t2 .. t3 .. t4 .. t5 .. t6 .. t7 .. t8 .. t9
end

return p</text>
      <sha1>si1rqy7dstjmxtyxbm8268rnufnwral</sha1>
    </revision>
    <revision>
      <id>4361</id>
      <parentid>4360</parentid>
      <timestamp>2012-08-26T05:05:32Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Fixed a nil/blank problem.</comment>
      <origin>4361</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="13703" sha1="6e6t3w2wqazf2omwidjehf5j7rdkeba" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    if ( &quot;span&quot; == name or &quot;div&quot; == name or &quot;blockquote&quot; == name or &quot;sup&quot; == name ) then
        for n,v in pairs(t.params) do
            params = params .. &quot; &quot; .. n .. &quot;=\&quot;&quot; .. v .. &quot;\&quot;&quot;
        end
        return &quot;&lt;&quot; .. name .. params .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    else
        for n,v in pairs(t.params) do
            params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
        end
        return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
    end
end

function hideinprint(frame, content)
    return content
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

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 Authors = args.authors 
    local a = {}
    for i=1,9,1 do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthor or args.coauthors 
    local Editors = args.editors 
    local e = {}    
    for i=1,9,1 do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Journal = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN = args.isbn or args.ISBN
    local DOI = args.doi or args.DOI
    local ID = args.id or args.ID or args.pmid or args.PMID
    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
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Journal ~= nil ) then
        Chapter = Title
        Title = Journal
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; ISBN &quot; .. ISBN else ISBN = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI) else DOI = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. URL else URL = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; &quot; .. Edition .. &quot; edition&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) 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
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Date .. Chapter .. Editors .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. ISBN .. DOI .. ID .. URL
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. ISBN .. DOI .. ID .. URL
    else
        text = Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. Date .. ISBN .. DOI .. ID .. URL
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    return text
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function p.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function p.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function p.r(frame)
    local pframe = frame:getParent()
    local config = frame.args
    local args = pframe.args
    local t1 = r0(frame, args[1], args.group, args.page or args.page1)
    local t2 = r0(frame, args[2], args.group, args.page2)
    local t3 = r0(frame, args[3], args.group, args.page3)
    local t4 = r0(frame, args[4], args.group, args.page4)
    local t5 = r0(frame, args[5], args.group, args.page5)
    local t6 = r0(frame, args[6], args.group, args.page6)
    local t7 = r0(frame, args[7], args.group, args.page7)
    local t8 = r0(frame, args[8], args.group, args.page8)
    local t9 = r0(frame, args[9], args.group, args.page9)
    return t1 .. t2 .. t3 .. t4 .. t5 .. t6 .. t7 .. t8 .. t9
end

return p</text>
      <sha1>6e6t3w2wqazf2omwidjehf5j7rdkeba</sha1>
    </revision>
    <revision>
      <id>4362</id>
      <parentid>4361</parentid>
      <timestamp>2012-08-26T18:26:18Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added reflabel function.</comment>
      <origin>4362</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="14323" sha1="joexzwlhyrr5e04ys5r13fj70z7uuzd" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    if ( &quot;span&quot; == name or &quot;div&quot; == name or &quot;blockquote&quot; == name or &quot;sup&quot; == name ) then
        for n,v in pairs(t.params) do
            params = params .. &quot; &quot; .. n .. &quot;=\&quot;&quot; .. v .. &quot;\&quot;&quot;
        end
        return &quot;&lt;&quot; .. name .. params .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    else
        for n,v in pairs(t.params) do
            params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
        end
        return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
    end
end

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

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 Authors = args.authors 
    local a = {}
    for i=1,9,1 do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthor or args.coauthors 
    local Editors = args.editors 
    local e = {}    
    for i=1,9,1 do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Journal = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN = args.isbn or args.ISBN
    local DOI = args.doi or args.DOI
    local ID = args.id or args.ID or args.pmid or args.PMID
    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
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Journal ~= nil ) then
        Chapter = Title
        Title = Journal
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; ISBN &quot; .. ISBN else ISBN = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI) else DOI = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. URL else URL = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; &quot; .. Edition .. &quot; edition&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) 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
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Date .. Chapter .. Editors .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. ISBN .. DOI .. ID .. URL
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. ISBN .. DOI .. ID .. URL
    else
        text = Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. Date .. ISBN .. DOI .. ID .. URL
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    return text
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function p.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function p.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function p.r(frame)
    local pframe = frame:getParent()
    local config = frame.args
    local args = pframe.args
    local t1 = r0(frame, args[1], args.group, args.page or args.page1)
    local t2 = r0(frame, args[2], args.group, args.page2)
    local t3 = r0(frame, args[3], args.group, args.page3)
    local t4 = r0(frame, args[4], args.group, args.page4)
    local t5 = r0(frame, args[5], args.group, args.page5)
    local t6 = r0(frame, args[6], args.group, args.page6)
    local t7 = r0(frame, args[7], args.group, args.page7)
    local t8 = r0(frame, args[8], args.group, args.page8)
    local t9 = r0(frame, args[9], args.group, args.page9)
    return t1 .. t2 .. t3 .. t4 .. t5 .. t6 .. t7 .. t8 .. t9
end

-- This is used by template {{reflabel}}.
function p.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args
    local args = pframe.args    
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid ~= nil and args.noid ~= &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return tag(frame, {name=&quot;sup&quot;,contents=content,params=params})
end

return p</text>
      <sha1>joexzwlhyrr5e04ys5r13fj70z7uuzd</sha1>
    </revision>
    <revision>
      <id>4363</id>
      <parentid>4362</parentid>
      <timestamp>2012-08-26T18:32:16Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Inverted the sense of a test.</comment>
      <origin>4363</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="14563" sha1="ln7pfucgetsulvj3219hj37wqqldjm7" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    if ( &quot;nowiki&quot; == name or &quot;ref&quot; == name or &quot;pre&quot; == name or &quot;gallery&quot; == name or &quot;poem&quot; == name ) then
        -- We have to preprocess these, so that they are properly turned into so-called &quot;strip markers&quot; in the generated wikitext.
        for n,v in pairs(t.params) do
            params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
        end
        return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
    else
        -- Everything else we can just generate directly, without calling the preprocessor.
        for n,v in pairs(t.params) do
            params = params .. &quot; &quot; .. n .. &quot;=\&quot;&quot; .. v .. &quot;\&quot;&quot;
        end
        return &quot;&lt;&quot; .. name .. params .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    end
end

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

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 Authors = args.authors 
    local a = {}
    for i=1,9,1 do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthor or args.coauthors 
    local Editors = args.editors 
    local e = {}    
    for i=1,9,1 do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Journal = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN = args.isbn or args.ISBN
    local DOI = args.doi or args.DOI
    local ID = args.id or args.ID or args.pmid or args.PMID
    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
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Journal ~= nil ) then
        Chapter = Title
        Title = Journal
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; ISBN &quot; .. ISBN else ISBN = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI) else DOI = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. URL else URL = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; &quot; .. Edition .. &quot; edition&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) 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
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Date .. Chapter .. Editors .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. ISBN .. DOI .. ID .. URL
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. ISBN .. DOI .. ID .. URL
    else
        text = Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. Date .. ISBN .. DOI .. ID .. URL
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    return text
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function p.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function p.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function p.r(frame)
    local pframe = frame:getParent()
    local config = frame.args
    local args = pframe.args
    local t1 = r0(frame, args[1], args.group, args.page or args.page1)
    local t2 = r0(frame, args[2], args.group, args.page2)
    local t3 = r0(frame, args[3], args.group, args.page3)
    local t4 = r0(frame, args[4], args.group, args.page4)
    local t5 = r0(frame, args[5], args.group, args.page5)
    local t6 = r0(frame, args[6], args.group, args.page6)
    local t7 = r0(frame, args[7], args.group, args.page7)
    local t8 = r0(frame, args[8], args.group, args.page8)
    local t9 = r0(frame, args[9], args.group, args.page9)
    return t1 .. t2 .. t3 .. t4 .. t5 .. t6 .. t7 .. t8 .. t9
end

-- This is used by template {{reflabel}}.
function p.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args
    local args = pframe.args    
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid ~= nil and args.noid ~= &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return tag(frame, {name=&quot;sup&quot;,contents=content,params=params})
end

return p</text>
      <sha1>ln7pfucgetsulvj3219hj37wqqldjm7</sha1>
    </revision>
    <revision>
      <id>4364</id>
      <parentid>4363</parentid>
      <timestamp>2012-08-26T18:33:28Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Fixed my typing error.</comment>
      <origin>4364</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="14564" sha1="ktgz44umgaxgod9eumcafk4if068b58" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    if ( &quot;nowiki&quot; == name or &quot;ref&quot; == name or &quot;pre&quot; == name or &quot;gallery&quot; == name or &quot;poem&quot; == name ) then
        -- We have to preprocess these, so that they are properly turned into so-called &quot;strip markers&quot; in the generated wikitext.
        for n,v in pairs(t.params) do
            params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
        end
        return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
    else
        -- Everything else we can just generate directly, without calling the preprocessor.
        for n,v in pairs(t.params) do
            params = params .. &quot; &quot; .. n .. &quot;=\&quot;&quot; .. v .. &quot;\&quot;&quot;
        end
        return &quot;&lt;&quot; .. name .. params .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    end
end

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

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 Authors = args.authors 
    local a = {}
    for i=1,9,1 do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthor or args.coauthors 
    local Editors = args.editors 
    local e = {}    
    for i=1,9,1 do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Journal = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN = args.isbn or args.ISBN
    local DOI = args.doi or args.DOI
    local ID = args.id or args.ID or args.pmid or args.PMID
    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
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Journal ~= nil ) then
        Chapter = Title
        Title = Journal
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; ISBN &quot; .. ISBN else ISBN = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI) else DOI = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. URL else URL = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; &quot; .. Edition .. &quot; edition&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) 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
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Date .. Chapter .. Editors .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. ISBN .. DOI .. ID .. URL
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. ISBN .. DOI .. ID .. URL
    else
        text = Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. Date .. ISBN .. DOI .. ID .. URL
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    return text
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function p.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function p.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function p.r(frame)
    local pframe = frame:getParent()
    local config = frame.args
    local args = pframe.args
    local t1 = r0(frame, args[1], args.group, args.page or args.page1)
    local t2 = r0(frame, args[2], args.group, args.page2)
    local t3 = r0(frame, args[3], args.group, args.page3)
    local t4 = r0(frame, args[4], args.group, args.page4)
    local t5 = r0(frame, args[5], args.group, args.page5)
    local t6 = r0(frame, args[6], args.group, args.page6)
    local t7 = r0(frame, args[7], args.group, args.page7)
    local t8 = r0(frame, args[8], args.group, args.page8)
    local t9 = r0(frame, args[9], args.group, args.page9)
    return t1 .. t2 .. t3 .. t4 .. t5 .. t6 .. t7 .. t8 .. t9
end

-- This is used by template {{reflabel}}.
function p.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args
    local args = pframe.args    
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid ~= nil and args.noid ~= &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

return p</text>
      <sha1>ktgz44umgaxgod9eumcafk4if068b58</sha1>
    </revision>
    <revision>
      <id>4365</id>
      <parentid>4364</parentid>
      <timestamp>2012-08-26T19:19:19Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Rolled up loop.</comment>
      <origin>4365</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="14674" sha1="f13z12n87l6w75sj45sce5zz6sdo4i2" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    if ( &quot;nowiki&quot; == name or &quot;ref&quot; == name or &quot;pre&quot; == name or &quot;gallery&quot; == name or &quot;poem&quot; == name ) then
        -- We have to preprocess these, so that they are properly turned into so-called &quot;strip markers&quot; in the generated wikitext.
        for n,v in pairs(t.params) do
            params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
        end
        return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
    else
        -- Everything else we can just generate directly, without calling the preprocessor.
        for n,v in pairs(t.params) do
            params = params .. &quot; &quot; .. n .. &quot;=\&quot;&quot; .. v .. &quot;\&quot;&quot;
        end
        return &quot;&lt;&quot; .. name .. params .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    end
end

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors 
    local a = {}
    for i=1,9,1 do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthor or args.coauthors 
    local Editors = args.editors 
    local e = {}    
    for i=1,9,1 do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Journal = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN = args.isbn or args.ISBN
    local DOI = args.doi or args.DOI
    local ID = args.id or args.ID or args.pmid or args.PMID
    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
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Journal ~= nil ) then
        Chapter = Title
        Title = Journal
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; ISBN &quot; .. ISBN else ISBN = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI) else DOI = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. URL else URL = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; &quot; .. Edition .. &quot; edition&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) 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
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Date .. Chapter .. Editors .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. ISBN .. DOI .. ID .. URL
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. ISBN .. DOI .. ID .. URL
    else
        text = Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. Date .. ISBN .. DOI .. ID .. URL
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    return text
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function p.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function p.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function p.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    for index,arg in ipairs(args) do
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
    end
    return text
end

-- This is used by template {{reflabel}}.
function p.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid ~= nil and args.noid ~= &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

return p</text>
      <sha1>f13z12n87l6w75sj45sce5zz6sdo4i2</sha1>
    </revision>
    <revision>
      <id>4366</id>
      <parentid>4365</parentid>
      <timestamp>2012-08-26T22:05:39Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Removed use of ipairs() directly on a template argument list.</comment>
      <origin>4366</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="14747" sha1="10q2djkwrn81s020llrotezzeqbeiht" xml:space="preserve">--require &quot;mw.text&quot;

local p = {}

-- This can be removed when mw.text.tag appears.
function tag(frame, t)
    local name = t.name or &quot;!--&quot;
    local content = t.contents or &quot;&quot;
    local params = &quot;&quot;
    if ( &quot;nowiki&quot; == name or &quot;ref&quot; == name or &quot;pre&quot; == name or &quot;gallery&quot; == name or &quot;poem&quot; == name ) then
        -- We have to preprocess these, so that they are properly turned into so-called &quot;strip markers&quot; in the generated wikitext.
        for n,v in pairs(t.params) do
            params = params .. &quot;|&quot; .. n .. &quot;=&quot; .. v
        end
        return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. params .. &quot;}}&quot;)
    else
        -- Everything else we can just generate directly, without calling the preprocessor.
        for n,v in pairs(t.params) do
            params = params .. &quot; &quot; .. n .. &quot;=\&quot;&quot; .. v .. &quot;\&quot;&quot;
        end
        return &quot;&lt;&quot; .. name .. params .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    end
end

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors 
    local a = {}
    for i=1,9,1 do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthor or args.coauthors 
    local Editors = args.editors 
    local e = {}    
    for i=1,9,1 do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Journal = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN = args.isbn or args.ISBN
    local DOI = args.doi or args.DOI
    local ID = args.id or args.ID or args.pmid or args.PMID
    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
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Journal ~= nil ) then
        Chapter = Title
        Title = Journal
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; ISBN &quot; .. ISBN else ISBN = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI) else DOI = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. URL else URL = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; &quot; .. Edition .. &quot; edition&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) 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
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Date .. Chapter .. Editors .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. ISBN .. DOI .. ID .. URL
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. ISBN .. DOI .. ID .. URL
    else
        text = Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. Date .. ISBN .. DOI .. ID .. URL
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    return text
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function p.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function p.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function p.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    local index = 1
    while args[index] ~= nil do
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{reflabel}}.
function p.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid ~= nil and args.noid ~= &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

return p</text>
      <sha1>10q2djkwrn81s020llrotezzeqbeiht</sha1>
    </revision>
    <revision>
      <id>4367</id>
      <parentid>4366</parentid>
      <timestamp>2012-08-26T22:15:13Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Removed use of ipairs() directly on a template argument list.  Eliminated function now in [[Module:Wikitext]].</comment>
      <origin>4367</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="14074" sha1="hcxyufbagqshw9ymr1beyi89i86q6xu" xml:space="preserve">--require &quot;mw.text&quot;

local p = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. p.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors 
    local a = {}
    for i=1,9,1 do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthor or args.coauthors 
    local Editors = args.editors 
    local e = {}    
    for i=1,9,1 do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Journal = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN = args.isbn or args.ISBN
    local DOI = args.doi or args.DOI
    local ID = args.id or args.ID or args.pmid or args.PMID
    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
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Journal ~= nil ) then
        Chapter = Title
        Title = Journal
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; ISBN &quot; .. ISBN else ISBN = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI) else DOI = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. URL else URL = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; &quot; .. Edition .. &quot; edition&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) 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
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Date .. Chapter .. Editors .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. ISBN .. DOI .. ID .. URL
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. ISBN .. DOI .. ID .. URL
    else
        text = Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. Date .. ISBN .. DOI .. ID .. URL
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = p.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    return text
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = p.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return p.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function p.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function p.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return p.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function p.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{reflabel}}.
function p.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid ~= nil and args.noid ~= &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return p.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

return p</text>
      <sha1>hcxyufbagqshw9ymr1beyi89i86q6xu</sha1>
    </revision>
    <revision>
      <id>4368</id>
      <parentid>4367</parentid>
      <timestamp>2012-08-26T22:17:34Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Fixed variable conflict.</comment>
      <origin>4368</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="14074" sha1="7ikxb27g95wvr85pnx0bn390yw7sg6k" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors 
    local a = {}
    for i=1,9,1 do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthor or args.coauthors 
    local Editors = args.editors 
    local e = {}    
    for i=1,9,1 do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Journal = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN = args.isbn or args.ISBN
    local DOI = args.doi or args.DOI
    local ID = args.id or args.ID or args.pmid or args.PMID
    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
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Journal ~= nil ) then
        Chapter = Title
        Title = Journal
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; ISBN &quot; .. ISBN else ISBN = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI) else DOI = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. URL else URL = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; &quot; .. Edition .. &quot; edition&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) 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
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Date .. Chapter .. Editors .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. ISBN .. DOI .. ID .. URL
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. ISBN .. DOI .. ID .. URL
    else
        text = Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. Date .. ISBN .. DOI .. ID .. URL
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    return text
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function p.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function p.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function p.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function p.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function p.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function p.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function p.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{reflabel}}.
function p.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid ~= nil and args.noid ~= &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

return z</text>
      <sha1>7ikxb27g95wvr85pnx0bn390yw7sg6k</sha1>
    </revision>
    <revision>
      <id>4369</id>
      <parentid>4368</parentid>
      <timestamp>2012-08-26T22:18:40Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Followed table name change.</comment>
      <origin>4369</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="14074" sha1="r8lj2bjqaw8tebnlqskmfcaydscc92f" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function doi(frame, id)
    local text = hideinprint(frame, &quot;[[Digital object identifier|doi]]:[http://dx.doi.org/{{urlencode:&quot; .. id .. &quot;}} &quot; .. z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=id,params={}}) .. &quot;]&quot;)
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors 
    local a = {}
    for i=1,9,1 do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthor or args.coauthors 
    local Editors = args.editors 
    local e = {}    
    for i=1,9,1 do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Journal = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local ISBN = args.isbn or args.ISBN
    local DOI = args.doi or args.DOI
    local ID = args.id or args.ID or args.pmid or args.PMID
    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
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Journal ~= nil ) then
        Chapter = Title
        Title = Journal
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; ISBN &quot; .. ISBN else ISBN = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI) else DOI = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. URL else URL = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; &quot; .. Edition .. &quot; edition&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) 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
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Date .. Chapter .. Editors .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. ISBN .. DOI .. ID .. URL
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. ISBN .. DOI .. ID .. URL
    else
        text = Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. Date .. ISBN .. DOI .. ID .. URL
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    return text
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{reflabel}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid ~= nil and args.noid ~= &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

return z</text>
      <sha1>r8lj2bjqaw8tebnlqskmfcaydscc92f</sha1>
    </revision>
    <revision>
      <id>4370</id>
      <parentid>4369</parentid>
      <timestamp>2012-08-27T09:50:04Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added processing of more parameters.</comment>
      <origin>4370</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="20258" sha1="hjk19ycb7t6haxapraeun355egxj6nm" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. &quot;{{urlencode:&quot; .. args.id .. &quot;}}&quot; .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. &quot;{{urlencode:&quot; .. args.id .. &quot;}}|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local text = externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = string.sub(id,string.length(id),1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors 
    local a = {}
    for i=1,9,1 do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthor or args.coauthors 
    local Editors = args.editors 
    local e = {}    
    for i=1,9,1 do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Journal = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or argx.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  
  
    -- 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
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Journal ~= nil ) then
        Chapter = Title
        Title = Journal
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) end
    if ( ARXIV ~= nil ) then ARXIV = externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internalinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externalinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; 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 identifiers = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Date .. Chapter .. Editors .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. identifiers
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. identifiers
    else
        text = Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. Date .. identifiers
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    
    local OCinS = &quot;&quot;
    
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid ~= nil and args.noid ~= &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

return z</text>
      <sha1>hjk19ycb7t6haxapraeun355egxj6nm</sha1>
    </revision>
    <revision>
      <id>4371</id>
      <parentid>4370</parentid>
      <timestamp>2012-08-27T09:50:44Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Corrected variable name.</comment>
      <origin>4371</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="20263" sha1="k8jjh4x7fn2h5ws80zwpcvb26xlh02e" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. &quot;{{urlencode:&quot; .. args.id .. &quot;}}&quot; .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. &quot;{{urlencode:&quot; .. args.id .. &quot;}}|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local text = externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = string.sub(id,string.length(id),1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors 
    local a = {}
    for i=1,9,1 do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthor or args.coauthors 
    local Editors = args.editors 
    local e = {}    
    for i=1,9,1 do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Journal = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or argx.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  
  
    -- 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
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Journal ~= nil ) then
        Chapter = Title
        Title = Journal
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) end
    if ( ARXIV ~= nil ) then ARXIV = externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internalinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externalinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; 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 identifiers = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Date .. Chapter .. Editors .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. identifiers
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. identifiers
    else
        text = Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. Date .. identifiers
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    
    local OCinS = &quot;&quot;
    
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid ~= nil and args.noid ~= &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

return z</text>
      <sha1>k8jjh4x7fn2h5ws80zwpcvb26xlh02e</sha1>
    </revision>
    <revision>
      <id>4372</id>
      <parentid>4371</parentid>
      <timestamp>2012-08-27T09:51:28Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Corrected table name.</comment>
      <origin>4372</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="20263" sha1="a511kjehokhl69idym0alprbqy8n3gx" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. &quot;{{urlencode:&quot; .. args.id .. &quot;}}&quot; .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. &quot;{{urlencode:&quot; .. args.id .. &quot;}}|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local text = externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = string.sub(id,string.length(id),1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors 
    local a = {}
    for i=1,9,1 do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthor or args.coauthors 
    local Editors = args.editors 
    local e = {}    
    for i=1,9,1 do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Journal = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  
  
    -- 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
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Journal ~= nil ) then
        Chapter = Title
        Title = Journal
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) end
    if ( ARXIV ~= nil ) then ARXIV = externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internalinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externalinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; 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 identifiers = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Date .. Chapter .. Editors .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. identifiers
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. identifiers
    else
        text = Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. Date .. identifiers
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    
    local OCinS = &quot;&quot;
    
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid ~= nil and args.noid ~= &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

return z</text>
      <sha1>a511kjehokhl69idym0alprbqy8n3gx</sha1>
    </revision>
    <revision>
      <id>4373</id>
      <parentid>4372</parentid>
      <timestamp>2012-08-27T09:52:32Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Fixed function call.</comment>
      <origin>4373</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="20264" sha1="98ly9cs20jdrgmtx4i14xkengzgtfsk" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. &quot;{{urlencode:&quot; .. args.id .. &quot;}}&quot; .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. &quot;{{urlencode:&quot; .. args.id .. &quot;}}|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local text = externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = string.sub(id,string.length(id),1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors 
    local a = {}
    for i=1,9,1 do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthor or args.coauthors 
    local Editors = args.editors 
    local e = {}    
    for i=1,9,1 do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Journal = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  
  
    -- 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
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Journal ~= nil ) then
        Chapter = Title
        Title = Journal
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) end
    if ( ARXIV ~= nil ) then ARXIV = externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externalinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; 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 identifiers = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Date .. Chapter .. Editors .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. identifiers
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. identifiers
    else
        text = Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. Date .. identifiers
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    
    local OCinS = &quot;&quot;
    
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid ~= nil and args.noid ~= &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

return z</text>
      <sha1>98ly9cs20jdrgmtx4i14xkengzgtfsk</sha1>
    </revision>
    <revision>
      <id>4374</id>
      <parentid>4373</parentid>
      <timestamp>2012-08-27T09:53:15Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Fixed variable reference.</comment>
      <origin>4374</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="20269" sha1="nkf6tcbiunya5y1d25nqinl0f4zgelx" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. &quot;{{urlencode:&quot; .. args.id .. &quot;}}&quot; .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. &quot;{{urlencode:&quot; .. args.id .. &quot;}}|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local text = externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = string.sub(id,string.length(id),1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors 
    local a = {}
    for i=1,9,1 do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthor or args.coauthors 
    local Editors = args.editors 
    local e = {}    
    for i=1,9,1 do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Journal = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  
  
    -- 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
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Journal ~= nil ) then
        Chapter = Title
        Title = Journal
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) end
    if ( ARXIV ~= nil ) then ARXIV = externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externalinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; 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 identifiers = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Date .. Chapter .. Editors .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. identifiers
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. identifiers
    else
        text = Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. Date .. identifiers
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    
    local OCinS = &quot;&quot;
    
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid ~= nil and args.noid ~= &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

return z</text>
      <sha1>nkf6tcbiunya5y1d25nqinl0f4zgelx</sha1>
    </revision>
    <revision>
      <id>4375</id>
      <parentid>4374</parentid>
      <timestamp>2012-08-27T09:54:53Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Fixed function call.</comment>
      <origin>4375</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="20301" sha1="nrzdorz7nv9iiujt61yffv3tb1vwcd7" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. &quot;{{urlencode:&quot; .. args.id .. &quot;}}&quot; .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local text = externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = string.sub(id,string.length(id),1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors 
    local a = {}
    for i=1,9,1 do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthor or args.coauthors 
    local Editors = args.editors 
    local e = {}    
    for i=1,9,1 do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Journal = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  
  
    -- 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
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Journal ~= nil ) then
        Chapter = Title
        Title = Journal
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) end
    if ( ARXIV ~= nil ) then ARXIV = externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; 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 identifiers = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Date .. Chapter .. Editors .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. identifiers
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. identifiers
    else
        text = Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. Date .. identifiers
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    
    local OCinS = &quot;&quot;
    
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid ~= nil and args.noid ~= &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

return z</text>
      <sha1>nrzdorz7nv9iiujt61yffv3tb1vwcd7</sha1>
    </revision>
    <revision>
      <id>4376</id>
      <parentid>4375</parentid>
      <timestamp>2012-08-27T09:56:31Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added whitespace to generated output.</comment>
      <origin>4376</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="20322" sha1="0a2dzojay4c0batrta18f19a1fulu6s" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. &quot;{{urlencode:&quot; .. args.id .. &quot;}}&quot; .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local text = externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = string.sub(id,string.length(id),1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors 
    local a = {}
    for i=1,9,1 do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthor or args.coauthors 
    local Editors = args.editors 
    local e = {}    
    for i=1,9,1 do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Journal = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  
  
    -- 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
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Journal ~= nil ) then
        Chapter = Title
        Title = Journal
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; 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 identifiers = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Date .. Chapter .. Editors .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. identifiers
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. identifiers
    else
        text = Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. Date .. identifiers
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local P1 = Surname1
            local P2 = Surname2
            local P3 = Surname3
            local P4 = Surname4
            local P5
            if ( Surname2 == nil ) then 
                P2 = Year 
            elseif ( Surname3 == nil ) then
                P3 = Year
            elseif ( Surname4 == nil ) then
                P4 = Year
            else
                P5 = Year
            end
            id = anchorid({P1,P2,P3,P4,P5})
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    
    local OCinS = &quot;&quot;
    
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid ~= nil and args.noid ~= &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

return z</text>
      <sha1>0a2dzojay4c0batrta18f19a1fulu6s</sha1>
    </revision>
    <revision>
      <id>4377</id>
      <parentid>4376</parentid>
      <timestamp>2012-08-27T10:14:06Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Fixed generation of citation span ID.</comment>
      <origin>4377</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="20513" sha1="f6j2ithjvbmynik0ayyletzmwrjb81g" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. &quot;{{urlencode:&quot; .. args.id .. &quot;}}&quot; .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local text = externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = string.sub(id,string.length(id),1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors 
    local a = {}
    for i=1,9,1 do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthor or args.coauthors 
    local Editors = args.editors 
    local e = {}    
    for i=1,9,1 do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Journal = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  
  
    -- 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 ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Journal ~= nil ) then
        Chapter = Title
        Title = Journal
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; 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 identifiers = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Date .. Chapter .. Editors .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. identifiers
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. identifiers
    else
        text = Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. Date .. identifiers
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. config.CitationClass, id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    
    local OCinS = &quot;&quot;
    
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid ~= nil and args.noid ~= &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

return z</text>
      <sha1>f6j2ithjvbmynik0ayyletzmwrjb81g</sha1>
    </revision>
    <revision>
      <id>4378</id>
      <parentid>4377</parentid>
      <timestamp>2012-08-27T11:22:01Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added nil check.</comment>
      <origin>4378</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="20521" sha1="11sr01pizph4vmydxzawq3ehu62oxxl" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. &quot;{{urlencode:&quot; .. args.id .. &quot;}}&quot; .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local text = externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = string.sub(id,string.length(id),1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors 
    local a = {}
    for i=1,9,1 do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthor or args.coauthors 
    local Editors = args.editors 
    local e = {}    
    for i=1,9,1 do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Journal = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  
  
    -- 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 ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Journal ~= nil ) then
        Chapter = Title
        Title = Journal
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; 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 identifiers = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Date .. Chapter .. Editors .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. identifiers
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. identifiers
    else
        text = Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. Date .. identifiers
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args}) 
    end
    
    local OCinS = &quot;&quot;
    
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid ~= nil and args.noid ~= &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

return z</text>
      <sha1>11sr01pizph4vmydxzawq3ehu62oxxl</sha1>
    </revision>
    <revision>
      <id>4379</id>
      <parentid>4378</parentid>
      <timestamp>2012-08-27T13:15:54Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added generation of COinS tags.</comment>
      <origin>4379</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="23239" sha1="bt1y5b9bx4zzkqax472i2pux1h2z0lw" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. &quot;{{&quot; .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local text = externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = string.sub(id,string.length(id),1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors 
    local a = {}
    for i=1,9,1 do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthor or args.coauthors 
    local Editors = args.editors 
    local e = {}    
    for i=1,9,1 do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    if ( PublicationPlace or Place ) then OCinSdata[&quot;rft.place&quot;] = (PublicationPlace or Place) end
    OCinSdata[&quot;rft.date&quot;] = Date
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = Publisher
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.ft_id = (URL or ChapterURL)
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;    
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Periodical ~= nil ) then
        Chapter = Title
        Title = Periodical
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; 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 identifiers = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Date .. Chapter .. Editors .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. identifiers
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. identifiers
    else
        text = Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. Date .. identifiers
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args})
    end
    
    local hiddenspace = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}}) 
    local OCinS = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=hiddenspace, params={class=&quot;Z3988&quot;,title=OCinStitle}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid ~= nil and args.noid ~= &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

return z</text>
      <sha1>bt1y5b9bx4zzkqax472i2pux1h2z0lw</sha1>
    </revision>
    <revision>
      <id>4380</id>
      <parentid>4379</parentid>
      <timestamp>2012-08-27T13:31:57Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Corrected OCinS datum name.</comment>
      <origin>4380</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="23240" sha1="ovi9aoeuoer5zxz4ph17nwa0cox5oop" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. &quot;{{&quot; .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local text = externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = string.sub(id,string.length(id),1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors 
    local a = {}
    for i=1,9,1 do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthor or args.coauthors 
    local Editors = args.editors 
    local e = {}    
    for i=1,9,1 do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    if ( PublicationPlace or Place ) then OCinSdata[&quot;rft.place&quot;] = (PublicationPlace or Place) end
    OCinSdata[&quot;rft.date&quot;] = Date
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = Publisher
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = (URL or ChapterURL)
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;    
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Periodical ~= nil ) then
        Chapter = Title
        Title = Periodical
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; 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 identifiers = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Date .. Chapter .. Editors .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. identifiers
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. identifiers
    else
        text = Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. Date .. identifiers
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args})
    end
    
    local hiddenspace = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}}) 
    local OCinS = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=hiddenspace, params={class=&quot;Z3988&quot;,title=OCinStitle}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid ~= nil and args.noid ~= &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

return z</text>
      <sha1>ovi9aoeuoer5zxz4ph17nwa0cox5oop</sha1>
    </revision>
    <revision>
      <id>4381</id>
      <parentid>4380</parentid>
      <timestamp>2012-08-27T14:34:33Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Spuriousopeningbracesectomy.</comment>
      <origin>4381</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="23232" sha1="a1mng8sem2aqy2ytqluhk6oxhy790dk" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local text = externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = string.sub(id,string.length(id),1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors 
    local a = {}
    for i=1,9,1 do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthor or args.coauthors 
    local Editors = args.editors 
    local e = {}    
    for i=1,9,1 do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    if ( PublicationPlace or Place ) then OCinSdata[&quot;rft.place&quot;] = (PublicationPlace or Place) end
    OCinSdata[&quot;rft.date&quot;] = Date
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = Publisher
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = (URL or ChapterURL)
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;    
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Periodical ~= nil ) then
        Chapter = Title
        Title = Periodical
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; 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 identifiers = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Date .. Chapter .. Editors .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. identifiers
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. identifiers
    else
        text = Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. Date .. identifiers
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args})
    end
    
    local hiddenspace = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}}) 
    local OCinS = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=hiddenspace, params={class=&quot;Z3988&quot;,title=OCinStitle}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid ~= nil and args.noid ~= &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

return z</text>
      <sha1>a1mng8sem2aqy2ytqluhk6oxhy790dk</sha1>
    </revision>
    <revision>
      <id>4382</id>
      <parentid>4381</parentid>
      <timestamp>2012-08-27T15:07:07Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added processing of more parameters.</comment>
      <origin>4382</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="23806" sha1="azwxnbycvavyj9952kpi5d7njofqcbz" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local text = externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = string.sub(id,string.length(id),1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors 
    local a = {}
    for i=1,9,1 do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthor or args.coauthors 
    local Editors = args.editors 
    local e = {}    
    for i=1,9,1 do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local Accessed = args.accessdate
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    if ( PublicationPlace or Place ) then OCinSdata[&quot;rft.place&quot;] = (PublicationPlace or Place) end
    OCinSdata[&quot;rft.date&quot;] = Date
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = Publisher
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = (URL or ChapterURL)
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;    
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Periodical ~= nil ) then
        Chapter = Title
        Title = Periodical
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( Accessed ~= nil ) then Accessed = &quot; Accessed on &quot; .. Accessed .. &quot;.&quot; else Accessed = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; 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 common = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Accessed .. Via .. SubscriptionRequired
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Date .. Chapter .. Editors .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. common
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. common
    else
        text = Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. Date .. common
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args})
    end
    
    local hiddenspace = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}}) 
    local OCinS = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=hiddenspace, params={class=&quot;Z3988&quot;,title=OCinStitle}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid ~= nil and args.noid ~= &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

return z</text>
      <sha1>azwxnbycvavyj9952kpi5d7njofqcbz</sha1>
    </revision>
    <revision>
      <id>4383</id>
      <parentid>4382</parentid>
      <timestamp>2012-08-27T15:14:28Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added whitespace to generated output.</comment>
      <origin>4383</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="23813" sha1="laemixxkdgfk3sx2z789r6kz4od3oyx" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local text = externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = string.sub(id,string.length(id),1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors 
    local a = {}
    for i=1,9,1 do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthor or args.coauthors 
    local Editors = args.editors 
    local e = {}    
    for i=1,9,1 do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local Accessed = args.accessdate
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    if ( PublicationPlace or Place ) then OCinSdata[&quot;rft.place&quot;] = (PublicationPlace or Place) end
    OCinSdata[&quot;rft.date&quot;] = Date
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = Publisher
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = (URL or ChapterURL)
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;    
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Periodical ~= nil ) then
        Chapter = Title
        Title = Periodical
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( Accessed ~= nil ) then Accessed = &quot; Accessed on &quot; .. Accessed .. &quot;.&quot; else Accessed = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; 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 common = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Accessed .. Via .. SubscriptionRequired
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Date .. Chapter .. Editors .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. common
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. common
    else
        text = Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. Date .. common
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args})
    end
    
    local hiddenspace = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}}) 
    local OCinS = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=hiddenspace, params={class=&quot;Z3988&quot;,title=OCinStitle}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid ~= nil and args.noid ~= &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

return z</text>
      <sha1>laemixxkdgfk3sx2z789r6kz4od3oyx</sha1>
    </revision>
    <revision>
      <id>4384</id>
      <parentid>4383</parentid>
      <timestamp>2012-08-27T17:14:41Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Made author and editor scanning loops shorter for the common case of only one or two names.</comment>
      <origin>4384</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="23939" sha1="1986l7dkfzojxcfzweaz8hywyuwmlj3" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local text = externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = string.sub(id,string.length(id),1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors 
    local i 
    local a = {}
    i = 1
    while true do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        else
            break
        end
        i = i + 1
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthor or args.coauthors 
    local Editors = args.editors 
    local e = {} 
    i = 1
    while true do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        else
            break
        end
        i = i + 1
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local Accessed = args.accessdate
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    if ( PublicationPlace or Place ) then OCinSdata[&quot;rft.place&quot;] = (PublicationPlace or Place) end
    OCinSdata[&quot;rft.date&quot;] = Date
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = Publisher
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = (URL or ChapterURL)
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;    
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Periodical ~= nil ) then
        Chapter = Title
        Title = Periodical
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( Accessed ~= nil ) then Accessed = &quot; Accessed on &quot; .. Accessed .. &quot;.&quot; else Accessed = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; 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 common = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Accessed .. Via .. SubscriptionRequired
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Date .. Chapter .. Editors .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. common
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. common
    else
        text = Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. Date .. common
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args})
    end
    
    local hiddenspace = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}}) 
    local OCinS = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=hiddenspace, params={class=&quot;Z3988&quot;,title=OCinStitle}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid ~= nil and args.noid ~= &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

return z</text>
      <sha1>1986l7dkfzojxcfzweaz8hywyuwmlj3</sha1>
    </revision>
    <revision>
      <id>4385</id>
      <parentid>4384</parentid>
      <timestamp>2012-08-27T17:58:21Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added support for [[Template:reflist]].</comment>
      <origin>4385</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="25367" sha1="m7gb676n7pcnrwl7udwtkqu13ylkh9g" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local text = externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = string.sub(id,string.length(id),1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors 
    local i 
    local a = {}
    i = 1
    while true do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        else
            break
        end
        i = i + 1
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthor or args.coauthors 
    local Editors = args.editors 
    local e = {} 
    i = 1
    while true do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        else
            break
        end
        i = i + 1
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local Accessed = args.accessdate
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    if ( PublicationPlace or Place ) then OCinSdata[&quot;rft.place&quot;] = (PublicationPlace or Place) end
    OCinSdata[&quot;rft.date&quot;] = Date
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = Publisher
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = (URL or ChapterURL)
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;    
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Periodical ~= nil ) then
        Chapter = Title
        Title = Periodical
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( Accessed ~= nil ) then Accessed = &quot; Accessed on &quot; .. Accessed .. &quot;.&quot; else Accessed = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; 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 common = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Accessed .. Via .. SubscriptionRequired
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Date .. Chapter .. Editors .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. common
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. common
    else
        text = Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. Date .. common
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid ~= nil and args.noid ~= &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{reflist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group
    local params = {}
    if ( tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = &quot;decimal&quot;
        end
    end
    params.class = &quot;reflist&quot;
    params.group = group
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    return z.wikitext.tag(frame, {name=&quot;references&quot;,contents=contents,params=params})
end

return z</text>
      <sha1>m7gb676n7pcnrwl7udwtkqu13ylkh9g</sha1>
    </revision>
    <revision>
      <id>4386</id>
      <parentid>4385</parentid>
      <timestamp>2012-08-27T18:01:42Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Inverted the sense of a test.</comment>
      <origin>4386</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="25374" sha1="qis2p090kabmbu44g7q3qxmgpvrbs6i" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local text = externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = string.sub(id,string.length(id),1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors 
    local i 
    local a = {}
    i = 1
    while true do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        else
            break
        end
        i = i + 1
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthor or args.coauthors 
    local Editors = args.editors 
    local e = {} 
    i = 1
    while true do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        else
            break
        end
        i = i + 1
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local Accessed = args.accessdate
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    if ( PublicationPlace or Place ) then OCinSdata[&quot;rft.place&quot;] = (PublicationPlace or Place) end
    OCinSdata[&quot;rft.date&quot;] = Date
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = Publisher
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = (URL or ChapterURL)
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;    
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Periodical ~= nil ) then
        Chapter = Title
        Title = Periodical
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( Accessed ~= nil ) then Accessed = &quot; Accessed on &quot; .. Accessed .. &quot;.&quot; else Accessed = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; 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 common = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Accessed .. Via .. SubscriptionRequired
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Date .. Chapter .. Editors .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. common
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. common
    else
        text = Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. Date .. common
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid ~= nil and args.noid ~= &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{reflist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group
    local params = {}
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = &quot;decimal&quot;
        end
    end
    params.class = &quot;reflist&quot;
    params.group = group
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    return z.wikitext.tag(frame, {name=&quot;references&quot;,contents=contents,params=params})
end

return z</text>
      <sha1>qis2p090kabmbu44g7q3qxmgpvrbs6i</sha1>
    </revision>
    <revision>
      <id>4387</id>
      <parentid>4386</parentid>
      <timestamp>2012-08-27T18:08:06Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Fixed generated &lt;references&gt; element.</comment>
      <origin>4387</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="25453" sha1="t7h4ga5frbtfwomef77res0ac4hg9dd" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local text = externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = string.sub(id,string.length(id),1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors 
    local i 
    local a = {}
    i = 1
    while true do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        else
            break
        end
        i = i + 1
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthor or args.coauthors 
    local Editors = args.editors 
    local e = {} 
    i = 1
    while true do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        else
            break
        end
        i = i + 1
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year or args.publicationdate
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local Chapter = args.chapter or args.article
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Pages = args.pages or args.page
    local Edition = args.edition
    local Place = args.place or args.location
    local PublicationPlace = args.publicationplace or args.place or args.location
    local Publisher = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local Accessed = args.accessdate
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    if ( PublicationPlace or Place ) then OCinSdata[&quot;rft.place&quot;] = (PublicationPlace or Place) end
    OCinSdata[&quot;rft.date&quot;] = Date
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = Publisher
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = (URL or ChapterURL)
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;    
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end        
    end
    if ( Periodical ~= nil ) then
        Chapter = Title
        Title = Periodical
    end
    if ( Chapter ~= nil ) then 
        Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Publisher ~= nil ) then Publisher = &quot; &quot; .. Publisher .. &quot;.&quot; else Publisher = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = &quot; &quot; .. PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Pages ~= nil ) then Pages = &quot; :&quot; .. Pages else Pages = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( Accessed ~= nil ) then Accessed = &quot; Accessed on &quot; .. Accessed .. &quot;.&quot; else Accessed = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; 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 common = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Accessed .. Via .. SubscriptionRequired
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Date .. Chapter .. Editors .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. common
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. common
    else
        text = Chapter .. Title .. Format .. Edition .. Language .. Volume .. Issue .. Pages .. Series .. PublicationPlace .. Publisher .. Date .. common
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid ~= nil and args.noid ~= &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{reflist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group
    local params = {}
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = &quot;decimal&quot;
        end
    end
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.wikitext.tag(frame, {name=&quot;references&quot;,contents=contents,params={group=group}})
    return z.wikitext.tag(frame, {name=&quot;div&quot;,contents=references,params=params})
end

return z</text>
      <sha1>t7h4ga5frbtfwomef77res0ac4hg9dd</sha1>
    </revision>
    <revision>
      <id>4388</id>
      <parentid>4387</parentid>
      <timestamp>2012-08-27T19:11:45Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added processing of more parameters.</comment>
      <origin>4388</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="27659" sha1="quk86gvlcg02jbnqn6w7tyflt034mo6" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local text = externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = string.sub(id,string.length(id),1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        else
            break
        end
        i = i + 1
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        else
            break
        end
        i = i + 1
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local TransTitle = args.trans_title
    local Chapter = args.chapter or args.article
    local TransChapter = args.trans_chapter
    local Type = args.type
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local Accessed = args.accessdate
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;    
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( Chapter ~= nil ) then 
        if ( Periodical ~= nil ) then
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        else
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        end
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if ( Periodical ~= nil ) then
            Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
        else
            Title = &quot; \&quot;&quot; .. Title .. &quot;\&quot;.&quot;
        end
    else 
        Title = &quot;&quot; 
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    elseif ( &quot;y&quot; == args.nopp ) then
        Page = &quot; &quot; .. Page
    else
        Page = &quot; p.&quot; .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Page
    elseif ( &quot;y&quot; == args.nopp ) then
        Pages = &quot; &quot; .. Pages
    else
        Pages = &quot; pp.&quot; .. Page
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot; else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TransTitle ~= nil ) then TransTitle = &quot; (&quot; .. TransTitle .. &quot;).&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; (&quot; .. TransChapter .. &quot;).&quot; else TransChapter = &quot;&quot; end
    if ( Type ~= nil ) then Type = &quot; (&quot; .. Type .. &quot;).&quot; else Type = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( Accessed ~= nil ) then Accessed = &quot; Accessed on &quot; .. Accessed .. &quot;.&quot; else Accessed = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot;(&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Accessed .. Via .. SubscriptionRequired
    local tcommon = Title .. TransTitle .. Type .. Format .. Edition .. Language .. Periodical .. Series .. Volume .. Issue .. Page .. Pages
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. TransChapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. TransChapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. TransChapter .. tcommon .. Publisher .. Date .. common
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid ~= nil and args.noid ~= &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{reflist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group
    local params = {}
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = &quot;decimal&quot;
        end
    end
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.wikitext.tag(frame, {name=&quot;references&quot;,contents=contents,params={group=group}})
    return z.wikitext.tag(frame, {name=&quot;div&quot;,contents=references,params=params})
end

return z</text>
      <sha1>quk86gvlcg02jbnqn6w7tyflt034mo6</sha1>
    </revision>
    <revision>
      <id>4389</id>
      <parentid>4388</parentid>
      <timestamp>2012-08-27T19:12:41Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Corrected variable name.</comment>
      <origin>4389</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="27661" sha1="emsn07l14hfj9qlrkb9nahz2hb2t6fo" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local text = externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = string.sub(id,string.length(id),1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        else
            break
        end
        i = i + 1
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        else
            break
        end
        i = i + 1
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local TransTitle = args.trans_title
    local Chapter = args.chapter or args.article
    local TransChapter = args.trans_chapter
    local Type = args.type
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local Accessed = args.accessdate
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;    
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( Chapter ~= nil ) then 
        if ( Periodical ~= nil ) then
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        else
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        end
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if ( Periodical ~= nil ) then
            Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
        else
            Title = &quot; \&quot;&quot; .. Title .. &quot;\&quot;.&quot;
        end
    else 
        Title = &quot;&quot; 
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    elseif ( &quot;y&quot; == args.nopp ) then
        Page = &quot; &quot; .. Page
    else
        Page = &quot; p.&quot; .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Page
    elseif ( &quot;y&quot; == args.nopp ) then
        Pages = &quot; &quot; .. Pages
    else
        Pages = &quot; pp.&quot; .. Page
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot; else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TransTitle ~= nil ) then TransTitle = &quot; (&quot; .. TransTitle .. &quot;).&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; (&quot; .. TransChapter .. &quot;).&quot; else TransChapter = &quot;&quot; end
    if ( Type ~= nil ) then Type = &quot; (&quot; .. Type .. &quot;).&quot; else Type = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;:&quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( Accessed ~= nil ) then Accessed = &quot; Accessed on &quot; .. Accessed .. &quot;.&quot; else Accessed = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot;(&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Accessed .. Via .. SubscriptionRequired
    local tcommon = Title .. TransTitle .. Type .. Format .. Edition .. Language .. Periodical .. Series .. Volume .. Issue .. Page .. Pages
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. TransChapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. TransChapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. TransChapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid ~= nil and args.noid ~= &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{reflist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group
    local params = {}
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = &quot;decimal&quot;
        end
    end
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.wikitext.tag(frame, {name=&quot;references&quot;,contents=contents,params={group=group}})
    return z.wikitext.tag(frame, {name=&quot;div&quot;,contents=references,params=params})
end

return z</text>
      <sha1>emsn07l14hfj9qlrkb9nahz2hb2t6fo</sha1>
    </revision>
    <revision>
      <id>4390</id>
      <parentid>4389</parentid>
      <timestamp>2012-08-27T19:15:33Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Corrected variable name.</comment>
      <origin>4390</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="27663" sha1="8kuoc7hnohoc2fut7b2e973v16ilhel" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local text = externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = string.sub(id,string.length(id),1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        else
            break
        end
        i = i + 1
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        else
            break
        end
        i = i + 1
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local TransTitle = args.trans_title
    local Chapter = args.chapter or args.article
    local TransChapter = args.trans_chapter
    local Type = args.type
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local Accessed = args.accessdate
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;    
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( Chapter ~= nil ) then 
        if ( Periodical ~= nil ) then
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        else
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        end
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if ( Periodical ~= nil ) then
            Title = &quot; ''&quot; .. Title .. &quot;''.&quot;
        else
            Title = &quot; \&quot;&quot; .. Title .. &quot;\&quot;.&quot;
        end
    else 
        Title = &quot;&quot; 
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    elseif ( &quot;y&quot; == args.nopp ) then
        Page = &quot; &quot; .. Page
    else
        Page = &quot; p.&quot; .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Page
    elseif ( &quot;y&quot; == args.nopp ) then
        Pages = &quot; &quot; .. Pages
    else
        Pages = &quot; pp.&quot; .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot; else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TransTitle ~= nil ) then TransTitle = &quot; (&quot; .. TransTitle .. &quot;).&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; (&quot; .. TransChapter .. &quot;).&quot; else TransChapter = &quot;&quot; end
    if ( Type ~= nil ) then Type = &quot; (&quot; .. Type .. &quot;).&quot; else Type = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( Accessed ~= nil ) then Accessed = &quot; Accessed on &quot; .. Accessed .. &quot;.&quot; else Accessed = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot;(&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Accessed .. Via .. SubscriptionRequired
    local tcommon = Title .. TransTitle .. Type .. Format .. Edition .. Language .. Periodical .. Series .. Volume .. Issue .. Page .. Pages
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. TransChapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. TransChapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. TransChapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid ~= nil and args.noid ~= &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{reflist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group
    local params = {}
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = &quot;decimal&quot;
        end
    end
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.wikitext.tag(frame, {name=&quot;references&quot;,contents=contents,params={group=group}})
    return z.wikitext.tag(frame, {name=&quot;div&quot;,contents=references,params=params})
end

return z</text>
      <sha1>8kuoc7hnohoc2fut7b2e973v16ilhel</sha1>
    </revision>
    <revision>
      <id>4391</id>
      <parentid>4390</parentid>
      <timestamp>2012-08-27T19:19:57Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Inverted the sense of a test.</comment>
      <origin>4391</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="27695" sha1="rxcd99i114v9uzndfldc5vmgyhuga5u" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local text = externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = string.sub(id,string.length(id),1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        else
            break
        end
        i = i + 1
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        else
            break
        end
        i = i + 1
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local TransTitle = args.trans_title
    local Chapter = args.chapter or args.article
    local TransChapter = args.trans_chapter
    local Type = args.type
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local Accessed = args.accessdate
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;    
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( Chapter ~= nil ) then 
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    elseif ( &quot;y&quot; == args.nopp ) then
        Page = &quot; &quot; .. Page
    else
        Page = &quot; p.&quot; .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Page
    elseif ( &quot;y&quot; == args.nopp ) then
        Pages = &quot; &quot; .. Pages
    else
        Pages = &quot; pp.&quot; .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot; else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TransTitle ~= nil ) then TransTitle = &quot; (&quot; .. TransTitle .. &quot;).&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; (&quot; .. TransChapter .. &quot;).&quot; else TransChapter = &quot;&quot; end
    if ( Type ~= nil ) then Type = &quot; (&quot; .. Type .. &quot;).&quot; else Type = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( Accessed ~= nil ) then Accessed = &quot; Accessed on &quot; .. Accessed .. &quot;.&quot; else Accessed = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot;(&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Accessed .. Via .. SubscriptionRequired
    local tcommon = Title .. TransTitle .. Type .. Format .. Edition .. Language .. Periodical .. Series .. Volume .. Issue .. Page .. Pages
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. TransChapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. TransChapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. TransChapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid ~= nil and args.noid ~= &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{reflist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group
    local params = {}
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = &quot;decimal&quot;
        end
    end
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.wikitext.tag(frame, {name=&quot;references&quot;,contents=contents,params={group=group}})
    return z.wikitext.tag(frame, {name=&quot;div&quot;,contents=references,params=params})
end

return z</text>
      <sha1>rxcd99i114v9uzndfldc5vmgyhuga5u</sha1>
    </revision>
    <revision>
      <id>4392</id>
      <parentid>4391</parentid>
      <timestamp>2012-08-27T19:22:15Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Corrected variable name.</comment>
      <origin>4392</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="27696" sha1="rh1nzff15d9mk5h5ar6zpdcc4g6h88h" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local text = externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = string.sub(id,string.length(id),1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        else
            break
        end
        i = i + 1
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        else
            break
        end
        i = i + 1
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local TransTitle = args.trans_title
    local Chapter = args.chapter or args.article
    local TransChapter = args.trans_chapter
    local Type = args.type
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local Accessed = args.accessdate
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;    
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( Chapter ~= nil ) then 
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    elseif ( &quot;y&quot; == args.nopp ) then
        Page = &quot; &quot; .. Page
    else
        Page = &quot; p.&quot; .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    elseif ( &quot;y&quot; == args.nopp ) then
        Pages = &quot; &quot; .. Pages
    else
        Pages = &quot; pp.&quot; .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot; else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TransTitle ~= nil ) then TransTitle = &quot; (&quot; .. TransTitle .. &quot;).&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; (&quot; .. TransChapter .. &quot;).&quot; else TransChapter = &quot;&quot; end
    if ( Type ~= nil ) then Type = &quot; (&quot; .. Type .. &quot;).&quot; else Type = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( Accessed ~= nil ) then Accessed = &quot; Accessed on &quot; .. Accessed .. &quot;.&quot; else Accessed = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot;(&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Accessed .. Via .. SubscriptionRequired
    local tcommon = Title .. TransTitle .. Type .. Format .. Edition .. Language .. Periodical .. Series .. Volume .. Issue .. Page .. Pages
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. TransChapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. TransChapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. TransChapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid ~= nil and args.noid ~= &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{reflist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group
    local params = {}
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = &quot;decimal&quot;
        end
    end
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.wikitext.tag(frame, {name=&quot;references&quot;,contents=contents,params={group=group}})
    return z.wikitext.tag(frame, {name=&quot;div&quot;,contents=references,params=params})
end

return z</text>
      <sha1>rh1nzff15d9mk5h5ar6zpdcc4g6h88h</sha1>
    </revision>
    <revision>
      <id>4393</id>
      <parentid>4392</parentid>
      <timestamp>2012-08-27T19:27:04Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added whitespace to generated output.</comment>
      <origin>4393</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="27697" sha1="1feny3vtygwaxftx6h6dbp7tvffkd8o" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local text = externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = string.sub(id,string.length(id),1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        else
            break
        end
        i = i + 1
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        else
            break
        end
        i = i + 1
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local TransTitle = args.trans_title
    local Chapter = args.chapter or args.article
    local TransChapter = args.trans_chapter
    local Type = args.type
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local Accessed = args.accessdate
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;    
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( Chapter ~= nil ) then 
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    elseif ( &quot;y&quot; == args.nopp ) then
        Page = &quot; &quot; .. Page
    else
        Page = &quot; p.&quot; .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    elseif ( &quot;y&quot; == args.nopp ) then
        Pages = &quot; &quot; .. Pages
    else
        Pages = &quot; pp.&quot; .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot; else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TransTitle ~= nil ) then TransTitle = &quot; (&quot; .. TransTitle .. &quot;).&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; (&quot; .. TransChapter .. &quot;).&quot; else TransChapter = &quot;&quot; end
    if ( Type ~= nil ) then Type = &quot; (&quot; .. Type .. &quot;).&quot; else Type = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( Accessed ~= nil ) then Accessed = &quot; Accessed on &quot; .. Accessed .. &quot;.&quot; else Accessed = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Accessed .. Via .. SubscriptionRequired
    local tcommon = Title .. TransTitle .. Type .. Format .. Edition .. Language .. Periodical .. Series .. Volume .. Issue .. Page .. Pages
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. TransChapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. TransChapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. TransChapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid ~= nil and args.noid ~= &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{reflist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group
    local params = {}
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = &quot;decimal&quot;
        end
    end
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.wikitext.tag(frame, {name=&quot;references&quot;,contents=contents,params={group=group}})
    return z.wikitext.tag(frame, {name=&quot;div&quot;,contents=references,params=params})
end

return z</text>
      <sha1>1feny3vtygwaxftx6h6dbp7tvffkd8o</sha1>
    </revision>
    <revision>
      <id>4394</id>
      <parentid>4393</parentid>
      <timestamp>2012-08-27T23:58:06Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added support for [[Template:efn]].</comment>
      <origin>4394</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="28141" sha1="4sflwl72marqq4x0e065bpem7tomr4v" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local text = externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = string.sub(id,string.length(id),1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        else
            break
        end
        i = i + 1
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        else
            break
        end
        i = i + 1
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local TransTitle = args.trans_title
    local Chapter = args.chapter or args.article
    local TransChapter = args.trans_chapter
    local Type = args.type
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local Accessed = args.accessdate
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;    
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( Chapter ~= nil ) then 
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    elseif ( &quot;y&quot; == args.nopp ) then
        Page = &quot; &quot; .. Page
    else
        Page = &quot; p.&quot; .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    elseif ( &quot;y&quot; == args.nopp ) then
        Pages = &quot; &quot; .. Pages
    else
        Pages = &quot; pp.&quot; .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot; else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TransTitle ~= nil ) then TransTitle = &quot; (&quot; .. TransTitle .. &quot;).&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; (&quot; .. TransChapter .. &quot;).&quot; else TransChapter = &quot;&quot; end
    if ( Type ~= nil ) then Type = &quot; (&quot; .. Type .. &quot;).&quot; else Type = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( Accessed ~= nil ) then Accessed = &quot; Accessed on &quot; .. Accessed .. &quot;.&quot; else Accessed = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Accessed .. Via .. SubscriptionRequired
    local tcommon = Title .. TransTitle .. Type .. Format .. Edition .. Language .. Periodical .. Series .. Volume .. Issue .. Page .. Pages
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. TransChapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. TransChapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. TransChapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid ~= nil and args.noid ~= &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{reflist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group
    local params = {}
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = &quot;decimal&quot;
        end
    end
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.wikitext.tag(frame, {name=&quot;references&quot;,contents=contents,params={group=group}})
    return z.wikitext.tag(frame, {name=&quot;div&quot;,contents=references,params=params})
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=&quot;lower-alpha&quot;}})
end

return z</text>
      <sha1>4sflwl72marqq4x0e065bpem7tomr4v</sha1>
    </revision>
    <revision>
      <id>4395</id>
      <parentid>4394</parentid>
      <timestamp>2012-08-28T00:05:39Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added support for [[Template:notelist]].</comment>
      <origin>4395</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="28634" sha1="g0ns5zb2rg3lrxs3s4i0oydwewqf2o5" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local text = externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = string.sub(id,string.length(id),1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        else
            break
        end
        i = i + 1
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        else
            break
        end
        i = i + 1
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local TransTitle = args.trans_title
    local Chapter = args.chapter or args.article
    local TransChapter = args.trans_chapter
    local Type = args.type
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local Accessed = args.accessdate
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;    
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( Chapter ~= nil ) then 
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    elseif ( &quot;y&quot; == args.nopp ) then
        Page = &quot; &quot; .. Page
    else
        Page = &quot; p.&quot; .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    elseif ( &quot;y&quot; == args.nopp ) then
        Pages = &quot; &quot; .. Pages
    else
        Pages = &quot; pp.&quot; .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot; else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TransTitle ~= nil ) then TransTitle = &quot; (&quot; .. TransTitle .. &quot;).&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; (&quot; .. TransChapter .. &quot;).&quot; else TransChapter = &quot;&quot; end
    if ( Type ~= nil ) then Type = &quot; (&quot; .. Type .. &quot;).&quot; else Type = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( Accessed ~= nil ) then Accessed = &quot; Accessed on &quot; .. Accessed .. &quot;.&quot; else Accessed = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Accessed .. Via .. SubscriptionRequired
    local tcommon = Title .. TransTitle .. Type .. Format .. Edition .. Language .. Periodical .. Series .. Volume .. Issue .. Page .. Pages
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. TransChapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. TransChapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. TransChapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

function reflist0(frame, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group
    local params = {}
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = &quot;decimal&quot;
        end
    end
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.wikitext.tag(frame, {name=&quot;references&quot;,contents=contents,params={group=group}})
    return z.wikitext.tag(frame, {name=&quot;div&quot;,contents=references,params=params})
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid ~= nil and args.noid ~= &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{reflist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, args)    
end

-- This is used by template {{notelist}}.
function z.notelist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.group = args.group or &quot;lower-alpha&quot;
    return reflist0(frame, args)    
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=&quot;lower-alpha&quot;}})
end

return z</text>
      <sha1>g0ns5zb2rg3lrxs3s4i0oydwewqf2o5</sha1>
    </revision>
    <revision>
      <id>4396</id>
      <parentid>4395</parentid>
      <timestamp>2012-08-28T00:14:06Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Inverted the sense of a test.</comment>
      <origin>4396</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="28633" sha1="d0y19z9np149ert1wodjwe41puni3xd" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local text = externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = string.sub(id,string.length(id),1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        else
            break
        end
        i = i + 1
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        else
            break
        end
        i = i + 1
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local TransTitle = args.trans_title
    local Chapter = args.chapter or args.article
    local TransChapter = args.trans_chapter
    local Type = args.type
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local Accessed = args.accessdate
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;    
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( Chapter ~= nil ) then 
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    elseif ( &quot;y&quot; == args.nopp ) then
        Page = &quot; &quot; .. Page
    else
        Page = &quot; p.&quot; .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    elseif ( &quot;y&quot; == args.nopp ) then
        Pages = &quot; &quot; .. Pages
    else
        Pages = &quot; pp.&quot; .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot; else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TransTitle ~= nil ) then TransTitle = &quot; (&quot; .. TransTitle .. &quot;).&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; (&quot; .. TransChapter .. &quot;).&quot; else TransChapter = &quot;&quot; end
    if ( Type ~= nil ) then Type = &quot; (&quot; .. Type .. &quot;).&quot; else Type = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( Accessed ~= nil ) then Accessed = &quot; Accessed on &quot; .. Accessed .. &quot;.&quot; else Accessed = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Accessed .. Via .. SubscriptionRequired
    local tcommon = Title .. TransTitle .. Type .. Format .. Edition .. Language .. Periodical .. Series .. Volume .. Issue .. Page .. Pages
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. TransChapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. TransChapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. TransChapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

function reflist0(frame, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group
    local params = {}
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = &quot;decimal&quot;
        end
    end
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.wikitext.tag(frame, {name=&quot;references&quot;,contents=contents,params={group=group}})
    return z.wikitext.tag(frame, {name=&quot;div&quot;,contents=references,params=params})
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{reflist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, args)    
end

-- This is used by template {{notelist}}.
function z.notelist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.group = args.group or &quot;lower-alpha&quot;
    return reflist0(frame, args)    
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=&quot;lower-alpha&quot;}})
end

return z</text>
      <sha1>d0y19z9np149ert1wodjwe41puni3xd</sha1>
    </revision>
    <revision>
      <id>4397</id>
      <parentid>4396</parentid>
      <timestamp>2012-08-28T16:29:08Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Merged two functions into one.</comment>
      <origin>4397</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="28289" sha1="rqukds72v7ga32ivg9xbgvze4ylae47" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local text = externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = string.sub(id,string.length(id),1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        else
            break
        end
        i = i + 1
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        else
            break
        end
        i = i + 1
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local TransTitle = args.trans_title
    local Chapter = args.chapter or args.article
    local TransChapter = args.trans_chapter
    local Type = args.type
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local Accessed = args.accessdate
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;    
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( Chapter ~= nil ) then 
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    elseif ( &quot;y&quot; == args.nopp ) then
        Page = &quot; &quot; .. Page
    else
        Page = &quot; p.&quot; .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    elseif ( &quot;y&quot; == args.nopp ) then
        Pages = &quot; &quot; .. Pages
    else
        Pages = &quot; pp.&quot; .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot; else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TransTitle ~= nil ) then TransTitle = &quot; (&quot; .. TransTitle .. &quot;).&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; (&quot; .. TransChapter .. &quot;).&quot; else TransChapter = &quot;&quot; end
    if ( Type ~= nil ) then Type = &quot; (&quot; .. Type .. &quot;).&quot; else Type = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( Accessed ~= nil ) then Accessed = &quot; Accessed on &quot; .. Accessed .. &quot;.&quot; else Accessed = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Accessed .. Via .. SubscriptionRequired
    local tcommon = Title .. TransTitle .. Type .. Format .. Edition .. Language .. Periodical .. Series .. Volume .. Issue .. Page .. Pages
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. TransChapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. TransChapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. TransChapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    local params = {}
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.wikitext.tag(frame, {name=&quot;references&quot;,contents=contents,params={group=group}})
    return z.wikitext.tag(frame, {name=&quot;div&quot;,contents=references,params=params})
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}})
end

return z</text>
      <sha1>rqukds72v7ga32ivg9xbgvze4ylae47</sha1>
    </revision>
    <revision>
      <id>4398</id>
      <parentid>4397</parentid>
      <timestamp>2012-08-28T16:53:46Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added support for [[Template:refbegin]] and [[Template:refend]].</comment>
      <origin>4398</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="33779" sha1="2ab09t2t9i0brwlmdmy3la3w7l6fcth" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local text = externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = string.sub(id,string.length(id),1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        else
            break
        end
        i = i + 1
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        else
            break
        end
        i = i + 1
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local TransTitle = args.trans_title
    local Chapter = args.chapter or args.article
    local TransChapter = args.trans_chapter
    local Type = args.type
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local Accessed = args.accessdate
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;    
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( Chapter ~= nil ) then 
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    elseif ( &quot;y&quot; == args.nopp ) then
        Page = &quot; &quot; .. Page
    else
        Page = &quot; p.&quot; .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    elseif ( &quot;y&quot; == args.nopp ) then
        Pages = &quot; &quot; .. Pages
    else
        Pages = &quot; pp.&quot; .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot; else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TransTitle ~= nil ) then TransTitle = &quot; (&quot; .. TransTitle .. &quot;).&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; (&quot; .. TransChapter .. &quot;).&quot; else TransChapter = &quot;&quot; end
    if ( Type ~= nil ) then Type = &quot; (&quot; .. Type .. &quot;).&quot; else Type = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( Accessed ~= nil ) then Accessed = &quot; Accessed on &quot; .. Accessed .. &quot;.&quot; else Accessed = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Accessed .. Via .. SubscriptionRequired
    local tcommon = Title .. TransTitle .. Type .. Format .. Edition .. Language .. Periodical .. Series .. Volume .. Issue .. Page .. Pages
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. TransChapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. TransChapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. TransChapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    local params = {}
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.wikitext.tag(frame, {name=&quot;references&quot;,contents=contents,params={group=group}})
    return z.wikitext.tag(frame, {name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    local params = {}
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag(frame, {name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag(frame, {name=&quot;div&quot;,params=params}) .. dlopen
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag(frame, {name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag(frame, {name=&quot;div&quot;,params=params}) .. dlopen
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag(frame, {name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag(frame, {name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}})
end

return z</text>
      <sha1>2ab09t2t9i0brwlmdmy3la3w7l6fcth</sha1>
    </revision>
    <revision>
      <id>4399</id>
      <parentid>4398</parentid>
      <timestamp>2012-08-28T16:58:16Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Fixed my copy and paste error</comment>
      <origin>4399</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="30701" sha1="ejkz9l6s0w52879wb2fwt6urg3s3ipi" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local text = externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = string.sub(id,string.length(id),1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        else
            break
        end
        i = i + 1
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        else
            break
        end
        i = i + 1
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local TransTitle = args.trans_title
    local Chapter = args.chapter or args.article
    local TransChapter = args.trans_chapter
    local Type = args.type
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local Accessed = args.accessdate
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;    
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( Chapter ~= nil ) then 
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    elseif ( &quot;y&quot; == args.nopp ) then
        Page = &quot; &quot; .. Page
    else
        Page = &quot; p.&quot; .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    elseif ( &quot;y&quot; == args.nopp ) then
        Pages = &quot; &quot; .. Pages
    else
        Pages = &quot; pp.&quot; .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot; else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TransTitle ~= nil ) then TransTitle = &quot; (&quot; .. TransTitle .. &quot;).&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; (&quot; .. TransChapter .. &quot;).&quot; else TransChapter = &quot;&quot; end
    if ( Type ~= nil ) then Type = &quot; (&quot; .. Type .. &quot;).&quot; else Type = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( Accessed ~= nil ) then Accessed = &quot; Accessed on &quot; .. Accessed .. &quot;.&quot; else Accessed = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Accessed .. Via .. SubscriptionRequired
    local tcommon = Title .. TransTitle .. Type .. Format .. Edition .. Language .. Periodical .. Series .. Volume .. Issue .. Page .. Pages
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. TransChapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. TransChapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. TransChapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.wikitext.tag(frame, {name=&quot;references&quot;,contents=contents,params={group=group}})
    return z.wikitext.tag(frame, {name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag(frame, {name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag(frame, {name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}})
end

return z</text>
      <sha1>ejkz9l6s0w52879wb2fwt6urg3s3ipi</sha1>
    </revision>
    <revision>
      <id>4400</id>
      <parentid>4399</parentid>
      <timestamp>2012-08-28T17:03:04Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Removed incorrect extra argument to function.</comment>
      <origin>4400</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="30687" sha1="2vk14epotmy9w41uu1c5ux08jzib0fd" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local text = externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = string.sub(id,string.length(id),1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        else
            break
        end
        i = i + 1
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        else
            break
        end
        i = i + 1
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia
    local TransTitle = args.trans_title
    local Chapter = args.chapter or args.article
    local TransChapter = args.trans_chapter
    local Type = args.type
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local Accessed = args.accessdate
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;    
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( Chapter ~= nil ) then 
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    elseif ( &quot;y&quot; == args.nopp ) then
        Page = &quot; &quot; .. Page
    else
        Page = &quot; p.&quot; .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    elseif ( &quot;y&quot; == args.nopp ) then
        Pages = &quot; &quot; .. Pages
    else
        Pages = &quot; pp.&quot; .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot; else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TransTitle ~= nil ) then TransTitle = &quot; (&quot; .. TransTitle .. &quot;).&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; (&quot; .. TransChapter .. &quot;).&quot; else TransChapter = &quot;&quot; end
    if ( Type ~= nil ) then Type = &quot; (&quot; .. Type .. &quot;).&quot; else Type = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( Accessed ~= nil ) then Accessed = &quot; Accessed on &quot; .. Accessed .. &quot;.&quot; else Accessed = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Accessed .. Via .. SubscriptionRequired
    local tcommon = Title .. TransTitle .. Type .. Format .. Edition .. Language .. Periodical .. Series .. Volume .. Issue .. Page .. Pages
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. TransChapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. TransChapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. TransChapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.wikitext.tag(frame, {name=&quot;references&quot;,contents=contents,params={group=group}})
    return z.wikitext.tag(frame, {name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}})
end

return z</text>
      <sha1>2vk14epotmy9w41uu1c5ux08jzib0fd</sha1>
    </revision>
    <revision>
      <id>4401</id>
      <parentid>4400</parentid>
      <timestamp>2012-08-29T04:04:54Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added support for [[Template:Cite dictionary]].</comment>
      <origin>4401</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="30720" sha1="bv8p3w8g2c03u4aoeh35cl62g9cfv47" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local text = externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = string.sub(id,string.length(id),1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[i] = {}
            a[i].last = last
            a[i].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[i].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        else
            break
        end
        i = i + 1
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last ~= nil ) then
            a[1] = {}
            a[1].last = last
            a[1].first = args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i]
            a[1].link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
        end
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last ~= nil ) then
            e[i] = {}
            e[i].last = last
            e[i].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[i].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        else
            break
        end
        i = i + 1
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last ~= nil ) then
            e[1] = {}
            e[1].last = last
            e[1].first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i]
            e[1].link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
        end
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local TransTitle = args.trans_title
    local Chapter = args.chapter or args.article or args.entry
    local TransChapter = args.trans_chapter
    local Type = args.type
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local Accessed = args.accessdate
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;    
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( Chapter ~= nil ) then 
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    elseif ( &quot;y&quot; == args.nopp ) then
        Page = &quot; &quot; .. Page
    else
        Page = &quot; p.&quot; .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    elseif ( &quot;y&quot; == args.nopp ) then
        Pages = &quot; &quot; .. Pages
    else
        Pages = &quot; pp.&quot; .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot; else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TransTitle ~= nil ) then TransTitle = &quot; (&quot; .. TransTitle .. &quot;).&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; (&quot; .. TransChapter .. &quot;).&quot; else TransChapter = &quot;&quot; end
    if ( Type ~= nil ) then Type = &quot; (&quot; .. Type .. &quot;).&quot; else Type = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( Accessed ~= nil ) then Accessed = &quot; Accessed on &quot; .. Accessed .. &quot;.&quot; else Accessed = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Accessed .. Via .. SubscriptionRequired
    local tcommon = Title .. TransTitle .. Type .. Format .. Edition .. Language .. Periodical .. Series .. Volume .. Issue .. Page .. Pages
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. TransChapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. TransChapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. TransChapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.wikitext.tag(frame, {name=&quot;references&quot;,contents=contents,params={group=group}})
    return z.wikitext.tag(frame, {name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}})
end

return z</text>
      <sha1>bv8p3w8g2c03u4aoeh35cl62g9cfv47</sha1>
    </revision>
    <revision>
      <id>4402</id>
      <parentid>4401</parentid>
      <timestamp>2012-08-29T04:58:13Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Factored out common code.</comment>
      <origin>4402</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="30229" sha1="7cq01ttjny4hi7v65czjxnr1gclo0ar" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local text = externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = string.sub(id,string.length(id),1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot; &amp; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        a[1] = extractauthor(args, i)
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        e[1] = extracteditor(args, i)
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local TransTitle = args.trans_title
    local Chapter = args.chapter or args.article or args.entry
    local TransChapter = args.trans_chapter
    local Type = args.type
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local Accessed = args.accessdate
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;    
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( Chapter ~= nil ) then 
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    elseif ( &quot;y&quot; == args.nopp ) then
        Page = &quot; &quot; .. Page
    else
        Page = &quot; p.&quot; .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    elseif ( &quot;y&quot; == args.nopp ) then
        Pages = &quot; &quot; .. Pages
    else
        Pages = &quot; pp.&quot; .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot; else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TransTitle ~= nil ) then TransTitle = &quot; (&quot; .. TransTitle .. &quot;).&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; (&quot; .. TransChapter .. &quot;).&quot; else TransChapter = &quot;&quot; end
    if ( Type ~= nil ) then Type = &quot; (&quot; .. Type .. &quot;).&quot; else Type = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( Accessed ~= nil ) then Accessed = &quot; Accessed on &quot; .. Accessed .. &quot;.&quot; else Accessed = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Accessed .. Via .. SubscriptionRequired
    local tcommon = Title .. TransTitle .. Type .. Format .. Edition .. Language .. Periodical .. Series .. Volume .. Issue .. Page .. Pages
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. TransChapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. TransChapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. TransChapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.wikitext.tag(frame, {name=&quot;references&quot;,contents=contents,params={group=group}})
    return z.wikitext.tag(frame, {name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}})
end

return z</text>
      <sha1>7cq01ttjny4hi7v65czjxnr1gclo0ar</sha1>
    </revision>
    <revision>
      <id>4403</id>
      <parentid>4402</parentid>
      <timestamp>2012-08-29T16:03:42Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Fixed emitted punctuation.</comment>
      <origin>4403</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="30229" sha1="aruek7lcgex9zef0tbvia12rks356mn" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local text = externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    return text
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = string.sub(id,string.length(id),1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        a[1] = extractauthor(args, i)
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        e[1] = extracteditor(args, i)
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local TransTitle = args.trans_title
    local Chapter = args.chapter or args.article or args.entry
    local TransChapter = args.trans_chapter
    local Type = args.type
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local Accessed = args.accessdate
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;    
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( Chapter ~= nil ) then 
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    elseif ( &quot;y&quot; == args.nopp ) then
        Page = &quot; &quot; .. Page
    else
        Page = &quot; p.&quot; .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    elseif ( &quot;y&quot; == args.nopp ) then
        Pages = &quot; &quot; .. Pages
    else
        Pages = &quot; pp.&quot; .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot; else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TransTitle ~= nil ) then TransTitle = &quot; (&quot; .. TransTitle .. &quot;).&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; (&quot; .. TransChapter .. &quot;).&quot; else TransChapter = &quot;&quot; end
    if ( Type ~= nil ) then Type = &quot; (&quot; .. Type .. &quot;).&quot; else Type = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( Accessed ~= nil ) then Accessed = &quot; Accessed on &quot; .. Accessed .. &quot;.&quot; else Accessed = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Accessed .. Via .. SubscriptionRequired
    local tcommon = Title .. TransTitle .. Type .. Format .. Edition .. Language .. Periodical .. Series .. Volume .. Issue .. Page .. Pages
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. TransChapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. TransChapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. TransChapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.wikitext.tag(frame, {name=&quot;references&quot;,contents=contents,params={group=group}})
    return z.wikitext.tag(frame, {name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}})
end

return z</text>
      <sha1>aruek7lcgex9zef0tbvia12rks356mn</sha1>
    </revision>
    <revision>
      <id>4404</id>
      <parentid>4403</parentid>
      <timestamp>2012-08-30T14:05:50Z</timestamp>
      <contributor>
        <username>Phil Boswell</username>
        <id>805</id>
      </contributor>
      <comment>commenting out lines which seem to have strayed from another function</comment>
      <origin>4404</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="30268" sha1="04jfjzchzrgm4aqt4n6i10tvgec8pgz" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local text = externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
--[=[ this applies to DOI not ASIN
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        text = text .. &quot;[[Category:Pages with DOI errors]]&quot;
    end ]=]
    return text
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = string.sub(id,string.length(id),1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        a[1] = extractauthor(args, i)
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        e[1] = extracteditor(args, i)
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local TransTitle = args.trans_title
    local Chapter = args.chapter or args.article or args.entry
    local TransChapter = args.trans_chapter
    local Type = args.type
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local Accessed = args.accessdate
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;    
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( Chapter ~= nil ) then 
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    elseif ( &quot;y&quot; == args.nopp ) then
        Page = &quot; &quot; .. Page
    else
        Page = &quot; p.&quot; .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    elseif ( &quot;y&quot; == args.nopp ) then
        Pages = &quot; &quot; .. Pages
    else
        Pages = &quot; pp.&quot; .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot; else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TransTitle ~= nil ) then TransTitle = &quot; (&quot; .. TransTitle .. &quot;).&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; (&quot; .. TransChapter .. &quot;).&quot; else TransChapter = &quot;&quot; end
    if ( Type ~= nil ) then Type = &quot; (&quot; .. Type .. &quot;).&quot; else Type = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( Accessed ~= nil ) then Accessed = &quot; Accessed on &quot; .. Accessed .. &quot;.&quot; else Accessed = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Accessed .. Via .. SubscriptionRequired
    local tcommon = Title .. TransTitle .. Type .. Format .. Edition .. Language .. Periodical .. Series .. Volume .. Issue .. Page .. Pages
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. TransChapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. TransChapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. TransChapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.wikitext.tag(frame, {name=&quot;references&quot;,contents=contents,params={group=group}})
    return z.wikitext.tag(frame, {name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}})
end

return z</text>
      <sha1>04jfjzchzrgm4aqt4n6i10tvgec8pgz</sha1>
    </revision>
    <revision>
      <id>4405</id>
      <parentid>4404</parentid>
      <timestamp>2012-08-30T14:52:57Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Fixed substring calculations.</comment>
      <origin>4405</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="30074" sha1="kjosq7wer4f801slk9nbj2bwugeltsa" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function listpeople(config, people)
    local text = &quot;&quot;
    local sep = config.AuthorSep or &quot;&amp;#59;&quot;
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            if (person.first ~= nil) then one = one .. &quot;, &quot; .. person.first end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            text = text .. one
            if ( people[i + 1] ~= nil ) then text = text .. sep .. &quot; &quot; end
        end
    end
    return text
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    -- 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 Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        a[1] = extractauthor(args, i)
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        e[1] = extracteditor(args, i)
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local TransTitle = args.trans_title
    local Chapter = args.chapter or args.article or args.entry
    local TransChapter = args.trans_chapter
    local Type = args.type
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local Accessed = args.accessdate
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;    
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then Authors = listpeople(config, a) end
    if ( Editors == nil ) then Editors = listpeople(config, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( Chapter ~= nil ) then 
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    elseif ( &quot;y&quot; == args.nopp ) then
        Page = &quot; &quot; .. Page
    else
        Page = &quot; p.&quot; .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    elseif ( &quot;y&quot; == args.nopp ) then
        Pages = &quot; &quot; .. Pages
    else
        Pages = &quot; pp.&quot; .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot; else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TransTitle ~= nil ) then TransTitle = &quot; (&quot; .. TransTitle .. &quot;).&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; (&quot; .. TransChapter .. &quot;).&quot; else TransChapter = &quot;&quot; end
    if ( Type ~= nil ) then Type = &quot; (&quot; .. Type .. &quot;).&quot; else Type = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( Accessed ~= nil ) then Accessed = &quot; Accessed on &quot; .. Accessed .. &quot;.&quot; else Accessed = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Accessed .. Via .. SubscriptionRequired
    local tcommon = Title .. TransTitle .. Type .. Format .. Edition .. Language .. Periodical .. Series .. Volume .. Issue .. Page .. Pages
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. TransChapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. TransChapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. TransChapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.wikitext.tag(frame, {name=&quot;references&quot;,contents=contents,params={group=group}})
    return z.wikitext.tag(frame, {name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}})
end

return z</text>
      <sha1>kjosq7wer4f801slk9nbj2bwugeltsa</sha1>
    </revision>
    <revision>
      <id>4406</id>
      <parentid>4405</parentid>
      <timestamp>2012-08-30T17:50:07Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added switch from talk page.</comment>
      <origin>4406</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="30628" sha1="lyx0pj7q6lfa0iuhcifhwjngti4d0yg" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1) .. &quot;.&quot;)
    end
    return table.concat(initials, &quot; &quot;)
end

function listpeople(sep, format, mask, people)
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            local first = person.first
            if (first ~= nil) then 
                if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                one = one .. &quot;, &quot; .. first 
            end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
        end
    end
    return table.concat(text, sep .. &quot; &quot;)
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local AuthorSep = config.AuthorSep or &quot;&amp;#59;&quot;

    -- 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[&quot;author-mask&quot;]
    local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        a[1] = extractauthor(args, i)
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        e[1] = extracteditor(args, i)
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local TransTitle = args.trans_title
    local Chapter = args.chapter or args.article or args.entry
    local TransChapter = args.trans_chapter
    local Type = args.type
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local Accessed = args.accessdate
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;    
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then Authors = listpeople(AuthorSep, AuthorFormat, AuthorMask, a) end
    if ( Editors == nil ) then Editors = listpeople(AuthorSep, EditorFormat, EditorMask, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( Chapter ~= nil ) then 
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    elseif ( &quot;y&quot; == args.nopp ) then
        Page = &quot; &quot; .. Page
    else
        Page = &quot; p.&quot; .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    elseif ( &quot;y&quot; == args.nopp ) then
        Pages = &quot; &quot; .. Pages
    else
        Pages = &quot; pp.&quot; .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot; else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TransTitle ~= nil ) then TransTitle = &quot; (&quot; .. TransTitle .. &quot;).&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; (&quot; .. TransChapter .. &quot;).&quot; else TransChapter = &quot;&quot; end
    if ( Type ~= nil ) then Type = &quot; (&quot; .. Type .. &quot;).&quot; else Type = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( Accessed ~= nil ) then Accessed = &quot; Accessed on &quot; .. Accessed .. &quot;.&quot; else Accessed = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Accessed .. Via .. SubscriptionRequired
    local tcommon = Title .. TransTitle .. Type .. Format .. Edition .. Language .. Periodical .. Series .. Volume .. Issue .. Page .. Pages
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. TransChapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. TransChapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. TransChapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.wikitext.tag(frame, {name=&quot;references&quot;,contents=contents,params={group=group}})
    return z.wikitext.tag(frame, {name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}})
end

return z</text>
      <sha1>lyx0pj7q6lfa0iuhcifhwjngti4d0yg</sha1>
    </revision>
    <revision>
      <id>4407</id>
      <parentid>4406</parentid>
      <timestamp>2012-08-30T17:53:37Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added missing table insertion.</comment>
      <origin>4407</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="30664" sha1="5f9p9yrb9libekb4a15wvp5jins8qc4" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1) .. &quot;.&quot;)
    end
    return table.concat(initials, &quot; &quot;)
end

function listpeople(sep, format, mask, people)
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            local first = person.first
            if (first ~= nil) then 
                if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                one = one .. &quot;, &quot; .. first 
            end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            table.insert(text, one)
        end
    end
    return table.concat(text, sep .. &quot; &quot;)
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local AuthorSep = config.AuthorSep or &quot;&amp;#59;&quot;

    -- 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[&quot;author-mask&quot;]
    local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    if ( a[1] == nil ) then
        local i = &quot;&quot;
        a[1] = extractauthor(args, i)
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    if ( e[1] == nil ) then
        local i = &quot;&quot;
        e[1] = extracteditor(args, i)
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local TransTitle = args.trans_title
    local Chapter = args.chapter or args.article or args.entry
    local TransChapter = args.trans_chapter
    local Type = args.type
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local Accessed = args.accessdate
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;    
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then Authors = listpeople(AuthorSep, AuthorFormat, AuthorMask, a) end
    if ( Editors == nil ) then Editors = listpeople(AuthorSep, EditorFormat, EditorMask, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( Chapter ~= nil ) then 
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    elseif ( &quot;y&quot; == args.nopp ) then
        Page = &quot; &quot; .. Page
    else
        Page = &quot; p.&quot; .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    elseif ( &quot;y&quot; == args.nopp ) then
        Pages = &quot; &quot; .. Pages
    else
        Pages = &quot; pp.&quot; .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot; else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TransTitle ~= nil ) then TransTitle = &quot; (&quot; .. TransTitle .. &quot;).&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; (&quot; .. TransChapter .. &quot;).&quot; else TransChapter = &quot;&quot; end
    if ( Type ~= nil ) then Type = &quot; (&quot; .. Type .. &quot;).&quot; else Type = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( Accessed ~= nil ) then Accessed = &quot; Accessed on &quot; .. Accessed .. &quot;.&quot; else Accessed = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Accessed .. Via .. SubscriptionRequired
    local tcommon = Title .. TransTitle .. Type .. Format .. Edition .. Language .. Periodical .. Series .. Volume .. Issue .. Page .. Pages
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. TransChapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. TransChapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. TransChapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.wikitext.tag(frame, {name=&quot;references&quot;,contents=contents,params={group=group}})
    return z.wikitext.tag(frame, {name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}})
end

return z</text>
      <sha1>5f9p9yrb9libekb4a15wvp5jins8qc4</sha1>
    </revision>
    <revision>
      <id>4408</id>
      <parentid>4407</parentid>
      <timestamp>2012-08-31T10:07:51Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Fixed the case where &quot;last&quot;/&quot;first&quot; and &quot;last2&quot;/&quot;first2&quot; are mixed.</comment>
      <origin>4408</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="31398" sha1="hc8ywbwzpmcrauc5tzcmnwr3n34wx39" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1) .. &quot;.&quot;)
    end
    return table.concat(initials, &quot; &quot;)
end

function listpeople(sep, format, mask, people)
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            local first = person.first
            if (first ~= nil) then 
                if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                one = one .. &quot;, &quot; .. first 
            end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            table.insert(text, one)
        end
    end
    return table.concat(text, sep .. &quot; &quot;)
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local AuthorSep = config.AuthorSep or &quot;&amp;#59;&quot;
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- 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[&quot;author-mask&quot;]
    local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local TransTitle = args.trans_title
    local Chapter = args.chapter or args.article or args.entry
    local TransChapter = args.trans_chapter
    local Type = args.type
    local URL = args.archiveurl or args.url
    local ChapterURL = args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local Accessed = args.accessdate
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;    
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then Authors = listpeople(AuthorSep, AuthorFormat, AuthorMask, a) end
    if ( Editors == nil ) then Editors = listpeople(AuthorSep, EditorFormat, EditorMask, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( Chapter ~= nil ) then 
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    elseif ( &quot;y&quot; == args.nopp ) then
        Page = &quot; &quot; .. Page
    else
        Page = &quot; p.&quot; .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    elseif ( &quot;y&quot; == args.nopp ) then
        Pages = &quot; &quot; .. Pages
    else
        Pages = &quot; pp.&quot; .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot; else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TransTitle ~= nil ) then TransTitle = &quot; (&quot; .. TransTitle .. &quot;).&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; (&quot; .. TransChapter .. &quot;).&quot; else TransChapter = &quot;&quot; end
    if ( Type ~= nil ) then Type = &quot; (&quot; .. Type .. &quot;).&quot; else Type = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( Accessed ~= nil ) then Accessed = &quot; Accessed on &quot; .. Accessed .. &quot;.&quot; else Accessed = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Accessed .. Via .. SubscriptionRequired
    local tcommon = Title .. TransTitle .. Type .. Format .. Edition .. Language .. Periodical .. Series .. Volume .. Issue .. Page .. Pages
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. TransChapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. TransChapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. TransChapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.wikitext.tag(frame, {name=&quot;references&quot;,contents=contents,params={group=group}})
    return z.wikitext.tag(frame, {name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}})
end

return z</text>
      <sha1>hc8ywbwzpmcrauc5tzcmnwr3n34wx39</sha1>
    </revision>
    <revision>
      <id>4409</id>
      <parentid>4408</parentid>
      <timestamp>2012-08-31T10:09:57Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added some alternative parameter names.</comment>
      <origin>4409</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="31498" sha1="p6osp19auxdkvhia1m9fo7dmuwpit3r" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1) .. &quot;.&quot;)
    end
    return table.concat(initials, &quot; &quot;)
end

function listpeople(sep, format, mask, people)
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            local first = person.first
            if (first ~= nil) then 
                if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                one = one .. &quot;, &quot; .. first 
            end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            table.insert(text, one)
        end
    end
    return table.concat(text, sep .. &quot; &quot;)
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local AuthorSep = config.AuthorSep or &quot;&amp;#59;&quot;
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- 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[&quot;author-mask&quot;]
    local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local TransTitle = args.trans_title
    local Chapter = args.chapter or args.article or args.entry
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local Type = args.type
    local URL = args[&quot;archive-url&quot;] or args.archiveurl or args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local Accessed = args.accessdate
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;    
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then Authors = listpeople(AuthorSep, AuthorFormat, AuthorMask, a) end
    if ( Editors == nil ) then Editors = listpeople(AuthorSep, EditorFormat, EditorMask, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( Chapter ~= nil ) then 
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    elseif ( &quot;y&quot; == args.nopp ) then
        Page = &quot; &quot; .. Page
    else
        Page = &quot; p.&quot; .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    elseif ( &quot;y&quot; == args.nopp ) then
        Pages = &quot; &quot; .. Pages
    else
        Pages = &quot; pp.&quot; .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot; else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TransTitle ~= nil ) then TransTitle = &quot; (&quot; .. TransTitle .. &quot;).&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; (&quot; .. TransChapter .. &quot;).&quot; else TransChapter = &quot;&quot; end
    if ( Type ~= nil ) then Type = &quot; (&quot; .. Type .. &quot;).&quot; else Type = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( Accessed ~= nil ) then Accessed = &quot; Accessed on &quot; .. Accessed .. &quot;.&quot; else Accessed = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Accessed .. Via .. SubscriptionRequired
    local tcommon = Title .. TransTitle .. Type .. Format .. Edition .. Language .. Periodical .. Series .. Volume .. Issue .. Page .. Pages
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. TransChapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. TransChapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. TransChapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.wikitext.tag(frame, {name=&quot;references&quot;,contents=contents,params={group=group}})
    return z.wikitext.tag(frame, {name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}})
end

return z</text>
      <sha1>p6osp19auxdkvhia1m9fo7dmuwpit3r</sha1>
    </revision>
    <revision>
      <id>4410</id>
      <parentid>4409</parentid>
      <timestamp>2012-08-31T13:22:19Z</timestamp>
      <contributor>
        <username>Phil Boswell</username>
        <id>805</id>
      </contributor>
      <comment>fix the vancouver-format helper function to strip down the initials even further</comment>
      <origin>4410</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="31598" sha1="nhtd5qwr7sf0fb7xev79dlm9z0tmk6f" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1))-- .. &quot;.&quot;) -- vancouver format does not include full stops
    end
    return table.concat(initials, &quot;&quot;)--, &quot; &quot;)--vancouver format does not include spaces
end

function listpeople(sep, format, mask, people)
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            local first = person.first
            if (first ~= nil) then 
                if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                one = one .. &quot;, &quot; .. first 
            end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            table.insert(text, one)
        end
    end
    return table.concat(text, sep .. &quot; &quot;)
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local AuthorSep = config.AuthorSep or &quot;&amp;#59;&quot;
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- 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[&quot;author-mask&quot;]
    local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local TransTitle = args.trans_title
    local Chapter = args.chapter or args.article or args.entry
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local Type = args.type
    local URL = args[&quot;archive-url&quot;] or args.archiveurl or args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local Accessed = args.accessdate
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;    
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then Authors = listpeople(AuthorSep, AuthorFormat, AuthorMask, a) end
    if ( Editors == nil ) then Editors = listpeople(AuthorSep, EditorFormat, EditorMask, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            if ( args.month ~= nil ) then 
                Date = args.month .. &quot; &quot; .. Date 
                if ( args.day ~= nil ) then Date = args.day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( Chapter ~= nil ) then 
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    elseif ( &quot;y&quot; == args.nopp ) then
        Page = &quot; &quot; .. Page
    else
        Page = &quot; p.&quot; .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    elseif ( &quot;y&quot; == args.nopp ) then
        Pages = &quot; &quot; .. Pages
    else
        Pages = &quot; pp.&quot; .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot; else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TransTitle ~= nil ) then TransTitle = &quot; (&quot; .. TransTitle .. &quot;).&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; (&quot; .. TransChapter .. &quot;).&quot; else TransChapter = &quot;&quot; end
    if ( Type ~= nil ) then Type = &quot; (&quot; .. Type .. &quot;).&quot; else Type = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( Accessed ~= nil ) then Accessed = &quot; Accessed on &quot; .. Accessed .. &quot;.&quot; else Accessed = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Accessed .. Via .. SubscriptionRequired
    local tcommon = Title .. TransTitle .. Type .. Format .. Edition .. Language .. Periodical .. Series .. Volume .. Issue .. Page .. Pages
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. TransChapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. TransChapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. TransChapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.wikitext.tag(frame, {name=&quot;references&quot;,contents=contents,params={group=group}})
    return z.wikitext.tag(frame, {name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}})
end

return z</text>
      <sha1>nhtd5qwr7sf0fb7xev79dlm9z0tmk6f</sha1>
    </revision>
    <revision>
      <id>4411</id>
      <parentid>4410</parentid>
      <timestamp>2012-08-31T19:18:18Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Corrected processing of translated chapter and title.  Added configuration option for page(s) prefix.</comment>
      <origin>4411</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="31705" sha1="oqo6mq3ye23woqtljfua8xil1aria6l" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1))-- .. &quot;.&quot;) -- vancouver format does not include full stops
    end
    return table.concat(initials, &quot;&quot;)--, &quot; &quot;)--vancouver format does not include spaces
end

function listpeople(sep, format, mask, people)
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            local first = person.first
            if (first ~= nil) then 
                if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                one = one .. &quot;, &quot; .. first 
            end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            table.insert(text, one)
        end
    end
    return table.concat(text, sep .. &quot; &quot;)
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local AuthorSep = config.AuthorSep or &quot;&amp;#59;&quot;
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( &quot;y&quot; == args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- 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[&quot;author-mask&quot;]
    local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local TransTitle = args.trans_title
    local Chapter = args.chapter or args.article or args.entry
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local Type = args.type
    local URL = args[&quot;archive-url&quot;] or args.archiveurl or args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local Accessed = args.accessdate
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then Authors = listpeople(AuthorSep, AuthorFormat, AuthorMask, a) end
    if ( Editors == nil ) then Editors = listpeople(AuthorSep, EditorFormat, EditorMask, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then 
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot; else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( Type ~= nil ) then Type = &quot; (&quot; .. Type .. &quot;).&quot; else Type = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( Accessed ~= nil ) then Accessed = &quot; Accessed on &quot; .. Accessed .. &quot;.&quot; else Accessed = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Accessed .. Via .. SubscriptionRequired
    local tcommon = Title .. Type .. Format .. Edition .. Language .. Periodical .. Series .. Volume .. Issue .. Page .. Pages
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.wikitext.tag(frame, {name=&quot;references&quot;,contents=contents,params={group=group}})
    return z.wikitext.tag(frame, {name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}})
end

return z</text>
      <sha1>oqo6mq3ye23woqtljfua8xil1aria6l</sha1>
    </revision>
    <revision>
      <id>4412</id>
      <parentid>4411</parentid>
      <timestamp>2012-08-31T19:24:19Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Enabled a parameter.</comment>
      <origin>4412</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="31784" sha1="opxcoid4gg94bx25gkhiqhrl1uc7pqs" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1))-- .. &quot;.&quot;) -- vancouver format does not include full stops
    end
    return table.concat(initials, &quot;&quot;)--, &quot; &quot;)--vancouver format does not include spaces
end

function listpeople(sep, format, mask, people)
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            local first = person.first
            if (first ~= nil) then 
                if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                one = one .. &quot;, &quot; .. first 
            end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            table.insert(text, one)
        end
    end
    return table.concat(text, sep .. &quot; &quot;)
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local AuthorSep = config.AuthorSep or &quot;&amp;#59;&quot;
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( &quot;y&quot; == args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- 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[&quot;author-mask&quot;]
    local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local TransTitle = args.trans_title
    local Chapter = args.chapter or args.article or args.entry
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local Type = args.type
    local URL = args[&quot;archive-url&quot;] or args.archiveurl or args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local Accessed = args.accessdate
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL  

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then Authors = listpeople(AuthorSep, AuthorFormat, AuthorMask, a) end
    if ( Editors == nil ) then Editors = listpeople(AuthorSep, EditorFormat, EditorMask, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then 
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( Type ~= nil ) then Type = &quot; (&quot; .. Type .. &quot;).&quot; else Type = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( Accessed ~= nil ) then Accessed = &quot; Accessed on &quot; .. Accessed .. &quot;.&quot; else Accessed = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Accessed .. Via .. SubscriptionRequired
    local tcommon = Title .. Type .. Format .. Edition .. Language .. Periodical .. Series .. Volume .. Issue .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.wikitext.tag(frame, {name=&quot;references&quot;,contents=contents,params={group=group}})
    return z.wikitext.tag(frame, {name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}})
end

return z</text>
      <sha1>opxcoid4gg94bx25gkhiqhrl1uc7pqs</sha1>
    </revision>
    <revision>
      <id>4413</id>
      <parentid>4412</parentid>
      <timestamp>2012-08-31T19:41:49Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added processing of more parameters.</comment>
      <origin>4413</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="32638" sha1="8cnmb9xfhp92iuhy8ghcgnhoci0fqja" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(frame, content)
    return content
end

function onlyinprint(frame, content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(frame, args.label .. sep .. args.id)
    local t1 = hideinprint(frame, &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(frame, id)
    local t1 = hideinprint(frame, &quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1))-- .. &quot;.&quot;) -- vancouver format does not include full stops
    end
    return table.concat(initials, &quot;&quot;)--, &quot; &quot;)--vancouver format does not include spaces
end

function listpeople(sep, format, mask, people)
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local one = person.last
            local first = person.first
            if (first ~= nil) then 
                if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                one = one .. &quot;, &quot; .. first 
            end
            if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            table.insert(text, one)
        end
    end
    return table.concat(text, sep .. &quot; &quot;)
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local AuthorSep = config.AuthorSep or &quot;&amp;#59;&quot;
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( &quot;y&quot; == args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- 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[&quot;author-mask&quot;]
    local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local TransTitle = args.trans_title
    local Chapter = args.chapter or args.article or args.entry
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local Type = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then Authors = listpeople(AuthorSep, AuthorFormat, AuthorMask, a) end
    if ( Editors == nil ) then Editors = listpeople(AuthorSep, EditorFormat, EditorMask, e) end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL and &quot;no&quot; == DeadURL ) then
        local temp = URL
        URL = ArchiveURL
        ArchiveURL = temp
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then 
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( Type ~= nil ) then Type = &quot; (&quot; .. Type .. &quot;).&quot; else Type = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Accessed on &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; else Quote = &quot;&quot; end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; (&quot; .. ArchiveDate .. &quot;)&quot; else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot;[&quot; .. ArchiveURL .. &quot;Archived] from the original.&quot; .. ArchiveDate
        else
            Archived = &quot;Archived from [&quot; .. ArchiveURL .. &quot; the original].&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. AccessDate .. Archived .. Via .. SubscriptionRequired .. Quote
    local tcommon = Title .. Type .. Format .. Edition .. Language .. Periodical .. Series .. Volume .. Issue .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = z.wikitext.tag(frame, {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.wikitext.tag(frame, {name=&quot;references&quot;,contents=contents,params={group=group}})
    return z.wikitext.tag(frame, {name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.tag(frame, {name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}})
end

return z</text>
      <sha1>8cnmb9xfhp92iuhy8ghcgnhoci0fqja</sha1>
    </revision>
    <revision>
      <id>4414</id>
      <parentid>4413</parentid>
      <timestamp>2012-08-31T21:29:20Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added processing of more parameters.</comment>
      <origin>4414</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="34973" sha1="p2xrtl1uxozbqkn7ec53ipdt3f3cfh7" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    return table.concat(text, sep)
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( &quot;y&quot; == args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local TransTitle = args.trans_title
    local Chapter = args.chapter or args.article or args.entry
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local Type = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL and &quot;no&quot; == DeadURL ) then
        local temp = URL
        URL = ArchiveURL
        ArchiveURL = temp
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then 
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( Type ~= nil ) then Type = &quot; (&quot; .. Type .. &quot;).&quot; else Type = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Accessed on &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.wikitext.HTMLTag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; (&quot; .. ArchiveDate .. &quot;)&quot; else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot;[&quot; .. ArchiveURL .. &quot;Archived] from the original.&quot; .. ArchiveDate
        else
            Archived = &quot;Archived from [&quot; .. ArchiveURL .. &quot; the original].&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySumary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = LaySummary .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. AccessDate .. Archived .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. Type .. Format .. Edition .. Language .. Periodical .. Series .. Volume .. Issue .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.HTMLTag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = z.wikitext.HTMLTag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.HTMLTag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.wikitext.tag(frame, {name=&quot;references&quot;,contents=contents,params={group=group}})
    return z.wikitext.HTMLTag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.HTMLTag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}})
end

return z</text>
      <sha1>p2xrtl1uxozbqkn7ec53ipdt3f3cfh7</sha1>
    </revision>
    <revision>
      <id>4415</id>
      <parentid>4414</parentid>
      <timestamp>2012-08-31T21:37:12Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added generation of name to lay summary hyperlink.</comment>
      <origin>4415</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="34999" sha1="fcwku6yp4v0cq8ynvbslxlvmi3240xt" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    return table.concat(text, sep)
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( &quot;y&quot; == args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local TransTitle = args.trans_title
    local Chapter = args.chapter or args.article or args.entry
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local Type = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL and &quot;no&quot; == DeadURL ) then
        local temp = URL
        URL = ArchiveURL
        ArchiveURL = temp
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then 
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( Type ~= nil ) then Type = &quot; (&quot; .. Type .. &quot;).&quot; else Type = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Accessed on &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.wikitext.HTMLTag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; (&quot; .. ArchiveDate .. &quot;)&quot; else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot;[&quot; .. ArchiveURL .. &quot;Archived] from the original.&quot; .. ArchiveDate
        else
            Archived = &quot;Archived from [&quot; .. ArchiveURL .. &quot; the original].&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySumary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot;[&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. AccessDate .. Archived .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. Type .. Format .. Edition .. Language .. Periodical .. Series .. Volume .. Issue .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.HTMLTag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = z.wikitext.HTMLTag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.HTMLTag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.wikitext.tag(frame, {name=&quot;references&quot;,contents=contents,params={group=group}})
    return z.wikitext.HTMLTag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.HTMLTag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}})
end

return z</text>
      <sha1>fcwku6yp4v0cq8ynvbslxlvmi3240xt</sha1>
    </revision>
    <revision>
      <id>4416</id>
      <parentid>4415</parentid>
      <timestamp>2012-08-31T21:42:20Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Fixed my typing error.</comment>
      <origin>4416</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="35000" sha1="6ne764e8w1zp24lfhmw4mabksxkwwno" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    return table.concat(text, sep)
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( &quot;y&quot; == args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local TransTitle = args.trans_title
    local Chapter = args.chapter or args.article or args.entry
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local Type = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL and &quot;no&quot; == DeadURL ) then
        local temp = URL
        URL = ArchiveURL
        ArchiveURL = temp
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then 
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( Type ~= nil ) then Type = &quot; (&quot; .. Type .. &quot;).&quot; else Type = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Accessed on &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.wikitext.HTMLTag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; (&quot; .. ArchiveDate .. &quot;)&quot; else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot;[&quot; .. ArchiveURL .. &quot;Archived] from the original.&quot; .. ArchiveDate
        else
            Archived = &quot;Archived from [&quot; .. ArchiveURL .. &quot; the original].&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot;[&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. AccessDate .. Archived .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. Type .. Format .. Edition .. Language .. Periodical .. Series .. Volume .. Issue .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.HTMLTag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = z.wikitext.HTMLTag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.HTMLTag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.wikitext.tag(frame, {name=&quot;references&quot;,contents=contents,params={group=group}})
    return z.wikitext.HTMLTag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.HTMLTag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}})
end

return z</text>
      <sha1>6ne764e8w1zp24lfhmw4mabksxkwwno</sha1>
    </revision>
    <revision>
      <id>4417</id>
      <parentid>4416</parentid>
      <timestamp>2012-08-31T21:43:02Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added whitespace to generated output.</comment>
      <origin>4417</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="35001" sha1="r2eibya5hvaabzuitkmf0780pf3q5yi" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    return table.concat(text, sep)
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( &quot;y&quot; == args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local TransTitle = args.trans_title
    local Chapter = args.chapter or args.article or args.entry
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local Type = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL and &quot;no&quot; == DeadURL ) then
        local temp = URL
        URL = ArchiveURL
        ArchiveURL = temp
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then 
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( Type ~= nil ) then Type = &quot; (&quot; .. Type .. &quot;).&quot; else Type = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Accessed on &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.wikitext.HTMLTag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; (&quot; .. ArchiveDate .. &quot;)&quot; else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot;[&quot; .. ArchiveURL .. &quot;Archived] from the original.&quot; .. ArchiveDate
        else
            Archived = &quot;Archived from [&quot; .. ArchiveURL .. &quot; the original].&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. AccessDate .. Archived .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. Type .. Format .. Edition .. Language .. Periodical .. Series .. Volume .. Issue .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.HTMLTag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = z.wikitext.HTMLTag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.HTMLTag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.wikitext.tag(frame, {name=&quot;references&quot;,contents=contents,params={group=group}})
    return z.wikitext.HTMLTag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.HTMLTag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}})
end

return z</text>
      <sha1>r2eibya5hvaabzuitkmf0780pf3q5yi</sha1>
    </revision>
    <revision>
      <id>4418</id>
      <parentid>4417</parentid>
      <timestamp>2012-09-01T07:39:30Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added processing of more parameters.</comment>
      <origin>4418</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="35897" sha1="j2odd4kg0z9a43u4krr3t3m3ro8o7sp" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.wikitext.tag(frame, {name=&quot;nowiki&quot;,contents=content,params={}})
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    return table.concat(text, sep)
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( &quot;y&quot; == args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNore = args.department
    local Chapter = args.chapter or args.article or args.entry
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        TransChapter = TransTitle
        Title= BookTitle
        TransTitle = nil
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL and &quot;no&quot; == DeadURL ) then
        local temp = URL
        URL = ArchiveURL
        ArchiveURL = temp
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then 
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Accessed on &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.wikitext.HTMLTag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; (&quot; .. ArchiveDate .. &quot;)&quot; else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot;[&quot; .. ArchiveURL .. &quot;Archived] from the original.&quot; .. ArchiveDate
        else
            Archived = &quot;Archived from [&quot; .. ArchiveURL .. &quot; the original].&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. AccessDate .. Archived .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = z.wikitext.HTMLTag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = z.wikitext.HTMLTag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.wikitext.HTMLTag(frame, {name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.wikitext.tag(frame, {name=&quot;references&quot;,contents=contents,params={group=group}})
    return z.wikitext.HTMLTag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
--  return mw.text.tag{name = &quot;ref&quot;, contents = content, params = args}
    return z.wikitext.tag(frame, {name = &quot;ref&quot;, contents = content, params = args})
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.wikitext.HTMLTag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.wikitext.tag(frame, {name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}})
end

return z</text>
      <sha1>j2odd4kg0z9a43u4krr3t3m3ro8o7sp</sha1>
    </revision>
    <revision>
      <id>4419</id>
      <parentid>4418</parentid>
      <timestamp>2012-09-01T11:08:36Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Changed to use &quot;mw&quot; library.</comment>
      <origin>4419</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="35761" sha1="2pulanb4bfh3im6nusa5x2e0xnvfdke" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.wikitext.urlencode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    return table.concat(text, sep)
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( &quot;y&quot; == args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNore = args.department
    local Chapter = args.chapter or args.article or args.entry
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        TransChapter = TransTitle
        Title= BookTitle
        TransTitle = nil
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. z.wikitext.urlencode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. z.wikitext.urlencode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL and &quot;no&quot; == DeadURL ) then
        local temp = URL
        URL = ArchiveURL
        ArchiveURL = temp
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then 
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Accessed on &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; (&quot; .. ArchiveDate .. &quot;)&quot; else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot;[&quot; .. ArchiveURL .. &quot;Archived] from the original.&quot; .. ArchiveDate
        else
            Archived = &quot;Archived from [&quot; .. ArchiveURL .. &quot; the original].&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. AccessDate .. Archived .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.Tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z</text>
      <sha1>2pulanb4bfh3im6nusa5x2e0xnvfdke</sha1>
    </revision>
    <revision>
      <id>4420</id>
      <parentid>4419</parentid>
      <timestamp>2012-09-01T11:10:22Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Changed to use &quot;mw&quot; library.</comment>
      <origin>4420</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="35740" sha1="3uqo30lh98qae993sakn3s9h5uxzc63" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    return table.concat(text, sep)
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( &quot;y&quot; == args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNore = args.department
    local Chapter = args.chapter or args.article or args.entry
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        TransChapter = TransTitle
        Title= BookTitle
        TransTitle = nil
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL and &quot;no&quot; == DeadURL ) then
        local temp = URL
        URL = ArchiveURL
        ArchiveURL = temp
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then 
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Accessed on &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; (&quot; .. ArchiveDate .. &quot;)&quot; else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot;[&quot; .. ArchiveURL .. &quot;Archived] from the original.&quot; .. ArchiveDate
        else
            Archived = &quot;Archived from [&quot; .. ArchiveURL .. &quot; the original].&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. AccessDate .. Archived .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.Tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z</text>
      <sha1>3uqo30lh98qae993sakn3s9h5uxzc63</sha1>
    </revision>
    <revision>
      <id>4421</id>
      <parentid>4420</parentid>
      <timestamp>2012-09-01T11:20:20Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Fixed my typing error.</comment>
      <origin>4421</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="35740" sha1="5lx1noithagxdxw3nxlw91srrvnoyr8" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    return table.concat(text, sep)
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( &quot;y&quot; == args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNore = args.department
    local Chapter = args.chapter or args.article or args.entry
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        TransChapter = TransTitle
        Title= BookTitle
        TransTitle = nil
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL and &quot;no&quot; == DeadURL ) then
        local temp = URL
        URL = ArchiveURL
        ArchiveURL = temp
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then 
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Accessed on &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; (&quot; .. ArchiveDate .. &quot;)&quot; else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot;[&quot; .. ArchiveURL .. &quot;Archived] from the original.&quot; .. ArchiveDate
        else
            Archived = &quot;Archived from [&quot; .. ArchiveURL .. &quot; the original].&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. AccessDate .. Archived .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z</text>
      <sha1>5lx1noithagxdxw3nxlw91srrvnoyr8</sha1>
    </revision>
    <revision>
      <id>4422</id>
      <parentid>4421</parentid>
      <timestamp>2012-09-07T04:47:44Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added function for [[Template:note label]].</comment>
      <origin>4422</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="36834" sha1="17tlpc2vfwfw0pobd9v0hxg494qlk0n" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    return table.concat(text, sep)
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( &quot;y&quot; == args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNore = args.department
    local Chapter = args.chapter or args.article or args.entry
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        TransChapter = TransTitle
        Title= BookTitle
        TransTitle = nil
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL and &quot;no&quot; == DeadURL ) then
        local temp = URL
        URL = ArchiveURL
        ArchiveURL = temp
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then 
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterURL ~= nil ) then
            Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
        elseif ( URL ~= nil ) then 
            Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            URL = nil
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Accessed on &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; (&quot; .. ArchiveDate .. &quot;)&quot; else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot;[&quot; .. ArchiveURL .. &quot;Archived] from the original.&quot; .. ArchiveDate
        else
            Archived = &quot;Archived from [&quot; .. ArchiveURL .. &quot; the original].&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. AccessDate .. Archived .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z</text>
      <sha1>17tlpc2vfwfw0pobd9v0hxg494qlk0n</sha1>
    </revision>
    <revision>
      <id>4423</id>
      <parentid>4422</parentid>
      <timestamp>2012-09-07T18:59:07Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added processing of more parameters.</comment>
      <origin>4423</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="39521" sha1="l7xnxdr53jebmmw9zwreualfmftjkod" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    return table.concat(text, sep)
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( &quot;y&quot; == args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.Network
        local Station = args.Station
        local s = {}
        if Number ~= nil then table.insert(s, &quot;episode &quot; .. Number) Number = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL and &quot;no&quot; == DeadURL ) then
        local temp = URL
        URL = ArchiveURL
        ArchiveURL = temp
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Accessed on &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; (&quot; .. ArchiveDate .. &quot;)&quot; else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot;[&quot; .. ArchiveURL .. &quot;Archived] from the original.&quot; .. ArchiveDate
        else
            Archived = &quot;Archived from [&quot; .. ArchiveURL .. &quot; the original].&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. AccessDate .. Archived .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z</text>
      <sha1>l7xnxdr53jebmmw9zwreualfmftjkod</sha1>
    </revision>
    <revision>
      <id>4424</id>
      <parentid>4423</parentid>
      <timestamp>2012-09-07T19:07:24Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Corrected variable names.</comment>
      <origin>4424</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="39518" sha1="lo7la2vo01llocd19ygctcsuewzl8xj" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    return table.concat(text, sep)
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc or &quot;&quot;
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( &quot;y&quot; == args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL and &quot;no&quot; == DeadURL ) then
        local temp = URL
        URL = ArchiveURL
        ArchiveURL = temp
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Accessed on &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; (&quot; .. ArchiveDate .. &quot;)&quot; else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot;[&quot; .. ArchiveURL .. &quot;Archived] from the original.&quot; .. ArchiveDate
        else
            Archived = &quot;Archived from [&quot; .. ArchiveURL .. &quot; the original].&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. AccessDate .. Archived .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z</text>
      <sha1>lo7la2vo01llocd19ygctcsuewzl8xj</sha1>
    </revision>
    <revision>
      <id>4425</id>
      <parentid>4424</parentid>
      <timestamp>2012-09-10T22:07:25Z</timestamp>
      <contributor>
        <username>Uncle G</username>
        <id>804</id>
      </contributor>
      <comment>Added support for another parameter.</comment>
      <origin>4425</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="39629" sha1="qpx76j2canecc0z4ke43l2rdf5yilyd" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat ~= nil and nocal ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    return table.concat(text, sep)
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( &quot;y&quot; == args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL and &quot;no&quot; == DeadURL ) then
        local temp = URL
        URL = ArchiveURL
        ArchiveURL = temp
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Accessed on &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; (&quot; .. ArchiveDate .. &quot;)&quot; else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot;[&quot; .. ArchiveURL .. &quot;Archived] from the original.&quot; .. ArchiveDate
        else
            Archived = &quot;Archived from [&quot; .. ArchiveURL .. &quot; the original].&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. AccessDate .. Archived .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z</text>
      <sha1>qpx76j2canecc0z4ke43l2rdf5yilyd</sha1>
    </revision>
    <revision>
      <id>4426</id>
      <parentid>4425</parentid>
      <timestamp>2012-09-12T15:10:55Z</timestamp>
      <contributor>
        <username>Phil Boswell</username>
        <id>805</id>
      </contributor>
      <comment>fix error, short-circuit a comparison</comment>
      <origin>4426</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="39622" sha1="gxw03cexjsz8ibijwznatwh9zcm9mm2" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    return table.concat(text, sep)
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( &quot;y&quot; == args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL and &quot;no&quot; == DeadURL ) then
        local temp = URL
        URL = ArchiveURL
        ArchiveURL = temp
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Accessed on &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; (&quot; .. ArchiveDate .. &quot;)&quot; else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot;[&quot; .. ArchiveURL .. &quot;Archived] from the original.&quot; .. ArchiveDate
        else
            Archived = &quot;Archived from [&quot; .. ArchiveURL .. &quot; the original].&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. AccessDate .. Archived .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z</text>
      <sha1>gxw03cexjsz8ibijwznatwh9zcm9mm2</sha1>
    </revision>
    <revision>
      <id>4427</id>
      <parentid>4426</parentid>
      <timestamp>2012-10-03T21:09:11Z</timestamp>
      <contributor>
        <username>Phil Boswell</username>
        <id>805</id>
      </contributor>
      <comment>add option to format authors in Small Caps</comment>
      <origin>4427</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="39883" sha1="4ndjvy3x9i37zud6fwuerqsna835con" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( &quot;y&quot; == args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL and &quot;no&quot; == DeadURL ) then
        local temp = URL
        URL = ArchiveURL
        ArchiveURL = temp
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Accessed on &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; (&quot; .. ArchiveDate .. &quot;)&quot; else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot;[&quot; .. ArchiveURL .. &quot;Archived] from the original.&quot; .. ArchiveDate
        else
            Archived = &quot;Archived from [&quot; .. ArchiveURL .. &quot; the original].&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. AccessDate .. Archived .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z</text>
      <sha1>4ndjvy3x9i37zud6fwuerqsna835con</sha1>
    </revision>
    <revision>
      <id>4428</id>
      <parentid>4427</parentid>
      <timestamp>2012-10-11T10:39:00Z</timestamp>
      <contributor>
        <username>Phil Boswell</username>
        <id>805</id>
      </contributor>
      <comment>revert to older version of date-handling until we work out how to avoid those pesky dashes</comment>
      <origin>4428</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="40334" sha1="pr89ppn1t1bg8zsvfa0ezy8qdfou1oc" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( &quot;y&quot; == args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL and &quot;no&quot; == DeadURL ) then
        local temp = URL
        URL = ArchiveURL
        ArchiveURL = temp
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Accessed on &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; (&quot; .. ArchiveDate .. &quot;)&quot; else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot;[&quot; .. ArchiveURL .. &quot;Archived] from the original.&quot; .. ArchiveDate
        else
            Archived = &quot;Archived from [&quot; .. ArchiveURL .. &quot; the original].&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. AccessDate .. Archived .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z</text>
      <sha1>pr89ppn1t1bg8zsvfa0ezy8qdfou1oc</sha1>
    </revision>
    <revision>
      <id>4429</id>
      <parentid>4428</parentid>
      <timestamp>2012-10-17T12:36:07Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>for AccessDate, put &quot;Retrieved&quot; was &quot;Accessed on&quot;</comment>
      <origin>4429</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="40332" sha1="96cuy401gfhyc4raiogl89t30hlkwoi" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( &quot;y&quot; == args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL and &quot;no&quot; == DeadURL ) then
        local temp = URL
        URL = ArchiveURL
        ArchiveURL = temp
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = &quot; (&quot; .. Date .. &quot;)&quot; else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; (&quot; .. ArchiveDate .. &quot;)&quot; else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot;[&quot; .. ArchiveURL .. &quot;Archived] from the original.&quot; .. ArchiveDate
        else
            Archived = &quot;Archived from [&quot; .. ArchiveURL .. &quot; the original].&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. AccessDate .. Archived .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear 
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z</text>
      <sha1>96cuy401gfhyc4raiogl89t30hlkwoi</sha1>
    </revision>
    <revision>
      <id>4430</id>
      <parentid>4429</parentid>
      <timestamp>2012-10-17T13:01:31Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>added if &quot;end&quot;</comment>
      <origin>4430</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="40412" sha1="cq3h67m7donheb4knj9pk6fsoych5pf" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( &quot;y&quot; == args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL and &quot;no&quot; == DeadURL ) then
        local temp = URL
        URL = ArchiveURL
        ArchiveURL = temp
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; &quot; .. Title .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot; :&quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; (&quot; .. ArchiveDate .. &quot;)&quot; else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot;[&quot; .. ArchiveURL .. &quot;Archived] from the original.&quot; .. ArchiveDate
        else
            Archived = &quot;Archived from [&quot; .. ArchiveURL .. &quot; the original].&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. AccessDate .. Archived .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;).&quot;
        else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;).&quot;
        else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z</text>
      <sha1>cq3h67m7donheb4knj9pk6fsoych5pf</sha1>
    </revision>
    <revision>
      <id>4431</id>
      <parentid>4430</parentid>
      <timestamp>2012-10-17T13:14:45Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>quoted title when CitationClass == &quot;news&quot;; omitted one dot after Title</comment>
      <origin>4431</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="40519" sha1="qgodde2ijscg3eob8qodjvpf2hfmofc" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( &quot;y&quot; == args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL and &quot;no&quot; == DeadURL ) then
        local temp = URL
        URL = ArchiveURL
        ArchiveURL = temp
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; &quot; .. Title -- omit final .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; (&quot; .. ArchiveDate .. &quot;)&quot; else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot;[&quot; .. ArchiveURL .. &quot;Archived] from the original.&quot; .. ArchiveDate
        else
            Archived = &quot;Archived from [&quot; .. ArchiveURL .. &quot; the original].&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. AccessDate .. Archived .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;).&quot;
        else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;).&quot;
        else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z</text>
      <sha1>qgodde2ijscg3eob8qodjvpf2hfmofc</sha1>
    </revision>
    <revision>
      <id>4432</id>
      <parentid>4431</parentid>
      <timestamp>2012-10-17T13:23:20Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>checked config.CitationClass for name &quot;news&quot; &amp; set Periodical also for &quot;args.encyclopedia&quot;</comment>
      <origin>4432</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="40547" sha1="d7pd2dkutl8fes5fnc5bmbwf2u1fyot" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( &quot;y&quot; == args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL and &quot;no&quot; == DeadURL ) then
        local temp = URL
        URL = ArchiveURL
        ArchiveURL = temp
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; &quot; .. Title -- omit final .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; (&quot; .. ArchiveDate .. &quot;)&quot; else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot;[&quot; .. ArchiveURL .. &quot;Archived] from the original.&quot; .. ArchiveDate
        else
            Archived = &quot;Archived from [&quot; .. ArchiveURL .. &quot; the original].&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &quot; .. Periodical .. &quot;.&quot; else Periodical = &quot;&quot; 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. AccessDate .. Archived .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;).&quot;
        else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;).&quot;
        else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z</text>
      <sha1>d7pd2dkutl8fes5fnc5bmbwf2u1fyot</sha1>
    </revision>
    <revision>
      <id>4433</id>
      <parentid>4432</parentid>
      <timestamp>2012-10-17T13:37:12Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>checked config.CitationClass for name &quot;web&quot; &amp; set Periodical also for &quot;args.encyclopaedia&quot; &amp; italicized</comment>
      <origin>4433</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="40599" sha1="s8zvgifgz6ua7i0oe08ft2qemt5sw95" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( &quot;y&quot; == args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL and &quot;no&quot; == DeadURL ) then
        local temp = URL
        URL = ArchiveURL
        ArchiveURL = temp
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end    
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = &quot; &quot; .. Title -- omit final .. &quot;.&quot;
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; (&quot; .. ArchiveDate .. &quot;)&quot; else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot;[&quot; .. ArchiveURL .. &quot;Archived] from the original.&quot; .. ArchiveDate
        else
            Archived = &quot;Archived from [&quot; .. ArchiveURL .. &quot; the original].&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. AccessDate .. Archived .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;).&quot;
        else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;).&quot;
        else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z</text>
      <sha1>s8zvgifgz6ua7i0oe08ft2qemt5sw95</sha1>
    </revision>
    <revision>
      <id>4434</id>
      <parentid>4433</parentid>
      <timestamp>2012-10-17T14:00:15Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>changed to omit lead space on title unless Authors or Editors or Chapter.</comment>
      <origin>4434</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="40649" sha1="02bx5iedakvwndndygp7u5h2w1duzlz" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( &quot;y&quot; == args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL and &quot;no&quot; == DeadURL ) then
        local temp = URL
        URL = ArchiveURL
        ArchiveURL = temp
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if (nil ~= Authors or nil ~= Editors or &quot;&quot; ~= Chapter)
        then Title = &quot; &quot; .. Title end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; (&quot; .. ArchiveDate .. &quot;)&quot; else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot;[&quot; .. ArchiveURL .. &quot;Archived] from the original.&quot; .. ArchiveDate
        else
            Archived = &quot;Archived from [&quot; .. ArchiveURL .. &quot; the original].&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. AccessDate .. Archived .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;).&quot;
        else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;).&quot;
        else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z</text>
      <sha1>02bx5iedakvwndndygp7u5h2w1duzlz</sha1>
    </revision>
    <revision>
      <id>4435</id>
      <parentid>4434</parentid>
      <timestamp>2012-10-17T15:01:54Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>moved &quot; Archived&quot; (+space) to precede &quot;Retrieved&quot; date</comment>
      <origin>4435</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="40662" sha1="9xo1dx0750jxurxublazefft28z3nnu" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( &quot;y&quot; == args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL and &quot;no&quot; == DeadURL ) then
        local temp = URL
        URL = ArchiveURL
        ArchiveURL = temp
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if (nil ~= Authors or nil ~= Editors or &quot;&quot; ~= Chapter)
        then Title = &quot; &quot; .. Title end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. URL .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;).&quot;
        else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;).&quot;
        else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z</text>
      <sha1>9xo1dx0750jxurxublazefft28z3nnu</sha1>
    </revision>
    <revision>
      <id>4436</id>
      <parentid>4435</parentid>
      <timestamp>2012-10-17T15:11:35Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>used args.url as &quot;the original&quot;</comment>
      <origin>4436</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="40621" sha1="977gjdxt8fce2wc8eb276nddj5wsuvx" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( &quot;y&quot; == args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if (nil ~= Authors or nil ~= Editors or &quot;&quot; ~= Chapter)
        then Title = &quot; &quot; .. Title end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;).&quot;
        else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;).&quot;
        else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z</text>
      <sha1>977gjdxt8fce2wc8eb276nddj5wsuvx</sha1>
    </revision>
    <revision>
      <id>4437</id>
      <parentid>4436</parentid>
      <timestamp>2012-10-18T14:11:45Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>new &quot;local PP = args.pp&quot; to detect page-ranges</comment>
      <origin>4437</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="40756" sha1="05g22tosopn2fa4x1htdx4qhhl8iiqf" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( &quot;y&quot; == args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if (Authors ~= nil or Editors ~= nil or &quot;&quot; ~= Chapter)
        then Title = &quot; &quot; .. Title end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( PP ~= nil) then 
        Page = PP
        if (PP..&quot;00000&quot; &lt; 0) then Page = &quot;range &quot; .. PP end
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;).&quot;
        else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;).&quot;
        else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z</text>
      <sha1>05g22tosopn2fa4x1htdx4qhhl8iiqf</sha1>
    </revision>
    <revision>
      <id>4438</id>
      <parentid>4437</parentid>
      <timestamp>2012-10-18T14:21:20Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>testing integer page number</comment>
      <origin>4438</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="40793" sha1="1eeg4dzjmhl7w1ixr2spgx4u9aa9nr9" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( &quot;y&quot; == args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if (Authors ~= nil or Editors ~= nil or &quot;&quot; ~= Chapter)
        then Title = &quot; &quot; .. Title end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( PP ~= nil) then 
        Page = PP
        local int pnum = int(PP .. &quot;00000&quot;)
        if (pnum &lt; 0) then Page = &quot;range &quot; .. PP end
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;).&quot;
        else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;).&quot;
        else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z</text>
      <sha1>1eeg4dzjmhl7w1ixr2spgx4u9aa9nr9</sha1>
    </revision>
    <revision>
      <id>4439</id>
      <parentid>4438</parentid>
      <timestamp>2012-10-18T14:38:43Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>check data type as &quot;type(PP)&quot;</comment>
      <origin>4439</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="40930" sha1="m25qqga7a0gtfevq4huzbwce4nawne1" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( &quot;y&quot; == args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if (Authors ~= nil or Editors ~= nil or &quot;&quot; ~= Chapter)
        then Title = &quot; &quot; .. Title end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( PP ~= nil) then 
        local pnum
        if ( type(PP) == &quot;number&quot;) then
          Page = PP
          pnum = PP .. &quot;00000&quot;
          pnum = 0 + pnum
          if (pnum &lt; 0) then Page = &quot;range &quot; .. PP .. &quot;.&quot; end
        else Page = &quot;stuff &quot; .. PP .. &quot;.&quot;
        end
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;).&quot;
        else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;).&quot;
        else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z</text>
      <sha1>m25qqga7a0gtfevq4huzbwce4nawne1</sha1>
    </revision>
    <revision>
      <id>4440</id>
      <parentid>4439</parentid>
      <timestamp>2012-10-18T14:45:11Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>check &quot;type(0+PP)&quot;</comment>
      <origin>4440</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="40932" sha1="8850avkci99x7p4lhxoc28no1fkqyb8" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( &quot;y&quot; == args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if (Authors ~= nil or Editors ~= nil or &quot;&quot; ~= Chapter)
        then Title = &quot; &quot; .. Title end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( PP ~= nil) then 
        local pnum
        if ( type(0+PP) == &quot;number&quot;) then
          Page = PP
          pnum = PP .. &quot;00000&quot;
          pnum = 0 + pnum
          if (pnum &lt; 0) then Page = &quot;range &quot; .. PP .. &quot;.&quot; end
        else Page = &quot;stuff &quot; .. PP .. &quot;.&quot;
        end
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;).&quot;
        else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;).&quot;
        else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z</text>
      <sha1>8850avkci99x7p4lhxoc28no1fkqyb8</sha1>
    </revision>
    <revision>
      <id>4441</id>
      <parentid>4440</parentid>
      <timestamp>2012-10-18T21:53:06Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>try casting &quot;46-48&quot; by &quot;tonumber(PP)&quot;</comment>
      <origin>4441</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="40911" sha1="1dnrisypy50km5xbuct2xx7pl90i4vd" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( &quot;y&quot; == args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if (Authors ~= nil or Editors ~= nil or &quot;&quot; ~= Chapter)
        then Title = &quot; &quot; .. Title end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( PP ~= nil) then 
        local pnum
        if ( type(PP) == &quot;number&quot;) then
          Page = &quot;lone &quot; .. PP .. &quot;.&quot;
        elseif ( tonumber(PP) ~= nil) then
          Page = &quot;range &quot; .. PP .. &quot;.&quot;
        else Page = &quot;stuff &quot; .. PP .. &quot;.&quot;
        end
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot; :&quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;).&quot;
        else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;).&quot;
        else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z</text>
      <sha1>1dnrisypy50km5xbuct2xx7pl90i4vd</sha1>
    </revision>
    <revision>
      <id>4442</id>
      <parentid>4441</parentid>
      <timestamp>2012-10-18T23:10:30Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>suppress &quot;p.&quot; when nil ~= args.nopp; try detect lone number: if ( type(PP) == type(1) ) then...</comment>
      <origin>4442</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="40796" sha1="kmoi50hx70olnhf1eqd1w9nk6350c9c" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if (Authors ~= nil or Editors ~= nil or &quot;&quot; ~= Chapter)
        then Title = &quot; &quot; .. Title end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( PP ~= nil) then 
        if ( type(PP) == type(1) ) then
          Page = &quot;lone &quot; .. PP
        else Page = &quot;stuff &quot; .. PP
        end
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;).&quot;
        else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;).&quot;
        else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z</text>
      <sha1>kmoi50hx70olnhf1eqd1w9nk6350c9c</sha1>
    </revision>
    <revision>
      <id>4443</id>
      <parentid>4442</parentid>
      <timestamp>2012-10-18T23:16:08Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>try detect lone number: if ( tonumber(PP) ~= nil ) then...</comment>
      <origin>4443</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="40796" sha1="oieiroipn0l5ulfrqqum1ugusfgkkjt" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = &quot; &quot; .. Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if (Authors ~= nil or Editors ~= nil or &quot;&quot; ~= Chapter)
        then Title = &quot; &quot; .. Title end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( PP ~= nil) then 
        if ( tonumber(PP) ~= nil ) then
          Page = &quot;lone &quot; .. PP
        else Page = &quot;stuff &quot; .. PP
        end
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;).&quot;
        else Authors = Authors .. &quot;.&quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;).&quot;
        else Editors = Editors .. &quot;.&quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z</text>
      <sha1>oieiroipn0l5ulfrqqum1ugusfgkkjt</sha1>
    </revision>
    <revision>
      <id>4444</id>
      <parentid>4443</parentid>
      <timestamp>2012-10-18T23:22:44Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>removed lead-space from Chapter and put at end of Authors, Editors or Date</comment>
      <origin>4444</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="40692" sha1="lu3s7jpu0foolge38caffotl8ccbgml" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;.&quot;
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( PP ~= nil) then 
        if ( tonumber(PP) ~= nil ) then
          Page = &quot;lone &quot; .. PP
        else Page = &quot;stuff &quot; .. PP
        end
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;). &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;). &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z</text>
      <sha1>lu3s7jpu0foolge38caffotl8ccbgml</sha1>
    </revision>
    <revision>
      <id>4445</id>
      <parentid>4444</parentid>
      <timestamp>2012-10-18T23:31:58Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>put space after Chapter, &quot;.&quot; after Title</comment>
      <origin>4445</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="40756" sha1="eklhlbt4sy98ikiorbhmjt1lg4muo3s" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = Title .. &quot;.&quot; -- with end-dot
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( PP ~= nil) then 
        if ( tonumber(PP) ~= nil ) then
          Page = &quot;lone &quot; .. PP
        else Page = &quot;stuff &quot; .. PP
        end
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;). &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;). &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z</text>
      <sha1>eklhlbt4sy98ikiorbhmjt1lg4muo3s</sha1>
    </revision>
    <revision>
      <id>4446</id>
      <parentid>4445</parentid>
      <timestamp>2012-10-18T23:43:50Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>add &quot;.&quot; to Title only when config.CitationClass == &quot;web&quot;</comment>
      <origin>4446</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="40810" sha1="5s56rw4idh8h27hvgouln95yn7adxgy" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if ( config.CitationClass == &quot;web&quot; ) then
        Title = Title .. &quot;.&quot; end -- with end-dot
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( PP ~= nil) then 
        if ( tonumber(PP) ~= nil ) then
          Page = &quot;lone &quot; .. PP
        else Page = &quot;stuff &quot; .. PP
        end
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;). &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;). &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z</text>
      <sha1>5s56rw4idh8h27hvgouln95yn7adxgy</sha1>
    </revision>
    <revision>
      <id>4447</id>
      <parentid>4446</parentid>
      <timestamp>2012-10-18T23:49:28Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>OMG, try again.</comment>
      <origin>4447</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="40811" sha1="kxb1kwpcebbmg8sbbfl74jmapy4sg69" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if ( config.CitationClass == &quot;book&quot; ) then
        Title = Title .. &quot;.&quot; end -- with end-dot
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( PP ~= nil) then 
        if ( tonumber(PP) ~= nil ) then
          Page = &quot;lone &quot; .. PP
        else Page = &quot;stuff &quot; .. PP
        end
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;). &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;). &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z</text>
      <sha1>kxb1kwpcebbmg8sbbfl74jmapy4sg69</sha1>
    </revision>
    <revision>
      <id>4448</id>
      <parentid>4447</parentid>
      <timestamp>2012-10-19T00:01:42Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>fixed Title end-dot when NOT-equal: config.CitationClass ~= &quot;book&quot;</comment>
      <origin>4448</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="40811" sha1="39rlo2lnh64tl88ituubicxamunxw6f" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if ( config.CitationClass ~= &quot;book&quot; ) then
        Title = Title .. &quot;.&quot; end -- with end-dot
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( PP ~= nil) then 
        if ( tonumber(PP) ~= nil ) then
          Page = &quot;lone &quot; .. PP
        else Page = &quot;stuff &quot; .. PP
        end
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At .. &quot;.&quot;
    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;). &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;). &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z</text>
      <sha1>39rlo2lnh64tl88ituubicxamunxw6f</sha1>
    </revision>
    <revision>
      <id>4449</id>
      <parentid>4448</parentid>
      <timestamp>2012-10-19T02:34:59Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>DEBUG: show all variable names in Title output, to see which one contains the spastic extra &quot;.&quot;</comment>
      <origin>4449</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="41163" sha1="0a1sxhtccj1q7uuexsvnx3guqfem831" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        if ( config.CitationClass ~= &quot;book&quot; ) then
        Title = Title .. &quot;.&quot; end -- with end-dot
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( PP ~= nil) then 
        if ( tonumber(PP) ~= nil ) then
          Page = &quot;lone &quot; .. PP
        else Page = &quot;stuff &quot; .. PP
        end
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At .. &quot;.&quot;
    tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position .. Page .. Pages .. At .. &quot;.&quot;

    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;). &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;). &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z</text>
      <sha1>0a1sxhtccj1q7uuexsvnx3guqfem831</sha1>
    </revision>
    <revision>
      <id>4450</id>
      <parentid>4449</parentid>
      <timestamp>2012-10-19T02:49:47Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;; put comment &quot;--DEBUG&quot; to show all variable names in Title output; added HISTORY comments.</comment>
      <origin>4450</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="41491" sha1="3d5fd9q0fcyj75iwh6jobwsw1of01m6" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = Title .. &quot;.&quot; -- with end-dot
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( PP ~= nil) then 
        if ( tonumber(PP) ~= nil ) then
          Page = &quot;lone &quot; .. PP
        else Page = &quot;stuff &quot; .. PP
        end
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages
    else
        Pages = &quot; &quot; .. PPPrefix .. Pages
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position .. Page .. Pages .. At

    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;). &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;). &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 ?
--
--End</text>
      <sha1>3d5fd9q0fcyj75iwh6jobwsw1of01m6</sha1>
    </revision>
    <revision>
      <id>4451</id>
      <parentid>4450</parentid>
      <timestamp>2012-10-19T03:02:05Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.</comment>
      <origin>4451</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="41581" sha1="h0tbbt0nebgs7qjr75uzvu0hb01bmt1" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = Title .. &quot;.&quot; -- with end-dot
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Page = &quot; &quot; .. PPrefix .. Pages
        else Pages = &quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position .. Page .. Pages .. At

    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;). &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;). &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 ?
--
--End</text>
      <sha1>h0tbbt0nebgs7qjr75uzvu0hb01bmt1</sha1>
    </revision>
    <revision>
      <id>4452</id>
      <parentid>4451</parentid>
      <timestamp>2012-10-19T03:09:35Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>fixed to show &quot;.&quot; after Periodical name</comment>
      <origin>4452</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="41660" sha1="923l3cepy43z63hbfxqvv3h7cakrhum" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = Title .. &quot;.&quot; -- with end-dot
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page
    else
        Page = &quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages
        else Pages = &quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;.&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position .. Page .. Pages .. At

    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;). &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;). &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper, etc.).
--19Oct2012 ?
--
--End</text>
      <sha1>923l3cepy43z63hbfxqvv3h7cakrhum</sha1>
    </revision>
    <revision>
      <id>4453</id>
      <parentid>4452</parentid>
      <timestamp>2012-10-19T03:16:39Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>fixed to show &quot;.&quot; after pages/at</comment>
      <origin>4453</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="41706" sha1="6i9izurj86qjhls3byfpj0mgs5y0cb1" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = Title .. &quot;.&quot; -- with end-dot
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;.&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position .. Page .. Pages .. At

    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;). &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;). &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper, etc.).
--19Oct2012 ?
--
--End</text>
      <sha1>6i9izurj86qjhls3byfpj0mgs5y0cb1</sha1>
    </revision>
    <revision>
      <id>4454</id>
      <parentid>4453</parentid>
      <timestamp>2012-10-19T04:11:09Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.</comment>
      <origin>4454</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="41787" sha1="hdkjynsnsnw31ij6jkbsct955oas9cw" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = Title .. &quot;.&quot; -- with end-dot
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then Coauthors = &quot; &quot; .. Coauthors .. &quot;.&quot; else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;.&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position .. Page .. Pages .. At

    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;). &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;). &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper, etc.).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 ?
--
--End</text>
      <sha1>hdkjynsnsnw31ij6jkbsct955oas9cw</sha1>
    </revision>
    <revision>
      <id>4455</id>
      <parentid>4454</parentid>
      <timestamp>2012-10-19T04:35:41Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>fixed to show &quot;;&quot; between authors &amp; coauthors.</comment>
      <origin>4455</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="41943" sha1="r79rocnkphu9rx7r9vsb8p01vp55ytq" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = Title .. &quot;.&quot; -- with end-dot
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors .. &quot;.&quot; 
      else Coauthors = Coauthors .. &quot;.&quot; end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;.&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position .. Page .. Pages .. At

    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;). &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;). &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper, etc.).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 ?
--19Oct2012 ?
--
--End</text>
      <sha1>r79rocnkphu9rx7r9vsb8p01vp55ytq</sha1>
    </revision>
    <revision>
      <id>4456</id>
      <parentid>4455</parentid>
      <timestamp>2012-10-19T04:46:48Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>fixed to omit &quot;.&quot; after coauthors</comment>
      <origin>4456</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="42005" sha1="rogz7kkqd42nl4qu44n3zpdwit4cx5r" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {}
    OCinSdata.ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {}
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value) .. &quot;&amp;&quot;
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. mw.url.encode(name .. &quot;=&quot; .. value) .. &quot;&amp;&quot;
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = Title .. &quot;.&quot; -- with end-dot
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. &quot;.&quot; end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;.&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position .. Page .. Pages .. At

    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;). &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;). &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper, etc.).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit &quot;.&quot; after coauthors.
--19Oct2012 ?
--19Oct2012 ?
--
--End</text>
      <sha1>rogz7kkqd42nl4qu44n3zpdwit4cx5r</sha1>
    </revision>
    <revision>
      <id>4457</id>
      <parentid>4456</parentid>
      <timestamp>2012-10-20T17:43:28Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>fixed [[COinS]] metadata to not end with &quot;&amp;&quot; but use leading &quot;&amp;rft...=&quot; form.</comment>
      <origin>4457</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="42296" sha1="05pix6dlsbgoj1qtiw6p4l7w4uxqdpt" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    OCinSdata.rfr_id = &quot;info:sid/en.wikipedia.org:&quot; .. config.fullpagename    
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.url.encode(value)
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = Title .. &quot;.&quot; -- with end-dot
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. &quot;.&quot; end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;.&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position .. Page .. Pages .. At

    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;). &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;). &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper, etc.).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end with &quot;&amp;&quot; but use leading &quot;&amp;rft...=&quot; form.
--20Oct2012 ?
--20Oct2012 ?
--
--End</text>
      <sha1>05pix6dlsbgoj1qtiw6p4l7w4uxqdpt</sha1>
    </revision>
    <revision>
      <id>4458</id>
      <parentid>4457</parentid>
      <timestamp>2012-10-20T18:03:04Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>fixed [[COinS]] metadata to not url.encode page's rfr_id pagename</comment>
      <origin>4458</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="42437" sha1="iwnhzbm6bezn08ab6lrgexac1iwp3tt" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    elseif ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = Title .. &quot;.&quot; -- with end-dot
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. &quot;.&quot; end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;.&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position .. Page .. Pages .. At

    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;). &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;). &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper, etc.).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end with &quot;&amp;&quot; but use leading &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 ?
--20Oct2012 ?
--
--End</text>
      <sha1>iwnhzbm6bezn08ab6lrgexac1iwp3tt</sha1>
    </revision>
    <revision>
      <id>4459</id>
      <parentid>4458</parentid>
      <timestamp>2012-10-20T18:17:29Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>fixed [[COinS]] metadata when &quot;web&quot; to default to rft.genre &quot;book&quot;</comment>
      <origin>4459</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="42513" sha1="pizxs36e1cvxo2w0huo8hfver8tpmai" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = Title .. &quot;.&quot; -- with end-dot
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. &quot;.&quot; end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;.&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position .. Page .. Pages .. At

    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;). &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;). &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element if it is cross-linked from elsewhere.
    if ( Year == nil ) then Year = &quot;&quot; end
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;), id=id }
        text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})
    end
    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper, etc.).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end with &quot;&amp;&quot; but use leading &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--20Oct2012 ?
--20Oct2012 ?
--
--End</text>
      <sha1>pizxs36e1cvxo2w0huo8hfver8tpmai</sha1>
    </revision>
    <revision>
      <id>4460</id>
      <parentid>4459</parentid>
      <timestamp>2012-11-05T09:39:52Z</timestamp>
      <contributor>
        <username>Tim Starling</username>
        <id>807</id>
      </contributor>
      <comment>Add a span wrapper even when there is no Ref parameter, to match previous template</comment>
      <origin>4460</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="42550" sha1="snjgbq0mmnie7ask8w5bw7a7hy1od8a" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require &quot;Module:Wikitext&quot;
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = Title .. &quot;.&quot; -- with end-dot
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. &quot;.&quot; end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;.&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position .. Page .. Pages .. At

    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;). &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;). &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = &quot;&quot; end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper, etc.).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end with &quot;&amp;&quot; but use leading &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--20Oct2012 ?
--20Oct2012 ?
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--
--End</text>
      <sha1>snjgbq0mmnie7ask8w5bw7a7hy1od8a</sha1>
    </revision>
    <revision>
      <id>4461</id>
      <parentid>4460</parentid>
      <timestamp>2012-11-07T06:02:22Z</timestamp>
      <contributor>
        <username>Tim Starling</username>
        <id>807</id>
      </contributor>
      <comment>fix use of global variables defined by Module:Mw</comment>
      <origin>4461</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="42618" sha1="tni4thajmjc5ij866ksr1q911lon2k5" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
        link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
        mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
    }
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = Title .. &quot;.&quot; -- with end-dot
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. &quot;.&quot; end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;.&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position .. Page .. Pages .. At

    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;). &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;). &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = &quot;&quot; end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper, etc.).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end with &quot;&amp;&quot; but use leading &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--20Oct2012 ?
--20Oct2012 ?
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--
--End</text>
      <sha1>tni4thajmjc5ij866ksr1q911lon2k5</sha1>
    </revision>
    <revision>
      <id>4462</id>
      <parentid>4461</parentid>
      <timestamp>2012-11-08T13:59:03Z</timestamp>
      <contributor>
        <username>Phil Boswell</username>
        <id>805</id>
      </contributor>
      <comment>fix up author extraction to account for blank parameters—proof of concept for other parameters</comment>
      <origin>4462</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="42723" sha1="do5dlha8tae694usykojcrtr1667mvs" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = Title .. &quot;.&quot; -- with end-dot
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. &quot;.&quot; end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, id) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;.&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position .. Page .. Pages .. At

    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;). &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;). &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = &quot;&quot; end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper, etc.).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end with &quot;&amp;&quot; but use leading &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--20Oct2012 ?
--20Oct2012 ?
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--
--End</text>
      <sha1>do5dlha8tae694usykojcrtr1667mvs</sha1>
    </revision>
    <revision>
      <id>4463</id>
      <parentid>4462</parentid>
      <timestamp>2012-11-08T14:11:33Z</timestamp>
      <contributor>
        <username>Phil Boswell</username>
        <id>805</id>
      </contributor>
      <comment>pass OD parameter into builder function</comment>
      <origin>4463</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="42723" sha1="g82hescfmh9epy1ko4129mzcvo9o7xu" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = Title .. &quot;.&quot; -- with end-dot
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. &quot;.&quot; end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; '''&quot; .. Volume .. &quot;'''&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;.&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position .. Page .. Pages .. At

    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;). &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;). &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = &quot;&quot; end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|'''&quot; .. sup_arrow .. &quot;''']]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper, etc.).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end with &quot;&amp;&quot; but use leading &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--20Oct2012 ?
--20Oct2012 ?
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--
--End</text>
      <sha1>g82hescfmh9epy1ko4129mzcvo9o7xu</sha1>
    </revision>
    <revision>
      <id>4464</id>
      <parentid>4463</parentid>
      <timestamp>2012-11-08T14:23:46Z</timestamp>
      <contributor>
        <username>Phil Boswell</username>
        <id>805</id>
      </contributor>
      <comment>use HTML for bold and italic instead of wikicode</comment>
      <origin>4464</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="42728" sha1="m9ydffj6v3io1qupblcincp9kjvq3xm" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( nil == last ) then return nil end
    return {
        last = last,
        first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
        link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
        mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
    }
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = Title .. &quot;.&quot; -- with end-dot
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. &quot;.&quot; end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;.&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position .. Page .. Pages .. At

    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;). &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;). &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = &quot;&quot; end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper, etc.).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end with &quot;&amp;&quot; but use leading &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--20Oct2012 ?
--20Oct2012 ?
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--
--End</text>
      <sha1>m9ydffj6v3io1qupblcincp9kjvq3xm</sha1>
    </revision>
    <revision>
      <id>4465</id>
      <parentid>4464</parentid>
      <timestamp>2012-11-09T13:00:50Z</timestamp>
      <contributor>
        <username>Phil Boswell</username>
        <id>805</id>
      </contributor>
      <comment>fixing up editor extraction (same as authors) to account for blank parameters</comment>
      <origin>4465</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="42833" sha1="hlqz9aa0hdd0z9njoti5w78r6jktsjo" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( nil ~= ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle ~= nil ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter ~= nil ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter ~= nil ) then
        if ( ChapterLink ~= nil ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL ~= nil ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL ~= nil ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title ~= nil ) then
        if ( TitleLink ~= nil ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical ~= nil ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL ~= nil ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = Title .. &quot;.&quot; -- with end-dot
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. &quot;.&quot; end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;.&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position .. Page .. Pages .. At

    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;). &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;). &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = &quot;&quot; end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper, etc.).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end with &quot;&amp;&quot; but use leading &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--20Oct2012 ?
--20Oct2012 ?
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--
--End</text>
      <sha1>hlqz9aa0hdd0z9njoti5w78r6jktsjo</sha1>
    </revision>
    <revision>
      <id>4466</id>
      <parentid>4465</parentid>
      <timestamp>2012-11-12T12:34:42Z</timestamp>
      <contributor>
        <username>Phil Boswell</username>
        <id>805</id>
      </contributor>
      <comment>fix up some more parameters to handle blanks</comment>
      <origin>4466</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="42969" sha1="ps50o2jg6tl9erog5ccef48z29aqt5s" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = Title .. &quot;.&quot; -- with end-dot
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. &quot;.&quot; end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;.&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position .. Page .. Pages .. At

    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;). &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;). &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = &quot;&quot; end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper, etc.).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end with &quot;&amp;&quot; but use leading &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--20Oct2012 ?
--20Oct2012 ?
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--
--End</text>
      <sha1>ps50o2jg6tl9erog5ccef48z29aqt5s</sha1>
    </revision>
    <revision>
      <id>4467</id>
      <parentid>4466</parentid>
      <timestamp>2013-02-15T22:46:13Z</timestamp>
      <contributor>
        <ip>12.78.83.141</ip>
      </contributor>
      <comment>added Agency to handle &quot;agency=xx&quot;.</comment>
      <origin>4467</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="43120" sha1="5429y4ng0gc722tmhl6ephz1qbgon37" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = Title .. &quot;.&quot; -- with end-dot
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. &quot;.&quot; end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Agency ~= nil ) then Agency = &quot; &quot; .. Agency .. &quot;.&quot; else Agency = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot; else Publisher = &quot;&quot; end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;.&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position .. Page .. Pages .. At

    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;). &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. Agency .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;). &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. Agency .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Agency .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = &quot;&quot; end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper, etc.).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--
--End</text>
      <sha1>5429y4ng0gc722tmhl6ephz1qbgon37</sha1>
    </revision>
    <revision>
      <id>4468</id>
      <parentid>4467</parentid>
      <timestamp>2013-02-16T00:37:55Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>added  &quot;Location&quot; to handle &quot;location=xx&quot; when no PublisherName</comment>
      <origin>4468</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="43280" sha1="5bojvvtabyca7y5p4jdjdj0e7hhb9im" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = Title .. &quot;.&quot; -- with end-dot
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. &quot;.&quot; end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Agency ~= nil ) then Agency = &quot; &quot; .. Agency .. &quot;.&quot; else Agency = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;).&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;.&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position .. Page .. Pages .. At

    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;). &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. Agency .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;). &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. Agency .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Agency .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = &quot;&quot; end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper, etc.).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--
--End</text>
      <sha1>5bojvvtabyca7y5p4jdjdj0e7hhb9im</sha1>
    </revision>
    <revision>
      <id>4469</id>
      <parentid>4468</parentid>
      <timestamp>2013-02-19T13:17:17Z</timestamp>
      <contributor>
        <username>Shyamal</username>
        <id>808</id>
      </contributor>
      <comment>attempt a kludgy fix to see if Zotero works</comment>
      <origin>4469</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="43471" sha1="a9xaqpp86jypd6qmfmn92z5ald6xiyh" xml:space="preserve">--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then 
               OCinSdata[&quot;rft.atitle&quot;] = Title 
               OCinSdata.rft_val_fmt &quot;info:ofi/fmt:kev:mtx:journal&quot;
            end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then 
               OCinSdata[&quot;rft.btitle&quot;] = Title 
               OCinSdata.rft_val_fmt &quot;info:ofi/fmt:kev:mtx:book&quot;
            end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = Title .. &quot;.&quot; -- with end-dot
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. &quot;.&quot; end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Agency ~= nil ) then Agency = &quot; &quot; .. Agency .. &quot;.&quot; else Agency = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;).&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;.&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position .. Page .. Pages .. At

    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;). &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. Agency .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;). &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. Agency .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Agency .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = &quot;&quot; end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper, etc.).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--
--End</text>
      <sha1>a9xaqpp86jypd6qmfmn92z5ald6xiyh</sha1>
    </revision>
    <revision>
      <id>4470</id>
      <parentid>4469</parentid>
      <timestamp>2013-02-19T14:07:47Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>created, as a submodule of [[Module:Citation]], to alter to match [[Help:CS1|Citation Style 1]] cite format.</comment>
      <origin>4470</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="43615" sha1="94bs95evu9atksytjwopfi2hwhosvn8" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = Title .. &quot;.&quot; -- with end-dot
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. &quot;.&quot; end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; &quot; .. OrigYear else OrigYear = &quot;&quot; end
    if ( Agency ~= nil ) then Agency = &quot; &quot; .. Agency .. &quot;.&quot; else Agency = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;).&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;.&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position .. Page .. Pages .. At

    Date = Date .. OrigYear
    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;). &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. Agency .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date .. &quot;). &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. Agency .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Agency .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = &quot;&quot; end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper, etc.).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--
--End</text>
      <sha1>94bs95evu9atksytjwopfi2hwhosvn8</sha1>
    </revision>
    <revision>
      <id>4471</id>
      <parentid>4470</parentid>
      <timestamp>2013-02-19T15:03:37Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>changed OrigYear to use [__] for CS1 style.</comment>
      <origin>4471</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="43686" sha1="9u1k2x14im0jyu3lf886xms760078hg" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = Title .. &quot;.&quot; -- with end-dot
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. &quot;.&quot; end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil ) then Agency = &quot; &quot; .. Agency .. &quot;.&quot; else Agency = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;).&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;.&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Position .. Page .. Pages .. At
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position .. Page .. Pages .. At

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. &quot;. &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Publisher .. Agency .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. &quot;. &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. Agency .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Agency .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = &quot;&quot; end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper, etc.).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--
--End</text>
      <sha1>9u1k2x14im0jyu3lf886xms760078hg</sha1>
    </revision>
    <revision>
      <id>4472</id>
      <parentid>4471</parentid>
      <timestamp>2013-02-19T17:51:43Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>moved Publisher / Agency before pages</comment>
      <origin>4472</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="43686" sha1="tul3rzlds5gdjkmrg1yoc93d6mngwo0" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
        Title = Title .. &quot;.&quot; -- with end-dot
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. &quot;.&quot; end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil ) then Agency = &quot; &quot; .. Agency .. &quot;.&quot; else Agency = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;).&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;.&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Publisher .. Agency .. Position .. Page .. Pages .. At
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position .. Page .. Pages .. At

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. &quot;. &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. &quot;. &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Publisher .. Agency .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Publisher .. Agency .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = &quot;&quot; end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper, etc.).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--
--End</text>
      <sha1>tul3rzlds5gdjkmrg1yoc93d6mngwo0</sha1>
    </revision>
    <revision>
      <id>4473</id>
      <parentid>4472</parentid>
      <timestamp>2013-02-19T20:29:51Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>fixed to show optional Format before endtitle &quot;.&quot;; fixed to not show duplicate Publisher/Agency.</comment>
      <origin>4473</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="43777" sha1="4ypwgy2twrgfig3aala21m105ck44xn" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. &quot;.&quot; end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;).&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;).&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil ) then Agency = &quot; &quot; .. Agency .. &quot;.&quot; else Agency = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;).&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;.&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local endtitle = &quot;.&quot;
    if (TitleType ~= &quot;&quot; or TitleNote ~= &quot;&quot; or Format ~= &quot;&quot;)
    then endtitle = &quot;&quot; end
    local tcommon = Title .. TitleType .. TitleNote .. Format .. endtitle .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Publisher .. Agency .. Position .. Page .. Pages .. At
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position .. Page .. Pages .. At

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. &quot;. &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. &quot;. &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Date .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = &quot;&quot; end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper, etc.).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--
--End</text>
      <sha1>4ypwgy2twrgfig3aala21m105ck44xn</sha1>
    </revision>
    <revision>
      <id>4474</id>
      <parentid>4473</parentid>
      <timestamp>2013-02-19T20:51:13Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>moved page number to after date for CitationClass &quot;web&quot;; put period after Format or Edition.</comment>
      <origin>4474</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="43759" sha1="29w76q5yllnplgbh72jbnfaksybd6um" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. &quot;.&quot; end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil ) then Agency = &quot; &quot; .. Agency .. &quot;.&quot; else Agency = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher
    if ( Periodical ~= nil ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;).&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;.&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local endtitle = &quot;.&quot;
    if (Title == &quot;&quot;)
    then endtitle = &quot;&quot; end
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. endtitle .. Conference .. Periodical .. Series .. Volume .. Issue .. Publisher .. Agency .. Position
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. &quot;. &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. &quot;. &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = &quot;&quot; end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper, etc.).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--
--End</text>
      <sha1>29w76q5yllnplgbh72jbnfaksybd6um</sha1>
    </revision>
    <revision>
      <id>4475</id>
      <parentid>4474</parentid>
      <timestamp>2013-02-19T21:29:38Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>fixed dot &quot;.&quot; when Publisher &amp; omit parentheses &quot;(publisher)&quot; if CitationClass &quot;web&quot; etc.</comment>
      <origin>4475</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="43894" sha1="d0d0r8edglwnpcvg9nvk9bdqm5has1d" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. &quot;.&quot; end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot; &quot; .. Series .. &quot;.&quot; else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil ) then Agency = &quot; &quot; .. Agency .. &quot;.&quot; else Agency = &quot;&quot; end
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;).&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;).&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot;. &quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;.&quot; else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    local enddot = &quot;&quot;
    if ( Periodical ~= nil ) then 
        Periodical = &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
        if ( Publisher == &quot;&quot; ) then Publisher = &quot;.&quot; end
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local endtitle = &quot;.&quot;
    if (Title == &quot;&quot;)
    then endtitle = &quot;&quot; end
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. endtitle .. Conference .. Periodical .. Series .. Volume .. Issue .. Publisher .. Agency .. Position
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. &quot;. &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. &quot;. &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = &quot;&quot; end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper, etc.).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--
--End</text>
      <sha1>d0d0r8edglwnpcvg9nvk9bdqm5has1d</sha1>
    </revision>
    <revision>
      <id>4476</id>
      <parentid>4475</parentid>
      <timestamp>2013-02-20T00:56:58Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>reworked to stop double-dots &quot;..&quot;, put NOTES comments to explain module operation.</comment>
      <origin>4476</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="44867" sha1="5uocctsfybg9si0ux345odtk7ghquox" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. &quot;.&quot; end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot;. &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil ) then Agency = &quot;. &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via .. &quot;.&quot; else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot;. &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then 
        Periodical = &quot;. &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 enddot = &quot;.&quot;
    if (Title == &quot;&quot;)
    then enddot = &quot;&quot; end
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Publisher .. Agency .. Position .. enddot
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position
    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. &quot;. &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. &quot;. &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = &quot;&quot; end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--
--End</text>
      <sha1>5uocctsfybg9si0ux345odtk7ghquox</sha1>
    </revision>
    <revision>
      <id>4477</id>
      <parentid>4476</parentid>
      <timestamp>2013-02-20T01:04:33Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>re-added space at Date</comment>
      <origin>4477</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="44874" sha1="smuh1fvpt2k4k06q2frzv9llo0gk6u6" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. &quot;.&quot; end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot;. &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil ) then Agency = &quot;. &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via .. &quot;.&quot; else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot;. &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then 
        Periodical = &quot;. &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 enddot = &quot;.&quot;
    if (Title == &quot;&quot;)
    then enddot = &quot;&quot; end
    local tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Publisher .. Agency .. Position .. enddot
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position
    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. &quot;. &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. &quot;. &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = &quot;&quot; end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--
--End</text>
      <sha1>smuh1fvpt2k4k06q2frzv9llo0gk6u6</sha1>
    </revision>
    <revision>
      <id>4478</id>
      <parentid>4477</parentid>
      <timestamp>2013-02-20T03:24:36Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>changed to omit dot &quot;.&quot; if already ends with dot.</comment>
      <origin>4478</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="45006" sha1="eiviffbmqer2vdc566cptzk4xkqi3gc" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. &quot;.&quot; end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot;. &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil ) then Agency = &quot;. &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via .. &quot;.&quot; else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot;. &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then 
        Periodical = &quot;. &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Publisher .. Agency .. Position
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position
    local enddot = &quot;.&quot;
    if (Title == &quot;&quot;) then enddot = &quot;&quot; end
    if (tcommon.sub(-1,-1) == &quot;.&quot;) then enddot = &quot;&quot; end
    tcommon = tcommon + &quot;.&quot;
    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. &quot;. &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. &quot;. &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = &quot;&quot; end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--
--End</text>
      <sha1>eiviffbmqer2vdc566cptzk4xkqi3gc</sha1>
    </revision>
    <revision>
      <id>4479</id>
      <parentid>4478</parentid>
      <timestamp>2013-02-20T03:29:28Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>substring: string.sub(tcommon,-1,1) == &quot;.&quot;</comment>
      <origin>4479</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="45017" sha1="dks0xm146trdz8c5wi8dskht7gqzsnt" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. &quot;.&quot; end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot;. &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil ) then Agency = &quot;. &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via .. &quot;.&quot; else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot;. &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then 
        Periodical = &quot;. &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Publisher .. Agency .. Position
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position
    local enddot = &quot;.&quot;
    if (Title == &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(tcommon,-1,1) == &quot;.&quot;) then enddot = &quot;&quot; end
    tcommon = tcommon .. enddot
    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. &quot;. &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. &quot;. &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = &quot;&quot; end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--
--End</text>
      <sha1>dks0xm146trdz8c5wi8dskht7gqzsnt</sha1>
    </revision>
    <revision>
      <id>4480</id>
      <parentid>4479</parentid>
      <timestamp>2013-02-20T04:11:30Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>for CitationClass &quot;journal&quot; shows Publisher after Periodical / Series</comment>
      <origin>4480</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="45259" sha1="fq4u6njeqs2q1f3hn24j7yf3o7aw076" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. &quot;.&quot; end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot;. &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil ) then Agency = &quot;. &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via .. &quot;.&quot; else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot;. &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then 
        Periodical = &quot;. &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Issue .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Publisher .. Agency .. Position end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position
    local enddot = &quot;.&quot;
    if (Title == &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(tcommon,-1,1) == &quot;.&quot;) then enddot = &quot;&quot; end
    tcommon = tcommon .. enddot
    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. &quot;. &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. &quot;. &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = &quot;&quot; end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--
--End</text>
      <sha1>fq4u6njeqs2q1f3hn24j7yf3o7aw076</sha1>
    </revision>
    <revision>
      <id>4481</id>
      <parentid>4480</parentid>
      <timestamp>2013-02-20T04:17:20Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>for class &quot;journal&quot; omitted enddot</comment>
      <origin>4481</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="45396" sha1="qknuy3af3xnadb7inqnzm7bz94yw8f5" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;].&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;].&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. &quot;.&quot; end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot;. &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil ) then Agency = &quot;. &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via .. &quot;.&quot; else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot;. &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then 
        Periodical = &quot;. &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Issue .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Publisher .. Agency .. Position end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position
    local enddot = &quot;.&quot;
    if (Title == &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(tcommon,-1,1) == &quot;.&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;journal&quot;) then enddot = &quot;&quot; end
    tcommon = tcommon .. enddot
    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. &quot;. &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. &quot;. &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = &quot;&quot; end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--
--End</text>
      <sha1>qknuy3af3xnadb7inqnzm7bz94yw8f5</sha1>
    </revision>
    <revision>
      <id>4482</id>
      <parentid>4481</parentid>
      <timestamp>2013-02-20T04:27:17Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>used &amp;#93 for &quot;]&quot; to allow URL link</comment>
      <origin>4482</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="45404" sha1="7bgwe3uxfbpkal9s21uogp8a1ijkc1n" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;.&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;.&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. &quot;.&quot; end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot;. &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil ) then Agency = &quot;. &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via .. &quot;.&quot; else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot;. &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then 
        Periodical = &quot;. &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Issue .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Format .. Edition .. Language .. Conference .. Periodical .. Series .. Volume .. Issue .. Publisher .. Agency .. Position end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position
    local enddot = &quot;.&quot;
    if (Title == &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(tcommon,-1,1) == &quot;.&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;journal&quot;) then enddot = &quot;&quot; end
    tcommon = tcommon .. enddot
    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. &quot;. &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Others .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. &quot;. &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = &quot;&quot; end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--
--End</text>
      <sha1>7bgwe3uxfbpkal9s21uogp8a1ijkc1n</sha1>
    </revision>
    <revision>
      <id>4483</id>
      <parentid>4482</parentid>
      <timestamp>2013-02-20T20:41:24Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>shifted Format to follow Language, and Others to follow Volume</comment>
      <origin>4483</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="45485" sha1="4d9fo5ehbmjsmmqk19bfuxyinz08pd4" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        local temp = URL
        URL = ArchiveURL
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;.&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;.&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. &quot;.&quot; end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot;. &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil ) then Agency = &quot;. &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via .. &quot;.&quot; else Via = &quot;&quot; end
    if ( AccessDate ~= nil ) then AccessDate = &quot; Retrieved &quot; .. AccessDate .. &quot;.&quot; else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot;. &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then 
        Periodical = &quot;. &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position
    local enddot = &quot;.&quot;
    if (Title == &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(tcommon,-1,1) == &quot;.&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;journal&quot;) then enddot = &quot;&quot; end
    tcommon = tcommon .. enddot
    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. &quot;. &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. &quot;. &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = &quot;&quot; end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--
--End</text>
      <sha1>4d9fo5ehbmjsmmqk19bfuxyinz08pd4</sha1>
    </revision>
    <revision>
      <id>4484</id>
      <parentid>4483</parentid>
      <timestamp>2013-02-20T21:31:46Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;; fixed url when deadurl=no.</comment>
      <origin>4484</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="45741" sha1="mwna6mk5ap6ezn8ur4rozw2gsgh1sxm" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;.&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;.&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. &quot;.&quot; end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = &quot;. &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil ) then Agency = &quot;. &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via .. &quot;.&quot; else Via = &quot;&quot; end
    if ( AccessDate ~= nil )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt; Retrieved ' .. AccessDate .. '.&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;Online Computer Library Center&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot;. &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then 
        Periodical = &quot;. &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position
    local enddot = &quot;.&quot;
    if (Title == &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(tcommon,-1,1) == &quot;.&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;journal&quot;) then enddot = &quot;&quot; end
    tcommon = tcommon .. enddot
    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. &quot;. &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. &quot;. &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;.&quot; end
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = &quot;&quot; end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--
--End</text>
      <sha1>mwna6mk5ap6ezn8ur4rozw2gsgh1sxm</sha1>
    </revision>
    <revision>
      <id>4485</id>
      <parentid>4484</parentid>
      <timestamp>2013-02-20T22:05:40Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>added sepc for separator character between parameters; set &quot;OCLC&quot;</comment>
      <origin>4485</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="46057" sha1="5z8nvsm4b9or897ek416gmks4vt6n5m" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al.&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;citation&quot; ) then sepc = &quot;,&quot; end 
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;.&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;.&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. &quot;.&quot; end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil ) then Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via .. sepc else Via = &quot;&quot; end
    if ( AccessDate ~= nil )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt; Retrieved ' .. AccessDate .. '.&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot;. &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then 
        Periodical = &quot;. &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position
    local enddot = sepc
    if (Title == &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(tcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;journal&quot;) then enddot = &quot;&quot; end
    tcommon = tcommon .. enddot
    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. &quot;. &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. &quot;. &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;'''&quot; .. string.sub(&quot;.&quot;,-1,-1) .. &quot;'''&quot; end
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = string.sub(Date,-3) end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--
--End</text>
      <sha1>5z8nvsm4b9or897ek416gmks4vt6n5m</sha1>
    </revision>
    <revision>
      <id>4486</id>
      <parentid>4485</parentid>
      <timestamp>2013-02-20T22:40:13Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>added space to AuthorSep &amp; AuthorNameSep; handled empty &quot;authorlink=&quot;</comment>
      <origin>4486</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="46328" sha1="f018w41qmi24dchews36i4nnqalt9du" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;&lt;i&gt;et al.&lt;/i&gt;&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;citation&quot; ) then sepc = &quot;,&quot; end 
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;.&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;.&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. &quot;. &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. &quot;.&quot; end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil ) then Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via .. sepc else Via = &quot;&quot; end
    if ( AccessDate ~= nil )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt; Retrieved ' .. AccessDate .. '.&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = &quot;. &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then 
        Periodical = &quot;. &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  At this point, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; or
         config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position
    local enddot = sepc
    if (Title == &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(tcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;journal&quot;) then enddot = &quot;&quot; end
    tcommon = tcommon .. enddot
    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. &quot;. &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. &quot;. &quot;
        else Editors = Editors .. &quot;. &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. &quot;'''&quot; .. string.sub(&quot;.&quot;,-1,-1) .. &quot;'''&quot; end
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = string.sub(Date,-3) end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--
--End</text>
      <sha1>f018w41qmi24dchews36i4nnqalt9du</sha1>
    </revision>
    <revision>
      <id>4487</id>
      <parentid>4486</parentid>
      <timestamp>2013-02-20T22:58:48Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>replaced more dots &quot;.&quot; with sepc.</comment>
      <origin>4487</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="46326" sha1="cof2tng6b7cxkctg9wzpljm0tklu5ng" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;&lt;i&gt;et al.&lt;/i&gt;&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;citation&quot; ) then sepc = &quot;,&quot; end 
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;.&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;.&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. &quot;.&quot; end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. &quot;.&quot; else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil ) then Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via .. sepc else Via = &quot;&quot; end
    if ( AccessDate ~= nil )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt; Retrieved ' .. AccessDate .. '.&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; or
         config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position
    local enddot = sepc
    if (Title == &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(tcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;journal&quot;) then enddot = &quot;&quot; end
    tcommon = tcommon .. enddot
    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. &quot;. &quot;
        else Authors = Authors .. &quot;. &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. &quot;.&quot; end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. sepc end
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = string.sub(Date,-3) end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--
--End</text>
      <sha1>cof2tng6b7cxkctg9wzpljm0tklu5ng</sha1>
    </revision>
    <revision>
      <id>4488</id>
      <parentid>4487</parentid>
      <timestamp>2013-02-20T23:10:02Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>replaced more dots &quot;.&quot; with sepc</comment>
      <origin>4488</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="46409" sha1="htbbup4dhuolfzllpgpjuf1v2uc9etm" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;&lt;i&gt;et al.&lt;/i&gt;&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;citation&quot; ) then sepc = &quot;,&quot; end 
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;.&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;.&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil ) then Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via .. sepc else Via = &quot;&quot; end
    if ( AccessDate ~= nil )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt; Retrieved ' .. AccessDate .. '.&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; or
         config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position
    local enddot = sepc
    if (Title == &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(tcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;journal&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    tcommon = tcommon .. enddot
    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. sepc end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. sepc end
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = string.sub(Date,-3) end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--
--End</text>
      <sha1>htbbup4dhuolfzllpgpjuf1v2uc9etm</sha1>
    </revision>
    <revision>
      <id>4489</id>
      <parentid>4488</parentid>
      <timestamp>2013-02-21T01:09:43Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>when empty URL with PMC, then defaulted URL to use PMC url; omitted when blank codes as &quot;&quot;.</comment>
      <origin>4489</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="46927" sha1="6gpk93is8y8d50hvb9wpmooh8w8zdlz" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;&lt;i&gt;et al.&lt;/i&gt;&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;citation&quot; ) then sepc = &quot;,&quot; end 
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.

    if ( URL == nil ) then
        if ( PMC ~= nil ) then
          URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC .. &quot;/?tool=pmcentrez&quot;
        end
    end
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;.&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;.&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil ) then Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via .. sepc else Via = &quot;&quot; end
    if ( AccessDate ~= nil )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt; Retrieved ' .. AccessDate .. '.&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then
        ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
        DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~= &quot;&quot; ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot; ) then
        ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~= &quot;&quot; ) then
        ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~= &quot;&quot; ) then
        JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; or
         config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position
    local enddot = sepc
    if (Title == &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(tcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;journal&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    tcommon = tcommon .. enddot
    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. sepc end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. sepc end
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = string.sub(Date,-3) end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 If empty URL with PMC, then defaulted URL as PMC url.
--21Feb2013 Checked for empty codes (ASIN ~= &quot;&quot;) as well as nil.
--
--End</text>
      <sha1>6gpk93is8y8d50hvb9wpmooh8w8zdlz</sha1>
    </revision>
    <revision>
      <id>4490</id>
      <parentid>4489</parentid>
      <timestamp>2013-02-21T01:16:16Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>checked more blank codes</comment>
      <origin>4490</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="46919" sha1="ha3xpzbc7f3btvu8m2k8mlxl1kppaqr" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;&lt;i&gt;et al.&lt;/i&gt;&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;citation&quot; ) then sepc = &quot;,&quot; end 
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.

    if ( URL == nil ) then
        if ( PMC ~= nil ) then
          URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC .. &quot;/?tool=pmcentrez&quot;
        end
    end
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;.&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;.&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil ) then Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via .. sepc else Via = &quot;&quot; end
    if ( AccessDate ~= nil )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt; Retrieved ' .. AccessDate .. '.&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then
        ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
        DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~= &quot;&quot; ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot; ) then
        ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~= &quot;&quot; ) then
        ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~= &quot;&quot; ) then
        JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR &gt; &quot;&quot; ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN &gt; &quot;&quot; ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR &gt; &quot;&quot; ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC &gt; &quot;&quot; ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; or
         config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position
    local enddot = sepc
    if (Title == &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(tcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;journal&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    tcommon = tcommon .. enddot
    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. sepc end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. sepc end
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = string.sub(Date,-3) end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 If empty URL with PMC, then defaulted URL as PMC url.
--21Feb2013 Checked for empty codes (ASIN ~= &quot;&quot;) as well as nil.
--
--End</text>
      <sha1>ha3xpzbc7f3btvu8m2k8mlxl1kppaqr</sha1>
    </revision>
    <revision>
      <id>4491</id>
      <parentid>4490</parentid>
      <timestamp>2013-02-21T01:23:11Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>undid 2 revisions after &quot;Script error&quot;</comment>
      <origin>4491</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="46409" sha1="htbbup4dhuolfzllpgpjuf1v2uc9etm" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;&lt;i&gt;et al.&lt;/i&gt;&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;citation&quot; ) then sepc = &quot;,&quot; end 
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;.&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;.&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil ) then Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via .. sepc else Via = &quot;&quot; end
    if ( AccessDate ~= nil )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt; Retrieved ' .. AccessDate .. '.&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; or
         config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position
    local enddot = sepc
    if (Title == &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(tcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;journal&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    tcommon = tcommon .. enddot
    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. sepc end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. sepc end
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = string.sub(Date,-3) end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--
--End</text>
      <sha1>htbbup4dhuolfzllpgpjuf1v2uc9etm</sha1>
    </revision>
    <revision>
      <id>4492</id>
      <parentid>4491</parentid>
      <timestamp>2013-02-21T01:48:23Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>fixed to allow &quot;contribution=x&quot; (formerly ignored); fixed &quot;EditorSep&quot; (was misspelled &quot;EdithorSep&quot;).</comment>
      <origin>4492</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="46631" sha1="l6h5csq7h4yfjzln0ua9qibmbaxldze" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;&lt;i&gt;et al.&lt;/i&gt;&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;citation&quot; ) then sepc = &quot;,&quot; end 
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        EditorNameSep = EditorNameSep + &quot; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        EditorSep = EditorSep + &quot; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;.&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;.&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil ) then Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via .. sepc else Via = &quot;&quot; end
    if ( AccessDate ~= nil )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt; Retrieved ' .. AccessDate .. '.&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; or
         config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position
    local enddot = sepc
    if (Title == &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(tcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;journal&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    tcommon = tcommon .. enddot
    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. sepc end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. sepc end
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = string.sub(Date,-3) end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Fixed to allow &quot;contribution=x&quot; as &quot;new&quot; parameter.
--21Feb2013 Fixed separator &quot;EditorSep&quot; (was &quot;EdithorSep&quot;).
--
--End</text>
      <sha1>l6h5csq7h4yfjzln0ua9qibmbaxldze</sha1>
    </revision>
    <revision>
      <id>4493</id>
      <parentid>4492</parentid>
      <timestamp>2013-02-21T01:59:53Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>fixed to allow empty parameters (ASIN= |DOI= etc.).</comment>
      <origin>4493</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="46653" sha1="c3h55yg1s5zl7205tag6nki85yt6ciz" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;&lt;i&gt;et al.&lt;/i&gt;&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;citation&quot; ) then sepc = &quot;,&quot; end 
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        EditorNameSep = EditorNameSep .. &quot; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        EditorSep = EditorSep .. &quot; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;.&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;.&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil ) then Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via .. sepc else Via = &quot;&quot; end
    if ( AccessDate ~= nil )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt; Retrieved ' .. AccessDate .. '.&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV &gt; &quot;&quot; ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN &gt; &quot;&quot; ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE &gt; &quot;&quot; ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI &gt; &quot;&quot; ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID &gt; &quot;&quot; ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN &gt; &quot;&quot; ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN &gt; &quot;&quot; ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM &gt; &quot;&quot; ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR &gt; &quot;&quot; ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN &gt; &quot;&quot; ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR &gt; &quot;&quot; ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC &gt; &quot;&quot; ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL &gt; &quot;&quot; ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI &gt; &quot;&quot; ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC &gt; &quot;&quot; ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID &gt; &quot;&quot; ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC &gt; &quot;&quot; ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN &gt; &quot;&quot; ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL &gt; &quot;&quot; ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL &gt; &quot;&quot; ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote &gt; &quot;&quot; ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript &gt; &quot;&quot; ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; or
         config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position
    local enddot = sepc
    if (Title == &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(tcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;journal&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    tcommon = tcommon .. enddot
    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. sepc end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. sepc end
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = string.sub(Date,-3) end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Fixed to allow &quot;contribution=x&quot; as &quot;new&quot; parameter.
--21Feb2013 Fixed separator &quot;EditorSep&quot; (was &quot;EdithorSep&quot;).
--21Feb2013 Fixed to allow empty parameters (ASIN= |DOI= etc.).
--
--End</text>
      <sha1>c3h55yg1s5zl7205tag6nki85yt6ciz</sha1>
    </revision>
    <revision>
      <id>4494</id>
      <parentid>4493</parentid>
      <timestamp>2013-02-21T02:17:44Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>started hacking out changes until &quot;Script error&quot; stops.</comment>
      <origin>4494</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="46573" sha1="br9mcj3m3j78e2ibj7b8i6ab732sdd1" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;&lt;i&gt;et al.&lt;/i&gt;&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;citation&quot; ) then sepc = &quot;,&quot; end 
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;.&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;.&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil ) then Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via .. sepc else Via = &quot;&quot; end
    if ( AccessDate ~= nil )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt; Retrieved ' .. AccessDate .. '.&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV &gt; &quot;&quot; ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN &gt; &quot;&quot; ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE &gt; &quot;&quot; ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI &gt; &quot;&quot; ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID &gt; &quot;&quot; ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN &gt; &quot;&quot; ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN &gt; &quot;&quot; ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM &gt; &quot;&quot; ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR &gt; &quot;&quot; ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN &gt; &quot;&quot; ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR &gt; &quot;&quot; ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC &gt; &quot;&quot; ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL &gt; &quot;&quot; ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI &gt; &quot;&quot; ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC &gt; &quot;&quot; ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID &gt; &quot;&quot; ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC &gt; &quot;&quot; ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN &gt; &quot;&quot; ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL &gt; &quot;&quot; ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL &gt; &quot;&quot; ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote &gt; &quot;&quot; ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript &gt; &quot;&quot; ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; or
         config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position
    local enddot = sepc
    if (Title == &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(tcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;journal&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    tcommon = tcommon .. enddot
    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. sepc end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. sepc end
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = string.sub(Date,-3) end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Fixed to allow &quot;contribution=x&quot; as &quot;new&quot; parameter.
--21Feb2013 Fixed separator &quot;EditorSep&quot; (was &quot;EdithorSep&quot;).
--21Feb2013 Fixed to allow empty parameters (ASIN= |DOI= etc.).
--
--End</text>
      <sha1>br9mcj3m3j78e2ibj7b8i6ab732sdd1</sha1>
    </revision>
    <revision>
      <id>4495</id>
      <parentid>4494</parentid>
      <timestamp>2013-02-21T02:21:30Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>cut &quot;args.contribution&quot; to see if &quot;Script error&quot; stops in Lua crapnology</comment>
      <origin>4495</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="46632" sha1="luk16klruqxzd6hgswtyiswyijx6lyw" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;&lt;i&gt;et al.&lt;/i&gt;&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;citation&quot; ) then sepc = &quot;,&quot; end 
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        EditorNameSep = EditorNameSep .. &quot; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        EditorSep = EditorSep .. &quot; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;.&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;.&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil ) then Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via .. sepc else Via = &quot;&quot; end
    if ( AccessDate ~= nil )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt; Retrieved ' .. AccessDate .. '.&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV &gt; &quot;&quot; ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN &gt; &quot;&quot; ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE &gt; &quot;&quot; ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI &gt; &quot;&quot; ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID &gt; &quot;&quot; ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN &gt; &quot;&quot; ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN &gt; &quot;&quot; ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM &gt; &quot;&quot; ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR &gt; &quot;&quot; ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN &gt; &quot;&quot; ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR &gt; &quot;&quot; ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC &gt; &quot;&quot; ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL &gt; &quot;&quot; ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI &gt; &quot;&quot; ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC &gt; &quot;&quot; ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID &gt; &quot;&quot; ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC &gt; &quot;&quot; ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN &gt; &quot;&quot; ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL &gt; &quot;&quot; ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL &gt; &quot;&quot; ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote &gt; &quot;&quot; ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript &gt; &quot;&quot; ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; or
         config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position
    local enddot = sepc
    if (Title == &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(tcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;journal&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    tcommon = tcommon .. enddot
    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. sepc end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. sepc end
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = string.sub(Date,-3) end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Fixed to allow &quot;contribution=x&quot; as &quot;new&quot; parameter.
--21Feb2013 Fixed separator &quot;EditorSep&quot; (was &quot;EdithorSep&quot;).
--21Feb2013 Fixed to allow empty parameters (ASIN= |DOI= etc.).
--
--End</text>
      <sha1>luk16klruqxzd6hgswtyiswyijx6lyw</sha1>
    </revision>
    <revision>
      <id>4496</id>
      <parentid>4495</parentid>
      <timestamp>2013-02-21T02:27:20Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>undid revisions after &quot;Script error&quot;; re-added &quot;args.contribution&quot;</comment>
      <origin>4496</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="46430" sha1="twa0pssnwqifwumrnqcda97fm11ymng" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;&lt;i&gt;et al.&lt;/i&gt;&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;citation&quot; ) then sepc = &quot;,&quot; end 
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EdithorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;.&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;.&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil ) then Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via .. sepc else Via = &quot;&quot; end
    if ( AccessDate ~= nil )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt; Retrieved ' .. AccessDate .. '.&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; or
         config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position
    local enddot = sepc
    if (Title == &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(tcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;journal&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    tcommon = tcommon .. enddot
    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. sepc end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. sepc end
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = string.sub(Date,-3) end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--
--End</text>
      <sha1>twa0pssnwqifwumrnqcda97fm11ymng</sha1>
    </revision>
    <revision>
      <id>4497</id>
      <parentid>4496</parentid>
      <timestamp>2013-02-21T02:32:50Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>again fixed &quot;EditorSep&quot; (was &quot;EdithorSep&quot;), now save and look for &quot;Script error&quot;</comment>
      <origin>4497</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="46429" sha1="5xwuaeg1xiy0w29t8anvzen7vco9iz7" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;&lt;i&gt;et al.&lt;/i&gt;&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;citation&quot; ) then sepc = &quot;,&quot; end 
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;.&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;.&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil ) then Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via .. sepc else Via = &quot;&quot; end
    if ( AccessDate ~= nil )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt; Retrieved ' .. AccessDate .. '.&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; or
         config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position
    local enddot = sepc
    if (Title == &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(tcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;journal&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    tcommon = tcommon .. enddot
    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. sepc end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. sepc end
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = string.sub(Date,-3) end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--
--End</text>
      <sha1>5xwuaeg1xiy0w29t8anvzen7vco9iz7</sha1>
    </revision>
    <revision>
      <id>4498</id>
      <parentid>4497</parentid>
      <timestamp>2013-02-21T03:31:43Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>try a change &amp; see if &quot;Script error&quot;</comment>
      <origin>4498</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="46425" sha1="nn3uoyh7ona0rdacwo7f3cxd3ntlv92" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;&lt;i&gt;et al.&lt;/i&gt;&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;citation&quot; ) then sepc = &quot;,&quot; end 
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:&quot;
    if ( nil ~= Periodical ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;.&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;.&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil ) then Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via .. sepc else Via = &quot;&quot; end
    if ( AccessDate ~= nil )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt; Retrieved ' .. AccessDate .. '.&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV &gt; &quot;&quot; ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN &gt; &quot;&quot; ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; or
         config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position
    local enddot = sepc
    if (Title == &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(tcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;journal&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    tcommon = tcommon .. enddot
    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. sepc end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. sepc end
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = string.sub(Date,-3) end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--
--End</text>
      <sha1>nn3uoyh7ona0rdacwo7f3cxd3ntlv92</sha1>
    </revision>
    <revision>
      <id>4499</id>
      <parentid>4498</parentid>
      <timestamp>2013-02-21T03:34:18Z</timestamp>
      <contributor>
        <username>Shyamal</username>
        <id>808</id>
      </contributor>
      <comment>add compulsory book or journal suffix</comment>
      <origin>4499</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="46552" sha1="gz0pfgqpiuqotg2afzqg98i8vniqcud" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;&lt;i&gt;et al.&lt;/i&gt;&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;citation&quot; ) then sepc = &quot;,&quot; end 
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
	    OCinSdata[&quot;rft.btitle&quot;] = Chapter
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;.&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;.&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil ) then Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via .. sepc else Via = &quot;&quot; end
    if ( AccessDate ~= nil )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt; Retrieved ' .. AccessDate .. '.&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil ) then
        SubscriptionRequired = &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV &gt; &quot;&quot; ) then ARXIV = &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN &gt; &quot;&quot; ) then ASIN = &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil ) then BIBCODE = &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil ) then DOI = &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil ) then ID = &quot; &quot; .. ID else ID = &quot;&quot; end
    if ( ISBN ~= nil ) then ISBN = &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil ) then ISSN = &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil ) then JFM = &quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil ) then JSTOR = &quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil ) then LCCN = &quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil ) then MR = &quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; or
         config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position
    local enddot = sepc
    if (Title == &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(tcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;journal&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    tcommon = tcommon .. enddot
    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. sepc end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. sepc end
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = string.sub(Date,-3) end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--
--End</text>
      <sha1>gz0pfgqpiuqotg2afzqg98i8vniqcud</sha1>
    </revision>
    <revision>
      <id>4500</id>
      <parentid>4499</parentid>
      <timestamp>2013-02-21T04:07:15Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>checked to omit blank codes (asin= | doi= etc.); fixed prior &quot;Script error&quot; after edit-conflict.</comment>
      <origin>4500</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="47181" sha1="3q6g1ioaes1wvrkurplzux8msi388eg" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;&lt;i&gt;et al.&lt;/i&gt;&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;citation&quot; ) then sepc = &quot;,&quot; end 
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;.&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;.&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page .. &quot;.&quot;
    else
        Page = &quot; &quot; .. PPrefix .. Page .. &quot;.&quot;
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages .. &quot;.&quot;
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = &quot; &quot; .. PPrefix .. Pages .. &quot;.&quot;
        else Pages = &quot; &quot; .. PPPrefix .. Pages .. &quot;.&quot;
        end
    end
    if ( At ~= nil ) then At = &quot; &quot; .. At .. &quot;.&quot;
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil ) then Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc .. ' Retrieved ' .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil ) then OCLC = &quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil ) then OL = &quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil ) then OSTI = &quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil ) then PMC = &quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil ) then PMID = &quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil ) then RFC = &quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil ) then SSRN = &quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil ) then URL = &quot; &quot; .. url(frame, URL) else URL = &quot;&quot; end
    if ( ZBL ~= nil ) then ZBL = &quot; &quot; .. externallinkid(frame, {label=&quot;ZBL&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = &quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = &quot; &quot; .. PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; or
         config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position
    local enddot = sepc
    if (Title == &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(tcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;journal&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    tcommon = tcommon .. enddot
    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. sepc end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date .. sepc end
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = string.sub(Date,-3) end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--
--End</text>
      <sha1>3q6g1ioaes1wvrkurplzux8msi388eg</sha1>
    </revision>
    <revision>
      <id>4501</id>
      <parentid>4500</parentid>
      <timestamp>2013-02-21T04:30:15Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>checked for more blank codes; cut dots after page-numbers.</comment>
      <origin>4501</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="47570" sha1="r7senvc6b1ufpl36kw9sc0k438wzpbb" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;&lt;i&gt;et al.&lt;/i&gt;&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;citation&quot; ) then sepc = &quot;,&quot; end 
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;.&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;.&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages ) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil ) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil ) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors ~= nil ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil ) then Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil ) then TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil ) then TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil ) then PublicationPlace = PublicationPlace .. &quot;: &quot; else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil ) then Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil ) then Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil ) then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil ) then Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil ) then Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil ) then Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil ) then OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil ) then Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil ) then Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc .. ' Retrieved ' .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and RFC ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = sepc ..&quot; &quot; .. url(frame, URL)
    else
       if (PMC ~= nil and PMC ~=&quot;&quot;)
         then URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC .. &quot;/?tool=pmcentrez&quot;
         else URL = &quot;&quot;
       end
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; or
         config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position
    local enddot = sepc
    if (Title == &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(tcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;journal&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    tcommon = tcommon .. enddot
    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. sepc end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date end
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = string.sub(Date,-3) end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--
--End</text>
      <sha1>r7senvc6b1ufpl36kw9sc0k438wzpbb</sha1>
    </revision>
    <revision>
      <id>4502</id>
      <parentid>4501</parentid>
      <timestamp>2013-02-21T04:56:49Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>checked 22 more empty parameters; unitalicized &quot;et al.&quot;</comment>
      <origin>4502</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="48051" sha1="1b541aksba3n8gnuirf64gfwfjiiuab" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;citation&quot; ) then sepc = &quot;,&quot; end 
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;.&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;.&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; ) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors ~= nil and Coauthors ~=&quot;&quot; ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; ) then
        Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc .. ' Retrieved ' .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and RFC ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = sepc ..&quot; &quot; .. url(frame, URL)
    else
       if (PMC ~= nil and PMC ~=&quot;&quot;)
         then URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC .. &quot;/?tool=pmcentrez&quot;
         else URL = &quot;&quot;
       end
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil ) then PostScript = PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil ) then ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil ) then PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot; else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil ) then Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; or
         config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position
    local enddot = sepc
    if (Title == &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(tcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;journal&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    tcommon = tcommon .. enddot
    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. sepc end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date end
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = string.sub(Date,-3) end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--
--End</text>
      <sha1>1b541aksba3n8gnuirf64gfwfjiiuab</sha1>
    </revision>
    <revision>
      <id>4503</id>
      <parentid>4502</parentid>
      <timestamp>2013-02-21T05:42:12Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>set enddot to end line when not class &quot;citation&quot;.</comment>
      <origin>4503</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="48420" sha1="n22b256p7rgfcq807xnazzi2wygfw64" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;citation&quot; ) then sepc = &quot;,&quot; end 
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;.&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;.&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; ) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors ~= nil and Coauthors ~=&quot;&quot; ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; ) then
        Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc .. ' Retrieved ' .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and RFC ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = sepc ..&quot; &quot; .. url(frame, URL)
    else
       if (PMC ~= nil and PMC ~=&quot;&quot;)
         then URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC .. &quot;/?tool=pmcentrez&quot;
         else URL = &quot;&quot;
       end
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil and PostScript ~=&quot;&quot; ) then
            PostScript = PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; or
         config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ID .. ISBN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. sepc end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date end
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = string.sub(Date,-3) end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--
--End</text>
      <sha1>n22b256p7rgfcq807xnazzi2wygfw64</sha1>
    </revision>
    <revision>
      <id>4504</id>
      <parentid>4503</parentid>
      <timestamp>2013-02-21T06:32:37Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>checked for person.last ~= &quot;&quot; and more tedious details.</comment>
      <origin>4504</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="48700" sha1="50gjo5a64hcted57d23zqzjph8em2cf" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot; &quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;citation&quot; ) then sepc = &quot;,&quot; end 
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;.&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;.&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors ~= nil and Coauthors ~=&quot;&quot; ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; ) then
        Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc .. ' Retrieved ' .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and RFC ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = sepc ..&quot; &quot; .. url(frame, URL)
    else
       if (PMC ~= nil and PMC ~=&quot;&quot;)
         then URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC .. &quot;/?tool=pmcentrez&quot;
         else URL = &quot;&quot;
       end
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil and PostScript ~=&quot;&quot; ) then
            PostScript = PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; or
         config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. sepc end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then Date = &quot; &quot; .. Date end
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = string.sub(Date,-3) end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 
--
--End</text>
      <sha1>50gjo5a64hcted57d23zqzjph8em2cf</sha1>
    </revision>
    <revision>
      <id>4505</id>
      <parentid>4504</parentid>
      <timestamp>2013-02-21T06:48:38Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>changed to omit double-dot before date when already dot.</comment>
      <origin>4505</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="48915" sha1="3uq79h86adyhw1scxsdlle9m8gikt7u" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot; &quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;citation&quot; ) then sepc = &quot;,&quot; end 
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;.&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;.&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors ~= nil and Coauthors ~=&quot;&quot; ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; ) then
        Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc .. ' Retrieved ' .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and RFC ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = sepc ..&quot; &quot; .. url(frame, URL)
    else
       if (PMC ~= nil and PMC ~=&quot;&quot;)
         then URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC .. &quot;/?tool=pmcentrez&quot;
         else URL = &quot;&quot;
       end
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil and PostScript ~=&quot;&quot; ) then
            PostScript = PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; or
         config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. sepc end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = string.sub(Date,-3) end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--
--End</text>
      <sha1>3uq79h86adyhw1scxsdlle9m8gikt7u</sha1>
    </revision>
    <revision>
      <id>4506</id>
      <parentid>4505</parentid>
      <timestamp>2013-02-21T07:05:39Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>fixed for empty Periodical ~= &quot;&quot;</comment>
      <origin>4506</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="48935" sha1="s0mlzhei6tp9afnbjr9pwd7kg3imk15" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot; &quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;citation&quot; ) then sepc = &quot;,&quot; end 
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;.&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;.&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors ~= nil and Coauthors ~=&quot;&quot; ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; ) then
        Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc .. ' Retrieved ' .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and RFC ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = sepc ..&quot; &quot; .. url(frame, URL)
    else
       if (PMC ~= nil and PMC ~=&quot;&quot;)
         then URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC .. &quot;/?tool=pmcentrez&quot;
         else URL = &quot;&quot;
       end
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil and PostScript ~=&quot;&quot; ) then
            PostScript = PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; or
         config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. sepc end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = string.sub(Date,-3) end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--
--End</text>
      <sha1>s0mlzhei6tp9afnbjr9pwd7kg3imk15</sha1>
    </revision>
    <revision>
      <id>4507</id>
      <parentid>4506</parentid>
      <timestamp>2013-02-21T07:17:34Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>removed PMC url when empty URL.</comment>
      <origin>4507</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="48778" sha1="ow8kf8iqvi7a4rgl6r8zeb5ityf00eh" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot; &quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;citation&quot; ) then sepc = &quot;,&quot; end 
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;.&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;.&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors ~= nil and Coauthors ~=&quot;&quot; ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; ) then
        Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc .. ' Retrieved ' .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and RFC ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil and PostScript ~=&quot;&quot; ) then
            PostScript = PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate .. &quot;.&quot;
        else
            Archived = &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate .. &quot;.&quot;
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; or
         config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. sepc end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = string.sub(Date,-3) end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--
--End</text>
      <sha1>ow8kf8iqvi7a4rgl6r8zeb5ityf00eh</sha1>
    </revision>
    <revision>
      <id>4508</id>
      <parentid>4507</parentid>
      <timestamp>2013-02-21T07:36:04Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>for config.CitationClass == &quot;journal&quot; reset empty URL to use PMC url if any.</comment>
      <origin>4508</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="49036" sha1="om7hat4z10xmgkx68mq6ccn2838318y" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot; &quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    end 
    if ( config.CitationClass == &quot;citation&quot; ) then sepc = &quot;,&quot; end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;.&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;.&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors ~= nil and Coauthors ~=&quot;&quot; ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; ) then
        Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc .. ' Retrieved ' .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and RFC ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil and PostScript ~=&quot;&quot; ) then
            PostScript = PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; or
         config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. sepc end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = string.sub(Date,-3) end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--
--End</text>
      <sha1>om7hat4z10xmgkx68mq6ccn2838318y</sha1>
    </revision>
    <revision>
      <id>4509</id>
      <parentid>4508</parentid>
      <timestamp>2013-02-21T07:57:07Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>for config.CitationClass &quot;citation&quot; reset order as: Volume, Issue, Publisher</comment>
      <origin>4509</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="49306" sha1="pbe83qqojvpi91utr5agtjlk8tre2zc" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot; &quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    end 
    if ( config.CitationClass == &quot;citation&quot; ) then sepc = &quot;,&quot; end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;.&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;.&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors ~= nil and Coauthors ~=&quot;&quot; ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; ) then
        Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc .. ' Retrieved ' .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and RFC ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil and PostScript ~=&quot;&quot; ) then
            PostScript = PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Volume .. Issue .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. sepc end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = string.sub(Date,-3) end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--
--End</text>
      <sha1>pbe83qqojvpi91utr5agtjlk8tre2zc</sha1>
    </revision>
    <revision>
      <id>4510</id>
      <parentid>4509</parentid>
      <timestamp>2013-02-21T08:32:15Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>fixed extra dot in &quot;].&quot; for TransTitle (etc.); set Bad-DOI warning.</comment>
      <origin>4510</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="49593" sha1="4xo9jo5axjyakd9nw2rmep7v737xhz1" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=strong&gt;Bad DOI (expected &quot;10.&quot; prefix)&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot; &quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    end 
    if ( config.CitationClass == &quot;citation&quot; ) then sepc = &quot;,&quot; end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors ~= nil and Coauthors ~=&quot;&quot; ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; ) then
        if ( string.len(Volume) &lt; 5 )
            then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; 
            else Volume = sepc ..&quot; &quot; .. Volume 
        end
    end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc .. ' Retrieved ' .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and RFC ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil and PostScript ~=&quot;&quot; ) then
            PostScript = PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Volume .. Issue .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. sepc end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = string.sub(Date,-3) end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--
--End</text>
      <sha1>4xo9jo5axjyakd9nw2rmep7v737xhz1</sha1>
    </revision>
    <revision>
      <id>4511</id>
      <parentid>4510</parentid>
      <timestamp>2013-02-21T08:36:41Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>reset warning as class=&quot;error&quot;</comment>
      <origin>4511</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="49597" sha1="7y9huuzh03j8dk6ao83b9m7r6s422t3" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt;Bad DOI (expected &quot;10.&quot; prefix)&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot; &quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    end 
    if ( config.CitationClass == &quot;citation&quot; ) then sepc = &quot;,&quot; end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors ~= nil and Coauthors ~=&quot;&quot; ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; ) then
        if ( string.length(Volume) &lt; 5 )
            then Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; 
            else Volume = sepc ..&quot; &quot; .. Volume 
        end
    end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc .. ' Retrieved ' .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and RFC ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil and PostScript ~=&quot;&quot; ) then
            PostScript = PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Volume .. Issue .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. sepc end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = string.sub(Date,-3) end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--
--End</text>
      <sha1>7y9huuzh03j8dk6ao83b9m7r6s422t3</sha1>
    </revision>
    <revision>
      <id>4512</id>
      <parentid>4511</parentid>
      <timestamp>2013-02-21T08:50:34Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>reset Volume</comment>
      <origin>4512</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="49703" sha1="ldvo5hrn3togs5fci6vwj8wfzjg4hb8" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt;Bad DOI (expected &quot;10.&quot; prefix)&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot; &quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    end 
    if ( config.CitationClass == &quot;citation&quot; ) then sepc = &quot;,&quot; end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors ~= nil and Coauthors ~=&quot;&quot; ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; ) then
        Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; 
    end
    if ( args.vol ~= nil and args.vol ~=&quot;&quot; ) then
        if ( string.len(args.vol) &lt; 5 )
            then Volume = &quot; &lt;b&gt;&quot; .. args.vol .. &quot;&lt;/b&gt;&quot; 
            else Volume = sepc ..&quot; &quot; .. args.vol 
        end
    end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc .. ' Retrieved ' .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and RFC ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil and PostScript ~=&quot;&quot; ) then
            PostScript = PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Volume .. Issue .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. sepc end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = string.sub(Date,-3) end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--
--End</text>
      <sha1>ldvo5hrn3togs5fci6vwj8wfzjg4hb8</sha1>
    </revision>
    <revision>
      <id>4513</id>
      <parentid>4512</parentid>
      <timestamp>2013-02-21T08:59:41Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>more</comment>
      <origin>4513</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="49713" sha1="mjegv1e9aiziyt118dour3nvis9ar1f" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix)&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot; &quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    end 
    if ( config.CitationClass == &quot;citation&quot; ) then sepc = &quot;,&quot; end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors ~= nil and Coauthors ~=&quot;&quot; ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; ) then
        Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; 
    end
    if ( args.vol ~= nil and args.vol ~=&quot;&quot; ) then
        if ( string.sub(args.vol,1,3) ~= &quot;vol&quot; )
            then Volume = &quot; &lt;b&gt;&quot; .. args.vol .. &quot;&lt;/b&gt;&quot; 
            else Volume = sepc ..&quot; &quot; .. args.vol 
        end
    end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc .. ' Retrieved ' .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and RFC ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil and PostScript ~=&quot;&quot; ) then
            PostScript = PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Volume .. Issue .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. sepc end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = string.sub(Date,-3) end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--
--End</text>
      <sha1>mjegv1e9aiziyt118dour3nvis9ar1f</sha1>
    </revision>
    <revision>
      <id>4514</id>
      <parentid>4513</parentid>
      <timestamp>2013-02-21T09:05:22Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>delete text until Lua crapnology works again</comment>
      <origin>4514</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="49488" sha1="5okhu9885iajrq5crl2j292skava1by" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix)&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot; &quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    end 
    if ( config.CitationClass == &quot;citation&quot; ) then sepc = &quot;,&quot; end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors ~= nil and Coauthors ~=&quot;&quot; ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; ) then
        Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; 
    end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc .. ' Retrieved ' .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and RFC ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil and PostScript ~=&quot;&quot; ) then
            PostScript = PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Volume .. Issue .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. sepc end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = string.sub(Date,-3) end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--
--End</text>
      <sha1>5okhu9885iajrq5crl2j292skava1by</sha1>
    </revision>
    <revision>
      <id>4515</id>
      <parentid>4514</parentid>
      <timestamp>2013-02-21T09:14:41Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>reverted 5 edits to salvage whatever works; again cut dots &quot;].&quot;</comment>
      <origin>4515</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="49304" sha1="5d5labcq7zn4whn8vrb55capftp1wkl" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot;
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot; &quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    end 
    if ( config.CitationClass == &quot;citation&quot; ) then sepc = &quot;,&quot; end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors ~= nil and Coauthors ~=&quot;&quot; ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; ) then
        Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc .. ' Retrieved ' .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and RFC ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil and PostScript ~=&quot;&quot; ) then
            PostScript = PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Volume .. Issue .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. sepc end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = string.sub(Date,-3) end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--
--End</text>
      <sha1>5d5labcq7zn4whn8vrb55capftp1wkl</sha1>
    </revision>
    <revision>
      <id>4516</id>
      <parentid>4515</parentid>
      <timestamp>2013-02-21T09:23:55Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>again, put Bad-DOI warning &amp; see if causes another &quot;Script error&quot;</comment>
      <origin>4516</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="49437" sha1="5un8cai1d95bwszxit11b217vwztr26" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix)&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot; &quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    end 
    if ( config.CitationClass == &quot;citation&quot; ) then sepc = &quot;,&quot; end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors ~= nil and Coauthors ~=&quot;&quot; ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; ) then
        Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot; else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc .. ' Retrieved ' .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and RFC ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil and PostScript ~=&quot;&quot; ) then
            PostScript = PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Volume .. Issue .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. sepc end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = string.sub(Date,-3) end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--
--End</text>
      <sha1>5un8cai1d95bwszxit11b217vwztr26</sha1>
    </revision>
    <revision>
      <id>4517</id>
      <parentid>4516</parentid>
      <timestamp>2013-02-21T09:38:31Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>again, set to automatically unbold volume+comma when &gt; 4 long.</comment>
      <origin>4517</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="49610" sha1="anilxbn4sqhygwcap9xlyrq65w3g809" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix)&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot; &quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    end 
    if ( config.CitationClass == &quot;citation&quot; ) then sepc = &quot;,&quot; end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors ~= nil and Coauthors ~=&quot;&quot; ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc .. ' Retrieved ' .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and RFC ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil and PostScript ~=&quot;&quot; ) then
            PostScript = PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Volume .. Issue .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. sepc end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = string.sub(Date,-3) end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--
--End</text>
      <sha1>anilxbn4sqhygwcap9xlyrq65w3g809</sha1>
    </revision>
    <revision>
      <id>4518</id>
      <parentid>4517</parentid>
      <timestamp>2013-02-21T14:51:29Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>changed to allow lowercase &quot;asin-tld&quot;; fixed typo to allow SSRN.</comment>
      <origin>4518</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="49697" sha1="4w26xmydxuycsxungp2dv4s32zd2716" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot; &quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    end 
    if ( config.CitationClass == &quot;citation&quot; ) then sepc = &quot;,&quot; end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors ~= nil and Coauthors ~=&quot;&quot; ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc .. ' Retrieved ' .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil and PostScript ~=&quot;&quot; ) then
            PostScript = PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Volume .. Issue .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. sepc end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then Year = string.sub(Date,-3) end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--
--End</text>
      <sha1>4w26xmydxuycsxungp2dv4s32zd2716</sha1>
    </revision>
    <revision>
      <id>4519</id>
      <parentid>4518</parentid>
      <timestamp>2013-02-22T04:44:48Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>fixed ref=harv to extract Year from Date</comment>
      <origin>4519</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="49879" sha1="1mvywgq10ums7kx5sseocououxesaot" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot; &quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    end 
    if ( config.CitationClass == &quot;citation&quot; ) then sepc = &quot;,&quot; end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors ~= nil and Coauthors ~=&quot;&quot; ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc .. ' Retrieved ' .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil and PostScript ~=&quot;&quot; ) then
            PostScript = PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Volume .. Issue .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. sepc end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {}
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--
--End</text>
      <sha1>1mvywgq10ums7kx5sseocououxesaot</sha1>
    </revision>
    <revision>
      <id>4520</id>
      <parentid>4519</parentid>
      <timestamp>2013-02-22T05:02:27Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>set Harvard reference span-tag id when config.CitationClass==&quot;citation&quot;</comment>
      <origin>4520</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="50017" sha1="q33me0anrxm8p1up6shzrvqsteq1tdv" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot; &quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    end 
    if ( config.CitationClass == &quot;citation&quot; ) then sepc = &quot;,&quot; end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors ~= nil and Coauthors ~=&quot;&quot; ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc .. ' Retrieved ' .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil and PostScript ~=&quot;&quot; ) then
            PostScript = PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Volume .. Issue .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. sepc end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local args = { class=&quot;citation &quot; .. (config.CitationClass or &quot;&quot;) }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref or config.CitationClass==&quot;citation&quot;) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;
--
--End</text>
      <sha1>q33me0anrxm8p1up6shzrvqsteq1tdv</sha1>
    </revision>
    <revision>
      <id>4521</id>
      <parentid>4520</parentid>
      <timestamp>2013-02-22T07:04:31Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot; &amp; set Ref=harv if nil</comment>
      <origin>4521</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="50271" sha1="3b5tv4ha14qrjvkaa7atxn0da3w0dty" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot; &quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    end 
    if ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors ~= nil and Coauthors ~=&quot;&quot; ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc .. ' Retrieved ' .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil and PostScript ~=&quot;&quot; ) then
            PostScript = PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Volume .. Issue .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. sepc end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref or config.CitationClass==&quot;citation&quot;) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--
--End</text>
      <sha1>3b5tv4ha14qrjvkaa7atxn0da3w0dty</sha1>
    </revision>
    <revision>
      <id>4522</id>
      <parentid>4521</parentid>
      <timestamp>2013-02-22T07:32:42Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>fixed ref=xx</comment>
      <origin>4522</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="50236" sha1="jqn2c8gzkida6w5ra1y0tjgaz5dn9d1" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot; &quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    end 
    if ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors ~= nil and Coauthors ~=&quot;&quot; ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc .. ' Retrieved ' .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil and PostScript ~=&quot;&quot; ) then
            PostScript = PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = &quot; [&quot; .. ArchiveURL .. &quot;  Archived] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. &quot; Archived from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Volume .. Issue .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. sepc end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--
--End</text>
      <sha1>jqn2c8gzkida6w5ra1y0tjgaz5dn9d1</sha1>
    </revision>
    <revision>
      <id>4523</id>
      <parentid>4522</parentid>
      <timestamp>2013-02-22T08:00:57Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot; separator.</comment>
      <origin>4523</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="50519" sha1="ptoq7g5fq00m3je8dzuvamy2um6m3k1" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot; &quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    end 
    if ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors ~= nil and Coauthors ~=&quot;&quot; ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    local retrv_text = ' retrieved '
    if (sepc == &quot;.&quot;) then retrv_text = ' Retrieved ' end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil and PostScript ~=&quot;&quot; ) then
            PostScript = PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end
    
    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Volume .. Issue .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors ) then Editors = &quot; in &quot; .. Editors .. sepc end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--
--End</text>
      <sha1>ptoq7g5fq00m3je8dzuvamy2um6m3k1</sha1>
    </revision>
    <revision>
      <id>4524</id>
      <parentid>4523</parentid>
      <timestamp>2013-02-23T02:10:06Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>fixed author's editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.</comment>
      <origin>4524</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="50707" sha1="1jilxydrz5l757ykts2d3j4rjpn86e9" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot;&amp;#32;&quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                one = &quot;et al&quot;
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors ~= nil and Coauthors ~=&quot;&quot; ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    local retrv_text = ' retrieved '
    if (sepc == &quot;.&quot;) then retrv_text = ' Retrieved ' end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil and PostScript ~=&quot;&quot; ) then
            PostScript = PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Volume .. Issue .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            Editors = in_text .. Editors .. sepc .. &quot; &quot;
        end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--
--End</text>
      <sha1>1jilxydrz5l757ykts2d3j4rjpn86e9</sha1>
    </revision>
    <revision>
      <id>4525</id>
      <parentid>4524</parentid>
      <timestamp>2013-02-23T04:34:00Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator; quickened other sepc text by moving inside gated-if structures</comment>
      <origin>4525</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="50896" sha1="4p15qyismz3jnr04p4knxbrecdldjii" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot;&amp;#32;&quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args[&quot;author1&quot;] or args[&quot;author&quot;]
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;] or args [&quot;first&quot;]
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors ~= nil and Coauthors ~=&quot;&quot; ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil and PostScript ~=&quot;&quot; ) then
            PostScript = PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Volume .. Issue .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            Editors = in_text .. Editors .. sepc .. &quot; &quot;
        end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--
--End</text>
      <sha1>4p15qyismz3jnr04p4knxbrecdldjii</sha1>
    </revision>
    <revision>
      <id>4526</id>
      <parentid>4525</parentid>
      <timestamp>2013-02-23T07:00:42Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>ensure &quot;author1-first&quot; also gets args.given or args.given1</comment>
      <origin>4526</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="51025" sha1="jfy8lq1jreq83ceh8is1va5sp7xc6j9" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot;&amp;#32;&quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.article or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors ~= nil and Coauthors ~=&quot;&quot; ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil and PostScript ~=&quot;&quot; ) then
            PostScript = PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Volume .. Issue .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            Editors = in_text .. Editors .. sepc .. &quot; &quot;
        end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--
--End</text>
      <sha1>jfy8lq1jreq83ceh8is1va5sp7xc6j9</sha1>
    </revision>
    <revision>
      <id>4527</id>
      <parentid>4526</parentid>
      <timestamp>2013-02-23T17:38:38Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>fixed args.article to set Title, after Periodical is set from Title; allowed blank Title (as &quot;contribution=mytitle&quot;); fixed &quot;..&quot; in Editors list</comment>
      <origin>4527</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="51753" sha1="elc9zrm2uezby6ehu5cv0mepktlnmul" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot;&amp;#32;&quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( args.article and args.article ~= &quot;&quot;) then
        if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
        Title = args.article
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors ~= nil and Coauthors ~=&quot;&quot; ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot;/?tool=pmcentrez&quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil and PostScript ~=&quot;&quot; ) then
            PostScript = PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;)
            then Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
            else Periodical = &quot;&lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Volume .. Others .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleType .. TitleNote .. Language .. Format .. Edition .. Conference .. Periodical .. Series .. Volume .. Issue .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleType .. TitleNote .. Series .. Language .. Format .. Edition .. Conference .. Periodical .. Volume .. Others .. Issue .. Publisher .. Agency .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--
--End</text>
      <sha1>elc9zrm2uezby6ehu5cv0mepktlnmul</sha1>
    </revision>
    <revision>
      <id>4528</id>
      <parentid>4527</parentid>
      <timestamp>2013-02-26T17:15:36Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>moved &quot;type=&quot; to show after &quot;format=&quot;; moved &quot;issue=&quot; to show before &quot;page=&quot;; for &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.</comment>
      <origin>4528</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="51924" sha1="15ji5lisivryxxt7g2lz95mg50t1i71" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot;&amp;#32;&quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( args.article and args.article ~= &quot;&quot;) then
        if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
        Title = args.article
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil ) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil ) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors ~= nil and Coauthors ~=&quot;&quot; ) then
      if ( Authors ~= nil ) then Coauthors = &quot;; &quot; .. Coauthors end
      if ( Date == nil ) then Coauthors = Coauthors .. sepc end
    else Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil and PostScript ~=&quot;&quot; ) then
            PostScript = PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;)
            then Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
            else Periodical = &quot;&lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Language .. Format .. TitleType .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Others .. Volume .. Others .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Language .. Format .. TitleType .. Edition .. Conference .. Periodical .. Series .. Volume .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Language .. Format .. TitleType .. Edition .. Conference .. Periodical .. Volume .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    local text
    if ( &quot;&quot; ~= Authors ) then
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Authors = Authors .. sepc .. &quot; &quot; end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Coauthors .. &quot; &quot;..Date .. Chapter .. Editors .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Issue .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--
--End</text>
      <sha1>15ji5lisivryxxt7g2lz95mg50t1i71</sha1>
    </revision>
    <revision>
      <id>4529</id>
      <parentid>4528</parentid>
      <timestamp>2013-02-27T04:53:49Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>for coauthors, omitted extra separator after authors; for date, allowed empty date to use month/day/year.</comment>
      <origin>4529</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="52080" sha1="qb3d20fshkf0lncv74r6pq01rt0x2li" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot;&amp;#32;&quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( args.article and args.article ~= &quot;&quot;) then
        if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
        Title = args.article
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil and PostScript ~=&quot;&quot; ) then
            PostScript = PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;)
            then Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
            else Periodical = &quot;&lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Language .. Format .. TitleType .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Others .. Volume .. Others .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Language .. Format .. TitleType .. Edition .. Conference .. Periodical .. Series .. Volume .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Language .. Format .. TitleType .. Edition .. Conference .. Periodical .. Volume .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else Authors = Authors .. sepc .. &quot; &quot;
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        Editors = Editors .. &quot; (eds.)&quot;
        if ( &quot;&quot; ~= Date ) then Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else Editors = Editors .. sepc .. &quot; &quot; end
        text = Editors .. Date .. Chapter .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Issue .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--
--End</text>
      <sha1>qb3d20fshkf0lncv74r6pq01rt0x2li</sha1>
    </revision>
    <revision>
      <id>4530</id>
      <parentid>4529</parentid>
      <timestamp>2013-02-27T05:22:47Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>reset editor suffix as &quot;, ed.&quot; when date exists</comment>
      <origin>4530</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="52385" sha1="jsyeytvawurdnnv8glnp43n5uv1sso5" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot;&amp;#32;&quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( args.article and args.article ~= &quot;&quot;) then
        if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
        Title = args.article
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = &quot; &quot; .. Others .. sepc else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = &quot; (&quot; .. TitleNote .. &quot;)&quot; else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil and PostScript ~=&quot;&quot; ) then
            PostScript = PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;)
            then Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
            else Periodical = &quot;&lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Language .. Format .. TitleType .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Others .. Volume .. Others .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Language .. Format .. TitleType .. Edition .. Conference .. Periodical .. Series .. Volume .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Language .. Format .. TitleType .. Edition .. Conference .. Periodical .. Volume .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,1) == sepc)
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            Editors = Editors .. &quot;, ed.&quot;
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
        end
        text = Editors .. Date .. Chapter .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Issue .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--
--End</text>
      <sha1>jsyeytvawurdnnv8glnp43n5uv1sso5</sha1>
    </revision>
    <revision>
      <id>4531</id>
      <parentid>4530</parentid>
      <timestamp>2013-02-27T06:48:27Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>removed duplicate display of &quot;others=&quot; data.</comment>
      <origin>4531</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="52501" sha1="54vqupc7jfaeu8zxs3mehnwytcc7fnb" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot;&amp;#32;&quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( args.article and args.article ~= &quot;&quot;) then
        if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
        Title = args.article
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil and PostScript ~=&quot;&quot; ) then
            PostScript = PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;)
            then Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
            else Periodical = &quot;&lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Language .. Format .. TitleType .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Others .. Volume .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Language .. Format .. TitleType .. Edition .. Conference .. Periodical .. Series .. Volume .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Language .. Format .. TitleType .. Edition .. Conference .. Periodical .. Volume .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,1) == sepc)
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            Editors = Editors .. &quot;, ed.&quot;
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
        end
        text = Editors .. Date .. Chapter .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Issue .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--
--End</text>
      <sha1>54vqupc7jfaeu8zxs3mehnwytcc7fnb</sha1>
    </revision>
    <revision>
      <id>4532</id>
      <parentid>4531</parentid>
      <timestamp>2013-02-27T14:26:13Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>fixed double-dot &quot;..&quot; at end of authors/coauthors list</comment>
      <origin>4532</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="52524" sha1="ihe4uqeb1yxfx1ogy7zv55h8ni6h27g" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot;&amp;#32;&quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( args.article and args.article ~= &quot;&quot;) then
        if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
        Title = args.article
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; edition)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil and PostScript ~=&quot;&quot; ) then
            PostScript = PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
        Edition = &quot;&quot;
    else
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;)
            then Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
            else Periodical = &quot;&lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Language .. Format .. TitleType .. Edition .. Conference .. Periodical .. Series .. Publisher .. Agency .. Others .. Volume .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Language .. Format .. TitleType .. Edition .. Conference .. Periodical .. Series .. Volume .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Language .. Format .. TitleType .. Edition .. Conference .. Periodical .. Volume .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            Editors = Editors .. &quot;, ed.&quot;
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
        end
        text = Editors .. Date .. Chapter .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Issue .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--
--End</text>
      <sha1>ihe4uqeb1yxfx1ogy7zv55h8ni6h27g</sha1>
    </revision>
    <revision>
      <id>4533</id>
      <parentid>4532</parentid>
      <timestamp>2013-03-05T16:13:30Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>moved Language to follow Periodical or Series; fixed Edition to follow Series or Volume; fixed class &quot;encyclopaedia&quot; to show article as quoted Chapter.</comment>
      <origin>4533</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="53328" sha1="80arxuodhr51dfpdjrswlm0kd0ns3cm" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot;&amp;#32;&quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil and PostScript ~=&quot;&quot; ) then
            PostScript = PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; &quot; .. PublicationDate else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate ~= nil and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate else Publisher = &quot;&quot; end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;)
            then Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
            else Periodical = &quot;&lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            Editors = Editors .. &quot;, ed.&quot;
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
        end
        text = Editors .. Date .. Chapter .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Issue .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core).
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      might be a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--
--End</text>
      <sha1>80arxuodhr51dfpdjrswlm0kd0ns3cm</sha1>
    </revision>
    <revision>
      <id>4534</id>
      <parentid>4533</parentid>
      <timestamp>2013-03-07T14:36:17Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>changed class &quot;encyclopaedia&quot; to omit &quot;(__)&quot; around publisher; updated internal notes.</comment>
      <origin>4534</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="53653" sha1="nk6yuz9cp4vb29w7609vnmwg46zd2c7" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot;&amp;#32;&quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote ~= nil and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript ~= nil and PostScript ~=&quot;&quot; ) then
            PostScript = PostScript else PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
            else Publisher = &quot;&quot;
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;)
            then Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
            else Periodical = &quot;&lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            Editors = Editors .. &quot;, ed.&quot;
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
        end
        text = Editors .. Date .. Chapter .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Issue .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--
--End</text>
      <sha1>nk6yuz9cp4vb29w7609vnmwg46zd2c7</sha1>
    </revision>
    <revision>
      <id>4535</id>
      <parentid>4534</parentid>
      <timestamp>2013-03-07T15:29:35Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>fixed final double-dot by &quot;string.sub(idcommon,-1,-1)&quot; which had &quot;-1,1&quot;.</comment>
      <origin>4535</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="53660" sha1="7mw49dmfs2qw5n2oyndpwy26ug8fnpz" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot;&amp;#32;&quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
            else Publisher = &quot;&quot;
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;)
            then Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
            else Periodical = &quot;&lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            Editors = Editors .. &quot;, ed.&quot;
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
        end
        text = Editors .. Date .. Chapter .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Issue .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={class=&quot;Z3988&quot;,title=OCinStitle,style=&quot;display: none;&quot;}}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--
--End</text>
      <sha1>7mw49dmfs2qw5n2oyndpwy26ug8fnpz</sha1>
    </revision>
    <revision>
      <id>4536</id>
      <parentid>4535</parentid>
      <timestamp>2013-03-12T00:03:40Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>COinS issue explained on talk</comment>
      <origin>4536</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="53825" sha1="qfbzxhrrjly90ba751jdrxj43s6d4xe" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot;&amp;#32;&quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;no&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
            else Publisher = &quot;&quot;
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;)
            then Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
            else Periodical = &quot;&lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            Editors = Editors .. &quot;, ed.&quot;
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
        end
        text = Editors .. Date .. Chapter .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Issue .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--
--End</text>
      <sha1>qfbzxhrrjly90ba751jdrxj43s6d4xe</sha1>
    </revision>
    <revision>
      <id>4537</id>
      <parentid>4536</parentid>
      <timestamp>2013-03-13T02:47:23Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>wrong default behavior</comment>
      <origin>4537</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="53826" sha1="of8w5390lhe2cx5lvbw0hu1wi3y82jl" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. args.prefix .. z.mw.url.encode(args.id) .. args.suffix .. &quot; &quot; .. nowiki(frame, args.id) .. &quot;]&quot;)
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot;&amp;#32;&quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
            else Publisher = &quot;&quot;
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;)
            then Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
            else Periodical = &quot;&lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            Editors = Editors .. &quot;, ed.&quot;
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
        end
        text = Editors .. Date .. Chapter .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Issue .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--
--End</text>
      <sha1>of8w5390lhe2cx5lvbw0hu1wi3y82jl</sha1>
    </revision>
    <revision>
      <id>4538</id>
      <parentid>4537</parentid>
      <timestamp>2013-03-13T03:40:56Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>make encoding optional and cut down on pointless / broken encoding</comment>
      <origin>4538</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="54032" sha1="i7cvdyyw34lznj7kyklqxwsu6rfb14v" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot;&amp;#32;&quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN,encode=false}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
            else Publisher = &quot;&quot;
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;)
            then Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
            else Periodical = &quot;&lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            Editors = Editors .. &quot;, ed.&quot;
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
        end
        text = Editors .. Date .. Chapter .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Issue .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--
--End</text>
      <sha1>i7cvdyyw34lznj7kyklqxwsu6rfb14v</sha1>
    </revision>
    <revision>
      <id>4539</id>
      <parentid>4538</parentid>
      <timestamp>2013-03-13T03:43:35Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <minor />
      <comment>doesn't apply to internal link</comment>
      <origin>4539</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="54019" sha1="oi18n8fr57ft27h13bt4va6623nz1p5" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot;&amp;#32;&quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
            else Publisher = &quot;&quot;
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;)
            then Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
            else Periodical = &quot;&lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            Editors = Editors .. &quot;, ed.&quot;
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
        end
        text = Editors .. Date .. Chapter .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Issue .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--
--End</text>
      <sha1>oi18n8fr57ft27h13bt4va6623nz1p5</sha1>
    </revision>
    <revision>
      <id>4540</id>
      <parentid>4539</parentid>
      <timestamp>2013-03-13T03:46:34Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>drop extra quotation marks</comment>
      <origin>4540</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="54139" sha1="sgb7ujv5brxo242k0iyh7dsfagkn5va" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot;&amp;#32;&quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
            else Publisher = &quot;&quot;
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;)
            then Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
            else Periodical = &quot;&lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            Editors = Editors .. &quot;, ed.&quot;
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
        end
        text = Editors .. Date .. Chapter .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Issue .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--
--End</text>
      <sha1>sgb7ujv5brxo242k0iyh7dsfagkn5va</sha1>
    </revision>
    <revision>
      <id>4541</id>
      <parentid>4540</parentid>
      <timestamp>2013-03-13T03:47:06Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>oops</comment>
      <origin>4541</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="54143" sha1="ihc1agiq4cds38vczzcodt8z5xm5ywo" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot;&amp;#32;&quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors = listpeople(control, e) 
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
            else Publisher = &quot;&quot;
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;)
            then Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
            else Periodical = &quot;&lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            Editors = Editors .. &quot;, ed.&quot;
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
        end
        text = Editors .. Date .. Chapter .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Issue .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--
--End</text>
      <sha1>ihc1agiq4cds38vczzcodt8z5xm5ywo</sha1>
    </revision>
    <revision>
      <id>4542</id>
      <parentid>4541</parentid>
      <timestamp>2013-03-13T03:59:37Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>plural option for editors</comment>
      <origin>4542</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="54532" sha1="ljw1q5az696ls56p83230d50qgk77wz" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, broken, inactive, nocat)
    local text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
    local cat = &quot;&quot;
    if ( inactive ~= nil ) then 
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot;&amp;#32;&quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
            else Publisher = &quot;&quot;
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;)
            then Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
            else Periodical = &quot;&lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Issue .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--
--End</text>
      <sha1>ljw1q5az696ls56p83230d50qgk77wz</sha1>
    </revision>
    <revision>
      <id>4543</id>
      <parentid>4542</parentid>
      <timestamp>2013-03-13T04:18:51Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>fix inactive doi</comment>
      <origin>4543</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="54597" sha1="qr6addzianwbx0ynlbkfm5sbnflq12f" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot;&amp;#32;&quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
            else Publisher = &quot;&quot;
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;)
            then Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
            else Periodical = &quot;&lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Issue .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--
--End</text>
      <sha1>qr6addzianwbx0ynlbkfm5sbnflq12f</sha1>
    </revision>
    <revision>
      <id>4544</id>
      <parentid>4543</parentid>
      <timestamp>2013-03-13T09:46:20Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>removed enddot &quot;.&quot; after &quot;quote=&quot; parameter; changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.</comment>
      <origin>4544</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="54865" sha1="n1sms0hxs15vwaovidddlgnf3wkfcpc" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot;&amp;#32;&quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
            else Publisher = &quot;&quot;
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;)
            then Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
            else Periodical = &quot;&lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Issue .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--
--End</text>
      <sha1>n1sms0hxs15vwaovidddlgnf3wkfcpc</sha1>
    </revision>
    <revision>
      <id>4545</id>
      <parentid>4544</parentid>
      <timestamp>2013-03-13T10:39:32Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>fixed missing &quot;location=&quot; for class &quot;web&quot; or &quot;encyclopaedia&quot;</comment>
      <origin>4545</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="55023" sha1="d7jjw821s4201dgk1tebrzvs8msaxfw" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot;&amp;#32;&quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~=nil) then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;)
            then Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
            else Periodical = &quot;&lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Issue .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--
--End</text>
      <sha1>d7jjw821s4201dgk1tebrzvs8msaxfw</sha1>
    </revision>
    <revision>
      <id>4546</id>
      <parentid>4545</parentid>
      <timestamp>2013-03-13T17:00:50Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>fix ordering</comment>
      <origin>4546</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="55023" sha1="an277pkxpc6nhguhyeu5304lzn7tasv" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot;&amp;#32;&quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;&lt;i&gt;&quot; .. Title .. &quot;&lt;/i&gt;&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~=nil) then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;)
            then Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
            else Periodical = &quot;&lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Issue .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--
--End</text>
      <sha1>an277pkxpc6nhguhyeu5304lzn7tasv</sha1>
    </revision>
    <revision>
      <id>4547</id>
      <parentid>4546</parentid>
      <timestamp>2013-03-13T17:06:23Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>Try Wikipedia style italics, should work better for titles with embedded italics</comment>
      <origin>4547</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="55020" sha1="s94swnlz9y5lqbvf4kgwm48bc4j04km" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot;&amp;#32;&quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;&lt;i&gt;&quot; .. Chapter .. &quot;&lt;/i&gt;&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; &lt;i&gt;&quot; .. LaySource .. &quot;&lt;/i&gt;&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~=nil) then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;)
            then Periodical = sepc .. &quot; &lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
            else Periodical = &quot;&lt;i&gt;&quot; .. Periodical .. &quot;&lt;/i&gt;&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Issue .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--
--End</text>
      <sha1>s94swnlz9y5lqbvf4kgwm48bc4j04km</sha1>
    </revision>
    <revision>
      <id>4548</id>
      <parentid>4547</parentid>
      <timestamp>2013-03-13T17:12:21Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>switch other italic tags to wikistyle italics, should be more consistent with prior style when input contains italics</comment>
      <origin>4548</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="55008" sha1="tqeeeuj01blkr701ielag6l6vcj5w9b" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot;&amp;#32;&quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page = args.p or args.page
    local pages = args.pp or args.pages
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~=nil) then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;)
            then Periodical = sepc .. &quot; ''&quot; .. Periodical .. &quot;''&quot;
            else Periodical = &quot;''&quot; .. Periodical .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Issue .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--
--End</text>
      <sha1>tqeeeuj01blkr701ielag6l6vcj5w9b</sha1>
    </revision>
    <revision>
      <id>4549</id>
      <parentid>4548</parentid>
      <timestamp>2013-03-13T17:20:31Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>only load page if pages doesn't exist</comment>
      <origin>4549</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="55071" sha1="cvhh8gl7ahvh2x9vehk8b4lgz87nxwc" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot;&amp;#32;&quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.page
    local Pages = args.pages
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~=nil) then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;)
            then Periodical = sepc .. &quot; ''&quot; .. Periodical .. &quot;''&quot;
            else Periodical = &quot;''&quot; .. Periodical .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Issue .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--
--End</text>
      <sha1>cvhh8gl7ahvh2x9vehk8b4lgz87nxwc</sha1>
    </revision>
    <revision>
      <id>4550</id>
      <parentid>4549</parentid>
      <timestamp>2013-03-13T17:25:53Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>only load page if pages doesn't exist</comment>
      <origin>4550</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="55166" sha1="a3ucrihexy7f6648fidpv47z0a7l19k" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep .. &quot;&amp;#32;&quot;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    end
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~=nil) then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;)
            then Periodical = sepc .. &quot; ''&quot; .. Periodical .. &quot;''&quot;
            else Periodical = &quot;''&quot; .. Periodical .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Issue .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--
--End</text>
      <sha1>a3ucrihexy7f6648fidpv47z0a7l19k</sha1>
    </revision>
    <revision>
      <id>4551</id>
      <parentid>4550</parentid>
      <timestamp>2013-03-13T17:28:32Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>avoid excess spaces, also coding seems unnecessary here</comment>
      <origin>4551</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="55211" sha1="roxbqmang32smrcs5u8yz6todkyj7xw" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    end
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. Chapter .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. Chapter .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. Title .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. Conference .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~=nil) then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;)
            then Periodical = sepc .. &quot; ''&quot; .. Periodical .. &quot;''&quot;
            else Periodical = &quot;''&quot; .. Periodical .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Issue .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--
--End</text>
      <sha1>roxbqmang32smrcs5u8yz6todkyj7xw</sha1>
    </revision>
    <revision>
      <id>4552</id>
      <parentid>4551</parentid>
      <timestamp>2013-03-13T17:41:30Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>add escaping of url arguments</comment>
      <origin>4552</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="55357" sha1="ju6z3rxfhkjutdelga4gwvt3n9if4qm" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:replace('[','&amp;#91;'):replace(']','&amp;#93;')
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    end
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~=nil) then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;)
            then Periodical = sepc .. &quot; ''&quot; .. Periodical .. &quot;''&quot;
            else Periodical = &quot;''&quot; .. Periodical .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Issue .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--
--End</text>
      <sha1>ju6z3rxfhkjutdelga4gwvt3n9if4qm</sha1>
    </revision>
    <revision>
      <id>4553</id>
      <parentid>4552</parentid>
      <timestamp>2013-03-13T17:42:35Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>oops</comment>
      <origin>4553</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="55351" sha1="ny52omvqcq6thak8gz7n1a7aehyapaj" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('[','&amp;#91;'):gsub(']','&amp;#93;')
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    end
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~=nil) then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;)
            then Periodical = sepc .. &quot; ''&quot; .. Periodical .. &quot;''&quot;
            else Periodical = &quot;''&quot; .. Periodical .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Issue .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--
--End</text>
      <sha1>ny52omvqcq6thak8gz7n1a7aehyapaj</sha1>
    </revision>
    <revision>
      <id>4554</id>
      <parentid>4553</parentid>
      <timestamp>2013-03-13T17:43:18Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>pattern escaping, yay</comment>
      <origin>4554</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="55353" sha1="t88vju688htu9vbcbr9ilq2wmcrup87" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;')
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    end
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~=nil) then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;)
            then Periodical = sepc .. &quot; ''&quot; .. Periodical .. &quot;''&quot;
            else Periodical = &quot;''&quot; .. Periodical .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Issue .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--
--End</text>
      <sha1>t88vju688htu9vbcbr9ilq2wmcrup87</sha1>
    </revision>
    <revision>
      <id>4555</id>
      <parentid>4554</parentid>
      <timestamp>2013-03-14T01:23:41Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>and newline to url filter</comment>
      <origin>4555</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="55370" sha1="a9xfgt1day5w3cgu9dcyso78jv5wsbs" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    end
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~=nil) then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;)
            then Periodical = sepc .. &quot; ''&quot; .. Periodical .. &quot;''&quot;
            else Periodical = &quot;''&quot; .. Periodical .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Issue .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--
--End</text>
      <sha1>a9xfgt1day5w3cgu9dcyso78jv5wsbs</sha1>
    </revision>
    <revision>
      <id>4556</id>
      <parentid>4555</parentid>
      <timestamp>2013-03-14T01:27:13Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>special case of italic plus dot</comment>
      <origin>4556</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="55445" sha1="n6g3mzb4qek9h8j4luiob216gdyh9zd" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    end
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~=nil) then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;)
            then Periodical = sepc .. &quot; ''&quot; .. Periodical .. &quot;''&quot;
            else Periodical = &quot;''&quot; .. Periodical .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-3,-1) == sepc .. &quot;''&quot; ) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Issue .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--
--End</text>
      <sha1>n6g3mzb4qek9h8j4luiob216gdyh9zd</sha1>
    </revision>
    <revision>
      <id>4557</id>
      <parentid>4556</parentid>
      <timestamp>2013-03-14T01:28:43Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>rv, that didn't work</comment>
      <origin>4557</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="55370" sha1="a9xfgt1day5w3cgu9dcyso78jv5wsbs" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    end
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~=nil) then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;)
            then Periodical = sepc .. &quot; ''&quot; .. Periodical .. &quot;''&quot;
            else Periodical = &quot;''&quot; .. Periodical .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Issue .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--
--End</text>
      <sha1>a9xfgt1day5w3cgu9dcyso78jv5wsbs</sha1>
    </revision>
    <revision>
      <id>4558</id>
      <parentid>4557</parentid>
      <timestamp>2013-03-14T01:49:00Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>alternative form</comment>
      <origin>4558</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="55398" sha1="5rufdx9rv1s64021w7njf5euayt86c8" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    end
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~=nil) then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~=nil) then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;)
            then Periodical = sepc .. &quot; ''&quot; .. Periodical .. &quot;''&quot;
            else Periodical = &quot;''&quot; .. Periodical .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Issue .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--
--End</text>
      <sha1>5rufdx9rv1s64021w7njf5euayt86c8</sha1>
    </revision>
    <revision>
      <id>4559</id>
      <parentid>4558</parentid>
      <timestamp>2013-03-14T01:57:47Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>empty checking</comment>
      <origin>4559</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="55438" sha1="cptytwlarcirmzyt5ml8udve5re7wax" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    end
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;)
            then Periodical = sepc .. &quot; ''&quot; .. Periodical .. &quot;''&quot;
            else Periodical = &quot;''&quot; .. Periodical .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon .. Issue .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Issue .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--
--End</text>
      <sha1>cptytwlarcirmzyt5ml8udve5re7wax</sha1>
    </revision>
    <revision>
      <id>4560</id>
      <parentid>4559</parentid>
      <timestamp>2013-03-14T02:22:49Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>Move issue next to volume, is this going to break lots of things?</comment>
      <origin>4560</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="55438" sha1="155uz6a9y559lj9nxluocvq16iwk0rt" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    end
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; else LaySource = &quot;&quot; end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;)
            then Periodical = sepc .. &quot; ''&quot; .. Periodical .. &quot;''&quot;
            else Periodical = &quot;''&quot; .. Periodical .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--
--End</text>
      <sha1>155uz6a9y559lj9nxluocvq16iwk0rt</sha1>
    </revision>
    <revision>
      <id>4561</id>
      <parentid>4560</parentid>
      <timestamp>2013-03-14T03:54:45Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>sanity check the italics for other single quotes</comment>
      <origin>4561</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="56117" sha1="h8kiroy5k6tnudhm3mnktiud83iag3p" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    end
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            if Chapter:sub(1,1) == &quot;'&quot; then Chapter = &quot; &quot; .. Chapter; end
            if Chapter:sub(-1,-1) == &quot;'&quot; then Chapter = Chapter .. &quot; &quot;; end
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            if Title:sub(1,1) == &quot;'&quot; then Title = &quot; &quot; .. Title; end
            if Title:sub(-1,-1) == &quot;'&quot; then Title = Title .. &quot; &quot;; end
            
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            if LaySource:sub(1,1) == &quot;'&quot; then LaySource = &quot; &quot; .. LaySource; end
            if LaySource:sub(-1,-1) == &quot;'&quot; then LaySource = LaySource .. &quot; &quot;; end

            LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if Periodical:sub(1,1) == &quot;'&quot; then Periodical = &quot; &quot; .. Periodical; end
        if Periodical:sub(-1,-1) == &quot;'&quot; then Periodical = Periodical .. &quot; &quot;; end

        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. Periodical .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. Periodical .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--
--End</text>
      <sha1>h8kiroy5k6tnudhm3mnktiud83iag3p</sha1>
    </revision>
    <revision>
      <id>4562</id>
      <parentid>4561</parentid>
      <timestamp>2013-03-14T03:58:42Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>Use empty spans rather than spaces</comment>
      <origin>4562</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="56173" sha1="hokqvqn26zqrqbv0qz0n82k4v0gqdx9" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    end
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            if Chapter:sub(1,1) == &quot;'&quot; then Chapter = &quot;&lt;span /&gt;&quot; .. Chapter; end
            if Chapter:sub(-1,-1) == &quot;'&quot; then Chapter = Chapter .. &quot;&lt;span /&gt;&quot;; end
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            if Title:sub(1,1) == &quot;'&quot; then Title = &quot;&lt;span /&gt;&quot; .. Title; end
            if Title:sub(-1,-1) == &quot;'&quot; then Title = Title .. &quot;&lt;span /&gt;&quot;; end
            
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            if LaySource:sub(1,1) == &quot;'&quot; then LaySource = &quot;&lt;span /&gt;&quot; .. LaySource; end
            if LaySource:sub(-1,-1) == &quot;'&quot; then LaySource = LaySource .. &quot;&lt;span /&gt;&quot;; end

            LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if Periodical:sub(1,1) == &quot;'&quot; then Periodical = &quot;&lt;span /&gt;&quot; .. Periodical; end
        if Periodical:sub(-1,-1) == &quot;'&quot; then Periodical = Periodical .. &quot;&lt;span /&gt;&quot;; end

        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. Periodical .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. Periodical .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--
--End</text>
      <sha1>hokqvqn26zqrqbv0qz0n82k4v0gqdx9</sha1>
    </revision>
    <revision>
      <id>4563</id>
      <parentid>4562</parentid>
      <timestamp>2013-03-14T15:28:18Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>Treat PublicationDate as Date is Date is absent</comment>
      <origin>4563</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="56319" sha1="h1c1bxh2635uk5pu3sa9o7452qcxuja" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    end
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            if Chapter:sub(1,1) == &quot;'&quot; then Chapter = &quot;&lt;span /&gt;&quot; .. Chapter; end
            if Chapter:sub(-1,-1) == &quot;'&quot; then Chapter = Chapter .. &quot;&lt;span /&gt;&quot;; end
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            if Title:sub(1,1) == &quot;'&quot; then Title = &quot;&lt;span /&gt;&quot; .. Title; end
            if Title:sub(-1,-1) == &quot;'&quot; then Title = Title .. &quot;&lt;span /&gt;&quot;; end
            
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            if LaySource:sub(1,1) == &quot;'&quot; then LaySource = &quot;&lt;span /&gt;&quot; .. LaySource; end
            if LaySource:sub(-1,-1) == &quot;'&quot; then LaySource = LaySource .. &quot;&lt;span /&gt;&quot;; end

            LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if Periodical:sub(1,1) == &quot;'&quot; then Periodical = &quot;&lt;span /&gt;&quot; .. Periodical; end
        if Periodical:sub(-1,-1) == &quot;'&quot; then Periodical = Periodical .. &quot;&lt;span /&gt;&quot;; end

        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. Periodical .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. Periodical .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if (DateIn == nil or DateIn == &quot;&quot;)
          then Year = &quot;&quot;
          else Year = string.sub(DateIn,-4,-1)
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--
--End</text>
      <sha1>h1c1bxh2635uk5pu3sa9o7452qcxuja</sha1>
    </revision>
    <revision>
      <id>4564</id>
      <parentid>4563</parentid>
      <timestamp>2013-03-14T17:13:16Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>Try to fix year handling for CITEREF</comment>
      <origin>4564</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="56695" sha1="8a8yeag0uu58y19sbcfjdc0jj95j0nm" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local DateIn = Date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    end
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            if Chapter:sub(1,1) == &quot;'&quot; then Chapter = &quot;&lt;span /&gt;&quot; .. Chapter; end
            if Chapter:sub(-1,-1) == &quot;'&quot; then Chapter = Chapter .. &quot;&lt;span /&gt;&quot;; end
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            if Title:sub(1,1) == &quot;'&quot; then Title = &quot;&lt;span /&gt;&quot; .. Title; end
            if Title:sub(-1,-1) == &quot;'&quot; then Title = Title .. &quot;&lt;span /&gt;&quot;; end
            
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            if LaySource:sub(1,1) == &quot;'&quot; then LaySource = &quot;&lt;span /&gt;&quot; .. LaySource; end
            if LaySource:sub(-1,-1) == &quot;'&quot; then LaySource = LaySource .. &quot;&lt;span /&gt;&quot;; end

            LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if Periodical:sub(1,1) == &quot;'&quot; then Periodical = &quot;&lt;span /&gt;&quot; .. Periodical; end
        if Periodical:sub(-1,-1) == &quot;'&quot; then Periodical = Periodical .. &quot;&lt;span /&gt;&quot;; end

        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. Periodical .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. Periodical .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--
--End</text>
      <sha1>8a8yeag0uu58y19sbcfjdc0jj95j0nm</sha1>
    </revision>
    <revision>
      <id>4565</id>
      <parentid>4564</parentid>
      <timestamp>2013-03-14T17:17:56Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>try again</comment>
      <origin>4565</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="56788" sha1="exw5vww6jk6vie7gqi0xv75259em9bw" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. z.wikitext.canonicalcleanuptime(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    end
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            if Chapter:sub(1,1) == &quot;'&quot; then Chapter = &quot;&lt;span /&gt;&quot; .. Chapter; end
            if Chapter:sub(-1,-1) == &quot;'&quot; then Chapter = Chapter .. &quot;&lt;span /&gt;&quot;; end
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            if Title:sub(1,1) == &quot;'&quot; then Title = &quot;&lt;span /&gt;&quot; .. Title; end
            if Title:sub(-1,-1) == &quot;'&quot; then Title = Title .. &quot;&lt;span /&gt;&quot;; end
            
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            if LaySource:sub(1,1) == &quot;'&quot; then LaySource = &quot;&lt;span /&gt;&quot; .. LaySource; end
            if LaySource:sub(-1,-1) == &quot;'&quot; then LaySource = LaySource .. &quot;&lt;span /&gt;&quot;; end

            LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if Periodical:sub(1,1) == &quot;'&quot; then Periodical = &quot;&lt;span /&gt;&quot; .. Periodical; end
        if Periodical:sub(-1,-1) == &quot;'&quot; then Periodical = Periodical .. &quot;&lt;span /&gt;&quot;; end

        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. Periodical .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. Periodical .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--
--End</text>
      <sha1>exw5vww6jk6vie7gqi0xv75259em9bw</sha1>
    </revision>
    <revision>
      <id>4566</id>
      <parentid>4565</parentid>
      <timestamp>2013-03-14T17:22:57Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>DOI cleanup is organized by year</comment>
      <origin>4566</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="56767" sha1="mhgiejdefkqxbs6f6dlc5xi7z4c3cq7" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                local etal_text = &quot;et al.&quot;
                if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
                one = etal_text
            elseif ( maximum ~= nil and i &gt; maximum + 1 ) then
                break
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    end
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            if Chapter:sub(1,1) == &quot;'&quot; then Chapter = &quot;&lt;span /&gt;&quot; .. Chapter; end
            if Chapter:sub(-1,-1) == &quot;'&quot; then Chapter = Chapter .. &quot;&lt;span /&gt;&quot;; end
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            if Title:sub(1,1) == &quot;'&quot; then Title = &quot;&lt;span /&gt;&quot; .. Title; end
            if Title:sub(-1,-1) == &quot;'&quot; then Title = Title .. &quot;&lt;span /&gt;&quot;; end
            
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            if LaySource:sub(1,1) == &quot;'&quot; then LaySource = &quot;&lt;span /&gt;&quot; .. LaySource; end
            if LaySource:sub(-1,-1) == &quot;'&quot; then LaySource = LaySource .. &quot;&lt;span /&gt;&quot;; end

            LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if Periodical:sub(1,1) == &quot;'&quot; then Periodical = &quot;&lt;span /&gt;&quot; .. Periodical; end
        if Periodical:sub(-1,-1) == &quot;'&quot; then Periodical = Periodical .. &quot;&lt;span /&gt;&quot;; end

        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. Periodical .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. Periodical .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--
--End</text>
      <sha1>mhgiejdefkqxbs6f6dlc5xi7z4c3cq7</sha1>
    </revision>
    <revision>
      <id>4567</id>
      <parentid>4566</parentid>
      <timestamp>2013-03-14T17:47:02Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>get the semicolon off the et al.</comment>
      <origin>4567</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="56786" sha1="gc4p4tpyc4macpxopy8n45p9phh50a9" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    end
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            if Chapter:sub(1,1) == &quot;'&quot; then Chapter = &quot;&lt;span /&gt;&quot; .. Chapter; end
            if Chapter:sub(-1,-1) == &quot;'&quot; then Chapter = Chapter .. &quot;&lt;span /&gt;&quot;; end
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            if Title:sub(1,1) == &quot;'&quot; then Title = &quot;&lt;span /&gt;&quot; .. Title; end
            if Title:sub(-1,-1) == &quot;'&quot; then Title = Title .. &quot;&lt;span /&gt;&quot;; end
            
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            if LaySource:sub(1,1) == &quot;'&quot; then LaySource = &quot;&lt;span /&gt;&quot; .. LaySource; end
            if LaySource:sub(-1,-1) == &quot;'&quot; then LaySource = LaySource .. &quot;&lt;span /&gt;&quot;; end

            LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if Periodical:sub(1,1) == &quot;'&quot; then Periodical = &quot;&lt;span /&gt;&quot; .. Periodical; end
        if Periodical:sub(-1,-1) == &quot;'&quot; then Periodical = Periodical .. &quot;&lt;span /&gt;&quot;; end

        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. Periodical .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. Periodical .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--
--End</text>
      <sha1>gc4p4tpyc4macpxopy8n45p9phh50a9</sha1>
    </revision>
    <revision>
      <id>4568</id>
      <parentid>4567</parentid>
      <timestamp>2013-03-14T18:34:34Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>fixed end double-dot after book/work title (very rare).</comment>
      <origin>4568</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="56960" sha1="0ht6nradvz3qte6ezcic761zv56xqke" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    end
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            if Chapter:sub(1,1) == &quot;'&quot; then Chapter = &quot;&lt;span /&gt;&quot; .. Chapter; end
            if Chapter:sub(-1,-1) == &quot;'&quot; then Chapter = Chapter .. &quot;&lt;span /&gt;&quot;; end
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            if Title:sub(1,1) == &quot;'&quot; then Title = &quot;&lt;span /&gt;&quot; .. Title; end
            if Title:sub(-1,-1) == &quot;'&quot; then Title = Title .. &quot;&lt;span /&gt;&quot;; end
            
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;news&quot; and
             config.CitationClass ~= &quot;web&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            if LaySource:sub(1,1) == &quot;'&quot; then LaySource = &quot;&lt;span /&gt;&quot; .. LaySource; end
            if LaySource:sub(-1,-1) == &quot;'&quot; then LaySource = LaySource .. &quot;&lt;span /&gt;&quot;; end

            LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if Periodical:sub(1,1) == &quot;'&quot; then Periodical = &quot;&lt;span /&gt;&quot; .. Periodical; end
        if Periodical:sub(-1,-1) == &quot;'&quot; then Periodical = Periodical .. &quot;&lt;span /&gt;&quot;; end

        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. Periodical .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. Periodical .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon .. Page .. Pages .. At .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon .. Page .. Pages .. At .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date .. Page .. Pages .. At .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    if ( text:sub(-4,-1) == &quot;.''.&quot; ) then --when dot after title
        text = text:sub(1,-2) end --truncate end-dot
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--
--End</text>
      <sha1>0ht6nradvz3qte6ezcic761zv56xqke</sha1>
    </revision>
    <revision>
      <id>4569</id>
      <parentid>4568</parentid>
      <timestamp>2013-03-14T19:48:20Z</timestamp>
      <contributor>
        <username>Wikid77</username>
        <id>806</id>
      </contributor>
      <comment>fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number; fixed config.CitationClass &quot;book&quot; to use p./pp. page number.</comment>
      <origin>4569</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="57743" sha1="ov8twahc5fmn7pa7gsj9hcedw5mpgqp" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    end
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            if Chapter:sub(1,1) == &quot;'&quot; then Chapter = &quot;&lt;span /&gt;&quot; .. Chapter; end
            if Chapter:sub(-1,-1) == &quot;'&quot; then Chapter = Chapter .. &quot;&lt;span /&gt;&quot;; end
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            if Title:sub(1,1) == &quot;'&quot; then Title = &quot;&lt;span /&gt;&quot; .. Title; end
            if Title:sub(-1,-1) == &quot;'&quot; then Title = Title .. &quot;&lt;span /&gt;&quot;; end
            
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            if LaySource:sub(1,1) == &quot;'&quot; then LaySource = &quot;&lt;span /&gt;&quot; .. LaySource; end
            if LaySource:sub(-1,-1) == &quot;'&quot; then LaySource = LaySource .. &quot;&lt;span /&gt;&quot;; end

            LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if Periodical:sub(1,1) == &quot;'&quot; then Periodical = &quot;&lt;span /&gt;&quot; .. Periodical; end
        if Periodical:sub(-1,-1) == &quot;'&quot; then Periodical = Periodical .. &quot;&lt;span /&gt;&quot;; end

        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. Periodical .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. Periodical .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    if ( text:sub(-4,-1) == &quot;.''.&quot; ) then --when dot after title
        text = text:sub(1,-2) end --truncate end-dot
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    return citation0(frame, pframe.args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>ov8twahc5fmn7pa7gsj9hcedw5mpgqp</sha1>
    </revision>
    <revision>
      <id>4570</id>
      <parentid>4569</parentid>
      <timestamp>2013-03-14T20:38:45Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>performance related test</comment>
      <origin>4570</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="57835" sha1="emt2443iunzazgm9sh6e2o4n81etjaa" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    end
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            if Chapter:sub(1,1) == &quot;'&quot; then Chapter = &quot;&lt;span /&gt;&quot; .. Chapter; end
            if Chapter:sub(-1,-1) == &quot;'&quot; then Chapter = Chapter .. &quot;&lt;span /&gt;&quot;; end
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            if Title:sub(1,1) == &quot;'&quot; then Title = &quot;&lt;span /&gt;&quot; .. Title; end
            if Title:sub(-1,-1) == &quot;'&quot; then Title = Title .. &quot;&lt;span /&gt;&quot;; end
            
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            if LaySource:sub(1,1) == &quot;'&quot; then LaySource = &quot;&lt;span /&gt;&quot; .. LaySource; end
            if LaySource:sub(-1,-1) == &quot;'&quot; then LaySource = LaySource .. &quot;&lt;span /&gt;&quot;; end

            LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if Periodical:sub(1,1) == &quot;'&quot; then Periodical = &quot;&lt;span /&gt;&quot; .. Periodical; end
        if Periodical:sub(-1,-1) == &quot;'&quot; then Periodical = Periodical .. &quot;&lt;span /&gt;&quot;; end

        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. Periodical .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. Periodical .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    if ( text:sub(-4,-1) == &quot;.''.&quot; ) then --when dot after title
        text = text:sub(1,-2) end --truncate end-dot
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>emt2443iunzazgm9sh6e2o4n81etjaa</sha1>
    </revision>
    <revision>
      <id>4571</id>
      <parentid>4570</parentid>
      <timestamp>2013-03-15T04:18:01Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>performance related testing</comment>
      <origin>4571</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="57898" sha1="ofxrz51m7pti6s2uqzs6dmoxot81p8q" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    end
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            if Chapter:sub(1,1) == &quot;'&quot; then Chapter = &quot;&lt;span /&gt;&quot; .. Chapter; end
            if Chapter:sub(-1,-1) == &quot;'&quot; then Chapter = Chapter .. &quot;&lt;span /&gt;&quot;; end
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot;
                URL = nil
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            if Title:sub(1,1) == &quot;'&quot; then Title = &quot;&lt;span /&gt;&quot; .. Title; end
            if Title:sub(-1,-1) == &quot;'&quot; then Title = Title .. &quot;&lt;span /&gt;&quot;; end
            
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot;
            URL = nil
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            if LaySource:sub(1,1) == &quot;'&quot; then LaySource = &quot;&lt;span /&gt;&quot; .. LaySource; end
            if LaySource:sub(-1,-1) == &quot;'&quot; then LaySource = LaySource .. &quot;&lt;span /&gt;&quot;; end

            LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if Periodical:sub(1,1) == &quot;'&quot; then Periodical = &quot;&lt;span /&gt;&quot; .. Periodical; end
        if Periodical:sub(-1,-1) == &quot;'&quot; then Periodical = Periodical .. &quot;&lt;span /&gt;&quot;; end

        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. Periodical .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. Periodical .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    if ( text:sub(-4,-1) == &quot;.''.&quot; ) then --when dot after title
        text = text:sub(1,-2) end --truncate end-dot
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>ofxrz51m7pti6s2uqzs6dmoxot81p8q</sha1>
    </revision>
    <revision>
      <id>4572</id>
      <parentid>4571</parentid>
      <timestamp>2013-03-16T03:38:04Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>keep format together with URL</comment>
      <origin>4572</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="57970" sha1="65roojau005hi90nrryl4sa4yw337cn" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
      if ( args.article and args.article ~= &quot;&quot;) then
          if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
          Chapter = args.article
          TransChapter = TransTitle
      else
          if ( Periodical and Periodical ~= &quot;&quot;) then
            Chapter = Title
            TransChapter = TransTitle
          else Periodical = Title
          end
      end
      Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    end
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            if Chapter:sub(1,1) == &quot;'&quot; then Chapter = &quot;&lt;span /&gt;&quot; .. Chapter; end
            if Chapter:sub(-1,-1) == &quot;'&quot; then Chapter = Chapter .. &quot;&lt;span /&gt;&quot;; end
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            if Title:sub(1,1) == &quot;'&quot; then Title = &quot;&lt;span /&gt;&quot; .. Title; end
            if Title:sub(-1,-1) == &quot;'&quot; then Title = Title .. &quot;&lt;span /&gt;&quot;; end
            
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            if LaySource:sub(1,1) == &quot;'&quot; then LaySource = &quot;&lt;span /&gt;&quot; .. LaySource; end
            if LaySource:sub(-1,-1) == &quot;'&quot; then LaySource = LaySource .. &quot;&lt;span /&gt;&quot;; end

            LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if Periodical:sub(1,1) == &quot;'&quot; then Periodical = &quot;&lt;span /&gt;&quot; .. Periodical; end
        if Periodical:sub(-1,-1) == &quot;'&quot; then Periodical = Periodical .. &quot;&lt;span /&gt;&quot;; end

        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. Periodical .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. Periodical .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    if ( text:sub(-4,-1) == &quot;.''.&quot; ) then --when dot after title
        text = text:sub(1,-2) end --truncate end-dot
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>65roojau005hi90nrryl4sa4yw337cn</sha1>
    </revision>
    <revision>
      <id>4573</id>
      <parentid>4572</parentid>
      <timestamp>2013-03-16T19:05:13Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>kill duplication</comment>
      <origin>4573</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="58071" sha1="ep5ld0ckqngz12dddig6i9sx1pkovo2" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
        else
            if ( Periodical and Periodical ~= &quot;&quot;) then
                if Periodical ~= Title then 
                    Chapter = Title
                    TransChapter = TransTitle
                end
            else Periodical = Title
            end
        end
        Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    end
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            if Chapter:sub(1,1) == &quot;'&quot; then Chapter = &quot;&lt;span /&gt;&quot; .. Chapter; end
            if Chapter:sub(-1,-1) == &quot;'&quot; then Chapter = Chapter .. &quot;&lt;span /&gt;&quot;; end
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            if Title:sub(1,1) == &quot;'&quot; then Title = &quot;&lt;span /&gt;&quot; .. Title; end
            if Title:sub(-1,-1) == &quot;'&quot; then Title = Title .. &quot;&lt;span /&gt;&quot;; end
            
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            if LaySource:sub(1,1) == &quot;'&quot; then LaySource = &quot;&lt;span /&gt;&quot; .. LaySource; end
            if LaySource:sub(-1,-1) == &quot;'&quot; then LaySource = LaySource .. &quot;&lt;span /&gt;&quot;; end

            LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if Periodical:sub(1,1) == &quot;'&quot; then Periodical = &quot;&lt;span /&gt;&quot; .. Periodical; end
        if Periodical:sub(-1,-1) == &quot;'&quot; then Periodical = Periodical .. &quot;&lt;span /&gt;&quot;; end

        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. Periodical .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. Periodical .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    if ( text:sub(-4,-1) == &quot;.''.&quot; ) then --when dot after title
        text = text:sub(1,-2) end --truncate end-dot
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>ep5ld0ckqngz12dddig6i9sx1pkovo2</sha1>
    </revision>
    <revision>
      <id>4574</id>
      <parentid>4573</parentid>
      <timestamp>2013-03-16T19:45:05Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>convert hyphens to dashs</comment>
      <origin>4574</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="58172" sha1="jhpb5ot3b695l4w6z37qhgxth5j72y5" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
        else
            if ( Periodical and Periodical ~= &quot;&quot;) then
                if Periodical ~= Title then 
                    Chapter = Title
                    TransChapter = TransTitle
                end
            else Periodical = Title
            end
        end
        Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = hyphentodash( args.pages )
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    end
    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = hyphentodash( args.isbn13 or args.isbn or args.ISBN )
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            if Chapter:sub(1,1) == &quot;'&quot; then Chapter = &quot;&lt;span /&gt;&quot; .. Chapter; end
            if Chapter:sub(-1,-1) == &quot;'&quot; then Chapter = Chapter .. &quot;&lt;span /&gt;&quot;; end
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            if Title:sub(1,1) == &quot;'&quot; then Title = &quot;&lt;span /&gt;&quot; .. Title; end
            if Title:sub(-1,-1) == &quot;'&quot; then Title = Title .. &quot;&lt;span /&gt;&quot;; end
            
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            if LaySource:sub(1,1) == &quot;'&quot; then LaySource = &quot;&lt;span /&gt;&quot; .. LaySource; end
            if LaySource:sub(-1,-1) == &quot;'&quot; then LaySource = LaySource .. &quot;&lt;span /&gt;&quot;; end

            LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if Periodical:sub(1,1) == &quot;'&quot; then Periodical = &quot;&lt;span /&gt;&quot; .. Periodical; end
        if Periodical:sub(-1,-1) == &quot;'&quot; then Periodical = Periodical .. &quot;&lt;span /&gt;&quot;; end

        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. Periodical .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. Periodical .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    if ( text:sub(-4,-1) == &quot;.''.&quot; ) then --when dot after title
        text = text:sub(1,-2) end --truncate end-dot
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>jhpb5ot3b695l4w6z37qhgxth5j72y5</sha1>
    </revision>
    <revision>
      <id>4575</id>
      <parentid>4574</parentid>
      <timestamp>2013-03-16T19:47:08Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>fix</comment>
      <origin>4575</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="58245" sha1="6mo9apkd0ywadr7kncn5q80ybjw8up5" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
        else
            if ( Periodical and Periodical ~= &quot;&quot;) then
                if Periodical ~= Title then 
                    Chapter = Title
                    TransChapter = TransTitle
                end
            else Periodical = Title
            end
        end
        Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    if ISBN ~= nil then ISBN = hyphentodash( ISBN ) end
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            if Chapter:sub(1,1) == &quot;'&quot; then Chapter = &quot;&lt;span /&gt;&quot; .. Chapter; end
            if Chapter:sub(-1,-1) == &quot;'&quot; then Chapter = Chapter .. &quot;&lt;span /&gt;&quot;; end
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            if Title:sub(1,1) == &quot;'&quot; then Title = &quot;&lt;span /&gt;&quot; .. Title; end
            if Title:sub(-1,-1) == &quot;'&quot; then Title = Title .. &quot;&lt;span /&gt;&quot;; end
            
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            if LaySource:sub(1,1) == &quot;'&quot; then LaySource = &quot;&lt;span /&gt;&quot; .. LaySource; end
            if LaySource:sub(-1,-1) == &quot;'&quot; then LaySource = LaySource .. &quot;&lt;span /&gt;&quot;; end

            LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if Periodical:sub(1,1) == &quot;'&quot; then Periodical = &quot;&lt;span /&gt;&quot; .. Periodical; end
        if Periodical:sub(-1,-1) == &quot;'&quot; then Periodical = Periodical .. &quot;&lt;span /&gt;&quot;; end

        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. Periodical .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. Periodical .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    if ( text:sub(-4,-1) == &quot;.''.&quot; ) then --when dot after title
        text = text:sub(1,-2) end --truncate end-dot
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>6mo9apkd0ywadr7kncn5q80ybjw8up5</sha1>
    </revision>
    <revision>
      <id>4576</id>
      <parentid>4575</parentid>
      <timestamp>2013-03-16T19:50:23Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>nevermind, I'm probably wrong about this one</comment>
      <origin>4576</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="58189" sha1="9uoazhm0m06cesd3nkgbh0l9dlxticr" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
        else
            if ( Periodical and Periodical ~= &quot;&quot;) then
                if Periodical ~= Title then 
                    Chapter = Title
                    TransChapter = TransTitle
                end
            else Periodical = Title
            end
        end
        Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            if Chapter:sub(1,1) == &quot;'&quot; then Chapter = &quot;&lt;span /&gt;&quot; .. Chapter; end
            if Chapter:sub(-1,-1) == &quot;'&quot; then Chapter = Chapter .. &quot;&lt;span /&gt;&quot;; end
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            if Title:sub(1,1) == &quot;'&quot; then Title = &quot;&lt;span /&gt;&quot; .. Title; end
            if Title:sub(-1,-1) == &quot;'&quot; then Title = Title .. &quot;&lt;span /&gt;&quot;; end
            
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            if LaySource:sub(1,1) == &quot;'&quot; then LaySource = &quot;&lt;span /&gt;&quot; .. LaySource; end
            if LaySource:sub(-1,-1) == &quot;'&quot; then LaySource = LaySource .. &quot;&lt;span /&gt;&quot;; end

            LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if Periodical:sub(1,1) == &quot;'&quot; then Periodical = &quot;&lt;span /&gt;&quot; .. Periodical; end
        if Periodical:sub(-1,-1) == &quot;'&quot; then Periodical = Periodical .. &quot;&lt;span /&gt;&quot;; end

        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. Periodical .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. Periodical .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    if ( text:sub(-4,-1) == &quot;.''.&quot; ) then --when dot after title
        text = text:sub(1,-2) end --truncate end-dot
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>9uoazhm0m06cesd3nkgbh0l9dlxticr</sha1>
    </revision>
    <revision>
      <id>4577</id>
      <parentid>4576</parentid>
      <timestamp>2013-03-16T19:55:46Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>Does this fix the URL issue</comment>
      <origin>4577</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="58308" sha1="d1bmtrvz9hbzhgu6w5fdj2dgr0q2erw" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            ChapterURL = URL
            URL = ''
        else
            if ( Periodical and Periodical ~= &quot;&quot;) then
                if Periodical ~= Title then 
                    Chapter = Title
                    TransChapter = TransTitle
                    ChapterURL = URL;  
                    URL = ''
                end
            else Periodical = Title
            end
        end
        Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            if Chapter:sub(1,1) == &quot;'&quot; then Chapter = &quot;&lt;span /&gt;&quot; .. Chapter; end
            if Chapter:sub(-1,-1) == &quot;'&quot; then Chapter = Chapter .. &quot;&lt;span /&gt;&quot;; end
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            if Title:sub(1,1) == &quot;'&quot; then Title = &quot;&lt;span /&gt;&quot; .. Title; end
            if Title:sub(-1,-1) == &quot;'&quot; then Title = Title .. &quot;&lt;span /&gt;&quot;; end
            
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            if LaySource:sub(1,1) == &quot;'&quot; then LaySource = &quot;&lt;span /&gt;&quot; .. LaySource; end
            if LaySource:sub(-1,-1) == &quot;'&quot; then LaySource = LaySource .. &quot;&lt;span /&gt;&quot;; end

            LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if Periodical:sub(1,1) == &quot;'&quot; then Periodical = &quot;&lt;span /&gt;&quot; .. Periodical; end
        if Periodical:sub(-1,-1) == &quot;'&quot; then Periodical = Periodical .. &quot;&lt;span /&gt;&quot;; end

        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. Periodical .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. Periodical .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    if ( text:sub(-4,-1) == &quot;.''.&quot; ) then --when dot after title
        text = text:sub(1,-2) end --truncate end-dot
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>d1bmtrvz9hbzhgu6w5fdj2dgr0q2erw</sha1>
    </revision>
    <revision>
      <id>4578</id>
      <parentid>4577</parentid>
      <timestamp>2013-03-16T20:02:07Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>trying to fix the encyclopedia logic</comment>
      <origin>4578</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="58255" sha1="5krf8648dc9dv8j3zfwqal7052scqmf" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            ChapterURL = URL
            URL = ''
        else
            if ( Periodical and Periodical ~= &quot;&quot;) then
                if Periodical == Title then Periodical = '' end
            end
            Chapter = Title
            TransChapter = TransTitle
            ChapterURL = URL;  
            URL = ''                
        end
        Title = &quot;&quot;
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            if Chapter:sub(1,1) == &quot;'&quot; then Chapter = &quot;&lt;span /&gt;&quot; .. Chapter; end
            if Chapter:sub(-1,-1) == &quot;'&quot; then Chapter = Chapter .. &quot;&lt;span /&gt;&quot;; end
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            if Title:sub(1,1) == &quot;'&quot; then Title = &quot;&lt;span /&gt;&quot; .. Title; end
            if Title:sub(-1,-1) == &quot;'&quot; then Title = Title .. &quot;&lt;span /&gt;&quot;; end
            
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            if LaySource:sub(1,1) == &quot;'&quot; then LaySource = &quot;&lt;span /&gt;&quot; .. LaySource; end
            if LaySource:sub(-1,-1) == &quot;'&quot; then LaySource = LaySource .. &quot;&lt;span /&gt;&quot;; end

            LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if Periodical:sub(1,1) == &quot;'&quot; then Periodical = &quot;&lt;span /&gt;&quot; .. Periodical; end
        if Periodical:sub(-1,-1) == &quot;'&quot; then Periodical = Periodical .. &quot;&lt;span /&gt;&quot;; end

        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. Periodical .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. Periodical .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    if ( text:sub(-4,-1) == &quot;.''.&quot; ) then --when dot after title
        text = text:sub(1,-2) end --truncate end-dot
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>5krf8648dc9dv8j3zfwqal7052scqmf</sha1>
    </revision>
    <revision>
      <id>4579</id>
      <parentid>4578</parentid>
      <timestamp>2013-03-16T20:07:21Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>encyc logic</comment>
      <origin>4579</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="58362" sha1="nqk9173sql3au2pwoqz1o6jtaj4r5uy" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            ChapterURL = URL
            URL = ''
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            Chapter = Title
            TransChapter = TransTitle
            ChapterURL = URL;  
            URL = ''                
            Title = &quot;&quot;            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            if Chapter:sub(1,1) == &quot;'&quot; then Chapter = &quot;&lt;span /&gt;&quot; .. Chapter; end
            if Chapter:sub(-1,-1) == &quot;'&quot; then Chapter = Chapter .. &quot;&lt;span /&gt;&quot;; end
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            if Title:sub(1,1) == &quot;'&quot; then Title = &quot;&lt;span /&gt;&quot; .. Title; end
            if Title:sub(-1,-1) == &quot;'&quot; then Title = Title .. &quot;&lt;span /&gt;&quot;; end
            
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            if LaySource:sub(1,1) == &quot;'&quot; then LaySource = &quot;&lt;span /&gt;&quot; .. LaySource; end
            if LaySource:sub(-1,-1) == &quot;'&quot; then LaySource = LaySource .. &quot;&lt;span /&gt;&quot;; end

            LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if Periodical:sub(1,1) == &quot;'&quot; then Periodical = &quot;&lt;span /&gt;&quot; .. Periodical; end
        if Periodical:sub(-1,-1) == &quot;'&quot; then Periodical = Periodical .. &quot;&lt;span /&gt;&quot;; end

        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. Periodical .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. Periodical .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    if ( text:sub(-4,-1) == &quot;.''.&quot; ) then --when dot after title
        text = text:sub(1,-2) end --truncate end-dot
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>nqk9173sql3au2pwoqz1o6jtaj4r5uy</sha1>
    </revision>
    <revision>
      <id>4580</id>
      <parentid>4579</parentid>
      <timestamp>2013-03-16T20:13:33Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>test whether that is unnecessary</comment>
      <origin>4580</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="58243" sha1="qij6k3ubc9znej17nrcf9043rr38kjp" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            Chapter = Title
            TransChapter = TransTitle
            Title = &quot;&quot;            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            if Chapter:sub(1,1) == &quot;'&quot; then Chapter = &quot;&lt;span /&gt;&quot; .. Chapter; end
            if Chapter:sub(-1,-1) == &quot;'&quot; then Chapter = Chapter .. &quot;&lt;span /&gt;&quot;; end
            Chapter = &quot;''&quot; .. Chapter .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            if Title:sub(1,1) == &quot;'&quot; then Title = &quot;&lt;span /&gt;&quot; .. Title; end
            if Title:sub(-1,-1) == &quot;'&quot; then Title = Title .. &quot;&lt;span /&gt;&quot;; end
            
            Title = &quot;''&quot; .. Title .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            if LaySource:sub(1,1) == &quot;'&quot; then LaySource = &quot;&lt;span /&gt;&quot; .. LaySource; end
            if LaySource:sub(-1,-1) == &quot;'&quot; then LaySource = LaySource .. &quot;&lt;span /&gt;&quot;; end

            LaySource = &quot; &amp;ndash; ''&quot; .. LaySource .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if Periodical:sub(1,1) == &quot;'&quot; then Periodical = &quot;&lt;span /&gt;&quot; .. Periodical; end
        if Periodical:sub(-1,-1) == &quot;'&quot; then Periodical = Periodical .. &quot;&lt;span /&gt;&quot;; end

        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. Periodical .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. Periodical .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    if ( text:sub(-4,-1) == &quot;.''.&quot; ) then --when dot after title
        text = text:sub(1,-2) end --truncate end-dot
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>qij6k3ubc9znej17nrcf9043rr38kjp</sha1>
    </revision>
    <revision>
      <id>4581</id>
      <parentid>4580</parentid>
      <timestamp>2013-03-16T20:25:34Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>code cleanup</comment>
      <origin>4581</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="57903" sha1="3bbf5sit35jvo8gub5i2s2sqk1z3m2i" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            Chapter = Title
            TransChapter = TransTitle
            Title = &quot;&quot;            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date
        if ( text:sub(-1,-1) == &quot;.&quot; and --prior text ends as &quot;.&quot;
             pgtext:sub(1,1) == &quot;.&quot; )
            then pgtext = pgtext:sub(2,-1) end --truncate by 1
        text = text .. pgtext .. idcommon
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    if ( text:sub(-4,-1) == &quot;.''.&quot; ) then --when dot after title
        text = text:sub(1,-2) end --truncate end-dot
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>3bbf5sit35jvo8gub5i2s2sqk1z3m2i</sha1>
    </revision>
    <revision>
      <id>4582</id>
      <parentid>4581</parentid>
      <timestamp>2013-03-16T20:39:56Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>testing</comment>
      <origin>4582</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="58331" sha1="1xi4aftx1i13xec7gljupnzxkpfjgjj" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char, space_char )
    local str = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        -- Trim spaces
        value = value:match( '^%s*(.-)%s*$' ); 
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == duplicate_char then
                if str:sub(-1,-1) == duplicate_char then
                    str = str .. space_char .. value:sub(2);
                elseif str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                    str = str .. space_char .. value:sub(2);
                else
                    str = str .. space_char .. value;
                end
            else
                str = str .. space_char .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            Chapter = Title
            TransChapter = TransTitle
            Title = &quot;&quot;            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon
        safejoin( {text, pgtext, idcommon}, sepc, ' ' );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon
        text = safejoin( {text, pgtext, idcommon}, sepc, ' ' );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date
        text = safejoin( {text, pgtext, idcommon}, sepc, ' ' );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    if ( text:sub(-4,-1) == &quot;.''.&quot; ) then --when dot after title
        text = text:sub(1,-2) end --truncate end-dot
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>1xi4aftx1i13xec7gljupnzxkpfjgjj</sha1>
    </revision>
    <revision>
      <id>4583</id>
      <parentid>4582</parentid>
      <timestamp>2013-03-16T20:45:32Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>testing</comment>
      <origin>4583</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="58812" sha1="7gb6ongvzpnik36emgu0q07k723sf8w" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char, space_char )
    --[[
    Note: we use string function here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char and space_char are strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        -- Trim spaces
        value = value:match( '^%s*(.-)%s*$' ); 
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == duplicate_char then
                if str:sub(-1,-1) == duplicate_char then
                    if string.len( value ) &gt; 1 then
                        str = str .. space_char .. value:sub(2);
                    end                    
                elseif str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                    if string.len( value ) &gt; 1 then
                        str = str .. space_char .. value:sub(2);
                    end                    
                else
                    str = str .. space_char .. value;
                end
            else
                str = str .. space_char .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            Chapter = Title
            TransChapter = TransTitle
            Title = &quot;&quot;            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon
        safejoin( {text, pgtext, idcommon}, sepc, ' ' );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon
        text = safejoin( {text, pgtext, idcommon}, sepc, ' ' );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date
        text = safejoin( {text, pgtext, idcommon}, sepc, ' ' );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    if ( text:sub(-4,-1) == &quot;.''.&quot; ) then --when dot after title
        text = text:sub(1,-2) end --truncate end-dot
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>7gb6ongvzpnik36emgu0q07k723sf8w</sha1>
    </revision>
    <revision>
      <id>4584</id>
      <parentid>4583</parentid>
      <timestamp>2013-03-16T20:50:21Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>hmmm, I see how spaces are currently handled</comment>
      <origin>4584</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="58448" sha1="r4m3962vtg9x0g8lh7w7q631eg057lf" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string function here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == duplicate_char then
                if str:sub(-1,-1) == duplicate_char then
                    str = str .. value:sub(2);
                elseif str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                    str = str .. value:sub(2);
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            Chapter = Title
            TransChapter = TransTitle
            Title = &quot;&quot;            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon
        safejoin( {text, pgtext, idcommon}, sepc, ' ' );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon
        text = safejoin( {text, pgtext, idcommon}, sepc, ' ' );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date
        text = safejoin( {text, pgtext, idcommon}, sepc, ' ' );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    if ( text:sub(-4,-1) == &quot;.''.&quot; ) then --when dot after title
        text = text:sub(1,-2) end --truncate end-dot
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>r4m3962vtg9x0g8lh7w7q631eg057lf</sha1>
    </revision>
    <revision>
      <id>4585</id>
      <parentid>4584</parentid>
      <timestamp>2013-03-16T20:53:06Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>fix</comment>
      <origin>4585</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="58328" sha1="jo5hn68137idahodudihclzgq99ndi3" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char, space_char )
    local str = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        -- Trim spaces
        value = value:match( '^%s*(.-)%s*$' ); 
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == duplicate_char then
                if str:sub(-1,-1) == duplicate_char then
                    str = str .. space_char .. value:sub(2);
                elseif str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                    str = str .. space_char .. value:sub(2);
                else
                    str = str .. space_char .. value;
                end
            else
                str = str .. space_char .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            Chapter = Title
            TransChapter = TransTitle
            Title = &quot;&quot;            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon
        text = safejoin( {text, pgtext, idcommon}, sepc, ' ' );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date
        text = safejoin( {text, pgtext, idcommon}, sepc );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    if ( text:sub(-4,-1) == &quot;.''.&quot; ) then --when dot after title
        text = text:sub(1,-2) end --truncate end-dot
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>jo5hn68137idahodudihclzgq99ndi3</sha1>
    </revision>
    <revision>
      <id>4586</id>
      <parentid>4585</parentid>
      <timestamp>2013-03-16T20:54:27Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>note to self, don't edit old versions</comment>
      <origin>4586</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="58440" sha1="8atju9p4otuesu3rt2zcqn7ifu9tovb" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string function here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == duplicate_char then
                if str:sub(-1,-1) == duplicate_char then
                    str = str .. value:sub(2);
                elseif str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                    str = str .. value:sub(2);
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            Chapter = Title
            TransChapter = TransTitle
            Title = &quot;&quot;            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Edition .. Publisher .. Agency .. Others .. Volume .. Issue .. Position
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = Title .. TitleNote .. Format .. TitleType .. Conference .. Periodical .. Series .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    else tcommon = Title .. TitleNote .. Series .. Format .. TitleType .. Conference .. Periodical .. Language .. Volume .. Issue .. Edition .. Publisher .. Agency .. Others .. Position
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = ARXIV .. ASIN .. BIBCODE .. DOI .. ISBN .. ISSN .. JFM .. JSTOR .. LCCN .. MR .. OCLC .. OL .. OSTI .. PMC .. PMID .. RFC .. SSRN .. URL .. ZBL .. ID .. Archived .. AccessDate .. Via .. SubscriptionRequired .. Lay .. Quote .. PostScript
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date
        text = safejoin( {text, pgtext, idcommon}, sepc );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    if ( text:sub(-4,-1) == &quot;.''.&quot; ) then --when dot after title
        text = text:sub(1,-2) end --truncate end-dot
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>8atju9p4otuesu3rt2zcqn7ifu9tovb</sha1>
    </revision>
    <revision>
      <id>4587</id>
      <parentid>4586</parentid>
      <timestamp>2013-03-16T21:01:55Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>testing aggressive dot killing</comment>
      <origin>4587</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="58391" sha1="pgpvem686hloquix3bp83jz8nyuf0ws" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string function here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == duplicate_char then
                if str:sub(-1,-1) == duplicate_char then
                    str = str .. value:sub(2);
                elseif str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                    str = str .. value:sub(2);
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            Chapter = Title
            TransChapter = TransTitle
            Title = &quot;&quot;            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position }, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date
        text = safejoin( {text, pgtext, idcommon}, sepc );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    if ( text:sub(-4,-1) == &quot;.''.&quot; ) then --when dot after title
        text = text:sub(1,-2) end --truncate end-dot
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>pgpvem686hloquix3bp83jz8nyuf0ws</sha1>
    </revision>
    <revision>
      <id>4588</id>
      <parentid>4587</parentid>
      <timestamp>2013-03-16T21:09:55Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>&quot;. .&quot; case</comment>
      <origin>4588</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="58510" sha1="cv61beugq6dvd3bx69k89jcqjh9hfzg" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == duplicate_char then
                if str:sub(-1,-1) == duplicate_char then
                    str = str .. value:sub(2);
                elseif str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                    str = str .. value:sub(2);
                elseif str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                    str = str:sub(1,-3) .. value;
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            Chapter = Title
            TransChapter = TransTitle
            Title = &quot;&quot;            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position }, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;&quot;
    if (Title ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Periodical ~= &quot;&quot;) then enddot = &quot;.&quot; end
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( string.sub(idcommon,-1,-1) == sepc) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = idcommon .. enddot

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date
        text = safejoin( {text, pgtext, idcommon}, sepc );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    if ( text:sub(-4,-1) == &quot;.''.&quot; ) then --when dot after title
        text = text:sub(1,-2) end --truncate end-dot
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>cv61beugq6dvd3bx69k89jcqjh9hfzg</sha1>
    </revision>
    <revision>
      <id>4589</id>
      <parentid>4588</parentid>
      <timestamp>2013-03-16T21:14:39Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>worry about the enddot</comment>
      <origin>4589</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="58374" sha1="d64tgt7z28x44uwy8n4nz0mp9bma997" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == duplicate_char then
                if str:sub(-1,-1) == duplicate_char then
                    str = str .. value:sub(2);
                elseif str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                    str = str .. value:sub(2);
                elseif str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                    str = str:sub(1,-3) .. value;
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            Chapter = Title
            TransChapter = TransTitle
            Title = &quot;&quot;            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position }, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date
        text = safejoin( {text, pgtext, idcommon}, sepc );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    if ( text:sub(-4,-1) == &quot;.''.&quot; ) then --when dot after title
        text = text:sub(1,-2) end --truncate end-dot
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>d64tgt7z28x44uwy8n4nz0mp9bma997</sha1>
    </revision>
    <revision>
      <id>4590</id>
      <parentid>4589</parentid>
      <timestamp>2013-03-16T21:20:13Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <origin>4590</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="58656" sha1="eg4p3n8c8e4iei330aoatymhd7w65pr" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:replace( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                if str:sub(-1,-1) == duplicate_char then
                    str = str(1,-2) .. value;
                elseif str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                    str = str(1, -4) .. &quot;''&quot; .. value:sub(2);
                elseif str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                    str = str:sub(1,-3) .. value;
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            Chapter = Title
            TransChapter = TransTitle
            Title = &quot;&quot;            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position }, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date
        text = safejoin( {text, pgtext, idcommon}, sepc );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    if ( text:sub(-4,-1) == &quot;.''.&quot; ) then --when dot after title
        text = text:sub(1,-2) end --truncate end-dot
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>eg4p3n8c8e4iei330aoatymhd7w65pr</sha1>
    </revision>
    <revision>
      <id>4591</id>
      <parentid>4590</parentid>
      <timestamp>2013-03-16T21:20:45Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>always forget the name</comment>
      <origin>4591</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="58653" sha1="hds67qvjqy8zo9zpp926ao54qtyyimm" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                if str:sub(-1,-1) == duplicate_char then
                    str = str(1,-2) .. value;
                elseif str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                    str = str(1, -4) .. &quot;''&quot; .. value:sub(2);
                elseif str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                    str = str:sub(1,-3) .. value;
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            Chapter = Title
            TransChapter = TransTitle
            Title = &quot;&quot;            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position }, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date
        text = safejoin( {text, pgtext, idcommon}, sepc );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    if ( text:sub(-4,-1) == &quot;.''.&quot; ) then --when dot after title
        text = text:sub(1,-2) end --truncate end-dot
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>hds67qvjqy8zo9zpp926ao54qtyyimm</sha1>
    </revision>
    <revision>
      <id>4592</id>
      <parentid>4591</parentid>
      <timestamp>2013-03-16T21:21:50Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>fixes</comment>
      <origin>4592</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="58654" sha1="73sjqbqsgtn45idrh34ach4a8qjamx9" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                if str:sub(-1,-1) == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                    str = str:sub(1, -4) .. &quot;''&quot; .. value;
                elseif str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                    str = str:sub(1,-3) .. value;
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            Chapter = Title
            TransChapter = TransTitle
            Title = &quot;&quot;            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position }, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = Authors .. Date .. Chapter .. Editors .. tcommon
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = Editors .. Date .. Chapter .. tcommon
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = Chapter .. tcommon .. Date
        text = safejoin( {text, pgtext, idcommon}, sepc );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    if ( text:sub(-4,-1) == &quot;.''.&quot; ) then --when dot after title
        text = text:sub(1,-2) end --truncate end-dot
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>73sjqbqsgtn45idrh34ach4a8qjamx9</sha1>
    </revision>
    <revision>
      <id>4593</id>
      <parentid>4592</parentid>
      <timestamp>2013-03-16T21:33:00Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>aarrggggh, dots.</comment>
      <origin>4593</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="58700" sha1="b8ymg1sf2njb7kwk5u3ynhzxo4h79lg" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                if str:sub(-1,-1) == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                    str = str:sub(1, -4) .. &quot;''&quot; .. value;
                elseif str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                    str = str:sub(1,-3) .. value;
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            Chapter = Title
            TransChapter = TransTitle
            Title = &quot;&quot;            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position }, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = safejoin( {Chapter, tcommon, Date}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    if ( text:sub(-4,-1) == &quot;.''.&quot; ) then --when dot after title
        text = text:sub(1,-2) end --truncate end-dot
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>b8ymg1sf2njb7kwk5u3ynhzxo4h79lg</sha1>
    </revision>
    <revision>
      <id>4594</id>
      <parentid>4593</parentid>
      <timestamp>2013-03-16T21:40:58Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>special case with only encyclopedia given</comment>
      <origin>4594</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="58788" sha1="dmg69dt3vyp7pzacxtb9ik67mogk1ed" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                if str:sub(-1,-1) == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                    str = str:sub(1, -4) .. &quot;''&quot; .. value;
                elseif str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                    str = str:sub(1,-3) .. value;
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; )
    then tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position }, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; )
    then tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = safejoin( {Chapter, tcommon, Date}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    if ( text:sub(-4,-1) == &quot;.''.&quot; ) then --when dot after title
        text = text:sub(1,-2) end --truncate end-dot
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>dmg69dt3vyp7pzacxtb9ik67mogk1ed</sha1>
    </revision>
    <revision>
      <id>4595</id>
      <parentid>4594</parentid>
      <timestamp>2013-03-16T21:47:52Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>fun, fun, Series ordering</comment>
      <origin>4595</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="58851" sha1="jv14lqoheyyd1i7f0wlsw2ns8wipb03" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                if str:sub(-1,-1) == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                    str = str:sub(1, -4) .. &quot;''&quot; .. value;
                elseif str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                    str = str:sub(1,-3) .. value;
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else ArchiveDate = &quot;&quot; end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position }, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = safejoin( {Chapter, tcommon, Date}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    if ( text:sub(-4,-1) == &quot;.''.&quot; ) then --when dot after title
        text = text:sub(1,-2) end --truncate end-dot
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>jv14lqoheyyd1i7f0wlsw2ns8wipb03</sha1>
    </revision>
    <revision>
      <id>4596</id>
      <parentid>4595</parentid>
      <timestamp>2013-03-16T22:08:41Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>Archive date error condition</comment>
      <origin>4596</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="58973" sha1="ff19asxcbshi8f3wez8anjejag1czub" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                if str:sub(-1,-1) == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                    str = str:sub(1, -4) .. &quot;''&quot; .. value;
                elseif str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                    str = str:sub(1,-3) .. value;
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot;&lt;strong class='error'&gt;Error: If you specify archiveurl=, you must also specify archivedate=&lt;/strong&gt; &quot;
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position }, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = safejoin( {Chapter, tcommon, Date}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    if ( text:sub(-4,-1) == &quot;.''.&quot; ) then --when dot after title
        text = text:sub(1,-2) end --truncate end-dot
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>ff19asxcbshi8f3wez8anjejag1czub</sha1>
    </revision>
    <revision>
      <id>4597</id>
      <parentid>4596</parentid>
      <timestamp>2013-03-16T22:12:01Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>formatting</comment>
      <origin>4597</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="58988" sha1="68dtikd6r5r8lf4h7jy266eoneg3azw" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                if str:sub(-1,-1) == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                    str = str:sub(1, -4) .. &quot;''&quot; .. value;
                elseif str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                    str = str:sub(1,-3) .. value;
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot;&lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position }, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = safejoin( {Chapter, tcommon, Date}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    if ( text:sub(-4,-1) == &quot;.''.&quot; ) then --when dot after title
        text = text:sub(1,-2) end --truncate end-dot
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>68dtikd6r5r8lf4h7jy266eoneg3azw</sha1>
    </revision>
    <revision>
      <id>4598</id>
      <parentid>4597</parentid>
      <timestamp>2013-03-16T22:29:22Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>should be unneccesary now</comment>
      <origin>4598</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="58870" sha1="gw50siwuody03k99jmw8wee94jh9w5e" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                if str:sub(-1,-1) == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                    str = str:sub(1, -4) .. &quot;''&quot; .. value;
                elseif str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                    str = str:sub(1,-3) .. value;
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot;&lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position }, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = safejoin( {Chapter, tcommon, Date}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>gw50siwuody03k99jmw8wee94jh9w5e</sha1>
    </revision>
    <revision>
      <id>4599</id>
      <parentid>4598</parentid>
      <timestamp>2013-03-16T22:31:25Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>error trapping of empty citations</comment>
      <origin>4599</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="58987" sha1="q078ccs8397jeetiylnsuxp8lt8ur2g" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                if str:sub(-1,-1) == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                    str = str:sub(1, -4) .. &quot;''&quot; .. value;
                elseif str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                    str = str:sub(1,-3) .. value;
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot;&lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position }, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = safejoin( {Chapter, tcommon, Date}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.length(text) &lt; 2 then
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
    end
    
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>q078ccs8397jeetiylnsuxp8lt8ur2g</sha1>
    </revision>
    <revision>
      <id>4600</id>
      <parentid>4599</parentid>
      <timestamp>2013-03-16T22:31:58Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>len not length</comment>
      <origin>4600</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="58984" sha1="tpjd3x8xlwuhudlxgg3z3n0oc5q1eru" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                if str:sub(-1,-1) == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                    str = str:sub(1, -4) .. &quot;''&quot; .. value;
                elseif str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                    str = str:sub(1,-3) .. value;
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot;&lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position }, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = safejoin( {Chapter, tcommon, Date}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text) &lt; 2 then
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
    end
    
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>tpjd3x8xlwuhudlxgg3z3n0oc5q1eru</sha1>
    </revision>
    <revision>
      <id>4601</id>
      <parentid>4600</parentid>
      <timestamp>2013-03-16T22:46:00Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>slightly reduce number of sub calls for performance</comment>
      <origin>4601</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="59347" sha1="8xkhgovacrwnni99cocy8udemt36ijv" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                end_chr = str:sub(-1,-1);
                if end_chr == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                        str = str:sub(1, -4) .. &quot;''&quot; .. value;
                    else
                        str = str .. value;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3) .. value;
                    else
                        str = str .. value;
                    end                        
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot;&lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position }, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = safejoin( {Chapter, tcommon, Date}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text) &lt; 2 then
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
    end
    
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>8xkhgovacrwnni99cocy8udemt36ijv</sha1>
    </revision>
    <revision>
      <id>4602</id>
      <parentid>4601</parentid>
      <timestamp>2013-03-17T00:10:54Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>don't need encoding</comment>
      <origin>4602</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="59373" sha1="m81qjs3g2y5dhtehy0bpe2a0w591qjv" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = z.mw.url.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                end_chr = str:sub(-1,-1);
                if end_chr == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                        str = str:sub(1, -4) .. &quot;''&quot; .. value;
                    else
                        str = str .. value;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3) .. value;
                    else
                        str = str .. value;
                    end                        
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. z.mw.url.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. z.mw.url.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot;&lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position }, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = safejoin( {Chapter, tcommon, Date}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text) &lt; 2 then
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
    end
    
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = z.mw.url.encodeAnchor(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>m81qjs3g2y5dhtehy0bpe2a0w591qjv</sha1>
    </revision>
    <revision>
      <id>4603</id>
      <parentid>4602</parentid>
      <timestamp>2013-03-17T00:55:32Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>replace all calls to z.mw.url with calls to mw.uri builtins</comment>
      <origin>4603</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="59365" sha1="6u7o0m0mi61upptoxe837tma9k2x1tc" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                end_chr = str:sub(-1,-1);
                if end_chr == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                        str = str:sub(1, -4) .. &quot;''&quot; .. value;
                    else
                        str = str .. value;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3) .. value;
                    else
                        str = str .. value;
                    end                        
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot;&lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position }, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = safejoin( {Chapter, tcommon, Date}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text) &lt; 2 then
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
    end
    
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.uri.anchorEncode(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>6u7o0m0mi61upptoxe837tma9k2x1tc</sha1>
    </revision>
    <revision>
      <id>4604</id>
      <parentid>4603</parentid>
      <timestamp>2013-03-17T03:39:38Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <minor />
      <comment>Protected Module:Citation/CS1: [[WP:High-risk templates|Highly visible template]]: Going to be semi-visible soon during preliminary citation tests ([Edit=Allow only autoconfirmed users] (indefinite) [Move=Allow only autoconfirmed users] (indefinite))</comment>
      <origin>4603</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="59365" sha1="6u7o0m0mi61upptoxe837tma9k2x1tc" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub('%[','&amp;#91;'):gsub('%]','&amp;#93;'):gsub(&quot;\n&quot;, &quot; &quot;);
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                end_chr = str:sub(-1,-1);
                if end_chr == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                        str = str:sub(1, -4) .. &quot;''&quot; .. value;
                    else
                        str = str .. value;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3) .. value;
                    else
                        str = str .. value;
                    end                        
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot;&lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position }, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = safejoin( {Chapter, tcommon, Date}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text) &lt; 2 then
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
    end
    
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.uri.anchorEncode(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>6u7o0m0mi61upptoxe837tma9k2x1tc</sha1>
    </revision>
    <revision>
      <id>4605</id>
      <parentid>4604</parentid>
      <timestamp>2013-03-17T16:45:39Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>Faster that gsub chains</comment>
      <origin>4605</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="59427" sha1="qn22gud4ulng9vmlju38vfha1hqmopm" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub( '[%[%]\n]', {    
            	['['] = '&amp;#91;',	
	            [']'] = '&amp;#93;',	
	            ['\n'] = ' ' } );
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                end_chr = str:sub(-1,-1);
                if end_chr == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                        str = str:sub(1, -4) .. &quot;''&quot; .. value;
                    else
                        str = str .. value;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3) .. value;
                    else
                        str = str .. value;
                    end                        
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot;&lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position }, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = safejoin( {Chapter, tcommon, Date}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text) &lt; 2 then
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
    end
    
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.uri.anchorEncode(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>qn22gud4ulng9vmlju38vfha1hqmopm</sha1>
    </revision>
    <revision>
      <id>4606</id>
      <parentid>4605</parentid>
      <timestamp>2013-03-17T16:52:03Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>formatting and comments</comment>
      <origin>4606</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="59707" sha1="1g12prv14g8kvz5fcrxlqfgc7s3f7ze" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                end_chr = str:sub(-1,-1);
                if end_chr == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                        str = str:sub(1, -4) .. &quot;''&quot; .. value;
                    else
                        str = str .. value;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3) .. value;
                    else
                        str = str .. value;
                    end                        
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end

function extractauthor(args, i)
    local last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
            link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
            mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
        }
    else
        return nil
    end
end

function extracteditor(args, i)
    local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
    if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
        return {
            last = last,
            first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
            link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
            mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
        }
    else
        return nil
    end
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = {}
    i = 1
    while true do
        a[i] = extractauthor(args, i)
        if ( nil == a[i]) then break end
        i = i + 1
    end
    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = {} 
    i = 1
    while true do
        e[i] = extracteditor(args, i)
        if ( nil == e[i]) then break end
        i = i + 1
    end
    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot;&lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position }, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = safejoin( {Chapter, tcommon, Date}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text) &lt; 2 then
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
    end
    
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.uri.anchorEncode(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>1g12prv14g8kvz5fcrxlqfgc7s3f7ze</sha1>
    </revision>
    <revision>
      <id>4607</id>
      <parentid>4606</parentid>
      <timestamp>2013-03-17T18:10:32Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>convert extractauthor to extractauthors, etc., less coping of parameters back and forth.  Possibly better for performance.</comment>
      <origin>4607</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="59819" sha1="nlumam6ddm8qzvbdkiscbr6dwxq6w3t" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                end_chr = str:sub(-1,-1);
                if end_chr == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                        str = str:sub(1, -4) .. &quot;''&quot; .. value;
                    else
                        str = str .. value;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3) .. value;
                    else
                        str = str .. value;
                    end                        
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end
    
function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            authors[i] = {
                last = last,
                first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
                link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
                mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

function extracteditors(args)
    local editors;
    local i = 1;
    local last;
    
    while true do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            editors[i] = {
                last = last,
                first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
                link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
                mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot;&lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position }, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = safejoin( {Chapter, tcommon, Date}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text) &lt; 2 then
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
    end
    
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.uri.anchorEncode(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>nlumam6ddm8qzvbdkiscbr6dwxq6w3t</sha1>
    </revision>
    <revision>
      <id>4608</id>
      <parentid>4607</parentid>
      <timestamp>2013-03-17T18:11:17Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>fix</comment>
      <origin>4608</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="59824" sha1="3mxmlfv6ziq7hg6xxijq9i34a0vmcm7" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                end_chr = str:sub(-1,-1);
                if end_chr == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                        str = str:sub(1, -4) .. &quot;''&quot; .. value;
                    else
                        str = str .. value;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3) .. value;
                    else
                        str = str .. value;
                    end                        
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end
    
function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            authors[i] = {
                last = last,
                first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
                link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
                mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            editors[i] = {
                last = last,
                first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
                link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
                mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot;&lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position }, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = safejoin( {Chapter, tcommon, Date}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text) &lt; 2 then
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
    end
    
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.uri.anchorEncode(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>3mxmlfv6ziq7hg6xxijq9i34a0vmcm7</sha1>
    </revision>
    <revision>
      <id>4609</id>
      <parentid>4608</parentid>
      <timestamp>2013-03-17T18:44:42Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>performance related hacking.  Remove all references to Module:Mw by incorporating relevant parts of its code, also quit passing the frame around unnecessarily.</comment>
      <origin>4609</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="61360" sha1="pqn2i7vjg5hwily3w2pxteynsih0cw8" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    extensiontags = {
        nowiki = true,
        ref = true,
        gallery = true,
        pre = true,
        source = true,
        categorytree = true,
        charinsert = true,
        hiero = true,
        imagemap = true,
        inputbox = true,
        math = true,
        poem = true,
        ref = true,
        references = true,
        syntaxhighlight = true,
        timeline = true,
    }
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',	
            [']'] = '&amp;#93;',	
            ['{'] = '&amp;#123;',	
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

function createTag(t, frame)
    local name = t.name or &quot;!-- --&quot;
    local content = t.contents or &quot;&quot;
    local attrs = {}
    if ( z.extensiontags[name] ) then
        -- We have to preprocess these, so that they are properly turned into so-called &quot;strip markers&quot; in the generated wikitext.
        if ( not frame ) then error (&quot;Please supply an extra frame argument to the createTag() function.&quot;) end
        local params = {}
        for n,v in pairs(t.params) do
            table.insert(params, &quot;|&quot; .. n .. &quot;=&quot; .. v)
        end
        return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. table.concat(params) .. &quot;}}&quot;)
    else   
        for n,v in pairs(t.params) do
            if (v) then
                table.insert(attrs, n .. &quot;=\&quot;&quot; .. wikiescape(v) .. &quot;\&quot;&quot;)
            else
                table.insert(attrs, n)
            end
        end
        if (&quot;&quot; == content) then
            return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;/&gt;&quot;
        else
            return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
        end
    end
end

function nowiki(content)
    return createTag( {name=&quot;nowiki&quot;, contents=content, params={}} )
end

function externallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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;)
    
    return t0 .. t1
end

function internallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid({link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

function doi(id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                end_chr = str:sub(-1,-1);
                if end_chr == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                        str = str:sub(1, -4) .. &quot;''&quot; .. value;
                    else
                        str = str .. value;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3) .. value;
                    else
                        str = str .. value;
                    end                        
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= createTag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end
    
function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            authors[i] = {
                last = last,
                first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
                link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
                mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            editors[i] = {
                last = last,
                first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
                link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
                mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

function citation0( config, args)
    
    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. createTag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid({label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid({label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid({label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid({label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid({label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid({label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid({label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid({label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid({label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid({label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid({label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid({label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid({label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot;&lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position }, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = safejoin( {Chapter, tcommon, Date}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text) &lt; 2 then
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
    end
    
    text = createTag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = createTag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = createTag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = createTag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return createTag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = createTag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return createTag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
    end    
    
    return citation0( config, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return createTag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return createTag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = createTag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.uri.anchorEncode(&quot;endnote_&quot; .. id .. arrow)
    end
    return createTag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return createTag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>pqn2i7vjg5hwily3w2pxteynsih0cw8</sha1>
    </revision>
    <revision>
      <id>4610</id>
      <parentid>4609</parentid>
      <timestamp>2013-03-17T18:47:56Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>self rv, problems with nowiki, needs more testing</comment>
      <origin>4610</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="59824" sha1="3mxmlfv6ziq7hg6xxijq9i34a0vmcm7" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                end_chr = str:sub(-1,-1);
                if end_chr == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                        str = str:sub(1, -4) .. &quot;''&quot; .. value;
                    else
                        str = str .. value;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3) .. value;
                    else
                        str = str .. value;
                    end                        
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end
    
function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            authors[i] = {
                last = last,
                first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
                link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
                mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            editors[i] = {
                last = last,
                first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
                link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
                mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot;&lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position }, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = safejoin( {Chapter, tcommon, Date}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text) &lt; 2 then
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
    end
    
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.uri.anchorEncode(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>3mxmlfv6ziq7hg6xxijq9i34a0vmcm7</sha1>
    </revision>
    <revision>
      <id>4611</id>
      <parentid>4610</parentid>
      <timestamp>2013-03-17T18:58:31Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>I think this should work for nowiki, restore previous edit</comment>
      <origin>4611</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="61329" sha1="qgwkaiticy4gzcw2xn9g8g4x2pas5th" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    extensiontags = {
        nowiki = true,
        ref = true,
        gallery = true,
        pre = true,
        source = true,
        categorytree = true,
        charinsert = true,
        hiero = true,
        imagemap = true,
        inputbox = true,
        math = true,
        poem = true,
        ref = true,
        references = true,
        syntaxhighlight = true,
        timeline = true,
    }
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',	
            [']'] = '&amp;#93;',	
            ['{'] = '&amp;#123;',	
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

function createTag(t, frame)
    local name = t.name or &quot;!-- --&quot;
    local content = t.contents or &quot;&quot;
    local attrs = {}
    if ( z.extensiontags[name] ) then
        -- We have to preprocess these, so that they are properly turned into so-called &quot;strip markers&quot; in the generated wikitext.
        if ( not frame ) then error (&quot;Please supply an extra frame argument to the createTag() function.&quot;) end
        local params = {}
        for n,v in pairs(t.params) do
            table.insert(params, &quot;|&quot; .. n .. &quot;=&quot; .. v)
        end
        return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. table.concat(params) .. &quot;}}&quot;)
    else   
        for n,v in pairs(t.params) do
            if (v) then
                table.insert(attrs, n .. &quot;=\&quot;&quot; .. wikiescape(v) .. &quot;\&quot;&quot;)
            else
                table.insert(attrs, n)
            end
        end
        if (&quot;&quot; == content) then
            return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;/&gt;&quot;
        else
            return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
        end
    end
end

function nowiki(content)
    return mw.text.nowiki( content );
end

function externallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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;)
    
    return t0 .. t1
end

function internallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid({link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

function doi(id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                end_chr = str:sub(-1,-1);
                if end_chr == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                        str = str:sub(1, -4) .. &quot;''&quot; .. value;
                    else
                        str = str .. value;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3) .. value;
                    else
                        str = str .. value;
                    end                        
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= createTag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end
    
function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            authors[i] = {
                last = last,
                first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
                link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
                mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            editors[i] = {
                last = last,
                first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
                link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
                mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

function citation0( config, args)
    
    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. createTag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid({label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid({label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid({label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid({label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid({label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid({label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid({label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid({label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid({label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid({label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid({label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid({label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid({label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot;&lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position }, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = safejoin( {Chapter, tcommon, Date}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text) &lt; 2 then
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
    end
    
    text = createTag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = createTag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = createTag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = createTag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return createTag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = createTag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return createTag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
    end    
    
    return citation0( config, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return createTag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return createTag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = createTag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.uri.anchorEncode(&quot;endnote_&quot; .. id .. arrow)
    end
    return createTag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return createTag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>qgwkaiticy4gzcw2xn9g8g4x2pas5th</sha1>
    </revision>
    <revision>
      <id>4612</id>
      <parentid>4611</parentid>
      <timestamp>2013-03-17T19:00:21Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>self rv, the mw.text library isn't installed?  well joy</comment>
      <origin>4612</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="59824" sha1="3mxmlfv6ziq7hg6xxijq9i34a0vmcm7" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    mw = require(&quot;Module:Mw&quot;)
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function nowiki(frame, content)
    return z.mw.text.tag({name=&quot;nowiki&quot;,contents=content,params={}}, frame)
end

function externallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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(frame, args.id) .. &quot;]&quot;)
    
    return t0 .. t1
end

function internallinkid(frame, args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(frame, args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(frame, id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid(frame, {link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

function doi(frame, id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid(frame, {link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(frame, id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(frame, id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                end_chr = str:sub(-1,-1);
                if end_chr == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                        str = str:sub(1, -4) .. &quot;''&quot; .. value;
                    else
                        str = str .. value;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3) .. value;
                    else
                        str = str .. value;
                    end                        
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(frame, id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid(frame, {link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= z.mw.text.tag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end
    
function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            authors[i] = {
                last = last,
                first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
                link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
                mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            editors[i] = {
                last = last,
                first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
                link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
                mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

function citation0(frame, args)
    local config = {};
    for k, v in pairs( frame.args ) do -- the arguments passed BY the template, in the wikitext of the template itself
        config[k] = v;
    end

    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. z.mw.text.tag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(frame, ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(frame, DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid(frame, {label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid(frame, {label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(frame, OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(frame, URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid(frame, {label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot;&lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position }, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = safejoin( {Chapter, tcommon, Date}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text) &lt; 2 then
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
    end
    
    text = z.mw.text.tag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = z.mw.text.tag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = z.mw.text.tag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return z.mw.text.tag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = z.mw.text.tag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return z.mw.text.tag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(frame, id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    return hideinprint(frame, &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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    
    return citation0(frame, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return z.mw.text.tag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return z.mw.text.tag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = z.mw.text.tag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.uri.anchorEncode(&quot;endnote_&quot; .. id .. arrow)
    end
    return z.mw.text.tag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return z.mw.text.tag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>3mxmlfv6ziq7hg6xxijq9i34a0vmcm7</sha1>
    </revision>
    <revision>
      <id>4613</id>
      <parentid>4612</parentid>
      <timestamp>2013-03-17T19:05:29Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>once more.  Locally copying mw.text.nowiki</comment>
      <origin>4613</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="62163" sha1="4xnozqcnwrem6b4rggow3yslvw1p5xx" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    extensiontags = {
        nowiki = true,
        ref = true,
        gallery = true,
        pre = true,
        source = true,
        categorytree = true,
        charinsert = true,
        hiero = true,
        imagemap = true,
        inputbox = true,
        math = true,
        poem = true,
        ref = true,
        references = true,
        syntaxhighlight = true,
        timeline = true,
    }
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',	
            [']'] = '&amp;#93;',	
            ['{'] = '&amp;#123;',	
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

function createTag(t, frame)
    local name = t.name or &quot;!-- --&quot;
    local content = t.contents or &quot;&quot;
    local attrs = {}
    if ( z.extensiontags[name] ) then
        -- We have to preprocess these, so that they are properly turned into so-called &quot;strip markers&quot; in the generated wikitext.
        if ( not frame ) then error (&quot;Please supply an extra frame argument to the createTag() function.&quot;) end
        local params = {}
        for n,v in pairs(t.params) do
            table.insert(params, &quot;|&quot; .. n .. &quot;=&quot; .. v)
        end
        return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. table.concat(params) .. &quot;}}&quot;)
    else   
        for n,v in pairs(t.params) do
            if (v) then
                table.insert(attrs, n .. &quot;=\&quot;&quot; .. wikiescape(v) .. &quot;\&quot;&quot;)
            else
                table.insert(attrs, n)
            end
        end
        if (&quot;&quot; == content) then
            return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;/&gt;&quot;
        else
            return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
        end
    end
end

--[[
This is a clone of mw.text.nowiki.  When the mw.text library is installed,
this can be replaced by a call to that library. ]]
function nowiki( s )
    -- string.gsub is safe here, because we're only caring about ASCII chars
    s = string.gsub( s, '[&quot;&amp;\'&lt;=&gt;%[%]{|}]', {
        ['&quot;'] = '&amp;#34;',
        ['&amp;'] = '&amp;#38;',
        [&quot;'&quot;] = '&amp;#39;',
        ['&lt;'] = '&amp;#60;',
        ['='] = '&amp;#61;',
        ['&gt;'] = '&amp;#62;',
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['{'] = '&amp;#123;',
        ['|'] = '&amp;#124;',
        ['}'] = '&amp;#125;',
    } )
    s = string.sub( string.gsub( '\n' .. s, '\n[#*:;]', {
        [&quot;\n#&quot;] = &quot;\n&amp;#35;&quot;,
        [&quot;\n*&quot;] = &quot;\n&amp;#42;&quot;,
        [&quot;\n:&quot;] = &quot;\n&amp;#58;&quot;,
        [&quot;\n;&quot;] = &quot;\n&amp;#59;&quot;,
    } ), 2 )
    s = string.gsub( s, '://', '&amp;#58;//' )
    s = string.gsub( s, 'ISBN ', 'ISBN&amp;#32;' )
    s = string.gsub( s, 'RFC ', 'RFC&amp;#32;' )

    return s
end

function externallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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;)
    
    return t0 .. t1
end

function internallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid({link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

function doi(id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                end_chr = str:sub(-1,-1);
                if end_chr == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                        str = str:sub(1, -4) .. &quot;''&quot; .. value;
                    else
                        str = str .. value;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3) .. value;
                    else
                        str = str .. value;
                    end                        
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= createTag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end
    
function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            authors[i] = {
                last = last,
                first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
                link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
                mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            editors[i] = {
                last = last,
                first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
                link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
                mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

function citation0( config, args)
    
    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. createTag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid({label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid({label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid({label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid({label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid({label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid({label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid({label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid({label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid({label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid({label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid({label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid({label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid({label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot;&lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position }, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = safejoin( {Chapter, tcommon, Date}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text) &lt; 2 then
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
    end
    
    text = createTag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = createTag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = createTag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

function r0(frame, name, group, page)
    if ( name == nil ) then return &quot;&quot; end
    if ( group == nil ) then group = &quot;&quot; end
    local p = &quot;&quot;
    if ( page ~= nil ) then 
        local contents = &quot;:&quot; .. page
        p = createTag({name=&quot;sup&quot;,contents=contents,params={class=&quot;reference&quot;,style=&quot;white-space:nowrap;&quot;}}) 
    end
    return createTag({name=&quot;ref&quot;,contents=&quot;&quot;,params={name=name,group=group}}, frame) .. p
end

function reflist0(frame, config, args)
    local contents = args.refs or &quot;&quot;
    local liststyle = args.liststyle
    local count = args[1]
    local width = args.colwidth
    local group = args.group or config.default_group
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;reflist&quot;    
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local references = createTag({name=&quot;references&quot;,contents=contents,params={group=group}}, frame)
    return createTag({name=&quot;div&quot;,contents=references,params=params})
end

function refbegin0(frame, config, args)
    local liststyle = args.liststyle
    local indent = args.indent
    local indentsize = args.indentsize
    local count = args[1]
    local width = args.colwidth
    if ( nil == tonumber(count) and nil == width ) then 
        width = count
        count = nil
    end
    if ( nil == liststyle ) then
        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
            liststyle = group
        else
            liststyle = config.default_liststyle
        end
    end
    local params = {}
    params.class = &quot;refbegin&quot;
    params.style = z.wikitext.liststyle(liststyle)
    if ( nil ~= count ) then        
        params.class = params.class .. &quot; references-column-count references-column-count-&quot; .. count
        params.style = params.style .. &quot; &quot; .. z.wikitext.columncountstyle(count)
    end    
    if ( nil ~= width ) then
        params.class = params.class .. &quot; references-column-width&quot;
        params.style = params.style .. &quot; &quot; .. z.wikitext.columnwidthstyle(width)
    end
    local dlopen
    if ( nil ~= indent ) then
        dlopen = z.wikitext.OpenHTMLTag({name=&quot;dl&quot;,params={style=&quot;text-indent: -&quot; .. (indentsize or &quot;3.2&quot;) .. &quot;em;&quot;}})
    else
        dlopen = &quot;&quot;
    end
    return z.wikitext.OpenHTMLTag({name=&quot;div&quot;,params=params}) .. dlopen
end

function refend0(frame, config, args)
    local indent = args.indent
    local dlclose
    if ( nil ~= indent ) then
        dlclose = &quot;&lt;/dl&gt;&quot;
    else
        dlclose = &quot;&quot;
    end
    return dlclose .. &quot;&lt;/div&gt;&quot;
end

-- This is used by {{doi}} to create DOI links in the style used in citations.
function z.doi(frame)
    local pframe = frame:getParent()
    local id = pframe.args.id or pframe.args[1] or &quot;&quot;
    return doi(id)
end

-- This is used by {{ISSN}} to create ISSN links in the style used in citations.
function z.ISSN(frame)
    local pframe = frame:getParent()
    local Name = pframe.args[1] or &quot;&quot;
    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;)
end

-- This is used by templates such as {{SfnRef}} to create the (encoded) anchor name for a Harvard cross-reference hyperlink.
function z.SFNID(frame)
    local pframe = frame:getParent()
    return anchorid(pframe.args)
end

-- This is used by templates such as {{Harvard citation}} to create the Harvard cross-reference text.
function z.Harvard(frame)
    local pframe = frame:getParent()
    return crossref(frame, pframe.args)
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
    end    
    
    return citation0( config, args)
end

-- This is used by templates such as {{sfn}} to create the entire cross-reference.
function z.sfn(frame)
    local pframe = frame:getParent()
    local content = crossref(frame, pframe.args)
    local args = { name = refid(pframe.args) }
    return createTag({name = &quot;ref&quot;, contents = content, params = args}, frame)
end

-- This is used by template {{r}}.
function z.r(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    args.page1 = args.page1 or args.page
    local text = &quot;&quot;
    -- 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
        local arg = args[index]
        local t = r0(frame, arg, args.group, args[&quot;page&quot; .. index])
        text = text .. t
        index = index + 1
    end
    return text
end

-- This is used by template {{ref label}}.
function z.reflabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local id = nil
    local contents = &quot;[[#endnote_&quot; .. P1 .. P3 .. &quot;|&amp;#91;&quot; .. P2 .. &quot;&amp;#93;]]&quot;
    local params = {}
    params.class=&quot;reference&quot;
    if ( args.noid == nil or args.noid == &quot;&quot; ) then params.id = &quot;ref_&quot; .. P1 .. P3 end
    return createTag({name=&quot;sup&quot;,contents=contents,params=params})
end

-- This is used by template {{note label}}.
function z.notelabel(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    local id = args[1] or &quot;&quot;
    local arrow = args[3] or &quot;&quot;
    local postscript = args[4] or &quot;&quot;
    local contents 
    if arrow ~= &quot;&quot; then
        local sup_arrow = createTag({name=&quot;sup&quot;,contents=arrow,params={}})
        contents = &quot;[[#ref_&quot; .. id .. arrow .. &quot;|&lt;b&gt;&quot; .. sup_arrow .. &quot;&lt;/b&gt;]]&quot; .. postscript
        if &quot;none&quot; == arrow then arrow = &quot;^&quot; end -- Change this AFTER using it in the ID parameter and the contents.
    else
        contents = (args[2] or &quot;&quot;) .. postscript
    end
    local params = { class=&quot;citation wikicite&quot; }
    if id ~= &quot;&quot; and ( args.noid == nil or args.noid == &quot;&quot; ) then 
        params.id = mw.uri.anchorEncode(&quot;endnote_&quot; .. id .. arrow)
    end
    return createTag({name=&quot;span&quot;,contents=contents,params=params})
end

-- This is used by templates {{reflist}} and {{notelist}}.
function z.reflist(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return reflist0(frame, config, args)
end

-- This is used by template {{refbegin}}.
function z.refbegin(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refbegin0(frame, config, args)
end

-- This is used by template {{refend}}.
function z.refend(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return refend0(frame, config, args)
end

-- This is used by template {{efn}}.
function z.efn(frame)
    local pframe = frame:getParent()
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local args = pframe.args -- the arguments passed TO the template, in the wikitext that instantiates the template
    return createTag({name=&quot;ref&quot;,contents=(args[1] or &quot;&quot;),params={name=args.name,group=config.default_group}}, frame)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>4xnozqcnwrem6b4rggow3yslvw1p5xx</sha1>
    </revision>
    <revision>
      <id>4614</id>
      <parentid>4613</parentid>
      <timestamp>2013-03-17T21:02:39Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>All the functions not directly associated with {cite} moved to Module:Citation</comment>
      <origin>4614</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="53305" sha1="41dj5hrmhbmj69c430oza8vt21hbs3a" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {
    wikitext = require(&quot;Module:Wikitext&quot;),
    extensiontags = {
        nowiki = true,
        ref = true,
        gallery = true,
        pre = true,
        source = true,
        categorytree = true,
        charinsert = true,
        hiero = true,
        imagemap = true,
        inputbox = true,
        math = true,
        poem = true,
        ref = true,
        references = true,
        syntaxhighlight = true,
        timeline = true,
    }
}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',	
            [']'] = '&amp;#93;',	
            ['{'] = '&amp;#123;',	
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

function createTag(t, frame)
    local name = t.name or &quot;!-- --&quot;
    local content = t.contents or &quot;&quot;
    local attrs = {}
    if ( z.extensiontags[name] ) then
        -- We have to preprocess these, so that they are properly turned into so-called &quot;strip markers&quot; in the generated wikitext.
        if ( not frame ) then error (&quot;Please supply an extra frame argument to the createTag() function.&quot;) end
        local params = {}
        for n,v in pairs(t.params) do
            table.insert(params, &quot;|&quot; .. n .. &quot;=&quot; .. v)
        end
        return frame:preprocess(&quot;{{#tag:&quot; .. name .. &quot;|&quot; .. content .. table.concat(params) .. &quot;}}&quot;)
    else   
        for n,v in pairs(t.params) do
            if (v) then
                table.insert(attrs, n .. &quot;=\&quot;&quot; .. wikiescape(v) .. &quot;\&quot;&quot;)
            else
                table.insert(attrs, n)
            end
        end
        if (&quot;&quot; == content) then
            return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;/&gt;&quot;
        else
            return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
        end
    end
end

--[[
This is a clone of mw.text.nowiki.  When the mw.text library is installed,
this can be replaced by a call to that library. ]]
function nowiki( s )
    -- string.gsub is safe here, because we're only caring about ASCII chars
    s = string.gsub( s, '[&quot;&amp;\'&lt;=&gt;%[%]{|}]', {
        ['&quot;'] = '&amp;#34;',
        ['&amp;'] = '&amp;#38;',
        [&quot;'&quot;] = '&amp;#39;',
        ['&lt;'] = '&amp;#60;',
        ['='] = '&amp;#61;',
        ['&gt;'] = '&amp;#62;',
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['{'] = '&amp;#123;',
        ['|'] = '&amp;#124;',
        ['}'] = '&amp;#125;',
    } )
    s = string.sub( string.gsub( '\n' .. s, '\n[#*:;]', {
        [&quot;\n#&quot;] = &quot;\n&amp;#35;&quot;,
        [&quot;\n*&quot;] = &quot;\n&amp;#42;&quot;,
        [&quot;\n:&quot;] = &quot;\n&amp;#58;&quot;,
        [&quot;\n;&quot;] = &quot;\n&amp;#59;&quot;,
    } ), 2 )
    s = string.gsub( s, '://', '&amp;#58;//' )
    s = string.gsub( s, 'ISBN ', 'ISBN&amp;#32;' )
    s = string.gsub( s, 'RFC ', 'RFC&amp;#32;' )

    return s
end

function externallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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;)
    
    return t0 .. t1
end

function internallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid({link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

function doi(id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                end_chr = str:sub(-1,-1);
                if end_chr == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                        str = str:sub(1, -4) .. &quot;''&quot; .. value;
                    else
                        str = str .. value;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3) .. value;
                    else
                        str = str .. value;
                    end                        
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= createTag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end
    
function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            authors[i] = {
                last = last,
                first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
                link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
                mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            editors[i] = {
                last = last,
                first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
                link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
                mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

function citation0( config, args)
    
    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. createTag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid({label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid({label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid({label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid({label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid({label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid({label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid({label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid({label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid({label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid({label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid({label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid({label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid({label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot;&lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position }, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = safejoin( {Chapter, tcommon, Date}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text) &lt; 2 then
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
    end
    
    text = createTag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = createTag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = createTag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>41dj5hrmhbmj69c430oza8vt21hbs3a</sha1>
    </revision>
    <revision>
      <id>4615</id>
      <parentid>4614</parentid>
      <timestamp>2013-03-17T21:12:22Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>remove Module:Wikitext requirement no longer used here, and remove parts of createTag no longer needed</comment>
      <origin>4615</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="52269" sha1="2fjni9otco1oxuhetv5lyv7y23k7blu" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',	
            [']'] = '&amp;#93;',	
            ['{'] = '&amp;#123;',	
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

function createTag(t, frame)
    local name = t.name or &quot;!-- --&quot;
    local content = t.contents or &quot;&quot;
    local attrs = {}
    for n,v in pairs(t.params) do
        if (v) then
            table.insert(attrs, n .. &quot;=\&quot;&quot; .. wikiescape(v) .. &quot;\&quot;&quot;)
        else
            table.insert(attrs, n)
        end
    end
    if (&quot;&quot; == content) then
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;/&gt;&quot;
    else
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    end
end

--[[
This is a clone of mw.text.nowiki.  When the mw.text library is installed,
this can be replaced by a call to that library. ]]
function nowiki( s )
    -- string.gsub is safe here, because we're only caring about ASCII chars
    s = string.gsub( s, '[&quot;&amp;\'&lt;=&gt;%[%]{|}]', {
        ['&quot;'] = '&amp;#34;',
        ['&amp;'] = '&amp;#38;',
        [&quot;'&quot;] = '&amp;#39;',
        ['&lt;'] = '&amp;#60;',
        ['='] = '&amp;#61;',
        ['&gt;'] = '&amp;#62;',
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['{'] = '&amp;#123;',
        ['|'] = '&amp;#124;',
        ['}'] = '&amp;#125;',
    } )
    s = string.sub( string.gsub( '\n' .. s, '\n[#*:;]', {
        [&quot;\n#&quot;] = &quot;\n&amp;#35;&quot;,
        [&quot;\n*&quot;] = &quot;\n&amp;#42;&quot;,
        [&quot;\n:&quot;] = &quot;\n&amp;#58;&quot;,
        [&quot;\n;&quot;] = &quot;\n&amp;#59;&quot;,
    } ), 2 )
    s = string.gsub( s, '://', '&amp;#58;//' )
    s = string.gsub( s, 'ISBN ', 'ISBN&amp;#32;' )
    s = string.gsub( s, 'RFC ', 'RFC&amp;#32;' )

    return s
end

function externallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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;)
    
    return t0 .. t1
end

function internallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid({link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

function doi(id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

function hyphentodash( str )
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                end_chr = str:sub(-1,-1);
                if end_chr == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                        str = str:sub(1, -4) .. &quot;''&quot; .. value;
                    else
                        str = str .. value;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3) .. value;
                    else
                        str = str .. value;
                    end                        
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= createTag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function refid(args)
    local p = args.p or &quot;&quot;
    local pp = args.pp or &quot;&quot;
    local loc = args.loc or &quot;&quot;
    return anchorid(args) .. p .. pp .. loc    
end

function name(args)
    local P1 = args[1] or &quot;&quot;
    if ( args[5] ~= nil) then
        return P1 .. &quot; et al.&quot;
    else
        local P2 = args[2] or &quot;&quot;
        local P3 = args[3] or &quot;&quot; 
        local P4 = args[4] or &quot;&quot;
        if ( args[4] ~= nil ) then
            P4 = &quot; &quot; .. P4
            P3 = &quot;, &amp; &quot; .. P3
            P2 = &quot;, &quot; .. P2
        elseif ( args[3] ~= nil ) then
            P3 = &quot; &quot; .. P3
            P2 = &quot; &amp; &quot; .. P2
        elseif ( args[2] ~= nil ) then
            P2 = &quot; &quot; .. P2            
        end
        return P1 .. P2 .. P3 .. P4
    end 
end

function crossref(frame, args)
    local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
    local LB = config.BracketLeft or &quot;&quot;
    local RB = config.BracketRight or &quot;&quot;
    local anchor = args.ref or args.Ref or anchorid(args)
    local text = name(args)
    local loc = args.loc
    local page
    local pages = args.pp or args.pages
    if pages == nil or pages == '' then
        page = args.p or args.page;
    end 
    if nil == loc then loc = &quot;&quot; else loc = &quot; &quot; .. loc end
    if ( page ~= nil ) then
        local pagesep = config.PageSep or &quot;, p. &quot;
        loc = loc .. pagesep .. page
    end
    if ( pages ~= nil ) then
        local pagessep = config.PagesSep or &quot;, pp. &quot;
        loc = loc .. pagessep .. pages
    end        
    local pagename = args.pagename or &quot;&quot;
    local ps = args.Postscript or &quot;&quot;
    return LB .. &quot;[[&quot; .. pagename .. &quot;#&quot; .. anchor .. &quot;|&quot; .. text .. &quot;]]&quot; .. loc .. RB .. ps
end
    
function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            authors[i] = {
                last = last,
                first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
                link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
                mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            editors[i] = {
                last = last,
                first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
                link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
                mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

function citation0( config, args)
    
    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page
    local Pages = args.pages
    if Pages == nil or Pages == '' then
        Page = args.page  -- allows Pages to override Page
    else
        Pages = hyphentodash( Pages );
    end

    local PP = args.pp
    local At = args.at
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Page = &quot;: &quot; .. Page
    else
        Page = sepc ..&quot; &quot; .. PPrefix .. Page
    end
    if ( nil == Pages or &quot;&quot; == Pages) then 
        Pages = &quot;&quot; 
    elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
        Pages = &quot;: &quot; .. Pages
    else
        if ( tonumber(Pages) ~= nil ) then
          Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
        else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. createTag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid({label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid({label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid({label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid({label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid({label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid({label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid({label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid({label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid({label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid({label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid({label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid({label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid({label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot;&lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position }, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = safejoin( {Chapter, tcommon, Date}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text) &lt; 2 then
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
    end
    
    text = createTag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = createTag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = createTag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--
--End</text>
      <sha1>2fjni9otco1oxuhetv5lyv7y23k7blu</sha1>
    </revision>
    <revision>
      <id>4616</id>
      <parentid>4615</parentid>
      <timestamp>2013-03-18T19:13:36Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>merge from sandbox.  Removes unused functions (moved to Module:Citation) and updates page handling</comment>
      <origin>4616</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="51268" sha1="sl3rbshz1x83gtpfe9oi7y8sstxs4g5" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',	
            ['{'] = '&amp;#123;',	
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

function createTag(t, frame)
    local name = t.name or &quot;!-- --&quot;
    local content = t.contents or &quot;&quot;
    local attrs = {}
    for n,v in pairs(t.params) do
        if (v) then
            table.insert(attrs, n .. &quot;=\&quot;&quot; .. wikiescape(v) .. &quot;\&quot;&quot;)
        else
            table.insert(attrs, n)
        end
    end
    if (&quot;&quot; == content) then
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;/&gt;&quot;
    else
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    end
end

--[[
This is a clone of mw.text.nowiki.  When the mw.text library is installed,
this can be replaced by a call to that library. ]]
function nowiki( s )
    -- string.gsub is safe here, because we're only caring about ASCII chars
    s = string.gsub( s, '[&quot;&amp;\'&lt;=&gt;%[%]{|}]', {
        ['&quot;'] = '&amp;#34;',
        ['&amp;'] = '&amp;#38;',
        [&quot;'&quot;] = '&amp;#39;',
        ['&lt;'] = '&amp;#60;',
        ['='] = '&amp;#61;',
        ['&gt;'] = '&amp;#62;',
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['{'] = '&amp;#123;',
        ['|'] = '&amp;#124;',
        ['}'] = '&amp;#125;',
    } )
    s = string.sub( string.gsub( '\n' .. s, '\n[#*:;]', {
        [&quot;\n#&quot;] = &quot;\n&amp;#35;&quot;,
        [&quot;\n*&quot;] = &quot;\n&amp;#42;&quot;,
        [&quot;\n:&quot;] = &quot;\n&amp;#58;&quot;,
        [&quot;\n;&quot;] = &quot;\n&amp;#59;&quot;,
    } ), 2 )
    s = string.gsub( s, '://', '&amp;#58;//' )
    s = string.gsub( s, 'ISBN ', 'ISBN&amp;#32;' )
    s = string.gsub( s, 'RFC ', 'RFC&amp;#32;' )

    return s
end

function externallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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;)
    
    return t0 .. t1
end

function internallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid({link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

function doi(id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                end_chr = str:sub(-1,-1);
                if end_chr == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                        str = str:sub(1, -4) .. &quot;''&quot; .. value;
                    else
                        str = str .. value;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3) .. value;
                    else
                        str = str .. value;
                    end                        
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        return '';
    end
end

function openlibrary(id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= createTag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            authors[i] = {
                last = last,
                first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
                link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
                mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            editors[i] = {
                last = last,
                first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
                link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
                mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

function citation0( config, args)
    
    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.p or args.page
    local Pages = hyphentodash( args.pp or args.pages )
    local At = args.at
    local page_error = false;
    
    if Page ~= nil and Page ~= '' then
        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 Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. createTag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid({label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid({label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid({label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid({label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid({label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid({label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid({label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid({label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid({label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid({label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid({label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid({label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid({label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot;&lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position }, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if page_error then
        pgtext = pgtext .. '[[Category:References with multiple page specifications]]&lt;!-- Bad page specification here --&gt;';
    end
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = safejoin( {Chapter, tcommon, Date}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text) &lt; 2 then
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
    end
    
    text = createTag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = createTag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = createTag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--18Mar2013 Fixed &quot;page=&quot; to override &quot;pages=&quot; as in markup-based cites.
--
--End</text>
      <sha1>sl3rbshz1x83gtpfe9oi7y8sstxs4g5</sha1>
    </revision>
    <revision>
      <id>4617</id>
      <parentid>4616</parentid>
      <timestamp>2013-03-18T22:25:59Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>workaround for limitations of formatDate</comment>
      <origin>4617</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="51645" sha1="0xsgr31sdda1832dw6degx9u4fkm7xl" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',	
            ['{'] = '&amp;#123;',	
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

function createTag(t, frame)
    local name = t.name or &quot;!-- --&quot;
    local content = t.contents or &quot;&quot;
    local attrs = {}
    for n,v in pairs(t.params) do
        if (v) then
            table.insert(attrs, n .. &quot;=\&quot;&quot; .. wikiescape(v) .. &quot;\&quot;&quot;)
        else
            table.insert(attrs, n)
        end
    end
    if (&quot;&quot; == content) then
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;/&gt;&quot;
    else
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    end
end

--[[
This is a clone of mw.text.nowiki.  When the mw.text library is installed,
this can be replaced by a call to that library. ]]
function nowiki( s )
    -- string.gsub is safe here, because we're only caring about ASCII chars
    s = string.gsub( s, '[&quot;&amp;\'&lt;=&gt;%[%]{|}]', {
        ['&quot;'] = '&amp;#34;',
        ['&amp;'] = '&amp;#38;',
        [&quot;'&quot;] = '&amp;#39;',
        ['&lt;'] = '&amp;#60;',
        ['='] = '&amp;#61;',
        ['&gt;'] = '&amp;#62;',
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['{'] = '&amp;#123;',
        ['|'] = '&amp;#124;',
        ['}'] = '&amp;#125;',
    } )
    s = string.sub( string.gsub( '\n' .. s, '\n[#*:;]', {
        [&quot;\n#&quot;] = &quot;\n&amp;#35;&quot;,
        [&quot;\n*&quot;] = &quot;\n&amp;#42;&quot;,
        [&quot;\n:&quot;] = &quot;\n&amp;#58;&quot;,
        [&quot;\n;&quot;] = &quot;\n&amp;#59;&quot;,
    } ), 2 )
    s = string.gsub( s, '://', '&amp;#58;//' )
    s = string.gsub( s, 'ISBN ', 'ISBN&amp;#32;' )
    s = string.gsub( s, 'RFC ', 'RFC&amp;#32;' )

    return s
end

function externallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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;)
    
    return t0 .. t1
end

function internallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid({link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

function doi(id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                end_chr = str:sub(-1,-1);
                if end_chr == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                        str = str:sub(1, -4) .. &quot;''&quot; .. value;
                    else
                        str = str .. value;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3) .. value;
                    else
                        str = str .. value;
                    end                        
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        --[[
        FormatDate fails on years that are less than 4 digits.  If the input 
        is a positive integer, assume it is a valid year even if it has less 
        than four digits.  
        ]]
        local num = tonumber( str );
        if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
            return str;
        else
            return '';
        end
    end
end

function openlibrary(id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= createTag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            authors[i] = {
                last = last,
                first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
                link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
                mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            editors[i] = {
                last = last,
                first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
                link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
                mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

function citation0( config, args)
    
    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.p or args.page
    local Pages = hyphentodash( args.pp or args.pages )
    local At = args.at
    local page_error = false;
    
    if Page ~= nil and Page ~= '' then
        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 Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. createTag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid({label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid({label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid({label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid({label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid({label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid({label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid({label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid({label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid({label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid({label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid({label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid({label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid({label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot;&lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position }, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if page_error then
        pgtext = pgtext .. '[[Category:References with multiple page specifications]]&lt;!-- Bad page specification here --&gt;';
    end
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = safejoin( {Chapter, tcommon, Date}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text) &lt; 2 then
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
    end
    
    text = createTag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = createTag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = createTag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--18Mar2013 Fixed &quot;page=&quot; to override &quot;pages=&quot; as in markup-based cites.
--
--End</text>
      <sha1>0xsgr31sdda1832dw6degx9u4fkm7xl</sha1>
    </revision>
    <revision>
      <id>4618</id>
      <parentid>4617</parentid>
      <timestamp>2013-03-19T00:10:17Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <minor />
      <comment>check for empty parameter</comment>
      <origin>4618</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="51661" sha1="neun4dntwdu7oxds0jmep652y5yk23n" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',	
            ['{'] = '&amp;#123;',	
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

function createTag(t, frame)
    local name = t.name or &quot;!-- --&quot;
    local content = t.contents or &quot;&quot;
    local attrs = {}
    for n,v in pairs(t.params) do
        if (v) then
            table.insert(attrs, n .. &quot;=\&quot;&quot; .. wikiescape(v) .. &quot;\&quot;&quot;)
        else
            table.insert(attrs, n)
        end
    end
    if (&quot;&quot; == content) then
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;/&gt;&quot;
    else
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    end
end

--[[
This is a clone of mw.text.nowiki.  When the mw.text library is installed,
this can be replaced by a call to that library. ]]
function nowiki( s )
    -- string.gsub is safe here, because we're only caring about ASCII chars
    s = string.gsub( s, '[&quot;&amp;\'&lt;=&gt;%[%]{|}]', {
        ['&quot;'] = '&amp;#34;',
        ['&amp;'] = '&amp;#38;',
        [&quot;'&quot;] = '&amp;#39;',
        ['&lt;'] = '&amp;#60;',
        ['='] = '&amp;#61;',
        ['&gt;'] = '&amp;#62;',
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['{'] = '&amp;#123;',
        ['|'] = '&amp;#124;',
        ['}'] = '&amp;#125;',
    } )
    s = string.sub( string.gsub( '\n' .. s, '\n[#*:;]', {
        [&quot;\n#&quot;] = &quot;\n&amp;#35;&quot;,
        [&quot;\n*&quot;] = &quot;\n&amp;#42;&quot;,
        [&quot;\n:&quot;] = &quot;\n&amp;#58;&quot;,
        [&quot;\n;&quot;] = &quot;\n&amp;#59;&quot;,
    } ), 2 )
    s = string.gsub( s, '://', '&amp;#58;//' )
    s = string.gsub( s, 'ISBN ', 'ISBN&amp;#32;' )
    s = string.gsub( s, 'RFC ', 'RFC&amp;#32;' )

    return s
end

function externallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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;)
    
    return t0 .. t1
end

function internallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid({link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

function doi(id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                end_chr = str:sub(-1,-1);
                if end_chr == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                        str = str:sub(1, -4) .. &quot;''&quot; .. value;
                    else
                        str = str .. value;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3) .. value;
                    else
                        str = str .. value;
                    end                        
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        --[[
        FormatDate fails on years that are less than 4 digits.  If the input 
        is a positive integer, assume it is a valid year even if it has less 
        than four digits.  
        ]]
        local num = tonumber( str );
        if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
            return str;
        else
            return '';
        end
    end
end

function openlibrary(id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil and first ~= '') then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= createTag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            authors[i] = {
                last = last,
                first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
                link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
                mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            editors[i] = {
                last = last,
                first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
                link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
                mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

function citation0( config, args)
    
    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end            
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.p or args.page
    local Pages = hyphentodash( args.pp or args.pages )
    local At = args.at
    local page_error = false;
    
    if Page ~= nil and Page ~= '' then
        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 Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. createTag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid({label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid({label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid({label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid({label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid({label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid({label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid({label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid({label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid({label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid({label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid({label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid({label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid({label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot;&lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position }, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if page_error then
        pgtext = pgtext .. '[[Category:References with multiple page specifications]]&lt;!-- Bad page specification here --&gt;';
    end
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end                
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end                
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        text = safejoin( {Chapter, tcommon, Date}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end        
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text) &lt; 2 then
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
    end
    
    text = createTag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = createTag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = createTag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--18Mar2013 Fixed &quot;page=&quot; to override &quot;pages=&quot; as in markup-based cites.
--
--End</text>
      <sha1>neun4dntwdu7oxds0jmep652y5yk23n</sha1>
    </revision>
    <revision>
      <id>4619</id>
      <parentid>4618</parentid>
      <timestamp>2013-03-19T14:08:44Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>merge with sandbox</comment>
      <origin>4619</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="51985" sha1="s8h4v5qmkn73j2jsuzg1drcaprjred8" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',	
            ['{'] = '&amp;#123;',	
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

function createTag(t, frame)
    local name = t.name or &quot;!-- --&quot;
    local content = t.contents or &quot;&quot;
    local attrs = {}
    for n,v in pairs(t.params) do
        if (v) then
            table.insert(attrs, n .. &quot;=\&quot;&quot; .. wikiescape(v) .. &quot;\&quot;&quot;)
        else
            table.insert(attrs, n)
        end
    end
    if (&quot;&quot; == content) then
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;/&gt;&quot;
    else
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    end
end

--[[
This is a clone of mw.text.nowiki.  When the mw.text library is installed,
this can be replaced by a call to that library. ]]
function nowiki( s )
    -- string.gsub is safe here, because we're only caring about ASCII chars
    s = string.gsub( s, '[&quot;&amp;\'&lt;=&gt;%[%]{|}]', {
        ['&quot;'] = '&amp;#34;',
        ['&amp;'] = '&amp;#38;',
        [&quot;'&quot;] = '&amp;#39;',
        ['&lt;'] = '&amp;#60;',
        ['='] = '&amp;#61;',
        ['&gt;'] = '&amp;#62;',
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['{'] = '&amp;#123;',
        ['|'] = '&amp;#124;',
        ['}'] = '&amp;#125;',
    } )
    s = string.sub( string.gsub( '\n' .. s, '\n[#*:;]', {
        [&quot;\n#&quot;] = &quot;\n&amp;#35;&quot;,
        [&quot;\n*&quot;] = &quot;\n&amp;#42;&quot;,
        [&quot;\n:&quot;] = &quot;\n&amp;#58;&quot;,
        [&quot;\n;&quot;] = &quot;\n&amp;#59;&quot;,
    } ), 2 )
    s = string.gsub( s, '://', '&amp;#58;//' )
    s = string.gsub( s, 'ISBN ', 'ISBN&amp;#32;' )
    s = string.gsub( s, 'RFC ', 'RFC&amp;#32;' )

    return s
end

function externallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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;)
    
    return t0 .. t1
end

function internallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid({link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

function doi(id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                end_chr = str:sub(-1,-1);
                if end_chr == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                        str = str:sub(1, -4) .. &quot;''&quot; .. value;
                    else
                        str = str .. value;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3) .. value;
                    else
                        str = str .. value;
                    end
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        --[[
        FormatDate fails on years that are less than 4 digits.  If the input 
        is a positive integer, assume it is a valid year even if it has less 
        than four digits.  
        ]]
        local num = tonumber( str );
        if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
            return str;
        else
            return '';
        end
    end
end

function openlibrary(id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil and first ~= '') then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= createTag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            authors[i] = {
                last = last,
                first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
                link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
                mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            editors[i] = {
                last = last,
                first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
                link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
                mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

function citation0( config, args)
    
    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.p or args.page
    local Pages = hyphentodash( args.pp or args.pages )
    local At = args.at
    local page_error = false;
    
    if Page ~= nil and Page ~= '' then
        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 Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. createTag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid({label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid({label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid({label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid({label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid({label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid({label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid({label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid({label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid({label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid({label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid({label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid({label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid({label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot;&lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position }, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if (args.postscript == &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if page_error then
        pgtext = pgtext .. '[[Category:References with multiple page specifications]]&lt;!-- Bad page specification here --&gt;';
    end
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        if ( config.CitationClass==&quot;journal&quot; and Periodical ) then
          text = safejoin( {Chapter, tcommon}, sepc );
          text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
          text = safejoin( {Chapter, tcommon, Date}, sepc );
          text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text) &lt; 2 then
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
    end
    
    text = createTag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = createTag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = createTag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--18Mar2013 Fixed &quot;page=&quot; to override &quot;pages=&quot; as in markup-based cites.
--19Mar2013 Fixed date of class=journal Periodical to show after page.
--19Mar2013 Changed null &quot;postscript=&quot; to suppress end-dot of citation.
--
--End</text>
      <sha1>s8h4v5qmkn73j2jsuzg1drcaprjred8</sha1>
    </revision>
    <revision>
      <id>4620</id>
      <parentid>4619</parentid>
      <timestamp>2013-03-19T14:16:02Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <minor />
      <comment>Changed protection level of Module:Citation/CS1: [[WP:High-risk templates|Highly visible template]] ([Edit=Block all non-admin users] (indefinite) [Move=Block all non-admin users] (indefinite))</comment>
      <origin>4619</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="51985" sha1="s8h4v5qmkn73j2jsuzg1drcaprjred8" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',	
            ['{'] = '&amp;#123;',	
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

function createTag(t, frame)
    local name = t.name or &quot;!-- --&quot;
    local content = t.contents or &quot;&quot;
    local attrs = {}
    for n,v in pairs(t.params) do
        if (v) then
            table.insert(attrs, n .. &quot;=\&quot;&quot; .. wikiescape(v) .. &quot;\&quot;&quot;)
        else
            table.insert(attrs, n)
        end
    end
    if (&quot;&quot; == content) then
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;/&gt;&quot;
    else
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    end
end

--[[
This is a clone of mw.text.nowiki.  When the mw.text library is installed,
this can be replaced by a call to that library. ]]
function nowiki( s )
    -- string.gsub is safe here, because we're only caring about ASCII chars
    s = string.gsub( s, '[&quot;&amp;\'&lt;=&gt;%[%]{|}]', {
        ['&quot;'] = '&amp;#34;',
        ['&amp;'] = '&amp;#38;',
        [&quot;'&quot;] = '&amp;#39;',
        ['&lt;'] = '&amp;#60;',
        ['='] = '&amp;#61;',
        ['&gt;'] = '&amp;#62;',
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['{'] = '&amp;#123;',
        ['|'] = '&amp;#124;',
        ['}'] = '&amp;#125;',
    } )
    s = string.sub( string.gsub( '\n' .. s, '\n[#*:;]', {
        [&quot;\n#&quot;] = &quot;\n&amp;#35;&quot;,
        [&quot;\n*&quot;] = &quot;\n&amp;#42;&quot;,
        [&quot;\n:&quot;] = &quot;\n&amp;#58;&quot;,
        [&quot;\n;&quot;] = &quot;\n&amp;#59;&quot;,
    } ), 2 )
    s = string.gsub( s, '://', '&amp;#58;//' )
    s = string.gsub( s, 'ISBN ', 'ISBN&amp;#32;' )
    s = string.gsub( s, 'RFC ', 'RFC&amp;#32;' )

    return s
end

function externallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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;)
    
    return t0 .. t1
end

function internallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid({link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

function doi(id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                end_chr = str:sub(-1,-1);
                if end_chr == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                        str = str:sub(1, -4) .. &quot;''&quot; .. value;
                    else
                        str = str .. value;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3) .. value;
                    else
                        str = str .. value;
                    end
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        --[[
        FormatDate fails on years that are less than 4 digits.  If the input 
        is a positive integer, assume it is a valid year even if it has less 
        than four digits.  
        ]]
        local num = tonumber( str );
        if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
            return str;
        else
            return '';
        end
    end
end

function openlibrary(id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil and first ~= '') then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= createTag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            authors[i] = {
                last = last,
                first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
                link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
                mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            editors[i] = {
                last = last,
                first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
                link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
                mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

function citation0( config, args)
    
    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.p or args.page
    local Pages = hyphentodash( args.pp or args.pages )
    local At = args.at
    local page_error = false;
    
    if Page ~= nil and Page ~= '' then
        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 Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. createTag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid({label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid({label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid({label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid({label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid({label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid({label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid({label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid({label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid({label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid({label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid({label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid({label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid({label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot;&lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position }, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if (args.postscript == &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if page_error then
        pgtext = pgtext .. '[[Category:References with multiple page specifications]]&lt;!-- Bad page specification here --&gt;';
    end
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        if ( config.CitationClass==&quot;journal&quot; and Periodical ) then
          text = safejoin( {Chapter, tcommon}, sepc );
          text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
          text = safejoin( {Chapter, tcommon, Date}, sepc );
          text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text) &lt; 2 then
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
    end
    
    text = createTag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = createTag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = createTag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--18Mar2013 Fixed &quot;page=&quot; to override &quot;pages=&quot; as in markup-based cites.
--19Mar2013 Fixed date of class=journal Periodical to show after page.
--19Mar2013 Changed null &quot;postscript=&quot; to suppress end-dot of citation.
--
--End</text>
      <sha1>s8h4v5qmkn73j2jsuzg1drcaprjred8</sha1>
    </revision>
    <revision>
      <id>4621</id>
      <parentid>4620</parentid>
      <timestamp>2013-03-19T15:30:18Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>error handling for archiveurl / url</comment>
      <origin>4621</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="52301" sha1="5my5iro171x3sbe6306gjj9hoz545ua" xml:space="preserve">---------------------------------------------------------------------
-- Module:Citation/CS1 - Lua module for Citation Style 1 templates
---------------------------------------------------------------------
--                               (see NOTES at bottom)
--require &quot;mw.text&quot;

local z = {}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',	
            ['{'] = '&amp;#123;',	
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

function createTag(t, frame)
    local name = t.name or &quot;!-- --&quot;
    local content = t.contents or &quot;&quot;
    local attrs = {}
    for n,v in pairs(t.params) do
        if (v) then
            table.insert(attrs, n .. &quot;=\&quot;&quot; .. wikiescape(v) .. &quot;\&quot;&quot;)
        else
            table.insert(attrs, n)
        end
    end
    if (&quot;&quot; == content) then
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;/&gt;&quot;
    else
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    end
end

--[[
This is a clone of mw.text.nowiki.  When the mw.text library is installed,
this can be replaced by a call to that library. ]]
function nowiki( s )
    -- string.gsub is safe here, because we're only caring about ASCII chars
    s = string.gsub( s, '[&quot;&amp;\'&lt;=&gt;%[%]{|}]', {
        ['&quot;'] = '&amp;#34;',
        ['&amp;'] = '&amp;#38;',
        [&quot;'&quot;] = '&amp;#39;',
        ['&lt;'] = '&amp;#60;',
        ['='] = '&amp;#61;',
        ['&gt;'] = '&amp;#62;',
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['{'] = '&amp;#123;',
        ['|'] = '&amp;#124;',
        ['}'] = '&amp;#125;',
    } )
    s = string.sub( string.gsub( '\n' .. s, '\n[#*:;]', {
        [&quot;\n#&quot;] = &quot;\n&amp;#35;&quot;,
        [&quot;\n*&quot;] = &quot;\n&amp;#42;&quot;,
        [&quot;\n:&quot;] = &quot;\n&amp;#58;&quot;,
        [&quot;\n;&quot;] = &quot;\n&amp;#59;&quot;,
    } ), 2 )
    s = string.gsub( s, '://', '&amp;#58;//' )
    s = string.gsub( s, 'ISBN ', 'ISBN&amp;#32;' )
    s = string.gsub( s, 'RFC ', 'RFC&amp;#32;' )

    return s
end

function externallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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;)
    
    return t0 .. t1
end

function internallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid({link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

function doi(id, inactive, nocat)
    local cat = &quot;&quot;
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        cat = cat .. &quot;[[Category:Pages with DOIs inactive since &quot; .. selectyear(inactive) .. &quot;]]&quot;
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        cat = cat .. &quot;[[Category:Pages with DOI errors]]&quot; .. '&lt;span class=&quot;error&quot;&gt; Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    if ( nocat and nocat ~= &quot;&quot; ) then cat = &quot;&quot; end
    return text .. inactive .. cat    
 end

function url(id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                end_chr = str:sub(-1,-1);
                if end_chr == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                        str = str:sub(1, -4) .. &quot;''&quot; .. value;
                    else
                        str = str .. value;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3) .. value;
                    else
                        str = str .. value;
                    end
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        --[[
        FormatDate fails on years that are less than 4 digits.  If the input 
        is a positive integer, assume it is a valid year even if it has less 
        than four digits.  
        ]]
        local num = tonumber( str );
        if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
            return str;
        else
            return '';
        end
    end
end

function openlibrary(id)
    local cat = &quot;&quot;
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        cat = cat .. &quot;[[Category:Pages with OL errors]]&quot;
    end
    local text = externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    return text .. cat
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil and first ~= '') then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= createTag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            authors[i] = {
                last = last,
                first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
                link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
                mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            editors[i] = {
                last = last,
                first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
                link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
                mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

function citation0( config, args)
    
    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.p or args.page
    local Pages = hyphentodash( args.pp or args.pages )
    local At = args.at
    local page_error = false;
    
    if Page ~= nil and Page ~= '' then
        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 Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. createTag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid({label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid({label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
       DOI = sepc .. &quot; &quot; .. doi(DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid({label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid({label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid({label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid({label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid({label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid({label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid({label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc ..&quot; &quot; .. openlibrary(OL) else OL = &quot;&quot; end
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid({label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid({label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid({label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(URL)
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid({label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot;&lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            if args.url ~= nil and args.url ~= '' then
                Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
            else
                Archived = sepc .. arch_text .. &quot; from &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;&quot; ..
                    &quot;, you must also specify &lt;code&gt;url=&lt;/code&gt;&lt;/span&gt; on&quot; .. ArchiveDate
            end                
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position }, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if (args.postscript == &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if page_error then
        pgtext = pgtext .. '[[Category:References with multiple page specifications]]&lt;!-- Bad page specification here --&gt;';
    end
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        if ( config.CitationClass==&quot;journal&quot; and Periodical ) then
          text = safejoin( {Chapter, tcommon}, sepc );
          text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
          text = safejoin( {Chapter, tcommon, Date}, sepc );
          text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text) &lt; 2 then
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
    end
    
    text = createTag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = createTag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = createTag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
        
    return text .. OCinS
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--18Mar2013 Fixed &quot;page=&quot; to override &quot;pages=&quot; as in markup-based cites.
--19Mar2013 Fixed date of class=journal Periodical to show after page.
--19Mar2013 Changed null &quot;postscript=&quot; to suppress end-dot of citation.
--
--End</text>
      <sha1>5my5iro171x3sbe6306gjj9hoz545ua</sha1>
    </revision>
    <revision>
      <id>4622</id>
      <parentid>4621</parentid>
      <timestamp>2013-03-20T18:33:30Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>Adds a variety of error tracking and handling</comment>
      <origin>4622</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="54698" sha1="i4r525bgxdwzmzqrvfr7n6en3obn80w" xml:space="preserve">local z = {}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',    
            ['{'] = '&amp;#123;',    
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

function createTag(t, frame)
    local name = t.name or &quot;!-- --&quot;
    local content = t.contents or &quot;&quot;
    local attrs = {}
    for n,v in pairs(t.params) do
        if (v) then
            table.insert(attrs, n .. &quot;=\&quot;&quot; .. wikiescape(v) .. &quot;\&quot;&quot;)
        else
            table.insert(attrs, n)
        end
    end
    if (&quot;&quot; == content) then
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;/&gt;&quot;
    else
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    end
end

--[[
This is a clone of mw.text.nowiki.  When the mw.text library is installed,
this can be replaced by a call to that library. ]]
function nowiki( s )
    -- string.gsub is safe here, because we're only caring about ASCII chars
    s = string.gsub( s, '[&quot;&amp;\'&lt;=&gt;%[%]{|}]', {
        ['&quot;'] = '&amp;#34;',
        ['&amp;'] = '&amp;#38;',
        [&quot;'&quot;] = '&amp;#39;',
        ['&lt;'] = '&amp;#60;',
        ['='] = '&amp;#61;',
        ['&gt;'] = '&amp;#62;',
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['{'] = '&amp;#123;',
        ['|'] = '&amp;#124;',
        ['}'] = '&amp;#125;',
    } )
    s = string.sub( string.gsub( '\n' .. s, '\n[#*:;]', {
        [&quot;\n#&quot;] = &quot;\n&amp;#35;&quot;,
        [&quot;\n*&quot;] = &quot;\n&amp;#42;&quot;,
        [&quot;\n:&quot;] = &quot;\n&amp;#58;&quot;,
        [&quot;\n;&quot;] = &quot;\n&amp;#59;&quot;,
    } ), 2 )
    s = string.gsub( s, '://', '&amp;#58;//' )
    s = string.gsub( s, 'ISBN ', 'ISBN&amp;#32;' )
    s = string.gsub( s, 'RFC ', 'RFC&amp;#32;' )

    return s
end

function externallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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;)
    
    return t0 .. t1
end

function internallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid({link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

function doi(id, inactive)
    local cat = &quot;&quot;
    local error_categories = {};
    
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        table.insert( error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        table.insert( error_categories, &quot;Pages with DOI errors&quot; );        
        cat = ' &lt;span class=&quot;error&quot;&gt;Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    return text .. inactive .. cat, error_categories 
 end

function url(id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                end_chr = str:sub(-1,-1);
                if end_chr == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                        str = str:sub(1, -4) .. &quot;''&quot; .. value;
                    else
                        str = str .. value;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3) .. value;
                    else
                        str = str .. value;
                    end
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        --[[
        FormatDate fails on years that are less than 4 digits.  If the input 
        is a positive integer, assume it is a valid year even if it has less 
        than four digits.  
        ]]
        local num = tonumber( str );
        if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
            return str;
        else
            return '';
        end
    end
end

function openlibrary(id)
    local error_categories = {};
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        table.insert( error_categories, &quot;Pages with OL errors&quot; );
    end
    local text = externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    if #error_categories ~= 0 then
        text = text .. ' &lt;span class=&quot;error&quot;&gt;Bad OL specified&lt;/span&gt;';
    end    
    return text, error_categories
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil and first ~= '') then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= createTag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            authors[i] = {
                last = last,
                first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
                link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
                mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            editors[i] = {
                last = last,
                first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
                link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
                mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

function citation0( config, args)
    local error_categories = {};
    
    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.p or args.page
    local Pages = hyphentodash( args.pp or args.pages )
    local At = args.at
    local page_error = false;
    
    if Page ~= nil and Page ~= '' then
        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 Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    local no_tracking_cats = args[&quot;template doc demo&quot;] or args[&quot;nocat&quot;] or args[&quot;notracking&quot;] or args[&quot;no-tracking&quot;];

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date
    if ( config.CitationClass == &quot;web&quot; ) then
        if ( URL == nil or URL == '' ) and
                ( ChapterURL == nil or ChapterURL == '' ) and
                ( ArchiveURL == nil or ArchiveURL == '' ) and                
                ( ConferenceURL == nil or ConferenceURL == '' ) and                
                ( TranscriptURL == nil or TranscriptURL == '' ) then
            table.insert( error_categories, 'Pages using web citations with no URL' );
            if Title == nil or Title == &quot;&quot; then 
                Authors = Authors .. &quot;&lt;!-- No URL on cite web here --&gt;&quot;; 
            else
                Title = Title .. &quot;&lt;!-- No URL on cite web here --&gt;&quot;;
            end
        end
    end    

    if ( Chapter == nil or Chapter == &quot;&quot; ) and 
            ( Title == nil or Title == &quot;&quot; ) and
            ( Periodcial == nil or Periodical == &quot;&quot; ) and
            ( Conference == nil or Conference == &quot;&quot; ) then
        table.insert( error_categories, 'Pages with citations lacking titles' );
        Authors = Authors .. &quot;&lt;!-- No citation title here --&gt;&quot;;
    end

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. createTag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid({label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid({label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
        local DOI_string, DOI_error;
        DOI_string, DOI_error = doi(DOI, DoiBroken);
        DOI = sepc .. &quot; &quot; .. DOI_string
        for _, v in ipairs( DOI_error ) do
            table.insert( error_categories, v );
        end        
    else 
        DOI = &quot;&quot; 
    end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid({label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid({label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid({label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid({label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid({label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid({label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid({label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        local OL_string, OL_error;
        OL_string, OL_error = openlibrary(OL);
        OL = sepc .. &quot; &quot; .. OL_string
        for _, v in ipairs( OL_error ) do
            table.insert( error_categories, v );
        end      
    else
        OL = &quot;&quot;;
    end    
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid({label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid({label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid({label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(URL)
       table.insert( error_categories, &quot;Pages with citations having bare URLs&quot; );
       if config.CitationClass == &quot;web&quot; then
           URL = URL .. &quot; &lt;span class='error'&gt;No &lt;code&gt;title=&lt;/code&gt; specified&lt;/span&gt;&quot;
       else
           URL = URL .. &quot;&lt;!-- Bare URL here --&gt;&quot;
       end       
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid({label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot; &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
            table.insert( error_categories, 'Pages with archiveurl citation errors' );
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            if args.url ~= nil and args.url ~= '' then
                Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
            else
                Archived = sepc .. arch_text .. &quot; from &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;&quot; ..
                    &quot;, you must also specify &lt;code&gt;url=&lt;/code&gt;&lt;/span&gt; on&quot; .. ArchiveDate
                table.insert( error_categories, 'Pages with archiveurl citation errors' );
            end                
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position}, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if (args.postscript == &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if page_error then
        table.insert( error_categories, 'Pages with citations using conflicting page specifications' );
        pgtext = pgtext .. '&lt;!-- Bad page specification here --&gt;';
    end
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        if ( config.CitationClass==&quot;journal&quot; and Periodical ) then
          text = safejoin( {Chapter, tcommon}, sepc );
          text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
          text = safejoin( {Chapter, tcommon, Date}, sepc );
          text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text:gsub(&quot;%b&lt;&gt;&quot;, &quot;&quot;)) &lt;= 2 then
        table.insert( error_categories, 'Pages with empty citations' );
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
    end
    
    text = createTag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = createTag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = createTag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
    text = text .. OCinS;
    
    if no_tracking_cats ~= nil and no_tracking_cats ~= '' then
        error_categories = {};
    end 
    for _, v in pairs( error_categories ) do
        text = text .. '[[Category:' .. v ..']]';
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--18Mar2013 Fixed &quot;page=&quot; to override &quot;pages=&quot; as in markup-based cites.
--19Mar2013 Fixed date of class=journal Periodical to show after page.
--19Mar2013 Changed null &quot;postscript=&quot; to suppress end-dot of citation.
--
--End</text>
      <sha1>i4r525bgxdwzmzqrvfr7n6en3obn80w</sha1>
    </revision>
    <revision>
      <id>4623</id>
      <parentid>4622</parentid>
      <timestamp>2013-03-20T18:45:29Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>typo</comment>
      <origin>4623</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="54698" sha1="9f7ru74dkwvnxmbo7wf0v5as15ypqtt" xml:space="preserve">local z = {}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',    
            ['{'] = '&amp;#123;',    
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

function createTag(t, frame)
    local name = t.name or &quot;!-- --&quot;
    local content = t.contents or &quot;&quot;
    local attrs = {}
    for n,v in pairs(t.params) do
        if (v) then
            table.insert(attrs, n .. &quot;=\&quot;&quot; .. wikiescape(v) .. &quot;\&quot;&quot;)
        else
            table.insert(attrs, n)
        end
    end
    if (&quot;&quot; == content) then
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;/&gt;&quot;
    else
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    end
end

--[[
This is a clone of mw.text.nowiki.  When the mw.text library is installed,
this can be replaced by a call to that library. ]]
function nowiki( s )
    -- string.gsub is safe here, because we're only caring about ASCII chars
    s = string.gsub( s, '[&quot;&amp;\'&lt;=&gt;%[%]{|}]', {
        ['&quot;'] = '&amp;#34;',
        ['&amp;'] = '&amp;#38;',
        [&quot;'&quot;] = '&amp;#39;',
        ['&lt;'] = '&amp;#60;',
        ['='] = '&amp;#61;',
        ['&gt;'] = '&amp;#62;',
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['{'] = '&amp;#123;',
        ['|'] = '&amp;#124;',
        ['}'] = '&amp;#125;',
    } )
    s = string.sub( string.gsub( '\n' .. s, '\n[#*:;]', {
        [&quot;\n#&quot;] = &quot;\n&amp;#35;&quot;,
        [&quot;\n*&quot;] = &quot;\n&amp;#42;&quot;,
        [&quot;\n:&quot;] = &quot;\n&amp;#58;&quot;,
        [&quot;\n;&quot;] = &quot;\n&amp;#59;&quot;,
    } ), 2 )
    s = string.gsub( s, '://', '&amp;#58;//' )
    s = string.gsub( s, 'ISBN ', 'ISBN&amp;#32;' )
    s = string.gsub( s, 'RFC ', 'RFC&amp;#32;' )

    return s
end

function externallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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;)
    
    return t0 .. t1
end

function internallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid({link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

function doi(id, inactive)
    local cat = &quot;&quot;
    local error_categories = {};
    
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        table.insert( error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        table.insert( error_categories, &quot;Pages with DOI errors&quot; );        
        cat = ' &lt;span class=&quot;error&quot;&gt;Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    return text .. inactive .. cat, error_categories 
 end

function url(id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                end_chr = str:sub(-1,-1);
                if end_chr == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                        str = str:sub(1, -4) .. &quot;''&quot; .. value;
                    else
                        str = str .. value;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3) .. value;
                    else
                        str = str .. value;
                    end
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        --[[
        FormatDate fails on years that are less than 4 digits.  If the input 
        is a positive integer, assume it is a valid year even if it has less 
        than four digits.  
        ]]
        local num = tonumber( str );
        if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
            return str;
        else
            return '';
        end
    end
end

function openlibrary(id)
    local error_categories = {};
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        table.insert( error_categories, &quot;Pages with OL errors&quot; );
    end
    local text = externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    if #error_categories ~= 0 then
        text = text .. ' &lt;span class=&quot;error&quot;&gt;Bad OL specified&lt;/span&gt;';
    end    
    return text, error_categories
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil and first ~= '') then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= createTag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            authors[i] = {
                last = last,
                first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
                link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
                mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            editors[i] = {
                last = last,
                first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
                link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
                mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

function citation0( config, args)
    local error_categories = {};
    
    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.p or args.page
    local Pages = hyphentodash( args.pp or args.pages )
    local At = args.at
    local page_error = false;
    
    if Page ~= nil and Page ~= '' then
        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 Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    local no_tracking_cats = args[&quot;template doc demo&quot;] or args[&quot;nocat&quot;] or args[&quot;notracking&quot;] or args[&quot;no-tracking&quot;];

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date
    if ( config.CitationClass == &quot;web&quot; ) then
        if ( URL == nil or URL == '' ) and
                ( ChapterURL == nil or ChapterURL == '' ) and
                ( ArchiveURL == nil or ArchiveURL == '' ) and                
                ( ConferenceURL == nil or ConferenceURL == '' ) and                
                ( TranscriptURL == nil or TranscriptURL == '' ) then
            table.insert( error_categories, 'Pages using web citations with no URL' );
            if Title == nil or Title == &quot;&quot; then 
                Authors = Authors .. &quot;&lt;!-- No URL on cite web here --&gt;&quot;; 
            else
                Title = Title .. &quot;&lt;!-- No URL on cite web here --&gt;&quot;;
            end
        end
    end    

    if ( Chapter == nil or Chapter == &quot;&quot; ) and 
            ( Title == nil or Title == &quot;&quot; ) and
            ( Periodical == nil or Periodical == &quot;&quot; ) and
            ( Conference == nil or Conference == &quot;&quot; ) then
        table.insert( error_categories, 'Pages with citations lacking titles' );
        Authors = Authors .. &quot;&lt;!-- No citation title here --&gt;&quot;;
    end

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. createTag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid({label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid({label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
        local DOI_string, DOI_error;
        DOI_string, DOI_error = doi(DOI, DoiBroken);
        DOI = sepc .. &quot; &quot; .. DOI_string
        for _, v in ipairs( DOI_error ) do
            table.insert( error_categories, v );
        end        
    else 
        DOI = &quot;&quot; 
    end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid({label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid({label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid({label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid({label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid({label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid({label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid({label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        local OL_string, OL_error;
        OL_string, OL_error = openlibrary(OL);
        OL = sepc .. &quot; &quot; .. OL_string
        for _, v in ipairs( OL_error ) do
            table.insert( error_categories, v );
        end      
    else
        OL = &quot;&quot;;
    end    
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid({label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid({label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid({label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(URL)
       table.insert( error_categories, &quot;Pages with citations having bare URLs&quot; );
       if config.CitationClass == &quot;web&quot; then
           URL = URL .. &quot; &lt;span class='error'&gt;No &lt;code&gt;title=&lt;/code&gt; specified&lt;/span&gt;&quot;
       else
           URL = URL .. &quot;&lt;!-- Bare URL here --&gt;&quot;
       end       
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid({label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot; &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
            table.insert( error_categories, 'Pages with archiveurl citation errors' );
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            if args.url ~= nil and args.url ~= '' then
                Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
            else
                Archived = sepc .. arch_text .. &quot; from &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;&quot; ..
                    &quot;, you must also specify &lt;code&gt;url=&lt;/code&gt;&lt;/span&gt; on&quot; .. ArchiveDate
                table.insert( error_categories, 'Pages with archiveurl citation errors' );
            end                
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Others, Volume, Issue, Position}, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if (args.postscript == &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if page_error then
        table.insert( error_categories, 'Pages with citations using conflicting page specifications' );
        pgtext = pgtext .. '&lt;!-- Bad page specification here --&gt;';
    end
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        if ( config.CitationClass==&quot;journal&quot; and Periodical ) then
          text = safejoin( {Chapter, tcommon}, sepc );
          text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
          text = safejoin( {Chapter, tcommon, Date}, sepc );
          text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text:gsub(&quot;%b&lt;&gt;&quot;, &quot;&quot;)) &lt;= 2 then
        table.insert( error_categories, 'Pages with empty citations' );
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
    end
    
    text = createTag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = createTag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = createTag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
    text = text .. OCinS;
    
    if no_tracking_cats ~= nil and no_tracking_cats ~= '' then
        error_categories = {};
    end 
    for _, v in pairs( error_categories ) do
        text = text .. '[[Category:' .. v ..']]';
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--18Mar2013 Fixed &quot;page=&quot; to override &quot;pages=&quot; as in markup-based cites.
--19Mar2013 Fixed date of class=journal Periodical to show after page.
--19Mar2013 Changed null &quot;postscript=&quot; to suppress end-dot of citation.
--
--End</text>
      <sha1>9f7ru74dkwvnxmbo7wf0v5as15ypqtt</sha1>
    </revision>
    <revision>
      <id>4624</id>
      <parentid>4623</parentid>
      <timestamp>2013-03-20T19:29:57Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>sync to sandbox, deals with hidden comment issue</comment>
      <origin>4624</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="55008" sha1="bz51re7t4w9x3zkh9mzczsmgqztohmo" xml:space="preserve">local z = {}

function hideinprint(content)
    return content
end

function onlyinprint(content)
    return &quot;&quot;
end

function hiddencomment( content )
    return '&lt;span style=&quot;display: none;&quot;&gt;' .. content .. '&lt;/span&gt;';
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',    
            ['{'] = '&amp;#123;',    
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

function createTag(t, frame)
    local name = t.name or &quot;!-- --&quot;
    local content = t.contents or &quot;&quot;
    local attrs = {}
    for n,v in pairs(t.params) do
        if (v) then
            table.insert(attrs, n .. &quot;=\&quot;&quot; .. wikiescape(v) .. &quot;\&quot;&quot;)
        else
            table.insert(attrs, n)
        end
    end
    if (&quot;&quot; == content) then
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;/&gt;&quot;
    else
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    end
end

--[[
This is a clone of mw.text.nowiki.  When the mw.text library is installed,
this can be replaced by a call to that library. ]]
function nowiki( s )
    -- string.gsub is safe here, because we're only caring about ASCII chars
    s = string.gsub( s, '[&quot;&amp;\'&lt;=&gt;%[%]{|}]', {
        ['&quot;'] = '&amp;#34;',
        ['&amp;'] = '&amp;#38;',
        [&quot;'&quot;] = '&amp;#39;',
        ['&lt;'] = '&amp;#60;',
        ['='] = '&amp;#61;',
        ['&gt;'] = '&amp;#62;',
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['{'] = '&amp;#123;',
        ['|'] = '&amp;#124;',
        ['}'] = '&amp;#125;',
    } )
    s = string.sub( string.gsub( '\n' .. s, '\n[#*:;]', {
        [&quot;\n#&quot;] = &quot;\n&amp;#35;&quot;,
        [&quot;\n*&quot;] = &quot;\n&amp;#42;&quot;,
        [&quot;\n:&quot;] = &quot;\n&amp;#58;&quot;,
        [&quot;\n;&quot;] = &quot;\n&amp;#59;&quot;,
    } ), 2 )
    s = string.gsub( s, '://', '&amp;#58;//' )
    s = string.gsub( s, 'ISBN ', 'ISBN&amp;#32;' )
    s = string.gsub( s, 'RFC ', 'RFC&amp;#32;' )

    return s
end

function externallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    local t0 = onlyinprint(args.label .. sep .. args.id)
    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;)
    
    return t0 .. t1
end

function internallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local t0 = onlyinprint(args.label .. sep .. args.id)
    local t1 = hideinprint(&quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(args.id) .. &quot;]]&quot;)
    return t0 .. t1
end

function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid({link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

function doi(id, inactive)
    local cat = &quot;&quot;
    local error_categories = {};
    
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        table.insert( error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        table.insert( error_categories, &quot;Pages with DOI errors&quot; );        
        cat = ' &lt;span class=&quot;error&quot;&gt;Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    return text .. inactive .. cat, error_categories 
 end

function url(id)
    local t0 = onlyinprint(id)
    local t1 = hideinprint(&quot;[&quot; .. id .. &quot; &quot; .. nowiki(id) .. &quot;]&quot;)
    return t0 .. t1
end

function safeforurl( str )
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    return str:gsub( '-', '–' );
end

function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                end_chr = str:sub(-1,-1);
                if end_chr == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                        str = str:sub(1, -4) .. &quot;''&quot; .. value;
                    else
                        str = str .. value;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3) .. value;
                    else
                        str = str .. value;
                    end
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        --[[
        FormatDate fails on years that are less than 4 digits.  If the input 
        is a positive integer, assume it is a valid year even if it has less 
        than four digits.  
        ]]
        local num = tonumber( str );
        if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
            return str;
        else
            return '';
        end
    end
end

function openlibrary(id)
    local error_categories = {};
    local prefix = &quot;&quot;
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        prefix = &quot;http://openlibrary.org/authors/OL&quot;
    elseif ( code == &quot;M&quot; ) then
        prefix = &quot;http://openlibrary.org/books/OL&quot;
    elseif ( code == &quot;W&quot; ) then
        prefix = &quot;http://openlibrary.org/works/OL&quot;
    else
        prefix = &quot;http://openlibrary.org/OL&quot;
        table.insert( error_categories, &quot;Pages with OL errors&quot; );
    end
    local text = externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=prefix,id=id})
    if #error_categories ~= 0 then
        text = text .. ' &lt;span class=&quot;error&quot;&gt;Bad OL specified&lt;/span&gt;';
    end    
    return text, error_categories
end

function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil and first ~= '') then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= createTag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            authors[i] = {
                last = last,
                first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
                link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
                mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        local last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            editors[i] = {
                last = last,
                first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
                link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
                mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

function citation0( config, args)
    local error_categories = {};
    
    --------------------------------------------------- Get parameters    
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.p or args.page
    local Pages = hyphentodash( args.pp or args.pages )
    local At = args.at
    local page_error = false;
    
    if Page ~= nil and Page ~= '' then
        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 Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator

    local no_tracking_cats = args[&quot;template doc demo&quot;] or args[&quot;nocat&quot;] or args[&quot;notracking&quot;] or args[&quot;no-tracking&quot;];

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end
    if ( sepc == nil ) then sepc = &quot;.&quot; end 
    if ( DeadURL == nil ) then DeadURL = &quot;yes&quot; end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. config.fullpagename  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date
    if ( config.CitationClass == &quot;web&quot; ) then
        if ( URL == nil or URL == '' ) and
                ( ChapterURL == nil or ChapterURL == '' ) and
                ( ArchiveURL == nil or ArchiveURL == '' ) and                
                ( ConferenceURL == nil or ConferenceURL == '' ) and                
                ( TranscriptURL == nil or TranscriptURL == '' ) then
            table.insert( error_categories, 'Pages using web citations with no URL' );
            if Title == nil or Title == &quot;&quot; then 
                Authors = Authors .. hiddencomment(&quot;No URL on cite web here&quot;); 
            else
                Title = Title .. hiddencomment(&quot;No URL on cite web here&quot;);
            end
        end
    end    

    if ( Chapter == nil or Chapter == &quot;&quot; ) and 
            ( Title == nil or Title == &quot;&quot; ) and
            ( Periodical == nil or Periodical == &quot;&quot; ) and
            ( Conference == nil or Conference == &quot;&quot; ) then
        table.insert( error_categories, 'Pages with citations lacking titles' );
        Authors = Authors .. hiddencomment(&quot;No citation title here&quot;);
    end

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. createTag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid({label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid({label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
        local DOI_string, DOI_error;
        DOI_string, DOI_error = doi(DOI, DoiBroken);
        DOI = sepc .. &quot; &quot; .. DOI_string
        for _, v in ipairs( DOI_error ) do
            table.insert( error_categories, v );
        end        
    else 
        DOI = &quot;&quot; 
    end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid({label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid({label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid({label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid({label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid({label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid({label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid({label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        local OL_string, OL_error;
        OL_string, OL_error = openlibrary(OL);
        OL = sepc .. &quot; &quot; .. OL_string
        for _, v in ipairs( OL_error ) do
            table.insert( error_categories, v );
        end      
    else
        OL = &quot;&quot;;
    end    
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid({label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid({label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid({label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. url(URL)
       table.insert( error_categories, &quot;Pages with citations having bare URLs&quot; );
       if config.CitationClass == &quot;web&quot; then
           URL = URL .. &quot; &lt;span class='error'&gt;No &lt;code&gt;title=&lt;/code&gt; specified&lt;/span&gt;&quot;
       else
           URL = URL .. hiddencomment(&quot;Bare URL here&quot;);
       end       
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid({label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot; &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
            table.insert( error_categories, 'Pages with archiveurl citation errors' );
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            if args.url ~= nil and args.url ~= '' then
                Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
            else
                Archived = sepc .. arch_text .. &quot; from &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;&quot; ..
                    &quot;, you must also specify &lt;code&gt;url=&lt;/code&gt;&lt;/span&gt; on&quot; .. ArchiveDate
                table.insert( error_categories, 'Pages with archiveurl citation errors' );
            end                
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; ) then
        tcommon = safejoin( {Others, Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
    end
    -- DEBUG: tcommon = &quot;/Title=&quot;..Title .. &quot;/TitleType=&quot;..TitleType .. &quot;/TitleNote=&quot;..TitleNote .. &quot;/Format=&quot;..Format .. &quot;/Edition=&quot;..Edition .. &quot;/Language=&quot;..Language .. &quot;/Conference=&quot;..Conference .. &quot;/Periodical=&quot;..Periodical .. &quot;/Series=&quot;..Series .. &quot;/Volume=&quot;..Volume .. &quot;/Issue=&quot;..Issue .. &quot;/Position=&quot;..Position

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if (args.postscript == &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if page_error then
        table.insert( error_categories, 'Pages with citations using conflicting page specifications' );
        pgtext = pgtext .. hiddencomment('Bad page specification here');
    end
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        if ( config.CitationClass==&quot;journal&quot; and Periodical ) then
          text = safejoin( {Chapter, tcommon}, sepc );
          text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
          text = safejoin( {Chapter, tcommon, Date}, sepc );
          text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        table.insert( error_categories, 'Pages with empty citations' );
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
    end
    
    text = createTag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = createTag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = createTag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
    text = text .. OCinS;
    
    if no_tracking_cats ~= nil and no_tracking_cats ~= '' then
        error_categories = {};
    end 
    for _, v in pairs( error_categories ) do
        text = text .. '[[Category:' .. v ..']]';
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--18Mar2013 Fixed &quot;page=&quot; to override &quot;pages=&quot; as in markup-based cites.
--19Mar2013 Fixed date of class=journal Periodical to show after page.
--19Mar2013 Changed null &quot;postscript=&quot; to suppress end-dot of citation.
--20Mar2013 If CitationClass is journal, show &quot;others=&quot; before title.
--20Mar2013 If CitationClass is book, show &quot;others=&quot; before edition.
--
--End</text>
      <sha1>bz51re7t4w9x3zkh9mzczsmgqztohmo</sha1>
    </revision>
    <revision>
      <id>4625</id>
      <parentid>4624</parentid>
      <timestamp>2013-03-21T01:01:08Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>sync to sandbox</comment>
      <origin>4625</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="55146" sha1="mdegh9xo9799jitl2k3hg3q42waeaxl" xml:space="preserve">local z = {
    error_categories = {};
}

-- Formats a hidden comment for error trapping not intended to be visible to readers
function hiddencomment( content )
    return '&lt;span style=&quot;display: none;&quot; class=&quot;citation-comment&quot;&gt;' .. content .. '&lt;/span&gt;';
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',    
            ['{'] = '&amp;#123;',    
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

-- Create an HTML tag
function createTag(t, frame)
    local name = t.name or &quot;!-- --&quot;
    local content = t.contents or &quot;&quot;
    local attrs = {}
    for n,v in pairs(t.params) do
        if (v) then
            table.insert(attrs, n .. &quot;=\&quot;&quot; .. wikiescape(v) .. &quot;\&quot;&quot;)
        else
            table.insert(attrs, n)
        end
    end
    if (&quot;&quot; == content) then
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;/&gt;&quot;
    else
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    end
end

--[[
This is a clone of mw.text.nowiki.  When the mw.text library is installed,
this can be replaced by a call to that library. 
]]
function nowiki( s )
    -- string.gsub is safe here, because we're only caring about ASCII chars
    s = string.gsub( s, '[&quot;&amp;\'&lt;=&gt;%[%]{|}]', {
        ['&quot;'] = '&amp;#34;',
        ['&amp;'] = '&amp;#38;',
        [&quot;'&quot;] = '&amp;#39;',
        ['&lt;'] = '&amp;#60;',
        ['='] = '&amp;#61;',
        ['&gt;'] = '&amp;#62;',
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['{'] = '&amp;#123;',
        ['|'] = '&amp;#124;',
        ['}'] = '&amp;#125;',
    } )
    s = string.sub( string.gsub( '\n' .. s, '\n[#*:;]', {
        [&quot;\n#&quot;] = &quot;\n&amp;#35;&quot;,
        [&quot;\n*&quot;] = &quot;\n&amp;#42;&quot;,
        [&quot;\n:&quot;] = &quot;\n&amp;#58;&quot;,
        [&quot;\n;&quot;] = &quot;\n&amp;#59;&quot;,
    } ), 2 )
    s = string.gsub( s, '://', '&amp;#58;//' )
    s = string.gsub( s, 'ISBN ', 'ISBN&amp;#32;' )
    s = string.gsub( s, 'RFC ', 'RFC&amp;#32;' )

    return s
end

-- Formats a wiki style external link
function externallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    return &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;
end

-- Formats a wiki style internal link
function internallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    return &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(args.id) .. &quot;]]&quot;
end

-- Formats a link to Amazon
function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid({link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        table.insert( z.error_categories, &quot;Pages with DOI errors&quot; );        
        cat = ' &lt;span class=&quot;error&quot;&gt;Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    return text .. inactive .. cat 
 end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

--[[
Joins a sequence of string together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                end_chr = str:sub(-1,-1);
                if end_chr == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                        str = str:sub(1, -4) .. &quot;''&quot; .. value;
                    else
                        str = str .. value;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3) .. value;
                    else
                        str = str .. value;
                    end
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    local lang = mw.getContentLanguage();
    local good, result;
    good, result = pcall( lang.formatDate, lang, 'Y', str )
    if good then 
        return result;
    else
        --[[
        FormatDate fails on years that are less than 4 digits.  If the input 
        is a positive integer, assume it is a valid year even if it has less 
        than four digits.  
        ]]
        local num = tonumber( str );
        if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
            return str;
        else
            return '';
        end
    end
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id})
    else
        table.insert( z.error_categories, &quot;Pages with OL errors&quot; );
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix= &quot;http://openlibrary.org/OL&quot;,id=id}) .. 
            ' &lt;span class=&quot;error&quot;&gt;Bad OL specified&lt;/span&gt;';
    end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil and first ~= '') then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= createTag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

-- Gets author list from the input arguments
function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            authors[i] = {
                last = last,
                first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
                link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
                mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

-- Gets editor list from the input arguments
function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            editors[i] = {
                last = last,
                first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
                link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
                mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    -- Load Input Parameters

    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.p or args.page
    local Pages = hyphentodash( args.pp or args.pages )
    local At = args.at
    local page_error = false;
    
    if Page ~= nil and Page ~= '' then
        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 Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl or &quot;yes&quot;           -- Only used is ArchiveURL is present.
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator or &quot;.&quot;
    local no_tracking_cats = args[&quot;template doc demo&quot;] or args.nocat or args.notracking or args[&quot;no-tracking&quot;] or &quot;&quot;;

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    
    local this_page = mw.title.getCurrentTitle();
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. this_page.prefixedText  -- end COinS data by page's non-encoded pagename

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date
    
    -- Test is cite web is called without giving a URL
    if ( config.CitationClass == &quot;web&quot; ) then
        if ( URL == nil or URL == '' ) and
                ( ChapterURL == nil or ChapterURL == '' ) and
                ( ArchiveURL == nil or ArchiveURL == '' ) and                
                ( ConferenceURL == nil or ConferenceURL == '' ) and                
                ( TranscriptURL == nil or TranscriptURL == '' ) then
            table.insert( z.error_categories, 'Pages using web citations with no URL' );
            if Title == nil or Title == &quot;&quot; then 
                Authors = Authors .. hiddencomment(&quot;No URL on cite web here&quot;); 
            else
                Title = Title .. hiddencomment(&quot;No URL on cite web here&quot;);
            end
        end
    end    

    -- Test if citation has no title
    if ( Chapter == nil or Chapter == &quot;&quot; ) and 
            ( Title == nil or Title == &quot;&quot; ) and
            ( Periodical == nil or Periodical == &quot;&quot; ) and
            ( Conference == nil or Conference == &quot;&quot; ) then
        table.insert( z.error_categories, 'Pages with citations lacking titles' );
        Authors = Authors .. hiddencomment(&quot;No citation title here&quot;);
    end

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
          local temp = URL
          URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical
            and config.CitationClass ~= &quot;encyclopaedia&quot;
        ) then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. createTag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid({label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid({label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
        DOI = sepc .. &quot; &quot; .. doi(DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid({label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid({label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid({label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid({label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid({label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid({label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid({label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc .. &quot; &quot; .. openlibrary(OL) else OL = &quot;&quot; end    
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid({label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid({label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid({label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. &quot;[&quot; .. URL .. &quot; &quot; .. nowiki(URL) .. &quot;]&quot;;
       table.insert( z.error_categories, &quot;Pages with citations having bare URLs&quot; );
       if config.CitationClass == &quot;web&quot; then
           URL = URL .. &quot; &lt;span class='error'&gt;No &lt;code&gt;title=&lt;/code&gt; specified&lt;/span&gt;&quot;
       else
           URL = URL .. hiddencomment(&quot;Bare URL here&quot;);
       end       
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid({label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot; &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
            table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            if args.url ~= nil and args.url ~= '' then
                Archived = sepc .. arch_text .. &quot; from [&quot; .. args.url .. &quot; the original] on&quot; .. ArchiveDate
            else
                Archived = sepc .. arch_text .. &quot; from &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;&quot; ..
                    &quot;, you must also specify &lt;code&gt;url=&lt;/code&gt;&lt;/span&gt; on&quot; .. ArchiveDate
                table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
            end                
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; and
         Periodical ~= &quot;&quot; ) then
        if (Others ~= &quot;&quot;) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, TitleType, Conference, Periodical, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
    end

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if (args.postscript == &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if page_error then
        table.insert( z.error_categories, 'Pages with citations using conflicting page specifications' );
        pgtext = pgtext .. hiddencomment('Bad page specification here');
    end
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        if ( config.CitationClass==&quot;journal&quot; and Periodical ) then
          text = safejoin( {Chapter, tcommon}, sepc );
          text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
          text = safejoin( {Chapter, tcommon, Date}, sepc );
          text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        table.insert( z.error_categories, 'Pages with empty citations' );
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
    end
    
    text = createTag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = createTag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = createTag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
    text = text .. OCinS;
    
    if no_tracking_cats == '' then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        args[k] = v;
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--18Mar2013 Fixed &quot;page=&quot; to override &quot;pages=&quot; as in markup-based cites.
--19Mar2013 Fixed date of class=journal Periodical to show after page.
--19Mar2013 Changed null &quot;postscript=&quot; to suppress end-dot of citation.
--20Mar2013 If CitationClass is journal, show &quot;others=&quot; before title.
--20Mar2013 If CitationClass is book, show &quot;others=&quot; before edition.
--20Mar2013 If CitationClass is journal, adjust &quot;others=&quot; to have sepc.
--20Mar2013 For class &quot;journal&quot;, use book format unless Periodical set.
--
--End</text>
      <sha1>mdegh9xo9799jitl2k3hg3q42waeaxl</sha1>
    </revision>
    <revision>
      <id>4626</id>
      <parentid>4625</parentid>
      <timestamp>2013-03-22T18:51:43Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>sync with sandbox</comment>
      <origin>4626</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="55575" sha1="a2xld9jnqbfblzs7540dcw8uf5z4bvz" xml:space="preserve">local z = {
    error_categories = {};
}

-- Formats a hidden comment for error trapping not intended to be visible to readers
function hiddencomment( content )
    return '&lt;span style=&quot;display: none;&quot; class=&quot;citation-comment&quot;&gt;' .. content .. '&lt;/span&gt;';
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',    
            ['{'] = '&amp;#123;',    
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

-- Create an HTML tag
function createTag(t, frame)
    local name = t.name or &quot;!-- --&quot;
    local content = t.contents or &quot;&quot;
    local attrs = {}
    for n,v in pairs(t.params) do
        if (v) then
            table.insert(attrs, n .. &quot;=\&quot;&quot; .. wikiescape(v) .. &quot;\&quot;&quot;)
        else
            table.insert(attrs, n)
        end
    end
    if (&quot;&quot; == content) then
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;/&gt;&quot;
    else
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    end
end

--[[
This is a clone of mw.text.nowiki.  When the mw.text library is installed,
this can be replaced by a call to that library. 
]]
function nowiki( s )
    -- string.gsub is safe here, because we're only caring about ASCII chars
    s = string.gsub( s, '[&quot;&amp;\'&lt;=&gt;%[%]{|}]', {
        ['&quot;'] = '&amp;#34;',
        ['&amp;'] = '&amp;#38;',
        [&quot;'&quot;] = '&amp;#39;',
        ['&lt;'] = '&amp;#60;',
        ['='] = '&amp;#61;',
        ['&gt;'] = '&amp;#62;',
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['{'] = '&amp;#123;',
        ['|'] = '&amp;#124;',
        ['}'] = '&amp;#125;',
    } )
    s = string.sub( string.gsub( '\n' .. s, '\n[#*:;]', {
        [&quot;\n#&quot;] = &quot;\n&amp;#35;&quot;,
        [&quot;\n*&quot;] = &quot;\n&amp;#42;&quot;,
        [&quot;\n:&quot;] = &quot;\n&amp;#58;&quot;,
        [&quot;\n;&quot;] = &quot;\n&amp;#59;&quot;,
    } ), 2 )
    s = string.gsub( s, '://', '&amp;#58;//' )
    s = string.gsub( s, 'ISBN ', 'ISBN&amp;#32;' )
    s = string.gsub( s, 'RFC ', 'RFC&amp;#32;' )

    return s
end

-- Formats a wiki style external link
function externallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    return &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;
end

-- Formats a wiki style internal link
function internallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    return &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(args.id) .. &quot;]]&quot;
end

-- Formats a link to Amazon
function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid({link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        table.insert( z.error_categories, &quot;Pages with DOI errors&quot; );        
        cat = ' &lt;span class=&quot;error&quot;&gt;Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    return text .. inactive .. cat 
 end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

--[[
Joins a sequence of string together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                end_chr = str:sub(-1,-1);
                if end_chr == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                        str = str:sub(1, -4) .. &quot;''&quot; .. value;
                    else
                        str = str .. value;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3) .. value;
                    else
                        str = str .. value;
                    end
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    -- Is the input a simple number?
    local num = tonumber( str ); 
    if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
        return str;
    else
        -- Use formatDate to interpret more complicated formats
        local lang = mw.getContentLanguage();
        local good, result;
        good, result = pcall( lang.formatDate, lang, 'Y', str )
        if good then 
            return result;
        else
            -- Can't make sense of this input, return blank.
            return &quot;&quot;;
        end
    end
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id})
    else
        table.insert( z.error_categories, &quot;Pages with OL errors&quot; );
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix= &quot;http://openlibrary.org/OL&quot;,id=id}) .. 
            ' &lt;span class=&quot;error&quot;&gt;Bad OL specified&lt;/span&gt;';
    end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil and first ~= '') then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= createTag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

-- Gets author list from the input arguments
function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            authors[i] = {
                last = last,
                first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
                link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
                mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

-- Gets editor list from the input arguments
function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            editors[i] = {
                last = last,
                first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
                link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
                mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    -- Load Input Parameters

    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url or args.URL
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.p or args.page
    local Pages = hyphentodash( args.pp or args.pages )
    local At = args.at
    local page_error = false;
    
    if Page ~= nil and Page ~= '' then
        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 Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl or &quot;yes&quot;           -- Only used is ArchiveURL is present.
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator or &quot;.&quot;
    local no_tracking_cats = args[&quot;template doc demo&quot;] or args.nocat or args.notracking or args[&quot;no-tracking&quot;] or &quot;&quot;;

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    
    local this_page = mw.title.getCurrentTitle();
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. this_page.prefixedText  -- end COinS data by page's non-encoded pagename

    if (Periodical ~= nil and Periodical ~= &quot;&quot;) and
        (Chapter == nil or Chapter == '') and
        (Title ~= nil and Title ~= &quot;&quot;) then
            Chapter = Title
            ChapterLink = TitleLink
            TransChapter = TransTitle
            Title = nil
            TitleLink = nil
            TransTitle = nil            
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date
    
    -- Test is cite web is called without giving a URL
    if ( config.CitationClass == &quot;web&quot; ) then
        if ( URL == nil or URL == '' ) and
                ( ChapterURL == nil or ChapterURL == '' ) and
                ( ArchiveURL == nil or ArchiveURL == '' ) and                
                ( ConferenceURL == nil or ConferenceURL == '' ) and                
                ( TranscriptURL == nil or TranscriptURL == '' ) then
            table.insert( z.error_categories, 'Pages using web citations with no URL' );
            if Title == nil or Title == &quot;&quot; then 
                Authors = Authors .. hiddencomment(&quot;No URL on cite web here&quot;); 
            else
                Title = Title .. hiddencomment(&quot;No URL on cite web here&quot;);
            end
        end
    end    

    -- Test if citation has no title
    if ( Chapter == nil or Chapter == &quot;&quot; ) and 
            ( Title == nil or Title == &quot;&quot; ) and
            ( Periodical == nil or Periodical == &quot;&quot; ) and
            ( Conference == nil or Conference == &quot;&quot; ) then
        table.insert( z.error_categories, 'Pages with citations lacking titles' );
        Authors = Authors .. hiddencomment(&quot;No citation title here&quot;);
    end

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    
    local OriginalURL = URL
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) and (Title ~= nil and Title ~= &quot;&quot; )
        then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. createTag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid({label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid({label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
        DOI = sepc .. &quot; &quot; .. doi(DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid({label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid({label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid({label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid({label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid({label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid({label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid({label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc .. &quot; &quot; .. openlibrary(OL) else OL = &quot;&quot; end    
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid({label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid({label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid({label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. &quot;[&quot; .. URL .. &quot; &quot; .. nowiki(URL) .. &quot;]&quot;;
       table.insert( z.error_categories, &quot;Pages with citations having bare URLs&quot; );
       if config.CitationClass == &quot;web&quot; then
           URL = URL .. &quot; &lt;span class='error'&gt;No &lt;code&gt;title=&lt;/code&gt; specified&lt;/span&gt;&quot;
       else
           URL = URL .. hiddencomment(&quot;Bare URL here&quot;);
       end       
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid({label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot; &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
            table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            if OriginalURL ~= nil and OriginalURL ~= '' then
                Archived = sepc .. arch_text .. &quot; from [&quot; .. OriginalURL .. &quot; the original] on&quot; .. ArchiveDate
            else
                Archived = sepc .. arch_text .. &quot; from &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;&quot; ..
                    &quot;, you must also specify &lt;code&gt;url=&lt;/code&gt;&lt;/span&gt; on&quot; .. ArchiveDate
                table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
            end                
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; and
         Periodical ~= &quot;&quot; ) then
        if (Others ~= &quot;&quot;) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Format, Conference, Periodical, TitleType, Series, Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, Conference, Periodical, TitleType, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
    end

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if (args.postscript == &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if page_error then
        table.insert( z.error_categories, 'Pages with citations using conflicting page specifications' );
        pgtext = pgtext .. hiddencomment('Bad page specification here');
    end
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        if ( config.CitationClass==&quot;journal&quot; and Periodical ) then
          text = safejoin( {Chapter, tcommon}, sepc );
          text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
          text = safejoin( {Chapter, tcommon, Date}, sepc );
          text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        table.insert( z.error_categories, 'Pages with empty citations' );
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
    end
    
    text = createTag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = createTag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = createTag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
    text = text .. OCinS;
    
    if no_tracking_cats == '' then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            args[k] = v;
        elseif k == 'postscript' then
            args[k] = v;
        end        
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--18Mar2013 Fixed &quot;page=&quot; to override &quot;pages=&quot; as in markup-based cites.
--19Mar2013 Fixed date of class=journal Periodical to show after page.
--19Mar2013 Changed null &quot;postscript=&quot; to suppress end-dot of citation.
--20Mar2013 If CitationClass is journal, show &quot;others=&quot; before title.
--20Mar2013 If CitationClass is book, show &quot;others=&quot; before edition.
--20Mar2013 If CitationClass is journal, adjust &quot;others=&quot; to have sepc.
--20Mar2013 For class &quot;journal&quot;, use book format unless Periodical set.
--
--End</text>
      <sha1>a2xld9jnqbfblzs7540dcw8uf5z4bvz</sha1>
    </revision>
    <revision>
      <id>4627</id>
      <parentid>4626</parentid>
      <timestamp>2013-03-22T19:12:52Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>sync fix to LaySummary</comment>
      <origin>4627</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="55583" sha1="f6c1l3y6kal7ek7dqfgmxou29r8bqwg" xml:space="preserve">local z = {
    error_categories = {};
}

-- Formats a hidden comment for error trapping not intended to be visible to readers
function hiddencomment( content )
    return '&lt;span style=&quot;display: none;&quot; class=&quot;citation-comment&quot;&gt;' .. content .. '&lt;/span&gt;';
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',    
            ['{'] = '&amp;#123;',    
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

-- Create an HTML tag
function createTag(t, frame)
    local name = t.name or &quot;!-- --&quot;
    local content = t.contents or &quot;&quot;
    local attrs = {}
    for n,v in pairs(t.params) do
        if (v) then
            table.insert(attrs, n .. &quot;=\&quot;&quot; .. wikiescape(v) .. &quot;\&quot;&quot;)
        else
            table.insert(attrs, n)
        end
    end
    if (&quot;&quot; == content) then
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;/&gt;&quot;
    else
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    end
end

--[[
This is a clone of mw.text.nowiki.  When the mw.text library is installed,
this can be replaced by a call to that library. 
]]
function nowiki( s )
    -- string.gsub is safe here, because we're only caring about ASCII chars
    s = string.gsub( s, '[&quot;&amp;\'&lt;=&gt;%[%]{|}]', {
        ['&quot;'] = '&amp;#34;',
        ['&amp;'] = '&amp;#38;',
        [&quot;'&quot;] = '&amp;#39;',
        ['&lt;'] = '&amp;#60;',
        ['='] = '&amp;#61;',
        ['&gt;'] = '&amp;#62;',
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['{'] = '&amp;#123;',
        ['|'] = '&amp;#124;',
        ['}'] = '&amp;#125;',
    } )
    s = string.sub( string.gsub( '\n' .. s, '\n[#*:;]', {
        [&quot;\n#&quot;] = &quot;\n&amp;#35;&quot;,
        [&quot;\n*&quot;] = &quot;\n&amp;#42;&quot;,
        [&quot;\n:&quot;] = &quot;\n&amp;#58;&quot;,
        [&quot;\n;&quot;] = &quot;\n&amp;#59;&quot;,
    } ), 2 )
    s = string.gsub( s, '://', '&amp;#58;//' )
    s = string.gsub( s, 'ISBN ', 'ISBN&amp;#32;' )
    s = string.gsub( s, 'RFC ', 'RFC&amp;#32;' )

    return s
end

-- Formats a wiki style external link
function externallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    return &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;
end

-- Formats a wiki style internal link
function internallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    return &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(args.id) .. &quot;]]&quot;
end

-- Formats a link to Amazon
function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid({link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        table.insert( z.error_categories, &quot;Pages with DOI errors&quot; );        
        cat = ' &lt;span class=&quot;error&quot;&gt;Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    return text .. inactive .. cat 
 end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

--[[
Joins a sequence of string together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                end_chr = str:sub(-1,-1);
                if end_chr == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                        str = str:sub(1, -4) .. &quot;''&quot; .. value;
                    else
                        str = str .. value;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3) .. value;
                    else
                        str = str .. value;
                    end
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    -- Is the input a simple number?
    local num = tonumber( str ); 
    if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
        return str;
    else
        -- Use formatDate to interpret more complicated formats
        local lang = mw.getContentLanguage();
        local good, result;
        good, result = pcall( lang.formatDate, lang, 'Y', str )
        if good then 
            return result;
        else
            -- Can't make sense of this input, return blank.
            return &quot;&quot;;
        end
    end
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id})
    else
        table.insert( z.error_categories, &quot;Pages with OL errors&quot; );
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix= &quot;http://openlibrary.org/OL&quot;,id=id}) .. 
            ' &lt;span class=&quot;error&quot;&gt;Bad OL specified&lt;/span&gt;';
    end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil and first ~= '') then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= createTag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

-- Gets author list from the input arguments
function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            authors[i] = {
                last = last,
                first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
                link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
                mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

-- Gets editor list from the input arguments
function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            editors[i] = {
                last = last,
                first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
                link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
                mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    -- Load Input Parameters

    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url or args.URL
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.p or args.page
    local Pages = hyphentodash( args.pp or args.pages )
    local At = args.at
    local page_error = false;
    
    if Page ~= nil and Page ~= '' then
        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 Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl or &quot;yes&quot;           -- Only used is ArchiveURL is present.
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator or &quot;.&quot;
    local no_tracking_cats = args[&quot;template doc demo&quot;] or args.nocat or args.notracking or args[&quot;no-tracking&quot;] or &quot;&quot;;

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    
    local this_page = mw.title.getCurrentTitle();
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. this_page.prefixedText  -- end COinS data by page's non-encoded pagename

    if (Periodical ~= nil and Periodical ~= &quot;&quot;) and
        (Chapter == nil or Chapter == '') and
        (Title ~= nil and Title ~= &quot;&quot;) then
            Chapter = Title
            ChapterLink = TitleLink
            TransChapter = TransTitle
            Title = nil
            TitleLink = nil
            TransTitle = nil            
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44;&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;&amp;#44; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or args[&quot;separator&quot;] or &quot;&amp;#59; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date
    
    -- Test is cite web is called without giving a URL
    if ( config.CitationClass == &quot;web&quot; ) then
        if ( URL == nil or URL == '' ) and
                ( ChapterURL == nil or ChapterURL == '' ) and
                ( ArchiveURL == nil or ArchiveURL == '' ) and                
                ( ConferenceURL == nil or ConferenceURL == '' ) and                
                ( TranscriptURL == nil or TranscriptURL == '' ) then
            table.insert( z.error_categories, 'Pages using web citations with no URL' );
            if Title == nil or Title == &quot;&quot; then 
                Authors = Authors .. hiddencomment(&quot;No URL on cite web here&quot;); 
            else
                Title = Title .. hiddencomment(&quot;No URL on cite web here&quot;);
            end
        end
    end    

    -- Test if citation has no title
    if ( Chapter == nil or Chapter == &quot;&quot; ) and 
            ( Title == nil or Title == &quot;&quot; ) and
            ( Periodical == nil or Periodical == &quot;&quot; ) and
            ( Conference == nil or Conference == &quot;&quot; ) then
        table.insert( z.error_categories, 'Pages with citations lacking titles' );
        Authors = Authors .. hiddencomment(&quot;No citation title here&quot;);
    end

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    
    local OriginalURL = URL
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) and (Title ~= nil and Title ~= &quot;&quot; )
        then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. createTag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid({label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid({label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
        DOI = sepc .. &quot; &quot; .. doi(DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid({label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid({label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid({label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid({label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid({label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid({label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid({label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc .. &quot; &quot; .. openlibrary(OL) else OL = &quot;&quot; end    
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid({label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid({label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid({label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. &quot;[&quot; .. URL .. &quot; &quot; .. nowiki(URL) .. &quot;]&quot;;
       table.insert( z.error_categories, &quot;Pages with citations having bare URLs&quot; );
       if config.CitationClass == &quot;web&quot; then
           URL = URL .. &quot; &lt;span class='error'&gt;No &lt;code&gt;title=&lt;/code&gt; specified&lt;/span&gt;&quot;
       else
           URL = URL .. hiddencomment(&quot;Bare URL here&quot;);
       end       
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid({label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot; &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
            table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            if OriginalURL ~= nil and OriginalURL ~= '' then
                Archived = sepc .. arch_text .. &quot; from [&quot; .. OriginalURL .. &quot; the original] on&quot; .. ArchiveDate
            else
                Archived = sepc .. arch_text .. &quot; from &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;&quot; ..
                    &quot;, you must also specify &lt;code&gt;url=&lt;/code&gt;&lt;/span&gt; on&quot; .. ArchiveDate
                table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
            end                
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; Lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; and
         Periodical ~= &quot;&quot; ) then
        if (Others ~= &quot;&quot;) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Format, Conference, Periodical, TitleType, Series, Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, Conference, Periodical, TitleType, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
    end

    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote, PostScript }, sepc );
    local enddot = &quot;.&quot;
    if (Quote ~= &quot;&quot;) then enddot = &quot;&quot; end
    if (args.postscript == &quot;&quot;) then enddot = &quot;&quot; end
    if ( config.CitationClass == &quot;citation&quot;) then enddot = &quot;&quot; end
    idcommon = safejoin( { idcommon, enddot }, sepc )

    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        Chapter = Chapter
    end

    local text
    local pgtext = Page .. Pages .. At
    if page_error then
        table.insert( z.error_categories, 'Pages with citations using conflicting page specifications' );
        pgtext = pgtext .. hiddencomment('Bad page specification here');
    end
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        if ( config.CitationClass==&quot;journal&quot; and Periodical ) then
          text = safejoin( {Chapter, tcommon}, sepc );
          text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
          text = safejoin( {Chapter, tcommon, Date}, sepc );
          text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        table.insert( z.error_categories, 'Pages with empty citations' );
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
    end
    
    text = createTag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = createTag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = createTag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
    text = text .. OCinS;
    
    if no_tracking_cats == '' then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            args[k] = v;
        elseif k == 'postscript' then
            args[k] = v;
        end        
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--18Mar2013 Fixed &quot;page=&quot; to override &quot;pages=&quot; as in markup-based cites.
--19Mar2013 Fixed date of class=journal Periodical to show after page.
--19Mar2013 Changed null &quot;postscript=&quot; to suppress end-dot of citation.
--20Mar2013 If CitationClass is journal, show &quot;others=&quot; before title.
--20Mar2013 If CitationClass is book, show &quot;others=&quot; before edition.
--20Mar2013 If CitationClass is journal, adjust &quot;others=&quot; to have sepc.
--20Mar2013 For class &quot;journal&quot;, use book format unless Periodical set.
--
--End</text>
      <sha1>f6c1l3y6kal7ek7dqfgmxou29r8bqwg</sha1>
    </revision>
    <revision>
      <id>4628</id>
      <parentid>4627</parentid>
      <timestamp>2013-03-24T19:11:21Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>sync with sandbox.  Address lastauthoramp, postscript, and separator issues</comment>
      <origin>4628</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="55972" sha1="e4ala9ub7nf2acmdog7uglzlb1az6in" xml:space="preserve">local z = {
    error_categories = {};
}

-- Formats a hidden comment for error trapping not intended to be visible to readers
function hiddencomment( content )
    return '&lt;span style=&quot;display: none;&quot; class=&quot;citation-comment&quot;&gt;' .. content .. '&lt;/span&gt;';
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',    
            ['{'] = '&amp;#123;',    
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

-- Create an HTML tag
function createTag(t, frame)
    local name = t.name or &quot;!-- --&quot;
    local content = t.contents or &quot;&quot;
    local attrs = {}
    for n,v in pairs(t.params) do
        if (v) then
            table.insert(attrs, n .. &quot;=\&quot;&quot; .. wikiescape(v) .. &quot;\&quot;&quot;)
        else
            table.insert(attrs, n)
        end
    end
    if (&quot;&quot; == content) then
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;/&gt;&quot;
    else
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    end
end

--[[
This is a clone of mw.text.nowiki.  When the mw.text library is installed,
this can be replaced by a call to that library. 
]]
function nowiki( s )
    -- string.gsub is safe here, because we're only caring about ASCII chars
    s = string.gsub( s, '[&quot;&amp;\'&lt;=&gt;%[%]{|}]', {
        ['&quot;'] = '&amp;#34;',
        ['&amp;'] = '&amp;#38;',
        [&quot;'&quot;] = '&amp;#39;',
        ['&lt;'] = '&amp;#60;',
        ['='] = '&amp;#61;',
        ['&gt;'] = '&amp;#62;',
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['{'] = '&amp;#123;',
        ['|'] = '&amp;#124;',
        ['}'] = '&amp;#125;',
    } )
    s = string.sub( string.gsub( '\n' .. s, '\n[#*:;]', {
        [&quot;\n#&quot;] = &quot;\n&amp;#35;&quot;,
        [&quot;\n*&quot;] = &quot;\n&amp;#42;&quot;,
        [&quot;\n:&quot;] = &quot;\n&amp;#58;&quot;,
        [&quot;\n;&quot;] = &quot;\n&amp;#59;&quot;,
    } ), 2 )
    s = string.gsub( s, '://', '&amp;#58;//' )
    s = string.gsub( s, 'ISBN ', 'ISBN&amp;#32;' )
    s = string.gsub( s, 'RFC ', 'RFC&amp;#32;' )

    return s
end

-- Formats a wiki style external link
function externallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    return &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;
end

-- Formats a wiki style internal link
function internallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    return &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(args.id) .. &quot;]]&quot;
end

-- Formats a link to Amazon
function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid({link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        table.insert( z.error_categories, &quot;Pages with DOI errors&quot; );        
        cat = ' &lt;span class=&quot;error&quot;&gt;Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    return text .. inactive .. cat 
 end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

--[[
Joins a sequence of string together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                end_chr = str:sub(-1,-1);
                if end_chr == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                        str = str:sub(1, -4) .. &quot;''&quot; .. value;
                    else
                        str = str .. value;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3) .. value;
                    else
                        str = str .. value;
                    end
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    -- Is the input a simple number?
    local num = tonumber( str ); 
    if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
        return str;
    else
        -- Use formatDate to interpret more complicated formats
        local lang = mw.getContentLanguage();
        local good, result;
        good, result = pcall( lang.formatDate, lang, 'Y', str )
        if good then 
            return result;
        else
            -- Can't make sense of this input, return blank.
            return &quot;&quot;;
        end
    end
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id})
    else
        table.insert( z.error_categories, &quot;Pages with OL errors&quot; );
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix= &quot;http://openlibrary.org/OL&quot;,id=id}) .. 
            ' &lt;span class=&quot;error&quot;&gt;Bad OL specified&lt;/span&gt;';
    end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil and first ~= '') then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    if count &gt; 1 and lastauthoramp ~= nil and lastauthoramp ~= &quot;&quot; and not etal then
        text[count-1] = text[count-1] .. &quot; &amp; &quot; .. text[count];
        text[count] = nil;
    end    
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= createTag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

-- Gets author list from the input arguments
function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            authors[i] = {
                last = last,
                first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
                link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
                mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

-- Gets editor list from the input arguments
function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            editors[i] = {
                last = last,
                first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
                link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
                mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    -- Load Input Parameters

    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url or args.URL
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.p or args.page
    local Pages = hyphentodash( args.pp or args.pages )
    local At = args.at
    local page_error = false;
    
    if Page ~= nil and Page ~= '' then
        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 Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl or &quot;yes&quot;           -- Only used is ArchiveURL is present.
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript or &quot;.&quot;
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator or &quot;.&quot;
    local LastAuthorAmp = args.lastauthoramp
    local no_tracking_cats = args[&quot;template doc demo&quot;] or args.nocat or args.notracking or args[&quot;no-tracking&quot;] or &quot;&quot;;

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    
    local this_page = mw.title.getCurrentTitle();
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. this_page.prefixedText  -- end COinS data by page's non-encoded pagename

    if (Periodical ~= nil and Periodical ~= &quot;&quot;) and
        (Chapter == nil or Chapter == '') and
        (Title ~= nil and Title ~= &quot;&quot;) then
            Chapter = Title
            ChapterLink = TitleLink
            TransChapter = TransTitle
            Title = nil
            TitleLink = nil
            TransTitle = nil            
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or &quot;;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum, lastauthoramp = LastAuthorAmp }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;
        EditorNameSep = EditorNameSep .. &quot; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or &quot;;&quot;
        EditorSep = EditorSep .. &quot; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum, lastauthoramp = LastAuthorAmp }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date
    
    -- Test is cite web is called without giving a URL
    if ( config.CitationClass == &quot;web&quot; ) then
        if ( URL == nil or URL == '' ) and
                ( ChapterURL == nil or ChapterURL == '' ) and
                ( ArchiveURL == nil or ArchiveURL == '' ) and                
                ( ConferenceURL == nil or ConferenceURL == '' ) and                
                ( TranscriptURL == nil or TranscriptURL == '' ) then
            table.insert( z.error_categories, 'Pages using web citations with no URL' );
            if Title == nil or Title == &quot;&quot; then 
                Authors = Authors .. hiddencomment(&quot;No URL on cite web here&quot;); 
            else
                Title = Title .. hiddencomment(&quot;No URL on cite web here&quot;);
            end
        end
    end    

    -- Test if citation has no title
    if ( Chapter == nil or Chapter == &quot;&quot; ) and 
            ( Title == nil or Title == &quot;&quot; ) and
            ( Periodical == nil or Periodical == &quot;&quot; ) and
            ( Conference == nil or Conference == &quot;&quot; ) then
        table.insert( z.error_categories, 'Pages with citations lacking titles' );
        Authors = Authors .. hiddencomment(&quot;No citation title here&quot;);
    end

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    
    local OriginalURL = URL
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) and (Title ~= nil and Title ~= &quot;&quot; )
        then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( string.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. Volume .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. createTag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid({label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid({label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
        DOI = sepc .. &quot; &quot; .. doi(DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid({label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid({label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid({label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid({label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid({label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid({label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid({label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc .. &quot; &quot; .. openlibrary(OL) else OL = &quot;&quot; end    
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid({label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid({label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid({label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. &quot;[&quot; .. URL .. &quot; &quot; .. nowiki(URL) .. &quot;]&quot;;
       table.insert( z.error_categories, &quot;Pages with citations having bare URLs&quot; );
       if config.CitationClass == &quot;web&quot; then
           URL = URL .. &quot; &lt;span class='error'&gt;No &lt;code&gt;title=&lt;/code&gt; specified&lt;/span&gt;&quot;
       else
           URL = URL .. hiddencomment(&quot;Bare URL here&quot;);
       end       
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid({label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot; &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
            table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            if OriginalURL ~= nil and OriginalURL ~= '' then
                Archived = sepc .. arch_text .. &quot; from [&quot; .. OriginalURL .. &quot; the original] on&quot; .. ArchiveDate
            else
                Archived = sepc .. arch_text .. &quot; from &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;&quot; ..
                    &quot;, you must also specify &lt;code&gt;url=&lt;/code&gt;&lt;/span&gt; on&quot; .. ArchiveDate
                table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
            end                
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; Lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; and
         Periodical ~= &quot;&quot; ) then
        if (Others ~= &quot;&quot;) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Format, Conference, Periodical, TitleType, Series, Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, Conference, Periodical, TitleType, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
    end
    
    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );

    local text
    local pgtext = Page .. Pages .. At
    if page_error then
        table.insert( z.error_categories, 'Pages with citations using conflicting page specifications' );
        pgtext = pgtext .. hiddencomment('Bad page specification here');
    end
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        if ( config.CitationClass==&quot;journal&quot; and Periodical ) then
          text = safejoin( {Chapter, tcommon}, sepc );
          text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
          text = safejoin( {Chapter, tcommon, Date}, sepc );
          text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if ( config.CitationClass == &quot;citation&quot;) then PostScript = &quot;&quot; end
    if PostScript ~= '' and PostScript ~= nil and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        table.insert( z.error_categories, 'Pages with empty citations' );
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
    end
    
    text = createTag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = createTag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = createTag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
    text = text .. OCinS;
    
    if no_tracking_cats == '' then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            args[k] = v;
        elseif k == 'postscript' then
            args[k] = v;
        end        
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--18Mar2013 Fixed &quot;page=&quot; to override &quot;pages=&quot; as in markup-based cites.
--19Mar2013 Fixed date of class=journal Periodical to show after page.
--19Mar2013 Changed null &quot;postscript=&quot; to suppress end-dot of citation.
--20Mar2013 If CitationClass is journal, show &quot;others=&quot; before title.
--20Mar2013 If CitationClass is book, show &quot;others=&quot; before edition.
--20Mar2013 If CitationClass is journal, adjust &quot;others=&quot; to have sepc.
--20Mar2013 For class &quot;journal&quot;, use book format unless Periodical set.
--
--End</text>
      <sha1>e4ala9ub7nf2acmdog7uglzlb1az6in</sha1>
    </revision>
    <revision>
      <id>4629</id>
      <parentid>4628</parentid>
      <timestamp>2013-03-25T19:15:12Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>sync to sandbox, addressing hyphen links, authormask, bolding, etc.</comment>
      <origin>4629</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="56750" sha1="brsot2868lh9ar5g9bfqa68in18xxd5" xml:space="preserve">local z = {
    error_categories = {};
}

-- Formats a hidden comment for error trapping not intended to be visible to readers
function hiddencomment( content )
    return '&lt;span style=&quot;display: none;&quot; class=&quot;citation-comment&quot;&gt;' .. content .. '&lt;/span&gt;';
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',    
            ['{'] = '&amp;#123;',    
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

-- Create an HTML tag
function createTag(t, frame)
    local name = t.name or &quot;!-- --&quot;
    local content = t.contents or &quot;&quot;
    local attrs = {}
    for n,v in pairs(t.params) do
        if (v) then
            table.insert(attrs, n .. &quot;=\&quot;&quot; .. wikiescape(v) .. &quot;\&quot;&quot;)
        else
            table.insert(attrs, n)
        end
    end
    if (&quot;&quot; == content) then
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;/&gt;&quot;
    else
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    end
end

--[[
This is a clone of mw.text.nowiki.  When the mw.text library is installed,
this can be replaced by a call to that library. 
]]
function nowiki( s )
    -- string.gsub is safe here, because we're only caring about ASCII chars
    s = string.gsub( s, '[&quot;&amp;\'&lt;=&gt;%[%]{|}]', {
        ['&quot;'] = '&amp;#34;',
        ['&amp;'] = '&amp;#38;',
        [&quot;'&quot;] = '&amp;#39;',
        ['&lt;'] = '&amp;#60;',
        ['='] = '&amp;#61;',
        ['&gt;'] = '&amp;#62;',
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['{'] = '&amp;#123;',
        ['|'] = '&amp;#124;',
        ['}'] = '&amp;#125;',
    } )
    s = string.sub( string.gsub( '\n' .. s, '\n[#*:;]', {
        [&quot;\n#&quot;] = &quot;\n&amp;#35;&quot;,
        [&quot;\n*&quot;] = &quot;\n&amp;#42;&quot;,
        [&quot;\n:&quot;] = &quot;\n&amp;#58;&quot;,
        [&quot;\n;&quot;] = &quot;\n&amp;#59;&quot;,
    } ), 2 )
    s = string.gsub( s, '://', '&amp;#58;//' )
    s = string.gsub( s, 'ISBN ', 'ISBN&amp;#32;' )
    s = string.gsub( s, 'RFC ', 'RFC&amp;#32;' )

    return s
end

-- Formats a wiki style external link
function externallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    return &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;
end

-- Formats a wiki style internal link
function internallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    return &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(args.id) .. &quot;]]&quot;
end

-- Formats a link to Amazon
function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid({link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        table.insert( z.error_categories, &quot;Pages with DOI errors&quot; );        
        cat = ' &lt;span class=&quot;error&quot;&gt;Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    return text .. inactive .. cat 
 end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    if str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then 
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

--[[
Joins a sequence of string together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                end_chr = str:sub(-1,-1);
                if end_chr == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                        str = str:sub(1, -4) .. &quot;''&quot; .. value;
                    else
                        str = str .. value;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3) .. value;
                    else
                        str = str .. value;
                    end
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    -- Is the input a simple number?
    local num = tonumber( str ); 
    if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
        return str;
    else
        -- Use formatDate to interpret more complicated formats
        local lang = mw.getContentLanguage();
        local good, result;
        good, result = pcall( lang.formatDate, lang, 'Y', str )
        if good then 
            return result;
        else
            -- Can't make sense of this input, return blank.
            return &quot;&quot;;
        end
    end
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id})
    else
        table.insert( z.error_categories, &quot;Pages with OL errors&quot; );
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix= &quot;http://openlibrary.org/OL&quot;,id=id}) .. 
            ' &lt;span class=&quot;error&quot;&gt;Bad OL specified&lt;/span&gt;';
    end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil and first ~= '') then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    if count &gt; 1 and lastauthoramp ~= nil and lastauthoramp ~= &quot;&quot; and not etal then
        text[count-1] = text[count-1] .. &quot; &amp; &quot; .. text[count];
        text[count] = nil;
    end    
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= createTag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    return &quot;CITEREF&quot; .. P1 .. P2 .. P3 .. P4 .. P5
end

-- Gets author list from the input arguments
function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            authors[i] = {
                last = last,
                first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
                link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
                mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

-- Gets editor list from the input arguments
function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            editors[i] = {
                last = last,
                first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
                link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
                mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    -- Load Input Parameters

    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;] or args[&quot;authormask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;] or args[&quot;editormask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url or args.URL
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.p or args.page
    local Pages = hyphentodash( args.pp or args.pages )
    local At = args.at
    local page_error = false;
    
    if Page ~= nil and Page ~= '' then
        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 Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl or &quot;yes&quot;           -- Only used is ArchiveURL is present.
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript or &quot;.&quot;
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator or &quot;.&quot;
    local LastAuthorAmp = args.lastauthoramp
    local no_tracking_cats = args[&quot;template doc demo&quot;] or args.nocat or args.notracking or args[&quot;no-tracking&quot;] or &quot;&quot;;
    local MessageTail = &quot;&quot;;

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    
    local this_page = mw.title.getCurrentTitle();
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. this_page.prefixedText  -- end COinS data by page's non-encoded pagename

    if (Periodical ~= nil and Periodical ~= &quot;&quot;) and
        (Chapter == nil or Chapter == '') and
        (Title ~= nil and Title ~= &quot;&quot;) then
            Chapter = Title
            ChapterLink = TitleLink
            TransChapter = TransTitle
            Title = nil
            TitleLink = nil
            TransTitle = nil            
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or &quot;;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum, lastauthoramp = LastAuthorAmp }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;
        EditorNameSep = EditorNameSep .. &quot; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or &quot;;&quot;
        EditorSep = EditorSep .. &quot; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum, lastauthoramp = LastAuthorAmp }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date
    
    -- Test if cite web is called without giving a URL
    if ( URL == nil or URL == '' ) and
            ( ChapterURL == nil or ChapterURL == '' ) and
            ( ArchiveURL == nil or ArchiveURL == '' ) and                
            ( ConferenceURL == nil or ConferenceURL == '' ) and                
            ( TranscriptURL == nil or TranscriptURL == '' ) then
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.error_categories, 'Pages using web citations with no URL' );
            if MessageTail ~= '' then
                MessageTail = MessageTail .. &quot;, no URL on cite web&quot;;
            else
                MessageTail = MessageTail .. &quot;No URL on cite web&quot;;
            end
        end
        if ( AccessDate ~= nil and AccessDate ~= '' ) then
            table.insert( z.error_categories, 'Pages using citations with accessdate and no URL' );
            AccessDate = nil;
            if MessageTail ~= '' then
                MessageTail = MessageTail .. &quot;, accessdate used without URL&quot;;
            else
                MessageTail = MessageTail .. &quot;Accessdate used without URL&quot;; 
            end
        end        
    end    

    -- Test if citation has no title
    if ( Chapter == nil or Chapter == &quot;&quot; ) and 
            ( Title == nil or Title == &quot;&quot; ) and
            ( Periodical == nil or Periodical == &quot;&quot; ) and
            ( Conference == nil or Conference == &quot;&quot; ) then
        table.insert( z.error_categories, 'Pages with citations lacking titles' );
        if MessageTail ~= '' then
            MessageTail = MessageTail .. &quot;, citation has no title&quot;;
        else
            MessageTail = MessageTail .. &quot;Citation has no title&quot;; 
        end 
    end

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    
    local OriginalURL = URL
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) and (Title ~= nil and Title ~= &quot;&quot; )
        then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. createTag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid({label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid({label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
        DOI = sepc .. &quot; &quot; .. doi(DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid({label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid({label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid({label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid({label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid({label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid({label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid({label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc .. &quot; &quot; .. openlibrary(OL) else OL = &quot;&quot; end    
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid({label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid({label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid({label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( URL ~= nil and URL ~=&quot;&quot;) then
       URL = &quot; &quot; .. &quot;[&quot; .. URL .. &quot; &quot; .. nowiki(URL) .. &quot;]&quot;;
       table.insert( z.error_categories, &quot;Pages with citations having bare URLs&quot; );
       if config.CitationClass == &quot;web&quot; then
           URL = URL .. &quot; &lt;span class='error'&gt;No &lt;code&gt;title=&lt;/code&gt; specified&lt;/span&gt;&quot;
       else
           URL = URL .. hiddencomment(&quot;Bare URL here&quot;);
       end       
    else
       URL = &quot;&quot;
    end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid({label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end
    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot; &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
            table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            if OriginalURL ~= nil and OriginalURL ~= '' then
                Archived = sepc .. arch_text .. &quot; from [&quot; .. OriginalURL .. &quot; the original] on&quot; .. ArchiveDate
            else
                Archived = sepc .. arch_text .. &quot; from &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;&quot; ..
                    &quot;, you must also specify &lt;code&gt;url=&lt;/code&gt;&lt;/span&gt; on&quot; .. ArchiveDate
                table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
            end                
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; Lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot;) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; and
         Periodical ~= &quot;&quot; ) then
        if (Others ~= &quot;&quot;) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Format, Conference, Periodical, TitleType, Series, Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Format, Conference, Periodical, TitleType, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Series, Format, TitleType, Conference, Periodical, Language, Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
    end
    
    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );

    local text
    local pgtext = Page .. Pages .. At
    if page_error then
        table.insert( z.error_categories, 'Pages with citations using conflicting page specifications' );
        pgtext = pgtext .. hiddencomment('Bad page specification here');
    end
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        if ( config.CitationClass==&quot;journal&quot; and Periodical ) then
          text = safejoin( {Chapter, tcommon}, sepc );
          text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
          text = safejoin( {Chapter, tcommon, Date}, sepc );
          text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if ( config.CitationClass == &quot;citation&quot;) then PostScript = &quot;&quot; end
    if PostScript ~= '' and PostScript ~= nil and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        table.insert( z.error_categories, 'Pages with empty citations' );
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
    end
    
    text = createTag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = createTag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = createTag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
    text = text .. OCinS;
    
    if MessageTail ~= '' then
        text = text .. hiddencomment( MessageTail );
    end
    
    if no_tracking_cats == '' then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            args[k] = v;
        elseif k == 'postscript' then
            args[k] = v;
        end        
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--18Mar2013 Fixed &quot;page=&quot; to override &quot;pages=&quot; as in markup-based cites.
--19Mar2013 Fixed date of class=journal Periodical to show after page.
--19Mar2013 Changed null &quot;postscript=&quot; to suppress end-dot of citation.
--20Mar2013 If CitationClass is journal, show &quot;others=&quot; before title.
--20Mar2013 If CitationClass is book, show &quot;others=&quot; before edition.
--20Mar2013 If CitationClass is journal, adjust &quot;others=&quot; to have sepc.
--20Mar2013 For class &quot;journal&quot;, use book format unless Periodical set.
--
--End</text>
      <sha1>brsot2868lh9ar5g9bfqa68in18xxd5</sha1>
    </revision>
    <revision>
      <id>4630</id>
      <parentid>4629</parentid>
      <timestamp>2013-03-27T17:31:30Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>sync with sandbox.  Addresses format / type positioning, CITEREF encoding, and error categorization</comment>
      <origin>4630</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="57448" sha1="ngl7dv3krqsroe8jsqvv1k1ekre8rk6" xml:space="preserve">local z = {
    error_categories = {};
}

-- Formats a hidden comment for error trapping not intended to be visible to readers
function hiddencomment( content )
    return '&lt;span style=&quot;display: none;&quot; class=&quot;citation-comment&quot;&gt;' .. content .. '&lt;/span&gt;';
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',    
            ['{'] = '&amp;#123;',    
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

-- Create an HTML tag
function createTag(t, frame)
    local name = t.name or &quot;!-- --&quot;
    local content = t.contents or &quot;&quot;
    local attrs = {}
    for n,v in pairs(t.params) do
        if (v) then
            table.insert(attrs, n .. &quot;=\&quot;&quot; .. wikiescape(v) .. &quot;\&quot;&quot;)
        else
            table.insert(attrs, n)
        end
    end
    if (&quot;&quot; == content) then
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;/&gt;&quot;
    else
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    end
end

--[[
This is a clone of mw.text.nowiki.  When the mw.text library is installed,
this can be replaced by a call to that library. 
]]
function nowiki( s )
    -- string.gsub is safe here, because we're only caring about ASCII chars
    s = string.gsub( s, '[&quot;&amp;\'&lt;=&gt;%[%]{|}]', {
        ['&quot;'] = '&amp;#34;',
        ['&amp;'] = '&amp;#38;',
        [&quot;'&quot;] = '&amp;#39;',
        ['&lt;'] = '&amp;#60;',
        ['='] = '&amp;#61;',
        ['&gt;'] = '&amp;#62;',
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['{'] = '&amp;#123;',
        ['|'] = '&amp;#124;',
        ['}'] = '&amp;#125;',
    } )
    s = string.sub( string.gsub( '\n' .. s, '\n[#*:;]', {
        [&quot;\n#&quot;] = &quot;\n&amp;#35;&quot;,
        [&quot;\n*&quot;] = &quot;\n&amp;#42;&quot;,
        [&quot;\n:&quot;] = &quot;\n&amp;#58;&quot;,
        [&quot;\n;&quot;] = &quot;\n&amp;#59;&quot;,
    } ), 2 )
    s = string.gsub( s, '://', '&amp;#58;//' )
    s = string.gsub( s, 'ISBN ', 'ISBN&amp;#32;' )
    s = string.gsub( s, 'RFC ', 'RFC&amp;#32;' )

    return s
end

-- Formats a wiki style external link
function externallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    return &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;
end

-- Formats a wiki style internal link
function internallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    return &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(args.id) .. &quot;]]&quot;
end

-- Formats a link to Amazon
function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid({link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        table.insert( z.error_categories, &quot;Pages with DOI errors&quot; );        
        cat = ' &lt;span class=&quot;error&quot;&gt;Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    return text .. inactive .. cat 
 end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    if str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then 
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

--[[
Joins a sequence of string together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                end_chr = str:sub(-1,-1);
                if end_chr == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                        str = str:sub(1, -4) .. &quot;''&quot; .. value;
                    else
                        str = str .. value;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3) .. value;
                    else
                        str = str .. value;
                    end
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    -- Is the input a simple number?
    local num = tonumber( str ); 
    if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
        return str;
    else
        -- Use formatDate to interpret more complicated formats
        local lang = mw.getContentLanguage();
        local good, result;
        good, result = pcall( lang.formatDate, lang, 'Y', str )
        if good then 
            return result;
        else
            -- Can't make sense of this input, return blank.
            return &quot;&quot;;
        end
    end
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id})
    else
        table.insert( z.error_categories, &quot;Pages with OL errors&quot; );
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix= &quot;http://openlibrary.org/OL&quot;,id=id}) .. 
            ' &lt;span class=&quot;error&quot;&gt;Bad OL specified&lt;/span&gt;';
    end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil and first ~= '') then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    if count &gt; 1 and lastauthoramp ~= nil and lastauthoramp ~= &quot;&quot; and not etal then
        text[count-1] = text[count-1] .. &quot; &amp; &quot; .. text[count];
        text[count] = nil;
    end    
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= createTag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    
    -- Bugzilla 46608
    local encoded = mw.uri.anchorEncode( P1 .. P2 .. P3 .. P4 .. P5 );
    if encoded == false then
        encoded = &quot;&quot;;
    end
    
    return &quot;CITEREF&quot; .. encoded;
end

-- Gets author list from the input arguments
function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            authors[i] = {
                last = last,
                first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
                link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
                mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

-- Gets editor list from the input arguments
function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            editors[i] = {
                last = last,
                first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
                link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
                mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    -- Load Input Parameters

    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;] or args[&quot;authormask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;] or args[&quot;editormask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url or args.URL
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.p or args.page
    local Pages = hyphentodash( args.pp or args.pages )
    local At = args.at
    local page_error = false;
    
    if Page ~= nil and Page ~= '' then
        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 Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl or &quot;yes&quot;           -- Only used is ArchiveURL is present.
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript or &quot;.&quot;
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator or &quot;.&quot;
    local LastAuthorAmp = args.lastauthoramp
    local no_tracking_cats = args[&quot;template doc demo&quot;] or args.nocat or args.notracking or args[&quot;no-tracking&quot;] or &quot;&quot;;
    local MessageTail = &quot;&quot;;

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    
    local this_page = mw.title.getCurrentTitle();
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. this_page.prefixedText  -- end COinS data by page's non-encoded pagename

    if (Periodical ~= nil and Periodical ~= &quot;&quot;) and
        (Chapter == nil or Chapter == '') and
        (Title ~= nil and Title ~= &quot;&quot;) then
            Chapter = Title
            ChapterLink = TitleLink
            TransChapter = TransTitle
            Title = nil
            TitleLink = nil
            TransTitle = nil            
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local AuthorNameSep = args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;
        AuthorNameSep = AuthorNameSep .. &quot; &quot;
        local AuthorSep = args[&quot;author-separator&quot;] or &quot;;&quot;
        AuthorSep = AuthorSep .. &quot; &quot;
        local AuthorFormat = args[&quot;author-format&quot;] or args.authorformat
        local AuthorMaximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors) or 8
        local control = { sep = AuthorSep, namesep = AuthorNameSep, format = AuthorFormat, maximum = AuthorMaximum, lastauthoramp = LastAuthorAmp }
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local EditorNameSep = args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;
        EditorNameSep = EditorNameSep .. &quot; &quot;
        local EditorSep = args[&quot;editor-separator&quot;] or &quot;;&quot;
        EditorSep = EditorSep .. &quot; &quot;
        local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
        local EditorMaximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors) or 3
        local control = { sep = EditorSep, namesep = EditorNameSep, format = EditorFormat, maximum = EditorMaximum, lastauthoramp = LastAuthorAmp }
        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date
    
    if ( URL == nil or URL == '' ) and
            ( ChapterURL == nil or ChapterURL == '' ) and
            ( ArchiveURL == nil or ArchiveURL == '' ) and                
            ( ConferenceURL == nil or ConferenceURL == '' ) and                
            ( TranscriptURL == nil or TranscriptURL == '' ) then

        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.error_categories, 'Pages using web citations with no URL' );
            if MessageTail ~= '' then
                MessageTail = MessageTail .. &quot;, no URL on cite web&quot;;
            else
                MessageTail = MessageTail .. &quot;No URL on cite web&quot;;
            end
        end

        -- Test if accessdate is given without giving a URL
        if ( AccessDate ~= nil and AccessDate ~= '' ) then
            table.insert( z.error_categories, 'Pages using citations with accessdate and no URL' );
            AccessDate = nil;
            if MessageTail ~= '' then
                MessageTail = MessageTail .. &quot;, accessdate used without URL&quot;;
            else
                MessageTail = MessageTail .. &quot;Accessdate used without URL&quot;; 
            end
        end      
    
        -- Test if format is given without giving a URL
        if ( Format ~= nil and Format ~= '' ) then
            table.insert( z.error_categories, 'Pages using citations with format and no URL' );
            Format = Format .. hiddencomment( &quot;File format specified without giving a URL&quot; );
        end        
    end    

    -- Test if citation has no title
    if ( Chapter == nil or Chapter == &quot;&quot; ) and 
            ( Title == nil or Title == &quot;&quot; ) and
            ( Periodical == nil or Periodical == &quot;&quot; ) and
            ( Conference == nil or Conference == &quot;&quot; ) then
        table.insert( z.error_categories, 'Pages with citations lacking titles' );
        if MessageTail ~= '' then
            MessageTail = MessageTail .. &quot;, citation has no title&quot;;
        else
            MessageTail = MessageTail .. &quot;Citation has no title&quot;; 
        end 
    end

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    
    local OriginalURL = URL
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) and (Title ~= nil and Title ~= &quot;&quot; )
        then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
              or config.CitationClass == &quot;news&quot; ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. createTag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid({label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid({label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
        DOI = sepc .. &quot; &quot; .. doi(DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid({label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid({label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid({label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid({label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid({label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid({label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid({label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc .. &quot; &quot; .. openlibrary(OL) else OL = &quot;&quot; end    
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid({label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid({label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid({label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid({label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end

    if ( URL ~= nil and URL ~=&quot;&quot;) then
        URL = &quot; &quot; .. &quot;[&quot; .. URL .. &quot; &quot; .. nowiki(URL) .. &quot;]&quot;;
        table.insert( z.error_categories, &quot;Pages with citations having bare URLs&quot; );
        if config.CitationClass == &quot;web&quot; then
            table.insert( z.error_categories, &quot;Pages using web citations with no title&quot; );
            URL = URL .. &quot; &lt;span class='error'&gt;No &lt;code&gt;title=&lt;/code&gt; specified&lt;/span&gt;&quot;
        else
            URL = URL .. hiddencomment(&quot;Bare URL needs a title&quot;);
        end       
    else
        URL = &quot;&quot;
    end

    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot; &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
            table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            if OriginalURL ~= nil and OriginalURL ~= '' then
                Archived = sepc .. arch_text .. &quot; from [&quot; .. OriginalURL .. &quot; the original] on&quot; .. ArchiveDate
            else
                Archived = sepc .. arch_text .. &quot; from &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;&quot; ..
                    &quot;, you must also specify &lt;code&gt;url=&lt;/code&gt;&lt;/span&gt; on&quot; .. ArchiveDate
                table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
            end                
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; Lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot; ) or ( TitleNote and TitleNote ~= &quot;&quot; ) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; and
         Periodical ~= &quot;&quot; ) then
        if (Others ~= &quot;&quot;) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Series, Conference, Periodical, Format, TitleType, Language, Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
    end
    
    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );

    local text
    local pgtext = Page .. Pages .. At
    if page_error then
        table.insert( z.error_categories, 'Pages with citations using conflicting page specifications' );
        pgtext = pgtext .. hiddencomment('Bad page specification here');
    end
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date
              else Date = &quot; &quot; .. Date
            end
        end -- endif &quot;&quot;~=Date
        if ( config.CitationClass==&quot;journal&quot; and Periodical ) then
          text = safejoin( {Chapter, tcommon}, sepc );
          text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
          text = safejoin( {Chapter, tcommon, Date}, sepc );
          text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if ( config.CitationClass == &quot;citation&quot;) then PostScript = &quot;&quot; end
    if PostScript ~= '' and PostScript ~= nil and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = { 'Pages with empty citations' };
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
        MessageTail = '';
    end
    
    text = createTag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = createTag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = createTag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
    text = text .. OCinS;
    
    if MessageTail ~= '' then
        text = text .. hiddencomment( MessageTail );
    end
    
    if no_tracking_cats == '' then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            args[k] = v;
        elseif k == 'postscript' then
            args[k] = v;
        end        
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--18Mar2013 Fixed &quot;page=&quot; to override &quot;pages=&quot; as in markup-based cites.
--19Mar2013 Fixed date of class=journal Periodical to show after page.
--19Mar2013 Changed null &quot;postscript=&quot; to suppress end-dot of citation.
--20Mar2013 If CitationClass is journal, show &quot;others=&quot; before title.
--20Mar2013 If CitationClass is book, show &quot;others=&quot; before edition.
--20Mar2013 If CitationClass is journal, adjust &quot;others=&quot; to have sepc.
--20Mar2013 For class &quot;journal&quot;, use book format unless Periodical set.
--
--End</text>
      <sha1>ngl7dv3krqsroe8jsqvv1k1ekre8rk6</sha1>
    </revision>
    <revision>
      <id>4631</id>
      <parentid>4630</parentid>
      <timestamp>2013-03-28T19:38:39Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>sync with sandbox.  Fixes OrigYear with no Author, position of Series, and styling of cite web with Chapter.  Changes default behavior of display-authors.  Cleanup error message system.</comment>
      <origin>4631</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="57905" sha1="kmdm6rt5j9r4j01zu6ec8scoa56q610" xml:space="preserve">local z = {
    error_categories = {};
}

-- Formats a hidden comment for error trapping not intended to be visible to readers
function hiddencomment( content )
    return '&lt;span style=&quot;display: none;&quot; class=&quot;citation-comment&quot;&gt;' .. content .. '&lt;/span&gt;';
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',    
            ['{'] = '&amp;#123;',    
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

-- Create an HTML tag
function createTag(t, frame)
    local name = t.name or &quot;!-- --&quot;
    local content = t.contents or &quot;&quot;
    local attrs = {}
    for n,v in pairs(t.params) do
        if (v) then
            table.insert(attrs, n .. &quot;=\&quot;&quot; .. wikiescape(v) .. &quot;\&quot;&quot;)
        else
            table.insert(attrs, n)
        end
    end
    if (&quot;&quot; == content) then
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;/&gt;&quot;
    else
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    end
end

--[[
This is a clone of mw.text.nowiki.  When the mw.text library is installed,
this can be replaced by a call to that library. 
]]
function nowiki( s )
    -- string.gsub is safe here, because we're only caring about ASCII chars
    s = string.gsub( s, '[&quot;&amp;\'&lt;=&gt;%[%]{|}]', {
        ['&quot;'] = '&amp;#34;',
        ['&amp;'] = '&amp;#38;',
        [&quot;'&quot;] = '&amp;#39;',
        ['&lt;'] = '&amp;#60;',
        ['='] = '&amp;#61;',
        ['&gt;'] = '&amp;#62;',
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['{'] = '&amp;#123;',
        ['|'] = '&amp;#124;',
        ['}'] = '&amp;#125;',
    } )
    s = string.sub( string.gsub( '\n' .. s, '\n[#*:;]', {
        [&quot;\n#&quot;] = &quot;\n&amp;#35;&quot;,
        [&quot;\n*&quot;] = &quot;\n&amp;#42;&quot;,
        [&quot;\n:&quot;] = &quot;\n&amp;#58;&quot;,
        [&quot;\n;&quot;] = &quot;\n&amp;#59;&quot;,
    } ), 2 )
    s = string.gsub( s, '://', '&amp;#58;//' )
    s = string.gsub( s, 'ISBN ', 'ISBN&amp;#32;' )
    s = string.gsub( s, 'RFC ', 'RFC&amp;#32;' )

    return s
end

-- Formats a wiki style external link
function externallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    return &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;
end

-- Formats a wiki style internal link
function internallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    return &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(args.id) .. &quot;]]&quot;
end

-- Formats a link to Amazon
function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid({link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        table.insert( z.error_categories, &quot;Pages with DOI errors&quot; );        
        cat = ' &lt;span class=&quot;error&quot;&gt;Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    return text .. inactive .. cat 
 end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    if str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then 
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

--[[
Joins a sequence of string together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                end_chr = str:sub(-1,-1);
                if end_chr == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                        str = str:sub(1, -4) .. &quot;''&quot; .. value;
                    else
                        str = str .. value;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3) .. value;
                    else
                        str = str .. value;
                    end
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    -- Is the input a simple number?
    local num = tonumber( str ); 
    if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
        return str;
    else
        -- Use formatDate to interpret more complicated formats
        local lang = mw.getContentLanguage();
        local good, result;
        good, result = pcall( lang.formatDate, lang, 'Y', str )
        if good then 
            return result;
        else
            -- Can't make sense of this input, return blank.
            return &quot;&quot;;
        end
    end
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id})
    else
        table.insert( z.error_categories, &quot;Pages with OL errors&quot; );
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix= &quot;http://openlibrary.org/OL&quot;,id=id}) .. 
            ' &lt;span class=&quot;error&quot;&gt;Bad OL specified&lt;/span&gt;';
    end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil and first ~= '') then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    if count &gt; 1 and lastauthoramp ~= nil and lastauthoramp ~= &quot;&quot; and not etal then
        text[count-1] = text[count-1] .. &quot; &amp; &quot; .. text[count];
        text[count] = nil;
    end    
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= createTag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    
    -- Bugzilla 46608
    local encoded = mw.uri.anchorEncode( P1 .. P2 .. P3 .. P4 .. P5 );
    if encoded == false then
        encoded = &quot;&quot;;
    end
    
    return &quot;CITEREF&quot; .. encoded;
end

-- Gets author list from the input arguments
function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            authors[i] = {
                last = last,
                first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
                link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
                mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

-- Gets editor list from the input arguments
function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            editors[i] = {
                last = last,
                first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
                link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
                mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    -- Load Input Parameters

    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;] or args[&quot;authormask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;] or args[&quot;editormask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url or args.URL
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.p or args.page
    local Pages = hyphentodash( args.pp or args.pages )
    local At = args.at
    local page_error = false;
    
    if Page ~= nil and Page ~= '' then
        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 Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl or &quot;yes&quot;           -- Only used is ArchiveURL is present.
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript or &quot;.&quot;
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator or &quot;.&quot;
    local LastAuthorAmp = args.lastauthoramp
    local no_tracking_cats = args[&quot;template doc demo&quot;] or args.nocat or args.notracking or args[&quot;no-tracking&quot;] or &quot;&quot;;
    local MessageTail = {};

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=&quot;&quot;
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    
    local this_page = mw.title.getCurrentTitle();
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. this_page.prefixedText  -- end COinS data by page's non-encoded pagename

    if (Periodical ~= nil and Periodical ~= &quot;&quot;) and
        (Chapter == nil or Chapter == '') and
        (Title ~= nil and Title ~= &quot;&quot;) then
            Chapter = Title
            ChapterLink = TitleLink
            TransChapter = TransTitle
            Title = nil
            TitleLink = nil
            TransTitle = nil            
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local Maximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors);
        
        -- Preserve old-style implicit et al.
        if Maximum == nil and #a == 9 then 
            Maximum = 8;
            table.insert( z.error_categories, 'Pages using citations with old-style implicit et al.' );
            table.insert( MessageTail, 'Citation uses old-style implicit et al. for authors' );
        elseif Maximum == nil then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = (args[&quot;author-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = args[&quot;author-format&quot;] or args.authorformat,
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        }
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if Coauthors ~= nil and Coauthors ~= &quot;&quot; then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
                
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local Maximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors);

        -- Preserve old-style implicit et al.
        if Maximum == nil and #e == 4 then 
            Maximum = 3;
            table.insert( z.error_categories, 'Pages using citations with old-style implicit et al.' );
            table.insert( MessageTail, 'Citation uses old-style implicit et al. for editors' );
        elseif Maximum == nil then
            Maximum = #e + 1;
        end

        local control = { 
            sep = (args[&quot;editor-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = args[&quot;editor-format&quot;] or args.editorformat,
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
            }

        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date
    
    if ( URL == nil or URL == '' ) and
            ( ChapterURL == nil or ChapterURL == '' ) and
            ( ArchiveURL == nil or ArchiveURL == '' ) and                
            ( ConferenceURL == nil or ConferenceURL == '' ) and                
            ( TranscriptURL == nil or TranscriptURL == '' ) then

        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.error_categories, 'Pages using web citations with no URL' );
            table.insert( MessageTail, 'No URL on cite web' );
        end

        -- Test if accessdate is given without giving a URL
        if ( AccessDate ~= nil and AccessDate ~= '' ) then
            table.insert( z.error_categories, 'Pages using citations with accessdate and no URL' );
            table.insert( MessageTail, 'Accessdate used without URL' );
            AccessDate = nil;
        end      
    
        -- Test if format is given without giving a URL
        if ( Format ~= nil and Format ~= '' ) then
            table.insert( z.error_categories, 'Pages using citations with format and no URL' );
            Format = Format .. hiddencomment( &quot;File format specified without giving a URL&quot; );
        end        
    end    

    -- Test if citation has no title
    if ( Chapter == nil or Chapter == &quot;&quot; ) and 
            ( Title == nil or Title == &quot;&quot; ) and
            ( Periodical == nil or Periodical == &quot;&quot; ) and
            ( Conference == nil or Conference == &quot;&quot; ) then
        table.insert( z.error_categories, 'Pages with citations lacking titles' );
        table.insert( MessageTail, 'Citation has no title' );
    end

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    
    local OriginalURL = URL
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) and (Title ~= nil and Title ~= &quot;&quot; )
        then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
                or config.CitationClass == &quot;news&quot; ) and 
                Chapter == &quot;&quot; then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. createTag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid({label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid({label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
        DOI = sepc .. &quot; &quot; .. doi(DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid({label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid({label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid({label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid({label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid({label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid({label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid({label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc .. &quot; &quot; .. openlibrary(OL) else OL = &quot;&quot; end    
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid({label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid({label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid({label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid({label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end

    if ( URL ~= nil and URL ~=&quot;&quot;) then
        URL = &quot; &quot; .. &quot;[&quot; .. URL .. &quot; &quot; .. nowiki(URL) .. &quot;]&quot;;
        table.insert( z.error_categories, &quot;Pages with citations having bare URLs&quot; );
        if config.CitationClass == &quot;web&quot; then
            table.insert( z.error_categories, &quot;Pages using web citations with no title&quot; );
            URL = URL .. &quot; &lt;span class='error'&gt;No &lt;code&gt;title=&lt;/code&gt; specified&lt;/span&gt;&quot;
        else
            URL = URL .. hiddencomment(&quot;Bare URL needs a title&quot;);
        end       
    else
        URL = &quot;&quot;
    end

    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot; &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
            table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
        else
            if OriginalURL ~= nil and OriginalURL ~= '' then
                Archived = sepc .. arch_text .. &quot; from [&quot; .. OriginalURL .. &quot; the original] on&quot; .. ArchiveDate
            else
                Archived = sepc .. arch_text .. &quot; from &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;&quot; ..
                    &quot;, you must also specify &lt;code&gt;url=&lt;/code&gt;&lt;/span&gt; on&quot; .. ArchiveDate
                table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
            end                
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; Lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot; ) or ( TitleNote and TitleNote ~= &quot;&quot; ) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; and
         Periodical ~= &quot;&quot; ) then
        if (Others ~= &quot;&quot;) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
    end
    
    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );

    local text
    local pgtext = Page .. Pages .. At
    if page_error then
        table.insert( z.error_categories, 'Pages with citations using conflicting page specifications' );
        pgtext = pgtext .. hiddencomment('Bad page specification here');
    end
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end -- endif &quot;&quot;~=Date
        if ( config.CitationClass==&quot;journal&quot; and Periodical ) then
          text = safejoin( {Chapter, tcommon}, sepc );
          text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
          text = safejoin( {Chapter, tcommon, Date}, sepc );
          text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if ( config.CitationClass == &quot;citation&quot;) then PostScript = &quot;&quot; end
    if PostScript ~= '' and PostScript ~= nil and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = { 'Pages with empty citations' };
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
        MessageTail = {};
    end
    
    text = createTag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = createTag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = createTag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
    text = text .. OCinS;
    
    if #MessageTail ~= 0 then
        text = text .. hiddencomment( table.concat( MessageTail, &quot;; &quot; ) );
    end
    
    if no_tracking_cats == '' then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            args[k] = v;
        elseif k == 'postscript' then
            args[k] = v;
        end        
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--18Mar2013 Fixed &quot;page=&quot; to override &quot;pages=&quot; as in markup-based cites.
--19Mar2013 Fixed date of class=journal Periodical to show after page.
--19Mar2013 Changed null &quot;postscript=&quot; to suppress end-dot of citation.
--20Mar2013 If CitationClass is journal, show &quot;others=&quot; before title.
--20Mar2013 If CitationClass is book, show &quot;others=&quot; before edition.
--20Mar2013 If CitationClass is journal, adjust &quot;others=&quot; to have sepc.
--20Mar2013 For class &quot;journal&quot;, use book format unless Periodical set.
--
--End</text>
      <sha1>kmdm6rt5j9r4j01zu6ec8scoa56q610</sha1>
    </revision>
    <revision>
      <id>4632</id>
      <parentid>4631</parentid>
      <timestamp>2013-03-29T05:00:01Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>sync to sandbox, addresses archiveurl= error handling</comment>
      <origin>4632</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="58546" sha1="rplwl7wix0c5rddhyb52irfsupv7rf2" xml:space="preserve">local z = {
    error_categories = {};
}

-- Formats a hidden comment for error trapping not intended to be visible to readers
function hiddencomment( content )
    return '&lt;span style=&quot;display: none;&quot; class=&quot;citation-comment&quot;&gt;' .. content .. '&lt;/span&gt;';
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',    
            ['{'] = '&amp;#123;',    
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

-- Create an HTML tag
function createTag(t, frame)
    local name = t.name or &quot;!-- --&quot;
    local content = t.contents or &quot;&quot;
    local attrs = {}
    for n,v in pairs(t.params) do
        if (v) then
            table.insert(attrs, n .. &quot;=\&quot;&quot; .. wikiescape(v) .. &quot;\&quot;&quot;)
        else
            table.insert(attrs, n)
        end
    end
    if (&quot;&quot; == content) then
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;/&gt;&quot;
    else
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    end
end

--[[
This is a clone of mw.text.nowiki.  When the mw.text library is installed,
this can be replaced by a call to that library. 
]]
function nowiki( s )
    -- string.gsub is safe here, because we're only caring about ASCII chars
    s = string.gsub( s, '[&quot;&amp;\'&lt;=&gt;%[%]{|}]', {
        ['&quot;'] = '&amp;#34;',
        ['&amp;'] = '&amp;#38;',
        [&quot;'&quot;] = '&amp;#39;',
        ['&lt;'] = '&amp;#60;',
        ['='] = '&amp;#61;',
        ['&gt;'] = '&amp;#62;',
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['{'] = '&amp;#123;',
        ['|'] = '&amp;#124;',
        ['}'] = '&amp;#125;',
    } )
    s = string.sub( string.gsub( '\n' .. s, '\n[#*:;]', {
        [&quot;\n#&quot;] = &quot;\n&amp;#35;&quot;,
        [&quot;\n*&quot;] = &quot;\n&amp;#42;&quot;,
        [&quot;\n:&quot;] = &quot;\n&amp;#58;&quot;,
        [&quot;\n;&quot;] = &quot;\n&amp;#59;&quot;,
    } ), 2 )
    s = string.gsub( s, '://', '&amp;#58;//' )
    s = string.gsub( s, 'ISBN ', 'ISBN&amp;#32;' )
    s = string.gsub( s, 'RFC ', 'RFC&amp;#32;' )

    return s
end

-- Formats a wiki style external link
function externallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    return &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;
end

-- Formats a wiki style internal link
function internallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    return &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(args.id) .. &quot;]]&quot;
end

-- Formats a link to Amazon
function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid({link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        table.insert( z.error_categories, &quot;Pages with DOI errors&quot; );        
        cat = ' &lt;span class=&quot;error&quot;&gt;Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    return text .. inactive .. cat 
 end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    if str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then 
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

--[[
Joins a sequence of string together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                end_chr = str:sub(-1,-1);
                if end_chr == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                        str = str:sub(1, -4) .. &quot;''&quot; .. value;
                    else
                        str = str .. value;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3) .. value;
                    else
                        str = str .. value;
                    end
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    -- Is the input a simple number?
    local num = tonumber( str ); 
    if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
        return str;
    else
        -- Use formatDate to interpret more complicated formats
        local lang = mw.getContentLanguage();
        local good, result;
        good, result = pcall( lang.formatDate, lang, 'Y', str )
        if good then 
            return result;
        else
            -- Can't make sense of this input, return blank.
            return &quot;&quot;;
        end
    end
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id})
    else
        table.insert( z.error_categories, &quot;Pages with OL errors&quot; );
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix= &quot;http://openlibrary.org/OL&quot;,id=id}) .. 
            ' &lt;span class=&quot;error&quot;&gt;Bad OL specified&lt;/span&gt;';
    end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil and first ~= '') then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    if count &gt; 1 and lastauthoramp ~= nil and lastauthoramp ~= &quot;&quot; and not etal then
        text[count-1] = text[count-1] .. &quot; &amp; &quot; .. text[count];
        text[count] = nil;
    end    
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= createTag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    
    -- Bugzilla 46608
    local encoded = mw.uri.anchorEncode( P1 .. P2 .. P3 .. P4 .. P5 );
    if encoded == false then
        encoded = &quot;&quot;;
    end
    
    return &quot;CITEREF&quot; .. encoded;
end

-- Gets author list from the input arguments
function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            authors[i] = {
                last = last,
                first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
                link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
                mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

-- Gets editor list from the input arguments
function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            editors[i] = {
                last = last,
                first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
                link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
                mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    -- Load Input Parameters

    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;] or args[&quot;authormask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;] or args[&quot;editormask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url or args.URL
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = &quot;&quot;            
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = &quot;&quot;            
            end
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = '' end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.p or args.page
    local Pages = hyphentodash( args.pp or args.pages )
    local At = args.at
    local page_error = false;
    
    if Page ~= nil and Page ~= '' then
        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 Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl or &quot;yes&quot;           -- Only used is ArchiveURL is present.
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript or &quot;.&quot;
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator or &quot;.&quot;
    local LastAuthorAmp = args.lastauthoramp
    local no_tracking_cats = args[&quot;template doc demo&quot;] or args.nocat or args.notracking or args[&quot;no-tracking&quot;] or &quot;&quot;;
    local MessageTail = {};

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=nil
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    
    local this_page = mw.title.getCurrentTitle();
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. this_page.prefixedText  -- end COinS data by page's non-encoded pagename

    if (Periodical ~= nil and Periodical ~= &quot;&quot;) and
        (Chapter == nil or Chapter == '') and
        (Title ~= nil and Title ~= &quot;&quot;) then
            Chapter = Title
            ChapterLink = TitleLink
            TransChapter = TransTitle
            Title = nil
            TitleLink = nil
            TransTitle = nil            
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local Maximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors);
        
        -- Preserve old-style implicit et al.
        if Maximum == nil and #a == 9 then 
            Maximum = 8;
            table.insert( z.error_categories, 'Pages using citations with old-style implicit et al.' );
            table.insert( MessageTail, 'Citation uses old-style implicit et al. for authors' );
        elseif Maximum == nil then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = (args[&quot;author-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = args[&quot;author-format&quot;] or args.authorformat,
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        }
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if Coauthors ~= nil and Coauthors ~= &quot;&quot; then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
                
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local Maximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors);

        -- Preserve old-style implicit et al.
        if Maximum == nil and #e == 4 then 
            Maximum = 3;
            table.insert( z.error_categories, 'Pages using citations with old-style implicit et al.' );
            table.insert( MessageTail, 'Citation uses old-style implicit et al. for editors' );
        elseif Maximum == nil then
            Maximum = #e + 1;
        end

        local control = { 
            sep = (args[&quot;editor-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = args[&quot;editor-format&quot;] or args.editorformat,
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
            }

        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date
    
    if ( URL == nil or URL == '' ) and
            ( ChapterURL == nil or ChapterURL == '' ) and
            ( ArchiveURL == nil or ArchiveURL == '' ) and                
            ( ConferenceURL == nil or ConferenceURL == '' ) and                
            ( TranscriptURL == nil or TranscriptURL == '' ) then

        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.error_categories, 'Pages using web citations with no URL' );
            table.insert( MessageTail, 'No URL on cite web' );
        end

        -- Test if accessdate is given without giving a URL
        if ( AccessDate ~= nil and AccessDate ~= '' ) then
            table.insert( z.error_categories, 'Pages using citations with accessdate and no URL' );
            table.insert( MessageTail, 'Accessdate used without URL' );
            AccessDate = nil;
        end      
    
        -- Test if format is given without giving a URL
        if ( Format ~= nil and Format ~= '' ) then
            table.insert( z.error_categories, 'Pages using citations with format and no URL' );
            Format = Format .. hiddencomment( &quot;File format specified without giving a URL&quot; );
        end        
    end    

    -- Test if citation has no title
    if ( Chapter == nil or Chapter == &quot;&quot; ) and 
            ( Title == nil or Title == &quot;&quot; ) and
            ( Periodical == nil or Periodical == &quot;&quot; ) and
            ( Conference == nil or Conference == &quot;&quot; ) then
        table.insert( z.error_categories, 'Pages with citations lacking titles' );
        table.insert( MessageTail, 'Citation has no title' );
    end

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
        end
    end
    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
    if ( Chapter and &quot;&quot; &lt; Chapter ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) and (Title ~= nil and Title ~= &quot;&quot; )
        then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
        Chapter = Chapter .. TransChapter
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    else 
        Chapter = &quot;&quot; 
    end
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
                or config.CitationClass == &quot;news&quot; ) and 
                Chapter == &quot;&quot; then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
        Title = Title .. TransTitle
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    else 
        Title = &quot;&quot; 
    end
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. createTag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid({label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid({label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
        DOI = sepc .. &quot; &quot; .. doi(DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid({label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid({label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid({label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid({label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid({label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid({label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid({label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc .. &quot; &quot; .. openlibrary(OL) else OL = &quot;&quot; end    
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid({label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid({label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid({label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid({label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end

    if ( URL ~= nil and URL ~=&quot;&quot;) then
        URL = &quot; &quot; .. &quot;[&quot; .. URL .. &quot; &quot; .. nowiki(URL) .. &quot;]&quot;;
        table.insert( z.error_categories, &quot;Pages with citations having bare URLs&quot; );
        if config.CitationClass == &quot;web&quot; then
            table.insert( z.error_categories, &quot;Pages using web citations with no title&quot; );
            URL = URL .. &quot; &lt;span class='error'&gt;No &lt;code&gt;title=&lt;/code&gt; specified&lt;/span&gt;&quot;
        else
            URL = URL .. hiddencomment(&quot;Bare URL needs a title&quot;);
        end       
    else
        URL = &quot;&quot;
    end

    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot; &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
            table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
            if OriginalURL == nil or OriginalUrl == '' then
                table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
                Archived = Archived .. &quot; &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;&quot; ..
                    &quot; and &lt;code&gt;deadurl=no&lt;/code&gt;, then you must also specify &lt;code&gt;url=&lt;/code&gt;&lt;/span&gt;&quot;;                               
            end
        else
            if OriginalURL ~= nil and OriginalURL ~= '' then
                Archived = sepc .. arch_text .. &quot; from [&quot; .. OriginalURL .. &quot; the original] on&quot; .. ArchiveDate
            else
                if config.CitationClass ~= 'web' then 
                    Archived = sepc .. arch_text .. &quot; from &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;&quot; ..
                        &quot;, you must also specify &lt;code&gt;url=&lt;/code&gt;&lt;/span&gt; on&quot; .. ArchiveDate
                    table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
                else
                    Archived = sepc .. arch_text .. &quot; from the original on&quot; .. ArchiveDate
                end
            end                
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; Lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot; ) or ( TitleNote and TitleNote ~= &quot;&quot; ) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; and
         Periodical ~= &quot;&quot; ) then
        if (Others ~= &quot;&quot;) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
    end
    
    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );

    local text
    local pgtext = Page .. Pages .. At
    if page_error then
        table.insert( z.error_categories, 'Pages with citations using conflicting page specifications' );
        pgtext = pgtext .. hiddencomment('Bad page specification here');
    end
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end -- endif &quot;&quot;~=Date
        if ( config.CitationClass==&quot;journal&quot; and Periodical ) then
          text = safejoin( {Chapter, tcommon}, sepc );
          text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
          text = safejoin( {Chapter, tcommon, Date}, sepc );
          text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if ( config.CitationClass == &quot;citation&quot;) then PostScript = &quot;&quot; end
    if PostScript ~= '' and PostScript ~= nil and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = { 'Pages with empty citations' };
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
        MessageTail = {};
    end
    
    text = createTag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = createTag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = createTag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
    text = text .. OCinS;
    
    if #MessageTail ~= 0 then
        text = text .. hiddencomment( table.concat( MessageTail, &quot;; &quot; ) );
    end
    
    if no_tracking_cats == '' then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            args[k] = v;
        elseif k == 'postscript' then
            args[k] = v;
        end        
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--18Mar2013 Fixed &quot;page=&quot; to override &quot;pages=&quot; as in markup-based cites.
--19Mar2013 Fixed date of class=journal Periodical to show after page.
--19Mar2013 Changed null &quot;postscript=&quot; to suppress end-dot of citation.
--20Mar2013 If CitationClass is journal, show &quot;others=&quot; before title.
--20Mar2013 If CitationClass is book, show &quot;others=&quot; before edition.
--20Mar2013 If CitationClass is journal, adjust &quot;others=&quot; to have sepc.
--20Mar2013 For class &quot;journal&quot;, use book format unless Periodical set.
--
--End</text>
      <sha1>rplwl7wix0c5rddhyb52irfsupv7rf2</sha1>
    </revision>
    <revision>
      <id>4633</id>
      <parentid>4632</parentid>
      <timestamp>2013-03-29T16:15:56Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>sync to sandbox, addresses handling of trans-title with no title.  Also fixes to COinS for encyclopedia mode.</comment>
      <origin>4633</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="59410" sha1="3xuvex4fjkxj4x9i8hgdmhmrq42w7a7" xml:space="preserve">local z = {
    error_categories = {};
}

-- Formats a hidden comment for error trapping not intended to be visible to readers
function hiddencomment( content )
    return '&lt;span style=&quot;display: none;&quot; class=&quot;citation-comment&quot;&gt;' .. content .. '&lt;/span&gt;';
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',    
            ['{'] = '&amp;#123;',    
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

-- Create an HTML tag
function createTag(t, frame)
    local name = t.name or &quot;!-- --&quot;
    local content = t.contents or &quot;&quot;
    local attrs = {}
    for n,v in pairs(t.params) do
        if (v) then
            table.insert(attrs, n .. &quot;=\&quot;&quot; .. wikiescape(v) .. &quot;\&quot;&quot;)
        else
            table.insert(attrs, n)
        end
    end
    if (&quot;&quot; == content) then
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;/&gt;&quot;
    else
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    end
end

--[[
This is a clone of mw.text.nowiki.  When the mw.text library is installed,
this can be replaced by a call to that library. 
]]
function nowiki( s )
    -- string.gsub is safe here, because we're only caring about ASCII chars
    s = string.gsub( s, '[&quot;&amp;\'&lt;=&gt;%[%]{|}]', {
        ['&quot;'] = '&amp;#34;',
        ['&amp;'] = '&amp;#38;',
        [&quot;'&quot;] = '&amp;#39;',
        ['&lt;'] = '&amp;#60;',
        ['='] = '&amp;#61;',
        ['&gt;'] = '&amp;#62;',
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['{'] = '&amp;#123;',
        ['|'] = '&amp;#124;',
        ['}'] = '&amp;#125;',
    } )
    s = string.sub( string.gsub( '\n' .. s, '\n[#*:;]', {
        [&quot;\n#&quot;] = &quot;\n&amp;#35;&quot;,
        [&quot;\n*&quot;] = &quot;\n&amp;#42;&quot;,
        [&quot;\n:&quot;] = &quot;\n&amp;#58;&quot;,
        [&quot;\n;&quot;] = &quot;\n&amp;#59;&quot;,
    } ), 2 )
    s = string.gsub( s, '://', '&amp;#58;//' )
    s = string.gsub( s, 'ISBN ', 'ISBN&amp;#32;' )
    s = string.gsub( s, 'RFC ', 'RFC&amp;#32;' )

    return s
end

-- Formats a wiki style external link
function externallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    return &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;
end

-- Formats a wiki style internal link
function internallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    return &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(args.id) .. &quot;]]&quot;
end

-- Formats a link to Amazon
function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid({link=&quot;Amazon Standard Identification Number&quot;,label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        table.insert( z.error_categories, &quot;Pages with DOI errors&quot; );        
        cat = ' &lt;span class=&quot;error&quot;&gt;Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    return text .. inactive .. cat 
 end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    if str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then 
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

--[[
Joins a sequence of string together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                end_chr = str:sub(-1,-1);
                if end_chr == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                        str = str:sub(1, -4) .. &quot;''&quot; .. value;
                    else
                        str = str .. value;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3) .. value;
                    else
                        str = str .. value;
                    end
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    -- Is the input a simple number?
    local num = tonumber( str ); 
    if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
        return str;
    else
        -- Use formatDate to interpret more complicated formats
        local lang = mw.getContentLanguage();
        local good, result;
        good, result = pcall( lang.formatDate, lang, 'Y', str )
        if good then 
            return result;
        else
            -- Can't make sense of this input, return blank.
            return &quot;&quot;;
        end
    end
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id})
    else
        table.insert( z.error_categories, &quot;Pages with OL errors&quot; );
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,prefix= &quot;http://openlibrary.org/OL&quot;,id=id}) .. 
            ' &lt;span class=&quot;error&quot;&gt;Bad OL specified&lt;/span&gt;';
    end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil and first ~= '') then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    if count &gt; 1 and lastauthoramp ~= nil and lastauthoramp ~= &quot;&quot; and not etal then
        text[count-1] = text[count-1] .. &quot; &amp; &quot; .. text[count];
        text[count] = nil;
    end    
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    if ( &quot;scap&quot; == format ) then result= createTag({name=&quot;span&quot;, contents=result, params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    
    -- Bugzilla 46608
    local encoded = mw.uri.anchorEncode( P1 .. P2 .. P3 .. P4 .. P5 );
    if encoded == false then
        encoded = &quot;&quot;;
    end
    
    return &quot;CITEREF&quot; .. encoded;
end

-- Gets author list from the input arguments
function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            authors[i] = {
                last = last,
                first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
                link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
                mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

-- Gets editor list from the input arguments
function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            editors[i] = {
                last = last,
                first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
                link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
                mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    -- Load Input Parameters

    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;] or args[&quot;authormask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;] or args[&quot;editormask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url or args.URL
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work or args.periodical or args.encyclopedia or args.encyclopaedia
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = nil          
            TransTitle = nil
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = nil 
                TransTitle = nil
            end
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = nil end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.p or args.page
    local Pages = hyphentodash( args.pp or args.pages )
    local At = args.at
    local page_error = false;
    
    if Page ~= nil and Page ~= '' then
        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 Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace or args.place or args.location
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl or &quot;yes&quot;           -- Only used is ArchiveURL is present.
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript or &quot;.&quot;
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator or &quot;.&quot;
    local LastAuthorAmp = args.lastauthoramp
    local no_tracking_cats = args[&quot;template doc demo&quot;] or args.nocat or args.notracking or args[&quot;no-tracking&quot;] or &quot;&quot;;
    local MessageTail = {};

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=nil
          end
        end
    elseif ( config.CitationClass == &quot;citation&quot; ) then
        sepc = &quot;,&quot;
        if ( Ref == nil ) then Ref = &quot;harv&quot; end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    
    local this_page = mw.title.getCurrentTitle();
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. this_page.prefixedText  -- end COinS data by page's non-encoded pagename

    if (Periodical ~= nil and Periodical ~= &quot;&quot;) and
        (Chapter == nil or Chapter == '') and
        (Title ~= nil and Title ~= &quot;&quot;) then
            Chapter = Title
            ChapterLink = TitleLink
            TransChapter = TransTitle
            Title = nil
            TitleLink = nil
            TransTitle = nil            
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local Maximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors);
        
        -- Preserve old-style implicit et al.
        if Maximum == nil and #a == 9 then 
            Maximum = 8;
            table.insert( z.error_categories, 'Pages using citations with old-style implicit et al.' );
            table.insert( MessageTail, 'Citation uses old-style implicit et al. for authors' );
        elseif Maximum == nil then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = (args[&quot;author-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = args[&quot;author-format&quot;] or args.authorformat,
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        }
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if Coauthors ~= nil and Coauthors ~= &quot;&quot; then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
                
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local Maximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors);

        -- Preserve old-style implicit et al.
        if Maximum == nil and #e == 4 then 
            Maximum = 3;
            table.insert( z.error_categories, 'Pages using citations with old-style implicit et al.' );
            table.insert( MessageTail, 'Citation uses old-style implicit et al. for editors' );
        elseif Maximum == nil then
            Maximum = #e + 1;
        end

        local control = { 
            sep = (args[&quot;editor-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = args[&quot;editor-format&quot;] or args.editorformat,
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
            }

        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date
    
    if ( URL == nil or URL == '' ) and
            ( ChapterURL == nil or ChapterURL == '' ) and
            ( ArchiveURL == nil or ArchiveURL == '' ) and                
            ( ConferenceURL == nil or ConferenceURL == '' ) and                
            ( TranscriptURL == nil or TranscriptURL == '' ) then

        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.error_categories, 'Pages using web citations with no URL' );
            table.insert( MessageTail, 'No URL on cite web' );
        end

        -- Test if accessdate is given without giving a URL
        if ( AccessDate ~= nil and AccessDate ~= '' ) then
            table.insert( z.error_categories, 'Pages using citations with accessdate and no URL' );
            table.insert( MessageTail, 'Accessdate used without URL' );
            AccessDate = nil;
        end      
    
        -- Test if format is given without giving a URL
        if ( Format ~= nil and Format ~= '' ) then
            table.insert( z.error_categories, 'Pages using citations with format and no URL' );
            Format = Format .. hiddencomment( &quot;File format specified without giving a URL&quot; );
        end        
    end    

    -- Test if citation has no title
    if ( Chapter == nil or Chapter == &quot;&quot; ) and 
            ( Title == nil or Title == &quot;&quot; ) and
            ( Periodical == nil or Periodical == &quot;&quot; ) and
            ( Conference == nil or Conference == &quot;&quot; ) and 
            ( TransTitle == nil or TransTitle == &quot;&quot; ) and
            ( TransChapter == nil or TransChapter == &quot;&quot; ) then
        table.insert( z.error_categories, 'Pages with citations lacking titles' );
        table.insert( MessageTail, 'Citation has no title' );
    end

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
        end
    end

    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
        
    -- Format chapter / article title
    if ( Chapter ~= nil and Chapter ~= &quot;&quot; ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) and (Title ~= nil and Title ~= &quot;&quot; )
        then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
    else
        Chapter = &quot;&quot;;
    end
    if TransChapter ~= &quot;&quot; and Chapter == &quot;&quot; then
        table.insert( z.error_categories, 'Pages with citations using translated terms without the original' );
        TransChapter = TransChapter .. hiddencomment( &quot;Translated title included without the original&quot; );
    end
    Chapter = Chapter .. TransChapter
    if Chapter ~= &quot;&quot; then
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    end
    
    -- Format main title.
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
                or config.CitationClass == &quot;news&quot; ) and 
                Chapter == &quot;&quot; then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
    else
        Title = &quot;&quot;;
    end    
    if TransTitle ~= &quot;&quot; and Title == &quot;&quot; then
        table.insert( z.error_categories, 'Pages with citations using translated terms without the original' );
        TransTitle = TransTitle .. hiddencomment( &quot;Translated title included without the original&quot; );
    end
    Title = Title .. TransTitle
    if Title ~= &quot;&quot; then
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    end


    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. createTag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid({label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid({label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
        DOI = sepc .. &quot; &quot; .. doi(DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid({label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid({label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid({label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid({label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid({label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid({label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid({label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc .. &quot; &quot; .. openlibrary(OL) else OL = &quot;&quot; end    
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid({label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid({label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid({label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid({label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end

    if ( URL ~= nil and URL ~=&quot;&quot;) then
        URL = &quot; &quot; .. &quot;[&quot; .. URL .. &quot; &quot; .. nowiki(URL) .. &quot;]&quot;;
        table.insert( z.error_categories, &quot;Pages with citations having bare URLs&quot; );
        if config.CitationClass == &quot;web&quot; then
            table.insert( z.error_categories, &quot;Pages using web citations with no title&quot; );
            URL = URL .. &quot; &lt;span class='error'&gt;No &lt;code&gt;title=&lt;/code&gt; specified&lt;/span&gt;&quot;
        else
            URL = URL .. hiddencomment(&quot;Bare URL needs a title&quot;);
        end       
    else
        URL = &quot;&quot;
    end

    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot; &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
            table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
            if OriginalURL == nil or OriginalUrl == '' then
                table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
                Archived = Archived .. &quot; &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;&quot; ..
                    &quot; and &lt;code&gt;deadurl=no&lt;/code&gt;, then you must also specify &lt;code&gt;url=&lt;/code&gt;&lt;/span&gt;&quot;;                               
            end
        else
            if OriginalURL ~= nil and OriginalURL ~= '' then
                Archived = sepc .. arch_text .. &quot; from [&quot; .. OriginalURL .. &quot; the original] on&quot; .. ArchiveDate
            else
                if config.CitationClass ~= 'web' then 
                    Archived = sepc .. arch_text .. &quot; from &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;&quot; ..
                        &quot;, you must also specify &lt;code&gt;url=&lt;/code&gt;&lt;/span&gt; on&quot; .. ArchiveDate
                    table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
                else
                    Archived = sepc .. arch_text .. &quot; from the original on&quot; .. ArchiveDate
                end
            end                
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; Lay summary]&quot; .. LaySource .. LayDate
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot; ) or ( TitleNote and TitleNote ~= &quot;&quot; ) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( config.CitationClass == &quot;journal&quot; and
         Periodical ~= &quot;&quot; ) then
        if (Others ~= &quot;&quot;) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc );
    elseif ( config.CitationClass == &quot;citation&quot; ) or (config.CitationClass == &quot;encyclopaedia&quot; ) then
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Issue, Edition, Publisher, Agency, Others, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
    end
    
    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );

    local text
    local pgtext = Page .. Pages .. At
    if page_error then
        table.insert( z.error_categories, 'Pages with citations using conflicting page specifications' );
        pgtext = pgtext .. hiddencomment('Bad page specification here');
    end
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end -- endif &quot;&quot;~=Date
        if ( config.CitationClass==&quot;journal&quot; and Periodical ) then
          text = safejoin( {Chapter, tcommon}, sepc );
          text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
          text = safejoin( {Chapter, tcommon, Date}, sepc );
          text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if ( config.CitationClass == &quot;citation&quot;) then PostScript = &quot;&quot; end
    if PostScript ~= '' and PostScript ~= nil and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = { 'Pages with empty citations' };
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
        MessageTail = {};
    end
    
    text = createTag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = createTag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = createTag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
    text = text .. OCinS;
    
    if #MessageTail ~= 0 then
        text = text .. hiddencomment( table.concat( MessageTail, &quot;; &quot; ) );
    end
    
    if no_tracking_cats == '' then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            args[k] = v;
        elseif k == 'postscript' then
            args[k] = v;
        end        
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--18Mar2013 Fixed &quot;page=&quot; to override &quot;pages=&quot; as in markup-based cites.
--19Mar2013 Fixed date of class=journal Periodical to show after page.
--19Mar2013 Changed null &quot;postscript=&quot; to suppress end-dot of citation.
--20Mar2013 If CitationClass is journal, show &quot;others=&quot; before title.
--20Mar2013 If CitationClass is book, show &quot;others=&quot; before edition.
--20Mar2013 If CitationClass is journal, adjust &quot;others=&quot; to have sepc.
--20Mar2013 For class &quot;journal&quot;, use book format unless Periodical set.
--
--End</text>
      <sha1>3xuvex4fjkxj4x9i8hgdmhmrq42w7a7</sha1>
    </revision>
    <revision>
      <id>4634</id>
      <parentid>4633</parentid>
      <timestamp>2013-04-01T19:57:47Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>sync with sandbox.  Mostly prep work for dealing with {citation} (e.g. Place=), also code formatting, and wikilinks in urls</comment>
      <origin>4634</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="60589" sha1="2e41yzuh9gxmd1opo0n7l1vkqvedy1o" xml:space="preserve">local z = {
    error_categories = {};
    message_tail = {};
}

-- Formats a hidden comment for error trapping not intended to be visible to readers
function hiddencomment( content )
    return '&lt;span style=&quot;display: none;&quot; class=&quot;citation-comment&quot;&gt;' .. content .. '&lt;/span&gt;';
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',    
            ['{'] = '&amp;#123;',    
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

-- Create an HTML tag
function createTag(t, frame)
    local name = t.name or &quot;!-- --&quot;
    local content = t.contents or &quot;&quot;
    local attrs = {}
    for n,v in pairs(t.params) do
        if (v) then
            table.insert(attrs, n .. &quot;=\&quot;&quot; .. wikiescape(v) .. &quot;\&quot;&quot;)
        else
            table.insert(attrs, n)
        end
    end
    if (&quot;&quot; == content) then
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;/&gt;&quot;
    else
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    end
end

--[[
This is a clone of mw.text.nowiki.  When the mw.text library is installed,
this can be replaced by a call to that library. 
]]
function nowiki( s )
    -- string.gsub is safe here, because we're only caring about ASCII chars
    s = string.gsub( s, '[&quot;&amp;\'&lt;=&gt;%[%]{|}]', {
        ['&quot;'] = '&amp;#34;',
        ['&amp;'] = '&amp;#38;',
        [&quot;'&quot;] = '&amp;#39;',
        ['&lt;'] = '&amp;#60;',
        ['='] = '&amp;#61;',
        ['&gt;'] = '&amp;#62;',
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['{'] = '&amp;#123;',
        ['|'] = '&amp;#124;',
        ['}'] = '&amp;#125;',
    } )
    s = string.sub( string.gsub( '\n' .. s, '\n[#*:;]', {
        [&quot;\n#&quot;] = &quot;\n&amp;#35;&quot;,
        [&quot;\n*&quot;] = &quot;\n&amp;#42;&quot;,
        [&quot;\n:&quot;] = &quot;\n&amp;#58;&quot;,
        [&quot;\n;&quot;] = &quot;\n&amp;#59;&quot;,
    } ), 2 )
    s = string.gsub( s, '://', '&amp;#58;//' )
    s = string.gsub( s, 'ISBN ', 'ISBN&amp;#32;' )
    s = string.gsub( s, 'RFC ', 'RFC&amp;#32;' )

    return s
end

-- Formats a wiki style external link
function externallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    return &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;
end

-- Formats a wiki style internal link
function internallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    return &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. 
            args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(args.id) .. &quot;]]&quot;
end

-- Formats a link to Amazon
function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid({link=&quot;Amazon Standard Identification Number&quot;,
        label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,
            prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        table.insert( z.error_categories, &quot;Pages with DOI errors&quot; );        
        cat = ' &lt;span class=&quot;error&quot;&gt;Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    return text .. inactive .. cat 
 end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.error_categories, &quot;Pages with citations having wikilinks embedded in URL titles&quot; );
        table.insert( z.message_tail, &quot;Wikilink embedded in URL title&quot; );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    if str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then 
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

--[[
Joins a sequence of string together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                end_chr = str:sub(-1,-1);
                if end_chr == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then                  
                        str = str:sub(1, -4) .. &quot;''&quot; .. value;
                    else
                        str = str .. value;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3) .. value;
                    else
                        str = str .. value;
                    end
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    -- Is the input a simple number?
    local num = tonumber( str ); 
    if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
        return str;
    else
        -- Use formatDate to interpret more complicated formats
        local lang = mw.getContentLanguage();
        local good, result;
        good, result = pcall( lang.formatDate, lang, 'Y', str )
        if good then 
            return result;
        else
            -- Can't make sense of this input, return blank.
            return &quot;&quot;;
        end
    end
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id})
    else
        table.insert( z.error_categories, &quot;Pages with OL errors&quot; );
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id}) .. 
            ' &lt;span class=&quot;error&quot;&gt;Bad OL specified&lt;/span&gt;';
    end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil and first ~= '') then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    if count &gt; 1 and lastauthoramp ~= nil and lastauthoramp ~= &quot;&quot; and not etal then
        text[count-1] = text[count-1] .. &quot; &amp; &quot; .. text[count];
        text[count] = nil;
    end    
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result= createTag({name=&quot;span&quot;, contents=result, 
        params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    
    -- Bugzilla 46608
    local encoded = mw.uri.anchorEncode( P1 .. P2 .. P3 .. P4 .. P5 );
    if encoded == false then
        encoded = &quot;&quot;;
    end
    
    return &quot;CITEREF&quot; .. encoded;
end

-- Gets author list from the input arguments
function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or 
                args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            authors[i] = {
                last = last,
                first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or 
                        args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
                link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or 
                        args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
                mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or 
                        args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

-- Gets editor list from the input arguments
function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or 
                args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            editors[i] = {
                last = last,
                first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
                link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or 
                        args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
                mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or 
                        args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    -- Load Input Parameters

    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;] or args[&quot;authormask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;] or args[&quot;editormask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url or args.URL
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work
            or args.periodical or args.encyclopedia or args.encyclopaedia
            
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = nil          
            TransTitle = nil
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = nil 
                TransTitle = nil
            end
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = nil end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.p or args.page
    local Pages = hyphentodash( args.pp or args.pages )
    local At = args.at
    local page_error = false;
    
    if Page ~= nil and Page ~= '' then
        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 Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace 
            or args.place or args.location
    local Place = args.place or args.location
    if PublicationPlace == Place then Place = nil; end
    
    local Location = PublicationPlace
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl or &quot;yes&quot;           -- Only used is ArchiveURL is present.
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript or &quot;.&quot;
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator or &quot;.&quot;
    local LastAuthorAmp = args.lastauthoramp
    local no_tracking_cats = args[&quot;template doc demo&quot;] or args.nocat or 
            args.notracking or args[&quot;no-tracking&quot;] or &quot;&quot;;

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=nil
          end
        end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows 
    -- automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    
    local this_page = mw.title.getCurrentTitle();
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. this_page.prefixedText  -- end COinS data by page's non-encoded pagename

    if (Periodical ~= nil and Periodical ~= &quot;&quot;) and
        (Chapter == nil or Chapter == '') and
        (Title ~= nil and Title ~= &quot;&quot;) then
            Chapter = Title
            ChapterLink = TitleLink
            TransChapter = TransTitle
            Title = nil
            TitleLink = nil
            TransTitle = nil            
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local Maximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors);
        
        -- Preserve old-style implicit et al.
        if Maximum == nil and #a == 9 then 
            Maximum = 8;
            table.insert( z.error_categories, 'Pages using citations with old-style implicit et al.' );
            table.insert( z.message_tail, 'Citation uses old-style implicit et al. for authors' );
        elseif Maximum == nil then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = (args[&quot;author-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = args[&quot;author-format&quot;] or args.authorformat,
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        }
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if Coauthors ~= nil and Coauthors ~= &quot;&quot; then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
                
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local Maximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors);

        -- Preserve old-style implicit et al.
        if Maximum == nil and #e == 4 then 
            Maximum = 3;
            table.insert( z.error_categories, 'Pages using citations with old-style implicit et al.' );
            table.insert( z.message_tail, 'Citation uses old-style implicit et al. for editors' );
        elseif Maximum == nil then
            Maximum = #e + 1;
        end

        local control = { 
            sep = (args[&quot;editor-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = args[&quot;editor-format&quot;] or args.editorformat,
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
            }

        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date
    
    if ( URL == nil or URL == '' ) and
            ( ChapterURL == nil or ChapterURL == '' ) and
            ( ArchiveURL == nil or ArchiveURL == '' ) and                
            ( ConferenceURL == nil or ConferenceURL == '' ) and                
            ( TranscriptURL == nil or TranscriptURL == '' ) then

        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.error_categories, 'Pages using web citations with no URL' );
            table.insert( z.message_tail, 'No URL on cite web' );
        end

        -- Test if accessdate is given without giving a URL
        if ( AccessDate ~= nil and AccessDate ~= '' ) then
            table.insert( z.error_categories, 'Pages using citations with accessdate and no URL' );
            table.insert( z.message_tail, 'Accessdate used without URL' );
            AccessDate = nil;
        end      
    
        -- Test if format is given without giving a URL
        if ( Format ~= nil and Format ~= '' ) then
            table.insert( z.error_categories, 'Pages using citations with format and no URL' );
            Format = Format .. hiddencomment( &quot;File format specified without giving a URL&quot; );
        end        
    end    

    -- Test if citation has no title
    if ( Chapter == nil or Chapter == &quot;&quot; ) and 
            ( Title == nil or Title == &quot;&quot; ) and
            ( Periodical == nil or Periodical == &quot;&quot; ) and
            ( Conference == nil or Conference == &quot;&quot; ) and 
            ( TransTitle == nil or TransTitle == &quot;&quot; ) and
            ( TransChapter == nil or TransChapter == &quot;&quot; ) then
        table.insert( z.error_categories, 'Pages with citations lacking titles' );
        table.insert( z.message_tail, 'Citation has no title' );
    end

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
        end
    end

    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
        
    -- Format chapter / article title
    if ( Chapter ~= nil and Chapter ~= &quot;&quot; ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) and (Title ~= nil and Title ~= &quot;&quot; )
        then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
    else
        Chapter = &quot;&quot;;
    end
    if TransChapter ~= &quot;&quot; and Chapter == &quot;&quot; then
        table.insert( z.error_categories, 'Pages with citations using translated terms without the original' );
        TransChapter = TransChapter .. hiddencomment( &quot;Translated title included without the original&quot; );
    end
    Chapter = Chapter .. TransChapter
    if Chapter ~= &quot;&quot; then
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    end
    
    -- Format main title.
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
                or config.CitationClass == &quot;news&quot; 
                or config.CitationClass == &quot;pressrelease&quot; ) and 
                Chapter == &quot;&quot; then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
    else
        Title = &quot;&quot;;
    end    
    if TransTitle ~= &quot;&quot; and Title == &quot;&quot; then
        table.insert( z.error_categories, 'Pages with citations using translated terms without the original' );
        TransTitle = TransTitle .. hiddencomment( &quot;Translated title included without the original&quot; );
    end
    Title = Title .. TransTitle
    if Title ~= &quot;&quot; then
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    end

    if ( Place ~= nil and Place ~= &quot;&quot; ) then
        if sepc == '.' then
            Place = &quot; Written at &quot; .. Place .. sepc .. &quot; &quot;;
        else
            Place = &quot; written at &quot; .. Place .. sepc .. &quot; &quot;;
        end            
    else
        Place = &quot;&quot;;
    end
    
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( PublicationPlace ~= nil and PublicationPlace ~=&quot;&quot; ) then
        PublicationPlace = PublicationPlace .. &quot;: &quot;
        else PublicationPlace = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. createTag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, 
            params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid({label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,
            prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid({label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,
            prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
        DOI = sepc .. &quot; &quot; .. doi(DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid({label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,
            prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid({label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,
            prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid({label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,
            prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid({label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,
            prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid({label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,
            prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid({label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,
            prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid({label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,
            prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc .. &quot; &quot; .. openlibrary(OL) else OL = &quot;&quot; end    
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid({label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,
            prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;
            ,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,
            prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid({label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,
            prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid({label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,
            prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid({label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,
            prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end

    if ( URL ~= nil and URL ~=&quot;&quot;) then
        URL = &quot; &quot; .. &quot;[&quot; .. URL .. &quot; &quot; .. nowiki(URL) .. &quot;]&quot;;
        table.insert( z.error_categories, &quot;Pages with citations having bare URLs&quot; );
        if config.CitationClass == &quot;web&quot; then
            table.insert( z.error_categories, &quot;Pages using web citations with no title&quot; );
            URL = URL .. &quot; &lt;span class='error'&gt;No &lt;code&gt;title=&lt;/code&gt; specified&lt;/span&gt;&quot;
        else
            URL = URL .. hiddencomment(&quot;Bare URL needs a title&quot;);
        end       
    else
        URL = &quot;&quot;
    end

    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot; &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, &quot; ..
                &quot;you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
            table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
            if OriginalURL == nil or OriginalUrl == '' then
                table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
                Archived = Archived .. &quot; &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;&quot; ..
                    &quot; and &lt;code&gt;deadurl=no&lt;/code&gt;, then you must also specify &lt;code&gt;url=&lt;/code&gt;&lt;/span&gt;&quot;;                               
            end
        else
            if OriginalURL ~= nil and OriginalURL ~= '' then
                Archived = sepc .. arch_text .. &quot; from [&quot; .. OriginalURL .. &quot; the original] on&quot; .. ArchiveDate
            else
                if config.CitationClass ~= 'web' then 
                    Archived = sepc .. arch_text .. &quot; from &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;&quot; ..
                        &quot;, you must also specify &lt;code&gt;url=&lt;/code&gt;&lt;/span&gt; on&quot; .. ArchiveDate
                    table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
                else
                    Archived = sepc .. arch_text .. &quot; from the original on&quot; .. ArchiveDate
                end
            end                
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        if sepc == '.' then
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; Lay summary]&quot; .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublicationDate and PublicationDate ~=&quot;&quot; )
            then PublicationDate = &quot; &quot; .. PublicationDate
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = &quot; (&quot; .. PublicationPlace .. PublisherName .. PublicationDate .. &quot;)&quot;
        else
            if (Location ~= nil and Location ~= '') then Publisher= &quot; (&quot; .. Location .. &quot;)&quot;
            else Publisher = &quot;&quot; end
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
            else PublicationDate = &quot;&quot; end
        if ( PublisherName and PublisherName ~=&quot;&quot; ) then
            Publisher = sepc .. &quot; &quot; .. PublicationPlace .. PublisherName .. PublicationDate
        else
            if (Location ~= nil and Location ~= '') then Publisher= sepc .. &quot; &quot; .. Location
            else Publisher = &quot;&quot; end
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot; ) or ( TitleNote and TitleNote ~= &quot;&quot; ) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( ( (config.CitationClass == &quot;journal&quot;) or (config.CitationClass == &quot;citation&quot;) )  and
         Periodical ~= &quot;&quot; ) then
        if (Others ~= &quot;&quot;) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
            Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
            Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
    end
    
    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, 
        PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );

    local text
    local pgtext = Page .. Pages .. At
    if page_error then
        table.insert( z.error_categories, 'Pages with citations using conflicting page specifications' );
        pgtext = pgtext .. hiddencomment('Bad page specification here');
    end
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end -- endif &quot;&quot;~=Date
        if ( config.CitationClass==&quot;journal&quot; and Periodical ) then
          text = safejoin( {Chapter, Place, tcommon}, sepc );
          text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
          text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
          text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if PostScript ~= '' and PostScript ~= nil and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = { 'Pages with empty citations' };
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
        z.message_tail = {};
    end
    
    text = createTag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = createTag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = createTag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        text = text .. hiddencomment( table.concat( z.message_tail, &quot;; &quot; ) );
    end
    
    if no_tracking_cats == '' then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            args[k] = v;
        elseif k == 'postscript' then
            args[k] = v;
        end        
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        if args[k] == nil and (v ~= '' or k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--18Mar2013 Fixed &quot;page=&quot; to override &quot;pages=&quot; as in markup-based cites.
--19Mar2013 Fixed date of class=journal Periodical to show after page.
--19Mar2013 Changed null &quot;postscript=&quot; to suppress end-dot of citation.
--20Mar2013 If CitationClass is journal, show &quot;others=&quot; before title.
--20Mar2013 If CitationClass is book, show &quot;others=&quot; before edition.
--20Mar2013 If CitationClass is journal, adjust &quot;others=&quot; to have sepc.
--20Mar2013 For class &quot;journal&quot;, use book format unless Periodical set.
--
--End</text>
      <sha1>2e41yzuh9gxmd1opo0n7l1vkqvedy1o</sha1>
    </revision>
    <revision>
      <id>4635</id>
      <parentid>4634</parentid>
      <timestamp>2013-04-03T21:56:47Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>sync to sandbox.  Fixes publication-date issues, repeated &quot;.&quot; in wikilink, and format on chapterurl.</comment>
      <origin>4635</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="62182" sha1="78ykrvcsbra8d978u49fy3zbsiz6mzo" xml:space="preserve">local z = {
    error_categories = {};
    message_tail = {};
}

-- Formats a hidden comment for error trapping not intended to be visible to readers
function hiddencomment( content )
    return '&lt;span style=&quot;display: none;&quot; class=&quot;citation-comment&quot;&gt;' .. content .. '&lt;/span&gt;';
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',    
            ['{'] = '&amp;#123;',    
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

-- Create an HTML tag
function createTag(t, frame)
    local name = t.name or &quot;!-- --&quot;
    local content = t.contents or &quot;&quot;
    local attrs = {}
    for n,v in pairs(t.params) do
        if (v) then
            table.insert(attrs, n .. &quot;=\&quot;&quot; .. wikiescape(v) .. &quot;\&quot;&quot;)
        else
            table.insert(attrs, n)
        end
    end
    if (&quot;&quot; == content) then
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;/&gt;&quot;
    else
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    end
end

--[[
This is a clone of mw.text.nowiki.  When the mw.text library is installed,
this can be replaced by a call to that library. 
]]
function nowiki( s )
    -- string.gsub is safe here, because we're only caring about ASCII chars
    s = string.gsub( s, '[&quot;&amp;\'&lt;=&gt;%[%]{|}]', {
        ['&quot;'] = '&amp;#34;',
        ['&amp;'] = '&amp;#38;',
        [&quot;'&quot;] = '&amp;#39;',
        ['&lt;'] = '&amp;#60;',
        ['='] = '&amp;#61;',
        ['&gt;'] = '&amp;#62;',
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['{'] = '&amp;#123;',
        ['|'] = '&amp;#124;',
        ['}'] = '&amp;#125;',
    } )
    s = string.sub( string.gsub( '\n' .. s, '\n[#*:;]', {
        [&quot;\n#&quot;] = &quot;\n&amp;#35;&quot;,
        [&quot;\n*&quot;] = &quot;\n&amp;#42;&quot;,
        [&quot;\n:&quot;] = &quot;\n&amp;#58;&quot;,
        [&quot;\n;&quot;] = &quot;\n&amp;#59;&quot;,
    } ), 2 )
    s = string.gsub( s, '://', '&amp;#58;//' )
    s = string.gsub( s, 'ISBN ', 'ISBN&amp;#32;' )
    s = string.gsub( s, 'RFC ', 'RFC&amp;#32;' )

    return s
end

-- Formats a wiki style external link
function externallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    return &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;
end

-- Formats a wiki style internal link
function internallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    return &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. 
            args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(args.id) .. &quot;]]&quot;
end

-- Formats a link to Amazon
function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid({link=&quot;Amazon Standard Identification Number&quot;,
        label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,
            prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        table.insert( z.error_categories, &quot;Pages with DOI errors&quot; );        
        cat = ' &lt;span class=&quot;error&quot;&gt;Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    return text .. inactive .. cat 
 end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.error_categories, &quot;Pages with citations having wikilinks embedded in URL titles&quot; );
        table.insert( z.message_tail, &quot;Wikilink embedded in URL title&quot; );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    if str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then 
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2) .. value;
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot; .. value;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        str = str .. value:sub(2,-1)
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        str = str .. value:sub(2,-1)
                    else
                        str = str .. value;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        str = str .. value:sub(2,-1)
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        str = str .. value:sub(2,-1)
                    else
                        str = str .. value;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3) .. value;
                    else
                        str = str .. value;
                    end
                else
                    str = str .. value;
                end
            else
                str = str .. value;
            end
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    -- Is the input a simple number?
    local num = tonumber( str ); 
    if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
        return str;
    else
        -- Use formatDate to interpret more complicated formats
        local lang = mw.getContentLanguage();
        local good, result;
        good, result = pcall( lang.formatDate, lang, 'Y', str )
        if good then 
            return result;
        else
            -- Can't make sense of this input, return blank.
            return &quot;&quot;;
        end
    end
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id})
    else
        table.insert( z.error_categories, &quot;Pages with OL errors&quot; );
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id}) .. 
            ' &lt;span class=&quot;error&quot;&gt;Bad OL specified&lt;/span&gt;';
    end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil and first ~= '') then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    if count &gt; 1 and lastauthoramp ~= nil and lastauthoramp ~= &quot;&quot; and not etal then
        text[count-1] = text[count-1] .. &quot; &amp; &quot; .. text[count];
        text[count] = nil;
    end    
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result= createTag({name=&quot;span&quot;, contents=result, 
        params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    
    -- Bugzilla 46608
    local encoded = mw.uri.anchorEncode( P1 .. P2 .. P3 .. P4 .. P5 );
    if encoded == false then
        encoded = &quot;&quot;;
    end
    
    return &quot;CITEREF&quot; .. encoded;
end

-- Gets author list from the input arguments
function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or 
                args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            authors[i] = {
                last = last,
                first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or 
                        args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
                link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or 
                        args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
                mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or 
                        args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

-- Gets editor list from the input arguments
function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or 
                args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            editors[i] = {
                last = last,
                first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
                link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or 
                        args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
                mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or 
                        args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    -- Load Input Parameters

    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;] or args[&quot;authormask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;] or args[&quot;editormask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url or args.URL
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work
            or args.periodical or args.encyclopedia or args.encyclopaedia
            
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = nil          
            TransTitle = nil
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = nil 
                TransTitle = nil
            end
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = nil end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.p or args.page
    local Pages = hyphentodash( args.pp or args.pages )
    local At = args.at
    local page_error = false;
    
    if Page ~= nil and Page ~= '' then
        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 Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace 
            or args.place or args.location
    local Place = args.place or args.location
    if PublicationPlace == Place then Place = nil; end
    
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl or &quot;yes&quot;           -- Only used is ArchiveURL is present.
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript or &quot;.&quot;
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator or &quot;.&quot;
    local LastAuthorAmp = args.lastauthoramp
    local no_tracking_cats = args[&quot;template doc demo&quot;] or args.nocat or 
            args.notracking or args[&quot;no-tracking&quot;] or &quot;&quot;;

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=nil
          end
        end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows 
    -- automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    
    local this_page = mw.title.getCurrentTitle();
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. this_page.prefixedText  -- end COinS data by page's non-encoded pagename

    if (Periodical ~= nil and Periodical ~= &quot;&quot;) and
        (Chapter == nil or Chapter == '') and
        (Title ~= nil and Title ~= &quot;&quot;) then
            Chapter = Title
            ChapterLink = TitleLink
            TransChapter = TransTitle
            Title = nil
            TitleLink = nil
            TransTitle = nil            
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local Maximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors);
        
        -- Preserve old-style implicit et al.
        if Maximum == nil and #a == 9 then 
            Maximum = 8;
            table.insert( z.error_categories, 'Pages using citations with old-style implicit et al.' );
            table.insert( z.message_tail, 'Citation uses old-style implicit et al. for authors' );
        elseif Maximum == nil then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = (args[&quot;author-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = args[&quot;author-format&quot;] or args.authorformat,
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        }
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if Coauthors ~= nil and Coauthors ~= &quot;&quot; then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
                
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local Maximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors);

        -- Preserve old-style implicit et al.
        if Maximum == nil and #e == 4 then 
            Maximum = 3;
            table.insert( z.error_categories, 'Pages using citations with old-style implicit et al.' );
            table.insert( z.message_tail, 'Citation uses old-style implicit et al. for editors' );
        elseif Maximum == nil then
            Maximum = #e + 1;
        end

        local control = { 
            sep = (args[&quot;editor-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = args[&quot;editor-format&quot;] or args.editorformat,
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
            }

        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date
    
    if ( URL == nil or URL == '' ) and
            ( ChapterURL == nil or ChapterURL == '' ) and
            ( ArchiveURL == nil or ArchiveURL == '' ) and                
            ( ConferenceURL == nil or ConferenceURL == '' ) and                
            ( TranscriptURL == nil or TranscriptURL == '' ) then

        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.error_categories, 'Pages using web citations with no URL' );
            table.insert( z.message_tail, 'No URL on cite web' );
        end

        -- Test if accessdate is given without giving a URL
        if ( AccessDate ~= nil and AccessDate ~= '' ) then
            table.insert( z.error_categories, 'Pages using citations with accessdate and no URL' );
            table.insert( z.message_tail, 'Accessdate used without URL' );
            AccessDate = nil;
        end      
    
        -- Test if format is given without giving a URL
        if ( Format ~= nil and Format ~= '' ) then
            table.insert( z.error_categories, 'Pages using citations with format and no URL' );
            Format = Format .. hiddencomment( &quot;File format specified without giving a URL&quot; );
        end        
    end    

    -- Test if citation has no title
    if ( Chapter == nil or Chapter == &quot;&quot; ) and 
            ( Title == nil or Title == &quot;&quot; ) and
            ( Periodical == nil or Periodical == &quot;&quot; ) and
            ( Conference == nil or Conference == &quot;&quot; ) and 
            ( TransTitle == nil or TransTitle == &quot;&quot; ) and
            ( TransChapter == nil or TransChapter == &quot;&quot; ) then
        table.insert( z.error_categories, 'Pages with citations lacking titles' );
        table.insert( z.message_tail, 'Citation has no title' );
    end

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
        end
    end

    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
        
    -- Format chapter / article title
    if ( Chapter ~= nil and Chapter ~= &quot;&quot; ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) and (Title ~= nil and Title ~= &quot;&quot; )
        then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
    else
        Chapter = &quot;&quot;;
    end
    if TransChapter ~= &quot;&quot; and Chapter == &quot;&quot; then
        table.insert( z.error_categories, 'Pages with citations using translated terms without the original' );
        TransChapter = TransChapter .. hiddencomment( &quot;Translated title included without the original&quot; );
    end
    Chapter = Chapter .. TransChapter
    if Chapter ~= &quot;&quot; then
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
                if URL == nil or URL == &quot;&quot; then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    end
    
    -- Format main title.
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
                or config.CitationClass == &quot;news&quot; 
                or config.CitationClass == &quot;pressrelease&quot; ) and 
                Chapter == &quot;&quot; then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
    else
        Title = &quot;&quot;;
    end    
    if TransTitle ~= &quot;&quot; and Title == &quot;&quot; then
        table.insert( z.error_categories, 'Pages with citations using translated terms without the original' );
        TransTitle = TransTitle .. hiddencomment( &quot;Translated title included without the original&quot; );
    end
    Title = Title .. TransTitle
    if Title ~= &quot;&quot; then
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    end

    if ( Place ~= nil and Place ~= &quot;&quot; ) then
        if sepc == '.' then
            Place = &quot; Written at &quot; .. Place .. sepc .. &quot; &quot;;
        else
            Place = &quot; written at &quot; .. Place .. sepc .. &quot; &quot;;
        end            
    else
        Place = &quot;&quot;;
    end
    
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;'
         .. sepc .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. createTag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, 
            params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid({label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,
            prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid({label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,
            prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
        DOI = sepc .. &quot; &quot; .. doi(DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid({label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,
            prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid({label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,
            prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid({label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,
            prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid({label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,
            prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid({label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,
            prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid({label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,
            prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid({label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,
            prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc .. &quot; &quot; .. openlibrary(OL) else OL = &quot;&quot; end    
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid({label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,
            prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;
            ,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,
            prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid({label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,
            prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid({label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,
            prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid({label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,
            prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end

    if ( URL ~= nil and URL ~=&quot;&quot;) then
        URL = &quot; &quot; .. &quot;[&quot; .. URL .. &quot; &quot; .. nowiki(URL) .. &quot;]&quot;;
        table.insert( z.error_categories, &quot;Pages with citations having bare URLs&quot; );
        if config.CitationClass == &quot;web&quot; then
            table.insert( z.error_categories, &quot;Pages using web citations with no title&quot; );
            URL = URL .. &quot; &lt;span class='error'&gt;No &lt;code&gt;title=&lt;/code&gt; specified&lt;/span&gt;&quot;
        else
            URL = URL .. hiddencomment(&quot;Bare URL needs a title&quot;);
        end       
    else
        URL = &quot;&quot;
    end

    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot; &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, &quot; ..
                &quot;you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
            table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
            if OriginalURL == nil or OriginalUrl == '' then
                table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
                Archived = Archived .. &quot; &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;&quot; ..
                    &quot; and &lt;code&gt;deadurl=no&lt;/code&gt;, then you must also specify &lt;code&gt;url=&lt;/code&gt;&lt;/span&gt;&quot;;                               
            end
        else
            if OriginalURL ~= nil and OriginalURL ~= '' then
                Archived = sepc .. arch_text .. &quot; from [&quot; .. OriginalURL .. &quot; the original] on&quot; .. ArchiveDate
            else
                if config.CitationClass ~= 'web' then 
                    Archived = sepc .. arch_text .. &quot; from &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;&quot; ..
                        &quot;, you must also specify &lt;code&gt;url=&lt;/code&gt;&lt;/span&gt; on&quot; .. ArchiveDate
                    table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
                else
                    Archived = sepc .. arch_text .. &quot; from the original on&quot; .. ArchiveDate
                end
            end                
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        if sepc == '.' then
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; Lay summary]&quot; .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; ) then
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            if Publisher ~= '' then
                Publisher = Publisher .. &quot;, published &quot; .. PublicationDate;
            else
                Publisher = PublicationDate;
            end
        end
        if Publisher ~= &quot;&quot; then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
        else 
            PublicationDate = &quot;&quot;
        end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot; ) or ( TitleNote and TitleNote ~= &quot;&quot; ) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( ( (config.CitationClass == &quot;journal&quot;) or (config.CitationClass == &quot;citation&quot;) )  and
         Periodical ~= &quot;&quot; ) then
        if (Others ~= &quot;&quot;) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
            Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
            Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
    end
    
    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, 
        PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );

    local text
    local pgtext = Page .. Pages .. At
    if page_error then
        table.insert( z.error_categories, 'Pages with citations using conflicting page specifications' );
        pgtext = pgtext .. hiddencomment('Bad page specification here');
    end
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end -- endif &quot;&quot;~=Date
        if ( config.CitationClass==&quot;journal&quot; and Periodical ) then
          text = safejoin( {Chapter, Place, tcommon}, sepc );
          text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
          text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
          text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if PostScript ~= '' and PostScript ~= nil and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = { 'Pages with empty citations' };
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
        z.message_tail = {};
    end
    
    text = createTag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = createTag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = createTag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        text = text .. hiddencomment( table.concat( z.message_tail, &quot;; &quot; ) );
    end
    
    if no_tracking_cats == '' then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            args[k] = v;
        elseif k == 'postscript' then
            args[k] = v;
        end        
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        if args[k] == nil and (v ~= '' or k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--18Mar2013 Fixed &quot;page=&quot; to override &quot;pages=&quot; as in markup-based cites.
--19Mar2013 Fixed date of class=journal Periodical to show after page.
--19Mar2013 Changed null &quot;postscript=&quot; to suppress end-dot of citation.
--20Mar2013 If CitationClass is journal, show &quot;others=&quot; before title.
--20Mar2013 If CitationClass is book, show &quot;others=&quot; before edition.
--20Mar2013 If CitationClass is journal, adjust &quot;others=&quot; to have sepc.
--20Mar2013 For class &quot;journal&quot;, use book format unless Periodical set.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; after wikilink &quot;.]]&quot; end dot.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; after external &quot;.]&quot; end dot.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; at italic wikilink &quot;.]]&quot; end.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; at italic external &quot;.]&quot; end.
--
--End</text>
      <sha1>78ykrvcsbra8d978u49fy3zbsiz6mzo</sha1>
    </revision>
    <revision>
      <id>4636</id>
      <parentid>4635</parentid>
      <timestamp>2013-04-04T18:42:58Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>sync to sandbox, fixes problem with broken span in association with double &quot;..&quot;, also publisher layout for pressrelease mode</comment>
      <origin>4636</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="62399" sha1="l4yyle3p36jpjd5bebx2xtlipjcipoa" xml:space="preserve">local z = {
    error_categories = {};
    message_tail = {};
}

-- Formats a hidden comment for error trapping not intended to be visible to readers
function hiddencomment( content )
    return '&lt;span style=&quot;display: none;&quot; class=&quot;citation-comment&quot;&gt;' .. content .. '&lt;/span&gt;';
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',    
            ['{'] = '&amp;#123;',    
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

-- Create an HTML tag
function createTag(t, frame)
    local name = t.name or &quot;!-- --&quot;
    local content = t.contents or &quot;&quot;
    local attrs = {}
    for n,v in pairs(t.params) do
        if (v) then
            table.insert(attrs, n .. &quot;=\&quot;&quot; .. wikiescape(v) .. &quot;\&quot;&quot;)
        else
            table.insert(attrs, n)
        end
    end
    if (&quot;&quot; == content) then
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;/&gt;&quot;
    else
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    end
end

--[[
This is a clone of mw.text.nowiki.  When the mw.text library is installed,
this can be replaced by a call to that library. 
]]
function nowiki( s )
    -- string.gsub is safe here, because we're only caring about ASCII chars
    s = string.gsub( s, '[&quot;&amp;\'&lt;=&gt;%[%]{|}]', {
        ['&quot;'] = '&amp;#34;',
        ['&amp;'] = '&amp;#38;',
        [&quot;'&quot;] = '&amp;#39;',
        ['&lt;'] = '&amp;#60;',
        ['='] = '&amp;#61;',
        ['&gt;'] = '&amp;#62;',
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['{'] = '&amp;#123;',
        ['|'] = '&amp;#124;',
        ['}'] = '&amp;#125;',
    } )
    s = string.sub( string.gsub( '\n' .. s, '\n[#*:;]', {
        [&quot;\n#&quot;] = &quot;\n&amp;#35;&quot;,
        [&quot;\n*&quot;] = &quot;\n&amp;#42;&quot;,
        [&quot;\n:&quot;] = &quot;\n&amp;#58;&quot;,
        [&quot;\n;&quot;] = &quot;\n&amp;#59;&quot;,
    } ), 2 )
    s = string.gsub( s, '://', '&amp;#58;//' )
    s = string.gsub( s, 'ISBN ', 'ISBN&amp;#32;' )
    s = string.gsub( s, 'RFC ', 'RFC&amp;#32;' )

    return s
end

-- Formats a wiki style external link
function externallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    local url_string = args.id
    if args.encode == true or args.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    return &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;
end

-- Formats a wiki style internal link
function internallinkid(args)
    local sep = args.separator or &quot;&amp;nbsp;&quot;
    args.suffix = args.suffix or &quot;&quot;
    return &quot;[[&quot; .. args.link .. &quot;|&quot; .. args.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. 
            args.prefix .. args.id .. args.suffix .. &quot;|&quot; .. nowiki(args.id) .. &quot;]]&quot;
end

-- Formats a link to Amazon
function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid({link=&quot;Amazon Standard Identification Number&quot;,
        label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,
            prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        table.insert( z.error_categories, &quot;Pages with DOI errors&quot; );        
        cat = ' &lt;span class=&quot;error&quot;&gt;Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    return text .. inactive .. cat 
 end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.error_categories, &quot;Pages with citations having wikilinks embedded in URL titles&quot; );
        table.insert( z.message_tail, &quot;Wikilink embedded in URL title&quot; );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    if str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then 
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    -- Is the input a simple number?
    local num = tonumber( str ); 
    if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
        return str;
    else
        -- Use formatDate to interpret more complicated formats
        local lang = mw.getContentLanguage();
        local good, result;
        good, result = pcall( lang.formatDate, lang, 'Y', str )
        if good then 
            return result;
        else
            -- Can't make sense of this input, return blank.
            return &quot;&quot;;
        end
    end
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id})
    else
        table.insert( z.error_categories, &quot;Pages with OL errors&quot; );
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id}) .. 
            ' &lt;span class=&quot;error&quot;&gt;Bad OL specified&lt;/span&gt;';
    end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil and first ~= '') then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    if count &gt; 1 and lastauthoramp ~= nil and lastauthoramp ~= &quot;&quot; and not etal then
        text[count-1] = text[count-1] .. &quot; &amp; &quot; .. text[count];
        text[count] = nil;
    end    
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result= createTag({name=&quot;span&quot;, contents=result, 
        params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid(args)
    local P1 = args[1] or &quot;&quot;
    local P2 = args[2] or &quot;&quot;
    local P3 = args[3] or &quot;&quot;
    local P4 = args[4] or &quot;&quot;
    local P5 = args[5] or &quot;&quot;
    
    -- Bugzilla 46608
    local encoded = mw.uri.anchorEncode( P1 .. P2 .. P3 .. P4 .. P5 );
    if encoded == false then
        encoded = &quot;&quot;;
    end
    
    return &quot;CITEREF&quot; .. encoded;
end

-- Gets author list from the input arguments
function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or 
                args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            authors[i] = {
                last = last,
                first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or 
                        args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
                link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or 
                        args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
                mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or 
                        args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

-- Gets editor list from the input arguments
function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or 
                args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            editors[i] = {
                last = last,
                first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
                link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or 
                        args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
                mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or 
                        args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    -- Load Input Parameters

    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;] or args[&quot;authormask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;] or args[&quot;editormask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url or args.URL
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work
            or args.periodical or args.encyclopedia or args.encyclopaedia
            
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = nil          
            TransTitle = nil
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = nil 
                TransTitle = nil
            end
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = nil end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.p or args.page
    local Pages = hyphentodash( args.pp or args.pages )
    local At = args.at
    local page_error = false;
    
    if Page ~= nil and Page ~= '' then
        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 Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace 
            or args.place or args.location
    local Place = args.place or args.location
    if PublicationPlace == Place then Place = nil; end
    
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl or &quot;yes&quot;           -- Only used is ArchiveURL is present.
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript or &quot;.&quot;
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator or &quot;.&quot;
    local LastAuthorAmp = args.lastauthoramp
    local no_tracking_cats = args[&quot;template doc demo&quot;] or args.nocat or 
            args.notracking or args[&quot;no-tracking&quot;] or &quot;&quot;;

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=nil
          end
        end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows 
    -- automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    
    local this_page = mw.title.getCurrentTitle();
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. this_page.prefixedText  -- end COinS data by page's non-encoded pagename

    if (Periodical ~= nil and Periodical ~= &quot;&quot;) and
        (Chapter == nil or Chapter == '') and
        (Title ~= nil and Title ~= &quot;&quot;) then
            Chapter = Title
            ChapterLink = TitleLink
            TransChapter = TransTitle
            Title = nil
            TitleLink = nil
            TransTitle = nil            
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local Maximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors);
        
        -- Preserve old-style implicit et al.
        if Maximum == nil and #a == 9 then 
            Maximum = 8;
            table.insert( z.error_categories, 'Pages using citations with old-style implicit et al.' );
            table.insert( z.message_tail, 'Citation uses old-style implicit et al. for authors' );
        elseif Maximum == nil then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = (args[&quot;author-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = args[&quot;author-format&quot;] or args.authorformat,
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        }
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if Coauthors ~= nil and Coauthors ~= &quot;&quot; then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
                
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local Maximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors);

        -- Preserve old-style implicit et al.
        if Maximum == nil and #e == 4 then 
            Maximum = 3;
            table.insert( z.error_categories, 'Pages using citations with old-style implicit et al.' );
            table.insert( z.message_tail, 'Citation uses old-style implicit et al. for editors' );
        elseif Maximum == nil then
            Maximum = #e + 1;
        end

        local control = { 
            sep = (args[&quot;editor-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = args[&quot;editor-format&quot;] or args.editorformat,
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
            }

        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date
    
    if ( URL == nil or URL == '' ) and
            ( ChapterURL == nil or ChapterURL == '' ) and
            ( ArchiveURL == nil or ArchiveURL == '' ) and                
            ( ConferenceURL == nil or ConferenceURL == '' ) and                
            ( TranscriptURL == nil or TranscriptURL == '' ) then

        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.error_categories, 'Pages using web citations with no URL' );
            table.insert( z.message_tail, 'No URL on cite web' );
        end

        -- Test if accessdate is given without giving a URL
        if ( AccessDate ~= nil and AccessDate ~= '' ) then
            table.insert( z.error_categories, 'Pages using citations with accessdate and no URL' );
            table.insert( z.message_tail, 'Accessdate used without URL' );
            AccessDate = nil;
        end      
    
        -- Test if format is given without giving a URL
        if ( Format ~= nil and Format ~= '' ) then
            table.insert( z.error_categories, 'Pages using citations with format and no URL' );
            Format = Format .. hiddencomment( &quot;File format specified without giving a URL&quot; );
        end        
    end    

    -- Test if citation has no title
    if ( Chapter == nil or Chapter == &quot;&quot; ) and 
            ( Title == nil or Title == &quot;&quot; ) and
            ( Periodical == nil or Periodical == &quot;&quot; ) and
            ( Conference == nil or Conference == &quot;&quot; ) and 
            ( TransTitle == nil or TransTitle == &quot;&quot; ) and
            ( TransChapter == nil or TransChapter == &quot;&quot; ) then
        table.insert( z.error_categories, 'Pages with citations lacking titles' );
        table.insert( z.message_tail, 'Citation has no title' );
    end

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
        end
    end

    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
        
    -- Format chapter / article title
    if ( Chapter ~= nil and Chapter ~= &quot;&quot; ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) and (Title ~= nil and Title ~= &quot;&quot; )
        then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
    else
        Chapter = &quot;&quot;;
    end
    if TransChapter ~= &quot;&quot; and Chapter == &quot;&quot; then
        table.insert( z.error_categories, 'Pages with citations using translated terms without the original' );
        TransChapter = TransChapter .. hiddencomment( &quot;Translated title included without the original&quot; );
    end
    Chapter = Chapter .. TransChapter
    if Chapter ~= &quot;&quot; then
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
                if URL == nil or URL == &quot;&quot; then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    end
    
    -- Format main title.
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
                or config.CitationClass == &quot;news&quot; 
                or config.CitationClass == &quot;pressrelease&quot; ) and 
                Chapter == &quot;&quot; then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
    else
        Title = &quot;&quot;;
    end    
    if TransTitle ~= &quot;&quot; and Title == &quot;&quot; then
        table.insert( z.error_categories, 'Pages with citations using translated terms without the original' );
        TransTitle = TransTitle .. hiddencomment( &quot;Translated title included without the original&quot; );
    end
    Title = Title .. TransTitle
    if Title ~= &quot;&quot; then
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    end

    if ( Place ~= nil and Place ~= &quot;&quot; ) then
        if sepc == '.' then
            Place = &quot; Written at &quot; .. Place .. sepc .. &quot; &quot;;
        else
            Place = &quot; written at &quot; .. Place .. sepc .. &quot; &quot;;
        end            
    else
        Place = &quot;&quot;;
    end
    
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
             .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. createTag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, 
            params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid({label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,
            prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid({label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,
            prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
        DOI = sepc .. &quot; &quot; .. doi(DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid({label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,
            prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid({label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,
            prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid({label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,
            prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid({label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,
            prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid({label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,
            prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid({label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,
            prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid({label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,
            prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc .. &quot; &quot; .. openlibrary(OL) else OL = &quot;&quot; end    
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid({label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,
            prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;
            ,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,
            prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid({label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,
            prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid({label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,
            prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid({label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,
            prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end

    if ( URL ~= nil and URL ~=&quot;&quot;) then
        URL = &quot; &quot; .. &quot;[&quot; .. URL .. &quot; &quot; .. nowiki(URL) .. &quot;]&quot;;
        table.insert( z.error_categories, &quot;Pages with citations having bare URLs&quot; );
        if config.CitationClass == &quot;web&quot; then
            table.insert( z.error_categories, &quot;Pages using web citations with no title&quot; );
            URL = URL .. &quot; &lt;span class='error'&gt;No &lt;code&gt;title=&lt;/code&gt; specified&lt;/span&gt;&quot;
        else
            URL = URL .. hiddencomment(&quot;Bare URL needs a title&quot;);
        end       
    else
        URL = &quot;&quot;
    end

    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot; &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, &quot; ..
                &quot;you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
            table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
            if OriginalURL == nil or OriginalUrl == '' then
                table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
                Archived = Archived .. &quot; &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;&quot; ..
                    &quot; and &lt;code&gt;deadurl=no&lt;/code&gt;, then you must also specify &lt;code&gt;url=&lt;/code&gt;&lt;/span&gt;&quot;;                               
            end
        else
            if OriginalURL ~= nil and OriginalURL ~= '' then
                Archived = sepc .. arch_text .. &quot; from [&quot; .. OriginalURL .. &quot; the original] on&quot; .. ArchiveDate
            else
                if config.CitationClass ~= 'web' then 
                    Archived = sepc .. arch_text .. &quot; from &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;&quot; ..
                        &quot;, you must also specify &lt;code&gt;url=&lt;/code&gt;&lt;/span&gt; on&quot; .. ArchiveDate
                    table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
                else
                    Archived = sepc .. arch_text .. &quot; from the original on&quot; .. ArchiveDate
                end
            end                
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        if sepc == '.' then
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; Lay summary]&quot; .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; and
         config.CitationClass ~= &quot;pressrelease&quot; ) then
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            if Publisher ~= '' then
                Publisher = Publisher .. &quot;, published &quot; .. PublicationDate;
            else
                Publisher = PublicationDate;
            end
        end
        if Publisher ~= &quot;&quot; then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
        else 
            PublicationDate = &quot;&quot;
        end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot; ) or ( TitleNote and TitleNote ~= &quot;&quot; ) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( ( (config.CitationClass == &quot;journal&quot;) or (config.CitationClass == &quot;citation&quot;) )  and
         Periodical ~= &quot;&quot; ) then
        if (Others ~= &quot;&quot;) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
            Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
            Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
    end
    
    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, 
        PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );

    local text
    local pgtext = Page .. Pages .. At
    if page_error then
        table.insert( z.error_categories, 'Pages with citations using conflicting page specifications' );
        pgtext = pgtext .. hiddencomment('Bad page specification here');
    end
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end -- endif &quot;&quot;~=Date
        if ( config.CitationClass==&quot;journal&quot; and Periodical ) then
          text = safejoin( {Chapter, Place, tcommon}, sepc );
          text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
          text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
          text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if PostScript ~= '' and PostScript ~= nil and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = { 'Pages with empty citations' };
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
        z.message_tail = {};
    end
    
    text = createTag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = createTag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = createTag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        text = text .. hiddencomment( table.concat( z.message_tail, &quot;; &quot; ) );
    end
    
    if no_tracking_cats == '' then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            args[k] = v;
        elseif k == 'postscript' then
            args[k] = v;
        end        
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        if args[k] == nil and (v ~= '' or k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--18Mar2013 Fixed &quot;page=&quot; to override &quot;pages=&quot; as in markup-based cites.
--19Mar2013 Fixed date of class=journal Periodical to show after page.
--19Mar2013 Changed null &quot;postscript=&quot; to suppress end-dot of citation.
--20Mar2013 If CitationClass is journal, show &quot;others=&quot; before title.
--20Mar2013 If CitationClass is book, show &quot;others=&quot; before edition.
--20Mar2013 If CitationClass is journal, adjust &quot;others=&quot; to have sepc.
--20Mar2013 For class &quot;journal&quot;, use book format unless Periodical set.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; after wikilink &quot;.]]&quot; end dot.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; after external &quot;.]&quot; end dot.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; at italic wikilink &quot;.]]&quot; end.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; at italic external &quot;.]&quot; end.
--04Apr2013 Moved sepc before &lt;span class=&quot;reference-accessdate&quot;&gt; for &quot;..&quot;.
--
--End</text>
      <sha1>l4yyle3p36jpjd5bebx2xtlipjcipoa</sha1>
    </revision>
    <revision>
      <id>4637</id>
      <parentid>4636</parentid>
      <timestamp>2013-04-05T03:12:59Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>sync to sandbox, adds parameter whitelist</comment>
      <origin>4637</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="63821" sha1="dtikh48pdsmrr68ve16miun6ptzo22p" xml:space="preserve">local z = {
    error_categories = {};
    message_tail = {};
}

local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );

-- Checks that parameter name is valid
function validate( name )
    name = tostring( name );
    
    -- Normal arguments
    if whitelist.basic_arguments[ name ] then
        return true;
    end
    
    -- Arguments with numbers in them
    name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );
    if whitelist.numbered_arguments[ name ] then
        return true;
    end
    
    -- Not found, argument not supported.
    return false
end

-- Formats a hidden comment for error trapping not intended to be visible to readers
function hiddencomment( content )
    return '&lt;span style=&quot;display: none;&quot; class=&quot;citation-comment&quot;&gt;' .. content .. '&lt;/span&gt;';
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',    
            ['{'] = '&amp;#123;',    
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

-- Create an HTML tag
function createTag(t, frame)
    local name = t.name or &quot;!-- --&quot;
    local content = t.contents or &quot;&quot;
    local attrs = {}
    for n,v in pairs(t.params) do
        if (v) then
            table.insert(attrs, n .. &quot;=\&quot;&quot; .. wikiescape(v) .. &quot;\&quot;&quot;)
        else
            table.insert(attrs, n)
        end
    end
    if (&quot;&quot; == content) then
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;/&gt;&quot;
    else
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    end
end

--[[
This is a clone of mw.text.nowiki.  When the mw.text library is installed,
this can be replaced by a call to that library. 
]]
function nowiki( s )
    -- string.gsub is safe here, because we're only caring about ASCII chars
    s = string.gsub( s, '[&quot;&amp;\'&lt;=&gt;%[%]{|}]', {
        ['&quot;'] = '&amp;#34;',
        ['&amp;'] = '&amp;#38;',
        [&quot;'&quot;] = '&amp;#39;',
        ['&lt;'] = '&amp;#60;',
        ['='] = '&amp;#61;',
        ['&gt;'] = '&amp;#62;',
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['{'] = '&amp;#123;',
        ['|'] = '&amp;#124;',
        ['}'] = '&amp;#125;',
    } )
    s = string.sub( string.gsub( '\n' .. s, '\n[#*:;]', {
        [&quot;\n#&quot;] = &quot;\n&amp;#35;&quot;,
        [&quot;\n*&quot;] = &quot;\n&amp;#42;&quot;,
        [&quot;\n:&quot;] = &quot;\n&amp;#58;&quot;,
        [&quot;\n;&quot;] = &quot;\n&amp;#59;&quot;,
    } ), 2 )
    s = string.gsub( s, '://', '&amp;#58;//' )
    s = string.gsub( s, 'ISBN ', 'ISBN&amp;#32;' )
    s = string.gsub( s, 'RFC ', 'RFC&amp;#32;' )

    return s
end

-- Formats a wiki style external link
function externallinkid(options)
    local sep = options.separator or &quot;&amp;nbsp;&quot;
    options.suffix = options.suffix or &quot;&quot;
    local url_string = options.id
    if options.encode == true or options.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    return &quot;[[&quot; .. options.link .. &quot;|&quot; .. options.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. 
            options.prefix .. url_string .. options.suffix .. &quot; &quot; .. nowiki(options.id) .. &quot;]&quot;
end

-- Formats a wiki style internal link
function internallinkid(options)
    local sep = options.separator or &quot;&amp;nbsp;&quot;
    options.suffix = options.suffix or &quot;&quot;
    return &quot;[[&quot; .. options.link .. &quot;|&quot; .. options.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. 
            options.prefix .. options.id .. options.suffix .. &quot;|&quot; .. nowiki(options.id) .. &quot;]]&quot;
end

-- Formats a link to Amazon
function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid({link=&quot;Amazon Standard Identification Number&quot;,
        label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,
            prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        table.insert( z.error_categories, &quot;Pages with DOI errors&quot; );        
        cat = ' &lt;span class=&quot;error&quot;&gt;Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    return text .. inactive .. cat 
 end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.error_categories, &quot;Pages with citations having wikilinks embedded in URL titles&quot; );
        table.insert( z.message_tail, &quot;Wikilink embedded in URL title&quot; );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    if str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then 
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    -- Is the input a simple number?
    local num = tonumber( str ); 
    if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
        return str;
    else
        -- Use formatDate to interpret more complicated formats
        local lang = mw.getContentLanguage();
        local good, result;
        good, result = pcall( lang.formatDate, lang, 'Y', str )
        if good then 
            return result;
        else
            -- Can't make sense of this input, return blank.
            return &quot;&quot;;
        end
    end
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id})
    else
        table.insert( z.error_categories, &quot;Pages with OL errors&quot; );
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id}) .. 
            ' &lt;span class=&quot;error&quot;&gt;Bad OL specified&lt;/span&gt;';
    end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil and first ~= '') then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    if count &gt; 1 and lastauthoramp ~= nil and lastauthoramp ~= &quot;&quot; and not etal then
        text[count-1] = text[count-1] .. &quot; &amp; &quot; .. text[count];
        text[count] = nil;
    end    
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result= createTag({name=&quot;span&quot;, contents=result, 
        params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid(options)
    local P1 = options[1] or &quot;&quot;
    local P2 = options[2] or &quot;&quot;
    local P3 = options[3] or &quot;&quot;
    local P4 = options[4] or &quot;&quot;
    local P5 = options[5] or &quot;&quot;
    
    -- Bugzilla 46608
    local encoded = mw.uri.anchorEncode( P1 .. P2 .. P3 .. P4 .. P5 );
    if encoded == false then
        encoded = &quot;&quot;;
    end
    
    return &quot;CITEREF&quot; .. encoded;
end

-- Gets author list from the input arguments
function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or 
                args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            authors[i] = {
                last = last,
                first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or 
                        args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
                link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or 
                        args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
                mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or 
                        args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

-- Gets editor list from the input arguments
function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or 
                args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            editors[i] = {
                last = last,
                first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
                link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or 
                        args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
                mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or 
                        args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    -- Load Input Parameters

    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;] or args[&quot;authormask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;] or args[&quot;editormask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url or args.URL
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl or args[&quot;contribution-url&quot;]
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work
            or args.periodical or args.encyclopedia or args.encyclopaedia
            
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = nil          
            TransTitle = nil
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = nil 
                TransTitle = nil
            end
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = nil end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.p or args.page
    local Pages = hyphentodash( args.pp or args.pages )
    local At = args.at
    local page_error = false;
    
    if Page ~= nil and Page ~= '' then
        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 Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace 
            or args.place or args.location
    local Place = args.place or args.location
    if PublicationPlace == Place then Place = nil; end
    
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl or &quot;yes&quot;           -- Only used is ArchiveURL is present.
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript or &quot;.&quot;
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator or &quot;.&quot;
    local LastAuthorAmp = args.lastauthoramp
    local no_tracking_cats = args[&quot;template doc demo&quot;] or args.nocat or 
            args.notracking or args[&quot;no-tracking&quot;] or &quot;&quot;;

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=nil
          end
        end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows 
    -- automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    
    local this_page = mw.title.getCurrentTitle();
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. this_page.prefixedText  -- end COinS data by page's non-encoded pagename

    if (Periodical ~= nil and Periodical ~= &quot;&quot;) and
        (Chapter == nil or Chapter == '') and
        (Title ~= nil and Title ~= &quot;&quot;) then
            Chapter = Title
            ChapterLink = TitleLink
            TransChapter = TransTitle
            Title = nil
            TitleLink = nil
            TransTitle = nil            
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local Maximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors);
        
        -- Preserve old-style implicit et al.
        if Maximum == nil and #a == 9 then 
            Maximum = 8;
            table.insert( z.error_categories, 'Pages using citations with old-style implicit et al.' );
            table.insert( z.message_tail, 'Citation uses old-style implicit et al. for authors' );
        elseif Maximum == nil then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = (args[&quot;author-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = args[&quot;author-format&quot;] or args.authorformat,
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        }
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if Coauthors ~= nil and Coauthors ~= &quot;&quot; then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
                
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local Maximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors);

        -- Preserve old-style implicit et al.
        if Maximum == nil and #e == 4 then 
            Maximum = 3;
            table.insert( z.error_categories, 'Pages using citations with old-style implicit et al.' );
            table.insert( z.message_tail, 'Citation uses old-style implicit et al. for editors' );
        elseif Maximum == nil then
            Maximum = #e + 1;
        end

        local control = { 
            sep = (args[&quot;editor-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = args[&quot;editor-format&quot;] or args.editorformat,
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
            }

        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date
    
    if ( URL == nil or URL == '' ) and
            ( ChapterURL == nil or ChapterURL == '' ) and
            ( ArchiveURL == nil or ArchiveURL == '' ) and                
            ( ConferenceURL == nil or ConferenceURL == '' ) and                
            ( TranscriptURL == nil or TranscriptURL == '' ) then

        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.error_categories, 'Pages using web citations with no URL' );
            table.insert( z.message_tail, 'No URL on cite web' );
        end

        -- Test if accessdate is given without giving a URL
        if ( AccessDate ~= nil and AccessDate ~= '' ) then
            table.insert( z.error_categories, 'Pages using citations with accessdate and no URL' );
            table.insert( z.message_tail, 'Accessdate used without URL' );
            AccessDate = nil;
        end      
    
        -- Test if format is given without giving a URL
        if ( Format ~= nil and Format ~= '' ) then
            table.insert( z.error_categories, 'Pages using citations with format and no URL' );
            Format = Format .. hiddencomment( &quot;File format specified without giving a URL&quot; );
        end        
    end    

    -- Test if citation has no title
    if ( Chapter == nil or Chapter == &quot;&quot; ) and 
            ( Title == nil or Title == &quot;&quot; ) and
            ( Periodical == nil or Periodical == &quot;&quot; ) and
            ( Conference == nil or Conference == &quot;&quot; ) and 
            ( TransTitle == nil or TransTitle == &quot;&quot; ) and
            ( TransChapter == nil or TransChapter == &quot;&quot; ) then
        table.insert( z.error_categories, 'Pages with citations lacking titles' );
        table.insert( z.message_tail, 'Citation has no title' );
    end

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
        end
    end

    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
        
    -- Format chapter / article title
    if ( Chapter ~= nil and Chapter ~= &quot;&quot; ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) and (Title ~= nil and Title ~= &quot;&quot; )
        then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
    else
        Chapter = &quot;&quot;;
    end
    if TransChapter ~= &quot;&quot; and Chapter == &quot;&quot; then
        table.insert( z.error_categories, 'Pages with citations using translated terms without the original' );
        TransChapter = TransChapter .. hiddencomment( &quot;Translated title included without the original&quot; );
    end
    Chapter = Chapter .. TransChapter
    if Chapter ~= &quot;&quot; then
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
                if URL == nil or URL == &quot;&quot; then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    end
    
    -- Format main title.
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
                or config.CitationClass == &quot;news&quot; 
                or config.CitationClass == &quot;pressrelease&quot; ) and 
                Chapter == &quot;&quot; then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
    else
        Title = &quot;&quot;;
    end    
    if TransTitle ~= &quot;&quot; and Title == &quot;&quot; then
        table.insert( z.error_categories, 'Pages with citations using translated terms without the original' );
        TransTitle = TransTitle .. hiddencomment( &quot;Translated title included without the original&quot; );
    end
    Title = Title .. TransTitle
    if Title ~= &quot;&quot; then
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    end

    if ( Place ~= nil and Place ~= &quot;&quot; ) then
        if sepc == '.' then
            Place = &quot; Written at &quot; .. Place .. sepc .. &quot; &quot;;
        else
            Place = &quot; written at &quot; .. Place .. sepc .. &quot; &quot;;
        end            
    else
        Place = &quot;&quot;;
    end
    
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
             .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. createTag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, 
            params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid({label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,
            prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid({label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,
            prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
        DOI = sepc .. &quot; &quot; .. doi(DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid({label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,
            prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid({label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,
            prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid({label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,
            prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid({label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,
            prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid({label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,
            prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid({label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,
            prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid({label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,
            prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc .. &quot; &quot; .. openlibrary(OL) else OL = &quot;&quot; end    
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid({label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,
            prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;
            ,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,
            prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid({label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,
            prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid({label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,
            prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid({label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,
            prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end

    if ( URL ~= nil and URL ~=&quot;&quot;) then
        URL = &quot; &quot; .. &quot;[&quot; .. URL .. &quot; &quot; .. nowiki(URL) .. &quot;]&quot;;
        table.insert( z.error_categories, &quot;Pages with citations having bare URLs&quot; );
        if config.CitationClass == &quot;web&quot; then
            table.insert( z.error_categories, &quot;Pages using web citations with no title&quot; );
            URL = URL .. &quot; &lt;span class='error'&gt;No &lt;code&gt;title=&lt;/code&gt; specified&lt;/span&gt;&quot;
        else
            URL = URL .. hiddencomment(&quot;Bare URL needs a title&quot;);
        end       
    else
        URL = &quot;&quot;
    end

    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot; &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, &quot; ..
                &quot;you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
            table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
            if OriginalURL == nil or OriginalUrl == '' then
                table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
                Archived = Archived .. &quot; &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;&quot; ..
                    &quot; and &lt;code&gt;deadurl=no&lt;/code&gt;, then you must also specify &lt;code&gt;url=&lt;/code&gt;&lt;/span&gt;&quot;;                               
            end
        else
            if OriginalURL ~= nil and OriginalURL ~= '' then
                Archived = sepc .. arch_text .. &quot; from [&quot; .. OriginalURL .. &quot; the original] on&quot; .. ArchiveDate
            else
                if config.CitationClass ~= 'web' then 
                    Archived = sepc .. arch_text .. &quot; from &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;&quot; ..
                        &quot;, you must also specify &lt;code&gt;url=&lt;/code&gt;&lt;/span&gt; on&quot; .. ArchiveDate
                    table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
                else
                    Archived = sepc .. arch_text .. &quot; from the original on&quot; .. ArchiveDate
                end
            end                
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        if sepc == '.' then
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; Lay summary]&quot; .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; and
         config.CitationClass ~= &quot;pressrelease&quot; ) then
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            if Publisher ~= '' then
                Publisher = Publisher .. &quot;, published &quot; .. PublicationDate;
            else
                Publisher = PublicationDate;
            end
        end
        if Publisher ~= &quot;&quot; then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
        else 
            PublicationDate = &quot;&quot;
        end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot; ) or ( TitleNote and TitleNote ~= &quot;&quot; ) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( ( (config.CitationClass == &quot;journal&quot;) or (config.CitationClass == &quot;citation&quot;) )  and
         Periodical ~= &quot;&quot; ) then
        if (Others ~= &quot;&quot;) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
            Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
            Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
    end
    
    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, 
        PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );

    local text
    local pgtext = Page .. Pages .. At
    if page_error then
        table.insert( z.error_categories, 'Pages with citations using conflicting page specifications' );
        pgtext = pgtext .. hiddencomment('Bad page specification here');
    end
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end -- endif &quot;&quot;~=Date
        if ( config.CitationClass==&quot;journal&quot; and Periodical ) then
          text = safejoin( {Chapter, Place, tcommon}, sepc );
          text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
          text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
          text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if PostScript ~= '' and PostScript ~= nil and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = { 'Pages with empty citations' };
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
        z.message_tail = {};
    end
    
    text = createTag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = createTag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = createTag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        text = text .. hiddencomment( table.concat( z.message_tail, &quot;; &quot; ) );
    end
    
    if no_tracking_cats == '' then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            if not validate( k ) then
                if type( k ) ~= 'string' then
                    -- Exclude empty numbered parameters
                    if v:match(&quot;%S+&quot;) ~= nil then
                        table.insert( z.message_tail, 'Unnamed parameter containing &quot;' .. v .. '&quot; ignored' );                        
                    end
                elseif validate( k:lower() ) then 
                    table.insert( z.message_tail, 'Unknown parameter &quot;' .. k .. '=&quot; ignored (suggest &quot;' .. k:lower() .. '=&quot;)' );
                else
                    table.insert( z.message_tail, 'Unknown parameter &quot;' .. k .. '=&quot; ignored' );
                end                    
                table.insert( z.error_categories, 'Pages with citations using unsupported parameters' );
            end            
            args[k] = v;
        elseif k == 'postscript' then
            args[k] = v;
        end        
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        if args[k] == nil and (v ~= '' or k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--18Mar2013 Fixed &quot;page=&quot; to override &quot;pages=&quot; as in markup-based cites.
--19Mar2013 Fixed date of class=journal Periodical to show after page.
--19Mar2013 Changed null &quot;postscript=&quot; to suppress end-dot of citation.
--20Mar2013 If CitationClass is journal, show &quot;others=&quot; before title.
--20Mar2013 If CitationClass is book, show &quot;others=&quot; before edition.
--20Mar2013 If CitationClass is journal, adjust &quot;others=&quot; to have sepc.
--20Mar2013 For class &quot;journal&quot;, use book format unless Periodical set.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; after wikilink &quot;.]]&quot; end dot.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; after external &quot;.]&quot; end dot.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; at italic wikilink &quot;.]]&quot; end.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; at italic external &quot;.]&quot; end.
--04Apr2013 Moved sepc before &lt;span class=&quot;reference-accessdate&quot;&gt; for &quot;..&quot;.
--
--End</text>
      <sha1>dtikh48pdsmrr68ve16miun6ptzo22p</sha1>
    </revision>
    <revision>
      <id>4638</id>
      <parentid>4637</parentid>
      <timestamp>2013-04-05T17:02:57Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>don't categorize empty unnamed parameters</comment>
      <origin>4638</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="64047" sha1="33ihg50j6otmk2pqdi2zbkd3lxezjnn" xml:space="preserve">local z = {
    error_categories = {};
    message_tail = {};
}

local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );

-- Checks that parameter name is valid
function validate( name )
    name = tostring( name );
    
    -- Normal arguments
    if whitelist.basic_arguments[ name ] then
        return true;
    end
    
    -- Arguments with numbers in them
    name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );
    if whitelist.numbered_arguments[ name ] then
        return true;
    end
    
    -- Not found, argument not supported.
    return false
end

-- Formats a hidden comment for error trapping not intended to be visible to readers
function hiddencomment( content )
    return '&lt;span style=&quot;display: none;&quot; class=&quot;citation-comment&quot;&gt;' .. content .. '&lt;/span&gt;';
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',    
            ['{'] = '&amp;#123;',    
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

-- Create an HTML tag
function createTag(t, frame)
    local name = t.name or &quot;!-- --&quot;
    local content = t.contents or &quot;&quot;
    local attrs = {}
    for n,v in pairs(t.params) do
        if (v) then
            table.insert(attrs, n .. &quot;=\&quot;&quot; .. wikiescape(v) .. &quot;\&quot;&quot;)
        else
            table.insert(attrs, n)
        end
    end
    if (&quot;&quot; == content) then
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;/&gt;&quot;
    else
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    end
end

--[[
This is a clone of mw.text.nowiki.  When the mw.text library is installed,
this can be replaced by a call to that library. 
]]
function nowiki( s )
    -- string.gsub is safe here, because we're only caring about ASCII chars
    s = string.gsub( s, '[&quot;&amp;\'&lt;=&gt;%[%]{|}]', {
        ['&quot;'] = '&amp;#34;',
        ['&amp;'] = '&amp;#38;',
        [&quot;'&quot;] = '&amp;#39;',
        ['&lt;'] = '&amp;#60;',
        ['='] = '&amp;#61;',
        ['&gt;'] = '&amp;#62;',
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['{'] = '&amp;#123;',
        ['|'] = '&amp;#124;',
        ['}'] = '&amp;#125;',
    } )
    s = string.sub( string.gsub( '\n' .. s, '\n[#*:;]', {
        [&quot;\n#&quot;] = &quot;\n&amp;#35;&quot;,
        [&quot;\n*&quot;] = &quot;\n&amp;#42;&quot;,
        [&quot;\n:&quot;] = &quot;\n&amp;#58;&quot;,
        [&quot;\n;&quot;] = &quot;\n&amp;#59;&quot;,
    } ), 2 )
    s = string.gsub( s, '://', '&amp;#58;//' )
    s = string.gsub( s, 'ISBN ', 'ISBN&amp;#32;' )
    s = string.gsub( s, 'RFC ', 'RFC&amp;#32;' )

    return s
end

-- Formats a wiki style external link
function externallinkid(options)
    local sep = options.separator or &quot;&amp;nbsp;&quot;
    options.suffix = options.suffix or &quot;&quot;
    local url_string = options.id
    if options.encode == true or options.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    return &quot;[[&quot; .. options.link .. &quot;|&quot; .. options.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. 
            options.prefix .. url_string .. options.suffix .. &quot; &quot; .. nowiki(options.id) .. &quot;]&quot;
end

-- Formats a wiki style internal link
function internallinkid(options)
    local sep = options.separator or &quot;&amp;nbsp;&quot;
    options.suffix = options.suffix or &quot;&quot;
    return &quot;[[&quot; .. options.link .. &quot;|&quot; .. options.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. 
            options.prefix .. options.id .. options.suffix .. &quot;|&quot; .. nowiki(options.id) .. &quot;]]&quot;
end

-- Formats a link to Amazon
function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid({link=&quot;Amazon Standard Identification Number&quot;,
        label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,
            prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        table.insert( z.error_categories, &quot;Pages with DOI errors&quot; );        
        cat = ' &lt;span class=&quot;error&quot;&gt;Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    return text .. inactive .. cat 
 end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.error_categories, &quot;Pages with citations having wikilinks embedded in URL titles&quot; );
        table.insert( z.message_tail, &quot;Wikilink embedded in URL title&quot; );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    if str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then 
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    -- Is the input a simple number?
    local num = tonumber( str ); 
    if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
        return str;
    else
        -- Use formatDate to interpret more complicated formats
        local lang = mw.getContentLanguage();
        local good, result;
        good, result = pcall( lang.formatDate, lang, 'Y', str )
        if good then 
            return result;
        else
            -- Can't make sense of this input, return blank.
            return &quot;&quot;;
        end
    end
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id})
    else
        table.insert( z.error_categories, &quot;Pages with OL errors&quot; );
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id}) .. 
            ' &lt;span class=&quot;error&quot;&gt;Bad OL specified&lt;/span&gt;';
    end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil and first ~= '') then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    if count &gt; 1 and lastauthoramp ~= nil and lastauthoramp ~= &quot;&quot; and not etal then
        text[count-1] = text[count-1] .. &quot; &amp; &quot; .. text[count];
        text[count] = nil;
    end    
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result= createTag({name=&quot;span&quot;, contents=result, 
        params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid(options)
    local P1 = options[1] or &quot;&quot;
    local P2 = options[2] or &quot;&quot;
    local P3 = options[3] or &quot;&quot;
    local P4 = options[4] or &quot;&quot;
    local P5 = options[5] or &quot;&quot;
    
    -- Bugzilla 46608
    local encoded = mw.uri.anchorEncode( P1 .. P2 .. P3 .. P4 .. P5 );
    if encoded == false then
        encoded = &quot;&quot;;
    end
    
    return &quot;CITEREF&quot; .. encoded;
end

-- Gets author list from the input arguments
function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or 
                args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            authors[i] = {
                last = last,
                first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or 
                        args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
                link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or 
                        args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
                mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or 
                        args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

-- Gets editor list from the input arguments
function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or 
                args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            editors[i] = {
                last = last,
                first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
                link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or 
                        args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
                mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or 
                        args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    -- Load Input Parameters

    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;] or args[&quot;authormask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;] or args[&quot;editormask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url or args.URL
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl or args[&quot;contribution-url&quot;]
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work
            or args.periodical or args.encyclopedia or args.encyclopaedia
            
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = nil          
            TransTitle = nil
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = nil 
                TransTitle = nil
            end
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = nil end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.p or args.page
    local Pages = hyphentodash( args.pp or args.pages )
    local At = args.at
    local page_error = false;
    
    if Page ~= nil and Page ~= '' then
        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 Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace 
            or args.place or args.location
    local Place = args.place or args.location
    if PublicationPlace == Place then Place = nil; end
    
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl or &quot;yes&quot;           -- Only used is ArchiveURL is present.
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript or &quot;.&quot;
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator or &quot;.&quot;
    local LastAuthorAmp = args.lastauthoramp
    local no_tracking_cats = args[&quot;template doc demo&quot;] or args.nocat or 
            args.notracking or args[&quot;no-tracking&quot;] or &quot;&quot;;

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=nil
          end
        end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows 
    -- automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
	    if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL
    if ( nil ~= a[1] and nil ~= a[1].last) then
    local last = a[1].last
	local first = a[1].first
	OCinSdata[&quot;rft.aulast&quot;] = last
        if ( nil ~= first ) then 
	    OCinSdata[&quot;rft.aufirst&quot;] = first
	    OCinSdata[&quot;rft.au&quot;] = last .. (args.NameSep or &quot;, &quot;) .. first
	else
	    OCinSdata[&quot;rft.au&quot;] = last
        end
    end
    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    
    local this_page = mw.title.getCurrentTitle();
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. this_page.prefixedText  -- end COinS data by page's non-encoded pagename

    if (Periodical ~= nil and Periodical ~= &quot;&quot;) and
        (Chapter == nil or Chapter == '') and
        (Title ~= nil and Title ~= &quot;&quot;) then
            Chapter = Title
            ChapterLink = TitleLink
            TransChapter = TransTitle
            Title = nil
            TitleLink = nil
            TransTitle = nil            
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local Maximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors);
        
        -- Preserve old-style implicit et al.
        if Maximum == nil and #a == 9 then 
            Maximum = 8;
            table.insert( z.error_categories, 'Pages using citations with old-style implicit et al.' );
            table.insert( z.message_tail, 'Citation uses old-style implicit et al. for authors' );
        elseif Maximum == nil then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = (args[&quot;author-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = args[&quot;author-format&quot;] or args.authorformat,
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        }
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if Coauthors ~= nil and Coauthors ~= &quot;&quot; then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
                
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local Maximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors);

        -- Preserve old-style implicit et al.
        if Maximum == nil and #e == 4 then 
            Maximum = 3;
            table.insert( z.error_categories, 'Pages using citations with old-style implicit et al.' );
            table.insert( z.message_tail, 'Citation uses old-style implicit et al. for editors' );
        elseif Maximum == nil then
            Maximum = #e + 1;
        end

        local control = { 
            sep = (args[&quot;editor-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = args[&quot;editor-format&quot;] or args.editorformat,
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
            }

        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date
    
    if ( URL == nil or URL == '' ) and
            ( ChapterURL == nil or ChapterURL == '' ) and
            ( ArchiveURL == nil or ArchiveURL == '' ) and                
            ( ConferenceURL == nil or ConferenceURL == '' ) and                
            ( TranscriptURL == nil or TranscriptURL == '' ) then

        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.error_categories, 'Pages using web citations with no URL' );
            table.insert( z.message_tail, 'No URL on cite web' );
        end

        -- Test if accessdate is given without giving a URL
        if ( AccessDate ~= nil and AccessDate ~= '' ) then
            table.insert( z.error_categories, 'Pages using citations with accessdate and no URL' );
            table.insert( z.message_tail, 'Accessdate used without URL' );
            AccessDate = nil;
        end      
    
        -- Test if format is given without giving a URL
        if ( Format ~= nil and Format ~= '' ) then
            table.insert( z.error_categories, 'Pages using citations with format and no URL' );
            Format = Format .. hiddencomment( &quot;File format specified without giving a URL&quot; );
        end        
    end    

    -- Test if citation has no title
    if ( Chapter == nil or Chapter == &quot;&quot; ) and 
            ( Title == nil or Title == &quot;&quot; ) and
            ( Periodical == nil or Periodical == &quot;&quot; ) and
            ( Conference == nil or Conference == &quot;&quot; ) and 
            ( TransTitle == nil or TransTitle == &quot;&quot; ) and
            ( TransChapter == nil or TransChapter == &quot;&quot; ) then
        table.insert( z.error_categories, 'Pages with citations lacking titles' );
        table.insert( z.message_tail, 'Citation has no title' );
    end

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
        end
    end

    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
        
    -- Format chapter / article title
    if ( Chapter ~= nil and Chapter ~= &quot;&quot; ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) and (Title ~= nil and Title ~= &quot;&quot; )
        then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
    else
        Chapter = &quot;&quot;;
    end
    if TransChapter ~= &quot;&quot; and Chapter == &quot;&quot; then
        table.insert( z.error_categories, 'Pages with citations using translated terms without the original' );
        TransChapter = TransChapter .. hiddencomment( &quot;Translated title included without the original&quot; );
    end
    Chapter = Chapter .. TransChapter
    if Chapter ~= &quot;&quot; then
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
                if URL == nil or URL == &quot;&quot; then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    end
    
    -- Format main title.
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
                or config.CitationClass == &quot;news&quot; 
                or config.CitationClass == &quot;pressrelease&quot; ) and 
                Chapter == &quot;&quot; then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
    else
        Title = &quot;&quot;;
    end    
    if TransTitle ~= &quot;&quot; and Title == &quot;&quot; then
        table.insert( z.error_categories, 'Pages with citations using translated terms without the original' );
        TransTitle = TransTitle .. hiddencomment( &quot;Translated title included without the original&quot; );
    end
    Title = Title .. TransTitle
    if Title ~= &quot;&quot; then
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    end

    if ( Place ~= nil and Place ~= &quot;&quot; ) then
        if sepc == '.' then
            Place = &quot; Written at &quot; .. Place .. sepc .. &quot; &quot;;
        else
            Place = &quot; written at &quot; .. Place .. sepc .. &quot; &quot;;
        end            
    else
        Place = &quot;&quot;;
    end
    
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
             .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. createTag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, 
            params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid({label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,
            prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid({label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,
            prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
        DOI = sepc .. &quot; &quot; .. doi(DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid({label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,
            prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid({label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,
            prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid({label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,
            prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid({label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,
            prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid({label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,
            prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid({label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,
            prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid({label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,
            prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc .. &quot; &quot; .. openlibrary(OL) else OL = &quot;&quot; end    
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid({label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,
            prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;
            ,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,
            prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid({label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,
            prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid({label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,
            prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid({label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,
            prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end

    if ( URL ~= nil and URL ~=&quot;&quot;) then
        URL = &quot; &quot; .. &quot;[&quot; .. URL .. &quot; &quot; .. nowiki(URL) .. &quot;]&quot;;
        table.insert( z.error_categories, &quot;Pages with citations having bare URLs&quot; );
        if config.CitationClass == &quot;web&quot; then
            table.insert( z.error_categories, &quot;Pages using web citations with no title&quot; );
            URL = URL .. &quot; &lt;span class='error'&gt;No &lt;code&gt;title=&lt;/code&gt; specified&lt;/span&gt;&quot;
        else
            URL = URL .. hiddencomment(&quot;Bare URL needs a title&quot;);
        end       
    else
        URL = &quot;&quot;
    end

    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot; &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, &quot; ..
                &quot;you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
            table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
            if OriginalURL == nil or OriginalUrl == '' then
                table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
                Archived = Archived .. &quot; &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;&quot; ..
                    &quot; and &lt;code&gt;deadurl=no&lt;/code&gt;, then you must also specify &lt;code&gt;url=&lt;/code&gt;&lt;/span&gt;&quot;;                               
            end
        else
            if OriginalURL ~= nil and OriginalURL ~= '' then
                Archived = sepc .. arch_text .. &quot; from [&quot; .. OriginalURL .. &quot; the original] on&quot; .. ArchiveDate
            else
                if config.CitationClass ~= 'web' then 
                    Archived = sepc .. arch_text .. &quot; from &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;&quot; ..
                        &quot;, you must also specify &lt;code&gt;url=&lt;/code&gt;&lt;/span&gt; on&quot; .. ArchiveDate
                    table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
                else
                    Archived = sepc .. arch_text .. &quot; from the original on&quot; .. ArchiveDate
                end
            end                
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        if sepc == '.' then
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; Lay summary]&quot; .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; and
         config.CitationClass ~= &quot;pressrelease&quot; ) then
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            if Publisher ~= '' then
                Publisher = Publisher .. &quot;, published &quot; .. PublicationDate;
            else
                Publisher = PublicationDate;
            end
        end
        if Publisher ~= &quot;&quot; then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
        else 
            PublicationDate = &quot;&quot;
        end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot; ) or ( TitleNote and TitleNote ~= &quot;&quot; ) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( ( (config.CitationClass == &quot;journal&quot;) or (config.CitationClass == &quot;citation&quot;) )  and
         Periodical ~= &quot;&quot; ) then
        if (Others ~= &quot;&quot;) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
            Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
            Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
    end
    
    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, 
        PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );

    local text
    local pgtext = Page .. Pages .. At
    if page_error then
        table.insert( z.error_categories, 'Pages with citations using conflicting page specifications' );
        pgtext = pgtext .. hiddencomment('Bad page specification here');
    end
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end -- endif &quot;&quot;~=Date
        if ( config.CitationClass==&quot;journal&quot; and Periodical ) then
          text = safejoin( {Chapter, Place, tcommon}, sepc );
          text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
          text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
          text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if PostScript ~= '' and PostScript ~= nil and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = { 'Pages with empty citations' };
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
        z.message_tail = {};
    end
    
    text = createTag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = createTag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = createTag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        text = text .. hiddencomment( table.concat( z.message_tail, &quot;; &quot; ) );
    end
    
    if no_tracking_cats == '' then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            if not validate( k ) then
                if type( k ) ~= 'string' then
                    -- Exclude empty numbered parameters
                    if v:match(&quot;%S+&quot;) ~= nil then
                        table.insert( z.message_tail, 'Unnamed parameter containing &quot;' .. v .. '&quot; ignored' );                        
                        table.insert( z.error_categories, 'Pages with citations using unsupported parameters' );
                    end
                elseif validate( k:lower() ) then 
                    table.insert( z.message_tail, 'Unknown parameter &quot;' .. k .. '=&quot; ignored (suggest &quot;' .. k:lower() .. '=&quot;)' );
                    table.insert( z.error_categories, 'Pages with citations using unsupported parameters' );
                else
                    table.insert( z.message_tail, 'Unknown parameter &quot;' .. k .. '=&quot; ignored' );
                    table.insert( z.error_categories, 'Pages with citations using unsupported parameters' );
                end                    
            end            
            args[k] = v;
        elseif k == 'postscript' then
            args[k] = v;
        end        
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        if args[k] == nil and (v ~= '' or k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--18Mar2013 Fixed &quot;page=&quot; to override &quot;pages=&quot; as in markup-based cites.
--19Mar2013 Fixed date of class=journal Periodical to show after page.
--19Mar2013 Changed null &quot;postscript=&quot; to suppress end-dot of citation.
--20Mar2013 If CitationClass is journal, show &quot;others=&quot; before title.
--20Mar2013 If CitationClass is book, show &quot;others=&quot; before edition.
--20Mar2013 If CitationClass is journal, adjust &quot;others=&quot; to have sepc.
--20Mar2013 For class &quot;journal&quot;, use book format unless Periodical set.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; after wikilink &quot;.]]&quot; end dot.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; after external &quot;.]&quot; end dot.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; at italic wikilink &quot;.]]&quot; end.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; at italic external &quot;.]&quot; end.
--04Apr2013 Moved sepc before &lt;span class=&quot;reference-accessdate&quot;&gt; for &quot;..&quot;.
--
--End</text>
      <sha1>33ihg50j6otmk2pqdi2zbkd3lxezjnn</sha1>
    </revision>
    <revision>
      <id>4639</id>
      <parentid>4638</parentid>
      <timestamp>2013-04-05T19:39:46Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>sync to sandbox, fixes COinS author list</comment>
      <origin>4639</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="64431" sha1="mgcocplhjvu6vv8eqc0w2mx5o6b85oi" xml:space="preserve">local z = {
    error_categories = {};
    message_tail = {};
}

local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );

-- Checks that parameter name is valid
function validate( name )
    name = tostring( name );
    
    -- Normal arguments
    if whitelist.basic_arguments[ name ] then
        return true;
    end
    
    -- Arguments with numbers in them
    name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );
    if whitelist.numbered_arguments[ name ] then
        return true;
    end
    
    -- Not found, argument not supported.
    return false
end

-- Formats a hidden comment for error trapping not intended to be visible to readers
function hiddencomment( content )
    return '&lt;span style=&quot;display: none;&quot; class=&quot;citation-comment&quot;&gt;' .. content .. '&lt;/span&gt;';
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',    
            ['{'] = '&amp;#123;',    
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

-- Create an HTML tag
function createTag(t, frame)
    local name = t.name or &quot;!-- --&quot;
    local content = t.contents or &quot;&quot;
    local attrs = {}
    for n,v in pairs(t.params) do
        if (v) then
            table.insert(attrs, n .. &quot;=\&quot;&quot; .. wikiescape(v) .. &quot;\&quot;&quot;)
        else
            table.insert(attrs, n)
        end
    end
    if (&quot;&quot; == content) then
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;/&gt;&quot;
    else
        return &quot;&lt;&quot; .. name .. &quot; &quot; .. table.concat(attrs, &quot; &quot;) .. &quot;&gt;&quot; .. content .. &quot;&lt;/&quot; .. name .. &quot;&gt;&quot;
    end
end

--[[
This is a clone of mw.text.nowiki.  When the mw.text library is installed,
this can be replaced by a call to that library. 
]]
function nowiki( s )
    -- string.gsub is safe here, because we're only caring about ASCII chars
    s = string.gsub( s, '[&quot;&amp;\'&lt;=&gt;%[%]{|}]', {
        ['&quot;'] = '&amp;#34;',
        ['&amp;'] = '&amp;#38;',
        [&quot;'&quot;] = '&amp;#39;',
        ['&lt;'] = '&amp;#60;',
        ['='] = '&amp;#61;',
        ['&gt;'] = '&amp;#62;',
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['{'] = '&amp;#123;',
        ['|'] = '&amp;#124;',
        ['}'] = '&amp;#125;',
    } )
    s = string.sub( string.gsub( '\n' .. s, '\n[#*:;]', {
        [&quot;\n#&quot;] = &quot;\n&amp;#35;&quot;,
        [&quot;\n*&quot;] = &quot;\n&amp;#42;&quot;,
        [&quot;\n:&quot;] = &quot;\n&amp;#58;&quot;,
        [&quot;\n;&quot;] = &quot;\n&amp;#59;&quot;,
    } ), 2 )
    s = string.gsub( s, '://', '&amp;#58;//' )
    s = string.gsub( s, 'ISBN ', 'ISBN&amp;#32;' )
    s = string.gsub( s, 'RFC ', 'RFC&amp;#32;' )

    return s
end

-- Formats a wiki style external link
function externallinkid(options)
    local sep = options.separator or &quot;&amp;nbsp;&quot;
    options.suffix = options.suffix or &quot;&quot;
    local url_string = options.id
    if options.encode == true or options.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    return &quot;[[&quot; .. options.link .. &quot;|&quot; .. options.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. 
            options.prefix .. url_string .. options.suffix .. &quot; &quot; .. nowiki(options.id) .. &quot;]&quot;
end

-- Formats a wiki style internal link
function internallinkid(options)
    local sep = options.separator or &quot;&amp;nbsp;&quot;
    options.suffix = options.suffix or &quot;&quot;
    return &quot;[[&quot; .. options.link .. &quot;|&quot; .. options.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. 
            options.prefix .. options.id .. options.suffix .. &quot;|&quot; .. nowiki(options.id) .. &quot;]]&quot;
end

-- Formats a link to Amazon
function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    return externallinkid({link=&quot;Amazon Standard Identification Number&quot;,
        label=&quot;ASIN&quot;,prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,encode=false})
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[Digital object identifier|doi]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (inactive &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link=&quot;Digital object identifier&quot;,label=&quot;doi&quot;,
            prefix=&quot;http://dx.doi.org/&quot;,id=id,separator=&quot;:&quot;})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then
        table.insert( z.error_categories, &quot;Pages with DOI errors&quot; );        
        cat = ' &lt;span class=&quot;error&quot;&gt;Bad DOI (expected &quot;10.&quot; prefix) in code number&lt;/span&gt;'
    end
    return text .. inactive .. cat 
 end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.error_categories, &quot;Pages with citations having wikilinks embedded in URL titles&quot; );
        table.insert( z.message_tail, &quot;Wikilink embedded in URL title&quot; );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    if str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then 
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    -- Is the input a simple number?
    local num = tonumber( str ); 
    if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
        return str;
    else
        -- Use formatDate to interpret more complicated formats
        local lang = mw.getContentLanguage();
        local good, result;
        good, result = pcall( lang.formatDate, lang, 'Y', str )
        if good then 
            return result;
        else
            -- Can't make sense of this input, return blank.
            return &quot;&quot;;
        end
    end
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id})
    else
        table.insert( z.error_categories, &quot;Pages with OL errors&quot; );
        return externallinkid({link=&quot;Open Library&quot;,label=&quot;OL&quot;,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id}) .. 
            ' &lt;span class=&quot;error&quot;&gt;Bad OL specified&lt;/span&gt;';
    end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil and first ~= '') then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    if count &gt; 1 and lastauthoramp ~= nil and lastauthoramp ~= &quot;&quot; and not etal then
        text[count-1] = text[count-1] .. &quot; &amp; &quot; .. text[count];
        text[count] = nil;
    end    
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = &quot;et al.&quot;
        if (sepc == &quot;.&quot;) then etal_text = &quot;et al&quot; end
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result= createTag({name=&quot;span&quot;, contents=result, 
        params={class=&quot;smallcaps&quot;, style=&quot;font-variant:small-caps;&quot;}}) end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid(options)
    local P1 = options[1] or &quot;&quot;
    local P2 = options[2] or &quot;&quot;
    local P3 = options[3] or &quot;&quot;
    local P4 = options[4] or &quot;&quot;
    local P5 = options[5] or &quot;&quot;
    
    -- Bugzilla 46608
    local encoded = mw.uri.anchorEncode( P1 .. P2 .. P3 .. P4 .. P5 );
    if encoded == false then
        encoded = &quot;&quot;;
    end
    
    return &quot;CITEREF&quot; .. encoded;
end

-- Gets author list from the input arguments
function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;author&quot; .. i .. &quot;-last&quot;] or args[&quot;author-last&quot; .. i] or 
                args[&quot;last&quot; .. i] or args[&quot;surname&quot; .. i] or args[&quot;Author&quot; .. i] or args[&quot;author&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            authors[i] = {
                last = last,
                first = args[&quot;author&quot; .. i .. &quot;-first&quot;] or args[&quot;author-first&quot; .. i] or 
                        args[&quot;first&quot; .. i] or args[&quot;given&quot; .. i],
                link = args[&quot;author&quot; .. i .. &quot;-link&quot;] or args[&quot;author-link&quot; .. i] or 
                        args[&quot;author&quot; .. i .. &quot;link&quot;] or args[&quot;authorlink&quot; .. i],
                mask = args[&quot;author&quot; .. i .. &quot;-mask&quot;] or args[&quot;author-mask&quot; .. i] or 
                        args[&quot;author&quot; .. i .. &quot;mask&quot;] or args[&quot;authormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

-- Gets editor list from the input arguments
function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        last = args[&quot;editor&quot; .. i .. &quot;-last&quot;] or args[&quot;editor-last&quot; .. i] or 
                args[&quot;EditorSurname&quot; .. i] or args[&quot;Editor&quot; .. i] or args[&quot;editor&quot; .. i]
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            editors[i] = {
                last = last,
                first = args[&quot;editor&quot; .. i .. &quot;-first&quot;] or args[&quot;editor-first&quot; .. i] or args[&quot;EditorGiven&quot; .. i],
                link = args[&quot;editor&quot; .. i .. &quot;-link&quot;] or args[&quot;editor-link&quot; .. i] or 
                        args[&quot;editor&quot; .. i .. &quot;link&quot;] or args[&quot;editorlink&quot; .. i],
                mask = args[&quot;editor&quot; .. i .. &quot;-mask&quot;] or args[&quot;editor-mask&quot; .. i] or 
                        args[&quot;editor&quot; .. i .. &quot;mask&quot;] or args[&quot;editormask&quot; .. i]
            }
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    -- Load Input Parameters

    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Transfer unnumbered arguments to numbered arguments if necessary.
    args[&quot;author1&quot;] = args.author1 or args.author or args.authors
    args[&quot;author1-last&quot;] = args[&quot;author1-last&quot;] or args[&quot;author-last&quot;] or args[&quot;last&quot;]
    args[&quot;author1-first&quot;] = args[&quot;author1-first&quot;] or args[&quot;author-first&quot;]
      or args.first or args.first1 or args.given or args.given1
    args[&quot;author1-link&quot;] = args[&quot;author1-link&quot;] or args[&quot;author-link&quot;]
    args[&quot;author1-mask&quot;] = args[&quot;author1-mask&quot;] or args[&quot;author-mask&quot;] or args[&quot;authormask&quot;]
    args[&quot;author1link&quot;] = args[&quot;author1link&quot;] or args[&quot;authorlink&quot;]    
    args[&quot;editor1&quot;] = args[&quot;editor1&quot;] or args[&quot;editor&quot;]
    args[&quot;editor1-last&quot;] = args[&quot;editor1-last&quot;] or args[&quot;editor-last&quot;]
    args[&quot;editor1-first&quot;] = args[&quot;editor1-first&quot;] or args[&quot;editor-first&quot;]
    args[&quot;editor1-link&quot;] = args[&quot;editor1-link&quot;] or args[&quot;editor-link&quot;]
    args[&quot;editor1-mask&quot;] = args[&quot;editor1-mask&quot;] or args[&quot;editor-mask&quot;] or args[&quot;editormask&quot;]
    args[&quot;editor1link&quot;] = args[&quot;editor1link&quot;] or args[&quot;editorlink&quot;]    

    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = args.authors
    local i 
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local EditorMask = args.editormask or args[&quot;editor-mask&quot;]
    local EditorFormat = args[&quot;editor-format&quot;] or args.editorformat
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = args.chapter or args.contribution or args.entry
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url or args.URL
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl or args[&quot;contribution-url&quot;]
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = args.journal or args.newspaper or args.magazine or args.work
            or args.periodical or args.encyclopedia or args.encyclopaedia
            
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = nil          
            TransTitle = nil
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = nil 
                TransTitle = nil
            end
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = nil end
        end
    end
    local Series = args.series or args.version
    local Volume = args.volume
    local Issue = args.issue or args.number
    local Position = nil
    local Page = args.p or args.page
    local Pages = hyphentodash( args.pp or args.pages )
    local At = args.at
    local page_error = false;
    
    if Page ~= nil and Page ~= '' then
        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 Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace 
            or args.place or args.location
    local Place = args.place or args.location
    if PublicationPlace == Place then Place = nil; end
    
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl or &quot;yes&quot;           -- Only used is ArchiveURL is present.
    local Language = args.language or args[&quot;in&quot;]
    local Format = args.format
    local Ref = args.ref or args.Ref
    local ARXIV = args.arxiv or args.ARXIV
    local ASIN = args.asin or args.ASIN 
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]
    local BIBCODE = args.bibcode or args.BIBCODE
    local DOI = args.doi or args.DOI
    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = args.id or args.ID
    local ISBN = args.isbn13 or args.isbn or args.ISBN
    local ISSN = args.issn or args.ISSN
    local JFM = args.jfm or args.JFM
    local JSTOR = args.jstor or args.JSTOR
    local LCCN = args.lccn or args.LCCN
    local MR = args.mr or args.MR
    local OCLC = args.oclc or args.OCLC
    local OL = args.ol or args.OL
    local OSTI = args.osti or args.OSTI
    local PMC = args.pmc or args.PMC
    local PMID = args.pmid or args.PMID
    local RFC = args.rfc or args.RFC
    local SSRN = args.ssrn or args.SSRN
    local ZBL = args.zbl or args.ZBL
    local Quote = args.quote or args.quotation
    local PostScript = args.postscript or &quot;.&quot;
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator or &quot;.&quot;
    local LastAuthorAmp = args.lastauthoramp
    local no_tracking_cats = args[&quot;template doc demo&quot;] or args.nocat or 
            args.notracking or args[&quot;no-tracking&quot;] or &quot;&quot;;

    if ( config.CitationClass == &quot;journal&quot; ) then
        if (URL == nil or URL == &quot;&quot;) then
          if (PMC ~= nil and PMC ~=&quot;&quot;)
            then URL=&quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. PMC
            else URL=nil
          end
        end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, &quot;episode &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, &quot;season &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, &quot;series &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows 
    -- automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
        if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    OCinSdata[&quot;rft.isbn&quot;] = ISBN
    OCinSdata[&quot;rft.issn&quot;] = ISSN
    OCinSdata[&quot;rft.jfm&quot;] = JFM
    OCinSdata[&quot;rft.jstor&quot;] = JSTOR
    OCinSdata[&quot;rft.lccn&quot;] = LCCN
    OCinSdata[&quot;rft.mr&quot;] = MR
    OCinSdata.rft_id = URL or ChapterURL

    local last, first;
    local OCinSauthors = {};
    for k, v in ipairs( a ) do
        last = v.last;
        first = v.first;
        if k == 1 then
            if last ~= nil then
                OCinSdata[&quot;rft.aulast&quot;] = last;
            end
            if first ~= nil then 
                OCinSdata[&quot;rft.aufirst&quot;] = first;
            end
        end
        if last ~= nil and first ~= nil then
            table.insert( OCinSauthors, last .. (args.NameSep or &quot;, &quot;) .. first );
    	elseif last ~= nil then
            table.insert( OCinSauthors, last );
        end
    end

    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    OCinSids[&quot;info:arxiv&quot;] = ARXIV
    OCinSids[&quot;info:asin&quot;] = ASIN
    OCinSids[&quot;info:bibcode&quot;] = BIBCODE
    OCinSids[&quot;info:doi&quot;] = DOI
    OCinSids[&quot;info:oclcnum&quot;] = OCLC
    OCinSids[&quot;info:olnum&quot;] = OL
    OCinSids[&quot;info:osti&quot;] = OSTI
    OCinSids[&quot;info:pmc&quot;] = PMC
    OCinSids[&quot;info:pmid&quot;] = PMID
    OCinSids[&quot;info:rfc&quot;] = RFC
    OCinSids[&quot;info:ssrn&quot;] = SSRN
    OCinSids[&quot;info:zbl&quot;] = ZBL
    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    for _, value in ipairs(OCinSauthors) do
        OCinStitle = OCinStitle .. &quot;&amp;rft.au=&quot; .. mw.uri.encode(value)
    end
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    
    local this_page = mw.title.getCurrentTitle();
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/en.wikipedia.org:&quot;
       .. this_page.prefixedText  -- end COinS data by page's non-encoded pagename

    if (Periodical ~= nil and Periodical ~= &quot;&quot;) and
        (Chapter == nil or Chapter == '') and
        (Title ~= nil and Title ~= &quot;&quot;) then
            Chapter = Title
            ChapterLink = TitleLink
            TransChapter = TransTitle
            Title = nil
            TitleLink = nil
            TransTitle = nil            
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local Maximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors);
        
        -- Preserve old-style implicit et al.
        if Maximum == nil and #a == 9 then 
            Maximum = 8;
            table.insert( z.error_categories, 'Pages using citations with old-style implicit et al.' );
            table.insert( z.message_tail, 'Citation uses old-style implicit et al. for authors' );
        elseif Maximum == nil then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = (args[&quot;author-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = args[&quot;author-format&quot;] or args.authorformat,
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        }
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if Coauthors ~= nil and Coauthors ~= &quot;&quot; then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
                
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local Maximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors);

        -- Preserve old-style implicit et al.
        if Maximum == nil and #e == 4 then 
            Maximum = 3;
            table.insert( z.error_categories, 'Pages using citations with old-style implicit et al.' );
            table.insert( z.message_tail, 'Citation uses old-style implicit et al. for editors' );
        elseif Maximum == nil then
            Maximum = #e + 1;
        end

        local control = { 
            sep = (args[&quot;editor-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = args[&quot;editor-format&quot;] or args.editorformat,
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
            }

        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date
    
    if ( URL == nil or URL == '' ) and
            ( ChapterURL == nil or ChapterURL == '' ) and
            ( ArchiveURL == nil or ArchiveURL == '' ) and                
            ( ConferenceURL == nil or ConferenceURL == '' ) and                
            ( TranscriptURL == nil or TranscriptURL == '' ) then

        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.error_categories, 'Pages using web citations with no URL' );
            table.insert( z.message_tail, 'No URL on cite web' );
        end

        -- Test if accessdate is given without giving a URL
        if ( AccessDate ~= nil and AccessDate ~= '' ) then
            table.insert( z.error_categories, 'Pages using citations with accessdate and no URL' );
            table.insert( z.message_tail, 'Accessdate used without URL' );
            AccessDate = nil;
        end      
    
        -- Test if format is given without giving a URL
        if ( Format ~= nil and Format ~= '' ) then
            table.insert( z.error_categories, 'Pages using citations with format and no URL' );
            Format = Format .. hiddencomment( &quot;File format specified without giving a URL&quot; );
        end        
    end    

    -- Test if citation has no title
    if ( Chapter == nil or Chapter == &quot;&quot; ) and 
            ( Title == nil or Title == &quot;&quot; ) and
            ( Periodical == nil or Periodical == &quot;&quot; ) and
            ( Conference == nil or Conference == &quot;&quot; ) and 
            ( TransTitle == nil or TransTitle == &quot;&quot; ) and
            ( TransChapter == nil or TransChapter == &quot;&quot; ) then
        table.insert( z.error_categories, 'Pages with citations lacking titles' );
        table.insert( z.message_tail, 'Citation has no title' );
    end

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
        end
    end

    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
        
    -- Format chapter / article title
    if ( Chapter ~= nil and Chapter ~= &quot;&quot; ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) and (Title ~= nil and Title ~= &quot;&quot; )
        then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
    else
        Chapter = &quot;&quot;;
    end
    if TransChapter ~= &quot;&quot; and Chapter == &quot;&quot; then
        table.insert( z.error_categories, 'Pages with citations using translated terms without the original' );
        TransChapter = TransChapter .. hiddencomment( &quot;Translated title included without the original&quot; );
    end
    Chapter = Chapter .. TransChapter
    if Chapter ~= &quot;&quot; then
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
                if URL == nil or URL == &quot;&quot; then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    end
    
    -- Format main title.
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
                or config.CitationClass == &quot;news&quot; 
                or config.CitationClass == &quot;pressrelease&quot; ) and 
                Chapter == &quot;&quot; then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
    else
        Title = &quot;&quot;;
    end    
    if TransTitle ~= &quot;&quot; and Title == &quot;&quot; then
        table.insert( z.error_categories, 'Pages with citations using translated terms without the original' );
        TransTitle = TransTitle .. hiddencomment( &quot;Translated title included without the original&quot; );
    end
    Title = Title .. TransTitle
    if Title ~= &quot;&quot; then
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    end

    if ( Place ~= nil and Place ~= &quot;&quot; ) then
        if sepc == '.' then
            Place = &quot; Written at &quot; .. Place .. sepc .. &quot; &quot;;
        else
            Place = &quot; written at &quot; .. Place .. sepc .. &quot; &quot;;
        end            
    else
        Place = &quot;&quot;;
    end
    
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    else 
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; minutes in&quot;
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption or &quot;Event occurs at&quot;
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (in &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; ed.)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; via &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; retrieved &quot;
         if (sepc == &quot;.&quot;) then retrv_text = &quot; Retrieved &quot; end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
             .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. createTag({name=&quot;span&quot;, contents=&quot;(subscription required)&quot;, 
            params={style=&quot;font-size:0.95em; font-size: 90%; color: #555&quot;}})
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ARXIV ~= nil and ARXIV ~= &quot;&quot; ) then
        ARXIV = sepc .. &quot; &quot; .. externallinkid({label=&quot;arXiv&quot;,link=&quot;arXiv&quot;,
            prefix=&quot;http://arxiv.org/abs/&quot;,id=ARXIV,separator=&quot;:&quot;,encode=false}) else ARXIV = &quot;&quot; end
    if ( ASIN ~= nil and ASIN ~= &quot;&quot; ) then 
        ASIN = sepc .. &quot; &quot; .. amazon(ASIN, ASINTLD) else ASIN = &quot;&quot; end
    if ( BIBCODE ~= nil and BIBCODE ~= &quot;&quot; ) then
        BIBCODE = sepc .. &quot; &quot; .. externallinkid({label=&quot;Bibcode&quot;,link=&quot;Bibcode&quot;,
            prefix=&quot;http://adsabs.harvard.edu/abs/&quot;,id=BIBCODE,separator=&quot;:&quot;}) else BIBCODE = &quot;&quot; end
    if ( DOI ~= nil and DOI ~= &quot;&quot; ) then
        DOI = sepc .. &quot; &quot; .. doi(DOI, DoiBroken) else DOI = &quot;&quot; end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end
    if ( ISBN ~= nil and ISBN ~= &quot;&quot;) then
        ISBN = sepc .. &quot; &quot; .. internallinkid({label=&quot;ISBN&quot;,link=&quot;International Standard Book Number&quot;,
            prefix=&quot;Special:BookSources/&quot;,id=ISBN}) else ISBN = &quot;&quot; end
    if ( ISSN ~= nil and ISSN ~=&quot;&quot; ) then
        ISSN = sepc .. &quot; &quot; .. externallinkid({label=&quot;ISSN&quot;,link=&quot;International Standard Serial Number&quot;,
            prefix=&quot;//www.worldcat.org/issn/&quot;,id=ISSN,encode=false}) else ISSN = &quot;&quot; end
    if ( JFM ~= nil and JFM ~=&quot;&quot; ) then
        JFM = sepc ..&quot; &quot; .. externallinkid({label=&quot;JFM&quot;,link=&quot;Jahrbuch über die Fortschritte der Mathematik&quot;,
            prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=JFM}) else JFM = &quot;&quot; end
    if ( JSTOR ~= nil and JSTOR ~=&quot;&quot;) then
        JSTOR = sepc ..&quot; &quot; .. externallinkid({label=&quot;JSTOR&quot;,link=&quot;JSTOR&quot;,
            prefix=&quot;http://www.jstor.org/stable/&quot;,id=JSTOR}) else JSTOR = &quot;&quot; end
    if ( LCCN ~= nil and LCCN ~=&quot;&quot; ) then
        LCCN = sepc ..&quot; &quot; .. externallinkid({label=&quot;LCCN&quot;,link=&quot;Library of Congress Control Number&quot;,
            prefix=&quot;http://lccn.loc.gov/&quot;,id=LCCN,encode=false}) else LCCN = &quot;&quot; end
    if ( MR ~= nil and MR ~=&quot;&quot; ) then
        MR = sepc ..&quot; &quot; .. externallinkid({label=&quot;MR&quot;,link=&quot;Mathematical Reviews&quot;,
            prefix=&quot;http://www.ams.org/mathscinet-getitem?mr=&quot;,id=MR}) else MR = &quot;&quot; end
    if ( OCLC ~= nil and OCLC ~=&quot;&quot;) then 
        OCLC = sepc ..&quot; &quot; .. externallinkid({label=&quot;OCLC&quot;,link=&quot;OCLC&quot;,
            prefix=&quot;//www.worldcat.org/oclc/&quot;,id=OCLC}) else OCLC = &quot;&quot; end
    if ( OL ~= nil and OL ~=&quot;&quot;) then
        OL = sepc .. &quot; &quot; .. openlibrary(OL) else OL = &quot;&quot; end    
    if ( OSTI ~= nil and OSTI ~=&quot;&quot;) then
        OSTI = sepc ..&quot; &quot; .. externallinkid({label=&quot;OSTI&quot;,link=&quot;Office of Scientific and Technical Information&quot;,
            prefix=&quot;http://www.osti.gov/energycitations/product.biblio.jsp?osti_id=&quot;,id=OSTI}) else OSTI = &quot;&quot; end
    if ( PMC ~= nil and PMC ~=&quot;&quot;) then
        PMC = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMC&quot;,link=&quot;PubMed Central&quot;
            ,prefix=&quot;//www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot;,suffix=&quot; &quot;,id=PMC}) else PMC = &quot;&quot; end
    if ( PMID ~= nil and PMID ~=&quot;&quot;) then
        PMID = sepc ..&quot; &quot; .. externallinkid({label=&quot;PMID&quot;,link=&quot;PubMed Identifier&quot;,
            prefix=&quot;//www.ncbi.nlm.nih.gov/pubmed/&quot;,id=PMID,encode=false}) else PMID = &quot;&quot; end
    if ( RFC ~= nil and RFC ~=&quot;&quot;) then
        RFC = sepc ..&quot; &quot; .. externallinkid({label=&quot;RFC&quot;,link=&quot;Request for Comments&quot;,
            prefix=&quot;//tools.ietf.org/html/rfc&quot;,id=RFC,encode=false}) else RFC = &quot;&quot; end
    if ( SSRN ~= nil and SSRN ~=&quot;&quot;) then
        SSRN = sepc ..&quot; &quot; .. externallinkid({label=&quot;SSRN&quot;,link=&quot;Social Science Research Network&quot;,
            prefix=&quot;http://ssrn.com/abstract=&quot;,id=SSRN}) else SSRN = &quot;&quot; end
    if ( ZBL ~= nil and ZBL ~=&quot;&quot;) then
        ZBL = sepc ..&quot; &quot; .. externallinkid({label=&quot;Zbl&quot;,link=&quot;Zentralblatt MATH&quot;,
            prefix=&quot;http://www.zentralblatt-math.org/zmath/en/search/?format=complete&amp;q=an:&quot;,id=ZBL}) else ZBL = &quot;&quot; end

    if ( URL ~= nil and URL ~=&quot;&quot;) then
        URL = &quot; &quot; .. &quot;[&quot; .. URL .. &quot; &quot; .. nowiki(URL) .. &quot;]&quot;;
        table.insert( z.error_categories, &quot;Pages with citations having bare URLs&quot; );
        if config.CitationClass == &quot;web&quot; then
            table.insert( z.error_categories, &quot;Pages using web citations with no title&quot; );
            URL = URL .. &quot; &lt;span class='error'&gt;No &lt;code&gt;title=&lt;/code&gt; specified&lt;/span&gt;&quot;
        else
            URL = URL .. hiddencomment(&quot;Bare URL needs a title&quot;);
        end       
    else
        URL = &quot;&quot;
    end

    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot; &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;, &quot; ..
                &quot;you must also specify &lt;code&gt;archivedate=&lt;/code&gt;&lt;/span&gt; &quot;
            table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
        end
        local arch_text = &quot; archived&quot;
        if (sepc == &quot;.&quot;) then arch_text = &quot; Archived&quot; end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] from the original on&quot; .. ArchiveDate
            if OriginalURL == nil or OriginalUrl == '' then
                table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
                Archived = Archived .. &quot; &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;&quot; ..
                    &quot; and &lt;code&gt;deadurl=no&lt;/code&gt;, then you must also specify &lt;code&gt;url=&lt;/code&gt;&lt;/span&gt;&quot;;                               
            end
        else
            if OriginalURL ~= nil and OriginalURL ~= '' then
                Archived = sepc .. arch_text .. &quot; from [&quot; .. OriginalURL .. &quot; the original] on&quot; .. ArchiveDate
            else
                if config.CitationClass ~= 'web' then 
                    Archived = sepc .. arch_text .. &quot; from &lt;span class='error'&gt;If you specify &lt;code&gt;archiveurl=&lt;/code&gt;&quot; ..
                        &quot;, you must also specify &lt;code&gt;url=&lt;/code&gt;&lt;/span&gt; on&quot; .. ArchiveDate
                    table.insert( z.error_categories, 'Pages with archiveurl citation errors' );
                else
                    Archived = sepc .. arch_text .. &quot; from the original on&quot; .. ArchiveDate
                end
            end                
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        if sepc == '.' then
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; Lay summary]&quot; .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; lay summary]&quot; .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; and
         config.CitationClass ~= &quot;pressrelease&quot; ) then
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            if Publisher ~= '' then
                Publisher = Publisher .. &quot;, published &quot; .. PublicationDate;
            else
                Publisher = PublicationDate;
            end
        end
        if Publisher ~= &quot;&quot; then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (published &quot; .. PublicationDate .. &quot;)&quot;
        else 
            PublicationDate = &quot;&quot;
        end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot; ) or ( TitleNote and TitleNote ~= &quot;&quot; ) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( ( (config.CitationClass == &quot;journal&quot;) or (config.CitationClass == &quot;citation&quot;) )  and
         Periodical ~= &quot;&quot; ) then
        if (Others ~= &quot;&quot;) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
            Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
            Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
    end
    
    local idcommon = safejoin( { ARXIV, ASIN, BIBCODE, DOI, ISBN, ISSN, JFM, JSTOR, LCCN, MR, OCLC, OL, OSTI, 
        PMC, PMID, RFC, SSRN, URL, ZBL, ID, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );

    local text
    local pgtext = Page .. Pages .. At
    if page_error then
        table.insert( z.error_categories, 'Pages with citations using conflicting page specifications' );
        pgtext = pgtext .. hiddencomment('Bad page specification here');
    end
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, ed.&quot;
            else
                Editors = Editors .. &quot;, eds.&quot;
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (ed.)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (eds.)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end -- endif &quot;&quot;~=Date
        if ( config.CitationClass==&quot;journal&quot; and Periodical ) then
          text = safejoin( {Chapter, Place, tcommon}, sepc );
          text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
          text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
          text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if PostScript ~= '' and PostScript ~= nil and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local args = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        args.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = { 'Pages with empty citations' };
        text = '&lt;span class=&quot;error&quot;&gt;Citation is empty&lt;/span&gt;';
        z.message_tail = {};
    end
    
    text = createTag({name=&quot;span&quot;, contents=text, params=args})

    local empty_span = createTag( {name=&quot;span&quot;, contents=&quot;&amp;nbsp;&quot;, params={style=&quot;display: none;&quot;}} );
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = createTag({name=&quot;span&quot;, contents=empty_span, params={class=&quot;Z3988&quot;,title=OCinStitle }}) 
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        text = text .. hiddencomment( table.concat( z.message_tail, &quot;; &quot; ) );
    end
    
    if no_tracking_cats == '' then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            if not validate( k ) then
                if type( k ) ~= 'string' then
                    -- Exclude empty numbered parameters
                    if v:match(&quot;%S+&quot;) ~= nil then
                        table.insert( z.message_tail, 'Unnamed parameter containing &quot;' .. v .. '&quot; ignored' );                        
                        table.insert( z.error_categories, 'Pages with citations using unsupported parameters' );
                    end
                elseif validate( k:lower() ) then 
                    table.insert( z.message_tail, 'Unknown parameter &quot;' .. k .. '=&quot; ignored (suggest &quot;' .. k:lower() .. '=&quot;)' );
                    table.insert( z.error_categories, 'Pages with citations using unsupported parameters' );
                else
                    table.insert( z.message_tail, 'Unknown parameter &quot;' .. k .. '=&quot; ignored' );
                    table.insert( z.error_categories, 'Pages with citations using unsupported parameters' );
                end                    
            end            
            args[k] = v;
        elseif k == 'postscript' then
            args[k] = v;
        end        
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        if args[k] == nil and (v ~= '' or k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--18Mar2013 Fixed &quot;page=&quot; to override &quot;pages=&quot; as in markup-based cites.
--19Mar2013 Fixed date of class=journal Periodical to show after page.
--19Mar2013 Changed null &quot;postscript=&quot; to suppress end-dot of citation.
--20Mar2013 If CitationClass is journal, show &quot;others=&quot; before title.
--20Mar2013 If CitationClass is book, show &quot;others=&quot; before edition.
--20Mar2013 If CitationClass is journal, adjust &quot;others=&quot; to have sepc.
--20Mar2013 For class &quot;journal&quot;, use book format unless Periodical set.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; after wikilink &quot;.]]&quot; end dot.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; after external &quot;.]&quot; end dot.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; at italic wikilink &quot;.]]&quot; end.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; at italic external &quot;.]&quot; end.
--04Apr2013 Moved sepc before &lt;span class=&quot;reference-accessdate&quot;&gt; for &quot;..&quot;.
--
--End</text>
      <sha1>mgcocplhjvu6vv8eqc0w2mx5o6b85oi</sha1>
    </revision>
    <revision>
      <id>4640</id>
      <parentid>4639</parentid>
      <timestamp>2013-04-09T20:51:14Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>sync to sandbox, very large update addressing configuration, error handling, id handling, and others</comment>
      <origin>4640</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="67216" sha1="gubfdhme7f5plrmrc9ss6ai2iw2q7t9" xml:space="preserve">local z = {
    error_categories = {};
    message_tail = {};
}

-- Include translation message hooks, ID and error handling configuration settings.
local cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );
 
-- Contains a list of all recognized parameters
local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );

-- Checks that parameter name is valid
function validate( name )
    name = tostring( name );
    
    -- Normal arguments
    if whitelist.basic_arguments[ name ] then
        return true;
    end
    
    -- Arguments with numbers in them
    name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );
    if whitelist.numbered_arguments[ name ] then
        return true;
    end
    
    -- Not found, argument not supported.
    return false
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
    if hidden then 
        return '&lt;span style=&quot;display:none;font-size:100%&quot; class=&quot;error citation-comment&quot;&gt;' .. content .. '&lt;/span&gt;';
    else
        return '&lt;span style=&quot;font-size:100%&quot; class=&quot;error&quot;&gt;' .. content .. '&lt;/span&gt;';
    end        
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, args, raw )
    local error_state = cfg.error_conditions[ error_id ];

    if error_state == nil then
        error( cfg.message_list['undefined_error'] );
    end
    
    if error_state.category ~= nil and error_state.category ~= &quot;&quot; then
        table.insert( z.error_categories, error_state.category );
    end
    
    local message = error_state.message;
    if args ~= nil then
        for k, m in ipairs( args ) do
            message = message:gsub( &quot;$&quot; .. k .. &quot;(%D)&quot;, m .. &quot;%1&quot; );
        end
    end

    message = wikiescape(message) .. &quot; ([[&quot; .. cfg.message_list['help page link'] .. 
        &quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
        cfg.message_list['help page label'] .. &quot;]])&quot;;

    if raw == true then
        return message, error_state.hidden;
    end
        
    return errorcomment( message, error_state.hidden );
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',    
            ['{'] = '&amp;#123;',    
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

-- Formats a wiki style external link
function externallinkid(options)
    local sep = options.separator or &quot;&amp;nbsp;&quot;
    options.suffix = options.suffix or &quot;&quot;
    local url_string = options.id
    if options.encode == true or options.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    return &quot;[[&quot; .. options.link .. &quot;|&quot; .. options.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. 
            options.prefix .. url_string .. options.suffix .. &quot; &quot; .. mw.text.nowiki(options.id) .. &quot;]&quot;
end

-- Formats a wiki style internal link
function internallinkid(options)
    local sep = options.separator or &quot;&amp;nbsp;&quot;
    options.suffix = options.suffix or &quot;&quot;
    return &quot;[[&quot; .. options.link .. &quot;|&quot; .. options.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. 
            options.prefix .. options.id .. options.suffix .. &quot;|&quot; .. mw.text.nowiki(options.id) .. &quot;]]&quot;
end

-- Formats a link to Amazon
function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local handler = cfg.id_handlers['ASIN'];
    return externallinkid({link = handler.link,
        label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
        encode=handler.encode, separator = handler.separator})
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    local handler = cfg.id_handlers['DOI'];
    
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (&quot; .. cfg.message_list['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link = handler.link, label = handler.label,
            prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then      
        cat = seterror( 'bad_doi' );
    end
    return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    local handler = cfg.id_handlers['OL'];
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    else
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode}) .. 
            ' ' .. seterror( 'bad_ol' );
    end
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
    isbn_str = isbn_str:gsub(&quot;[- ]&quot;, &quot;&quot;):upper();
    local len = isbn_str:len();
 
    if len ~= 10 and len ~= 13 then
        return false;
    end
 
    local temp = 0;
    if len == 10 then
        if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            if v == string.byte( &quot;X&quot; ) then
                temp = temp + 10*( 11 - i );
            else
                temp = temp + tonumber( string.char(v) )*(11-i);
            end
        end
        return temp % 11 == 0;
    else
        if isbn_str:match( &quot;^%d*$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
        end
        return temp % 10 == 0;
    end
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    if str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then 
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    -- Is the input a simple number?
    local num = tonumber( str ); 
    if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
        return str;
    else
        -- Use formatDate to interpret more complicated formats
        local lang = mw.getContentLanguage();
        local good, result;
        good, result = pcall( lang.formatDate, lang, 'Y', str )
        if good then 
            return result;
        else
            -- Can't make sense of this input, return blank.
            return &quot;&quot;;
        end
    end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil and first ~= '') then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    if count &gt; 1 and lastauthoramp ~= nil and lastauthoramp ~= &quot;&quot; and not etal then
        text[count-1] = text[count-1] .. &quot; &amp; &quot; .. text[count];
        text[count] = nil;
    end    
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = cfg.message_list['et al'];
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result = 
        '&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
    end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid(options)
    local P1 = options[1] or &quot;&quot;
    local P2 = options[2] or &quot;&quot;
    local P3 = options[3] or &quot;&quot;
    local P4 = options[4] or &quot;&quot;
    local P5 = options[5] or &quot;&quot;
    
    -- Bugzilla 46608
    local encoded = mw.uri.anchorEncode( P1 .. P2 .. P3 .. P4 .. P5 );
    if encoded == false then
        encoded = &quot;&quot;;
    end
    
    return &quot;CITEREF&quot; .. encoded;
end

-- Gets author list from the input arguments
function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    while true do
        if i == 1 then 
            last = selectone( args, {&quot;author&quot; .. i .. &quot;-last&quot;, &quot;author-last&quot; .. i, 
                &quot;last&quot; .. i, &quot;surname&quot; .. i, &quot;Author&quot; .. i, &quot;author&quot; .. i, 
                &quot;author-last&quot;, &quot;last&quot;, &quot;surname&quot;, &quot;Author&quot;, &quot;author&quot;, &quot;authors&quot;}, 'redundant_parameters' );
        else
            last = selectone( args, {&quot;author&quot; .. i .. &quot;-last&quot;, &quot;author-last&quot; .. i, 
                &quot;last&quot; .. i, &quot;surname&quot; .. i, &quot;Author&quot; .. i, &quot;author&quot; .. i}, 'redundant_parameters' );
        end
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            if i == 1 then 
                authors[i] = {
                    last = last,
                    first = selectone( args, {&quot;author&quot; .. i .. &quot;-first&quot;, &quot;author-first&quot; .. i, 
                        &quot;first&quot; .. i, &quot;given&quot; .. i, &quot;author-first&quot;, 
                        &quot;first&quot;, &quot;given&quot;}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;author&quot; .. i .. &quot;-link&quot;, &quot;author-link&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;link&quot;, &quot;authorlink&quot; .. i, &quot;author-link&quot;,  
                        &quot;authorlink&quot;}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;author&quot; .. i .. &quot;-mask&quot;, &quot;author-mask&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;mask&quot;, &quot;authormask&quot; .. i, &quot;author-mask&quot;, 
                        &quot;authormask&quot; }, 'redundant_parameters' )
                }
            else
                authors[i] = {
                    last = last,
                    first = selectone( args, {&quot;author&quot; .. i .. &quot;-first&quot;, &quot;author-first&quot; .. i, 
                        &quot;first&quot; .. i, &quot;given&quot; .. i}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;author&quot; .. i .. &quot;-link&quot;, &quot;author-link&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;link&quot;, &quot;authorlink&quot; .. i}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;author&quot; .. i .. &quot;-mask&quot;, &quot;author-mask&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;mask&quot;, &quot;authormask&quot; .. i}, 'redundant_parameters' )
                }
            end            
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

-- Gets editor list from the input arguments
function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        if i == 1 then
            last = selectone( args, {&quot;editor&quot; .. i .. &quot;-last&quot;, &quot;editor-last&quot; .. i,
                &quot;EditorSurname&quot; .. i, &quot;Editor&quot; .. i, &quot;editor&quot; .. i, &quot;editor-last&quot;, 
                &quot;EditorSurname&quot;, &quot;Editor&quot;, &quot;editor&quot;, &quot;editors&quot;}, 'redundant_parameters' );
        else
            last = selectone( args, {&quot;editor&quot; .. i .. &quot;-last&quot;, &quot;editor-last&quot; .. i,
                &quot;EditorSurname&quot; .. i, &quot;Editor&quot; .. i, &quot;editor&quot; .. i}, 'redundant_parameters' );
        end        
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            if i == 1 then
                editors[i] = {
                    last = last,
                    first = selectone( args, {&quot;editor&quot; .. i .. &quot;-first&quot;, 
                        &quot;editor-first&quot; .. i, &quot;EditorGiven&quot; .. i, &quot;editor-first&quot;, 
                        &quot;EditorGiven&quot;}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;editor&quot; .. i .. &quot;-link&quot;, &quot;editor-link&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;link&quot;, &quot;editorlink&quot; .. i, &quot;editor-link&quot;, 
                        &quot;editorlink&quot;}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;editor&quot; .. i .. &quot;-mask&quot;, &quot;editor-mask&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;mask&quot;, &quot;editormask&quot; .. i, &quot;editor-mask&quot;,  
                        &quot;editormask&quot;}, 'redundant_parameters' )
                }                
            else
                editors[i] = {
                    last = last,
                    first = selectone( args, {&quot;editor&quot; .. i .. &quot;-first&quot;, 
                        &quot;editor-first&quot; .. i, &quot;EditorGiven&quot; .. i}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;editor&quot; .. i .. &quot;-link&quot;, &quot;editor-link&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;link&quot;, &quot;editorlink&quot; .. i}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;editor&quot; .. i .. &quot;-mask&quot;, &quot;editor-mask&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;mask&quot;, &quot;editormask&quot; .. i}, 'redundant_parameters' )
                }
            end
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
    local id_list = {};
    
    for k, v in pairs( cfg.id_handlers ) do    
        id_list[k] = selectone( args, v.parameters, 'redundant_parameters' );
    end

    return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
    local handler;
    local new_list = {};
    
    for k, v in pairs( id_list ) do
        handler = {};
        
        --Becasue cfg is read-only we have to copy it the hard way.
        for k2, v2 in pairs( cfg.id_handlers[k] ) do
            handler[k2] = v2;
        end
        handler['id'] = v;
        
        if handler.mode == 'external' then        
            table.insert( new_list, {handler.label, externallinkid( handler ) } );
        elseif handler.mode == 'internal' then
            table.insert( new_list, {handler.label, internallinkid( handler ) } );
        elseif handler.mode == 'manual' then
            if k == 'DOI' then
                table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
            elseif k == 'ASIN' then
                table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
            elseif k == 'OL' then
                table.insert( new_list, {handler.label, openlibrary( v ) } );
            elseif k == 'ISBN' then
                local ISBN = internallinkid( handler );
                if not checkisbn( v ) then 
                    ISBN = ISBN .. seterror( 'bad_isbn' );
                end
                table.insert( new_list, {handler.label, ISBN } );                
            else
                error( cfg.message_list['unknown_manual_ID'] );
            end            
        else
            error( cfg.message_list['unknown_ID_mode'] );
        end
    end

    function comp( a, b )
        return a[1] &lt; b[1];
    end

    table.sort( new_list, comp );
    for k, v in ipairs( new_list ) do
        new_list[k] = v[2];
    end
    
    return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition )
    local value = nil;
    local selected = '';
    local error_list = {};
    
    for _, v in ipairs( possible ) do
        if args[v] ~= nil then
            if value ~= nil then
                table.insert( error_list, v );
            else
                value = args[v];
                selected = v;
            end
        end
    end
            
    if #error_list &gt; 0 then
        local error_str = &quot;&quot;;
        for _, k in ipairs( error_list ) do
            if error_str ~= &quot;&quot; then error_str = error_str .. &quot;, &quot; end
            error_str = error_str .. &quot;&lt;code&gt;|&quot; .. k .. &quot;=&lt;/code&gt;&quot;;
        end
        if #error_list &gt; 1 then
            error_str = error_str .. &quot;, and &quot;;
        else
            error_str = error_str .. &quot; and &quot;;
        end
        error_str = error_str .. &quot;&lt;code&gt;|&quot; .. selected .. &quot;=&lt;/code&gt;&quot;;
        table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
    end
            
    return value, selected;
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    -- Load Input Parameters

    local i 
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = args.authors
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = selectone( args, {'chapter', 'contribution', 'entry' }, 'redundant_parameters' );
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url or args.URL
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl or args[&quot;contribution-url&quot;]
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = selectone( args, {'journal', 'newspaper', 'magazine', 'work', 'website', 
        'periodical', 'encyclopedia', 'encyclopaedia'}, 'redundant_parameters' );
            
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = nil          
            TransTitle = nil
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = nil 
                TransTitle = nil
            end
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = nil end
        end
    end
    local Series = selectone( args, {'series', 'version'}, 'redundant_parameters' );
    local Volume = args.volume
    local Issue = selectone( args, {'issue', 'number'}, 'redundant_parameters' );
    local Position = nil
    local Page, Pages, At, page_type;
    
    Page, page_type = selectone( args, {'p', 'page', 'pp', 'pages', 'at'}, 
        'extra_pages' );
    if page_type == 'pp' or page_type == 'pages' then
        Pages = hyphentodash( Page );
        Page = nil;
    elseif page_type == 'at' then
        At = Page;
        Page = nil;
    end
                
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace 
    local Place = selectone( args, {'place', 'location'}, 'redundant_parameters' );
    if PublicationPlace == nil and Place ~= nil then 
        PublicationPlace = Place;
    end
    if PublicationPlace == Place then Place = nil end
    
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl or &quot;yes&quot;           -- Only used is ArchiveURL is present.
    local Language = selectone( args, {'language', 'in'}, 'redundant_parameters' );
    local Format = args.format
    local Ref = args.ref or args.Ref

    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = selectone( args, {'id', 'ID', 'docket'}, 'redundant_parameters' );
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]

    local ID_list = extractids( args );
    
    local Quote = selectone( args, {'quote', 'quotation'}, 'redundant_parameters' );
    local PostScript = args.postscript or &quot;.&quot;
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator or &quot;.&quot;
    local LastAuthorAmp = args.lastauthoramp
    local no_tracking_cats = args[&quot;template doc demo&quot;] or args.nocat or 
            args.notracking or args[&quot;no-tracking&quot;] or &quot;&quot;;

    if ( config.CitationClass == &quot;journal&quot; ) then        
        if (URL == nil or URL == &quot;&quot;) then
            if (ID_list['PMC'] ~= nil) then 
                local Embargo = args.embargo or args.Embargo;
                if Embargo ~= nil then
                    local lang = mw.getContentLanguage();
                    local good1, result1, good2, result2;
                    good1, result1 = pcall( lang.formatDate, lang, 'U', Embargo );
                    good2, result2 = pcall( lang.formatDate, lang, 'U' );

                    if good1 and good2 and tonumber( result1 ) &lt; tonumber( result2 ) then 
                        URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];
                    end
                else
                    URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];           
                end
            end
        end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, cfg.message_list[&quot;episode&quot;] .. &quot; &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, cfg.message_list[&quot;season&quot;] .. &quot; &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, cfg.message_list[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows 
    -- automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
        if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    
    for k, v in pairs( ID_list ) do
        if string.sub( cfg.id_handlers[k].COinS or &quot;info&quot;, 1, 4 ) ~= 'info' then
            OCinSdata[ cfg.id_handlers[k].COinS ] = v;
        end
    end
    
    OCinSdata.rft_id = URL or ChapterURL

    local last, first;
    local OCinSauthors = {};
    for k, v in ipairs( a ) do
        last = v.last;
        first = v.first;
        if k == 1 then
            if last ~= nil then
                OCinSdata[&quot;rft.aulast&quot;] = last;
            end
            if first ~= nil then 
                OCinSdata[&quot;rft.aufirst&quot;] = first;
            end
        end
        if last ~= nil and first ~= nil then
            table.insert( OCinSauthors, last .. (args.NameSep or &quot;, &quot;) .. first );
    	elseif last ~= nil then
            table.insert( OCinSauthors, last );
        end
    end

    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    for k, v in pairs( ID_list ) do
        if string.sub( cfg.id_handlers[k].COinS or &quot;&quot;, 1, 4 ) == 'info' then
            OCinSids[ cfg.id_handlers[k].COinS ] = v;
        end
    end

    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    for _, value in ipairs(OCinSauthors) do
        OCinStitle = OCinStitle .. &quot;&amp;rft.au=&quot; .. mw.uri.encode(value)
    end
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    
    local this_page = mw.title.getCurrentTitle();
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/&quot; .. mw.site.server:match( &quot;[^/]*$&quot; ) .. &quot;:&quot;
       .. this_page.prefixedText  -- end COinS data by page's non-encoded pagename

    if (Periodical ~= nil and Periodical ~= &quot;&quot;) and
        (Chapter == nil or Chapter == '') and
        (Title ~= nil and Title ~= &quot;&quot;) then
            Chapter = Title
            ChapterLink = TitleLink
            TransChapter = TransTitle
            Title = nil
            TitleLink = nil
            TransTitle = nil            
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local Maximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors);
        
        -- Preserve old-style implicit et al.
        if Maximum == nil and #a == 9 then 
            Maximum = 8;
            table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
        elseif Maximum == nil then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = (args[&quot;author-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = args[&quot;author-format&quot;] or args.authorformat,
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        }
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if Coauthors ~= nil and Coauthors ~= &quot;&quot; then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
                
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local Maximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors);

        -- Preserve old-style implicit et al.
        if Maximum == nil and #e == 4 then 
            Maximum = 3;
            table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
        elseif Maximum == nil then
            Maximum = #e + 1;
        end

        local control = { 
            sep = (args[&quot;editor-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = args[&quot;editor-format&quot;] or args.editorformat,
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
            }

        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date
    
    if ( URL == nil or URL == '' ) and
            ( ChapterURL == nil or ChapterURL == '' ) and
            ( ArchiveURL == nil or ArchiveURL == '' ) and                
            ( ConferenceURL == nil or ConferenceURL == '' ) and                
            ( TranscriptURL == nil or TranscriptURL == '' ) then

        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
        end

        -- Test if accessdate is given without giving a URL
        if ( AccessDate ~= nil and AccessDate ~= '' ) then
            table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
            AccessDate = nil;
        end      
    
        -- Test if format is given without giving a URL
        if ( Format ~= nil and Format ~= '' ) then
            Format = Format .. seterror( 'format_missing_url' );
        end        
    end    

    -- Test if citation has no title
    if ( Chapter == nil or Chapter == &quot;&quot; ) and 
            ( Title == nil or Title == &quot;&quot; ) and
            ( Periodical == nil or Periodical == &quot;&quot; ) and
            ( Conference == nil or Conference == &quot;&quot; ) and 
            ( TransTitle == nil or TransTitle == &quot;&quot; ) and
            ( TransChapter == nil or TransChapter == &quot;&quot; ) then
        table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
    end

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
        end
    end

    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
        
    -- Format chapter / article title
    if ( Chapter ~= nil and Chapter ~= &quot;&quot; ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) and (Title ~= nil and Title ~= &quot;&quot; )
        then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
    else
        Chapter = &quot;&quot;;
    end
    if TransChapter ~= &quot;&quot; and Chapter == &quot;&quot; then
        TransChapter = TransChapter .. seterror( 'trans_missing_chapter' );
    end
    Chapter = Chapter .. TransChapter
    if Chapter ~= &quot;&quot; then
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
                if URL == nil or URL == &quot;&quot; then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        elseif ChapterURL ~= nil and ChapterURL ~= &quot;&quot; then
            Chapter = Chapter .. &quot; [&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( ChapterURL ) .. &quot;]&quot; .. 
                seterror( 'bare_url_missing_title' );
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    elseif ChapterURL ~= nil and ChapterURL ~= &quot;&quot; then
        Chapter = &quot; [&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( ChapterURL ) .. &quot;]&quot; .. 
            seterror( 'bare_url_missing_title' ) .. sepc .. &quot; &quot;;
    end        
    
    -- Format main title.
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
                or config.CitationClass == &quot;news&quot; 
                or config.CitationClass == &quot;pressrelease&quot; ) and 
                Chapter == &quot;&quot; then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
    else
        Title = &quot;&quot;;
    end    
    if TransTitle ~= &quot;&quot; and Title == &quot;&quot; then
        TransTitle = TransTitle .. seterror( 'trans_missing_title' );
    end
    Title = Title .. TransTitle
    if Title ~= &quot;&quot; then
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    end

    if ( Place ~= nil and Place ~= &quot;&quot; ) then
        if sepc == '.' then
            Place = &quot; &quot; .. cfg.message_list['written'] .. &quot; &quot; .. Place .. sepc .. &quot; &quot;;
        else
            Place = &quot; &quot; .. cfg.message_list['written']:lower() .. &quot; &quot; .. Place .. sepc .. &quot; &quot;;
        end            
    else
        Place = &quot;&quot;;
    end
    
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    elseif ConferenceURL ~= nil and ConferenceURL ~= &quot;&quot; then
        Conference = &quot; [&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( ConferenceURL ) .. &quot;]&quot; .. 
            seterror( 'bare_url_missing_title' );
    else
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.message_list['minutes'];
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption 
                if TimeCaption == nil then
                    TimeCaption = cfg.message_list['event'];
                    if sepc ~= '.' then
                        TimeCaption = TimeCaption:lower();
                    end
                end                
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (&quot; .. cfg.message_list['in'] .. &quot; &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; &quot; .. cfg.message_list['edition'] .. &quot;)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; &quot; .. cfg.message_list['via'] .. &quot; &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; &quot; .. cfg.message_list['retrieved'] .. &quot; &quot;
         if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
             .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.message_list['subscription'];
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end

    ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD} );

    if ( URL ~= nil and URL ~=&quot;&quot;) then
        URL = &quot; &quot; .. &quot;[&quot; .. URL .. &quot; &quot; .. mw.text.nowiki(URL) .. &quot;]&quot;;
        local error_text = seterror( 'bare_url_missing_title' );
        if config.CitationClass == &quot;web&quot; then
            URL = URL .. &quot; &quot; .. seterror( 'cite_web_title' );
        else
            URL = URL .. error_text;
        end       
    else
        URL = &quot;&quot;
    end

    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot; &quot; .. seterror('archive_missing_date') .. &quot; &quot;
        end
        local arch_text = &quot; &quot; .. cfg.message_list['archived'];
        if (sepc ~= &quot;.&quot;) then arch_text = arch_text:lower() end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] &quot; .. 
                cfg.message_list['from'] .. &quot; &quot; .. cfg.message_list['original'] .. &quot; &quot; .. 
                cfg.message_list['on'] .. ArchiveDate
            if OriginalURL == nil or OriginalUrl == '' then
                Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url_not_dead');                               
            end
        else
            if OriginalURL ~= nil and OriginalURL ~= '' then
                Archived = sepc .. arch_text .. &quot; &quot; .. cfg.message_list['from'] .. &quot; [&quot; .. OriginalURL .. &quot; &quot; .. 
                    cfg.message_list['original'] .. &quot;] &quot; .. cfg.message_list['on'] .. ArchiveDate
            else
                if config.CitationClass ~= 'web' then 
                    Archived = sepc .. arch_text .. &quot; &quot; .. cfg.message_list['from'] .. &quot; &quot; .. 
                    seterror('archive_missing_url') .. &quot; &quot; .. cfg.message_list['on'] .. ArchiveDate
                else
                    Archived = sepc .. arch_text .. &quot; &quot; .. cfg.message_list['from'] .. 
                        &quot; &quot; .. cfg.message_list['original'] .. &quot; &quot; .. 
                        cfg.message_list['on'] .. ArchiveDate
                end
            end                
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        if sepc == '.' then
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; &quot; .. cfg.message_list['lay summary'] .. &quot;]&quot; .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; &quot; .. cfg.message_list['lay summary']:lower() .. &quot;]&quot; .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    elseif TranscriptURL ~= nil and TranscriptURL ~= &quot;&quot; then
        Transcript = &quot;[&quot; .. TranscriptURL .. &quot; &quot; .. safeforurl( TranscriptURL ) .. &quot;]&quot; .. 
            seterror( 'bare_url_missing_title' )        
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; and
         config.CitationClass ~= &quot;pressrelease&quot; ) then
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            if Publisher ~= '' then
                Publisher = Publisher .. &quot;, &quot; .. cfg.message_list['published'] .. &quot; &quot; .. PublicationDate;
            else
                Publisher = PublicationDate;
            end
        end
        if Publisher ~= &quot;&quot; then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (&quot; .. cfg.message_list['published'] .. &quot; &quot; .. PublicationDate .. &quot;)&quot;
        else 
            PublicationDate = &quot;&quot;
        end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot; ) or ( TitleNote and TitleNote ~= &quot;&quot; ) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( ( (config.CitationClass == &quot;journal&quot;) or (config.CitationClass == &quot;citation&quot;) )  and
         Periodical ~= &quot;&quot; ) then
        if (Others ~= &quot;&quot;) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
            Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
            Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
    end
    
    if #ID_list &gt; 0 then
        ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
    else
        ID_list = ID;
    end    
    local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );

    local text
    local pgtext = Page .. Pages .. At
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, &quot; .. cfg.message_list['editor'];
            else
                Editors = Editors .. &quot;, &quot; .. cfg.message_list['editors'];
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (&quot; .. cfg.message_list['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (&quot; .. cfg.message_list['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end -- endif &quot;&quot;~=Date
        if ( config.CitationClass==&quot;journal&quot; and Periodical ) then
          text = safejoin( {Chapter, Place, tcommon}, sepc );
          text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
          text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
          text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if PostScript ~= '' and PostScript ~= nil and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local options = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        options.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = {};
        text = seterror('empty_citation');
        z.message_tail = {};
    end
    
    if options.id ~= nil then 
        text = '&lt;span id=&quot;' .. wikiescape(options.id) ..'&quot; class=&quot;' .. wikiescape(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    else
        text = '&lt;span class=&quot;' .. wikiescape(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    end        

    local empty_span = '&lt;span style=&quot;display: none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = '&lt;span title=&quot;' .. wikiescape(OCinStitle) .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        for i,v in ipairs( z.message_tail ) do
            if i == #z.message_tail then
                text = text .. errorcomment( v[1], v[2] );
            else
                text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
            end
        end
    end
    
    if no_tracking_cats == '' then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    local suggestions = {};
    local error_text, error_state;
    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            if not validate( k ) then            
                if type( k ) ~= 'string' then
                    -- Exclude empty numbered parameters
                    if v:match(&quot;%S+&quot;) ~= nil then
                        error_text, error_state = seterror( 'text_ignored', {v}, true );
                    end
                elseif validate( k:lower() ) then 
                    error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
                else
                    if #suggestions == 0 then
                        suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
                    end
                    if suggestions[ k:lower() ] ~= nil then
                        error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
                    else
                        error_text, error_state = seterror( 'parameter_ignored', {k}, true );
                    end
                end                  
                if error_text ~= '' then
                    table.insert( z.message_tail, {error_text, error_state} );
                end                
            end            
            args[k] = v;
        elseif k == 'postscript' then
            args[k] = v;
        end        
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        if args[k] == nil and (v ~= '' or k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--18Mar2013 Fixed &quot;page=&quot; to override &quot;pages=&quot; as in markup-based cites.
--19Mar2013 Fixed date of class=journal Periodical to show after page.
--19Mar2013 Changed null &quot;postscript=&quot; to suppress end-dot of citation.
--20Mar2013 If CitationClass is journal, show &quot;others=&quot; before title.
--20Mar2013 If CitationClass is book, show &quot;others=&quot; before edition.
--20Mar2013 If CitationClass is journal, adjust &quot;others=&quot; to have sepc.
--20Mar2013 For class &quot;journal&quot;, use book format unless Periodical set.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; after wikilink &quot;.]]&quot; end dot.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; after external &quot;.]&quot; end dot.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; at italic wikilink &quot;.]]&quot; end.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; at italic external &quot;.]&quot; end.
--04Apr2013 Moved sepc before &lt;span class=&quot;reference-accessdate&quot;&gt; for &quot;..&quot;.
--
--End</text>
      <sha1>gubfdhme7f5plrmrc9ss6ai2iw2q7t9</sha1>
    </revision>
    <revision>
      <id>4641</id>
      <parentid>4640</parentid>
      <timestamp>2013-04-09T21:28:44Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>not sure what is causing a nil value here, but this should fix the immediate script errors</comment>
      <origin>4641</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="67228" sha1="6j8th3po4qnb4p1m2ikmrsjlbf9kzpf" xml:space="preserve">local z = {
    error_categories = {};
    message_tail = {};
}

-- Include translation message hooks, ID and error handling configuration settings.
local cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );
 
-- Contains a list of all recognized parameters
local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );

-- Checks that parameter name is valid
function validate( name )
    name = tostring( name );
    
    -- Normal arguments
    if whitelist.basic_arguments[ name ] then
        return true;
    end
    
    -- Arguments with numbers in them
    name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );
    if whitelist.numbered_arguments[ name ] then
        return true;
    end
    
    -- Not found, argument not supported.
    return false
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
    if hidden then 
        return '&lt;span style=&quot;display:none;font-size:100%&quot; class=&quot;error citation-comment&quot;&gt;' .. content or &quot;&quot; .. '&lt;/span&gt;';
    else
        return '&lt;span style=&quot;font-size:100%&quot; class=&quot;error&quot;&gt;' .. content or &quot;&quot; .. '&lt;/span&gt;';
    end        
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, args, raw )
    local error_state = cfg.error_conditions[ error_id ];

    if error_state == nil then
        error( cfg.message_list['undefined_error'] );
    end
    
    if error_state.category ~= nil and error_state.category ~= &quot;&quot; then
        table.insert( z.error_categories, error_state.category );
    end
    
    local message = error_state.message;
    if args ~= nil then
        for k, m in ipairs( args ) do
            message = message:gsub( &quot;$&quot; .. k .. &quot;(%D)&quot;, m .. &quot;%1&quot; );
        end
    end

    message = wikiescape(message) .. &quot; ([[&quot; .. cfg.message_list['help page link'] .. 
        &quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
        cfg.message_list['help page label'] .. &quot;]])&quot;;

    if raw == true then
        return message, error_state.hidden;
    end
        
    return errorcomment( message, error_state.hidden );
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',    
            ['{'] = '&amp;#123;',    
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

-- Formats a wiki style external link
function externallinkid(options)
    local sep = options.separator or &quot;&amp;nbsp;&quot;
    options.suffix = options.suffix or &quot;&quot;
    local url_string = options.id
    if options.encode == true or options.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    return &quot;[[&quot; .. options.link .. &quot;|&quot; .. options.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. 
            options.prefix .. url_string .. options.suffix .. &quot; &quot; .. mw.text.nowiki(options.id) .. &quot;]&quot;
end

-- Formats a wiki style internal link
function internallinkid(options)
    local sep = options.separator or &quot;&amp;nbsp;&quot;
    options.suffix = options.suffix or &quot;&quot;
    return &quot;[[&quot; .. options.link .. &quot;|&quot; .. options.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. 
            options.prefix .. options.id .. options.suffix .. &quot;|&quot; .. mw.text.nowiki(options.id) .. &quot;]]&quot;
end

-- Formats a link to Amazon
function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local handler = cfg.id_handlers['ASIN'];
    return externallinkid({link = handler.link,
        label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
        encode=handler.encode, separator = handler.separator})
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    local handler = cfg.id_handlers['DOI'];
    
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (&quot; .. cfg.message_list['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link = handler.link, label = handler.label,
            prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then      
        cat = seterror( 'bad_doi' );
    end
    return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    local handler = cfg.id_handlers['OL'];
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    else
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode}) .. 
            ' ' .. seterror( 'bad_ol' );
    end
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
    isbn_str = isbn_str:gsub(&quot;[- ]&quot;, &quot;&quot;):upper();
    local len = isbn_str:len();
 
    if len ~= 10 and len ~= 13 then
        return false;
    end
 
    local temp = 0;
    if len == 10 then
        if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            if v == string.byte( &quot;X&quot; ) then
                temp = temp + 10*( 11 - i );
            else
                temp = temp + tonumber( string.char(v) )*(11-i);
            end
        end
        return temp % 11 == 0;
    else
        if isbn_str:match( &quot;^%d*$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
        end
        return temp % 10 == 0;
    end
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    if str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then 
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    -- Is the input a simple number?
    local num = tonumber( str ); 
    if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
        return str;
    else
        -- Use formatDate to interpret more complicated formats
        local lang = mw.getContentLanguage();
        local good, result;
        good, result = pcall( lang.formatDate, lang, 'Y', str )
        if good then 
            return result;
        else
            -- Can't make sense of this input, return blank.
            return &quot;&quot;;
        end
    end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil and first ~= '') then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    if count &gt; 1 and lastauthoramp ~= nil and lastauthoramp ~= &quot;&quot; and not etal then
        text[count-1] = text[count-1] .. &quot; &amp; &quot; .. text[count];
        text[count] = nil;
    end    
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = cfg.message_list['et al'];
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result = 
        '&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
    end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid(options)
    local P1 = options[1] or &quot;&quot;
    local P2 = options[2] or &quot;&quot;
    local P3 = options[3] or &quot;&quot;
    local P4 = options[4] or &quot;&quot;
    local P5 = options[5] or &quot;&quot;
    
    -- Bugzilla 46608
    local encoded = mw.uri.anchorEncode( P1 .. P2 .. P3 .. P4 .. P5 );
    if encoded == false then
        encoded = &quot;&quot;;
    end
    
    return &quot;CITEREF&quot; .. encoded;
end

-- Gets author list from the input arguments
function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    while true do
        if i == 1 then 
            last = selectone( args, {&quot;author&quot; .. i .. &quot;-last&quot;, &quot;author-last&quot; .. i, 
                &quot;last&quot; .. i, &quot;surname&quot; .. i, &quot;Author&quot; .. i, &quot;author&quot; .. i, 
                &quot;author-last&quot;, &quot;last&quot;, &quot;surname&quot;, &quot;Author&quot;, &quot;author&quot;, &quot;authors&quot;}, 'redundant_parameters' );
        else
            last = selectone( args, {&quot;author&quot; .. i .. &quot;-last&quot;, &quot;author-last&quot; .. i, 
                &quot;last&quot; .. i, &quot;surname&quot; .. i, &quot;Author&quot; .. i, &quot;author&quot; .. i}, 'redundant_parameters' );
        end
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            if i == 1 then 
                authors[i] = {
                    last = last,
                    first = selectone( args, {&quot;author&quot; .. i .. &quot;-first&quot;, &quot;author-first&quot; .. i, 
                        &quot;first&quot; .. i, &quot;given&quot; .. i, &quot;author-first&quot;, 
                        &quot;first&quot;, &quot;given&quot;}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;author&quot; .. i .. &quot;-link&quot;, &quot;author-link&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;link&quot;, &quot;authorlink&quot; .. i, &quot;author-link&quot;,  
                        &quot;authorlink&quot;}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;author&quot; .. i .. &quot;-mask&quot;, &quot;author-mask&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;mask&quot;, &quot;authormask&quot; .. i, &quot;author-mask&quot;, 
                        &quot;authormask&quot; }, 'redundant_parameters' )
                }
            else
                authors[i] = {
                    last = last,
                    first = selectone( args, {&quot;author&quot; .. i .. &quot;-first&quot;, &quot;author-first&quot; .. i, 
                        &quot;first&quot; .. i, &quot;given&quot; .. i}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;author&quot; .. i .. &quot;-link&quot;, &quot;author-link&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;link&quot;, &quot;authorlink&quot; .. i}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;author&quot; .. i .. &quot;-mask&quot;, &quot;author-mask&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;mask&quot;, &quot;authormask&quot; .. i}, 'redundant_parameters' )
                }
            end            
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

-- Gets editor list from the input arguments
function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        if i == 1 then
            last = selectone( args, {&quot;editor&quot; .. i .. &quot;-last&quot;, &quot;editor-last&quot; .. i,
                &quot;EditorSurname&quot; .. i, &quot;Editor&quot; .. i, &quot;editor&quot; .. i, &quot;editor-last&quot;, 
                &quot;EditorSurname&quot;, &quot;Editor&quot;, &quot;editor&quot;, &quot;editors&quot;}, 'redundant_parameters' );
        else
            last = selectone( args, {&quot;editor&quot; .. i .. &quot;-last&quot;, &quot;editor-last&quot; .. i,
                &quot;EditorSurname&quot; .. i, &quot;Editor&quot; .. i, &quot;editor&quot; .. i}, 'redundant_parameters' );
        end        
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            if i == 1 then
                editors[i] = {
                    last = last,
                    first = selectone( args, {&quot;editor&quot; .. i .. &quot;-first&quot;, 
                        &quot;editor-first&quot; .. i, &quot;EditorGiven&quot; .. i, &quot;editor-first&quot;, 
                        &quot;EditorGiven&quot;}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;editor&quot; .. i .. &quot;-link&quot;, &quot;editor-link&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;link&quot;, &quot;editorlink&quot; .. i, &quot;editor-link&quot;, 
                        &quot;editorlink&quot;}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;editor&quot; .. i .. &quot;-mask&quot;, &quot;editor-mask&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;mask&quot;, &quot;editormask&quot; .. i, &quot;editor-mask&quot;,  
                        &quot;editormask&quot;}, 'redundant_parameters' )
                }                
            else
                editors[i] = {
                    last = last,
                    first = selectone( args, {&quot;editor&quot; .. i .. &quot;-first&quot;, 
                        &quot;editor-first&quot; .. i, &quot;EditorGiven&quot; .. i}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;editor&quot; .. i .. &quot;-link&quot;, &quot;editor-link&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;link&quot;, &quot;editorlink&quot; .. i}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;editor&quot; .. i .. &quot;-mask&quot;, &quot;editor-mask&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;mask&quot;, &quot;editormask&quot; .. i}, 'redundant_parameters' )
                }
            end
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
    local id_list = {};
    
    for k, v in pairs( cfg.id_handlers ) do    
        id_list[k] = selectone( args, v.parameters, 'redundant_parameters' );
    end

    return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
    local handler;
    local new_list = {};
    
    for k, v in pairs( id_list ) do
        handler = {};
        
        --Becasue cfg is read-only we have to copy it the hard way.
        for k2, v2 in pairs( cfg.id_handlers[k] ) do
            handler[k2] = v2;
        end
        handler['id'] = v;
        
        if handler.mode == 'external' then        
            table.insert( new_list, {handler.label, externallinkid( handler ) } );
        elseif handler.mode == 'internal' then
            table.insert( new_list, {handler.label, internallinkid( handler ) } );
        elseif handler.mode == 'manual' then
            if k == 'DOI' then
                table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
            elseif k == 'ASIN' then
                table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
            elseif k == 'OL' then
                table.insert( new_list, {handler.label, openlibrary( v ) } );
            elseif k == 'ISBN' then
                local ISBN = internallinkid( handler );
                if not checkisbn( v ) then 
                    ISBN = ISBN .. seterror( 'bad_isbn' );
                end
                table.insert( new_list, {handler.label, ISBN } );                
            else
                error( cfg.message_list['unknown_manual_ID'] );
            end            
        else
            error( cfg.message_list['unknown_ID_mode'] );
        end
    end

    function comp( a, b )
        return a[1] &lt; b[1];
    end

    table.sort( new_list, comp );
    for k, v in ipairs( new_list ) do
        new_list[k] = v[2];
    end
    
    return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition )
    local value = nil;
    local selected = '';
    local error_list = {};
    
    for _, v in ipairs( possible ) do
        if args[v] ~= nil then
            if value ~= nil then
                table.insert( error_list, v );
            else
                value = args[v];
                selected = v;
            end
        end
    end
            
    if #error_list &gt; 0 then
        local error_str = &quot;&quot;;
        for _, k in ipairs( error_list ) do
            if error_str ~= &quot;&quot; then error_str = error_str .. &quot;, &quot; end
            error_str = error_str .. &quot;&lt;code&gt;|&quot; .. k .. &quot;=&lt;/code&gt;&quot;;
        end
        if #error_list &gt; 1 then
            error_str = error_str .. &quot;, and &quot;;
        else
            error_str = error_str .. &quot; and &quot;;
        end
        error_str = error_str .. &quot;&lt;code&gt;|&quot; .. selected .. &quot;=&lt;/code&gt;&quot;;
        table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
    end
            
    return value, selected;
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    -- Load Input Parameters

    local i 
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = args.authors
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = selectone( args, {'chapter', 'contribution', 'entry' }, 'redundant_parameters' );
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url or args.URL
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl or args[&quot;contribution-url&quot;]
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = selectone( args, {'journal', 'newspaper', 'magazine', 'work', 'website', 
        'periodical', 'encyclopedia', 'encyclopaedia'}, 'redundant_parameters' );
            
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = nil          
            TransTitle = nil
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = nil 
                TransTitle = nil
            end
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = nil end
        end
    end
    local Series = selectone( args, {'series', 'version'}, 'redundant_parameters' );
    local Volume = args.volume
    local Issue = selectone( args, {'issue', 'number'}, 'redundant_parameters' );
    local Position = nil
    local Page, Pages, At, page_type;
    
    Page, page_type = selectone( args, {'p', 'page', 'pp', 'pages', 'at'}, 
        'extra_pages' );
    if page_type == 'pp' or page_type == 'pages' then
        Pages = hyphentodash( Page );
        Page = nil;
    elseif page_type == 'at' then
        At = Page;
        Page = nil;
    end
                
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace 
    local Place = selectone( args, {'place', 'location'}, 'redundant_parameters' );
    if PublicationPlace == nil and Place ~= nil then 
        PublicationPlace = Place;
    end
    if PublicationPlace == Place then Place = nil end
    
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl or &quot;yes&quot;           -- Only used is ArchiveURL is present.
    local Language = selectone( args, {'language', 'in'}, 'redundant_parameters' );
    local Format = args.format
    local Ref = args.ref or args.Ref

    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = selectone( args, {'id', 'ID', 'docket'}, 'redundant_parameters' );
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]

    local ID_list = extractids( args );
    
    local Quote = selectone( args, {'quote', 'quotation'}, 'redundant_parameters' );
    local PostScript = args.postscript or &quot;.&quot;
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator or &quot;.&quot;
    local LastAuthorAmp = args.lastauthoramp
    local no_tracking_cats = args[&quot;template doc demo&quot;] or args.nocat or 
            args.notracking or args[&quot;no-tracking&quot;] or &quot;&quot;;

    if ( config.CitationClass == &quot;journal&quot; ) then        
        if (URL == nil or URL == &quot;&quot;) then
            if (ID_list['PMC'] ~= nil) then 
                local Embargo = args.embargo or args.Embargo;
                if Embargo ~= nil then
                    local lang = mw.getContentLanguage();
                    local good1, result1, good2, result2;
                    good1, result1 = pcall( lang.formatDate, lang, 'U', Embargo );
                    good2, result2 = pcall( lang.formatDate, lang, 'U' );

                    if good1 and good2 and tonumber( result1 ) &lt; tonumber( result2 ) then 
                        URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];
                    end
                else
                    URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];           
                end
            end
        end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, cfg.message_list[&quot;episode&quot;] .. &quot; &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, cfg.message_list[&quot;season&quot;] .. &quot; &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, cfg.message_list[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows 
    -- automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
        if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    
    for k, v in pairs( ID_list ) do
        if string.sub( cfg.id_handlers[k].COinS or &quot;info&quot;, 1, 4 ) ~= 'info' then
            OCinSdata[ cfg.id_handlers[k].COinS ] = v;
        end
    end
    
    OCinSdata.rft_id = URL or ChapterURL

    local last, first;
    local OCinSauthors = {};
    for k, v in ipairs( a ) do
        last = v.last;
        first = v.first;
        if k == 1 then
            if last ~= nil then
                OCinSdata[&quot;rft.aulast&quot;] = last;
            end
            if first ~= nil then 
                OCinSdata[&quot;rft.aufirst&quot;] = first;
            end
        end
        if last ~= nil and first ~= nil then
            table.insert( OCinSauthors, last .. (args.NameSep or &quot;, &quot;) .. first );
    	elseif last ~= nil then
            table.insert( OCinSauthors, last );
        end
    end

    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    for k, v in pairs( ID_list ) do
        if string.sub( cfg.id_handlers[k].COinS or &quot;&quot;, 1, 4 ) == 'info' then
            OCinSids[ cfg.id_handlers[k].COinS ] = v;
        end
    end

    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    for _, value in ipairs(OCinSauthors) do
        OCinStitle = OCinStitle .. &quot;&amp;rft.au=&quot; .. mw.uri.encode(value)
    end
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    
    local this_page = mw.title.getCurrentTitle();
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/&quot; .. mw.site.server:match( &quot;[^/]*$&quot; ) .. &quot;:&quot;
       .. this_page.prefixedText  -- end COinS data by page's non-encoded pagename

    if (Periodical ~= nil and Periodical ~= &quot;&quot;) and
        (Chapter == nil or Chapter == '') and
        (Title ~= nil and Title ~= &quot;&quot;) then
            Chapter = Title
            ChapterLink = TitleLink
            TransChapter = TransTitle
            Title = nil
            TitleLink = nil
            TransTitle = nil            
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local Maximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors);
        
        -- Preserve old-style implicit et al.
        if Maximum == nil and #a == 9 then 
            Maximum = 8;
            table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
        elseif Maximum == nil then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = (args[&quot;author-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = args[&quot;author-format&quot;] or args.authorformat,
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        }
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if Coauthors ~= nil and Coauthors ~= &quot;&quot; then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
                
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local Maximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors);

        -- Preserve old-style implicit et al.
        if Maximum == nil and #e == 4 then 
            Maximum = 3;
            table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
        elseif Maximum == nil then
            Maximum = #e + 1;
        end

        local control = { 
            sep = (args[&quot;editor-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = args[&quot;editor-format&quot;] or args.editorformat,
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
            }

        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date
    
    if ( URL == nil or URL == '' ) and
            ( ChapterURL == nil or ChapterURL == '' ) and
            ( ArchiveURL == nil or ArchiveURL == '' ) and                
            ( ConferenceURL == nil or ConferenceURL == '' ) and                
            ( TranscriptURL == nil or TranscriptURL == '' ) then

        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
        end

        -- Test if accessdate is given without giving a URL
        if ( AccessDate ~= nil and AccessDate ~= '' ) then
            table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
            AccessDate = nil;
        end      
    
        -- Test if format is given without giving a URL
        if ( Format ~= nil and Format ~= '' ) then
            Format = Format .. seterror( 'format_missing_url' );
        end        
    end    

    -- Test if citation has no title
    if ( Chapter == nil or Chapter == &quot;&quot; ) and 
            ( Title == nil or Title == &quot;&quot; ) and
            ( Periodical == nil or Periodical == &quot;&quot; ) and
            ( Conference == nil or Conference == &quot;&quot; ) and 
            ( TransTitle == nil or TransTitle == &quot;&quot; ) and
            ( TransChapter == nil or TransChapter == &quot;&quot; ) then
        table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
    end

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
        end
    end

    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
        
    -- Format chapter / article title
    if ( Chapter ~= nil and Chapter ~= &quot;&quot; ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) and (Title ~= nil and Title ~= &quot;&quot; )
        then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
    else
        Chapter = &quot;&quot;;
    end
    if TransChapter ~= &quot;&quot; and Chapter == &quot;&quot; then
        TransChapter = TransChapter .. seterror( 'trans_missing_chapter' );
    end
    Chapter = Chapter .. TransChapter
    if Chapter ~= &quot;&quot; then
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
                if URL == nil or URL == &quot;&quot; then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        elseif ChapterURL ~= nil and ChapterURL ~= &quot;&quot; then
            Chapter = Chapter .. &quot; [&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( ChapterURL ) .. &quot;]&quot; .. 
                seterror( 'bare_url_missing_title' );
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    elseif ChapterURL ~= nil and ChapterURL ~= &quot;&quot; then
        Chapter = &quot; [&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( ChapterURL ) .. &quot;]&quot; .. 
            seterror( 'bare_url_missing_title' ) .. sepc .. &quot; &quot;;
    end        
    
    -- Format main title.
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
                or config.CitationClass == &quot;news&quot; 
                or config.CitationClass == &quot;pressrelease&quot; ) and 
                Chapter == &quot;&quot; then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
    else
        Title = &quot;&quot;;
    end    
    if TransTitle ~= &quot;&quot; and Title == &quot;&quot; then
        TransTitle = TransTitle .. seterror( 'trans_missing_title' );
    end
    Title = Title .. TransTitle
    if Title ~= &quot;&quot; then
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    end

    if ( Place ~= nil and Place ~= &quot;&quot; ) then
        if sepc == '.' then
            Place = &quot; &quot; .. cfg.message_list['written'] .. &quot; &quot; .. Place .. sepc .. &quot; &quot;;
        else
            Place = &quot; &quot; .. cfg.message_list['written']:lower() .. &quot; &quot; .. Place .. sepc .. &quot; &quot;;
        end            
    else
        Place = &quot;&quot;;
    end
    
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    elseif ConferenceURL ~= nil and ConferenceURL ~= &quot;&quot; then
        Conference = &quot; [&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( ConferenceURL ) .. &quot;]&quot; .. 
            seterror( 'bare_url_missing_title' );
    else
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.message_list['minutes'];
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption 
                if TimeCaption == nil then
                    TimeCaption = cfg.message_list['event'];
                    if sepc ~= '.' then
                        TimeCaption = TimeCaption:lower();
                    end
                end                
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (&quot; .. cfg.message_list['in'] .. &quot; &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; &quot; .. cfg.message_list['edition'] .. &quot;)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; &quot; .. cfg.message_list['via'] .. &quot; &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; &quot; .. cfg.message_list['retrieved'] .. &quot; &quot;
         if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
             .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.message_list['subscription'];
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end

    ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD} );

    if ( URL ~= nil and URL ~=&quot;&quot;) then
        URL = &quot; &quot; .. &quot;[&quot; .. URL .. &quot; &quot; .. mw.text.nowiki(URL) .. &quot;]&quot;;
        local error_text = seterror( 'bare_url_missing_title' );
        if config.CitationClass == &quot;web&quot; then
            URL = URL .. &quot; &quot; .. seterror( 'cite_web_title' );
        else
            URL = URL .. error_text;
        end       
    else
        URL = &quot;&quot;
    end

    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot; &quot; .. seterror('archive_missing_date') .. &quot; &quot;
        end
        local arch_text = &quot; &quot; .. cfg.message_list['archived'];
        if (sepc ~= &quot;.&quot;) then arch_text = arch_text:lower() end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] &quot; .. 
                cfg.message_list['from'] .. &quot; &quot; .. cfg.message_list['original'] .. &quot; &quot; .. 
                cfg.message_list['on'] .. ArchiveDate
            if OriginalURL == nil or OriginalUrl == '' then
                Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url_not_dead');                               
            end
        else
            if OriginalURL ~= nil and OriginalURL ~= '' then
                Archived = sepc .. arch_text .. &quot; &quot; .. cfg.message_list['from'] .. &quot; [&quot; .. OriginalURL .. &quot; &quot; .. 
                    cfg.message_list['original'] .. &quot;] &quot; .. cfg.message_list['on'] .. ArchiveDate
            else
                if config.CitationClass ~= 'web' then 
                    Archived = sepc .. arch_text .. &quot; &quot; .. cfg.message_list['from'] .. &quot; &quot; .. 
                    seterror('archive_missing_url') .. &quot; &quot; .. cfg.message_list['on'] .. ArchiveDate
                else
                    Archived = sepc .. arch_text .. &quot; &quot; .. cfg.message_list['from'] .. 
                        &quot; &quot; .. cfg.message_list['original'] .. &quot; &quot; .. 
                        cfg.message_list['on'] .. ArchiveDate
                end
            end                
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        if sepc == '.' then
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; &quot; .. cfg.message_list['lay summary'] .. &quot;]&quot; .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; &quot; .. cfg.message_list['lay summary']:lower() .. &quot;]&quot; .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    elseif TranscriptURL ~= nil and TranscriptURL ~= &quot;&quot; then
        Transcript = &quot;[&quot; .. TranscriptURL .. &quot; &quot; .. safeforurl( TranscriptURL ) .. &quot;]&quot; .. 
            seterror( 'bare_url_missing_title' )        
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; and
         config.CitationClass ~= &quot;pressrelease&quot; ) then
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            if Publisher ~= '' then
                Publisher = Publisher .. &quot;, &quot; .. cfg.message_list['published'] .. &quot; &quot; .. PublicationDate;
            else
                Publisher = PublicationDate;
            end
        end
        if Publisher ~= &quot;&quot; then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (&quot; .. cfg.message_list['published'] .. &quot; &quot; .. PublicationDate .. &quot;)&quot;
        else 
            PublicationDate = &quot;&quot;
        end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot; ) or ( TitleNote and TitleNote ~= &quot;&quot; ) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( ( (config.CitationClass == &quot;journal&quot;) or (config.CitationClass == &quot;citation&quot;) )  and
         Periodical ~= &quot;&quot; ) then
        if (Others ~= &quot;&quot;) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
            Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
            Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
    end
    
    if #ID_list &gt; 0 then
        ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
    else
        ID_list = ID;
    end    
    local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );

    local text
    local pgtext = Page .. Pages .. At
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, &quot; .. cfg.message_list['editor'];
            else
                Editors = Editors .. &quot;, &quot; .. cfg.message_list['editors'];
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (&quot; .. cfg.message_list['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (&quot; .. cfg.message_list['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end -- endif &quot;&quot;~=Date
        if ( config.CitationClass==&quot;journal&quot; and Periodical ) then
          text = safejoin( {Chapter, Place, tcommon}, sepc );
          text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
          text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
          text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if PostScript ~= '' and PostScript ~= nil and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local options = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        options.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = {};
        text = seterror('empty_citation');
        z.message_tail = {};
    end
    
    if options.id ~= nil then 
        text = '&lt;span id=&quot;' .. wikiescape(options.id) ..'&quot; class=&quot;' .. wikiescape(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    else
        text = '&lt;span class=&quot;' .. wikiescape(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    end        

    local empty_span = '&lt;span style=&quot;display: none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = '&lt;span title=&quot;' .. wikiescape(OCinStitle) .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        for i,v in ipairs( z.message_tail ) do
            if i == #z.message_tail then
                text = text .. errorcomment( v[1], v[2] );
            else
                text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
            end
        end
    end
    
    if no_tracking_cats == '' then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    local suggestions = {};
    local error_text, error_state;
    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            if not validate( k ) then            
                if type( k ) ~= 'string' then
                    -- Exclude empty numbered parameters
                    if v:match(&quot;%S+&quot;) ~= nil then
                        error_text, error_state = seterror( 'text_ignored', {v}, true );
                    end
                elseif validate( k:lower() ) then 
                    error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
                else
                    if #suggestions == 0 then
                        suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
                    end
                    if suggestions[ k:lower() ] ~= nil then
                        error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
                    else
                        error_text, error_state = seterror( 'parameter_ignored', {k}, true );
                    end
                end                  
                if error_text ~= '' then
                    table.insert( z.message_tail, {error_text, error_state} );
                end                
            end            
            args[k] = v;
        elseif k == 'postscript' then
            args[k] = v;
        end        
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        if args[k] == nil and (v ~= '' or k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--18Mar2013 Fixed &quot;page=&quot; to override &quot;pages=&quot; as in markup-based cites.
--19Mar2013 Fixed date of class=journal Periodical to show after page.
--19Mar2013 Changed null &quot;postscript=&quot; to suppress end-dot of citation.
--20Mar2013 If CitationClass is journal, show &quot;others=&quot; before title.
--20Mar2013 If CitationClass is book, show &quot;others=&quot; before edition.
--20Mar2013 If CitationClass is journal, adjust &quot;others=&quot; to have sepc.
--20Mar2013 For class &quot;journal&quot;, use book format unless Periodical set.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; after wikilink &quot;.]]&quot; end dot.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; after external &quot;.]&quot; end dot.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; at italic wikilink &quot;.]]&quot; end.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; at italic external &quot;.]&quot; end.
--04Apr2013 Moved sepc before &lt;span class=&quot;reference-accessdate&quot;&gt; for &quot;..&quot;.
--
--End</text>
      <sha1>6j8th3po4qnb4p1m2ikmrsjlbf9kzpf</sha1>
    </revision>
    <revision>
      <id>4642</id>
      <parentid>4641</parentid>
      <timestamp>2013-04-09T21:30:24Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>better</comment>
      <origin>4642</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="67232" sha1="4y7eq9di2abms4xgj7lrvvoqwj5ji4z" xml:space="preserve">local z = {
    error_categories = {};
    message_tail = {};
}

-- Include translation message hooks, ID and error handling configuration settings.
local cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );
 
-- Contains a list of all recognized parameters
local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );

-- Checks that parameter name is valid
function validate( name )
    name = tostring( name );
    
    -- Normal arguments
    if whitelist.basic_arguments[ name ] then
        return true;
    end
    
    -- Arguments with numbers in them
    name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );
    if whitelist.numbered_arguments[ name ] then
        return true;
    end
    
    -- Not found, argument not supported.
    return false
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
    if hidden then 
        return '&lt;span style=&quot;display:none;font-size:100%&quot; class=&quot;error citation-comment&quot;&gt;' .. (content or &quot;&quot;) .. '&lt;/span&gt;';
    else
        return '&lt;span style=&quot;font-size:100%&quot; class=&quot;error&quot;&gt;' .. (content or &quot;&quot;) .. '&lt;/span&gt;';
    end        
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, args, raw )
    local error_state = cfg.error_conditions[ error_id ];

    if error_state == nil then
        error( cfg.message_list['undefined_error'] );
    end
    
    if error_state.category ~= nil and error_state.category ~= &quot;&quot; then
        table.insert( z.error_categories, error_state.category );
    end
    
    local message = error_state.message;
    if args ~= nil then
        for k, m in ipairs( args ) do
            message = message:gsub( &quot;$&quot; .. k .. &quot;(%D)&quot;, m .. &quot;%1&quot; );
        end
    end

    message = wikiescape(message) .. &quot; ([[&quot; .. cfg.message_list['help page link'] .. 
        &quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
        cfg.message_list['help page label'] .. &quot;]])&quot;;

    if raw == true then
        return message, error_state.hidden;
    end
        
    return errorcomment( message, error_state.hidden );
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',    
            ['{'] = '&amp;#123;',    
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

-- Formats a wiki style external link
function externallinkid(options)
    local sep = options.separator or &quot;&amp;nbsp;&quot;
    options.suffix = options.suffix or &quot;&quot;
    local url_string = options.id
    if options.encode == true or options.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    return &quot;[[&quot; .. options.link .. &quot;|&quot; .. options.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. 
            options.prefix .. url_string .. options.suffix .. &quot; &quot; .. mw.text.nowiki(options.id) .. &quot;]&quot;
end

-- Formats a wiki style internal link
function internallinkid(options)
    local sep = options.separator or &quot;&amp;nbsp;&quot;
    options.suffix = options.suffix or &quot;&quot;
    return &quot;[[&quot; .. options.link .. &quot;|&quot; .. options.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. 
            options.prefix .. options.id .. options.suffix .. &quot;|&quot; .. mw.text.nowiki(options.id) .. &quot;]]&quot;
end

-- Formats a link to Amazon
function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local handler = cfg.id_handlers['ASIN'];
    return externallinkid({link = handler.link,
        label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
        encode=handler.encode, separator = handler.separator})
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    local handler = cfg.id_handlers['DOI'];
    
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (&quot; .. cfg.message_list['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link = handler.link, label = handler.label,
            prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then      
        cat = seterror( 'bad_doi' );
    end
    return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    local handler = cfg.id_handlers['OL'];
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    else
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode}) .. 
            ' ' .. seterror( 'bad_ol' );
    end
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
    isbn_str = isbn_str:gsub(&quot;[- ]&quot;, &quot;&quot;):upper();
    local len = isbn_str:len();
 
    if len ~= 10 and len ~= 13 then
        return false;
    end
 
    local temp = 0;
    if len == 10 then
        if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            if v == string.byte( &quot;X&quot; ) then
                temp = temp + 10*( 11 - i );
            else
                temp = temp + tonumber( string.char(v) )*(11-i);
            end
        end
        return temp % 11 == 0;
    else
        if isbn_str:match( &quot;^%d*$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
        end
        return temp % 10 == 0;
    end
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    if str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then 
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    -- Is the input a simple number?
    local num = tonumber( str ); 
    if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
        return str;
    else
        -- Use formatDate to interpret more complicated formats
        local lang = mw.getContentLanguage();
        local good, result;
        good, result = pcall( lang.formatDate, lang, 'Y', str )
        if good then 
            return result;
        else
            -- Can't make sense of this input, return blank.
            return &quot;&quot;;
        end
    end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil and first ~= '') then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    if count &gt; 1 and lastauthoramp ~= nil and lastauthoramp ~= &quot;&quot; and not etal then
        text[count-1] = text[count-1] .. &quot; &amp; &quot; .. text[count];
        text[count] = nil;
    end    
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = cfg.message_list['et al'];
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result = 
        '&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
    end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid(options)
    local P1 = options[1] or &quot;&quot;
    local P2 = options[2] or &quot;&quot;
    local P3 = options[3] or &quot;&quot;
    local P4 = options[4] or &quot;&quot;
    local P5 = options[5] or &quot;&quot;
    
    -- Bugzilla 46608
    local encoded = mw.uri.anchorEncode( P1 .. P2 .. P3 .. P4 .. P5 );
    if encoded == false then
        encoded = &quot;&quot;;
    end
    
    return &quot;CITEREF&quot; .. encoded;
end

-- Gets author list from the input arguments
function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    while true do
        if i == 1 then 
            last = selectone( args, {&quot;author&quot; .. i .. &quot;-last&quot;, &quot;author-last&quot; .. i, 
                &quot;last&quot; .. i, &quot;surname&quot; .. i, &quot;Author&quot; .. i, &quot;author&quot; .. i, 
                &quot;author-last&quot;, &quot;last&quot;, &quot;surname&quot;, &quot;Author&quot;, &quot;author&quot;, &quot;authors&quot;}, 'redundant_parameters' );
        else
            last = selectone( args, {&quot;author&quot; .. i .. &quot;-last&quot;, &quot;author-last&quot; .. i, 
                &quot;last&quot; .. i, &quot;surname&quot; .. i, &quot;Author&quot; .. i, &quot;author&quot; .. i}, 'redundant_parameters' );
        end
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            if i == 1 then 
                authors[i] = {
                    last = last,
                    first = selectone( args, {&quot;author&quot; .. i .. &quot;-first&quot;, &quot;author-first&quot; .. i, 
                        &quot;first&quot; .. i, &quot;given&quot; .. i, &quot;author-first&quot;, 
                        &quot;first&quot;, &quot;given&quot;}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;author&quot; .. i .. &quot;-link&quot;, &quot;author-link&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;link&quot;, &quot;authorlink&quot; .. i, &quot;author-link&quot;,  
                        &quot;authorlink&quot;}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;author&quot; .. i .. &quot;-mask&quot;, &quot;author-mask&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;mask&quot;, &quot;authormask&quot; .. i, &quot;author-mask&quot;, 
                        &quot;authormask&quot; }, 'redundant_parameters' )
                }
            else
                authors[i] = {
                    last = last,
                    first = selectone( args, {&quot;author&quot; .. i .. &quot;-first&quot;, &quot;author-first&quot; .. i, 
                        &quot;first&quot; .. i, &quot;given&quot; .. i}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;author&quot; .. i .. &quot;-link&quot;, &quot;author-link&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;link&quot;, &quot;authorlink&quot; .. i}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;author&quot; .. i .. &quot;-mask&quot;, &quot;author-mask&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;mask&quot;, &quot;authormask&quot; .. i}, 'redundant_parameters' )
                }
            end            
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

-- Gets editor list from the input arguments
function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        if i == 1 then
            last = selectone( args, {&quot;editor&quot; .. i .. &quot;-last&quot;, &quot;editor-last&quot; .. i,
                &quot;EditorSurname&quot; .. i, &quot;Editor&quot; .. i, &quot;editor&quot; .. i, &quot;editor-last&quot;, 
                &quot;EditorSurname&quot;, &quot;Editor&quot;, &quot;editor&quot;, &quot;editors&quot;}, 'redundant_parameters' );
        else
            last = selectone( args, {&quot;editor&quot; .. i .. &quot;-last&quot;, &quot;editor-last&quot; .. i,
                &quot;EditorSurname&quot; .. i, &quot;Editor&quot; .. i, &quot;editor&quot; .. i}, 'redundant_parameters' );
        end        
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            if i == 1 then
                editors[i] = {
                    last = last,
                    first = selectone( args, {&quot;editor&quot; .. i .. &quot;-first&quot;, 
                        &quot;editor-first&quot; .. i, &quot;EditorGiven&quot; .. i, &quot;editor-first&quot;, 
                        &quot;EditorGiven&quot;}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;editor&quot; .. i .. &quot;-link&quot;, &quot;editor-link&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;link&quot;, &quot;editorlink&quot; .. i, &quot;editor-link&quot;, 
                        &quot;editorlink&quot;}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;editor&quot; .. i .. &quot;-mask&quot;, &quot;editor-mask&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;mask&quot;, &quot;editormask&quot; .. i, &quot;editor-mask&quot;,  
                        &quot;editormask&quot;}, 'redundant_parameters' )
                }                
            else
                editors[i] = {
                    last = last,
                    first = selectone( args, {&quot;editor&quot; .. i .. &quot;-first&quot;, 
                        &quot;editor-first&quot; .. i, &quot;EditorGiven&quot; .. i}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;editor&quot; .. i .. &quot;-link&quot;, &quot;editor-link&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;link&quot;, &quot;editorlink&quot; .. i}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;editor&quot; .. i .. &quot;-mask&quot;, &quot;editor-mask&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;mask&quot;, &quot;editormask&quot; .. i}, 'redundant_parameters' )
                }
            end
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
    local id_list = {};
    
    for k, v in pairs( cfg.id_handlers ) do    
        id_list[k] = selectone( args, v.parameters, 'redundant_parameters' );
    end

    return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
    local handler;
    local new_list = {};
    
    for k, v in pairs( id_list ) do
        handler = {};
        
        --Becasue cfg is read-only we have to copy it the hard way.
        for k2, v2 in pairs( cfg.id_handlers[k] ) do
            handler[k2] = v2;
        end
        handler['id'] = v;
        
        if handler.mode == 'external' then        
            table.insert( new_list, {handler.label, externallinkid( handler ) } );
        elseif handler.mode == 'internal' then
            table.insert( new_list, {handler.label, internallinkid( handler ) } );
        elseif handler.mode == 'manual' then
            if k == 'DOI' then
                table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
            elseif k == 'ASIN' then
                table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
            elseif k == 'OL' then
                table.insert( new_list, {handler.label, openlibrary( v ) } );
            elseif k == 'ISBN' then
                local ISBN = internallinkid( handler );
                if not checkisbn( v ) then 
                    ISBN = ISBN .. seterror( 'bad_isbn' );
                end
                table.insert( new_list, {handler.label, ISBN } );                
            else
                error( cfg.message_list['unknown_manual_ID'] );
            end            
        else
            error( cfg.message_list['unknown_ID_mode'] );
        end
    end

    function comp( a, b )
        return a[1] &lt; b[1];
    end

    table.sort( new_list, comp );
    for k, v in ipairs( new_list ) do
        new_list[k] = v[2];
    end
    
    return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition )
    local value = nil;
    local selected = '';
    local error_list = {};
    
    for _, v in ipairs( possible ) do
        if args[v] ~= nil then
            if value ~= nil then
                table.insert( error_list, v );
            else
                value = args[v];
                selected = v;
            end
        end
    end
            
    if #error_list &gt; 0 then
        local error_str = &quot;&quot;;
        for _, k in ipairs( error_list ) do
            if error_str ~= &quot;&quot; then error_str = error_str .. &quot;, &quot; end
            error_str = error_str .. &quot;&lt;code&gt;|&quot; .. k .. &quot;=&lt;/code&gt;&quot;;
        end
        if #error_list &gt; 1 then
            error_str = error_str .. &quot;, and &quot;;
        else
            error_str = error_str .. &quot; and &quot;;
        end
        error_str = error_str .. &quot;&lt;code&gt;|&quot; .. selected .. &quot;=&lt;/code&gt;&quot;;
        table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
    end
            
    return value, selected;
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    -- Load Input Parameters

    local i 
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = args.authors
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = selectone( args, {'chapter', 'contribution', 'entry' }, 'redundant_parameters' );
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url or args.URL
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl or args[&quot;contribution-url&quot;]
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = selectone( args, {'journal', 'newspaper', 'magazine', 'work', 'website', 
        'periodical', 'encyclopedia', 'encyclopaedia'}, 'redundant_parameters' );
            
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = nil          
            TransTitle = nil
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = nil 
                TransTitle = nil
            end
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = nil end
        end
    end
    local Series = selectone( args, {'series', 'version'}, 'redundant_parameters' );
    local Volume = args.volume
    local Issue = selectone( args, {'issue', 'number'}, 'redundant_parameters' );
    local Position = nil
    local Page, Pages, At, page_type;
    
    Page, page_type = selectone( args, {'p', 'page', 'pp', 'pages', 'at'}, 
        'extra_pages' );
    if page_type == 'pp' or page_type == 'pages' then
        Pages = hyphentodash( Page );
        Page = nil;
    elseif page_type == 'at' then
        At = Page;
        Page = nil;
    end
                
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace 
    local Place = selectone( args, {'place', 'location'}, 'redundant_parameters' );
    if PublicationPlace == nil and Place ~= nil then 
        PublicationPlace = Place;
    end
    if PublicationPlace == Place then Place = nil end
    
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl or &quot;yes&quot;           -- Only used is ArchiveURL is present.
    local Language = selectone( args, {'language', 'in'}, 'redundant_parameters' );
    local Format = args.format
    local Ref = args.ref or args.Ref

    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = selectone( args, {'id', 'ID', 'docket'}, 'redundant_parameters' );
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]

    local ID_list = extractids( args );
    
    local Quote = selectone( args, {'quote', 'quotation'}, 'redundant_parameters' );
    local PostScript = args.postscript or &quot;.&quot;
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator or &quot;.&quot;
    local LastAuthorAmp = args.lastauthoramp
    local no_tracking_cats = args[&quot;template doc demo&quot;] or args.nocat or 
            args.notracking or args[&quot;no-tracking&quot;] or &quot;&quot;;

    if ( config.CitationClass == &quot;journal&quot; ) then        
        if (URL == nil or URL == &quot;&quot;) then
            if (ID_list['PMC'] ~= nil) then 
                local Embargo = args.embargo or args.Embargo;
                if Embargo ~= nil then
                    local lang = mw.getContentLanguage();
                    local good1, result1, good2, result2;
                    good1, result1 = pcall( lang.formatDate, lang, 'U', Embargo );
                    good2, result2 = pcall( lang.formatDate, lang, 'U' );

                    if good1 and good2 and tonumber( result1 ) &lt; tonumber( result2 ) then 
                        URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];
                    end
                else
                    URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];           
                end
            end
        end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, cfg.message_list[&quot;episode&quot;] .. &quot; &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, cfg.message_list[&quot;season&quot;] .. &quot; &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, cfg.message_list[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows 
    -- automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
        if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    
    for k, v in pairs( ID_list ) do
        if string.sub( cfg.id_handlers[k].COinS or &quot;info&quot;, 1, 4 ) ~= 'info' then
            OCinSdata[ cfg.id_handlers[k].COinS ] = v;
        end
    end
    
    OCinSdata.rft_id = URL or ChapterURL

    local last, first;
    local OCinSauthors = {};
    for k, v in ipairs( a ) do
        last = v.last;
        first = v.first;
        if k == 1 then
            if last ~= nil then
                OCinSdata[&quot;rft.aulast&quot;] = last;
            end
            if first ~= nil then 
                OCinSdata[&quot;rft.aufirst&quot;] = first;
            end
        end
        if last ~= nil and first ~= nil then
            table.insert( OCinSauthors, last .. (args.NameSep or &quot;, &quot;) .. first );
    	elseif last ~= nil then
            table.insert( OCinSauthors, last );
        end
    end

    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    for k, v in pairs( ID_list ) do
        if string.sub( cfg.id_handlers[k].COinS or &quot;&quot;, 1, 4 ) == 'info' then
            OCinSids[ cfg.id_handlers[k].COinS ] = v;
        end
    end

    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    for _, value in ipairs(OCinSauthors) do
        OCinStitle = OCinStitle .. &quot;&amp;rft.au=&quot; .. mw.uri.encode(value)
    end
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    
    local this_page = mw.title.getCurrentTitle();
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/&quot; .. mw.site.server:match( &quot;[^/]*$&quot; ) .. &quot;:&quot;
       .. this_page.prefixedText  -- end COinS data by page's non-encoded pagename

    if (Periodical ~= nil and Periodical ~= &quot;&quot;) and
        (Chapter == nil or Chapter == '') and
        (Title ~= nil and Title ~= &quot;&quot;) then
            Chapter = Title
            ChapterLink = TitleLink
            TransChapter = TransTitle
            Title = nil
            TitleLink = nil
            TransTitle = nil            
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local Maximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors);
        
        -- Preserve old-style implicit et al.
        if Maximum == nil and #a == 9 then 
            Maximum = 8;
            table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
        elseif Maximum == nil then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = (args[&quot;author-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = args[&quot;author-format&quot;] or args.authorformat,
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        }
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if Coauthors ~= nil and Coauthors ~= &quot;&quot; then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
                
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local Maximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors);

        -- Preserve old-style implicit et al.
        if Maximum == nil and #e == 4 then 
            Maximum = 3;
            table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
        elseif Maximum == nil then
            Maximum = #e + 1;
        end

        local control = { 
            sep = (args[&quot;editor-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = args[&quot;editor-format&quot;] or args.editorformat,
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
            }

        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date
    
    if ( URL == nil or URL == '' ) and
            ( ChapterURL == nil or ChapterURL == '' ) and
            ( ArchiveURL == nil or ArchiveURL == '' ) and                
            ( ConferenceURL == nil or ConferenceURL == '' ) and                
            ( TranscriptURL == nil or TranscriptURL == '' ) then

        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
        end

        -- Test if accessdate is given without giving a URL
        if ( AccessDate ~= nil and AccessDate ~= '' ) then
            table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
            AccessDate = nil;
        end      
    
        -- Test if format is given without giving a URL
        if ( Format ~= nil and Format ~= '' ) then
            Format = Format .. seterror( 'format_missing_url' );
        end        
    end    

    -- Test if citation has no title
    if ( Chapter == nil or Chapter == &quot;&quot; ) and 
            ( Title == nil or Title == &quot;&quot; ) and
            ( Periodical == nil or Periodical == &quot;&quot; ) and
            ( Conference == nil or Conference == &quot;&quot; ) and 
            ( TransTitle == nil or TransTitle == &quot;&quot; ) and
            ( TransChapter == nil or TransChapter == &quot;&quot; ) then
        table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
    end

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
        end
    end

    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
        
    -- Format chapter / article title
    if ( Chapter ~= nil and Chapter ~= &quot;&quot; ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) and (Title ~= nil and Title ~= &quot;&quot; )
        then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
    else
        Chapter = &quot;&quot;;
    end
    if TransChapter ~= &quot;&quot; and Chapter == &quot;&quot; then
        TransChapter = TransChapter .. seterror( 'trans_missing_chapter' );
    end
    Chapter = Chapter .. TransChapter
    if Chapter ~= &quot;&quot; then
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
                if URL == nil or URL == &quot;&quot; then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        elseif ChapterURL ~= nil and ChapterURL ~= &quot;&quot; then
            Chapter = Chapter .. &quot; [&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( ChapterURL ) .. &quot;]&quot; .. 
                seterror( 'bare_url_missing_title' );
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    elseif ChapterURL ~= nil and ChapterURL ~= &quot;&quot; then
        Chapter = &quot; [&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( ChapterURL ) .. &quot;]&quot; .. 
            seterror( 'bare_url_missing_title' ) .. sepc .. &quot; &quot;;
    end        
    
    -- Format main title.
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
                or config.CitationClass == &quot;news&quot; 
                or config.CitationClass == &quot;pressrelease&quot; ) and 
                Chapter == &quot;&quot; then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
    else
        Title = &quot;&quot;;
    end    
    if TransTitle ~= &quot;&quot; and Title == &quot;&quot; then
        TransTitle = TransTitle .. seterror( 'trans_missing_title' );
    end
    Title = Title .. TransTitle
    if Title ~= &quot;&quot; then
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    end

    if ( Place ~= nil and Place ~= &quot;&quot; ) then
        if sepc == '.' then
            Place = &quot; &quot; .. cfg.message_list['written'] .. &quot; &quot; .. Place .. sepc .. &quot; &quot;;
        else
            Place = &quot; &quot; .. cfg.message_list['written']:lower() .. &quot; &quot; .. Place .. sepc .. &quot; &quot;;
        end            
    else
        Place = &quot;&quot;;
    end
    
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    elseif ConferenceURL ~= nil and ConferenceURL ~= &quot;&quot; then
        Conference = &quot; [&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( ConferenceURL ) .. &quot;]&quot; .. 
            seterror( 'bare_url_missing_title' );
    else
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.message_list['minutes'];
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption 
                if TimeCaption == nil then
                    TimeCaption = cfg.message_list['event'];
                    if sepc ~= '.' then
                        TimeCaption = TimeCaption:lower();
                    end
                end                
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (&quot; .. cfg.message_list['in'] .. &quot; &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; &quot; .. cfg.message_list['edition'] .. &quot;)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; &quot; .. cfg.message_list['via'] .. &quot; &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; &quot; .. cfg.message_list['retrieved'] .. &quot; &quot;
         if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
             .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.message_list['subscription'];
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end

    ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD} );

    if ( URL ~= nil and URL ~=&quot;&quot;) then
        URL = &quot; &quot; .. &quot;[&quot; .. URL .. &quot; &quot; .. mw.text.nowiki(URL) .. &quot;]&quot;;
        local error_text = seterror( 'bare_url_missing_title' );
        if config.CitationClass == &quot;web&quot; then
            URL = URL .. &quot; &quot; .. seterror( 'cite_web_title' );
        else
            URL = URL .. error_text;
        end       
    else
        URL = &quot;&quot;
    end

    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot; &quot; .. seterror('archive_missing_date') .. &quot; &quot;
        end
        local arch_text = &quot; &quot; .. cfg.message_list['archived'];
        if (sepc ~= &quot;.&quot;) then arch_text = arch_text:lower() end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] &quot; .. 
                cfg.message_list['from'] .. &quot; &quot; .. cfg.message_list['original'] .. &quot; &quot; .. 
                cfg.message_list['on'] .. ArchiveDate
            if OriginalURL == nil or OriginalUrl == '' then
                Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url_not_dead');                               
            end
        else
            if OriginalURL ~= nil and OriginalURL ~= '' then
                Archived = sepc .. arch_text .. &quot; &quot; .. cfg.message_list['from'] .. &quot; [&quot; .. OriginalURL .. &quot; &quot; .. 
                    cfg.message_list['original'] .. &quot;] &quot; .. cfg.message_list['on'] .. ArchiveDate
            else
                if config.CitationClass ~= 'web' then 
                    Archived = sepc .. arch_text .. &quot; &quot; .. cfg.message_list['from'] .. &quot; &quot; .. 
                    seterror('archive_missing_url') .. &quot; &quot; .. cfg.message_list['on'] .. ArchiveDate
                else
                    Archived = sepc .. arch_text .. &quot; &quot; .. cfg.message_list['from'] .. 
                        &quot; &quot; .. cfg.message_list['original'] .. &quot; &quot; .. 
                        cfg.message_list['on'] .. ArchiveDate
                end
            end                
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        if sepc == '.' then
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; &quot; .. cfg.message_list['lay summary'] .. &quot;]&quot; .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; &quot; .. cfg.message_list['lay summary']:lower() .. &quot;]&quot; .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    elseif TranscriptURL ~= nil and TranscriptURL ~= &quot;&quot; then
        Transcript = &quot;[&quot; .. TranscriptURL .. &quot; &quot; .. safeforurl( TranscriptURL ) .. &quot;]&quot; .. 
            seterror( 'bare_url_missing_title' )        
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; and
         config.CitationClass ~= &quot;pressrelease&quot; ) then
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            if Publisher ~= '' then
                Publisher = Publisher .. &quot;, &quot; .. cfg.message_list['published'] .. &quot; &quot; .. PublicationDate;
            else
                Publisher = PublicationDate;
            end
        end
        if Publisher ~= &quot;&quot; then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (&quot; .. cfg.message_list['published'] .. &quot; &quot; .. PublicationDate .. &quot;)&quot;
        else 
            PublicationDate = &quot;&quot;
        end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot; ) or ( TitleNote and TitleNote ~= &quot;&quot; ) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( ( (config.CitationClass == &quot;journal&quot;) or (config.CitationClass == &quot;citation&quot;) )  and
         Periodical ~= &quot;&quot; ) then
        if (Others ~= &quot;&quot;) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
            Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
            Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
    end
    
    if #ID_list &gt; 0 then
        ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
    else
        ID_list = ID;
    end    
    local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );

    local text
    local pgtext = Page .. Pages .. At
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, &quot; .. cfg.message_list['editor'];
            else
                Editors = Editors .. &quot;, &quot; .. cfg.message_list['editors'];
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (&quot; .. cfg.message_list['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (&quot; .. cfg.message_list['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end -- endif &quot;&quot;~=Date
        if ( config.CitationClass==&quot;journal&quot; and Periodical ) then
          text = safejoin( {Chapter, Place, tcommon}, sepc );
          text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
          text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
          text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if PostScript ~= '' and PostScript ~= nil and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local options = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        options.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = {};
        text = seterror('empty_citation');
        z.message_tail = {};
    end
    
    if options.id ~= nil then 
        text = '&lt;span id=&quot;' .. wikiescape(options.id) ..'&quot; class=&quot;' .. wikiescape(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    else
        text = '&lt;span class=&quot;' .. wikiescape(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    end        

    local empty_span = '&lt;span style=&quot;display: none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = '&lt;span title=&quot;' .. wikiescape(OCinStitle) .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        for i,v in ipairs( z.message_tail ) do
            if i == #z.message_tail then
                text = text .. errorcomment( v[1], v[2] );
            else
                text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
            end
        end
    end
    
    if no_tracking_cats == '' then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    local suggestions = {};
    local error_text, error_state;
    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            if not validate( k ) then            
                if type( k ) ~= 'string' then
                    -- Exclude empty numbered parameters
                    if v:match(&quot;%S+&quot;) ~= nil then
                        error_text, error_state = seterror( 'text_ignored', {v}, true );
                    end
                elseif validate( k:lower() ) then 
                    error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
                else
                    if #suggestions == 0 then
                        suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
                    end
                    if suggestions[ k:lower() ] ~= nil then
                        error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
                    else
                        error_text, error_state = seterror( 'parameter_ignored', {k}, true );
                    end
                end                  
                if error_text ~= '' then
                    table.insert( z.message_tail, {error_text, error_state} );
                end                
            end            
            args[k] = v;
        elseif k == 'postscript' then
            args[k] = v;
        end        
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        if args[k] == nil and (v ~= '' or k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--18Mar2013 Fixed &quot;page=&quot; to override &quot;pages=&quot; as in markup-based cites.
--19Mar2013 Fixed date of class=journal Periodical to show after page.
--19Mar2013 Changed null &quot;postscript=&quot; to suppress end-dot of citation.
--20Mar2013 If CitationClass is journal, show &quot;others=&quot; before title.
--20Mar2013 If CitationClass is book, show &quot;others=&quot; before edition.
--20Mar2013 If CitationClass is journal, adjust &quot;others=&quot; to have sepc.
--20Mar2013 For class &quot;journal&quot;, use book format unless Periodical set.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; after wikilink &quot;.]]&quot; end dot.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; after external &quot;.]&quot; end dot.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; at italic wikilink &quot;.]]&quot; end.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; at italic external &quot;.]&quot; end.
--04Apr2013 Moved sepc before &lt;span class=&quot;reference-accessdate&quot;&gt; for &quot;..&quot;.
--
--End</text>
      <sha1>4y7eq9di2abms4xgj7lrvvoqwj5ji4z</sha1>
    </revision>
    <revision>
      <id>4643</id>
      <parentid>4642</parentid>
      <timestamp>2013-04-09T21:40:16Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>fix script error caused by abandoned error check.</comment>
      <origin>4643</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="67249" sha1="f3vukcj8bhoqymgibgmbfjr4bgjkcab" xml:space="preserve">local z = {
    error_categories = {};
    message_tail = {};
}

-- Include translation message hooks, ID and error handling configuration settings.
local cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );
 
-- Contains a list of all recognized parameters
local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );

-- Checks that parameter name is valid
function validate( name )
    name = tostring( name );
    
    -- Normal arguments
    if whitelist.basic_arguments[ name ] then
        return true;
    end
    
    -- Arguments with numbers in them
    name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );
    if whitelist.numbered_arguments[ name ] then
        return true;
    end
    
    -- Not found, argument not supported.
    return false
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
    if hidden then 
        return '&lt;span style=&quot;display:none;font-size:100%&quot; class=&quot;error citation-comment&quot;&gt;' .. content .. '&lt;/span&gt;';
    else
        return '&lt;span style=&quot;font-size:100%&quot; class=&quot;error&quot;&gt;' .. content .. '&lt;/span&gt;';
    end        
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, args, raw )
    local error_state = cfg.error_conditions[ error_id ];

    if error_state == nil then
        error( cfg.message_list['undefined_error'] );
    end
    
    if error_state.category ~= nil and error_state.category ~= &quot;&quot; then
        table.insert( z.error_categories, error_state.category );
    end
    
    local message = error_state.message;
    if args ~= nil then
        for k, m in ipairs( args ) do
            message = message:gsub( &quot;$&quot; .. k .. &quot;(%D)&quot;, m .. &quot;%1&quot; );
        end
    end

    message = wikiescape(message) .. &quot; ([[&quot; .. cfg.message_list['help page link'] .. 
        &quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
        cfg.message_list['help page label'] .. &quot;]])&quot;;

    if raw == true then
        return message, error_state.hidden;
    end
        
    return errorcomment( message, error_state.hidden );
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',    
            ['{'] = '&amp;#123;',    
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

-- Formats a wiki style external link
function externallinkid(options)
    local sep = options.separator or &quot;&amp;nbsp;&quot;
    options.suffix = options.suffix or &quot;&quot;
    local url_string = options.id
    if options.encode == true or options.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    return &quot;[[&quot; .. options.link .. &quot;|&quot; .. options.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. 
            options.prefix .. url_string .. options.suffix .. &quot; &quot; .. mw.text.nowiki(options.id) .. &quot;]&quot;
end

-- Formats a wiki style internal link
function internallinkid(options)
    local sep = options.separator or &quot;&amp;nbsp;&quot;
    options.suffix = options.suffix or &quot;&quot;
    return &quot;[[&quot; .. options.link .. &quot;|&quot; .. options.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. 
            options.prefix .. options.id .. options.suffix .. &quot;|&quot; .. mw.text.nowiki(options.id) .. &quot;]]&quot;
end

-- Formats a link to Amazon
function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local handler = cfg.id_handlers['ASIN'];
    return externallinkid({link = handler.link,
        label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
        encode=handler.encode, separator = handler.separator})
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    local handler = cfg.id_handlers['DOI'];
    
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (&quot; .. cfg.message_list['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link = handler.link, label = handler.label,
            prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then      
        cat = seterror( 'bad_doi' );
    end
    return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    local handler = cfg.id_handlers['OL'];
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    else
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode}) .. 
            ' ' .. seterror( 'bad_ol' );
    end
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
    isbn_str = isbn_str:gsub(&quot;[- ]&quot;, &quot;&quot;):upper();
    local len = isbn_str:len();
 
    if len ~= 10 and len ~= 13 then
        return false;
    end
 
    local temp = 0;
    if len == 10 then
        if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            if v == string.byte( &quot;X&quot; ) then
                temp = temp + 10*( 11 - i );
            else
                temp = temp + tonumber( string.char(v) )*(11-i);
            end
        end
        return temp % 11 == 0;
    else
        if isbn_str:match( &quot;^%d*$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
        end
        return temp % 10 == 0;
    end
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    if str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then 
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    -- Is the input a simple number?
    local num = tonumber( str ); 
    if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
        return str;
    else
        -- Use formatDate to interpret more complicated formats
        local lang = mw.getContentLanguage();
        local good, result;
        good, result = pcall( lang.formatDate, lang, 'Y', str )
        if good then 
            return result;
        else
            -- Can't make sense of this input, return blank.
            return &quot;&quot;;
        end
    end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil and first ~= '') then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    if count &gt; 1 and lastauthoramp ~= nil and lastauthoramp ~= &quot;&quot; and not etal then
        text[count-1] = text[count-1] .. &quot; &amp; &quot; .. text[count];
        text[count] = nil;
    end    
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = cfg.message_list['et al'];
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result = 
        '&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
    end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid(options)
    local P1 = options[1] or &quot;&quot;
    local P2 = options[2] or &quot;&quot;
    local P3 = options[3] or &quot;&quot;
    local P4 = options[4] or &quot;&quot;
    local P5 = options[5] or &quot;&quot;
    
    -- Bugzilla 46608
    local encoded = mw.uri.anchorEncode( P1 .. P2 .. P3 .. P4 .. P5 );
    if encoded == false then
        encoded = &quot;&quot;;
    end
    
    return &quot;CITEREF&quot; .. encoded;
end

-- Gets author list from the input arguments
function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    while true do
        if i == 1 then 
            last = selectone( args, {&quot;author&quot; .. i .. &quot;-last&quot;, &quot;author-last&quot; .. i, 
                &quot;last&quot; .. i, &quot;surname&quot; .. i, &quot;Author&quot; .. i, &quot;author&quot; .. i, 
                &quot;author-last&quot;, &quot;last&quot;, &quot;surname&quot;, &quot;Author&quot;, &quot;author&quot;, &quot;authors&quot;}, 'redundant_parameters' );
        else
            last = selectone( args, {&quot;author&quot; .. i .. &quot;-last&quot;, &quot;author-last&quot; .. i, 
                &quot;last&quot; .. i, &quot;surname&quot; .. i, &quot;Author&quot; .. i, &quot;author&quot; .. i}, 'redundant_parameters' );
        end
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            if i == 1 then 
                authors[i] = {
                    last = last,
                    first = selectone( args, {&quot;author&quot; .. i .. &quot;-first&quot;, &quot;author-first&quot; .. i, 
                        &quot;first&quot; .. i, &quot;given&quot; .. i, &quot;author-first&quot;, 
                        &quot;first&quot;, &quot;given&quot;}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;author&quot; .. i .. &quot;-link&quot;, &quot;author-link&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;link&quot;, &quot;authorlink&quot; .. i, &quot;author-link&quot;,  
                        &quot;authorlink&quot;}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;author&quot; .. i .. &quot;-mask&quot;, &quot;author-mask&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;mask&quot;, &quot;authormask&quot; .. i, &quot;author-mask&quot;, 
                        &quot;authormask&quot; }, 'redundant_parameters' )
                }
            else
                authors[i] = {
                    last = last,
                    first = selectone( args, {&quot;author&quot; .. i .. &quot;-first&quot;, &quot;author-first&quot; .. i, 
                        &quot;first&quot; .. i, &quot;given&quot; .. i}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;author&quot; .. i .. &quot;-link&quot;, &quot;author-link&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;link&quot;, &quot;authorlink&quot; .. i}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;author&quot; .. i .. &quot;-mask&quot;, &quot;author-mask&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;mask&quot;, &quot;authormask&quot; .. i}, 'redundant_parameters' )
                }
            end            
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

-- Gets editor list from the input arguments
function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        if i == 1 then
            last = selectone( args, {&quot;editor&quot; .. i .. &quot;-last&quot;, &quot;editor-last&quot; .. i,
                &quot;EditorSurname&quot; .. i, &quot;Editor&quot; .. i, &quot;editor&quot; .. i, &quot;editor-last&quot;, 
                &quot;EditorSurname&quot;, &quot;Editor&quot;, &quot;editor&quot;, &quot;editors&quot;}, 'redundant_parameters' );
        else
            last = selectone( args, {&quot;editor&quot; .. i .. &quot;-last&quot;, &quot;editor-last&quot; .. i,
                &quot;EditorSurname&quot; .. i, &quot;Editor&quot; .. i, &quot;editor&quot; .. i}, 'redundant_parameters' );
        end        
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            if i == 1 then
                editors[i] = {
                    last = last,
                    first = selectone( args, {&quot;editor&quot; .. i .. &quot;-first&quot;, 
                        &quot;editor-first&quot; .. i, &quot;EditorGiven&quot; .. i, &quot;editor-first&quot;, 
                        &quot;EditorGiven&quot;}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;editor&quot; .. i .. &quot;-link&quot;, &quot;editor-link&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;link&quot;, &quot;editorlink&quot; .. i, &quot;editor-link&quot;, 
                        &quot;editorlink&quot;}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;editor&quot; .. i .. &quot;-mask&quot;, &quot;editor-mask&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;mask&quot;, &quot;editormask&quot; .. i, &quot;editor-mask&quot;,  
                        &quot;editormask&quot;}, 'redundant_parameters' )
                }                
            else
                editors[i] = {
                    last = last,
                    first = selectone( args, {&quot;editor&quot; .. i .. &quot;-first&quot;, 
                        &quot;editor-first&quot; .. i, &quot;EditorGiven&quot; .. i}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;editor&quot; .. i .. &quot;-link&quot;, &quot;editor-link&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;link&quot;, &quot;editorlink&quot; .. i}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;editor&quot; .. i .. &quot;-mask&quot;, &quot;editor-mask&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;mask&quot;, &quot;editormask&quot; .. i}, 'redundant_parameters' )
                }
            end
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
    local id_list = {};
    
    for k, v in pairs( cfg.id_handlers ) do    
        id_list[k] = selectone( args, v.parameters, 'redundant_parameters' );
    end

    return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
    local handler;
    local new_list = {};
    
    for k, v in pairs( id_list ) do
        handler = {};
        
        --Becasue cfg is read-only we have to copy it the hard way.
        for k2, v2 in pairs( cfg.id_handlers[k] ) do
            handler[k2] = v2;
        end
        handler['id'] = v;
        
        if handler.mode == 'external' then        
            table.insert( new_list, {handler.label, externallinkid( handler ) } );
        elseif handler.mode == 'internal' then
            table.insert( new_list, {handler.label, internallinkid( handler ) } );
        elseif handler.mode == 'manual' then
            if k == 'DOI' then
                table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
            elseif k == 'ASIN' then
                table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
            elseif k == 'OL' then
                table.insert( new_list, {handler.label, openlibrary( v ) } );
            elseif k == 'ISBN' then
                local ISBN = internallinkid( handler );
                if not checkisbn( v ) then 
                    ISBN = ISBN .. seterror( 'bad_isbn' );
                end
                table.insert( new_list, {handler.label, ISBN } );                
            else
                error( cfg.message_list['unknown_manual_ID'] );
            end            
        else
            error( cfg.message_list['unknown_ID_mode'] );
        end
    end

    function comp( a, b )
        return a[1] &lt; b[1];
    end

    table.sort( new_list, comp );
    for k, v in ipairs( new_list ) do
        new_list[k] = v[2];
    end
    
    return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition )
    local value = nil;
    local selected = '';
    local error_list = {};
    
    for _, v in ipairs( possible ) do
        if args[v] ~= nil then
            if value ~= nil then
                table.insert( error_list, v );
            else
                value = args[v];
                selected = v;
            end
        end
    end
            
    if #error_list &gt; 0 then
        local error_str = &quot;&quot;;
        for _, k in ipairs( error_list ) do
            if error_str ~= &quot;&quot; then error_str = error_str .. &quot;, &quot; end
            error_str = error_str .. &quot;&lt;code&gt;|&quot; .. k .. &quot;=&lt;/code&gt;&quot;;
        end
        if #error_list &gt; 1 then
            error_str = error_str .. &quot;, and &quot;;
        else
            error_str = error_str .. &quot; and &quot;;
        end
        error_str = error_str .. &quot;&lt;code&gt;|&quot; .. selected .. &quot;=&lt;/code&gt;&quot;;
        table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
    end
            
    return value, selected;
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    -- Load Input Parameters

    local i 
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = args.authors
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = selectone( args, {'chapter', 'contribution', 'entry' }, 'redundant_parameters' );
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url or args.URL
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl or args[&quot;contribution-url&quot;]
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = selectone( args, {'journal', 'newspaper', 'magazine', 'work', 'website', 
        'periodical', 'encyclopedia', 'encyclopaedia'}, 'redundant_parameters' );
            
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = nil          
            TransTitle = nil
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = nil 
                TransTitle = nil
            end
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = nil end
        end
    end
    local Series = selectone( args, {'series', 'version'}, 'redundant_parameters' );
    local Volume = args.volume
    local Issue = selectone( args, {'issue', 'number'}, 'redundant_parameters' );
    local Position = nil
    local Page, Pages, At, page_type;
    
    Page, page_type = selectone( args, {'p', 'page', 'pp', 'pages', 'at'}, 
        'extra_pages' );
    if page_type == 'pp' or page_type == 'pages' then
        Pages = hyphentodash( Page );
        Page = nil;
    elseif page_type == 'at' then
        At = Page;
        Page = nil;
    end
                
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace 
    local Place = selectone( args, {'place', 'location'}, 'redundant_parameters' );
    if PublicationPlace == nil and Place ~= nil then 
        PublicationPlace = Place;
    end
    if PublicationPlace == Place then Place = nil end
    
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl or &quot;yes&quot;           -- Only used is ArchiveURL is present.
    local Language = selectone( args, {'language', 'in'}, 'redundant_parameters' );
    local Format = args.format
    local Ref = args.ref or args.Ref

    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = selectone( args, {'id', 'ID', 'docket'}, 'redundant_parameters' );
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]

    local ID_list = extractids( args );
    
    local Quote = selectone( args, {'quote', 'quotation'}, 'redundant_parameters' );
    local PostScript = args.postscript or &quot;.&quot;
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator or &quot;.&quot;
    local LastAuthorAmp = args.lastauthoramp
    local no_tracking_cats = args[&quot;template doc demo&quot;] or args.nocat or 
            args.notracking or args[&quot;no-tracking&quot;] or &quot;&quot;;

    if ( config.CitationClass == &quot;journal&quot; ) then        
        if (URL == nil or URL == &quot;&quot;) then
            if (ID_list['PMC'] ~= nil) then 
                local Embargo = args.embargo or args.Embargo;
                if Embargo ~= nil then
                    local lang = mw.getContentLanguage();
                    local good1, result1, good2, result2;
                    good1, result1 = pcall( lang.formatDate, lang, 'U', Embargo );
                    good2, result2 = pcall( lang.formatDate, lang, 'U' );

                    if good1 and good2 and tonumber( result1 ) &lt; tonumber( result2 ) then 
                        URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];
                    end
                else
                    URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];           
                end
            end
        end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, cfg.message_list[&quot;episode&quot;] .. &quot; &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, cfg.message_list[&quot;season&quot;] .. &quot; &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, cfg.message_list[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows 
    -- automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
        if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    
    for k, v in pairs( ID_list ) do
        if string.sub( cfg.id_handlers[k].COinS or &quot;info&quot;, 1, 4 ) ~= 'info' then
            OCinSdata[ cfg.id_handlers[k].COinS ] = v;
        end
    end
    
    OCinSdata.rft_id = URL or ChapterURL

    local last, first;
    local OCinSauthors = {};
    for k, v in ipairs( a ) do
        last = v.last;
        first = v.first;
        if k == 1 then
            if last ~= nil then
                OCinSdata[&quot;rft.aulast&quot;] = last;
            end
            if first ~= nil then 
                OCinSdata[&quot;rft.aufirst&quot;] = first;
            end
        end
        if last ~= nil and first ~= nil then
            table.insert( OCinSauthors, last .. (args.NameSep or &quot;, &quot;) .. first );
    	elseif last ~= nil then
            table.insert( OCinSauthors, last );
        end
    end

    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    for k, v in pairs( ID_list ) do
        if string.sub( cfg.id_handlers[k].COinS or &quot;&quot;, 1, 4 ) == 'info' then
            OCinSids[ cfg.id_handlers[k].COinS ] = v;
        end
    end

    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    for _, value in ipairs(OCinSauthors) do
        OCinStitle = OCinStitle .. &quot;&amp;rft.au=&quot; .. mw.uri.encode(value)
    end
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    
    local this_page = mw.title.getCurrentTitle();
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/&quot; .. mw.site.server:match( &quot;[^/]*$&quot; ) .. &quot;:&quot;
       .. this_page.prefixedText  -- end COinS data by page's non-encoded pagename

    if (Periodical ~= nil and Periodical ~= &quot;&quot;) and
        (Chapter == nil or Chapter == '') and
        (Title ~= nil and Title ~= &quot;&quot;) then
            Chapter = Title
            ChapterLink = TitleLink
            TransChapter = TransTitle
            Title = nil
            TitleLink = nil
            TransTitle = nil            
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local Maximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors);
        
        -- Preserve old-style implicit et al.
        if Maximum == nil and #a == 9 then 
            Maximum = 8;
            table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
        elseif Maximum == nil then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = (args[&quot;author-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = args[&quot;author-format&quot;] or args.authorformat,
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        }
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if Coauthors ~= nil and Coauthors ~= &quot;&quot; then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
                
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local Maximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors);

        -- Preserve old-style implicit et al.
        if Maximum == nil and #e == 4 then 
            Maximum = 3;
            table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
        elseif Maximum == nil then
            Maximum = #e + 1;
        end

        local control = { 
            sep = (args[&quot;editor-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = args[&quot;editor-format&quot;] or args.editorformat,
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
            }

        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date
    
    if ( URL == nil or URL == '' ) and
            ( ChapterURL == nil or ChapterURL == '' ) and
            ( ArchiveURL == nil or ArchiveURL == '' ) and                
            ( ConferenceURL == nil or ConferenceURL == '' ) and                
            ( TranscriptURL == nil or TranscriptURL == '' ) then

        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
        end

        -- Test if accessdate is given without giving a URL
        if ( AccessDate ~= nil and AccessDate ~= '' ) then
            table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
            AccessDate = nil;
        end      
    
        -- Test if format is given without giving a URL
        if ( Format ~= nil and Format ~= '' ) then
            Format = Format .. seterror( 'format_missing_url' );
        end        
    end    

    -- Test if citation has no title
    if ( Chapter == nil or Chapter == &quot;&quot; ) and 
            ( Title == nil or Title == &quot;&quot; ) and
            ( Periodical == nil or Periodical == &quot;&quot; ) and
            ( Conference == nil or Conference == &quot;&quot; ) and 
            ( TransTitle == nil or TransTitle == &quot;&quot; ) and
            ( TransChapter == nil or TransChapter == &quot;&quot; ) then
        table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
    end

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
        end
    end

    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
        
    -- Format chapter / article title
    if ( Chapter ~= nil and Chapter ~= &quot;&quot; ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) and (Title ~= nil and Title ~= &quot;&quot; )
        then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
    else
        Chapter = &quot;&quot;;
    end
    if TransChapter ~= &quot;&quot; and Chapter == &quot;&quot; then
        TransChapter = TransChapter .. seterror( 'trans_missing_chapter' );
    end
    Chapter = Chapter .. TransChapter
    if Chapter ~= &quot;&quot; then
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
                if URL == nil or URL == &quot;&quot; then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        elseif ChapterURL ~= nil and ChapterURL ~= &quot;&quot; then
            Chapter = Chapter .. &quot; [&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( ChapterURL ) .. &quot;]&quot; .. 
                seterror( 'bare_url_missing_title' );
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    elseif ChapterURL ~= nil and ChapterURL ~= &quot;&quot; then
        Chapter = &quot; [&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( ChapterURL ) .. &quot;]&quot; .. 
            seterror( 'bare_url_missing_title' ) .. sepc .. &quot; &quot;;
    end        
    
    -- Format main title.
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
                or config.CitationClass == &quot;news&quot; 
                or config.CitationClass == &quot;pressrelease&quot; ) and 
                Chapter == &quot;&quot; then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
    else
        Title = &quot;&quot;;
    end    
    if TransTitle ~= &quot;&quot; and Title == &quot;&quot; then
        TransTitle = TransTitle .. seterror( 'trans_missing_title' );
    end
    Title = Title .. TransTitle
    if Title ~= &quot;&quot; then
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    end

    if ( Place ~= nil and Place ~= &quot;&quot; ) then
        if sepc == '.' then
            Place = &quot; &quot; .. cfg.message_list['written'] .. &quot; &quot; .. Place .. sepc .. &quot; &quot;;
        else
            Place = &quot; &quot; .. cfg.message_list['written']:lower() .. &quot; &quot; .. Place .. sepc .. &quot; &quot;;
        end            
    else
        Place = &quot;&quot;;
    end
    
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    elseif ConferenceURL ~= nil and ConferenceURL ~= &quot;&quot; then
        Conference = &quot; [&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( ConferenceURL ) .. &quot;]&quot; .. 
            seterror( 'bare_url_missing_title' );
    else
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.message_list['minutes'];
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption 
                if TimeCaption == nil then
                    TimeCaption = cfg.message_list['event'];
                    if sepc ~= '.' then
                        TimeCaption = TimeCaption:lower();
                    end
                end                
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (&quot; .. cfg.message_list['in'] .. &quot; &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; &quot; .. cfg.message_list['edition'] .. &quot;)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; &quot; .. cfg.message_list['via'] .. &quot; &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; &quot; .. cfg.message_list['retrieved'] .. &quot; &quot;
         if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
             .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.message_list['subscription'];
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end

    ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD} );

    if ( URL ~= nil and URL ~=&quot;&quot;) then
        URL = &quot; &quot; .. &quot;[&quot; .. URL .. &quot; &quot; .. mw.text.nowiki(URL) .. &quot;]&quot;;
        local error_text = seterror( 'bare_url_missing_title' );
        if config.CitationClass == &quot;web&quot; then
            URL = URL .. &quot; &quot; .. seterror( 'cite_web_title' );
        else
            URL = URL .. error_text;
        end       
    else
        URL = &quot;&quot;
    end

    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot; &quot; .. seterror('archive_missing_date') .. &quot; &quot;
        end
        local arch_text = &quot; &quot; .. cfg.message_list['archived'];
        if (sepc ~= &quot;.&quot;) then arch_text = arch_text:lower() end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] &quot; .. 
                cfg.message_list['from'] .. &quot; &quot; .. cfg.message_list['original'] .. &quot; &quot; .. 
                cfg.message_list['on'] .. ArchiveDate
            if OriginalURL == nil or OriginalUrl == '' then
                Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url_not_dead');                               
            end
        else
            if OriginalURL ~= nil and OriginalURL ~= '' then
                Archived = sepc .. arch_text .. &quot; &quot; .. cfg.message_list['from'] .. &quot; [&quot; .. OriginalURL .. &quot; &quot; .. 
                    cfg.message_list['original'] .. &quot;] &quot; .. cfg.message_list['on'] .. ArchiveDate
            else
                if config.CitationClass ~= 'web' then 
                    Archived = sepc .. arch_text .. &quot; &quot; .. cfg.message_list['from'] .. &quot; &quot; .. 
                    seterror('archive_missing_url') .. &quot; &quot; .. cfg.message_list['on'] .. ArchiveDate
                else
                    Archived = sepc .. arch_text .. &quot; &quot; .. cfg.message_list['from'] .. 
                        &quot; &quot; .. cfg.message_list['original'] .. &quot; &quot; .. 
                        cfg.message_list['on'] .. ArchiveDate
                end
            end                
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        if sepc == '.' then
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; &quot; .. cfg.message_list['lay summary'] .. &quot;]&quot; .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; &quot; .. cfg.message_list['lay summary']:lower() .. &quot;]&quot; .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    elseif TranscriptURL ~= nil and TranscriptURL ~= &quot;&quot; then
        Transcript = &quot;[&quot; .. TranscriptURL .. &quot; &quot; .. safeforurl( TranscriptURL ) .. &quot;]&quot; .. 
            seterror( 'bare_url_missing_title' )        
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; and
         config.CitationClass ~= &quot;pressrelease&quot; ) then
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            if Publisher ~= '' then
                Publisher = Publisher .. &quot;, &quot; .. cfg.message_list['published'] .. &quot; &quot; .. PublicationDate;
            else
                Publisher = PublicationDate;
            end
        end
        if Publisher ~= &quot;&quot; then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (&quot; .. cfg.message_list['published'] .. &quot; &quot; .. PublicationDate .. &quot;)&quot;
        else 
            PublicationDate = &quot;&quot;
        end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot; ) or ( TitleNote and TitleNote ~= &quot;&quot; ) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( ( (config.CitationClass == &quot;journal&quot;) or (config.CitationClass == &quot;citation&quot;) )  and
         Periodical ~= &quot;&quot; ) then
        if (Others ~= &quot;&quot;) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
            Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
            Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
    end
    
    if #ID_list &gt; 0 then
        ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
    else
        ID_list = ID;
    end    
    local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );

    local text
    local pgtext = Page .. Pages .. At
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, &quot; .. cfg.message_list['editor'];
            else
                Editors = Editors .. &quot;, &quot; .. cfg.message_list['editors'];
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (&quot; .. cfg.message_list['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (&quot; .. cfg.message_list['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end -- endif &quot;&quot;~=Date
        if ( config.CitationClass==&quot;journal&quot; and Periodical ) then
          text = safejoin( {Chapter, Place, tcommon}, sepc );
          text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
          text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
          text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if PostScript ~= '' and PostScript ~= nil and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local options = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        options.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = {};
        text = seterror('empty_citation');
        z.message_tail = {};
    end
    
    if options.id ~= nil then 
        text = '&lt;span id=&quot;' .. wikiescape(options.id) ..'&quot; class=&quot;' .. wikiescape(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    else
        text = '&lt;span class=&quot;' .. wikiescape(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    end        

    local empty_span = '&lt;span style=&quot;display: none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = '&lt;span title=&quot;' .. wikiescape(OCinStitle) .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        for i,v in ipairs( z.message_tail ) do
            if i == #z.message_tail then
                text = text .. errorcomment( v[1], v[2] );
            else
                text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
            end
        end
    end
    
    if no_tracking_cats == '' then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    local suggestions = {};
    local error_text, error_state;
    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            if not validate( k ) then            
                error_text = &quot;&quot;;
                if type( k ) ~= 'string' then
                    -- Exclude empty numbered parameters
                    if v:match(&quot;%S+&quot;) ~= nil then
                        error_text, error_state = seterror( 'text_ignored', {v}, true );
                    end
                elseif validate( k:lower() ) then 
                    error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
                else
                    if #suggestions == 0 then
                        suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
                    end
                    if suggestions[ k:lower() ] ~= nil then
                        error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
                    else
                        error_text, error_state = seterror( 'parameter_ignored', {k}, true );
                    end
                end                  
                if error_text ~= '' then
                    table.insert( z.message_tail, {error_text, error_state} );
                end                
            end            
            args[k] = v;
        elseif k == 'postscript' then
            args[k] = v;
        end        
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        if args[k] == nil and (v ~= '' or k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--18Mar2013 Fixed &quot;page=&quot; to override &quot;pages=&quot; as in markup-based cites.
--19Mar2013 Fixed date of class=journal Periodical to show after page.
--19Mar2013 Changed null &quot;postscript=&quot; to suppress end-dot of citation.
--20Mar2013 If CitationClass is journal, show &quot;others=&quot; before title.
--20Mar2013 If CitationClass is book, show &quot;others=&quot; before edition.
--20Mar2013 If CitationClass is journal, adjust &quot;others=&quot; to have sepc.
--20Mar2013 For class &quot;journal&quot;, use book format unless Periodical set.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; after wikilink &quot;.]]&quot; end dot.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; after external &quot;.]&quot; end dot.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; at italic wikilink &quot;.]]&quot; end.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; at italic external &quot;.]&quot; end.
--04Apr2013 Moved sepc before &lt;span class=&quot;reference-accessdate&quot;&gt; for &quot;..&quot;.
--
--End</text>
      <sha1>f3vukcj8bhoqymgibgmbfjr4bgjkcab</sha1>
    </revision>
    <revision>
      <id>4644</id>
      <parentid>4643</parentid>
      <timestamp>2013-04-09T21:56:12Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>escape values that look like Lua back patterns</comment>
      <origin>4644</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="67289" sha1="9clzikuhukq0tup0zazqyj8kbdu4wvs" xml:space="preserve">local z = {
    error_categories = {};
    message_tail = {};
}

-- Include translation message hooks, ID and error handling configuration settings.
local cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );
 
-- Contains a list of all recognized parameters
local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );

-- Checks that parameter name is valid
function validate( name )
    name = tostring( name );
    
    -- Normal arguments
    if whitelist.basic_arguments[ name ] then
        return true;
    end
    
    -- Arguments with numbers in them
    name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );
    if whitelist.numbered_arguments[ name ] then
        return true;
    end
    
    -- Not found, argument not supported.
    return false
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
    if hidden then 
        return '&lt;span style=&quot;display:none;font-size:100%&quot; class=&quot;error citation-comment&quot;&gt;' .. content .. '&lt;/span&gt;';
    else
        return '&lt;span style=&quot;font-size:100%&quot; class=&quot;error&quot;&gt;' .. content .. '&lt;/span&gt;';
    end        
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, args, raw )
    local error_state = cfg.error_conditions[ error_id ];

    if error_state == nil then
        error( cfg.message_list['undefined_error'] );
    end
    
    if error_state.category ~= nil and error_state.category ~= &quot;&quot; then
        table.insert( z.error_categories, error_state.category );
    end
    
    local message = error_state.message;
    if args ~= nil then
        for k, m in ipairs( args ) do
            m = m:gsub( &quot;%%&quot;, &quot;%%%%&quot; );
            message = message:gsub( &quot;$&quot; .. k .. &quot;(%D)&quot;, m .. &quot;%1&quot; );
        end
    end

    message = wikiescape(message) .. &quot; ([[&quot; .. cfg.message_list['help page link'] .. 
        &quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
        cfg.message_list['help page label'] .. &quot;]])&quot;;

    if raw == true then
        return message, error_state.hidden;
    end
        
    return errorcomment( message, error_state.hidden );
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',    
            ['{'] = '&amp;#123;',    
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

-- Formats a wiki style external link
function externallinkid(options)
    local sep = options.separator or &quot;&amp;nbsp;&quot;
    options.suffix = options.suffix or &quot;&quot;
    local url_string = options.id
    if options.encode == true or options.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    return &quot;[[&quot; .. options.link .. &quot;|&quot; .. options.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. 
            options.prefix .. url_string .. options.suffix .. &quot; &quot; .. mw.text.nowiki(options.id) .. &quot;]&quot;
end

-- Formats a wiki style internal link
function internallinkid(options)
    local sep = options.separator or &quot;&amp;nbsp;&quot;
    options.suffix = options.suffix or &quot;&quot;
    return &quot;[[&quot; .. options.link .. &quot;|&quot; .. options.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. 
            options.prefix .. options.id .. options.suffix .. &quot;|&quot; .. mw.text.nowiki(options.id) .. &quot;]]&quot;
end

-- Formats a link to Amazon
function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local handler = cfg.id_handlers['ASIN'];
    return externallinkid({link = handler.link,
        label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
        encode=handler.encode, separator = handler.separator})
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    local handler = cfg.id_handlers['DOI'];
    
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (&quot; .. cfg.message_list['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link = handler.link, label = handler.label,
            prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then      
        cat = seterror( 'bad_doi' );
    end
    return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    local handler = cfg.id_handlers['OL'];
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    else
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode}) .. 
            ' ' .. seterror( 'bad_ol' );
    end
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
    isbn_str = isbn_str:gsub(&quot;[- ]&quot;, &quot;&quot;):upper();
    local len = isbn_str:len();
 
    if len ~= 10 and len ~= 13 then
        return false;
    end
 
    local temp = 0;
    if len == 10 then
        if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            if v == string.byte( &quot;X&quot; ) then
                temp = temp + 10*( 11 - i );
            else
                temp = temp + tonumber( string.char(v) )*(11-i);
            end
        end
        return temp % 11 == 0;
    else
        if isbn_str:match( &quot;^%d*$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
        end
        return temp % 10 == 0;
    end
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    if str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then 
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    -- Is the input a simple number?
    local num = tonumber( str ); 
    if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
        return str;
    else
        -- Use formatDate to interpret more complicated formats
        local lang = mw.getContentLanguage();
        local good, result;
        good, result = pcall( lang.formatDate, lang, 'Y', str )
        if good then 
            return result;
        else
            -- Can't make sense of this input, return blank.
            return &quot;&quot;;
        end
    end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil and first ~= '') then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    if count &gt; 1 and lastauthoramp ~= nil and lastauthoramp ~= &quot;&quot; and not etal then
        text[count-1] = text[count-1] .. &quot; &amp; &quot; .. text[count];
        text[count] = nil;
    end    
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = cfg.message_list['et al'];
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result = 
        '&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
    end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid(options)
    local P1 = options[1] or &quot;&quot;
    local P2 = options[2] or &quot;&quot;
    local P3 = options[3] or &quot;&quot;
    local P4 = options[4] or &quot;&quot;
    local P5 = options[5] or &quot;&quot;
    
    -- Bugzilla 46608
    local encoded = mw.uri.anchorEncode( P1 .. P2 .. P3 .. P4 .. P5 );
    if encoded == false then
        encoded = &quot;&quot;;
    end
    
    return &quot;CITEREF&quot; .. encoded;
end

-- Gets author list from the input arguments
function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    while true do
        if i == 1 then 
            last = selectone( args, {&quot;author&quot; .. i .. &quot;-last&quot;, &quot;author-last&quot; .. i, 
                &quot;last&quot; .. i, &quot;surname&quot; .. i, &quot;Author&quot; .. i, &quot;author&quot; .. i, 
                &quot;author-last&quot;, &quot;last&quot;, &quot;surname&quot;, &quot;Author&quot;, &quot;author&quot;, &quot;authors&quot;}, 'redundant_parameters' );
        else
            last = selectone( args, {&quot;author&quot; .. i .. &quot;-last&quot;, &quot;author-last&quot; .. i, 
                &quot;last&quot; .. i, &quot;surname&quot; .. i, &quot;Author&quot; .. i, &quot;author&quot; .. i}, 'redundant_parameters' );
        end
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            if i == 1 then 
                authors[i] = {
                    last = last,
                    first = selectone( args, {&quot;author&quot; .. i .. &quot;-first&quot;, &quot;author-first&quot; .. i, 
                        &quot;first&quot; .. i, &quot;given&quot; .. i, &quot;author-first&quot;, 
                        &quot;first&quot;, &quot;given&quot;}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;author&quot; .. i .. &quot;-link&quot;, &quot;author-link&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;link&quot;, &quot;authorlink&quot; .. i, &quot;author-link&quot;,  
                        &quot;authorlink&quot;}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;author&quot; .. i .. &quot;-mask&quot;, &quot;author-mask&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;mask&quot;, &quot;authormask&quot; .. i, &quot;author-mask&quot;, 
                        &quot;authormask&quot; }, 'redundant_parameters' )
                }
            else
                authors[i] = {
                    last = last,
                    first = selectone( args, {&quot;author&quot; .. i .. &quot;-first&quot;, &quot;author-first&quot; .. i, 
                        &quot;first&quot; .. i, &quot;given&quot; .. i}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;author&quot; .. i .. &quot;-link&quot;, &quot;author-link&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;link&quot;, &quot;authorlink&quot; .. i}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;author&quot; .. i .. &quot;-mask&quot;, &quot;author-mask&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;mask&quot;, &quot;authormask&quot; .. i}, 'redundant_parameters' )
                }
            end            
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

-- Gets editor list from the input arguments
function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        if i == 1 then
            last = selectone( args, {&quot;editor&quot; .. i .. &quot;-last&quot;, &quot;editor-last&quot; .. i,
                &quot;EditorSurname&quot; .. i, &quot;Editor&quot; .. i, &quot;editor&quot; .. i, &quot;editor-last&quot;, 
                &quot;EditorSurname&quot;, &quot;Editor&quot;, &quot;editor&quot;, &quot;editors&quot;}, 'redundant_parameters' );
        else
            last = selectone( args, {&quot;editor&quot; .. i .. &quot;-last&quot;, &quot;editor-last&quot; .. i,
                &quot;EditorSurname&quot; .. i, &quot;Editor&quot; .. i, &quot;editor&quot; .. i}, 'redundant_parameters' );
        end        
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            if i == 1 then
                editors[i] = {
                    last = last,
                    first = selectone( args, {&quot;editor&quot; .. i .. &quot;-first&quot;, 
                        &quot;editor-first&quot; .. i, &quot;EditorGiven&quot; .. i, &quot;editor-first&quot;, 
                        &quot;EditorGiven&quot;}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;editor&quot; .. i .. &quot;-link&quot;, &quot;editor-link&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;link&quot;, &quot;editorlink&quot; .. i, &quot;editor-link&quot;, 
                        &quot;editorlink&quot;}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;editor&quot; .. i .. &quot;-mask&quot;, &quot;editor-mask&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;mask&quot;, &quot;editormask&quot; .. i, &quot;editor-mask&quot;,  
                        &quot;editormask&quot;}, 'redundant_parameters' )
                }                
            else
                editors[i] = {
                    last = last,
                    first = selectone( args, {&quot;editor&quot; .. i .. &quot;-first&quot;, 
                        &quot;editor-first&quot; .. i, &quot;EditorGiven&quot; .. i}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;editor&quot; .. i .. &quot;-link&quot;, &quot;editor-link&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;link&quot;, &quot;editorlink&quot; .. i}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;editor&quot; .. i .. &quot;-mask&quot;, &quot;editor-mask&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;mask&quot;, &quot;editormask&quot; .. i}, 'redundant_parameters' )
                }
            end
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
    local id_list = {};
    
    for k, v in pairs( cfg.id_handlers ) do    
        id_list[k] = selectone( args, v.parameters, 'redundant_parameters' );
    end

    return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
    local handler;
    local new_list = {};
    
    for k, v in pairs( id_list ) do
        handler = {};
        
        --Becasue cfg is read-only we have to copy it the hard way.
        for k2, v2 in pairs( cfg.id_handlers[k] ) do
            handler[k2] = v2;
        end
        handler['id'] = v;
        
        if handler.mode == 'external' then        
            table.insert( new_list, {handler.label, externallinkid( handler ) } );
        elseif handler.mode == 'internal' then
            table.insert( new_list, {handler.label, internallinkid( handler ) } );
        elseif handler.mode == 'manual' then
            if k == 'DOI' then
                table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
            elseif k == 'ASIN' then
                table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
            elseif k == 'OL' then
                table.insert( new_list, {handler.label, openlibrary( v ) } );
            elseif k == 'ISBN' then
                local ISBN = internallinkid( handler );
                if not checkisbn( v ) then 
                    ISBN = ISBN .. seterror( 'bad_isbn' );
                end
                table.insert( new_list, {handler.label, ISBN } );                
            else
                error( cfg.message_list['unknown_manual_ID'] );
            end            
        else
            error( cfg.message_list['unknown_ID_mode'] );
        end
    end

    function comp( a, b )
        return a[1] &lt; b[1];
    end

    table.sort( new_list, comp );
    for k, v in ipairs( new_list ) do
        new_list[k] = v[2];
    end
    
    return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition )
    local value = nil;
    local selected = '';
    local error_list = {};
    
    for _, v in ipairs( possible ) do
        if args[v] ~= nil then
            if value ~= nil then
                table.insert( error_list, v );
            else
                value = args[v];
                selected = v;
            end
        end
    end
            
    if #error_list &gt; 0 then
        local error_str = &quot;&quot;;
        for _, k in ipairs( error_list ) do
            if error_str ~= &quot;&quot; then error_str = error_str .. &quot;, &quot; end
            error_str = error_str .. &quot;&lt;code&gt;|&quot; .. k .. &quot;=&lt;/code&gt;&quot;;
        end
        if #error_list &gt; 1 then
            error_str = error_str .. &quot;, and &quot;;
        else
            error_str = error_str .. &quot; and &quot;;
        end
        error_str = error_str .. &quot;&lt;code&gt;|&quot; .. selected .. &quot;=&lt;/code&gt;&quot;;
        table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
    end
            
    return value, selected;
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    -- Load Input Parameters

    local i 
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = args.authors
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = selectone( args, {'chapter', 'contribution', 'entry' }, 'redundant_parameters' );
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url or args.URL
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl or args[&quot;contribution-url&quot;]
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = selectone( args, {'journal', 'newspaper', 'magazine', 'work', 'website', 
        'periodical', 'encyclopedia', 'encyclopaedia'}, 'redundant_parameters' );
            
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = nil          
            TransTitle = nil
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = nil 
                TransTitle = nil
            end
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = nil end
        end
    end
    local Series = selectone( args, {'series', 'version'}, 'redundant_parameters' );
    local Volume = args.volume
    local Issue = selectone( args, {'issue', 'number'}, 'redundant_parameters' );
    local Position = nil
    local Page, Pages, At, page_type;
    
    Page, page_type = selectone( args, {'p', 'page', 'pp', 'pages', 'at'}, 
        'extra_pages' );
    if page_type == 'pp' or page_type == 'pages' then
        Pages = hyphentodash( Page );
        Page = nil;
    elseif page_type == 'at' then
        At = Page;
        Page = nil;
    end
                
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace 
    local Place = selectone( args, {'place', 'location'}, 'redundant_parameters' );
    if PublicationPlace == nil and Place ~= nil then 
        PublicationPlace = Place;
    end
    if PublicationPlace == Place then Place = nil end
    
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl or &quot;yes&quot;           -- Only used is ArchiveURL is present.
    local Language = selectone( args, {'language', 'in'}, 'redundant_parameters' );
    local Format = args.format
    local Ref = args.ref or args.Ref

    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = selectone( args, {'id', 'ID', 'docket'}, 'redundant_parameters' );
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]

    local ID_list = extractids( args );
    
    local Quote = selectone( args, {'quote', 'quotation'}, 'redundant_parameters' );
    local PostScript = args.postscript or &quot;.&quot;
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator or &quot;.&quot;
    local LastAuthorAmp = args.lastauthoramp
    local no_tracking_cats = args[&quot;template doc demo&quot;] or args.nocat or 
            args.notracking or args[&quot;no-tracking&quot;] or &quot;&quot;;

    if ( config.CitationClass == &quot;journal&quot; ) then        
        if (URL == nil or URL == &quot;&quot;) then
            if (ID_list['PMC'] ~= nil) then 
                local Embargo = args.embargo or args.Embargo;
                if Embargo ~= nil then
                    local lang = mw.getContentLanguage();
                    local good1, result1, good2, result2;
                    good1, result1 = pcall( lang.formatDate, lang, 'U', Embargo );
                    good2, result2 = pcall( lang.formatDate, lang, 'U' );

                    if good1 and good2 and tonumber( result1 ) &lt; tonumber( result2 ) then 
                        URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];
                    end
                else
                    URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];           
                end
            end
        end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, cfg.message_list[&quot;episode&quot;] .. &quot; &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, cfg.message_list[&quot;season&quot;] .. &quot; &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, cfg.message_list[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows 
    -- automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
        if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    
    for k, v in pairs( ID_list ) do
        if string.sub( cfg.id_handlers[k].COinS or &quot;info&quot;, 1, 4 ) ~= 'info' then
            OCinSdata[ cfg.id_handlers[k].COinS ] = v;
        end
    end
    
    OCinSdata.rft_id = URL or ChapterURL

    local last, first;
    local OCinSauthors = {};
    for k, v in ipairs( a ) do
        last = v.last;
        first = v.first;
        if k == 1 then
            if last ~= nil then
                OCinSdata[&quot;rft.aulast&quot;] = last;
            end
            if first ~= nil then 
                OCinSdata[&quot;rft.aufirst&quot;] = first;
            end
        end
        if last ~= nil and first ~= nil then
            table.insert( OCinSauthors, last .. (args.NameSep or &quot;, &quot;) .. first );
    	elseif last ~= nil then
            table.insert( OCinSauthors, last );
        end
    end

    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    for k, v in pairs( ID_list ) do
        if string.sub( cfg.id_handlers[k].COinS or &quot;&quot;, 1, 4 ) == 'info' then
            OCinSids[ cfg.id_handlers[k].COinS ] = v;
        end
    end

    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    for _, value in ipairs(OCinSauthors) do
        OCinStitle = OCinStitle .. &quot;&amp;rft.au=&quot; .. mw.uri.encode(value)
    end
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    
    local this_page = mw.title.getCurrentTitle();
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/&quot; .. mw.site.server:match( &quot;[^/]*$&quot; ) .. &quot;:&quot;
       .. this_page.prefixedText  -- end COinS data by page's non-encoded pagename

    if (Periodical ~= nil and Periodical ~= &quot;&quot;) and
        (Chapter == nil or Chapter == '') and
        (Title ~= nil and Title ~= &quot;&quot;) then
            Chapter = Title
            ChapterLink = TitleLink
            TransChapter = TransTitle
            Title = nil
            TitleLink = nil
            TransTitle = nil            
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local Maximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors);
        
        -- Preserve old-style implicit et al.
        if Maximum == nil and #a == 9 then 
            Maximum = 8;
            table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
        elseif Maximum == nil then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = (args[&quot;author-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = args[&quot;author-format&quot;] or args.authorformat,
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        }
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if Coauthors ~= nil and Coauthors ~= &quot;&quot; then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
                
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local Maximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors);

        -- Preserve old-style implicit et al.
        if Maximum == nil and #e == 4 then 
            Maximum = 3;
            table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
        elseif Maximum == nil then
            Maximum = #e + 1;
        end

        local control = { 
            sep = (args[&quot;editor-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = args[&quot;editor-format&quot;] or args.editorformat,
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
            }

        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date
    
    if ( URL == nil or URL == '' ) and
            ( ChapterURL == nil or ChapterURL == '' ) and
            ( ArchiveURL == nil or ArchiveURL == '' ) and                
            ( ConferenceURL == nil or ConferenceURL == '' ) and                
            ( TranscriptURL == nil or TranscriptURL == '' ) then

        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
        end

        -- Test if accessdate is given without giving a URL
        if ( AccessDate ~= nil and AccessDate ~= '' ) then
            table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
            AccessDate = nil;
        end      
    
        -- Test if format is given without giving a URL
        if ( Format ~= nil and Format ~= '' ) then
            Format = Format .. seterror( 'format_missing_url' );
        end        
    end    

    -- Test if citation has no title
    if ( Chapter == nil or Chapter == &quot;&quot; ) and 
            ( Title == nil or Title == &quot;&quot; ) and
            ( Periodical == nil or Periodical == &quot;&quot; ) and
            ( Conference == nil or Conference == &quot;&quot; ) and 
            ( TransTitle == nil or TransTitle == &quot;&quot; ) and
            ( TransChapter == nil or TransChapter == &quot;&quot; ) then
        table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
    end

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
        end
    end

    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
        
    -- Format chapter / article title
    if ( Chapter ~= nil and Chapter ~= &quot;&quot; ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) and (Title ~= nil and Title ~= &quot;&quot; )
        then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
    else
        Chapter = &quot;&quot;;
    end
    if TransChapter ~= &quot;&quot; and Chapter == &quot;&quot; then
        TransChapter = TransChapter .. seterror( 'trans_missing_chapter' );
    end
    Chapter = Chapter .. TransChapter
    if Chapter ~= &quot;&quot; then
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot;
                if URL == nil or URL == &quot;&quot; then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. Format
                URL = nil
                Format = &quot;&quot;
            end
        elseif ChapterURL ~= nil and ChapterURL ~= &quot;&quot; then
            Chapter = Chapter .. &quot; [&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( ChapterURL ) .. &quot;]&quot; .. 
                seterror( 'bare_url_missing_title' );
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    elseif ChapterURL ~= nil and ChapterURL ~= &quot;&quot; then
        Chapter = &quot; [&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( ChapterURL ) .. &quot;]&quot; .. 
            seterror( 'bare_url_missing_title' ) .. sepc .. &quot; &quot;;
    end        
    
    -- Format main title.
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
                or config.CitationClass == &quot;news&quot; 
                or config.CitationClass == &quot;pressrelease&quot; ) and 
                Chapter == &quot;&quot; then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
    else
        Title = &quot;&quot;;
    end    
    if TransTitle ~= &quot;&quot; and Title == &quot;&quot; then
        TransTitle = TransTitle .. seterror( 'trans_missing_title' );
    end
    Title = Title .. TransTitle
    if Title ~= &quot;&quot; then
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. Format
            URL = nil
            Format = ''
        end
    end

    if ( Place ~= nil and Place ~= &quot;&quot; ) then
        if sepc == '.' then
            Place = &quot; &quot; .. cfg.message_list['written'] .. &quot; &quot; .. Place .. sepc .. &quot; &quot;;
        else
            Place = &quot; &quot; .. cfg.message_list['written']:lower() .. &quot; &quot; .. Place .. sepc .. &quot; &quot;;
        end            
    else
        Place = &quot;&quot;;
    end
    
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    elseif ConferenceURL ~= nil and ConferenceURL ~= &quot;&quot; then
        Conference = &quot; [&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( ConferenceURL ) .. &quot;]&quot; .. 
            seterror( 'bare_url_missing_title' );
    else
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.message_list['minutes'];
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption 
                if TimeCaption == nil then
                    TimeCaption = cfg.message_list['event'];
                    if sepc ~= '.' then
                        TimeCaption = TimeCaption:lower();
                    end
                end                
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (&quot; .. cfg.message_list['in'] .. &quot; &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; &quot; .. cfg.message_list['edition'] .. &quot;)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; &quot; .. cfg.message_list['via'] .. &quot; &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; &quot; .. cfg.message_list['retrieved'] .. &quot; &quot;
         if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
             .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.message_list['subscription'];
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end

    ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD} );

    if ( URL ~= nil and URL ~=&quot;&quot;) then
        URL = &quot; &quot; .. &quot;[&quot; .. URL .. &quot; &quot; .. mw.text.nowiki(URL) .. &quot;]&quot;;
        local error_text = seterror( 'bare_url_missing_title' );
        if config.CitationClass == &quot;web&quot; then
            URL = URL .. &quot; &quot; .. seterror( 'cite_web_title' );
        else
            URL = URL .. error_text;
        end       
    else
        URL = &quot;&quot;
    end

    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot; &quot; .. seterror('archive_missing_date') .. &quot; &quot;
        end
        local arch_text = &quot; &quot; .. cfg.message_list['archived'];
        if (sepc ~= &quot;.&quot;) then arch_text = arch_text:lower() end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] &quot; .. 
                cfg.message_list['from'] .. &quot; &quot; .. cfg.message_list['original'] .. &quot; &quot; .. 
                cfg.message_list['on'] .. ArchiveDate
            if OriginalURL == nil or OriginalUrl == '' then
                Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url_not_dead');                               
            end
        else
            if OriginalURL ~= nil and OriginalURL ~= '' then
                Archived = sepc .. arch_text .. &quot; &quot; .. cfg.message_list['from'] .. &quot; [&quot; .. OriginalURL .. &quot; &quot; .. 
                    cfg.message_list['original'] .. &quot;] &quot; .. cfg.message_list['on'] .. ArchiveDate
            else
                if config.CitationClass ~= 'web' then 
                    Archived = sepc .. arch_text .. &quot; &quot; .. cfg.message_list['from'] .. &quot; &quot; .. 
                    seterror('archive_missing_url') .. &quot; &quot; .. cfg.message_list['on'] .. ArchiveDate
                else
                    Archived = sepc .. arch_text .. &quot; &quot; .. cfg.message_list['from'] .. 
                        &quot; &quot; .. cfg.message_list['original'] .. &quot; &quot; .. 
                        cfg.message_list['on'] .. ArchiveDate
                end
            end                
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        if sepc == '.' then
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; &quot; .. cfg.message_list['lay summary'] .. &quot;]&quot; .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; &quot; .. cfg.message_list['lay summary']:lower() .. &quot;]&quot; .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    elseif TranscriptURL ~= nil and TranscriptURL ~= &quot;&quot; then
        Transcript = &quot;[&quot; .. TranscriptURL .. &quot; &quot; .. safeforurl( TranscriptURL ) .. &quot;]&quot; .. 
            seterror( 'bare_url_missing_title' )        
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; and
         config.CitationClass ~= &quot;pressrelease&quot; ) then
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            if Publisher ~= '' then
                Publisher = Publisher .. &quot;, &quot; .. cfg.message_list['published'] .. &quot; &quot; .. PublicationDate;
            else
                Publisher = PublicationDate;
            end
        end
        if Publisher ~= &quot;&quot; then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (&quot; .. cfg.message_list['published'] .. &quot; &quot; .. PublicationDate .. &quot;)&quot;
        else 
            PublicationDate = &quot;&quot;
        end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot; ) or ( TitleNote and TitleNote ~= &quot;&quot; ) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( ( (config.CitationClass == &quot;journal&quot;) or (config.CitationClass == &quot;citation&quot;) )  and
         Periodical ~= &quot;&quot; ) then
        if (Others ~= &quot;&quot;) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
            Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
            Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
    end
    
    if #ID_list &gt; 0 then
        ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
    else
        ID_list = ID;
    end    
    local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );

    local text
    local pgtext = Page .. Pages .. At
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, &quot; .. cfg.message_list['editor'];
            else
                Editors = Editors .. &quot;, &quot; .. cfg.message_list['editors'];
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (&quot; .. cfg.message_list['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (&quot; .. cfg.message_list['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end -- endif &quot;&quot;~=Date
        if ( config.CitationClass==&quot;journal&quot; and Periodical ) then
          text = safejoin( {Chapter, Place, tcommon}, sepc );
          text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
          text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
          text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if PostScript ~= '' and PostScript ~= nil and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local options = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        options.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = {};
        text = seterror('empty_citation');
        z.message_tail = {};
    end
    
    if options.id ~= nil then 
        text = '&lt;span id=&quot;' .. wikiescape(options.id) ..'&quot; class=&quot;' .. wikiescape(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    else
        text = '&lt;span class=&quot;' .. wikiescape(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    end        

    local empty_span = '&lt;span style=&quot;display: none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = '&lt;span title=&quot;' .. wikiescape(OCinStitle) .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        for i,v in ipairs( z.message_tail ) do
            if i == #z.message_tail then
                text = text .. errorcomment( v[1], v[2] );
            else
                text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
            end
        end
    end
    
    if no_tracking_cats == '' then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    local suggestions = {};
    local error_text, error_state;
    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            if not validate( k ) then            
                error_text = &quot;&quot;;
                if type( k ) ~= 'string' then
                    -- Exclude empty numbered parameters
                    if v:match(&quot;%S+&quot;) ~= nil then
                        error_text, error_state = seterror( 'text_ignored', {v}, true );
                    end
                elseif validate( k:lower() ) then 
                    error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
                else
                    if #suggestions == 0 then
                        suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
                    end
                    if suggestions[ k:lower() ] ~= nil then
                        error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
                    else
                        error_text, error_state = seterror( 'parameter_ignored', {k}, true );
                    end
                end                  
                if error_text ~= '' then
                    table.insert( z.message_tail, {error_text, error_state} );
                end                
            end            
            args[k] = v;
        elseif k == 'postscript' then
            args[k] = v;
        end        
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        if args[k] == nil and (v ~= '' or k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--18Mar2013 Fixed &quot;page=&quot; to override &quot;pages=&quot; as in markup-based cites.
--19Mar2013 Fixed date of class=journal Periodical to show after page.
--19Mar2013 Changed null &quot;postscript=&quot; to suppress end-dot of citation.
--20Mar2013 If CitationClass is journal, show &quot;others=&quot; before title.
--20Mar2013 If CitationClass is book, show &quot;others=&quot; before edition.
--20Mar2013 If CitationClass is journal, adjust &quot;others=&quot; to have sepc.
--20Mar2013 For class &quot;journal&quot;, use book format unless Periodical set.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; after wikilink &quot;.]]&quot; end dot.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; after external &quot;.]&quot; end dot.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; at italic wikilink &quot;.]]&quot; end.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; at italic external &quot;.]&quot; end.
--04Apr2013 Moved sepc before &lt;span class=&quot;reference-accessdate&quot;&gt; for &quot;..&quot;.
--
--End</text>
      <sha1>9clzikuhukq0tup0zazqyj8kbdu4wvs</sha1>
    </revision>
    <revision>
      <id>4645</id>
      <parentid>4644</parentid>
      <timestamp>2013-04-10T01:22:15Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>sync with sandbox, reposition translation error to avoid wrapping in url</comment>
      <origin>4645</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="67588" sha1="3lfcn9guj4j2ni13d1eji9mbloi9l8a" xml:space="preserve">local z = {
    error_categories = {};
    message_tail = {};
}

-- Include translation message hooks, ID and error handling configuration settings.
local cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );
 
-- Contains a list of all recognized parameters
local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );

-- Checks that parameter name is valid
function validate( name )
    name = tostring( name );
    
    -- Normal arguments
    if whitelist.basic_arguments[ name ] then
        return true;
    end
    
    -- Arguments with numbers in them
    name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );
    if whitelist.numbered_arguments[ name ] then
        return true;
    end
    
    -- Not found, argument not supported.
    return false
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
    if hidden then 
        return '&lt;span style=&quot;display:none;font-size:100%&quot; class=&quot;error citation-comment&quot;&gt;' .. content .. '&lt;/span&gt;';
    else
        return '&lt;span style=&quot;font-size:100%&quot; class=&quot;error&quot;&gt;' .. content .. '&lt;/span&gt;';
    end        
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, args, raw )
    local error_state = cfg.error_conditions[ error_id ];

    if error_state == nil then
        error( cfg.message_list['undefined_error'] );
    end
    
    if error_state.category ~= nil and error_state.category ~= &quot;&quot; then
        table.insert( z.error_categories, error_state.category );
    end
    
    local message = error_state.message;
    if args ~= nil then
        for k, m in ipairs( args ) do
            m = m:gsub( &quot;%%&quot;, &quot;%%%%&quot; );
            message = message:gsub( &quot;$&quot; .. k .. &quot;(%D)&quot;, m .. &quot;%1&quot; );
        end
    end

    message = wikiescape(message) .. &quot; ([[&quot; .. cfg.message_list['help page link'] .. 
        &quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
        cfg.message_list['help page label'] .. &quot;]])&quot;;

    if raw == true then
        return message, error_state.hidden;
    end
        
    return errorcomment( message, error_state.hidden );
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',    
            ['{'] = '&amp;#123;',    
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

-- Formats a wiki style external link
function externallinkid(options)
    local sep = options.separator or &quot;&amp;nbsp;&quot;
    options.suffix = options.suffix or &quot;&quot;
    local url_string = options.id
    if options.encode == true or options.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    return &quot;[[&quot; .. options.link .. &quot;|&quot; .. options.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. 
            options.prefix .. url_string .. options.suffix .. &quot; &quot; .. mw.text.nowiki(options.id) .. &quot;]&quot;
end

-- Formats a wiki style internal link
function internallinkid(options)
    local sep = options.separator or &quot;&amp;nbsp;&quot;
    options.suffix = options.suffix or &quot;&quot;
    return &quot;[[&quot; .. options.link .. &quot;|&quot; .. options.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. 
            options.prefix .. options.id .. options.suffix .. &quot;|&quot; .. mw.text.nowiki(options.id) .. &quot;]]&quot;
end

-- Formats a link to Amazon
function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local handler = cfg.id_handlers['ASIN'];
    return externallinkid({link = handler.link,
        label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
        encode=handler.encode, separator = handler.separator})
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    local handler = cfg.id_handlers['DOI'];
    
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (&quot; .. cfg.message_list['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link = handler.link, label = handler.label,
            prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then      
        cat = seterror( 'bad_doi' );
    end
    return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    local handler = cfg.id_handlers['OL'];
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    else
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode}) .. 
            ' ' .. seterror( 'bad_ol' );
    end
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
    isbn_str = isbn_str:gsub(&quot;[- ]&quot;, &quot;&quot;):upper();
    local len = isbn_str:len();
 
    if len ~= 10 and len ~= 13 then
        return false;
    end
 
    local temp = 0;
    if len == 10 then
        if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            if v == string.byte( &quot;X&quot; ) then
                temp = temp + 10*( 11 - i );
            else
                temp = temp + tonumber( string.char(v) )*(11-i);
            end
        end
        return temp % 11 == 0;
    else
        if isbn_str:match( &quot;^%d*$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
        end
        return temp % 10 == 0;
    end
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    if str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then 
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    -- Is the input a simple number?
    local num = tonumber( str ); 
    if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
        return str;
    else
        -- Use formatDate to interpret more complicated formats
        local lang = mw.getContentLanguage();
        local good, result;
        good, result = pcall( lang.formatDate, lang, 'Y', str )
        if good then 
            return result;
        else
            -- Can't make sense of this input, return blank.
            return &quot;&quot;;
        end
    end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil and first ~= '') then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    if count &gt; 1 and lastauthoramp ~= nil and lastauthoramp ~= &quot;&quot; and not etal then
        text[count-1] = text[count-1] .. &quot; &amp; &quot; .. text[count];
        text[count] = nil;
    end    
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = cfg.message_list['et al'];
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result = 
        '&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
    end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid(options)
    local P1 = options[1] or &quot;&quot;
    local P2 = options[2] or &quot;&quot;
    local P3 = options[3] or &quot;&quot;
    local P4 = options[4] or &quot;&quot;
    local P5 = options[5] or &quot;&quot;
    
    -- Bugzilla 46608
    local encoded = mw.uri.anchorEncode( P1 .. P2 .. P3 .. P4 .. P5 );
    if encoded == false then
        encoded = &quot;&quot;;
    end
    
    return &quot;CITEREF&quot; .. encoded;
end

-- Gets author list from the input arguments
function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    while true do
        if i == 1 then 
            last = selectone( args, {&quot;author&quot; .. i .. &quot;-last&quot;, &quot;author-last&quot; .. i, 
                &quot;last&quot; .. i, &quot;surname&quot; .. i, &quot;Author&quot; .. i, &quot;author&quot; .. i, 
                &quot;author-last&quot;, &quot;last&quot;, &quot;surname&quot;, &quot;Author&quot;, &quot;author&quot;, &quot;authors&quot;}, 'redundant_parameters' );
        else
            last = selectone( args, {&quot;author&quot; .. i .. &quot;-last&quot;, &quot;author-last&quot; .. i, 
                &quot;last&quot; .. i, &quot;surname&quot; .. i, &quot;Author&quot; .. i, &quot;author&quot; .. i}, 'redundant_parameters' );
        end
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            if i == 1 then 
                authors[i] = {
                    last = last,
                    first = selectone( args, {&quot;author&quot; .. i .. &quot;-first&quot;, &quot;author-first&quot; .. i, 
                        &quot;first&quot; .. i, &quot;given&quot; .. i, &quot;author-first&quot;, 
                        &quot;first&quot;, &quot;given&quot;}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;author&quot; .. i .. &quot;-link&quot;, &quot;author-link&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;link&quot;, &quot;authorlink&quot; .. i, &quot;author-link&quot;,  
                        &quot;authorlink&quot;}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;author&quot; .. i .. &quot;-mask&quot;, &quot;author-mask&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;mask&quot;, &quot;authormask&quot; .. i, &quot;author-mask&quot;, 
                        &quot;authormask&quot; }, 'redundant_parameters' )
                }
            else
                authors[i] = {
                    last = last,
                    first = selectone( args, {&quot;author&quot; .. i .. &quot;-first&quot;, &quot;author-first&quot; .. i, 
                        &quot;first&quot; .. i, &quot;given&quot; .. i}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;author&quot; .. i .. &quot;-link&quot;, &quot;author-link&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;link&quot;, &quot;authorlink&quot; .. i}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;author&quot; .. i .. &quot;-mask&quot;, &quot;author-mask&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;mask&quot;, &quot;authormask&quot; .. i}, 'redundant_parameters' )
                }
            end            
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

-- Gets editor list from the input arguments
function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        if i == 1 then
            last = selectone( args, {&quot;editor&quot; .. i .. &quot;-last&quot;, &quot;editor-last&quot; .. i,
                &quot;EditorSurname&quot; .. i, &quot;Editor&quot; .. i, &quot;editor&quot; .. i, &quot;editor-last&quot;, 
                &quot;EditorSurname&quot;, &quot;Editor&quot;, &quot;editor&quot;, &quot;editors&quot;}, 'redundant_parameters' );
        else
            last = selectone( args, {&quot;editor&quot; .. i .. &quot;-last&quot;, &quot;editor-last&quot; .. i,
                &quot;EditorSurname&quot; .. i, &quot;Editor&quot; .. i, &quot;editor&quot; .. i}, 'redundant_parameters' );
        end        
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            if i == 1 then
                editors[i] = {
                    last = last,
                    first = selectone( args, {&quot;editor&quot; .. i .. &quot;-first&quot;, 
                        &quot;editor-first&quot; .. i, &quot;EditorGiven&quot; .. i, &quot;editor-first&quot;, 
                        &quot;EditorGiven&quot;}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;editor&quot; .. i .. &quot;-link&quot;, &quot;editor-link&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;link&quot;, &quot;editorlink&quot; .. i, &quot;editor-link&quot;, 
                        &quot;editorlink&quot;}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;editor&quot; .. i .. &quot;-mask&quot;, &quot;editor-mask&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;mask&quot;, &quot;editormask&quot; .. i, &quot;editor-mask&quot;,  
                        &quot;editormask&quot;}, 'redundant_parameters' )
                }                
            else
                editors[i] = {
                    last = last,
                    first = selectone( args, {&quot;editor&quot; .. i .. &quot;-first&quot;, 
                        &quot;editor-first&quot; .. i, &quot;EditorGiven&quot; .. i}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;editor&quot; .. i .. &quot;-link&quot;, &quot;editor-link&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;link&quot;, &quot;editorlink&quot; .. i}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;editor&quot; .. i .. &quot;-mask&quot;, &quot;editor-mask&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;mask&quot;, &quot;editormask&quot; .. i}, 'redundant_parameters' )
                }
            end
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
    local id_list = {};
    
    for k, v in pairs( cfg.id_handlers ) do    
        id_list[k] = selectone( args, v.parameters, 'redundant_parameters' );
    end

    return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
    local handler;
    local new_list = {};
    
    for k, v in pairs( id_list ) do
        handler = {};
        
        --Becasue cfg is read-only we have to copy it the hard way.
        for k2, v2 in pairs( cfg.id_handlers[k] ) do
            handler[k2] = v2;
        end
        handler['id'] = v;
        
        if handler.mode == 'external' then        
            table.insert( new_list, {handler.label, externallinkid( handler ) } );
        elseif handler.mode == 'internal' then
            table.insert( new_list, {handler.label, internallinkid( handler ) } );
        elseif handler.mode == 'manual' then
            if k == 'DOI' then
                table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
            elseif k == 'ASIN' then
                table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
            elseif k == 'OL' then
                table.insert( new_list, {handler.label, openlibrary( v ) } );
            elseif k == 'ISBN' then
                local ISBN = internallinkid( handler );
                if not checkisbn( v ) then 
                    ISBN = ISBN .. seterror( 'bad_isbn' );
                end
                table.insert( new_list, {handler.label, ISBN } );                
            else
                error( cfg.message_list['unknown_manual_ID'] );
            end            
        else
            error( cfg.message_list['unknown_ID_mode'] );
        end
    end

    function comp( a, b )
        return a[1] &lt; b[1];
    end

    table.sort( new_list, comp );
    for k, v in ipairs( new_list ) do
        new_list[k] = v[2];
    end
    
    return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition )
    local value = nil;
    local selected = '';
    local error_list = {};
    
    for _, v in ipairs( possible ) do
        if args[v] ~= nil then
            if value ~= nil then
                table.insert( error_list, v );
            else
                value = args[v];
                selected = v;
            end
        end
    end
            
    if #error_list &gt; 0 then
        local error_str = &quot;&quot;;
        for _, k in ipairs( error_list ) do
            if error_str ~= &quot;&quot; then error_str = error_str .. &quot;, &quot; end
            error_str = error_str .. &quot;&lt;code&gt;|&quot; .. k .. &quot;=&lt;/code&gt;&quot;;
        end
        if #error_list &gt; 1 then
            error_str = error_str .. &quot;, and &quot;;
        else
            error_str = error_str .. &quot; and &quot;;
        end
        error_str = error_str .. &quot;&lt;code&gt;|&quot; .. selected .. &quot;=&lt;/code&gt;&quot;;
        table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
    end
            
    return value, selected;
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    -- Load Input Parameters

    local i 
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = args.authors
    local a = extractauthors( args );

    local Coauthors = args.coauthors or args.coauthor 
    local Others = args.others 
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = args.publicationdate or args[&quot;publication-date&quot;]
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = args.trans_title
    local TitleNote = args.department
    local TitleLink = args.titlelink or args.episodelink
    local Chapter = selectone( args, {'chapter', 'contribution', 'entry' }, 'redundant_parameters' );
    local ChapterLink = args.chapterlink
    local TransChapter = args[&quot;trans-chapter&quot;] or args.trans_chapter
    local TitleType = args.type
    local ArchiveURL = args[&quot;archive-url&quot;] or args.archiveurl
    local URL = args.url or args.URL
    local ChapterURL = args[&quot;chapter-url&quot;] or args.chapterurl or args[&quot;contribution-url&quot;]
    local ConferenceURL = args[&quot;conference-url&quot;] or args.conferenceurl
    local Periodical = selectone( args, {'journal', 'newspaper', 'magazine', 'work', 'website', 
        'periodical', 'encyclopedia', 'encyclopaedia'}, 'redundant_parameters' );
            
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = nil          
            TransTitle = nil
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = nil 
                TransTitle = nil
            end
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = nil end
        end
    end
    local Series = selectone( args, {'series', 'version'}, 'redundant_parameters' );
    local Volume = args.volume
    local Issue = selectone( args, {'issue', 'number'}, 'redundant_parameters' );
    local Position = nil
    local Page, Pages, At, page_type;
    
    Page, page_type = selectone( args, {'p', 'page', 'pp', 'pages', 'at'}, 
        'extra_pages' );
    if page_type == 'pp' or page_type == 'pages' then
        Pages = hyphentodash( Page );
        Page = nil;
    elseif page_type == 'at' then
        At = Page;
        Page = nil;
    end
                
    local Edition = args.edition
    local PublicationPlace = args[&quot;publication-place&quot;] or args.publicationplace 
    local Place = selectone( args, {'place', 'location'}, 'redundant_parameters' );
    if PublicationPlace == nil and Place ~= nil then 
        PublicationPlace = Place;
    end
    if PublicationPlace == Place then Place = nil end
    
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = args[&quot;access-date&quot;] or args.accessdate
    local ArchiveDate = args[&quot;archive-date&quot;] or args.archivedate
    local Agency = args.agency
    local DeadURL = args.deadurl or &quot;yes&quot;           -- Only used is ArchiveURL is present.
    local Language = selectone( args, {'language', 'in'}, 'redundant_parameters' );
    local Format = args.format
    local Ref = args.ref or args.Ref

    local DoiBroken = args.doi_inactivedate or args.doi_brokendate or args.DoiBroken
    local ID = selectone( args, {'id', 'ID', 'docket'}, 'redundant_parameters' );
    local ASINTLD = args[&quot;ASIN-TLD&quot;] or args[&quot;asin-tld&quot;]

    local ID_list = extractids( args );
    
    local Quote = selectone( args, {'quote', 'quotation'}, 'redundant_parameters' );
    local PostScript = args.postscript or &quot;.&quot;
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = args[&quot;transcript-url&quot;] or args.transcripturl
    local sepc = args.separator or &quot;.&quot;
    local LastAuthorAmp = args.lastauthoramp
    local no_tracking_cats = args[&quot;template doc demo&quot;] or args.nocat or 
            args.notracking or args[&quot;no-tracking&quot;] or &quot;&quot;;

    if ( config.CitationClass == &quot;journal&quot; ) then        
        if (URL == nil or URL == &quot;&quot;) then
            if (ID_list['PMC'] ~= nil) then 
                local Embargo = args.embargo or args.Embargo;
                if Embargo ~= nil then
                    local lang = mw.getContentLanguage();
                    local good1, result1, good2, result2;
                    good1, result1 = pcall( lang.formatDate, lang, 'U', Embargo );
                    good2, result2 = pcall( lang.formatDate, lang, 'U' );

                    if good1 and good2 and tonumber( result1 ) &lt; tonumber( result2 ) then 
                        URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];
                    end
                else
                    URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];           
                end
            end
        end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, cfg.message_list[&quot;episode&quot;] .. &quot; &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, cfg.message_list[&quot;season&quot;] .. &quot; &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, cfg.message_list[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows 
    -- automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
        if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    
    for k, v in pairs( ID_list ) do
        if string.sub( cfg.id_handlers[k].COinS or &quot;info&quot;, 1, 4 ) ~= 'info' then
            OCinSdata[ cfg.id_handlers[k].COinS ] = v;
        end
    end
    
    OCinSdata.rft_id = URL or ChapterURL

    local last, first;
    local OCinSauthors = {};
    for k, v in ipairs( a ) do
        last = v.last;
        first = v.first;
        if k == 1 then
            if last ~= nil then
                OCinSdata[&quot;rft.aulast&quot;] = last;
            end
            if first ~= nil then 
                OCinSdata[&quot;rft.aufirst&quot;] = first;
            end
        end
        if last ~= nil and first ~= nil then
            table.insert( OCinSauthors, last .. (args.NameSep or &quot;, &quot;) .. first );
    	elseif last ~= nil then
            table.insert( OCinSauthors, last );
        end
    end

    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    for k, v in pairs( ID_list ) do
        if string.sub( cfg.id_handlers[k].COinS or &quot;&quot;, 1, 4 ) == 'info' then
            OCinSids[ cfg.id_handlers[k].COinS ] = v;
        end
    end

    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode(value)
    end
    for _, value in ipairs(OCinSauthors) do
        OCinStitle = OCinStitle .. &quot;&amp;rft.au=&quot; .. mw.uri.encode(value)
    end
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. value)
    end
    
    local this_page = mw.title.getCurrentTitle();
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/&quot; .. mw.site.server:match( &quot;[^/]*$&quot; ) .. &quot;:&quot;
       .. this_page.prefixedText  -- end COinS data by page's non-encoded pagename

    if (Periodical ~= nil and Periodical ~= &quot;&quot;) and
        (Chapter == nil or Chapter == '') and
        (Title ~= nil and Title ~= &quot;&quot;) then
            Chapter = Title
            ChapterLink = TitleLink
            TransChapter = TransTitle
            Title = nil
            TitleLink = nil
            TransTitle = nil            
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local Maximum = tonumber(args[&quot;display-authors&quot;] or args.displayauthors);
        
        -- Preserve old-style implicit et al.
        if Maximum == nil and #a == 9 then 
            Maximum = 8;
            table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
        elseif Maximum == nil then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = (args[&quot;author-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = args[&quot;author-format&quot;] or args.authorformat,
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        }
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if Coauthors ~= nil and Coauthors ~= &quot;&quot; then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
                
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local Maximum = tonumber(args[&quot;display-editors&quot;] or args.displayeditors);

        -- Preserve old-style implicit et al.
        if Maximum == nil and #e == 4 then 
            Maximum = 3;
            table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
        elseif Maximum == nil then
            Maximum = #e + 1;
        end

        local control = { 
            sep = (args[&quot;editor-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = args[&quot;editor-format&quot;] or args.editorformat,
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
            }

        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date
    
    if ( URL == nil or URL == '' ) and
            ( ChapterURL == nil or ChapterURL == '' ) and
            ( ArchiveURL == nil or ArchiveURL == '' ) and                
            ( ConferenceURL == nil or ConferenceURL == '' ) and                
            ( TranscriptURL == nil or TranscriptURL == '' ) then

        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
        end

        -- Test if accessdate is given without giving a URL
        if ( AccessDate ~= nil and AccessDate ~= '' ) then
            table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
            AccessDate = nil;
        end      
    
        -- Test if format is given without giving a URL
        if ( Format ~= nil and Format ~= '' ) then
            Format = Format .. seterror( 'format_missing_url' );
        end        
    end    

    -- Test if citation has no title
    if ( Chapter == nil or Chapter == &quot;&quot; ) and 
            ( Title == nil or Title == &quot;&quot; ) and
            ( Periodical == nil or Periodical == &quot;&quot; ) and
            ( Conference == nil or Conference == &quot;&quot; ) and 
            ( TransTitle == nil or TransTitle == &quot;&quot; ) and
            ( TransChapter == nil or TransChapter == &quot;&quot; ) then
        table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
    end

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
        end
    end

    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
        
    -- Format chapter / article title
    if ( Chapter ~= nil and Chapter ~= &quot;&quot; ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) and (Title ~= nil and Title ~= &quot;&quot; )
        then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
    else
        Chapter = &quot;&quot;;
    end
    
    local TransError = &quot;&quot;
    if TransChapter ~= &quot;&quot; and Chapter == &quot;&quot; then
        TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
    end
    Chapter = Chapter .. TransChapter
    if Chapter ~= &quot;&quot; then
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then
                Chapter = &quot;[&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( Chapter )  .. &quot;]&quot; .. TransError;
                if URL == nil or URL == &quot;&quot; then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Chapter ) .. &quot;]&quot; .. TransError .. Format
                URL = nil
                Format = &quot;&quot;
            else
                Chapter = Chapter .. TransError;
            end            
        elseif ChapterURL ~= nil and ChapterURL ~= &quot;&quot; then
            Chapter = Chapter .. &quot; [&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( ChapterURL ) .. &quot;]&quot; .. 
                TransError .. &quot; &quot; .. seterror( 'bare_url_missing_title' );
        else
            Chapter = Chapter .. TransError;
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    elseif ChapterURL ~= nil and ChapterURL ~= &quot;&quot; then
        Chapter = &quot; [&quot; .. ChapterURL .. &quot; &quot; .. safeforurl( ChapterURL ) .. &quot;]&quot; .. 
            seterror( 'bare_url_missing_title' ) .. sepc .. &quot; &quot;;
    end        
    
    -- Format main title.
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
                or config.CitationClass == &quot;news&quot; 
                or config.CitationClass == &quot;pressrelease&quot; ) and 
                Chapter == &quot;&quot; then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
    else
        Title = &quot;&quot;;
    end    
    
    local TransError = &quot;&quot;;
    if TransTitle ~= &quot;&quot; and Title == &quot;&quot; then
        TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
    end
    Title = Title .. TransTitle
    if Title ~= &quot;&quot; then
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = &quot;[&quot; .. URL .. &quot; &quot; .. safeforurl( Title ) .. &quot;]&quot; .. TransError .. Format
            URL = nil
            Format = ''
        else
            Title = Title .. TransError;
        end
    end

    if ( Place ~= nil and Place ~= &quot;&quot; ) then
        if sepc == '.' then
            Place = &quot; &quot; .. cfg.message_list['written'] .. &quot; &quot; .. Place .. sepc .. &quot; &quot;;
        else
            Place = &quot; &quot; .. cfg.message_list['written']:lower() .. &quot; &quot; .. Place .. sepc .. &quot; &quot;;
        end            
    else
        Place = &quot;&quot;;
    end
    
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = &quot;[&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( Conference ) .. &quot;]&quot;
        end
        Conference = &quot; &quot; .. Conference
    elseif ConferenceURL ~= nil and ConferenceURL ~= &quot;&quot; then
        Conference = &quot; [&quot; .. ConferenceURL .. &quot; &quot; .. safeforurl( ConferenceURL ) .. &quot;]&quot; .. 
            seterror( 'bare_url_missing_title' );
    else
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.message_list['minutes'];
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption 
                if TimeCaption == nil then
                    TimeCaption = cfg.message_list['event'];
                    if sepc ~= '.' then
                        TimeCaption = TimeCaption:lower();
                    end
                end                
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (&quot; .. cfg.message_list['in'] .. &quot; &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; &quot; .. cfg.message_list['edition'] .. &quot;)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; &quot; .. cfg.message_list['via'] .. &quot; &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; &quot; .. cfg.message_list['retrieved'] .. &quot; &quot;
         if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
             .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.message_list['subscription'];
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end

    ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD} );

    if ( URL ~= nil and URL ~=&quot;&quot;) then
        URL = &quot; &quot; .. &quot;[&quot; .. URL .. &quot; &quot; .. mw.text.nowiki(URL) .. &quot;]&quot;;
        local error_text = seterror( 'bare_url_missing_title' );
        if config.CitationClass == &quot;web&quot; then
            URL = URL .. &quot; &quot; .. seterror( 'cite_web_title' );
        else
            URL = URL .. error_text;
        end       
    else
        URL = &quot;&quot;
    end

    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot; &quot; .. seterror('archive_missing_date') .. &quot; &quot;
        end
        local arch_text = &quot; &quot; .. cfg.message_list['archived'];
        if (sepc ~= &quot;.&quot;) then arch_text = arch_text:lower() end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; [&quot; .. ArchiveURL .. arch_text .. &quot;] &quot; .. 
                cfg.message_list['from'] .. &quot; &quot; .. cfg.message_list['original'] .. &quot; &quot; .. 
                cfg.message_list['on'] .. ArchiveDate
            if OriginalURL == nil or OriginalUrl == '' then
                Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url_not_dead');                               
            end
        else
            if OriginalURL ~= nil and OriginalURL ~= '' then
                Archived = sepc .. arch_text .. &quot; &quot; .. cfg.message_list['from'] .. &quot; [&quot; .. OriginalURL .. &quot; &quot; .. 
                    cfg.message_list['original'] .. &quot;] &quot; .. cfg.message_list['on'] .. ArchiveDate
            else
                if config.CitationClass ~= 'web' then 
                    Archived = sepc .. arch_text .. &quot; &quot; .. cfg.message_list['from'] .. &quot; &quot; .. 
                    seterror('archive_missing_url') .. &quot; &quot; .. cfg.message_list['on'] .. ArchiveDate
                else
                    Archived = sepc .. arch_text .. &quot; &quot; .. cfg.message_list['from'] .. 
                        &quot; &quot; .. cfg.message_list['original'] .. &quot; &quot; .. 
                        cfg.message_list['on'] .. ArchiveDate
                end
            end                
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        if sepc == '.' then
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; &quot; .. cfg.message_list['lay summary'] .. &quot;]&quot; .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; &quot; .. cfg.message_list['lay summary']:lower() .. &quot;]&quot; .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = &quot;[&quot; .. TranscriptURL .. Transcript .. &quot;]&quot; end
    elseif TranscriptURL ~= nil and TranscriptURL ~= &quot;&quot; then
        Transcript = &quot;[&quot; .. TranscriptURL .. &quot; &quot; .. safeforurl( TranscriptURL ) .. &quot;]&quot; .. 
            seterror( 'bare_url_missing_title' )        
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; and
         config.CitationClass ~= &quot;pressrelease&quot; ) then
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            if Publisher ~= '' then
                Publisher = Publisher .. &quot;, &quot; .. cfg.message_list['published'] .. &quot; &quot; .. PublicationDate;
            else
                Publisher = PublicationDate;
            end
        end
        if Publisher ~= &quot;&quot; then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (&quot; .. cfg.message_list['published'] .. &quot; &quot; .. PublicationDate .. &quot;)&quot;
        else 
            PublicationDate = &quot;&quot;
        end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot; ) or ( TitleNote and TitleNote ~= &quot;&quot; ) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( ( (config.CitationClass == &quot;journal&quot;) or (config.CitationClass == &quot;citation&quot;) )  and
         Periodical ~= &quot;&quot; ) then
        if (Others ~= &quot;&quot;) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
            Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
            Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
    end
    
    if #ID_list &gt; 0 then
        ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
    else
        ID_list = ID;
    end    
    local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );

    local text
    local pgtext = Page .. Pages .. At
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, &quot; .. cfg.message_list['editor'];
            else
                Editors = Editors .. &quot;, &quot; .. cfg.message_list['editors'];
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (&quot; .. cfg.message_list['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (&quot; .. cfg.message_list['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end -- endif &quot;&quot;~=Date
        if ( config.CitationClass==&quot;journal&quot; and Periodical ) then
          text = safejoin( {Chapter, Place, tcommon}, sepc );
          text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
          text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
          text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if PostScript ~= '' and PostScript ~= nil and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local options = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do names[i] = v.last end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do names[i] = v.last end
            end
            if ( names[1] == nil ) then 
                names[1] = Year 
            elseif ( names[2] == nil ) then 
                names[2] = Year 
            elseif ( names[3] == nil ) then
                names[3] = Year
            elseif ( names[4] == nil ) then
                names[4] = Year
            else
                names[5] = Year
            end
            id = anchorid(names)
        end
        options.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = {};
        text = seterror('empty_citation');
        z.message_tail = {};
    end
    
    if options.id ~= nil then 
        text = '&lt;span id=&quot;' .. wikiescape(options.id) ..'&quot; class=&quot;' .. wikiescape(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    else
        text = '&lt;span class=&quot;' .. wikiescape(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    end        

    local empty_span = '&lt;span style=&quot;display: none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = '&lt;span title=&quot;' .. wikiescape(OCinStitle) .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        for i,v in ipairs( z.message_tail ) do
            if i == #z.message_tail then
                text = text .. errorcomment( v[1], v[2] );
            else
                text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
            end
        end
    end
    
    if no_tracking_cats == '' then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    local suggestions = {};
    local error_text, error_state;
    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            if not validate( k ) then            
                error_text = &quot;&quot;;
                if type( k ) ~= 'string' then
                    -- Exclude empty numbered parameters
                    if v:match(&quot;%S+&quot;) ~= nil then
                        error_text, error_state = seterror( 'text_ignored', {v}, true );
                    end
                elseif validate( k:lower() ) then 
                    error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
                else
                    if #suggestions == 0 then
                        suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
                    end
                    if suggestions[ k:lower() ] ~= nil then
                        error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
                    else
                        error_text, error_state = seterror( 'parameter_ignored', {k}, true );
                    end
                end                  
                if error_text ~= '' then
                    table.insert( z.message_tail, {error_text, error_state} );
                end                
            end            
            args[k] = v;
        elseif k == 'postscript' then
            args[k] = v;
        end        
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        if args[k] == nil and (v ~= '' or k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--18Mar2013 Fixed &quot;page=&quot; to override &quot;pages=&quot; as in markup-based cites.
--19Mar2013 Fixed date of class=journal Periodical to show after page.
--19Mar2013 Changed null &quot;postscript=&quot; to suppress end-dot of citation.
--20Mar2013 If CitationClass is journal, show &quot;others=&quot; before title.
--20Mar2013 If CitationClass is book, show &quot;others=&quot; before edition.
--20Mar2013 If CitationClass is journal, adjust &quot;others=&quot; to have sepc.
--20Mar2013 For class &quot;journal&quot;, use book format unless Periodical set.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; after wikilink &quot;.]]&quot; end dot.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; after external &quot;.]&quot; end dot.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; at italic wikilink &quot;.]]&quot; end.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; at italic external &quot;.]&quot; end.
--04Apr2013 Moved sepc before &lt;span class=&quot;reference-accessdate&quot;&gt; for &quot;..&quot;.
--
--End</text>
      <sha1>3lfcn9guj4j2ni13d1eji9mbloi9l8a</sha1>
    </revision>
    <revision>
      <id>4646</id>
      <parentid>4645</parentid>
      <timestamp>2013-04-11T15:15:33Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>sync to sandbox, add additional redundant parameters checks, check for malformed URLs, removal of wikilinks in COinS data, and various code formatting.</comment>
      <origin>4646</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="69352" sha1="rm33qxcb4rajjuocpfqr4lgj5ub0nqw" xml:space="preserve">local z = {
    error_categories = {};
    error_ids = {};
    message_tail = {};
}

-- Include translation message hooks, ID and error handling configuration settings.
local cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );
 
-- Contains a list of all recognized parameters
local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );

-- Checks that parameter name is valid
function validate( name )
    name = tostring( name );
    
    -- Normal arguments
    if whitelist.basic_arguments[ name ] then
        return true;
    end
    
    -- Arguments with numbers in them
    name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );
    if whitelist.numbered_arguments[ name ] then
        return true;
    end
    
    -- Not found, argument not supported.
    return false
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
    if hidden then 
        return '&lt;span style=&quot;display:none;font-size:100%&quot; class=&quot;error citation-comment&quot;&gt;' .. content .. '&lt;/span&gt;';
    else
        return '&lt;span style=&quot;font-size:100%&quot; class=&quot;error&quot;&gt;' .. content .. '&lt;/span&gt;';
    end        
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, args, raw )
    local error_state = cfg.error_conditions[ error_id ];

    if error_state == nil then
        error( cfg.message_list['undefined_error'] );
    end
    
    if error_state.category ~= nil and error_state.category ~= &quot;&quot; then
        table.insert( z.error_categories, error_state.category );
    end
    
    local message = error_state.message;
    if args ~= nil then
        for k, m in ipairs( args ) do
            m = m:gsub( &quot;%%&quot;, &quot;%%%%&quot; );
            message = message:gsub( &quot;$&quot; .. k .. &quot;(%D)&quot;, m .. &quot;%1&quot; );
        end
    end

    message = wikiescape(message) .. &quot; ([[&quot; .. cfg.message_list['help page link'] .. 
        &quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
        cfg.message_list['help page label'] .. &quot;]])&quot;;

    z.error_ids[ error_id ] = true;
    if (error_id == 'bare_url_missing_title' or error_id == 'trans_missing_title')
            and z.error_ids['citation_missing_title'] then
        return '', false;
    end
    
    if raw == true then
        return message, error_state.hidden;
    end        
        
    return errorcomment( message, error_state.hidden );
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',    
            ['{'] = '&amp;#123;',    
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

-- Formats a wiki style external link
function externallinkid(options)
    local sep = options.separator or &quot;&amp;nbsp;&quot;
    options.suffix = options.suffix or &quot;&quot;
    local url_string = options.id
    if options.encode == true or options.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    return &quot;[[&quot; .. options.link .. &quot;|&quot; .. options.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. 
            options.prefix .. url_string .. options.suffix .. &quot; &quot; .. mw.text.nowiki(options.id) .. &quot;]&quot;
end

-- Formats a wiki style internal link
function internallinkid(options)
    local sep = options.separator or &quot;&amp;nbsp;&quot;
    options.suffix = options.suffix or &quot;&quot;
    return &quot;[[&quot; .. options.link .. &quot;|&quot; .. options.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. 
            options.prefix .. options.id .. options.suffix .. &quot;|&quot; .. mw.text.nowiki(options.id) .. &quot;]]&quot;
end

-- Format an external link with error checking
function externallink( URL, label )
    local error_str = &quot;&quot;;
    if label == nil or label == &quot;&quot; then
        label = URL;
        error_str = seterror( 'bare_url_missing_title' );
    end
    if not checkurl( URL ) then
        error_str = seterror( 'bad_url' ) .. error_str;
    end

    return &quot;[&quot; .. URL .. ' ' .. safeforurl( label ) .. &quot;]&quot; .. error_str;
end

-- Formats a link to Amazon
function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local handler = cfg.id_handlers['ASIN'];
    return externallinkid({link = handler.link,
        label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
        encode=handler.encode, separator = handler.separator})
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    local handler = cfg.id_handlers['DOI'];
    
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (&quot; .. cfg.message_list['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link = handler.link, label = handler.label,
            prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then      
        cat = seterror( 'bad_doi' );
    end
    return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    local handler = cfg.id_handlers['OL'];
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    else
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode}) .. 
            ' ' .. seterror( 'bad_ol' );
    end
end

--[[
Determines whether an URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
    if url_str:sub(1,2) == &quot;//&quot; then  
        -- Protocol-less URLs
        return true;
    elseif url_str:match( &quot;^[^/]*:&quot; ) ~= nil then   
        -- Look for &quot;:&quot; prefix and assume it is a URI scheme
        return true;
    else
        -- Anything else is an error
        return false;
    end
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
    isbn_str = isbn_str:gsub(&quot;[- ]&quot;, &quot;&quot;):upper();
    local len = isbn_str:len();
 
    if len ~= 10 and len ~= 13 then
        return false;
    end
 
    local temp = 0;
    if len == 10 then
        if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            if v == string.byte( &quot;X&quot; ) then
                temp = temp + 10*( 11 - i );
            else
                temp = temp + tonumber( string.char(v) )*(11-i);
            end
        end
        return temp % 11 == 0;
    else
        if isbn_str:match( &quot;^%d*$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
        end
        return temp % 10 == 0;
    end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
    str = str:gsub( &quot;%[%[[^|%]]*|([^%]]*)%]%]&quot;, &quot;%1&quot; );
    str = str:gsub( &quot;%[%[([^%]]*)%]%]&quot;, &quot;%1&quot; );    
    return str
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    if str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then 
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    -- Is the input a simple number?
    local num = tonumber( str ); 
    if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
        return str;
    else
        -- Use formatDate to interpret more complicated formats
        local lang = mw.getContentLanguage();
        local good, result;
        good, result = pcall( lang.formatDate, lang, 'Y', str )
        if good then 
            return result;
        else
            -- Can't make sense of this input, return blank.
            return &quot;&quot;;
        end
    end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil and first ~= '') then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    if count &gt; 1 and lastauthoramp ~= nil and lastauthoramp ~= &quot;&quot; and not etal then
        text[count-1] = text[count-1] .. &quot; &amp; &quot; .. text[count];
        text[count] = nil;
    end    
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = cfg.message_list['et al'];
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result = 
        '&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
    end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
    return &quot;CITEREF&quot; .. mw.uri.anchorEncode( table.concat( options ) );
end

-- Gets author list from the input arguments
function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    while true do
        if i == 1 then 
            last = selectone( args, {&quot;author&quot; .. i .. &quot;-last&quot;, &quot;author-last&quot; .. i, 
                &quot;last&quot; .. i, &quot;surname&quot; .. i, &quot;Author&quot; .. i, &quot;author&quot; .. i, 
                &quot;author-last&quot;, &quot;last&quot;, &quot;surname&quot;, &quot;Author&quot;, &quot;author&quot;, &quot;authors&quot;}, 'redundant_parameters' );
        else
            last = selectone( args, {&quot;author&quot; .. i .. &quot;-last&quot;, &quot;author-last&quot; .. i, 
                &quot;last&quot; .. i, &quot;surname&quot; .. i, &quot;Author&quot; .. i, &quot;author&quot; .. i}, 'redundant_parameters' );
        end
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            if i == 1 then 
                authors[i] = {
                    last = last,
                    first = selectone( args, {&quot;author&quot; .. i .. &quot;-first&quot;, &quot;author-first&quot; .. i, 
                        &quot;first&quot; .. i, &quot;given&quot; .. i, &quot;author-first&quot;, 
                        &quot;first&quot;, &quot;given&quot;}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;author&quot; .. i .. &quot;-link&quot;, &quot;author-link&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;link&quot;, &quot;authorlink&quot; .. i, &quot;author-link&quot;,  
                        &quot;authorlink&quot;}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;author&quot; .. i .. &quot;-mask&quot;, &quot;author-mask&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;mask&quot;, &quot;authormask&quot; .. i, &quot;author-mask&quot;, 
                        &quot;authormask&quot; }, 'redundant_parameters' )
                }
            else
                authors[i] = {
                    last = last,
                    first = selectone( args, {&quot;author&quot; .. i .. &quot;-first&quot;, &quot;author-first&quot; .. i, 
                        &quot;first&quot; .. i, &quot;given&quot; .. i}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;author&quot; .. i .. &quot;-link&quot;, &quot;author-link&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;link&quot;, &quot;authorlink&quot; .. i}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;author&quot; .. i .. &quot;-mask&quot;, &quot;author-mask&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;mask&quot;, &quot;authormask&quot; .. i}, 'redundant_parameters' )
                }
            end            
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

-- Gets editor list from the input arguments
function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        if i == 1 then
            last = selectone( args, {&quot;editor&quot; .. i .. &quot;-last&quot;, &quot;editor-last&quot; .. i,
                &quot;EditorSurname&quot; .. i, &quot;Editor&quot; .. i, &quot;editor&quot; .. i, &quot;editor-last&quot;, 
                &quot;EditorSurname&quot;, &quot;Editor&quot;, &quot;editor&quot;, &quot;editors&quot;}, 'redundant_parameters' );
        else
            last = selectone( args, {&quot;editor&quot; .. i .. &quot;-last&quot;, &quot;editor-last&quot; .. i,
                &quot;EditorSurname&quot; .. i, &quot;Editor&quot; .. i, &quot;editor&quot; .. i}, 'redundant_parameters' );
        end        
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            if i == 1 then
                editors[i] = {
                    last = last,
                    first = selectone( args, {&quot;editor&quot; .. i .. &quot;-first&quot;, 
                        &quot;editor-first&quot; .. i, &quot;EditorGiven&quot; .. i, &quot;editor-first&quot;, 
                        &quot;EditorGiven&quot;}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;editor&quot; .. i .. &quot;-link&quot;, &quot;editor-link&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;link&quot;, &quot;editorlink&quot; .. i, &quot;editor-link&quot;, 
                        &quot;editorlink&quot;}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;editor&quot; .. i .. &quot;-mask&quot;, &quot;editor-mask&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;mask&quot;, &quot;editormask&quot; .. i, &quot;editor-mask&quot;,  
                        &quot;editormask&quot;}, 'redundant_parameters' )
                }                
            else
                editors[i] = {
                    last = last,
                    first = selectone( args, {&quot;editor&quot; .. i .. &quot;-first&quot;, 
                        &quot;editor-first&quot; .. i, &quot;EditorGiven&quot; .. i}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;editor&quot; .. i .. &quot;-link&quot;, &quot;editor-link&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;link&quot;, &quot;editorlink&quot; .. i}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;editor&quot; .. i .. &quot;-mask&quot;, &quot;editor-mask&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;mask&quot;, &quot;editormask&quot; .. i}, 'redundant_parameters' )
                }
            end
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
    local id_list = {};
    
    for k, v in pairs( cfg.id_handlers ) do    
        id_list[k] = selectone( args, v.parameters, 'redundant_parameters' );
    end

    return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
    local handler;
    local new_list = {};
    
    for k, v in pairs( id_list ) do
        handler = {};
        
        --Becasue cfg is read-only we have to copy it the hard way.
        for k2, v2 in pairs( cfg.id_handlers[k] ) do
            handler[k2] = v2;
        end
        handler['id'] = v;
        
        if handler.mode == 'external' then        
            table.insert( new_list, {handler.label, externallinkid( handler ) } );
        elseif handler.mode == 'internal' then
            table.insert( new_list, {handler.label, internallinkid( handler ) } );
        elseif handler.mode == 'manual' then
            if k == 'DOI' then
                table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
            elseif k == 'ASIN' then
                table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
            elseif k == 'OL' then
                table.insert( new_list, {handler.label, openlibrary( v ) } );
            elseif k == 'ISBN' then
                local ISBN = internallinkid( handler );
                if not checkisbn( v ) and (IgnoreISBN == nil or IgnoreISBN == &quot;&quot;) then 
                    ISBN = ISBN .. seterror( 'bad_isbn' );
                end
                table.insert( new_list, {handler.label, ISBN } );                
            else
                error( cfg.message_list['unknown_manual_ID'] );
            end            
        else
            error( cfg.message_list['unknown_ID_mode'] );
        end
    end

    function comp( a, b )
        return a[1] &lt; b[1];
    end

    table.sort( new_list, comp );
    for k, v in ipairs( new_list ) do
        new_list[k] = v[2];
    end
    
    return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition )
    local value = nil;
    local selected = '';
    local error_list = {};
    
    for _, v in ipairs( possible ) do
        if args[v] ~= nil then
            if value ~= nil then
                table.insert( error_list, v );
            else
                value = args[v];
                selected = v;
            end
        end
    end
            
    if #error_list &gt; 0 then
        local error_str = &quot;&quot;;
        for _, k in ipairs( error_list ) do
            if error_str ~= &quot;&quot; then error_str = error_str .. &quot;, &quot; end
            error_str = error_str .. &quot;&lt;code&gt;|&quot; .. k .. &quot;=&lt;/code&gt;&quot;;
        end
        if #error_list &gt; 1 then
            error_str = error_str .. &quot;, and &quot;;
        else
            error_str = error_str .. &quot; and &quot;;
        end
        error_str = error_str .. &quot;&lt;code&gt;|&quot; .. selected .. &quot;=&lt;/code&gt;&quot;;
        table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
    end
            
    return value, selected;
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    -- Load Input Parameters

    local i 
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = args.authors
    local a = extractauthors( args );

    local Coauthors = selectone( args, {'coauthors', 'coauthor' }, 'redundant_parameters' );
    local Others = args.others 
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = selectone( args, {'publicationdate', 'publication-date' }, 'redundant_parameters' );
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = selectone( args, {'trans-title', 'trans_title' }, 'redundant_parameters' );
    local TitleNote = args.department
    local TitleLink = selectone( args, {'titlelink', 'episodelink' }, 'redundant_parameters' );
    local Chapter = selectone( args, {'chapter', 'contribution', 'entry' }, 'redundant_parameters' );
    local ChapterLink = args.chapterlink
    local TransChapter = selectone( args, {'trans-chapter', 'trans_chapter' }, 'redundant_parameters' );
    local TitleType = args.type
    local ArchiveURL = selectone( args, {'archive-url', 'archiveurl' }, 'redundant_parameters' );
    local URL = selectone( args, {'url', 'URL'}, 'redundant_parameters' );
    local ChapterURL = selectone( args, {'chapter-url', 'chapterurl', 'contribution-url', 'contributionurl' }, 'redundant_parameters' );
    local ConferenceURL = selectone( args, {'conference-url', 'conferenceurl' }, 'redundant_parameters' );
    local Periodical = selectone( args, {'journal', 'newspaper', 'magazine', 'work', 'website', 
        'periodical', 'encyclopedia', 'encyclopaedia'}, 'redundant_parameters' );
            
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = nil          
            TransTitle = nil
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = nil 
                TransTitle = nil
            end
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = nil end
        end
    end
    local Series = selectone( args, {'series', 'version'}, 'redundant_parameters' );
    local Volume = args.volume
    local Issue = selectone( args, {'issue', 'number'}, 'redundant_parameters' );
    local Position = nil
    local Page, Pages, At, page_type;
    
    Page, page_type = selectone( args, {'p', 'page', 'pp', 'pages', 'at'}, 
        'extra_pages' );
    if page_type == 'pp' or page_type == 'pages' then
        Pages = hyphentodash( Page );
        Page = nil;
    elseif page_type == 'at' then
        At = Page;
        Page = nil;
    end
                
    local Edition = args.edition
    local PublicationPlace = selectone( args, {'publication-place', 'publicationplace' }, 'redundant_parameters' ); 
    local Place = selectone( args, {'place', 'location'}, 'redundant_parameters' );
    if PublicationPlace == nil and Place ~= nil then 
        PublicationPlace = Place;
    end
    if PublicationPlace == Place then Place = nil end
    
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = selectone( args, {'access-date', 'accessdate' }, 'redundant_parameters' );
    local ArchiveDate = selectone( args, {'archive-date', 'archivedate' }, 'redundant_parameters' );
    local Agency = args.agency
    local DeadURL = args.deadurl or &quot;yes&quot;           -- Only used if ArchiveURL is present.
    local Language = selectone( args, {'language', 'in'}, 'redundant_parameters' );
    local Format = args.format
    local Ref = selectone( args, {'ref', 'Ref'}, 'redundant_parameters' );

    local DoiBroken = selectone( args, {'doi_inactivedate', 'doi_brokendate', 'DoiBroken'}, 'redundant_parameters' );
    local ID = selectone( args, {'id', 'ID', 'docket'}, 'redundant_parameters' );
    local ASINTLD = selectone( args, {'ASIN-TLD', 'asin-tld'}, 'redundant_parameters' );
    local IgnoreISBN = selectone( args, {'ignore-isbn-error', 'ignoreisbnerror'}, 'redundant_parameters' );

    local ID_list = extractids( args );
    
    local Quote = selectone( args, {'quote', 'quotation'}, 'redundant_parameters' );
    local PostScript = args.postscript or &quot;.&quot;
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = selectone( args, {'transcript-url', 'transcripturl'}, 'redundant_parameters' );
    local sepc = args.separator or &quot;.&quot;
    local LastAuthorAmp = args.lastauthoramp
    local no_tracking_cats = selectone( args, {&quot;template doc demo&quot;, 'nocat', 
        'notracking', &quot;no-tracking&quot;}, 'redundant_parameters' ) or &quot;&quot;;

    if ( config.CitationClass == &quot;journal&quot; ) then        
        if (URL == nil or URL == &quot;&quot;) then
            if (ID_list['PMC'] ~= nil) then 
                local Embargo = args.embargo or args.Embargo;
                if Embargo ~= nil then
                    local lang = mw.getContentLanguage();
                    local good1, result1, good2, result2;
                    good1, result1 = pcall( lang.formatDate, lang, 'U', Embargo );
                    good2, result2 = pcall( lang.formatDate, lang, 'U' );

                    if good1 and good2 and tonumber( result1 ) &lt; tonumber( result2 ) then 
                        URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];
                    end
                else
                    URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];           
                end
            end
        end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, cfg.message_list[&quot;episode&quot;] .. &quot; &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, cfg.message_list[&quot;season&quot;] .. &quot; &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, cfg.message_list[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows 
    -- automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
        if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    
    for k, v in pairs( ID_list ) do
        if string.sub( cfg.id_handlers[k].COinS or &quot;info&quot;, 1, 4 ) ~= 'info' then
            OCinSdata[ cfg.id_handlers[k].COinS ] = v;
        end
    end
    
    OCinSdata.rft_id = URL or ChapterURL

    local last, first;
    local OCinSauthors = {};
    for k, v in ipairs( a ) do
        last = v.last;
        first = v.first;
        if k == 1 then
            if last ~= nil then
                OCinSdata[&quot;rft.aulast&quot;] = last;
            end
            if first ~= nil then 
                OCinSdata[&quot;rft.aufirst&quot;] = first;
            end
        end
        if last ~= nil and first ~= nil then
            table.insert( OCinSauthors, last .. (args.NameSep or &quot;, &quot;) .. first );
    	elseif last ~= nil then
            table.insert( OCinSauthors, last );
        end
    end

    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    for k, v in pairs( ID_list ) do
        if string.sub( cfg.id_handlers[k].COinS or &quot;&quot;, 1, 4 ) == 'info' then
            OCinSids[ cfg.id_handlers[k].COinS ] = v;
        end
    end

    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode( removewikilink(value) );
    end
    for _, value in ipairs(OCinSauthors) do
        OCinStitle = OCinStitle .. &quot;&amp;rft.au=&quot; .. mw.uri.encode( removewikilink(value) );
    end
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. removewikilink(value) );
    end
    
    local this_page = mw.title.getCurrentTitle();
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/&quot; .. mw.site.server:match( &quot;[^/]*$&quot; ) .. &quot;:&quot;
       .. this_page.prefixedText  -- end COinS data by page's non-encoded pagename

    if (Periodical ~= nil and Periodical ~= &quot;&quot;) and
        (Chapter == nil or Chapter == '') and
        (Title ~= nil and Title ~= &quot;&quot;) then
            Chapter = Title
            ChapterLink = TitleLink
            TransChapter = TransTitle
            Title = nil
            TitleLink = nil
            TransTitle = nil            
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local Maximum = tonumber( (selectone( args, {&quot;display-authors&quot;, &quot;displayauthors&quot;}, 'redundant_parameters' )) );
        
        -- Preserve old-style implicit et al.
        if Maximum == nil and #a == 9 then 
            Maximum = 8;
            table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
        elseif Maximum == nil then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = (args[&quot;author-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = selectone( args, {&quot;author-format&quot;, &quot;authorformat&quot; }, 'redundant_parameters' ),
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        }
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if Coauthors ~= nil and Coauthors ~= &quot;&quot; then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
                
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local Maximum = tonumber( (selectone( args, {&quot;display-editors&quot;, &quot;displayeditors&quot;}, 'redundant_parameters' )) );

        -- Preserve old-style implicit et al.
        if Maximum == nil and #e == 4 then 
            Maximum = 3;
            table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
        elseif Maximum == nil then
            Maximum = #e + 1;
        end

        local control = { 
            sep = (args[&quot;editor-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = selectone( args, {&quot;editor-format&quot;, &quot;editorformat&quot; }, 'redundant_parameters' ),
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
            }

        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date
    
    if ( URL == nil or URL == '' ) and
            ( ChapterURL == nil or ChapterURL == '' ) and
            ( ArchiveURL == nil or ArchiveURL == '' ) and                
            ( ConferenceURL == nil or ConferenceURL == '' ) and                
            ( TranscriptURL == nil or TranscriptURL == '' ) then

        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
        end

        -- Test if accessdate is given without giving a URL
        if ( AccessDate ~= nil and AccessDate ~= '' ) then
            table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
            AccessDate = nil;
        end      
    
        -- Test if format is given without giving a URL
        if ( Format ~= nil and Format ~= '' ) then
            Format = Format .. seterror( 'format_missing_url' );
        end        
    end    

    -- Test if citation has no title
    if ( Chapter == nil or Chapter == &quot;&quot; ) and 
            ( Title == nil or Title == &quot;&quot; ) and
            ( Periodical == nil or Periodical == &quot;&quot; ) and
            ( Conference == nil or Conference == &quot;&quot; ) and 
            ( TransTitle == nil or TransTitle == &quot;&quot; ) and
            ( TransChapter == nil or TransChapter == &quot;&quot; ) then
        table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
    end

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
        end
    end

    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
        
    -- Format chapter / article title
    if ( Chapter ~= nil and Chapter ~= &quot;&quot; ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) and (Title ~= nil and Title ~= &quot;&quot; )
        then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
    else
        Chapter = &quot;&quot;;
    end
    
    local TransError = &quot;&quot;
    if TransChapter ~= &quot;&quot; and Chapter == &quot;&quot; then
        TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
    end
    Chapter = Chapter .. TransChapter
    if Chapter ~= &quot;&quot; then
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then                
                Chapter = externallink( ChapterURL, Chapter ) .. TransError;
                if URL == nil or URL == &quot;&quot; then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = externallink( URL, Chapter ) .. TransError .. Format;
                URL = nil
                Format = &quot;&quot;
            else
                Chapter = Chapter .. TransError;
            end            
        elseif ChapterURL ~= nil and ChapterURL ~= &quot;&quot; then
            Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL ) .. 
                TransError;
        else
            Chapter = Chapter .. TransError;
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    elseif ChapterURL ~= nil and ChapterURL ~= &quot;&quot; then
        Chapter = &quot; &quot; .. externallink( ChapterURL ) .. sepc .. &quot; &quot;;
    end        
    
    -- Format main title.
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
                or config.CitationClass == &quot;news&quot; 
                or config.CitationClass == &quot;pressrelease&quot; ) and 
                Chapter == &quot;&quot; then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
    else
        Title = &quot;&quot;;
    end    
    
    local TransError = &quot;&quot;;
    if TransTitle ~= &quot;&quot; and Title == &quot;&quot; then
        TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
    end
    Title = Title .. TransTitle
    if Title ~= &quot;&quot; then
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = externallink( URL, Title ) .. TransError .. Format       
            URL = nil
            Format = ''
        else
            Title = Title .. TransError;
        end
    end

    if ( Place ~= nil and Place ~= &quot;&quot; ) then
        if sepc == '.' then
            Place = &quot; &quot; .. cfg.message_list['written'] .. &quot; &quot; .. Place .. sepc .. &quot; &quot;;
        else
            Place = &quot; &quot; .. cfg.message_list['written']:lower() .. &quot; &quot; .. Place .. sepc .. &quot; &quot;;
        end            
    else
        Place = &quot;&quot;;
    end
    
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = externallink( ConferenceURL, Conference );
        end
        Conference = &quot; &quot; .. Conference
    elseif ConferenceURL ~= nil and ConferenceURL ~= &quot;&quot; then
        Conference = &quot; &quot; .. externallink( ConferenceURL );
    else
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.message_list['minutes'];
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption 
                if TimeCaption == nil then
                    TimeCaption = cfg.message_list['event'];
                    if sepc ~= '.' then
                        TimeCaption = TimeCaption:lower();
                    end
                end                
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (&quot; .. cfg.message_list['in'] .. &quot; &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; &quot; .. cfg.message_list['edition'] .. &quot;)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; &quot; .. cfg.message_list['via'] .. &quot; &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; &quot; .. cfg.message_list['retrieved'] .. &quot; &quot;
         if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
             .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.message_list['subscription'];
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end

    ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN} );

    if ( URL ~= nil and URL ~=&quot;&quot;) then
        URL = &quot; &quot; .. externallink( URL, URL );
        local error_text = seterror( 'bare_url_missing_title' );
        if config.CitationClass == &quot;web&quot; then
            URL = URL .. &quot; &quot; .. seterror( 'cite_web_title' );
        else
            URL = URL .. error_text;
        end       
    else
        URL = &quot;&quot;
    end

    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot; &quot; .. seterror('archive_missing_date') .. &quot; &quot;
        end
        local arch_text = cfg.message_list['archived'];
        if (sepc ~= &quot;.&quot;) then arch_text = arch_text:lower() end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; &quot; .. externallink( ArchiveURL, arch_text ) .. &quot; &quot; .. 
                cfg.message_list['from'] .. &quot; &quot; .. cfg.message_list['original'] .. &quot; &quot; .. 
                cfg.message_list['on'] .. ArchiveDate
            if OriginalURL == nil or OriginalUrl == '' then
                Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url_not_dead');                               
            end
        else
            if OriginalURL ~= nil and OriginalURL ~= '' then
                Archived = sepc .. &quot; &quot; .. arch_text .. &quot; &quot; .. cfg.message_list['from'] .. 
                    &quot; &quot; .. externallink( OriginalURL, cfg.message_list['original'] ) .. &quot; &quot;
                    .. cfg.message_list['on'] .. ArchiveDate
            else
                if config.CitationClass ~= 'web' then 
                    Archived = sepc .. &quot; &quot; .. arch_text .. &quot; &quot; .. cfg.message_list['from'] .. &quot; &quot; .. 
                    seterror('archive_missing_url') .. &quot; &quot; .. cfg.message_list['on'] .. ArchiveDate
                else
                    Archived = sepc .. &quot; &quot; .. arch_text .. &quot; &quot; .. cfg.message_list['from'] .. 
                        &quot; &quot; .. cfg.message_list['original'] .. &quot; &quot; .. 
                        cfg.message_list['on'] .. ArchiveDate
                end
            end                
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        if sepc == '.' then
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; &quot; .. cfg.message_list['lay summary'] .. &quot;]&quot; .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; &quot; .. cfg.message_list['lay summary']:lower() .. &quot;]&quot; .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = externallink( TranscriptURL, Transcript ) end
    elseif TranscriptURL ~= nil and TranscriptURL ~= &quot;&quot; then
        Transcript = externallink( TranscriptURL )     
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; and
         config.CitationClass ~= &quot;pressrelease&quot; ) then
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            if Publisher ~= '' then
                Publisher = Publisher .. &quot;, &quot; .. cfg.message_list['published'] .. &quot; &quot; .. PublicationDate;
            else
                Publisher = PublicationDate;
            end
        end
        if Publisher ~= &quot;&quot; then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (&quot; .. cfg.message_list['published'] .. &quot; &quot; .. PublicationDate .. &quot;)&quot;
        else 
            PublicationDate = &quot;&quot;
        end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot; ) or ( TitleNote and TitleNote ~= &quot;&quot; ) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( ( (config.CitationClass == &quot;journal&quot;) or (config.CitationClass == &quot;citation&quot;) )  and
         Periodical ~= &quot;&quot; ) then
        if (Others ~= &quot;&quot;) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
            Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
            Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
    end
    
    if #ID_list &gt; 0 then
        ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
    else
        ID_list = ID;
    end    
    local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );

    local text
    local pgtext = Page .. Pages .. At
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, &quot; .. cfg.message_list['editor'];
            else
                Editors = Editors .. &quot;, &quot; .. cfg.message_list['editors'];
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (&quot; .. cfg.message_list['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (&quot; .. cfg.message_list['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end -- endif &quot;&quot;~=Date
        if ( config.CitationClass==&quot;journal&quot; and Periodical ) then
          text = safejoin( {Chapter, Place, tcommon}, sepc );
          text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
          text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
          text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if PostScript ~= '' and PostScript ~= nil and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local options = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do 
                    names[i] = v.last 
                    if i == 4 then break end
                end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do 
                    names[i] = v.last 
                    if i == 4 then break end                
                end
            end
            names[ #names + 1 ] = Year;
            id = anchorid(names)
        end
        options.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = {};
        text = seterror('empty_citation');
        z.message_tail = {};
    end
    
    if options.id ~= nil then 
        text = '&lt;span id=&quot;' .. wikiescape(options.id) ..'&quot; class=&quot;' .. wikiescape(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    else
        text = '&lt;span class=&quot;' .. wikiescape(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    end        

    local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = '&lt;span title=&quot;' .. wikiescape(OCinStitle) .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        for i,v in ipairs( z.message_tail ) do
            if v[1] ~= nil and v[1] ~= &quot;&quot; then 
                if i == #z.message_tail then
                    text = text .. errorcomment( v[1], v[2] );
                else
                    text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
                end
            end
        end
    end
    
    if no_tracking_cats == '' then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    local suggestions = {};
    local error_text, error_state;
    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            if not validate( k ) then            
                error_text = &quot;&quot;;
                if type( k ) ~= 'string' then
                    -- Exclude empty numbered parameters
                    if v:match(&quot;%S+&quot;) ~= nil then
                        error_text, error_state = seterror( 'text_ignored', {v}, true );
                    end
                elseif validate( k:lower() ) then 
                    error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
                else
                    if #suggestions == 0 then
                        suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
                    end
                    if suggestions[ k:lower() ] ~= nil then
                        error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
                    else
                        error_text, error_state = seterror( 'parameter_ignored', {k}, true );
                    end
                end                  
                if error_text ~= '' then
                    table.insert( z.message_tail, {error_text, error_state} );
                end                
            end            
            args[k] = v;
        elseif k == 'postscript' then
            args[k] = v;
        end        
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        if args[k] == nil and (v ~= '' or k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--18Mar2013 Fixed &quot;page=&quot; to override &quot;pages=&quot; as in markup-based cites.
--19Mar2013 Fixed date of class=journal Periodical to show after page.
--19Mar2013 Changed null &quot;postscript=&quot; to suppress end-dot of citation.
--20Mar2013 If CitationClass is journal, show &quot;others=&quot; before title.
--20Mar2013 If CitationClass is book, show &quot;others=&quot; before edition.
--20Mar2013 If CitationClass is journal, adjust &quot;others=&quot; to have sepc.
--20Mar2013 For class &quot;journal&quot;, use book format unless Periodical set.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; after wikilink &quot;.]]&quot; end dot.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; after external &quot;.]&quot; end dot.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; at italic wikilink &quot;.]]&quot; end.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; at italic external &quot;.]&quot; end.
--04Apr2013 Moved sepc before &lt;span class=&quot;reference-accessdate&quot;&gt; for &quot;..&quot;.
--
--End</text>
      <sha1>rm33qxcb4rajjuocpfqr4lgj5ub0nqw</sha1>
    </revision>
    <revision>
      <id>4647</id>
      <parentid>4646</parentid>
      <timestamp>2013-04-11T16:58:02Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>sync to sandbox, this creates temporary transitional hidden error for cite web archiveurl.  This will be merged into the visible archiveurl errors next week or so.</comment>
      <origin>4647</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="69394" sha1="fnm43o8r25y1l6xdlddthiqcxrk4zp7" xml:space="preserve">local z = {
    error_categories = {};
    error_ids = {};
    message_tail = {};
}

-- Include translation message hooks, ID and error handling configuration settings.
local cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );
 
-- Contains a list of all recognized parameters
local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );

-- Checks that parameter name is valid
function validate( name )
    name = tostring( name );
    
    -- Normal arguments
    if whitelist.basic_arguments[ name ] then
        return true;
    end
    
    -- Arguments with numbers in them
    name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );
    if whitelist.numbered_arguments[ name ] then
        return true;
    end
    
    -- Not found, argument not supported.
    return false
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
    if hidden then 
        return '&lt;span style=&quot;display:none;font-size:100%&quot; class=&quot;error citation-comment&quot;&gt;' .. content .. '&lt;/span&gt;';
    else
        return '&lt;span style=&quot;font-size:100%&quot; class=&quot;error&quot;&gt;' .. content .. '&lt;/span&gt;';
    end        
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, args, raw )
    local error_state = cfg.error_conditions[ error_id ];

    if error_state == nil then
        error( cfg.message_list['undefined_error'] );
    end
    
    if error_state.category ~= nil and error_state.category ~= &quot;&quot; then
        table.insert( z.error_categories, error_state.category );
    end
    
    local message = error_state.message;
    if args ~= nil then
        for k, m in ipairs( args ) do
            m = m:gsub( &quot;%%&quot;, &quot;%%%%&quot; );
            message = message:gsub( &quot;$&quot; .. k .. &quot;(%D)&quot;, m .. &quot;%1&quot; );
        end
    end

    message = wikiescape(message) .. &quot; ([[&quot; .. cfg.message_list['help page link'] .. 
        &quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
        cfg.message_list['help page label'] .. &quot;]])&quot;;

    z.error_ids[ error_id ] = true;
    if (error_id == 'bare_url_missing_title' or error_id == 'trans_missing_title')
            and z.error_ids['citation_missing_title'] then
        return '', false;
    end
    
    if raw == true then
        return message, error_state.hidden;
    end        
        
    return errorcomment( message, error_state.hidden );
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',    
            ['{'] = '&amp;#123;',    
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

-- Formats a wiki style external link
function externallinkid(options)
    local sep = options.separator or &quot;&amp;nbsp;&quot;
    options.suffix = options.suffix or &quot;&quot;
    local url_string = options.id
    if options.encode == true or options.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    return &quot;[[&quot; .. options.link .. &quot;|&quot; .. options.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. 
            options.prefix .. url_string .. options.suffix .. &quot; &quot; .. mw.text.nowiki(options.id) .. &quot;]&quot;
end

-- Formats a wiki style internal link
function internallinkid(options)
    local sep = options.separator or &quot;&amp;nbsp;&quot;
    options.suffix = options.suffix or &quot;&quot;
    return &quot;[[&quot; .. options.link .. &quot;|&quot; .. options.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. 
            options.prefix .. options.id .. options.suffix .. &quot;|&quot; .. mw.text.nowiki(options.id) .. &quot;]]&quot;
end

-- Format an external link with error checking
function externallink( URL, label )
    local error_str = &quot;&quot;;
    if label == nil or label == &quot;&quot; then
        label = URL;
        error_str = seterror( 'bare_url_missing_title' );
    end
    if not checkurl( URL ) then
        error_str = seterror( 'bad_url' ) .. error_str;
    end

    return &quot;[&quot; .. URL .. ' ' .. safeforurl( label ) .. &quot;]&quot; .. error_str;
end

-- Formats a link to Amazon
function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local handler = cfg.id_handlers['ASIN'];
    return externallinkid({link = handler.link,
        label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
        encode=handler.encode, separator = handler.separator})
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    local handler = cfg.id_handlers['DOI'];
    
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (&quot; .. cfg.message_list['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link = handler.link, label = handler.label,
            prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then      
        cat = seterror( 'bad_doi' );
    end
    return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    local handler = cfg.id_handlers['OL'];
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    else
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode}) .. 
            ' ' .. seterror( 'bad_ol' );
    end
end

--[[
Determines whether an URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
    if url_str:sub(1,2) == &quot;//&quot; then  
        -- Protocol-less URLs
        return true;
    elseif url_str:match( &quot;^[^/]*:&quot; ) ~= nil then   
        -- Look for &quot;:&quot; prefix and assume it is a URI scheme
        return true;
    else
        -- Anything else is an error
        return false;
    end
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
    isbn_str = isbn_str:gsub(&quot;[- ]&quot;, &quot;&quot;):upper();
    local len = isbn_str:len();
 
    if len ~= 10 and len ~= 13 then
        return false;
    end
 
    local temp = 0;
    if len == 10 then
        if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            if v == string.byte( &quot;X&quot; ) then
                temp = temp + 10*( 11 - i );
            else
                temp = temp + tonumber( string.char(v) )*(11-i);
            end
        end
        return temp % 11 == 0;
    else
        if isbn_str:match( &quot;^%d*$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
        end
        return temp % 10 == 0;
    end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
    str = str:gsub( &quot;%[%[[^|%]]*|([^%]]*)%]%]&quot;, &quot;%1&quot; );
    str = str:gsub( &quot;%[%[([^%]]*)%]%]&quot;, &quot;%1&quot; );    
    return str
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    if str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then 
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    -- Is the input a simple number?
    local num = tonumber( str ); 
    if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
        return str;
    else
        -- Use formatDate to interpret more complicated formats
        local lang = mw.getContentLanguage();
        local good, result;
        good, result = pcall( lang.formatDate, lang, 'Y', str )
        if good then 
            return result;
        else
            -- Can't make sense of this input, return blank.
            return &quot;&quot;;
        end
    end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil and first ~= '') then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    if count &gt; 1 and lastauthoramp ~= nil and lastauthoramp ~= &quot;&quot; and not etal then
        text[count-1] = text[count-1] .. &quot; &amp; &quot; .. text[count];
        text[count] = nil;
    end    
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = cfg.message_list['et al'];
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result = 
        '&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
    end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
    return &quot;CITEREF&quot; .. mw.uri.anchorEncode( table.concat( options ) );
end

-- Gets author list from the input arguments
function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    while true do
        if i == 1 then 
            last = selectone( args, {&quot;author&quot; .. i .. &quot;-last&quot;, &quot;author-last&quot; .. i, 
                &quot;last&quot; .. i, &quot;surname&quot; .. i, &quot;Author&quot; .. i, &quot;author&quot; .. i, 
                &quot;author-last&quot;, &quot;last&quot;, &quot;surname&quot;, &quot;Author&quot;, &quot;author&quot;, &quot;authors&quot;}, 'redundant_parameters' );
        else
            last = selectone( args, {&quot;author&quot; .. i .. &quot;-last&quot;, &quot;author-last&quot; .. i, 
                &quot;last&quot; .. i, &quot;surname&quot; .. i, &quot;Author&quot; .. i, &quot;author&quot; .. i}, 'redundant_parameters' );
        end
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            if i == 1 then 
                authors[i] = {
                    last = last,
                    first = selectone( args, {&quot;author&quot; .. i .. &quot;-first&quot;, &quot;author-first&quot; .. i, 
                        &quot;first&quot; .. i, &quot;given&quot; .. i, &quot;author-first&quot;, 
                        &quot;first&quot;, &quot;given&quot;}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;author&quot; .. i .. &quot;-link&quot;, &quot;author-link&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;link&quot;, &quot;authorlink&quot; .. i, &quot;author-link&quot;,  
                        &quot;authorlink&quot;}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;author&quot; .. i .. &quot;-mask&quot;, &quot;author-mask&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;mask&quot;, &quot;authormask&quot; .. i, &quot;author-mask&quot;, 
                        &quot;authormask&quot; }, 'redundant_parameters' )
                }
            else
                authors[i] = {
                    last = last,
                    first = selectone( args, {&quot;author&quot; .. i .. &quot;-first&quot;, &quot;author-first&quot; .. i, 
                        &quot;first&quot; .. i, &quot;given&quot; .. i}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;author&quot; .. i .. &quot;-link&quot;, &quot;author-link&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;link&quot;, &quot;authorlink&quot; .. i}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;author&quot; .. i .. &quot;-mask&quot;, &quot;author-mask&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;mask&quot;, &quot;authormask&quot; .. i}, 'redundant_parameters' )
                }
            end            
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

-- Gets editor list from the input arguments
function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        if i == 1 then
            last = selectone( args, {&quot;editor&quot; .. i .. &quot;-last&quot;, &quot;editor-last&quot; .. i,
                &quot;EditorSurname&quot; .. i, &quot;Editor&quot; .. i, &quot;editor&quot; .. i, &quot;editor-last&quot;, 
                &quot;EditorSurname&quot;, &quot;Editor&quot;, &quot;editor&quot;, &quot;editors&quot;}, 'redundant_parameters' );
        else
            last = selectone( args, {&quot;editor&quot; .. i .. &quot;-last&quot;, &quot;editor-last&quot; .. i,
                &quot;EditorSurname&quot; .. i, &quot;Editor&quot; .. i, &quot;editor&quot; .. i}, 'redundant_parameters' );
        end        
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            if i == 1 then
                editors[i] = {
                    last = last,
                    first = selectone( args, {&quot;editor&quot; .. i .. &quot;-first&quot;, 
                        &quot;editor-first&quot; .. i, &quot;EditorGiven&quot; .. i, &quot;editor-first&quot;, 
                        &quot;EditorGiven&quot;}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;editor&quot; .. i .. &quot;-link&quot;, &quot;editor-link&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;link&quot;, &quot;editorlink&quot; .. i, &quot;editor-link&quot;, 
                        &quot;editorlink&quot;}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;editor&quot; .. i .. &quot;-mask&quot;, &quot;editor-mask&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;mask&quot;, &quot;editormask&quot; .. i, &quot;editor-mask&quot;,  
                        &quot;editormask&quot;}, 'redundant_parameters' )
                }                
            else
                editors[i] = {
                    last = last,
                    first = selectone( args, {&quot;editor&quot; .. i .. &quot;-first&quot;, 
                        &quot;editor-first&quot; .. i, &quot;EditorGiven&quot; .. i}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;editor&quot; .. i .. &quot;-link&quot;, &quot;editor-link&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;link&quot;, &quot;editorlink&quot; .. i}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;editor&quot; .. i .. &quot;-mask&quot;, &quot;editor-mask&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;mask&quot;, &quot;editormask&quot; .. i}, 'redundant_parameters' )
                }
            end
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
    local id_list = {};
    
    for k, v in pairs( cfg.id_handlers ) do    
        id_list[k] = selectone( args, v.parameters, 'redundant_parameters' );
    end

    return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
    local handler;
    local new_list = {};
    
    for k, v in pairs( id_list ) do
        handler = {};
        
        --Becasue cfg is read-only we have to copy it the hard way.
        for k2, v2 in pairs( cfg.id_handlers[k] ) do
            handler[k2] = v2;
        end
        handler['id'] = v;
        
        if handler.mode == 'external' then        
            table.insert( new_list, {handler.label, externallinkid( handler ) } );
        elseif handler.mode == 'internal' then
            table.insert( new_list, {handler.label, internallinkid( handler ) } );
        elseif handler.mode == 'manual' then
            if k == 'DOI' then
                table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
            elseif k == 'ASIN' then
                table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
            elseif k == 'OL' then
                table.insert( new_list, {handler.label, openlibrary( v ) } );
            elseif k == 'ISBN' then
                local ISBN = internallinkid( handler );
                if not checkisbn( v ) and (IgnoreISBN == nil or IgnoreISBN == &quot;&quot;) then 
                    ISBN = ISBN .. seterror( 'bad_isbn' );
                end
                table.insert( new_list, {handler.label, ISBN } );                
            else
                error( cfg.message_list['unknown_manual_ID'] );
            end            
        else
            error( cfg.message_list['unknown_ID_mode'] );
        end
    end

    function comp( a, b )
        return a[1] &lt; b[1];
    end

    table.sort( new_list, comp );
    for k, v in ipairs( new_list ) do
        new_list[k] = v[2];
    end
    
    return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition )
    local value = nil;
    local selected = '';
    local error_list = {};
    
    for _, v in ipairs( possible ) do
        if args[v] ~= nil then
            if value ~= nil then
                table.insert( error_list, v );
            else
                value = args[v];
                selected = v;
            end
        end
    end
            
    if #error_list &gt; 0 then
        local error_str = &quot;&quot;;
        for _, k in ipairs( error_list ) do
            if error_str ~= &quot;&quot; then error_str = error_str .. &quot;, &quot; end
            error_str = error_str .. &quot;&lt;code&gt;|&quot; .. k .. &quot;=&lt;/code&gt;&quot;;
        end
        if #error_list &gt; 1 then
            error_str = error_str .. &quot;, and &quot;;
        else
            error_str = error_str .. &quot; and &quot;;
        end
        error_str = error_str .. &quot;&lt;code&gt;|&quot; .. selected .. &quot;=&lt;/code&gt;&quot;;
        table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
    end
            
    return value, selected;
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    -- Load Input Parameters

    local i 
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = args.authors
    local a = extractauthors( args );

    local Coauthors = selectone( args, {'coauthors', 'coauthor' }, 'redundant_parameters' );
    local Others = args.others 
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = selectone( args, {'publicationdate', 'publication-date' }, 'redundant_parameters' );
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = selectone( args, {'trans-title', 'trans_title' }, 'redundant_parameters' );
    local TitleNote = args.department
    local TitleLink = selectone( args, {'titlelink', 'episodelink' }, 'redundant_parameters' );
    local Chapter = selectone( args, {'chapter', 'contribution', 'entry' }, 'redundant_parameters' );
    local ChapterLink = args.chapterlink
    local TransChapter = selectone( args, {'trans-chapter', 'trans_chapter' }, 'redundant_parameters' );
    local TitleType = args.type
    local ArchiveURL = selectone( args, {'archive-url', 'archiveurl' }, 'redundant_parameters' );
    local URL = selectone( args, {'url', 'URL'}, 'redundant_parameters' );
    local ChapterURL = selectone( args, {'chapter-url', 'chapterurl', 'contribution-url', 'contributionurl' }, 'redundant_parameters' );
    local ConferenceURL = selectone( args, {'conference-url', 'conferenceurl' }, 'redundant_parameters' );
    local Periodical = selectone( args, {'journal', 'newspaper', 'magazine', 'work', 'website', 
        'periodical', 'encyclopedia', 'encyclopaedia'}, 'redundant_parameters' );
            
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = nil          
            TransTitle = nil
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = nil 
                TransTitle = nil
            end
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = nil end
        end
    end
    local Series = selectone( args, {'series', 'version'}, 'redundant_parameters' );
    local Volume = args.volume
    local Issue = selectone( args, {'issue', 'number'}, 'redundant_parameters' );
    local Position = nil
    local Page, Pages, At, page_type;
    
    Page, page_type = selectone( args, {'p', 'page', 'pp', 'pages', 'at'}, 
        'extra_pages' );
    if page_type == 'pp' or page_type == 'pages' then
        Pages = hyphentodash( Page );
        Page = nil;
    elseif page_type == 'at' then
        At = Page;
        Page = nil;
    end
                
    local Edition = args.edition
    local PublicationPlace = selectone( args, {'publication-place', 'publicationplace' }, 'redundant_parameters' ); 
    local Place = selectone( args, {'place', 'location'}, 'redundant_parameters' );
    if PublicationPlace == nil and Place ~= nil then 
        PublicationPlace = Place;
    end
    if PublicationPlace == Place then Place = nil end
    
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = selectone( args, {'access-date', 'accessdate' }, 'redundant_parameters' );
    local ArchiveDate = selectone( args, {'archive-date', 'archivedate' }, 'redundant_parameters' );
    local Agency = args.agency
    local DeadURL = args.deadurl or &quot;yes&quot;           -- Only used if ArchiveURL is present.
    local Language = selectone( args, {'language', 'in'}, 'redundant_parameters' );
    local Format = args.format
    local Ref = selectone( args, {'ref', 'Ref'}, 'redundant_parameters' );

    local DoiBroken = selectone( args, {'doi_inactivedate', 'doi_brokendate', 'DoiBroken'}, 'redundant_parameters' );
    local ID = selectone( args, {'id', 'ID', 'docket'}, 'redundant_parameters' );
    local ASINTLD = selectone( args, {'ASIN-TLD', 'asin-tld'}, 'redundant_parameters' );
    local IgnoreISBN = selectone( args, {'ignore-isbn-error', 'ignoreisbnerror'}, 'redundant_parameters' );

    local ID_list = extractids( args );
    
    local Quote = selectone( args, {'quote', 'quotation'}, 'redundant_parameters' );
    local PostScript = args.postscript or &quot;.&quot;
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = selectone( args, {'transcript-url', 'transcripturl'}, 'redundant_parameters' );
    local sepc = args.separator or &quot;.&quot;
    local LastAuthorAmp = args.lastauthoramp
    local no_tracking_cats = selectone( args, {&quot;template doc demo&quot;, 'nocat', 
        'notracking', &quot;no-tracking&quot;}, 'redundant_parameters' ) or &quot;&quot;;

    if ( config.CitationClass == &quot;journal&quot; ) then        
        if (URL == nil or URL == &quot;&quot;) then
            if (ID_list['PMC'] ~= nil) then 
                local Embargo = args.embargo or args.Embargo;
                if Embargo ~= nil then
                    local lang = mw.getContentLanguage();
                    local good1, result1, good2, result2;
                    good1, result1 = pcall( lang.formatDate, lang, 'U', Embargo );
                    good2, result2 = pcall( lang.formatDate, lang, 'U' );

                    if good1 and good2 and tonumber( result1 ) &lt; tonumber( result2 ) then 
                        URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];
                    end
                else
                    URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];           
                end
            end
        end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, cfg.message_list[&quot;episode&quot;] .. &quot; &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, cfg.message_list[&quot;season&quot;] .. &quot; &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, cfg.message_list[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows 
    -- automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
        if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    
    for k, v in pairs( ID_list ) do
        if string.sub( cfg.id_handlers[k].COinS or &quot;info&quot;, 1, 4 ) ~= 'info' then
            OCinSdata[ cfg.id_handlers[k].COinS ] = v;
        end
    end
    
    OCinSdata.rft_id = URL or ChapterURL

    local last, first;
    local OCinSauthors = {};
    for k, v in ipairs( a ) do
        last = v.last;
        first = v.first;
        if k == 1 then
            if last ~= nil then
                OCinSdata[&quot;rft.aulast&quot;] = last;
            end
            if first ~= nil then 
                OCinSdata[&quot;rft.aufirst&quot;] = first;
            end
        end
        if last ~= nil and first ~= nil then
            table.insert( OCinSauthors, last .. (args.NameSep or &quot;, &quot;) .. first );
    	elseif last ~= nil then
            table.insert( OCinSauthors, last );
        end
    end

    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    for k, v in pairs( ID_list ) do
        if string.sub( cfg.id_handlers[k].COinS or &quot;&quot;, 1, 4 ) == 'info' then
            OCinSids[ cfg.id_handlers[k].COinS ] = v;
        end
    end

    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode( removewikilink(value) );
    end
    for _, value in ipairs(OCinSauthors) do
        OCinStitle = OCinStitle .. &quot;&amp;rft.au=&quot; .. mw.uri.encode( removewikilink(value) );
    end
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. removewikilink(value) );
    end
    
    local this_page = mw.title.getCurrentTitle();
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/&quot; .. mw.site.server:match( &quot;[^/]*$&quot; ) .. &quot;:&quot;
       .. this_page.prefixedText  -- end COinS data by page's non-encoded pagename

    if (Periodical ~= nil and Periodical ~= &quot;&quot;) and
        (Chapter == nil or Chapter == '') and
        (Title ~= nil and Title ~= &quot;&quot;) then
            Chapter = Title
            ChapterLink = TitleLink
            TransChapter = TransTitle
            Title = nil
            TitleLink = nil
            TransTitle = nil            
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local Maximum = tonumber( (selectone( args, {&quot;display-authors&quot;, &quot;displayauthors&quot;}, 'redundant_parameters' )) );
        
        -- Preserve old-style implicit et al.
        if Maximum == nil and #a == 9 then 
            Maximum = 8;
            table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
        elseif Maximum == nil then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = (args[&quot;author-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = selectone( args, {&quot;author-format&quot;, &quot;authorformat&quot; }, 'redundant_parameters' ),
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        }
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if Coauthors ~= nil and Coauthors ~= &quot;&quot; then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
                
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local Maximum = tonumber( (selectone( args, {&quot;display-editors&quot;, &quot;displayeditors&quot;}, 'redundant_parameters' )) );

        -- Preserve old-style implicit et al.
        if Maximum == nil and #e == 4 then 
            Maximum = 3;
            table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
        elseif Maximum == nil then
            Maximum = #e + 1;
        end

        local control = { 
            sep = (args[&quot;editor-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = selectone( args, {&quot;editor-format&quot;, &quot;editorformat&quot; }, 'redundant_parameters' ),
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
            }

        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date
    
    if ( URL == nil or URL == '' ) and
            ( ChapterURL == nil or ChapterURL == '' ) and
            ( ArchiveURL == nil or ArchiveURL == '' ) and                
            ( ConferenceURL == nil or ConferenceURL == '' ) and                
            ( TranscriptURL == nil or TranscriptURL == '' ) then

        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
        end

        -- Test if accessdate is given without giving a URL
        if ( AccessDate ~= nil and AccessDate ~= '' ) then
            table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
            AccessDate = nil;
        end      
    
        -- Test if format is given without giving a URL
        if ( Format ~= nil and Format ~= '' ) then
            Format = Format .. seterror( 'format_missing_url' );
        end        
    end    

    -- Test if citation has no title
    if ( Chapter == nil or Chapter == &quot;&quot; ) and 
            ( Title == nil or Title == &quot;&quot; ) and
            ( Periodical == nil or Periodical == &quot;&quot; ) and
            ( Conference == nil or Conference == &quot;&quot; ) and 
            ( TransTitle == nil or TransTitle == &quot;&quot; ) and
            ( TransChapter == nil or TransChapter == &quot;&quot; ) then
        table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
    end

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
        end
    end

    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
        
    -- Format chapter / article title
    if ( Chapter ~= nil and Chapter ~= &quot;&quot; ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) and (Title ~= nil and Title ~= &quot;&quot; )
        then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
    else
        Chapter = &quot;&quot;;
    end
    
    local TransError = &quot;&quot;
    if TransChapter ~= &quot;&quot; and Chapter == &quot;&quot; then
        TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
    end
    Chapter = Chapter .. TransChapter
    if Chapter ~= &quot;&quot; then
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then                
                Chapter = externallink( ChapterURL, Chapter ) .. TransError;
                if URL == nil or URL == &quot;&quot; then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = externallink( URL, Chapter ) .. TransError .. Format;
                URL = nil
                Format = &quot;&quot;
            else
                Chapter = Chapter .. TransError;
            end            
        elseif ChapterURL ~= nil and ChapterURL ~= &quot;&quot; then
            Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL ) .. 
                TransError;
        else
            Chapter = Chapter .. TransError;
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    elseif ChapterURL ~= nil and ChapterURL ~= &quot;&quot; then
        Chapter = &quot; &quot; .. externallink( ChapterURL ) .. sepc .. &quot; &quot;;
    end        
    
    -- Format main title.
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
                or config.CitationClass == &quot;news&quot; 
                or config.CitationClass == &quot;pressrelease&quot; ) and 
                Chapter == &quot;&quot; then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
    else
        Title = &quot;&quot;;
    end    
    
    local TransError = &quot;&quot;;
    if TransTitle ~= &quot;&quot; and Title == &quot;&quot; then
        TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
    end
    Title = Title .. TransTitle
    if Title ~= &quot;&quot; then
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = externallink( URL, Title ) .. TransError .. Format       
            URL = nil
            Format = ''
        else
            Title = Title .. TransError;
        end
    end

    if ( Place ~= nil and Place ~= &quot;&quot; ) then
        if sepc == '.' then
            Place = &quot; &quot; .. cfg.message_list['written'] .. &quot; &quot; .. Place .. sepc .. &quot; &quot;;
        else
            Place = &quot; &quot; .. cfg.message_list['written']:lower() .. &quot; &quot; .. Place .. sepc .. &quot; &quot;;
        end            
    else
        Place = &quot;&quot;;
    end
    
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = externallink( ConferenceURL, Conference );
        end
        Conference = &quot; &quot; .. Conference
    elseif ConferenceURL ~= nil and ConferenceURL ~= &quot;&quot; then
        Conference = &quot; &quot; .. externallink( ConferenceURL );
    else
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.message_list['minutes'];
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption 
                if TimeCaption == nil then
                    TimeCaption = cfg.message_list['event'];
                    if sepc ~= '.' then
                        TimeCaption = TimeCaption:lower();
                    end
                end                
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (&quot; .. cfg.message_list['in'] .. &quot; &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; &quot; .. cfg.message_list['edition'] .. &quot;)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; &quot; .. cfg.message_list['via'] .. &quot; &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; &quot; .. cfg.message_list['retrieved'] .. &quot; &quot;
         if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
             .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.message_list['subscription'];
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end

    ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN} );

    if ( URL ~= nil and URL ~=&quot;&quot;) then
        URL = &quot; &quot; .. externallink( URL, URL );
        local error_text = seterror( 'bare_url_missing_title' );
        if config.CitationClass == &quot;web&quot; then
            URL = URL .. &quot; &quot; .. seterror( 'cite_web_title' );
        else
            URL = URL .. error_text;
        end       
    else
        URL = &quot;&quot;
    end

    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot; &quot; .. seterror('archive_missing_date') .. &quot; &quot;
        end
        local arch_text = cfg.message_list['archived'];
        if (sepc ~= &quot;.&quot;) then arch_text = arch_text:lower() end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; &quot; .. externallink( ArchiveURL, arch_text ) .. &quot; &quot; .. 
                cfg.message_list['from'] .. &quot; &quot; .. cfg.message_list['original'] .. &quot; &quot; .. 
                cfg.message_list['on'] .. ArchiveDate
            if OriginalURL == nil or OriginalUrl == '' then
                Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url_not_dead');                               
            end
        else
            if OriginalURL ~= nil and OriginalURL ~= '' then
                Archived = sepc .. &quot; &quot; .. arch_text .. &quot; &quot; .. cfg.message_list['from'] .. 
                    &quot; &quot; .. externallink( OriginalURL, cfg.message_list['original'] ) .. &quot; &quot;
                    .. cfg.message_list['on'] .. ArchiveDate
            else
                if config.CitationClass ~= 'web' then 
                    Archived = sepc .. &quot; &quot; .. arch_text .. &quot; &quot; .. cfg.message_list['from'] .. &quot; &quot; .. 
                    cfg.message_list['original'] .. seterror('archive_missing_url') .. &quot; &quot; .. cfg.message_list['on'] .. ArchiveDate
                else
                    Archived = sepc .. &quot; &quot; .. arch_text .. &quot; &quot; .. cfg.message_list['from'] .. &quot; &quot; .. 
                    cfg.message_list['original'] .. seterror('archive_missing_url_web') .. &quot; &quot; .. cfg.message_list['on'] .. ArchiveDate
                end
            end                
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        if sepc == '.' then
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; &quot; .. cfg.message_list['lay summary'] .. &quot;]&quot; .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; &quot; .. cfg.message_list['lay summary']:lower() .. &quot;]&quot; .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = externallink( TranscriptURL, Transcript ) end
    elseif TranscriptURL ~= nil and TranscriptURL ~= &quot;&quot; then
        Transcript = externallink( TranscriptURL )     
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; and
         config.CitationClass ~= &quot;pressrelease&quot; ) then
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            if Publisher ~= '' then
                Publisher = Publisher .. &quot;, &quot; .. cfg.message_list['published'] .. &quot; &quot; .. PublicationDate;
            else
                Publisher = PublicationDate;
            end
        end
        if Publisher ~= &quot;&quot; then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (&quot; .. cfg.message_list['published'] .. &quot; &quot; .. PublicationDate .. &quot;)&quot;
        else 
            PublicationDate = &quot;&quot;
        end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot; ) or ( TitleNote and TitleNote ~= &quot;&quot; ) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( ( (config.CitationClass == &quot;journal&quot;) or (config.CitationClass == &quot;citation&quot;) )  and
         Periodical ~= &quot;&quot; ) then
        if (Others ~= &quot;&quot;) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
            Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
            Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
    end
    
    if #ID_list &gt; 0 then
        ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
    else
        ID_list = ID;
    end    
    local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );

    local text
    local pgtext = Page .. Pages .. At
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, &quot; .. cfg.message_list['editor'];
            else
                Editors = Editors .. &quot;, &quot; .. cfg.message_list['editors'];
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (&quot; .. cfg.message_list['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (&quot; .. cfg.message_list['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end -- endif &quot;&quot;~=Date
        if ( config.CitationClass==&quot;journal&quot; and Periodical ) then
          text = safejoin( {Chapter, Place, tcommon}, sepc );
          text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
          text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
          text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if PostScript ~= '' and PostScript ~= nil and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local options = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do 
                    names[i] = v.last 
                    if i == 4 then break end
                end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do 
                    names[i] = v.last 
                    if i == 4 then break end                
                end
            end
            names[ #names + 1 ] = Year;
            id = anchorid(names)
        end
        options.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = {};
        text = seterror('empty_citation');
        z.message_tail = {};
    end
    
    if options.id ~= nil then 
        text = '&lt;span id=&quot;' .. wikiescape(options.id) ..'&quot; class=&quot;' .. wikiescape(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    else
        text = '&lt;span class=&quot;' .. wikiescape(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    end        

    local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = '&lt;span title=&quot;' .. wikiescape(OCinStitle) .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        for i,v in ipairs( z.message_tail ) do
            if v[1] ~= nil and v[1] ~= &quot;&quot; then 
                if i == #z.message_tail then
                    text = text .. errorcomment( v[1], v[2] );
                else
                    text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
                end
            end
        end
    end
    
    if no_tracking_cats == '' then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    local suggestions = {};
    local error_text, error_state;
    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            if not validate( k ) then            
                error_text = &quot;&quot;;
                if type( k ) ~= 'string' then
                    -- Exclude empty numbered parameters
                    if v:match(&quot;%S+&quot;) ~= nil then
                        error_text, error_state = seterror( 'text_ignored', {v}, true );
                    end
                elseif validate( k:lower() ) then 
                    error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
                else
                    if #suggestions == 0 then
                        suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
                    end
                    if suggestions[ k:lower() ] ~= nil then
                        error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
                    else
                        error_text, error_state = seterror( 'parameter_ignored', {k}, true );
                    end
                end                  
                if error_text ~= '' then
                    table.insert( z.message_tail, {error_text, error_state} );
                end                
            end            
            args[k] = v;
        elseif k == 'postscript' then
            args[k] = v;
        end        
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        if args[k] == nil and (v ~= '' or k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--18Mar2013 Fixed &quot;page=&quot; to override &quot;pages=&quot; as in markup-based cites.
--19Mar2013 Fixed date of class=journal Periodical to show after page.
--19Mar2013 Changed null &quot;postscript=&quot; to suppress end-dot of citation.
--20Mar2013 If CitationClass is journal, show &quot;others=&quot; before title.
--20Mar2013 If CitationClass is book, show &quot;others=&quot; before edition.
--20Mar2013 If CitationClass is journal, adjust &quot;others=&quot; to have sepc.
--20Mar2013 For class &quot;journal&quot;, use book format unless Periodical set.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; after wikilink &quot;.]]&quot; end dot.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; after external &quot;.]&quot; end dot.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; at italic wikilink &quot;.]]&quot; end.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; at italic external &quot;.]&quot; end.
--04Apr2013 Moved sepc before &lt;span class=&quot;reference-accessdate&quot;&gt; for &quot;..&quot;.
--
--End</text>
      <sha1>fnm43o8r25y1l6xdlddthiqcxrk4zp7</sha1>
    </revision>
    <revision>
      <id>4648</id>
      <parentid>4647</parentid>
      <timestamp>2013-04-13T01:13:44Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>fix isbn flag, add some spaces</comment>
      <origin>4648</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="69582" sha1="03eky3zcnulgiudayjnyeufj6f0zb1m" xml:space="preserve">local z = {
    error_categories = {};
    error_ids = {};
    message_tail = {};
}

-- Include translation message hooks, ID and error handling configuration settings.
local cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );
 
-- Contains a list of all recognized parameters
local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );

-- Checks that parameter name is valid
function validate( name )
    name = tostring( name );
    
    -- Normal arguments
    if whitelist.basic_arguments[ name ] then
        return true;
    end
    
    -- Arguments with numbers in them
    name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );
    if whitelist.numbered_arguments[ name ] then
        return true;
    end
    
    -- Not found, argument not supported.
    return false
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
    if hidden then 
        return '&lt;span style=&quot;display:none;font-size:100%&quot; class=&quot;error citation-comment&quot;&gt;' .. content .. '&lt;/span&gt;';
    else
        return '&lt;span style=&quot;font-size:100%&quot; class=&quot;error&quot;&gt;' .. content .. '&lt;/span&gt;';
    end        
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, args, raw, prefix, suffix )
    local error_state = cfg.error_conditions[ error_id ];
    prefix = prefix or &quot;&quot;;
    suffix = suffix or &quot;&quot;;

    if error_state == nil then
        error( cfg.message_list['undefined_error'] );
    end
    
    if error_state.category ~= nil and error_state.category ~= &quot;&quot; then
        table.insert( z.error_categories, error_state.category );
    end
    
    local message = error_state.message;
    if args ~= nil then
        for k, m in ipairs( args ) do
            m = m:gsub( &quot;%%&quot;, &quot;%%%%&quot; );
            message = message:gsub( &quot;$&quot; .. k .. &quot;(%D)&quot;, m .. &quot;%1&quot; );
        end
    end

    message = wikiescape(message) .. &quot; ([[&quot; .. cfg.message_list['help page link'] .. 
        &quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
        cfg.message_list['help page label'] .. &quot;]])&quot;;

    z.error_ids[ error_id ] = true;
    if (error_id == 'bare_url_missing_title' or error_id == 'trans_missing_title')
            and z.error_ids['citation_missing_title'] then
        return '', false;
    end
    
    message = prefix .. message .. suffix;
    
    if raw == true then
        return message, error_state.hidden;
    end        
        
    return errorcomment( message, error_state.hidden );
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',    
            ['{'] = '&amp;#123;',    
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

-- Formats a wiki style external link
function externallinkid(options)
    local sep = options.separator or &quot;&amp;nbsp;&quot;
    options.suffix = options.suffix or &quot;&quot;
    local url_string = options.id
    if options.encode == true or options.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    return &quot;[[&quot; .. options.link .. &quot;|&quot; .. options.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. 
            options.prefix .. url_string .. options.suffix .. &quot; &quot; .. mw.text.nowiki(options.id) .. &quot;]&quot;
end

-- Formats a wiki style internal link
function internallinkid(options)
    local sep = options.separator or &quot;&amp;nbsp;&quot;
    options.suffix = options.suffix or &quot;&quot;
    return &quot;[[&quot; .. options.link .. &quot;|&quot; .. options.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. 
            options.prefix .. options.id .. options.suffix .. &quot;|&quot; .. mw.text.nowiki(options.id) .. &quot;]]&quot;
end

-- Format an external link with error checking
function externallink( URL, label )
    local error_str = &quot;&quot;;
    if label == nil or label == &quot;&quot; then
        label = URL;
        error_str = seterror( 'bare_url_missing_title', {}, false, &quot; &quot; );
    end
    if not checkurl( URL ) then
        error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
    end

    return &quot;[&quot; .. URL .. ' ' .. safeforurl( label ) .. &quot;]&quot; .. error_str;
end

-- Formats a link to Amazon
function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local handler = cfg.id_handlers['ASIN'];
    return externallinkid({link = handler.link,
        label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
        encode=handler.encode, separator = handler.separator})
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    local handler = cfg.id_handlers['DOI'];
    
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (&quot; .. cfg.message_list['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link = handler.link, label = handler.label,
            prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then      
        cat = seterror( 'bad_doi' );
    end
    return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    local handler = cfg.id_handlers['OL'];
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    else
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode}) .. 
            ' ' .. seterror( 'bad_ol' );
    end
end

--[[
Determines whether an URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
    if url_str:sub(1,2) == &quot;//&quot; then  
        -- Protocol-less URLs
        return true;
    elseif url_str:match( &quot;^[^/]*:&quot; ) ~= nil then   
        -- Look for &quot;:&quot; prefix and assume it is a URI scheme
        return true;
    else
        -- Anything else is an error
        return false;
    end
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
    isbn_str = isbn_str:gsub(&quot;[- ]&quot;, &quot;&quot;):upper();
    local len = isbn_str:len();
 
    if len ~= 10 and len ~= 13 then
        return false;
    end
 
    local temp = 0;
    if len == 10 then
        if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            if v == string.byte( &quot;X&quot; ) then
                temp = temp + 10*( 11 - i );
            else
                temp = temp + tonumber( string.char(v) )*(11-i);
            end
        end
        return temp % 11 == 0;
    else
        if isbn_str:match( &quot;^%d*$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
        end
        return temp % 10 == 0;
    end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
    str = str:gsub( &quot;%[%[[^|%]]*|([^%]]*)%]%]&quot;, &quot;%1&quot; );
    str = str:gsub( &quot;%[%[([^%]]*)%]%]&quot;, &quot;%1&quot; );    
    return str
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    if str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then 
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str;
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    -- Is the input a simple number?
    local num = tonumber( str ); 
    if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
        return str;
    else
        -- Use formatDate to interpret more complicated formats
        local lang = mw.getContentLanguage();
        local good, result;
        good, result = pcall( lang.formatDate, lang, 'Y', str )
        if good then 
            return result;
        else
            -- Can't make sense of this input, return blank.
            return &quot;&quot;;
        end
    end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil and first ~= '') then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    if count &gt; 1 and lastauthoramp ~= nil and lastauthoramp ~= &quot;&quot; and not etal then
        text[count-1] = text[count-1] .. &quot; &amp; &quot; .. text[count];
        text[count] = nil;
    end    
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = cfg.message_list['et al'];
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result = 
        '&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
    end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
    return &quot;CITEREF&quot; .. mw.uri.anchorEncode( table.concat( options ) );
end

-- Gets author list from the input arguments
function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    while true do
        if i == 1 then 
            last = selectone( args, {&quot;author&quot; .. i .. &quot;-last&quot;, &quot;author-last&quot; .. i, 
                &quot;last&quot; .. i, &quot;surname&quot; .. i, &quot;Author&quot; .. i, &quot;author&quot; .. i, 
                &quot;author-last&quot;, &quot;last&quot;, &quot;surname&quot;, &quot;Author&quot;, &quot;author&quot;, &quot;authors&quot;}, 'redundant_parameters' );
        else
            last = selectone( args, {&quot;author&quot; .. i .. &quot;-last&quot;, &quot;author-last&quot; .. i, 
                &quot;last&quot; .. i, &quot;surname&quot; .. i, &quot;Author&quot; .. i, &quot;author&quot; .. i}, 'redundant_parameters' );
        end
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            if i == 1 then 
                authors[i] = {
                    last = last,
                    first = selectone( args, {&quot;author&quot; .. i .. &quot;-first&quot;, &quot;author-first&quot; .. i, 
                        &quot;first&quot; .. i, &quot;given&quot; .. i, &quot;author-first&quot;, 
                        &quot;first&quot;, &quot;given&quot;}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;author&quot; .. i .. &quot;-link&quot;, &quot;author-link&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;link&quot;, &quot;authorlink&quot; .. i, &quot;author-link&quot;,  
                        &quot;authorlink&quot;}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;author&quot; .. i .. &quot;-mask&quot;, &quot;author-mask&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;mask&quot;, &quot;authormask&quot; .. i, &quot;author-mask&quot;, 
                        &quot;authormask&quot; }, 'redundant_parameters' )
                }
            else
                authors[i] = {
                    last = last,
                    first = selectone( args, {&quot;author&quot; .. i .. &quot;-first&quot;, &quot;author-first&quot; .. i, 
                        &quot;first&quot; .. i, &quot;given&quot; .. i}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;author&quot; .. i .. &quot;-link&quot;, &quot;author-link&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;link&quot;, &quot;authorlink&quot; .. i}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;author&quot; .. i .. &quot;-mask&quot;, &quot;author-mask&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;mask&quot;, &quot;authormask&quot; .. i}, 'redundant_parameters' )
                }
            end            
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

-- Gets editor list from the input arguments
function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        if i == 1 then
            last = selectone( args, {&quot;editor&quot; .. i .. &quot;-last&quot;, &quot;editor-last&quot; .. i,
                &quot;EditorSurname&quot; .. i, &quot;Editor&quot; .. i, &quot;editor&quot; .. i, &quot;editor-last&quot;, 
                &quot;EditorSurname&quot;, &quot;Editor&quot;, &quot;editor&quot;, &quot;editors&quot;}, 'redundant_parameters' );
        else
            last = selectone( args, {&quot;editor&quot; .. i .. &quot;-last&quot;, &quot;editor-last&quot; .. i,
                &quot;EditorSurname&quot; .. i, &quot;Editor&quot; .. i, &quot;editor&quot; .. i}, 'redundant_parameters' );
        end        
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            if i == 1 then
                editors[i] = {
                    last = last,
                    first = selectone( args, {&quot;editor&quot; .. i .. &quot;-first&quot;, 
                        &quot;editor-first&quot; .. i, &quot;EditorGiven&quot; .. i, &quot;editor-first&quot;, 
                        &quot;EditorGiven&quot;}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;editor&quot; .. i .. &quot;-link&quot;, &quot;editor-link&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;link&quot;, &quot;editorlink&quot; .. i, &quot;editor-link&quot;, 
                        &quot;editorlink&quot;}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;editor&quot; .. i .. &quot;-mask&quot;, &quot;editor-mask&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;mask&quot;, &quot;editormask&quot; .. i, &quot;editor-mask&quot;,  
                        &quot;editormask&quot;}, 'redundant_parameters' )
                }                
            else
                editors[i] = {
                    last = last,
                    first = selectone( args, {&quot;editor&quot; .. i .. &quot;-first&quot;, 
                        &quot;editor-first&quot; .. i, &quot;EditorGiven&quot; .. i}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;editor&quot; .. i .. &quot;-link&quot;, &quot;editor-link&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;link&quot;, &quot;editorlink&quot; .. i}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;editor&quot; .. i .. &quot;-mask&quot;, &quot;editor-mask&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;mask&quot;, &quot;editormask&quot; .. i}, 'redundant_parameters' )
                }
            end
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
    local id_list = {};
    
    for k, v in pairs( cfg.id_handlers ) do    
        id_list[k] = selectone( args, v.parameters, 'redundant_parameters' );
    end

    return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
    local handler;
    local new_list = {};
    
    for k, v in pairs( id_list ) do
        handler = {};
        
        --Becasue cfg is read-only we have to copy it the hard way.
        for k2, v2 in pairs( cfg.id_handlers[k] ) do
            handler[k2] = v2;
        end
        handler['id'] = v;
        
        if handler.mode == 'external' then        
            table.insert( new_list, {handler.label, externallinkid( handler ) } );
        elseif handler.mode == 'internal' then
            table.insert( new_list, {handler.label, internallinkid( handler ) } );
        elseif handler.mode == 'manual' then
            if k == 'DOI' then
                table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
            elseif k == 'ASIN' then
                table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
            elseif k == 'OL' then
                table.insert( new_list, {handler.label, openlibrary( v ) } );
            elseif k == 'ISBN' then
                local ISBN = internallinkid( handler );
                if not checkisbn( v ) and ( options.IgnoreISBN == nil or options.IgnoreISBN == &quot;&quot; ) then 
                    ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
                end
                table.insert( new_list, {handler.label, ISBN } );                
            else
                error( cfg.message_list['unknown_manual_ID'] );
            end            
        else
            error( cfg.message_list['unknown_ID_mode'] );
        end
    end

    function comp( a, b )
        return a[1] &lt; b[1];
    end

    table.sort( new_list, comp );
    for k, v in ipairs( new_list ) do
        new_list[k] = v[2];
    end
    
    return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition )
    local value = nil;
    local selected = '';
    local error_list = {};
    
    for _, v in ipairs( possible ) do
        if args[v] ~= nil then
            if value ~= nil then
                table.insert( error_list, v );
            else
                value = args[v];
                selected = v;
            end
        end
    end
            
    if #error_list &gt; 0 then
        local error_str = &quot;&quot;;
        for _, k in ipairs( error_list ) do
            if error_str ~= &quot;&quot; then error_str = error_str .. &quot;, &quot; end
            error_str = error_str .. &quot;&lt;code&gt;|&quot; .. k .. &quot;=&lt;/code&gt;&quot;;
        end
        if #error_list &gt; 1 then
            error_str = error_str .. &quot;, and &quot;;
        else
            error_str = error_str .. &quot; and &quot;;
        end
        error_str = error_str .. &quot;&lt;code&gt;|&quot; .. selected .. &quot;=&lt;/code&gt;&quot;;
        table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
    end
            
    return value, selected;
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    -- Load Input Parameters

    local i 
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = args.authors
    local a = extractauthors( args );

    local Coauthors = selectone( args, {'coauthors', 'coauthor' }, 'redundant_parameters' );
    local Others = args.others 
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = selectone( args, {'publicationdate', 'publication-date' }, 'redundant_parameters' );
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = selectone( args, {'trans-title', 'trans_title' }, 'redundant_parameters' );
    local TitleNote = args.department
    local TitleLink = selectone( args, {'titlelink', 'episodelink' }, 'redundant_parameters' );
    local Chapter = selectone( args, {'chapter', 'contribution', 'entry' }, 'redundant_parameters' );
    local ChapterLink = args.chapterlink
    local TransChapter = selectone( args, {'trans-chapter', 'trans_chapter' }, 'redundant_parameters' );
    local TitleType = args.type
    local ArchiveURL = selectone( args, {'archive-url', 'archiveurl' }, 'redundant_parameters' );
    local URL = selectone( args, {'url', 'URL'}, 'redundant_parameters' );
    local ChapterURL = selectone( args, {'chapter-url', 'chapterurl', 'contribution-url', 'contributionurl' }, 'redundant_parameters' );
    local ConferenceURL = selectone( args, {'conference-url', 'conferenceurl' }, 'redundant_parameters' );
    local Periodical = selectone( args, {'journal', 'newspaper', 'magazine', 'work', 'website', 
        'periodical', 'encyclopedia', 'encyclopaedia'}, 'redundant_parameters' );
            
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = nil          
            TransTitle = nil
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = nil 
                TransTitle = nil
            end
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = nil end
        end
    end
    local Series = selectone( args, {'series', 'version'}, 'redundant_parameters' );
    local Volume = args.volume
    local Issue = selectone( args, {'issue', 'number'}, 'redundant_parameters' );
    local Position = nil
    local Page, Pages, At, page_type;
    
    Page, page_type = selectone( args, {'p', 'page', 'pp', 'pages', 'at'}, 
        'extra_pages' );
    if page_type == 'pp' or page_type == 'pages' then
        Pages = hyphentodash( Page );
        Page = nil;
    elseif page_type == 'at' then
        At = Page;
        Page = nil;
    end
                
    local Edition = args.edition
    local PublicationPlace = selectone( args, {'publication-place', 'publicationplace' }, 'redundant_parameters' ); 
    local Place = selectone( args, {'place', 'location'}, 'redundant_parameters' );
    if PublicationPlace == nil and Place ~= nil then 
        PublicationPlace = Place;
    end
    if PublicationPlace == Place then Place = nil end
    
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = selectone( args, {'access-date', 'accessdate' }, 'redundant_parameters' );
    local ArchiveDate = selectone( args, {'archive-date', 'archivedate' }, 'redundant_parameters' );
    local Agency = args.agency
    local DeadURL = args.deadurl or &quot;yes&quot;           -- Only used if ArchiveURL is present.
    local Language = selectone( args, {'language', 'in'}, 'redundant_parameters' );
    local Format = args.format
    local Ref = selectone( args, {'ref', 'Ref'}, 'redundant_parameters' );

    local DoiBroken = selectone( args, {'doi_inactivedate', 'doi_brokendate', 'DoiBroken'}, 'redundant_parameters' );
    local ID = selectone( args, {'id', 'ID', 'docket'}, 'redundant_parameters' );
    local ASINTLD = selectone( args, {'ASIN-TLD', 'asin-tld'}, 'redundant_parameters' );
    local IgnoreISBN = selectone( args, {'ignore-isbn-error', 'ignoreisbnerror'}, 'redundant_parameters' );

    local ID_list = extractids( args );
    
    local Quote = selectone( args, {'quote', 'quotation'}, 'redundant_parameters' );
    local PostScript = args.postscript or &quot;.&quot;
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = selectone( args, {'transcript-url', 'transcripturl'}, 'redundant_parameters' );
    local sepc = args.separator or &quot;.&quot;
    local LastAuthorAmp = args.lastauthoramp
    local no_tracking_cats = selectone( args, {&quot;template doc demo&quot;, 'nocat', 
        'notracking', &quot;no-tracking&quot;}, 'redundant_parameters' ) or &quot;&quot;;

    if ( config.CitationClass == &quot;journal&quot; ) then        
        if (URL == nil or URL == &quot;&quot;) then
            if (ID_list['PMC'] ~= nil) then 
                local Embargo = args.embargo or args.Embargo;
                if Embargo ~= nil then
                    local lang = mw.getContentLanguage();
                    local good1, result1, good2, result2;
                    good1, result1 = pcall( lang.formatDate, lang, 'U', Embargo );
                    good2, result2 = pcall( lang.formatDate, lang, 'U' );

                    if good1 and good2 and tonumber( result1 ) &lt; tonumber( result2 ) then 
                        URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];
                    end
                else
                    URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];           
                end
            end
        end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, cfg.message_list[&quot;episode&quot;] .. &quot; &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, cfg.message_list[&quot;season&quot;] .. &quot; &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, cfg.message_list[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows 
    -- automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
        if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    
    for k, v in pairs( ID_list ) do
        if string.sub( cfg.id_handlers[k].COinS or &quot;info&quot;, 1, 4 ) ~= 'info' then
            OCinSdata[ cfg.id_handlers[k].COinS ] = v;
        end
    end
    
    OCinSdata.rft_id = URL or ChapterURL

    local last, first;
    local OCinSauthors = {};
    for k, v in ipairs( a ) do
        last = v.last;
        first = v.first;
        if k == 1 then
            if last ~= nil then
                OCinSdata[&quot;rft.aulast&quot;] = last;
            end
            if first ~= nil then 
                OCinSdata[&quot;rft.aufirst&quot;] = first;
            end
        end
        if last ~= nil and first ~= nil then
            table.insert( OCinSauthors, last .. (args.NameSep or &quot;, &quot;) .. first );
    	elseif last ~= nil then
            table.insert( OCinSauthors, last );
        end
    end

    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    for k, v in pairs( ID_list ) do
        if string.sub( cfg.id_handlers[k].COinS or &quot;&quot;, 1, 4 ) == 'info' then
            OCinSids[ cfg.id_handlers[k].COinS ] = v;
        end
    end

    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode( removewikilink(value) );
    end
    for _, value in ipairs(OCinSauthors) do
        OCinStitle = OCinStitle .. &quot;&amp;rft.au=&quot; .. mw.uri.encode( removewikilink(value) );
    end
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. removewikilink(value) );
    end
    
    local this_page = mw.title.getCurrentTitle();
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/&quot; .. mw.site.server:match( &quot;[^/]*$&quot; ) .. &quot;:&quot;
       .. this_page.prefixedText  -- end COinS data by page's non-encoded pagename

    if (Periodical ~= nil and Periodical ~= &quot;&quot;) and
        (Chapter == nil or Chapter == '') and
        (Title ~= nil and Title ~= &quot;&quot;) then
            Chapter = Title
            ChapterLink = TitleLink
            TransChapter = TransTitle
            Title = nil
            TitleLink = nil
            TransTitle = nil            
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local Maximum = tonumber( (selectone( args, {&quot;display-authors&quot;, &quot;displayauthors&quot;}, 'redundant_parameters' )) );
        
        -- Preserve old-style implicit et al.
        if Maximum == nil and #a == 9 then 
            Maximum = 8;
            table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
        elseif Maximum == nil then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = (args[&quot;author-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = selectone( args, {&quot;author-format&quot;, &quot;authorformat&quot; }, 'redundant_parameters' ),
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        }
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if Coauthors ~= nil and Coauthors ~= &quot;&quot; then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
                
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local Maximum = tonumber( (selectone( args, {&quot;display-editors&quot;, &quot;displayeditors&quot;}, 'redundant_parameters' )) );

        -- Preserve old-style implicit et al.
        if Maximum == nil and #e == 4 then 
            Maximum = 3;
            table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
        elseif Maximum == nil then
            Maximum = #e + 1;
        end

        local control = { 
            sep = (args[&quot;editor-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = selectone( args, {&quot;editor-format&quot;, &quot;editorformat&quot; }, 'redundant_parameters' ),
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
            }

        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date
    
    if ( URL == nil or URL == '' ) and
            ( ChapterURL == nil or ChapterURL == '' ) and
            ( ArchiveURL == nil or ArchiveURL == '' ) and                
            ( ConferenceURL == nil or ConferenceURL == '' ) and                
            ( TranscriptURL == nil or TranscriptURL == '' ) then

        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
        end

        -- Test if accessdate is given without giving a URL
        if ( AccessDate ~= nil and AccessDate ~= '' ) then
            table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
            AccessDate = nil;
        end      
    
        -- Test if format is given without giving a URL
        if ( Format ~= nil and Format ~= '' ) then
            Format = Format .. seterror( 'format_missing_url' );
        end        
    end    

    -- Test if citation has no title
    if ( Chapter == nil or Chapter == &quot;&quot; ) and 
            ( Title == nil or Title == &quot;&quot; ) and
            ( Periodical == nil or Periodical == &quot;&quot; ) and
            ( Conference == nil or Conference == &quot;&quot; ) and 
            ( TransTitle == nil or TransTitle == &quot;&quot; ) and
            ( TransChapter == nil or TransChapter == &quot;&quot; ) then
        table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
    end

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
        end
    end

    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
        
    -- Format chapter / article title
    if ( Chapter ~= nil and Chapter ~= &quot;&quot; ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) and (Title ~= nil and Title ~= &quot;&quot; )
        then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
    else
        Chapter = &quot;&quot;;
    end
    
    local TransError = &quot;&quot;
    if TransChapter ~= &quot;&quot; and Chapter == &quot;&quot; then
        TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
    end
    Chapter = Chapter .. TransChapter
    if Chapter ~= &quot;&quot; then
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then                
                Chapter = externallink( ChapterURL, Chapter ) .. TransError;
                if URL == nil or URL == &quot;&quot; then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = externallink( URL, Chapter ) .. TransError .. Format;
                URL = nil
                Format = &quot;&quot;
            else
                Chapter = Chapter .. TransError;
            end            
        elseif ChapterURL ~= nil and ChapterURL ~= &quot;&quot; then
            Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL ) .. 
                TransError;
        else
            Chapter = Chapter .. TransError;
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    elseif ChapterURL ~= nil and ChapterURL ~= &quot;&quot; then
        Chapter = &quot; &quot; .. externallink( ChapterURL ) .. sepc .. &quot; &quot;;
    end        
    
    -- Format main title.
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
                or config.CitationClass == &quot;news&quot; 
                or config.CitationClass == &quot;pressrelease&quot; ) and 
                Chapter == &quot;&quot; then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
    else
        Title = &quot;&quot;;
    end    
    
    local TransError = &quot;&quot;;
    if TransTitle ~= &quot;&quot; and Title == &quot;&quot; then
        TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
    end
    Title = Title .. TransTitle
    if Title ~= &quot;&quot; then
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = externallink( URL, Title ) .. TransError .. Format       
            URL = nil
            Format = ''
        else
            Title = Title .. TransError;
        end
    end

    if ( Place ~= nil and Place ~= &quot;&quot; ) then
        if sepc == '.' then
            Place = &quot; &quot; .. cfg.message_list['written'] .. &quot; &quot; .. Place .. sepc .. &quot; &quot;;
        else
            Place = &quot; &quot; .. cfg.message_list['written']:lower() .. &quot; &quot; .. Place .. sepc .. &quot; &quot;;
        end            
    else
        Place = &quot;&quot;;
    end
    
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = externallink( ConferenceURL, Conference );
        end
        Conference = &quot; &quot; .. Conference
    elseif ConferenceURL ~= nil and ConferenceURL ~= &quot;&quot; then
        Conference = &quot; &quot; .. externallink( ConferenceURL );
    else
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.message_list['minutes'];
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption 
                if TimeCaption == nil then
                    TimeCaption = cfg.message_list['event'];
                    if sepc ~= '.' then
                        TimeCaption = TimeCaption:lower();
                    end
                end                
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (&quot; .. cfg.message_list['in'] .. &quot; &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; &quot; .. cfg.message_list['edition'] .. &quot;)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; &quot; .. cfg.message_list['via'] .. &quot; &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; &quot; .. cfg.message_list['retrieved'] .. &quot; &quot;
         if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
             .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.message_list['subscription'];
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end

    ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN} );

    if ( URL ~= nil and URL ~=&quot;&quot;) then
        URL = &quot; &quot; .. externallink( URL, URL );
        local error_text = seterror( 'bare_url_missing_title' );
        if config.CitationClass == &quot;web&quot; then
            URL = URL .. &quot; &quot; .. seterror( 'cite_web_title' );
        else
            URL = URL .. error_text;
        end       
    else
        URL = &quot;&quot;
    end

    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot; &quot; .. seterror('archive_missing_date') .. &quot; &quot;
        end
        local arch_text = cfg.message_list['archived'];
        if (sepc ~= &quot;.&quot;) then arch_text = arch_text:lower() end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; &quot; .. externallink( ArchiveURL, arch_text ) .. &quot; &quot; .. 
                cfg.message_list['from'] .. &quot; &quot; .. cfg.message_list['original'] .. &quot; &quot; .. 
                cfg.message_list['on'] .. ArchiveDate
            if OriginalURL == nil or OriginalUrl == '' then
                Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url_not_dead');                               
            end
        else
            if OriginalURL ~= nil and OriginalURL ~= '' then
                Archived = sepc .. &quot; &quot; .. arch_text .. &quot; &quot; .. cfg.message_list['from'] .. 
                    &quot; &quot; .. externallink( OriginalURL, cfg.message_list['original'] ) .. &quot; &quot;
                    .. cfg.message_list['on'] .. ArchiveDate
            else
                if config.CitationClass ~= 'web' then 
                    Archived = sepc .. &quot; &quot; .. arch_text .. &quot; &quot; .. cfg.message_list['from'] .. &quot; &quot; .. 
                    cfg.message_list['original'] .. seterror('archive_missing_url') .. &quot; &quot; .. cfg.message_list['on'] .. ArchiveDate
                else
                    Archived = sepc .. &quot; &quot; .. arch_text .. &quot; &quot; .. cfg.message_list['from'] .. &quot; &quot; .. 
                    cfg.message_list['original'] .. seterror('archive_missing_url_web') .. &quot; &quot; .. cfg.message_list['on'] .. ArchiveDate
                end
            end                
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        if sepc == '.' then
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; &quot; .. cfg.message_list['lay summary'] .. &quot;]&quot; .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; &quot; .. cfg.message_list['lay summary']:lower() .. &quot;]&quot; .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = externallink( TranscriptURL, Transcript ) end
    elseif TranscriptURL ~= nil and TranscriptURL ~= &quot;&quot; then
        Transcript = externallink( TranscriptURL )     
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; and
         config.CitationClass ~= &quot;pressrelease&quot; ) then
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            if Publisher ~= '' then
                Publisher = Publisher .. &quot;, &quot; .. cfg.message_list['published'] .. &quot; &quot; .. PublicationDate;
            else
                Publisher = PublicationDate;
            end
        end
        if Publisher ~= &quot;&quot; then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (&quot; .. cfg.message_list['published'] .. &quot; &quot; .. PublicationDate .. &quot;)&quot;
        else 
            PublicationDate = &quot;&quot;
        end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot; ) or ( TitleNote and TitleNote ~= &quot;&quot; ) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( ( (config.CitationClass == &quot;journal&quot;) or (config.CitationClass == &quot;citation&quot;) )  and
         Periodical ~= &quot;&quot; ) then
        if (Others ~= &quot;&quot;) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
            Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
            Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
    end
    
    if #ID_list &gt; 0 then
        ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
    else
        ID_list = ID;
    end    
    local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );

    local text
    local pgtext = Page .. Pages .. At
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, &quot; .. cfg.message_list['editor'];
            else
                Editors = Editors .. &quot;, &quot; .. cfg.message_list['editors'];
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (&quot; .. cfg.message_list['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (&quot; .. cfg.message_list['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end -- endif &quot;&quot;~=Date
        if ( config.CitationClass==&quot;journal&quot; and Periodical ) then
          text = safejoin( {Chapter, Place, tcommon}, sepc );
          text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
          text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
          text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if PostScript ~= '' and PostScript ~= nil and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local options = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do 
                    names[i] = v.last 
                    if i == 4 then break end
                end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do 
                    names[i] = v.last 
                    if i == 4 then break end                
                end
            end
            names[ #names + 1 ] = Year;
            id = anchorid(names)
        end
        options.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = {};
        text = seterror('empty_citation');
        z.message_tail = {};
    end
    
    if options.id ~= nil then 
        text = '&lt;span id=&quot;' .. wikiescape(options.id) ..'&quot; class=&quot;' .. wikiescape(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    else
        text = '&lt;span class=&quot;' .. wikiescape(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    end        

    local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = '&lt;span title=&quot;' .. wikiescape(OCinStitle) .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        for i,v in ipairs( z.message_tail ) do
            if v[1] ~= nil and v[1] ~= &quot;&quot; then 
                if i == #z.message_tail then
                    text = text .. errorcomment( v[1], v[2] );
                else
                    text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
                end
            end
        end
    end
    
    if no_tracking_cats == '' then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    local suggestions = {};
    local error_text, error_state;
    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            if not validate( k ) then            
                error_text = &quot;&quot;;
                if type( k ) ~= 'string' then
                    -- Exclude empty numbered parameters
                    if v:match(&quot;%S+&quot;) ~= nil then
                        error_text, error_state = seterror( 'text_ignored', {v}, true );
                    end
                elseif validate( k:lower() ) then 
                    error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
                else
                    if #suggestions == 0 then
                        suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
                    end
                    if suggestions[ k:lower() ] ~= nil then
                        error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
                    else
                        error_text, error_state = seterror( 'parameter_ignored', {k}, true );
                    end
                end                  
                if error_text ~= '' then
                    table.insert( z.message_tail, {error_text, error_state} );
                end                
            end            
            args[k] = v;
        elseif k == 'postscript' then
            args[k] = v;
        end        
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        if args[k] == nil and (v ~= '' or k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--18Mar2013 Fixed &quot;page=&quot; to override &quot;pages=&quot; as in markup-based cites.
--19Mar2013 Fixed date of class=journal Periodical to show after page.
--19Mar2013 Changed null &quot;postscript=&quot; to suppress end-dot of citation.
--20Mar2013 If CitationClass is journal, show &quot;others=&quot; before title.
--20Mar2013 If CitationClass is book, show &quot;others=&quot; before edition.
--20Mar2013 If CitationClass is journal, adjust &quot;others=&quot; to have sepc.
--20Mar2013 For class &quot;journal&quot;, use book format unless Periodical set.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; after wikilink &quot;.]]&quot; end dot.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; after external &quot;.]&quot; end dot.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; at italic wikilink &quot;.]]&quot; end.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; at italic external &quot;.]&quot; end.
--04Apr2013 Moved sepc before &lt;span class=&quot;reference-accessdate&quot;&gt; for &quot;..&quot;.
--
--End</text>
      <sha1>03eky3zcnulgiudayjnyeufj6f0zb1m</sha1>
    </revision>
    <revision>
      <id>4649</id>
      <parentid>4648</parentid>
      <timestamp>2013-04-14T14:26:42Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>sync to sandbox, make ISBN forgiving in a similar way to Special:BookSources, fix newline in italics</comment>
      <origin>4649</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="69859" sha1="c1b59g4wol2wreqnq8x7x91yqtqh14i" xml:space="preserve">local z = {
    error_categories = {};
    error_ids = {};
    message_tail = {};
}

-- Include translation message hooks, ID and error handling configuration settings.
local cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );
 
-- Contains a list of all recognized parameters
local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );

-- Checks that parameter name is valid
function validate( name )
    name = tostring( name );
    
    -- Normal arguments
    if whitelist.basic_arguments[ name ] then
        return true;
    end
    
    -- Arguments with numbers in them
    name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );
    if whitelist.numbered_arguments[ name ] then
        return true;
    end
    
    -- Not found, argument not supported.
    return false
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
    if hidden then 
        return '&lt;span style=&quot;display:none;font-size:100%&quot; class=&quot;error citation-comment&quot;&gt;' .. content .. '&lt;/span&gt;';
    else
        return '&lt;span style=&quot;font-size:100%&quot; class=&quot;error&quot;&gt;' .. content .. '&lt;/span&gt;';
    end        
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, args, raw, prefix, suffix )
    local error_state = cfg.error_conditions[ error_id ];
    prefix = prefix or &quot;&quot;;
    suffix = suffix or &quot;&quot;;

    if error_state == nil then
        error( cfg.message_list['undefined_error'] );
    end
    
    if error_state.category ~= nil and error_state.category ~= &quot;&quot; then
        table.insert( z.error_categories, error_state.category );
    end
    
    local message = error_state.message;
    if args ~= nil then
        for k, m in ipairs( args ) do
            m = m:gsub( &quot;%%&quot;, &quot;%%%%&quot; );
            message = message:gsub( &quot;$&quot; .. k .. &quot;(%D)&quot;, m .. &quot;%1&quot; );
        end
    end

    message = wikiescape(message) .. &quot; ([[&quot; .. cfg.message_list['help page link'] .. 
        &quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
        cfg.message_list['help page label'] .. &quot;]])&quot;;

    z.error_ids[ error_id ] = true;
    if (error_id == 'bare_url_missing_title' or error_id == 'trans_missing_title')
            and z.error_ids['citation_missing_title'] then
        return '', false;
    end
    
    message = prefix .. message .. suffix;
    
    if raw == true then
        return message, error_state.hidden;
    end        
        
    return errorcomment( message, error_state.hidden );
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',    
            ['{'] = '&amp;#123;',    
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

-- Formats a wiki style external link
function externallinkid(options)
    local sep = options.separator or &quot;&amp;nbsp;&quot;
    options.suffix = options.suffix or &quot;&quot;
    local url_string = options.id
    if options.encode == true or options.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    return &quot;[[&quot; .. options.link .. &quot;|&quot; .. options.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. 
            options.prefix .. url_string .. options.suffix .. &quot; &quot; .. mw.text.nowiki(options.id) .. &quot;]&quot;
end

-- Formats a wiki style internal link
function internallinkid(options)
    local sep = options.separator or &quot;&amp;nbsp;&quot;
    options.suffix = options.suffix or &quot;&quot;
    return &quot;[[&quot; .. options.link .. &quot;|&quot; .. options.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. 
            options.prefix .. options.id .. options.suffix .. &quot;|&quot; .. mw.text.nowiki(options.id) .. &quot;]]&quot;
end

-- Format an external link with error checking
function externallink( URL, label )
    local error_str = &quot;&quot;;
    if label == nil or label == &quot;&quot; then
        label = URL;
        error_str = seterror( 'bare_url_missing_title', {}, false, &quot; &quot; );
    end
    if not checkurl( URL ) then
        error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
    end

    return &quot;[&quot; .. URL .. ' ' .. safeforurl( label ) .. &quot;]&quot; .. error_str;
end

-- Formats a link to Amazon
function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local handler = cfg.id_handlers['ASIN'];
    return externallinkid({link = handler.link,
        label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
        encode=handler.encode, separator = handler.separator})
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    local handler = cfg.id_handlers['DOI'];
    
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (&quot; .. cfg.message_list['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link = handler.link, label = handler.label,
            prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then      
        cat = seterror( 'bad_doi' );
    end
    return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    local handler = cfg.id_handlers['OL'];
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    else
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode}) .. 
            ' ' .. seterror( 'bad_ol' );
    end
end

--[[
Determines whether an URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
    if url_str:sub(1,2) == &quot;//&quot; then  
        -- Protocol-less URLs
        return true;
    elseif url_str:match( &quot;^[^/]*:&quot; ) ~= nil then   
        -- Look for &quot;:&quot; prefix and assume it is a URI scheme
        return true;
    else
        -- Anything else is an error
        return false;
    end
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
    return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
    isbn_str = cleanisbn( isbn_str ):gsub( &quot;-&quot;, &quot;&quot; );
    local len = isbn_str:len();
 
    if len ~= 10 and len ~= 13 then
        return false;
    end
 
    local temp = 0;
    if len == 10 then
        if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            if v == string.byte( &quot;X&quot; ) then
                temp = temp + 10*( 11 - i );
            else
                temp = temp + tonumber( string.char(v) )*(11-i);
            end
        end
        return temp % 11 == 0;
    else
        if isbn_str:match( &quot;^%d*$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
        end
        return temp % 10 == 0;
    end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
    str = str:gsub( &quot;%[%[[^|%]]*|([^%]]*)%]%]&quot;, &quot;%1&quot; );
    str = str:gsub( &quot;%[%[([^%]]*)%]%]&quot;, &quot;%1&quot; );    
    return str
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    if str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then 
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str:gsub( '\n', ' ' );
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    -- Is the input a simple number?
    local num = tonumber( str ); 
    if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
        return str;
    else
        -- Use formatDate to interpret more complicated formats
        local lang = mw.getContentLanguage();
        local good, result;
        good, result = pcall( lang.formatDate, lang, 'Y', str )
        if good then 
            return result;
        else
            -- Can't make sense of this input, return blank.
            return &quot;&quot;;
        end
    end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil and first ~= '') then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    if count &gt; 1 and lastauthoramp ~= nil and lastauthoramp ~= &quot;&quot; and not etal then
        text[count-1] = text[count-1] .. &quot; &amp; &quot; .. text[count];
        text[count] = nil;
    end    
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = cfg.message_list['et al'];
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result = 
        '&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
    end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
    return &quot;CITEREF&quot; .. mw.uri.anchorEncode( table.concat( options ) );
end

-- Gets author list from the input arguments
function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    while true do
        if i == 1 then 
            last = selectone( args, {&quot;author&quot; .. i .. &quot;-last&quot;, &quot;author-last&quot; .. i, 
                &quot;last&quot; .. i, &quot;surname&quot; .. i, &quot;Author&quot; .. i, &quot;author&quot; .. i, 
                &quot;author-last&quot;, &quot;last&quot;, &quot;surname&quot;, &quot;Author&quot;, &quot;author&quot;, &quot;authors&quot;}, 'redundant_parameters' );
        else
            last = selectone( args, {&quot;author&quot; .. i .. &quot;-last&quot;, &quot;author-last&quot; .. i, 
                &quot;last&quot; .. i, &quot;surname&quot; .. i, &quot;Author&quot; .. i, &quot;author&quot; .. i}, 'redundant_parameters' );
        end
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            if i == 1 then 
                authors[i] = {
                    last = last,
                    first = selectone( args, {&quot;author&quot; .. i .. &quot;-first&quot;, &quot;author-first&quot; .. i, 
                        &quot;first&quot; .. i, &quot;given&quot; .. i, &quot;author-first&quot;, 
                        &quot;first&quot;, &quot;given&quot;}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;author&quot; .. i .. &quot;-link&quot;, &quot;author-link&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;link&quot;, &quot;authorlink&quot; .. i, &quot;author-link&quot;,  
                        &quot;authorlink&quot;}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;author&quot; .. i .. &quot;-mask&quot;, &quot;author-mask&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;mask&quot;, &quot;authormask&quot; .. i, &quot;author-mask&quot;, 
                        &quot;authormask&quot; }, 'redundant_parameters' )
                }
            else
                authors[i] = {
                    last = last,
                    first = selectone( args, {&quot;author&quot; .. i .. &quot;-first&quot;, &quot;author-first&quot; .. i, 
                        &quot;first&quot; .. i, &quot;given&quot; .. i}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;author&quot; .. i .. &quot;-link&quot;, &quot;author-link&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;link&quot;, &quot;authorlink&quot; .. i}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;author&quot; .. i .. &quot;-mask&quot;, &quot;author-mask&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;mask&quot;, &quot;authormask&quot; .. i}, 'redundant_parameters' )
                }
            end            
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

-- Gets editor list from the input arguments
function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        if i == 1 then
            last = selectone( args, {&quot;editor&quot; .. i .. &quot;-last&quot;, &quot;editor-last&quot; .. i,
                &quot;EditorSurname&quot; .. i, &quot;Editor&quot; .. i, &quot;editor&quot; .. i, &quot;editor-last&quot;, 
                &quot;EditorSurname&quot;, &quot;Editor&quot;, &quot;editor&quot;, &quot;editors&quot;}, 'redundant_parameters' );
        else
            last = selectone( args, {&quot;editor&quot; .. i .. &quot;-last&quot;, &quot;editor-last&quot; .. i,
                &quot;EditorSurname&quot; .. i, &quot;Editor&quot; .. i, &quot;editor&quot; .. i}, 'redundant_parameters' );
        end        
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            if i == 1 then
                editors[i] = {
                    last = last,
                    first = selectone( args, {&quot;editor&quot; .. i .. &quot;-first&quot;, 
                        &quot;editor-first&quot; .. i, &quot;EditorGiven&quot; .. i, &quot;editor-first&quot;, 
                        &quot;EditorGiven&quot;}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;editor&quot; .. i .. &quot;-link&quot;, &quot;editor-link&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;link&quot;, &quot;editorlink&quot; .. i, &quot;editor-link&quot;, 
                        &quot;editorlink&quot;}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;editor&quot; .. i .. &quot;-mask&quot;, &quot;editor-mask&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;mask&quot;, &quot;editormask&quot; .. i, &quot;editor-mask&quot;,  
                        &quot;editormask&quot;}, 'redundant_parameters' )
                }                
            else
                editors[i] = {
                    last = last,
                    first = selectone( args, {&quot;editor&quot; .. i .. &quot;-first&quot;, 
                        &quot;editor-first&quot; .. i, &quot;EditorGiven&quot; .. i}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;editor&quot; .. i .. &quot;-link&quot;, &quot;editor-link&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;link&quot;, &quot;editorlink&quot; .. i}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;editor&quot; .. i .. &quot;-mask&quot;, &quot;editor-mask&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;mask&quot;, &quot;editormask&quot; .. i}, 'redundant_parameters' )
                }
            end
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
    local id_list = {};
    
    for k, v in pairs( cfg.id_handlers ) do    
        id_list[k] = selectone( args, v.parameters, 'redundant_parameters' );
    end

    return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
    local handler;
    local new_list = {};
    
    for k, v in pairs( id_list ) do
        handler = {};
        
        --Becasue cfg is read-only we have to copy it the hard way.
        for k2, v2 in pairs( cfg.id_handlers[k] ) do
            handler[k2] = v2;
        end
        handler['id'] = v;
        
        if handler.mode == 'external' then        
            table.insert( new_list, {handler.label, externallinkid( handler ) } );
        elseif handler.mode == 'internal' then
            table.insert( new_list, {handler.label, internallinkid( handler ) } );
        elseif handler.mode == 'manual' then
            if k == 'DOI' then
                table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
            elseif k == 'ASIN' then
                table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
            elseif k == 'OL' then
                table.insert( new_list, {handler.label, openlibrary( v ) } );
            elseif k == 'ISBN' then
                local ISBN = internallinkid( handler );
                if not checkisbn( v ) and ( options.IgnoreISBN == nil or options.IgnoreISBN == &quot;&quot; ) then 
                    ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
                end
                table.insert( new_list, {handler.label, ISBN } );                
            else
                error( cfg.message_list['unknown_manual_ID'] );
            end            
        else
            error( cfg.message_list['unknown_ID_mode'] );
        end
    end

    function comp( a, b )
        return a[1] &lt; b[1];
    end

    table.sort( new_list, comp );
    for k, v in ipairs( new_list ) do
        new_list[k] = v[2];
    end
    
    return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition )
    local value = nil;
    local selected = '';
    local error_list = {};
    
    for _, v in ipairs( possible ) do
        if args[v] ~= nil then
            if value ~= nil then
                table.insert( error_list, v );
            else
                value = args[v];
                selected = v;
            end
        end
    end
            
    if #error_list &gt; 0 then
        local error_str = &quot;&quot;;
        for _, k in ipairs( error_list ) do
            if error_str ~= &quot;&quot; then error_str = error_str .. &quot;, &quot; end
            error_str = error_str .. &quot;&lt;code&gt;|&quot; .. k .. &quot;=&lt;/code&gt;&quot;;
        end
        if #error_list &gt; 1 then
            error_str = error_str .. &quot;, and &quot;;
        else
            error_str = error_str .. &quot; and &quot;;
        end
        error_str = error_str .. &quot;&lt;code&gt;|&quot; .. selected .. &quot;=&lt;/code&gt;&quot;;
        table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
    end
            
    return value, selected;
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    -- Load Input Parameters

    local i 
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = args.authors
    local a = extractauthors( args );

    local Coauthors = selectone( args, {'coauthors', 'coauthor' }, 'redundant_parameters' );
    local Others = args.others 
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = selectone( args, {'publicationdate', 'publication-date' }, 'redundant_parameters' );
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = selectone( args, {'trans-title', 'trans_title' }, 'redundant_parameters' );
    local TitleNote = args.department
    local TitleLink = selectone( args, {'titlelink', 'episodelink' }, 'redundant_parameters' );
    local Chapter = selectone( args, {'chapter', 'contribution', 'entry' }, 'redundant_parameters' );
    local ChapterLink = args.chapterlink
    local TransChapter = selectone( args, {'trans-chapter', 'trans_chapter' }, 'redundant_parameters' );
    local TitleType = args.type
    local ArchiveURL = selectone( args, {'archive-url', 'archiveurl' }, 'redundant_parameters' );
    local URL = selectone( args, {'url', 'URL'}, 'redundant_parameters' );
    local ChapterURL = selectone( args, {'chapter-url', 'chapterurl', 'contribution-url', 'contributionurl' }, 'redundant_parameters' );
    local ConferenceURL = selectone( args, {'conference-url', 'conferenceurl' }, 'redundant_parameters' );
    local Periodical = selectone( args, {'journal', 'newspaper', 'magazine', 'work', 'website', 
        'periodical', 'encyclopedia', 'encyclopaedia'}, 'redundant_parameters' );
            
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = nil          
            TransTitle = nil
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = nil 
                TransTitle = nil
            end
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = nil end
        end
    end
    local Series = selectone( args, {'series', 'version'}, 'redundant_parameters' );
    local Volume = args.volume
    local Issue = selectone( args, {'issue', 'number'}, 'redundant_parameters' );
    local Position = nil
    local Page, Pages, At, page_type;
    
    Page, page_type = selectone( args, {'p', 'page', 'pp', 'pages', 'at'}, 
        'extra_pages' );
    if page_type == 'pp' or page_type == 'pages' then
        Pages = hyphentodash( Page );
        Page = nil;
    elseif page_type == 'at' then
        At = Page;
        Page = nil;
    end
                
    local Edition = args.edition
    local PublicationPlace = selectone( args, {'publication-place', 'publicationplace' }, 'redundant_parameters' ); 
    local Place = selectone( args, {'place', 'location'}, 'redundant_parameters' );
    if PublicationPlace == nil and Place ~= nil then 
        PublicationPlace = Place;
    end
    if PublicationPlace == Place then Place = nil end
    
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = selectone( args, {'access-date', 'accessdate' }, 'redundant_parameters' );
    local ArchiveDate = selectone( args, {'archive-date', 'archivedate' }, 'redundant_parameters' );
    local Agency = args.agency
    local DeadURL = args.deadurl or &quot;yes&quot;           -- Only used if ArchiveURL is present.
    local Language = selectone( args, {'language', 'in'}, 'redundant_parameters' );
    local Format = args.format
    local Ref = selectone( args, {'ref', 'Ref'}, 'redundant_parameters' );

    local DoiBroken = selectone( args, {'doi_inactivedate', 'doi_brokendate', 'DoiBroken'}, 'redundant_parameters' );
    local ID = selectone( args, {'id', 'ID', 'docket'}, 'redundant_parameters' );
    local ASINTLD = selectone( args, {'ASIN-TLD', 'asin-tld'}, 'redundant_parameters' );
    local IgnoreISBN = selectone( args, {'ignore-isbn-error', 'ignoreisbnerror'}, 'redundant_parameters' );

    local ID_list = extractids( args );
    
    local Quote = selectone( args, {'quote', 'quotation'}, 'redundant_parameters' );
    local PostScript = args.postscript or &quot;.&quot;
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = selectone( args, {'transcript-url', 'transcripturl'}, 'redundant_parameters' );
    local sepc = args.separator or &quot;.&quot;
    local LastAuthorAmp = args.lastauthoramp
    local no_tracking_cats = selectone( args, {&quot;template doc demo&quot;, 'nocat', 
        'notracking', &quot;no-tracking&quot;}, 'redundant_parameters' ) or &quot;&quot;;

    if ( config.CitationClass == &quot;journal&quot; ) then        
        if (URL == nil or URL == &quot;&quot;) then
            if (ID_list['PMC'] ~= nil) then 
                local Embargo = args.embargo or args.Embargo;
                if Embargo ~= nil then
                    local lang = mw.getContentLanguage();
                    local good1, result1, good2, result2;
                    good1, result1 = pcall( lang.formatDate, lang, 'U', Embargo );
                    good2, result2 = pcall( lang.formatDate, lang, 'U' );

                    if good1 and good2 and tonumber( result1 ) &lt; tonumber( result2 ) then 
                        URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];
                    end
                else
                    URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];           
                end
            end
        end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, cfg.message_list[&quot;episode&quot;] .. &quot; &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, cfg.message_list[&quot;season&quot;] .. &quot; &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, cfg.message_list[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows 
    -- automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
        if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    
    for k, v in pairs( ID_list ) do
        if k == 'ISBN' then
            v = cleanisbn( v );
        end
        if string.sub( cfg.id_handlers[k].COinS or &quot;info&quot;, 1, 4 ) ~= 'info' then
            OCinSdata[ cfg.id_handlers[k].COinS ] = v;
        end
    end
    
    OCinSdata.rft_id = URL or ChapterURL

    local last, first;
    local OCinSauthors = {};
    for k, v in ipairs( a ) do
        last = v.last;
        first = v.first;
        if k == 1 then
            if last ~= nil then
                OCinSdata[&quot;rft.aulast&quot;] = last;
            end
            if first ~= nil then 
                OCinSdata[&quot;rft.aufirst&quot;] = first;
            end
        end
        if last ~= nil and first ~= nil then
            table.insert( OCinSauthors, last .. (args.NameSep or &quot;, &quot;) .. first );
    	elseif last ~= nil then
            table.insert( OCinSauthors, last );
        end
    end

    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    for k, v in pairs( ID_list ) do
        if string.sub( cfg.id_handlers[k].COinS or &quot;&quot;, 1, 4 ) == 'info' then
            OCinSids[ cfg.id_handlers[k].COinS ] = v;
        end
    end

    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode( removewikilink(value) );
    end
    for _, value in ipairs(OCinSauthors) do
        OCinStitle = OCinStitle .. &quot;&amp;rft.au=&quot; .. mw.uri.encode( removewikilink(value) );
    end
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. removewikilink(value) );
    end
    
    local this_page = mw.title.getCurrentTitle();
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/&quot; .. mw.site.server:match( &quot;[^/]*$&quot; ) .. &quot;:&quot;
       .. this_page.prefixedText  -- end COinS data by page's non-encoded pagename

    if (Periodical ~= nil and Periodical ~= &quot;&quot;) and
        (Chapter == nil or Chapter == '') and
        (Title ~= nil and Title ~= &quot;&quot;) then
            Chapter = Title
            ChapterLink = TitleLink
            TransChapter = TransTitle
            Title = nil
            TitleLink = nil
            TransTitle = nil            
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local Maximum = tonumber( (selectone( args, {&quot;display-authors&quot;, &quot;displayauthors&quot;}, 'redundant_parameters' )) );
        
        -- Preserve old-style implicit et al.
        if Maximum == nil and #a == 9 then 
            Maximum = 8;
            table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
        elseif Maximum == nil then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = (args[&quot;author-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = selectone( args, {&quot;author-format&quot;, &quot;authorformat&quot; }, 'redundant_parameters' ),
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        }
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if Coauthors ~= nil and Coauthors ~= &quot;&quot; then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
                
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local Maximum = tonumber( (selectone( args, {&quot;display-editors&quot;, &quot;displayeditors&quot;}, 'redundant_parameters' )) );

        -- Preserve old-style implicit et al.
        if Maximum == nil and #e == 4 then 
            Maximum = 3;
            table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
        elseif Maximum == nil then
            Maximum = #e + 1;
        end

        local control = { 
            sep = (args[&quot;editor-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = selectone( args, {&quot;editor-format&quot;, &quot;editorformat&quot; }, 'redundant_parameters' ),
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
            }

        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date
    
    if ( URL == nil or URL == '' ) and
            ( ChapterURL == nil or ChapterURL == '' ) and
            ( ArchiveURL == nil or ArchiveURL == '' ) and                
            ( ConferenceURL == nil or ConferenceURL == '' ) and                
            ( TranscriptURL == nil or TranscriptURL == '' ) then

        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
        end

        -- Test if accessdate is given without giving a URL
        if ( AccessDate ~= nil and AccessDate ~= '' ) then
            table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
            AccessDate = nil;
        end      
    
        -- Test if format is given without giving a URL
        if ( Format ~= nil and Format ~= '' ) then
            Format = Format .. seterror( 'format_missing_url' );
        end        
    end    

    -- Test if citation has no title
    if ( Chapter == nil or Chapter == &quot;&quot; ) and 
            ( Title == nil or Title == &quot;&quot; ) and
            ( Periodical == nil or Periodical == &quot;&quot; ) and
            ( Conference == nil or Conference == &quot;&quot; ) and 
            ( TransTitle == nil or TransTitle == &quot;&quot; ) and
            ( TransChapter == nil or TransChapter == &quot;&quot; ) then
        table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
    end

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
        end
    end

    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
        
    -- Format chapter / article title
    if ( Chapter ~= nil and Chapter ~= &quot;&quot; ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) and (Title ~= nil and Title ~= &quot;&quot; )
        then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
    else
        Chapter = &quot;&quot;;
    end
    
    local TransError = &quot;&quot;
    if TransChapter ~= &quot;&quot; and Chapter == &quot;&quot; then
        TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
    end
    Chapter = Chapter .. TransChapter
    if Chapter ~= &quot;&quot; then
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then                
                Chapter = externallink( ChapterURL, Chapter ) .. TransError;
                if URL == nil or URL == &quot;&quot; then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = externallink( URL, Chapter ) .. TransError .. Format;
                URL = nil
                Format = &quot;&quot;
            else
                Chapter = Chapter .. TransError;
            end            
        elseif ChapterURL ~= nil and ChapterURL ~= &quot;&quot; then
            Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL ) .. 
                TransError;
        else
            Chapter = Chapter .. TransError;
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    elseif ChapterURL ~= nil and ChapterURL ~= &quot;&quot; then
        Chapter = &quot; &quot; .. externallink( ChapterURL ) .. sepc .. &quot; &quot;;
    end        
    
    -- Format main title.
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
                or config.CitationClass == &quot;news&quot; 
                or config.CitationClass == &quot;pressrelease&quot; ) and 
                Chapter == &quot;&quot; then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
    else
        Title = &quot;&quot;;
    end    
    
    local TransError = &quot;&quot;;
    if TransTitle ~= &quot;&quot; and Title == &quot;&quot; then
        TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
    end
    Title = Title .. TransTitle
    if Title ~= &quot;&quot; then
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = externallink( URL, Title ) .. TransError .. Format       
            URL = nil
            Format = ''
        else
            Title = Title .. TransError;
        end
    end

    if ( Place ~= nil and Place ~= &quot;&quot; ) then
        if sepc == '.' then
            Place = &quot; &quot; .. cfg.message_list['written'] .. &quot; &quot; .. Place .. sepc .. &quot; &quot;;
        else
            Place = &quot; &quot; .. cfg.message_list['written']:lower() .. &quot; &quot; .. Place .. sepc .. &quot; &quot;;
        end            
    else
        Place = &quot;&quot;;
    end
    
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = externallink( ConferenceURL, Conference );
        end
        Conference = &quot; &quot; .. Conference
    elseif ConferenceURL ~= nil and ConferenceURL ~= &quot;&quot; then
        Conference = &quot; &quot; .. externallink( ConferenceURL );
    else
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.message_list['minutes'];
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption 
                if TimeCaption == nil then
                    TimeCaption = cfg.message_list['event'];
                    if sepc ~= '.' then
                        TimeCaption = TimeCaption:lower();
                    end
                end                
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (&quot; .. cfg.message_list['in'] .. &quot; &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; &quot; .. cfg.message_list['edition'] .. &quot;)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; &quot; .. cfg.message_list['via'] .. &quot; &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; &quot; .. cfg.message_list['retrieved'] .. &quot; &quot;
         if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
             .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.message_list['subscription'];
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end

    ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN} );

    if ( URL ~= nil and URL ~=&quot;&quot;) then
        URL = &quot; &quot; .. externallink( URL, URL );
        local error_text = seterror( 'bare_url_missing_title' );
        if config.CitationClass == &quot;web&quot; then
            URL = URL .. &quot; &quot; .. seterror( 'cite_web_title' );
        else
            URL = URL .. error_text;
        end       
    else
        URL = &quot;&quot;
    end

    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot; &quot; .. seterror('archive_missing_date') .. &quot; &quot;
        end
        local arch_text = cfg.message_list['archived'];
        if (sepc ~= &quot;.&quot;) then arch_text = arch_text:lower() end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; &quot; .. externallink( ArchiveURL, arch_text ) .. &quot; &quot; .. 
                cfg.message_list['from'] .. &quot; &quot; .. cfg.message_list['original'] .. &quot; &quot; .. 
                cfg.message_list['on'] .. ArchiveDate
            if OriginalURL == nil or OriginalUrl == '' then
                Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url_not_dead');                               
            end
        else
            if OriginalURL ~= nil and OriginalURL ~= '' then
                Archived = sepc .. &quot; &quot; .. arch_text .. &quot; &quot; .. cfg.message_list['from'] .. 
                    &quot; &quot; .. externallink( OriginalURL, cfg.message_list['original'] ) .. &quot; &quot;
                    .. cfg.message_list['on'] .. ArchiveDate
            else
                if config.CitationClass ~= 'web' then 
                    Archived = sepc .. &quot; &quot; .. arch_text .. &quot; &quot; .. cfg.message_list['from'] .. &quot; &quot; .. 
                    cfg.message_list['original'] .. seterror('archive_missing_url') .. &quot; &quot; .. cfg.message_list['on'] .. ArchiveDate
                else
                    Archived = sepc .. &quot; &quot; .. arch_text .. &quot; &quot; .. cfg.message_list['from'] .. &quot; &quot; .. 
                    cfg.message_list['original'] .. seterror('archive_missing_url_web') .. &quot; &quot; .. cfg.message_list['on'] .. ArchiveDate
                end
            end                
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        if sepc == '.' then
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; &quot; .. cfg.message_list['lay summary'] .. &quot;]&quot; .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; &quot; .. cfg.message_list['lay summary']:lower() .. &quot;]&quot; .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = externallink( TranscriptURL, Transcript ) end
    elseif TranscriptURL ~= nil and TranscriptURL ~= &quot;&quot; then
        Transcript = externallink( TranscriptURL )     
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; and
         config.CitationClass ~= &quot;pressrelease&quot; ) then
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            if Publisher ~= '' then
                Publisher = Publisher .. &quot;, &quot; .. cfg.message_list['published'] .. &quot; &quot; .. PublicationDate;
            else
                Publisher = PublicationDate;
            end
        end
        if Publisher ~= &quot;&quot; then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (&quot; .. cfg.message_list['published'] .. &quot; &quot; .. PublicationDate .. &quot;)&quot;
        else 
            PublicationDate = &quot;&quot;
        end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot; ) or ( TitleNote and TitleNote ~= &quot;&quot; ) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( ( (config.CitationClass == &quot;journal&quot;) or (config.CitationClass == &quot;citation&quot;) )  and
         Periodical ~= &quot;&quot; ) then
        if (Others ~= &quot;&quot;) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
            Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
            Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
    end
    
    if #ID_list &gt; 0 then
        ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
    else
        ID_list = ID;
    end    
    local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );

    local text
    local pgtext = Page .. Pages .. At
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, &quot; .. cfg.message_list['editor'];
            else
                Editors = Editors .. &quot;, &quot; .. cfg.message_list['editors'];
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (&quot; .. cfg.message_list['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (&quot; .. cfg.message_list['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end -- endif &quot;&quot;~=Date
        if ( config.CitationClass==&quot;journal&quot; and Periodical ) then
          text = safejoin( {Chapter, Place, tcommon}, sepc );
          text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
          text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
          text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if PostScript ~= '' and PostScript ~= nil and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local options = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do 
                    names[i] = v.last 
                    if i == 4 then break end
                end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do 
                    names[i] = v.last 
                    if i == 4 then break end                
                end
            end
            names[ #names + 1 ] = Year;
            id = anchorid(names)
        end
        options.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = {};
        text = seterror('empty_citation');
        z.message_tail = {};
    end
    
    if options.id ~= nil then 
        text = '&lt;span id=&quot;' .. wikiescape(options.id) ..'&quot; class=&quot;' .. wikiescape(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    else
        text = '&lt;span class=&quot;' .. wikiescape(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    end        

    local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = '&lt;span title=&quot;' .. wikiescape(OCinStitle) .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        for i,v in ipairs( z.message_tail ) do
            if v[1] ~= nil and v[1] ~= &quot;&quot; then 
                if i == #z.message_tail then
                    text = text .. errorcomment( v[1], v[2] );
                else
                    text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
                end
            end
        end
    end
    
    if no_tracking_cats == '' then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    local suggestions = {};
    local error_text, error_state;
    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            if not validate( k ) then            
                error_text = &quot;&quot;;
                if type( k ) ~= 'string' then
                    -- Exclude empty numbered parameters
                    if v:match(&quot;%S+&quot;) ~= nil then
                        error_text, error_state = seterror( 'text_ignored', {v}, true );
                    end
                elseif validate( k:lower() ) then 
                    error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
                else
                    if #suggestions == 0 then
                        suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
                    end
                    if suggestions[ k:lower() ] ~= nil then
                        error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
                    else
                        error_text, error_state = seterror( 'parameter_ignored', {k}, true );
                    end
                end                  
                if error_text ~= '' then
                    table.insert( z.message_tail, {error_text, error_state} );
                end                
            end            
            args[k] = v;
        elseif k == 'postscript' then
            args[k] = v;
        end        
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        if args[k] == nil and (v ~= '' or k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--18Mar2013 Fixed &quot;page=&quot; to override &quot;pages=&quot; as in markup-based cites.
--19Mar2013 Fixed date of class=journal Periodical to show after page.
--19Mar2013 Changed null &quot;postscript=&quot; to suppress end-dot of citation.
--20Mar2013 If CitationClass is journal, show &quot;others=&quot; before title.
--20Mar2013 If CitationClass is book, show &quot;others=&quot; before edition.
--20Mar2013 If CitationClass is journal, adjust &quot;others=&quot; to have sepc.
--20Mar2013 For class &quot;journal&quot;, use book format unless Periodical set.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; after wikilink &quot;.]]&quot; end dot.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; after external &quot;.]&quot; end dot.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; at italic wikilink &quot;.]]&quot; end.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; at italic external &quot;.]&quot; end.
--04Apr2013 Moved sepc before &lt;span class=&quot;reference-accessdate&quot;&gt; for &quot;..&quot;.
--
--End</text>
      <sha1>c1b59g4wol2wreqnq8x7x91yqtqh14i</sha1>
    </revision>
    <revision>
      <id>4650</id>
      <parentid>4649</parentid>
      <timestamp>2013-04-16T05:43:48Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>move to message</comment>
      <origin>4650</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="69870" sha1="cqvbwnm388ajanoh1gn97ay21z2fijj" xml:space="preserve">local z = {
    error_categories = {};
    error_ids = {};
    message_tail = {};
}

-- Include translation message hooks, ID and error handling configuration settings.
local cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );
 
-- Contains a list of all recognized parameters
local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );

-- Checks that parameter name is valid
function validate( name )
    name = tostring( name );
    
    -- Normal arguments
    if whitelist.basic_arguments[ name ] then
        return true;
    end
    
    -- Arguments with numbers in them
    name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );
    if whitelist.numbered_arguments[ name ] then
        return true;
    end
    
    -- Not found, argument not supported.
    return false
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
    if hidden then 
        return '&lt;span style=&quot;display:none;font-size:100%&quot; class=&quot;error citation-comment&quot;&gt;' .. content .. '&lt;/span&gt;';
    else
        return '&lt;span style=&quot;font-size:100%&quot; class=&quot;error&quot;&gt;' .. content .. '&lt;/span&gt;';
    end        
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, args, raw, prefix, suffix )
    local error_state = cfg.error_conditions[ error_id ];
    prefix = prefix or &quot;&quot;;
    suffix = suffix or &quot;&quot;;

    if error_state == nil then
        error( cfg.message_list['undefined_error'] );
    end
    
    if error_state.category ~= nil and error_state.category ~= &quot;&quot; then
        table.insert( z.error_categories, error_state.category );
    end
    
    local message = error_state.message;
    if args ~= nil then
        for k, m in ipairs( args ) do
            m = m:gsub( &quot;%%&quot;, &quot;%%%%&quot; );
            message = message:gsub( &quot;$&quot; .. k .. &quot;(%D)&quot;, m .. &quot;%1&quot; );
        end
    end

    message = wikiescape(message) .. &quot; ([[&quot; .. cfg.message_list['help page link'] .. 
        &quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
        cfg.message_list['help page label'] .. &quot;]])&quot;;

    z.error_ids[ error_id ] = true;
    if (error_id == 'bare_url_missing_title' or error_id == 'trans_missing_title')
            and z.error_ids['citation_missing_title'] then
        return '', false;
    end
    
    message = prefix .. message .. suffix;
    
    if raw == true then
        return message, error_state.hidden;
    end        
        
    return errorcomment( message, error_state.hidden );
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',    
            ['{'] = '&amp;#123;',    
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

-- Formats a wiki style external link
function externallinkid(options)
    local sep = options.separator or &quot;&amp;nbsp;&quot;
    options.suffix = options.suffix or &quot;&quot;
    local url_string = options.id
    if options.encode == true or options.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    return &quot;[[&quot; .. options.link .. &quot;|&quot; .. options.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. 
            options.prefix .. url_string .. options.suffix .. &quot; &quot; .. mw.text.nowiki(options.id) .. &quot;]&quot;
end

-- Formats a wiki style internal link
function internallinkid(options)
    local sep = options.separator or &quot;&amp;nbsp;&quot;
    options.suffix = options.suffix or &quot;&quot;
    return &quot;[[&quot; .. options.link .. &quot;|&quot; .. options.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. 
            options.prefix .. options.id .. options.suffix .. &quot;|&quot; .. mw.text.nowiki(options.id) .. &quot;]]&quot;
end

-- Format an external link with error checking
function externallink( URL, label )
    local error_str = &quot;&quot;;
    if label == nil or label == &quot;&quot; then
        label = URL;
        error_str = seterror( 'bare_url_missing_title', {}, false, &quot; &quot; );
    end
    if not checkurl( URL ) then
        error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
    end

    return &quot;[&quot; .. URL .. ' ' .. safeforurl( label ) .. &quot;]&quot; .. error_str;
end

-- Formats a link to Amazon
function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local handler = cfg.id_handlers['ASIN'];
    return externallinkid({link = handler.link,
        label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
        encode=handler.encode, separator = handler.separator})
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    local handler = cfg.id_handlers['DOI'];
    
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (&quot; .. cfg.message_list['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link = handler.link, label = handler.label,
            prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then      
        cat = seterror( 'bad_doi' );
    end
    return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    local handler = cfg.id_handlers['OL'];
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    else
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode}) .. 
            ' ' .. seterror( 'bad_ol' );
    end
end

--[[
Determines whether an URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
    if url_str:sub(1,2) == &quot;//&quot; then  
        -- Protocol-less URLs
        return true;
    elseif url_str:match( &quot;^[^/]*:&quot; ) ~= nil then   
        -- Look for &quot;:&quot; prefix and assume it is a URI scheme
        return true;
    else
        -- Anything else is an error
        return false;
    end
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
    return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
    isbn_str = cleanisbn( isbn_str ):gsub( &quot;-&quot;, &quot;&quot; );
    local len = isbn_str:len();
 
    if len ~= 10 and len ~= 13 then
        return false;
    end
 
    local temp = 0;
    if len == 10 then
        if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            if v == string.byte( &quot;X&quot; ) then
                temp = temp + 10*( 11 - i );
            else
                temp = temp + tonumber( string.char(v) )*(11-i);
            end
        end
        return temp % 11 == 0;
    else
        if isbn_str:match( &quot;^%d*$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
        end
        return temp % 10 == 0;
    end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
    str = str:gsub( &quot;%[%[[^|%]]*|([^%]]*)%]%]&quot;, &quot;%1&quot; );
    str = str:gsub( &quot;%[%[([^%]]*)%]%]&quot;, &quot;%1&quot; );    
    return str
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    if str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then 
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str:gsub( '\n', ' ' );
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    -- Is the input a simple number?
    local num = tonumber( str ); 
    if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
        return str;
    else
        -- Use formatDate to interpret more complicated formats
        local lang = mw.getContentLanguage();
        local good, result;
        good, result = pcall( lang.formatDate, lang, 'Y', str )
        if good then 
            return result;
        else
            -- Can't make sense of this input, return blank.
            return &quot;&quot;;
        end
    end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil and first ~= '') then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    if count &gt; 1 and lastauthoramp ~= nil and lastauthoramp ~= &quot;&quot; and not etal then
        text[count-1] = text[count-1] .. &quot; &amp; &quot; .. text[count];
        text[count] = nil;
    end    
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = cfg.message_list['et al'];
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result = 
        '&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
    end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
    return &quot;CITEREF&quot; .. mw.uri.anchorEncode( table.concat( options ) );
end

-- Gets author list from the input arguments
function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    while true do
        if i == 1 then 
            last = selectone( args, {&quot;author&quot; .. i .. &quot;-last&quot;, &quot;author-last&quot; .. i, 
                &quot;last&quot; .. i, &quot;surname&quot; .. i, &quot;Author&quot; .. i, &quot;author&quot; .. i, 
                &quot;author-last&quot;, &quot;last&quot;, &quot;surname&quot;, &quot;Author&quot;, &quot;author&quot;, &quot;authors&quot;}, 'redundant_parameters' );
        else
            last = selectone( args, {&quot;author&quot; .. i .. &quot;-last&quot;, &quot;author-last&quot; .. i, 
                &quot;last&quot; .. i, &quot;surname&quot; .. i, &quot;Author&quot; .. i, &quot;author&quot; .. i}, 'redundant_parameters' );
        end
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            if i == 1 then 
                authors[i] = {
                    last = last,
                    first = selectone( args, {&quot;author&quot; .. i .. &quot;-first&quot;, &quot;author-first&quot; .. i, 
                        &quot;first&quot; .. i, &quot;given&quot; .. i, &quot;author-first&quot;, 
                        &quot;first&quot;, &quot;given&quot;}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;author&quot; .. i .. &quot;-link&quot;, &quot;author-link&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;link&quot;, &quot;authorlink&quot; .. i, &quot;author-link&quot;,  
                        &quot;authorlink&quot;}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;author&quot; .. i .. &quot;-mask&quot;, &quot;author-mask&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;mask&quot;, &quot;authormask&quot; .. i, &quot;author-mask&quot;, 
                        &quot;authormask&quot; }, 'redundant_parameters' )
                }
            else
                authors[i] = {
                    last = last,
                    first = selectone( args, {&quot;author&quot; .. i .. &quot;-first&quot;, &quot;author-first&quot; .. i, 
                        &quot;first&quot; .. i, &quot;given&quot; .. i}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;author&quot; .. i .. &quot;-link&quot;, &quot;author-link&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;link&quot;, &quot;authorlink&quot; .. i}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;author&quot; .. i .. &quot;-mask&quot;, &quot;author-mask&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;mask&quot;, &quot;authormask&quot; .. i}, 'redundant_parameters' )
                }
            end            
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

-- Gets editor list from the input arguments
function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        if i == 1 then
            last = selectone( args, {&quot;editor&quot; .. i .. &quot;-last&quot;, &quot;editor-last&quot; .. i,
                &quot;EditorSurname&quot; .. i, &quot;Editor&quot; .. i, &quot;editor&quot; .. i, &quot;editor-last&quot;, 
                &quot;EditorSurname&quot;, &quot;Editor&quot;, &quot;editor&quot;, &quot;editors&quot;}, 'redundant_parameters' );
        else
            last = selectone( args, {&quot;editor&quot; .. i .. &quot;-last&quot;, &quot;editor-last&quot; .. i,
                &quot;EditorSurname&quot; .. i, &quot;Editor&quot; .. i, &quot;editor&quot; .. i}, 'redundant_parameters' );
        end        
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            if i == 1 then
                editors[i] = {
                    last = last,
                    first = selectone( args, {&quot;editor&quot; .. i .. &quot;-first&quot;, 
                        &quot;editor-first&quot; .. i, &quot;EditorGiven&quot; .. i, &quot;editor-first&quot;, 
                        &quot;EditorGiven&quot;}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;editor&quot; .. i .. &quot;-link&quot;, &quot;editor-link&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;link&quot;, &quot;editorlink&quot; .. i, &quot;editor-link&quot;, 
                        &quot;editorlink&quot;}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;editor&quot; .. i .. &quot;-mask&quot;, &quot;editor-mask&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;mask&quot;, &quot;editormask&quot; .. i, &quot;editor-mask&quot;,  
                        &quot;editormask&quot;}, 'redundant_parameters' )
                }                
            else
                editors[i] = {
                    last = last,
                    first = selectone( args, {&quot;editor&quot; .. i .. &quot;-first&quot;, 
                        &quot;editor-first&quot; .. i, &quot;EditorGiven&quot; .. i}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;editor&quot; .. i .. &quot;-link&quot;, &quot;editor-link&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;link&quot;, &quot;editorlink&quot; .. i}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;editor&quot; .. i .. &quot;-mask&quot;, &quot;editor-mask&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;mask&quot;, &quot;editormask&quot; .. i}, 'redundant_parameters' )
                }
            end
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
    local id_list = {};
    
    for k, v in pairs( cfg.id_handlers ) do    
        id_list[k] = selectone( args, v.parameters, 'redundant_parameters' );
    end

    return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
    local handler;
    local new_list = {};
    
    for k, v in pairs( id_list ) do
        handler = {};
        
        --Becasue cfg is read-only we have to copy it the hard way.
        for k2, v2 in pairs( cfg.id_handlers[k] ) do
            handler[k2] = v2;
        end
        handler['id'] = v;
        
        if handler.mode == 'external' then        
            table.insert( new_list, {handler.label, externallinkid( handler ) } );
        elseif handler.mode == 'internal' then
            table.insert( new_list, {handler.label, internallinkid( handler ) } );
        elseif handler.mode == 'manual' then
            if k == 'DOI' then
                table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
            elseif k == 'ASIN' then
                table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
            elseif k == 'OL' then
                table.insert( new_list, {handler.label, openlibrary( v ) } );
            elseif k == 'ISBN' then
                local ISBN = internallinkid( handler );
                if not checkisbn( v ) and ( options.IgnoreISBN == nil or options.IgnoreISBN == &quot;&quot; ) then 
                    ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
                end
                table.insert( new_list, {handler.label, ISBN } );                
            else
                error( cfg.message_list['unknown_manual_ID'] );
            end            
        else
            error( cfg.message_list['unknown_ID_mode'] );
        end
    end

    function comp( a, b )
        return a[1] &lt; b[1];
    end

    table.sort( new_list, comp );
    for k, v in ipairs( new_list ) do
        new_list[k] = v[2];
    end
    
    return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition )
    local value = nil;
    local selected = '';
    local error_list = {};
    
    for _, v in ipairs( possible ) do
        if args[v] ~= nil then
            if value ~= nil then
                table.insert( error_list, v );
            else
                value = args[v];
                selected = v;
            end
        end
    end
            
    if #error_list &gt; 0 then
        local error_str = &quot;&quot;;
        for _, k in ipairs( error_list ) do
            if error_str ~= &quot;&quot; then error_str = error_str .. &quot;, &quot; end
            error_str = error_str .. &quot;&lt;code&gt;|&quot; .. k .. &quot;=&lt;/code&gt;&quot;;
        end
        if #error_list &gt; 1 then
            error_str = error_str .. &quot;, and &quot;;
        else
            error_str = error_str .. &quot; and &quot;;
        end
        error_str = error_str .. &quot;&lt;code&gt;|&quot; .. selected .. &quot;=&lt;/code&gt;&quot;;
        table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
    end
            
    return value, selected;
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    -- Load Input Parameters

    local i 
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = args.authors
    local a = extractauthors( args );

    local Coauthors = selectone( args, {'coauthors', 'coauthor' }, 'redundant_parameters' );
    local Others = args.others 
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = selectone( args, {'publicationdate', 'publication-date' }, 'redundant_parameters' );
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = selectone( args, {'trans-title', 'trans_title' }, 'redundant_parameters' );
    local TitleNote = args.department
    local TitleLink = selectone( args, {'titlelink', 'episodelink' }, 'redundant_parameters' );
    local Chapter = selectone( args, {'chapter', 'contribution', 'entry' }, 'redundant_parameters' );
    local ChapterLink = args.chapterlink
    local TransChapter = selectone( args, {'trans-chapter', 'trans_chapter' }, 'redundant_parameters' );
    local TitleType = args.type
    local ArchiveURL = selectone( args, {'archive-url', 'archiveurl' }, 'redundant_parameters' );
    local URL = selectone( args, {'url', 'URL'}, 'redundant_parameters' );
    local ChapterURL = selectone( args, {'chapter-url', 'chapterurl', 'contribution-url', 'contributionurl' }, 'redundant_parameters' );
    local ConferenceURL = selectone( args, {'conference-url', 'conferenceurl' }, 'redundant_parameters' );
    local Periodical = selectone( args, {'journal', 'newspaper', 'magazine', 'work', 'website', 
        'periodical', 'encyclopedia', 'encyclopaedia'}, 'redundant_parameters' );
            
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = nil          
            TransTitle = nil
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = nil 
                TransTitle = nil
            end
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = nil end
        end
    end
    local Series = selectone( args, {'series', 'version'}, 'redundant_parameters' );
    local Volume = args.volume
    local Issue = selectone( args, {'issue', 'number'}, 'redundant_parameters' );
    local Position = nil
    local Page, Pages, At, page_type;
    
    Page, page_type = selectone( args, {'p', 'page', 'pp', 'pages', 'at'}, 
        'extra_pages' );
    if page_type == 'pp' or page_type == 'pages' then
        Pages = hyphentodash( Page );
        Page = nil;
    elseif page_type == 'at' then
        At = Page;
        Page = nil;
    end
                
    local Edition = args.edition
    local PublicationPlace = selectone( args, {'publication-place', 'publicationplace' }, 'redundant_parameters' ); 
    local Place = selectone( args, {'place', 'location'}, 'redundant_parameters' );
    if PublicationPlace == nil and Place ~= nil then 
        PublicationPlace = Place;
    end
    if PublicationPlace == Place then Place = nil end
    
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = selectone( args, {'access-date', 'accessdate' }, 'redundant_parameters' );
    local ArchiveDate = selectone( args, {'archive-date', 'archivedate' }, 'redundant_parameters' );
    local Agency = args.agency
    local DeadURL = args.deadurl or &quot;yes&quot;           -- Only used if ArchiveURL is present.
    local Language = selectone( args, {'language', 'in'}, 'redundant_parameters' );
    local Format = args.format
    local Ref = selectone( args, {'ref', 'Ref'}, 'redundant_parameters' );

    local DoiBroken = selectone( args, {'doi_inactivedate', 'doi_brokendate', 'DoiBroken'}, 'redundant_parameters' );
    local ID = selectone( args, {'id', 'ID', 'docket'}, 'redundant_parameters' );
    local ASINTLD = selectone( args, {'ASIN-TLD', 'asin-tld'}, 'redundant_parameters' );
    local IgnoreISBN = selectone( args, {'ignore-isbn-error', 'ignoreisbnerror'}, 'redundant_parameters' );

    local ID_list = extractids( args );
    
    local Quote = selectone( args, {'quote', 'quotation'}, 'redundant_parameters' );
    local PostScript = args.postscript or &quot;.&quot;
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = selectone( args, {'transcript-url', 'transcripturl'}, 'redundant_parameters' );
    local sepc = args.separator or &quot;.&quot;
    local LastAuthorAmp = args.lastauthoramp
    local no_tracking_cats = selectone( args, {&quot;template doc demo&quot;, 'nocat', 
        'notracking', &quot;no-tracking&quot;}, 'redundant_parameters' ) or &quot;&quot;;

    if ( config.CitationClass == &quot;journal&quot; ) then        
        if (URL == nil or URL == &quot;&quot;) then
            if (ID_list['PMC'] ~= nil) then 
                local Embargo = args.embargo or args.Embargo;
                if Embargo ~= nil then
                    local lang = mw.getContentLanguage();
                    local good1, result1, good2, result2;
                    good1, result1 = pcall( lang.formatDate, lang, 'U', Embargo );
                    good2, result2 = pcall( lang.formatDate, lang, 'U' );

                    if good1 and good2 and tonumber( result1 ) &lt; tonumber( result2 ) then 
                        URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];
                    end
                else
                    URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];           
                end
            end
        end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, cfg.message_list[&quot;episode&quot;] .. &quot; &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, cfg.message_list[&quot;season&quot;] .. &quot; &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, cfg.message_list[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows 
    -- automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
        if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    
    for k, v in pairs( ID_list ) do
        if k == 'ISBN' then
            v = cleanisbn( v );
        end
        if string.sub( cfg.id_handlers[k].COinS or &quot;info&quot;, 1, 4 ) ~= 'info' then
            OCinSdata[ cfg.id_handlers[k].COinS ] = v;
        end
    end
    
    OCinSdata.rft_id = URL or ChapterURL

    local last, first;
    local OCinSauthors = {};
    for k, v in ipairs( a ) do
        last = v.last;
        first = v.first;
        if k == 1 then
            if last ~= nil then
                OCinSdata[&quot;rft.aulast&quot;] = last;
            end
            if first ~= nil then 
                OCinSdata[&quot;rft.aufirst&quot;] = first;
            end
        end
        if last ~= nil and first ~= nil then
            table.insert( OCinSauthors, last .. (args.NameSep or &quot;, &quot;) .. first );
    	elseif last ~= nil then
            table.insert( OCinSauthors, last );
        end
    end

    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    for k, v in pairs( ID_list ) do
        if string.sub( cfg.id_handlers[k].COinS or &quot;&quot;, 1, 4 ) == 'info' then
            OCinSids[ cfg.id_handlers[k].COinS ] = v;
        end
    end

    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode( removewikilink(value) );
    end
    for _, value in ipairs(OCinSauthors) do
        OCinStitle = OCinStitle .. &quot;&amp;rft.au=&quot; .. mw.uri.encode( removewikilink(value) );
    end
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. removewikilink(value) );
    end
    
    local this_page = mw.title.getCurrentTitle();
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/&quot; .. mw.site.server:match( &quot;[^/]*$&quot; ) .. &quot;:&quot;
       .. this_page.prefixedText  -- end COinS data by page's non-encoded pagename

    if (Periodical ~= nil and Periodical ~= &quot;&quot;) and
        (Chapter == nil or Chapter == '') and
        (Title ~= nil and Title ~= &quot;&quot;) then
            Chapter = Title
            ChapterLink = TitleLink
            TransChapter = TransTitle
            Title = nil
            TitleLink = nil
            TransTitle = nil            
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local Maximum = tonumber( (selectone( args, {&quot;display-authors&quot;, &quot;displayauthors&quot;}, 'redundant_parameters' )) );
        
        -- Preserve old-style implicit et al.
        if Maximum == nil and #a == 9 then 
            Maximum = 8;
            table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
        elseif Maximum == nil then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = (args[&quot;author-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = selectone( args, {&quot;author-format&quot;, &quot;authorformat&quot; }, 'redundant_parameters' ),
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        }
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if Coauthors ~= nil and Coauthors ~= &quot;&quot; then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
                
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local Maximum = tonumber( (selectone( args, {&quot;display-editors&quot;, &quot;displayeditors&quot;}, 'redundant_parameters' )) );

        -- Preserve old-style implicit et al.
        if Maximum == nil and #e == 4 then 
            Maximum = 3;
            table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
        elseif Maximum == nil then
            Maximum = #e + 1;
        end

        local control = { 
            sep = (args[&quot;editor-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = selectone( args, {&quot;editor-format&quot;, &quot;editorformat&quot; }, 'redundant_parameters' ),
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
            }

        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date
    
    if ( URL == nil or URL == '' ) and
            ( ChapterURL == nil or ChapterURL == '' ) and
            ( ArchiveURL == nil or ArchiveURL == '' ) and                
            ( ConferenceURL == nil or ConferenceURL == '' ) and                
            ( TranscriptURL == nil or TranscriptURL == '' ) then

        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
        end

        -- Test if accessdate is given without giving a URL
        if ( AccessDate ~= nil and AccessDate ~= '' ) then
            table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
            AccessDate = nil;
        end      
    
        -- Test if format is given without giving a URL
        if ( Format ~= nil and Format ~= '' ) then
            Format = Format .. seterror( 'format_missing_url' );
        end        
    end    

    -- Test if citation has no title
    if ( Chapter == nil or Chapter == &quot;&quot; ) and 
            ( Title == nil or Title == &quot;&quot; ) and
            ( Periodical == nil or Periodical == &quot;&quot; ) and
            ( Conference == nil or Conference == &quot;&quot; ) and 
            ( TransTitle == nil or TransTitle == &quot;&quot; ) and
            ( TransChapter == nil or TransChapter == &quot;&quot; ) then
        table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
    end

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
        end
    end

    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
        
    -- Format chapter / article title
    if ( Chapter ~= nil and Chapter ~= &quot;&quot; ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) and (Title ~= nil and Title ~= &quot;&quot; )
        then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
    else
        Chapter = &quot;&quot;;
    end
    
    local TransError = &quot;&quot;
    if TransChapter ~= &quot;&quot; and Chapter == &quot;&quot; then
        TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
    end
    Chapter = Chapter .. TransChapter
    if Chapter ~= &quot;&quot; then
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then                
                Chapter = externallink( ChapterURL, Chapter ) .. TransError;
                if URL == nil or URL == &quot;&quot; then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = externallink( URL, Chapter ) .. TransError .. Format;
                URL = nil
                Format = &quot;&quot;
            else
                Chapter = Chapter .. TransError;
            end            
        elseif ChapterURL ~= nil and ChapterURL ~= &quot;&quot; then
            Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL ) .. 
                TransError;
        else
            Chapter = Chapter .. TransError;
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    elseif ChapterURL ~= nil and ChapterURL ~= &quot;&quot; then
        Chapter = &quot; &quot; .. externallink( ChapterURL ) .. sepc .. &quot; &quot;;
    end        
    
    -- Format main title.
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
                or config.CitationClass == &quot;news&quot; 
                or config.CitationClass == &quot;pressrelease&quot; ) and 
                Chapter == &quot;&quot; then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
    else
        Title = &quot;&quot;;
    end    
    
    local TransError = &quot;&quot;;
    if TransTitle ~= &quot;&quot; and Title == &quot;&quot; then
        TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
    end
    Title = Title .. TransTitle
    if Title ~= &quot;&quot; then
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = externallink( URL, Title ) .. TransError .. Format       
            URL = nil
            Format = ''
        else
            Title = Title .. TransError;
        end
    end

    if ( Place ~= nil and Place ~= &quot;&quot; ) then
        if sepc == '.' then
            Place = &quot; &quot; .. cfg.message_list['written'] .. &quot; &quot; .. Place .. sepc .. &quot; &quot;;
        else
            Place = &quot; &quot; .. cfg.message_list['written']:lower() .. &quot; &quot; .. Place .. sepc .. &quot; &quot;;
        end            
    else
        Place = &quot;&quot;;
    end
    
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = externallink( ConferenceURL, Conference );
        end
        Conference = &quot; &quot; .. Conference
    elseif ConferenceURL ~= nil and ConferenceURL ~= &quot;&quot; then
        Conference = &quot; &quot; .. externallink( ConferenceURL );
    else
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.message_list['minutes'];
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption 
                if TimeCaption == nil then
                    TimeCaption = cfg.message_list['event'];
                    if sepc ~= '.' then
                        TimeCaption = TimeCaption:lower();
                    end
                end                
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (&quot; .. cfg.message_list['in'] .. &quot; &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; &quot; .. cfg.message_list['edition'] .. &quot;)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; &quot; .. cfg.message_list['via'] .. &quot; &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; &quot; .. cfg.message_list['retrieved']
         if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
             .. substitution( retrv_text, { AccessDate } ) .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.message_list['subscription'];
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end

    ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN} );

    if ( URL ~= nil and URL ~=&quot;&quot;) then
        URL = &quot; &quot; .. externallink( URL, URL );
        local error_text = seterror( 'bare_url_missing_title' );
        if config.CitationClass == &quot;web&quot; then
            URL = URL .. &quot; &quot; .. seterror( 'cite_web_title' );
        else
            URL = URL .. error_text;
        end       
    else
        URL = &quot;&quot;
    end

    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot; &quot; .. seterror('archive_missing_date') .. &quot; &quot;
        end
        local arch_text = cfg.message_list['archived'];
        if (sepc ~= &quot;.&quot;) then arch_text = arch_text:lower() end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; &quot; .. externallink( ArchiveURL, arch_text ) .. &quot; &quot; .. 
                cfg.message_list['from'] .. &quot; &quot; .. cfg.message_list['original'] .. &quot; &quot; .. 
                cfg.message_list['on'] .. ArchiveDate
            if OriginalURL == nil or OriginalUrl == '' then
                Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url_not_dead');                               
            end
        else
            if OriginalURL ~= nil and OriginalURL ~= '' then
                Archived = sepc .. &quot; &quot; .. arch_text .. &quot; &quot; .. cfg.message_list['from'] .. 
                    &quot; &quot; .. externallink( OriginalURL, cfg.message_list['original'] ) .. &quot; &quot;
                    .. cfg.message_list['on'] .. ArchiveDate
            else
                if config.CitationClass ~= 'web' then 
                    Archived = sepc .. &quot; &quot; .. arch_text .. &quot; &quot; .. cfg.message_list['from'] .. &quot; &quot; .. 
                    cfg.message_list['original'] .. seterror('archive_missing_url') .. &quot; &quot; .. cfg.message_list['on'] .. ArchiveDate
                else
                    Archived = sepc .. &quot; &quot; .. arch_text .. &quot; &quot; .. cfg.message_list['from'] .. &quot; &quot; .. 
                    cfg.message_list['original'] .. seterror('archive_missing_url_web') .. &quot; &quot; .. cfg.message_list['on'] .. ArchiveDate
                end
            end                
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        if sepc == '.' then
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; &quot; .. cfg.message_list['lay summary'] .. &quot;]&quot; .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; &quot; .. cfg.message_list['lay summary']:lower() .. &quot;]&quot; .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = externallink( TranscriptURL, Transcript ) end
    elseif TranscriptURL ~= nil and TranscriptURL ~= &quot;&quot; then
        Transcript = externallink( TranscriptURL )     
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; and
         config.CitationClass ~= &quot;pressrelease&quot; ) then
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            if Publisher ~= '' then
                Publisher = Publisher .. &quot;, &quot; .. cfg.message_list['published'] .. &quot; &quot; .. PublicationDate;
            else
                Publisher = PublicationDate;
            end
        end
        if Publisher ~= &quot;&quot; then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (&quot; .. cfg.message_list['published'] .. &quot; &quot; .. PublicationDate .. &quot;)&quot;
        else 
            PublicationDate = &quot;&quot;
        end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot; ) or ( TitleNote and TitleNote ~= &quot;&quot; ) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( ( (config.CitationClass == &quot;journal&quot;) or (config.CitationClass == &quot;citation&quot;) )  and
         Periodical ~= &quot;&quot; ) then
        if (Others ~= &quot;&quot;) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
            Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
            Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
    end
    
    if #ID_list &gt; 0 then
        ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
    else
        ID_list = ID;
    end    
    local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );

    local text
    local pgtext = Page .. Pages .. At
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, &quot; .. cfg.message_list['editor'];
            else
                Editors = Editors .. &quot;, &quot; .. cfg.message_list['editors'];
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (&quot; .. cfg.message_list['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (&quot; .. cfg.message_list['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end -- endif &quot;&quot;~=Date
        if ( config.CitationClass==&quot;journal&quot; and Periodical ) then
          text = safejoin( {Chapter, Place, tcommon}, sepc );
          text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
          text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
          text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if PostScript ~= '' and PostScript ~= nil and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local options = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do 
                    names[i] = v.last 
                    if i == 4 then break end
                end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do 
                    names[i] = v.last 
                    if i == 4 then break end                
                end
            end
            names[ #names + 1 ] = Year;
            id = anchorid(names)
        end
        options.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = {};
        text = seterror('empty_citation');
        z.message_tail = {};
    end
    
    if options.id ~= nil then 
        text = '&lt;span id=&quot;' .. wikiescape(options.id) ..'&quot; class=&quot;' .. wikiescape(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    else
        text = '&lt;span class=&quot;' .. wikiescape(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    end        

    local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = '&lt;span title=&quot;' .. wikiescape(OCinStitle) .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        for i,v in ipairs( z.message_tail ) do
            if v[1] ~= nil and v[1] ~= &quot;&quot; then 
                if i == #z.message_tail then
                    text = text .. errorcomment( v[1], v[2] );
                else
                    text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
                end
            end
        end
    end
    
    if no_tracking_cats == '' then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    local suggestions = {};
    local error_text, error_state;
    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            if not validate( k ) then            
                error_text = &quot;&quot;;
                if type( k ) ~= 'string' then
                    -- Exclude empty numbered parameters
                    if v:match(&quot;%S+&quot;) ~= nil then
                        error_text, error_state = seterror( 'text_ignored', {v}, true );
                    end
                elseif validate( k:lower() ) then 
                    error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
                else
                    if #suggestions == 0 then
                        suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
                    end
                    if suggestions[ k:lower() ] ~= nil then
                        error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
                    else
                        error_text, error_state = seterror( 'parameter_ignored', {k}, true );
                    end
                end                  
                if error_text ~= '' then
                    table.insert( z.message_tail, {error_text, error_state} );
                end                
            end            
            args[k] = v;
        elseif k == 'postscript' then
            args[k] = v;
        end        
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        if args[k] == nil and (v ~= '' or k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--18Mar2013 Fixed &quot;page=&quot; to override &quot;pages=&quot; as in markup-based cites.
--19Mar2013 Fixed date of class=journal Periodical to show after page.
--19Mar2013 Changed null &quot;postscript=&quot; to suppress end-dot of citation.
--20Mar2013 If CitationClass is journal, show &quot;others=&quot; before title.
--20Mar2013 If CitationClass is book, show &quot;others=&quot; before edition.
--20Mar2013 If CitationClass is journal, adjust &quot;others=&quot; to have sepc.
--20Mar2013 For class &quot;journal&quot;, use book format unless Periodical set.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; after wikilink &quot;.]]&quot; end dot.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; after external &quot;.]&quot; end dot.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; at italic wikilink &quot;.]]&quot; end.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; at italic external &quot;.]&quot; end.
--04Apr2013 Moved sepc before &lt;span class=&quot;reference-accessdate&quot;&gt; for &quot;..&quot;.
--
--End</text>
      <sha1>cqvbwnm388ajanoh1gn97ay21z2fijj</sha1>
    </revision>
    <revision>
      <id>4651</id>
      <parentid>4650</parentid>
      <timestamp>2013-04-16T05:44:36Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>D'oh, meant to edit sandbox</comment>
      <origin>4651</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="69859" sha1="c1b59g4wol2wreqnq8x7x91yqtqh14i" xml:space="preserve">local z = {
    error_categories = {};
    error_ids = {};
    message_tail = {};
}

-- Include translation message hooks, ID and error handling configuration settings.
local cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );
 
-- Contains a list of all recognized parameters
local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );

-- Checks that parameter name is valid
function validate( name )
    name = tostring( name );
    
    -- Normal arguments
    if whitelist.basic_arguments[ name ] then
        return true;
    end
    
    -- Arguments with numbers in them
    name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );
    if whitelist.numbered_arguments[ name ] then
        return true;
    end
    
    -- Not found, argument not supported.
    return false
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
    if hidden then 
        return '&lt;span style=&quot;display:none;font-size:100%&quot; class=&quot;error citation-comment&quot;&gt;' .. content .. '&lt;/span&gt;';
    else
        return '&lt;span style=&quot;font-size:100%&quot; class=&quot;error&quot;&gt;' .. content .. '&lt;/span&gt;';
    end        
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, args, raw, prefix, suffix )
    local error_state = cfg.error_conditions[ error_id ];
    prefix = prefix or &quot;&quot;;
    suffix = suffix or &quot;&quot;;

    if error_state == nil then
        error( cfg.message_list['undefined_error'] );
    end
    
    if error_state.category ~= nil and error_state.category ~= &quot;&quot; then
        table.insert( z.error_categories, error_state.category );
    end
    
    local message = error_state.message;
    if args ~= nil then
        for k, m in ipairs( args ) do
            m = m:gsub( &quot;%%&quot;, &quot;%%%%&quot; );
            message = message:gsub( &quot;$&quot; .. k .. &quot;(%D)&quot;, m .. &quot;%1&quot; );
        end
    end

    message = wikiescape(message) .. &quot; ([[&quot; .. cfg.message_list['help page link'] .. 
        &quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
        cfg.message_list['help page label'] .. &quot;]])&quot;;

    z.error_ids[ error_id ] = true;
    if (error_id == 'bare_url_missing_title' or error_id == 'trans_missing_title')
            and z.error_ids['citation_missing_title'] then
        return '', false;
    end
    
    message = prefix .. message .. suffix;
    
    if raw == true then
        return message, error_state.hidden;
    end        
        
    return errorcomment( message, error_state.hidden );
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',    
            ['{'] = '&amp;#123;',    
            ['|'] = '&amp;#124;',	
            ['}'] = '&amp;#125;' } );
    return text;
end

-- Formats a wiki style external link
function externallinkid(options)
    local sep = options.separator or &quot;&amp;nbsp;&quot;
    options.suffix = options.suffix or &quot;&quot;
    local url_string = options.id
    if options.encode == true or options.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    return &quot;[[&quot; .. options.link .. &quot;|&quot; .. options.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. 
            options.prefix .. url_string .. options.suffix .. &quot; &quot; .. mw.text.nowiki(options.id) .. &quot;]&quot;
end

-- Formats a wiki style internal link
function internallinkid(options)
    local sep = options.separator or &quot;&amp;nbsp;&quot;
    options.suffix = options.suffix or &quot;&quot;
    return &quot;[[&quot; .. options.link .. &quot;|&quot; .. options.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. 
            options.prefix .. options.id .. options.suffix .. &quot;|&quot; .. mw.text.nowiki(options.id) .. &quot;]]&quot;
end

-- Format an external link with error checking
function externallink( URL, label )
    local error_str = &quot;&quot;;
    if label == nil or label == &quot;&quot; then
        label = URL;
        error_str = seterror( 'bare_url_missing_title', {}, false, &quot; &quot; );
    end
    if not checkurl( URL ) then
        error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
    end

    return &quot;[&quot; .. URL .. ' ' .. safeforurl( label ) .. &quot;]&quot; .. error_str;
end

-- Formats a link to Amazon
function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local handler = cfg.id_handlers['ASIN'];
    return externallinkid({link = handler.link,
        label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
        encode=handler.encode, separator = handler.separator})
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    local handler = cfg.id_handlers['DOI'];
    
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (&quot; .. cfg.message_list['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link = handler.link, label = handler.label,
            prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then      
        cat = seterror( 'bad_doi' );
    end
    return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    local handler = cfg.id_handlers['OL'];
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    else
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode}) .. 
            ' ' .. seterror( 'bad_ol' );
    end
end

--[[
Determines whether an URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
    if url_str:sub(1,2) == &quot;//&quot; then  
        -- Protocol-less URLs
        return true;
    elseif url_str:match( &quot;^[^/]*:&quot; ) ~= nil then   
        -- Look for &quot;:&quot; prefix and assume it is a URI scheme
        return true;
    else
        -- Anything else is an error
        return false;
    end
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
    return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
    isbn_str = cleanisbn( isbn_str ):gsub( &quot;-&quot;, &quot;&quot; );
    local len = isbn_str:len();
 
    if len ~= 10 and len ~= 13 then
        return false;
    end
 
    local temp = 0;
    if len == 10 then
        if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            if v == string.byte( &quot;X&quot; ) then
                temp = temp + 10*( 11 - i );
            else
                temp = temp + tonumber( string.char(v) )*(11-i);
            end
        end
        return temp % 11 == 0;
    else
        if isbn_str:match( &quot;^%d*$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
        end
        return temp % 10 == 0;
    end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
    str = str:gsub( &quot;%[%[[^|%]]*|([^%]]*)%]%]&quot;, &quot;%1&quot; );
    str = str:gsub( &quot;%[%[([^%]]*)%]%]&quot;, &quot;%1&quot; );    
    return str
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    if str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then 
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        return str:gsub( '\n', ' ' );
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    -- Is the input a simple number?
    local num = tonumber( str ); 
    if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
        return str;
    else
        -- Use formatDate to interpret more complicated formats
        local lang = mw.getContentLanguage();
        local good, result;
        good, result = pcall( lang.formatDate, lang, 'Y', str )
        if good then 
            return result;
        else
            -- Can't make sense of this input, return blank.
            return &quot;&quot;;
        end
    end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil and first ~= '') then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    if count &gt; 1 and lastauthoramp ~= nil and lastauthoramp ~= &quot;&quot; and not etal then
        text[count-1] = text[count-1] .. &quot; &amp; &quot; .. text[count];
        text[count] = nil;
    end    
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = cfg.message_list['et al'];
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result = 
        '&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
    end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
    return &quot;CITEREF&quot; .. mw.uri.anchorEncode( table.concat( options ) );
end

-- Gets author list from the input arguments
function extractauthors(args)
    local authors = {};
    local i = 1;
    local last;
    while true do
        if i == 1 then 
            last = selectone( args, {&quot;author&quot; .. i .. &quot;-last&quot;, &quot;author-last&quot; .. i, 
                &quot;last&quot; .. i, &quot;surname&quot; .. i, &quot;Author&quot; .. i, &quot;author&quot; .. i, 
                &quot;author-last&quot;, &quot;last&quot;, &quot;surname&quot;, &quot;Author&quot;, &quot;author&quot;, &quot;authors&quot;}, 'redundant_parameters' );
        else
            last = selectone( args, {&quot;author&quot; .. i .. &quot;-last&quot;, &quot;author-last&quot; .. i, 
                &quot;last&quot; .. i, &quot;surname&quot; .. i, &quot;Author&quot; .. i, &quot;author&quot; .. i}, 'redundant_parameters' );
        end
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            if i == 1 then 
                authors[i] = {
                    last = last,
                    first = selectone( args, {&quot;author&quot; .. i .. &quot;-first&quot;, &quot;author-first&quot; .. i, 
                        &quot;first&quot; .. i, &quot;given&quot; .. i, &quot;author-first&quot;, 
                        &quot;first&quot;, &quot;given&quot;}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;author&quot; .. i .. &quot;-link&quot;, &quot;author-link&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;link&quot;, &quot;authorlink&quot; .. i, &quot;author-link&quot;,  
                        &quot;authorlink&quot;}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;author&quot; .. i .. &quot;-mask&quot;, &quot;author-mask&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;mask&quot;, &quot;authormask&quot; .. i, &quot;author-mask&quot;, 
                        &quot;authormask&quot; }, 'redundant_parameters' )
                }
            else
                authors[i] = {
                    last = last,
                    first = selectone( args, {&quot;author&quot; .. i .. &quot;-first&quot;, &quot;author-first&quot; .. i, 
                        &quot;first&quot; .. i, &quot;given&quot; .. i}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;author&quot; .. i .. &quot;-link&quot;, &quot;author-link&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;link&quot;, &quot;authorlink&quot; .. i}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;author&quot; .. i .. &quot;-mask&quot;, &quot;author-mask&quot; .. i, 
                        &quot;author&quot; .. i .. &quot;mask&quot;, &quot;authormask&quot; .. i}, 'redundant_parameters' )
                }
            end            
        else
            break;
        end
        i = i + 1;
    end
    return authors;
end

-- Gets editor list from the input arguments
function extracteditors(args)
    local editors = {};
    local i = 1;
    local last;
    
    while true do
        if i == 1 then
            last = selectone( args, {&quot;editor&quot; .. i .. &quot;-last&quot;, &quot;editor-last&quot; .. i,
                &quot;EditorSurname&quot; .. i, &quot;Editor&quot; .. i, &quot;editor&quot; .. i, &quot;editor-last&quot;, 
                &quot;EditorSurname&quot;, &quot;Editor&quot;, &quot;editor&quot;, &quot;editors&quot;}, 'redundant_parameters' );
        else
            last = selectone( args, {&quot;editor&quot; .. i .. &quot;-last&quot;, &quot;editor-last&quot; .. i,
                &quot;EditorSurname&quot; .. i, &quot;Editor&quot; .. i, &quot;editor&quot; .. i}, 'redundant_parameters' );
        end        
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            if i == 1 then
                editors[i] = {
                    last = last,
                    first = selectone( args, {&quot;editor&quot; .. i .. &quot;-first&quot;, 
                        &quot;editor-first&quot; .. i, &quot;EditorGiven&quot; .. i, &quot;editor-first&quot;, 
                        &quot;EditorGiven&quot;}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;editor&quot; .. i .. &quot;-link&quot;, &quot;editor-link&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;link&quot;, &quot;editorlink&quot; .. i, &quot;editor-link&quot;, 
                        &quot;editorlink&quot;}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;editor&quot; .. i .. &quot;-mask&quot;, &quot;editor-mask&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;mask&quot;, &quot;editormask&quot; .. i, &quot;editor-mask&quot;,  
                        &quot;editormask&quot;}, 'redundant_parameters' )
                }                
            else
                editors[i] = {
                    last = last,
                    first = selectone( args, {&quot;editor&quot; .. i .. &quot;-first&quot;, 
                        &quot;editor-first&quot; .. i, &quot;EditorGiven&quot; .. i}, 'redundant_parameters' ),
                    link = selectone( args, {&quot;editor&quot; .. i .. &quot;-link&quot;, &quot;editor-link&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;link&quot;, &quot;editorlink&quot; .. i}, 'redundant_parameters' ),
                    mask = selectone( args, {&quot;editor&quot; .. i .. &quot;-mask&quot;, &quot;editor-mask&quot; .. i, 
                        &quot;editor&quot; .. i .. &quot;mask&quot;, &quot;editormask&quot; .. i}, 'redundant_parameters' )
                }
            end
        else
            break;
        end
        i = i + 1;
    end
    return editors;
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
    local id_list = {};
    
    for k, v in pairs( cfg.id_handlers ) do    
        id_list[k] = selectone( args, v.parameters, 'redundant_parameters' );
    end

    return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
    local handler;
    local new_list = {};
    
    for k, v in pairs( id_list ) do
        handler = {};
        
        --Becasue cfg is read-only we have to copy it the hard way.
        for k2, v2 in pairs( cfg.id_handlers[k] ) do
            handler[k2] = v2;
        end
        handler['id'] = v;
        
        if handler.mode == 'external' then        
            table.insert( new_list, {handler.label, externallinkid( handler ) } );
        elseif handler.mode == 'internal' then
            table.insert( new_list, {handler.label, internallinkid( handler ) } );
        elseif handler.mode == 'manual' then
            if k == 'DOI' then
                table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
            elseif k == 'ASIN' then
                table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
            elseif k == 'OL' then
                table.insert( new_list, {handler.label, openlibrary( v ) } );
            elseif k == 'ISBN' then
                local ISBN = internallinkid( handler );
                if not checkisbn( v ) and ( options.IgnoreISBN == nil or options.IgnoreISBN == &quot;&quot; ) then 
                    ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
                end
                table.insert( new_list, {handler.label, ISBN } );                
            else
                error( cfg.message_list['unknown_manual_ID'] );
            end            
        else
            error( cfg.message_list['unknown_ID_mode'] );
        end
    end

    function comp( a, b )
        return a[1] &lt; b[1];
    end

    table.sort( new_list, comp );
    for k, v in ipairs( new_list ) do
        new_list[k] = v[2];
    end
    
    return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition )
    local value = nil;
    local selected = '';
    local error_list = {};
    
    for _, v in ipairs( possible ) do
        if args[v] ~= nil then
            if value ~= nil then
                table.insert( error_list, v );
            else
                value = args[v];
                selected = v;
            end
        end
    end
            
    if #error_list &gt; 0 then
        local error_str = &quot;&quot;;
        for _, k in ipairs( error_list ) do
            if error_str ~= &quot;&quot; then error_str = error_str .. &quot;, &quot; end
            error_str = error_str .. &quot;&lt;code&gt;|&quot; .. k .. &quot;=&lt;/code&gt;&quot;;
        end
        if #error_list &gt; 1 then
            error_str = error_str .. &quot;, and &quot;;
        else
            error_str = error_str .. &quot; and &quot;;
        end
        error_str = error_str .. &quot;&lt;code&gt;|&quot; .. selected .. &quot;=&lt;/code&gt;&quot;;
        table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
    end
            
    return value, selected;
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    -- Load Input Parameters

    local i 
    local PPrefix = config.PPrefix or &quot;p.&amp;nbsp;&quot;
    local PPPrefix = config.PPPrefix or &quot;pp.&amp;nbsp;&quot;
    if ( nil ~= args.nopp ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = args.authors
    local a = extractauthors( args );

    local Coauthors = selectone( args, {'coauthors', 'coauthor' }, 'redundant_parameters' );
    local Others = args.others 
    local Editors = args.editors
    local e = extracteditors( args );

    local Year = args.year 
    local PublicationDate = selectone( args, {'publicationdate', 'publication-date' }, 'redundant_parameters' );
    local OrigYear = args.origyear
    local Date = args.date
    local LayDate = args.laydate
    ------------------------------------------------- Get title data
    local Title = args.title or args.encyclopaedia or args.encyclopedia or args.dictionary
    local BookTitle = args.booktitle
    local Conference = args.conference
    local TransTitle = selectone( args, {'trans-title', 'trans_title' }, 'redundant_parameters' );
    local TitleNote = args.department
    local TitleLink = selectone( args, {'titlelink', 'episodelink' }, 'redundant_parameters' );
    local Chapter = selectone( args, {'chapter', 'contribution', 'entry' }, 'redundant_parameters' );
    local ChapterLink = args.chapterlink
    local TransChapter = selectone( args, {'trans-chapter', 'trans_chapter' }, 'redundant_parameters' );
    local TitleType = args.type
    local ArchiveURL = selectone( args, {'archive-url', 'archiveurl' }, 'redundant_parameters' );
    local URL = selectone( args, {'url', 'URL'}, 'redundant_parameters' );
    local ChapterURL = selectone( args, {'chapter-url', 'chapterurl', 'contribution-url', 'contributionurl' }, 'redundant_parameters' );
    local ConferenceURL = selectone( args, {'conference-url', 'conferenceurl' }, 'redundant_parameters' );
    local Periodical = selectone( args, {'journal', 'newspaper', 'magazine', 'work', 'website', 
        'periodical', 'encyclopedia', 'encyclopaedia'}, 'redundant_parameters' );
            
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( args.article and args.article ~= &quot;&quot;) then
            if ( Title and Title ~= &quot;&quot;) then Periodical = Title end
            Chapter = args.article
            TransChapter = TransTitle
            Title = nil          
            TransTitle = nil
        elseif ( Chapter == nil or Chapter == '' ) then
            if Title ~= args.encyclopedia then 
                Chapter = Title
                TransChapter = TransTitle
                Title = nil 
                TransTitle = nil
            end
        end
        if ( Periodical and Periodical ~= &quot;&quot;) then
            if Periodical == Title or Periodical == Chapter then Periodical = nil end
        end
    end
    local Series = selectone( args, {'series', 'version'}, 'redundant_parameters' );
    local Volume = args.volume
    local Issue = selectone( args, {'issue', 'number'}, 'redundant_parameters' );
    local Position = nil
    local Page, Pages, At, page_type;
    
    Page, page_type = selectone( args, {'p', 'page', 'pp', 'pages', 'at'}, 
        'extra_pages' );
    if page_type == 'pp' or page_type == 'pages' then
        Pages = hyphentodash( Page );
        Page = nil;
    elseif page_type == 'at' then
        At = Page;
        Page = nil;
    end
                
    local Edition = args.edition
    local PublicationPlace = selectone( args, {'publication-place', 'publicationplace' }, 'redundant_parameters' ); 
    local Place = selectone( args, {'place', 'location'}, 'redundant_parameters' );
    if PublicationPlace == nil and Place ~= nil then 
        PublicationPlace = Place;
    end
    if PublicationPlace == Place then Place = nil end
    
    local PublisherName = args.publisher
    local SubscriptionRequired = args.subscription
    local Via = args.via
    local AccessDate = selectone( args, {'access-date', 'accessdate' }, 'redundant_parameters' );
    local ArchiveDate = selectone( args, {'archive-date', 'archivedate' }, 'redundant_parameters' );
    local Agency = args.agency
    local DeadURL = args.deadurl or &quot;yes&quot;           -- Only used if ArchiveURL is present.
    local Language = selectone( args, {'language', 'in'}, 'redundant_parameters' );
    local Format = args.format
    local Ref = selectone( args, {'ref', 'Ref'}, 'redundant_parameters' );

    local DoiBroken = selectone( args, {'doi_inactivedate', 'doi_brokendate', 'DoiBroken'}, 'redundant_parameters' );
    local ID = selectone( args, {'id', 'ID', 'docket'}, 'redundant_parameters' );
    local ASINTLD = selectone( args, {'ASIN-TLD', 'asin-tld'}, 'redundant_parameters' );
    local IgnoreISBN = selectone( args, {'ignore-isbn-error', 'ignoreisbnerror'}, 'redundant_parameters' );

    local ID_list = extractids( args );
    
    local Quote = selectone( args, {'quote', 'quotation'}, 'redundant_parameters' );
    local PostScript = args.postscript or &quot;.&quot;
    local LaySummary = args.laysummary
    local LaySource = args.laysource
    local Transcript = args.transcript
    local TranscriptURL = selectone( args, {'transcript-url', 'transcripturl'}, 'redundant_parameters' );
    local sepc = args.separator or &quot;.&quot;
    local LastAuthorAmp = args.lastauthoramp
    local no_tracking_cats = selectone( args, {&quot;template doc demo&quot;, 'nocat', 
        'notracking', &quot;no-tracking&quot;}, 'redundant_parameters' ) or &quot;&quot;;

    if ( config.CitationClass == &quot;journal&quot; ) then        
        if (URL == nil or URL == &quot;&quot;) then
            if (ID_list['PMC'] ~= nil) then 
                local Embargo = args.embargo or args.Embargo;
                if Embargo ~= nil then
                    local lang = mw.getContentLanguage();
                    local good1, result1, good2, result2;
                    good1, result1 = pcall( lang.formatDate, lang, 'U', Embargo );
                    good2, result2 = pcall( lang.formatDate, lang, 'U' );

                    if good1 and good2 and tonumber( result1 ) &lt; tonumber( result2 ) then 
                        URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];
                    end
                else
                    URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];           
                end
            end
        end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = args.airdate
        local SeriesLink = args.serieslink
        local Season = args.season
        local SeriesNumber = args.seriesnumber or args.seriesno
        local Network = args.network
        local Station = args.station
        local s = {}
        if Issue ~= nil then table.insert(s, cfg.message_list[&quot;episode&quot;] .. &quot; &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, cfg.message_list[&quot;season&quot;] .. &quot; &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, cfg.message_list[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = args[&quot;series-separator&quot;] or args[&quot;separator&quot;] or &quot;. &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows 
    -- automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
        if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    
    for k, v in pairs( ID_list ) do
        if k == 'ISBN' then
            v = cleanisbn( v );
        end
        if string.sub( cfg.id_handlers[k].COinS or &quot;info&quot;, 1, 4 ) ~= 'info' then
            OCinSdata[ cfg.id_handlers[k].COinS ] = v;
        end
    end
    
    OCinSdata.rft_id = URL or ChapterURL

    local last, first;
    local OCinSauthors = {};
    for k, v in ipairs( a ) do
        last = v.last;
        first = v.first;
        if k == 1 then
            if last ~= nil then
                OCinSdata[&quot;rft.aulast&quot;] = last;
            end
            if first ~= nil then 
                OCinSdata[&quot;rft.aufirst&quot;] = first;
            end
        end
        if last ~= nil and first ~= nil then
            table.insert( OCinSauthors, last .. (args.NameSep or &quot;, &quot;) .. first );
    	elseif last ~= nil then
            table.insert( OCinSauthors, last );
        end
    end

    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    for k, v in pairs( ID_list ) do
        if string.sub( cfg.id_handlers[k].COinS or &quot;&quot;, 1, 4 ) == 'info' then
            OCinSids[ cfg.id_handlers[k].COinS ] = v;
        end
    end

    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode( removewikilink(value) );
    end
    for _, value in ipairs(OCinSauthors) do
        OCinStitle = OCinStitle .. &quot;&amp;rft.au=&quot; .. mw.uri.encode( removewikilink(value) );
    end
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. removewikilink(value) );
    end
    
    local this_page = mw.title.getCurrentTitle();
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/&quot; .. mw.site.server:match( &quot;[^/]*$&quot; ) .. &quot;:&quot;
       .. this_page.prefixedText  -- end COinS data by page's non-encoded pagename

    if (Periodical ~= nil and Periodical ~= &quot;&quot;) and
        (Chapter == nil or Chapter == '') and
        (Title ~= nil and Title ~= &quot;&quot;) then
            Chapter = Title
            ChapterLink = TitleLink
            TransChapter = TransTitle
            Title = nil
            TitleLink = nil
            TransTitle = nil            
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local Maximum = tonumber( (selectone( args, {&quot;display-authors&quot;, &quot;displayauthors&quot;}, 'redundant_parameters' )) );
        
        -- Preserve old-style implicit et al.
        if Maximum == nil and #a == 9 then 
            Maximum = 8;
            table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
        elseif Maximum == nil then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = (args[&quot;author-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;author-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = selectone( args, {&quot;author-format&quot;, &quot;authorformat&quot; }, 'redundant_parameters' ),
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        }
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if Coauthors ~= nil and Coauthors ~= &quot;&quot; then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
                
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local Maximum = tonumber( (selectone( args, {&quot;display-editors&quot;, &quot;displayeditors&quot;}, 'redundant_parameters' )) );

        -- Preserve old-style implicit et al.
        if Maximum == nil and #e == 4 then 
            Maximum = 3;
            table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
        elseif Maximum == nil then
            Maximum = #e + 1;
        end

        local control = { 
            sep = (args[&quot;editor-separator&quot;] or &quot;;&quot;) .. &quot; &quot;,
            namesep = (args[&quot;editor-name-separator&quot;] or args[&quot;name-separator&quot;] or &quot;,&quot;) .. &quot; &quot;,
            format = selectone( args, {&quot;editor-format&quot;, &quot;editorformat&quot; }, 'redundant_parameters' ),
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
            }

        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = args.month
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = args.day
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date
    
    if ( URL == nil or URL == '' ) and
            ( ChapterURL == nil or ChapterURL == '' ) and
            ( ArchiveURL == nil or ArchiveURL == '' ) and                
            ( ConferenceURL == nil or ConferenceURL == '' ) and                
            ( TranscriptURL == nil or TranscriptURL == '' ) then

        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
        end

        -- Test if accessdate is given without giving a URL
        if ( AccessDate ~= nil and AccessDate ~= '' ) then
            table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
            AccessDate = nil;
        end      
    
        -- Test if format is given without giving a URL
        if ( Format ~= nil and Format ~= '' ) then
            Format = Format .. seterror( 'format_missing_url' );
        end        
    end    

    -- Test if citation has no title
    if ( Chapter == nil or Chapter == &quot;&quot; ) and 
            ( Title == nil or Title == &quot;&quot; ) and
            ( Periodical == nil or Periodical == &quot;&quot; ) and
            ( Conference == nil or Conference == &quot;&quot; ) and 
            ( TransTitle == nil or TransTitle == &quot;&quot; ) and
            ( TransChapter == nil or TransChapter == &quot;&quot; ) then
        table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
    end

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
        end
    end

    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; [&quot; .. TransTitle .. &quot;&amp;#93;&quot; else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; [&quot; .. TransChapter .. &quot;&amp;#93;&quot; else TransChapter = &quot;&quot; end
        
    -- Format chapter / article title
    if ( Chapter ~= nil and Chapter ~= &quot;&quot; ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) and (Title ~= nil and Title ~= &quot;&quot; )
        then
            Chapter = &quot;''&quot; .. safeforitalics(Chapter) .. &quot;''&quot;
        else
            Chapter = &quot;\&quot;&quot; .. Chapter .. &quot;\&quot;&quot;
        end
    else
        Chapter = &quot;&quot;;
    end
    
    local TransError = &quot;&quot;
    if TransChapter ~= &quot;&quot; and Chapter == &quot;&quot; then
        TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
    end
    Chapter = Chapter .. TransChapter
    if Chapter ~= &quot;&quot; then
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then                
                Chapter = externallink( ChapterURL, Chapter ) .. TransError;
                if URL == nil or URL == &quot;&quot; then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = externallink( URL, Chapter ) .. TransError .. Format;
                URL = nil
                Format = &quot;&quot;
            else
                Chapter = Chapter .. TransError;
            end            
        elseif ChapterURL ~= nil and ChapterURL ~= &quot;&quot; then
            Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL ) .. 
                TransError;
        else
            Chapter = Chapter .. TransError;
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    elseif ChapterURL ~= nil and ChapterURL ~= &quot;&quot; then
        Chapter = &quot; &quot; .. externallink( ChapterURL ) .. sepc .. &quot; &quot;;
    end        
    
    -- Format main title.
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        elseif ( config.CitationClass == &quot;web&quot;
                or config.CitationClass == &quot;news&quot; 
                or config.CitationClass == &quot;pressrelease&quot; ) and 
                Chapter == &quot;&quot; then
            Title = &quot;\&quot;&quot; .. Title .. &quot;\&quot;&quot;
        else
            Title = &quot;''&quot; .. safeforitalics(Title) .. &quot;''&quot;
        end
    else
        Title = &quot;&quot;;
    end    
    
    local TransError = &quot;&quot;;
    if TransTitle ~= &quot;&quot; and Title == &quot;&quot; then
        TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
    end
    Title = Title .. TransTitle
    if Title ~= &quot;&quot; then
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = externallink( URL, Title ) .. TransError .. Format       
            URL = nil
            Format = ''
        else
            Title = Title .. TransError;
        end
    end

    if ( Place ~= nil and Place ~= &quot;&quot; ) then
        if sepc == '.' then
            Place = &quot; &quot; .. cfg.message_list['written'] .. &quot; &quot; .. Place .. sepc .. &quot; &quot;;
        else
            Place = &quot; &quot; .. cfg.message_list['written']:lower() .. &quot; &quot; .. Place .. sepc .. &quot; &quot;;
        end            
    else
        Place = &quot;&quot;;
    end
    
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = externallink( ConferenceURL, Conference );
        end
        Conference = &quot; &quot; .. Conference
    elseif ConferenceURL ~= nil and ConferenceURL ~= &quot;&quot; then
        Conference = &quot; &quot; .. externallink( ConferenceURL );
    else
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = args.minutes
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.message_list['minutes'];
        else
            local Time = args.time
            if ( nil ~= Time ) then
                local TimeCaption = args.timecaption 
                if TimeCaption == nil then
                    TimeCaption = cfg.message_list['event'];
                    if sepc ~= '.' then
                        TimeCaption = TimeCaption:lower();
                    end
                end                
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; (&quot; .. cfg.message_list['in'] .. &quot; &quot; .. Language .. &quot;)&quot; else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; (&quot; .. Edition .. &quot; &quot; .. cfg.message_list['edition'] .. &quot;)&quot; else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &amp;mdash; &quot; .. cfg.message_list['via'] .. &quot; &quot; .. Via else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; &quot; .. cfg.message_list['retrieved'] .. &quot; &quot;
         if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
             .. retrv_text .. AccessDate .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.message_list['subscription'];
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end

    ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN} );

    if ( URL ~= nil and URL ~=&quot;&quot;) then
        URL = &quot; &quot; .. externallink( URL, URL );
        local error_text = seterror( 'bare_url_missing_title' );
        if config.CitationClass == &quot;web&quot; then
            URL = URL .. &quot; &quot; .. seterror( 'cite_web_title' );
        else
            URL = URL .. error_text;
        end       
    else
        URL = &quot;&quot;
    end

    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; \&quot;&quot; .. Quote .. &quot;\&quot;&quot; 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate ~= nil and ArchiveDate ~=&quot;&quot; ) then
            ArchiveDate = &quot; &quot; .. ArchiveDate
        else 
            ArchiveDate = &quot; &quot; .. seterror('archive_missing_date') .. &quot; &quot;
        end
        local arch_text = cfg.message_list['archived'];
        if (sepc ~= &quot;.&quot;) then arch_text = arch_text:lower() end
        if ( &quot;no&quot; == DeadURL ) then
            Archived = sepc .. &quot; &quot; .. externallink( ArchiveURL, arch_text ) .. &quot; &quot; .. 
                cfg.message_list['from'] .. &quot; &quot; .. cfg.message_list['original'] .. &quot; &quot; .. 
                cfg.message_list['on'] .. ArchiveDate
            if OriginalURL == nil or OriginalUrl == '' then
                Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url_not_dead');                               
            end
        else
            if OriginalURL ~= nil and OriginalURL ~= '' then
                Archived = sepc .. &quot; &quot; .. arch_text .. &quot; &quot; .. cfg.message_list['from'] .. 
                    &quot; &quot; .. externallink( OriginalURL, cfg.message_list['original'] ) .. &quot; &quot;
                    .. cfg.message_list['on'] .. ArchiveDate
            else
                if config.CitationClass ~= 'web' then 
                    Archived = sepc .. &quot; &quot; .. arch_text .. &quot; &quot; .. cfg.message_list['from'] .. &quot; &quot; .. 
                    cfg.message_list['original'] .. seterror('archive_missing_url') .. &quot; &quot; .. cfg.message_list['on'] .. ArchiveDate
                else
                    Archived = sepc .. &quot; &quot; .. arch_text .. &quot; &quot; .. cfg.message_list['from'] .. &quot; &quot; .. 
                    cfg.message_list['original'] .. seterror('archive_missing_url_web') .. &quot; &quot; .. cfg.message_list['on'] .. ArchiveDate
                end
            end                
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        if sepc == '.' then
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; &quot; .. cfg.message_list['lay summary'] .. &quot;]&quot; .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; &quot; .. cfg.message_list['lay summary']:lower() .. &quot;]&quot; .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = externallink( TranscriptURL, Transcript ) end
    elseif TranscriptURL ~= nil and TranscriptURL ~= &quot;&quot; then
        Transcript = externallink( TranscriptURL )     
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; and
         config.CitationClass ~= &quot;pressrelease&quot; ) then
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            if Publisher ~= '' then
                Publisher = Publisher .. &quot;, &quot; .. cfg.message_list['published'] .. &quot; &quot; .. PublicationDate;
            else
                Publisher = PublicationDate;
            end
        end
        if Publisher ~= &quot;&quot; then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (&quot; .. cfg.message_list['published'] .. &quot; &quot; .. PublicationDate .. &quot;)&quot;
        else 
            PublicationDate = &quot;&quot;
        end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot; ) or ( TitleNote and TitleNote ~= &quot;&quot; ) then 
            Periodical = sepc .. &quot; ''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        else 
            Periodical = &quot;''&quot; .. safeforitalics(Periodical) .. &quot;''&quot;
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( ( (config.CitationClass == &quot;journal&quot;) or (config.CitationClass == &quot;citation&quot;) )  and
         Periodical ~= &quot;&quot; ) then
        if (Others ~= &quot;&quot;) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
            Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
            Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
    end
    
    if #ID_list &gt; 0 then
        ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
    else
        ID_list = ID;
    end    
    local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );

    local text
    local pgtext = Page .. Pages .. At
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. &quot;; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, &quot; .. cfg.message_list['editor'];
            else
                Editors = Editors .. &quot;, &quot; .. cfg.message_list['editors'];
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (&quot; .. cfg.message_list['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (&quot; .. cfg.message_list['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end -- endif &quot;&quot;~=Date
        if ( config.CitationClass==&quot;journal&quot; and Periodical ) then
          text = safejoin( {Chapter, Place, tcommon}, sepc );
          text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
          text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
          text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if PostScript ~= '' and PostScript ~= nil and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local options = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do 
                    names[i] = v.last 
                    if i == 4 then break end
                end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do 
                    names[i] = v.last 
                    if i == 4 then break end                
                end
            end
            names[ #names + 1 ] = Year;
            id = anchorid(names)
        end
        options.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = {};
        text = seterror('empty_citation');
        z.message_tail = {};
    end
    
    if options.id ~= nil then 
        text = '&lt;span id=&quot;' .. wikiescape(options.id) ..'&quot; class=&quot;' .. wikiescape(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    else
        text = '&lt;span class=&quot;' .. wikiescape(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    end        

    local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = '&lt;span title=&quot;' .. wikiescape(OCinStitle) .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        for i,v in ipairs( z.message_tail ) do
            if v[1] ~= nil and v[1] ~= &quot;&quot; then 
                if i == #z.message_tail then
                    text = text .. errorcomment( v[1], v[2] );
                else
                    text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
                end
            end
        end
    end
    
    if no_tracking_cats == '' then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    local suggestions = {};
    local error_text, error_state;
    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            if not validate( k ) then            
                error_text = &quot;&quot;;
                if type( k ) ~= 'string' then
                    -- Exclude empty numbered parameters
                    if v:match(&quot;%S+&quot;) ~= nil then
                        error_text, error_state = seterror( 'text_ignored', {v}, true );
                    end
                elseif validate( k:lower() ) then 
                    error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
                else
                    if #suggestions == 0 then
                        suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
                    end
                    if suggestions[ k:lower() ] ~= nil then
                        error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
                    else
                        error_text, error_state = seterror( 'parameter_ignored', {k}, true );
                    end
                end                  
                if error_text ~= '' then
                    table.insert( z.message_tail, {error_text, error_state} );
                end                
            end            
            args[k] = v;
        elseif k == 'postscript' then
            args[k] = v;
        end        
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        if args[k] == nil and (v ~= '' or k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z
---------------------------------------------------------------------
--NOTES
--
-- NOTE A1: This Lua module was originally designed to handle a mix
--      of citation styles, crossing Vancouver style with Wikipedia's
--      local Citation Style 1 (CS1) from {Template:Citation/core}.
--      However, the conflicting positions of parameters, scattered
--      in twisted locations across this module, led to a separate
--      variation just to untangle the CS1 format of citations.
--
-- NOTE D2: The placement of dots and other separators between the
--      displayed parameters has been a continual headache, to keep
--      coordinated with the data in parentheses &quot;(data)&quot;. There
--      has been a need to pre-check for the existence of related
--      options, to keep from putting double-dots &quot;..&quot; in some cases.
--      In particular, the omission of the &quot;title=&quot; parameter has led
--      to several cases of a spurious dot &quot;. .&quot; because the original
--      design had treated the title as a mandatory parameter.
--
------------------------------------------------------------------------
--HISTORY:
--18Oct2012 Fixed lead-space in Chapter by omitting &quot; &quot;.
--18Oct2012 Fixed lead-space in Chapter/Title as end &quot; &quot; of Authors/Date/...
--19Oct2012 Put HISTORY comments to log major changes (not typos).
--19Oct2012 Fixed extra dot &quot;..&quot; in Title by omitting at end of &quot;tcommon=...&quot;.
--19Oct2012 For pages, put &amp;nbsp in &quot;p.&amp;nbsp;&quot; etc.
--19Oct2012 Enhanced &quot;pages=&quot; to detect lone page as &quot;p.&quot; else &quot;pp.&quot; prefix.
--19Oct2012 Fixed to show &quot;.&quot; after Periodical name (work, newspaper...).
--19Oct2012 Fixed web-link to have spaces &quot;[...  Archived] from the original&quot;.
--19Oct2012 Fixed to show &quot;;&quot; between authors &amp; coauthors.
--19Oct2012 Fixed to omit extra &quot;.&quot; after coauthors.
--20Oct2012 Fixed COinS data to not urlencode all, as &quot;ctx_ver=Z39.88-2004&quot;
--20Oct2012 Fixed COinS to not end as &quot;&amp;&quot; but use lead &quot;&amp;rft...=&quot; form.
--20Oct2012 Fixed COinS to not url.encode page's &quot;rfr_id=...&quot; pagename.
--20Oct2012 Fixed COinS data when &quot;web&quot; to default to rft.genre &quot;book&quot;.
--05Nov2012 Add a span wrapper even when there is no Ref parameter
--15Feb2013 Added Agency for &quot;agency=xx&quot;.
--19Feb2013 Put NOTES comments to explain module operation.
--19Feb2013 Copied as Module:Citation/CS1 to alter to match wp:CS1 form.
--19Feb2013 Changed OrigYear to use [__] for CS1 style.
--19Feb2013 Fixed to not show duplicate Publisher/Agency.
--19Feb2013 Moved page-number parameters to after final date.
--19Feb2013 Fixed to not put double-dots after title again.
--20Feb2013 Changed to omit dot &quot;.&quot; if already ends with dot.
--20Feb2013 If class &quot;journal&quot; shows Publisher after Periodical/Series.
--20Feb2013 Shifted Format to after Language, and Others after Volume.
--20Feb2013 Set AccessDate + &lt;span class=&quot;reference-accessdate&quot;&gt;
--20Feb2013 Fixed url when deadurl=no.
--20Feb2013 Added sepc for separator character between parameters.
--20Feb2013 Put &quot;OCLC&quot; for &quot;Online Computer Library Center&quot;.
--20Feb2013 Fix empty &quot;authorlink=&quot; as person.link ~= &quot;&quot;.
--20Feb2013 Added space after AuthorSep &amp; AuthorNameSep.
--21Feb2013 Added args.contributor (was missing parameter).
--21Feb2013 Fixed EditorSep (was misspelled &quot;EdithorSep&quot;).
--21Feb2013 Set OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
--21Feb2013 Checked to omit blank codes (asin= | doi= etc.).
--21Feb2013 Set enddot to end line if not config.CitationClass &quot;citation&quot;.
--21Feb2013 Fixed to show &quot;issn=x&quot; as the ISSN code.
--21Feb2013 Fixed to show &quot;id=x&quot; after Zbl code.
--21Feb2013 Changed to omit double-dot before date when already dot.
--21Feb2013 Order config.CitationClass &quot;citation&quot;: Volume, Issue, Publisher.
--21Feb2013 Put warning &quot;Bad DOI (expected &quot;10.&quot;..)&quot; in DOI result.
--21Feb2013 Automatically unbolded volume+comma when &gt; 4 long.
--21Feb2013 Changed to allow lowercase &quot;asin-tld&quot;.
--22Feb2013 Fixed ref=harv to extract Year from Date.
--22Feb2013 Set Harvard refer. span id if config.CitationClass &quot;citation&quot;.
--22Feb2013 Fixed config.CitationClass &quot;citation&quot; as span class=&quot;citation&quot;.
--22Feb2013 Capitalized &quot;Archived/Retrieved&quot; only when sepc is dot &quot;.&quot;.
--23Feb2013 Fixed author editor for &quot;in&quot; or &quot;In&quot; and put space after sepc.
--23Feb2013 Changed to omit dot in &quot;et al.&quot; when sepc is &quot;.&quot; separator.
--23Feb2013 Fixed &quot;author1-first&quot; to also get args.given or args.given1.
--23Feb2013 Fixed args.article to set Title, after Periodical is Title.
--23Feb2013 Fixed to allow blank Title (such as &quot;contribution=mytitle&quot;).
--23Feb2013 Fixed double-dot &quot;..&quot; at end of Editors list
--26Feb2013 Moved &quot;issue=&quot; data to show before &quot;page=&quot;.
--26Feb2013 Moved &quot;type=&quot; data to show after &quot;format=&quot;.
--26Feb2013 For &quot;pmc=&quot; link, omitted suffix &quot;/?tool=pmcentrez&quot;.
--27Feb2013 For coauthors, omitted extra separator after authors.
--27Feb2013 For date, allowed empty date to use month/day/year.
--27Feb2013 Fixed double-dot &quot;..&quot; at end of authors/coauthors list.
--27Feb2013 Reset editor suffix as &quot;, ed.&quot; when date exists.
--27Feb2013 Removed duplicate display of &quot;others=&quot; data.
--27Feb2013 Removed parentheses &quot;( )&quot; around &quot;department&quot; TitleNote.
--05Mar2013 Moved Language to follow Periodical or Series.
--05Mar2013 Fixed Edition to follow Series or Volume.
--05Mar2013 Fixed class encyclopaedia to show article as quoted Chapter.
--05Mar2013 Fixed class encyclopaedia to show page as &quot;pp.&quot; or &quot;p.&quot;.
--07Mar2013 Changed class encyclopaedia to omit &quot;( )&quot; around publisher.
--07Mar2013 Fixed end double-dot by string.sub(idcommon,-1,-1) was &quot;-1,1&quot;.
--13Mar2013 Removed enddot &quot;.&quot; after &quot;quote=&quot; parameter.
--13Mar2013 Changed config.CitationClass &quot;news&quot; to use &quot;p.&quot; page format.
--13Mar2013 Fixed missing &quot;location=&quot; when &quot;web&quot; or &quot;encyclopaedia&quot;.
--14Mar2013 Fixed end double-dot after book/work title.
--14Mar2013 Fixed double-dot before &quot;p.&quot; or &quot;pp.&quot; page number.
--14Mar2013 Fixed config.CitationClass &quot;book&quot; to use p./pp. page.
--18Mar2013 Fixed &quot;page=&quot; to override &quot;pages=&quot; as in markup-based cites.
--19Mar2013 Fixed date of class=journal Periodical to show after page.
--19Mar2013 Changed null &quot;postscript=&quot; to suppress end-dot of citation.
--20Mar2013 If CitationClass is journal, show &quot;others=&quot; before title.
--20Mar2013 If CitationClass is book, show &quot;others=&quot; before edition.
--20Mar2013 If CitationClass is journal, adjust &quot;others=&quot; to have sepc.
--20Mar2013 For class &quot;journal&quot;, use book format unless Periodical set.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; after wikilink &quot;.]]&quot; end dot.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; after external &quot;.]&quot; end dot.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; at italic wikilink &quot;.]]&quot; end.
--03Apr2013 Changed safejoin() to omit &quot;.&quot; at italic external &quot;.]&quot; end.
--04Apr2013 Moved sepc before &lt;span class=&quot;reference-accessdate&quot;&gt; for &quot;..&quot;.
--
--End</text>
      <sha1>c1b59g4wol2wreqnq8x7x91yqtqh14i</sha1>
    </revision>
    <revision>
      <id>4652</id>
      <parentid>4651</parentid>
      <timestamp>2013-04-17T00:53:04Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>sync to sandbox, mostly translation handles almost uniformity for archiveurl errors.</comment>
      <origin>4652</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="59225" sha1="5twpyi1nudcqh6vh29s0ebgcn3enr9n" xml:space="preserve">local z = {
    error_categories = {};
    error_ids = {};
    message_tail = {};
}

local SEEN = {};
local DATA = {};

-- Include translation message hooks, ID and error handling configuration settings.
local cfg = require( 'Module:Citation/CS1/Configuration' );
 
-- Contains a list of all recognized parameters
local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );

-- Populates numbered arguments in a message string using
-- an argument table.
function substitute( message, arguments )
    if arguments == nil then 
        return message;
    end
    
    message = message .. &quot; &quot;;
    for k, v in ipairs( arguments ) do
        v = v:gsub( &quot;%%&quot;, &quot;%%%%&quot; );
        message = message:gsub( &quot;$&quot; .. k .. &quot;(%D)&quot;, v .. &quot;%1&quot; );
    end     
    message = message:sub(1,-2);
    return message;
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
    DATA = args;
    local tbl = {};
    
    local mt = {
        __index = function ( tbl, k )            
            if SEEN[k] then
                return nil;
            end
            
            local list = cfg.argument_map[k];                    

            if list == nil then
                error( cfg.message_list['unknown_argument_map'] );
            elseif type( list ) == 'string' then
                v = DATA[list];
            else                    
                v = selectone( DATA, cfg.argument_map[k],
                    'redundant_parameters' );
            end
            if v == nil then
                v = cfg.default_values[k];
            end
            SEEN[k] = true;
            tbl = rawset( tbl, k, v );
            
            return v;
        end,
    }
    return setmetatable( tbl, mt );
end

-- Checks that parameter name is valid using the whitelist
function validate( name )
    name = tostring( name );
    
    -- Normal arguments
    if whitelist.basic_arguments[ name ] then
        return true;
    end
    
    -- Arguments with numbers in them
    name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );
    if whitelist.numbered_arguments[ name ] then
        return true;
    end
    
    -- Not found, argument not supported.
    return false
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
    if hidden then 
        return substitute( cfg.message_list['hidden-error'], { content } );
    else
        return substitute( cfg.message_list['visible-error'], { content } );
    end        
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
    local error_state = cfg.error_conditions[ error_id ];
    prefix = prefix or &quot;&quot;;
    suffix = suffix or &quot;&quot;;

    if error_state == nil then
        error( cfg.message_list['undefined_error'] );
    end
    
    if error_state.category ~= nil and error_state.category ~= &quot;&quot; then
        table.insert( z.error_categories, error_state.category );
    end
    
    local message = error_state.message;
    message = substitute( message, arguments );

    message = wikiescape(message) .. &quot; ([[&quot; .. cfg.message_list['help page link'] .. 
        &quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
        cfg.message_list['help page label'] .. &quot;]])&quot;;

    z.error_ids[ error_id ] = true;
    if (error_id == 'bare_url_missing_title' or error_id == 'trans_missing_title')
            and z.error_ids['citation_missing_title'] then
        return '', false;
    end
    
    message = prefix .. message .. suffix;
    
    if raw == true then
        return message, error_state.hidden;
    end        
        
    return errorcomment( message, error_state.hidden );
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',    
            ['{'] = '&amp;#123;',    
            ['|'] = '&amp;#124;',    
            ['}'] = '&amp;#125;' } );
    return text;
end

-- Formats a wiki style external link
function externallinkid(options)
    local sep = options.separator or &quot;&amp;nbsp;&quot;
    options.suffix = options.suffix or &quot;&quot;
    local url_string = options.id
    if options.encode == true or options.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    return &quot;[[&quot; .. options.link .. &quot;|&quot; .. options.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. 
            options.prefix .. url_string .. options.suffix .. &quot; &quot; .. mw.text.nowiki(options.id) .. &quot;]&quot;
end

-- Formats a wiki style internal link
function internallinkid(options)
    local sep = options.separator or &quot;&amp;nbsp;&quot;
    options.suffix = options.suffix or &quot;&quot;
    return &quot;[[&quot; .. options.link .. &quot;|&quot; .. options.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. 
            options.prefix .. options.id .. options.suffix .. &quot;|&quot; .. mw.text.nowiki(options.id) .. &quot;]]&quot;
end

-- Format an external link with error checking
function externallink( URL, label )
    local error_str = &quot;&quot;;
    if label == nil or label == &quot;&quot; then
        label = URL;
        error_str = seterror( 'bare_url_missing_title', {}, false, &quot; &quot; );
    end
    if not checkurl( URL ) then
        error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
    end

    return &quot;[&quot; .. URL .. ' ' .. safeforurl( label ) .. &quot;]&quot; .. error_str;
end

-- Formats a link to Amazon
function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local handler = cfg.id_handlers['ASIN'];
    return externallinkid({link = handler.link,
        label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
        encode=handler.encode, separator = handler.separator})
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    local handler = cfg.id_handlers['DOI'];
    
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (&quot; .. cfg.message_list['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link = handler.link, label = handler.label,
            prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then      
        cat = seterror( 'bad_doi' );
    end
    return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    local handler = cfg.id_handlers['OL'];
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    else
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode}) .. 
            ' ' .. seterror( 'bad_ol' );
    end
end

--[[
Determines whether an URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
    if url_str:sub(1,2) == &quot;//&quot; then  
        -- Protocol-less URLs
        return true;
    elseif url_str:match( &quot;^[^/]*:&quot; ) ~= nil then   
        -- Look for &quot;:&quot; prefix and assume it is a URI scheme
        return true;
    else
        -- Anything else is an error
        return false;
    end
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
    return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
    isbn_str = cleanisbn( isbn_str ):gsub( &quot;-&quot;, &quot;&quot; );
    local len = isbn_str:len();
 
    if len ~= 10 and len ~= 13 then
        return false;
    end
 
    local temp = 0;
    if len == 10 then
        if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            if v == string.byte( &quot;X&quot; ) then
                temp = temp + 10*( 11 - i );
            else
                temp = temp + tonumber( string.char(v) )*(11-i);
            end
        end
        return temp % 11 == 0;
    else
        if isbn_str:match( &quot;^%d*$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
        end
        return temp % 10 == 0;
    end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
    str = str:gsub( &quot;%[%[[^|%]]*|([^%]]*)%]%]&quot;, &quot;%1&quot; );
    str = str:gsub( &quot;%[%[([^%]]*)%]%]&quot;, &quot;%1&quot; );    
    return str
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    if str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then 
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        
        -- Remove newlines as they break italics.
        return str:gsub( '\n', ' ' );
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    -- Is the input a simple number?
    local num = tonumber( str ); 
    if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
        return str;
    else
        -- Use formatDate to interpret more complicated formats
        local lang = mw.getContentLanguage();
        local good, result;
        good, result = pcall( lang.formatDate, lang, 'Y', str )
        if good then 
            return result;
        else
            -- Can't make sense of this input, return blank.
            return &quot;&quot;;
        end
    end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            if ( maximum ~= nil and i == maximum + 1 ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil and first ~= '') then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert(text, one)
        end
    end
    local count = #text;
    if count &gt; 1 and lastauthoramp ~= nil and lastauthoramp ~= &quot;&quot; and not etal then
        text[count-1] = text[count-1] .. &quot; &amp; &quot; .. text[count];
        text[count] = nil;
    end    
    local result = table.concat(text, sep) -- construct list
    if etal then 
        local etal_text = cfg.message_list['et al'];
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result = 
        '&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
    end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
    return &quot;CITEREF&quot; .. mw.uri.anchorEncode( table.concat( options ) );
end

-- Gets name list from the input arguments
function extractnames(args, list_name)
    local names = {};
    local i = 1;
    local last;
    
    while true do
        last = selectone( args, cfg.argument_map[list_name .. '-Last'], 'redundant_parameters', i );
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            names[i] = {
                last = last,
                first = selectone( args, cfg.argument_map[list_name .. '-First'], 'redundant_parameters', i ),
                link = selectone( args, cfg.argument_map[list_name .. '-Link'], 'redundant_parameters', i ),
                mask = selectone( args, cfg.argument_map[list_name .. '-Mask'], 'redundant_parameters', i )
            }                
        else
            break;
        end
        i = i + 1;
    end
    return names;
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
    local id_list = {};
    
    for k, v in pairs( cfg.id_handlers ) do    
        id_list[k] = selectone( args, v.parameters, 'redundant_parameters' );
    end

    return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
    local handler;
    local new_list = {};
    
    for k, v in pairs( id_list ) do
        handler = {};
        
        --Becasue cfg is read-only we have to copy it the hard way.
        for k2, v2 in pairs( cfg.id_handlers[k] ) do
            handler[k2] = v2;
        end
        handler['id'] = v;
        
        if handler.mode == 'external' then        
            table.insert( new_list, {handler.label, externallinkid( handler ) } );
        elseif handler.mode == 'internal' then
            table.insert( new_list, {handler.label, internallinkid( handler ) } );
        elseif handler.mode == 'manual' then
            if k == 'DOI' then
                table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
            elseif k == 'ASIN' then
                table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
            elseif k == 'OL' then
                table.insert( new_list, {handler.label, openlibrary( v ) } );
            elseif k == 'ISBN' then
                local ISBN = internallinkid( handler );
                if not checkisbn( v ) and ( options.IgnoreISBN == nil or options.IgnoreISBN == &quot;&quot; ) then 
                    ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
                end
                table.insert( new_list, {handler.label, ISBN } );                
            else
                error( cfg.message_list['unknown_manual_ID'] );
            end            
        else
            error( cfg.message_list['unknown_ID_mode'] );
        end
    end

    function comp( a, b )
        return a[1] &lt; b[1];
    end

    table.sort( new_list, comp );
    for k, v in ipairs( new_list ) do
        new_list[k] = v[2];
    end
    
    return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
    local value = nil;
    local selected = '';
    local error_list = {};
    if index ~= nil then index = tostring(index); end
    
    -- Handle special case of &quot;#&quot; replaced by empty string
    if index == '1' then
        for _, v in ipairs( possible ) do
            v = v:gsub( &quot;#&quot;, &quot;&quot; );
            if args[v] ~= nil then
                if value ~= nil and selected ~= v then
                    table.insert( error_list, v );
                else
                    value = args[v];
                    selected = v;
                end
            end
        end        
    end

    for _, v in ipairs( possible ) do
        if index ~= nil then
            v = v:gsub( &quot;#&quot;, index );
        end
        if args[v] ~= nil then
            if value ~= nil then
                table.insert( error_list, v );
            else
                value = args[v];
                selected = v;
            end
        end
    end

    if #error_list &gt; 0 then
        local error_str = &quot;&quot;;
        for _, k in ipairs( error_list ) do
            if error_str ~= &quot;&quot; then error_str = error_str .. &quot;, &quot; end
            error_str = error_str .. &quot;&lt;code&gt;|&quot; .. k .. &quot;=&lt;/code&gt;&quot;;
        end
        if #error_list &gt; 1 then
            error_str = error_str .. &quot;, and &quot;;
        else
            error_str = error_str .. &quot; and &quot;;
        end
        error_str = error_str .. &quot;&lt;code&gt;|&quot; .. selected .. &quot;=&lt;/code&gt;&quot;;
        table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
    end
            
    return value, selected;
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    --[[ 
    Load Input Parameters
    The argment_wrapper facillitates the mapping of multiple
    aliases to single internal variable.
    ]]
    local A = argument_wrapper( args );

    local i 
    local PPrefix = A['PPrefix']
    local PPPrefix = A['PPPrefix']
    if ( nil ~= A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = A['Authors'];
    local a = extractnames( args, 'AuthorList' );

    local Coauthors = A['Coauthors'];
    local Others = A['Others'];
    local Editors = A['Editors'];
    local e = extractnames( args, 'EditorList' );

    local Year = A['Year'];
    local PublicationDate = A['PublicationDate'];
    local OrigYear = A['OrigYear'];
    local Date = A['Date'];
    local LayDate = A['LayDate'];
    ------------------------------------------------- Get title data
    local Title = A['Title'];
    local BookTitle = A['BookTitle'];
    local Conference = A['Conference'];
    local TransTitle = A['TransTitle'];
    local TitleNote = A['TitleNote'];
    local TitleLink = A['TitleLink'];
    local Chapter = A['Chapter'];
    local ChapterLink = A['ChapterLink'];
    local TransChapter = A['TransChapter'];
    local TitleType = A['TitleType'];
    local ArchiveURL = A['ArchiveURL'];
    local URL = A['URL'];
    local ChapterURL = A['ChapterURL'];
    local ConferenceURL = A['ConferenceURL'];
    local Periodical = A['Periodical'];
            
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( Chapter == nil or Chapter == '' ) then    
            if (Title == nil or Title == &quot;&quot;) then
                Title = Periodical;
                Periodical = nil;
            else
                Chapter = Title
                TransChapter = TransTitle
                Title = nil 
                TransTitle = nil
            end
        end
    end

    local Series = A['Series'];
    local Volume = A['Volume'];
    local Issue = A['Issue'];
    local Position = nil
    local Page, Pages, At, page_type;
    
    Page = A['Page'];
    Pages = hyphentodash( A['Pages'] );
    At = A['At'];
    if Page ~= nil then
        if Pages ~= nil or At ~= nil then
            Page = Page .. &quot; &quot; .. seterror('extra_pages');
            Pages = nil;
            At = nil;
        end
    elseif Pages ~= nil then
        if At ~= nil then
            Pages = Pages .. &quot; &quot; .. seterror('extra_pages');
            At = nil;
        end
    end    
                
    local Edition = A['Edition'];
    local PublicationPlace = A['PublicationPlace']
    local Place = A['Place'];
    if PublicationPlace == nil and Place ~= nil then 
        PublicationPlace = Place;
    end
    if PublicationPlace == Place then Place = nil end
    
    local PublisherName = A['PublisherName'];
    local SubscriptionRequired = A['SubscriptionRequired'];
    local Via = A['Via'];
    local AccessDate = A['AccessDate'];
    local ArchiveDate = A['ArchiveDate'];
    local Agency = A['Agency'];
    local DeadURL = A['DeadURL']
    local Language = A['Language'];
    local Format = A['Format']
    local Ref = A['Ref']

    local DoiBroken = A['DoiBroken']
    local ID = A['ID'];
    local ASINTLD = A['ASINTLD'];
    local IgnoreISBN = A['IgnoreISBN']

    local ID_list = extractids( args );
    
    local Quote = A['Quote'];
    local PostScript = A['PostScript']
    local LaySummary = A['LaySummary']
    local LaySource = A['LaySource'];
    local Transcript = A['Transcript'];
    local TranscriptURL = A['TranscriptURL'];
    local sepc = A['Separator']
    local LastAuthorAmp = A['LastAuthorAmp']
    local no_tracking_cats = A['NoTracking'];

    if ( config.CitationClass == &quot;journal&quot; ) then        
        if (URL == nil or URL == &quot;&quot;) then
            if (ID_list['PMC'] ~= nil) then 
                local Embargo = A['Embargo'];
                if Embargo ~= nil then
                    local lang = mw.getContentLanguage();
                    local good1, result1, good2, result2;
                    good1, result1 = pcall( lang.formatDate, lang, 'U', Embargo );
                    good2, result2 = pcall( lang.formatDate, lang, 'U' );

                    if good1 and good2 and tonumber( result1 ) &lt; tonumber( result2 ) then 
                        URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];
                    end
                else
                    URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];           
                end
            end
        end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = A['AirDate']
        local SeriesLink = A['SeriesLink']
        local Season = A['Season']
        local SeriesNumber = A['SeriesNumber']
        local Network = A['Network']
        local Station = A['Station']
        local s = {}
        if Issue ~= nil then table.insert(s, cfg.message_list[&quot;episode&quot;] .. &quot; &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, cfg.message_list[&quot;season&quot;] .. &quot; &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, cfg.message_list[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = (A[&quot;SeriesSeparator&quot;] or A[&quot;Separator&quot;]) .. &quot; &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows 
    -- automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
        if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    
    for k, v in pairs( ID_list ) do
        if k == 'ISBN' then
            v = cleanisbn( v );
        end
        if string.sub( cfg.id_handlers[k].COinS or &quot;info&quot;, 1, 4 ) ~= 'info' then
            OCinSdata[ cfg.id_handlers[k].COinS ] = v;
        end
    end
    
    OCinSdata.rft_id = URL or ChapterURL

    local last, first;
    local OCinSauthors = {};
    for k, v in ipairs( a ) do
        last = v.last;
        first = v.first;
        if k == 1 then
            if last ~= nil then
                OCinSdata[&quot;rft.aulast&quot;] = last;
            end
            if first ~= nil then 
                OCinSdata[&quot;rft.aufirst&quot;] = first;
            end
        end
        if last ~= nil and first ~= nil then
            table.insert( OCinSauthors, last .. &quot;, &quot; .. first );
    	elseif last ~= nil then
            table.insert( OCinSauthors, last );
        end
    end

    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    for k, v in pairs( ID_list ) do
        if string.sub( cfg.id_handlers[k].COinS or &quot;&quot;, 1, 4 ) == 'info' then
            OCinSids[ cfg.id_handlers[k].COinS ] = v;
        end
    end

    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode( removewikilink(value) );
    end
    for _, value in ipairs(OCinSauthors) do
        OCinStitle = OCinStitle .. &quot;&amp;rft.au=&quot; .. mw.uri.encode( removewikilink(value) );
    end
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. removewikilink(value) );
    end
    
    local this_page = mw.title.getCurrentTitle();
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/&quot; .. mw.site.server:match( &quot;[^/]*$&quot; ) .. &quot;:&quot;
       .. this_page.prefixedText  -- end COinS data by page's non-encoded pagename

    if (Periodical ~= nil and Periodical ~= &quot;&quot;) and
        (Chapter == nil or Chapter == '') and
        (Title ~= nil and Title ~= &quot;&quot;) then
            Chapter = Title
            ChapterLink = TitleLink
            TransChapter = TransTitle
            Title = nil
            TitleLink = nil
            TransTitle = nil            
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local Maximum = tonumber( A['DisplayAuthors'] );
        
        -- Preserve old-style implicit et al.
        if Maximum == nil and #a == 9 then 
            Maximum = 8;
            table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
        elseif Maximum == nil then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = A[&quot;AuthorSeparator&quot;] .. &quot; &quot;,
            namesep = (A[&quot;AuthorNameSeparator&quot;] or A[&quot;NameSeparator&quot;]) .. &quot; &quot;,
            format = A[&quot;AuthorFormat&quot;],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        }
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if Coauthors ~= nil and Coauthors ~= &quot;&quot; then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
                
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local Maximum = tonumber( A['DisplayEditors'] );

        -- Preserve old-style implicit et al.
        if Maximum == nil and #e == 4 then 
            Maximum = 3;
            table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
        elseif Maximum == nil then
            Maximum = #e + 1;
        end

        local control = { 
            sep = A[&quot;EditorSeparator&quot;] .. &quot; &quot;,
            namesep = (A[&quot;EditorNameSeparator&quot;] or A[&quot;NameSeparator&quot;]) .. &quot; &quot;,
            format = A['EditorFormat'],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
            }

        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = A['Month']
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = A['Day']
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date
    
    if ( URL == nil or URL == '' ) and
            ( ChapterURL == nil or ChapterURL == '' ) and
            ( ArchiveURL == nil or ArchiveURL == '' ) and                
            ( ConferenceURL == nil or ConferenceURL == '' ) and                
            ( TranscriptURL == nil or TranscriptURL == '' ) then

        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
        end

        -- Test if accessdate is given without giving a URL
        if ( AccessDate ~= nil and AccessDate ~= '' ) then
            table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
            AccessDate = nil;
        end      
    
        -- Test if format is given without giving a URL
        if ( Format ~= nil and Format ~= '' ) then
            Format = Format .. seterror( 'format_missing_url' );
        end        
    end    

    -- Test if citation has no title
    if ( Chapter == nil or Chapter == &quot;&quot; ) and 
            ( Title == nil or Title == &quot;&quot; ) and
            ( Periodical == nil or Periodical == &quot;&quot; ) and
            ( Conference == nil or Conference == &quot;&quot; ) and 
            ( TransTitle == nil or TransTitle == &quot;&quot; ) and
            ( TransChapter == nil or TransChapter == &quot;&quot; ) then
        table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
    end

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
        end
    end

    if ( TransTitle and &quot;&quot; &lt; TransTitle ) then TransTitle = &quot; &quot; .. substitute( cfg.message_list['trans-title'], { TransTitle } ) else TransTitle = &quot;&quot; end
    if ( TransChapter and &quot;&quot; &lt; TransChapter ) then TransChapter = &quot; &quot; .. substitute( cfg.message_list['trans-title'], { TransChapter } ) else TransChapter = &quot;&quot; end
        
    -- Format chapter / article title
    if ( Chapter ~= nil and Chapter ~= &quot;&quot; ) then
        if ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) and (Title ~= nil and Title ~= &quot;&quot; )
        then
            Chapter = substitute( cfg.message_list['italic-title'], { (safeforitalics(Chapter)) } );
        else
            Chapter = substitute( cfg.message_list['quoted-title'], { Chapter } );
        end
    else
        Chapter = &quot;&quot;;
    end
    
    local TransError = &quot;&quot;
    if TransChapter ~= &quot;&quot; and Chapter == &quot;&quot; then
        TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
    end
    Chapter = Chapter .. TransChapter
    if Chapter ~= &quot;&quot; then
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then                
                Chapter = externallink( ChapterURL, Chapter ) .. TransError;
                if URL == nil or URL == &quot;&quot; then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = externallink( URL, Chapter ) .. TransError .. Format;
                URL = nil
                Format = &quot;&quot;
            else
                Chapter = Chapter .. TransError;
            end            
        elseif ChapterURL ~= nil and ChapterURL ~= &quot;&quot; then
            Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL ) .. 
                TransError;
        else
            Chapter = Chapter .. TransError;
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    elseif ChapterURL ~= nil and ChapterURL ~= &quot;&quot; then
        Chapter = &quot; &quot; .. externallink( ChapterURL ) .. sepc .. &quot; &quot;;
    end        
    
    -- Format main title.
    if ( Title and &quot;&quot; &lt; Title ) then
        if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; end
        if ( Periodical and &quot;&quot; &lt; Periodical ) then
            Title = substitute( cfg.message_list['quoted-title'], { Title } );
        elseif ( config.CitationClass == &quot;web&quot;
                or config.CitationClass == &quot;news&quot; 
                or config.CitationClass == &quot;pressrelease&quot; ) and 
                Chapter == &quot;&quot; then
            Title = substitute( cfg.message_list['quoted-title'], { Title } );
        else
            Title = substitute( cfg.message_list['italic-title'], { (safeforitalics(Title)) } );
        end
    else
        Title = &quot;&quot;;
    end    
    
    local TransError = &quot;&quot;;
    if TransTitle ~= &quot;&quot; and Title == &quot;&quot; then
        TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
    end
    Title = Title .. TransTitle
    if Title ~= &quot;&quot; then
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = externallink( URL, Title ) .. TransError .. Format       
            URL = nil
            Format = ''
        else
            Title = Title .. TransError;
        end
    end

    if ( Place ~= nil and Place ~= &quot;&quot; ) then
        if sepc == '.' then
            Place = &quot; &quot; .. substitute( cfg.message_list['written'], {Place} ) .. sepc .. &quot; &quot;;
        else
            Place = &quot; &quot; .. substitute( cfg.message_list['written']:lower(), {Place} ) .. sepc .. &quot; &quot;;
        end            
    else
        Place = &quot;&quot;;
    end
    
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = externallink( ConferenceURL, Conference );
        end
        Conference = &quot; &quot; .. Conference
    elseif ConferenceURL ~= nil and ConferenceURL ~= &quot;&quot; then
        Conference = &quot; &quot; .. externallink( ConferenceURL );
    else
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = A['Minutes'];
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.message_list['minutes'];
        else
            local Time = A['Time'];
            if ( nil ~= Time ) then
                local TimeCaption = A['TimeCaption']
                if TimeCaption == nil then
                    TimeCaption = cfg.message_list['event'];
                    if sepc ~= '.' then
                        TimeCaption = TimeCaption:lower();
                    end
                end                
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; &quot; .. substitute( cfg.message_list['language'] , {Language} ) else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; &quot; .. substitute( cfg.message_list['edition'] , {Edition} ) else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &quot; .. substitute( cfg.message_list['via'], {Via} ) else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; &quot; .. cfg.message_list['retrieved']
         if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
             .. substitute( retrv_text, {AccessDate} ) .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.message_list['subscription'];
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end

    ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN} );

    if ( URL ~= nil and URL ~=&quot;&quot;) then
        URL = &quot; &quot; .. externallink( URL, URL );
        local error_text = seterror( 'bare_url_missing_title' );
        if config.CitationClass == &quot;web&quot; then
            URL = URL .. &quot; &quot; .. seterror( 'cite_web_title' );
        else
            URL = URL .. error_text;
        end       
    else
        URL = &quot;&quot;
    end

    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; &quot; .. substitute( cfg.message_list['quoted-text'], { Quote } ); 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate == nil or ArchiveDate ==&quot;&quot; ) then
            ArchiveDate = seterror('archive_missing_date');
        end
        if ( &quot;no&quot; == DeadURL ) then
            local arch_text = cfg.message_list['archived'];
            if (sepc ~= &quot;.&quot;) then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( cfg.message_list['archived-not-dead'],
                { externallink( ArchiveURL, arch_text ), ArchiveDate } );
            if OriginalURL == nil or OriginalUrl == '' then
                Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url');                               
            end
        else
            if OriginalURL ~= nil and OriginalURL ~= '' then
                local arch_text = cfg.message_list['archived-dead'];
                if (sepc ~= &quot;.&quot;) then arch_text = arch_text:lower() end
                Archived = sepc .. &quot; &quot; .. substitute( arch_text,
                    { externallink( OriginalURL, cfg.message_list['original'] ), ArchiveDate } );
            else
                local arch_text = cfg.message_list['archived-missing'];
                if (sepc ~= &quot;.&quot;) then arch_text = arch_text:lower() end
                Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
                    { seterror('archive_missing_url'), ArchiveDate } );
            end                
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        if sepc == '.' then
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; &quot; .. cfg.message_list['lay summary'] .. &quot;]&quot; .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; [&quot; .. LaySummary .. &quot; &quot; .. cfg.message_list['lay summary']:lower() .. &quot;]&quot; .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = externallink( TranscriptURL, Transcript ) end
    elseif TranscriptURL ~= nil and TranscriptURL ~= &quot;&quot; then
        Transcript = externallink( TranscriptURL )     
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; and
         config.CitationClass ~= &quot;pressrelease&quot; ) then
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            if Publisher ~= '' then
                Publisher = Publisher .. &quot;, &quot; .. substitute( cfg.message_list['published'], {PublicationDate} );
            else
                Publisher = PublicationDate;
            end
        end
        if Publisher ~= &quot;&quot; then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (&quot; .. substitute( cfg.message_list['published'], {PublicationDate} ) .. &quot;)&quot;
        else 
            PublicationDate = &quot;&quot;
        end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot; ) or ( TitleNote and TitleNote ~= &quot;&quot; ) then 
            Periodical = sepc .. &quot; &quot; .. substitute( cfg.message_list['italic-title'], { (safeforitalics(Periodical)) } ) 
        else 
            Periodical = substitute( cfg.message_list['italic-title'], { (safeforitalics(Periodical)) } ) 
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( ( (config.CitationClass == &quot;journal&quot;) or (config.CitationClass == &quot;citation&quot;) )  and
         Periodical ~= &quot;&quot; ) then
        if (Others ~= &quot;&quot;) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
            Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
            Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
    end
    
    if #ID_list &gt; 0 then
        ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
    else
        ID_list = ID;
    end    
    local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );

    local text
    local pgtext = Page .. Pages .. At
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. A['AuthorSeparator'] .. &quot; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, &quot; .. cfg.message_list['editor'];
            else
                Editors = Editors .. &quot;, &quot; .. cfg.message_list['editors'];
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (&quot; .. cfg.message_list['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (&quot; .. cfg.message_list['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end -- endif &quot;&quot;~=Date
        if ( config.CitationClass==&quot;journal&quot; and Periodical ) then
          text = safejoin( {Chapter, Place, tcommon}, sepc );
          text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
          text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
          text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if PostScript ~= '' and PostScript ~= nil and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local options = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do 
                    names[i] = v.last 
                    if i == 4 then break end
                end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do 
                    names[i] = v.last 
                    if i == 4 then break end                
                end
            end
            names[ #names + 1 ] = Year;
            id = anchorid(names)
        end
        options.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = {};
        text = seterror('empty_citation');
        z.message_tail = {};
    end
    
    if options.id ~= nil then 
        text = '&lt;span id=&quot;' .. wikiescape(options.id) ..'&quot; class=&quot;' .. wikiescape(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    else
        text = '&lt;span class=&quot;' .. wikiescape(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    end        

    local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = '&lt;span title=&quot;' .. wikiescape(OCinStitle) .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        text = text .. &quot; &quot;;
        for i,v in ipairs( z.message_tail ) do
            if v[1] ~= nil and v[1] ~= &quot;&quot; then 
                if i == #z.message_tail then
                    text = text .. errorcomment( v[1], v[2] );
                else
                    text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
                end
            end
        end
    end
    
    if no_tracking_cats == nil then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    local suggestions = {};
    local error_text, error_state;
    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            if not validate( k ) then            
                error_text = &quot;&quot;;
                if type( k ) ~= 'string' then
                    -- Exclude empty numbered parameters
                    if v:match(&quot;%S+&quot;) ~= nil then
                        error_text, error_state = seterror( 'text_ignored', {v}, true );
                    end
                elseif validate( k:lower() ) then 
                    error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
                else
                    if #suggestions == 0 then
                        suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
                    end
                    if suggestions[ k:lower() ] ~= nil then
                        error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
                    else
                        error_text, error_state = seterror( 'parameter_ignored', {k}, true );
                    end
                end                  
                if error_text ~= '' then
                    table.insert( z.message_tail, {error_text, error_state} );
                end                
            end            
            args[k] = v;
        elseif k == 'postscript' then
            args[k] = v;
        end        
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        if args[k] == nil and (v ~= '' or k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z</text>
      <sha1>5twpyi1nudcqh6vh29s0ebgcn3enr9n</sha1>
    </revision>
    <revision>
      <id>4653</id>
      <parentid>4652</parentid>
      <timestamp>2013-04-19T23:07:02Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>sync with sandbox, merge cite_web_title to bare_url, better style control on translations, category suppression by config, tweak display authors</comment>
      <origin>4653</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="59479" sha1="1pjj5k43ynuy2az98d1uxyws2wj3wz9" xml:space="preserve">local z = {
    error_categories = {};
    error_ids = {};
    message_tail = {};
}

local SEEN = {};
local DATA = {};

-- Include translation message hooks, ID and error handling configuration settings.
local cfg = require( 'Module:Citation/CS1/Configuration' );
 
-- Contains a list of all recognized parameters
local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );

-- Populates numbered arguments in a message string using
-- an argument table.
function substitute( message, arguments )
    if arguments == nil then 
        return message;
    end
    
    message = message .. &quot; &quot;;
    for k, v in ipairs( arguments ) do
        v = v:gsub( &quot;%%&quot;, &quot;%%%%&quot; );
        message = message:gsub( &quot;$&quot; .. k .. &quot;(%D)&quot;, v .. &quot;%1&quot; );
    end     
    message = message:sub(1,-2);
    return message;
end

-- Wraps a string using a message_list configuration taking one argument
function wrap( message_key, str )
    if str == nil or str == &quot;&quot; then
        return &quot;&quot;;
    end
    if message_key == 'italic-title' or 
            message_key == 'trans-italic-title' then
        str = safeforitalics( str );
    end
    return substitute( cfg.message_list[message_key], {str} );
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
    DATA = args;
    local tbl = {};
    
    local mt = {
        __index = function ( tbl, k )            
            if SEEN[k] then
                return nil;
            end
            
            local list = cfg.argument_map[k];                    

            if list == nil then
                error( cfg.message_list['unknown_argument_map'] );
            elseif type( list ) == 'string' then
                v = DATA[list];
            else                    
                v = selectone( DATA, cfg.argument_map[k],
                    'redundant_parameters' );
            end
            if v == nil then
                v = cfg.default_values[k];
            end
            SEEN[k] = true;
            tbl = rawset( tbl, k, v );
            
            return v;
        end,
    }
    return setmetatable( tbl, mt );
end

-- Checks that parameter name is valid using the whitelist
function validate( name )
    name = tostring( name );
    
    -- Normal arguments
    if whitelist.basic_arguments[ name ] then
        return true;
    end
    
    -- Arguments with numbers in them
    name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );
    if whitelist.numbered_arguments[ name ] then
        return true;
    end
    
    -- Not found, argument not supported.
    return false
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
    if hidden then 
        return wrap( 'hidden-error', content );
    else
        return wrap( 'visible-error', content );
    end        
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
    local error_state = cfg.error_conditions[ error_id ];
    prefix = prefix or &quot;&quot;;
    suffix = suffix or &quot;&quot;;

    if error_state == nil then
        error( cfg.message_list['undefined_error'] );
    end
    
    if error_state.category ~= nil and error_state.category ~= &quot;&quot; then
        table.insert( z.error_categories, error_state.category );
    end
    
    local message = error_state.message;
    message = substitute( message, arguments );

    message = wikiescape(message) .. &quot; ([[&quot; .. cfg.message_list['help page link'] .. 
        &quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
        cfg.message_list['help page label'] .. &quot;]])&quot;;

    z.error_ids[ error_id ] = true;
    if (error_id == 'bare_url_missing_title' or error_id == 'trans_missing_title')
            and z.error_ids['citation_missing_title'] then
        return '', false;
    end
    
    message = prefix .. message .. suffix;
    
    if raw == true then
        return message, error_state.hidden;
    end        
        
    return errorcomment( message, error_state.hidden );
end

-- This returns a string with HTML character entities for wikitext markup characters.
function wikiescape(text)
    text = text:gsub( '[&amp;\'%[%]{|}]', {    
            ['&amp;'] = '&amp;#38;',    
            [&quot;'&quot;] = '&amp;#39;',    
            ['['] = '&amp;#91;',    
            [']'] = '&amp;#93;',    
            ['{'] = '&amp;#123;',    
            ['|'] = '&amp;#124;',    
            ['}'] = '&amp;#125;' } );
    return text;
end

-- Formats a wiki style external link
function externallinkid(options)
    local sep = options.separator or &quot;&amp;nbsp;&quot;
    options.suffix = options.suffix or &quot;&quot;
    local url_string = options.id
    if options.encode == true or options.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    
    return &quot;[[&quot; .. options.link .. &quot;|&quot; .. options.label .. &quot;]]&quot; .. sep .. &quot;[&quot; .. 
            options.prefix .. url_string .. options.suffix .. &quot; &quot; .. mw.text.nowiki(options.id) .. &quot;]&quot;
end

-- Formats a wiki style internal link
function internallinkid(options)
    local sep = options.separator or &quot;&amp;nbsp;&quot;
    options.suffix = options.suffix or &quot;&quot;
    return &quot;[[&quot; .. options.link .. &quot;|&quot; .. options.label .. &quot;]]&quot; .. sep .. &quot;[[&quot; .. 
            options.prefix .. options.id .. options.suffix .. &quot;|&quot; .. mw.text.nowiki(options.id) .. &quot;]]&quot;
end

-- Format an external link with error checking
function externallink( URL, label )
    local error_str = &quot;&quot;;
    if label == nil or label == &quot;&quot; then
        label = URL;
        error_str = seterror( 'bare_url_missing_title', {}, false, &quot; &quot; );
    end
    if not checkurl( URL ) then
        error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
    end

    return &quot;[&quot; .. URL .. ' ' .. safeforurl( label ) .. &quot;]&quot; .. error_str;
end

-- Formats a link to Amazon
function amazon(id, domain)
    if ( nil == domain ) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local handler = cfg.id_handlers['ASIN'];
    return externallinkid({link = handler.link,
        label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
        encode=handler.encode, separator = handler.separator})
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    local handler = cfg.id_handlers['DOI'];
    
    local text;
    if ( inactive ~= nil ) then 
        text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (&quot; .. cfg.message_list['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link = handler.link, label = handler.label,
            prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then      
        cat = seterror( 'bad_doi' );
    end
    return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    local handler = cfg.id_handlers['OL'];
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    else
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode}) .. 
            ' ' .. seterror( 'bad_ol' );
    end
end

--[[
Determines whether an URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
    if url_str:sub(1,2) == &quot;//&quot; then  
        -- Protocol-less URLs
        return true;
    elseif url_str:match( &quot;^[^/]*:&quot; ) ~= nil then   
        -- Look for &quot;:&quot; prefix and assume it is a URI scheme
        return true;
    else
        -- Anything else is an error
        return false;
    end
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
    return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
    isbn_str = cleanisbn( isbn_str ):gsub( &quot;-&quot;, &quot;&quot; );
    local len = isbn_str:len();
 
    if len ~= 10 and len ~= 13 then
        return false;
    end
 
    local temp = 0;
    if len == 10 then
        if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            if v == string.byte( &quot;X&quot; ) then
                temp = temp + 10*( 11 - i );
            else
                temp = temp + tonumber( string.char(v) )*(11-i);
            end
        end
        return temp % 11 == 0;
    else
        if isbn_str:match( &quot;^%d*$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
        end
        return temp % 10 == 0;
    end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
    str = str:gsub( &quot;%[%[[^|%]]*|([^%]]*)%]%]&quot;, &quot;%1&quot; );
    str = str:gsub( &quot;%[%[([^%]]*)%]%]&quot;, &quot;%1&quot; );    
    return str
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',	
        [']'] = '&amp;#93;',	
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if str == nil then
        return nil;
    end    
    if str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then 
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if str == nil or str == '' then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        
        -- Remove newlines as they break italics.
        return str:gsub( '\n', ' ' );
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    -- Is the input a simple number?
    local num = tonumber( str ); 
    if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.abs(num) then
        return str;
    else
        -- Use formatDate to interpret more complicated formats
        local lang = mw.getContentLanguage();
        local good, result;
        good, result = pcall( lang.formatDate, lang, 'Y', str )
        if good then 
            return result;
        else
            -- Can't make sense of this input, return blank.
            return &quot;&quot;;
        end
    end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    if maximum &lt; 1 then return &quot;&quot;, 0; end
    for i,person in ipairs(people) do
        if (person.last ~= nil or person.last ~= &quot;&quot;) then
            local mask = person.mask
            local one
            local sep_one = sep;
            if ( maximum ~= nil and i &gt; maximum ) then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask;
                    sep_one = &quot; &quot;;
                end
            else
                one = person.last
                local first = person.first
                if (first ~= nil and first ~= '') then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if (person.link ~= nil and person.link ~= &quot;&quot;) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert( text, one )
            table.insert( text, sep_one )
        end
    end

    local count = #text / 2;
    if count &gt; 0 then 
        if count &gt; 1 and lastauthoramp ~= nil and lastauthoramp ~= &quot;&quot; and not etal then
            text[#text-2] = &quot; &amp; &quot;;
        end
        text[#text] = nil; 
    end
    
    local result = table.concat(text) -- construct list
    if etal then 
        local etal_text = cfg.message_list['et al'];
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result = 
        '&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
    end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
    return &quot;CITEREF&quot; .. mw.uri.anchorEncode( table.concat( options ) );
end

-- Gets name list from the input arguments
function extractnames(args, list_name)
    local names = {};
    local i = 1;
    local last;
    
    while true do
        last = selectone( args, cfg.argument_map[list_name .. '-Last'], 'redundant_parameters', i );
        if ( last and &quot;&quot; &lt; last ) then -- just in case someone passed in an empty parameter
            names[i] = {
                last = last,
                first = selectone( args, cfg.argument_map[list_name .. '-First'], 'redundant_parameters', i ),
                link = selectone( args, cfg.argument_map[list_name .. '-Link'], 'redundant_parameters', i ),
                mask = selectone( args, cfg.argument_map[list_name .. '-Mask'], 'redundant_parameters', i )
            }                
        else
            break;
        end
        i = i + 1;
    end
    return names;
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
    local id_list = {};
    
    for k, v in pairs( cfg.id_handlers ) do    
        id_list[k] = selectone( args, v.parameters, 'redundant_parameters' );
    end

    return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
    local handler;
    local new_list = {};
    
    for k, v in pairs( id_list ) do
        handler = {};
        
        --Becasue cfg is read-only we have to copy it the hard way.
        for k2, v2 in pairs( cfg.id_handlers[k] ) do
            handler[k2] = v2;
        end
        handler['id'] = v;
        
        if handler.mode == 'external' then        
            table.insert( new_list, {handler.label, externallinkid( handler ) } );
        elseif handler.mode == 'internal' then
            table.insert( new_list, {handler.label, internallinkid( handler ) } );
        elseif handler.mode == 'manual' then
            if k == 'DOI' then
                table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
            elseif k == 'ASIN' then
                table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
            elseif k == 'OL' then
                table.insert( new_list, {handler.label, openlibrary( v ) } );
            elseif k == 'ISBN' then
                local ISBN = internallinkid( handler );
                if not checkisbn( v ) and ( options.IgnoreISBN == nil or options.IgnoreISBN == &quot;&quot; ) then 
                    ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
                end
                table.insert( new_list, {handler.label, ISBN } );                
            else
                error( cfg.message_list['unknown_manual_ID'] );
            end            
        else
            error( cfg.message_list['unknown_ID_mode'] );
        end
    end

    function comp( a, b )
        return a[1] &lt; b[1];
    end

    table.sort( new_list, comp );
    for k, v in ipairs( new_list ) do
        new_list[k] = v[2];
    end
    
    return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
    local value = nil;
    local selected = '';
    local error_list = {};
    if index ~= nil then index = tostring(index); end
    
    -- Handle special case of &quot;#&quot; replaced by empty string
    if index == '1' then
        for _, v in ipairs( possible ) do
            v = v:gsub( &quot;#&quot;, &quot;&quot; );
            if args[v] ~= nil then
                if value ~= nil and selected ~= v then
                    table.insert( error_list, v );
                else
                    value = args[v];
                    selected = v;
                end
            end
        end        
    end

    for _, v in ipairs( possible ) do
        if index ~= nil then
            v = v:gsub( &quot;#&quot;, index );
        end
        if args[v] ~= nil then
            if value ~= nil then
                table.insert( error_list, v );
            else
                value = args[v];
                selected = v;
            end
        end
    end

    if #error_list &gt; 0 then
        local error_str = &quot;&quot;;
        for _, k in ipairs( error_list ) do
            if error_str ~= &quot;&quot; then error_str = error_str .. &quot;, &quot; end
            error_str = error_str .. &quot;&lt;code&gt;|&quot; .. k .. &quot;=&lt;/code&gt;&quot;;
        end
        if #error_list &gt; 1 then
            error_str = error_str .. &quot;, and &quot;;
        else
            error_str = error_str .. &quot; and &quot;;
        end
        error_str = error_str .. &quot;&lt;code&gt;|&quot; .. selected .. &quot;=&lt;/code&gt;&quot;;
        table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
    end
            
    return value, selected;
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    --[[ 
    Load Input Parameters
    The argment_wrapper facillitates the mapping of multiple
    aliases to single internal variable.
    ]]
    local A = argument_wrapper( args );

    local i 
    local PPrefix = A['PPrefix']
    local PPPrefix = A['PPPrefix']
    if ( nil ~= A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = A['Authors'];
    local a = extractnames( args, 'AuthorList' );

    local Coauthors = A['Coauthors'];
    local Others = A['Others'];
    local Editors = A['Editors'];
    local e = extractnames( args, 'EditorList' );

    local Year = A['Year'];
    local PublicationDate = A['PublicationDate'];
    local OrigYear = A['OrigYear'];
    local Date = A['Date'];
    local LayDate = A['LayDate'];
    ------------------------------------------------- Get title data
    local Title = A['Title'];
    local BookTitle = A['BookTitle'];
    local Conference = A['Conference'];
    local TransTitle = A['TransTitle'];
    local TitleNote = A['TitleNote'];
    local TitleLink = A['TitleLink'];
    local Chapter = A['Chapter'];
    local ChapterLink = A['ChapterLink'];
    local TransChapter = A['TransChapter'];
    local TitleType = A['TitleType'];
    local ArchiveURL = A['ArchiveURL'];
    local URL = A['URL'];
    local ChapterURL = A['ChapterURL'];
    local ConferenceURL = A['ConferenceURL'];
    local Periodical = A['Periodical'];
            
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if ( Chapter == nil or Chapter == '' ) then    
            if (Title == nil or Title == &quot;&quot;) then
                Title = Periodical;
                Periodical = nil;
            else
                Chapter = Title
                TransChapter = TransTitle
                Title = nil 
                TransTitle = nil
            end
        end
    end

    local Series = A['Series'];
    local Volume = A['Volume'];
    local Issue = A['Issue'];
    local Position = nil
    local Page, Pages, At, page_type;
    
    Page = A['Page'];
    Pages = hyphentodash( A['Pages'] );
    At = A['At'];
    if Page ~= nil then
        if Pages ~= nil or At ~= nil then
            Page = Page .. &quot; &quot; .. seterror('extra_pages');
            Pages = nil;
            At = nil;
        end
    elseif Pages ~= nil then
        if At ~= nil then
            Pages = Pages .. &quot; &quot; .. seterror('extra_pages');
            At = nil;
        end
    end    
                
    local Edition = A['Edition'];
    local PublicationPlace = A['PublicationPlace']
    local Place = A['Place'];
    if PublicationPlace == nil and Place ~= nil then 
        PublicationPlace = Place;
    end
    if PublicationPlace == Place then Place = nil end
    
    local PublisherName = A['PublisherName'];
    local SubscriptionRequired = A['SubscriptionRequired'];
    local Via = A['Via'];
    local AccessDate = A['AccessDate'];
    local ArchiveDate = A['ArchiveDate'];
    local Agency = A['Agency'];
    local DeadURL = A['DeadURL']
    local Language = A['Language'];
    local Format = A['Format']
    local Ref = A['Ref']

    local DoiBroken = A['DoiBroken']
    local ID = A['ID'];
    local ASINTLD = A['ASINTLD'];
    local IgnoreISBN = A['IgnoreISBN']

    local ID_list = extractids( args );
    
    local Quote = A['Quote'];
    local PostScript = A['PostScript']
    local LaySummary = A['LaySummary']
    local LaySource = A['LaySource'];
    local Transcript = A['Transcript'];
    local TranscriptURL = A['TranscriptURL'];
    local sepc = A['Separator']
    local LastAuthorAmp = A['LastAuthorAmp']
    local no_tracking_cats = A['NoTracking'] or &quot;&quot;;

    local this_page = mw.title.getCurrentTitle();  --Also used for COinS
    if no_tracking_cats == &quot;&quot; then
        for k, v in pairs( cfg.uncategorized_namespaces ) do
            if this_page.nsText == v then
                no_tracking_cats = &quot;true&quot;;
                break;
            end
        end
    end

    if ( config.CitationClass == &quot;journal&quot; ) then        
        if (URL == nil or URL == &quot;&quot;) then
            if (ID_list['PMC'] ~= nil) then 
                local Embargo = A['Embargo'];
                if Embargo ~= nil then
                    local lang = mw.getContentLanguage();
                    local good1, result1, good2, result2;
                    good1, result1 = pcall( lang.formatDate, lang, 'U', Embargo );
                    good2, result2 = pcall( lang.formatDate, lang, 'U' );

                    if good1 and good2 and tonumber( result1 ) &lt; tonumber( result2 ) then 
                        URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];
                    end
                else
                    URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];           
                end
            end
        end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if ( BookTitle ) then
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = BookTitle
        TitleLink = nil
        TransTitle = nil
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = A['AirDate']
        local SeriesLink = A['SeriesLink']
        local Season = A['Season']
        local SeriesNumber = A['SeriesNumber']
        local Network = A['Network']
        local Station = A['Station']
        local s = {}
        if Issue ~= nil then table.insert(s, cfg.message_list[&quot;episode&quot;] .. &quot; &quot; .. Issue) Issue = nil end
        if Season ~= nil then table.insert(s, cfg.message_list[&quot;season&quot;] .. &quot; &quot; .. Season) end
        if SeriesNumber ~= nil then table.insert(s, cfg.message_list[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber) end
        local n = {}
        if Network ~= nil then table.insert(n, Network) end
        if Station ~= nil then table.insert(n, Station) end
        Date = Date or AirDate
        Chapter = Title
        ChapterLink = TitleLink
        TransChapter = TransTitle
        Title = Series
        TitleLink = SeriesLink
        TransTitle = nil
        local Sep = (A[&quot;SeriesSeparator&quot;] or A[&quot;Separator&quot;]) .. &quot; &quot;
        Series = table.concat(s, Sep)
        ID = table.concat(n, Sep)
    end
    
    -- These data form a COinS tag (see &lt;http://ocoins.info/&gt;) which allows 
    -- automated tools to parse the citation information.
    local OCinSdata = {} -- COinS metadata excluding id, bibcode, doi, etc.
    local ctx_ver = &quot;Z39.88-2004&quot; 
    OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
    if ( nil ~= Periodical ) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;article&quot;
        OCinSdata[&quot;rft.jtitle&quot;] = Periodical
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    end
    if ( nil ~= Chapter and &quot;&quot; ~= Chapter) then
        OCinSdata.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;
        OCinSdata[&quot;rft.genre&quot;] = &quot;bookitem&quot;
        OCinSdata[&quot;rft.btitle&quot;] = Chapter
        if ( nil ~= Title ) then OCinSdata[&quot;rft.atitle&quot;] = Title end
    else
        OCinSdata[&quot;rft.genre&quot;] = &quot;book&quot;
        if ( nil ~= Title ) then OCinSdata[&quot;rft.btitle&quot;] = Title end
    end
    OCinSdata[&quot;rft.place&quot;] = PublicationPlace
    OCinSdata[&quot;rft.date&quot;] = Date or Year or PublicationDate
    OCinSdata[&quot;rft.series&quot;] = Series
    OCinSdata[&quot;rft.volume&quot;] = Volume
    OCinSdata[&quot;rft.issue&quot;] = Issue
    OCinSdata[&quot;rft.pages&quot;] = Page or Pages or At
    OCinSdata[&quot;rft.edition&quot;] = Edition
    OCinSdata[&quot;rft.pub&quot;] = PublisherName
    
    for k, v in pairs( ID_list ) do
        if k == 'ISBN' then
            v = cleanisbn( v );
        end
        if string.sub( cfg.id_handlers[k].COinS or &quot;info&quot;, 1, 4 ) ~= 'info' then
            OCinSdata[ cfg.id_handlers[k].COinS ] = v;
        end
    end
    
    OCinSdata.rft_id = URL or ChapterURL

    local last, first;
    local OCinSauthors = {};
    for k, v in ipairs( a ) do
        last = v.last;
        first = v.first;
        if k == 1 then
            if last ~= nil then
                OCinSdata[&quot;rft.aulast&quot;] = last;
            end
            if first ~= nil then 
                OCinSdata[&quot;rft.aufirst&quot;] = first;
            end
        end
        if last ~= nil and first ~= nil then
            table.insert( OCinSauthors, last .. &quot;, &quot; .. first );
    	elseif last ~= nil then
            table.insert( OCinSauthors, last );
        end
    end

    local OCinSids = {} -- COinS data only for id, bibcode, doi, pmid, etc.
    for k, v in pairs( ID_list ) do
        if string.sub( cfg.id_handlers[k].COinS or &quot;&quot;, 1, 4 ) == 'info' then
            OCinSids[ cfg.id_handlers[k].COinS ] = v;
        end
    end

    local OCinStitle = &quot;ctx_ver=&quot; .. ctx_ver  -- such as &quot;Z39.88-2004&quot;
    for name,value in pairs(OCinSdata) do
        OCinStitle = OCinStitle .. &quot;&amp;&quot; .. name .. &quot;=&quot; .. mw.uri.encode( removewikilink(value) );
    end
    for _, value in ipairs(OCinSauthors) do
        OCinStitle = OCinStitle .. &quot;&amp;rft.au=&quot; .. mw.uri.encode( removewikilink(value) );
    end
    for name,value in pairs(OCinSids) do
        OCinStitle = OCinStitle .. &quot;&amp;rft_id=&quot; .. mw.uri.encode(name .. &quot;/&quot; .. removewikilink(value) );
    end
    
    OCinStitle = OCinStitle .. &quot;&amp;rfr_id=info:sid/&quot; .. mw.site.server:match( &quot;[^/]*$&quot; ) .. &quot;:&quot;
       .. this_page.prefixedText  -- end COinS data by page's non-encoded pagename

    if (Periodical ~= nil and Periodical ~= &quot;&quot;) and
        (Chapter == nil or Chapter == '') and
        (Title ~= nil and Title ~= &quot;&quot;) then
            Chapter = Title
            ChapterLink = TitleLink
            TransChapter = TransTitle
            Title = nil
            TitleLink = nil
            TransTitle = nil            
    end

    -- Now perform various field 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 ( Authors == nil ) then 
        local Maximum = tonumber( A['DisplayAuthors'] );
        
        -- Preserve old-style implicit et al.
        if Maximum == nil and #a == 9 then 
            Maximum = 8;
            table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
        elseif Maximum == nil then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = A[&quot;AuthorSeparator&quot;] .. &quot; &quot;,
            namesep = (A[&quot;AuthorNameSeparator&quot;] or A[&quot;NameSeparator&quot;]) .. &quot; &quot;,
            format = A[&quot;AuthorFormat&quot;],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        }
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if Coauthors ~= nil and Coauthors ~= &quot;&quot; then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
                
        Authors = listpeople(control, a) 
    end
    local EditorCount
    if ( Editors == nil ) then 
        local Maximum = tonumber( A['DisplayEditors'] );

        -- Preserve old-style implicit et al.
        if Maximum == nil and #e == 4 then 
            Maximum = 3;
            table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
        elseif Maximum == nil then
            Maximum = #e + 1;
        end

        local control = { 
            sep = A[&quot;EditorSeparator&quot;] .. &quot; &quot;,
            namesep = (A[&quot;EditorNameSeparator&quot;] or A[&quot;NameSeparator&quot;]) .. &quot; &quot;,
            format = A['EditorFormat'],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
            }

        Editors, EditorCount = listpeople(control, e) 
    else
        EditorCount = 1;
    end
    if ( Date == nil or Date == &quot;&quot;) then
--   there's something hinky with how this adds dashes to perfectly-good free-standing years
--[[        Date = Year
        if ( Date ~= nil ) then
            local Month = args.month
            if ( Month == nil ) then 
                local Began = args.began
                local Ended = args.ended
                if Began ~= nil and Ended ~= nil then
                    Month = Began .. &quot;&amp;ndash;&quot; .. Ended
                else
                    Month = &quot;&amp;ndash;&quot;
                end
            end
            Date = Month .. &quot; &quot; .. Date
            local Day = args.day
            if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
        end
]] -- so let's use the original version for now
        Date = Year
        if ( Date ~= nil and Date ~=&quot;&quot;) then
            local Month = A['Month']
            if ( Month ~= nil and Month ~= &quot;&quot;) then 
                Date = Month .. &quot; &quot; .. Date 
                local Day = A['Day']
                if ( Day ~= nil ) then Date = Day .. &quot; &quot; .. Date end
                else Month = &quot;&quot;
            end
            else Date = &quot;&quot;
        end
    end
    if ( PublicationDate == Date or PublicationDate == Year ) then PublicationDate = nil end
    if( (Date == nil or Date == &quot;&quot;) and PublicationDate ~= nil ) then 
        Date = PublicationDate;
        PublicationDate = nil;
    end    

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date
    
    if ( URL == nil or URL == '' ) and
            ( ChapterURL == nil or ChapterURL == '' ) and
            ( ArchiveURL == nil or ArchiveURL == '' ) and                
            ( ConferenceURL == nil or ConferenceURL == '' ) and                
            ( TranscriptURL == nil or TranscriptURL == '' ) then

        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
        end

        -- Test if accessdate is given without giving a URL
        if ( AccessDate ~= nil and AccessDate ~= '' ) then
            table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
            AccessDate = nil;
        end      
    
        -- Test if format is given without giving a URL
        if ( Format ~= nil and Format ~= '' ) then
            Format = Format .. seterror( 'format_missing_url' );
        end        
    end    

    -- Test if citation has no title
    if ( Chapter == nil or Chapter == &quot;&quot; ) and 
            ( Title == nil or Title == &quot;&quot; ) and
            ( Periodical == nil or Periodical == &quot;&quot; ) and
            ( Conference == nil or Conference == &quot;&quot; ) and 
            ( TransTitle == nil or TransTitle == &quot;&quot; ) and
            ( TransChapter == nil or TransChapter == &quot;&quot; ) then
        table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
    end

    if ( Format ~= nil and Format ~=&quot;&quot; ) then
        Format = &quot; (&quot; .. Format .. &quot;)&quot; else Format = &quot;&quot; end
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
        end
    end

    -- Format chapter / article title
    if ( Chapter ~= nil and Chapter ~= &quot;&quot; ) and ( ChapterLink and &quot;&quot; &lt; ChapterLink ) then 
        Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot;;
    end
    if ( Periodical and &quot;&quot; &lt; Periodical ) and (Title ~= nil and Title ~= &quot;&quot; ) then
        Chapter = wrap( 'italic-title', Chapter );
        TransChapter = wrap( 'trans-italic-title', TransChapter );
    else
        Chapter = wrap( 'quoted-title', Chapter );
        TransChapter = wrap( 'trans-quoted-title', TransChapter );
    end
    
    local TransError = &quot;&quot;
    if TransChapter ~= &quot;&quot; and Chapter == &quot;&quot; then
        TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
    end
    
    if TransChapter ~= &quot;&quot; and Chapter ~= &quot;&quot; then TransChapter = &quot; &quot; .. TransChapter; end
    Chapter = Chapter .. TransChapter
    
    if Chapter ~= &quot;&quot; then
        if ( ChapterLink == nil ) then
            if ( ChapterURL and &quot;&quot; &lt; ChapterURL ) then                
                Chapter = externallink( ChapterURL, Chapter ) .. TransError;
                if URL == nil or URL == &quot;&quot; then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif ( URL and &quot;&quot; &lt; URL ) then 
                Chapter = externallink( URL, Chapter ) .. TransError .. Format;
                URL = nil
                Format = &quot;&quot;
            else
                Chapter = Chapter .. TransError;
            end            
        elseif ChapterURL ~= nil and ChapterURL ~= &quot;&quot; then
            Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL ) .. 
                TransError;
        else
            Chapter = Chapter .. TransError;
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    elseif ChapterURL ~= nil and ChapterURL ~= &quot;&quot; then
        Chapter = &quot; &quot; .. externallink( ChapterURL ) .. sepc .. &quot; &quot;;
    end        
    
    -- Format main title.
    if ( TitleLink and &quot;&quot; &lt; TitleLink ) then
        if ( Title and &quot;&quot; &lt; Title ) then
            Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot; 
        end
    end

    if ( Periodical and &quot;&quot; &lt; Periodical ) then
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    elseif ( config.CitationClass == &quot;web&quot;
            or config.CitationClass == &quot;news&quot; 
            or config.CitationClass == &quot;pressrelease&quot; ) and 
            Chapter == &quot;&quot; then
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    else
        Title = wrap( 'italic-title', Title );
        TransTitle = wrap( 'trans-italic-title', TransTitle );
    end
    
    local TransError = &quot;&quot;;
    if TransTitle ~= &quot;&quot; and Title == &quot;&quot; then
        TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
    end
    
    if TransTitle ~= &quot;&quot; and Title ~= &quot;&quot; then TransTitle = &quot; &quot; .. TransTitle; end
    Title = Title .. TransTitle
    
    if Title ~= &quot;&quot; then
        if ( TitleLink == nil and URL and &quot;&quot; &lt; URL ) then 
            Title = externallink( URL, Title ) .. TransError .. Format       
            URL = nil
            Format = ''
        else
            Title = Title .. TransError;
        end
    end

    if ( Place ~= nil and Place ~= &quot;&quot; ) then
        if sepc == '.' then
            Place = &quot; &quot; .. wrap( 'written', Place ) .. sepc .. &quot; &quot;;
        else
            Place = &quot; &quot; .. substitute( cfg.message_list['written']:lower(), {Place} ) .. sepc .. &quot; &quot;;
        end            
    else
        Place = &quot;&quot;;
    end
    
    if ( Conference ~= nil and Conference ~=&quot;&quot; ) then
        if ( ConferenceURL ~= nil ) then
            Conference = externallink( ConferenceURL, Conference );
        end
        Conference = &quot; &quot; .. Conference
    elseif ConferenceURL ~= nil and ConferenceURL ~= &quot;&quot; then
        Conference = &quot; &quot; .. externallink( ConferenceURL );
    else
        Conference = &quot;&quot; 
    end
    if ( nil ~= Position or nil ~= Page or nil ~= Pages ) then At = nil end
    if ( nil == Position and &quot;&quot; ~= Position ) then
        local Minutes = A['Minutes'];
        if ( nil ~= Minutes ) then
            Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.message_list['minutes'];
        else
            local Time = A['Time'];
            if ( nil ~= Time ) then
                local TimeCaption = A['TimeCaption']
                if TimeCaption == nil then
                    TimeCaption = cfg.message_list['event'];
                    if sepc ~= '.' then
                        TimeCaption = TimeCaption:lower();
                    end
                end                
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time
            else
                Position = &quot;&quot;
            end
        end
    else
        Position = &quot; &quot; .. Position
    end
    if ( nil == Page or &quot;&quot; == Page ) then 
        Page = &quot;&quot; 
        if ( nil == Pages or &quot;&quot; == Pages) then 
            Pages = &quot;&quot;
        elseif ( Periodical ~= nil and Periodical ~= &quot;&quot; and
                 config.CitationClass ~= &quot;encyclopaedia&quot; and
                 config.CitationClass ~= &quot;web&quot; and
                 config.CitationClass ~= &quot;book&quot; and
                 config.CitationClass ~= &quot;news&quot;) then
            Pages = &quot;: &quot; .. Pages
        else
            if ( tonumber(Pages) ~= nil ) then
              Pages = sepc ..&quot; &quot; .. PPrefix .. Pages
            else Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages
            end
        end
    else
        Pages = &quot;&quot;
        if ( Periodical ~= nil and Periodical ~= &quot;&quot; and
             config.CitationClass ~= &quot;encyclopaedia&quot; and
             config.CitationClass ~= &quot;web&quot; and
             config.CitationClass ~= &quot;book&quot; and
             config.CitationClass ~= &quot;news&quot;) then
            Page = &quot;: &quot; .. Page
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page
        end
    end
    if ( At ~= nil and At ~=&quot;&quot;) then At = sepc .. &quot; &quot; .. At
    else At = &quot;&quot; end
    if ( Coauthors == nil ) then Coauthors = &quot;&quot; end
    if ( Others ~= nil and Others ~=&quot;&quot; ) then
        Others = sepc .. &quot; &quot; .. Others else Others = &quot;&quot; end
    if ( TitleType ~= nil and TitleType ~=&quot;&quot; ) then
        TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot; else TitleType = &quot;&quot; end
    if ( TitleNote ~= nil and TitleNote ~=&quot;&quot; ) then
        TitleNote = sepc .. &quot; &quot; .. TitleNote else TitleNote = &quot;&quot; end
    if ( Language ~= nil and Language ~=&quot;&quot; ) then
        Language = &quot; &quot; .. wrap( 'language', Language ) else Language = &quot;&quot; end
    if ( Edition ~= nil and Edition ~=&quot;&quot; ) then
        Edition = &quot; &quot; .. wrap( 'edition', Edition ) else Edition = &quot;&quot; end
    if ( Volume ~= nil and Volume ~=&quot;&quot; )
    then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;
        end
    else Volume = &quot;&quot; end
    if ( Issue ~= nil and Issue ~=&quot;&quot; ) then
        Issue = &quot; (&quot; .. Issue .. &quot;)&quot; else Issue = &quot;&quot; end
    if ( Series ~= nil and Series ~=&quot;&quot; ) then
        Series = sepc .. &quot; &quot; .. Series else Series = &quot;&quot; end
    if ( OrigYear ~= nil and OrigYear ~=&quot;&quot; ) then
        OrigYear = &quot; [&quot; .. OrigYear .. &quot;]&quot; else OrigYear = &quot;&quot; end
    if ( Agency ~= nil and Agency ~=&quot;&quot; ) then
        Agency = sepc .. &quot; &quot; .. Agency else Agency = &quot;&quot; end
    ------------------------------------ totally unrelated data
    if ( Date ~= nil ) then Date = Date else Date = &quot;&quot; end
    if ( Via ~= nil and Via ~=&quot;&quot; ) then
        Via = &quot; &quot; .. wrap( 'via', Via ) else Via = &quot;&quot; end
    if ( AccessDate ~= nil and AccessDate ~=&quot;&quot; )
    then local retrv_text = &quot; &quot; .. cfg.message_list['retrieved']
         if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
         AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
             .. substitute( retrv_text, {AccessDate} ) .. '&lt;/span&gt;'
    else AccessDate = &quot;&quot; end
    if ( SubscriptionRequired ~= nil and
         SubscriptionRequired ~= &quot;&quot; ) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.message_list['subscription'];
    else
        SubscriptionRequired = &quot;&quot;
    end
    if ( ID ~= nil and ID ~=&quot;&quot;) then ID = sepc ..&quot; &quot;.. ID else ID=&quot;&quot; end

    ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN} );

    if ( URL ~= nil and URL ~=&quot;&quot;) then
        URL = &quot; &quot; .. externallink( URL );
    else
        URL = &quot;&quot;
    end

    if ( Quote and Quote ~=&quot;&quot; ) then 
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        
        Quote = sepc ..&quot; &quot; .. wrap( 'quoted-text', Quote ); 
        PostScript = &quot;&quot;
    else 
        if ( PostScript == nil) then PostScript = &quot;&quot; end
        Quote = &quot;&quot; 
    end
    
    local Archived
    if ( nil ~= ArchiveURL and &quot;&quot; ~= ArchiveURL ) then
        if ( ArchiveDate == nil or ArchiveDate ==&quot;&quot; ) then
            ArchiveDate = seterror('archive_missing_date');
        end
        if ( &quot;no&quot; == DeadURL ) then
            local arch_text = cfg.message_list['archived'];
            if (sepc ~= &quot;.&quot;) then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( cfg.message_list['archived-not-dead'],
                { externallink( ArchiveURL, arch_text ), ArchiveDate } );
            if OriginalURL == nil or OriginalUrl == '' then
                Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url');                               
            end
        else
            if OriginalURL ~= nil and OriginalURL ~= '' then
                local arch_text = cfg.message_list['archived-dead'];
                if (sepc ~= &quot;.&quot;) then arch_text = arch_text:lower() end
                Archived = sepc .. &quot; &quot; .. substitute( arch_text,
                    { externallink( OriginalURL, cfg.message_list['original'] ), ArchiveDate } );
            else
                local arch_text = cfg.message_list['archived-missing'];
                if (sepc ~= &quot;.&quot;) then arch_text = arch_text:lower() end
                Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
                    { seterror('archive_missing_url'), ArchiveDate } );
            end                
        end
    else
        Archived = &quot;&quot;
    end
    local Lay
    if ( nil ~= LaySummary and &quot;&quot; ~= LaySummary ) then
        if ( LayDate ~= nil ) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; else LayDate = &quot;&quot; end
        if ( LaySource ~= nil ) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot; 
        else 
            LaySource = &quot;&quot; 
        end
        if sepc == '.' then
            Lay = sepc .. &quot; &quot; .. externallink( LaySummary, cfg.message_list['lay summary'] ) .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; &quot; .. externallink( LaySummary, cfg.message_list['lay summary']:lower() ) .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;
    end
    if ( nil ~= Transcript and &quot;&quot; ~= Transcript ) then
        if ( TranscriptURL ~= nil ) then Transcript = externallink( TranscriptURL, Transcript ) end
    elseif TranscriptURL ~= nil and TranscriptURL ~= &quot;&quot; then
        Transcript = externallink( TranscriptURL )     
    else
        Transcript = &quot;&quot;
    end
    local Publisher = &quot;&quot;
    if ( Periodical and Periodical ~= &quot;&quot; and
         config.CitationClass ~= &quot;encyclopaedia&quot; and
         config.CitationClass ~= &quot;web&quot; and
         config.CitationClass ~= &quot;pressrelease&quot; ) then
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            if Publisher ~= '' then
                Publisher = Publisher .. &quot;, &quot; .. wrap( 'published', PublicationDate );
            else
                Publisher = PublicationDate;
            end
        end
        if Publisher ~= &quot;&quot; then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if ( PublicationDate and PublicationDate ~=&quot;&quot; ) then
            PublicationDate = &quot; (&quot; .. wrap( 'published', PublicationDate ) .. &quot;)&quot;
        else 
            PublicationDate = &quot;&quot;
        end
        if ( PublisherName ~= nil and PublisherName ~=&quot;&quot; ) then
            if (PublicationPlace ~= nil and PublicationPlace ~= '') then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif (PublicationPlace ~= nil and PublicationPlace ~= '') then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    -- Several of the above rely upon detecting this as nil, so do it last.
    if ( Periodical ~= nil and Periodical ~=&quot;&quot; ) then 
        if ( Title and Title ~= &quot;&quot; ) or ( TitleNote and TitleNote ~= &quot;&quot; ) then 
            Periodical = sepc .. &quot; &quot; .. wrap( 'italic-title', Periodical ) 
        else 
            Periodical = wrap( 'italic-title', Periodical )
        end
    else Periodical = &quot;&quot; end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if ( ( (config.CitationClass == &quot;journal&quot;) or (config.CitationClass == &quot;citation&quot;) )  and
         Periodical ~= &quot;&quot; ) then
        if (Others ~= &quot;&quot;) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
            Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
            Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
    end
    
    if #ID_list &gt; 0 then
        ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
    else
        ID_list = ID;
    end    
    local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );

    local text
    local pgtext = Page .. Pages .. At
    
    if ( &quot;&quot; ~= Authors ) then
        if (Coauthors ~= &quot;&quot;) 
          then Authors = Authors .. A['AuthorSeparator'] .. &quot; &quot; .. Coauthors
        end
        if ( &quot;&quot; ~= Date )
          then Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
          else
            if ( string.sub(Authors,-1,-1) == sepc) --check end character
              then Authors = Authors .. &quot; &quot;
              else Authors = Authors .. sepc .. &quot; &quot;
            end
        end
        if ( &quot;&quot; ~= Editors) then
            local in_text = &quot; in &quot;
            if (sepc == '.') then in_text = &quot; In &quot; end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif ( &quot;&quot; ~= Editors) then
        if ( &quot;&quot; ~= Date ) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, &quot; .. cfg.message_list['editor'];
            else
                Editors = Editors .. &quot;, &quot; .. cfg.message_list['editors'];
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (&quot; .. cfg.message_list['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (&quot; .. cfg.message_list['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if ( &quot;&quot; ~= Date ) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end -- endif &quot;&quot;~=Date
        if ( config.CitationClass==&quot;journal&quot; and Periodical ) then
          text = safejoin( {Chapter, Place, tcommon}, sepc );
          text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
          text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
          text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if PostScript ~= '' and PostScript ~= nil and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    if ( Year == nil ) then
        if ( DateIn ~= nil and DateIn ~= &quot;&quot; ) then 
            Year = selectyear( DateIn )
        elseif( PublicationDate ~= nil and PublicationDate ~= &quot;&quot; ) then
            Year = selectyear( PublicationDate )
        else
            Year = &quot;&quot;
        end
    end
    local classname = &quot;citation&quot;
    if ( config.CitationClass ~= &quot;citation&quot; )
       then classname = &quot;citation &quot; .. (config.CitationClass or &quot;&quot;) end
    local options = { class=classname }
    if ( Ref ~= nil ) then 
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if ( &quot;&quot; ~= Authors ) then
                for i,v in ipairs(a) do 
                    names[i] = v.last 
                    if i == 4 then break end
                end
            elseif ( &quot;&quot; ~= Editors ) then
                for i,v in ipairs(e) do 
                    names[i] = v.last 
                    if i == 4 then break end                
                end
            end
            names[ #names + 1 ] = Year;
            id = anchorid(names)
        end
        options.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = {};
        text = seterror('empty_citation');
        z.message_tail = {};
    end
    
    if options.id ~= nil then 
        text = '&lt;span id=&quot;' .. wikiescape(options.id) ..'&quot; class=&quot;' .. wikiescape(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    else
        text = '&lt;span class=&quot;' .. wikiescape(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    end        

    local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = '&lt;span title=&quot;' .. wikiescape(OCinStitle) .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        text = text .. &quot; &quot;;
        for i,v in ipairs( z.message_tail ) do
            if v[1] ~= nil and v[1] ~= &quot;&quot; then 
                if i == #z.message_tail then
                    text = text .. errorcomment( v[1], v[2] );
                else
                    text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
                end
            end
        end
    end
    
    no_tracking_cats = no_tracking_cats:lower();
    if no_tracking_cats == &quot;&quot; or no_tracking_cats == &quot;no&quot; or
            no_tracking_cats == &quot;false&quot; or no_tracking_cats == &quot;n&quot; then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    local suggestions = {};
    local error_text, error_state;
    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            if not validate( k ) then            
                error_text = &quot;&quot;;
                if type( k ) ~= 'string' then
                    -- Exclude empty numbered parameters
                    if v:match(&quot;%S+&quot;) ~= nil then
                        error_text, error_state = seterror( 'text_ignored', {v}, true );
                    end
                elseif validate( k:lower() ) then 
                    error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
                else
                    if #suggestions == 0 then
                        suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
                    end
                    if suggestions[ k:lower() ] ~= nil then
                        error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
                    else
                        error_text, error_state = seterror( 'parameter_ignored', {k}, true );
                    end
                end                  
                if error_text ~= '' then
                    table.insert( z.message_tail, {error_text, error_state} );
                end                
            end            
            args[k] = v;
        elseif k == 'postscript' then
            args[k] = v;
        end        
    end    

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        if args[k] == nil and (v ~= '' or k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z</text>
      <sha1>1pjj5k43ynuy2az98d1uxyws2wj3wz9</sha1>
    </revision>
    <revision>
      <id>4654</id>
      <parentid>4653</parentid>
      <timestamp>2013-04-25T18:42:40Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>sync to sandbox, mostly code cleaning / organization.  Also, ref = none, layurl as alias for laysummary, tweaks to COinS output, and changes to bareurl error.</comment>
      <origin>4654</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="56197" sha1="ghf1zqz8c2ac0pvfpc8oxbtq4nj2r1t" xml:space="preserve">local z = {
    error_categories = {};
    error_ids = {};
    message_tail = {};
}

-- Include translation message hooks, ID and error handling configuration settings.
-- Note that require has tested to be significantly faster than loadData for this 
-- usage.  This might be a side effect of the unnecessary cloning described 
-- in bugzilla 47300.
local cfg = require( 'Module:Citation/CS1/Configuration/sandbox' );

-- Contains a list of all recognized parameters
local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );

-- Whether variable is set or not
function is_set( var )
    return not (var == nil or var == '');
end

-- First set variable or nil if none
function first_set(...)
    local list = {...};
    for _, var in pairs(list) do
        if is_set( var ) then
            return var;
        end
    end
end

-- Whether needle is in haystack
function inArray( needle, haystack )
    if needle == nil then
        return false;
    end
    for n,v in ipairs( haystack ) do
        if v == needle then
            return n;
        end
    end
    return false;
end

-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
    return args and tostring( mw.message.newRawMessage( msg, args ) ) or msg;
end

-- Wraps a string using a message_list configuration taking one argument
function wrap( key, str )
    if not is_set( str ) then
        return &quot;&quot;;
    elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
        str = safeforitalics( str );
    end
    return substitute( cfg.messages[key], {str} );
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
    local origin = {};
    
    return setmetatable({
        ORIGIN = function( self, k )
            local dummy = self[k]; --force the variable to be loaded.
            return origin[k];
        end
    },
    {
        __index = function ( tbl, k )
            if origin[k] ~= nil then
                return nil;
            end
            
            local args, list, v = args, cfg.aliases[k];
            
            if list == nil then
                error( cfg.messages['unknown_argument_map'] );
            elseif type( list ) == 'string' then
                v, origin[k] = args[list], list;
            else
                v, origin[k] = selectone( args, list, 'redundant_parameters' );
                if origin[k] == nil then
                    origin[k] = '';   --Empty string, not nil;
                end
            end
            
            if v == nil then
                v = cfg.defaults[k] or &quot;&quot;;
                origin[k] = '';   --Empty string, not nil;
            end
            
            tbl = rawset( tbl, k, v );
            return v;
        end,
    });
end

-- Checks that parameter name is valid using the whitelist
function validate( name )
    name = tostring( name );
    
    -- Normal arguments
    if whitelist.basic_arguments[ name ] then
        return true;
    end
    
    -- Arguments with numbers in them
    name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );
    if whitelist.numbered_arguments[ name ] then
        return true;
    end
    
    -- Not found, argument not supported.
    return false
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
    return wrap( hidden and 'hidden-error' or 'visible-error', content );
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
    local error_state = cfg.error_conditions[ error_id ];
    
    prefix = prefix or &quot;&quot;;
    suffix = suffix or &quot;&quot;;
    
    if error_state == nil then
        error( cfg.messages['undefined_error'] );
    elseif is_set( error_state.category ) then
        table.insert( z.error_categories, error_state.category );
    end
    
    local message = substitute( error_state.message, arguments );
    
    message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
        &quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
        cfg.messages['help page label'] .. &quot;]])&quot;;
    
    z.error_ids[ error_id ] = true;
    if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
            and z.error_ids['citation_missing_title'] then
        return '', false;
    end
    
    message = table.concat({ prefix, message, suffix });
    
    if raw == true then
        return message, error_state.hidden;
    end        
        
    return errorcomment( message, error_state.hidden );
end

-- Formats a wiki style external link
function externallinkid(options)
    local url_string = options.id;
    if options.encode == true or options.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, url_string, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Formats a wiki style internal link
function internallinkid(options)
    return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, options.id, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Format an external link with error checking
function externallink( URL, label, source )
    local error_str = &quot;&quot;;
    if not is_set( label ) then
        label = URL;
        if is_set( source ) then
            error_str = seterror( 'bare_url_missing_title', { wrap( 'parameter', source ) }, false, &quot; &quot; );
        else
            error( cfg.messages[&quot;bare_url_no_origin&quot;] );
        end            
    end
    if not checkurl( URL ) then
        error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
    end
    return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safeforurl( label ), &quot;]&quot;, error_str });
end

-- Formats a link to Amazon
function amazon(id, domain)
    if not is_set(domain) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local handler = cfg.id_handlers['ASIN'];
    return externallinkid({link = handler.link,
        label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
        encode=handler.encode, separator = handler.separator})
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    local handler = cfg.id_handlers['DOI'];
    
    local text;
    if is_set(inactive) then
        text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link = handler.link, label = handler.label,
            prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then      
        cat = seterror( 'bad_doi' );
    end
    return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    local handler = cfg.id_handlers['OL'];
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    else
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode}) .. 
            ' ' .. seterror( 'bad_ol' );
    end
end

--[[
Determines whether an URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
    -- Protocol-relative or URL scheme
    return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
    return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
    isbn_str = cleanisbn( isbn_str ):gsub( &quot;-&quot;, &quot;&quot; );
    local len = isbn_str:len();
 
    if len ~= 10 and len ~= 13 then
        return false;
    end
 
    local temp = 0;
    if len == 10 then
        if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            if v == string.byte( &quot;X&quot; ) then
                temp = temp + 10*( 11 - i );
            else
                temp = temp + tonumber( string.char(v) )*(11-i);
            end
        end
        return temp % 11 == 0;
    else
        if isbn_str:match( &quot;^%d*$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
        end
        return temp % 10 == 0;
    end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
    return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
        return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
    end));
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if not is_set(str) then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        
        -- Remove newlines as they break italics.
        return str:gsub( '\n', ' ' );
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    -- Is the input a simple number?
    local num = tonumber( str ); 
    if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.floor(num) then
        return str;
    else
        -- Use formatDate to interpret more complicated formats
        local lang = mw.getContentLanguage();
        local good, result;
        good, result = pcall( lang.formatDate, lang, 'Y', str )
        if good then 
            return result;
        else
            -- Can't make sense of this input, return blank.
            return &quot;&quot;;
        end
    end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    if maximum ~= nil and maximum &lt; 1 then return &quot;&quot;, 0; end
    
    for i,person in ipairs(people) do
        if is_set(person.last) then
            local mask = person.mask
            local one
            local sep_one = sep;
            if maximum ~= nil and i &gt; maximum then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask;
                    sep_one = &quot; &quot;;
                end
            else
                one = person.last
                local first = person.first
                if is_set(first) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if is_set(person.link) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert( text, one )
            table.insert( text, sep_one )
        end
    end

    local count = #text / 2;
    if count &gt; 0 then 
        if count &gt; 1 and is_set(lastauthoramp) and not etal then
            text[#text-2] = &quot; &amp; &quot;;
        end
        text[#text] = nil; 
    end
    
    local result = table.concat(text) -- construct list
    if etal then 
        local etal_text = cfg.messages['et al'];
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result = 
        '&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
    end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
    return &quot;CITEREF&quot; .. table.concat( options );
end

-- Gets name list from the input arguments
function extractnames(args, list_name)
    local names = {};
    local i = 1;
    local last;
    
    while true do
        last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );
        if not is_set(last) then
            -- just in case someone passed in an empty parameter
            break;
        end
        names[i] = {
            last = last,
            first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i ),
            link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ),
            mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i )
        };
        i = i + 1;
    end
    return names;
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
    local id_list = {};
    for k, v in pairs( cfg.id_handlers ) do    
        v = selectone( args, v.parameters, 'redundant_parameters' );
        if is_set(v) then id_list[k] = v; end
    end
    return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
    local new_list, handler = {};
    
    function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
    
    for k, v in pairs( id_list ) do
        -- fallback to read-only cfg
        handler = setmetatable( { ['id'] = v }, fallback(k) );
        
        if handler.mode == 'external' then
            table.insert( new_list, {handler.label, externallinkid( handler ) } );
        elseif handler.mode == 'internal' then
            table.insert( new_list, {handler.label, internallinkid( handler ) } );
        elseif handler.mode ~= 'manual' then
            error( cfg.messages['unknown_ID_mode'] );
        elseif k == 'DOI' then
            table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
        elseif k == 'ASIN' then
            table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
        elseif k == 'OL' then
            table.insert( new_list, {handler.label, openlibrary( v ) } );
        elseif k == 'ISBN' then
            local ISBN = internallinkid( handler );
            if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
                ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
            end
            table.insert( new_list, {handler.label, ISBN } );                
        else
            error( cfg.messages['unknown_manual_ID'] );
        end
    end
    
    function comp( a, b )
        return a[1] &lt; b[1];
    end
    
    table.sort( new_list, comp );
    for k, v in ipairs( new_list ) do
        new_list[k] = v[2];
    end
    
    return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
    local value = nil;
    local selected = '';
    local error_list = {};
    
    if index ~= nil then index = tostring(index); end
    
    -- Handle special case of &quot;#&quot; replaced by empty string
    if index == '1' then
        for _, v in ipairs( possible ) do
            v = v:gsub( &quot;#&quot;, &quot;&quot; );
            if is_set(args[v]) then
                if value ~= nil and selected ~= v then
                    table.insert( error_list, v );
                else
                    value = args[v];
                    selected = v;
                end
            end
        end        
    end
    
    for _, v in ipairs( possible ) do
        if index ~= nil then
            v = v:gsub( &quot;#&quot;, index );
        end
        if is_set(args[v]) then
            if value ~= nil and selected ~=  v then
                table.insert( error_list, v );
            else
                value = args[v];
                selected = v;
            end
        end
    end
    
    if #error_list &gt; 0 then
        local error_str = &quot;&quot;;
        for _, k in ipairs( error_list ) do
            if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
            error_str = error_str .. wrap( 'parameter', k );
        end
        if #error_list &gt; 1 then
            error_str = error_str .. cfg.messages['parameter-final-separator'];
        else
            error_str = error_str .. cfg.messages['parameter-pair-separator'];
        end
        error_str = error_str .. wrap( 'parameter', selected );
        table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
    end
    
    return value, selected;
end

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
function COinS(data)
    if 'table' ~= type(data) or nil == next(data) then
        return '';
    end
    
    local ctx_ver = &quot;Z39.88-2004&quot;;
    
    -- treat table strictly as an array with only set values.
    local OCinSoutput = setmetatable( {}, {
        __newindex = function(self, key, value)
            if is_set(value) then
                rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
            end
        end
    });
    
    if is_set(data.Chapter) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Chapter;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    elseif is_set(data.Periodical) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
        OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    else
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
    end
    
    OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
    OCinSoutput[&quot;rft.date&quot;] = data.Date;
    OCinSoutput[&quot;rft.series&quot;] = data.Series;
    OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
    OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
    OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
    OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
    OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
    
    for k, v in pairs( data.ID_list ) do
        local id, value = cfg.id_handlers[k].COinS;
        if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
        if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
            OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
        else
            OCinSoutput[ id ] = value;
        end
    end
    
    local last, first;
    for k, v in ipairs( data.Authors ) do
        last, first = v.last, v.first;
        if k == 1 then
            if is_set(last) then
                OCinSoutput[&quot;rft.aulast&quot;] = last;
            end
            if is_set(first) then 
                OCinSoutput[&quot;rft.aufirst&quot;] = first;
            end
        end
        if is_set(last) and is_set(first) then
            OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
        elseif is_set(last) then
            OCinSoutput[&quot;rft.au&quot;] = last;
        end
    end
    
    OCinSoutput.rft_id = data.URL;
    OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
    OCinSoutput = setmetatable( OCinSoutput, nil );
    
    -- sort with version string always first, and combine.
    table.sort( OCinSoutput );
    table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
    return table.concat(OCinSoutput, &quot;&amp;&quot;);
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    --[[ 
    Load Input Parameters
    The argment_wrapper facillitates the mapping of multiple
    aliases to single internal variable.
    ]]
    local A = argument_wrapper( args );

    local i 
    local PPrefix = A['PPrefix']
    local PPPrefix = A['PPPrefix']
    if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = A['Authors'];
    local a = extractnames( args, 'AuthorList' );

    local Coauthors = A['Coauthors'];
    local Others = A['Others'];
    local Editors = A['Editors'];
    local e = extractnames( args, 'EditorList' );

    local Year = A['Year'];
    local PublicationDate = A['PublicationDate'];
    local OrigYear = A['OrigYear'];
    local Date = A['Date'];
    local LayDate = A['LayDate'];
    ------------------------------------------------- Get title data
    local Title = A['Title'];
    local BookTitle = A['BookTitle'];
    local Conference = A['Conference'];
    local TransTitle = A['TransTitle'];
    local TitleNote = A['TitleNote'];
    local TitleLink = A['TitleLink'];
    local Chapter = A['Chapter'];
    local ChapterLink = A['ChapterLink'];
    local TransChapter = A['TransChapter'];
    local TitleType = A['TitleType'];
    local ArchiveURL = A['ArchiveURL'];
    local URL = A['URL']
    local URLorigin = A:ORIGIN('URL');
    local ChapterURL = A['ChapterURL'];
    local ChapterURLorigin = A:ORIGIN('ChapterURL');
    local ConferenceURL = A['ConferenceURL'];
    local ConferenceURLorigin = A:ORIGIN('ConferenceURL');
    local Periodical = A['Periodical'];
    
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if not is_set(Chapter) then
            if not is_set(Title) then
                Title = Periodical;
                Periodical = '';
            else
                Chapter = Title
                TransChapter = TransTitle
                Title = '';
                TransTitle = '';
            end
        end
    end

    local Series = A['Series'];
    local Volume = A['Volume'];
    local Issue = A['Issue'];
    local Position = '';
    local Page, Pages, At, page_type;
    
    Page = A['Page'];
    Pages = hyphentodash( A['Pages'] );
    At = A['At'];
    
    if is_set(Page) then
        if is_set(Pages) or is_set(At) then
            Page = Page .. &quot; &quot; .. seterror('extra_pages');
            Pages = '';
            At = '';
        end
    elseif is_set(Pages) then
        if is_set(At) then
            Pages = Pages .. &quot; &quot; .. seterror('extra_pages');
            At = '';
        end
    end    
    
    local Edition = A['Edition'];
    local PublicationPlace = A['PublicationPlace']
    local Place = A['Place'];
    
    if not is_set(PublicationPlace) and is_set(Place) then
        PublicationPlace = Place;
    end
    
    if PublicationPlace == Place then Place = ''; end
    
    local PublisherName = A['PublisherName'];
    local SubscriptionRequired = A['SubscriptionRequired'];
    local Via = A['Via'];
    local AccessDate = A['AccessDate'];
    local ArchiveDate = A['ArchiveDate'];
    local Agency = A['Agency'];
    local DeadURL = A['DeadURL']
    local Language = A['Language'];
    local Format = A['Format'];
    local Ref = A['Ref'];
    
    local DoiBroken = A['DoiBroken'];
    local ID = A['ID'];
    local ASINTLD = A['ASINTLD'];
    local IgnoreISBN = A['IgnoreISBN'];

    local ID_list = extractids( args );
    
    local Quote = A['Quote'];
    local PostScript = A['PostScript'];
    local LayURL = A['LayURL'];
    local LaySource = A['LaySource'];
    local Transcript = A['Transcript'];
    local TranscriptURL = A['TranscriptURL'] 
    local TranscriptURLorigin = A:ORIGIN('TranscriptURL');
    local sepc = A['Separator'];
    local LastAuthorAmp = A['LastAuthorAmp'];
    local no_tracking_cats = A['NoTracking'];

    local this_page = mw.title.getCurrentTitle();  --Also used for COinS
    
    if not is_set(no_tracking_cats) then
        for k, v in pairs( cfg.uncategorized_namespaces ) do
            if this_page.nsText == v then
                no_tracking_cats = &quot;true&quot;;
                break;
            end
        end
    end

    if ( config.CitationClass == &quot;journal&quot; ) then
        if not is_set(URL) and is_set(ID_list['PMC']) then
            local Embargo = A['Embargo'];
            if is_set(Embargo) then
                local lang = mw.getContentLanguage();
                local good1, result1, good2, result2;
                good1, result1 = pcall( lang.formatDate, lang, 'U', Embargo );
                good2, result2 = pcall( lang.formatDate, lang, 'U' );
                
                if good1 and good2 and tonumber( result1 ) &lt; tonumber( result2 ) then 
                    URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];
                    URLorigin = cfg.id_handlers['PMC'].parameters[1];
                end
            else
                URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];
                URLorigin = cfg.id_handlers['PMC'].parameters[1];
            end
        end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if is_set(BookTitle) then
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = BookTitle;
        TitleLink = '';
        TransTitle = '';
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = A['AirDate'];
        local SeriesLink = A['SeriesLink'];
        local Season = A['Season'];
        local SeriesNumber = A['SeriesNumber'];
        local Network = A['Network'];
        local Station = A['Station'];
        local s, n = {}, {};
        local Sep = (first_set(A[&quot;SeriesSeparator&quot;], A[&quot;Separator&quot;]) or &quot;&quot;) .. &quot; &quot;;
        
        if is_set(Issue) then table.insert(s, cfg.messages[&quot;episode&quot;] .. &quot; &quot; .. Issue); Issue = ''; end
        if is_set(Season) then table.insert(s, cfg.messages[&quot;season&quot;] .. &quot; &quot; .. Season); end
        if is_set(SeriesNumber) then table.insert(s, cfg.messages[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber); end
        if is_set(Network) then table.insert(n, Network); end
        if is_set(Station) then table.insert(n, Station); end
        
        Date = Date or AirDate;
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = Series;
        TitleLink = SeriesLink;
        TransTitle = '';
        
        Series = table.concat(s, Sep);
        ID = table.concat(n, Sep);
    end
    
    -- COinS metadata (see &lt;http://ocoins.info/&gt;) for
    -- automated parsing of citation information.
    local OCinSoutput = COinS{
        ['Periodical'] = Periodical,
        ['Chapter'] = Chapter,
        ['Title'] = Title,
        ['PublicationPlace'] = PublicationPlace,
        ['Date'] = first_set(Date, Year, PublicationDate),
        ['Series'] = Series,
        ['Volume'] = Volume,
        ['Issue'] = Issue,
        ['Pages'] = first_set(Page, Pages, At),
        ['Edition'] = Edition,
        ['PublisherName'] = PublisherName,
        ['URL'] = first_set( URL, ChapterURL ),
        ['Authors'] = a,
        ['ID_list'] = ID_list,
        ['RawPage'] = this_page.prefixedText,
    };

    if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = '';
        TitleLink = '';
        TransTitle = '';
    end

    -- Now perform various field 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 not is_set(Authors) then
        local Maximum = tonumber( A['DisplayAuthors'] );
        
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #a == 9 then 
            Maximum = 8;
            table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
        elseif not is_set(Maximum) then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = A[&quot;AuthorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;AuthorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A[&quot;AuthorFormat&quot;],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if is_set(Coauthors) then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
        
        Authors = listpeople(control, a) 
    end
    
    local EditorCount
    if not is_set(Editors) then
        local Maximum = tonumber( A['DisplayEditors'] );
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #e == 4 then 
            Maximum = 3;
            table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
        elseif not is_set(Maximum) then
            Maximum = #e + 1;
        end

        local control = { 
            sep = A[&quot;EditorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;EditorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A['EditorFormat'],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };

        Editors, EditorCount = listpeople(control, e);
    else
        EditorCount = 1;
    end
    
    if not is_set(Date) then
        Date = Year;
        if is_set(Date) then
            local Month = A['Month'];
            if is_set(Month) then 
                Date = Month .. &quot; &quot; .. Date;
                local Day = A['Day']
                if is_set(Day) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    
    if inArray(PublicationDate, {Date, Year}) then PublicationDate = ''; end
    if not is_set(Date) and is_set(PublicationDate) then
        Date = PublicationDate;
        PublicationDate = '';
    end

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date;
    
    if  not is_set(URL) and
        not is_set(ChapterURL) and
        not is_set(ArchiveURL) and
        not is_set(ConferenceURL) and
        not is_set(TranscriptURL) then
        
        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
        end
        
        -- Test if accessdate is given without giving a URL
        if is_set(AccessDate) then
            table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
            AccessDate = '';
        end
        
        -- Test if format is given without giving a URL
        if is_set(Format) then
            Format = Format .. seterror( 'format_missing_url' );
        end
    end
    
    -- Test if citation has no title
    if  not is_set(Chapter) and
        not is_set(Title) and
        not is_set(Periodical) and
        not is_set(Conference) and
        not is_set(TransTitle) and
        not is_set(TransChapter) then
        table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
    end
    
    Format = is_set(Format) and &quot; (&quot; .. Format .. &quot;)&quot; or &quot;&quot;;
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
        end
    end
    
    -- Format chapter / article title
    if is_set(Chapter) and is_set(ChapterLink) then 
        Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot;;
    end
    if is_set(Periodical) and is_set(Title) then
        Chapter = wrap( 'italic-title', Chapter );
        TransChapter = wrap( 'trans-italic-title', TransChapter );
    else
        Chapter = wrap( 'quoted-title', Chapter );
        TransChapter = wrap( 'trans-quoted-title', TransChapter );
    end
    
    local TransError = &quot;&quot;
    if is_set(TransChapter) then
        if not is_set(Chapter) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
        else
            TransChapter = &quot; &quot; .. TransChapter;
        end
    end
    
    Chapter = Chapter .. TransChapter;
    
    if is_set(Chapter) then
        if not is_set(ChapterLink) then
            if is_set(ChapterURL) then
                Chapter = externallink( ChapterURL, Chapter ) .. TransError;
                if not is_set(URL) then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif is_set(URL) then 
                Chapter = externallink( URL, Chapter ) .. TransError .. Format;
                URL = &quot;&quot;;
                Format = &quot;&quot;;
            else
                Chapter = Chapter .. TransError;
            end            
        elseif is_set(ChapterURL) then
            Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. 
                TransError;
        else
            Chapter = Chapter .. TransError;
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    elseif is_set(ChapterURL) then
        Chapter = &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. sepc .. &quot; &quot;;
    end        
    
    -- Format main title.
    if is_set(TitleLink) and is_set(Title) then
        Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
    end
    
    if is_set(Periodical) then
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    elseif inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;pressrelease&quot;}) and
            not is_set(Chapter) then
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    else
        Title = wrap( 'italic-title', Title );
        TransTitle = wrap( 'trans-italic-title', TransTitle );
    end
    
    TransError = &quot;&quot;;
    if is_set(TransTitle) then
        if not is_set(Title) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
        else
            TransTitle = &quot; &quot; .. TransTitle;
        end
    end
    
    Title = Title .. TransTitle;
    
    if is_set(Title) then
        if not is_set(TitleLink) and is_set(URL) then 
            Title = externallink( URL, Title ) .. TransError .. Format       
            URL = &quot;&quot;;
            Format = &quot;&quot;;
        else
            Title = Title .. TransError;
        end
    end
    
    if is_set(Place) then
        if sepc == '.' then
            Place = &quot; &quot; .. wrap( 'written', Place ) .. sepc .. &quot; &quot;;
        else
            Place = &quot; &quot; .. substitute( cfg.messages['written']:lower(), {Place} ) .. sepc .. &quot; &quot;;
        end
    end
    
    if is_set(Conference) then
        if is_set(ConferenceURL) then
            Conference = externallink( ConferenceURL, Conference );
        end
        Conference = &quot; &quot; .. Conference
    elseif is_set(ConferenceURL) then
        Conference = &quot; &quot; .. externallink( ConferenceURL, nil, ConferenceURLorigin );
    end
    
    if not is_set(Position) then
        local Minutes = A['Minutes'];
        if is_set(Minutes) then
            Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
        else
            local Time = A['Time'];
            if is_set(Time) then
                local TimeCaption = A['TimeCaption']
                if not is_set(TimeCaption) then
                    TimeCaption = cfg.messages['event'];
                    if sepc ~= '.' then
                        TimeCaption = TimeCaption:lower();
                    end
                end
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
            end
        end
    else
        Position = &quot; &quot; .. Position;
        At = '';
    end
    
    if not is_set(Page) then
        if is_set(Pages) then
            if is_set(Periodical) and
                not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;}) then
                Pages = &quot;: &quot; .. Pages;
            elseif tonumber(Pages) ~= nil then
                Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
            else
                Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
            end
        end
    else
        if is_set(Periodical) and
            not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;}) then
            Page = &quot;: &quot; .. Page;
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page;
        end
    end
    
    At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
    Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
    TitleType = is_set(TitleType) and (&quot; (&quot; .. TitleType .. &quot;)&quot;) or &quot;&quot;;
    TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
    Language = is_set(Language) and (&quot; &quot; .. wrap( 'language', Language )) or &quot;&quot;;
    Edition = is_set(Edition) and (&quot; &quot; .. wrap( 'edition', Edition )) or &quot;&quot;;
    Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
    Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
    OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
    Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;
    
    if is_set(Volume) then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume;
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
        end
    end
    
    ------------------------------------ totally unrelated data
    if is_set(Via) then Via = &quot; &quot; .. wrap( 'via', Via ); end
    if is_set(AccessDate) then
        local retrv_text = &quot; &quot; .. cfg.messages['retrieved']
        if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
        AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
            .. substitute( retrv_text, {AccessDate} ) .. '&lt;/span&gt;'
    end
    
    if is_set(SubscriptionRequired) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];
    end
    
    if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
    
    ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN} );

    if is_set(URL) then
        URL = &quot; &quot; .. externallink( URL, nil, URLorigin );
    end

    if is_set(Quote) then
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        Quote = sepc ..&quot; &quot; .. wrap( 'quoted-text', Quote ); 
        PostScript = &quot;&quot;;
    elseif PostScript:lower() == &quot;none&quot; then
        PostScript = &quot;&quot;;
    end
    
    local Archived
    if is_set(ArchiveURL) then
        if not is_set(ArchiveDate) then
            ArchiveDate = seterror('archive_missing_date');
        end
        if &quot;no&quot; == DeadURL then
            local arch_text = cfg.messages['archived'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
                { externallink( ArchiveURL, arch_text ), ArchiveDate } );
            if not is_set(OriginalURL) then
                Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url');                               
            end
        elseif is_set(OriginalURL) then
            local arch_text = cfg.messages['archived-dead'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text,
                { externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
        else
            local arch_text = cfg.messages['archived-missing'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
                { seterror('archive_missing_url'), ArchiveDate } );
        end
    else
        Archived = &quot;&quot;
    end
    
    local Lay
    if is_set(LayURL) then
        if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
        if is_set(LaySource) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot;;
        else
            LaySource = &quot;&quot;;
        end
        if sepc == '.' then
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;;
    end
    
    if is_set(Transcript) then
        if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
    elseif is_set(TranscriptURL) then
        Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
    end
    
    local Publisher;
    if is_set(Periodical) and
        not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;}) then
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end
        elseif is_set(PublicationPlace) then
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if is_set(PublicationDate) then
            if is_set(Publisher) then
                Publisher = Publisher .. &quot;, &quot; .. wrap( 'published', PublicationDate );
            else
                Publisher = PublicationDate;
            end
        end
        if is_set(Publisher) then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if is_set(PublicationDate) then
            PublicationDate = &quot; (&quot; .. wrap( 'published', PublicationDate ) .. &quot;)&quot;;
        end
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif is_set(PublicationPlace) then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    
    -- Several of the above rely upon detecting this as nil, so do it last.
    if is_set(Periodical) then
        if is_set(Title) or is_set(TitleNote) then 
            Periodical = sepc .. &quot; &quot; .. wrap( 'italic-title', Periodical ) 
        else 
            Periodical = wrap( 'italic-title', Periodical )
        end
    end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if inArray(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
        if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
            Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
            Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
    end
    
    if #ID_list &gt; 0 then
        ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
    else
        ID_list = ID;
    end
    
    local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
    local text;
    local pgtext = Page .. Pages .. At;
    
    if is_set(Authors) then
        if is_set(Coauthors) then
            Authors = Authors .. A['AuthorSeparator'] .. &quot; &quot; .. Coauthors
        end
        if is_set(Date) then
            Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        elseif string.sub(Authors,-1,-1) == sepc then
            Authors = Authors .. &quot; &quot;
        else
            Authors = Authors .. sepc .. &quot; &quot;
        end
        if is_set(Editors) then
            local in_text = &quot; &quot; .. cfg.messages['in'] .. &quot; &quot;
            if (sepc ~= '.') then in_text = in_text:lower() end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif is_set(Editors) then
        if is_set(Date) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
            else
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if is_set(Date) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end
        if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
            text = safejoin( {Chapter, Place, tcommon}, sepc );
            text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
            text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
            text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if is_set(PostScript) and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    if not is_set(Year) then
        if is_set(DateIn) then
            Year = selectyear( DateIn );
        elseif is_set(PublicationDate) then
            Year = selectyear( PublicationDate );
        end
    end
    
    local options = {};
    
    if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
        options.class = &quot;citation &quot; .. config.CitationClass;
    else
        options.class = &quot;citation&quot;;
    end
    
    if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if is_set(Authors) then
                for i,v in ipairs(a) do 
                    names[i] = v.last 
                    if i == 4 then break end
                end
            elseif is_set(Editors) then
                for i,v in ipairs(e) do 
                    names[i] = v.last 
                    if i == 4 then break end                
                end
            end
            names[ #names + 1 ] = Year;
            id = anchorid(names)
        end
        options.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = {};
        text = seterror('empty_citation');
        z.message_tail = {};
    end
    
    if is_set(options.id) then 
        text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    else
        text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    end        

    local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        text = text .. &quot; &quot;;
        for i,v in ipairs( z.message_tail ) do
            if is_set(v[1]) then
                if i == #z.message_tail then
                    text = text .. errorcomment( v[1], v[2] );
                else
                    text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
                end
            end
        end
    end
    
    no_tracking_cats = no_tracking_cats:lower();
    if inArray(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    local suggestions = {};
    local error_text, error_state;

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        args[k] = v;       
    end    

    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            if not validate( k ) then            
                error_text = &quot;&quot;;
                if type( k ) ~= 'string' then
                    -- Exclude empty numbered parameters
                    if v:match(&quot;%S+&quot;) ~= nil then
                        error_text, error_state = seterror( 'text_ignored', {v}, true );
                    end
                elseif validate( k:lower() ) then 
                    error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
                else
                    if #suggestions == 0 then
                        suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
                    end
                    if suggestions[ k:lower() ] ~= nil then
                        error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
                    else
                        error_text, error_state = seterror( 'parameter_ignored', {k}, true );
                    end
                end                  
                if error_text ~= '' then
                    table.insert( z.message_tail, {error_text, error_state} );
                end                
            end
            args[k] = v;
        elseif args[k] ~= nil or (k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z</text>
      <sha1>ghf1zqz8c2ac0pvfpc8oxbtq4nj2r1t</sha1>
    </revision>
    <revision>
      <id>4655</id>
      <parentid>4654</parentid>
      <timestamp>2013-04-25T20:04:54Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>oops</comment>
      <origin>4655</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="56189" sha1="e5tdq4ek1hrs0qsghm11asicf5zpyc7" xml:space="preserve">local z = {
    error_categories = {};
    error_ids = {};
    message_tail = {};
}

-- Include translation message hooks, ID and error handling configuration settings.
-- Note that require has tested to be significantly faster than loadData for this 
-- usage.  This might be a side effect of the unnecessary cloning described 
-- in bugzilla 47300.
local cfg = require( 'Module:Citation/CS1/Configuration' );

-- Contains a list of all recognized parameters
local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );

-- Whether variable is set or not
function is_set( var )
    return not (var == nil or var == '');
end

-- First set variable or nil if none
function first_set(...)
    local list = {...};
    for _, var in pairs(list) do
        if is_set( var ) then
            return var;
        end
    end
end

-- Whether needle is in haystack
function inArray( needle, haystack )
    if needle == nil then
        return false;
    end
    for n,v in ipairs( haystack ) do
        if v == needle then
            return n;
        end
    end
    return false;
end

-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
    return args and tostring( mw.message.newRawMessage( msg, args ) ) or msg;
end

-- Wraps a string using a message_list configuration taking one argument
function wrap( key, str )
    if not is_set( str ) then
        return &quot;&quot;;
    elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
        str = safeforitalics( str );
    end
    return substitute( cfg.messages[key], {str} );
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
    local origin = {};
    
    return setmetatable({
        ORIGIN = function( self, k )
            local dummy = self[k]; --force the variable to be loaded.
            return origin[k];
        end
    },
    {
        __index = function ( tbl, k )
            if origin[k] ~= nil then
                return nil;
            end
            
            local args, list, v = args, cfg.aliases[k];
            
            if list == nil then
                error( cfg.messages['unknown_argument_map'] );
            elseif type( list ) == 'string' then
                v, origin[k] = args[list], list;
            else
                v, origin[k] = selectone( args, list, 'redundant_parameters' );
                if origin[k] == nil then
                    origin[k] = '';   --Empty string, not nil;
                end
            end
            
            if v == nil then
                v = cfg.defaults[k] or &quot;&quot;;
                origin[k] = '';   --Empty string, not nil;
            end
            
            tbl = rawset( tbl, k, v );
            return v;
        end,
    });
end

-- Checks that parameter name is valid using the whitelist
function validate( name )
    name = tostring( name );
    
    -- Normal arguments
    if whitelist.basic_arguments[ name ] then
        return true;
    end
    
    -- Arguments with numbers in them
    name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );
    if whitelist.numbered_arguments[ name ] then
        return true;
    end
    
    -- Not found, argument not supported.
    return false
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
    return wrap( hidden and 'hidden-error' or 'visible-error', content );
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
    local error_state = cfg.error_conditions[ error_id ];
    
    prefix = prefix or &quot;&quot;;
    suffix = suffix or &quot;&quot;;
    
    if error_state == nil then
        error( cfg.messages['undefined_error'] );
    elseif is_set( error_state.category ) then
        table.insert( z.error_categories, error_state.category );
    end
    
    local message = substitute( error_state.message, arguments );
    
    message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
        &quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
        cfg.messages['help page label'] .. &quot;]])&quot;;
    
    z.error_ids[ error_id ] = true;
    if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
            and z.error_ids['citation_missing_title'] then
        return '', false;
    end
    
    message = table.concat({ prefix, message, suffix });
    
    if raw == true then
        return message, error_state.hidden;
    end        
        
    return errorcomment( message, error_state.hidden );
end

-- Formats a wiki style external link
function externallinkid(options)
    local url_string = options.id;
    if options.encode == true or options.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, url_string, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Formats a wiki style internal link
function internallinkid(options)
    return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, options.id, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Format an external link with error checking
function externallink( URL, label, source )
    local error_str = &quot;&quot;;
    if not is_set( label ) then
        label = URL;
        if is_set( source ) then
            error_str = seterror( 'bare_url_missing_title', { wrap( 'parameter', source ) }, false, &quot; &quot; );
        else
            error( cfg.messages[&quot;bare_url_no_origin&quot;] );
        end            
    end
    if not checkurl( URL ) then
        error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
    end
    return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safeforurl( label ), &quot;]&quot;, error_str });
end

-- Formats a link to Amazon
function amazon(id, domain)
    if not is_set(domain) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local handler = cfg.id_handlers['ASIN'];
    return externallinkid({link = handler.link,
        label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
        encode=handler.encode, separator = handler.separator})
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    local handler = cfg.id_handlers['DOI'];
    
    local text;
    if is_set(inactive) then
        text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link = handler.link, label = handler.label,
            prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then      
        cat = seterror( 'bad_doi' );
    end
    return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    local handler = cfg.id_handlers['OL'];
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    else
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode}) .. 
            ' ' .. seterror( 'bad_ol' );
    end
end

--[[
Determines whether an URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
    -- Protocol-relative or URL scheme
    return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
    return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
    isbn_str = cleanisbn( isbn_str ):gsub( &quot;-&quot;, &quot;&quot; );
    local len = isbn_str:len();
 
    if len ~= 10 and len ~= 13 then
        return false;
    end
 
    local temp = 0;
    if len == 10 then
        if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            if v == string.byte( &quot;X&quot; ) then
                temp = temp + 10*( 11 - i );
            else
                temp = temp + tonumber( string.char(v) )*(11-i);
            end
        end
        return temp % 11 == 0;
    else
        if isbn_str:match( &quot;^%d*$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
        end
        return temp % 10 == 0;
    end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
    return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
        return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
    end));
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if not is_set(str) then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        
        -- Remove newlines as they break italics.
        return str:gsub( '\n', ' ' );
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    -- Is the input a simple number?
    local num = tonumber( str ); 
    if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.floor(num) then
        return str;
    else
        -- Use formatDate to interpret more complicated formats
        local lang = mw.getContentLanguage();
        local good, result;
        good, result = pcall( lang.formatDate, lang, 'Y', str )
        if good then 
            return result;
        else
            -- Can't make sense of this input, return blank.
            return &quot;&quot;;
        end
    end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    if maximum ~= nil and maximum &lt; 1 then return &quot;&quot;, 0; end
    
    for i,person in ipairs(people) do
        if is_set(person.last) then
            local mask = person.mask
            local one
            local sep_one = sep;
            if maximum ~= nil and i &gt; maximum then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask;
                    sep_one = &quot; &quot;;
                end
            else
                one = person.last
                local first = person.first
                if is_set(first) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if is_set(person.link) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert( text, one )
            table.insert( text, sep_one )
        end
    end

    local count = #text / 2;
    if count &gt; 0 then 
        if count &gt; 1 and is_set(lastauthoramp) and not etal then
            text[#text-2] = &quot; &amp; &quot;;
        end
        text[#text] = nil; 
    end
    
    local result = table.concat(text) -- construct list
    if etal then 
        local etal_text = cfg.messages['et al'];
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result = 
        '&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
    end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
    return &quot;CITEREF&quot; .. table.concat( options );
end

-- Gets name list from the input arguments
function extractnames(args, list_name)
    local names = {};
    local i = 1;
    local last;
    
    while true do
        last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );
        if not is_set(last) then
            -- just in case someone passed in an empty parameter
            break;
        end
        names[i] = {
            last = last,
            first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i ),
            link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ),
            mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i )
        };
        i = i + 1;
    end
    return names;
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
    local id_list = {};
    for k, v in pairs( cfg.id_handlers ) do    
        v = selectone( args, v.parameters, 'redundant_parameters' );
        if is_set(v) then id_list[k] = v; end
    end
    return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
    local new_list, handler = {};
    
    function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
    
    for k, v in pairs( id_list ) do
        -- fallback to read-only cfg
        handler = setmetatable( { ['id'] = v }, fallback(k) );
        
        if handler.mode == 'external' then
            table.insert( new_list, {handler.label, externallinkid( handler ) } );
        elseif handler.mode == 'internal' then
            table.insert( new_list, {handler.label, internallinkid( handler ) } );
        elseif handler.mode ~= 'manual' then
            error( cfg.messages['unknown_ID_mode'] );
        elseif k == 'DOI' then
            table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
        elseif k == 'ASIN' then
            table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
        elseif k == 'OL' then
            table.insert( new_list, {handler.label, openlibrary( v ) } );
        elseif k == 'ISBN' then
            local ISBN = internallinkid( handler );
            if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
                ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
            end
            table.insert( new_list, {handler.label, ISBN } );                
        else
            error( cfg.messages['unknown_manual_ID'] );
        end
    end
    
    function comp( a, b )
        return a[1] &lt; b[1];
    end
    
    table.sort( new_list, comp );
    for k, v in ipairs( new_list ) do
        new_list[k] = v[2];
    end
    
    return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
    local value = nil;
    local selected = '';
    local error_list = {};
    
    if index ~= nil then index = tostring(index); end
    
    -- Handle special case of &quot;#&quot; replaced by empty string
    if index == '1' then
        for _, v in ipairs( possible ) do
            v = v:gsub( &quot;#&quot;, &quot;&quot; );
            if is_set(args[v]) then
                if value ~= nil and selected ~= v then
                    table.insert( error_list, v );
                else
                    value = args[v];
                    selected = v;
                end
            end
        end        
    end
    
    for _, v in ipairs( possible ) do
        if index ~= nil then
            v = v:gsub( &quot;#&quot;, index );
        end
        if is_set(args[v]) then
            if value ~= nil and selected ~=  v then
                table.insert( error_list, v );
            else
                value = args[v];
                selected = v;
            end
        end
    end
    
    if #error_list &gt; 0 then
        local error_str = &quot;&quot;;
        for _, k in ipairs( error_list ) do
            if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
            error_str = error_str .. wrap( 'parameter', k );
        end
        if #error_list &gt; 1 then
            error_str = error_str .. cfg.messages['parameter-final-separator'];
        else
            error_str = error_str .. cfg.messages['parameter-pair-separator'];
        end
        error_str = error_str .. wrap( 'parameter', selected );
        table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
    end
    
    return value, selected;
end

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
function COinS(data)
    if 'table' ~= type(data) or nil == next(data) then
        return '';
    end
    
    local ctx_ver = &quot;Z39.88-2004&quot;;
    
    -- treat table strictly as an array with only set values.
    local OCinSoutput = setmetatable( {}, {
        __newindex = function(self, key, value)
            if is_set(value) then
                rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
            end
        end
    });
    
    if is_set(data.Chapter) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Chapter;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    elseif is_set(data.Periodical) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
        OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    else
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
    end
    
    OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
    OCinSoutput[&quot;rft.date&quot;] = data.Date;
    OCinSoutput[&quot;rft.series&quot;] = data.Series;
    OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
    OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
    OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
    OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
    OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
    
    for k, v in pairs( data.ID_list ) do
        local id, value = cfg.id_handlers[k].COinS;
        if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
        if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
            OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
        else
            OCinSoutput[ id ] = value;
        end
    end
    
    local last, first;
    for k, v in ipairs( data.Authors ) do
        last, first = v.last, v.first;
        if k == 1 then
            if is_set(last) then
                OCinSoutput[&quot;rft.aulast&quot;] = last;
            end
            if is_set(first) then 
                OCinSoutput[&quot;rft.aufirst&quot;] = first;
            end
        end
        if is_set(last) and is_set(first) then
            OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
        elseif is_set(last) then
            OCinSoutput[&quot;rft.au&quot;] = last;
        end
    end
    
    OCinSoutput.rft_id = data.URL;
    OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
    OCinSoutput = setmetatable( OCinSoutput, nil );
    
    -- sort with version string always first, and combine.
    table.sort( OCinSoutput );
    table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
    return table.concat(OCinSoutput, &quot;&amp;&quot;);
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    --[[ 
    Load Input Parameters
    The argment_wrapper facillitates the mapping of multiple
    aliases to single internal variable.
    ]]
    local A = argument_wrapper( args );

    local i 
    local PPrefix = A['PPrefix']
    local PPPrefix = A['PPPrefix']
    if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = A['Authors'];
    local a = extractnames( args, 'AuthorList' );

    local Coauthors = A['Coauthors'];
    local Others = A['Others'];
    local Editors = A['Editors'];
    local e = extractnames( args, 'EditorList' );

    local Year = A['Year'];
    local PublicationDate = A['PublicationDate'];
    local OrigYear = A['OrigYear'];
    local Date = A['Date'];
    local LayDate = A['LayDate'];
    ------------------------------------------------- Get title data
    local Title = A['Title'];
    local BookTitle = A['BookTitle'];
    local Conference = A['Conference'];
    local TransTitle = A['TransTitle'];
    local TitleNote = A['TitleNote'];
    local TitleLink = A['TitleLink'];
    local Chapter = A['Chapter'];
    local ChapterLink = A['ChapterLink'];
    local TransChapter = A['TransChapter'];
    local TitleType = A['TitleType'];
    local ArchiveURL = A['ArchiveURL'];
    local URL = A['URL']
    local URLorigin = A:ORIGIN('URL');
    local ChapterURL = A['ChapterURL'];
    local ChapterURLorigin = A:ORIGIN('ChapterURL');
    local ConferenceURL = A['ConferenceURL'];
    local ConferenceURLorigin = A:ORIGIN('ConferenceURL');
    local Periodical = A['Periodical'];
    
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if not is_set(Chapter) then
            if not is_set(Title) then
                Title = Periodical;
                Periodical = '';
            else
                Chapter = Title
                TransChapter = TransTitle
                Title = '';
                TransTitle = '';
            end
        end
    end

    local Series = A['Series'];
    local Volume = A['Volume'];
    local Issue = A['Issue'];
    local Position = '';
    local Page, Pages, At, page_type;
    
    Page = A['Page'];
    Pages = hyphentodash( A['Pages'] );
    At = A['At'];
    
    if is_set(Page) then
        if is_set(Pages) or is_set(At) then
            Page = Page .. &quot; &quot; .. seterror('extra_pages');
            Pages = '';
            At = '';
        end
    elseif is_set(Pages) then
        if is_set(At) then
            Pages = Pages .. &quot; &quot; .. seterror('extra_pages');
            At = '';
        end
    end    
    
    local Edition = A['Edition'];
    local PublicationPlace = A['PublicationPlace']
    local Place = A['Place'];
    
    if not is_set(PublicationPlace) and is_set(Place) then
        PublicationPlace = Place;
    end
    
    if PublicationPlace == Place then Place = ''; end
    
    local PublisherName = A['PublisherName'];
    local SubscriptionRequired = A['SubscriptionRequired'];
    local Via = A['Via'];
    local AccessDate = A['AccessDate'];
    local ArchiveDate = A['ArchiveDate'];
    local Agency = A['Agency'];
    local DeadURL = A['DeadURL']
    local Language = A['Language'];
    local Format = A['Format'];
    local Ref = A['Ref'];
    
    local DoiBroken = A['DoiBroken'];
    local ID = A['ID'];
    local ASINTLD = A['ASINTLD'];
    local IgnoreISBN = A['IgnoreISBN'];

    local ID_list = extractids( args );
    
    local Quote = A['Quote'];
    local PostScript = A['PostScript'];
    local LayURL = A['LayURL'];
    local LaySource = A['LaySource'];
    local Transcript = A['Transcript'];
    local TranscriptURL = A['TranscriptURL'] 
    local TranscriptURLorigin = A:ORIGIN('TranscriptURL');
    local sepc = A['Separator'];
    local LastAuthorAmp = A['LastAuthorAmp'];
    local no_tracking_cats = A['NoTracking'];

    local this_page = mw.title.getCurrentTitle();  --Also used for COinS
    
    if not is_set(no_tracking_cats) then
        for k, v in pairs( cfg.uncategorized_namespaces ) do
            if this_page.nsText == v then
                no_tracking_cats = &quot;true&quot;;
                break;
            end
        end
    end

    if ( config.CitationClass == &quot;journal&quot; ) then
        if not is_set(URL) and is_set(ID_list['PMC']) then
            local Embargo = A['Embargo'];
            if is_set(Embargo) then
                local lang = mw.getContentLanguage();
                local good1, result1, good2, result2;
                good1, result1 = pcall( lang.formatDate, lang, 'U', Embargo );
                good2, result2 = pcall( lang.formatDate, lang, 'U' );
                
                if good1 and good2 and tonumber( result1 ) &lt; tonumber( result2 ) then 
                    URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];
                    URLorigin = cfg.id_handlers['PMC'].parameters[1];
                end
            else
                URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];
                URLorigin = cfg.id_handlers['PMC'].parameters[1];
            end
        end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if is_set(BookTitle) then
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = BookTitle;
        TitleLink = '';
        TransTitle = '';
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = A['AirDate'];
        local SeriesLink = A['SeriesLink'];
        local Season = A['Season'];
        local SeriesNumber = A['SeriesNumber'];
        local Network = A['Network'];
        local Station = A['Station'];
        local s, n = {}, {};
        local Sep = (first_set(A[&quot;SeriesSeparator&quot;], A[&quot;Separator&quot;]) or &quot;&quot;) .. &quot; &quot;;
        
        if is_set(Issue) then table.insert(s, cfg.messages[&quot;episode&quot;] .. &quot; &quot; .. Issue); Issue = ''; end
        if is_set(Season) then table.insert(s, cfg.messages[&quot;season&quot;] .. &quot; &quot; .. Season); end
        if is_set(SeriesNumber) then table.insert(s, cfg.messages[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber); end
        if is_set(Network) then table.insert(n, Network); end
        if is_set(Station) then table.insert(n, Station); end
        
        Date = Date or AirDate;
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = Series;
        TitleLink = SeriesLink;
        TransTitle = '';
        
        Series = table.concat(s, Sep);
        ID = table.concat(n, Sep);
    end
    
    -- COinS metadata (see &lt;http://ocoins.info/&gt;) for
    -- automated parsing of citation information.
    local OCinSoutput = COinS{
        ['Periodical'] = Periodical,
        ['Chapter'] = Chapter,
        ['Title'] = Title,
        ['PublicationPlace'] = PublicationPlace,
        ['Date'] = first_set(Date, Year, PublicationDate),
        ['Series'] = Series,
        ['Volume'] = Volume,
        ['Issue'] = Issue,
        ['Pages'] = first_set(Page, Pages, At),
        ['Edition'] = Edition,
        ['PublisherName'] = PublisherName,
        ['URL'] = first_set( URL, ChapterURL ),
        ['Authors'] = a,
        ['ID_list'] = ID_list,
        ['RawPage'] = this_page.prefixedText,
    };

    if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = '';
        TitleLink = '';
        TransTitle = '';
    end

    -- Now perform various field 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 not is_set(Authors) then
        local Maximum = tonumber( A['DisplayAuthors'] );
        
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #a == 9 then 
            Maximum = 8;
            table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
        elseif not is_set(Maximum) then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = A[&quot;AuthorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;AuthorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A[&quot;AuthorFormat&quot;],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if is_set(Coauthors) then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
        
        Authors = listpeople(control, a) 
    end
    
    local EditorCount
    if not is_set(Editors) then
        local Maximum = tonumber( A['DisplayEditors'] );
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #e == 4 then 
            Maximum = 3;
            table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
        elseif not is_set(Maximum) then
            Maximum = #e + 1;
        end

        local control = { 
            sep = A[&quot;EditorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;EditorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A['EditorFormat'],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };

        Editors, EditorCount = listpeople(control, e);
    else
        EditorCount = 1;
    end
    
    if not is_set(Date) then
        Date = Year;
        if is_set(Date) then
            local Month = A['Month'];
            if is_set(Month) then 
                Date = Month .. &quot; &quot; .. Date;
                local Day = A['Day']
                if is_set(Day) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    
    if inArray(PublicationDate, {Date, Year}) then PublicationDate = ''; end
    if not is_set(Date) and is_set(PublicationDate) then
        Date = PublicationDate;
        PublicationDate = '';
    end

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date;
    
    if  not is_set(URL) and
        not is_set(ChapterURL) and
        not is_set(ArchiveURL) and
        not is_set(ConferenceURL) and
        not is_set(TranscriptURL) then
        
        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
        end
        
        -- Test if accessdate is given without giving a URL
        if is_set(AccessDate) then
            table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
            AccessDate = '';
        end
        
        -- Test if format is given without giving a URL
        if is_set(Format) then
            Format = Format .. seterror( 'format_missing_url' );
        end
    end
    
    -- Test if citation has no title
    if  not is_set(Chapter) and
        not is_set(Title) and
        not is_set(Periodical) and
        not is_set(Conference) and
        not is_set(TransTitle) and
        not is_set(TransChapter) then
        table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
    end
    
    Format = is_set(Format) and &quot; (&quot; .. Format .. &quot;)&quot; or &quot;&quot;;
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if ( ArchiveURL and &quot;&quot; &lt; ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
        end
    end
    
    -- Format chapter / article title
    if is_set(Chapter) and is_set(ChapterLink) then 
        Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot;;
    end
    if is_set(Periodical) and is_set(Title) then
        Chapter = wrap( 'italic-title', Chapter );
        TransChapter = wrap( 'trans-italic-title', TransChapter );
    else
        Chapter = wrap( 'quoted-title', Chapter );
        TransChapter = wrap( 'trans-quoted-title', TransChapter );
    end
    
    local TransError = &quot;&quot;
    if is_set(TransChapter) then
        if not is_set(Chapter) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
        else
            TransChapter = &quot; &quot; .. TransChapter;
        end
    end
    
    Chapter = Chapter .. TransChapter;
    
    if is_set(Chapter) then
        if not is_set(ChapterLink) then
            if is_set(ChapterURL) then
                Chapter = externallink( ChapterURL, Chapter ) .. TransError;
                if not is_set(URL) then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif is_set(URL) then 
                Chapter = externallink( URL, Chapter ) .. TransError .. Format;
                URL = &quot;&quot;;
                Format = &quot;&quot;;
            else
                Chapter = Chapter .. TransError;
            end            
        elseif is_set(ChapterURL) then
            Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. 
                TransError;
        else
            Chapter = Chapter .. TransError;
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    elseif is_set(ChapterURL) then
        Chapter = &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. sepc .. &quot; &quot;;
    end        
    
    -- Format main title.
    if is_set(TitleLink) and is_set(Title) then
        Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
    end
    
    if is_set(Periodical) then
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    elseif inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;pressrelease&quot;}) and
            not is_set(Chapter) then
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    else
        Title = wrap( 'italic-title', Title );
        TransTitle = wrap( 'trans-italic-title', TransTitle );
    end
    
    TransError = &quot;&quot;;
    if is_set(TransTitle) then
        if not is_set(Title) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
        else
            TransTitle = &quot; &quot; .. TransTitle;
        end
    end
    
    Title = Title .. TransTitle;
    
    if is_set(Title) then
        if not is_set(TitleLink) and is_set(URL) then 
            Title = externallink( URL, Title ) .. TransError .. Format       
            URL = &quot;&quot;;
            Format = &quot;&quot;;
        else
            Title = Title .. TransError;
        end
    end
    
    if is_set(Place) then
        if sepc == '.' then
            Place = &quot; &quot; .. wrap( 'written', Place ) .. sepc .. &quot; &quot;;
        else
            Place = &quot; &quot; .. substitute( cfg.messages['written']:lower(), {Place} ) .. sepc .. &quot; &quot;;
        end
    end
    
    if is_set(Conference) then
        if is_set(ConferenceURL) then
            Conference = externallink( ConferenceURL, Conference );
        end
        Conference = &quot; &quot; .. Conference
    elseif is_set(ConferenceURL) then
        Conference = &quot; &quot; .. externallink( ConferenceURL, nil, ConferenceURLorigin );
    end
    
    if not is_set(Position) then
        local Minutes = A['Minutes'];
        if is_set(Minutes) then
            Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
        else
            local Time = A['Time'];
            if is_set(Time) then
                local TimeCaption = A['TimeCaption']
                if not is_set(TimeCaption) then
                    TimeCaption = cfg.messages['event'];
                    if sepc ~= '.' then
                        TimeCaption = TimeCaption:lower();
                    end
                end
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
            end
        end
    else
        Position = &quot; &quot; .. Position;
        At = '';
    end
    
    if not is_set(Page) then
        if is_set(Pages) then
            if is_set(Periodical) and
                not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;}) then
                Pages = &quot;: &quot; .. Pages;
            elseif tonumber(Pages) ~= nil then
                Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
            else
                Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
            end
        end
    else
        if is_set(Periodical) and
            not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;}) then
            Page = &quot;: &quot; .. Page;
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page;
        end
    end
    
    At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
    Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
    TitleType = is_set(TitleType) and (&quot; (&quot; .. TitleType .. &quot;)&quot;) or &quot;&quot;;
    TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
    Language = is_set(Language) and (&quot; &quot; .. wrap( 'language', Language )) or &quot;&quot;;
    Edition = is_set(Edition) and (&quot; &quot; .. wrap( 'edition', Edition )) or &quot;&quot;;
    Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
    Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
    OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
    Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;
    
    if is_set(Volume) then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume;
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
        end
    end
    
    ------------------------------------ totally unrelated data
    if is_set(Via) then Via = &quot; &quot; .. wrap( 'via', Via ); end
    if is_set(AccessDate) then
        local retrv_text = &quot; &quot; .. cfg.messages['retrieved']
        if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
        AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
            .. substitute( retrv_text, {AccessDate} ) .. '&lt;/span&gt;'
    end
    
    if is_set(SubscriptionRequired) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];
    end
    
    if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
    
    ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN} );

    if is_set(URL) then
        URL = &quot; &quot; .. externallink( URL, nil, URLorigin );
    end

    if is_set(Quote) then
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        Quote = sepc ..&quot; &quot; .. wrap( 'quoted-text', Quote ); 
        PostScript = &quot;&quot;;
    elseif PostScript:lower() == &quot;none&quot; then
        PostScript = &quot;&quot;;
    end
    
    local Archived
    if is_set(ArchiveURL) then
        if not is_set(ArchiveDate) then
            ArchiveDate = seterror('archive_missing_date');
        end
        if &quot;no&quot; == DeadURL then
            local arch_text = cfg.messages['archived'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
                { externallink( ArchiveURL, arch_text ), ArchiveDate } );
            if not is_set(OriginalURL) then
                Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url');                               
            end
        elseif is_set(OriginalURL) then
            local arch_text = cfg.messages['archived-dead'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text,
                { externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
        else
            local arch_text = cfg.messages['archived-missing'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
                { seterror('archive_missing_url'), ArchiveDate } );
        end
    else
        Archived = &quot;&quot;
    end
    
    local Lay
    if is_set(LayURL) then
        if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
        if is_set(LaySource) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot;;
        else
            LaySource = &quot;&quot;;
        end
        if sepc == '.' then
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;;
    end
    
    if is_set(Transcript) then
        if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
    elseif is_set(TranscriptURL) then
        Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
    end
    
    local Publisher;
    if is_set(Periodical) and
        not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;}) then
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end
        elseif is_set(PublicationPlace) then
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if is_set(PublicationDate) then
            if is_set(Publisher) then
                Publisher = Publisher .. &quot;, &quot; .. wrap( 'published', PublicationDate );
            else
                Publisher = PublicationDate;
            end
        end
        if is_set(Publisher) then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if is_set(PublicationDate) then
            PublicationDate = &quot; (&quot; .. wrap( 'published', PublicationDate ) .. &quot;)&quot;;
        end
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif is_set(PublicationPlace) then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    
    -- Several of the above rely upon detecting this as nil, so do it last.
    if is_set(Periodical) then
        if is_set(Title) or is_set(TitleNote) then 
            Periodical = sepc .. &quot; &quot; .. wrap( 'italic-title', Periodical ) 
        else 
            Periodical = wrap( 'italic-title', Periodical )
        end
    end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if inArray(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
        if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
            Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
            Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
    end
    
    if #ID_list &gt; 0 then
        ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
    else
        ID_list = ID;
    end
    
    local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
    local text;
    local pgtext = Page .. Pages .. At;
    
    if is_set(Authors) then
        if is_set(Coauthors) then
            Authors = Authors .. A['AuthorSeparator'] .. &quot; &quot; .. Coauthors
        end
        if is_set(Date) then
            Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        elseif string.sub(Authors,-1,-1) == sepc then
            Authors = Authors .. &quot; &quot;
        else
            Authors = Authors .. sepc .. &quot; &quot;
        end
        if is_set(Editors) then
            local in_text = &quot; &quot; .. cfg.messages['in'] .. &quot; &quot;
            if (sepc ~= '.') then in_text = in_text:lower() end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif is_set(Editors) then
        if is_set(Date) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
            else
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if is_set(Date) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end
        if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
            text = safejoin( {Chapter, Place, tcommon}, sepc );
            text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
            text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
            text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if is_set(PostScript) and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    if not is_set(Year) then
        if is_set(DateIn) then
            Year = selectyear( DateIn );
        elseif is_set(PublicationDate) then
            Year = selectyear( PublicationDate );
        end
    end
    
    local options = {};
    
    if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
        options.class = &quot;citation &quot; .. config.CitationClass;
    else
        options.class = &quot;citation&quot;;
    end
    
    if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if is_set(Authors) then
                for i,v in ipairs(a) do 
                    names[i] = v.last 
                    if i == 4 then break end
                end
            elseif is_set(Editors) then
                for i,v in ipairs(e) do 
                    names[i] = v.last 
                    if i == 4 then break end                
                end
            end
            names[ #names + 1 ] = Year;
            id = anchorid(names)
        end
        options.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = {};
        text = seterror('empty_citation');
        z.message_tail = {};
    end
    
    if is_set(options.id) then 
        text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    else
        text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    end        

    local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        text = text .. &quot; &quot;;
        for i,v in ipairs( z.message_tail ) do
            if is_set(v[1]) then
                if i == #z.message_tail then
                    text = text .. errorcomment( v[1], v[2] );
                else
                    text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
                end
            end
        end
    end
    
    no_tracking_cats = no_tracking_cats:lower();
    if inArray(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    local suggestions = {};
    local error_text, error_state;

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        args[k] = v;       
    end    

    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            if not validate( k ) then            
                error_text = &quot;&quot;;
                if type( k ) ~= 'string' then
                    -- Exclude empty numbered parameters
                    if v:match(&quot;%S+&quot;) ~= nil then
                        error_text, error_state = seterror( 'text_ignored', {v}, true );
                    end
                elseif validate( k:lower() ) then 
                    error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
                else
                    if #suggestions == 0 then
                        suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
                    end
                    if suggestions[ k:lower() ] ~= nil then
                        error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
                    else
                        error_text, error_state = seterror( 'parameter_ignored', {k}, true );
                    end
                end                  
                if error_text ~= '' then
                    table.insert( z.message_tail, {error_text, error_state} );
                end                
            end
            args[k] = v;
        elseif args[k] ~= nil or (k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z</text>
      <sha1>e5tdq4ek1hrs0qsghm11asicf5zpyc7</sha1>
    </revision>
    <revision>
      <id>4656</id>
      <parentid>4655</parentid>
      <timestamp>2013-04-29T16:53:20Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>sync to sandbox, fixes a problem that can cause a script error in rare circumstances</comment>
      <origin>4656</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="56222" sha1="i5z5yioadyrmhvkjxchyc5d9kuxklkh" xml:space="preserve">local z = {
    error_categories = {};
    error_ids = {};
    message_tail = {};
}

-- Include translation message hooks, ID and error handling configuration settings.
-- Note that require has tested to be significantly faster than loadData for this 
-- usage.  This might be a side effect of the unnecessary cloning described 
-- in bugzilla 47300.
local cfg = require( 'Module:Citation/CS1/Configuration' );

-- Contains a list of all recognized parameters
local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );

-- Whether variable is set or not
function is_set( var )
    return not (var == nil or var == '');
end

-- First set variable or nil if none
function first_set(...)
    local list = {...};
    for _, var in pairs(list) do
        if is_set( var ) then
            return var;
        end
    end
end

-- Whether needle is in haystack
function inArray( needle, haystack )
    if needle == nil then
        return false;
    end
    for n,v in ipairs( haystack ) do
        if v == needle then
            return n;
        end
    end
    return false;
end

-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
    return args and tostring( mw.message.newRawMessage( msg, args ) ) or msg;
end

-- Wraps a string using a message_list configuration taking one argument
function wrap( key, str )
    if not is_set( str ) then
        return &quot;&quot;;
    elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
        str = safeforitalics( str );
    end
    return substitute( cfg.messages[key], {str} );
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
    local origin = {};
    
    return setmetatable({
        ORIGIN = function( self, k )
            local dummy = self[k]; --force the variable to be loaded.
            return origin[k];
        end
    },
    {
        __index = function ( tbl, k )
            if origin[k] ~= nil then
                return nil;
            end
            
            local args, list, v = args, cfg.aliases[k];
            
            if list == nil then
                error( cfg.messages['unknown_argument_map'] );
            elseif type( list ) == 'string' then
                v, origin[k] = args[list], list;
            else
                v, origin[k] = selectone( args, list, 'redundant_parameters' );
                if origin[k] == nil then
                    origin[k] = '';   --Empty string, not nil;
                end
            end
            
            if v == nil then
                v = cfg.defaults[k] or &quot;&quot;;
                origin[k] = '';   --Empty string, not nil;
            end
            
            tbl = rawset( tbl, k, v );
            return v;
        end,
    });
end

-- Checks that parameter name is valid using the whitelist
function validate( name )
    name = tostring( name );
    
    -- Normal arguments
    if whitelist.basic_arguments[ name ] then
        return true;
    end
    
    -- Arguments with numbers in them
    name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );
    if whitelist.numbered_arguments[ name ] then
        return true;
    end
    
    -- Not found, argument not supported.
    return false
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
    return wrap( hidden and 'hidden-error' or 'visible-error', content );
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
    local error_state = cfg.error_conditions[ error_id ];
    
    prefix = prefix or &quot;&quot;;
    suffix = suffix or &quot;&quot;;
    
    if error_state == nil then
        error( cfg.messages['undefined_error'] );
    elseif is_set( error_state.category ) then
        table.insert( z.error_categories, error_state.category );
    end
    
    local message = substitute( error_state.message, arguments );
    
    message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
        &quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
        cfg.messages['help page label'] .. &quot;]])&quot;;
    
    z.error_ids[ error_id ] = true;
    if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
            and z.error_ids['citation_missing_title'] then
        return '', false;
    end
    
    message = table.concat({ prefix, message, suffix });
    
    if raw == true then
        return message, error_state.hidden;
    end        
        
    return errorcomment( message, error_state.hidden );
end

-- Formats a wiki style external link
function externallinkid(options)
    local url_string = options.id;
    if options.encode == true or options.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, url_string, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Formats a wiki style internal link
function internallinkid(options)
    return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, options.id, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Format an external link with error checking
function externallink( URL, label, source )
    local error_str = &quot;&quot;;
    if not is_set( label ) then
        label = URL;
        if is_set( source ) then
            error_str = seterror( 'bare_url_missing_title', { wrap( 'parameter', source ) }, false, &quot; &quot; );
        else
            error( cfg.messages[&quot;bare_url_no_origin&quot;] );
        end            
    end
    if not checkurl( URL ) then
        error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
    end
    return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safeforurl( label ), &quot;]&quot;, error_str });
end

-- Formats a link to Amazon
function amazon(id, domain)
    if not is_set(domain) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local handler = cfg.id_handlers['ASIN'];
    return externallinkid({link = handler.link,
        label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
        encode=handler.encode, separator = handler.separator})
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    local handler = cfg.id_handlers['DOI'];
    
    local text;
    if is_set(inactive) then
        text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link = handler.link, label = handler.label,
            prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then      
        cat = seterror( 'bad_doi' );
    end
    return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    local handler = cfg.id_handlers['OL'];
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    else
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode}) .. 
            ' ' .. seterror( 'bad_ol' );
    end
end

--[[
Determines whether an URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
    -- Protocol-relative or URL scheme
    return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
    return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
    isbn_str = cleanisbn( isbn_str ):gsub( &quot;-&quot;, &quot;&quot; );
    local len = isbn_str:len();
 
    if len ~= 10 and len ~= 13 then
        return false;
    end
 
    local temp = 0;
    if len == 10 then
        if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            if v == string.byte( &quot;X&quot; ) then
                temp = temp + 10*( 11 - i );
            else
                temp = temp + tonumber( string.char(v) )*(11-i);
            end
        end
        return temp % 11 == 0;
    else
        if isbn_str:match( &quot;^%d*$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
        end
        return temp % 10 == 0;
    end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
    return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
        return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
    end));
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if not is_set(str) then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        
        -- Remove newlines as they break italics.
        return str:gsub( '\n', ' ' );
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    -- Is the input a simple number?
    local num = tonumber( str ); 
    if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.floor(num) then
        return str;
    else
        -- Use formatDate to interpret more complicated formats
        local lang = mw.getContentLanguage();
        local good, result;
        good, result = pcall( lang.formatDate, lang, 'Y', str )
        if good then 
            return result;
        else
            -- Can't make sense of this input, return blank.
            return &quot;&quot;;
        end
    end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    if maximum ~= nil and maximum &lt; 1 then return &quot;&quot;, 0; end
    
    for i,person in ipairs(people) do
        if is_set(person.last) then
            local mask = person.mask
            local one
            local sep_one = sep;
            if maximum ~= nil and i &gt; maximum then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask;
                    sep_one = &quot; &quot;;
                end
            else
                one = person.last
                local first = person.first
                if is_set(first) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if is_set(person.link) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert( text, one )
            table.insert( text, sep_one )
        end
    end

    local count = #text / 2;
    if count &gt; 0 then 
        if count &gt; 1 and is_set(lastauthoramp) and not etal then
            text[#text-2] = &quot; &amp; &quot;;
        end
        text[#text] = nil; 
    end
    
    local result = table.concat(text) -- construct list
    if etal then 
        local etal_text = cfg.messages['et al'];
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result = 
        '&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
    end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
    return &quot;CITEREF&quot; .. table.concat( options );
end

-- Gets name list from the input arguments
function extractnames(args, list_name)
    local names = {};
    local i = 1;
    local last;
    
    while true do
        last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );
        if not is_set(last) then
            -- just in case someone passed in an empty parameter
            break;
        end
        names[i] = {
            last = last,
            first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i ),
            link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ),
            mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i )
        };
        i = i + 1;
    end
    return names;
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
    local id_list = {};
    for k, v in pairs( cfg.id_handlers ) do    
        v = selectone( args, v.parameters, 'redundant_parameters' );
        if is_set(v) then id_list[k] = v; end
    end
    return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
    local new_list, handler = {};
    
    function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
    
    for k, v in pairs( id_list ) do
        -- fallback to read-only cfg
        handler = setmetatable( { ['id'] = v }, fallback(k) );
        
        if handler.mode == 'external' then
            table.insert( new_list, {handler.label, externallinkid( handler ) } );
        elseif handler.mode == 'internal' then
            table.insert( new_list, {handler.label, internallinkid( handler ) } );
        elseif handler.mode ~= 'manual' then
            error( cfg.messages['unknown_ID_mode'] );
        elseif k == 'DOI' then
            table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
        elseif k == 'ASIN' then
            table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
        elseif k == 'OL' then
            table.insert( new_list, {handler.label, openlibrary( v ) } );
        elseif k == 'ISBN' then
            local ISBN = internallinkid( handler );
            if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
                ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
            end
            table.insert( new_list, {handler.label, ISBN } );                
        else
            error( cfg.messages['unknown_manual_ID'] );
        end
    end
    
    function comp( a, b )
        return a[1] &lt; b[1];
    end
    
    table.sort( new_list, comp );
    for k, v in ipairs( new_list ) do
        new_list[k] = v[2];
    end
    
    return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
    local value = nil;
    local selected = '';
    local error_list = {};
    
    if index ~= nil then index = tostring(index); end
    
    -- Handle special case of &quot;#&quot; replaced by empty string
    if index == '1' then
        for _, v in ipairs( possible ) do
            v = v:gsub( &quot;#&quot;, &quot;&quot; );
            if is_set(args[v]) then
                if value ~= nil and selected ~= v then
                    table.insert( error_list, v );
                else
                    value = args[v];
                    selected = v;
                end
            end
        end        
    end
    
    for _, v in ipairs( possible ) do
        if index ~= nil then
            v = v:gsub( &quot;#&quot;, index );
        end
        if is_set(args[v]) then
            if value ~= nil and selected ~=  v then
                table.insert( error_list, v );
            else
                value = args[v];
                selected = v;
            end
        end
    end
    
    if #error_list &gt; 0 then
        local error_str = &quot;&quot;;
        for _, k in ipairs( error_list ) do
            if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
            error_str = error_str .. wrap( 'parameter', k );
        end
        if #error_list &gt; 1 then
            error_str = error_str .. cfg.messages['parameter-final-separator'];
        else
            error_str = error_str .. cfg.messages['parameter-pair-separator'];
        end
        error_str = error_str .. wrap( 'parameter', selected );
        table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
    end
    
    return value, selected;
end

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
function COinS(data)
    if 'table' ~= type(data) or nil == next(data) then
        return '';
    end
    
    local ctx_ver = &quot;Z39.88-2004&quot;;
    
    -- treat table strictly as an array with only set values.
    local OCinSoutput = setmetatable( {}, {
        __newindex = function(self, key, value)
            if is_set(value) then
                rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
            end
        end
    });
    
    if is_set(data.Chapter) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Chapter;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    elseif is_set(data.Periodical) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
        OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    else
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
    end
    
    OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
    OCinSoutput[&quot;rft.date&quot;] = data.Date;
    OCinSoutput[&quot;rft.series&quot;] = data.Series;
    OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
    OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
    OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
    OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
    OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
    
    for k, v in pairs( data.ID_list ) do
        local id, value = cfg.id_handlers[k].COinS;
        if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
        if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
            OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
        else
            OCinSoutput[ id ] = value;
        end
    end
    
    local last, first;
    for k, v in ipairs( data.Authors ) do
        last, first = v.last, v.first;
        if k == 1 then
            if is_set(last) then
                OCinSoutput[&quot;rft.aulast&quot;] = last;
            end
            if is_set(first) then 
                OCinSoutput[&quot;rft.aufirst&quot;] = first;
            end
        end
        if is_set(last) and is_set(first) then
            OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
        elseif is_set(last) then
            OCinSoutput[&quot;rft.au&quot;] = last;
        end
    end
    
    OCinSoutput.rft_id = data.URL;
    OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
    OCinSoutput = setmetatable( OCinSoutput, nil );
    
    -- sort with version string always first, and combine.
    table.sort( OCinSoutput );
    table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
    return table.concat(OCinSoutput, &quot;&amp;&quot;);
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    --[[ 
    Load Input Parameters
    The argment_wrapper facillitates the mapping of multiple
    aliases to single internal variable.
    ]]
    local A = argument_wrapper( args );

    local i 
    local PPrefix = A['PPrefix']
    local PPPrefix = A['PPPrefix']
    if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = A['Authors'];
    local a = extractnames( args, 'AuthorList' );

    local Coauthors = A['Coauthors'];
    local Others = A['Others'];
    local Editors = A['Editors'];
    local e = extractnames( args, 'EditorList' );

    local Year = A['Year'];
    local PublicationDate = A['PublicationDate'];
    local OrigYear = A['OrigYear'];
    local Date = A['Date'];
    local LayDate = A['LayDate'];
    ------------------------------------------------- Get title data
    local Title = A['Title'];
    local BookTitle = A['BookTitle'];
    local Conference = A['Conference'];
    local TransTitle = A['TransTitle'];
    local TitleNote = A['TitleNote'];
    local TitleLink = A['TitleLink'];
    local Chapter = A['Chapter'];
    local ChapterLink = A['ChapterLink'];
    local TransChapter = A['TransChapter'];
    local TitleType = A['TitleType'];
    local ArchiveURL = A['ArchiveURL'];
    local URL = A['URL']
    local URLorigin = A:ORIGIN('URL');
    local ChapterURL = A['ChapterURL'];
    local ChapterURLorigin = A:ORIGIN('ChapterURL');
    local ConferenceURL = A['ConferenceURL'];
    local ConferenceURLorigin = A:ORIGIN('ConferenceURL');
    local Periodical = A['Periodical'];
    
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if not is_set(Chapter) then
            if not is_set(Title) then
                Title = Periodical;
                Periodical = '';
            else
                Chapter = Title
                TransChapter = TransTitle
                Title = '';
                TransTitle = '';
            end
        end
    end

    local Series = A['Series'];
    local Volume = A['Volume'];
    local Issue = A['Issue'];
    local Position = '';
    local Page, Pages, At, page_type;
    
    Page = A['Page'];
    Pages = hyphentodash( A['Pages'] );
    At = A['At'];
    
    if is_set(Page) then
        if is_set(Pages) or is_set(At) then
            Page = Page .. &quot; &quot; .. seterror('extra_pages');
            Pages = '';
            At = '';
        end
    elseif is_set(Pages) then
        if is_set(At) then
            Pages = Pages .. &quot; &quot; .. seterror('extra_pages');
            At = '';
        end
    end    
    
    local Edition = A['Edition'];
    local PublicationPlace = A['PublicationPlace']
    local Place = A['Place'];
    
    if not is_set(PublicationPlace) and is_set(Place) then
        PublicationPlace = Place;
    end
    
    if PublicationPlace == Place then Place = ''; end
    
    local PublisherName = A['PublisherName'];
    local SubscriptionRequired = A['SubscriptionRequired'];
    local Via = A['Via'];
    local AccessDate = A['AccessDate'];
    local ArchiveDate = A['ArchiveDate'];
    local Agency = A['Agency'];
    local DeadURL = A['DeadURL']
    local Language = A['Language'];
    local Format = A['Format'];
    local Ref = A['Ref'];
    
    local DoiBroken = A['DoiBroken'];
    local ID = A['ID'];
    local ASINTLD = A['ASINTLD'];
    local IgnoreISBN = A['IgnoreISBN'];

    local ID_list = extractids( args );
    
    local Quote = A['Quote'];
    local PostScript = A['PostScript'];
    local LayURL = A['LayURL'];
    local LaySource = A['LaySource'];
    local Transcript = A['Transcript'];
    local TranscriptURL = A['TranscriptURL'] 
    local TranscriptURLorigin = A:ORIGIN('TranscriptURL');
    local sepc = A['Separator'];
    local LastAuthorAmp = A['LastAuthorAmp'];
    local no_tracking_cats = A['NoTracking'];

    local this_page = mw.title.getCurrentTitle();  --Also used for COinS
    
    if not is_set(no_tracking_cats) then
        for k, v in pairs( cfg.uncategorized_namespaces ) do
            if this_page.nsText == v then
                no_tracking_cats = &quot;true&quot;;
                break;
            end
        end
    end

    if ( config.CitationClass == &quot;journal&quot; ) then
        if not is_set(URL) and is_set(ID_list['PMC']) then
            local Embargo = A['Embargo'];
            if is_set(Embargo) then
                local lang = mw.getContentLanguage();
                local good1, result1, good2, result2;
                good1, result1 = pcall( lang.formatDate, lang, 'U', Embargo );
                good2, result2 = pcall( lang.formatDate, lang, 'U' );
                
                if good1 and good2 and tonumber( result1 ) &lt; tonumber( result2 ) then 
                    URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];
                    URLorigin = cfg.id_handlers['PMC'].parameters[1];
                end
            else
                URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];
                URLorigin = cfg.id_handlers['PMC'].parameters[1];
            end
        end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if is_set(BookTitle) then
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = BookTitle;
        TitleLink = '';
        TransTitle = '';
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = A['AirDate'];
        local SeriesLink = A['SeriesLink'];
        local Season = A['Season'];
        local SeriesNumber = A['SeriesNumber'];
        local Network = A['Network'];
        local Station = A['Station'];
        local s, n = {}, {};
        local Sep = (first_set(A[&quot;SeriesSeparator&quot;], A[&quot;Separator&quot;]) or &quot;&quot;) .. &quot; &quot;;
        
        if is_set(Issue) then table.insert(s, cfg.messages[&quot;episode&quot;] .. &quot; &quot; .. Issue); Issue = ''; end
        if is_set(Season) then table.insert(s, cfg.messages[&quot;season&quot;] .. &quot; &quot; .. Season); end
        if is_set(SeriesNumber) then table.insert(s, cfg.messages[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber); end
        if is_set(Network) then table.insert(n, Network); end
        if is_set(Station) then table.insert(n, Station); end
        
        Date = Date or AirDate;
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = Series;
        TitleLink = SeriesLink;
        TransTitle = '';
        
        Series = table.concat(s, Sep);
        ID = table.concat(n, Sep);
    end
    
    -- COinS metadata (see &lt;http://ocoins.info/&gt;) for
    -- automated parsing of citation information.
    local OCinSoutput = COinS{
        ['Periodical'] = Periodical,
        ['Chapter'] = Chapter,
        ['Title'] = Title,
        ['PublicationPlace'] = PublicationPlace,
        ['Date'] = first_set(Date, Year, PublicationDate),
        ['Series'] = Series,
        ['Volume'] = Volume,
        ['Issue'] = Issue,
        ['Pages'] = first_set(Page, Pages, At),
        ['Edition'] = Edition,
        ['PublisherName'] = PublisherName,
        ['URL'] = first_set( URL, ChapterURL ),
        ['Authors'] = a,
        ['ID_list'] = ID_list,
        ['RawPage'] = this_page.prefixedText,
    };

    if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = '';
        TitleLink = '';
        TransTitle = '';
    end

    -- Now perform various field 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 not is_set(Authors) then
        local Maximum = tonumber( A['DisplayAuthors'] );
        
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #a == 9 then 
            Maximum = 8;
            table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
        elseif not is_set(Maximum) then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = A[&quot;AuthorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;AuthorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A[&quot;AuthorFormat&quot;],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if is_set(Coauthors) then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
        
        Authors = listpeople(control, a) 
    end
    
    local EditorCount
    if not is_set(Editors) then
        local Maximum = tonumber( A['DisplayEditors'] );
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #e == 4 then 
            Maximum = 3;
            table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
        elseif not is_set(Maximum) then
            Maximum = #e + 1;
        end

        local control = { 
            sep = A[&quot;EditorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;EditorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A['EditorFormat'],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };

        Editors, EditorCount = listpeople(control, e);
    else
        EditorCount = 1;
    end
    
    if not is_set(Date) then
        Date = Year;
        if is_set(Date) then
            local Month = A['Month'];
            if is_set(Month) then 
                Date = Month .. &quot; &quot; .. Date;
                local Day = A['Day']
                if is_set(Day) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    
    if inArray(PublicationDate, {Date, Year}) then PublicationDate = ''; end
    if not is_set(Date) and is_set(PublicationDate) then
        Date = PublicationDate;
        PublicationDate = '';
    end

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date;
    
    if  not is_set(URL) and
        not is_set(ChapterURL) and
        not is_set(ArchiveURL) and
        not is_set(ConferenceURL) and
        not is_set(TranscriptURL) then
        
        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
        end
        
        -- Test if accessdate is given without giving a URL
        if is_set(AccessDate) then
            table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
            AccessDate = '';
        end
        
        -- Test if format is given without giving a URL
        if is_set(Format) then
            Format = Format .. seterror( 'format_missing_url' );
        end
    end
    
    -- Test if citation has no title
    if  not is_set(Chapter) and
        not is_set(Title) and
        not is_set(Periodical) and
        not is_set(Conference) and
        not is_set(TransTitle) and
        not is_set(TransChapter) then
        table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
    end
    
    Format = is_set(Format) and &quot; (&quot; .. Format .. &quot;)&quot; or &quot;&quot;;
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if is_set( ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
            URLorigin = A:ORIGIN('ArchiveURL')
        end
    end
    
    -- Format chapter / article title
    if is_set(Chapter) and is_set(ChapterLink) then 
        Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot;;
    end
    if is_set(Periodical) and is_set(Title) then
        Chapter = wrap( 'italic-title', Chapter );
        TransChapter = wrap( 'trans-italic-title', TransChapter );
    else
        Chapter = wrap( 'quoted-title', Chapter );
        TransChapter = wrap( 'trans-quoted-title', TransChapter );
    end
    
    local TransError = &quot;&quot;
    if is_set(TransChapter) then
        if not is_set(Chapter) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
        else
            TransChapter = &quot; &quot; .. TransChapter;
        end
    end
    
    Chapter = Chapter .. TransChapter;
    
    if is_set(Chapter) then
        if not is_set(ChapterLink) then
            if is_set(ChapterURL) then
                Chapter = externallink( ChapterURL, Chapter ) .. TransError;
                if not is_set(URL) then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif is_set(URL) then 
                Chapter = externallink( URL, Chapter ) .. TransError .. Format;
                URL = &quot;&quot;;
                Format = &quot;&quot;;
            else
                Chapter = Chapter .. TransError;
            end            
        elseif is_set(ChapterURL) then
            Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. 
                TransError;
        else
            Chapter = Chapter .. TransError;
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    elseif is_set(ChapterURL) then
        Chapter = &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. sepc .. &quot; &quot;;
    end        
    
    -- Format main title.
    if is_set(TitleLink) and is_set(Title) then
        Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
    end
    
    if is_set(Periodical) then
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    elseif inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;pressrelease&quot;}) and
            not is_set(Chapter) then
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    else
        Title = wrap( 'italic-title', Title );
        TransTitle = wrap( 'trans-italic-title', TransTitle );
    end
    
    TransError = &quot;&quot;;
    if is_set(TransTitle) then
        if not is_set(Title) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
        else
            TransTitle = &quot; &quot; .. TransTitle;
        end
    end
    
    Title = Title .. TransTitle;
    
    if is_set(Title) then
        if not is_set(TitleLink) and is_set(URL) then 
            Title = externallink( URL, Title ) .. TransError .. Format       
            URL = &quot;&quot;;
            Format = &quot;&quot;;
        else
            Title = Title .. TransError;
        end
    end
    
    if is_set(Place) then
        if sepc == '.' then
            Place = &quot; &quot; .. wrap( 'written', Place ) .. sepc .. &quot; &quot;;
        else
            Place = &quot; &quot; .. substitute( cfg.messages['written']:lower(), {Place} ) .. sepc .. &quot; &quot;;
        end
    end
    
    if is_set(Conference) then
        if is_set(ConferenceURL) then
            Conference = externallink( ConferenceURL, Conference );
        end
        Conference = &quot; &quot; .. Conference
    elseif is_set(ConferenceURL) then
        Conference = &quot; &quot; .. externallink( ConferenceURL, nil, ConferenceURLorigin );
    end
    
    if not is_set(Position) then
        local Minutes = A['Minutes'];
        if is_set(Minutes) then
            Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
        else
            local Time = A['Time'];
            if is_set(Time) then
                local TimeCaption = A['TimeCaption']
                if not is_set(TimeCaption) then
                    TimeCaption = cfg.messages['event'];
                    if sepc ~= '.' then
                        TimeCaption = TimeCaption:lower();
                    end
                end
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
            end
        end
    else
        Position = &quot; &quot; .. Position;
        At = '';
    end
    
    if not is_set(Page) then
        if is_set(Pages) then
            if is_set(Periodical) and
                not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;}) then
                Pages = &quot;: &quot; .. Pages;
            elseif tonumber(Pages) ~= nil then
                Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
            else
                Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
            end
        end
    else
        if is_set(Periodical) and
            not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;}) then
            Page = &quot;: &quot; .. Page;
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page;
        end
    end
    
    At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
    Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
    TitleType = is_set(TitleType) and (&quot; (&quot; .. TitleType .. &quot;)&quot;) or &quot;&quot;;
    TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
    Language = is_set(Language) and (&quot; &quot; .. wrap( 'language', Language )) or &quot;&quot;;
    Edition = is_set(Edition) and (&quot; &quot; .. wrap( 'edition', Edition )) or &quot;&quot;;
    Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
    Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
    OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
    Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;
    
    if is_set(Volume) then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume;
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
        end
    end
    
    ------------------------------------ totally unrelated data
    if is_set(Via) then Via = &quot; &quot; .. wrap( 'via', Via ); end
    if is_set(AccessDate) then
        local retrv_text = &quot; &quot; .. cfg.messages['retrieved']
        if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
        AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
            .. substitute( retrv_text, {AccessDate} ) .. '&lt;/span&gt;'
    end
    
    if is_set(SubscriptionRequired) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];
    end
    
    if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
    
    ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN} );

    if is_set(URL) then
        URL = &quot; &quot; .. externallink( URL, nil, URLorigin );
    end

    if is_set(Quote) then
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        Quote = sepc ..&quot; &quot; .. wrap( 'quoted-text', Quote ); 
        PostScript = &quot;&quot;;
    elseif PostScript:lower() == &quot;none&quot; then
        PostScript = &quot;&quot;;
    end
    
    local Archived
    if is_set(ArchiveURL) then
        if not is_set(ArchiveDate) then
            ArchiveDate = seterror('archive_missing_date');
        end
        if &quot;no&quot; == DeadURL then
            local arch_text = cfg.messages['archived'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
                { externallink( ArchiveURL, arch_text ), ArchiveDate } );
            if not is_set(OriginalURL) then
                Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url');                               
            end
        elseif is_set(OriginalURL) then
            local arch_text = cfg.messages['archived-dead'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text,
                { externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
        else
            local arch_text = cfg.messages['archived-missing'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
                { seterror('archive_missing_url'), ArchiveDate } );
        end
    else
        Archived = &quot;&quot;
    end
    
    local Lay
    if is_set(LayURL) then
        if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
        if is_set(LaySource) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot;;
        else
            LaySource = &quot;&quot;;
        end
        if sepc == '.' then
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;;
    end
    
    if is_set(Transcript) then
        if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
    elseif is_set(TranscriptURL) then
        Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
    end
    
    local Publisher;
    if is_set(Periodical) and
        not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;}) then
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end
        elseif is_set(PublicationPlace) then
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if is_set(PublicationDate) then
            if is_set(Publisher) then
                Publisher = Publisher .. &quot;, &quot; .. wrap( 'published', PublicationDate );
            else
                Publisher = PublicationDate;
            end
        end
        if is_set(Publisher) then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if is_set(PublicationDate) then
            PublicationDate = &quot; (&quot; .. wrap( 'published', PublicationDate ) .. &quot;)&quot;;
        end
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif is_set(PublicationPlace) then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    
    -- Several of the above rely upon detecting this as nil, so do it last.
    if is_set(Periodical) then
        if is_set(Title) or is_set(TitleNote) then 
            Periodical = sepc .. &quot; &quot; .. wrap( 'italic-title', Periodical ) 
        else 
            Periodical = wrap( 'italic-title', Periodical )
        end
    end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if inArray(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
        if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
            Language, Edition, Publisher, Agency, Volume, Issue, Position}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
            Volume, Issue, Others, Edition, Publisher, Agency, Position}, sepc );
    end
    
    if #ID_list &gt; 0 then
        ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
    else
        ID_list = ID;
    end
    
    local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
    local text;
    local pgtext = Page .. Pages .. At;
    
    if is_set(Authors) then
        if is_set(Coauthors) then
            Authors = Authors .. A['AuthorSeparator'] .. &quot; &quot; .. Coauthors
        end
        if is_set(Date) then
            Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        elseif string.sub(Authors,-1,-1) == sepc then
            Authors = Authors .. &quot; &quot;
        else
            Authors = Authors .. sepc .. &quot; &quot;
        end
        if is_set(Editors) then
            local in_text = &quot; &quot; .. cfg.messages['in'] .. &quot; &quot;
            if (sepc ~= '.') then in_text = in_text:lower() end
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = in_text .. Editors .. &quot; &quot;
                else Editors = in_text .. Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif is_set(Editors) then
        if is_set(Date) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
            else
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if is_set(Date) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end
        if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
            text = safejoin( {Chapter, Place, tcommon}, sepc );
            text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
            text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
            text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if is_set(PostScript) and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    if not is_set(Year) then
        if is_set(DateIn) then
            Year = selectyear( DateIn );
        elseif is_set(PublicationDate) then
            Year = selectyear( PublicationDate );
        end
    end
    
    local options = {};
    
    if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
        options.class = &quot;citation &quot; .. config.CitationClass;
    else
        options.class = &quot;citation&quot;;
    end
    
    if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if is_set(Authors) then
                for i,v in ipairs(a) do 
                    names[i] = v.last 
                    if i == 4 then break end
                end
            elseif is_set(Editors) then
                for i,v in ipairs(e) do 
                    names[i] = v.last 
                    if i == 4 then break end                
                end
            end
            names[ #names + 1 ] = Year;
            id = anchorid(names)
        end
        options.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = {};
        text = seterror('empty_citation');
        z.message_tail = {};
    end
    
    if is_set(options.id) then 
        text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    else
        text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    end        

    local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        text = text .. &quot; &quot;;
        for i,v in ipairs( z.message_tail ) do
            if is_set(v[1]) then
                if i == #z.message_tail then
                    text = text .. errorcomment( v[1], v[2] );
                else
                    text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
                end
            end
        end
    end
    
    no_tracking_cats = no_tracking_cats:lower();
    if inArray(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    local suggestions = {};
    local error_text, error_state;

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        args[k] = v;       
    end    

    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            if not validate( k ) then            
                error_text = &quot;&quot;;
                if type( k ) ~= 'string' then
                    -- Exclude empty numbered parameters
                    if v:match(&quot;%S+&quot;) ~= nil then
                        error_text, error_state = seterror( 'text_ignored', {v}, true );
                    end
                elseif validate( k:lower() ) then 
                    error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
                else
                    if #suggestions == 0 then
                        suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
                    end
                    if suggestions[ k:lower() ] ~= nil then
                        error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
                    else
                        error_text, error_state = seterror( 'parameter_ignored', {k}, true );
                    end
                end                  
                if error_text ~= '' then
                    table.insert( z.message_tail, {error_text, error_state} );
                end                
            end
            args[k] = v;
        elseif args[k] ~= nil or (k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z</text>
      <sha1>i5z5yioadyrmhvkjxchyc5d9kuxklkh</sha1>
    </revision>
    <revision>
      <id>4657</id>
      <parentid>4656</parentid>
      <timestamp>2013-05-20T07:19:35Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>sync to sandbox, changes in support of additional modes and minro bug fixes</comment>
      <origin>4657</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="58417" sha1="0y692ueid98uzigij9jdg66y5xx1azc" xml:space="preserve">local z = {
    error_categories = {};
    error_ids = {};
    message_tail = {};
}

-- Include translation message hooks, ID and error handling configuration settings.
local cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );

-- Contains a list of all recognized parameters
local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );

-- Whether variable is set or not
function is_set( var )
    return not (var == nil or var == '');
end

-- First set variable or nil if none
function first_set(...)
    local list = {...};
    for _, var in pairs(list) do
        if is_set( var ) then
            return var;
        end
    end
end

-- Whether needle is in haystack
function inArray( needle, haystack )
    if needle == nil then
        return false;
    end
    for n,v in ipairs( haystack ) do
        if v == needle then
            return n;
        end
    end
    return false;
end

-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
    return args and tostring( mw.message.newRawMessage( msg, args ) ) or msg;
end

-- Wraps a string using a message_list configuration taking one argument
function wrap( key, str, lower )
    if not is_set( str ) then
        return &quot;&quot;;
    elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
        str = safeforitalics( str );
    end
    if lower == true then
        return substitute( cfg.messages[key]:lower(), {str} );
    else
        return substitute( cfg.messages[key], {str} );
    end        
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
    local origin = {};
    
    return setmetatable({
        ORIGIN = function( self, k )
            local dummy = self[k]; --force the variable to be loaded.
            return origin[k];
        end
    },
    {
        __index = function ( tbl, k )
            if origin[k] ~= nil then
                return nil;
            end
            
            local args, list, v = args, cfg.aliases[k];
            
            if type( list ) == 'table' then
                v, origin[k] = selectone( args, list, 'redundant_parameters' );
                if origin[k] == nil then
                    origin[k] = ''; -- Empty string, not nil
                end
            elseif list ~= nil then
                v, origin[k] = args[list], list;
            else
                -- maybe let through instead of raising an error?
                -- v, origin[k] = args[k], k;
                error( cfg.messages['unknown_argument_map'] );
            end
            
            -- Empty strings, not nil;
            if v == nil then
                v = cfg.defaults[k] or '';
                origin[k] = '';
            end
            
            tbl = rawset( tbl, k, v );
            return v;
        end,
    });
end

-- Checks that parameter name is valid using the whitelist
function validate( name )
    name = tostring( name );
    
    -- Normal arguments
    if whitelist.basic_arguments[ name ] then
        return true;
    end
    
    -- Arguments with numbers in them
    name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );
    if whitelist.numbered_arguments[ name ] then
        return true;
    end
    
    -- Not found, argument not supported.
    return false
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
    return wrap( hidden and 'hidden-error' or 'visible-error', content );
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
    local error_state = cfg.error_conditions[ error_id ];
    
    prefix = prefix or &quot;&quot;;
    suffix = suffix or &quot;&quot;;
    
    if error_state == nil then
        error( cfg.messages['undefined_error'] );
    elseif is_set( error_state.category ) then
        table.insert( z.error_categories, error_state.category );
    end
    
    local message = substitute( error_state.message, arguments );
    
    message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
        &quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
        cfg.messages['help page label'] .. &quot;]])&quot;;
    
    z.error_ids[ error_id ] = true;
    if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
            and z.error_ids['citation_missing_title'] then
        return '', false;
    end
    
    message = table.concat({ prefix, message, suffix });
    
    if raw == true then
        return message, error_state.hidden;
    end        
        
    return errorcomment( message, error_state.hidden );
end

-- Formats a wiki style external link
function externallinkid(options)
    local url_string = options.id;
    if options.encode == true or options.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, url_string, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Formats a wiki style internal link
function internallinkid(options)
    return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, options.id, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Format an external link with error checking
function externallink( URL, label, source )
    local error_str = &quot;&quot;;
    if not is_set( label ) then
        label = URL;
        if is_set( source ) then
            error_str = seterror( 'bare_url_missing_title', { wrap( 'parameter', source ) }, false, &quot; &quot; );
        else
            error( cfg.messages[&quot;bare_url_no_origin&quot;] );
        end            
    end
    if not checkurl( URL ) then
        error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
    end
    return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safeforurl( label ), &quot;]&quot;, error_str });
end

-- Formats a link to Amazon
function amazon(id, domain)
    if not is_set(domain) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local handler = cfg.id_handlers['ASIN'];
    return externallinkid({link = handler.link,
        label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
        encode=handler.encode, separator = handler.separator})
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    local handler = cfg.id_handlers['DOI'];
    
    local text;
    if is_set(inactive) then
        text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link = handler.link, label = handler.label,
            prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then      
        cat = seterror( 'bad_doi' );
    end
    return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    local handler = cfg.id_handlers['OL'];
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    else
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode}) .. 
            ' ' .. seterror( 'bad_ol' );
    end
end

--[[
Determines whether an URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
    -- Protocol-relative or URL scheme
    return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
    return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
    isbn_str = cleanisbn( isbn_str ):gsub( &quot;-&quot;, &quot;&quot; );
    local len = isbn_str:len();
 
    if len ~= 10 and len ~= 13 then
        return false;
    end
 
    local temp = 0;
    if len == 10 then
        if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            if v == string.byte( &quot;X&quot; ) then
                temp = temp + 10*( 11 - i );
            else
                temp = temp + tonumber( string.char(v) )*(11-i);
            end
        end
        return temp % 11 == 0;
    else
        if isbn_str:match( &quot;^%d*$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
        end
        return temp % 10 == 0;
    end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
    return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
        return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
    end));
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if not is_set(str) then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        
        -- Remove newlines as they break italics.
        return str:gsub( '\n', ' ' );
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    -- Is the input a simple number?
    local num = tonumber( str ); 
    if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.floor(num) then
        return str;
    else
        -- Use formatDate to interpret more complicated formats
        local lang = mw.getContentLanguage();
        local good, result;
        good, result = pcall( lang.formatDate, lang, 'Y', str )
        if good then 
            return result;
        else
            -- Can't make sense of this input, return blank.
            return &quot;&quot;;
        end
    end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    if maximum ~= nil and maximum &lt; 1 then return &quot;&quot;, 0; end
    
    for i,person in ipairs(people) do
        if is_set(person.last) then
            local mask = person.mask
            local one
            local sep_one = sep;
            if maximum ~= nil and i &gt; maximum then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask;
                    sep_one = &quot; &quot;;
                end
            else
                one = person.last
                local first = person.first
                if is_set(first) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if is_set(person.link) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert( text, one )
            table.insert( text, sep_one )
        end
    end

    local count = #text / 2;
    if count &gt; 0 then 
        if count &gt; 1 and is_set(lastauthoramp) and not etal then
            text[#text-2] = &quot; &amp; &quot;;
        end
        text[#text] = nil; 
    end
    
    local result = table.concat(text) -- construct list
    if etal then 
        local etal_text = cfg.messages['et al'];
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result = 
        '&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
    end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
    return &quot;CITEREF&quot; .. table.concat( options );
end

-- Gets name list from the input arguments
function extractnames(args, list_name)
    local names = {};
    local i = 1;
    local last;
    
    while true do
        last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );
        if not is_set(last) then
            -- just in case someone passed in an empty parameter
            break;
        end
        names[i] = {
            last = last,
            first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i ),
            link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ),
            mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i )
        };
        i = i + 1;
    end
    return names;
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
    local id_list = {};
    for k, v in pairs( cfg.id_handlers ) do    
        v = selectone( args, v.parameters, 'redundant_parameters' );
        if is_set(v) then id_list[k] = v; end
    end
    return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
    local new_list, handler = {};
    
    function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
    
    for k, v in pairs( id_list ) do
        -- fallback to read-only cfg
        handler = setmetatable( { ['id'] = v }, fallback(k) );
        
        if handler.mode == 'external' then
            table.insert( new_list, {handler.label, externallinkid( handler ) } );
        elseif handler.mode == 'internal' then
            table.insert( new_list, {handler.label, internallinkid( handler ) } );
        elseif handler.mode ~= 'manual' then
            error( cfg.messages['unknown_ID_mode'] );
        elseif k == 'DOI' then
            table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
        elseif k == 'ASIN' then
            table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
        elseif k == 'OL' then
            table.insert( new_list, {handler.label, openlibrary( v ) } );
        elseif k == 'ISBN' then
            local ISBN = internallinkid( handler );
            if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
                ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
            end
            table.insert( new_list, {handler.label, ISBN } );                
        else
            error( cfg.messages['unknown_manual_ID'] );
        end
    end
    
    function comp( a, b )
        return a[1] &lt; b[1];
    end
    
    table.sort( new_list, comp );
    for k, v in ipairs( new_list ) do
        new_list[k] = v[2];
    end
    
    return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
    local value = nil;
    local selected = '';
    local error_list = {};
    
    if index ~= nil then index = tostring(index); end
    
    -- Handle special case of &quot;#&quot; replaced by empty string
    if index == '1' then
        for _, v in ipairs( possible ) do
            v = v:gsub( &quot;#&quot;, &quot;&quot; );
            if is_set(args[v]) then
                if value ~= nil and selected ~= v then
                    table.insert( error_list, v );
                else
                    value = args[v];
                    selected = v;
                end
            end
        end        
    end
    
    for _, v in ipairs( possible ) do
        if index ~= nil then
            v = v:gsub( &quot;#&quot;, index );
        end
        if is_set(args[v]) then
            if value ~= nil and selected ~=  v then
                table.insert( error_list, v );
            else
                value = args[v];
                selected = v;
            end
        end
    end
    
    if #error_list &gt; 0 then
        local error_str = &quot;&quot;;
        for _, k in ipairs( error_list ) do
            if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
            error_str = error_str .. wrap( 'parameter', k );
        end
        if #error_list &gt; 1 then
            error_str = error_str .. cfg.messages['parameter-final-separator'];
        else
            error_str = error_str .. cfg.messages['parameter-pair-separator'];
        end
        error_str = error_str .. wrap( 'parameter', selected );
        table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
    end
    
    return value, selected;
end

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
function COinS(data)
    if 'table' ~= type(data) or nil == next(data) then
        return '';
    end
    
    local ctx_ver = &quot;Z39.88-2004&quot;;
    
    -- treat table strictly as an array with only set values.
    local OCinSoutput = setmetatable( {}, {
        __newindex = function(self, key, value)
            if is_set(value) then
                rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
            end
        end
    });
    
    if is_set(data.Chapter) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Chapter;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    elseif is_set(data.Periodical) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
        OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    else
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
    end
    
    OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
    OCinSoutput[&quot;rft.date&quot;] = data.Date;
    OCinSoutput[&quot;rft.series&quot;] = data.Series;
    OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
    OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
    OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
    OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
    OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
    
    for k, v in pairs( data.ID_list ) do
        local id, value = cfg.id_handlers[k].COinS;
        if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
        if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
            OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
        else
            OCinSoutput[ id ] = value;
        end
    end
    
    local last, first;
    for k, v in ipairs( data.Authors ) do
        last, first = v.last, v.first;
        if k == 1 then
            if is_set(last) then
                OCinSoutput[&quot;rft.aulast&quot;] = last;
            end
            if is_set(first) then 
                OCinSoutput[&quot;rft.aufirst&quot;] = first;
            end
        end
        if is_set(last) and is_set(first) then
            OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
        elseif is_set(last) then
            OCinSoutput[&quot;rft.au&quot;] = last;
        end
    end
    
    OCinSoutput.rft_id = data.URL;
    OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
    OCinSoutput = setmetatable( OCinSoutput, nil );
    
    -- sort with version string always first, and combine.
    table.sort( OCinSoutput );
    table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
    return table.concat(OCinSoutput, &quot;&amp;&quot;);
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    --[[ 
    Load Input Parameters
    The argment_wrapper facillitates the mapping of multiple
    aliases to single internal variable.
    ]]
    local A = argument_wrapper( args );

    local i 
    local PPrefix = A['PPrefix']
    local PPPrefix = A['PPPrefix']
    if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = A['Authors'];
    local a = extractnames( args, 'AuthorList' );

    local Coauthors = A['Coauthors'];
    local Others = A['Others'];
    local Editors = A['Editors'];
    local e = extractnames( args, 'EditorList' );

    local Year = A['Year'];
    local PublicationDate = A['PublicationDate'];
    local OrigYear = A['OrigYear'];
    local Date = A['Date'];
    local LayDate = A['LayDate'];
    ------------------------------------------------- Get title data
    local Title = A['Title'];
    local BookTitle = A['BookTitle'];
    local Conference = A['Conference'];
    local TransTitle = A['TransTitle'];
    local TitleNote = A['TitleNote'];
    local TitleLink = A['TitleLink'];
    local Chapter = A['Chapter'];
    local ChapterLink = A['ChapterLink'];
    local TransChapter = A['TransChapter'];
    local TitleType = A['TitleType'];
    local ArchiveURL = A['ArchiveURL'];
    local URL = A['URL']
    local URLorigin = A:ORIGIN('URL');
    local ChapterURL = A['ChapterURL'];
    local ChapterURLorigin = A:ORIGIN('ChapterURL');
    local ConferenceURL = A['ConferenceURL'];
    local ConferenceURLorigin = A:ORIGIN('ConferenceURL');
    local Periodical = A['Periodical'];
    
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if not is_set(Chapter) then
            if not is_set(Title) then
                Title = Periodical;
                Periodical = '';
            else
                Chapter = Title
                TransChapter = TransTitle
                Title = '';
                TransTitle = '';
            end
        end
    end

    local Series = A['Series'];
    local Volume = A['Volume'];
    local Issue = A['Issue'];
    local Position = '';
    local Page, Pages, At, page_type;
    
    Page = A['Page'];
    Pages = hyphentodash( A['Pages'] );
    At = A['At'];
    
    if is_set(Page) then
        if is_set(Pages) or is_set(At) then
            Page = Page .. &quot; &quot; .. seterror('extra_pages');
            Pages = '';
            At = '';
        end
    elseif is_set(Pages) then
        if is_set(At) then
            Pages = Pages .. &quot; &quot; .. seterror('extra_pages');
            At = '';
        end
    end    
    
    local Edition = A['Edition'];
    local PublicationPlace = A['PublicationPlace']
    local Place = A['Place'];
    
    if not is_set(PublicationPlace) and is_set(Place) then
        PublicationPlace = Place;
    end
    
    if PublicationPlace == Place then Place = ''; end
    
    local PublisherName = A['PublisherName'];
    local SubscriptionRequired = A['SubscriptionRequired'];
    local Via = A['Via'];
    local AccessDate = A['AccessDate'];
    local ArchiveDate = A['ArchiveDate'];
    local Agency = A['Agency'];
    local DeadURL = A['DeadURL']
    local Language = A['Language'];
    local Format = A['Format'];
    local Ref = A['Ref'];
    
    local DoiBroken = A['DoiBroken'];
    local ID = A['ID'];
    local ASINTLD = A['ASINTLD'];
    local IgnoreISBN = A['IgnoreISBN'];

    local ID_list = extractids( args );
    
    local Quote = A['Quote'];
    local PostScript = A['PostScript'];
    local LayURL = A['LayURL'];
    local LaySource = A['LaySource'];
    local Transcript = A['Transcript'];
    local TranscriptURL = A['TranscriptURL'] 
    local TranscriptURLorigin = A:ORIGIN('TranscriptURL');
    local sepc = A['Separator'];
    local LastAuthorAmp = A['LastAuthorAmp'];
    local no_tracking_cats = A['NoTracking'];

    local use_lowercase = ( sepc ~= '.' );
    local this_page = mw.title.getCurrentTitle();  --Also used for COinS
    
    if not is_set(no_tracking_cats) then
        for k, v in pairs( cfg.uncategorized_namespaces ) do
            if this_page.nsText == v then
                no_tracking_cats = &quot;true&quot;;
                break;
            end
        end
    end

    if ( config.CitationClass == &quot;journal&quot; ) then
        if not is_set(URL) and is_set(ID_list['PMC']) then
            local Embargo = A['Embargo'];
            if is_set(Embargo) then
                local lang = mw.getContentLanguage();
                local good1, result1, good2, result2;
                good1, result1 = pcall( lang.formatDate, lang, 'U', Embargo );
                good2, result2 = pcall( lang.formatDate, lang, 'U' );
                
                if good1 and good2 and tonumber( result1 ) &lt; tonumber( result2 ) then 
                    URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];
                    URLorigin = cfg.id_handlers['PMC'].parameters[1];
                end
            else
                URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];
                URLorigin = cfg.id_handlers['PMC'].parameters[1];
            end
        end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if is_set(BookTitle) then
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = BookTitle;
        TitleLink = '';
        TransTitle = '';
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = A['AirDate'];
        local SeriesLink = A['SeriesLink'];
        local Season = A['Season'];
        local SeriesNumber = A['SeriesNumber'];
        local Network = A['Network'];
        local Station = A['Station'];
        local s, n = {}, {};
        local Sep = (first_set(A[&quot;SeriesSeparator&quot;], A[&quot;Separator&quot;]) or &quot;&quot;) .. &quot; &quot;;
        
        if is_set(Issue) then table.insert(s, cfg.messages[&quot;episode&quot;] .. &quot; &quot; .. Issue); Issue = ''; end
        if is_set(Season) then table.insert(s, cfg.messages[&quot;season&quot;] .. &quot; &quot; .. Season); end
        if is_set(SeriesNumber) then table.insert(s, cfg.messages[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber); end
        if is_set(Network) then table.insert(n, Network); end
        if is_set(Station) then table.insert(n, Station); end
        
        Date = Date or AirDate;
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = Series;
        TitleLink = SeriesLink;
        TransTitle = '';
        
        Series = table.concat(s, Sep);
        ID = table.concat(n, Sep);
    end
    
    -- COinS metadata (see &lt;http://ocoins.info/&gt;) for
    -- automated parsing of citation information.
    local OCinSoutput = COinS{
        ['Periodical'] = Periodical,
        ['Chapter'] = Chapter,
        ['Title'] = Title,
        ['PublicationPlace'] = PublicationPlace,
        ['Date'] = first_set(Date, Year, PublicationDate),
        ['Series'] = Series,
        ['Volume'] = Volume,
        ['Issue'] = Issue,
        ['Pages'] = first_set(Page, Pages, At),
        ['Edition'] = Edition,
        ['PublisherName'] = PublisherName,
        ['URL'] = first_set( URL, ChapterURL ),
        ['Authors'] = a,
        ['ID_list'] = ID_list,
        ['RawPage'] = this_page.prefixedText,
    };

    if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = '';
        TitleLink = '';
        TransTitle = '';
    end

    -- Now perform various field 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 not is_set(Authors) then
        local Maximum = tonumber( A['DisplayAuthors'] );
        
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #a == 9 then 
            Maximum = 8;
            table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
        elseif not is_set(Maximum) then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = A[&quot;AuthorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;AuthorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A[&quot;AuthorFormat&quot;],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if is_set(Coauthors) then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
        
        Authors = listpeople(control, a) 
    end

    local EditorCount
    if not is_set(Editors) then
        local Maximum = tonumber( A['DisplayEditors'] );
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #e == 4 then 
            Maximum = 3;
            table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
        elseif not is_set(Maximum) then
            Maximum = #e + 1;
        end

        local control = { 
            sep = A[&quot;EditorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;EditorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A['EditorFormat'],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };

        Editors, EditorCount = listpeople(control, e);
    else
        EditorCount = 1;
    end

    local Cartography = &quot;&quot;;
    local Scale = &quot;&quot;;
    if config.CitationClass == &quot;map&quot; then
        if not is_set( Authors ) and is_set( PublisherName ) then
            Authors = PublisherName;
            PublisherName = &quot;&quot;;
        end
        Cartography = A['Cartography'];
        if is_set( Cartography ) then
            Cartography = sepc .. &quot; &quot; .. wrap( 'cartography', Cartography, use_lowercase );
        end        
        Scale = A['Scale'];
        if is_set( Scale ) then
            Scale = sepc .. &quot; &quot; .. Scale;
        end        
    end
    
    if not is_set(Date) then
        Date = Year;
        if is_set(Date) then
            local Month = A['Month'];
            if is_set(Month) then 
                Date = Month .. &quot; &quot; .. Date;
                local Day = A['Day']
                if is_set(Day) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    
    if inArray(PublicationDate, {Date, Year}) then PublicationDate = ''; end
    if not is_set(Date) and is_set(PublicationDate) then
        Date = PublicationDate;
        PublicationDate = '';
    end

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date;
    
    if  not is_set(URL) and
        not is_set(ChapterURL) and
        not is_set(ArchiveURL) and
        not is_set(ConferenceURL) and
        not is_set(TranscriptURL) then
        
        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
        end
        
        -- Test if accessdate is given without giving a URL
        if is_set(AccessDate) then
            table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
            AccessDate = '';
        end
        
        -- Test if format is given without giving a URL
        if is_set(Format) then
            Format = Format .. seterror( 'format_missing_url' );
        end
    end
    
    -- Test if citation has no title
    if  not is_set(Chapter) and
        not is_set(Title) and
        not is_set(Periodical) and
        not is_set(Conference) and
        not is_set(TransTitle) and
        not is_set(TransChapter) then
        table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
    end
    
    Format = is_set(Format) and &quot; (&quot; .. Format .. &quot;)&quot; or &quot;&quot;;
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if is_set( ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
            URLorigin = A:ORIGIN('ArchiveURL')
        end
    end
    
    -- Format chapter / article title
    if is_set(Chapter) and is_set(ChapterLink) then 
        Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot;;
    end
    if is_set(Periodical) and is_set(Title) then
        Chapter = wrap( 'italic-title', Chapter );
        TransChapter = wrap( 'trans-italic-title', TransChapter );
    else
        Chapter = wrap( 'quoted-title', Chapter );
        TransChapter = wrap( 'trans-quoted-title', TransChapter );
    end
    
    local TransError = &quot;&quot;
    if is_set(TransChapter) then
        if not is_set(Chapter) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
        else
            TransChapter = &quot; &quot; .. TransChapter;
        end
    end
    
    Chapter = Chapter .. TransChapter;
    
    if is_set(Chapter) then
        if not is_set(ChapterLink) then
            if is_set(ChapterURL) then
                Chapter = externallink( ChapterURL, Chapter ) .. TransError;
                if not is_set(URL) then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif is_set(URL) then 
                Chapter = externallink( URL, Chapter ) .. TransError .. Format;
                URL = &quot;&quot;;
                Format = &quot;&quot;;
            else
                Chapter = Chapter .. TransError;
            end            
        elseif is_set(ChapterURL) then
            Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. 
                TransError;
        else
            Chapter = Chapter .. TransError;
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    elseif is_set(ChapterURL) then
        Chapter = &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. sepc .. &quot; &quot;;
    end        
    
    -- Format main title.
    if is_set(TitleLink) and is_set(Title) then
        Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
    end
    
    if is_set(Periodical) then
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    elseif inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;pressrelease&quot;,&quot;conference&quot;}) and
            not is_set(Chapter) then
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    else
        Title = wrap( 'italic-title', Title );
        TransTitle = wrap( 'trans-italic-title', TransTitle );
    end
    
    TransError = &quot;&quot;;
    if is_set(TransTitle) then
        if not is_set(Title) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
        else
            TransTitle = &quot; &quot; .. TransTitle;
        end
    end
    
    Title = Title .. TransTitle;
    
    if is_set(Title) then
        if not is_set(TitleLink) and is_set(URL) then 
            Title = externallink( URL, Title ) .. TransError .. Format       
            URL = &quot;&quot;;
            Format = &quot;&quot;;
        else
            Title = Title .. TransError;
        end
    end
    
    if is_set(Place) then
        Place = &quot; &quot; .. wrap( 'written', Place, use_lowercase ) .. sepc .. &quot; &quot;;
    end
    
    if is_set(Conference) then
        if is_set(ConferenceURL) then
            Conference = externallink( ConferenceURL, Conference );
        end
        Conference = sepc .. &quot; &quot; .. Conference
    elseif is_set(ConferenceURL) then
        Conference = sepc .. &quot; &quot; .. externallink( ConferenceURL, nil, ConferenceURLorigin );
    end
    
    if not is_set(Position) then
        local Minutes = A['Minutes'];
        if is_set(Minutes) then
            Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
        else
            local Time = A['Time'];
            if is_set(Time) then
                local TimeCaption = A['TimeCaption']
                if not is_set(TimeCaption) then
                    TimeCaption = cfg.messages['event'];
                    if sepc ~= '.' then
                        TimeCaption = TimeCaption:lower();
                    end
                end
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
            end
        end
    else
        Position = &quot; &quot; .. Position;
        At = '';
    end
    
    if not is_set(Page) then
        if is_set(Pages) then
            if is_set(Periodical) and
                not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;}) then
                Pages = &quot;: &quot; .. Pages;
            elseif tonumber(Pages) ~= nil then
                Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
            else
                Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
            end
        end
    else
        if is_set(Periodical) and
            not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;}) then
            Page = &quot;: &quot; .. Page;
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page;
        end
    end
    
    At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
    Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
    if config.CitationClass == 'map' then
        local Section = A['Section'];
        local Inset = A['Inset'];
        if first_set( Pages, Page, At ) ~= nil or sepc ~= '.' then
            if is_set( Section ) then
                Section = &quot;, &quot; .. wrap( 'section', Section, true );
            end
            if is_set( Inset ) then
                Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
            end
        else
            if is_set( Section ) then
                Section = sepc .. &quot; &quot; .. wrap( 'section', Section, use_lowercase );
                if is_set( Inset ) then
                    Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
                end
            elseif is_set( Inset ) then
                Inset = sepc .. &quot; &quot; .. wrap( 'inset', Inset, use_lowercase );
            end            
        end            
        At = At .. Section .. Inset;        
    end    
    
    Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
    TitleType = is_set(TitleType) and (&quot; (&quot; .. TitleType .. &quot;)&quot;) or &quot;&quot;;
    TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
    Language = is_set(Language) and (&quot; &quot; .. wrap( 'language', Language )) or &quot;&quot;;
    Edition = is_set(Edition) and (&quot; &quot; .. wrap( 'edition', Edition )) or &quot;&quot;;
    Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
    Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
    OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
    Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;
    
    if is_set(Volume) then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume;
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
        end
    end
    
    ------------------------------------ totally unrelated data
    -- Mimic {{subscription required}} template; 
    if is_set(Via) then
        Via = &quot; &quot; .. wrap( 'via', Via );
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription']; --citation always requires subscription if 'via' parameter is used
    elseif is_set(SubscriptionRequired) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription_no_via']; --here when 'via' parameter not used but 'subscription' is
    end

    if is_set(AccessDate) then
        local retrv_text = &quot; &quot; .. cfg.messages['retrieved']
        if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
        AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
            .. substitute( retrv_text, {AccessDate} ) .. '&lt;/span&gt;'
    end
    
    if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
    
    ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN} );

    if is_set(URL) then
        URL = &quot; &quot; .. externallink( URL, nil, URLorigin );
    end

    if is_set(Quote) then
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        Quote = sepc ..&quot; &quot; .. wrap( 'quoted-text', Quote ); 
        PostScript = &quot;&quot;;
    elseif PostScript:lower() == &quot;none&quot; then
        PostScript = &quot;&quot;;
    end
    
    local Archived
    if is_set(ArchiveURL) then
        if not is_set(ArchiveDate) then
            ArchiveDate = seterror('archive_missing_date');
        end
        if &quot;no&quot; == DeadURL then
            local arch_text = cfg.messages['archived'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
                { externallink( ArchiveURL, arch_text ), ArchiveDate } );
            if not is_set(OriginalURL) then
                Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url');                               
            end
        elseif is_set(OriginalURL) then
            local arch_text = cfg.messages['archived-dead'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text,
                { externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
        else
            local arch_text = cfg.messages['archived-missing'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
                { seterror('archive_missing_url'), ArchiveDate } );
        end
    else
        Archived = &quot;&quot;
    end
    
    local Lay
    if is_set(LayURL) then
        if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
        if is_set(LaySource) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot;;
        else
            LaySource = &quot;&quot;;
        end
        if sepc == '.' then
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;;
    end
    
    if is_set(Transcript) then
        if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
    elseif is_set(TranscriptURL) then
        Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
    end
    
    local Publisher;
    if is_set(Periodical) and
        not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;}) then
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end
        elseif is_set(PublicationPlace) then
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if is_set(PublicationDate) then
            if is_set(Publisher) then
                Publisher = Publisher .. &quot;, &quot; .. wrap( 'published', PublicationDate );
            else
                Publisher = PublicationDate;
            end
        end
        if is_set(Publisher) then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if is_set(PublicationDate) then
            PublicationDate = &quot; (&quot; .. wrap( 'published', PublicationDate ) .. &quot;)&quot;;
        end
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif is_set(PublicationPlace) then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    
    -- Several of the above rely upon detecting this as nil, so do it last.
    if is_set(Periodical) then
        if is_set(Title) or is_set(TitleNote) then 
            Periodical = sepc .. &quot; &quot; .. wrap( 'italic-title', Periodical ) 
        else 
            Periodical = wrap( 'italic-title', Periodical )
        end
    end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if inArray(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
        if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, 
            Language, Cartography, Edition, Publisher, Agency, Volume, Issue}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, Language, 
            Volume, Issue, Others, Cartography, Edition, Publisher, Agency}, sepc );
    end
    
    if #ID_list &gt; 0 then
        ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
    else
        ID_list = ID;
    end
    
    local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
    local text;
    local pgtext = Position .. Page .. Pages .. At;
    
    if is_set(Authors) then
        if is_set(Coauthors) then
            Authors = Authors .. A['AuthorSeparator'] .. &quot; &quot; .. Coauthors
        end
        if is_set(Date) then
            Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        elseif string.sub(Authors,-1,-1) == sepc then
            Authors = Authors .. &quot; &quot;
        else
            Authors = Authors .. sepc .. &quot; &quot;
        end
        if is_set(Editors) then
            local in_text = &quot; &quot;;
            local post_text = &quot;&quot;;
            if is_set(Chapter) then
                in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
            else
                if EditorCount &lt;= 1 then
                    post_text = &quot;, &quot; .. cfg.messages['editor'];
                else
                    post_text = &quot;, &quot; .. cfg.messages['editors'];
                end
            end 
            if (sepc ~= '.') then in_text = in_text:lower() end
            Editors = in_text .. Editors .. post_text;
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = Editors .. &quot; &quot;
                else Editors = Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif is_set(Editors) then
        if is_set(Date) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
            else
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if is_set(Date) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end
        if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
            text = safejoin( {Chapter, Place, tcommon}, sepc );
            text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
            text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
            text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if is_set(PostScript) and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    if not is_set(Year) then
        if is_set(DateIn) then
            Year = selectyear( DateIn );
        elseif is_set(PublicationDate) then
            Year = selectyear( PublicationDate );
        end
    end
    
    local options = {};
    
    if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
        options.class = &quot;citation &quot; .. config.CitationClass;
    else
        options.class = &quot;citation&quot;;
    end
    
    if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if #a &gt; 0 then
                for i,v in ipairs(a) do 
                    names[i] = v.last 
                    if i == 4 then break end
                end
            elseif #e &gt; 0 then
                for i,v in ipairs(e) do 
                    names[i] = v.last 
                    if i == 4 then break end                
                end
            end
            names[ #names + 1 ] = Year;
            id = anchorid(names)
        end
        options.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = {};
        text = seterror('empty_citation');
        z.message_tail = {};
    end
    
    if is_set(options.id) then 
        text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    else
        text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    end        

    local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        text = text .. &quot; &quot;;
        for i,v in ipairs( z.message_tail ) do
            if is_set(v[1]) then
                if i == #z.message_tail then
                    text = text .. errorcomment( v[1], v[2] );
                else
                    text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
                end
            end
        end
    end
    
    no_tracking_cats = no_tracking_cats:lower();
    if inArray(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    local suggestions = {};
    local error_text, error_state;

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        args[k] = v;       
    end    

    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            if not validate( k ) then            
                error_text = &quot;&quot;;
                if type( k ) ~= 'string' then
                    -- Exclude empty numbered parameters
                    if v:match(&quot;%S+&quot;) ~= nil then
                        error_text, error_state = seterror( 'text_ignored', {v}, true );
                    end
                elseif validate( k:lower() ) then 
                    error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
                else
                    if #suggestions == 0 then
                        suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
                    end
                    if suggestions[ k:lower() ] ~= nil then
                        error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
                    else
                        error_text, error_state = seterror( 'parameter_ignored', {k}, true );
                    end
                end                  
                if error_text ~= '' then
                    table.insert( z.message_tail, {error_text, error_state} );
                end                
            end
            args[k] = v;
        elseif args[k] ~= nil or (k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z</text>
      <sha1>0y692ueid98uzigij9jdg66y5xx1azc</sha1>
    </revision>
    <revision>
      <id>4658</id>
      <parentid>4657</parentid>
      <timestamp>2013-08-26T20:40:50Z</timestamp>
      <contributor>
        <username>Gadget850</username>
        <id>810</id>
      </contributor>
      <comment>registration required</comment>
      <origin>4658</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="58863" sha1="gonhupo960lxojgi9e94398f6osek40" xml:space="preserve">local z = {
    error_categories = {};
    error_ids = {};
    message_tail = {};
}

-- Include translation message hooks, ID and error handling configuration settings.
local cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );

-- Contains a list of all recognized parameters
local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );

-- Whether variable is set or not
function is_set( var )
    return not (var == nil or var == '');
end

-- First set variable or nil if none
function first_set(...)
    local list = {...};
    for _, var in pairs(list) do
        if is_set( var ) then
            return var;
        end
    end
end

-- Whether needle is in haystack
function inArray( needle, haystack )
    if needle == nil then
        return false;
    end
    for n,v in ipairs( haystack ) do
        if v == needle then
            return n;
        end
    end
    return false;
end

-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
    return args and tostring( mw.message.newRawMessage( msg, args ) ) or msg;
end

-- Wraps a string using a message_list configuration taking one argument
function wrap( key, str, lower )
    if not is_set( str ) then
        return &quot;&quot;;
    elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
        str = safeforitalics( str );
    end
    if lower == true then
        return substitute( cfg.messages[key]:lower(), {str} );
    else
        return substitute( cfg.messages[key], {str} );
    end        
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
    local origin = {};
    
    return setmetatable({
        ORIGIN = function( self, k )
            local dummy = self[k]; --force the variable to be loaded.
            return origin[k];
        end
    },
    {
        __index = function ( tbl, k )
            if origin[k] ~= nil then
                return nil;
            end
            
            local args, list, v = args, cfg.aliases[k];
            
            if type( list ) == 'table' then
                v, origin[k] = selectone( args, list, 'redundant_parameters' );
                if origin[k] == nil then
                    origin[k] = ''; -- Empty string, not nil
                end
            elseif list ~= nil then
                v, origin[k] = args[list], list;
            else
                -- maybe let through instead of raising an error?
                -- v, origin[k] = args[k], k;
                error( cfg.messages['unknown_argument_map'] );
            end
            
            -- Empty strings, not nil;
            if v == nil then
                v = cfg.defaults[k] or '';
                origin[k] = '';
            end
            
            tbl = rawset( tbl, k, v );
            return v;
        end,
    });
end

-- Checks that parameter name is valid using the whitelist
function validate( name )
    name = tostring( name );
    
    -- Normal arguments
    if whitelist.basic_arguments[ name ] then
        return true;
    end
    
    -- Arguments with numbers in them
    name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );
    if whitelist.numbered_arguments[ name ] then
        return true;
    end
    
    -- Not found, argument not supported.
    return false
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
    return wrap( hidden and 'hidden-error' or 'visible-error', content );
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
    local error_state = cfg.error_conditions[ error_id ];
    
    prefix = prefix or &quot;&quot;;
    suffix = suffix or &quot;&quot;;
    
    if error_state == nil then
        error( cfg.messages['undefined_error'] );
    elseif is_set( error_state.category ) then
        table.insert( z.error_categories, error_state.category );
    end
    
    local message = substitute( error_state.message, arguments );
    
    message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
        &quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
        cfg.messages['help page label'] .. &quot;]])&quot;;
    
    z.error_ids[ error_id ] = true;
    if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
            and z.error_ids['citation_missing_title'] then
        return '', false;
    end
    
    message = table.concat({ prefix, message, suffix });
    
    if raw == true then
        return message, error_state.hidden;
    end        
        
    return errorcomment( message, error_state.hidden );
end

-- Formats a wiki style external link
function externallinkid(options)
    local url_string = options.id;
    if options.encode == true or options.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, url_string, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Formats a wiki style internal link
function internallinkid(options)
    return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, options.id, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Format an external link with error checking
function externallink( URL, label, source )
    local error_str = &quot;&quot;;
    if not is_set( label ) then
        label = URL;
        if is_set( source ) then
            error_str = seterror( 'bare_url_missing_title', { wrap( 'parameter', source ) }, false, &quot; &quot; );
        else
            error( cfg.messages[&quot;bare_url_no_origin&quot;] );
        end            
    end
    if not checkurl( URL ) then
        error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
    end
    return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safeforurl( label ), &quot;]&quot;, error_str });
end

-- Formats a link to Amazon
function amazon(id, domain)
    if not is_set(domain) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local handler = cfg.id_handlers['ASIN'];
    return externallinkid({link = handler.link,
        label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
        encode=handler.encode, separator = handler.separator})
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    local handler = cfg.id_handlers['DOI'];
    
    local text;
    if is_set(inactive) then
        text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link = handler.link, label = handler.label,
            prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then      
        cat = seterror( 'bad_doi' );
    end
    return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    local handler = cfg.id_handlers['OL'];
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    else
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode}) .. 
            ' ' .. seterror( 'bad_ol' );
    end
end

--[[
Determines whether an URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
    -- Protocol-relative or URL scheme
    return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
    return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
    isbn_str = cleanisbn( isbn_str ):gsub( &quot;-&quot;, &quot;&quot; );
    local len = isbn_str:len();
 
    if len ~= 10 and len ~= 13 then
        return false;
    end
 
    local temp = 0;
    if len == 10 then
        if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            if v == string.byte( &quot;X&quot; ) then
                temp = temp + 10*( 11 - i );
            else
                temp = temp + tonumber( string.char(v) )*(11-i);
            end
        end
        return temp % 11 == 0;
    else
        if isbn_str:match( &quot;^%d*$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
        end
        return temp % 10 == 0;
    end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
    return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
        return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
    end));
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if not is_set(str) then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        
        -- Remove newlines as they break italics.
        return str:gsub( '\n', ' ' );
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    -- Is the input a simple number?
    local num = tonumber( str ); 
    if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.floor(num) then
        return str;
    else
        -- Use formatDate to interpret more complicated formats
        local lang = mw.getContentLanguage();
        local good, result;
        good, result = pcall( lang.formatDate, lang, 'Y', str )
        if good then 
            return result;
        else
            -- Can't make sense of this input, return blank.
            return &quot;&quot;;
        end
    end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    if maximum ~= nil and maximum &lt; 1 then return &quot;&quot;, 0; end
    
    for i,person in ipairs(people) do
        if is_set(person.last) then
            local mask = person.mask
            local one
            local sep_one = sep;
            if maximum ~= nil and i &gt; maximum then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask;
                    sep_one = &quot; &quot;;
                end
            else
                one = person.last
                local first = person.first
                if is_set(first) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if is_set(person.link) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert( text, one )
            table.insert( text, sep_one )
        end
    end

    local count = #text / 2;
    if count &gt; 0 then 
        if count &gt; 1 and is_set(lastauthoramp) and not etal then
            text[#text-2] = &quot; &amp; &quot;;
        end
        text[#text] = nil; 
    end
    
    local result = table.concat(text) -- construct list
    if etal then 
        local etal_text = cfg.messages['et al'];
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result = 
        '&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
    end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
    return &quot;CITEREF&quot; .. table.concat( options );
end

-- Gets name list from the input arguments
function extractnames(args, list_name)
    local names = {};
    local i = 1;
    local last;
    
    while true do
        last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );
        if not is_set(last) then
            -- just in case someone passed in an empty parameter
            break;
        end
        names[i] = {
            last = last,
            first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i ),
            link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ),
            mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i )
        };
        i = i + 1;
    end
    return names;
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
    local id_list = {};
    for k, v in pairs( cfg.id_handlers ) do    
        v = selectone( args, v.parameters, 'redundant_parameters' );
        if is_set(v) then id_list[k] = v; end
    end
    return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
    local new_list, handler = {};
    
    function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
    
    for k, v in pairs( id_list ) do
        -- fallback to read-only cfg
        handler = setmetatable( { ['id'] = v }, fallback(k) );
        
        if handler.mode == 'external' then
            table.insert( new_list, {handler.label, externallinkid( handler ) } );
        elseif handler.mode == 'internal' then
            table.insert( new_list, {handler.label, internallinkid( handler ) } );
        elseif handler.mode ~= 'manual' then
            error( cfg.messages['unknown_ID_mode'] );
        elseif k == 'DOI' then
            table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
        elseif k == 'ASIN' then
            table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
        elseif k == 'OL' then
            table.insert( new_list, {handler.label, openlibrary( v ) } );
        elseif k == 'ISBN' then
            local ISBN = internallinkid( handler );
            if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
                ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
            end
            table.insert( new_list, {handler.label, ISBN } );                
        else
            error( cfg.messages['unknown_manual_ID'] );
        end
    end
    
    function comp( a, b )
        return a[1] &lt; b[1];
    end
    
    table.sort( new_list, comp );
    for k, v in ipairs( new_list ) do
        new_list[k] = v[2];
    end
    
    return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
    local value = nil;
    local selected = '';
    local error_list = {};
    
    if index ~= nil then index = tostring(index); end
    
    -- Handle special case of &quot;#&quot; replaced by empty string
    if index == '1' then
        for _, v in ipairs( possible ) do
            v = v:gsub( &quot;#&quot;, &quot;&quot; );
            if is_set(args[v]) then
                if value ~= nil and selected ~= v then
                    table.insert( error_list, v );
                else
                    value = args[v];
                    selected = v;
                end
            end
        end        
    end
    
    for _, v in ipairs( possible ) do
        if index ~= nil then
            v = v:gsub( &quot;#&quot;, index );
        end
        if is_set(args[v]) then
            if value ~= nil and selected ~=  v then
                table.insert( error_list, v );
            else
                value = args[v];
                selected = v;
            end
        end
    end
    
    if #error_list &gt; 0 then
        local error_str = &quot;&quot;;
        for _, k in ipairs( error_list ) do
            if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
            error_str = error_str .. wrap( 'parameter', k );
        end
        if #error_list &gt; 1 then
            error_str = error_str .. cfg.messages['parameter-final-separator'];
        else
            error_str = error_str .. cfg.messages['parameter-pair-separator'];
        end
        error_str = error_str .. wrap( 'parameter', selected );
        table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
    end
    
    return value, selected;
end

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
function COinS(data)
    if 'table' ~= type(data) or nil == next(data) then
        return '';
    end
    
    local ctx_ver = &quot;Z39.88-2004&quot;;
    
    -- treat table strictly as an array with only set values.
    local OCinSoutput = setmetatable( {}, {
        __newindex = function(self, key, value)
            if is_set(value) then
                rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
            end
        end
    });
    
    if is_set(data.Chapter) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Chapter;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    elseif is_set(data.Periodical) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
        OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    else
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
    end
    
    OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
    OCinSoutput[&quot;rft.date&quot;] = data.Date;
    OCinSoutput[&quot;rft.series&quot;] = data.Series;
    OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
    OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
    OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
    OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
    OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
    
    for k, v in pairs( data.ID_list ) do
        local id, value = cfg.id_handlers[k].COinS;
        if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
        if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
            OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
        else
            OCinSoutput[ id ] = value;
        end
    end
    
    local last, first;
    for k, v in ipairs( data.Authors ) do
        last, first = v.last, v.first;
        if k == 1 then
            if is_set(last) then
                OCinSoutput[&quot;rft.aulast&quot;] = last;
            end
            if is_set(first) then 
                OCinSoutput[&quot;rft.aufirst&quot;] = first;
            end
        end
        if is_set(last) and is_set(first) then
            OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
        elseif is_set(last) then
            OCinSoutput[&quot;rft.au&quot;] = last;
        end
    end
    
    OCinSoutput.rft_id = data.URL;
    OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
    OCinSoutput = setmetatable( OCinSoutput, nil );
    
    -- sort with version string always first, and combine.
    table.sort( OCinSoutput );
    table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
    return table.concat(OCinSoutput, &quot;&amp;&quot;);
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    --[[ 
    Load Input Parameters
    The argment_wrapper facillitates the mapping of multiple
    aliases to single internal variable.
    ]]
    local A = argument_wrapper( args );

    local i 
    local PPrefix = A['PPrefix']
    local PPPrefix = A['PPPrefix']
    if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = A['Authors'];
    local a = extractnames( args, 'AuthorList' );

    local Coauthors = A['Coauthors'];
    local Others = A['Others'];
    local Editors = A['Editors'];
    local e = extractnames( args, 'EditorList' );

    local Year = A['Year'];
    local PublicationDate = A['PublicationDate'];
    local OrigYear = A['OrigYear'];
    local Date = A['Date'];
    local LayDate = A['LayDate'];
    ------------------------------------------------- Get title data
    local Title = A['Title'];
    local BookTitle = A['BookTitle'];
    local Conference = A['Conference'];
    local TransTitle = A['TransTitle'];
    local TitleNote = A['TitleNote'];
    local TitleLink = A['TitleLink'];
    local Chapter = A['Chapter'];
    local ChapterLink = A['ChapterLink'];
    local TransChapter = A['TransChapter'];
    local TitleType = A['TitleType'];
    local ArchiveURL = A['ArchiveURL'];
    local URL = A['URL']
    local URLorigin = A:ORIGIN('URL');
    local ChapterURL = A['ChapterURL'];
    local ChapterURLorigin = A:ORIGIN('ChapterURL');
    local ConferenceURL = A['ConferenceURL'];
    local ConferenceURLorigin = A:ORIGIN('ConferenceURL');
    local Periodical = A['Periodical'];
    
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if not is_set(Chapter) then
            if not is_set(Title) then
                Title = Periodical;
                Periodical = '';
            else
                Chapter = Title
                TransChapter = TransTitle
                Title = '';
                TransTitle = '';
            end
        end
    end

    local Series = A['Series'];
    local Volume = A['Volume'];
    local Issue = A['Issue'];
    local Position = '';
    local Page, Pages, At, page_type;
    
    Page = A['Page'];
    Pages = hyphentodash( A['Pages'] );
    At = A['At'];
    
    if is_set(Page) then
        if is_set(Pages) or is_set(At) then
            Page = Page .. &quot; &quot; .. seterror('extra_pages');
            Pages = '';
            At = '';
        end
    elseif is_set(Pages) then
        if is_set(At) then
            Pages = Pages .. &quot; &quot; .. seterror('extra_pages');
            At = '';
        end
    end    
    
    local Edition = A['Edition'];
    local PublicationPlace = A['PublicationPlace']
    local Place = A['Place'];
    
    if not is_set(PublicationPlace) and is_set(Place) then
        PublicationPlace = Place;
    end
    
    if PublicationPlace == Place then Place = ''; end
    
    local PublisherName = A['PublisherName'];
    local RegistrationRequired = A['RegistrationRequired'];
    local SubscriptionRequired = A['SubscriptionRequired'];
    local Via = A['Via'];
    local AccessDate = A['AccessDate'];
    local ArchiveDate = A['ArchiveDate'];
    local Agency = A['Agency'];
    local DeadURL = A['DeadURL']
    local Language = A['Language'];
    local Format = A['Format'];
    local Ref = A['Ref'];
    
    local DoiBroken = A['DoiBroken'];
    local ID = A['ID'];
    local ASINTLD = A['ASINTLD'];
    local IgnoreISBN = A['IgnoreISBN'];

    local ID_list = extractids( args );
    
    local Quote = A['Quote'];
    local PostScript = A['PostScript'];
    local LayURL = A['LayURL'];
    local LaySource = A['LaySource'];
    local Transcript = A['Transcript'];
    local TranscriptURL = A['TranscriptURL'] 
    local TranscriptURLorigin = A:ORIGIN('TranscriptURL');
    local sepc = A['Separator'];
    local LastAuthorAmp = A['LastAuthorAmp'];
    local no_tracking_cats = A['NoTracking'];

    local use_lowercase = ( sepc ~= '.' );
    local this_page = mw.title.getCurrentTitle();  --Also used for COinS
    
    if not is_set(no_tracking_cats) then
        for k, v in pairs( cfg.uncategorized_namespaces ) do
            if this_page.nsText == v then
                no_tracking_cats = &quot;true&quot;;
                break;
            end
        end
    end

    if ( config.CitationClass == &quot;journal&quot; ) then
        if not is_set(URL) and is_set(ID_list['PMC']) then
            local Embargo = A['Embargo'];
            if is_set(Embargo) then
                local lang = mw.getContentLanguage();
                local good1, result1, good2, result2;
                good1, result1 = pcall( lang.formatDate, lang, 'U', Embargo );
                good2, result2 = pcall( lang.formatDate, lang, 'U' );
                
                if good1 and good2 and tonumber( result1 ) &lt; tonumber( result2 ) then 
                    URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];
                    URLorigin = cfg.id_handlers['PMC'].parameters[1];
                end
            else
                URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];
                URLorigin = cfg.id_handlers['PMC'].parameters[1];
            end
        end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if is_set(BookTitle) then
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = BookTitle;
        TitleLink = '';
        TransTitle = '';
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = A['AirDate'];
        local SeriesLink = A['SeriesLink'];
        local Season = A['Season'];
        local SeriesNumber = A['SeriesNumber'];
        local Network = A['Network'];
        local Station = A['Station'];
        local s, n = {}, {};
        local Sep = (first_set(A[&quot;SeriesSeparator&quot;], A[&quot;Separator&quot;]) or &quot;&quot;) .. &quot; &quot;;
        
        if is_set(Issue) then table.insert(s, cfg.messages[&quot;episode&quot;] .. &quot; &quot; .. Issue); Issue = ''; end
        if is_set(Season) then table.insert(s, cfg.messages[&quot;season&quot;] .. &quot; &quot; .. Season); end
        if is_set(SeriesNumber) then table.insert(s, cfg.messages[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber); end
        if is_set(Network) then table.insert(n, Network); end
        if is_set(Station) then table.insert(n, Station); end
        
        Date = Date or AirDate;
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = Series;
        TitleLink = SeriesLink;
        TransTitle = '';
        
        Series = table.concat(s, Sep);
        ID = table.concat(n, Sep);
    end
    
    -- COinS metadata (see &lt;http://ocoins.info/&gt;) for
    -- automated parsing of citation information.
    local OCinSoutput = COinS{
        ['Periodical'] = Periodical,
        ['Chapter'] = Chapter,
        ['Title'] = Title,
        ['PublicationPlace'] = PublicationPlace,
        ['Date'] = first_set(Date, Year, PublicationDate),
        ['Series'] = Series,
        ['Volume'] = Volume,
        ['Issue'] = Issue,
        ['Pages'] = first_set(Page, Pages, At),
        ['Edition'] = Edition,
        ['PublisherName'] = PublisherName,
        ['URL'] = first_set( URL, ChapterURL ),
        ['Authors'] = a,
        ['ID_list'] = ID_list,
        ['RawPage'] = this_page.prefixedText,
    };

    if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = '';
        TitleLink = '';
        TransTitle = '';
    end

    -- Now perform various field 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 not is_set(Authors) then
        local Maximum = tonumber( A['DisplayAuthors'] );
        
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #a == 9 then 
            Maximum = 8;
            table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
        elseif not is_set(Maximum) then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = A[&quot;AuthorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;AuthorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A[&quot;AuthorFormat&quot;],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if is_set(Coauthors) then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
        
        Authors = listpeople(control, a) 
    end

    local EditorCount
    if not is_set(Editors) then
        local Maximum = tonumber( A['DisplayEditors'] );
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #e == 4 then 
            Maximum = 3;
            table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
        elseif not is_set(Maximum) then
            Maximum = #e + 1;
        end

        local control = { 
            sep = A[&quot;EditorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;EditorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A['EditorFormat'],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };

        Editors, EditorCount = listpeople(control, e);
    else
        EditorCount = 1;
    end

    local Cartography = &quot;&quot;;
    local Scale = &quot;&quot;;
    if config.CitationClass == &quot;map&quot; then
        if not is_set( Authors ) and is_set( PublisherName ) then
            Authors = PublisherName;
            PublisherName = &quot;&quot;;
        end
        Cartography = A['Cartography'];
        if is_set( Cartography ) then
            Cartography = sepc .. &quot; &quot; .. wrap( 'cartography', Cartography, use_lowercase );
        end        
        Scale = A['Scale'];
        if is_set( Scale ) then
            Scale = sepc .. &quot; &quot; .. Scale;
        end        
    end
    
    if not is_set(Date) then
        Date = Year;
        if is_set(Date) then
            local Month = A['Month'];
            if is_set(Month) then 
                Date = Month .. &quot; &quot; .. Date;
                local Day = A['Day']
                if is_set(Day) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    
    if inArray(PublicationDate, {Date, Year}) then PublicationDate = ''; end
    if not is_set(Date) and is_set(PublicationDate) then
        Date = PublicationDate;
        PublicationDate = '';
    end

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date;
    
    if  not is_set(URL) and
        not is_set(ChapterURL) and
        not is_set(ArchiveURL) and
        not is_set(ConferenceURL) and
        not is_set(TranscriptURL) then
        
        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
        end
        
        -- Test if accessdate is given without giving a URL
        if is_set(AccessDate) then
            table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
            AccessDate = '';
        end
        
        -- Test if format is given without giving a URL
        if is_set(Format) then
            Format = Format .. seterror( 'format_missing_url' );
        end
    end
    
    -- Test if citation has no title
    if  not is_set(Chapter) and
        not is_set(Title) and
        not is_set(Periodical) and
        not is_set(Conference) and
        not is_set(TransTitle) and
        not is_set(TransChapter) then
        table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
    end
    
    Format = is_set(Format) and &quot; (&quot; .. Format .. &quot;)&quot; or &quot;&quot;;
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if is_set( ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
            URLorigin = A:ORIGIN('ArchiveURL')
        end
    end
    
    -- Format chapter / article title
    if is_set(Chapter) and is_set(ChapterLink) then 
        Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot;;
    end
    if is_set(Periodical) and is_set(Title) then
        Chapter = wrap( 'italic-title', Chapter );
        TransChapter = wrap( 'trans-italic-title', TransChapter );
    else
        Chapter = wrap( 'quoted-title', Chapter );
        TransChapter = wrap( 'trans-quoted-title', TransChapter );
    end
    
    local TransError = &quot;&quot;
    if is_set(TransChapter) then
        if not is_set(Chapter) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
        else
            TransChapter = &quot; &quot; .. TransChapter;
        end
    end
    
    Chapter = Chapter .. TransChapter;
    
    if is_set(Chapter) then
        if not is_set(ChapterLink) then
            if is_set(ChapterURL) then
                Chapter = externallink( ChapterURL, Chapter ) .. TransError;
                if not is_set(URL) then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif is_set(URL) then 
                Chapter = externallink( URL, Chapter ) .. TransError .. Format;
                URL = &quot;&quot;;
                Format = &quot;&quot;;
            else
                Chapter = Chapter .. TransError;
            end            
        elseif is_set(ChapterURL) then
            Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. 
                TransError;
        else
            Chapter = Chapter .. TransError;
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    elseif is_set(ChapterURL) then
        Chapter = &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. sepc .. &quot; &quot;;
    end        
    
    -- Format main title.
    if is_set(TitleLink) and is_set(Title) then
        Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
    end
    
    if is_set(Periodical) then
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    elseif inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;pressrelease&quot;,&quot;conference&quot;}) and
            not is_set(Chapter) then
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    else
        Title = wrap( 'italic-title', Title );
        TransTitle = wrap( 'trans-italic-title', TransTitle );
    end
    
    TransError = &quot;&quot;;
    if is_set(TransTitle) then
        if not is_set(Title) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
        else
            TransTitle = &quot; &quot; .. TransTitle;
        end
    end
    
    Title = Title .. TransTitle;
    
    if is_set(Title) then
        if not is_set(TitleLink) and is_set(URL) then 
            Title = externallink( URL, Title ) .. TransError .. Format       
            URL = &quot;&quot;;
            Format = &quot;&quot;;
        else
            Title = Title .. TransError;
        end
    end
    
    if is_set(Place) then
        Place = &quot; &quot; .. wrap( 'written', Place, use_lowercase ) .. sepc .. &quot; &quot;;
    end
    
    if is_set(Conference) then
        if is_set(ConferenceURL) then
            Conference = externallink( ConferenceURL, Conference );
        end
        Conference = sepc .. &quot; &quot; .. Conference
    elseif is_set(ConferenceURL) then
        Conference = sepc .. &quot; &quot; .. externallink( ConferenceURL, nil, ConferenceURLorigin );
    end
    
    if not is_set(Position) then
        local Minutes = A['Minutes'];
        if is_set(Minutes) then
            Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
        else
            local Time = A['Time'];
            if is_set(Time) then
                local TimeCaption = A['TimeCaption']
                if not is_set(TimeCaption) then
                    TimeCaption = cfg.messages['event'];
                    if sepc ~= '.' then
                        TimeCaption = TimeCaption:lower();
                    end
                end
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
            end
        end
    else
        Position = &quot; &quot; .. Position;
        At = '';
    end
    
    if not is_set(Page) then
        if is_set(Pages) then
            if is_set(Periodical) and
                not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;}) then
                Pages = &quot;: &quot; .. Pages;
            elseif tonumber(Pages) ~= nil then
                Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
            else
                Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
            end
        end
    else
        if is_set(Periodical) and
            not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;}) then
            Page = &quot;: &quot; .. Page;
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page;
        end
    end
    
    At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
    Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
    if config.CitationClass == 'map' then
        local Section = A['Section'];
        local Inset = A['Inset'];
        if first_set( Pages, Page, At ) ~= nil or sepc ~= '.' then
            if is_set( Section ) then
                Section = &quot;, &quot; .. wrap( 'section', Section, true );
            end
            if is_set( Inset ) then
                Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
            end
        else
            if is_set( Section ) then
                Section = sepc .. &quot; &quot; .. wrap( 'section', Section, use_lowercase );
                if is_set( Inset ) then
                    Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
                end
            elseif is_set( Inset ) then
                Inset = sepc .. &quot; &quot; .. wrap( 'inset', Inset, use_lowercase );
            end            
        end            
        At = At .. Section .. Inset;        
    end    
    
    Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
    TitleType = is_set(TitleType) and (&quot; (&quot; .. TitleType .. &quot;)&quot;) or &quot;&quot;;
    TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
    Language = is_set(Language) and (&quot; &quot; .. wrap( 'language', Language )) or &quot;&quot;;
    Edition = is_set(Edition) and (&quot; &quot; .. wrap( 'edition', Edition )) or &quot;&quot;;
    Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
    Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
    OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
    Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;
    
    if is_set(Volume) then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume;
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
        end
    end
    
    ------------------------------------ totally unrelated data
    -- Mimic {{subscription required}} template; 
    if is_set(Via) then
        Via = &quot; &quot; .. wrap( 'via', Via );
--      SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];   --citation always requires subscription if 'via' parameter is used
                                                                              -- This line removed because of editors desire to use via for citations that do not require subscriptions
    elseif is_set(SubscriptionRequired) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription_no_via']; --here when 'via' parameter not used but 'subscription' is
    elseif is_set(RegistrationRequired) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration']; --here when 'via' and 'subscription' parameters not used but 'registration' is
    end

    if is_set(AccessDate) then
        local retrv_text = &quot; &quot; .. cfg.messages['retrieved']
        if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
        AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
            .. substitute( retrv_text, {AccessDate} ) .. '&lt;/span&gt;'
    end
    
    if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
    
    ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN} );

    if is_set(URL) then
        URL = &quot; &quot; .. externallink( URL, nil, URLorigin );
    end

    if is_set(Quote) then
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        Quote = sepc ..&quot; &quot; .. wrap( 'quoted-text', Quote ); 
        PostScript = &quot;&quot;;
    elseif PostScript:lower() == &quot;none&quot; then
        PostScript = &quot;&quot;;
    end
    
    local Archived
    if is_set(ArchiveURL) then
        if not is_set(ArchiveDate) then
            ArchiveDate = seterror('archive_missing_date');
        end
        if &quot;no&quot; == DeadURL then
            local arch_text = cfg.messages['archived'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
                { externallink( ArchiveURL, arch_text ), ArchiveDate } );
            if not is_set(OriginalURL) then
                Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url');                               
            end
        elseif is_set(OriginalURL) then
            local arch_text = cfg.messages['archived-dead'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text,
                { externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
        else
            local arch_text = cfg.messages['archived-missing'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
                { seterror('archive_missing_url'), ArchiveDate } );
        end
    else
        Archived = &quot;&quot;
    end
    
    local Lay
    if is_set(LayURL) then
        if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
        if is_set(LaySource) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot;;
        else
            LaySource = &quot;&quot;;
        end
        if sepc == '.' then
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;;
    end
    
    if is_set(Transcript) then
        if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
    elseif is_set(TranscriptURL) then
        Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
    end
    
    local Publisher;
    if is_set(Periodical) and
        not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;}) then
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end
        elseif is_set(PublicationPlace) then
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if is_set(PublicationDate) then
            if is_set(Publisher) then
                Publisher = Publisher .. &quot;, &quot; .. wrap( 'published', PublicationDate );
            else
                Publisher = PublicationDate;
            end
        end
        if is_set(Publisher) then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if is_set(PublicationDate) then
            PublicationDate = &quot; (&quot; .. wrap( 'published', PublicationDate ) .. &quot;)&quot;;
        end
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif is_set(PublicationPlace) then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    
    -- Several of the above rely upon detecting this as nil, so do it last.
    if is_set(Periodical) then
        if is_set(Title) or is_set(TitleNote) then 
            Periodical = sepc .. &quot; &quot; .. wrap( 'italic-title', Periodical ) 
        else 
            Periodical = wrap( 'italic-title', Periodical )
        end
    end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if inArray(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
        if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, 
            Language, Cartography, Edition, Publisher, Agency, Volume, Issue}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, Language, 
            Volume, Issue, Others, Cartography, Edition, Publisher, Agency}, sepc );
    end
    
    if #ID_list &gt; 0 then
        ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
    else
        ID_list = ID;
    end
    
    local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
    local text;
    local pgtext = Position .. Page .. Pages .. At;
    
    if is_set(Authors) then
        if is_set(Coauthors) then
            Authors = Authors .. A['AuthorSeparator'] .. &quot; &quot; .. Coauthors
        end
        if is_set(Date) then
            Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        elseif string.sub(Authors,-1,-1) == sepc then
            Authors = Authors .. &quot; &quot;
        else
            Authors = Authors .. sepc .. &quot; &quot;
        end
        if is_set(Editors) then
            local in_text = &quot; &quot;;
            local post_text = &quot;&quot;;
            if is_set(Chapter) then
                in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
            else
                if EditorCount &lt;= 1 then
                    post_text = &quot;, &quot; .. cfg.messages['editor'];
                else
                    post_text = &quot;, &quot; .. cfg.messages['editors'];
                end
            end 
            if (sepc ~= '.') then in_text = in_text:lower() end
            Editors = in_text .. Editors .. post_text;
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = Editors .. &quot; &quot;
                else Editors = Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif is_set(Editors) then
        if is_set(Date) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
            else
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if is_set(Date) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end
        if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
            text = safejoin( {Chapter, Place, tcommon}, sepc );
            text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
            text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
            text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if is_set(PostScript) and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    if not is_set(Year) then
        if is_set(DateIn) then
            Year = selectyear( DateIn );
        elseif is_set(PublicationDate) then
            Year = selectyear( PublicationDate );
        end
    end
    
    local options = {};
    
    if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
        options.class = &quot;citation &quot; .. config.CitationClass;
    else
        options.class = &quot;citation&quot;;
    end
    
    if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if #a &gt; 0 then
                for i,v in ipairs(a) do 
                    names[i] = v.last 
                    if i == 4 then break end
                end
            elseif #e &gt; 0 then
                for i,v in ipairs(e) do 
                    names[i] = v.last 
                    if i == 4 then break end                
                end
            end
            names[ #names + 1 ] = Year;
            id = anchorid(names)
        end
        options.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = {};
        text = seterror('empty_citation');
        z.message_tail = {};
    end
    
    if is_set(options.id) then 
        text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    else
        text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    end        

    local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        text = text .. &quot; &quot;;
        for i,v in ipairs( z.message_tail ) do
            if is_set(v[1]) then
                if i == #z.message_tail then
                    text = text .. errorcomment( v[1], v[2] );
                else
                    text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
                end
            end
        end
    end
    
    no_tracking_cats = no_tracking_cats:lower();
    if inArray(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    local suggestions = {};
    local error_text, error_state;

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        args[k] = v;       
    end    

    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            if not validate( k ) then            
                error_text = &quot;&quot;;
                if type( k ) ~= 'string' then
                    -- Exclude empty numbered parameters
                    if v:match(&quot;%S+&quot;) ~= nil then
                        error_text, error_state = seterror( 'text_ignored', {v}, true );
                    end
                elseif validate( k:lower() ) then 
                    error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
                else
                    if #suggestions == 0 then
                        suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
                    end
                    if suggestions[ k:lower() ] ~= nil then
                        error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
                    else
                        error_text, error_state = seterror( 'parameter_ignored', {k}, true );
                    end
                end                  
                if error_text ~= '' then
                    table.insert( z.message_tail, {error_text, error_state} );
                end                
            end
            args[k] = v;
        elseif args[k] ~= nil or (k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z</text>
      <sha1>gonhupo960lxojgi9e94398f6osek40</sha1>
    </revision>
    <revision>
      <id>4659</id>
      <parentid>4658</parentid>
      <timestamp>2013-09-01T17:37:00Z</timestamp>
      <contributor>
        <username>Gadget850</username>
        <id>810</id>
      </contributor>
      <comment>Fix via/subscription bug</comment>
      <origin>4659</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="58867" sha1="mvned19itk93o0dvg6ypwkx9i9hhxgq" xml:space="preserve">local z = {
    error_categories = {};
    error_ids = {};
    message_tail = {};
}

-- Include translation message hooks, ID and error handling configuration settings.
local cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );

-- Contains a list of all recognized parameters
local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );

-- Whether variable is set or not
function is_set( var )
    return not (var == nil or var == '');
end

-- First set variable or nil if none
function first_set(...)
    local list = {...};
    for _, var in pairs(list) do
        if is_set( var ) then
            return var;
        end
    end
end

-- Whether needle is in haystack
function inArray( needle, haystack )
    if needle == nil then
        return false;
    end
    for n,v in ipairs( haystack ) do
        if v == needle then
            return n;
        end
    end
    return false;
end

-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
    return args and tostring( mw.message.newRawMessage( msg, args ) ) or msg;
end

-- Wraps a string using a message_list configuration taking one argument
function wrap( key, str, lower )
    if not is_set( str ) then
        return &quot;&quot;;
    elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
        str = safeforitalics( str );
    end
    if lower == true then
        return substitute( cfg.messages[key]:lower(), {str} );
    else
        return substitute( cfg.messages[key], {str} );
    end        
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
    local origin = {};
    
    return setmetatable({
        ORIGIN = function( self, k )
            local dummy = self[k]; --force the variable to be loaded.
            return origin[k];
        end
    },
    {
        __index = function ( tbl, k )
            if origin[k] ~= nil then
                return nil;
            end
            
            local args, list, v = args, cfg.aliases[k];
            
            if type( list ) == 'table' then
                v, origin[k] = selectone( args, list, 'redundant_parameters' );
                if origin[k] == nil then
                    origin[k] = ''; -- Empty string, not nil
                end
            elseif list ~= nil then
                v, origin[k] = args[list], list;
            else
                -- maybe let through instead of raising an error?
                -- v, origin[k] = args[k], k;
                error( cfg.messages['unknown_argument_map'] );
            end
            
            -- Empty strings, not nil;
            if v == nil then
                v = cfg.defaults[k] or '';
                origin[k] = '';
            end
            
            tbl = rawset( tbl, k, v );
            return v;
        end,
    });
end

-- Checks that parameter name is valid using the whitelist
function validate( name )
    name = tostring( name );
    
    -- Normal arguments
    if whitelist.basic_arguments[ name ] then
        return true;
    end
    
    -- Arguments with numbers in them
    name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );
    if whitelist.numbered_arguments[ name ] then
        return true;
    end
    
    -- Not found, argument not supported.
    return false
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
    return wrap( hidden and 'hidden-error' or 'visible-error', content );
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
    local error_state = cfg.error_conditions[ error_id ];
    
    prefix = prefix or &quot;&quot;;
    suffix = suffix or &quot;&quot;;
    
    if error_state == nil then
        error( cfg.messages['undefined_error'] );
    elseif is_set( error_state.category ) then
        table.insert( z.error_categories, error_state.category );
    end
    
    local message = substitute( error_state.message, arguments );
    
    message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
        &quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
        cfg.messages['help page label'] .. &quot;]])&quot;;
    
    z.error_ids[ error_id ] = true;
    if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
            and z.error_ids['citation_missing_title'] then
        return '', false;
    end
    
    message = table.concat({ prefix, message, suffix });
    
    if raw == true then
        return message, error_state.hidden;
    end        
        
    return errorcomment( message, error_state.hidden );
end

-- Formats a wiki style external link
function externallinkid(options)
    local url_string = options.id;
    if options.encode == true or options.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, url_string, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Formats a wiki style internal link
function internallinkid(options)
    return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, options.id, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Format an external link with error checking
function externallink( URL, label, source )
    local error_str = &quot;&quot;;
    if not is_set( label ) then
        label = URL;
        if is_set( source ) then
            error_str = seterror( 'bare_url_missing_title', { wrap( 'parameter', source ) }, false, &quot; &quot; );
        else
            error( cfg.messages[&quot;bare_url_no_origin&quot;] );
        end            
    end
    if not checkurl( URL ) then
        error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
    end
    return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safeforurl( label ), &quot;]&quot;, error_str });
end

-- Formats a link to Amazon
function amazon(id, domain)
    if not is_set(domain) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local handler = cfg.id_handlers['ASIN'];
    return externallinkid({link = handler.link,
        label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
        encode=handler.encode, separator = handler.separator})
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    local handler = cfg.id_handlers['DOI'];
    
    local text;
    if is_set(inactive) then
        text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link = handler.link, label = handler.label,
            prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then      
        cat = seterror( 'bad_doi' );
    end
    return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    local handler = cfg.id_handlers['OL'];
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    else
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode}) .. 
            ' ' .. seterror( 'bad_ol' );
    end
end

--[[
Determines whether an URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
    -- Protocol-relative or URL scheme
    return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
    return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
    isbn_str = cleanisbn( isbn_str ):gsub( &quot;-&quot;, &quot;&quot; );
    local len = isbn_str:len();
 
    if len ~= 10 and len ~= 13 then
        return false;
    end
 
    local temp = 0;
    if len == 10 then
        if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            if v == string.byte( &quot;X&quot; ) then
                temp = temp + 10*( 11 - i );
            else
                temp = temp + tonumber( string.char(v) )*(11-i);
            end
        end
        return temp % 11 == 0;
    else
        if isbn_str:match( &quot;^%d*$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
        end
        return temp % 10 == 0;
    end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
    return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
        return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
    end));
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if not is_set(str) then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        
        -- Remove newlines as they break italics.
        return str:gsub( '\n', ' ' );
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    -- Is the input a simple number?
    local num = tonumber( str ); 
    if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.floor(num) then
        return str;
    else
        -- Use formatDate to interpret more complicated formats
        local lang = mw.getContentLanguage();
        local good, result;
        good, result = pcall( lang.formatDate, lang, 'Y', str )
        if good then 
            return result;
        else
            -- Can't make sense of this input, return blank.
            return &quot;&quot;;
        end
    end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    if maximum ~= nil and maximum &lt; 1 then return &quot;&quot;, 0; end
    
    for i,person in ipairs(people) do
        if is_set(person.last) then
            local mask = person.mask
            local one
            local sep_one = sep;
            if maximum ~= nil and i &gt; maximum then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask;
                    sep_one = &quot; &quot;;
                end
            else
                one = person.last
                local first = person.first
                if is_set(first) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if is_set(person.link) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert( text, one )
            table.insert( text, sep_one )
        end
    end

    local count = #text / 2;
    if count &gt; 0 then 
        if count &gt; 1 and is_set(lastauthoramp) and not etal then
            text[#text-2] = &quot; &amp; &quot;;
        end
        text[#text] = nil; 
    end
    
    local result = table.concat(text) -- construct list
    if etal then 
        local etal_text = cfg.messages['et al'];
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result = 
        '&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
    end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
    return &quot;CITEREF&quot; .. table.concat( options );
end

-- Gets name list from the input arguments
function extractnames(args, list_name)
    local names = {};
    local i = 1;
    local last;
    
    while true do
        last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );
        if not is_set(last) then
            -- just in case someone passed in an empty parameter
            break;
        end
        names[i] = {
            last = last,
            first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i ),
            link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ),
            mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i )
        };
        i = i + 1;
    end
    return names;
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
    local id_list = {};
    for k, v in pairs( cfg.id_handlers ) do    
        v = selectone( args, v.parameters, 'redundant_parameters' );
        if is_set(v) then id_list[k] = v; end
    end
    return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
    local new_list, handler = {};
    
    function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
    
    for k, v in pairs( id_list ) do
        -- fallback to read-only cfg
        handler = setmetatable( { ['id'] = v }, fallback(k) );
        
        if handler.mode == 'external' then
            table.insert( new_list, {handler.label, externallinkid( handler ) } );
        elseif handler.mode == 'internal' then
            table.insert( new_list, {handler.label, internallinkid( handler ) } );
        elseif handler.mode ~= 'manual' then
            error( cfg.messages['unknown_ID_mode'] );
        elseif k == 'DOI' then
            table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
        elseif k == 'ASIN' then
            table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
        elseif k == 'OL' then
            table.insert( new_list, {handler.label, openlibrary( v ) } );
        elseif k == 'ISBN' then
            local ISBN = internallinkid( handler );
            if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
                ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
            end
            table.insert( new_list, {handler.label, ISBN } );                
        else
            error( cfg.messages['unknown_manual_ID'] );
        end
    end
    
    function comp( a, b )
        return a[1] &lt; b[1];
    end
    
    table.sort( new_list, comp );
    for k, v in ipairs( new_list ) do
        new_list[k] = v[2];
    end
    
    return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
    local value = nil;
    local selected = '';
    local error_list = {};
    
    if index ~= nil then index = tostring(index); end
    
    -- Handle special case of &quot;#&quot; replaced by empty string
    if index == '1' then
        for _, v in ipairs( possible ) do
            v = v:gsub( &quot;#&quot;, &quot;&quot; );
            if is_set(args[v]) then
                if value ~= nil and selected ~= v then
                    table.insert( error_list, v );
                else
                    value = args[v];
                    selected = v;
                end
            end
        end        
    end
    
    for _, v in ipairs( possible ) do
        if index ~= nil then
            v = v:gsub( &quot;#&quot;, index );
        end
        if is_set(args[v]) then
            if value ~= nil and selected ~=  v then
                table.insert( error_list, v );
            else
                value = args[v];
                selected = v;
            end
        end
    end
    
    if #error_list &gt; 0 then
        local error_str = &quot;&quot;;
        for _, k in ipairs( error_list ) do
            if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
            error_str = error_str .. wrap( 'parameter', k );
        end
        if #error_list &gt; 1 then
            error_str = error_str .. cfg.messages['parameter-final-separator'];
        else
            error_str = error_str .. cfg.messages['parameter-pair-separator'];
        end
        error_str = error_str .. wrap( 'parameter', selected );
        table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
    end
    
    return value, selected;
end

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
function COinS(data)
    if 'table' ~= type(data) or nil == next(data) then
        return '';
    end
    
    local ctx_ver = &quot;Z39.88-2004&quot;;
    
    -- treat table strictly as an array with only set values.
    local OCinSoutput = setmetatable( {}, {
        __newindex = function(self, key, value)
            if is_set(value) then
                rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
            end
        end
    });
    
    if is_set(data.Chapter) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Chapter;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    elseif is_set(data.Periodical) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
        OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    else
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
    end
    
    OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
    OCinSoutput[&quot;rft.date&quot;] = data.Date;
    OCinSoutput[&quot;rft.series&quot;] = data.Series;
    OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
    OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
    OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
    OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
    OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
    
    for k, v in pairs( data.ID_list ) do
        local id, value = cfg.id_handlers[k].COinS;
        if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
        if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
            OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
        else
            OCinSoutput[ id ] = value;
        end
    end
    
    local last, first;
    for k, v in ipairs( data.Authors ) do
        last, first = v.last, v.first;
        if k == 1 then
            if is_set(last) then
                OCinSoutput[&quot;rft.aulast&quot;] = last;
            end
            if is_set(first) then 
                OCinSoutput[&quot;rft.aufirst&quot;] = first;
            end
        end
        if is_set(last) and is_set(first) then
            OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
        elseif is_set(last) then
            OCinSoutput[&quot;rft.au&quot;] = last;
        end
    end
    
    OCinSoutput.rft_id = data.URL;
    OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
    OCinSoutput = setmetatable( OCinSoutput, nil );
    
    -- sort with version string always first, and combine.
    table.sort( OCinSoutput );
    table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
    return table.concat(OCinSoutput, &quot;&amp;&quot;);
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    --[[ 
    Load Input Parameters
    The argment_wrapper facillitates the mapping of multiple
    aliases to single internal variable.
    ]]
    local A = argument_wrapper( args );

    local i 
    local PPrefix = A['PPrefix']
    local PPPrefix = A['PPPrefix']
    if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = A['Authors'];
    local a = extractnames( args, 'AuthorList' );

    local Coauthors = A['Coauthors'];
    local Others = A['Others'];
    local Editors = A['Editors'];
    local e = extractnames( args, 'EditorList' );

    local Year = A['Year'];
    local PublicationDate = A['PublicationDate'];
    local OrigYear = A['OrigYear'];
    local Date = A['Date'];
    local LayDate = A['LayDate'];
    ------------------------------------------------- Get title data
    local Title = A['Title'];
    local BookTitle = A['BookTitle'];
    local Conference = A['Conference'];
    local TransTitle = A['TransTitle'];
    local TitleNote = A['TitleNote'];
    local TitleLink = A['TitleLink'];
    local Chapter = A['Chapter'];
    local ChapterLink = A['ChapterLink'];
    local TransChapter = A['TransChapter'];
    local TitleType = A['TitleType'];
    local ArchiveURL = A['ArchiveURL'];
    local URL = A['URL']
    local URLorigin = A:ORIGIN('URL');
    local ChapterURL = A['ChapterURL'];
    local ChapterURLorigin = A:ORIGIN('ChapterURL');
    local ConferenceURL = A['ConferenceURL'];
    local ConferenceURLorigin = A:ORIGIN('ConferenceURL');
    local Periodical = A['Periodical'];
    
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if not is_set(Chapter) then
            if not is_set(Title) then
                Title = Periodical;
                Periodical = '';
            else
                Chapter = Title
                TransChapter = TransTitle
                Title = '';
                TransTitle = '';
            end
        end
    end

    local Series = A['Series'];
    local Volume = A['Volume'];
    local Issue = A['Issue'];
    local Position = '';
    local Page, Pages, At, page_type;
    
    Page = A['Page'];
    Pages = hyphentodash( A['Pages'] );
    At = A['At'];
    
    if is_set(Page) then
        if is_set(Pages) or is_set(At) then
            Page = Page .. &quot; &quot; .. seterror('extra_pages');
            Pages = '';
            At = '';
        end
    elseif is_set(Pages) then
        if is_set(At) then
            Pages = Pages .. &quot; &quot; .. seterror('extra_pages');
            At = '';
        end
    end    
    
    local Edition = A['Edition'];
    local PublicationPlace = A['PublicationPlace']
    local Place = A['Place'];
    
    if not is_set(PublicationPlace) and is_set(Place) then
        PublicationPlace = Place;
    end
    
    if PublicationPlace == Place then Place = ''; end
    
    local PublisherName = A['PublisherName'];
    local RegistrationRequired = A['RegistrationRequired'];
    local SubscriptionRequired = A['SubscriptionRequired'];
    local Via = A['Via'];
    local AccessDate = A['AccessDate'];
    local ArchiveDate = A['ArchiveDate'];
    local Agency = A['Agency'];
    local DeadURL = A['DeadURL']
    local Language = A['Language'];
    local Format = A['Format'];
    local Ref = A['Ref'];
    
    local DoiBroken = A['DoiBroken'];
    local ID = A['ID'];
    local ASINTLD = A['ASINTLD'];
    local IgnoreISBN = A['IgnoreISBN'];

    local ID_list = extractids( args );
    
    local Quote = A['Quote'];
    local PostScript = A['PostScript'];
    local LayURL = A['LayURL'];
    local LaySource = A['LaySource'];
    local Transcript = A['Transcript'];
    local TranscriptURL = A['TranscriptURL'] 
    local TranscriptURLorigin = A:ORIGIN('TranscriptURL');
    local sepc = A['Separator'];
    local LastAuthorAmp = A['LastAuthorAmp'];
    local no_tracking_cats = A['NoTracking'];

    local use_lowercase = ( sepc ~= '.' );
    local this_page = mw.title.getCurrentTitle();  --Also used for COinS
    
    if not is_set(no_tracking_cats) then
        for k, v in pairs( cfg.uncategorized_namespaces ) do
            if this_page.nsText == v then
                no_tracking_cats = &quot;true&quot;;
                break;
            end
        end
    end

    if ( config.CitationClass == &quot;journal&quot; ) then
        if not is_set(URL) and is_set(ID_list['PMC']) then
            local Embargo = A['Embargo'];
            if is_set(Embargo) then
                local lang = mw.getContentLanguage();
                local good1, result1, good2, result2;
                good1, result1 = pcall( lang.formatDate, lang, 'U', Embargo );
                good2, result2 = pcall( lang.formatDate, lang, 'U' );
                
                if good1 and good2 and tonumber( result1 ) &lt; tonumber( result2 ) then 
                    URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];
                    URLorigin = cfg.id_handlers['PMC'].parameters[1];
                end
            else
                URL = &quot;http://www.ncbi.nlm.nih.gov/pmc/articles/PMC&quot; .. ID_list['PMC'];
                URLorigin = cfg.id_handlers['PMC'].parameters[1];
            end
        end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if is_set(BookTitle) then
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = BookTitle;
        TitleLink = '';
        TransTitle = '';
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = A['AirDate'];
        local SeriesLink = A['SeriesLink'];
        local Season = A['Season'];
        local SeriesNumber = A['SeriesNumber'];
        local Network = A['Network'];
        local Station = A['Station'];
        local s, n = {}, {};
        local Sep = (first_set(A[&quot;SeriesSeparator&quot;], A[&quot;Separator&quot;]) or &quot;&quot;) .. &quot; &quot;;
        
        if is_set(Issue) then table.insert(s, cfg.messages[&quot;episode&quot;] .. &quot; &quot; .. Issue); Issue = ''; end
        if is_set(Season) then table.insert(s, cfg.messages[&quot;season&quot;] .. &quot; &quot; .. Season); end
        if is_set(SeriesNumber) then table.insert(s, cfg.messages[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber); end
        if is_set(Network) then table.insert(n, Network); end
        if is_set(Station) then table.insert(n, Station); end
        
        Date = Date or AirDate;
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = Series;
        TitleLink = SeriesLink;
        TransTitle = '';
        
        Series = table.concat(s, Sep);
        ID = table.concat(n, Sep);
    end
    
    -- COinS metadata (see &lt;http://ocoins.info/&gt;) for
    -- automated parsing of citation information.
    local OCinSoutput = COinS{
        ['Periodical'] = Periodical,
        ['Chapter'] = Chapter,
        ['Title'] = Title,
        ['PublicationPlace'] = PublicationPlace,
        ['Date'] = first_set(Date, Year, PublicationDate),
        ['Series'] = Series,
        ['Volume'] = Volume,
        ['Issue'] = Issue,
        ['Pages'] = first_set(Page, Pages, At),
        ['Edition'] = Edition,
        ['PublisherName'] = PublisherName,
        ['URL'] = first_set( URL, ChapterURL ),
        ['Authors'] = a,
        ['ID_list'] = ID_list,
        ['RawPage'] = this_page.prefixedText,
    };

    if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = '';
        TitleLink = '';
        TransTitle = '';
    end

    -- Now perform various field 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 not is_set(Authors) then
        local Maximum = tonumber( A['DisplayAuthors'] );
        
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #a == 9 then 
            Maximum = 8;
            table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
        elseif not is_set(Maximum) then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = A[&quot;AuthorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;AuthorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A[&quot;AuthorFormat&quot;],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if is_set(Coauthors) then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
        
        Authors = listpeople(control, a) 
    end

    local EditorCount
    if not is_set(Editors) then
        local Maximum = tonumber( A['DisplayEditors'] );
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #e == 4 then 
            Maximum = 3;
            table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
        elseif not is_set(Maximum) then
            Maximum = #e + 1;
        end

        local control = { 
            sep = A[&quot;EditorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;EditorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A['EditorFormat'],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };

        Editors, EditorCount = listpeople(control, e);
    else
        EditorCount = 1;
    end

    local Cartography = &quot;&quot;;
    local Scale = &quot;&quot;;
    if config.CitationClass == &quot;map&quot; then
        if not is_set( Authors ) and is_set( PublisherName ) then
            Authors = PublisherName;
            PublisherName = &quot;&quot;;
        end
        Cartography = A['Cartography'];
        if is_set( Cartography ) then
            Cartography = sepc .. &quot; &quot; .. wrap( 'cartography', Cartography, use_lowercase );
        end        
        Scale = A['Scale'];
        if is_set( Scale ) then
            Scale = sepc .. &quot; &quot; .. Scale;
        end        
    end
    
    if not is_set(Date) then
        Date = Year;
        if is_set(Date) then
            local Month = A['Month'];
            if is_set(Month) then 
                Date = Month .. &quot; &quot; .. Date;
                local Day = A['Day']
                if is_set(Day) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    
    if inArray(PublicationDate, {Date, Year}) then PublicationDate = ''; end
    if not is_set(Date) and is_set(PublicationDate) then
        Date = PublicationDate;
        PublicationDate = '';
    end

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date;
    
    if  not is_set(URL) and
        not is_set(ChapterURL) and
        not is_set(ArchiveURL) and
        not is_set(ConferenceURL) and
        not is_set(TranscriptURL) then
        
        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
        end
        
        -- Test if accessdate is given without giving a URL
        if is_set(AccessDate) then
            table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
            AccessDate = '';
        end
        
        -- Test if format is given without giving a URL
        if is_set(Format) then
            Format = Format .. seterror( 'format_missing_url' );
        end
    end
    
    -- Test if citation has no title
    if  not is_set(Chapter) and
        not is_set(Title) and
        not is_set(Periodical) and
        not is_set(Conference) and
        not is_set(TransTitle) and
        not is_set(TransChapter) then
        table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
    end
    
    Format = is_set(Format) and &quot; (&quot; .. Format .. &quot;)&quot; or &quot;&quot;;
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if is_set( ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
            URLorigin = A:ORIGIN('ArchiveURL')
        end
    end
    
    -- Format chapter / article title
    if is_set(Chapter) and is_set(ChapterLink) then 
        Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot;;
    end
    if is_set(Periodical) and is_set(Title) then
        Chapter = wrap( 'italic-title', Chapter );
        TransChapter = wrap( 'trans-italic-title', TransChapter );
    else
        Chapter = wrap( 'quoted-title', Chapter );
        TransChapter = wrap( 'trans-quoted-title', TransChapter );
    end
    
    local TransError = &quot;&quot;
    if is_set(TransChapter) then
        if not is_set(Chapter) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
        else
            TransChapter = &quot; &quot; .. TransChapter;
        end
    end
    
    Chapter = Chapter .. TransChapter;
    
    if is_set(Chapter) then
        if not is_set(ChapterLink) then
            if is_set(ChapterURL) then
                Chapter = externallink( ChapterURL, Chapter ) .. TransError;
                if not is_set(URL) then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif is_set(URL) then 
                Chapter = externallink( URL, Chapter ) .. TransError .. Format;
                URL = &quot;&quot;;
                Format = &quot;&quot;;
            else
                Chapter = Chapter .. TransError;
            end            
        elseif is_set(ChapterURL) then
            Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. 
                TransError;
        else
            Chapter = Chapter .. TransError;
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    elseif is_set(ChapterURL) then
        Chapter = &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. sepc .. &quot; &quot;;
    end        
    
    -- Format main title.
    if is_set(TitleLink) and is_set(Title) then
        Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
    end
    
    if is_set(Periodical) then
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    elseif inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;pressrelease&quot;,&quot;conference&quot;}) and
            not is_set(Chapter) then
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    else
        Title = wrap( 'italic-title', Title );
        TransTitle = wrap( 'trans-italic-title', TransTitle );
    end
    
    TransError = &quot;&quot;;
    if is_set(TransTitle) then
        if not is_set(Title) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
        else
            TransTitle = &quot; &quot; .. TransTitle;
        end
    end
    
    Title = Title .. TransTitle;
    
    if is_set(Title) then
        if not is_set(TitleLink) and is_set(URL) then 
            Title = externallink( URL, Title ) .. TransError .. Format       
            URL = &quot;&quot;;
            Format = &quot;&quot;;
        else
            Title = Title .. TransError;
        end
    end
    
    if is_set(Place) then
        Place = &quot; &quot; .. wrap( 'written', Place, use_lowercase ) .. sepc .. &quot; &quot;;
    end
    
    if is_set(Conference) then
        if is_set(ConferenceURL) then
            Conference = externallink( ConferenceURL, Conference );
        end
        Conference = sepc .. &quot; &quot; .. Conference
    elseif is_set(ConferenceURL) then
        Conference = sepc .. &quot; &quot; .. externallink( ConferenceURL, nil, ConferenceURLorigin );
    end
    
    if not is_set(Position) then
        local Minutes = A['Minutes'];
        if is_set(Minutes) then
            Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
        else
            local Time = A['Time'];
            if is_set(Time) then
                local TimeCaption = A['TimeCaption']
                if not is_set(TimeCaption) then
                    TimeCaption = cfg.messages['event'];
                    if sepc ~= '.' then
                        TimeCaption = TimeCaption:lower();
                    end
                end
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
            end
        end
    else
        Position = &quot; &quot; .. Position;
        At = '';
    end
    
    if not is_set(Page) then
        if is_set(Pages) then
            if is_set(Periodical) and
                not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;}) then
                Pages = &quot;: &quot; .. Pages;
            elseif tonumber(Pages) ~= nil then
                Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
            else
                Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
            end
        end
    else
        if is_set(Periodical) and
            not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;}) then
            Page = &quot;: &quot; .. Page;
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page;
        end
    end
    
    At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
    Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
    if config.CitationClass == 'map' then
        local Section = A['Section'];
        local Inset = A['Inset'];
        if first_set( Pages, Page, At ) ~= nil or sepc ~= '.' then
            if is_set( Section ) then
                Section = &quot;, &quot; .. wrap( 'section', Section, true );
            end
            if is_set( Inset ) then
                Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
            end
        else
            if is_set( Section ) then
                Section = sepc .. &quot; &quot; .. wrap( 'section', Section, use_lowercase );
                if is_set( Inset ) then
                    Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
                end
            elseif is_set( Inset ) then
                Inset = sepc .. &quot; &quot; .. wrap( 'inset', Inset, use_lowercase );
            end            
        end            
        At = At .. Section .. Inset;        
    end    
    
    Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
    TitleType = is_set(TitleType) and (&quot; (&quot; .. TitleType .. &quot;)&quot;) or &quot;&quot;;
    TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
    Language = is_set(Language) and (&quot; &quot; .. wrap( 'language', Language )) or &quot;&quot;;
    Edition = is_set(Edition) and (&quot; &quot; .. wrap( 'edition', Edition )) or &quot;&quot;;
    Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
    Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
    OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
    Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;
    
    if is_set(Volume) then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume;
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
        end
    end
    
    ------------------------------------ totally unrelated data
    -- Mimic {{subscription required}} template; 
    if is_set(Via) then
        Via = &quot; &quot; .. wrap( 'via', Via );
    end
--      SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];   --citation always requires subscription if 'via' parameter is used
                                                                              -- This line removed because of editors desire to use via for citations that do not require subscriptions
    if is_set(SubscriptionRequired) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription_no_via']; --here when 'via' parameter not used but 'subscription' is
    elseif is_set(RegistrationRequired) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration']; --here when 'via' and 'subscription' parameters not used but 'registration' is
    end

    if is_set(AccessDate) then
        local retrv_text = &quot; &quot; .. cfg.messages['retrieved']
        if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
        AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
            .. substitute( retrv_text, {AccessDate} ) .. '&lt;/span&gt;'
    end
    
    if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
    
    ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN} );

    if is_set(URL) then
        URL = &quot; &quot; .. externallink( URL, nil, URLorigin );
    end

    if is_set(Quote) then
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        Quote = sepc ..&quot; &quot; .. wrap( 'quoted-text', Quote ); 
        PostScript = &quot;&quot;;
    elseif PostScript:lower() == &quot;none&quot; then
        PostScript = &quot;&quot;;
    end
    
    local Archived
    if is_set(ArchiveURL) then
        if not is_set(ArchiveDate) then
            ArchiveDate = seterror('archive_missing_date');
        end
        if &quot;no&quot; == DeadURL then
            local arch_text = cfg.messages['archived'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
                { externallink( ArchiveURL, arch_text ), ArchiveDate } );
            if not is_set(OriginalURL) then
                Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url');                               
            end
        elseif is_set(OriginalURL) then
            local arch_text = cfg.messages['archived-dead'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text,
                { externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
        else
            local arch_text = cfg.messages['archived-missing'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
                { seterror('archive_missing_url'), ArchiveDate } );
        end
    else
        Archived = &quot;&quot;
    end
    
    local Lay
    if is_set(LayURL) then
        if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
        if is_set(LaySource) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot;;
        else
            LaySource = &quot;&quot;;
        end
        if sepc == '.' then
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;;
    end
    
    if is_set(Transcript) then
        if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
    elseif is_set(TranscriptURL) then
        Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
    end
    
    local Publisher;
    if is_set(Periodical) and
        not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;}) then
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end
        elseif is_set(PublicationPlace) then
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if is_set(PublicationDate) then
            if is_set(Publisher) then
                Publisher = Publisher .. &quot;, &quot; .. wrap( 'published', PublicationDate );
            else
                Publisher = PublicationDate;
            end
        end
        if is_set(Publisher) then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if is_set(PublicationDate) then
            PublicationDate = &quot; (&quot; .. wrap( 'published', PublicationDate ) .. &quot;)&quot;;
        end
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif is_set(PublicationPlace) then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    
    -- Several of the above rely upon detecting this as nil, so do it last.
    if is_set(Periodical) then
        if is_set(Title) or is_set(TitleNote) then 
            Periodical = sepc .. &quot; &quot; .. wrap( 'italic-title', Periodical ) 
        else 
            Periodical = wrap( 'italic-title', Periodical )
        end
    end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if inArray(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
        if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, 
            Language, Cartography, Edition, Publisher, Agency, Volume, Issue}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, Language, 
            Volume, Issue, Others, Cartography, Edition, Publisher, Agency}, sepc );
    end
    
    if #ID_list &gt; 0 then
        ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
    else
        ID_list = ID;
    end
    
    local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
    local text;
    local pgtext = Position .. Page .. Pages .. At;
    
    if is_set(Authors) then
        if is_set(Coauthors) then
            Authors = Authors .. A['AuthorSeparator'] .. &quot; &quot; .. Coauthors
        end
        if is_set(Date) then
            Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        elseif string.sub(Authors,-1,-1) == sepc then
            Authors = Authors .. &quot; &quot;
        else
            Authors = Authors .. sepc .. &quot; &quot;
        end
        if is_set(Editors) then
            local in_text = &quot; &quot;;
            local post_text = &quot;&quot;;
            if is_set(Chapter) then
                in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
            else
                if EditorCount &lt;= 1 then
                    post_text = &quot;, &quot; .. cfg.messages['editor'];
                else
                    post_text = &quot;, &quot; .. cfg.messages['editors'];
                end
            end 
            if (sepc ~= '.') then in_text = in_text:lower() end
            Editors = in_text .. Editors .. post_text;
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = Editors .. &quot; &quot;
                else Editors = Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif is_set(Editors) then
        if is_set(Date) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
            else
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if is_set(Date) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end
        if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
            text = safejoin( {Chapter, Place, tcommon}, sepc );
            text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
            text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
            text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if is_set(PostScript) and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    if not is_set(Year) then
        if is_set(DateIn) then
            Year = selectyear( DateIn );
        elseif is_set(PublicationDate) then
            Year = selectyear( PublicationDate );
        end
    end
    
    local options = {};
    
    if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
        options.class = &quot;citation &quot; .. config.CitationClass;
    else
        options.class = &quot;citation&quot;;
    end
    
    if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if #a &gt; 0 then
                for i,v in ipairs(a) do 
                    names[i] = v.last 
                    if i == 4 then break end
                end
            elseif #e &gt; 0 then
                for i,v in ipairs(e) do 
                    names[i] = v.last 
                    if i == 4 then break end                
                end
            end
            names[ #names + 1 ] = Year;
            id = anchorid(names)
        end
        options.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = {};
        text = seterror('empty_citation');
        z.message_tail = {};
    end
    
    if is_set(options.id) then 
        text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    else
        text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    end        

    local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        text = text .. &quot; &quot;;
        for i,v in ipairs( z.message_tail ) do
            if is_set(v[1]) then
                if i == #z.message_tail then
                    text = text .. errorcomment( v[1], v[2] );
                else
                    text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
                end
            end
        end
    end
    
    no_tracking_cats = no_tracking_cats:lower();
    if inArray(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    local suggestions = {};
    local error_text, error_state;

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        args[k] = v;       
    end    

    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            if not validate( k ) then            
                error_text = &quot;&quot;;
                if type( k ) ~= 'string' then
                    -- Exclude empty numbered parameters
                    if v:match(&quot;%S+&quot;) ~= nil then
                        error_text, error_state = seterror( 'text_ignored', {v}, true );
                    end
                elseif validate( k:lower() ) then 
                    error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
                else
                    if #suggestions == 0 then
                        suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
                    end
                    if suggestions[ k:lower() ] ~= nil then
                        error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
                    else
                        error_text, error_state = seterror( 'parameter_ignored', {k}, true );
                    end
                end                  
                if error_text ~= '' then
                    table.insert( z.message_tail, {error_text, error_state} );
                end                
            end
            args[k] = v;
        elseif args[k] ~= nil or (k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z</text>
      <sha1>mvned19itk93o0dvg6ypwkx9i9hhxgq</sha1>
    </revision>
    <revision>
      <id>4660</id>
      <parentid>4659</parentid>
      <timestamp>2013-09-21T12:00:26Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Subscription/Registration help; Via cat fix; identifier protocol relative urls; PMC identifier fix; iso639-1 support;</comment>
      <origin>4660</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="62632" sha1="0bjkkscopz2k9yeoti72n6rf6yi9yw5" xml:space="preserve">local z = {
    error_categories = {};
    error_ids = {};
    message_tail = {};
}

-- Include translation message hooks, ID and error handling configuration settings.
local cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );

-- Contains a list of all recognized parameters
local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );

-- Whether variable is set or not
function is_set( var )
    return not (var == nil or var == '');
end

-- First set variable or nil if none
function first_set(...)
    local list = {...};
    for _, var in pairs(list) do
        if is_set( var ) then
            return var;
        end
    end
end

-- Whether needle is in haystack
function inArray( needle, haystack )
    if needle == nil then
        return false;
    end
    for n,v in ipairs( haystack ) do
        if v == needle then
            return n;
        end
    end
    return false;
end

-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
    return args and tostring( mw.message.newRawMessage( msg, args ) ) or msg;
end

-- Wraps a string using a message_list configuration taking one argument
function wrap( key, str, lower )
    if not is_set( str ) then
        return &quot;&quot;;
    elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
        str = safeforitalics( str );
    end
    if lower == true then
        return substitute( cfg.messages[key]:lower(), {str} );
    else
        return substitute( cfg.messages[key], {str} );
    end        
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
    local origin = {};
    
    return setmetatable({
        ORIGIN = function( self, k )
            local dummy = self[k]; --force the variable to be loaded.
            return origin[k];
        end
    },
    {
        __index = function ( tbl, k )
            if origin[k] ~= nil then
                return nil;
            end
            
            local args, list, v = args, cfg.aliases[k];
            
            if type( list ) == 'table' then
                v, origin[k] = selectone( args, list, 'redundant_parameters' );
                if origin[k] == nil then
                    origin[k] = ''; -- Empty string, not nil
                end
            elseif list ~= nil then
                v, origin[k] = args[list], list;
            else
                -- maybe let through instead of raising an error?
                -- v, origin[k] = args[k], k;
                error( cfg.messages['unknown_argument_map'] );
            end
            
            -- Empty strings, not nil;
            if v == nil then
                v = cfg.defaults[k] or '';
                origin[k] = '';
            end
            
            tbl = rawset( tbl, k, v );
            return v;
        end,
    });
end

-- Checks that parameter name is valid using the whitelist
function validate( name )
    name = tostring( name );
    
    -- Normal arguments
    if whitelist.basic_arguments[ name ] then
        return true;
    end
    
    -- Arguments with numbers in them
    name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );
    if whitelist.numbered_arguments[ name ] then
        return true;
    end
    
    -- Not found, argument not supported.
    return false
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
    return wrap( hidden and 'hidden-error' or 'visible-error', content );
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
    local error_state = cfg.error_conditions[ error_id ];
    
    prefix = prefix or &quot;&quot;;
    suffix = suffix or &quot;&quot;;
    
    if error_state == nil then
        error( cfg.messages['undefined_error'] );
    elseif is_set( error_state.category ) then
        table.insert( z.error_categories, error_state.category );
    end
    
    local message = substitute( error_state.message, arguments );
    
    message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
        &quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
        cfg.messages['help page label'] .. &quot;]])&quot;;
    
    z.error_ids[ error_id ] = true;
    if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
            and z.error_ids['citation_missing_title'] then
        return '', false;
    end
    
    message = table.concat({ prefix, message, suffix });
    
    if raw == true then
        return message, error_state.hidden;
    end        
        
    return errorcomment( message, error_state.hidden );
end

-- Formats a wiki style external link
function externallinkid(options)
    local url_string = options.id;
    if options.encode == true or options.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, url_string, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Formats a wiki style internal link
function internallinkid(options)
    return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, options.id, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Format an external link with error checking
function externallink( URL, label, source )
    local error_str = &quot;&quot;;
    if not is_set( label ) then
        label = URL;
        if is_set( source ) then
            error_str = seterror( 'bare_url_missing_title', { wrap( 'parameter', source ) }, false, &quot; &quot; );
        else
            error( cfg.messages[&quot;bare_url_no_origin&quot;] );
        end            
    end
    if not checkurl( URL ) then
        error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
    end
    return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safeforurl( label ), &quot;]&quot;, error_str });
end

-- Formats a link to Amazon
function amazon(id, domain)
    if not is_set(domain) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local handler = cfg.id_handlers['ASIN'];
    return externallinkid({link = handler.link,
        label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
        encode=handler.encode, separator = handler.separator})
end

--[[
Formats a PMC and checks for embargoed articles.  The embargo parameter takes a date for a value. If the embargo date is in the futue
the PMC identifier will not be linked to the article.  If the embargo specifies a date in the past, or if it is empty or omitted, then
the PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].link.

The {{citation/core}} version of {{cite journal}} links the citation title (if url parameter is empty) when embargo date is in the past
or when embargo parameter is missing or empty. That behavior is inconsistent with the behavior of other identifiers used in CS1 and is
not supported here.
]]
function pmc(id, embargo)
	local handler = cfg.id_handlers['PMC'];
    
	local text;
	
	if is_set(embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );

		if good1 and good2 and tonumber( embargo_date ) &lt; tonumber( todays_date ) then	--if embargo date is in the past then
			text = externallinkid({link = handler.link, label = handler.label,			--ok to link to article
				prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		else
			text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id;	--still embargoed so no external link
		end
	else
		text = externallinkid({link = handler.link, label = handler.label,			--no embargo date, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
	end
	return text
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    local handler = cfg.id_handlers['DOI'];
    
    local text;
    if is_set(inactive) then
        text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link = handler.link, label = handler.label,
            prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then      
        cat = seterror( 'bad_doi' );
    end
    return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    local handler = cfg.id_handlers['OL'];
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    else
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode}) .. 
            ' ' .. seterror( 'bad_ol' );
    end
end

--[[
Determines whether an URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
    -- Protocol-relative or URL scheme
    return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
    return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
    isbn_str = cleanisbn( isbn_str ):gsub( &quot;-&quot;, &quot;&quot; );
    local len = isbn_str:len();
 
    if len ~= 10 and len ~= 13 then
        return false;
    end
 
    local temp = 0;
    if len == 10 then
        if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            if v == string.byte( &quot;X&quot; ) then
                temp = temp + 10*( 11 - i );
            else
                temp = temp + tonumber( string.char(v) )*(11-i);
            end
        end
        return temp % 11 == 0;
    else
        if isbn_str:match( &quot;^%d*$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
        end
        return temp % 10 == 0;
    end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
    return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
        return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
    end));
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if not is_set(str) then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        
        -- Remove newlines as they break italics.
        return str:gsub( '\n', ' ' );
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    -- Is the input a simple number?
    local num = tonumber( str ); 
    if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.floor(num) then
        return str;
    else
        -- Use formatDate to interpret more complicated formats
        local lang = mw.getContentLanguage();
        local good, result;
        good, result = pcall( lang.formatDate, lang, 'Y', str );
        if good then 
            return result;
        else
            -- extract year if the date uses seasons
            str=string.lower (str);
            local seasons={&quot;winter&quot;, &quot;spring&quot;, &quot;summer&quot;, &quot;fall&quot;, &quot;autumn&quot;};
            local date_string_split=mw.text.split (str, &quot;[%s%-/–]&quot;);      -- split date string into parts; white space, hyphen, forward slash, and ndash are allowed separators
            local has_season=false;
            
            for n,season_value in ipairs(seasons) do                -- for each season ...
                for n,split_value in ipairs(date_string_split) do   -- ... loop through date string values 
                    if split_value == season_value then             -- does the split value match the season value?
                        if has_season==false then                   -- found one. if this one is the first we've found ...
                            has_season=true;                        -- ... remember that we found a season
                        end
                    elseif has_season==true then                    -- if split_value isn't a season, and we've previously found a season ...
                        num = tonumber( split_value );              -- ... convert current split value to a number if we can
                        if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.floor(num) then    -- if it's a suitable number
                            return tostring( num );                                                 -- return it as a string
                        end -- if num
                    end -- if string.find
                end -- for split value loop
            end -- season value loop
        end -- if good
    end -- if num
end -- selectyear

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    if maximum ~= nil and maximum &lt; 1 then return &quot;&quot;, 0; end
    
    for i,person in ipairs(people) do
        if is_set(person.last) then
            local mask = person.mask
            local one
            local sep_one = sep;
            if maximum ~= nil and i &gt; maximum then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask;
                    sep_one = &quot; &quot;;
                end
            else
                one = person.last
                local first = person.first
                if is_set(first) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if is_set(person.link) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert( text, one )
            table.insert( text, sep_one )
        end
    end

    local count = #text / 2;
    if count &gt; 0 then 
        if count &gt; 1 and is_set(lastauthoramp) and not etal then
            text[#text-2] = &quot; &amp; &quot;;
        end
        text[#text] = nil; 
    end
    
    local result = table.concat(text) -- construct list
    if etal then 
        local etal_text = cfg.messages['et al'];
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result = 
        '&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
    end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
    return &quot;CITEREF&quot; .. table.concat( options );
end

-- Gets name list from the input arguments
function extractnames(args, list_name)
    local names = {};
    local i = 1;
    local last;
    
    while true do
        last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );
        if not is_set(last) then
            -- just in case someone passed in an empty parameter
            break;
        end
        names[i] = {
            last = last,
            first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i ),
            link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ),
            mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i )
        };
        i = i + 1;
    end
    return names;
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
    local id_list = {};
    for k, v in pairs( cfg.id_handlers ) do    
        v = selectone( args, v.parameters, 'redundant_parameters' );
        if is_set(v) then id_list[k] = v; end
    end
    return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
    local new_list, handler = {};
    
    function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
    
    for k, v in pairs( id_list ) do
        -- fallback to read-only cfg
        handler = setmetatable( { ['id'] = v }, fallback(k) );
        
        if handler.mode == 'external' then
            table.insert( new_list, {handler.label, externallinkid( handler ) } );
        elseif handler.mode == 'internal' then
            table.insert( new_list, {handler.label, internallinkid( handler ) } );
        elseif handler.mode ~= 'manual' then
            error( cfg.messages['unknown_ID_mode'] );
        elseif k == 'DOI' then
            table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
        elseif k == 'ASIN' then
            table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
        elseif k == 'OL' then
            table.insert( new_list, {handler.label, openlibrary( v ) } );
        elseif k == 'PMC' then
            table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
        elseif k == 'ISBN' then
            local ISBN = internallinkid( handler );
            if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
                ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
            end
            table.insert( new_list, {handler.label, ISBN } );                
        else
            error( cfg.messages['unknown_manual_ID'] );
        end
    end
    
    function comp( a, b )
        return a[1] &lt; b[1];
    end
    
    table.sort( new_list, comp );
    for k, v in ipairs( new_list ) do
        new_list[k] = v[2];
    end
    
    return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
    local value = nil;
    local selected = '';
    local error_list = {};
    
    if index ~= nil then index = tostring(index); end
    
    -- Handle special case of &quot;#&quot; replaced by empty string
    if index == '1' then
        for _, v in ipairs( possible ) do
            v = v:gsub( &quot;#&quot;, &quot;&quot; );
            if is_set(args[v]) then
                if value ~= nil and selected ~= v then
                    table.insert( error_list, v );
                else
                    value = args[v];
                    selected = v;
                end
            end
        end        
    end
    
    for _, v in ipairs( possible ) do
        if index ~= nil then
            v = v:gsub( &quot;#&quot;, index );
        end
        if is_set(args[v]) then
            if value ~= nil and selected ~=  v then
                table.insert( error_list, v );
            else
                value = args[v];
                selected = v;
            end
        end
    end
    
    if #error_list &gt; 0 then
        local error_str = &quot;&quot;;
        for _, k in ipairs( error_list ) do
            if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
            error_str = error_str .. wrap( 'parameter', k );
        end
        if #error_list &gt; 1 then
            error_str = error_str .. cfg.messages['parameter-final-separator'];
        else
            error_str = error_str .. cfg.messages['parameter-pair-separator'];
        end
        error_str = error_str .. wrap( 'parameter', selected );
        table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
    end
    
    return value, selected;
end

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
function COinS(data)
    if 'table' ~= type(data) or nil == next(data) then
        return '';
    end
    
    local ctx_ver = &quot;Z39.88-2004&quot;;
    
    -- treat table strictly as an array with only set values.
    local OCinSoutput = setmetatable( {}, {
        __newindex = function(self, key, value)
            if is_set(value) then
                rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
            end
        end
    });
    
    if is_set(data.Chapter) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Chapter;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    elseif is_set(data.Periodical) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
        OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    else
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
    end
    
    OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
    OCinSoutput[&quot;rft.date&quot;] = data.Date;
    OCinSoutput[&quot;rft.series&quot;] = data.Series;
    OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
    OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
    OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
    OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
    OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
    
    for k, v in pairs( data.ID_list ) do
        local id, value = cfg.id_handlers[k].COinS;
        if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
        if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
            OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
        else
            OCinSoutput[ id ] = value;
        end
    end
    
    local last, first;
    for k, v in ipairs( data.Authors ) do
        last, first = v.last, v.first;
        if k == 1 then
            if is_set(last) then
                OCinSoutput[&quot;rft.aulast&quot;] = last;
            end
            if is_set(first) then 
                OCinSoutput[&quot;rft.aufirst&quot;] = first;
            end
        end
        if is_set(last) and is_set(first) then
            OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
        elseif is_set(last) then
            OCinSoutput[&quot;rft.au&quot;] = last;
        end
    end
    
    OCinSoutput.rft_id = data.URL;
    OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
    OCinSoutput = setmetatable( OCinSoutput, nil );
    
    -- sort with version string always first, and combine.
    table.sort( OCinSoutput );
    table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
    return table.concat(OCinSoutput, &quot;&amp;&quot;);
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    --[[ 
    Load Input Parameters
    The argment_wrapper facillitates the mapping of multiple
    aliases to single internal variable.
    ]]
    local A = argument_wrapper( args );

    local i 
    local PPrefix = A['PPrefix']
    local PPPrefix = A['PPPrefix']
    if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = A['Authors'];
    local a = extractnames( args, 'AuthorList' );

    local Coauthors = A['Coauthors'];
    local Others = A['Others'];
    local Editors = A['Editors'];
    local e = extractnames( args, 'EditorList' );

    local Year = A['Year'];
    local PublicationDate = A['PublicationDate'];
    local OrigYear = A['OrigYear'];
    local Date = A['Date'];
    local LayDate = A['LayDate'];
    ------------------------------------------------- Get title data
    local Title = A['Title'];
    local BookTitle = A['BookTitle'];
    local Conference = A['Conference'];
    local TransTitle = A['TransTitle'];
    local TitleNote = A['TitleNote'];
    local TitleLink = A['TitleLink'];
    local Chapter = A['Chapter'];
    local ChapterLink = A['ChapterLink'];
    local TransChapter = A['TransChapter'];
    local TitleType = A['TitleType'];
    local ArchiveURL = A['ArchiveURL'];
    local URL = A['URL']
    local URLorigin = A:ORIGIN('URL');
    local ChapterURL = A['ChapterURL'];
    local ChapterURLorigin = A:ORIGIN('ChapterURL');
    local ConferenceURL = A['ConferenceURL'];
    local ConferenceURLorigin = A:ORIGIN('ConferenceURL');
    local Periodical = A['Periodical'];
    
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if not is_set(Chapter) then
            if not is_set(Title) then
                Title = Periodical;
                Periodical = '';
            else
                Chapter = Title
                TransChapter = TransTitle
                Title = '';
                TransTitle = '';
            end
        end
    end

    local Series = A['Series'];
    local Volume = A['Volume'];
    local Issue = A['Issue'];
    local Position = '';
    local Page, Pages, At, page_type;
    
    Page = A['Page'];
    Pages = hyphentodash( A['Pages'] );
    At = A['At'];
    
    if is_set(Page) then
        if is_set(Pages) or is_set(At) then
            Page = Page .. &quot; &quot; .. seterror('extra_pages');
            Pages = '';
            At = '';
        end
    elseif is_set(Pages) then
        if is_set(At) then
            Pages = Pages .. &quot; &quot; .. seterror('extra_pages');
            At = '';
        end
    end    
    
    local Edition = A['Edition'];
    local PublicationPlace = A['PublicationPlace']
    local Place = A['Place'];
    
    if not is_set(PublicationPlace) and is_set(Place) then
        PublicationPlace = Place;
    end
    
    if PublicationPlace == Place then Place = ''; end
    
    local PublisherName = A['PublisherName'];
    local RegistrationRequired = A['RegistrationRequired'];
    local SubscriptionRequired = A['SubscriptionRequired'];
    local Via = A['Via'];
    local AccessDate = A['AccessDate'];
    local ArchiveDate = A['ArchiveDate'];
    local Agency = A['Agency'];
    local DeadURL = A['DeadURL']
    local Language = A['Language'];
    local Format = A['Format'];
    local Ref = A['Ref'];
    
    local DoiBroken = A['DoiBroken'];
    local ID = A['ID'];
    local ASINTLD = A['ASINTLD'];
    local IgnoreISBN = A['IgnoreISBN'];
    local Embargo = A['Embargo'];

    local ID_list = extractids( args );
    
    local Quote = A['Quote'];
    local PostScript = A['PostScript'];
    local LayURL = A['LayURL'];
    local LaySource = A['LaySource'];
    local Transcript = A['Transcript'];
    local TranscriptURL = A['TranscriptURL'] 
    local TranscriptURLorigin = A:ORIGIN('TranscriptURL');
    local sepc = A['Separator'];
    local LastAuthorAmp = A['LastAuthorAmp'];
    local no_tracking_cats = A['NoTracking'];

    local use_lowercase = ( sepc ~= '.' );
    local this_page = mw.title.getCurrentTitle();  --Also used for COinS and for language
    
    if not is_set(no_tracking_cats) then
        for k, v in pairs( cfg.uncategorized_namespaces ) do
            if this_page.nsText == v then
                no_tracking_cats = &quot;true&quot;;
                break;
            end
        end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if is_set(BookTitle) then
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = BookTitle;
        TitleLink = '';
        TransTitle = '';
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = A['AirDate'];
        local SeriesLink = A['SeriesLink'];
        local Season = A['Season'];
        local SeriesNumber = A['SeriesNumber'];
        local Network = A['Network'];
        local Station = A['Station'];
        local s, n = {}, {};
        local Sep = (first_set(A[&quot;SeriesSeparator&quot;], A[&quot;Separator&quot;]) or &quot;&quot;) .. &quot; &quot;;
        
        if is_set(Issue) then table.insert(s, cfg.messages[&quot;episode&quot;] .. &quot; &quot; .. Issue); Issue = ''; end
        if is_set(Season) then table.insert(s, cfg.messages[&quot;season&quot;] .. &quot; &quot; .. Season); end
        if is_set(SeriesNumber) then table.insert(s, cfg.messages[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber); end
        if is_set(Network) then table.insert(n, Network); end
        if is_set(Station) then table.insert(n, Station); end
        
        Date = Date or AirDate;
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = Series;
        TitleLink = SeriesLink;
        TransTitle = '';
        
        Series = table.concat(s, Sep);
        ID = table.concat(n, Sep);
    end
    
    -- COinS metadata (see &lt;http://ocoins.info/&gt;) for
    -- automated parsing of citation information.
    local OCinSoutput = COinS{
        ['Periodical'] = Periodical,
        ['Chapter'] = Chapter,
        ['Title'] = Title,
        ['PublicationPlace'] = PublicationPlace,
        ['Date'] = first_set(Date, Year, PublicationDate),
        ['Series'] = Series,
        ['Volume'] = Volume,
        ['Issue'] = Issue,
        ['Pages'] = first_set(Page, Pages, At),
        ['Edition'] = Edition,
        ['PublisherName'] = PublisherName,
        ['URL'] = first_set( URL, ChapterURL ),
        ['Authors'] = a,
        ['ID_list'] = ID_list,
        ['RawPage'] = this_page.prefixedText,
    };

    if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = '';
        TitleLink = '';
        TransTitle = '';
    end

    -- Now perform various field 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 not is_set(Authors) then
        local Maximum = tonumber( A['DisplayAuthors'] );
        
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #a == 9 then 
            Maximum = 8;
            table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
        elseif not is_set(Maximum) then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = A[&quot;AuthorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;AuthorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A[&quot;AuthorFormat&quot;],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if is_set(Coauthors) then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
        
        Authors = listpeople(control, a) 
    end

    local EditorCount
    if not is_set(Editors) then
        local Maximum = tonumber( A['DisplayEditors'] );
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #e == 4 then 
            Maximum = 3;
            table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
        elseif not is_set(Maximum) then
            Maximum = #e + 1;
        end

        local control = { 
            sep = A[&quot;EditorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;EditorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A['EditorFormat'],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };

        Editors, EditorCount = listpeople(control, e);
    else
        EditorCount = 1;
    end

    local Cartography = &quot;&quot;;
    local Scale = &quot;&quot;;
    if config.CitationClass == &quot;map&quot; then
        if not is_set( Authors ) and is_set( PublisherName ) then
            Authors = PublisherName;
            PublisherName = &quot;&quot;;
        end
        Cartography = A['Cartography'];
        if is_set( Cartography ) then
            Cartography = sepc .. &quot; &quot; .. wrap( 'cartography', Cartography, use_lowercase );
        end        
        Scale = A['Scale'];
        if is_set( Scale ) then
            Scale = sepc .. &quot; &quot; .. Scale;
        end        
    end
    
    if not is_set(Date) then
        Date = Year;
        if is_set(Date) then
            local Month = A['Month'];
            if is_set(Month) then 
                Date = Month .. &quot; &quot; .. Date;
                local Day = A['Day']
                if is_set(Day) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    
    if inArray(PublicationDate, {Date, Year}) then PublicationDate = ''; end
    if not is_set(Date) and is_set(PublicationDate) then
        Date = PublicationDate;
        PublicationDate = '';
    end

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date;
    
    if  not is_set(URL) and
        not is_set(ChapterURL) and
        not is_set(ArchiveURL) and
        not is_set(ConferenceURL) and
        not is_set(TranscriptURL) then
        
        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
        end
        
        -- Test if accessdate is given without giving a URL
        if is_set(AccessDate) then
            table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
            AccessDate = '';
        end
        
        -- Test if format is given without giving a URL
        if is_set(Format) then
            Format = Format .. seterror( 'format_missing_url' );
        end
    end
    
    -- Test if citation has no title
    if  not is_set(Chapter) and
        not is_set(Title) and
        not is_set(Periodical) and
        not is_set(Conference) and
        not is_set(TransTitle) and
        not is_set(TransChapter) then
        table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
    end
    
    Format = is_set(Format) and &quot; (&quot; .. Format .. &quot;)&quot; or &quot;&quot;;
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if is_set( ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
            URLorigin = A:ORIGIN('ArchiveURL')
        end
    end
    
    -- Format chapter / article title
    if is_set(Chapter) and is_set(ChapterLink) then 
        Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot;;
    end
    if is_set(Periodical) and is_set(Title) then
        Chapter = wrap( 'italic-title', Chapter );
        TransChapter = wrap( 'trans-italic-title', TransChapter );
    else
        Chapter = wrap( 'quoted-title', Chapter );
        TransChapter = wrap( 'trans-quoted-title', TransChapter );
    end
    
    local TransError = &quot;&quot;
    if is_set(TransChapter) then
        if not is_set(Chapter) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
        else
            TransChapter = &quot; &quot; .. TransChapter;
        end
    end
    
    Chapter = Chapter .. TransChapter;
    
    if is_set(Chapter) then
        if not is_set(ChapterLink) then
            if is_set(ChapterURL) then
                Chapter = externallink( ChapterURL, Chapter ) .. TransError;
                if not is_set(URL) then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif is_set(URL) then 
                Chapter = externallink( URL, Chapter ) .. TransError .. Format;
                URL = &quot;&quot;;
                Format = &quot;&quot;;
            else
                Chapter = Chapter .. TransError;
            end            
        elseif is_set(ChapterURL) then
            Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. 
                TransError;
        else
            Chapter = Chapter .. TransError;
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    elseif is_set(ChapterURL) then
        Chapter = &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. sepc .. &quot; &quot;;
    end        
    
    -- Format main title.
    if is_set(TitleLink) and is_set(Title) then
        Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
    end
    
    if is_set(Periodical) then
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    elseif inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;pressrelease&quot;,&quot;conference&quot;}) and
            not is_set(Chapter) then
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    else
        Title = wrap( 'italic-title', Title );
        TransTitle = wrap( 'trans-italic-title', TransTitle );
    end
    
    TransError = &quot;&quot;;
    if is_set(TransTitle) then
        if not is_set(Title) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
        else
            TransTitle = &quot; &quot; .. TransTitle;
        end
    end
    
    Title = Title .. TransTitle;
    
    if is_set(Title) then
        if not is_set(TitleLink) and is_set(URL) then 
            Title = externallink( URL, Title ) .. TransError .. Format       
            URL = &quot;&quot;;
            Format = &quot;&quot;;
        else
            Title = Title .. TransError;
        end
    end
    
    if is_set(Place) then
        Place = &quot; &quot; .. wrap( 'written', Place, use_lowercase ) .. sepc .. &quot; &quot;;
    end
    
    if is_set(Conference) then
        if is_set(ConferenceURL) then
            Conference = externallink( ConferenceURL, Conference );
        end
        Conference = sepc .. &quot; &quot; .. Conference
    elseif is_set(ConferenceURL) then
        Conference = sepc .. &quot; &quot; .. externallink( ConferenceURL, nil, ConferenceURLorigin );
    end
    
    if not is_set(Position) then
        local Minutes = A['Minutes'];
        if is_set(Minutes) then
            Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
        else
            local Time = A['Time'];
            if is_set(Time) then
                local TimeCaption = A['TimeCaption']
                if not is_set(TimeCaption) then
                    TimeCaption = cfg.messages['event'];
                    if sepc ~= '.' then
                        TimeCaption = TimeCaption:lower();
                    end
                end
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
            end
        end
    else
        Position = &quot; &quot; .. Position;
        At = '';
    end
    
    if not is_set(Page) then
        if is_set(Pages) then
            if is_set(Periodical) and
                not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;}) then
                Pages = &quot;: &quot; .. Pages;
            elseif tonumber(Pages) ~= nil then
                Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
            else
                Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
            end
        end
    else
        if is_set(Periodical) and
            not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;}) then
            Page = &quot;: &quot; .. Page;
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page;
        end
    end
    
    At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
    Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
    if config.CitationClass == 'map' then
        local Section = A['Section'];
        local Inset = A['Inset'];
        if first_set( Pages, Page, At ) ~= nil or sepc ~= '.' then
            if is_set( Section ) then
                Section = &quot;, &quot; .. wrap( 'section', Section, true );
            end
            if is_set( Inset ) then
                Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
            end
        else
            if is_set( Section ) then
                Section = sepc .. &quot; &quot; .. wrap( 'section', Section, use_lowercase );
                if is_set( Inset ) then
                    Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
                end
            elseif is_set( Inset ) then
                Inset = sepc .. &quot; &quot; .. wrap( 'inset', Inset, use_lowercase );
            end            
        end            
        At = At .. Section .. Inset;        
    end    

	--[[Look in the list of iso639-1 language codes to see if the value provided in the language parameter matches one of them.  If a match is found, 
	use that value; if not, then use the value that was provided with the language parameter.
	
	Categories are assigned in a manner similar to the {{xx icon}} templates - categorizes only mainspace citations and only when the language code is not 'en' (English).
	]]
	if is_set (Language) then
		local name = cfg.iso639_1[Language:lower()];		-- get the language name if Language parameter has a valid iso 639-1 code
		if nil == name then
			Language=&quot; &quot; .. wrap( 'language', Language );	-- no match, use parameter's value
		else
			if 0 == this_page.namespace and 'en' ~= Language:lower() then	--found a match; is this page main / article space and English not the language?
				Language=&quot; &quot; .. wrap( 'language', name .. '[[Category:Articles with ' .. name .. '-language external links]]' );	-- in main space and not English: categorize
			else
				Language=&quot; &quot; .. wrap( 'language', name );	--not in mainspace or language is English so don't categorize
			end
		end
	else
		Language=&quot;&quot;;	-- language not specified so make sure this is an empty string;
	end

    Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
    TitleType = is_set(TitleType) and (&quot; (&quot; .. TitleType .. &quot;)&quot;) or &quot;&quot;;
    TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
    Edition = is_set(Edition) and (&quot; &quot; .. wrap( 'edition', Edition )) or &quot;&quot;;
    Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
    Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
    OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
    Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;
    
    if is_set(Volume) then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume;
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
        end
    end
    
    ------------------------------------ totally unrelated data
    --[[ Loosely mimic {{subscription required}} template; Via parameter identifies a delivery source that is not the publisher; these sources often, but not always, exist
    behind a registration or paywall.  So here, we've chosen to decouple via from subscription (via has never been part of the registration required template).
    
    Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link note is displayed. There are no error messages for this condition.
    ]]
    if is_set(Via) then
        Via = &quot; &quot; .. wrap( 'via', Via );
    end

	if is_set(SubscriptionRequired) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription']; --here when 'via' parameter not used but 'subscription' is
    elseif is_set(RegistrationRequired) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration']; --here when 'via' and 'subscription' parameters not used but 'registration' is
    end

    if is_set(AccessDate) then
        local retrv_text = &quot; &quot; .. cfg.messages['retrieved']
        if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
        AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
            .. substitute( retrv_text, {AccessDate} ) .. '&lt;/span&gt;'
    end
    
    if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
    
    ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo} );

    if is_set(URL) then
        URL = &quot; &quot; .. externallink( URL, nil, URLorigin );
    end

    if is_set(Quote) then
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        Quote = sepc ..&quot; &quot; .. wrap( 'quoted-text', Quote ); 
        PostScript = &quot;&quot;;
    elseif PostScript:lower() == &quot;none&quot; then
        PostScript = &quot;&quot;;
    end
    
    local Archived
    if is_set(ArchiveURL) then
        if not is_set(ArchiveDate) then
            ArchiveDate = seterror('archive_missing_date');
        end
        if &quot;no&quot; == DeadURL then
            local arch_text = cfg.messages['archived'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
                { externallink( ArchiveURL, arch_text ), ArchiveDate } );
            if not is_set(OriginalURL) then
                Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url');                               
            end
        elseif is_set(OriginalURL) then
            local arch_text = cfg.messages['archived-dead'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text,
                { externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
        else
            local arch_text = cfg.messages['archived-missing'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
                { seterror('archive_missing_url'), ArchiveDate } );
        end
    else
        Archived = &quot;&quot;
    end
    
    local Lay
    if is_set(LayURL) then
        if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
        if is_set(LaySource) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot;;
        else
            LaySource = &quot;&quot;;
        end
        if sepc == '.' then
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;;
    end
    
    if is_set(Transcript) then
        if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
    elseif is_set(TranscriptURL) then
        Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
    end
    
    local Publisher;
    if is_set(Periodical) and
        not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;}) then
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end
        elseif is_set(PublicationPlace) then
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if is_set(PublicationDate) then
            if is_set(Publisher) then
                Publisher = Publisher .. &quot;, &quot; .. wrap( 'published', PublicationDate );
            else
                Publisher = PublicationDate;
            end
        end
        if is_set(Publisher) then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if is_set(PublicationDate) then
            PublicationDate = &quot; (&quot; .. wrap( 'published', PublicationDate ) .. &quot;)&quot;;
        end
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif is_set(PublicationPlace) then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    
    -- Several of the above rely upon detecting this as nil, so do it last.
    if is_set(Periodical) then
        if is_set(Title) or is_set(TitleNote) then 
            Periodical = sepc .. &quot; &quot; .. wrap( 'italic-title', Periodical ) 
        else 
            Periodical = wrap( 'italic-title', Periodical )
        end
    end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if inArray(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
        if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, 
            Language, Cartography, Edition, Publisher, Agency, Volume, Issue}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, Language, 
            Volume, Issue, Others, Cartography, Edition, Publisher, Agency}, sepc );
    end
    
    if #ID_list &gt; 0 then
        ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
    else
        ID_list = ID;
    end
    
    local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
    local text;
    local pgtext = Position .. Page .. Pages .. At;
    
    if is_set(Authors) then
        if is_set(Coauthors) then
            Authors = Authors .. A['AuthorSeparator'] .. &quot; &quot; .. Coauthors
        end
        if is_set(Date) then
            Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        elseif string.sub(Authors,-1,-1) == sepc then
            Authors = Authors .. &quot; &quot;
        else
            Authors = Authors .. sepc .. &quot; &quot;
        end
        if is_set(Editors) then
            local in_text = &quot; &quot;;
            local post_text = &quot;&quot;;
            if is_set(Chapter) then
                in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
            else
                if EditorCount &lt;= 1 then
                    post_text = &quot;, &quot; .. cfg.messages['editor'];
                else
                    post_text = &quot;, &quot; .. cfg.messages['editors'];
                end
            end 
            if (sepc ~= '.') then in_text = in_text:lower() end
            Editors = in_text .. Editors .. post_text;
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = Editors .. &quot; &quot;
                else Editors = Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif is_set(Editors) then
        if is_set(Date) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
            else
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if is_set(Date) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end
        if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
            text = safejoin( {Chapter, Place, tcommon}, sepc );
            text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
            text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
            text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if is_set(PostScript) and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    if not is_set(Year) then
        if is_set(DateIn) then
            Year = selectyear( DateIn );
        elseif is_set(PublicationDate) then
            Year = selectyear( PublicationDate );
        end
    end
    
    local options = {};
    
    if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
        options.class = &quot;citation &quot; .. config.CitationClass;
    else
        options.class = &quot;citation&quot;;
    end
    
    if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if #a &gt; 0 then
                for i,v in ipairs(a) do 
                    names[i] = v.last 
                    if i == 4 then break end
                end
            elseif #e &gt; 0 then
                for i,v in ipairs(e) do 
                    names[i] = v.last 
                    if i == 4 then break end                
                end
            end
            names[ #names + 1 ] = Year;
            id = anchorid(names)
        end
        options.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = {};
        text = seterror('empty_citation');
        z.message_tail = {};
    end
    
    if is_set(options.id) then 
        text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    else
        text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    end        

    local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        text = text .. &quot; &quot;;
        for i,v in ipairs( z.message_tail ) do
            if is_set(v[1]) then
                if i == #z.message_tail then
                    text = text .. errorcomment( v[1], v[2] );
                else
                    text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
                end
            end
        end
    end
    
    no_tracking_cats = no_tracking_cats:lower();
    if inArray(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    local suggestions = {};
    local error_text, error_state;

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        args[k] = v;       
    end    

    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            if not validate( k ) then            
                error_text = &quot;&quot;;
                if type( k ) ~= 'string' then
                    -- Exclude empty numbered parameters
                    if v:match(&quot;%S+&quot;) ~= nil then
                        error_text, error_state = seterror( 'text_ignored', {v}, true );
                    end
                elseif validate( k:lower() ) then 
                    error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
                else
                    if #suggestions == 0 then
                        suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
                    end
                    if suggestions[ k:lower() ] ~= nil then
                        error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
                    else
                        error_text, error_state = seterror( 'parameter_ignored', {k}, true );
                    end
                end                  
                if error_text ~= '' then
                    table.insert( z.message_tail, {error_text, error_state} );
                end                
            end
            args[k] = v;
        elseif args[k] ~= nil or (k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z</text>
      <sha1>0bjkkscopz2k9yeoti72n6rf6yi9yw5</sha1>
    </revision>
    <revision>
      <id>4661</id>
      <parentid>4660</parentid>
      <timestamp>2013-10-12T10:38:09Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>ISSN error detection; Expand uncategorized namespaces; Reg/Sub required msg tweak; Trap coauthors without authors; Hide error messages;</comment>
      <origin>4661</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="65461" sha1="pczrwu2bcyarrsod4oqimn3p0xqucy5" xml:space="preserve">local z = {
    error_categories = {};
    error_ids = {};
    message_tail = {};
}

-- Include translation message hooks, ID and error handling configuration settings.
local cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );

-- Contains a list of all recognized parameters
local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );

-- Whether variable is set or not
function is_set( var )
    return not (var == nil or var == '');
end

-- First set variable or nil if none
function first_set(...)
    local list = {...};
    for _, var in pairs(list) do
        if is_set( var ) then
            return var;
        end
    end
end

-- Whether needle is in haystack
function inArray( needle, haystack )
    if needle == nil then
        return false;
    end
    for n,v in ipairs( haystack ) do
        if v == needle then
            return n;
        end
    end
    return false;
end

-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
    return args and tostring( mw.message.newRawMessage( msg, args ) ) or msg;
end

-- Wraps a string using a message_list configuration taking one argument
function wrap( key, str, lower )
    if not is_set( str ) then
        return &quot;&quot;;
    elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
        str = safeforitalics( str );
    end
    if lower == true then
        return substitute( cfg.messages[key]:lower(), {str} );
    else
        return substitute( cfg.messages[key], {str} );
    end        
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
    local origin = {};
    
    return setmetatable({
        ORIGIN = function( self, k )
            local dummy = self[k]; --force the variable to be loaded.
            return origin[k];
        end
    },
    {
        __index = function ( tbl, k )
            if origin[k] ~= nil then
                return nil;
            end
            
            local args, list, v = args, cfg.aliases[k];
            
            if type( list ) == 'table' then
                v, origin[k] = selectone( args, list, 'redundant_parameters' );
                if origin[k] == nil then
                    origin[k] = ''; -- Empty string, not nil
                end
            elseif list ~= nil then
                v, origin[k] = args[list], list;
            else
                -- maybe let through instead of raising an error?
                -- v, origin[k] = args[k], k;
                error( cfg.messages['unknown_argument_map'] );
            end
            
            -- Empty strings, not nil;
            if v == nil then
                v = cfg.defaults[k] or '';
                origin[k] = '';
            end
            
            tbl = rawset( tbl, k, v );
            return v;
        end,
    });
end

-- Checks that parameter name is valid using the whitelist
function validate( name )
    name = tostring( name );
    
    -- Normal arguments
    if whitelist.basic_arguments[ name ] then
        return true;
    end
    
    -- Arguments with numbers in them
    name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );
    if whitelist.numbered_arguments[ name ] then
        return true;
    end
    
    -- Not found, argument not supported.
    return false
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
    return wrap( hidden and 'hidden-error' or 'visible-error', content );
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
    local error_state = cfg.error_conditions[ error_id ];
    
    prefix = prefix or &quot;&quot;;
    suffix = suffix or &quot;&quot;;
    
    if error_state == nil then
        error( cfg.messages['undefined_error'] );
    elseif is_set( error_state.category ) then
        table.insert( z.error_categories, error_state.category );
    end
    
    local message = substitute( error_state.message, arguments );
    
    message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
        &quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
        cfg.messages['help page label'] .. &quot;]])&quot;;
    
    z.error_ids[ error_id ] = true;
    if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
            and z.error_ids['citation_missing_title'] then
        return '', false;
    end
    
    message = table.concat({ prefix, message, suffix });
    
    if raw == true then
        return message, error_state.hidden;
    end        
        
    return errorcomment( message, error_state.hidden );
end

-- Formats a wiki style external link
function externallinkid(options)
    local url_string = options.id;
    if options.encode == true or options.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, url_string, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Formats a wiki style internal link
function internallinkid(options)
    return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, options.id, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Format an external link with error checking
function externallink( URL, label, source )
    local error_str = &quot;&quot;;
    if not is_set( label ) then
        label = URL;
        if is_set( source ) then
            error_str = seterror( 'bare_url_missing_title', { wrap( 'parameter', source ) }, false, &quot; &quot; );
        else
            error( cfg.messages[&quot;bare_url_no_origin&quot;] );
        end            
    end
    if not checkurl( URL ) then
        error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
    end
    return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safeforurl( label ), &quot;]&quot;, error_str });
end

-- Formats a link to Amazon
function amazon(id, domain)
    if not is_set(domain) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local handler = cfg.id_handlers['ASIN'];
    return externallinkid({link = handler.link,
        label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
        encode=handler.encode, separator = handler.separator})
end

--[[
Formats a PMC and checks for embargoed articles.  The embargo parameter takes a date for a value. If the embargo date is in the futue
the PMC identifier will not be linked to the article.  If the embargo specifies a date in the past, or if it is empty or omitted, then
the PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].link.

The {{citation/core}} version of {{cite journal}} links the citation title (if url parameter is empty) when embargo date is in the past
or when embargo parameter is missing or empty. That behavior is inconsistent with the behavior of other identifiers used in CS1 and is
not supported here.
]]
function pmc(id, embargo)
	local handler = cfg.id_handlers['PMC'];
    
	local text;
	
	if is_set(embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );

		if good1 and good2 and tonumber( embargo_date ) &lt; tonumber( todays_date ) then	--if embargo date is in the past then
			text = externallinkid({link = handler.link, label = handler.label,			--ok to link to article
				prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		else
			text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id;	--still embargoed so no external link
		end
	else
		text = externallinkid({link = handler.link, label = handler.label,			--no embargo date, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
	end
	return text
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    local handler = cfg.id_handlers['DOI'];
    
    local text;
    if is_set(inactive) then
        text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link = handler.link, label = handler.label,
            prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then      
        cat = seterror( 'bad_doi' );
    end
    return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    local handler = cfg.id_handlers['OL'];
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    else
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode}) .. 
            ' ' .. seterror( 'bad_ol' );
    end
end

--[[
Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.
]]
function issn(id)
	local clean_issn;
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local temp = 0;
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and ndashes from the issn
	clean_issn=string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- make a copy with a hyphen after 4 digits; use this version for display if issn validates

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 didgits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		id = { id:byte(1, 8) };									-- table of individual bytes
		for i, v in ipairs( id ) do								-- loop through all of the byte an calculate the checksum
			if v == string.byte( &quot;X&quot; ) then						-- if checkdigit is X
				temp = temp + 10*( 9 - i );						-- it represents 10 decimal
			else
				temp = temp + tonumber( string.char(v) )*(9-i);	
			end
		end
		valid_issn = temp % 11 == 0;							-- checksum must be zero for valid issn
	end

	if true == valid_issn then
		id = clean_issn;										-- if valid, use the cleaned-up version for the display			
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = externallinkid({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. seterror( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[
Determines whether an URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
    -- Protocol-relative or URL scheme
    return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
    return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
    isbn_str = cleanisbn( isbn_str ):gsub( &quot;-&quot;, &quot;&quot; );
    local len = isbn_str:len();
 
    if len ~= 10 and len ~= 13 then
        return false;
    end
 
    local temp = 0;
    if len == 10 then
        if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            if v == string.byte( &quot;X&quot; ) then
                temp = temp + 10*( 11 - i );
            else
                temp = temp + tonumber( string.char(v) )*(11-i);
            end
        end
        return temp % 11 == 0;
    else
        if isbn_str:match( &quot;^%d*$&quot; ) == nil then return false; end
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
        end
        return temp % 10 == 0;
    end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
    return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
        return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
    end));
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if not is_set(str) then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        
        -- Remove newlines as they break italics.
        return str:gsub( '\n', ' ' );
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.
]]
function selectyear( str )
    -- Is the input a simple number?
    local num = tonumber( str ); 
    if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.floor(num) then
        return str;
    else
        -- Use formatDate to interpret more complicated formats
        local lang = mw.getContentLanguage();
        local good, result;
        good, result = pcall( lang.formatDate, lang, 'Y', str );
        if good then 
            return result;
        else
            -- extract year if the date uses seasons
            str=string.lower (str);
            local seasons={&quot;winter&quot;, &quot;spring&quot;, &quot;summer&quot;, &quot;fall&quot;, &quot;autumn&quot;};
            local date_string_split=mw.text.split (str, &quot;[%s%-/–]&quot;);      -- split date string into parts; white space, hyphen, forward slash, and ndash are allowed separators
            local has_season=false;
            
            for n,season_value in ipairs(seasons) do                -- for each season ...
                for n,split_value in ipairs(date_string_split) do   -- ... loop through date string values 
                    if split_value == season_value then             -- does the split value match the season value?
                        if has_season==false then                   -- found one. if this one is the first we've found ...
                            has_season=true;                        -- ... remember that we found a season
                        end
                    elseif has_season==true then                    -- if split_value isn't a season, and we've previously found a season ...
                        num = tonumber( split_value );              -- ... convert current split value to a number if we can
                        if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.floor(num) then    -- if it's a suitable number
                            return tostring( num );                                                 -- return it as a string
                        end -- if num
                    end -- if string.find
                end -- for split value loop
            end -- season value loop
        end -- if good
    end -- if num
end -- selectyear

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    if maximum ~= nil and maximum &lt; 1 then return &quot;&quot;, 0; end
    
    for i,person in ipairs(people) do
        if is_set(person.last) then
            local mask = person.mask
            local one
            local sep_one = sep;
            if maximum ~= nil and i &gt; maximum then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask;
                    sep_one = &quot; &quot;;
                end
            else
                one = person.last
                local first = person.first
                if is_set(first) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if is_set(person.link) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert( text, one )
            table.insert( text, sep_one )
        end
    end

    local count = #text / 2;
    if count &gt; 0 then 
        if count &gt; 1 and is_set(lastauthoramp) and not etal then
            text[#text-2] = &quot; &amp; &quot;;
        end
        text[#text] = nil; 
    end
    
    local result = table.concat(text) -- construct list
    if etal then 
        local etal_text = cfg.messages['et al'];
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result = 
        '&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
    end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
    return &quot;CITEREF&quot; .. table.concat( options );
end

-- Gets name list from the input arguments
function extractnames(args, list_name)
    local names = {};
    local i = 1;
    local last;
    
    while true do
        last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );
        if not is_set(last) then
            -- just in case someone passed in an empty parameter
            break;
        end
        names[i] = {
            last = last,
            first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i ),
            link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ),
            mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i )
        };
        i = i + 1;
    end
    return names;
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
    local id_list = {};
    for k, v in pairs( cfg.id_handlers ) do    
        v = selectone( args, v.parameters, 'redundant_parameters' );
        if is_set(v) then id_list[k] = v; end
    end
    return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
    local new_list, handler = {};
    
    function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
    
    for k, v in pairs( id_list ) do
        -- fallback to read-only cfg
        handler = setmetatable( { ['id'] = v }, fallback(k) );
        
        if handler.mode == 'external' then
            table.insert( new_list, {handler.label, externallinkid( handler ) } );
        elseif handler.mode == 'internal' then
            table.insert( new_list, {handler.label, internallinkid( handler ) } );
        elseif handler.mode ~= 'manual' then
            error( cfg.messages['unknown_ID_mode'] );
        elseif k == 'DOI' then
            table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
        elseif k == 'ASIN' then
            table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
        elseif k == 'OL' then
            table.insert( new_list, {handler.label, openlibrary( v ) } );
        elseif k == 'PMC' then
            table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
        elseif k == 'ISSN' then
        	table.insert( new_list, {handler.label, issn( v ) } );
        elseif k == 'ISBN' then
            local ISBN = internallinkid( handler );
            if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
                ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
            end
            table.insert( new_list, {handler.label, ISBN } );                
        else
            error( cfg.messages['unknown_manual_ID'] );
        end
    end
    
    function comp( a, b )
        return a[1] &lt; b[1];
    end
    
    table.sort( new_list, comp );
    for k, v in ipairs( new_list ) do
        new_list[k] = v[2];
    end
    
    return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
    local value = nil;
    local selected = '';
    local error_list = {};
    
    if index ~= nil then index = tostring(index); end
    
    -- Handle special case of &quot;#&quot; replaced by empty string
    if index == '1' then
        for _, v in ipairs( possible ) do
            v = v:gsub( &quot;#&quot;, &quot;&quot; );
            if is_set(args[v]) then
                if value ~= nil and selected ~= v then
                    table.insert( error_list, v );
                else
                    value = args[v];
                    selected = v;
                end
            end
        end        
    end
    
    for _, v in ipairs( possible ) do
        if index ~= nil then
            v = v:gsub( &quot;#&quot;, index );
        end
        if is_set(args[v]) then
            if value ~= nil and selected ~=  v then
                table.insert( error_list, v );
            else
                value = args[v];
                selected = v;
            end
        end
    end
    
    if #error_list &gt; 0 then
        local error_str = &quot;&quot;;
        for _, k in ipairs( error_list ) do
            if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
            error_str = error_str .. wrap( 'parameter', k );
        end
        if #error_list &gt; 1 then
            error_str = error_str .. cfg.messages['parameter-final-separator'];
        else
            error_str = error_str .. cfg.messages['parameter-pair-separator'];
        end
        error_str = error_str .. wrap( 'parameter', selected );
        table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
    end
    
    return value, selected;
end

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
function COinS(data)
    if 'table' ~= type(data) or nil == next(data) then
        return '';
    end
    
    local ctx_ver = &quot;Z39.88-2004&quot;;
    
    -- treat table strictly as an array with only set values.
    local OCinSoutput = setmetatable( {}, {
        __newindex = function(self, key, value)
            if is_set(value) then
                rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
            end
        end
    });
    
    if is_set(data.Chapter) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Chapter;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    elseif is_set(data.Periodical) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
        OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    else
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
    end
    
    OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
    OCinSoutput[&quot;rft.date&quot;] = data.Date;
    OCinSoutput[&quot;rft.series&quot;] = data.Series;
    OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
    OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
    OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
    OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
    OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
    
    for k, v in pairs( data.ID_list ) do
        local id, value = cfg.id_handlers[k].COinS;
        if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
        if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
            OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
        else
            OCinSoutput[ id ] = value;
        end
    end
    
    local last, first;
    for k, v in ipairs( data.Authors ) do
        last, first = v.last, v.first;
        if k == 1 then
            if is_set(last) then
                OCinSoutput[&quot;rft.aulast&quot;] = last;
            end
            if is_set(first) then 
                OCinSoutput[&quot;rft.aufirst&quot;] = first;
            end
        end
        if is_set(last) and is_set(first) then
            OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
        elseif is_set(last) then
            OCinSoutput[&quot;rft.au&quot;] = last;
        end
    end
    
    OCinSoutput.rft_id = data.URL;
    OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
    OCinSoutput = setmetatable( OCinSoutput, nil );
    
    -- sort with version string always first, and combine.
    table.sort( OCinSoutput );
    table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
    return table.concat(OCinSoutput, &quot;&amp;&quot;);
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    --[[ 
    Load Input Parameters
    The argment_wrapper facillitates the mapping of multiple
    aliases to single internal variable.
    ]]
    local A = argument_wrapper( args );

    local i 
    local PPrefix = A['PPrefix']
    local PPPrefix = A['PPPrefix']
    if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = A['Authors'];
    local a = extractnames( args, 'AuthorList' );

    local Coauthors = A['Coauthors'];
    local Others = A['Others'];
    local Editors = A['Editors'];
    local e = extractnames( args, 'EditorList' );

    local Year = A['Year'];
    local PublicationDate = A['PublicationDate'];
    local OrigYear = A['OrigYear'];
    local Date = A['Date'];
    local LayDate = A['LayDate'];
    ------------------------------------------------- Get title data
    local Title = A['Title'];
    local BookTitle = A['BookTitle'];
    local Conference = A['Conference'];
    local TransTitle = A['TransTitle'];
    local TitleNote = A['TitleNote'];
    local TitleLink = A['TitleLink'];
    local Chapter = A['Chapter'];
    local ChapterLink = A['ChapterLink'];
    local TransChapter = A['TransChapter'];
    local TitleType = A['TitleType'];
    local ArchiveURL = A['ArchiveURL'];
    local URL = A['URL']
    local URLorigin = A:ORIGIN('URL');
    local ChapterURL = A['ChapterURL'];
    local ChapterURLorigin = A:ORIGIN('ChapterURL');
    local ConferenceURL = A['ConferenceURL'];
    local ConferenceURLorigin = A:ORIGIN('ConferenceURL');
    local Periodical = A['Periodical'];
    
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if not is_set(Chapter) then
            if not is_set(Title) then
                Title = Periodical;
                Periodical = '';
            else
                Chapter = Title
                TransChapter = TransTitle
                Title = '';
                TransTitle = '';
            end
        end
    end

    local Series = A['Series'];
    local Volume = A['Volume'];
    local Issue = A['Issue'];
    local Position = '';
    local Page, Pages, At, page_type;
    
    Page = A['Page'];
    Pages = hyphentodash( A['Pages'] );
    At = A['At'];
    
    if is_set(Page) then
        if is_set(Pages) or is_set(At) then
            Page = Page .. &quot; &quot; .. seterror('extra_pages');
            Pages = '';
            At = '';
        end
    elseif is_set(Pages) then
        if is_set(At) then
            Pages = Pages .. &quot; &quot; .. seterror('extra_pages');
            At = '';
        end
    end    
    
    local Edition = A['Edition'];
    local PublicationPlace = A['PublicationPlace']
    local Place = A['Place'];
    
    if not is_set(PublicationPlace) and is_set(Place) then
        PublicationPlace = Place;
    end
    
    if PublicationPlace == Place then Place = ''; end
    
    local PublisherName = A['PublisherName'];
    local RegistrationRequired = A['RegistrationRequired'];
    local SubscriptionRequired = A['SubscriptionRequired'];
    local Via = A['Via'];
    local AccessDate = A['AccessDate'];
    local ArchiveDate = A['ArchiveDate'];
    local Agency = A['Agency'];
    local DeadURL = A['DeadURL']
    local Language = A['Language'];
    local Format = A['Format'];
    local Ref = A['Ref'];
    
    local DoiBroken = A['DoiBroken'];
    local ID = A['ID'];
    local ASINTLD = A['ASINTLD'];
    local IgnoreISBN = A['IgnoreISBN'];
    local Embargo = A['Embargo'];

    local ID_list = extractids( args );
    
    local Quote = A['Quote'];
    local PostScript = A['PostScript'];
    local LayURL = A['LayURL'];
    local LaySource = A['LaySource'];
    local Transcript = A['Transcript'];
    local TranscriptURL = A['TranscriptURL'] 
    local TranscriptURLorigin = A:ORIGIN('TranscriptURL');
    local sepc = A['Separator'];
    local LastAuthorAmp = A['LastAuthorAmp'];
    local no_tracking_cats = A['NoTracking'];

    local use_lowercase = ( sepc ~= '.' );
    local this_page = mw.title.getCurrentTitle();  --Also used for COinS and for language
    
    if not is_set(no_tracking_cats) then
        for k, v in pairs( cfg.uncategorized_namespaces ) do
            if this_page.nsText == v then
                no_tracking_cats = &quot;true&quot;;
                break;
            end
        end
    end

    -- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if is_set(BookTitle) then
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = BookTitle;
        TitleLink = '';
        TransTitle = '';
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = A['AirDate'];
        local SeriesLink = A['SeriesLink'];
        local Season = A['Season'];
        local SeriesNumber = A['SeriesNumber'];
        local Network = A['Network'];
        local Station = A['Station'];
        local s, n = {}, {};
        local Sep = (first_set(A[&quot;SeriesSeparator&quot;], A[&quot;Separator&quot;]) or &quot;&quot;) .. &quot; &quot;;
        
        if is_set(Issue) then table.insert(s, cfg.messages[&quot;episode&quot;] .. &quot; &quot; .. Issue); Issue = ''; end
        if is_set(Season) then table.insert(s, cfg.messages[&quot;season&quot;] .. &quot; &quot; .. Season); end
        if is_set(SeriesNumber) then table.insert(s, cfg.messages[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber); end
        if is_set(Network) then table.insert(n, Network); end
        if is_set(Station) then table.insert(n, Station); end
        
        Date = Date or AirDate;
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = Series;
        TitleLink = SeriesLink;
        TransTitle = '';
        
        Series = table.concat(s, Sep);
        ID = table.concat(n, Sep);
    end
    
    -- COinS metadata (see &lt;http://ocoins.info/&gt;) for
    -- automated parsing of citation information.
    local OCinSoutput = COinS{
        ['Periodical'] = Periodical,
        ['Chapter'] = Chapter,
        ['Title'] = Title,
        ['PublicationPlace'] = PublicationPlace,
        ['Date'] = first_set(Date, Year, PublicationDate),
        ['Series'] = Series,
        ['Volume'] = Volume,
        ['Issue'] = Issue,
        ['Pages'] = first_set(Page, Pages, At),
        ['Edition'] = Edition,
        ['PublisherName'] = PublisherName,
        ['URL'] = first_set( URL, ChapterURL ),
        ['Authors'] = a,
        ['ID_list'] = ID_list,
        ['RawPage'] = this_page.prefixedText,
    };

    if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = '';
        TitleLink = '';
        TransTitle = '';
    end

    -- Now perform various field 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 not is_set(Authors) then
        local Maximum = tonumber( A['DisplayAuthors'] );
        
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #a == 9 then 
            Maximum = 8;
            table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
        elseif not is_set(Maximum) then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = A[&quot;AuthorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;AuthorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A[&quot;AuthorFormat&quot;],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if is_set(Coauthors) then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
        
        Authors = listpeople(control, a) 
    end

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { seterror('coauthors_missing_author', {}, true) } );	-- emit error message
	end

    local EditorCount
    if not is_set(Editors) then
        local Maximum = tonumber( A['DisplayEditors'] );
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #e == 4 then 
            Maximum = 3;
            table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
        elseif not is_set(Maximum) then
            Maximum = #e + 1;
        end

        local control = { 
            sep = A[&quot;EditorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;EditorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A['EditorFormat'],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };

        Editors, EditorCount = listpeople(control, e);
    else
        EditorCount = 1;
    end

    local Cartography = &quot;&quot;;
    local Scale = &quot;&quot;;
    if config.CitationClass == &quot;map&quot; then
        if not is_set( Authors ) and is_set( PublisherName ) then
            Authors = PublisherName;
            PublisherName = &quot;&quot;;
        end
        Cartography = A['Cartography'];
        if is_set( Cartography ) then
            Cartography = sepc .. &quot; &quot; .. wrap( 'cartography', Cartography, use_lowercase );
        end        
        Scale = A['Scale'];
        if is_set( Scale ) then
            Scale = sepc .. &quot; &quot; .. Scale;
        end        
    end
    
    if not is_set(Date) then
        Date = Year;
        if is_set(Date) then
            local Month = A['Month'];
            if is_set(Month) then 
                Date = Month .. &quot; &quot; .. Date;
                local Day = A['Day']
                if is_set(Day) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    
    if inArray(PublicationDate, {Date, Year}) then PublicationDate = ''; end
    if not is_set(Date) and is_set(PublicationDate) then
        Date = PublicationDate;
        PublicationDate = '';
    end

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date;
    
    if  not is_set(URL) and
        not is_set(ChapterURL) and
        not is_set(ArchiveURL) and
        not is_set(ConferenceURL) and
        not is_set(TranscriptURL) then
        
        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
        end
        
        -- Test if accessdate is given without giving a URL
        if is_set(AccessDate) then
            table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
            AccessDate = '';
        end
        
        -- Test if format is given without giving a URL
        if is_set(Format) then
            Format = Format .. seterror( 'format_missing_url' );
        end
    end
    
    -- Test if citation has no title
    if  not is_set(Chapter) and
        not is_set(Title) and
        not is_set(Periodical) and
        not is_set(Conference) and
        not is_set(TransTitle) and
        not is_set(TransChapter) then
        table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
    end
    
    Format = is_set(Format) and &quot; (&quot; .. Format .. &quot;)&quot; or &quot;&quot;;
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if is_set( ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
            URLorigin = A:ORIGIN('ArchiveURL')
        end
    end
    
    -- Format chapter / article title
    if is_set(Chapter) and is_set(ChapterLink) then 
        Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot;;
    end
    if is_set(Periodical) and is_set(Title) then
        Chapter = wrap( 'italic-title', Chapter );
        TransChapter = wrap( 'trans-italic-title', TransChapter );
    else
        Chapter = wrap( 'quoted-title', Chapter );
        TransChapter = wrap( 'trans-quoted-title', TransChapter );
    end
    
    local TransError = &quot;&quot;
    if is_set(TransChapter) then
        if not is_set(Chapter) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
        else
            TransChapter = &quot; &quot; .. TransChapter;
        end
    end
    
    Chapter = Chapter .. TransChapter;
    
    if is_set(Chapter) then
        if not is_set(ChapterLink) then
            if is_set(ChapterURL) then
                Chapter = externallink( ChapterURL, Chapter ) .. TransError;
                if not is_set(URL) then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif is_set(URL) then 
                Chapter = externallink( URL, Chapter ) .. TransError .. Format;
                URL = &quot;&quot;;
                Format = &quot;&quot;;
            else
                Chapter = Chapter .. TransError;
            end            
        elseif is_set(ChapterURL) then
            Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. 
                TransError;
        else
            Chapter = Chapter .. TransError;
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    elseif is_set(ChapterURL) then
        Chapter = &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. sepc .. &quot; &quot;;
    end        
    
    -- Format main title.
    if is_set(TitleLink) and is_set(Title) then
        Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
    end
    
    if is_set(Periodical) then
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    elseif inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;pressrelease&quot;,&quot;conference&quot;}) and
            not is_set(Chapter) then
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    else
        Title = wrap( 'italic-title', Title );
        TransTitle = wrap( 'trans-italic-title', TransTitle );
    end
    
    TransError = &quot;&quot;;
    if is_set(TransTitle) then
        if not is_set(Title) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
        else
            TransTitle = &quot; &quot; .. TransTitle;
        end
    end
    
    Title = Title .. TransTitle;
    
    if is_set(Title) then
        if not is_set(TitleLink) and is_set(URL) then 
            Title = externallink( URL, Title ) .. TransError .. Format       
            URL = &quot;&quot;;
            Format = &quot;&quot;;
        else
            Title = Title .. TransError;
        end
    end
    
    if is_set(Place) then
        Place = &quot; &quot; .. wrap( 'written', Place, use_lowercase ) .. sepc .. &quot; &quot;;
    end
    
    if is_set(Conference) then
        if is_set(ConferenceURL) then
            Conference = externallink( ConferenceURL, Conference );
        end
        Conference = sepc .. &quot; &quot; .. Conference
    elseif is_set(ConferenceURL) then
        Conference = sepc .. &quot; &quot; .. externallink( ConferenceURL, nil, ConferenceURLorigin );
    end
    
    if not is_set(Position) then
        local Minutes = A['Minutes'];
        if is_set(Minutes) then
            Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
        else
            local Time = A['Time'];
            if is_set(Time) then
                local TimeCaption = A['TimeCaption']
                if not is_set(TimeCaption) then
                    TimeCaption = cfg.messages['event'];
                    if sepc ~= '.' then
                        TimeCaption = TimeCaption:lower();
                    end
                end
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
            end
        end
    else
        Position = &quot; &quot; .. Position;
        At = '';
    end
    
    if not is_set(Page) then
        if is_set(Pages) then
            if is_set(Periodical) and
                not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;}) then
                Pages = &quot;: &quot; .. Pages;
            elseif tonumber(Pages) ~= nil then
                Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
            else
                Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
            end
        end
    else
        if is_set(Periodical) and
            not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;}) then
            Page = &quot;: &quot; .. Page;
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page;
        end
    end
    
    At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
    Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
    if config.CitationClass == 'map' then
        local Section = A['Section'];
        local Inset = A['Inset'];
        if first_set( Pages, Page, At ) ~= nil or sepc ~= '.' then
            if is_set( Section ) then
                Section = &quot;, &quot; .. wrap( 'section', Section, true );
            end
            if is_set( Inset ) then
                Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
            end
        else
            if is_set( Section ) then
                Section = sepc .. &quot; &quot; .. wrap( 'section', Section, use_lowercase );
                if is_set( Inset ) then
                    Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
                end
            elseif is_set( Inset ) then
                Inset = sepc .. &quot; &quot; .. wrap( 'inset', Inset, use_lowercase );
            end            
        end            
        At = At .. Section .. Inset;        
    end    

	--[[Look in the list of iso639-1 language codes to see if the value provided in the language parameter matches one of them.  If a match is found, 
	use that value; if not, then use the value that was provided with the language parameter.
	
	Categories are assigned in a manner similar to the {{xx icon}} templates - categorizes only mainspace citations and only when the language code is not 'en' (English).
	]]
	if is_set (Language) then
		local name = cfg.iso639_1[Language:lower()];		-- get the language name if Language parameter has a valid iso 639-1 code
		if nil == name then
			Language=&quot; &quot; .. wrap( 'language', Language );	-- no match, use parameter's value
		else
			if 0 == this_page.namespace and 'en' ~= Language:lower() then	--found a match; is this page main / article space and English not the language?
				Language=&quot; &quot; .. wrap( 'language', name .. '[[Category:Articles with ' .. name .. '-language external links]]' );	-- in main space and not English: categorize
			else
				Language=&quot; &quot; .. wrap( 'language', name );	--not in mainspace or language is English so don't categorize
			end
		end
	else
		Language=&quot;&quot;;	-- language not specified so make sure this is an empty string;
	end

    Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
    TitleType = is_set(TitleType) and (&quot; (&quot; .. TitleType .. &quot;)&quot;) or &quot;&quot;;
    TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
    Edition = is_set(Edition) and (&quot; &quot; .. wrap( 'edition', Edition )) or &quot;&quot;;
    Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
    Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
    OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
    Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;
    
    if is_set(Volume) then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume;
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
        end
    end
    
    ------------------------------------ totally unrelated data
    --[[ Loosely mimic {{subscription required}} template; Via parameter identifies a delivery source that is not the publisher; these sources often, but not always, exist
    behind a registration or paywall.  So here, we've chosen to decouple via from subscription (via has never been part of the registration required template).
    
    Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link note is displayed. There are no error messages for this condition.
    ]]
    if is_set(Via) then
        Via = &quot; &quot; .. wrap( 'via', Via );
    end

	if is_set(SubscriptionRequired) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription']; --here when 'via' parameter not used but 'subscription' is
    elseif is_set(RegistrationRequired) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration']; --here when 'via' and 'subscription' parameters not used but 'registration' is
    end

    if is_set(AccessDate) then
        local retrv_text = &quot; &quot; .. cfg.messages['retrieved']
        if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
        AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
            .. substitute( retrv_text, {AccessDate} ) .. '&lt;/span&gt;'
    end
    
    if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
    
    ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo} );

    if is_set(URL) then
        URL = &quot; &quot; .. externallink( URL, nil, URLorigin );
    end

    if is_set(Quote) then
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        Quote = sepc ..&quot; &quot; .. wrap( 'quoted-text', Quote ); 
        PostScript = &quot;&quot;;
    elseif PostScript:lower() == &quot;none&quot; then
        PostScript = &quot;&quot;;
    end
    
    local Archived
    if is_set(ArchiveURL) then
        if not is_set(ArchiveDate) then
            ArchiveDate = seterror('archive_missing_date');
        end
        if &quot;no&quot; == DeadURL then
            local arch_text = cfg.messages['archived'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
                { externallink( ArchiveURL, arch_text ), ArchiveDate } );
            if not is_set(OriginalURL) then
                Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url');                               
            end
        elseif is_set(OriginalURL) then
            local arch_text = cfg.messages['archived-dead'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text,
                { externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
        else
            local arch_text = cfg.messages['archived-missing'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
                { seterror('archive_missing_url'), ArchiveDate } );
        end
    else
        Archived = &quot;&quot;
    end
    
    local Lay
    if is_set(LayURL) then
        if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
        if is_set(LaySource) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot;;
        else
            LaySource = &quot;&quot;;
        end
        if sepc == '.' then
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;;
    end
    
    if is_set(Transcript) then
        if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
    elseif is_set(TranscriptURL) then
        Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
    end
    
    local Publisher;
    if is_set(Periodical) and
        not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;}) then
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end
        elseif is_set(PublicationPlace) then
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if is_set(PublicationDate) then
            if is_set(Publisher) then
                Publisher = Publisher .. &quot;, &quot; .. wrap( 'published', PublicationDate );
            else
                Publisher = PublicationDate;
            end
        end
        if is_set(Publisher) then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if is_set(PublicationDate) then
            PublicationDate = &quot; (&quot; .. wrap( 'published', PublicationDate ) .. &quot;)&quot;;
        end
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif is_set(PublicationPlace) then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    
    -- Several of the above rely upon detecting this as nil, so do it last.
    if is_set(Periodical) then
        if is_set(Title) or is_set(TitleNote) then 
            Periodical = sepc .. &quot; &quot; .. wrap( 'italic-title', Periodical ) 
        else 
            Periodical = wrap( 'italic-title', Periodical )
        end
    end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if inArray(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
        if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, 
            Language, Cartography, Edition, Publisher, Agency, Volume, Issue}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, Language, 
            Volume, Issue, Others, Cartography, Edition, Publisher, Agency}, sepc );
    end
    
    if #ID_list &gt; 0 then
        ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
    else
        ID_list = ID;
    end
    
    local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
    local text;
    local pgtext = Position .. Page .. Pages .. At;
    
    if is_set(Authors) then
        if is_set(Coauthors) then
            Authors = Authors .. A['AuthorSeparator'] .. &quot; &quot; .. Coauthors
        end
        if is_set(Date) then
            Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        elseif string.sub(Authors,-1,-1) == sepc then
            Authors = Authors .. &quot; &quot;
        else
            Authors = Authors .. sepc .. &quot; &quot;
        end
        if is_set(Editors) then
            local in_text = &quot; &quot;;
            local post_text = &quot;&quot;;
            if is_set(Chapter) then
                in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
            else
                if EditorCount &lt;= 1 then
                    post_text = &quot;, &quot; .. cfg.messages['editor'];
                else
                    post_text = &quot;, &quot; .. cfg.messages['editors'];
                end
            end 
            if (sepc ~= '.') then in_text = in_text:lower() end
            Editors = in_text .. Editors .. post_text;
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = Editors .. &quot; &quot;
                else Editors = Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif is_set(Editors) then
        if is_set(Date) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
            else
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if is_set(Date) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end
        if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
            text = safejoin( {Chapter, Place, tcommon}, sepc );
            text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
            text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
            text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if is_set(PostScript) and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    if not is_set(Year) then
        if is_set(DateIn) then
            Year = selectyear( DateIn );
        elseif is_set(PublicationDate) then
            Year = selectyear( PublicationDate );
        end
    end
    
    local options = {};
    
    if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
        options.class = &quot;citation &quot; .. config.CitationClass;
    else
        options.class = &quot;citation&quot;;
    end
    
    if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if #a &gt; 0 then
                for i,v in ipairs(a) do 
                    names[i] = v.last 
                    if i == 4 then break end
                end
            elseif #e &gt; 0 then
                for i,v in ipairs(e) do 
                    names[i] = v.last 
                    if i == 4 then break end                
                end
            end
            names[ #names + 1 ] = Year;
            id = anchorid(names)
        end
        options.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = {};
        text = seterror('empty_citation');
        z.message_tail = {};
    end
    
    if is_set(options.id) then 
        text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    else
        text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    end        

    local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        text = text .. &quot; &quot;;
        for i,v in ipairs( z.message_tail ) do
            if is_set(v[1]) then
                if i == #z.message_tail then
                    text = text .. errorcomment( v[1], v[2] );
                else
                    text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
                end
            end
        end
    end
    
    no_tracking_cats = no_tracking_cats:lower();
    if inArray(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    local suggestions = {};
    local error_text, error_state;

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        args[k] = v;       
    end    

    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            if not validate( k ) then            
                error_text = &quot;&quot;;
                if type( k ) ~= 'string' then
                    -- Exclude empty numbered parameters
                    if v:match(&quot;%S+&quot;) ~= nil then
                        error_text, error_state = seterror( 'text_ignored', {v}, true );
                    end
                elseif validate( k:lower() ) then 
                    error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
                else
                    if #suggestions == 0 then
                        suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
                    end
                    if suggestions[ k:lower() ] ~= nil then
                        error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
                    else
                        error_text, error_state = seterror( 'parameter_ignored', {k}, true );
                    end
                end                  
                if error_text ~= '' then
                    table.insert( z.message_tail, {error_text, error_state} );
                end                
            end
            args[k] = v;
        elseif args[k] ~= nil or (k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z</text>
      <sha1>pczrwu2bcyarrsod4oqimn3p0xqucy5</sha1>
    </revision>
    <revision>
      <id>4662</id>
      <parentid>4661</parentid>
      <timestamp>2013-11-09T11:39:17Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox; Migrate cite thesis and cite techreport; ISBN &amp; ISSN tweaks; Deprecated parameter tracking; Add date validation;</comment>
      <origin>4662</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="77570" sha1="3trntte6ahxt1qanijd0bp39zk6cthw" xml:space="preserve">local z = {
    error_categories = {};
    error_ids = {};
    message_tail = {};
}

-- Include translation message hooks, ID and error handling configuration settings.
local cfg = mw.loadData( 'Module:Citation/CS1/Configuration/sandbox' );

-- Contains a list of all recognized parameters
local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist/sandbox' );

-- Whether variable is set or not
function is_set( var )
    return not (var == nil or var == '');
end

-- First set variable or nil if none
function first_set(...)
    local list = {...};
    for _, var in pairs(list) do
        if is_set( var ) then
            return var;
        end
    end
end

-- Whether needle is in haystack
function inArray( needle, haystack )
    if needle == nil then
        return false;
    end
    for n,v in ipairs( haystack ) do
        if v == needle then
            return n;
        end
    end
    return false;
end

-- Add this page to the deprecated parameter tracking category
function deprecated_parameter()
	if true ~= Page_in_deprecated_cat then	-- if we haven't been here before then set a 
		Page_in_deprecated_cat=true;		-- sticky flag so that if there are more than one deprecated parameter the category is added only once
		table.insert( z.error_categories, &quot;Pages containing cite templates with deprecated parameters&quot; );	-- add page to category
	end
end

-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
    return args and tostring( mw.message.newRawMessage( msg, args ) ) or msg;
end

-- Wraps a string using a message_list configuration taking one argument
function wrap( key, str, lower )
    if not is_set( str ) then
        return &quot;&quot;;
    elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
        str = safeforitalics( str );
    end
    if lower == true then
        return substitute( cfg.messages[key]:lower(), {str} );
    else
        return substitute( cfg.messages[key], {str} );
    end        
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
    local origin = {};
    
    return setmetatable({
        ORIGIN = function( self, k )
            local dummy = self[k]; --force the variable to be loaded.
            return origin[k];
        end
    },
    {
        __index = function ( tbl, k )
            if origin[k] ~= nil then
                return nil;
            end
            
            local args, list, v = args, cfg.aliases[k];
            
            if type( list ) == 'table' then
                v, origin[k] = selectone( args, list, 'redundant_parameters' );
                if origin[k] == nil then
                    origin[k] = ''; -- Empty string, not nil
                end
            elseif list ~= nil then
                v, origin[k] = args[list], list;
            else
                -- maybe let through instead of raising an error?
                -- v, origin[k] = args[k], k;
                error( cfg.messages['unknown_argument_map'] );
            end
            
            -- Empty strings, not nil;
            if v == nil then
                v = cfg.defaults[k] or '';
                origin[k] = '';
            end
            
            tbl = rawset( tbl, k, v );
            return v;
        end,
    });
end

-- Checks that parameter name is valid using the whitelist
function validate( name )
    name = tostring( name );
    
    -- Normal arguments
    if whitelist.basic_arguments[ name ] then
        return true;
    end
    
    -- Arguments with numbers in them
    name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );
    if whitelist.numbered_arguments[ name ] then
        return true;
    end
    
    -- Not found, argument not supported.
    return false
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
    return wrap( hidden and 'hidden-error' or 'visible-error', content );
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
    local error_state = cfg.error_conditions[ error_id ];
    
    prefix = prefix or &quot;&quot;;
    suffix = suffix or &quot;&quot;;
    
    if error_state == nil then
        error( cfg.messages['undefined_error'] );
    elseif is_set( error_state.category ) then
        table.insert( z.error_categories, error_state.category );
    end
    
    local message = substitute( error_state.message, arguments );
    
    message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
        &quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
        cfg.messages['help page label'] .. &quot;]])&quot;;
    
    z.error_ids[ error_id ] = true;
    if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
            and z.error_ids['citation_missing_title'] then
        return '', false;
    end
    
    message = table.concat({ prefix, message, suffix });
    
    if raw == true then
        return message, error_state.hidden;
    end        
        
    return errorcomment( message, error_state.hidden );
end

-- Formats a wiki style external link
function externallinkid(options)
    local url_string = options.id;
    if options.encode == true or options.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, url_string, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Formats a wiki style internal link
function internallinkid(options)
    return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, options.id, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Format an external link with error checking
function externallink( URL, label, source )
    local error_str = &quot;&quot;;
    if not is_set( label ) then
        label = URL;
        if is_set( source ) then
            error_str = seterror( 'bare_url_missing_title', { wrap( 'parameter', source ) }, false, &quot; &quot; );
        else
            error( cfg.messages[&quot;bare_url_no_origin&quot;] );
        end            
    end
    if not checkurl( URL ) then
        error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
    end
    return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safeforurl( label ), &quot;]&quot;, error_str });
end

-- Formats a link to Amazon
function amazon(id, domain)
    if not is_set(domain) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local handler = cfg.id_handlers['ASIN'];
    return externallinkid({link = handler.link,
        label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
        encode=handler.encode, separator = handler.separator})
end

--[[
Formats a PMC and checks for embargoed articles.  The embargo parameter takes a date for a value. If the embargo date is in the futue
the PMC identifier will not be linked to the article.  If the embargo specifies a date in the past, or if it is empty or omitted, then
the PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].link.

The {{citation/core}} version of {{cite journal}} links the citation title (if url parameter is empty) when embargo date is in the past
or when embargo parameter is missing or empty. That behavior is inconsistent with the behavior of other identifiers used in CS1 and is
not supported here.
]]
function pmc(id, embargo)
	local handler = cfg.id_handlers['PMC'];
    
	local text;
	
	if is_set(embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );

		if good1 and good2 and tonumber( embargo_date ) &lt; tonumber( todays_date ) then	--if embargo date is in the past then
			text = externallinkid({link = handler.link, label = handler.label,			--ok to link to article
				prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		else
			text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id;	--still embargoed so no external link
		end
	else
		text = externallinkid({link = handler.link, label = handler.label,			--no embargo date, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
	end
	return text
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    local handler = cfg.id_handlers['DOI'];
    
    local text;
    if is_set(inactive) then
        text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link = handler.link, label = handler.label,
            prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then      
        cat = seterror( 'bad_doi' );
    end
    return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    local handler = cfg.id_handlers['OL'];
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    else
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode}) .. 
            ' ' .. seterror( 'bad_ol' );
    end
end

--[[
Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.
]]
function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and ndashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 didgits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = externallinkid({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. seterror( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

-- returns a number according to the month in a date 1 for January, etc.  If not a valid month, returns 0
function get_month_number (month)
local long_months = {['january']=1, ['february']=2, ['march']=3, ['april']=4, ['may']=5, ['june']=6, ['july']=7, ['august']=8, ['september']=9, ['october']=10, ['november']=11, ['december']=12};
local short_months = {['jan']=1, ['feb']=2, ['mar']=3, ['apr']=4, ['may']=5, ['jun']=6, ['jul']=7, ['aug']=8, ['sep']=9, ['oct']=10, ['nov']=11, ['dec']=12};
local temp;
	temp=long_months[month:lower()];
	if temp then return temp; end	-- if month is the long-form name
	temp=short_months[month:lower()];
	if temp then return temp; end	-- if month is the short-form name
	return 0;													-- misspelled or not a month name
end

-- returns true if date has one of the five seasons.  Else false.
function is_valid_season (season)
	if inArray( season, {'winter', 'spring', 'summer', 'fall', 'autumn'} ) then
		return true;
	end
	return false;
end

--[[
Returns true if day is less than or equal to the number of days in month; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap years before 1582 and Gregorian leap years after 1582.
Where the two calendars overlap (1582 to approximately 1923) dates are assumed to be Gregorian.
]]
function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if (2==month) then		-- if February
		month_length = 28;	-- then 28 days unless
		if 1582 &gt; tonumber(year) then	-- Julian calendar
			if 0==(year%4) then
				month_length = 29;
			end
		else				-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then	-- date specifies a leap year
				month_length = 29;	-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end

--Check a pair of months or seasons to see if both are valid members of a month or season pair.

function is_valid_month_season_range(range_start, range_end)
	if 0 == get_month_number (range_start:lower()) then			-- is this a month range?
		if true == is_valid_season (range_start:lower()) then	-- not a month range, is this a season range?
			return is_valid_season (range_end:lower());			-- range_start is season; return true if range_end also a season; else false
		end
		return false;		-- range_start is not a month or a season
	end
	if 0 == get_month_number (range_end:lower()) then			-- range_start is a month; is range_end also a  month?
		return false;											-- not a month range
	end
	return true;
end


--[[
Check date format to see that it is one of the formats approved by MOS:DATE: MMMM D, YYYY; D MMMM YYYY; MMMM YYYY; YYYY-MM-DD; YYYY.
Additionally, check the date to see that it is a real date: no 31 in 30-day months; no 29 February when not a leap year.  Months, both long-form and three
character abbreviations, and seasons must be spelled correctly.

If the date fails the fomat tests, this function returns false but does not return values for anchor_year and COinS_date.  When this happens, the date parameter is
used in the COinS metadata and the CITEREF identifier gets its year from the year parameter if present.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is date_string without anchor_year disambiguators if any
]]
function check_date (date_string)
	local year;
	local month;
	local day;
	local anchor_year;
	local coins_date;

	if date_string:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then			-- Year-initial numerical year month day format
		coins_date = date_string:match(&quot;%d%d%d%d%-%d%d%-%d%d&quot;);
		year, month, day=string.match(date_string, &quot;(%d%d%d%d)%-(%d%d)%-(%d%d)&quot;);
		anchor_year = year;
		month=tonumber(month);
		if 12 &lt; month or 1 &gt; month then return false; end

	elseif date_string:match(&quot;^%a+%s*%d%d*%s*,%s*%d%d%d%d%a?$&quot;) then	-- month-initial: month day, year
		coins_date = date_string:match(&quot;%a+%s*%d%d*%s*,%s*%d%d%d%d&quot;);
		month, day, anchor_year, year=string.match(date_string, &quot;(%a+)%s*(%d%d*)%s*,%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month:lower());
		if 0 == month then return false; end					-- return false if month text isn't one of the twelve months
				
	elseif date_string:match(&quot;^%d%d*%s*%a+%s*%d%d%d%d%a?$&quot;) then		-- date-initial: day month year
		coins_date = date_string:match(&quot;%d%d*%s*%a+%s*%d%d%d%d&quot;);
		day, month, anchor_year, year=string.match(date_string, &quot;(%d%d*)%s*(%a+)%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month:lower());
		if 0 == month then return false; end					-- return false if month text isn't one of the twelve months

	elseif mw.ustring.match (date_string, &quot;^%a+%s*[%s%-/–]%s*%a+%s*%d%d%d%d%a?$&quot;) then		-- month/season range year
		local month2
		coins_date = mw.ustring.match (date_string, &quot;%a+%s*[%s%-/–]%s*%a+%s*%d%d%d%d&quot;);
		coins_date= mw.ustring.gsub( coins_date, &quot;–&quot;, &quot;-&quot; );	-- replace ndash with hyphen
		month, month2, anchor_year, year=mw.ustring.match (date_string, &quot;(%a+)%s*[%s%-/–]%s*(%a+)%s*((%d%d%d%d)%a?)&quot;);
		day=0;													-- mark day as not used
		if false == is_valid_month_season_range(month, month2) then
			return false;
		end
		
	elseif date_string:match(&quot;^%a+%s*%d%d%d%d%a?$&quot;) then				-- month/season year
		coins_date = date_string:match(&quot;%a+%s*%d%d%d%d&quot;);
		month, anchor_year, year=string.match(date_string, &quot;(%a+)%s*((%d%d%d%d)%a?)&quot;);
		day=0;													-- mark day as not used
		local season=month;										-- copy 
		month = get_month_number (month:lower());
		if month == 0 then										-- if month text isn't one of the twelve months, might be a season
			if false == is_valid_season (season:lower()) then
				return false;									-- return false not a month or one of the five seasons
			end
		end

	elseif date_string:match(&quot;^%d%d%d%d?%a?$&quot;) then			-- year; here accept either YYY or YYYY
		coins_date = date_string:match(&quot;^%d%d%d%d?&quot;);
		anchor_year, year=string.match(date_string, &quot;((%d%d%d%d?)%a?)&quot;);
		month, day = 0, 0;										-- mark day and month as not used
	else
		return false;											-- date format not one of the MOS:DATE approved formats
	end

	if 0~=month and 0~=day then									-- check year month day dates for validity
		if false==is_valid_date(year,month,day) then
			return false;										-- date string is not a real date return false; unset anchor_year and coins_date
		end
	end
	
	return true, anchor_year, coins_date;						-- format is good and date string represents a real date
end	

--[[
Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true and values for anchor_year (used in CITEREF identifiers) and COinS_date (used in the COinS metadata).  The |date= parameter test is unique.  This function only 
accepts anchor_year and COinS_date results from the |date= parameter test and |date= is the only date-holding parameter that is allowed to contain the no-date keywords
&quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.
]]

function dates(date_parameters_list)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local error_message =&quot;&quot;;
	local good_date=false;
	
	for k, v in pairs(date_parameters_list) do		-- for each date-holding parameter in the list
		if is_set(v) then							-- if the parameter has a value
			if v:match(&quot;^c%.%s%d%d%d%d?%a?$&quot;) then		-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				if 'date'==k then
					good_date, anchor_year, COinS_date = true, v:match(&quot;((c%.%s%d%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
				elseif 'year'==k then
					good_date =  true;
				end
			elseif 'year'==k then					-- if the parameter is |year= (but not c. year)
				if v:match(&quot;^%d%d%d%d?%a?$&quot;) then	-- year with or without CITEREF disambiguator
					good_date =  true;
				end
			elseif 'date'==k then						-- if the parameter is |date=
				if v:match(&quot;n%.d%.%a?&quot;) then		-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;;	-- no error when date parameter is set to no date
				elseif v:match(&quot;nd%a?$&quot;) then		-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	-- no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v);	-- go test the date
				end
			else									-- any other date-holding parameter
				good_date = check_date (v);			-- go test the date
			end
			if false==good_date then		-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then		-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;	-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;	-- add the failed parameter
			end
		end
	end
	if is_set(error_message) then
		table.insert( z.message_tail, { seterror( 'bad_date', {error_message}, true ) } );	-- add this error message
	end

	return anchor_year, COinS_date;		-- and done
end

--[[
Determines whether an URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
    -- Protocol-relative or URL scheme
    return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
    return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

--[[
ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. If the number is valid the result will be 0.
Before calling this function, issbn/issn must be checked for length and stripped of dashes, spaces and other non-isxn characters.
]]
function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of bytes
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do				-- loop through all of the byte an calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
    isbn_str = cleanisbn( isbn_str ):gsub( &quot;-&quot;, &quot;&quot; );
    local len = isbn_str:len();
 
    if len ~= 10 and len ~= 13 then
        return false;
    end
 
    if len == 10 then
        if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
    else
	    local temp = 0;
        if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end	-- isbn13 begins with 978 or 979
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
        end
        return temp % 10 == 0;
    end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
    return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
        return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
    end));
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if not is_set(str) then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        
        -- Remove newlines as they break italics.
        return str:gsub( '\n', ' ' );
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.

BUG: If editors set |date=n.d or |date=n.da then selectyear() returns the current year for use in CITEREF.  These &quot;dates&quot; are caught by dates().
]]
function selectyear( str )
	-- Is the input a simple number?
	local num = tonumber( str ); 
	if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.floor(num) then
		return str;
	else
		-- Use formatDate to interpret more complicated formats
		local lang = mw.getContentLanguage();
		local good, result;
		good, result = pcall( lang.formatDate, lang, 'Y', str );
		if good then return result; end -- if good
	end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    if maximum ~= nil and maximum &lt; 1 then return &quot;&quot;, 0; end
    
    for i,person in ipairs(people) do
        if is_set(person.last) then
            local mask = person.mask
            local one
            local sep_one = sep;
            if maximum ~= nil and i &gt; maximum then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask;
                    sep_one = &quot; &quot;;
                end
            else
                one = person.last
                local first = person.first
                if is_set(first) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if is_set(person.link) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert( text, one )
            table.insert( text, sep_one )
        end
    end

    local count = #text / 2;
    if count &gt; 0 then 
        if count &gt; 1 and is_set(lastauthoramp) and not etal then
            text[#text-2] = &quot; &amp; &quot;;
        end
        text[#text] = nil; 
    end
    
    local result = table.concat(text) -- construct list
    if etal then 
        local etal_text = cfg.messages['et al'];
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result = 
        '&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
    end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
    return &quot;CITEREF&quot; .. table.concat( options );
end

-- Gets name list from the input arguments
function extractnames(args, list_name)
    local names = {};
    local i = 1;
    local last;
    
    while true do
        last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );
        if not is_set(last) then
            -- just in case someone passed in an empty parameter
            break;
        end
        names[i] = {
            last = last,
            first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i ),
            link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ),
            mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i )
        };
        i = i + 1;
    end
    return names;
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
    local id_list = {};
    for k, v in pairs( cfg.id_handlers ) do    
        v = selectone( args, v.parameters, 'redundant_parameters' );
        if is_set(v) then id_list[k] = v; end
    end
    return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
    local new_list, handler = {};
    
    function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
    
    for k, v in pairs( id_list ) do
        -- fallback to read-only cfg
        handler = setmetatable( { ['id'] = v }, fallback(k) );
        
        if handler.mode == 'external' then
            table.insert( new_list, {handler.label, externallinkid( handler ) } );
        elseif handler.mode == 'internal' then
            table.insert( new_list, {handler.label, internallinkid( handler ) } );
        elseif handler.mode ~= 'manual' then
            error( cfg.messages['unknown_ID_mode'] );
        elseif k == 'DOI' then
            table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
        elseif k == 'ASIN' then
            table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
        elseif k == 'OL' then
            table.insert( new_list, {handler.label, openlibrary( v ) } );
        elseif k == 'PMC' then
            table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
        elseif k == 'ISSN' then
        	table.insert( new_list, {handler.label, issn( v ) } );
        elseif k == 'ISBN' then
            local ISBN = internallinkid( handler );
            if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
                ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
            end
            table.insert( new_list, {handler.label, ISBN } );                
        else
            error( cfg.messages['unknown_manual_ID'] );
        end
    end
    
    function comp( a, b )
        return a[1] &lt; b[1];
    end
    
    table.sort( new_list, comp );
    for k, v in ipairs( new_list ) do
        new_list[k] = v[2];
    end
    
    return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
    local value = nil;
    local selected = '';
    local error_list = {};
    
    if index ~= nil then index = tostring(index); end
    
    -- Handle special case of &quot;#&quot; replaced by empty string
    if index == '1' then
        for _, v in ipairs( possible ) do
            v = v:gsub( &quot;#&quot;, &quot;&quot; );
            if is_set(args[v]) then
                if value ~= nil and selected ~= v then
                    table.insert( error_list, v );
                else
                    value = args[v];
                    selected = v;
                end
            end
        end        
    end
    
    for _, v in ipairs( possible ) do
        if index ~= nil then
            v = v:gsub( &quot;#&quot;, index );
        end
        if is_set(args[v]) then
            if value ~= nil and selected ~=  v then
                table.insert( error_list, v );
            else
                value = args[v];
                selected = v;
            end
        end
    end
    
    if #error_list &gt; 0 then
        local error_str = &quot;&quot;;
        for _, k in ipairs( error_list ) do
            if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
            error_str = error_str .. wrap( 'parameter', k );
        end
        if #error_list &gt; 1 then
            error_str = error_str .. cfg.messages['parameter-final-separator'];
        else
            error_str = error_str .. cfg.messages['parameter-pair-separator'];
        end
        error_str = error_str .. wrap( 'parameter', selected );
        table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
    end
    
    return value, selected;
end

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
function COinS(data)
    if 'table' ~= type(data) or nil == next(data) then
        return '';
    end
    
    local ctx_ver = &quot;Z39.88-2004&quot;;
    
    -- treat table strictly as an array with only set values.
    local OCinSoutput = setmetatable( {}, {
        __newindex = function(self, key, value)
            if is_set(value) then
                rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
            end
        end
    });
    
    if is_set(data.Chapter) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Chapter;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    elseif is_set(data.Periodical) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
        OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    else
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
    end
    
    OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
    OCinSoutput[&quot;rft.date&quot;] = data.Date;
    OCinSoutput[&quot;rft.series&quot;] = data.Series;
    OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
    OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
    OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
    OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
    OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
    
    for k, v in pairs( data.ID_list ) do
        local id, value = cfg.id_handlers[k].COinS;
        if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
        if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
            OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
        else
            OCinSoutput[ id ] = value;
        end
    end
    
    local last, first;
    for k, v in ipairs( data.Authors ) do
        last, first = v.last, v.first;
        if k == 1 then
            if is_set(last) then
                OCinSoutput[&quot;rft.aulast&quot;] = last;
            end
            if is_set(first) then 
                OCinSoutput[&quot;rft.aufirst&quot;] = first;
            end
        end
        if is_set(last) and is_set(first) then
            OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
        elseif is_set(last) then
            OCinSoutput[&quot;rft.au&quot;] = last;
        end
    end
    
    OCinSoutput.rft_id = data.URL;
    OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
    OCinSoutput = setmetatable( OCinSoutput, nil );
    
    -- sort with version string always first, and combine.
    table.sort( OCinSoutput );
    table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
    return table.concat(OCinSoutput, &quot;&amp;&quot;);
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    --[[ 
    Load Input Parameters
    The argment_wrapper facillitates the mapping of multiple
    aliases to single internal variable.
    ]]
    local A = argument_wrapper( args );

    local i 
    local PPrefix = A['PPrefix']
    local PPPrefix = A['PPPrefix']
    if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = A['Authors'];
    local a = extractnames( args, 'AuthorList' );

    local Coauthors = A['Coauthors'];
    local Others = A['Others'];
    local Editors = A['Editors'];
    local e = extractnames( args, 'EditorList' );

    local Year = A['Year'];
    local PublicationDate = A['PublicationDate'];
    local OrigYear = A['OrigYear'];
    local Date = A['Date'];
    local LayDate = A['LayDate'];
    ------------------------------------------------- Get title data
    local Title = A['Title'];
    local BookTitle = A['BookTitle'];
    local Conference = A['Conference'];
    local TransTitle = A['TransTitle'];
    local TitleNote = A['TitleNote'];
    local TitleLink = A['TitleLink'];
    local Chapter = A['Chapter'];
    local ChapterLink = A['ChapterLink'];
    local TransChapter = A['TransChapter'];
    local TitleType = A['TitleType'];
    local Degree = A['Degree'];
    local Docket = A['Docket'];
    local ArchiveURL = A['ArchiveURL'];
    local URL = A['URL']
    local URLorigin = A:ORIGIN('URL');
    local ChapterURL = A['ChapterURL'];
    local ChapterURLorigin = A:ORIGIN('ChapterURL');
    local ConferenceURL = A['ConferenceURL'];
    local ConferenceURLorigin = A:ORIGIN('ConferenceURL');
    local Periodical = A['Periodical'];
    
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if not is_set(Chapter) then
            if not is_set(Title) then
                Title = Periodical;
                Periodical = '';
            else
                Chapter = Title
                TransChapter = TransTitle
                Title = '';
                TransTitle = '';
            end
        end
    end

    local Series = A['Series'];
    local Volume = A['Volume'];
    local Issue = A['Issue'];
    local Position = '';
    local Page, Pages, At, page_type;
    
    Page = A['Page'];
    Pages = hyphentodash( A['Pages'] );
    At = A['At'];
    
    if is_set(Page) then
        if is_set(Pages) or is_set(At) then
            Page = Page .. &quot; &quot; .. seterror('extra_pages');
            Pages = '';
            At = '';
        end
    elseif is_set(Pages) then
        if is_set(At) then
            Pages = Pages .. &quot; &quot; .. seterror('extra_pages');
            At = '';
        end
    end    
    
    local Edition = A['Edition'];
    local PublicationPlace = A['PublicationPlace']
    local Place = A['Place'];
    
    if not is_set(PublicationPlace) and is_set(Place) then
        PublicationPlace = Place;
    end
    
    if PublicationPlace == Place then Place = ''; end
    
    local PublisherName = A['PublisherName'];
    local RegistrationRequired = A['RegistrationRequired'];
    local SubscriptionRequired = A['SubscriptionRequired'];
    local Via = A['Via'];
    local AccessDate = A['AccessDate'];
    local ArchiveDate = A['ArchiveDate'];
    local Agency = A['Agency'];
    local DeadURL = A['DeadURL']
    local Language = A['Language'];
    local Format = A['Format'];
    local Ref = A['Ref'];
    
    local DoiBroken = A['DoiBroken'];
	
-- Special case for cite techreport.
	local ID = A['ID'];
	if (config.CitationClass == &quot;techreport&quot;) then	-- special case for cite techreport
		if is_set(Issue) then						-- cite techreport uses 'number', which everything else aliases to 'issue'
			if not is_set(ID) then					-- can we use ID for the &quot;number&quot;?
				ID = Issue;							-- yes, use it
				Issue = &quot;&quot;;							-- unset Issue so that &quot;number&quot; isn't duplicated in the rendered citation or COinS metadata
			else									-- can't use ID so emit error message
				ID = ID .. &quot; &quot; .. seterror('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
			end
		end	
	end	
			
    local ASINTLD = A['ASINTLD'];
    local IgnoreISBN = A['IgnoreISBN'];
    local Embargo = A['Embargo'];

    local ID_list = extractids( args );
    
    local Quote = A['Quote'];
    local PostScript = A['PostScript'];
    local LayURL = A['LayURL'];
    local LaySource = A['LaySource'];
    local Transcript = A['Transcript'];
    local TranscriptURL = A['TranscriptURL'] 
    local TranscriptURLorigin = A:ORIGIN('TranscriptURL');
    local sepc = A['Separator'];
    local LastAuthorAmp = A['LastAuthorAmp'];
    local no_tracking_cats = A['NoTracking'];

    local use_lowercase = ( sepc ~= '.' );
    local this_page = mw.title.getCurrentTitle();  --Also used for COinS and for language
    
    if not is_set(no_tracking_cats) then
        for k, v in pairs( cfg.uncategorized_namespaces ) do
            if this_page.nsText == v then
                no_tracking_cats = &quot;true&quot;;
                break;
            end
        end
    end

	local anchor_year;		-- used in the CITEREF identifier
	local COinS_date;		-- used in the COinS metadata

-- Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates.
-- TODO: 2013-10-27: AirDate is nil when dates() is called because it hasn't been set yet.  Move the call to dates() or set AirDate earlier.
	anchor_year, COinS_date = dates({['accessdate']=AccessDate, ['airdate']=AirDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
		['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});

	if not is_set(Year) then	-- prevent Year from being set from DateIn  TODO: eliminate the need for this?
		if is_set(anchor_year) then
			Year = anchor_year;
		end
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if is_set(BookTitle) then
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = BookTitle;
        TitleLink = '';
        TransTitle = '';
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = A['AirDate'];
        local SeriesLink = A['SeriesLink'];
        local Season = A['Season'];
        local SeriesNumber = A['SeriesNumber'];
        local Network = A['Network'];
        local Station = A['Station'];
        local s, n = {}, {};
        local Sep = (first_set(A[&quot;SeriesSeparator&quot;], A[&quot;Separator&quot;]) or &quot;&quot;) .. &quot; &quot;;
        
        if is_set(Issue) then table.insert(s, cfg.messages[&quot;episode&quot;] .. &quot; &quot; .. Issue); Issue = ''; end
        if is_set(Season) then table.insert(s, cfg.messages[&quot;season&quot;] .. &quot; &quot; .. Season); end
        if is_set(SeriesNumber) then table.insert(s, cfg.messages[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber); end
        if is_set(Network) then table.insert(n, Network); end
        if is_set(Station) then table.insert(n, Station); end
        
        Date = Date or AirDate;
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = Series;
        TitleLink = SeriesLink;
        TransTitle = '';
        
        Series = table.concat(s, Sep);
        ID = table.concat(n, Sep);
    end
    
    -- COinS metadata (see &lt;http://ocoins.info/&gt;) for
    -- automated parsing of citation information.
    local OCinSoutput = COinS{
        ['Periodical'] = Periodical,
        ['Chapter'] = Chapter,
        ['Title'] = Title,
        ['PublicationPlace'] = PublicationPlace,
        ['Date'] = first_set(COinS_date, Date, Year, PublicationDate),
        ['Series'] = Series,
        ['Volume'] = Volume,
        ['Issue'] = Issue,
        ['Pages'] = first_set(Page, Pages, At),
        ['Edition'] = Edition,
        ['PublisherName'] = PublisherName,
        ['URL'] = first_set( URL, ChapterURL ),
        ['Authors'] = a,
        ['ID_list'] = ID_list,
        ['RawPage'] = this_page.prefixedText,
    };

    if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = '';
        TitleLink = '';
        TransTitle = '';
    end

    -- Now perform various field 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 not is_set(Authors) then
        local Maximum = tonumber( A['DisplayAuthors'] );
        
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #a == 9 then 
            Maximum = 8;
            table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
        elseif not is_set(Maximum) then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = A[&quot;AuthorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;AuthorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A[&quot;AuthorFormat&quot;],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if is_set(Coauthors) then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
            deprecated_parameter();		-- |coauthor= and |coathors= are deprecated; add this page to deprecated parameter category
        end
        
        Authors = listpeople(control, a) 
    end

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { seterror('coauthors_missing_author', {}, true) } );	-- emit error message
		deprecated_parameter();		-- |coauthor= and |coathors= are deprecated; add this page to deprecated parameter category
	end

    local EditorCount
    if not is_set(Editors) then
        local Maximum = tonumber( A['DisplayEditors'] );
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #e == 4 then 
            Maximum = 3;
            table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
        elseif not is_set(Maximum) then
            Maximum = #e + 1;
        end

        local control = { 
            sep = A[&quot;EditorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;EditorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A['EditorFormat'],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };

        Editors, EditorCount = listpeople(control, e);
    else
        EditorCount = 1;
    end

    local Cartography = &quot;&quot;;
    local Scale = &quot;&quot;;
    if config.CitationClass == &quot;map&quot; then
        if not is_set( Authors ) and is_set( PublisherName ) then
            Authors = PublisherName;
            PublisherName = &quot;&quot;;
        end
        Cartography = A['Cartography'];
        if is_set( Cartography ) then
            Cartography = sepc .. &quot; &quot; .. wrap( 'cartography', Cartography, use_lowercase );
        end        
        Scale = A['Scale'];
        if is_set( Scale ) then
            Scale = sepc .. &quot; &quot; .. Scale;
        end        
    end
    
    if not is_set(Date) then
        Date = Year;
        if is_set(Date) then
            local Month = A['Month'];
            if is_set(Month) then
            	deprecated_parameter();		-- |month= (and also |day=) is deprecated; add this page to deprecated parameter category
                Date = Month .. &quot; &quot; .. Date;
                local Day = A['Day']
                if is_set(Day) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    
    if inArray(PublicationDate, {Date, Year}) then PublicationDate = ''; end
    if not is_set(Date) and is_set(PublicationDate) then
        Date = PublicationDate;
        PublicationDate = '';
    end

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date;
    
    if  not is_set(URL) and
        not is_set(ChapterURL) and
        not is_set(ArchiveURL) and
        not is_set(ConferenceURL) and
        not is_set(TranscriptURL) then
        
        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
        end
        
        -- Test if accessdate is given without giving a URL
        if is_set(AccessDate) then
            table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
            AccessDate = '';
        end
        
        -- Test if format is given without giving a URL
        if is_set(Format) then
            Format = Format .. seterror( 'format_missing_url' );
        end
    end
    
    -- Test if citation has no title
    if  not is_set(Chapter) and
        not is_set(Title) and
        not is_set(Periodical) and
        not is_set(Conference) and
        not is_set(TransTitle) and
        not is_set(TransChapter) then
        table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
    end
    
    Format = is_set(Format) and &quot; (&quot; .. Format .. &quot;)&quot; or &quot;&quot;;
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if is_set( ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
            URLorigin = A:ORIGIN('ArchiveURL')
        end
    end
    
    -- Format chapter / article title
    if is_set(Chapter) and is_set(ChapterLink) then 
        Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot;;
    end
    if is_set(Periodical) and is_set(Title) then
        Chapter = wrap( 'italic-title', Chapter );
        TransChapter = wrap( 'trans-italic-title', TransChapter );
    else
        Chapter = wrap( 'quoted-title', Chapter );
        TransChapter = wrap( 'trans-quoted-title', TransChapter );
    end
    
    local TransError = &quot;&quot;
    if is_set(TransChapter) then
        if not is_set(Chapter) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
        else
            TransChapter = &quot; &quot; .. TransChapter;
        end
    end
    
    Chapter = Chapter .. TransChapter;
    
    if is_set(Chapter) then
        if not is_set(ChapterLink) then
            if is_set(ChapterURL) then
                Chapter = externallink( ChapterURL, Chapter ) .. TransError;
                if not is_set(URL) then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif is_set(URL) then 
                Chapter = externallink( URL, Chapter ) .. TransError .. Format;
                URL = &quot;&quot;;
                Format = &quot;&quot;;
            else
                Chapter = Chapter .. TransError;
            end            
        elseif is_set(ChapterURL) then
            Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. 
                TransError;
        else
            Chapter = Chapter .. TransError;
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    elseif is_set(ChapterURL) then
        Chapter = &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. sepc .. &quot; &quot;;
    end        
    
    -- Format main title.
    if is_set(TitleLink) and is_set(Title) then
        Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
    end
    
    if is_set(Periodical) then
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    elseif inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;pressrelease&quot;,&quot;conference&quot;}) and
            not is_set(Chapter) then
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    else
        Title = wrap( 'italic-title', Title );
        TransTitle = wrap( 'trans-italic-title', TransTitle );
    end
    
    TransError = &quot;&quot;;
    if is_set(TransTitle) then
        if not is_set(Title) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
        else
            TransTitle = &quot; &quot; .. TransTitle;
        end
    end
    
    Title = Title .. TransTitle;
    
    if is_set(Title) then
        if not is_set(TitleLink) and is_set(URL) then 
            Title = externallink( URL, Title ) .. TransError .. Format       
            URL = &quot;&quot;;
            Format = &quot;&quot;;
        else
            Title = Title .. TransError;
        end
    end
    
    if is_set(Place) then
        Place = &quot; &quot; .. wrap( 'written', Place, use_lowercase ) .. sepc .. &quot; &quot;;
    end
    
    if is_set(Conference) then
        if is_set(ConferenceURL) then
            Conference = externallink( ConferenceURL, Conference );
        end
        Conference = sepc .. &quot; &quot; .. Conference
    elseif is_set(ConferenceURL) then
        Conference = sepc .. &quot; &quot; .. externallink( ConferenceURL, nil, ConferenceURLorigin );
    end
    
    if not is_set(Position) then
        local Minutes = A['Minutes'];
        if is_set(Minutes) then
            Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
        else
            local Time = A['Time'];
            if is_set(Time) then
                local TimeCaption = A['TimeCaption']
                if not is_set(TimeCaption) then
                    TimeCaption = cfg.messages['event'];
                    if sepc ~= '.' then
                        TimeCaption = TimeCaption:lower();
                    end
                end
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
            end
        end
    else
        Position = &quot; &quot; .. Position;
        At = '';
    end
    
    if not is_set(Page) then
        if is_set(Pages) then
            if is_set(Periodical) and
                not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;}) then
                Pages = &quot;: &quot; .. Pages;
            elseif tonumber(Pages) ~= nil then
                Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
            else
                Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
            end
        end
    else
        if is_set(Periodical) and
            not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;}) then
            Page = &quot;: &quot; .. Page;
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page;
        end
    end
    
    At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
    Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
    if config.CitationClass == 'map' then
        local Section = A['Section'];
        local Inset = A['Inset'];
        if first_set( Pages, Page, At ) ~= nil or sepc ~= '.' then
            if is_set( Section ) then
                Section = &quot;, &quot; .. wrap( 'section', Section, true );
            end
            if is_set( Inset ) then
                Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
            end
        else
            if is_set( Section ) then
                Section = sepc .. &quot; &quot; .. wrap( 'section', Section, use_lowercase );
                if is_set( Inset ) then
                    Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
                end
            elseif is_set( Inset ) then
                Inset = sepc .. &quot; &quot; .. wrap( 'inset', Inset, use_lowercase );
            end            
        end            
        At = At .. Section .. Inset;        
    end    

	--[[Look in the list of iso639-1 language codes to see if the value provided in the language parameter matches one of them.  If a match is found, 
	use that value; if not, then use the value that was provided with the language parameter.
	
	Categories are assigned in a manner similar to the {{xx icon}} templates - categorizes only mainspace citations and only when the language code is not 'en' (English).
	]]
	if is_set (Language) then
		local name = cfg.iso639_1[Language:lower()];		-- get the language name if Language parameter has a valid iso 639-1 code
		if nil == name then
			Language=&quot; &quot; .. wrap( 'language', Language );	-- no match, use parameter's value
		else
			if 0 == this_page.namespace and 'en' ~= Language:lower() then	--found a match; is this page main / article space and English not the language?
				Language=&quot; &quot; .. wrap( 'language', name .. '[[Category:Articles with ' .. name .. '-language external links]]' );	-- in main space and not English: categorize
			else
				Language=&quot; &quot; .. wrap( 'language', name );	--not in mainspace or language is English so don't categorize
			end
		end
	else
		Language=&quot;&quot;;	-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;

-- handle type parameter for those CS1 citations that have default values

	if &quot;pressrelease&quot; == config.CitationClass then		-- if this citation is cite press release
		if not is_set (TitleType) then
			TitleType = &quot;Press release&quot;;				-- if type not specified, display the press release annotation
		else
			if &quot;none&quot; == TitleType then TitleType = &quot;&quot;; end		-- if |type=none then type parameter not displayed
		end

	elseif &quot;techreport&quot; == config.CitationClass then	-- if this citation is cite techreport
		if not is_set (TitleType) then
			TitleType = &quot;Technical report&quot;;				-- if type not specified, display the techreport annotation
		else
			if &quot;none&quot; == TitleType then TitleType = &quot;&quot;; end		-- if |type=none then type parameter not displayed; |number=, if set, will be displayed
		end
	
	elseif &quot;thesis&quot; == config.CitationClass then		-- if this citation is cite thesis
		if not is_set (TitleType) then
			if is_set(Degree) then						-- if type not specified, display one of the thesis annotations
				TitleType = Degree .. &quot; thesis&quot;;		-- if a degree (masters, PhD, ...) is specified include it in the display
			else
				TitleType = &quot;Thesis&quot;;					-- otherwise display the simple thesis annotation
			end
		else
			if &quot;none&quot; == TitleType then TitleType = &quot;&quot;; end		-- if |type=none then type parameter not displayed
		end
	end
	if is_set(TitleType) then					-- if type parameter is specified
		TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot;;	-- display it in parentheses
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
    Edition = is_set(Edition) and (&quot; &quot; .. wrap( 'edition', Edition )) or &quot;&quot;;
    Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
    Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
    OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
    Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;
    
    if is_set(Volume) then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume;
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
        end
    end
    
    ------------------------------------ totally unrelated data
    --[[ Loosely mimic {{subscription required}} template; Via parameter identifies a delivery source that is not the publisher; these sources often, but not always, exist
    behind a registration or paywall.  So here, we've chosen to decouple via from subscription (via has never been part of the registration required template).
    
    Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link note is displayed. There are no error messages for this condition.
    ]]
    if is_set(Via) then
        Via = &quot; &quot; .. wrap( 'via', Via );
    end

	if is_set(SubscriptionRequired) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription']; --here when 'via' parameter not used but 'subscription' is
    elseif is_set(RegistrationRequired) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration']; --here when 'via' and 'subscription' parameters not used but 'registration' is
    end

    if is_set(AccessDate) then
        local retrv_text = &quot; &quot; .. cfg.messages['retrieved']
        if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
        AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
            .. substitute( retrv_text, {AccessDate} ) .. '&lt;/span&gt;'
    end
    
    if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end

    
    ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo} );

    if is_set(URL) then
        URL = &quot; &quot; .. externallink( URL, nil, URLorigin );
    end

    if is_set(Quote) then
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        Quote = sepc ..&quot; &quot; .. wrap( 'quoted-text', Quote ); 
        PostScript = &quot;&quot;;
    elseif PostScript:lower() == &quot;none&quot; then
        PostScript = &quot;&quot;;
    end
    
    local Archived
    if is_set(ArchiveURL) then
        if not is_set(ArchiveDate) then
            ArchiveDate = seterror('archive_missing_date');
        end
        if &quot;no&quot; == DeadURL then
            local arch_text = cfg.messages['archived'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
                { externallink( ArchiveURL, arch_text ), ArchiveDate } );
            if not is_set(OriginalURL) then
                Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url');                               
            end
        elseif is_set(OriginalURL) then
            local arch_text = cfg.messages['archived-dead'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text,
                { externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
        else
            local arch_text = cfg.messages['archived-missing'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
                { seterror('archive_missing_url'), ArchiveDate } );
        end
    else
        Archived = &quot;&quot;
    end
    
    local Lay
    if is_set(LayURL) then
        if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
        if is_set(LaySource) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot;;
        else
            LaySource = &quot;&quot;;
        end
        if sepc == '.' then
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;;
    end
    
    if is_set(Transcript) then
        if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
    elseif is_set(TranscriptURL) then
        Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
    end
    
    local Publisher;
    if is_set(Periodical) and
        not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;}) then
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end
        elseif is_set(PublicationPlace) then
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if is_set(PublicationDate) then
            if is_set(Publisher) then
                Publisher = Publisher .. &quot;, &quot; .. wrap( 'published', PublicationDate );
            else
                Publisher = PublicationDate;
            end
        end
        if is_set(Publisher) then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if is_set(PublicationDate) then
            PublicationDate = &quot; (&quot; .. wrap( 'published', PublicationDate ) .. &quot;)&quot;;
        end
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif is_set(PublicationPlace) then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    
    -- Several of the above rely upon detecting this as nil, so do it last.
    if is_set(Periodical) then
        if is_set(Title) or is_set(TitleNote) then 
            Periodical = sepc .. &quot; &quot; .. wrap( 'italic-title', Periodical ) 
        else 
            Periodical = wrap( 'italic-title', Periodical )
        end
    end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if inArray(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
        if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, 
            Language, Cartography, Edition, Publisher, Agency, Volume, Issue}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, Language, 
            Volume, Issue, Others, Cartography, Edition, Publisher, Agency}, sepc );
    end
    
    if #ID_list &gt; 0 then
        ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
    else
        ID_list = ID;
    end
    
    local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
    local text;
    local pgtext = Position .. Page .. Pages .. At;
    
    if is_set(Authors) then
        if is_set(Coauthors) then
            Authors = Authors .. A['AuthorSeparator'] .. &quot; &quot; .. Coauthors
        end
        if is_set(Date) then
            Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        elseif string.sub(Authors,-1,-1) == sepc then
            Authors = Authors .. &quot; &quot;
        else
            Authors = Authors .. sepc .. &quot; &quot;
        end
        if is_set(Editors) then
            local in_text = &quot; &quot;;
            local post_text = &quot;&quot;;
            if is_set(Chapter) then
                in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
            else
                if EditorCount &lt;= 1 then
                    post_text = &quot;, &quot; .. cfg.messages['editor'];
                else
                    post_text = &quot;, &quot; .. cfg.messages['editors'];
                end
            end 
            if (sepc ~= '.') then in_text = in_text:lower() end
            Editors = in_text .. Editors .. post_text;
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = Editors .. &quot; &quot;
                else Editors = Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif is_set(Editors) then
        if is_set(Date) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
            else
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if is_set(Date) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end
        if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
            text = safejoin( {Chapter, Place, tcommon}, sepc );
            text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
            text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
            text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if is_set(PostScript) and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    if not is_set(Year) then
        if is_set(DateIn) then
            Year = selectyear( DateIn );
        elseif is_set(PublicationDate) then
            Year = selectyear( PublicationDate );
        end
    end
    
    local options = {};
    
    if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
        options.class = &quot;citation &quot; .. config.CitationClass;
    else
        options.class = &quot;citation&quot;;
    end
    
    if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if #a &gt; 0 then
                for i,v in ipairs(a) do 
                    names[i] = v.last 
                    if i == 4 then break end
                end
            elseif #e &gt; 0 then
                for i,v in ipairs(e) do 
                    names[i] = v.last 
                    if i == 4 then break end                
                end
            end
			names[ #names + 1 ] = Year or anchor_year;	-- Year first for legacy citations
            id = anchorid(names)
        end
        options.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = {};
        text = seterror('empty_citation');
        z.message_tail = {};
    end
    
    if is_set(options.id) then 
        text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    else
        text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    end        

    local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        text = text .. &quot; &quot;;
        for i,v in ipairs( z.message_tail ) do
            if is_set(v[1]) then
                if i == #z.message_tail then
                    text = text .. errorcomment( v[1], v[2] );
                else
                    text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
                end
            end
        end
    end
    
    no_tracking_cats = no_tracking_cats:lower();
    if inArray(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    local suggestions = {};
    local error_text, error_state;

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        args[k] = v;       
    end    

    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            if not validate( k ) then            
                error_text = &quot;&quot;;
                if type( k ) ~= 'string' then
                    -- Exclude empty numbered parameters
                    if v:match(&quot;%S+&quot;) ~= nil then
                        error_text, error_state = seterror( 'text_ignored', {v}, true );
                    end
                elseif validate( k:lower() ) then 
                    error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
                else
                    if #suggestions == 0 then
                        suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
                    end
                    if suggestions[ k:lower() ] ~= nil then
                        error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
                    else
                        error_text, error_state = seterror( 'parameter_ignored', {k}, true );
                    end
                end                  
                if error_text ~= '' then
                    table.insert( z.message_tail, {error_text, error_state} );
                end                
            end
            args[k] = v;
        elseif args[k] ~= nil or (k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z</text>
      <sha1>3trntte6ahxt1qanijd0bp39zk6cthw</sha1>
    </revision>
    <revision>
      <id>4663</id>
      <parentid>4662</parentid>
      <timestamp>2013-11-09T13:37:00Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Fix sandbox oversight;</comment>
      <origin>4663</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="77554" sha1="rhj0prb6ftlhx3l38ww4v97cxxy26my" xml:space="preserve">local z = {
    error_categories = {};
    error_ids = {};
    message_tail = {};
}

-- Include translation message hooks, ID and error handling configuration settings.
local cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );

-- Contains a list of all recognized parameters
local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );

-- Whether variable is set or not
function is_set( var )
    return not (var == nil or var == '');
end

-- First set variable or nil if none
function first_set(...)
    local list = {...};
    for _, var in pairs(list) do
        if is_set( var ) then
            return var;
        end
    end
end

-- Whether needle is in haystack
function inArray( needle, haystack )
    if needle == nil then
        return false;
    end
    for n,v in ipairs( haystack ) do
        if v == needle then
            return n;
        end
    end
    return false;
end

-- Add this page to the deprecated parameter tracking category
function deprecated_parameter()
	if true ~= Page_in_deprecated_cat then	-- if we haven't been here before then set a 
		Page_in_deprecated_cat=true;		-- sticky flag so that if there are more than one deprecated parameter the category is added only once
		table.insert( z.error_categories, &quot;Pages containing cite templates with deprecated parameters&quot; );	-- add page to category
	end
end

-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
    return args and tostring( mw.message.newRawMessage( msg, args ) ) or msg;
end

-- Wraps a string using a message_list configuration taking one argument
function wrap( key, str, lower )
    if not is_set( str ) then
        return &quot;&quot;;
    elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
        str = safeforitalics( str );
    end
    if lower == true then
        return substitute( cfg.messages[key]:lower(), {str} );
    else
        return substitute( cfg.messages[key], {str} );
    end        
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
    local origin = {};
    
    return setmetatable({
        ORIGIN = function( self, k )
            local dummy = self[k]; --force the variable to be loaded.
            return origin[k];
        end
    },
    {
        __index = function ( tbl, k )
            if origin[k] ~= nil then
                return nil;
            end
            
            local args, list, v = args, cfg.aliases[k];
            
            if type( list ) == 'table' then
                v, origin[k] = selectone( args, list, 'redundant_parameters' );
                if origin[k] == nil then
                    origin[k] = ''; -- Empty string, not nil
                end
            elseif list ~= nil then
                v, origin[k] = args[list], list;
            else
                -- maybe let through instead of raising an error?
                -- v, origin[k] = args[k], k;
                error( cfg.messages['unknown_argument_map'] );
            end
            
            -- Empty strings, not nil;
            if v == nil then
                v = cfg.defaults[k] or '';
                origin[k] = '';
            end
            
            tbl = rawset( tbl, k, v );
            return v;
        end,
    });
end

-- Checks that parameter name is valid using the whitelist
function validate( name )
    name = tostring( name );
    
    -- Normal arguments
    if whitelist.basic_arguments[ name ] then
        return true;
    end
    
    -- Arguments with numbers in them
    name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );
    if whitelist.numbered_arguments[ name ] then
        return true;
    end
    
    -- Not found, argument not supported.
    return false
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
    return wrap( hidden and 'hidden-error' or 'visible-error', content );
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
    local error_state = cfg.error_conditions[ error_id ];
    
    prefix = prefix or &quot;&quot;;
    suffix = suffix or &quot;&quot;;
    
    if error_state == nil then
        error( cfg.messages['undefined_error'] );
    elseif is_set( error_state.category ) then
        table.insert( z.error_categories, error_state.category );
    end
    
    local message = substitute( error_state.message, arguments );
    
    message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
        &quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
        cfg.messages['help page label'] .. &quot;]])&quot;;
    
    z.error_ids[ error_id ] = true;
    if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
            and z.error_ids['citation_missing_title'] then
        return '', false;
    end
    
    message = table.concat({ prefix, message, suffix });
    
    if raw == true then
        return message, error_state.hidden;
    end        
        
    return errorcomment( message, error_state.hidden );
end

-- Formats a wiki style external link
function externallinkid(options)
    local url_string = options.id;
    if options.encode == true or options.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, url_string, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Formats a wiki style internal link
function internallinkid(options)
    return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, options.id, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Format an external link with error checking
function externallink( URL, label, source )
    local error_str = &quot;&quot;;
    if not is_set( label ) then
        label = URL;
        if is_set( source ) then
            error_str = seterror( 'bare_url_missing_title', { wrap( 'parameter', source ) }, false, &quot; &quot; );
        else
            error( cfg.messages[&quot;bare_url_no_origin&quot;] );
        end            
    end
    if not checkurl( URL ) then
        error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
    end
    return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safeforurl( label ), &quot;]&quot;, error_str });
end

-- Formats a link to Amazon
function amazon(id, domain)
    if not is_set(domain) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local handler = cfg.id_handlers['ASIN'];
    return externallinkid({link = handler.link,
        label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
        encode=handler.encode, separator = handler.separator})
end

--[[
Formats a PMC and checks for embargoed articles.  The embargo parameter takes a date for a value. If the embargo date is in the futue
the PMC identifier will not be linked to the article.  If the embargo specifies a date in the past, or if it is empty or omitted, then
the PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].link.

The {{citation/core}} version of {{cite journal}} links the citation title (if url parameter is empty) when embargo date is in the past
or when embargo parameter is missing or empty. That behavior is inconsistent with the behavior of other identifiers used in CS1 and is
not supported here.
]]
function pmc(id, embargo)
	local handler = cfg.id_handlers['PMC'];
    
	local text;
	
	if is_set(embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );

		if good1 and good2 and tonumber( embargo_date ) &lt; tonumber( todays_date ) then	--if embargo date is in the past then
			text = externallinkid({link = handler.link, label = handler.label,			--ok to link to article
				prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		else
			text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id;	--still embargoed so no external link
		end
	else
		text = externallinkid({link = handler.link, label = handler.label,			--no embargo date, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
	end
	return text
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    local handler = cfg.id_handlers['DOI'];
    
    local text;
    if is_set(inactive) then
        text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
        table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. selectyear(inactive) );        
        inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
    else 
        text = externallinkid({link = handler.link, label = handler.label,
            prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
        inactive = &quot;&quot; 
    end
    if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then      
        cat = seterror( 'bad_doi' );
    end
    return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    local handler = cfg.id_handlers['OL'];
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    else
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode}) .. 
            ' ' .. seterror( 'bad_ol' );
    end
end

--[[
Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.
]]
function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and ndashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 didgits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = externallinkid({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. seterror( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

-- returns a number according to the month in a date 1 for January, etc.  If not a valid month, returns 0
function get_month_number (month)
local long_months = {['january']=1, ['february']=2, ['march']=3, ['april']=4, ['may']=5, ['june']=6, ['july']=7, ['august']=8, ['september']=9, ['october']=10, ['november']=11, ['december']=12};
local short_months = {['jan']=1, ['feb']=2, ['mar']=3, ['apr']=4, ['may']=5, ['jun']=6, ['jul']=7, ['aug']=8, ['sep']=9, ['oct']=10, ['nov']=11, ['dec']=12};
local temp;
	temp=long_months[month:lower()];
	if temp then return temp; end	-- if month is the long-form name
	temp=short_months[month:lower()];
	if temp then return temp; end	-- if month is the short-form name
	return 0;													-- misspelled or not a month name
end

-- returns true if date has one of the five seasons.  Else false.
function is_valid_season (season)
	if inArray( season, {'winter', 'spring', 'summer', 'fall', 'autumn'} ) then
		return true;
	end
	return false;
end

--[[
Returns true if day is less than or equal to the number of days in month; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap years before 1582 and Gregorian leap years after 1582.
Where the two calendars overlap (1582 to approximately 1923) dates are assumed to be Gregorian.
]]
function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if (2==month) then		-- if February
		month_length = 28;	-- then 28 days unless
		if 1582 &gt; tonumber(year) then	-- Julian calendar
			if 0==(year%4) then
				month_length = 29;
			end
		else				-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then	-- date specifies a leap year
				month_length = 29;	-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end

--Check a pair of months or seasons to see if both are valid members of a month or season pair.

function is_valid_month_season_range(range_start, range_end)
	if 0 == get_month_number (range_start:lower()) then			-- is this a month range?
		if true == is_valid_season (range_start:lower()) then	-- not a month range, is this a season range?
			return is_valid_season (range_end:lower());			-- range_start is season; return true if range_end also a season; else false
		end
		return false;		-- range_start is not a month or a season
	end
	if 0 == get_month_number (range_end:lower()) then			-- range_start is a month; is range_end also a  month?
		return false;											-- not a month range
	end
	return true;
end


--[[
Check date format to see that it is one of the formats approved by MOS:DATE: MMMM D, YYYY; D MMMM YYYY; MMMM YYYY; YYYY-MM-DD; YYYY.
Additionally, check the date to see that it is a real date: no 31 in 30-day months; no 29 February when not a leap year.  Months, both long-form and three
character abbreviations, and seasons must be spelled correctly.

If the date fails the fomat tests, this function returns false but does not return values for anchor_year and COinS_date.  When this happens, the date parameter is
used in the COinS metadata and the CITEREF identifier gets its year from the year parameter if present.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is date_string without anchor_year disambiguators if any
]]
function check_date (date_string)
	local year;
	local month;
	local day;
	local anchor_year;
	local coins_date;

	if date_string:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then			-- Year-initial numerical year month day format
		coins_date = date_string:match(&quot;%d%d%d%d%-%d%d%-%d%d&quot;);
		year, month, day=string.match(date_string, &quot;(%d%d%d%d)%-(%d%d)%-(%d%d)&quot;);
		anchor_year = year;
		month=tonumber(month);
		if 12 &lt; month or 1 &gt; month then return false; end

	elseif date_string:match(&quot;^%a+%s*%d%d*%s*,%s*%d%d%d%d%a?$&quot;) then	-- month-initial: month day, year
		coins_date = date_string:match(&quot;%a+%s*%d%d*%s*,%s*%d%d%d%d&quot;);
		month, day, anchor_year, year=string.match(date_string, &quot;(%a+)%s*(%d%d*)%s*,%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month:lower());
		if 0 == month then return false; end					-- return false if month text isn't one of the twelve months
				
	elseif date_string:match(&quot;^%d%d*%s*%a+%s*%d%d%d%d%a?$&quot;) then		-- date-initial: day month year
		coins_date = date_string:match(&quot;%d%d*%s*%a+%s*%d%d%d%d&quot;);
		day, month, anchor_year, year=string.match(date_string, &quot;(%d%d*)%s*(%a+)%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month:lower());
		if 0 == month then return false; end					-- return false if month text isn't one of the twelve months

	elseif mw.ustring.match (date_string, &quot;^%a+%s*[%s%-/–]%s*%a+%s*%d%d%d%d%a?$&quot;) then		-- month/season range year
		local month2
		coins_date = mw.ustring.match (date_string, &quot;%a+%s*[%s%-/–]%s*%a+%s*%d%d%d%d&quot;);
		coins_date= mw.ustring.gsub( coins_date, &quot;–&quot;, &quot;-&quot; );	-- replace ndash with hyphen
		month, month2, anchor_year, year=mw.ustring.match (date_string, &quot;(%a+)%s*[%s%-/–]%s*(%a+)%s*((%d%d%d%d)%a?)&quot;);
		day=0;													-- mark day as not used
		if false == is_valid_month_season_range(month, month2) then
			return false;
		end
		
	elseif date_string:match(&quot;^%a+%s*%d%d%d%d%a?$&quot;) then				-- month/season year
		coins_date = date_string:match(&quot;%a+%s*%d%d%d%d&quot;);
		month, anchor_year, year=string.match(date_string, &quot;(%a+)%s*((%d%d%d%d)%a?)&quot;);
		day=0;													-- mark day as not used
		local season=month;										-- copy 
		month = get_month_number (month:lower());
		if month == 0 then										-- if month text isn't one of the twelve months, might be a season
			if false == is_valid_season (season:lower()) then
				return false;									-- return false not a month or one of the five seasons
			end
		end

	elseif date_string:match(&quot;^%d%d%d%d?%a?$&quot;) then			-- year; here accept either YYY or YYYY
		coins_date = date_string:match(&quot;^%d%d%d%d?&quot;);
		anchor_year, year=string.match(date_string, &quot;((%d%d%d%d?)%a?)&quot;);
		month, day = 0, 0;										-- mark day and month as not used
	else
		return false;											-- date format not one of the MOS:DATE approved formats
	end

	if 0~=month and 0~=day then									-- check year month day dates for validity
		if false==is_valid_date(year,month,day) then
			return false;										-- date string is not a real date return false; unset anchor_year and coins_date
		end
	end
	
	return true, anchor_year, coins_date;						-- format is good and date string represents a real date
end	

--[[
Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true and values for anchor_year (used in CITEREF identifiers) and COinS_date (used in the COinS metadata).  The |date= parameter test is unique.  This function only 
accepts anchor_year and COinS_date results from the |date= parameter test and |date= is the only date-holding parameter that is allowed to contain the no-date keywords
&quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.
]]

function dates(date_parameters_list)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local error_message =&quot;&quot;;
	local good_date=false;
	
	for k, v in pairs(date_parameters_list) do		-- for each date-holding parameter in the list
		if is_set(v) then							-- if the parameter has a value
			if v:match(&quot;^c%.%s%d%d%d%d?%a?$&quot;) then		-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				if 'date'==k then
					good_date, anchor_year, COinS_date = true, v:match(&quot;((c%.%s%d%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
				elseif 'year'==k then
					good_date =  true;
				end
			elseif 'year'==k then					-- if the parameter is |year= (but not c. year)
				if v:match(&quot;^%d%d%d%d?%a?$&quot;) then	-- year with or without CITEREF disambiguator
					good_date =  true;
				end
			elseif 'date'==k then						-- if the parameter is |date=
				if v:match(&quot;n%.d%.%a?&quot;) then		-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;;	-- no error when date parameter is set to no date
				elseif v:match(&quot;nd%a?$&quot;) then		-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	-- no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v);	-- go test the date
				end
			else									-- any other date-holding parameter
				good_date = check_date (v);			-- go test the date
			end
			if false==good_date then		-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then		-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;	-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;	-- add the failed parameter
			end
		end
	end
	if is_set(error_message) then
		table.insert( z.message_tail, { seterror( 'bad_date', {error_message}, true ) } );	-- add this error message
	end

	return anchor_year, COinS_date;		-- and done
end

--[[
Determines whether an URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
    -- Protocol-relative or URL scheme
    return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
    return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

--[[
ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. If the number is valid the result will be 0.
Before calling this function, issbn/issn must be checked for length and stripped of dashes, spaces and other non-isxn characters.
]]
function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of bytes
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do				-- loop through all of the byte an calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
    isbn_str = cleanisbn( isbn_str ):gsub( &quot;-&quot;, &quot;&quot; );
    local len = isbn_str:len();
 
    if len ~= 10 and len ~= 13 then
        return false;
    end
 
    if len == 10 then
        if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
    else
	    local temp = 0;
        if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end	-- isbn13 begins with 978 or 979
        isbn_str = { isbn_str:byte(1, len) };
        for i, v in ipairs( isbn_str ) do
            temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
        end
        return temp % 10 == 0;
    end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
    return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
        return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
    end));
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if not is_set(str) then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        
        -- Remove newlines as they break italics.
        return str:gsub( '\n', ' ' );
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

--[[
Return the year portion of a date string, if possible.  
Returns empty string if the argument can not be interpreted
as a year.

BUG: If editors set |date=n.d or |date=n.da then selectyear() returns the current year for use in CITEREF.  These &quot;dates&quot; are caught by dates().
]]
function selectyear( str )
	-- Is the input a simple number?
	local num = tonumber( str ); 
	if num ~= nil and num &gt; 0 and num &lt; 2100 and num == math.floor(num) then
		return str;
	else
		-- Use formatDate to interpret more complicated formats
		local lang = mw.getContentLanguage();
		local good, result;
		good, result = pcall( lang.formatDate, lang, 'Y', str );
		if good then return result; end -- if good
	end
end

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    if maximum ~= nil and maximum &lt; 1 then return &quot;&quot;, 0; end
    
    for i,person in ipairs(people) do
        if is_set(person.last) then
            local mask = person.mask
            local one
            local sep_one = sep;
            if maximum ~= nil and i &gt; maximum then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask;
                    sep_one = &quot; &quot;;
                end
            else
                one = person.last
                local first = person.first
                if is_set(first) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if is_set(person.link) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert( text, one )
            table.insert( text, sep_one )
        end
    end

    local count = #text / 2;
    if count &gt; 0 then 
        if count &gt; 1 and is_set(lastauthoramp) and not etal then
            text[#text-2] = &quot; &amp; &quot;;
        end
        text[#text] = nil; 
    end
    
    local result = table.concat(text) -- construct list
    if etal then 
        local etal_text = cfg.messages['et al'];
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result = 
        '&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
    end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
    return &quot;CITEREF&quot; .. table.concat( options );
end

-- Gets name list from the input arguments
function extractnames(args, list_name)
    local names = {};
    local i = 1;
    local last;
    
    while true do
        last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );
        if not is_set(last) then
            -- just in case someone passed in an empty parameter
            break;
        end
        names[i] = {
            last = last,
            first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i ),
            link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ),
            mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i )
        };
        i = i + 1;
    end
    return names;
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
    local id_list = {};
    for k, v in pairs( cfg.id_handlers ) do    
        v = selectone( args, v.parameters, 'redundant_parameters' );
        if is_set(v) then id_list[k] = v; end
    end
    return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
    local new_list, handler = {};
    
    function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
    
    for k, v in pairs( id_list ) do
        -- fallback to read-only cfg
        handler = setmetatable( { ['id'] = v }, fallback(k) );
        
        if handler.mode == 'external' then
            table.insert( new_list, {handler.label, externallinkid( handler ) } );
        elseif handler.mode == 'internal' then
            table.insert( new_list, {handler.label, internallinkid( handler ) } );
        elseif handler.mode ~= 'manual' then
            error( cfg.messages['unknown_ID_mode'] );
        elseif k == 'DOI' then
            table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
        elseif k == 'ASIN' then
            table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
        elseif k == 'OL' then
            table.insert( new_list, {handler.label, openlibrary( v ) } );
        elseif k == 'PMC' then
            table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
        elseif k == 'ISSN' then
        	table.insert( new_list, {handler.label, issn( v ) } );
        elseif k == 'ISBN' then
            local ISBN = internallinkid( handler );
            if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
                ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
            end
            table.insert( new_list, {handler.label, ISBN } );                
        else
            error( cfg.messages['unknown_manual_ID'] );
        end
    end
    
    function comp( a, b )
        return a[1] &lt; b[1];
    end
    
    table.sort( new_list, comp );
    for k, v in ipairs( new_list ) do
        new_list[k] = v[2];
    end
    
    return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
    local value = nil;
    local selected = '';
    local error_list = {};
    
    if index ~= nil then index = tostring(index); end
    
    -- Handle special case of &quot;#&quot; replaced by empty string
    if index == '1' then
        for _, v in ipairs( possible ) do
            v = v:gsub( &quot;#&quot;, &quot;&quot; );
            if is_set(args[v]) then
                if value ~= nil and selected ~= v then
                    table.insert( error_list, v );
                else
                    value = args[v];
                    selected = v;
                end
            end
        end        
    end
    
    for _, v in ipairs( possible ) do
        if index ~= nil then
            v = v:gsub( &quot;#&quot;, index );
        end
        if is_set(args[v]) then
            if value ~= nil and selected ~=  v then
                table.insert( error_list, v );
            else
                value = args[v];
                selected = v;
            end
        end
    end
    
    if #error_list &gt; 0 then
        local error_str = &quot;&quot;;
        for _, k in ipairs( error_list ) do
            if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
            error_str = error_str .. wrap( 'parameter', k );
        end
        if #error_list &gt; 1 then
            error_str = error_str .. cfg.messages['parameter-final-separator'];
        else
            error_str = error_str .. cfg.messages['parameter-pair-separator'];
        end
        error_str = error_str .. wrap( 'parameter', selected );
        table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
    end
    
    return value, selected;
end

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
function COinS(data)
    if 'table' ~= type(data) or nil == next(data) then
        return '';
    end
    
    local ctx_ver = &quot;Z39.88-2004&quot;;
    
    -- treat table strictly as an array with only set values.
    local OCinSoutput = setmetatable( {}, {
        __newindex = function(self, key, value)
            if is_set(value) then
                rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
            end
        end
    });
    
    if is_set(data.Chapter) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Chapter;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    elseif is_set(data.Periodical) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
        OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    else
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
    end
    
    OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
    OCinSoutput[&quot;rft.date&quot;] = data.Date;
    OCinSoutput[&quot;rft.series&quot;] = data.Series;
    OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
    OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
    OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
    OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
    OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
    
    for k, v in pairs( data.ID_list ) do
        local id, value = cfg.id_handlers[k].COinS;
        if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
        if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
            OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
        else
            OCinSoutput[ id ] = value;
        end
    end
    
    local last, first;
    for k, v in ipairs( data.Authors ) do
        last, first = v.last, v.first;
        if k == 1 then
            if is_set(last) then
                OCinSoutput[&quot;rft.aulast&quot;] = last;
            end
            if is_set(first) then 
                OCinSoutput[&quot;rft.aufirst&quot;] = first;
            end
        end
        if is_set(last) and is_set(first) then
            OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
        elseif is_set(last) then
            OCinSoutput[&quot;rft.au&quot;] = last;
        end
    end
    
    OCinSoutput.rft_id = data.URL;
    OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
    OCinSoutput = setmetatable( OCinSoutput, nil );
    
    -- sort with version string always first, and combine.
    table.sort( OCinSoutput );
    table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
    return table.concat(OCinSoutput, &quot;&amp;&quot;);
end

--[[
This is the main function foing the majority of the citation
formatting.
]]
function citation0( config, args)
    --[[ 
    Load Input Parameters
    The argment_wrapper facillitates the mapping of multiple
    aliases to single internal variable.
    ]]
    local A = argument_wrapper( args );

    local i 
    local PPrefix = A['PPrefix']
    local PPPrefix = A['PPPrefix']
    if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = A['Authors'];
    local a = extractnames( args, 'AuthorList' );

    local Coauthors = A['Coauthors'];
    local Others = A['Others'];
    local Editors = A['Editors'];
    local e = extractnames( args, 'EditorList' );

    local Year = A['Year'];
    local PublicationDate = A['PublicationDate'];
    local OrigYear = A['OrigYear'];
    local Date = A['Date'];
    local LayDate = A['LayDate'];
    ------------------------------------------------- Get title data
    local Title = A['Title'];
    local BookTitle = A['BookTitle'];
    local Conference = A['Conference'];
    local TransTitle = A['TransTitle'];
    local TitleNote = A['TitleNote'];
    local TitleLink = A['TitleLink'];
    local Chapter = A['Chapter'];
    local ChapterLink = A['ChapterLink'];
    local TransChapter = A['TransChapter'];
    local TitleType = A['TitleType'];
    local Degree = A['Degree'];
    local Docket = A['Docket'];
    local ArchiveURL = A['ArchiveURL'];
    local URL = A['URL']
    local URLorigin = A:ORIGIN('URL');
    local ChapterURL = A['ChapterURL'];
    local ChapterURLorigin = A:ORIGIN('ChapterURL');
    local ConferenceURL = A['ConferenceURL'];
    local ConferenceURLorigin = A:ORIGIN('ConferenceURL');
    local Periodical = A['Periodical'];
    
    if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
        if not is_set(Chapter) then
            if not is_set(Title) then
                Title = Periodical;
                Periodical = '';
            else
                Chapter = Title
                TransChapter = TransTitle
                Title = '';
                TransTitle = '';
            end
        end
    end

    local Series = A['Series'];
    local Volume = A['Volume'];
    local Issue = A['Issue'];
    local Position = '';
    local Page, Pages, At, page_type;
    
    Page = A['Page'];
    Pages = hyphentodash( A['Pages'] );
    At = A['At'];
    
    if is_set(Page) then
        if is_set(Pages) or is_set(At) then
            Page = Page .. &quot; &quot; .. seterror('extra_pages');
            Pages = '';
            At = '';
        end
    elseif is_set(Pages) then
        if is_set(At) then
            Pages = Pages .. &quot; &quot; .. seterror('extra_pages');
            At = '';
        end
    end    
    
    local Edition = A['Edition'];
    local PublicationPlace = A['PublicationPlace']
    local Place = A['Place'];
    
    if not is_set(PublicationPlace) and is_set(Place) then
        PublicationPlace = Place;
    end
    
    if PublicationPlace == Place then Place = ''; end
    
    local PublisherName = A['PublisherName'];
    local RegistrationRequired = A['RegistrationRequired'];
    local SubscriptionRequired = A['SubscriptionRequired'];
    local Via = A['Via'];
    local AccessDate = A['AccessDate'];
    local ArchiveDate = A['ArchiveDate'];
    local Agency = A['Agency'];
    local DeadURL = A['DeadURL']
    local Language = A['Language'];
    local Format = A['Format'];
    local Ref = A['Ref'];
    
    local DoiBroken = A['DoiBroken'];
	
-- Special case for cite techreport.
	local ID = A['ID'];
	if (config.CitationClass == &quot;techreport&quot;) then	-- special case for cite techreport
		if is_set(Issue) then						-- cite techreport uses 'number', which everything else aliases to 'issue'
			if not is_set(ID) then					-- can we use ID for the &quot;number&quot;?
				ID = Issue;							-- yes, use it
				Issue = &quot;&quot;;							-- unset Issue so that &quot;number&quot; isn't duplicated in the rendered citation or COinS metadata
			else									-- can't use ID so emit error message
				ID = ID .. &quot; &quot; .. seterror('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
			end
		end	
	end	
			
    local ASINTLD = A['ASINTLD'];
    local IgnoreISBN = A['IgnoreISBN'];
    local Embargo = A['Embargo'];

    local ID_list = extractids( args );
    
    local Quote = A['Quote'];
    local PostScript = A['PostScript'];
    local LayURL = A['LayURL'];
    local LaySource = A['LaySource'];
    local Transcript = A['Transcript'];
    local TranscriptURL = A['TranscriptURL'] 
    local TranscriptURLorigin = A:ORIGIN('TranscriptURL');
    local sepc = A['Separator'];
    local LastAuthorAmp = A['LastAuthorAmp'];
    local no_tracking_cats = A['NoTracking'];

    local use_lowercase = ( sepc ~= '.' );
    local this_page = mw.title.getCurrentTitle();  --Also used for COinS and for language
    
    if not is_set(no_tracking_cats) then
        for k, v in pairs( cfg.uncategorized_namespaces ) do
            if this_page.nsText == v then
                no_tracking_cats = &quot;true&quot;;
                break;
            end
        end
    end

	local anchor_year;		-- used in the CITEREF identifier
	local COinS_date;		-- used in the COinS metadata

-- Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates.
-- TODO: 2013-10-27: AirDate is nil when dates() is called because it hasn't been set yet.  Move the call to dates() or set AirDate earlier.
	anchor_year, COinS_date = dates({['accessdate']=AccessDate, ['airdate']=AirDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
		['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});

	if not is_set(Year) then	-- prevent Year from being set from DateIn  TODO: eliminate the need for this?
		if is_set(anchor_year) then
			Year = anchor_year;
		end
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
    
    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if is_set(BookTitle) then
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = BookTitle;
        TitleLink = '';
        TransTitle = '';
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = A['AirDate'];
        local SeriesLink = A['SeriesLink'];
        local Season = A['Season'];
        local SeriesNumber = A['SeriesNumber'];
        local Network = A['Network'];
        local Station = A['Station'];
        local s, n = {}, {};
        local Sep = (first_set(A[&quot;SeriesSeparator&quot;], A[&quot;Separator&quot;]) or &quot;&quot;) .. &quot; &quot;;
        
        if is_set(Issue) then table.insert(s, cfg.messages[&quot;episode&quot;] .. &quot; &quot; .. Issue); Issue = ''; end
        if is_set(Season) then table.insert(s, cfg.messages[&quot;season&quot;] .. &quot; &quot; .. Season); end
        if is_set(SeriesNumber) then table.insert(s, cfg.messages[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber); end
        if is_set(Network) then table.insert(n, Network); end
        if is_set(Station) then table.insert(n, Station); end
        
        Date = Date or AirDate;
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = Series;
        TitleLink = SeriesLink;
        TransTitle = '';
        
        Series = table.concat(s, Sep);
        ID = table.concat(n, Sep);
    end
    
    -- COinS metadata (see &lt;http://ocoins.info/&gt;) for
    -- automated parsing of citation information.
    local OCinSoutput = COinS{
        ['Periodical'] = Periodical,
        ['Chapter'] = Chapter,
        ['Title'] = Title,
        ['PublicationPlace'] = PublicationPlace,
        ['Date'] = first_set(COinS_date, Date, Year, PublicationDate),
        ['Series'] = Series,
        ['Volume'] = Volume,
        ['Issue'] = Issue,
        ['Pages'] = first_set(Page, Pages, At),
        ['Edition'] = Edition,
        ['PublisherName'] = PublisherName,
        ['URL'] = first_set( URL, ChapterURL ),
        ['Authors'] = a,
        ['ID_list'] = ID_list,
        ['RawPage'] = this_page.prefixedText,
    };

    if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = '';
        TitleLink = '';
        TransTitle = '';
    end

    -- Now perform various field 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 not is_set(Authors) then
        local Maximum = tonumber( A['DisplayAuthors'] );
        
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #a == 9 then 
            Maximum = 8;
            table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
        elseif not is_set(Maximum) then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = A[&quot;AuthorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;AuthorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A[&quot;AuthorFormat&quot;],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if is_set(Coauthors) then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
            deprecated_parameter();		-- |coauthor= and |coathors= are deprecated; add this page to deprecated parameter category
        end
        
        Authors = listpeople(control, a) 
    end

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { seterror('coauthors_missing_author', {}, true) } );	-- emit error message
		deprecated_parameter();		-- |coauthor= and |coathors= are deprecated; add this page to deprecated parameter category
	end

    local EditorCount
    if not is_set(Editors) then
        local Maximum = tonumber( A['DisplayEditors'] );
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #e == 4 then 
            Maximum = 3;
            table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
        elseif not is_set(Maximum) then
            Maximum = #e + 1;
        end

        local control = { 
            sep = A[&quot;EditorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;EditorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A['EditorFormat'],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };

        Editors, EditorCount = listpeople(control, e);
    else
        EditorCount = 1;
    end

    local Cartography = &quot;&quot;;
    local Scale = &quot;&quot;;
    if config.CitationClass == &quot;map&quot; then
        if not is_set( Authors ) and is_set( PublisherName ) then
            Authors = PublisherName;
            PublisherName = &quot;&quot;;
        end
        Cartography = A['Cartography'];
        if is_set( Cartography ) then
            Cartography = sepc .. &quot; &quot; .. wrap( 'cartography', Cartography, use_lowercase );
        end        
        Scale = A['Scale'];
        if is_set( Scale ) then
            Scale = sepc .. &quot; &quot; .. Scale;
        end        
    end
    
    if not is_set(Date) then
        Date = Year;
        if is_set(Date) then
            local Month = A['Month'];
            if is_set(Month) then
            	deprecated_parameter();		-- |month= (and also |day=) is deprecated; add this page to deprecated parameter category
                Date = Month .. &quot; &quot; .. Date;
                local Day = A['Day']
                if is_set(Day) then Date = Day .. &quot; &quot; .. Date end
            end
        end
    end
    
    if inArray(PublicationDate, {Date, Year}) then PublicationDate = ''; end
    if not is_set(Date) and is_set(PublicationDate) then
        Date = PublicationDate;
        PublicationDate = '';
    end

    -- Captures the value for Date prior to adding parens or other textual transformations
    local DateIn = Date;
    
    if  not is_set(URL) and
        not is_set(ChapterURL) and
        not is_set(ArchiveURL) and
        not is_set(ConferenceURL) and
        not is_set(TranscriptURL) then
        
        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
        end
        
        -- Test if accessdate is given without giving a URL
        if is_set(AccessDate) then
            table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
            AccessDate = '';
        end
        
        -- Test if format is given without giving a URL
        if is_set(Format) then
            Format = Format .. seterror( 'format_missing_url' );
        end
    end
    
    -- Test if citation has no title
    if  not is_set(Chapter) and
        not is_set(Title) and
        not is_set(Periodical) and
        not is_set(Conference) and
        not is_set(TransTitle) and
        not is_set(TransChapter) then
        table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
    end
    
    Format = is_set(Format) and &quot; (&quot; .. Format .. &quot;)&quot; or &quot;&quot;;
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if is_set( ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
            URLorigin = A:ORIGIN('ArchiveURL')
        end
    end
    
    -- Format chapter / article title
    if is_set(Chapter) and is_set(ChapterLink) then 
        Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot;;
    end
    if is_set(Periodical) and is_set(Title) then
        Chapter = wrap( 'italic-title', Chapter );
        TransChapter = wrap( 'trans-italic-title', TransChapter );
    else
        Chapter = wrap( 'quoted-title', Chapter );
        TransChapter = wrap( 'trans-quoted-title', TransChapter );
    end
    
    local TransError = &quot;&quot;
    if is_set(TransChapter) then
        if not is_set(Chapter) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
        else
            TransChapter = &quot; &quot; .. TransChapter;
        end
    end
    
    Chapter = Chapter .. TransChapter;
    
    if is_set(Chapter) then
        if not is_set(ChapterLink) then
            if is_set(ChapterURL) then
                Chapter = externallink( ChapterURL, Chapter ) .. TransError;
                if not is_set(URL) then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif is_set(URL) then 
                Chapter = externallink( URL, Chapter ) .. TransError .. Format;
                URL = &quot;&quot;;
                Format = &quot;&quot;;
            else
                Chapter = Chapter .. TransError;
            end            
        elseif is_set(ChapterURL) then
            Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. 
                TransError;
        else
            Chapter = Chapter .. TransError;
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    elseif is_set(ChapterURL) then
        Chapter = &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. sepc .. &quot; &quot;;
    end        
    
    -- Format main title.
    if is_set(TitleLink) and is_set(Title) then
        Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
    end
    
    if is_set(Periodical) then
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    elseif inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;pressrelease&quot;,&quot;conference&quot;}) and
            not is_set(Chapter) then
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    else
        Title = wrap( 'italic-title', Title );
        TransTitle = wrap( 'trans-italic-title', TransTitle );
    end
    
    TransError = &quot;&quot;;
    if is_set(TransTitle) then
        if not is_set(Title) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
        else
            TransTitle = &quot; &quot; .. TransTitle;
        end
    end
    
    Title = Title .. TransTitle;
    
    if is_set(Title) then
        if not is_set(TitleLink) and is_set(URL) then 
            Title = externallink( URL, Title ) .. TransError .. Format       
            URL = &quot;&quot;;
            Format = &quot;&quot;;
        else
            Title = Title .. TransError;
        end
    end
    
    if is_set(Place) then
        Place = &quot; &quot; .. wrap( 'written', Place, use_lowercase ) .. sepc .. &quot; &quot;;
    end
    
    if is_set(Conference) then
        if is_set(ConferenceURL) then
            Conference = externallink( ConferenceURL, Conference );
        end
        Conference = sepc .. &quot; &quot; .. Conference
    elseif is_set(ConferenceURL) then
        Conference = sepc .. &quot; &quot; .. externallink( ConferenceURL, nil, ConferenceURLorigin );
    end
    
    if not is_set(Position) then
        local Minutes = A['Minutes'];
        if is_set(Minutes) then
            Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
        else
            local Time = A['Time'];
            if is_set(Time) then
                local TimeCaption = A['TimeCaption']
                if not is_set(TimeCaption) then
                    TimeCaption = cfg.messages['event'];
                    if sepc ~= '.' then
                        TimeCaption = TimeCaption:lower();
                    end
                end
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
            end
        end
    else
        Position = &quot; &quot; .. Position;
        At = '';
    end
    
    if not is_set(Page) then
        if is_set(Pages) then
            if is_set(Periodical) and
                not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;}) then
                Pages = &quot;: &quot; .. Pages;
            elseif tonumber(Pages) ~= nil then
                Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
            else
                Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
            end
        end
    else
        if is_set(Periodical) and
            not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;}) then
            Page = &quot;: &quot; .. Page;
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page;
        end
    end
    
    At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
    Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
    if config.CitationClass == 'map' then
        local Section = A['Section'];
        local Inset = A['Inset'];
        if first_set( Pages, Page, At ) ~= nil or sepc ~= '.' then
            if is_set( Section ) then
                Section = &quot;, &quot; .. wrap( 'section', Section, true );
            end
            if is_set( Inset ) then
                Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
            end
        else
            if is_set( Section ) then
                Section = sepc .. &quot; &quot; .. wrap( 'section', Section, use_lowercase );
                if is_set( Inset ) then
                    Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
                end
            elseif is_set( Inset ) then
                Inset = sepc .. &quot; &quot; .. wrap( 'inset', Inset, use_lowercase );
            end            
        end            
        At = At .. Section .. Inset;        
    end    

	--[[Look in the list of iso639-1 language codes to see if the value provided in the language parameter matches one of them.  If a match is found, 
	use that value; if not, then use the value that was provided with the language parameter.
	
	Categories are assigned in a manner similar to the {{xx icon}} templates - categorizes only mainspace citations and only when the language code is not 'en' (English).
	]]
	if is_set (Language) then
		local name = cfg.iso639_1[Language:lower()];		-- get the language name if Language parameter has a valid iso 639-1 code
		if nil == name then
			Language=&quot; &quot; .. wrap( 'language', Language );	-- no match, use parameter's value
		else
			if 0 == this_page.namespace and 'en' ~= Language:lower() then	--found a match; is this page main / article space and English not the language?
				Language=&quot; &quot; .. wrap( 'language', name .. '[[Category:Articles with ' .. name .. '-language external links]]' );	-- in main space and not English: categorize
			else
				Language=&quot; &quot; .. wrap( 'language', name );	--not in mainspace or language is English so don't categorize
			end
		end
	else
		Language=&quot;&quot;;	-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;

-- handle type parameter for those CS1 citations that have default values

	if &quot;pressrelease&quot; == config.CitationClass then		-- if this citation is cite press release
		if not is_set (TitleType) then
			TitleType = &quot;Press release&quot;;				-- if type not specified, display the press release annotation
		else
			if &quot;none&quot; == TitleType then TitleType = &quot;&quot;; end		-- if |type=none then type parameter not displayed
		end

	elseif &quot;techreport&quot; == config.CitationClass then	-- if this citation is cite techreport
		if not is_set (TitleType) then
			TitleType = &quot;Technical report&quot;;				-- if type not specified, display the techreport annotation
		else
			if &quot;none&quot; == TitleType then TitleType = &quot;&quot;; end		-- if |type=none then type parameter not displayed; |number=, if set, will be displayed
		end
	
	elseif &quot;thesis&quot; == config.CitationClass then		-- if this citation is cite thesis
		if not is_set (TitleType) then
			if is_set(Degree) then						-- if type not specified, display one of the thesis annotations
				TitleType = Degree .. &quot; thesis&quot;;		-- if a degree (masters, PhD, ...) is specified include it in the display
			else
				TitleType = &quot;Thesis&quot;;					-- otherwise display the simple thesis annotation
			end
		else
			if &quot;none&quot; == TitleType then TitleType = &quot;&quot;; end		-- if |type=none then type parameter not displayed
		end
	end
	if is_set(TitleType) then					-- if type parameter is specified
		TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot;;	-- display it in parentheses
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
    Edition = is_set(Edition) and (&quot; &quot; .. wrap( 'edition', Edition )) or &quot;&quot;;
    Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
    Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
    OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
    Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;
    
    if is_set(Volume) then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume;
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
        end
    end
    
    ------------------------------------ totally unrelated data
    --[[ Loosely mimic {{subscription required}} template; Via parameter identifies a delivery source that is not the publisher; these sources often, but not always, exist
    behind a registration or paywall.  So here, we've chosen to decouple via from subscription (via has never been part of the registration required template).
    
    Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link note is displayed. There are no error messages for this condition.
    ]]
    if is_set(Via) then
        Via = &quot; &quot; .. wrap( 'via', Via );
    end

	if is_set(SubscriptionRequired) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription']; --here when 'via' parameter not used but 'subscription' is
    elseif is_set(RegistrationRequired) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration']; --here when 'via' and 'subscription' parameters not used but 'registration' is
    end

    if is_set(AccessDate) then
        local retrv_text = &quot; &quot; .. cfg.messages['retrieved']
        if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
        AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
            .. substitute( retrv_text, {AccessDate} ) .. '&lt;/span&gt;'
    end
    
    if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end

    
    ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo} );

    if is_set(URL) then
        URL = &quot; &quot; .. externallink( URL, nil, URLorigin );
    end

    if is_set(Quote) then
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        Quote = sepc ..&quot; &quot; .. wrap( 'quoted-text', Quote ); 
        PostScript = &quot;&quot;;
    elseif PostScript:lower() == &quot;none&quot; then
        PostScript = &quot;&quot;;
    end
    
    local Archived
    if is_set(ArchiveURL) then
        if not is_set(ArchiveDate) then
            ArchiveDate = seterror('archive_missing_date');
        end
        if &quot;no&quot; == DeadURL then
            local arch_text = cfg.messages['archived'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
                { externallink( ArchiveURL, arch_text ), ArchiveDate } );
            if not is_set(OriginalURL) then
                Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url');                               
            end
        elseif is_set(OriginalURL) then
            local arch_text = cfg.messages['archived-dead'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text,
                { externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
        else
            local arch_text = cfg.messages['archived-missing'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
                { seterror('archive_missing_url'), ArchiveDate } );
        end
    else
        Archived = &quot;&quot;
    end
    
    local Lay
    if is_set(LayURL) then
        if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
        if is_set(LaySource) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot;;
        else
            LaySource = &quot;&quot;;
        end
        if sepc == '.' then
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;;
    end
    
    if is_set(Transcript) then
        if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
    elseif is_set(TranscriptURL) then
        Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
    end
    
    local Publisher;
    if is_set(Periodical) and
        not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;}) then
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end
        elseif is_set(PublicationPlace) then
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if is_set(PublicationDate) then
            if is_set(Publisher) then
                Publisher = Publisher .. &quot;, &quot; .. wrap( 'published', PublicationDate );
            else
                Publisher = PublicationDate;
            end
        end
        if is_set(Publisher) then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if is_set(PublicationDate) then
            PublicationDate = &quot; (&quot; .. wrap( 'published', PublicationDate ) .. &quot;)&quot;;
        end
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif is_set(PublicationPlace) then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    
    -- Several of the above rely upon detecting this as nil, so do it last.
    if is_set(Periodical) then
        if is_set(Title) or is_set(TitleNote) then 
            Periodical = sepc .. &quot; &quot; .. wrap( 'italic-title', Periodical ) 
        else 
            Periodical = wrap( 'italic-title', Periodical )
        end
    end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if inArray(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
        if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, 
            Language, Cartography, Edition, Publisher, Agency, Volume, Issue}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, Language, 
            Volume, Issue, Others, Cartography, Edition, Publisher, Agency}, sepc );
    end
    
    if #ID_list &gt; 0 then
        ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
    else
        ID_list = ID;
    end
    
    local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
    local text;
    local pgtext = Position .. Page .. Pages .. At;
    
    if is_set(Authors) then
        if is_set(Coauthors) then
            Authors = Authors .. A['AuthorSeparator'] .. &quot; &quot; .. Coauthors
        end
        if is_set(Date) then
            Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        elseif string.sub(Authors,-1,-1) == sepc then
            Authors = Authors .. &quot; &quot;
        else
            Authors = Authors .. sepc .. &quot; &quot;
        end
        if is_set(Editors) then
            local in_text = &quot; &quot;;
            local post_text = &quot;&quot;;
            if is_set(Chapter) then
                in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
            else
                if EditorCount &lt;= 1 then
                    post_text = &quot;, &quot; .. cfg.messages['editor'];
                else
                    post_text = &quot;, &quot; .. cfg.messages['editors'];
                end
            end 
            if (sepc ~= '.') then in_text = in_text:lower() end
            Editors = in_text .. Editors .. post_text;
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = Editors .. &quot; &quot;
                else Editors = Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif is_set(Editors) then
        if is_set(Date) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
            else
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if is_set(Date) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end
        if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
            text = safejoin( {Chapter, Place, tcommon}, sepc );
            text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
            text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
            text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if is_set(PostScript) and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    if not is_set(Year) then
        if is_set(DateIn) then
            Year = selectyear( DateIn );
        elseif is_set(PublicationDate) then
            Year = selectyear( PublicationDate );
        end
    end
    
    local options = {};
    
    if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
        options.class = &quot;citation &quot; .. config.CitationClass;
    else
        options.class = &quot;citation&quot;;
    end
    
    if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if #a &gt; 0 then
                for i,v in ipairs(a) do 
                    names[i] = v.last 
                    if i == 4 then break end
                end
            elseif #e &gt; 0 then
                for i,v in ipairs(e) do 
                    names[i] = v.last 
                    if i == 4 then break end                
                end
            end
			names[ #names + 1 ] = Year or anchor_year;	-- Year first for legacy citations
            id = anchorid(names)
        end
        options.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = {};
        text = seterror('empty_citation');
        z.message_tail = {};
    end
    
    if is_set(options.id) then 
        text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    else
        text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    end        

    local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        text = text .. &quot; &quot;;
        for i,v in ipairs( z.message_tail ) do
            if is_set(v[1]) then
                if i == #z.message_tail then
                    text = text .. errorcomment( v[1], v[2] );
                else
                    text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
                end
            end
        end
    end
    
    no_tracking_cats = no_tracking_cats:lower();
    if inArray(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    local suggestions = {};
    local error_text, error_state;

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        args[k] = v;       
    end    

    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            if not validate( k ) then            
                error_text = &quot;&quot;;
                if type( k ) ~= 'string' then
                    -- Exclude empty numbered parameters
                    if v:match(&quot;%S+&quot;) ~= nil then
                        error_text, error_state = seterror( 'text_ignored', {v}, true );
                    end
                elseif validate( k:lower() ) then 
                    error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
                else
                    if #suggestions == 0 then
                        suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
                    end
                    if suggestions[ k:lower() ] ~= nil then
                        error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
                    else
                        error_text, error_state = seterror( 'parameter_ignored', {k}, true );
                    end
                end                  
                if error_text ~= '' then
                    table.insert( z.message_tail, {error_text, error_state} );
                end                
            end
            args[k] = v;
        elseif args[k] ~= nil or (k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z</text>
      <sha1>rhj0prb6ftlhx3l38ww4v97cxxy26my</sha1>
    </revision>
    <revision>
      <id>4664</id>
      <parentid>4663</parentid>
      <timestamp>2013-12-14T18:30:40Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Sync from sandbox; Bug fixes; streamlined deprecated parameter detection; Year and PublicationDate promotion to Date consolidation; Change pmc/url handling; Modify parameter handling for cite encyclopedia;</comment>
      <origin>4664</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="79923" sha1="dlova0korsp17pfhg3wqi4zihqq2hd3" xml:space="preserve">--[[
History of changes since last sync 2013-11-09

2013-11-13: Fix Script Error bug that occured when |doi_brokendate= did not contain a year value;
2013-11-13: Fix doi() so that dois with invalid doi_brokendate categorize to &quot;Pages with inactive DOIs&quot; and not to &quot;Pages with DOIs inactive since&quot;;
2013-11-14: Change deprecated_parameter() to emit a single error message;
2013-11-15: Fix bug in checkisbn() that stripped-out non-isbn character before validation; declared good as long as the stripped version of the isbn passed the remaining tests;
2013-11-21: Year and PublicationDate promotion to Date consolidation;
2013-11-22: Change validate() and the whitelist to recognize deprecated parameters;
2013-11-30: Change pmc/url handling;
2013-12-05: Modify |encyclopedia, |title and |article parameter handling for cite encyclopedia;
]]

local z = {
    error_categories = {};
    error_ids = {};
    message_tail = {};
}

-- Include translation message hooks, ID and error handling configuration settings.
local cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );

-- Contains a list of all recognized parameters
local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );

-- Whether variable is set or not
function is_set( var )
    return not (var == nil or var == '');
end

-- First set variable or nil if none
function first_set(...)
    local list = {...};
    for _, var in pairs(list) do
        if is_set( var ) then
            return var;
        end
    end
end

-- Whether needle is in haystack
function inArray( needle, haystack )
    if needle == nil then
        return false;
    end
    for n,v in ipairs( haystack ) do
        if v == needle then
            return n;
        end
    end
    return false;
end

--[[
Categorize and emit an error message when the citation contains one or more deprecated parameters.  Because deprecated parameters (currently |day=, |month=,
|coauthor=, and |coauthors=) aren't related to each other and because these parameters may be concatenated into the variables used by |date= and |author#= (and aliases)
details of which parameter caused the error message are not provided.  Only one error message is emitted regarless of the number of deprecated parameters in the citation.
]]
function deprecated_parameter()
	if true ~= Page_in_deprecated_cat then	-- if we haven't been here before then set a 
		Page_in_deprecated_cat=true;		-- sticky flag so that if there are more than one deprecated parameter the category is added only once
		table.insert( z.message_tail, { seterror( 'deprecated_params', {error_message}, true ) } );		-- add error message
	end
end

-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
    return args and tostring( mw.message.newRawMessage( msg, args ) ) or msg;
end

-- Wraps a string using a message_list configuration taking one argument
function wrap( key, str, lower )
    if not is_set( str ) then
        return &quot;&quot;;
    elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
        str = safeforitalics( str );
    end
    if lower == true then
        return substitute( cfg.messages[key]:lower(), {str} );
    else
        return substitute( cfg.messages[key], {str} );
    end        
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
    local origin = {};
    
    return setmetatable({
        ORIGIN = function( self, k )
            local dummy = self[k]; --force the variable to be loaded.
            return origin[k];
        end
    },
    {
        __index = function ( tbl, k )
            if origin[k] ~= nil then
                return nil;
            end
            
            local args, list, v = args, cfg.aliases[k];
            
            if type( list ) == 'table' then
                v, origin[k] = selectone( args, list, 'redundant_parameters' );
                if origin[k] == nil then
                    origin[k] = ''; -- Empty string, not nil
                end
            elseif list ~= nil then
                v, origin[k] = args[list], list;
            else
                -- maybe let through instead of raising an error?
                -- v, origin[k] = args[k], k;
                error( cfg.messages['unknown_argument_map'] );
            end
            
            -- Empty strings, not nil;
            if v == nil then
                v = cfg.defaults[k] or '';
                origin[k] = '';
            end
            
            tbl = rawset( tbl, k, v );
            return v;
        end,
    });
end

--[[
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three valuse:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
]]
function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
    return wrap( hidden and 'hidden-error' or 'visible-error', content );
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
    local error_state = cfg.error_conditions[ error_id ];
    
    prefix = prefix or &quot;&quot;;
    suffix = suffix or &quot;&quot;;
    
    if error_state == nil then
        error( cfg.messages['undefined_error'] );
    elseif is_set( error_state.category ) then
        table.insert( z.error_categories, error_state.category );
    end
    
    local message = substitute( error_state.message, arguments );
    
    message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
        &quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
        cfg.messages['help page label'] .. &quot;]])&quot;;
    
    z.error_ids[ error_id ] = true;
    if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
            and z.error_ids['citation_missing_title'] then
        return '', false;
    end
    
    message = table.concat({ prefix, message, suffix });
    
    if raw == true then
        return message, error_state.hidden;
    end        
        
    return errorcomment( message, error_state.hidden );
end

-- Formats a wiki style external link
function externallinkid(options)
    local url_string = options.id;
    if options.encode == true or options.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, url_string, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Formats a wiki style internal link
function internallinkid(options)
    return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, options.id, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Format an external link with error checking
function externallink( URL, label, source )
    local error_str = &quot;&quot;;
    if not is_set( label ) then
        label = URL;
        if is_set( source ) then
            error_str = seterror( 'bare_url_missing_title', { wrap( 'parameter', source ) }, false, &quot; &quot; );
        else
            error( cfg.messages[&quot;bare_url_no_origin&quot;] );
        end            
    end
    if not checkurl( URL ) then
        error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
    end
    return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safeforurl( label ), &quot;]&quot;, error_str });
end

-- Formats a link to Amazon
function amazon(id, domain)
    if not is_set(domain) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local handler = cfg.id_handlers['ASIN'];
    return externallinkid({link = handler.link,
        label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
        encode=handler.encode, separator = handler.separator})
end

--[[
Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns true; otherwse, returns false because the embargo has expired or |embargo= not set in this cite.
]]
function is_embargoed(embargo)
	if is_set(embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 and tonumber( embargo_date ) &gt;= tonumber( todays_date ) then	--is embargo date is in the future?
			return true;	-- still embargoed
		end
	end
	return false;			-- embargo expired or |embargo= not set
end

--[[
Formats a PMC and checks for embargoed articles.  The embargo parameter takes a date for a value. If the embargo date is in the future
the PMC identifier will not be linked to the article.  If the embargo specifies a date in the past, or if it is empty or omitted, then
the PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.
]]
function pmc(id, embargo)
	local handler = cfg.id_handlers['PMC'];
    
	local text;

	if is_embargoed(embargo) then
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id;	--still embargoed so no external link
	else
		text = externallinkid({link = handler.link, label = handler.label,			--no embargo date, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    local handler = cfg.id_handlers['DOI'];
    
    local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end
	if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then      
		cat = seterror( 'bad_doi' );
	end
	return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    local handler = cfg.id_handlers['OL'];
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    else
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode}) .. 
            ' ' .. seterror( 'bad_ol' );
    end
end

--[[
Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.
]]
function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and ndashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 didgits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = externallinkid({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. seterror( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[
This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those citations that have defaults.
Also handles the special case where it is desireable to omit the title type from the rendered citation (|type=none).
]]
function set_titletype(cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;					-- if |type=none then type parameter not displayed
		end
		return title_type;						-- if |type= has been set to any other value use that value
	end

	if &quot;pressrelease&quot; == cite_class then		-- if this citation is cite press release
		return &quot;Press release&quot;;					-- display press release annotation

	elseif &quot;speech&quot; == cite_class then			-- if this citation is cite speech
		return &quot;Speech&quot;;						-- display speech annotation
	
	elseif &quot;techreport&quot; == cite_class then		-- if this citation is cite techreport
		return &quot;Technical report&quot;;				-- display techreport annotation
	
	elseif &quot;thesis&quot; == cite_class then			-- if this citation is cite thesis (degree option handled after this function returns)
			return &quot;Thesis&quot;;					-- display simple thesis annotation (without |degree= modification)
	end
end

-- returns a number according to the month in a date: 1 for January, etc.  If not a valid month, returns 0
function get_month_number (month)
local long_months = {['january']=1, ['february']=2, ['march']=3, ['april']=4, ['may']=5, ['june']=6, ['july']=7, ['august']=8, ['september']=9, ['october']=10, ['november']=11, ['december']=12};
local short_months = {['jan']=1, ['feb']=2, ['mar']=3, ['apr']=4, ['may']=5, ['jun']=6, ['jul']=7, ['aug']=8, ['sep']=9, ['oct']=10, ['nov']=11, ['dec']=12};
local temp;
	temp=long_months[month:lower()];
	if temp then return temp; end				-- if month is the long-form name
	temp=short_months[month:lower()];
	if temp then return temp; end				-- if month is the short-form name
	return 0;									-- misspelled or not a month name
end

-- returns true if date has one of the five seasons.  Else false.
function is_valid_season (season)
	if inArray( season, {'winter', 'spring', 'summer', 'fall', 'autumn'} ) then
		return true;
	end
	return false;
end

--[[
Returns true if day is less than or equal to the number of days in month; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap years before 1582 and Gregorian leap years after 1582.
Where the two calendars overlap (1582 to approximately 1923) dates are assumed to be Gregorian.
]]
function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if (2==month) then							-- if February
		month_length = 28;						-- then 28 days unless
		if 1582 &gt; tonumber(year) then			-- Julian calendar
			if 0==(year%4) then
				month_length = 29;
			end
		else									-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then	-- is a leap year?
				month_length = 29;				-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end

--Check a pair of months or seasons to see if both are valid members of a month or season pair.
--TODO: Check order to make sure that the left month/season properly precedes the right month/season

function is_valid_month_season_range(range_start, range_end)
	if 0 == get_month_number (range_start:lower()) then			-- is this a month range?
		if true == is_valid_season (range_start:lower()) then	-- not a month range, is this a season range?
			return is_valid_season (range_end:lower());			-- range_start is season; return true if range_end also a season; else false
		end
		return false;		-- range_start is not a month or a season
	end
	if 0 == get_month_number (range_end:lower()) then			-- range_start is a month; is range_end also a  month?
		return false;											-- not a month range
	end
	return true;
end

--[[
Check date format to see that it is one of the formats approved by MOS:DATE: MMMM D, YYYY; D MMMM YYYY; MMMM YYYY; YYYY-MM-DD; YYYY.
Additionally, check the date to see that it is a real date: no 31 in 30-day months; no 29 February when not a leap year.  Months, both long-form and three
character abbreviations, and seasons must be spelled correctly.

If the date fails the fomat tests, this function returns false but does not return values for anchor_year and COinS_date.  When this happens, the date parameter is
used in the COinS metadata and the CITEREF identifier gets its year from the year parameter if present.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is date_string without anchor_year disambiguator if any
]]
function check_date (date_string)
	local year;
	local month;
	local day;
	local anchor_year;
	local coins_date;

	if date_string:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then			-- Year-initial numerical year month day format
		coins_date = date_string:match(&quot;%d%d%d%d%-%d%d%-%d%d&quot;);
		year, month, day=string.match(date_string, &quot;(%d%d%d%d)%-(%d%d)%-(%d%d)&quot;);
		anchor_year = year;
		month=tonumber(month);
		if 12 &lt; month or 1 &gt; month then return false; end

	elseif date_string:match(&quot;^%a+%s*%d%d*%s*,%s*%d%d%d%d%a?$&quot;) then	-- month-initial: month day, year
		coins_date = date_string:match(&quot;%a+%s*%d%d*%s*,%s*%d%d%d%d&quot;);
		month, day, anchor_year, year=string.match(date_string, &quot;(%a+)%s*(%d%d*)%s*,%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month:lower());
		if 0 == month then return false; end					-- return false if month text isn't one of the twelve months
				
	elseif date_string:match(&quot;^%d%d*%s*%a+%s*%d%d%d%d%a?$&quot;) then		-- date-initial: day month year
		coins_date = date_string:match(&quot;%d%d*%s*%a+%s*%d%d%d%d&quot;);
		day, month, anchor_year, year=string.match(date_string, &quot;(%d%d*)%s*(%a+)%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month:lower());
		if 0 == month then return false; end					-- return false if month text isn't one of the twelve months

	elseif mw.ustring.match (date_string, &quot;^%a+%s*[%s%-/–]%s*%a+%s*%d%d%d%d%a?$&quot;) then		-- month/season range year
		local month2
		coins_date = mw.ustring.match (date_string, &quot;%a+%s*[%s%-/–]%s*%a+%s*%d%d%d%d&quot;);
		coins_date= mw.ustring.gsub( coins_date, &quot;–&quot;, &quot;-&quot; );	-- replace ndash with hyphen
		month, month2, anchor_year, year=mw.ustring.match (date_string, &quot;(%a+)%s*[%s%-/–]%s*(%a+)%s*((%d%d%d%d)%a?)&quot;);
		day=0;													-- mark day as not used
		if false == is_valid_month_season_range(month, month2) then
			return false;
		end
		
	elseif date_string:match(&quot;^%a+%s*%d%d%d%d%a?$&quot;) then		-- month/season year
		coins_date = date_string:match(&quot;%a+%s*%d%d%d%d&quot;);
		month, anchor_year, year=string.match(date_string, &quot;(%a+)%s*((%d%d%d%d)%a?)&quot;);
		day=0;													-- mark day as not used
		local season=month;										-- copy 
		month = get_month_number (month:lower());
		if month == 0 then										-- if month text isn't one of the twelve months, might be a season
			if false == is_valid_season (season:lower()) then
				return false;									-- return false not a month or one of the five seasons
			end
		end

	elseif date_string:match(&quot;^%d%d%d%d?%a?$&quot;) then			-- year; here accept either YYY or YYYY
		coins_date = date_string:match(&quot;^%d%d%d%d?&quot;);
		anchor_year, year=string.match(date_string, &quot;((%d%d%d%d?)%a?)&quot;);
		month, day = 0, 0;										-- mark day and month as not used
	else
		return false;											-- date format not one of the MOS:DATE approved formats
	end

	if 0~=month and 0~=day then									-- check year month day dates for validity
		if false==is_valid_date(year,month,day) then
			return false;										-- date string is not a real date return false; unset anchor_year and coins_date
		end
	end
	
	return true, anchor_year, coins_date;						-- format is good and date string represents a real date
end	

--[[
Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true and values for anchor_year (used in CITEREF identifiers) and COinS_date (used in the COinS metadata).  The |date= parameter test is unique.  This function only 
accepts anchor_year and COinS_date results from the |date= parameter test and |date= is the only date-holding parameter that is allowed to contain the no-date keywords
&quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.
]]

function dates(date_parameters_list)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local error_message =&quot;&quot;;
	local good_date=false;
	
	for k, v in pairs(date_parameters_list) do		-- for each date-holding parameter in the list
		if is_set(v) then							-- if the parameter has a value
			if v:match(&quot;^c%.%s%d%d%d%d?%a?$&quot;) then	-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				if 'date'==k then
					good_date, anchor_year, COinS_date = true, v:match(&quot;((c%.%s%d%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
				elseif 'year'==k then
					good_date =  true;
				end
			elseif 'year'==k then					-- if the parameter is |year= (but not c. year)
				if v:match(&quot;^%d%d%d%d?%a?$&quot;) then	-- year with or without CITEREF disambiguator
					good_date =  true;
				end
			elseif 'date'==k then					-- if the parameter is |date=
				if v:match(&quot;n%.d%.%a?&quot;) then		-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v:match(&quot;nd%a?$&quot;) then		-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v);	-- go test the date
				end
			else									-- any other date-holding parameter
				good_date = check_date (v);			-- go test the date
			end
			if false==good_date then				-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then		-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;	-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;	-- add the failed parameter
			end
		end
	end
	if is_set(error_message) then
		table.insert( z.message_tail, { seterror( 'bad_date', {error_message}, true ) } );	-- add this error message
	end

	return anchor_year, COinS_date;		-- and done
end

--[[
Determines whether a URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
    -- Protocol-relative or URL scheme
    return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
    return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

--[[
ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in checkisbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.
]]
function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of bytes
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end	-- isbn13 begins with 978 or 979
		isbn_str = { isbn_str:byte(1, len) };
		for i, v in ipairs( isbn_str ) do
			temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
		end
		return temp % 10 == 0;
	end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
    return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
        return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
    end));
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if not is_set(str) then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        
        -- Remove newlines as they break italics.
        return str:gsub( '\n', ' ' );
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    if maximum ~= nil and maximum &lt; 1 then return &quot;&quot;, 0; end
    
    for i,person in ipairs(people) do
        if is_set(person.last) then
            local mask = person.mask
            local one
            local sep_one = sep;
            if maximum ~= nil and i &gt; maximum then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask;
                    sep_one = &quot; &quot;;
                end
            else
                one = person.last
                local first = person.first
                if is_set(first) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if is_set(person.link) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert( text, one )
            table.insert( text, sep_one )
        end
    end

    local count = #text / 2;
    if count &gt; 0 then 
        if count &gt; 1 and is_set(lastauthoramp) and not etal then
            text[#text-2] = &quot; &amp; &quot;;
        end
        text[#text] = nil; 
    end
    
    local result = table.concat(text) -- construct list
    if etal then 
        local etal_text = cfg.messages['et al'];
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result = 
        '&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
    end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
    return &quot;CITEREF&quot; .. table.concat( options );
end

-- Gets name list from the input arguments
function extractnames(args, list_name)
    local names = {};
    local i = 1;
    local last;
    
    while true do
        last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );
        if not is_set(last) then
            -- just in case someone passed in an empty parameter
            break;
        end
        names[i] = {
            last = last,
            first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i ),
            link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ),
            mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i )
        };
        i = i + 1;
    end
    return names;
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
    local id_list = {};
    for k, v in pairs( cfg.id_handlers ) do    
        v = selectone( args, v.parameters, 'redundant_parameters' );
        if is_set(v) then id_list[k] = v; end
    end
    return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
    local new_list, handler = {};
    
    function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
    
    for k, v in pairs( id_list ) do
        -- fallback to read-only cfg
        handler = setmetatable( { ['id'] = v }, fallback(k) );
        
        if handler.mode == 'external' then
            table.insert( new_list, {handler.label, externallinkid( handler ) } );
        elseif handler.mode == 'internal' then
            table.insert( new_list, {handler.label, internallinkid( handler ) } );
        elseif handler.mode ~= 'manual' then
            error( cfg.messages['unknown_ID_mode'] );
        elseif k == 'DOI' then
            table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
        elseif k == 'ASIN' then
            table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
        elseif k == 'OL' then
            table.insert( new_list, {handler.label, openlibrary( v ) } );
        elseif k == 'PMC' then
            table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
        elseif k == 'ISSN' then
        	table.insert( new_list, {handler.label, issn( v ) } );
        elseif k == 'ISBN' then
            local ISBN = internallinkid( handler );
            if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
                ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
            end
            table.insert( new_list, {handler.label, ISBN } );                
        else
            error( cfg.messages['unknown_manual_ID'] );
        end
    end
    
    function comp( a, b )	-- used in following table.sort()
        return a[1] &lt; b[1];
    end
    
    table.sort( new_list, comp );
    for k, v in ipairs( new_list ) do
        new_list[k] = v[2];
    end
    
    return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
    local value = nil;
    local selected = '';
    local error_list = {};
    
    if index ~= nil then index = tostring(index); end
    
    -- Handle special case of &quot;#&quot; replaced by empty string
    if index == '1' then
        for _, v in ipairs( possible ) do
            v = v:gsub( &quot;#&quot;, &quot;&quot; );
            if is_set(args[v]) then
                if value ~= nil and selected ~= v then
                    table.insert( error_list, v );
                else
                    value = args[v];
                    selected = v;
                end
            end
        end        
    end
    
    for _, v in ipairs( possible ) do
        if index ~= nil then
            v = v:gsub( &quot;#&quot;, index );
        end
        if is_set(args[v]) then
            if value ~= nil and selected ~=  v then
                table.insert( error_list, v );
            else
                value = args[v];
                selected = v;
            end
        end
    end
    
    if #error_list &gt; 0 then
        local error_str = &quot;&quot;;
        for _, k in ipairs( error_list ) do
            if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
            error_str = error_str .. wrap( 'parameter', k );
        end
        if #error_list &gt; 1 then
            error_str = error_str .. cfg.messages['parameter-final-separator'];
        else
            error_str = error_str .. cfg.messages['parameter-pair-separator'];
        end
        error_str = error_str .. wrap( 'parameter', selected );
        table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
    end
    
    return value, selected;
end

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
function COinS(data)
    if 'table' ~= type(data) or nil == next(data) then
        return '';
    end
    
    local ctx_ver = &quot;Z39.88-2004&quot;;
    
    -- treat table strictly as an array with only set values.
    local OCinSoutput = setmetatable( {}, {
        __newindex = function(self, key, value)
            if is_set(value) then
                rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
            end
        end
    });
    
    if is_set(data.Chapter) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Chapter;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    elseif is_set(data.Periodical) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
        OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    else
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
    end
    
    OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
    OCinSoutput[&quot;rft.date&quot;] = data.Date;
    OCinSoutput[&quot;rft.series&quot;] = data.Series;
    OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
    OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
    OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
    OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
    OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
    
    for k, v in pairs( data.ID_list ) do
        local id, value = cfg.id_handlers[k].COinS;
        if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
        if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
            OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
        else
            OCinSoutput[ id ] = value;
        end
    end
    
    local last, first;
    for k, v in ipairs( data.Authors ) do
        last, first = v.last, v.first;
        if k == 1 then
            if is_set(last) then
                OCinSoutput[&quot;rft.aulast&quot;] = last;
            end
            if is_set(first) then 
                OCinSoutput[&quot;rft.aufirst&quot;] = first;
            end
        end
        if is_set(last) and is_set(first) then
            OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
        elseif is_set(last) then
            OCinSoutput[&quot;rft.au&quot;] = last;
        end
    end
    
    OCinSoutput.rft_id = data.URL;
    OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
    OCinSoutput = setmetatable( OCinSoutput, nil );
    
    -- sort with version string always first, and combine.
    table.sort( OCinSoutput );
    table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
    return table.concat(OCinSoutput, &quot;&amp;&quot;);
end

--[[
This is the main function doing the majority of the citation
formatting.
]]
function citation0( config, args)
    --[[ 
    Load Input Parameters
    The argment_wrapper facillitates the mapping of multiple
    aliases to single internal variable.
    ]]
    local A = argument_wrapper( args );

    local i 
    local PPrefix = A['PPrefix']
    local PPPrefix = A['PPPrefix']
    if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = A['Authors'];
    local a = extractnames( args, 'AuthorList' );

    local Coauthors = A['Coauthors'];
    local Others = A['Others'];
    local Editors = A['Editors'];
    local e = extractnames( args, 'EditorList' );

    local Year = A['Year'];
    local PublicationDate = A['PublicationDate'];
    local OrigYear = A['OrigYear'];
    local Date = A['Date'];
    local LayDate = A['LayDate'];
    ------------------------------------------------- Get title data
    local Title = A['Title'];
    local BookTitle = A['BookTitle'];
    local Conference = A['Conference'];
    local TransTitle = A['TransTitle'];
    local TitleNote = A['TitleNote'];
    local TitleLink = A['TitleLink'];
    local Chapter = A['Chapter'];
    local ChapterLink = A['ChapterLink'];
    local TransChapter = A['TransChapter'];
    local TitleType = A['TitleType'];
    local Degree = A['Degree'];
    local Docket = A['Docket'];
    local ArchiveURL = A['ArchiveURL'];
    local URL = A['URL']
    local URLorigin = A:ORIGIN('URL');
    local ChapterURL = A['ChapterURL'];
    local ChapterURLorigin = A:ORIGIN('ChapterURL');
    local ConferenceURL = A['ConferenceURL'];
    local ConferenceURLorigin = A:ORIGIN('ConferenceURL');
    local Periodical = A['Periodical'];

--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped

All other combinations of |encyclopedia, |title, and |article are not modified
]]
	if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
		if is_set(Periodical) then					-- Periodical is set when |encyclopedia is set
			if is_set(Title) then
				if not is_set(Chapter) then
					Chapter = Title;				-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					TransChapter = TransTitle;
					Title = Periodical;
					Periodical = '';				-- redundant so unset
					TransTitle = '';				-- redundant so unset
				end
			else									-- |title not set
				Title = Periodical;					-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';					-- redundant so unset
			end
		end
	end

local Series = A['Series'];
    local Volume = A['Volume'];
    local Issue = A['Issue'];
    local Position = '';
    local Page, Pages, At, page_type;
    
    Page = A['Page'];
    Pages = hyphentodash( A['Pages'] );
    At = A['At'];
    
    if is_set(Page) then
        if is_set(Pages) or is_set(At) then
            Page = Page .. &quot; &quot; .. seterror('extra_pages');
            Pages = '';
            At = '';
        end
    elseif is_set(Pages) then
        if is_set(At) then
            Pages = Pages .. &quot; &quot; .. seterror('extra_pages');
            At = '';
        end
    end    
    
    local Edition = A['Edition'];
    local PublicationPlace = A['PublicationPlace']
    local Place = A['Place'];
    
    if not is_set(PublicationPlace) and is_set(Place) then
        PublicationPlace = Place;
    end
    
    if PublicationPlace == Place then Place = ''; end
    
    local PublisherName = A['PublisherName'];
    local RegistrationRequired = A['RegistrationRequired'];
    local SubscriptionRequired = A['SubscriptionRequired'];
    local Via = A['Via'];
    local AccessDate = A['AccessDate'];
    local ArchiveDate = A['ArchiveDate'];
    local Agency = A['Agency'];
    local DeadURL = A['DeadURL']
    local Language = A['Language'];
    local Format = A['Format'];
    local Ref = A['Ref'];
    
    local DoiBroken = A['DoiBroken'];
	
-- Special case for cite techreport.
	local ID = A['ID'];
	if (config.CitationClass == &quot;techreport&quot;) then	-- special case for cite techreport
		if is_set(Issue) then						-- cite techreport uses 'number', which other citations aliase to 'issue'
			if not is_set(ID) then					-- can we use ID for the &quot;number&quot;?
				ID = Issue;							-- yes, use it
				Issue = &quot;&quot;;							-- unset Issue so that &quot;number&quot; isn't duplicated in the rendered citation or COinS metadata
			else									-- can't use ID so emit error message
				ID = ID .. &quot; &quot; .. seterror('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
			end
		end	
	end	
			
    local ASINTLD = A['ASINTLD'];
    local IgnoreISBN = A['IgnoreISBN'];
    local Embargo = A['Embargo'];

    local ID_list = extractids( args );
    
    local Quote = A['Quote'];
    local PostScript = A['PostScript'];
    local LayURL = A['LayURL'];
    local LaySource = A['LaySource'];
    local Transcript = A['Transcript'];
    local TranscriptURL = A['TranscriptURL'] 
    local TranscriptURLorigin = A:ORIGIN('TranscriptURL');
    local sepc = A['Separator'];
    local LastAuthorAmp = A['LastAuthorAmp'];
    local no_tracking_cats = A['NoTracking'];

    local use_lowercase = ( sepc ~= '.' );
    local this_page = mw.title.getCurrentTitle();  --Also used for COinS and for language
    
    if not is_set(no_tracking_cats) then
        for k, v in pairs( cfg.uncategorized_namespaces ) do
            if this_page.nsText == v then
                no_tracking_cats = &quot;true&quot;;
                break;
            end
        end
    end

	local anchor_year;		-- used in the CITEREF identifier
	local COinS_date;		-- used in the COinS metadata

-- legacy: promote concatenation of |day=, |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set(Date) then
		Date = Year;						-- promote Year to Date
		Year = nil;							-- make nil so Year as empty string isn't used for CITEREF
		if is_set(Date) then
			local Month = A['Month'];
			if is_set(Month) then
				Date = Month .. &quot; &quot; .. Date;
				local Day = A['Day']
				if is_set(Day) then Date = Day .. &quot; &quot; .. Date end
			end
		elseif is_set(PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;			-- promonte PublicationDate to Date
			PublicationDate = '';			-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end	-- if PublicationDate is same as Date, don't display in rendered citation

-- Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates.
-- TODO: 2013-10-27: AirDate is nil when dates() is called because it hasn't been set yet.  Move the call to dates() or set AirDate earlier.
	anchor_year, COinS_date = dates({['accessdate']=AccessDate, ['airdate']=AirDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
		['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.

	--Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set
	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_embargoed(Embargo) then
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];	-- set url to be the same as the PMC external link if not embargoed
		end
	end

    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if is_set(BookTitle) then
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = BookTitle;
        TitleLink = '';
        TransTitle = '';
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = A['AirDate'];
        local SeriesLink = A['SeriesLink'];
        local Season = A['Season'];
        local SeriesNumber = A['SeriesNumber'];
        local Network = A['Network'];
        local Station = A['Station'];
        local s, n = {}, {};
        local Sep = (first_set(A[&quot;SeriesSeparator&quot;], A[&quot;Separator&quot;]) or &quot;&quot;) .. &quot; &quot;;
        
        if is_set(Issue) then table.insert(s, cfg.messages[&quot;episode&quot;] .. &quot; &quot; .. Issue); Issue = ''; end
        if is_set(Season) then table.insert(s, cfg.messages[&quot;season&quot;] .. &quot; &quot; .. Season); end
        if is_set(SeriesNumber) then table.insert(s, cfg.messages[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber); end
        if is_set(Network) then table.insert(n, Network); end
        if is_set(Station) then table.insert(n, Station); end
        
        Date = Date or AirDate;
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = Series;
        TitleLink = SeriesLink;
        TransTitle = '';
        
        Series = table.concat(s, Sep);
        ID = table.concat(n, Sep);
    end
    
    -- COinS metadata (see &lt;http://ocoins.info/&gt;) for
    -- automated parsing of citation information.
    local OCinSoutput = COinS{
        ['Periodical'] = Periodical,
        ['Chapter'] = Chapter,
        ['Title'] = Title,
        ['PublicationPlace'] = PublicationPlace,
        ['Date'] = first_set(COinS_date, Date),		-- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here?  Should we be including invalid dates in metadata?
        ['Series'] = Series,
        ['Volume'] = Volume,
        ['Issue'] = Issue,
        ['Pages'] = first_set(Page, Pages, At),
        ['Edition'] = Edition,
        ['PublisherName'] = PublisherName,
        ['URL'] = first_set( URL, ChapterURL ),
        ['Authors'] = a,
        ['ID_list'] = ID_list,
        ['RawPage'] = this_page.prefixedText,
    };

    if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = '';
        TitleLink = '';
        TransTitle = '';
    end

    -- Now perform various field 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 not is_set(Authors) then
        local Maximum = tonumber( A['DisplayAuthors'] );
        
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #a == 9 then 
            Maximum = 8;
            table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
        elseif not is_set(Maximum) then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = A[&quot;AuthorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;AuthorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A[&quot;AuthorFormat&quot;],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if is_set(Coauthors) then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
        
        Authors = listpeople(control, a) 
    end

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { seterror('coauthors_missing_author', {}, true) } );	-- emit error message
	end

    local EditorCount
    if not is_set(Editors) then
        local Maximum = tonumber( A['DisplayEditors'] );
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #e == 4 then 
            Maximum = 3;
            table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
        elseif not is_set(Maximum) then
            Maximum = #e + 1;
        end

        local control = { 
            sep = A[&quot;EditorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;EditorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A['EditorFormat'],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };

        Editors, EditorCount = listpeople(control, e);
    else
        EditorCount = 1;
    end

    local Cartography = &quot;&quot;;
    local Scale = &quot;&quot;;
    if config.CitationClass == &quot;map&quot; then
        if not is_set( Authors ) and is_set( PublisherName ) then
            Authors = PublisherName;
            PublisherName = &quot;&quot;;
        end
        Cartography = A['Cartography'];
        if is_set( Cartography ) then
            Cartography = sepc .. &quot; &quot; .. wrap( 'cartography', Cartography, use_lowercase );
        end        
        Scale = A['Scale'];
        if is_set( Scale ) then
            Scale = sepc .. &quot; &quot; .. Scale;
        end        
    end
    
    if  not is_set(URL) and
        not is_set(ChapterURL) and
        not is_set(ArchiveURL) and
        not is_set(ConferenceURL) and
        not is_set(TranscriptURL) then
        
        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
        end
        
        -- Test if accessdate is given without giving a URL
        if is_set(AccessDate) then
            table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
            AccessDate = '';
        end
        
        -- Test if format is given without giving a URL
        if is_set(Format) then
            Format = Format .. seterror( 'format_missing_url' );
        end
    end
    
    -- Test if citation has no title
    if  not is_set(Chapter) and
        not is_set(Title) and
        not is_set(Periodical) and
        not is_set(Conference) and
        not is_set(TransTitle) and
        not is_set(TransChapter) then
        table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
    end
    
    Format = is_set(Format) and &quot; (&quot; .. Format .. &quot;)&quot; or &quot;&quot;;
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if is_set( ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
            URLorigin = A:ORIGIN('ArchiveURL')
        end
    end
    
    -- Format chapter / article title
    if is_set(Chapter) and is_set(ChapterLink) then 
        Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot;;
    end
    if is_set(Periodical) and is_set(Title) then
        Chapter = wrap( 'italic-title', Chapter );
        TransChapter = wrap( 'trans-italic-title', TransChapter );
    else
        Chapter = wrap( 'quoted-title', Chapter );
        TransChapter = wrap( 'trans-quoted-title', TransChapter );
    end
    
    local TransError = &quot;&quot;
    if is_set(TransChapter) then
        if not is_set(Chapter) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
        else
            TransChapter = &quot; &quot; .. TransChapter;
        end
    end
    
    Chapter = Chapter .. TransChapter;
    
    if is_set(Chapter) then
        if not is_set(ChapterLink) then
            if is_set(ChapterURL) then
                Chapter = externallink( ChapterURL, Chapter ) .. TransError;
                if not is_set(URL) then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif is_set(URL) then 
                Chapter = externallink( URL, Chapter ) .. TransError .. Format;
                URL = &quot;&quot;;
                Format = &quot;&quot;;
            else
                Chapter = Chapter .. TransError;
            end            
        elseif is_set(ChapterURL) then
            Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. 
                TransError;
        else
            Chapter = Chapter .. TransError;
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    elseif is_set(ChapterURL) then
        Chapter = &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. sepc .. &quot; &quot;;
    end        
    
    -- Format main title.
    if is_set(TitleLink) and is_set(Title) then
        Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
    end
    
    if is_set(Periodical) then
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    elseif inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;pressrelease&quot;,&quot;conference&quot;}) and
            not is_set(Chapter) then
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    else
        Title = wrap( 'italic-title', Title );
        TransTitle = wrap( 'trans-italic-title', TransTitle );
    end
    
    TransError = &quot;&quot;;
    if is_set(TransTitle) then
        if not is_set(Title) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
        else
            TransTitle = &quot; &quot; .. TransTitle;
        end
    end
    
    Title = Title .. TransTitle;
    
    if is_set(Title) then
        if not is_set(TitleLink) and is_set(URL) then 
            Title = externallink( URL, Title ) .. TransError .. Format       
            URL = &quot;&quot;;
            Format = &quot;&quot;;
        else
            Title = Title .. TransError;
        end
    end
    
    if is_set(Place) then
        Place = &quot; &quot; .. wrap( 'written', Place, use_lowercase ) .. sepc .. &quot; &quot;;
    end
    
    if is_set(Conference) then
        if is_set(ConferenceURL) then
            Conference = externallink( ConferenceURL, Conference );
        end
        Conference = sepc .. &quot; &quot; .. Conference
    elseif is_set(ConferenceURL) then
        Conference = sepc .. &quot; &quot; .. externallink( ConferenceURL, nil, ConferenceURLorigin );
    end
    
    if not is_set(Position) then
        local Minutes = A['Minutes'];
        if is_set(Minutes) then
            Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
        else
            local Time = A['Time'];
            if is_set(Time) then
                local TimeCaption = A['TimeCaption']
                if not is_set(TimeCaption) then
                    TimeCaption = cfg.messages['event'];
                    if sepc ~= '.' then
                        TimeCaption = TimeCaption:lower();
                    end
                end
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
            end
        end
    else
        Position = &quot; &quot; .. Position;
        At = '';
    end
    
    if not is_set(Page) then
        if is_set(Pages) then
            if is_set(Periodical) and
                not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;}) then
                Pages = &quot;: &quot; .. Pages;
            elseif tonumber(Pages) ~= nil then
                Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
            else
                Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
            end
        end
    else
        if is_set(Periodical) and
            not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;}) then
            Page = &quot;: &quot; .. Page;
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page;
        end
    end
    
    At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
    Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
    if config.CitationClass == 'map' then
        local Section = A['Section'];
        local Inset = A['Inset'];
        if first_set( Pages, Page, At ) ~= nil or sepc ~= '.' then
            if is_set( Section ) then
                Section = &quot;, &quot; .. wrap( 'section', Section, true );
            end
            if is_set( Inset ) then
                Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
            end
        else
            if is_set( Section ) then
                Section = sepc .. &quot; &quot; .. wrap( 'section', Section, use_lowercase );
                if is_set( Inset ) then
                    Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
                end
            elseif is_set( Inset ) then
                Inset = sepc .. &quot; &quot; .. wrap( 'inset', Inset, use_lowercase );
            end            
        end            
        At = At .. Section .. Inset;        
    end    

	--[[Look in the list of iso639-1 language codes to see if the value provided in the language parameter matches one of them.  If a match is found, 
	use that value; if not, then use the value that was provided with the language parameter.
	
	Categories are assigned in a manner similar to the {{xx icon}} templates - categorizes only mainspace citations and only when the language code is not 'en' (English).
	]]
	if is_set (Language) then
		local name = cfg.iso639_1[Language:lower()];		-- get the language name if Language parameter has a valid iso 639-1 code
		if nil == name then
			Language=&quot; &quot; .. wrap( 'language', Language );	-- no match, use parameter's value
		else
			if 0 == this_page.namespace and 'en' ~= Language:lower() then	--found a match; is this page main / article space and English not the language?
				Language=&quot; &quot; .. wrap( 'language', name .. '[[Category:Articles with ' .. name .. '-language external links]]' );	-- in main space and not English: categorize
			else
				Language=&quot; &quot; .. wrap( 'language', name );	--not in mainspace or language is English so don't categorize
			end
		end
	else
		Language=&quot;&quot;;	-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;

-- handle type parameter for those CS1 citations that have default values

	if inArray(config.CitationClass, {&quot;pressrelease&quot;,&quot;techreport&quot;,&quot;thesis&quot;, &quot;speech&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then	-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then					-- if type parameter is specified
		TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot;;	-- display it in parentheses
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
    Edition = is_set(Edition) and (&quot; &quot; .. wrap( 'edition', Edition )) or &quot;&quot;;
    Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
    Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
    OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
    Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;
    
    if is_set(Volume) then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume;
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
        end
    end
    
    ------------------------------------ totally unrelated data
    --[[ Loosely mimic {{subscription required}} template; Via parameter identifies a delivery source that is not the publisher; these sources often, but not always, exist
    behind a registration or paywall.  So here, we've chosen to decouple via from subscription (via has never been part of the registration required template).
    
    Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link note is displayed. There are no error messages for this condition.
    ]]
    if is_set(Via) then
        Via = &quot; &quot; .. wrap( 'via', Via );
    end

	if is_set(SubscriptionRequired) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription']; --here when 'via' parameter not used but 'subscription' is
    elseif is_set(RegistrationRequired) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration']; --here when 'via' and 'subscription' parameters not used but 'registration' is
    end

    if is_set(AccessDate) then
        local retrv_text = &quot; &quot; .. cfg.messages['retrieved']
        if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
        AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
            .. substitute( retrv_text, {AccessDate} ) .. '&lt;/span&gt;'
    end
    
    if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end

    
    ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo} );

    if is_set(URL) then
        URL = &quot; &quot; .. externallink( URL, nil, URLorigin );
    end

    if is_set(Quote) then
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        Quote = sepc ..&quot; &quot; .. wrap( 'quoted-text', Quote ); 
        PostScript = &quot;&quot;;
    elseif PostScript:lower() == &quot;none&quot; then
        PostScript = &quot;&quot;;
    end
    
    local Archived
    if is_set(ArchiveURL) then
        if not is_set(ArchiveDate) then
            ArchiveDate = seterror('archive_missing_date');
        end
        if &quot;no&quot; == DeadURL then
            local arch_text = cfg.messages['archived'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
                { externallink( ArchiveURL, arch_text ), ArchiveDate } );
            if not is_set(OriginalURL) then
                Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url');                               
            end
        elseif is_set(OriginalURL) then
            local arch_text = cfg.messages['archived-dead'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text,
                { externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
        else
            local arch_text = cfg.messages['archived-missing'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
                { seterror('archive_missing_url'), ArchiveDate } );
        end
    else
        Archived = &quot;&quot;
    end
    
    local Lay
    if is_set(LayURL) then
        if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
        if is_set(LaySource) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot;;
        else
            LaySource = &quot;&quot;;
        end
        if sepc == '.' then
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;;
    end
    
    if is_set(Transcript) then
        if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
    elseif is_set(TranscriptURL) then
        Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
    end
    
    local Publisher;
    if is_set(Periodical) and
        not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;}) then
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end
        elseif is_set(PublicationPlace) then
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if is_set(PublicationDate) then
            if is_set(Publisher) then
                Publisher = Publisher .. &quot;, &quot; .. wrap( 'published', PublicationDate );
            else
                Publisher = PublicationDate;
            end
        end
        if is_set(Publisher) then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if is_set(PublicationDate) then
            PublicationDate = &quot; (&quot; .. wrap( 'published', PublicationDate ) .. &quot;)&quot;;
        end
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif is_set(PublicationPlace) then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    
    -- Several of the above rely upon detecting this as nil, so do it last.
    if is_set(Periodical) then
        if is_set(Title) or is_set(TitleNote) then 
            Periodical = sepc .. &quot; &quot; .. wrap( 'italic-title', Periodical ) 
        else 
            Periodical = wrap( 'italic-title', Periodical )
        end
    end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if inArray(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
        if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, 
            Language, Cartography, Edition, Publisher, Agency, Volume, Issue}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, Language, 
            Volume, Issue, Others, Cartography, Edition, Publisher, Agency}, sepc );
    end
    
    if #ID_list &gt; 0 then
        ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
    else
        ID_list = ID;
    end
    
    local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
    local text;
    local pgtext = Position .. Page .. Pages .. At;
    
    if is_set(Authors) then
        if is_set(Coauthors) then
            Authors = Authors .. A['AuthorSeparator'] .. &quot; &quot; .. Coauthors
        end
        if is_set(Date) then
            Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        elseif string.sub(Authors,-1,-1) == sepc then
            Authors = Authors .. &quot; &quot;
        else
            Authors = Authors .. sepc .. &quot; &quot;
        end
        if is_set(Editors) then
            local in_text = &quot; &quot;;
            local post_text = &quot;&quot;;
            if is_set(Chapter) then
                in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
            else
                if EditorCount &lt;= 1 then
                    post_text = &quot;, &quot; .. cfg.messages['editor'];
                else
                    post_text = &quot;, &quot; .. cfg.messages['editors'];
                end
            end 
            if (sepc ~= '.') then in_text = in_text:lower() end
            Editors = in_text .. Editors .. post_text;
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = Editors .. &quot; &quot;
                else Editors = Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif is_set(Editors) then
        if is_set(Date) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
            else
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if is_set(Date) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end
        if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
            text = safejoin( {Chapter, Place, tcommon}, sepc );
            text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
            text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
            text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if is_set(PostScript) and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    local options = {};
    
    if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
        options.class = &quot;citation &quot; .. config.CitationClass;
    else
        options.class = &quot;citation&quot;;
    end
    
    if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if #a &gt; 0 then
                for i,v in ipairs(a) do 
                    names[i] = v.last 
                    if i == 4 then break end
                end
            elseif #e &gt; 0 then
                for i,v in ipairs(e) do 
                    names[i] = v.last 
                    if i == 4 then break end                
                end
            end
			names[ #names + 1 ] = Year or anchor_year;	-- Year first for legacy citations
            id = anchorid(names)
        end
        options.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = {};
        text = seterror('empty_citation');
        z.message_tail = {};
    end
    
    if is_set(options.id) then 
        text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    else
        text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    end        

    local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        text = text .. &quot; &quot;;
        for i,v in ipairs( z.message_tail ) do
            if is_set(v[1]) then
                if i == #z.message_tail then
                    text = text .. errorcomment( v[1], v[2] );
                else
                    text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
                end
            end
        end
    end
    
    no_tracking_cats = no_tracking_cats:lower();
    if inArray(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    local suggestions = {};
    local error_text, error_state;

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        args[k] = v;       
    end    

    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            if not validate( k ) then            
                error_text = &quot;&quot;;
                if type( k ) ~= 'string' then
                    -- Exclude empty numbered parameters
                    if v:match(&quot;%S+&quot;) ~= nil then
                        error_text, error_state = seterror( 'text_ignored', {v}, true );
                    end
                elseif validate( k:lower() ) then 
                    error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
                else
                    if #suggestions == 0 then
                        suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
                    end
                    if suggestions[ k:lower() ] ~= nil then
                        error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
                    else
                        error_text, error_state = seterror( 'parameter_ignored', {k}, true );
                    end
                end                  
                if error_text ~= '' then
                    table.insert( z.message_tail, {error_text, error_state} );
                end                
            end
            args[k] = v;
        elseif args[k] ~= nil or (k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z</text>
      <sha1>dlova0korsp17pfhg3wqi4zihqq2hd3</sha1>
    </revision>
    <revision>
      <id>4665</id>
      <parentid>4664</parentid>
      <timestamp>2013-12-14T18:31:15Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <minor />
      <comment>Cleanup;</comment>
      <origin>4665</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="79082" sha1="i9xigzjpy60hbalv36j44343n7td1mf" xml:space="preserve">local z = {
    error_categories = {};
    error_ids = {};
    message_tail = {};
}

-- Include translation message hooks, ID and error handling configuration settings.
local cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );

-- Contains a list of all recognized parameters
local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );

-- Whether variable is set or not
function is_set( var )
    return not (var == nil or var == '');
end

-- First set variable or nil if none
function first_set(...)
    local list = {...};
    for _, var in pairs(list) do
        if is_set( var ) then
            return var;
        end
    end
end

-- Whether needle is in haystack
function inArray( needle, haystack )
    if needle == nil then
        return false;
    end
    for n,v in ipairs( haystack ) do
        if v == needle then
            return n;
        end
    end
    return false;
end

--[[
Categorize and emit an error message when the citation contains one or more deprecated parameters.  Because deprecated parameters (currently |day=, |month=,
|coauthor=, and |coauthors=) aren't related to each other and because these parameters may be concatenated into the variables used by |date= and |author#= (and aliases)
details of which parameter caused the error message are not provided.  Only one error message is emitted regarless of the number of deprecated parameters in the citation.
]]
function deprecated_parameter()
	if true ~= Page_in_deprecated_cat then	-- if we haven't been here before then set a 
		Page_in_deprecated_cat=true;		-- sticky flag so that if there are more than one deprecated parameter the category is added only once
		table.insert( z.message_tail, { seterror( 'deprecated_params', {error_message}, true ) } );		-- add error message
	end
end

-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
    return args and tostring( mw.message.newRawMessage( msg, args ) ) or msg;
end

-- Wraps a string using a message_list configuration taking one argument
function wrap( key, str, lower )
    if not is_set( str ) then
        return &quot;&quot;;
    elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
        str = safeforitalics( str );
    end
    if lower == true then
        return substitute( cfg.messages[key]:lower(), {str} );
    else
        return substitute( cfg.messages[key], {str} );
    end        
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
    local origin = {};
    
    return setmetatable({
        ORIGIN = function( self, k )
            local dummy = self[k]; --force the variable to be loaded.
            return origin[k];
        end
    },
    {
        __index = function ( tbl, k )
            if origin[k] ~= nil then
                return nil;
            end
            
            local args, list, v = args, cfg.aliases[k];
            
            if type( list ) == 'table' then
                v, origin[k] = selectone( args, list, 'redundant_parameters' );
                if origin[k] == nil then
                    origin[k] = ''; -- Empty string, not nil
                end
            elseif list ~= nil then
                v, origin[k] = args[list], list;
            else
                -- maybe let through instead of raising an error?
                -- v, origin[k] = args[k], k;
                error( cfg.messages['unknown_argument_map'] );
            end
            
            -- Empty strings, not nil;
            if v == nil then
                v = cfg.defaults[k] or '';
                origin[k] = '';
            end
            
            tbl = rawset( tbl, k, v );
            return v;
        end,
    });
end

--[[
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three valuse:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
]]
function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
    return wrap( hidden and 'hidden-error' or 'visible-error', content );
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
    local error_state = cfg.error_conditions[ error_id ];
    
    prefix = prefix or &quot;&quot;;
    suffix = suffix or &quot;&quot;;
    
    if error_state == nil then
        error( cfg.messages['undefined_error'] );
    elseif is_set( error_state.category ) then
        table.insert( z.error_categories, error_state.category );
    end
    
    local message = substitute( error_state.message, arguments );
    
    message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
        &quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
        cfg.messages['help page label'] .. &quot;]])&quot;;
    
    z.error_ids[ error_id ] = true;
    if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
            and z.error_ids['citation_missing_title'] then
        return '', false;
    end
    
    message = table.concat({ prefix, message, suffix });
    
    if raw == true then
        return message, error_state.hidden;
    end        
        
    return errorcomment( message, error_state.hidden );
end

-- Formats a wiki style external link
function externallinkid(options)
    local url_string = options.id;
    if options.encode == true or options.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, url_string, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Formats a wiki style internal link
function internallinkid(options)
    return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, options.id, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Format an external link with error checking
function externallink( URL, label, source )
    local error_str = &quot;&quot;;
    if not is_set( label ) then
        label = URL;
        if is_set( source ) then
            error_str = seterror( 'bare_url_missing_title', { wrap( 'parameter', source ) }, false, &quot; &quot; );
        else
            error( cfg.messages[&quot;bare_url_no_origin&quot;] );
        end            
    end
    if not checkurl( URL ) then
        error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
    end
    return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safeforurl( label ), &quot;]&quot;, error_str });
end

-- Formats a link to Amazon
function amazon(id, domain)
    if not is_set(domain) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local handler = cfg.id_handlers['ASIN'];
    return externallinkid({link = handler.link,
        label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
        encode=handler.encode, separator = handler.separator})
end

--[[
Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns true; otherwse, returns false because the embargo has expired or |embargo= not set in this cite.
]]
function is_embargoed(embargo)
	if is_set(embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 and tonumber( embargo_date ) &gt;= tonumber( todays_date ) then	--is embargo date is in the future?
			return true;	-- still embargoed
		end
	end
	return false;			-- embargo expired or |embargo= not set
end

--[[
Formats a PMC and checks for embargoed articles.  The embargo parameter takes a date for a value. If the embargo date is in the future
the PMC identifier will not be linked to the article.  If the embargo specifies a date in the past, or if it is empty or omitted, then
the PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.
]]
function pmc(id, embargo)
	local handler = cfg.id_handlers['PMC'];
    
	local text;

	if is_embargoed(embargo) then
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id;	--still embargoed so no external link
	else
		text = externallinkid({link = handler.link, label = handler.label,			--no embargo date, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    local handler = cfg.id_handlers['DOI'];
    
    local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end
	if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then      
		cat = seterror( 'bad_doi' );
	end
	return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    local handler = cfg.id_handlers['OL'];
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    else
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode}) .. 
            ' ' .. seterror( 'bad_ol' );
    end
end

--[[
Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.
]]
function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and ndashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 didgits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = externallinkid({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. seterror( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[
This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those citations that have defaults.
Also handles the special case where it is desireable to omit the title type from the rendered citation (|type=none).
]]
function set_titletype(cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;					-- if |type=none then type parameter not displayed
		end
		return title_type;						-- if |type= has been set to any other value use that value
	end

	if &quot;pressrelease&quot; == cite_class then		-- if this citation is cite press release
		return &quot;Press release&quot;;					-- display press release annotation

	elseif &quot;speech&quot; == cite_class then			-- if this citation is cite speech
		return &quot;Speech&quot;;						-- display speech annotation
	
	elseif &quot;techreport&quot; == cite_class then		-- if this citation is cite techreport
		return &quot;Technical report&quot;;				-- display techreport annotation
	
	elseif &quot;thesis&quot; == cite_class then			-- if this citation is cite thesis (degree option handled after this function returns)
			return &quot;Thesis&quot;;					-- display simple thesis annotation (without |degree= modification)
	end
end

-- returns a number according to the month in a date: 1 for January, etc.  If not a valid month, returns 0
function get_month_number (month)
local long_months = {['january']=1, ['february']=2, ['march']=3, ['april']=4, ['may']=5, ['june']=6, ['july']=7, ['august']=8, ['september']=9, ['october']=10, ['november']=11, ['december']=12};
local short_months = {['jan']=1, ['feb']=2, ['mar']=3, ['apr']=4, ['may']=5, ['jun']=6, ['jul']=7, ['aug']=8, ['sep']=9, ['oct']=10, ['nov']=11, ['dec']=12};
local temp;
	temp=long_months[month:lower()];
	if temp then return temp; end				-- if month is the long-form name
	temp=short_months[month:lower()];
	if temp then return temp; end				-- if month is the short-form name
	return 0;									-- misspelled or not a month name
end

-- returns true if date has one of the five seasons.  Else false.
function is_valid_season (season)
	if inArray( season, {'winter', 'spring', 'summer', 'fall', 'autumn'} ) then
		return true;
	end
	return false;
end

--[[
Returns true if day is less than or equal to the number of days in month; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap years before 1582 and Gregorian leap years after 1582.
Where the two calendars overlap (1582 to approximately 1923) dates are assumed to be Gregorian.
]]
function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if (2==month) then							-- if February
		month_length = 28;						-- then 28 days unless
		if 1582 &gt; tonumber(year) then			-- Julian calendar
			if 0==(year%4) then
				month_length = 29;
			end
		else									-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then	-- is a leap year?
				month_length = 29;				-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end

--Check a pair of months or seasons to see if both are valid members of a month or season pair.
--TODO: Check order to make sure that the left month/season properly precedes the right month/season

function is_valid_month_season_range(range_start, range_end)
	if 0 == get_month_number (range_start:lower()) then			-- is this a month range?
		if true == is_valid_season (range_start:lower()) then	-- not a month range, is this a season range?
			return is_valid_season (range_end:lower());			-- range_start is season; return true if range_end also a season; else false
		end
		return false;		-- range_start is not a month or a season
	end
	if 0 == get_month_number (range_end:lower()) then			-- range_start is a month; is range_end also a  month?
		return false;											-- not a month range
	end
	return true;
end

--[[
Check date format to see that it is one of the formats approved by MOS:DATE: MMMM D, YYYY; D MMMM YYYY; MMMM YYYY; YYYY-MM-DD; YYYY.
Additionally, check the date to see that it is a real date: no 31 in 30-day months; no 29 February when not a leap year.  Months, both long-form and three
character abbreviations, and seasons must be spelled correctly.

If the date fails the fomat tests, this function returns false but does not return values for anchor_year and COinS_date.  When this happens, the date parameter is
used in the COinS metadata and the CITEREF identifier gets its year from the year parameter if present.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is date_string without anchor_year disambiguator if any
]]
function check_date (date_string)
	local year;
	local month;
	local day;
	local anchor_year;
	local coins_date;

	if date_string:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then			-- Year-initial numerical year month day format
		coins_date = date_string:match(&quot;%d%d%d%d%-%d%d%-%d%d&quot;);
		year, month, day=string.match(date_string, &quot;(%d%d%d%d)%-(%d%d)%-(%d%d)&quot;);
		anchor_year = year;
		month=tonumber(month);
		if 12 &lt; month or 1 &gt; month then return false; end

	elseif date_string:match(&quot;^%a+%s*%d%d*%s*,%s*%d%d%d%d%a?$&quot;) then	-- month-initial: month day, year
		coins_date = date_string:match(&quot;%a+%s*%d%d*%s*,%s*%d%d%d%d&quot;);
		month, day, anchor_year, year=string.match(date_string, &quot;(%a+)%s*(%d%d*)%s*,%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month:lower());
		if 0 == month then return false; end					-- return false if month text isn't one of the twelve months
				
	elseif date_string:match(&quot;^%d%d*%s*%a+%s*%d%d%d%d%a?$&quot;) then		-- date-initial: day month year
		coins_date = date_string:match(&quot;%d%d*%s*%a+%s*%d%d%d%d&quot;);
		day, month, anchor_year, year=string.match(date_string, &quot;(%d%d*)%s*(%a+)%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month:lower());
		if 0 == month then return false; end					-- return false if month text isn't one of the twelve months

	elseif mw.ustring.match (date_string, &quot;^%a+%s*[%s%-/–]%s*%a+%s*%d%d%d%d%a?$&quot;) then		-- month/season range year
		local month2
		coins_date = mw.ustring.match (date_string, &quot;%a+%s*[%s%-/–]%s*%a+%s*%d%d%d%d&quot;);
		coins_date= mw.ustring.gsub( coins_date, &quot;–&quot;, &quot;-&quot; );	-- replace ndash with hyphen
		month, month2, anchor_year, year=mw.ustring.match (date_string, &quot;(%a+)%s*[%s%-/–]%s*(%a+)%s*((%d%d%d%d)%a?)&quot;);
		day=0;													-- mark day as not used
		if false == is_valid_month_season_range(month, month2) then
			return false;
		end
		
	elseif date_string:match(&quot;^%a+%s*%d%d%d%d%a?$&quot;) then		-- month/season year
		coins_date = date_string:match(&quot;%a+%s*%d%d%d%d&quot;);
		month, anchor_year, year=string.match(date_string, &quot;(%a+)%s*((%d%d%d%d)%a?)&quot;);
		day=0;													-- mark day as not used
		local season=month;										-- copy 
		month = get_month_number (month:lower());
		if month == 0 then										-- if month text isn't one of the twelve months, might be a season
			if false == is_valid_season (season:lower()) then
				return false;									-- return false not a month or one of the five seasons
			end
		end

	elseif date_string:match(&quot;^%d%d%d%d?%a?$&quot;) then			-- year; here accept either YYY or YYYY
		coins_date = date_string:match(&quot;^%d%d%d%d?&quot;);
		anchor_year, year=string.match(date_string, &quot;((%d%d%d%d?)%a?)&quot;);
		month, day = 0, 0;										-- mark day and month as not used
	else
		return false;											-- date format not one of the MOS:DATE approved formats
	end

	if 0~=month and 0~=day then									-- check year month day dates for validity
		if false==is_valid_date(year,month,day) then
			return false;										-- date string is not a real date return false; unset anchor_year and coins_date
		end
	end
	
	return true, anchor_year, coins_date;						-- format is good and date string represents a real date
end	

--[[
Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true and values for anchor_year (used in CITEREF identifiers) and COinS_date (used in the COinS metadata).  The |date= parameter test is unique.  This function only 
accepts anchor_year and COinS_date results from the |date= parameter test and |date= is the only date-holding parameter that is allowed to contain the no-date keywords
&quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.
]]

function dates(date_parameters_list)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local error_message =&quot;&quot;;
	local good_date=false;
	
	for k, v in pairs(date_parameters_list) do		-- for each date-holding parameter in the list
		if is_set(v) then							-- if the parameter has a value
			if v:match(&quot;^c%.%s%d%d%d%d?%a?$&quot;) then	-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				if 'date'==k then
					good_date, anchor_year, COinS_date = true, v:match(&quot;((c%.%s%d%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
				elseif 'year'==k then
					good_date =  true;
				end
			elseif 'year'==k then					-- if the parameter is |year= (but not c. year)
				if v:match(&quot;^%d%d%d%d?%a?$&quot;) then	-- year with or without CITEREF disambiguator
					good_date =  true;
				end
			elseif 'date'==k then					-- if the parameter is |date=
				if v:match(&quot;n%.d%.%a?&quot;) then		-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v:match(&quot;nd%a?$&quot;) then		-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v);	-- go test the date
				end
			else									-- any other date-holding parameter
				good_date = check_date (v);			-- go test the date
			end
			if false==good_date then				-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then		-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;	-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;	-- add the failed parameter
			end
		end
	end
	if is_set(error_message) then
		table.insert( z.message_tail, { seterror( 'bad_date', {error_message}, true ) } );	-- add this error message
	end

	return anchor_year, COinS_date;		-- and done
end

--[[
Determines whether a URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
    -- Protocol-relative or URL scheme
    return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
    return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

--[[
ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in checkisbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.
]]
function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of bytes
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end	-- isbn13 begins with 978 or 979
		isbn_str = { isbn_str:byte(1, len) };
		for i, v in ipairs( isbn_str ) do
			temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
		end
		return temp % 10 == 0;
	end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
    return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
        return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
    end));
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if not is_set(str) then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        
        -- Remove newlines as they break italics.
        return str:gsub( '\n', ' ' );
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    if maximum ~= nil and maximum &lt; 1 then return &quot;&quot;, 0; end
    
    for i,person in ipairs(people) do
        if is_set(person.last) then
            local mask = person.mask
            local one
            local sep_one = sep;
            if maximum ~= nil and i &gt; maximum then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask;
                    sep_one = &quot; &quot;;
                end
            else
                one = person.last
                local first = person.first
                if is_set(first) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if is_set(person.link) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert( text, one )
            table.insert( text, sep_one )
        end
    end

    local count = #text / 2;
    if count &gt; 0 then 
        if count &gt; 1 and is_set(lastauthoramp) and not etal then
            text[#text-2] = &quot; &amp; &quot;;
        end
        text[#text] = nil; 
    end
    
    local result = table.concat(text) -- construct list
    if etal then 
        local etal_text = cfg.messages['et al'];
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result = 
        '&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
    end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
    return &quot;CITEREF&quot; .. table.concat( options );
end

-- Gets name list from the input arguments
function extractnames(args, list_name)
    local names = {};
    local i = 1;
    local last;
    
    while true do
        last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );
        if not is_set(last) then
            -- just in case someone passed in an empty parameter
            break;
        end
        names[i] = {
            last = last,
            first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i ),
            link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ),
            mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i )
        };
        i = i + 1;
    end
    return names;
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
    local id_list = {};
    for k, v in pairs( cfg.id_handlers ) do    
        v = selectone( args, v.parameters, 'redundant_parameters' );
        if is_set(v) then id_list[k] = v; end
    end
    return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
    local new_list, handler = {};
    
    function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
    
    for k, v in pairs( id_list ) do
        -- fallback to read-only cfg
        handler = setmetatable( { ['id'] = v }, fallback(k) );
        
        if handler.mode == 'external' then
            table.insert( new_list, {handler.label, externallinkid( handler ) } );
        elseif handler.mode == 'internal' then
            table.insert( new_list, {handler.label, internallinkid( handler ) } );
        elseif handler.mode ~= 'manual' then
            error( cfg.messages['unknown_ID_mode'] );
        elseif k == 'DOI' then
            table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
        elseif k == 'ASIN' then
            table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
        elseif k == 'OL' then
            table.insert( new_list, {handler.label, openlibrary( v ) } );
        elseif k == 'PMC' then
            table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
        elseif k == 'ISSN' then
        	table.insert( new_list, {handler.label, issn( v ) } );
        elseif k == 'ISBN' then
            local ISBN = internallinkid( handler );
            if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
                ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
            end
            table.insert( new_list, {handler.label, ISBN } );                
        else
            error( cfg.messages['unknown_manual_ID'] );
        end
    end
    
    function comp( a, b )	-- used in following table.sort()
        return a[1] &lt; b[1];
    end
    
    table.sort( new_list, comp );
    for k, v in ipairs( new_list ) do
        new_list[k] = v[2];
    end
    
    return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
    local value = nil;
    local selected = '';
    local error_list = {};
    
    if index ~= nil then index = tostring(index); end
    
    -- Handle special case of &quot;#&quot; replaced by empty string
    if index == '1' then
        for _, v in ipairs( possible ) do
            v = v:gsub( &quot;#&quot;, &quot;&quot; );
            if is_set(args[v]) then
                if value ~= nil and selected ~= v then
                    table.insert( error_list, v );
                else
                    value = args[v];
                    selected = v;
                end
            end
        end        
    end
    
    for _, v in ipairs( possible ) do
        if index ~= nil then
            v = v:gsub( &quot;#&quot;, index );
        end
        if is_set(args[v]) then
            if value ~= nil and selected ~=  v then
                table.insert( error_list, v );
            else
                value = args[v];
                selected = v;
            end
        end
    end
    
    if #error_list &gt; 0 then
        local error_str = &quot;&quot;;
        for _, k in ipairs( error_list ) do
            if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
            error_str = error_str .. wrap( 'parameter', k );
        end
        if #error_list &gt; 1 then
            error_str = error_str .. cfg.messages['parameter-final-separator'];
        else
            error_str = error_str .. cfg.messages['parameter-pair-separator'];
        end
        error_str = error_str .. wrap( 'parameter', selected );
        table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
    end
    
    return value, selected;
end

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
function COinS(data)
    if 'table' ~= type(data) or nil == next(data) then
        return '';
    end
    
    local ctx_ver = &quot;Z39.88-2004&quot;;
    
    -- treat table strictly as an array with only set values.
    local OCinSoutput = setmetatable( {}, {
        __newindex = function(self, key, value)
            if is_set(value) then
                rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
            end
        end
    });
    
    if is_set(data.Chapter) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Chapter;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    elseif is_set(data.Periodical) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
        OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    else
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
    end
    
    OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
    OCinSoutput[&quot;rft.date&quot;] = data.Date;
    OCinSoutput[&quot;rft.series&quot;] = data.Series;
    OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
    OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
    OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
    OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
    OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
    
    for k, v in pairs( data.ID_list ) do
        local id, value = cfg.id_handlers[k].COinS;
        if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
        if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
            OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
        else
            OCinSoutput[ id ] = value;
        end
    end
    
    local last, first;
    for k, v in ipairs( data.Authors ) do
        last, first = v.last, v.first;
        if k == 1 then
            if is_set(last) then
                OCinSoutput[&quot;rft.aulast&quot;] = last;
            end
            if is_set(first) then 
                OCinSoutput[&quot;rft.aufirst&quot;] = first;
            end
        end
        if is_set(last) and is_set(first) then
            OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
        elseif is_set(last) then
            OCinSoutput[&quot;rft.au&quot;] = last;
        end
    end
    
    OCinSoutput.rft_id = data.URL;
    OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
    OCinSoutput = setmetatable( OCinSoutput, nil );
    
    -- sort with version string always first, and combine.
    table.sort( OCinSoutput );
    table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
    return table.concat(OCinSoutput, &quot;&amp;&quot;);
end

--[[
This is the main function doing the majority of the citation
formatting.
]]
function citation0( config, args)
    --[[ 
    Load Input Parameters
    The argment_wrapper facillitates the mapping of multiple
    aliases to single internal variable.
    ]]
    local A = argument_wrapper( args );

    local i 
    local PPrefix = A['PPrefix']
    local PPPrefix = A['PPPrefix']
    if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = A['Authors'];
    local a = extractnames( args, 'AuthorList' );

    local Coauthors = A['Coauthors'];
    local Others = A['Others'];
    local Editors = A['Editors'];
    local e = extractnames( args, 'EditorList' );

    local Year = A['Year'];
    local PublicationDate = A['PublicationDate'];
    local OrigYear = A['OrigYear'];
    local Date = A['Date'];
    local LayDate = A['LayDate'];
    ------------------------------------------------- Get title data
    local Title = A['Title'];
    local BookTitle = A['BookTitle'];
    local Conference = A['Conference'];
    local TransTitle = A['TransTitle'];
    local TitleNote = A['TitleNote'];
    local TitleLink = A['TitleLink'];
    local Chapter = A['Chapter'];
    local ChapterLink = A['ChapterLink'];
    local TransChapter = A['TransChapter'];
    local TitleType = A['TitleType'];
    local Degree = A['Degree'];
    local Docket = A['Docket'];
    local ArchiveURL = A['ArchiveURL'];
    local URL = A['URL']
    local URLorigin = A:ORIGIN('URL');
    local ChapterURL = A['ChapterURL'];
    local ChapterURLorigin = A:ORIGIN('ChapterURL');
    local ConferenceURL = A['ConferenceURL'];
    local ConferenceURLorigin = A:ORIGIN('ConferenceURL');
    local Periodical = A['Periodical'];

--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped

All other combinations of |encyclopedia, |title, and |article are not modified
]]
	if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
		if is_set(Periodical) then					-- Periodical is set when |encyclopedia is set
			if is_set(Title) then
				if not is_set(Chapter) then
					Chapter = Title;				-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					TransChapter = TransTitle;
					Title = Periodical;
					Periodical = '';				-- redundant so unset
					TransTitle = '';				-- redundant so unset
				end
			else									-- |title not set
				Title = Periodical;					-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';					-- redundant so unset
			end
		end
	end

local Series = A['Series'];
    local Volume = A['Volume'];
    local Issue = A['Issue'];
    local Position = '';
    local Page, Pages, At, page_type;
    
    Page = A['Page'];
    Pages = hyphentodash( A['Pages'] );
    At = A['At'];
    
    if is_set(Page) then
        if is_set(Pages) or is_set(At) then
            Page = Page .. &quot; &quot; .. seterror('extra_pages');
            Pages = '';
            At = '';
        end
    elseif is_set(Pages) then
        if is_set(At) then
            Pages = Pages .. &quot; &quot; .. seterror('extra_pages');
            At = '';
        end
    end    
    
    local Edition = A['Edition'];
    local PublicationPlace = A['PublicationPlace']
    local Place = A['Place'];
    
    if not is_set(PublicationPlace) and is_set(Place) then
        PublicationPlace = Place;
    end
    
    if PublicationPlace == Place then Place = ''; end
    
    local PublisherName = A['PublisherName'];
    local RegistrationRequired = A['RegistrationRequired'];
    local SubscriptionRequired = A['SubscriptionRequired'];
    local Via = A['Via'];
    local AccessDate = A['AccessDate'];
    local ArchiveDate = A['ArchiveDate'];
    local Agency = A['Agency'];
    local DeadURL = A['DeadURL']
    local Language = A['Language'];
    local Format = A['Format'];
    local Ref = A['Ref'];
    
    local DoiBroken = A['DoiBroken'];
	
-- Special case for cite techreport.
	local ID = A['ID'];
	if (config.CitationClass == &quot;techreport&quot;) then	-- special case for cite techreport
		if is_set(Issue) then						-- cite techreport uses 'number', which other citations aliase to 'issue'
			if not is_set(ID) then					-- can we use ID for the &quot;number&quot;?
				ID = Issue;							-- yes, use it
				Issue = &quot;&quot;;							-- unset Issue so that &quot;number&quot; isn't duplicated in the rendered citation or COinS metadata
			else									-- can't use ID so emit error message
				ID = ID .. &quot; &quot; .. seterror('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
			end
		end	
	end	
			
    local ASINTLD = A['ASINTLD'];
    local IgnoreISBN = A['IgnoreISBN'];
    local Embargo = A['Embargo'];

    local ID_list = extractids( args );
    
    local Quote = A['Quote'];
    local PostScript = A['PostScript'];
    local LayURL = A['LayURL'];
    local LaySource = A['LaySource'];
    local Transcript = A['Transcript'];
    local TranscriptURL = A['TranscriptURL'] 
    local TranscriptURLorigin = A:ORIGIN('TranscriptURL');
    local sepc = A['Separator'];
    local LastAuthorAmp = A['LastAuthorAmp'];
    local no_tracking_cats = A['NoTracking'];

    local use_lowercase = ( sepc ~= '.' );
    local this_page = mw.title.getCurrentTitle();  --Also used for COinS and for language
    
    if not is_set(no_tracking_cats) then
        for k, v in pairs( cfg.uncategorized_namespaces ) do
            if this_page.nsText == v then
                no_tracking_cats = &quot;true&quot;;
                break;
            end
        end
    end

	local anchor_year;		-- used in the CITEREF identifier
	local COinS_date;		-- used in the COinS metadata

-- legacy: promote concatenation of |day=, |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set(Date) then
		Date = Year;						-- promote Year to Date
		Year = nil;							-- make nil so Year as empty string isn't used for CITEREF
		if is_set(Date) then
			local Month = A['Month'];
			if is_set(Month) then
				Date = Month .. &quot; &quot; .. Date;
				local Day = A['Day']
				if is_set(Day) then Date = Day .. &quot; &quot; .. Date end
			end
		elseif is_set(PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;			-- promonte PublicationDate to Date
			PublicationDate = '';			-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end	-- if PublicationDate is same as Date, don't display in rendered citation

-- Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates.
-- TODO: 2013-10-27: AirDate is nil when dates() is called because it hasn't been set yet.  Move the call to dates() or set AirDate earlier.
	anchor_year, COinS_date = dates({['accessdate']=AccessDate, ['airdate']=AirDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
		['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.

	--Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set
	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_embargoed(Embargo) then
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];	-- set url to be the same as the PMC external link if not embargoed
		end
	end

    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if is_set(BookTitle) then
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = BookTitle;
        TitleLink = '';
        TransTitle = '';
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = A['AirDate'];
        local SeriesLink = A['SeriesLink'];
        local Season = A['Season'];
        local SeriesNumber = A['SeriesNumber'];
        local Network = A['Network'];
        local Station = A['Station'];
        local s, n = {}, {};
        local Sep = (first_set(A[&quot;SeriesSeparator&quot;], A[&quot;Separator&quot;]) or &quot;&quot;) .. &quot; &quot;;
        
        if is_set(Issue) then table.insert(s, cfg.messages[&quot;episode&quot;] .. &quot; &quot; .. Issue); Issue = ''; end
        if is_set(Season) then table.insert(s, cfg.messages[&quot;season&quot;] .. &quot; &quot; .. Season); end
        if is_set(SeriesNumber) then table.insert(s, cfg.messages[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber); end
        if is_set(Network) then table.insert(n, Network); end
        if is_set(Station) then table.insert(n, Station); end
        
        Date = Date or AirDate;
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = Series;
        TitleLink = SeriesLink;
        TransTitle = '';
        
        Series = table.concat(s, Sep);
        ID = table.concat(n, Sep);
    end
    
    -- COinS metadata (see &lt;http://ocoins.info/&gt;) for
    -- automated parsing of citation information.
    local OCinSoutput = COinS{
        ['Periodical'] = Periodical,
        ['Chapter'] = Chapter,
        ['Title'] = Title,
        ['PublicationPlace'] = PublicationPlace,
        ['Date'] = first_set(COinS_date, Date),		-- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here?  Should we be including invalid dates in metadata?
        ['Series'] = Series,
        ['Volume'] = Volume,
        ['Issue'] = Issue,
        ['Pages'] = first_set(Page, Pages, At),
        ['Edition'] = Edition,
        ['PublisherName'] = PublisherName,
        ['URL'] = first_set( URL, ChapterURL ),
        ['Authors'] = a,
        ['ID_list'] = ID_list,
        ['RawPage'] = this_page.prefixedText,
    };

    if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = '';
        TitleLink = '';
        TransTitle = '';
    end

    -- Now perform various field 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 not is_set(Authors) then
        local Maximum = tonumber( A['DisplayAuthors'] );
        
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #a == 9 then 
            Maximum = 8;
            table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
        elseif not is_set(Maximum) then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = A[&quot;AuthorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;AuthorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A[&quot;AuthorFormat&quot;],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if is_set(Coauthors) then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
        
        Authors = listpeople(control, a) 
    end

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { seterror('coauthors_missing_author', {}, true) } );	-- emit error message
	end

    local EditorCount
    if not is_set(Editors) then
        local Maximum = tonumber( A['DisplayEditors'] );
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #e == 4 then 
            Maximum = 3;
            table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
        elseif not is_set(Maximum) then
            Maximum = #e + 1;
        end

        local control = { 
            sep = A[&quot;EditorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;EditorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A['EditorFormat'],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };

        Editors, EditorCount = listpeople(control, e);
    else
        EditorCount = 1;
    end

    local Cartography = &quot;&quot;;
    local Scale = &quot;&quot;;
    if config.CitationClass == &quot;map&quot; then
        if not is_set( Authors ) and is_set( PublisherName ) then
            Authors = PublisherName;
            PublisherName = &quot;&quot;;
        end
        Cartography = A['Cartography'];
        if is_set( Cartography ) then
            Cartography = sepc .. &quot; &quot; .. wrap( 'cartography', Cartography, use_lowercase );
        end        
        Scale = A['Scale'];
        if is_set( Scale ) then
            Scale = sepc .. &quot; &quot; .. Scale;
        end        
    end
    
    if  not is_set(URL) and
        not is_set(ChapterURL) and
        not is_set(ArchiveURL) and
        not is_set(ConferenceURL) and
        not is_set(TranscriptURL) then
        
        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
        end
        
        -- Test if accessdate is given without giving a URL
        if is_set(AccessDate) then
            table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
            AccessDate = '';
        end
        
        -- Test if format is given without giving a URL
        if is_set(Format) then
            Format = Format .. seterror( 'format_missing_url' );
        end
    end
    
    -- Test if citation has no title
    if  not is_set(Chapter) and
        not is_set(Title) and
        not is_set(Periodical) and
        not is_set(Conference) and
        not is_set(TransTitle) and
        not is_set(TransChapter) then
        table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
    end
    
    Format = is_set(Format) and &quot; (&quot; .. Format .. &quot;)&quot; or &quot;&quot;;
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if is_set( ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
            URLorigin = A:ORIGIN('ArchiveURL')
        end
    end
    
    -- Format chapter / article title
    if is_set(Chapter) and is_set(ChapterLink) then 
        Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot;;
    end
    if is_set(Periodical) and is_set(Title) then
        Chapter = wrap( 'italic-title', Chapter );
        TransChapter = wrap( 'trans-italic-title', TransChapter );
    else
        Chapter = wrap( 'quoted-title', Chapter );
        TransChapter = wrap( 'trans-quoted-title', TransChapter );
    end
    
    local TransError = &quot;&quot;
    if is_set(TransChapter) then
        if not is_set(Chapter) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
        else
            TransChapter = &quot; &quot; .. TransChapter;
        end
    end
    
    Chapter = Chapter .. TransChapter;
    
    if is_set(Chapter) then
        if not is_set(ChapterLink) then
            if is_set(ChapterURL) then
                Chapter = externallink( ChapterURL, Chapter ) .. TransError;
                if not is_set(URL) then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif is_set(URL) then 
                Chapter = externallink( URL, Chapter ) .. TransError .. Format;
                URL = &quot;&quot;;
                Format = &quot;&quot;;
            else
                Chapter = Chapter .. TransError;
            end            
        elseif is_set(ChapterURL) then
            Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. 
                TransError;
        else
            Chapter = Chapter .. TransError;
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    elseif is_set(ChapterURL) then
        Chapter = &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. sepc .. &quot; &quot;;
    end        
    
    -- Format main title.
    if is_set(TitleLink) and is_set(Title) then
        Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
    end
    
    if is_set(Periodical) then
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    elseif inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;pressrelease&quot;,&quot;conference&quot;}) and
            not is_set(Chapter) then
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    else
        Title = wrap( 'italic-title', Title );
        TransTitle = wrap( 'trans-italic-title', TransTitle );
    end
    
    TransError = &quot;&quot;;
    if is_set(TransTitle) then
        if not is_set(Title) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
        else
            TransTitle = &quot; &quot; .. TransTitle;
        end
    end
    
    Title = Title .. TransTitle;
    
    if is_set(Title) then
        if not is_set(TitleLink) and is_set(URL) then 
            Title = externallink( URL, Title ) .. TransError .. Format       
            URL = &quot;&quot;;
            Format = &quot;&quot;;
        else
            Title = Title .. TransError;
        end
    end
    
    if is_set(Place) then
        Place = &quot; &quot; .. wrap( 'written', Place, use_lowercase ) .. sepc .. &quot; &quot;;
    end
    
    if is_set(Conference) then
        if is_set(ConferenceURL) then
            Conference = externallink( ConferenceURL, Conference );
        end
        Conference = sepc .. &quot; &quot; .. Conference
    elseif is_set(ConferenceURL) then
        Conference = sepc .. &quot; &quot; .. externallink( ConferenceURL, nil, ConferenceURLorigin );
    end
    
    if not is_set(Position) then
        local Minutes = A['Minutes'];
        if is_set(Minutes) then
            Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
        else
            local Time = A['Time'];
            if is_set(Time) then
                local TimeCaption = A['TimeCaption']
                if not is_set(TimeCaption) then
                    TimeCaption = cfg.messages['event'];
                    if sepc ~= '.' then
                        TimeCaption = TimeCaption:lower();
                    end
                end
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
            end
        end
    else
        Position = &quot; &quot; .. Position;
        At = '';
    end
    
    if not is_set(Page) then
        if is_set(Pages) then
            if is_set(Periodical) and
                not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;}) then
                Pages = &quot;: &quot; .. Pages;
            elseif tonumber(Pages) ~= nil then
                Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
            else
                Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
            end
        end
    else
        if is_set(Periodical) and
            not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;}) then
            Page = &quot;: &quot; .. Page;
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page;
        end
    end
    
    At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
    Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
    if config.CitationClass == 'map' then
        local Section = A['Section'];
        local Inset = A['Inset'];
        if first_set( Pages, Page, At ) ~= nil or sepc ~= '.' then
            if is_set( Section ) then
                Section = &quot;, &quot; .. wrap( 'section', Section, true );
            end
            if is_set( Inset ) then
                Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
            end
        else
            if is_set( Section ) then
                Section = sepc .. &quot; &quot; .. wrap( 'section', Section, use_lowercase );
                if is_set( Inset ) then
                    Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
                end
            elseif is_set( Inset ) then
                Inset = sepc .. &quot; &quot; .. wrap( 'inset', Inset, use_lowercase );
            end            
        end            
        At = At .. Section .. Inset;        
    end    

	--[[Look in the list of iso639-1 language codes to see if the value provided in the language parameter matches one of them.  If a match is found, 
	use that value; if not, then use the value that was provided with the language parameter.
	
	Categories are assigned in a manner similar to the {{xx icon}} templates - categorizes only mainspace citations and only when the language code is not 'en' (English).
	]]
	if is_set (Language) then
		local name = cfg.iso639_1[Language:lower()];		-- get the language name if Language parameter has a valid iso 639-1 code
		if nil == name then
			Language=&quot; &quot; .. wrap( 'language', Language );	-- no match, use parameter's value
		else
			if 0 == this_page.namespace and 'en' ~= Language:lower() then	--found a match; is this page main / article space and English not the language?
				Language=&quot; &quot; .. wrap( 'language', name .. '[[Category:Articles with ' .. name .. '-language external links]]' );	-- in main space and not English: categorize
			else
				Language=&quot; &quot; .. wrap( 'language', name );	--not in mainspace or language is English so don't categorize
			end
		end
	else
		Language=&quot;&quot;;	-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;

-- handle type parameter for those CS1 citations that have default values

	if inArray(config.CitationClass, {&quot;pressrelease&quot;,&quot;techreport&quot;,&quot;thesis&quot;, &quot;speech&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then	-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then					-- if type parameter is specified
		TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot;;	-- display it in parentheses
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
    Edition = is_set(Edition) and (&quot; &quot; .. wrap( 'edition', Edition )) or &quot;&quot;;
    Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
    Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
    OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
    Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;
    
    if is_set(Volume) then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume;
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
        end
    end
    
    ------------------------------------ totally unrelated data
    --[[ Loosely mimic {{subscription required}} template; Via parameter identifies a delivery source that is not the publisher; these sources often, but not always, exist
    behind a registration or paywall.  So here, we've chosen to decouple via from subscription (via has never been part of the registration required template).
    
    Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link note is displayed. There are no error messages for this condition.
    ]]
    if is_set(Via) then
        Via = &quot; &quot; .. wrap( 'via', Via );
    end

	if is_set(SubscriptionRequired) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription']; --here when 'via' parameter not used but 'subscription' is
    elseif is_set(RegistrationRequired) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration']; --here when 'via' and 'subscription' parameters not used but 'registration' is
    end

    if is_set(AccessDate) then
        local retrv_text = &quot; &quot; .. cfg.messages['retrieved']
        if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
        AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
            .. substitute( retrv_text, {AccessDate} ) .. '&lt;/span&gt;'
    end
    
    if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end

    
    ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo} );

    if is_set(URL) then
        URL = &quot; &quot; .. externallink( URL, nil, URLorigin );
    end

    if is_set(Quote) then
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        Quote = sepc ..&quot; &quot; .. wrap( 'quoted-text', Quote ); 
        PostScript = &quot;&quot;;
    elseif PostScript:lower() == &quot;none&quot; then
        PostScript = &quot;&quot;;
    end
    
    local Archived
    if is_set(ArchiveURL) then
        if not is_set(ArchiveDate) then
            ArchiveDate = seterror('archive_missing_date');
        end
        if &quot;no&quot; == DeadURL then
            local arch_text = cfg.messages['archived'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
                { externallink( ArchiveURL, arch_text ), ArchiveDate } );
            if not is_set(OriginalURL) then
                Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url');                               
            end
        elseif is_set(OriginalURL) then
            local arch_text = cfg.messages['archived-dead'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text,
                { externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
        else
            local arch_text = cfg.messages['archived-missing'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
                { seterror('archive_missing_url'), ArchiveDate } );
        end
    else
        Archived = &quot;&quot;
    end
    
    local Lay
    if is_set(LayURL) then
        if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
        if is_set(LaySource) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot;;
        else
            LaySource = &quot;&quot;;
        end
        if sepc == '.' then
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;;
    end
    
    if is_set(Transcript) then
        if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
    elseif is_set(TranscriptURL) then
        Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
    end
    
    local Publisher;
    if is_set(Periodical) and
        not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;}) then
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end
        elseif is_set(PublicationPlace) then
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if is_set(PublicationDate) then
            if is_set(Publisher) then
                Publisher = Publisher .. &quot;, &quot; .. wrap( 'published', PublicationDate );
            else
                Publisher = PublicationDate;
            end
        end
        if is_set(Publisher) then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if is_set(PublicationDate) then
            PublicationDate = &quot; (&quot; .. wrap( 'published', PublicationDate ) .. &quot;)&quot;;
        end
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif is_set(PublicationPlace) then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    
    -- Several of the above rely upon detecting this as nil, so do it last.
    if is_set(Periodical) then
        if is_set(Title) or is_set(TitleNote) then 
            Periodical = sepc .. &quot; &quot; .. wrap( 'italic-title', Periodical ) 
        else 
            Periodical = wrap( 'italic-title', Periodical )
        end
    end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if inArray(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
        if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, 
            Language, Cartography, Edition, Publisher, Agency, Volume, Issue}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, Language, 
            Volume, Issue, Others, Cartography, Edition, Publisher, Agency}, sepc );
    end
    
    if #ID_list &gt; 0 then
        ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
    else
        ID_list = ID;
    end
    
    local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
    local text;
    local pgtext = Position .. Page .. Pages .. At;
    
    if is_set(Authors) then
        if is_set(Coauthors) then
            Authors = Authors .. A['AuthorSeparator'] .. &quot; &quot; .. Coauthors
        end
        if is_set(Date) then
            Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        elseif string.sub(Authors,-1,-1) == sepc then
            Authors = Authors .. &quot; &quot;
        else
            Authors = Authors .. sepc .. &quot; &quot;
        end
        if is_set(Editors) then
            local in_text = &quot; &quot;;
            local post_text = &quot;&quot;;
            if is_set(Chapter) then
                in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
            else
                if EditorCount &lt;= 1 then
                    post_text = &quot;, &quot; .. cfg.messages['editor'];
                else
                    post_text = &quot;, &quot; .. cfg.messages['editors'];
                end
            end 
            if (sepc ~= '.') then in_text = in_text:lower() end
            Editors = in_text .. Editors .. post_text;
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = Editors .. &quot; &quot;
                else Editors = Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif is_set(Editors) then
        if is_set(Date) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
            else
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if is_set(Date) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end
        if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
            text = safejoin( {Chapter, Place, tcommon}, sepc );
            text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
            text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
            text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if is_set(PostScript) and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    local options = {};
    
    if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
        options.class = &quot;citation &quot; .. config.CitationClass;
    else
        options.class = &quot;citation&quot;;
    end
    
    if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if #a &gt; 0 then
                for i,v in ipairs(a) do 
                    names[i] = v.last 
                    if i == 4 then break end
                end
            elseif #e &gt; 0 then
                for i,v in ipairs(e) do 
                    names[i] = v.last 
                    if i == 4 then break end                
                end
            end
			names[ #names + 1 ] = Year or anchor_year;	-- Year first for legacy citations
            id = anchorid(names)
        end
        options.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = {};
        text = seterror('empty_citation');
        z.message_tail = {};
    end
    
    if is_set(options.id) then 
        text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    else
        text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    end        

    local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        text = text .. &quot; &quot;;
        for i,v in ipairs( z.message_tail ) do
            if is_set(v[1]) then
                if i == #z.message_tail then
                    text = text .. errorcomment( v[1], v[2] );
                else
                    text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
                end
            end
        end
    end
    
    no_tracking_cats = no_tracking_cats:lower();
    if inArray(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    local suggestions = {};
    local error_text, error_state;

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        args[k] = v;       
    end    

    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            if not validate( k ) then            
                error_text = &quot;&quot;;
                if type( k ) ~= 'string' then
                    -- Exclude empty numbered parameters
                    if v:match(&quot;%S+&quot;) ~= nil then
                        error_text, error_state = seterror( 'text_ignored', {v}, true );
                    end
                elseif validate( k:lower() ) then 
                    error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
                else
                    if #suggestions == 0 then
                        suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
                    end
                    if suggestions[ k:lower() ] ~= nil then
                        error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
                    else
                        error_text, error_state = seterror( 'parameter_ignored', {k}, true );
                    end
                end                  
                if error_text ~= '' then
                    table.insert( z.message_tail, {error_text, error_state} );
                end                
            end
            args[k] = v;
        elseif args[k] ~= nil or (k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z</text>
      <sha1>i9xigzjpy60hbalv36j44343n7td1mf</sha1>
    </revision>
    <revision>
      <id>4666</id>
      <parentid>4665</parentid>
      <timestamp>2013-12-14T19:51:46Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Fix for broken |ref=harv;</comment>
      <origin>4666</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="79174" sha1="kwfrpcv7nwnynwgkw2gicg8fqby7xzd" xml:space="preserve">local z = {
    error_categories = {};
    error_ids = {};
    message_tail = {};
}

-- Include translation message hooks, ID and error handling configuration settings.
local cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );

-- Contains a list of all recognized parameters
local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );

-- Whether variable is set or not
function is_set( var )
    return not (var == nil or var == '');
end

-- First set variable or nil if none
function first_set(...)
    local list = {...};
    for _, var in pairs(list) do
        if is_set( var ) then
            return var;
        end
    end
end

-- Whether needle is in haystack
function inArray( needle, haystack )
    if needle == nil then
        return false;
    end
    for n,v in ipairs( haystack ) do
        if v == needle then
            return n;
        end
    end
    return false;
end

--[[
Categorize and emit an error message when the citation contains one or more deprecated parameters.  Because deprecated parameters (currently |day=, |month=,
|coauthor=, and |coauthors=) aren't related to each other and because these parameters may be concatenated into the variables used by |date= and |author#= (and aliases)
details of which parameter caused the error message are not provided.  Only one error message is emitted regarless of the number of deprecated parameters in the citation.
]]
function deprecated_parameter()
	if true ~= Page_in_deprecated_cat then	-- if we haven't been here before then set a 
		Page_in_deprecated_cat=true;		-- sticky flag so that if there are more than one deprecated parameter the category is added only once
		table.insert( z.message_tail, { seterror( 'deprecated_params', {error_message}, true ) } );		-- add error message
	end
end

-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
    return args and tostring( mw.message.newRawMessage( msg, args ) ) or msg;
end

-- Wraps a string using a message_list configuration taking one argument
function wrap( key, str, lower )
    if not is_set( str ) then
        return &quot;&quot;;
    elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
        str = safeforitalics( str );
    end
    if lower == true then
        return substitute( cfg.messages[key]:lower(), {str} );
    else
        return substitute( cfg.messages[key], {str} );
    end        
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
    local origin = {};
    
    return setmetatable({
        ORIGIN = function( self, k )
            local dummy = self[k]; --force the variable to be loaded.
            return origin[k];
        end
    },
    {
        __index = function ( tbl, k )
            if origin[k] ~= nil then
                return nil;
            end
            
            local args, list, v = args, cfg.aliases[k];
            
            if type( list ) == 'table' then
                v, origin[k] = selectone( args, list, 'redundant_parameters' );
                if origin[k] == nil then
                    origin[k] = ''; -- Empty string, not nil
                end
            elseif list ~= nil then
                v, origin[k] = args[list], list;
            else
                -- maybe let through instead of raising an error?
                -- v, origin[k] = args[k], k;
                error( cfg.messages['unknown_argument_map'] );
            end
            
            -- Empty strings, not nil;
            if v == nil then
                v = cfg.defaults[k] or '';
                origin[k] = '';
            end
            
            tbl = rawset( tbl, k, v );
            return v;
        end,
    });
end

--[[
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three valuse:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
]]
function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
    return wrap( hidden and 'hidden-error' or 'visible-error', content );
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
    local error_state = cfg.error_conditions[ error_id ];
    
    prefix = prefix or &quot;&quot;;
    suffix = suffix or &quot;&quot;;
    
    if error_state == nil then
        error( cfg.messages['undefined_error'] );
    elseif is_set( error_state.category ) then
        table.insert( z.error_categories, error_state.category );
    end
    
    local message = substitute( error_state.message, arguments );
    
    message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
        &quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
        cfg.messages['help page label'] .. &quot;]])&quot;;
    
    z.error_ids[ error_id ] = true;
    if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
            and z.error_ids['citation_missing_title'] then
        return '', false;
    end
    
    message = table.concat({ prefix, message, suffix });
    
    if raw == true then
        return message, error_state.hidden;
    end        
        
    return errorcomment( message, error_state.hidden );
end

-- Formats a wiki style external link
function externallinkid(options)
    local url_string = options.id;
    if options.encode == true or options.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, url_string, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Formats a wiki style internal link
function internallinkid(options)
    return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, options.id, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Format an external link with error checking
function externallink( URL, label, source )
    local error_str = &quot;&quot;;
    if not is_set( label ) then
        label = URL;
        if is_set( source ) then
            error_str = seterror( 'bare_url_missing_title', { wrap( 'parameter', source ) }, false, &quot; &quot; );
        else
            error( cfg.messages[&quot;bare_url_no_origin&quot;] );
        end            
    end
    if not checkurl( URL ) then
        error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
    end
    return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safeforurl( label ), &quot;]&quot;, error_str });
end

-- Formats a link to Amazon
function amazon(id, domain)
    if not is_set(domain) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local handler = cfg.id_handlers['ASIN'];
    return externallinkid({link = handler.link,
        label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
        encode=handler.encode, separator = handler.separator})
end

--[[
Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns true; otherwse, returns false because the embargo has expired or |embargo= not set in this cite.
]]
function is_embargoed(embargo)
	if is_set(embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 and tonumber( embargo_date ) &gt;= tonumber( todays_date ) then	--is embargo date is in the future?
			return true;	-- still embargoed
		end
	end
	return false;			-- embargo expired or |embargo= not set
end

--[[
Formats a PMC and checks for embargoed articles.  The embargo parameter takes a date for a value. If the embargo date is in the future
the PMC identifier will not be linked to the article.  If the embargo specifies a date in the past, or if it is empty or omitted, then
the PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.
]]
function pmc(id, embargo)
	local handler = cfg.id_handlers['PMC'];
    
	local text;

	if is_embargoed(embargo) then
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id;	--still embargoed so no external link
	else
		text = externallinkid({link = handler.link, label = handler.label,			--no embargo date, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    local handler = cfg.id_handlers['DOI'];
    
    local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end
	if ( string.sub(id,1,3) ~= &quot;10.&quot; ) then      
		cat = seterror( 'bad_doi' );
	end
	return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    local handler = cfg.id_handlers['OL'];
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    else
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode}) .. 
            ' ' .. seterror( 'bad_ol' );
    end
end

--[[
Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.
]]
function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and ndashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 didgits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = externallinkid({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. seterror( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[
This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those citations that have defaults.
Also handles the special case where it is desireable to omit the title type from the rendered citation (|type=none).
]]
function set_titletype(cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;					-- if |type=none then type parameter not displayed
		end
		return title_type;						-- if |type= has been set to any other value use that value
	end

	if &quot;pressrelease&quot; == cite_class then		-- if this citation is cite press release
		return &quot;Press release&quot;;					-- display press release annotation

	elseif &quot;speech&quot; == cite_class then			-- if this citation is cite speech
		return &quot;Speech&quot;;						-- display speech annotation
	
	elseif &quot;techreport&quot; == cite_class then		-- if this citation is cite techreport
		return &quot;Technical report&quot;;				-- display techreport annotation
	
	elseif &quot;thesis&quot; == cite_class then			-- if this citation is cite thesis (degree option handled after this function returns)
			return &quot;Thesis&quot;;					-- display simple thesis annotation (without |degree= modification)
	end
end

-- returns a number according to the month in a date: 1 for January, etc.  If not a valid month, returns 0
function get_month_number (month)
local long_months = {['january']=1, ['february']=2, ['march']=3, ['april']=4, ['may']=5, ['june']=6, ['july']=7, ['august']=8, ['september']=9, ['october']=10, ['november']=11, ['december']=12};
local short_months = {['jan']=1, ['feb']=2, ['mar']=3, ['apr']=4, ['may']=5, ['jun']=6, ['jul']=7, ['aug']=8, ['sep']=9, ['oct']=10, ['nov']=11, ['dec']=12};
local temp;
	temp=long_months[month:lower()];
	if temp then return temp; end				-- if month is the long-form name
	temp=short_months[month:lower()];
	if temp then return temp; end				-- if month is the short-form name
	return 0;									-- misspelled or not a month name
end

-- returns true if date has one of the five seasons.  Else false.
function is_valid_season (season)
	if inArray( season, {'winter', 'spring', 'summer', 'fall', 'autumn'} ) then
		return true;
	end
	return false;
end

--[[
Returns true if day is less than or equal to the number of days in month; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap years before 1582 and Gregorian leap years after 1582.
Where the two calendars overlap (1582 to approximately 1923) dates are assumed to be Gregorian.
]]
function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if (2==month) then							-- if February
		month_length = 28;						-- then 28 days unless
		if 1582 &gt; tonumber(year) then			-- Julian calendar
			if 0==(year%4) then
				month_length = 29;
			end
		else									-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then	-- is a leap year?
				month_length = 29;				-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end

--Check a pair of months or seasons to see if both are valid members of a month or season pair.
--TODO: Check order to make sure that the left month/season properly precedes the right month/season

function is_valid_month_season_range(range_start, range_end)
	if 0 == get_month_number (range_start:lower()) then			-- is this a month range?
		if true == is_valid_season (range_start:lower()) then	-- not a month range, is this a season range?
			return is_valid_season (range_end:lower());			-- range_start is season; return true if range_end also a season; else false
		end
		return false;		-- range_start is not a month or a season
	end
	if 0 == get_month_number (range_end:lower()) then			-- range_start is a month; is range_end also a  month?
		return false;											-- not a month range
	end
	return true;
end

--[[
Check date format to see that it is one of the formats approved by MOS:DATE: MMMM D, YYYY; D MMMM YYYY; MMMM YYYY; YYYY-MM-DD; YYYY.
Additionally, check the date to see that it is a real date: no 31 in 30-day months; no 29 February when not a leap year.  Months, both long-form and three
character abbreviations, and seasons must be spelled correctly.

If the date fails the fomat tests, this function returns false but does not return values for anchor_year and COinS_date.  When this happens, the date parameter is
used in the COinS metadata and the CITEREF identifier gets its year from the year parameter if present.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is date_string without anchor_year disambiguator if any
]]
function check_date (date_string)
	local year;
	local month;
	local day;
	local anchor_year;
	local coins_date;

	if date_string:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then			-- Year-initial numerical year month day format
		coins_date = date_string:match(&quot;%d%d%d%d%-%d%d%-%d%d&quot;);
		year, month, day=string.match(date_string, &quot;(%d%d%d%d)%-(%d%d)%-(%d%d)&quot;);
		anchor_year = year;
		month=tonumber(month);
		if 12 &lt; month or 1 &gt; month then return false; end

	elseif date_string:match(&quot;^%a+%s*%d%d*%s*,%s*%d%d%d%d%a?$&quot;) then	-- month-initial: month day, year
		coins_date = date_string:match(&quot;%a+%s*%d%d*%s*,%s*%d%d%d%d&quot;);
		month, day, anchor_year, year=string.match(date_string, &quot;(%a+)%s*(%d%d*)%s*,%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month:lower());
		if 0 == month then return false; end					-- return false if month text isn't one of the twelve months
				
	elseif date_string:match(&quot;^%d%d*%s*%a+%s*%d%d%d%d%a?$&quot;) then		-- date-initial: day month year
		coins_date = date_string:match(&quot;%d%d*%s*%a+%s*%d%d%d%d&quot;);
		day, month, anchor_year, year=string.match(date_string, &quot;(%d%d*)%s*(%a+)%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month:lower());
		if 0 == month then return false; end					-- return false if month text isn't one of the twelve months

	elseif mw.ustring.match (date_string, &quot;^%a+%s*[%s%-/–]%s*%a+%s*%d%d%d%d%a?$&quot;) then		-- month/season range year
		local month2
		coins_date = mw.ustring.match (date_string, &quot;%a+%s*[%s%-/–]%s*%a+%s*%d%d%d%d&quot;);
		coins_date= mw.ustring.gsub( coins_date, &quot;–&quot;, &quot;-&quot; );	-- replace ndash with hyphen
		month, month2, anchor_year, year=mw.ustring.match (date_string, &quot;(%a+)%s*[%s%-/–]%s*(%a+)%s*((%d%d%d%d)%a?)&quot;);
		day=0;													-- mark day as not used
		if false == is_valid_month_season_range(month, month2) then
			return false;
		end
		
	elseif date_string:match(&quot;^%a+%s*%d%d%d%d%a?$&quot;) then		-- month/season year
		coins_date = date_string:match(&quot;%a+%s*%d%d%d%d&quot;);
		month, anchor_year, year=string.match(date_string, &quot;(%a+)%s*((%d%d%d%d)%a?)&quot;);
		day=0;													-- mark day as not used
		local season=month;										-- copy 
		month = get_month_number (month:lower());
		if month == 0 then										-- if month text isn't one of the twelve months, might be a season
			if false == is_valid_season (season:lower()) then
				return false;									-- return false not a month or one of the five seasons
			end
		end

	elseif date_string:match(&quot;^%d%d%d%d?%a?$&quot;) then			-- year; here accept either YYY or YYYY
		coins_date = date_string:match(&quot;^%d%d%d%d?&quot;);
		anchor_year, year=string.match(date_string, &quot;((%d%d%d%d?)%a?)&quot;);
		month, day = 0, 0;										-- mark day and month as not used
	else
		return false;											-- date format not one of the MOS:DATE approved formats
	end

	if 0~=month and 0~=day then									-- check year month day dates for validity
		if false==is_valid_date(year,month,day) then
			return false;										-- date string is not a real date return false; unset anchor_year and coins_date
		end
	end
	
	return true, anchor_year, coins_date;						-- format is good and date string represents a real date
end	

--[[
Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true and values for anchor_year (used in CITEREF identifiers) and COinS_date (used in the COinS metadata).  The |date= parameter test is unique.  This function only 
accepts anchor_year and COinS_date results from the |date= parameter test and |date= is the only date-holding parameter that is allowed to contain the no-date keywords
&quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.
]]

function dates(date_parameters_list)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local error_message =&quot;&quot;;
	local good_date=false;
	
	for k, v in pairs(date_parameters_list) do		-- for each date-holding parameter in the list
		if is_set(v) then							-- if the parameter has a value
			if v:match(&quot;^c%.%s%d%d%d%d?%a?$&quot;) then	-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				if 'date'==k then
					good_date, anchor_year, COinS_date = true, v:match(&quot;((c%.%s%d%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
				elseif 'year'==k then
					good_date =  true;
				end
			elseif 'year'==k then					-- if the parameter is |year= (but not c. year)
				if v:match(&quot;^%d%d%d%d?%a?$&quot;) then	-- year with or without CITEREF disambiguator
					good_date =  true;
				end
			elseif 'date'==k then					-- if the parameter is |date=
				if v:match(&quot;n%.d%.%a?&quot;) then		-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v:match(&quot;nd%a?$&quot;) then		-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v);	-- go test the date
				end
			else									-- any other date-holding parameter
				good_date = check_date (v);			-- go test the date
			end
			if false==good_date then				-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then		-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;	-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;	-- add the failed parameter
			end
		end
	end
	if is_set(error_message) then
		table.insert( z.message_tail, { seterror( 'bad_date', {error_message}, true ) } );	-- add this error message
	end

	return anchor_year, COinS_date;		-- and done
end

--[[
Determines whether a URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
    -- Protocol-relative or URL scheme
    return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
    return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

--[[
ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in checkisbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.
]]
function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of bytes
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end	-- isbn13 begins with 978 or 979
		isbn_str = { isbn_str:byte(1, len) };
		for i, v in ipairs( isbn_str ) do
			temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
		end
		return temp % 10 == 0;
	end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
    return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
        return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
    end));
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if not is_set(str) then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        
        -- Remove newlines as they break italics.
        return str:gsub( '\n', ' ' );
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    if maximum ~= nil and maximum &lt; 1 then return &quot;&quot;, 0; end
    
    for i,person in ipairs(people) do
        if is_set(person.last) then
            local mask = person.mask
            local one
            local sep_one = sep;
            if maximum ~= nil and i &gt; maximum then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask;
                    sep_one = &quot; &quot;;
                end
            else
                one = person.last
                local first = person.first
                if is_set(first) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if is_set(person.link) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert( text, one )
            table.insert( text, sep_one )
        end
    end

    local count = #text / 2;
    if count &gt; 0 then 
        if count &gt; 1 and is_set(lastauthoramp) and not etal then
            text[#text-2] = &quot; &amp; &quot;;
        end
        text[#text] = nil; 
    end
    
    local result = table.concat(text) -- construct list
    if etal then 
        local etal_text = cfg.messages['et al'];
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result = 
        '&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
    end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
    return &quot;CITEREF&quot; .. table.concat( options );
end

-- Gets name list from the input arguments
function extractnames(args, list_name)
    local names = {};
    local i = 1;
    local last;
    
    while true do
        last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );
        if not is_set(last) then
            -- just in case someone passed in an empty parameter
            break;
        end
        names[i] = {
            last = last,
            first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i ),
            link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ),
            mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i )
        };
        i = i + 1;
    end
    return names;
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
    local id_list = {};
    for k, v in pairs( cfg.id_handlers ) do    
        v = selectone( args, v.parameters, 'redundant_parameters' );
        if is_set(v) then id_list[k] = v; end
    end
    return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
    local new_list, handler = {};
    
    function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
    
    for k, v in pairs( id_list ) do
        -- fallback to read-only cfg
        handler = setmetatable( { ['id'] = v }, fallback(k) );
        
        if handler.mode == 'external' then
            table.insert( new_list, {handler.label, externallinkid( handler ) } );
        elseif handler.mode == 'internal' then
            table.insert( new_list, {handler.label, internallinkid( handler ) } );
        elseif handler.mode ~= 'manual' then
            error( cfg.messages['unknown_ID_mode'] );
        elseif k == 'DOI' then
            table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
        elseif k == 'ASIN' then
            table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
        elseif k == 'OL' then
            table.insert( new_list, {handler.label, openlibrary( v ) } );
        elseif k == 'PMC' then
            table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
        elseif k == 'ISSN' then
        	table.insert( new_list, {handler.label, issn( v ) } );
        elseif k == 'ISBN' then
            local ISBN = internallinkid( handler );
            if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
                ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
            end
            table.insert( new_list, {handler.label, ISBN } );                
        else
            error( cfg.messages['unknown_manual_ID'] );
        end
    end
    
    function comp( a, b )	-- used in following table.sort()
        return a[1] &lt; b[1];
    end
    
    table.sort( new_list, comp );
    for k, v in ipairs( new_list ) do
        new_list[k] = v[2];
    end
    
    return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
    local value = nil;
    local selected = '';
    local error_list = {};
    
    if index ~= nil then index = tostring(index); end
    
    -- Handle special case of &quot;#&quot; replaced by empty string
    if index == '1' then
        for _, v in ipairs( possible ) do
            v = v:gsub( &quot;#&quot;, &quot;&quot; );
            if is_set(args[v]) then
                if value ~= nil and selected ~= v then
                    table.insert( error_list, v );
                else
                    value = args[v];
                    selected = v;
                end
            end
        end        
    end
    
    for _, v in ipairs( possible ) do
        if index ~= nil then
            v = v:gsub( &quot;#&quot;, index );
        end
        if is_set(args[v]) then
            if value ~= nil and selected ~=  v then
                table.insert( error_list, v );
            else
                value = args[v];
                selected = v;
            end
        end
    end
    
    if #error_list &gt; 0 then
        local error_str = &quot;&quot;;
        for _, k in ipairs( error_list ) do
            if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
            error_str = error_str .. wrap( 'parameter', k );
        end
        if #error_list &gt; 1 then
            error_str = error_str .. cfg.messages['parameter-final-separator'];
        else
            error_str = error_str .. cfg.messages['parameter-pair-separator'];
        end
        error_str = error_str .. wrap( 'parameter', selected );
        table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
    end
    
    return value, selected;
end

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
function COinS(data)
    if 'table' ~= type(data) or nil == next(data) then
        return '';
    end
    
    local ctx_ver = &quot;Z39.88-2004&quot;;
    
    -- treat table strictly as an array with only set values.
    local OCinSoutput = setmetatable( {}, {
        __newindex = function(self, key, value)
            if is_set(value) then
                rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
            end
        end
    });
    
    if is_set(data.Chapter) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Chapter;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    elseif is_set(data.Periodical) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
        OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    else
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
    end
    
    OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
    OCinSoutput[&quot;rft.date&quot;] = data.Date;
    OCinSoutput[&quot;rft.series&quot;] = data.Series;
    OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
    OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
    OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
    OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
    OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
    
    for k, v in pairs( data.ID_list ) do
        local id, value = cfg.id_handlers[k].COinS;
        if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
        if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
            OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
        else
            OCinSoutput[ id ] = value;
        end
    end
    
    local last, first;
    for k, v in ipairs( data.Authors ) do
        last, first = v.last, v.first;
        if k == 1 then
            if is_set(last) then
                OCinSoutput[&quot;rft.aulast&quot;] = last;
            end
            if is_set(first) then 
                OCinSoutput[&quot;rft.aufirst&quot;] = first;
            end
        end
        if is_set(last) and is_set(first) then
            OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
        elseif is_set(last) then
            OCinSoutput[&quot;rft.au&quot;] = last;
        end
    end
    
    OCinSoutput.rft_id = data.URL;
    OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
    OCinSoutput = setmetatable( OCinSoutput, nil );
    
    -- sort with version string always first, and combine.
    table.sort( OCinSoutput );
    table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
    return table.concat(OCinSoutput, &quot;&amp;&quot;);
end

--[[
This is the main function doing the majority of the citation
formatting.
]]
function citation0( config, args)
    --[[ 
    Load Input Parameters
    The argment_wrapper facillitates the mapping of multiple
    aliases to single internal variable.
    ]]
    local A = argument_wrapper( args );

    local i 
    local PPrefix = A['PPrefix']
    local PPPrefix = A['PPPrefix']
    if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = A['Authors'];
    local a = extractnames( args, 'AuthorList' );

    local Coauthors = A['Coauthors'];
    local Others = A['Others'];
    local Editors = A['Editors'];
    local e = extractnames( args, 'EditorList' );

    local Year = A['Year'];
    local PublicationDate = A['PublicationDate'];
    local OrigYear = A['OrigYear'];
    local Date = A['Date'];
    local LayDate = A['LayDate'];
    ------------------------------------------------- Get title data
    local Title = A['Title'];
    local BookTitle = A['BookTitle'];
    local Conference = A['Conference'];
    local TransTitle = A['TransTitle'];
    local TitleNote = A['TitleNote'];
    local TitleLink = A['TitleLink'];
    local Chapter = A['Chapter'];
    local ChapterLink = A['ChapterLink'];
    local TransChapter = A['TransChapter'];
    local TitleType = A['TitleType'];
    local Degree = A['Degree'];
    local Docket = A['Docket'];
    local ArchiveURL = A['ArchiveURL'];
    local URL = A['URL']
    local URLorigin = A:ORIGIN('URL');
    local ChapterURL = A['ChapterURL'];
    local ChapterURLorigin = A:ORIGIN('ChapterURL');
    local ConferenceURL = A['ConferenceURL'];
    local ConferenceURLorigin = A:ORIGIN('ConferenceURL');
    local Periodical = A['Periodical'];

--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped

All other combinations of |encyclopedia, |title, and |article are not modified
]]
	if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
		if is_set(Periodical) then					-- Periodical is set when |encyclopedia is set
			if is_set(Title) then
				if not is_set(Chapter) then
					Chapter = Title;				-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					TransChapter = TransTitle;
					Title = Periodical;
					Periodical = '';				-- redundant so unset
					TransTitle = '';				-- redundant so unset
				end
			else									-- |title not set
				Title = Periodical;					-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';					-- redundant so unset
			end
		end
	end

local Series = A['Series'];
    local Volume = A['Volume'];
    local Issue = A['Issue'];
    local Position = '';
    local Page, Pages, At, page_type;
    
    Page = A['Page'];
    Pages = hyphentodash( A['Pages'] );
    At = A['At'];
    
    if is_set(Page) then
        if is_set(Pages) or is_set(At) then
            Page = Page .. &quot; &quot; .. seterror('extra_pages');
            Pages = '';
            At = '';
        end
    elseif is_set(Pages) then
        if is_set(At) then
            Pages = Pages .. &quot; &quot; .. seterror('extra_pages');
            At = '';
        end
    end    
    
    local Edition = A['Edition'];
    local PublicationPlace = A['PublicationPlace']
    local Place = A['Place'];
    
    if not is_set(PublicationPlace) and is_set(Place) then
        PublicationPlace = Place;
    end
    
    if PublicationPlace == Place then Place = ''; end
    
    local PublisherName = A['PublisherName'];
    local RegistrationRequired = A['RegistrationRequired'];
    local SubscriptionRequired = A['SubscriptionRequired'];
    local Via = A['Via'];
    local AccessDate = A['AccessDate'];
    local ArchiveDate = A['ArchiveDate'];
    local Agency = A['Agency'];
    local DeadURL = A['DeadURL']
    local Language = A['Language'];
    local Format = A['Format'];
    local Ref = A['Ref'];
    
    local DoiBroken = A['DoiBroken'];
	
-- Special case for cite techreport.
	local ID = A['ID'];
	if (config.CitationClass == &quot;techreport&quot;) then	-- special case for cite techreport
		if is_set(Issue) then						-- cite techreport uses 'number', which other citations aliase to 'issue'
			if not is_set(ID) then					-- can we use ID for the &quot;number&quot;?
				ID = Issue;							-- yes, use it
				Issue = &quot;&quot;;							-- unset Issue so that &quot;number&quot; isn't duplicated in the rendered citation or COinS metadata
			else									-- can't use ID so emit error message
				ID = ID .. &quot; &quot; .. seterror('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
			end
		end	
	end	
			
    local ASINTLD = A['ASINTLD'];
    local IgnoreISBN = A['IgnoreISBN'];
    local Embargo = A['Embargo'];

    local ID_list = extractids( args );
    
    local Quote = A['Quote'];
    local PostScript = A['PostScript'];
    local LayURL = A['LayURL'];
    local LaySource = A['LaySource'];
    local Transcript = A['Transcript'];
    local TranscriptURL = A['TranscriptURL'] 
    local TranscriptURLorigin = A:ORIGIN('TranscriptURL');
    local sepc = A['Separator'];
    local LastAuthorAmp = A['LastAuthorAmp'];
    local no_tracking_cats = A['NoTracking'];

    local use_lowercase = ( sepc ~= '.' );
    local this_page = mw.title.getCurrentTitle();  --Also used for COinS and for language
    
    if not is_set(no_tracking_cats) then
        for k, v in pairs( cfg.uncategorized_namespaces ) do
            if this_page.nsText == v then
                no_tracking_cats = &quot;true&quot;;
                break;
            end
        end
    end

	local anchor_year;		-- used in the CITEREF identifier
	local COinS_date;		-- used in the COinS metadata

-- legacy: promote concatenation of |day=, |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set(Date) then
		Date = Year;						-- promote Year to Date
		Year = nil;							-- make nil so Year as empty string isn't used for CITEREF
		if is_set(Date) then
			local Month = A['Month'];
			if is_set(Month) then
				Date = Month .. &quot; &quot; .. Date;
				local Day = A['Day']
				if is_set(Day) then Date = Day .. &quot; &quot; .. Date end
			end
		elseif is_set(PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;			-- promonte PublicationDate to Date
			PublicationDate = '';			-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end	-- if PublicationDate is same as Date, don't display in rendered citation

-- Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates.
-- TODO: 2013-10-27: AirDate is nil when dates() is called because it hasn't been set yet.  Move the call to dates() or set AirDate earlier.
	anchor_year, COinS_date = dates({['accessdate']=AccessDate, ['airdate']=AirDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
		['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.

	--Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set
	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_embargoed(Embargo) then
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];	-- set url to be the same as the PMC external link if not embargoed
		end
	end

    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if is_set(BookTitle) then
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = BookTitle;
        TitleLink = '';
        TransTitle = '';
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = A['AirDate'];
        local SeriesLink = A['SeriesLink'];
        local Season = A['Season'];
        local SeriesNumber = A['SeriesNumber'];
        local Network = A['Network'];
        local Station = A['Station'];
        local s, n = {}, {};
        local Sep = (first_set(A[&quot;SeriesSeparator&quot;], A[&quot;Separator&quot;]) or &quot;&quot;) .. &quot; &quot;;
        
        if is_set(Issue) then table.insert(s, cfg.messages[&quot;episode&quot;] .. &quot; &quot; .. Issue); Issue = ''; end
        if is_set(Season) then table.insert(s, cfg.messages[&quot;season&quot;] .. &quot; &quot; .. Season); end
        if is_set(SeriesNumber) then table.insert(s, cfg.messages[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber); end
        if is_set(Network) then table.insert(n, Network); end
        if is_set(Station) then table.insert(n, Station); end
        
        Date = Date or AirDate;
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = Series;
        TitleLink = SeriesLink;
        TransTitle = '';
        
        Series = table.concat(s, Sep);
        ID = table.concat(n, Sep);
    end
    
    -- COinS metadata (see &lt;http://ocoins.info/&gt;) for
    -- automated parsing of citation information.
    local OCinSoutput = COinS{
        ['Periodical'] = Periodical,
        ['Chapter'] = Chapter,
        ['Title'] = Title,
        ['PublicationPlace'] = PublicationPlace,
        ['Date'] = first_set(COinS_date, Date),		-- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here?  Should we be including invalid dates in metadata?
        ['Series'] = Series,
        ['Volume'] = Volume,
        ['Issue'] = Issue,
        ['Pages'] = first_set(Page, Pages, At),
        ['Edition'] = Edition,
        ['PublisherName'] = PublisherName,
        ['URL'] = first_set( URL, ChapterURL ),
        ['Authors'] = a,
        ['ID_list'] = ID_list,
        ['RawPage'] = this_page.prefixedText,
    };

    if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = '';
        TitleLink = '';
        TransTitle = '';
    end

    -- Now perform various field 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 not is_set(Authors) then
        local Maximum = tonumber( A['DisplayAuthors'] );
        
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #a == 9 then 
            Maximum = 8;
            table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
        elseif not is_set(Maximum) then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = A[&quot;AuthorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;AuthorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A[&quot;AuthorFormat&quot;],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if is_set(Coauthors) then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
        
        Authors = listpeople(control, a) 
    end

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { seterror('coauthors_missing_author', {}, true) } );	-- emit error message
	end

    local EditorCount
    if not is_set(Editors) then
        local Maximum = tonumber( A['DisplayEditors'] );
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #e == 4 then 
            Maximum = 3;
            table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
        elseif not is_set(Maximum) then
            Maximum = #e + 1;
        end

        local control = { 
            sep = A[&quot;EditorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;EditorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A['EditorFormat'],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };

        Editors, EditorCount = listpeople(control, e);
    else
        EditorCount = 1;
    end

    local Cartography = &quot;&quot;;
    local Scale = &quot;&quot;;
    if config.CitationClass == &quot;map&quot; then
        if not is_set( Authors ) and is_set( PublisherName ) then
            Authors = PublisherName;
            PublisherName = &quot;&quot;;
        end
        Cartography = A['Cartography'];
        if is_set( Cartography ) then
            Cartography = sepc .. &quot; &quot; .. wrap( 'cartography', Cartography, use_lowercase );
        end        
        Scale = A['Scale'];
        if is_set( Scale ) then
            Scale = sepc .. &quot; &quot; .. Scale;
        end        
    end
    
    if  not is_set(URL) and
        not is_set(ChapterURL) and
        not is_set(ArchiveURL) and
        not is_set(ConferenceURL) and
        not is_set(TranscriptURL) then
        
        -- Test if cite web is called without giving a URL
        if ( config.CitationClass == &quot;web&quot; ) then
            table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
        end
        
        -- Test if accessdate is given without giving a URL
        if is_set(AccessDate) then
            table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
            AccessDate = '';
        end
        
        -- Test if format is given without giving a URL
        if is_set(Format) then
            Format = Format .. seterror( 'format_missing_url' );
        end
    end
    
    -- Test if citation has no title
    if  not is_set(Chapter) and
        not is_set(Title) and
        not is_set(Periodical) and
        not is_set(Conference) and
        not is_set(TransTitle) and
        not is_set(TransChapter) then
        table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
    end
    
    Format = is_set(Format) and &quot; (&quot; .. Format .. &quot;)&quot; or &quot;&quot;;
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if is_set( ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
            URLorigin = A:ORIGIN('ArchiveURL')
        end
    end
    
    -- Format chapter / article title
    if is_set(Chapter) and is_set(ChapterLink) then 
        Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot;;
    end
    if is_set(Periodical) and is_set(Title) then
        Chapter = wrap( 'italic-title', Chapter );
        TransChapter = wrap( 'trans-italic-title', TransChapter );
    else
        Chapter = wrap( 'quoted-title', Chapter );
        TransChapter = wrap( 'trans-quoted-title', TransChapter );
    end
    
    local TransError = &quot;&quot;
    if is_set(TransChapter) then
        if not is_set(Chapter) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
        else
            TransChapter = &quot; &quot; .. TransChapter;
        end
    end
    
    Chapter = Chapter .. TransChapter;
    
    if is_set(Chapter) then
        if not is_set(ChapterLink) then
            if is_set(ChapterURL) then
                Chapter = externallink( ChapterURL, Chapter ) .. TransError;
                if not is_set(URL) then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif is_set(URL) then 
                Chapter = externallink( URL, Chapter ) .. TransError .. Format;
                URL = &quot;&quot;;
                Format = &quot;&quot;;
            else
                Chapter = Chapter .. TransError;
            end            
        elseif is_set(ChapterURL) then
            Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. 
                TransError;
        else
            Chapter = Chapter .. TransError;
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    elseif is_set(ChapterURL) then
        Chapter = &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. sepc .. &quot; &quot;;
    end        
    
    -- Format main title.
    if is_set(TitleLink) and is_set(Title) then
        Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
    end
    
    if is_set(Periodical) then
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    elseif inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;pressrelease&quot;,&quot;conference&quot;}) and
            not is_set(Chapter) then
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    else
        Title = wrap( 'italic-title', Title );
        TransTitle = wrap( 'trans-italic-title', TransTitle );
    end
    
    TransError = &quot;&quot;;
    if is_set(TransTitle) then
        if not is_set(Title) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
        else
            TransTitle = &quot; &quot; .. TransTitle;
        end
    end
    
    Title = Title .. TransTitle;
    
    if is_set(Title) then
        if not is_set(TitleLink) and is_set(URL) then 
            Title = externallink( URL, Title ) .. TransError .. Format       
            URL = &quot;&quot;;
            Format = &quot;&quot;;
        else
            Title = Title .. TransError;
        end
    end
    
    if is_set(Place) then
        Place = &quot; &quot; .. wrap( 'written', Place, use_lowercase ) .. sepc .. &quot; &quot;;
    end
    
    if is_set(Conference) then
        if is_set(ConferenceURL) then
            Conference = externallink( ConferenceURL, Conference );
        end
        Conference = sepc .. &quot; &quot; .. Conference
    elseif is_set(ConferenceURL) then
        Conference = sepc .. &quot; &quot; .. externallink( ConferenceURL, nil, ConferenceURLorigin );
    end
    
    if not is_set(Position) then
        local Minutes = A['Minutes'];
        if is_set(Minutes) then
            Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
        else
            local Time = A['Time'];
            if is_set(Time) then
                local TimeCaption = A['TimeCaption']
                if not is_set(TimeCaption) then
                    TimeCaption = cfg.messages['event'];
                    if sepc ~= '.' then
                        TimeCaption = TimeCaption:lower();
                    end
                end
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
            end
        end
    else
        Position = &quot; &quot; .. Position;
        At = '';
    end
    
    if not is_set(Page) then
        if is_set(Pages) then
            if is_set(Periodical) and
                not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;}) then
                Pages = &quot;: &quot; .. Pages;
            elseif tonumber(Pages) ~= nil then
                Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
            else
                Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
            end
        end
    else
        if is_set(Periodical) and
            not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;}) then
            Page = &quot;: &quot; .. Page;
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page;
        end
    end
    
    At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
    Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
    if config.CitationClass == 'map' then
        local Section = A['Section'];
        local Inset = A['Inset'];
        if first_set( Pages, Page, At ) ~= nil or sepc ~= '.' then
            if is_set( Section ) then
                Section = &quot;, &quot; .. wrap( 'section', Section, true );
            end
            if is_set( Inset ) then
                Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
            end
        else
            if is_set( Section ) then
                Section = sepc .. &quot; &quot; .. wrap( 'section', Section, use_lowercase );
                if is_set( Inset ) then
                    Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
                end
            elseif is_set( Inset ) then
                Inset = sepc .. &quot; &quot; .. wrap( 'inset', Inset, use_lowercase );
            end            
        end            
        At = At .. Section .. Inset;        
    end    

	--[[Look in the list of iso639-1 language codes to see if the value provided in the language parameter matches one of them.  If a match is found, 
	use that value; if not, then use the value that was provided with the language parameter.
	
	Categories are assigned in a manner similar to the {{xx icon}} templates - categorizes only mainspace citations and only when the language code is not 'en' (English).
	]]
	if is_set (Language) then
		local name = cfg.iso639_1[Language:lower()];		-- get the language name if Language parameter has a valid iso 639-1 code
		if nil == name then
			Language=&quot; &quot; .. wrap( 'language', Language );	-- no match, use parameter's value
		else
			if 0 == this_page.namespace and 'en' ~= Language:lower() then	--found a match; is this page main / article space and English not the language?
				Language=&quot; &quot; .. wrap( 'language', name .. '[[Category:Articles with ' .. name .. '-language external links]]' );	-- in main space and not English: categorize
			else
				Language=&quot; &quot; .. wrap( 'language', name );	--not in mainspace or language is English so don't categorize
			end
		end
	else
		Language=&quot;&quot;;	-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;

-- handle type parameter for those CS1 citations that have default values

	if inArray(config.CitationClass, {&quot;pressrelease&quot;,&quot;techreport&quot;,&quot;thesis&quot;, &quot;speech&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then	-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then					-- if type parameter is specified
		TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot;;	-- display it in parentheses
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
    Edition = is_set(Edition) and (&quot; &quot; .. wrap( 'edition', Edition )) or &quot;&quot;;
    Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
    Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
    OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
    Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;
    
    if is_set(Volume) then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume;
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
        end
    end
    
    ------------------------------------ totally unrelated data
    --[[ Loosely mimic {{subscription required}} template; Via parameter identifies a delivery source that is not the publisher; these sources often, but not always, exist
    behind a registration or paywall.  So here, we've chosen to decouple via from subscription (via has never been part of the registration required template).
    
    Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link note is displayed. There are no error messages for this condition.
    ]]
    if is_set(Via) then
        Via = &quot; &quot; .. wrap( 'via', Via );
    end

	if is_set(SubscriptionRequired) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription']; --here when 'via' parameter not used but 'subscription' is
    elseif is_set(RegistrationRequired) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration']; --here when 'via' and 'subscription' parameters not used but 'registration' is
    end

    if is_set(AccessDate) then
        local retrv_text = &quot; &quot; .. cfg.messages['retrieved']
        if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
        AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
            .. substitute( retrv_text, {AccessDate} ) .. '&lt;/span&gt;'
    end
    
    if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end

    
    ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo} );

    if is_set(URL) then
        URL = &quot; &quot; .. externallink( URL, nil, URLorigin );
    end

    if is_set(Quote) then
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        Quote = sepc ..&quot; &quot; .. wrap( 'quoted-text', Quote ); 
        PostScript = &quot;&quot;;
    elseif PostScript:lower() == &quot;none&quot; then
        PostScript = &quot;&quot;;
    end
    
    local Archived
    if is_set(ArchiveURL) then
        if not is_set(ArchiveDate) then
            ArchiveDate = seterror('archive_missing_date');
        end
        if &quot;no&quot; == DeadURL then
            local arch_text = cfg.messages['archived'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
                { externallink( ArchiveURL, arch_text ), ArchiveDate } );
            if not is_set(OriginalURL) then
                Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url');                               
            end
        elseif is_set(OriginalURL) then
            local arch_text = cfg.messages['archived-dead'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text,
                { externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
        else
            local arch_text = cfg.messages['archived-missing'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
                { seterror('archive_missing_url'), ArchiveDate } );
        end
    else
        Archived = &quot;&quot;
    end
    
    local Lay
    if is_set(LayURL) then
        if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
        if is_set(LaySource) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot;;
        else
            LaySource = &quot;&quot;;
        end
        if sepc == '.' then
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;;
    end
    
    if is_set(Transcript) then
        if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
    elseif is_set(TranscriptURL) then
        Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
    end
    
    local Publisher;
    if is_set(Periodical) and
        not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;}) then
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end
        elseif is_set(PublicationPlace) then
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if is_set(PublicationDate) then
            if is_set(Publisher) then
                Publisher = Publisher .. &quot;, &quot; .. wrap( 'published', PublicationDate );
            else
                Publisher = PublicationDate;
            end
        end
        if is_set(Publisher) then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if is_set(PublicationDate) then
            PublicationDate = &quot; (&quot; .. wrap( 'published', PublicationDate ) .. &quot;)&quot;;
        end
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif is_set(PublicationPlace) then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    
    -- Several of the above rely upon detecting this as nil, so do it last.
    if is_set(Periodical) then
        if is_set(Title) or is_set(TitleNote) then 
            Periodical = sepc .. &quot; &quot; .. wrap( 'italic-title', Periodical ) 
        else 
            Periodical = wrap( 'italic-title', Periodical )
        end
    end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if inArray(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
        if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, 
            Language, Cartography, Edition, Publisher, Agency, Volume, Issue}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, Language, 
            Volume, Issue, Others, Cartography, Edition, Publisher, Agency}, sepc );
    end
    
    if #ID_list &gt; 0 then
        ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
    else
        ID_list = ID;
    end
    
    local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
    local text;
    local pgtext = Position .. Page .. Pages .. At;
    
    if is_set(Authors) then
        if is_set(Coauthors) then
            Authors = Authors .. A['AuthorSeparator'] .. &quot; &quot; .. Coauthors
        end
        if is_set(Date) then
            Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        elseif string.sub(Authors,-1,-1) == sepc then
            Authors = Authors .. &quot; &quot;
        else
            Authors = Authors .. sepc .. &quot; &quot;
        end
        if is_set(Editors) then
            local in_text = &quot; &quot;;
            local post_text = &quot;&quot;;
            if is_set(Chapter) then
                in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
            else
                if EditorCount &lt;= 1 then
                    post_text = &quot;, &quot; .. cfg.messages['editor'];
                else
                    post_text = &quot;, &quot; .. cfg.messages['editors'];
                end
            end 
            if (sepc ~= '.') then in_text = in_text:lower() end
            Editors = in_text .. Editors .. post_text;
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = Editors .. &quot; &quot;
                else Editors = Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif is_set(Editors) then
        if is_set(Date) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
            else
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if is_set(Date) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end
        if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
            text = safejoin( {Chapter, Place, tcommon}, sepc );
            text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
            text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
            text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if is_set(PostScript) and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    local options = {};
    
    if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
        options.class = &quot;citation &quot; .. config.CitationClass;
    else
        options.class = &quot;citation&quot;;
    end
    
    if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if #a &gt; 0 then
                for i,v in ipairs(a) do 
                    names[i] = v.last 
                    if i == 4 then break end
                end
            elseif #e &gt; 0 then
                for i,v in ipairs(e) do 
                    names[i] = v.last 
                    if i == 4 then break end                
                end
            end
			names[ #names + 1 ] = first_set(Year, anchor_year);	-- Year first for legacy citations
--			names[ #names + 1 ] = Year or anchor_year;	-- Year first for legacy citations
            id = anchorid(names)
        end
        options.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = {};
        text = seterror('empty_citation');
        z.message_tail = {};
    end
    
    if is_set(options.id) then 
        text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    else
        text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    end        

    local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        text = text .. &quot; &quot;;
        for i,v in ipairs( z.message_tail ) do
            if is_set(v[1]) then
                if i == #z.message_tail then
                    text = text .. errorcomment( v[1], v[2] );
                else
                    text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
                end
            end
        end
    end
    
    no_tracking_cats = no_tracking_cats:lower();
    if inArray(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    local suggestions = {};
    local error_text, error_state;

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        args[k] = v;       
    end    

    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            if not validate( k ) then            
                error_text = &quot;&quot;;
                if type( k ) ~= 'string' then
                    -- Exclude empty numbered parameters
                    if v:match(&quot;%S+&quot;) ~= nil then
                        error_text, error_state = seterror( 'text_ignored', {v}, true );
                    end
                elseif validate( k:lower() ) then 
                    error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
                else
                    if #suggestions == 0 then
                        suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
                    end
                    if suggestions[ k:lower() ] ~= nil then
                        error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
                    else
                        error_text, error_state = seterror( 'parameter_ignored', {k}, true );
                    end
                end                  
                if error_text ~= '' then
                    table.insert( z.message_tail, {error_text, error_state} );
                end                
            end
            args[k] = v;
        elseif args[k] ~= nil or (k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z</text>
      <sha1>kwfrpcv7nwnynwgkw2gicg8fqby7xzd</sha1>
    </revision>
    <revision>
      <id>4667</id>
      <parentid>4666</parentid>
      <timestamp>2014-02-15T11:15:17Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4667</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="85565" sha1="f65bf7r68qmxgjvm1u3t29b3esods4l" xml:space="preserve">local z = {
    error_categories = {};
    error_ids = {};
    message_tail = {};
}

-- Include translation message hooks, ID and error handling configuration settings.
local cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );

-- Contains a list of all recognized parameters
local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );

-- Whether variable is set or not
function is_set( var )
    return not (var == nil or var == '');
end

-- First set variable or nil if none
function first_set(...)
    local list = {...};
    for _, var in pairs(list) do
        if is_set( var ) then
            return var;
        end
    end
end

-- Whether needle is in haystack
function inArray( needle, haystack )
    if needle == nil then
        return false;
    end
    for n,v in ipairs( haystack ) do
        if v == needle then
            return n;
        end
    end
    return false;
end

--[[
Categorize and emit an error message when the citation contains one or more deprecated parameters.  Because deprecated parameters (currently |day=, |month=,
|coauthor=, and |coauthors=) aren't related to each other and because these parameters may be concatenated into the variables used by |date= and |author#= (and aliases)
details of which parameter caused the error message are not provided.  Only one error message is emitted regarless of the number of deprecated parameters in the citation.
]]
function deprecated_parameter()
	if true ~= Page_in_deprecated_cat then	-- if we haven't been here before then set a 
		Page_in_deprecated_cat=true;		-- sticky flag so that if there are more than one deprecated parameter the category is added only once
		table.insert( z.message_tail, { seterror( 'deprecated_params', {error_message}, true ) } );		-- add error message
	end
end

-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
--	return args and tostring( mw.message.newRawMessage( msg, args ) ) or msg;
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[
Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern  either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
]]
function kern_quotes (str)
	local left='&lt;span style=&quot;padding-left:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains leading single or double quote mark
	local right='&lt;span style=&quot;padding-right:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains trailing single or double quote mark
	
	str = string.gsub( str, &quot;^([\&quot;\'])&quot;, left, 1 );					-- replace (captured) leading single or double quote with left-side &lt;span&gt;
	str = string.gsub( str, &quot;([\&quot;\'])$&quot;, right, 1 );				-- replace (captured) trailing single or double quote with right-side &lt;span&gt;
	return str;
end

-- Wraps a string using a message_list configuration taking one argument
function wrap( key, str, lower )
    if not is_set( str ) then
        return &quot;&quot;;
    elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
        str = safeforitalics( str );
    end
    if lower == true then
        return substitute( cfg.messages[key]:lower(), {str} );
    else
        return substitute( cfg.messages[key], {str} );
    end        
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
    local origin = {};
    
    return setmetatable({
        ORIGIN = function( self, k )
            local dummy = self[k]; --force the variable to be loaded.
            return origin[k];
        end
    },
    {
        __index = function ( tbl, k )
            if origin[k] ~= nil then
                return nil;
            end
            
            local args, list, v = args, cfg.aliases[k];
            
            if type( list ) == 'table' then
                v, origin[k] = selectone( args, list, 'redundant_parameters' );
                if origin[k] == nil then
                    origin[k] = ''; -- Empty string, not nil
                end
            elseif list ~= nil then
                v, origin[k] = args[list], list;
            else
                -- maybe let through instead of raising an error?
                -- v, origin[k] = args[k], k;
                error( cfg.messages['unknown_argument_map'] );
            end
            
            -- Empty strings, not nil;
            if v == nil then
                v = cfg.defaults[k] or '';
                origin[k] = '';
            end
            
            tbl = rawset( tbl, k, v );
            return v;
        end,
    });
end

--[[
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
]]
function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
    return wrap( hidden and 'hidden-error' or 'visible-error', content );
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
    local error_state = cfg.error_conditions[ error_id ];
    
    prefix = prefix or &quot;&quot;;
    suffix = suffix or &quot;&quot;;
    
    if error_state == nil then
        error( cfg.messages['undefined_error'] );
    elseif is_set( error_state.category ) then
        table.insert( z.error_categories, error_state.category );
    end
    
    local message = substitute( error_state.message, arguments );
    
    message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
        &quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
        cfg.messages['help page label'] .. &quot;]])&quot;;
    
    z.error_ids[ error_id ] = true;
    if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
            and z.error_ids['citation_missing_title'] then
        return '', false;
    end
    
    message = table.concat({ prefix, message, suffix });
    
    if raw == true then
        return message, error_state.hidden;
    end        
        
    return errorcomment( message, error_state.hidden );
end

-- Formats a wiki style external link
function externallinkid(options)
    local url_string = options.id;
    if options.encode == true or options.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, url_string, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Formats a wiki style internal link
function internallinkid(options)
    return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, options.id, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Format an external link with error checking
function externallink( URL, label, source )
    local error_str = &quot;&quot;;
    if not is_set( label ) then
        label = URL;
        if is_set( source ) then
            error_str = seterror( 'bare_url_missing_title', { wrap( 'parameter', source ) }, false, &quot; &quot; );
        else
            error( cfg.messages[&quot;bare_url_no_origin&quot;] );
        end            
    end
    if not checkurl( URL ) then
        error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
    end
    return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safeforurl( label ), &quot;]&quot;, error_str });
end

-- Formats a link to Amazon
function amazon(id, domain)
    if not is_set(domain) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local handler = cfg.id_handlers['ASIN'];
    return externallinkid({link = handler.link,
        label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
        encode=handler.encode, separator = handler.separator})
end

--[[
Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]
function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmid' );	-- set an error message
		end
	end
	
	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns true; otherwse, returns false because the embargo has expired or |embargo= not set in this cite.
]]
function is_embargoed(embargo)
	if is_set(embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 and tonumber( embargo_date ) &gt;= tonumber( todays_date ) then	--is embargo date is in the future?
			return true;	-- still embargoed
		end
	end
	return false;			-- embargo expired or |embargo= not set
end

--[[
Formats a PMC and checks for embargoed articles.  The embargo parameter takes a date for a value. If the embargo date is in the future
the PMC identifier will not be linked to the article.  If the embargo specifies a date in the past, or if it is empty or omitted, then
the PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.
]]
function pmc(id, embargo)
	local handler = cfg.id_handlers['PMC'];
    
	local text;

	if is_embargoed(embargo) then
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id;	--still embargoed so no external link
	else
		text = externallinkid({link = handler.link, label = handler.label,			--no embargo date, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    local handler = cfg.id_handlers['DOI'];
    
    local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-[^%p]$&quot;) then	-- doi must begin with '10.', must not contain spaces or endashes, and must not end with punctuation
		cat = seterror( 'bad_doi' );
	end
	return text .. inactive .. ' ' .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    local handler = cfg.id_handlers['OL'];
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    else
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode}) .. 
            ' ' .. seterror( 'bad_ol' );
    end
end

--[[
Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.
]]
function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and ndashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 didgits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = externallinkid({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. seterror( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[
This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those citations that have defaults.
Also handles the special case where it is desireable to omit the title type from the rendered citation (|type=none).
]]
function set_titletype(cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;					-- if |type=none then type parameter not displayed
		end
		return title_type;						-- if |type= has been set to any other value use that value
	end

	if &quot;podcast&quot; == cite_class then				-- if this citation is cite podcast
		return &quot;Podcast&quot;;						-- display podcast annotation

	elseif &quot;pressrelease&quot; == cite_class then	-- if this citation is cite press release
		return &quot;Press release&quot;;					-- display press release annotation

	elseif &quot;techreport&quot; == cite_class then		-- if this citation is cite techreport
		return &quot;Technical report&quot;;				-- display techreport annotation
	
	elseif &quot;thesis&quot; == cite_class then			-- if this citation is cite thesis (degree option handled after this function returns)
			return &quot;Thesis&quot;;					-- display simple thesis annotation (without |degree= modification)
	end
end

-- returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct. If not a valid month, returns 0
function get_month_number (month)
local long_months = {['January']=1, ['February']=2, ['March']=3, ['April']=4, ['May']=5, ['June']=6, ['July']=7, ['August']=8, ['September']=9, ['October']=10, ['November']=11, ['December']=12};
local short_months = {['Jan']=1, ['Feb']=2, ['Mar']=3, ['Apr']=4, ['May']=5, ['Jun']=6, ['Jul']=7, ['Aug']=8, ['Sep']=9, ['Oct']=10, ['Nov']=11, ['Dec']=12};
local temp;
	temp=long_months[month];
	if temp then return temp; end				-- if month is the long-form name
	temp=short_months[month];
	if temp then return temp; end				-- if month is the short-form name
	return 0;									-- misspelled, improper case, or not a month name
end

-- returns a number according to the sequence of seasons in a year: 1 for Winter, etc.  Capitalization and spelling must be correct. If not a valid season, returns 0
function get_season_number (season)
local season_list = {['Winter']=1, ['Spring']=2, ['Summer']=3, ['Fall']=4, ['Autumn']=4}
local temp;
	temp=season_list[season];
	if temp then return temp; end				-- if season is a valid name return its number
	return 0;									-- misspelled, improper case, or not a season name
end

--[[
Returns true if day is less than or equal to the number of days in month; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap years before 1582 and Gregorian leap years after 1582.
Where the two calendars overlap (1582 to approximately 1923) dates are assumed to be Gregorian.
]]
function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if (2==month) then							-- if February
		month_length = 28;						-- then 28 days unless
		if 1582 &gt; tonumber(year) then			-- Julian calendar
			if 0==(year%4) then
				month_length = 29;
			end
		else									-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then	-- is a leap year?
				month_length = 29;				-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end

--[[
Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.  Similarly, seasons are also left to right, earliest to latest in time.  There is
an oddity with seasons.  Winter is assigned a value of 1, spring 2, ..., fall and autumn 4.  Because winter can follow fall/autumn at the end of a calender year, a special test
is made to see if |date=Fall-Winter yyyy (4-1) is the date.
]]

function is_valid_month_season_range(range_start, range_end)
	local range_start_number = get_month_number (range_start);
	
	if 0 == range_start_number then								-- is this a month range?
		local range_start_number = get_season_number (range_start);		-- not a month; is it a season? get start season number
		local range_end_number = get_season_number (range_end);			-- get end season number

		if 0 ~= range_start_number then							-- is start of range a season?
			if range_start_number &lt; range_end_number then		-- range_start is a season
				return true;									-- return true when range_end is also a season and follows start season; else false
			end
			if 4 == range_start_number and 1 == range_end_number then	-- special case when range is Fall-Winter or Autumn-Winter
				return true;
			end
		end
		return false;		-- range_start is not a month or a season; or range_start is a season and range_end is not; or improper season sequence
	end

	local range_end_number = get_month_number (range_end);		-- get end month number
	if range_start_number &lt; range_end_number then				-- range_start is a month; does range_start precede range_end?
		return true;											-- if yes, return true
	end
	return false;												-- range_start month number is greater than or equal to range end number; or range end isn't a month
end

--[[
Check date format to see that it is one of the formats approved by MOS:DATE: MMMM D, YYYY; D MMMM YYYY; MMMM YYYY; YYYY-MM-DD; YYYY.
Additionally, check the date to see that it is a real date: no 31 in 30-day months; no 29 February when not a leap year.  Months, both long-form and three
character abbreviations, and seasons must be spelled correctly.

If the date fails the fomat tests, this function returns false but does not return values for anchor_year and COinS_date.  When this happens, the date parameter is
used in the COinS metadata and the CITEREF identifier gets its year from the year parameter if present.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is date_string without anchor_year disambiguator if any
]]
function check_date (date_string)
	local year;
	local month=0;		-- assume that month and day are not used; if either is zero then final year/month/day validation is not necessary
	local day=0;
	local day2=0;		-- second day in a day range	
	local anchor_year;
	local coins_date;

	if date_string:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then			-- Year-initial numerical year month day format
		year, month, day=string.match(date_string, &quot;(%d%d%d%d)%-(%d%d)%-(%d%d)&quot;);
		month=tonumber(month);
		if 12 &lt; month or 1 &gt; month or 1583 &gt; tonumber(year) then return false; end	-- month number not valid or not Gregorian calendar
		anchor_year = year;

	elseif date_string:match(&quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then	-- month-initial: month day, year
		month, day, anchor_year, year=string.match(date_string, &quot;(%a+)%s*(%d%d?),%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end					-- return false if month text isn't one of the twelve months
				
	elseif date_string:match(&quot;^%a+ +[1-9]%d?–[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then	-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year=string.match(date_string, &quot;(%a+) +(%d%d?)–(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end					-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day-initial: day month year
		day, month, anchor_year, year=string.match(date_string, &quot;(%d%d*)%s*(%a+)%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end					-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d?–[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then	-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year=string.match(date_string, &quot;(%d%d?)–(%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end					-- return false if month text isn't one of the twelve months

	elseif mw.ustring.match (date_string, &quot;^%a+–%a+ +[1-9]%d%d%d%a?$&quot;) then		-- month/season range year; months separated by endash 
		local month2
		month, month2, anchor_year, year=mw.ustring.match (date_string, &quot;(%a+)[%-/–](%a+)%s*((%d%d%d%d)%a?)&quot;);
		if false == is_valid_month_season_range(month, month2) then
			return false;
		end
		
	elseif date_string:match(&quot;^%a+ +%d%d%d%d%a?$&quot;) then			-- month/season year
		month, anchor_year, year=string.match(date_string, &quot;(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if 0 == get_month_number (month) then					-- if month text isn't one of the twelve months, might be a season
			if 0 == get_season_number (month) then				-- not a month, is it a season?
				return false;									-- return false not a month or one of the five seasons
			end
		end

	elseif date_string:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then			-- year; here accept either YYY or YYYY
		anchor_year, year=string.match(date_string, &quot;((%d%d%d%d?)%a?)&quot;);

	else
		return false;											-- date format not one of the MOS:DATE approved formats
	end

	if 0~=month and 0~=day then									-- check year month day dates for validity
		if 0~=day2 then											-- If there is a second day (d–d Mmm YYYY or Mmm d–d, YYYY) test the second date
			if false==is_valid_date(year,month,day2) then
				return false;									-- second date in date range string is not a real date return false; unset anchor_year and coins_date
			end													-- if second date range string is valid, fall through to test the first date range
		end
		if false==is_valid_date(year,month,day) then
			return false;										-- date string is not a real date return false; unset anchor_year and coins_date
		end
	end

	coins_date= mw.ustring.gsub( date_string, &quot;–&quot;, &quot;-&quot; );		-- if here, then date_string is valid; set coins_date and replace any ndash with a hyphen
	
	return true, anchor_year, coins_date;						-- format is good and date string represents a real date
end	

--[[
Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true and values for anchor_year (used in CITEREF identifiers) and COinS_date (used in the COinS metadata).  The |date= parameter test is unique.  This function only 
accepts anchor_year and COinS_date results from the |date= parameter test and |date= is the only date-holding parameter that is allowed to contain the no-date keywords
&quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.
]]

function dates(date_parameters_list)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local error_message =&quot;&quot;;
	local good_date=false;
	
	for k, v in pairs(date_parameters_list) do		-- for each date-holding parameter in the list
		if is_set(v) then							-- if the parameter has a value
			if v:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then	-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				if 'date'==k then
					good_date, anchor_year, COinS_date = true, v:match(&quot;((c%. [1-9]d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
				elseif 'year'==k then
					good_date =  true;
				end
			elseif 'year'==k then					-- if the parameter is |year= (but not c. year)
				if v:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then	-- year with or without CITEREF disambiguator
					good_date =  true;
				end
			elseif 'date'==k then					-- if the parameter is |date=
				if v:match(&quot;n%.d%.%a?&quot;) then		-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v:match(&quot;nd%a?$&quot;) then		-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v);	-- go test the date
				end
			else									-- any other date-holding parameter
				good_date = check_date (v);			-- go test the date
			end
			if false==good_date then				-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then		-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;	-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;	-- add the failed parameter
			end
		end
	end
	if is_set(error_message) then
		table.insert( z.message_tail, { seterror( 'bad_date', {error_message}, true ) } );	-- add this error message
	end

	return anchor_year, COinS_date;		-- and done
end

--[[
Determines whether a URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
    -- Protocol-relative or URL scheme
    return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
    return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

--[[
ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in checkisbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.
]]
function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of bytes
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end	-- isbn13 begins with 978 or 979
		isbn_str = { isbn_str:byte(1, len) };
		for i, v in ipairs( isbn_str ) do
			temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
		end
		return temp % 10 == 0;
	end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
    return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
        return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
    end));
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if not is_set(str) then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        
        -- Remove newlines as they break italics.
        return str:gsub( '\n', ' ' );
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    if maximum ~= nil and maximum &lt; 1 then return &quot;&quot;, 0; end
    
    for i,person in ipairs(people) do
        if is_set(person.last) then
            local mask = person.mask
            local one
            local sep_one = sep;
            if maximum ~= nil and i &gt; maximum then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask;
                    sep_one = &quot; &quot;;
                end
            else
                one = person.last
                local first = person.first
                if is_set(first) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if is_set(person.link) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert( text, one )
            table.insert( text, sep_one )
        end
    end

    local count = #text / 2;
    if count &gt; 0 then 
        if count &gt; 1 and is_set(lastauthoramp) and not etal then
            text[#text-2] = &quot; &amp; &quot;;
        end
        text[#text] = nil; 
    end
    
    local result = table.concat(text) -- construct list
    if etal then 
        local etal_text = cfg.messages['et al'];
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result = 
        '&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
    end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
    return &quot;CITEREF&quot; .. table.concat( options );
end

-- Gets name list from the input arguments
function extractnames(args, list_name)
    local names = {};
    local i = 1;
    local last;
    
    while true do
        last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );
        if not is_set(last) then
            -- just in case someone passed in an empty parameter
            break;
        end
        names[i] = {
            last = last,
            first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i ),
            link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ),
            mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i )
        };
        i = i + 1;
    end
    return names;
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
    local id_list = {};
    for k, v in pairs( cfg.id_handlers ) do    
        v = selectone( args, v.parameters, 'redundant_parameters' );
        if is_set(v) then id_list[k] = v; end
    end
    return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
    local new_list, handler = {};
    
    function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
    
    for k, v in pairs( id_list ) do
        -- fallback to read-only cfg
        handler = setmetatable( { ['id'] = v }, fallback(k) );
        
        if handler.mode == 'external' then
            table.insert( new_list, {handler.label, externallinkid( handler ) } );
        elseif handler.mode == 'internal' then
            table.insert( new_list, {handler.label, internallinkid( handler ) } );
        elseif handler.mode ~= 'manual' then
            error( cfg.messages['unknown_ID_mode'] );
        elseif k == 'DOI' then
            table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
        elseif k == 'ASIN' then
            table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
        elseif k == 'OL' then
            table.insert( new_list, {handler.label, openlibrary( v ) } );
        elseif k == 'PMC' then
            table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
        elseif k == 'PMID' then
            table.insert( new_list, {handler.label, pmid( v ) } );
        elseif k == 'ISSN' then
        	table.insert( new_list, {handler.label, issn( v ) } );
        elseif k == 'ISBN' then
            local ISBN = internallinkid( handler );
            if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
                ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
            end
            table.insert( new_list, {handler.label, ISBN } );                
        else
            error( cfg.messages['unknown_manual_ID'] );
        end
    end
    
    function comp( a, b )	-- used in following table.sort()
        return a[1] &lt; b[1];
    end
    
    table.sort( new_list, comp );
    for k, v in ipairs( new_list ) do
        new_list[k] = v[2];
    end
    
    return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
    local value = nil;
    local selected = '';
    local error_list = {};
    
    if index ~= nil then index = tostring(index); end
    
    -- Handle special case of &quot;#&quot; replaced by empty string
    if index == '1' then
        for _, v in ipairs( possible ) do
            v = v:gsub( &quot;#&quot;, &quot;&quot; );
            if is_set(args[v]) then
                if value ~= nil and selected ~= v then
                    table.insert( error_list, v );
                else
                    value = args[v];
                    selected = v;
                end
            end
        end        
    end
    
    for _, v in ipairs( possible ) do
        if index ~= nil then
            v = v:gsub( &quot;#&quot;, index );
        end
        if is_set(args[v]) then
            if value ~= nil and selected ~=  v then
                table.insert( error_list, v );
            else
                value = args[v];
                selected = v;
            end
        end
    end
    
    if #error_list &gt; 0 then
        local error_str = &quot;&quot;;
        for _, k in ipairs( error_list ) do
            if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
            error_str = error_str .. wrap( 'parameter', k );
        end
        if #error_list &gt; 1 then
            error_str = error_str .. cfg.messages['parameter-final-separator'];
        else
            error_str = error_str .. cfg.messages['parameter-pair-separator'];
        end
        error_str = error_str .. wrap( 'parameter', selected );
        table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
    end
    
    return value, selected;
end

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
function COinS(data)
    if 'table' ~= type(data) or nil == next(data) then
        return '';
    end
    
    local ctx_ver = &quot;Z39.88-2004&quot;;
    
    -- treat table strictly as an array with only set values.
    local OCinSoutput = setmetatable( {}, {
        __newindex = function(self, key, value)
            if is_set(value) then
                rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
            end
        end
    });
    
    if is_set(data.Chapter) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Chapter;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    elseif is_set(data.Periodical) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
        OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    else
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
    end
    
    OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
    OCinSoutput[&quot;rft.date&quot;] = data.Date;
    OCinSoutput[&quot;rft.series&quot;] = data.Series;
    OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
    OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
    OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
    OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
    OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
    
    for k, v in pairs( data.ID_list ) do
        local id, value = cfg.id_handlers[k].COinS;
        if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
        if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
            OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
        else
            OCinSoutput[ id ] = value;
        end
    end
    
    local last, first;
    for k, v in ipairs( data.Authors ) do
        last, first = v.last, v.first;
        if k == 1 then
            if is_set(last) then
                OCinSoutput[&quot;rft.aulast&quot;] = last;
            end
            if is_set(first) then 
                OCinSoutput[&quot;rft.aufirst&quot;] = first;
            end
        end
        if is_set(last) and is_set(first) then
            OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
        elseif is_set(last) then
            OCinSoutput[&quot;rft.au&quot;] = last;
        end
    end
    
    OCinSoutput.rft_id = data.URL;
    OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
    OCinSoutput = setmetatable( OCinSoutput, nil );
    
    -- sort with version string always first, and combine.
    table.sort( OCinSoutput );
    table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
    return table.concat(OCinSoutput, &quot;&amp;&quot;);
end

--[[
This is the main function doing the majority of the citation
formatting.
]]
function citation0( config, args)
    --[[ 
    Load Input Parameters
    The argment_wrapper facillitates the mapping of multiple
    aliases to single internal variable.
    ]]
    local A = argument_wrapper( args );

    local i 
    local PPrefix = A['PPrefix']
    local PPPrefix = A['PPPrefix']
    if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = A['Authors'];
    local a = extractnames( args, 'AuthorList' );

    local Coauthors = A['Coauthors'];
    local Others = A['Others'];
    local Editors = A['Editors'];
    local e = extractnames( args, 'EditorList' );

    local Year = A['Year'];
    local PublicationDate = A['PublicationDate'];
    local OrigYear = A['OrigYear'];
    local Date = A['Date'];
    local LayDate = A['LayDate'];
    ------------------------------------------------- Get title data
    local Title = A['Title'];
    local BookTitle = A['BookTitle'];
    local Conference = A['Conference'];
    local TransTitle = A['TransTitle'];
    local TitleNote = A['TitleNote'];
    local TitleLink = A['TitleLink'];
    local Chapter = A['Chapter'];
    local ChapterLink = A['ChapterLink'];
    local TransChapter = A['TransChapter'];
    local TitleType = A['TitleType'];
    local Degree = A['Degree'];
    local Docket = A['Docket'];
    local ArchiveURL = A['ArchiveURL'];
    local URL = A['URL']
    local URLorigin = A:ORIGIN('URL');
    local ChapterURL = A['ChapterURL'];
    local ChapterURLorigin = A:ORIGIN('ChapterURL');
    local ConferenceURL = A['ConferenceURL'];
    local ConferenceURLorigin = A:ORIGIN('ConferenceURL');
    local Periodical = A['Periodical'];

--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped

All other combinations of |encyclopedia, |title, and |article are not modified
]]
	if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
		if is_set(Periodical) then					-- Periodical is set when |encyclopedia is set
			if is_set(Title) then
				if not is_set(Chapter) then
					Chapter = Title;				-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					TransChapter = TransTitle;
					Title = Periodical;
					Periodical = '';				-- redundant so unset
					TransTitle = '';				-- redundant so unset
				end
			else									-- |title not set
				Title = Periodical;					-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';					-- redundant so unset
			end
		end
	end

local Series = A['Series'];
    local Volume = A['Volume'];
    local Issue = A['Issue'];
    local Position = '';
    local Page, Pages, At, page_type;
    
    Page = A['Page'];
    Pages = hyphentodash( A['Pages'] );
    At = A['At'];
    
    if is_set(Page) then
        if is_set(Pages) or is_set(At) then
            Page = Page .. &quot; &quot; .. seterror('extra_pages');
            Pages = '';
            At = '';
        end
    elseif is_set(Pages) then
        if is_set(At) then
            Pages = Pages .. &quot; &quot; .. seterror('extra_pages');
            At = '';
        end
    end    
    
    local Edition = A['Edition'];
    local PublicationPlace = A['PublicationPlace']
    local Place = A['Place'];
    
    if not is_set(PublicationPlace) and is_set(Place) then
        PublicationPlace = Place;
    end
    
    if PublicationPlace == Place then Place = ''; end
    
    local PublisherName = A['PublisherName'];
    local RegistrationRequired = A['RegistrationRequired'];
    local SubscriptionRequired = A['SubscriptionRequired'];
    local Via = A['Via'];
    local AccessDate = A['AccessDate'];
    local ArchiveDate = A['ArchiveDate'];
    local Agency = A['Agency'];
    local DeadURL = A['DeadURL']
    local Language = A['Language'];
    local Format = A['Format'];
    local Ref = A['Ref'];
    
    local DoiBroken = A['DoiBroken'];
	
-- Special case for cite techreport.
	local ID = A['ID'];
	if (config.CitationClass == &quot;techreport&quot;) then	-- special case for cite techreport
		if is_set(Issue) then						-- cite techreport uses 'number', which other citations aliase to 'issue'
			if not is_set(ID) then					-- can we use ID for the &quot;number&quot;?
				ID = Issue;							-- yes, use it
				Issue = &quot;&quot;;							-- unset Issue so that &quot;number&quot; isn't duplicated in the rendered citation or COinS metadata
			else									-- can't use ID so emit error message
				ID = ID .. &quot; &quot; .. seterror('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
			end
		end	
	end	
			
    local ASINTLD = A['ASINTLD'];
    local IgnoreISBN = A['IgnoreISBN'];
    local Embargo = A['Embargo'];

    local ID_list = extractids( args );
    
    local Quote = A['Quote'];
    local PostScript = A['PostScript'];
    local LayURL = A['LayURL'];
    local LaySource = A['LaySource'];
    local Transcript = A['Transcript'];
    local TranscriptURL = A['TranscriptURL'] 
    local TranscriptURLorigin = A:ORIGIN('TranscriptURL');
    local sepc = A['Separator'];
    local LastAuthorAmp = A['LastAuthorAmp'];
    local no_tracking_cats = A['NoTracking'];

    local use_lowercase = ( sepc ~= '.' );
    local this_page = mw.title.getCurrentTitle();  --Also used for COinS and for language
    
    if not is_set(no_tracking_cats) then
        for k, v in pairs( cfg.uncategorized_namespaces ) do
            if this_page.nsText == v then
                no_tracking_cats = &quot;true&quot;;
                break;
            end
        end
    end

	local anchor_year;		-- used in the CITEREF identifier
	local COinS_date;		-- used in the COinS metadata

-- legacy: promote concatenation of |day=, |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set(Date) then
		Date = Year;						-- promote Year to Date
		Year = nil;							-- make nil so Year as empty string isn't used for CITEREF
		if is_set(Date) then
			local Month = A['Month'];
			if is_set(Month) then
				Date = Month .. &quot; &quot; .. Date;
				local Day = A['Day']
				if is_set(Day) then Date = Day .. &quot; &quot; .. Date end
			end
		elseif is_set(PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;			-- promonte PublicationDate to Date
			PublicationDate = '';			-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end	-- if PublicationDate is same as Date, don't display in rendered citation

-- Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates.
-- TODO: 2013-10-27: AirDate is nil when dates() is called because it hasn't been set yet.  Move the call to dates() or set AirDate earlier.
	anchor_year, COinS_date = dates({['accessdate']=AccessDate, ['airdate']=AirDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
		['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.

	--Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set
	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_embargoed(Embargo) then
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];	-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];		-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if is_set(BookTitle) then
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = BookTitle;
        TitleLink = '';
        TransTitle = '';
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = A['AirDate'];
        local SeriesLink = A['SeriesLink'];
        local Season = A['Season'];
        local SeriesNumber = A['SeriesNumber'];
        local Network = A['Network'];
        local Station = A['Station'];
        local s, n = {}, {};
        local Sep = (first_set(A[&quot;SeriesSeparator&quot;], A[&quot;Separator&quot;]) or &quot;&quot;) .. &quot; &quot;;
        
        if is_set(Issue) then table.insert(s, cfg.messages[&quot;episode&quot;] .. &quot; &quot; .. Issue); Issue = ''; end
        if is_set(Season) then table.insert(s, cfg.messages[&quot;season&quot;] .. &quot; &quot; .. Season); end
        if is_set(SeriesNumber) then table.insert(s, cfg.messages[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber); end
        if is_set(Network) then table.insert(n, Network); end
        if is_set(Station) then table.insert(n, Station); end
        
        Date = Date or AirDate;
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = Series;
        TitleLink = SeriesLink;
        TransTitle = '';
        
        Series = table.concat(s, Sep);
        ID = table.concat(n, Sep);
    end
    
    -- COinS metadata (see &lt;http://ocoins.info/&gt;) for
    -- automated parsing of citation information.
    local OCinSoutput = COinS{
        ['Periodical'] = Periodical,
        ['Chapter'] = Chapter,
        ['Title'] = Title,
        ['PublicationPlace'] = PublicationPlace,
        ['Date'] = first_set(COinS_date, Date),		-- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here?  Should we be including invalid dates in metadata?
        ['Series'] = Series,
        ['Volume'] = Volume,
        ['Issue'] = Issue,
        ['Pages'] = first_set(Page, Pages, At),
        ['Edition'] = Edition,
        ['PublisherName'] = PublisherName,
        ['URL'] = first_set( URL, ChapterURL ),
        ['Authors'] = a,
        ['ID_list'] = ID_list,
        ['RawPage'] = this_page.prefixedText,
    };

    if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = '';
        TitleLink = '';
        TransTitle = '';
    end

    -- Now perform various field 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 not is_set(Authors) then
        local Maximum = tonumber( A['DisplayAuthors'] );
        
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #a == 9 then 
            Maximum = 8;
            table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
        elseif not is_set(Maximum) then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = A[&quot;AuthorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;AuthorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A[&quot;AuthorFormat&quot;],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if is_set(Coauthors) then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
        
        Authors = listpeople(control, a) 
    end

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { seterror('coauthors_missing_author', {}, true) } );	-- emit error message
	end

    local EditorCount
    if not is_set(Editors) then
        local Maximum = tonumber( A['DisplayEditors'] );
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #e == 4 then 
            Maximum = 3;
            table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
        elseif not is_set(Maximum) then
            Maximum = #e + 1;
        end

        local control = { 
            sep = A[&quot;EditorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;EditorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A['EditorFormat'],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };

        Editors, EditorCount = listpeople(control, e);
    else
        EditorCount = 1;
    end

    local Cartography = &quot;&quot;;
    local Scale = &quot;&quot;;
    if config.CitationClass == &quot;map&quot; then
        if not is_set( Authors ) and is_set( PublisherName ) then
            Authors = PublisherName;
            PublisherName = &quot;&quot;;
        end
        Cartography = A['Cartography'];
        if is_set( Cartography ) then
            Cartography = sepc .. &quot; &quot; .. wrap( 'cartography', Cartography, use_lowercase );
        end        
        Scale = A['Scale'];
        if is_set( Scale ) then
            Scale = sepc .. &quot; &quot; .. Scale;
        end        
    end
    
    if  not is_set(URL) and
        not is_set(ChapterURL) and
        not is_set(ArchiveURL) and
        not is_set(ConferenceURL) and
        not is_set(TranscriptURL) then
        
        -- Test if cite web or cite podcast |url= is missing or empty 
		if inArray(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;}) then	
			table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
		end
        
        -- Test if accessdate is given without giving a URL
        if is_set(AccessDate) then
            table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
            AccessDate = '';
        end
        
        -- Test if format is given without giving a URL
        if is_set(Format) then
            Format = Format .. seterror( 'format_missing_url' );
        end
    end
    
    -- Test if citation has no title
    if  not is_set(Chapter) and
        not is_set(Title) and
        not is_set(Periodical) and
        not is_set(Conference) and
        not is_set(TransTitle) and
        not is_set(TransChapter) then
        table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
    end
    
    Format = is_set(Format) and &quot; (&quot; .. Format .. &quot;)&quot; or &quot;&quot;;
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if is_set( ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
            URLorigin = A:ORIGIN('ArchiveURL')
        end
    end
    
    -- Format chapter / article title
    if is_set(Chapter) and is_set(ChapterLink) then 
        Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot;;
    end
    if is_set(Periodical) and is_set(Title) then
        Chapter = wrap( 'italic-title', Chapter );
        TransChapter = wrap( 'trans-italic-title', TransChapter );
    else
		Chapter = kern_quotes (Chapter);				-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
        Chapter = wrap( 'quoted-title', Chapter );
        TransChapter = wrap( 'trans-quoted-title', TransChapter );
    end
    
    local TransError = &quot;&quot;
    if is_set(TransChapter) then
        if not is_set(Chapter) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
        else
            TransChapter = &quot; &quot; .. TransChapter;
        end
    end
    
    Chapter = Chapter .. TransChapter;
    
    if is_set(Chapter) then
        if not is_set(ChapterLink) then
            if is_set(ChapterURL) then
                Chapter = externallink( ChapterURL, Chapter ) .. TransError;
                if not is_set(URL) then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif is_set(URL) then 
                Chapter = externallink( URL, Chapter ) .. TransError .. Format;
                URL = &quot;&quot;;
                Format = &quot;&quot;;
            else
                Chapter = Chapter .. TransError;
            end            
        elseif is_set(ChapterURL) then
            Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. 
                TransError;
        else
            Chapter = Chapter .. TransError;
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    elseif is_set(ChapterURL) then
        Chapter = &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. sepc .. &quot; &quot;;
    end        
    
    -- Format main title.
    if is_set(TitleLink) and is_set(Title) then
        Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
    end
    
    if is_set(Periodical) then
		Title = kern_quotes (Title);				-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    elseif inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;pressrelease&quot;,&quot;conference&quot;,&quot;podcast&quot;}) and
            not is_set(Chapter) then
		Title = kern_quotes (Title);				-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    else
        Title = wrap( 'italic-title', Title );
        TransTitle = wrap( 'trans-italic-title', TransTitle );
    end
    
    TransError = &quot;&quot;;
    if is_set(TransTitle) then
        if not is_set(Title) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
        else
            TransTitle = &quot; &quot; .. TransTitle;
        end
    end
    
    Title = Title .. TransTitle;
    
    if is_set(Title) then
        if not is_set(TitleLink) and is_set(URL) then 
            Title = externallink( URL, Title ) .. TransError .. Format       
            URL = &quot;&quot;;
            Format = &quot;&quot;;
        else
            Title = Title .. TransError;
        end
    end
    
    if is_set(Place) then
        Place = &quot; &quot; .. wrap( 'written', Place, use_lowercase ) .. sepc .. &quot; &quot;;
    end
    
    if is_set(Conference) then
        if is_set(ConferenceURL) then
            Conference = externallink( ConferenceURL, Conference );
        end
        Conference = sepc .. &quot; &quot; .. Conference
    elseif is_set(ConferenceURL) then
        Conference = sepc .. &quot; &quot; .. externallink( ConferenceURL, nil, ConferenceURLorigin );
    end
    
    if not is_set(Position) then
        local Minutes = A['Minutes'];
        if is_set(Minutes) then
            Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
        else
            local Time = A['Time'];
            if is_set(Time) then
                local TimeCaption = A['TimeCaption']
                if not is_set(TimeCaption) then
                    TimeCaption = cfg.messages['event'];
                    if sepc ~= '.' then
                        TimeCaption = TimeCaption:lower();
                    end
                end
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
            end
        end
    else
        Position = &quot; &quot; .. Position;
        At = '';
    end
    
    if not is_set(Page) then
        if is_set(Pages) then
            if is_set(Periodical) and
                not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
                Pages = &quot;: &quot; .. Pages;
            elseif tonumber(Pages) ~= nil then
                Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
            else
                Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
            end
        end
    else
        if is_set(Periodical) and
            not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
            Page = &quot;: &quot; .. Page;
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page;
        end
    end
    
    At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
    Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
    if config.CitationClass == 'map' then
        local Section = A['Section'];
        local Inset = A['Inset'];
        if first_set( Pages, Page, At ) ~= nil or sepc ~= '.' then
            if is_set( Section ) then
                Section = &quot;, &quot; .. wrap( 'section', Section, true );
            end
            if is_set( Inset ) then
                Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
            end
        else
            if is_set( Section ) then
                Section = sepc .. &quot; &quot; .. wrap( 'section', Section, use_lowercase );
                if is_set( Inset ) then
                    Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
                end
            elseif is_set( Inset ) then
                Inset = sepc .. &quot; &quot; .. wrap( 'inset', Inset, use_lowercase );
            end            
        end            
        At = At .. Section .. Inset;        
    end    

	--[[Look in the list of iso639-1 language codes to see if the value provided in the language parameter matches one of them.  If a match is found, 
	use that value; if not, then use the value that was provided with the language parameter.
	
	Categories are assigned in a manner similar to the {{xx icon}} templates - categorizes only mainspace citations and only when the language code is not 'en' (English).
	]]
	if is_set (Language) then
--		local name = mw.language.fetchLanguageName( Language:lower(), &quot;en&quot; );	-- experiment: this seems to return correct ISO 639-1 language names
		local name = cfg.iso639_1[Language:lower()];		-- get the language name if Language parameter has a valid iso 639-1 code
		if nil == name then
			Language=&quot; &quot; .. wrap( 'language', Language );	-- no match, use parameter's value
		else
			if 0 == this_page.namespace and 'en' ~= Language:lower() then	--found a match; is this page main / article space and English not the language?
				Language=&quot; &quot; .. wrap( 'language', name .. '[[Category:Articles with ' .. name .. '-language external links]]' );	-- in main space and not English: categorize
			else
				Language=&quot; &quot; .. wrap( 'language', name );	--not in mainspace or language is English so don't categorize
			end
		end
	else
		Language=&quot;&quot;;	-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;

-- handle type parameter for those CS1 citations that have default values

	if inArray(config.CitationClass, {&quot;podcast&quot;,&quot;pressrelease&quot;,&quot;techreport&quot;,&quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then	-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then					-- if type parameter is specified
		TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot;;	-- display it in parentheses
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
    Edition = is_set(Edition) and (&quot; &quot; .. wrap( 'edition', Edition )) or &quot;&quot;;
    Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
    Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
    OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
    Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;
    
    if is_set(Volume) then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume;
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
        end
    end
    
    ------------------------------------ totally unrelated data
    --[[ Loosely mimic {{subscription required}} template; Via parameter identifies a delivery source that is not the publisher; these sources often, but not always, exist
    behind a registration or paywall.  So here, we've chosen to decouple via from subscription (via has never been part of the registration required template).
    
    Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link note is displayed. There are no error messages for this condition.
    ]]
    if is_set(Via) then
        Via = &quot; &quot; .. wrap( 'via', Via );
    end

	if is_set(SubscriptionRequired) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription']; --here when 'via' parameter not used but 'subscription' is
    elseif is_set(RegistrationRequired) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration']; --here when 'via' and 'subscription' parameters not used but 'registration' is
    end

    if is_set(AccessDate) then
        local retrv_text = &quot; &quot; .. cfg.messages['retrieved']
        if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
        AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
            .. substitute( retrv_text, {AccessDate} ) .. '&lt;/span&gt;'
    end
    
    if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end

    
    ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo} );

    if is_set(URL) then
        URL = &quot; &quot; .. externallink( URL, nil, URLorigin );
    end

    if is_set(Quote) then
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        Quote = sepc ..&quot; &quot; .. wrap( 'quoted-text', Quote ); 
        PostScript = &quot;&quot;;
    elseif PostScript:lower() == &quot;none&quot; then
        PostScript = &quot;&quot;;
    end
    
    local Archived
    if is_set(ArchiveURL) then
        if not is_set(ArchiveDate) then
            ArchiveDate = seterror('archive_missing_date');
        end
        if &quot;no&quot; == DeadURL then
            local arch_text = cfg.messages['archived'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
                { externallink( ArchiveURL, arch_text ), ArchiveDate } );
            if not is_set(OriginalURL) then
                Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url');                               
            end
        elseif is_set(OriginalURL) then
            local arch_text = cfg.messages['archived-dead'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text,
                { externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
        else
            local arch_text = cfg.messages['archived-missing'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
                { seterror('archive_missing_url'), ArchiveDate } );
        end
    else
        Archived = &quot;&quot;
    end
    
    local Lay
    if is_set(LayURL) then
        if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
        if is_set(LaySource) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot;;
        else
            LaySource = &quot;&quot;;
        end
        if sepc == '.' then
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;;
    end
    
    if is_set(Transcript) then
        if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
    elseif is_set(TranscriptURL) then
        Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
    end
    
    local Publisher;
    if is_set(Periodical) and
        not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end
        elseif is_set(PublicationPlace) then
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if is_set(PublicationDate) then
            if is_set(Publisher) then
                Publisher = Publisher .. &quot;, &quot; .. wrap( 'published', PublicationDate );
            else
                Publisher = PublicationDate;
            end
        end
        if is_set(Publisher) then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if is_set(PublicationDate) then
            PublicationDate = &quot; (&quot; .. wrap( 'published', PublicationDate ) .. &quot;)&quot;;
        end
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif is_set(PublicationPlace) then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    
    -- Several of the above rely upon detecting this as nil, so do it last.
    if is_set(Periodical) then
        if is_set(Title) or is_set(TitleNote) then 
            Periodical = sepc .. &quot; &quot; .. wrap( 'italic-title', Periodical ) 
        else 
            Periodical = wrap( 'italic-title', Periodical )
        end
    end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if inArray(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
        if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, 
            Language, Cartography, Edition, Publisher, Agency, Volume, Issue}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, Language, 
            Volume, Issue, Others, Cartography, Edition, Publisher, Agency}, sepc );
    end
    
    if #ID_list &gt; 0 then
        ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
    else
        ID_list = ID;
    end
    
    local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
    local text;
    local pgtext = Position .. Page .. Pages .. At;
    
    if is_set(Authors) then
        if is_set(Coauthors) then
            Authors = Authors .. A['AuthorSeparator'] .. &quot; &quot; .. Coauthors
        end
        if is_set(Date) then
            Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        elseif string.sub(Authors,-1,-1) == sepc then
            Authors = Authors .. &quot; &quot;
        else
            Authors = Authors .. sepc .. &quot; &quot;
        end
        if is_set(Editors) then
            local in_text = &quot; &quot;;
            local post_text = &quot;&quot;;
            if is_set(Chapter) then
                in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
            else
                if EditorCount &lt;= 1 then
                    post_text = &quot;, &quot; .. cfg.messages['editor'];
                else
                    post_text = &quot;, &quot; .. cfg.messages['editors'];
                end
            end 
            if (sepc ~= '.') then in_text = in_text:lower() end
            Editors = in_text .. Editors .. post_text;
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = Editors .. &quot; &quot;
                else Editors = Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif is_set(Editors) then
        if is_set(Date) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
            else
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if is_set(Date) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end
        if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
            text = safejoin( {Chapter, Place, tcommon}, sepc );
            text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
            text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
            text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if is_set(PostScript) and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    local options = {};
    
    if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
        options.class = &quot;citation &quot; .. config.CitationClass;
    else
        options.class = &quot;citation&quot;;
    end
    
    if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if #a &gt; 0 then
                for i,v in ipairs(a) do 
                    names[i] = v.last 
                    if i == 4 then break end
                end
            elseif #e &gt; 0 then
                for i,v in ipairs(e) do 
                    names[i] = v.last 
                    if i == 4 then break end                
                end
            end
			names[ #names + 1 ] = first_set(Year, anchor_year);	-- Year first for legacy citations
            id = anchorid(names)
        end
        options.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = {};
        text = seterror('empty_citation');
        z.message_tail = {};
    end
    
    if is_set(options.id) then 
        text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    else
        text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    end        

    local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        text = text .. &quot; &quot;;
        for i,v in ipairs( z.message_tail ) do
            if is_set(v[1]) then
                if i == #z.message_tail then
                    text = text .. errorcomment( v[1], v[2] );
                else
                    text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
                end
            end
        end
    end
    
    no_tracking_cats = no_tracking_cats:lower();
    if inArray(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    local suggestions = {};
    local error_text, error_state;

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        args[k] = v;       
    end    

    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            if not validate( k ) then            
                error_text = &quot;&quot;;
                if type( k ) ~= 'string' then
                    -- Exclude empty numbered parameters
                    if v:match(&quot;%S+&quot;) ~= nil then
                        error_text, error_state = seterror( 'text_ignored', {v}, true );
                    end
                elseif validate( k:lower() ) then 
                    error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
                else
                    if #suggestions == 0 then
                        suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
                    end
                    if suggestions[ k:lower() ] ~= nil then
                        error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
                    else
                        error_text, error_state = seterror( 'parameter_ignored', {k}, true );
                    end
                end                  
                if error_text ~= '' then
                    table.insert( z.message_tail, {error_text, error_state} );
                end                
            end
            args[k] = v;
        elseif args[k] ~= nil or (k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z</text>
      <sha1>f65bf7r68qmxgjvm1u3t29b3esods4l</sha1>
    </revision>
    <revision>
      <id>4668</id>
      <parentid>4667</parentid>
      <timestamp>2014-02-15T17:31:16Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Changed doi validation test to accept all terminal punctuation except period and comma;</comment>
      <origin>4668</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="85570" sha1="4i2tnuaf7cbcfig1bj9z2jmmfeu9jyx" xml:space="preserve">local z = {
    error_categories = {};
    error_ids = {};
    message_tail = {};
}

-- Include translation message hooks, ID and error handling configuration settings.
local cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );

-- Contains a list of all recognized parameters
local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );

-- Whether variable is set or not
function is_set( var )
    return not (var == nil or var == '');
end

-- First set variable or nil if none
function first_set(...)
    local list = {...};
    for _, var in pairs(list) do
        if is_set( var ) then
            return var;
        end
    end
end

-- Whether needle is in haystack
function inArray( needle, haystack )
    if needle == nil then
        return false;
    end
    for n,v in ipairs( haystack ) do
        if v == needle then
            return n;
        end
    end
    return false;
end

--[[
Categorize and emit an error message when the citation contains one or more deprecated parameters.  Because deprecated parameters (currently |day=, |month=,
|coauthor=, and |coauthors=) aren't related to each other and because these parameters may be concatenated into the variables used by |date= and |author#= (and aliases)
details of which parameter caused the error message are not provided.  Only one error message is emitted regarless of the number of deprecated parameters in the citation.
]]
function deprecated_parameter()
	if true ~= Page_in_deprecated_cat then	-- if we haven't been here before then set a 
		Page_in_deprecated_cat=true;		-- sticky flag so that if there are more than one deprecated parameter the category is added only once
		table.insert( z.message_tail, { seterror( 'deprecated_params', {error_message}, true ) } );		-- add error message
	end
end

-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
--	return args and tostring( mw.message.newRawMessage( msg, args ) ) or msg;
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[
Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern  either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
]]
function kern_quotes (str)
	local left='&lt;span style=&quot;padding-left:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains leading single or double quote mark
	local right='&lt;span style=&quot;padding-right:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains trailing single or double quote mark
	
	str = string.gsub( str, &quot;^([\&quot;\'])&quot;, left, 1 );					-- replace (captured) leading single or double quote with left-side &lt;span&gt;
	str = string.gsub( str, &quot;([\&quot;\'])$&quot;, right, 1 );				-- replace (captured) trailing single or double quote with right-side &lt;span&gt;
	return str;
end

-- Wraps a string using a message_list configuration taking one argument
function wrap( key, str, lower )
    if not is_set( str ) then
        return &quot;&quot;;
    elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
        str = safeforitalics( str );
    end
    if lower == true then
        return substitute( cfg.messages[key]:lower(), {str} );
    else
        return substitute( cfg.messages[key], {str} );
    end        
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
    local origin = {};
    
    return setmetatable({
        ORIGIN = function( self, k )
            local dummy = self[k]; --force the variable to be loaded.
            return origin[k];
        end
    },
    {
        __index = function ( tbl, k )
            if origin[k] ~= nil then
                return nil;
            end
            
            local args, list, v = args, cfg.aliases[k];
            
            if type( list ) == 'table' then
                v, origin[k] = selectone( args, list, 'redundant_parameters' );
                if origin[k] == nil then
                    origin[k] = ''; -- Empty string, not nil
                end
            elseif list ~= nil then
                v, origin[k] = args[list], list;
            else
                -- maybe let through instead of raising an error?
                -- v, origin[k] = args[k], k;
                error( cfg.messages['unknown_argument_map'] );
            end
            
            -- Empty strings, not nil;
            if v == nil then
                v = cfg.defaults[k] or '';
                origin[k] = '';
            end
            
            tbl = rawset( tbl, k, v );
            return v;
        end,
    });
end

--[[
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
]]
function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
    return wrap( hidden and 'hidden-error' or 'visible-error', content );
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
    local error_state = cfg.error_conditions[ error_id ];
    
    prefix = prefix or &quot;&quot;;
    suffix = suffix or &quot;&quot;;
    
    if error_state == nil then
        error( cfg.messages['undefined_error'] );
    elseif is_set( error_state.category ) then
        table.insert( z.error_categories, error_state.category );
    end
    
    local message = substitute( error_state.message, arguments );
    
    message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
        &quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
        cfg.messages['help page label'] .. &quot;]])&quot;;
    
    z.error_ids[ error_id ] = true;
    if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
            and z.error_ids['citation_missing_title'] then
        return '', false;
    end
    
    message = table.concat({ prefix, message, suffix });
    
    if raw == true then
        return message, error_state.hidden;
    end        
        
    return errorcomment( message, error_state.hidden );
end

-- Formats a wiki style external link
function externallinkid(options)
    local url_string = options.id;
    if options.encode == true or options.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, url_string, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Formats a wiki style internal link
function internallinkid(options)
    return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, options.id, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Format an external link with error checking
function externallink( URL, label, source )
    local error_str = &quot;&quot;;
    if not is_set( label ) then
        label = URL;
        if is_set( source ) then
            error_str = seterror( 'bare_url_missing_title', { wrap( 'parameter', source ) }, false, &quot; &quot; );
        else
            error( cfg.messages[&quot;bare_url_no_origin&quot;] );
        end            
    end
    if not checkurl( URL ) then
        error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
    end
    return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safeforurl( label ), &quot;]&quot;, error_str });
end

-- Formats a link to Amazon
function amazon(id, domain)
    if not is_set(domain) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local handler = cfg.id_handlers['ASIN'];
    return externallinkid({link = handler.link,
        label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
        encode=handler.encode, separator = handler.separator})
end

--[[
Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]
function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmid' );	-- set an error message
		end
	end
	
	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns true; otherwse, returns false because the embargo has expired or |embargo= not set in this cite.
]]
function is_embargoed(embargo)
	if is_set(embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 and tonumber( embargo_date ) &gt;= tonumber( todays_date ) then	--is embargo date is in the future?
			return true;	-- still embargoed
		end
	end
	return false;			-- embargo expired or |embargo= not set
end

--[[
Formats a PMC and checks for embargoed articles.  The embargo parameter takes a date for a value. If the embargo date is in the future
the PMC identifier will not be linked to the article.  If the embargo specifies a date in the past, or if it is empty or omitted, then
the PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.
]]
function pmc(id, embargo)
	local handler = cfg.id_handlers['PMC'];
    
	local text;

	if is_embargoed(embargo) then
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id;	--still embargoed so no external link
	else
		text = externallinkid({link = handler.link, label = handler.label,			--no embargo date, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    local handler = cfg.id_handlers['DOI'];
    
    local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must not contain spaces or endashes, and must not end with period or comma
		cat = seterror( 'bad_doi' );
	end
	return text .. inactive .. ' ' .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    local handler = cfg.id_handlers['OL'];
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    else
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode}) .. 
            ' ' .. seterror( 'bad_ol' );
    end
end

--[[
Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.
]]
function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and ndashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 didgits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = externallinkid({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. seterror( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[
This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those citations that have defaults.
Also handles the special case where it is desireable to omit the title type from the rendered citation (|type=none).
]]
function set_titletype(cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;					-- if |type=none then type parameter not displayed
		end
		return title_type;						-- if |type= has been set to any other value use that value
	end

	if &quot;podcast&quot; == cite_class then				-- if this citation is cite podcast
		return &quot;Podcast&quot;;						-- display podcast annotation

	elseif &quot;pressrelease&quot; == cite_class then	-- if this citation is cite press release
		return &quot;Press release&quot;;					-- display press release annotation

	elseif &quot;techreport&quot; == cite_class then		-- if this citation is cite techreport
		return &quot;Technical report&quot;;				-- display techreport annotation
	
	elseif &quot;thesis&quot; == cite_class then			-- if this citation is cite thesis (degree option handled after this function returns)
			return &quot;Thesis&quot;;					-- display simple thesis annotation (without |degree= modification)
	end
end

-- returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct. If not a valid month, returns 0
function get_month_number (month)
local long_months = {['January']=1, ['February']=2, ['March']=3, ['April']=4, ['May']=5, ['June']=6, ['July']=7, ['August']=8, ['September']=9, ['October']=10, ['November']=11, ['December']=12};
local short_months = {['Jan']=1, ['Feb']=2, ['Mar']=3, ['Apr']=4, ['May']=5, ['Jun']=6, ['Jul']=7, ['Aug']=8, ['Sep']=9, ['Oct']=10, ['Nov']=11, ['Dec']=12};
local temp;
	temp=long_months[month];
	if temp then return temp; end				-- if month is the long-form name
	temp=short_months[month];
	if temp then return temp; end				-- if month is the short-form name
	return 0;									-- misspelled, improper case, or not a month name
end

-- returns a number according to the sequence of seasons in a year: 1 for Winter, etc.  Capitalization and spelling must be correct. If not a valid season, returns 0
function get_season_number (season)
local season_list = {['Winter']=1, ['Spring']=2, ['Summer']=3, ['Fall']=4, ['Autumn']=4}
local temp;
	temp=season_list[season];
	if temp then return temp; end				-- if season is a valid name return its number
	return 0;									-- misspelled, improper case, or not a season name
end

--[[
Returns true if day is less than or equal to the number of days in month; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap years before 1582 and Gregorian leap years after 1582.
Where the two calendars overlap (1582 to approximately 1923) dates are assumed to be Gregorian.
]]
function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if (2==month) then							-- if February
		month_length = 28;						-- then 28 days unless
		if 1582 &gt; tonumber(year) then			-- Julian calendar
			if 0==(year%4) then
				month_length = 29;
			end
		else									-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then	-- is a leap year?
				month_length = 29;				-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end

--[[
Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.  Similarly, seasons are also left to right, earliest to latest in time.  There is
an oddity with seasons.  Winter is assigned a value of 1, spring 2, ..., fall and autumn 4.  Because winter can follow fall/autumn at the end of a calender year, a special test
is made to see if |date=Fall-Winter yyyy (4-1) is the date.
]]

function is_valid_month_season_range(range_start, range_end)
	local range_start_number = get_month_number (range_start);
	
	if 0 == range_start_number then								-- is this a month range?
		local range_start_number = get_season_number (range_start);		-- not a month; is it a season? get start season number
		local range_end_number = get_season_number (range_end);			-- get end season number

		if 0 ~= range_start_number then							-- is start of range a season?
			if range_start_number &lt; range_end_number then		-- range_start is a season
				return true;									-- return true when range_end is also a season and follows start season; else false
			end
			if 4 == range_start_number and 1 == range_end_number then	-- special case when range is Fall-Winter or Autumn-Winter
				return true;
			end
		end
		return false;		-- range_start is not a month or a season; or range_start is a season and range_end is not; or improper season sequence
	end

	local range_end_number = get_month_number (range_end);		-- get end month number
	if range_start_number &lt; range_end_number then				-- range_start is a month; does range_start precede range_end?
		return true;											-- if yes, return true
	end
	return false;												-- range_start month number is greater than or equal to range end number; or range end isn't a month
end

--[[
Check date format to see that it is one of the formats approved by MOS:DATE: MMMM D, YYYY; D MMMM YYYY; MMMM YYYY; YYYY-MM-DD; YYYY.
Additionally, check the date to see that it is a real date: no 31 in 30-day months; no 29 February when not a leap year.  Months, both long-form and three
character abbreviations, and seasons must be spelled correctly.

If the date fails the fomat tests, this function returns false but does not return values for anchor_year and COinS_date.  When this happens, the date parameter is
used in the COinS metadata and the CITEREF identifier gets its year from the year parameter if present.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is date_string without anchor_year disambiguator if any
]]
function check_date (date_string)
	local year;
	local month=0;		-- assume that month and day are not used; if either is zero then final year/month/day validation is not necessary
	local day=0;
	local day2=0;		-- second day in a day range	
	local anchor_year;
	local coins_date;

	if date_string:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then			-- Year-initial numerical year month day format
		year, month, day=string.match(date_string, &quot;(%d%d%d%d)%-(%d%d)%-(%d%d)&quot;);
		month=tonumber(month);
		if 12 &lt; month or 1 &gt; month or 1583 &gt; tonumber(year) then return false; end	-- month number not valid or not Gregorian calendar
		anchor_year = year;

	elseif date_string:match(&quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then	-- month-initial: month day, year
		month, day, anchor_year, year=string.match(date_string, &quot;(%a+)%s*(%d%d?),%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end					-- return false if month text isn't one of the twelve months
				
	elseif date_string:match(&quot;^%a+ +[1-9]%d?–[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then	-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year=string.match(date_string, &quot;(%a+) +(%d%d?)–(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end					-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day-initial: day month year
		day, month, anchor_year, year=string.match(date_string, &quot;(%d%d*)%s*(%a+)%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end					-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d?–[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then	-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year=string.match(date_string, &quot;(%d%d?)–(%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end					-- return false if month text isn't one of the twelve months

	elseif mw.ustring.match (date_string, &quot;^%a+–%a+ +[1-9]%d%d%d%a?$&quot;) then		-- month/season range year; months separated by endash 
		local month2
		month, month2, anchor_year, year=mw.ustring.match (date_string, &quot;(%a+)[%-/–](%a+)%s*((%d%d%d%d)%a?)&quot;);
		if false == is_valid_month_season_range(month, month2) then
			return false;
		end
		
	elseif date_string:match(&quot;^%a+ +%d%d%d%d%a?$&quot;) then			-- month/season year
		month, anchor_year, year=string.match(date_string, &quot;(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if 0 == get_month_number (month) then					-- if month text isn't one of the twelve months, might be a season
			if 0 == get_season_number (month) then				-- not a month, is it a season?
				return false;									-- return false not a month or one of the five seasons
			end
		end

	elseif date_string:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then			-- year; here accept either YYY or YYYY
		anchor_year, year=string.match(date_string, &quot;((%d%d%d%d?)%a?)&quot;);

	else
		return false;											-- date format not one of the MOS:DATE approved formats
	end

	if 0~=month and 0~=day then									-- check year month day dates for validity
		if 0~=day2 then											-- If there is a second day (d–d Mmm YYYY or Mmm d–d, YYYY) test the second date
			if false==is_valid_date(year,month,day2) then
				return false;									-- second date in date range string is not a real date return false; unset anchor_year and coins_date
			end													-- if second date range string is valid, fall through to test the first date range
		end
		if false==is_valid_date(year,month,day) then
			return false;										-- date string is not a real date return false; unset anchor_year and coins_date
		end
	end

	coins_date= mw.ustring.gsub( date_string, &quot;–&quot;, &quot;-&quot; );		-- if here, then date_string is valid; set coins_date and replace any ndash with a hyphen
	
	return true, anchor_year, coins_date;						-- format is good and date string represents a real date
end	

--[[
Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true and values for anchor_year (used in CITEREF identifiers) and COinS_date (used in the COinS metadata).  The |date= parameter test is unique.  This function only 
accepts anchor_year and COinS_date results from the |date= parameter test and |date= is the only date-holding parameter that is allowed to contain the no-date keywords
&quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.
]]

function dates(date_parameters_list)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local error_message =&quot;&quot;;
	local good_date=false;
	
	for k, v in pairs(date_parameters_list) do		-- for each date-holding parameter in the list
		if is_set(v) then							-- if the parameter has a value
			if v:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then	-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				if 'date'==k then
					good_date, anchor_year, COinS_date = true, v:match(&quot;((c%. [1-9]d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
				elseif 'year'==k then
					good_date =  true;
				end
			elseif 'year'==k then					-- if the parameter is |year= (but not c. year)
				if v:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then	-- year with or without CITEREF disambiguator
					good_date =  true;
				end
			elseif 'date'==k then					-- if the parameter is |date=
				if v:match(&quot;n%.d%.%a?&quot;) then		-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v:match(&quot;nd%a?$&quot;) then		-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v);	-- go test the date
				end
			else									-- any other date-holding parameter
				good_date = check_date (v);			-- go test the date
			end
			if false==good_date then				-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then		-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;	-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;	-- add the failed parameter
			end
		end
	end
	if is_set(error_message) then
		table.insert( z.message_tail, { seterror( 'bad_date', {error_message}, true ) } );	-- add this error message
	end

	return anchor_year, COinS_date;		-- and done
end

--[[
Determines whether a URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
    -- Protocol-relative or URL scheme
    return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
    return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

--[[
ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in checkisbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.
]]
function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of bytes
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end	-- isbn13 begins with 978 or 979
		isbn_str = { isbn_str:byte(1, len) };
		for i, v in ipairs( isbn_str ) do
			temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
		end
		return temp % 10 == 0;
	end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
    return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
        return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
    end));
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if not is_set(str) then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        
        -- Remove newlines as they break italics.
        return str:gsub( '\n', ' ' );
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    if maximum ~= nil and maximum &lt; 1 then return &quot;&quot;, 0; end
    
    for i,person in ipairs(people) do
        if is_set(person.last) then
            local mask = person.mask
            local one
            local sep_one = sep;
            if maximum ~= nil and i &gt; maximum then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask;
                    sep_one = &quot; &quot;;
                end
            else
                one = person.last
                local first = person.first
                if is_set(first) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if is_set(person.link) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert( text, one )
            table.insert( text, sep_one )
        end
    end

    local count = #text / 2;
    if count &gt; 0 then 
        if count &gt; 1 and is_set(lastauthoramp) and not etal then
            text[#text-2] = &quot; &amp; &quot;;
        end
        text[#text] = nil; 
    end
    
    local result = table.concat(text) -- construct list
    if etal then 
        local etal_text = cfg.messages['et al'];
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result = 
        '&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
    end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
    return &quot;CITEREF&quot; .. table.concat( options );
end

-- Gets name list from the input arguments
function extractnames(args, list_name)
    local names = {};
    local i = 1;
    local last;
    
    while true do
        last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );
        if not is_set(last) then
            -- just in case someone passed in an empty parameter
            break;
        end
        names[i] = {
            last = last,
            first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i ),
            link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ),
            mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i )
        };
        i = i + 1;
    end
    return names;
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
    local id_list = {};
    for k, v in pairs( cfg.id_handlers ) do    
        v = selectone( args, v.parameters, 'redundant_parameters' );
        if is_set(v) then id_list[k] = v; end
    end
    return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
    local new_list, handler = {};
    
    function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
    
    for k, v in pairs( id_list ) do
        -- fallback to read-only cfg
        handler = setmetatable( { ['id'] = v }, fallback(k) );
        
        if handler.mode == 'external' then
            table.insert( new_list, {handler.label, externallinkid( handler ) } );
        elseif handler.mode == 'internal' then
            table.insert( new_list, {handler.label, internallinkid( handler ) } );
        elseif handler.mode ~= 'manual' then
            error( cfg.messages['unknown_ID_mode'] );
        elseif k == 'DOI' then
            table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
        elseif k == 'ASIN' then
            table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
        elseif k == 'OL' then
            table.insert( new_list, {handler.label, openlibrary( v ) } );
        elseif k == 'PMC' then
            table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
        elseif k == 'PMID' then
            table.insert( new_list, {handler.label, pmid( v ) } );
        elseif k == 'ISSN' then
        	table.insert( new_list, {handler.label, issn( v ) } );
        elseif k == 'ISBN' then
            local ISBN = internallinkid( handler );
            if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
                ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
            end
            table.insert( new_list, {handler.label, ISBN } );                
        else
            error( cfg.messages['unknown_manual_ID'] );
        end
    end
    
    function comp( a, b )	-- used in following table.sort()
        return a[1] &lt; b[1];
    end
    
    table.sort( new_list, comp );
    for k, v in ipairs( new_list ) do
        new_list[k] = v[2];
    end
    
    return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
    local value = nil;
    local selected = '';
    local error_list = {};
    
    if index ~= nil then index = tostring(index); end
    
    -- Handle special case of &quot;#&quot; replaced by empty string
    if index == '1' then
        for _, v in ipairs( possible ) do
            v = v:gsub( &quot;#&quot;, &quot;&quot; );
            if is_set(args[v]) then
                if value ~= nil and selected ~= v then
                    table.insert( error_list, v );
                else
                    value = args[v];
                    selected = v;
                end
            end
        end        
    end
    
    for _, v in ipairs( possible ) do
        if index ~= nil then
            v = v:gsub( &quot;#&quot;, index );
        end
        if is_set(args[v]) then
            if value ~= nil and selected ~=  v then
                table.insert( error_list, v );
            else
                value = args[v];
                selected = v;
            end
        end
    end
    
    if #error_list &gt; 0 then
        local error_str = &quot;&quot;;
        for _, k in ipairs( error_list ) do
            if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
            error_str = error_str .. wrap( 'parameter', k );
        end
        if #error_list &gt; 1 then
            error_str = error_str .. cfg.messages['parameter-final-separator'];
        else
            error_str = error_str .. cfg.messages['parameter-pair-separator'];
        end
        error_str = error_str .. wrap( 'parameter', selected );
        table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
    end
    
    return value, selected;
end

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
function COinS(data)
    if 'table' ~= type(data) or nil == next(data) then
        return '';
    end
    
    local ctx_ver = &quot;Z39.88-2004&quot;;
    
    -- treat table strictly as an array with only set values.
    local OCinSoutput = setmetatable( {}, {
        __newindex = function(self, key, value)
            if is_set(value) then
                rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
            end
        end
    });
    
    if is_set(data.Chapter) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Chapter;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    elseif is_set(data.Periodical) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
        OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    else
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
    end
    
    OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
    OCinSoutput[&quot;rft.date&quot;] = data.Date;
    OCinSoutput[&quot;rft.series&quot;] = data.Series;
    OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
    OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
    OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
    OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
    OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
    
    for k, v in pairs( data.ID_list ) do
        local id, value = cfg.id_handlers[k].COinS;
        if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
        if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
            OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
        else
            OCinSoutput[ id ] = value;
        end
    end
    
    local last, first;
    for k, v in ipairs( data.Authors ) do
        last, first = v.last, v.first;
        if k == 1 then
            if is_set(last) then
                OCinSoutput[&quot;rft.aulast&quot;] = last;
            end
            if is_set(first) then 
                OCinSoutput[&quot;rft.aufirst&quot;] = first;
            end
        end
        if is_set(last) and is_set(first) then
            OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
        elseif is_set(last) then
            OCinSoutput[&quot;rft.au&quot;] = last;
        end
    end
    
    OCinSoutput.rft_id = data.URL;
    OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
    OCinSoutput = setmetatable( OCinSoutput, nil );
    
    -- sort with version string always first, and combine.
    table.sort( OCinSoutput );
    table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
    return table.concat(OCinSoutput, &quot;&amp;&quot;);
end

--[[
This is the main function doing the majority of the citation
formatting.
]]
function citation0( config, args)
    --[[ 
    Load Input Parameters
    The argment_wrapper facillitates the mapping of multiple
    aliases to single internal variable.
    ]]
    local A = argument_wrapper( args );

    local i 
    local PPrefix = A['PPrefix']
    local PPPrefix = A['PPPrefix']
    if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = A['Authors'];
    local a = extractnames( args, 'AuthorList' );

    local Coauthors = A['Coauthors'];
    local Others = A['Others'];
    local Editors = A['Editors'];
    local e = extractnames( args, 'EditorList' );

    local Year = A['Year'];
    local PublicationDate = A['PublicationDate'];
    local OrigYear = A['OrigYear'];
    local Date = A['Date'];
    local LayDate = A['LayDate'];
    ------------------------------------------------- Get title data
    local Title = A['Title'];
    local BookTitle = A['BookTitle'];
    local Conference = A['Conference'];
    local TransTitle = A['TransTitle'];
    local TitleNote = A['TitleNote'];
    local TitleLink = A['TitleLink'];
    local Chapter = A['Chapter'];
    local ChapterLink = A['ChapterLink'];
    local TransChapter = A['TransChapter'];
    local TitleType = A['TitleType'];
    local Degree = A['Degree'];
    local Docket = A['Docket'];
    local ArchiveURL = A['ArchiveURL'];
    local URL = A['URL']
    local URLorigin = A:ORIGIN('URL');
    local ChapterURL = A['ChapterURL'];
    local ChapterURLorigin = A:ORIGIN('ChapterURL');
    local ConferenceURL = A['ConferenceURL'];
    local ConferenceURLorigin = A:ORIGIN('ConferenceURL');
    local Periodical = A['Periodical'];

--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped

All other combinations of |encyclopedia, |title, and |article are not modified
]]
	if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
		if is_set(Periodical) then					-- Periodical is set when |encyclopedia is set
			if is_set(Title) then
				if not is_set(Chapter) then
					Chapter = Title;				-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					TransChapter = TransTitle;
					Title = Periodical;
					Periodical = '';				-- redundant so unset
					TransTitle = '';				-- redundant so unset
				end
			else									-- |title not set
				Title = Periodical;					-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';					-- redundant so unset
			end
		end
	end

local Series = A['Series'];
    local Volume = A['Volume'];
    local Issue = A['Issue'];
    local Position = '';
    local Page, Pages, At, page_type;
    
    Page = A['Page'];
    Pages = hyphentodash( A['Pages'] );
    At = A['At'];
    
    if is_set(Page) then
        if is_set(Pages) or is_set(At) then
            Page = Page .. &quot; &quot; .. seterror('extra_pages');
            Pages = '';
            At = '';
        end
    elseif is_set(Pages) then
        if is_set(At) then
            Pages = Pages .. &quot; &quot; .. seterror('extra_pages');
            At = '';
        end
    end    
    
    local Edition = A['Edition'];
    local PublicationPlace = A['PublicationPlace']
    local Place = A['Place'];
    
    if not is_set(PublicationPlace) and is_set(Place) then
        PublicationPlace = Place;
    end
    
    if PublicationPlace == Place then Place = ''; end
    
    local PublisherName = A['PublisherName'];
    local RegistrationRequired = A['RegistrationRequired'];
    local SubscriptionRequired = A['SubscriptionRequired'];
    local Via = A['Via'];
    local AccessDate = A['AccessDate'];
    local ArchiveDate = A['ArchiveDate'];
    local Agency = A['Agency'];
    local DeadURL = A['DeadURL']
    local Language = A['Language'];
    local Format = A['Format'];
    local Ref = A['Ref'];
    
    local DoiBroken = A['DoiBroken'];
	
-- Special case for cite techreport.
	local ID = A['ID'];
	if (config.CitationClass == &quot;techreport&quot;) then	-- special case for cite techreport
		if is_set(Issue) then						-- cite techreport uses 'number', which other citations aliase to 'issue'
			if not is_set(ID) then					-- can we use ID for the &quot;number&quot;?
				ID = Issue;							-- yes, use it
				Issue = &quot;&quot;;							-- unset Issue so that &quot;number&quot; isn't duplicated in the rendered citation or COinS metadata
			else									-- can't use ID so emit error message
				ID = ID .. &quot; &quot; .. seterror('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
			end
		end	
	end	
			
    local ASINTLD = A['ASINTLD'];
    local IgnoreISBN = A['IgnoreISBN'];
    local Embargo = A['Embargo'];

    local ID_list = extractids( args );
    
    local Quote = A['Quote'];
    local PostScript = A['PostScript'];
    local LayURL = A['LayURL'];
    local LaySource = A['LaySource'];
    local Transcript = A['Transcript'];
    local TranscriptURL = A['TranscriptURL'] 
    local TranscriptURLorigin = A:ORIGIN('TranscriptURL');
    local sepc = A['Separator'];
    local LastAuthorAmp = A['LastAuthorAmp'];
    local no_tracking_cats = A['NoTracking'];

    local use_lowercase = ( sepc ~= '.' );
    local this_page = mw.title.getCurrentTitle();  --Also used for COinS and for language
    
    if not is_set(no_tracking_cats) then
        for k, v in pairs( cfg.uncategorized_namespaces ) do
            if this_page.nsText == v then
                no_tracking_cats = &quot;true&quot;;
                break;
            end
        end
    end

	local anchor_year;		-- used in the CITEREF identifier
	local COinS_date;		-- used in the COinS metadata

-- legacy: promote concatenation of |day=, |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set(Date) then
		Date = Year;						-- promote Year to Date
		Year = nil;							-- make nil so Year as empty string isn't used for CITEREF
		if is_set(Date) then
			local Month = A['Month'];
			if is_set(Month) then
				Date = Month .. &quot; &quot; .. Date;
				local Day = A['Day']
				if is_set(Day) then Date = Day .. &quot; &quot; .. Date end
			end
		elseif is_set(PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;			-- promonte PublicationDate to Date
			PublicationDate = '';			-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end	-- if PublicationDate is same as Date, don't display in rendered citation

-- Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates.
-- TODO: 2013-10-27: AirDate is nil when dates() is called because it hasn't been set yet.  Move the call to dates() or set AirDate earlier.
	anchor_year, COinS_date = dates({['accessdate']=AccessDate, ['airdate']=AirDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
		['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.

	--Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set
	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_embargoed(Embargo) then
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];	-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];		-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if is_set(BookTitle) then
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = BookTitle;
        TitleLink = '';
        TransTitle = '';
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = A['AirDate'];
        local SeriesLink = A['SeriesLink'];
        local Season = A['Season'];
        local SeriesNumber = A['SeriesNumber'];
        local Network = A['Network'];
        local Station = A['Station'];
        local s, n = {}, {};
        local Sep = (first_set(A[&quot;SeriesSeparator&quot;], A[&quot;Separator&quot;]) or &quot;&quot;) .. &quot; &quot;;
        
        if is_set(Issue) then table.insert(s, cfg.messages[&quot;episode&quot;] .. &quot; &quot; .. Issue); Issue = ''; end
        if is_set(Season) then table.insert(s, cfg.messages[&quot;season&quot;] .. &quot; &quot; .. Season); end
        if is_set(SeriesNumber) then table.insert(s, cfg.messages[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber); end
        if is_set(Network) then table.insert(n, Network); end
        if is_set(Station) then table.insert(n, Station); end
        
        Date = Date or AirDate;
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = Series;
        TitleLink = SeriesLink;
        TransTitle = '';
        
        Series = table.concat(s, Sep);
        ID = table.concat(n, Sep);
    end
    
    -- COinS metadata (see &lt;http://ocoins.info/&gt;) for
    -- automated parsing of citation information.
    local OCinSoutput = COinS{
        ['Periodical'] = Periodical,
        ['Chapter'] = Chapter,
        ['Title'] = Title,
        ['PublicationPlace'] = PublicationPlace,
        ['Date'] = first_set(COinS_date, Date),		-- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here?  Should we be including invalid dates in metadata?
        ['Series'] = Series,
        ['Volume'] = Volume,
        ['Issue'] = Issue,
        ['Pages'] = first_set(Page, Pages, At),
        ['Edition'] = Edition,
        ['PublisherName'] = PublisherName,
        ['URL'] = first_set( URL, ChapterURL ),
        ['Authors'] = a,
        ['ID_list'] = ID_list,
        ['RawPage'] = this_page.prefixedText,
    };

    if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = '';
        TitleLink = '';
        TransTitle = '';
    end

    -- Now perform various field 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 not is_set(Authors) then
        local Maximum = tonumber( A['DisplayAuthors'] );
        
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #a == 9 then 
            Maximum = 8;
            table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
        elseif not is_set(Maximum) then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = A[&quot;AuthorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;AuthorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A[&quot;AuthorFormat&quot;],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if is_set(Coauthors) then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
        
        Authors = listpeople(control, a) 
    end

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { seterror('coauthors_missing_author', {}, true) } );	-- emit error message
	end

    local EditorCount
    if not is_set(Editors) then
        local Maximum = tonumber( A['DisplayEditors'] );
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #e == 4 then 
            Maximum = 3;
            table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
        elseif not is_set(Maximum) then
            Maximum = #e + 1;
        end

        local control = { 
            sep = A[&quot;EditorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;EditorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A['EditorFormat'],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };

        Editors, EditorCount = listpeople(control, e);
    else
        EditorCount = 1;
    end

    local Cartography = &quot;&quot;;
    local Scale = &quot;&quot;;
    if config.CitationClass == &quot;map&quot; then
        if not is_set( Authors ) and is_set( PublisherName ) then
            Authors = PublisherName;
            PublisherName = &quot;&quot;;
        end
        Cartography = A['Cartography'];
        if is_set( Cartography ) then
            Cartography = sepc .. &quot; &quot; .. wrap( 'cartography', Cartography, use_lowercase );
        end        
        Scale = A['Scale'];
        if is_set( Scale ) then
            Scale = sepc .. &quot; &quot; .. Scale;
        end        
    end
    
    if  not is_set(URL) and
        not is_set(ChapterURL) and
        not is_set(ArchiveURL) and
        not is_set(ConferenceURL) and
        not is_set(TranscriptURL) then
        
        -- Test if cite web or cite podcast |url= is missing or empty 
		if inArray(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;}) then	
			table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
		end
        
        -- Test if accessdate is given without giving a URL
        if is_set(AccessDate) then
            table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
            AccessDate = '';
        end
        
        -- Test if format is given without giving a URL
        if is_set(Format) then
            Format = Format .. seterror( 'format_missing_url' );
        end
    end
    
    -- Test if citation has no title
    if  not is_set(Chapter) and
        not is_set(Title) and
        not is_set(Periodical) and
        not is_set(Conference) and
        not is_set(TransTitle) and
        not is_set(TransChapter) then
        table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
    end
    
    Format = is_set(Format) and &quot; (&quot; .. Format .. &quot;)&quot; or &quot;&quot;;
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if is_set( ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
            URLorigin = A:ORIGIN('ArchiveURL')
        end
    end
    
    -- Format chapter / article title
    if is_set(Chapter) and is_set(ChapterLink) then 
        Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot;;
    end
    if is_set(Periodical) and is_set(Title) then
        Chapter = wrap( 'italic-title', Chapter );
        TransChapter = wrap( 'trans-italic-title', TransChapter );
    else
		Chapter = kern_quotes (Chapter);				-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
        Chapter = wrap( 'quoted-title', Chapter );
        TransChapter = wrap( 'trans-quoted-title', TransChapter );
    end
    
    local TransError = &quot;&quot;
    if is_set(TransChapter) then
        if not is_set(Chapter) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
        else
            TransChapter = &quot; &quot; .. TransChapter;
        end
    end
    
    Chapter = Chapter .. TransChapter;
    
    if is_set(Chapter) then
        if not is_set(ChapterLink) then
            if is_set(ChapterURL) then
                Chapter = externallink( ChapterURL, Chapter ) .. TransError;
                if not is_set(URL) then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif is_set(URL) then 
                Chapter = externallink( URL, Chapter ) .. TransError .. Format;
                URL = &quot;&quot;;
                Format = &quot;&quot;;
            else
                Chapter = Chapter .. TransError;
            end            
        elseif is_set(ChapterURL) then
            Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. 
                TransError;
        else
            Chapter = Chapter .. TransError;
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    elseif is_set(ChapterURL) then
        Chapter = &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. sepc .. &quot; &quot;;
    end        
    
    -- Format main title.
    if is_set(TitleLink) and is_set(Title) then
        Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
    end
    
    if is_set(Periodical) then
		Title = kern_quotes (Title);				-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    elseif inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;pressrelease&quot;,&quot;conference&quot;,&quot;podcast&quot;}) and
            not is_set(Chapter) then
		Title = kern_quotes (Title);				-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    else
        Title = wrap( 'italic-title', Title );
        TransTitle = wrap( 'trans-italic-title', TransTitle );
    end
    
    TransError = &quot;&quot;;
    if is_set(TransTitle) then
        if not is_set(Title) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
        else
            TransTitle = &quot; &quot; .. TransTitle;
        end
    end
    
    Title = Title .. TransTitle;
    
    if is_set(Title) then
        if not is_set(TitleLink) and is_set(URL) then 
            Title = externallink( URL, Title ) .. TransError .. Format       
            URL = &quot;&quot;;
            Format = &quot;&quot;;
        else
            Title = Title .. TransError;
        end
    end
    
    if is_set(Place) then
        Place = &quot; &quot; .. wrap( 'written', Place, use_lowercase ) .. sepc .. &quot; &quot;;
    end
    
    if is_set(Conference) then
        if is_set(ConferenceURL) then
            Conference = externallink( ConferenceURL, Conference );
        end
        Conference = sepc .. &quot; &quot; .. Conference
    elseif is_set(ConferenceURL) then
        Conference = sepc .. &quot; &quot; .. externallink( ConferenceURL, nil, ConferenceURLorigin );
    end
    
    if not is_set(Position) then
        local Minutes = A['Minutes'];
        if is_set(Minutes) then
            Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
        else
            local Time = A['Time'];
            if is_set(Time) then
                local TimeCaption = A['TimeCaption']
                if not is_set(TimeCaption) then
                    TimeCaption = cfg.messages['event'];
                    if sepc ~= '.' then
                        TimeCaption = TimeCaption:lower();
                    end
                end
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
            end
        end
    else
        Position = &quot; &quot; .. Position;
        At = '';
    end
    
    if not is_set(Page) then
        if is_set(Pages) then
            if is_set(Periodical) and
                not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
                Pages = &quot;: &quot; .. Pages;
            elseif tonumber(Pages) ~= nil then
                Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
            else
                Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
            end
        end
    else
        if is_set(Periodical) and
            not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
            Page = &quot;: &quot; .. Page;
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page;
        end
    end
    
    At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
    Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
    if config.CitationClass == 'map' then
        local Section = A['Section'];
        local Inset = A['Inset'];
        if first_set( Pages, Page, At ) ~= nil or sepc ~= '.' then
            if is_set( Section ) then
                Section = &quot;, &quot; .. wrap( 'section', Section, true );
            end
            if is_set( Inset ) then
                Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
            end
        else
            if is_set( Section ) then
                Section = sepc .. &quot; &quot; .. wrap( 'section', Section, use_lowercase );
                if is_set( Inset ) then
                    Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
                end
            elseif is_set( Inset ) then
                Inset = sepc .. &quot; &quot; .. wrap( 'inset', Inset, use_lowercase );
            end            
        end            
        At = At .. Section .. Inset;        
    end    

	--[[Look in the list of iso639-1 language codes to see if the value provided in the language parameter matches one of them.  If a match is found, 
	use that value; if not, then use the value that was provided with the language parameter.
	
	Categories are assigned in a manner similar to the {{xx icon}} templates - categorizes only mainspace citations and only when the language code is not 'en' (English).
	]]
	if is_set (Language) then
--		local name = mw.language.fetchLanguageName( Language:lower(), &quot;en&quot; );	-- experiment: this seems to return correct ISO 639-1 language names
		local name = cfg.iso639_1[Language:lower()];		-- get the language name if Language parameter has a valid iso 639-1 code
		if nil == name then
			Language=&quot; &quot; .. wrap( 'language', Language );	-- no match, use parameter's value
		else
			if 0 == this_page.namespace and 'en' ~= Language:lower() then	--found a match; is this page main / article space and English not the language?
				Language=&quot; &quot; .. wrap( 'language', name .. '[[Category:Articles with ' .. name .. '-language external links]]' );	-- in main space and not English: categorize
			else
				Language=&quot; &quot; .. wrap( 'language', name );	--not in mainspace or language is English so don't categorize
			end
		end
	else
		Language=&quot;&quot;;	-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;

-- handle type parameter for those CS1 citations that have default values

	if inArray(config.CitationClass, {&quot;podcast&quot;,&quot;pressrelease&quot;,&quot;techreport&quot;,&quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then	-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then					-- if type parameter is specified
		TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot;;	-- display it in parentheses
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
    Edition = is_set(Edition) and (&quot; &quot; .. wrap( 'edition', Edition )) or &quot;&quot;;
    Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
    Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
    OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
    Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;
    
    if is_set(Volume) then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume;
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
        end
    end
    
    ------------------------------------ totally unrelated data
    --[[ Loosely mimic {{subscription required}} template; Via parameter identifies a delivery source that is not the publisher; these sources often, but not always, exist
    behind a registration or paywall.  So here, we've chosen to decouple via from subscription (via has never been part of the registration required template).
    
    Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link note is displayed. There are no error messages for this condition.
    ]]
    if is_set(Via) then
        Via = &quot; &quot; .. wrap( 'via', Via );
    end

	if is_set(SubscriptionRequired) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription']; --here when 'via' parameter not used but 'subscription' is
    elseif is_set(RegistrationRequired) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration']; --here when 'via' and 'subscription' parameters not used but 'registration' is
    end

    if is_set(AccessDate) then
        local retrv_text = &quot; &quot; .. cfg.messages['retrieved']
        if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
        AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
            .. substitute( retrv_text, {AccessDate} ) .. '&lt;/span&gt;'
    end
    
    if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end

    
    ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo} );

    if is_set(URL) then
        URL = &quot; &quot; .. externallink( URL, nil, URLorigin );
    end

    if is_set(Quote) then
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        Quote = sepc ..&quot; &quot; .. wrap( 'quoted-text', Quote ); 
        PostScript = &quot;&quot;;
    elseif PostScript:lower() == &quot;none&quot; then
        PostScript = &quot;&quot;;
    end
    
    local Archived
    if is_set(ArchiveURL) then
        if not is_set(ArchiveDate) then
            ArchiveDate = seterror('archive_missing_date');
        end
        if &quot;no&quot; == DeadURL then
            local arch_text = cfg.messages['archived'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
                { externallink( ArchiveURL, arch_text ), ArchiveDate } );
            if not is_set(OriginalURL) then
                Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url');                               
            end
        elseif is_set(OriginalURL) then
            local arch_text = cfg.messages['archived-dead'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text,
                { externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
        else
            local arch_text = cfg.messages['archived-missing'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
                { seterror('archive_missing_url'), ArchiveDate } );
        end
    else
        Archived = &quot;&quot;
    end
    
    local Lay
    if is_set(LayURL) then
        if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
        if is_set(LaySource) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot;;
        else
            LaySource = &quot;&quot;;
        end
        if sepc == '.' then
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;;
    end
    
    if is_set(Transcript) then
        if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
    elseif is_set(TranscriptURL) then
        Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
    end
    
    local Publisher;
    if is_set(Periodical) and
        not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end
        elseif is_set(PublicationPlace) then
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if is_set(PublicationDate) then
            if is_set(Publisher) then
                Publisher = Publisher .. &quot;, &quot; .. wrap( 'published', PublicationDate );
            else
                Publisher = PublicationDate;
            end
        end
        if is_set(Publisher) then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if is_set(PublicationDate) then
            PublicationDate = &quot; (&quot; .. wrap( 'published', PublicationDate ) .. &quot;)&quot;;
        end
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif is_set(PublicationPlace) then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    
    -- Several of the above rely upon detecting this as nil, so do it last.
    if is_set(Periodical) then
        if is_set(Title) or is_set(TitleNote) then 
            Periodical = sepc .. &quot; &quot; .. wrap( 'italic-title', Periodical ) 
        else 
            Periodical = wrap( 'italic-title', Periodical )
        end
    end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if inArray(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
        if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, 
            Language, Cartography, Edition, Publisher, Agency, Volume, Issue}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, Language, 
            Volume, Issue, Others, Cartography, Edition, Publisher, Agency}, sepc );
    end
    
    if #ID_list &gt; 0 then
        ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
    else
        ID_list = ID;
    end
    
    local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
    local text;
    local pgtext = Position .. Page .. Pages .. At;
    
    if is_set(Authors) then
        if is_set(Coauthors) then
            Authors = Authors .. A['AuthorSeparator'] .. &quot; &quot; .. Coauthors
        end
        if is_set(Date) then
            Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        elseif string.sub(Authors,-1,-1) == sepc then
            Authors = Authors .. &quot; &quot;
        else
            Authors = Authors .. sepc .. &quot; &quot;
        end
        if is_set(Editors) then
            local in_text = &quot; &quot;;
            local post_text = &quot;&quot;;
            if is_set(Chapter) then
                in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
            else
                if EditorCount &lt;= 1 then
                    post_text = &quot;, &quot; .. cfg.messages['editor'];
                else
                    post_text = &quot;, &quot; .. cfg.messages['editors'];
                end
            end 
            if (sepc ~= '.') then in_text = in_text:lower() end
            Editors = in_text .. Editors .. post_text;
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = Editors .. &quot; &quot;
                else Editors = Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif is_set(Editors) then
        if is_set(Date) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
            else
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if is_set(Date) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end
        if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
            text = safejoin( {Chapter, Place, tcommon}, sepc );
            text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
            text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
            text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if is_set(PostScript) and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    local options = {};
    
    if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
        options.class = &quot;citation &quot; .. config.CitationClass;
    else
        options.class = &quot;citation&quot;;
    end
    
    if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if #a &gt; 0 then
                for i,v in ipairs(a) do 
                    names[i] = v.last 
                    if i == 4 then break end
                end
            elseif #e &gt; 0 then
                for i,v in ipairs(e) do 
                    names[i] = v.last 
                    if i == 4 then break end                
                end
            end
			names[ #names + 1 ] = first_set(Year, anchor_year);	-- Year first for legacy citations
            id = anchorid(names)
        end
        options.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = {};
        text = seterror('empty_citation');
        z.message_tail = {};
    end
    
    if is_set(options.id) then 
        text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    else
        text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    end        

    local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        text = text .. &quot; &quot;;
        for i,v in ipairs( z.message_tail ) do
            if is_set(v[1]) then
                if i == #z.message_tail then
                    text = text .. errorcomment( v[1], v[2] );
                else
                    text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
                end
            end
        end
    end
    
    no_tracking_cats = no_tracking_cats:lower();
    if inArray(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    local suggestions = {};
    local error_text, error_state;

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        args[k] = v;       
    end    

    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            if not validate( k ) then            
                error_text = &quot;&quot;;
                if type( k ) ~= 'string' then
                    -- Exclude empty numbered parameters
                    if v:match(&quot;%S+&quot;) ~= nil then
                        error_text, error_state = seterror( 'text_ignored', {v}, true );
                    end
                elseif validate( k:lower() ) then 
                    error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
                else
                    if #suggestions == 0 then
                        suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
                    end
                    if suggestions[ k:lower() ] ~= nil then
                        error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
                    else
                        error_text, error_state = seterror( 'parameter_ignored', {k}, true );
                    end
                end                  
                if error_text ~= '' then
                    table.insert( z.message_tail, {error_text, error_state} );
                end                
            end
            args[k] = v;
        elseif args[k] ~= nil or (k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z</text>
      <sha1>4i2tnuaf7cbcfig1bj9z2jmmfeu9jyx</sha1>
    </revision>
    <revision>
      <id>4669</id>
      <parentid>4668</parentid>
      <timestamp>2014-02-16T22:51:08Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Fix kerning; tweak doi display;</comment>
      <origin>4669</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="85649" sha1="blgksqtxo6r9apy9go13tq1hphuuz4n" xml:space="preserve">local z = {
    error_categories = {};
    error_ids = {};
    message_tail = {};
}

-- Include translation message hooks, ID and error handling configuration settings.
local cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );

-- Contains a list of all recognized parameters
local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );

-- Whether variable is set or not
function is_set( var )
    return not (var == nil or var == '');
end

-- First set variable or nil if none
function first_set(...)
    local list = {...};
    for _, var in pairs(list) do
        if is_set( var ) then
            return var;
        end
    end
end

-- Whether needle is in haystack
function inArray( needle, haystack )
    if needle == nil then
        return false;
    end
    for n,v in ipairs( haystack ) do
        if v == needle then
            return n;
        end
    end
    return false;
end

--[[
Categorize and emit an error message when the citation contains one or more deprecated parameters.  Because deprecated parameters (currently |day=, |month=,
|coauthor=, and |coauthors=) aren't related to each other and because these parameters may be concatenated into the variables used by |date= and |author#= (and aliases)
details of which parameter caused the error message are not provided.  Only one error message is emitted regarless of the number of deprecated parameters in the citation.
]]
function deprecated_parameter()
	if true ~= Page_in_deprecated_cat then	-- if we haven't been here before then set a 
		Page_in_deprecated_cat=true;		-- sticky flag so that if there are more than one deprecated parameter the category is added only once
		table.insert( z.message_tail, { seterror( 'deprecated_params', {error_message}, true ) } );		-- add error message
	end
end

-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
--	return args and tostring( mw.message.newRawMessage( msg, args ) ) or msg;
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[
Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern  either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
]]
function kern_quotes (str)
	local left='&lt;span style=&quot;padding-left:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains leading single or double quote mark
	local right='&lt;span style=&quot;padding-right:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains trailing single or double quote mark
	
	if  str:match (&quot;^[\&quot;\'][^\']&quot;) then
		str = string.gsub( str, &quot;^[\&quot;\']&quot;, left, 1 );				-- replace (captured) leading single or double quote with left-side &lt;span&gt;
	end
	if str:match (&quot;[^\'][\&quot;\']$&quot;) then
		str = string.gsub( str, &quot;[\&quot;\']$&quot;, right, 1 );			-- replace (captured) trailing single or double quote with right-side &lt;span&gt;
	end
	return str;
end

-- Wraps a string using a message_list configuration taking one argument
function wrap( key, str, lower )
    if not is_set( str ) then
        return &quot;&quot;;
    elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
        str = safeforitalics( str );
    end
    if lower == true then
        return substitute( cfg.messages[key]:lower(), {str} );
    else
        return substitute( cfg.messages[key], {str} );
    end        
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
    local origin = {};
    
    return setmetatable({
        ORIGIN = function( self, k )
            local dummy = self[k]; --force the variable to be loaded.
            return origin[k];
        end
    },
    {
        __index = function ( tbl, k )
            if origin[k] ~= nil then
                return nil;
            end
            
            local args, list, v = args, cfg.aliases[k];
            
            if type( list ) == 'table' then
                v, origin[k] = selectone( args, list, 'redundant_parameters' );
                if origin[k] == nil then
                    origin[k] = ''; -- Empty string, not nil
                end
            elseif list ~= nil then
                v, origin[k] = args[list], list;
            else
                -- maybe let through instead of raising an error?
                -- v, origin[k] = args[k], k;
                error( cfg.messages['unknown_argument_map'] );
            end
            
            -- Empty strings, not nil;
            if v == nil then
                v = cfg.defaults[k] or '';
                origin[k] = '';
            end
            
            tbl = rawset( tbl, k, v );
            return v;
        end,
    });
end

--[[
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
]]
function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
    return wrap( hidden and 'hidden-error' or 'visible-error', content );
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
    local error_state = cfg.error_conditions[ error_id ];
    
    prefix = prefix or &quot;&quot;;
    suffix = suffix or &quot;&quot;;
    
    if error_state == nil then
        error( cfg.messages['undefined_error'] );
    elseif is_set( error_state.category ) then
        table.insert( z.error_categories, error_state.category );
    end
    
    local message = substitute( error_state.message, arguments );
    
    message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
        &quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
        cfg.messages['help page label'] .. &quot;]])&quot;;
    
    z.error_ids[ error_id ] = true;
    if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
            and z.error_ids['citation_missing_title'] then
        return '', false;
    end
    
    message = table.concat({ prefix, message, suffix });
    
    if raw == true then
        return message, error_state.hidden;
    end        
        
    return errorcomment( message, error_state.hidden );
end

-- Formats a wiki style external link
function externallinkid(options)
    local url_string = options.id;
    if options.encode == true or options.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, url_string, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Formats a wiki style internal link
function internallinkid(options)
    return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, options.id, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Format an external link with error checking
function externallink( URL, label, source )
    local error_str = &quot;&quot;;
    if not is_set( label ) then
        label = URL;
        if is_set( source ) then
            error_str = seterror( 'bare_url_missing_title', { wrap( 'parameter', source ) }, false, &quot; &quot; );
        else
            error( cfg.messages[&quot;bare_url_no_origin&quot;] );
        end            
    end
    if not checkurl( URL ) then
        error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
    end
    return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safeforurl( label ), &quot;]&quot;, error_str });
end

-- Formats a link to Amazon
function amazon(id, domain)
    if not is_set(domain) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local handler = cfg.id_handlers['ASIN'];
    return externallinkid({link = handler.link,
        label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
        encode=handler.encode, separator = handler.separator})
end

--[[
Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]
function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmid' );	-- set an error message
		end
	end
	
	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns true; otherwse, returns false because the embargo has expired or |embargo= not set in this cite.
]]
function is_embargoed(embargo)
	if is_set(embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 and tonumber( embargo_date ) &gt;= tonumber( todays_date ) then	--is embargo date is in the future?
			return true;	-- still embargoed
		end
	end
	return false;			-- embargo expired or |embargo= not set
end

--[[
Formats a PMC and checks for embargoed articles.  The embargo parameter takes a date for a value. If the embargo date is in the future
the PMC identifier will not be linked to the article.  If the embargo specifies a date in the past, or if it is empty or omitted, then
the PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.
]]
function pmc(id, embargo)
	local handler = cfg.id_handlers['PMC'];
    
	local text;

	if is_embargoed(embargo) then
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id;	--still embargoed so no external link
	else
		text = externallinkid({link = handler.link, label = handler.label,			--no embargo date, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.
function doi(id, inactive)
    local cat = &quot;&quot;
    local handler = cfg.id_handlers['DOI'];
    
    local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. seterror( 'bad_doi' );
	end
	return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    local handler = cfg.id_handlers['OL'];
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    else
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode}) .. 
            ' ' .. seterror( 'bad_ol' );
    end
end

--[[
Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.
]]
function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and ndashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 didgits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = externallinkid({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. seterror( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[
This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those citations that have defaults.
Also handles the special case where it is desireable to omit the title type from the rendered citation (|type=none).
]]
function set_titletype(cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;					-- if |type=none then type parameter not displayed
		end
		return title_type;						-- if |type= has been set to any other value use that value
	end

	if &quot;podcast&quot; == cite_class then				-- if this citation is cite podcast
		return &quot;Podcast&quot;;						-- display podcast annotation

	elseif &quot;pressrelease&quot; == cite_class then	-- if this citation is cite press release
		return &quot;Press release&quot;;					-- display press release annotation

	elseif &quot;techreport&quot; == cite_class then		-- if this citation is cite techreport
		return &quot;Technical report&quot;;				-- display techreport annotation
	
	elseif &quot;thesis&quot; == cite_class then			-- if this citation is cite thesis (degree option handled after this function returns)
			return &quot;Thesis&quot;;					-- display simple thesis annotation (without |degree= modification)
	end
end

-- returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct. If not a valid month, returns 0
function get_month_number (month)
local long_months = {['January']=1, ['February']=2, ['March']=3, ['April']=4, ['May']=5, ['June']=6, ['July']=7, ['August']=8, ['September']=9, ['October']=10, ['November']=11, ['December']=12};
local short_months = {['Jan']=1, ['Feb']=2, ['Mar']=3, ['Apr']=4, ['May']=5, ['Jun']=6, ['Jul']=7, ['Aug']=8, ['Sep']=9, ['Oct']=10, ['Nov']=11, ['Dec']=12};
local temp;
	temp=long_months[month];
	if temp then return temp; end				-- if month is the long-form name
	temp=short_months[month];
	if temp then return temp; end				-- if month is the short-form name
	return 0;									-- misspelled, improper case, or not a month name
end

-- returns a number according to the sequence of seasons in a year: 1 for Winter, etc.  Capitalization and spelling must be correct. If not a valid season, returns 0
function get_season_number (season)
local season_list = {['Winter']=1, ['Spring']=2, ['Summer']=3, ['Fall']=4, ['Autumn']=4}
local temp;
	temp=season_list[season];
	if temp then return temp; end				-- if season is a valid name return its number
	return 0;									-- misspelled, improper case, or not a season name
end

--[[
Returns true if day is less than or equal to the number of days in month; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap years before 1582 and Gregorian leap years after 1582.
Where the two calendars overlap (1582 to approximately 1923) dates are assumed to be Gregorian.
]]
function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if (2==month) then							-- if February
		month_length = 28;						-- then 28 days unless
		if 1582 &gt; tonumber(year) then			-- Julian calendar
			if 0==(year%4) then
				month_length = 29;
			end
		else									-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then	-- is a leap year?
				month_length = 29;				-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end

--[[
Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.  Similarly, seasons are also left to right, earliest to latest in time.  There is
an oddity with seasons.  Winter is assigned a value of 1, spring 2, ..., fall and autumn 4.  Because winter can follow fall/autumn at the end of a calender year, a special test
is made to see if |date=Fall-Winter yyyy (4-1) is the date.
]]

function is_valid_month_season_range(range_start, range_end)
	local range_start_number = get_month_number (range_start);
	
	if 0 == range_start_number then								-- is this a month range?
		local range_start_number = get_season_number (range_start);		-- not a month; is it a season? get start season number
		local range_end_number = get_season_number (range_end);			-- get end season number

		if 0 ~= range_start_number then							-- is start of range a season?
			if range_start_number &lt; range_end_number then		-- range_start is a season
				return true;									-- return true when range_end is also a season and follows start season; else false
			end
			if 4 == range_start_number and 1 == range_end_number then	-- special case when range is Fall-Winter or Autumn-Winter
				return true;
			end
		end
		return false;		-- range_start is not a month or a season; or range_start is a season and range_end is not; or improper season sequence
	end

	local range_end_number = get_month_number (range_end);		-- get end month number
	if range_start_number &lt; range_end_number then				-- range_start is a month; does range_start precede range_end?
		return true;											-- if yes, return true
	end
	return false;												-- range_start month number is greater than or equal to range end number; or range end isn't a month
end

--[[
Check date format to see that it is one of the formats approved by MOS:DATE: MMMM D, YYYY; D MMMM YYYY; MMMM YYYY; YYYY-MM-DD; YYYY.
Additionally, check the date to see that it is a real date: no 31 in 30-day months; no 29 February when not a leap year.  Months, both long-form and three
character abbreviations, and seasons must be spelled correctly.

If the date fails the fomat tests, this function returns false but does not return values for anchor_year and COinS_date.  When this happens, the date parameter is
used in the COinS metadata and the CITEREF identifier gets its year from the year parameter if present.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is date_string without anchor_year disambiguator if any
]]
function check_date (date_string)
	local year;
	local month=0;		-- assume that month and day are not used; if either is zero then final year/month/day validation is not necessary
	local day=0;
	local day2=0;		-- second day in a day range	
	local anchor_year;
	local coins_date;

	if date_string:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then			-- Year-initial numerical year month day format
		year, month, day=string.match(date_string, &quot;(%d%d%d%d)%-(%d%d)%-(%d%d)&quot;);
		month=tonumber(month);
		if 12 &lt; month or 1 &gt; month or 1583 &gt; tonumber(year) then return false; end	-- month number not valid or not Gregorian calendar
		anchor_year = year;

	elseif date_string:match(&quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then	-- month-initial: month day, year
		month, day, anchor_year, year=string.match(date_string, &quot;(%a+)%s*(%d%d?),%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end					-- return false if month text isn't one of the twelve months
				
	elseif date_string:match(&quot;^%a+ +[1-9]%d?–[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then	-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year=string.match(date_string, &quot;(%a+) +(%d%d?)–(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end					-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day-initial: day month year
		day, month, anchor_year, year=string.match(date_string, &quot;(%d%d*)%s*(%a+)%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end					-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d?–[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then	-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year=string.match(date_string, &quot;(%d%d?)–(%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end					-- return false if month text isn't one of the twelve months

	elseif mw.ustring.match (date_string, &quot;^%a+–%a+ +[1-9]%d%d%d%a?$&quot;) then		-- month/season range year; months separated by endash 
		local month2
		month, month2, anchor_year, year=mw.ustring.match (date_string, &quot;(%a+)[%-/–](%a+)%s*((%d%d%d%d)%a?)&quot;);
		if false == is_valid_month_season_range(month, month2) then
			return false;
		end
		
	elseif date_string:match(&quot;^%a+ +%d%d%d%d%a?$&quot;) then			-- month/season year
		month, anchor_year, year=string.match(date_string, &quot;(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if 0 == get_month_number (month) then					-- if month text isn't one of the twelve months, might be a season
			if 0 == get_season_number (month) then				-- not a month, is it a season?
				return false;									-- return false not a month or one of the five seasons
			end
		end

	elseif date_string:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then			-- year; here accept either YYY or YYYY
		anchor_year, year=string.match(date_string, &quot;((%d%d%d%d?)%a?)&quot;);

	else
		return false;											-- date format not one of the MOS:DATE approved formats
	end

	if 0~=month and 0~=day then									-- check year month day dates for validity
		if 0~=day2 then											-- If there is a second day (d–d Mmm YYYY or Mmm d–d, YYYY) test the second date
			if false==is_valid_date(year,month,day2) then
				return false;									-- second date in date range string is not a real date return false; unset anchor_year and coins_date
			end													-- if second date range string is valid, fall through to test the first date range
		end
		if false==is_valid_date(year,month,day) then
			return false;										-- date string is not a real date return false; unset anchor_year and coins_date
		end
	end

	coins_date= mw.ustring.gsub( date_string, &quot;–&quot;, &quot;-&quot; );		-- if here, then date_string is valid; set coins_date and replace any ndash with a hyphen
	
	return true, anchor_year, coins_date;						-- format is good and date string represents a real date
end	

--[[
Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true and values for anchor_year (used in CITEREF identifiers) and COinS_date (used in the COinS metadata).  The |date= parameter test is unique.  This function only 
accepts anchor_year and COinS_date results from the |date= parameter test and |date= is the only date-holding parameter that is allowed to contain the no-date keywords
&quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.
]]

function dates(date_parameters_list)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local error_message =&quot;&quot;;
	local good_date=false;
	
	for k, v in pairs(date_parameters_list) do		-- for each date-holding parameter in the list
		if is_set(v) then							-- if the parameter has a value
			if v:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then	-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				if 'date'==k then
					good_date, anchor_year, COinS_date = true, v:match(&quot;((c%. [1-9]d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
				elseif 'year'==k then
					good_date =  true;
				end
			elseif 'year'==k then					-- if the parameter is |year= (but not c. year)
				if v:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then	-- year with or without CITEREF disambiguator
					good_date =  true;
				end
			elseif 'date'==k then					-- if the parameter is |date=
				if v:match(&quot;n%.d%.%a?&quot;) then		-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v:match(&quot;nd%a?$&quot;) then		-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v);	-- go test the date
				end
			else									-- any other date-holding parameter
				good_date = check_date (v);			-- go test the date
			end
			if false==good_date then				-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then		-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;	-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;	-- add the failed parameter
			end
		end
	end
	if is_set(error_message) then
		table.insert( z.message_tail, { seterror( 'bad_date', {error_message}, true ) } );	-- add this error message
	end

	return anchor_year, COinS_date;		-- and done
end

--[[
Determines whether a URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
    -- Protocol-relative or URL scheme
    return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
    return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

--[[
ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in checkisbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.
]]
function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of bytes
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end	-- isbn13 begins with 978 or 979
		isbn_str = { isbn_str:byte(1, len) };
		for i, v in ipairs( isbn_str ) do
			temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
		end
		return temp % 10 == 0;
	end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
    return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
        return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
    end));
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if not is_set(str) then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        
        -- Remove newlines as they break italics.
        return str:gsub( '\n', ' ' );
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    if maximum ~= nil and maximum &lt; 1 then return &quot;&quot;, 0; end
    
    for i,person in ipairs(people) do
        if is_set(person.last) then
            local mask = person.mask
            local one
            local sep_one = sep;
            if maximum ~= nil and i &gt; maximum then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask;
                    sep_one = &quot; &quot;;
                end
            else
                one = person.last
                local first = person.first
                if is_set(first) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if is_set(person.link) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
            end
            table.insert( text, one )
            table.insert( text, sep_one )
        end
    end

    local count = #text / 2;
    if count &gt; 0 then 
        if count &gt; 1 and is_set(lastauthoramp) and not etal then
            text[#text-2] = &quot; &amp; &quot;;
        end
        text[#text] = nil; 
    end
    
    local result = table.concat(text) -- construct list
    if etal then 
        local etal_text = cfg.messages['et al'];
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result = 
        '&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
    end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
    return &quot;CITEREF&quot; .. table.concat( options );
end

-- Gets name list from the input arguments
function extractnames(args, list_name)
    local names = {};
    local i = 1;
    local last;
    
    while true do
        last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );
        if not is_set(last) then
            -- just in case someone passed in an empty parameter
            break;
        end
        names[i] = {
            last = last,
            first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i ),
            link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ),
            mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i )
        };
        i = i + 1;
    end
    return names;
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
    local id_list = {};
    for k, v in pairs( cfg.id_handlers ) do    
        v = selectone( args, v.parameters, 'redundant_parameters' );
        if is_set(v) then id_list[k] = v; end
    end
    return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
    local new_list, handler = {};
    
    function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
    
    for k, v in pairs( id_list ) do
        -- fallback to read-only cfg
        handler = setmetatable( { ['id'] = v }, fallback(k) );
        
        if handler.mode == 'external' then
            table.insert( new_list, {handler.label, externallinkid( handler ) } );
        elseif handler.mode == 'internal' then
            table.insert( new_list, {handler.label, internallinkid( handler ) } );
        elseif handler.mode ~= 'manual' then
            error( cfg.messages['unknown_ID_mode'] );
        elseif k == 'DOI' then
            table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
        elseif k == 'ASIN' then
            table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
        elseif k == 'OL' then
            table.insert( new_list, {handler.label, openlibrary( v ) } );
        elseif k == 'PMC' then
            table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
        elseif k == 'PMID' then
            table.insert( new_list, {handler.label, pmid( v ) } );
        elseif k == 'ISSN' then
        	table.insert( new_list, {handler.label, issn( v ) } );
        elseif k == 'ISBN' then
            local ISBN = internallinkid( handler );
            if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
                ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
            end
            table.insert( new_list, {handler.label, ISBN } );                
        else
            error( cfg.messages['unknown_manual_ID'] );
        end
    end
    
    function comp( a, b )	-- used in following table.sort()
        return a[1] &lt; b[1];
    end
    
    table.sort( new_list, comp );
    for k, v in ipairs( new_list ) do
        new_list[k] = v[2];
    end
    
    return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
    local value = nil;
    local selected = '';
    local error_list = {};
    
    if index ~= nil then index = tostring(index); end
    
    -- Handle special case of &quot;#&quot; replaced by empty string
    if index == '1' then
        for _, v in ipairs( possible ) do
            v = v:gsub( &quot;#&quot;, &quot;&quot; );
            if is_set(args[v]) then
                if value ~= nil and selected ~= v then
                    table.insert( error_list, v );
                else
                    value = args[v];
                    selected = v;
                end
            end
        end        
    end
    
    for _, v in ipairs( possible ) do
        if index ~= nil then
            v = v:gsub( &quot;#&quot;, index );
        end
        if is_set(args[v]) then
            if value ~= nil and selected ~=  v then
                table.insert( error_list, v );
            else
                value = args[v];
                selected = v;
            end
        end
    end
    
    if #error_list &gt; 0 then
        local error_str = &quot;&quot;;
        for _, k in ipairs( error_list ) do
            if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
            error_str = error_str .. wrap( 'parameter', k );
        end
        if #error_list &gt; 1 then
            error_str = error_str .. cfg.messages['parameter-final-separator'];
        else
            error_str = error_str .. cfg.messages['parameter-pair-separator'];
        end
        error_str = error_str .. wrap( 'parameter', selected );
        table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
    end
    
    return value, selected;
end

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
function COinS(data)
    if 'table' ~= type(data) or nil == next(data) then
        return '';
    end
    
    local ctx_ver = &quot;Z39.88-2004&quot;;
    
    -- treat table strictly as an array with only set values.
    local OCinSoutput = setmetatable( {}, {
        __newindex = function(self, key, value)
            if is_set(value) then
                rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
            end
        end
    });
    
    if is_set(data.Chapter) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Chapter;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    elseif is_set(data.Periodical) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
        OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    else
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
    end
    
    OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
    OCinSoutput[&quot;rft.date&quot;] = data.Date;
    OCinSoutput[&quot;rft.series&quot;] = data.Series;
    OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
    OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
    OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
    OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
    OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
    
    for k, v in pairs( data.ID_list ) do
        local id, value = cfg.id_handlers[k].COinS;
        if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
        if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
            OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
        else
            OCinSoutput[ id ] = value;
        end
    end
    
    local last, first;
    for k, v in ipairs( data.Authors ) do
        last, first = v.last, v.first;
        if k == 1 then
            if is_set(last) then
                OCinSoutput[&quot;rft.aulast&quot;] = last;
            end
            if is_set(first) then 
                OCinSoutput[&quot;rft.aufirst&quot;] = first;
            end
        end
        if is_set(last) and is_set(first) then
            OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
        elseif is_set(last) then
            OCinSoutput[&quot;rft.au&quot;] = last;
        end
    end
    
    OCinSoutput.rft_id = data.URL;
    OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
    OCinSoutput = setmetatable( OCinSoutput, nil );
    
    -- sort with version string always first, and combine.
    table.sort( OCinSoutput );
    table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
    return table.concat(OCinSoutput, &quot;&amp;&quot;);
end

--[[
This is the main function doing the majority of the citation
formatting.
]]
function citation0( config, args)
    --[[ 
    Load Input Parameters
    The argment_wrapper facillitates the mapping of multiple
    aliases to single internal variable.
    ]]
    local A = argument_wrapper( args );

    local i 
    local PPrefix = A['PPrefix']
    local PPPrefix = A['PPPrefix']
    if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = A['Authors'];
    local a = extractnames( args, 'AuthorList' );

    local Coauthors = A['Coauthors'];
    local Others = A['Others'];
    local Editors = A['Editors'];
    local e = extractnames( args, 'EditorList' );

    local Year = A['Year'];
    local PublicationDate = A['PublicationDate'];
    local OrigYear = A['OrigYear'];
    local Date = A['Date'];
    local LayDate = A['LayDate'];
    ------------------------------------------------- Get title data
    local Title = A['Title'];
    local BookTitle = A['BookTitle'];
    local Conference = A['Conference'];
    local TransTitle = A['TransTitle'];
    local TitleNote = A['TitleNote'];
    local TitleLink = A['TitleLink'];
    local Chapter = A['Chapter'];
    local ChapterLink = A['ChapterLink'];
    local TransChapter = A['TransChapter'];
    local TitleType = A['TitleType'];
    local Degree = A['Degree'];
    local Docket = A['Docket'];
    local ArchiveURL = A['ArchiveURL'];
    local URL = A['URL']
    local URLorigin = A:ORIGIN('URL');
    local ChapterURL = A['ChapterURL'];
    local ChapterURLorigin = A:ORIGIN('ChapterURL');
    local ConferenceURL = A['ConferenceURL'];
    local ConferenceURLorigin = A:ORIGIN('ConferenceURL');
    local Periodical = A['Periodical'];

--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped

All other combinations of |encyclopedia, |title, and |article are not modified
]]
	if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
		if is_set(Periodical) then					-- Periodical is set when |encyclopedia is set
			if is_set(Title) then
				if not is_set(Chapter) then
					Chapter = Title;				-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					TransChapter = TransTitle;
					Title = Periodical;
					Periodical = '';				-- redundant so unset
					TransTitle = '';				-- redundant so unset
				end
			else									-- |title not set
				Title = Periodical;					-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';					-- redundant so unset
			end
		end
	end

local Series = A['Series'];
    local Volume = A['Volume'];
    local Issue = A['Issue'];
    local Position = '';
    local Page, Pages, At, page_type;
    
    Page = A['Page'];
    Pages = hyphentodash( A['Pages'] );
    At = A['At'];
    
    if is_set(Page) then
        if is_set(Pages) or is_set(At) then
            Page = Page .. &quot; &quot; .. seterror('extra_pages');
            Pages = '';
            At = '';
        end
    elseif is_set(Pages) then
        if is_set(At) then
            Pages = Pages .. &quot; &quot; .. seterror('extra_pages');
            At = '';
        end
    end    
    
    local Edition = A['Edition'];
    local PublicationPlace = A['PublicationPlace']
    local Place = A['Place'];
    
    if not is_set(PublicationPlace) and is_set(Place) then
        PublicationPlace = Place;
    end
    
    if PublicationPlace == Place then Place = ''; end
    
    local PublisherName = A['PublisherName'];
    local RegistrationRequired = A['RegistrationRequired'];
    local SubscriptionRequired = A['SubscriptionRequired'];
    local Via = A['Via'];
    local AccessDate = A['AccessDate'];
    local ArchiveDate = A['ArchiveDate'];
    local Agency = A['Agency'];
    local DeadURL = A['DeadURL']
    local Language = A['Language'];
    local Format = A['Format'];
    local Ref = A['Ref'];
    
    local DoiBroken = A['DoiBroken'];
	
-- Special case for cite techreport.
	local ID = A['ID'];
	if (config.CitationClass == &quot;techreport&quot;) then	-- special case for cite techreport
		if is_set(Issue) then						-- cite techreport uses 'number', which other citations aliase to 'issue'
			if not is_set(ID) then					-- can we use ID for the &quot;number&quot;?
				ID = Issue;							-- yes, use it
				Issue = &quot;&quot;;							-- unset Issue so that &quot;number&quot; isn't duplicated in the rendered citation or COinS metadata
			else									-- can't use ID so emit error message
				ID = ID .. &quot; &quot; .. seterror('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
			end
		end	
	end	
			
    local ASINTLD = A['ASINTLD'];
    local IgnoreISBN = A['IgnoreISBN'];
    local Embargo = A['Embargo'];

    local ID_list = extractids( args );
    
    local Quote = A['Quote'];
    local PostScript = A['PostScript'];
    local LayURL = A['LayURL'];
    local LaySource = A['LaySource'];
    local Transcript = A['Transcript'];
    local TranscriptURL = A['TranscriptURL'] 
    local TranscriptURLorigin = A:ORIGIN('TranscriptURL');
    local sepc = A['Separator'];
    local LastAuthorAmp = A['LastAuthorAmp'];
    local no_tracking_cats = A['NoTracking'];

    local use_lowercase = ( sepc ~= '.' );
    local this_page = mw.title.getCurrentTitle();  --Also used for COinS and for language
    
    if not is_set(no_tracking_cats) then
        for k, v in pairs( cfg.uncategorized_namespaces ) do
            if this_page.nsText == v then
                no_tracking_cats = &quot;true&quot;;
                break;
            end
        end
    end

	local anchor_year;		-- used in the CITEREF identifier
	local COinS_date;		-- used in the COinS metadata

-- legacy: promote concatenation of |day=, |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set(Date) then
		Date = Year;						-- promote Year to Date
		Year = nil;							-- make nil so Year as empty string isn't used for CITEREF
		if is_set(Date) then
			local Month = A['Month'];
			if is_set(Month) then
				Date = Month .. &quot; &quot; .. Date;
				local Day = A['Day']
				if is_set(Day) then Date = Day .. &quot; &quot; .. Date end
			end
		elseif is_set(PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;			-- promonte PublicationDate to Date
			PublicationDate = '';			-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end	-- if PublicationDate is same as Date, don't display in rendered citation

-- Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates.
-- TODO: 2013-10-27: AirDate is nil when dates() is called because it hasn't been set yet.  Move the call to dates() or set AirDate earlier.
	anchor_year, COinS_date = dates({['accessdate']=AccessDate, ['airdate']=AirDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
		['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.

	--Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set
	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_embargoed(Embargo) then
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];	-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];		-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

    -- Account for the oddity that is {{cite conference}}, before generation of COinS data.
    if is_set(BookTitle) then
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = BookTitle;
        TitleLink = '';
        TransTitle = '';
    end
    -- Account for the oddity that is {{cite episode}}, before generation of COinS data.
    if config.CitationClass == &quot;episode&quot; then
        local AirDate = A['AirDate'];
        local SeriesLink = A['SeriesLink'];
        local Season = A['Season'];
        local SeriesNumber = A['SeriesNumber'];
        local Network = A['Network'];
        local Station = A['Station'];
        local s, n = {}, {};
        local Sep = (first_set(A[&quot;SeriesSeparator&quot;], A[&quot;Separator&quot;]) or &quot;&quot;) .. &quot; &quot;;
        
        if is_set(Issue) then table.insert(s, cfg.messages[&quot;episode&quot;] .. &quot; &quot; .. Issue); Issue = ''; end
        if is_set(Season) then table.insert(s, cfg.messages[&quot;season&quot;] .. &quot; &quot; .. Season); end
        if is_set(SeriesNumber) then table.insert(s, cfg.messages[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber); end
        if is_set(Network) then table.insert(n, Network); end
        if is_set(Station) then table.insert(n, Station); end
        
        Date = Date or AirDate;
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = Series;
        TitleLink = SeriesLink;
        TransTitle = '';
        
        Series = table.concat(s, Sep);
        ID = table.concat(n, Sep);
    end
    
    -- COinS metadata (see &lt;http://ocoins.info/&gt;) for
    -- automated parsing of citation information.
    local OCinSoutput = COinS{
        ['Periodical'] = Periodical,
        ['Chapter'] = Chapter,
        ['Title'] = Title,
        ['PublicationPlace'] = PublicationPlace,
        ['Date'] = first_set(COinS_date, Date),		-- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here?  Should we be including invalid dates in metadata?
        ['Series'] = Series,
        ['Volume'] = Volume,
        ['Issue'] = Issue,
        ['Pages'] = first_set(Page, Pages, At),
        ['Edition'] = Edition,
        ['PublisherName'] = PublisherName,
        ['URL'] = first_set( URL, ChapterURL ),
        ['Authors'] = a,
        ['ID_list'] = ID_list,
        ['RawPage'] = this_page.prefixedText,
    };

    if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = '';
        TitleLink = '';
        TransTitle = '';
    end

    -- Now perform various field 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 not is_set(Authors) then
        local Maximum = tonumber( A['DisplayAuthors'] );
        
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #a == 9 then 
            Maximum = 8;
            table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
        elseif not is_set(Maximum) then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = A[&quot;AuthorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;AuthorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A[&quot;AuthorFormat&quot;],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if is_set(Coauthors) then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
        
        Authors = listpeople(control, a) 
    end

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { seterror('coauthors_missing_author', {}, true) } );	-- emit error message
	end

    local EditorCount
    if not is_set(Editors) then
        local Maximum = tonumber( A['DisplayEditors'] );
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #e == 4 then 
            Maximum = 3;
            table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
        elseif not is_set(Maximum) then
            Maximum = #e + 1;
        end

        local control = { 
            sep = A[&quot;EditorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;EditorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A['EditorFormat'],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };

        Editors, EditorCount = listpeople(control, e);
    else
        EditorCount = 1;
    end

    local Cartography = &quot;&quot;;
    local Scale = &quot;&quot;;
    if config.CitationClass == &quot;map&quot; then
        if not is_set( Authors ) and is_set( PublisherName ) then
            Authors = PublisherName;
            PublisherName = &quot;&quot;;
        end
        Cartography = A['Cartography'];
        if is_set( Cartography ) then
            Cartography = sepc .. &quot; &quot; .. wrap( 'cartography', Cartography, use_lowercase );
        end        
        Scale = A['Scale'];
        if is_set( Scale ) then
            Scale = sepc .. &quot; &quot; .. Scale;
        end        
    end
    
    if  not is_set(URL) and
        not is_set(ChapterURL) and
        not is_set(ArchiveURL) and
        not is_set(ConferenceURL) and
        not is_set(TranscriptURL) then
        
        -- Test if cite web or cite podcast |url= is missing or empty 
		if inArray(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;}) then	
			table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
		end
        
        -- Test if accessdate is given without giving a URL
        if is_set(AccessDate) then
            table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
            AccessDate = '';
        end
        
        -- Test if format is given without giving a URL
        if is_set(Format) then
            Format = Format .. seterror( 'format_missing_url' );
        end
    end
    
    -- Test if citation has no title
    if  not is_set(Chapter) and
        not is_set(Title) and
        not is_set(Periodical) and
        not is_set(Conference) and
        not is_set(TransTitle) and
        not is_set(TransChapter) then
        table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
    end
    
    Format = is_set(Format) and &quot; (&quot; .. Format .. &quot;)&quot; or &quot;&quot;;
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if is_set( ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
            URLorigin = A:ORIGIN('ArchiveURL')
        end
    end
    
    -- Format chapter / article title
    if is_set(Chapter) and is_set(ChapterLink) then 
        Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot;;
    end
    if is_set(Periodical) and is_set(Title) then
        Chapter = wrap( 'italic-title', Chapter );
        TransChapter = wrap( 'trans-italic-title', TransChapter );
    else
		Chapter = kern_quotes (Chapter);				-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
        Chapter = wrap( 'quoted-title', Chapter );
        TransChapter = wrap( 'trans-quoted-title', TransChapter );
    end
    
    local TransError = &quot;&quot;
    if is_set(TransChapter) then
        if not is_set(Chapter) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
        else
            TransChapter = &quot; &quot; .. TransChapter;
        end
    end
    
    Chapter = Chapter .. TransChapter;
    
    if is_set(Chapter) then
        if not is_set(ChapterLink) then
            if is_set(ChapterURL) then
                Chapter = externallink( ChapterURL, Chapter ) .. TransError;
                if not is_set(URL) then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif is_set(URL) then 
                Chapter = externallink( URL, Chapter ) .. TransError .. Format;
                URL = &quot;&quot;;
                Format = &quot;&quot;;
            else
                Chapter = Chapter .. TransError;
            end            
        elseif is_set(ChapterURL) then
            Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. 
                TransError;
        else
            Chapter = Chapter .. TransError;
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    elseif is_set(ChapterURL) then
        Chapter = &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. sepc .. &quot; &quot;;
    end        
    
    -- Format main title.
    if is_set(TitleLink) and is_set(Title) then
        Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
    end
    
    if is_set(Periodical) then
		Title = kern_quotes (Title);				-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    elseif inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;pressrelease&quot;,&quot;conference&quot;,&quot;podcast&quot;}) and
            not is_set(Chapter) then
		Title = kern_quotes (Title);				-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    else
        Title = wrap( 'italic-title', Title );
        TransTitle = wrap( 'trans-italic-title', TransTitle );
    end
    
    TransError = &quot;&quot;;
    if is_set(TransTitle) then
        if not is_set(Title) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
        else
            TransTitle = &quot; &quot; .. TransTitle;
        end
    end
    
    Title = Title .. TransTitle;
    
    if is_set(Title) then
        if not is_set(TitleLink) and is_set(URL) then 
            Title = externallink( URL, Title ) .. TransError .. Format       
            URL = &quot;&quot;;
            Format = &quot;&quot;;
        else
            Title = Title .. TransError;
        end
    end
    
    if is_set(Place) then
        Place = &quot; &quot; .. wrap( 'written', Place, use_lowercase ) .. sepc .. &quot; &quot;;
    end
    
    if is_set(Conference) then
        if is_set(ConferenceURL) then
            Conference = externallink( ConferenceURL, Conference );
        end
        Conference = sepc .. &quot; &quot; .. Conference
    elseif is_set(ConferenceURL) then
        Conference = sepc .. &quot; &quot; .. externallink( ConferenceURL, nil, ConferenceURLorigin );
    end
    
    if not is_set(Position) then
        local Minutes = A['Minutes'];
        if is_set(Minutes) then
            Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
        else
            local Time = A['Time'];
            if is_set(Time) then
                local TimeCaption = A['TimeCaption']
                if not is_set(TimeCaption) then
                    TimeCaption = cfg.messages['event'];
                    if sepc ~= '.' then
                        TimeCaption = TimeCaption:lower();
                    end
                end
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
            end
        end
    else
        Position = &quot; &quot; .. Position;
        At = '';
    end
    
    if not is_set(Page) then
        if is_set(Pages) then
            if is_set(Periodical) and
                not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
                Pages = &quot;: &quot; .. Pages;
            elseif tonumber(Pages) ~= nil then
                Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
            else
                Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
            end
        end
    else
        if is_set(Periodical) and
            not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
            Page = &quot;: &quot; .. Page;
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page;
        end
    end
    
    At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
    Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
    if config.CitationClass == 'map' then
        local Section = A['Section'];
        local Inset = A['Inset'];
        if first_set( Pages, Page, At ) ~= nil or sepc ~= '.' then
            if is_set( Section ) then
                Section = &quot;, &quot; .. wrap( 'section', Section, true );
            end
            if is_set( Inset ) then
                Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
            end
        else
            if is_set( Section ) then
                Section = sepc .. &quot; &quot; .. wrap( 'section', Section, use_lowercase );
                if is_set( Inset ) then
                    Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
                end
            elseif is_set( Inset ) then
                Inset = sepc .. &quot; &quot; .. wrap( 'inset', Inset, use_lowercase );
            end            
        end            
        At = At .. Section .. Inset;        
    end    

	--[[Look in the list of iso639-1 language codes to see if the value provided in the language parameter matches one of them.  If a match is found, 
	use that value; if not, then use the value that was provided with the language parameter.
	
	Categories are assigned in a manner similar to the {{xx icon}} templates - categorizes only mainspace citations and only when the language code is not 'en' (English).
	]]
	if is_set (Language) then
--		local name = mw.language.fetchLanguageName( Language:lower(), &quot;en&quot; );	-- experiment: this seems to return correct ISO 639-1 language names
		local name = cfg.iso639_1[Language:lower()];		-- get the language name if Language parameter has a valid iso 639-1 code
		if nil == name then
			Language=&quot; &quot; .. wrap( 'language', Language );	-- no match, use parameter's value
		else
			if 0 == this_page.namespace and 'en' ~= Language:lower() then	--found a match; is this page main / article space and English not the language?
				Language=&quot; &quot; .. wrap( 'language', name .. '[[Category:Articles with ' .. name .. '-language external links]]' );	-- in main space and not English: categorize
			else
				Language=&quot; &quot; .. wrap( 'language', name );	--not in mainspace or language is English so don't categorize
			end
		end
	else
		Language=&quot;&quot;;	-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;

-- handle type parameter for those CS1 citations that have default values

	if inArray(config.CitationClass, {&quot;podcast&quot;,&quot;pressrelease&quot;,&quot;techreport&quot;,&quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then	-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then					-- if type parameter is specified
		TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot;;	-- display it in parentheses
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
    Edition = is_set(Edition) and (&quot; &quot; .. wrap( 'edition', Edition )) or &quot;&quot;;
    Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
    Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
    OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
    Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;
    
    if is_set(Volume) then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume;
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
        end
    end
    
    ------------------------------------ totally unrelated data
    --[[ Loosely mimic {{subscription required}} template; Via parameter identifies a delivery source that is not the publisher; these sources often, but not always, exist
    behind a registration or paywall.  So here, we've chosen to decouple via from subscription (via has never been part of the registration required template).
    
    Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link note is displayed. There are no error messages for this condition.
    ]]
    if is_set(Via) then
        Via = &quot; &quot; .. wrap( 'via', Via );
    end

	if is_set(SubscriptionRequired) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription']; --here when 'via' parameter not used but 'subscription' is
    elseif is_set(RegistrationRequired) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration']; --here when 'via' and 'subscription' parameters not used but 'registration' is
    end

    if is_set(AccessDate) then
        local retrv_text = &quot; &quot; .. cfg.messages['retrieved']
        if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
        AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
            .. substitute( retrv_text, {AccessDate} ) .. '&lt;/span&gt;'
    end
    
    if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end

    
    ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo} );

    if is_set(URL) then
        URL = &quot; &quot; .. externallink( URL, nil, URLorigin );
    end

    if is_set(Quote) then
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        Quote = sepc ..&quot; &quot; .. wrap( 'quoted-text', Quote ); 
        PostScript = &quot;&quot;;
    elseif PostScript:lower() == &quot;none&quot; then
        PostScript = &quot;&quot;;
    end
    
    local Archived
    if is_set(ArchiveURL) then
        if not is_set(ArchiveDate) then
            ArchiveDate = seterror('archive_missing_date');
        end
        if &quot;no&quot; == DeadURL then
            local arch_text = cfg.messages['archived'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
                { externallink( ArchiveURL, arch_text ), ArchiveDate } );
            if not is_set(OriginalURL) then
                Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url');                               
            end
        elseif is_set(OriginalURL) then
            local arch_text = cfg.messages['archived-dead'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text,
                { externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
        else
            local arch_text = cfg.messages['archived-missing'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
                { seterror('archive_missing_url'), ArchiveDate } );
        end
    else
        Archived = &quot;&quot;
    end
    
    local Lay
    if is_set(LayURL) then
        if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
        if is_set(LaySource) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot;;
        else
            LaySource = &quot;&quot;;
        end
        if sepc == '.' then
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;;
    end
    
    if is_set(Transcript) then
        if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
    elseif is_set(TranscriptURL) then
        Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
    end
    
    local Publisher;
    if is_set(Periodical) and
        not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end
        elseif is_set(PublicationPlace) then
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if is_set(PublicationDate) then
            if is_set(Publisher) then
                Publisher = Publisher .. &quot;, &quot; .. wrap( 'published', PublicationDate );
            else
                Publisher = PublicationDate;
            end
        end
        if is_set(Publisher) then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if is_set(PublicationDate) then
            PublicationDate = &quot; (&quot; .. wrap( 'published', PublicationDate ) .. &quot;)&quot;;
        end
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif is_set(PublicationPlace) then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    
    -- Several of the above rely upon detecting this as nil, so do it last.
    if is_set(Periodical) then
        if is_set(Title) or is_set(TitleNote) then 
            Periodical = sepc .. &quot; &quot; .. wrap( 'italic-title', Periodical ) 
        else 
            Periodical = wrap( 'italic-title', Periodical )
        end
    end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if inArray(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
        if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, 
            Language, Cartography, Edition, Publisher, Agency, Volume, Issue}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, Language, 
            Volume, Issue, Others, Cartography, Edition, Publisher, Agency}, sepc );
    end
    
    if #ID_list &gt; 0 then
        ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
    else
        ID_list = ID;
    end
    
    local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
    local text;
    local pgtext = Position .. Page .. Pages .. At;
    
    if is_set(Authors) then
        if is_set(Coauthors) then
            Authors = Authors .. A['AuthorSeparator'] .. &quot; &quot; .. Coauthors
        end
        if is_set(Date) then
            Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        elseif string.sub(Authors,-1,-1) == sepc then
            Authors = Authors .. &quot; &quot;
        else
            Authors = Authors .. sepc .. &quot; &quot;
        end
        if is_set(Editors) then
            local in_text = &quot; &quot;;
            local post_text = &quot;&quot;;
            if is_set(Chapter) then
                in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
            else
                if EditorCount &lt;= 1 then
                    post_text = &quot;, &quot; .. cfg.messages['editor'];
                else
                    post_text = &quot;, &quot; .. cfg.messages['editors'];
                end
            end 
            if (sepc ~= '.') then in_text = in_text:lower() end
            Editors = in_text .. Editors .. post_text;
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = Editors .. &quot; &quot;
                else Editors = Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif is_set(Editors) then
        if is_set(Date) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
            else
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if is_set(Date) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end
        if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
            text = safejoin( {Chapter, Place, tcommon}, sepc );
            text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
            text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
            text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
    if is_set(PostScript) and PostScript ~= sepc then
        text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
        text = text:sub(1,-2); --Remove final seperator    
    end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    local options = {};
    
    if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
        options.class = &quot;citation &quot; .. config.CitationClass;
    else
        options.class = &quot;citation&quot;;
    end
    
    if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if #a &gt; 0 then
                for i,v in ipairs(a) do 
                    names[i] = v.last 
                    if i == 4 then break end
                end
            elseif #e &gt; 0 then
                for i,v in ipairs(e) do 
                    names[i] = v.last 
                    if i == 4 then break end                
                end
            end
			names[ #names + 1 ] = first_set(Year, anchor_year);	-- Year first for legacy citations
            id = anchorid(names)
        end
        options.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = {};
        text = seterror('empty_citation');
        z.message_tail = {};
    end
    
    if is_set(options.id) then 
        text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    else
        text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    end        

    local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        text = text .. &quot; &quot;;
        for i,v in ipairs( z.message_tail ) do
            if is_set(v[1]) then
                if i == #z.message_tail then
                    text = text .. errorcomment( v[1], v[2] );
                else
                    text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
                end
            end
        end
    end
    
    no_tracking_cats = no_tracking_cats:lower();
    if inArray(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    local args = {};
    local suggestions = {};
    local error_text, error_state;

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        args[k] = v;       
    end    

    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            if not validate( k ) then            
                error_text = &quot;&quot;;
                if type( k ) ~= 'string' then
                    -- Exclude empty numbered parameters
                    if v:match(&quot;%S+&quot;) ~= nil then
                        error_text, error_state = seterror( 'text_ignored', {v}, true );
                    end
                elseif validate( k:lower() ) then 
                    error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
                else
                    if #suggestions == 0 then
                        suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
                    end
                    if suggestions[ k:lower() ] ~= nil then
                        error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
                    else
                        error_text, error_state = seterror( 'parameter_ignored', {k}, true );
                    end
                end                  
                if error_text ~= '' then
                    table.insert( z.message_tail, {error_text, error_state} );
                end                
            end
            args[k] = v;
        elseif args[k] ~= nil or (k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z</text>
      <sha1>blgksqtxo6r9apy9go13tq1hphuuz4n</sha1>
    </revision>
    <revision>
      <id>4670</id>
      <parentid>4669</parentid>
      <timestamp>2014-03-30T12:26:52Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4670</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="83070" sha1="lo6xwe0knz7xynvby9rsvvyhw76rrl2" xml:space="preserve">local z = {
    error_categories = {};
    error_ids = {};
    message_tail = {};
}

-- Include translation message hooks, ID and error handling configuration settings.
--local cfg = mw.loadData( 'Module:Citation/CS1/Configuration/sandbox' );

-- Contains a list of all recognized parameters
--local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist/sandbox' );

--local dates = require('Module:Citation/CS1/Date_validation/sandbox').dates		-- location of date validation code

-- Whether variable is set or not
function is_set( var )
    return not (var == nil or var == '');
end

-- First set variable or nil if none
function first_set(...)
    local list = {...};
    for _, var in pairs(list) do
        if is_set( var ) then
            return var;
        end
    end
end

-- Whether needle is in haystack
function inArray( needle, haystack )
    if needle == nil then
        return false;
    end
    for n,v in ipairs( haystack ) do
        if v == needle then
            return n;
        end
    end
    return false;
end

--[[
Categorize and emit an error message when the citation contains one or more deprecated parameters.  Because deprecated parameters (currently |day=, |month=,
|coauthor=, and |coauthors=) aren't related to each other and because these parameters may be concatenated into the variables used by |date= and |author#= (and aliases)
details of which parameter caused the error message are not provided.  Only one error message is emitted regarless of the number of deprecated parameters in the citation.
]]
function deprecated_parameter()
	if true ~= Page_in_deprecated_cat then	-- if we haven't been here before then set a 
		Page_in_deprecated_cat=true;		-- sticky flag so that if there are more than one deprecated parameter the category is added only once
--		table.insert( z.message_tail, { seterror( 'deprecated_params', {error_message}, true ) } );		-- add error message
		table.insert( z.message_tail, { seterror( 'deprecated_params', {}, true ) } );		-- add error message
	end
end

-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
--	return args and tostring( mw.message.newRawMessage( msg, args ) ) or msg;
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[
Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern  either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
]]
function kern_quotes (str)
	local left='&lt;span style=&quot;padding-left:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains leading single or double quote mark
	local right='&lt;span style=&quot;padding-right:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains trailing single or double quote mark
	
	if  str:match (&quot;^[\&quot;\'][^\']&quot;) then
		str = string.gsub( str, &quot;^[\&quot;\']&quot;, left, 1 );				-- replace (captured) leading single or double quote with left-side &lt;span&gt;
	end
	if str:match (&quot;[^\'][\&quot;\']$&quot;) then
		str = string.gsub( str, &quot;[\&quot;\']$&quot;, right, 1 );			-- replace (captured) trailing single or double quote with right-side &lt;span&gt;
	end
	return str;
end

-- Wraps a string using a message_list configuration taking one argument
function wrap( key, str, lower )
    if not is_set( str ) then
        return &quot;&quot;;
    elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
        str = safeforitalics( str );
    end
    if lower == true then
        return substitute( cfg.messages[key]:lower(), {str} );
    else
        return substitute( cfg.messages[key], {str} );
    end        
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
    local origin = {};
    
    return setmetatable({
        ORIGIN = function( self, k )
            local dummy = self[k]; --force the variable to be loaded.
            return origin[k];
        end
    },
    {
        __index = function ( tbl, k )
            if origin[k] ~= nil then
                return nil;
            end
            
            local args, list, v = args, cfg.aliases[k];
            
            if type( list ) == 'table' then
                v, origin[k] = selectone( args, list, 'redundant_parameters' );
                if origin[k] == nil then
                    origin[k] = ''; -- Empty string, not nil
                end
            elseif list ~= nil then
                v, origin[k] = args[list], list;
            else
                -- maybe let through instead of raising an error?
                -- v, origin[k] = args[k], k;
                error( cfg.messages['unknown_argument_map'] );
            end
            
            -- Empty strings, not nil;
            if v == nil then
                v = cfg.defaults[k] or '';
                origin[k] = '';
            end
            
            tbl = rawset( tbl, k, v );
            return v;
        end,
    });
end

--[[
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
]]
function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
    return wrap( hidden and 'hidden-error' or 'visible-error', content );
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
    local error_state = cfg.error_conditions[ error_id ];
    
    prefix = prefix or &quot;&quot;;
    suffix = suffix or &quot;&quot;;
    
    if error_state == nil then
        error( cfg.messages['undefined_error'] );
    elseif is_set( error_state.category ) then
        table.insert( z.error_categories, error_state.category );
    end
    
    local message = substitute( error_state.message, arguments );
    
    message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
        &quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
        cfg.messages['help page label'] .. &quot;]])&quot;;
    
    z.error_ids[ error_id ] = true;
    if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
            and z.error_ids['citation_missing_title'] then
        return '', false;
    end
    
    message = table.concat({ prefix, message, suffix });
    
    if raw == true then
        return message, error_state.hidden;
    end        
        
    return errorcomment( message, error_state.hidden );
end

-- Formats a wiki style external link
function externallinkid(options)
    local url_string = options.id;
    if options.encode == true or options.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, url_string, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Formats a wiki style internal link
function internallinkid(options)
    return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, options.id, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Format an external link with error checking
function externallink( URL, label, source )
    local error_str = &quot;&quot;;
    if not is_set( label ) then
        label = URL;
        if is_set( source ) then
            error_str = seterror( 'bare_url_missing_title', { wrap( 'parameter', source ) }, false, &quot; &quot; );
        else
            error( cfg.messages[&quot;bare_url_no_origin&quot;] );
        end            
    end
    if not checkurl( URL ) then
        error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
    end
    return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safeforurl( label ), &quot;]&quot;, error_str });
end

-- Formats a link to Amazon
function amazon(id, domain)
    if not is_set(domain) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local handler = cfg.id_handlers['ASIN'];
    return externallinkid({link = handler.link,
        label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
        encode=handler.encode, separator = handler.separator})
end

--[[
Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of the LCCN dictates the character type of the first 1-3 characters; the
rightmost eight are always digits. http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is alpha
length = 10 then lccn[1] and lccn[2] are both alpha or both digits
length = 11 then lccn[1] is alpha, lccn[2] and lccn[3] are both alpha or both digits
length = 12 then lccn[1] and lccn[2] are both alpha

]]
function lccn(id)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid

	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%a%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%a%a%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%a%a%a%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%a%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%a%a%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. seterror( 'bad_lccn' );		-- wrong length, set an error message
	end

	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]
function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmid' );	-- set an error message
		end
	end
	
	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns true; otherwse, returns false because the embargo has expired or |embargo= not set in this cite.
]]
function is_embargoed(embargo)
	if is_set(embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 and tonumber( embargo_date ) &gt;= tonumber( todays_date ) then	--is embargo date is in the future?
			return true;	-- still embargoed
		end
	end
	return false;			-- embargo expired or |embargo= not set
end

--[[
Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future
the PMC identifier will not be linked to the article.  If the embargo specifies a date in the past, or if it is empty or omitted, then
the PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.
]]
function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
    
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_embargoed(embargo) then
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	--still embargoed so no external link
	else
		text = externallinkid({link = handler.link, label = handler.label,			--no embargo date, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.

-- DOI names contain two parts: prefix and suffix separated by a forward slash.
--  Prefix: directory indicator '10.' followed by a registrant code
--  Suffix: character string of any length chosen by the registrant

-- This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes,
-- or, if it ends with a period or a comma, this function will emit a bad_doi error message.

-- DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
-- and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely if ever used in doi names.

function doi(id, inactive)
    local cat = &quot;&quot;
    local handler = cfg.id_handlers['DOI'];
    
    local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. seterror( 'bad_doi' );
	end
	return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    local handler = cfg.id_handlers['OL'];
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    else
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode}) .. 
            ' ' .. seterror( 'bad_ol' );
    end
end

--[[
Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.
]]
function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and ndashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 didgits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = externallinkid({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. seterror( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[
This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those citations that have defaults.
Also handles the special case where it is desireable to omit the title type from the rendered citation (|type=none).
]]
function set_titletype(cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;					-- if |type=none then type parameter not displayed
		end
		return title_type;						-- if |type= has been set to any other value use that value
	end

	if &quot;AV media notes&quot; == cite_class or &quot;DVD notes&quot; == cite_class then		-- if this citation is cite AV media notes or cite DVD notes
		return &quot;Media notes&quot;;					-- display AV media notes / DVD media notes annotation

	elseif &quot;podcast&quot; == cite_class then			-- if this citation is cite podcast
		return &quot;Podcast&quot;;						-- display podcast annotation

	elseif &quot;pressrelease&quot; == cite_class then	-- if this citation is cite press release
		return &quot;Press release&quot;;					-- display press release annotation

	elseif &quot;techreport&quot; == cite_class then		-- if this citation is cite techreport
		return &quot;Technical report&quot;;				-- display techreport annotation
	
	elseif &quot;thesis&quot; == cite_class then			-- if this citation is cite thesis (degree option handled after this function returns)
			return &quot;Thesis&quot;;					-- display simple thesis annotation (without |degree= modification)
	end
end

--[[
Determines whether a URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
    -- Protocol-relative or URL scheme
    return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
    return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

-- Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.
function get_coins_pages (pages)
	if not is_set (pages) then return pages; end			-- if no page numbers then we're done
	
    while true do
		pattern = pages:match(&quot;%[([%w/:\.]+%s+)[%w%d].*%]&quot;);	-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end					-- no more urls
		pages = pages:gsub(pattern, &quot;&quot;);					-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);						-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end

--[[
ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in checkisbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.
]]
function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of bytes
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end	-- isbn13 begins with 978 or 979
		isbn_str = { isbn_str:byte(1, len) };
		for i, v in ipairs( isbn_str ) do
			temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
		end
		return temp % 10 == 0;
	end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
    return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
        return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
    end));
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if not is_set(str) then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        
        -- Remove newlines as they break italics.
        return str:gsub( '\n', ' ' );
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    if maximum ~= nil and maximum &lt; 1 then return &quot;&quot;, 0; end
    
    for i,person in ipairs(people) do
        if is_set(person.last) then
            local mask = person.mask
            local one
            local sep_one = sep;
            if maximum ~= nil and i &gt; maximum then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask;
                    sep_one = &quot; &quot;;
                end
            else
                one = person.last
                local first = person.first
                if is_set(first) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if is_set(person.link) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
                if is_set(person.link) and nil ~= person.link:find(&quot;//&quot;) then one = one .. &quot; &quot; .. seterror( 'bad_authorlink' ) end	-- check for url in author link;
            end
            table.insert( text, one )
            table.insert( text, sep_one )
        end
    end

    local count = #text / 2;
    if count &gt; 0 then 
        if count &gt; 1 and is_set(lastauthoramp) and not etal then
            text[#text-2] = &quot; &amp; &quot;;
        end
        text[#text] = nil; 
    end
    
    local result = table.concat(text) -- construct list
    if etal then 
        local etal_text = cfg.messages['et al'];
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result = 
        '&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
    end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
    return &quot;CITEREF&quot; .. table.concat( options );
end

-- Gets name list from the input arguments
function extractnames(args, list_name)
    local names = {};
    local i = 1;
    local last;
    
    while true do
        last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );
        if not is_set(last) then
            -- just in case someone passed in an empty parameter
            break;
        end
        names[i] = {
            last = last,
            first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i ),
            link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ),
            mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i )
        };
        i = i + 1;
    end
    return names;
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
    local id_list = {};
    for k, v in pairs( cfg.id_handlers ) do    
        v = selectone( args, v.parameters, 'redundant_parameters' );
        if is_set(v) then id_list[k] = v; end
    end
    return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
    local new_list, handler = {};
    
    function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
    
    for k, v in pairs( id_list ) do
        -- fallback to read-only cfg
        handler = setmetatable( { ['id'] = v }, fallback(k) );
        
        if handler.mode == 'external' then
            table.insert( new_list, {handler.label, externallinkid( handler ) } );
        elseif handler.mode == 'internal' then
            table.insert( new_list, {handler.label, internallinkid( handler ) } );
        elseif handler.mode ~= 'manual' then
            error( cfg.messages['unknown_ID_mode'] );
        elseif k == 'DOI' then
            table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
        elseif k == 'ASIN' then
            table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
        elseif k == 'LCCN' then
            table.insert( new_list, {handler.label, lccn( v ) } );
        elseif k == 'OL' then
            table.insert( new_list, {handler.label, openlibrary( v ) } );
        elseif k == 'PMC' then
            table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
        elseif k == 'PMID' then
            table.insert( new_list, {handler.label, pmid( v ) } );
        elseif k == 'ISSN' then
        	table.insert( new_list, {handler.label, issn( v ) } );
        elseif k == 'ISBN' then
            local ISBN = internallinkid( handler );
            if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
                ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
            end
            table.insert( new_list, {handler.label, ISBN } );                
        else
            error( cfg.messages['unknown_manual_ID'] );
        end
    end
    
    function comp( a, b )	-- used in following table.sort()
        return a[1] &lt; b[1];
    end
    
    table.sort( new_list, comp );
    for k, v in ipairs( new_list ) do
        new_list[k] = v[2];
    end
    
    return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
    local value = nil;
    local selected = '';
    local error_list = {};
    
    if index ~= nil then index = tostring(index); end
    
    -- Handle special case of &quot;#&quot; replaced by empty string
    if index == '1' then
        for _, v in ipairs( possible ) do
            v = v:gsub( &quot;#&quot;, &quot;&quot; );
            if is_set(args[v]) then
                if value ~= nil and selected ~= v then
                    table.insert( error_list, v );
                else
                    value = args[v];
                    selected = v;
                end
            end
        end        
    end
    
    for _, v in ipairs( possible ) do
        if index ~= nil then
            v = v:gsub( &quot;#&quot;, index );
        end
        if is_set(args[v]) then
            if value ~= nil and selected ~=  v then
                table.insert( error_list, v );
            else
                value = args[v];
                selected = v;
            end
        end
    end
    
    if #error_list &gt; 0 then
        local error_str = &quot;&quot;;
        for _, k in ipairs( error_list ) do
            if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
            error_str = error_str .. wrap( 'parameter', k );
        end
        if #error_list &gt; 1 then
            error_str = error_str .. cfg.messages['parameter-final-separator'];
        else
            error_str = error_str .. cfg.messages['parameter-pair-separator'];
        end
        error_str = error_str .. wrap( 'parameter', selected );
        table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
    end
    
    return value, selected;
end

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
function COinS(data)
    if 'table' ~= type(data) or nil == next(data) then
        return '';
    end
    
    local ctx_ver = &quot;Z39.88-2004&quot;;
    
    -- treat table strictly as an array with only set values.
    local OCinSoutput = setmetatable( {}, {
        __newindex = function(self, key, value)
            if is_set(value) then
                rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
            end
        end
    });
    
    if is_set(data.Chapter) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Chapter;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    elseif is_set(data.Periodical) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
        OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    else
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
    end
    
    OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
    OCinSoutput[&quot;rft.date&quot;] = data.Date;
    OCinSoutput[&quot;rft.series&quot;] = data.Series;
    OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
    OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
    OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
    OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
    OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
    
    for k, v in pairs( data.ID_list ) do
        local id, value = cfg.id_handlers[k].COinS;
        if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
        if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
            OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
        else
            OCinSoutput[ id ] = value;
        end
    end
    
    local last, first;
    for k, v in ipairs( data.Authors ) do
        last, first = v.last, v.first;
        if k == 1 then
            if is_set(last) then
                OCinSoutput[&quot;rft.aulast&quot;] = last;
            end
            if is_set(first) then 
                OCinSoutput[&quot;rft.aufirst&quot;] = first;
            end
        end
        if is_set(last) and is_set(first) then
            OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
        elseif is_set(last) then
            OCinSoutput[&quot;rft.au&quot;] = last;
        end
    end
    
    OCinSoutput.rft_id = data.URL;
    OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
    OCinSoutput = setmetatable( OCinSoutput, nil );
    
    -- sort with version string always first, and combine.
    table.sort( OCinSoutput );
    table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
    return table.concat(OCinSoutput, &quot;&amp;&quot;);
end

--[[
This is the main function doing the majority of the citation
formatting.
]]
function citation0( config, args)
    --[[ 
    Load Input Parameters
    The argment_wrapper facillitates the mapping of multiple
    aliases to single internal variable.
    ]]
    local A = argument_wrapper( args );

    local i 
    local PPrefix = A['PPrefix']
    local PPPrefix = A['PPPrefix']
    if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = A['Authors'];
    local a = extractnames( args, 'AuthorList' );

    local Coauthors = A['Coauthors'];
    local Others = A['Others'];
    local Editors = A['Editors'];
    local e = extractnames( args, 'EditorList' );

    local Year = A['Year'];
    local PublicationDate = A['PublicationDate'];
    local OrigYear = A['OrigYear'];
    local Date = A['Date'];
    local LayDate = A['LayDate'];
    ------------------------------------------------- Get title data
    local Title = A['Title'];
    local BookTitle = A['BookTitle'];
    local Conference = A['Conference'];
    local TransTitle = A['TransTitle'];
    local TitleNote = A['TitleNote'];
    local TitleLink = A['TitleLink'];
    local Chapter = A['Chapter'];
    local ChapterLink = A['ChapterLink'];
    local TransChapter = A['TransChapter'];
    local TitleType = A['TitleType'];
    local Degree = A['Degree'];
    local Docket = A['Docket'];
    local ArchiveURL = A['ArchiveURL'];
    local URL = A['URL']
    local URLorigin = A:ORIGIN('URL');
    local ChapterURL = A['ChapterURL'];
    local ChapterURLorigin = A:ORIGIN('ChapterURL');
    local ConferenceURL = A['ConferenceURL'];
    local ConferenceURLorigin = A:ORIGIN('ConferenceURL');
    local Periodical = A['Periodical'];

	local Series = A['Series'];
    local Volume = A['Volume'];
    local Issue = A['Issue'];
    local Position = '';
    local Page = A['Page'];
    local Pages = hyphentodash( A['Pages'] );	
    local At = A['At'];

    local Edition = A['Edition'];
    local PublicationPlace = A['PublicationPlace']
    local Place = A['Place'];
    
    local PublisherName = A['PublisherName'];
    local RegistrationRequired = A['RegistrationRequired'];
    local SubscriptionRequired = A['SubscriptionRequired'];
    local Via = A['Via'];
    local AccessDate = A['AccessDate'];
    local ArchiveDate = A['ArchiveDate'];
    local Agency = A['Agency'];
    local DeadURL = A['DeadURL']
    local Language = A['Language'];
    local Format = A['Format'];
    local Ref = A['Ref'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
    local ASINTLD = A['ASINTLD'];
    local IgnoreISBN = A['IgnoreISBN'];
    local Embargo = A['Embargo'];

    local ID_list = extractids( args );
    
    local Quote = A['Quote'];
    local PostScript = A['PostScript'];

    local LayURL = A['LayURL'];
    local LaySource = A['LaySource'];
    local Transcript = A['Transcript'];
    local TranscriptURL = A['TranscriptURL'] 
    local TranscriptURLorigin = A:ORIGIN('TranscriptURL');
    local sepc = A['Separator'];

    local LastAuthorAmp = A['LastAuthorAmp'];
    local no_tracking_cats = A['NoTracking'];

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Cointerviewers = A['Cointerviewers'];			-- deprecated
	local Interviewer = A['Interviewer'];				-- deprecated
	local Program = A['Program'];

--local variables that are not cs1 parameters
    local page_type;									-- is this needed?  Doesn't appear to be used anywhere;
    local use_lowercase = ( sepc ~= '.' );
    local this_page = mw.title.getCurrentTitle();		--Also used for COinS and for language
	local anchor_year;									-- used in the CITEREF identifier
	local COinS_date;									-- used in the COinS metadata

-- Set postscript default.
	if not is_set (PostScript) then						-- if |postscript= has not been set (Postscript is nil which is the default for {{citation}}) and
		if (config.CitationClass ~= &quot;citation&quot;) then	-- this template is not a citation template
			PostScript = '.';							-- must be a cite xxx template so set postscript to default (period)
		end
	else
		if PostScript:lower() == 'none' then			-- if |postscript=none then
			PostScript = '';							-- no postscript
		end
	end

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories.
	if not is_set(no_tracking_cats) then				-- ignore if we are already not going to categorize this page
		for k, v in pairs( cfg.uncategorized_namespaces ) do	-- otherwise, spin through the list of namespaces we don't include in error categories
			if this_page.nsText == v then				-- if we find one
				no_tracking_cats = &quot;true&quot;;				-- set no_trackin_cats
				break;									-- and we're done
            end
        end
    end

-- check for extra |page=, |pages= or |at= parameters. 
    if is_set(Page) then
        if is_set(Pages) or is_set(At) then
            Page = Page .. &quot; &quot; .. seterror('extra_pages');	-- add error message
            Pages = '';										-- unset the others
            At = '';
        end
    elseif is_set(Pages) then
        if is_set(At) then
            Pages = Pages .. &quot; &quot; .. seterror('extra_pages');	-- add error messages
            At = '';											-- unset
        end
    end    

-- both |publication-place= and |place= (|location=) allowed if different
    if not is_set(PublicationPlace) and is_set(Place) then
        PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
    end
    
    if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
    
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped

All other combinations of |encyclopedia, |title, and |article are not modified
]]
	if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
		if is_set(Periodical) then					-- Periodical is set when |encyclopedia is set
			if is_set(Title) then
				if not is_set(Chapter) then
					Chapter = Title;				-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					TransChapter = TransTitle;
					Title = Periodical;
					Periodical = '';				-- redundant so unset
					TransTitle = '';				-- redundant so unset
				end
			else									-- |title not set
				Title = Periodical;					-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';					-- redundant so unset
			end
		end
	end

--special cases for citation.
	if (config.CitationClass == &quot;citation&quot;) then		-- for citation templates
		if not is_set (Ref) then						-- if |ref= is not set
			Ref = &quot;harv&quot;;								-- set default |ref=harv
		end
		if not is_set (sepc) then						-- if |separator= is not set
			sepc = ',';									-- set citation separator to its default (comma)
		end
	else												-- not a citation template
		if not is_set (sepc) then						-- if |separator= has not been set
			sepc = '.';									-- set cite xxx separator to its default (period)
		end
	end

-- check for specital case where |separator=none
	if 'none' == sepc:lower() then						-- if |separator=none
		sepc = '';										-- then set it to a empty string
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then	-- special case for cite techreport
		if is_set(Issue) then						-- cite techreport uses 'number', which other citations aliase to 'issue'
			if not is_set(ID) then					-- can we use ID for the &quot;number&quot;?
				ID = Issue;							-- yes, use it
				Issue = &quot;&quot;;							-- unset Issue so that &quot;number&quot; isn't duplicated in the rendered citation or COinS metadata
			else									-- can't use ID so emit error message
				ID = ID .. &quot; &quot; .. seterror('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Interviewer) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Interviewer;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Interviewer;
			end
			if is_set(Cointerviewers) then
				Others = Others .. sepc .. ' ' .. Cointerviewers;
			end
		else
			Others = '(Interview)';
		end
	end

--Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set
	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_embargoed(Embargo) then
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];	-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];		-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
--TODO: if this is only for {{cite conference}}, shouldn't we be checking? (if config.CitationClass=='conference' then ...)
	if is_set(BookTitle) then
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = BookTitle;
		TitleLink = '';
		TransTitle = '';
	end

-- Account for the oddity that is {{cite episode}}, before generation of COinS data.
--[[	-- {{cite episode}} is not currently supported by this module
	if config.CitationClass == &quot;episode&quot; then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];
		local Season = A['Season'];
		local SeriesNumber = A['SeriesNumber'];
		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
		local Sep = (first_set(A[&quot;SeriesSeparator&quot;], A[&quot;Separator&quot;]) or &quot;&quot;) .. &quot; &quot;;
		
		if is_set(Issue) then table.insert(s, cfg.messages[&quot;episode&quot;] .. &quot; &quot; .. Issue); Issue = ''; end
		if is_set(Season) then table.insert(s, cfg.messages[&quot;season&quot;] .. &quot; &quot; .. Season); end
		if is_set(SeriesNumber) then table.insert(s, cfg.messages[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber); end
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		
		Date = Date or AirDate;
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = Series;
		TitleLink = SeriesLink;
		TransTitle = '';
		
		Series = table.concat(s, Sep);
		ID = table.concat(n, Sep);
	end
-- end of {{cite episode}} stuff]]

-- legacy: promote concatenation of |day=, |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set(Date) then
		Date = Year;						-- promote Year to Date
		Year = nil;							-- make nil so Year as empty string isn't used for CITEREF
		if is_set(Date) then
			local Month = A['Month'];
			if is_set(Month) then
				Date = Month .. &quot; &quot; .. Date;
				local Day = A['Day']
				if is_set(Day) then Date = Day .. &quot; &quot; .. Date end
			end
		elseif is_set(PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;			-- promonte PublicationDate to Date
			PublicationDate = '';			-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end	-- if PublicationDate is same as Date, don't display in rendered citation


--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	anchor_year, COinS_date, error_message = dates({['accessdate']=AccessDate, ['airdate']=AirDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
		['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});
	if is_set(error_message) then
		table.insert( z.message_tail, { seterror( 'bad_date', {error_message}, true ) } );	-- add this error message
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.

    -- COinS metadata (see &lt;http://ocoins.info/&gt;) for
    -- automated parsing of citation information.
    local OCinSoutput = COinS{
        ['Periodical'] = Periodical,
        ['Chapter'] = Chapter,
        ['Title'] = Title,
        ['PublicationPlace'] = PublicationPlace,
        ['Date'] = first_set(COinS_date, Date),		-- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here?  Should we be including invalid dates in metadata?
        ['Series'] = Series,
        ['Volume'] = Volume,
        ['Issue'] = Issue,
        ['Pages'] = get_coins_pages (first_set(Page, Pages, At)),	-- pages stripped of external links
        ['Edition'] = Edition,
        ['PublisherName'] = PublisherName,
        ['URL'] = first_set( URL, ChapterURL ),
        ['Authors'] = a,
        ['ID_list'] = ID_list,
        ['RawPage'] = this_page.prefixedText,
    };

    if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = '';
        TitleLink = '';
        TransTitle = '';
    end

    -- Now perform various field 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 not is_set(Authors) then
        local Maximum = tonumber( A['DisplayAuthors'] );
        
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #a == 9 then 
            Maximum = 8;
            table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
        elseif not is_set(Maximum) then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = A[&quot;AuthorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;AuthorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A[&quot;AuthorFormat&quot;],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if is_set(Coauthors) then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
        
        Authors = listpeople(control, a) 
    end

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { seterror('coauthors_missing_author', {}, true) } );	-- emit error message
	end

    local EditorCount
    if not is_set(Editors) then
        local Maximum = tonumber( A['DisplayEditors'] );
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #e == 4 then 
            Maximum = 3;
            table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
        elseif not is_set(Maximum) then
            Maximum = #e + 1;
        end

        local control = { 
            sep = A[&quot;EditorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;EditorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A['EditorFormat'],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };

        Editors, EditorCount = listpeople(control, e);
    else
        EditorCount = 1;
    end

    local Cartography = &quot;&quot;;
    local Scale = &quot;&quot;;
    if config.CitationClass == &quot;map&quot; then
        if not is_set( Authors ) and is_set( PublisherName ) then
            Authors = PublisherName;
            PublisherName = &quot;&quot;;
        end
        Cartography = A['Cartography'];
        if is_set( Cartography ) then
            Cartography = sepc .. &quot; &quot; .. wrap( 'cartography', Cartography, use_lowercase );
        end        
        Scale = A['Scale'];
        if is_set( Scale ) then
            Scale = sepc .. &quot; &quot; .. Scale;
        end        
    end
    
    if  not is_set(URL) and
        not is_set(ChapterURL) and
        not is_set(ArchiveURL) and
        not is_set(ConferenceURL) and
        not is_set(TranscriptURL) then
        
        -- Test if cite web or cite podcast |url= is missing or empty 
		if inArray(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;}) then	
			table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
		end
        
        -- Test if accessdate is given without giving a URL
        if is_set(AccessDate) then
            table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
            AccessDate = '';
        end
        
        -- Test if format is given without giving a URL
        if is_set(Format) then
            Format = Format .. seterror( 'format_missing_url' );
        end
    end
    
    -- Test if citation has no title
    if  not is_set(Chapter) and
        not is_set(Title) and
        not is_set(Periodical) and
        not is_set(Conference) and
        not is_set(TransTitle) and
        not is_set(TransChapter) then
        table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
    end
    
    Format = is_set(Format) and &quot; (&quot; .. Format .. &quot;)&quot; or &quot;&quot;;
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if is_set( ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
            URLorigin = A:ORIGIN('ArchiveURL')
        end
    end
    
    -- Format chapter / article title
    if is_set(Chapter) and is_set(ChapterLink) then 
        Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot;;
    end
    if is_set(Periodical) and is_set(Title) then
        Chapter = wrap( 'italic-title', Chapter );
        TransChapter = wrap( 'trans-italic-title', TransChapter );
    else
		Chapter = kern_quotes (Chapter);				-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
        Chapter = wrap( 'quoted-title', Chapter );
        TransChapter = wrap( 'trans-quoted-title', TransChapter );
    end
    
    local TransError = &quot;&quot;
    if is_set(TransChapter) then
        if not is_set(Chapter) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
        else
            TransChapter = &quot; &quot; .. TransChapter;
        end
    end
    
    Chapter = Chapter .. TransChapter;
    
    if is_set(Chapter) then
        if not is_set(ChapterLink) then
            if is_set(ChapterURL) then
                Chapter = externallink( ChapterURL, Chapter ) .. TransError;
                if not is_set(URL) then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif is_set(URL) then 
                Chapter = externallink( URL, Chapter ) .. TransError .. Format;
                URL = &quot;&quot;;
                Format = &quot;&quot;;
            else
                Chapter = Chapter .. TransError;
            end            
        elseif is_set(ChapterURL) then
            Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. 
                TransError;
        else
            Chapter = Chapter .. TransError;
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    elseif is_set(ChapterURL) then
        Chapter = &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. sepc .. &quot; &quot;;
    end        
    
    -- Format main title.
    if is_set(TitleLink) and is_set(Title) then
        Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
    end
    
    if is_set(Periodical) then
		Title = kern_quotes (Title);				-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    elseif inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;pressrelease&quot;,&quot;conference&quot;,&quot;podcast&quot;}) and
            not is_set(Chapter) then
		Title = kern_quotes (Title);				-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    else
        Title = wrap( 'italic-title', Title );
        TransTitle = wrap( 'trans-italic-title', TransTitle );
    end
    
    TransError = &quot;&quot;;
    if is_set(TransTitle) then
        if not is_set(Title) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
        else
            TransTitle = &quot; &quot; .. TransTitle;
        end
    end
    
    Title = Title .. TransTitle;
    
    if is_set(Title) then
        if not is_set(TitleLink) and is_set(URL) then 
            Title = externallink( URL, Title ) .. TransError .. Format       
            URL = &quot;&quot;;
            Format = &quot;&quot;;
        else
            Title = Title .. TransError;
        end
    end
    
    if is_set(Place) then
        Place = &quot; &quot; .. wrap( 'written', Place, use_lowercase ) .. sepc .. &quot; &quot;;
    end
    
    if is_set(Conference) then
        if is_set(ConferenceURL) then
            Conference = externallink( ConferenceURL, Conference );
        end
        Conference = sepc .. &quot; &quot; .. Conference
    elseif is_set(ConferenceURL) then
        Conference = sepc .. &quot; &quot; .. externallink( ConferenceURL, nil, ConferenceURLorigin );
    end
    
    if not is_set(Position) then
        local Minutes = A['Minutes'];
        if is_set(Minutes) then
            Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
        else
            local Time = A['Time'];
            if is_set(Time) then
                local TimeCaption = A['TimeCaption']
                if not is_set(TimeCaption) then
                    TimeCaption = cfg.messages['event'];
                    if sepc ~= '.' then
                        TimeCaption = TimeCaption:lower();
                    end
                end
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
            end
        end
    else
        Position = &quot; &quot; .. Position;
        At = '';
    end
    
    if not is_set(Page) then
        if is_set(Pages) then
            if is_set(Periodical) and
                not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
                Pages = &quot;: &quot; .. Pages;
            elseif tonumber(Pages) ~= nil then
                Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
            else
                Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
            end
        end
    else
        if is_set(Periodical) and
            not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
            Page = &quot;: &quot; .. Page;
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page;
        end
    end
    
    At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
    Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
    if config.CitationClass == 'map' then
        local Section = A['Section'];
        local Inset = A['Inset'];
        if first_set( Pages, Page, At ) ~= nil or sepc ~= '.' then
            if is_set( Section ) then
                Section = &quot;, &quot; .. wrap( 'section', Section, true );
            end
            if is_set( Inset ) then
                Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
            end
        else
            if is_set( Section ) then
                Section = sepc .. &quot; &quot; .. wrap( 'section', Section, use_lowercase );
                if is_set( Inset ) then
                    Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
                end
            elseif is_set( Inset ) then
                Inset = sepc .. &quot; &quot; .. wrap( 'inset', Inset, use_lowercase );
            end            
        end            
        At = At .. Section .. Inset;        
    end    

	--[[Look in the list of iso639-1 language codes to see if the value provided in the language parameter matches one of them.  If a match is found, 
	use that value; if not, then use the value that was provided with the language parameter.
	
	Categories are assigned in a manner similar to the {{xx icon}} templates - categorizes only mainspace citations and only when the language code is not 'en' (English).
	]]
	if is_set (Language) then
--		local name = mw.language.fetchLanguageName( Language:lower(), &quot;en&quot; );	-- experiment: this seems to return correct ISO 639-1 language names
		local name = cfg.iso639_1[Language:lower()];		-- get the language name if Language parameter has a valid iso 639-1 code
		if nil == name then
			Language=&quot; &quot; .. wrap( 'language', Language );	-- no match, use parameter's value
		else
			if 0 == this_page.namespace and 'en' ~= Language:lower() then	--found a match; is this page main / article space and English not the language?
				Language=&quot; &quot; .. wrap( 'language', name .. '[[Category:Articles with ' .. name .. '-language external links]]' );	-- in main space and not English: categorize
			else
				Language=&quot; &quot; .. wrap( 'language', name );	--not in mainspace or language is English so don't categorize
			end
		end
	else
		Language=&quot;&quot;;	-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;

-- handle type parameter for those CS1 citations that have default values

	if inArray(config.CitationClass, {&quot;AV media notes&quot;, &quot;DVD notes&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then	-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then					-- if type parameter is specified
		TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot;;	-- display it in parentheses
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
    Edition = is_set(Edition) and (&quot; &quot; .. wrap( 'edition', Edition )) or &quot;&quot;;
    Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
    Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
    OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
    Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

    if is_set(Volume) then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume;
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
        end
    end

--[[ This code commented out while discussion continues until after week of 2014-03-23 live module update;
    if is_set(Volume) then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc .. &quot; &quot; .. Volume;
          else
              Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
              if is_set(Series) then Volume = sepc .. Volume;
              end
        end
    end
]]    
    ------------------------------------ totally unrelated data
    --[[ Loosely mimic {{subscription required}} template; Via parameter identifies a delivery source that is not the publisher; these sources often, but not always, exist
    behind a registration or paywall.  So here, we've chosen to decouple via from subscription (via has never been part of the registration required template).
    
    Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link note is displayed. There are no error messages for this condition.
    ]]
    if is_set(Via) then
        Via = &quot; &quot; .. wrap( 'via', Via );
    end

	if is_set(SubscriptionRequired) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription']; --here when 'via' parameter not used but 'subscription' is
    elseif is_set(RegistrationRequired) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration']; --here when 'via' and 'subscription' parameters not used but 'registration' is
    end

    if is_set(AccessDate) then
        local retrv_text = &quot; &quot; .. cfg.messages['retrieved']
        if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
        AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
            .. substitute( retrv_text, {AccessDate} ) .. '&lt;/span&gt;'
    end
    
    if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end

    
    ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo} );

    if is_set(URL) then
        URL = &quot; &quot; .. externallink( URL, nil, URLorigin );
    end

    if is_set(Quote) then
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        Quote = sepc ..&quot; &quot; .. wrap( 'quoted-text', Quote ); 
        PostScript = &quot;&quot;;							-- CS1 does not supply terminal punctuation when |quote= is set
    end
    
    local Archived
    if is_set(ArchiveURL) then
        if not is_set(ArchiveDate) then
            ArchiveDate = seterror('archive_missing_date');
        end
        if &quot;no&quot; == DeadURL then
            local arch_text = cfg.messages['archived'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
                { externallink( ArchiveURL, arch_text ), ArchiveDate } );
            if not is_set(OriginalURL) then
                Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url');                               
            end
        elseif is_set(OriginalURL) then
            local arch_text = cfg.messages['archived-dead'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text,
                { externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
        else
            local arch_text = cfg.messages['archived-missing'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
                { seterror('archive_missing_url'), ArchiveDate } );
        end
    else
        Archived = &quot;&quot;
    end
    
    local Lay
    if is_set(LayURL) then
        if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
        if is_set(LaySource) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot;;
        else
            LaySource = &quot;&quot;;
        end
        if sepc == '.' then
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;;
    end
    
    if is_set(Transcript) then
        if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
    elseif is_set(TranscriptURL) then
        Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
    end
    
    local Publisher;
    if is_set(Periodical) and
        not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end
        elseif is_set(PublicationPlace) then
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if is_set(PublicationDate) then
            if is_set(Publisher) then
                Publisher = Publisher .. &quot;, &quot; .. wrap( 'published', PublicationDate );
            else
                Publisher = PublicationDate;
            end
        end
        if is_set(Publisher) then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if is_set(PublicationDate) then
            PublicationDate = &quot; (&quot; .. wrap( 'published', PublicationDate ) .. &quot;)&quot;;
        end
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif is_set(PublicationPlace) then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    
    -- Several of the above rely upon detecting this as nil, so do it last.
    if is_set(Periodical) then
        if is_set(Title) or is_set(TitleNote) then 
            Periodical = sepc .. &quot; &quot; .. wrap( 'italic-title', Periodical ) 
        else 
            Periodical = wrap( 'italic-title', Periodical )
        end
    end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if inArray(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
        if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, 
            Language, Cartography, Edition, Publisher, Agency, Volume, Issue}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, Language, 
            Volume, Issue, Others, Cartography, Edition, Publisher, Agency}, sepc );
    end
    
    if #ID_list &gt; 0 then
        ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
    else
        ID_list = ID;
    end
    
    local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
    local text;
    local pgtext = Position .. Page .. Pages .. At;
    
    if is_set(Authors) then
        if is_set(Coauthors) then
            Authors = Authors .. A['AuthorSeparator'] .. &quot; &quot; .. Coauthors
        end
        if is_set(Date) then
            Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        elseif string.sub(Authors,-1,-1) == sepc then
            Authors = Authors .. &quot; &quot;
        else
            Authors = Authors .. sepc .. &quot; &quot;
        end
        if is_set(Editors) then
            local in_text = &quot; &quot;;
            local post_text = &quot;&quot;;
            if is_set(Chapter) then
                in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
            else
                if EditorCount &lt;= 1 then
                    post_text = &quot;, &quot; .. cfg.messages['editor'];
                else
                    post_text = &quot;, &quot; .. cfg.messages['editors'];
                end
            end 
            if (sepc ~= '.') then in_text = in_text:lower() end
            Editors = in_text .. Editors .. post_text;
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = Editors .. &quot; &quot;
                else Editors = Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif is_set(Editors) then
        if is_set(Date) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
            else
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if is_set(Date) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end
        if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
            text = safejoin( {Chapter, Place, tcommon}, sepc );
            text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
            text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
            text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
	if is_set(PostScript) and PostScript ~= sepc then
		text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
--		text = text:sub(1,-2);	--Remove final separator (assumes that sepc is only one character)
	end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    local options = {};
    
    if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
        options.class = &quot;citation &quot; .. config.CitationClass;
    else
        options.class = &quot;citation&quot;;
    end
    
    if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if #a &gt; 0 then
                for i,v in ipairs(a) do 
                    names[i] = v.last 
                    if i == 4 then break end
                end
            elseif #e &gt; 0 then
                for i,v in ipairs(e) do 
                    names[i] = v.last 
                    if i == 4 then break end                
                end
            end
			names[ #names + 1 ] = first_set(Year, anchor_year);	-- Year first for legacy citations
            id = anchorid(names)
        end
        options.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = {};
        text = seterror('empty_citation');
        z.message_tail = {};
    end
    
    if is_set(options.id) then 
        text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    else
        text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    end        

    local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        text = text .. &quot; &quot;;
        for i,v in ipairs( z.message_tail ) do
            if is_set(v[1]) then
                if i == #z.message_tail then
                    text = text .. errorcomment( v[1], v[2] );
                else
                    text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
                end
            end
        end
    end
    
    no_tracking_cats = no_tracking_cats:lower();
    if inArray(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    if nil ~= string.find( frame:getTitle(), 'sandbox', 1, true ) then				-- did the {{#invoke:}} use sandbox version?
    	cfg = mw.loadData( 'Module:Citation/CS1/Configuration/sandbox' );	-- load sandbox versions of Configuration and Whitelist and ...
    	whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist/sandbox' );
    	dates = require('Module:Citation/CS1/Date_validation/sandbox').dates	-- ... sandbox version of date validation code
    else																	-- otherwise
    	cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );			-- load live versions of Configuration and Whitelist and ...
    	whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );
    	dates = require('Module:Citation/CS1/Date_validation').dates		-- ... live version of date validation code
	end
	
    local args = {};
    local suggestions = {};
    local error_text, error_state;

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        args[k] = v;       
    end    

    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            if not validate( k ) then            
                error_text = &quot;&quot;;
                if type( k ) ~= 'string' then
                    -- Exclude empty numbered parameters
                    if v:match(&quot;%S+&quot;) ~= nil then
                        error_text, error_state = seterror( 'text_ignored', {v}, true );
                    end
                elseif validate( k:lower() ) then 
                    error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
                else
                    if #suggestions == 0 then
                        suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
                    end
                    if suggestions[ k:lower() ] ~= nil then
                        error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
                    else
                        error_text, error_state = seterror( 'parameter_ignored', {k}, true );
                    end
                end                  
                if error_text ~= '' then
                    table.insert( z.message_tail, {error_text, error_state} );
                end                
            end
            args[k] = v;
        elseif args[k] ~= nil or (k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z</text>
      <sha1>lo6xwe0knz7xynvby9rsvvyhw76rrl2</sha1>
    </revision>
    <revision>
      <id>4671</id>
      <parentid>4670</parentid>
      <timestamp>2014-08-24T10:59:00Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4671</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="82543" sha1="s5mh2z9v87ep18mtdwc4la2hbn05ffk" xml:space="preserve">local z = {
	error_categories = {};
	error_ids = {};
	message_tail = {};
}

-- Whether variable is set or not
function is_set( var )
	return not (var == nil or var == '');
end

-- First set variable or nil if none
function first_set(...)
	local list = {...};
	for _, var in pairs(list) do
		if is_set( var ) then
			return var;
		end
	end
end

-- Whether needle is in haystack
function inArray( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end

--[[
Categorize and emit an error message when the citation contains one or more deprecated parameters.  Because deprecated parameters (currently |day=, |month=,
|coauthor=, and |coauthors=) aren't related to each other and because these parameters may be concatenated into the variables used by |date= and |author#= (and aliases)
details of which parameter caused the error message are not provided.  Only one error message is emitted regardless of the number of deprecated parameters in the citation.
]]
function deprecated_parameter()
	if true ~= Page_in_deprecated_cat then	-- if we haven't been here before then set a 
		Page_in_deprecated_cat=true;		-- sticky flag so that if there are more than one deprecated parameter the category is added only once
--		table.insert( z.message_tail, { seterror( 'deprecated_params', {error_message}, true ) } );		-- add error message
		table.insert( z.message_tail, { seterror( 'deprecated_params', {}, true ) } );		-- add error message
	end
end

-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
--	return args and tostring( mw.message.newRawMessage( msg, args ) ) or msg;
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[
Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern  either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
]]
function kern_quotes (str)
	local left='&lt;span style=&quot;padding-left:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains leading single or double quote mark
	local right='&lt;span style=&quot;padding-right:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains trailing single or double quote mark
	
	if  str:match (&quot;^[\&quot;\'][^\']&quot;) then
		str = string.gsub( str, &quot;^[\&quot;\']&quot;, left, 1 );				-- replace (captured) leading single or double quote with left-side &lt;span&gt;
	end
	if str:match (&quot;[^\'][\&quot;\']$&quot;) then
		str = string.gsub( str, &quot;[\&quot;\']$&quot;, right, 1 );			-- replace (captured) trailing single or double quote with right-side &lt;span&gt;
	end
	return str;
end

-- Wraps a string using a message_list configuration taking one argument
function wrap( key, str, lower )
	if not is_set( str ) then
		return &quot;&quot;;
	elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safeforitalics( str );
	end
	if lower == true then
		return substitute( cfg.messages[key]:lower(), {str} );
	else
		return substitute( cfg.messages[key], {str} );
	end		
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = selectone( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
]]
function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
	return wrap( hidden and 'hidden-error' or 'visible-error', content );
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return errorcomment( message, error_state.hidden );
end

-- Formats a wiki style external link
function externallinkid(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

-- Formats a wiki style internal link
function internallinkid(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

-- Format an external link with error checking
function externallink( URL, label, source )
	local error_str = &quot;&quot;;
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = seterror( 'bare_url_missing_title', { wrap( 'parameter', source ) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not checkurl( URL ) then
		error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
	end
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safeforurl( label ), &quot;]&quot;, error_str });
end

-- Formats a link to Amazon
function amazon(id, domain)
	if not is_set(domain) then 
		domain = &quot;com&quot;
	elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
		domain = &quot;co.&quot; .. domain
	end
	local handler = cfg.id_handlers['ASIN'];
	return externallinkid({link = handler.link,
		label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
		encode=handler.encode, separator = handler.separator})
end

--[[
format and error check arXiv identifier.  There are two valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	
the second form, valid from April 2007 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces
]]

function arxiv (id)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = &quot;&quot;
	
	year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d$&quot;);				-- test for the 9108-0703 format
	if not year then		-- arXiv id is not proper 9108-0703 form
		year, month, version = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d([v%d]*)$&quot;);	-- test for the 0704- format
		if not year then	
			err_cat = ' ' .. seterror( 'bad_arxiv' );							-- arXiv id doesn't match either format
		else	-- id is the 0704- format
			year = tonumber(year);
			month = tonumber(month);
			if ((7 &gt; year) or (1 &gt; month and 12 &lt; month)) or					-- is year invalid or is month invalid? (doesn't test for future years)
				((7 == year) and (4 &gt; month)) or								-- when year is 07, is month invalid (before April)?
				is_set (version) and nil == version:match(&quot;v%d+&quot;) then			-- is version proper format of single 'v' followed by digits?
					err_cat = ' ' .. seterror( 'bad_arxiv' );					-- set error message
			end
		end
	else	-- id is the 9108-0703 format; are the date values ok
		year = tonumber(year);
		month = tonumber(month);
		if ((91 &gt; year and 7 &lt; year) or (1 &gt; month and 12 &lt; month)) or			-- if invalid year or invalid month
			((91 == year and 8 &gt; month) or (7 == year and 3 &lt; month)) then 		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. seterror( 'bad_arxiv' );						-- set error message
		end
	end

	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--[[
Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of the LCCN dictates the character type of the first 1-3 characters; the
rightmost eight are always digits. http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is alpha
length = 10 then lccn[1] and lccn[2] are both alpha or both digits
length = 11 then lccn[1] is alpha, lccn[2] and lccn[3] are both alpha or both digits
length = 12 then lccn[1] and lccn[2] are both alpha

]]
function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%a%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%a%a%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%a%a%a%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%a%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%a%a%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. seterror( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. seterror( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]
function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmid' );	-- set an error message
		end
	end
	
	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns true; otherwise, returns false because the embargo has expired or |embargo= not set in this cite.
]]
function is_embargoed(embargo)
	if is_set(embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 and tonumber( embargo_date ) &gt;= tonumber( todays_date ) then	--is embargo date is in the future?
			return true;	-- still embargoed
		end
	end
	return false;			-- embargo expired or |embargo= not set
end

--[[
Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future
the PMC identifier will not be linked to the article.  If the embargo specifies a date in the past, or if it is empty or omitted, then
the PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.
]]
function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_embargoed(embargo) then
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	--still embargoed so no external link
	else
		text = externallinkid({link = handler.link, label = handler.label,			--no embargo date, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.

-- DOI names contain two parts: prefix and suffix separated by a forward slash.
--  Prefix: directory indicator '10.' followed by a registrant code
--  Suffix: character string of any length chosen by the registrant

-- This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes,
-- or, if it ends with a period or a comma, this function will emit a bad_doi error message.

-- DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
-- and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely if ever used in doi names.

function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. seterror( 'bad_doi' );
	end
	return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
	local code = id:sub(-1,-1)
	local handler = cfg.id_handlers['OL'];
	if ( code == &quot;A&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	else
		return externallinkid({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode}) .. 
			' ' .. seterror( 'bad_ol' );
	end
end

--[[
Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.
]]
function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = externallinkid({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. seterror( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[
This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those citations that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).
]]
function set_titletype(cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;					-- if |type=none then type parameter not displayed
		end
		return title_type;						-- if |type= has been set to any other value use that value
	end

	if &quot;AV-media-notes&quot; == cite_class or &quot;DVD-notes&quot; == cite_class then		-- if this citation is cite AV media notes or cite DVD notes
		return &quot;Media notes&quot;;					-- display AV media notes / DVD media notes annotation

	elseif &quot;podcast&quot; == cite_class then			-- if this citation is cite podcast
		return &quot;Podcast&quot;;						-- display podcast annotation

	elseif &quot;pressrelease&quot; == cite_class then	-- if this citation is cite press release
		return &quot;Press release&quot;;					-- display press release annotation

	elseif &quot;techreport&quot; == cite_class then		-- if this citation is cite techreport
		return &quot;Technical report&quot;;				-- display techreport annotation
	
	elseif &quot;thesis&quot; == cite_class then			-- if this citation is cite thesis (degree option handled after this function returns)
			return &quot;Thesis&quot;;					-- display simple thesis annotation (without |degree= modification)
	end
end

--[[
Determines whether a URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
	-- Protocol-relative or URL scheme
	return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
	return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

-- Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.
--TODO: Fix so this code supports urls like this:
--	http://www.history.navy.mil/download/va125153.pdf#page=13 %w/:\.
function get_coins_pages (pages)
	if not is_set (pages) then return pages; end			-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);	-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end					-- no more urls
		pages = pages:gsub(pattern, &quot;&quot;);					-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);						-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end

--[[
ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in checkisbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.
]]
function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of bytes
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end	-- isbn13 begins with 978 or 979
		isbn_str = { isbn_str:byte(1, len) };
		for i, v in ipairs( isbn_str ) do
			temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
		end
		return temp % 10 == 0;
	end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
	--[[ Note: We cannot use &lt;i&gt; for italics, as the expected behavior for
	italics specified by ''...'' in the title is that they will be inverted
	(i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
	tend to interact poorly under Mediawiki's HTML tidy. ]]
	
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end

--[[
Joins a sequence of strings together while checking for duplicate separation characters.

TODO: safejoin() has a flaw where it won't remove the duplicate character from a |title= / |url= combination.
This is because by the time we get here, |title=http://somesite.com and |title=Document Title. have been combined:
	[http://somesite.com and ''Document Title.'']
so that now, the last character is not sepc but is ] (unless sepc == ']' which breaks the external link)
]]
function safejoin( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';
	local comp = '';
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then
			str = value;
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then
				-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
			else
				comp = value;
			end
			
			if comp:sub(1,1) == duplicate_char then
				trim = false;
				end_chr = str:sub(-1,-1);
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
				if end_chr == duplicate_char then
					str = str:sub(1,-2);
				elseif end_chr == &quot;'&quot; then
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
						str = str:sub(1, -4) .. &quot;''&quot;;
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
						trim = true;
					end
				elseif end_chr == &quot;]&quot; then
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
						trim = true;
					end
				elseif end_chr == &quot; &quot; then
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
						str = str:sub(1,-3);
					end
				end

				if trim then
					if value ~= comp then 
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
					else
						value = value:sub( 2, -1 );
					end
				end
			end
			str = str .. value;
		end
	end
	return str;
end  

-- Attempts to convert names to initials.
function reducetoinitials(first)
	local initials = {}
	local i = 0;										-- counter for number of initials
	for word in string.gmatch(first, &quot;%S+&quot;) do
		table.insert(initials, string.sub(word,1,1))	-- Vancouver format does not include full stops.
		i = i + 1;										-- bump the counter 
		if 2 &lt;= i then break; end						-- only two initials allowed in Vancouver system; if 2, quit
	end
	return table.concat(initials)						-- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
	local sep = control.sep;
	local namesep = control.namesep
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}
	local etal = false;
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if maximum ~= nil and maximum &lt; 1 then return &quot;&quot;, 0; end
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if maximum ~= nil and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
					one = one .. namesep .. first 
				end
				if is_set(person.link) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
				if is_set(person.link) and nil ~= person.link:find(&quot;//&quot;) then one = one .. &quot; &quot; .. seterror( 'bad_authorlink' ) end	-- check for url in author link;
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;
		end
		text[#text] = nil; 
	end
	
	local result = table.concat(text) -- construct list
	if etal then 
		local etal_text = cfg.messages['et al'];
		result = result .. &quot; &quot; .. etal_text;
	end
	
	-- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
	if ( &quot;scap&quot; == format ) then result = 
		'&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
	end 
	return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
	return &quot;CITEREF&quot; .. table.concat( options );
end

--[[
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.
]]
function extractnames(args, list_name)
	local names = {};			-- table of names
	local i = 1;				-- loop counter/indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	
	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary

	while true do
		names[i] =				-- search through args for name components beginning at 1
			{
			last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i ),
			first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i ),
			link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ),
			mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i )
			};
		if names[i].first and not names[i].last then							-- if there is a firstn without a matching lastn
			names[i].first = nil;												-- set first to nil so we don't confuse the implicit et al message code
			table.insert( z.message_tail, { seterror( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
			break;																-- and done because lastn not found
		elseif not names[i].first and not names[i].last then					-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 == count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- last with or without a first
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { seterror( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end

		i = i + 1;																-- bump to the next name
	end
	return names;																-- all done, return our list of names
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
	local id_list = {};
	for k, v in pairs( cfg.id_handlers ) do	
		v = selectone( args, v.parameters, 'redundant_parameters' );
		if is_set(v) then id_list[k] = v; end
	end
	return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
	local new_list, handler = {};
	
	function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, externallinkid( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internallinkid( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internallinkid( handler );
			if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
	local value = nil;
	local selected = '';
	local error_list = {};
	
	if index ~= nil then index = tostring(index); end
	
	-- Handle special case of &quot;#&quot; replaced by empty string
	if index == '1' then
		for _, v in ipairs( possible ) do
			v = v:gsub( &quot;#&quot;, &quot;&quot; );
			if is_set(args[v]) then
				if value ~= nil and selected ~= v then
					table.insert( error_list, v );
				else
					value = args[v];
					selected = v;
				end
			end
		end		
	end
	
	for _, v in ipairs( possible ) do
		if index ~= nil then
			v = v:gsub( &quot;#&quot;, index );
		end
		if is_set(args[v]) then
			if value ~= nil and selected ~=  v then
				table.insert( error_list, v );
			else
				value = args[v];
				selected = v;
			end
		end
	end
	
	if #error_list &gt; 0 then
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap( 'parameter', k );
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap( 'parameter', selected );
		table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
function COinS(data)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end
	
	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
			end
		end
	});
	
	if is_set(data.Chapter) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Chapter;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	elseif is_set(data.Periodical) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
		OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	else
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
	end
	
	OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
	OCinSoutput[&quot;rft.date&quot;] = data.Date;
	OCinSoutput[&quot;rft.series&quot;] = data.Series;
	OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
	OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
	OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
	OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
	OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
	
	for k, v in pairs( data.ID_list ) do
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
	
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = v.last, v.first;
		if k == 1 then
			if is_set(last) then
				OCinSoutput[&quot;rft.aulast&quot;] = last;
			end
			if is_set(first) then 
				OCinSoutput[&quot;rft.aufirst&quot;] = first;
			end
		end
		if is_set(last) and is_set(first) then
			OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
		elseif is_set(last) then
			OCinSoutput[&quot;rft.au&quot;] = last;
		end
	end
	
	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end

--[[
This is the main function doing the majority of the citation
formatting.
]]
function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple
	aliases to single internal variable.
	]]
	local A = argument_wrapper( args );

	local i 
	local PPrefix = A['PPrefix']
	local PPPrefix = A['PPPrefix']
	if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
	
	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local Authors = A['Authors'];
	local a = extractnames( args, 'AuthorList' );

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];
	local Editors = A['Editors'];
	local e = extractnames( args, 'EditorList' );

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
	local Chapter = A['Chapter'];
	local ChapterLink = A['ChapterLink'];
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveURL = A['ArchiveURL'];
	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');
	local Periodical = A['Periodical'];

	local Series = A['Series'];
	local Volume = A['Volume'];
	local Issue = A['Issue'];
	local Position = '';
	local Page = A['Page'];
	local Pages = hyphentodash( A['Pages'] );	
	local At = A['At'];

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
	local SubscriptionRequired = A['SubscriptionRequired'];
	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local ArchiveDate = A['ArchiveDate'];
	local Agency = A['Agency'];
	local DeadURL = A['DeadURL']
	local Language = A['Language'];
	local Format = A['Format'];
	local Ref = A['Ref'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
	local Embargo = A['Embargo'];

	local ID_list = extractids( args );
--[[ Hide unfinished cite newsgroup code so that long delayed update can take place
	-- special case for cite newsgroup which uses |id= for a usenet article or post id
	-- |id= is not included in COinS so here we convert it to an ID that will be included in COinS
	if ('newsgroup' == config.CitationClass) and (is_set (ID)) then
		ID_list['USENETID']=ID;			-- add this new 'id' to the list of IDs
		ID = '';						-- and unset
	end
]]	
	local Quote = A['Quote'];
	local PostScript = A['PostScript'];

	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');
	local sepc = A['Separator'];

	local LastAuthorAmp = A['LastAuthorAmp'];
	local no_tracking_cats = A['NoTracking'];

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Cointerviewers = A['Cointerviewers'];			-- deprecated
	local Interviewer = A['Interviewer'];				-- deprecated
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local page_type;									-- is this needed?  Doesn't appear to be used anywhere;
	local use_lowercase = ( sepc ~= '.' );
	local this_page = mw.title.getCurrentTitle();		--Also used for COinS and for language
	local anchor_year;									-- used in the CITEREF identifier
	local COinS_date;									-- used in the COinS metadata

-- Set postscript default.
	if not is_set (PostScript) then						-- if |postscript= has not been set (Postscript is nil which is the default for {{citation}}) and
		if (config.CitationClass ~= &quot;citation&quot;) then	-- this template is not a citation template
			PostScript = '.';							-- must be a cite xxx template so set postscript to default (period)
		end
	else
		if PostScript:lower() == 'none' then			-- if |postscript=none then
			PostScript = '';							-- no postscript
		end
	end

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories.
	if not is_set(no_tracking_cats) then				-- ignore if we are already not going to categorize this page
		for k, v in pairs( cfg.uncategorized_namespaces ) do	-- otherwise, spin through the list of namespaces we don't include in error categories
			if this_page.nsText == v then				-- if we find one
				no_tracking_cats = &quot;true&quot;;				-- set no_tracking_cats
				break;									-- and we're done
			end
		end
	end

-- check for extra |page=, |pages= or |at= parameters. 
	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Page = Page .. &quot; &quot; .. seterror('extra_pages');	-- add error message
			Pages = '';										-- unset the others
			At = '';
		end
	elseif is_set(Pages) then
		if is_set(At) then
			Pages = Pages .. &quot; &quot; .. seterror('extra_pages');	-- add error messages
			At = '';											-- unset
		end
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped

All other combinations of |encyclopedia, |title, and |article are not modified
]]
	if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
		if is_set(Periodical) then					-- Periodical is set when |encyclopedia is set
			if is_set(Title) then
				if not is_set(Chapter) then
					Chapter = Title;				-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					TransChapter = TransTitle;
					Title = Periodical;
					Periodical = '';				-- redundant so unset
					TransTitle = '';				-- redundant so unset
				end
			else									-- |title not set
				Title = Periodical;					-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';					-- redundant so unset
			end
		end
	end

--special cases for citation.
	if (config.CitationClass == &quot;citation&quot;) then		-- for citation templates
		if not is_set (Ref) then						-- if |ref= is not set
			Ref = &quot;harv&quot;;								-- set default |ref=harv
		end
		if not is_set (sepc) then						-- if |separator= is not set
			sepc = ',';									-- set citation separator to its default (comma)
		end
	else												-- not a citation template
		if not is_set (sepc) then						-- if |separator= has not been set
			sepc = '.';									-- set cite xxx separator to its default (period)
		end
	end

-- check for special case where |separator=none
	if 'none' == sepc:lower() then						-- if |separator=none
		sepc = '';										-- then set it to an empty string
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then	-- special case for cite techreport
		if is_set(Issue) then						-- cite techreport uses 'number', which other citations aliase to 'issue'
			if not is_set(ID) then					-- can we use ID for the &quot;number&quot;?
				ID = Issue;							-- yes, use it
				Issue = &quot;&quot;;							-- unset Issue so that &quot;number&quot; isn't duplicated in the rendered citation or COinS metadata
			else									-- can't use ID so emit error message
				ID = ID .. &quot; &quot; .. seterror('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Interviewer) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Interviewer;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Interviewer;
			end
			if is_set(Cointerviewers) then
				Others = Others .. sepc .. ' ' .. Cointerviewers;
			end
		else
			Others = '(Interview)';
		end
	end

--Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set
	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_embargoed(Embargo) then
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];	-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];		-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
--TODO: if this is only for {{cite conference}}, shouldn't we be checking? (if config.CitationClass=='conference' then ...)
	if is_set(BookTitle) then
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = BookTitle;
		TitleLink = '';
		TransTitle = '';
	end

-- Account for the oddity that is {{cite episode}}, before generation of COinS data.
--[[	-- {{cite episode}} is not currently supported by this module
	if config.CitationClass == &quot;episode&quot; then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];
		local Season = A['Season'];
		local SeriesNumber = A['SeriesNumber'];
		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
		local Sep = (first_set(A[&quot;SeriesSeparator&quot;], A[&quot;Separator&quot;]) or &quot;&quot;) .. &quot; &quot;;
		
		if is_set(Issue) then table.insert(s, cfg.messages[&quot;episode&quot;] .. &quot; &quot; .. Issue); Issue = ''; end
		if is_set(Season) then table.insert(s, cfg.messages[&quot;season&quot;] .. &quot; &quot; .. Season); end
		if is_set(SeriesNumber) then table.insert(s, cfg.messages[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber); end
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		
		Date = Date or AirDate;
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = Series;
		TitleLink = SeriesLink;
		TransTitle = '';
		
		Series = table.concat(s, Sep);
		ID = table.concat(n, Sep);
	end
-- end of {{cite episode}} stuff]]

-- legacy: promote concatenation of |day=, |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set(Date) then
		Date = Year;						-- promote Year to Date
		Year = nil;							-- make nil so Year as empty string isn't used for CITEREF
		if is_set(Date) then
			local Month = A['Month'];
			if is_set(Month) then
				Date = Month .. &quot; &quot; .. Date;
				local Day = A['Day']
				if is_set(Day) then Date = Day .. &quot; &quot; .. Date end
			end
		elseif is_set(PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;			-- promote PublicationDate to Date
			PublicationDate = '';			-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end	-- if PublicationDate is same as Date, don't display in rendered citation


--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	anchor_year, COinS_date, error_message = dates({['accessdate']=AccessDate, ['airdate']=AirDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
		['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});
	if is_set(error_message) then
		table.insert( z.message_tail, { seterror( 'bad_date', {error_message}, true ) } );	-- add this error message
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for
	-- automated parsing of citation information.
	local OCinSoutput = COinS{
		['Periodical'] = Periodical,
		['Chapter'] = Chapter,
		['Title'] = Title,
		['PublicationPlace'] = PublicationPlace,
		['Date'] = first_set(COinS_date, Date),		-- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here?  Should we be including invalid dates in metadata?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set(Page, Pages, At)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set( URL, ChapterURL ),
		['Authors'] = a,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	};

	if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = '';
		TitleLink = '';
		TransTitle = '';
	end
--[[ Hide unfinished cite newsgroup code so that long delayed update can take place
-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername and ID
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = '[Newsgroup]:&amp;nbsp;' ..  externallink( 'news:' .. PublisherName, PublisherName );
		end
	end
]]


	-- Now perform various field 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 not is_set(Authors) then
		local Maximum = tonumber( A['DisplayAuthors'] );
		
		-- Preserve old-style implicit et al.
		if not is_set(Maximum) and #a == 9 then 
			Maximum = 8;
			table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
		elseif not is_set(Maximum) then
			Maximum = #a + 1;
		end
			
		local control = { 
			sep = A[&quot;AuthorSeparator&quot;] .. &quot; &quot;,
			namesep = (first_set(A[&quot;AuthorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
			format = A[&quot;AuthorFormat&quot;],
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp
		};
		
		-- If the coauthor field is also used, prevent ampersand and et al. formatting.
		if is_set(Coauthors) then
			control.lastauthoramp = nil;
			control.maximum = #a + 1;
		end
		
		Authors = listpeople(control, a) 
	end

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { seterror('coauthors_missing_author', {}, true) } );	-- emit error message
	end

	local EditorCount
	if not is_set(Editors) then
		local Maximum = tonumber( A['DisplayEditors'] );
		-- Preserve old-style implicit et al.
		if not is_set(Maximum) and #e == 4 then 
			Maximum = 3;
			table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
		elseif not is_set(Maximum) then
			Maximum = #e + 1;
		end

		local control = { 
			sep = A[&quot;EditorSeparator&quot;] .. &quot; &quot;,
			namesep = (first_set(A[&quot;EditorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
			format = A['EditorFormat'],
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp
		};

		Editors, EditorCount = listpeople(control, e);
	else
		EditorCount = 1;
	end

	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	if config.CitationClass == &quot;map&quot; then
		if not is_set( Authors ) and is_set( PublisherName ) then
			Authors = PublisherName;
			PublisherName = &quot;&quot;;
		end
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap( 'cartography', Cartography, use_lowercase );
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end		
	end
	
	if  not is_set(URL) and
		not is_set(ChapterURL) and
		not is_set(ArchiveURL) and
		not is_set(ConferenceURL) and
		not is_set(TranscriptURL) then
		
		-- Test if cite web or cite podcast |url= is missing or empty 
		if inArray(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;}) then	
			table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
		end
		
		-- Test if accessdate is given without giving a URL
		if is_set(AccessDate) then
			table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
		
		-- Test if format is given without giving a URL
		if is_set(Format) then
			Format = Format .. seterror( 'format_missing_url' );
		end
	end
	
	-- Test if citation has no title
	if  not is_set(Chapter) and
		not is_set(Title) and
		not is_set(Periodical) and
		not is_set(Conference) and
		not is_set(TransTitle) and
		not is_set(TransChapter) then
		table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
	end
	
	Format = is_set(Format) and &quot; (&quot; .. Format .. &quot;)&quot; or &quot;&quot;;
	
	local OriginalURL = URL
	DeadURL = DeadURL:lower();
	if is_set( ArchiveURL ) then
		if ( DeadURL ~= &quot;no&quot; ) then
			URL = ArchiveURL
			URLorigin = A:ORIGIN('ArchiveURL')
		end
	end
	
	-- Format chapter / article title
	if is_set(Chapter) and is_set(ChapterLink) then 
		Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot;;
	end
	if is_set(Periodical) and is_set(Title) then
		Chapter = wrap( 'italic-title', Chapter );
		TransChapter = wrap( 'trans-italic-title', TransChapter );
	else
		Chapter = kern_quotes (Chapter);				-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
		Chapter = wrap( 'quoted-title', Chapter );
		TransChapter = wrap( 'trans-quoted-title', TransChapter );
	end
	
	local TransError = &quot;&quot;
	if is_set(TransChapter) then
		if not is_set(Chapter) then
			TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
		else
			TransChapter = &quot; &quot; .. TransChapter;
		end
	end
	
	Chapter = Chapter .. TransChapter;
	
	if is_set(Chapter) then
		if not is_set(ChapterLink) then
			if is_set(ChapterURL) then
				Chapter = externallink( ChapterURL, Chapter ) .. TransError;
				if not is_set(URL) then
					Chapter = Chapter .. Format;
					Format = &quot;&quot;;
				end
			elseif is_set(URL) then 
				Chapter = externallink( URL, Chapter ) .. TransError .. Format;
				URL = &quot;&quot;;
				Format = &quot;&quot;;
			else
				Chapter = Chapter .. TransError;
			end			
		elseif is_set(ChapterURL) then
			Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. 
				TransError;
		else
			Chapter = Chapter .. TransError;
		end
		Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
	elseif is_set(ChapterURL) then
		Chapter = &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. sepc .. &quot; &quot;;
	end		
	
	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end
	
	if is_set(Periodical) then
		Title = kern_quotes (Title);				-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
		Title = wrap( 'quoted-title', Title );
		TransTitle = wrap( 'trans-quoted-title', TransTitle );
--[[ Hide unfinished cite newsgroup code so that long delayed update can take place
	elseif inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;pressrelease&quot;,&quot;conference&quot;,&quot;podcast&quot;,&quot;newsgroup&quot;}) and
]]	elseif inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;pressrelease&quot;,&quot;conference&quot;,&quot;podcast&quot;}) and
			not is_set(Chapter) then
		Title = kern_quotes (Title);				-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
		Title = wrap( 'quoted-title', Title );
		TransTitle = wrap( 'trans-quoted-title', TransTitle );
	else
		Title = wrap( 'italic-title', Title );
		TransTitle = wrap( 'trans-italic-title', TransTitle );
	end
	
	TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if not is_set(Title) then
			TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
		else
			TransTitle = &quot; &quot; .. TransTitle;
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then 
			Title = externallink( URL, Title ) .. TransError .. Format	   
			URL = &quot;&quot;;
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end
	
	if is_set(Place) then
		Place = &quot; &quot; .. wrap( 'written', Place, use_lowercase ) .. sepc .. &quot; &quot;;
	end
	
	if is_set(Conference) then
		if is_set(ConferenceURL) then
			Conference = externallink( ConferenceURL, Conference );
		end
		Conference = sepc .. &quot; &quot; .. Conference
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. externallink( ConferenceURL, nil, ConferenceURLorigin );
	end
	
	if not is_set(Position) then
		local Minutes = A['Minutes'];
		if is_set(Minutes) then
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			local Time = A['Time'];
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end
	
	if not is_set(Page) then
		if is_set(Pages) then
			if is_set(Periodical) and
				not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
				Pages = &quot;: &quot; .. Pages;
			elseif tonumber(Pages) ~= nil then
				Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
			else
				Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
			end
		end
	else
		if is_set(Periodical) and
			not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
			Page = &quot;: &quot; .. Page;
		else
			Page = sepc ..&quot; &quot; .. PPrefix .. Page;
		end
	end
	
	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Inset = A['Inset'];
		if first_set( Pages, Page, At ) ~= nil or sepc ~= '.' then
			if is_set( Section ) then
				Section = &quot;, &quot; .. wrap( 'section', Section, true );
			end
			if is_set( Inset ) then
				Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
			end
		else
			if is_set( Section ) then
				Section = sepc .. &quot; &quot; .. wrap( 'section', Section, use_lowercase );
				if is_set( Inset ) then
					Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
				end
			elseif is_set( Inset ) then
				Inset = sepc .. &quot; &quot; .. wrap( 'inset', Inset, use_lowercase );
			end			
		end			
		At = At .. Section .. Inset;		
	end	

	--[[Look in the list of iso639-1 language codes to see if the value provided in the language parameter matches one of them.  If a match is found, 
	use that value; if not, then use the value that was provided with the language parameter.
	
	Categories are assigned in a manner similar to the {{xx icon}} templates - categorizes only mainspace citations and only when the language code is not 'en' (English).
	]]
	if is_set (Language) then
--		local name = mw.language.fetchLanguageName( Language:lower(), &quot;en&quot; );	-- experiment: this seems to return correct ISO 639-1 language names
		local name = cfg.iso639_1[Language:lower()];		-- get the language name if Language parameter has a valid iso 639-1 code
		if nil == name then
			Language=&quot; &quot; .. wrap( 'language', Language );	-- no match, use parameter's value
		else
			if 0 == this_page.namespace and 'en' ~= Language:lower() then	--found a match; is this page main / article space and English not the language?
				Language=&quot; &quot; .. wrap( 'language', name .. '[[Category:Articles with ' .. name .. '-language external links]]' );	-- in main space and not English: categorize
			else
				Language=&quot; &quot; .. wrap( 'language', name );	--not in mainspace or language is English so don't categorize
			end
		end
	else
		Language=&quot;&quot;;	-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;

-- handle type parameter for those CS1 citations that have default values

	if inArray(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then	-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then					-- if type parameter is specified
		TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot;;	-- display it in parentheses
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	Edition = is_set(Edition) and (&quot; &quot; .. wrap( 'edition', Edition )) or &quot;&quot;;
	Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc ..&quot; &quot; .. Volume;
		  else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
		end
	end

--[[ This code commented out while discussion continues until after week of 2014-03-23 live module update;
	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc .. &quot; &quot; .. Volume;
		  else
			  Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
			  if is_set(Series) then Volume = sepc .. Volume;
			  end
		end
	end
]]	
	------------------------------------ totally unrelated data
	--[[ Loosely mimic {{subscription required}} template; Via parameter identifies a delivery source that is not the publisher; these sources often, but not always, exist
	behind a registration or paywall.  So here, we've chosen to decouple via from subscription (via has never been part of the registration required template).
	
	Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link note is displayed. There are no error messages for this condition.
	]]
	if is_set(Via) then
		Via = &quot; &quot; .. wrap( 'via', Via );
	end

	if is_set(SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription']; --here when 'via' parameter not used but 'subscription' is
	elseif is_set(RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration']; --here when 'via' and 'subscription' parameters not used but 'registration' is
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
		AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
			.. substitute( retrv_text, {AccessDate} ) .. '&lt;/span&gt;'
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end

	
	ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo} );

	if is_set(URL) then
		URL = &quot; &quot; .. externallink( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
			Quote = Quote:sub(2,-2);
		end
		Quote = sepc ..&quot; &quot; .. wrap( 'quoted-text', Quote ); 
		PostScript = &quot;&quot;;							-- CS1 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = seterror('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ externallink( ArchiveURL, arch_text ), ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text,
				{ externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ seterror('archive_missing_url'), ArchiveDate } );
		end
	else
		Archived = &quot;&quot;
	end
	
	local Lay
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
		end			
	else
		Lay = &quot;&quot;;
	end
	
	if is_set(Transcript) then
		if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
	elseif is_set(TranscriptURL) then
		Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
	end
	
	local Publisher;
	if is_set(Periodical) and
		not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap( 'published', PublicationDate );
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap( 'published', PublicationDate ) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap( 'italic-title', Periodical ) 
		else 
			Periodical = wrap( 'italic-title', Periodical )
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon
	if inArray(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, 
			Language, Cartography, Edition, Publisher, Agency, Volume, Issue}, sepc );
	else 
		tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, Language, 
			Volume, Issue, Others, Cartography, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Page .. Pages .. At;
	
	if is_set(Authors) then
		if is_set(Coauthors) then
			Authors = Authors .. A['AuthorSeparator'] .. &quot; &quot; .. Coauthors
		end
		if is_set(Date) then
			Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		elseif string.sub(Authors,-1,-1) == sepc then
			Authors = Authors .. &quot; &quot;
		else
			Authors = Authors .. sepc .. &quot; &quot;
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			if (sepc ~= '.') then in_text = in_text:lower() end
			Editors = in_text .. Editors .. post_text;
			if (string.sub(Editors,-1,-1) == sepc)
				then Editors = Editors .. &quot; &quot;
				else Editors = Editors .. sepc .. &quot; &quot;
			end
		end
		text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
		text = safejoin( {text, pgtext, idcommon}, sepc );
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
		text = safejoin( {text, pgtext, idcommon}, sepc );
	else
		if is_set(Date) then
			if ( string.sub(tcommon,-1,-1) ~= sepc )
			  then Date = sepc ..&quot; &quot; .. Date .. OrigYear
			  else Date = &quot; &quot; .. Date .. OrigYear
			end
		end
		if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
			text = safejoin( {Chapter, Place, tcommon}, sepc );
			text = safejoin( {text, pgtext, Date, idcommon}, sepc );
		else
			text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
			text = safejoin( {text, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
--		text = text:sub(1,-2);	--Remove final separator (assumes that sepc is only one character)
	end	
	
	text = safejoin( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;span/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = &quot;citation &quot; .. config.CitationClass;
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
		local id = Ref
		if ( &quot;harv&quot; == Ref ) then
			local names = {} --table of last names &amp; year
			if #a &gt; 0 then
				for i,v in ipairs(a) do 
					names[i] = v.last 
					if i == 4 then break end
				end
			elseif #e &gt; 0 then
				for i,v in ipairs(e) do 
					names[i] = v.last 
					if i == 4 then break end				
				end
			end
			names[ #names + 1 ] = first_set(Year, anchor_year);	-- Year first for legacy citations
			id = anchorid(names)
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = seterror('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then 
		text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	else
		text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	end		

	local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
	
	-- Note: Using display: none on then COinS span breaks some clients.
	local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
	text = text .. OCinS;
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. errorcomment( v[1], v[2] );
				else
					text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if inArray(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
	local pframe = frame:getParent()
	
	if nil ~= string.find( frame:getTitle(), 'sandbox', 1, true ) then				-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData( 'Module:Citation/CS1/Configuration/sandbox' );	-- load sandbox versions of Configuration and Whitelist and ...
		whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist/sandbox' );
		dates = require('Module:Citation/CS1/Date_validation/sandbox').dates	-- ... sandbox version of date validation code
	else																	-- otherwise
		cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );			-- load live versions of Configuration and Whitelist and ...
		whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );
		dates = require('Module:Citation/CS1/Date_validation').dates		-- ... live version of date validation code
	end
	
	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = seterror( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if #suggestions == 0 then
						suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
					end
					if suggestions[ k:lower() ] ~= nil then
						error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
					else
						error_text, error_state = seterror( 'parameter_ignored', {k}, true );
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	
	
	return citation0( config, args)
end

return z</text>
      <sha1>s5mh2z9v87ep18mtdwc4la2hbn05ffk</sha1>
    </revision>
    <revision>
      <id>4672</id>
      <parentid>4671</parentid>
      <timestamp>2014-08-24T11:36:40Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Fix undocumented arxiv error check bug;</comment>
      <origin>4672</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="82783" sha1="7cric5a4jud1y0vrr380248irypajmx" xml:space="preserve">local z = {
	error_categories = {};
	error_ids = {};
	message_tail = {};
}

-- Whether variable is set or not
function is_set( var )
	return not (var == nil or var == '');
end

-- First set variable or nil if none
function first_set(...)
	local list = {...};
	for _, var in pairs(list) do
		if is_set( var ) then
			return var;
		end
	end
end

-- Whether needle is in haystack
function inArray( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end

--[[
Categorize and emit an error message when the citation contains one or more deprecated parameters.  Because deprecated parameters (currently |day=, |month=,
|coauthor=, and |coauthors=) aren't related to each other and because these parameters may be concatenated into the variables used by |date= and |author#= (and aliases)
details of which parameter caused the error message are not provided.  Only one error message is emitted regardless of the number of deprecated parameters in the citation.
]]
function deprecated_parameter()
	if true ~= Page_in_deprecated_cat then	-- if we haven't been here before then set a 
		Page_in_deprecated_cat=true;		-- sticky flag so that if there are more than one deprecated parameter the category is added only once
--		table.insert( z.message_tail, { seterror( 'deprecated_params', {error_message}, true ) } );		-- add error message
		table.insert( z.message_tail, { seterror( 'deprecated_params', {}, true ) } );		-- add error message
	end
end

-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
--	return args and tostring( mw.message.newRawMessage( msg, args ) ) or msg;
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[
Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern  either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
]]
function kern_quotes (str)
	local left='&lt;span style=&quot;padding-left:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains leading single or double quote mark
	local right='&lt;span style=&quot;padding-right:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains trailing single or double quote mark
	
	if  str:match (&quot;^[\&quot;\'][^\']&quot;) then
		str = string.gsub( str, &quot;^[\&quot;\']&quot;, left, 1 );				-- replace (captured) leading single or double quote with left-side &lt;span&gt;
	end
	if str:match (&quot;[^\'][\&quot;\']$&quot;) then
		str = string.gsub( str, &quot;[\&quot;\']$&quot;, right, 1 );			-- replace (captured) trailing single or double quote with right-side &lt;span&gt;
	end
	return str;
end

-- Wraps a string using a message_list configuration taking one argument
function wrap( key, str, lower )
	if not is_set( str ) then
		return &quot;&quot;;
	elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safeforitalics( str );
	end
	if lower == true then
		return substitute( cfg.messages[key]:lower(), {str} );
	else
		return substitute( cfg.messages[key], {str} );
	end		
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = selectone( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
]]
function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
	return wrap( hidden and 'hidden-error' or 'visible-error', content );
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return errorcomment( message, error_state.hidden );
end

-- Formats a wiki style external link
function externallinkid(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

-- Formats a wiki style internal link
function internallinkid(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

-- Format an external link with error checking
function externallink( URL, label, source )
	local error_str = &quot;&quot;;
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = seterror( 'bare_url_missing_title', { wrap( 'parameter', source ) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not checkurl( URL ) then
		error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
	end
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safeforurl( label ), &quot;]&quot;, error_str });
end

-- Formats a link to Amazon
function amazon(id, domain)
	if not is_set(domain) then 
		domain = &quot;com&quot;
	elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
		domain = &quot;co.&quot; .. domain
	end
	local handler = cfg.id_handlers['ASIN'];
	return externallinkid({link = handler.link,
		label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
		encode=handler.encode, separator = handler.separator})
end

--[[
format and error check arXiv identifier.  There are two valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces
]]

function arxiv (id)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = &quot;&quot;
	
	year, month, version = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d([v%d]*)$&quot;);				-- test for the 9108-0703 format
	if not year then		-- arXiv id is not proper 9108-0703 form
		year, month, version = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d([v%d]*)$&quot;);	-- test for the 0704- format
		if not year then	
			err_cat = ' ' .. seterror( 'bad_arxiv' );							-- arXiv id doesn't match either format
		else	-- id is the 0704- format
			year = tonumber(year);
			month = tonumber(month);
			if ((7 &gt; year) or (1 &gt; month and 12 &lt; month)) or					-- is year invalid or is month invalid? (doesn't test for future years)
				((7 == year) and (4 &gt; month)) or								-- when year is 07, is month invalid (before April)?
				is_set (version) and nil == version:match(&quot;v%d+&quot;) then			-- is version proper format of single 'v' followed by digits?
					err_cat = ' ' .. seterror( 'bad_arxiv' );					-- set error message
			end
		end
	else	-- id is the 9108-0703 format; are the date values ok
		year = tonumber(year);
		month = tonumber(month);
		if ((91 &gt; year and 7 &lt; year) or (1 &gt; month and 12 &lt; month)) or			-- if invalid year or invalid month
			((91 == year and 8 &gt; month) or (7 == year and 3 &lt; month)) or 		-- if years ok, are starting and ending months ok?
				is_set (version) and nil == version:match(&quot;v%d+&quot;) then			-- is version proper format of single 'v' followed by digits?
					err_cat = ' ' .. seterror( 'bad_arxiv' );					-- set error message
		end
	end

	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--[[
Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of the LCCN dictates the character type of the first 1-3 characters; the
rightmost eight are always digits. http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is alpha
length = 10 then lccn[1] and lccn[2] are both alpha or both digits
length = 11 then lccn[1] is alpha, lccn[2] and lccn[3] are both alpha or both digits
length = 12 then lccn[1] and lccn[2] are both alpha

]]
function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%a%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%a%a%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%a%a%a%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%a%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%a%a%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. seterror( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. seterror( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]
function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmid' );	-- set an error message
		end
	end
	
	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns true; otherwise, returns false because the embargo has expired or |embargo= not set in this cite.
]]
function is_embargoed(embargo)
	if is_set(embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 and tonumber( embargo_date ) &gt;= tonumber( todays_date ) then	--is embargo date is in the future?
			return true;	-- still embargoed
		end
	end
	return false;			-- embargo expired or |embargo= not set
end

--[[
Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future
the PMC identifier will not be linked to the article.  If the embargo specifies a date in the past, or if it is empty or omitted, then
the PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.
]]
function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_embargoed(embargo) then
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	--still embargoed so no external link
	else
		text = externallinkid({link = handler.link, label = handler.label,			--no embargo date, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.

-- DOI names contain two parts: prefix and suffix separated by a forward slash.
--  Prefix: directory indicator '10.' followed by a registrant code
--  Suffix: character string of any length chosen by the registrant

-- This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes,
-- or, if it ends with a period or a comma, this function will emit a bad_doi error message.

-- DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
-- and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely if ever used in doi names.

function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. seterror( 'bad_doi' );
	end
	return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
	local code = id:sub(-1,-1)
	local handler = cfg.id_handlers['OL'];
	if ( code == &quot;A&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	else
		return externallinkid({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode}) .. 
			' ' .. seterror( 'bad_ol' );
	end
end

--[[
Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.
]]
function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = externallinkid({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. seterror( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[
This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those citations that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).
]]
function set_titletype(cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;					-- if |type=none then type parameter not displayed
		end
		return title_type;						-- if |type= has been set to any other value use that value
	end

	if &quot;AV-media-notes&quot; == cite_class or &quot;DVD-notes&quot; == cite_class then		-- if this citation is cite AV media notes or cite DVD notes
		return &quot;Media notes&quot;;					-- display AV media notes / DVD media notes annotation

	elseif &quot;podcast&quot; == cite_class then			-- if this citation is cite podcast
		return &quot;Podcast&quot;;						-- display podcast annotation

	elseif &quot;pressrelease&quot; == cite_class then	-- if this citation is cite press release
		return &quot;Press release&quot;;					-- display press release annotation

	elseif &quot;techreport&quot; == cite_class then		-- if this citation is cite techreport
		return &quot;Technical report&quot;;				-- display techreport annotation
	
	elseif &quot;thesis&quot; == cite_class then			-- if this citation is cite thesis (degree option handled after this function returns)
			return &quot;Thesis&quot;;					-- display simple thesis annotation (without |degree= modification)
	end
end

--[[
Determines whether a URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
	-- Protocol-relative or URL scheme
	return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
	return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

-- Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.
--TODO: Fix so this code supports urls like this:
--	http://www.history.navy.mil/download/va125153.pdf#page=13 %w/:\.
function get_coins_pages (pages)
	if not is_set (pages) then return pages; end			-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);	-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end					-- no more urls
		pages = pages:gsub(pattern, &quot;&quot;);					-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);						-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end

--[[
ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in checkisbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.
]]
function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of bytes
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end	-- isbn13 begins with 978 or 979
		isbn_str = { isbn_str:byte(1, len) };
		for i, v in ipairs( isbn_str ) do
			temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
		end
		return temp % 10 == 0;
	end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
	--[[ Note: We cannot use &lt;i&gt; for italics, as the expected behavior for
	italics specified by ''...'' in the title is that they will be inverted
	(i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
	tend to interact poorly under Mediawiki's HTML tidy. ]]
	
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end

--[[
Joins a sequence of strings together while checking for duplicate separation characters.

TODO: safejoin() has a flaw where it won't remove the duplicate character from a |title= / |url= combination.
This is because by the time we get here, |title=http://somesite.com and |title=Document Title. have been combined:
	[http://somesite.com and ''Document Title.'']
so that now, the last character is not sepc but is ] (unless sepc == ']' which breaks the external link)
]]
function safejoin( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';
	local comp = '';
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then
			str = value;
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then
				-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
			else
				comp = value;
			end
			
			if comp:sub(1,1) == duplicate_char then
				trim = false;
				end_chr = str:sub(-1,-1);
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
				if end_chr == duplicate_char then
					str = str:sub(1,-2);
				elseif end_chr == &quot;'&quot; then
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
						str = str:sub(1, -4) .. &quot;''&quot;;
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
						trim = true;
					end
				elseif end_chr == &quot;]&quot; then
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
						trim = true;
					end
				elseif end_chr == &quot; &quot; then
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
						str = str:sub(1,-3);
					end
				end

				if trim then
					if value ~= comp then 
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
					else
						value = value:sub( 2, -1 );
					end
				end
			end
			str = str .. value;
		end
	end
	return str;
end  

-- Attempts to convert names to initials.
function reducetoinitials(first)
	local initials = {}
	local i = 0;										-- counter for number of initials
	for word in string.gmatch(first, &quot;%S+&quot;) do
		table.insert(initials, string.sub(word,1,1))	-- Vancouver format does not include full stops.
		i = i + 1;										-- bump the counter 
		if 2 &lt;= i then break; end						-- only two initials allowed in Vancouver system; if 2, quit
	end
	return table.concat(initials)						-- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
	local sep = control.sep;
	local namesep = control.namesep
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}
	local etal = false;
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if maximum ~= nil and maximum &lt; 1 then return &quot;&quot;, 0; end
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if maximum ~= nil and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
					one = one .. namesep .. first 
				end
				if is_set(person.link) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
				if is_set(person.link) and nil ~= person.link:find(&quot;//&quot;) then one = one .. &quot; &quot; .. seterror( 'bad_authorlink' ) end	-- check for url in author link;
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;
		end
		text[#text] = nil; 
	end
	
	local result = table.concat(text) -- construct list
	if etal then 
		local etal_text = cfg.messages['et al'];
		result = result .. &quot; &quot; .. etal_text;
	end
	
	-- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
	if ( &quot;scap&quot; == format ) then result = 
		'&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
	end 
	return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
	return &quot;CITEREF&quot; .. table.concat( options );
end

--[[
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.
]]
function extractnames(args, list_name)
	local names = {};			-- table of names
	local i = 1;				-- loop counter/indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	
	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary

	while true do
		names[i] =				-- search through args for name components beginning at 1
			{
			last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i ),
			first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i ),
			link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ),
			mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i )
			};
		if names[i].first and not names[i].last then							-- if there is a firstn without a matching lastn
			names[i].first = nil;												-- set first to nil so we don't confuse the implicit et al message code
			table.insert( z.message_tail, { seterror( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
			break;																-- and done because lastn not found
		elseif not names[i].first and not names[i].last then					-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 == count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- last with or without a first
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { seterror( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end

		i = i + 1;																-- bump to the next name
	end
	return names;																-- all done, return our list of names
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
	local id_list = {};
	for k, v in pairs( cfg.id_handlers ) do	
		v = selectone( args, v.parameters, 'redundant_parameters' );
		if is_set(v) then id_list[k] = v; end
	end
	return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
	local new_list, handler = {};
	
	function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, externallinkid( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internallinkid( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internallinkid( handler );
			if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
	local value = nil;
	local selected = '';
	local error_list = {};
	
	if index ~= nil then index = tostring(index); end
	
	-- Handle special case of &quot;#&quot; replaced by empty string
	if index == '1' then
		for _, v in ipairs( possible ) do
			v = v:gsub( &quot;#&quot;, &quot;&quot; );
			if is_set(args[v]) then
				if value ~= nil and selected ~= v then
					table.insert( error_list, v );
				else
					value = args[v];
					selected = v;
				end
			end
		end		
	end
	
	for _, v in ipairs( possible ) do
		if index ~= nil then
			v = v:gsub( &quot;#&quot;, index );
		end
		if is_set(args[v]) then
			if value ~= nil and selected ~=  v then
				table.insert( error_list, v );
			else
				value = args[v];
				selected = v;
			end
		end
	end
	
	if #error_list &gt; 0 then
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap( 'parameter', k );
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap( 'parameter', selected );
		table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
function COinS(data)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end
	
	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
			end
		end
	});
	
	if is_set(data.Chapter) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Chapter;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	elseif is_set(data.Periodical) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
		OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	else
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
	end
	
	OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
	OCinSoutput[&quot;rft.date&quot;] = data.Date;
	OCinSoutput[&quot;rft.series&quot;] = data.Series;
	OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
	OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
	OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
	OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
	OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
	
	for k, v in pairs( data.ID_list ) do
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
	
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = v.last, v.first;
		if k == 1 then
			if is_set(last) then
				OCinSoutput[&quot;rft.aulast&quot;] = last;
			end
			if is_set(first) then 
				OCinSoutput[&quot;rft.aufirst&quot;] = first;
			end
		end
		if is_set(last) and is_set(first) then
			OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
		elseif is_set(last) then
			OCinSoutput[&quot;rft.au&quot;] = last;
		end
	end
	
	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end

--[[
This is the main function doing the majority of the citation
formatting.
]]
function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple
	aliases to single internal variable.
	]]
	local A = argument_wrapper( args );

	local i 
	local PPrefix = A['PPrefix']
	local PPPrefix = A['PPPrefix']
	if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
	
	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local Authors = A['Authors'];
	local a = extractnames( args, 'AuthorList' );

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];
	local Editors = A['Editors'];
	local e = extractnames( args, 'EditorList' );

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
	local Chapter = A['Chapter'];
	local ChapterLink = A['ChapterLink'];
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveURL = A['ArchiveURL'];
	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');
	local Periodical = A['Periodical'];

	local Series = A['Series'];
	local Volume = A['Volume'];
	local Issue = A['Issue'];
	local Position = '';
	local Page = A['Page'];
	local Pages = hyphentodash( A['Pages'] );	
	local At = A['At'];

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
	local SubscriptionRequired = A['SubscriptionRequired'];
	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local ArchiveDate = A['ArchiveDate'];
	local Agency = A['Agency'];
	local DeadURL = A['DeadURL']
	local Language = A['Language'];
	local Format = A['Format'];
	local Ref = A['Ref'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
	local Embargo = A['Embargo'];

	local ID_list = extractids( args );
--[[ Hide unfinished cite newsgroup code so that long delayed update can take place
	-- special case for cite newsgroup which uses |id= for a usenet article or post id
	-- |id= is not included in COinS so here we convert it to an ID that will be included in COinS
	if ('newsgroup' == config.CitationClass) and (is_set (ID)) then
		ID_list['USENETID']=ID;			-- add this new 'id' to the list of IDs
		ID = '';						-- and unset
	end
]]	
	local Quote = A['Quote'];
	local PostScript = A['PostScript'];

	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');
	local sepc = A['Separator'];

	local LastAuthorAmp = A['LastAuthorAmp'];
	local no_tracking_cats = A['NoTracking'];

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Cointerviewers = A['Cointerviewers'];			-- deprecated
	local Interviewer = A['Interviewer'];				-- deprecated
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local page_type;									-- is this needed?  Doesn't appear to be used anywhere;
	local use_lowercase = ( sepc ~= '.' );
	local this_page = mw.title.getCurrentTitle();		--Also used for COinS and for language
	local anchor_year;									-- used in the CITEREF identifier
	local COinS_date;									-- used in the COinS metadata

-- Set postscript default.
	if not is_set (PostScript) then						-- if |postscript= has not been set (Postscript is nil which is the default for {{citation}}) and
		if (config.CitationClass ~= &quot;citation&quot;) then	-- this template is not a citation template
			PostScript = '.';							-- must be a cite xxx template so set postscript to default (period)
		end
	else
		if PostScript:lower() == 'none' then			-- if |postscript=none then
			PostScript = '';							-- no postscript
		end
	end

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories.
	if not is_set(no_tracking_cats) then				-- ignore if we are already not going to categorize this page
		for k, v in pairs( cfg.uncategorized_namespaces ) do	-- otherwise, spin through the list of namespaces we don't include in error categories
			if this_page.nsText == v then				-- if we find one
				no_tracking_cats = &quot;true&quot;;				-- set no_tracking_cats
				break;									-- and we're done
			end
		end
	end

-- check for extra |page=, |pages= or |at= parameters. 
	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Page = Page .. &quot; &quot; .. seterror('extra_pages');	-- add error message
			Pages = '';										-- unset the others
			At = '';
		end
	elseif is_set(Pages) then
		if is_set(At) then
			Pages = Pages .. &quot; &quot; .. seterror('extra_pages');	-- add error messages
			At = '';											-- unset
		end
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped

All other combinations of |encyclopedia, |title, and |article are not modified
]]
	if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
		if is_set(Periodical) then					-- Periodical is set when |encyclopedia is set
			if is_set(Title) then
				if not is_set(Chapter) then
					Chapter = Title;				-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					TransChapter = TransTitle;
					Title = Periodical;
					Periodical = '';				-- redundant so unset
					TransTitle = '';				-- redundant so unset
				end
			else									-- |title not set
				Title = Periodical;					-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';					-- redundant so unset
			end
		end
	end

--special cases for citation.
	if (config.CitationClass == &quot;citation&quot;) then		-- for citation templates
		if not is_set (Ref) then						-- if |ref= is not set
			Ref = &quot;harv&quot;;								-- set default |ref=harv
		end
		if not is_set (sepc) then						-- if |separator= is not set
			sepc = ',';									-- set citation separator to its default (comma)
		end
	else												-- not a citation template
		if not is_set (sepc) then						-- if |separator= has not been set
			sepc = '.';									-- set cite xxx separator to its default (period)
		end
	end

-- check for special case where |separator=none
	if 'none' == sepc:lower() then						-- if |separator=none
		sepc = '';										-- then set it to an empty string
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then	-- special case for cite techreport
		if is_set(Issue) then						-- cite techreport uses 'number', which other citations aliase to 'issue'
			if not is_set(ID) then					-- can we use ID for the &quot;number&quot;?
				ID = Issue;							-- yes, use it
				Issue = &quot;&quot;;							-- unset Issue so that &quot;number&quot; isn't duplicated in the rendered citation or COinS metadata
			else									-- can't use ID so emit error message
				ID = ID .. &quot; &quot; .. seterror('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Interviewer) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Interviewer;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Interviewer;
			end
			if is_set(Cointerviewers) then
				Others = Others .. sepc .. ' ' .. Cointerviewers;
			end
		else
			Others = '(Interview)';
		end
	end

--Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set
	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_embargoed(Embargo) then
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];	-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];		-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
--TODO: if this is only for {{cite conference}}, shouldn't we be checking? (if config.CitationClass=='conference' then ...)
	if is_set(BookTitle) then
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = BookTitle;
		TitleLink = '';
		TransTitle = '';
	end

-- Account for the oddity that is {{cite episode}}, before generation of COinS data.
--[[	-- {{cite episode}} is not currently supported by this module
	if config.CitationClass == &quot;episode&quot; then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];
		local Season = A['Season'];
		local SeriesNumber = A['SeriesNumber'];
		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
		local Sep = (first_set(A[&quot;SeriesSeparator&quot;], A[&quot;Separator&quot;]) or &quot;&quot;) .. &quot; &quot;;
		
		if is_set(Issue) then table.insert(s, cfg.messages[&quot;episode&quot;] .. &quot; &quot; .. Issue); Issue = ''; end
		if is_set(Season) then table.insert(s, cfg.messages[&quot;season&quot;] .. &quot; &quot; .. Season); end
		if is_set(SeriesNumber) then table.insert(s, cfg.messages[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber); end
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		
		Date = Date or AirDate;
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = Series;
		TitleLink = SeriesLink;
		TransTitle = '';
		
		Series = table.concat(s, Sep);
		ID = table.concat(n, Sep);
	end
-- end of {{cite episode}} stuff]]

-- legacy: promote concatenation of |day=, |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set(Date) then
		Date = Year;						-- promote Year to Date
		Year = nil;							-- make nil so Year as empty string isn't used for CITEREF
		if is_set(Date) then
			local Month = A['Month'];
			if is_set(Month) then
				Date = Month .. &quot; &quot; .. Date;
				local Day = A['Day']
				if is_set(Day) then Date = Day .. &quot; &quot; .. Date end
			end
		elseif is_set(PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;			-- promote PublicationDate to Date
			PublicationDate = '';			-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end	-- if PublicationDate is same as Date, don't display in rendered citation


--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	anchor_year, COinS_date, error_message = dates({['accessdate']=AccessDate, ['airdate']=AirDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
		['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});
	if is_set(error_message) then
		table.insert( z.message_tail, { seterror( 'bad_date', {error_message}, true ) } );	-- add this error message
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for
	-- automated parsing of citation information.
	local OCinSoutput = COinS{
		['Periodical'] = Periodical,
		['Chapter'] = Chapter,
		['Title'] = Title,
		['PublicationPlace'] = PublicationPlace,
		['Date'] = first_set(COinS_date, Date),		-- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here?  Should we be including invalid dates in metadata?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set(Page, Pages, At)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set( URL, ChapterURL ),
		['Authors'] = a,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	};

	if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = '';
		TitleLink = '';
		TransTitle = '';
	end
--[[ Hide unfinished cite newsgroup code so that long delayed update can take place
-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername and ID
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = '[Newsgroup]:&amp;nbsp;' ..  externallink( 'news:' .. PublisherName, PublisherName );
		end
	end
]]


	-- Now perform various field 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 not is_set(Authors) then
		local Maximum = tonumber( A['DisplayAuthors'] );
		
		-- Preserve old-style implicit et al.
		if not is_set(Maximum) and #a == 9 then 
			Maximum = 8;
			table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
		elseif not is_set(Maximum) then
			Maximum = #a + 1;
		end
			
		local control = { 
			sep = A[&quot;AuthorSeparator&quot;] .. &quot; &quot;,
			namesep = (first_set(A[&quot;AuthorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
			format = A[&quot;AuthorFormat&quot;],
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp
		};
		
		-- If the coauthor field is also used, prevent ampersand and et al. formatting.
		if is_set(Coauthors) then
			control.lastauthoramp = nil;
			control.maximum = #a + 1;
		end
		
		Authors = listpeople(control, a) 
	end

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { seterror('coauthors_missing_author', {}, true) } );	-- emit error message
	end

	local EditorCount
	if not is_set(Editors) then
		local Maximum = tonumber( A['DisplayEditors'] );
		-- Preserve old-style implicit et al.
		if not is_set(Maximum) and #e == 4 then 
			Maximum = 3;
			table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
		elseif not is_set(Maximum) then
			Maximum = #e + 1;
		end

		local control = { 
			sep = A[&quot;EditorSeparator&quot;] .. &quot; &quot;,
			namesep = (first_set(A[&quot;EditorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
			format = A['EditorFormat'],
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp
		};

		Editors, EditorCount = listpeople(control, e);
	else
		EditorCount = 1;
	end

	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	if config.CitationClass == &quot;map&quot; then
		if not is_set( Authors ) and is_set( PublisherName ) then
			Authors = PublisherName;
			PublisherName = &quot;&quot;;
		end
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap( 'cartography', Cartography, use_lowercase );
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end		
	end
	
	if  not is_set(URL) and
		not is_set(ChapterURL) and
		not is_set(ArchiveURL) and
		not is_set(ConferenceURL) and
		not is_set(TranscriptURL) then
		
		-- Test if cite web or cite podcast |url= is missing or empty 
		if inArray(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;}) then	
			table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
		end
		
		-- Test if accessdate is given without giving a URL
		if is_set(AccessDate) then
			table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
		
		-- Test if format is given without giving a URL
		if is_set(Format) then
			Format = Format .. seterror( 'format_missing_url' );
		end
	end
	
	-- Test if citation has no title
	if  not is_set(Chapter) and
		not is_set(Title) and
		not is_set(Periodical) and
		not is_set(Conference) and
		not is_set(TransTitle) and
		not is_set(TransChapter) then
		table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
	end
	
	Format = is_set(Format) and &quot; (&quot; .. Format .. &quot;)&quot; or &quot;&quot;;
	
	local OriginalURL = URL
	DeadURL = DeadURL:lower();
	if is_set( ArchiveURL ) then
		if ( DeadURL ~= &quot;no&quot; ) then
			URL = ArchiveURL
			URLorigin = A:ORIGIN('ArchiveURL')
		end
	end
	
	-- Format chapter / article title
	if is_set(Chapter) and is_set(ChapterLink) then 
		Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot;;
	end
	if is_set(Periodical) and is_set(Title) then
		Chapter = wrap( 'italic-title', Chapter );
		TransChapter = wrap( 'trans-italic-title', TransChapter );
	else
		Chapter = kern_quotes (Chapter);				-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
		Chapter = wrap( 'quoted-title', Chapter );
		TransChapter = wrap( 'trans-quoted-title', TransChapter );
	end
	
	local TransError = &quot;&quot;
	if is_set(TransChapter) then
		if not is_set(Chapter) then
			TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
		else
			TransChapter = &quot; &quot; .. TransChapter;
		end
	end
	
	Chapter = Chapter .. TransChapter;
	
	if is_set(Chapter) then
		if not is_set(ChapterLink) then
			if is_set(ChapterURL) then
				Chapter = externallink( ChapterURL, Chapter ) .. TransError;
				if not is_set(URL) then
					Chapter = Chapter .. Format;
					Format = &quot;&quot;;
				end
			elseif is_set(URL) then 
				Chapter = externallink( URL, Chapter ) .. TransError .. Format;
				URL = &quot;&quot;;
				Format = &quot;&quot;;
			else
				Chapter = Chapter .. TransError;
			end			
		elseif is_set(ChapterURL) then
			Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. 
				TransError;
		else
			Chapter = Chapter .. TransError;
		end
		Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
	elseif is_set(ChapterURL) then
		Chapter = &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. sepc .. &quot; &quot;;
	end		
	
	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end
	
	if is_set(Periodical) then
		Title = kern_quotes (Title);				-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
		Title = wrap( 'quoted-title', Title );
		TransTitle = wrap( 'trans-quoted-title', TransTitle );
--[[ Hide unfinished cite newsgroup code so that long delayed update can take place
	elseif inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;pressrelease&quot;,&quot;conference&quot;,&quot;podcast&quot;,&quot;newsgroup&quot;}) and
]]	elseif inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;pressrelease&quot;,&quot;conference&quot;,&quot;podcast&quot;}) and
			not is_set(Chapter) then
		Title = kern_quotes (Title);				-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
		Title = wrap( 'quoted-title', Title );
		TransTitle = wrap( 'trans-quoted-title', TransTitle );
	else
		Title = wrap( 'italic-title', Title );
		TransTitle = wrap( 'trans-italic-title', TransTitle );
	end
	
	TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if not is_set(Title) then
			TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
		else
			TransTitle = &quot; &quot; .. TransTitle;
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then 
			Title = externallink( URL, Title ) .. TransError .. Format	   
			URL = &quot;&quot;;
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end
	
	if is_set(Place) then
		Place = &quot; &quot; .. wrap( 'written', Place, use_lowercase ) .. sepc .. &quot; &quot;;
	end
	
	if is_set(Conference) then
		if is_set(ConferenceURL) then
			Conference = externallink( ConferenceURL, Conference );
		end
		Conference = sepc .. &quot; &quot; .. Conference
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. externallink( ConferenceURL, nil, ConferenceURLorigin );
	end
	
	if not is_set(Position) then
		local Minutes = A['Minutes'];
		if is_set(Minutes) then
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			local Time = A['Time'];
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end
	
	if not is_set(Page) then
		if is_set(Pages) then
			if is_set(Periodical) and
				not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
				Pages = &quot;: &quot; .. Pages;
			elseif tonumber(Pages) ~= nil then
				Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
			else
				Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
			end
		end
	else
		if is_set(Periodical) and
			not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
			Page = &quot;: &quot; .. Page;
		else
			Page = sepc ..&quot; &quot; .. PPrefix .. Page;
		end
	end
	
	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Inset = A['Inset'];
		if first_set( Pages, Page, At ) ~= nil or sepc ~= '.' then
			if is_set( Section ) then
				Section = &quot;, &quot; .. wrap( 'section', Section, true );
			end
			if is_set( Inset ) then
				Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
			end
		else
			if is_set( Section ) then
				Section = sepc .. &quot; &quot; .. wrap( 'section', Section, use_lowercase );
				if is_set( Inset ) then
					Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
				end
			elseif is_set( Inset ) then
				Inset = sepc .. &quot; &quot; .. wrap( 'inset', Inset, use_lowercase );
			end			
		end			
		At = At .. Section .. Inset;		
	end	

	--[[Look in the list of iso639-1 language codes to see if the value provided in the language parameter matches one of them.  If a match is found, 
	use that value; if not, then use the value that was provided with the language parameter.
	
	Categories are assigned in a manner similar to the {{xx icon}} templates - categorizes only mainspace citations and only when the language code is not 'en' (English).
	]]
	if is_set (Language) then
--		local name = mw.language.fetchLanguageName( Language:lower(), &quot;en&quot; );	-- experiment: this seems to return correct ISO 639-1 language names
		local name = cfg.iso639_1[Language:lower()];		-- get the language name if Language parameter has a valid iso 639-1 code
		if nil == name then
			Language=&quot; &quot; .. wrap( 'language', Language );	-- no match, use parameter's value
		else
			if 0 == this_page.namespace and 'en' ~= Language:lower() then	--found a match; is this page main / article space and English not the language?
				Language=&quot; &quot; .. wrap( 'language', name .. '[[Category:Articles with ' .. name .. '-language external links]]' );	-- in main space and not English: categorize
			else
				Language=&quot; &quot; .. wrap( 'language', name );	--not in mainspace or language is English so don't categorize
			end
		end
	else
		Language=&quot;&quot;;	-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;

-- handle type parameter for those CS1 citations that have default values

	if inArray(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then	-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then					-- if type parameter is specified
		TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot;;	-- display it in parentheses
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	Edition = is_set(Edition) and (&quot; &quot; .. wrap( 'edition', Edition )) or &quot;&quot;;
	Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc ..&quot; &quot; .. Volume;
		  else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
		end
	end

--[[ This code commented out while discussion continues until after week of 2014-03-23 live module update;
	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc .. &quot; &quot; .. Volume;
		  else
			  Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
			  if is_set(Series) then Volume = sepc .. Volume;
			  end
		end
	end
]]	
	------------------------------------ totally unrelated data
	--[[ Loosely mimic {{subscription required}} template; Via parameter identifies a delivery source that is not the publisher; these sources often, but not always, exist
	behind a registration or paywall.  So here, we've chosen to decouple via from subscription (via has never been part of the registration required template).
	
	Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link note is displayed. There are no error messages for this condition.
	]]
	if is_set(Via) then
		Via = &quot; &quot; .. wrap( 'via', Via );
	end

	if is_set(SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription']; --here when 'via' parameter not used but 'subscription' is
	elseif is_set(RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration']; --here when 'via' and 'subscription' parameters not used but 'registration' is
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
		AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
			.. substitute( retrv_text, {AccessDate} ) .. '&lt;/span&gt;'
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end

	
	ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo} );

	if is_set(URL) then
		URL = &quot; &quot; .. externallink( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
			Quote = Quote:sub(2,-2);
		end
		Quote = sepc ..&quot; &quot; .. wrap( 'quoted-text', Quote ); 
		PostScript = &quot;&quot;;							-- CS1 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = seterror('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ externallink( ArchiveURL, arch_text ), ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text,
				{ externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ seterror('archive_missing_url'), ArchiveDate } );
		end
	else
		Archived = &quot;&quot;
	end
	
	local Lay
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
		end			
	else
		Lay = &quot;&quot;;
	end
	
	if is_set(Transcript) then
		if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
	elseif is_set(TranscriptURL) then
		Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
	end
	
	local Publisher;
	if is_set(Periodical) and
		not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap( 'published', PublicationDate );
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap( 'published', PublicationDate ) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap( 'italic-title', Periodical ) 
		else 
			Periodical = wrap( 'italic-title', Periodical )
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon
	if inArray(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, 
			Language, Cartography, Edition, Publisher, Agency, Volume, Issue}, sepc );
	else 
		tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, Language, 
			Volume, Issue, Others, Cartography, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Page .. Pages .. At;
	
	if is_set(Authors) then
		if is_set(Coauthors) then
			Authors = Authors .. A['AuthorSeparator'] .. &quot; &quot; .. Coauthors
		end
		if is_set(Date) then
			Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		elseif string.sub(Authors,-1,-1) == sepc then
			Authors = Authors .. &quot; &quot;
		else
			Authors = Authors .. sepc .. &quot; &quot;
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			if (sepc ~= '.') then in_text = in_text:lower() end
			Editors = in_text .. Editors .. post_text;
			if (string.sub(Editors,-1,-1) == sepc)
				then Editors = Editors .. &quot; &quot;
				else Editors = Editors .. sepc .. &quot; &quot;
			end
		end
		text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
		text = safejoin( {text, pgtext, idcommon}, sepc );
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
		text = safejoin( {text, pgtext, idcommon}, sepc );
	else
		if is_set(Date) then
			if ( string.sub(tcommon,-1,-1) ~= sepc )
			  then Date = sepc ..&quot; &quot; .. Date .. OrigYear
			  else Date = &quot; &quot; .. Date .. OrigYear
			end
		end
		if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
			text = safejoin( {Chapter, Place, tcommon}, sepc );
			text = safejoin( {text, pgtext, Date, idcommon}, sepc );
		else
			text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
			text = safejoin( {text, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
--		text = text:sub(1,-2);	--Remove final separator (assumes that sepc is only one character)
	end	
	
	text = safejoin( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;span/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = &quot;citation &quot; .. config.CitationClass;
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
		local id = Ref
		if ( &quot;harv&quot; == Ref ) then
			local names = {} --table of last names &amp; year
			if #a &gt; 0 then
				for i,v in ipairs(a) do 
					names[i] = v.last 
					if i == 4 then break end
				end
			elseif #e &gt; 0 then
				for i,v in ipairs(e) do 
					names[i] = v.last 
					if i == 4 then break end				
				end
			end
			names[ #names + 1 ] = first_set(Year, anchor_year);	-- Year first for legacy citations
			id = anchorid(names)
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = seterror('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then 
		text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	else
		text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	end		

	local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
	
	-- Note: Using display: none on then COinS span breaks some clients.
	local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
	text = text .. OCinS;
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. errorcomment( v[1], v[2] );
				else
					text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if inArray(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
	local pframe = frame:getParent()
	
	if nil ~= string.find( frame:getTitle(), 'sandbox', 1, true ) then				-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData( 'Module:Citation/CS1/Configuration/sandbox' );	-- load sandbox versions of Configuration and Whitelist and ...
		whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist/sandbox' );
		dates = require('Module:Citation/CS1/Date_validation/sandbox').dates	-- ... sandbox version of date validation code
	else																	-- otherwise
		cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );			-- load live versions of Configuration and Whitelist and ...
		whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );
		dates = require('Module:Citation/CS1/Date_validation').dates		-- ... live version of date validation code
	end
	
	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = seterror( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if #suggestions == 0 then
						suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
					end
					if suggestions[ k:lower() ] ~= nil then
						error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
					else
						error_text, error_state = seterror( 'parameter_ignored', {k}, true );
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	
	
	return citation0( config, args)
end

return z</text>
      <sha1>7cric5a4jud1y0vrr380248irypajmx</sha1>
    </revision>
    <revision>
      <id>4673</id>
      <parentid>4672</parentid>
      <timestamp>2014-08-24T13:49:36Z</timestamp>
      <contributor>
        <username>Mr. Stradivarius</username>
        <id>812</id>
      </contributor>
      <comment>revert to version from March 30, 2014 - the update was causing Lua to exceed the 10-second execution limit on e.g. [[Karnataka]]</comment>
      <origin>4673</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="83070" sha1="lo6xwe0knz7xynvby9rsvvyhw76rrl2" xml:space="preserve">local z = {
    error_categories = {};
    error_ids = {};
    message_tail = {};
}

-- Include translation message hooks, ID and error handling configuration settings.
--local cfg = mw.loadData( 'Module:Citation/CS1/Configuration/sandbox' );

-- Contains a list of all recognized parameters
--local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist/sandbox' );

--local dates = require('Module:Citation/CS1/Date_validation/sandbox').dates		-- location of date validation code

-- Whether variable is set or not
function is_set( var )
    return not (var == nil or var == '');
end

-- First set variable or nil if none
function first_set(...)
    local list = {...};
    for _, var in pairs(list) do
        if is_set( var ) then
            return var;
        end
    end
end

-- Whether needle is in haystack
function inArray( needle, haystack )
    if needle == nil then
        return false;
    end
    for n,v in ipairs( haystack ) do
        if v == needle then
            return n;
        end
    end
    return false;
end

--[[
Categorize and emit an error message when the citation contains one or more deprecated parameters.  Because deprecated parameters (currently |day=, |month=,
|coauthor=, and |coauthors=) aren't related to each other and because these parameters may be concatenated into the variables used by |date= and |author#= (and aliases)
details of which parameter caused the error message are not provided.  Only one error message is emitted regarless of the number of deprecated parameters in the citation.
]]
function deprecated_parameter()
	if true ~= Page_in_deprecated_cat then	-- if we haven't been here before then set a 
		Page_in_deprecated_cat=true;		-- sticky flag so that if there are more than one deprecated parameter the category is added only once
--		table.insert( z.message_tail, { seterror( 'deprecated_params', {error_message}, true ) } );		-- add error message
		table.insert( z.message_tail, { seterror( 'deprecated_params', {}, true ) } );		-- add error message
	end
end

-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
--	return args and tostring( mw.message.newRawMessage( msg, args ) ) or msg;
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[
Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern  either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
]]
function kern_quotes (str)
	local left='&lt;span style=&quot;padding-left:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains leading single or double quote mark
	local right='&lt;span style=&quot;padding-right:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains trailing single or double quote mark
	
	if  str:match (&quot;^[\&quot;\'][^\']&quot;) then
		str = string.gsub( str, &quot;^[\&quot;\']&quot;, left, 1 );				-- replace (captured) leading single or double quote with left-side &lt;span&gt;
	end
	if str:match (&quot;[^\'][\&quot;\']$&quot;) then
		str = string.gsub( str, &quot;[\&quot;\']$&quot;, right, 1 );			-- replace (captured) trailing single or double quote with right-side &lt;span&gt;
	end
	return str;
end

-- Wraps a string using a message_list configuration taking one argument
function wrap( key, str, lower )
    if not is_set( str ) then
        return &quot;&quot;;
    elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
        str = safeforitalics( str );
    end
    if lower == true then
        return substitute( cfg.messages[key]:lower(), {str} );
    else
        return substitute( cfg.messages[key], {str} );
    end        
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
    local origin = {};
    
    return setmetatable({
        ORIGIN = function( self, k )
            local dummy = self[k]; --force the variable to be loaded.
            return origin[k];
        end
    },
    {
        __index = function ( tbl, k )
            if origin[k] ~= nil then
                return nil;
            end
            
            local args, list, v = args, cfg.aliases[k];
            
            if type( list ) == 'table' then
                v, origin[k] = selectone( args, list, 'redundant_parameters' );
                if origin[k] == nil then
                    origin[k] = ''; -- Empty string, not nil
                end
            elseif list ~= nil then
                v, origin[k] = args[list], list;
            else
                -- maybe let through instead of raising an error?
                -- v, origin[k] = args[k], k;
                error( cfg.messages['unknown_argument_map'] );
            end
            
            -- Empty strings, not nil;
            if v == nil then
                v = cfg.defaults[k] or '';
                origin[k] = '';
            end
            
            tbl = rawset( tbl, k, v );
            return v;
        end,
    });
end

--[[
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
]]
function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
    return wrap( hidden and 'hidden-error' or 'visible-error', content );
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
    local error_state = cfg.error_conditions[ error_id ];
    
    prefix = prefix or &quot;&quot;;
    suffix = suffix or &quot;&quot;;
    
    if error_state == nil then
        error( cfg.messages['undefined_error'] );
    elseif is_set( error_state.category ) then
        table.insert( z.error_categories, error_state.category );
    end
    
    local message = substitute( error_state.message, arguments );
    
    message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
        &quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
        cfg.messages['help page label'] .. &quot;]])&quot;;
    
    z.error_ids[ error_id ] = true;
    if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
            and z.error_ids['citation_missing_title'] then
        return '', false;
    end
    
    message = table.concat({ prefix, message, suffix });
    
    if raw == true then
        return message, error_state.hidden;
    end        
        
    return errorcomment( message, error_state.hidden );
end

-- Formats a wiki style external link
function externallinkid(options)
    local url_string = options.id;
    if options.encode == true or options.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, url_string, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Formats a wiki style internal link
function internallinkid(options)
    return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, options.id, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Format an external link with error checking
function externallink( URL, label, source )
    local error_str = &quot;&quot;;
    if not is_set( label ) then
        label = URL;
        if is_set( source ) then
            error_str = seterror( 'bare_url_missing_title', { wrap( 'parameter', source ) }, false, &quot; &quot; );
        else
            error( cfg.messages[&quot;bare_url_no_origin&quot;] );
        end            
    end
    if not checkurl( URL ) then
        error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
    end
    return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safeforurl( label ), &quot;]&quot;, error_str });
end

-- Formats a link to Amazon
function amazon(id, domain)
    if not is_set(domain) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local handler = cfg.id_handlers['ASIN'];
    return externallinkid({link = handler.link,
        label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
        encode=handler.encode, separator = handler.separator})
end

--[[
Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of the LCCN dictates the character type of the first 1-3 characters; the
rightmost eight are always digits. http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is alpha
length = 10 then lccn[1] and lccn[2] are both alpha or both digits
length = 11 then lccn[1] is alpha, lccn[2] and lccn[3] are both alpha or both digits
length = 12 then lccn[1] and lccn[2] are both alpha

]]
function lccn(id)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid

	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%a%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%a%a%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%a%a%a%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%a%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%a%a%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. seterror( 'bad_lccn' );		-- wrong length, set an error message
	end

	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]
function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmid' );	-- set an error message
		end
	end
	
	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns true; otherwse, returns false because the embargo has expired or |embargo= not set in this cite.
]]
function is_embargoed(embargo)
	if is_set(embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 and tonumber( embargo_date ) &gt;= tonumber( todays_date ) then	--is embargo date is in the future?
			return true;	-- still embargoed
		end
	end
	return false;			-- embargo expired or |embargo= not set
end

--[[
Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future
the PMC identifier will not be linked to the article.  If the embargo specifies a date in the past, or if it is empty or omitted, then
the PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.
]]
function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
    
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_embargoed(embargo) then
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	--still embargoed so no external link
	else
		text = externallinkid({link = handler.link, label = handler.label,			--no embargo date, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.

-- DOI names contain two parts: prefix and suffix separated by a forward slash.
--  Prefix: directory indicator '10.' followed by a registrant code
--  Suffix: character string of any length chosen by the registrant

-- This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes,
-- or, if it ends with a period or a comma, this function will emit a bad_doi error message.

-- DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
-- and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely if ever used in doi names.

function doi(id, inactive)
    local cat = &quot;&quot;
    local handler = cfg.id_handlers['DOI'];
    
    local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. seterror( 'bad_doi' );
	end
	return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    local handler = cfg.id_handlers['OL'];
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    else
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode}) .. 
            ' ' .. seterror( 'bad_ol' );
    end
end

--[[
Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.
]]
function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and ndashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 didgits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = externallinkid({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. seterror( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[
This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those citations that have defaults.
Also handles the special case where it is desireable to omit the title type from the rendered citation (|type=none).
]]
function set_titletype(cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;					-- if |type=none then type parameter not displayed
		end
		return title_type;						-- if |type= has been set to any other value use that value
	end

	if &quot;AV media notes&quot; == cite_class or &quot;DVD notes&quot; == cite_class then		-- if this citation is cite AV media notes or cite DVD notes
		return &quot;Media notes&quot;;					-- display AV media notes / DVD media notes annotation

	elseif &quot;podcast&quot; == cite_class then			-- if this citation is cite podcast
		return &quot;Podcast&quot;;						-- display podcast annotation

	elseif &quot;pressrelease&quot; == cite_class then	-- if this citation is cite press release
		return &quot;Press release&quot;;					-- display press release annotation

	elseif &quot;techreport&quot; == cite_class then		-- if this citation is cite techreport
		return &quot;Technical report&quot;;				-- display techreport annotation
	
	elseif &quot;thesis&quot; == cite_class then			-- if this citation is cite thesis (degree option handled after this function returns)
			return &quot;Thesis&quot;;					-- display simple thesis annotation (without |degree= modification)
	end
end

--[[
Determines whether a URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
    -- Protocol-relative or URL scheme
    return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
    return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

-- Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.
function get_coins_pages (pages)
	if not is_set (pages) then return pages; end			-- if no page numbers then we're done
	
    while true do
		pattern = pages:match(&quot;%[([%w/:\.]+%s+)[%w%d].*%]&quot;);	-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end					-- no more urls
		pages = pages:gsub(pattern, &quot;&quot;);					-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);						-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end

--[[
ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in checkisbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.
]]
function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of bytes
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end	-- isbn13 begins with 978 or 979
		isbn_str = { isbn_str:byte(1, len) };
		for i, v in ipairs( isbn_str ) do
			temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
		end
		return temp % 10 == 0;
	end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
    return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
        return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
    end));
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if not is_set(str) then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        
        -- Remove newlines as they break italics.
        return str:gsub( '\n', ' ' );
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    if maximum ~= nil and maximum &lt; 1 then return &quot;&quot;, 0; end
    
    for i,person in ipairs(people) do
        if is_set(person.last) then
            local mask = person.mask
            local one
            local sep_one = sep;
            if maximum ~= nil and i &gt; maximum then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask;
                    sep_one = &quot; &quot;;
                end
            else
                one = person.last
                local first = person.first
                if is_set(first) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if is_set(person.link) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
                if is_set(person.link) and nil ~= person.link:find(&quot;//&quot;) then one = one .. &quot; &quot; .. seterror( 'bad_authorlink' ) end	-- check for url in author link;
            end
            table.insert( text, one )
            table.insert( text, sep_one )
        end
    end

    local count = #text / 2;
    if count &gt; 0 then 
        if count &gt; 1 and is_set(lastauthoramp) and not etal then
            text[#text-2] = &quot; &amp; &quot;;
        end
        text[#text] = nil; 
    end
    
    local result = table.concat(text) -- construct list
    if etal then 
        local etal_text = cfg.messages['et al'];
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result = 
        '&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
    end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
    return &quot;CITEREF&quot; .. table.concat( options );
end

-- Gets name list from the input arguments
function extractnames(args, list_name)
    local names = {};
    local i = 1;
    local last;
    
    while true do
        last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );
        if not is_set(last) then
            -- just in case someone passed in an empty parameter
            break;
        end
        names[i] = {
            last = last,
            first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i ),
            link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ),
            mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i )
        };
        i = i + 1;
    end
    return names;
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
    local id_list = {};
    for k, v in pairs( cfg.id_handlers ) do    
        v = selectone( args, v.parameters, 'redundant_parameters' );
        if is_set(v) then id_list[k] = v; end
    end
    return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
    local new_list, handler = {};
    
    function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
    
    for k, v in pairs( id_list ) do
        -- fallback to read-only cfg
        handler = setmetatable( { ['id'] = v }, fallback(k) );
        
        if handler.mode == 'external' then
            table.insert( new_list, {handler.label, externallinkid( handler ) } );
        elseif handler.mode == 'internal' then
            table.insert( new_list, {handler.label, internallinkid( handler ) } );
        elseif handler.mode ~= 'manual' then
            error( cfg.messages['unknown_ID_mode'] );
        elseif k == 'DOI' then
            table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
        elseif k == 'ASIN' then
            table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
        elseif k == 'LCCN' then
            table.insert( new_list, {handler.label, lccn( v ) } );
        elseif k == 'OL' then
            table.insert( new_list, {handler.label, openlibrary( v ) } );
        elseif k == 'PMC' then
            table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
        elseif k == 'PMID' then
            table.insert( new_list, {handler.label, pmid( v ) } );
        elseif k == 'ISSN' then
        	table.insert( new_list, {handler.label, issn( v ) } );
        elseif k == 'ISBN' then
            local ISBN = internallinkid( handler );
            if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
                ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
            end
            table.insert( new_list, {handler.label, ISBN } );                
        else
            error( cfg.messages['unknown_manual_ID'] );
        end
    end
    
    function comp( a, b )	-- used in following table.sort()
        return a[1] &lt; b[1];
    end
    
    table.sort( new_list, comp );
    for k, v in ipairs( new_list ) do
        new_list[k] = v[2];
    end
    
    return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
    local value = nil;
    local selected = '';
    local error_list = {};
    
    if index ~= nil then index = tostring(index); end
    
    -- Handle special case of &quot;#&quot; replaced by empty string
    if index == '1' then
        for _, v in ipairs( possible ) do
            v = v:gsub( &quot;#&quot;, &quot;&quot; );
            if is_set(args[v]) then
                if value ~= nil and selected ~= v then
                    table.insert( error_list, v );
                else
                    value = args[v];
                    selected = v;
                end
            end
        end        
    end
    
    for _, v in ipairs( possible ) do
        if index ~= nil then
            v = v:gsub( &quot;#&quot;, index );
        end
        if is_set(args[v]) then
            if value ~= nil and selected ~=  v then
                table.insert( error_list, v );
            else
                value = args[v];
                selected = v;
            end
        end
    end
    
    if #error_list &gt; 0 then
        local error_str = &quot;&quot;;
        for _, k in ipairs( error_list ) do
            if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
            error_str = error_str .. wrap( 'parameter', k );
        end
        if #error_list &gt; 1 then
            error_str = error_str .. cfg.messages['parameter-final-separator'];
        else
            error_str = error_str .. cfg.messages['parameter-pair-separator'];
        end
        error_str = error_str .. wrap( 'parameter', selected );
        table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
    end
    
    return value, selected;
end

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
function COinS(data)
    if 'table' ~= type(data) or nil == next(data) then
        return '';
    end
    
    local ctx_ver = &quot;Z39.88-2004&quot;;
    
    -- treat table strictly as an array with only set values.
    local OCinSoutput = setmetatable( {}, {
        __newindex = function(self, key, value)
            if is_set(value) then
                rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
            end
        end
    });
    
    if is_set(data.Chapter) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Chapter;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    elseif is_set(data.Periodical) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
        OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    else
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
    end
    
    OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
    OCinSoutput[&quot;rft.date&quot;] = data.Date;
    OCinSoutput[&quot;rft.series&quot;] = data.Series;
    OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
    OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
    OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
    OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
    OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
    
    for k, v in pairs( data.ID_list ) do
        local id, value = cfg.id_handlers[k].COinS;
        if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
        if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
            OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
        else
            OCinSoutput[ id ] = value;
        end
    end
    
    local last, first;
    for k, v in ipairs( data.Authors ) do
        last, first = v.last, v.first;
        if k == 1 then
            if is_set(last) then
                OCinSoutput[&quot;rft.aulast&quot;] = last;
            end
            if is_set(first) then 
                OCinSoutput[&quot;rft.aufirst&quot;] = first;
            end
        end
        if is_set(last) and is_set(first) then
            OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
        elseif is_set(last) then
            OCinSoutput[&quot;rft.au&quot;] = last;
        end
    end
    
    OCinSoutput.rft_id = data.URL;
    OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
    OCinSoutput = setmetatable( OCinSoutput, nil );
    
    -- sort with version string always first, and combine.
    table.sort( OCinSoutput );
    table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
    return table.concat(OCinSoutput, &quot;&amp;&quot;);
end

--[[
This is the main function doing the majority of the citation
formatting.
]]
function citation0( config, args)
    --[[ 
    Load Input Parameters
    The argment_wrapper facillitates the mapping of multiple
    aliases to single internal variable.
    ]]
    local A = argument_wrapper( args );

    local i 
    local PPrefix = A['PPrefix']
    local PPPrefix = A['PPPrefix']
    if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = A['Authors'];
    local a = extractnames( args, 'AuthorList' );

    local Coauthors = A['Coauthors'];
    local Others = A['Others'];
    local Editors = A['Editors'];
    local e = extractnames( args, 'EditorList' );

    local Year = A['Year'];
    local PublicationDate = A['PublicationDate'];
    local OrigYear = A['OrigYear'];
    local Date = A['Date'];
    local LayDate = A['LayDate'];
    ------------------------------------------------- Get title data
    local Title = A['Title'];
    local BookTitle = A['BookTitle'];
    local Conference = A['Conference'];
    local TransTitle = A['TransTitle'];
    local TitleNote = A['TitleNote'];
    local TitleLink = A['TitleLink'];
    local Chapter = A['Chapter'];
    local ChapterLink = A['ChapterLink'];
    local TransChapter = A['TransChapter'];
    local TitleType = A['TitleType'];
    local Degree = A['Degree'];
    local Docket = A['Docket'];
    local ArchiveURL = A['ArchiveURL'];
    local URL = A['URL']
    local URLorigin = A:ORIGIN('URL');
    local ChapterURL = A['ChapterURL'];
    local ChapterURLorigin = A:ORIGIN('ChapterURL');
    local ConferenceURL = A['ConferenceURL'];
    local ConferenceURLorigin = A:ORIGIN('ConferenceURL');
    local Periodical = A['Periodical'];

	local Series = A['Series'];
    local Volume = A['Volume'];
    local Issue = A['Issue'];
    local Position = '';
    local Page = A['Page'];
    local Pages = hyphentodash( A['Pages'] );	
    local At = A['At'];

    local Edition = A['Edition'];
    local PublicationPlace = A['PublicationPlace']
    local Place = A['Place'];
    
    local PublisherName = A['PublisherName'];
    local RegistrationRequired = A['RegistrationRequired'];
    local SubscriptionRequired = A['SubscriptionRequired'];
    local Via = A['Via'];
    local AccessDate = A['AccessDate'];
    local ArchiveDate = A['ArchiveDate'];
    local Agency = A['Agency'];
    local DeadURL = A['DeadURL']
    local Language = A['Language'];
    local Format = A['Format'];
    local Ref = A['Ref'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
    local ASINTLD = A['ASINTLD'];
    local IgnoreISBN = A['IgnoreISBN'];
    local Embargo = A['Embargo'];

    local ID_list = extractids( args );
    
    local Quote = A['Quote'];
    local PostScript = A['PostScript'];

    local LayURL = A['LayURL'];
    local LaySource = A['LaySource'];
    local Transcript = A['Transcript'];
    local TranscriptURL = A['TranscriptURL'] 
    local TranscriptURLorigin = A:ORIGIN('TranscriptURL');
    local sepc = A['Separator'];

    local LastAuthorAmp = A['LastAuthorAmp'];
    local no_tracking_cats = A['NoTracking'];

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Cointerviewers = A['Cointerviewers'];			-- deprecated
	local Interviewer = A['Interviewer'];				-- deprecated
	local Program = A['Program'];

--local variables that are not cs1 parameters
    local page_type;									-- is this needed?  Doesn't appear to be used anywhere;
    local use_lowercase = ( sepc ~= '.' );
    local this_page = mw.title.getCurrentTitle();		--Also used for COinS and for language
	local anchor_year;									-- used in the CITEREF identifier
	local COinS_date;									-- used in the COinS metadata

-- Set postscript default.
	if not is_set (PostScript) then						-- if |postscript= has not been set (Postscript is nil which is the default for {{citation}}) and
		if (config.CitationClass ~= &quot;citation&quot;) then	-- this template is not a citation template
			PostScript = '.';							-- must be a cite xxx template so set postscript to default (period)
		end
	else
		if PostScript:lower() == 'none' then			-- if |postscript=none then
			PostScript = '';							-- no postscript
		end
	end

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories.
	if not is_set(no_tracking_cats) then				-- ignore if we are already not going to categorize this page
		for k, v in pairs( cfg.uncategorized_namespaces ) do	-- otherwise, spin through the list of namespaces we don't include in error categories
			if this_page.nsText == v then				-- if we find one
				no_tracking_cats = &quot;true&quot;;				-- set no_trackin_cats
				break;									-- and we're done
            end
        end
    end

-- check for extra |page=, |pages= or |at= parameters. 
    if is_set(Page) then
        if is_set(Pages) or is_set(At) then
            Page = Page .. &quot; &quot; .. seterror('extra_pages');	-- add error message
            Pages = '';										-- unset the others
            At = '';
        end
    elseif is_set(Pages) then
        if is_set(At) then
            Pages = Pages .. &quot; &quot; .. seterror('extra_pages');	-- add error messages
            At = '';											-- unset
        end
    end    

-- both |publication-place= and |place= (|location=) allowed if different
    if not is_set(PublicationPlace) and is_set(Place) then
        PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
    end
    
    if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
    
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped

All other combinations of |encyclopedia, |title, and |article are not modified
]]
	if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
		if is_set(Periodical) then					-- Periodical is set when |encyclopedia is set
			if is_set(Title) then
				if not is_set(Chapter) then
					Chapter = Title;				-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					TransChapter = TransTitle;
					Title = Periodical;
					Periodical = '';				-- redundant so unset
					TransTitle = '';				-- redundant so unset
				end
			else									-- |title not set
				Title = Periodical;					-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';					-- redundant so unset
			end
		end
	end

--special cases for citation.
	if (config.CitationClass == &quot;citation&quot;) then		-- for citation templates
		if not is_set (Ref) then						-- if |ref= is not set
			Ref = &quot;harv&quot;;								-- set default |ref=harv
		end
		if not is_set (sepc) then						-- if |separator= is not set
			sepc = ',';									-- set citation separator to its default (comma)
		end
	else												-- not a citation template
		if not is_set (sepc) then						-- if |separator= has not been set
			sepc = '.';									-- set cite xxx separator to its default (period)
		end
	end

-- check for specital case where |separator=none
	if 'none' == sepc:lower() then						-- if |separator=none
		sepc = '';										-- then set it to a empty string
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then	-- special case for cite techreport
		if is_set(Issue) then						-- cite techreport uses 'number', which other citations aliase to 'issue'
			if not is_set(ID) then					-- can we use ID for the &quot;number&quot;?
				ID = Issue;							-- yes, use it
				Issue = &quot;&quot;;							-- unset Issue so that &quot;number&quot; isn't duplicated in the rendered citation or COinS metadata
			else									-- can't use ID so emit error message
				ID = ID .. &quot; &quot; .. seterror('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Interviewer) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Interviewer;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Interviewer;
			end
			if is_set(Cointerviewers) then
				Others = Others .. sepc .. ' ' .. Cointerviewers;
			end
		else
			Others = '(Interview)';
		end
	end

--Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set
	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_embargoed(Embargo) then
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];	-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];		-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
--TODO: if this is only for {{cite conference}}, shouldn't we be checking? (if config.CitationClass=='conference' then ...)
	if is_set(BookTitle) then
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = BookTitle;
		TitleLink = '';
		TransTitle = '';
	end

-- Account for the oddity that is {{cite episode}}, before generation of COinS data.
--[[	-- {{cite episode}} is not currently supported by this module
	if config.CitationClass == &quot;episode&quot; then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];
		local Season = A['Season'];
		local SeriesNumber = A['SeriesNumber'];
		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
		local Sep = (first_set(A[&quot;SeriesSeparator&quot;], A[&quot;Separator&quot;]) or &quot;&quot;) .. &quot; &quot;;
		
		if is_set(Issue) then table.insert(s, cfg.messages[&quot;episode&quot;] .. &quot; &quot; .. Issue); Issue = ''; end
		if is_set(Season) then table.insert(s, cfg.messages[&quot;season&quot;] .. &quot; &quot; .. Season); end
		if is_set(SeriesNumber) then table.insert(s, cfg.messages[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber); end
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		
		Date = Date or AirDate;
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = Series;
		TitleLink = SeriesLink;
		TransTitle = '';
		
		Series = table.concat(s, Sep);
		ID = table.concat(n, Sep);
	end
-- end of {{cite episode}} stuff]]

-- legacy: promote concatenation of |day=, |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set(Date) then
		Date = Year;						-- promote Year to Date
		Year = nil;							-- make nil so Year as empty string isn't used for CITEREF
		if is_set(Date) then
			local Month = A['Month'];
			if is_set(Month) then
				Date = Month .. &quot; &quot; .. Date;
				local Day = A['Day']
				if is_set(Day) then Date = Day .. &quot; &quot; .. Date end
			end
		elseif is_set(PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;			-- promonte PublicationDate to Date
			PublicationDate = '';			-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end	-- if PublicationDate is same as Date, don't display in rendered citation


--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	anchor_year, COinS_date, error_message = dates({['accessdate']=AccessDate, ['airdate']=AirDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
		['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});
	if is_set(error_message) then
		table.insert( z.message_tail, { seterror( 'bad_date', {error_message}, true ) } );	-- add this error message
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.

    -- COinS metadata (see &lt;http://ocoins.info/&gt;) for
    -- automated parsing of citation information.
    local OCinSoutput = COinS{
        ['Periodical'] = Periodical,
        ['Chapter'] = Chapter,
        ['Title'] = Title,
        ['PublicationPlace'] = PublicationPlace,
        ['Date'] = first_set(COinS_date, Date),		-- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here?  Should we be including invalid dates in metadata?
        ['Series'] = Series,
        ['Volume'] = Volume,
        ['Issue'] = Issue,
        ['Pages'] = get_coins_pages (first_set(Page, Pages, At)),	-- pages stripped of external links
        ['Edition'] = Edition,
        ['PublisherName'] = PublisherName,
        ['URL'] = first_set( URL, ChapterURL ),
        ['Authors'] = a,
        ['ID_list'] = ID_list,
        ['RawPage'] = this_page.prefixedText,
    };

    if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = '';
        TitleLink = '';
        TransTitle = '';
    end

    -- Now perform various field 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 not is_set(Authors) then
        local Maximum = tonumber( A['DisplayAuthors'] );
        
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #a == 9 then 
            Maximum = 8;
            table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
        elseif not is_set(Maximum) then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = A[&quot;AuthorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;AuthorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A[&quot;AuthorFormat&quot;],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if is_set(Coauthors) then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
        
        Authors = listpeople(control, a) 
    end

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { seterror('coauthors_missing_author', {}, true) } );	-- emit error message
	end

    local EditorCount
    if not is_set(Editors) then
        local Maximum = tonumber( A['DisplayEditors'] );
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #e == 4 then 
            Maximum = 3;
            table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
        elseif not is_set(Maximum) then
            Maximum = #e + 1;
        end

        local control = { 
            sep = A[&quot;EditorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;EditorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A['EditorFormat'],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };

        Editors, EditorCount = listpeople(control, e);
    else
        EditorCount = 1;
    end

    local Cartography = &quot;&quot;;
    local Scale = &quot;&quot;;
    if config.CitationClass == &quot;map&quot; then
        if not is_set( Authors ) and is_set( PublisherName ) then
            Authors = PublisherName;
            PublisherName = &quot;&quot;;
        end
        Cartography = A['Cartography'];
        if is_set( Cartography ) then
            Cartography = sepc .. &quot; &quot; .. wrap( 'cartography', Cartography, use_lowercase );
        end        
        Scale = A['Scale'];
        if is_set( Scale ) then
            Scale = sepc .. &quot; &quot; .. Scale;
        end        
    end
    
    if  not is_set(URL) and
        not is_set(ChapterURL) and
        not is_set(ArchiveURL) and
        not is_set(ConferenceURL) and
        not is_set(TranscriptURL) then
        
        -- Test if cite web or cite podcast |url= is missing or empty 
		if inArray(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;}) then	
			table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
		end
        
        -- Test if accessdate is given without giving a URL
        if is_set(AccessDate) then
            table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
            AccessDate = '';
        end
        
        -- Test if format is given without giving a URL
        if is_set(Format) then
            Format = Format .. seterror( 'format_missing_url' );
        end
    end
    
    -- Test if citation has no title
    if  not is_set(Chapter) and
        not is_set(Title) and
        not is_set(Periodical) and
        not is_set(Conference) and
        not is_set(TransTitle) and
        not is_set(TransChapter) then
        table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
    end
    
    Format = is_set(Format) and &quot; (&quot; .. Format .. &quot;)&quot; or &quot;&quot;;
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if is_set( ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
            URLorigin = A:ORIGIN('ArchiveURL')
        end
    end
    
    -- Format chapter / article title
    if is_set(Chapter) and is_set(ChapterLink) then 
        Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot;;
    end
    if is_set(Periodical) and is_set(Title) then
        Chapter = wrap( 'italic-title', Chapter );
        TransChapter = wrap( 'trans-italic-title', TransChapter );
    else
		Chapter = kern_quotes (Chapter);				-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
        Chapter = wrap( 'quoted-title', Chapter );
        TransChapter = wrap( 'trans-quoted-title', TransChapter );
    end
    
    local TransError = &quot;&quot;
    if is_set(TransChapter) then
        if not is_set(Chapter) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
        else
            TransChapter = &quot; &quot; .. TransChapter;
        end
    end
    
    Chapter = Chapter .. TransChapter;
    
    if is_set(Chapter) then
        if not is_set(ChapterLink) then
            if is_set(ChapterURL) then
                Chapter = externallink( ChapterURL, Chapter ) .. TransError;
                if not is_set(URL) then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif is_set(URL) then 
                Chapter = externallink( URL, Chapter ) .. TransError .. Format;
                URL = &quot;&quot;;
                Format = &quot;&quot;;
            else
                Chapter = Chapter .. TransError;
            end            
        elseif is_set(ChapterURL) then
            Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. 
                TransError;
        else
            Chapter = Chapter .. TransError;
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    elseif is_set(ChapterURL) then
        Chapter = &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. sepc .. &quot; &quot;;
    end        
    
    -- Format main title.
    if is_set(TitleLink) and is_set(Title) then
        Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
    end
    
    if is_set(Periodical) then
		Title = kern_quotes (Title);				-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    elseif inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;pressrelease&quot;,&quot;conference&quot;,&quot;podcast&quot;}) and
            not is_set(Chapter) then
		Title = kern_quotes (Title);				-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    else
        Title = wrap( 'italic-title', Title );
        TransTitle = wrap( 'trans-italic-title', TransTitle );
    end
    
    TransError = &quot;&quot;;
    if is_set(TransTitle) then
        if not is_set(Title) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
        else
            TransTitle = &quot; &quot; .. TransTitle;
        end
    end
    
    Title = Title .. TransTitle;
    
    if is_set(Title) then
        if not is_set(TitleLink) and is_set(URL) then 
            Title = externallink( URL, Title ) .. TransError .. Format       
            URL = &quot;&quot;;
            Format = &quot;&quot;;
        else
            Title = Title .. TransError;
        end
    end
    
    if is_set(Place) then
        Place = &quot; &quot; .. wrap( 'written', Place, use_lowercase ) .. sepc .. &quot; &quot;;
    end
    
    if is_set(Conference) then
        if is_set(ConferenceURL) then
            Conference = externallink( ConferenceURL, Conference );
        end
        Conference = sepc .. &quot; &quot; .. Conference
    elseif is_set(ConferenceURL) then
        Conference = sepc .. &quot; &quot; .. externallink( ConferenceURL, nil, ConferenceURLorigin );
    end
    
    if not is_set(Position) then
        local Minutes = A['Minutes'];
        if is_set(Minutes) then
            Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
        else
            local Time = A['Time'];
            if is_set(Time) then
                local TimeCaption = A['TimeCaption']
                if not is_set(TimeCaption) then
                    TimeCaption = cfg.messages['event'];
                    if sepc ~= '.' then
                        TimeCaption = TimeCaption:lower();
                    end
                end
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
            end
        end
    else
        Position = &quot; &quot; .. Position;
        At = '';
    end
    
    if not is_set(Page) then
        if is_set(Pages) then
            if is_set(Periodical) and
                not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
                Pages = &quot;: &quot; .. Pages;
            elseif tonumber(Pages) ~= nil then
                Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
            else
                Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
            end
        end
    else
        if is_set(Periodical) and
            not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
            Page = &quot;: &quot; .. Page;
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page;
        end
    end
    
    At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
    Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
    if config.CitationClass == 'map' then
        local Section = A['Section'];
        local Inset = A['Inset'];
        if first_set( Pages, Page, At ) ~= nil or sepc ~= '.' then
            if is_set( Section ) then
                Section = &quot;, &quot; .. wrap( 'section', Section, true );
            end
            if is_set( Inset ) then
                Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
            end
        else
            if is_set( Section ) then
                Section = sepc .. &quot; &quot; .. wrap( 'section', Section, use_lowercase );
                if is_set( Inset ) then
                    Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
                end
            elseif is_set( Inset ) then
                Inset = sepc .. &quot; &quot; .. wrap( 'inset', Inset, use_lowercase );
            end            
        end            
        At = At .. Section .. Inset;        
    end    

	--[[Look in the list of iso639-1 language codes to see if the value provided in the language parameter matches one of them.  If a match is found, 
	use that value; if not, then use the value that was provided with the language parameter.
	
	Categories are assigned in a manner similar to the {{xx icon}} templates - categorizes only mainspace citations and only when the language code is not 'en' (English).
	]]
	if is_set (Language) then
--		local name = mw.language.fetchLanguageName( Language:lower(), &quot;en&quot; );	-- experiment: this seems to return correct ISO 639-1 language names
		local name = cfg.iso639_1[Language:lower()];		-- get the language name if Language parameter has a valid iso 639-1 code
		if nil == name then
			Language=&quot; &quot; .. wrap( 'language', Language );	-- no match, use parameter's value
		else
			if 0 == this_page.namespace and 'en' ~= Language:lower() then	--found a match; is this page main / article space and English not the language?
				Language=&quot; &quot; .. wrap( 'language', name .. '[[Category:Articles with ' .. name .. '-language external links]]' );	-- in main space and not English: categorize
			else
				Language=&quot; &quot; .. wrap( 'language', name );	--not in mainspace or language is English so don't categorize
			end
		end
	else
		Language=&quot;&quot;;	-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;

-- handle type parameter for those CS1 citations that have default values

	if inArray(config.CitationClass, {&quot;AV media notes&quot;, &quot;DVD notes&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then	-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then					-- if type parameter is specified
		TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot;;	-- display it in parentheses
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
    Edition = is_set(Edition) and (&quot; &quot; .. wrap( 'edition', Edition )) or &quot;&quot;;
    Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
    Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
    OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
    Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

    if is_set(Volume) then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume;
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
        end
    end

--[[ This code commented out while discussion continues until after week of 2014-03-23 live module update;
    if is_set(Volume) then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc .. &quot; &quot; .. Volume;
          else
              Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
              if is_set(Series) then Volume = sepc .. Volume;
              end
        end
    end
]]    
    ------------------------------------ totally unrelated data
    --[[ Loosely mimic {{subscription required}} template; Via parameter identifies a delivery source that is not the publisher; these sources often, but not always, exist
    behind a registration or paywall.  So here, we've chosen to decouple via from subscription (via has never been part of the registration required template).
    
    Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link note is displayed. There are no error messages for this condition.
    ]]
    if is_set(Via) then
        Via = &quot; &quot; .. wrap( 'via', Via );
    end

	if is_set(SubscriptionRequired) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription']; --here when 'via' parameter not used but 'subscription' is
    elseif is_set(RegistrationRequired) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration']; --here when 'via' and 'subscription' parameters not used but 'registration' is
    end

    if is_set(AccessDate) then
        local retrv_text = &quot; &quot; .. cfg.messages['retrieved']
        if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
        AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
            .. substitute( retrv_text, {AccessDate} ) .. '&lt;/span&gt;'
    end
    
    if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end

    
    ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo} );

    if is_set(URL) then
        URL = &quot; &quot; .. externallink( URL, nil, URLorigin );
    end

    if is_set(Quote) then
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        Quote = sepc ..&quot; &quot; .. wrap( 'quoted-text', Quote ); 
        PostScript = &quot;&quot;;							-- CS1 does not supply terminal punctuation when |quote= is set
    end
    
    local Archived
    if is_set(ArchiveURL) then
        if not is_set(ArchiveDate) then
            ArchiveDate = seterror('archive_missing_date');
        end
        if &quot;no&quot; == DeadURL then
            local arch_text = cfg.messages['archived'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
                { externallink( ArchiveURL, arch_text ), ArchiveDate } );
            if not is_set(OriginalURL) then
                Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url');                               
            end
        elseif is_set(OriginalURL) then
            local arch_text = cfg.messages['archived-dead'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text,
                { externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
        else
            local arch_text = cfg.messages['archived-missing'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
                { seterror('archive_missing_url'), ArchiveDate } );
        end
    else
        Archived = &quot;&quot;
    end
    
    local Lay
    if is_set(LayURL) then
        if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
        if is_set(LaySource) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot;;
        else
            LaySource = &quot;&quot;;
        end
        if sepc == '.' then
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;;
    end
    
    if is_set(Transcript) then
        if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
    elseif is_set(TranscriptURL) then
        Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
    end
    
    local Publisher;
    if is_set(Periodical) and
        not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end
        elseif is_set(PublicationPlace) then
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if is_set(PublicationDate) then
            if is_set(Publisher) then
                Publisher = Publisher .. &quot;, &quot; .. wrap( 'published', PublicationDate );
            else
                Publisher = PublicationDate;
            end
        end
        if is_set(Publisher) then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if is_set(PublicationDate) then
            PublicationDate = &quot; (&quot; .. wrap( 'published', PublicationDate ) .. &quot;)&quot;;
        end
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif is_set(PublicationPlace) then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    
    -- Several of the above rely upon detecting this as nil, so do it last.
    if is_set(Periodical) then
        if is_set(Title) or is_set(TitleNote) then 
            Periodical = sepc .. &quot; &quot; .. wrap( 'italic-title', Periodical ) 
        else 
            Periodical = wrap( 'italic-title', Periodical )
        end
    end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if inArray(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
        if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, 
            Language, Cartography, Edition, Publisher, Agency, Volume, Issue}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, Language, 
            Volume, Issue, Others, Cartography, Edition, Publisher, Agency}, sepc );
    end
    
    if #ID_list &gt; 0 then
        ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
    else
        ID_list = ID;
    end
    
    local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
    local text;
    local pgtext = Position .. Page .. Pages .. At;
    
    if is_set(Authors) then
        if is_set(Coauthors) then
            Authors = Authors .. A['AuthorSeparator'] .. &quot; &quot; .. Coauthors
        end
        if is_set(Date) then
            Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        elseif string.sub(Authors,-1,-1) == sepc then
            Authors = Authors .. &quot; &quot;
        else
            Authors = Authors .. sepc .. &quot; &quot;
        end
        if is_set(Editors) then
            local in_text = &quot; &quot;;
            local post_text = &quot;&quot;;
            if is_set(Chapter) then
                in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
            else
                if EditorCount &lt;= 1 then
                    post_text = &quot;, &quot; .. cfg.messages['editor'];
                else
                    post_text = &quot;, &quot; .. cfg.messages['editors'];
                end
            end 
            if (sepc ~= '.') then in_text = in_text:lower() end
            Editors = in_text .. Editors .. post_text;
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = Editors .. &quot; &quot;
                else Editors = Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif is_set(Editors) then
        if is_set(Date) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
            else
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if is_set(Date) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end
        if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
            text = safejoin( {Chapter, Place, tcommon}, sepc );
            text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
            text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
            text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
	if is_set(PostScript) and PostScript ~= sepc then
		text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
--		text = text:sub(1,-2);	--Remove final separator (assumes that sepc is only one character)
	end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    local options = {};
    
    if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
        options.class = &quot;citation &quot; .. config.CitationClass;
    else
        options.class = &quot;citation&quot;;
    end
    
    if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if #a &gt; 0 then
                for i,v in ipairs(a) do 
                    names[i] = v.last 
                    if i == 4 then break end
                end
            elseif #e &gt; 0 then
                for i,v in ipairs(e) do 
                    names[i] = v.last 
                    if i == 4 then break end                
                end
            end
			names[ #names + 1 ] = first_set(Year, anchor_year);	-- Year first for legacy citations
            id = anchorid(names)
        end
        options.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = {};
        text = seterror('empty_citation');
        z.message_tail = {};
    end
    
    if is_set(options.id) then 
        text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    else
        text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    end        

    local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        text = text .. &quot; &quot;;
        for i,v in ipairs( z.message_tail ) do
            if is_set(v[1]) then
                if i == #z.message_tail then
                    text = text .. errorcomment( v[1], v[2] );
                else
                    text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
                end
            end
        end
    end
    
    no_tracking_cats = no_tracking_cats:lower();
    if inArray(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    if nil ~= string.find( frame:getTitle(), 'sandbox', 1, true ) then				-- did the {{#invoke:}} use sandbox version?
    	cfg = mw.loadData( 'Module:Citation/CS1/Configuration/sandbox' );	-- load sandbox versions of Configuration and Whitelist and ...
    	whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist/sandbox' );
    	dates = require('Module:Citation/CS1/Date_validation/sandbox').dates	-- ... sandbox version of date validation code
    else																	-- otherwise
    	cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );			-- load live versions of Configuration and Whitelist and ...
    	whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );
    	dates = require('Module:Citation/CS1/Date_validation').dates		-- ... live version of date validation code
	end
	
    local args = {};
    local suggestions = {};
    local error_text, error_state;

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        args[k] = v;       
    end    

    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            if not validate( k ) then            
                error_text = &quot;&quot;;
                if type( k ) ~= 'string' then
                    -- Exclude empty numbered parameters
                    if v:match(&quot;%S+&quot;) ~= nil then
                        error_text, error_state = seterror( 'text_ignored', {v}, true );
                    end
                elseif validate( k:lower() ) then 
                    error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
                else
                    if #suggestions == 0 then
                        suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
                    end
                    if suggestions[ k:lower() ] ~= nil then
                        error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
                    else
                        error_text, error_state = seterror( 'parameter_ignored', {k}, true );
                    end
                end                  
                if error_text ~= '' then
                    table.insert( z.message_tail, {error_text, error_state} );
                end                
            end
            args[k] = v;
        elseif args[k] ~= nil or (k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z</text>
      <sha1>lo6xwe0knz7xynvby9rsvvyhw76rrl2</sha1>
    </revision>
    <revision>
      <id>4674</id>
      <parentid>4673</parentid>
      <timestamp>2014-08-24T14:02:34Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Disabled get_coins_pages() while debugging;</comment>
      <origin>4674</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="82827" sha1="bgzq74a6qkouh35p8t2mogcsn7lkm2i" xml:space="preserve">local z = {
	error_categories = {};
	error_ids = {};
	message_tail = {};
}

-- Whether variable is set or not
function is_set( var )
	return not (var == nil or var == '');
end

-- First set variable or nil if none
function first_set(...)
	local list = {...};
	for _, var in pairs(list) do
		if is_set( var ) then
			return var;
		end
	end
end

-- Whether needle is in haystack
function inArray( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end

--[[
Categorize and emit an error message when the citation contains one or more deprecated parameters.  Because deprecated parameters (currently |day=, |month=,
|coauthor=, and |coauthors=) aren't related to each other and because these parameters may be concatenated into the variables used by |date= and |author#= (and aliases)
details of which parameter caused the error message are not provided.  Only one error message is emitted regardless of the number of deprecated parameters in the citation.
]]
function deprecated_parameter()
	if true ~= Page_in_deprecated_cat then	-- if we haven't been here before then set a 
		Page_in_deprecated_cat=true;		-- sticky flag so that if there are more than one deprecated parameter the category is added only once
--		table.insert( z.message_tail, { seterror( 'deprecated_params', {error_message}, true ) } );		-- add error message
		table.insert( z.message_tail, { seterror( 'deprecated_params', {}, true ) } );		-- add error message
	end
end

-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
--	return args and tostring( mw.message.newRawMessage( msg, args ) ) or msg;
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[
Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern  either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
]]
function kern_quotes (str)
	local left='&lt;span style=&quot;padding-left:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains leading single or double quote mark
	local right='&lt;span style=&quot;padding-right:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains trailing single or double quote mark
	
	if  str:match (&quot;^[\&quot;\'][^\']&quot;) then
		str = string.gsub( str, &quot;^[\&quot;\']&quot;, left, 1 );				-- replace (captured) leading single or double quote with left-side &lt;span&gt;
	end
	if str:match (&quot;[^\'][\&quot;\']$&quot;) then
		str = string.gsub( str, &quot;[\&quot;\']$&quot;, right, 1 );			-- replace (captured) trailing single or double quote with right-side &lt;span&gt;
	end
	return str;
end

-- Wraps a string using a message_list configuration taking one argument
function wrap( key, str, lower )
	if not is_set( str ) then
		return &quot;&quot;;
	elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safeforitalics( str );
	end
	if lower == true then
		return substitute( cfg.messages[key]:lower(), {str} );
	else
		return substitute( cfg.messages[key], {str} );
	end		
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = selectone( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
]]
function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
	return wrap( hidden and 'hidden-error' or 'visible-error', content );
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return errorcomment( message, error_state.hidden );
end

-- Formats a wiki style external link
function externallinkid(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

-- Formats a wiki style internal link
function internallinkid(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

-- Format an external link with error checking
function externallink( URL, label, source )
	local error_str = &quot;&quot;;
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = seterror( 'bare_url_missing_title', { wrap( 'parameter', source ) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not checkurl( URL ) then
		error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
	end
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safeforurl( label ), &quot;]&quot;, error_str });
end

-- Formats a link to Amazon
function amazon(id, domain)
	if not is_set(domain) then 
		domain = &quot;com&quot;
	elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
		domain = &quot;co.&quot; .. domain
	end
	local handler = cfg.id_handlers['ASIN'];
	return externallinkid({link = handler.link,
		label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
		encode=handler.encode, separator = handler.separator})
end

--[[
format and error check arXiv identifier.  There are two valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces
]]

function arxiv (id)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = &quot;&quot;
	
	year, month, version = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d([v%d]*)$&quot;);				-- test for the 9108-0703 format
	if not year then		-- arXiv id is not proper 9108-0703 form
		year, month, version = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d([v%d]*)$&quot;);	-- test for the 0704- format
		if not year then	
			err_cat = ' ' .. seterror( 'bad_arxiv' );							-- arXiv id doesn't match either format
		else	-- id is the 0704- format
			year = tonumber(year);
			month = tonumber(month);
			if ((7 &gt; year) or (1 &gt; month and 12 &lt; month)) or					-- is year invalid or is month invalid? (doesn't test for future years)
				((7 == year) and (4 &gt; month)) or								-- when year is 07, is month invalid (before April)?
				is_set (version) and nil == version:match(&quot;v%d+&quot;) then			-- is version proper format of single 'v' followed by digits?
					err_cat = ' ' .. seterror( 'bad_arxiv' );					-- set error message
			end
		end
	else	-- id is the 9108-0703 format; are the date values ok
		year = tonumber(year);
		month = tonumber(month);
		if ((91 &gt; year and 7 &lt; year) or (1 &gt; month and 12 &lt; month)) or			-- if invalid year or invalid month
			((91 == year and 8 &gt; month) or (7 == year and 3 &lt; month)) or 		-- if years ok, are starting and ending months ok?
				is_set (version) and nil == version:match(&quot;v%d+&quot;) then			-- is version proper format of single 'v' followed by digits?
					err_cat = ' ' .. seterror( 'bad_arxiv' );					-- set error message
		end
	end

	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--[[
Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of the LCCN dictates the character type of the first 1-3 characters; the
rightmost eight are always digits. http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is alpha
length = 10 then lccn[1] and lccn[2] are both alpha or both digits
length = 11 then lccn[1] is alpha, lccn[2] and lccn[3] are both alpha or both digits
length = 12 then lccn[1] and lccn[2] are both alpha

]]
function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%a%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%a%a%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%a%a%a%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%a%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%a%a%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. seterror( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. seterror( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]
function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmid' );	-- set an error message
		end
	end
	
	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns true; otherwise, returns false because the embargo has expired or |embargo= not set in this cite.
]]
function is_embargoed(embargo)
	if is_set(embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 and tonumber( embargo_date ) &gt;= tonumber( todays_date ) then	--is embargo date is in the future?
			return true;	-- still embargoed
		end
	end
	return false;			-- embargo expired or |embargo= not set
end

--[[
Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future
the PMC identifier will not be linked to the article.  If the embargo specifies a date in the past, or if it is empty or omitted, then
the PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.
]]
function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_embargoed(embargo) then
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	--still embargoed so no external link
	else
		text = externallinkid({link = handler.link, label = handler.label,			--no embargo date, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.

-- DOI names contain two parts: prefix and suffix separated by a forward slash.
--  Prefix: directory indicator '10.' followed by a registrant code
--  Suffix: character string of any length chosen by the registrant

-- This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes,
-- or, if it ends with a period or a comma, this function will emit a bad_doi error message.

-- DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
-- and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely if ever used in doi names.

function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. seterror( 'bad_doi' );
	end
	return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
	local code = id:sub(-1,-1)
	local handler = cfg.id_handlers['OL'];
	if ( code == &quot;A&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	else
		return externallinkid({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode}) .. 
			' ' .. seterror( 'bad_ol' );
	end
end

--[[
Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.
]]
function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = externallinkid({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. seterror( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[
This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those citations that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).
]]
function set_titletype(cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;					-- if |type=none then type parameter not displayed
		end
		return title_type;						-- if |type= has been set to any other value use that value
	end

	if &quot;AV-media-notes&quot; == cite_class or &quot;DVD-notes&quot; == cite_class then		-- if this citation is cite AV media notes or cite DVD notes
		return &quot;Media notes&quot;;					-- display AV media notes / DVD media notes annotation

	elseif &quot;podcast&quot; == cite_class then			-- if this citation is cite podcast
		return &quot;Podcast&quot;;						-- display podcast annotation

	elseif &quot;pressrelease&quot; == cite_class then	-- if this citation is cite press release
		return &quot;Press release&quot;;					-- display press release annotation

	elseif &quot;techreport&quot; == cite_class then		-- if this citation is cite techreport
		return &quot;Technical report&quot;;				-- display techreport annotation
	
	elseif &quot;thesis&quot; == cite_class then			-- if this citation is cite thesis (degree option handled after this function returns)
			return &quot;Thesis&quot;;					-- display simple thesis annotation (without |degree= modification)
	end
end

--[[
Determines whether a URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
	-- Protocol-relative or URL scheme
	return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
	return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

-- Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.
--TODO: Fix so this code supports urls like this:
--	http://www.history.navy.mil/download/va125153.pdf#page=13 %w/:\.
function get_coins_pages (pages)
	if not is_set (pages) then return pages; end			-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);	-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end					-- no more urls
		pages = pages:gsub(pattern, &quot;&quot;);					-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);						-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end

--[[
ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in checkisbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.
]]
function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of bytes
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end	-- isbn13 begins with 978 or 979
		isbn_str = { isbn_str:byte(1, len) };
		for i, v in ipairs( isbn_str ) do
			temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
		end
		return temp % 10 == 0;
	end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
	--[[ Note: We cannot use &lt;i&gt; for italics, as the expected behavior for
	italics specified by ''...'' in the title is that they will be inverted
	(i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
	tend to interact poorly under Mediawiki's HTML tidy. ]]
	
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end

--[[
Joins a sequence of strings together while checking for duplicate separation characters.

TODO: safejoin() has a flaw where it won't remove the duplicate character from a |title= / |url= combination.
This is because by the time we get here, |title=http://somesite.com and |title=Document Title. have been combined:
	[http://somesite.com and ''Document Title.'']
so that now, the last character is not sepc but is ] (unless sepc == ']' which breaks the external link)
]]
function safejoin( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';
	local comp = '';
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then
			str = value;
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then
				-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
			else
				comp = value;
			end
			
			if comp:sub(1,1) == duplicate_char then
				trim = false;
				end_chr = str:sub(-1,-1);
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
				if end_chr == duplicate_char then
					str = str:sub(1,-2);
				elseif end_chr == &quot;'&quot; then
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
						str = str:sub(1, -4) .. &quot;''&quot;;
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
						trim = true;
					end
				elseif end_chr == &quot;]&quot; then
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
						trim = true;
					end
				elseif end_chr == &quot; &quot; then
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
						str = str:sub(1,-3);
					end
				end

				if trim then
					if value ~= comp then 
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
					else
						value = value:sub( 2, -1 );
					end
				end
			end
			str = str .. value;
		end
	end
	return str;
end  

-- Attempts to convert names to initials.
function reducetoinitials(first)
	local initials = {}
	local i = 0;										-- counter for number of initials
	for word in string.gmatch(first, &quot;%S+&quot;) do
		table.insert(initials, string.sub(word,1,1))	-- Vancouver format does not include full stops.
		i = i + 1;										-- bump the counter 
		if 2 &lt;= i then break; end						-- only two initials allowed in Vancouver system; if 2, quit
	end
	return table.concat(initials)						-- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
	local sep = control.sep;
	local namesep = control.namesep
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}
	local etal = false;
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if maximum ~= nil and maximum &lt; 1 then return &quot;&quot;, 0; end
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if maximum ~= nil and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
					one = one .. namesep .. first 
				end
				if is_set(person.link) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
				if is_set(person.link) and nil ~= person.link:find(&quot;//&quot;) then one = one .. &quot; &quot; .. seterror( 'bad_authorlink' ) end	-- check for url in author link;
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;
		end
		text[#text] = nil; 
	end
	
	local result = table.concat(text) -- construct list
	if etal then 
		local etal_text = cfg.messages['et al'];
		result = result .. &quot; &quot; .. etal_text;
	end
	
	-- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
	if ( &quot;scap&quot; == format ) then result = 
		'&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
	end 
	return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
	return &quot;CITEREF&quot; .. table.concat( options );
end

--[[
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.
]]
function extractnames(args, list_name)
	local names = {};			-- table of names
	local i = 1;				-- loop counter/indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	
	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary

	while true do
		names[i] =				-- search through args for name components beginning at 1
			{
			last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i ),
			first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i ),
			link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ),
			mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i )
			};
		if names[i].first and not names[i].last then							-- if there is a firstn without a matching lastn
			names[i].first = nil;												-- set first to nil so we don't confuse the implicit et al message code
			table.insert( z.message_tail, { seterror( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
			break;																-- and done because lastn not found
		elseif not names[i].first and not names[i].last then					-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 == count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- last with or without a first
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { seterror( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end

		i = i + 1;																-- bump to the next name
	end
	return names;																-- all done, return our list of names
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
	local id_list = {};
	for k, v in pairs( cfg.id_handlers ) do	
		v = selectone( args, v.parameters, 'redundant_parameters' );
		if is_set(v) then id_list[k] = v; end
	end
	return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
	local new_list, handler = {};
	
	function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, externallinkid( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internallinkid( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internallinkid( handler );
			if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
	local value = nil;
	local selected = '';
	local error_list = {};
	
	if index ~= nil then index = tostring(index); end
	
	-- Handle special case of &quot;#&quot; replaced by empty string
	if index == '1' then
		for _, v in ipairs( possible ) do
			v = v:gsub( &quot;#&quot;, &quot;&quot; );
			if is_set(args[v]) then
				if value ~= nil and selected ~= v then
					table.insert( error_list, v );
				else
					value = args[v];
					selected = v;
				end
			end
		end		
	end
	
	for _, v in ipairs( possible ) do
		if index ~= nil then
			v = v:gsub( &quot;#&quot;, index );
		end
		if is_set(args[v]) then
			if value ~= nil and selected ~=  v then
				table.insert( error_list, v );
			else
				value = args[v];
				selected = v;
			end
		end
	end
	
	if #error_list &gt; 0 then
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap( 'parameter', k );
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap( 'parameter', selected );
		table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
function COinS(data)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end
	
	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
			end
		end
	});
	
	if is_set(data.Chapter) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Chapter;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	elseif is_set(data.Periodical) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
		OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	else
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
	end
	
	OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
	OCinSoutput[&quot;rft.date&quot;] = data.Date;
	OCinSoutput[&quot;rft.series&quot;] = data.Series;
	OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
	OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
	OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
	OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
	OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
	
	for k, v in pairs( data.ID_list ) do
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
	
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = v.last, v.first;
		if k == 1 then
			if is_set(last) then
				OCinSoutput[&quot;rft.aulast&quot;] = last;
			end
			if is_set(first) then 
				OCinSoutput[&quot;rft.aufirst&quot;] = first;
			end
		end
		if is_set(last) and is_set(first) then
			OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
		elseif is_set(last) then
			OCinSoutput[&quot;rft.au&quot;] = last;
		end
	end
	
	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end

--[[
This is the main function doing the majority of the citation
formatting.
]]
function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple
	aliases to single internal variable.
	]]
	local A = argument_wrapper( args );

	local i 
	local PPrefix = A['PPrefix']
	local PPPrefix = A['PPPrefix']
	if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
	
	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local Authors = A['Authors'];
	local a = extractnames( args, 'AuthorList' );

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];
	local Editors = A['Editors'];
	local e = extractnames( args, 'EditorList' );

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
	local Chapter = A['Chapter'];
	local ChapterLink = A['ChapterLink'];
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveURL = A['ArchiveURL'];
	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');
	local Periodical = A['Periodical'];

	local Series = A['Series'];
	local Volume = A['Volume'];
	local Issue = A['Issue'];
	local Position = '';
	local Page = A['Page'];
	local Pages = hyphentodash( A['Pages'] );	
	local At = A['At'];

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
	local SubscriptionRequired = A['SubscriptionRequired'];
	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local ArchiveDate = A['ArchiveDate'];
	local Agency = A['Agency'];
	local DeadURL = A['DeadURL']
	local Language = A['Language'];
	local Format = A['Format'];
	local Ref = A['Ref'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
	local Embargo = A['Embargo'];

	local ID_list = extractids( args );
--[[ Hide unfinished cite newsgroup code so that long delayed update can take place
	-- special case for cite newsgroup which uses |id= for a usenet article or post id
	-- |id= is not included in COinS so here we convert it to an ID that will be included in COinS
	if ('newsgroup' == config.CitationClass) and (is_set (ID)) then
		ID_list['USENETID']=ID;			-- add this new 'id' to the list of IDs
		ID = '';						-- and unset
	end
]]	
	local Quote = A['Quote'];
	local PostScript = A['PostScript'];

	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');
	local sepc = A['Separator'];

	local LastAuthorAmp = A['LastAuthorAmp'];
	local no_tracking_cats = A['NoTracking'];

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Cointerviewers = A['Cointerviewers'];			-- deprecated
	local Interviewer = A['Interviewer'];				-- deprecated
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local page_type;									-- is this needed?  Doesn't appear to be used anywhere;
	local use_lowercase = ( sepc ~= '.' );
	local this_page = mw.title.getCurrentTitle();		--Also used for COinS and for language
	local anchor_year;									-- used in the CITEREF identifier
	local COinS_date;									-- used in the COinS metadata

-- Set postscript default.
	if not is_set (PostScript) then						-- if |postscript= has not been set (Postscript is nil which is the default for {{citation}}) and
		if (config.CitationClass ~= &quot;citation&quot;) then	-- this template is not a citation template
			PostScript = '.';							-- must be a cite xxx template so set postscript to default (period)
		end
	else
		if PostScript:lower() == 'none' then			-- if |postscript=none then
			PostScript = '';							-- no postscript
		end
	end

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories.
	if not is_set(no_tracking_cats) then				-- ignore if we are already not going to categorize this page
		for k, v in pairs( cfg.uncategorized_namespaces ) do	-- otherwise, spin through the list of namespaces we don't include in error categories
			if this_page.nsText == v then				-- if we find one
				no_tracking_cats = &quot;true&quot;;				-- set no_tracking_cats
				break;									-- and we're done
			end
		end
	end

-- check for extra |page=, |pages= or |at= parameters. 
	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Page = Page .. &quot; &quot; .. seterror('extra_pages');	-- add error message
			Pages = '';										-- unset the others
			At = '';
		end
	elseif is_set(Pages) then
		if is_set(At) then
			Pages = Pages .. &quot; &quot; .. seterror('extra_pages');	-- add error messages
			At = '';											-- unset
		end
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped

All other combinations of |encyclopedia, |title, and |article are not modified
]]
	if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
		if is_set(Periodical) then					-- Periodical is set when |encyclopedia is set
			if is_set(Title) then
				if not is_set(Chapter) then
					Chapter = Title;				-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					TransChapter = TransTitle;
					Title = Periodical;
					Periodical = '';				-- redundant so unset
					TransTitle = '';				-- redundant so unset
				end
			else									-- |title not set
				Title = Periodical;					-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';					-- redundant so unset
			end
		end
	end

--special cases for citation.
	if (config.CitationClass == &quot;citation&quot;) then		-- for citation templates
		if not is_set (Ref) then						-- if |ref= is not set
			Ref = &quot;harv&quot;;								-- set default |ref=harv
		end
		if not is_set (sepc) then						-- if |separator= is not set
			sepc = ',';									-- set citation separator to its default (comma)
		end
	else												-- not a citation template
		if not is_set (sepc) then						-- if |separator= has not been set
			sepc = '.';									-- set cite xxx separator to its default (period)
		end
	end

-- check for special case where |separator=none
	if 'none' == sepc:lower() then						-- if |separator=none
		sepc = '';										-- then set it to an empty string
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then	-- special case for cite techreport
		if is_set(Issue) then						-- cite techreport uses 'number', which other citations aliase to 'issue'
			if not is_set(ID) then					-- can we use ID for the &quot;number&quot;?
				ID = Issue;							-- yes, use it
				Issue = &quot;&quot;;							-- unset Issue so that &quot;number&quot; isn't duplicated in the rendered citation or COinS metadata
			else									-- can't use ID so emit error message
				ID = ID .. &quot; &quot; .. seterror('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Interviewer) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Interviewer;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Interviewer;
			end
			if is_set(Cointerviewers) then
				Others = Others .. sepc .. ' ' .. Cointerviewers;
			end
		else
			Others = '(Interview)';
		end
	end

--Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set
	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_embargoed(Embargo) then
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];	-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];		-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
--TODO: if this is only for {{cite conference}}, shouldn't we be checking? (if config.CitationClass=='conference' then ...)
	if is_set(BookTitle) then
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = BookTitle;
		TitleLink = '';
		TransTitle = '';
	end

-- Account for the oddity that is {{cite episode}}, before generation of COinS data.
--[[	-- {{cite episode}} is not currently supported by this module
	if config.CitationClass == &quot;episode&quot; then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];
		local Season = A['Season'];
		local SeriesNumber = A['SeriesNumber'];
		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
		local Sep = (first_set(A[&quot;SeriesSeparator&quot;], A[&quot;Separator&quot;]) or &quot;&quot;) .. &quot; &quot;;
		
		if is_set(Issue) then table.insert(s, cfg.messages[&quot;episode&quot;] .. &quot; &quot; .. Issue); Issue = ''; end
		if is_set(Season) then table.insert(s, cfg.messages[&quot;season&quot;] .. &quot; &quot; .. Season); end
		if is_set(SeriesNumber) then table.insert(s, cfg.messages[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber); end
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		
		Date = Date or AirDate;
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = Series;
		TitleLink = SeriesLink;
		TransTitle = '';
		
		Series = table.concat(s, Sep);
		ID = table.concat(n, Sep);
	end
-- end of {{cite episode}} stuff]]

-- legacy: promote concatenation of |day=, |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set(Date) then
		Date = Year;						-- promote Year to Date
		Year = nil;							-- make nil so Year as empty string isn't used for CITEREF
		if is_set(Date) then
			local Month = A['Month'];
			if is_set(Month) then
				Date = Month .. &quot; &quot; .. Date;
				local Day = A['Day']
				if is_set(Day) then Date = Day .. &quot; &quot; .. Date end
			end
		elseif is_set(PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;			-- promote PublicationDate to Date
			PublicationDate = '';			-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end	-- if PublicationDate is same as Date, don't display in rendered citation


--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	anchor_year, COinS_date, error_message = dates({['accessdate']=AccessDate, ['airdate']=AirDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
		['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});
	if is_set(error_message) then
		table.insert( z.message_tail, { seterror( 'bad_date', {error_message}, true ) } );	-- add this error message
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for
	-- automated parsing of citation information.
	local OCinSoutput = COinS{
		['Periodical'] = Periodical,
		['Chapter'] = Chapter,
		['Title'] = Title,
		['PublicationPlace'] = PublicationPlace,
		['Date'] = first_set(COinS_date, Date),		-- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here?  Should we be including invalid dates in metadata?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
--		['Pages'] = get_coins_pages (first_set(Page, Pages, At)),	-- pages stripped of external links
		['Pages'] = first_set(Page, Pages, At),
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set( URL, ChapterURL ),
		['Authors'] = a,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	};

	if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = '';
		TitleLink = '';
		TransTitle = '';
	end
--[[ Hide unfinished cite newsgroup code so that long delayed update can take place
-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername and ID
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = '[Newsgroup]:&amp;nbsp;' ..  externallink( 'news:' .. PublisherName, PublisherName );
		end
	end
]]


	-- Now perform various field 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 not is_set(Authors) then
		local Maximum = tonumber( A['DisplayAuthors'] );
		
		-- Preserve old-style implicit et al.
		if not is_set(Maximum) and #a == 9 then 
			Maximum = 8;
			table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
		elseif not is_set(Maximum) then
			Maximum = #a + 1;
		end
			
		local control = { 
			sep = A[&quot;AuthorSeparator&quot;] .. &quot; &quot;,
			namesep = (first_set(A[&quot;AuthorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
			format = A[&quot;AuthorFormat&quot;],
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp
		};
		
		-- If the coauthor field is also used, prevent ampersand and et al. formatting.
		if is_set(Coauthors) then
			control.lastauthoramp = nil;
			control.maximum = #a + 1;
		end
		
		Authors = listpeople(control, a) 
	end

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { seterror('coauthors_missing_author', {}, true) } );	-- emit error message
	end

	local EditorCount
	if not is_set(Editors) then
		local Maximum = tonumber( A['DisplayEditors'] );
		-- Preserve old-style implicit et al.
		if not is_set(Maximum) and #e == 4 then 
			Maximum = 3;
			table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
		elseif not is_set(Maximum) then
			Maximum = #e + 1;
		end

		local control = { 
			sep = A[&quot;EditorSeparator&quot;] .. &quot; &quot;,
			namesep = (first_set(A[&quot;EditorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
			format = A['EditorFormat'],
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp
		};

		Editors, EditorCount = listpeople(control, e);
	else
		EditorCount = 1;
	end

	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	if config.CitationClass == &quot;map&quot; then
		if not is_set( Authors ) and is_set( PublisherName ) then
			Authors = PublisherName;
			PublisherName = &quot;&quot;;
		end
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap( 'cartography', Cartography, use_lowercase );
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end		
	end
	
	if  not is_set(URL) and
		not is_set(ChapterURL) and
		not is_set(ArchiveURL) and
		not is_set(ConferenceURL) and
		not is_set(TranscriptURL) then
		
		-- Test if cite web or cite podcast |url= is missing or empty 
		if inArray(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;}) then	
			table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
		end
		
		-- Test if accessdate is given without giving a URL
		if is_set(AccessDate) then
			table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
		
		-- Test if format is given without giving a URL
		if is_set(Format) then
			Format = Format .. seterror( 'format_missing_url' );
		end
	end
	
	-- Test if citation has no title
	if  not is_set(Chapter) and
		not is_set(Title) and
		not is_set(Periodical) and
		not is_set(Conference) and
		not is_set(TransTitle) and
		not is_set(TransChapter) then
		table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
	end
	
	Format = is_set(Format) and &quot; (&quot; .. Format .. &quot;)&quot; or &quot;&quot;;
	
	local OriginalURL = URL
	DeadURL = DeadURL:lower();
	if is_set( ArchiveURL ) then
		if ( DeadURL ~= &quot;no&quot; ) then
			URL = ArchiveURL
			URLorigin = A:ORIGIN('ArchiveURL')
		end
	end
	
	-- Format chapter / article title
	if is_set(Chapter) and is_set(ChapterLink) then 
		Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot;;
	end
	if is_set(Periodical) and is_set(Title) then
		Chapter = wrap( 'italic-title', Chapter );
		TransChapter = wrap( 'trans-italic-title', TransChapter );
	else
		Chapter = kern_quotes (Chapter);				-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
		Chapter = wrap( 'quoted-title', Chapter );
		TransChapter = wrap( 'trans-quoted-title', TransChapter );
	end
	
	local TransError = &quot;&quot;
	if is_set(TransChapter) then
		if not is_set(Chapter) then
			TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
		else
			TransChapter = &quot; &quot; .. TransChapter;
		end
	end
	
	Chapter = Chapter .. TransChapter;
	
	if is_set(Chapter) then
		if not is_set(ChapterLink) then
			if is_set(ChapterURL) then
				Chapter = externallink( ChapterURL, Chapter ) .. TransError;
				if not is_set(URL) then
					Chapter = Chapter .. Format;
					Format = &quot;&quot;;
				end
			elseif is_set(URL) then 
				Chapter = externallink( URL, Chapter ) .. TransError .. Format;
				URL = &quot;&quot;;
				Format = &quot;&quot;;
			else
				Chapter = Chapter .. TransError;
			end			
		elseif is_set(ChapterURL) then
			Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. 
				TransError;
		else
			Chapter = Chapter .. TransError;
		end
		Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
	elseif is_set(ChapterURL) then
		Chapter = &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. sepc .. &quot; &quot;;
	end		
	
	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end
	
	if is_set(Periodical) then
		Title = kern_quotes (Title);				-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
		Title = wrap( 'quoted-title', Title );
		TransTitle = wrap( 'trans-quoted-title', TransTitle );
--[[ Hide unfinished cite newsgroup code so that long delayed update can take place
	elseif inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;pressrelease&quot;,&quot;conference&quot;,&quot;podcast&quot;,&quot;newsgroup&quot;}) and
]]	elseif inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;pressrelease&quot;,&quot;conference&quot;,&quot;podcast&quot;}) and
			not is_set(Chapter) then
		Title = kern_quotes (Title);				-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
		Title = wrap( 'quoted-title', Title );
		TransTitle = wrap( 'trans-quoted-title', TransTitle );
	else
		Title = wrap( 'italic-title', Title );
		TransTitle = wrap( 'trans-italic-title', TransTitle );
	end
	
	TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if not is_set(Title) then
			TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
		else
			TransTitle = &quot; &quot; .. TransTitle;
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then 
			Title = externallink( URL, Title ) .. TransError .. Format	   
			URL = &quot;&quot;;
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end
	
	if is_set(Place) then
		Place = &quot; &quot; .. wrap( 'written', Place, use_lowercase ) .. sepc .. &quot; &quot;;
	end
	
	if is_set(Conference) then
		if is_set(ConferenceURL) then
			Conference = externallink( ConferenceURL, Conference );
		end
		Conference = sepc .. &quot; &quot; .. Conference
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. externallink( ConferenceURL, nil, ConferenceURLorigin );
	end
	
	if not is_set(Position) then
		local Minutes = A['Minutes'];
		if is_set(Minutes) then
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			local Time = A['Time'];
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end
	
	if not is_set(Page) then
		if is_set(Pages) then
			if is_set(Periodical) and
				not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
				Pages = &quot;: &quot; .. Pages;
			elseif tonumber(Pages) ~= nil then
				Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
			else
				Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
			end
		end
	else
		if is_set(Periodical) and
			not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
			Page = &quot;: &quot; .. Page;
		else
			Page = sepc ..&quot; &quot; .. PPrefix .. Page;
		end
	end
	
	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Inset = A['Inset'];
		if first_set( Pages, Page, At ) ~= nil or sepc ~= '.' then
			if is_set( Section ) then
				Section = &quot;, &quot; .. wrap( 'section', Section, true );
			end
			if is_set( Inset ) then
				Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
			end
		else
			if is_set( Section ) then
				Section = sepc .. &quot; &quot; .. wrap( 'section', Section, use_lowercase );
				if is_set( Inset ) then
					Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
				end
			elseif is_set( Inset ) then
				Inset = sepc .. &quot; &quot; .. wrap( 'inset', Inset, use_lowercase );
			end			
		end			
		At = At .. Section .. Inset;		
	end	

	--[[Look in the list of iso639-1 language codes to see if the value provided in the language parameter matches one of them.  If a match is found, 
	use that value; if not, then use the value that was provided with the language parameter.
	
	Categories are assigned in a manner similar to the {{xx icon}} templates - categorizes only mainspace citations and only when the language code is not 'en' (English).
	]]
	if is_set (Language) then
--		local name = mw.language.fetchLanguageName( Language:lower(), &quot;en&quot; );	-- experiment: this seems to return correct ISO 639-1 language names
		local name = cfg.iso639_1[Language:lower()];		-- get the language name if Language parameter has a valid iso 639-1 code
		if nil == name then
			Language=&quot; &quot; .. wrap( 'language', Language );	-- no match, use parameter's value
		else
			if 0 == this_page.namespace and 'en' ~= Language:lower() then	--found a match; is this page main / article space and English not the language?
				Language=&quot; &quot; .. wrap( 'language', name .. '[[Category:Articles with ' .. name .. '-language external links]]' );	-- in main space and not English: categorize
			else
				Language=&quot; &quot; .. wrap( 'language', name );	--not in mainspace or language is English so don't categorize
			end
		end
	else
		Language=&quot;&quot;;	-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;

-- handle type parameter for those CS1 citations that have default values

	if inArray(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then	-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then					-- if type parameter is specified
		TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot;;	-- display it in parentheses
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	Edition = is_set(Edition) and (&quot; &quot; .. wrap( 'edition', Edition )) or &quot;&quot;;
	Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc ..&quot; &quot; .. Volume;
		  else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
		end
	end

--[[ This code commented out while discussion continues until after week of 2014-03-23 live module update;
	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc .. &quot; &quot; .. Volume;
		  else
			  Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
			  if is_set(Series) then Volume = sepc .. Volume;
			  end
		end
	end
]]	
	------------------------------------ totally unrelated data
	--[[ Loosely mimic {{subscription required}} template; Via parameter identifies a delivery source that is not the publisher; these sources often, but not always, exist
	behind a registration or paywall.  So here, we've chosen to decouple via from subscription (via has never been part of the registration required template).
	
	Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link note is displayed. There are no error messages for this condition.
	]]
	if is_set(Via) then
		Via = &quot; &quot; .. wrap( 'via', Via );
	end

	if is_set(SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription']; --here when 'via' parameter not used but 'subscription' is
	elseif is_set(RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration']; --here when 'via' and 'subscription' parameters not used but 'registration' is
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
		AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
			.. substitute( retrv_text, {AccessDate} ) .. '&lt;/span&gt;'
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end

	
	ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo} );

	if is_set(URL) then
		URL = &quot; &quot; .. externallink( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
			Quote = Quote:sub(2,-2);
		end
		Quote = sepc ..&quot; &quot; .. wrap( 'quoted-text', Quote ); 
		PostScript = &quot;&quot;;							-- CS1 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = seterror('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ externallink( ArchiveURL, arch_text ), ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text,
				{ externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ seterror('archive_missing_url'), ArchiveDate } );
		end
	else
		Archived = &quot;&quot;
	end
	
	local Lay
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
		end			
	else
		Lay = &quot;&quot;;
	end
	
	if is_set(Transcript) then
		if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
	elseif is_set(TranscriptURL) then
		Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
	end
	
	local Publisher;
	if is_set(Periodical) and
		not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap( 'published', PublicationDate );
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap( 'published', PublicationDate ) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap( 'italic-title', Periodical ) 
		else 
			Periodical = wrap( 'italic-title', Periodical )
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon
	if inArray(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, 
			Language, Cartography, Edition, Publisher, Agency, Volume, Issue}, sepc );
	else 
		tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, Language, 
			Volume, Issue, Others, Cartography, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Page .. Pages .. At;
	
	if is_set(Authors) then
		if is_set(Coauthors) then
			Authors = Authors .. A['AuthorSeparator'] .. &quot; &quot; .. Coauthors
		end
		if is_set(Date) then
			Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		elseif string.sub(Authors,-1,-1) == sepc then
			Authors = Authors .. &quot; &quot;
		else
			Authors = Authors .. sepc .. &quot; &quot;
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			if (sepc ~= '.') then in_text = in_text:lower() end
			Editors = in_text .. Editors .. post_text;
			if (string.sub(Editors,-1,-1) == sepc)
				then Editors = Editors .. &quot; &quot;
				else Editors = Editors .. sepc .. &quot; &quot;
			end
		end
		text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
		text = safejoin( {text, pgtext, idcommon}, sepc );
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
		text = safejoin( {text, pgtext, idcommon}, sepc );
	else
		if is_set(Date) then
			if ( string.sub(tcommon,-1,-1) ~= sepc )
			  then Date = sepc ..&quot; &quot; .. Date .. OrigYear
			  else Date = &quot; &quot; .. Date .. OrigYear
			end
		end
		if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
			text = safejoin( {Chapter, Place, tcommon}, sepc );
			text = safejoin( {text, pgtext, Date, idcommon}, sepc );
		else
			text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
			text = safejoin( {text, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
--		text = text:sub(1,-2);	--Remove final separator (assumes that sepc is only one character)
	end	
	
	text = safejoin( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;span/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = &quot;citation &quot; .. config.CitationClass;
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
		local id = Ref
		if ( &quot;harv&quot; == Ref ) then
			local names = {} --table of last names &amp; year
			if #a &gt; 0 then
				for i,v in ipairs(a) do 
					names[i] = v.last 
					if i == 4 then break end
				end
			elseif #e &gt; 0 then
				for i,v in ipairs(e) do 
					names[i] = v.last 
					if i == 4 then break end				
				end
			end
			names[ #names + 1 ] = first_set(Year, anchor_year);	-- Year first for legacy citations
			id = anchorid(names)
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = seterror('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then 
		text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	else
		text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	end		

	local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
	
	-- Note: Using display: none on then COinS span breaks some clients.
	local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
	text = text .. OCinS;
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. errorcomment( v[1], v[2] );
				else
					text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if inArray(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
	local pframe = frame:getParent()
	
	if nil ~= string.find( frame:getTitle(), 'sandbox', 1, true ) then				-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData( 'Module:Citation/CS1/Configuration/sandbox' );	-- load sandbox versions of Configuration and Whitelist and ...
		whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist/sandbox' );
		dates = require('Module:Citation/CS1/Date_validation/sandbox').dates	-- ... sandbox version of date validation code
	else																	-- otherwise
		cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );			-- load live versions of Configuration and Whitelist and ...
		whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );
		dates = require('Module:Citation/CS1/Date_validation').dates		-- ... live version of date validation code
	end
	
	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = seterror( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if #suggestions == 0 then
						suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
					end
					if suggestions[ k:lower() ] ~= nil then
						error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
					else
						error_text, error_state = seterror( 'parameter_ignored', {k}, true );
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	
	
	return citation0( config, args)
end

return z</text>
      <sha1>bgzq74a6qkouh35p8t2mogcsn7lkm2i</sha1>
    </revision>
    <revision>
      <id>4675</id>
      <parentid>4674</parentid>
      <timestamp>2014-08-24T16:08:43Z</timestamp>
      <contributor>
        <username>Redrose64</username>
        <id>813</id>
      </contributor>
      <comment>Undid revision 622602243 by [[Special:Contributions/Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) breaks harv linking for editors - see [[Help talk:CS1 errors#CITEREF and the editor parameter]]</comment>
      <origin>4675</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="83070" sha1="lo6xwe0knz7xynvby9rsvvyhw76rrl2" xml:space="preserve">local z = {
    error_categories = {};
    error_ids = {};
    message_tail = {};
}

-- Include translation message hooks, ID and error handling configuration settings.
--local cfg = mw.loadData( 'Module:Citation/CS1/Configuration/sandbox' );

-- Contains a list of all recognized parameters
--local whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist/sandbox' );

--local dates = require('Module:Citation/CS1/Date_validation/sandbox').dates		-- location of date validation code

-- Whether variable is set or not
function is_set( var )
    return not (var == nil or var == '');
end

-- First set variable or nil if none
function first_set(...)
    local list = {...};
    for _, var in pairs(list) do
        if is_set( var ) then
            return var;
        end
    end
end

-- Whether needle is in haystack
function inArray( needle, haystack )
    if needle == nil then
        return false;
    end
    for n,v in ipairs( haystack ) do
        if v == needle then
            return n;
        end
    end
    return false;
end

--[[
Categorize and emit an error message when the citation contains one or more deprecated parameters.  Because deprecated parameters (currently |day=, |month=,
|coauthor=, and |coauthors=) aren't related to each other and because these parameters may be concatenated into the variables used by |date= and |author#= (and aliases)
details of which parameter caused the error message are not provided.  Only one error message is emitted regarless of the number of deprecated parameters in the citation.
]]
function deprecated_parameter()
	if true ~= Page_in_deprecated_cat then	-- if we haven't been here before then set a 
		Page_in_deprecated_cat=true;		-- sticky flag so that if there are more than one deprecated parameter the category is added only once
--		table.insert( z.message_tail, { seterror( 'deprecated_params', {error_message}, true ) } );		-- add error message
		table.insert( z.message_tail, { seterror( 'deprecated_params', {}, true ) } );		-- add error message
	end
end

-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
--	return args and tostring( mw.message.newRawMessage( msg, args ) ) or msg;
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[
Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern  either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
]]
function kern_quotes (str)
	local left='&lt;span style=&quot;padding-left:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains leading single or double quote mark
	local right='&lt;span style=&quot;padding-right:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains trailing single or double quote mark
	
	if  str:match (&quot;^[\&quot;\'][^\']&quot;) then
		str = string.gsub( str, &quot;^[\&quot;\']&quot;, left, 1 );				-- replace (captured) leading single or double quote with left-side &lt;span&gt;
	end
	if str:match (&quot;[^\'][\&quot;\']$&quot;) then
		str = string.gsub( str, &quot;[\&quot;\']$&quot;, right, 1 );			-- replace (captured) trailing single or double quote with right-side &lt;span&gt;
	end
	return str;
end

-- Wraps a string using a message_list configuration taking one argument
function wrap( key, str, lower )
    if not is_set( str ) then
        return &quot;&quot;;
    elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
        str = safeforitalics( str );
    end
    if lower == true then
        return substitute( cfg.messages[key]:lower(), {str} );
    else
        return substitute( cfg.messages[key], {str} );
    end        
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
    local origin = {};
    
    return setmetatable({
        ORIGIN = function( self, k )
            local dummy = self[k]; --force the variable to be loaded.
            return origin[k];
        end
    },
    {
        __index = function ( tbl, k )
            if origin[k] ~= nil then
                return nil;
            end
            
            local args, list, v = args, cfg.aliases[k];
            
            if type( list ) == 'table' then
                v, origin[k] = selectone( args, list, 'redundant_parameters' );
                if origin[k] == nil then
                    origin[k] = ''; -- Empty string, not nil
                end
            elseif list ~= nil then
                v, origin[k] = args[list], list;
            else
                -- maybe let through instead of raising an error?
                -- v, origin[k] = args[k], k;
                error( cfg.messages['unknown_argument_map'] );
            end
            
            -- Empty strings, not nil;
            if v == nil then
                v = cfg.defaults[k] or '';
                origin[k] = '';
            end
            
            tbl = rawset( tbl, k, v );
            return v;
        end,
    });
end

--[[
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
]]
function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
    return wrap( hidden and 'hidden-error' or 'visible-error', content );
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
    local error_state = cfg.error_conditions[ error_id ];
    
    prefix = prefix or &quot;&quot;;
    suffix = suffix or &quot;&quot;;
    
    if error_state == nil then
        error( cfg.messages['undefined_error'] );
    elseif is_set( error_state.category ) then
        table.insert( z.error_categories, error_state.category );
    end
    
    local message = substitute( error_state.message, arguments );
    
    message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
        &quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
        cfg.messages['help page label'] .. &quot;]])&quot;;
    
    z.error_ids[ error_id ] = true;
    if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
            and z.error_ids['citation_missing_title'] then
        return '', false;
    end
    
    message = table.concat({ prefix, message, suffix });
    
    if raw == true then
        return message, error_state.hidden;
    end        
        
    return errorcomment( message, error_state.hidden );
end

-- Formats a wiki style external link
function externallinkid(options)
    local url_string = options.id;
    if options.encode == true or options.encode == nil then
        url_string = mw.uri.encode( url_string );
    end
    return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, url_string, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Formats a wiki style internal link
function internallinkid(options)
    return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
        options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
        options.prefix, options.id, options.suffix or &quot;&quot;,
        mw.text.nowiki(options.id)
    );
end

-- Format an external link with error checking
function externallink( URL, label, source )
    local error_str = &quot;&quot;;
    if not is_set( label ) then
        label = URL;
        if is_set( source ) then
            error_str = seterror( 'bare_url_missing_title', { wrap( 'parameter', source ) }, false, &quot; &quot; );
        else
            error( cfg.messages[&quot;bare_url_no_origin&quot;] );
        end            
    end
    if not checkurl( URL ) then
        error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
    end
    return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safeforurl( label ), &quot;]&quot;, error_str });
end

-- Formats a link to Amazon
function amazon(id, domain)
    if not is_set(domain) then 
        domain = &quot;com&quot;
    elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
        domain = &quot;co.&quot; .. domain
    end
    local handler = cfg.id_handlers['ASIN'];
    return externallinkid({link = handler.link,
        label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
        encode=handler.encode, separator = handler.separator})
end

--[[
Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of the LCCN dictates the character type of the first 1-3 characters; the
rightmost eight are always digits. http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is alpha
length = 10 then lccn[1] and lccn[2] are both alpha or both digits
length = 11 then lccn[1] is alpha, lccn[2] and lccn[3] are both alpha or both digits
length = 12 then lccn[1] and lccn[2] are both alpha

]]
function lccn(id)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid

	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%a%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%a%a%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%a%a%a%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%a%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%a%a%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. seterror( 'bad_lccn' );		-- wrong length, set an error message
	end

	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]
function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmid' );	-- set an error message
		end
	end
	
	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns true; otherwse, returns false because the embargo has expired or |embargo= not set in this cite.
]]
function is_embargoed(embargo)
	if is_set(embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 and tonumber( embargo_date ) &gt;= tonumber( todays_date ) then	--is embargo date is in the future?
			return true;	-- still embargoed
		end
	end
	return false;			-- embargo expired or |embargo= not set
end

--[[
Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future
the PMC identifier will not be linked to the article.  If the embargo specifies a date in the past, or if it is empty or omitted, then
the PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.
]]
function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
    
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_embargoed(embargo) then
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	--still embargoed so no external link
	else
		text = externallinkid({link = handler.link, label = handler.label,			--no embargo date, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.

-- DOI names contain two parts: prefix and suffix separated by a forward slash.
--  Prefix: directory indicator '10.' followed by a registrant code
--  Suffix: character string of any length chosen by the registrant

-- This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes,
-- or, if it ends with a period or a comma, this function will emit a bad_doi error message.

-- DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
-- and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely if ever used in doi names.

function doi(id, inactive)
    local cat = &quot;&quot;
    local handler = cfg.id_handlers['DOI'];
    
    local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. seterror( 'bad_doi' );
	end
	return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
    local code = id:sub(-1,-1)
    local handler = cfg.id_handlers['OL'];
    if ( code == &quot;A&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;M&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    elseif ( code == &quot;W&quot; ) then
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode})
    else
        return externallinkid({link=handler.link, label=handler.label,
            prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
            encode = handler.encode}) .. 
            ' ' .. seterror( 'bad_ol' );
    end
end

--[[
Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.
]]
function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and ndashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 didgits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = externallinkid({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. seterror( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[
This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those citations that have defaults.
Also handles the special case where it is desireable to omit the title type from the rendered citation (|type=none).
]]
function set_titletype(cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;					-- if |type=none then type parameter not displayed
		end
		return title_type;						-- if |type= has been set to any other value use that value
	end

	if &quot;AV media notes&quot; == cite_class or &quot;DVD notes&quot; == cite_class then		-- if this citation is cite AV media notes or cite DVD notes
		return &quot;Media notes&quot;;					-- display AV media notes / DVD media notes annotation

	elseif &quot;podcast&quot; == cite_class then			-- if this citation is cite podcast
		return &quot;Podcast&quot;;						-- display podcast annotation

	elseif &quot;pressrelease&quot; == cite_class then	-- if this citation is cite press release
		return &quot;Press release&quot;;					-- display press release annotation

	elseif &quot;techreport&quot; == cite_class then		-- if this citation is cite techreport
		return &quot;Technical report&quot;;				-- display techreport annotation
	
	elseif &quot;thesis&quot; == cite_class then			-- if this citation is cite thesis (degree option handled after this function returns)
			return &quot;Thesis&quot;;					-- display simple thesis annotation (without |degree= modification)
	end
end

--[[
Determines whether a URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
    -- Protocol-relative or URL scheme
    return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
    return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

-- Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.
function get_coins_pages (pages)
	if not is_set (pages) then return pages; end			-- if no page numbers then we're done
	
    while true do
		pattern = pages:match(&quot;%[([%w/:\.]+%s+)[%w%d].*%]&quot;);	-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end					-- no more urls
		pages = pages:gsub(pattern, &quot;&quot;);					-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);						-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end

--[[
ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in checkisbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.
]]
function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of bytes
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end	-- isbn13 begins with 978 or 979
		isbn_str = { isbn_str:byte(1, len) };
		for i, v in ipairs( isbn_str ) do
			temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
		end
		return temp % 10 == 0;
	end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
    return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
        return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
    end));
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
    if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
        table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
    end
    
    return str:gsub( '[%[%]\n]', {    
        ['['] = '&amp;#91;',
        [']'] = '&amp;#93;',
        ['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
    if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
        return str;
    end    
    return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
    --[[ Note: We can not use &lt;i&gt; for italics, as the expected behavior for
    italics specified by ''...'' in the title is that they will be inverted
    (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
    tend to interact poorly under Mediawiki's HTML tidy. ]]
    
    if not is_set(str) then
        return str;
    else
        if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
        if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
        
        -- Remove newlines as they break italics.
        return str:gsub( '\n', ' ' );
    end
end

--[[
Joins a sequence of strings together while checking for duplicate separation
characters.
]]
function safejoin( tbl, duplicate_char )
    --[[
    Note: we use string functions here, rather than ustring functions.
    
    This has considerably faster performance and should work correctly as 
    long as the duplicate_char is strict ASCII.  The strings
    in tbl may be ASCII or UTF8.
    ]]
    
    local str = '';
    local comp = '';
    local end_chr = '';
    local trim;
    for _, value in ipairs( tbl ) do
        if value == nil then value = ''; end
        
        if str == '' then
            str = value;
        elseif value ~= '' then
            if value:sub(1,1) == '&lt;' then
                -- Special case of values enclosed in spans and other markup.
                comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
            else
                comp = value;
            end
            
            if comp:sub(1,1) == duplicate_char then
                trim = false;
                end_chr = str:sub(-1,-1);
                -- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
                if end_chr == duplicate_char then
                    str = str:sub(1,-2);
                elseif end_chr == &quot;'&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
                        str = str:sub(1, -4) .. &quot;''&quot;;
                    elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
                        trim = true;
                    elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot;]&quot; then
                    if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
                        trim = true;
                    elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
                        trim = true;
                    end
                elseif end_chr == &quot; &quot; then
                    if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
                        str = str:sub(1,-3);
                    end
                end

                if trim then
                    if value ~= comp then 
                        local dup2 = duplicate_char;
                        if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
                        
                        value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
                    else
                        value = value:sub( 2, -1 );
                    end
                end
            end
            str = str .. value;
        end
    end
    return str;
end  

-- Attempts to convert names to initials.
function reducetoinitials(first)
    local initials = {}
    for word in string.gmatch(first, &quot;%S+&quot;) do
        table.insert(initials, string.sub(word,1,1)) -- Vancouver format does not include full stops.
    end
    return table.concat(initials) -- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
    local sep = control.sep;
    local namesep = control.namesep
    local format = control.format
    local maximum = control.maximum
    local lastauthoramp = control.lastauthoramp;
    local text = {}
    local etal = false;
    
    if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
    if maximum ~= nil and maximum &lt; 1 then return &quot;&quot;, 0; end
    
    for i,person in ipairs(people) do
        if is_set(person.last) then
            local mask = person.mask
            local one
            local sep_one = sep;
            if maximum ~= nil and i &gt; maximum then
                etal = true;
                break;
            elseif (mask ~= nil) then
                local n = tonumber(mask)
                if (n ~= nil) then
                    one = string.rep(&quot;&amp;mdash;&quot;,n)
                else
                    one = mask;
                    sep_one = &quot; &quot;;
                end
            else
                one = person.last
                local first = person.first
                if is_set(first) then 
                    if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
                    one = one .. namesep .. first 
                end
                if is_set(person.link) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
                if is_set(person.link) and nil ~= person.link:find(&quot;//&quot;) then one = one .. &quot; &quot; .. seterror( 'bad_authorlink' ) end	-- check for url in author link;
            end
            table.insert( text, one )
            table.insert( text, sep_one )
        end
    end

    local count = #text / 2;
    if count &gt; 0 then 
        if count &gt; 1 and is_set(lastauthoramp) and not etal then
            text[#text-2] = &quot; &amp; &quot;;
        end
        text[#text] = nil; 
    end
    
    local result = table.concat(text) -- construct list
    if etal then 
        local etal_text = cfg.messages['et al'];
        result = result .. &quot; &quot; .. etal_text;
    end
    
    -- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
    if ( &quot;scap&quot; == format ) then result = 
        '&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
    end 
    return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
    return &quot;CITEREF&quot; .. table.concat( options );
end

-- Gets name list from the input arguments
function extractnames(args, list_name)
    local names = {};
    local i = 1;
    local last;
    
    while true do
        last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );
        if not is_set(last) then
            -- just in case someone passed in an empty parameter
            break;
        end
        names[i] = {
            last = last,
            first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i ),
            link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ),
            mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i )
        };
        i = i + 1;
    end
    return names;
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
    local id_list = {};
    for k, v in pairs( cfg.id_handlers ) do    
        v = selectone( args, v.parameters, 'redundant_parameters' );
        if is_set(v) then id_list[k] = v; end
    end
    return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
    local new_list, handler = {};
    
    function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
    
    for k, v in pairs( id_list ) do
        -- fallback to read-only cfg
        handler = setmetatable( { ['id'] = v }, fallback(k) );
        
        if handler.mode == 'external' then
            table.insert( new_list, {handler.label, externallinkid( handler ) } );
        elseif handler.mode == 'internal' then
            table.insert( new_list, {handler.label, internallinkid( handler ) } );
        elseif handler.mode ~= 'manual' then
            error( cfg.messages['unknown_ID_mode'] );
        elseif k == 'DOI' then
            table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
        elseif k == 'ASIN' then
            table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
        elseif k == 'LCCN' then
            table.insert( new_list, {handler.label, lccn( v ) } );
        elseif k == 'OL' then
            table.insert( new_list, {handler.label, openlibrary( v ) } );
        elseif k == 'PMC' then
            table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
        elseif k == 'PMID' then
            table.insert( new_list, {handler.label, pmid( v ) } );
        elseif k == 'ISSN' then
        	table.insert( new_list, {handler.label, issn( v ) } );
        elseif k == 'ISBN' then
            local ISBN = internallinkid( handler );
            if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
                ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
            end
            table.insert( new_list, {handler.label, ISBN } );                
        else
            error( cfg.messages['unknown_manual_ID'] );
        end
    end
    
    function comp( a, b )	-- used in following table.sort()
        return a[1] &lt; b[1];
    end
    
    table.sort( new_list, comp );
    for k, v in ipairs( new_list ) do
        new_list[k] = v[2];
    end
    
    return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
    local value = nil;
    local selected = '';
    local error_list = {};
    
    if index ~= nil then index = tostring(index); end
    
    -- Handle special case of &quot;#&quot; replaced by empty string
    if index == '1' then
        for _, v in ipairs( possible ) do
            v = v:gsub( &quot;#&quot;, &quot;&quot; );
            if is_set(args[v]) then
                if value ~= nil and selected ~= v then
                    table.insert( error_list, v );
                else
                    value = args[v];
                    selected = v;
                end
            end
        end        
    end
    
    for _, v in ipairs( possible ) do
        if index ~= nil then
            v = v:gsub( &quot;#&quot;, index );
        end
        if is_set(args[v]) then
            if value ~= nil and selected ~=  v then
                table.insert( error_list, v );
            else
                value = args[v];
                selected = v;
            end
        end
    end
    
    if #error_list &gt; 0 then
        local error_str = &quot;&quot;;
        for _, k in ipairs( error_list ) do
            if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
            error_str = error_str .. wrap( 'parameter', k );
        end
        if #error_list &gt; 1 then
            error_str = error_str .. cfg.messages['parameter-final-separator'];
        else
            error_str = error_str .. cfg.messages['parameter-pair-separator'];
        end
        error_str = error_str .. wrap( 'parameter', selected );
        table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
    end
    
    return value, selected;
end

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
function COinS(data)
    if 'table' ~= type(data) or nil == next(data) then
        return '';
    end
    
    local ctx_ver = &quot;Z39.88-2004&quot;;
    
    -- treat table strictly as an array with only set values.
    local OCinSoutput = setmetatable( {}, {
        __newindex = function(self, key, value)
            if is_set(value) then
                rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
            end
        end
    });
    
    if is_set(data.Chapter) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Chapter;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    elseif is_set(data.Periodical) then
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
        OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
        OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
    else
        OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
        OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
        OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
    end
    
    OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
    OCinSoutput[&quot;rft.date&quot;] = data.Date;
    OCinSoutput[&quot;rft.series&quot;] = data.Series;
    OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
    OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
    OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
    OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
    OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
    
    for k, v in pairs( data.ID_list ) do
        local id, value = cfg.id_handlers[k].COinS;
        if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
        if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
            OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
        else
            OCinSoutput[ id ] = value;
        end
    end
    
    local last, first;
    for k, v in ipairs( data.Authors ) do
        last, first = v.last, v.first;
        if k == 1 then
            if is_set(last) then
                OCinSoutput[&quot;rft.aulast&quot;] = last;
            end
            if is_set(first) then 
                OCinSoutput[&quot;rft.aufirst&quot;] = first;
            end
        end
        if is_set(last) and is_set(first) then
            OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
        elseif is_set(last) then
            OCinSoutput[&quot;rft.au&quot;] = last;
        end
    end
    
    OCinSoutput.rft_id = data.URL;
    OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
    OCinSoutput = setmetatable( OCinSoutput, nil );
    
    -- sort with version string always first, and combine.
    table.sort( OCinSoutput );
    table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
    return table.concat(OCinSoutput, &quot;&amp;&quot;);
end

--[[
This is the main function doing the majority of the citation
formatting.
]]
function citation0( config, args)
    --[[ 
    Load Input Parameters
    The argment_wrapper facillitates the mapping of multiple
    aliases to single internal variable.
    ]]
    local A = argument_wrapper( args );

    local i 
    local PPrefix = A['PPrefix']
    local PPPrefix = A['PPPrefix']
    if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
    
    -- Pick out the relevant fields from the arguments.  Different citation templates
    -- define different field names for the same underlying things.    
    local Authors = A['Authors'];
    local a = extractnames( args, 'AuthorList' );

    local Coauthors = A['Coauthors'];
    local Others = A['Others'];
    local Editors = A['Editors'];
    local e = extractnames( args, 'EditorList' );

    local Year = A['Year'];
    local PublicationDate = A['PublicationDate'];
    local OrigYear = A['OrigYear'];
    local Date = A['Date'];
    local LayDate = A['LayDate'];
    ------------------------------------------------- Get title data
    local Title = A['Title'];
    local BookTitle = A['BookTitle'];
    local Conference = A['Conference'];
    local TransTitle = A['TransTitle'];
    local TitleNote = A['TitleNote'];
    local TitleLink = A['TitleLink'];
    local Chapter = A['Chapter'];
    local ChapterLink = A['ChapterLink'];
    local TransChapter = A['TransChapter'];
    local TitleType = A['TitleType'];
    local Degree = A['Degree'];
    local Docket = A['Docket'];
    local ArchiveURL = A['ArchiveURL'];
    local URL = A['URL']
    local URLorigin = A:ORIGIN('URL');
    local ChapterURL = A['ChapterURL'];
    local ChapterURLorigin = A:ORIGIN('ChapterURL');
    local ConferenceURL = A['ConferenceURL'];
    local ConferenceURLorigin = A:ORIGIN('ConferenceURL');
    local Periodical = A['Periodical'];

	local Series = A['Series'];
    local Volume = A['Volume'];
    local Issue = A['Issue'];
    local Position = '';
    local Page = A['Page'];
    local Pages = hyphentodash( A['Pages'] );	
    local At = A['At'];

    local Edition = A['Edition'];
    local PublicationPlace = A['PublicationPlace']
    local Place = A['Place'];
    
    local PublisherName = A['PublisherName'];
    local RegistrationRequired = A['RegistrationRequired'];
    local SubscriptionRequired = A['SubscriptionRequired'];
    local Via = A['Via'];
    local AccessDate = A['AccessDate'];
    local ArchiveDate = A['ArchiveDate'];
    local Agency = A['Agency'];
    local DeadURL = A['DeadURL']
    local Language = A['Language'];
    local Format = A['Format'];
    local Ref = A['Ref'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
    local ASINTLD = A['ASINTLD'];
    local IgnoreISBN = A['IgnoreISBN'];
    local Embargo = A['Embargo'];

    local ID_list = extractids( args );
    
    local Quote = A['Quote'];
    local PostScript = A['PostScript'];

    local LayURL = A['LayURL'];
    local LaySource = A['LaySource'];
    local Transcript = A['Transcript'];
    local TranscriptURL = A['TranscriptURL'] 
    local TranscriptURLorigin = A:ORIGIN('TranscriptURL');
    local sepc = A['Separator'];

    local LastAuthorAmp = A['LastAuthorAmp'];
    local no_tracking_cats = A['NoTracking'];

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Cointerviewers = A['Cointerviewers'];			-- deprecated
	local Interviewer = A['Interviewer'];				-- deprecated
	local Program = A['Program'];

--local variables that are not cs1 parameters
    local page_type;									-- is this needed?  Doesn't appear to be used anywhere;
    local use_lowercase = ( sepc ~= '.' );
    local this_page = mw.title.getCurrentTitle();		--Also used for COinS and for language
	local anchor_year;									-- used in the CITEREF identifier
	local COinS_date;									-- used in the COinS metadata

-- Set postscript default.
	if not is_set (PostScript) then						-- if |postscript= has not been set (Postscript is nil which is the default for {{citation}}) and
		if (config.CitationClass ~= &quot;citation&quot;) then	-- this template is not a citation template
			PostScript = '.';							-- must be a cite xxx template so set postscript to default (period)
		end
	else
		if PostScript:lower() == 'none' then			-- if |postscript=none then
			PostScript = '';							-- no postscript
		end
	end

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories.
	if not is_set(no_tracking_cats) then				-- ignore if we are already not going to categorize this page
		for k, v in pairs( cfg.uncategorized_namespaces ) do	-- otherwise, spin through the list of namespaces we don't include in error categories
			if this_page.nsText == v then				-- if we find one
				no_tracking_cats = &quot;true&quot;;				-- set no_trackin_cats
				break;									-- and we're done
            end
        end
    end

-- check for extra |page=, |pages= or |at= parameters. 
    if is_set(Page) then
        if is_set(Pages) or is_set(At) then
            Page = Page .. &quot; &quot; .. seterror('extra_pages');	-- add error message
            Pages = '';										-- unset the others
            At = '';
        end
    elseif is_set(Pages) then
        if is_set(At) then
            Pages = Pages .. &quot; &quot; .. seterror('extra_pages');	-- add error messages
            At = '';											-- unset
        end
    end    

-- both |publication-place= and |place= (|location=) allowed if different
    if not is_set(PublicationPlace) and is_set(Place) then
        PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
    end
    
    if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
    
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped

All other combinations of |encyclopedia, |title, and |article are not modified
]]
	if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
		if is_set(Periodical) then					-- Periodical is set when |encyclopedia is set
			if is_set(Title) then
				if not is_set(Chapter) then
					Chapter = Title;				-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					TransChapter = TransTitle;
					Title = Periodical;
					Periodical = '';				-- redundant so unset
					TransTitle = '';				-- redundant so unset
				end
			else									-- |title not set
				Title = Periodical;					-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';					-- redundant so unset
			end
		end
	end

--special cases for citation.
	if (config.CitationClass == &quot;citation&quot;) then		-- for citation templates
		if not is_set (Ref) then						-- if |ref= is not set
			Ref = &quot;harv&quot;;								-- set default |ref=harv
		end
		if not is_set (sepc) then						-- if |separator= is not set
			sepc = ',';									-- set citation separator to its default (comma)
		end
	else												-- not a citation template
		if not is_set (sepc) then						-- if |separator= has not been set
			sepc = '.';									-- set cite xxx separator to its default (period)
		end
	end

-- check for specital case where |separator=none
	if 'none' == sepc:lower() then						-- if |separator=none
		sepc = '';										-- then set it to a empty string
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then	-- special case for cite techreport
		if is_set(Issue) then						-- cite techreport uses 'number', which other citations aliase to 'issue'
			if not is_set(ID) then					-- can we use ID for the &quot;number&quot;?
				ID = Issue;							-- yes, use it
				Issue = &quot;&quot;;							-- unset Issue so that &quot;number&quot; isn't duplicated in the rendered citation or COinS metadata
			else									-- can't use ID so emit error message
				ID = ID .. &quot; &quot; .. seterror('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Interviewer) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Interviewer;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Interviewer;
			end
			if is_set(Cointerviewers) then
				Others = Others .. sepc .. ' ' .. Cointerviewers;
			end
		else
			Others = '(Interview)';
		end
	end

--Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set
	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_embargoed(Embargo) then
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];	-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];		-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
--TODO: if this is only for {{cite conference}}, shouldn't we be checking? (if config.CitationClass=='conference' then ...)
	if is_set(BookTitle) then
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = BookTitle;
		TitleLink = '';
		TransTitle = '';
	end

-- Account for the oddity that is {{cite episode}}, before generation of COinS data.
--[[	-- {{cite episode}} is not currently supported by this module
	if config.CitationClass == &quot;episode&quot; then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];
		local Season = A['Season'];
		local SeriesNumber = A['SeriesNumber'];
		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
		local Sep = (first_set(A[&quot;SeriesSeparator&quot;], A[&quot;Separator&quot;]) or &quot;&quot;) .. &quot; &quot;;
		
		if is_set(Issue) then table.insert(s, cfg.messages[&quot;episode&quot;] .. &quot; &quot; .. Issue); Issue = ''; end
		if is_set(Season) then table.insert(s, cfg.messages[&quot;season&quot;] .. &quot; &quot; .. Season); end
		if is_set(SeriesNumber) then table.insert(s, cfg.messages[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber); end
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		
		Date = Date or AirDate;
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = Series;
		TitleLink = SeriesLink;
		TransTitle = '';
		
		Series = table.concat(s, Sep);
		ID = table.concat(n, Sep);
	end
-- end of {{cite episode}} stuff]]

-- legacy: promote concatenation of |day=, |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set(Date) then
		Date = Year;						-- promote Year to Date
		Year = nil;							-- make nil so Year as empty string isn't used for CITEREF
		if is_set(Date) then
			local Month = A['Month'];
			if is_set(Month) then
				Date = Month .. &quot; &quot; .. Date;
				local Day = A['Day']
				if is_set(Day) then Date = Day .. &quot; &quot; .. Date end
			end
		elseif is_set(PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;			-- promonte PublicationDate to Date
			PublicationDate = '';			-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end	-- if PublicationDate is same as Date, don't display in rendered citation


--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	anchor_year, COinS_date, error_message = dates({['accessdate']=AccessDate, ['airdate']=AirDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
		['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});
	if is_set(error_message) then
		table.insert( z.message_tail, { seterror( 'bad_date', {error_message}, true ) } );	-- add this error message
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.

    -- COinS metadata (see &lt;http://ocoins.info/&gt;) for
    -- automated parsing of citation information.
    local OCinSoutput = COinS{
        ['Periodical'] = Periodical,
        ['Chapter'] = Chapter,
        ['Title'] = Title,
        ['PublicationPlace'] = PublicationPlace,
        ['Date'] = first_set(COinS_date, Date),		-- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here?  Should we be including invalid dates in metadata?
        ['Series'] = Series,
        ['Volume'] = Volume,
        ['Issue'] = Issue,
        ['Pages'] = get_coins_pages (first_set(Page, Pages, At)),	-- pages stripped of external links
        ['Edition'] = Edition,
        ['PublisherName'] = PublisherName,
        ['URL'] = first_set( URL, ChapterURL ),
        ['Authors'] = a,
        ['ID_list'] = ID_list,
        ['RawPage'] = this_page.prefixedText,
    };

    if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
        Chapter = Title;
        ChapterLink = TitleLink;
        TransChapter = TransTitle;
        Title = '';
        TitleLink = '';
        TransTitle = '';
    end

    -- Now perform various field 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 not is_set(Authors) then
        local Maximum = tonumber( A['DisplayAuthors'] );
        
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #a == 9 then 
            Maximum = 8;
            table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
        elseif not is_set(Maximum) then
            Maximum = #a + 1;
        end
            
        local control = { 
            sep = A[&quot;AuthorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;AuthorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A[&quot;AuthorFormat&quot;],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };
        
        -- If the coauthor field is also used, prevent ampersand and et al. formatting.
        if is_set(Coauthors) then
            control.lastauthoramp = nil;
            control.maximum = #a + 1;
        end
        
        Authors = listpeople(control, a) 
    end

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { seterror('coauthors_missing_author', {}, true) } );	-- emit error message
	end

    local EditorCount
    if not is_set(Editors) then
        local Maximum = tonumber( A['DisplayEditors'] );
        -- Preserve old-style implicit et al.
        if not is_set(Maximum) and #e == 4 then 
            Maximum = 3;
            table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
        elseif not is_set(Maximum) then
            Maximum = #e + 1;
        end

        local control = { 
            sep = A[&quot;EditorSeparator&quot;] .. &quot; &quot;,
            namesep = (first_set(A[&quot;EditorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
            format = A['EditorFormat'],
            maximum = Maximum,
            lastauthoramp = LastAuthorAmp
        };

        Editors, EditorCount = listpeople(control, e);
    else
        EditorCount = 1;
    end

    local Cartography = &quot;&quot;;
    local Scale = &quot;&quot;;
    if config.CitationClass == &quot;map&quot; then
        if not is_set( Authors ) and is_set( PublisherName ) then
            Authors = PublisherName;
            PublisherName = &quot;&quot;;
        end
        Cartography = A['Cartography'];
        if is_set( Cartography ) then
            Cartography = sepc .. &quot; &quot; .. wrap( 'cartography', Cartography, use_lowercase );
        end        
        Scale = A['Scale'];
        if is_set( Scale ) then
            Scale = sepc .. &quot; &quot; .. Scale;
        end        
    end
    
    if  not is_set(URL) and
        not is_set(ChapterURL) and
        not is_set(ArchiveURL) and
        not is_set(ConferenceURL) and
        not is_set(TranscriptURL) then
        
        -- Test if cite web or cite podcast |url= is missing or empty 
		if inArray(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;}) then	
			table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
		end
        
        -- Test if accessdate is given without giving a URL
        if is_set(AccessDate) then
            table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
            AccessDate = '';
        end
        
        -- Test if format is given without giving a URL
        if is_set(Format) then
            Format = Format .. seterror( 'format_missing_url' );
        end
    end
    
    -- Test if citation has no title
    if  not is_set(Chapter) and
        not is_set(Title) and
        not is_set(Periodical) and
        not is_set(Conference) and
        not is_set(TransTitle) and
        not is_set(TransChapter) then
        table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
    end
    
    Format = is_set(Format) and &quot; (&quot; .. Format .. &quot;)&quot; or &quot;&quot;;
    
    local OriginalURL = URL
    DeadURL = DeadURL:lower();
    if is_set( ArchiveURL ) then
        if ( DeadURL ~= &quot;no&quot; ) then
            URL = ArchiveURL
            URLorigin = A:ORIGIN('ArchiveURL')
        end
    end
    
    -- Format chapter / article title
    if is_set(Chapter) and is_set(ChapterLink) then 
        Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot;;
    end
    if is_set(Periodical) and is_set(Title) then
        Chapter = wrap( 'italic-title', Chapter );
        TransChapter = wrap( 'trans-italic-title', TransChapter );
    else
		Chapter = kern_quotes (Chapter);				-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
        Chapter = wrap( 'quoted-title', Chapter );
        TransChapter = wrap( 'trans-quoted-title', TransChapter );
    end
    
    local TransError = &quot;&quot;
    if is_set(TransChapter) then
        if not is_set(Chapter) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
        else
            TransChapter = &quot; &quot; .. TransChapter;
        end
    end
    
    Chapter = Chapter .. TransChapter;
    
    if is_set(Chapter) then
        if not is_set(ChapterLink) then
            if is_set(ChapterURL) then
                Chapter = externallink( ChapterURL, Chapter ) .. TransError;
                if not is_set(URL) then
                    Chapter = Chapter .. Format;
                    Format = &quot;&quot;;
                end
            elseif is_set(URL) then 
                Chapter = externallink( URL, Chapter ) .. TransError .. Format;
                URL = &quot;&quot;;
                Format = &quot;&quot;;
            else
                Chapter = Chapter .. TransError;
            end            
        elseif is_set(ChapterURL) then
            Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. 
                TransError;
        else
            Chapter = Chapter .. TransError;
        end
        Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
    elseif is_set(ChapterURL) then
        Chapter = &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. sepc .. &quot; &quot;;
    end        
    
    -- Format main title.
    if is_set(TitleLink) and is_set(Title) then
        Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
    end
    
    if is_set(Periodical) then
		Title = kern_quotes (Title);				-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    elseif inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;pressrelease&quot;,&quot;conference&quot;,&quot;podcast&quot;}) and
            not is_set(Chapter) then
		Title = kern_quotes (Title);				-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
        Title = wrap( 'quoted-title', Title );
        TransTitle = wrap( 'trans-quoted-title', TransTitle );
    else
        Title = wrap( 'italic-title', Title );
        TransTitle = wrap( 'trans-italic-title', TransTitle );
    end
    
    TransError = &quot;&quot;;
    if is_set(TransTitle) then
        if not is_set(Title) then
            TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
        else
            TransTitle = &quot; &quot; .. TransTitle;
        end
    end
    
    Title = Title .. TransTitle;
    
    if is_set(Title) then
        if not is_set(TitleLink) and is_set(URL) then 
            Title = externallink( URL, Title ) .. TransError .. Format       
            URL = &quot;&quot;;
            Format = &quot;&quot;;
        else
            Title = Title .. TransError;
        end
    end
    
    if is_set(Place) then
        Place = &quot; &quot; .. wrap( 'written', Place, use_lowercase ) .. sepc .. &quot; &quot;;
    end
    
    if is_set(Conference) then
        if is_set(ConferenceURL) then
            Conference = externallink( ConferenceURL, Conference );
        end
        Conference = sepc .. &quot; &quot; .. Conference
    elseif is_set(ConferenceURL) then
        Conference = sepc .. &quot; &quot; .. externallink( ConferenceURL, nil, ConferenceURLorigin );
    end
    
    if not is_set(Position) then
        local Minutes = A['Minutes'];
        if is_set(Minutes) then
            Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
        else
            local Time = A['Time'];
            if is_set(Time) then
                local TimeCaption = A['TimeCaption']
                if not is_set(TimeCaption) then
                    TimeCaption = cfg.messages['event'];
                    if sepc ~= '.' then
                        TimeCaption = TimeCaption:lower();
                    end
                end
                Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
            end
        end
    else
        Position = &quot; &quot; .. Position;
        At = '';
    end
    
    if not is_set(Page) then
        if is_set(Pages) then
            if is_set(Periodical) and
                not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
                Pages = &quot;: &quot; .. Pages;
            elseif tonumber(Pages) ~= nil then
                Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
            else
                Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
            end
        end
    else
        if is_set(Periodical) and
            not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
            Page = &quot;: &quot; .. Page;
        else
            Page = sepc ..&quot; &quot; .. PPrefix .. Page;
        end
    end
    
    At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
    Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
    if config.CitationClass == 'map' then
        local Section = A['Section'];
        local Inset = A['Inset'];
        if first_set( Pages, Page, At ) ~= nil or sepc ~= '.' then
            if is_set( Section ) then
                Section = &quot;, &quot; .. wrap( 'section', Section, true );
            end
            if is_set( Inset ) then
                Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
            end
        else
            if is_set( Section ) then
                Section = sepc .. &quot; &quot; .. wrap( 'section', Section, use_lowercase );
                if is_set( Inset ) then
                    Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
                end
            elseif is_set( Inset ) then
                Inset = sepc .. &quot; &quot; .. wrap( 'inset', Inset, use_lowercase );
            end            
        end            
        At = At .. Section .. Inset;        
    end    

	--[[Look in the list of iso639-1 language codes to see if the value provided in the language parameter matches one of them.  If a match is found, 
	use that value; if not, then use the value that was provided with the language parameter.
	
	Categories are assigned in a manner similar to the {{xx icon}} templates - categorizes only mainspace citations and only when the language code is not 'en' (English).
	]]
	if is_set (Language) then
--		local name = mw.language.fetchLanguageName( Language:lower(), &quot;en&quot; );	-- experiment: this seems to return correct ISO 639-1 language names
		local name = cfg.iso639_1[Language:lower()];		-- get the language name if Language parameter has a valid iso 639-1 code
		if nil == name then
			Language=&quot; &quot; .. wrap( 'language', Language );	-- no match, use parameter's value
		else
			if 0 == this_page.namespace and 'en' ~= Language:lower() then	--found a match; is this page main / article space and English not the language?
				Language=&quot; &quot; .. wrap( 'language', name .. '[[Category:Articles with ' .. name .. '-language external links]]' );	-- in main space and not English: categorize
			else
				Language=&quot; &quot; .. wrap( 'language', name );	--not in mainspace or language is English so don't categorize
			end
		end
	else
		Language=&quot;&quot;;	-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;

-- handle type parameter for those CS1 citations that have default values

	if inArray(config.CitationClass, {&quot;AV media notes&quot;, &quot;DVD notes&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then	-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then					-- if type parameter is specified
		TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot;;	-- display it in parentheses
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
    Edition = is_set(Edition) and (&quot; &quot; .. wrap( 'edition', Edition )) or &quot;&quot;;
    Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
    Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
    OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
    Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

    if is_set(Volume) then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc ..&quot; &quot; .. Volume;
          else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
        end
    end

--[[ This code commented out while discussion continues until after week of 2014-03-23 live module update;
    if is_set(Volume) then
        if ( mw.ustring.len(Volume) &gt; 4 )
          then Volume = sepc .. &quot; &quot; .. Volume;
          else
              Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
              if is_set(Series) then Volume = sepc .. Volume;
              end
        end
    end
]]    
    ------------------------------------ totally unrelated data
    --[[ Loosely mimic {{subscription required}} template; Via parameter identifies a delivery source that is not the publisher; these sources often, but not always, exist
    behind a registration or paywall.  So here, we've chosen to decouple via from subscription (via has never been part of the registration required template).
    
    Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link note is displayed. There are no error messages for this condition.
    ]]
    if is_set(Via) then
        Via = &quot; &quot; .. wrap( 'via', Via );
    end

	if is_set(SubscriptionRequired) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription']; --here when 'via' parameter not used but 'subscription' is
    elseif is_set(RegistrationRequired) then
        SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration']; --here when 'via' and 'subscription' parameters not used but 'registration' is
    end

    if is_set(AccessDate) then
        local retrv_text = &quot; &quot; .. cfg.messages['retrieved']
        if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
        AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
            .. substitute( retrv_text, {AccessDate} ) .. '&lt;/span&gt;'
    end
    
    if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end

    
    ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo} );

    if is_set(URL) then
        URL = &quot; &quot; .. externallink( URL, nil, URLorigin );
    end

    if is_set(Quote) then
        if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
            Quote = Quote:sub(2,-2);
        end
        Quote = sepc ..&quot; &quot; .. wrap( 'quoted-text', Quote ); 
        PostScript = &quot;&quot;;							-- CS1 does not supply terminal punctuation when |quote= is set
    end
    
    local Archived
    if is_set(ArchiveURL) then
        if not is_set(ArchiveDate) then
            ArchiveDate = seterror('archive_missing_date');
        end
        if &quot;no&quot; == DeadURL then
            local arch_text = cfg.messages['archived'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
                { externallink( ArchiveURL, arch_text ), ArchiveDate } );
            if not is_set(OriginalURL) then
                Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url');                               
            end
        elseif is_set(OriginalURL) then
            local arch_text = cfg.messages['archived-dead'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text,
                { externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
        else
            local arch_text = cfg.messages['archived-missing'];
            if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
            Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
                { seterror('archive_missing_url'), ArchiveDate } );
        end
    else
        Archived = &quot;&quot;
    end
    
    local Lay
    if is_set(LayURL) then
        if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
        if is_set(LaySource) then 
            LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot;;
        else
            LaySource = &quot;&quot;;
        end
        if sepc == '.' then
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
        else
            Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
        end            
    else
        Lay = &quot;&quot;;
    end
    
    if is_set(Transcript) then
        if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
    elseif is_set(TranscriptURL) then
        Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
    end
    
    local Publisher;
    if is_set(Periodical) and
        not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
            else
                Publisher = PublisherName;  
            end
        elseif is_set(PublicationPlace) then
            Publisher= PublicationPlace;
        else 
            Publisher = &quot;&quot;;
        end
        if is_set(PublicationDate) then
            if is_set(Publisher) then
                Publisher = Publisher .. &quot;, &quot; .. wrap( 'published', PublicationDate );
            else
                Publisher = PublicationDate;
            end
        end
        if is_set(Publisher) then
            Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
        end
    else
        if is_set(PublicationDate) then
            PublicationDate = &quot; (&quot; .. wrap( 'published', PublicationDate ) .. &quot;)&quot;;
        end
        if is_set(PublisherName) then
            if is_set(PublicationPlace) then
                Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
            else
                Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
            end            
        elseif is_set(PublicationPlace) then 
            Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
        else 
            Publisher = PublicationDate;
        end
    end
    
    -- Several of the above rely upon detecting this as nil, so do it last.
    if is_set(Periodical) then
        if is_set(Title) or is_set(TitleNote) then 
            Periodical = sepc .. &quot; &quot; .. wrap( 'italic-title', Periodical ) 
        else 
            Periodical = wrap( 'italic-title', Periodical )
        end
    end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

    -- Piece all bits together at last.  Here, all should be 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 tcommon
    if inArray(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
        if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
        tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, 
            Language, Cartography, Edition, Publisher, Agency, Volume, Issue}, sepc );
    else 
        tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, Language, 
            Volume, Issue, Others, Cartography, Edition, Publisher, Agency}, sepc );
    end
    
    if #ID_list &gt; 0 then
        ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
    else
        ID_list = ID;
    end
    
    local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
    local text;
    local pgtext = Position .. Page .. Pages .. At;
    
    if is_set(Authors) then
        if is_set(Coauthors) then
            Authors = Authors .. A['AuthorSeparator'] .. &quot; &quot; .. Coauthors
        end
        if is_set(Date) then
            Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        elseif string.sub(Authors,-1,-1) == sepc then
            Authors = Authors .. &quot; &quot;
        else
            Authors = Authors .. sepc .. &quot; &quot;
        end
        if is_set(Editors) then
            local in_text = &quot; &quot;;
            local post_text = &quot;&quot;;
            if is_set(Chapter) then
                in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
            else
                if EditorCount &lt;= 1 then
                    post_text = &quot;, &quot; .. cfg.messages['editor'];
                else
                    post_text = &quot;, &quot; .. cfg.messages['editors'];
                end
            end 
            if (sepc ~= '.') then in_text = in_text:lower() end
            Editors = in_text .. Editors .. post_text;
            if (string.sub(Editors,-1,-1) == sepc)
                then Editors = Editors .. &quot; &quot;
                else Editors = Editors .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    elseif is_set(Editors) then
        if is_set(Date) then
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
            else
                Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
            end
            Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
        else
            if EditorCount &lt;= 1 then
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            else
                Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
            end
        end
        text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
        text = safejoin( {text, pgtext, idcommon}, sepc );
    else
        if is_set(Date) then
            if ( string.sub(tcommon,-1,-1) ~= sepc )
              then Date = sepc ..&quot; &quot; .. Date .. OrigYear
              else Date = &quot; &quot; .. Date .. OrigYear
            end
        end
        if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
            text = safejoin( {Chapter, Place, tcommon}, sepc );
            text = safejoin( {text, pgtext, Date, idcommon}, sepc );
        else
            text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
            text = safejoin( {text, pgtext, idcommon}, sepc );
        end
    end
    
	if is_set(PostScript) and PostScript ~= sepc then
		text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
--		text = text:sub(1,-2);	--Remove final separator (assumes that sepc is only one character)
	end    
    
    text = safejoin( {text, PostScript}, sepc );

    -- Now enclose the whole thing in a &lt;span/&gt; element
    local options = {};
    
    if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
        options.class = &quot;citation &quot; .. config.CitationClass;
    else
        options.class = &quot;citation&quot;;
    end
    
    if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
        local id = Ref
        if ( &quot;harv&quot; == Ref ) then
            local names = {} --table of last names &amp; year
            if #a &gt; 0 then
                for i,v in ipairs(a) do 
                    names[i] = v.last 
                    if i == 4 then break end
                end
            elseif #e &gt; 0 then
                for i,v in ipairs(e) do 
                    names[i] = v.last 
                    if i == 4 then break end                
                end
            end
			names[ #names + 1 ] = first_set(Year, anchor_year);	-- Year first for legacy citations
            id = anchorid(names)
        end
        options.id = id;
    end
    
    if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
        z.error_categories = {};
        text = seterror('empty_citation');
        z.message_tail = {};
    end
    
    if is_set(options.id) then 
        text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    else
        text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
    end        

    local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
    
    -- Note: Using display: none on then COinS span breaks some clients.
    local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
    text = text .. OCinS;
    
    if #z.message_tail ~= 0 then
        text = text .. &quot; &quot;;
        for i,v in ipairs( z.message_tail ) do
            if is_set(v[1]) then
                if i == #z.message_tail then
                    text = text .. errorcomment( v[1], v[2] );
                else
                    text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
                end
            end
        end
    end
    
    no_tracking_cats = no_tracking_cats:lower();
    if inArray(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
        for _, v in ipairs( z.error_categories ) do
            text = text .. '[[Category:' .. v ..']]';
        end
    end
    
    return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
    local pframe = frame:getParent()
    
    if nil ~= string.find( frame:getTitle(), 'sandbox', 1, true ) then				-- did the {{#invoke:}} use sandbox version?
    	cfg = mw.loadData( 'Module:Citation/CS1/Configuration/sandbox' );	-- load sandbox versions of Configuration and Whitelist and ...
    	whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist/sandbox' );
    	dates = require('Module:Citation/CS1/Date_validation/sandbox').dates	-- ... sandbox version of date validation code
    else																	-- otherwise
    	cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );			-- load live versions of Configuration and Whitelist and ...
    	whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );
    	dates = require('Module:Citation/CS1/Date_validation').dates		-- ... live version of date validation code
	end
	
    local args = {};
    local suggestions = {};
    local error_text, error_state;

    local config = {};
    for k, v in pairs( frame.args ) do
        config[k] = v;
        args[k] = v;       
    end    

    for k, v in pairs( pframe.args ) do
        if v ~= '' then
            if not validate( k ) then            
                error_text = &quot;&quot;;
                if type( k ) ~= 'string' then
                    -- Exclude empty numbered parameters
                    if v:match(&quot;%S+&quot;) ~= nil then
                        error_text, error_state = seterror( 'text_ignored', {v}, true );
                    end
                elseif validate( k:lower() ) then 
                    error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
                else
                    if #suggestions == 0 then
                        suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
                    end
                    if suggestions[ k:lower() ] ~= nil then
                        error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
                    else
                        error_text, error_state = seterror( 'parameter_ignored', {k}, true );
                    end
                end                  
                if error_text ~= '' then
                    table.insert( z.message_tail, {error_text, error_state} );
                end                
            end
            args[k] = v;
        elseif args[k] ~= nil or (k == 'postscript') then
            args[k] = v;
        end        
    end    
    
    return citation0( config, args)
end

return z</text>
      <sha1>lo6xwe0knz7xynvby9rsvvyhw76rrl2</sha1>
    </revision>
    <revision>
      <id>4676</id>
      <parentid>4675</parentid>
      <timestamp>2014-08-24T17:00:32Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Restore with original extractnames(); missing and first/last mismatch author/editor error checking not present in this version;</comment>
      <origin>4676</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="83804" sha1="pvrwtjy3ythuh4lxlfvw2nah364kp6c" xml:space="preserve">local z = {
	error_categories = {};
	error_ids = {};
	message_tail = {};
}

-- Whether variable is set or not
function is_set( var )
	return not (var == nil or var == '');
end

-- First set variable or nil if none
function first_set(...)
	local list = {...};
	for _, var in pairs(list) do
		if is_set( var ) then
			return var;
		end
	end
end

-- Whether needle is in haystack
function inArray( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end

--[[
Categorize and emit an error message when the citation contains one or more deprecated parameters.  Because deprecated parameters (currently |day=, |month=,
|coauthor=, and |coauthors=) aren't related to each other and because these parameters may be concatenated into the variables used by |date= and |author#= (and aliases)
details of which parameter caused the error message are not provided.  Only one error message is emitted regardless of the number of deprecated parameters in the citation.
]]
function deprecated_parameter()
	if true ~= Page_in_deprecated_cat then	-- if we haven't been here before then set a 
		Page_in_deprecated_cat=true;		-- sticky flag so that if there are more than one deprecated parameter the category is added only once
--		table.insert( z.message_tail, { seterror( 'deprecated_params', {error_message}, true ) } );		-- add error message
		table.insert( z.message_tail, { seterror( 'deprecated_params', {}, true ) } );		-- add error message
	end
end

-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
--	return args and tostring( mw.message.newRawMessage( msg, args ) ) or msg;
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[
Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern  either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
]]
function kern_quotes (str)
	local left='&lt;span style=&quot;padding-left:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains leading single or double quote mark
	local right='&lt;span style=&quot;padding-right:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains trailing single or double quote mark
	
	if  str:match (&quot;^[\&quot;\'][^\']&quot;) then
		str = string.gsub( str, &quot;^[\&quot;\']&quot;, left, 1 );				-- replace (captured) leading single or double quote with left-side &lt;span&gt;
	end
	if str:match (&quot;[^\'][\&quot;\']$&quot;) then
		str = string.gsub( str, &quot;[\&quot;\']$&quot;, right, 1 );			-- replace (captured) trailing single or double quote with right-side &lt;span&gt;
	end
	return str;
end

-- Wraps a string using a message_list configuration taking one argument
function wrap( key, str, lower )
	if not is_set( str ) then
		return &quot;&quot;;
	elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safeforitalics( str );
	end
	if lower == true then
		return substitute( cfg.messages[key]:lower(), {str} );
	else
		return substitute( cfg.messages[key], {str} );
	end		
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = selectone( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
]]
function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
	return wrap( hidden and 'hidden-error' or 'visible-error', content );
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return errorcomment( message, error_state.hidden );
end

-- Formats a wiki style external link
function externallinkid(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

-- Formats a wiki style internal link
function internallinkid(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

-- Format an external link with error checking
function externallink( URL, label, source )
	local error_str = &quot;&quot;;
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = seterror( 'bare_url_missing_title', { wrap( 'parameter', source ) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not checkurl( URL ) then
		error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
	end
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safeforurl( label ), &quot;]&quot;, error_str });
end

-- Formats a link to Amazon
function amazon(id, domain)
	if not is_set(domain) then 
		domain = &quot;com&quot;
	elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
		domain = &quot;co.&quot; .. domain
	end
	local handler = cfg.id_handlers['ASIN'];
	return externallinkid({link = handler.link,
		label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
		encode=handler.encode, separator = handler.separator})
end

--[[
format and error check arXiv identifier.  There are two valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces
]]

function arxiv (id)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = &quot;&quot;
	
	year, month, version = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d([v%d]*)$&quot;);				-- test for the 9108-0703 format
	if not year then		-- arXiv id is not proper 9108-0703 form
		year, month, version = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d([v%d]*)$&quot;);	-- test for the 0704- format
		if not year then	
			err_cat = ' ' .. seterror( 'bad_arxiv' );							-- arXiv id doesn't match either format
		else	-- id is the 0704- format
			year = tonumber(year);
			month = tonumber(month);
			if ((7 &gt; year) or (1 &gt; month and 12 &lt; month)) or					-- is year invalid or is month invalid? (doesn't test for future years)
				((7 == year) and (4 &gt; month)) or								-- when year is 07, is month invalid (before April)?
				is_set (version) and nil == version:match(&quot;v%d+&quot;) then			-- is version proper format of single 'v' followed by digits?
					err_cat = ' ' .. seterror( 'bad_arxiv' );					-- set error message
			end
		end
	else	-- id is the 9108-0703 format; are the date values ok
		year = tonumber(year);
		month = tonumber(month);
		if ((91 &gt; year and 7 &lt; year) or (1 &gt; month and 12 &lt; month)) or			-- if invalid year or invalid month
			((91 == year and 8 &gt; month) or (7 == year and 3 &lt; month)) or 		-- if years ok, are starting and ending months ok?
				is_set (version) and nil == version:match(&quot;v%d+&quot;) then			-- is version proper format of single 'v' followed by digits?
					err_cat = ' ' .. seterror( 'bad_arxiv' );					-- set error message
		end
	end

	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--[[
Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of the LCCN dictates the character type of the first 1-3 characters; the
rightmost eight are always digits. http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is alpha
length = 10 then lccn[1] and lccn[2] are both alpha or both digits
length = 11 then lccn[1] is alpha, lccn[2] and lccn[3] are both alpha or both digits
length = 12 then lccn[1] and lccn[2] are both alpha

]]
function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%a%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%a%a%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%a%a%a%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%a%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%a%a%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. seterror( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. seterror( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]
function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmid' );	-- set an error message
		end
	end
	
	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns true; otherwise, returns false because the embargo has expired or |embargo= not set in this cite.
]]
function is_embargoed(embargo)
	if is_set(embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 and tonumber( embargo_date ) &gt;= tonumber( todays_date ) then	--is embargo date is in the future?
			return true;	-- still embargoed
		end
	end
	return false;			-- embargo expired or |embargo= not set
end

--[[
Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future
the PMC identifier will not be linked to the article.  If the embargo specifies a date in the past, or if it is empty or omitted, then
the PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.
]]
function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_embargoed(embargo) then
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	--still embargoed so no external link
	else
		text = externallinkid({link = handler.link, label = handler.label,			--no embargo date, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.

-- DOI names contain two parts: prefix and suffix separated by a forward slash.
--  Prefix: directory indicator '10.' followed by a registrant code
--  Suffix: character string of any length chosen by the registrant

-- This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes,
-- or, if it ends with a period or a comma, this function will emit a bad_doi error message.

-- DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
-- and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely if ever used in doi names.

function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. seterror( 'bad_doi' );
	end
	return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
	local code = id:sub(-1,-1)
	local handler = cfg.id_handlers['OL'];
	if ( code == &quot;A&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	else
		return externallinkid({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode}) .. 
			' ' .. seterror( 'bad_ol' );
	end
end

--[[
Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.
]]
function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = externallinkid({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. seterror( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[
This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those citations that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).
]]
function set_titletype(cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;					-- if |type=none then type parameter not displayed
		end
		return title_type;						-- if |type= has been set to any other value use that value
	end

	if &quot;AV-media-notes&quot; == cite_class or &quot;DVD-notes&quot; == cite_class then		-- if this citation is cite AV media notes or cite DVD notes
		return &quot;Media notes&quot;;					-- display AV media notes / DVD media notes annotation

	elseif &quot;podcast&quot; == cite_class then			-- if this citation is cite podcast
		return &quot;Podcast&quot;;						-- display podcast annotation

	elseif &quot;pressrelease&quot; == cite_class then	-- if this citation is cite press release
		return &quot;Press release&quot;;					-- display press release annotation

	elseif &quot;techreport&quot; == cite_class then		-- if this citation is cite techreport
		return &quot;Technical report&quot;;				-- display techreport annotation
	
	elseif &quot;thesis&quot; == cite_class then			-- if this citation is cite thesis (degree option handled after this function returns)
			return &quot;Thesis&quot;;					-- display simple thesis annotation (without |degree= modification)
	end
end

--[[
Determines whether a URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
	-- Protocol-relative or URL scheme
	return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
	return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

-- Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.
--TODO: Fix so this code supports urls like this:
--	http://www.history.navy.mil/download/va125153.pdf#page=13 %w/:\.
function get_coins_pages (pages)
	if not is_set (pages) then return pages; end			-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);	-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end					-- no more urls
		pattern = pattern:gsub(&quot;([%^%$%(%)%%%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);	-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);					-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);						-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end

--[[
ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in checkisbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.
]]
function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of bytes
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end	-- isbn13 begins with 978 or 979
		isbn_str = { isbn_str:byte(1, len) };
		for i, v in ipairs( isbn_str ) do
			temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
		end
		return temp % 10 == 0;
	end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
	--[[ Note: We cannot use &lt;i&gt; for italics, as the expected behavior for
	italics specified by ''...'' in the title is that they will be inverted
	(i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
	tend to interact poorly under Mediawiki's HTML tidy. ]]
	
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end

--[[
Joins a sequence of strings together while checking for duplicate separation characters.

TODO: safejoin() has a flaw where it won't remove the duplicate character from a |title= / |url= combination.
This is because by the time we get here, |title=http://somesite.com and |title=Document Title. have been combined:
	[http://somesite.com and ''Document Title.'']
so that now, the last character is not sepc but is ] (unless sepc == ']' which breaks the external link)
]]
function safejoin( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';
	local comp = '';
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then
			str = value;
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then
				-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
			else
				comp = value;
			end
			
			if comp:sub(1,1) == duplicate_char then
				trim = false;
				end_chr = str:sub(-1,-1);
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
				if end_chr == duplicate_char then
					str = str:sub(1,-2);
				elseif end_chr == &quot;'&quot; then
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
						str = str:sub(1, -4) .. &quot;''&quot;;
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
						trim = true;
					end
				elseif end_chr == &quot;]&quot; then
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
						trim = true;
					end
				elseif end_chr == &quot; &quot; then
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
						str = str:sub(1,-3);
					end
				end

				if trim then
					if value ~= comp then 
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
					else
						value = value:sub( 2, -1 );
					end
				end
			end
			str = str .. value;
		end
	end
	return str;
end  

-- Attempts to convert names to initials.
function reducetoinitials(first)
	local initials = {}
	local i = 0;										-- counter for number of initials
	for word in string.gmatch(first, &quot;%S+&quot;) do
		table.insert(initials, string.sub(word,1,1))	-- Vancouver format does not include full stops.
		i = i + 1;										-- bump the counter 
		if 2 &lt;= i then break; end						-- only two initials allowed in Vancouver system; if 2, quit
	end
	return table.concat(initials)						-- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
	local sep = control.sep;
	local namesep = control.namesep
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}
	local etal = false;
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if maximum ~= nil and maximum &lt; 1 then return &quot;&quot;, 0; end
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if maximum ~= nil and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
					one = one .. namesep .. first 
				end
				if is_set(person.link) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
				if is_set(person.link) and nil ~= person.link:find(&quot;//&quot;) then one = one .. &quot; &quot; .. seterror( 'bad_authorlink' ) end	-- check for url in author link;
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;
		end
		text[#text] = nil; 
	end
	
	local result = table.concat(text) -- construct list
	if etal then 
		local etal_text = cfg.messages['et al'];
		result = result .. &quot; &quot; .. etal_text;
	end
	
	-- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
	if ( &quot;scap&quot; == format ) then result = 
		'&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
	end 
	return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
	return &quot;CITEREF&quot; .. table.concat( options );
end

--[[
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.
]]
--Original function
function extractnames(args, list_name)
    local names = {};
    local i = 1;
    local last;
 
    while true do
        last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );
        if not is_set(last) then
            -- just in case someone passed in an empty parameter
            break;
        end
        names[i] = {
            last = last,
            first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i ),
            link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ),
            mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i )
        };
        i = i + 1;
    end
    return names;
end

--[[ Broken.  Editor CITEREF IDs are broken by this code (no editor list). Author CITEREF ID render correctly
function extractnames(args, list_name)
	local names = {};			-- table of names
	local i = 1;				-- loop counter/indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	
	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary

	while true do
		names[i] =				-- search through args for name components beginning at 1
			{
			last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i ),
			first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i ),
			link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ),
			mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i )
			};
		if names[i].first and not names[i].last then							-- if there is a firstn without a matching lastn
			names[i].first = nil;												-- set first to nil so we don't confuse the implicit et al message code
			table.insert( z.message_tail, { seterror( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
			break;																-- and done because lastn not found
		elseif not names[i].first and not names[i].last then					-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 == count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- last with or without a first
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { seterror( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- bump to the next name
	end
	return names;																-- all done, return our list of names
end
]]



-- Populates ID table from arguments using configuration settings
function extractids( args )
	local id_list = {};
	for k, v in pairs( cfg.id_handlers ) do	
		v = selectone( args, v.parameters, 'redundant_parameters' );
		if is_set(v) then id_list[k] = v; end
	end
	return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
	local new_list, handler = {};
	
	function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, externallinkid( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internallinkid( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internallinkid( handler );
			if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
	local value = nil;
	local selected = '';
	local error_list = {};
	
	if index ~= nil then index = tostring(index); end
	
	-- Handle special case of &quot;#&quot; replaced by empty string
	if index == '1' then
		for _, v in ipairs( possible ) do
			v = v:gsub( &quot;#&quot;, &quot;&quot; );
			if is_set(args[v]) then
				if value ~= nil and selected ~= v then
					table.insert( error_list, v );
				else
					value = args[v];
					selected = v;
				end
			end
		end		
	end
	
	for _, v in ipairs( possible ) do
		if index ~= nil then
			v = v:gsub( &quot;#&quot;, index );
		end
		if is_set(args[v]) then
			if value ~= nil and selected ~=  v then
				table.insert( error_list, v );
			else
				value = args[v];
				selected = v;
			end
		end
	end
	
	if #error_list &gt; 0 then
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap( 'parameter', k );
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap( 'parameter', selected );
		table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
function COinS(data)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end
	
	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
			end
		end
	});
	
	if is_set(data.Chapter) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Chapter;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	elseif is_set(data.Periodical) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
		OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	else
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
	end
	
	OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
	OCinSoutput[&quot;rft.date&quot;] = data.Date;
	OCinSoutput[&quot;rft.series&quot;] = data.Series;
	OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
	OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
	OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
	OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
	OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
	
	for k, v in pairs( data.ID_list ) do
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
	
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = v.last, v.first;
		if k == 1 then
			if is_set(last) then
				OCinSoutput[&quot;rft.aulast&quot;] = last;
			end
			if is_set(first) then 
				OCinSoutput[&quot;rft.aufirst&quot;] = first;
			end
		end
		if is_set(last) and is_set(first) then
			OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
		elseif is_set(last) then
			OCinSoutput[&quot;rft.au&quot;] = last;
		end
	end
	
	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end

--[[
This is the main function doing the majority of the citation
formatting.
]]
function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple
	aliases to single internal variable.
	]]
	local A = argument_wrapper( args );

	local i 
	local PPrefix = A['PPrefix']
	local PPPrefix = A['PPPrefix']
	if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
	
	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local Authors = A['Authors'];
	local a = extractnames( args, 'AuthorList' );

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];
	local Editors = A['Editors'];
	local e = extractnames( args, 'EditorList' );

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
	local Chapter = A['Chapter'];
	local ChapterLink = A['ChapterLink'];
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveURL = A['ArchiveURL'];
	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');
	local Periodical = A['Periodical'];

	local Series = A['Series'];
	local Volume = A['Volume'];
	local Issue = A['Issue'];
	local Position = '';
	local Page = A['Page'];
	local Pages = hyphentodash( A['Pages'] );	
	local At = A['At'];

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
	local SubscriptionRequired = A['SubscriptionRequired'];
	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local ArchiveDate = A['ArchiveDate'];
	local Agency = A['Agency'];
	local DeadURL = A['DeadURL']
	local Language = A['Language'];
	local Format = A['Format'];
	local Ref = A['Ref'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
	local Embargo = A['Embargo'];

	local ID_list = extractids( args );
--[[ Hide unfinished cite newsgroup code so that long delayed update can take place
	-- special case for cite newsgroup which uses |id= for a usenet article or post id
	-- |id= is not included in COinS so here we convert it to an ID that will be included in COinS
	if ('newsgroup' == config.CitationClass) and (is_set (ID)) then
		ID_list['USENETID']=ID;			-- add this new 'id' to the list of IDs
		ID = '';						-- and unset
	end
]]	
	local Quote = A['Quote'];
	local PostScript = A['PostScript'];

	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');
	local sepc = A['Separator'];

	local LastAuthorAmp = A['LastAuthorAmp'];
	local no_tracking_cats = A['NoTracking'];

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Cointerviewers = A['Cointerviewers'];			-- deprecated
	local Interviewer = A['Interviewer'];				-- deprecated
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local page_type;									-- is this needed?  Doesn't appear to be used anywhere;
	local use_lowercase = ( sepc ~= '.' );
	local this_page = mw.title.getCurrentTitle();		--Also used for COinS and for language
	local anchor_year;									-- used in the CITEREF identifier
	local COinS_date;									-- used in the COinS metadata

-- Set postscript default.
	if not is_set (PostScript) then						-- if |postscript= has not been set (Postscript is nil which is the default for {{citation}}) and
		if (config.CitationClass ~= &quot;citation&quot;) then	-- this template is not a citation template
			PostScript = '.';							-- must be a cite xxx template so set postscript to default (period)
		end
	else
		if PostScript:lower() == 'none' then			-- if |postscript=none then
			PostScript = '';							-- no postscript
		end
	end

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories.
	if not is_set(no_tracking_cats) then				-- ignore if we are already not going to categorize this page
		for k, v in pairs( cfg.uncategorized_namespaces ) do	-- otherwise, spin through the list of namespaces we don't include in error categories
			if this_page.nsText == v then				-- if we find one
				no_tracking_cats = &quot;true&quot;;				-- set no_tracking_cats
				break;									-- and we're done
			end
		end
	end

-- check for extra |page=, |pages= or |at= parameters. 
	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Page = Page .. &quot; &quot; .. seterror('extra_pages');	-- add error message
			Pages = '';										-- unset the others
			At = '';
		end
	elseif is_set(Pages) then
		if is_set(At) then
			Pages = Pages .. &quot; &quot; .. seterror('extra_pages');	-- add error messages
			At = '';											-- unset
		end
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped

All other combinations of |encyclopedia, |title, and |article are not modified
]]
	if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
		if is_set(Periodical) then					-- Periodical is set when |encyclopedia is set
			if is_set(Title) then
				if not is_set(Chapter) then
					Chapter = Title;				-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					TransChapter = TransTitle;
					Title = Periodical;
					Periodical = '';				-- redundant so unset
					TransTitle = '';				-- redundant so unset
				end
			else									-- |title not set
				Title = Periodical;					-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';					-- redundant so unset
			end
		end
	end

--special cases for citation.
	if (config.CitationClass == &quot;citation&quot;) then		-- for citation templates
		if not is_set (Ref) then						-- if |ref= is not set
			Ref = &quot;harv&quot;;								-- set default |ref=harv
		end
		if not is_set (sepc) then						-- if |separator= is not set
			sepc = ',';									-- set citation separator to its default (comma)
		end
	else												-- not a citation template
		if not is_set (sepc) then						-- if |separator= has not been set
			sepc = '.';									-- set cite xxx separator to its default (period)
		end
	end

-- check for special case where |separator=none
	if 'none' == sepc:lower() then						-- if |separator=none
		sepc = '';										-- then set it to an empty string
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then	-- special case for cite techreport
		if is_set(Issue) then						-- cite techreport uses 'number', which other citations aliase to 'issue'
			if not is_set(ID) then					-- can we use ID for the &quot;number&quot;?
				ID = Issue;							-- yes, use it
				Issue = &quot;&quot;;							-- unset Issue so that &quot;number&quot; isn't duplicated in the rendered citation or COinS metadata
			else									-- can't use ID so emit error message
				ID = ID .. &quot; &quot; .. seterror('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Interviewer) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Interviewer;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Interviewer;
			end
			if is_set(Cointerviewers) then
				Others = Others .. sepc .. ' ' .. Cointerviewers;
			end
		else
			Others = '(Interview)';
		end
	end

--Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set
	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_embargoed(Embargo) then
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];	-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];		-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
--TODO: if this is only for {{cite conference}}, shouldn't we be checking? (if config.CitationClass=='conference' then ...)
	if is_set(BookTitle) then
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = BookTitle;
		TitleLink = '';
		TransTitle = '';
	end

-- Account for the oddity that is {{cite episode}}, before generation of COinS data.
--[[	-- {{cite episode}} is not currently supported by this module
	if config.CitationClass == &quot;episode&quot; then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];
		local Season = A['Season'];
		local SeriesNumber = A['SeriesNumber'];
		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
		local Sep = (first_set(A[&quot;SeriesSeparator&quot;], A[&quot;Separator&quot;]) or &quot;&quot;) .. &quot; &quot;;
		
		if is_set(Issue) then table.insert(s, cfg.messages[&quot;episode&quot;] .. &quot; &quot; .. Issue); Issue = ''; end
		if is_set(Season) then table.insert(s, cfg.messages[&quot;season&quot;] .. &quot; &quot; .. Season); end
		if is_set(SeriesNumber) then table.insert(s, cfg.messages[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber); end
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		
		Date = Date or AirDate;
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = Series;
		TitleLink = SeriesLink;
		TransTitle = '';
		
		Series = table.concat(s, Sep);
		ID = table.concat(n, Sep);
	end
-- end of {{cite episode}} stuff]]

-- legacy: promote concatenation of |day=, |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set(Date) then
		Date = Year;						-- promote Year to Date
		Year = nil;							-- make nil so Year as empty string isn't used for CITEREF
		if is_set(Date) then
			local Month = A['Month'];
			if is_set(Month) then
				Date = Month .. &quot; &quot; .. Date;
				local Day = A['Day']
				if is_set(Day) then Date = Day .. &quot; &quot; .. Date end
			end
		elseif is_set(PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;			-- promote PublicationDate to Date
			PublicationDate = '';			-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end	-- if PublicationDate is same as Date, don't display in rendered citation


--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	anchor_year, COinS_date, error_message = dates({['accessdate']=AccessDate, ['airdate']=AirDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
		['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});
	if is_set(error_message) then
		table.insert( z.message_tail, { seterror( 'bad_date', {error_message}, true ) } );	-- add this error message
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for
	-- automated parsing of citation information.
	local OCinSoutput = COinS{
		['Periodical'] = Periodical,
		['Chapter'] = Chapter,
		['Title'] = Title,
		['PublicationPlace'] = PublicationPlace,
		['Date'] = first_set(COinS_date, Date),		-- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here?  Should we be including invalid dates in metadata?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set(Page, Pages, At)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set( URL, ChapterURL ),
		['Authors'] = a,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	};

	if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = '';
		TitleLink = '';
		TransTitle = '';
	end
--[[ Hide unfinished cite newsgroup code so that long delayed update can take place
-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername and ID
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = '[Newsgroup]:&amp;nbsp;' ..  externallink( 'news:' .. PublisherName, PublisherName );
		end
	end
]]


	-- Now perform various field 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 not is_set(Authors) then
		local Maximum = tonumber( A['DisplayAuthors'] );
		
		-- Preserve old-style implicit et al.
		if not is_set(Maximum) and #a == 9 then 
			Maximum = 8;
			table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
		elseif not is_set(Maximum) then
			Maximum = #a + 1;
		end
			
		local control = { 
			sep = A[&quot;AuthorSeparator&quot;] .. &quot; &quot;,
			namesep = (first_set(A[&quot;AuthorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
			format = A[&quot;AuthorFormat&quot;],
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp
		};
		
		-- If the coauthor field is also used, prevent ampersand and et al. formatting.
		if is_set(Coauthors) then
			control.lastauthoramp = nil;
			control.maximum = #a + 1;
		end
		
		Authors = listpeople(control, a) 
	end

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { seterror('coauthors_missing_author', {}, true) } );	-- emit error message
	end

	local EditorCount
	if not is_set(Editors) then
		local Maximum = tonumber( A['DisplayEditors'] );
		-- Preserve old-style implicit et al.
		if not is_set(Maximum) and #e == 4 then 
			Maximum = 3;
			table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
		elseif not is_set(Maximum) then
			Maximum = #e + 1;
		end

		local control = { 
			sep = A[&quot;EditorSeparator&quot;] .. &quot; &quot;,
			namesep = (first_set(A[&quot;EditorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
			format = A['EditorFormat'],
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp
		};

		Editors, EditorCount = listpeople(control, e);
	else
		EditorCount = 1;
	end

	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	if config.CitationClass == &quot;map&quot; then
		if not is_set( Authors ) and is_set( PublisherName ) then
			Authors = PublisherName;
			PublisherName = &quot;&quot;;
		end
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap( 'cartography', Cartography, use_lowercase );
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end		
	end
	
	if  not is_set(URL) and
		not is_set(ChapterURL) and
		not is_set(ArchiveURL) and
		not is_set(ConferenceURL) and
		not is_set(TranscriptURL) then
		
		-- Test if cite web or cite podcast |url= is missing or empty 
		if inArray(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;}) then	
			table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
		end
		
		-- Test if accessdate is given without giving a URL
		if is_set(AccessDate) then
			table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
		
		-- Test if format is given without giving a URL
		if is_set(Format) then
			Format = Format .. seterror( 'format_missing_url' );
		end
	end
	
	-- Test if citation has no title
	if  not is_set(Chapter) and
		not is_set(Title) and
		not is_set(Periodical) and
		not is_set(Conference) and
		not is_set(TransTitle) and
		not is_set(TransChapter) then
		table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
	end
	
	Format = is_set(Format) and &quot; (&quot; .. Format .. &quot;)&quot; or &quot;&quot;;
	
	local OriginalURL = URL
	DeadURL = DeadURL:lower();
	if is_set( ArchiveURL ) then
		if ( DeadURL ~= &quot;no&quot; ) then
			URL = ArchiveURL
			URLorigin = A:ORIGIN('ArchiveURL')
		end
	end
	
	-- Format chapter / article title
	if is_set(Chapter) and is_set(ChapterLink) then 
		Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot;;
	end
	if is_set(Periodical) and is_set(Title) then
		Chapter = wrap( 'italic-title', Chapter );
		TransChapter = wrap( 'trans-italic-title', TransChapter );
	else
		Chapter = kern_quotes (Chapter);				-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
		Chapter = wrap( 'quoted-title', Chapter );
		TransChapter = wrap( 'trans-quoted-title', TransChapter );
	end
	
	local TransError = &quot;&quot;
	if is_set(TransChapter) then
		if not is_set(Chapter) then
			TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
		else
			TransChapter = &quot; &quot; .. TransChapter;
		end
	end
	
	Chapter = Chapter .. TransChapter;
	
	if is_set(Chapter) then
		if not is_set(ChapterLink) then
			if is_set(ChapterURL) then
				Chapter = externallink( ChapterURL, Chapter ) .. TransError;
				if not is_set(URL) then
					Chapter = Chapter .. Format;
					Format = &quot;&quot;;
				end
			elseif is_set(URL) then 
				Chapter = externallink( URL, Chapter ) .. TransError .. Format;
				URL = &quot;&quot;;
				Format = &quot;&quot;;
			else
				Chapter = Chapter .. TransError;
			end			
		elseif is_set(ChapterURL) then
			Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. 
				TransError;
		else
			Chapter = Chapter .. TransError;
		end
		Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
	elseif is_set(ChapterURL) then
		Chapter = &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. sepc .. &quot; &quot;;
	end		
	
	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end
	
	if is_set(Periodical) then
		Title = kern_quotes (Title);				-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
		Title = wrap( 'quoted-title', Title );
		TransTitle = wrap( 'trans-quoted-title', TransTitle );
--[[ Hide unfinished cite newsgroup code so that long delayed update can take place
	elseif inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;pressrelease&quot;,&quot;conference&quot;,&quot;podcast&quot;,&quot;newsgroup&quot;}) and
]]	elseif inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;pressrelease&quot;,&quot;conference&quot;,&quot;podcast&quot;}) and
			not is_set(Chapter) then
		Title = kern_quotes (Title);				-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
		Title = wrap( 'quoted-title', Title );
		TransTitle = wrap( 'trans-quoted-title', TransTitle );
	else
		Title = wrap( 'italic-title', Title );
		TransTitle = wrap( 'trans-italic-title', TransTitle );
	end
	
	TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if not is_set(Title) then
			TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
		else
			TransTitle = &quot; &quot; .. TransTitle;
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then 
			Title = externallink( URL, Title ) .. TransError .. Format	   
			URL = &quot;&quot;;
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end
	
	if is_set(Place) then
		Place = &quot; &quot; .. wrap( 'written', Place, use_lowercase ) .. sepc .. &quot; &quot;;
	end
	
	if is_set(Conference) then
		if is_set(ConferenceURL) then
			Conference = externallink( ConferenceURL, Conference );
		end
		Conference = sepc .. &quot; &quot; .. Conference
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. externallink( ConferenceURL, nil, ConferenceURLorigin );
	end
	
	if not is_set(Position) then
		local Minutes = A['Minutes'];
		if is_set(Minutes) then
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			local Time = A['Time'];
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end
	
	if not is_set(Page) then
		if is_set(Pages) then
			if is_set(Periodical) and
				not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
				Pages = &quot;: &quot; .. Pages;
			elseif tonumber(Pages) ~= nil then
				Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
			else
				Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
			end
		end
	else
		if is_set(Periodical) and
			not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
			Page = &quot;: &quot; .. Page;
		else
			Page = sepc ..&quot; &quot; .. PPrefix .. Page;
		end
	end
	
	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Inset = A['Inset'];
		if first_set( Pages, Page, At ) ~= nil or sepc ~= '.' then
			if is_set( Section ) then
				Section = &quot;, &quot; .. wrap( 'section', Section, true );
			end
			if is_set( Inset ) then
				Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
			end
		else
			if is_set( Section ) then
				Section = sepc .. &quot; &quot; .. wrap( 'section', Section, use_lowercase );
				if is_set( Inset ) then
					Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
				end
			elseif is_set( Inset ) then
				Inset = sepc .. &quot; &quot; .. wrap( 'inset', Inset, use_lowercase );
			end			
		end			
		At = At .. Section .. Inset;		
	end	

	--[[Look in the list of iso639-1 language codes to see if the value provided in the language parameter matches one of them.  If a match is found, 
	use that value; if not, then use the value that was provided with the language parameter.
	
	Categories are assigned in a manner similar to the {{xx icon}} templates - categorizes only mainspace citations and only when the language code is not 'en' (English).
	]]
	if is_set (Language) then
--		local name = mw.language.fetchLanguageName( Language:lower(), &quot;en&quot; );	-- experiment: this seems to return correct ISO 639-1 language names
		local name = cfg.iso639_1[Language:lower()];		-- get the language name if Language parameter has a valid iso 639-1 code
		if nil == name then
			Language=&quot; &quot; .. wrap( 'language', Language );	-- no match, use parameter's value
		else
			if 0 == this_page.namespace and 'en' ~= Language:lower() then	--found a match; is this page main / article space and English not the language?
				Language=&quot; &quot; .. wrap( 'language', name .. '[[Category:Articles with ' .. name .. '-language external links]]' );	-- in main space and not English: categorize
			else
				Language=&quot; &quot; .. wrap( 'language', name );	--not in mainspace or language is English so don't categorize
			end
		end
	else
		Language=&quot;&quot;;	-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;

-- handle type parameter for those CS1 citations that have default values

	if inArray(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then	-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then					-- if type parameter is specified
		TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot;;	-- display it in parentheses
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	Edition = is_set(Edition) and (&quot; &quot; .. wrap( 'edition', Edition )) or &quot;&quot;;
	Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc ..&quot; &quot; .. Volume;
		  else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
		end
	end

--[[ This code commented out while discussion continues until after week of 2014-03-23 live module update;
	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc .. &quot; &quot; .. Volume;
		  else
			  Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
			  if is_set(Series) then Volume = sepc .. Volume;
			  end
		end
	end
]]	
	------------------------------------ totally unrelated data
	--[[ Loosely mimic {{subscription required}} template; Via parameter identifies a delivery source that is not the publisher; these sources often, but not always, exist
	behind a registration or paywall.  So here, we've chosen to decouple via from subscription (via has never been part of the registration required template).
	
	Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link note is displayed. There are no error messages for this condition.
	]]
	if is_set(Via) then
		Via = &quot; &quot; .. wrap( 'via', Via );
	end

	if is_set(SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription']; --here when 'via' parameter not used but 'subscription' is
	elseif is_set(RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration']; --here when 'via' and 'subscription' parameters not used but 'registration' is
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
		AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
			.. substitute( retrv_text, {AccessDate} ) .. '&lt;/span&gt;'
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end

	
	ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo} );

	if is_set(URL) then
		URL = &quot; &quot; .. externallink( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
			Quote = Quote:sub(2,-2);
		end
		Quote = sepc ..&quot; &quot; .. wrap( 'quoted-text', Quote ); 
		PostScript = &quot;&quot;;							-- CS1 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = seterror('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ externallink( ArchiveURL, arch_text ), ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text,
				{ externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ seterror('archive_missing_url'), ArchiveDate } );
		end
	else
		Archived = &quot;&quot;
	end
	
	local Lay
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
		end			
	else
		Lay = &quot;&quot;;
	end
	
	if is_set(Transcript) then
		if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
	elseif is_set(TranscriptURL) then
		Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
	end
	
	local Publisher;
	if is_set(Periodical) and
		not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap( 'published', PublicationDate );
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap( 'published', PublicationDate ) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap( 'italic-title', Periodical ) 
		else 
			Periodical = wrap( 'italic-title', Periodical )
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon
	if inArray(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, 
			Language, Cartography, Edition, Publisher, Agency, Volume, Issue}, sepc );
	else 
		tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, Language, 
			Volume, Issue, Others, Cartography, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Page .. Pages .. At;
	
	if is_set(Authors) then
		if is_set(Coauthors) then
			Authors = Authors .. A['AuthorSeparator'] .. &quot; &quot; .. Coauthors
		end
		if is_set(Date) then
			Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		elseif string.sub(Authors,-1,-1) == sepc then
			Authors = Authors .. &quot; &quot;
		else
			Authors = Authors .. sepc .. &quot; &quot;
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			if (sepc ~= '.') then in_text = in_text:lower() end
			Editors = in_text .. Editors .. post_text;
			if (string.sub(Editors,-1,-1) == sepc)
				then Editors = Editors .. &quot; &quot;
				else Editors = Editors .. sepc .. &quot; &quot;
			end
		end
		text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
		text = safejoin( {text, pgtext, idcommon}, sepc );
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
		text = safejoin( {text, pgtext, idcommon}, sepc );
	else
		if is_set(Date) then
			if ( string.sub(tcommon,-1,-1) ~= sepc )
			  then Date = sepc ..&quot; &quot; .. Date .. OrigYear
			  else Date = &quot; &quot; .. Date .. OrigYear
			end
		end
		if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
			text = safejoin( {Chapter, Place, tcommon}, sepc );
			text = safejoin( {text, pgtext, Date, idcommon}, sepc );
		else
			text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
			text = safejoin( {text, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
--		text = text:sub(1,-2);	--Remove final separator (assumes that sepc is only one character)
	end	
	
	text = safejoin( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;span/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = &quot;citation &quot; .. config.CitationClass;
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
		local id = Ref
		if ( &quot;harv&quot; == Ref ) then
			local names = {} --table of last names &amp; year
			if #a &gt; 0 then
				for i,v in ipairs(a) do 
					names[i] = v.last 
					if i == 4 then break end
				end
			elseif #e &gt; 0 then
				for i,v in ipairs(e) do 
					names[i] = v.last 
					if i == 4 then break end				
				end
			end
			names[ #names + 1 ] = first_set(Year, anchor_year);	-- Year first for legacy citations
			id = anchorid(names)
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = seterror('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then 
		text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	else
		text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	end		

	local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
	
	-- Note: Using display: none on then COinS span breaks some clients.
	local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
	text = text .. OCinS;
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. errorcomment( v[1], v[2] );
				else
					text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if inArray(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
	local pframe = frame:getParent()
	
	if nil ~= string.find( frame:getTitle(), 'sandbox', 1, true ) then				-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData( 'Module:Citation/CS1/Configuration/sandbox' );	-- load sandbox versions of Configuration and Whitelist and ...
		whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist/sandbox' );
		dates = require('Module:Citation/CS1/Date_validation/sandbox').dates	-- ... sandbox version of date validation code
	else																	-- otherwise
		cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );			-- load live versions of Configuration and Whitelist and ...
		whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );
		dates = require('Module:Citation/CS1/Date_validation').dates		-- ... live version of date validation code
	end
	
	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = seterror( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if #suggestions == 0 then
						suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
					end
					if suggestions[ k:lower() ] ~= nil then
						error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
					else
						error_text, error_state = seterror( 'parameter_ignored', {k}, true );
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	
	
	return citation0( config, args)
end

return z</text>
      <sha1>pvrwtjy3ythuh4lxlfvw2nah364kp6c</sha1>
    </revision>
    <revision>
      <id>4677</id>
      <parentid>4676</parentid>
      <timestamp>2014-09-03T11:29:11Z</timestamp>
      <contributor>
        <username>It Is Me Here</username>
        <id>814</id>
      </contributor>
      <minor />
      <comment>Changed protection level of Module:Citation/CS1: [[WP:High-risk templates|High-risk Lua module]] ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) [cascading]</comment>
      <origin>4676</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="83804" sha1="pvrwtjy3ythuh4lxlfvw2nah364kp6c" xml:space="preserve">local z = {
	error_categories = {};
	error_ids = {};
	message_tail = {};
}

-- Whether variable is set or not
function is_set( var )
	return not (var == nil or var == '');
end

-- First set variable or nil if none
function first_set(...)
	local list = {...};
	for _, var in pairs(list) do
		if is_set( var ) then
			return var;
		end
	end
end

-- Whether needle is in haystack
function inArray( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end

--[[
Categorize and emit an error message when the citation contains one or more deprecated parameters.  Because deprecated parameters (currently |day=, |month=,
|coauthor=, and |coauthors=) aren't related to each other and because these parameters may be concatenated into the variables used by |date= and |author#= (and aliases)
details of which parameter caused the error message are not provided.  Only one error message is emitted regardless of the number of deprecated parameters in the citation.
]]
function deprecated_parameter()
	if true ~= Page_in_deprecated_cat then	-- if we haven't been here before then set a 
		Page_in_deprecated_cat=true;		-- sticky flag so that if there are more than one deprecated parameter the category is added only once
--		table.insert( z.message_tail, { seterror( 'deprecated_params', {error_message}, true ) } );		-- add error message
		table.insert( z.message_tail, { seterror( 'deprecated_params', {}, true ) } );		-- add error message
	end
end

-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
--	return args and tostring( mw.message.newRawMessage( msg, args ) ) or msg;
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[
Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern  either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
]]
function kern_quotes (str)
	local left='&lt;span style=&quot;padding-left:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains leading single or double quote mark
	local right='&lt;span style=&quot;padding-right:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains trailing single or double quote mark
	
	if  str:match (&quot;^[\&quot;\'][^\']&quot;) then
		str = string.gsub( str, &quot;^[\&quot;\']&quot;, left, 1 );				-- replace (captured) leading single or double quote with left-side &lt;span&gt;
	end
	if str:match (&quot;[^\'][\&quot;\']$&quot;) then
		str = string.gsub( str, &quot;[\&quot;\']$&quot;, right, 1 );			-- replace (captured) trailing single or double quote with right-side &lt;span&gt;
	end
	return str;
end

-- Wraps a string using a message_list configuration taking one argument
function wrap( key, str, lower )
	if not is_set( str ) then
		return &quot;&quot;;
	elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safeforitalics( str );
	end
	if lower == true then
		return substitute( cfg.messages[key]:lower(), {str} );
	else
		return substitute( cfg.messages[key], {str} );
	end		
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = selectone( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
]]
function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
	return wrap( hidden and 'hidden-error' or 'visible-error', content );
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return errorcomment( message, error_state.hidden );
end

-- Formats a wiki style external link
function externallinkid(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

-- Formats a wiki style internal link
function internallinkid(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

-- Format an external link with error checking
function externallink( URL, label, source )
	local error_str = &quot;&quot;;
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = seterror( 'bare_url_missing_title', { wrap( 'parameter', source ) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not checkurl( URL ) then
		error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
	end
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safeforurl( label ), &quot;]&quot;, error_str });
end

-- Formats a link to Amazon
function amazon(id, domain)
	if not is_set(domain) then 
		domain = &quot;com&quot;
	elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
		domain = &quot;co.&quot; .. domain
	end
	local handler = cfg.id_handlers['ASIN'];
	return externallinkid({link = handler.link,
		label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
		encode=handler.encode, separator = handler.separator})
end

--[[
format and error check arXiv identifier.  There are two valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces
]]

function arxiv (id)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = &quot;&quot;
	
	year, month, version = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d([v%d]*)$&quot;);				-- test for the 9108-0703 format
	if not year then		-- arXiv id is not proper 9108-0703 form
		year, month, version = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d([v%d]*)$&quot;);	-- test for the 0704- format
		if not year then	
			err_cat = ' ' .. seterror( 'bad_arxiv' );							-- arXiv id doesn't match either format
		else	-- id is the 0704- format
			year = tonumber(year);
			month = tonumber(month);
			if ((7 &gt; year) or (1 &gt; month and 12 &lt; month)) or					-- is year invalid or is month invalid? (doesn't test for future years)
				((7 == year) and (4 &gt; month)) or								-- when year is 07, is month invalid (before April)?
				is_set (version) and nil == version:match(&quot;v%d+&quot;) then			-- is version proper format of single 'v' followed by digits?
					err_cat = ' ' .. seterror( 'bad_arxiv' );					-- set error message
			end
		end
	else	-- id is the 9108-0703 format; are the date values ok
		year = tonumber(year);
		month = tonumber(month);
		if ((91 &gt; year and 7 &lt; year) or (1 &gt; month and 12 &lt; month)) or			-- if invalid year or invalid month
			((91 == year and 8 &gt; month) or (7 == year and 3 &lt; month)) or 		-- if years ok, are starting and ending months ok?
				is_set (version) and nil == version:match(&quot;v%d+&quot;) then			-- is version proper format of single 'v' followed by digits?
					err_cat = ' ' .. seterror( 'bad_arxiv' );					-- set error message
		end
	end

	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--[[
Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of the LCCN dictates the character type of the first 1-3 characters; the
rightmost eight are always digits. http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is alpha
length = 10 then lccn[1] and lccn[2] are both alpha or both digits
length = 11 then lccn[1] is alpha, lccn[2] and lccn[3] are both alpha or both digits
length = 12 then lccn[1] and lccn[2] are both alpha

]]
function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%a%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%a%a%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%a%a%a%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%a%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%a%a%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. seterror( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. seterror( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]
function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmid' );	-- set an error message
		end
	end
	
	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns true; otherwise, returns false because the embargo has expired or |embargo= not set in this cite.
]]
function is_embargoed(embargo)
	if is_set(embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 and tonumber( embargo_date ) &gt;= tonumber( todays_date ) then	--is embargo date is in the future?
			return true;	-- still embargoed
		end
	end
	return false;			-- embargo expired or |embargo= not set
end

--[[
Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future
the PMC identifier will not be linked to the article.  If the embargo specifies a date in the past, or if it is empty or omitted, then
the PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.
]]
function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_embargoed(embargo) then
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	--still embargoed so no external link
	else
		text = externallinkid({link = handler.link, label = handler.label,			--no embargo date, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.

-- DOI names contain two parts: prefix and suffix separated by a forward slash.
--  Prefix: directory indicator '10.' followed by a registrant code
--  Suffix: character string of any length chosen by the registrant

-- This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes,
-- or, if it ends with a period or a comma, this function will emit a bad_doi error message.

-- DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
-- and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely if ever used in doi names.

function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. seterror( 'bad_doi' );
	end
	return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
	local code = id:sub(-1,-1)
	local handler = cfg.id_handlers['OL'];
	if ( code == &quot;A&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	else
		return externallinkid({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode}) .. 
			' ' .. seterror( 'bad_ol' );
	end
end

--[[
Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.
]]
function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = externallinkid({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. seterror( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[
This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those citations that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).
]]
function set_titletype(cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;					-- if |type=none then type parameter not displayed
		end
		return title_type;						-- if |type= has been set to any other value use that value
	end

	if &quot;AV-media-notes&quot; == cite_class or &quot;DVD-notes&quot; == cite_class then		-- if this citation is cite AV media notes or cite DVD notes
		return &quot;Media notes&quot;;					-- display AV media notes / DVD media notes annotation

	elseif &quot;podcast&quot; == cite_class then			-- if this citation is cite podcast
		return &quot;Podcast&quot;;						-- display podcast annotation

	elseif &quot;pressrelease&quot; == cite_class then	-- if this citation is cite press release
		return &quot;Press release&quot;;					-- display press release annotation

	elseif &quot;techreport&quot; == cite_class then		-- if this citation is cite techreport
		return &quot;Technical report&quot;;				-- display techreport annotation
	
	elseif &quot;thesis&quot; == cite_class then			-- if this citation is cite thesis (degree option handled after this function returns)
			return &quot;Thesis&quot;;					-- display simple thesis annotation (without |degree= modification)
	end
end

--[[
Determines whether a URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
	-- Protocol-relative or URL scheme
	return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
	return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

-- Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.
--TODO: Fix so this code supports urls like this:
--	http://www.history.navy.mil/download/va125153.pdf#page=13 %w/:\.
function get_coins_pages (pages)
	if not is_set (pages) then return pages; end			-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);	-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end					-- no more urls
		pattern = pattern:gsub(&quot;([%^%$%(%)%%%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);	-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);					-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);						-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end

--[[
ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in checkisbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.
]]
function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of bytes
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end	-- isbn13 begins with 978 or 979
		isbn_str = { isbn_str:byte(1, len) };
		for i, v in ipairs( isbn_str ) do
			temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
		end
		return temp % 10 == 0;
	end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
	--[[ Note: We cannot use &lt;i&gt; for italics, as the expected behavior for
	italics specified by ''...'' in the title is that they will be inverted
	(i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
	tend to interact poorly under Mediawiki's HTML tidy. ]]
	
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end

--[[
Joins a sequence of strings together while checking for duplicate separation characters.

TODO: safejoin() has a flaw where it won't remove the duplicate character from a |title= / |url= combination.
This is because by the time we get here, |title=http://somesite.com and |title=Document Title. have been combined:
	[http://somesite.com and ''Document Title.'']
so that now, the last character is not sepc but is ] (unless sepc == ']' which breaks the external link)
]]
function safejoin( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';
	local comp = '';
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then
			str = value;
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then
				-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
			else
				comp = value;
			end
			
			if comp:sub(1,1) == duplicate_char then
				trim = false;
				end_chr = str:sub(-1,-1);
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
				if end_chr == duplicate_char then
					str = str:sub(1,-2);
				elseif end_chr == &quot;'&quot; then
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
						str = str:sub(1, -4) .. &quot;''&quot;;
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
						trim = true;
					end
				elseif end_chr == &quot;]&quot; then
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
						trim = true;
					end
				elseif end_chr == &quot; &quot; then
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
						str = str:sub(1,-3);
					end
				end

				if trim then
					if value ~= comp then 
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
					else
						value = value:sub( 2, -1 );
					end
				end
			end
			str = str .. value;
		end
	end
	return str;
end  

-- Attempts to convert names to initials.
function reducetoinitials(first)
	local initials = {}
	local i = 0;										-- counter for number of initials
	for word in string.gmatch(first, &quot;%S+&quot;) do
		table.insert(initials, string.sub(word,1,1))	-- Vancouver format does not include full stops.
		i = i + 1;										-- bump the counter 
		if 2 &lt;= i then break; end						-- only two initials allowed in Vancouver system; if 2, quit
	end
	return table.concat(initials)						-- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
	local sep = control.sep;
	local namesep = control.namesep
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}
	local etal = false;
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if maximum ~= nil and maximum &lt; 1 then return &quot;&quot;, 0; end
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if maximum ~= nil and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
					one = one .. namesep .. first 
				end
				if is_set(person.link) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
				if is_set(person.link) and nil ~= person.link:find(&quot;//&quot;) then one = one .. &quot; &quot; .. seterror( 'bad_authorlink' ) end	-- check for url in author link;
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;
		end
		text[#text] = nil; 
	end
	
	local result = table.concat(text) -- construct list
	if etal then 
		local etal_text = cfg.messages['et al'];
		result = result .. &quot; &quot; .. etal_text;
	end
	
	-- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
	if ( &quot;scap&quot; == format ) then result = 
		'&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
	end 
	return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
	return &quot;CITEREF&quot; .. table.concat( options );
end

--[[
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.
]]
--Original function
function extractnames(args, list_name)
    local names = {};
    local i = 1;
    local last;
 
    while true do
        last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );
        if not is_set(last) then
            -- just in case someone passed in an empty parameter
            break;
        end
        names[i] = {
            last = last,
            first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i ),
            link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ),
            mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i )
        };
        i = i + 1;
    end
    return names;
end

--[[ Broken.  Editor CITEREF IDs are broken by this code (no editor list). Author CITEREF ID render correctly
function extractnames(args, list_name)
	local names = {};			-- table of names
	local i = 1;				-- loop counter/indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	
	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary

	while true do
		names[i] =				-- search through args for name components beginning at 1
			{
			last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i ),
			first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i ),
			link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ),
			mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i )
			};
		if names[i].first and not names[i].last then							-- if there is a firstn without a matching lastn
			names[i].first = nil;												-- set first to nil so we don't confuse the implicit et al message code
			table.insert( z.message_tail, { seterror( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
			break;																-- and done because lastn not found
		elseif not names[i].first and not names[i].last then					-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 == count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- last with or without a first
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { seterror( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- bump to the next name
	end
	return names;																-- all done, return our list of names
end
]]



-- Populates ID table from arguments using configuration settings
function extractids( args )
	local id_list = {};
	for k, v in pairs( cfg.id_handlers ) do	
		v = selectone( args, v.parameters, 'redundant_parameters' );
		if is_set(v) then id_list[k] = v; end
	end
	return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
	local new_list, handler = {};
	
	function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, externallinkid( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internallinkid( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internallinkid( handler );
			if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
	local value = nil;
	local selected = '';
	local error_list = {};
	
	if index ~= nil then index = tostring(index); end
	
	-- Handle special case of &quot;#&quot; replaced by empty string
	if index == '1' then
		for _, v in ipairs( possible ) do
			v = v:gsub( &quot;#&quot;, &quot;&quot; );
			if is_set(args[v]) then
				if value ~= nil and selected ~= v then
					table.insert( error_list, v );
				else
					value = args[v];
					selected = v;
				end
			end
		end		
	end
	
	for _, v in ipairs( possible ) do
		if index ~= nil then
			v = v:gsub( &quot;#&quot;, index );
		end
		if is_set(args[v]) then
			if value ~= nil and selected ~=  v then
				table.insert( error_list, v );
			else
				value = args[v];
				selected = v;
			end
		end
	end
	
	if #error_list &gt; 0 then
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap( 'parameter', k );
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap( 'parameter', selected );
		table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
function COinS(data)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end
	
	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
			end
		end
	});
	
	if is_set(data.Chapter) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Chapter;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	elseif is_set(data.Periodical) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
		OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	else
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
	end
	
	OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
	OCinSoutput[&quot;rft.date&quot;] = data.Date;
	OCinSoutput[&quot;rft.series&quot;] = data.Series;
	OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
	OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
	OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
	OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
	OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
	
	for k, v in pairs( data.ID_list ) do
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
	
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = v.last, v.first;
		if k == 1 then
			if is_set(last) then
				OCinSoutput[&quot;rft.aulast&quot;] = last;
			end
			if is_set(first) then 
				OCinSoutput[&quot;rft.aufirst&quot;] = first;
			end
		end
		if is_set(last) and is_set(first) then
			OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
		elseif is_set(last) then
			OCinSoutput[&quot;rft.au&quot;] = last;
		end
	end
	
	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end

--[[
This is the main function doing the majority of the citation
formatting.
]]
function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple
	aliases to single internal variable.
	]]
	local A = argument_wrapper( args );

	local i 
	local PPrefix = A['PPrefix']
	local PPPrefix = A['PPPrefix']
	if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
	
	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local Authors = A['Authors'];
	local a = extractnames( args, 'AuthorList' );

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];
	local Editors = A['Editors'];
	local e = extractnames( args, 'EditorList' );

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
	local Chapter = A['Chapter'];
	local ChapterLink = A['ChapterLink'];
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveURL = A['ArchiveURL'];
	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');
	local Periodical = A['Periodical'];

	local Series = A['Series'];
	local Volume = A['Volume'];
	local Issue = A['Issue'];
	local Position = '';
	local Page = A['Page'];
	local Pages = hyphentodash( A['Pages'] );	
	local At = A['At'];

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
	local SubscriptionRequired = A['SubscriptionRequired'];
	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local ArchiveDate = A['ArchiveDate'];
	local Agency = A['Agency'];
	local DeadURL = A['DeadURL']
	local Language = A['Language'];
	local Format = A['Format'];
	local Ref = A['Ref'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
	local Embargo = A['Embargo'];

	local ID_list = extractids( args );
--[[ Hide unfinished cite newsgroup code so that long delayed update can take place
	-- special case for cite newsgroup which uses |id= for a usenet article or post id
	-- |id= is not included in COinS so here we convert it to an ID that will be included in COinS
	if ('newsgroup' == config.CitationClass) and (is_set (ID)) then
		ID_list['USENETID']=ID;			-- add this new 'id' to the list of IDs
		ID = '';						-- and unset
	end
]]	
	local Quote = A['Quote'];
	local PostScript = A['PostScript'];

	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');
	local sepc = A['Separator'];

	local LastAuthorAmp = A['LastAuthorAmp'];
	local no_tracking_cats = A['NoTracking'];

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Cointerviewers = A['Cointerviewers'];			-- deprecated
	local Interviewer = A['Interviewer'];				-- deprecated
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local page_type;									-- is this needed?  Doesn't appear to be used anywhere;
	local use_lowercase = ( sepc ~= '.' );
	local this_page = mw.title.getCurrentTitle();		--Also used for COinS and for language
	local anchor_year;									-- used in the CITEREF identifier
	local COinS_date;									-- used in the COinS metadata

-- Set postscript default.
	if not is_set (PostScript) then						-- if |postscript= has not been set (Postscript is nil which is the default for {{citation}}) and
		if (config.CitationClass ~= &quot;citation&quot;) then	-- this template is not a citation template
			PostScript = '.';							-- must be a cite xxx template so set postscript to default (period)
		end
	else
		if PostScript:lower() == 'none' then			-- if |postscript=none then
			PostScript = '';							-- no postscript
		end
	end

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories.
	if not is_set(no_tracking_cats) then				-- ignore if we are already not going to categorize this page
		for k, v in pairs( cfg.uncategorized_namespaces ) do	-- otherwise, spin through the list of namespaces we don't include in error categories
			if this_page.nsText == v then				-- if we find one
				no_tracking_cats = &quot;true&quot;;				-- set no_tracking_cats
				break;									-- and we're done
			end
		end
	end

-- check for extra |page=, |pages= or |at= parameters. 
	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Page = Page .. &quot; &quot; .. seterror('extra_pages');	-- add error message
			Pages = '';										-- unset the others
			At = '';
		end
	elseif is_set(Pages) then
		if is_set(At) then
			Pages = Pages .. &quot; &quot; .. seterror('extra_pages');	-- add error messages
			At = '';											-- unset
		end
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped

All other combinations of |encyclopedia, |title, and |article are not modified
]]
	if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
		if is_set(Periodical) then					-- Periodical is set when |encyclopedia is set
			if is_set(Title) then
				if not is_set(Chapter) then
					Chapter = Title;				-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					TransChapter = TransTitle;
					Title = Periodical;
					Periodical = '';				-- redundant so unset
					TransTitle = '';				-- redundant so unset
				end
			else									-- |title not set
				Title = Periodical;					-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';					-- redundant so unset
			end
		end
	end

--special cases for citation.
	if (config.CitationClass == &quot;citation&quot;) then		-- for citation templates
		if not is_set (Ref) then						-- if |ref= is not set
			Ref = &quot;harv&quot;;								-- set default |ref=harv
		end
		if not is_set (sepc) then						-- if |separator= is not set
			sepc = ',';									-- set citation separator to its default (comma)
		end
	else												-- not a citation template
		if not is_set (sepc) then						-- if |separator= has not been set
			sepc = '.';									-- set cite xxx separator to its default (period)
		end
	end

-- check for special case where |separator=none
	if 'none' == sepc:lower() then						-- if |separator=none
		sepc = '';										-- then set it to an empty string
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then	-- special case for cite techreport
		if is_set(Issue) then						-- cite techreport uses 'number', which other citations aliase to 'issue'
			if not is_set(ID) then					-- can we use ID for the &quot;number&quot;?
				ID = Issue;							-- yes, use it
				Issue = &quot;&quot;;							-- unset Issue so that &quot;number&quot; isn't duplicated in the rendered citation or COinS metadata
			else									-- can't use ID so emit error message
				ID = ID .. &quot; &quot; .. seterror('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Interviewer) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Interviewer;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Interviewer;
			end
			if is_set(Cointerviewers) then
				Others = Others .. sepc .. ' ' .. Cointerviewers;
			end
		else
			Others = '(Interview)';
		end
	end

--Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set
	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_embargoed(Embargo) then
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];	-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];		-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
--TODO: if this is only for {{cite conference}}, shouldn't we be checking? (if config.CitationClass=='conference' then ...)
	if is_set(BookTitle) then
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = BookTitle;
		TitleLink = '';
		TransTitle = '';
	end

-- Account for the oddity that is {{cite episode}}, before generation of COinS data.
--[[	-- {{cite episode}} is not currently supported by this module
	if config.CitationClass == &quot;episode&quot; then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];
		local Season = A['Season'];
		local SeriesNumber = A['SeriesNumber'];
		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
		local Sep = (first_set(A[&quot;SeriesSeparator&quot;], A[&quot;Separator&quot;]) or &quot;&quot;) .. &quot; &quot;;
		
		if is_set(Issue) then table.insert(s, cfg.messages[&quot;episode&quot;] .. &quot; &quot; .. Issue); Issue = ''; end
		if is_set(Season) then table.insert(s, cfg.messages[&quot;season&quot;] .. &quot; &quot; .. Season); end
		if is_set(SeriesNumber) then table.insert(s, cfg.messages[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber); end
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		
		Date = Date or AirDate;
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = Series;
		TitleLink = SeriesLink;
		TransTitle = '';
		
		Series = table.concat(s, Sep);
		ID = table.concat(n, Sep);
	end
-- end of {{cite episode}} stuff]]

-- legacy: promote concatenation of |day=, |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set(Date) then
		Date = Year;						-- promote Year to Date
		Year = nil;							-- make nil so Year as empty string isn't used for CITEREF
		if is_set(Date) then
			local Month = A['Month'];
			if is_set(Month) then
				Date = Month .. &quot; &quot; .. Date;
				local Day = A['Day']
				if is_set(Day) then Date = Day .. &quot; &quot; .. Date end
			end
		elseif is_set(PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;			-- promote PublicationDate to Date
			PublicationDate = '';			-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end	-- if PublicationDate is same as Date, don't display in rendered citation


--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	anchor_year, COinS_date, error_message = dates({['accessdate']=AccessDate, ['airdate']=AirDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
		['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});
	if is_set(error_message) then
		table.insert( z.message_tail, { seterror( 'bad_date', {error_message}, true ) } );	-- add this error message
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for
	-- automated parsing of citation information.
	local OCinSoutput = COinS{
		['Periodical'] = Periodical,
		['Chapter'] = Chapter,
		['Title'] = Title,
		['PublicationPlace'] = PublicationPlace,
		['Date'] = first_set(COinS_date, Date),		-- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here?  Should we be including invalid dates in metadata?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set(Page, Pages, At)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set( URL, ChapterURL ),
		['Authors'] = a,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	};

	if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = '';
		TitleLink = '';
		TransTitle = '';
	end
--[[ Hide unfinished cite newsgroup code so that long delayed update can take place
-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername and ID
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = '[Newsgroup]:&amp;nbsp;' ..  externallink( 'news:' .. PublisherName, PublisherName );
		end
	end
]]


	-- Now perform various field 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 not is_set(Authors) then
		local Maximum = tonumber( A['DisplayAuthors'] );
		
		-- Preserve old-style implicit et al.
		if not is_set(Maximum) and #a == 9 then 
			Maximum = 8;
			table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
		elseif not is_set(Maximum) then
			Maximum = #a + 1;
		end
			
		local control = { 
			sep = A[&quot;AuthorSeparator&quot;] .. &quot; &quot;,
			namesep = (first_set(A[&quot;AuthorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
			format = A[&quot;AuthorFormat&quot;],
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp
		};
		
		-- If the coauthor field is also used, prevent ampersand and et al. formatting.
		if is_set(Coauthors) then
			control.lastauthoramp = nil;
			control.maximum = #a + 1;
		end
		
		Authors = listpeople(control, a) 
	end

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { seterror('coauthors_missing_author', {}, true) } );	-- emit error message
	end

	local EditorCount
	if not is_set(Editors) then
		local Maximum = tonumber( A['DisplayEditors'] );
		-- Preserve old-style implicit et al.
		if not is_set(Maximum) and #e == 4 then 
			Maximum = 3;
			table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
		elseif not is_set(Maximum) then
			Maximum = #e + 1;
		end

		local control = { 
			sep = A[&quot;EditorSeparator&quot;] .. &quot; &quot;,
			namesep = (first_set(A[&quot;EditorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
			format = A['EditorFormat'],
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp
		};

		Editors, EditorCount = listpeople(control, e);
	else
		EditorCount = 1;
	end

	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	if config.CitationClass == &quot;map&quot; then
		if not is_set( Authors ) and is_set( PublisherName ) then
			Authors = PublisherName;
			PublisherName = &quot;&quot;;
		end
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap( 'cartography', Cartography, use_lowercase );
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end		
	end
	
	if  not is_set(URL) and
		not is_set(ChapterURL) and
		not is_set(ArchiveURL) and
		not is_set(ConferenceURL) and
		not is_set(TranscriptURL) then
		
		-- Test if cite web or cite podcast |url= is missing or empty 
		if inArray(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;}) then	
			table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
		end
		
		-- Test if accessdate is given without giving a URL
		if is_set(AccessDate) then
			table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
		
		-- Test if format is given without giving a URL
		if is_set(Format) then
			Format = Format .. seterror( 'format_missing_url' );
		end
	end
	
	-- Test if citation has no title
	if  not is_set(Chapter) and
		not is_set(Title) and
		not is_set(Periodical) and
		not is_set(Conference) and
		not is_set(TransTitle) and
		not is_set(TransChapter) then
		table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
	end
	
	Format = is_set(Format) and &quot; (&quot; .. Format .. &quot;)&quot; or &quot;&quot;;
	
	local OriginalURL = URL
	DeadURL = DeadURL:lower();
	if is_set( ArchiveURL ) then
		if ( DeadURL ~= &quot;no&quot; ) then
			URL = ArchiveURL
			URLorigin = A:ORIGIN('ArchiveURL')
		end
	end
	
	-- Format chapter / article title
	if is_set(Chapter) and is_set(ChapterLink) then 
		Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot;;
	end
	if is_set(Periodical) and is_set(Title) then
		Chapter = wrap( 'italic-title', Chapter );
		TransChapter = wrap( 'trans-italic-title', TransChapter );
	else
		Chapter = kern_quotes (Chapter);				-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
		Chapter = wrap( 'quoted-title', Chapter );
		TransChapter = wrap( 'trans-quoted-title', TransChapter );
	end
	
	local TransError = &quot;&quot;
	if is_set(TransChapter) then
		if not is_set(Chapter) then
			TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
		else
			TransChapter = &quot; &quot; .. TransChapter;
		end
	end
	
	Chapter = Chapter .. TransChapter;
	
	if is_set(Chapter) then
		if not is_set(ChapterLink) then
			if is_set(ChapterURL) then
				Chapter = externallink( ChapterURL, Chapter ) .. TransError;
				if not is_set(URL) then
					Chapter = Chapter .. Format;
					Format = &quot;&quot;;
				end
			elseif is_set(URL) then 
				Chapter = externallink( URL, Chapter ) .. TransError .. Format;
				URL = &quot;&quot;;
				Format = &quot;&quot;;
			else
				Chapter = Chapter .. TransError;
			end			
		elseif is_set(ChapterURL) then
			Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. 
				TransError;
		else
			Chapter = Chapter .. TransError;
		end
		Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
	elseif is_set(ChapterURL) then
		Chapter = &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. sepc .. &quot; &quot;;
	end		
	
	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end
	
	if is_set(Periodical) then
		Title = kern_quotes (Title);				-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
		Title = wrap( 'quoted-title', Title );
		TransTitle = wrap( 'trans-quoted-title', TransTitle );
--[[ Hide unfinished cite newsgroup code so that long delayed update can take place
	elseif inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;pressrelease&quot;,&quot;conference&quot;,&quot;podcast&quot;,&quot;newsgroup&quot;}) and
]]	elseif inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;pressrelease&quot;,&quot;conference&quot;,&quot;podcast&quot;}) and
			not is_set(Chapter) then
		Title = kern_quotes (Title);				-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
		Title = wrap( 'quoted-title', Title );
		TransTitle = wrap( 'trans-quoted-title', TransTitle );
	else
		Title = wrap( 'italic-title', Title );
		TransTitle = wrap( 'trans-italic-title', TransTitle );
	end
	
	TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if not is_set(Title) then
			TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
		else
			TransTitle = &quot; &quot; .. TransTitle;
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then 
			Title = externallink( URL, Title ) .. TransError .. Format	   
			URL = &quot;&quot;;
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end
	
	if is_set(Place) then
		Place = &quot; &quot; .. wrap( 'written', Place, use_lowercase ) .. sepc .. &quot; &quot;;
	end
	
	if is_set(Conference) then
		if is_set(ConferenceURL) then
			Conference = externallink( ConferenceURL, Conference );
		end
		Conference = sepc .. &quot; &quot; .. Conference
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. externallink( ConferenceURL, nil, ConferenceURLorigin );
	end
	
	if not is_set(Position) then
		local Minutes = A['Minutes'];
		if is_set(Minutes) then
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			local Time = A['Time'];
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end
	
	if not is_set(Page) then
		if is_set(Pages) then
			if is_set(Periodical) and
				not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
				Pages = &quot;: &quot; .. Pages;
			elseif tonumber(Pages) ~= nil then
				Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
			else
				Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
			end
		end
	else
		if is_set(Periodical) and
			not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
			Page = &quot;: &quot; .. Page;
		else
			Page = sepc ..&quot; &quot; .. PPrefix .. Page;
		end
	end
	
	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Inset = A['Inset'];
		if first_set( Pages, Page, At ) ~= nil or sepc ~= '.' then
			if is_set( Section ) then
				Section = &quot;, &quot; .. wrap( 'section', Section, true );
			end
			if is_set( Inset ) then
				Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
			end
		else
			if is_set( Section ) then
				Section = sepc .. &quot; &quot; .. wrap( 'section', Section, use_lowercase );
				if is_set( Inset ) then
					Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
				end
			elseif is_set( Inset ) then
				Inset = sepc .. &quot; &quot; .. wrap( 'inset', Inset, use_lowercase );
			end			
		end			
		At = At .. Section .. Inset;		
	end	

	--[[Look in the list of iso639-1 language codes to see if the value provided in the language parameter matches one of them.  If a match is found, 
	use that value; if not, then use the value that was provided with the language parameter.
	
	Categories are assigned in a manner similar to the {{xx icon}} templates - categorizes only mainspace citations and only when the language code is not 'en' (English).
	]]
	if is_set (Language) then
--		local name = mw.language.fetchLanguageName( Language:lower(), &quot;en&quot; );	-- experiment: this seems to return correct ISO 639-1 language names
		local name = cfg.iso639_1[Language:lower()];		-- get the language name if Language parameter has a valid iso 639-1 code
		if nil == name then
			Language=&quot; &quot; .. wrap( 'language', Language );	-- no match, use parameter's value
		else
			if 0 == this_page.namespace and 'en' ~= Language:lower() then	--found a match; is this page main / article space and English not the language?
				Language=&quot; &quot; .. wrap( 'language', name .. '[[Category:Articles with ' .. name .. '-language external links]]' );	-- in main space and not English: categorize
			else
				Language=&quot; &quot; .. wrap( 'language', name );	--not in mainspace or language is English so don't categorize
			end
		end
	else
		Language=&quot;&quot;;	-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;

-- handle type parameter for those CS1 citations that have default values

	if inArray(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then	-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then					-- if type parameter is specified
		TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot;;	-- display it in parentheses
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	Edition = is_set(Edition) and (&quot; &quot; .. wrap( 'edition', Edition )) or &quot;&quot;;
	Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc ..&quot; &quot; .. Volume;
		  else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
		end
	end

--[[ This code commented out while discussion continues until after week of 2014-03-23 live module update;
	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc .. &quot; &quot; .. Volume;
		  else
			  Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
			  if is_set(Series) then Volume = sepc .. Volume;
			  end
		end
	end
]]	
	------------------------------------ totally unrelated data
	--[[ Loosely mimic {{subscription required}} template; Via parameter identifies a delivery source that is not the publisher; these sources often, but not always, exist
	behind a registration or paywall.  So here, we've chosen to decouple via from subscription (via has never been part of the registration required template).
	
	Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link note is displayed. There are no error messages for this condition.
	]]
	if is_set(Via) then
		Via = &quot; &quot; .. wrap( 'via', Via );
	end

	if is_set(SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription']; --here when 'via' parameter not used but 'subscription' is
	elseif is_set(RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration']; --here when 'via' and 'subscription' parameters not used but 'registration' is
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
		AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
			.. substitute( retrv_text, {AccessDate} ) .. '&lt;/span&gt;'
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end

	
	ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo} );

	if is_set(URL) then
		URL = &quot; &quot; .. externallink( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
			Quote = Quote:sub(2,-2);
		end
		Quote = sepc ..&quot; &quot; .. wrap( 'quoted-text', Quote ); 
		PostScript = &quot;&quot;;							-- CS1 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = seterror('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ externallink( ArchiveURL, arch_text ), ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text,
				{ externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ seterror('archive_missing_url'), ArchiveDate } );
		end
	else
		Archived = &quot;&quot;
	end
	
	local Lay
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
		end			
	else
		Lay = &quot;&quot;;
	end
	
	if is_set(Transcript) then
		if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
	elseif is_set(TranscriptURL) then
		Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
	end
	
	local Publisher;
	if is_set(Periodical) and
		not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap( 'published', PublicationDate );
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap( 'published', PublicationDate ) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap( 'italic-title', Periodical ) 
		else 
			Periodical = wrap( 'italic-title', Periodical )
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon
	if inArray(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, 
			Language, Cartography, Edition, Publisher, Agency, Volume, Issue}, sepc );
	else 
		tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, Language, 
			Volume, Issue, Others, Cartography, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Page .. Pages .. At;
	
	if is_set(Authors) then
		if is_set(Coauthors) then
			Authors = Authors .. A['AuthorSeparator'] .. &quot; &quot; .. Coauthors
		end
		if is_set(Date) then
			Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		elseif string.sub(Authors,-1,-1) == sepc then
			Authors = Authors .. &quot; &quot;
		else
			Authors = Authors .. sepc .. &quot; &quot;
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			if (sepc ~= '.') then in_text = in_text:lower() end
			Editors = in_text .. Editors .. post_text;
			if (string.sub(Editors,-1,-1) == sepc)
				then Editors = Editors .. &quot; &quot;
				else Editors = Editors .. sepc .. &quot; &quot;
			end
		end
		text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
		text = safejoin( {text, pgtext, idcommon}, sepc );
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
		text = safejoin( {text, pgtext, idcommon}, sepc );
	else
		if is_set(Date) then
			if ( string.sub(tcommon,-1,-1) ~= sepc )
			  then Date = sepc ..&quot; &quot; .. Date .. OrigYear
			  else Date = &quot; &quot; .. Date .. OrigYear
			end
		end
		if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
			text = safejoin( {Chapter, Place, tcommon}, sepc );
			text = safejoin( {text, pgtext, Date, idcommon}, sepc );
		else
			text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
			text = safejoin( {text, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
--		text = text:sub(1,-2);	--Remove final separator (assumes that sepc is only one character)
	end	
	
	text = safejoin( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;span/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = &quot;citation &quot; .. config.CitationClass;
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
		local id = Ref
		if ( &quot;harv&quot; == Ref ) then
			local names = {} --table of last names &amp; year
			if #a &gt; 0 then
				for i,v in ipairs(a) do 
					names[i] = v.last 
					if i == 4 then break end
				end
			elseif #e &gt; 0 then
				for i,v in ipairs(e) do 
					names[i] = v.last 
					if i == 4 then break end				
				end
			end
			names[ #names + 1 ] = first_set(Year, anchor_year);	-- Year first for legacy citations
			id = anchorid(names)
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = seterror('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then 
		text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	else
		text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	end		

	local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
	
	-- Note: Using display: none on then COinS span breaks some clients.
	local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
	text = text .. OCinS;
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. errorcomment( v[1], v[2] );
				else
					text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if inArray(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
	local pframe = frame:getParent()
	
	if nil ~= string.find( frame:getTitle(), 'sandbox', 1, true ) then				-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData( 'Module:Citation/CS1/Configuration/sandbox' );	-- load sandbox versions of Configuration and Whitelist and ...
		whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist/sandbox' );
		dates = require('Module:Citation/CS1/Date_validation/sandbox').dates	-- ... sandbox version of date validation code
	else																	-- otherwise
		cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );			-- load live versions of Configuration and Whitelist and ...
		whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );
		dates = require('Module:Citation/CS1/Date_validation').dates		-- ... live version of date validation code
	end
	
	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = seterror( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if #suggestions == 0 then
						suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
					end
					if suggestions[ k:lower() ] ~= nil then
						error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
					else
						error_text, error_state = seterror( 'parameter_ignored', {k}, true );
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	
	
	return citation0( config, args)
end

return z</text>
      <sha1>pvrwtjy3ythuh4lxlfvw2nah364kp6c</sha1>
    </revision>
    <revision>
      <id>4678</id>
      <parentid>4677</parentid>
      <timestamp>2014-09-03T20:01:21Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <minor />
      <comment>Changed protection level of Module:Citation/CS1: Remove cascading, doesn't work like as you would expect for Modules/Templates ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))</comment>
      <origin>4676</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="83804" sha1="pvrwtjy3ythuh4lxlfvw2nah364kp6c" xml:space="preserve">local z = {
	error_categories = {};
	error_ids = {};
	message_tail = {};
}

-- Whether variable is set or not
function is_set( var )
	return not (var == nil or var == '');
end

-- First set variable or nil if none
function first_set(...)
	local list = {...};
	for _, var in pairs(list) do
		if is_set( var ) then
			return var;
		end
	end
end

-- Whether needle is in haystack
function inArray( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end

--[[
Categorize and emit an error message when the citation contains one or more deprecated parameters.  Because deprecated parameters (currently |day=, |month=,
|coauthor=, and |coauthors=) aren't related to each other and because these parameters may be concatenated into the variables used by |date= and |author#= (and aliases)
details of which parameter caused the error message are not provided.  Only one error message is emitted regardless of the number of deprecated parameters in the citation.
]]
function deprecated_parameter()
	if true ~= Page_in_deprecated_cat then	-- if we haven't been here before then set a 
		Page_in_deprecated_cat=true;		-- sticky flag so that if there are more than one deprecated parameter the category is added only once
--		table.insert( z.message_tail, { seterror( 'deprecated_params', {error_message}, true ) } );		-- add error message
		table.insert( z.message_tail, { seterror( 'deprecated_params', {}, true ) } );		-- add error message
	end
end

-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
--	return args and tostring( mw.message.newRawMessage( msg, args ) ) or msg;
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[
Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern  either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
]]
function kern_quotes (str)
	local left='&lt;span style=&quot;padding-left:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains leading single or double quote mark
	local right='&lt;span style=&quot;padding-right:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains trailing single or double quote mark
	
	if  str:match (&quot;^[\&quot;\'][^\']&quot;) then
		str = string.gsub( str, &quot;^[\&quot;\']&quot;, left, 1 );				-- replace (captured) leading single or double quote with left-side &lt;span&gt;
	end
	if str:match (&quot;[^\'][\&quot;\']$&quot;) then
		str = string.gsub( str, &quot;[\&quot;\']$&quot;, right, 1 );			-- replace (captured) trailing single or double quote with right-side &lt;span&gt;
	end
	return str;
end

-- Wraps a string using a message_list configuration taking one argument
function wrap( key, str, lower )
	if not is_set( str ) then
		return &quot;&quot;;
	elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safeforitalics( str );
	end
	if lower == true then
		return substitute( cfg.messages[key]:lower(), {str} );
	else
		return substitute( cfg.messages[key], {str} );
	end		
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = selectone( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
]]
function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
	return wrap( hidden and 'hidden-error' or 'visible-error', content );
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return errorcomment( message, error_state.hidden );
end

-- Formats a wiki style external link
function externallinkid(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

-- Formats a wiki style internal link
function internallinkid(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

-- Format an external link with error checking
function externallink( URL, label, source )
	local error_str = &quot;&quot;;
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = seterror( 'bare_url_missing_title', { wrap( 'parameter', source ) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not checkurl( URL ) then
		error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
	end
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safeforurl( label ), &quot;]&quot;, error_str });
end

-- Formats a link to Amazon
function amazon(id, domain)
	if not is_set(domain) then 
		domain = &quot;com&quot;
	elseif ( &quot;jp&quot; == domain or &quot;uk&quot; == domain ) then
		domain = &quot;co.&quot; .. domain
	end
	local handler = cfg.id_handlers['ASIN'];
	return externallinkid({link = handler.link,
		label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
		encode=handler.encode, separator = handler.separator})
end

--[[
format and error check arXiv identifier.  There are two valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces
]]

function arxiv (id)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = &quot;&quot;
	
	year, month, version = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d([v%d]*)$&quot;);				-- test for the 9108-0703 format
	if not year then		-- arXiv id is not proper 9108-0703 form
		year, month, version = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d([v%d]*)$&quot;);	-- test for the 0704- format
		if not year then	
			err_cat = ' ' .. seterror( 'bad_arxiv' );							-- arXiv id doesn't match either format
		else	-- id is the 0704- format
			year = tonumber(year);
			month = tonumber(month);
			if ((7 &gt; year) or (1 &gt; month and 12 &lt; month)) or					-- is year invalid or is month invalid? (doesn't test for future years)
				((7 == year) and (4 &gt; month)) or								-- when year is 07, is month invalid (before April)?
				is_set (version) and nil == version:match(&quot;v%d+&quot;) then			-- is version proper format of single 'v' followed by digits?
					err_cat = ' ' .. seterror( 'bad_arxiv' );					-- set error message
			end
		end
	else	-- id is the 9108-0703 format; are the date values ok
		year = tonumber(year);
		month = tonumber(month);
		if ((91 &gt; year and 7 &lt; year) or (1 &gt; month and 12 &lt; month)) or			-- if invalid year or invalid month
			((91 == year and 8 &gt; month) or (7 == year and 3 &lt; month)) or 		-- if years ok, are starting and ending months ok?
				is_set (version) and nil == version:match(&quot;v%d+&quot;) then			-- is version proper format of single 'v' followed by digits?
					err_cat = ' ' .. seterror( 'bad_arxiv' );					-- set error message
		end
	end

	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--[[
Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of the LCCN dictates the character type of the first 1-3 characters; the
rightmost eight are always digits. http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is alpha
length = 10 then lccn[1] and lccn[2] are both alpha or both digits
length = 11 then lccn[1] is alpha, lccn[2] and lccn[3] are both alpha or both digits
length = 12 then lccn[1] and lccn[2] are both alpha

]]
function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%a%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%a%a%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%a%a%a%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%a%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%a%a%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. seterror( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. seterror( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]
function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmid' );	-- set an error message
		end
	end
	
	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns true; otherwise, returns false because the embargo has expired or |embargo= not set in this cite.
]]
function is_embargoed(embargo)
	if is_set(embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 and tonumber( embargo_date ) &gt;= tonumber( todays_date ) then	--is embargo date is in the future?
			return true;	-- still embargoed
		end
	end
	return false;			-- embargo expired or |embargo= not set
end

--[[
Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future
the PMC identifier will not be linked to the article.  If the embargo specifies a date in the past, or if it is empty or omitted, then
the PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.
]]
function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_embargoed(embargo) then
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	--still embargoed so no external link
	else
		text = externallinkid({link = handler.link, label = handler.label,			--no embargo date, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.

-- DOI names contain two parts: prefix and suffix separated by a forward slash.
--  Prefix: directory indicator '10.' followed by a registrant code
--  Suffix: character string of any length chosen by the registrant

-- This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes,
-- or, if it ends with a period or a comma, this function will emit a bad_doi error message.

-- DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
-- and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely if ever used in doi names.

function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. seterror( 'bad_doi' );
	end
	return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
	local code = id:sub(-1,-1)
	local handler = cfg.id_handlers['OL'];
	if ( code == &quot;A&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	else
		return externallinkid({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode}) .. 
			' ' .. seterror( 'bad_ol' );
	end
end

--[[
Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.
]]
function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = externallinkid({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. seterror( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[
This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those citations that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).
]]
function set_titletype(cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;					-- if |type=none then type parameter not displayed
		end
		return title_type;						-- if |type= has been set to any other value use that value
	end

	if &quot;AV-media-notes&quot; == cite_class or &quot;DVD-notes&quot; == cite_class then		-- if this citation is cite AV media notes or cite DVD notes
		return &quot;Media notes&quot;;					-- display AV media notes / DVD media notes annotation

	elseif &quot;podcast&quot; == cite_class then			-- if this citation is cite podcast
		return &quot;Podcast&quot;;						-- display podcast annotation

	elseif &quot;pressrelease&quot; == cite_class then	-- if this citation is cite press release
		return &quot;Press release&quot;;					-- display press release annotation

	elseif &quot;techreport&quot; == cite_class then		-- if this citation is cite techreport
		return &quot;Technical report&quot;;				-- display techreport annotation
	
	elseif &quot;thesis&quot; == cite_class then			-- if this citation is cite thesis (degree option handled after this function returns)
			return &quot;Thesis&quot;;					-- display simple thesis annotation (without |degree= modification)
	end
end

--[[
Determines whether a URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
	-- Protocol-relative or URL scheme
	return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
	return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

-- Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.
--TODO: Fix so this code supports urls like this:
--	http://www.history.navy.mil/download/va125153.pdf#page=13 %w/:\.
function get_coins_pages (pages)
	if not is_set (pages) then return pages; end			-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);	-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end					-- no more urls
		pattern = pattern:gsub(&quot;([%^%$%(%)%%%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);	-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);					-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);						-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end

--[[
ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in checkisbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.
]]
function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of bytes
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end	-- isbn13 begins with 978 or 979
		isbn_str = { isbn_str:byte(1, len) };
		for i, v in ipairs( isbn_str ) do
			temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
		end
		return temp % 10 == 0;
	end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
	--[[ Note: We cannot use &lt;i&gt; for italics, as the expected behavior for
	italics specified by ''...'' in the title is that they will be inverted
	(i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
	tend to interact poorly under Mediawiki's HTML tidy. ]]
	
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end

--[[
Joins a sequence of strings together while checking for duplicate separation characters.

TODO: safejoin() has a flaw where it won't remove the duplicate character from a |title= / |url= combination.
This is because by the time we get here, |title=http://somesite.com and |title=Document Title. have been combined:
	[http://somesite.com and ''Document Title.'']
so that now, the last character is not sepc but is ] (unless sepc == ']' which breaks the external link)
]]
function safejoin( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';
	local comp = '';
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then
			str = value;
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then
				-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
			else
				comp = value;
			end
			
			if comp:sub(1,1) == duplicate_char then
				trim = false;
				end_chr = str:sub(-1,-1);
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
				if end_chr == duplicate_char then
					str = str:sub(1,-2);
				elseif end_chr == &quot;'&quot; then
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
						str = str:sub(1, -4) .. &quot;''&quot;;
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
						trim = true;
					end
				elseif end_chr == &quot;]&quot; then
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
						trim = true;
					end
				elseif end_chr == &quot; &quot; then
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
						str = str:sub(1,-3);
					end
				end

				if trim then
					if value ~= comp then 
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
					else
						value = value:sub( 2, -1 );
					end
				end
			end
			str = str .. value;
		end
	end
	return str;
end  

-- Attempts to convert names to initials.
function reducetoinitials(first)
	local initials = {}
	local i = 0;										-- counter for number of initials
	for word in string.gmatch(first, &quot;%S+&quot;) do
		table.insert(initials, string.sub(word,1,1))	-- Vancouver format does not include full stops.
		i = i + 1;										-- bump the counter 
		if 2 &lt;= i then break; end						-- only two initials allowed in Vancouver system; if 2, quit
	end
	return table.concat(initials)						-- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
	local sep = control.sep;
	local namesep = control.namesep
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}
	local etal = false;
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if maximum ~= nil and maximum &lt; 1 then return &quot;&quot;, 0; end
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if maximum ~= nil and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
					one = one .. namesep .. first 
				end
				if is_set(person.link) then one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot; end
				if is_set(person.link) and nil ~= person.link:find(&quot;//&quot;) then one = one .. &quot; &quot; .. seterror( 'bad_authorlink' ) end	-- check for url in author link;
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;
		end
		text[#text] = nil; 
	end
	
	local result = table.concat(text) -- construct list
	if etal then 
		local etal_text = cfg.messages['et al'];
		result = result .. &quot; &quot; .. etal_text;
	end
	
	-- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
	if ( &quot;scap&quot; == format ) then result = 
		'&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
	end 
	return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
	return &quot;CITEREF&quot; .. table.concat( options );
end

--[[
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.
]]
--Original function
function extractnames(args, list_name)
    local names = {};
    local i = 1;
    local last;
 
    while true do
        last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );
        if not is_set(last) then
            -- just in case someone passed in an empty parameter
            break;
        end
        names[i] = {
            last = last,
            first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i ),
            link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ),
            mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i )
        };
        i = i + 1;
    end
    return names;
end

--[[ Broken.  Editor CITEREF IDs are broken by this code (no editor list). Author CITEREF ID render correctly
function extractnames(args, list_name)
	local names = {};			-- table of names
	local i = 1;				-- loop counter/indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	
	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary

	while true do
		names[i] =				-- search through args for name components beginning at 1
			{
			last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i ),
			first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i ),
			link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ),
			mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i )
			};
		if names[i].first and not names[i].last then							-- if there is a firstn without a matching lastn
			names[i].first = nil;												-- set first to nil so we don't confuse the implicit et al message code
			table.insert( z.message_tail, { seterror( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
			break;																-- and done because lastn not found
		elseif not names[i].first and not names[i].last then					-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 == count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- last with or without a first
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { seterror( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- bump to the next name
	end
	return names;																-- all done, return our list of names
end
]]



-- Populates ID table from arguments using configuration settings
function extractids( args )
	local id_list = {};
	for k, v in pairs( cfg.id_handlers ) do	
		v = selectone( args, v.parameters, 'redundant_parameters' );
		if is_set(v) then id_list[k] = v; end
	end
	return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
	local new_list, handler = {};
	
	function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, externallinkid( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internallinkid( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internallinkid( handler );
			if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
	local value = nil;
	local selected = '';
	local error_list = {};
	
	if index ~= nil then index = tostring(index); end
	
	-- Handle special case of &quot;#&quot; replaced by empty string
	if index == '1' then
		for _, v in ipairs( possible ) do
			v = v:gsub( &quot;#&quot;, &quot;&quot; );
			if is_set(args[v]) then
				if value ~= nil and selected ~= v then
					table.insert( error_list, v );
				else
					value = args[v];
					selected = v;
				end
			end
		end		
	end
	
	for _, v in ipairs( possible ) do
		if index ~= nil then
			v = v:gsub( &quot;#&quot;, index );
		end
		if is_set(args[v]) then
			if value ~= nil and selected ~=  v then
				table.insert( error_list, v );
			else
				value = args[v];
				selected = v;
			end
		end
	end
	
	if #error_list &gt; 0 then
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap( 'parameter', k );
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap( 'parameter', selected );
		table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
function COinS(data)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end
	
	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
			end
		end
	});
	
	if is_set(data.Chapter) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Chapter;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	elseif is_set(data.Periodical) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
		OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	else
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
	end
	
	OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
	OCinSoutput[&quot;rft.date&quot;] = data.Date;
	OCinSoutput[&quot;rft.series&quot;] = data.Series;
	OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
	OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
	OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
	OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
	OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
	
	for k, v in pairs( data.ID_list ) do
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
	
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = v.last, v.first;
		if k == 1 then
			if is_set(last) then
				OCinSoutput[&quot;rft.aulast&quot;] = last;
			end
			if is_set(first) then 
				OCinSoutput[&quot;rft.aufirst&quot;] = first;
			end
		end
		if is_set(last) and is_set(first) then
			OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
		elseif is_set(last) then
			OCinSoutput[&quot;rft.au&quot;] = last;
		end
	end
	
	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end

--[[
This is the main function doing the majority of the citation
formatting.
]]
function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple
	aliases to single internal variable.
	]]
	local A = argument_wrapper( args );

	local i 
	local PPrefix = A['PPrefix']
	local PPPrefix = A['PPPrefix']
	if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
	
	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local Authors = A['Authors'];
	local a = extractnames( args, 'AuthorList' );

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];
	local Editors = A['Editors'];
	local e = extractnames( args, 'EditorList' );

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
	local Chapter = A['Chapter'];
	local ChapterLink = A['ChapterLink'];
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveURL = A['ArchiveURL'];
	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');
	local Periodical = A['Periodical'];

	local Series = A['Series'];
	local Volume = A['Volume'];
	local Issue = A['Issue'];
	local Position = '';
	local Page = A['Page'];
	local Pages = hyphentodash( A['Pages'] );	
	local At = A['At'];

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
	local SubscriptionRequired = A['SubscriptionRequired'];
	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local ArchiveDate = A['ArchiveDate'];
	local Agency = A['Agency'];
	local DeadURL = A['DeadURL']
	local Language = A['Language'];
	local Format = A['Format'];
	local Ref = A['Ref'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
	local Embargo = A['Embargo'];

	local ID_list = extractids( args );
--[[ Hide unfinished cite newsgroup code so that long delayed update can take place
	-- special case for cite newsgroup which uses |id= for a usenet article or post id
	-- |id= is not included in COinS so here we convert it to an ID that will be included in COinS
	if ('newsgroup' == config.CitationClass) and (is_set (ID)) then
		ID_list['USENETID']=ID;			-- add this new 'id' to the list of IDs
		ID = '';						-- and unset
	end
]]	
	local Quote = A['Quote'];
	local PostScript = A['PostScript'];

	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');
	local sepc = A['Separator'];

	local LastAuthorAmp = A['LastAuthorAmp'];
	local no_tracking_cats = A['NoTracking'];

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Cointerviewers = A['Cointerviewers'];			-- deprecated
	local Interviewer = A['Interviewer'];				-- deprecated
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local page_type;									-- is this needed?  Doesn't appear to be used anywhere;
	local use_lowercase = ( sepc ~= '.' );
	local this_page = mw.title.getCurrentTitle();		--Also used for COinS and for language
	local anchor_year;									-- used in the CITEREF identifier
	local COinS_date;									-- used in the COinS metadata

-- Set postscript default.
	if not is_set (PostScript) then						-- if |postscript= has not been set (Postscript is nil which is the default for {{citation}}) and
		if (config.CitationClass ~= &quot;citation&quot;) then	-- this template is not a citation template
			PostScript = '.';							-- must be a cite xxx template so set postscript to default (period)
		end
	else
		if PostScript:lower() == 'none' then			-- if |postscript=none then
			PostScript = '';							-- no postscript
		end
	end

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories.
	if not is_set(no_tracking_cats) then				-- ignore if we are already not going to categorize this page
		for k, v in pairs( cfg.uncategorized_namespaces ) do	-- otherwise, spin through the list of namespaces we don't include in error categories
			if this_page.nsText == v then				-- if we find one
				no_tracking_cats = &quot;true&quot;;				-- set no_tracking_cats
				break;									-- and we're done
			end
		end
	end

-- check for extra |page=, |pages= or |at= parameters. 
	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Page = Page .. &quot; &quot; .. seterror('extra_pages');	-- add error message
			Pages = '';										-- unset the others
			At = '';
		end
	elseif is_set(Pages) then
		if is_set(At) then
			Pages = Pages .. &quot; &quot; .. seterror('extra_pages');	-- add error messages
			At = '';											-- unset
		end
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped

All other combinations of |encyclopedia, |title, and |article are not modified
]]
	if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
		if is_set(Periodical) then					-- Periodical is set when |encyclopedia is set
			if is_set(Title) then
				if not is_set(Chapter) then
					Chapter = Title;				-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					TransChapter = TransTitle;
					Title = Periodical;
					Periodical = '';				-- redundant so unset
					TransTitle = '';				-- redundant so unset
				end
			else									-- |title not set
				Title = Periodical;					-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';					-- redundant so unset
			end
		end
	end

--special cases for citation.
	if (config.CitationClass == &quot;citation&quot;) then		-- for citation templates
		if not is_set (Ref) then						-- if |ref= is not set
			Ref = &quot;harv&quot;;								-- set default |ref=harv
		end
		if not is_set (sepc) then						-- if |separator= is not set
			sepc = ',';									-- set citation separator to its default (comma)
		end
	else												-- not a citation template
		if not is_set (sepc) then						-- if |separator= has not been set
			sepc = '.';									-- set cite xxx separator to its default (period)
		end
	end

-- check for special case where |separator=none
	if 'none' == sepc:lower() then						-- if |separator=none
		sepc = '';										-- then set it to an empty string
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then	-- special case for cite techreport
		if is_set(Issue) then						-- cite techreport uses 'number', which other citations aliase to 'issue'
			if not is_set(ID) then					-- can we use ID for the &quot;number&quot;?
				ID = Issue;							-- yes, use it
				Issue = &quot;&quot;;							-- unset Issue so that &quot;number&quot; isn't duplicated in the rendered citation or COinS metadata
			else									-- can't use ID so emit error message
				ID = ID .. &quot; &quot; .. seterror('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Interviewer) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Interviewer;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Interviewer;
			end
			if is_set(Cointerviewers) then
				Others = Others .. sepc .. ' ' .. Cointerviewers;
			end
		else
			Others = '(Interview)';
		end
	end

--Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set
	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_embargoed(Embargo) then
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];	-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];		-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
--TODO: if this is only for {{cite conference}}, shouldn't we be checking? (if config.CitationClass=='conference' then ...)
	if is_set(BookTitle) then
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = BookTitle;
		TitleLink = '';
		TransTitle = '';
	end

-- Account for the oddity that is {{cite episode}}, before generation of COinS data.
--[[	-- {{cite episode}} is not currently supported by this module
	if config.CitationClass == &quot;episode&quot; then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];
		local Season = A['Season'];
		local SeriesNumber = A['SeriesNumber'];
		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
		local Sep = (first_set(A[&quot;SeriesSeparator&quot;], A[&quot;Separator&quot;]) or &quot;&quot;) .. &quot; &quot;;
		
		if is_set(Issue) then table.insert(s, cfg.messages[&quot;episode&quot;] .. &quot; &quot; .. Issue); Issue = ''; end
		if is_set(Season) then table.insert(s, cfg.messages[&quot;season&quot;] .. &quot; &quot; .. Season); end
		if is_set(SeriesNumber) then table.insert(s, cfg.messages[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber); end
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		
		Date = Date or AirDate;
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = Series;
		TitleLink = SeriesLink;
		TransTitle = '';
		
		Series = table.concat(s, Sep);
		ID = table.concat(n, Sep);
	end
-- end of {{cite episode}} stuff]]

-- legacy: promote concatenation of |day=, |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set(Date) then
		Date = Year;						-- promote Year to Date
		Year = nil;							-- make nil so Year as empty string isn't used for CITEREF
		if is_set(Date) then
			local Month = A['Month'];
			if is_set(Month) then
				Date = Month .. &quot; &quot; .. Date;
				local Day = A['Day']
				if is_set(Day) then Date = Day .. &quot; &quot; .. Date end
			end
		elseif is_set(PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;			-- promote PublicationDate to Date
			PublicationDate = '';			-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end	-- if PublicationDate is same as Date, don't display in rendered citation


--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	anchor_year, COinS_date, error_message = dates({['accessdate']=AccessDate, ['airdate']=AirDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
		['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});
	if is_set(error_message) then
		table.insert( z.message_tail, { seterror( 'bad_date', {error_message}, true ) } );	-- add this error message
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for
	-- automated parsing of citation information.
	local OCinSoutput = COinS{
		['Periodical'] = Periodical,
		['Chapter'] = Chapter,
		['Title'] = Title,
		['PublicationPlace'] = PublicationPlace,
		['Date'] = first_set(COinS_date, Date),		-- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here?  Should we be including invalid dates in metadata?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set(Page, Pages, At)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set( URL, ChapterURL ),
		['Authors'] = a,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	};

	if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = '';
		TitleLink = '';
		TransTitle = '';
	end
--[[ Hide unfinished cite newsgroup code so that long delayed update can take place
-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername and ID
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = '[Newsgroup]:&amp;nbsp;' ..  externallink( 'news:' .. PublisherName, PublisherName );
		end
	end
]]


	-- Now perform various field 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 not is_set(Authors) then
		local Maximum = tonumber( A['DisplayAuthors'] );
		
		-- Preserve old-style implicit et al.
		if not is_set(Maximum) and #a == 9 then 
			Maximum = 8;
			table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
		elseif not is_set(Maximum) then
			Maximum = #a + 1;
		end
			
		local control = { 
			sep = A[&quot;AuthorSeparator&quot;] .. &quot; &quot;,
			namesep = (first_set(A[&quot;AuthorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
			format = A[&quot;AuthorFormat&quot;],
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp
		};
		
		-- If the coauthor field is also used, prevent ampersand and et al. formatting.
		if is_set(Coauthors) then
			control.lastauthoramp = nil;
			control.maximum = #a + 1;
		end
		
		Authors = listpeople(control, a) 
	end

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { seterror('coauthors_missing_author', {}, true) } );	-- emit error message
	end

	local EditorCount
	if not is_set(Editors) then
		local Maximum = tonumber( A['DisplayEditors'] );
		-- Preserve old-style implicit et al.
		if not is_set(Maximum) and #e == 4 then 
			Maximum = 3;
			table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
		elseif not is_set(Maximum) then
			Maximum = #e + 1;
		end

		local control = { 
			sep = A[&quot;EditorSeparator&quot;] .. &quot; &quot;,
			namesep = (first_set(A[&quot;EditorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
			format = A['EditorFormat'],
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp
		};

		Editors, EditorCount = listpeople(control, e);
	else
		EditorCount = 1;
	end

	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	if config.CitationClass == &quot;map&quot; then
		if not is_set( Authors ) and is_set( PublisherName ) then
			Authors = PublisherName;
			PublisherName = &quot;&quot;;
		end
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap( 'cartography', Cartography, use_lowercase );
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end		
	end
	
	if  not is_set(URL) and
		not is_set(ChapterURL) and
		not is_set(ArchiveURL) and
		not is_set(ConferenceURL) and
		not is_set(TranscriptURL) then
		
		-- Test if cite web or cite podcast |url= is missing or empty 
		if inArray(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;}) then	
			table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
		end
		
		-- Test if accessdate is given without giving a URL
		if is_set(AccessDate) then
			table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
		
		-- Test if format is given without giving a URL
		if is_set(Format) then
			Format = Format .. seterror( 'format_missing_url' );
		end
	end
	
	-- Test if citation has no title
	if  not is_set(Chapter) and
		not is_set(Title) and
		not is_set(Periodical) and
		not is_set(Conference) and
		not is_set(TransTitle) and
		not is_set(TransChapter) then
		table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
	end
	
	Format = is_set(Format) and &quot; (&quot; .. Format .. &quot;)&quot; or &quot;&quot;;
	
	local OriginalURL = URL
	DeadURL = DeadURL:lower();
	if is_set( ArchiveURL ) then
		if ( DeadURL ~= &quot;no&quot; ) then
			URL = ArchiveURL
			URLorigin = A:ORIGIN('ArchiveURL')
		end
	end
	
	-- Format chapter / article title
	if is_set(Chapter) and is_set(ChapterLink) then 
		Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot;;
	end
	if is_set(Periodical) and is_set(Title) then
		Chapter = wrap( 'italic-title', Chapter );
		TransChapter = wrap( 'trans-italic-title', TransChapter );
	else
		Chapter = kern_quotes (Chapter);				-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
		Chapter = wrap( 'quoted-title', Chapter );
		TransChapter = wrap( 'trans-quoted-title', TransChapter );
	end
	
	local TransError = &quot;&quot;
	if is_set(TransChapter) then
		if not is_set(Chapter) then
			TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
		else
			TransChapter = &quot; &quot; .. TransChapter;
		end
	end
	
	Chapter = Chapter .. TransChapter;
	
	if is_set(Chapter) then
		if not is_set(ChapterLink) then
			if is_set(ChapterURL) then
				Chapter = externallink( ChapterURL, Chapter ) .. TransError;
				if not is_set(URL) then
					Chapter = Chapter .. Format;
					Format = &quot;&quot;;
				end
			elseif is_set(URL) then 
				Chapter = externallink( URL, Chapter ) .. TransError .. Format;
				URL = &quot;&quot;;
				Format = &quot;&quot;;
			else
				Chapter = Chapter .. TransError;
			end			
		elseif is_set(ChapterURL) then
			Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. 
				TransError;
		else
			Chapter = Chapter .. TransError;
		end
		Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
	elseif is_set(ChapterURL) then
		Chapter = &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. sepc .. &quot; &quot;;
	end		
	
	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end
	
	if is_set(Periodical) then
		Title = kern_quotes (Title);				-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
		Title = wrap( 'quoted-title', Title );
		TransTitle = wrap( 'trans-quoted-title', TransTitle );
--[[ Hide unfinished cite newsgroup code so that long delayed update can take place
	elseif inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;pressrelease&quot;,&quot;conference&quot;,&quot;podcast&quot;,&quot;newsgroup&quot;}) and
]]	elseif inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;pressrelease&quot;,&quot;conference&quot;,&quot;podcast&quot;}) and
			not is_set(Chapter) then
		Title = kern_quotes (Title);				-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
		Title = wrap( 'quoted-title', Title );
		TransTitle = wrap( 'trans-quoted-title', TransTitle );
	else
		Title = wrap( 'italic-title', Title );
		TransTitle = wrap( 'trans-italic-title', TransTitle );
	end
	
	TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if not is_set(Title) then
			TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
		else
			TransTitle = &quot; &quot; .. TransTitle;
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then 
			Title = externallink( URL, Title ) .. TransError .. Format	   
			URL = &quot;&quot;;
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end
	
	if is_set(Place) then
		Place = &quot; &quot; .. wrap( 'written', Place, use_lowercase ) .. sepc .. &quot; &quot;;
	end
	
	if is_set(Conference) then
		if is_set(ConferenceURL) then
			Conference = externallink( ConferenceURL, Conference );
		end
		Conference = sepc .. &quot; &quot; .. Conference
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. externallink( ConferenceURL, nil, ConferenceURLorigin );
	end
	
	if not is_set(Position) then
		local Minutes = A['Minutes'];
		if is_set(Minutes) then
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			local Time = A['Time'];
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end
	
	if not is_set(Page) then
		if is_set(Pages) then
			if is_set(Periodical) and
				not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
				Pages = &quot;: &quot; .. Pages;
			elseif tonumber(Pages) ~= nil then
				Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
			else
				Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
			end
		end
	else
		if is_set(Periodical) and
			not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
			Page = &quot;: &quot; .. Page;
		else
			Page = sepc ..&quot; &quot; .. PPrefix .. Page;
		end
	end
	
	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Inset = A['Inset'];
		if first_set( Pages, Page, At ) ~= nil or sepc ~= '.' then
			if is_set( Section ) then
				Section = &quot;, &quot; .. wrap( 'section', Section, true );
			end
			if is_set( Inset ) then
				Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
			end
		else
			if is_set( Section ) then
				Section = sepc .. &quot; &quot; .. wrap( 'section', Section, use_lowercase );
				if is_set( Inset ) then
					Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
				end
			elseif is_set( Inset ) then
				Inset = sepc .. &quot; &quot; .. wrap( 'inset', Inset, use_lowercase );
			end			
		end			
		At = At .. Section .. Inset;		
	end	

	--[[Look in the list of iso639-1 language codes to see if the value provided in the language parameter matches one of them.  If a match is found, 
	use that value; if not, then use the value that was provided with the language parameter.
	
	Categories are assigned in a manner similar to the {{xx icon}} templates - categorizes only mainspace citations and only when the language code is not 'en' (English).
	]]
	if is_set (Language) then
--		local name = mw.language.fetchLanguageName( Language:lower(), &quot;en&quot; );	-- experiment: this seems to return correct ISO 639-1 language names
		local name = cfg.iso639_1[Language:lower()];		-- get the language name if Language parameter has a valid iso 639-1 code
		if nil == name then
			Language=&quot; &quot; .. wrap( 'language', Language );	-- no match, use parameter's value
		else
			if 0 == this_page.namespace and 'en' ~= Language:lower() then	--found a match; is this page main / article space and English not the language?
				Language=&quot; &quot; .. wrap( 'language', name .. '[[Category:Articles with ' .. name .. '-language external links]]' );	-- in main space and not English: categorize
			else
				Language=&quot; &quot; .. wrap( 'language', name );	--not in mainspace or language is English so don't categorize
			end
		end
	else
		Language=&quot;&quot;;	-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;

-- handle type parameter for those CS1 citations that have default values

	if inArray(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then	-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then					-- if type parameter is specified
		TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot;;	-- display it in parentheses
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	Edition = is_set(Edition) and (&quot; &quot; .. wrap( 'edition', Edition )) or &quot;&quot;;
	Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc ..&quot; &quot; .. Volume;
		  else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
		end
	end

--[[ This code commented out while discussion continues until after week of 2014-03-23 live module update;
	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc .. &quot; &quot; .. Volume;
		  else
			  Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
			  if is_set(Series) then Volume = sepc .. Volume;
			  end
		end
	end
]]	
	------------------------------------ totally unrelated data
	--[[ Loosely mimic {{subscription required}} template; Via parameter identifies a delivery source that is not the publisher; these sources often, but not always, exist
	behind a registration or paywall.  So here, we've chosen to decouple via from subscription (via has never been part of the registration required template).
	
	Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link note is displayed. There are no error messages for this condition.
	]]
	if is_set(Via) then
		Via = &quot; &quot; .. wrap( 'via', Via );
	end

	if is_set(SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription']; --here when 'via' parameter not used but 'subscription' is
	elseif is_set(RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration']; --here when 'via' and 'subscription' parameters not used but 'registration' is
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
		AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
			.. substitute( retrv_text, {AccessDate} ) .. '&lt;/span&gt;'
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end

	
	ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo} );

	if is_set(URL) then
		URL = &quot; &quot; .. externallink( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
			Quote = Quote:sub(2,-2);
		end
		Quote = sepc ..&quot; &quot; .. wrap( 'quoted-text', Quote ); 
		PostScript = &quot;&quot;;							-- CS1 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = seterror('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ externallink( ArchiveURL, arch_text ), ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text,
				{ externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ seterror('archive_missing_url'), ArchiveDate } );
		end
	else
		Archived = &quot;&quot;
	end
	
	local Lay
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
		end			
	else
		Lay = &quot;&quot;;
	end
	
	if is_set(Transcript) then
		if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
	elseif is_set(TranscriptURL) then
		Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
	end
	
	local Publisher;
	if is_set(Periodical) and
		not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap( 'published', PublicationDate );
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap( 'published', PublicationDate ) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap( 'italic-title', Periodical ) 
		else 
			Periodical = wrap( 'italic-title', Periodical )
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon
	if inArray(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, 
			Language, Cartography, Edition, Publisher, Agency, Volume, Issue}, sepc );
	else 
		tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, Language, 
			Volume, Issue, Others, Cartography, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Page .. Pages .. At;
	
	if is_set(Authors) then
		if is_set(Coauthors) then
			Authors = Authors .. A['AuthorSeparator'] .. &quot; &quot; .. Coauthors
		end
		if is_set(Date) then
			Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		elseif string.sub(Authors,-1,-1) == sepc then
			Authors = Authors .. &quot; &quot;
		else
			Authors = Authors .. sepc .. &quot; &quot;
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			if (sepc ~= '.') then in_text = in_text:lower() end
			Editors = in_text .. Editors .. post_text;
			if (string.sub(Editors,-1,-1) == sepc)
				then Editors = Editors .. &quot; &quot;
				else Editors = Editors .. sepc .. &quot; &quot;
			end
		end
		text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
		text = safejoin( {text, pgtext, idcommon}, sepc );
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
		text = safejoin( {text, pgtext, idcommon}, sepc );
	else
		if is_set(Date) then
			if ( string.sub(tcommon,-1,-1) ~= sepc )
			  then Date = sepc ..&quot; &quot; .. Date .. OrigYear
			  else Date = &quot; &quot; .. Date .. OrigYear
			end
		end
		if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
			text = safejoin( {Chapter, Place, tcommon}, sepc );
			text = safejoin( {text, pgtext, Date, idcommon}, sepc );
		else
			text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
			text = safejoin( {text, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
--		text = text:sub(1,-2);	--Remove final separator (assumes that sepc is only one character)
	end	
	
	text = safejoin( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;span/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = &quot;citation &quot; .. config.CitationClass;
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
		local id = Ref
		if ( &quot;harv&quot; == Ref ) then
			local names = {} --table of last names &amp; year
			if #a &gt; 0 then
				for i,v in ipairs(a) do 
					names[i] = v.last 
					if i == 4 then break end
				end
			elseif #e &gt; 0 then
				for i,v in ipairs(e) do 
					names[i] = v.last 
					if i == 4 then break end				
				end
			end
			names[ #names + 1 ] = first_set(Year, anchor_year);	-- Year first for legacy citations
			id = anchorid(names)
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = seterror('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then 
		text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	else
		text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	end		

	local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
	
	-- Note: Using display: none on then COinS span breaks some clients.
	local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
	text = text .. OCinS;
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. errorcomment( v[1], v[2] );
				else
					text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if inArray(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
	local pframe = frame:getParent()
	
	if nil ~= string.find( frame:getTitle(), 'sandbox', 1, true ) then				-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData( 'Module:Citation/CS1/Configuration/sandbox' );	-- load sandbox versions of Configuration and Whitelist and ...
		whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist/sandbox' );
		dates = require('Module:Citation/CS1/Date_validation/sandbox').dates	-- ... sandbox version of date validation code
	else																	-- otherwise
		cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );			-- load live versions of Configuration and Whitelist and ...
		whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );
		dates = require('Module:Citation/CS1/Date_validation').dates		-- ... live version of date validation code
	end
	
	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = seterror( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if #suggestions == 0 then
						suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
					end
					if suggestions[ k:lower() ] ~= nil then
						error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
					else
						error_text, error_state = seterror( 'parameter_ignored', {k}, true );
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	
	
	return citation0( config, args)
end

return z</text>
      <sha1>pvrwtjy3ythuh4lxlfvw2nah364kp6c</sha1>
    </revision>
    <revision>
      <id>4679</id>
      <parentid>4678</parentid>
      <timestamp>2014-10-11T12:17:50Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4679</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="95554" sha1="638wlaodcyyptetedxxmm4dwbdptlt2" xml:space="preserve">
local z = {
	error_categories = {};		-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};		-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};		-- for categorizing citations based on certain properties, language of source for instance
}

-- Whether variable is set or not
function is_set( var )
	return not (var == nil or var == '');
end

-- First set variable or nil if none
function first_set(...)
	local list = {...};
	for _, var in pairs(list) do
		if is_set( var ) then
			return var;
		end
	end
end

-- Whether needle is in haystack
function inArray( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end

--[[
Categorize and emit an error message when the citation contains one or more deprecated parameters.  Because deprecated parameters (currently |day=, |month=,
|coauthor=, and |coauthors=) aren't related to each other and because these parameters may be concatenated into the variables used by |date= and |author#= (and aliases)
details of which parameter caused the error message are not provided.  Only one error message is emitted regardless of the number of deprecated parameters in the citation.
]]
function deprecated_parameter()
	if true ~= Page_in_deprecated_cat then	-- if we haven't been here before then set a 
		Page_in_deprecated_cat=true;		-- sticky flag so that if there are more than one deprecated parameter the category is added only once
		table.insert( z.message_tail, { seterror( 'deprecated_params', {}, true ) } );		-- add error message
	end
end

-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
--	return args and tostring( mw.message.newRawMessage( msg, args ) ) or msg;
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[
Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern  either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
]]
function kern_quotes (str)
	local left='&lt;span style=&quot;padding-left:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains leading single or double quote mark
	local right='&lt;span style=&quot;padding-right:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains trailing single or double quote mark
	
	if  str:match (&quot;^[\&quot;\'][^\']&quot;) then
		str = string.gsub( str, &quot;^[\&quot;\']&quot;, left, 1 );				-- replace (captured) leading single or double quote with left-side &lt;span&gt;
	end
	if str:match (&quot;[^\'][\&quot;\']$&quot;) then
		str = string.gsub( str, &quot;[\&quot;\']$&quot;, right, 1 );			-- replace (captured) trailing single or double quote with right-side &lt;span&gt;
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

At this writing, only |script-title= is supported.  It is anticipated that additional parameters will be created to use this function.

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
			if inArray (lang, {'ar', 'ja', 'ko', 'he', 'zh'}) then				-- is prefix one of these language codes?
				table.insert( z.properties_cats, 'CS1 uses ' .. name .. '-language script ('..lang..')');	-- categorize in language-specific categories
			else
				table.insert( z.properties_cats, 'CS1 uses foreign language script');	-- use this category as a catchall until language-specific category is available
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = '&lt;bdi' .. lang .. '&gt;' .. script_value .. '&lt;/bdi&gt;';			-- isolate incase script is rlt

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end

-- Wraps a string using a message_list configuration taking one argument
function wrap( key, str, lower )
	if not is_set( str ) then
		return &quot;&quot;;
	elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safeforitalics( str );
	end
	if lower == true then
		return substitute( cfg.messages[key]:lower(), {str} );
	else
		return substitute( cfg.messages[key], {str} );
	end		
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = selectone( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
]]
function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
	return wrap( hidden and 'hidden-error' or 'visible-error', content );
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return errorcomment( message, error_state.hidden );
end

-- Formats a wiki style external link
function externallinkid(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

-- Formats a wiki style internal link
function internallinkid(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

-- Format an external link with error checking
function externallink( URL, label, source )
	local error_str = &quot;&quot;;
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = seterror( 'bare_url_missing_title', { wrap( 'parameter', source ) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not checkurl( URL ) then
		error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
	end
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safeforurl( label ), &quot;]&quot;, error_str });
end

-- Formats a link to Amazon
function amazon(id, domain)
	if checkisbn( id ) then														-- see if asin value is a 10-digit isbn
		table.insert( z.maintenance_cats, &quot;CS1 maint: ASIN uses ISBN&quot;);			-- add to maint category so a bot or awb script can replace |asin= with |isbn=
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif inArray (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif inArray (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return externallinkid({link = handler.link,
		label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
		encode=handler.encode, separator = handler.separator})
end

--[[
format and error check arXiv identifier.  There are two valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces
]]

function arxiv (id)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = &quot;&quot;
	
	year, month, version = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d([v%d]*)$&quot;);				-- test for the 9108-0703 format
	if not year then		-- arXiv id is not proper 9108-0703 form
		year, month, version = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d([v%d]*)$&quot;);	-- test for the 0704- format
		if not year then	
			err_cat = ' ' .. seterror( 'bad_arxiv' );							-- arXiv id doesn't match either format
		else	-- id is the 0704- format
			year = tonumber(year);
			month = tonumber(month);
			if ((7 &gt; year) or (1 &gt; month and 12 &lt; month)) or					-- is year invalid or is month invalid? (doesn't test for future years)
				((7 == year) and (4 &gt; month)) or								-- when year is 07, is month invalid (before April)?
				is_set (version) and nil == version:match(&quot;v%d+&quot;) then			-- is version proper format of single 'v' followed by digits?
					err_cat = ' ' .. seterror( 'bad_arxiv' );					-- set error message
			end
		end
	else	-- id is the 9108-0703 format; are the date values ok
		year = tonumber(year);
		month = tonumber(month);
		if ((91 &gt; year and 7 &lt; year) or (1 &gt; month and 12 &lt; month)) or			-- if invalid year or invalid month
			((91 == year and 8 &gt; month) or (7 == year and 3 &lt; month)) or 		-- if years ok, are starting and ending months ok?
				is_set (version) and nil == version:match(&quot;v%d+&quot;) then			-- is version proper format of single 'v' followed by digits?
					err_cat = ' ' .. seterror( 'bad_arxiv' );					-- set error message
		end
	end

	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--[[
Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of the LCCN dictates the character type of the first 1-3 characters; the
rightmost eight are always digits. http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]
function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. seterror( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. seterror( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]
function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmid' );	-- set an error message
		end
	end
	
	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns true; otherwise, returns false because the embargo has expired or |embargo= not set in this cite.
]]
function is_embargoed(embargo)
	if is_set(embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 and tonumber( embargo_date ) &gt;= tonumber( todays_date ) then	--is embargo date is in the future?
			return true;	-- still embargoed
		end
	end
	return false;			-- embargo expired or |embargo= not set
end

--[[
Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future
the PMC identifier will not be linked to the article.  If the embargo specifies a date in the past, or if it is empty or omitted, then
the PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.
]]
function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_embargoed(embargo) then
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	--still embargoed so no external link
	else
		text = externallinkid({link = handler.link, label = handler.label,			--no embargo date, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.

-- DOI names contain two parts: prefix and suffix separated by a forward slash.
--  Prefix: directory indicator '10.' followed by a registrant code
--  Suffix: character string of any length chosen by the registrant

-- This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes,
-- or, if it ends with a period or a comma, this function will emit a bad_doi error message.

-- DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
-- and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely if ever used in doi names.

function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. seterror( 'bad_doi' );
	end
	return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);					-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	else
		return externallinkid({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode}) .. 
			' ' .. seterror( 'bad_ol' );
	end
end

--[[
Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.
]]
function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = externallinkid({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. seterror( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[
This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those citations that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).
]]
function set_titletype(cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;					-- if |type=none then type parameter not displayed
		end
		return title_type;						-- if |type= has been set to any other value use that value
	end

	if &quot;AV-media-notes&quot; == cite_class or &quot;DVD-notes&quot; == cite_class then		-- if this citation is cite AV media notes or cite DVD notes
		return &quot;Media notes&quot;;					-- display AV media notes / DVD media notes annotation

	elseif &quot;podcast&quot; == cite_class then			-- if this citation is cite podcast
		return &quot;Podcast&quot;;						-- display podcast annotation

	elseif &quot;pressrelease&quot; == cite_class then	-- if this citation is cite press release
		return &quot;Press release&quot;;					-- display press release annotation

	elseif &quot;techreport&quot; == cite_class then		-- if this citation is cite techreport
		return &quot;Technical report&quot;;				-- display techreport annotation
	
	elseif &quot;thesis&quot; == cite_class then			-- if this citation is cite thesis (degree option handled after this function returns)
			return &quot;Thesis&quot;;					-- display simple thesis annotation (without |degree= modification)
	end
end

--[[
Determines whether a URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
	-- Protocol-relative or URL scheme
	return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
	return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end


--[[
Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup.
]]
function strip_apostrophe_markup (argument)
	local pattern, c1, c2;
	if not is_set (argument) then return argument; end
	
	while true do																-- look for and remove all 5-apostrophe (bold and italic) markup
		if argument:match (&quot;%'%'%'%'%'&quot;) then										-- is there an instance of bold-italic?
			if argument:match (&quot;%'%'%'%'%'.*%'%'%'%'%'&quot;) then						-- 5, 5
				pattern, c1 = argument:match (&quot;(%'%'%'%'%'(.*)%'%'%'%'%')&quot;);		
				c2 = &quot;&quot;;														-- set to empty string so we do only one replacement at end
			elseif argument:match (&quot;%'%'%'%'%'.*%'%'%'.*%'%'&quot;) then				-- bold italic followed by italic (5, 3, 2)
				pattern, c1, c2 = argument:match (&quot;(%'%'%'%'%'(.*)%'%'%'(.*)%'%')&quot;);
			elseif argument:match (&quot;%'%'%'%'%'.*%'%'.*%'%'%'&quot;) then				-- bold italic followed by bold (5, 2, 3)
				pattern, c1, c2 = argument:match (&quot;(%'%'%'%'%'(.*)%'%'(.*)%'%'%')&quot;);
			elseif argument:match (&quot;%'%'%'.*%'%'.*%'%'%'%'%'&quot;) then				-- bold italic followed by italic (3, 2, 5)
				pattern, c1, c2 = argument:match (&quot;(%'%'%'(.*)%'%'(.*)%'%'%'%'%')&quot;);
			elseif argument:match (&quot;%'%'.*%'%'%'.*%'%'%'%'%'&quot;) then				-- italic followed by bold (2, 3, 5)
				pattern, c1, c2 = argument:match (&quot;(%'%'(.*)%'%'%'(.*)%'%'%'%'%')&quot;);
			end
			argument=argument:gsub(pattern, c1..c2);							-- remove the markup
		else
			break;																-- none or no more 5-apostrophe matches
		end
	end
	while true do																-- look for and remove all 3-apostrophe (bold) markup
		if argument:match (&quot;%'%'%'.*%'%'%'&quot;) then								-- is there an instance of bold?
			pattern, c1 = argument:match (&quot;(%'%'%'(.*)%'%'%')&quot;)
			argument=argument:gsub(pattern, c1);								-- remove the markup
		else
			break;																-- none or no more 3 matches
		end
	end
	while true do																-- look for and remove all 2-apostrophe (italic) markup
		if argument:match (&quot;%'%'.*%'%'&quot;) then									-- is there an instance of italic?
			pattern, c1 = argument:match (&quot;(%'%'(.*)%'%')&quot;)
			argument=argument:gsub(pattern, c1);								-- remove the markup
		else
			break;																-- none or no more 2 matches
		end
	end
	return argument;															-- done
end

--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...
]]

function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end

-- Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.
function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end			-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);	-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end					-- no more urls
		pattern = pattern:gsub(&quot;([%^%$%(%)%%%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);	-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);					-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);						-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end

--[[
ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in checkisbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.
]]
function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of bytes
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end	-- isbn13 begins with 978 or 979
		isbn_str = { isbn_str:byte(1, len) };
		for i, v in ipairs( isbn_str ) do
			temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
		end
		return temp % 10 == 0;
	end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
	--[[ Note: We cannot use &lt;i&gt; for italics, as the expected behavior for
	italics specified by ''...'' in the title is that they will be inverted
	(i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
	tend to interact poorly under Mediawiki's HTML tidy. ]]
	
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end

--[[
Joins a sequence of strings together while checking for duplicate separation characters.

TODO: safejoin() has a flaw where it won't remove the duplicate character from a |title= / |url= combination.
This is because by the time we get here, |title=http://somesite.com and |title=Document Title. have been combined:
	[http://somesite.com and ''Document Title.'']
so that now, the last character is not sepc but is ] (unless sepc == ']' which breaks the external link)
]]
function safejoin( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';
	local comp = '';
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then
			str = value;
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then
				-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
			else
				comp = value;
			end
			
			if comp:sub(1,1) == duplicate_char then
				trim = false;
				end_chr = str:sub(-1,-1);
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
				if end_chr == duplicate_char then
					str = str:sub(1,-2);
				elseif end_chr == &quot;'&quot; then
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
						str = str:sub(1, -4) .. &quot;''&quot;;
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
						trim = true;
					end
				elseif end_chr == &quot;]&quot; then
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
						trim = true;
					end
				elseif end_chr == &quot; &quot; then
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
						str = str:sub(1,-3);
					end
				end

				if trim then
					if value ~= comp then 
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
					else
						value = value:sub( 2, -1 );
					end
				end
			end
			str = str .. value;
		end
	end
	return str;
end  

-- Attempts to convert names to initials.
function reducetoinitials(first)
	local initials = {}
	local i = 0;										-- counter for number of initials
	for word in string.gmatch(first, &quot;%S+&quot;) do
		table.insert(initials, string.sub(word,1,1))	-- Vancouver format does not include full stops.
		i = i + 1;										-- bump the counter 
		if 2 &lt;= i then break; end						-- only two initials allowed in Vancouver system; if 2, quit
	end
	return table.concat(initials)						-- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
	local sep = control.sep;
	local namesep = control.namesep
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}
	local etal = false;
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if maximum ~= nil and maximum &lt; 1 then return &quot;&quot;, 0; end
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if maximum ~= nil and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
					one = one .. namesep .. first 
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;		-- link author/editor if this page is not the author's/editor's page
				end

				if is_set(person.link) and nil ~= person.link:find(&quot;//&quot;) then one = one .. &quot; &quot; .. seterror( 'bad_authorlink' ) end	-- check for url in author link;
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;
		end
		text[#text] = nil; 
	end
	
	local result = table.concat(text) -- construct list
	if etal then 
		local etal_text = cfg.messages['et al'];
		result = result .. &quot; &quot; .. etal_text;
	end
	
	-- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
	if ( &quot;scap&quot; == format ) then result = 
		'&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
	end 
	return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
	return &quot;CITEREF&quot; .. table.concat( options );
end

--[[
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.
]]
function extractnames(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	
	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary

	while true do
		last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { seterror( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 == count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			names[n] = {last = last, first = first, link = link, mask = mask};	-- add this name to our names list
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { seterror( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	return names;																-- all done, return our list of names
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
	local id_list = {};
	for k, v in pairs( cfg.id_handlers ) do	
		v = selectone( args, v.parameters, 'redundant_parameters' );
		if is_set(v) then id_list[k] = v; end
	end
	return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
	local new_list, handler = {};
	
	function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, externallinkid( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internallinkid( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internallinkid( handler );
			if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
	local value = nil;
	local selected = '';
	local error_list = {};
	
	if index ~= nil then index = tostring(index); end
	
	-- Handle special case of &quot;#&quot; replaced by empty string
	if index == '1' then
		for _, v in ipairs( possible ) do
			v = v:gsub( &quot;#&quot;, &quot;&quot; );
			if is_set(args[v]) then
				if value ~= nil and selected ~= v then
					table.insert( error_list, v );
				else
					value = args[v];
					selected = v;
				end
			end
		end		
	end
	
	for _, v in ipairs( possible ) do
		if index ~= nil then
			v = v:gsub( &quot;#&quot;, index );
		end
		if is_set(args[v]) then
			if value ~= nil and selected ~=  v then
				table.insert( error_list, v );
			else
				value = args[v];
				selected = v;
			end
		end
	end
	
	if #error_list &gt; 0 then
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap( 'parameter', k );
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap( 'parameter', selected );
		table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
function COinS(data)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end
	
	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
			end
		end
	});
	
	if is_set(data.Chapter) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Chapter;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	elseif is_set(data.Periodical) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
		OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	else
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
	end
	
	OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
	OCinSoutput[&quot;rft.date&quot;] = data.Date;
	OCinSoutput[&quot;rft.series&quot;] = data.Series;
	OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
	OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
	OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
	OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
	OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
	
	for k, v in pairs( data.ID_list ) do
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
	
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = v.last, v.first;
		if k == 1 then
			if is_set(last) then
				OCinSoutput[&quot;rft.aulast&quot;] = last;
			end
			if is_set(first) then 
				OCinSoutput[&quot;rft.aufirst&quot;] = first;
			end
		end
		if is_set(last) and is_set(first) then
			OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
		elseif is_set(last) then
			OCinSoutput[&quot;rft.au&quot;] = last;
		end
	end
	
	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 code.  Handles the special case that is Norwegian where
ISO639-1 code 'no' is mapped to language name 'Norwegian Bokmål' by Extention:CLDR.

Returns the language name and associated ISO639-1 code.  Because case of the source may be incorrect or different from the case that Wikimedia
uses, the name comparisons are done in lower case and when a match is found, the Wikimedia version (assumed to be correct) is returned along
with the code.  When there is no match, we return the original language name string.

mw.language.fetchLanguageNames() will return a list of languages that aren't part of ISO639-1. Names that aren't ISO639-1 but that are included
in the list will be found if that name is provided in the |language= parameter.  For example, if |language=Samaritan Aramaic, that name will be
found with the associated code 'sam', not an ISO639-1 code.  When names are found and the associated code is not two characters, this function
returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.
]]

function get_iso639_code (lang)
	if 'Norwegian' == lang then
		return lang, 'no';														-- special case related to Wikimedia remap of code 'no' at Extension:CLDR
	end
	
	local languages = mw.language.fetchLanguageNames('en', 'all')				-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() then												-- ISO639-1 codes only
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the ISO639-1 code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for ISO639-1 code
end

--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Get language name from ISO639-1 code value provided.  If a code is valid use the returned name; if not, then use the value that was provided with the language parameter.

There is an exception.  There are three ISO639-1 codes for Norewegian language variants.  There are two official variants: Norwegian Bokmål (code 'nb') and
Norwegian Nynorsk (code 'nn').  The third, code 'no',  is defined by ISO639-1 as 'Norwegian' though in Norway this is pretty much meaningless.  However, it appears
that on enwiki, editors are for the most part unaware of the nb and nn variants (compare page counts for these variants at Category:Articles with non-English-language external links.

Because Norwegian Bokmål is the most common language variant, Media wiki has been modified to return Norwegian Bokmål for ISO639-1 code 'no'. Here we undo that and
return 'Norwegian' when editors use |language=no.  We presume that editors don't know about the variants or can't descriminate between them.

See Help talk:Citation Style_1#An ISO 639-1 language name test

When |language= contains a valid ISO639-1 code, the page is assigned to the category for that code: Category:Norwegian-language sources (no) if
the page is a mainspace page and the ISO639-1 code is not 'en'.  Similarly, if the  parameter is |language=Norwegian, it will be categorized in the same way.

TODO: Error message when language or language code is not ISO639-1?
]]

function language_parameter (lang, namespace)
	local code;			-- the ISO639-1 two character code
	local name;			-- the language name
	local test='';
		
	if 0 == namespace and (('en' == lang:lower()) or ('english' == lang:lower())) then
		table.insert (z.maintenance_cats, 'CS1 maint: English language specified');		-- add maintenance category if |language=English or |language=en in article space
	end

	if 2 == lang:len() then														-- ISO639-1 language code are 2 characters (fetchLanguageName also supports 3 character codes)
		name = mw.language.fetchLanguageName( lang:lower(), &quot;en&quot; );				-- get ISO 639-1 language name if Language is a proper code
	end

	if is_set (name) then														-- if Language specified a valid ISO639-1 code
		code = lang:lower();													-- save it
	else
		name, code = get_iso639_code (lang);									-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
	end

	if is_set (code) then
		if 'no' == code then name = 'Norwegian' end;							-- override wikimedia when code is 'no'
			if 0 == namespace and 'en' ~= code then					-- is this page main / article space and English not the language?
				table.insert( z.properties_cats, 'CS1 ' .. name .. '-language sources (' .. code .. ')');	-- in main space and not English: categorize
			end
		end
	return (&quot; &quot; .. wrap( 'language', name));									-- wrap with '(in ...)'
end




--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------
This is the main function doing the majority of the citation
formatting.
]]
function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple
	aliases to single internal variable.
	]]
	local A = argument_wrapper( args );

	local i 
	local PPrefix = A['PPrefix']
	local PPPrefix = A['PPPrefix']
	if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
	
	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local Authors = A['Authors'];
	local a = extractnames( args, 'AuthorList' );

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];
	local Editors = A['Editors'];
	local e = extractnames( args, 'EditorList' );

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
	local Chapter = A['Chapter'];
	local ChapterLink = A['ChapterLink'];
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveURL = A['ArchiveURL'];
	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');
	local Periodical = A['Periodical'];

	local Series = A['Series'];
	local Volume = A['Volume'];
	local Issue = A['Issue'];
	local Position = '';
	local Page = A['Page'];
	local Pages = hyphentodash( A['Pages'] );	
	local At = A['At'];

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
	local SubscriptionRequired = A['SubscriptionRequired'];
	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local ArchiveDate = A['ArchiveDate'];
	local Agency = A['Agency'];
	local DeadURL = A['DeadURL']
	local Language = A['Language'];
	local Format = A['Format'];
	local Ref = A['Ref'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
	local Embargo = A['Embargo'];

	local ID_list = extractids( args );
--[[ Hide unfinished cite newsgroup code so that long delayed update can take place
	-- special case for cite newsgroup which uses |id= for a usenet article or post id
	-- |id= is not included in COinS so here we convert it to an ID that will be included in COinS
	if ('newsgroup' == config.CitationClass) and (is_set (ID)) then
		ID_list['USENETID']=ID;			-- add this new 'id' to the list of IDs
		ID = '';						-- and unset
	end
]]	
	local Quote = A['Quote'];
	local PostScript = A['PostScript'];

	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');
	local sepc = A['Separator'];

	local LastAuthorAmp = A['LastAuthorAmp'];
	local no_tracking_cats = A['NoTracking'];

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Cointerviewers = A['Cointerviewers'];			-- deprecated
	local Interviewer = A['Interviewer'];				-- deprecated
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local page_type;									-- is this needed?  Doesn't appear to be used anywhere;
	local use_lowercase = ( sepc ~= '.' );
	local this_page = mw.title.getCurrentTitle();		--Also used for COinS and for language
	local anchor_year;									-- used in the CITEREF identifier
	local COinS_date;									-- used in the COinS metadata

-- Set postscript default.
	if not is_set (PostScript) then						-- if |postscript= has not been set (Postscript is nil which is the default for {{citation}}) and
		if (config.CitationClass ~= &quot;citation&quot;) then	-- this template is not a citation template
			PostScript = '.';							-- must be a cite xxx template so set postscript to default (period)
		end
	else
		if PostScript:lower() == 'none' then			-- if |postscript=none then
			PostScript = '';							-- no postscript
		end
	end

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories.
	if not is_set(no_tracking_cats) then				-- ignore if we are already not going to categorize this page
		if inArray (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;					-- set no_tracking_cats
		end
	end

-- check for extra |page=, |pages= or |at= parameters. 
	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Page = Page .. &quot; &quot; .. seterror('extra_pages');	-- add error message
			Pages = '';										-- unset the others
			At = '';
		end
	elseif is_set(Pages) then
		if is_set(At) then
			Pages = Pages .. &quot; &quot; .. seterror('extra_pages');	-- add error messages
			At = '';											-- unset
		end
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped

All other combinations of |encyclopedia, |title, and |article are not modified
]]
	if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
		if is_set(Periodical) then					-- Periodical is set when |encyclopedia is set
			if is_set(Title) then
				if not is_set(Chapter) then
					Chapter = Title;				-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					TransChapter = TransTitle;
					Title = Periodical;
					Periodical = '';				-- redundant so unset
					TransTitle = '';				-- redundant so unset
				end
			else									-- |title not set
				Title = Periodical;					-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';					-- redundant so unset
			end
		end
	end

--special cases for citation.
	if (config.CitationClass == &quot;citation&quot;) then		-- for citation templates
		if not is_set (Ref) then						-- if |ref= is not set
			Ref = &quot;harv&quot;;								-- set default |ref=harv
		end
		if not is_set (sepc) then						-- if |separator= is not set
			sepc = ',';									-- set citation separator to its default (comma)
		end
	else												-- not a citation template
		if not is_set (sepc) then						-- if |separator= has not been set
			sepc = '.';									-- set cite xxx separator to its default (period)
		end
	end

-- check for special case where |separator=none
	if 'none' == sepc:lower() then						-- if |separator=none
		sepc = '';										-- then set it to an empty string
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then	-- special case for cite techreport
		if is_set(Issue) then						-- cite techreport uses 'number', which other citations aliase to 'issue'
			if not is_set(ID) then					-- can we use ID for the &quot;number&quot;?
				ID = Issue;							-- yes, use it
				Issue = &quot;&quot;;							-- unset Issue so that &quot;number&quot; isn't duplicated in the rendered citation or COinS metadata
			else									-- can't use ID so emit error message
				ID = ID .. &quot; &quot; .. seterror('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Interviewer) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Interviewer;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Interviewer;
			end
			if is_set(Cointerviewers) then
				Others = Others .. sepc .. ' ' .. Cointerviewers;
			end
		else
			Others = '(Interview)';
		end
	end

--Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set
	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_embargoed(Embargo) then
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];	-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];		-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
--TODO: if this is only for {{cite conference}}, shouldn't we be checking? (if config.CitationClass=='conference' then ...)
	if is_set(BookTitle) then
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = BookTitle;
		TitleLink = '';
		TransTitle = '';
	end

-- Account for the oddity that is {{cite episode}}, before generation of COinS data.
--[[	-- {{cite episode}} is not currently supported by this module
	if config.CitationClass == &quot;episode&quot; then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];
		local Season = A['Season'];
		local SeriesNumber = A['SeriesNumber'];
		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
		local Sep = (first_set(A[&quot;SeriesSeparator&quot;], A[&quot;Separator&quot;]) or &quot;&quot;) .. &quot; &quot;;
		
		if is_set(Issue) then table.insert(s, cfg.messages[&quot;episode&quot;] .. &quot; &quot; .. Issue); Issue = ''; end
		if is_set(Season) then table.insert(s, cfg.messages[&quot;season&quot;] .. &quot; &quot; .. Season); end
		if is_set(SeriesNumber) then table.insert(s, cfg.messages[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber); end
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		
		Date = Date or AirDate;
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = Series;
		TitleLink = SeriesLink;
		TransTitle = '';
		
		Series = table.concat(s, Sep);
		ID = table.concat(n, Sep);
	end
-- end of {{cite episode}} stuff]]

-- legacy: promote concatenation of |day=, |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set(Date) then
		Date = Year;						-- promote Year to Date
		Year = nil;							-- make nil so Year as empty string isn't used for CITEREF
		if is_set(Date) then
			local Month = A['Month'];
			if is_set(Month) then
				Date = Month .. &quot; &quot; .. Date;
				local Day = A['Day']
				if is_set(Day) then Date = Day .. &quot; &quot; .. Date end
			end
		elseif is_set(PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;			-- promote PublicationDate to Date
			PublicationDate = '';			-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end	-- if PublicationDate is same as Date, don't display in rendered citation


--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	anchor_year, COinS_date, error_message = dates({['accessdate']=AccessDate, ['airdate']=AirDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
		['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});
	if is_set(error_message) then
		table.insert( z.message_tail, { seterror( 'bad_date', {error_message}, true ) } );	-- add this error message
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for
	-- automated parsing of citation information.
	-- this is the function call to COinS()
	local OCinSoutput = COinS{
		['Periodical'] = Periodical,
		['Chapter'] = strip_apostrophe_markup (Chapter),						-- Chapter stripped of bold / italic wikimarkup
		['Title'] = make_coins_title (Title, ScriptTitle),		-- strip_apostrophe_markup (Title),							-- Title stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = first_set(COinS_date, Date),		-- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here?  Should we be including invalid dates in metadata?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set(Page, Pages, At)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set( URL, ChapterURL ),
		['Authors'] = a,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	};
--[[Why is this here?  Why are we mapping Title to Chapter when Periodical is set?
	if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = '';
		TitleLink = '';
		TransTitle = '';
	end
]]
--[[ Hide unfinished cite newsgroup code so that long delayed update can take place
-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername and ID
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = '[Newsgroup]:&amp;nbsp;' ..  externallink( 'news:' .. PublisherName, PublisherName );
		end
	end
]]


	-- Now perform various field 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 not is_set(Authors) then
		local Maximum = tonumber( A['DisplayAuthors'] );
		
		-- Preserve old-style implicit et al.
		if not is_set(Maximum) and #a == 9 then 
			Maximum = 8;
			table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
		elseif not is_set(Maximum) then
			Maximum = #a + 1;
		end
			
		local control = { 
			sep = A[&quot;AuthorSeparator&quot;] .. &quot; &quot;,
			namesep = (first_set(A[&quot;AuthorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
			format = A[&quot;AuthorFormat&quot;],
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text				-- get current page name so that we don't wikilink to it via authorlinkn
		};
		
		-- If the coauthor field is also used, prevent ampersand and et al. formatting.
		if is_set(Coauthors) then
			control.lastauthoramp = nil;
			control.maximum = #a + 1;
		end
		
		Authors = listpeople(control, a) 
	end

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { seterror('coauthors_missing_author', {}, true) } );	-- emit error message
	end

	local EditorCount
	if not is_set(Editors) then
		local Maximum = tonumber( A['DisplayEditors'] );
		-- Preserve old-style implicit et al.
		if not is_set(Maximum) and #e == 4 then 
			Maximum = 3;
			table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
		elseif not is_set(Maximum) then
			Maximum = #e + 1;
		end

		local control = { 
			sep = A[&quot;EditorSeparator&quot;] .. &quot; &quot;,
			namesep = (first_set(A[&quot;EditorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
			format = A['EditorFormat'],
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text				-- get current page name so that we don't wikilink to it via authorlinkn
		};

		Editors, EditorCount = listpeople(control, e);
	else
		EditorCount = 1;
	end

	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	if config.CitationClass == &quot;map&quot; then
		if not is_set( Authors ) and is_set( PublisherName ) then
			Authors = PublisherName;
			PublisherName = &quot;&quot;;
		end
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap( 'cartography', Cartography, use_lowercase );
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end		
	end
	
	if  not is_set(URL) and
		not is_set(ChapterURL) and
		not is_set(ArchiveURL) and
		not is_set(ConferenceURL) and
		not is_set(TranscriptURL) then
		
		-- Test if cite web or cite podcast |url= is missing or empty 
		if inArray(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;}) then	
			table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
		end
		
		-- Test if accessdate is given without giving a URL
		if is_set(AccessDate) then
			table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
		
		-- Test if format is given without giving a URL
		if is_set(Format) then
			Format = Format .. seterror( 'format_missing_url' );
		end
	end
	
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(Periodical) and
		not is_set(Conference) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
		table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
	end
	
	Format = is_set(Format) and &quot; (&quot; .. Format .. &quot;)&quot; or &quot;&quot;;
	
	local OriginalURL = URL
	DeadURL = DeadURL:lower();
	if is_set( ArchiveURL ) then
		if ( DeadURL ~= &quot;no&quot; ) then
			URL = ArchiveURL
			URLorigin = A:ORIGIN('ArchiveURL')
		end
	end
	
	-- Format chapter / article title
	if is_set(Chapter) and is_set(ChapterLink) then 
		Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot;;
	end

	Chapter = kern_quotes (Chapter);				-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
	Chapter = wrap( 'quoted-title', Chapter );
	TransChapter = wrap( 'trans-quoted-title', TransChapter );

	local TransError = &quot;&quot;
	if is_set(TransChapter) then
		if not is_set(Chapter) then
			TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
		else
			TransChapter = &quot; &quot; .. TransChapter;
		end
	end
	
	Chapter = Chapter .. TransChapter;
	
	if is_set(Chapter) then
		if not is_set(ChapterLink) then
			if is_set(ChapterURL) then
				Chapter = externallink( ChapterURL, Chapter ) .. TransError;
				if not is_set(URL) then
					Chapter = Chapter .. Format;
					Format = &quot;&quot;;
				end
			elseif is_set(URL) then 
				Chapter = externallink( URL, Chapter ) .. TransError .. Format;
				URL = &quot;&quot;;
				Format = &quot;&quot;;
			else
				Chapter = Chapter .. TransError;
			end			
		elseif is_set(ChapterURL) then
			Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. 
				TransError;
		else
			Chapter = Chapter .. TransError;
		end
		Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
	elseif is_set(ChapterURL) then
		Chapter = &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. sepc .. &quot; &quot;;
	end		
	
	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;journal&quot;,&quot;pressrelease&quot;,&quot;conference&quot;,&quot;podcast&quot;}) then
		Title = kern_quotes (Title);											-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
		Title = wrap( 'quoted-title', Title );
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap( 'trans-quoted-title', TransTitle );
		Chapter = '';								-- chapter not allowed
	else
		Title = wrap( 'italic-title', Title );
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap( 'trans-italic-title', TransTitle );
	end

	TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then 
			Title = externallink( URL, Title ) .. TransError .. Format	   
			URL = &quot;&quot;;
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end
	
	if is_set(Place) then
		Place = &quot; &quot; .. wrap( 'written', Place, use_lowercase ) .. sepc .. &quot; &quot;;
	end
	
	if is_set(Conference) then
		if is_set(ConferenceURL) then
			Conference = externallink( ConferenceURL, Conference );
		end
		Conference = sepc .. &quot; &quot; .. Conference
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. externallink( ConferenceURL, nil, ConferenceURLorigin );
	end
	
	if not is_set(Position) then
		local Minutes = A['Minutes'];
		if is_set(Minutes) then
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			local Time = A['Time'];
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end
	
	if not is_set(Page) then
		if is_set(Pages) then
			if is_set(Periodical) and
				not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
				Pages = &quot;: &quot; .. Pages;
			elseif tonumber(Pages) ~= nil then
				Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
			else
				Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
			end
		end
	else
		if is_set(Periodical) and
			not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
			Page = &quot;: &quot; .. Page;
		else
			Page = sepc ..&quot; &quot; .. PPrefix .. Page;
		end
	end
	
	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Inset = A['Inset'];
		if first_set( Pages, Page, At ) ~= nil or sepc ~= '.' then
			if is_set( Section ) then
				Section = &quot;, &quot; .. wrap( 'section', Section, true );
			end
			if is_set( Inset ) then
				Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
			end
		else
			if is_set( Section ) then
				Section = sepc .. &quot; &quot; .. wrap( 'section', Section, use_lowercase );
				if is_set( Inset ) then
					Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
				end
			elseif is_set( Inset ) then
				Inset = sepc .. &quot; &quot; .. wrap( 'inset', Inset, use_lowercase );
			end			
		end			
		At = At .. Section .. Inset;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language, this_page.namespace);			-- format, categories (article namespace only), name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;

-- handle type parameter for those CS1 citations that have default values

	if inArray(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then	-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then					-- if type parameter is specified
		TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot;;	-- display it in parentheses
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	Edition = is_set(Edition) and (&quot; &quot; .. wrap( 'edition', Edition )) or &quot;&quot;;
	Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc ..&quot; &quot; .. Volume;
		  else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
		end
	end

--[[ This code commented out while discussion continues until after week of 2014-03-23 live module update;
	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc .. &quot; &quot; .. Volume;
		  else
			  Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
			  if is_set(Series) then Volume = sepc .. Volume;
			  end
		end
	end
]]	
	------------------------------------ totally unrelated data
	--[[ Loosely mimic {{subscription required}} template; Via parameter identifies a delivery source that is not the publisher; these sources often, but not always, exist
	behind a registration or paywall.  So here, we've chosen to decouple via from subscription (via has never been part of the registration required template).
	
	Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link note is displayed. There are no error messages for this condition.
	]]
	if is_set(Via) then
		Via = &quot; &quot; .. wrap( 'via', Via );
	end

	if is_set(SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription']; --here when 'via' parameter not used but 'subscription' is
	elseif is_set(RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration']; --here when 'via' and 'subscription' parameters not used but 'registration' is
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
		AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
			.. substitute( retrv_text, {AccessDate} ) .. '&lt;/span&gt;'
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end

	
	ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo} );

	if is_set(URL) then
		URL = &quot; &quot; .. externallink( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
			Quote = Quote:sub(2,-2);
		end
		Quote = sepc ..&quot; &quot; .. wrap( 'quoted-text', Quote ); 
		PostScript = &quot;&quot;;							-- CS1 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = seterror('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ externallink( ArchiveURL, arch_text ), ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text,
				{ externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ seterror('archive_missing_url'), ArchiveDate } );
		end
	else
		Archived = &quot;&quot;
	end
	
	local Lay
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
		end			
	else
		Lay = &quot;&quot;;
	end
	
	if is_set(Transcript) then
		if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
	elseif is_set(TranscriptURL) then
		Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
	end
	
	local Publisher;
	if is_set(Periodical) and
		not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap( 'published', PublicationDate );
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap( 'published', PublicationDate ) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap( 'italic-title', Periodical ) 
		else 
			Periodical = wrap( 'italic-title', Periodical )
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon
	if inArray(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, 
			Language, Cartography, Edition, Publisher, Agency, Volume, Issue}, sepc );
	else 
		tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, Language, 
			Volume, Issue, Others, Cartography, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Page .. Pages .. At;
	
	if is_set(Authors) then
		if is_set(Coauthors) then
			Authors = Authors .. A['AuthorSeparator'] .. &quot; &quot; .. Coauthors
		end
		if is_set(Date) then
			Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		elseif string.sub(Authors,-1,-1) == sepc then
			Authors = Authors .. &quot; &quot;
		else
			Authors = Authors .. sepc .. &quot; &quot;
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			if (sepc ~= '.') then in_text = in_text:lower() end
			Editors = in_text .. Editors .. post_text;
			if (string.sub(Editors,-1,-1) == sepc)
				then Editors = Editors .. &quot; &quot;
				else Editors = Editors .. sepc .. &quot; &quot;
			end
		end
		text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
		text = safejoin( {text, pgtext, idcommon}, sepc );
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
		text = safejoin( {text, pgtext, idcommon}, sepc );
	else
		if is_set(Date) then
			if ( string.sub(tcommon,-1,-1) ~= sepc )
			  then Date = sepc ..&quot; &quot; .. Date .. OrigYear
			  else Date = &quot; &quot; .. Date .. OrigYear
			end
		end
		if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
			text = safejoin( {Chapter, Place, tcommon}, sepc );
			text = safejoin( {text, pgtext, Date, idcommon}, sepc );
		else
			text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
			text = safejoin( {text, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
--		text = text:sub(1,-2);	--Remove final separator (assumes that sepc is only one character)
	end	
	
	text = safejoin( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;span/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = &quot;citation &quot; .. config.CitationClass;
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
		local id = Ref
		if ( &quot;harv&quot; == Ref ) then
			local names = {} --table of last names &amp; year
			if #a &gt; 0 then
				for i,v in ipairs(a) do 
					names[i] = v.last 
					if i == 4 then break end
				end
			elseif #e &gt; 0 then
				for i,v in ipairs(e) do 
					names[i] = v.last 
					if i == 4 then break end				
				end
			end
			names[ #names + 1 ] = first_set(Year, anchor_year);	-- Year first for legacy citations
			id = anchorid(names)
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = seterror('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then 
		text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	else
		text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	end		

	local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
	
	-- Note: Using display: none on then COinS span breaks some clients.
	local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
	text = text .. OCinS;
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. errorcomment( v[1], v[2] );
				else
					text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if inArray(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
	local pframe = frame:getParent()
	
	if nil ~= string.find( frame:getTitle(), 'sandbox', 1, true ) then				-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData( 'Module:Citation/CS1/Configuration/sandbox' );	-- load sandbox versions of Configuration and Whitelist and ...
		whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist/sandbox' );
		dates = require('Module:Citation/CS1/Date_validation/sandbox').dates	-- ... sandbox version of date validation code
	else																	-- otherwise
		cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );			-- load live versions of Configuration and Whitelist and ...
		whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );
		dates = require('Module:Citation/CS1/Date_validation').dates		-- ... live version of date validation code
	end
	
	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = seterror( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if #suggestions == 0 then
						suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
					end
					if suggestions[ k:lower() ] ~= nil then
						error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
					else
						error_text, error_state = seterror( 'parameter_ignored', {k}, true );
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	
	
	return citation0( config, args)
end

return z</text>
      <sha1>638wlaodcyyptetedxxmm4dwbdptlt2</sha1>
    </revision>
    <revision>
      <id>4680</id>
      <parentid>4679</parentid>
      <timestamp>2014-10-11T12:58:15Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>pattern not a literal string bites again</comment>
      <origin>4680</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="95978" sha1="87ca12r45l3g8puol5mjixvbaum2g1t" xml:space="preserve">
local z = {
	error_categories = {};		-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};		-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};		-- for categorizing citations based on certain properties, language of source for instance
}

-- Whether variable is set or not
function is_set( var )
	return not (var == nil or var == '');
end

-- First set variable or nil if none
function first_set(...)
	local list = {...};
	for _, var in pairs(list) do
		if is_set( var ) then
			return var;
		end
	end
end

-- Whether needle is in haystack
function inArray( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end

--[[
Categorize and emit an error message when the citation contains one or more deprecated parameters.  Because deprecated parameters (currently |day=, |month=,
|coauthor=, and |coauthors=) aren't related to each other and because these parameters may be concatenated into the variables used by |date= and |author#= (and aliases)
details of which parameter caused the error message are not provided.  Only one error message is emitted regardless of the number of deprecated parameters in the citation.
]]
function deprecated_parameter()
	if true ~= Page_in_deprecated_cat then	-- if we haven't been here before then set a 
		Page_in_deprecated_cat=true;		-- sticky flag so that if there are more than one deprecated parameter the category is added only once
		table.insert( z.message_tail, { seterror( 'deprecated_params', {}, true ) } );		-- add error message
	end
end

-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
--	return args and tostring( mw.message.newRawMessage( msg, args ) ) or msg;
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[
Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern  either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
]]
function kern_quotes (str)
	local left='&lt;span style=&quot;padding-left:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains leading single or double quote mark
	local right='&lt;span style=&quot;padding-right:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains trailing single or double quote mark
	
	if  str:match (&quot;^[\&quot;\'][^\']&quot;) then
		str = string.gsub( str, &quot;^[\&quot;\']&quot;, left, 1 );				-- replace (captured) leading single or double quote with left-side &lt;span&gt;
	end
	if str:match (&quot;[^\'][\&quot;\']$&quot;) then
		str = string.gsub( str, &quot;[\&quot;\']$&quot;, right, 1 );			-- replace (captured) trailing single or double quote with right-side &lt;span&gt;
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

At this writing, only |script-title= is supported.  It is anticipated that additional parameters will be created to use this function.

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
			if inArray (lang, {'ar', 'ja', 'ko', 'he', 'zh'}) then				-- is prefix one of these language codes?
				table.insert( z.properties_cats, 'CS1 uses ' .. name .. '-language script ('..lang..')');	-- categorize in language-specific categories
			else
				table.insert( z.properties_cats, 'CS1 uses foreign language script');	-- use this category as a catchall until language-specific category is available
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = '&lt;bdi' .. lang .. '&gt;' .. script_value .. '&lt;/bdi&gt;';			-- isolate incase script is rlt

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end

-- Wraps a string using a message_list configuration taking one argument
function wrap( key, str, lower )
	if not is_set( str ) then
		return &quot;&quot;;
	elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safeforitalics( str );
	end
	if lower == true then
		return substitute( cfg.messages[key]:lower(), {str} );
	else
		return substitute( cfg.messages[key], {str} );
	end		
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = selectone( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
]]
function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
	return wrap( hidden and 'hidden-error' or 'visible-error', content );
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return errorcomment( message, error_state.hidden );
end

-- Formats a wiki style external link
function externallinkid(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

-- Formats a wiki style internal link
function internallinkid(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

-- Format an external link with error checking
function externallink( URL, label, source )
	local error_str = &quot;&quot;;
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = seterror( 'bare_url_missing_title', { wrap( 'parameter', source ) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not checkurl( URL ) then
		error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
	end
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safeforurl( label ), &quot;]&quot;, error_str });
end

-- Formats a link to Amazon
function amazon(id, domain)
	if checkisbn( id ) then														-- see if asin value is a 10-digit isbn
		table.insert( z.maintenance_cats, &quot;CS1 maint: ASIN uses ISBN&quot;);			-- add to maint category so a bot or awb script can replace |asin= with |isbn=
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif inArray (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif inArray (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return externallinkid({link = handler.link,
		label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
		encode=handler.encode, separator = handler.separator})
end

--[[
format and error check arXiv identifier.  There are two valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces
]]

function arxiv (id)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = &quot;&quot;
	
	year, month, version = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d([v%d]*)$&quot;);				-- test for the 9108-0703 format
	if not year then		-- arXiv id is not proper 9108-0703 form
		year, month, version = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d([v%d]*)$&quot;);	-- test for the 0704- format
		if not year then	
			err_cat = ' ' .. seterror( 'bad_arxiv' );							-- arXiv id doesn't match either format
		else	-- id is the 0704- format
			year = tonumber(year);
			month = tonumber(month);
			if ((7 &gt; year) or (1 &gt; month and 12 &lt; month)) or					-- is year invalid or is month invalid? (doesn't test for future years)
				((7 == year) and (4 &gt; month)) or								-- when year is 07, is month invalid (before April)?
				is_set (version) and nil == version:match(&quot;v%d+&quot;) then			-- is version proper format of single 'v' followed by digits?
					err_cat = ' ' .. seterror( 'bad_arxiv' );					-- set error message
			end
		end
	else	-- id is the 9108-0703 format; are the date values ok
		year = tonumber(year);
		month = tonumber(month);
		if ((91 &gt; year and 7 &lt; year) or (1 &gt; month and 12 &lt; month)) or			-- if invalid year or invalid month
			((91 == year and 8 &gt; month) or (7 == year and 3 &lt; month)) or 		-- if years ok, are starting and ending months ok?
				is_set (version) and nil == version:match(&quot;v%d+&quot;) then			-- is version proper format of single 'v' followed by digits?
					err_cat = ' ' .. seterror( 'bad_arxiv' );					-- set error message
		end
	end

	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--[[
Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of the LCCN dictates the character type of the first 1-3 characters; the
rightmost eight are always digits. http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]
function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. seterror( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. seterror( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]
function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmid' );	-- set an error message
		end
	end
	
	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns true; otherwise, returns false because the embargo has expired or |embargo= not set in this cite.
]]
function is_embargoed(embargo)
	if is_set(embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 and tonumber( embargo_date ) &gt;= tonumber( todays_date ) then	--is embargo date is in the future?
			return true;	-- still embargoed
		end
	end
	return false;			-- embargo expired or |embargo= not set
end

--[[
Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future
the PMC identifier will not be linked to the article.  If the embargo specifies a date in the past, or if it is empty or omitted, then
the PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.
]]
function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_embargoed(embargo) then
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	--still embargoed so no external link
	else
		text = externallinkid({link = handler.link, label = handler.label,			--no embargo date, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.

-- DOI names contain two parts: prefix and suffix separated by a forward slash.
--  Prefix: directory indicator '10.' followed by a registrant code
--  Suffix: character string of any length chosen by the registrant

-- This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes,
-- or, if it ends with a period or a comma, this function will emit a bad_doi error message.

-- DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
-- and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely if ever used in doi names.

function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. seterror( 'bad_doi' );
	end
	return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);					-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	else
		return externallinkid({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode}) .. 
			' ' .. seterror( 'bad_ol' );
	end
end

--[[
Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.
]]
function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = externallinkid({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. seterror( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[
This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those citations that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).
]]
function set_titletype(cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;					-- if |type=none then type parameter not displayed
		end
		return title_type;						-- if |type= has been set to any other value use that value
	end

	if &quot;AV-media-notes&quot; == cite_class or &quot;DVD-notes&quot; == cite_class then		-- if this citation is cite AV media notes or cite DVD notes
		return &quot;Media notes&quot;;					-- display AV media notes / DVD media notes annotation

	elseif &quot;podcast&quot; == cite_class then			-- if this citation is cite podcast
		return &quot;Podcast&quot;;						-- display podcast annotation

	elseif &quot;pressrelease&quot; == cite_class then	-- if this citation is cite press release
		return &quot;Press release&quot;;					-- display press release annotation

	elseif &quot;techreport&quot; == cite_class then		-- if this citation is cite techreport
		return &quot;Technical report&quot;;				-- display techreport annotation
	
	elseif &quot;thesis&quot; == cite_class then			-- if this citation is cite thesis (degree option handled after this function returns)
			return &quot;Thesis&quot;;					-- display simple thesis annotation (without |degree= modification)
	end
end

--[[
Determines whether a URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
	-- Protocol-relative or URL scheme
	return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
	return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end


--[[
Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup.
]]
function strip_apostrophe_markup (argument)
	local pattern, c1, c2;
	if not is_set (argument) then return argument; end
	
	while true do																-- look for and remove all 5-apostrophe (bold and italic) markup
		if argument:match (&quot;%'%'%'%'%'&quot;) then										-- is there an instance of bold-italic?
			if argument:match (&quot;%'%'%'%'%'.*%'%'%'%'%'&quot;) then						-- 5, 5
				pattern, c1 = argument:match (&quot;(%'%'%'%'%'(.*)%'%'%'%'%')&quot;);		
				c2 = &quot;&quot;;														-- set to empty string so we do only one replacement at end
			elseif argument:match (&quot;%'%'%'%'%'.*%'%'%'.*%'%'&quot;) then				-- bold italic followed by italic (5, 3, 2)
				pattern, c1, c2 = argument:match (&quot;(%'%'%'%'%'(.*)%'%'%'(.*)%'%')&quot;);
			elseif argument:match (&quot;%'%'%'%'%'.*%'%'.*%'%'%'&quot;) then				-- bold italic followed by bold (5, 2, 3)
				pattern, c1, c2 = argument:match (&quot;(%'%'%'%'%'(.*)%'%'(.*)%'%'%')&quot;);
			elseif argument:match (&quot;%'%'%'.*%'%'.*%'%'%'%'%'&quot;) then				-- bold italic followed by italic (3, 2, 5)
				pattern, c1, c2 = argument:match (&quot;(%'%'%'(.*)%'%'(.*)%'%'%'%'%')&quot;);
			elseif argument:match (&quot;%'%'.*%'%'%'.*%'%'%'%'%'&quot;) then				-- italic followed by bold (2, 3, 5)
				pattern, c1, c2 = argument:match (&quot;(%'%'(.*)%'%'%'(.*)%'%'%'%'%')&quot;);
			end
			pattern = pattern:gsub(&quot;([%^%$%(%)%%%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);		-- pattern is not a literal string; escape lua's magic pattern characters
			argument=argument:gsub(pattern, c1..c2);							-- remove the markup
		else
			break;																-- none or no more 5-apostrophe matches
		end
	end
	while true do																-- look for and remove all 3-apostrophe (bold) markup
		if argument:match (&quot;%'%'%'.*%'%'%'&quot;) then								-- is there an instance of bold?
			pattern, c1 = argument:match (&quot;(%'%'%'(.*)%'%'%')&quot;)
			pattern = pattern:gsub(&quot;([%^%$%(%)%%%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);	-- pattern is not a literal string; escape lua's magic pattern characters
			argument=argument:gsub(pattern, c1);								-- remove the markup
		else
			break;																-- none or no more 3 matches
		end
	end
	while true do																-- look for and remove all 2-apostrophe (italic) markup
		if argument:match (&quot;%'%'.*%'%'&quot;) then									-- is there an instance of italic?
			pattern, c1 = argument:match (&quot;(%'%'(.*)%'%')&quot;)
			pattern = pattern:gsub(&quot;([%^%$%(%)%%%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);	-- pattern is not a literal string; escape lua's magic pattern characters
			argument=argument:gsub(pattern, c1);								-- remove the markup
		else
			break;																-- none or no more 2 matches
		end
	end
	return argument;															-- done
end

--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...
]]

function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end

-- Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.
function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end			-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);	-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end					-- no more urls
		pattern = pattern:gsub(&quot;([%^%$%(%)%%%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);	-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);					-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);						-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end

--[[
ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in checkisbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.
]]
function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of bytes
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end	-- isbn13 begins with 978 or 979
		isbn_str = { isbn_str:byte(1, len) };
		for i, v in ipairs( isbn_str ) do
			temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
		end
		return temp % 10 == 0;
	end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
	--[[ Note: We cannot use &lt;i&gt; for italics, as the expected behavior for
	italics specified by ''...'' in the title is that they will be inverted
	(i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
	tend to interact poorly under Mediawiki's HTML tidy. ]]
	
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end

--[[
Joins a sequence of strings together while checking for duplicate separation characters.

TODO: safejoin() has a flaw where it won't remove the duplicate character from a |title= / |url= combination.
This is because by the time we get here, |title=http://somesite.com and |title=Document Title. have been combined:
	[http://somesite.com and ''Document Title.'']
so that now, the last character is not sepc but is ] (unless sepc == ']' which breaks the external link)
]]
function safejoin( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';
	local comp = '';
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then
			str = value;
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then
				-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
			else
				comp = value;
			end
			
			if comp:sub(1,1) == duplicate_char then
				trim = false;
				end_chr = str:sub(-1,-1);
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
				if end_chr == duplicate_char then
					str = str:sub(1,-2);
				elseif end_chr == &quot;'&quot; then
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
						str = str:sub(1, -4) .. &quot;''&quot;;
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
						trim = true;
					end
				elseif end_chr == &quot;]&quot; then
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
						trim = true;
					end
				elseif end_chr == &quot; &quot; then
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
						str = str:sub(1,-3);
					end
				end

				if trim then
					if value ~= comp then 
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
					else
						value = value:sub( 2, -1 );
					end
				end
			end
			str = str .. value;
		end
	end
	return str;
end  

-- Attempts to convert names to initials.
function reducetoinitials(first)
	local initials = {}
	local i = 0;										-- counter for number of initials
	for word in string.gmatch(first, &quot;%S+&quot;) do
		table.insert(initials, string.sub(word,1,1))	-- Vancouver format does not include full stops.
		i = i + 1;										-- bump the counter 
		if 2 &lt;= i then break; end						-- only two initials allowed in Vancouver system; if 2, quit
	end
	return table.concat(initials)						-- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
	local sep = control.sep;
	local namesep = control.namesep
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}
	local etal = false;
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if maximum ~= nil and maximum &lt; 1 then return &quot;&quot;, 0; end
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if maximum ~= nil and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
					one = one .. namesep .. first 
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;		-- link author/editor if this page is not the author's/editor's page
				end

				if is_set(person.link) and nil ~= person.link:find(&quot;//&quot;) then one = one .. &quot; &quot; .. seterror( 'bad_authorlink' ) end	-- check for url in author link;
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;
		end
		text[#text] = nil; 
	end
	
	local result = table.concat(text) -- construct list
	if etal then 
		local etal_text = cfg.messages['et al'];
		result = result .. &quot; &quot; .. etal_text;
	end
	
	-- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
	if ( &quot;scap&quot; == format ) then result = 
		'&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
	end 
	return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
	return &quot;CITEREF&quot; .. table.concat( options );
end

--[[
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.
]]
function extractnames(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	
	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary

	while true do
		last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { seterror( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 == count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			names[n] = {last = last, first = first, link = link, mask = mask};	-- add this name to our names list
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { seterror( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	return names;																-- all done, return our list of names
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
	local id_list = {};
	for k, v in pairs( cfg.id_handlers ) do	
		v = selectone( args, v.parameters, 'redundant_parameters' );
		if is_set(v) then id_list[k] = v; end
	end
	return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
	local new_list, handler = {};
	
	function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, externallinkid( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internallinkid( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internallinkid( handler );
			if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
	local value = nil;
	local selected = '';
	local error_list = {};
	
	if index ~= nil then index = tostring(index); end
	
	-- Handle special case of &quot;#&quot; replaced by empty string
	if index == '1' then
		for _, v in ipairs( possible ) do
			v = v:gsub( &quot;#&quot;, &quot;&quot; );
			if is_set(args[v]) then
				if value ~= nil and selected ~= v then
					table.insert( error_list, v );
				else
					value = args[v];
					selected = v;
				end
			end
		end		
	end
	
	for _, v in ipairs( possible ) do
		if index ~= nil then
			v = v:gsub( &quot;#&quot;, index );
		end
		if is_set(args[v]) then
			if value ~= nil and selected ~=  v then
				table.insert( error_list, v );
			else
				value = args[v];
				selected = v;
			end
		end
	end
	
	if #error_list &gt; 0 then
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap( 'parameter', k );
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap( 'parameter', selected );
		table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
function COinS(data)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end
	
	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
			end
		end
	});
	
	if is_set(data.Chapter) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Chapter;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	elseif is_set(data.Periodical) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
		OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	else
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
	end
	
	OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
	OCinSoutput[&quot;rft.date&quot;] = data.Date;
	OCinSoutput[&quot;rft.series&quot;] = data.Series;
	OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
	OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
	OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
	OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
	OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
	
	for k, v in pairs( data.ID_list ) do
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
	
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = v.last, v.first;
		if k == 1 then
			if is_set(last) then
				OCinSoutput[&quot;rft.aulast&quot;] = last;
			end
			if is_set(first) then 
				OCinSoutput[&quot;rft.aufirst&quot;] = first;
			end
		end
		if is_set(last) and is_set(first) then
			OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
		elseif is_set(last) then
			OCinSoutput[&quot;rft.au&quot;] = last;
		end
	end
	
	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 code.  Handles the special case that is Norwegian where
ISO639-1 code 'no' is mapped to language name 'Norwegian Bokmål' by Extention:CLDR.

Returns the language name and associated ISO639-1 code.  Because case of the source may be incorrect or different from the case that Wikimedia
uses, the name comparisons are done in lower case and when a match is found, the Wikimedia version (assumed to be correct) is returned along
with the code.  When there is no match, we return the original language name string.

mw.language.fetchLanguageNames() will return a list of languages that aren't part of ISO639-1. Names that aren't ISO639-1 but that are included
in the list will be found if that name is provided in the |language= parameter.  For example, if |language=Samaritan Aramaic, that name will be
found with the associated code 'sam', not an ISO639-1 code.  When names are found and the associated code is not two characters, this function
returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.
]]

function get_iso639_code (lang)
	if 'Norwegian' == lang then
		return lang, 'no';														-- special case related to Wikimedia remap of code 'no' at Extension:CLDR
	end
	
	local languages = mw.language.fetchLanguageNames('en', 'all')				-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() then												-- ISO639-1 codes only
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the ISO639-1 code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for ISO639-1 code
end

--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Get language name from ISO639-1 code value provided.  If a code is valid use the returned name; if not, then use the value that was provided with the language parameter.

There is an exception.  There are three ISO639-1 codes for Norewegian language variants.  There are two official variants: Norwegian Bokmål (code 'nb') and
Norwegian Nynorsk (code 'nn').  The third, code 'no',  is defined by ISO639-1 as 'Norwegian' though in Norway this is pretty much meaningless.  However, it appears
that on enwiki, editors are for the most part unaware of the nb and nn variants (compare page counts for these variants at Category:Articles with non-English-language external links.

Because Norwegian Bokmål is the most common language variant, Media wiki has been modified to return Norwegian Bokmål for ISO639-1 code 'no'. Here we undo that and
return 'Norwegian' when editors use |language=no.  We presume that editors don't know about the variants or can't descriminate between them.

See Help talk:Citation Style_1#An ISO 639-1 language name test

When |language= contains a valid ISO639-1 code, the page is assigned to the category for that code: Category:Norwegian-language sources (no) if
the page is a mainspace page and the ISO639-1 code is not 'en'.  Similarly, if the  parameter is |language=Norwegian, it will be categorized in the same way.

TODO: Error message when language or language code is not ISO639-1?
]]

function language_parameter (lang, namespace)
	local code;			-- the ISO639-1 two character code
	local name;			-- the language name
	local test='';
		
	if 0 == namespace and (('en' == lang:lower()) or ('english' == lang:lower())) then
		table.insert (z.maintenance_cats, 'CS1 maint: English language specified');		-- add maintenance category if |language=English or |language=en in article space
	end

	if 2 == lang:len() then														-- ISO639-1 language code are 2 characters (fetchLanguageName also supports 3 character codes)
		name = mw.language.fetchLanguageName( lang:lower(), &quot;en&quot; );				-- get ISO 639-1 language name if Language is a proper code
	end

	if is_set (name) then														-- if Language specified a valid ISO639-1 code
		code = lang:lower();													-- save it
	else
		name, code = get_iso639_code (lang);									-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
	end

	if is_set (code) then
		if 'no' == code then name = 'Norwegian' end;							-- override wikimedia when code is 'no'
			if 0 == namespace and 'en' ~= code then					-- is this page main / article space and English not the language?
				table.insert( z.properties_cats, 'CS1 ' .. name .. '-language sources (' .. code .. ')');	-- in main space and not English: categorize
			end
		end
	return (&quot; &quot; .. wrap( 'language', name));									-- wrap with '(in ...)'
end




--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------
This is the main function doing the majority of the citation
formatting.
]]
function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple
	aliases to single internal variable.
	]]
	local A = argument_wrapper( args );

	local i 
	local PPrefix = A['PPrefix']
	local PPPrefix = A['PPPrefix']
	if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
	
	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local Authors = A['Authors'];
	local a = extractnames( args, 'AuthorList' );

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];
	local Editors = A['Editors'];
	local e = extractnames( args, 'EditorList' );

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
	local Chapter = A['Chapter'];
	local ChapterLink = A['ChapterLink'];
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveURL = A['ArchiveURL'];
	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');
	local Periodical = A['Periodical'];

	local Series = A['Series'];
	local Volume = A['Volume'];
	local Issue = A['Issue'];
	local Position = '';
	local Page = A['Page'];
	local Pages = hyphentodash( A['Pages'] );	
	local At = A['At'];

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
	local SubscriptionRequired = A['SubscriptionRequired'];
	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local ArchiveDate = A['ArchiveDate'];
	local Agency = A['Agency'];
	local DeadURL = A['DeadURL']
	local Language = A['Language'];
	local Format = A['Format'];
	local Ref = A['Ref'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
	local Embargo = A['Embargo'];

	local ID_list = extractids( args );
--[[ Hide unfinished cite newsgroup code so that long delayed update can take place
	-- special case for cite newsgroup which uses |id= for a usenet article or post id
	-- |id= is not included in COinS so here we convert it to an ID that will be included in COinS
	if ('newsgroup' == config.CitationClass) and (is_set (ID)) then
		ID_list['USENETID']=ID;			-- add this new 'id' to the list of IDs
		ID = '';						-- and unset
	end
]]	
	local Quote = A['Quote'];
	local PostScript = A['PostScript'];

	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');
	local sepc = A['Separator'];

	local LastAuthorAmp = A['LastAuthorAmp'];
	local no_tracking_cats = A['NoTracking'];

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Cointerviewers = A['Cointerviewers'];			-- deprecated
	local Interviewer = A['Interviewer'];				-- deprecated
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local page_type;									-- is this needed?  Doesn't appear to be used anywhere;
	local use_lowercase = ( sepc ~= '.' );
	local this_page = mw.title.getCurrentTitle();		--Also used for COinS and for language
	local anchor_year;									-- used in the CITEREF identifier
	local COinS_date;									-- used in the COinS metadata

-- Set postscript default.
	if not is_set (PostScript) then						-- if |postscript= has not been set (Postscript is nil which is the default for {{citation}}) and
		if (config.CitationClass ~= &quot;citation&quot;) then	-- this template is not a citation template
			PostScript = '.';							-- must be a cite xxx template so set postscript to default (period)
		end
	else
		if PostScript:lower() == 'none' then			-- if |postscript=none then
			PostScript = '';							-- no postscript
		end
	end

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories.
	if not is_set(no_tracking_cats) then				-- ignore if we are already not going to categorize this page
		if inArray (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;					-- set no_tracking_cats
		end
	end

-- check for extra |page=, |pages= or |at= parameters. 
	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Page = Page .. &quot; &quot; .. seterror('extra_pages');	-- add error message
			Pages = '';										-- unset the others
			At = '';
		end
	elseif is_set(Pages) then
		if is_set(At) then
			Pages = Pages .. &quot; &quot; .. seterror('extra_pages');	-- add error messages
			At = '';											-- unset
		end
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped

All other combinations of |encyclopedia, |title, and |article are not modified
]]
	if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
		if is_set(Periodical) then					-- Periodical is set when |encyclopedia is set
			if is_set(Title) then
				if not is_set(Chapter) then
					Chapter = Title;				-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					TransChapter = TransTitle;
					Title = Periodical;
					Periodical = '';				-- redundant so unset
					TransTitle = '';				-- redundant so unset
				end
			else									-- |title not set
				Title = Periodical;					-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';					-- redundant so unset
			end
		end
	end

--special cases for citation.
	if (config.CitationClass == &quot;citation&quot;) then		-- for citation templates
		if not is_set (Ref) then						-- if |ref= is not set
			Ref = &quot;harv&quot;;								-- set default |ref=harv
		end
		if not is_set (sepc) then						-- if |separator= is not set
			sepc = ',';									-- set citation separator to its default (comma)
		end
	else												-- not a citation template
		if not is_set (sepc) then						-- if |separator= has not been set
			sepc = '.';									-- set cite xxx separator to its default (period)
		end
	end

-- check for special case where |separator=none
	if 'none' == sepc:lower() then						-- if |separator=none
		sepc = '';										-- then set it to an empty string
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then	-- special case for cite techreport
		if is_set(Issue) then						-- cite techreport uses 'number', which other citations aliase to 'issue'
			if not is_set(ID) then					-- can we use ID for the &quot;number&quot;?
				ID = Issue;							-- yes, use it
				Issue = &quot;&quot;;							-- unset Issue so that &quot;number&quot; isn't duplicated in the rendered citation or COinS metadata
			else									-- can't use ID so emit error message
				ID = ID .. &quot; &quot; .. seterror('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Interviewer) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Interviewer;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Interviewer;
			end
			if is_set(Cointerviewers) then
				Others = Others .. sepc .. ' ' .. Cointerviewers;
			end
		else
			Others = '(Interview)';
		end
	end

--Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set
	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_embargoed(Embargo) then
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];	-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];		-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
--TODO: if this is only for {{cite conference}}, shouldn't we be checking? (if config.CitationClass=='conference' then ...)
	if is_set(BookTitle) then
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = BookTitle;
		TitleLink = '';
		TransTitle = '';
	end

-- Account for the oddity that is {{cite episode}}, before generation of COinS data.
--[[	-- {{cite episode}} is not currently supported by this module
	if config.CitationClass == &quot;episode&quot; then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];
		local Season = A['Season'];
		local SeriesNumber = A['SeriesNumber'];
		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
		local Sep = (first_set(A[&quot;SeriesSeparator&quot;], A[&quot;Separator&quot;]) or &quot;&quot;) .. &quot; &quot;;
		
		if is_set(Issue) then table.insert(s, cfg.messages[&quot;episode&quot;] .. &quot; &quot; .. Issue); Issue = ''; end
		if is_set(Season) then table.insert(s, cfg.messages[&quot;season&quot;] .. &quot; &quot; .. Season); end
		if is_set(SeriesNumber) then table.insert(s, cfg.messages[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber); end
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		
		Date = Date or AirDate;
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = Series;
		TitleLink = SeriesLink;
		TransTitle = '';
		
		Series = table.concat(s, Sep);
		ID = table.concat(n, Sep);
	end
-- end of {{cite episode}} stuff]]

-- legacy: promote concatenation of |day=, |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set(Date) then
		Date = Year;						-- promote Year to Date
		Year = nil;							-- make nil so Year as empty string isn't used for CITEREF
		if is_set(Date) then
			local Month = A['Month'];
			if is_set(Month) then
				Date = Month .. &quot; &quot; .. Date;
				local Day = A['Day']
				if is_set(Day) then Date = Day .. &quot; &quot; .. Date end
			end
		elseif is_set(PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;			-- promote PublicationDate to Date
			PublicationDate = '';			-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end	-- if PublicationDate is same as Date, don't display in rendered citation


--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	anchor_year, COinS_date, error_message = dates({['accessdate']=AccessDate, ['airdate']=AirDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
		['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});
	if is_set(error_message) then
		table.insert( z.message_tail, { seterror( 'bad_date', {error_message}, true ) } );	-- add this error message
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for
	-- automated parsing of citation information.
	-- this is the function call to COinS()
	local OCinSoutput = COinS{
		['Periodical'] = Periodical,
		['Chapter'] = strip_apostrophe_markup (Chapter),						-- Chapter stripped of bold / italic wikimarkup
		['Title'] = make_coins_title (Title, ScriptTitle),		-- strip_apostrophe_markup (Title),							-- Title stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = first_set(COinS_date, Date),		-- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here?  Should we be including invalid dates in metadata?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set(Page, Pages, At)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set( URL, ChapterURL ),
		['Authors'] = a,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	};
--[[Why is this here?  Why are we mapping Title to Chapter when Periodical is set?
	if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = '';
		TitleLink = '';
		TransTitle = '';
	end
]]
--[[ Hide unfinished cite newsgroup code so that long delayed update can take place
-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername and ID
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = '[Newsgroup]:&amp;nbsp;' ..  externallink( 'news:' .. PublisherName, PublisherName );
		end
	end
]]


	-- Now perform various field 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 not is_set(Authors) then
		local Maximum = tonumber( A['DisplayAuthors'] );
		
		-- Preserve old-style implicit et al.
		if not is_set(Maximum) and #a == 9 then 
			Maximum = 8;
			table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
		elseif not is_set(Maximum) then
			Maximum = #a + 1;
		end
			
		local control = { 
			sep = A[&quot;AuthorSeparator&quot;] .. &quot; &quot;,
			namesep = (first_set(A[&quot;AuthorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
			format = A[&quot;AuthorFormat&quot;],
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text				-- get current page name so that we don't wikilink to it via authorlinkn
		};
		
		-- If the coauthor field is also used, prevent ampersand and et al. formatting.
		if is_set(Coauthors) then
			control.lastauthoramp = nil;
			control.maximum = #a + 1;
		end
		
		Authors = listpeople(control, a) 
	end

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { seterror('coauthors_missing_author', {}, true) } );	-- emit error message
	end

	local EditorCount
	if not is_set(Editors) then
		local Maximum = tonumber( A['DisplayEditors'] );
		-- Preserve old-style implicit et al.
		if not is_set(Maximum) and #e == 4 then 
			Maximum = 3;
			table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
		elseif not is_set(Maximum) then
			Maximum = #e + 1;
		end

		local control = { 
			sep = A[&quot;EditorSeparator&quot;] .. &quot; &quot;,
			namesep = (first_set(A[&quot;EditorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
			format = A['EditorFormat'],
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text				-- get current page name so that we don't wikilink to it via authorlinkn
		};

		Editors, EditorCount = listpeople(control, e);
	else
		EditorCount = 1;
	end

	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	if config.CitationClass == &quot;map&quot; then
		if not is_set( Authors ) and is_set( PublisherName ) then
			Authors = PublisherName;
			PublisherName = &quot;&quot;;
		end
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap( 'cartography', Cartography, use_lowercase );
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end		
	end
	
	if  not is_set(URL) and
		not is_set(ChapterURL) and
		not is_set(ArchiveURL) and
		not is_set(ConferenceURL) and
		not is_set(TranscriptURL) then
		
		-- Test if cite web or cite podcast |url= is missing or empty 
		if inArray(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;}) then	
			table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
		end
		
		-- Test if accessdate is given without giving a URL
		if is_set(AccessDate) then
			table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
		
		-- Test if format is given without giving a URL
		if is_set(Format) then
			Format = Format .. seterror( 'format_missing_url' );
		end
	end
	
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(Periodical) and
		not is_set(Conference) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
		table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
	end
	
	Format = is_set(Format) and &quot; (&quot; .. Format .. &quot;)&quot; or &quot;&quot;;
	
	local OriginalURL = URL
	DeadURL = DeadURL:lower();
	if is_set( ArchiveURL ) then
		if ( DeadURL ~= &quot;no&quot; ) then
			URL = ArchiveURL
			URLorigin = A:ORIGIN('ArchiveURL')
		end
	end
	
	-- Format chapter / article title
	if is_set(Chapter) and is_set(ChapterLink) then 
		Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot;;
	end

	Chapter = kern_quotes (Chapter);				-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
	Chapter = wrap( 'quoted-title', Chapter );
	TransChapter = wrap( 'trans-quoted-title', TransChapter );

	local TransError = &quot;&quot;
	if is_set(TransChapter) then
		if not is_set(Chapter) then
			TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
		else
			TransChapter = &quot; &quot; .. TransChapter;
		end
	end
	
	Chapter = Chapter .. TransChapter;
	
	if is_set(Chapter) then
		if not is_set(ChapterLink) then
			if is_set(ChapterURL) then
				Chapter = externallink( ChapterURL, Chapter ) .. TransError;
				if not is_set(URL) then
					Chapter = Chapter .. Format;
					Format = &quot;&quot;;
				end
			elseif is_set(URL) then 
				Chapter = externallink( URL, Chapter ) .. TransError .. Format;
				URL = &quot;&quot;;
				Format = &quot;&quot;;
			else
				Chapter = Chapter .. TransError;
			end			
		elseif is_set(ChapterURL) then
			Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. 
				TransError;
		else
			Chapter = Chapter .. TransError;
		end
		Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
	elseif is_set(ChapterURL) then
		Chapter = &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. sepc .. &quot; &quot;;
	end		
	
	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;journal&quot;,&quot;pressrelease&quot;,&quot;conference&quot;,&quot;podcast&quot;}) then
		Title = kern_quotes (Title);											-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
		Title = wrap( 'quoted-title', Title );
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap( 'trans-quoted-title', TransTitle );
		Chapter = '';								-- chapter not allowed
	else
		Title = wrap( 'italic-title', Title );
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap( 'trans-italic-title', TransTitle );
	end

	TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then 
			Title = externallink( URL, Title ) .. TransError .. Format	   
			URL = &quot;&quot;;
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end
	
	if is_set(Place) then
		Place = &quot; &quot; .. wrap( 'written', Place, use_lowercase ) .. sepc .. &quot; &quot;;
	end
	
	if is_set(Conference) then
		if is_set(ConferenceURL) then
			Conference = externallink( ConferenceURL, Conference );
		end
		Conference = sepc .. &quot; &quot; .. Conference
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. externallink( ConferenceURL, nil, ConferenceURLorigin );
	end
	
	if not is_set(Position) then
		local Minutes = A['Minutes'];
		if is_set(Minutes) then
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			local Time = A['Time'];
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end
	
	if not is_set(Page) then
		if is_set(Pages) then
			if is_set(Periodical) and
				not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
				Pages = &quot;: &quot; .. Pages;
			elseif tonumber(Pages) ~= nil then
				Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
			else
				Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
			end
		end
	else
		if is_set(Periodical) and
			not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
			Page = &quot;: &quot; .. Page;
		else
			Page = sepc ..&quot; &quot; .. PPrefix .. Page;
		end
	end
	
	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Inset = A['Inset'];
		if first_set( Pages, Page, At ) ~= nil or sepc ~= '.' then
			if is_set( Section ) then
				Section = &quot;, &quot; .. wrap( 'section', Section, true );
			end
			if is_set( Inset ) then
				Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
			end
		else
			if is_set( Section ) then
				Section = sepc .. &quot; &quot; .. wrap( 'section', Section, use_lowercase );
				if is_set( Inset ) then
					Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
				end
			elseif is_set( Inset ) then
				Inset = sepc .. &quot; &quot; .. wrap( 'inset', Inset, use_lowercase );
			end			
		end			
		At = At .. Section .. Inset;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language, this_page.namespace);			-- format, categories (article namespace only), name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;

-- handle type parameter for those CS1 citations that have default values

	if inArray(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then	-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then					-- if type parameter is specified
		TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot;;	-- display it in parentheses
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	Edition = is_set(Edition) and (&quot; &quot; .. wrap( 'edition', Edition )) or &quot;&quot;;
	Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc ..&quot; &quot; .. Volume;
		  else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
		end
	end

--[[ This code commented out while discussion continues until after week of 2014-03-23 live module update;
	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc .. &quot; &quot; .. Volume;
		  else
			  Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
			  if is_set(Series) then Volume = sepc .. Volume;
			  end
		end
	end
]]	
	------------------------------------ totally unrelated data
	--[[ Loosely mimic {{subscription required}} template; Via parameter identifies a delivery source that is not the publisher; these sources often, but not always, exist
	behind a registration or paywall.  So here, we've chosen to decouple via from subscription (via has never been part of the registration required template).
	
	Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link note is displayed. There are no error messages for this condition.
	]]
	if is_set(Via) then
		Via = &quot; &quot; .. wrap( 'via', Via );
	end

	if is_set(SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription']; --here when 'via' parameter not used but 'subscription' is
	elseif is_set(RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration']; --here when 'via' and 'subscription' parameters not used but 'registration' is
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
		AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
			.. substitute( retrv_text, {AccessDate} ) .. '&lt;/span&gt;'
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end

	
	ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo} );

	if is_set(URL) then
		URL = &quot; &quot; .. externallink( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
			Quote = Quote:sub(2,-2);
		end
		Quote = sepc ..&quot; &quot; .. wrap( 'quoted-text', Quote ); 
		PostScript = &quot;&quot;;							-- CS1 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = seterror('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ externallink( ArchiveURL, arch_text ), ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text,
				{ externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ seterror('archive_missing_url'), ArchiveDate } );
		end
	else
		Archived = &quot;&quot;
	end
	
	local Lay
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
		end			
	else
		Lay = &quot;&quot;;
	end
	
	if is_set(Transcript) then
		if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
	elseif is_set(TranscriptURL) then
		Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
	end
	
	local Publisher;
	if is_set(Periodical) and
		not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap( 'published', PublicationDate );
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap( 'published', PublicationDate ) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap( 'italic-title', Periodical ) 
		else 
			Periodical = wrap( 'italic-title', Periodical )
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon
	if inArray(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, 
			Language, Cartography, Edition, Publisher, Agency, Volume, Issue}, sepc );
	else 
		tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, Language, 
			Volume, Issue, Others, Cartography, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Page .. Pages .. At;
	
	if is_set(Authors) then
		if is_set(Coauthors) then
			Authors = Authors .. A['AuthorSeparator'] .. &quot; &quot; .. Coauthors
		end
		if is_set(Date) then
			Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		elseif string.sub(Authors,-1,-1) == sepc then
			Authors = Authors .. &quot; &quot;
		else
			Authors = Authors .. sepc .. &quot; &quot;
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			if (sepc ~= '.') then in_text = in_text:lower() end
			Editors = in_text .. Editors .. post_text;
			if (string.sub(Editors,-1,-1) == sepc)
				then Editors = Editors .. &quot; &quot;
				else Editors = Editors .. sepc .. &quot; &quot;
			end
		end
		text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
		text = safejoin( {text, pgtext, idcommon}, sepc );
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
		text = safejoin( {text, pgtext, idcommon}, sepc );
	else
		if is_set(Date) then
			if ( string.sub(tcommon,-1,-1) ~= sepc )
			  then Date = sepc ..&quot; &quot; .. Date .. OrigYear
			  else Date = &quot; &quot; .. Date .. OrigYear
			end
		end
		if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
			text = safejoin( {Chapter, Place, tcommon}, sepc );
			text = safejoin( {text, pgtext, Date, idcommon}, sepc );
		else
			text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
			text = safejoin( {text, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
--		text = text:sub(1,-2);	--Remove final separator (assumes that sepc is only one character)
	end	
	
	text = safejoin( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;span/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = &quot;citation &quot; .. config.CitationClass;
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
		local id = Ref
		if ( &quot;harv&quot; == Ref ) then
			local names = {} --table of last names &amp; year
			if #a &gt; 0 then
				for i,v in ipairs(a) do 
					names[i] = v.last 
					if i == 4 then break end
				end
			elseif #e &gt; 0 then
				for i,v in ipairs(e) do 
					names[i] = v.last 
					if i == 4 then break end				
				end
			end
			names[ #names + 1 ] = first_set(Year, anchor_year);	-- Year first for legacy citations
			id = anchorid(names)
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = seterror('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then 
		text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	else
		text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	end		

	local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
	
	-- Note: Using display: none on then COinS span breaks some clients.
	local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
	text = text .. OCinS;
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. errorcomment( v[1], v[2] );
				else
					text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if inArray(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
	local pframe = frame:getParent()
	
	if nil ~= string.find( frame:getTitle(), 'sandbox', 1, true ) then				-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData( 'Module:Citation/CS1/Configuration/sandbox' );	-- load sandbox versions of Configuration and Whitelist and ...
		whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist/sandbox' );
		dates = require('Module:Citation/CS1/Date_validation/sandbox').dates	-- ... sandbox version of date validation code
	else																	-- otherwise
		cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );			-- load live versions of Configuration and Whitelist and ...
		whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );
		dates = require('Module:Citation/CS1/Date_validation').dates		-- ... live version of date validation code
	end
	
	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = seterror( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if #suggestions == 0 then
						suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
					end
					if suggestions[ k:lower() ] ~= nil then
						error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
					else
						error_text, error_state = seterror( 'parameter_ignored', {k}, true );
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	
	
	return citation0( config, args)
end

return z</text>
      <sha1>87ca12r45l3g8puol5mjixvbaum2g1t</sha1>
    </revision>
    <revision>
      <id>4681</id>
      <parentid>4680</parentid>
      <timestamp>2014-10-12T13:44:27Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Bug fix to allow display of trans-chapter errors;</comment>
      <origin>4681</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="96066" sha1="8zo2xgyukh2lmxbkeha8ifzs7jimboh" xml:space="preserve">
local z = {
	error_categories = {};		-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};		-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};		-- for categorizing citations based on certain properties, language of source for instance
}

-- Whether variable is set or not
function is_set( var )
	return not (var == nil or var == '');
end

-- First set variable or nil if none
function first_set(...)
	local list = {...};
	for _, var in pairs(list) do
		if is_set( var ) then
			return var;
		end
	end
end

-- Whether needle is in haystack
function inArray( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end

--[[
Categorize and emit an error message when the citation contains one or more deprecated parameters.  Because deprecated parameters (currently |day=, |month=,
|coauthor=, and |coauthors=) aren't related to each other and because these parameters may be concatenated into the variables used by |date= and |author#= (and aliases)
details of which parameter caused the error message are not provided.  Only one error message is emitted regardless of the number of deprecated parameters in the citation.
]]
function deprecated_parameter()
	if true ~= Page_in_deprecated_cat then	-- if we haven't been here before then set a 
		Page_in_deprecated_cat=true;		-- sticky flag so that if there are more than one deprecated parameter the category is added only once
		table.insert( z.message_tail, { seterror( 'deprecated_params', {}, true ) } );		-- add error message
	end
end

-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
--	return args and tostring( mw.message.newRawMessage( msg, args ) ) or msg;
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[
Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern  either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
]]
function kern_quotes (str)
	local left='&lt;span style=&quot;padding-left:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains leading single or double quote mark
	local right='&lt;span style=&quot;padding-right:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains trailing single or double quote mark
	
	if  str:match (&quot;^[\&quot;\'][^\']&quot;) then
		str = string.gsub( str, &quot;^[\&quot;\']&quot;, left, 1 );				-- replace (captured) leading single or double quote with left-side &lt;span&gt;
	end
	if str:match (&quot;[^\'][\&quot;\']$&quot;) then
		str = string.gsub( str, &quot;[\&quot;\']$&quot;, right, 1 );			-- replace (captured) trailing single or double quote with right-side &lt;span&gt;
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

At this writing, only |script-title= is supported.  It is anticipated that additional parameters will be created to use this function.

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
			if inArray (lang, {'ar', 'ja', 'ko', 'he', 'zh'}) then				-- is prefix one of these language codes?
				table.insert( z.properties_cats, 'CS1 uses ' .. name .. '-language script ('..lang..')');	-- categorize in language-specific categories
			else
				table.insert( z.properties_cats, 'CS1 uses foreign language script');	-- use this category as a catchall until language-specific category is available
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = '&lt;bdi' .. lang .. '&gt;' .. script_value .. '&lt;/bdi&gt;';			-- isolate incase script is rlt

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end

-- Wraps a string using a message_list configuration taking one argument
function wrap( key, str, lower )
	if not is_set( str ) then
		return &quot;&quot;;
	elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safeforitalics( str );
	end
	if lower == true then
		return substitute( cfg.messages[key]:lower(), {str} );
	else
		return substitute( cfg.messages[key], {str} );
	end		
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = selectone( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
]]
function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
	return wrap( hidden and 'hidden-error' or 'visible-error', content );
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return errorcomment( message, error_state.hidden );
end

-- Formats a wiki style external link
function externallinkid(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

-- Formats a wiki style internal link
function internallinkid(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

-- Format an external link with error checking
function externallink( URL, label, source )
	local error_str = &quot;&quot;;
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = seterror( 'bare_url_missing_title', { wrap( 'parameter', source ) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not checkurl( URL ) then
		error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
	end
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safeforurl( label ), &quot;]&quot;, error_str });
end

-- Formats a link to Amazon
function amazon(id, domain)
	if checkisbn( id ) then														-- see if asin value is a 10-digit isbn
		table.insert( z.maintenance_cats, &quot;CS1 maint: ASIN uses ISBN&quot;);			-- add to maint category so a bot or awb script can replace |asin= with |isbn=
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif inArray (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif inArray (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return externallinkid({link = handler.link,
		label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
		encode=handler.encode, separator = handler.separator})
end

--[[
format and error check arXiv identifier.  There are two valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces
]]

function arxiv (id)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = &quot;&quot;
	
	year, month, version = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d([v%d]*)$&quot;);				-- test for the 9108-0703 format
	if not year then		-- arXiv id is not proper 9108-0703 form
		year, month, version = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d([v%d]*)$&quot;);	-- test for the 0704- format
		if not year then	
			err_cat = ' ' .. seterror( 'bad_arxiv' );							-- arXiv id doesn't match either format
		else	-- id is the 0704- format
			year = tonumber(year);
			month = tonumber(month);
			if ((7 &gt; year) or (1 &gt; month and 12 &lt; month)) or					-- is year invalid or is month invalid? (doesn't test for future years)
				((7 == year) and (4 &gt; month)) or								-- when year is 07, is month invalid (before April)?
				is_set (version) and nil == version:match(&quot;v%d+&quot;) then			-- is version proper format of single 'v' followed by digits?
					err_cat = ' ' .. seterror( 'bad_arxiv' );					-- set error message
			end
		end
	else	-- id is the 9108-0703 format; are the date values ok
		year = tonumber(year);
		month = tonumber(month);
		if ((91 &gt; year and 7 &lt; year) or (1 &gt; month and 12 &lt; month)) or			-- if invalid year or invalid month
			((91 == year and 8 &gt; month) or (7 == year and 3 &lt; month)) or 		-- if years ok, are starting and ending months ok?
				is_set (version) and nil == version:match(&quot;v%d+&quot;) then			-- is version proper format of single 'v' followed by digits?
					err_cat = ' ' .. seterror( 'bad_arxiv' );					-- set error message
		end
	end

	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--[[
Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of the LCCN dictates the character type of the first 1-3 characters; the
rightmost eight are always digits. http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]
function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. seterror( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. seterror( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]
function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmid' );	-- set an error message
		end
	end
	
	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns true; otherwise, returns false because the embargo has expired or |embargo= not set in this cite.
]]
function is_embargoed(embargo)
	if is_set(embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 and tonumber( embargo_date ) &gt;= tonumber( todays_date ) then	--is embargo date is in the future?
			return true;	-- still embargoed
		end
	end
	return false;			-- embargo expired or |embargo= not set
end

--[[
Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future
the PMC identifier will not be linked to the article.  If the embargo specifies a date in the past, or if it is empty or omitted, then
the PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.
]]
function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_embargoed(embargo) then
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	--still embargoed so no external link
	else
		text = externallinkid({link = handler.link, label = handler.label,			--no embargo date, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.

-- DOI names contain two parts: prefix and suffix separated by a forward slash.
--  Prefix: directory indicator '10.' followed by a registrant code
--  Suffix: character string of any length chosen by the registrant

-- This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes,
-- or, if it ends with a period or a comma, this function will emit a bad_doi error message.

-- DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
-- and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely if ever used in doi names.

function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. seterror( 'bad_doi' );
	end
	return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);					-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	else
		return externallinkid({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode}) .. 
			' ' .. seterror( 'bad_ol' );
	end
end

--[[
Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.
]]
function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = externallinkid({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. seterror( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[
This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those citations that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).
]]
function set_titletype(cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;					-- if |type=none then type parameter not displayed
		end
		return title_type;						-- if |type= has been set to any other value use that value
	end

	if &quot;AV-media-notes&quot; == cite_class or &quot;DVD-notes&quot; == cite_class then		-- if this citation is cite AV media notes or cite DVD notes
		return &quot;Media notes&quot;;					-- display AV media notes / DVD media notes annotation

	elseif &quot;podcast&quot; == cite_class then			-- if this citation is cite podcast
		return &quot;Podcast&quot;;						-- display podcast annotation

	elseif &quot;pressrelease&quot; == cite_class then	-- if this citation is cite press release
		return &quot;Press release&quot;;					-- display press release annotation

	elseif &quot;techreport&quot; == cite_class then		-- if this citation is cite techreport
		return &quot;Technical report&quot;;				-- display techreport annotation
	
	elseif &quot;thesis&quot; == cite_class then			-- if this citation is cite thesis (degree option handled after this function returns)
			return &quot;Thesis&quot;;					-- display simple thesis annotation (without |degree= modification)
	end
end

--[[
Determines whether a URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
	-- Protocol-relative or URL scheme
	return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
	return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end


--[[
Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup.
]]
function strip_apostrophe_markup (argument)
	local pattern, c1, c2;
	if not is_set (argument) then return argument; end
	
	while true do																-- look for and remove all 5-apostrophe (bold and italic) markup
		if argument:match (&quot;%'%'%'%'%'&quot;) then										-- is there an instance of bold-italic?
			if argument:match (&quot;%'%'%'%'%'.*%'%'%'%'%'&quot;) then						-- 5, 5
				pattern, c1 = argument:match (&quot;(%'%'%'%'%'(.*)%'%'%'%'%')&quot;);		
				c2 = &quot;&quot;;														-- set to empty string so we do only one replacement at end
			elseif argument:match (&quot;%'%'%'%'%'.*%'%'%'.*%'%'&quot;) then				-- bold italic followed by italic (5, 3, 2)
				pattern, c1, c2 = argument:match (&quot;(%'%'%'%'%'(.*)%'%'%'(.*)%'%')&quot;);
			elseif argument:match (&quot;%'%'%'%'%'.*%'%'.*%'%'%'&quot;) then				-- bold italic followed by bold (5, 2, 3)
				pattern, c1, c2 = argument:match (&quot;(%'%'%'%'%'(.*)%'%'(.*)%'%'%')&quot;);
			elseif argument:match (&quot;%'%'%'.*%'%'.*%'%'%'%'%'&quot;) then				-- bold italic followed by italic (3, 2, 5)
				pattern, c1, c2 = argument:match (&quot;(%'%'%'(.*)%'%'(.*)%'%'%'%'%')&quot;);
			elseif argument:match (&quot;%'%'.*%'%'%'.*%'%'%'%'%'&quot;) then				-- italic followed by bold (2, 3, 5)
				pattern, c1, c2 = argument:match (&quot;(%'%'(.*)%'%'%'(.*)%'%'%'%'%')&quot;);
			end
			pattern = pattern:gsub(&quot;([%^%$%(%)%%%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);		-- pattern is not a literal string; escape lua's magic pattern characters
			argument=argument:gsub(pattern, c1..c2);							-- remove the markup
		else
			break;																-- none or no more 5-apostrophe matches
		end
	end
	while true do																-- look for and remove all 3-apostrophe (bold) markup
		if argument:match (&quot;%'%'%'.*%'%'%'&quot;) then								-- is there an instance of bold?
			pattern, c1 = argument:match (&quot;(%'%'%'(.*)%'%'%')&quot;)
			pattern = pattern:gsub(&quot;([%^%$%(%)%%%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);	-- pattern is not a literal string; escape lua's magic pattern characters
			argument=argument:gsub(pattern, c1);								-- remove the markup
		else
			break;																-- none or no more 3 matches
		end
	end
	while true do																-- look for and remove all 2-apostrophe (italic) markup
		if argument:match (&quot;%'%'.*%'%'&quot;) then									-- is there an instance of italic?
			pattern, c1 = argument:match (&quot;(%'%'(.*)%'%')&quot;)
			pattern = pattern:gsub(&quot;([%^%$%(%)%%%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);	-- pattern is not a literal string; escape lua's magic pattern characters
			argument=argument:gsub(pattern, c1);								-- remove the markup
		else
			break;																-- none or no more 2 matches
		end
	end
	return argument;															-- done
end

--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...
]]

function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end

-- Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.
function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end			-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);	-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end					-- no more urls
		pattern = pattern:gsub(&quot;([%^%$%(%)%%%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);	-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);					-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);						-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end

--[[
ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in checkisbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.
]]
function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of bytes
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end	-- isbn13 begins with 978 or 979
		isbn_str = { isbn_str:byte(1, len) };
		for i, v in ipairs( isbn_str ) do
			temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
		end
		return temp % 10 == 0;
	end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
	--[[ Note: We cannot use &lt;i&gt; for italics, as the expected behavior for
	italics specified by ''...'' in the title is that they will be inverted
	(i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
	tend to interact poorly under Mediawiki's HTML tidy. ]]
	
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end

--[[
Joins a sequence of strings together while checking for duplicate separation characters.

TODO: safejoin() has a flaw where it won't remove the duplicate character from a |title= / |url= combination.
This is because by the time we get here, |title=http://somesite.com and |title=Document Title. have been combined:
	[http://somesite.com and ''Document Title.'']
so that now, the last character is not sepc but is ] (unless sepc == ']' which breaks the external link)
]]
function safejoin( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';
	local comp = '';
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then
			str = value;
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then
				-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
			else
				comp = value;
			end
			
			if comp:sub(1,1) == duplicate_char then
				trim = false;
				end_chr = str:sub(-1,-1);
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
				if end_chr == duplicate_char then
					str = str:sub(1,-2);
				elseif end_chr == &quot;'&quot; then
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
						str = str:sub(1, -4) .. &quot;''&quot;;
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
						trim = true;
					end
				elseif end_chr == &quot;]&quot; then
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
						trim = true;
					end
				elseif end_chr == &quot; &quot; then
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
						str = str:sub(1,-3);
					end
				end

				if trim then
					if value ~= comp then 
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
					else
						value = value:sub( 2, -1 );
					end
				end
			end
			str = str .. value;
		end
	end
	return str;
end  

-- Attempts to convert names to initials.
function reducetoinitials(first)
	local initials = {}
	local i = 0;										-- counter for number of initials
	for word in string.gmatch(first, &quot;%S+&quot;) do
		table.insert(initials, string.sub(word,1,1))	-- Vancouver format does not include full stops.
		i = i + 1;										-- bump the counter 
		if 2 &lt;= i then break; end						-- only two initials allowed in Vancouver system; if 2, quit
	end
	return table.concat(initials)						-- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
	local sep = control.sep;
	local namesep = control.namesep
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}
	local etal = false;
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if maximum ~= nil and maximum &lt; 1 then return &quot;&quot;, 0; end
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if maximum ~= nil and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
					one = one .. namesep .. first 
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;		-- link author/editor if this page is not the author's/editor's page
				end

				if is_set(person.link) and nil ~= person.link:find(&quot;//&quot;) then one = one .. &quot; &quot; .. seterror( 'bad_authorlink' ) end	-- check for url in author link;
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;
		end
		text[#text] = nil; 
	end
	
	local result = table.concat(text) -- construct list
	if etal then 
		local etal_text = cfg.messages['et al'];
		result = result .. &quot; &quot; .. etal_text;
	end
	
	-- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
	if ( &quot;scap&quot; == format ) then result = 
		'&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
	end 
	return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
	return &quot;CITEREF&quot; .. table.concat( options );
end

--[[
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.
]]
function extractnames(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	
	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary

	while true do
		last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { seterror( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 == count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			names[n] = {last = last, first = first, link = link, mask = mask};	-- add this name to our names list
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { seterror( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	return names;																-- all done, return our list of names
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
	local id_list = {};
	for k, v in pairs( cfg.id_handlers ) do	
		v = selectone( args, v.parameters, 'redundant_parameters' );
		if is_set(v) then id_list[k] = v; end
	end
	return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
	local new_list, handler = {};
	
	function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, externallinkid( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internallinkid( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internallinkid( handler );
			if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
	local value = nil;
	local selected = '';
	local error_list = {};
	
	if index ~= nil then index = tostring(index); end
	
	-- Handle special case of &quot;#&quot; replaced by empty string
	if index == '1' then
		for _, v in ipairs( possible ) do
			v = v:gsub( &quot;#&quot;, &quot;&quot; );
			if is_set(args[v]) then
				if value ~= nil and selected ~= v then
					table.insert( error_list, v );
				else
					value = args[v];
					selected = v;
				end
			end
		end		
	end
	
	for _, v in ipairs( possible ) do
		if index ~= nil then
			v = v:gsub( &quot;#&quot;, index );
		end
		if is_set(args[v]) then
			if value ~= nil and selected ~=  v then
				table.insert( error_list, v );
			else
				value = args[v];
				selected = v;
			end
		end
	end
	
	if #error_list &gt; 0 then
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap( 'parameter', k );
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap( 'parameter', selected );
		table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
function COinS(data)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end
	
	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
			end
		end
	});
	
	if is_set(data.Chapter) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Chapter;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	elseif is_set(data.Periodical) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
		OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	else
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
	end
	
	OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
	OCinSoutput[&quot;rft.date&quot;] = data.Date;
	OCinSoutput[&quot;rft.series&quot;] = data.Series;
	OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
	OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
	OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
	OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
	OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
	
	for k, v in pairs( data.ID_list ) do
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
	
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = v.last, v.first;
		if k == 1 then
			if is_set(last) then
				OCinSoutput[&quot;rft.aulast&quot;] = last;
			end
			if is_set(first) then 
				OCinSoutput[&quot;rft.aufirst&quot;] = first;
			end
		end
		if is_set(last) and is_set(first) then
			OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
		elseif is_set(last) then
			OCinSoutput[&quot;rft.au&quot;] = last;
		end
	end
	
	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 code.  Handles the special case that is Norwegian where
ISO639-1 code 'no' is mapped to language name 'Norwegian Bokmål' by Extention:CLDR.

Returns the language name and associated ISO639-1 code.  Because case of the source may be incorrect or different from the case that Wikimedia
uses, the name comparisons are done in lower case and when a match is found, the Wikimedia version (assumed to be correct) is returned along
with the code.  When there is no match, we return the original language name string.

mw.language.fetchLanguageNames() will return a list of languages that aren't part of ISO639-1. Names that aren't ISO639-1 but that are included
in the list will be found if that name is provided in the |language= parameter.  For example, if |language=Samaritan Aramaic, that name will be
found with the associated code 'sam', not an ISO639-1 code.  When names are found and the associated code is not two characters, this function
returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.
]]

function get_iso639_code (lang)
	if 'Norwegian' == lang then
		return lang, 'no';														-- special case related to Wikimedia remap of code 'no' at Extension:CLDR
	end
	
	local languages = mw.language.fetchLanguageNames('en', 'all')				-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() then												-- ISO639-1 codes only
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the ISO639-1 code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for ISO639-1 code
end

--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Get language name from ISO639-1 code value provided.  If a code is valid use the returned name; if not, then use the value that was provided with the language parameter.

There is an exception.  There are three ISO639-1 codes for Norewegian language variants.  There are two official variants: Norwegian Bokmål (code 'nb') and
Norwegian Nynorsk (code 'nn').  The third, code 'no',  is defined by ISO639-1 as 'Norwegian' though in Norway this is pretty much meaningless.  However, it appears
that on enwiki, editors are for the most part unaware of the nb and nn variants (compare page counts for these variants at Category:Articles with non-English-language external links.

Because Norwegian Bokmål is the most common language variant, Media wiki has been modified to return Norwegian Bokmål for ISO639-1 code 'no'. Here we undo that and
return 'Norwegian' when editors use |language=no.  We presume that editors don't know about the variants or can't descriminate between them.

See Help talk:Citation Style_1#An ISO 639-1 language name test

When |language= contains a valid ISO639-1 code, the page is assigned to the category for that code: Category:Norwegian-language sources (no) if
the page is a mainspace page and the ISO639-1 code is not 'en'.  Similarly, if the  parameter is |language=Norwegian, it will be categorized in the same way.

TODO: Error message when language or language code is not ISO639-1?
]]

function language_parameter (lang, namespace)
	local code;			-- the ISO639-1 two character code
	local name;			-- the language name
	local test='';
		
	if 0 == namespace and (('en' == lang:lower()) or ('english' == lang:lower())) then
		table.insert (z.maintenance_cats, 'CS1 maint: English language specified');		-- add maintenance category if |language=English or |language=en in article space
	end

	if 2 == lang:len() then														-- ISO639-1 language code are 2 characters (fetchLanguageName also supports 3 character codes)
		name = mw.language.fetchLanguageName( lang:lower(), &quot;en&quot; );				-- get ISO 639-1 language name if Language is a proper code
	end

	if is_set (name) then														-- if Language specified a valid ISO639-1 code
		code = lang:lower();													-- save it
	else
		name, code = get_iso639_code (lang);									-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
	end

	if is_set (code) then
		if 'no' == code then name = 'Norwegian' end;							-- override wikimedia when code is 'no'
			if 0 == namespace and 'en' ~= code then					-- is this page main / article space and English not the language?
				table.insert( z.properties_cats, 'CS1 ' .. name .. '-language sources (' .. code .. ')');	-- in main space and not English: categorize
			end
		end
	return (&quot; &quot; .. wrap( 'language', name));									-- wrap with '(in ...)'
end




--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------
This is the main function doing the majority of the citation
formatting.
]]
function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple
	aliases to single internal variable.
	]]
	local A = argument_wrapper( args );

	local i 
	local PPrefix = A['PPrefix']
	local PPPrefix = A['PPPrefix']
	if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
	
	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local Authors = A['Authors'];
	local a = extractnames( args, 'AuthorList' );

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];
	local Editors = A['Editors'];
	local e = extractnames( args, 'EditorList' );

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
	local Chapter = A['Chapter'];
	local ChapterLink = A['ChapterLink'];
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveURL = A['ArchiveURL'];
	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');
	local Periodical = A['Periodical'];

	local Series = A['Series'];
	local Volume = A['Volume'];
	local Issue = A['Issue'];
	local Position = '';
	local Page = A['Page'];
	local Pages = hyphentodash( A['Pages'] );	
	local At = A['At'];

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
	local SubscriptionRequired = A['SubscriptionRequired'];
	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local ArchiveDate = A['ArchiveDate'];
	local Agency = A['Agency'];
	local DeadURL = A['DeadURL']
	local Language = A['Language'];
	local Format = A['Format'];
	local Ref = A['Ref'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
	local Embargo = A['Embargo'];

	local ID_list = extractids( args );
--[[ Hide unfinished cite newsgroup code so that long delayed update can take place
	-- special case for cite newsgroup which uses |id= for a usenet article or post id
	-- |id= is not included in COinS so here we convert it to an ID that will be included in COinS
	if ('newsgroup' == config.CitationClass) and (is_set (ID)) then
		ID_list['USENETID']=ID;			-- add this new 'id' to the list of IDs
		ID = '';						-- and unset
	end
]]	
	local Quote = A['Quote'];
	local PostScript = A['PostScript'];

	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');
	local sepc = A['Separator'];

	local LastAuthorAmp = A['LastAuthorAmp'];
	local no_tracking_cats = A['NoTracking'];

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Cointerviewers = A['Cointerviewers'];			-- deprecated
	local Interviewer = A['Interviewer'];				-- deprecated
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local page_type;									-- is this needed?  Doesn't appear to be used anywhere;
	local use_lowercase = ( sepc ~= '.' );
	local this_page = mw.title.getCurrentTitle();		--Also used for COinS and for language
	local anchor_year;									-- used in the CITEREF identifier
	local COinS_date;									-- used in the COinS metadata

-- Set postscript default.
	if not is_set (PostScript) then						-- if |postscript= has not been set (Postscript is nil which is the default for {{citation}}) and
		if (config.CitationClass ~= &quot;citation&quot;) then	-- this template is not a citation template
			PostScript = '.';							-- must be a cite xxx template so set postscript to default (period)
		end
	else
		if PostScript:lower() == 'none' then			-- if |postscript=none then
			PostScript = '';							-- no postscript
		end
	end

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories.
	if not is_set(no_tracking_cats) then				-- ignore if we are already not going to categorize this page
		if inArray (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;					-- set no_tracking_cats
		end
	end

-- check for extra |page=, |pages= or |at= parameters. 
	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Page = Page .. &quot; &quot; .. seterror('extra_pages');	-- add error message
			Pages = '';										-- unset the others
			At = '';
		end
	elseif is_set(Pages) then
		if is_set(At) then
			Pages = Pages .. &quot; &quot; .. seterror('extra_pages');	-- add error messages
			At = '';											-- unset
		end
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped

All other combinations of |encyclopedia, |title, and |article are not modified
]]
	if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
		if is_set(Periodical) then					-- Periodical is set when |encyclopedia is set
			if is_set(Title) then
				if not is_set(Chapter) then
					Chapter = Title;				-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					TransChapter = TransTitle;
					Title = Periodical;
					Periodical = '';				-- redundant so unset
					TransTitle = '';				-- redundant so unset
				end
			else									-- |title not set
				Title = Periodical;					-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';					-- redundant so unset
			end
		end
	end

--special cases for citation.
	if (config.CitationClass == &quot;citation&quot;) then		-- for citation templates
		if not is_set (Ref) then						-- if |ref= is not set
			Ref = &quot;harv&quot;;								-- set default |ref=harv
		end
		if not is_set (sepc) then						-- if |separator= is not set
			sepc = ',';									-- set citation separator to its default (comma)
		end
	else												-- not a citation template
		if not is_set (sepc) then						-- if |separator= has not been set
			sepc = '.';									-- set cite xxx separator to its default (period)
		end
	end

-- check for special case where |separator=none
	if 'none' == sepc:lower() then						-- if |separator=none
		sepc = '';										-- then set it to an empty string
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then	-- special case for cite techreport
		if is_set(Issue) then						-- cite techreport uses 'number', which other citations aliase to 'issue'
			if not is_set(ID) then					-- can we use ID for the &quot;number&quot;?
				ID = Issue;							-- yes, use it
				Issue = &quot;&quot;;							-- unset Issue so that &quot;number&quot; isn't duplicated in the rendered citation or COinS metadata
			else									-- can't use ID so emit error message
				ID = ID .. &quot; &quot; .. seterror('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Interviewer) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Interviewer;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Interviewer;
			end
			if is_set(Cointerviewers) then
				Others = Others .. sepc .. ' ' .. Cointerviewers;
			end
		else
			Others = '(Interview)';
		end
	end

--Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set
	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_embargoed(Embargo) then
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];	-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];		-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
--TODO: if this is only for {{cite conference}}, shouldn't we be checking? (if config.CitationClass=='conference' then ...)
	if is_set(BookTitle) then
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = BookTitle;
		TitleLink = '';
		TransTitle = '';
	end

-- Account for the oddity that is {{cite episode}}, before generation of COinS data.
--[[	-- {{cite episode}} is not currently supported by this module
	if config.CitationClass == &quot;episode&quot; then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];
		local Season = A['Season'];
		local SeriesNumber = A['SeriesNumber'];
		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
		local Sep = (first_set(A[&quot;SeriesSeparator&quot;], A[&quot;Separator&quot;]) or &quot;&quot;) .. &quot; &quot;;
		
		if is_set(Issue) then table.insert(s, cfg.messages[&quot;episode&quot;] .. &quot; &quot; .. Issue); Issue = ''; end
		if is_set(Season) then table.insert(s, cfg.messages[&quot;season&quot;] .. &quot; &quot; .. Season); end
		if is_set(SeriesNumber) then table.insert(s, cfg.messages[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber); end
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		
		Date = Date or AirDate;
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = Series;
		TitleLink = SeriesLink;
		TransTitle = '';
		
		Series = table.concat(s, Sep);
		ID = table.concat(n, Sep);
	end
-- end of {{cite episode}} stuff]]

-- legacy: promote concatenation of |day=, |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set(Date) then
		Date = Year;						-- promote Year to Date
		Year = nil;							-- make nil so Year as empty string isn't used for CITEREF
		if is_set(Date) then
			local Month = A['Month'];
			if is_set(Month) then
				Date = Month .. &quot; &quot; .. Date;
				local Day = A['Day']
				if is_set(Day) then Date = Day .. &quot; &quot; .. Date end
			end
		elseif is_set(PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;			-- promote PublicationDate to Date
			PublicationDate = '';			-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end	-- if PublicationDate is same as Date, don't display in rendered citation


--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	anchor_year, COinS_date, error_message = dates({['accessdate']=AccessDate, ['airdate']=AirDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
		['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});
	if is_set(error_message) then
		table.insert( z.message_tail, { seterror( 'bad_date', {error_message}, true ) } );	-- add this error message
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for
	-- automated parsing of citation information.
	-- this is the function call to COinS()
	local OCinSoutput = COinS{
		['Periodical'] = Periodical,
		['Chapter'] = strip_apostrophe_markup (Chapter),						-- Chapter stripped of bold / italic wikimarkup
		['Title'] = make_coins_title (Title, ScriptTitle),		-- strip_apostrophe_markup (Title),							-- Title stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = first_set(COinS_date, Date),		-- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here?  Should we be including invalid dates in metadata?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set(Page, Pages, At)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set( URL, ChapterURL ),
		['Authors'] = a,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	};
--[[Why is this here?  Why are we mapping Title to Chapter when Periodical is set?
	if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = '';
		TitleLink = '';
		TransTitle = '';
	end
]]
--[[ Hide unfinished cite newsgroup code so that long delayed update can take place
-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername and ID
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = '[Newsgroup]:&amp;nbsp;' ..  externallink( 'news:' .. PublisherName, PublisherName );
		end
	end
]]


	-- Now perform various field 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 not is_set(Authors) then
		local Maximum = tonumber( A['DisplayAuthors'] );
		
		-- Preserve old-style implicit et al.
		if not is_set(Maximum) and #a == 9 then 
			Maximum = 8;
			table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
		elseif not is_set(Maximum) then
			Maximum = #a + 1;
		end
			
		local control = { 
			sep = A[&quot;AuthorSeparator&quot;] .. &quot; &quot;,
			namesep = (first_set(A[&quot;AuthorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
			format = A[&quot;AuthorFormat&quot;],
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text				-- get current page name so that we don't wikilink to it via authorlinkn
		};
		
		-- If the coauthor field is also used, prevent ampersand and et al. formatting.
		if is_set(Coauthors) then
			control.lastauthoramp = nil;
			control.maximum = #a + 1;
		end
		
		Authors = listpeople(control, a) 
	end

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { seterror('coauthors_missing_author', {}, true) } );	-- emit error message
	end

	local EditorCount
	if not is_set(Editors) then
		local Maximum = tonumber( A['DisplayEditors'] );
		-- Preserve old-style implicit et al.
		if not is_set(Maximum) and #e == 4 then 
			Maximum = 3;
			table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
		elseif not is_set(Maximum) then
			Maximum = #e + 1;
		end

		local control = { 
			sep = A[&quot;EditorSeparator&quot;] .. &quot; &quot;,
			namesep = (first_set(A[&quot;EditorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
			format = A['EditorFormat'],
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text				-- get current page name so that we don't wikilink to it via authorlinkn
		};

		Editors, EditorCount = listpeople(control, e);
	else
		EditorCount = 1;
	end

	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	if config.CitationClass == &quot;map&quot; then
		if not is_set( Authors ) and is_set( PublisherName ) then
			Authors = PublisherName;
			PublisherName = &quot;&quot;;
		end
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap( 'cartography', Cartography, use_lowercase );
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end		
	end
	
	if  not is_set(URL) and
		not is_set(ChapterURL) and
		not is_set(ArchiveURL) and
		not is_set(ConferenceURL) and
		not is_set(TranscriptURL) then
		
		-- Test if cite web or cite podcast |url= is missing or empty 
		if inArray(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;}) then	
			table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
		end
		
		-- Test if accessdate is given without giving a URL
		if is_set(AccessDate) then
			table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
		
		-- Test if format is given without giving a URL
		if is_set(Format) then
			Format = Format .. seterror( 'format_missing_url' );
		end
	end
	
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(Periodical) and
		not is_set(Conference) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
		table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
	end
	
	Format = is_set(Format) and &quot; (&quot; .. Format .. &quot;)&quot; or &quot;&quot;;
	
	local OriginalURL = URL
	DeadURL = DeadURL:lower();
	if is_set( ArchiveURL ) then
		if ( DeadURL ~= &quot;no&quot; ) then
			URL = ArchiveURL
			URLorigin = A:ORIGIN('ArchiveURL')
		end
	end
	
	-- Format chapter / article title
	if is_set(Chapter) and is_set(ChapterLink) then 
		Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot;;
	end

	Chapter = kern_quotes (Chapter);				-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
	Chapter = wrap( 'quoted-title', Chapter );
	TransChapter = wrap( 'trans-quoted-title', TransChapter );

	local TransError = &quot;&quot;
	if is_set(TransChapter) then
		if not is_set(Chapter) then
			TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );
		else
			TransChapter = &quot; &quot; .. TransChapter;
		end
	end
	
	Chapter = Chapter .. TransChapter;
	
	if is_set(Chapter) then
		if not is_set(ChapterLink) then
			if is_set(ChapterURL) then
				Chapter = externallink( ChapterURL, Chapter ) .. TransError;
				if not is_set(URL) then
					Chapter = Chapter .. Format;
					Format = &quot;&quot;;
				end
			elseif is_set(URL) then 
				Chapter = externallink( URL, Chapter ) .. TransError .. Format;
				URL = &quot;&quot;;
				Format = &quot;&quot;;
			else
				Chapter = Chapter .. TransError;
			end			
		elseif is_set(ChapterURL) then
			Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. 
				TransError;
		else
			Chapter = Chapter .. TransError;
		end
		Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
	elseif is_set(ChapterURL) then
		Chapter = &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. sepc .. &quot; &quot;;
	end		
	
	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;journal&quot;,&quot;pressrelease&quot;,&quot;conference&quot;,&quot;podcast&quot;}) then
		Title = kern_quotes (Title);											-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
		Title = wrap( 'quoted-title', Title );
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap( 'trans-quoted-title', TransTitle );
--		Chapter = '';								-- chapter not allowed - disabled because doing this here doesn't display error msg and promoted url is lost
	else
		Title = wrap( 'italic-title', Title );
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap( 'trans-italic-title', TransTitle );
	end

	TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then 
			Title = externallink( URL, Title ) .. TransError .. Format	   
			URL = &quot;&quot;;
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end
	
	if is_set(Place) then
		Place = &quot; &quot; .. wrap( 'written', Place, use_lowercase ) .. sepc .. &quot; &quot;;
	end
	
	if is_set(Conference) then
		if is_set(ConferenceURL) then
			Conference = externallink( ConferenceURL, Conference );
		end
		Conference = sepc .. &quot; &quot; .. Conference
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. externallink( ConferenceURL, nil, ConferenceURLorigin );
	end
	
	if not is_set(Position) then
		local Minutes = A['Minutes'];
		if is_set(Minutes) then
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			local Time = A['Time'];
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end
	
	if not is_set(Page) then
		if is_set(Pages) then
			if is_set(Periodical) and
				not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
				Pages = &quot;: &quot; .. Pages;
			elseif tonumber(Pages) ~= nil then
				Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
			else
				Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
			end
		end
	else
		if is_set(Periodical) and
			not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
			Page = &quot;: &quot; .. Page;
		else
			Page = sepc ..&quot; &quot; .. PPrefix .. Page;
		end
	end
	
	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Inset = A['Inset'];
		if first_set( Pages, Page, At ) ~= nil or sepc ~= '.' then
			if is_set( Section ) then
				Section = &quot;, &quot; .. wrap( 'section', Section, true );
			end
			if is_set( Inset ) then
				Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
			end
		else
			if is_set( Section ) then
				Section = sepc .. &quot; &quot; .. wrap( 'section', Section, use_lowercase );
				if is_set( Inset ) then
					Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
				end
			elseif is_set( Inset ) then
				Inset = sepc .. &quot; &quot; .. wrap( 'inset', Inset, use_lowercase );
			end			
		end			
		At = At .. Section .. Inset;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language, this_page.namespace);			-- format, categories (article namespace only), name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;

-- handle type parameter for those CS1 citations that have default values

	if inArray(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then	-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then					-- if type parameter is specified
		TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot;;	-- display it in parentheses
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	Edition = is_set(Edition) and (&quot; &quot; .. wrap( 'edition', Edition )) or &quot;&quot;;
	Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc ..&quot; &quot; .. Volume;
		  else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
		end
	end

--[[ This code commented out while discussion continues until after week of 2014-03-23 live module update;
	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc .. &quot; &quot; .. Volume;
		  else
			  Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
			  if is_set(Series) then Volume = sepc .. Volume;
			  end
		end
	end
]]	
	------------------------------------ totally unrelated data
	--[[ Loosely mimic {{subscription required}} template; Via parameter identifies a delivery source that is not the publisher; these sources often, but not always, exist
	behind a registration or paywall.  So here, we've chosen to decouple via from subscription (via has never been part of the registration required template).
	
	Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link note is displayed. There are no error messages for this condition.
	]]
	if is_set(Via) then
		Via = &quot; &quot; .. wrap( 'via', Via );
	end

	if is_set(SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription']; --here when 'via' parameter not used but 'subscription' is
	elseif is_set(RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration']; --here when 'via' and 'subscription' parameters not used but 'registration' is
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
		AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
			.. substitute( retrv_text, {AccessDate} ) .. '&lt;/span&gt;'
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end

	
	ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo} );

	if is_set(URL) then
		URL = &quot; &quot; .. externallink( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
			Quote = Quote:sub(2,-2);
		end
		Quote = sepc ..&quot; &quot; .. wrap( 'quoted-text', Quote ); 
		PostScript = &quot;&quot;;							-- CS1 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = seterror('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ externallink( ArchiveURL, arch_text ), ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text,
				{ externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ seterror('archive_missing_url'), ArchiveDate } );
		end
	else
		Archived = &quot;&quot;
	end
	
	local Lay
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
		end			
	else
		Lay = &quot;&quot;;
	end
	
	if is_set(Transcript) then
		if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
	elseif is_set(TranscriptURL) then
		Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
	end
	
	local Publisher;
	if is_set(Periodical) and
		not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap( 'published', PublicationDate );
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap( 'published', PublicationDate ) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap( 'italic-title', Periodical ) 
		else 
			Periodical = wrap( 'italic-title', Periodical )
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon
	if inArray(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, 
			Language, Cartography, Edition, Publisher, Agency, Volume, Issue}, sepc );
	else 
		tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, Language, 
			Volume, Issue, Others, Cartography, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Page .. Pages .. At;
	
	if is_set(Authors) then
		if is_set(Coauthors) then
			Authors = Authors .. A['AuthorSeparator'] .. &quot; &quot; .. Coauthors
		end
		if is_set(Date) then
			Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		elseif string.sub(Authors,-1,-1) == sepc then
			Authors = Authors .. &quot; &quot;
		else
			Authors = Authors .. sepc .. &quot; &quot;
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			if (sepc ~= '.') then in_text = in_text:lower() end
			Editors = in_text .. Editors .. post_text;
			if (string.sub(Editors,-1,-1) == sepc)
				then Editors = Editors .. &quot; &quot;
				else Editors = Editors .. sepc .. &quot; &quot;
			end
		end
		text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
		text = safejoin( {text, pgtext, idcommon}, sepc );
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
		text = safejoin( {text, pgtext, idcommon}, sepc );
	else
		if is_set(Date) then
			if ( string.sub(tcommon,-1,-1) ~= sepc )
			  then Date = sepc ..&quot; &quot; .. Date .. OrigYear
			  else Date = &quot; &quot; .. Date .. OrigYear
			end
		end
		if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
			text = safejoin( {Chapter, Place, tcommon}, sepc );
			text = safejoin( {text, pgtext, Date, idcommon}, sepc );
		else
			text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
			text = safejoin( {text, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
--		text = text:sub(1,-2);	--Remove final separator (assumes that sepc is only one character)
	end	
	
	text = safejoin( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;span/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = &quot;citation &quot; .. config.CitationClass;
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
		local id = Ref
		if ( &quot;harv&quot; == Ref ) then
			local names = {} --table of last names &amp; year
			if #a &gt; 0 then
				for i,v in ipairs(a) do 
					names[i] = v.last 
					if i == 4 then break end
				end
			elseif #e &gt; 0 then
				for i,v in ipairs(e) do 
					names[i] = v.last 
					if i == 4 then break end				
				end
			end
			names[ #names + 1 ] = first_set(Year, anchor_year);	-- Year first for legacy citations
			id = anchorid(names)
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = seterror('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then 
		text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	else
		text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	end		

	local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
	
	-- Note: Using display: none on then COinS span breaks some clients.
	local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
	text = text .. OCinS;
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. errorcomment( v[1], v[2] );
				else
					text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if inArray(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
	local pframe = frame:getParent()
	
	if nil ~= string.find( frame:getTitle(), 'sandbox', 1, true ) then				-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData( 'Module:Citation/CS1/Configuration/sandbox' );	-- load sandbox versions of Configuration and Whitelist and ...
		whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist/sandbox' );
		dates = require('Module:Citation/CS1/Date_validation/sandbox').dates	-- ... sandbox version of date validation code
	else																	-- otherwise
		cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );			-- load live versions of Configuration and Whitelist and ...
		whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );
		dates = require('Module:Citation/CS1/Date_validation').dates		-- ... live version of date validation code
	end
	
	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = seterror( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if #suggestions == 0 then
						suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
					end
					if suggestions[ k:lower() ] ~= nil then
						error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
					else
						error_text, error_state = seterror( 'parameter_ignored', {k}, true );
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	
	
	return citation0( config, args)
end

return z</text>
      <sha1>8zo2xgyukh2lmxbkeha8ifzs7jimboh</sha1>
    </revision>
    <revision>
      <id>4682</id>
      <parentid>4681</parentid>
      <timestamp>2014-10-13T00:36:56Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Disable strip_apostrophe_markup() and make_coins_title(); causing script errors;</comment>
      <origin>4682</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="96022" sha1="2surmt4pinx8874ri6s36q4o78cjgg8" xml:space="preserve">
local z = {
	error_categories = {};		-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};		-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};		-- for categorizing citations based on certain properties, language of source for instance
}

-- Whether variable is set or not
function is_set( var )
	return not (var == nil or var == '');
end

-- First set variable or nil if none
function first_set(...)
	local list = {...};
	for _, var in pairs(list) do
		if is_set( var ) then
			return var;
		end
	end
end

-- Whether needle is in haystack
function inArray( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end

--[[
Categorize and emit an error message when the citation contains one or more deprecated parameters.  Because deprecated parameters (currently |day=, |month=,
|coauthor=, and |coauthors=) aren't related to each other and because these parameters may be concatenated into the variables used by |date= and |author#= (and aliases)
details of which parameter caused the error message are not provided.  Only one error message is emitted regardless of the number of deprecated parameters in the citation.
]]
function deprecated_parameter()
	if true ~= Page_in_deprecated_cat then	-- if we haven't been here before then set a 
		Page_in_deprecated_cat=true;		-- sticky flag so that if there are more than one deprecated parameter the category is added only once
		table.insert( z.message_tail, { seterror( 'deprecated_params', {}, true ) } );		-- add error message
	end
end

-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
--	return args and tostring( mw.message.newRawMessage( msg, args ) ) or msg;
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[
Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern  either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
]]
function kern_quotes (str)
	local left='&lt;span style=&quot;padding-left:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains leading single or double quote mark
	local right='&lt;span style=&quot;padding-right:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains trailing single or double quote mark
	
	if  str:match (&quot;^[\&quot;\'][^\']&quot;) then
		str = string.gsub( str, &quot;^[\&quot;\']&quot;, left, 1 );				-- replace (captured) leading single or double quote with left-side &lt;span&gt;
	end
	if str:match (&quot;[^\'][\&quot;\']$&quot;) then
		str = string.gsub( str, &quot;[\&quot;\']$&quot;, right, 1 );			-- replace (captured) trailing single or double quote with right-side &lt;span&gt;
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

At this writing, only |script-title= is supported.  It is anticipated that additional parameters will be created to use this function.

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
			if inArray (lang, {'ar', 'ja', 'ko', 'he', 'zh'}) then				-- is prefix one of these language codes?
				table.insert( z.properties_cats, 'CS1 uses ' .. name .. '-language script ('..lang..')');	-- categorize in language-specific categories
			else
				table.insert( z.properties_cats, 'CS1 uses foreign language script');	-- use this category as a catchall until language-specific category is available
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = '&lt;bdi' .. lang .. '&gt;' .. script_value .. '&lt;/bdi&gt;';			-- isolate incase script is rlt

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end

-- Wraps a string using a message_list configuration taking one argument
function wrap( key, str, lower )
	if not is_set( str ) then
		return &quot;&quot;;
	elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safeforitalics( str );
	end
	if lower == true then
		return substitute( cfg.messages[key]:lower(), {str} );
	else
		return substitute( cfg.messages[key], {str} );
	end		
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = selectone( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
]]
function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
	return wrap( hidden and 'hidden-error' or 'visible-error', content );
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return errorcomment( message, error_state.hidden );
end

-- Formats a wiki style external link
function externallinkid(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

-- Formats a wiki style internal link
function internallinkid(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

-- Format an external link with error checking
function externallink( URL, label, source )
	local error_str = &quot;&quot;;
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = seterror( 'bare_url_missing_title', { wrap( 'parameter', source ) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not checkurl( URL ) then
		error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
	end
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safeforurl( label ), &quot;]&quot;, error_str });
end

-- Formats a link to Amazon
function amazon(id, domain)
	if checkisbn( id ) then														-- see if asin value is a 10-digit isbn
		table.insert( z.maintenance_cats, &quot;CS1 maint: ASIN uses ISBN&quot;);			-- add to maint category so a bot or awb script can replace |asin= with |isbn=
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif inArray (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif inArray (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return externallinkid({link = handler.link,
		label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
		encode=handler.encode, separator = handler.separator})
end

--[[
format and error check arXiv identifier.  There are two valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces
]]

function arxiv (id)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = &quot;&quot;
	
	year, month, version = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d([v%d]*)$&quot;);				-- test for the 9108-0703 format
	if not year then		-- arXiv id is not proper 9108-0703 form
		year, month, version = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d([v%d]*)$&quot;);	-- test for the 0704- format
		if not year then	
			err_cat = ' ' .. seterror( 'bad_arxiv' );							-- arXiv id doesn't match either format
		else	-- id is the 0704- format
			year = tonumber(year);
			month = tonumber(month);
			if ((7 &gt; year) or (1 &gt; month and 12 &lt; month)) or					-- is year invalid or is month invalid? (doesn't test for future years)
				((7 == year) and (4 &gt; month)) or								-- when year is 07, is month invalid (before April)?
				is_set (version) and nil == version:match(&quot;v%d+&quot;) then			-- is version proper format of single 'v' followed by digits?
					err_cat = ' ' .. seterror( 'bad_arxiv' );					-- set error message
			end
		end
	else	-- id is the 9108-0703 format; are the date values ok
		year = tonumber(year);
		month = tonumber(month);
		if ((91 &gt; year and 7 &lt; year) or (1 &gt; month and 12 &lt; month)) or			-- if invalid year or invalid month
			((91 == year and 8 &gt; month) or (7 == year and 3 &lt; month)) or 		-- if years ok, are starting and ending months ok?
				is_set (version) and nil == version:match(&quot;v%d+&quot;) then			-- is version proper format of single 'v' followed by digits?
					err_cat = ' ' .. seterror( 'bad_arxiv' );					-- set error message
		end
	end

	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--[[
Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of the LCCN dictates the character type of the first 1-3 characters; the
rightmost eight are always digits. http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]
function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. seterror( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. seterror( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]
function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmid' );	-- set an error message
		end
	end
	
	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns true; otherwise, returns false because the embargo has expired or |embargo= not set in this cite.
]]
function is_embargoed(embargo)
	if is_set(embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 and tonumber( embargo_date ) &gt;= tonumber( todays_date ) then	--is embargo date is in the future?
			return true;	-- still embargoed
		end
	end
	return false;			-- embargo expired or |embargo= not set
end

--[[
Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future
the PMC identifier will not be linked to the article.  If the embargo specifies a date in the past, or if it is empty or omitted, then
the PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.
]]
function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_embargoed(embargo) then
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	--still embargoed so no external link
	else
		text = externallinkid({link = handler.link, label = handler.label,			--no embargo date, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.

-- DOI names contain two parts: prefix and suffix separated by a forward slash.
--  Prefix: directory indicator '10.' followed by a registrant code
--  Suffix: character string of any length chosen by the registrant

-- This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes,
-- or, if it ends with a period or a comma, this function will emit a bad_doi error message.

-- DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
-- and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely if ever used in doi names.

function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. seterror( 'bad_doi' );
	end
	return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);					-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	else
		return externallinkid({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode}) .. 
			' ' .. seterror( 'bad_ol' );
	end
end

--[[
Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.
]]
function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = externallinkid({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. seterror( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[
This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those citations that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).
]]
function set_titletype(cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;					-- if |type=none then type parameter not displayed
		end
		return title_type;						-- if |type= has been set to any other value use that value
	end

	if &quot;AV-media-notes&quot; == cite_class or &quot;DVD-notes&quot; == cite_class then		-- if this citation is cite AV media notes or cite DVD notes
		return &quot;Media notes&quot;;					-- display AV media notes / DVD media notes annotation

	elseif &quot;podcast&quot; == cite_class then			-- if this citation is cite podcast
		return &quot;Podcast&quot;;						-- display podcast annotation

	elseif &quot;pressrelease&quot; == cite_class then	-- if this citation is cite press release
		return &quot;Press release&quot;;					-- display press release annotation

	elseif &quot;techreport&quot; == cite_class then		-- if this citation is cite techreport
		return &quot;Technical report&quot;;				-- display techreport annotation
	
	elseif &quot;thesis&quot; == cite_class then			-- if this citation is cite thesis (degree option handled after this function returns)
			return &quot;Thesis&quot;;					-- display simple thesis annotation (without |degree= modification)
	end
end

--[[
Determines whether a URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
	-- Protocol-relative or URL scheme
	return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
	return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end


--[[
Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup.
]]
function strip_apostrophe_markup (argument)
	local pattern, c1, c2;
	if not is_set (argument) then return argument; end
	
	while true do																-- look for and remove all 5-apostrophe (bold and italic) markup
		if argument:match (&quot;%'%'%'%'%'&quot;) then										-- is there an instance of bold-italic?
			if argument:match (&quot;%'%'%'%'%'.*%'%'%'%'%'&quot;) then						-- 5, 5
				pattern, c1 = argument:match (&quot;(%'%'%'%'%'(.*)%'%'%'%'%')&quot;);		
				c2 = &quot;&quot;;														-- set to empty string so we do only one replacement at end
			elseif argument:match (&quot;%'%'%'%'%'.*%'%'%'.*%'%'&quot;) then				-- bold italic followed by italic (5, 3, 2)
				pattern, c1, c2 = argument:match (&quot;(%'%'%'%'%'(.*)%'%'%'(.*)%'%')&quot;);
			elseif argument:match (&quot;%'%'%'%'%'.*%'%'.*%'%'%'&quot;) then				-- bold italic followed by bold (5, 2, 3)
				pattern, c1, c2 = argument:match (&quot;(%'%'%'%'%'(.*)%'%'(.*)%'%'%')&quot;);
			elseif argument:match (&quot;%'%'%'.*%'%'.*%'%'%'%'%'&quot;) then				-- bold italic followed by italic (3, 2, 5)
				pattern, c1, c2 = argument:match (&quot;(%'%'%'(.*)%'%'(.*)%'%'%'%'%')&quot;);
			elseif argument:match (&quot;%'%'.*%'%'%'.*%'%'%'%'%'&quot;) then				-- italic followed by bold (2, 3, 5)
				pattern, c1, c2 = argument:match (&quot;(%'%'(.*)%'%'%'(.*)%'%'%'%'%')&quot;);
			end
			pattern = pattern:gsub(&quot;([%^%$%(%)%%%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);		-- pattern is not a literal string; escape lua's magic pattern characters
			argument=argument:gsub(pattern, c1..c2);							-- remove the markup
		else
			break;																-- none or no more 5-apostrophe matches
		end
	end
	while true do																-- look for and remove all 3-apostrophe (bold) markup
		if argument:match (&quot;%'%'%'.*%'%'%'&quot;) then								-- is there an instance of bold?
			pattern, c1 = argument:match (&quot;(%'%'%'(.*)%'%'%')&quot;)
			pattern = pattern:gsub(&quot;([%^%$%(%)%%%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);	-- pattern is not a literal string; escape lua's magic pattern characters
			argument=argument:gsub(pattern, c1);								-- remove the markup
		else
			break;																-- none or no more 3 matches
		end
	end
	while true do																-- look for and remove all 2-apostrophe (italic) markup
		if argument:match (&quot;%'%'.*%'%'&quot;) then									-- is there an instance of italic?
			pattern, c1 = argument:match (&quot;(%'%'(.*)%'%')&quot;)
			pattern = pattern:gsub(&quot;([%^%$%(%)%%%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);	-- pattern is not a literal string; escape lua's magic pattern characters
			argument=argument:gsub(pattern, c1);								-- remove the markup
		else
			break;																-- none or no more 2 matches
		end
	end
	return argument;															-- done
end

--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...
]]

function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end

-- Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.
function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end			-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);	-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end					-- no more urls
		pattern = pattern:gsub(&quot;([%^%$%(%)%%%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);	-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);					-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);						-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end

--[[
ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in checkisbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.
]]
function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of bytes
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end	-- isbn13 begins with 978 or 979
		isbn_str = { isbn_str:byte(1, len) };
		for i, v in ipairs( isbn_str ) do
			temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
		end
		return temp % 10 == 0;
	end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
	--[[ Note: We cannot use &lt;i&gt; for italics, as the expected behavior for
	italics specified by ''...'' in the title is that they will be inverted
	(i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
	tend to interact poorly under Mediawiki's HTML tidy. ]]
	
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end

--[[
Joins a sequence of strings together while checking for duplicate separation characters.

TODO: safejoin() has a flaw where it won't remove the duplicate character from a |title= / |url= combination.
This is because by the time we get here, |title=http://somesite.com and |title=Document Title. have been combined:
	[http://somesite.com and ''Document Title.'']
so that now, the last character is not sepc but is ] (unless sepc == ']' which breaks the external link)
]]
function safejoin( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';
	local comp = '';
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then
			str = value;
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then
				-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
			else
				comp = value;
			end
			
			if comp:sub(1,1) == duplicate_char then
				trim = false;
				end_chr = str:sub(-1,-1);
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
				if end_chr == duplicate_char then
					str = str:sub(1,-2);
				elseif end_chr == &quot;'&quot; then
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
						str = str:sub(1, -4) .. &quot;''&quot;;
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
						trim = true;
					end
				elseif end_chr == &quot;]&quot; then
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
						trim = true;
					end
				elseif end_chr == &quot; &quot; then
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
						str = str:sub(1,-3);
					end
				end

				if trim then
					if value ~= comp then 
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
					else
						value = value:sub( 2, -1 );
					end
				end
			end
			str = str .. value;
		end
	end
	return str;
end  

-- Attempts to convert names to initials.
function reducetoinitials(first)
	local initials = {}
	local i = 0;										-- counter for number of initials
	for word in string.gmatch(first, &quot;%S+&quot;) do
		table.insert(initials, string.sub(word,1,1))	-- Vancouver format does not include full stops.
		i = i + 1;										-- bump the counter 
		if 2 &lt;= i then break; end						-- only two initials allowed in Vancouver system; if 2, quit
	end
	return table.concat(initials)						-- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
	local sep = control.sep;
	local namesep = control.namesep
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}
	local etal = false;
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if maximum ~= nil and maximum &lt; 1 then return &quot;&quot;, 0; end
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if maximum ~= nil and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
					one = one .. namesep .. first 
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;		-- link author/editor if this page is not the author's/editor's page
				end

				if is_set(person.link) and nil ~= person.link:find(&quot;//&quot;) then one = one .. &quot; &quot; .. seterror( 'bad_authorlink' ) end	-- check for url in author link;
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;
		end
		text[#text] = nil; 
	end
	
	local result = table.concat(text) -- construct list
	if etal then 
		local etal_text = cfg.messages['et al'];
		result = result .. &quot; &quot; .. etal_text;
	end
	
	-- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
	if ( &quot;scap&quot; == format ) then result = 
		'&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
	end 
	return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
	return &quot;CITEREF&quot; .. table.concat( options );
end

--[[
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.
]]
function extractnames(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	
	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary

	while true do
		last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { seterror( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 == count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			names[n] = {last = last, first = first, link = link, mask = mask};	-- add this name to our names list
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { seterror( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	return names;																-- all done, return our list of names
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
	local id_list = {};
	for k, v in pairs( cfg.id_handlers ) do	
		v = selectone( args, v.parameters, 'redundant_parameters' );
		if is_set(v) then id_list[k] = v; end
	end
	return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
	local new_list, handler = {};
	
	function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, externallinkid( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internallinkid( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internallinkid( handler );
			if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
	local value = nil;
	local selected = '';
	local error_list = {};
	
	if index ~= nil then index = tostring(index); end
	
	-- Handle special case of &quot;#&quot; replaced by empty string
	if index == '1' then
		for _, v in ipairs( possible ) do
			v = v:gsub( &quot;#&quot;, &quot;&quot; );
			if is_set(args[v]) then
				if value ~= nil and selected ~= v then
					table.insert( error_list, v );
				else
					value = args[v];
					selected = v;
				end
			end
		end		
	end
	
	for _, v in ipairs( possible ) do
		if index ~= nil then
			v = v:gsub( &quot;#&quot;, index );
		end
		if is_set(args[v]) then
			if value ~= nil and selected ~=  v then
				table.insert( error_list, v );
			else
				value = args[v];
				selected = v;
			end
		end
	end
	
	if #error_list &gt; 0 then
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap( 'parameter', k );
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap( 'parameter', selected );
		table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
function COinS(data)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end
	
	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
			end
		end
	});
	
	if is_set(data.Chapter) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Chapter;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	elseif is_set(data.Periodical) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
		OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	else
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
	end
	
	OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
	OCinSoutput[&quot;rft.date&quot;] = data.Date;
	OCinSoutput[&quot;rft.series&quot;] = data.Series;
	OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
	OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
	OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
	OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
	OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
	
	for k, v in pairs( data.ID_list ) do
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
	
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = v.last, v.first;
		if k == 1 then
			if is_set(last) then
				OCinSoutput[&quot;rft.aulast&quot;] = last;
			end
			if is_set(first) then 
				OCinSoutput[&quot;rft.aufirst&quot;] = first;
			end
		end
		if is_set(last) and is_set(first) then
			OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
		elseif is_set(last) then
			OCinSoutput[&quot;rft.au&quot;] = last;
		end
	end
	
	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 code.  Handles the special case that is Norwegian where
ISO639-1 code 'no' is mapped to language name 'Norwegian Bokmål' by Extention:CLDR.

Returns the language name and associated ISO639-1 code.  Because case of the source may be incorrect or different from the case that Wikimedia
uses, the name comparisons are done in lower case and when a match is found, the Wikimedia version (assumed to be correct) is returned along
with the code.  When there is no match, we return the original language name string.

mw.language.fetchLanguageNames() will return a list of languages that aren't part of ISO639-1. Names that aren't ISO639-1 but that are included
in the list will be found if that name is provided in the |language= parameter.  For example, if |language=Samaritan Aramaic, that name will be
found with the associated code 'sam', not an ISO639-1 code.  When names are found and the associated code is not two characters, this function
returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.
]]

function get_iso639_code (lang)
	if 'Norwegian' == lang then
		return lang, 'no';														-- special case related to Wikimedia remap of code 'no' at Extension:CLDR
	end
	
	local languages = mw.language.fetchLanguageNames('en', 'all')				-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() then												-- ISO639-1 codes only
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the ISO639-1 code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for ISO639-1 code
end

--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Get language name from ISO639-1 code value provided.  If a code is valid use the returned name; if not, then use the value that was provided with the language parameter.

There is an exception.  There are three ISO639-1 codes for Norewegian language variants.  There are two official variants: Norwegian Bokmål (code 'nb') and
Norwegian Nynorsk (code 'nn').  The third, code 'no',  is defined by ISO639-1 as 'Norwegian' though in Norway this is pretty much meaningless.  However, it appears
that on enwiki, editors are for the most part unaware of the nb and nn variants (compare page counts for these variants at Category:Articles with non-English-language external links.

Because Norwegian Bokmål is the most common language variant, Media wiki has been modified to return Norwegian Bokmål for ISO639-1 code 'no'. Here we undo that and
return 'Norwegian' when editors use |language=no.  We presume that editors don't know about the variants or can't descriminate between them.

See Help talk:Citation Style_1#An ISO 639-1 language name test

When |language= contains a valid ISO639-1 code, the page is assigned to the category for that code: Category:Norwegian-language sources (no) if
the page is a mainspace page and the ISO639-1 code is not 'en'.  Similarly, if the  parameter is |language=Norwegian, it will be categorized in the same way.

TODO: Error message when language or language code is not ISO639-1?
]]

function language_parameter (lang, namespace)
	local code;			-- the ISO639-1 two character code
	local name;			-- the language name
	local test='';
		
	if 0 == namespace and (('en' == lang:lower()) or ('english' == lang:lower())) then
		table.insert (z.maintenance_cats, 'CS1 maint: English language specified');		-- add maintenance category if |language=English or |language=en in article space
	end

	if 2 == lang:len() then														-- ISO639-1 language code are 2 characters (fetchLanguageName also supports 3 character codes)
		name = mw.language.fetchLanguageName( lang:lower(), &quot;en&quot; );				-- get ISO 639-1 language name if Language is a proper code
	end

	if is_set (name) then														-- if Language specified a valid ISO639-1 code
		code = lang:lower();													-- save it
	else
		name, code = get_iso639_code (lang);									-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
	end

	if is_set (code) then
		if 'no' == code then name = 'Norwegian' end;							-- override wikimedia when code is 'no'
			if 0 == namespace and 'en' ~= code then					-- is this page main / article space and English not the language?
				table.insert( z.properties_cats, 'CS1 ' .. name .. '-language sources (' .. code .. ')');	-- in main space and not English: categorize
			end
		end
	return (&quot; &quot; .. wrap( 'language', name));									-- wrap with '(in ...)'
end




--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------
This is the main function doing the majority of the citation
formatting.
]]
function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple
	aliases to single internal variable.
	]]
	local A = argument_wrapper( args );

	local i 
	local PPrefix = A['PPrefix']
	local PPPrefix = A['PPPrefix']
	if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
	
	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local Authors = A['Authors'];
	local a = extractnames( args, 'AuthorList' );

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];
	local Editors = A['Editors'];
	local e = extractnames( args, 'EditorList' );

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
	local Chapter = A['Chapter'];
	local ChapterLink = A['ChapterLink'];
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveURL = A['ArchiveURL'];
	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');
	local Periodical = A['Periodical'];

	local Series = A['Series'];
	local Volume = A['Volume'];
	local Issue = A['Issue'];
	local Position = '';
	local Page = A['Page'];
	local Pages = hyphentodash( A['Pages'] );	
	local At = A['At'];

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
	local SubscriptionRequired = A['SubscriptionRequired'];
	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local ArchiveDate = A['ArchiveDate'];
	local Agency = A['Agency'];
	local DeadURL = A['DeadURL']
	local Language = A['Language'];
	local Format = A['Format'];
	local Ref = A['Ref'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
	local Embargo = A['Embargo'];

	local ID_list = extractids( args );
--[[ Hide unfinished cite newsgroup code so that long delayed update can take place
	-- special case for cite newsgroup which uses |id= for a usenet article or post id
	-- |id= is not included in COinS so here we convert it to an ID that will be included in COinS
	if ('newsgroup' == config.CitationClass) and (is_set (ID)) then
		ID_list['USENETID']=ID;			-- add this new 'id' to the list of IDs
		ID = '';						-- and unset
	end
]]	
	local Quote = A['Quote'];
	local PostScript = A['PostScript'];

	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');
	local sepc = A['Separator'];

	local LastAuthorAmp = A['LastAuthorAmp'];
	local no_tracking_cats = A['NoTracking'];

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Cointerviewers = A['Cointerviewers'];			-- deprecated
	local Interviewer = A['Interviewer'];				-- deprecated
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local page_type;									-- is this needed?  Doesn't appear to be used anywhere;
	local use_lowercase = ( sepc ~= '.' );
	local this_page = mw.title.getCurrentTitle();		--Also used for COinS and for language
	local anchor_year;									-- used in the CITEREF identifier
	local COinS_date;									-- used in the COinS metadata

-- Set postscript default.
	if not is_set (PostScript) then						-- if |postscript= has not been set (Postscript is nil which is the default for {{citation}}) and
		if (config.CitationClass ~= &quot;citation&quot;) then	-- this template is not a citation template
			PostScript = '.';							-- must be a cite xxx template so set postscript to default (period)
		end
	else
		if PostScript:lower() == 'none' then			-- if |postscript=none then
			PostScript = '';							-- no postscript
		end
	end

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories.
	if not is_set(no_tracking_cats) then				-- ignore if we are already not going to categorize this page
		if inArray (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;					-- set no_tracking_cats
		end
	end

-- check for extra |page=, |pages= or |at= parameters. 
	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Page = Page .. &quot; &quot; .. seterror('extra_pages');	-- add error message
			Pages = '';										-- unset the others
			At = '';
		end
	elseif is_set(Pages) then
		if is_set(At) then
			Pages = Pages .. &quot; &quot; .. seterror('extra_pages');	-- add error messages
			At = '';											-- unset
		end
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped

All other combinations of |encyclopedia, |title, and |article are not modified
]]
	if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
		if is_set(Periodical) then					-- Periodical is set when |encyclopedia is set
			if is_set(Title) then
				if not is_set(Chapter) then
					Chapter = Title;				-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					TransChapter = TransTitle;
					Title = Periodical;
					Periodical = '';				-- redundant so unset
					TransTitle = '';				-- redundant so unset
				end
			else									-- |title not set
				Title = Periodical;					-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';					-- redundant so unset
			end
		end
	end

--special cases for citation.
	if (config.CitationClass == &quot;citation&quot;) then		-- for citation templates
		if not is_set (Ref) then						-- if |ref= is not set
			Ref = &quot;harv&quot;;								-- set default |ref=harv
		end
		if not is_set (sepc) then						-- if |separator= is not set
			sepc = ',';									-- set citation separator to its default (comma)
		end
	else												-- not a citation template
		if not is_set (sepc) then						-- if |separator= has not been set
			sepc = '.';									-- set cite xxx separator to its default (period)
		end
	end

-- check for special case where |separator=none
	if 'none' == sepc:lower() then						-- if |separator=none
		sepc = '';										-- then set it to an empty string
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then	-- special case for cite techreport
		if is_set(Issue) then						-- cite techreport uses 'number', which other citations aliase to 'issue'
			if not is_set(ID) then					-- can we use ID for the &quot;number&quot;?
				ID = Issue;							-- yes, use it
				Issue = &quot;&quot;;							-- unset Issue so that &quot;number&quot; isn't duplicated in the rendered citation or COinS metadata
			else									-- can't use ID so emit error message
				ID = ID .. &quot; &quot; .. seterror('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Interviewer) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Interviewer;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Interviewer;
			end
			if is_set(Cointerviewers) then
				Others = Others .. sepc .. ' ' .. Cointerviewers;
			end
		else
			Others = '(Interview)';
		end
	end

--Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set
	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_embargoed(Embargo) then
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];	-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];		-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
--TODO: if this is only for {{cite conference}}, shouldn't we be checking? (if config.CitationClass=='conference' then ...)
	if is_set(BookTitle) then
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = BookTitle;
		TitleLink = '';
		TransTitle = '';
	end

-- Account for the oddity that is {{cite episode}}, before generation of COinS data.
--[[	-- {{cite episode}} is not currently supported by this module
	if config.CitationClass == &quot;episode&quot; then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];
		local Season = A['Season'];
		local SeriesNumber = A['SeriesNumber'];
		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
		local Sep = (first_set(A[&quot;SeriesSeparator&quot;], A[&quot;Separator&quot;]) or &quot;&quot;) .. &quot; &quot;;
		
		if is_set(Issue) then table.insert(s, cfg.messages[&quot;episode&quot;] .. &quot; &quot; .. Issue); Issue = ''; end
		if is_set(Season) then table.insert(s, cfg.messages[&quot;season&quot;] .. &quot; &quot; .. Season); end
		if is_set(SeriesNumber) then table.insert(s, cfg.messages[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber); end
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		
		Date = Date or AirDate;
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = Series;
		TitleLink = SeriesLink;
		TransTitle = '';
		
		Series = table.concat(s, Sep);
		ID = table.concat(n, Sep);
	end
-- end of {{cite episode}} stuff]]

-- legacy: promote concatenation of |day=, |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set(Date) then
		Date = Year;						-- promote Year to Date
		Year = nil;							-- make nil so Year as empty string isn't used for CITEREF
		if is_set(Date) then
			local Month = A['Month'];
			if is_set(Month) then
				Date = Month .. &quot; &quot; .. Date;
				local Day = A['Day']
				if is_set(Day) then Date = Day .. &quot; &quot; .. Date end
			end
		elseif is_set(PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;			-- promote PublicationDate to Date
			PublicationDate = '';			-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end	-- if PublicationDate is same as Date, don't display in rendered citation


--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	anchor_year, COinS_date, error_message = dates({['accessdate']=AccessDate, ['airdate']=AirDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
		['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});
	if is_set(error_message) then
		table.insert( z.message_tail, { seterror( 'bad_date', {error_message}, true ) } );	-- add this error message
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for
	-- automated parsing of citation information.
	-- this is the function call to COinS()
	local OCinSoutput = COinS{
		['Periodical'] = Periodical,
		['Chapter'] = Chapter, --strip_apostrophe_markup (Chapter),						-- Chapter stripped of bold / italic wikimarkup
		['Title'] = Title, --make_coins_title (Title, ScriptTitle),		-- strip_apostrophe_markup (Title),							-- Title stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = first_set(COinS_date, Date),		-- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here?  Should we be including invalid dates in metadata?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set(Page, Pages, At)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set( URL, ChapterURL ),
		['Authors'] = a,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	};
--[[Why is this here?  Why are we mapping Title to Chapter when Periodical is set?
	if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = '';
		TitleLink = '';
		TransTitle = '';
	end
]]
--[[ Hide unfinished cite newsgroup code so that long delayed update can take place
-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername and ID
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = '[Newsgroup]:&amp;nbsp;' ..  externallink( 'news:' .. PublisherName, PublisherName );
		end
	end
]]


	-- Now perform various field 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 not is_set(Authors) then
		local Maximum = tonumber( A['DisplayAuthors'] );
		
		-- Preserve old-style implicit et al.
		if not is_set(Maximum) and #a == 9 then 
			Maximum = 8;
			table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
		elseif not is_set(Maximum) then
			Maximum = #a + 1;
		end
			
		local control = { 
			sep = A[&quot;AuthorSeparator&quot;] .. &quot; &quot;,
			namesep = (first_set(A[&quot;AuthorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
			format = A[&quot;AuthorFormat&quot;],
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text				-- get current page name so that we don't wikilink to it via authorlinkn
		};
		
		-- If the coauthor field is also used, prevent ampersand and et al. formatting.
		if is_set(Coauthors) then
			control.lastauthoramp = nil;
			control.maximum = #a + 1;
		end
		
		Authors = listpeople(control, a) 
	end

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { seterror('coauthors_missing_author', {}, true) } );	-- emit error message
	end

	local EditorCount
	if not is_set(Editors) then
		local Maximum = tonumber( A['DisplayEditors'] );
		-- Preserve old-style implicit et al.
		if not is_set(Maximum) and #e == 4 then 
			Maximum = 3;
			table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
		elseif not is_set(Maximum) then
			Maximum = #e + 1;
		end

		local control = { 
			sep = A[&quot;EditorSeparator&quot;] .. &quot; &quot;,
			namesep = (first_set(A[&quot;EditorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
			format = A['EditorFormat'],
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text				-- get current page name so that we don't wikilink to it via authorlinkn
		};

		Editors, EditorCount = listpeople(control, e);
	else
		EditorCount = 1;
	end

	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	if config.CitationClass == &quot;map&quot; then
		if not is_set( Authors ) and is_set( PublisherName ) then
			Authors = PublisherName;
			PublisherName = &quot;&quot;;
		end
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap( 'cartography', Cartography, use_lowercase );
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end		
	end
	
	if  not is_set(URL) and
		not is_set(ChapterURL) and
		not is_set(ArchiveURL) and
		not is_set(ConferenceURL) and
		not is_set(TranscriptURL) then
		
		-- Test if cite web or cite podcast |url= is missing or empty 
		if inArray(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;}) then	
			table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
		end
		
		-- Test if accessdate is given without giving a URL
		if is_set(AccessDate) then
			table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
		
		-- Test if format is given without giving a URL
		if is_set(Format) then
			Format = Format .. seterror( 'format_missing_url' );
		end
	end
	
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(Periodical) and
		not is_set(Conference) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
		table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
	end
	
	Format = is_set(Format) and &quot; (&quot; .. Format .. &quot;)&quot; or &quot;&quot;;
	
	local OriginalURL = URL
	DeadURL = DeadURL:lower();
	if is_set( ArchiveURL ) then
		if ( DeadURL ~= &quot;no&quot; ) then
			URL = ArchiveURL
			URLorigin = A:ORIGIN('ArchiveURL')
		end
	end
	
	-- Format chapter / article title
	if is_set(Chapter) and is_set(ChapterLink) then 
		Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot;;
	end

	Chapter = kern_quotes (Chapter);				-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
	Chapter = wrap( 'quoted-title', Chapter );
	TransChapter = wrap( 'trans-quoted-title', TransChapter );

	local TransError = &quot;&quot;
	if is_set(TransChapter) then
		if not is_set(Chapter) then
			TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );		-- add error message
		else
			TransChapter = &quot; &quot; .. TransChapter;
		end
	end
	
	Chapter = Chapter .. TransChapter;
	
	if is_set(Chapter) then
		if not is_set(ChapterLink) then
			if is_set(ChapterURL) then
				Chapter = externallink( ChapterURL, Chapter ) .. TransError;
				if not is_set(URL) then
					Chapter = Chapter .. Format;
					Format = &quot;&quot;;
				end
			elseif is_set(URL) then 
				Chapter = externallink( URL, Chapter ) .. TransError .. Format;
				URL = &quot;&quot;;
				Format = &quot;&quot;;
			else
				Chapter = Chapter .. TransError;
			end			
		elseif is_set(ChapterURL) then
			Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. 
				TransError;
		else
			Chapter = Chapter .. TransError;
		end
		Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
	elseif is_set(ChapterURL) then
		Chapter = &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. sepc .. &quot; &quot;;
	end		
	
	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;journal&quot;,&quot;pressrelease&quot;,&quot;conference&quot;,&quot;podcast&quot;}) then
		Title = kern_quotes (Title);											-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
		Title = wrap( 'quoted-title', Title );
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap( 'trans-quoted-title', TransTitle );
--		Chapter = '';								-- chapter not allowed
	else
		Title = wrap( 'italic-title', Title );
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap( 'trans-italic-title', TransTitle );
	end

	TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then 
			Title = externallink( URL, Title ) .. TransError .. Format	   
			URL = &quot;&quot;;
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end
	
	if is_set(Place) then
		Place = &quot; &quot; .. wrap( 'written', Place, use_lowercase ) .. sepc .. &quot; &quot;;
	end
	
	if is_set(Conference) then
		if is_set(ConferenceURL) then
			Conference = externallink( ConferenceURL, Conference );
		end
		Conference = sepc .. &quot; &quot; .. Conference
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. externallink( ConferenceURL, nil, ConferenceURLorigin );
	end
	
	if not is_set(Position) then
		local Minutes = A['Minutes'];
		if is_set(Minutes) then
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			local Time = A['Time'];
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end
	
	if not is_set(Page) then
		if is_set(Pages) then
			if is_set(Periodical) and
				not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
				Pages = &quot;: &quot; .. Pages;
			elseif tonumber(Pages) ~= nil then
				Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
			else
				Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
			end
		end
	else
		if is_set(Periodical) and
			not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
			Page = &quot;: &quot; .. Page;
		else
			Page = sepc ..&quot; &quot; .. PPrefix .. Page;
		end
	end
	
	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Inset = A['Inset'];
		if first_set( Pages, Page, At ) ~= nil or sepc ~= '.' then
			if is_set( Section ) then
				Section = &quot;, &quot; .. wrap( 'section', Section, true );
			end
			if is_set( Inset ) then
				Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
			end
		else
			if is_set( Section ) then
				Section = sepc .. &quot; &quot; .. wrap( 'section', Section, use_lowercase );
				if is_set( Inset ) then
					Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
				end
			elseif is_set( Inset ) then
				Inset = sepc .. &quot; &quot; .. wrap( 'inset', Inset, use_lowercase );
			end			
		end			
		At = At .. Section .. Inset;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language, this_page.namespace);			-- format, categories (article namespace only), name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;

-- handle type parameter for those CS1 citations that have default values

	if inArray(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then	-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then					-- if type parameter is specified
		TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot;;	-- display it in parentheses
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	Edition = is_set(Edition) and (&quot; &quot; .. wrap( 'edition', Edition )) or &quot;&quot;;
	Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc ..&quot; &quot; .. Volume;
		  else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
		end
	end

--[[ This code commented out while discussion continues until after week of 2014-03-23 live module update;
	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc .. &quot; &quot; .. Volume;
		  else
			  Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
			  if is_set(Series) then Volume = sepc .. Volume;
			  end
		end
	end
]]	
	------------------------------------ totally unrelated data
	--[[ Loosely mimic {{subscription required}} template; Via parameter identifies a delivery source that is not the publisher; these sources often, but not always, exist
	behind a registration or paywall.  So here, we've chosen to decouple via from subscription (via has never been part of the registration required template).
	
	Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link note is displayed. There are no error messages for this condition.
	]]
	if is_set(Via) then
		Via = &quot; &quot; .. wrap( 'via', Via );
	end

	if is_set(SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription']; --here when 'via' parameter not used but 'subscription' is
	elseif is_set(RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration']; --here when 'via' and 'subscription' parameters not used but 'registration' is
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
		AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
			.. substitute( retrv_text, {AccessDate} ) .. '&lt;/span&gt;'
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end

	
	ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo} );

	if is_set(URL) then
		URL = &quot; &quot; .. externallink( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
			Quote = Quote:sub(2,-2);
		end
		Quote = sepc ..&quot; &quot; .. wrap( 'quoted-text', Quote ); 
		PostScript = &quot;&quot;;							-- CS1 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = seterror('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ externallink( ArchiveURL, arch_text ), ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text,
				{ externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ seterror('archive_missing_url'), ArchiveDate } );
		end
	else
		Archived = &quot;&quot;
	end
	
	local Lay
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
		end			
	else
		Lay = &quot;&quot;;
	end
	
	if is_set(Transcript) then
		if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
	elseif is_set(TranscriptURL) then
		Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
	end
	
	local Publisher;
	if is_set(Periodical) and
		not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap( 'published', PublicationDate );
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap( 'published', PublicationDate ) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap( 'italic-title', Periodical ) 
		else 
			Periodical = wrap( 'italic-title', Periodical )
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon
	if inArray(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, 
			Language, Cartography, Edition, Publisher, Agency, Volume, Issue}, sepc );
	else 
		tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, Language, 
			Volume, Issue, Others, Cartography, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Page .. Pages .. At;
	
	if is_set(Authors) then
		if is_set(Coauthors) then
			Authors = Authors .. A['AuthorSeparator'] .. &quot; &quot; .. Coauthors
		end
		if is_set(Date) then
			Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		elseif string.sub(Authors,-1,-1) == sepc then
			Authors = Authors .. &quot; &quot;
		else
			Authors = Authors .. sepc .. &quot; &quot;
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			if (sepc ~= '.') then in_text = in_text:lower() end
			Editors = in_text .. Editors .. post_text;
			if (string.sub(Editors,-1,-1) == sepc)
				then Editors = Editors .. &quot; &quot;
				else Editors = Editors .. sepc .. &quot; &quot;
			end
		end
		text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
		text = safejoin( {text, pgtext, idcommon}, sepc );
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
		text = safejoin( {text, pgtext, idcommon}, sepc );
	else
		if is_set(Date) then
			if ( string.sub(tcommon,-1,-1) ~= sepc )
			  then Date = sepc ..&quot; &quot; .. Date .. OrigYear
			  else Date = &quot; &quot; .. Date .. OrigYear
			end
		end
		if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
			text = safejoin( {Chapter, Place, tcommon}, sepc );
			text = safejoin( {text, pgtext, Date, idcommon}, sepc );
		else
			text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
			text = safejoin( {text, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
--		text = text:sub(1,-2);	--Remove final separator (assumes that sepc is only one character)
	end	
	
	text = safejoin( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;span/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = &quot;citation &quot; .. config.CitationClass;
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
		local id = Ref
		if ( &quot;harv&quot; == Ref ) then
			local names = {} --table of last names &amp; year
			if #a &gt; 0 then
				for i,v in ipairs(a) do 
					names[i] = v.last 
					if i == 4 then break end
				end
			elseif #e &gt; 0 then
				for i,v in ipairs(e) do 
					names[i] = v.last 
					if i == 4 then break end				
				end
			end
			names[ #names + 1 ] = first_set(Year, anchor_year);	-- Year first for legacy citations
			id = anchorid(names)
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = seterror('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then 
		text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	else
		text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	end		

	local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
	
	-- Note: Using display: none on then COinS span breaks some clients.
	local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
	text = text .. OCinS;
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. errorcomment( v[1], v[2] );
				else
					text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if inArray(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
	local pframe = frame:getParent()
	
	if nil ~= string.find( frame:getTitle(), 'sandbox', 1, true ) then				-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData( 'Module:Citation/CS1/Configuration/sandbox' );	-- load sandbox versions of Configuration and Whitelist and ...
		whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist/sandbox' );
		dates = require('Module:Citation/CS1/Date_validation/sandbox').dates	-- ... sandbox version of date validation code
	else																	-- otherwise
		cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );			-- load live versions of Configuration and Whitelist and ...
		whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );
		dates = require('Module:Citation/CS1/Date_validation').dates		-- ... live version of date validation code
	end
	
	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = seterror( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if #suggestions == 0 then
						suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
					end
					if suggestions[ k:lower() ] ~= nil then
						error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
					else
						error_text, error_state = seterror( 'parameter_ignored', {k}, true );
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	
	
	return citation0( config, args)
end

return z</text>
      <sha1>2surmt4pinx8874ri6s36q4o78cjgg8</sha1>
    </revision>
    <revision>
      <id>4683</id>
      <parentid>4682</parentid>
      <timestamp>2014-10-13T15:06:55Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox; script error fix in strip_apostrophe_markup();</comment>
      <origin>4683</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="97044" sha1="aqa1szgccy7p5s7kj3l0hynr45jqgu7" xml:space="preserve">
local z = {
	error_categories = {};		-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};		-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};		-- for categorizing citations based on certain properties, language of source for instance
}

-- Whether variable is set or not
function is_set( var )
	return not (var == nil or var == '');
end

-- First set variable or nil if none
function first_set(...)
	local list = {...};
	for _, var in pairs(list) do
		if is_set( var ) then
			return var;
		end
	end
end

-- Whether needle is in haystack
function inArray( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end

--[[
Categorize and emit an error message when the citation contains one or more deprecated parameters.  Because deprecated parameters (currently |day=, |month=,
|coauthor=, and |coauthors=) aren't related to each other and because these parameters may be concatenated into the variables used by |date= and |author#= (and aliases)
details of which parameter caused the error message are not provided.  Only one error message is emitted regardless of the number of deprecated parameters in the citation.
]]
function deprecated_parameter()
	if true ~= Page_in_deprecated_cat then	-- if we haven't been here before then set a 
		Page_in_deprecated_cat=true;		-- sticky flag so that if there are more than one deprecated parameter the category is added only once
		table.insert( z.message_tail, { seterror( 'deprecated_params', {}, true ) } );		-- add error message
	end
end

-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
--	return args and tostring( mw.message.newRawMessage( msg, args ) ) or msg;
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[
Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern  either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
]]
function kern_quotes (str)
	local left='&lt;span style=&quot;padding-left:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains leading single or double quote mark
	local right='&lt;span style=&quot;padding-right:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains trailing single or double quote mark
	
	if  str:match (&quot;^[\&quot;\'][^\']&quot;) then
		str = string.gsub( str, &quot;^[\&quot;\']&quot;, left, 1 );				-- replace (captured) leading single or double quote with left-side &lt;span&gt;
	end
	if str:match (&quot;[^\'][\&quot;\']$&quot;) then
		str = string.gsub( str, &quot;[\&quot;\']$&quot;, right, 1 );			-- replace (captured) trailing single or double quote with right-side &lt;span&gt;
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

At this writing, only |script-title= is supported.  It is anticipated that additional parameters will be created to use this function.

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
			if inArray (lang, {'ar', 'ja', 'ko', 'he', 'zh'}) then				-- is prefix one of these language codes?
				table.insert( z.properties_cats, 'CS1 uses ' .. name .. '-language script ('..lang..')');	-- categorize in language-specific categories
			else
				table.insert( z.properties_cats, 'CS1 uses foreign language script');	-- use this category as a catchall until language-specific category is available
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = '&lt;bdi' .. lang .. '&gt;' .. script_value .. '&lt;/bdi&gt;';			-- isolate incase script is rlt

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end

-- Wraps a string using a message_list configuration taking one argument
function wrap( key, str, lower )
	if not is_set( str ) then
		return &quot;&quot;;
	elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safeforitalics( str );
	end
	if lower == true then
		return substitute( cfg.messages[key]:lower(), {str} );
	else
		return substitute( cfg.messages[key], {str} );
	end		
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = selectone( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
]]
function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
	return wrap( hidden and 'hidden-error' or 'visible-error', content );
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return errorcomment( message, error_state.hidden );
end

-- Formats a wiki style external link
function externallinkid(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

-- Formats a wiki style internal link
function internallinkid(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

-- Format an external link with error checking
function externallink( URL, label, source )
	local error_str = &quot;&quot;;
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = seterror( 'bare_url_missing_title', { wrap( 'parameter', source ) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not checkurl( URL ) then
		error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
	end
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safeforurl( label ), &quot;]&quot;, error_str });
end

-- Formats a link to Amazon
function amazon(id, domain)
	if checkisbn( id ) then														-- see if asin value is a 10-digit isbn
		table.insert( z.maintenance_cats, &quot;CS1 maint: ASIN uses ISBN&quot;);			-- add to maint category so a bot or awb script can replace |asin= with |isbn=
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif inArray (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif inArray (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return externallinkid({link = handler.link,
		label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
		encode=handler.encode, separator = handler.separator})
end

--[[
format and error check arXiv identifier.  There are two valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces
]]

function arxiv (id)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = &quot;&quot;
	
	year, month, version = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d([v%d]*)$&quot;);				-- test for the 9108-0703 format
	if not year then		-- arXiv id is not proper 9108-0703 form
		year, month, version = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d([v%d]*)$&quot;);	-- test for the 0704- format
		if not year then	
			err_cat = ' ' .. seterror( 'bad_arxiv' );							-- arXiv id doesn't match either format
		else	-- id is the 0704- format
			year = tonumber(year);
			month = tonumber(month);
			if ((7 &gt; year) or (1 &gt; month and 12 &lt; month)) or					-- is year invalid or is month invalid? (doesn't test for future years)
				((7 == year) and (4 &gt; month)) or								-- when year is 07, is month invalid (before April)?
				is_set (version) and nil == version:match(&quot;v%d+&quot;) then			-- is version proper format of single 'v' followed by digits?
					err_cat = ' ' .. seterror( 'bad_arxiv' );					-- set error message
			end
		end
	else	-- id is the 9108-0703 format; are the date values ok
		year = tonumber(year);
		month = tonumber(month);
		if ((91 &gt; year and 7 &lt; year) or (1 &gt; month and 12 &lt; month)) or			-- if invalid year or invalid month
			((91 == year and 8 &gt; month) or (7 == year and 3 &lt; month)) or 		-- if years ok, are starting and ending months ok?
				is_set (version) and nil == version:match(&quot;v%d+&quot;) then			-- is version proper format of single 'v' followed by digits?
					err_cat = ' ' .. seterror( 'bad_arxiv' );					-- set error message
		end
	end

	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--[[
Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of the LCCN dictates the character type of the first 1-3 characters; the
rightmost eight are always digits. http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]
function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. seterror( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. seterror( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]
function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmid' );	-- set an error message
		end
	end
	
	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns true; otherwise, returns false because the embargo has expired or |embargo= not set in this cite.
]]
function is_embargoed(embargo)
	if is_set(embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 and tonumber( embargo_date ) &gt;= tonumber( todays_date ) then	--is embargo date is in the future?
			return true;	-- still embargoed
		end
	end
	return false;			-- embargo expired or |embargo= not set
end

--[[
Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future
the PMC identifier will not be linked to the article.  If the embargo specifies a date in the past, or if it is empty or omitted, then
the PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.
]]
function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_embargoed(embargo) then
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	--still embargoed so no external link
	else
		text = externallinkid({link = handler.link, label = handler.label,			--no embargo date, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.

-- DOI names contain two parts: prefix and suffix separated by a forward slash.
--  Prefix: directory indicator '10.' followed by a registrant code
--  Suffix: character string of any length chosen by the registrant

-- This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes,
-- or, if it ends with a period or a comma, this function will emit a bad_doi error message.

-- DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
-- and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely if ever used in doi names.

function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. seterror( 'bad_doi' );
	end
	return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);					-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	else
		return externallinkid({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode}) .. 
			' ' .. seterror( 'bad_ol' );
	end
end

--[[
Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.
]]
function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = externallinkid({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. seterror( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[
This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those citations that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).
]]
function set_titletype(cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;					-- if |type=none then type parameter not displayed
		end
		return title_type;						-- if |type= has been set to any other value use that value
	end

	if &quot;AV-media-notes&quot; == cite_class or &quot;DVD-notes&quot; == cite_class then		-- if this citation is cite AV media notes or cite DVD notes
		return &quot;Media notes&quot;;					-- display AV media notes / DVD media notes annotation

	elseif &quot;podcast&quot; == cite_class then			-- if this citation is cite podcast
		return &quot;Podcast&quot;;						-- display podcast annotation

	elseif &quot;pressrelease&quot; == cite_class then	-- if this citation is cite press release
		return &quot;Press release&quot;;					-- display press release annotation

	elseif &quot;techreport&quot; == cite_class then		-- if this citation is cite techreport
		return &quot;Technical report&quot;;				-- display techreport annotation
	
	elseif &quot;thesis&quot; == cite_class then			-- if this citation is cite thesis (degree option handled after this function returns)
			return &quot;Thesis&quot;;					-- display simple thesis annotation (without |degree= modification)
	end
end

--[[
Determines whether a URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
	-- Protocol-relative or URL scheme
	return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
	return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]
function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other lua magic pattern characters
	return argument;
end

--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup.
]]
function strip_apostrophe_markup (argument)
	local pattern, cap, cap2;
	if not is_set (argument) then return argument; end
	
	while true do																-- look for and remove all 5-apostrophe (bold and italic) markup
		if argument:match (&quot;%'%'%'%'%'&quot;) then									-- is there an instance of bold-italic?
			if argument:match (&quot;%'%'%'%'%'.*%'%'%'%'%'&quot;) then					-- 5, 5
				pattern, cap = argument:match (&quot;(%'%'%'%'%'(.*)%'%'%'%'%')&quot;);		
				cap2 = &quot;&quot;;														-- set to empty string so we do only one replacement at end
			elseif argument:match (&quot;%'%'%'%'%'.*%'%'%'.*%'%'&quot;) then				-- bold italic followed by italic (5, 3, 2)
				pattern, cap, cap2 = argument:match (&quot;(%'%'%'%'%'(.*)%'%'%'(.*)%'%')&quot;);
			elseif argument:match (&quot;%'%'%'%'%'.*%'%'.*%'%'%'&quot;) then				-- bold italic followed by bold (5, 2, 3)
				pattern, cap, cap2 = argument:match (&quot;(%'%'%'%'%'(.*)%'%'(.*)%'%'%')&quot;);
			elseif argument:match (&quot;%'%'%'.*%'%'.*%'%'%'%'%'&quot;) then				-- bold italic followed by italic (3, 2, 5)
				pattern, cap, cap2 = argument:match (&quot;(%'%'%'(.*)%'%'(.*)%'%'%'%'%')&quot;);
			elseif argument:match (&quot;%'%'.*%'%'%'.*%'%'%'%'%'&quot;) then				-- italic followed by bold (2, 3, 5)
				pattern, cap, cap2 = argument:match (&quot;(%'%'(.*)%'%'%'(.*)%'%'%'%'%')&quot;);
			end
			cap = escape_lua_magic_chars (cap);									-- replace lua magic characters
			cap2 = escape_lua_magic_chars (cap2);								-- replace lua magic characters
			pattern = escape_lua_magic_chars (pattern);							-- replace lua magic characters
			argument=argument:gsub(pattern, cap..cap2);							-- remove the markup
		else
			break;																-- none or no more 5-apostrophe matches
		end
	end
	while true do																-- look for and remove all 3-apostrophe (bold) markup
		if argument:match (&quot;%'%'%'.*%'%'%'&quot;) then								-- is there an instance of bold?
			pattern, cap = argument:match (&quot;(%'%'%'(.*)%'%'%')&quot;)
			cap = escape_lua_magic_chars (cap);									-- replace lua magic characters
			pattern = escape_lua_magic_chars (pattern);							-- replace lua magic characters
			argument=argument:gsub(pattern, cap);								-- remove the markup
		else
			break;																-- none or no more 3 matches
		end
	end
	while true do																-- look for and remove all 2-apostrophe (italic) markup
		if argument:match (&quot;%'%'.*%'%'&quot;) then									-- is there an instance of italic?
			pattern, cap = argument:match (&quot;(%'%'(.*)%'%')&quot;)
			cap = escape_lua_magic_chars (cap);									-- replace lua magic characters
			pattern = escape_lua_magic_chars (pattern);							-- replace lua magic characters
			argument=argument:gsub(pattern, cap);								-- remove the markup
		else
			break;																-- none or no more 2 matches
		end
	end
	return argument;															-- done
end

--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...
]]

function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end

--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]
function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end

--[[
ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in checkisbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.
]]
function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of bytes
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end	-- isbn13 begins with 978 or 979
		isbn_str = { isbn_str:byte(1, len) };
		for i, v in ipairs( isbn_str ) do
			temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
		end
		return temp % 10 == 0;
	end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
	--[[ Note: We cannot use &lt;i&gt; for italics, as the expected behavior for
	italics specified by ''...'' in the title is that they will be inverted
	(i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
	tend to interact poorly under Mediawiki's HTML tidy. ]]
	
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end

--[[
Joins a sequence of strings together while checking for duplicate separation characters.

TODO: safejoin() has a flaw where it won't remove the duplicate character from a |title= / |url= combination.
This is because by the time we get here, |title=http://somesite.com and |title=Document Title. have been combined:
	[http://somesite.com and ''Document Title.'']
so that now, the last character is not sepc but is ] (unless sepc == ']' which breaks the external link)
]]
function safejoin( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';
	local comp = '';
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then
			str = value;
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then
				-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
			else
				comp = value;
			end
			
			if comp:sub(1,1) == duplicate_char then
				trim = false;
				end_chr = str:sub(-1,-1);
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
				if end_chr == duplicate_char then
					str = str:sub(1,-2);
				elseif end_chr == &quot;'&quot; then
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
						str = str:sub(1, -4) .. &quot;''&quot;;
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
						trim = true;
					end
				elseif end_chr == &quot;]&quot; then
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
						trim = true;
					end
				elseif end_chr == &quot; &quot; then
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
						str = str:sub(1,-3);
					end
				end

				if trim then
					if value ~= comp then 
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
					else
						value = value:sub( 2, -1 );
					end
				end
			end
			str = str .. value;
		end
	end
	return str;
end  

-- Attempts to convert names to initials.
function reducetoinitials(first)
	local initials = {}
	local i = 0;										-- counter for number of initials
	for word in string.gmatch(first, &quot;%S+&quot;) do
		table.insert(initials, string.sub(word,1,1))	-- Vancouver format does not include full stops.
		i = i + 1;										-- bump the counter 
		if 2 &lt;= i then break; end						-- only two initials allowed in Vancouver system; if 2, quit
	end
	return table.concat(initials)						-- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
	local sep = control.sep;
	local namesep = control.namesep
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}
	local etal = false;
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if maximum ~= nil and maximum &lt; 1 then return &quot;&quot;, 0; end
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if maximum ~= nil and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
					one = one .. namesep .. first 
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;		-- link author/editor if this page is not the author's/editor's page
				end

				if is_set(person.link) and nil ~= person.link:find(&quot;//&quot;) then one = one .. &quot; &quot; .. seterror( 'bad_authorlink' ) end	-- check for url in author link;
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;
		end
		text[#text] = nil; 
	end
	
	local result = table.concat(text) -- construct list
	if etal then 
		local etal_text = cfg.messages['et al'];
		result = result .. &quot; &quot; .. etal_text;
	end
	
	-- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
	if ( &quot;scap&quot; == format ) then result = 
		'&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
	end 
	return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
	return &quot;CITEREF&quot; .. table.concat( options );
end

--[[
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.
]]
function extractnames(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	
	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary

	while true do
		last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { seterror( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 == count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			names[n] = {last = last, first = first, link = link, mask = mask};	-- add this name to our names list
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { seterror( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	return names;																-- all done, return our list of names
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
	local id_list = {};
	for k, v in pairs( cfg.id_handlers ) do	
		v = selectone( args, v.parameters, 'redundant_parameters' );
		if is_set(v) then id_list[k] = v; end
	end
	return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
	local new_list, handler = {};
	
	function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, externallinkid( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internallinkid( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internallinkid( handler );
			if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
	local value = nil;
	local selected = '';
	local error_list = {};
	
	if index ~= nil then index = tostring(index); end
	
	-- Handle special case of &quot;#&quot; replaced by empty string
	if index == '1' then
		for _, v in ipairs( possible ) do
			v = v:gsub( &quot;#&quot;, &quot;&quot; );
			if is_set(args[v]) then
				if value ~= nil and selected ~= v then
					table.insert( error_list, v );
				else
					value = args[v];
					selected = v;
				end
			end
		end		
	end
	
	for _, v in ipairs( possible ) do
		if index ~= nil then
			v = v:gsub( &quot;#&quot;, index );
		end
		if is_set(args[v]) then
			if value ~= nil and selected ~=  v then
				table.insert( error_list, v );
			else
				value = args[v];
				selected = v;
			end
		end
	end
	
	if #error_list &gt; 0 then
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap( 'parameter', k );
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap( 'parameter', selected );
		table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
function COinS(data)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end
	
	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
			end
		end
	});
	
	if is_set(data.Chapter) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Chapter;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	elseif is_set(data.Periodical) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
		OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	else
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
	end
	
	OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
	OCinSoutput[&quot;rft.date&quot;] = data.Date;
	OCinSoutput[&quot;rft.series&quot;] = data.Series;
	OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
	OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
	OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
	OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
	OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
	
	for k, v in pairs( data.ID_list ) do
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
	
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = v.last, v.first;
		if k == 1 then
			if is_set(last) then
				OCinSoutput[&quot;rft.aulast&quot;] = last;
			end
			if is_set(first) then 
				OCinSoutput[&quot;rft.aufirst&quot;] = first;
			end
		end
		if is_set(last) and is_set(first) then
			OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
		elseif is_set(last) then
			OCinSoutput[&quot;rft.au&quot;] = last;
		end
	end
	
	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 code.  Handles the special case that is Norwegian where
ISO639-1 code 'no' is mapped to language name 'Norwegian Bokmål' by Extention:CLDR.

Returns the language name and associated ISO639-1 code.  Because case of the source may be incorrect or different from the case that Wikimedia
uses, the name comparisons are done in lower case and when a match is found, the Wikimedia version (assumed to be correct) is returned along
with the code.  When there is no match, we return the original language name string.

mw.language.fetchLanguageNames() will return a list of languages that aren't part of ISO639-1. Names that aren't ISO639-1 but that are included
in the list will be found if that name is provided in the |language= parameter.  For example, if |language=Samaritan Aramaic, that name will be
found with the associated code 'sam', not an ISO639-1 code.  When names are found and the associated code is not two characters, this function
returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.
]]

function get_iso639_code (lang)
	if 'Norwegian' == lang then
		return lang, 'no';														-- special case related to Wikimedia remap of code 'no' at Extension:CLDR
	end
	
	local languages = mw.language.fetchLanguageNames('en', 'all')				-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() then												-- ISO639-1 codes only
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the ISO639-1 code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for ISO639-1 code
end

--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Get language name from ISO639-1 code value provided.  If a code is valid use the returned name; if not, then use the value that was provided with the language parameter.

There is an exception.  There are three ISO639-1 codes for Norewegian language variants.  There are two official variants: Norwegian Bokmål (code 'nb') and
Norwegian Nynorsk (code 'nn').  The third, code 'no',  is defined by ISO639-1 as 'Norwegian' though in Norway this is pretty much meaningless.  However, it appears
that on enwiki, editors are for the most part unaware of the nb and nn variants (compare page counts for these variants at Category:Articles with non-English-language external links.

Because Norwegian Bokmål is the most common language variant, Media wiki has been modified to return Norwegian Bokmål for ISO639-1 code 'no'. Here we undo that and
return 'Norwegian' when editors use |language=no.  We presume that editors don't know about the variants or can't descriminate between them.

See Help talk:Citation Style_1#An ISO 639-1 language name test

When |language= contains a valid ISO639-1 code, the page is assigned to the category for that code: Category:Norwegian-language sources (no) if
the page is a mainspace page and the ISO639-1 code is not 'en'.  Similarly, if the  parameter is |language=Norwegian, it will be categorized in the same way.

TODO: Error message when language or language code is not ISO639-1?
]]

function language_parameter (lang, namespace)
	local code;			-- the ISO639-1 two character code
	local name;			-- the language name
	local test='';
		
	if 0 == namespace and (('en' == lang:lower()) or ('english' == lang:lower())) then
		table.insert (z.maintenance_cats, 'CS1 maint: English language specified');		-- add maintenance category if |language=English or |language=en in article space
	end

	if 2 == lang:len() then														-- ISO639-1 language code are 2 characters (fetchLanguageName also supports 3 character codes)
		name = mw.language.fetchLanguageName( lang:lower(), &quot;en&quot; );				-- get ISO 639-1 language name if Language is a proper code
	end

	if is_set (name) then														-- if Language specified a valid ISO639-1 code
		code = lang:lower();													-- save it
	else
		name, code = get_iso639_code (lang);									-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
	end

	if is_set (code) then
		if 'no' == code then name = 'Norwegian' end;							-- override wikimedia when code is 'no'
			if 0 == namespace and 'en' ~= code then					-- is this page main / article space and English not the language?
				table.insert( z.properties_cats, 'CS1 ' .. name .. '-language sources (' .. code .. ')');	-- in main space and not English: categorize
			end
		end
	return (&quot; &quot; .. wrap( 'language', name));									-- wrap with '(in ...)'
end




--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------
This is the main function doing the majority of the citation
formatting.
]]
function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple
	aliases to single internal variable.
	]]
	local A = argument_wrapper( args );

	local i 
	local PPrefix = A['PPrefix']
	local PPPrefix = A['PPPrefix']
	if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
	
	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local Authors = A['Authors'];
	local a = extractnames( args, 'AuthorList' );

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];
	local Editors = A['Editors'];
	local e = extractnames( args, 'EditorList' );

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
	local Chapter = A['Chapter'];
	local ChapterLink = A['ChapterLink'];
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveURL = A['ArchiveURL'];
	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');
	local Periodical = A['Periodical'];

	local Series = A['Series'];
	local Volume = A['Volume'];
	local Issue = A['Issue'];
	local Position = '';
	local Page = A['Page'];
	local Pages = hyphentodash( A['Pages'] );	
	local At = A['At'];

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
	local SubscriptionRequired = A['SubscriptionRequired'];
	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local ArchiveDate = A['ArchiveDate'];
	local Agency = A['Agency'];
	local DeadURL = A['DeadURL']
	local Language = A['Language'];
	local Format = A['Format'];
	local Ref = A['Ref'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
	local Embargo = A['Embargo'];

	local ID_list = extractids( args );
--[[ Hide unfinished cite newsgroup code so that long delayed update can take place
	-- special case for cite newsgroup which uses |id= for a usenet article or post id
	-- |id= is not included in COinS so here we convert it to an ID that will be included in COinS
	if ('newsgroup' == config.CitationClass) and (is_set (ID)) then
		ID_list['USENETID']=ID;			-- add this new 'id' to the list of IDs
		ID = '';						-- and unset
	end
]]	
	local Quote = A['Quote'];
	local PostScript = A['PostScript'];

	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');
	local sepc = A['Separator'];

	local LastAuthorAmp = A['LastAuthorAmp'];
	local no_tracking_cats = A['NoTracking'];

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Cointerviewers = A['Cointerviewers'];			-- deprecated
	local Interviewer = A['Interviewer'];				-- deprecated
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local page_type;									-- is this needed?  Doesn't appear to be used anywhere;
	local use_lowercase = ( sepc ~= '.' );
	local this_page = mw.title.getCurrentTitle();		--Also used for COinS and for language
	local anchor_year;									-- used in the CITEREF identifier
	local COinS_date;									-- used in the COinS metadata

-- Set postscript default.
	if not is_set (PostScript) then						-- if |postscript= has not been set (Postscript is nil which is the default for {{citation}}) and
		if (config.CitationClass ~= &quot;citation&quot;) then	-- this template is not a citation template
			PostScript = '.';							-- must be a cite xxx template so set postscript to default (period)
		end
	else
		if PostScript:lower() == 'none' then			-- if |postscript=none then
			PostScript = '';							-- no postscript
		end
	end

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories.
	if not is_set(no_tracking_cats) then				-- ignore if we are already not going to categorize this page
		if inArray (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;					-- set no_tracking_cats
		end
	end

-- check for extra |page=, |pages= or |at= parameters. 
	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Page = Page .. &quot; &quot; .. seterror('extra_pages');	-- add error message
			Pages = '';										-- unset the others
			At = '';
		end
	elseif is_set(Pages) then
		if is_set(At) then
			Pages = Pages .. &quot; &quot; .. seterror('extra_pages');	-- add error messages
			At = '';											-- unset
		end
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped

All other combinations of |encyclopedia, |title, and |article are not modified
]]
	if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
		if is_set(Periodical) then					-- Periodical is set when |encyclopedia is set
			if is_set(Title) then
				if not is_set(Chapter) then
					Chapter = Title;				-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					TransChapter = TransTitle;
					Title = Periodical;
					Periodical = '';				-- redundant so unset
					TransTitle = '';				-- redundant so unset
				end
			else									-- |title not set
				Title = Periodical;					-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';					-- redundant so unset
			end
		end
	end

--special cases for citation.
	if (config.CitationClass == &quot;citation&quot;) then		-- for citation templates
		if not is_set (Ref) then						-- if |ref= is not set
			Ref = &quot;harv&quot;;								-- set default |ref=harv
		end
		if not is_set (sepc) then						-- if |separator= is not set
			sepc = ',';									-- set citation separator to its default (comma)
		end
	else												-- not a citation template
		if not is_set (sepc) then						-- if |separator= has not been set
			sepc = '.';									-- set cite xxx separator to its default (period)
		end
	end

-- check for special case where |separator=none
	if 'none' == sepc:lower() then						-- if |separator=none
		sepc = '';										-- then set it to an empty string
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then	-- special case for cite techreport
		if is_set(Issue) then						-- cite techreport uses 'number', which other citations aliase to 'issue'
			if not is_set(ID) then					-- can we use ID for the &quot;number&quot;?
				ID = Issue;							-- yes, use it
				Issue = &quot;&quot;;							-- unset Issue so that &quot;number&quot; isn't duplicated in the rendered citation or COinS metadata
			else									-- can't use ID so emit error message
				ID = ID .. &quot; &quot; .. seterror('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Interviewer) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Interviewer;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Interviewer;
			end
			if is_set(Cointerviewers) then
				Others = Others .. sepc .. ' ' .. Cointerviewers;
			end
		else
			Others = '(Interview)';
		end
	end

--Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set
	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_embargoed(Embargo) then
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];	-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];		-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
--TODO: if this is only for {{cite conference}}, shouldn't we be checking? (if config.CitationClass=='conference' then ...)
	if is_set(BookTitle) then
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = BookTitle;
		TitleLink = '';
		TransTitle = '';
	end

-- Account for the oddity that is {{cite episode}}, before generation of COinS data.
--[[	-- {{cite episode}} is not currently supported by this module
	if config.CitationClass == &quot;episode&quot; then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];
		local Season = A['Season'];
		local SeriesNumber = A['SeriesNumber'];
		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
		local Sep = (first_set(A[&quot;SeriesSeparator&quot;], A[&quot;Separator&quot;]) or &quot;&quot;) .. &quot; &quot;;
		
		if is_set(Issue) then table.insert(s, cfg.messages[&quot;episode&quot;] .. &quot; &quot; .. Issue); Issue = ''; end
		if is_set(Season) then table.insert(s, cfg.messages[&quot;season&quot;] .. &quot; &quot; .. Season); end
		if is_set(SeriesNumber) then table.insert(s, cfg.messages[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber); end
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		
		Date = Date or AirDate;
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = Series;
		TitleLink = SeriesLink;
		TransTitle = '';
		
		Series = table.concat(s, Sep);
		ID = table.concat(n, Sep);
	end
-- end of {{cite episode}} stuff]]

-- legacy: promote concatenation of |day=, |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set(Date) then
		Date = Year;						-- promote Year to Date
		Year = nil;							-- make nil so Year as empty string isn't used for CITEREF
		if is_set(Date) then
			local Month = A['Month'];
			if is_set(Month) then
				Date = Month .. &quot; &quot; .. Date;
				local Day = A['Day']
				if is_set(Day) then Date = Day .. &quot; &quot; .. Date end
			end
		elseif is_set(PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;			-- promote PublicationDate to Date
			PublicationDate = '';			-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end	-- if PublicationDate is same as Date, don't display in rendered citation


--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	anchor_year, COinS_date, error_message = dates({['accessdate']=AccessDate, ['airdate']=AirDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
		['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});
	if is_set(error_message) then
		table.insert( z.message_tail, { seterror( 'bad_date', {error_message}, true ) } );	-- add this error message
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for
	-- automated parsing of citation information.
	-- this is the function call to COinS()
	local OCinSoutput = COinS{
		['Periodical'] = Periodical,
		['Chapter'] = strip_apostrophe_markup (Chapter),						-- Chapter stripped of bold / italic wikimarkup
		['Title'] = make_coins_title (Title, ScriptTitle),						-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = first_set(COinS_date, Date),		-- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here?  Should we be including invalid dates in metadata?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set(Page, Pages, At)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set( URL, ChapterURL ),
		['Authors'] = a,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	};
--[[Why is this here?  Why are we mapping Title to Chapter when Periodical is set?
	if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = '';
		TitleLink = '';
		TransTitle = '';
	end
]]
--[[ Hide unfinished cite newsgroup code so that long delayed update can take place
-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername and ID
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = '[Newsgroup]:&amp;nbsp;' ..  externallink( 'news:' .. PublisherName, PublisherName );
		end
	end
]]


	-- Now perform various field 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 not is_set(Authors) then
		local Maximum = tonumber( A['DisplayAuthors'] );
		
		-- Preserve old-style implicit et al.
		if not is_set(Maximum) and #a == 9 then 
			Maximum = 8;
			table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
		elseif not is_set(Maximum) then
			Maximum = #a + 1;
		end
			
		local control = { 
			sep = A[&quot;AuthorSeparator&quot;] .. &quot; &quot;,
			namesep = (first_set(A[&quot;AuthorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
			format = A[&quot;AuthorFormat&quot;],
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text				-- get current page name so that we don't wikilink to it via authorlinkn
		};
		
		-- If the coauthor field is also used, prevent ampersand and et al. formatting.
		if is_set(Coauthors) then
			control.lastauthoramp = nil;
			control.maximum = #a + 1;
		end
		
		Authors = listpeople(control, a) 
	end

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { seterror('coauthors_missing_author', {}, true) } );	-- emit error message
	end

	local EditorCount
	if not is_set(Editors) then
		local Maximum = tonumber( A['DisplayEditors'] );
		-- Preserve old-style implicit et al.
		if not is_set(Maximum) and #e == 4 then 
			Maximum = 3;
			table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
		elseif not is_set(Maximum) then
			Maximum = #e + 1;
		end

		local control = { 
			sep = A[&quot;EditorSeparator&quot;] .. &quot; &quot;,
			namesep = (first_set(A[&quot;EditorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
			format = A['EditorFormat'],
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text				-- get current page name so that we don't wikilink to it via authorlinkn
		};

		Editors, EditorCount = listpeople(control, e);
	else
		EditorCount = 1;
	end

	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	if config.CitationClass == &quot;map&quot; then
		if not is_set( Authors ) and is_set( PublisherName ) then
			Authors = PublisherName;
			PublisherName = &quot;&quot;;
		end
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap( 'cartography', Cartography, use_lowercase );
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end		
	end
	
	if  not is_set(URL) and
		not is_set(ChapterURL) and
		not is_set(ArchiveURL) and
		not is_set(ConferenceURL) and
		not is_set(TranscriptURL) then
		
		-- Test if cite web or cite podcast |url= is missing or empty 
		if inArray(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;}) then	
			table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
		end
		
		-- Test if accessdate is given without giving a URL
		if is_set(AccessDate) then
			table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
		
		-- Test if format is given without giving a URL
		if is_set(Format) then
			Format = Format .. seterror( 'format_missing_url' );
		end
	end
	
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(Periodical) and
		not is_set(Conference) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
		table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
	end
	
	Format = is_set(Format) and &quot; (&quot; .. Format .. &quot;)&quot; or &quot;&quot;;
	
	local OriginalURL = URL
	DeadURL = DeadURL:lower();
	if is_set( ArchiveURL ) then
		if ( DeadURL ~= &quot;no&quot; ) then
			URL = ArchiveURL
			URLorigin = A:ORIGIN('ArchiveURL')
		end
	end
	
	-- Format chapter / article title
	if is_set(Chapter) and is_set(ChapterLink) then 
		Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot;;
	end

	Chapter = kern_quotes (Chapter);				-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
	Chapter = wrap( 'quoted-title', Chapter );
	TransChapter = wrap( 'trans-quoted-title', TransChapter );

	local TransError = &quot;&quot;
	if is_set(TransChapter) then
		if not is_set(Chapter) then
			TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );		-- add error message
		else
			TransChapter = &quot; &quot; .. TransChapter;
		end
	end
	
	Chapter = Chapter .. TransChapter;
	
	if is_set(Chapter) then
		if not is_set(ChapterLink) then
			if is_set(ChapterURL) then
				Chapter = externallink( ChapterURL, Chapter ) .. TransError;
				if not is_set(URL) then
					Chapter = Chapter .. Format;
					Format = &quot;&quot;;
				end
			elseif is_set(URL) then 
				Chapter = externallink( URL, Chapter ) .. TransError .. Format;
				URL = &quot;&quot;;
				Format = &quot;&quot;;
			else
				Chapter = Chapter .. TransError;
			end			
		elseif is_set(ChapterURL) then
			Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. 
				TransError;
		else
			Chapter = Chapter .. TransError;
		end
		Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
	elseif is_set(ChapterURL) then
		Chapter = &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. sepc .. &quot; &quot;;
	end		
	
	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;journal&quot;,&quot;pressrelease&quot;,&quot;conference&quot;,&quot;podcast&quot;}) then
		Title = kern_quotes (Title);											-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
		Title = wrap( 'quoted-title', Title );
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap( 'trans-quoted-title', TransTitle );
--		Chapter = '';								-- chapter not allowed - disabled because doing this here doesn't display error msg and promoted url is lost
	else
		Title = wrap( 'italic-title', Title );
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap( 'trans-italic-title', TransTitle );
	end

	TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then 
			Title = externallink( URL, Title ) .. TransError .. Format	   
			URL = &quot;&quot;;
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap( 'written', Place, use_lowercase ) .. sepc .. &quot; &quot;;
	end
	
	if is_set(Conference) then
		if is_set(ConferenceURL) then
			Conference = externallink( ConferenceURL, Conference );
		end
		Conference = sepc .. &quot; &quot; .. Conference
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. externallink( ConferenceURL, nil, ConferenceURLorigin );
	end
	
	if not is_set(Position) then
		local Minutes = A['Minutes'];
		if is_set(Minutes) then
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			local Time = A['Time'];
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end
	
	if not is_set(Page) then
		if is_set(Pages) then
			if is_set(Periodical) and
				not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
				Pages = &quot;: &quot; .. Pages;
			elseif tonumber(Pages) ~= nil then
				Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
			else
				Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
			end
		end
	else
		if is_set(Periodical) and
			not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
			Page = &quot;: &quot; .. Page;
		else
			Page = sepc ..&quot; &quot; .. PPrefix .. Page;
		end
	end
	
	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Inset = A['Inset'];
		if first_set( Pages, Page, At ) ~= nil or sepc ~= '.' then
			if is_set( Section ) then
				Section = &quot;, &quot; .. wrap( 'section', Section, true );
			end
			if is_set( Inset ) then
				Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
			end
		else
			if is_set( Section ) then
				Section = sepc .. &quot; &quot; .. wrap( 'section', Section, use_lowercase );
				if is_set( Inset ) then
					Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
				end
			elseif is_set( Inset ) then
				Inset = sepc .. &quot; &quot; .. wrap( 'inset', Inset, use_lowercase );
			end			
		end			
		At = At .. Section .. Inset;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language, this_page.namespace);			-- format, categories (article namespace only), name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;

-- handle type parameter for those CS1 citations that have default values

	if inArray(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then	-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then					-- if type parameter is specified
		TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot;;	-- display it in parentheses
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	Edition = is_set(Edition) and (&quot; &quot; .. wrap( 'edition', Edition )) or &quot;&quot;;
	Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc ..&quot; &quot; .. Volume;
		  else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
		end
	end

--[[ This code commented out while discussion continues until after week of 2014-03-23 live module update;
	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc .. &quot; &quot; .. Volume;
		  else
			  Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
			  if is_set(Series) then Volume = sepc .. Volume;
			  end
		end
	end
]]	
	------------------------------------ totally unrelated data
	--[[ Loosely mimic {{subscription required}} template; Via parameter identifies a delivery source that is not the publisher; these sources often, but not always, exist
	behind a registration or paywall.  So here, we've chosen to decouple via from subscription (via has never been part of the registration required template).
	
	Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link note is displayed. There are no error messages for this condition.
	]]
	if is_set(Via) then
		Via = &quot; &quot; .. wrap( 'via', Via );
	end

	if is_set(SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription']; --here when 'via' parameter not used but 'subscription' is
	elseif is_set(RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration']; --here when 'via' and 'subscription' parameters not used but 'registration' is
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
		AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
			.. substitute( retrv_text, {AccessDate} ) .. '&lt;/span&gt;'
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end

	
	ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo} );

	if is_set(URL) then
		URL = &quot; &quot; .. externallink( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
			Quote = Quote:sub(2,-2);
		end
		Quote = sepc ..&quot; &quot; .. wrap( 'quoted-text', Quote ); 
		PostScript = &quot;&quot;;							-- CS1 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = seterror('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ externallink( ArchiveURL, arch_text ), ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text,
				{ externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ seterror('archive_missing_url'), ArchiveDate } );
		end
	else
		Archived = &quot;&quot;
	end
	
	local Lay
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
		end			
	else
		Lay = &quot;&quot;;
	end
	
	if is_set(Transcript) then
		if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
	elseif is_set(TranscriptURL) then
		Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
	end
	
	local Publisher;
	if is_set(Periodical) and
		not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap( 'published', PublicationDate );
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap( 'published', PublicationDate ) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap( 'italic-title', Periodical ) 
		else 
			Periodical = wrap( 'italic-title', Periodical )
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon
	if inArray(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, 
			Language, Cartography, Edition, Publisher, Agency, Volume, Issue}, sepc );
	else 
		tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, Language, 
			Volume, Issue, Others, Cartography, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Page .. Pages .. At;
	
	if is_set(Authors) then
		if is_set(Coauthors) then
			Authors = Authors .. A['AuthorSeparator'] .. &quot; &quot; .. Coauthors
		end
		if is_set(Date) then
			Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		elseif string.sub(Authors,-1,-1) == sepc then
			Authors = Authors .. &quot; &quot;
		else
			Authors = Authors .. sepc .. &quot; &quot;
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			if (sepc ~= '.') then in_text = in_text:lower() end
			Editors = in_text .. Editors .. post_text;
			if (string.sub(Editors,-1,-1) == sepc)
				then Editors = Editors .. &quot; &quot;
				else Editors = Editors .. sepc .. &quot; &quot;
			end
		end
		text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
		text = safejoin( {text, pgtext, idcommon}, sepc );
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
		text = safejoin( {text, pgtext, idcommon}, sepc );
	else
		if is_set(Date) then
			if ( string.sub(tcommon,-1,-1) ~= sepc )
			  then Date = sepc ..&quot; &quot; .. Date .. OrigYear
			  else Date = &quot; &quot; .. Date .. OrigYear
			end
		end
		if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
			text = safejoin( {Chapter, Place, tcommon}, sepc );
			text = safejoin( {text, pgtext, Date, idcommon}, sepc );
		else
			text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
			text = safejoin( {text, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
--		text = text:sub(1,-2);	--Remove final separator (assumes that sepc is only one character)
	end	
	
	text = safejoin( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;span/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = &quot;citation &quot; .. config.CitationClass;
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
		local id = Ref
		if ( &quot;harv&quot; == Ref ) then
			local names = {} --table of last names &amp; year
			if #a &gt; 0 then
				for i,v in ipairs(a) do 
					names[i] = v.last 
					if i == 4 then break end
				end
			elseif #e &gt; 0 then
				for i,v in ipairs(e) do 
					names[i] = v.last 
					if i == 4 then break end				
				end
			end
			names[ #names + 1 ] = first_set(Year, anchor_year);	-- Year first for legacy citations
			id = anchorid(names)
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = seterror('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then 
		text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	else
		text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	end		

	local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
	
	-- Note: Using display: none on then COinS span breaks some clients.
	local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
	text = text .. OCinS;
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. errorcomment( v[1], v[2] );
				else
					text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if inArray(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
	local pframe = frame:getParent()
	
	if nil ~= string.find( frame:getTitle(), 'sandbox', 1, true ) then				-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData( 'Module:Citation/CS1/Configuration/sandbox' );	-- load sandbox versions of Configuration and Whitelist and ...
		whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist/sandbox' );
		dates = require('Module:Citation/CS1/Date_validation/sandbox').dates	-- ... sandbox version of date validation code
	else																	-- otherwise
		cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );			-- load live versions of Configuration and Whitelist and ...
		whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );
		dates = require('Module:Citation/CS1/Date_validation').dates		-- ... live version of date validation code
	end
	
	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = seterror( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if #suggestions == 0 then
						suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
					end
					if suggestions[ k:lower() ] ~= nil then
						error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
					else
						error_text, error_state = seterror( 'parameter_ignored', {k}, true );
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	
	
	return citation0( config, args)
end

return z</text>
      <sha1>aqa1szgccy7p5s7kj3l0hynr45jqgu7</sha1>
    </revision>
    <revision>
      <id>4684</id>
      <parentid>4683</parentid>
      <timestamp>2014-10-16T03:09:57Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Bug fix in strip_apostrophe_markup();</comment>
      <origin>4684</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="97687" sha1="qkhefok0px666o12qjq0wuw59swiu5w" xml:space="preserve">
local z = {
	error_categories = {};		-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};		-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};		-- for categorizing citations based on certain properties, language of source for instance
}

-- Whether variable is set or not
function is_set( var )
	return not (var == nil or var == '');
end

-- First set variable or nil if none
function first_set(...)
	local list = {...};
	for _, var in pairs(list) do
		if is_set( var ) then
			return var;
		end
	end
end

-- Whether needle is in haystack
function inArray( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end

--[[
Categorize and emit an error message when the citation contains one or more deprecated parameters.  Because deprecated parameters (currently |day=, |month=,
|coauthor=, and |coauthors=) aren't related to each other and because these parameters may be concatenated into the variables used by |date= and |author#= (and aliases)
details of which parameter caused the error message are not provided.  Only one error message is emitted regardless of the number of deprecated parameters in the citation.
]]
function deprecated_parameter()
	if true ~= Page_in_deprecated_cat then	-- if we haven't been here before then set a 
		Page_in_deprecated_cat=true;		-- sticky flag so that if there are more than one deprecated parameter the category is added only once
		table.insert( z.message_tail, { seterror( 'deprecated_params', {}, true ) } );		-- add error message
	end
end

-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
--	return args and tostring( mw.message.newRawMessage( msg, args ) ) or msg;
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[
Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern  either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
]]
function kern_quotes (str)
	local left='&lt;span style=&quot;padding-left:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains leading single or double quote mark
	local right='&lt;span style=&quot;padding-right:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains trailing single or double quote mark
	
	if  str:match (&quot;^[\&quot;\'][^\']&quot;) then
		str = string.gsub( str, &quot;^[\&quot;\']&quot;, left, 1 );				-- replace (captured) leading single or double quote with left-side &lt;span&gt;
	end
	if str:match (&quot;[^\'][\&quot;\']$&quot;) then
		str = string.gsub( str, &quot;[\&quot;\']$&quot;, right, 1 );			-- replace (captured) trailing single or double quote with right-side &lt;span&gt;
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

At this writing, only |script-title= is supported.  It is anticipated that additional parameters will be created to use this function.

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
			if inArray (lang, {'ar', 'ja', 'ko', 'he', 'zh'}) then				-- is prefix one of these language codes?
				table.insert( z.properties_cats, 'CS1 uses ' .. name .. '-language script ('..lang..')');	-- categorize in language-specific categories
			else
				table.insert( z.properties_cats, 'CS1 uses foreign language script');	-- use this category as a catchall until language-specific category is available
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = '&lt;bdi' .. lang .. '&gt;' .. script_value .. '&lt;/bdi&gt;';			-- isolate incase script is rlt

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end

-- Wraps a string using a message_list configuration taking one argument
function wrap( key, str, lower )
	if not is_set( str ) then
		return &quot;&quot;;
	elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safeforitalics( str );
	end
	if lower == true then
		return substitute( cfg.messages[key]:lower(), {str} );
	else
		return substitute( cfg.messages[key], {str} );
	end		
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = selectone( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
]]
function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
	return wrap( hidden and 'hidden-error' or 'visible-error', content );
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return errorcomment( message, error_state.hidden );
end

-- Formats a wiki style external link
function externallinkid(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

-- Formats a wiki style internal link
function internallinkid(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

-- Format an external link with error checking
function externallink( URL, label, source )
	local error_str = &quot;&quot;;
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = seterror( 'bare_url_missing_title', { wrap( 'parameter', source ) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not checkurl( URL ) then
		error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
	end
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safeforurl( label ), &quot;]&quot;, error_str });
end

-- Formats a link to Amazon
function amazon(id, domain)
	if checkisbn( id ) then														-- see if asin value is a 10-digit isbn
		table.insert( z.maintenance_cats, &quot;CS1 maint: ASIN uses ISBN&quot;);			-- add to maint category so a bot or awb script can replace |asin= with |isbn=
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif inArray (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif inArray (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return externallinkid({link = handler.link,
		label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
		encode=handler.encode, separator = handler.separator})
end

--[[
format and error check arXiv identifier.  There are two valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces
]]

function arxiv (id)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = &quot;&quot;
	
	year, month, version = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d([v%d]*)$&quot;);				-- test for the 9108-0703 format
	if not year then		-- arXiv id is not proper 9108-0703 form
		year, month, version = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d([v%d]*)$&quot;);	-- test for the 0704- format
		if not year then	
			err_cat = ' ' .. seterror( 'bad_arxiv' );							-- arXiv id doesn't match either format
		else	-- id is the 0704- format
			year = tonumber(year);
			month = tonumber(month);
			if ((7 &gt; year) or (1 &gt; month and 12 &lt; month)) or					-- is year invalid or is month invalid? (doesn't test for future years)
				((7 == year) and (4 &gt; month)) or								-- when year is 07, is month invalid (before April)?
				is_set (version) and nil == version:match(&quot;v%d+&quot;) then			-- is version proper format of single 'v' followed by digits?
					err_cat = ' ' .. seterror( 'bad_arxiv' );					-- set error message
			end
		end
	else	-- id is the 9108-0703 format; are the date values ok
		year = tonumber(year);
		month = tonumber(month);
		if ((91 &gt; year and 7 &lt; year) or (1 &gt; month and 12 &lt; month)) or			-- if invalid year or invalid month
			((91 == year and 8 &gt; month) or (7 == year and 3 &lt; month)) or 		-- if years ok, are starting and ending months ok?
				is_set (version) and nil == version:match(&quot;v%d+&quot;) then			-- is version proper format of single 'v' followed by digits?
					err_cat = ' ' .. seterror( 'bad_arxiv' );					-- set error message
		end
	end

	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--[[
Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of the LCCN dictates the character type of the first 1-3 characters; the
rightmost eight are always digits. http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]
function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. seterror( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. seterror( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]
function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmid' );	-- set an error message
		end
	end
	
	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns true; otherwise, returns false because the embargo has expired or |embargo= not set in this cite.
]]
function is_embargoed(embargo)
	if is_set(embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 and tonumber( embargo_date ) &gt;= tonumber( todays_date ) then	--is embargo date is in the future?
			return true;	-- still embargoed
		end
	end
	return false;			-- embargo expired or |embargo= not set
end

--[[
Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future
the PMC identifier will not be linked to the article.  If the embargo specifies a date in the past, or if it is empty or omitted, then
the PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.
]]
function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_embargoed(embargo) then
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	--still embargoed so no external link
	else
		text = externallinkid({link = handler.link, label = handler.label,			--no embargo date, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.

-- DOI names contain two parts: prefix and suffix separated by a forward slash.
--  Prefix: directory indicator '10.' followed by a registrant code
--  Suffix: character string of any length chosen by the registrant

-- This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes,
-- or, if it ends with a period or a comma, this function will emit a bad_doi error message.

-- DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
-- and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely if ever used in doi names.

function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. seterror( 'bad_doi' );
	end
	return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);					-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	else
		return externallinkid({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode}) .. 
			' ' .. seterror( 'bad_ol' );
	end
end

--[[
Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.
]]
function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = externallinkid({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. seterror( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[
This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those citations that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).
]]
function set_titletype(cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;					-- if |type=none then type parameter not displayed
		end
		return title_type;						-- if |type= has been set to any other value use that value
	end

	if &quot;AV-media-notes&quot; == cite_class or &quot;DVD-notes&quot; == cite_class then		-- if this citation is cite AV media notes or cite DVD notes
		return &quot;Media notes&quot;;					-- display AV media notes / DVD media notes annotation

	elseif &quot;podcast&quot; == cite_class then			-- if this citation is cite podcast
		return &quot;Podcast&quot;;						-- display podcast annotation

	elseif &quot;pressrelease&quot; == cite_class then	-- if this citation is cite press release
		return &quot;Press release&quot;;					-- display press release annotation

	elseif &quot;techreport&quot; == cite_class then		-- if this citation is cite techreport
		return &quot;Technical report&quot;;				-- display techreport annotation
	
	elseif &quot;thesis&quot; == cite_class then			-- if this citation is cite thesis (degree option handled after this function returns)
			return &quot;Thesis&quot;;					-- display simple thesis annotation (without |degree= modification)
	end
end

--[[
Determines whether a URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
	-- Protocol-relative or URL scheme
	return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
	return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]
function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other lua magic pattern characters
	return argument;
end

--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup.
]]
function strip_apostrophe_markup (argument)
	local pattern='';
	local cap='';
	local cap2='';
	if not is_set (argument) then return argument; end
	
	while true do																-- look for and remove all 5-apostrophe (bold and italic) markup
		if argument:match (&quot;%'%'%'%'%'&quot;) then									-- is there an instance of bold-italic?
			if argument:match (&quot;%'%'%'%'%'.*%'%'%'%'%'&quot;) then					-- 5, 5
				pattern, cap = argument:match (&quot;(%'%'%'%'%'(.*)%'%'%'%'%')&quot;);		
				cap2 = &quot;&quot;;														-- set to empty string so we do only one replacement at end
			elseif argument:match (&quot;%'%'%'%'%'.*%'%'%'.*%'%'&quot;) then				-- bold italic followed by italic (5, 3, 2)
				pattern, cap, cap2 = argument:match (&quot;(%'%'%'%'%'(.*)%'%'%'(.*)%'%')&quot;);
			elseif argument:match (&quot;%'%'%'%'%'.*%'%'.*%'%'%'&quot;) then				-- bold italic followed by bold (5, 2, 3)
				pattern, cap, cap2 = argument:match (&quot;(%'%'%'%'%'(.*)%'%'(.*)%'%'%')&quot;);
			elseif argument:match (&quot;%'%'%'.*%'%'.*%'%'%'%'%'&quot;) then				-- bold italic followed by italic (3, 2, 5)
				pattern, cap, cap2 = argument:match (&quot;(%'%'%'(.*)%'%'(.*)%'%'%'%'%')&quot;);
			elseif argument:match (&quot;%'%'%'.*%'%'%'%'%'.*%'%'&quot;) then				-- bold italic followed by italic (3, 5, 2)
				pattern, cap, cap2 = argument:match (&quot;(%'%'%'(.*)%'%'%'%'%'(.*)%'%')&quot;);
			elseif argument:match (&quot;%'%'.*%'%'%'%'%'.*%'%'%'&quot;) then				-- bold italic followed by italic (2, 5, 3)
				pattern, cap, cap2 = argument:match (&quot;(%'%'(.*)%'%'%'%'%'(.*)%'%'%')&quot;);
			elseif argument:match (&quot;%'%'.*%'%'%'.*%'%'%'%'%'&quot;) then				-- italic followed by bold (2, 3, 5)
				pattern, cap, cap2 = argument:match (&quot;(%'%'(.*)%'%'%'(.*)%'%'%'%'%')&quot;);
			end
			cap = escape_lua_magic_chars (cap);									-- replace lua magic characters
			cap2 = escape_lua_magic_chars (cap2);								-- replace lua magic characters
			pattern = escape_lua_magic_chars (pattern);							-- replace lua magic characters
			argument=argument:gsub(pattern, cap..cap2);							-- remove the markup
		else
			break;																-- none or no more 5-apostrophe matches
		end
	end
	while true do																-- look for and remove all 3-apostrophe (bold) markup
		if argument:match (&quot;%'%'%'.*%'%'%'&quot;) then								-- is there an instance of bold?
			pattern, cap = argument:match (&quot;(%'%'%'(.*)%'%'%')&quot;)
			cap = escape_lua_magic_chars (cap);									-- replace lua magic characters
			pattern = escape_lua_magic_chars (pattern);							-- replace lua magic characters
			argument=argument:gsub(pattern, cap);								-- remove the markup
		else
			break;																-- none or no more 3 matches
		end
	end
	while true do																-- look for and remove all 2-apostrophe (italic) markup
		if argument:match (&quot;%'%'.*%'%'&quot;) then									-- is there an instance of italic?
			pattern, cap = argument:match (&quot;(%'%'(.*)%'%')&quot;)
			cap = escape_lua_magic_chars (cap);									-- replace lua magic characters
			pattern = escape_lua_magic_chars (pattern);							-- replace lua magic characters
			argument=argument:gsub(pattern, cap);								-- remove the markup
		else
			break;																-- none or no more 2 matches
		end
	end
	return argument;															-- done
end

--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...
]]

function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end

--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]
function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end

--[[
ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in checkisbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.
]]
function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of bytes
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end	-- isbn13 begins with 978 or 979
		isbn_str = { isbn_str:byte(1, len) };
		for i, v in ipairs( isbn_str ) do
			temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
		end
		return temp % 10 == 0;
	end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
	--[[ Note: We cannot use &lt;i&gt; for italics, as the expected behavior for
	italics specified by ''...'' in the title is that they will be inverted
	(i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
	tend to interact poorly under Mediawiki's HTML tidy. ]]
	
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end

--[[
Joins a sequence of strings together while checking for duplicate separation characters.

TODO: safejoin() has a flaw where it won't remove the duplicate character from a |title= / |url= combination.
This is because by the time we get here, |title=http://somesite.com and |title=Document Title. have been combined:
	[http://somesite.com and ''Document Title.'']
so that now, the last character is not sepc but is ] (unless sepc == ']' which breaks the external link)
]]
function safejoin( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';
	local comp = '';
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then
			str = value;
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then
				-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
			else
				comp = value;
			end
			
			if comp:sub(1,1) == duplicate_char then
				trim = false;
				end_chr = str:sub(-1,-1);
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
				if end_chr == duplicate_char then
					str = str:sub(1,-2);
				elseif end_chr == &quot;'&quot; then
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
						str = str:sub(1, -4) .. &quot;''&quot;;
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
						trim = true;
					end
				elseif end_chr == &quot;]&quot; then
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
						trim = true;
					end
				elseif end_chr == &quot; &quot; then
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
						str = str:sub(1,-3);
					end
				end

				if trim then
					if value ~= comp then 
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
					else
						value = value:sub( 2, -1 );
					end
				end
			end
			str = str .. value;
		end
	end
	return str;
end  

-- Attempts to convert names to initials.
function reducetoinitials(first)
	local initials = {}
	local i = 0;										-- counter for number of initials
	for word in string.gmatch(first, &quot;%S+&quot;) do
		table.insert(initials, string.sub(word,1,1))	-- Vancouver format does not include full stops.
		i = i + 1;										-- bump the counter 
		if 2 &lt;= i then break; end						-- only two initials allowed in Vancouver system; if 2, quit
	end
	return table.concat(initials)						-- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
	local sep = control.sep;
	local namesep = control.namesep
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}
	local etal = false;
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if maximum ~= nil and maximum &lt; 1 then return &quot;&quot;, 0; end
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if maximum ~= nil and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
					one = one .. namesep .. first 
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;		-- link author/editor if this page is not the author's/editor's page
				end

				if is_set(person.link) and nil ~= person.link:find(&quot;//&quot;) then one = one .. &quot; &quot; .. seterror( 'bad_authorlink' ) end	-- check for url in author link;
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;
		end
		text[#text] = nil; 
	end
	
	local result = table.concat(text) -- construct list
	if etal then 
		local etal_text = cfg.messages['et al'];
		result = result .. &quot; &quot; .. etal_text;
	end
	
	-- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
	if ( &quot;scap&quot; == format ) then result = 
		'&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
	end 
	return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
	return &quot;CITEREF&quot; .. table.concat( options );
end

--[[
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.
]]
function extractnames(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	
	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary

	while true do
		last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { seterror( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 == count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			names[n] = {last = last, first = first, link = link, mask = mask};	-- add this name to our names list
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { seterror( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	return names;																-- all done, return our list of names
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
	local id_list = {};
	for k, v in pairs( cfg.id_handlers ) do	
		v = selectone( args, v.parameters, 'redundant_parameters' );
		if is_set(v) then id_list[k] = v; end
	end
	return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
	local new_list, handler = {};
	
	function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, externallinkid( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internallinkid( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internallinkid( handler );
			if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
	local value = nil;
	local selected = '';
	local error_list = {};
	
	if index ~= nil then index = tostring(index); end
	
	-- Handle special case of &quot;#&quot; replaced by empty string
	if index == '1' then
		for _, v in ipairs( possible ) do
			v = v:gsub( &quot;#&quot;, &quot;&quot; );
			if is_set(args[v]) then
				if value ~= nil and selected ~= v then
					table.insert( error_list, v );
				else
					value = args[v];
					selected = v;
				end
			end
		end		
	end
	
	for _, v in ipairs( possible ) do
		if index ~= nil then
			v = v:gsub( &quot;#&quot;, index );
		end
		if is_set(args[v]) then
			if value ~= nil and selected ~=  v then
				table.insert( error_list, v );
			else
				value = args[v];
				selected = v;
			end
		end
	end
	
	if #error_list &gt; 0 then
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap( 'parameter', k );
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap( 'parameter', selected );
		table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
function COinS(data)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end
	
	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
			end
		end
	});
	
	if is_set(data.Chapter) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Chapter;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	elseif is_set(data.Periodical) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
		OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	else
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
	end
	
	OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
	OCinSoutput[&quot;rft.date&quot;] = data.Date;
	OCinSoutput[&quot;rft.series&quot;] = data.Series;
	OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
	OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
	OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
	OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
	OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
	
	for k, v in pairs( data.ID_list ) do
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
	
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = v.last, v.first;
		if k == 1 then
			if is_set(last) then
				OCinSoutput[&quot;rft.aulast&quot;] = last;
			end
			if is_set(first) then 
				OCinSoutput[&quot;rft.aufirst&quot;] = first;
			end
		end
		if is_set(last) and is_set(first) then
			OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
		elseif is_set(last) then
			OCinSoutput[&quot;rft.au&quot;] = last;
		end
	end
	
	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 code.  Handles the special case that is Norwegian where
ISO639-1 code 'no' is mapped to language name 'Norwegian Bokmål' by Extention:CLDR.

Returns the language name and associated ISO639-1 code.  Because case of the source may be incorrect or different from the case that Wikimedia
uses, the name comparisons are done in lower case and when a match is found, the Wikimedia version (assumed to be correct) is returned along
with the code.  When there is no match, we return the original language name string.

mw.language.fetchLanguageNames() will return a list of languages that aren't part of ISO639-1. Names that aren't ISO639-1 but that are included
in the list will be found if that name is provided in the |language= parameter.  For example, if |language=Samaritan Aramaic, that name will be
found with the associated code 'sam', not an ISO639-1 code.  When names are found and the associated code is not two characters, this function
returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.
]]

function get_iso639_code (lang)
	if 'Norwegian' == lang then
		return lang, 'no';														-- special case related to Wikimedia remap of code 'no' at Extension:CLDR
	end
	
	local languages = mw.language.fetchLanguageNames('en', 'all')				-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() then												-- ISO639-1 codes only
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the ISO639-1 code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for ISO639-1 code
end

--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Get language name from ISO639-1 code value provided.  If a code is valid use the returned name; if not, then use the value that was provided with the language parameter.

There is an exception.  There are three ISO639-1 codes for Norewegian language variants.  There are two official variants: Norwegian Bokmål (code 'nb') and
Norwegian Nynorsk (code 'nn').  The third, code 'no',  is defined by ISO639-1 as 'Norwegian' though in Norway this is pretty much meaningless.  However, it appears
that on enwiki, editors are for the most part unaware of the nb and nn variants (compare page counts for these variants at Category:Articles with non-English-language external links.

Because Norwegian Bokmål is the most common language variant, Media wiki has been modified to return Norwegian Bokmål for ISO639-1 code 'no'. Here we undo that and
return 'Norwegian' when editors use |language=no.  We presume that editors don't know about the variants or can't descriminate between them.

See Help talk:Citation Style_1#An ISO 639-1 language name test

When |language= contains a valid ISO639-1 code, the page is assigned to the category for that code: Category:Norwegian-language sources (no) if
the page is a mainspace page and the ISO639-1 code is not 'en'.  Similarly, if the  parameter is |language=Norwegian, it will be categorized in the same way.

TODO: Error message when language or language code is not ISO639-1?
]]

function language_parameter (lang, namespace)
	local code;			-- the ISO639-1 two character code
	local name;			-- the language name
	local test='';
		
	if 0 == namespace and (('en' == lang:lower()) or ('english' == lang:lower())) then
		table.insert (z.maintenance_cats, 'CS1 maint: English language specified');		-- add maintenance category if |language=English or |language=en in article space
	end

	if 2 == lang:len() then														-- ISO639-1 language code are 2 characters (fetchLanguageName also supports 3 character codes)
		name = mw.language.fetchLanguageName( lang:lower(), &quot;en&quot; );				-- get ISO 639-1 language name if Language is a proper code
	end

	if is_set (name) then														-- if Language specified a valid ISO639-1 code
		code = lang:lower();													-- save it
	else
		name, code = get_iso639_code (lang);									-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
	end

	if is_set (code) then
		if 'no' == code then name = 'Norwegian' end;							-- override wikimedia when code is 'no'
			if 0 == namespace and 'en' ~= code then					-- is this page main / article space and English not the language?
				table.insert( z.properties_cats, 'CS1 ' .. name .. '-language sources (' .. code .. ')');	-- in main space and not English: categorize
			end
		end
	return (&quot; &quot; .. wrap( 'language', name));									-- wrap with '(in ...)'
end




--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------
This is the main function doing the majority of the citation
formatting.
]]
function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple
	aliases to single internal variable.
	]]
	local A = argument_wrapper( args );

	local i 
	local PPrefix = A['PPrefix']
	local PPPrefix = A['PPPrefix']
	if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
	
	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local Authors = A['Authors'];
	local a = extractnames( args, 'AuthorList' );

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];
	local Editors = A['Editors'];
	local e = extractnames( args, 'EditorList' );

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
	local Chapter = A['Chapter'];
	local ChapterLink = A['ChapterLink'];
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveURL = A['ArchiveURL'];
	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];

	local Series = A['Series'];
	local Volume = A['Volume'];
	local Issue = A['Issue'];
	local Position = '';
	local Page = A['Page'];
	local Pages = hyphentodash( A['Pages'] );	
	local At = A['At'];

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
	local SubscriptionRequired = A['SubscriptionRequired'];
	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local ArchiveDate = A['ArchiveDate'];
	local Agency = A['Agency'];
	local DeadURL = A['DeadURL']
	local Language = A['Language'];
	local Format = A['Format'];
	local Ref = A['Ref'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
	local Embargo = A['Embargo'];

	local ID_list = extractids( args );
--[[ Hide unfinished cite newsgroup code so that long delayed update can take place
	-- special case for cite newsgroup which uses |id= for a usenet article or post id
	-- |id= is not included in COinS so here we convert it to an ID that will be included in COinS
	if ('newsgroup' == config.CitationClass) and (is_set (ID)) then
		ID_list['USENETID']=ID;			-- add this new 'id' to the list of IDs
		ID = '';						-- and unset
	end
]]	
	local Quote = A['Quote'];
	local PostScript = A['PostScript'];

	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL
	local sepc = A['Separator'];

	local LastAuthorAmp = A['LastAuthorAmp'];
	local no_tracking_cats = A['NoTracking'];

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Cointerviewers = A['Cointerviewers'];			-- deprecated
	local Interviewer = A['Interviewer'];				-- deprecated
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local page_type;									-- is this needed?  Doesn't appear to be used anywhere;
	local use_lowercase = ( sepc ~= '.' );
	local this_page = mw.title.getCurrentTitle();		--Also used for COinS and for language
	local anchor_year;									-- used in the CITEREF identifier
	local COinS_date;									-- used in the COinS metadata

-- Set postscript default.
	if not is_set (PostScript) then						-- if |postscript= has not been set (Postscript is nil which is the default for {{citation}}) and
		if (config.CitationClass ~= &quot;citation&quot;) then	-- this template is not a citation template
			PostScript = '.';							-- must be a cite xxx template so set postscript to default (period)
		end
	else
		if PostScript:lower() == 'none' then			-- if |postscript=none then
			PostScript = '';							-- no postscript
		end
	end

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories.
	if not is_set(no_tracking_cats) then				-- ignore if we are already not going to categorize this page
		if inArray (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;					-- set no_tracking_cats
		end
	end

-- check for extra |page=, |pages= or |at= parameters. 
	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Page = Page .. &quot; &quot; .. seterror('extra_pages');	-- add error message
			Pages = '';										-- unset the others
			At = '';
		end
	elseif is_set(Pages) then
		if is_set(At) then
			Pages = Pages .. &quot; &quot; .. seterror('extra_pages');	-- add error messages
			At = '';											-- unset
		end
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped

All other combinations of |encyclopedia, |title, and |article are not modified
]]
	if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
		if is_set(Periodical) then					-- Periodical is set when |encyclopedia is set
			if is_set(Title) then
				if not is_set(Chapter) then
					Chapter = Title;				-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					TransChapter = TransTitle;
					Title = Periodical;
					Periodical = '';				-- redundant so unset
					TransTitle = '';				-- redundant so unset
				end
			else									-- |title not set
				Title = Periodical;					-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';					-- redundant so unset
			end
		end
	end

--special cases for citation.
	if (config.CitationClass == &quot;citation&quot;) then		-- for citation templates
		if not is_set (Ref) then						-- if |ref= is not set
			Ref = &quot;harv&quot;;								-- set default |ref=harv
		end
		if not is_set (sepc) then						-- if |separator= is not set
			sepc = ',';									-- set citation separator to its default (comma)
		end
	else												-- not a citation template
		if not is_set (sepc) then						-- if |separator= has not been set
			sepc = '.';									-- set cite xxx separator to its default (period)
		end
	end

-- check for special case where |separator=none
	if 'none' == sepc:lower() then						-- if |separator=none
		sepc = '';										-- then set it to an empty string
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then	-- special case for cite techreport
		if is_set(Issue) then						-- cite techreport uses 'number', which other citations aliase to 'issue'
			if not is_set(ID) then					-- can we use ID for the &quot;number&quot;?
				ID = Issue;							-- yes, use it
				Issue = &quot;&quot;;							-- unset Issue so that &quot;number&quot; isn't duplicated in the rendered citation or COinS metadata
			else									-- can't use ID so emit error message
				ID = ID .. &quot; &quot; .. seterror('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Interviewer) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Interviewer;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Interviewer;
			end
			if is_set(Cointerviewers) then
				Others = Others .. sepc .. ' ' .. Cointerviewers;
			end
		else
			Others = '(Interview)';
		end
	end

--Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set
	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_embargoed(Embargo) then
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];	-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];		-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
--TODO: if this is only for {{cite conference}}, shouldn't we be checking? (if config.CitationClass=='conference' then ...)
	if is_set(BookTitle) then
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = BookTitle;
		TitleLink = '';
		TransTitle = '';
	end

-- Account for the oddity that is {{cite episode}}, before generation of COinS data.
--[[	-- {{cite episode}} is not currently supported by this module
	if config.CitationClass == &quot;episode&quot; then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];
		local Season = A['Season'];
		local SeriesNumber = A['SeriesNumber'];
		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
		local Sep = (first_set(A[&quot;SeriesSeparator&quot;], A[&quot;Separator&quot;]) or &quot;&quot;) .. &quot; &quot;;
		
		if is_set(Issue) then table.insert(s, cfg.messages[&quot;episode&quot;] .. &quot; &quot; .. Issue); Issue = ''; end
		if is_set(Season) then table.insert(s, cfg.messages[&quot;season&quot;] .. &quot; &quot; .. Season); end
		if is_set(SeriesNumber) then table.insert(s, cfg.messages[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber); end
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		
		Date = Date or AirDate;
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = Series;
		TitleLink = SeriesLink;
		TransTitle = '';
		
		Series = table.concat(s, Sep);
		ID = table.concat(n, Sep);
	end
-- end of {{cite episode}} stuff]]

-- legacy: promote concatenation of |day=, |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set(Date) then
		Date = Year;						-- promote Year to Date
		Year = nil;							-- make nil so Year as empty string isn't used for CITEREF
		if is_set(Date) then
			local Month = A['Month'];
			if is_set(Month) then
				Date = Month .. &quot; &quot; .. Date;
				local Day = A['Day']
				if is_set(Day) then Date = Day .. &quot; &quot; .. Date end
			end
		elseif is_set(PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;			-- promote PublicationDate to Date
			PublicationDate = '';			-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end	-- if PublicationDate is same as Date, don't display in rendered citation


--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	anchor_year, COinS_date, error_message = dates({['accessdate']=AccessDate, ['airdate']=AirDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
		['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});
	if is_set(error_message) then
		table.insert( z.message_tail, { seterror( 'bad_date', {error_message}, true ) } );	-- add this error message
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for
	-- automated parsing of citation information.
	-- this is the function call to COinS()
	local OCinSoutput = COinS{
		['Periodical'] = Periodical,
		['Chapter'] = strip_apostrophe_markup (Chapter),						-- Chapter stripped of bold / italic wikimarkup
		['Title'] = make_coins_title (Title, ScriptTitle),						-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = first_set(COinS_date, Date),		-- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here?  Should we be including invalid dates in metadata?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set(Page, Pages, At)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set( URL, ChapterURL ),
		['Authors'] = a,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	};
--[[Why is this here?  Why are we mapping Title to Chapter when Periodical is set?
	if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = '';
		TitleLink = '';
		TransTitle = '';
	end
]]
--[[ Hide unfinished cite newsgroup code so that long delayed update can take place
-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername and ID
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = '[Newsgroup]:&amp;nbsp;' ..  externallink( 'news:' .. PublisherName, PublisherName );
		end
	end
]]


	-- Now perform various field 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 not is_set(Authors) then
		local Maximum = tonumber( A['DisplayAuthors'] );
		
		-- Preserve old-style implicit et al.
		if not is_set(Maximum) and #a == 9 then 
			Maximum = 8;
			table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
		elseif not is_set(Maximum) then
			Maximum = #a + 1;
		end
			
		local control = { 
			sep = A[&quot;AuthorSeparator&quot;] .. &quot; &quot;,
			namesep = (first_set(A[&quot;AuthorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
			format = A[&quot;AuthorFormat&quot;],
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text				-- get current page name so that we don't wikilink to it via authorlinkn
		};
		
		-- If the coauthor field is also used, prevent ampersand and et al. formatting.
		if is_set(Coauthors) then
			control.lastauthoramp = nil;
			control.maximum = #a + 1;
		end
		
		Authors = listpeople(control, a) 
	end

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { seterror('coauthors_missing_author', {}, true) } );	-- emit error message
	end

	local EditorCount
	if not is_set(Editors) then
		local Maximum = tonumber( A['DisplayEditors'] );
		-- Preserve old-style implicit et al.
		if not is_set(Maximum) and #e == 4 then 
			Maximum = 3;
			table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
		elseif not is_set(Maximum) then
			Maximum = #e + 1;
		end

		local control = { 
			sep = A[&quot;EditorSeparator&quot;] .. &quot; &quot;,
			namesep = (first_set(A[&quot;EditorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
			format = A['EditorFormat'],
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text				-- get current page name so that we don't wikilink to it via authorlinkn
		};

		Editors, EditorCount = listpeople(control, e);
	else
		EditorCount = 1;
	end

	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	if config.CitationClass == &quot;map&quot; then
		if not is_set( Authors ) and is_set( PublisherName ) then
			Authors = PublisherName;
			PublisherName = &quot;&quot;;
		end
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap( 'cartography', Cartography, use_lowercase );
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end		
	end
	
	if  not is_set(URL) and
		not is_set(ChapterURL) and
		not is_set(ArchiveURL) and
		not is_set(ConferenceURL) and
		not is_set(TranscriptURL) then
		
		-- Test if cite web or cite podcast |url= is missing or empty 
		if inArray(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;}) then	
			table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
		end
		
		-- Test if accessdate is given without giving a URL
		if is_set(AccessDate) then
			table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
		
		-- Test if format is given without giving a URL
		if is_set(Format) then
			Format = Format .. seterror( 'format_missing_url' );
		end
	end
	
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(Periodical) and
		not is_set(Conference) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
		table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
	end
	
	Format = is_set(Format) and &quot; (&quot; .. Format .. &quot;)&quot; or &quot;&quot;;
	
	local OriginalURL = URL
	DeadURL = DeadURL:lower();
	if is_set( ArchiveURL ) then
		if ( DeadURL ~= &quot;no&quot; ) then
			URL = ArchiveURL
			URLorigin = A:ORIGIN('ArchiveURL')
		end
	end
	
	-- Format chapter / article title
	if is_set(Chapter) and is_set(ChapterLink) then 
		Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot;;
	end

	Chapter = kern_quotes (Chapter);				-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
	Chapter = wrap( 'quoted-title', Chapter );
	TransChapter = wrap( 'trans-quoted-title', TransChapter );

	local TransError = &quot;&quot;
	if is_set(TransChapter) then
		if not is_set(Chapter) then
			TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );		-- add error message
		else
			TransChapter = &quot; &quot; .. TransChapter;
		end
	end
	
	Chapter = Chapter .. TransChapter;
	
	if is_set(Chapter) then
		if not is_set(ChapterLink) then
			if is_set(ChapterURL) then
				Chapter = externallink( ChapterURL, Chapter ) .. TransError;
				if not is_set(URL) then
					Chapter = Chapter .. Format;
					Format = &quot;&quot;;
				end
			elseif is_set(URL) then 
				Chapter = externallink( URL, Chapter ) .. TransError .. Format;
				URL = &quot;&quot;;
				Format = &quot;&quot;;
			else
				Chapter = Chapter .. TransError;
			end			
		elseif is_set(ChapterURL) then
			Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. TransError;	-- ChapterURLorigin holds the name of parameter
		else
			Chapter = Chapter .. TransError;
		end
		Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
	elseif is_set(ChapterURL) then
		Chapter = &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. sepc .. &quot; &quot;;
	end		
	
	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;journal&quot;,&quot;pressrelease&quot;,&quot;conference&quot;,&quot;podcast&quot;}) then
		Title = kern_quotes (Title);											-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
		Title = wrap( 'quoted-title', Title );
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap( 'trans-quoted-title', TransTitle );
--		Chapter = '';								-- chapter not allowed - disabled because doing this here doesn't display error msg and promoted url is lost
	else
		Title = wrap( 'italic-title', Title );
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap( 'trans-italic-title', TransTitle );
	end

	TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then 
			Title = externallink( URL, Title ) .. TransError .. Format	   
			URL = &quot;&quot;;
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap( 'written', Place, use_lowercase ) .. sepc .. &quot; &quot;;
	end
	
	if is_set(Conference) then
		if is_set(ConferenceURL) then
			Conference = externallink( ConferenceURL, Conference );
		end
		Conference = sepc .. &quot; &quot; .. Conference
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. externallink( ConferenceURL, nil, ConferenceURLorigin );
	end
	
	if not is_set(Position) then
		local Minutes = A['Minutes'];
		if is_set(Minutes) then
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			local Time = A['Time'];
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end
	
	if not is_set(Page) then
		if is_set(Pages) then
			if is_set(Periodical) and
				not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
				Pages = &quot;: &quot; .. Pages;
			elseif tonumber(Pages) ~= nil then
				Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
			else
				Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
			end
		end
	else
		if is_set(Periodical) and
			not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
			Page = &quot;: &quot; .. Page;
		else
			Page = sepc ..&quot; &quot; .. PPrefix .. Page;
		end
	end
	
	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Inset = A['Inset'];
		if first_set( Pages, Page, At ) ~= nil or sepc ~= '.' then
			if is_set( Section ) then
				Section = &quot;, &quot; .. wrap( 'section', Section, true );
			end
			if is_set( Inset ) then
				Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
			end
		else
			if is_set( Section ) then
				Section = sepc .. &quot; &quot; .. wrap( 'section', Section, use_lowercase );
				if is_set( Inset ) then
					Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
				end
			elseif is_set( Inset ) then
				Inset = sepc .. &quot; &quot; .. wrap( 'inset', Inset, use_lowercase );
			end			
		end			
		At = At .. Section .. Inset;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language, this_page.namespace);			-- format, categories (article namespace only), name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;

-- handle type parameter for those CS1 citations that have default values

	if inArray(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then	-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then					-- if type parameter is specified
		TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot;;	-- display it in parentheses
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	Edition = is_set(Edition) and (&quot; &quot; .. wrap( 'edition', Edition )) or &quot;&quot;;
	Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc ..&quot; &quot; .. Volume;
		  else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
		end
	end

--[[ This code commented out while discussion continues until after week of 2014-03-23 live module update;
	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc .. &quot; &quot; .. Volume;
		  else
			  Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
			  if is_set(Series) then Volume = sepc .. Volume;
			  end
		end
	end
]]	
	------------------------------------ totally unrelated data
	--[[ Loosely mimic {{subscription required}} template; Via parameter identifies a delivery source that is not the publisher; these sources often, but not always, exist
	behind a registration or paywall.  So here, we've chosen to decouple via from subscription (via has never been part of the registration required template).
	
	Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link note is displayed. There are no error messages for this condition.
	]]
	if is_set(Via) then
		Via = &quot; &quot; .. wrap( 'via', Via );
	end

	if is_set(SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription']; --here when 'via' parameter not used but 'subscription' is
	elseif is_set(RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration']; --here when 'via' and 'subscription' parameters not used but 'registration' is
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
		AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
			.. substitute( retrv_text, {AccessDate} ) .. '&lt;/span&gt;'
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end

	
	ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo} );

	if is_set(URL) then
		URL = &quot; &quot; .. externallink( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
			Quote = Quote:sub(2,-2);
		end
		Quote = sepc ..&quot; &quot; .. wrap( 'quoted-text', Quote ); 
		PostScript = &quot;&quot;;							-- CS1 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = seterror('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ externallink( ArchiveURL, arch_text ), ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text,
				{ externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ seterror('archive_missing_url'), ArchiveDate } );
		end
	else
		Archived = &quot;&quot;
	end
	
	local Lay
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
		end			
	else
		Lay = &quot;&quot;;
	end
	
	if is_set(Transcript) then
		if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
	elseif is_set(TranscriptURL) then
		Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
	end
	
	local Publisher;
	if is_set(Periodical) and
		not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap( 'published', PublicationDate );
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap( 'published', PublicationDate ) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap( 'italic-title', Periodical ) 
		else 
			Periodical = wrap( 'italic-title', Periodical )
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon
	if inArray(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, 
			Language, Cartography, Edition, Publisher, Agency, Volume, Issue}, sepc );
	else 
		tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, Language, 
			Volume, Issue, Others, Cartography, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Page .. Pages .. At;
	
	if is_set(Authors) then
		if is_set(Coauthors) then
			Authors = Authors .. A['AuthorSeparator'] .. &quot; &quot; .. Coauthors
		end
		if is_set(Date) then
			Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		elseif string.sub(Authors,-1,-1) == sepc then
			Authors = Authors .. &quot; &quot;
		else
			Authors = Authors .. sepc .. &quot; &quot;
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			if (sepc ~= '.') then in_text = in_text:lower() end
			Editors = in_text .. Editors .. post_text;
			if (string.sub(Editors,-1,-1) == sepc)
				then Editors = Editors .. &quot; &quot;
				else Editors = Editors .. sepc .. &quot; &quot;
			end
		end
		text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
		text = safejoin( {text, pgtext, idcommon}, sepc );
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
		text = safejoin( {text, pgtext, idcommon}, sepc );
	else
		if is_set(Date) then
			if ( string.sub(tcommon,-1,-1) ~= sepc )
			  then Date = sepc ..&quot; &quot; .. Date .. OrigYear
			  else Date = &quot; &quot; .. Date .. OrigYear
			end
		end
		if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
			text = safejoin( {Chapter, Place, tcommon}, sepc );
			text = safejoin( {text, pgtext, Date, idcommon}, sepc );
		else
			text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
			text = safejoin( {text, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
--		text = text:sub(1,-2);	--Remove final separator (assumes that sepc is only one character)
	end	
	
	text = safejoin( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;span/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = &quot;citation &quot; .. config.CitationClass;
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
		local id = Ref
		if ( &quot;harv&quot; == Ref ) then
			local names = {} --table of last names &amp; year
			if #a &gt; 0 then
				for i,v in ipairs(a) do 
					names[i] = v.last 
					if i == 4 then break end
				end
			elseif #e &gt; 0 then
				for i,v in ipairs(e) do 
					names[i] = v.last 
					if i == 4 then break end				
				end
			end
			names[ #names + 1 ] = first_set(Year, anchor_year);	-- Year first for legacy citations
			id = anchorid(names)
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = seterror('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then 
		text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	else
		text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	end		

	local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
	
	-- Note: Using display: none on then COinS span breaks some clients.
	local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
	text = text .. OCinS;
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. errorcomment( v[1], v[2] );
				else
					text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if inArray(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
	local pframe = frame:getParent()
	
	if nil ~= string.find( frame:getTitle(), 'sandbox', 1, true ) then				-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData( 'Module:Citation/CS1/Configuration/sandbox' );	-- load sandbox versions of Configuration and Whitelist and ...
		whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist/sandbox' );
		dates = require('Module:Citation/CS1/Date_validation/sandbox').dates	-- ... sandbox version of date validation code
	else																	-- otherwise
		cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );			-- load live versions of Configuration and Whitelist and ...
		whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );
		dates = require('Module:Citation/CS1/Date_validation').dates		-- ... live version of date validation code
	end
	
	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = seterror( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if #suggestions == 0 then
						suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
					end
					if suggestions[ k:lower() ] ~= nil then
						error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
					else
						error_text, error_state = seterror( 'parameter_ignored', {k}, true );
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	
	
	return citation0( config, args)
end

return z</text>
      <sha1>qkhefok0px666o12qjq0wuw59swiu5w</sha1>
    </revision>
    <revision>
      <id>4685</id>
      <parentid>4684</parentid>
      <timestamp>2014-10-24T14:36:06Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Better version of strip_apostrophe_markup()?</comment>
      <origin>4685</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="95275" sha1="t1grb375iy8fsgvunplu6yby6qtfbl1" xml:space="preserve">
local z = {
	error_categories = {};		-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};		-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};		-- for categorizing citations based on certain properties, language of source for instance
}

-- Whether variable is set or not
function is_set( var )
	return not (var == nil or var == '');
end

-- First set variable or nil if none
function first_set(...)
	local list = {...};
	for _, var in pairs(list) do
		if is_set( var ) then
			return var;
		end
	end
end

-- Whether needle is in haystack
function inArray( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end

--[[
Categorize and emit an error message when the citation contains one or more deprecated parameters.  Because deprecated parameters (currently |day=, |month=,
|coauthor=, and |coauthors=) aren't related to each other and because these parameters may be concatenated into the variables used by |date= and |author#= (and aliases)
details of which parameter caused the error message are not provided.  Only one error message is emitted regardless of the number of deprecated parameters in the citation.
]]
function deprecated_parameter()
	if true ~= Page_in_deprecated_cat then	-- if we haven't been here before then set a 
		Page_in_deprecated_cat=true;		-- sticky flag so that if there are more than one deprecated parameter the category is added only once
		table.insert( z.message_tail, { seterror( 'deprecated_params', {}, true ) } );		-- add error message
	end
end

-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
--	return args and tostring( mw.message.newRawMessage( msg, args ) ) or msg;
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[
Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern  either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
]]
function kern_quotes (str)
	local left='&lt;span style=&quot;padding-left:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains leading single or double quote mark
	local right='&lt;span style=&quot;padding-right:0.2em;&quot;&gt;%1&lt;/span&gt;';		-- spacing to use when title contains trailing single or double quote mark
	
	if  str:match (&quot;^[\&quot;\'][^\']&quot;) then
		str = string.gsub( str, &quot;^[\&quot;\']&quot;, left, 1 );				-- replace (captured) leading single or double quote with left-side &lt;span&gt;
	end
	if str:match (&quot;[^\'][\&quot;\']$&quot;) then
		str = string.gsub( str, &quot;[\&quot;\']$&quot;, right, 1 );			-- replace (captured) trailing single or double quote with right-side &lt;span&gt;
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

At this writing, only |script-title= is supported.  It is anticipated that additional parameters will be created to use this function.

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
			if inArray (lang, {'ar', 'ja', 'ko', 'he', 'zh'}) then				-- is prefix one of these language codes?
				table.insert( z.properties_cats, 'CS1 uses ' .. name .. '-language script ('..lang..')');	-- categorize in language-specific categories
			else
				table.insert( z.properties_cats, 'CS1 uses foreign language script');	-- use this category as a catchall until language-specific category is available
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = '&lt;bdi' .. lang .. '&gt;' .. script_value .. '&lt;/bdi&gt;';			-- isolate incase script is rlt

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end

-- Wraps a string using a message_list configuration taking one argument
function wrap( key, str, lower )
	if not is_set( str ) then
		return &quot;&quot;;
	elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safeforitalics( str );
	end
	if lower == true then
		return substitute( cfg.messages[key]:lower(), {str} );
	else
		return substitute( cfg.messages[key], {str} );
	end		
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = selectone( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
]]
function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end

-- Formats a comment for error trapping
function errorcomment( content, hidden )
	return wrap( hidden and 'hidden-error' or 'visible-error', content );
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return errorcomment( message, error_state.hidden );
end

-- Formats a wiki style external link
function externallinkid(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

-- Formats a wiki style internal link
function internallinkid(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

-- Format an external link with error checking
function externallink( URL, label, source )
	local error_str = &quot;&quot;;
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = seterror( 'bare_url_missing_title', { wrap( 'parameter', source ) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not checkurl( URL ) then
		error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
	end
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safeforurl( label ), &quot;]&quot;, error_str });
end

-- Formats a link to Amazon
function amazon(id, domain)
	if checkisbn( id ) then														-- see if asin value is a 10-digit isbn
		table.insert( z.maintenance_cats, &quot;CS1 maint: ASIN uses ISBN&quot;);			-- add to maint category so a bot or awb script can replace |asin= with |isbn=
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif inArray (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif inArray (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return externallinkid({link = handler.link,
		label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
		encode=handler.encode, separator = handler.separator})
end

--[[
format and error check arXiv identifier.  There are two valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces
]]

function arxiv (id)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = &quot;&quot;
	
	year, month, version = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d([v%d]*)$&quot;);				-- test for the 9108-0703 format
	if not year then		-- arXiv id is not proper 9108-0703 form
		year, month, version = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d([v%d]*)$&quot;);	-- test for the 0704- format
		if not year then	
			err_cat = ' ' .. seterror( 'bad_arxiv' );							-- arXiv id doesn't match either format
		else	-- id is the 0704- format
			year = tonumber(year);
			month = tonumber(month);
			if ((7 &gt; year) or (1 &gt; month and 12 &lt; month)) or					-- is year invalid or is month invalid? (doesn't test for future years)
				((7 == year) and (4 &gt; month)) or								-- when year is 07, is month invalid (before April)?
				is_set (version) and nil == version:match(&quot;v%d+&quot;) then			-- is version proper format of single 'v' followed by digits?
					err_cat = ' ' .. seterror( 'bad_arxiv' );					-- set error message
			end
		end
	else	-- id is the 9108-0703 format; are the date values ok
		year = tonumber(year);
		month = tonumber(month);
		if ((91 &gt; year and 7 &lt; year) or (1 &gt; month and 12 &lt; month)) or			-- if invalid year or invalid month
			((91 == year and 8 &gt; month) or (7 == year and 3 &lt; month)) or 		-- if years ok, are starting and ending months ok?
				is_set (version) and nil == version:match(&quot;v%d+&quot;) then			-- is version proper format of single 'v' followed by digits?
					err_cat = ' ' .. seterror( 'bad_arxiv' );					-- set error message
		end
	end

	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--[[
Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of the LCCN dictates the character type of the first 1-3 characters; the
rightmost eight are always digits. http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]
function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. seterror( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. seterror( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]
function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmid' );	-- set an error message
		end
	end
	
	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns true; otherwise, returns false because the embargo has expired or |embargo= not set in this cite.
]]
function is_embargoed(embargo)
	if is_set(embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 and tonumber( embargo_date ) &gt;= tonumber( todays_date ) then	--is embargo date is in the future?
			return true;	-- still embargoed
		end
	end
	return false;			-- embargo expired or |embargo= not set
end

--[[
Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future
the PMC identifier will not be linked to the article.  If the embargo specifies a date in the past, or if it is empty or omitted, then
the PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.
]]
function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_embargoed(embargo) then
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	--still embargoed so no external link
	else
		text = externallinkid({link = handler.link, label = handler.label,			--no embargo date, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.

-- DOI names contain two parts: prefix and suffix separated by a forward slash.
--  Prefix: directory indicator '10.' followed by a registrant code
--  Suffix: character string of any length chosen by the registrant

-- This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes,
-- or, if it ends with a period or a comma, this function will emit a bad_doi error message.

-- DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
-- and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely if ever used in doi names.

function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. seterror( 'bad_doi' );
	end
	return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);					-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	else
		return externallinkid({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode}) .. 
			' ' .. seterror( 'bad_ol' );
	end
end

--[[
Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.
]]
function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = externallinkid({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. seterror( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[
This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those citations that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).
]]
function set_titletype(cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;					-- if |type=none then type parameter not displayed
		end
		return title_type;						-- if |type= has been set to any other value use that value
	end

	if &quot;AV-media-notes&quot; == cite_class or &quot;DVD-notes&quot; == cite_class then		-- if this citation is cite AV media notes or cite DVD notes
		return &quot;Media notes&quot;;					-- display AV media notes / DVD media notes annotation

	elseif &quot;podcast&quot; == cite_class then			-- if this citation is cite podcast
		return &quot;Podcast&quot;;						-- display podcast annotation

	elseif &quot;pressrelease&quot; == cite_class then	-- if this citation is cite press release
		return &quot;Press release&quot;;					-- display press release annotation

	elseif &quot;techreport&quot; == cite_class then		-- if this citation is cite techreport
		return &quot;Technical report&quot;;				-- display techreport annotation
	
	elseif &quot;thesis&quot; == cite_class then			-- if this citation is cite thesis (degree option handled after this function returns)
			return &quot;Thesis&quot;;					-- display simple thesis annotation (without |degree= modification)
	end
end

--[[
Determines whether a URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
	-- Protocol-relative or URL scheme
	return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
	return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]
function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other lua magic pattern characters
	return argument;
end

--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]
function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	while true do
		if argument:match (&quot;%'%'%'%'%'&quot;) then									-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:match (&quot;%'%'%'%'&quot;) then									-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:match (&quot;%'%'%'&quot;) then									-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:match (&quot;%'%'&quot;) then										-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end

--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...
]]

function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end

--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]
function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end

--[[
ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in checkisbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.
]]
function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of bytes
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end	-- isbn13 begins with 978 or 979
		isbn_str = { isbn_str:byte(1, len) };
		for i, v in ipairs( isbn_str ) do
			temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
		end
		return temp % 10 == 0;
	end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
	--[[ Note: We cannot use &lt;i&gt; for italics, as the expected behavior for
	italics specified by ''...'' in the title is that they will be inverted
	(i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
	tend to interact poorly under Mediawiki's HTML tidy. ]]
	
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end

--[[
Joins a sequence of strings together while checking for duplicate separation characters.

TODO: safejoin() has a flaw where it won't remove the duplicate character from a |title= / |url= combination.
This is because by the time we get here, |title=http://somesite.com and |title=Document Title. have been combined:
	[http://somesite.com and ''Document Title.'']
so that now, the last character is not sepc but is ] (unless sepc == ']' which breaks the external link)
]]
function safejoin( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';
	local comp = '';
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then
			str = value;
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then
				-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
			else
				comp = value;
			end
			
			if comp:sub(1,1) == duplicate_char then
				trim = false;
				end_chr = str:sub(-1,-1);
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
				if end_chr == duplicate_char then
					str = str:sub(1,-2);
				elseif end_chr == &quot;'&quot; then
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
						str = str:sub(1, -4) .. &quot;''&quot;;
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
						trim = true;
					end
				elseif end_chr == &quot;]&quot; then
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
						trim = true;
					end
				elseif end_chr == &quot; &quot; then
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
						str = str:sub(1,-3);
					end
				end

				if trim then
					if value ~= comp then 
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
					else
						value = value:sub( 2, -1 );
					end
				end
			end
			str = str .. value;
		end
	end
	return str;
end  

-- Attempts to convert names to initials.
function reducetoinitials(first)
	local initials = {}
	local i = 0;										-- counter for number of initials
	for word in string.gmatch(first, &quot;%S+&quot;) do
		table.insert(initials, string.sub(word,1,1))	-- Vancouver format does not include full stops.
		i = i + 1;										-- bump the counter 
		if 2 &lt;= i then break; end						-- only two initials allowed in Vancouver system; if 2, quit
	end
	return table.concat(initials)						-- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
	local sep = control.sep;
	local namesep = control.namesep
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}
	local etal = false;
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if maximum ~= nil and maximum &lt; 1 then return &quot;&quot;, 0; end
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if maximum ~= nil and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
					one = one .. namesep .. first 
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;		-- link author/editor if this page is not the author's/editor's page
				end

				if is_set(person.link) and nil ~= person.link:find(&quot;//&quot;) then one = one .. &quot; &quot; .. seterror( 'bad_authorlink' ) end	-- check for url in author link;
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;
		end
		text[#text] = nil; 
	end
	
	local result = table.concat(text) -- construct list
	if etal then 
		local etal_text = cfg.messages['et al'];
		result = result .. &quot; &quot; .. etal_text;
	end
	
	-- if necessary wrap result in &lt;span&gt; tag to format in Small Caps
	if ( &quot;scap&quot; == format ) then result = 
		'&lt;span class=&quot;smallcaps&quot; style=&quot;font-variant:small-caps&quot;&gt;' .. result .. '&lt;/span&gt;';
	end 
	return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
	return &quot;CITEREF&quot; .. table.concat( options );
end

--[[
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.
]]
function extractnames(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	
	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary

	while true do
		last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { seterror( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 == count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			names[n] = {last = last, first = first, link = link, mask = mask};	-- add this name to our names list
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { seterror( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	return names;																-- all done, return our list of names
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
	local id_list = {};
	for k, v in pairs( cfg.id_handlers ) do	
		v = selectone( args, v.parameters, 'redundant_parameters' );
		if is_set(v) then id_list[k] = v; end
	end
	return id_list;
end

-- Takes a table of IDs and turns it into a table of formatted ID outputs.
function buildidlist( id_list, options )
	local new_list, handler = {};
	
	function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, externallinkid( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internallinkid( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internallinkid( handler );
			if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
	local value = nil;
	local selected = '';
	local error_list = {};
	
	if index ~= nil then index = tostring(index); end
	
	-- Handle special case of &quot;#&quot; replaced by empty string
	if index == '1' then
		for _, v in ipairs( possible ) do
			v = v:gsub( &quot;#&quot;, &quot;&quot; );
			if is_set(args[v]) then
				if value ~= nil and selected ~= v then
					table.insert( error_list, v );
				else
					value = args[v];
					selected = v;
				end
			end
		end		
	end
	
	for _, v in ipairs( possible ) do
		if index ~= nil then
			v = v:gsub( &quot;#&quot;, index );
		end
		if is_set(args[v]) then
			if value ~= nil and selected ~=  v then
				table.insert( error_list, v );
			else
				value = args[v];
				selected = v;
			end
		end
	end
	
	if #error_list &gt; 0 then
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap( 'parameter', k );
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap( 'parameter', selected );
		table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
function COinS(data)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end
	
	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
			end
		end
	});
	
	if is_set(data.Chapter) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Chapter;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	elseif is_set(data.Periodical) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
		OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	else
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
	end
	
	OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
	OCinSoutput[&quot;rft.date&quot;] = data.Date;
	OCinSoutput[&quot;rft.series&quot;] = data.Series;
	OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
	OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
	OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
	OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
	OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
	
	for k, v in pairs( data.ID_list ) do
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
	
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = v.last, v.first;
		if k == 1 then
			if is_set(last) then
				OCinSoutput[&quot;rft.aulast&quot;] = last;
			end
			if is_set(first) then 
				OCinSoutput[&quot;rft.aufirst&quot;] = first;
			end
		end
		if is_set(last) and is_set(first) then
			OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
		elseif is_set(last) then
			OCinSoutput[&quot;rft.au&quot;] = last;
		end
	end
	
	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 code.  Handles the special case that is Norwegian where
ISO639-1 code 'no' is mapped to language name 'Norwegian Bokmål' by Extention:CLDR.

Returns the language name and associated ISO639-1 code.  Because case of the source may be incorrect or different from the case that Wikimedia
uses, the name comparisons are done in lower case and when a match is found, the Wikimedia version (assumed to be correct) is returned along
with the code.  When there is no match, we return the original language name string.

mw.language.fetchLanguageNames() will return a list of languages that aren't part of ISO639-1. Names that aren't ISO639-1 but that are included
in the list will be found if that name is provided in the |language= parameter.  For example, if |language=Samaritan Aramaic, that name will be
found with the associated code 'sam', not an ISO639-1 code.  When names are found and the associated code is not two characters, this function
returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.
]]

function get_iso639_code (lang)
	if 'Norwegian' == lang then
		return lang, 'no';														-- special case related to Wikimedia remap of code 'no' at Extension:CLDR
	end
	
	local languages = mw.language.fetchLanguageNames('en', 'all')				-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() then												-- ISO639-1 codes only
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the ISO639-1 code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for ISO639-1 code
end

--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Get language name from ISO639-1 code value provided.  If a code is valid use the returned name; if not, then use the value that was provided with the language parameter.

There is an exception.  There are three ISO639-1 codes for Norewegian language variants.  There are two official variants: Norwegian Bokmål (code 'nb') and
Norwegian Nynorsk (code 'nn').  The third, code 'no',  is defined by ISO639-1 as 'Norwegian' though in Norway this is pretty much meaningless.  However, it appears
that on enwiki, editors are for the most part unaware of the nb and nn variants (compare page counts for these variants at Category:Articles with non-English-language external links.

Because Norwegian Bokmål is the most common language variant, Media wiki has been modified to return Norwegian Bokmål for ISO639-1 code 'no'. Here we undo that and
return 'Norwegian' when editors use |language=no.  We presume that editors don't know about the variants or can't descriminate between them.

See Help talk:Citation Style_1#An ISO 639-1 language name test

When |language= contains a valid ISO639-1 code, the page is assigned to the category for that code: Category:Norwegian-language sources (no) if
the page is a mainspace page and the ISO639-1 code is not 'en'.  Similarly, if the  parameter is |language=Norwegian, it will be categorized in the same way.

TODO: Error message when language or language code is not ISO639-1?
]]

function language_parameter (lang, namespace)
	local code;			-- the ISO639-1 two character code
	local name;			-- the language name
	local test='';
		
	if 0 == namespace and (('en' == lang:lower()) or ('english' == lang:lower())) then
		table.insert (z.maintenance_cats, 'CS1 maint: English language specified');		-- add maintenance category if |language=English or |language=en in article space
	end

	if 2 == lang:len() then														-- ISO639-1 language code are 2 characters (fetchLanguageName also supports 3 character codes)
		name = mw.language.fetchLanguageName( lang:lower(), &quot;en&quot; );				-- get ISO 639-1 language name if Language is a proper code
	end

	if is_set (name) then														-- if Language specified a valid ISO639-1 code
		code = lang:lower();													-- save it
	else
		name, code = get_iso639_code (lang);									-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
	end

	if is_set (code) then
		if 'no' == code then name = 'Norwegian' end;							-- override wikimedia when code is 'no'
			if 0 == namespace and 'en' ~= code then					-- is this page main / article space and English not the language?
				table.insert( z.properties_cats, 'CS1 ' .. name .. '-language sources (' .. code .. ')');	-- in main space and not English: categorize
			end
		end
	return (&quot; &quot; .. wrap( 'language', name));									-- wrap with '(in ...)'
end




--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------
This is the main function doing the majority of the citation
formatting.
]]
function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple
	aliases to single internal variable.
	]]
	local A = argument_wrapper( args );

	local i 
	local PPrefix = A['PPrefix']
	local PPPrefix = A['PPPrefix']
	if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
	
	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local Authors = A['Authors'];
	local a = extractnames( args, 'AuthorList' );

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];
	local Editors = A['Editors'];
	local e = extractnames( args, 'EditorList' );

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
	local Chapter = A['Chapter'];
	local ChapterLink = A['ChapterLink'];
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveURL = A['ArchiveURL'];
	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];

	local Series = A['Series'];
	local Volume = A['Volume'];
	local Issue = A['Issue'];
	local Position = '';
	local Page = A['Page'];
	local Pages = hyphentodash( A['Pages'] );	
	local At = A['At'];

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
	local SubscriptionRequired = A['SubscriptionRequired'];
	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local ArchiveDate = A['ArchiveDate'];
	local Agency = A['Agency'];
	local DeadURL = A['DeadURL']
	local Language = A['Language'];
	local Format = A['Format'];
	local Ref = A['Ref'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
	local Embargo = A['Embargo'];

	local ID_list = extractids( args );
--[[ Hide unfinished cite newsgroup code so that long delayed update can take place
	-- special case for cite newsgroup which uses |id= for a usenet article or post id
	-- |id= is not included in COinS so here we convert it to an ID that will be included in COinS
	if ('newsgroup' == config.CitationClass) and (is_set (ID)) then
		ID_list['USENETID']=ID;			-- add this new 'id' to the list of IDs
		ID = '';						-- and unset
	end
]]	
	local Quote = A['Quote'];
	local PostScript = A['PostScript'];

	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL
	local sepc = A['Separator'];

	local LastAuthorAmp = A['LastAuthorAmp'];
	local no_tracking_cats = A['NoTracking'];

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Cointerviewers = A['Cointerviewers'];			-- deprecated
	local Interviewer = A['Interviewer'];				-- deprecated
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local page_type;									-- is this needed?  Doesn't appear to be used anywhere;
	local use_lowercase = ( sepc ~= '.' );
	local this_page = mw.title.getCurrentTitle();		--Also used for COinS and for language
	local anchor_year;									-- used in the CITEREF identifier
	local COinS_date;									-- used in the COinS metadata

-- Set postscript default.
	if not is_set (PostScript) then						-- if |postscript= has not been set (Postscript is nil which is the default for {{citation}}) and
		if (config.CitationClass ~= &quot;citation&quot;) then	-- this template is not a citation template
			PostScript = '.';							-- must be a cite xxx template so set postscript to default (period)
		end
	else
		if PostScript:lower() == 'none' then			-- if |postscript=none then
			PostScript = '';							-- no postscript
		end
	end

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories.
	if not is_set(no_tracking_cats) then				-- ignore if we are already not going to categorize this page
		if inArray (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;					-- set no_tracking_cats
		end
	end

-- check for extra |page=, |pages= or |at= parameters. 
	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Page = Page .. &quot; &quot; .. seterror('extra_pages');	-- add error message
			Pages = '';										-- unset the others
			At = '';
		end
	elseif is_set(Pages) then
		if is_set(At) then
			Pages = Pages .. &quot; &quot; .. seterror('extra_pages');	-- add error messages
			At = '';											-- unset
		end
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped

All other combinations of |encyclopedia, |title, and |article are not modified
]]
	if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
		if is_set(Periodical) then					-- Periodical is set when |encyclopedia is set
			if is_set(Title) then
				if not is_set(Chapter) then
					Chapter = Title;				-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					TransChapter = TransTitle;
					Title = Periodical;
					Periodical = '';				-- redundant so unset
					TransTitle = '';				-- redundant so unset
				end
			else									-- |title not set
				Title = Periodical;					-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';					-- redundant so unset
			end
		end
	end

--special cases for citation.
	if (config.CitationClass == &quot;citation&quot;) then		-- for citation templates
		if not is_set (Ref) then						-- if |ref= is not set
			Ref = &quot;harv&quot;;								-- set default |ref=harv
		end
		if not is_set (sepc) then						-- if |separator= is not set
			sepc = ',';									-- set citation separator to its default (comma)
		end
	else												-- not a citation template
		if not is_set (sepc) then						-- if |separator= has not been set
			sepc = '.';									-- set cite xxx separator to its default (period)
		end
	end

-- check for special case where |separator=none
	if 'none' == sepc:lower() then						-- if |separator=none
		sepc = '';										-- then set it to an empty string
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then	-- special case for cite techreport
		if is_set(Issue) then						-- cite techreport uses 'number', which other citations aliase to 'issue'
			if not is_set(ID) then					-- can we use ID for the &quot;number&quot;?
				ID = Issue;							-- yes, use it
				Issue = &quot;&quot;;							-- unset Issue so that &quot;number&quot; isn't duplicated in the rendered citation or COinS metadata
			else									-- can't use ID so emit error message
				ID = ID .. &quot; &quot; .. seterror('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Interviewer) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Interviewer;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Interviewer;
			end
			if is_set(Cointerviewers) then
				Others = Others .. sepc .. ' ' .. Cointerviewers;
			end
		else
			Others = '(Interview)';
		end
	end

--Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set
	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_embargoed(Embargo) then
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];	-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];		-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
--TODO: if this is only for {{cite conference}}, shouldn't we be checking? (if config.CitationClass=='conference' then ...)
	if is_set(BookTitle) then
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = BookTitle;
		TitleLink = '';
		TransTitle = '';
	end

-- Account for the oddity that is {{cite episode}}, before generation of COinS data.
--[[	-- {{cite episode}} is not currently supported by this module
	if config.CitationClass == &quot;episode&quot; then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];
		local Season = A['Season'];
		local SeriesNumber = A['SeriesNumber'];
		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
		local Sep = (first_set(A[&quot;SeriesSeparator&quot;], A[&quot;Separator&quot;]) or &quot;&quot;) .. &quot; &quot;;
		
		if is_set(Issue) then table.insert(s, cfg.messages[&quot;episode&quot;] .. &quot; &quot; .. Issue); Issue = ''; end
		if is_set(Season) then table.insert(s, cfg.messages[&quot;season&quot;] .. &quot; &quot; .. Season); end
		if is_set(SeriesNumber) then table.insert(s, cfg.messages[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber); end
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		
		Date = Date or AirDate;
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = Series;
		TitleLink = SeriesLink;
		TransTitle = '';
		
		Series = table.concat(s, Sep);
		ID = table.concat(n, Sep);
	end
-- end of {{cite episode}} stuff]]

-- legacy: promote concatenation of |day=, |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set(Date) then
		Date = Year;						-- promote Year to Date
		Year = nil;							-- make nil so Year as empty string isn't used for CITEREF
		if is_set(Date) then
			local Month = A['Month'];
			if is_set(Month) then
				Date = Month .. &quot; &quot; .. Date;
				local Day = A['Day']
				if is_set(Day) then Date = Day .. &quot; &quot; .. Date end
			end
		elseif is_set(PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;			-- promote PublicationDate to Date
			PublicationDate = '';			-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end	-- if PublicationDate is same as Date, don't display in rendered citation


--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	anchor_year, COinS_date, error_message = dates({['accessdate']=AccessDate, ['airdate']=AirDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
		['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});
	if is_set(error_message) then
		table.insert( z.message_tail, { seterror( 'bad_date', {error_message}, true ) } );	-- add this error message
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for
	-- automated parsing of citation information.
	-- this is the function call to COinS()
	local OCinSoutput = COinS{
		['Periodical'] = Periodical,
		['Chapter'] = strip_apostrophe_markup (Chapter),						-- Chapter stripped of bold / italic wikimarkup
		['Title'] = make_coins_title (Title, ScriptTitle),						-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = first_set(COinS_date, Date),		-- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here?  Should we be including invalid dates in metadata?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set(Page, Pages, At)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set( URL, ChapterURL ),
		['Authors'] = a,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	};
--[[Why is this here?  Why are we mapping Title to Chapter when Periodical is set?
	if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = '';
		TitleLink = '';
		TransTitle = '';
	end
]]
--[[ Hide unfinished cite newsgroup code so that long delayed update can take place
-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername and ID
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = '[Newsgroup]:&amp;nbsp;' ..  externallink( 'news:' .. PublisherName, PublisherName );
		end
	end
]]


	-- Now perform various field 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 not is_set(Authors) then
		local Maximum = tonumber( A['DisplayAuthors'] );
		
		-- Preserve old-style implicit et al.
		if not is_set(Maximum) and #a == 9 then 
			Maximum = 8;
			table.insert( z.message_tail, { seterror('implict_etal_author', {}, true ) } );
		elseif not is_set(Maximum) then
			Maximum = #a + 1;
		end
			
		local control = { 
			sep = A[&quot;AuthorSeparator&quot;] .. &quot; &quot;,
			namesep = (first_set(A[&quot;AuthorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
			format = A[&quot;AuthorFormat&quot;],
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text				-- get current page name so that we don't wikilink to it via authorlinkn
		};
		
		-- If the coauthor field is also used, prevent ampersand and et al. formatting.
		if is_set(Coauthors) then
			control.lastauthoramp = nil;
			control.maximum = #a + 1;
		end
		
		Authors = listpeople(control, a) 
	end

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { seterror('coauthors_missing_author', {}, true) } );	-- emit error message
	end

	local EditorCount
	if not is_set(Editors) then
		local Maximum = tonumber( A['DisplayEditors'] );
		-- Preserve old-style implicit et al.
		if not is_set(Maximum) and #e == 4 then 
			Maximum = 3;
			table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
		elseif not is_set(Maximum) then
			Maximum = #e + 1;
		end

		local control = { 
			sep = A[&quot;EditorSeparator&quot;] .. &quot; &quot;,
			namesep = (first_set(A[&quot;EditorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
			format = A['EditorFormat'],
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text				-- get current page name so that we don't wikilink to it via authorlinkn
		};

		Editors, EditorCount = listpeople(control, e);
	else
		EditorCount = 1;
	end

	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	if config.CitationClass == &quot;map&quot; then
		if not is_set( Authors ) and is_set( PublisherName ) then
			Authors = PublisherName;
			PublisherName = &quot;&quot;;
		end
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap( 'cartography', Cartography, use_lowercase );
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end		
	end
	
	if  not is_set(URL) and
		not is_set(ChapterURL) and
		not is_set(ArchiveURL) and
		not is_set(ConferenceURL) and
		not is_set(TranscriptURL) then
		
		-- Test if cite web or cite podcast |url= is missing or empty 
		if inArray(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;}) then	
			table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
		end
		
		-- Test if accessdate is given without giving a URL
		if is_set(AccessDate) then
			table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
		
		-- Test if format is given without giving a URL
		if is_set(Format) then
			Format = Format .. seterror( 'format_missing_url' );
		end
	end
	
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(Periodical) and
		not is_set(Conference) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
		table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
	end
	
	Format = is_set(Format) and &quot; (&quot; .. Format .. &quot;)&quot; or &quot;&quot;;
	
	local OriginalURL = URL
	DeadURL = DeadURL:lower();
	if is_set( ArchiveURL ) then
		if ( DeadURL ~= &quot;no&quot; ) then
			URL = ArchiveURL
			URLorigin = A:ORIGIN('ArchiveURL')
		end
	end
	
	-- Format chapter / article title
	if is_set(Chapter) and is_set(ChapterLink) then 
		Chapter = &quot;[[&quot; .. ChapterLink .. &quot;|&quot; .. Chapter .. &quot;]]&quot;;
	end

	Chapter = kern_quotes (Chapter);				-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
	Chapter = wrap( 'quoted-title', Chapter );
	TransChapter = wrap( 'trans-quoted-title', TransChapter );

	local TransError = &quot;&quot;
	if is_set(TransChapter) then
		if not is_set(Chapter) then
			TransError = &quot; &quot; .. seterror( 'trans_missing_chapter' );		-- add error message
		else
			TransChapter = &quot; &quot; .. TransChapter;
		end
	end
	
	Chapter = Chapter .. TransChapter;
	
	if is_set(Chapter) then
		if not is_set(ChapterLink) then
			if is_set(ChapterURL) then
				Chapter = externallink( ChapterURL, Chapter ) .. TransError;
				if not is_set(URL) then
					Chapter = Chapter .. Format;
					Format = &quot;&quot;;
				end
			elseif is_set(URL) then 
				Chapter = externallink( URL, Chapter ) .. TransError .. Format;
				URL = &quot;&quot;;
				Format = &quot;&quot;;
			else
				Chapter = Chapter .. TransError;
			end			
		elseif is_set(ChapterURL) then
			Chapter = Chapter .. &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. TransError;	-- ChapterURLorigin holds the name of parameter
		else
			Chapter = Chapter .. TransError;
		end
		Chapter = Chapter .. sepc .. &quot; &quot; -- with end-space
	elseif is_set(ChapterURL) then
		Chapter = &quot; &quot; .. externallink( ChapterURL, nil, ChapterURLorigin ) .. sepc .. &quot; &quot;;
	end		
	
	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;journal&quot;,&quot;pressrelease&quot;,&quot;conference&quot;,&quot;podcast&quot;}) then
		Title = kern_quotes (Title);											-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
		Title = wrap( 'quoted-title', Title );
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap( 'trans-quoted-title', TransTitle );
--		Chapter = '';								-- chapter not allowed - disabled because doing this here doesn't display error msg and promoted url is lost
	else
		Title = wrap( 'italic-title', Title );
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap( 'trans-italic-title', TransTitle );
	end

	TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then 
			Title = externallink( URL, Title ) .. TransError .. Format	   
			URL = &quot;&quot;;
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap( 'written', Place, use_lowercase ) .. sepc .. &quot; &quot;;
	end
	
	if is_set(Conference) then
		if is_set(ConferenceURL) then
			Conference = externallink( ConferenceURL, Conference );
		end
		Conference = sepc .. &quot; &quot; .. Conference
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. externallink( ConferenceURL, nil, ConferenceURLorigin );
	end
	
	if not is_set(Position) then
		local Minutes = A['Minutes'];
		if is_set(Minutes) then
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			local Time = A['Time'];
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end
	
	if not is_set(Page) then
		if is_set(Pages) then
			if is_set(Periodical) and
				not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
				Pages = &quot;: &quot; .. Pages;
			elseif tonumber(Pages) ~= nil then
				Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
			else
				Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
			end
		end
	else
		if is_set(Periodical) and
			not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
			Page = &quot;: &quot; .. Page;
		else
			Page = sepc ..&quot; &quot; .. PPrefix .. Page;
		end
	end
	
	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Inset = A['Inset'];
		if first_set( Pages, Page, At ) ~= nil or sepc ~= '.' then
			if is_set( Section ) then
				Section = &quot;, &quot; .. wrap( 'section', Section, true );
			end
			if is_set( Inset ) then
				Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
			end
		else
			if is_set( Section ) then
				Section = sepc .. &quot; &quot; .. wrap( 'section', Section, use_lowercase );
				if is_set( Inset ) then
					Inset = &quot;, &quot; .. wrap( 'inset', Inset, true );
				end
			elseif is_set( Inset ) then
				Inset = sepc .. &quot; &quot; .. wrap( 'inset', Inset, use_lowercase );
			end			
		end			
		At = At .. Section .. Inset;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language, this_page.namespace);			-- format, categories (article namespace only), name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;

-- handle type parameter for those CS1 citations that have default values

	if inArray(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then	-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then					-- if type parameter is specified
		TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot;;	-- display it in parentheses
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	Edition = is_set(Edition) and (&quot; &quot; .. wrap( 'edition', Edition )) or &quot;&quot;;
	Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc ..&quot; &quot; .. Volume;
		  else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
		end
	end

--[[ This code commented out while discussion continues until after week of 2014-03-23 live module update;
	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc .. &quot; &quot; .. Volume;
		  else
			  Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
			  if is_set(Series) then Volume = sepc .. Volume;
			  end
		end
	end
]]	
	------------------------------------ totally unrelated data
	--[[ Loosely mimic {{subscription required}} template; Via parameter identifies a delivery source that is not the publisher; these sources often, but not always, exist
	behind a registration or paywall.  So here, we've chosen to decouple via from subscription (via has never been part of the registration required template).
	
	Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link note is displayed. There are no error messages for this condition.
	]]
	if is_set(Via) then
		Via = &quot; &quot; .. wrap( 'via', Via );
	end

	if is_set(SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription']; --here when 'via' parameter not used but 'subscription' is
	elseif is_set(RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration']; --here when 'via' and 'subscription' parameters not used but 'registration' is
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end
		AccessDate = '&lt;span class=&quot;reference-accessdate&quot;&gt;' .. sepc
			.. substitute( retrv_text, {AccessDate} ) .. '&lt;/span&gt;'
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end

	
	ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo} );

	if is_set(URL) then
		URL = &quot; &quot; .. externallink( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
			Quote = Quote:sub(2,-2);
		end
		Quote = sepc ..&quot; &quot; .. wrap( 'quoted-text', Quote ); 
		PostScript = &quot;&quot;;							-- CS1 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = seterror('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ externallink( ArchiveURL, arch_text ), ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text,
				{ externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ seterror('archive_missing_url'), ArchiveDate } );
		end
	else
		Archived = &quot;&quot;
	end
	
	local Lay
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
		end			
	else
		Lay = &quot;&quot;;
	end
	
	if is_set(Transcript) then
		if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
	elseif is_set(TranscriptURL) then
		Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
	end
	
	local Publisher;
	if is_set(Periodical) and
		not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap( 'published', PublicationDate );
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap( 'published', PublicationDate ) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap( 'italic-title', Periodical ) 
		else 
			Periodical = wrap( 'italic-title', Periodical )
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon
	if inArray(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, 
			Language, Cartography, Edition, Publisher, Agency, Volume, Issue}, sepc );
	else 
		tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, Language, 
			Volume, Issue, Others, Cartography, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Page .. Pages .. At;
	
	if is_set(Authors) then
		if is_set(Coauthors) then
			Authors = Authors .. A['AuthorSeparator'] .. &quot; &quot; .. Coauthors
		end
		if is_set(Date) then
			Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		elseif string.sub(Authors,-1,-1) == sepc then
			Authors = Authors .. &quot; &quot;
		else
			Authors = Authors .. sepc .. &quot; &quot;
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			if (sepc ~= '.') then in_text = in_text:lower() end
			Editors = in_text .. Editors .. post_text;
			if (string.sub(Editors,-1,-1) == sepc)
				then Editors = Editors .. &quot; &quot;
				else Editors = Editors .. sepc .. &quot; &quot;
			end
		end
		text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
		text = safejoin( {text, pgtext, idcommon}, sepc );
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
		text = safejoin( {text, pgtext, idcommon}, sepc );
	else
		if is_set(Date) then
			if ( string.sub(tcommon,-1,-1) ~= sepc )
			  then Date = sepc ..&quot; &quot; .. Date .. OrigYear
			  else Date = &quot; &quot; .. Date .. OrigYear
			end
		end
		if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
			text = safejoin( {Chapter, Place, tcommon}, sepc );
			text = safejoin( {text, pgtext, Date, idcommon}, sepc );
		else
			text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
			text = safejoin( {text, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
--		text = text:sub(1,-2);	--Remove final separator (assumes that sepc is only one character)
	end	
	
	text = safejoin( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;span/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = &quot;citation &quot; .. config.CitationClass;
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
		local id = Ref
		if ( &quot;harv&quot; == Ref ) then
			local names = {} --table of last names &amp; year
			if #a &gt; 0 then
				for i,v in ipairs(a) do 
					names[i] = v.last 
					if i == 4 then break end
				end
			elseif #e &gt; 0 then
				for i,v in ipairs(e) do 
					names[i] = v.last 
					if i == 4 then break end				
				end
			end
			names[ #names + 1 ] = first_set(Year, anchor_year);	-- Year first for legacy citations
			id = anchorid(names)
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = seterror('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then 
		text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	else
		text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	end		

	local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
	
	-- Note: Using display: none on then COinS span breaks some clients.
	local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
	text = text .. OCinS;
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. errorcomment( v[1], v[2] );
				else
					text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if inArray(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
	local pframe = frame:getParent()
	
	if nil ~= string.find( frame:getTitle(), 'sandbox', 1, true ) then				-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData( 'Module:Citation/CS1/Configuration/sandbox' );	-- load sandbox versions of Configuration and Whitelist and ...
		whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist/sandbox' );
		dates = require('Module:Citation/CS1/Date_validation/sandbox').dates	-- ... sandbox version of date validation code
	else																	-- otherwise
		cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );			-- load live versions of Configuration and Whitelist and ...
		whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );
		dates = require('Module:Citation/CS1/Date_validation').dates		-- ... live version of date validation code
	end
	
	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = seterror( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if #suggestions == 0 then
						suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
					end
					if suggestions[ k:lower() ] ~= nil then
						error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
					else
						error_text, error_state = seterror( 'parameter_ignored', {k}, true );
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	
	
	return citation0( config, args)
end

return z</text>
      <sha1>t1grb375iy8fsgvunplu6yby6qtfbl1</sha1>
    </revision>
    <revision>
      <id>4686</id>
      <parentid>4685</parentid>
      <timestamp>2014-11-29T11:59:16Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4686</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="100592" sha1="j2r1r6o8c9sb4wi0zbep5vnp6pvzd4y" xml:space="preserve">
local z = {
	error_categories = {};		-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};		-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};		-- for categorizing citations based on certain properties, language of source for instance
}

-- Whether variable is set or not
function is_set( var )
	return not (var == nil or var == '');
end

-- First set variable or nil if none
function first_set(...)
	local list = {...};
	for _, var in pairs(list) do
		if is_set( var ) then
			return var;
		end
	end
end

-- Whether needle is in haystack
function inArray( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end

--[[
Categorize and emit an error message when the citation contains one or more deprecated parameters.  Because deprecated parameters (currently |month=,
|coauthor=, and |coauthors=) aren't related to each other and because these parameters may be concatenated into the variables used by |date= and |author#= (and aliases)
details of which parameter caused the error message are not provided.  Only one error message is emitted regardless of the number of deprecated parameters in the citation.
]]
function deprecated_parameter()
	if true ~= Page_in_deprecated_cat then	-- if we haven't been here before then set a 
		Page_in_deprecated_cat=true;		-- sticky flag so that if there are more than one deprecated parameter the category is added only once
		table.insert( z.message_tail, { seterror( 'deprecated_params', {}, true ) } );		-- add error message
	end
end

-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[--------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Call this function for chapter titles, for website titles, etc; not for book titles.

]]

function kern_quotes (str)
	local cap='';
	local cap2='';
	
	cap, cap2 = str:match (&quot;^([\&quot;\'])([^\'].+)&quot;);								-- match leading double or single quote but not double single quotes
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-left'], {cap, cap2});
	end

	cap, cap2 = str:match (&quot;^(.+[^\'])([\&quot;\'])$&quot;)
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-right'], {cap, cap2});
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

At this writing, only |script-title= is supported.  It is anticipated that additional parameters will be created to use this function.

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if inArray (lang, {'ar', 'bs', 'dv', 'el', 'fa', 'hy', 'ja', 'ko', 'ku', 'he', 'ps', 'ru', 'sd', 'sr', 'th', 'uk', 'ug', 'yi', 'zh'}) then
				table.insert( z.properties_cats, 'CS1 uses ' .. name .. '-language script ('..lang..')');	-- categorize in language-specific categories
			else
				table.insert( z.properties_cats, 'CS1 uses foreign language script');	-- use this category as a catchall until language-specific category is available
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

function wrap_style (key, str)
	if not is_set( str ) then
		return &quot;&quot;;
	elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safeforitalics( str );
	end

	return substitute( cfg.presentation[key], {str} );
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		str = substitute( msg, {str} );											-- including template text
		return str;
	else
		return substitute( cfg.messages[key], {str} );
	end		
end

--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the three chapter parameters: |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

function format_chapter_title (chapter, transchapter, chapterurl, chapter_url_source)
	local chapter_error = '';
	
	if not is_set (chapter) then
		chapter = '';															-- just to be safe for concatenation
		if is_set (transchapter) then
			chapter = wrap_style ('trans-quoted-title', transchapter);
			chapter_error = &quot; &quot; .. seterror ('trans_missing_chapter');
		end
		if is_set (chapterurl) then
			chapter = externallink (chapterurl, chapter, chapter_url_source);	-- adds bare_url_missing_title error if appropriate
		end
		return chapter .. chapter_error;
	else																		-- here when chapter is set
		chapter = kern_quotes (chapter);										-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
		chapter = wrap_style ('quoted-title', chapter);
		if is_set (transchapter) then
			transchapter = wrap_style ('trans-quoted-title', transchapter);
			chapter = chapter .. ' ' .. transchapter;
		end
		if is_set (chapterurl) then
			chapter = externallink (chapterurl, chapter);						-- adds bare_url_missing_title error if appropriate
		end
	end
	return chapter;
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = selectone( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
]]
function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter ();				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end

--[[--------------------------&lt; E R R O R C O M M E N T &gt;------------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]
function errorcomment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return errorcomment( message, error_state.hidden );
end

-- Formats a wiki style external link
function externallinkid(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

-- Formats a wiki style internal link
function internallinkid(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

-- Format an external link with error checking
function externallink( URL, label, source )
	local error_str = &quot;&quot;;
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = seterror( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not checkurl( URL ) then
		error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
	end
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safeforurl( label ), &quot;]&quot;, error_str });
end

--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;%a+%s*%d%d?,%s*%d%d%d%d&quot;) or date:match (&quot;%d%d?%s*%a+%s*%d%d%d%d&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end

--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. seterror ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d%d$&quot;) then								-- if 10-digit numeric
			if checkisbn( id ) then												-- see if asin value is isbn10
				table.insert( z.maintenance_cats, &quot;CS1 maint: ASIN uses ISBN&quot;);	-- add to maint category
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. seterror ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. seterror ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif inArray (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif inArray (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return externallinkid({link = handler.link,
		label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
		encode=handler.encode, separator = handler.separator}) .. err_cat;
end

--[[
format and error check arXiv identifier.  There are two valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces
]]

function arxiv (id)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = &quot;&quot;
	
	year, month, version = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d([v%d]*)$&quot;);				-- test for the 9108-0703 format
	if not year then		-- arXiv id is not proper 9108-0703 form
		year, month, version = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d([v%d]*)$&quot;);	-- test for the 0704- format
		if not year then	
			err_cat = ' ' .. seterror( 'bad_arxiv' );							-- arXiv id doesn't match either format
		else	-- id is the 0704- format
			year = tonumber(year);
			month = tonumber(month);
			if ((7 &gt; year) or (1 &gt; month and 12 &lt; month)) or					-- is year invalid or is month invalid? (doesn't test for future years)
				((7 == year) and (4 &gt; month)) or								-- when year is 07, is month invalid (before April)?
				is_set (version) and nil == version:match(&quot;v%d+&quot;) then			-- is version proper format of single 'v' followed by digits?
					err_cat = ' ' .. seterror( 'bad_arxiv' );					-- set error message
			end
		end
	else	-- id is the 9108-0703 format; are the date values ok
		year = tonumber(year);
		month = tonumber(month);
		if ((91 &gt; year and 7 &lt; year) or (1 &gt; month and 12 &lt; month)) or			-- if invalid year or invalid month
			((91 == year and 8 &gt; month) or (7 == year and 3 &lt; month)) or 		-- if years ok, are starting and ending months ok?
				is_set (version) and nil == version:match(&quot;v%d+&quot;) then			-- is version proper format of single 'v' followed by digits?
					err_cat = ' ' .. seterror( 'bad_arxiv' );					-- set error message
		end
	end

	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--[[
Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of the LCCN dictates the character type of the first 1-3 characters; the
rightmost eight are always digits. http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]
function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. seterror( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. seterror( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]
function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmid' );	-- set an error message
		end
	end
	
	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns true; otherwise, returns false because the embargo has expired or |embargo= not set in this cite.
]]
function is_embargoed(embargo)
	if is_set(embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 and tonumber( embargo_date ) &gt;= tonumber( todays_date ) then	--is embargo date is in the future?
			return true;	-- still embargoed
		end
	end
	return false;			-- embargo expired or |embargo= not set
end

--[[
Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future
the PMC identifier will not be linked to the article.  If the embargo specifies a date in the past, or if it is empty or omitted, then
the PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.
]]
function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_embargoed(embargo) then
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	--still embargoed so no external link
	else
		text = externallinkid({link = handler.link, label = handler.label,			--no embargo date, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.

-- DOI names contain two parts: prefix and suffix separated by a forward slash.
--  Prefix: directory indicator '10.' followed by a registrant code
--  Suffix: character string of any length chosen by the registrant

-- This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes,
-- or, if it ends with a period or a comma, this function will emit a bad_doi error message.

-- DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
-- and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely if ever used in doi names.

function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. seterror( 'bad_doi' );
	end
	return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);					-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	else
		return externallinkid({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode}) .. 
			' ' .. seterror( 'bad_ol' );
	end
end

--[[
Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.
]]
function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = externallinkid({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. seterror( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	text = externallinkid({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. seterror( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end



--[[
This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those citations that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).
]]
function set_titletype(cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;					-- if |type=none then type parameter not displayed
		end
		return title_type;						-- if |type= has been set to any other value use that value
	end

	if &quot;AV-media-notes&quot; == cite_class or &quot;DVD-notes&quot; == cite_class then		-- if this citation is cite AV media notes or cite DVD notes
		return &quot;Media notes&quot;;					-- display AV media notes / DVD media notes annotation

	elseif &quot;podcast&quot; == cite_class then			-- if this citation is cite podcast
		return &quot;Podcast&quot;;						-- display podcast annotation

	elseif &quot;pressrelease&quot; == cite_class then	-- if this citation is cite press release
		return &quot;Press release&quot;;					-- display press release annotation

	elseif &quot;techreport&quot; == cite_class then		-- if this citation is cite techreport
		return &quot;Technical report&quot;;				-- display techreport annotation
	
	elseif &quot;thesis&quot; == cite_class then			-- if this citation is cite thesis (degree option handled after this function returns)
			return &quot;Thesis&quot;;					-- display simple thesis annotation (without |degree= modification)
	end
end

--[[
Determines whether a URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
	-- Protocol-relative or URL scheme
	return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
	return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]
function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other lua magic pattern characters
	return argument;
end

--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]
function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	while true do
		if argument:match (&quot;%'%'%'%'%'&quot;) then									-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:match (&quot;%'%'%'%'&quot;) then									-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:match (&quot;%'%'%'&quot;) then									-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:match (&quot;%'%'&quot;) then										-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end

--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...
]]

function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end

--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]
function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end

--[[
ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in checkisbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.
]]
function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of bytes
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end	-- isbn13 begins with 978 or 979
		isbn_str = { isbn_str:byte(1, len) };
		for i, v in ipairs( isbn_str ) do
			temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
		end
		return temp % 10 == 0;
	end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
	--[[ Note: We cannot use &lt;i&gt; for italics, as the expected behavior for
	italics specified by ''...'' in the title is that they will be inverted
	(i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
	tend to interact poorly under Mediawiki's HTML tidy. ]]
	
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end

--[[
Joins a sequence of strings together while checking for duplicate separation characters.

TODO: safejoin() has a flaw where it won't remove the duplicate character from a |title= / |url= combination.
This is because by the time we get here, |title=http://somesite.com and |title=Document Title. have been combined:
	[http://somesite.com and ''Document Title.'']
so that now, the last character is not sepc but is ] (unless sepc == ']' which breaks the external link)
]]
function safejoin( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';
	local comp = '';
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then
			str = value;
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then
				-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );
			else
				comp = value;
			end
			
			if comp:sub(1,1) == duplicate_char then
				trim = false;
				end_chr = str:sub(-1,-1);
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;
				if end_chr == duplicate_char then
					str = str:sub(1,-2);
				elseif end_chr == &quot;'&quot; then
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then
						str = str:sub(1, -4) .. &quot;''&quot;;
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then
						trim = true;
					end
				elseif end_chr == &quot;]&quot; then
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then
						trim = true;
					end
				elseif end_chr == &quot; &quot; then
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then
						str = str:sub(1,-3);
					end
				end

				if trim then
					if value ~= comp then 
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )
					else
						value = value:sub( 2, -1 );
					end
				end
			end
			str = str .. value;
		end
	end
	return str;
end  

-- Attempts to convert names to initials.
function reducetoinitials(first)
	local initials = {}
	local i = 0;										-- counter for number of initials
	for word in string.gmatch(first, &quot;%S+&quot;) do
		table.insert(initials, string.sub(word,1,1))	-- Vancouver format does not include full stops.
		i = i + 1;										-- bump the counter 
		if 2 &lt;= i then break; end						-- only two initials allowed in Vancouver system; if 2, quit
	end
	return table.concat(initials)						-- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
	local sep = control.sep;
	local namesep = control.namesep
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}
	local etal = false;
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if maximum ~= nil and maximum &lt; 1 then return &quot;&quot;, 0; end
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if maximum ~= nil and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
					one = one .. namesep .. first 
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;		-- link author/editor if this page is not the author's/editor's page
				end

				if is_set(person.link) and nil ~= person.link:find(&quot;//&quot;) then one = one .. &quot; &quot; .. seterror( 'bad_authorlink' ) end	-- check for url in author link;
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;
		end
		text[#text] = nil; 
	end
	
	local result = table.concat(text) -- construct list
	if etal then 
		local etal_text = cfg.messages['et al'];
		result = result .. &quot; &quot; .. etal_text;
	end
	
	if ( &quot;scap&quot; == format ) then												-- apply smallcaps formatting when authorformat or editorformat set to scap
		result = substitute (cfg.presentation['smallcaps'], result);
	end 
	return result, count
end

-- Generates a CITEREF anchor ID.
function anchorid( options )
	return &quot;CITEREF&quot; .. table.concat( options );
end

--[[
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.
]]
function extractnames(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	
	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary

	while true do
		last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { seterror( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 == count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			names[n] = {last = last, first = first, link = link, mask = mask};	-- add this name to our names list
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { seterror( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	return names;																-- all done, return our list of names
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
	local id_list = {};
	for k, v in pairs( cfg.id_handlers ) do	
		v = selectone( args, v.parameters, 'redundant_parameters' );
		if is_set(v) then id_list[k] = v; end
	end
	return id_list;
end

--[[--------------------------&lt; B U I L D I D L I S T &gt;--------------------------------------------------------
Takes a table of IDs and turns it into a table of formatted ID outputs.

]]
function buildidlist( id_list, options )
	local new_list, handler = {};

	function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, externallinkid( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internallinkid( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internallinkid( handler );
			if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
	local value = nil;
	local selected = '';
	local error_list = {};
	
	if index ~= nil then index = tostring(index); end
	
	-- Handle special case of &quot;#&quot; replaced by empty string
	if index == '1' then
		for _, v in ipairs( possible ) do
			v = v:gsub( &quot;#&quot;, &quot;&quot; );
			if is_set(args[v]) then
				if value ~= nil and selected ~= v then
					table.insert( error_list, v );
				else
					value = args[v];
					selected = v;
				end
			end
		end		
	end
	
	for _, v in ipairs( possible ) do
		if index ~= nil then
			v = v:gsub( &quot;#&quot;, index );
		end
		if is_set(args[v]) then
			if value ~= nil and selected ~=  v then
				table.insert( error_list, v );
			else
				value = args[v];
				selected = v;
			end
		end
	end
	
	if #error_list &gt; 0 then
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap_style ('parameter', k);
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap_style ('parameter', selected);
		table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
function COinS(data)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end
	
	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
			end
		end
	});
	
	if is_set(data.Chapter) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
	elseif is_set(data.Periodical) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
		OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	else
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
	end
	
	OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
	OCinSoutput[&quot;rft.date&quot;] = data.Date;
	OCinSoutput[&quot;rft.series&quot;] = data.Series;
	OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
	OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
	OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
	OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
	OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
	
	for k, v in pairs( data.ID_list ) do
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
	
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = v.last, v.first;
		if k == 1 then
			if is_set(last) then
				OCinSoutput[&quot;rft.aulast&quot;] = last;
			end
			if is_set(first) then 
				OCinSoutput[&quot;rft.aufirst&quot;] = first;
			end
		end
		if is_set(last) and is_set(first) then
			OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
		elseif is_set(last) then
			OCinSoutput[&quot;rft.au&quot;] = last;
		end
	end
	
	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 code.  Handles the special case that is Norwegian where
ISO639-1 code 'no' is mapped to language name 'Norwegian Bokmål' by Extention:CLDR.

Returns the language name and associated ISO639-1 code.  Because case of the source may be incorrect or different from the case that Wikimedia
uses, the name comparisons are done in lower case and when a match is found, the Wikimedia version (assumed to be correct) is returned along
with the code.  When there is no match, we return the original language name string.

mw.language.fetchLanguageNames() will return a list of languages that aren't part of ISO639-1. Names that aren't ISO639-1 but that are included
in the list will be found if that name is provided in the |language= parameter.  For example, if |language=Samaritan Aramaic, that name will be
found with the associated code 'sam', not an ISO639-1 code.  When names are found and the associated code is not two characters, this function
returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.
]]

function get_iso639_code (lang)
	if 'Norwegian' == lang then
		return lang, 'no';														-- special case related to Wikimedia remap of code 'no' at Extension:CLDR
	end
	
	local languages = mw.language.fetchLanguageNames('en', 'all')				-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() then												-- ISO639-1 codes only
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the ISO639-1 code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for ISO639-1 code
end

--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Get language name from ISO639-1 code value provided.  If a code is valid use the returned name; if not, then use the value that was provided with the language parameter.

There is an exception.  There are three ISO639-1 codes for Norewegian language variants.  There are two official variants: Norwegian Bokmål (code 'nb') and
Norwegian Nynorsk (code 'nn').  The third, code 'no',  is defined by ISO639-1 as 'Norwegian' though in Norway this is pretty much meaningless.  However, it appears
that on enwiki, editors are for the most part unaware of the nb and nn variants (compare page counts for these variants at Category:Articles with non-English-language external links.

Because Norwegian Bokmål is the most common language variant, Media wiki has been modified to return Norwegian Bokmål for ISO639-1 code 'no'. Here we undo that and
return 'Norwegian' when editors use |language=no.  We presume that editors don't know about the variants or can't descriminate between them.

See Help talk:Citation Style_1#An ISO 639-1 language name test

When |language= contains a valid ISO639-1 code, the page is assigned to the category for that code: Category:Norwegian-language sources (no) if
the page is a mainspace page and the ISO639-1 code is not 'en'.  Similarly, if the  parameter is |language=Norwegian, it will be categorized in the same way.

]]

function language_parameter (lang, namespace)
	local code;			-- the ISO639-1 two character code
	local name;			-- the language name
	local test='';
		
	if 0 == namespace and (('en' == lang:lower()) or ('english' == lang:lower())) then
		table.insert (z.maintenance_cats, 'CS1 maint: English language specified');		-- add maintenance category if |language=English or |language=en in article space
	end

	if 2 == lang:len() then														-- ISO639-1 language code are 2 characters (fetchLanguageName also supports 3 character codes)
		name = mw.language.fetchLanguageName( lang:lower(), &quot;en&quot; );				-- get ISO 639-1 language name if Language is a proper code
	end

	if is_set (name) then														-- if Language specified a valid ISO639-1 code
		code = lang:lower();													-- save it
	else
		name, code = get_iso639_code (lang);									-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
	end

	if is_set (code) then
		if 'no' == code then name = 'Norwegian' end;							-- override wikimedia when code is 'no'
		if 0 == namespace and 'en' ~= code then									-- is this page main / article space and English not the language?
			table.insert( z.properties_cats, 'CS1 ' .. name .. '-language sources (' .. code .. ')');	-- in main space and not English: categorize
		end
	else
		table.insert (z.maintenance_cats, 'CS1 maint: Unrecognized language');	-- add maintenance category when |language= does not appear to be ISO 639-1 language
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- wrap with '(in ...)'
end




--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------
This is the main function doing the majority of the citation
formatting.
]]
function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple
	aliases to single internal variable.
	]]
	local A = argument_wrapper( args );

	local i 
	local PPrefix = A['PPrefix']
	local PPPrefix = A['PPPrefix']
	if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
	
	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local Authors = A['Authors'];
	local a = extractnames( args, 'AuthorList' );

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];
	local Editors = A['Editors'];
	local e = extractnames( args, 'EditorList' );

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
	local Chapter = A['Chapter'];
	local ChapterLink = A['ChapterLink'];										-- deprecated
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveURL = A['ArchiveURL'];
	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];

	local Series = A['Series'];
	local Volume = A['Volume'];
	local Issue = A['Issue'];
	local Position = '';
	local Page = A['Page'];
	local Pages = hyphentodash( A['Pages'] );	
	local At = A['At'];

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
	local SubscriptionRequired = A['SubscriptionRequired'];
	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local ArchiveDate = A['ArchiveDate'];
	local Agency = A['Agency'];
	local DeadURL = A['DeadURL']
	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local Ref = A['Ref'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
	local Embargo = A['Embargo'];

	local ID_list = extractids( args );

	local Quote = A['Quote'];
	local PostScript = A['PostScript'];

	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL
	local sepc = A['Separator'];

	local LastAuthorAmp = A['LastAuthorAmp'];
	local no_tracking_cats = A['NoTracking'];

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local use_lowercase;								-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();		-- also used for COinS and for language
	local anchor_year;									-- used in the CITEREF identifier
	local COinS_date;									-- used in the COinS metadata

-- Set postscript default.
	if not is_set (PostScript) then						-- if |postscript= has not been set (Postscript is nil which is the default for {{citation}}) and
		if (config.CitationClass ~= &quot;citation&quot;) then	-- this template is not a citation template
			PostScript = '.';							-- must be a cite xxx template so set postscript to default (period)
		end
	else
		if PostScript:lower() == 'none' then			-- if |postscript=none then
			PostScript = '';							-- no postscript
		end
	end

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories.
	if not is_set(no_tracking_cats) then				-- ignore if we are already not going to categorize this page
		if inArray (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;					-- set no_tracking_cats
		end
	end

-- check for extra |page=, |pages= or |at= parameters. 
	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Page = Page .. &quot; &quot; .. seterror('extra_pages');	-- add error message
			Pages = '';										-- unset the others
			At = '';
		end
	elseif is_set(Pages) then
		if is_set(At) then
			Pages = Pages .. &quot; &quot; .. seterror('extra_pages');	-- add error messages
			At = '';											-- unset
		end
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped
	|url maps to |chapterurl when |title is remapped

All other combinations of |encyclopedia, |title, and |article are not modified
]]
	if ( config.CitationClass == &quot;encyclopaedia&quot; ) then
		if is_set(Periodical) then					-- Periodical is set when |encyclopedia is set
			if is_set(Title) then
				if not is_set(Chapter) then
					Chapter = Title;				-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					TransChapter = TransTitle;
					ChapterURL = URL;
					Title = Periodical;
					Periodical = '';				-- redundant so unset
					TransTitle = '';				-- redundant so unset
					URL = '';						-- redundant so unset
				end
			else									-- |title not set
				Title = Periodical;					-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';					-- redundant so unset
			end
		end
	end

--special cases for citation.
	if (config.CitationClass == &quot;citation&quot;) then		-- for citation templates
		if not is_set (Ref) then						-- if |ref= is not set
			Ref = &quot;harv&quot;;								-- set default |ref=harv
		end
		if not is_set (sepc) then						-- if |separator= is not set
			sepc = ',';									-- set citation separator to its default (comma)
		end
	else												-- not a citation template
		if not is_set (sepc) then						-- if |separator= has not been set
			sepc = '.';									-- set cite xxx separator to its default (period)
		end
	end
	use_lowercase = ( sepc ~= '.' );					-- used to control capitalization for certain static text

-- check for special case where |separator=none
	if 'none' == sepc:lower() then						-- if |separator=none
		sepc = '';										-- then set it to an empty string
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then	-- special case for cite techreport
		if is_set(Issue) then						-- cite techreport uses 'number', which other citations aliase to 'issue'
			if not is_set(ID) then					-- can we use ID for the &quot;number&quot;?
				ID = Issue;							-- yes, use it
				Issue = &quot;&quot;;							-- unset Issue so that &quot;number&quot; isn't duplicated in the rendered citation or COinS metadata
			else									-- can't use ID so emit error message
				ID = ID .. &quot; &quot; .. seterror('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Others) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Others;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Others;
			end
		else
			Others = '(Interview)';
		end
	end

--Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set
	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_embargoed(Embargo) then
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];	-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];		-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
--TODO: if this is only for {{cite conference}}, shouldn't we be checking? (if config.CitationClass=='conference' then ...)
	if is_set(BookTitle) then
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = BookTitle;
		TitleLink = '';
		TransTitle = '';
	end

-- Account for the oddity that is {{cite episode}}, before generation of COinS data.
--[[	-- {{cite episode}} is not currently supported by this module
	if config.CitationClass == &quot;episode&quot; then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];
		local Season = A['Season'];
		local SeriesNumber = A['SeriesNumber'];
		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
		local Sep = (first_set(A[&quot;SeriesSeparator&quot;], A[&quot;Separator&quot;]) or &quot;&quot;) .. &quot; &quot;;
		
		if is_set(Issue) then table.insert(s, cfg.messages[&quot;episode&quot;] .. &quot; &quot; .. Issue); Issue = ''; end
		if is_set(Season) then table.insert(s, cfg.messages[&quot;season&quot;] .. &quot; &quot; .. Season); end
		if is_set(SeriesNumber) then table.insert(s, cfg.messages[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber); end
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		
		Date = Date or AirDate;
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = Series;
		TitleLink = SeriesLink;
		TransTitle = '';
		
		Series = table.concat(s, Sep);
		ID = table.concat(n, Sep);
	end
-- end of {{cite episode}} stuff]]

-- legacy: promote concatenation of |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if is_set(Date) then
		if is_set (Year) then
			table.insert( z.maintenance_cats, &quot;CS1 maint: Date and year&quot;);		-- add to maint category
		end
	else
		Date = Year;						-- promote Year to Date
		Year = nil;							-- make nil so Year as empty string isn't used for CITEREF
		if is_set(Date) then
			local Month = A['Month'];
			if is_set(Month) then
				Date = Month .. &quot; &quot; .. Date;
			end
		elseif is_set(PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;			-- promote PublicationDate to Date
			PublicationDate = '';			-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end	-- if PublicationDate is same as Date, don't display in rendered citation


--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	anchor_year, COinS_date, error_message = dates({['accessdate']=AccessDate, ['airdate']=AirDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
		['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});
	if is_set(error_message) then
		table.insert( z.message_tail, { seterror( 'bad_date', {error_message}, true ) } );	-- add this error message
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for
	-- automated parsing of citation information.
	-- this is the function call to COinS()
	local OCinSoutput = COinS{
		['Periodical'] = Periodical,
		['Chapter'] = strip_apostrophe_markup (Chapter),						-- Chapter stripped of bold / italic wikimarkup
		['Title'] = make_coins_title (Title, ScriptTitle),						-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = first_set(COinS_date, Date),		-- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here?  Should we be including invalid dates in metadata?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set(Page, Pages, At)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set( URL, ChapterURL ),
		['Authors'] = a,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	};
--[[Why is this here?  Why are we mapping Title to Chapter when Periodical is set?
	if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = '';
		TitleLink = '';
		TransTitle = '';
	end
]]

-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include som static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = '[[Newsgroup]]:&amp;nbsp;' ..  externallink( 'news:' .. PublisherName, PublisherName );
		end
	end



	-- Now perform various field 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 not is_set(Authors) then
		local Maximum = tonumber( A['DisplayAuthors'] );

		if is_set (Maximum) then
			if Maximum &gt;= #a then												-- if display-authors value greater than or equal to number of authors
				table.insert( z.maintenance_cats, &quot;CS1 maint: display-authors&quot;);	-- add maintenance category because display-authors parameter may be removed
			end
		else
			Maximum = #a + 1;													-- number of authors + 1
		end

		local control = { 
			sep = A[&quot;AuthorSeparator&quot;] .. &quot; &quot;,
			namesep = (first_set(A[&quot;AuthorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
			format = A[&quot;AuthorFormat&quot;],
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text				-- get current page name so that we don't wikilink to it via authorlinkn
		};
		
		-- If the coauthor field is also used, prevent ampersand and et al. formatting.
		if is_set(Coauthors) then
			control.lastauthoramp = nil;
			control.maximum = #a + 1;
		end
		
		Authors = listpeople(control, a) 
	end

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { seterror('coauthors_missing_author', {}, true) } );	-- emit error message
	end

	local EditorCount
	if not is_set(Editors) then
		local Maximum = tonumber( A['DisplayEditors'] );
		-- Preserve old-style implicit et al.
		if not is_set(Maximum) and #e == 4 then 
			Maximum = 3;
			table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
		elseif not is_set(Maximum) then
			Maximum = #e + 1;
		end

		local control = { 
			sep = A[&quot;EditorSeparator&quot;] .. &quot; &quot;,
			namesep = (first_set(A[&quot;EditorNameSeparator&quot;], A[&quot;NameSeparator&quot;]) or &quot;&quot;) .. &quot; &quot;,
			format = A['EditorFormat'],
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text				-- get current page name so that we don't wikilink to it via editorlinkn
		};

		Editors, EditorCount = listpeople(control, e);
	else
		EditorCount = 1;
	end

	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	if config.CitationClass == &quot;map&quot; then
		if not is_set( Authors ) and is_set( PublisherName ) then
			Authors = PublisherName;
			PublisherName = &quot;&quot;;
		end
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end		
	end
	
	Format = is_set(Format) and &quot; (&quot; .. Format .. &quot;)&quot; or &quot;&quot;;

	if  not is_set(URL) and
		not is_set(ArchiveURL) and
		not is_set(ConferenceURL) and
		not is_set(TranscriptURL) then
		
		-- Test if cite web or cite podcast |url= is missing or empty 
		if inArray(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;}) then	
			table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
		end
		
		-- Test if accessdate is given without giving a URL
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when the others are not set; TODO: move this to a separate test?
			table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
		
		-- Test if format is given without giving a URL
		if is_set(Format) then
			Format = Format .. seterror( 'format_missing_url', {'format', 'url'} );
		end
	end

	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(Periodical) and
		not is_set(Conference) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
		table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
	end
	

	local OriginalURL;
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
			end
		elseif is_set (ChapterURL) then 										-- URL not set so if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
			end
		end
	end

	if inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;journal&quot;,&quot;pressrelease&quot;,&quot;conference&quot;,&quot;podcast&quot;, &quot;newsgroup&quot;}) or ('citation' == config.CitationClass and is_set (Periodical)) then
		if is_set (Chapter) or is_set (TransChapter) or is_set (ChapterURL)then	-- chapter parameters not supported for these citation types
			table.insert( z.message_tail, { seterror( 'chapter_ignored', {}, true ) } );		-- add error message
			Chapter = '';														-- set to empty string to be safe with concatenation
			TransChapter = '';
			ChapterURL = '';
		end
	else																		-- otherwise, format chapter / article title
		Chapter = format_chapter_title (Chapter, TransChapter, ChapterURL, ChapterURLorigin);
		if is_set (Chapter) then
			ChapterFormat = is_set(ChapterFormat) and &quot; (&quot; .. ChapterFormat .. &quot;)&quot; or &quot;&quot;;
			if is_set(ChapterFormat) and not is_set (ChapterURL) then			-- Test if |chapter-format= is given without giving a |chapter-url=
				ChapterFormat = ChapterFormat .. seterror( 'format_missing_url', {'chapter-format', 'chapter-url'} );
			end
			Chapter = Chapter .. ChapterFormat .. sepc .. ' ';
		end
	end

	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;journal&quot;,&quot;pressrelease&quot;,&quot;conference&quot;,&quot;podcast&quot;, &quot;newsgroup&quot;}) or ('citation' == config.CitationClass and is_set (Periodical)) then
		Title = kern_quotes (Title);											-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
		Title = wrap_style ('quoted-title', Title);

		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then 
			Title = externallink( URL, Title ) .. TransError .. Format	   
			URL = &quot;&quot;;
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end
	
	if is_set(Conference) then
		if is_set(ConferenceURL) then
			Conference = externallink( ConferenceURL, Conference );
		end
		Conference = sepc .. &quot; &quot; .. Conference
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. externallink( ConferenceURL, nil, ConferenceURLorigin );
	end
	
	if not is_set(Position) then
		local Minutes = A['Minutes'];
		if is_set(Minutes) then
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			local Time = A['Time'];
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end
	
	if not is_set(Page) then
		if is_set(Pages) then
			if is_set(Periodical) and
				not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
				Pages = &quot;: &quot; .. Pages;
			elseif tonumber(Pages) ~= nil then
				Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
			else
				Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
			end
		end
	else
		if is_set(Periodical) and
			not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
			Page = &quot;: &quot; .. Page;
		else
			Page = sepc ..&quot; &quot; .. PPrefix .. Page;
		end
	end
	
	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Inset = A['Inset'];
		if first_set( Pages, Page, At ) ~= nil or sepc ~= '.' then
			if is_set( Section ) then
				Section = &quot;, &quot; .. wrap_msg ('section', Section, true);
			end
			if is_set( Inset ) then
				Inset = &quot;, &quot; .. wrap_msg ('inset', Inset, true);
			end
		else
			if is_set( Section ) then
				Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
				if is_set( Inset ) then
					Inset = &quot;, &quot; .. wrap_msg ('inset', Inset, true);
				end
			elseif is_set( Inset ) then
				Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
			end			
		end			
		At = At .. Section .. Inset;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language, this_page.namespace);			-- format, categories (article namespace only), name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;

-- handle type parameter for those CS1 citations that have default values

	if inArray(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then	-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then					-- if type parameter is specified
		TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot;;	-- display it in parentheses
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	Edition = is_set(Edition) and (&quot; &quot; .. wrap_msg ('edition', Edition)) or &quot;&quot;;
	Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc ..&quot; &quot; .. Volume;
		  else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
		end
	end

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

--[[
Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
note is displayed. There are no error messages for this condition.

]]
	if is_set(SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif is_set(RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if 'citation', lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text
																				-- neither of these work; don't know why; it seems that substitute() isn't being called	
		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end

	ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo} );

	if is_set(URL) then
		URL = &quot; &quot; .. externallink( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
			Quote = Quote:sub(2,-2);
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- CS1 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = seterror('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ externallink( ArchiveURL, arch_text ), ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text,
				{ externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ seterror('archive_missing_url'), ArchiveDate } );
		end
	else
		Archived = &quot;&quot;
	end
	
	local Lay
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
		end			
	else
		Lay = &quot;&quot;;
	end
	
	if is_set(Transcript) then
		if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
	elseif is_set(TranscriptURL) then
		Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
	end
	
	local Publisher;
	if is_set(Periodical) and
		not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap_msg ('published', PublicationDate);
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap_msg ('published', PublicationDate) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon
	if inArray(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, 
			Language, Cartography, Edition, Publisher, Agency, Volume, Issue}, sepc );
	else 
		tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, Language, 
			Volume, Issue, Others, Cartography, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Page .. Pages .. At;
	
	if is_set(Authors) then
		if is_set(Coauthors) then
			Authors = Authors .. A['AuthorSeparator'] .. &quot; &quot; .. Coauthors
		end
		if is_set(Date) then
			Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		elseif string.sub(Authors,-1,-1) == sepc then
			Authors = Authors .. &quot; &quot;
		else
			Authors = Authors .. sepc .. &quot; &quot;
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			if (sepc ~= '.') then in_text = in_text:lower() end
			Editors = in_text .. Editors .. post_text;
			if (string.sub(Editors,-1,-1) == sepc)
				then Editors = Editors .. &quot; &quot;
				else Editors = Editors .. sepc .. &quot; &quot;
			end
		end
		text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
		text = safejoin( {text, pgtext, idcommon}, sepc );
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
		text = safejoin( {text, pgtext, idcommon}, sepc );
	else
		if is_set(Date) then
			if ( string.sub(tcommon,-1,-1) ~= sepc )
			  then Date = sepc ..&quot; &quot; .. Date .. OrigYear
			  else Date = &quot; &quot; .. Date .. OrigYear
			end
		end
		if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
			text = safejoin( {Chapter, Place, tcommon}, sepc );
			text = safejoin( {text, pgtext, Date, idcommon}, sepc );
		else
			text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
			text = safejoin( {text, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
--		text = text:sub(1,-2);	--Remove final separator (assumes that sepc is only one character)
	end	
	
	text = safejoin( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;span/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = &quot;citation &quot; .. config.CitationClass;
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
		local id = Ref
		if ( &quot;harv&quot; == Ref ) then
			local names = {} --table of last names &amp; year
			if #a &gt; 0 then
				for i,v in ipairs(a) do 
					names[i] = v.last 
					if i == 4 then break end
				end
			elseif #e &gt; 0 then
				for i,v in ipairs(e) do 
					names[i] = v.last 
					if i == 4 then break end				
				end
			end
			names[ #names + 1 ] = first_set(Year, anchor_year);	-- Year first for legacy citations
			id = anchorid(names)
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = seterror('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then 
		text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	else
		text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	end		

	local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
	
	-- Note: Using display: none on then COinS span breaks some clients.
	local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
	text = text .. OCinS;
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. errorcomment( v[1], v[2] );
				else
					text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if inArray(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
	local pframe = frame:getParent()
	
	if nil ~= string.find( frame:getTitle(), 'sandbox', 1, true ) then				-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData( 'Module:Citation/CS1/Configuration/sandbox' );	-- load sandbox versions of Configuration and Whitelist and ...
		whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist/sandbox' );
		dates = require('Module:Citation/CS1/Date_validation/sandbox').dates	-- ... sandbox version of date validation code
	else																	-- otherwise
		cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );			-- load live versions of Configuration and Whitelist and ...
		whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );
		dates = require('Module:Citation/CS1/Date_validation').dates		-- ... live version of date validation code
	end
	
	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = seterror( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if #suggestions == 0 then
						suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
					end
					if suggestions[ k:lower() ] ~= nil then
						error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
					else
						error_text, error_state = seterror( 'parameter_ignored', {k}, true );
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	
	
	return citation0( config, args)
end

return z</text>
      <sha1>j2r1r6o8c9sb4wi0zbep5vnp6pvzd4y</sha1>
    </revision>
    <revision>
      <id>4687</id>
      <parentid>4686</parentid>
      <timestamp>2015-02-14T13:05:20Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4687</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="109350" sha1="htf4zur3yobbvbz7du82q0v9lwgjsxm" xml:space="preserve">
local z = {
	error_categories = {};		-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};		-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};		-- for categorizing citations based on certain properties, language of source for instance
}

-- Whether variable is set or not
function is_set( var )
	return not (var == nil or var == '');
end

-- First set variable or nil if none
function first_set(...)
	local list = {...};
	for _, var in pairs(list) do
		if is_set( var ) then
			return var;
		end
	end
end

-- Whether needle is in haystack
function inArray( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end

--[[
Categorize and emit an error message when the citation contains one or more deprecated parameters.  Because deprecated parameters (currently |month=,
|coauthor=, and |coauthors=) aren't related to each other and because these parameters may be concatenated into the variables used by |date= and |author#= (and aliases)
details of which parameter caused the error message are not provided.  Only one error message is emitted regardless of the number of deprecated parameters in the citation.
]]
function deprecated_parameter(name)
	if true ~= Page_in_deprecated_cat then	-- if we haven't been here before then set a 
		Page_in_deprecated_cat=true;		-- sticky flag so that if there are more than one deprecated parameter the category is added only once
		table.insert( z.message_tail, { seterror( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end

-- Populates numbered arguments in a message string using an argument table.
function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[--------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Call this function for chapter titles, for website titles, etc; not for book titles.

]]

function kern_quotes (str)
	local cap='';
	local cap2='';
	
	cap, cap2 = str:match (&quot;^([\&quot;\'])([^\'].+)&quot;);								-- match leading double or single quote but not double single quotes
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-left'], {cap, cap2});
	end

	cap, cap2 = str:match (&quot;^(.+[^\'])([\&quot;\'])$&quot;)
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-right'], {cap, cap2});
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

At this writing, only |script-title= is supported.  It is anticipated that additional parameters will be created to use this function.

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if inArray (lang, {'ar', 'bs', 'dv', 'el', 'fa', 'hy', 'ja', 'ko', 'ku', 'he', 'ps', 'ru', 'sd', 'sr', 'th', 'uk', 'ug', 'yi', 'zh'}) then
				table.insert( z.properties_cats, 'CS1 uses ' .. name .. '-language script ('..lang..')');	-- categorize in language-specific categories
			else
				table.insert( z.properties_cats, 'CS1 uses foreign language script');	-- use this category as a catchall until language-specific category is available
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

function wrap_style (key, str)
	if not is_set( str ) then
		return &quot;&quot;;
	elseif inArray( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safeforitalics( str );
	end

	return substitute( cfg.presentation[key], {str} );
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		str = substitute( msg, {str} );											-- including template text
		return str;
	else
		return substitute( cfg.messages[key], {str} );
	end		
end

--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the three chapter parameters: |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

function format_chapter_title (chapter, transchapter, chapterurl, chapter_url_source)
	local chapter_error = '';
	
	if not is_set (chapter) then
		chapter = '';															-- just to be safe for concatenation
		if is_set (transchapter) then
			chapter = wrap_style ('trans-quoted-title', transchapter);
			chapter_error = &quot; &quot; .. seterror ('trans_missing_chapter');
		end
		if is_set (chapterurl) then
			chapter = externallink (chapterurl, chapter, chapter_url_source);	-- adds bare_url_missing_title error if appropriate
		end
		return chapter .. chapter_error;
	else																		-- here when chapter is set
		chapter = kern_quotes (chapter);										-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
		chapter = wrap_style ('quoted-title', chapter);
		if is_set (transchapter) then
			transchapter = wrap_style ('trans-quoted-title', transchapter);
			chapter = chapter .. ' ' .. transchapter;
		end
		if is_set (chapterurl) then
			chapter = externallink (chapterurl, chapter);						-- adds bare_url_missing_title error if appropriate
		end
	end
	return chapter;
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = selectone( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
]]
function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end

--[[--------------------------&lt; E R R O R C O M M E N T &gt;------------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]
function errorcomment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end

--[[
Sets an error condition and returns the appropriate error message.  The actual placement
of the error message in the output is the responsibility of the calling function.
]]
function seterror( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if inArray( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return errorcomment( message, error_state.hidden );
end

-- Formats a wiki style external link
function externallinkid(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

-- Formats a wiki style internal link
function internallinkid(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

-- Format an external link with error checking
function externallink( URL, label, source )
	local error_str = &quot;&quot;;
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = seterror( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not checkurl( URL ) then
		error_str = seterror( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
	end
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safeforurl( label ), &quot;]&quot;, error_str });
end

--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;%a+%s*%d%d?,%s*%d%d%d%d&quot;) or date:match (&quot;%d%d?%s*%a+%s*%d%d%d%d&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end

--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. seterror ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if checkisbn( id ) then												-- see if asin value is isbn10
				table.insert( z.maintenance_cats, &quot;CS1 maint: ASIN uses ISBN&quot;);	-- add to maint category
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. seterror ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. seterror ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif inArray (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif inArray (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return externallinkid({link = handler.link,
		label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
		encode=handler.encode, separator = handler.separator}) .. err_cat;
end

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

function arxiv (id)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = &quot;&quot;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. seterror( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. seterror( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. seterror( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. seterror( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[
lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--[[
Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of the LCCN dictates the character type of the first 1-3 characters; the
rightmost eight are always digits. http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]
function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. seterror( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. seterror( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. seterror( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]
function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmid' );	-- set an error message
		end
	end
	
	return externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns true; otherwise, returns false because the embargo has expired or |embargo= not set in this cite.
]]
function is_embargoed(embargo)
	if is_set(embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 and tonumber( embargo_date ) &gt;= tonumber( todays_date ) then	--is embargo date is in the future?
			return true;	-- still embargoed
		end
	end
	return false;			-- embargo expired or |embargo= not set
end

--[[
Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future
the PMC identifier will not be linked to the article.  If the embargo specifies a date in the past, or if it is empty or omitted, then
the PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.
]]
function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. seterror( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. seterror( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_embargoed(embargo) then
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	--still embargoed so no external link
	else
		text = externallinkid({link = handler.link, label = handler.label,			--no embargo date, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.

-- DOI names contain two parts: prefix and suffix separated by a forward slash.
--  Prefix: directory indicator '10.' followed by a registrant code
--  Suffix: character string of any length chosen by the registrant

-- This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes,
-- or, if it ends with a period or a comma, this function will emit a bad_doi error message.

-- DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
-- and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely if ever used in doi names.

function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = externallinkid({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. seterror( 'bad_doi' );
	end
	return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);					-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return externallinkid({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	else
		return externallinkid({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode}) .. 
			' ' .. seterror( 'bad_ol' );
	end
end

--[[
Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.
]]
function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = externallinkid({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. seterror( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	text = externallinkid({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. seterror( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end



--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those citations that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]
function set_titletype(cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;					-- if |type=none then type parameter not displayed
		end
		return title_type;						-- if |type= has been set to any other value use that value
	end

	if &quot;AV-media-notes&quot; == cite_class or &quot;DVD-notes&quot; == cite_class then		-- if this citation is cite AV media notes or cite DVD notes
		return &quot;Media notes&quot;;					-- display AV media notes / DVD media notes annotation

	elseif &quot;mailinglist&quot; == cite_class then		-- if this citation is cite mailing list
		return &quot;Mailing list&quot;;					-- display mailing list annotation

	elseif &quot;podcast&quot; == cite_class then			-- if this citation is cite podcast
		return &quot;Podcast&quot;;						-- display podcast annotation

	elseif &quot;pressrelease&quot; == cite_class then	-- if this citation is cite press release
		return &quot;Press release&quot;;					-- display press release annotation

	elseif &quot;report&quot; == cite_class then			-- if this citation is cite report
		return &quot;Report&quot;;						-- display report annotation
	
	elseif &quot;techreport&quot; == cite_class then		-- if this citation is cite techreport
		return &quot;Technical report&quot;;				-- display techreport annotation
	
	elseif &quot;thesis&quot; == cite_class then			-- if this citation is cite thesis (degree option handled after this function returns)
			return &quot;Thesis&quot;;					-- display simple thesis annotation (without |degree= modification)
	end
end

--[[
Determines whether a URL string is valid

At present the only check is whether the string appears to 
be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well 
formed.
]]
function checkurl( url_str )
	-- Protocol-relative or URL scheme
	return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
function cleanisbn( isbn_str )
	return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]
function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other lua magic pattern characters
	return argument;
end

--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]
function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	while true do
		if argument:match (&quot;%'%'%'%'%'&quot;) then									-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:match (&quot;%'%'%'%'&quot;) then									-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:match (&quot;%'%'%'&quot;) then									-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:match (&quot;%'%'&quot;) then										-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end

--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...
]]

function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end

--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]
function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end

--[[
ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in checkisbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.
]]
function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of bytes
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end

-- Determines whether an ISBN string is valid
function checkisbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end	-- isbn13 begins with 978 or 979
		isbn_str = { isbn_str:byte(1, len) };
		for i, v in ipairs( isbn_str ) do
			temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
		end
		return temp % 10 == 0;
	end
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
function removewikilink( str )
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end

-- Escape sequences for content that will be used for URL descriptions
function safeforurl( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { seterror( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

-- Converts a hyphen to a dash
function hyphentodash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end

-- Protects a string that will be wrapped in wiki italic markup '' ... ''
function safeforitalics( str )
	--[[ Note: We cannot use &lt;i&gt; for italics, as the expected behavior for
	italics specified by ''...'' in the title is that they will be inverted
	(i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and ''
	tend to interact poorly under Mediawiki's HTML tidy. ]]
	
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end

--[[--------------------------&lt; S A F E J O I N &gt;--------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]
function safejoin( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if comp:sub(1,1) == duplicate_char then								-- is first charactier same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for th
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = str:sub(-1,-1);										-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = str:sub(1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = str:sub(1, -4) .. &quot;''&quot;;							-- remove them and add back ''
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then		-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then		-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then			-- if last two chars of str are sepc] external link
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;'']&quot; then		-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then				-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = str:sub(1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end		-- if duplicate_char not a letter then escape it
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )			-- remove duplicate_char if it follows html markup
					else
						value = value:sub( 2, -1 );								-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end  

-- Attempts to convert names to initials.
function reducetoinitials(first)
	local initials = {}
	local i = 0;										-- counter for number of initials
	for word in string.gmatch(first, &quot;%S+&quot;) do
		table.insert(initials, string.sub(word,1,1))	-- Vancouver format does not include full stops.
		i = i + 1;										-- bump the counter 
		if 2 &lt;= i then break; end						-- only two initials allowed in Vancouver system; if 2, quit
	end
	return table.concat(initials)						-- Vancouver format does not include spaces.
end

-- Formats a list of people (e.g. authors / editors) 
function listpeople(control, people)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}
	local etal = false;
	
	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = ',';																-- name-list separator between authors is a comma
		namesep = ' ';															-- last/first separator is a space
	else
		sep = ';'																-- name-list separator between authors is a semicolon
		namesep = ', '															-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if maximum ~= nil and maximum &lt; 1 then return &quot;&quot;, 0; end
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if maximum ~= nil and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then first = reducetoinitials(first) end
					one = one .. namesep .. first 
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;		-- link author/editor if this page is not the author's/editor's page
				end

				if is_set(person.link) and ((nil ~= person.link:find(&quot;//&quot;)) or (nil ~= person.link:find(&quot;[%[%]]&quot;))) then
					one = one .. &quot; &quot; .. seterror( 'bad_authorlink' ) end	-- url or wikilink in author link;
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;
		end
		text[#text] = nil; 
	end
	
	local result = table.concat(text) -- construct list
	if etal then 
		local etal_text = cfg.messages['et al'];
		result = result .. &quot; &quot; .. etal_text;
	end
	
	return result, count
end

--[[--------------------------&lt; A N C H O R I D &gt;--------------------------------------------------------------
Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

]]

function anchorid( options )
	local id = table.concat( options );											-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end

--[[
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.
]]
function extractnames(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	
	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary

	while true do
		last = selectone( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = selectone( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = selectone( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = selectone( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { seterror( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 == count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			names[n] = {last = last, first = first, link = link, mask = mask};	-- add this name to our names list
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { seterror( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	return names;																-- all done, return our list of names
end

-- Populates ID table from arguments using configuration settings
function extractids( args )
	local id_list = {};
	for k, v in pairs( cfg.id_handlers ) do	
		v = selectone( args, v.parameters, 'redundant_parameters' );
		if is_set(v) then id_list[k] = v; end
	end
	return id_list;
end

--[[--------------------------&lt; B U I L D I D L I S T &gt;--------------------------------------------------------
Takes a table of IDs and turns it into a table of formatted ID outputs.

]]
function buildidlist( id_list, options )
	local new_list, handler = {};

	function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, externallinkid( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internallinkid( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internallinkid( handler );
			if not checkisbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. seterror( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end
  
-- Chooses one matching parameter from a list of parameters to consider
-- Generates an error if more than one match is present.
function selectone( args, possible, error_condition, index )
	local value = nil;
	local selected = '';
	local error_list = {};
	
	if index ~= nil then index = tostring(index); end
	
	-- Handle special case of &quot;#&quot; replaced by empty string
	if index == '1' then
		for _, v in ipairs( possible ) do
			v = v:gsub( &quot;#&quot;, &quot;&quot; );
			if is_set(args[v]) then
				if value ~= nil and selected ~= v then
					table.insert( error_list, v );
				else
					value = args[v];
					selected = v;
				end
			end
		end		
	end
	
	for _, v in ipairs( possible ) do
		if index ~= nil then
			v = v:gsub( &quot;#&quot;, index );
		end
		if is_set(args[v]) then
			if value ~= nil and selected ~=  v then
				table.insert( error_list, v );
			else
				value = args[v];
				selected = v;
			end
		end
	end
	
	if #error_list &gt; 0 then
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap_style ('parameter', k);
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap_style ('parameter', selected);
		table.insert( z.message_tail, { seterror( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
function COinS(data)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end
	
	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( removewikilink( value ) ) } );
			end
		end
	});
	
	if is_set(data.Chapter) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
	elseif is_set(data.Periodical) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
		OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	else
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
	end
	
	OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
	OCinSoutput[&quot;rft.date&quot;] = data.Date;
	OCinSoutput[&quot;rft.series&quot;] = data.Series;
	OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
	OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
	OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
	OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
	OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
	
	for k, v in pairs( data.ID_list ) do
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = cleanisbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
	
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = v.last, v.first;
		if k == 1 then
			if is_set(last) then
				OCinSoutput[&quot;rft.aulast&quot;] = last;
			end
			if is_set(first) then 
				OCinSoutput[&quot;rft.aufirst&quot;] = first;
			end
		end
		if is_set(last) and is_set(first) then
			OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
		elseif is_set(last) then
			OCinSoutput[&quot;rft.au&quot;] = last;
		end
	end
	
	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 code.  Handles the special case that is Norwegian where
ISO639-1 code 'no' is mapped to language name 'Norwegian Bokmål' by Extention:CLDR.

Returns the language name and associated ISO639-1 code.  Because case of the source may be incorrect or different from the case that Wikimedia
uses, the name comparisons are done in lower case and when a match is found, the Wikimedia version (assumed to be correct) is returned along
with the code.  When there is no match, we return the original language name string.

mw.language.fetchLanguageNames() will return a list of languages that aren't part of ISO639-1. Names that aren't ISO639-1 but that are included
in the list will be found if that name is provided in the |language= parameter.  For example, if |language=Samaritan Aramaic, that name will be
found with the associated code 'sam', not an ISO639-1 code.  When names are found and the associated code is not two characters, this function
returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.
]]

function get_iso639_code (lang)
	if 'norwegian' == lang:lower() then											-- special case related to Wikimedia remap of code 'no' at Extension:CLDR
		return 'Norwegian', 'no';												-- Make sure rendered version is properly capitalized
	end
	
	local languages = mw.language.fetchLanguageNames('en', 'all')				-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() then												-- ISO639-1 codes only
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the ISO639-1 code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for ISO639-1 code
end

--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Get language name from ISO639-1 code value provided.  If a code is valid use the returned name; if not, then use the value that was provided with the language parameter.

There is an exception.  There are three ISO639-1 codes for Norewegian language variants.  There are two official variants: Norwegian Bokmål (code 'nb') and
Norwegian Nynorsk (code 'nn').  The third, code 'no',  is defined by ISO639-1 as 'Norwegian' though in Norway this is pretty much meaningless.  However, it appears
that on enwiki, editors are for the most part unaware of the nb and nn variants (compare page counts for these variants at Category:Articles with non-English-language external links.

Because Norwegian Bokmål is the most common language variant, Media wiki has been modified to return Norwegian Bokmål for ISO639-1 code 'no'. Here we undo that and
return 'Norwegian' when editors use |language=no.  We presume that editors don't know about the variants or can't descriminate between them.

See Help talk:Citation Style_1#An ISO 639-1 language name test

When |language= contains a valid ISO639-1 code, the page is assigned to the category for that code: Category:Norwegian-language sources (no) if
the page is a mainspace page and the ISO639-1 code is not 'en'.  Similarly, if the  parameter is |language=Norwegian, it will be categorized in the same way.

]]

function language_parameter (lang, namespace)
	local code;			-- the ISO639-1 two character code
	local name;			-- the language name
	local test='';
		
	if 0 == namespace and (('en' == lang:lower()) or ('english' == lang:lower())) then
		table.insert (z.maintenance_cats, 'CS1 maint: English language specified');		-- add maintenance category if |language=English or |language=en in article space
	end

	if 2 == lang:len() then														-- ISO639-1 language code are 2 characters (fetchLanguageName also supports 3 character codes)
		name = mw.language.fetchLanguageName( lang:lower(), &quot;en&quot; );				-- get ISO 639-1 language name if Language is a proper code
	end

	if is_set (name) then														-- if Language specified a valid ISO639-1 code
		code = lang:lower();													-- save it
	else
		name, code = get_iso639_code (lang);									-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
	end

	if is_set (code) then
		if 'no' == code then name = 'Norwegian' end;							-- override wikimedia when code is 'no'
		if 0 == namespace and 'en' ~= code then									-- is this page main / article space and English not the language?
			table.insert( z.properties_cats, 'CS1 ' .. name .. '-language sources (' .. code .. ')');	-- in main space and not English: categorize
		end
	else
		table.insert (z.maintenance_cats, 'CS1 maint: Unrecognized language');	-- add maintenance category when |language= does not appear to be ISO 639-1 language
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- wrap with '(in ...)'
end

--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------
When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

function get_settings_from_cite_class (ps, ref, cite_class)
local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep = ',';																-- set citation separator to its default (comma)
		if not is_set (ps) then													-- if |postscript= has not been set, set cs2 default
			ps = '';															-- make sure it isn't nil
		end
		if not is_set (ref) then												-- if |ref= is not set
			ref = &quot;harv&quot;;														-- set default |ref=harv
		end
	else																		-- not a citation template so CS1
		sep = '.';																-- set cite xxx separator to its default (period)
		if not is_set (ps) then													-- if |postscript= has not been set
			ps = '.';															-- set cs1 default
		end
	end

	return sep, ps, ref															-- return them all
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

function set_style (mode, ps, ref, cite_class)
local sep;
	if is_set (mode) then
		if 'cs2' == mode then											-- if this template is to be rendered in CS2 (citation) style
			sep = ',';															-- separate elements with a comma
			if not is_set (ps) then												-- unless explicitely set to something
				ps = '';														-- make sure it isn't nil
			end
			if not is_set (ref) then											-- unless explicitely set to something
				ref = 'harv';													-- set so this template renders with CITEREF anchor id
			end
		elseif 'cs1' == mode then										-- if this template is to be rendered in CS1 (cite xxx) style
			sep = '.';															-- separate elements with a period
			if not is_set (ps) then												-- unless explicitely set to something
				ps = '.';														-- terminate the rendered citation with a period
			end
		else																	-- anything but cs1 or cs2
			table.insert( z.message_tail, { seterror( 'invalid_param_val', {'mode', mode}, true ) } );		-- add error message
			sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);	-- get settings based on the template's CitationClass
		end
	else													-- when |mode= empty or omitted
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------
This is the main function doing the majority of the citation
formatting.
]]
function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple
	aliases to single internal variable.
	]]
	local A = argument_wrapper( args );

	local i 
	local PPrefix = A['PPrefix']
	local PPPrefix = A['PPPrefix']
	if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
	
	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local Authors = A['Authors'];
	local a = extractnames( args, 'AuthorList' );

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];
	local Editors = A['Editors'];
	local e = extractnames( args, 'EditorList' );

	local NameListFormat = A['NameListFormat'];									-- replaces |author-format= and |editor-format=
	if is_set (NameListFormat) and ('vanc' ~= NameListFormat) then											-- only accepted value for this parameter is 'vanc'
		table.insert( z.message_tail, { seterror( 'invalid_param_val', {'name-list-format', NameListFormat}, true ) } );	-- not vanc so add error message
		NameListFormat = '';													-- set to empty string
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
	local Chapter = A['Chapter'];
	local ChapterLink = A['ChapterLink'];										-- deprecated
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveURL = A['ArchiveURL'];
	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];

	local Series = A['Series'];
	local Volume = A['Volume'];
	local Issue = A['Issue'];
	local Position = '';
	local Page = A['Page'];
	local Pages = hyphentodash( A['Pages'] );	
	local At = A['At'];

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
	local SubscriptionRequired = A['SubscriptionRequired'];
	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local ArchiveDate = A['ArchiveDate'];
	local Agency = A['Agency'];
	local DeadURL = A['DeadURL']
	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
	local Embargo = A['Embargo'];

	local ID_list = extractids( args );

	local Quote = A['Quote'];

	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
	local no_tracking_cats = A['NoTracking'];

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local use_lowercase;								-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();		-- also used for COinS and for language
	local anchor_year;									-- used in the CITEREF identifier
	local COinS_date;									-- used in the COinS metadata

-- set default parameter values defined by |mode= parameter.  If |mode= is empty or omitted, use CitationClass to set these values
	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (A['Mode']:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories.
	if not is_set(no_tracking_cats) then				-- ignore if we are already not going to categorize this page
		if inArray (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;					-- set no_tracking_cats
		end
	end

-- check for extra |page=, |pages= or |at= parameters. 
	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Page = Page .. &quot; &quot; .. seterror('extra_pages');	-- add error message
			Pages = '';										-- unset the others
			At = '';
		end
	elseif is_set(Pages) then
		if is_set(At) then
			Pages = Pages .. &quot; &quot; .. seterror('extra_pages');	-- add error messages
			At = '';											-- unset
		end
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped
	|url maps to |chapterurl when |title is remapped

All other combinations of |encyclopedia, |title, and |article are not modified
TODO: script-title to script-chapter if and when we support script-chapter
]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then					-- Periodical is set when |encyclopedia is set
			if is_set(Title) then
				if not is_set(Chapter) then
					Chapter = Title;				-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					TransChapter = TransTitle;
					ChapterURL = URL;
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';				-- redundant so unset
					TransTitle = '';				-- redundant so unset
					URL = '';						-- redundant so unset
					Format = '';					-- redundant so unset
				end
			else									-- |title not set
				Title = Periodical;					-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';					-- redundant so unset
			end
		end
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then	-- special case for cite techreport
		if is_set(Issue) then						-- cite techreport uses 'number', which other citations aliase to 'issue'
			if not is_set(ID) then					-- can we use ID for the &quot;number&quot;?
				ID = Issue;							-- yes, use it
				Issue = &quot;&quot;;							-- unset Issue so that &quot;number&quot; isn't duplicated in the rendered citation or COinS metadata
			else									-- can't use ID so emit error message
				ID = ID .. &quot; &quot; .. seterror('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Others) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Others;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Others;
			end
		else
			Others = '(Interview)';
		end
	end

-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	end

--Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set
	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_embargoed(Embargo) then
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];	-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];		-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	else
		Conference = '';														-- not cite conference so make sure this is empty string
	end

-- Account for the oddity that is {{cite episode}}, before generation of COinS data.
--[[	-- {{cite episode}} is not currently supported by this module
	if config.CitationClass == &quot;episode&quot; then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];
		local Season = A['Season'];
		local SeriesNumber = A['SeriesNumber'];
		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
		local Sep = (first_set(A[&quot;SeriesSeparator&quot;], A[&quot;Separator&quot;]) or &quot;&quot;) .. &quot; &quot;;
		
		if is_set(Issue) then table.insert(s, cfg.messages[&quot;episode&quot;] .. &quot; &quot; .. Issue); Issue = ''; end
		if is_set(Season) then table.insert(s, cfg.messages[&quot;season&quot;] .. &quot; &quot; .. Season); end
		if is_set(SeriesNumber) then table.insert(s, cfg.messages[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber); end
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		
		Date = Date or AirDate;
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = Series;
		TitleLink = SeriesLink;
		TransTitle = '';
		
		Series = table.concat(s, Sep);
		ID = table.concat(n, Sep);
	end
-- end of {{cite episode}} stuff]]

-- legacy: promote concatenation of |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if is_set(Date) then
		if is_set (Year) then
			table.insert( z.maintenance_cats, &quot;CS1 maint: Date and year&quot;);		-- add to maint category
		end
	else
		Date = Year;						-- promote Year to Date
		Year = nil;							-- make nil so Year as empty string isn't used for CITEREF
		if is_set(Date) then
			local Month = A['Month'];
			if is_set(Month) then
				Date = Month .. &quot; &quot; .. Date;
			end
		elseif is_set(PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;			-- promote PublicationDate to Date
			PublicationDate = '';			-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end	-- if PublicationDate is same as Date, don't display in rendered citation


--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	anchor_year, COinS_date, error_message = dates({['accessdate']=AccessDate, ['airdate']=AirDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
		['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});
	if is_set(error_message) then
		table.insert( z.message_tail, { seterror( 'bad_date', {error_message}, true ) } );	-- add this error message
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
--		not is_set(Periodical) and			-- not a title
--		not is_set(Conference) and			-- not a title
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
		table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
	end
	
	if 'none' == Title and is_set(Periodical) and not (( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia))) then								-- special case
		Title = '';																-- set title to empty string
		table.insert( z.maintenance_cats, &quot;CS1 maint: Untitled periodical&quot;);	-- add to maint category
	end

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	
	-- this is the function call to COinS()
	local OCinSoutput = COinS{
		['Periodical'] = Periodical,
		['Chapter'] = strip_apostrophe_markup (coins_chapter),					-- Chapter stripped of bold / italic wikimarkup
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = first_set(COinS_date, Date),		-- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here?  Should we be including invalid dates in metadata?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set(Page, Pages, At)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set( URL, ChapterURL ),
		['Authors'] = a,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	};
--[[Why is this here?  Why are we mapping Title to Chapter when Periodical is set?
	if is_set(Periodical) and not is_set(Chapter) and is_set(Title) then
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = '';
		TitleLink = '';
		TransTitle = '';
	end
]]

-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = '[[Newsgroup]]:&amp;nbsp;' ..  externallink( 'news:' .. PublisherName, PublisherName );
		end
	end



	-- Now perform various field 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 not is_set(Authors) then
		local Maximum = tonumber( A['DisplayAuthors'] );

		if is_set (Maximum) then
			if Maximum &gt;= #a then												-- if display-authors value greater than or equal to number of authors
				table.insert( z.maintenance_cats, &quot;CS1 maint: display-authors&quot;);	-- add maintenance category because display-authors parameter may be removed
			end
		else
			Maximum = #a + 1;													-- number of authors + 1
		end

		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text				-- get current page name so that we don't wikilink to it via authorlinkn
		};
		
		-- If the coauthor field is also used, prevent ampersand and et al. formatting.
		if is_set(Coauthors) then
			control.lastauthoramp = nil;
			control.maximum = #a + 1;
		end
		
		Authors = listpeople(control, a) 
	end

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { seterror('coauthors_missing_author', {}, true) } );	-- emit error message
	end

	local EditorCount
	if not is_set(Editors) then
		local Maximum = tonumber( A['DisplayEditors'] );
		-- Preserve old-style implicit et al.
		if not is_set(Maximum) and #e == 4 then 
			Maximum = 3;
			table.insert( z.message_tail, { seterror('implict_etal_editor', {}, true) } );
		elseif not is_set(Maximum) then
			Maximum = #e + 1;
		end

		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text				-- get current page name so that we don't wikilink to it via editorlinkn
		};

		Editors, EditorCount = listpeople(control, e);
	else
		EditorCount = 1;
	end

	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	if config.CitationClass == &quot;map&quot; then
		if not is_set( Authors ) and is_set( PublisherName ) then
			Authors = PublisherName;
			PublisherName = &quot;&quot;;
		end
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end		
	end
	
	Format = is_set(Format) and &quot; (&quot; .. Format .. &quot;)&quot; or &quot;&quot;;

	if  not is_set(URL) and
		not is_set(ArchiveURL) and
		not is_set(ConferenceURL) and											-- TODO: keep this here? conference as part of cite web or cite podcast?
		not is_set(TranscriptURL) then
		
		-- Test if cite web or cite podcast |url= is missing or empty 
		if inArray(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then	
			table.insert( z.message_tail, { seterror( 'cite_web_url', {}, true ) } );
		end
		
		-- Test if accessdate is given without giving a URL
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when the others are not set; TODO: move this to a separate test?
			table.insert( z.message_tail, { seterror( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
		
		-- Test if format is given without giving a URL
		if is_set(Format) then
			Format = Format .. seterror( 'format_missing_url', {'format', 'url'} );
		end
	end
--[[
	-- Test if citation has no title
	if	not is_set(Title) and
--		not is_set(Periodical) and			-- not a title
--		not is_set(Conference) and			-- not a title
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
		table.insert( z.message_tail, { seterror( 'citation_missing_title', {}, true ) } );
	end
	
	if 'none' == Title and is_set(Periodical) then								-- special case
		Title = '';																-- set title to empty string
		table.insert( z.maintenance_cats, &quot;CS1 maint: Untitled periodical&quot;);	-- add to maint category
	end
]]
	local OriginalURL;
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
			end
		elseif is_set (ChapterURL) then 										-- URL not set so if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
			end
		end
	end

	if inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;journal&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;, &quot;newsgroup&quot;}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			if is_set (Chapter) or is_set (TransChapter) or is_set (ChapterURL)then	-- chapter parameters not supported for these citation types
				table.insert( z.message_tail, { seterror( 'chapter_ignored', {}, true ) } );		-- add error message
				Chapter = '';														-- set to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
			end
	else																		-- otherwise, format chapter / article title
		Chapter = format_chapter_title (Chapter, TransChapter, ChapterURL, ChapterURLorigin);
		if is_set (Chapter) then
			ChapterFormat = is_set(ChapterFormat) and &quot; (&quot; .. ChapterFormat .. &quot;)&quot; or &quot;&quot;;
			if is_set(ChapterFormat) and not is_set (ChapterURL) then			-- Test if |chapter-format= is given without giving a |chapter-url=
				ChapterFormat = ChapterFormat .. seterror( 'format_missing_url', {'chapter-format', 'chapter-url'} );
			end
			Chapter = Chapter .. ChapterFormat .. sepc .. ' ';
		end
	end

	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if inArray(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;journal&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;, &quot;newsgroup&quot;, &quot;mailinglist&quot;}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			Title = kern_quotes (Title);											-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
	
			Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. seterror( 'trans_missing_title' );
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then 
			Title = externallink( URL, Title ) .. TransError .. Format	   
			URL = &quot;&quot;;
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end
	
	if is_set(Conference) then
		if is_set(ConferenceURL) then
			Conference = externallink( ConferenceURL, Conference );
		end
		Conference = sepc .. &quot; &quot; .. Conference
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. externallink( ConferenceURL, nil, ConferenceURLorigin );
	end
	
	if not is_set(Position) then
		local Minutes = A['Minutes'];
		if is_set(Minutes) then
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			local Time = A['Time'];
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end
	
	if not is_set(Page) then
		if is_set(Pages) then
			if is_set(Periodical) and
				not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
				Pages = &quot;: &quot; .. Pages;
			elseif tonumber(Pages) ~= nil then
				Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
			else
				Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
			end
		end
	else
		if is_set(Periodical) and
			not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
			Page = &quot;: &quot; .. Page;
		else
			Page = sepc ..&quot; &quot; .. PPrefix .. Page;
		end
	end
	
	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Inset = A['Inset'];
		if first_set( Pages, Page, At ) ~= nil or sepc ~= '.' then
			if is_set( Section ) then
				Section = &quot;, &quot; .. wrap_msg ('section', Section, true);
			end
			if is_set( Inset ) then
				Inset = &quot;, &quot; .. wrap_msg ('inset', Inset, true);
			end
		else
			if is_set( Section ) then
				Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
				if is_set( Inset ) then
					Inset = &quot;, &quot; .. wrap_msg ('inset', Inset, true);
				end
			elseif is_set( Inset ) then
				Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
			end			
		end			
		At = At .. Section .. Inset;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language, this_page.namespace);			-- format, categories (article namespace only), name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;

-- handle type parameter for those CS1 citations that have default values

	if inArray(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;mailinglist&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then	-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then					-- if type parameter is specified
		TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot;;	-- display it in parentheses
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	Edition = is_set(Edition) and (&quot; &quot; .. wrap_msg ('edition', Edition)) or &quot;&quot;;
	Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc ..&quot; &quot; .. Volume;
		  else Volume = &quot; &lt;b&gt;&quot; .. hyphentodash(Volume) .. &quot;&lt;/b&gt;&quot;;
		end
	end

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

--[[
Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
note is displayed. There are no error messages for this condition.

]]
	if inArray(SubscriptionRequired:lower(), {'yes', 'true', 'y'}) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif inArray(RegistrationRequired:lower(), {'yes', 'true', 'y'}) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if 'citation', lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text
																				-- neither of these work; don't know why; it seems that substitute() isn't being called	
		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = buildidlist( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo} );

	if is_set(URL) then
		URL = &quot; &quot; .. externallink( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
			Quote = Quote:sub(2,-2);
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- CS1 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = seterror('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ externallink( ArchiveURL, arch_text ), ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. seterror('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text,
				{ externallink( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ seterror('archive_missing_url'), ArchiveDate } );
		end
	else
		Archived = &quot;&quot;
	end
	
	local Lay
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safeforitalics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. externallink( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
		end			
	else
		Lay = &quot;&quot;;
	end
	
	if is_set(Transcript) then
		if is_set(TranscriptURL) then Transcript = externallink( TranscriptURL, Transcript ); end
	elseif is_set(TranscriptURL) then
		Transcript = externallink( TranscriptURL, nil, TranscriptURLorigin );
	end
	
	local Publisher;
	if is_set(Periodical) and
		not inArray(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap_msg ('published', PublicationDate);
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap_msg ('published', PublicationDate) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon
	if inArray(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safejoin( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, 
			Language, Cartography, Edition, Publisher, Agency, Volume, Issue}, sepc );
	else 
		tcommon = safejoin( {Title, TitleNote, Conference, Periodical, Format, TitleType, Scale, Series, Language, 
			Volume, Issue, Others, Cartography, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safejoin( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safejoin( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Page .. Pages .. At;
	
	if is_set(Authors) then
		if is_set(Coauthors) then
			local sep = '; ';
			if 'vanc' == NameListFormat then
				sep = ', ';
			end
			Authors = Authors .. sep .. Coauthors;
		end
		if is_set(Date) then
			Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		elseif string.sub(Authors,-1,-1) == sepc then
			Authors = Authors .. &quot; &quot;
		else
			Authors = Authors .. sepc .. &quot; &quot;
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			if (sepc ~= '.') then in_text = in_text:lower() end
			Editors = in_text .. Editors .. post_text;
			if (string.sub(Editors,-1,-1) == sepc)
				then Editors = Editors .. &quot; &quot;
				else Editors = Editors .. sepc .. &quot; &quot;
			end
		end
		text = safejoin( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
		text = safejoin( {text, pgtext, idcommon}, sepc );
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safejoin( {Editors, Date, Chapter, Place, tcommon}, sepc );
		text = safejoin( {text, pgtext, idcommon}, sepc );
	else
		if is_set(Date) then
			if ( string.sub(tcommon,-1,-1) ~= sepc )
			  then Date = sepc ..&quot; &quot; .. Date .. OrigYear
			  else Date = &quot; &quot; .. Date .. OrigYear
			end
		end
		if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
			text = safejoin( {Chapter, Place, tcommon}, sepc );
			text = safejoin( {text, pgtext, Date, idcommon}, sepc );
		else
			text = safejoin( {Chapter, Place, tcommon, Date}, sepc );
			text = safejoin( {text, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safejoin( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
--		text = text:sub(1,-2);	--Remove final separator (assumes that sepc is only one character)
	end	
	
	text = safejoin( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;span/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = &quot;citation &quot; .. config.CitationClass;
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
		local id = Ref
		if ( &quot;harv&quot; == Ref ) then
			local names = {} --table of last names &amp; year
			if #a &gt; 0 then
				for i,v in ipairs(a) do 
					names[i] = v.last 
					if i == 4 then break end
				end
			elseif #e &gt; 0 then
				for i,v in ipairs(e) do 
					names[i] = v.last 
					if i == 4 then break end				
				end
			end
			names[ #names + 1 ] = first_set(Year, anchor_year);	-- Year first for legacy citations and for YMD dates that require disambiguation
			id = anchorid(names)
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = seterror('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then 
		text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	else
		text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	end		

	local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
	
	-- Note: Using display: none on then COinS span breaks some clients.
	local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
	text = text .. OCinS;
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. errorcomment( v[1], v[2] );
				else
					text = text .. errorcomment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if inArray(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
	local pframe = frame:getParent()
	
	if nil ~= string.find( frame:getTitle(), 'sandbox', 1, true ) then				-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData( 'Module:Citation/CS1/Configuration/sandbox' );	-- load sandbox versions of Configuration and Whitelist and ...
		whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist/sandbox' );
		dates = require('Module:Citation/CS1/Date_validation/sandbox').dates	-- ... sandbox version of date validation code
	else																	-- otherwise
		cfg = mw.loadData( 'Module:Citation/CS1/Configuration' );			-- load live versions of Configuration and Whitelist and ...
		whitelist = mw.loadData( 'Module:Citation/CS1/Whitelist' );
		dates = require('Module:Citation/CS1/Date_validation').dates		-- ... live version of date validation code
	end
	
	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = seterror( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = seterror( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if #suggestions == 0 then
						suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
					end
					if suggestions[ k:lower() ] ~= nil then
						error_text, error_state = seterror( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
					else
						error_text, error_state = seterror( 'parameter_ignored', {k}, true );
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	
	
	return citation0( config, args)
end

return z</text>
      <sha1>htf4zur3yobbvbz7du82q0v9lwgjsxm</sha1>
    </revision>
    <revision>
      <id>4688</id>
      <parentid>4687</parentid>
      <timestamp>2015-03-21T12:13:28Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4688</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="116922" sha1="h11od2qzmjna9h6z9tv9cbf6f4ybqc0" xml:space="preserve">
local z = {
	error_categories = {};		-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};		-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};		-- for categorizing citations based on certain properties, language of source for instance
}

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]
local dates, year_date_check	-- functions in Module:Citation/CS1/Date_validation

--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.
This function is global because it is called from both this module and from Date validation

]]
function is_set( var )
	return not (var == nil or var == '');
end

--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

First set variable or nil if none

]]

local function first_set(...)
	local list = {...};
	for _, var in pairs(list) do
		if is_set( var ) then
			return var;
		end
	end
end

--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end

--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]
local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end

--[[--------------------------&lt; S E T _ E R R O R &gt;--------------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

]]
local function set_error( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if in_array( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return error_comment( message, error_state.hidden );
end

--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string is valid.

At present the only check is whether the string appears to be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well formed.

]]

local function check_url( url_str )
	return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;		-- Protocol-relative or URL scheme
end

--[[--------------------------&lt; S A F E _ F O R _ I T A L I C S &gt;----------------------------------------------

Protects a string that will be wrapped in wiki italic markup '' ... ''

Note: We cannot use &lt;i&gt; for italics, as the expected behavior for italics specified by ''...'' in the title is that
they will be inverted (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and '' tend to interact
poorly under Mediawiki's HTML tidy.

]]

local function safe_for_italics( str )
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end

--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

local function wrap_style (key, str)
	if not is_set( str ) then
		return &quot;&quot;;
	elseif in_array( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safe_for_italics( str );
	end

	return substitute( cfg.presentation[key], {str} );
end

--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source )
	local error_str = &quot;&quot;;
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
	end
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url( label ), &quot;]&quot;, error_str });
end

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

--[[
Categorize and emit an error message when the citation contains one or more deprecated parameters.  Because deprecated parameters (currently |month=,
|coauthor=, and |coauthors=) aren't related to each other and because these parameters may be concatenated into the variables used by |date= and |author#= (and aliases)
details of which parameter caused the error message are not provided.  Only one error message is emitted regardless of the number of deprecated parameters in the citation.
]]
local function deprecated_parameter(name)
	if true ~= Page_in_deprecated_cat then	-- if we haven't been here before then set a 
		Page_in_deprecated_cat=true;		-- sticky flag so that if there are more than one deprecated parameter the category is added only once
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end

--[[--------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Call this function for chapter titles, for website titles, etc; not for book titles.

]]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	
	cap, cap2 = str:match (&quot;^([\&quot;\'])([^\'].+)&quot;);								-- match leading double or single quote but not double single quotes
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-left'], {cap, cap2});
	end

	cap, cap2 = str:match (&quot;^(.+[^\'])([\&quot;\'])$&quot;)
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-right'], {cap, cap2});
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

At this writing, only |script-title= is supported.  It is anticipated that additional parameters will be created to use this function.

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, {'ar', 'bg', 'bs', 'dv', 'el', 'fa', 'hy', 'ja', 'ka', 'ko', 'ku', 'he', 'ps', 'ru', 'sd', 'sr', 'th', 'uk', 'ug', 'yi', 'zh'}) then
				table.insert( z.properties_cats, 'CS1 uses ' .. name .. '-language script ('..lang..')');	-- categorize in language-specific categories
			else
				table.insert( z.properties_cats, 'CS1 uses foreign language script');	-- use this category as a catchall until language-specific category is available
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		str = substitute( msg, {str} );											-- including template text
		return str;
	else
		return substitute( cfg.messages[key], {str} );
	end		
end
--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider
Generates an error if more than one match is present.

]]

local function select_one( args, possible, error_condition, index )
	local value = nil;
	local selected = '';
	local error_list = {};
	
	if index ~= nil then index = tostring(index); end
	
	-- Handle special case of &quot;#&quot; replaced by empty string
	if index == '1' then
		for _, v in ipairs( possible ) do
			v = v:gsub( &quot;#&quot;, &quot;&quot; );
			if is_set(args[v]) then
				if value ~= nil and selected ~= v then
					table.insert( error_list, v );
				else
					value = args[v];
					selected = v;
				end
			end
		end		
	end
	
	for _, v in ipairs( possible ) do
		if index ~= nil then
			v = v:gsub( &quot;#&quot;, index );
		end
		if is_set(args[v]) then
			if value ~= nil and selected ~=  v then
				table.insert( error_list, v );
			else
				value = args[v];
				selected = v;
			end
		end
	end
	
	if #error_list &gt; 0 then
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap_style ('parameter', k);
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap_style ('parameter', selected);
		table.insert( z.message_tail, { set_error( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end

--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the three chapter parameters: |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (chapter, transchapter, chapterurl, chapter_url_source)
	local chapter_error = '';
	
	if not is_set (chapter) then
		chapter = '';															-- just to be safe for concatenation
		if is_set (transchapter) then
			chapter = wrap_style ('trans-quoted-title', transchapter);
			chapter_error = &quot; &quot; .. set_error ('trans_missing_chapter');
		end
		if is_set (chapterurl) then
			chapter = external_link (chapterurl, chapter, chapter_url_source);	-- adds bare_url_missing_title error if appropriate
		end
		return chapter .. chapter_error;
	else																		-- here when chapter is set
		chapter = kern_quotes (chapter);										-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
		chapter = wrap_style ('quoted-title', chapter);
		if is_set (transchapter) then
			transchapter = wrap_style ('trans-quoted-title', transchapter);
			chapter = chapter .. ' ' .. transchapter;
		end
		if is_set (chapterurl) then
			chapter = external_link (chapterurl, chapter);						-- adds bare_url_missing_title error if appropriate
		end
	end
	return chapter;
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]
local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
]]
local function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end


-- Formats a wiki style internal link
local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s*%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s*%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end

--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in check_isbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of bytes
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end	-- isbn13 begins with 978 or 979
		isbn_str = { isbn_str:byte(1, len) };
		for i, v in ipairs( isbn_str ) do
			temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
		end
		return temp % 10 == 0;
	end
end

--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				table.insert( z.maintenance_cats, 'CS1 maint: ASIN uses ISBN');	-- add to maint category
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link = handler.link,
		label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
		encode=handler.encode, separator = handler.separator}) .. err_cat;
end

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = &quot;&quot;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[
lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--[[
Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of the LCCN dictates the character type of the first 1-3 characters; the
rightmost eight are always digits. http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]
local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]
local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns true; otherwise, returns false because the embargo has expired or |embargo= not set in this cite.
]]
local function is_embargoed(embargo)
	if is_set(embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 and tonumber( embargo_date ) &gt;= tonumber( todays_date ) then	--is embargo date is in the future?
			return true;	-- still embargoed
		end
	end
	return false;			-- embargo expired or |embargo= not set
end

--[[
Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future
the PMC identifier will not be linked to the article.  If the embargo specifies a date in the past, or if it is empty or omitted, then
the PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.
]]
local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_embargoed(embargo) then
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	--still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			--no embargo date, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.

-- DOI names contain two parts: prefix and suffix separated by a forward slash.
--  Prefix: directory indicator '10.' followed by a registrant code
--  Suffix: character string of any length chosen by the registrant

-- This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes,
-- or, if it ends with a period or a comma, this function will emit a bad_doi error message.

-- DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
-- and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely if ever used in doi names.

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);					-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode}) .. 
			' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end



--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those citations that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]
local function set_titletype(cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;					-- if |type=none then type parameter not displayed
		end
		return title_type;						-- if |type= has been set to any other value use that value
	end

	if &quot;AV-media-notes&quot; == cite_class or &quot;DVD-notes&quot; == cite_class then		-- if this citation is cite AV media notes or cite DVD notes
		return &quot;Media notes&quot;;					-- display AV media notes / DVD media notes annotation

	elseif &quot;mailinglist&quot; == cite_class then		-- if this citation is cite mailing list
		return &quot;Mailing list&quot;;					-- display mailing list annotation

	elseif &quot;map&quot; == cite_class then				-- if this citation is cite map
		return &quot;Map&quot;;							-- display map annotation

	elseif &quot;podcast&quot; == cite_class then			-- if this citation is cite podcast
		return &quot;Podcast&quot;;						-- display podcast annotation

	elseif &quot;pressrelease&quot; == cite_class then	-- if this citation is cite press release
		return &quot;Press release&quot;;					-- display press release annotation

	elseif &quot;report&quot; == cite_class then			-- if this citation is cite report
		return &quot;Report&quot;;						-- display report annotation
	
	elseif &quot;techreport&quot; == cite_class then		-- if this citation is cite techreport
		return &quot;Technical report&quot;;				-- display techreport annotation
	
	elseif &quot;thesis&quot; == cite_class then			-- if this citation is cite thesis (degree option handled after this function returns)
			return &quot;Thesis&quot;;					-- display simple thesis annotation (without |degree= modification)
	end
end

-- Removes irrelevant text and dashes from ISBN number
-- Similar to that used for Special:BookSources
local function clean_isbn( isbn_str )
	return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]
local function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other lua magic pattern characters
	return argument;
end

--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]
local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	while true do
		if argument:match (&quot;%'%'%'%'%'&quot;) then									-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:match (&quot;%'%'%'%'&quot;) then									-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:match (&quot;%'%'%'&quot;) then									-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:match (&quot;%'%'&quot;) then										-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end

--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...
]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end

--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]
local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
local function remove_wiki_link( str )
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end

-- Converts a hyphen to a dash
local function hyphen_to_dash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end

--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]
local function safe_join( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if comp:sub(1,1) == duplicate_char then								-- is first charactier same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for th
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = str:sub(-1,-1);										-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = str:sub(1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = str:sub(1, -4) .. &quot;''&quot;;							-- remove them and add back ''
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then		-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then		-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then			-- if last two chars of str are sepc] external link
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;'']&quot; then		-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then				-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = str:sub(1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end		-- if duplicate_char not a letter then escape it
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )			-- remove duplicate_char if it follows html markup
					else
						value = value:sub( 2, -1 );								-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end  


--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.  This module can, however, check
the content of |lastn= and |firstn= to see if the names contain non-Latin (non-ASCII) characters and emit an error message
when such characters are located.

Allow |lastn= to contain ASCII characters, hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
Allow |firstn= to contain ASCII characters, hyphens, spaces, apostrophes, and periods
]]

local function is_good_vanc_name (last, first)
	if last:find (&quot;[^%a%-%'%s]&quot;) or first:find (&quot;[^%a%-%'%s%.]&quot;) then												
		if true ~= Page_in_vanc_error_cat then									-- if we haven't been here before then set a sticky flag
			Page_in_vanc_error_cat=true;										-- so that if there are more than one error the category is added only once
			table.insert( z.message_tail, { set_error( 'vancouver', {}, true ) } );
		end
		return false;															-- not a string of latin characters; Vancouver required Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  This form is not
currently supported by this code so correctly formed names like Smith JL 2nd are converted to Smith J2. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.

]]

local function reduce_to_initials(first)
	if first:match(&quot;^%u%u$&quot;) then return first end;								-- when first contains just two upper-case letters, nothing to do
	local initials = {}
	local i = 0;																-- counter for number of initials
	for word in string.gmatch(first, &quot;[^%s%.%-]+&quot;) do							-- names separated by spaces, hyphens, or periods
		table.insert(initials, string.sub(word,1,1))							-- Vancouver format does not include full stops.
		i = i + 1;																-- bump the counter 
		if 2 &lt;= i then break; end												-- only two initials allowed in Vancouver system; if 2, quit
	end
	return table.concat(initials)												-- Vancouver format does not include spaces.
end

--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------
Formats a list of people (e.g. authors / editors) 
]]
local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = ',';																-- name-list separator between authors is a comma
		namesep = ' ';															-- last/first separator is a space
	else
		sep = ';'																-- name-list separator between authors is a semicolon
		namesep = ', '															-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if maximum ~= nil and maximum &lt; 1 then return &quot;&quot;, 0; end
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if maximum ~= nil and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if is_good_vanc_name (one, first) then					-- and name is all Latin characters
							first = reduce_to_initials(first)						-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first 
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;		-- link author/editor if this page is not the author's/editor's page
				end

				if is_set(person.link) and ((nil ~= person.link:find(&quot;//&quot;)) or (nil ~= person.link:find(&quot;[%[%]]&quot;))) then
					one = one .. &quot; &quot; .. set_error( 'bad_authorlink' ) end	-- url or wikilink in author link;
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;
		end
		text[#text] = nil; 
	end
	
	local result = table.concat(text) -- construct list
	if etal then 
		local etal_text = cfg.messages['et al'];
		result = result .. &quot; &quot; .. etal_text;
	end
	
	return result, count
end

--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------
Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

]]

local function anchor_id( options )
	local id = table.concat( options );											-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end

--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter
	local pattern = &quot;,? *'*[Ee][Tt] *[Aa][Ll][%.']*$&quot;							-- variations on the 'et al' theme
	
	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary

	while true do
		last = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		local name = tostring(last);
		if name:match (pattern) then											-- varients on et al.
			last = name:gsub (pattern, '');										-- if found, remove
			etal = true;
		end
		name = tostring(first);
		if name:match (pattern) then											-- varients on et al.
			first = name:gsub (pattern, '');									-- if found, remove
			etal = true;
		end

		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 == count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			names[n] = {last = last, first = first, link = link, mask = mask};	-- add this name to our names list
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	if true == etal then
		table.insert( z.maintenance_cats, 'CS1 maint: Explicit use of et al.');	-- add to maint category
	end
	return names, etal;															-- all done, return our list of names
end

-- Populates ID table from arguments using configuration settings
local function extract_ids( args )
	local id_list = {};
	for k, v in pairs( cfg.id_handlers ) do	
		v = select_one( args, v.parameters, 'redundant_parameters' );
		if is_set(v) then id_list[k] = v; end
	end
	return id_list;
end

--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------
Takes a table of IDs and turns it into a table of formatted ID outputs.

]]
local function build_id_list( id_list, options )
	local new_list, handler = {};

	function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end
  

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
local function COinS(data)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end
	
	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if is_set(data.Chapter) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
	elseif is_set(data.Periodical) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
		OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	else
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
	end
	
	OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
	OCinSoutput[&quot;rft.date&quot;] = data.Date;
	OCinSoutput[&quot;rft.series&quot;] = data.Series;
	OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
	OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
	OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
	OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
	OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
	
	for k, v in pairs( data.ID_list ) do
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
	
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = v.last, v.first;
		if k == 1 then
			if is_set(last) then
				OCinSoutput[&quot;rft.aulast&quot;] = last;
			end
			if is_set(first) then 
				OCinSoutput[&quot;rft.aufirst&quot;] = first;
			end
		end
		if is_set(last) and is_set(first) then
			OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
		elseif is_set(last) then
			OCinSoutput[&quot;rft.au&quot;] = last;
		end
	end
	
	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 code.  Handles the special case that is Norwegian where
ISO639-1 code 'no' is mapped to language name 'Norwegian Bokmål' by Extention:CLDR.

Returns the language name and associated ISO639-1 code.  Because case of the source may be incorrect or different from the case that Wikimedia
uses, the name comparisons are done in lower case and when a match is found, the Wikimedia version (assumed to be correct) is returned along
with the code.  When there is no match, we return the original language name string.

mw.language.fetchLanguageNames() will return a list of languages that aren't part of ISO639-1. Names that aren't ISO639-1 but that are included
in the list will be found if that name is provided in the |language= parameter.  For example, if |language=Samaritan Aramaic, that name will be
found with the associated code 'sam', not an ISO639-1 code.  When names are found and the associated code is not two characters, this function
returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.
]]

local function get_iso639_code (lang)
	if 'norwegian' == lang:lower() then											-- special case related to Wikimedia remap of code 'no' at Extension:CLDR
		return 'Norwegian', 'no';												-- Make sure rendered version is properly capitalized
	end
	
	local languages = mw.language.fetchLanguageNames('en', 'all')				-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() then												-- ISO639-1 codes only
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the ISO639-1 code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for ISO639-1 code
end

--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Get language name from ISO639-1 code value provided.  If a code is valid use the returned name; if not, then use the value that was provided with the language parameter.

There is an exception.  There are three ISO639-1 codes for Norewegian language variants.  There are two official variants: Norwegian Bokmål (code 'nb') and
Norwegian Nynorsk (code 'nn').  The third, code 'no',  is defined by ISO639-1 as 'Norwegian' though in Norway this is pretty much meaningless.  However, it appears
that on enwiki, editors are for the most part unaware of the nb and nn variants (compare page counts for these variants at Category:Articles with non-English-language external links.

Because Norwegian Bokmål is the most common language variant, Media wiki has been modified to return Norwegian Bokmål for ISO639-1 code 'no'. Here we undo that and
return 'Norwegian' when editors use |language=no.  We presume that editors don't know about the variants or can't descriminate between them.

See Help talk:Citation Style_1#An ISO 639-1 language name test

When |language= contains a valid ISO639-1 code, the page is assigned to the category for that code: Category:Norwegian-language sources (no) if
the page is a mainspace page and the ISO639-1 code is not 'en'.  Similarly, if the  parameter is |language=Norwegian, it will be categorized in the same way.

]]

local function language_parameter (lang, namespace)
	local code;			-- the ISO639-1 two character code
	local name;			-- the language name
	local test='';
		
	if 0 == namespace and (('en' == lang:lower()) or ('english' == lang:lower())) then
		table.insert (z.maintenance_cats, 'CS1 maint: English language specified');		-- add maintenance category if |language=English or |language=en in article space
	end

	if 2 == lang:len() then														-- ISO639-1 language code are 2 characters (fetchLanguageName also supports 3 character codes)
		name = mw.language.fetchLanguageName( lang:lower(), &quot;en&quot; );				-- get ISO 639-1 language name if Language is a proper code
	end

	if is_set (name) then														-- if Language specified a valid ISO639-1 code
		code = lang:lower();													-- save it
	else
		name, code = get_iso639_code (lang);									-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
	end

	if is_set (code) then
		if 'no' == code then name = 'Norwegian' end;							-- override wikimedia when code is 'no'
		if 0 == namespace and 'en' ~= code then									-- is this page main / article space and English not the language?
			table.insert( z.properties_cats, 'CS1 ' .. name .. '-language sources (' .. code .. ')');	-- in main space and not English: categorize
		end
	else
		table.insert (z.maintenance_cats, 'CS1 maint: Unrecognized language');	-- add maintenance category when |language= does not appear to be ISO 639-1 language
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- wrap with '(in ...)'
end

--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------
When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep = ',';																-- set citation separator to its default (comma)
		if not is_set (ps) then													-- if |postscript= has not been set, set cs2 default
			ps = '';															-- make sure it isn't nil
		end
		if not is_set (ref) then												-- if |ref= is not set
			ref = &quot;harv&quot;;														-- set default |ref=harv
		end
	else																		-- not a citation template so CS1
		sep = '.';																-- set cite xxx separator to its default (period)
		if not is_set (ps) then													-- if |postscript= has not been set
			ps = '.';															-- set cs1 default
		end
	end

	return sep, ps, ref															-- return them all
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
local sep;
	if is_set (mode) then
		if 'cs2' == mode then											-- if this template is to be rendered in CS2 (citation) style
			sep = ',';															-- separate elements with a comma
			if not is_set (ps) then												-- unless explicitely set to something
				ps = '';														-- make sure it isn't nil
			end
			if not is_set (ref) then											-- unless explicitely set to something
				ref = 'harv';													-- set so this template renders with CITEREF anchor id
			end
		elseif 'cs1' == mode then										-- if this template is to be rendered in CS1 (cite xxx) style
			sep = '.';															-- separate elements with a period
			if not is_set (ps) then												-- unless explicitely set to something
				ps = '.';														-- terminate the rendered citation with a period
			end
		else																	-- anything but cs1 or cs2
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'mode', mode}, true ) } );		-- add error message
			sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);	-- get settings based on the template's CitationClass
		end
	else													-- when |mode= empty or omitted
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------
This is the main function doing the majority of the citation
formatting.
]]
local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple
	aliases to single internal variable.
	]]
	local A = argument_wrapper( args );

	local i 
	local PPrefix = A['PPrefix']
	local PPPrefix = A['PPPrefix']
	if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
	
	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local Authors = A['Authors'];
	local author_etal;
	local a, author_etal = extract_names( args, 'AuthorList' );

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];
	local Editors = A['Editors'];
	local editor_etal;
	local e, editor_etal = extract_names( args, 'EditorList' );

	local NameListFormat = A['NameListFormat'];									-- replaces |author-format= and |editor-format=
	if is_set (NameListFormat) and ('vanc' ~= NameListFormat) then											-- only accepted value for this parameter is 'vanc'
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {'name-list-format', NameListFormat}, true ) } );	-- not vanc so add error message
		NameListFormat = '';													-- set to empty string
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
	local Chapter = A['Chapter'];
	local ChapterLink = A['ChapterLink'];										-- deprecated
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveURL = A['ArchiveURL'];
	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];

	local Series = A['Series'];
	local Volume = A['Volume'];
	local Issue = A['Issue'];
	local Position = '';
	local Page = A['Page'];
	local Pages = hyphen_to_dash( A['Pages'] );	
	local At = A['At'];

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
	local SubscriptionRequired = A['SubscriptionRequired'];
	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local ArchiveDate = A['ArchiveDate'];
	local Agency = A['Agency'];
	local DeadURL = A['DeadURL']
	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
	local Embargo = A['Embargo'];

	local ID_list = extract_ids( args );

	local Quote = A['Quote'];

	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
	local no_tracking_cats = A['NoTracking'];

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local use_lowercase;								-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();		-- also used for COinS and for language
	local anchor_year;									-- used in the CITEREF identifier
	local COinS_date;									-- used in the COinS metadata

-- set default parameter values defined by |mode= parameter.  If |mode= is empty or omitted, use CitationClass to set these values
	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (A['Mode']:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories.
	if not is_set(no_tracking_cats) then				-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;					-- set no_tracking_cats
		end
	end

-- check for extra |page=, |pages= or |at= parameters. 
	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Page = Page .. &quot; &quot; .. set_error('extra_pages');	-- add error message
			Pages = '';										-- unset the others
			At = '';
		end
	elseif is_set(Pages) then
		if is_set(At) then
			Pages = Pages .. &quot; &quot; .. set_error('extra_pages');	-- add error messages
			At = '';											-- unset
		end
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped
	|url maps to |chapterurl when |title is remapped

All other combinations of |encyclopedia, |title, and |article are not modified
TODO: script-title to script-chapter if and when we support script-chapter
]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then					-- Periodical is set when |encyclopedia is set
			if is_set(Title) then
				if not is_set(Chapter) then
					Chapter = Title;				-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					TransChapter = TransTitle;
					ChapterURL = URL;
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';				-- redundant so unset
					TransTitle = '';				-- redundant so unset
					URL = '';						-- redundant so unset
					Format = '';					-- redundant so unset
				end
			else									-- |title not set
				Title = Periodical;					-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';					-- redundant so unset
			end
		end
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then	-- special case for cite techreport
		if is_set(Issue) then						-- cite techreport uses 'number', which other citations aliase to 'issue'
			if not is_set(ID) then					-- can we use ID for the &quot;number&quot;?
				ID = Issue;							-- yes, use it
				Issue = &quot;&quot;;							-- unset Issue so that &quot;number&quot; isn't duplicated in the rendered citation or COinS metadata
			else									-- can't use ID so emit error message
				ID = ID .. &quot; &quot; .. set_error('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Others) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Others;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Others;
			end
		else
			Others = '(Interview)';
		end
	end

-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	end

--Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set
	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_embargoed(Embargo) then
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];	-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];		-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	else
		Conference = '';														-- not cite conference so make sure this is empty string
	end

-- Account for the oddity that is {{cite episode}}, before generation of COinS data.
--[[	-- {{cite episode}} is not currently supported by this module
	if config.CitationClass == &quot;episode&quot; then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];
		local Season = A['Season'];
		local SeriesNumber = A['SeriesNumber'];
		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
		local Sep = (first_set(A[&quot;SeriesSeparator&quot;], A[&quot;Separator&quot;]) or &quot;&quot;) .. &quot; &quot;;
		
		if is_set(Issue) then table.insert(s, cfg.messages[&quot;episode&quot;] .. &quot; &quot; .. Issue); Issue = ''; end
		if is_set(Season) then table.insert(s, cfg.messages[&quot;season&quot;] .. &quot; &quot; .. Season); end
		if is_set(SeriesNumber) then table.insert(s, cfg.messages[&quot;series&quot;] .. &quot; &quot; .. SeriesNumber); end
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		
		Date = Date or AirDate;
		Chapter = Title;
		ChapterLink = TitleLink;
		TransChapter = TransTitle;
		Title = Series;
		TitleLink = SeriesLink;
		TransTitle = '';
		
		Series = table.concat(s, Sep);
		ID = table.concat(n, Sep);
	end
-- end of {{cite episode}} stuff]]

-- legacy: promote concatenation of |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set (Date) then
		Date = Year;						-- promote Year to Date
		Year = nil;							-- make nil so Year as empty string isn't used for CITEREF
		if is_set(Date) then
			local Month = A['Month'];
			if is_set(Month) then
				Date = Month .. &quot; &quot; .. Date;
			end
		elseif is_set(PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;			-- promote PublicationDate to Date
			PublicationDate = '';			-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end	-- if PublicationDate is same as Date, don't display in rendered citation

--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	do	-- create defined block to contain local variables error_message and mismatch
		local error_message = '';

		anchor_year, COinS_date, error_message = dates({['accessdate']=AccessDate, ['airdate']=AirDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
			['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				table.insert( z.maintenance_cats, 'CS1 maint: Date and year');	-- add to maint category
			end
		end

		if is_set(error_message) then
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end
	end	-- end of do

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
		table.insert( z.message_tail, { set_error( 'citation_missing_title', {}, true ) } );
	end
	
	if 'none' == Title and is_set(Periodical) and not (( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia))) then								-- special case
		Title = '';																-- set title to empty string
		table.insert( z.maintenance_cats, 'CS1 maint: Untitled periodical');	-- add to maint category
	end

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	
	-- this is the function call to COinS()
	local OCinSoutput = COinS{
		['Periodical'] = Periodical,
		['Chapter'] = strip_apostrophe_markup (coins_chapter),					-- Chapter stripped of bold / italic wikimarkup
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = first_set(COinS_date, Date),		-- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here?  Should we be including invalid dates in metadata?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set(Page, Pages, At)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set( URL, ChapterURL ),
		['Authors'] = a,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	};

-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = '[[Newsgroup]]:&amp;nbsp;' ..  external_link( 'news:' .. PublisherName, PublisherName );
		end
	end



	-- Now perform various field 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 not is_set(Authors) then
		local Maximum = tonumber( A['DisplayAuthors'] );

		if is_set (Maximum) then
			if Maximum &gt;= #a then												-- if display-authors value greater than or equal to number of authors
				table.insert( z.maintenance_cats, 'CS1 maint: display-authors');	-- add maintenance category because display-authors parameter may be removed
			end
		else
			Maximum = #a + 1;													-- number of authors + 1
		end

		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text				-- get current page name so that we don't wikilink to it via authorlinkn
		};
		
		-- If the coauthor field is also used, prevent ampersand and et al. formatting.
		if is_set(Coauthors) then
			control.lastauthoramp = nil;
			control.maximum = #a + 1;
		end
		
		Authors = list_people(control, a, author_etal) 
	end

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { set_error('coauthors_missing_author', {}, true) } );	-- emit error message
	end

	local EditorCount
	if not is_set(Editors) then
		local Maximum = tonumber( A['DisplayEditors'] );
		-- Preserve old-style implicit et al.
		if not is_set(Maximum) and #e == 4 then 
			Maximum = 3;
			table.insert( z.message_tail, { set_error('implict_etal_editor', {}, true) } );
		elseif not is_set(Maximum) then
			Maximum = #e + 1;
		end

		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text				-- get current page name so that we don't wikilink to it via editorlinkn
		};

		Editors, EditorCount = list_people(control, e, editor_etal);
	else
		EditorCount = 1;
	end

-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end		
	end
	
	Format = is_set(Format) and &quot; (&quot; .. Format .. &quot;)&quot; or &quot;&quot;;

	if  not is_set(URL) and
		not is_set(ArchiveURL) and
		not is_set(ConferenceURL) and											-- TODO: keep this here? conference as part of cite web or cite podcast?
		not is_set(TranscriptURL) then
		
		-- Test if cite web or cite podcast |url= is missing or empty 
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then	
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- Test if accessdate is given without giving a URL
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when the others are not set; TODO: move this to a separate test?
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
		
		-- Test if format is given without giving a URL
		if is_set(Format) then
			Format = Format .. set_error( 'format_missing_url', {'format', 'url'} );
		end
	end

	local OriginalURL;
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
			end
		elseif is_set (ChapterURL) then 										-- URL not set so if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
			end
		end
	end

	if in_array(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;journal&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;, &quot;newsgroup&quot;}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			if is_set (Chapter) or is_set (TransChapter) or is_set (ChapterURL)then	-- chapter parameters not supported for these citation types
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {}, true ) } );		-- add error message
				Chapter = '';														-- set to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
			end
	else																		-- otherwise, format chapter / article title
		Chapter = format_chapter_title (Chapter, TransChapter, ChapterURL, ChapterURLorigin);
		if is_set (Chapter) then
			ChapterFormat = is_set(ChapterFormat) and &quot; (&quot; .. ChapterFormat .. &quot;)&quot; or &quot;&quot;;
			if is_set(ChapterFormat) and not is_set (ChapterURL) then			-- Test if |chapter-format= is given without giving a |chapter-url=
				ChapterFormat = ChapterFormat .. set_error( 'format_missing_url', {'chapter-format', 'chapter-url'} );
			end
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' (' .. TitleType .. ')';
			end
			Chapter = Chapter .. ChapterFormat .. sepc .. ' ';
		end
	end

	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if in_array(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;journal&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;, &quot;newsgroup&quot;, &quot;mailinglist&quot;}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
	
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title' );
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then 
			Title = external_link( URL, Title ) .. TransError .. Format	   
			URL = &quot;&quot;;
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end
	
	if is_set(Conference) then
		if is_set(ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference );
		end
		Conference = sepc .. &quot; &quot; .. Conference
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin );
	end
	
	if not is_set(Position) then
		local Minutes = A['Minutes'];
		if is_set(Minutes) then
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			local Time = A['Time'];
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end
	
	if not is_set(Page) then
		if is_set(Pages) then
			if is_set(Periodical) and
				not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
				Pages = &quot;: &quot; .. Pages;
			elseif tonumber(Pages) ~= nil then
				Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
			else
				Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
			end
		end
	else
		if is_set(Periodical) and
			not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
			Page = &quot;: &quot; .. Page;
		else
			Page = sepc ..&quot; &quot; .. PPrefix .. Page;
		end
	end
	
	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language, this_page.namespace);			-- format, categories (article namespace only), name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;

-- handle type parameter for those CS1 citations that have default values

	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then	-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then					-- if type parameter is specified
		TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot;;	-- display it in parentheses
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	Edition = is_set(Edition) and (&quot; &quot; .. wrap_msg ('edition', Edition)) or &quot;&quot;;
	Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc ..&quot; &quot; .. Volume;
		  else Volume = &quot; &lt;b&gt;&quot; .. hyphen_to_dash(Volume) .. &quot;&lt;/b&gt;&quot;;
		end
	end

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

--[[
Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
note is displayed. There are no error messages for this condition.

]]
	if in_array(SubscriptionRequired:lower(), {'yes', 'true', 'y'}) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif in_array(RegistrationRequired:lower(), {'yes', 'true', 'y'}) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if 'citation', lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text
																				-- neither of these work; don't know why; it seems that substitute() isn't being called	
		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
			Quote = Quote:sub(2,-2);
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- CS1 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text ), ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text,
				{ external_link( OriginalURL, cfg.messages['original'] ), ArchiveDate } );
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	else
		Archived = &quot;&quot;
	end
	
	local Lay
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'] ) .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower() ) .. LaySource .. LayDate
		end			
	else
		Lay = &quot;&quot;;
	end
	
	if is_set(Transcript) then
		if is_set(TranscriptURL) then Transcript = external_link( TranscriptURL, Transcript ); end
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin );
	end
	
	local Publisher;
	if is_set(Periodical) and
		not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap_msg ('published', PublicationDate);
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap_msg ('published', PublicationDate) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
			Language, Edition, Publisher, Agency, Volume, Issue}, sepc );
		
	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume, Issue}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Issue, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Page .. Pages .. At;
	
	if is_set(Authors) then
		if is_set(Coauthors) then
			local sep = '; ';
			if 'vanc' == NameListFormat then
				sep = ', ';
			end
			Authors = Authors .. sep .. Coauthors;
		end
		if is_set(Date) then
			Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		elseif string.sub(Authors,-1,-1) == sepc then
			Authors = Authors .. &quot; &quot;
		else
			Authors = Authors .. sepc .. &quot; &quot;
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			if (sepc ~= '.') then in_text = in_text:lower() end
			Editors = in_text .. Editors .. post_text;
			if (string.sub(Editors,-1,-1) == sepc)
				then Editors = Editors .. &quot; &quot;
				else Editors = Editors .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
		text = safe_join( {text, pgtext, idcommon}, sepc );
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon}, sepc );
		text = safe_join( {text, pgtext, idcommon}, sepc );
	else
		if is_set(Date) then
			if ( string.sub(tcommon,-1,-1) ~= sepc )
			  then Date = sepc ..&quot; &quot; .. Date .. OrigYear
			  else Date = &quot; &quot; .. Date .. OrigYear
			end
		end
		if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon}, sepc );
			text = safe_join( {text, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date}, sepc );
			text = safe_join( {text, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;span/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = &quot;citation &quot; .. config.CitationClass;
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
		local id = Ref
		if ( &quot;harv&quot; == Ref ) then
			local names = {} --table of last names &amp; year
			if #a &gt; 0 then
				for i,v in ipairs(a) do 
					names[i] = v.last 
					if i == 4 then break end
				end
			elseif #e &gt; 0 then
				for i,v in ipairs(e) do 
					names[i] = v.last 
					if i == 4 then break end				
				end
			end
			names[ #names + 1 ] = first_set(Year, anchor_year);	-- Year first for legacy citations and for YMD dates that require disambiguation
			id = anchor_id(names)
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then 
		text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	else
		text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	end		

	local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
	
	-- Note: Using display: none on then COinS span breaks some clients.
	local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
	text = text .. OCinS;
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. error_comment( v[1], v[2] );
				else
					text = text .. error_comment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end

	if #z.maintenance_cats ~= 0 then
		text = text .. ' &lt;span class=&quot;citation-comment&quot; style=&quot;display:none; color:#33aa33&quot;&gt;';
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. v .. ' ([[:Category:' .. v ..'|link]])';
		end
		text = text .. '&lt;/span&gt;';	-- maintenance mesages (realy just the names of the categories for now)
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
	local pframe = frame:getParent()
	local validation;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of Configuration and Whitelist and ...
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');	-- ... sandbox version of date validation code

	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of Configuration and Whitelist and ...
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		validation = require ('Module:Citation/CS1/Date_validation');			-- ... live version of date validation code
	end

	dates = validation.dates;													-- imported functions
	year_date_check = validation.year_date_check;

	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if #suggestions == 0 then
						suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
					end
					if suggestions[ k:lower() ] ~= nil then
						error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
					else
						error_text, error_state = set_error( 'parameter_ignored', {k}, true );
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	
	
	return citation0( config, args)
end

return z</text>
      <sha1>h11od2qzmjna9h6z9tv9cbf6f4ybqc0</sha1>
    </revision>
    <revision>
      <id>4689</id>
      <parentid>4688</parentid>
      <timestamp>2015-04-18T09:53:36Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4689</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="131799" sha1="tgkmkdmhs7m7zd0gulwv72mzhsxlqj6" xml:space="preserve">
local z = {
	error_categories = {};		-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};		-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};		-- for categorizing citations based on certain properties, language of source for instance
}

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]
local dates, year_date_check	-- functions in Module:Citation/CS1/Date_validation

local cfg = {};					-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};			-- talbe of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist

--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.
This function is global because it is called from both this module and from Date validation

]]
function is_set( var )
	return not (var == nil or var == '');
end

--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

First set variable or nil if none

]]

local function first_set(...)
	local list = {...};
	for _, var in pairs(list) do
		if is_set( var ) then
			return var;
		end
	end
end

--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end

--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]
local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end

--[[--------------------------&lt; S E T _ E R R O R &gt;--------------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

]]
local function set_error( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if in_array( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return error_comment( message, error_state.hidden );
end

--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maintenance_cats using names from the configuration file with additional text if any.

]]

local function add_maint_cat (key, arguments)
	table.insert( z.maintenance_cats, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
end

--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

]]

local function add_prop_cat (key, arguments)
	table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));		-- make name then add to table
end

--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string is valid.

At present the only check is whether the string appears to be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well formed.

]]

local function check_url( url_str )
	return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;		-- Protocol-relative or URL scheme
end

--[[--------------------------&lt; S A F E _ F O R _ I T A L I C S &gt;----------------------------------------------

Protects a string that will be wrapped in wiki italic markup '' ... ''

Note: We cannot use &lt;i&gt; for italics, as the expected behavior for italics specified by ''...'' in the title is that
they will be inverted (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and '' tend to interact
poorly under Mediawiki's HTML tidy.

]]

local function safe_for_italics( str )
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end

--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

local function wrap_style (key, str)
	if not is_set( str ) then
		return &quot;&quot;;
	elseif in_array( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safe_for_italics( str );
	end

	return substitute( cfg.presentation[key], {str} );
end

--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source )
	local error_str = &quot;&quot;;
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
	end
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url( label ), &quot;]&quot;, error_str });
end

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

--[[
Categorize and emit an error message when the citation contains one or more deprecated parameters.  Because deprecated parameters (currently |month=,
|coauthor=, and |coauthors=) aren't related to each other and because these parameters may be concatenated into the variables used by |date= and |author#= (and aliases)
details of which parameter caused the error message are not provided.  Only one error message is emitted regardless of the number of deprecated parameters in the citation.
]]
local function deprecated_parameter(name)
	if true ~= Page_in_deprecated_cat then	-- if we haven't been here before then set a 
		Page_in_deprecated_cat=true;		-- sticky flag so that if there are more than one deprecated parameter the category is added only once
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end

--[[--------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Call this function for chapter titles, for website titles, etc; not for book titles.

]]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	
	cap, cap2 = str:match (&quot;^([\&quot;\'])([^\'].+)&quot;);								-- match leading double or single quote but not double single quotes
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-left'], {cap, cap2});
	end

	cap, cap2 = str:match (&quot;^(.+[^\'])([\&quot;\'])$&quot;)
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-right'], {cap, cap2});
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

At this writing, only |script-title= is supported.  It is anticipated that additional parameters will be created to use this function.

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, {'ar', 'bg', 'bs', 'dv', 'el', 'fa', 'hy', 'ja', 'ka', 'ko', 'ku', 'he', 'ps', 'ru', 'sd', 'sr', 'th', 'uk', 'ug', 'yi', 'zh'}) then
				add_prop_cat ('script_name', {name, lang})
			else
				add_prop_cat ('script')
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		str = substitute( msg, {str} );											-- including template text
		return str;
	else
		return substitute( cfg.messages[key], {str} );
	end		
end

--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider
Generates an error if more than one match is present.

]]

local function select_one( args, possible, error_condition, index )
	local value = nil;
	local selected = '';
	local error_list = {};
	
	if index ~= nil then index = tostring(index); end
	
	-- Handle special case of &quot;#&quot; replaced by empty string
	if index == '1' then
		for _, v in ipairs( possible ) do
			v = v:gsub( &quot;#&quot;, &quot;&quot; );
			if is_set(args[v]) then
				if value ~= nil and selected ~= v then
					table.insert( error_list, v );
				else
					value = args[v];
					selected = v;
				end
			end
		end		
	end
	
	for _, v in ipairs( possible ) do
		if index ~= nil then
			v = v:gsub( &quot;#&quot;, index );
		end
		if is_set(args[v]) then
			if value ~= nil and selected ~=  v then
				table.insert( error_list, v );
			else
				value = args[v];
				selected = v;
			end
		end
	end
	
	if #error_list &gt; 0 then
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap_style ('parameter', k);
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap_style ('parameter', selected);
		table.insert( z.message_tail, { set_error( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end

--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the three chapter parameters: |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (chapter, transchapter, chapterurl, chapter_url_source)
	local chapter_error = '';
	
	if not is_set (chapter) then
		chapter = '';															-- just to be safe for concatenation
		if is_set (transchapter) then
			chapter = wrap_style ('trans-quoted-title', transchapter);
			chapter_error = &quot; &quot; .. set_error ('trans_missing_chapter');
		end
		if is_set (chapterurl) then
			chapter = external_link (chapterurl, chapter, chapter_url_source);	-- adds bare_url_missing_title error if appropriate
		end
		return chapter .. chapter_error;
	else																		-- here when chapter is set
		chapter = kern_quotes (chapter);										-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
		chapter = wrap_style ('quoted-title', chapter);
		if is_set (transchapter) then
			transchapter = wrap_style ('trans-quoted-title', transchapter);
			chapter = chapter .. ' ' .. transchapter;
		end
		if is_set (chapterurl) then
			chapter = external_link (chapterurl, chapter);						-- adds bare_url_missing_title error if appropriate
		end
	end
	return chapter;
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
]]

local function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end


-- Formats a wiki style internal link
local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s*%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s*%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end

--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in check_isbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end	-- isbn13 begins with 978 or 979
		isbn_str = { isbn_str:byte(1, len) };
		for i, v in ipairs( isbn_str ) do
			temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
		end
		return temp % 10 == 0;
	end
end

--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link = handler.link,
		label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
		encode=handler.encode, separator = handler.separator}) .. err_cat;
end

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end

--[[
lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--[[
Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of the LCCN dictates the character type of the first 1-3 characters; the
rightmost eight are always digits. http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end

--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.

-- DOI names contain two parts: prefix and suffix separated by a forward slash.
--  Prefix: directory indicator '10.' followed by a registrant code
--  Suffix: character string of any length chosen by the registrant

-- This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes,
-- or, if it ends with a period or a comma, this function will emit a bad_doi error message.

-- DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
-- and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely if ever used in doi names.

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);					-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode}) .. 
			' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end

--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end

--[[--------------------------&lt; C L E A N _ I S B N &gt;----------------------------------------------------------

Removes irrelevant text and dashes from ISBN number
Similar to that used for Special:BookSources

]]

local function clean_isbn( isbn_str )
	return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]
local function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other lua magic pattern characters
	return argument;
end

--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	while true do
		if argument:match (&quot;%'%'%'%'%'&quot;) then									-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:match (&quot;%'%'%'%'&quot;) then									-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:match (&quot;%'%'%'&quot;) then									-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:match (&quot;%'%'&quot;) then										-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end

--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...
]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end

--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
local function remove_wiki_link( str )
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end

-- Converts a hyphen to a dash
local function hyphen_to_dash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end

--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if comp:sub(1,1) == duplicate_char then								-- is first charactier same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for th
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = str:sub(-1,-1);										-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = str:sub(1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = str:sub(1, -4) .. &quot;''&quot;;							-- remove them and add back ''
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then		-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then		-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then			-- if last two chars of str are sepc] external link
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;'']&quot; then		-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then				-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = str:sub(1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end		-- if duplicate_char not a letter then escape it
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )			-- remove duplicate_char if it follows html markup
					else
						value = value:sub( 2, -1 );								-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end  

--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

At the time of this writing, I had to write the 'if nil == mw.ustring.find ...' test ouside of the code editor and past it here
because the code editor gets confused between character insertion point and cursor position.

]]

local function is_good_vanc_name (last, first)
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]*$&quot;) then
		if true ~= Page_in_vanc_error_cat then									-- if we haven't been here before then set a sticky flag
			Page_in_vanc_error_cat=true;										-- so that if there are more than one error the category is added only once
			table.insert( z.message_tail, { set_error( 'vancouver', {}, true ) } );
		end
		return false;															-- not a string of latin characters; Vancouver required Romanization
	end;
	return true;
end

--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  This form is not
currently supported by this code so correctly formed names like Smith JL 2nd are converted to Smith J2. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	if mw.ustring.match(first, &quot;^%u%u$&quot;) then return first end;					-- when first contains just two upper-case letters, nothing to do
	local initials = {}
	local i = 0;																-- counter for number of initials
	for word in mw.ustring.gmatch(first, &quot;[^%s%.%-]+&quot;) do						-- names separated by spaces, hyphens, or periods
		table.insert(initials, mw.ustring.sub(word,1,1))						-- Vancouver format does not include full stops.
		i = i + 1;																-- bump the counter 
		if 2 &lt;= i then break; end												-- only two initials allowed in Vancouver system; if 2, quit
	end
	return table.concat(initials)												-- Vancouver format does not include spaces.
end

--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = ',';																-- name-list separator between authors is a comma
		namesep = ' ';															-- last/first separator is a space
	else
		sep = ';'																-- name-list separator between authors is a semicolon
		namesep = ', '															-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if is_good_vanc_name (one, first) then					-- and name is all Latin characters
							first = reduce_to_initials(first)						-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first 
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;		-- link author/editor if this page is not the author's/editor's page
				end

				if is_set(person.link) and ((nil ~= person.link:find(&quot;//&quot;)) or (nil ~= person.link:find(&quot;[%[%]]&quot;))) then
					one = one .. &quot; &quot; .. set_error( 'bad_authorlink' ) end	-- url or wikilink in author link;
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;
		end
		text[#text] = nil; 
	end
	
	local result = table.concat(text) -- construct list
	if etal then 
		local etal_text = cfg.messages['et al'];
		result = result .. &quot; &quot; .. etal_text;
	end
	
	return result, count
end

--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

]]

local function anchor_id( options )
	local id = table.concat( options );											-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end

--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter
	local pattern = &quot;,? *'*[Ee][Tt] *[Aa][Ll][%.']*$&quot;							-- variations on the 'et al' theme
	
	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary

	while true do
		last = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		local name = tostring(last);
		if name:match (pattern) then											-- varients on et al.
			last = name:gsub (pattern, '');										-- if found, remove
			etal = true;
		end
		name = tostring(first);
		if name:match (pattern) then											-- varients on et al.
			first = name:gsub (pattern, '');									-- if found, remove
			etal = true;
		end

		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 == count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			names[n] = {last = last, first = first, link = link, mask = mask};	-- add this name to our names list
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	if true == etal then
		add_maint_cat ('etal');
	end
	return names, etal;															-- all done, return our list of names
end

-- Populates ID table from arguments using configuration settings
local function extract_ids( args )
	local id_list = {};
	for k, v in pairs( cfg.id_handlers ) do	
		v = select_one( args, v.parameters, 'redundant_parameters' );
		if is_set(v) then id_list[k] = v; end
	end
	return id_list;
end

--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs and turns it into a table of formatted ID outputs.

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end
  

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end
	
	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if is_set(data.Chapter) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
	elseif is_set(data.Periodical) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
		if 'arxiv' == class then
			OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;								-- cite arxiv
		else
			OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
		end
		OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	else
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
	end
	
	OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
	OCinSoutput[&quot;rft.date&quot;] = data.Date;
	OCinSoutput[&quot;rft.series&quot;] = data.Series;
	OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
	OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
	OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
	OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
	OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
	
	for k, v in pairs( data.ID_list ) do
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
	
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = v.last, v.first;
		if k == 1 then
			if is_set(last) then
				OCinSoutput[&quot;rft.aulast&quot;] = last;
			end
			if is_set(first) then 
				OCinSoutput[&quot;rft.aufirst&quot;] = first;
			end
		end
		if is_set(last) and is_set(first) then
			OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
		elseif is_set(last) then
			OCinSoutput[&quot;rft.au&quot;] = last;
		end
	end
	
	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 code.  Handles the special case that is Norwegian where
ISO639-1 code 'no' is mapped to language name 'Norwegian Bokmål' by Extention:CLDR.

Returns the language name and associated ISO639-1 code.  Because case of the source may be incorrect or different from the case that Wikimedia
uses, the name comparisons are done in lower case and when a match is found, the Wikimedia version (assumed to be correct) is returned along
with the code.  When there is no match, we return the original language name string.

mw.language.fetchLanguageNames() will return a list of languages that aren't part of ISO639-1. Names that aren't ISO639-1 but that are included
in the list will be found if that name is provided in the |language= parameter.  For example, if |language=Samaritan Aramaic, that name will be
found with the associated code 'sam', not an ISO639-1 code.  When names are found and the associated code is not two characters, this function
returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang)
	if 'norwegian' == lang:lower() then											-- special case related to Wikimedia remap of code 'no' at Extension:CLDR
		return 'Norwegian', 'no';												-- Make sure rendered version is properly capitalized
	end
	
	local languages = mw.language.fetchLanguageNames('en', 'all')				-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() then												-- ISO639-1 codes only
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the ISO639-1 code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for ISO639-1 code
end

--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Get language name from ISO639-1 code value provided.  If a code is valid use the returned name; if not, then use the value that was provided with the language parameter.

There is an exception.  There are three ISO639-1 codes for Norewegian language variants.  There are two official variants: Norwegian Bokmål (code 'nb') and
Norwegian Nynorsk (code 'nn').  The third, code 'no',  is defined by ISO639-1 as 'Norwegian' though in Norway this is pretty much meaningless.  However, it appears
that on enwiki, editors are for the most part unaware of the nb and nn variants (compare page counts for these variants at Category:Articles with non-English-language external links.

Because Norwegian Bokmål is the most common language variant, Media wiki has been modified to return Norwegian Bokmål for ISO639-1 code 'no'. Here we undo that and
return 'Norwegian' when editors use |language=no.  We presume that editors don't know about the variants or can't descriminate between them.

See Help talk:Citation Style_1#An ISO 639-1 language name test

When |language= contains a valid ISO639-1 code, the page is assigned to the category for that code: Category:Norwegian-language sources (no) if
the page is a mainspace page and the ISO639-1 code is not 'en'.  Similarly, if the  parameter is |language=Norwegian, it will be categorized in the same way.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are separated from each other by commas.

]]

local function language_parameter (lang, namespace)
	local code;																	-- the ISO639-1 two character code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=
	local unrec_cat = false														-- flag so that we only add unrecognized category once
	
	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list
	
	for _, lang in ipairs (names_table) do										-- reuse lang
		if 0 == namespace and (('en' == lang:lower()) or ('english' == lang:lower())) then
			add_maint_cat ('english');
		end
	
		if 2 == lang:len() then													-- ISO639-1 language code are 2 characters (fetchLanguageName also supports 3 character codes)
			name = mw.language.fetchLanguageName( lang:lower(), &quot;en&quot; );			-- get ISO 639-1 language name if Language is a proper code
		end
	
		if is_set (name) then													-- if Language specified a valid ISO639-1 code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang);								-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then
			if 'no' == code then name = 'Norwegian' end;						-- override wikimedia when code is 'no'
			if 0 == namespace and 'en' ~= code then								-- is this page main / article space and English not the language?
				add_prop_cat ('foreign_lang_source', {name, code})
			end
		elseif false == unrec_cat then
			unrec_cat = true;													-- only add this category once
			add_maint_cat (unknown_lang);
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, ' and ')							-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		language_list[code] = 'and ' .. language_list[code];					-- prepend last name with 'and&lt;space&gt;'
		name = table.concat (language_list, ', ')								-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
	end
	return (&quot; &quot; .. wrap_msg ('language', name));		-- wrap with '(in ...)'
end

--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = '.';																-- terminate the rendered citation with a period
	end
	return '.', ps;																-- separator is a full stop
end

--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = '';																-- make sure it isn't nil
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return ',', ps, ref;														-- separator is a comma
end

--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		if is_set (mode) then
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'mode', mode}, true ) } );		-- add error message
		end
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end

--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extension, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf[%?#]?') or url:match ('%.PDF[%?#]?');
end

--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format:upper());							-- force upper case, add leading space, parenthases, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end

--[[--------------------------&lt; G E T _ D I S P L A Y _ A U T H O R S _ E D I T O R S &gt;------------------------

Returns a number that may or may not limit the length of the author or editor name lists.

When the value assigned to |display-authors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-authors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

]]

local function get_display_authors_editors (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count and 'authors' == list_name then	-- AUTHORS ONLY		-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_auth_ed', list_name);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset
		end
	elseif 'authors' == list_name then		-- AUTHORS ONLY	need to clear implicit et al category
		max = count + 1;														-- number of authors + 1
	end
	
	return max, etal;
end

--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation
formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple
	aliases to single internal variable.
	]]
	local A = argument_wrapper( args );

	local i 
	local PPrefix = A['PPrefix']
	local PPPrefix = A['PPPrefix']
	if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
	
	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local Authors = A['Authors'];
	local author_etal;
	local a, author_etal = extract_names( args, 'AuthorList' );

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];
	local Editors = A['Editors'];
	local editor_etal;
	local e, editor_etal = extract_names( args, 'EditorList' );

	local NameListFormat = A['NameListFormat'];									-- replaces |author-format= and |editor-format=
	if is_set (NameListFormat) and ('vanc' ~= NameListFormat) then											-- only accepted value for this parameter is 'vanc'
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {'name-list-format', NameListFormat}, true ) } );	-- not vanc so add error message
		NameListFormat = '';													-- set to empty string
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
	local Chapter = A['Chapter'];
	local ChapterLink = A['ChapterLink'];										-- deprecated
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];
	local ArchiveURL = A['ArchiveURL'];
	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];

	local Series = A['Series'];
	local Volume = A['Volume'];
	local Issue = A['Issue'];
	local Position = '';
	local Page = A['Page'];
	local Pages = hyphen_to_dash( A['Pages'] );	
	local At = A['At'];

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
	local SubscriptionRequired = A['SubscriptionRequired'];
	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local ArchiveDate = A['ArchiveDate'];
	local Agency = A['Agency'];
	local DeadURL = A['DeadURL']
	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
	local no_tracking_cats = A['NoTracking'];

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local use_lowercase;								-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();		-- also used for COinS and for language
	local anchor_year;									-- used in the CITEREF identifier
	local COinS_date;									-- used in the COinS metadata

-- set default parameter values defined by |mode= parameter.  If |mode= is empty or omitted, use CitationClass to set these values
	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (A['Mode']:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

-- check for extra |page=, |pages= or |at= parameters. 
	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Page = Page .. &quot; &quot; .. set_error('extra_pages');	-- add error message
			Pages = '';										-- unset the others
			At = '';
		end
	elseif is_set(Pages) then
		if is_set(At) then
			Pages = Pages .. &quot; &quot; .. set_error('extra_pages');	-- add error messages
			At = '';											-- unset
		end
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped
	|url maps to |chapterurl when |title is remapped

All other combinations of |encyclopedia, |title, and |article are not modified
TODO: script-title to script-chapter if and when we support script-chapter
]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then					-- Periodical is set when |encyclopedia is set
			if is_set(Title) then
				if not is_set(Chapter) then
					Chapter = Title;				-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					TransChapter = TransTitle;
					ChapterURL = URL;
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';				-- redundant so unset
					TransTitle = '';				-- redundant so unset
					URL = '';						-- redundant so unset
					Format = '';					-- redundant so unset
				end
			else									-- |title not set
				Title = Periodical;					-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';					-- redundant so unset
			end
		end
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then	-- special case for cite techreport
		if is_set(Issue) then						-- cite techreport uses 'number', which other citations aliase to 'issue'
			if not is_set(ID) then					-- can we use ID for the &quot;number&quot;?
				ID = Issue;							-- yes, use it
				Issue = &quot;&quot;;							-- unset Issue so that &quot;number&quot; isn't duplicated in the rendered citation or COinS metadata
			else									-- can't use ID so emit error message
				ID = ID .. &quot; &quot; .. set_error('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Others) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Others;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Others;
			end
		else
			Others = '(Interview)';
		end
	end

-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local Began = A['Began'];												-- these two are deprecated because the module understands date ranges
		local Ended = A['Ended'];
		local SeriesLink = A['SeriesLink'];
		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};

																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) then												-- promote airdate or Began/Ended to date
			if is_set (AirDate) then
				Date = AirDate;
			elseif is_set (Began) then											-- deprecated
				if Began:match('%s') or Ended:match('%s') then					-- so we don't create errors: if either has spaces then
					Date = Began .. ' – ' .. Ended;								-- use spaced ndash as separator
				else
					Date = Began .. '–' .. Ended;								-- elsewise no spaces
				end
			end
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('series', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = '[[' .. ChapterLink .. '|' .. Chapter .. ']]';		-- ok to wikilink
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = '[[' .. ChapterLink .. '|' .. Series .. ']]';			-- series links with ChapterLink (episodelink -&gt; TitleLink -&gt; ChapterLink) ugly
			end
			URL = '';															-- unset
			TransTitle = '';													-- unset
			
		else																	-- now oddities that are cite serial
			Issue = '';														-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = '[[' .. SeriesLink .. '|' .. Series .. ']]';
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
-- end of {{cite episode}} stuff

-- Account for the oddities that are {{cite arxiv}}, before generation of COinS data.
	if 'arxiv' == config.CitationClass then
		if not is_set (ID_list['ARXIV']) then									-- |arxiv= or |eprint= required for cite arxiv
			table.insert( z.message_tail, { set_error( 'arxiv_missing', {}, true ) } );		-- add error message
		end
		if first_set (AccessDate, At, Chapter, Format, Page, Pages, Periodical, PublisherName, URL,	-- a crude list of parameters that are not supported by cite arxiv
			ID_list['ASIN'], ID_list['BIBCODE'], ID_list['DOI'], ID_list['ISBN'], ID_list['ISSN'],
			ID_list['JFM'], ID_list['JSTOR'], ID_list['LCCN'], ID_list['MR'], ID_list['OCLC'], ID_list['OL'],
			ID_list['OSTI'], ID_list['PMC'], ID_list['PMID'], ID_list['RFC'], ID_list['SSRN'], ID_list['USENETID'], ID_list['ZBL']) then
				table.insert( z.message_tail, { set_error( 'arxiv_params_not_supported', {}, true ) } );		-- add error message

				AccessDate= '';													-- set these to empty string; not supported in cite arXiv
				PublisherName = '';												-- (if the article has been published, use cite journal, or other)
				Chapter = '';
				URL = '';
				Format = '';
				Page = ''; Pages = ''; At = '';
		end
		Periodical = 'arXiv';													-- set to arXiv for COinS; after that, must be set to empty string
	end

-- handle type parameter for those CS1 citations that have default values

	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
		TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot;;									-- display it in parentheses
	end

-- legacy: promote concatenation of |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set (Date) then
		Date = Year;						-- promote Year to Date
		Year = nil;							-- make nil so Year as empty string isn't used for CITEREF
		if is_set(Date) then
			local Month = A['Month'];
			if is_set(Month) then
				Date = Month .. &quot; &quot; .. Date;
			end
		elseif is_set(PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;			-- promote PublicationDate to Date
			PublicationDate = '';			-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end	-- if PublicationDate is same as Date, don't display in rendered citation

--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	do	-- create defined block to contain local variables error_message and mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		anchor_year, COinS_date, error_message = dates({['accessdate']=AccessDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
			['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end

		if is_set(error_message) then
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end
	end	-- end of do

-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);											-- 

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
		table.insert( z.message_tail, { set_error( 'citation_missing_title', {}, true ) } );
	end
	
	if 'none' == Title and is_set(Periodical) and not (( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia))) then								-- special case
		Title = '';																-- set title to empty string
		add_maint_cat ('untitled');
	end

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	
	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = Periodical,
		['Chapter'] = strip_apostrophe_markup (coins_chapter),					-- Chapter stripped of bold / italic wikimarkup
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = first_set(COinS_date, Date),		-- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here?  Should we be including invalid dates in metadata?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set(Sheet, Sheets, Page, Pages, At)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set( URL, ChapterURL ),
		['Authors'] = a,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

-- Account for the oddities that are {{cite arxiv}}, AFTER generation of COinS data.
	if 'arxiv' == config.CitationClass then										-- we have set rft.jtitle in COinS to arXiv, now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in cite arxiv; if article has been published, use cite journal
	end

-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = '[[Newsgroup]]:&amp;nbsp;' ..  external_link( 'news:' .. PublisherName, PublisherName );
		end
	end



	-- Now perform various field 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.
	do																			-- do-block to limit scope of LastFirstAuthors
		local LastFirstAuthors;
		local Maximum = A['DisplayAuthors'];

		Maximum , author_etal = get_display_authors_editors (Maximum, #a, 'authors', author_etal);

		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text				-- get current page name so that we don't wikilink to it via authorlinkn
		};
		
		-- If the coauthor field is also used, prevent ampersand and et al. formatting.
		if is_set(Coauthors) then
			control.lastauthoramp = nil;
			control.maximum = #a + 1;
		end
		
		LastFirstAuthors = list_people(control, a, author_etal);

		if is_set (Authors) then
			if is_set (LastFirstAuthors) then									-- if both author name styles
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'authors') .. ' and ' .. wrap_style ('parameter', 'last')}, true ) } );		-- add error message
				Authors = LastFirstAuthors;										-- TODO: is this correct or should we use |authors= instead?
			end
		else
			Authors = LastFirstAuthors;											-- either an author name list or an empty string
		end
	end																			-- end of do

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { set_error('coauthors_missing_author', {}, true) } );	-- emit error message
	end

	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	if not is_set(Editors) then
		local Maximum = A['DisplayEditors'];

		Maximum , editor_etal = get_display_authors_editors (Maximum, #e, 'editors', editor_etal);
		-- Preserve old-style implicit et al.
		if not is_set(Maximum) and #e == 4 then 
			Maximum = 3;
			table.insert( z.message_tail, { set_error('implict_etal_editor', {}, true) } );
		end

		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text				-- get current page name so that we don't wikilink to it via editorlinkn
		};

		Editors, EditorCount = list_people(control, e, editor_etal);
		if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then			-- only one editor displayed but includes etal then 
			EditorCount = 2;													-- spoof to display (eds.) annotation
		end
	else
		EditorCount = 1;
	end

-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

	if  not is_set(URL) then --and
--		not is_set(ArchiveURL) then --and										-- prevents format_missing_url error from registering
--		not is_set(ConferenceURL) and											-- TODO: keep this here? conference as part of cite web or cite podcast?
--		not is_set(TranscriptURL) then											-- TODO: remove? |transcript-url= and |transcript= has separate test
		
		-- Test if cite web or cite podcast |url= is missing or empty 
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then	
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- Test if accessdate is given without giving a URL
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when the others are not set; TODO: move this to a separate test?
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalFormat;											-- TODO: swap chapter and title here so that archive applies to most specific if both are set?
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalFormat = Format;											-- and original |format=
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
			end
		elseif is_set (ChapterURL) then 										-- URL not set so if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalFormat = ChapterFormat;										-- and original |format=
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
			end
		end
	end

	if in_array(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;journal&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;, &quot;newsgroup&quot;, 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			if is_set (Chapter) or is_set (TransChapter) or is_set (ChapterURL)then	-- chapter parameters not supported for these citation types
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {}, true ) } );		-- add error message
				Chapter = '';														-- set to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
			end
	else																		-- otherwise, format chapter / article title
		Chapter = format_chapter_title (Chapter, TransChapter, ChapterURL, ChapterURLorigin);
		if is_set (Chapter) then
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;
			end
			Chapter = Chapter .. ChapterFormat .. sepc .. ' ';
		end
	end

	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if in_array(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;journal&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;, &quot;newsgroup&quot;, &quot;mailinglist&quot;, 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
	
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title' );
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then 
			Title = external_link( URL, Title ) .. TransError .. Format;
			URL = &quot;&quot;;
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		if is_set(Minutes) then
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			local Time = A['Time'];
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end
	
	if not is_set(Page) then
		if is_set(Pages) then
			if is_set(Periodical) and
				not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
				Pages = &quot;: &quot; .. Pages;
			elseif tonumber(Pages) ~= nil then
				Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
			else
				Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
			end
		end
	else
		if is_set(Periodical) and
			not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
			Page = &quot;: &quot; .. Page;
		else
			Page = sepc ..&quot; &quot; .. PPrefix .. Page;
		end
	end

	if 'map' == config.CitationClass then										-- cite map oddity done after COinS call (and with other in-source locators)
		if is_set (Sheet) or is_set (Sheets) then
			local err_msg1 = 'sheet=, &amp;#124;sheets';							-- default error message in case any of page pages or at are set
			local err_msg2;
			if is_set (Page) or is_set (Pages) or is_set (At) then				-- are any set?
				err_msg2 = 'page=, &amp;#124;pages=, &amp;#124;at';						-- a generic error message
				Page = ''; Pages = ''; At = '';
			elseif is_set (Sheet) and is_set (Sheets) then						-- if both are set make error message
				err_msg1 = 'sheet';
				err_msg2 = 'sheets';
			end
			if is_set (err_msg2) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', err_msg1) .. ' and ' .. wrap_style ('parameter', err_msg2)}, true ) } );		-- add error message
			end
			if not is_set (Sheet) then											-- do sheet static text and formatting; Sheet has priority over Sheets if both provided
				if is_set (Sheets) then
					if is_set (Periodical) then
						Sheet = &quot;: Sheets &quot; .. Sheets;							-- because Sheet has priority, no need to support both later on
					else
						Sheet = sepc .. &quot; Sheets &quot; .. Sheets;
					end
				end
			else
				if is_set (Periodical) then
					Sheet = &quot;: Sheet &quot; .. Sheet;
				else
					Sheet = sepc .. &quot; Sheet &quot; .. Sheet;
				end
			end
		end
	end

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language, this_page.namespace);			-- format, categories (article namespace only), name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	Edition = is_set(Edition) and (&quot; &quot; .. wrap_msg ('edition', Edition)) or &quot;&quot;;
	Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc ..&quot; &quot; .. Volume;
		  else Volume = &quot; &lt;b&gt;&quot; .. hyphen_to_dash(Volume) .. &quot;&lt;/b&gt;&quot;;
		end
	end

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

--[[
Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
note is displayed. There are no error messages for this condition.

]]
	if in_array(SubscriptionRequired:lower(), {'yes', 'true', 'y'}) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif in_array(RegistrationRequired:lower(), {'yes', 'true', 'y'}) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if 'citation', lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text
																				-- neither of these work; don't know why; it seems that substitute() isn't being called	
		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
			Quote = Quote:sub(2,-2);
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- CS1 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text,
				{ external_link( OriginalURL, cfg.messages['original'] ) .. OriginalFormat, ArchiveDate } );	-- format already styled
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'] ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower() ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin );
	end

	local Publisher;
	if is_set(Periodical) and
		not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap_msg ('published', PublicationDate);
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap_msg ('published', PublicationDate) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
			Language, Edition, Publisher, Agency, Volume, Issue}, sepc );
		
	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume, Issue}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Transcript, Language, Edition, Publisher}, sepc );
	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Issue, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Sheet .. Page .. Pages .. At;
	
	if is_set(Authors) then
		if is_set(Coauthors) then
			local sep = '; ';
			if 'vanc' == NameListFormat then
				sep = ', ';
			end
			Authors = Authors .. sep .. Coauthors;
		end
		if is_set(Date) then
			Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		elseif string.sub(Authors,-1,-1) == sepc then
			Authors = Authors .. &quot; &quot;
		else
			Authors = Authors .. sepc .. &quot; &quot;
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			if (sepc ~= '.') then in_text = in_text:lower() end
			Editors = in_text .. Editors .. post_text;
			if (string.sub(Editors,-1,-1) == sepc) or (string.sub(Editors,-3,-1) == sepc .. ']]') then	-- if last editor name ends with sepc char
				Editors = Editors .. &quot; &quot;;										-- don't add another
			else
				Editors = Editors .. sepc .. &quot; &quot;								-- otherwise terninate the editor list
			end
		end
		text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
		text = safe_join( {text, pgtext, idcommon}, sepc );
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon}, sepc );
		text = safe_join( {text, pgtext, idcommon}, sepc );
	else
		if is_set(Date) then
			if ( string.sub(tcommon,-1,-1) ~= sepc )
			  then Date = sepc ..&quot; &quot; .. Date .. OrigYear
			  else Date = &quot; &quot; .. Date .. OrigYear
			end
		end
		if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon}, sepc );
			text = safe_join( {text, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date}, sepc );
			text = safe_join( {text, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;span/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = &quot;citation &quot; .. config.CitationClass;
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
		local id = Ref
		if ( &quot;harv&quot; == Ref ) then
			local names = {} --table of last names &amp; year
			if #a &gt; 0 then
				for i,v in ipairs(a) do 
					names[i] = v.last 
					if i == 4 then break end
				end
			elseif #e &gt; 0 then
				for i,v in ipairs(e) do 
					names[i] = v.last 
					if i == 4 then break end				
				end
			end
			names[ #names + 1 ] = first_set(Year, anchor_year);	-- Year first for legacy citations and for YMD dates that require disambiguation
			id = anchor_id(names)
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then 
		text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	else
		text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	end		

	local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
	
	-- Note: Using display: none on then COinS span breaks some clients.
	local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
	text = text .. OCinS;
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. error_comment( v[1], v[2] );
				else
					text = text .. error_comment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end

	if #z.maintenance_cats ~= 0 then
		text = text .. ' &lt;span class=&quot;citation-comment&quot; style=&quot;display:none; color:#33aa33&quot;&gt;';
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. v .. ' ([[:Category:' .. v ..'|link]])';
		end
		text = text .. '&lt;/span&gt;';	-- maintenance mesages (realy just the names of the categories for now)
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
	local pframe = frame:getParent()
	local validation;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of Configuration and Whitelist and ...
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');	-- ... sandbox version of date validation code

	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of Configuration and Whitelist and ...
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		validation = require ('Module:Citation/CS1/Date_validation');			-- ... live version of date validation code
	end

	dates = validation.dates;													-- imported functions
	year_date_check = validation.year_date_check;

	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if #suggestions == 0 then
						suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
					end
					if suggestions[ k:lower() ] ~= nil then
						error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
					else
						error_text, error_state = set_error( 'parameter_ignored', {k}, true );
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	
	
	return citation0( config, args)
end

return z</text>
      <sha1>tgkmkdmhs7m7zd0gulwv72mzhsxlqj6</sha1>
    </revision>
    <revision>
      <id>4690</id>
      <parentid>4689</parentid>
      <timestamp>2015-04-18T10:10:25Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <minor />
      <comment>script-title bug fix;</comment>
      <origin>4690</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="131804" sha1="f2q6uujdm4pgd5uooc1n6ohk20zf55a" xml:space="preserve">
local z = {
	error_categories = {};		-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};		-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};		-- for categorizing citations based on certain properties, language of source for instance
}

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]
local dates, year_date_check	-- functions in Module:Citation/CS1/Date_validation

local cfg = {};					-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};			-- talbe of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist

--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.
This function is global because it is called from both this module and from Date validation

]]
function is_set( var )
	return not (var == nil or var == '');
end

--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

First set variable or nil if none

]]

local function first_set(...)
	local list = {...};
	for _, var in pairs(list) do
		if is_set( var ) then
			return var;
		end
	end
end

--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end

--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]
local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end

--[[--------------------------&lt; S E T _ E R R O R &gt;--------------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

]]
local function set_error( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if in_array( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return error_comment( message, error_state.hidden );
end

--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maintenance_cats using names from the configuration file with additional text if any.

]]

local function add_maint_cat (key, arguments)
	table.insert( z.maintenance_cats, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
end

--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

]]

local function add_prop_cat (key, arguments)
	table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));		-- make name then add to table
end

--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string is valid.

At present the only check is whether the string appears to be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well formed.

]]

local function check_url( url_str )
	return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;		-- Protocol-relative or URL scheme
end

--[[--------------------------&lt; S A F E _ F O R _ I T A L I C S &gt;----------------------------------------------

Protects a string that will be wrapped in wiki italic markup '' ... ''

Note: We cannot use &lt;i&gt; for italics, as the expected behavior for italics specified by ''...'' in the title is that
they will be inverted (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and '' tend to interact
poorly under Mediawiki's HTML tidy.

]]

local function safe_for_italics( str )
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end

--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

local function wrap_style (key, str)
	if not is_set( str ) then
		return &quot;&quot;;
	elseif in_array( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safe_for_italics( str );
	end

	return substitute( cfg.presentation[key], {str} );
end

--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source )
	local error_str = &quot;&quot;;
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
	end
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url( label ), &quot;]&quot;, error_str });
end

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

--[[
Categorize and emit an error message when the citation contains one or more deprecated parameters.  Because deprecated parameters (currently |month=,
|coauthor=, and |coauthors=) aren't related to each other and because these parameters may be concatenated into the variables used by |date= and |author#= (and aliases)
details of which parameter caused the error message are not provided.  Only one error message is emitted regardless of the number of deprecated parameters in the citation.
]]
local function deprecated_parameter(name)
	if true ~= Page_in_deprecated_cat then	-- if we haven't been here before then set a 
		Page_in_deprecated_cat=true;		-- sticky flag so that if there are more than one deprecated parameter the category is added only once
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end

--[[--------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Call this function for chapter titles, for website titles, etc; not for book titles.

]]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	
	cap, cap2 = str:match (&quot;^([\&quot;\'])([^\'].+)&quot;);								-- match leading double or single quote but not double single quotes
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-left'], {cap, cap2});
	end

	cap, cap2 = str:match (&quot;^(.+[^\'])([\&quot;\'])$&quot;)
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-right'], {cap, cap2});
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

At this writing, only |script-title= is supported.  It is anticipated that additional parameters will be created to use this function.

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, {'ar', 'bg', 'bs', 'dv', 'el', 'fa', 'hy', 'ja', 'ka', 'ko', 'ku', 'he', 'ps', 'ru', 'sd', 'sr', 'th', 'uk', 'ug', 'yi', 'zh'}) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				add_prop_cat ('script')
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		str = substitute( msg, {str} );											-- including template text
		return str;
	else
		return substitute( cfg.messages[key], {str} );
	end		
end

--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider
Generates an error if more than one match is present.

]]

local function select_one( args, possible, error_condition, index )
	local value = nil;
	local selected = '';
	local error_list = {};
	
	if index ~= nil then index = tostring(index); end
	
	-- Handle special case of &quot;#&quot; replaced by empty string
	if index == '1' then
		for _, v in ipairs( possible ) do
			v = v:gsub( &quot;#&quot;, &quot;&quot; );
			if is_set(args[v]) then
				if value ~= nil and selected ~= v then
					table.insert( error_list, v );
				else
					value = args[v];
					selected = v;
				end
			end
		end		
	end
	
	for _, v in ipairs( possible ) do
		if index ~= nil then
			v = v:gsub( &quot;#&quot;, index );
		end
		if is_set(args[v]) then
			if value ~= nil and selected ~=  v then
				table.insert( error_list, v );
			else
				value = args[v];
				selected = v;
			end
		end
	end
	
	if #error_list &gt; 0 then
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap_style ('parameter', k);
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap_style ('parameter', selected);
		table.insert( z.message_tail, { set_error( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end

--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the three chapter parameters: |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (chapter, transchapter, chapterurl, chapter_url_source)
	local chapter_error = '';
	
	if not is_set (chapter) then
		chapter = '';															-- just to be safe for concatenation
		if is_set (transchapter) then
			chapter = wrap_style ('trans-quoted-title', transchapter);
			chapter_error = &quot; &quot; .. set_error ('trans_missing_chapter');
		end
		if is_set (chapterurl) then
			chapter = external_link (chapterurl, chapter, chapter_url_source);	-- adds bare_url_missing_title error if appropriate
		end
		return chapter .. chapter_error;
	else																		-- here when chapter is set
		chapter = kern_quotes (chapter);										-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
		chapter = wrap_style ('quoted-title', chapter);
		if is_set (transchapter) then
			transchapter = wrap_style ('trans-quoted-title', transchapter);
			chapter = chapter .. ' ' .. transchapter;
		end
		if is_set (chapterurl) then
			chapter = external_link (chapterurl, chapter);						-- adds bare_url_missing_title error if appropriate
		end
	end
	return chapter;
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
]]

local function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end


-- Formats a wiki style internal link
local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s*%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s*%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end

--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in check_isbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end	-- isbn13 begins with 978 or 979
		isbn_str = { isbn_str:byte(1, len) };
		for i, v in ipairs( isbn_str ) do
			temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
		end
		return temp % 10 == 0;
	end
end

--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link = handler.link,
		label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
		encode=handler.encode, separator = handler.separator}) .. err_cat;
end

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end

--[[
lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--[[
Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of the LCCN dictates the character type of the first 1-3 characters; the
rightmost eight are always digits. http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end

--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.

-- DOI names contain two parts: prefix and suffix separated by a forward slash.
--  Prefix: directory indicator '10.' followed by a registrant code
--  Suffix: character string of any length chosen by the registrant

-- This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes,
-- or, if it ends with a period or a comma, this function will emit a bad_doi error message.

-- DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
-- and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely if ever used in doi names.

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);					-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode}) .. 
			' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end

--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end

--[[--------------------------&lt; C L E A N _ I S B N &gt;----------------------------------------------------------

Removes irrelevant text and dashes from ISBN number
Similar to that used for Special:BookSources

]]

local function clean_isbn( isbn_str )
	return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]
local function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other lua magic pattern characters
	return argument;
end

--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	while true do
		if argument:match (&quot;%'%'%'%'%'&quot;) then									-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:match (&quot;%'%'%'%'&quot;) then									-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:match (&quot;%'%'%'&quot;) then									-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:match (&quot;%'%'&quot;) then										-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end

--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...
]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end

--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
local function remove_wiki_link( str )
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end

-- Converts a hyphen to a dash
local function hyphen_to_dash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end

--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if comp:sub(1,1) == duplicate_char then								-- is first charactier same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for th
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = str:sub(-1,-1);										-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = str:sub(1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = str:sub(1, -4) .. &quot;''&quot;;							-- remove them and add back ''
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then		-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then		-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then			-- if last two chars of str are sepc] external link
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;'']&quot; then		-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then				-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = str:sub(1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end		-- if duplicate_char not a letter then escape it
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )			-- remove duplicate_char if it follows html markup
					else
						value = value:sub( 2, -1 );								-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end  

--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

At the time of this writing, I had to write the 'if nil == mw.ustring.find ...' test ouside of the code editor and past it here
because the code editor gets confused between character insertion point and cursor position.

]]

local function is_good_vanc_name (last, first)
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]*$&quot;) then
		if true ~= Page_in_vanc_error_cat then									-- if we haven't been here before then set a sticky flag
			Page_in_vanc_error_cat=true;										-- so that if there are more than one error the category is added only once
			table.insert( z.message_tail, { set_error( 'vancouver', {}, true ) } );
		end
		return false;															-- not a string of latin characters; Vancouver required Romanization
	end;
	return true;
end

--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  This form is not
currently supported by this code so correctly formed names like Smith JL 2nd are converted to Smith J2. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	if mw.ustring.match(first, &quot;^%u%u$&quot;) then return first end;					-- when first contains just two upper-case letters, nothing to do
	local initials = {}
	local i = 0;																-- counter for number of initials
	for word in mw.ustring.gmatch(first, &quot;[^%s%.%-]+&quot;) do						-- names separated by spaces, hyphens, or periods
		table.insert(initials, mw.ustring.sub(word,1,1))						-- Vancouver format does not include full stops.
		i = i + 1;																-- bump the counter 
		if 2 &lt;= i then break; end												-- only two initials allowed in Vancouver system; if 2, quit
	end
	return table.concat(initials)												-- Vancouver format does not include spaces.
end

--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = ',';																-- name-list separator between authors is a comma
		namesep = ' ';															-- last/first separator is a space
	else
		sep = ';'																-- name-list separator between authors is a semicolon
		namesep = ', '															-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if is_good_vanc_name (one, first) then					-- and name is all Latin characters
							first = reduce_to_initials(first)						-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first 
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;		-- link author/editor if this page is not the author's/editor's page
				end

				if is_set(person.link) and ((nil ~= person.link:find(&quot;//&quot;)) or (nil ~= person.link:find(&quot;[%[%]]&quot;))) then
					one = one .. &quot; &quot; .. set_error( 'bad_authorlink' ) end	-- url or wikilink in author link;
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;
		end
		text[#text] = nil; 
	end
	
	local result = table.concat(text) -- construct list
	if etal then 
		local etal_text = cfg.messages['et al'];
		result = result .. &quot; &quot; .. etal_text;
	end
	
	return result, count
end

--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

]]

local function anchor_id( options )
	local id = table.concat( options );											-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end

--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter
	local pattern = &quot;,? *'*[Ee][Tt] *[Aa][Ll][%.']*$&quot;							-- variations on the 'et al' theme
	
	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary

	while true do
		last = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		local name = tostring(last);
		if name:match (pattern) then											-- varients on et al.
			last = name:gsub (pattern, '');										-- if found, remove
			etal = true;
		end
		name = tostring(first);
		if name:match (pattern) then											-- varients on et al.
			first = name:gsub (pattern, '');									-- if found, remove
			etal = true;
		end

		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 == count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			names[n] = {last = last, first = first, link = link, mask = mask};	-- add this name to our names list
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	if true == etal then
		add_maint_cat ('etal');
	end
	return names, etal;															-- all done, return our list of names
end

-- Populates ID table from arguments using configuration settings
local function extract_ids( args )
	local id_list = {};
	for k, v in pairs( cfg.id_handlers ) do	
		v = select_one( args, v.parameters, 'redundant_parameters' );
		if is_set(v) then id_list[k] = v; end
	end
	return id_list;
end

--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs and turns it into a table of formatted ID outputs.

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end
  

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end
	
	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if is_set(data.Chapter) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
	elseif is_set(data.Periodical) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
		if 'arxiv' == class then
			OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;								-- cite arxiv
		else
			OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
		end
		OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	else
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
	end
	
	OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
	OCinSoutput[&quot;rft.date&quot;] = data.Date;
	OCinSoutput[&quot;rft.series&quot;] = data.Series;
	OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
	OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
	OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
	OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
	OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
	
	for k, v in pairs( data.ID_list ) do
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
	
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = v.last, v.first;
		if k == 1 then
			if is_set(last) then
				OCinSoutput[&quot;rft.aulast&quot;] = last;
			end
			if is_set(first) then 
				OCinSoutput[&quot;rft.aufirst&quot;] = first;
			end
		end
		if is_set(last) and is_set(first) then
			OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
		elseif is_set(last) then
			OCinSoutput[&quot;rft.au&quot;] = last;
		end
	end
	
	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 code.  Handles the special case that is Norwegian where
ISO639-1 code 'no' is mapped to language name 'Norwegian Bokmål' by Extention:CLDR.

Returns the language name and associated ISO639-1 code.  Because case of the source may be incorrect or different from the case that Wikimedia
uses, the name comparisons are done in lower case and when a match is found, the Wikimedia version (assumed to be correct) is returned along
with the code.  When there is no match, we return the original language name string.

mw.language.fetchLanguageNames() will return a list of languages that aren't part of ISO639-1. Names that aren't ISO639-1 but that are included
in the list will be found if that name is provided in the |language= parameter.  For example, if |language=Samaritan Aramaic, that name will be
found with the associated code 'sam', not an ISO639-1 code.  When names are found and the associated code is not two characters, this function
returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang)
	if 'norwegian' == lang:lower() then											-- special case related to Wikimedia remap of code 'no' at Extension:CLDR
		return 'Norwegian', 'no';												-- Make sure rendered version is properly capitalized
	end
	
	local languages = mw.language.fetchLanguageNames('en', 'all')				-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() then												-- ISO639-1 codes only
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the ISO639-1 code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for ISO639-1 code
end

--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Get language name from ISO639-1 code value provided.  If a code is valid use the returned name; if not, then use the value that was provided with the language parameter.

There is an exception.  There are three ISO639-1 codes for Norewegian language variants.  There are two official variants: Norwegian Bokmål (code 'nb') and
Norwegian Nynorsk (code 'nn').  The third, code 'no',  is defined by ISO639-1 as 'Norwegian' though in Norway this is pretty much meaningless.  However, it appears
that on enwiki, editors are for the most part unaware of the nb and nn variants (compare page counts for these variants at Category:Articles with non-English-language external links.

Because Norwegian Bokmål is the most common language variant, Media wiki has been modified to return Norwegian Bokmål for ISO639-1 code 'no'. Here we undo that and
return 'Norwegian' when editors use |language=no.  We presume that editors don't know about the variants or can't descriminate between them.

See Help talk:Citation Style_1#An ISO 639-1 language name test

When |language= contains a valid ISO639-1 code, the page is assigned to the category for that code: Category:Norwegian-language sources (no) if
the page is a mainspace page and the ISO639-1 code is not 'en'.  Similarly, if the  parameter is |language=Norwegian, it will be categorized in the same way.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are separated from each other by commas.

]]

local function language_parameter (lang, namespace)
	local code;																	-- the ISO639-1 two character code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=
	local unrec_cat = false														-- flag so that we only add unrecognized category once
	
	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list
	
	for _, lang in ipairs (names_table) do										-- reuse lang
		if 0 == namespace and (('en' == lang:lower()) or ('english' == lang:lower())) then
			add_maint_cat ('english');
		end
	
		if 2 == lang:len() then													-- ISO639-1 language code are 2 characters (fetchLanguageName also supports 3 character codes)
			name = mw.language.fetchLanguageName( lang:lower(), &quot;en&quot; );			-- get ISO 639-1 language name if Language is a proper code
		end
	
		if is_set (name) then													-- if Language specified a valid ISO639-1 code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang);								-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then
			if 'no' == code then name = 'Norwegian' end;						-- override wikimedia when code is 'no'
			if 0 == namespace and 'en' ~= code then								-- is this page main / article space and English not the language?
				add_prop_cat ('foreign_lang_source', {name, code})
			end
		elseif false == unrec_cat then
			unrec_cat = true;													-- only add this category once
			add_maint_cat (unknown_lang);
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, ' and ')							-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		language_list[code] = 'and ' .. language_list[code];					-- prepend last name with 'and&lt;space&gt;'
		name = table.concat (language_list, ', ')								-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
	end
	return (&quot; &quot; .. wrap_msg ('language', name));		-- wrap with '(in ...)'
end

--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = '.';																-- terminate the rendered citation with a period
	end
	return '.', ps;																-- separator is a full stop
end

--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = '';																-- make sure it isn't nil
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return ',', ps, ref;														-- separator is a comma
end

--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		if is_set (mode) then
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'mode', mode}, true ) } );		-- add error message
		end
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end

--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extension, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf[%?#]?') or url:match ('%.PDF[%?#]?');
end

--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format:upper());							-- force upper case, add leading space, parenthases, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end

--[[--------------------------&lt; G E T _ D I S P L A Y _ A U T H O R S _ E D I T O R S &gt;------------------------

Returns a number that may or may not limit the length of the author or editor name lists.

When the value assigned to |display-authors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-authors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

]]

local function get_display_authors_editors (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count and 'authors' == list_name then	-- AUTHORS ONLY		-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_auth_ed', list_name);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset
		end
	elseif 'authors' == list_name then		-- AUTHORS ONLY	need to clear implicit et al category
		max = count + 1;														-- number of authors + 1
	end
	
	return max, etal;
end

--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation
formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple
	aliases to single internal variable.
	]]
	local A = argument_wrapper( args );

	local i 
	local PPrefix = A['PPrefix']
	local PPPrefix = A['PPPrefix']
	if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
	
	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local Authors = A['Authors'];
	local author_etal;
	local a, author_etal = extract_names( args, 'AuthorList' );

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];
	local Editors = A['Editors'];
	local editor_etal;
	local e, editor_etal = extract_names( args, 'EditorList' );

	local NameListFormat = A['NameListFormat'];									-- replaces |author-format= and |editor-format=
	if is_set (NameListFormat) and ('vanc' ~= NameListFormat) then											-- only accepted value for this parameter is 'vanc'
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {'name-list-format', NameListFormat}, true ) } );	-- not vanc so add error message
		NameListFormat = '';													-- set to empty string
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
	local Chapter = A['Chapter'];
	local ChapterLink = A['ChapterLink'];										-- deprecated
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];
	local ArchiveURL = A['ArchiveURL'];
	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];

	local Series = A['Series'];
	local Volume = A['Volume'];
	local Issue = A['Issue'];
	local Position = '';
	local Page = A['Page'];
	local Pages = hyphen_to_dash( A['Pages'] );	
	local At = A['At'];

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
	local SubscriptionRequired = A['SubscriptionRequired'];
	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local ArchiveDate = A['ArchiveDate'];
	local Agency = A['Agency'];
	local DeadURL = A['DeadURL']
	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
	local no_tracking_cats = A['NoTracking'];

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local use_lowercase;								-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();		-- also used for COinS and for language
	local anchor_year;									-- used in the CITEREF identifier
	local COinS_date;									-- used in the COinS metadata

-- set default parameter values defined by |mode= parameter.  If |mode= is empty or omitted, use CitationClass to set these values
	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (A['Mode']:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

-- check for extra |page=, |pages= or |at= parameters. 
	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Page = Page .. &quot; &quot; .. set_error('extra_pages');	-- add error message
			Pages = '';										-- unset the others
			At = '';
		end
	elseif is_set(Pages) then
		if is_set(At) then
			Pages = Pages .. &quot; &quot; .. set_error('extra_pages');	-- add error messages
			At = '';											-- unset
		end
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped
	|url maps to |chapterurl when |title is remapped

All other combinations of |encyclopedia, |title, and |article are not modified
TODO: script-title to script-chapter if and when we support script-chapter
]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then					-- Periodical is set when |encyclopedia is set
			if is_set(Title) then
				if not is_set(Chapter) then
					Chapter = Title;				-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					TransChapter = TransTitle;
					ChapterURL = URL;
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';				-- redundant so unset
					TransTitle = '';				-- redundant so unset
					URL = '';						-- redundant so unset
					Format = '';					-- redundant so unset
				end
			else									-- |title not set
				Title = Periodical;					-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';					-- redundant so unset
			end
		end
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then	-- special case for cite techreport
		if is_set(Issue) then						-- cite techreport uses 'number', which other citations aliase to 'issue'
			if not is_set(ID) then					-- can we use ID for the &quot;number&quot;?
				ID = Issue;							-- yes, use it
				Issue = &quot;&quot;;							-- unset Issue so that &quot;number&quot; isn't duplicated in the rendered citation or COinS metadata
			else									-- can't use ID so emit error message
				ID = ID .. &quot; &quot; .. set_error('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Others) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Others;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Others;
			end
		else
			Others = '(Interview)';
		end
	end

-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local Began = A['Began'];												-- these two are deprecated because the module understands date ranges
		local Ended = A['Ended'];
		local SeriesLink = A['SeriesLink'];
		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};

																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) then												-- promote airdate or Began/Ended to date
			if is_set (AirDate) then
				Date = AirDate;
			elseif is_set (Began) then											-- deprecated
				if Began:match('%s') or Ended:match('%s') then					-- so we don't create errors: if either has spaces then
					Date = Began .. ' – ' .. Ended;								-- use spaced ndash as separator
				else
					Date = Began .. '–' .. Ended;								-- elsewise no spaces
				end
			end
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('series', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = '[[' .. ChapterLink .. '|' .. Chapter .. ']]';		-- ok to wikilink
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = '[[' .. ChapterLink .. '|' .. Series .. ']]';			-- series links with ChapterLink (episodelink -&gt; TitleLink -&gt; ChapterLink) ugly
			end
			URL = '';															-- unset
			TransTitle = '';													-- unset
			
		else																	-- now oddities that are cite serial
			Issue = '';														-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = '[[' .. SeriesLink .. '|' .. Series .. ']]';
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
-- end of {{cite episode}} stuff

-- Account for the oddities that are {{cite arxiv}}, before generation of COinS data.
	if 'arxiv' == config.CitationClass then
		if not is_set (ID_list['ARXIV']) then									-- |arxiv= or |eprint= required for cite arxiv
			table.insert( z.message_tail, { set_error( 'arxiv_missing', {}, true ) } );		-- add error message
		end
		if first_set (AccessDate, At, Chapter, Format, Page, Pages, Periodical, PublisherName, URL,	-- a crude list of parameters that are not supported by cite arxiv
			ID_list['ASIN'], ID_list['BIBCODE'], ID_list['DOI'], ID_list['ISBN'], ID_list['ISSN'],
			ID_list['JFM'], ID_list['JSTOR'], ID_list['LCCN'], ID_list['MR'], ID_list['OCLC'], ID_list['OL'],
			ID_list['OSTI'], ID_list['PMC'], ID_list['PMID'], ID_list['RFC'], ID_list['SSRN'], ID_list['USENETID'], ID_list['ZBL']) then
				table.insert( z.message_tail, { set_error( 'arxiv_params_not_supported', {}, true ) } );		-- add error message

				AccessDate= '';													-- set these to empty string; not supported in cite arXiv
				PublisherName = '';												-- (if the article has been published, use cite journal, or other)
				Chapter = '';
				URL = '';
				Format = '';
				Page = ''; Pages = ''; At = '';
		end
		Periodical = 'arXiv';													-- set to arXiv for COinS; after that, must be set to empty string
	end

-- handle type parameter for those CS1 citations that have default values

	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
		TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot;;									-- display it in parentheses
	end

-- legacy: promote concatenation of |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set (Date) then
		Date = Year;						-- promote Year to Date
		Year = nil;							-- make nil so Year as empty string isn't used for CITEREF
		if is_set(Date) then
			local Month = A['Month'];
			if is_set(Month) then
				Date = Month .. &quot; &quot; .. Date;
			end
		elseif is_set(PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;			-- promote PublicationDate to Date
			PublicationDate = '';			-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end	-- if PublicationDate is same as Date, don't display in rendered citation

--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	do	-- create defined block to contain local variables error_message and mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		anchor_year, COinS_date, error_message = dates({['accessdate']=AccessDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
			['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end

		if is_set(error_message) then
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end
	end	-- end of do

-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);											-- 

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
		table.insert( z.message_tail, { set_error( 'citation_missing_title', {}, true ) } );
	end
	
	if 'none' == Title and is_set(Periodical) and not (( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia))) then								-- special case
		Title = '';																-- set title to empty string
		add_maint_cat ('untitled');
	end

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	
	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = Periodical,
		['Chapter'] = strip_apostrophe_markup (coins_chapter),					-- Chapter stripped of bold / italic wikimarkup
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = first_set(COinS_date, Date),		-- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here?  Should we be including invalid dates in metadata?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set(Sheet, Sheets, Page, Pages, At)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set( URL, ChapterURL ),
		['Authors'] = a,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

-- Account for the oddities that are {{cite arxiv}}, AFTER generation of COinS data.
	if 'arxiv' == config.CitationClass then										-- we have set rft.jtitle in COinS to arXiv, now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in cite arxiv; if article has been published, use cite journal
	end

-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = '[[Newsgroup]]:&amp;nbsp;' ..  external_link( 'news:' .. PublisherName, PublisherName );
		end
	end



	-- Now perform various field 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.
	do																			-- do-block to limit scope of LastFirstAuthors
		local LastFirstAuthors;
		local Maximum = A['DisplayAuthors'];

		Maximum , author_etal = get_display_authors_editors (Maximum, #a, 'authors', author_etal);

		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text				-- get current page name so that we don't wikilink to it via authorlinkn
		};
		
		-- If the coauthor field is also used, prevent ampersand and et al. formatting.
		if is_set(Coauthors) then
			control.lastauthoramp = nil;
			control.maximum = #a + 1;
		end
		
		LastFirstAuthors = list_people(control, a, author_etal);

		if is_set (Authors) then
			if is_set (LastFirstAuthors) then									-- if both author name styles
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'authors') .. ' and ' .. wrap_style ('parameter', 'last')}, true ) } );		-- add error message
				Authors = LastFirstAuthors;										-- TODO: is this correct or should we use |authors= instead?
			end
		else
			Authors = LastFirstAuthors;											-- either an author name list or an empty string
		end
	end																			-- end of do

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { set_error('coauthors_missing_author', {}, true) } );	-- emit error message
	end

	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	if not is_set(Editors) then
		local Maximum = A['DisplayEditors'];

		Maximum , editor_etal = get_display_authors_editors (Maximum, #e, 'editors', editor_etal);
		-- Preserve old-style implicit et al.
		if not is_set(Maximum) and #e == 4 then 
			Maximum = 3;
			table.insert( z.message_tail, { set_error('implict_etal_editor', {}, true) } );
		end

		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text				-- get current page name so that we don't wikilink to it via editorlinkn
		};

		Editors, EditorCount = list_people(control, e, editor_etal);
		if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then			-- only one editor displayed but includes etal then 
			EditorCount = 2;													-- spoof to display (eds.) annotation
		end
	else
		EditorCount = 1;
	end

-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

	if  not is_set(URL) then --and
--		not is_set(ArchiveURL) then --and										-- prevents format_missing_url error from registering
--		not is_set(ConferenceURL) and											-- TODO: keep this here? conference as part of cite web or cite podcast?
--		not is_set(TranscriptURL) then											-- TODO: remove? |transcript-url= and |transcript= has separate test
		
		-- Test if cite web or cite podcast |url= is missing or empty 
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then	
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- Test if accessdate is given without giving a URL
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when the others are not set; TODO: move this to a separate test?
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalFormat;											-- TODO: swap chapter and title here so that archive applies to most specific if both are set?
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalFormat = Format;											-- and original |format=
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
			end
		elseif is_set (ChapterURL) then 										-- URL not set so if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalFormat = ChapterFormat;										-- and original |format=
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
			end
		end
	end

	if in_array(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;journal&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;, &quot;newsgroup&quot;, 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			if is_set (Chapter) or is_set (TransChapter) or is_set (ChapterURL)then	-- chapter parameters not supported for these citation types
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {}, true ) } );		-- add error message
				Chapter = '';														-- set to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
			end
	else																		-- otherwise, format chapter / article title
		Chapter = format_chapter_title (Chapter, TransChapter, ChapterURL, ChapterURLorigin);
		if is_set (Chapter) then
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;
			end
			Chapter = Chapter .. ChapterFormat .. sepc .. ' ';
		end
	end

	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if in_array(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;journal&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;, &quot;newsgroup&quot;, &quot;mailinglist&quot;, 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
	
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title' );
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then 
			Title = external_link( URL, Title ) .. TransError .. Format;
			URL = &quot;&quot;;
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		if is_set(Minutes) then
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			local Time = A['Time'];
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end
	
	if not is_set(Page) then
		if is_set(Pages) then
			if is_set(Periodical) and
				not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
				Pages = &quot;: &quot; .. Pages;
			elseif tonumber(Pages) ~= nil then
				Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
			else
				Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
			end
		end
	else
		if is_set(Periodical) and
			not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
			Page = &quot;: &quot; .. Page;
		else
			Page = sepc ..&quot; &quot; .. PPrefix .. Page;
		end
	end

	if 'map' == config.CitationClass then										-- cite map oddity done after COinS call (and with other in-source locators)
		if is_set (Sheet) or is_set (Sheets) then
			local err_msg1 = 'sheet=, &amp;#124;sheets';							-- default error message in case any of page pages or at are set
			local err_msg2;
			if is_set (Page) or is_set (Pages) or is_set (At) then				-- are any set?
				err_msg2 = 'page=, &amp;#124;pages=, &amp;#124;at';						-- a generic error message
				Page = ''; Pages = ''; At = '';
			elseif is_set (Sheet) and is_set (Sheets) then						-- if both are set make error message
				err_msg1 = 'sheet';
				err_msg2 = 'sheets';
			end
			if is_set (err_msg2) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', err_msg1) .. ' and ' .. wrap_style ('parameter', err_msg2)}, true ) } );		-- add error message
			end
			if not is_set (Sheet) then											-- do sheet static text and formatting; Sheet has priority over Sheets if both provided
				if is_set (Sheets) then
					if is_set (Periodical) then
						Sheet = &quot;: Sheets &quot; .. Sheets;							-- because Sheet has priority, no need to support both later on
					else
						Sheet = sepc .. &quot; Sheets &quot; .. Sheets;
					end
				end
			else
				if is_set (Periodical) then
					Sheet = &quot;: Sheet &quot; .. Sheet;
				else
					Sheet = sepc .. &quot; Sheet &quot; .. Sheet;
				end
			end
		end
	end

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language, this_page.namespace);			-- format, categories (article namespace only), name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	Edition = is_set(Edition) and (&quot; &quot; .. wrap_msg ('edition', Edition)) or &quot;&quot;;
	Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc ..&quot; &quot; .. Volume;
		  else Volume = &quot; &lt;b&gt;&quot; .. hyphen_to_dash(Volume) .. &quot;&lt;/b&gt;&quot;;
		end
	end

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

--[[
Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
note is displayed. There are no error messages for this condition.

]]
	if in_array(SubscriptionRequired:lower(), {'yes', 'true', 'y'}) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif in_array(RegistrationRequired:lower(), {'yes', 'true', 'y'}) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if 'citation', lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text
																				-- neither of these work; don't know why; it seems that substitute() isn't being called	
		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
			Quote = Quote:sub(2,-2);
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- CS1 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text,
				{ external_link( OriginalURL, cfg.messages['original'] ) .. OriginalFormat, ArchiveDate } );	-- format already styled
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'] ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower() ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin );
	end

	local Publisher;
	if is_set(Periodical) and
		not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap_msg ('published', PublicationDate);
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap_msg ('published', PublicationDate) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
			Language, Edition, Publisher, Agency, Volume, Issue}, sepc );
		
	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume, Issue}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Transcript, Language, Edition, Publisher}, sepc );
	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Issue, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Sheet .. Page .. Pages .. At;
	
	if is_set(Authors) then
		if is_set(Coauthors) then
			local sep = '; ';
			if 'vanc' == NameListFormat then
				sep = ', ';
			end
			Authors = Authors .. sep .. Coauthors;
		end
		if is_set(Date) then
			Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		elseif string.sub(Authors,-1,-1) == sepc then
			Authors = Authors .. &quot; &quot;
		else
			Authors = Authors .. sepc .. &quot; &quot;
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			if (sepc ~= '.') then in_text = in_text:lower() end
			Editors = in_text .. Editors .. post_text;
			if (string.sub(Editors,-1,-1) == sepc) or (string.sub(Editors,-3,-1) == sepc .. ']]') then	-- if last editor name ends with sepc char
				Editors = Editors .. &quot; &quot;;										-- don't add another
			else
				Editors = Editors .. sepc .. &quot; &quot;								-- otherwise terninate the editor list
			end
		end
		text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
		text = safe_join( {text, pgtext, idcommon}, sepc );
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon}, sepc );
		text = safe_join( {text, pgtext, idcommon}, sepc );
	else
		if is_set(Date) then
			if ( string.sub(tcommon,-1,-1) ~= sepc )
			  then Date = sepc ..&quot; &quot; .. Date .. OrigYear
			  else Date = &quot; &quot; .. Date .. OrigYear
			end
		end
		if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon}, sepc );
			text = safe_join( {text, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date}, sepc );
			text = safe_join( {text, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;span/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = &quot;citation &quot; .. config.CitationClass;
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
		local id = Ref
		if ( &quot;harv&quot; == Ref ) then
			local names = {} --table of last names &amp; year
			if #a &gt; 0 then
				for i,v in ipairs(a) do 
					names[i] = v.last 
					if i == 4 then break end
				end
			elseif #e &gt; 0 then
				for i,v in ipairs(e) do 
					names[i] = v.last 
					if i == 4 then break end				
				end
			end
			names[ #names + 1 ] = first_set(Year, anchor_year);	-- Year first for legacy citations and for YMD dates that require disambiguation
			id = anchor_id(names)
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then 
		text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	else
		text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	end		

	local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
	
	-- Note: Using display: none on then COinS span breaks some clients.
	local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
	text = text .. OCinS;
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. error_comment( v[1], v[2] );
				else
					text = text .. error_comment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end

	if #z.maintenance_cats ~= 0 then
		text = text .. ' &lt;span class=&quot;citation-comment&quot; style=&quot;display:none; color:#33aa33&quot;&gt;';
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. v .. ' ([[:Category:' .. v ..'|link]])';
		end
		text = text .. '&lt;/span&gt;';	-- maintenance mesages (realy just the names of the categories for now)
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
	local pframe = frame:getParent()
	local validation;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of Configuration and Whitelist and ...
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');	-- ... sandbox version of date validation code

	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of Configuration and Whitelist and ...
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		validation = require ('Module:Citation/CS1/Date_validation');			-- ... live version of date validation code
	end

	dates = validation.dates;													-- imported functions
	year_date_check = validation.year_date_check;

	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if #suggestions == 0 then
						suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
					end
					if suggestions[ k:lower() ] ~= nil then
						error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
					else
						error_text, error_state = set_error( 'parameter_ignored', {k}, true );
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	
	
	return citation0( config, args)
end

return z</text>
      <sha1>f2q6uujdm4pgd5uooc1n6ohk20zf55a</sha1>
    </revision>
    <revision>
      <id>4691</id>
      <parentid>4690</parentid>
      <timestamp>2015-07-20T18:03:11Z</timestamp>
      <contributor>
        <username>Waldyrious</username>
        <id>815</id>
      </contributor>
      <minor />
      <comment>fix link to redirect</comment>
      <origin>4691</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="131821" sha1="4r1qw1ta1lfawu6bwmohetxos6ksnap" xml:space="preserve">
local z = {
	error_categories = {};		-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};		-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};		-- for categorizing citations based on certain properties, language of source for instance
}

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]
local dates, year_date_check	-- functions in Module:Citation/CS1/Date_validation

local cfg = {};					-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};			-- talbe of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist

--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.
This function is global because it is called from both this module and from Date validation

]]
function is_set( var )
	return not (var == nil or var == '');
end

--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

First set variable or nil if none

]]

local function first_set(...)
	local list = {...};
	for _, var in pairs(list) do
		if is_set( var ) then
			return var;
		end
	end
end

--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end

--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]
local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end

--[[--------------------------&lt; S E T _ E R R O R &gt;--------------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

]]
local function set_error( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if in_array( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return error_comment( message, error_state.hidden );
end

--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maintenance_cats using names from the configuration file with additional text if any.

]]

local function add_maint_cat (key, arguments)
	table.insert( z.maintenance_cats, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
end

--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

]]

local function add_prop_cat (key, arguments)
	table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));		-- make name then add to table
end

--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string is valid.

At present the only check is whether the string appears to be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well formed.

]]

local function check_url( url_str )
	return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;		-- Protocol-relative or URL scheme
end

--[[--------------------------&lt; S A F E _ F O R _ I T A L I C S &gt;----------------------------------------------

Protects a string that will be wrapped in wiki italic markup '' ... ''

Note: We cannot use &lt;i&gt; for italics, as the expected behavior for italics specified by ''...'' in the title is that
they will be inverted (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and '' tend to interact
poorly under Mediawiki's HTML tidy.

]]

local function safe_for_italics( str )
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end

--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

local function wrap_style (key, str)
	if not is_set( str ) then
		return &quot;&quot;;
	elseif in_array( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safe_for_italics( str );
	end

	return substitute( cfg.presentation[key], {str} );
end

--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source )
	local error_str = &quot;&quot;;
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
	end
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url( label ), &quot;]&quot;, error_str });
end

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

--[[
Categorize and emit an error message when the citation contains one or more deprecated parameters.  Because deprecated parameters (currently |month=,
|coauthor=, and |coauthors=) aren't related to each other and because these parameters may be concatenated into the variables used by |date= and |author#= (and aliases)
details of which parameter caused the error message are not provided.  Only one error message is emitted regardless of the number of deprecated parameters in the citation.
]]
local function deprecated_parameter(name)
	if true ~= Page_in_deprecated_cat then	-- if we haven't been here before then set a 
		Page_in_deprecated_cat=true;		-- sticky flag so that if there are more than one deprecated parameter the category is added only once
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end

--[[--------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Call this function for chapter titles, for website titles, etc; not for book titles.

]]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	
	cap, cap2 = str:match (&quot;^([\&quot;\'])([^\'].+)&quot;);								-- match leading double or single quote but not double single quotes
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-left'], {cap, cap2});
	end

	cap, cap2 = str:match (&quot;^(.+[^\'])([\&quot;\'])$&quot;)
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-right'], {cap, cap2});
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

At this writing, only |script-title= is supported.  It is anticipated that additional parameters will be created to use this function.

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, {'ar', 'bg', 'bs', 'dv', 'el', 'fa', 'hy', 'ja', 'ka', 'ko', 'ku', 'he', 'ps', 'ru', 'sd', 'sr', 'th', 'uk', 'ug', 'yi', 'zh'}) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				add_prop_cat ('script')
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		str = substitute( msg, {str} );											-- including template text
		return str;
	else
		return substitute( cfg.messages[key], {str} );
	end		
end

--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider
Generates an error if more than one match is present.

]]

local function select_one( args, possible, error_condition, index )
	local value = nil;
	local selected = '';
	local error_list = {};
	
	if index ~= nil then index = tostring(index); end
	
	-- Handle special case of &quot;#&quot; replaced by empty string
	if index == '1' then
		for _, v in ipairs( possible ) do
			v = v:gsub( &quot;#&quot;, &quot;&quot; );
			if is_set(args[v]) then
				if value ~= nil and selected ~= v then
					table.insert( error_list, v );
				else
					value = args[v];
					selected = v;
				end
			end
		end		
	end
	
	for _, v in ipairs( possible ) do
		if index ~= nil then
			v = v:gsub( &quot;#&quot;, index );
		end
		if is_set(args[v]) then
			if value ~= nil and selected ~=  v then
				table.insert( error_list, v );
			else
				value = args[v];
				selected = v;
			end
		end
	end
	
	if #error_list &gt; 0 then
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap_style ('parameter', k);
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap_style ('parameter', selected);
		table.insert( z.message_tail, { set_error( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end

--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the three chapter parameters: |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (chapter, transchapter, chapterurl, chapter_url_source)
	local chapter_error = '';
	
	if not is_set (chapter) then
		chapter = '';															-- just to be safe for concatenation
		if is_set (transchapter) then
			chapter = wrap_style ('trans-quoted-title', transchapter);
			chapter_error = &quot; &quot; .. set_error ('trans_missing_chapter');
		end
		if is_set (chapterurl) then
			chapter = external_link (chapterurl, chapter, chapter_url_source);	-- adds bare_url_missing_title error if appropriate
		end
		return chapter .. chapter_error;
	else																		-- here when chapter is set
		chapter = kern_quotes (chapter);										-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
		chapter = wrap_style ('quoted-title', chapter);
		if is_set (transchapter) then
			transchapter = wrap_style ('trans-quoted-title', transchapter);
			chapter = chapter .. ' ' .. transchapter;
		end
		if is_set (chapterurl) then
			chapter = external_link (chapterurl, chapter);						-- adds bare_url_missing_title error if appropriate
		end
	end
	return chapter;
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
]]

local function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end


-- Formats a wiki style internal link
local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s*%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s*%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end

--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in check_isbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end	-- isbn13 begins with 978 or 979
		isbn_str = { isbn_str:byte(1, len) };
		for i, v in ipairs( isbn_str ) do
			temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );
		end
		return temp % 10 == 0;
	end
end

--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link = handler.link,
		label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
		encode=handler.encode, separator = handler.separator}) .. err_cat;
end

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end

--[[
lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--[[
Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of the LCCN dictates the character type of the first 1-3 characters; the
rightmost eight are always digits. http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end

--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.

-- DOI names contain two parts: prefix and suffix separated by a forward slash.
--  Prefix: directory indicator '10.' followed by a registrant code
--  Suffix: character string of any length chosen by the registrant

-- This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes,
-- or, if it ends with a period or a comma, this function will emit a bad_doi error message.

-- DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
-- and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely if ever used in doi names.

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);					-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode}) .. 
			' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end

--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end

--[[--------------------------&lt; C L E A N _ I S B N &gt;----------------------------------------------------------

Removes irrelevant text and dashes from ISBN number
Similar to that used for Special:BookSources

]]

local function clean_isbn( isbn_str )
	return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]
local function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other lua magic pattern characters
	return argument;
end

--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	while true do
		if argument:match (&quot;%'%'%'%'%'&quot;) then									-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:match (&quot;%'%'%'%'&quot;) then									-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:match (&quot;%'%'%'&quot;) then									-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:match (&quot;%'%'&quot;) then										-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end

--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...
]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end

--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
local function remove_wiki_link( str )
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end

-- Converts a hyphen to a dash
local function hyphen_to_dash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end

--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if comp:sub(1,1) == duplicate_char then								-- is first charactier same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for th
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = str:sub(-1,-1);										-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = str:sub(1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = str:sub(1, -4) .. &quot;''&quot;;							-- remove them and add back ''
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then		-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then		-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then			-- if last two chars of str are sepc] external link
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;'']&quot; then		-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then				-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = str:sub(1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end		-- if duplicate_char not a letter then escape it
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )			-- remove duplicate_char if it follows html markup
					else
						value = value:sub( 2, -1 );								-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end  

--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

At the time of this writing, I had to write the 'if nil == mw.ustring.find ...' test ouside of the code editor and past it here
because the code editor gets confused between character insertion point and cursor position.

]]

local function is_good_vanc_name (last, first)
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]*$&quot;) then
		if true ~= Page_in_vanc_error_cat then									-- if we haven't been here before then set a sticky flag
			Page_in_vanc_error_cat=true;										-- so that if there are more than one error the category is added only once
			table.insert( z.message_tail, { set_error( 'vancouver', {}, true ) } );
		end
		return false;															-- not a string of latin characters; Vancouver required Romanization
	end;
	return true;
end

--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  This form is not
currently supported by this code so correctly formed names like Smith JL 2nd are converted to Smith J2. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	if mw.ustring.match(first, &quot;^%u%u$&quot;) then return first end;					-- when first contains just two upper-case letters, nothing to do
	local initials = {}
	local i = 0;																-- counter for number of initials
	for word in mw.ustring.gmatch(first, &quot;[^%s%.%-]+&quot;) do						-- names separated by spaces, hyphens, or periods
		table.insert(initials, mw.ustring.sub(word,1,1))						-- Vancouver format does not include full stops.
		i = i + 1;																-- bump the counter 
		if 2 &lt;= i then break; end												-- only two initials allowed in Vancouver system; if 2, quit
	end
	return table.concat(initials)												-- Vancouver format does not include spaces.
end

--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = ',';																-- name-list separator between authors is a comma
		namesep = ' ';															-- last/first separator is a space
	else
		sep = ';'																-- name-list separator between authors is a semicolon
		namesep = ', '															-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if is_good_vanc_name (one, first) then					-- and name is all Latin characters
							first = reduce_to_initials(first)						-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first 
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;		-- link author/editor if this page is not the author's/editor's page
				end

				if is_set(person.link) and ((nil ~= person.link:find(&quot;//&quot;)) or (nil ~= person.link:find(&quot;[%[%]]&quot;))) then
					one = one .. &quot; &quot; .. set_error( 'bad_authorlink' ) end	-- url or wikilink in author link;
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;
		end
		text[#text] = nil; 
	end
	
	local result = table.concat(text) -- construct list
	if etal then 
		local etal_text = cfg.messages['et al'];
		result = result .. &quot; &quot; .. etal_text;
	end
	
	return result, count
end

--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

]]

local function anchor_id( options )
	local id = table.concat( options );											-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end

--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter
	local pattern = &quot;,? *'*[Ee][Tt] *[Aa][Ll][%.']*$&quot;							-- variations on the 'et al' theme
	
	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary

	while true do
		last = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		local name = tostring(last);
		if name:match (pattern) then											-- varients on et al.
			last = name:gsub (pattern, '');										-- if found, remove
			etal = true;
		end
		name = tostring(first);
		if name:match (pattern) then											-- varients on et al.
			first = name:gsub (pattern, '');									-- if found, remove
			etal = true;
		end

		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 == count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			names[n] = {last = last, first = first, link = link, mask = mask};	-- add this name to our names list
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	if true == etal then
		add_maint_cat ('etal');
	end
	return names, etal;															-- all done, return our list of names
end

-- Populates ID table from arguments using configuration settings
local function extract_ids( args )
	local id_list = {};
	for k, v in pairs( cfg.id_handlers ) do	
		v = select_one( args, v.parameters, 'redundant_parameters' );
		if is_set(v) then id_list[k] = v; end
	end
	return id_list;
end

--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs and turns it into a table of formatted ID outputs.

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end
  

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end
	
	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if is_set(data.Chapter) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
	elseif is_set(data.Periodical) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
		if 'arxiv' == class then
			OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;								-- cite arxiv
		else
			OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
		end
		OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	else
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
	end
	
	OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
	OCinSoutput[&quot;rft.date&quot;] = data.Date;
	OCinSoutput[&quot;rft.series&quot;] = data.Series;
	OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
	OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
	OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
	OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
	OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
	
	for k, v in pairs( data.ID_list ) do
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
	
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = v.last, v.first;
		if k == 1 then
			if is_set(last) then
				OCinSoutput[&quot;rft.aulast&quot;] = last;
			end
			if is_set(first) then 
				OCinSoutput[&quot;rft.aufirst&quot;] = first;
			end
		end
		if is_set(last) and is_set(first) then
			OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
		elseif is_set(last) then
			OCinSoutput[&quot;rft.au&quot;] = last;
		end
	end
	
	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 code.  Handles the special case that is Norwegian where
ISO639-1 code 'no' is mapped to language name 'Norwegian Bokmål' by Extention:CLDR.

Returns the language name and associated ISO639-1 code.  Because case of the source may be incorrect or different from the case that Wikimedia
uses, the name comparisons are done in lower case and when a match is found, the Wikimedia version (assumed to be correct) is returned along
with the code.  When there is no match, we return the original language name string.

mw.language.fetchLanguageNames() will return a list of languages that aren't part of ISO639-1. Names that aren't ISO639-1 but that are included
in the list will be found if that name is provided in the |language= parameter.  For example, if |language=Samaritan Aramaic, that name will be
found with the associated code 'sam', not an ISO639-1 code.  When names are found and the associated code is not two characters, this function
returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang)
	if 'norwegian' == lang:lower() then											-- special case related to Wikimedia remap of code 'no' at Extension:CLDR
		return 'Norwegian', 'no';												-- Make sure rendered version is properly capitalized
	end
	
	local languages = mw.language.fetchLanguageNames('en', 'all')				-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() then												-- ISO639-1 codes only
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the ISO639-1 code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for ISO639-1 code
end

--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Get language name from ISO639-1 code value provided.  If a code is valid use the returned name; if not, then use the value that was provided with the language parameter.

There is an exception.  There are three ISO639-1 codes for Norewegian language variants.  There are two official variants: Norwegian Bokmål (code 'nb') and
Norwegian Nynorsk (code 'nn').  The third, code 'no',  is defined by ISO639-1 as 'Norwegian' though in Norway this is pretty much meaningless.  However, it appears
that on enwiki, editors are for the most part unaware of the nb and nn variants (compare page counts for these variants at Category:Articles with non-English-language external links.

Because Norwegian Bokmål is the most common language variant, Media wiki has been modified to return Norwegian Bokmål for ISO639-1 code 'no'. Here we undo that and
return 'Norwegian' when editors use |language=no.  We presume that editors don't know about the variants or can't descriminate between them.

See Help talk:Citation Style_1#An ISO 639-1 language name test

When |language= contains a valid ISO639-1 code, the page is assigned to the category for that code: Category:Norwegian-language sources (no) if
the page is a mainspace page and the ISO639-1 code is not 'en'.  Similarly, if the  parameter is |language=Norwegian, it will be categorized in the same way.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are separated from each other by commas.

]]

local function language_parameter (lang, namespace)
	local code;																	-- the ISO639-1 two character code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=
	local unrec_cat = false														-- flag so that we only add unrecognized category once
	
	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list
	
	for _, lang in ipairs (names_table) do										-- reuse lang
		if 0 == namespace and (('en' == lang:lower()) or ('english' == lang:lower())) then
			add_maint_cat ('english');
		end
	
		if 2 == lang:len() then													-- ISO639-1 language code are 2 characters (fetchLanguageName also supports 3 character codes)
			name = mw.language.fetchLanguageName( lang:lower(), &quot;en&quot; );			-- get ISO 639-1 language name if Language is a proper code
		end
	
		if is_set (name) then													-- if Language specified a valid ISO639-1 code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang);								-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then
			if 'no' == code then name = 'Norwegian' end;						-- override wikimedia when code is 'no'
			if 0 == namespace and 'en' ~= code then								-- is this page main / article space and English not the language?
				add_prop_cat ('foreign_lang_source', {name, code})
			end
		elseif false == unrec_cat then
			unrec_cat = true;													-- only add this category once
			add_maint_cat (unknown_lang);
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, ' and ')							-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		language_list[code] = 'and ' .. language_list[code];					-- prepend last name with 'and&lt;space&gt;'
		name = table.concat (language_list, ', ')								-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
	end
	return (&quot; &quot; .. wrap_msg ('language', name));		-- wrap with '(in ...)'
end

--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = '.';																-- terminate the rendered citation with a period
	end
	return '.', ps;																-- separator is a full stop
end

--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = '';																-- make sure it isn't nil
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return ',', ps, ref;														-- separator is a comma
end

--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		if is_set (mode) then
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'mode', mode}, true ) } );		-- add error message
		end
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end

--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extension, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf[%?#]?') or url:match ('%.PDF[%?#]?');
end

--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format:upper());							-- force upper case, add leading space, parenthases, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end

--[[--------------------------&lt; G E T _ D I S P L A Y _ A U T H O R S _ E D I T O R S &gt;------------------------

Returns a number that may or may not limit the length of the author or editor name lists.

When the value assigned to |display-authors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-authors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

]]

local function get_display_authors_editors (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count and 'authors' == list_name then	-- AUTHORS ONLY		-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_auth_ed', list_name);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset
		end
	elseif 'authors' == list_name then		-- AUTHORS ONLY	need to clear implicit et al category
		max = count + 1;														-- number of authors + 1
	end
	
	return max, etal;
end

--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation
formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple
	aliases to single internal variable.
	]]
	local A = argument_wrapper( args );

	local i 
	local PPrefix = A['PPrefix']
	local PPPrefix = A['PPPrefix']
	if is_set( A['NoPP'] ) then PPPrefix = &quot;&quot; PPrefix = &quot;&quot; end
	
	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local Authors = A['Authors'];
	local author_etal;
	local a, author_etal = extract_names( args, 'AuthorList' );

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];
	local Editors = A['Editors'];
	local editor_etal;
	local e, editor_etal = extract_names( args, 'EditorList' );

	local NameListFormat = A['NameListFormat'];									-- replaces |author-format= and |editor-format=
	if is_set (NameListFormat) and ('vanc' ~= NameListFormat) then											-- only accepted value for this parameter is 'vanc'
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {'name-list-format', NameListFormat}, true ) } );	-- not vanc so add error message
		NameListFormat = '';													-- set to empty string
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
	local Chapter = A['Chapter'];
	local ChapterLink = A['ChapterLink'];										-- deprecated
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];
	local ArchiveURL = A['ArchiveURL'];
	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];

	local Series = A['Series'];
	local Volume = A['Volume'];
	local Issue = A['Issue'];
	local Position = '';
	local Page = A['Page'];
	local Pages = hyphen_to_dash( A['Pages'] );	
	local At = A['At'];

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
	local SubscriptionRequired = A['SubscriptionRequired'];
	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local ArchiveDate = A['ArchiveDate'];
	local Agency = A['Agency'];
	local DeadURL = A['DeadURL']
	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
	local no_tracking_cats = A['NoTracking'];

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local use_lowercase;								-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();		-- also used for COinS and for language
	local anchor_year;									-- used in the CITEREF identifier
	local COinS_date;									-- used in the COinS metadata

-- set default parameter values defined by |mode= parameter.  If |mode= is empty or omitted, use CitationClass to set these values
	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (A['Mode']:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

-- check for extra |page=, |pages= or |at= parameters. 
	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Page = Page .. &quot; &quot; .. set_error('extra_pages');	-- add error message
			Pages = '';										-- unset the others
			At = '';
		end
	elseif is_set(Pages) then
		if is_set(At) then
			Pages = Pages .. &quot; &quot; .. set_error('extra_pages');	-- add error messages
			At = '';											-- unset
		end
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped
	|url maps to |chapterurl when |title is remapped

All other combinations of |encyclopedia, |title, and |article are not modified
TODO: script-title to script-chapter if and when we support script-chapter
]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then					-- Periodical is set when |encyclopedia is set
			if is_set(Title) then
				if not is_set(Chapter) then
					Chapter = Title;				-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					TransChapter = TransTitle;
					ChapterURL = URL;
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';				-- redundant so unset
					TransTitle = '';				-- redundant so unset
					URL = '';						-- redundant so unset
					Format = '';					-- redundant so unset
				end
			else									-- |title not set
				Title = Periodical;					-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';					-- redundant so unset
			end
		end
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then	-- special case for cite techreport
		if is_set(Issue) then						-- cite techreport uses 'number', which other citations aliase to 'issue'
			if not is_set(ID) then					-- can we use ID for the &quot;number&quot;?
				ID = Issue;							-- yes, use it
				Issue = &quot;&quot;;							-- unset Issue so that &quot;number&quot; isn't duplicated in the rendered citation or COinS metadata
			else									-- can't use ID so emit error message
				ID = ID .. &quot; &quot; .. set_error('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Others) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Others;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Others;
			end
		else
			Others = '(Interview)';
		end
	end

-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local Began = A['Began'];												-- these two are deprecated because the module understands date ranges
		local Ended = A['Ended'];
		local SeriesLink = A['SeriesLink'];
		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};

																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) then												-- promote airdate or Began/Ended to date
			if is_set (AirDate) then
				Date = AirDate;
			elseif is_set (Began) then											-- deprecated
				if Began:match('%s') or Ended:match('%s') then					-- so we don't create errors: if either has spaces then
					Date = Began .. ' – ' .. Ended;								-- use spaced ndash as separator
				else
					Date = Began .. '–' .. Ended;								-- elsewise no spaces
				end
			end
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('series', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = '[[' .. ChapterLink .. '|' .. Chapter .. ']]';		-- ok to wikilink
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = '[[' .. ChapterLink .. '|' .. Series .. ']]';			-- series links with ChapterLink (episodelink -&gt; TitleLink -&gt; ChapterLink) ugly
			end
			URL = '';															-- unset
			TransTitle = '';													-- unset
			
		else																	-- now oddities that are cite serial
			Issue = '';														-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = '[[' .. SeriesLink .. '|' .. Series .. ']]';
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
-- end of {{cite episode}} stuff

-- Account for the oddities that are {{cite arxiv}}, before generation of COinS data.
	if 'arxiv' == config.CitationClass then
		if not is_set (ID_list['ARXIV']) then									-- |arxiv= or |eprint= required for cite arxiv
			table.insert( z.message_tail, { set_error( 'arxiv_missing', {}, true ) } );		-- add error message
		end
		if first_set (AccessDate, At, Chapter, Format, Page, Pages, Periodical, PublisherName, URL,	-- a crude list of parameters that are not supported by cite arxiv
			ID_list['ASIN'], ID_list['BIBCODE'], ID_list['DOI'], ID_list['ISBN'], ID_list['ISSN'],
			ID_list['JFM'], ID_list['JSTOR'], ID_list['LCCN'], ID_list['MR'], ID_list['OCLC'], ID_list['OL'],
			ID_list['OSTI'], ID_list['PMC'], ID_list['PMID'], ID_list['RFC'], ID_list['SSRN'], ID_list['USENETID'], ID_list['ZBL']) then
				table.insert( z.message_tail, { set_error( 'arxiv_params_not_supported', {}, true ) } );		-- add error message

				AccessDate= '';													-- set these to empty string; not supported in cite arXiv
				PublisherName = '';												-- (if the article has been published, use cite journal, or other)
				Chapter = '';
				URL = '';
				Format = '';
				Page = ''; Pages = ''; At = '';
		end
		Periodical = 'arXiv';													-- set to arXiv for COinS; after that, must be set to empty string
	end

-- handle type parameter for those CS1 citations that have default values

	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
		TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot;;									-- display it in parentheses
	end

-- legacy: promote concatenation of |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set (Date) then
		Date = Year;						-- promote Year to Date
		Year = nil;							-- make nil so Year as empty string isn't used for CITEREF
		if is_set(Date) then
			local Month = A['Month'];
			if is_set(Month) then
				Date = Month .. &quot; &quot; .. Date;
			end
		elseif is_set(PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;			-- promote PublicationDate to Date
			PublicationDate = '';			-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end	-- if PublicationDate is same as Date, don't display in rendered citation

--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	do	-- create defined block to contain local variables error_message and mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		anchor_year, COinS_date, error_message = dates({['accessdate']=AccessDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
			['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end

		if is_set(error_message) then
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end
	end	-- end of do

-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);											-- 

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
		table.insert( z.message_tail, { set_error( 'citation_missing_title', {}, true ) } );
	end
	
	if 'none' == Title and is_set(Periodical) and not (( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia))) then								-- special case
		Title = '';																-- set title to empty string
		add_maint_cat ('untitled');
	end

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	
	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = Periodical,
		['Chapter'] = strip_apostrophe_markup (coins_chapter),					-- Chapter stripped of bold / italic wikimarkup
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = first_set(COinS_date, Date),		-- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here?  Should we be including invalid dates in metadata?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set(Sheet, Sheets, Page, Pages, At)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set( URL, ChapterURL ),
		['Authors'] = a,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

-- Account for the oddities that are {{cite arxiv}}, AFTER generation of COinS data.
	if 'arxiv' == config.CitationClass then										-- we have set rft.jtitle in COinS to arXiv, now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in cite arxiv; if article has been published, use cite journal
	end

-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = '[[Usenet newsgroup|Newsgroup]]:&amp;nbsp;' ..  external_link( 'news:' .. PublisherName, PublisherName );
		end
	end



	-- Now perform various field 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.
	do																			-- do-block to limit scope of LastFirstAuthors
		local LastFirstAuthors;
		local Maximum = A['DisplayAuthors'];

		Maximum , author_etal = get_display_authors_editors (Maximum, #a, 'authors', author_etal);

		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text				-- get current page name so that we don't wikilink to it via authorlinkn
		};
		
		-- If the coauthor field is also used, prevent ampersand and et al. formatting.
		if is_set(Coauthors) then
			control.lastauthoramp = nil;
			control.maximum = #a + 1;
		end
		
		LastFirstAuthors = list_people(control, a, author_etal);

		if is_set (Authors) then
			if is_set (LastFirstAuthors) then									-- if both author name styles
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'authors') .. ' and ' .. wrap_style ('parameter', 'last')}, true ) } );		-- add error message
				Authors = LastFirstAuthors;										-- TODO: is this correct or should we use |authors= instead?
			end
		else
			Authors = LastFirstAuthors;											-- either an author name list or an empty string
		end
	end																			-- end of do

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { set_error('coauthors_missing_author', {}, true) } );	-- emit error message
	end

	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	if not is_set(Editors) then
		local Maximum = A['DisplayEditors'];

		Maximum , editor_etal = get_display_authors_editors (Maximum, #e, 'editors', editor_etal);
		-- Preserve old-style implicit et al.
		if not is_set(Maximum) and #e == 4 then 
			Maximum = 3;
			table.insert( z.message_tail, { set_error('implict_etal_editor', {}, true) } );
		end

		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = Maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text				-- get current page name so that we don't wikilink to it via editorlinkn
		};

		Editors, EditorCount = list_people(control, e, editor_etal);
		if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then			-- only one editor displayed but includes etal then 
			EditorCount = 2;													-- spoof to display (eds.) annotation
		end
	else
		EditorCount = 1;
	end

-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

	if  not is_set(URL) then --and
--		not is_set(ArchiveURL) then --and										-- prevents format_missing_url error from registering
--		not is_set(ConferenceURL) and											-- TODO: keep this here? conference as part of cite web or cite podcast?
--		not is_set(TranscriptURL) then											-- TODO: remove? |transcript-url= and |transcript= has separate test
		
		-- Test if cite web or cite podcast |url= is missing or empty 
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then	
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- Test if accessdate is given without giving a URL
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when the others are not set; TODO: move this to a separate test?
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalFormat;											-- TODO: swap chapter and title here so that archive applies to most specific if both are set?
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalFormat = Format;											-- and original |format=
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
			end
		elseif is_set (ChapterURL) then 										-- URL not set so if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalFormat = ChapterFormat;										-- and original |format=
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
			end
		end
	end

	if in_array(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;journal&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;, &quot;newsgroup&quot;, 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			if is_set (Chapter) or is_set (TransChapter) or is_set (ChapterURL)then	-- chapter parameters not supported for these citation types
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {}, true ) } );		-- add error message
				Chapter = '';														-- set to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
			end
	else																		-- otherwise, format chapter / article title
		Chapter = format_chapter_title (Chapter, TransChapter, ChapterURL, ChapterURLorigin);
		if is_set (Chapter) then
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;
			end
			Chapter = Chapter .. ChapterFormat .. sepc .. ' ';
		end
	end

	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if in_array(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;journal&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;, &quot;newsgroup&quot;, &quot;mailinglist&quot;, 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
	
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title' );
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then 
			Title = external_link( URL, Title ) .. TransError .. Format;
			URL = &quot;&quot;;
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		if is_set(Minutes) then
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			local Time = A['Time'];
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end
	
	if not is_set(Page) then
		if is_set(Pages) then
			if is_set(Periodical) and
				not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
				Pages = &quot;: &quot; .. Pages;
			elseif tonumber(Pages) ~= nil then
				Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
			else
				Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
			end
		end
	else
		if is_set(Periodical) and
			not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
			Page = &quot;: &quot; .. Page;
		else
			Page = sepc ..&quot; &quot; .. PPrefix .. Page;
		end
	end

	if 'map' == config.CitationClass then										-- cite map oddity done after COinS call (and with other in-source locators)
		if is_set (Sheet) or is_set (Sheets) then
			local err_msg1 = 'sheet=, &amp;#124;sheets';							-- default error message in case any of page pages or at are set
			local err_msg2;
			if is_set (Page) or is_set (Pages) or is_set (At) then				-- are any set?
				err_msg2 = 'page=, &amp;#124;pages=, &amp;#124;at';						-- a generic error message
				Page = ''; Pages = ''; At = '';
			elseif is_set (Sheet) and is_set (Sheets) then						-- if both are set make error message
				err_msg1 = 'sheet';
				err_msg2 = 'sheets';
			end
			if is_set (err_msg2) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', err_msg1) .. ' and ' .. wrap_style ('parameter', err_msg2)}, true ) } );		-- add error message
			end
			if not is_set (Sheet) then											-- do sheet static text and formatting; Sheet has priority over Sheets if both provided
				if is_set (Sheets) then
					if is_set (Periodical) then
						Sheet = &quot;: Sheets &quot; .. Sheets;							-- because Sheet has priority, no need to support both later on
					else
						Sheet = sepc .. &quot; Sheets &quot; .. Sheets;
					end
				end
			else
				if is_set (Periodical) then
					Sheet = &quot;: Sheet &quot; .. Sheet;
				else
					Sheet = sepc .. &quot; Sheet &quot; .. Sheet;
				end
			end
		end
	end

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language, this_page.namespace);			-- format, categories (article namespace only), name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	Edition = is_set(Edition) and (&quot; &quot; .. wrap_msg ('edition', Edition)) or &quot;&quot;;
	Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc ..&quot; &quot; .. Volume;
		  else Volume = &quot; &lt;b&gt;&quot; .. hyphen_to_dash(Volume) .. &quot;&lt;/b&gt;&quot;;
		end
	end

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

--[[
Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
note is displayed. There are no error messages for this condition.

]]
	if in_array(SubscriptionRequired:lower(), {'yes', 'true', 'y'}) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif in_array(RegistrationRequired:lower(), {'yes', 'true', 'y'}) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if 'citation', lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text
																				-- neither of these work; don't know why; it seems that substitute() isn't being called	
		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
			Quote = Quote:sub(2,-2);
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- CS1 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text,
				{ external_link( OriginalURL, cfg.messages['original'] ) .. OriginalFormat, ArchiveDate } );	-- format already styled
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'] ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower() ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin );
	end

	local Publisher;
	if is_set(Periodical) and
		not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap_msg ('published', PublicationDate);
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap_msg ('published', PublicationDate) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
			Language, Edition, Publisher, Agency, Volume, Issue}, sepc );
		
	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume, Issue}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Transcript, Language, Edition, Publisher}, sepc );
	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Issue, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Sheet .. Page .. Pages .. At;
	
	if is_set(Authors) then
		if is_set(Coauthors) then
			local sep = '; ';
			if 'vanc' == NameListFormat then
				sep = ', ';
			end
			Authors = Authors .. sep .. Coauthors;
		end
		if is_set(Date) then
			Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		elseif string.sub(Authors,-1,-1) == sepc then
			Authors = Authors .. &quot; &quot;
		else
			Authors = Authors .. sepc .. &quot; &quot;
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			if (sepc ~= '.') then in_text = in_text:lower() end
			Editors = in_text .. Editors .. post_text;
			if (string.sub(Editors,-1,-1) == sepc) or (string.sub(Editors,-3,-1) == sepc .. ']]') then	-- if last editor name ends with sepc char
				Editors = Editors .. &quot; &quot;;										-- don't add another
			else
				Editors = Editors .. sepc .. &quot; &quot;								-- otherwise terninate the editor list
			end
		end
		text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
		text = safe_join( {text, pgtext, idcommon}, sepc );
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon}, sepc );
		text = safe_join( {text, pgtext, idcommon}, sepc );
	else
		if is_set(Date) then
			if ( string.sub(tcommon,-1,-1) ~= sepc )
			  then Date = sepc ..&quot; &quot; .. Date .. OrigYear
			  else Date = &quot; &quot; .. Date .. OrigYear
			end
		end
		if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon}, sepc );
			text = safe_join( {text, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date}, sepc );
			text = safe_join( {text, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;span/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = &quot;citation &quot; .. config.CitationClass;
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
		local id = Ref
		if ( &quot;harv&quot; == Ref ) then
			local names = {} --table of last names &amp; year
			if #a &gt; 0 then
				for i,v in ipairs(a) do 
					names[i] = v.last 
					if i == 4 then break end
				end
			elseif #e &gt; 0 then
				for i,v in ipairs(e) do 
					names[i] = v.last 
					if i == 4 then break end				
				end
			end
			names[ #names + 1 ] = first_set(Year, anchor_year);	-- Year first for legacy citations and for YMD dates that require disambiguation
			id = anchor_id(names)
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then 
		text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	else
		text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	end		

	local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
	
	-- Note: Using display: none on then COinS span breaks some clients.
	local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
	text = text .. OCinS;
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. error_comment( v[1], v[2] );
				else
					text = text .. error_comment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end

	if #z.maintenance_cats ~= 0 then
		text = text .. ' &lt;span class=&quot;citation-comment&quot; style=&quot;display:none; color:#33aa33&quot;&gt;';
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. v .. ' ([[:Category:' .. v ..'|link]])';
		end
		text = text .. '&lt;/span&gt;';	-- maintenance mesages (realy just the names of the categories for now)
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
	local pframe = frame:getParent()
	local validation;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of Configuration and Whitelist and ...
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');	-- ... sandbox version of date validation code

	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of Configuration and Whitelist and ...
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		validation = require ('Module:Citation/CS1/Date_validation');			-- ... live version of date validation code
	end

	dates = validation.dates;													-- imported functions
	year_date_check = validation.year_date_check;

	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if #suggestions == 0 then
						suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
					end
					if suggestions[ k:lower() ] ~= nil then
						error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
					else
						error_text, error_state = set_error( 'parameter_ignored', {k}, true );
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	
	
	return citation0( config, args)
end

return z</text>
      <sha1>4r1qw1ta1lfawu6bwmohetxos6ksnap</sha1>
    </revision>
    <revision>
      <id>4692</id>
      <parentid>4691</parentid>
      <timestamp>2015-07-25T10:24:12Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4692</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="145530" sha1="6i2ehmhjtybprdyct0atqe1o869u02e" xml:space="preserve">
local z = {
	error_categories = {};		-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};		-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};		-- for categorizing citations based on certain properties, language of source for instance
}

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]
local dates, year_date_check	-- functions in Module:Citation/CS1/Date_validation

local cfg = {};					-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};			-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist

--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.
This function is global because it is called from both this module and from Date validation

]]
function is_set( var )
	return not (var == nil or var == '');
end

--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

First set variable or nil if none

]]

local function first_set(...)
	local list = {...};
	for _, var in pairs(list) do
		if is_set( var ) then
			return var;
		end
	end
end

--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end

--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]
local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end

--[[--------------------------&lt; S E T _ E R R O R &gt;--------------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

]]
local function set_error( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if in_array( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return error_comment( message, error_state.hidden );
end

--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maintenance_cats using names from the configuration file with additional text if any.
To prevent duplication, the added_maint_cats table lists the categories by key that have been added to z.maintenance_cats.

]]

local added_maint_cats = {}														-- list of maintenance categories that have been added to z.maintenance_cats
local function add_maint_cat (key, arguments)
	if not added_maint_cats [key] then
		added_maint_cats [key] = true;											-- note that we've added this category
		table.insert( z.maintenance_cats, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
	end
end

--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

]]

local added_prop_cats = {}														-- list of property categories that have been added to z.properties_cats
local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));		-- make name then add to table
	end
end

--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

]]

local added_vanc_errs;															-- flag so we only emit one Vancouver error / category
local function add_vanc_error ()
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {}, true ) } );
	end
end

--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string is valid.

At present the only check is whether the string appears to be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well formed.

]]

local function check_url( url_str )
	return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;		-- Protocol-relative or URL scheme
end

--[[--------------------------&lt; S A F E _ F O R _ I T A L I C S &gt;----------------------------------------------

Protects a string that will be wrapped in wiki italic markup '' ... ''

Note: We cannot use &lt;i&gt; for italics, as the expected behavior for italics specified by ''...'' in the title is that
they will be inverted (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and '' tend to interact
poorly under Mediawiki's HTML tidy.

]]

local function safe_for_italics( str )
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end

--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

local function wrap_style (key, str)
	if not is_set( str ) then
		return &quot;&quot;;
	elseif in_array( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safe_for_italics( str );
	end

	return substitute( cfg.presentation[key], {str} );
end

--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source )
	local error_str = &quot;&quot;;
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
	end
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url( label ), &quot;]&quot;, error_str });
end

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

]]

local page_in_deprecated_cat;													-- sticky flag so that the category is added only once
local function deprecated_parameter(name)
	if not page_in_deprecated_cat then
		page_in_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end

--[[--------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Call this function for chapter titles, for website titles, etc; not for book titles.

]]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	
	cap, cap2 = str:match (&quot;^([\&quot;\'])([^\'].+)&quot;);								-- match leading double or single quote but not double single quotes
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-left'], {cap, cap2});
	end

	cap, cap2 = str:match (&quot;^(.+[^\'])([\&quot;\'])$&quot;)
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-right'], {cap, cap2});
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

At this writing, only |script-title= is supported.  It is anticipated that additional parameters will be created to use this function.

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, {'ar', 'bg', 'bs', 'dv', 'el', 'fa', 'hy', 'ja', 'ka', 'ko', 'ku', 'he', 'ps', 'ru', 'sd', 'sr', 'th', 'uk', 'ug', 'yi', 'zh'}) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				add_prop_cat ('script')
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		str = substitute( msg, {str} );											-- including template text
		return str;
	else
		return substitute( cfg.messages[key], {str} );
	end		
end

--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider
Generates an error if more than one match is present.

]]

local function select_one( args, possible, error_condition, index )
	local value = nil;
	local selected = '';
	local error_list = {};
	
	if index ~= nil then index = tostring(index); end
	
	-- Handle special case of &quot;#&quot; replaced by empty string
	if index == '1' then
		for _, v in ipairs( possible ) do
			v = v:gsub( &quot;#&quot;, &quot;&quot; );
			if is_set(args[v]) then
				if value ~= nil and selected ~= v then
					table.insert( error_list, v );
				else
					value = args[v];
					selected = v;
				end
			end
		end		
	end
	
	for _, v in ipairs( possible ) do
		if index ~= nil then
			v = v:gsub( &quot;#&quot;, index );
		end
		if is_set(args[v]) then
			if value ~= nil and selected ~=  v then
				table.insert( error_list, v );
			else
				value = args[v];
				selected = v;
			end
		end
	end
	
	if #error_list &gt; 0 then
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap_style ('parameter', k);
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap_style ('parameter', selected);
		table.insert( z.message_tail, { set_error( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end

--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the three chapter parameters: |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (chapter, transchapter, chapterurl, chapter_url_source)
	local chapter_error = '';
	
	if not is_set (chapter) then
		chapter = '';															-- just to be safe for concatenation
		if is_set (transchapter) then
			chapter = wrap_style ('trans-quoted-title', transchapter);
			chapter_error = &quot; &quot; .. set_error ('trans_missing_chapter');
		end
		if is_set (chapterurl) then
			chapter = external_link (chapterurl, chapter, chapter_url_source);	-- adds bare_url_missing_title error if appropriate
		end
		return chapter .. chapter_error;
	else																		-- here when chapter is set
		chapter = kern_quotes (chapter);										-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
		chapter = wrap_style ('quoted-title', chapter);
		if is_set (transchapter) then
			transchapter = wrap_style ('trans-quoted-title', transchapter);
			chapter = chapter .. ' ' .. transchapter;
		end
		if is_set (chapterurl) then
			chapter = external_link (chapterurl, chapter);						-- adds bare_url_missing_title error if appropriate
		end
	end
	return chapter;
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
]]

local function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end


-- Formats a wiki style internal link
local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s*%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s*%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end

--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in check_isbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end

--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end

--[[--------------------------&lt; C H E C K _ I S M N &gt;------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the issn is invalid
	end 
	
	return text;
end

--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link = handler.link,
		label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
		encode=handler.encode, separator = handler.separator}) .. err_cat;
end

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end

--[[
lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--[[
Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of the LCCN dictates the character type of the first 1-3 characters; the
rightmost eight are always digits. http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end

--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.

-- DOI names contain two parts: prefix and suffix separated by a forward slash.
--  Prefix: directory indicator '10.' followed by a registrant code
--  Suffix: character string of any length chosen by the registrant

-- This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes,
-- or, if it ends with a period or a comma, this function will emit a bad_doi error message.

-- DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
-- and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely if ever used in doi names.

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);					-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode}) .. 
			' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end

--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end

--[[--------------------------&lt; C L E A N _ I S B N &gt;----------------------------------------------------------

Removes irrelevant text and dashes from ISBN number
Similar to that used for Special:BookSources

]]

local function clean_isbn( isbn_str )
	return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]
local function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other lua magic pattern characters
	return argument;
end

--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	while true do
		if argument:match (&quot;%'%'%'%'%'&quot;) then									-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:match (&quot;%'%'%'%'&quot;) then									-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:match (&quot;%'%'%'&quot;) then									-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:match (&quot;%'%'&quot;) then										-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end

--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...
]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end

--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
local function remove_wiki_link( str )
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end

-- Converts a hyphen to a dash
local function hyphen_to_dash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end

--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if comp:sub(1,1) == duplicate_char then								-- is first charactier same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for th
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = str:sub(-1,-1);										-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = str:sub(1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = str:sub(1, -4) .. &quot;''&quot;;							-- remove them and add back ''
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then		-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then		-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then			-- if last two chars of str are sepc] external link
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;'']&quot; then		-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then				-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = str:sub(1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end		-- if duplicate_char not a letter then escape it
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )			-- remove duplicate_char if it follows html markup
					else
						value = value:sub( 2, -1 );								-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end  

--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

At the time of this writing, I had to write the 'if nil == mw.ustring.find ...' test ouside of the code editor and paste it here
because the code editor gets confused between character insertion point and cursor position.

]]

local function is_good_vanc_name (last, first)
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]*$&quot;) then
		add_vanc_error ();
		return false;															-- not a string of latin characters; Vancouver required Romanization
	end;
	return true;
end

--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  This form is not
currently supported by this code so correctly formed names like Smith JL 2nd are converted to Smith J2. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	if mw.ustring.match(first, &quot;^%u%u$&quot;) then return first end;					-- when first contains just two upper-case letters, nothing to do
	local initials = {}
	local i = 0;																-- counter for number of initials
	for word in mw.ustring.gmatch(first, &quot;[^%s%.%-]+&quot;) do						-- names separated by spaces, hyphens, or periods
		table.insert(initials, mw.ustring.sub(word,1,1))						-- Vancouver format does not include full stops.
		i = i + 1;																-- bump the counter 
		if 2 &lt;= i then break; end												-- only two initials allowed in Vancouver system; if 2, quit
	end
	return table.concat(initials)												-- Vancouver format does not include spaces.
end

--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = ',';																-- name-list separator between authors is a comma
		namesep = ' ';															-- last/first separator is a space
	else
		sep = ';'																-- name-list separator between authors is a semicolon
		namesep = ', '															-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then					-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first 
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;				-- link author/editor if this page is not the author's/editor's page
				end

				if is_set(person.link) and ((nil ~= person.link:find(&quot;//&quot;)) or (nil ~= person.link:find(&quot;[%[%]]&quot;))) then
					one = one .. &quot; &quot; .. set_error( 'bad_authorlink' ) end		-- url or wikilink in author link;
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. ' ' .. cfg.messages['et al'];						-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end

--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

]]

local function anchor_id( options )
	local id = table.concat( options );											-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end

--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of author and editor name parameters for variations on the theme eof et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the parameters |display-authors=etal or |displayeditors=etal

]]

local function name_has_etal (name, etal, nocat)

	if is_set (name) then														-- name can be nil in which case just return
		local pattern = &quot;[;,]? *[\&quot;']*%f[Ee][Ee][Tt] *[Aa][Ll][%.\&quot;']*$&quot;		-- variations on the 'et al' theme
		
		if name:match (pattern) then											-- variants on et al.
			name = name:gsub (pattern, '');										-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		end
	end
	return name, etal;															-- 
end

--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary

	while true do
		last = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false);								-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false);								-- find and remove variations on et al.

		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end

-- Populates ID table from arguments using configuration settings
local function extract_ids( args )
	local id_list = {};
	for k, v in pairs( cfg.id_handlers ) do	
		v = select_one( args, v.parameters, 'redundant_parameters' );
		if is_set(v) then id_list[k] = v; end
	end
	return id_list;
end

--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs and turns it into a table of formatted ID outputs.

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end
  

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end
	
	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if is_set(data.Chapter) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
	elseif is_set(data.Periodical) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
		if 'arxiv' == class then
			OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;								-- cite arxiv
		else
			OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
		end
		OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	else
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
	end
	
	OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
	OCinSoutput[&quot;rft.date&quot;] = data.Date;
	OCinSoutput[&quot;rft.series&quot;] = data.Series;
	OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
	OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
	OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
	OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
	OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
	
	for k, v in pairs( data.ID_list ) do
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
	
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = v.last, v.first;
		if k == 1 then
			if is_set(last) then
				OCinSoutput[&quot;rft.aulast&quot;] = last;
			end
			if is_set(first) then 
				OCinSoutput[&quot;rft.aufirst&quot;] = first;
			end
		end
		if is_set(last) and is_set(first) then
			OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
		elseif is_set(last) then
			OCinSoutput[&quot;rft.au&quot;] = last;
		end
	end
	
	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 code.  Handles the special case that is Norwegian where
ISO639-1 code 'no' is mapped to language name 'Norwegian Bokmål' by Extention:CLDR.

Returns the language name and associated ISO639-1 code.  Because case of the source may be incorrect or different from the case that Wikimedia
uses, the name comparisons are done in lower case and when a match is found, the Wikimedia version (assumed to be correct) is returned along
with the code.  When there is no match, we return the original language name string.

mw.language.fetchLanguageNames() will return a list of languages that aren't part of ISO639-1. Names that aren't ISO639-1 but that are included
in the list will be found if that name is provided in the |language= parameter.  For example, if |language=Samaritan Aramaic, that name will be
found with the associated code 'sam', not an ISO639-1 code.  When names are found and the associated code is not two characters, this function
returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang)
	if 'norwegian' == lang:lower() then											-- special case related to Wikimedia remap of code 'no' at Extension:CLDR
		return 'Norwegian', 'no';												-- Make sure rendered version is properly capitalized
	end
	
	local languages = mw.language.fetchLanguageNames('en', 'all')				-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() then												-- ISO639-1 codes only
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the ISO639-1 code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for ISO639-1 code
end

--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Get language name from ISO639-1 code value provided.  If a code is valid use the returned name; if not, then use the value that was provided with the language parameter.

There is an exception.  There are three ISO639-1 codes for Norewegian language variants.  There are two official variants: Norwegian Bokmål (code 'nb') and
Norwegian Nynorsk (code 'nn').  The third, code 'no',  is defined by ISO639-1 as 'Norwegian' though in Norway this is pretty much meaningless.  However, it appears
that on enwiki, editors are for the most part unaware of the nb and nn variants (compare page counts for these variants at Category:Articles with non-English-language external links.

Because Norwegian Bokmål is the most common language variant, Media wiki has been modified to return Norwegian Bokmål for ISO639-1 code 'no'. Here we undo that and
return 'Norwegian' when editors use |language=no.  We presume that editors don't know about the variants or can't descriminate between them.

See Help talk:Citation Style_1#An ISO 639-1 language name test

When |language= contains a valid ISO639-1 code, the page is assigned to the category for that code: Category:Norwegian-language sources (no) if
the page is a mainspace page and the ISO639-1 code is not 'en'.  Similarly, if the  parameter is |language=Norwegian, it will be categorized in the same way.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the ISO639-1 two character code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang

		if 2 == lang:len() then													-- ISO639-1 language code are 2 characters (fetchLanguageName also supports 3 character codes)
			name = mw.language.fetchLanguageName( lang:lower(), &quot;en&quot; );			-- get ISO 639-1 language name if Language is a proper code
		end
	
		if is_set (name) then													-- if Language specified a valid ISO639-1 code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang);								-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then
			if 'no' == code then name = 'Norwegian' end;						-- override wikimedia when code is 'no'
			if 'en' ~= code then												-- English not the language
				add_prop_cat ('foreign_lang_source', {name, code})
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, ' and ')							-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		language_list[code] = 'and ' .. language_list[code];					-- prepend last name with 'and&lt;space&gt;'
		name = table.concat (language_list, ', ')								-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
	end
	if 'English' == name then
		return '';																-- if one language and that language is English return an enpty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
end

--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = '.';																-- terminate the rendered citation with a period
	end
	return '.', ps;																-- separator is a full stop
end

--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = '';																-- make sure it isn't nil
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return ',', ps, ref;														-- separator is a comma
end

--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		if is_set (mode) then
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'mode', mode}, true ) } );		-- add error message
		end
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end

--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extension, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf[%?#]?') or url:match ('%.PDF[%?#]?');
end

--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parenthases, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end

--[[--------------------------&lt; G E T _ D I S P L A Y _ A U T H O R S _ E D I T O R S &gt;------------------------

Returns a number that may or may not limit the length of the author or editor name lists.

When the value assigned to |display-authors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-authors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

]]

local function get_display_authors_editors (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count and 'authors' == list_name then	-- AUTHORS ONLY		-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_auth_ed', list_name);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset
		end
	elseif 'authors' == list_name then		-- AUTHORS ONLY	need to clear implicit et al category
		max = count + 1;														-- number of authors + 1
	end
	
	return max, etal;
end

--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page, nopp)
--	local good_pattern = '^P[^%.P%l]';
	local good_pattern = '^P[^%.Pp]';										-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
--	local bad_pattern = '^[Pp][Pp]';
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if is_set (nopp) then													-- don't bother checking if |nopp= is set
		return;
	end

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
--		if Page:match ('^[Pp]?[Pp]%.?[ %d]') or  Page:match ('^[Pp]ages?[ %d]') or
--			Pages:match ('^[Pp]?[Pp]%.?[ %d]') or  Pages:match ('^[Pp]ages?[ %d]') then
--				add_maint_cat ('extra_text');
--		end
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	if vparam:find ('%[%[') or vparam:find ('%]%]')	then						-- no wikilinking vauthors names
		add_vanc_error ();
	end
	v_name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;)								-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parenthese to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')
			corporate = true;
		elseif string.find(v_name, &quot;%s&quot;) then
		    lastfirstTable = {}
		    lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
		    first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
		    last  = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) and not mw.ustring.match (first, &quot;^%u?%u$&quot;) then		-- first shall contain one or two upper-case letters, nothing else
			add_vanc_error ();
		end
																				-- this from extract_names ()
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', 1 ) or		-- do this twice incase we have a first 1 without a last1
		select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 0;																	-- no authors so return 0 
end

--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );

	local i 
	local PPrefix = A['PPrefix']
	local PPPrefix = A['PPPrefix']
	local NoPP = A['NoPP'] 
	if in_array(NoPP:lower(), {'yes', 'true', 'y'}) then
		PPPrefix = '';															-- unset these, prefix if used is in |page= or |pages=
		PPrefix = '';
	else
		NoPP = nil;																-- unset, used as a flag later
	end

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];									-- replaces |author-format= and |editor-format=

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
		end
	end

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
		end
	end

	if is_set (NameListFormat) and ('vanc' ~= NameListFormat) then											-- only accepted value for this parameter is 'vanc'
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {'name-list-format', NameListFormat}, true ) } );	-- not vanc so add error message
		NameListFormat = '';													-- set to empty string
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
	local Chapter = A['Chapter'];
	local ChapterLink = A['ChapterLink'];										-- deprecated but used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];
	local ArchiveURL = A['ArchiveURL'];
	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];

	local Series = A['Series'];
	local Volume = A['Volume'];
	local Issue = A['Issue'];
	local Position = '';
	local Page = A['Page'];
	local Pages = hyphen_to_dash( A['Pages'] );	
	local At = A['At'];

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
	local SubscriptionRequired = A['SubscriptionRequired'];
	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local ArchiveDate = A['ArchiveDate'];
	local Agency = A['Agency'];
	local DeadURL = A['DeadURL']
	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
	local no_tracking_cats = A['NoTracking'];

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local use_lowercase;								-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();		-- also used for COinS and for language
	local anchor_year;									-- used in the CITEREF identifier
	local COinS_date;									-- used in the COinS metadata

-- set default parameter values defined by |mode= parameter.  If |mode= is empty or omitted, use CitationClass to set these values
	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (A['Mode']:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

-- check for extra |page=, |pages= or |at= parameters. 
	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Page = Page .. &quot; &quot; .. set_error('extra_pages');						-- add error message
			Pages = '';															-- unset the others
			At = '';
		end
		extra_text_in_page_check (Page, NoPP);									-- add this page to maint cat if |page= value begins with what looks like p. or pp.
	elseif is_set(Pages) then
		if is_set(At) then
			Pages = Pages .. &quot; &quot; .. set_error('extra_pages');					-- add error messages
			At = '';															-- unset
		end
		extra_text_in_page_check (Pages, NoPP);									-- add this page to maint cat if |page= value begins with what looks like p. or pp.
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped
	|url maps to |chapterurl when |title is remapped

All other combinations of |encyclopedia, |title, and |article are not modified
TODO: script-title to script-chapter if and when we support script-chapter
]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then					-- Periodical is set when |encyclopedia is set
			if is_set(Title) then
				if not is_set(Chapter) then
					Chapter = Title;				-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					TransChapter = TransTitle;
					ChapterURL = URL;
					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter= '[[' .. TitleLink .. '|' .. Chapter .. ']]';
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';				-- redundant so unset
					TransTitle = '';				-- redundant so unset
					URL = '';						-- redundant so unset
					Format = '';					-- redundant so unset
					TitleLink = '';					-- redundant so unset
				end
			else									-- |title not set
				Title = Periodical;					-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';					-- redundant so unset
			end
		end
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then	-- special case for cite techreport
		if is_set(Issue) then						-- cite techreport uses 'number', which other citations aliase to 'issue'
			if not is_set(ID) then					-- can we use ID for the &quot;number&quot;?
				ID = Issue;							-- yes, use it
				Issue = &quot;&quot;;							-- unset Issue so that &quot;number&quot; isn't duplicated in the rendered citation or COinS metadata
			else									-- can't use ID so emit error message
				ID = ID .. &quot; &quot; .. set_error('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Others) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Others;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Others;
			end
		else
			Others = '(Interview)';
		end
	end

-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local Began = A['Began'];												-- these two are deprecated because the module understands date ranges
		local Ended = A['Ended'];
		local SeriesLink = A['SeriesLink'];
		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};

																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) then												-- promote airdate or Began/Ended to date
			if is_set (AirDate) then
				Date = AirDate;
			elseif is_set (Began) then											-- deprecated
				if Began:match('%s') or Ended:match('%s') then					-- so we don't create errors: if either has spaces then
					Date = Began .. ' – ' .. Ended;								-- use spaced ndash as separator
				else
					Date = Began .. '–' .. Ended;								-- elsewise no spaces
				end
			end
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('series', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = '[[' .. ChapterLink .. '|' .. Chapter .. ']]';		-- ok to wikilink
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = '[[' .. ChapterLink .. '|' .. Series .. ']]';			-- series links with ChapterLink (episodelink -&gt; TitleLink -&gt; ChapterLink) ugly
			end
			URL = '';															-- unset
			TransTitle = '';													-- unset
			
		else																	-- now oddities that are cite serial
			Issue = '';														-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = '[[' .. SeriesLink .. '|' .. Series .. ']]';
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
-- end of {{cite episode}} stuff

-- Account for the oddities that are {{cite arxiv}}, before generation of COinS data.
	if 'arxiv' == config.CitationClass then
		if not is_set (ID_list['ARXIV']) then									-- |arxiv= or |eprint= required for cite arxiv
			table.insert( z.message_tail, { set_error( 'arxiv_missing', {}, true ) } );		-- add error message
		elseif is_set (Series) then												-- series is an alias of version
			ID_list['ARXIV'] = ID_list['ARXIV'] .. Series;						-- concatenate version onto the end of the arxiv identifier
			Series = '';														-- unset
			deprecated_parameter ('version');									-- deprecated parameter but only for cite arxiv
		end
		
		if first_set (AccessDate, At, Chapter, Format, Page, Pages, Periodical, PublisherName, URL,	-- a crude list of parameters that are not supported by cite arxiv
			ID_list['ASIN'], ID_list['BIBCODE'], ID_list['DOI'], ID_list['ISBN'], ID_list['ISSN'],
			ID_list['JFM'], ID_list['JSTOR'], ID_list['LCCN'], ID_list['MR'], ID_list['OCLC'], ID_list['OL'],
			ID_list['OSTI'], ID_list['PMC'], ID_list['PMID'], ID_list['RFC'], ID_list['SSRN'], ID_list['USENETID'], ID_list['ZBL']) then
				table.insert( z.message_tail, { set_error( 'arxiv_params_not_supported', {}, true ) } );		-- add error message

				AccessDate= '';													-- set these to empty string; not supported in cite arXiv
				PublisherName = '';												-- (if the article has been published, use cite journal, or other)
				Chapter = '';
				URL = '';
				Format = '';
				Page = ''; Pages = ''; At = '';
		end
		Periodical = 'arXiv';													-- set to arXiv for COinS; after that, must be set to empty string
	end

-- handle type parameter for those CS1 citations that have default values

	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
		TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot;;									-- display it in parentheses
	end

-- legacy: promote concatenation of |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set (Date) then
		Date = Year;						-- promote Year to Date
		Year = nil;							-- make nil so Year as empty string isn't used for CITEREF
		if is_set(Date) then
			local Month = A['Month'];
			if is_set(Month) then
				Date = Month .. &quot; &quot; .. Date;
			end
		elseif is_set(PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;			-- promote PublicationDate to Date
			PublicationDate = '';			-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end	-- if PublicationDate is same as Date, don't display in rendered citation

--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	do	-- create defined block to contain local variables error_message and mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		anchor_year, COinS_date, error_message = dates({['accessdate']=AccessDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
			['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end

		if is_set(error_message) then
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end
	end	-- end of do

-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);											-- 

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
		table.insert( z.message_tail, { set_error( 'citation_missing_title', {}, true ) } );
	end
	
	if 'none' == Title and is_set(Periodical) and not (( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia))) then								-- special case
		Title = '';																-- set title to empty string
		add_maint_cat ('untitled');
	end

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	
	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = Periodical,
		['Chapter'] = strip_apostrophe_markup (coins_chapter),					-- Chapter stripped of bold / italic wikimarkup
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = first_set(COinS_date, Date),		-- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here?  Should we be including invalid dates in metadata?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set(Sheet, Sheets, Page, Pages, At)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set( URL, ChapterURL ),
		['Authors'] = a,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

-- Account for the oddities that are {{cite arxiv}}, AFTER generation of COinS data.
	if 'arxiv' == config.CitationClass then										-- we have set rft.jtitle in COinS to arXiv, now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in cite arxiv; if article has been published, use cite journal
	end

-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = '[[Usenet newsgroup|Newsgroup]]:&amp;nbsp;' ..  external_link( 'news:' .. PublisherName, PublisherName );
		end
	end



	-- Now perform various field 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.
	do																			-- do-block to limit scope of last_first_list
		local last_first_list;
		local maximum = A['DisplayAuthors'];

		maximum , author_etal = get_display_authors_editors (maximum, #a, 'authors', author_etal);

		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text											-- get current page name so that we don't wikilink to it via authorlinkn
			};
		
		if is_set(Coauthors) then												-- if the coauthor field is also used, prevent ampersand and et al. formatting.
			control.lastauthoramp = nil;
			control.maximum = #a + 1;
		end
		
		last_first_list = list_people(control, a, author_etal);

		if is_set (Authors) then
			Authors, author_etal = name_has_etal (Authors, author_etal, false);	-- find and remove variations on et al.
			if author_etal then
				Authors = Authors .. ' ' .. cfg.messages['et al'];				-- add et al. to authors parameter
			end
		else
			Authors = last_first_list;											-- either an author name list or an empty string
		end

	end																			-- end of do

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { set_error('coauthors_missing_author', {}, true) } );	-- emit error message
	end

	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local maximum = A['DisplayEditors'];

		maximum , editor_etal = get_display_authors_editors (maximum, #e, 'editors', editor_etal);
		-- Preserve old-style implicit et al.
		if not is_set(maximum) and #e == 4 then 
			maximum = 3;
			table.insert( z.message_tail, { set_error('implict_etal_editor', {}, true) } );
		end

		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text											-- get current page name so that we don't wikilink to it via editorlinkn
		};

		last_first_list, EditorCount = list_people(control, e, editor_etal);

		if is_set (Editors) then
			if editor_etal then
				Editors = Editors .. ' ' .. cfg.messages['et al'];				-- add et al. to editors parameter beause |display-editors=etal
				EditorCount = 2;												-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
			else
				EditorCount = 2;												-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
			end
		else
			Editors = last_first_list;											-- either an author name list or an empty string
		end

		if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then			-- only one editor displayed but includes etal then 
			EditorCount = 2;													-- spoof to display (eds.) annotation
		end
	end


-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

	if  not is_set(URL) then --and
--		not is_set(ArchiveURL) then --and										-- prevents format_missing_url error from registering
--		not is_set(ConferenceURL) and											-- TODO: keep this here? conference as part of cite web or cite podcast?
--		not is_set(TranscriptURL) then											-- TODO: remove? |transcript-url= and |transcript= has separate test
		
		-- Test if cite web or cite podcast |url= is missing or empty 
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then	
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- Test if accessdate is given without giving a URL
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when the others are not set; TODO: move this to a separate test?
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalFormat;											-- TODO: swap chapter and title here so that archive applies to most specific if both are set?
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalFormat = Format;											-- and original |format=
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
			end
		elseif is_set (ChapterURL) then 										-- URL not set so if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalFormat = ChapterFormat;										-- and original |format=
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
			end
		end
	end

	if in_array(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;journal&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;, &quot;newsgroup&quot;, 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			if is_set (Chapter) or is_set (TransChapter) or is_set (ChapterURL)then	-- chapter parameters not supported for these citation types
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {}, true ) } );		-- add error message
				Chapter = '';														-- set to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
			end
	else																		-- otherwise, format chapter / article title
		Chapter = format_chapter_title (Chapter, TransChapter, ChapterURL, ChapterURLorigin);
		if is_set (Chapter) then
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;
			end
			Chapter = Chapter .. ChapterFormat .. sepc .. ' ';
		end
	end

	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if in_array(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;journal&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;, &quot;newsgroup&quot;, &quot;mailinglist&quot;, 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
	
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title' );
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then 
			Title = external_link( URL, Title ) .. TransError .. Format;
			URL = &quot;&quot;;
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		if is_set(Minutes) then
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			local Time = A['Time'];
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end
	
	if not is_set(Page) then
		if is_set(Pages) then
			if is_set(Periodical) and
				not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
				Pages = &quot;: &quot; .. Pages;
			elseif tonumber(Pages) ~= nil then
				Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
			else
				Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
			end
		end
	else
		if is_set(Periodical) and
			not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
			Page = &quot;: &quot; .. Page;
		else
			Page = sepc ..&quot; &quot; .. PPrefix .. Page;
		end
	end

	if 'map' == config.CitationClass then										-- cite map oddity done after COinS call (and with other in-source locators)
		if is_set (Sheet) or is_set (Sheets) then
			local err_msg1 = 'sheet=, &amp;#124;sheets';							-- default error message in case any of page pages or at are set
			local err_msg2;
			if is_set (Page) or is_set (Pages) or is_set (At) then				-- are any set?
				err_msg2 = 'page=, &amp;#124;pages=, &amp;#124;at';						-- a generic error message
				Page = ''; Pages = ''; At = '';
			elseif is_set (Sheet) and is_set (Sheets) then						-- if both are set make error message
				err_msg1 = 'sheet';
				err_msg2 = 'sheets';
			end
			if is_set (err_msg2) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', err_msg1) .. ' and ' .. wrap_style ('parameter', err_msg2)}, true ) } );		-- add error message
			end
			if not is_set (Sheet) then											-- do sheet static text and formatting; Sheet has priority over Sheets if both provided
				if is_set (Sheets) then
					if is_set (Periodical) then
						Sheet = &quot;: Sheets &quot; .. Sheets;							-- because Sheet has priority, no need to support both later on
					else
						Sheet = sepc .. &quot; Sheets &quot; .. Sheets;
					end
				end
			else
				if is_set (Periodical) then
					Sheet = &quot;: Sheet &quot; .. Sheet;
				else
					Sheet = sepc .. &quot; Sheet &quot; .. Sheet;
				end
			end
		end
	end

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('[Ee]d%.?$') or Edition:match ('[Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end
	Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc ..&quot; &quot; .. Volume;
		  else Volume = &quot; &lt;b&gt;&quot; .. hyphen_to_dash(Volume) .. &quot;&lt;/b&gt;&quot;;
		end
	end

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

--[[
Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
note is displayed. There are no error messages for this condition.

]]
	if in_array(SubscriptionRequired:lower(), {'yes', 'true', 'y'}) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif in_array(RegistrationRequired:lower(), {'yes', 'true', 'y'}) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if 'citation', lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text
																				-- neither of these work; don't know why; it seems that substitute() isn't being called	
		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
			Quote = Quote:sub(2,-2);
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- CS1 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text,
				{ external_link( OriginalURL, cfg.messages['original'] ) .. OriginalFormat, ArchiveDate } );	-- format already styled
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'] ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower() ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin );
	end

	local Publisher;
	if is_set(Periodical) and
		not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap_msg ('published', PublicationDate);
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap_msg ('published', PublicationDate) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
			Language, Edition, Publisher, Agency, Volume, Issue}, sepc );
		
	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume, Issue}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Transcript, Language, Edition, Publisher}, sepc );
	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Issue, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Sheet .. Page .. Pages .. At;
	
	if is_set(Authors) then
		if is_set(Coauthors) then
			local sep = '; ';
			if 'vanc' == NameListFormat then
				sep = ', ';
			end
			Authors = Authors .. sep .. Coauthors;
		end
		if is_set(Date) then
			Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		elseif string.sub(Authors,-1,-1) == sepc then
			Authors = Authors .. &quot; &quot;
		else
			Authors = Authors .. sepc .. &quot; &quot;
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			if (sepc ~= '.') then in_text = in_text:lower() end
			Editors = in_text .. Editors .. post_text;
			if (string.sub(Editors,-1,-1) == sepc) or (string.sub(Editors,-3,-1) == sepc .. ']]') then	-- if last editor name ends with sepc char
				Editors = Editors .. &quot; &quot;;										-- don't add another
			else
				Editors = Editors .. sepc .. &quot; &quot;								-- otherwise terninate the editor list
			end
		end
		text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
		text = safe_join( {text, pgtext, idcommon}, sepc );
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon}, sepc );
		text = safe_join( {text, pgtext, idcommon}, sepc );
	else
		if is_set(Date) then
			if ( string.sub(tcommon,-1,-1) ~= sepc )
			  then Date = sepc ..&quot; &quot; .. Date .. OrigYear
			  else Date = &quot; &quot; .. Date .. OrigYear
			end
		end
		if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon}, sepc );
			text = safe_join( {text, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date}, sepc );
			text = safe_join( {text, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;span/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = &quot;citation &quot; .. config.CitationClass;
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
		local id = Ref
		if ( &quot;harv&quot; == Ref ) then
			local names = {} --table of last names &amp; year
			if #a &gt; 0 then
				for i,v in ipairs(a) do 
					names[i] = v.last 
					if i == 4 then break end
				end
			elseif #e &gt; 0 then
				for i,v in ipairs(e) do 
					names[i] = v.last 
					if i == 4 then break end				
				end
			end
			names[ #names + 1 ] = first_set(Year, anchor_year);	-- Year first for legacy citations and for YMD dates that require disambiguation
			id = anchor_id(names)
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then 
		text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	else
		text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	end		

	local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
	
	-- Note: Using display: none on then COinS span breaks some clients.
	local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
	text = text .. OCinS;
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. error_comment( v[1], v[2] );
				else
					text = text .. error_comment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end

	if #z.maintenance_cats ~= 0 then
		text = text .. '&lt;span class=&quot;citation-comment&quot; style=&quot;display:none; color:#33aa33&quot;&gt;';
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. ' ' .. v .. ' ([[:Category:' .. v ..'|link]])';
		end
		text = text .. '&lt;/span&gt;';	-- maintenance mesages (realy just the names of the categories for now)
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
	local pframe = frame:getParent()
	local validation;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of Configuration and Whitelist and ...
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');	-- ... sandbox version of date validation code

	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of Configuration and Whitelist and ...
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		validation = require ('Module:Citation/CS1/Date_validation');			-- ... live version of date validation code
	end

	dates = validation.dates;													-- imported functions
	year_date_check = validation.year_date_check;

	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if #suggestions == 0 then
						suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
					end
					if suggestions[ k:lower() ] ~= nil then
						error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
					else
						error_text, error_state = set_error( 'parameter_ignored', {k}, true );
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	
	
	return citation0( config, args)
end

return z</text>
      <sha1>6i2ehmhjtybprdyct0atqe1o869u02e</sha1>
    </revision>
    <revision>
      <id>4693</id>
      <parentid>4692</parentid>
      <timestamp>2015-08-31T05:29:59Z</timestamp>
      <contributor>
        <username>Shyamal</username>
        <id>808</id>
      </contributor>
      <comment>sorry, I am not very good at testing in the sandbox - so here is a bold test, will revert on failure</comment>
      <origin>4693</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="145608" sha1="n82ihyt60cnbcwyryt7bvoasasxi6fo" xml:space="preserve">
local z = {
	error_categories = {};		-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};		-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};		-- for categorizing citations based on certain properties, language of source for instance
}

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]
local dates, year_date_check	-- functions in Module:Citation/CS1/Date_validation

local cfg = {};					-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};			-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist

--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.
This function is global because it is called from both this module and from Date validation

]]
function is_set( var )
	return not (var == nil or var == '');
end

--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

First set variable or nil if none

]]

local function first_set(...)
	local list = {...};
	for _, var in pairs(list) do
		if is_set( var ) then
			return var;
		end
	end
end

--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end

--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]
local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end

--[[--------------------------&lt; S E T _ E R R O R &gt;--------------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

]]
local function set_error( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if in_array( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return error_comment( message, error_state.hidden );
end

--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maintenance_cats using names from the configuration file with additional text if any.
To prevent duplication, the added_maint_cats table lists the categories by key that have been added to z.maintenance_cats.

]]

local added_maint_cats = {}														-- list of maintenance categories that have been added to z.maintenance_cats
local function add_maint_cat (key, arguments)
	if not added_maint_cats [key] then
		added_maint_cats [key] = true;											-- note that we've added this category
		table.insert( z.maintenance_cats, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
	end
end

--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

]]

local added_prop_cats = {}														-- list of property categories that have been added to z.properties_cats
local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));		-- make name then add to table
	end
end

--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

]]

local added_vanc_errs;															-- flag so we only emit one Vancouver error / category
local function add_vanc_error ()
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {}, true ) } );
	end
end

--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string is valid.

At present the only check is whether the string appears to be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well formed.

]]

local function check_url( url_str )
	return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;		-- Protocol-relative or URL scheme
end

--[[--------------------------&lt; S A F E _ F O R _ I T A L I C S &gt;----------------------------------------------

Protects a string that will be wrapped in wiki italic markup '' ... ''

Note: We cannot use &lt;i&gt; for italics, as the expected behavior for italics specified by ''...'' in the title is that
they will be inverted (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and '' tend to interact
poorly under Mediawiki's HTML tidy.

]]

local function safe_for_italics( str )
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end

--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

local function wrap_style (key, str)
	if not is_set( str ) then
		return &quot;&quot;;
	elseif in_array( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safe_for_italics( str );
	end

	return substitute( cfg.presentation[key], {str} );
end

--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source )
	local error_str = &quot;&quot;;
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
	end
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url( label ), &quot;]&quot;, error_str });
end

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

]]

local page_in_deprecated_cat;													-- sticky flag so that the category is added only once
local function deprecated_parameter(name)
	if not page_in_deprecated_cat then
		page_in_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end

--[[--------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Call this function for chapter titles, for website titles, etc; not for book titles.

]]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	
	cap, cap2 = str:match (&quot;^([\&quot;\'])([^\'].+)&quot;);								-- match leading double or single quote but not double single quotes
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-left'], {cap, cap2});
	end

	cap, cap2 = str:match (&quot;^(.+[^\'])([\&quot;\'])$&quot;)
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-right'], {cap, cap2});
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

At this writing, only |script-title= is supported.  It is anticipated that additional parameters will be created to use this function.

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, {'ar', 'bg', 'bs', 'dv', 'el', 'fa', 'hy', 'ja', 'ka', 'ko', 'ku', 'he', 'ps', 'ru', 'sd', 'sr', 'th', 'uk', 'ug', 'yi', 'zh'}) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				add_prop_cat ('script')
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		str = substitute( msg, {str} );											-- including template text
		return str;
	else
		return substitute( cfg.messages[key], {str} );
	end		
end

--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider
Generates an error if more than one match is present.

]]

local function select_one( args, possible, error_condition, index )
	local value = nil;
	local selected = '';
	local error_list = {};
	
	if index ~= nil then index = tostring(index); end
	
	-- Handle special case of &quot;#&quot; replaced by empty string
	if index == '1' then
		for _, v in ipairs( possible ) do
			v = v:gsub( &quot;#&quot;, &quot;&quot; );
			if is_set(args[v]) then
				if value ~= nil and selected ~= v then
					table.insert( error_list, v );
				else
					value = args[v];
					selected = v;
				end
			end
		end		
	end
	
	for _, v in ipairs( possible ) do
		if index ~= nil then
			v = v:gsub( &quot;#&quot;, index );
		end
		if is_set(args[v]) then
			if value ~= nil and selected ~=  v then
				table.insert( error_list, v );
			else
				value = args[v];
				selected = v;
			end
		end
	end
	
	if #error_list &gt; 0 then
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap_style ('parameter', k);
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap_style ('parameter', selected);
		table.insert( z.message_tail, { set_error( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end

--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the three chapter parameters: |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (chapter, transchapter, chapterurl, chapter_url_source)
	local chapter_error = '';
	
	if not is_set (chapter) then
		chapter = '';															-- just to be safe for concatenation
		if is_set (transchapter) then
			chapter = wrap_style ('trans-quoted-title', transchapter);
			chapter_error = &quot; &quot; .. set_error ('trans_missing_chapter');
		end
		if is_set (chapterurl) then
			chapter = external_link (chapterurl, chapter, chapter_url_source);	-- adds bare_url_missing_title error if appropriate
		end
		return chapter .. chapter_error;
	else																		-- here when chapter is set
		chapter = kern_quotes (chapter);										-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
		chapter = wrap_style ('quoted-title', chapter);
		if is_set (transchapter) then
			transchapter = wrap_style ('trans-quoted-title', transchapter);
			chapter = chapter .. ' ' .. transchapter;
		end
		if is_set (chapterurl) then
			chapter = external_link (chapterurl, chapter);						-- adds bare_url_missing_title error if appropriate
		end
	end
	return chapter;
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
]]

local function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end


-- Formats a wiki style internal link
local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s*%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s*%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end

--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in check_isbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end

--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end

--[[--------------------------&lt; C H E C K _ I S M N &gt;------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the issn is invalid
	end 
	
	return text;
end

--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link = handler.link,
		label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
		encode=handler.encode, separator = handler.separator}) .. err_cat;
end

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end

--[[
lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--[[
Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of the LCCN dictates the character type of the first 1-3 characters; the
rightmost eight are always digits. http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end

--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.

-- DOI names contain two parts: prefix and suffix separated by a forward slash.
--  Prefix: directory indicator '10.' followed by a registrant code
--  Suffix: character string of any length chosen by the registrant

-- This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes,
-- or, if it ends with a period or a comma, this function will emit a bad_doi error message.

-- DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
-- and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely if ever used in doi names.

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);					-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode}) .. 
			' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end

--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end

--[[--------------------------&lt; C L E A N _ I S B N &gt;----------------------------------------------------------

Removes irrelevant text and dashes from ISBN number
Similar to that used for Special:BookSources

]]

local function clean_isbn( isbn_str )
	return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]
local function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other lua magic pattern characters
	return argument;
end

--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	while true do
		if argument:match (&quot;%'%'%'%'%'&quot;) then									-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:match (&quot;%'%'%'%'&quot;) then									-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:match (&quot;%'%'%'&quot;) then									-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:match (&quot;%'%'&quot;) then										-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end

--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...
]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end

--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
local function remove_wiki_link( str )
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end

-- Converts a hyphen to a dash
local function hyphen_to_dash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end

--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if comp:sub(1,1) == duplicate_char then								-- is first charactier same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for th
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = str:sub(-1,-1);										-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = str:sub(1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = str:sub(1, -4) .. &quot;''&quot;;							-- remove them and add back ''
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then		-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then		-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then			-- if last two chars of str are sepc] external link
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;'']&quot; then		-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then				-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = str:sub(1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end		-- if duplicate_char not a letter then escape it
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )			-- remove duplicate_char if it follows html markup
					else
						value = value:sub( 2, -1 );								-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end  

--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

At the time of this writing, I had to write the 'if nil == mw.ustring.find ...' test ouside of the code editor and paste it here
because the code editor gets confused between character insertion point and cursor position.

]]

local function is_good_vanc_name (last, first)
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]*$&quot;) then
		add_vanc_error ();
		return false;															-- not a string of latin characters; Vancouver required Romanization
	end;
	return true;
end

--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  This form is not
currently supported by this code so correctly formed names like Smith JL 2nd are converted to Smith J2. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	if mw.ustring.match(first, &quot;^%u%u$&quot;) then return first end;					-- when first contains just two upper-case letters, nothing to do
	local initials = {}
	local i = 0;																-- counter for number of initials
	for word in mw.ustring.gmatch(first, &quot;[^%s%.%-]+&quot;) do						-- names separated by spaces, hyphens, or periods
		table.insert(initials, mw.ustring.sub(word,1,1))						-- Vancouver format does not include full stops.
		i = i + 1;																-- bump the counter 
		if 2 &lt;= i then break; end												-- only two initials allowed in Vancouver system; if 2, quit
	end
	return table.concat(initials)												-- Vancouver format does not include spaces.
end

--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = ',';																-- name-list separator between authors is a comma
		namesep = ' ';															-- last/first separator is a space
	else
		sep = ';'																-- name-list separator between authors is a semicolon
		namesep = ', '															-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then					-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first 
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;				-- link author/editor if this page is not the author's/editor's page
				end

				if is_set(person.link) and ((nil ~= person.link:find(&quot;//&quot;)) or (nil ~= person.link:find(&quot;[%[%]]&quot;))) then
					one = one .. &quot; &quot; .. set_error( 'bad_authorlink' ) end		-- url or wikilink in author link;
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. ' ' .. cfg.messages['et al'];						-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end

--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

]]

local function anchor_id( options )
	local id = table.concat( options );											-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end

--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of author and editor name parameters for variations on the theme eof et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the parameters |display-authors=etal or |displayeditors=etal

]]

local function name_has_etal (name, etal, nocat)

	if is_set (name) then														-- name can be nil in which case just return
		local pattern = &quot;[;,]? *[\&quot;']*%f[Ee][Ee][Tt] *[Aa][Ll][%.\&quot;']*$&quot;		-- variations on the 'et al' theme
		
		if name:match (pattern) then											-- variants on et al.
			name = name:gsub (pattern, '');										-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		end
	end
	return name, etal;															-- 
end

--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary

	while true do
		last = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false);								-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false);								-- find and remove variations on et al.

		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end

-- Populates ID table from arguments using configuration settings
local function extract_ids( args )
	local id_list = {};
	for k, v in pairs( cfg.id_handlers ) do	
		v = select_one( args, v.parameters, 'redundant_parameters' );
		if is_set(v) then id_list[k] = v; end
	end
	return id_list;
end

--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs and turns it into a table of formatted ID outputs.

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end
  

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end
	
	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if is_set(data.Chapter) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
	elseif is_set(data.Periodical) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
		if 'arxiv' == class then
			OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;								-- cite arxiv
		else
			OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
		end
		OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	else
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
	end
	
	OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
	OCinSoutput[&quot;rft.date&quot;] = data.Date;
	OCinSoutput[&quot;rft.series&quot;] = data.Series;
	OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
	OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
	OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
	OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
	OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
	
	for k, v in pairs( data.ID_list ) do
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
	
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = v.last, v.first;
		if k == 1 then
			if is_set(last) then
				OCinSoutput[&quot;rft.aulast&quot;] = last;
			end
			if is_set(first) then 
				OCinSoutput[&quot;rft.aufirst&quot;] = first;
			end
		end
	        if #data.Authors &gt; 1 then
                   if is_set(last) and is_set(first) then
			OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
		   elseif is_set(last) then
			OCinSoutput[&quot;rft.au&quot;] = last;
		   end
                end
	end
	
	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 code.  Handles the special case that is Norwegian where
ISO639-1 code 'no' is mapped to language name 'Norwegian Bokmål' by Extention:CLDR.

Returns the language name and associated ISO639-1 code.  Because case of the source may be incorrect or different from the case that Wikimedia
uses, the name comparisons are done in lower case and when a match is found, the Wikimedia version (assumed to be correct) is returned along
with the code.  When there is no match, we return the original language name string.

mw.language.fetchLanguageNames() will return a list of languages that aren't part of ISO639-1. Names that aren't ISO639-1 but that are included
in the list will be found if that name is provided in the |language= parameter.  For example, if |language=Samaritan Aramaic, that name will be
found with the associated code 'sam', not an ISO639-1 code.  When names are found and the associated code is not two characters, this function
returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang)
	if 'norwegian' == lang:lower() then											-- special case related to Wikimedia remap of code 'no' at Extension:CLDR
		return 'Norwegian', 'no';												-- Make sure rendered version is properly capitalized
	end
	
	local languages = mw.language.fetchLanguageNames('en', 'all')				-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() then												-- ISO639-1 codes only
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the ISO639-1 code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for ISO639-1 code
end

--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Get language name from ISO639-1 code value provided.  If a code is valid use the returned name; if not, then use the value that was provided with the language parameter.

There is an exception.  There are three ISO639-1 codes for Norewegian language variants.  There are two official variants: Norwegian Bokmål (code 'nb') and
Norwegian Nynorsk (code 'nn').  The third, code 'no',  is defined by ISO639-1 as 'Norwegian' though in Norway this is pretty much meaningless.  However, it appears
that on enwiki, editors are for the most part unaware of the nb and nn variants (compare page counts for these variants at Category:Articles with non-English-language external links.

Because Norwegian Bokmål is the most common language variant, Media wiki has been modified to return Norwegian Bokmål for ISO639-1 code 'no'. Here we undo that and
return 'Norwegian' when editors use |language=no.  We presume that editors don't know about the variants or can't descriminate between them.

See Help talk:Citation Style_1#An ISO 639-1 language name test

When |language= contains a valid ISO639-1 code, the page is assigned to the category for that code: Category:Norwegian-language sources (no) if
the page is a mainspace page and the ISO639-1 code is not 'en'.  Similarly, if the  parameter is |language=Norwegian, it will be categorized in the same way.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the ISO639-1 two character code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang

		if 2 == lang:len() then													-- ISO639-1 language code are 2 characters (fetchLanguageName also supports 3 character codes)
			name = mw.language.fetchLanguageName( lang:lower(), &quot;en&quot; );			-- get ISO 639-1 language name if Language is a proper code
		end
	
		if is_set (name) then													-- if Language specified a valid ISO639-1 code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang);								-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then
			if 'no' == code then name = 'Norwegian' end;						-- override wikimedia when code is 'no'
			if 'en' ~= code then												-- English not the language
				add_prop_cat ('foreign_lang_source', {name, code})
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, ' and ')							-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		language_list[code] = 'and ' .. language_list[code];					-- prepend last name with 'and&lt;space&gt;'
		name = table.concat (language_list, ', ')								-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
	end
	if 'English' == name then
		return '';																-- if one language and that language is English return an enpty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
end

--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = '.';																-- terminate the rendered citation with a period
	end
	return '.', ps;																-- separator is a full stop
end

--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = '';																-- make sure it isn't nil
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return ',', ps, ref;														-- separator is a comma
end

--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		if is_set (mode) then
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'mode', mode}, true ) } );		-- add error message
		end
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end

--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extension, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf[%?#]?') or url:match ('%.PDF[%?#]?');
end

--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parenthases, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end

--[[--------------------------&lt; G E T _ D I S P L A Y _ A U T H O R S _ E D I T O R S &gt;------------------------

Returns a number that may or may not limit the length of the author or editor name lists.

When the value assigned to |display-authors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-authors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

]]

local function get_display_authors_editors (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count and 'authors' == list_name then	-- AUTHORS ONLY		-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_auth_ed', list_name);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset
		end
	elseif 'authors' == list_name then		-- AUTHORS ONLY	need to clear implicit et al category
		max = count + 1;														-- number of authors + 1
	end
	
	return max, etal;
end

--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page, nopp)
--	local good_pattern = '^P[^%.P%l]';
	local good_pattern = '^P[^%.Pp]';										-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
--	local bad_pattern = '^[Pp][Pp]';
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if is_set (nopp) then													-- don't bother checking if |nopp= is set
		return;
	end

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
--		if Page:match ('^[Pp]?[Pp]%.?[ %d]') or  Page:match ('^[Pp]ages?[ %d]') or
--			Pages:match ('^[Pp]?[Pp]%.?[ %d]') or  Pages:match ('^[Pp]ages?[ %d]') then
--				add_maint_cat ('extra_text');
--		end
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	if vparam:find ('%[%[') or vparam:find ('%]%]')	then						-- no wikilinking vauthors names
		add_vanc_error ();
	end
	v_name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;)								-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parenthese to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')
			corporate = true;
		elseif string.find(v_name, &quot;%s&quot;) then
		    lastfirstTable = {}
		    lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
		    first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
		    last  = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) and not mw.ustring.match (first, &quot;^%u?%u$&quot;) then		-- first shall contain one or two upper-case letters, nothing else
			add_vanc_error ();
		end
																				-- this from extract_names ()
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', 1 ) or		-- do this twice incase we have a first 1 without a last1
		select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 0;																	-- no authors so return 0 
end

--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );

	local i 
	local PPrefix = A['PPrefix']
	local PPPrefix = A['PPPrefix']
	local NoPP = A['NoPP'] 
	if in_array(NoPP:lower(), {'yes', 'true', 'y'}) then
		PPPrefix = '';															-- unset these, prefix if used is in |page= or |pages=
		PPrefix = '';
	else
		NoPP = nil;																-- unset, used as a flag later
	end

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];									-- replaces |author-format= and |editor-format=

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
		end
	end

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
		end
	end

	if is_set (NameListFormat) and ('vanc' ~= NameListFormat) then											-- only accepted value for this parameter is 'vanc'
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {'name-list-format', NameListFormat}, true ) } );	-- not vanc so add error message
		NameListFormat = '';													-- set to empty string
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
	local Chapter = A['Chapter'];
	local ChapterLink = A['ChapterLink'];										-- deprecated but used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];
	local ArchiveURL = A['ArchiveURL'];
	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];

	local Series = A['Series'];
	local Volume = A['Volume'];
	local Issue = A['Issue'];
	local Position = '';
	local Page = A['Page'];
	local Pages = hyphen_to_dash( A['Pages'] );	
	local At = A['At'];

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
	local SubscriptionRequired = A['SubscriptionRequired'];
	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local ArchiveDate = A['ArchiveDate'];
	local Agency = A['Agency'];
	local DeadURL = A['DeadURL']
	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
	local no_tracking_cats = A['NoTracking'];

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local use_lowercase;								-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();		-- also used for COinS and for language
	local anchor_year;									-- used in the CITEREF identifier
	local COinS_date;									-- used in the COinS metadata

-- set default parameter values defined by |mode= parameter.  If |mode= is empty or omitted, use CitationClass to set these values
	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (A['Mode']:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

-- check for extra |page=, |pages= or |at= parameters. 
	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Page = Page .. &quot; &quot; .. set_error('extra_pages');						-- add error message
			Pages = '';															-- unset the others
			At = '';
		end
		extra_text_in_page_check (Page, NoPP);									-- add this page to maint cat if |page= value begins with what looks like p. or pp.
	elseif is_set(Pages) then
		if is_set(At) then
			Pages = Pages .. &quot; &quot; .. set_error('extra_pages');					-- add error messages
			At = '';															-- unset
		end
		extra_text_in_page_check (Pages, NoPP);									-- add this page to maint cat if |page= value begins with what looks like p. or pp.
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped
	|url maps to |chapterurl when |title is remapped

All other combinations of |encyclopedia, |title, and |article are not modified
TODO: script-title to script-chapter if and when we support script-chapter
]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then					-- Periodical is set when |encyclopedia is set
			if is_set(Title) then
				if not is_set(Chapter) then
					Chapter = Title;				-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					TransChapter = TransTitle;
					ChapterURL = URL;
					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter= '[[' .. TitleLink .. '|' .. Chapter .. ']]';
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';				-- redundant so unset
					TransTitle = '';				-- redundant so unset
					URL = '';						-- redundant so unset
					Format = '';					-- redundant so unset
					TitleLink = '';					-- redundant so unset
				end
			else									-- |title not set
				Title = Periodical;					-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';					-- redundant so unset
			end
		end
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then	-- special case for cite techreport
		if is_set(Issue) then						-- cite techreport uses 'number', which other citations aliase to 'issue'
			if not is_set(ID) then					-- can we use ID for the &quot;number&quot;?
				ID = Issue;							-- yes, use it
				Issue = &quot;&quot;;							-- unset Issue so that &quot;number&quot; isn't duplicated in the rendered citation or COinS metadata
			else									-- can't use ID so emit error message
				ID = ID .. &quot; &quot; .. set_error('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Others) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Others;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Others;
			end
		else
			Others = '(Interview)';
		end
	end

-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local Began = A['Began'];												-- these two are deprecated because the module understands date ranges
		local Ended = A['Ended'];
		local SeriesLink = A['SeriesLink'];
		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};

																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) then												-- promote airdate or Began/Ended to date
			if is_set (AirDate) then
				Date = AirDate;
			elseif is_set (Began) then											-- deprecated
				if Began:match('%s') or Ended:match('%s') then					-- so we don't create errors: if either has spaces then
					Date = Began .. ' – ' .. Ended;								-- use spaced ndash as separator
				else
					Date = Began .. '–' .. Ended;								-- elsewise no spaces
				end
			end
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('series', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = '[[' .. ChapterLink .. '|' .. Chapter .. ']]';		-- ok to wikilink
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = '[[' .. ChapterLink .. '|' .. Series .. ']]';			-- series links with ChapterLink (episodelink -&gt; TitleLink -&gt; ChapterLink) ugly
			end
			URL = '';															-- unset
			TransTitle = '';													-- unset
			
		else																	-- now oddities that are cite serial
			Issue = '';														-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = '[[' .. SeriesLink .. '|' .. Series .. ']]';
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
-- end of {{cite episode}} stuff

-- Account for the oddities that are {{cite arxiv}}, before generation of COinS data.
	if 'arxiv' == config.CitationClass then
		if not is_set (ID_list['ARXIV']) then									-- |arxiv= or |eprint= required for cite arxiv
			table.insert( z.message_tail, { set_error( 'arxiv_missing', {}, true ) } );		-- add error message
		elseif is_set (Series) then												-- series is an alias of version
			ID_list['ARXIV'] = ID_list['ARXIV'] .. Series;						-- concatenate version onto the end of the arxiv identifier
			Series = '';														-- unset
			deprecated_parameter ('version');									-- deprecated parameter but only for cite arxiv
		end
		
		if first_set (AccessDate, At, Chapter, Format, Page, Pages, Periodical, PublisherName, URL,	-- a crude list of parameters that are not supported by cite arxiv
			ID_list['ASIN'], ID_list['BIBCODE'], ID_list['DOI'], ID_list['ISBN'], ID_list['ISSN'],
			ID_list['JFM'], ID_list['JSTOR'], ID_list['LCCN'], ID_list['MR'], ID_list['OCLC'], ID_list['OL'],
			ID_list['OSTI'], ID_list['PMC'], ID_list['PMID'], ID_list['RFC'], ID_list['SSRN'], ID_list['USENETID'], ID_list['ZBL']) then
				table.insert( z.message_tail, { set_error( 'arxiv_params_not_supported', {}, true ) } );		-- add error message

				AccessDate= '';													-- set these to empty string; not supported in cite arXiv
				PublisherName = '';												-- (if the article has been published, use cite journal, or other)
				Chapter = '';
				URL = '';
				Format = '';
				Page = ''; Pages = ''; At = '';
		end
		Periodical = 'arXiv';													-- set to arXiv for COinS; after that, must be set to empty string
	end

-- handle type parameter for those CS1 citations that have default values

	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
		TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot;;									-- display it in parentheses
	end

-- legacy: promote concatenation of |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set (Date) then
		Date = Year;						-- promote Year to Date
		Year = nil;							-- make nil so Year as empty string isn't used for CITEREF
		if is_set(Date) then
			local Month = A['Month'];
			if is_set(Month) then
				Date = Month .. &quot; &quot; .. Date;
			end
		elseif is_set(PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;			-- promote PublicationDate to Date
			PublicationDate = '';			-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end	-- if PublicationDate is same as Date, don't display in rendered citation

--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	do	-- create defined block to contain local variables error_message and mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		anchor_year, COinS_date, error_message = dates({['accessdate']=AccessDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
			['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end

		if is_set(error_message) then
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end
	end	-- end of do

-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);											-- 

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
		table.insert( z.message_tail, { set_error( 'citation_missing_title', {}, true ) } );
	end
	
	if 'none' == Title and is_set(Periodical) and not (( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia))) then								-- special case
		Title = '';																-- set title to empty string
		add_maint_cat ('untitled');
	end

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	
	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = Periodical,
		['Chapter'] = strip_apostrophe_markup (coins_chapter),					-- Chapter stripped of bold / italic wikimarkup
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = first_set(COinS_date, Date),		-- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here?  Should we be including invalid dates in metadata?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set(Sheet, Sheets, Page, Pages, At)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set( URL, ChapterURL ),
		['Authors'] = a,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

-- Account for the oddities that are {{cite arxiv}}, AFTER generation of COinS data.
	if 'arxiv' == config.CitationClass then										-- we have set rft.jtitle in COinS to arXiv, now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in cite arxiv; if article has been published, use cite journal
	end

-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = '[[Usenet newsgroup|Newsgroup]]:&amp;nbsp;' ..  external_link( 'news:' .. PublisherName, PublisherName );
		end
	end



	-- Now perform various field 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.
	do																			-- do-block to limit scope of last_first_list
		local last_first_list;
		local maximum = A['DisplayAuthors'];

		maximum , author_etal = get_display_authors_editors (maximum, #a, 'authors', author_etal);

		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text											-- get current page name so that we don't wikilink to it via authorlinkn
			};
		
		if is_set(Coauthors) then												-- if the coauthor field is also used, prevent ampersand and et al. formatting.
			control.lastauthoramp = nil;
			control.maximum = #a + 1;
		end
		
		last_first_list = list_people(control, a, author_etal);

		if is_set (Authors) then
			Authors, author_etal = name_has_etal (Authors, author_etal, false);	-- find and remove variations on et al.
			if author_etal then
				Authors = Authors .. ' ' .. cfg.messages['et al'];				-- add et al. to authors parameter
			end
		else
			Authors = last_first_list;											-- either an author name list or an empty string
		end

	end																			-- end of do

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { set_error('coauthors_missing_author', {}, true) } );	-- emit error message
	end

	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local maximum = A['DisplayEditors'];

		maximum , editor_etal = get_display_authors_editors (maximum, #e, 'editors', editor_etal);
		-- Preserve old-style implicit et al.
		if not is_set(maximum) and #e == 4 then 
			maximum = 3;
			table.insert( z.message_tail, { set_error('implict_etal_editor', {}, true) } );
		end

		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text											-- get current page name so that we don't wikilink to it via editorlinkn
		};

		last_first_list, EditorCount = list_people(control, e, editor_etal);

		if is_set (Editors) then
			if editor_etal then
				Editors = Editors .. ' ' .. cfg.messages['et al'];				-- add et al. to editors parameter beause |display-editors=etal
				EditorCount = 2;												-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
			else
				EditorCount = 2;												-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
			end
		else
			Editors = last_first_list;											-- either an author name list or an empty string
		end

		if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then			-- only one editor displayed but includes etal then 
			EditorCount = 2;													-- spoof to display (eds.) annotation
		end
	end


-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

	if  not is_set(URL) then --and
--		not is_set(ArchiveURL) then --and										-- prevents format_missing_url error from registering
--		not is_set(ConferenceURL) and											-- TODO: keep this here? conference as part of cite web or cite podcast?
--		not is_set(TranscriptURL) then											-- TODO: remove? |transcript-url= and |transcript= has separate test
		
		-- Test if cite web or cite podcast |url= is missing or empty 
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then	
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- Test if accessdate is given without giving a URL
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when the others are not set; TODO: move this to a separate test?
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalFormat;											-- TODO: swap chapter and title here so that archive applies to most specific if both are set?
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalFormat = Format;											-- and original |format=
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
			end
		elseif is_set (ChapterURL) then 										-- URL not set so if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalFormat = ChapterFormat;										-- and original |format=
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
			end
		end
	end

	if in_array(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;journal&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;, &quot;newsgroup&quot;, 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			if is_set (Chapter) or is_set (TransChapter) or is_set (ChapterURL)then	-- chapter parameters not supported for these citation types
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {}, true ) } );		-- add error message
				Chapter = '';														-- set to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
			end
	else																		-- otherwise, format chapter / article title
		Chapter = format_chapter_title (Chapter, TransChapter, ChapterURL, ChapterURLorigin);
		if is_set (Chapter) then
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;
			end
			Chapter = Chapter .. ChapterFormat .. sepc .. ' ';
		end
	end

	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if in_array(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;journal&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;, &quot;newsgroup&quot;, &quot;mailinglist&quot;, 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
	
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title' );
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then 
			Title = external_link( URL, Title ) .. TransError .. Format;
			URL = &quot;&quot;;
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		if is_set(Minutes) then
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			local Time = A['Time'];
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end
	
	if not is_set(Page) then
		if is_set(Pages) then
			if is_set(Periodical) and
				not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
				Pages = &quot;: &quot; .. Pages;
			elseif tonumber(Pages) ~= nil then
				Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
			else
				Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
			end
		end
	else
		if is_set(Periodical) and
			not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
			Page = &quot;: &quot; .. Page;
		else
			Page = sepc ..&quot; &quot; .. PPrefix .. Page;
		end
	end

	if 'map' == config.CitationClass then										-- cite map oddity done after COinS call (and with other in-source locators)
		if is_set (Sheet) or is_set (Sheets) then
			local err_msg1 = 'sheet=, &amp;#124;sheets';							-- default error message in case any of page pages or at are set
			local err_msg2;
			if is_set (Page) or is_set (Pages) or is_set (At) then				-- are any set?
				err_msg2 = 'page=, &amp;#124;pages=, &amp;#124;at';						-- a generic error message
				Page = ''; Pages = ''; At = '';
			elseif is_set (Sheet) and is_set (Sheets) then						-- if both are set make error message
				err_msg1 = 'sheet';
				err_msg2 = 'sheets';
			end
			if is_set (err_msg2) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', err_msg1) .. ' and ' .. wrap_style ('parameter', err_msg2)}, true ) } );		-- add error message
			end
			if not is_set (Sheet) then											-- do sheet static text and formatting; Sheet has priority over Sheets if both provided
				if is_set (Sheets) then
					if is_set (Periodical) then
						Sheet = &quot;: Sheets &quot; .. Sheets;							-- because Sheet has priority, no need to support both later on
					else
						Sheet = sepc .. &quot; Sheets &quot; .. Sheets;
					end
				end
			else
				if is_set (Periodical) then
					Sheet = &quot;: Sheet &quot; .. Sheet;
				else
					Sheet = sepc .. &quot; Sheet &quot; .. Sheet;
				end
			end
		end
	end

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('[Ee]d%.?$') or Edition:match ('[Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end
	Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc ..&quot; &quot; .. Volume;
		  else Volume = &quot; &lt;b&gt;&quot; .. hyphen_to_dash(Volume) .. &quot;&lt;/b&gt;&quot;;
		end
	end

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

--[[
Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
note is displayed. There are no error messages for this condition.

]]
	if in_array(SubscriptionRequired:lower(), {'yes', 'true', 'y'}) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif in_array(RegistrationRequired:lower(), {'yes', 'true', 'y'}) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if 'citation', lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text
																				-- neither of these work; don't know why; it seems that substitute() isn't being called	
		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
			Quote = Quote:sub(2,-2);
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- CS1 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text,
				{ external_link( OriginalURL, cfg.messages['original'] ) .. OriginalFormat, ArchiveDate } );	-- format already styled
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'] ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower() ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin );
	end

	local Publisher;
	if is_set(Periodical) and
		not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap_msg ('published', PublicationDate);
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap_msg ('published', PublicationDate) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
			Language, Edition, Publisher, Agency, Volume, Issue}, sepc );
		
	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume, Issue}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Transcript, Language, Edition, Publisher}, sepc );
	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Issue, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Sheet .. Page .. Pages .. At;
	
	if is_set(Authors) then
		if is_set(Coauthors) then
			local sep = '; ';
			if 'vanc' == NameListFormat then
				sep = ', ';
			end
			Authors = Authors .. sep .. Coauthors;
		end
		if is_set(Date) then
			Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		elseif string.sub(Authors,-1,-1) == sepc then
			Authors = Authors .. &quot; &quot;
		else
			Authors = Authors .. sepc .. &quot; &quot;
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			if (sepc ~= '.') then in_text = in_text:lower() end
			Editors = in_text .. Editors .. post_text;
			if (string.sub(Editors,-1,-1) == sepc) or (string.sub(Editors,-3,-1) == sepc .. ']]') then	-- if last editor name ends with sepc char
				Editors = Editors .. &quot; &quot;;										-- don't add another
			else
				Editors = Editors .. sepc .. &quot; &quot;								-- otherwise terninate the editor list
			end
		end
		text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
		text = safe_join( {text, pgtext, idcommon}, sepc );
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon}, sepc );
		text = safe_join( {text, pgtext, idcommon}, sepc );
	else
		if is_set(Date) then
			if ( string.sub(tcommon,-1,-1) ~= sepc )
			  then Date = sepc ..&quot; &quot; .. Date .. OrigYear
			  else Date = &quot; &quot; .. Date .. OrigYear
			end
		end
		if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon}, sepc );
			text = safe_join( {text, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date}, sepc );
			text = safe_join( {text, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;span/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = &quot;citation &quot; .. config.CitationClass;
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
		local id = Ref
		if ( &quot;harv&quot; == Ref ) then
			local names = {} --table of last names &amp; year
			if #a &gt; 0 then
				for i,v in ipairs(a) do 
					names[i] = v.last 
					if i == 4 then break end
				end
			elseif #e &gt; 0 then
				for i,v in ipairs(e) do 
					names[i] = v.last 
					if i == 4 then break end				
				end
			end
			names[ #names + 1 ] = first_set(Year, anchor_year);	-- Year first for legacy citations and for YMD dates that require disambiguation
			id = anchor_id(names)
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then 
		text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	else
		text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	end		

	local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
	
	-- Note: Using display: none on then COinS span breaks some clients.
	local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
	text = text .. OCinS;
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. error_comment( v[1], v[2] );
				else
					text = text .. error_comment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end

	if #z.maintenance_cats ~= 0 then
		text = text .. '&lt;span class=&quot;citation-comment&quot; style=&quot;display:none; color:#33aa33&quot;&gt;';
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. ' ' .. v .. ' ([[:Category:' .. v ..'|link]])';
		end
		text = text .. '&lt;/span&gt;';	-- maintenance mesages (realy just the names of the categories for now)
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
	local pframe = frame:getParent()
	local validation;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of Configuration and Whitelist and ...
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');	-- ... sandbox version of date validation code

	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of Configuration and Whitelist and ...
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		validation = require ('Module:Citation/CS1/Date_validation');			-- ... live version of date validation code
	end

	dates = validation.dates;													-- imported functions
	year_date_check = validation.year_date_check;

	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if #suggestions == 0 then
						suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
					end
					if suggestions[ k:lower() ] ~= nil then
						error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
					else
						error_text, error_state = set_error( 'parameter_ignored', {k}, true );
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	
	
	return citation0( config, args)
end

return z</text>
      <sha1>n82ihyt60cnbcwyryt7bvoasasxi6fo</sha1>
    </revision>
    <revision>
      <id>4694</id>
      <parentid>4693</parentid>
      <timestamp>2015-08-31T05:31:38Z</timestamp>
      <contributor>
        <username>Shyamal</username>
        <id>808</id>
      </contributor>
      <minor />
      <comment>Reverted edits by [[Special:Contribs/Shyamal|Shyamal]] ([[User talk:Shyamal|talk]]) to last version by Trappist the monk</comment>
      <origin>4694</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="145530" sha1="6i2ehmhjtybprdyct0atqe1o869u02e" xml:space="preserve">
local z = {
	error_categories = {};		-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};		-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};		-- for categorizing citations based on certain properties, language of source for instance
}

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]
local dates, year_date_check	-- functions in Module:Citation/CS1/Date_validation

local cfg = {};					-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};			-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist

--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.
This function is global because it is called from both this module and from Date validation

]]
function is_set( var )
	return not (var == nil or var == '');
end

--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

First set variable or nil if none

]]

local function first_set(...)
	local list = {...};
	for _, var in pairs(list) do
		if is_set( var ) then
			return var;
		end
	end
end

--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end

--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]
local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end

--[[--------------------------&lt; S E T _ E R R O R &gt;--------------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

]]
local function set_error( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if in_array( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return error_comment( message, error_state.hidden );
end

--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maintenance_cats using names from the configuration file with additional text if any.
To prevent duplication, the added_maint_cats table lists the categories by key that have been added to z.maintenance_cats.

]]

local added_maint_cats = {}														-- list of maintenance categories that have been added to z.maintenance_cats
local function add_maint_cat (key, arguments)
	if not added_maint_cats [key] then
		added_maint_cats [key] = true;											-- note that we've added this category
		table.insert( z.maintenance_cats, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
	end
end

--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

]]

local added_prop_cats = {}														-- list of property categories that have been added to z.properties_cats
local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));		-- make name then add to table
	end
end

--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

]]

local added_vanc_errs;															-- flag so we only emit one Vancouver error / category
local function add_vanc_error ()
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {}, true ) } );
	end
end

--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string is valid.

At present the only check is whether the string appears to be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well formed.

]]

local function check_url( url_str )
	return url_str:sub(1,2) == &quot;//&quot; or url_str:match( &quot;^[^/]*:&quot; ) ~= nil;		-- Protocol-relative or URL scheme
end

--[[--------------------------&lt; S A F E _ F O R _ I T A L I C S &gt;----------------------------------------------

Protects a string that will be wrapped in wiki italic markup '' ... ''

Note: We cannot use &lt;i&gt; for italics, as the expected behavior for italics specified by ''...'' in the title is that
they will be inverted (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and '' tend to interact
poorly under Mediawiki's HTML tidy.

]]

local function safe_for_italics( str )
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end

--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

local function wrap_style (key, str)
	if not is_set( str ) then
		return &quot;&quot;;
	elseif in_array( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safe_for_italics( str );
	end

	return substitute( cfg.presentation[key], {str} );
end

--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source )
	local error_str = &quot;&quot;;
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
	end
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url( label ), &quot;]&quot;, error_str });
end

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

]]

local page_in_deprecated_cat;													-- sticky flag so that the category is added only once
local function deprecated_parameter(name)
	if not page_in_deprecated_cat then
		page_in_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end

--[[--------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Call this function for chapter titles, for website titles, etc; not for book titles.

]]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	
	cap, cap2 = str:match (&quot;^([\&quot;\'])([^\'].+)&quot;);								-- match leading double or single quote but not double single quotes
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-left'], {cap, cap2});
	end

	cap, cap2 = str:match (&quot;^(.+[^\'])([\&quot;\'])$&quot;)
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-right'], {cap, cap2});
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

At this writing, only |script-title= is supported.  It is anticipated that additional parameters will be created to use this function.

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, {'ar', 'bg', 'bs', 'dv', 'el', 'fa', 'hy', 'ja', 'ka', 'ko', 'ku', 'he', 'ps', 'ru', 'sd', 'sr', 'th', 'uk', 'ug', 'yi', 'zh'}) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				add_prop_cat ('script')
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		str = substitute( msg, {str} );											-- including template text
		return str;
	else
		return substitute( cfg.messages[key], {str} );
	end		
end

--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider
Generates an error if more than one match is present.

]]

local function select_one( args, possible, error_condition, index )
	local value = nil;
	local selected = '';
	local error_list = {};
	
	if index ~= nil then index = tostring(index); end
	
	-- Handle special case of &quot;#&quot; replaced by empty string
	if index == '1' then
		for _, v in ipairs( possible ) do
			v = v:gsub( &quot;#&quot;, &quot;&quot; );
			if is_set(args[v]) then
				if value ~= nil and selected ~= v then
					table.insert( error_list, v );
				else
					value = args[v];
					selected = v;
				end
			end
		end		
	end
	
	for _, v in ipairs( possible ) do
		if index ~= nil then
			v = v:gsub( &quot;#&quot;, index );
		end
		if is_set(args[v]) then
			if value ~= nil and selected ~=  v then
				table.insert( error_list, v );
			else
				value = args[v];
				selected = v;
			end
		end
	end
	
	if #error_list &gt; 0 then
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap_style ('parameter', k);
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap_style ('parameter', selected);
		table.insert( z.message_tail, { set_error( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end

--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the three chapter parameters: |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (chapter, transchapter, chapterurl, chapter_url_source)
	local chapter_error = '';
	
	if not is_set (chapter) then
		chapter = '';															-- just to be safe for concatenation
		if is_set (transchapter) then
			chapter = wrap_style ('trans-quoted-title', transchapter);
			chapter_error = &quot; &quot; .. set_error ('trans_missing_chapter');
		end
		if is_set (chapterurl) then
			chapter = external_link (chapterurl, chapter, chapter_url_source);	-- adds bare_url_missing_title error if appropriate
		end
		return chapter .. chapter_error;
	else																		-- here when chapter is set
		chapter = kern_quotes (chapter);										-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
		chapter = wrap_style ('quoted-title', chapter);
		if is_set (transchapter) then
			transchapter = wrap_style ('trans-quoted-title', transchapter);
			chapter = chapter .. ' ' .. transchapter;
		end
		if is_set (chapterurl) then
			chapter = external_link (chapterurl, chapter);						-- adds bare_url_missing_title error if appropriate
		end
	end
	return chapter;
end

--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
]]

local function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end


-- Formats a wiki style internal link
local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s*%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s*%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end

--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in check_isbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end

--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end

--[[--------------------------&lt; C H E C K _ I S M N &gt;------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the issn is invalid
	end 
	
	return text;
end

--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link = handler.link,
		label=handler.label , prefix=&quot;//www.amazon.&quot;..domain..&quot;/dp/&quot;,id=id,
		encode=handler.encode, separator = handler.separator}) .. err_cat;
end

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end

--[[
lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--[[
Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of the LCCN dictates the character type of the first 1-3 characters; the
rightmost eight are always digits. http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end

--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.

-- DOI names contain two parts: prefix and suffix separated by a forward slash.
--  Prefix: directory indicator '10.' followed by a registrant code
--  Suffix: character string of any length chosen by the registrant

-- This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes,
-- or, if it ends with a period or a comma, this function will emit a bad_doi error message.

-- DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
-- and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely if ever used in doi names.

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);					-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/authors/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=&quot;http://openlibrary.org/books/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/works/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix= &quot;http://openlibrary.org/OL&quot;,id=id, separator=handler.separator,
			encode = handler.encode}) .. 
			' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end

--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end

--[[--------------------------&lt; C L E A N _ I S B N &gt;----------------------------------------------------------

Removes irrelevant text and dashes from ISBN number
Similar to that used for Special:BookSources

]]

local function clean_isbn( isbn_str )
	return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]
local function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other lua magic pattern characters
	return argument;
end

--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	while true do
		if argument:match (&quot;%'%'%'%'%'&quot;) then									-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:match (&quot;%'%'%'%'&quot;) then									-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:match (&quot;%'%'%'&quot;) then									-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:match (&quot;%'%'&quot;) then										-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end

--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...
]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end

--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
local function remove_wiki_link( str )
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end

-- Converts a hyphen to a dash
local function hyphen_to_dash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end

--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if comp:sub(1,1) == duplicate_char then								-- is first charactier same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for th
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = str:sub(-1,-1);										-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = str:sub(1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = str:sub(1, -4) .. &quot;''&quot;;							-- remove them and add back ''
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then		-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then		-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then			-- if last two chars of str are sepc] external link
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;'']&quot; then		-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then				-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = str:sub(1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end		-- if duplicate_char not a letter then escape it
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )			-- remove duplicate_char if it follows html markup
					else
						value = value:sub( 2, -1 );								-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end  

--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

At the time of this writing, I had to write the 'if nil == mw.ustring.find ...' test ouside of the code editor and paste it here
because the code editor gets confused between character insertion point and cursor position.

]]

local function is_good_vanc_name (last, first)
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]*$&quot;) then
		add_vanc_error ();
		return false;															-- not a string of latin characters; Vancouver required Romanization
	end;
	return true;
end

--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  This form is not
currently supported by this code so correctly formed names like Smith JL 2nd are converted to Smith J2. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	if mw.ustring.match(first, &quot;^%u%u$&quot;) then return first end;					-- when first contains just two upper-case letters, nothing to do
	local initials = {}
	local i = 0;																-- counter for number of initials
	for word in mw.ustring.gmatch(first, &quot;[^%s%.%-]+&quot;) do						-- names separated by spaces, hyphens, or periods
		table.insert(initials, mw.ustring.sub(word,1,1))						-- Vancouver format does not include full stops.
		i = i + 1;																-- bump the counter 
		if 2 &lt;= i then break; end												-- only two initials allowed in Vancouver system; if 2, quit
	end
	return table.concat(initials)												-- Vancouver format does not include spaces.
end

--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = ',';																-- name-list separator between authors is a comma
		namesep = ' ';															-- last/first separator is a space
	else
		sep = ';'																-- name-list separator between authors is a semicolon
		namesep = ', '															-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then					-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first 
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;				-- link author/editor if this page is not the author's/editor's page
				end

				if is_set(person.link) and ((nil ~= person.link:find(&quot;//&quot;)) or (nil ~= person.link:find(&quot;[%[%]]&quot;))) then
					one = one .. &quot; &quot; .. set_error( 'bad_authorlink' ) end		-- url or wikilink in author link;
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. ' ' .. cfg.messages['et al'];						-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end

--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

]]

local function anchor_id( options )
	local id = table.concat( options );											-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end

--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of author and editor name parameters for variations on the theme eof et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the parameters |display-authors=etal or |displayeditors=etal

]]

local function name_has_etal (name, etal, nocat)

	if is_set (name) then														-- name can be nil in which case just return
		local pattern = &quot;[;,]? *[\&quot;']*%f[Ee][Ee][Tt] *[Aa][Ll][%.\&quot;']*$&quot;		-- variations on the 'et al' theme
		
		if name:match (pattern) then											-- variants on et al.
			name = name:gsub (pattern, '');										-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		end
	end
	return name, etal;															-- 
end

--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary

	while true do
		last = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false);								-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false);								-- find and remove variations on et al.

		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end

-- Populates ID table from arguments using configuration settings
local function extract_ids( args )
	local id_list = {};
	for k, v in pairs( cfg.id_handlers ) do	
		v = select_one( args, v.parameters, 'redundant_parameters' );
		if is_set(v) then id_list[k] = v; end
	end
	return id_list;
end

--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs and turns it into a table of formatted ID outputs.

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end
  

-- COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse
-- the citation information.
local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end
	
	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if is_set(data.Chapter) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
	elseif is_set(data.Periodical) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
		if 'arxiv' == class then
			OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;								-- cite arxiv
		else
			OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
		end
		OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	else
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
	end
	
	OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
	OCinSoutput[&quot;rft.date&quot;] = data.Date;
	OCinSoutput[&quot;rft.series&quot;] = data.Series;
	OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
	OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
	OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
	OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
	OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
	
	for k, v in pairs( data.ID_list ) do
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
	
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = v.last, v.first;
		if k == 1 then
			if is_set(last) then
				OCinSoutput[&quot;rft.aulast&quot;] = last;
			end
			if is_set(first) then 
				OCinSoutput[&quot;rft.aufirst&quot;] = first;
			end
		end
		if is_set(last) and is_set(first) then
			OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
		elseif is_set(last) then
			OCinSoutput[&quot;rft.au&quot;] = last;
		end
	end
	
	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 code.  Handles the special case that is Norwegian where
ISO639-1 code 'no' is mapped to language name 'Norwegian Bokmål' by Extention:CLDR.

Returns the language name and associated ISO639-1 code.  Because case of the source may be incorrect or different from the case that Wikimedia
uses, the name comparisons are done in lower case and when a match is found, the Wikimedia version (assumed to be correct) is returned along
with the code.  When there is no match, we return the original language name string.

mw.language.fetchLanguageNames() will return a list of languages that aren't part of ISO639-1. Names that aren't ISO639-1 but that are included
in the list will be found if that name is provided in the |language= parameter.  For example, if |language=Samaritan Aramaic, that name will be
found with the associated code 'sam', not an ISO639-1 code.  When names are found and the associated code is not two characters, this function
returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang)
	if 'norwegian' == lang:lower() then											-- special case related to Wikimedia remap of code 'no' at Extension:CLDR
		return 'Norwegian', 'no';												-- Make sure rendered version is properly capitalized
	end
	
	local languages = mw.language.fetchLanguageNames('en', 'all')				-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() then												-- ISO639-1 codes only
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the ISO639-1 code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for ISO639-1 code
end

--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Get language name from ISO639-1 code value provided.  If a code is valid use the returned name; if not, then use the value that was provided with the language parameter.

There is an exception.  There are three ISO639-1 codes for Norewegian language variants.  There are two official variants: Norwegian Bokmål (code 'nb') and
Norwegian Nynorsk (code 'nn').  The third, code 'no',  is defined by ISO639-1 as 'Norwegian' though in Norway this is pretty much meaningless.  However, it appears
that on enwiki, editors are for the most part unaware of the nb and nn variants (compare page counts for these variants at Category:Articles with non-English-language external links.

Because Norwegian Bokmål is the most common language variant, Media wiki has been modified to return Norwegian Bokmål for ISO639-1 code 'no'. Here we undo that and
return 'Norwegian' when editors use |language=no.  We presume that editors don't know about the variants or can't descriminate between them.

See Help talk:Citation Style_1#An ISO 639-1 language name test

When |language= contains a valid ISO639-1 code, the page is assigned to the category for that code: Category:Norwegian-language sources (no) if
the page is a mainspace page and the ISO639-1 code is not 'en'.  Similarly, if the  parameter is |language=Norwegian, it will be categorized in the same way.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the ISO639-1 two character code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang

		if 2 == lang:len() then													-- ISO639-1 language code are 2 characters (fetchLanguageName also supports 3 character codes)
			name = mw.language.fetchLanguageName( lang:lower(), &quot;en&quot; );			-- get ISO 639-1 language name if Language is a proper code
		end
	
		if is_set (name) then													-- if Language specified a valid ISO639-1 code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang);								-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then
			if 'no' == code then name = 'Norwegian' end;						-- override wikimedia when code is 'no'
			if 'en' ~= code then												-- English not the language
				add_prop_cat ('foreign_lang_source', {name, code})
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, ' and ')							-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		language_list[code] = 'and ' .. language_list[code];					-- prepend last name with 'and&lt;space&gt;'
		name = table.concat (language_list, ', ')								-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
	end
	if 'English' == name then
		return '';																-- if one language and that language is English return an enpty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
end

--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = '.';																-- terminate the rendered citation with a period
	end
	return '.', ps;																-- separator is a full stop
end

--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = '';																-- make sure it isn't nil
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return ',', ps, ref;														-- separator is a comma
end

--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		if is_set (mode) then
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'mode', mode}, true ) } );		-- add error message
		end
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end

--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extension, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf[%?#]?') or url:match ('%.PDF[%?#]?');
end

--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parenthases, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end

--[[--------------------------&lt; G E T _ D I S P L A Y _ A U T H O R S _ E D I T O R S &gt;------------------------

Returns a number that may or may not limit the length of the author or editor name lists.

When the value assigned to |display-authors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-authors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

]]

local function get_display_authors_editors (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count and 'authors' == list_name then	-- AUTHORS ONLY		-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_auth_ed', list_name);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset
		end
	elseif 'authors' == list_name then		-- AUTHORS ONLY	need to clear implicit et al category
		max = count + 1;														-- number of authors + 1
	end
	
	return max, etal;
end

--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page, nopp)
--	local good_pattern = '^P[^%.P%l]';
	local good_pattern = '^P[^%.Pp]';										-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
--	local bad_pattern = '^[Pp][Pp]';
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if is_set (nopp) then													-- don't bother checking if |nopp= is set
		return;
	end

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
--		if Page:match ('^[Pp]?[Pp]%.?[ %d]') or  Page:match ('^[Pp]ages?[ %d]') or
--			Pages:match ('^[Pp]?[Pp]%.?[ %d]') or  Pages:match ('^[Pp]ages?[ %d]') then
--				add_maint_cat ('extra_text');
--		end
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	if vparam:find ('%[%[') or vparam:find ('%]%]')	then						-- no wikilinking vauthors names
		add_vanc_error ();
	end
	v_name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;)								-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parenthese to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')
			corporate = true;
		elseif string.find(v_name, &quot;%s&quot;) then
		    lastfirstTable = {}
		    lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
		    first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
		    last  = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) and not mw.ustring.match (first, &quot;^%u?%u$&quot;) then		-- first shall contain one or two upper-case letters, nothing else
			add_vanc_error ();
		end
																				-- this from extract_names ()
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', 1 ) or		-- do this twice incase we have a first 1 without a last1
		select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 0;																	-- no authors so return 0 
end

--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );

	local i 
	local PPrefix = A['PPrefix']
	local PPPrefix = A['PPPrefix']
	local NoPP = A['NoPP'] 
	if in_array(NoPP:lower(), {'yes', 'true', 'y'}) then
		PPPrefix = '';															-- unset these, prefix if used is in |page= or |pages=
		PPrefix = '';
	else
		NoPP = nil;																-- unset, used as a flag later
	end

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];									-- replaces |author-format= and |editor-format=

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
		end
	end

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
		end
	end

	if is_set (NameListFormat) and ('vanc' ~= NameListFormat) then											-- only accepted value for this parameter is 'vanc'
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {'name-list-format', NameListFormat}, true ) } );	-- not vanc so add error message
		NameListFormat = '';													-- set to empty string
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
	local Chapter = A['Chapter'];
	local ChapterLink = A['ChapterLink'];										-- deprecated but used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];
	local ArchiveURL = A['ArchiveURL'];
	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];

	local Series = A['Series'];
	local Volume = A['Volume'];
	local Issue = A['Issue'];
	local Position = '';
	local Page = A['Page'];
	local Pages = hyphen_to_dash( A['Pages'] );	
	local At = A['At'];

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
	local SubscriptionRequired = A['SubscriptionRequired'];
	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local ArchiveDate = A['ArchiveDate'];
	local Agency = A['Agency'];
	local DeadURL = A['DeadURL']
	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
	local no_tracking_cats = A['NoTracking'];

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local use_lowercase;								-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();		-- also used for COinS and for language
	local anchor_year;									-- used in the CITEREF identifier
	local COinS_date;									-- used in the COinS metadata

-- set default parameter values defined by |mode= parameter.  If |mode= is empty or omitted, use CitationClass to set these values
	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (A['Mode']:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

-- check for extra |page=, |pages= or |at= parameters. 
	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Page = Page .. &quot; &quot; .. set_error('extra_pages');						-- add error message
			Pages = '';															-- unset the others
			At = '';
		end
		extra_text_in_page_check (Page, NoPP);									-- add this page to maint cat if |page= value begins with what looks like p. or pp.
	elseif is_set(Pages) then
		if is_set(At) then
			Pages = Pages .. &quot; &quot; .. set_error('extra_pages');					-- add error messages
			At = '';															-- unset
		end
		extra_text_in_page_check (Pages, NoPP);									-- add this page to maint cat if |page= value begins with what looks like p. or pp.
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped
	|url maps to |chapterurl when |title is remapped

All other combinations of |encyclopedia, |title, and |article are not modified
TODO: script-title to script-chapter if and when we support script-chapter
]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then					-- Periodical is set when |encyclopedia is set
			if is_set(Title) then
				if not is_set(Chapter) then
					Chapter = Title;				-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					TransChapter = TransTitle;
					ChapterURL = URL;
					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter= '[[' .. TitleLink .. '|' .. Chapter .. ']]';
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';				-- redundant so unset
					TransTitle = '';				-- redundant so unset
					URL = '';						-- redundant so unset
					Format = '';					-- redundant so unset
					TitleLink = '';					-- redundant so unset
				end
			else									-- |title not set
				Title = Periodical;					-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';					-- redundant so unset
			end
		end
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then	-- special case for cite techreport
		if is_set(Issue) then						-- cite techreport uses 'number', which other citations aliase to 'issue'
			if not is_set(ID) then					-- can we use ID for the &quot;number&quot;?
				ID = Issue;							-- yes, use it
				Issue = &quot;&quot;;							-- unset Issue so that &quot;number&quot; isn't duplicated in the rendered citation or COinS metadata
			else									-- can't use ID so emit error message
				ID = ID .. &quot; &quot; .. set_error('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Others) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Others;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Others;
			end
		else
			Others = '(Interview)';
		end
	end

-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local Began = A['Began'];												-- these two are deprecated because the module understands date ranges
		local Ended = A['Ended'];
		local SeriesLink = A['SeriesLink'];
		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};

																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) then												-- promote airdate or Began/Ended to date
			if is_set (AirDate) then
				Date = AirDate;
			elseif is_set (Began) then											-- deprecated
				if Began:match('%s') or Ended:match('%s') then					-- so we don't create errors: if either has spaces then
					Date = Began .. ' – ' .. Ended;								-- use spaced ndash as separator
				else
					Date = Began .. '–' .. Ended;								-- elsewise no spaces
				end
			end
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('series', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = '[[' .. ChapterLink .. '|' .. Chapter .. ']]';		-- ok to wikilink
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = '[[' .. ChapterLink .. '|' .. Series .. ']]';			-- series links with ChapterLink (episodelink -&gt; TitleLink -&gt; ChapterLink) ugly
			end
			URL = '';															-- unset
			TransTitle = '';													-- unset
			
		else																	-- now oddities that are cite serial
			Issue = '';														-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = '[[' .. SeriesLink .. '|' .. Series .. ']]';
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
-- end of {{cite episode}} stuff

-- Account for the oddities that are {{cite arxiv}}, before generation of COinS data.
	if 'arxiv' == config.CitationClass then
		if not is_set (ID_list['ARXIV']) then									-- |arxiv= or |eprint= required for cite arxiv
			table.insert( z.message_tail, { set_error( 'arxiv_missing', {}, true ) } );		-- add error message
		elseif is_set (Series) then												-- series is an alias of version
			ID_list['ARXIV'] = ID_list['ARXIV'] .. Series;						-- concatenate version onto the end of the arxiv identifier
			Series = '';														-- unset
			deprecated_parameter ('version');									-- deprecated parameter but only for cite arxiv
		end
		
		if first_set (AccessDate, At, Chapter, Format, Page, Pages, Periodical, PublisherName, URL,	-- a crude list of parameters that are not supported by cite arxiv
			ID_list['ASIN'], ID_list['BIBCODE'], ID_list['DOI'], ID_list['ISBN'], ID_list['ISSN'],
			ID_list['JFM'], ID_list['JSTOR'], ID_list['LCCN'], ID_list['MR'], ID_list['OCLC'], ID_list['OL'],
			ID_list['OSTI'], ID_list['PMC'], ID_list['PMID'], ID_list['RFC'], ID_list['SSRN'], ID_list['USENETID'], ID_list['ZBL']) then
				table.insert( z.message_tail, { set_error( 'arxiv_params_not_supported', {}, true ) } );		-- add error message

				AccessDate= '';													-- set these to empty string; not supported in cite arXiv
				PublisherName = '';												-- (if the article has been published, use cite journal, or other)
				Chapter = '';
				URL = '';
				Format = '';
				Page = ''; Pages = ''; At = '';
		end
		Periodical = 'arXiv';													-- set to arXiv for COinS; after that, must be set to empty string
	end

-- handle type parameter for those CS1 citations that have default values

	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
		TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot;;									-- display it in parentheses
	end

-- legacy: promote concatenation of |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set (Date) then
		Date = Year;						-- promote Year to Date
		Year = nil;							-- make nil so Year as empty string isn't used for CITEREF
		if is_set(Date) then
			local Month = A['Month'];
			if is_set(Month) then
				Date = Month .. &quot; &quot; .. Date;
			end
		elseif is_set(PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;			-- promote PublicationDate to Date
			PublicationDate = '';			-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end	-- if PublicationDate is same as Date, don't display in rendered citation

--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	do	-- create defined block to contain local variables error_message and mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		anchor_year, COinS_date, error_message = dates({['accessdate']=AccessDate, ['archivedate']=ArchiveDate, ['date']=Date, ['doi_brokendate']=DoiBroken,
			['embargo']=Embargo, ['laydate']=LayDate, ['publicationdate']=PublicationDate, ['year']=Year});

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end

		if is_set(error_message) then
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end
	end	-- end of do

-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);											-- 

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
		table.insert( z.message_tail, { set_error( 'citation_missing_title', {}, true ) } );
	end
	
	if 'none' == Title and is_set(Periodical) and not (( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia))) then								-- special case
		Title = '';																-- set title to empty string
		add_maint_cat ('untitled');
	end

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	
	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = Periodical,
		['Chapter'] = strip_apostrophe_markup (coins_chapter),					-- Chapter stripped of bold / italic wikimarkup
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = first_set(COinS_date, Date),		-- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here?  Should we be including invalid dates in metadata?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set(Sheet, Sheets, Page, Pages, At)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set( URL, ChapterURL ),
		['Authors'] = a,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

-- Account for the oddities that are {{cite arxiv}}, AFTER generation of COinS data.
	if 'arxiv' == config.CitationClass then										-- we have set rft.jtitle in COinS to arXiv, now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in cite arxiv; if article has been published, use cite journal
	end

-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = '[[Usenet newsgroup|Newsgroup]]:&amp;nbsp;' ..  external_link( 'news:' .. PublisherName, PublisherName );
		end
	end



	-- Now perform various field 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.
	do																			-- do-block to limit scope of last_first_list
		local last_first_list;
		local maximum = A['DisplayAuthors'];

		maximum , author_etal = get_display_authors_editors (maximum, #a, 'authors', author_etal);

		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text											-- get current page name so that we don't wikilink to it via authorlinkn
			};
		
		if is_set(Coauthors) then												-- if the coauthor field is also used, prevent ampersand and et al. formatting.
			control.lastauthoramp = nil;
			control.maximum = #a + 1;
		end
		
		last_first_list = list_people(control, a, author_etal);

		if is_set (Authors) then
			Authors, author_etal = name_has_etal (Authors, author_etal, false);	-- find and remove variations on et al.
			if author_etal then
				Authors = Authors .. ' ' .. cfg.messages['et al'];				-- add et al. to authors parameter
			end
		else
			Authors = last_first_list;											-- either an author name list or an empty string
		end

	end																			-- end of do

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { set_error('coauthors_missing_author', {}, true) } );	-- emit error message
	end

	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local maximum = A['DisplayEditors'];

		maximum , editor_etal = get_display_authors_editors (maximum, #e, 'editors', editor_etal);
		-- Preserve old-style implicit et al.
		if not is_set(maximum) and #e == 4 then 
			maximum = 3;
			table.insert( z.message_tail, { set_error('implict_etal_editor', {}, true) } );
		end

		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text											-- get current page name so that we don't wikilink to it via editorlinkn
		};

		last_first_list, EditorCount = list_people(control, e, editor_etal);

		if is_set (Editors) then
			if editor_etal then
				Editors = Editors .. ' ' .. cfg.messages['et al'];				-- add et al. to editors parameter beause |display-editors=etal
				EditorCount = 2;												-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
			else
				EditorCount = 2;												-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
			end
		else
			Editors = last_first_list;											-- either an author name list or an empty string
		end

		if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then			-- only one editor displayed but includes etal then 
			EditorCount = 2;													-- spoof to display (eds.) annotation
		end
	end


-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

	if  not is_set(URL) then --and
--		not is_set(ArchiveURL) then --and										-- prevents format_missing_url error from registering
--		not is_set(ConferenceURL) and											-- TODO: keep this here? conference as part of cite web or cite podcast?
--		not is_set(TranscriptURL) then											-- TODO: remove? |transcript-url= and |transcript= has separate test
		
		-- Test if cite web or cite podcast |url= is missing or empty 
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then	
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- Test if accessdate is given without giving a URL
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when the others are not set; TODO: move this to a separate test?
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalFormat;											-- TODO: swap chapter and title here so that archive applies to most specific if both are set?
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalFormat = Format;											-- and original |format=
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
			end
		elseif is_set (ChapterURL) then 										-- URL not set so if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalFormat = ChapterFormat;										-- and original |format=
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
			end
		end
	end

	if in_array(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;journal&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;, &quot;newsgroup&quot;, 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			if is_set (Chapter) or is_set (TransChapter) or is_set (ChapterURL)then	-- chapter parameters not supported for these citation types
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {}, true ) } );		-- add error message
				Chapter = '';														-- set to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
			end
	else																		-- otherwise, format chapter / article title
		Chapter = format_chapter_title (Chapter, TransChapter, ChapterURL, ChapterURLorigin);
		if is_set (Chapter) then
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;
			end
			Chapter = Chapter .. ChapterFormat .. sepc .. ' ';
		end
	end

	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if in_array(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;journal&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;, &quot;newsgroup&quot;, &quot;mailinglist&quot;, 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
	
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title' );
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then 
			Title = external_link( URL, Title ) .. TransError .. Format;
			URL = &quot;&quot;;
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		if is_set(Minutes) then
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			local Time = A['Time'];
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end
	
	if not is_set(Page) then
		if is_set(Pages) then
			if is_set(Periodical) and
				not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
				Pages = &quot;: &quot; .. Pages;
			elseif tonumber(Pages) ~= nil then
				Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
			else
				Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
			end
		end
	else
		if is_set(Periodical) and
			not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
			Page = &quot;: &quot; .. Page;
		else
			Page = sepc ..&quot; &quot; .. PPrefix .. Page;
		end
	end

	if 'map' == config.CitationClass then										-- cite map oddity done after COinS call (and with other in-source locators)
		if is_set (Sheet) or is_set (Sheets) then
			local err_msg1 = 'sheet=, &amp;#124;sheets';							-- default error message in case any of page pages or at are set
			local err_msg2;
			if is_set (Page) or is_set (Pages) or is_set (At) then				-- are any set?
				err_msg2 = 'page=, &amp;#124;pages=, &amp;#124;at';						-- a generic error message
				Page = ''; Pages = ''; At = '';
			elseif is_set (Sheet) and is_set (Sheets) then						-- if both are set make error message
				err_msg1 = 'sheet';
				err_msg2 = 'sheets';
			end
			if is_set (err_msg2) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', err_msg1) .. ' and ' .. wrap_style ('parameter', err_msg2)}, true ) } );		-- add error message
			end
			if not is_set (Sheet) then											-- do sheet static text and formatting; Sheet has priority over Sheets if both provided
				if is_set (Sheets) then
					if is_set (Periodical) then
						Sheet = &quot;: Sheets &quot; .. Sheets;							-- because Sheet has priority, no need to support both later on
					else
						Sheet = sepc .. &quot; Sheets &quot; .. Sheets;
					end
				end
			else
				if is_set (Periodical) then
					Sheet = &quot;: Sheet &quot; .. Sheet;
				else
					Sheet = sepc .. &quot; Sheet &quot; .. Sheet;
				end
			end
		end
	end

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('[Ee]d%.?$') or Edition:match ('[Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end
	Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc ..&quot; &quot; .. Volume;
		  else Volume = &quot; &lt;b&gt;&quot; .. hyphen_to_dash(Volume) .. &quot;&lt;/b&gt;&quot;;
		end
	end

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

--[[
Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
note is displayed. There are no error messages for this condition.

]]
	if in_array(SubscriptionRequired:lower(), {'yes', 'true', 'y'}) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif in_array(RegistrationRequired:lower(), {'yes', 'true', 'y'}) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if 'citation', lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text
																				-- neither of these work; don't know why; it seems that substitute() isn't being called	
		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
			Quote = Quote:sub(2,-2);
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- CS1 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text,
				{ external_link( OriginalURL, cfg.messages['original'] ) .. OriginalFormat, ArchiveDate } );	-- format already styled
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'] ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower() ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin );
	end

	local Publisher;
	if is_set(Periodical) and
		not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap_msg ('published', PublicationDate);
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap_msg ('published', PublicationDate) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
			Language, Edition, Publisher, Agency, Volume, Issue}, sepc );
		
	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume, Issue}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Transcript, Language, Edition, Publisher}, sepc );
	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Issue, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Sheet .. Page .. Pages .. At;
	
	if is_set(Authors) then
		if is_set(Coauthors) then
			local sep = '; ';
			if 'vanc' == NameListFormat then
				sep = ', ';
			end
			Authors = Authors .. sep .. Coauthors;
		end
		if is_set(Date) then
			Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		elseif string.sub(Authors,-1,-1) == sepc then
			Authors = Authors .. &quot; &quot;
		else
			Authors = Authors .. sepc .. &quot; &quot;
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			if (sepc ~= '.') then in_text = in_text:lower() end
			Editors = in_text .. Editors .. post_text;
			if (string.sub(Editors,-1,-1) == sepc) or (string.sub(Editors,-3,-1) == sepc .. ']]') then	-- if last editor name ends with sepc char
				Editors = Editors .. &quot; &quot;;										-- don't add another
			else
				Editors = Editors .. sepc .. &quot; &quot;								-- otherwise terninate the editor list
			end
		end
		text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
		text = safe_join( {text, pgtext, idcommon}, sepc );
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon}, sepc );
		text = safe_join( {text, pgtext, idcommon}, sepc );
	else
		if is_set(Date) then
			if ( string.sub(tcommon,-1,-1) ~= sepc )
			  then Date = sepc ..&quot; &quot; .. Date .. OrigYear
			  else Date = &quot; &quot; .. Date .. OrigYear
			end
		end
		if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon}, sepc );
			text = safe_join( {text, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date}, sepc );
			text = safe_join( {text, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;span/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = &quot;citation &quot; .. config.CitationClass;
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
		local id = Ref
		if ( &quot;harv&quot; == Ref ) then
			local names = {} --table of last names &amp; year
			if #a &gt; 0 then
				for i,v in ipairs(a) do 
					names[i] = v.last 
					if i == 4 then break end
				end
			elseif #e &gt; 0 then
				for i,v in ipairs(e) do 
					names[i] = v.last 
					if i == 4 then break end				
				end
			end
			names[ #names + 1 ] = first_set(Year, anchor_year);	-- Year first for legacy citations and for YMD dates that require disambiguation
			id = anchor_id(names)
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then 
		text = '&lt;span id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	else
		text = '&lt;span class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/span&gt;&quot;;
	end		

	local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
	
	-- Note: Using display: none on then COinS span breaks some clients.
	local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
	text = text .. OCinS;
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. error_comment( v[1], v[2] );
				else
					text = text .. error_comment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end

	if #z.maintenance_cats ~= 0 then
		text = text .. '&lt;span class=&quot;citation-comment&quot; style=&quot;display:none; color:#33aa33&quot;&gt;';
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. ' ' .. v .. ' ([[:Category:' .. v ..'|link]])';
		end
		text = text .. '&lt;/span&gt;';	-- maintenance mesages (realy just the names of the categories for now)
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
	local pframe = frame:getParent()
	local validation;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of Configuration and Whitelist and ...
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');	-- ... sandbox version of date validation code

	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of Configuration and Whitelist and ...
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		validation = require ('Module:Citation/CS1/Date_validation');			-- ... live version of date validation code
	end

	dates = validation.dates;													-- imported functions
	year_date_check = validation.year_date_check;

	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if #suggestions == 0 then
						suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
					end
					if suggestions[ k:lower() ] ~= nil then
						error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
					else
						error_text, error_state = set_error( 'parameter_ignored', {k}, true );
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	
	
	return citation0( config, args)
end

return z</text>
      <sha1>6i2ehmhjtybprdyct0atqe1o869u02e</sha1>
    </revision>
    <revision>
      <id>4695</id>
      <parentid>4694</parentid>
      <timestamp>2015-09-26T16:13:45Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4695</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="156683" sha1="cwm35adoov8xmr4vpsgc0e8dfqsvpps" xml:space="preserve">
local z = {
	error_categories = {};		-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};		-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};		-- for categorizing citations based on certain properties, language of source for instance
}

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]
local dates, year_date_check	-- functions in Module:Citation/CS1/Date_validation

local cfg = {};					-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};			-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist

--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.
This function is global because it is called from both this module and from Date validation

]]
function is_set( var )
	return not (var == nil or var == '');
end

--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

First set variable or nil if none

]]

local function first_set(...)
	local list = {...};
	for _, var in pairs(list) do
		if is_set( var ) then
			return var;
		end
	end
end

--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end

--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]
local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end

--[[--------------------------&lt; S E T _ E R R O R &gt;--------------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

]]
local function set_error( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if in_array( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return error_comment( message, error_state.hidden );
end

--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maintenance_cats using names from the configuration file with additional text if any.
To prevent duplication, the added_maint_cats table lists the categories by key that have been added to z.maintenance_cats.

]]

local added_maint_cats = {}														-- list of maintenance categories that have been added to z.maintenance_cats
local function add_maint_cat (key, arguments)
	if not added_maint_cats [key] then
		added_maint_cats [key] = true;											-- note that we've added this category
		table.insert( z.maintenance_cats, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
	end
end

--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

]]

local added_prop_cats = {}														-- list of property categories that have been added to z.properties_cats
local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));		-- make name then add to table
	end
end

--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

]]

local added_vanc_errs;															-- flag so we only emit one Vancouver error / category
local function add_vanc_error ()
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {}, true ) } );
	end
end

--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string is valid.

At present the only check is whether the string appears to be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well formed.

The scheme is checked http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

First we test for space characters.  If any are found, return false.  Then test for the case where the url is
protocol relative (//example.com).  If the first two characters of the |url= value are //, return true.  Last
look for what appears to be a scheme according to the definition above.  If the characters preceding the colon
are in the allowed set, return true, else false
]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value
		return false;
	end
	return url_str:sub(1,2) == &quot;//&quot; or nil ~= url_str:match (&quot;^%a[%a%d%+%.%-]*:&quot;)		-- protocol relative or scheme part composed of legitimate characters
end

--[[--------------------------&lt; S A F E _ F O R _ I T A L I C S &gt;----------------------------------------------

Protects a string that will be wrapped in wiki italic markup '' ... ''

Note: We cannot use &lt;i&gt; for italics, as the expected behavior for italics specified by ''...'' in the title is that
they will be inverted (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and '' tend to interact
poorly under Mediawiki's HTML tidy.

]]

local function safe_for_italics( str )
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end

--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

local function wrap_style (key, str)
	if not is_set( str ) then
		return &quot;&quot;;
	elseif in_array( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safe_for_italics( str );
	end

	return substitute( cfg.presentation[key], {str} );
end

--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source )
	local error_str = &quot;&quot;;
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
	end
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url( label ), &quot;]&quot;, error_str });
end

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

]]

local page_in_deprecated_cat;													-- sticky flag so that the category is added only once
local function deprecated_parameter(name)
	if not page_in_deprecated_cat then
		page_in_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end

--[[--------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Call this function for chapter titles, for website titles, etc; not for book titles.

]]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	
	cap, cap2 = str:match (&quot;^([\&quot;\'])([^\'].+)&quot;);								-- match leading double or single quote but not double single quotes
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-left'], {cap, cap2});
	end

	cap, cap2 = str:match (&quot;^(.+[^\'])([\&quot;\'])$&quot;)
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-right'], {cap, cap2});
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title= and |script-chapter=

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, {'ar', 'bg', 'bs', 'dv', 'el', 'fa', 'he', 'hy', 'ja', 'ka', 'ko', 'ku', 'mk', 'ps', 'ru', 'sd', 'sr', 'th', 'uk', 'ug', 'yi', 'zh'}) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				add_prop_cat ('script')
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		str = substitute( msg, {str} );											-- including template text
		return str;
	else
		return substitute( cfg.messages[key], {str} );
	end		
end

--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider
Generates an error if more than one match is present.

]]

local function select_one( args, possible, error_condition, index )
	local value = nil;
	local selected = '';
	local error_list = {};
	
	if index ~= nil then index = tostring(index); end
	
	-- Handle special case of &quot;#&quot; replaced by empty string
	if index == '1' then
		for _, v in ipairs( possible ) do
			v = v:gsub( &quot;#&quot;, &quot;&quot; );
			if is_set(args[v]) then
				if value ~= nil and selected ~= v then
					table.insert( error_list, v );
				else
					value = args[v];
					selected = v;
				end
			end
		end		
	end
	
	for _, v in ipairs( possible ) do
		if index ~= nil then
			v = v:gsub( &quot;#&quot;, index );
		end
		if is_set(args[v]) then
			if value ~= nil and selected ~=  v then
				table.insert( error_list, v );
			else
				value = args[v];
				selected = v;
			end
		end
	end
	
	if #error_list &gt; 0 then
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap_style ('parameter', k);
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap_style ('parameter', selected);
		table.insert( z.message_tail, { set_error( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end

--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (scriptchapter, chapter, transchapter, chapterurl, chapter_url_source)
	local chapter_error = '';
	
	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		chapter = kern_quotes (chapter);										-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
		chapter = wrap_style ('quoted-title', chapter);
	end

	chapter = script_concatenate (chapter, scriptchapter)						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (transchapter) then
		transchapter = wrap_style ('trans-quoted-title', transchapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. transchapter;
		else																	-- here when transchapter without chapter or script-chapter
			chapter = transchapter;												-- 
			chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
		end
	end

	if is_set (chapterurl) then
		chapter = external_link (chapterurl, chapter, chapter_url_source);		-- adds bare_url_missing_title error if appropriate
	end

	return chapter .. chapter_error;
end


--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
]]

local function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end


-- Formats a wiki style internal link
local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s*%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s*%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end

--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in check_isbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end

--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end

--[[--------------------------&lt; C H E C K _ I S M N &gt;------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the issn is invalid
	end 
	
	return text;
end

--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end

--[[
lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--[[
Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of the LCCN dictates the character type of the first 1-3 characters; the
rightmost eight are always digits. http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end

--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.

-- DOI names contain two parts: prefix and suffix separated by a forward slash.
--  Prefix: directory indicator '10.' followed by a registrant code
--  Suffix: character string of any length chosen by the registrant

-- This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes,
-- or, if it ends with a period or a comma, this function will emit a bad_doi error message.

-- DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
-- and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely if ever used in doi names.

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);					-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end

--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end

--[[--------------------------&lt; C L E A N _ I S B N &gt;----------------------------------------------------------

Removes irrelevant text and dashes from ISBN number
Similar to that used for Special:BookSources

]]

local function clean_isbn( isbn_str )
	return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]
local function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other lua magic pattern characters
	return argument;
end

--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	while true do
		if argument:match (&quot;%'%'%'%'%'&quot;) then									-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:match (&quot;%'%'%'%'&quot;) then									-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:match (&quot;%'%'%'&quot;) then									-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:match (&quot;%'%'&quot;) then										-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end

--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...
]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end

--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
local function remove_wiki_link( str )
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end

-- Converts a hyphen to a dash
local function hyphen_to_dash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end

--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if comp:sub(1,1) == duplicate_char then								-- is first charactier same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for th
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = str:sub(-1,-1);										-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = str:sub(1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = str:sub(1, -4) .. &quot;''&quot;;							-- remove them and add back ''
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then		-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then		-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then			-- if last two chars of str are sepc] external link
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;'']&quot; then		-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then				-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = str:sub(1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end		-- if duplicate_char not a letter then escape it
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )			-- remove duplicate_char if it follows html markup
					else
						value = value:sub( 2, -1 );								-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end  

--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

At the time of this writing, I had to write the 'if nil == mw.ustring.find ...' test ouside of the code editor and paste it here
because the code editor gets confused between character insertion point and cursor position.

]]

local function is_good_vanc_name (last, first)
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]*$&quot;) then
		add_vanc_error ();
		return false;															-- not a string of latin characters; Vancouver required Romanization
	end;
	return true;
end

--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  This form is not
currently supported by this code so correctly formed names like Smith JL 2nd are converted to Smith J2. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	if mw.ustring.match(first, &quot;^%u%u$&quot;) then return first end;					-- when first contains just two upper-case letters, nothing to do
	local initials = {}
	local i = 0;																-- counter for number of initials
	for word in mw.ustring.gmatch(first, &quot;[^%s%.%-]+&quot;) do						-- names separated by spaces, hyphens, or periods
		table.insert(initials, mw.ustring.sub(word,1,1))						-- Vancouver format does not include full stops.
		i = i + 1;																-- bump the counter 
		if 2 &lt;= i then break; end												-- only two initials allowed in Vancouver system; if 2, quit
	end
	return table.concat(initials)												-- Vancouver format does not include spaces.
end

--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = ',';																-- name-list separator between authors is a comma
		namesep = ' ';															-- last/first separator is a space
	else
		sep = ';'																-- name-list separator between authors is a semicolon
		namesep = ', '															-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then					-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first 
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;				-- link author/editor if this page is not the author's/editor's page
				end

				if is_set(person.link) and ((nil ~= person.link:find(&quot;//&quot;)) or (nil ~= person.link:find(&quot;[%[%]]&quot;))) then
					one = one .. &quot; &quot; .. set_error( 'bad_authorlink' ) end		-- url or wikilink in author link;
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];						-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end

--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

]]

local function anchor_id( options )
	local id = table.concat( options );											-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end

--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of author and editor name parameters for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the parameters |display-authors=etal or |display-editors=etal

]]

local function name_has_etal (name, etal, nocat)

	if is_set (name) then														-- name can be nil in which case just return
		local etal_pattern = &quot;[;,]? *[\&quot;']*%f[Ee][Ee][Tt] *[Aa][Ll][%.\&quot;']*$&quot;	-- variations on the 'et al' theme
		local others_pattern = &quot;[;,]? *%f[%a]and [Oo]thers&quot;;					-- and alternate to et al.
		
		if name:match (etal_pattern) then										-- variants on et al.
			name = name:gsub (etal_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		elseif name:match (others_pattern) then									-- if not 'et al.', then 'and others'?
			name = name:gsub (others_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		end
	end
	return name, etal;															-- 
end

--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary
	while true do
		last = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false);								-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false);								-- find and remove variations on et al.

		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end

-- Populates ID table from arguments using configuration settings
local function extract_ids( args )
	local id_list = {};
	for k, v in pairs( cfg.id_handlers ) do	
		v = select_one( args, v.parameters, 'redundant_parameters' );
		if is_set(v) then id_list[k] = v; end
	end
	return id_list;
end

--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs and turns it into a table of formatted ID outputs.

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end
  

--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end
	
	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'citation', 'conference', 'interview', 'press release'}) and is_set(data.Periodical) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
		OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	elseif in_array (class, {'arxiv', 'journal', 'news'}) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
		if 'arxiv' == class then
			OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;								-- cite arxiv
		else
			OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
		end
		OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	else
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		if is_set (data.Chapter) then
			OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
			OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;
		else
			OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
	end

	OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
	OCinSoutput[&quot;rft.date&quot;] = data.Date;
	OCinSoutput[&quot;rft.series&quot;] = data.Series;
	OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
	OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
	OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
	OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
	OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
	
	for k, v in pairs( data.ID_list ) do
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
	
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = v.last, v.first;
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;
				OCinSoutput[&quot;rft.aufirst&quot;] = first;
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 code.  Handles the special case that is Norwegian where
ISO639-1 code 'no' is mapped to language name 'Norwegian Bokmål' by Extention:CLDR.

Returns the language name and associated ISO639-1 code.  Because case of the source may be incorrect or different from the case that Wikimedia
uses, the name comparisons are done in lower case and when a match is found, the Wikimedia version (assumed to be correct) is returned along
with the code.  When there is no match, we return the original language name string.

mw.language.fetchLanguageNames() will return a list of languages that aren't part of ISO639-1. Names that aren't ISO639-1 but that are included
in the list will be found if that name is provided in the |language= parameter.  For example, if |language=Samaritan Aramaic, that name will be
found with the associated code 'sam', not an ISO639-1 code.  When names are found and the associated code is not two characters, this function
returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang)
	if 'norwegian' == lang:lower() then											-- special case related to Wikimedia remap of code 'no' at Extension:CLDR
		return 'Norwegian', 'no';												-- Make sure rendered version is properly capitalized
	end
	
	local languages = mw.language.fetchLanguageNames('en', 'all')				-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() then												-- ISO639-1 codes only
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the ISO639-1 code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for ISO639-1 code
end

--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Get language name from ISO639-1 code value provided.  If a code is valid use the returned name; if not, then use the value that was provided with the language parameter.

There is an exception.  There are three ISO639-1 codes for Norewegian language variants.  There are two official variants: Norwegian Bokmål (code 'nb') and
Norwegian Nynorsk (code 'nn').  The third, code 'no',  is defined by ISO639-1 as 'Norwegian' though in Norway this is pretty much meaningless.  However, it appears
that on enwiki, editors are for the most part unaware of the nb and nn variants (compare page counts for these variants at Category:Articles with non-English-language external links.

Because Norwegian Bokmål is the most common language variant, Media wiki has been modified to return Norwegian Bokmål for ISO639-1 code 'no'. Here we undo that and
return 'Norwegian' when editors use |language=no.  We presume that editors don't know about the variants or can't descriminate between them.

See Help talk:Citation Style_1#An ISO 639-1 language name test

When |language= contains a valid ISO639-1 code, the page is assigned to the category for that code: Category:Norwegian-language sources (no) if
the page is a mainspace page and the ISO639-1 code is not 'en'.  Similarly, if the  parameter is |language=Norwegian, it will be categorized in the same way.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the ISO639-1 two character code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang

		if 2 == lang:len() then													-- ISO639-1 language code are 2 characters (fetchLanguageName also supports 3 character codes)
			name = mw.language.fetchLanguageName( lang:lower(), &quot;en&quot; );			-- get ISO 639-1 language name if Language is a proper code
		end
	
		if is_set (name) then													-- if Language specified a valid ISO639-1 code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang);								-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then
			if 'no' == code then name = 'Norwegian' end;						-- override wikimedia when code is 'no'
			if 'en' ~= code then												-- English not the language
				add_prop_cat ('foreign_lang_source', {name, code})
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, ' and ')							-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		language_list[code] = 'and ' .. language_list[code];					-- prepend last name with 'and&lt;space&gt;'
		name = table.concat (language_list, ', ')								-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
	end
	if 'English' == name then
		return '';																-- if one language and that language is English return an enpty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
end

--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = '.';																-- terminate the rendered citation with a period
	end
	return '.', ps;																-- separator is a full stop
end

--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = '';																-- make sure it isn't nil
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return ',', ps, ref;														-- separator is a comma
end

--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end

--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extension, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf[%?#]?') or url:match ('%.PDF[%?#]?');
end

--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parenthases, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end

--[[--------------------------&lt; G E T _ D I S P L A Y _ A U T H O R S _ E D I T O R S &gt;------------------------

Returns a number that may or may not limit the length of the author or editor name lists.

When the value assigned to |display-authors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-authors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

]]

local function get_display_authors_editors (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count and 'authors' == list_name then	-- AUTHORS ONLY		-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_auth_ed', list_name);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset
		end
	elseif 'authors' == list_name then		-- AUTHORS ONLY	need to clear implicit et al category
		max = count + 1;														-- number of authors + 1
	end
	
	return max, etal;
end

--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page, nopp)
--	local good_pattern = '^P[^%.P%l]';
	local good_pattern = '^P[^%.Pp]';										-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
--	local bad_pattern = '^[Pp][Pp]';
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if is_set (nopp) then													-- don't bother checking if |nopp= is set
		return;
	end

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
--		if Page:match ('^[Pp]?[Pp]%.?[ %d]') or  Page:match ('^[Pp]ages?[ %d]') or
--			Pages:match ('^[Pp]?[Pp]%.?[ %d]') or  Pages:match ('^[Pp]ages?[ %d]') then
--				add_maint_cat ('extra_text');
--		end
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	if vparam:find ('%[%[') or vparam:find ('%]%]')	then						-- no wikilinking vauthors names
		add_vanc_error ();
	end
	v_name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;)								-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parenthese to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')
			corporate = true;
		elseif string.find(v_name, &quot;%s&quot;) then
		    lastfirstTable = {}
		    lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
		    first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
		    last  = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
		    if mw.ustring.match (last, '%a+%s+%u+%s+%a+') or mw.ustring.match (v_name, ' %u %u$') then
				add_vanc_error ();												-- matches last II last; the case when a comma is missing or a space between two intiials
			end
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) and not mw.ustring.match (first, &quot;^%u?%u$&quot;) then		-- first shall contain one or two upper-case letters, nothing else
			add_vanc_error ();
		end
																				-- this from extract_names ()
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', 1 ) or		-- do this twice incase we have a first 1 without a last1
		select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, no, etc).  When the parameter value has not been assigned a value (missing or empty
in the source template) the function refurns true.  If the parameter value is one of the list of allowed values returns
true; else, emits an error message and returns false.

]]

local function is_valid_parameter_value (value, name, possible)
	if not is_set (value) then
		return true;															-- an empty parameter is ok
	elseif in_array(value:lower(), possible) then
		return true;
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
end


--[[--------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
characters following the opening bracket obey the rules of a uri scheme (see check_url()).  The test will also find
external wikilinks that use protocol relative urls.

]]

local function is_parameter_ext_wikilink (value)
	if value:match (&quot;%[%a[%a%d%+%.%-]*:.*%]&quot;) or value:match (&quot;%[//.*%]&quot;) then	-- does the param value contain an external wikilink?
		return true;
	else
		return false;
	end
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then														-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );

	local i 
	local PPrefix = A['PPrefix']
	local PPPrefix = A['PPPrefix']
	local NoPP = A['NoPP'] 
	if is_valid_parameter_value (NoPP, 'nopp', cfg.keywords ['yes_true_y']) then
		PPPrefix = '';															-- unset these, prefix if used is in |page= or |pages=
		PPrefix = '';
	else
		NoPP = nil;																-- unset, used as a flag later
	end
		
	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
		end
	end

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
		end
	end

	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled trnaslators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	
	if not is_valid_parameter_value (NameListFormat, 'name-list-format', cfg.keywords['name-list-format']) then			-- only accepted value for this parameter is 'vanc'
		NameListFormat = '';													-- anything else, set to empty string
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
	local Chapter = A['Chapter'];
	local ScriptChapter = A['ScriptChapter'];
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];
	local ArchiveURL = A['ArchiveURL'];
	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];

	local Series = A['Series'];
	local Volume = A['Volume'];
	local Issue = A['Issue'];
	local Position = '';
	local Page = A['Page'];
	local Pages = hyphen_to_dash( A['Pages'] );	
	local At = A['At'];

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
		if not is_valid_parameter_value (RegistrationRequired, 'registration', cfg.keywords ['yes_true_y']) then
			registration=nil;
		end
	local SubscriptionRequired = A['SubscriptionRequired'];
		if not is_valid_parameter_value (SubscriptionRequired, 'subscription', cfg.keywords ['yes_true_y']) then
			subscription=nil;
		end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local ArchiveDate = A['ArchiveDate'];
	local Agency = A['Agency'];
	local DeadURL = A['DeadURL']
		if not is_valid_parameter_value (DeadURL, 'dead-url', cfg.keywords ['deadurl']) then	-- set in config.defaults to 'yes'
			DeadURL = '';														-- anything else, set to empty string
		end

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
		if not is_valid_parameter_value (IgnoreISBN, 'ignore-isbn-error', cfg.keywords ['yes_true_y']) then
			IgnoreISBN = nil;													-- anything else, set to empty string
		end
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
		if not is_valid_parameter_value (LastAuthorAmp, 'last-author-amp', cfg.keywords ['yes_true_y']) then
			LastAuthorAmp = nil;													-- set to empty string
		end
	local no_tracking_cats = A['NoTracking'];
		if not is_valid_parameter_value (no_tracking_cats, 'no-tracking', cfg.keywords ['yes_true_y']) then
			no_tracking_cats = nil;													-- set to empty string
		end

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local use_lowercase;								-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();		-- also used for COinS and for language
	local anchor_year;									-- used in the CITEREF identifier
	local COinS_date;									-- used in the COinS metadata

-- set default parameter values defined by |mode= parameter.  If |mode= is empty or omitted, use CitationClass to set these values
	local Mode = A['Mode'];
	if not is_valid_parameter_value (Mode, 'mode', cfg.keywords['mode']) then
		Mode = '';
	end
	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

-- check for extra |page=, |pages= or |at= parameters. 
	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Page = Page .. &quot; &quot; .. set_error('extra_pages');						-- add error message
			Pages = '';															-- unset the others
			At = '';
		end
		extra_text_in_page_check (Page, NoPP);									-- add this page to maint cat if |page= value begins with what looks like p. or pp.
	elseif is_set(Pages) then
		if is_set(At) then
			Pages = Pages .. &quot; &quot; .. set_error('extra_pages');					-- add error messages
			At = '';															-- unset
		end
		extra_text_in_page_check (Pages, NoPP);									-- add this page to maint cat if |page= value begins with what looks like p. or pp.
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped
	|url maps to |chapterurl when |title is remapped

All other combinations of |encyclopedia, |title, and |article are not modified

]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					TransChapter = TransTitle;
					ChapterURL = URL;
					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter= '[[' .. TitleLink .. '|' .. Chapter .. ']]';
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			else																-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then	-- special case for cite techreport
		if is_set(Issue) then						-- cite techreport uses 'number', which other citations aliase to 'issue'
			if not is_set(ID) then					-- can we use ID for the &quot;number&quot;?
				ID = Issue;							-- yes, use it
				Issue = &quot;&quot;;							-- unset Issue so that &quot;number&quot; isn't duplicated in the rendered citation or COinS metadata
			else									-- can't use ID so emit error message
				ID = ID .. &quot; &quot; .. set_error('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Others) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Others;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Others;
			end
		else
			Others = '(Interview)';
		end
	end

-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];
		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};

																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) then												-- promote airdate or Began/Ended to date
			if is_set (AirDate) then
				Date = AirDate;
			end
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('series', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = '[[' .. ChapterLink .. '|' .. Chapter .. ']]';		-- ok to wikilink
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = '[[' .. ChapterLink .. '|' .. Series .. ']]';			-- series links with ChapterLink (episodelink -&gt; TitleLink -&gt; ChapterLink) ugly
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = '[[' .. SeriesLink .. '|' .. Series .. ']]';
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
-- end of {{cite episode}} stuff

-- Account for the oddities that are {{cite arxiv}}, before generation of COinS data.
	if 'arxiv' == config.CitationClass then
		if not is_set (ID_list['ARXIV']) then									-- |arxiv= or |eprint= required for cite arxiv
			table.insert( z.message_tail, { set_error( 'arxiv_missing', {}, true ) } );		-- add error message
		elseif is_set (Series) then												-- series is an alias of version
			ID_list['ARXIV'] = ID_list['ARXIV'] .. Series;						-- concatenate version onto the end of the arxiv identifier
			Series = '';														-- unset
			deprecated_parameter ('version');									-- deprecated parameter but only for cite arxiv
		end
		
		if first_set (AccessDate, At, Chapter, Format, Page, Pages, Periodical, PublisherName, URL,	-- a crude list of parameters that are not supported by cite arxiv
			ID_list['ASIN'], ID_list['BIBCODE'], ID_list['DOI'], ID_list['ISBN'], ID_list['ISSN'],
			ID_list['JFM'], ID_list['JSTOR'], ID_list['LCCN'], ID_list['MR'], ID_list['OCLC'], ID_list['OL'],
			ID_list['OSTI'], ID_list['PMC'], ID_list['PMID'], ID_list['RFC'], ID_list['SSRN'], ID_list['USENETID'], ID_list['ZBL']) then
				table.insert( z.message_tail, { set_error( 'arxiv_params_not_supported', {}, true ) } );		-- add error message

				AccessDate= '';													-- set these to empty string; not supported in cite arXiv
				PublisherName = '';												-- (if the article has been published, use cite journal, or other)
				Chapter = '';
				URL = '';
				Format = '';
				Page = ''; Pages = ''; At = '';
		end
		Periodical = 'arXiv';													-- set to arXiv for COinS; after that, must be set to empty string
	end

-- handle type parameter for those CS1 citations that have default values

	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
		TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot;;									-- display it in parentheses
	end

-- legacy: promote concatenation of |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end	-- if PublicationDate is same as Date, don't display in rendered citation

--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	do	-- create defined block to contain local variables error_message and mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		anchor_year, COinS_date, error_message = dates({['access-date']=AccessDate, ['archive-date']=ArchiveDate, ['date']=Date, ['doi-broken-date']=DoiBroken,
			['embargo']=Embargo, ['lay-date']=LayDate, ['publication-date']=PublicationDate, ['year']=Year});

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end

		if is_set(error_message) then
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end
	end	-- end of do

-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);											-- 

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
			if 'episode' == config.CitationClass then							-- special case for cite episode; is there a better way to do this?
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
			else
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
			end
	end
	
	if 'none' == Title and is_set(Periodical) and not (( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia))) then								-- special case
		Title = '';																-- set title to empty string
		add_maint_cat ('untitled');
	end

	check_for_url ({['title']=Title, ['chapter']=Chapter, ['work']=Periodical});	-- adds error message when any of these parameters contain a URL

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	
	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = Periodical,
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = first_set(COinS_date, Date),		-- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here?  Should we be including invalid dates in metadata?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set(Sheet, Sheets, Page, Pages, At)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set( URL, ChapterURL ),
		['Authors'] = a,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

-- Account for the oddities that are {{cite arxiv}}, AFTER generation of COinS data.
	if 'arxiv' == config.CitationClass then										-- we have set rft.jtitle in COinS to arXiv, now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in cite arxiv; if article has been published, use cite journal
	end

-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = '[[Usenet newsgroup|Newsgroup]]:&amp;nbsp;' ..  external_link( 'news:' .. PublisherName, PublisherName );
		end
	end



	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local maximum;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text											-- get current page name so that we don't wikilink to it via editorlinkn
		};

		do																		-- do editor name list first because coauthors can modify control table
			maximum , editor_etal = get_display_authors_editors (A['DisplayEditors'], #e, 'editors', editor_etal);
			-- Preserve old-style implicit et al.
			if not is_set(maximum) and #e == 4 then 
				maximum = 3;
				table.insert( z.message_tail, { set_error('implict_etal_editor', {}, true) } );
			end

			control.maximum = maximum;
			
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if is_set (Editors) then
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];				-- add et al. to editors parameter beause |display-editors=etal
					EditorCount = 2;												-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
				else
					EditorCount = 2;												-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
				end
			else
				Editors = last_first_list;											-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then			-- only one editor displayed but includes etal then 
				EditorCount = 2;													-- spoof to display (eds.) annotation
			end
		end
		do																			-- now do translators
			control.maximum = #t;													-- number of translators
			Translators = list_people(control, t, false);							-- et al not currently supported
		end
		do																			-- now do authors
			control.maximum , author_etal = get_display_authors_editors (A['DisplayAuthors'], #a, 'authors', author_etal);

			if is_set(Coauthors) then												-- if the coauthor field is also used, prevent ampersand and et al. formatting.
				control.lastauthoramp = nil;
				control.maximum = #a + 1;
			end
			
			last_first_list = list_people(control, a, author_etal);

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false);	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];				-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;											-- either an author name list or an empty string
			end

		end																			-- end of do

		if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
			table.insert( z.message_tail, { set_error('coauthors_missing_author', {}, true) } );	-- emit error message
		end
	end



--[[
	do																			-- do-block to limit scope of last_first_list
		local last_first_list;
		local maximum = A['DisplayAuthors'];

		maximum , author_etal = get_display_authors_editors (maximum, #a, 'authors', author_etal);

		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text											-- get current page name so that we don't wikilink to it via authorlinkn
			};
		
		if is_set(Coauthors) then												-- if the coauthor field is also used, prevent ampersand and et al. formatting.
			control.lastauthoramp = nil;
			control.maximum = #a + 1;
		end
		
		last_first_list = list_people(control, a, author_etal);

		if is_set (Authors) then
			Authors, author_etal = name_has_etal (Authors, author_etal, false);	-- find and remove variations on et al.
			if author_etal then
				Authors = Authors .. ' ' .. cfg.messages['et al'];				-- add et al. to authors parameter
			end
		else
			Authors = last_first_list;											-- either an author name list or an empty string
		end

	end																			-- end of do

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { set_error('coauthors_missing_author', {}, true) } );	-- emit error message
	end

	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local maximum = A['DisplayEditors'];

		maximum , editor_etal = get_display_authors_editors (maximum, #e, 'editors', editor_etal);
		-- Preserve old-style implicit et al.
		if not is_set(maximum) and #e == 4 then 
			maximum = 3;
			table.insert( z.message_tail, { set_error('implict_etal_editor', {}, true) } );
		end

		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text											-- get current page name so that we don't wikilink to it via editorlinkn
		};

		last_first_list, EditorCount = list_people(control, e, editor_etal);

		if is_set (Editors) then
			if editor_etal then
				Editors = Editors .. ' ' .. cfg.messages['et al'];				-- add et al. to editors parameter beause |display-editors=etal
				EditorCount = 2;												-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
			else
				EditorCount = 2;												-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
			end
		else
			Editors = last_first_list;											-- either an author name list or an empty string
		end

		if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then			-- only one editor displayed but includes etal then 
			EditorCount = 2;													-- spoof to display (eds.) annotation
		end
	end
]]

-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

	if  not is_set(URL) then --and
--		not is_set(ArchiveURL) then --and										-- prevents format_missing_url error from registering
--		not is_set(ConferenceURL) and											-- TODO: keep this here? conference as part of cite web or cite podcast?
--		not is_set(TranscriptURL) then											-- TODO: remove? |transcript-url= and |transcript= has separate test
		
		-- Test if cite web or cite podcast |url= is missing or empty 
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then	
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- Test if accessdate is given without giving a URL
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when the others are not set; TODO: move this to a separate test?
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalFormat;											-- TODO: swap chapter and title here so that archive applies to most specific if both are set?
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalFormat = Format;											-- and original |format=
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
			end
		elseif is_set (ChapterURL) then 										-- URL not set so if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalFormat = ChapterFormat;										-- and original |format=
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
			end
		end
	end

	if in_array(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;journal&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;, &quot;newsgroup&quot;, 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			if is_set (Chapter) or is_set (TransChapter) or is_set (ChapterURL) or is_set (ScriptChapter) then	-- chapter parameters not supported for these citation types
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {A:ORIGIN ('Chapter')}, true ) } );		-- add error message
				Chapter = '';													-- set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
			end
	else																		-- otherwise, format chapter / article title
		Chapter = format_chapter_title (ScriptChapter, Chapter, TransChapter, ChapterURL, ChapterURLorigin);
		if is_set (Chapter) then
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;
			end
			Chapter = Chapter .. ChapterFormat .. sepc .. ' ';
		end
	end

	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if in_array(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;journal&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;, &quot;newsgroup&quot;, &quot;mailinglist&quot;, 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
	
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then 
			Title = external_link( URL, Title ) .. TransError .. Format;
			URL = &quot;&quot;;
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		if is_set(Minutes) then
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			local Time = A['Time'];
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end
	
	if not is_set(Page) then
		if is_set(Pages) then
			if is_set(Periodical) and
				not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
				Pages = &quot;: &quot; .. Pages;
			elseif tonumber(Pages) ~= nil then
				Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
			else
				Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
			end
		end
	else
		if is_set(Periodical) and
			not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
			Page = &quot;: &quot; .. Page;
		else
			Page = sepc ..&quot; &quot; .. PPrefix .. Page;
		end
	end

	if 'map' == config.CitationClass then										-- cite map oddity done after COinS call (and with other in-source locators)
		if is_set (Sheet) or is_set (Sheets) then
			local err_msg1 = 'sheet=, &amp;#124;sheets';							-- default error message in case any of page pages or at are set
			local err_msg2;
			if is_set (Page) or is_set (Pages) or is_set (At) then				-- are any set?
				err_msg2 = 'page=, &amp;#124;pages=, &amp;#124;at';						-- a generic error message
				Page = ''; Pages = ''; At = '';
			elseif is_set (Sheet) and is_set (Sheets) then						-- if both are set make error message
				err_msg1 = 'sheet';
				err_msg2 = 'sheets';
			end
			if is_set (err_msg2) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', err_msg1) .. ' and ' .. wrap_style ('parameter', err_msg2)}, true ) } );		-- add error message
			end
			if not is_set (Sheet) then											-- do sheet static text and formatting; Sheet has priority over Sheets if both provided
				if is_set (Sheets) then
					if is_set (Periodical) then
						Sheet = &quot;: Sheets &quot; .. Sheets;							-- because Sheet has priority, no need to support both later on
					else
						Sheet = sepc .. &quot; Sheets &quot; .. Sheets;
					end
				end
			else
				if is_set (Periodical) then
					Sheet = &quot;: Sheet &quot; .. Sheet;
				else
					Sheet = sepc .. &quot; Sheet &quot; .. Sheet;
				end
			end
		end
	end

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
		Others = sepc .. ' Translated by ' .. Translators .. Others; 
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end
	Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc ..&quot; &quot; .. Volume;
		  else Volume = &quot; &lt;b&gt;&quot; .. hyphen_to_dash(Volume) .. &quot;&lt;/b&gt;&quot;;
		end
	end

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

--[[
Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
note is displayed. There are no error messages for this condition.

]]
	if is_set (SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif is_set (RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if 'citation', lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text
																				-- neither of these work; don't know why; it seems that substitute() isn't being called	
		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
			Quote = Quote:sub(2,-2);
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- CS1 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- DeadURL is empty, 'yes', 'true', 'y', 'unfit', 'usurped'
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
--			if 'usurped' == DeadURL then										-- when original has unsuitable content do not link
			if in_array (DeadURL, {'unfit', 'usurped'}) then
				Archived = sepc .. &quot; &quot; .. 'Archived from the original on ' .. ArchiveDate;	-- format already styled
			else																-- DeadURL is empty, 'yes', 'true', or 'y'
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'] ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'] ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower() ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin );
	end

	local Publisher;
	if is_set(Periodical) and
		not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap_msg ('published', PublicationDate);
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap_msg ('published', PublicationDate) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
			Language, Edition, Publisher, Agency, Volume, Issue}, sepc );
		
	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume, Issue}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Transcript, Language, Edition, Publisher}, sepc );
	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Issue, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Sheet .. Page .. Pages .. At;
	
	if is_set(Authors) then
		if is_set(Coauthors) then
			local sep = '; ';
			if 'vanc' == NameListFormat then
				sep = ', ';
			end
			Authors = Authors .. sep .. Coauthors;
		end
		if is_set(Date) then
			Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		elseif string.sub(Authors,-1,-1) == sepc then
			Authors = Authors .. &quot; &quot;
		else
			Authors = Authors .. sepc .. &quot; &quot;
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			if (sepc ~= '.') then in_text = in_text:lower() end
			Editors = in_text .. Editors .. post_text;
			if (string.sub(Editors,-1,-1) == sepc) or (string.sub(Editors,-3,-1) == sepc .. ']]') then	-- if last editor name ends with sepc char
				Editors = Editors .. &quot; &quot;;										-- don't add another
			else
				Editors = Editors .. sepc .. &quot; &quot;								-- otherwise terninate the editor list
			end
		end
		text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
		text = safe_join( {text, pgtext, idcommon}, sepc );
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon}, sepc );
		text = safe_join( {text, pgtext, idcommon}, sepc );
	else
		if is_set(Date) then
			if ( string.sub(tcommon,-1,-1) ~= sepc )
			  then Date = sepc ..&quot; &quot; .. Date .. OrigYear
			  else Date = &quot; &quot; .. Date .. OrigYear
			end
		end
		if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon}, sepc );
			text = safe_join( {text, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date}, sepc );
			text = safe_join( {text, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = config.CitationClass;
		options.class = &quot;citation &quot; .. config.CitationClass;					-- class=citation required for blue highlight when used with |ref=
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
		local id = Ref
		if ( &quot;harv&quot; == Ref ) then
			local names = {} --table of last names &amp; year
			if #a &gt; 0 then
				for i,v in ipairs(a) do 
					names[i] = v.last 
					if i == 4 then break end
				end
			elseif #e &gt; 0 then
				for i,v in ipairs(e) do 
					names[i] = v.last 
					if i == 4 then break end				
				end
			end
			names[ #names + 1 ] = first_set(Year, anchor_year);	-- Year first for legacy citations and for YMD dates that require disambiguation
			id = anchor_id(names)
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then 
		text = '&lt;cite id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/cite&gt;&quot;;
	else
		text = '&lt;cite class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/cite&gt;&quot;;
	end		

	local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
	
	-- Note: Using display: none on then COinS span breaks some clients.
	local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
	text = text .. OCinS;
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. error_comment( v[1], v[2] );
				else
					text = text .. error_comment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end

	if #z.maintenance_cats ~= 0 then
		text = text .. '&lt;span class=&quot;citation-comment&quot; style=&quot;display:none; color:#33aa33&quot;&gt;';
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. ' ' .. v .. ' ([[:Category:' .. v ..'|link]])';
		end
		text = text .. '&lt;/span&gt;';	-- maintenance mesages (realy just the names of the categories for now)
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
	local pframe = frame:getParent()
	local validation;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of Configuration and Whitelist and ...
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');	-- ... sandbox version of date validation code

	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of Configuration and Whitelist and ...
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		validation = require ('Module:Citation/CS1/Date_validation');			-- ... live version of date validation code
	end

	dates = validation.dates;													-- imported functions
	year_date_check = validation.year_date_check;

	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute( param, capture );				-- add the capture to the suggested parameter (typically the enumerator)
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, param}, true );	-- set the error message
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
						end
					end
--					if #suggestions == 0 then
--						suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
--					end
--					if suggestions[ k:lower() ] ~= nil then
--						error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
--					else
--						error_text, error_state = set_error( 'parameter_ignored', {k}, true );
--					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	
	
	return citation0( config, args)
end

return z</text>
      <sha1>cwm35adoov8xmr4vpsgc0e8dfqsvpps</sha1>
    </revision>
    <revision>
      <id>4696</id>
      <parentid>4695</parentid>
      <timestamp>2015-09-26T17:17:39Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <minor />
      <comment>is_parameter_ext_wikilink() fix;</comment>
      <origin>4696</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="156779" sha1="2inpqucvt56tuiwvq2cfg4slk4o10fu" xml:space="preserve">
local z = {
	error_categories = {};		-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};		-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};		-- for categorizing citations based on certain properties, language of source for instance
}

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]
local dates, year_date_check	-- functions in Module:Citation/CS1/Date_validation

local cfg = {};					-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};			-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist

--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.
This function is global because it is called from both this module and from Date validation

]]
function is_set( var )
	return not (var == nil or var == '');
end

--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

First set variable or nil if none

]]

local function first_set(...)
	local list = {...};
	for _, var in pairs(list) do
		if is_set( var ) then
			return var;
		end
	end
end

--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end

--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]
local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end

--[[--------------------------&lt; S E T _ E R R O R &gt;--------------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

]]
local function set_error( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if in_array( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return error_comment( message, error_state.hidden );
end

--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maintenance_cats using names from the configuration file with additional text if any.
To prevent duplication, the added_maint_cats table lists the categories by key that have been added to z.maintenance_cats.

]]

local added_maint_cats = {}														-- list of maintenance categories that have been added to z.maintenance_cats
local function add_maint_cat (key, arguments)
	if not added_maint_cats [key] then
		added_maint_cats [key] = true;											-- note that we've added this category
		table.insert( z.maintenance_cats, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
	end
end

--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

]]

local added_prop_cats = {}														-- list of property categories that have been added to z.properties_cats
local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));		-- make name then add to table
	end
end

--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

]]

local added_vanc_errs;															-- flag so we only emit one Vancouver error / category
local function add_vanc_error ()
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {}, true ) } );
	end
end

--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string is valid.

At present the only check is whether the string appears to be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well formed.

The scheme is checked http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

First we test for space characters.  If any are found, return false.  Then test for the case where the url is
protocol relative (//example.com).  If the first two characters of the |url= value are //, return true.  Last
look for what appears to be a scheme according to the definition above.  If the characters preceding the colon
are in the allowed set, return true, else false
]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value
		return false;
	end
	return url_str:sub(1,2) == &quot;//&quot; or nil ~= url_str:match (&quot;^%a[%a%d%+%.%-]*:&quot;)		-- protocol relative or scheme part composed of legitimate characters
end

--[[--------------------------&lt; S A F E _ F O R _ I T A L I C S &gt;----------------------------------------------

Protects a string that will be wrapped in wiki italic markup '' ... ''

Note: We cannot use &lt;i&gt; for italics, as the expected behavior for italics specified by ''...'' in the title is that
they will be inverted (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and '' tend to interact
poorly under Mediawiki's HTML tidy.

]]

local function safe_for_italics( str )
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end

--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

local function wrap_style (key, str)
	if not is_set( str ) then
		return &quot;&quot;;
	elseif in_array( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safe_for_italics( str );
	end

	return substitute( cfg.presentation[key], {str} );
end

--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source )
	local error_str = &quot;&quot;;
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
	end
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url( label ), &quot;]&quot;, error_str });
end

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

]]

local page_in_deprecated_cat;													-- sticky flag so that the category is added only once
local function deprecated_parameter(name)
	if not page_in_deprecated_cat then
		page_in_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end

--[[--------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Call this function for chapter titles, for website titles, etc; not for book titles.

]]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	
	cap, cap2 = str:match (&quot;^([\&quot;\'])([^\'].+)&quot;);								-- match leading double or single quote but not double single quotes
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-left'], {cap, cap2});
	end

	cap, cap2 = str:match (&quot;^(.+[^\'])([\&quot;\'])$&quot;)
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-right'], {cap, cap2});
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title= and |script-chapter=

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, {'ar', 'bg', 'bs', 'dv', 'el', 'fa', 'he', 'hy', 'ja', 'ka', 'ko', 'ku', 'mk', 'ps', 'ru', 'sd', 'sr', 'th', 'uk', 'ug', 'yi', 'zh'}) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				add_prop_cat ('script')
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		str = substitute( msg, {str} );											-- including template text
		return str;
	else
		return substitute( cfg.messages[key], {str} );
	end		
end

--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider
Generates an error if more than one match is present.

]]

local function select_one( args, possible, error_condition, index )
	local value = nil;
	local selected = '';
	local error_list = {};
	
	if index ~= nil then index = tostring(index); end
	
	-- Handle special case of &quot;#&quot; replaced by empty string
	if index == '1' then
		for _, v in ipairs( possible ) do
			v = v:gsub( &quot;#&quot;, &quot;&quot; );
			if is_set(args[v]) then
				if value ~= nil and selected ~= v then
					table.insert( error_list, v );
				else
					value = args[v];
					selected = v;
				end
			end
		end		
	end
	
	for _, v in ipairs( possible ) do
		if index ~= nil then
			v = v:gsub( &quot;#&quot;, index );
		end
		if is_set(args[v]) then
			if value ~= nil and selected ~=  v then
				table.insert( error_list, v );
			else
				value = args[v];
				selected = v;
			end
		end
	end
	
	if #error_list &gt; 0 then
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap_style ('parameter', k);
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap_style ('parameter', selected);
		table.insert( z.message_tail, { set_error( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end

--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (scriptchapter, chapter, transchapter, chapterurl, chapter_url_source)
	local chapter_error = '';
	
	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		chapter = kern_quotes (chapter);										-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
		chapter = wrap_style ('quoted-title', chapter);
	end

	chapter = script_concatenate (chapter, scriptchapter)						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (transchapter) then
		transchapter = wrap_style ('trans-quoted-title', transchapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. transchapter;
		else																	-- here when transchapter without chapter or script-chapter
			chapter = transchapter;												-- 
			chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
		end
	end

	if is_set (chapterurl) then
		chapter = external_link (chapterurl, chapter, chapter_url_source);		-- adds bare_url_missing_title error if appropriate
	end

	return chapter .. chapter_error;
end


--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
]]

local function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end


-- Formats a wiki style internal link
local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s*%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s*%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end

--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in check_isbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end

--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end

--[[--------------------------&lt; C H E C K _ I S M N &gt;------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the issn is invalid
	end 
	
	return text;
end

--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end

--[[
lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--[[
Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of the LCCN dictates the character type of the first 1-3 characters; the
rightmost eight are always digits. http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end

--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.

-- DOI names contain two parts: prefix and suffix separated by a forward slash.
--  Prefix: directory indicator '10.' followed by a registrant code
--  Suffix: character string of any length chosen by the registrant

-- This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes,
-- or, if it ends with a period or a comma, this function will emit a bad_doi error message.

-- DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
-- and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely if ever used in doi names.

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);					-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end

--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end

--[[--------------------------&lt; C L E A N _ I S B N &gt;----------------------------------------------------------

Removes irrelevant text and dashes from ISBN number
Similar to that used for Special:BookSources

]]

local function clean_isbn( isbn_str )
	return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]
local function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other lua magic pattern characters
	return argument;
end

--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	while true do
		if argument:match (&quot;%'%'%'%'%'&quot;) then									-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:match (&quot;%'%'%'%'&quot;) then									-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:match (&quot;%'%'%'&quot;) then									-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:match (&quot;%'%'&quot;) then										-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end

--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...
]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end

--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
local function remove_wiki_link( str )
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end

-- Converts a hyphen to a dash
local function hyphen_to_dash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end

--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if comp:sub(1,1) == duplicate_char then								-- is first charactier same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for th
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = str:sub(-1,-1);										-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = str:sub(1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = str:sub(1, -4) .. &quot;''&quot;;							-- remove them and add back ''
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then		-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then		-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then			-- if last two chars of str are sepc] external link
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;'']&quot; then		-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then				-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = str:sub(1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end		-- if duplicate_char not a letter then escape it
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )			-- remove duplicate_char if it follows html markup
					else
						value = value:sub( 2, -1 );								-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end  

--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

At the time of this writing, I had to write the 'if nil == mw.ustring.find ...' test ouside of the code editor and paste it here
because the code editor gets confused between character insertion point and cursor position.

]]

local function is_good_vanc_name (last, first)
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]*$&quot;) then
		add_vanc_error ();
		return false;															-- not a string of latin characters; Vancouver required Romanization
	end;
	return true;
end

--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  This form is not
currently supported by this code so correctly formed names like Smith JL 2nd are converted to Smith J2. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	if mw.ustring.match(first, &quot;^%u%u$&quot;) then return first end;					-- when first contains just two upper-case letters, nothing to do
	local initials = {}
	local i = 0;																-- counter for number of initials
	for word in mw.ustring.gmatch(first, &quot;[^%s%.%-]+&quot;) do						-- names separated by spaces, hyphens, or periods
		table.insert(initials, mw.ustring.sub(word,1,1))						-- Vancouver format does not include full stops.
		i = i + 1;																-- bump the counter 
		if 2 &lt;= i then break; end												-- only two initials allowed in Vancouver system; if 2, quit
	end
	return table.concat(initials)												-- Vancouver format does not include spaces.
end

--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = ',';																-- name-list separator between authors is a comma
		namesep = ' ';															-- last/first separator is a space
	else
		sep = ';'																-- name-list separator between authors is a semicolon
		namesep = ', '															-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then					-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first 
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;				-- link author/editor if this page is not the author's/editor's page
				end

				if is_set(person.link) and ((nil ~= person.link:find(&quot;//&quot;)) or (nil ~= person.link:find(&quot;[%[%]]&quot;))) then
					one = one .. &quot; &quot; .. set_error( 'bad_authorlink' ) end		-- url or wikilink in author link;
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];						-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end

--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

]]

local function anchor_id( options )
	local id = table.concat( options );											-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end

--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of author and editor name parameters for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the parameters |display-authors=etal or |display-editors=etal

]]

local function name_has_etal (name, etal, nocat)

	if is_set (name) then														-- name can be nil in which case just return
		local etal_pattern = &quot;[;,]? *[\&quot;']*%f[Ee][Ee][Tt] *[Aa][Ll][%.\&quot;']*$&quot;	-- variations on the 'et al' theme
		local others_pattern = &quot;[;,]? *%f[%a]and [Oo]thers&quot;;					-- and alternate to et al.
		
		if name:match (etal_pattern) then										-- variants on et al.
			name = name:gsub (etal_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		elseif name:match (others_pattern) then									-- if not 'et al.', then 'and others'?
			name = name:gsub (others_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		end
	end
	return name, etal;															-- 
end

--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary
	while true do
		last = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false);								-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false);								-- find and remove variations on et al.

		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end

-- Populates ID table from arguments using configuration settings
local function extract_ids( args )
	local id_list = {};
	for k, v in pairs( cfg.id_handlers ) do	
		v = select_one( args, v.parameters, 'redundant_parameters' );
		if is_set(v) then id_list[k] = v; end
	end
	return id_list;
end

--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs and turns it into a table of formatted ID outputs.

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end
  

--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end
	
	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'citation', 'conference', 'interview', 'press release'}) and is_set(data.Periodical) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
		OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	elseif in_array (class, {'arxiv', 'journal', 'news'}) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
		if 'arxiv' == class then
			OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;								-- cite arxiv
		else
			OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
		end
		OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	else
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		if is_set (data.Chapter) then
			OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
			OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;
		else
			OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
	end

	OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
	OCinSoutput[&quot;rft.date&quot;] = data.Date;
	OCinSoutput[&quot;rft.series&quot;] = data.Series;
	OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
	OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
	OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
	OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
	OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
	
	for k, v in pairs( data.ID_list ) do
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
	
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = v.last, v.first;
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;
				OCinSoutput[&quot;rft.aufirst&quot;] = first;
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 code.  Handles the special case that is Norwegian where
ISO639-1 code 'no' is mapped to language name 'Norwegian Bokmål' by Extention:CLDR.

Returns the language name and associated ISO639-1 code.  Because case of the source may be incorrect or different from the case that Wikimedia
uses, the name comparisons are done in lower case and when a match is found, the Wikimedia version (assumed to be correct) is returned along
with the code.  When there is no match, we return the original language name string.

mw.language.fetchLanguageNames() will return a list of languages that aren't part of ISO639-1. Names that aren't ISO639-1 but that are included
in the list will be found if that name is provided in the |language= parameter.  For example, if |language=Samaritan Aramaic, that name will be
found with the associated code 'sam', not an ISO639-1 code.  When names are found and the associated code is not two characters, this function
returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang)
	if 'norwegian' == lang:lower() then											-- special case related to Wikimedia remap of code 'no' at Extension:CLDR
		return 'Norwegian', 'no';												-- Make sure rendered version is properly capitalized
	end
	
	local languages = mw.language.fetchLanguageNames('en', 'all')				-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() then												-- ISO639-1 codes only
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the ISO639-1 code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for ISO639-1 code
end

--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Get language name from ISO639-1 code value provided.  If a code is valid use the returned name; if not, then use the value that was provided with the language parameter.

There is an exception.  There are three ISO639-1 codes for Norewegian language variants.  There are two official variants: Norwegian Bokmål (code 'nb') and
Norwegian Nynorsk (code 'nn').  The third, code 'no',  is defined by ISO639-1 as 'Norwegian' though in Norway this is pretty much meaningless.  However, it appears
that on enwiki, editors are for the most part unaware of the nb and nn variants (compare page counts for these variants at Category:Articles with non-English-language external links.

Because Norwegian Bokmål is the most common language variant, Media wiki has been modified to return Norwegian Bokmål for ISO639-1 code 'no'. Here we undo that and
return 'Norwegian' when editors use |language=no.  We presume that editors don't know about the variants or can't descriminate between them.

See Help talk:Citation Style_1#An ISO 639-1 language name test

When |language= contains a valid ISO639-1 code, the page is assigned to the category for that code: Category:Norwegian-language sources (no) if
the page is a mainspace page and the ISO639-1 code is not 'en'.  Similarly, if the  parameter is |language=Norwegian, it will be categorized in the same way.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the ISO639-1 two character code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang

		if 2 == lang:len() then													-- ISO639-1 language code are 2 characters (fetchLanguageName also supports 3 character codes)
			name = mw.language.fetchLanguageName( lang:lower(), &quot;en&quot; );			-- get ISO 639-1 language name if Language is a proper code
		end
	
		if is_set (name) then													-- if Language specified a valid ISO639-1 code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang);								-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then
			if 'no' == code then name = 'Norwegian' end;						-- override wikimedia when code is 'no'
			if 'en' ~= code then												-- English not the language
				add_prop_cat ('foreign_lang_source', {name, code})
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, ' and ')							-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		language_list[code] = 'and ' .. language_list[code];					-- prepend last name with 'and&lt;space&gt;'
		name = table.concat (language_list, ', ')								-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
	end
	if 'English' == name then
		return '';																-- if one language and that language is English return an enpty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
end

--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = '.';																-- terminate the rendered citation with a period
	end
	return '.', ps;																-- separator is a full stop
end

--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = '';																-- make sure it isn't nil
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return ',', ps, ref;														-- separator is a comma
end

--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end

--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extension, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf[%?#]?') or url:match ('%.PDF[%?#]?');
end

--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parenthases, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end

--[[--------------------------&lt; G E T _ D I S P L A Y _ A U T H O R S _ E D I T O R S &gt;------------------------

Returns a number that may or may not limit the length of the author or editor name lists.

When the value assigned to |display-authors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-authors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

]]

local function get_display_authors_editors (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count and 'authors' == list_name then	-- AUTHORS ONLY		-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_auth_ed', list_name);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset
		end
	elseif 'authors' == list_name then		-- AUTHORS ONLY	need to clear implicit et al category
		max = count + 1;														-- number of authors + 1
	end
	
	return max, etal;
end

--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page, nopp)
--	local good_pattern = '^P[^%.P%l]';
	local good_pattern = '^P[^%.Pp]';										-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
--	local bad_pattern = '^[Pp][Pp]';
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if is_set (nopp) then													-- don't bother checking if |nopp= is set
		return;
	end

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
--		if Page:match ('^[Pp]?[Pp]%.?[ %d]') or  Page:match ('^[Pp]ages?[ %d]') or
--			Pages:match ('^[Pp]?[Pp]%.?[ %d]') or  Pages:match ('^[Pp]ages?[ %d]') then
--				add_maint_cat ('extra_text');
--		end
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	if vparam:find ('%[%[') or vparam:find ('%]%]')	then						-- no wikilinking vauthors names
		add_vanc_error ();
	end
	v_name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;)								-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parenthese to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')
			corporate = true;
		elseif string.find(v_name, &quot;%s&quot;) then
		    lastfirstTable = {}
		    lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
		    first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
		    last  = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
		    if mw.ustring.match (last, '%a+%s+%u+%s+%a+') or mw.ustring.match (v_name, ' %u %u$') then
				add_vanc_error ();												-- matches last II last; the case when a comma is missing or a space between two intiials
			end
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) and not mw.ustring.match (first, &quot;^%u?%u$&quot;) then		-- first shall contain one or two upper-case letters, nothing else
			add_vanc_error ();
		end
																				-- this from extract_names ()
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', 1 ) or		-- do this twice incase we have a first 1 without a last1
		select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, no, etc).  When the parameter value has not been assigned a value (missing or empty
in the source template) the function refurns true.  If the parameter value is one of the list of allowed values returns
true; else, emits an error message and returns false.

]]

local function is_valid_parameter_value (value, name, possible)
	if not is_set (value) then
		return true;															-- an empty parameter is ok
	elseif in_array(value:lower(), possible) then
		return true;
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
end


--[[--------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
characters following the opening bracket obey the rules of a uri scheme (see check_url()).  The test will also find
external wikilinks that use protocol relative urls.

]]

local function is_parameter_ext_wikilink (value)
	if value:match (&quot;%[%[%a+:&quot;) then											-- if a wikilink with namespace
		return false;
	elseif value:match (&quot;%[%a[%a%d%+%.%-]*:.*%]&quot;) or value:match (&quot;%[//.*%]&quot;) then	-- does the param value contain an external wikilink?
		return true;
	else
		return false;
	end
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then														-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );

	local i 
	local PPrefix = A['PPrefix']
	local PPPrefix = A['PPPrefix']
	local NoPP = A['NoPP'] 
	if is_valid_parameter_value (NoPP, 'nopp', cfg.keywords ['yes_true_y']) then
		PPPrefix = '';															-- unset these, prefix if used is in |page= or |pages=
		PPrefix = '';
	else
		NoPP = nil;																-- unset, used as a flag later
	end
		
	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
		end
	end

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
		end
	end

	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled trnaslators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	
	if not is_valid_parameter_value (NameListFormat, 'name-list-format', cfg.keywords['name-list-format']) then			-- only accepted value for this parameter is 'vanc'
		NameListFormat = '';													-- anything else, set to empty string
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
	local Chapter = A['Chapter'];
	local ScriptChapter = A['ScriptChapter'];
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];
	local ArchiveURL = A['ArchiveURL'];
	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];

	local Series = A['Series'];
	local Volume = A['Volume'];
	local Issue = A['Issue'];
	local Position = '';
	local Page = A['Page'];
	local Pages = hyphen_to_dash( A['Pages'] );	
	local At = A['At'];

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
		if not is_valid_parameter_value (RegistrationRequired, 'registration', cfg.keywords ['yes_true_y']) then
			registration=nil;
		end
	local SubscriptionRequired = A['SubscriptionRequired'];
		if not is_valid_parameter_value (SubscriptionRequired, 'subscription', cfg.keywords ['yes_true_y']) then
			subscription=nil;
		end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local ArchiveDate = A['ArchiveDate'];
	local Agency = A['Agency'];
	local DeadURL = A['DeadURL']
		if not is_valid_parameter_value (DeadURL, 'dead-url', cfg.keywords ['deadurl']) then	-- set in config.defaults to 'yes'
			DeadURL = '';														-- anything else, set to empty string
		end

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
		if not is_valid_parameter_value (IgnoreISBN, 'ignore-isbn-error', cfg.keywords ['yes_true_y']) then
			IgnoreISBN = nil;													-- anything else, set to empty string
		end
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
		if not is_valid_parameter_value (LastAuthorAmp, 'last-author-amp', cfg.keywords ['yes_true_y']) then
			LastAuthorAmp = nil;													-- set to empty string
		end
	local no_tracking_cats = A['NoTracking'];
		if not is_valid_parameter_value (no_tracking_cats, 'no-tracking', cfg.keywords ['yes_true_y']) then
			no_tracking_cats = nil;													-- set to empty string
		end

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local use_lowercase;								-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();		-- also used for COinS and for language
	local anchor_year;									-- used in the CITEREF identifier
	local COinS_date;									-- used in the COinS metadata

-- set default parameter values defined by |mode= parameter.  If |mode= is empty or omitted, use CitationClass to set these values
	local Mode = A['Mode'];
	if not is_valid_parameter_value (Mode, 'mode', cfg.keywords['mode']) then
		Mode = '';
	end
	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

-- check for extra |page=, |pages= or |at= parameters. 
	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Page = Page .. &quot; &quot; .. set_error('extra_pages');						-- add error message
			Pages = '';															-- unset the others
			At = '';
		end
		extra_text_in_page_check (Page, NoPP);									-- add this page to maint cat if |page= value begins with what looks like p. or pp.
	elseif is_set(Pages) then
		if is_set(At) then
			Pages = Pages .. &quot; &quot; .. set_error('extra_pages');					-- add error messages
			At = '';															-- unset
		end
		extra_text_in_page_check (Pages, NoPP);									-- add this page to maint cat if |page= value begins with what looks like p. or pp.
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped
	|url maps to |chapterurl when |title is remapped

All other combinations of |encyclopedia, |title, and |article are not modified

]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					TransChapter = TransTitle;
					ChapterURL = URL;
					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter= '[[' .. TitleLink .. '|' .. Chapter .. ']]';
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			else																-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then	-- special case for cite techreport
		if is_set(Issue) then						-- cite techreport uses 'number', which other citations aliase to 'issue'
			if not is_set(ID) then					-- can we use ID for the &quot;number&quot;?
				ID = Issue;							-- yes, use it
				Issue = &quot;&quot;;							-- unset Issue so that &quot;number&quot; isn't duplicated in the rendered citation or COinS metadata
			else									-- can't use ID so emit error message
				ID = ID .. &quot; &quot; .. set_error('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Others) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Others;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Others;
			end
		else
			Others = '(Interview)';
		end
	end

-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];
		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};

																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) then												-- promote airdate or Began/Ended to date
			if is_set (AirDate) then
				Date = AirDate;
			end
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('series', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = '[[' .. ChapterLink .. '|' .. Chapter .. ']]';		-- ok to wikilink
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = '[[' .. ChapterLink .. '|' .. Series .. ']]';			-- series links with ChapterLink (episodelink -&gt; TitleLink -&gt; ChapterLink) ugly
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = '[[' .. SeriesLink .. '|' .. Series .. ']]';
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
-- end of {{cite episode}} stuff

-- Account for the oddities that are {{cite arxiv}}, before generation of COinS data.
	if 'arxiv' == config.CitationClass then
		if not is_set (ID_list['ARXIV']) then									-- |arxiv= or |eprint= required for cite arxiv
			table.insert( z.message_tail, { set_error( 'arxiv_missing', {}, true ) } );		-- add error message
		elseif is_set (Series) then												-- series is an alias of version
			ID_list['ARXIV'] = ID_list['ARXIV'] .. Series;						-- concatenate version onto the end of the arxiv identifier
			Series = '';														-- unset
			deprecated_parameter ('version');									-- deprecated parameter but only for cite arxiv
		end
		
		if first_set (AccessDate, At, Chapter, Format, Page, Pages, Periodical, PublisherName, URL,	-- a crude list of parameters that are not supported by cite arxiv
			ID_list['ASIN'], ID_list['BIBCODE'], ID_list['DOI'], ID_list['ISBN'], ID_list['ISSN'],
			ID_list['JFM'], ID_list['JSTOR'], ID_list['LCCN'], ID_list['MR'], ID_list['OCLC'], ID_list['OL'],
			ID_list['OSTI'], ID_list['PMC'], ID_list['PMID'], ID_list['RFC'], ID_list['SSRN'], ID_list['USENETID'], ID_list['ZBL']) then
				table.insert( z.message_tail, { set_error( 'arxiv_params_not_supported', {}, true ) } );		-- add error message

				AccessDate= '';													-- set these to empty string; not supported in cite arXiv
				PublisherName = '';												-- (if the article has been published, use cite journal, or other)
				Chapter = '';
				URL = '';
				Format = '';
				Page = ''; Pages = ''; At = '';
		end
		Periodical = 'arXiv';													-- set to arXiv for COinS; after that, must be set to empty string
	end

-- handle type parameter for those CS1 citations that have default values

	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
		TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot;;									-- display it in parentheses
	end

-- legacy: promote concatenation of |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end	-- if PublicationDate is same as Date, don't display in rendered citation

--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	do	-- create defined block to contain local variables error_message and mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		anchor_year, COinS_date, error_message = dates({['access-date']=AccessDate, ['archive-date']=ArchiveDate, ['date']=Date, ['doi-broken-date']=DoiBroken,
			['embargo']=Embargo, ['lay-date']=LayDate, ['publication-date']=PublicationDate, ['year']=Year});

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end

		if is_set(error_message) then
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end
	end	-- end of do

-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);											-- 

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
			if 'episode' == config.CitationClass then							-- special case for cite episode; is there a better way to do this?
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
			else
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
			end
	end
	
	if 'none' == Title and is_set(Periodical) and not (( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia))) then								-- special case
		Title = '';																-- set title to empty string
		add_maint_cat ('untitled');
	end

	check_for_url ({['title']=Title, ['chapter']=Chapter, ['work']=Periodical});	-- adds error message when any of these parameters contain a URL

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	
	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = Periodical,
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = first_set(COinS_date, Date),		-- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here?  Should we be including invalid dates in metadata?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set(Sheet, Sheets, Page, Pages, At)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set( URL, ChapterURL ),
		['Authors'] = a,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

-- Account for the oddities that are {{cite arxiv}}, AFTER generation of COinS data.
	if 'arxiv' == config.CitationClass then										-- we have set rft.jtitle in COinS to arXiv, now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in cite arxiv; if article has been published, use cite journal
	end

-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = '[[Usenet newsgroup|Newsgroup]]:&amp;nbsp;' ..  external_link( 'news:' .. PublisherName, PublisherName );
		end
	end



	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local maximum;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text											-- get current page name so that we don't wikilink to it via editorlinkn
		};

		do																		-- do editor name list first because coauthors can modify control table
			maximum , editor_etal = get_display_authors_editors (A['DisplayEditors'], #e, 'editors', editor_etal);
			-- Preserve old-style implicit et al.
			if not is_set(maximum) and #e == 4 then 
				maximum = 3;
				table.insert( z.message_tail, { set_error('implict_etal_editor', {}, true) } );
			end

			control.maximum = maximum;
			
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if is_set (Editors) then
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];				-- add et al. to editors parameter beause |display-editors=etal
					EditorCount = 2;												-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
				else
					EditorCount = 2;												-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
				end
			else
				Editors = last_first_list;											-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then			-- only one editor displayed but includes etal then 
				EditorCount = 2;													-- spoof to display (eds.) annotation
			end
		end
		do																			-- now do translators
			control.maximum = #t;													-- number of translators
			Translators = list_people(control, t, false);							-- et al not currently supported
		end
		do																			-- now do authors
			control.maximum , author_etal = get_display_authors_editors (A['DisplayAuthors'], #a, 'authors', author_etal);

			if is_set(Coauthors) then												-- if the coauthor field is also used, prevent ampersand and et al. formatting.
				control.lastauthoramp = nil;
				control.maximum = #a + 1;
			end
			
			last_first_list = list_people(control, a, author_etal);

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false);	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];				-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;											-- either an author name list or an empty string
			end

		end																			-- end of do

		if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
			table.insert( z.message_tail, { set_error('coauthors_missing_author', {}, true) } );	-- emit error message
		end
	end



--[[
	do																			-- do-block to limit scope of last_first_list
		local last_first_list;
		local maximum = A['DisplayAuthors'];

		maximum , author_etal = get_display_authors_editors (maximum, #a, 'authors', author_etal);

		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text											-- get current page name so that we don't wikilink to it via authorlinkn
			};
		
		if is_set(Coauthors) then												-- if the coauthor field is also used, prevent ampersand and et al. formatting.
			control.lastauthoramp = nil;
			control.maximum = #a + 1;
		end
		
		last_first_list = list_people(control, a, author_etal);

		if is_set (Authors) then
			Authors, author_etal = name_has_etal (Authors, author_etal, false);	-- find and remove variations on et al.
			if author_etal then
				Authors = Authors .. ' ' .. cfg.messages['et al'];				-- add et al. to authors parameter
			end
		else
			Authors = last_first_list;											-- either an author name list or an empty string
		end

	end																			-- end of do

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { set_error('coauthors_missing_author', {}, true) } );	-- emit error message
	end

	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local maximum = A['DisplayEditors'];

		maximum , editor_etal = get_display_authors_editors (maximum, #e, 'editors', editor_etal);
		-- Preserve old-style implicit et al.
		if not is_set(maximum) and #e == 4 then 
			maximum = 3;
			table.insert( z.message_tail, { set_error('implict_etal_editor', {}, true) } );
		end

		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text											-- get current page name so that we don't wikilink to it via editorlinkn
		};

		last_first_list, EditorCount = list_people(control, e, editor_etal);

		if is_set (Editors) then
			if editor_etal then
				Editors = Editors .. ' ' .. cfg.messages['et al'];				-- add et al. to editors parameter beause |display-editors=etal
				EditorCount = 2;												-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
			else
				EditorCount = 2;												-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
			end
		else
			Editors = last_first_list;											-- either an author name list or an empty string
		end

		if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then			-- only one editor displayed but includes etal then 
			EditorCount = 2;													-- spoof to display (eds.) annotation
		end
	end
]]

-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

	if  not is_set(URL) then --and
--		not is_set(ArchiveURL) then --and										-- prevents format_missing_url error from registering
--		not is_set(ConferenceURL) and											-- TODO: keep this here? conference as part of cite web or cite podcast?
--		not is_set(TranscriptURL) then											-- TODO: remove? |transcript-url= and |transcript= has separate test
		
		-- Test if cite web or cite podcast |url= is missing or empty 
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then	
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- Test if accessdate is given without giving a URL
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when the others are not set; TODO: move this to a separate test?
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalFormat;											-- TODO: swap chapter and title here so that archive applies to most specific if both are set?
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalFormat = Format;											-- and original |format=
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
			end
		elseif is_set (ChapterURL) then 										-- URL not set so if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalFormat = ChapterFormat;										-- and original |format=
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
			end
		end
	end

	if in_array(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;journal&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;, &quot;newsgroup&quot;, 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			if is_set (Chapter) or is_set (TransChapter) or is_set (ChapterURL) or is_set (ScriptChapter) then	-- chapter parameters not supported for these citation types
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {A:ORIGIN ('Chapter')}, true ) } );		-- add error message
				Chapter = '';													-- set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
			end
	else																		-- otherwise, format chapter / article title
		Chapter = format_chapter_title (ScriptChapter, Chapter, TransChapter, ChapterURL, ChapterURLorigin);
		if is_set (Chapter) then
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;
			end
			Chapter = Chapter .. ChapterFormat .. sepc .. ' ';
		end
	end

	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if in_array(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;journal&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;, &quot;newsgroup&quot;, &quot;mailinglist&quot;, 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
	
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then 
			Title = external_link( URL, Title ) .. TransError .. Format;
			URL = &quot;&quot;;
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		if is_set(Minutes) then
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			local Time = A['Time'];
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end
	
	if not is_set(Page) then
		if is_set(Pages) then
			if is_set(Periodical) and
				not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
				Pages = &quot;: &quot; .. Pages;
			elseif tonumber(Pages) ~= nil then
				Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
			else
				Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
			end
		end
	else
		if is_set(Periodical) and
			not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
			Page = &quot;: &quot; .. Page;
		else
			Page = sepc ..&quot; &quot; .. PPrefix .. Page;
		end
	end

	if 'map' == config.CitationClass then										-- cite map oddity done after COinS call (and with other in-source locators)
		if is_set (Sheet) or is_set (Sheets) then
			local err_msg1 = 'sheet=, &amp;#124;sheets';							-- default error message in case any of page pages or at are set
			local err_msg2;
			if is_set (Page) or is_set (Pages) or is_set (At) then				-- are any set?
				err_msg2 = 'page=, &amp;#124;pages=, &amp;#124;at';						-- a generic error message
				Page = ''; Pages = ''; At = '';
			elseif is_set (Sheet) and is_set (Sheets) then						-- if both are set make error message
				err_msg1 = 'sheet';
				err_msg2 = 'sheets';
			end
			if is_set (err_msg2) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', err_msg1) .. ' and ' .. wrap_style ('parameter', err_msg2)}, true ) } );		-- add error message
			end
			if not is_set (Sheet) then											-- do sheet static text and formatting; Sheet has priority over Sheets if both provided
				if is_set (Sheets) then
					if is_set (Periodical) then
						Sheet = &quot;: Sheets &quot; .. Sheets;							-- because Sheet has priority, no need to support both later on
					else
						Sheet = sepc .. &quot; Sheets &quot; .. Sheets;
					end
				end
			else
				if is_set (Periodical) then
					Sheet = &quot;: Sheet &quot; .. Sheet;
				else
					Sheet = sepc .. &quot; Sheet &quot; .. Sheet;
				end
			end
		end
	end

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
		Others = sepc .. ' Translated by ' .. Translators .. Others; 
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end
	Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc ..&quot; &quot; .. Volume;
		  else Volume = &quot; &lt;b&gt;&quot; .. hyphen_to_dash(Volume) .. &quot;&lt;/b&gt;&quot;;
		end
	end

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

--[[
Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
note is displayed. There are no error messages for this condition.

]]
	if is_set (SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif is_set (RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if 'citation', lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text
																				-- neither of these work; don't know why; it seems that substitute() isn't being called	
		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
			Quote = Quote:sub(2,-2);
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- CS1 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- DeadURL is empty, 'yes', 'true', 'y', 'unfit', 'usurped'
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
--			if 'usurped' == DeadURL then										-- when original has unsuitable content do not link
			if in_array (DeadURL, {'unfit', 'usurped'}) then
				Archived = sepc .. &quot; &quot; .. 'Archived from the original on ' .. ArchiveDate;	-- format already styled
			else																-- DeadURL is empty, 'yes', 'true', or 'y'
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'] ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'] ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower() ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin );
	end

	local Publisher;
	if is_set(Periodical) and
		not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap_msg ('published', PublicationDate);
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap_msg ('published', PublicationDate) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
			Language, Edition, Publisher, Agency, Volume, Issue}, sepc );
		
	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume, Issue}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Transcript, Language, Edition, Publisher}, sepc );
	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Issue, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Sheet .. Page .. Pages .. At;
	
	if is_set(Authors) then
		if is_set(Coauthors) then
			local sep = '; ';
			if 'vanc' == NameListFormat then
				sep = ', ';
			end
			Authors = Authors .. sep .. Coauthors;
		end
		if is_set(Date) then
			Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		elseif string.sub(Authors,-1,-1) == sepc then
			Authors = Authors .. &quot; &quot;
		else
			Authors = Authors .. sepc .. &quot; &quot;
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			if (sepc ~= '.') then in_text = in_text:lower() end
			Editors = in_text .. Editors .. post_text;
			if (string.sub(Editors,-1,-1) == sepc) or (string.sub(Editors,-3,-1) == sepc .. ']]') then	-- if last editor name ends with sepc char
				Editors = Editors .. &quot; &quot;;										-- don't add another
			else
				Editors = Editors .. sepc .. &quot; &quot;								-- otherwise terninate the editor list
			end
		end
		text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
		text = safe_join( {text, pgtext, idcommon}, sepc );
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon}, sepc );
		text = safe_join( {text, pgtext, idcommon}, sepc );
	else
		if is_set(Date) then
			if ( string.sub(tcommon,-1,-1) ~= sepc )
			  then Date = sepc ..&quot; &quot; .. Date .. OrigYear
			  else Date = &quot; &quot; .. Date .. OrigYear
			end
		end
		if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon}, sepc );
			text = safe_join( {text, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date}, sepc );
			text = safe_join( {text, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = config.CitationClass;
		options.class = &quot;citation &quot; .. config.CitationClass;					-- class=citation required for blue highlight when used with |ref=
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
		local id = Ref
		if ( &quot;harv&quot; == Ref ) then
			local names = {} --table of last names &amp; year
			if #a &gt; 0 then
				for i,v in ipairs(a) do 
					names[i] = v.last 
					if i == 4 then break end
				end
			elseif #e &gt; 0 then
				for i,v in ipairs(e) do 
					names[i] = v.last 
					if i == 4 then break end				
				end
			end
			names[ #names + 1 ] = first_set(Year, anchor_year);	-- Year first for legacy citations and for YMD dates that require disambiguation
			id = anchor_id(names)
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then 
		text = '&lt;cite id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/cite&gt;&quot;;
	else
		text = '&lt;cite class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/cite&gt;&quot;;
	end		

	local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
	
	-- Note: Using display: none on then COinS span breaks some clients.
	local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
	text = text .. OCinS;
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. error_comment( v[1], v[2] );
				else
					text = text .. error_comment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end

	if #z.maintenance_cats ~= 0 then
		text = text .. '&lt;span class=&quot;citation-comment&quot; style=&quot;display:none; color:#33aa33&quot;&gt;';
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. ' ' .. v .. ' ([[:Category:' .. v ..'|link]])';
		end
		text = text .. '&lt;/span&gt;';	-- maintenance mesages (realy just the names of the categories for now)
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
	local pframe = frame:getParent()
	local validation;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of Configuration and Whitelist and ...
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');	-- ... sandbox version of date validation code

	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of Configuration and Whitelist and ...
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		validation = require ('Module:Citation/CS1/Date_validation');			-- ... live version of date validation code
	end

	dates = validation.dates;													-- imported functions
	year_date_check = validation.year_date_check;

	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute( param, capture );				-- add the capture to the suggested parameter (typically the enumerator)
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, param}, true );	-- set the error message
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
						end
					end
--					if #suggestions == 0 then
--						suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
--					end
--					if suggestions[ k:lower() ] ~= nil then
--						error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
--					else
--						error_text, error_state = set_error( 'parameter_ignored', {k}, true );
--					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	
	
	return citation0( config, args)
end

return z</text>
      <sha1>2inpqucvt56tuiwvq2cfg4slk4o10fu</sha1>
    </revision>
    <revision>
      <id>4697</id>
      <parentid>4696</parentid>
      <timestamp>2015-09-26T19:44:34Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>bug fix in page number rendering (NoPP);</comment>
      <origin>4697</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="156964" sha1="pj9y5nd4q0ny056hx525cqymzi9by46" xml:space="preserve">
local z = {
	error_categories = {};		-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};		-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};		-- for categorizing citations based on certain properties, language of source for instance
}

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]
local dates, year_date_check	-- functions in Module:Citation/CS1/Date_validation

local cfg = {};					-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};			-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist

--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.
This function is global because it is called from both this module and from Date validation

]]
function is_set( var )
	return not (var == nil or var == '');
end

--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

First set variable or nil if none

]]

local function first_set(...)
	local list = {...};
	for _, var in pairs(list) do
		if is_set( var ) then
			return var;
		end
	end
end

--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end

--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]
local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end

--[[--------------------------&lt; S E T _ E R R O R &gt;--------------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

]]
local function set_error( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if in_array( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return error_comment( message, error_state.hidden );
end

--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maintenance_cats using names from the configuration file with additional text if any.
To prevent duplication, the added_maint_cats table lists the categories by key that have been added to z.maintenance_cats.

]]

local added_maint_cats = {}														-- list of maintenance categories that have been added to z.maintenance_cats
local function add_maint_cat (key, arguments)
	if not added_maint_cats [key] then
		added_maint_cats [key] = true;											-- note that we've added this category
		table.insert( z.maintenance_cats, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
	end
end

--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

]]

local added_prop_cats = {}														-- list of property categories that have been added to z.properties_cats
local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));		-- make name then add to table
	end
end

--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

]]

local added_vanc_errs;															-- flag so we only emit one Vancouver error / category
local function add_vanc_error ()
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {}, true ) } );
	end
end

--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string is valid.

At present the only check is whether the string appears to be prefixed with a URI scheme.  It is not determined whether 
the URI scheme is valid or whether the URL is otherwise well formed.

The scheme is checked http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

First we test for space characters.  If any are found, return false.  Then test for the case where the url is
protocol relative (//example.com).  If the first two characters of the |url= value are //, return true.  Last
look for what appears to be a scheme according to the definition above.  If the characters preceding the colon
are in the allowed set, return true, else false
]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value
		return false;
	end
	return url_str:sub(1,2) == &quot;//&quot; or nil ~= url_str:match (&quot;^%a[%a%d%+%.%-]*:&quot;)		-- protocol relative or scheme part composed of legitimate characters
end

--[[--------------------------&lt; S A F E _ F O R _ I T A L I C S &gt;----------------------------------------------

Protects a string that will be wrapped in wiki italic markup '' ... ''

Note: We cannot use &lt;i&gt; for italics, as the expected behavior for italics specified by ''...'' in the title is that
they will be inverted (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and '' tend to interact
poorly under Mediawiki's HTML tidy.

]]

local function safe_for_italics( str )
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end

--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

local function wrap_style (key, str)
	if not is_set( str ) then
		return &quot;&quot;;
	elseif in_array( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safe_for_italics( str );
	end

	return substitute( cfg.presentation[key], {str} );
end

--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source )
	local error_str = &quot;&quot;;
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {}, false, &quot; &quot; ) .. error_str;
	end
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url( label ), &quot;]&quot;, error_str });
end

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

]]

local page_in_deprecated_cat;													-- sticky flag so that the category is added only once
local function deprecated_parameter(name)
	if not page_in_deprecated_cat then
		page_in_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end

--[[--------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Call this function for chapter titles, for website titles, etc; not for book titles.

]]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	
	cap, cap2 = str:match (&quot;^([\&quot;\'])([^\'].+)&quot;);								-- match leading double or single quote but not double single quotes
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-left'], {cap, cap2});
	end

	cap, cap2 = str:match (&quot;^(.+[^\'])([\&quot;\'])$&quot;)
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-right'], {cap, cap2});
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title= and |script-chapter=

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, {'ar', 'bg', 'bs', 'dv', 'el', 'fa', 'he', 'hy', 'ja', 'ka', 'ko', 'ku', 'mk', 'ps', 'ru', 'sd', 'sr', 'th', 'uk', 'ug', 'yi', 'zh'}) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				add_prop_cat ('script')
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		str = substitute( msg, {str} );											-- including template text
		return str;
	else
		return substitute( cfg.messages[key], {str} );
	end		
end

--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider
Generates an error if more than one match is present.

]]

local function select_one( args, possible, error_condition, index )
	local value = nil;
	local selected = '';
	local error_list = {};
	
	if index ~= nil then index = tostring(index); end
	
	-- Handle special case of &quot;#&quot; replaced by empty string
	if index == '1' then
		for _, v in ipairs( possible ) do
			v = v:gsub( &quot;#&quot;, &quot;&quot; );
			if is_set(args[v]) then
				if value ~= nil and selected ~= v then
					table.insert( error_list, v );
				else
					value = args[v];
					selected = v;
				end
			end
		end		
	end
	
	for _, v in ipairs( possible ) do
		if index ~= nil then
			v = v:gsub( &quot;#&quot;, index );
		end
		if is_set(args[v]) then
			if value ~= nil and selected ~=  v then
				table.insert( error_list, v );
			else
				value = args[v];
				selected = v;
			end
		end
	end
	
	if #error_list &gt; 0 then
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap_style ('parameter', k);
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap_style ('parameter', selected);
		table.insert( z.message_tail, { set_error( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end

--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (scriptchapter, chapter, transchapter, chapterurl, chapter_url_source)
	local chapter_error = '';
	
	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		chapter = kern_quotes (chapter);										-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
		chapter = wrap_style ('quoted-title', chapter);
	end

	chapter = script_concatenate (chapter, scriptchapter)						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (transchapter) then
		transchapter = wrap_style ('trans-quoted-title', transchapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. transchapter;
		else																	-- here when transchapter without chapter or script-chapter
			chapter = transchapter;												-- 
			chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
		end
	end

	if is_set (chapterurl) then
		chapter = external_link (chapterurl, chapter, chapter_url_source);		-- adds bare_url_missing_title error if appropriate
	end

	return chapter .. chapter_error;
end


--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
]]

local function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end


-- Formats a wiki style internal link
local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s*%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s*%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end

--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in check_isbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end

--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end

--[[--------------------------&lt; C H E C K _ I S M N &gt;------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the issn is invalid
	end 
	
	return text;
end

--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end

--[[
lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--[[
Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of the LCCN dictates the character type of the first 1-3 characters; the
rightmost eight are always digits. http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end

--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.

-- DOI names contain two parts: prefix and suffix separated by a forward slash.
--  Prefix: directory indicator '10.' followed by a registrant code
--  Suffix: character string of any length chosen by the registrant

-- This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes,
-- or, if it ends with a period or a comma, this function will emit a bad_doi error message.

-- DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
-- and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely if ever used in doi names.

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end

-- Formats an OpenLibrary link, and checks for associated errors.
local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);					-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end

--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end

--[[--------------------------&lt; C L E A N _ I S B N &gt;----------------------------------------------------------

Removes irrelevant text and dashes from ISBN number
Similar to that used for Special:BookSources

]]

local function clean_isbn( isbn_str )
	return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]
local function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other lua magic pattern characters
	return argument;
end

--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	while true do
		if argument:match (&quot;%'%'%'%'%'&quot;) then									-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:match (&quot;%'%'%'%'&quot;) then									-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:match (&quot;%'%'%'&quot;) then									-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:match (&quot;%'%'&quot;) then										-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end

--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...
]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end

--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
local function remove_wiki_link( str )
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end

-- Converts a hyphen to a dash
local function hyphen_to_dash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end

--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if comp:sub(1,1) == duplicate_char then								-- is first charactier same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for th
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = str:sub(-1,-1);										-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = str:sub(1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = str:sub(1, -4) .. &quot;''&quot;;							-- remove them and add back ''
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then		-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then		-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then			-- if last two chars of str are sepc] external link
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;'']&quot; then		-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then				-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = str:sub(1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end		-- if duplicate_char not a letter then escape it
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )			-- remove duplicate_char if it follows html markup
					else
						value = value:sub( 2, -1 );								-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end  

--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

At the time of this writing, I had to write the 'if nil == mw.ustring.find ...' test ouside of the code editor and paste it here
because the code editor gets confused between character insertion point and cursor position.

]]

local function is_good_vanc_name (last, first)
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]*$&quot;) then
		add_vanc_error ();
		return false;															-- not a string of latin characters; Vancouver required Romanization
	end;
	return true;
end

--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  This form is not
currently supported by this code so correctly formed names like Smith JL 2nd are converted to Smith J2. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	if mw.ustring.match(first, &quot;^%u%u$&quot;) then return first end;					-- when first contains just two upper-case letters, nothing to do
	local initials = {}
	local i = 0;																-- counter for number of initials
	for word in mw.ustring.gmatch(first, &quot;[^%s%.%-]+&quot;) do						-- names separated by spaces, hyphens, or periods
		table.insert(initials, mw.ustring.sub(word,1,1))						-- Vancouver format does not include full stops.
		i = i + 1;																-- bump the counter 
		if 2 &lt;= i then break; end												-- only two initials allowed in Vancouver system; if 2, quit
	end
	return table.concat(initials)												-- Vancouver format does not include spaces.
end

--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = ',';																-- name-list separator between authors is a comma
		namesep = ' ';															-- last/first separator is a space
	else
		sep = ';'																-- name-list separator between authors is a semicolon
		namesep = ', '															-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then					-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first 
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;				-- link author/editor if this page is not the author's/editor's page
				end

				if is_set(person.link) and ((nil ~= person.link:find(&quot;//&quot;)) or (nil ~= person.link:find(&quot;[%[%]]&quot;))) then
					one = one .. &quot; &quot; .. set_error( 'bad_authorlink' ) end		-- url or wikilink in author link;
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];						-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end

--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

]]

local function anchor_id( options )
	local id = table.concat( options );											-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end

--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of author and editor name parameters for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the parameters |display-authors=etal or |display-editors=etal

]]

local function name_has_etal (name, etal, nocat)

	if is_set (name) then														-- name can be nil in which case just return
		local etal_pattern = &quot;[;,]? *[\&quot;']*%f[Ee][Ee][Tt] *[Aa][Ll][%.\&quot;']*$&quot;	-- variations on the 'et al' theme
		local others_pattern = &quot;[;,]? *%f[%a]and [Oo]thers&quot;;					-- and alternate to et al.
		
		if name:match (etal_pattern) then										-- variants on et al.
			name = name:gsub (etal_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		elseif name:match (others_pattern) then									-- if not 'et al.', then 'and others'?
			name = name:gsub (others_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		end
	end
	return name, etal;															-- 
end

--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary
	while true do
		last = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false);								-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false);								-- find and remove variations on et al.

		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end

-- Populates ID table from arguments using configuration settings
local function extract_ids( args )
	local id_list = {};
	for k, v in pairs( cfg.id_handlers ) do	
		v = select_one( args, v.parameters, 'redundant_parameters' );
		if is_set(v) then id_list[k] = v; end
	end
	return id_list;
end

--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs and turns it into a table of formatted ID outputs.

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end
  

--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end
	
	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'citation', 'conference', 'interview', 'press release'}) and is_set(data.Periodical) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
		OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
		OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	elseif in_array (class, {'arxiv', 'journal', 'news'}) then
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;
		if 'arxiv' == class then
			OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;								-- cite arxiv
		else
			OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;
		end
		OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;
		OCinSoutput[&quot;rft.atitle&quot;] = data.Title;
	else
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;
		if is_set (data.Chapter) then
			OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
			OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;
		else
			OCinSoutput[&quot;rft.genre&quot;] = &quot;book&quot;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;
	end

	OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;
	OCinSoutput[&quot;rft.date&quot;] = data.Date;
	OCinSoutput[&quot;rft.series&quot;] = data.Series;
	OCinSoutput[&quot;rft.volume&quot;] = data.Volume;
	OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
	OCinSoutput[&quot;rft.pages&quot;] = data.Pages;
	OCinSoutput[&quot;rft.edition&quot;] = data.Edition;
	OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;
	
	for k, v in pairs( data.ID_list ) do
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
	
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = v.last, v.first;
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;
				OCinSoutput[&quot;rft.aufirst&quot;] = first;
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 code.  Handles the special case that is Norwegian where
ISO639-1 code 'no' is mapped to language name 'Norwegian Bokmål' by Extention:CLDR.

Returns the language name and associated ISO639-1 code.  Because case of the source may be incorrect or different from the case that Wikimedia
uses, the name comparisons are done in lower case and when a match is found, the Wikimedia version (assumed to be correct) is returned along
with the code.  When there is no match, we return the original language name string.

mw.language.fetchLanguageNames() will return a list of languages that aren't part of ISO639-1. Names that aren't ISO639-1 but that are included
in the list will be found if that name is provided in the |language= parameter.  For example, if |language=Samaritan Aramaic, that name will be
found with the associated code 'sam', not an ISO639-1 code.  When names are found and the associated code is not two characters, this function
returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang)
	if 'norwegian' == lang:lower() then											-- special case related to Wikimedia remap of code 'no' at Extension:CLDR
		return 'Norwegian', 'no';												-- Make sure rendered version is properly capitalized
	end
	
	local languages = mw.language.fetchLanguageNames('en', 'all')				-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() then												-- ISO639-1 codes only
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the ISO639-1 code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for ISO639-1 code
end

--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Get language name from ISO639-1 code value provided.  If a code is valid use the returned name; if not, then use the value that was provided with the language parameter.

There is an exception.  There are three ISO639-1 codes for Norewegian language variants.  There are two official variants: Norwegian Bokmål (code 'nb') and
Norwegian Nynorsk (code 'nn').  The third, code 'no',  is defined by ISO639-1 as 'Norwegian' though in Norway this is pretty much meaningless.  However, it appears
that on enwiki, editors are for the most part unaware of the nb and nn variants (compare page counts for these variants at Category:Articles with non-English-language external links.

Because Norwegian Bokmål is the most common language variant, Media wiki has been modified to return Norwegian Bokmål for ISO639-1 code 'no'. Here we undo that and
return 'Norwegian' when editors use |language=no.  We presume that editors don't know about the variants or can't descriminate between them.

See Help talk:Citation Style_1#An ISO 639-1 language name test

When |language= contains a valid ISO639-1 code, the page is assigned to the category for that code: Category:Norwegian-language sources (no) if
the page is a mainspace page and the ISO639-1 code is not 'en'.  Similarly, if the  parameter is |language=Norwegian, it will be categorized in the same way.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the ISO639-1 two character code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang

		if 2 == lang:len() then													-- ISO639-1 language code are 2 characters (fetchLanguageName also supports 3 character codes)
			name = mw.language.fetchLanguageName( lang:lower(), &quot;en&quot; );			-- get ISO 639-1 language name if Language is a proper code
		end
	
		if is_set (name) then													-- if Language specified a valid ISO639-1 code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang);								-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then
			if 'no' == code then name = 'Norwegian' end;						-- override wikimedia when code is 'no'
			if 'en' ~= code then												-- English not the language
				add_prop_cat ('foreign_lang_source', {name, code})
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, ' and ')							-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		language_list[code] = 'and ' .. language_list[code];					-- prepend last name with 'and&lt;space&gt;'
		name = table.concat (language_list, ', ')								-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
	end
	if 'English' == name then
		return '';																-- if one language and that language is English return an enpty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
end

--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = '.';																-- terminate the rendered citation with a period
	end
	return '.', ps;																-- separator is a full stop
end

--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = '';																-- make sure it isn't nil
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return ',', ps, ref;														-- separator is a comma
end

--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end

--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extension, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf[%?#]?') or url:match ('%.PDF[%?#]?');
end

--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parenthases, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end

--[[--------------------------&lt; G E T _ D I S P L A Y _ A U T H O R S _ E D I T O R S &gt;------------------------

Returns a number that may or may not limit the length of the author or editor name lists.

When the value assigned to |display-authors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-authors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

]]

local function get_display_authors_editors (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count and 'authors' == list_name then	-- AUTHORS ONLY		-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_auth_ed', list_name);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset
		end
	elseif 'authors' == list_name then		-- AUTHORS ONLY	need to clear implicit et al category
		max = count + 1;														-- number of authors + 1
	end
	
	return max, etal;
end

--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page, nopp)
--	local good_pattern = '^P[^%.P%l]';
	local good_pattern = '^P[^%.Pp]';										-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
--	local bad_pattern = '^[Pp][Pp]';
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if is_set (nopp) then													-- don't bother checking if |nopp= is set
		return;
	end

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
--		if Page:match ('^[Pp]?[Pp]%.?[ %d]') or  Page:match ('^[Pp]ages?[ %d]') or
--			Pages:match ('^[Pp]?[Pp]%.?[ %d]') or  Pages:match ('^[Pp]ages?[ %d]') then
--				add_maint_cat ('extra_text');
--		end
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	if vparam:find ('%[%[') or vparam:find ('%]%]')	then						-- no wikilinking vauthors names
		add_vanc_error ();
	end
	v_name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;)								-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parenthese to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')
			corporate = true;
		elseif string.find(v_name, &quot;%s&quot;) then
		    lastfirstTable = {}
		    lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
		    first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
		    last  = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
		    if mw.ustring.match (last, '%a+%s+%u+%s+%a+') or mw.ustring.match (v_name, ' %u %u$') then
				add_vanc_error ();												-- matches last II last; the case when a comma is missing or a space between two intiials
			end
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) and not mw.ustring.match (first, &quot;^%u?%u$&quot;) then		-- first shall contain one or two upper-case letters, nothing else
			add_vanc_error ();
		end
																				-- this from extract_names ()
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', 1 ) or		-- do this twice incase we have a first 1 without a last1
		select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, no, etc).  When the parameter value has not been assigned a value (missing or empty
in the source template) the function refurns true.  If the parameter value is one of the list of allowed values returns
true; else, emits an error message and returns false.

]]

local function is_valid_parameter_value (value, name, possible)
	if not is_set (value) then
		return true;															-- an empty parameter is ok
	elseif in_array(value:lower(), possible) then
		return true;
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
end


--[[--------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
characters following the opening bracket obey the rules of a uri scheme (see check_url()).  The test will also find
external wikilinks that use protocol relative urls.

]]

local function is_parameter_ext_wikilink (value)
	if value:match (&quot;%[%[%a+:&quot;) then											-- if a wikilink with namespace (interwiki)
		return false;
	elseif value:match (&quot;%[%a[%a%d%+%.%-]*:.*%]&quot;) or value:match (&quot;%[//.*%]&quot;) then		-- does the param value contain an external wikilink?
--	elseif value:match (&quot;%[%a[%a%d%+%.%-]*:%S.*%]&quot;) or value:match (&quot;%[//.*%]&quot;) then	-- does the param value contain an external wikilink?
		return true;
	else
		return false;
	end
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then														-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );

	local i 
	local PPrefix = A['PPrefix']
	local PPPrefix = A['PPPrefix']
	local NoPP = A['NoPP'] 
	if is_set (NoPP) and is_valid_parameter_value (NoPP, 'nopp', cfg.keywords ['yes_true_y']) then
		PPPrefix = '';															-- unset these, prefix if used is in |page= or |pages=
		PPrefix = '';
	else
		NoPP = nil;																-- unset, used as a flag later
	end
		
	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
		end
	end

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
		end
	end

	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled trnaslators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	
	if not is_valid_parameter_value (NameListFormat, 'name-list-format', cfg.keywords['name-list-format']) then			-- only accepted value for this parameter is 'vanc'
		NameListFormat = '';													-- anything else, set to empty string
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
	local Chapter = A['Chapter'];
	local ScriptChapter = A['ScriptChapter'];
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];
	local ArchiveURL = A['ArchiveURL'];
	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];

	local Series = A['Series'];
	local Volume = A['Volume'];
	local Issue = A['Issue'];
	local Position = '';
	local Page = A['Page'];
	local Pages = hyphen_to_dash( A['Pages'] );	
	local At = A['At'];

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
		if not is_valid_parameter_value (RegistrationRequired, 'registration', cfg.keywords ['yes_true_y']) then
			RegistrationRequired=nil;
		end
	local SubscriptionRequired = A['SubscriptionRequired'];
		if not is_valid_parameter_value (SubscriptionRequired, 'subscription', cfg.keywords ['yes_true_y']) then
			SubscriptionRequired=nil;
		end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local ArchiveDate = A['ArchiveDate'];
	local Agency = A['Agency'];
	local DeadURL = A['DeadURL']
		if not is_valid_parameter_value (DeadURL, 'dead-url', cfg.keywords ['deadurl']) then	-- set in config.defaults to 'yes'
			DeadURL = '';														-- anything else, set to empty string
		end

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
		if not is_valid_parameter_value (IgnoreISBN, 'ignore-isbn-error', cfg.keywords ['yes_true_y']) then
			IgnoreISBN = nil;													-- anything else, set to empty string
		end
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
		if not is_valid_parameter_value (LastAuthorAmp, 'last-author-amp', cfg.keywords ['yes_true_y']) then
			LastAuthorAmp = nil;													-- set to empty string
		end
	local no_tracking_cats = A['NoTracking'];
		if not is_valid_parameter_value (no_tracking_cats, 'no-tracking', cfg.keywords ['yes_true_y']) then
			no_tracking_cats = nil;													-- set to empty string
		end

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local use_lowercase;								-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();		-- also used for COinS and for language
	local anchor_year;									-- used in the CITEREF identifier
	local COinS_date;									-- used in the COinS metadata

-- set default parameter values defined by |mode= parameter.  If |mode= is empty or omitted, use CitationClass to set these values
	local Mode = A['Mode'];
	if not is_valid_parameter_value (Mode, 'mode', cfg.keywords['mode']) then
		Mode = '';
	end
	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

-- check for extra |page=, |pages= or |at= parameters. 
	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Page = Page .. &quot; &quot; .. set_error('extra_pages');						-- add error message
			Pages = '';															-- unset the others
			At = '';
		end
		extra_text_in_page_check (Page, NoPP);									-- add this page to maint cat if |page= value begins with what looks like p. or pp.
	elseif is_set(Pages) then
		if is_set(At) then
			Pages = Pages .. &quot; &quot; .. set_error('extra_pages');					-- add error messages
			At = '';															-- unset
		end
		extra_text_in_page_check (Pages, NoPP);									-- add this page to maint cat if |page= value begins with what looks like p. or pp.
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped
	|url maps to |chapterurl when |title is remapped

All other combinations of |encyclopedia, |title, and |article are not modified

]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					TransChapter = TransTitle;
					ChapterURL = URL;
					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter= '[[' .. TitleLink .. '|' .. Chapter .. ']]';
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			else																-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then	-- special case for cite techreport
		if is_set(Issue) then						-- cite techreport uses 'number', which other citations aliase to 'issue'
			if not is_set(ID) then					-- can we use ID for the &quot;number&quot;?
				ID = Issue;							-- yes, use it
				Issue = &quot;&quot;;							-- unset Issue so that &quot;number&quot; isn't duplicated in the rendered citation or COinS metadata
			else									-- can't use ID so emit error message
				ID = ID .. &quot; &quot; .. set_error('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Others) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Others;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Others;
			end
		else
			Others = '(Interview)';
		end
	end

-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];
		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};

																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) then												-- promote airdate or Began/Ended to date
			if is_set (AirDate) then
				Date = AirDate;
			end
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('series', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = '[[' .. ChapterLink .. '|' .. Chapter .. ']]';		-- ok to wikilink
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = '[[' .. ChapterLink .. '|' .. Series .. ']]';			-- series links with ChapterLink (episodelink -&gt; TitleLink -&gt; ChapterLink) ugly
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = '[[' .. SeriesLink .. '|' .. Series .. ']]';
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
-- end of {{cite episode}} stuff

-- Account for the oddities that are {{cite arxiv}}, before generation of COinS data.
	if 'arxiv' == config.CitationClass then
		if not is_set (ID_list['ARXIV']) then									-- |arxiv= or |eprint= required for cite arxiv
			table.insert( z.message_tail, { set_error( 'arxiv_missing', {}, true ) } );		-- add error message
		elseif is_set (Series) then												-- series is an alias of version
			ID_list['ARXIV'] = ID_list['ARXIV'] .. Series;						-- concatenate version onto the end of the arxiv identifier
			Series = '';														-- unset
			deprecated_parameter ('version');									-- deprecated parameter but only for cite arxiv
		end
		
		if first_set (AccessDate, At, Chapter, Format, Page, Pages, Periodical, PublisherName, URL,	-- a crude list of parameters that are not supported by cite arxiv
			ID_list['ASIN'], ID_list['BIBCODE'], ID_list['DOI'], ID_list['ISBN'], ID_list['ISSN'],
			ID_list['JFM'], ID_list['JSTOR'], ID_list['LCCN'], ID_list['MR'], ID_list['OCLC'], ID_list['OL'],
			ID_list['OSTI'], ID_list['PMC'], ID_list['PMID'], ID_list['RFC'], ID_list['SSRN'], ID_list['USENETID'], ID_list['ZBL']) then
				table.insert( z.message_tail, { set_error( 'arxiv_params_not_supported', {}, true ) } );		-- add error message

				AccessDate= '';													-- set these to empty string; not supported in cite arXiv
				PublisherName = '';												-- (if the article has been published, use cite journal, or other)
				Chapter = '';
				URL = '';
				Format = '';
				Page = ''; Pages = ''; At = '';
		end
		Periodical = 'arXiv';													-- set to arXiv for COinS; after that, must be set to empty string
	end

-- handle type parameter for those CS1 citations that have default values

	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
		TitleType = &quot; (&quot; .. TitleType .. &quot;)&quot;;									-- display it in parentheses
	end

-- legacy: promote concatenation of |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end	-- if PublicationDate is same as Date, don't display in rendered citation

--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	do	-- create defined block to contain local variables error_message and mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		anchor_year, COinS_date, error_message = dates({['access-date']=AccessDate, ['archive-date']=ArchiveDate, ['date']=Date, ['doi-broken-date']=DoiBroken,
			['embargo']=Embargo, ['lay-date']=LayDate, ['publication-date']=PublicationDate, ['year']=Year});

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end

		if is_set(error_message) then
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end
	end	-- end of do

-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);											-- 

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
			if 'episode' == config.CitationClass then							-- special case for cite episode; is there a better way to do this?
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
			else
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
			end
	end
	
	if 'none' == Title and is_set(Periodical) and not (( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia))) then								-- special case
		Title = '';																-- set title to empty string
		add_maint_cat ('untitled');
	end

	check_for_url ({['title']=Title, ['chapter']=Chapter, ['work']=Periodical});	-- adds error message when any of these parameters contain a URL

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	
	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = Periodical,
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = first_set(COinS_date, Date),		-- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here?  Should we be including invalid dates in metadata?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set(Sheet, Sheets, Page, Pages, At)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set( URL, ChapterURL ),
		['Authors'] = a,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

-- Account for the oddities that are {{cite arxiv}}, AFTER generation of COinS data.
	if 'arxiv' == config.CitationClass then										-- we have set rft.jtitle in COinS to arXiv, now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in cite arxiv; if article has been published, use cite journal
	end

-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = '[[Usenet newsgroup|Newsgroup]]:&amp;nbsp;' ..  external_link( 'news:' .. PublisherName, PublisherName );
		end
	end



	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local maximum;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text											-- get current page name so that we don't wikilink to it via editorlinkn
		};

		do																		-- do editor name list first because coauthors can modify control table
			maximum , editor_etal = get_display_authors_editors (A['DisplayEditors'], #e, 'editors', editor_etal);
			-- Preserve old-style implicit et al.
			if not is_set(maximum) and #e == 4 then 
				maximum = 3;
				table.insert( z.message_tail, { set_error('implict_etal_editor', {}, true) } );
			end

			control.maximum = maximum;
			
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if is_set (Editors) then
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];				-- add et al. to editors parameter beause |display-editors=etal
					EditorCount = 2;												-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
				else
					EditorCount = 2;												-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
				end
			else
				Editors = last_first_list;											-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then			-- only one editor displayed but includes etal then 
				EditorCount = 2;													-- spoof to display (eds.) annotation
			end
		end
		do																			-- now do translators
			control.maximum = #t;													-- number of translators
			Translators = list_people(control, t, false);							-- et al not currently supported
		end
		do																			-- now do authors
			control.maximum , author_etal = get_display_authors_editors (A['DisplayAuthors'], #a, 'authors', author_etal);

			if is_set(Coauthors) then												-- if the coauthor field is also used, prevent ampersand and et al. formatting.
				control.lastauthoramp = nil;
				control.maximum = #a + 1;
			end
			
			last_first_list = list_people(control, a, author_etal);

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false);	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];				-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;											-- either an author name list or an empty string
			end

		end																			-- end of do

		if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
			table.insert( z.message_tail, { set_error('coauthors_missing_author', {}, true) } );	-- emit error message
		end
	end



--[[
	do																			-- do-block to limit scope of last_first_list
		local last_first_list;
		local maximum = A['DisplayAuthors'];

		maximum , author_etal = get_display_authors_editors (maximum, #a, 'authors', author_etal);

		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text											-- get current page name so that we don't wikilink to it via authorlinkn
			};
		
		if is_set(Coauthors) then												-- if the coauthor field is also used, prevent ampersand and et al. formatting.
			control.lastauthoramp = nil;
			control.maximum = #a + 1;
		end
		
		last_first_list = list_people(control, a, author_etal);

		if is_set (Authors) then
			Authors, author_etal = name_has_etal (Authors, author_etal, false);	-- find and remove variations on et al.
			if author_etal then
				Authors = Authors .. ' ' .. cfg.messages['et al'];				-- add et al. to authors parameter
			end
		else
			Authors = last_first_list;											-- either an author name list or an empty string
		end

	end																			-- end of do

	if not is_set(Authors) and is_set(Coauthors) then	-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
		table.insert( z.message_tail, { set_error('coauthors_missing_author', {}, true) } );	-- emit error message
	end

	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local maximum = A['DisplayEditors'];

		maximum , editor_etal = get_display_authors_editors (maximum, #e, 'editors', editor_etal);
		-- Preserve old-style implicit et al.
		if not is_set(maximum) and #e == 4 then 
			maximum = 3;
			table.insert( z.message_tail, { set_error('implict_etal_editor', {}, true) } );
		end

		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = maximum,
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text											-- get current page name so that we don't wikilink to it via editorlinkn
		};

		last_first_list, EditorCount = list_people(control, e, editor_etal);

		if is_set (Editors) then
			if editor_etal then
				Editors = Editors .. ' ' .. cfg.messages['et al'];				-- add et al. to editors parameter beause |display-editors=etal
				EditorCount = 2;												-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
			else
				EditorCount = 2;												-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
			end
		else
			Editors = last_first_list;											-- either an author name list or an empty string
		end

		if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then			-- only one editor displayed but includes etal then 
			EditorCount = 2;													-- spoof to display (eds.) annotation
		end
	end
]]

-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

	if  not is_set(URL) then --and
--		not is_set(ArchiveURL) then --and										-- prevents format_missing_url error from registering
--		not is_set(ConferenceURL) and											-- TODO: keep this here? conference as part of cite web or cite podcast?
--		not is_set(TranscriptURL) then											-- TODO: remove? |transcript-url= and |transcript= has separate test
		
		-- Test if cite web or cite podcast |url= is missing or empty 
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then	
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- Test if accessdate is given without giving a URL
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when the others are not set; TODO: move this to a separate test?
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalFormat;											-- TODO: swap chapter and title here so that archive applies to most specific if both are set?
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalFormat = Format;											-- and original |format=
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
			end
		elseif is_set (ChapterURL) then 										-- URL not set so if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalFormat = ChapterFormat;										-- and original |format=
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
			end
		end
	end

	if in_array(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;journal&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;, &quot;newsgroup&quot;, 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			if is_set (Chapter) or is_set (TransChapter) or is_set (ChapterURL) or is_set (ScriptChapter) then	-- chapter parameters not supported for these citation types
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {A:ORIGIN ('Chapter')}, true ) } );		-- add error message
				Chapter = '';													-- set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
			end
	else																		-- otherwise, format chapter / article title
		Chapter = format_chapter_title (ScriptChapter, Chapter, TransChapter, ChapterURL, ChapterURLorigin);
		if is_set (Chapter) then
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;
			end
			Chapter = Chapter .. ChapterFormat .. sepc .. ' ';
		end
	end

	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if in_array(config.CitationClass, {&quot;web&quot;,&quot;news&quot;,&quot;journal&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;, &quot;newsgroup&quot;, &quot;mailinglist&quot;, 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
	
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then 
			Title = external_link( URL, Title ) .. TransError .. Format;
			URL = &quot;&quot;;
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		if is_set(Minutes) then
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			local Time = A['Time'];
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end
	
	if not is_set(Page) then
		if is_set(Pages) then
			if is_set(Periodical) and
				not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
				Pages = &quot;: &quot; .. Pages;
			elseif tonumber(Pages) ~= nil then
				Pages = sepc ..&quot; &quot; .. PPrefix .. Pages;
			else
				Pages = sepc ..&quot; &quot; .. PPPrefix .. Pages;
			end
		end
	else
		if is_set(Periodical) and
			not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;book&quot;,&quot;news&quot;,&quot;podcast&quot;}) then
			Page = &quot;: &quot; .. Page;
		else
			Page = sepc ..&quot; &quot; .. PPrefix .. Page;
		end
	end

	if 'map' == config.CitationClass then										-- cite map oddity done after COinS call (and with other in-source locators)
		if is_set (Sheet) or is_set (Sheets) then
			local err_msg1 = 'sheet=, &amp;#124;sheets';							-- default error message in case any of page pages or at are set
			local err_msg2;
			if is_set (Page) or is_set (Pages) or is_set (At) then				-- are any set?
				err_msg2 = 'page=, &amp;#124;pages=, &amp;#124;at';						-- a generic error message
				Page = ''; Pages = ''; At = '';
			elseif is_set (Sheet) and is_set (Sheets) then						-- if both are set make error message
				err_msg1 = 'sheet';
				err_msg2 = 'sheets';
			end
			if is_set (err_msg2) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', err_msg1) .. ' and ' .. wrap_style ('parameter', err_msg2)}, true ) } );		-- add error message
			end
			if not is_set (Sheet) then											-- do sheet static text and formatting; Sheet has priority over Sheets if both provided
				if is_set (Sheets) then
					if is_set (Periodical) then
						Sheet = &quot;: Sheets &quot; .. Sheets;							-- because Sheet has priority, no need to support both later on
					else
						Sheet = sepc .. &quot; Sheets &quot; .. Sheets;
					end
				end
			else
				if is_set (Periodical) then
					Sheet = &quot;: Sheet &quot; .. Sheet;
				else
					Sheet = sepc .. &quot; Sheet &quot; .. Sheet;
				end
			end
		end
	end

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
		Others = sepc .. ' Translated by ' .. Translators .. Others; 
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end
	Issue = is_set(Issue) and (&quot; (&quot; .. Issue .. &quot;)&quot;) or &quot;&quot;;
	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	if is_set(Volume) then
		if ( mw.ustring.len(Volume) &gt; 4 )
		  then Volume = sepc ..&quot; &quot; .. Volume;
		  else Volume = &quot; &lt;b&gt;&quot; .. hyphen_to_dash(Volume) .. &quot;&lt;/b&gt;&quot;;
		end
	end

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

--[[
Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
note is displayed. There are no error messages for this condition.

]]
	if is_set (SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif is_set (RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if 'citation', lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text
																				-- neither of these work; don't know why; it seems that substitute() isn't being called	
		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then
			Quote = Quote:sub(2,-2);
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- CS1 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- DeadURL is empty, 'yes', 'true', 'y', 'unfit', 'usurped'
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
--			if 'usurped' == DeadURL then										-- when original has unsuitable content do not link
			if in_array (DeadURL, {'unfit', 'usurped'}) then
				Archived = sepc .. &quot; &quot; .. 'Archived from the original on ' .. ArchiveDate;	-- format already styled
			else																-- DeadURL is empty, 'yes', 'true', or 'y'
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'] ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'] ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower() ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin );
	end

	local Publisher;
	if is_set(Periodical) and
		not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap_msg ('published', PublicationDate);
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap_msg ('published', PublicationDate) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
			Language, Edition, Publisher, Agency, Volume, Issue}, sepc );
		
	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume, Issue}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Transcript, Language, Edition, Publisher}, sepc );
	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Issue, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Sheet .. Page .. Pages .. At;
	
	if is_set(Authors) then
		if is_set(Coauthors) then
			local sep = '; ';
			if 'vanc' == NameListFormat then
				sep = ', ';
			end
			Authors = Authors .. sep .. Coauthors;
		end
		if is_set(Date) then
			Date = &quot; (&quot;..Date..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		elseif string.sub(Authors,-1,-1) == sepc then
			Authors = Authors .. &quot; &quot;
		else
			Authors = Authors .. sepc .. &quot; &quot;
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			if (sepc ~= '.') then in_text = in_text:lower() end
			Editors = in_text .. Editors .. post_text;
			if (string.sub(Editors,-1,-1) == sepc) or (string.sub(Editors,-3,-1) == sepc .. ']]') then	-- if last editor name ends with sepc char
				Editors = Editors .. &quot; &quot;;										-- don't add another
			else
				Editors = Editors .. sepc .. &quot; &quot;								-- otherwise terninate the editor list
			end
		end
		text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon }, sepc );
		text = safe_join( {text, pgtext, idcommon}, sepc );
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon}, sepc );
		text = safe_join( {text, pgtext, idcommon}, sepc );
	else
		if is_set(Date) then
			if ( string.sub(tcommon,-1,-1) ~= sepc )
			  then Date = sepc ..&quot; &quot; .. Date .. OrigYear
			  else Date = &quot; &quot; .. Date .. OrigYear
			end
		end
		if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon}, sepc );
			text = safe_join( {text, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date}, sepc );
			text = safe_join( {text, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = config.CitationClass;
		options.class = &quot;citation &quot; .. config.CitationClass;					-- class=citation required for blue highlight when used with |ref=
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then
		local id = Ref
		if ( &quot;harv&quot; == Ref ) then
			local names = {} --table of last names &amp; year
			if #a &gt; 0 then
				for i,v in ipairs(a) do 
					names[i] = v.last 
					if i == 4 then break end
				end
			elseif #e &gt; 0 then
				for i,v in ipairs(e) do 
					names[i] = v.last 
					if i == 4 then break end				
				end
			end
			names[ #names + 1 ] = first_set(Year, anchor_year);	-- Year first for legacy citations and for YMD dates that require disambiguation
			id = anchor_id(names)
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then 
		text = '&lt;cite id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/cite&gt;&quot;;
	else
		text = '&lt;cite class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/cite&gt;&quot;;
	end		

	local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
	
	-- Note: Using display: none on then COinS span breaks some clients.
	local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
	text = text .. OCinS;
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. error_comment( v[1], v[2] );
				else
					text = text .. error_comment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end

	if #z.maintenance_cats ~= 0 then
		text = text .. '&lt;span class=&quot;citation-comment&quot; style=&quot;display:none; color:#33aa33&quot;&gt;';
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. ' ' .. v .. ' ([[:Category:' .. v ..'|link]])';
		end
		text = text .. '&lt;/span&gt;';	-- maintenance mesages (realy just the names of the categories for now)
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

-- This is used by templates such as {{cite book}} to create the actual citation text.
function z.citation(frame)
	local pframe = frame:getParent()
	local validation;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of Configuration and Whitelist and ...
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');	-- ... sandbox version of date validation code

	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of Configuration and Whitelist and ...
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		validation = require ('Module:Citation/CS1/Date_validation');			-- ... live version of date validation code
	end

	dates = validation.dates;													-- imported functions
	year_date_check = validation.year_date_check;

	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute( param, capture );				-- add the capture to the suggested parameter (typically the enumerator)
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, param}, true );	-- set the error message
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
						end
					end
--					if #suggestions == 0 then
--						suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );
--					end
--					if suggestions[ k:lower() ] ~= nil then
--						error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions[ k:lower() ]}, true );
--					else
--						error_text, error_state = set_error( 'parameter_ignored', {k}, true );
--					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	
	
	return citation0( config, args)
end

return z</text>
      <sha1>pj9y5nd4q0ny056hx525cqymzi9by46</sha1>
    </revision>
    <revision>
      <id>4698</id>
      <parentid>4697</parentid>
      <timestamp>2015-12-05T12:45:09Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4698</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="178138" sha1="6o10kyf3rmxgmw26tighjw1pdkd66gq" xml:space="preserve">
local z = {
	error_categories = {};		-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};		-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};		-- for categorizing citations based on certain properties, language of source for instance
}

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]
local dates, year_date_check	-- functions in Module:Citation/CS1/Date_validation

local cfg = {};					-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};			-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist

--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.
This function is global because it is called from both this module and from Date validation

]]
function is_set( var )
	return not (var == nil or var == '');
end

--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end

--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end

--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]
local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end

--[[--------------------------&lt; S E T _ E R R O R &gt;--------------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

]]
local function set_error( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if in_array( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return error_comment( message, error_state.hidden );
end

--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maintenance_cats using names from the configuration file with additional text if any.
To prevent duplication, the added_maint_cats table lists the categories by key that have been added to z.maintenance_cats.

]]

local added_maint_cats = {}														-- list of maintenance categories that have been added to z.maintenance_cats
local function add_maint_cat (key, arguments)
	if not added_maint_cats [key] then
		added_maint_cats [key] = true;											-- note that we've added this category
		table.insert( z.maintenance_cats, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
	end
end

--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

]]

local added_prop_cats = {}														-- list of property categories that have been added to z.properties_cats
local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));		-- make name then add to table
	end
end

--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

]]

local added_vanc_errs;															-- flag so we only emit one Vancouver error / category
local function add_vanc_error ()
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a uri scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[[--------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen. Single character names are not allowed.

Also allowed are IPv4 addresses. IPv6 not supported

There are three tests: the first is looking for a hostname that is 2 to n letters or digits followed by a dot and a
letter (tld); the second looks for a hostname that is 3 to n characters where the first and last are letters or
digits and the middle characters are letters, digits, or the hyphen; the whole followed by a dot and a letter or digit.
The third test is for IPv4 dot-decimal address format; tld not allowed.

returns true if domain appears to be a proper name and tld or IPv4 address, else false

]]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if domain:match ('^[%a%d][%a%d]+%.%a') then									-- two character hostname and tld
		return true;
	elseif domain:match ('^[%a%d][%a%d%-]+[%a%d]%.[%a%d]') then					-- three or more character hostname.hostname or hostname.tld
		return true;
	elseif domain:match ('^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?') then		-- IPv4 address
		return true;
	else
		return false;
	end
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a url appear to be a valid url; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if is_set (scheme) then														-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when url is protocol relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a url into a scheme and domain pair and return both parts.  If protocol relative url, return nil for scheme
and domain else return nil for both scheme and domain.

]]

local function split_url (url_str)
	local scheme, domain;
	
	if url_str:match ('%S-:%S+') then											-- if there is what appears to be a scheme domain pair
		scheme, domain = url_str:match ('(%S-:)(%S+)');							-- extract the scheme and domain portions
	elseif url_str:match ('//%S*') then											-- if there is what appears to be a protocol relative url
		domain = url_str:match ('//(%S*)')
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link= etc for properly formatted content: no wikilinks, no urls

Link parameters are to hold the title of a wikipedia article so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid url (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid url (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[#&lt;&gt;%[%]|{}_]') then										-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from url; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid url
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the url into scheme and domain
portions, or for protocol relative (//example.com) urls, just the domain.  Use is_scheme() and is_domain() to
validate the two portions of the url.  If both are valid, or for protocol relative if domain is valid, return true, else false.

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper url
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from url; 
	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
characters following the opening bracket obey the rules of a uri scheme (see check_url()).  The test will also find
external wikilinks that use protocol relative urls. Also finds bare urls.

The frontier pattern prevents a match on interwiki links which are similar to scheme:path urls.  The tests that
find bracketed urls are required because the parameters that call this test (currently |title=, |chapter=, and
|work=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]] is
possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S.*%]') then									-- if ext wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = value:match ('%f[%[]%[(%a%S*:)(%S.*)%]')
	elseif value:match ('%f[%[]%[//%S*%.%S*%]') then									-- if protocol relative ext wikilink: [//yyyyy.zzz]
		domain = value:match ('%f[%[]%[//(%S*%.%S*)%]');
	else
		scheme, domain = split_url (value);										-- get scheme or nil and domain or nil from url; 
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then														-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ I T A L I C S &gt;----------------------------------------------

Protects a string that will be wrapped in wiki italic markup '' ... ''

Note: We cannot use &lt;i&gt; for italics, as the expected behavior for italics specified by ''...'' in the title is that
they will be inverted (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and '' tend to interact
poorly under Mediawiki's HTML tidy.

]]

local function safe_for_italics( str )
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end

--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

local function wrap_style (key, str)
	if not is_set( str ) then
		return &quot;&quot;;
	elseif in_array( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safe_for_italics( str );
	end

	return substitute( cfg.presentation[key], {str} );
end

--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source )
	local error_str = &quot;&quot;;
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url( label ), &quot;]&quot;, error_str });
end

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

]]

local page_in_deprecated_cat;													-- sticky flag so that the category is added only once
local function deprecated_parameter(name)
	if not page_in_deprecated_cat then
		page_in_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end

--[[--------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Call this function for chapter titles, for website titles, etc; not for book titles.

]]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	
	cap, cap2 = str:match (&quot;^([\&quot;\'])([^\'].+)&quot;);								-- match leading double or single quote but not double single quotes
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-left'], {cap, cap2});
	end

	cap, cap2 = str:match (&quot;^(.+[^\'])([\&quot;\'])$&quot;)
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-right'], {cap, cap2});
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title= and |script-chapter=

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, {'ar', 'bg', 'bs', 'dv', 'el', 'fa', 'he', 'hy', 'ja', 'ka', 'ko', 'ku', 'mk', 'ps', 'ru', 'sd', 'sr', 'th', 'uk', 'ug', 'yi', 'zh'}) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				add_prop_cat ('script')
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return substitute( msg, str );										-- including template text
	else
		return substitute( cfg.messages[key], str );
	end		
end


--[[-------------------------&lt; I S _ A L I A S _ U S E D &gt;-----------------------------------------------------

This function is used by select_one() to determine if one of a list of alias parameters is in the argument list
provided by the template.

Input:
	args – pointer to the arguments table from calling template
	alias – one of the list of possible aliases in the aliases lists from Module:Citation/CS1/Configuration
	index – for enumerated parameters, identifies which one
	enumerated – true/false flag used choose how enumerated aliases are examined
	value – value associated with an alias that has previously been selected; nil if not yet selected
	selected – the alias that has previously been selected; nil if not yet selected
	error_list – list of aliases that are duplicates of the alias already selected

Returns:
	value – value associated with alias we selected or that was previously selected or nil if an alias not yet selected
	selected – the alias we selected or the alias that was previously selected or nil if an alias not yet selected

]]

local function is_alias_used (args, alias, index, enumerated, value, selected, error_list)
	if enumerated then															-- is this a test for an enumerated parameters?
		alias = alias:gsub ('#', index);										-- replace '#' with the value in index
	else
		alias = alias:gsub ('#', '');											-- remove '#' if it exists
	end

	if is_set(args[alias]) then													-- alias is in the template's argument list
		if value ~= nil and selected ~= alias then								-- if we have already selected one of the aliases
			local skip;
			for _, v in ipairs(error_list) do											-- spin through the error list to see if we've added this alias
				if v == alias then
					skip = true;
					break;																-- has been added so stop looking 
				end
			end
			if not skip then															-- has not been added so
				table.insert( error_list, alias );									-- add error alias to the error list
			end
		else
			value = args[alias];												-- not yet selected an alias, so select this one
			selected = alias;
		end
	end
	return value, selected;														-- return newly selected alias, or previously selected alias
end


--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider.  The list of parameters to consider is just
names.  For parameters that may be enumerated, the position of the numerator in the parameter name is identified
by the '#' so |author-last1= and |author1-last= are represented as 'author-last#' and 'author#-last'.

Because enumerated parameter |&lt;param&gt;1= is an alias of |&lt;param&gt;= we must test for both possibilities.


Generates an error if more than one match is present.

]]

local function select_one( args, aliases_list, error_condition, index )
	local value = nil;															-- the value assigned to the selected parameter
	local selected = '';														-- the name of the parameter we have chosen
	local error_list = {};

	if index ~= nil then index = tostring(index); end

	for _, alias in ipairs( aliases_list ) do									-- for each alias in the aliases list
		if alias:match ('#') then												-- if this alias can be enumerated
			if '1' == index then												-- when index is 1 test for enumerated and non-enumerated aliases
				value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);	-- first test for non-enumerated alias
			end
			value, selected = is_alias_used (args, alias, index, true, value, selected, error_list);		-- test for enumerated alias
		else
			value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);		--test for non-enumerated alias
		end
	end

	if #error_list &gt; 0 and 'none' ~= error_condition then						-- for cases where this code is used outside of extract_names()
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap_style ('parameter', k);
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap_style ('parameter', selected);
		table.insert( z.message_tail, { set_error( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (scriptchapter, chapter, transchapter, chapterurl, chapter_url_source, no_quotes)
	local chapter_error = '';
	
	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);										-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
			chapter = wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, scriptchapter)						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (transchapter) then
		transchapter = wrap_style ('trans-quoted-title', transchapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. transchapter;
		else																	-- here when transchapter without chapter or script-chapter
			chapter = transchapter;												-- 
			chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
		end
	end

	if is_set (chapterurl) then
		chapter = external_link (chapterurl, chapter, chapter_url_source);		-- adds bare_url_missing_title error if appropriate
	end

	return chapter .. chapter_error;
end


--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
]]

local function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end


-- Formats a wiki style internal link
local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end

--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in check_isbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end

--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end

--[[--------------------------&lt; C H E C K _ I S M N &gt;------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the issn is invalid
	end 
	
	return text;
end

--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end

--[[
lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--[[
Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of the LCCN dictates the character type of the first 1-3 characters; the
rightmost eight are always digits. http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end

--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.

-- DOI names contain two parts: prefix and suffix separated by a forward slash.
--  Prefix: directory indicator '10.' followed by a registrant code
--  Suffix: character string of any length chosen by the registrant

-- This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes,
-- or, if it ends with a period or a comma, this function will emit a bad_doi error message.

-- DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
-- and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely if ever used in doi names.

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]
local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end

--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end

--[[--------------------------&lt; C L E A N _ I S B N &gt;----------------------------------------------------------

Removes irrelevant text and dashes from ISBN number
Similar to that used for Special:BookSources

]]

local function clean_isbn( isbn_str )
	return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]
local function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other lua magic pattern characters
	return argument;
end

--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	while true do
		if argument:match (&quot;%'%'%'%'%'&quot;) then									-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:match (&quot;%'%'%'%'&quot;) then									-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:match (&quot;%'%'%'&quot;) then									-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:match (&quot;%'%'&quot;) then										-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end

--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...
]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end

--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
local function remove_wiki_link( str )
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end

-- Converts a hyphen to a dash
local function hyphen_to_dash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end

--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if comp:sub(1,1) == duplicate_char then								-- is first charactier same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for th
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = str:sub(-1,-1);										-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = str:sub(1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = str:sub(1, -4) .. &quot;''&quot;;							-- remove them and add back ''
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then		-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then		-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then			-- if last two chars of str are sepc] external link
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;'']&quot; then		-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then				-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = str:sub(1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end		-- if duplicate_char not a letter then escape it
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )			-- remove duplicate_char if it follows html markup
					else
						value = value:sub( 2, -1 );								-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end  

--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

At the time of this writing, I had to write the 'if nil == mw.ustring.find ...' test ouside of the code editor and paste it here
because the code editor gets confused between character insertion point and cursor position.

]]

local function is_good_vanc_name (last, first)
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]*$&quot;) then
		add_vanc_error ();
		return false;															-- not a string of latin characters; Vancouver required Romanization
	end;
	return true;
end

--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  This form is not
currently supported by this code so correctly formed names like Smith JL 2nd are converted to Smith J2. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	if mw.ustring.match(first, &quot;^%u%u$&quot;) then return first end;					-- when first contains just two upper-case letters, nothing to do
	local initials = {}
	local i = 0;																-- counter for number of initials
	for word in mw.ustring.gmatch(first, &quot;[^%s%.%-]+&quot;) do						-- names separated by spaces, hyphens, or periods
		table.insert(initials, mw.ustring.sub(word,1,1))						-- Vancouver format does not include full stops.
		i = i + 1;																-- bump the counter 
		if 2 &lt;= i then break; end												-- only two initials allowed in Vancouver system; if 2, quit
	end
	return table.concat(initials)												-- Vancouver format does not include spaces.
end

--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal, list_name)					-- TODO: why is list_name here?  not used in this function
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = ',';																-- name-list separator between authors is a comma
		namesep = ' ';															-- last/first separator is a space
	else
		sep = ';'																-- name-list separator between authors is a semicolon
		namesep = ', '															-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then					-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first 
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;				-- link author/editor if this page is not the author's/editor's page
				end
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end

--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]
local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of author and editor name parameters for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the parameters |display-authors=etal or |display-editors=etal

]]

local function name_has_etal (name, etal, nocat)

	if is_set (name) then														-- name can be nil in which case just return
		local etal_pattern = &quot;[;,]? *[\&quot;']*%f[%a][Ee][Tt] *[Aa][Ll][%.\&quot;']*$&quot;	-- variations on the 'et al' theme
		local others_pattern = &quot;[;,]? *%f[%a]and [Oo]thers&quot;;					-- and alternate to et al.
		
		if name:match (etal_pattern) then										-- variants on et al.
			name = name:gsub (etal_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		elseif name:match (others_pattern) then									-- if not 'et al.', then 'and others'?
			name = name:gsub (others_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		end
	end
	return name, etal;															-- 
end

--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary
	while true do
		last = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false);								-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false);								-- find and remove variations on et al.

		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			if is_set (link) and false == link_param_ok (link) then				-- do this test here in case link is missing last
				table.insert( z.message_tail, { set_error( 'bad_paramlink', list_name:match (&quot;(%w+)List&quot;):lower() .. '-link' .. i )});			-- url or wikilink in author link;
			end
			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end

--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end
  

--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end
	
	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'journal', 'news'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if 'arxiv' == class then											-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			if is_set (data.Map) then
				OCinSoutput[&quot;rft.atitle&quot;] = data.Map;							-- for a map in a periodical
			else
				OCinSoutput[&quot;rft.atitle&quot;] = data.Title;							-- all other 'periodical' article titles
			end
																				-- these used onlu for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	--{'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation
	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		if k == 'ISBN' then v = clean_isbn( v ) end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v };	-- others; provide a url
		end
	end

--[[	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
]]
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = v.last, v.first;
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 code.  Handles the special case that is Norwegian where
ISO639-1 code 'no' is mapped to language name 'Norwegian Bokmål' by Extention:CLDR.

Returns the language name and associated ISO639-1 code.  Because case of the source may be incorrect or different from the case that Wikimedia
uses, the name comparisons are done in lower case and when a match is found, the Wikimedia version (assumed to be correct) is returned along
with the code.  When there is no match, we return the original language name string.

mw.language.fetchLanguageNames() will return a list of languages that aren't part of ISO639-1. Names that aren't ISO639-1 but that are included
in the list will be found if that name is provided in the |language= parameter.  For example, if |language=Samaritan Aramaic, that name will be
found with the associated code 'sam', not an ISO639-1 code.  When names are found and the associated code is not two characters, this function
returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang)
	if 'norwegian' == lang:lower() then											-- special case related to Wikimedia remap of code 'no' at Extension:CLDR
		return 'Norwegian', 'no';												-- Make sure rendered version is properly capitalized
	end
	
	local languages = mw.language.fetchLanguageNames('en', 'all')				-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() then												-- ISO639-1 codes only
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the ISO639-1 code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for ISO639-1 code
end

--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Get language name from ISO639-1 code value provided.  If a code is valid use the returned name; if not, then use the value that was provided with the language parameter.

There is an exception.  There are three ISO639-1 codes for Norewegian language variants.  There are two official variants: Norwegian Bokmål (code 'nb') and
Norwegian Nynorsk (code 'nn').  The third, code 'no',  is defined by ISO639-1 as 'Norwegian' though in Norway this is pretty much meaningless.  However, it appears
that on enwiki, editors are for the most part unaware of the nb and nn variants (compare page counts for these variants at Category:Articles with non-English-language external links.

Because Norwegian Bokmål is the most common language variant, Media wiki has been modified to return Norwegian Bokmål for ISO639-1 code 'no'. Here we undo that and
return 'Norwegian' when editors use |language=no.  We presume that editors don't know about the variants or can't descriminate between them.

See Help talk:Citation Style_1#An ISO 639-1 language name test

When |language= contains a valid ISO639-1 code, the page is assigned to the category for that code: Category:Norwegian-language sources (no) if
the page is a mainspace page and the ISO639-1 code is not 'en'.  Similarly, if the  parameter is |language=Norwegian, it will be categorized in the same way.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the ISO639-1 two character code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang

		if lang:match ('^%a%a%-') then											-- strip ietf language tags from code
			lang = lang:match ('(%a%a)%-')										-- keep only 639-1 code portion to lang; TODO: do something with 3166 alpha 2 country code?
		end
		if 2 == lang:len() then													-- ISO639-1 language code are 2 characters (fetchLanguageName also supports 3 character codes)
			name = mw.language.fetchLanguageName( lang:lower(), &quot;en&quot; );			-- get ISO 639-1 language name if Language is a proper code
		end
	
		if is_set (name) then													-- if Language specified a valid ISO639-1 code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang);								-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then
			if 'no' == code then name = 'Norwegian' end;						-- override wikimedia when code is 'no'
			if 'en' ~= code then												-- English not the language
				add_prop_cat ('foreign_lang_source', {name, code})
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, ' and ')							-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		language_list[code] = 'and ' .. language_list[code];					-- prepend last name with 'and&lt;space&gt;'
		name = table.concat (language_list, ', ')								-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
	end
	if 'English' == name then
		return '';																-- if one language and that language is English return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
end

--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = '.';																-- terminate the rendered citation with a period
	end
	return '.', ps;																-- separator is a full stop
end

--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = '';																-- make sure it isn't nil
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return ',', ps, ref;														-- separator is a comma
end

--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end

--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extension, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf[%?#]?') or url:match ('%.PDF[%?#]?');
end

--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parenthases, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end

--[[--------------------------&lt; G E T _ D I S P L A Y _ A U T H O R S _ E D I T O R S &gt;------------------------

Returns a number that may or may not limit the length of the author or editor name lists.

When the value assigned to |display-authors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-authors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

]]

local function get_display_authors_editors (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count and 'authors' == list_name then	-- AUTHORS ONLY		-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_auth_ed', list_name);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset
		end
	elseif 'authors' == list_name then		-- AUTHORS ONLY	need to clear implicit et al category
		max = count + 1;														-- number of authors + 1
	end
	
	return max, etal;
end

--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
--	local good_pattern = '^P[^%.P%l]';
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
--	local bad_pattern = '^[Pp][Pp]';
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
--		if Page:match ('^[Pp]?[Pp]%.?[ %d]') or  Page:match ('^[Pp]ages?[ %d]') or
--			Pages:match ('^[Pp]?[Pp]%.?[ %d]') or  Pages:match ('^[Pp]ages?[ %d]') then
--				add_maint_cat ('extra_text');
--		end
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	if vparam:find ('%[%[') or vparam:find ('%]%]')	then						-- no wikilinking vauthors names
		add_vanc_error ();
	end
	v_name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;)								-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parenthese to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')
			corporate = true;
		elseif string.find(v_name, &quot;%s&quot;) then
		    lastfirstTable = {}
		    lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
		    first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
		    last  = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
		    if mw.ustring.match (last, '%a+%s+%u+%s+%a+') or mw.ustring.match (v_name, ' %u %u$') then
				add_vanc_error ();												-- matches last II last; the case when a comma is missing or a space between two intiials
			end
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) and not mw.ustring.match (first, &quot;^%u?%u$&quot;) then		-- first shall contain one or two upper-case letters, nothing else
			add_vanc_error ();
		end
																				-- this from extract_names ()
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice incase we have a first 1 without a last1
		select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, no, etc).  When the parameter value has not been assigned a value (missing or empty
in the source template) the function refurns true.  If the parameter value is one of the list of allowed values returns
true; else, emits an error message and returns false.

]]

local function is_valid_parameter_value (value, name, possible)
	if not is_set (value) then
		return true;															-- an empty parameter is ok
	elseif in_array(value:lower(), possible) then
		return true;
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list,-1,-1) == sepc) or (string.sub (name_list,-3,-1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terninate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not is_set (volume) and not is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end
	
	local vol = '';
		
	if is_set (volume) then
		if (4 &lt; mw.ustring.len(volume)) then
			vol = substitute (cfg.messages['j-vol'], {sepc, volume});
		else
			vol = wrap_style ('vol-bold', hyphen_to_dash(volume));
		end
	end
	if is_set (issue) then
		return vol .. substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'journal' == origin);

	if is_set (page) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif is_set(pages) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then										-- if pages is only digits, assume a single page number
			return '', substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end

--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
		end
	end

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
		end
	end

	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list
	local Contribution = A['Contribution'];
	if in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not is_set (Contribution) then									-- |contributor= requires |contribution=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if select_one (args, cfg.aliases['ContributorList-Last'], 'redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { set_error( 'contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if not is_valid_parameter_value (NameListFormat, 'name-list-format', cfg.keywords['name-list-format']) then			-- only accepted value for this parameter is 'vanc'
		NameListFormat = '';													-- anything else, set to empty string
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
		if is_set (TitleLink) and false == link_param_ok (TitleLink) then
			table.insert( z.message_tail, { set_error( 'bad_paramlink', A:ORIGIN('TitleLink'))});		-- url or wikilink in |title-link=;
		end

	local Chapter = A['Chapter'];
	local ScriptChapter = A['ScriptChapter'];
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];
	local ArchiveURL = A['ArchiveURL'];
	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];
	local Periodical_origin = A:ORIGIN('Periodical');							-- get the name of the periodical parameter

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if in_array (config.CitationClass, cfg.templates_using_volume) and not ('conference' == config.CitationClass and not is_set (Periodical)) then
		Volume = A['Volume'];
	end
	if in_array (config.CitationClass, cfg.templates_using_issue) and not (in_array (config.CitationClass, {'conference', 'map'}) and not is_set (Periodical))then
		Issue = A['Issue'];
	end
	local Position = '';
	if not in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash( A['Pages'] );	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
		if not is_valid_parameter_value (RegistrationRequired, 'registration', cfg.keywords ['yes_true_y']) then
			RegistrationRequired=nil;
		end
	local SubscriptionRequired = A['SubscriptionRequired'];
		if not is_valid_parameter_value (SubscriptionRequired, 'subscription', cfg.keywords ['yes_true_y']) then
			SubscriptionRequired=nil;
		end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local ArchiveDate = A['ArchiveDate'];
	local Agency = A['Agency'];
	local DeadURL = A['DeadURL']
		if not is_valid_parameter_value (DeadURL, 'dead-url', cfg.keywords ['deadurl']) then	-- set in config.defaults to 'yes'
			DeadURL = '';														-- anything else, set to empty string
		end

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
		if not is_valid_parameter_value (IgnoreISBN, 'ignore-isbn-error', cfg.keywords ['yes_true_y']) then
			IgnoreISBN = nil;													-- anything else, set to empty string
		end
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
		if not is_valid_parameter_value (LastAuthorAmp, 'last-author-amp', cfg.keywords ['yes_true_y']) then
			LastAuthorAmp = nil;													-- set to empty string
		end
	local no_tracking_cats = A['NoTracking'];
		if not is_valid_parameter_value (no_tracking_cats, 'no-tracking', cfg.keywords ['yes_true_y']) then
			no_tracking_cats = nil;												-- set to empty string
		end

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

-- set default parameter values defined by |mode= parameter.  If |mode= is empty or omitted, use CitationClass to set these values
	local Mode = A['Mode'];
	if not is_valid_parameter_value (Mode, 'mode', cfg.keywords['mode']) then
		Mode = '';
	end
	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	select_one( args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'redundant_parameters' );		-- this is a dummy call simply to get the error message and category

	local NoPP = A['NoPP'] 
	if is_set (NoPP) and is_valid_parameter_value (NoPP, 'nopp', cfg.keywords ['yes_true_y']) then
		NoPP = true;
	else
		NoPP = nil;																-- unset, used as a flag later
	end

	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Pages = '';															-- unset the others
			At = '';
		end
		extra_text_in_page_check (Page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.
	elseif is_set(Pages) then
		if is_set(At) then
			At = '';															-- unset
		end
		extra_text_in_page_check (Pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped
	|url maps to |chapterurl when |title is remapped

All other combinations of |encyclopedia, |title, and |article are not modified

]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					TransChapter = TransTitle;
					ChapterURL = URL;
					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter= '[[' .. TitleLink .. '|' .. Chapter .. ']]';
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			else																-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if is_set(A['Number']) then													-- cite techreport uses 'number', which other citations alias to 'issue'
			if not is_set(ID) then												-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];													-- yes, use it
			else																-- ID has a value so emit error message
--				ID = ID .. &quot; &quot; .. set_error('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
				table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', 'id') .. ' and ' .. wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Others) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Others;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Others;
			end
		else
			Others = '(Interview)';
		end
	end

-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	elseif 'mailinglist' == A:ORIGIN('Periodical') then
		Periodical = '';														-- unset because mailing list is only used for cite mailing list
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];
			if is_set (SeriesLink) and false == link_param_ok (SeriesLink) then
				table.insert( z.message_tail, { set_error( 'bad_paramlink', A:ORIGIN('SeriesLink'))});
			end
		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) and is_set (AirDate) then							-- promote airdate to date
			Date = AirDate;
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('series', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = '[[' .. ChapterLink .. '|' .. Chapter .. ']]';		-- ok to wikilink
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = '[[' .. ChapterLink .. '|' .. Series .. ']]';			-- series links with ChapterLink (episodelink -&gt; TitleLink -&gt; ChapterLink) ugly
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = '[[' .. SeriesLink .. '|' .. Series .. ']]';
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
-- end of {{cite episode}} stuff

-- Account for the oddities that are {{cite arxiv}}, before generation of COinS data.
	if 'arxiv' == config.CitationClass then
		if not is_set (ID_list['ARXIV']) then									-- |arxiv= or |eprint= required for cite arxiv
			table.insert( z.message_tail, { set_error( 'arxiv_missing', {}, true ) } );		-- add error message
		elseif is_set (Series) then												-- series is an alias of version
			ID_list['ARXIV'] = ID_list['ARXIV'] .. Series;						-- concatenate version onto the end of the arxiv identifier
			Series = '';														-- unset
			deprecated_parameter ('version');									-- deprecated parameter but only for cite arxiv
		end
		
		if first_set ({AccessDate, At, Chapter, Format, Page, Pages, Periodical, PublisherName, URL,	-- a crude list of parameters that are not supported by cite arxiv
			ID_list['ASIN'], ID_list['BIBCODE'], ID_list['DOI'], ID_list['ISBN'], ID_list['ISSN'],
			ID_list['JFM'], ID_list['JSTOR'], ID_list['LCCN'], ID_list['MR'], ID_list['OCLC'], ID_list['OL'],
			ID_list['OSTI'], ID_list['PMC'], ID_list['PMID'], ID_list['RFC'], ID_list['SSRN'], ID_list['USENETID'], ID_list['ZBL']},27) then
				table.insert( z.message_tail, { set_error( 'arxiv_params_not_supported', {}, true ) } );		-- add error message

				AccessDate= '';													-- set these to empty string; not supported in cite arXiv
				PublisherName = '';												-- (if the article has been published, use cite journal, or other)
				Chapter = '';
				URL = '';
				Format = '';
				Page = ''; Pages = ''; At = '';
		end
		Periodical = 'arXiv';													-- set to arXiv for COinS; after that, must be set to empty string
	end

-- handle type parameter for those CS1 citations that have default values
	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
	TitleType = substitute( cfg.messages['type'], TitleType);					-- display it in parentheses
	end

-- legacy: promote concatenation of |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	do	-- create defined block to contain local variables error_message and mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		anchor_year, error_message = dates({['access-date']=AccessDate, ['archive-date']=ArchiveDate, ['date']=Date, ['doi-broken-date']=DoiBroken,
			['embargo']=Embargo, ['lay-date']=LayDate, ['publication-date']=PublicationDate, ['year']=Year}, COinS_date);

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end

		if is_set(error_message) then
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end
	end	-- end of do

-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);											-- 

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
			if 'episode' == config.CitationClass then							-- special case for cite episode; TODO: is there a better way to do this?
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
			else
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
			end
	end
	
	if 'none' == Title and in_array (config.CitationClass, {'journal', 'citation'}) and is_set (Periodical) and 'journal' == A:ORIGIN('Periodical') then	-- special case for journal cites
		Title = '';																-- set title to empty string
		add_maint_cat ('untitled');
	end

	check_for_url ({															-- add error message when any of these parameters contains a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[A:ORIGIN('Periodical')]=Periodical,
		[A:ORIGIN('PublisherName')] = PublisherName,
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = Periodical,
		['Encyclopedia'] = Encyclopedia,
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Map'] = Map,
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

-- Account for the oddities that are {{cite arxiv}}, AFTER generation of COinS data.
	if 'arxiv' == config.CitationClass then										-- we have set rft.jtitle in COinS to arXiv, now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in cite arxiv; if article has been published, use cite journal
	end

-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = substitute (cfg.messages['newsgroup'], external_link( 'news:' .. PublisherName, PublisherName, A:ORIGIN('PublisherName') ));
		end
	end



	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local maximum;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text											-- get current page name so that we don't wikilink to it via editorlinkn
		};

		do																		-- do editor name list first because coauthors can modify control table
			maximum , editor_etal = get_display_authors_editors (A['DisplayEditors'], #e, 'editors', editor_etal);
			-- Preserve old-style implicit et al.
			if not is_set(maximum) and #e == 4 then 
				maximum = 3;
				table.insert( z.message_tail, { set_error('implict_etal_editor', {}, true) } );
			end

			control.maximum = maximum;
			
			last_first_list, EditorCount = list_people(control, e, editor_etal, 'editor');

			if is_set (Editors) then
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
					EditorCount = 2;											-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
				else
					EditorCount = 2;											-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
				end
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do translators
			control.maximum = #t;												-- number of translators
			Translators = list_people(control, t, false, 'translator');			-- et al not currently supported
		end
		do																		-- now do contributors
			control.maximum = #c;												-- number of contributors
			Contributors = list_people(control, c, false, 'contributor');		-- et al not currently supported
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_authors_editors (A['DisplayAuthors'], #a, 'authors', author_etal);

			if is_set(Coauthors) then											-- if the coauthor field is also used, prevent ampersand and et al. formatting.
				control.lastauthoramp = nil;
				control.maximum = #a + 1;
			end
			
			last_first_list = list_people(control, a, author_etal, 'author');

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false);	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do

		if not is_set(Authors) and is_set(Coauthors) then						-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
			table.insert( z.message_tail, { set_error('coauthors_missing_author', {}, true) } );	-- emit error message
		end
	end

-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

-- special case for chapter format so no error message or cat when chapter not supported
	if not (in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if  not is_set(URL) then --and
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then		-- Test if cite web or cite podcast |url= is missing or empty 
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- Test if accessdate is given without giving a URL
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when the others are not set; TODO: move this to a separate test?
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURLorigin, OriginalFormat;						-- TODO: swap chapter and title here so that archive applies to most specific if both are set?
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURLorigin = URLorigin;										-- name of url parameter for error messages
			OriginalFormat = Format;											-- and original |format=
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
			end
		elseif is_set (ChapterURL) then 										-- URL not set so if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURLorigin = ChapterURLorigin;								-- name of chapter-url parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |format=
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				ChapterURLorigin = A:ORIGIN('ArchiveURL')						-- name of archive-url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
			end
		end
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'arxiv'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			local chap_param;
			if is_set (Chapter) then											-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif is_set (ScriptChapter) then
				chap_param = A:ORIGIN ('ScriptChapter')
			else is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if is_set (chap_param) then											-- if we found one
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {chap_param}, true ) } );		-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if is_set (Contribution) and 0 &lt; #c then								-- if this is a contribution with contributor(s)
			if in_array (Contribution:lower(), cfg.keywords.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, Chapter, TransChapter, ChapterURL, ChapterURLorigin, no_quotes);		-- Contribution is also in Chapter
		if is_set (Chapter) then
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;
			end
			Chapter = Chapter .. ChapterFormat .. sepc .. ' ';
		elseif is_set (ChapterFormat) then										-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'mailinglist', 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
	
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then 
			Title = external_link( URL, Title, URLorigin ) .. TransError .. Format;
			URL = &quot;&quot;;
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURLorigin );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if is_set(Minutes) then
			if is_set (Time) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'minutes') .. ' and ' .. wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
		Others = sepc .. ' Translated by ' .. Translators .. Others; 
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

--[[
Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
note is displayed. There are no error messages for this condition.

]]
	if is_set (SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif is_set (RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if 'citation', lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text
																				-- neither of these work; don't know why; it seems that substitute() isn't being called	
		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then				-- if first and last characters of quote are quote marks
			Quote = Quote:sub(2,-2);											-- strip them off
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL') ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- DeadURL is empty, 'yes', 'true', 'y', 'unfit', 'usurped'
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if in_array (DeadURL, {'unfit', 'usurped'}) then
				Archived = sepc .. &quot; &quot; .. 'Archived from the original on ' .. ArchiveDate;	-- format already styled
			else																-- DeadURL is empty, 'yes', 'true', or 'y'
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURLorigin ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL') ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL') ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURLorigin );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin );
	end

	local Publisher;
	if is_set(Periodical) and
		not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap_msg ('published', PublicationDate);
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap_msg ('published', PublicationDate) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
			Language, Edition, Publisher, Agency, Volume}, sepc );
		
	elseif in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(Periodical) then		-- special cases for book cites
		if is_set (Contributors) then											-- when we are citing foreword, preface, introduction, etc
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Transcript, Language, Edition, Publisher}, sepc );
	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if is_set(Date) then
		if is_set (Authors) or is_set (Editors) then							-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;;				-- in paranetheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon,-1,-1) == sepc) then							-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigYear;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigYear;							-- Date begins with sepc
			end
		end
	end	
	if is_set(Authors) then
		if is_set(Coauthors) then
			if 'vanc' == NameListFormat then									-- separate authors and coauthors with proper name-list-separator
				Authors = Authors .. ', ' .. Coauthors;
			else
				Authors = Authors .. '; ' .. Coauthors;
			end
		end
		if not is_set (Date) then												-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then in_text = in_text:lower() end				-- lowercase for cs2
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if is_set (Contributors) then											-- book cite and we're citing the intro, preface, etc
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if is_set (Editors) then											-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if not is_set (Date) then											-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = config.CitationClass;
		options.class = &quot;citation &quot; .. config.CitationClass;					-- class=citation required for blue highlight when used with |ref=
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then								-- set reference anchor if appropriate
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
--			local year = first_set (Year, anchor_year);							-- Year first for legacy citations and for YMD dates that require disambiguation
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			id = anchor_id (namelist, year);									-- go make the CITEREF anchor
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then 
		text = '&lt;cite id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/cite&gt;&quot;;
	else
		text = '&lt;cite class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/cite&gt;&quot;;
	end		

	local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
	
	-- Note: Using display: none on the COinS span breaks some clients.
	local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
	text = text .. OCinS;
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. error_comment( v[1], v[2] );
				else
					text = text .. error_comment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end

	if #z.maintenance_cats ~= 0 then
		text = text .. '&lt;span class=&quot;citation-comment&quot; style=&quot;display:none; color:#33aa33&quot;&gt;';
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. ' ' .. v .. ' ([[:Category:' .. v ..'|link]])';
		end
		text = text .. '&lt;/span&gt;';	-- maintenance mesages (realy just the names of the categories for now)
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the first match.

Sometime after this module is done with rendering a citation, some C0 control characters are replaced with the
replacement character.  That replacement character is not detected by this test though it is visible to readers
of the rendered citation.  This function will detect the replacement character when it is part of the wikisource.

Output of this function is an error message that identifies the character or the Unicode group that the character
belongs to along with its position in the parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';
	local i=1;

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		position = mw.ustring.find (v, pattern)									-- see if the parameter value contains characters that match the pattern
		if position then
			table.insert( z.message_tail, { set_error( 'invisible_char', {char, wrap_style ('parameter', param), position}, true ) } );	-- add error message
			return;																-- and done with this parameter
		end
		i=i+1;																	-- bump our index
	end
end


--[[--------------------------&lt; Z . C I T A T I O N &gt;----------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

function z.citation(frame)
	local pframe = frame:getParent()
	local validation;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of Configuration and Whitelist and ...
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');	-- ... sandbox version of date validation code

	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of Configuration and Whitelist and ...
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		validation = require ('Module:Citation/CS1/Date_validation');			-- ... live version of date validation code
	end

	dates = validation.dates;													-- imported functions
	year_date_check = validation.year_date_check;

	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute( param, capture );				-- add the capture to the suggested parameter (typically the enumerator)
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, param}, true );	-- set the error message
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	

	for k, v in pairs( args ) do
		has_invisible_chars (k, v)
	end
	return citation0( config, args)
end

return z</text>
      <sha1>6o10kyf3rmxgmw26tighjw1pdkd66gq</sha1>
    </revision>
    <revision>
      <id>4699</id>
      <parentid>4698</parentid>
      <timestamp>2015-12-05T13:10:58Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <minor />
      <comment>change link_param_ok (value) to allow underscore;</comment>
      <origin>4699</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="178199" sha1="spwpca3e34x6ccu1p3gnae8ajggc42f" xml:space="preserve">
local z = {
	error_categories = {};		-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};		-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};		-- for categorizing citations based on certain properties, language of source for instance
}

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]
local dates, year_date_check	-- functions in Module:Citation/CS1/Date_validation

local cfg = {};					-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};			-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist

--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.
This function is global because it is called from both this module and from Date validation

]]
function is_set( var )
	return not (var == nil or var == '');
end

--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end

--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end

--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]
local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end

--[[--------------------------&lt; S E T _ E R R O R &gt;--------------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

]]
local function set_error( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if in_array( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return error_comment( message, error_state.hidden );
end

--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maintenance_cats using names from the configuration file with additional text if any.
To prevent duplication, the added_maint_cats table lists the categories by key that have been added to z.maintenance_cats.

]]

local added_maint_cats = {}														-- list of maintenance categories that have been added to z.maintenance_cats
local function add_maint_cat (key, arguments)
	if not added_maint_cats [key] then
		added_maint_cats [key] = true;											-- note that we've added this category
		table.insert( z.maintenance_cats, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
	end
end

--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

]]

local added_prop_cats = {}														-- list of property categories that have been added to z.properties_cats
local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));		-- make name then add to table
	end
end

--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

]]

local added_vanc_errs;															-- flag so we only emit one Vancouver error / category
local function add_vanc_error ()
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a uri scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[[--------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen. Single character names are not allowed.

Also allowed are IPv4 addresses. IPv6 not supported

There are three tests: the first is looking for a hostname that is 2 to n letters or digits followed by a dot and a
letter (tld); the second looks for a hostname that is 3 to n characters where the first and last are letters or
digits and the middle characters are letters, digits, or the hyphen; the whole followed by a dot and a letter or digit.
The third test is for IPv4 dot-decimal address format; tld not allowed.

returns true if domain appears to be a proper name and tld or IPv4 address, else false

]]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if domain:match ('^[%a%d][%a%d]+%.%a') then									-- two character hostname and tld
		return true;
	elseif domain:match ('^[%a%d][%a%d%-]+[%a%d]%.[%a%d]') then					-- three or more character hostname.hostname or hostname.tld
		return true;
	elseif domain:match ('^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?') then		-- IPv4 address
		return true;
	else
		return false;
	end
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a url appear to be a valid url; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if is_set (scheme) then														-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when url is protocol relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a url into a scheme and domain pair and return both parts.  If protocol relative url, return nil for scheme
and domain else return nil for both scheme and domain.

]]

local function split_url (url_str)
	local scheme, domain;
	
	if url_str:match ('%S-:%S+') then											-- if there is what appears to be a scheme domain pair
		scheme, domain = url_str:match ('(%S-:)(%S+)');							-- extract the scheme and domain portions
	elseif url_str:match ('//%S*') then											-- if there is what appears to be a protocol relative url
		domain = url_str:match ('//(%S*)')
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link= etc for properly formatted content: no wikilinks, no urls

Link parameters are to hold the title of a wikipedia article so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki urls

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid url (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid url (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[#&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from url; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid url
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the url into scheme and domain
portions, or for protocol relative (//example.com) urls, just the domain.  Use is_scheme() and is_domain() to
validate the two portions of the url.  If both are valid, or for protocol relative if domain is valid, return true, else false.

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper url
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from url; 
	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
characters following the opening bracket obey the rules of a uri scheme (see check_url()).  The test will also find
external wikilinks that use protocol relative urls. Also finds bare urls.

The frontier pattern prevents a match on interwiki links which are similar to scheme:path urls.  The tests that
find bracketed urls are required because the parameters that call this test (currently |title=, |chapter=, and
|work=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]] is
possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S.*%]') then									-- if ext wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = value:match ('%f[%[]%[(%a%S*:)(%S.*)%]')
	elseif value:match ('%f[%[]%[//%S*%.%S*%]') then									-- if protocol relative ext wikilink: [//yyyyy.zzz]
		domain = value:match ('%f[%[]%[//(%S*%.%S*)%]');
	else
		scheme, domain = split_url (value);										-- get scheme or nil and domain or nil from url; 
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then														-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ I T A L I C S &gt;----------------------------------------------

Protects a string that will be wrapped in wiki italic markup '' ... ''

Note: We cannot use &lt;i&gt; for italics, as the expected behavior for italics specified by ''...'' in the title is that
they will be inverted (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and '' tend to interact
poorly under Mediawiki's HTML tidy.

]]

local function safe_for_italics( str )
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end

--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

local function wrap_style (key, str)
	if not is_set( str ) then
		return &quot;&quot;;
	elseif in_array( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safe_for_italics( str );
	end

	return substitute( cfg.presentation[key], {str} );
end

--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source )
	local error_str = &quot;&quot;;
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url( label ), &quot;]&quot;, error_str });
end

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

]]

local page_in_deprecated_cat;													-- sticky flag so that the category is added only once
local function deprecated_parameter(name)
	if not page_in_deprecated_cat then
		page_in_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end

--[[--------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Call this function for chapter titles, for website titles, etc; not for book titles.

]]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	
	cap, cap2 = str:match (&quot;^([\&quot;\'])([^\'].+)&quot;);								-- match leading double or single quote but not double single quotes
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-left'], {cap, cap2});
	end

	cap, cap2 = str:match (&quot;^(.+[^\'])([\&quot;\'])$&quot;)
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-right'], {cap, cap2});
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title= and |script-chapter=

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, {'ar', 'bg', 'bs', 'dv', 'el', 'fa', 'he', 'hy', 'ja', 'ka', 'ko', 'ku', 'mk', 'ps', 'ru', 'sd', 'sr', 'th', 'uk', 'ug', 'yi', 'zh'}) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				add_prop_cat ('script')
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return substitute( msg, str );										-- including template text
	else
		return substitute( cfg.messages[key], str );
	end		
end


--[[-------------------------&lt; I S _ A L I A S _ U S E D &gt;-----------------------------------------------------

This function is used by select_one() to determine if one of a list of alias parameters is in the argument list
provided by the template.

Input:
	args – pointer to the arguments table from calling template
	alias – one of the list of possible aliases in the aliases lists from Module:Citation/CS1/Configuration
	index – for enumerated parameters, identifies which one
	enumerated – true/false flag used choose how enumerated aliases are examined
	value – value associated with an alias that has previously been selected; nil if not yet selected
	selected – the alias that has previously been selected; nil if not yet selected
	error_list – list of aliases that are duplicates of the alias already selected

Returns:
	value – value associated with alias we selected or that was previously selected or nil if an alias not yet selected
	selected – the alias we selected or the alias that was previously selected or nil if an alias not yet selected

]]

local function is_alias_used (args, alias, index, enumerated, value, selected, error_list)
	if enumerated then															-- is this a test for an enumerated parameters?
		alias = alias:gsub ('#', index);										-- replace '#' with the value in index
	else
		alias = alias:gsub ('#', '');											-- remove '#' if it exists
	end

	if is_set(args[alias]) then													-- alias is in the template's argument list
		if value ~= nil and selected ~= alias then								-- if we have already selected one of the aliases
			local skip;
			for _, v in ipairs(error_list) do											-- spin through the error list to see if we've added this alias
				if v == alias then
					skip = true;
					break;																-- has been added so stop looking 
				end
			end
			if not skip then															-- has not been added so
				table.insert( error_list, alias );									-- add error alias to the error list
			end
		else
			value = args[alias];												-- not yet selected an alias, so select this one
			selected = alias;
		end
	end
	return value, selected;														-- return newly selected alias, or previously selected alias
end


--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider.  The list of parameters to consider is just
names.  For parameters that may be enumerated, the position of the numerator in the parameter name is identified
by the '#' so |author-last1= and |author1-last= are represented as 'author-last#' and 'author#-last'.

Because enumerated parameter |&lt;param&gt;1= is an alias of |&lt;param&gt;= we must test for both possibilities.


Generates an error if more than one match is present.

]]

local function select_one( args, aliases_list, error_condition, index )
	local value = nil;															-- the value assigned to the selected parameter
	local selected = '';														-- the name of the parameter we have chosen
	local error_list = {};

	if index ~= nil then index = tostring(index); end

	for _, alias in ipairs( aliases_list ) do									-- for each alias in the aliases list
		if alias:match ('#') then												-- if this alias can be enumerated
			if '1' == index then												-- when index is 1 test for enumerated and non-enumerated aliases
				value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);	-- first test for non-enumerated alias
			end
			value, selected = is_alias_used (args, alias, index, true, value, selected, error_list);		-- test for enumerated alias
		else
			value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);		--test for non-enumerated alias
		end
	end

	if #error_list &gt; 0 and 'none' ~= error_condition then						-- for cases where this code is used outside of extract_names()
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap_style ('parameter', k);
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap_style ('parameter', selected);
		table.insert( z.message_tail, { set_error( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (scriptchapter, chapter, transchapter, chapterurl, chapter_url_source, no_quotes)
	local chapter_error = '';
	
	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);										-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
			chapter = wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, scriptchapter)						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (transchapter) then
		transchapter = wrap_style ('trans-quoted-title', transchapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. transchapter;
		else																	-- here when transchapter without chapter or script-chapter
			chapter = transchapter;												-- 
			chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
		end
	end

	if is_set (chapterurl) then
		chapter = external_link (chapterurl, chapter, chapter_url_source);		-- adds bare_url_missing_title error if appropriate
	end

	return chapter .. chapter_error;
end


--[[
Argument wrapper.  This function provides support for argument 
mapping defined in the configuration file so that multiple names
can be transparently aliased to single internal variable.
]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
]]

local function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end


-- Formats a wiki style internal link
local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end

--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in check_isbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end

--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end

--[[--------------------------&lt; C H E C K _ I S M N &gt;------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the issn is invalid
	end 
	
	return text;
end

--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end

--[[
lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--[[
Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of the LCCN dictates the character type of the first 1-3 characters; the
rightmost eight are always digits. http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end

--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.

-- DOI names contain two parts: prefix and suffix separated by a forward slash.
--  Prefix: directory indicator '10.' followed by a registrant code
--  Suffix: character string of any length chosen by the registrant

-- This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes,
-- or, if it ends with a period or a comma, this function will emit a bad_doi error message.

-- DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
-- and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely if ever used in doi names.

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]
local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end

--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end

--[[--------------------------&lt; C L E A N _ I S B N &gt;----------------------------------------------------------

Removes irrelevant text and dashes from ISBN number
Similar to that used for Special:BookSources

]]

local function clean_isbn( isbn_str )
	return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]
local function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other lua magic pattern characters
	return argument;
end

--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	while true do
		if argument:match (&quot;%'%'%'%'%'&quot;) then									-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:match (&quot;%'%'%'%'&quot;) then									-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:match (&quot;%'%'%'&quot;) then									-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:match (&quot;%'%'&quot;) then										-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end

--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...
]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end

--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
local function remove_wiki_link( str )
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end

-- Converts a hyphen to a dash
local function hyphen_to_dash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end

--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if comp:sub(1,1) == duplicate_char then								-- is first charactier same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for th
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = str:sub(-1,-1);										-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = str:sub(1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = str:sub(1, -4) .. &quot;''&quot;;							-- remove them and add back ''
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then		-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then		-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then			-- if last two chars of str are sepc] external link
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;'']&quot; then		-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then				-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = str:sub(1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end		-- if duplicate_char not a letter then escape it
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )			-- remove duplicate_char if it follows html markup
					else
						value = value:sub( 2, -1 );								-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end  

--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

At the time of this writing, I had to write the 'if nil == mw.ustring.find ...' test ouside of the code editor and paste it here
because the code editor gets confused between character insertion point and cursor position.

]]

local function is_good_vanc_name (last, first)
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]*$&quot;) then
		add_vanc_error ();
		return false;															-- not a string of latin characters; Vancouver required Romanization
	end;
	return true;
end

--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  This form is not
currently supported by this code so correctly formed names like Smith JL 2nd are converted to Smith J2. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	if mw.ustring.match(first, &quot;^%u%u$&quot;) then return first end;					-- when first contains just two upper-case letters, nothing to do
	local initials = {}
	local i = 0;																-- counter for number of initials
	for word in mw.ustring.gmatch(first, &quot;[^%s%.%-]+&quot;) do						-- names separated by spaces, hyphens, or periods
		table.insert(initials, mw.ustring.sub(word,1,1))						-- Vancouver format does not include full stops.
		i = i + 1;																-- bump the counter 
		if 2 &lt;= i then break; end												-- only two initials allowed in Vancouver system; if 2, quit
	end
	return table.concat(initials)												-- Vancouver format does not include spaces.
end

--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal, list_name)					-- TODO: why is list_name here?  not used in this function
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = ',';																-- name-list separator between authors is a comma
		namesep = ' ';															-- last/first separator is a space
	else
		sep = ';'																-- name-list separator between authors is a semicolon
		namesep = ', '															-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then					-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first 
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;				-- link author/editor if this page is not the author's/editor's page
				end
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end

--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]
local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of author and editor name parameters for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the parameters |display-authors=etal or |display-editors=etal

]]

local function name_has_etal (name, etal, nocat)

	if is_set (name) then														-- name can be nil in which case just return
		local etal_pattern = &quot;[;,]? *[\&quot;']*%f[%a][Ee][Tt] *[Aa][Ll][%.\&quot;']*$&quot;	-- variations on the 'et al' theme
		local others_pattern = &quot;[;,]? *%f[%a]and [Oo]thers&quot;;					-- and alternate to et al.
		
		if name:match (etal_pattern) then										-- variants on et al.
			name = name:gsub (etal_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		elseif name:match (others_pattern) then									-- if not 'et al.', then 'and others'?
			name = name:gsub (others_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		end
	end
	return name, etal;															-- 
end

--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary
	while true do
		last = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false);								-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false);								-- find and remove variations on et al.

		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			if is_set (link) and false == link_param_ok (link) then				-- do this test here in case link is missing last
				table.insert( z.message_tail, { set_error( 'bad_paramlink', list_name:match (&quot;(%w+)List&quot;):lower() .. '-link' .. i )});			-- url or wikilink in author link;
			end
			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end

--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end
  

--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end
	
	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'journal', 'news'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if 'arxiv' == class then											-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			if is_set (data.Map) then
				OCinSoutput[&quot;rft.atitle&quot;] = data.Map;							-- for a map in a periodical
			else
				OCinSoutput[&quot;rft.atitle&quot;] = data.Title;							-- all other 'periodical' article titles
			end
																				-- these used onlu for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	--{'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation
	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		if k == 'ISBN' then v = clean_isbn( v ) end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v };	-- others; provide a url
		end
	end

--[[	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
]]
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = v.last, v.first;
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 code.  Handles the special case that is Norwegian where
ISO639-1 code 'no' is mapped to language name 'Norwegian Bokmål' by Extention:CLDR.

Returns the language name and associated ISO639-1 code.  Because case of the source may be incorrect or different from the case that Wikimedia
uses, the name comparisons are done in lower case and when a match is found, the Wikimedia version (assumed to be correct) is returned along
with the code.  When there is no match, we return the original language name string.

mw.language.fetchLanguageNames() will return a list of languages that aren't part of ISO639-1. Names that aren't ISO639-1 but that are included
in the list will be found if that name is provided in the |language= parameter.  For example, if |language=Samaritan Aramaic, that name will be
found with the associated code 'sam', not an ISO639-1 code.  When names are found and the associated code is not two characters, this function
returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang)
	if 'norwegian' == lang:lower() then											-- special case related to Wikimedia remap of code 'no' at Extension:CLDR
		return 'Norwegian', 'no';												-- Make sure rendered version is properly capitalized
	end
	
	local languages = mw.language.fetchLanguageNames('en', 'all')				-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() then												-- ISO639-1 codes only
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the ISO639-1 code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for ISO639-1 code
end

--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Get language name from ISO639-1 code value provided.  If a code is valid use the returned name; if not, then use the value that was provided with the language parameter.

There is an exception.  There are three ISO639-1 codes for Norewegian language variants.  There are two official variants: Norwegian Bokmål (code 'nb') and
Norwegian Nynorsk (code 'nn').  The third, code 'no',  is defined by ISO639-1 as 'Norwegian' though in Norway this is pretty much meaningless.  However, it appears
that on enwiki, editors are for the most part unaware of the nb and nn variants (compare page counts for these variants at Category:Articles with non-English-language external links.

Because Norwegian Bokmål is the most common language variant, Media wiki has been modified to return Norwegian Bokmål for ISO639-1 code 'no'. Here we undo that and
return 'Norwegian' when editors use |language=no.  We presume that editors don't know about the variants or can't descriminate between them.

See Help talk:Citation Style_1#An ISO 639-1 language name test

When |language= contains a valid ISO639-1 code, the page is assigned to the category for that code: Category:Norwegian-language sources (no) if
the page is a mainspace page and the ISO639-1 code is not 'en'.  Similarly, if the  parameter is |language=Norwegian, it will be categorized in the same way.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the ISO639-1 two character code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang

		if lang:match ('^%a%a%-') then											-- strip ietf language tags from code
			lang = lang:match ('(%a%a)%-')										-- keep only 639-1 code portion to lang; TODO: do something with 3166 alpha 2 country code?
		end
		if 2 == lang:len() then													-- ISO639-1 language code are 2 characters (fetchLanguageName also supports 3 character codes)
			name = mw.language.fetchLanguageName( lang:lower(), &quot;en&quot; );			-- get ISO 639-1 language name if Language is a proper code
		end
	
		if is_set (name) then													-- if Language specified a valid ISO639-1 code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang);								-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then
			if 'no' == code then name = 'Norwegian' end;						-- override wikimedia when code is 'no'
			if 'en' ~= code then												-- English not the language
				add_prop_cat ('foreign_lang_source', {name, code})
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, ' and ')							-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		language_list[code] = 'and ' .. language_list[code];					-- prepend last name with 'and&lt;space&gt;'
		name = table.concat (language_list, ', ')								-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
	end
	if 'English' == name then
		return '';																-- if one language and that language is English return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
end

--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = '.';																-- terminate the rendered citation with a period
	end
	return '.', ps;																-- separator is a full stop
end

--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = '';																-- make sure it isn't nil
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return ',', ps, ref;														-- separator is a comma
end

--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end

--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extension, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf[%?#]?') or url:match ('%.PDF[%?#]?');
end

--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parenthases, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end

--[[--------------------------&lt; G E T _ D I S P L A Y _ A U T H O R S _ E D I T O R S &gt;------------------------

Returns a number that may or may not limit the length of the author or editor name lists.

When the value assigned to |display-authors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-authors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

]]

local function get_display_authors_editors (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count and 'authors' == list_name then	-- AUTHORS ONLY		-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_auth_ed', list_name);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset
		end
	elseif 'authors' == list_name then		-- AUTHORS ONLY	need to clear implicit et al category
		max = count + 1;														-- number of authors + 1
	end
	
	return max, etal;
end

--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
--	local good_pattern = '^P[^%.P%l]';
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
--	local bad_pattern = '^[Pp][Pp]';
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
--		if Page:match ('^[Pp]?[Pp]%.?[ %d]') or  Page:match ('^[Pp]ages?[ %d]') or
--			Pages:match ('^[Pp]?[Pp]%.?[ %d]') or  Pages:match ('^[Pp]ages?[ %d]') then
--				add_maint_cat ('extra_text');
--		end
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	if vparam:find ('%[%[') or vparam:find ('%]%]')	then						-- no wikilinking vauthors names
		add_vanc_error ();
	end
	v_name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;)								-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parenthese to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')
			corporate = true;
		elseif string.find(v_name, &quot;%s&quot;) then
		    lastfirstTable = {}
		    lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
		    first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
		    last  = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
		    if mw.ustring.match (last, '%a+%s+%u+%s+%a+') or mw.ustring.match (v_name, ' %u %u$') then
				add_vanc_error ();												-- matches last II last; the case when a comma is missing or a space between two intiials
			end
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) and not mw.ustring.match (first, &quot;^%u?%u$&quot;) then		-- first shall contain one or two upper-case letters, nothing else
			add_vanc_error ();
		end
																				-- this from extract_names ()
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice incase we have a first 1 without a last1
		select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, no, etc).  When the parameter value has not been assigned a value (missing or empty
in the source template) the function refurns true.  If the parameter value is one of the list of allowed values returns
true; else, emits an error message and returns false.

]]

local function is_valid_parameter_value (value, name, possible)
	if not is_set (value) then
		return true;															-- an empty parameter is ok
	elseif in_array(value:lower(), possible) then
		return true;
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list,-1,-1) == sepc) or (string.sub (name_list,-3,-1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terninate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not is_set (volume) and not is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end
	
	local vol = '';
		
	if is_set (volume) then
		if (4 &lt; mw.ustring.len(volume)) then
			vol = substitute (cfg.messages['j-vol'], {sepc, volume});
		else
			vol = wrap_style ('vol-bold', hyphen_to_dash(volume));
		end
	end
	if is_set (issue) then
		return vol .. substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'journal' == origin);

	if is_set (page) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif is_set(pages) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then										-- if pages is only digits, assume a single page number
			return '', substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end

--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
		end
	end

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
		end
	end

	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list
	local Contribution = A['Contribution'];
	if in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not is_set (Contribution) then									-- |contributor= requires |contribution=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if select_one (args, cfg.aliases['ContributorList-Last'], 'redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { set_error( 'contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if not is_valid_parameter_value (NameListFormat, 'name-list-format', cfg.keywords['name-list-format']) then			-- only accepted value for this parameter is 'vanc'
		NameListFormat = '';													-- anything else, set to empty string
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
		if is_set (TitleLink) and false == link_param_ok (TitleLink) then
			table.insert( z.message_tail, { set_error( 'bad_paramlink', A:ORIGIN('TitleLink'))});		-- url or wikilink in |title-link=;
		end

	local Chapter = A['Chapter'];
	local ScriptChapter = A['ScriptChapter'];
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];
	local ArchiveURL = A['ArchiveURL'];
	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];
	local Periodical_origin = A:ORIGIN('Periodical');							-- get the name of the periodical parameter

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if in_array (config.CitationClass, cfg.templates_using_volume) and not ('conference' == config.CitationClass and not is_set (Periodical)) then
		Volume = A['Volume'];
	end
	if in_array (config.CitationClass, cfg.templates_using_issue) and not (in_array (config.CitationClass, {'conference', 'map'}) and not is_set (Periodical))then
		Issue = A['Issue'];
	end
	local Position = '';
	if not in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash( A['Pages'] );	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
		if not is_valid_parameter_value (RegistrationRequired, 'registration', cfg.keywords ['yes_true_y']) then
			RegistrationRequired=nil;
		end
	local SubscriptionRequired = A['SubscriptionRequired'];
		if not is_valid_parameter_value (SubscriptionRequired, 'subscription', cfg.keywords ['yes_true_y']) then
			SubscriptionRequired=nil;
		end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local ArchiveDate = A['ArchiveDate'];
	local Agency = A['Agency'];
	local DeadURL = A['DeadURL']
		if not is_valid_parameter_value (DeadURL, 'dead-url', cfg.keywords ['deadurl']) then	-- set in config.defaults to 'yes'
			DeadURL = '';														-- anything else, set to empty string
		end

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
		if not is_valid_parameter_value (IgnoreISBN, 'ignore-isbn-error', cfg.keywords ['yes_true_y']) then
			IgnoreISBN = nil;													-- anything else, set to empty string
		end
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
		if not is_valid_parameter_value (LastAuthorAmp, 'last-author-amp', cfg.keywords ['yes_true_y']) then
			LastAuthorAmp = nil;													-- set to empty string
		end
	local no_tracking_cats = A['NoTracking'];
		if not is_valid_parameter_value (no_tracking_cats, 'no-tracking', cfg.keywords ['yes_true_y']) then
			no_tracking_cats = nil;												-- set to empty string
		end

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

-- set default parameter values defined by |mode= parameter.  If |mode= is empty or omitted, use CitationClass to set these values
	local Mode = A['Mode'];
	if not is_valid_parameter_value (Mode, 'mode', cfg.keywords['mode']) then
		Mode = '';
	end
	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	select_one( args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'redundant_parameters' );		-- this is a dummy call simply to get the error message and category

	local NoPP = A['NoPP'] 
	if is_set (NoPP) and is_valid_parameter_value (NoPP, 'nopp', cfg.keywords ['yes_true_y']) then
		NoPP = true;
	else
		NoPP = nil;																-- unset, used as a flag later
	end

	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Pages = '';															-- unset the others
			At = '';
		end
		extra_text_in_page_check (Page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.
	elseif is_set(Pages) then
		if is_set(At) then
			At = '';															-- unset
		end
		extra_text_in_page_check (Pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped
	|url maps to |chapterurl when |title is remapped

All other combinations of |encyclopedia, |title, and |article are not modified

]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					TransChapter = TransTitle;
					ChapterURL = URL;
					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter= '[[' .. TitleLink .. '|' .. Chapter .. ']]';
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			else																-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if is_set(A['Number']) then													-- cite techreport uses 'number', which other citations alias to 'issue'
			if not is_set(ID) then												-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];													-- yes, use it
			else																-- ID has a value so emit error message
--				ID = ID .. &quot; &quot; .. set_error('redundant_parameters', '&lt;code&gt;&amp;#124;id=&lt;/code&gt; and &lt;code&gt;&amp;#124;number=&lt;/code&gt;');
				table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', 'id') .. ' and ' .. wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Others) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Others;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Others;
			end
		else
			Others = '(Interview)';
		end
	end

-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	elseif 'mailinglist' == A:ORIGIN('Periodical') then
		Periodical = '';														-- unset because mailing list is only used for cite mailing list
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];
			if is_set (SeriesLink) and false == link_param_ok (SeriesLink) then
				table.insert( z.message_tail, { set_error( 'bad_paramlink', A:ORIGIN('SeriesLink'))});
			end
		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) and is_set (AirDate) then							-- promote airdate to date
			Date = AirDate;
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('series', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = '[[' .. ChapterLink .. '|' .. Chapter .. ']]';		-- ok to wikilink
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = '[[' .. ChapterLink .. '|' .. Series .. ']]';			-- series links with ChapterLink (episodelink -&gt; TitleLink -&gt; ChapterLink) ugly
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = '[[' .. SeriesLink .. '|' .. Series .. ']]';
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
-- end of {{cite episode}} stuff

-- Account for the oddities that are {{cite arxiv}}, before generation of COinS data.
	if 'arxiv' == config.CitationClass then
		if not is_set (ID_list['ARXIV']) then									-- |arxiv= or |eprint= required for cite arxiv
			table.insert( z.message_tail, { set_error( 'arxiv_missing', {}, true ) } );		-- add error message
		elseif is_set (Series) then												-- series is an alias of version
			ID_list['ARXIV'] = ID_list['ARXIV'] .. Series;						-- concatenate version onto the end of the arxiv identifier
			Series = '';														-- unset
			deprecated_parameter ('version');									-- deprecated parameter but only for cite arxiv
		end
		
		if first_set ({AccessDate, At, Chapter, Format, Page, Pages, Periodical, PublisherName, URL,	-- a crude list of parameters that are not supported by cite arxiv
			ID_list['ASIN'], ID_list['BIBCODE'], ID_list['DOI'], ID_list['ISBN'], ID_list['ISSN'],
			ID_list['JFM'], ID_list['JSTOR'], ID_list['LCCN'], ID_list['MR'], ID_list['OCLC'], ID_list['OL'],
			ID_list['OSTI'], ID_list['PMC'], ID_list['PMID'], ID_list['RFC'], ID_list['SSRN'], ID_list['USENETID'], ID_list['ZBL']},27) then
				table.insert( z.message_tail, { set_error( 'arxiv_params_not_supported', {}, true ) } );		-- add error message

				AccessDate= '';													-- set these to empty string; not supported in cite arXiv
				PublisherName = '';												-- (if the article has been published, use cite journal, or other)
				Chapter = '';
				URL = '';
				Format = '';
				Page = ''; Pages = ''; At = '';
		end
		Periodical = 'arXiv';													-- set to arXiv for COinS; after that, must be set to empty string
	end

-- handle type parameter for those CS1 citations that have default values
	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
	TitleType = substitute( cfg.messages['type'], TitleType);					-- display it in parentheses
	end

-- legacy: promote concatenation of |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	do	-- create defined block to contain local variables error_message and mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		anchor_year, error_message = dates({['access-date']=AccessDate, ['archive-date']=ArchiveDate, ['date']=Date, ['doi-broken-date']=DoiBroken,
			['embargo']=Embargo, ['lay-date']=LayDate, ['publication-date']=PublicationDate, ['year']=Year}, COinS_date);

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end

		if is_set(error_message) then
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end
	end	-- end of do

-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);											-- 

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
			if 'episode' == config.CitationClass then							-- special case for cite episode; TODO: is there a better way to do this?
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
			else
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
			end
	end
	
	if 'none' == Title and in_array (config.CitationClass, {'journal', 'citation'}) and is_set (Periodical) and 'journal' == A:ORIGIN('Periodical') then	-- special case for journal cites
		Title = '';																-- set title to empty string
		add_maint_cat ('untitled');
	end

	check_for_url ({															-- add error message when any of these parameters contains a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[A:ORIGIN('Periodical')]=Periodical,
		[A:ORIGIN('PublisherName')] = PublisherName,
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = Periodical,
		['Encyclopedia'] = Encyclopedia,
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Map'] = Map,
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

-- Account for the oddities that are {{cite arxiv}}, AFTER generation of COinS data.
	if 'arxiv' == config.CitationClass then										-- we have set rft.jtitle in COinS to arXiv, now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in cite arxiv; if article has been published, use cite journal
	end

-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = substitute (cfg.messages['newsgroup'], external_link( 'news:' .. PublisherName, PublisherName, A:ORIGIN('PublisherName') ));
		end
	end



	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local maximum;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text											-- get current page name so that we don't wikilink to it via editorlinkn
		};

		do																		-- do editor name list first because coauthors can modify control table
			maximum , editor_etal = get_display_authors_editors (A['DisplayEditors'], #e, 'editors', editor_etal);
			-- Preserve old-style implicit et al.
			if not is_set(maximum) and #e == 4 then 
				maximum = 3;
				table.insert( z.message_tail, { set_error('implict_etal_editor', {}, true) } );
			end

			control.maximum = maximum;
			
			last_first_list, EditorCount = list_people(control, e, editor_etal, 'editor');

			if is_set (Editors) then
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
					EditorCount = 2;											-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
				else
					EditorCount = 2;											-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
				end
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do translators
			control.maximum = #t;												-- number of translators
			Translators = list_people(control, t, false, 'translator');			-- et al not currently supported
		end
		do																		-- now do contributors
			control.maximum = #c;												-- number of contributors
			Contributors = list_people(control, c, false, 'contributor');		-- et al not currently supported
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_authors_editors (A['DisplayAuthors'], #a, 'authors', author_etal);

			if is_set(Coauthors) then											-- if the coauthor field is also used, prevent ampersand and et al. formatting.
				control.lastauthoramp = nil;
				control.maximum = #a + 1;
			end
			
			last_first_list = list_people(control, a, author_etal, 'author');

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false);	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do

		if not is_set(Authors) and is_set(Coauthors) then						-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
			table.insert( z.message_tail, { set_error('coauthors_missing_author', {}, true) } );	-- emit error message
		end
	end

-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

-- special case for chapter format so no error message or cat when chapter not supported
	if not (in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if  not is_set(URL) then --and
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then		-- Test if cite web or cite podcast |url= is missing or empty 
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- Test if accessdate is given without giving a URL
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when the others are not set; TODO: move this to a separate test?
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURLorigin, OriginalFormat;						-- TODO: swap chapter and title here so that archive applies to most specific if both are set?
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURLorigin = URLorigin;										-- name of url parameter for error messages
			OriginalFormat = Format;											-- and original |format=
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
			end
		elseif is_set (ChapterURL) then 										-- URL not set so if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURLorigin = ChapterURLorigin;								-- name of chapter-url parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |format=
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				ChapterURLorigin = A:ORIGIN('ArchiveURL')						-- name of archive-url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
			end
		end
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'arxiv'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			local chap_param;
			if is_set (Chapter) then											-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif is_set (ScriptChapter) then
				chap_param = A:ORIGIN ('ScriptChapter')
			else is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if is_set (chap_param) then											-- if we found one
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {chap_param}, true ) } );		-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if is_set (Contribution) and 0 &lt; #c then								-- if this is a contribution with contributor(s)
			if in_array (Contribution:lower(), cfg.keywords.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, Chapter, TransChapter, ChapterURL, ChapterURLorigin, no_quotes);		-- Contribution is also in Chapter
		if is_set (Chapter) then
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;
			end
			Chapter = Chapter .. ChapterFormat .. sepc .. ' ';
		elseif is_set (ChapterFormat) then										-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'mailinglist', 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
	
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then 
			Title = external_link( URL, Title, URLorigin ) .. TransError .. Format;
			URL = &quot;&quot;;
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURLorigin );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if is_set(Minutes) then
			if is_set (Time) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'minutes') .. ' and ' .. wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
		Others = sepc .. ' Translated by ' .. Translators .. Others; 
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

--[[
Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
note is displayed. There are no error messages for this condition.

]]
	if is_set (SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif is_set (RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if 'citation', lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text
																				-- neither of these work; don't know why; it seems that substitute() isn't being called	
		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then				-- if first and last characters of quote are quote marks
			Quote = Quote:sub(2,-2);											-- strip them off
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL') ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- DeadURL is empty, 'yes', 'true', 'y', 'unfit', 'usurped'
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if in_array (DeadURL, {'unfit', 'usurped'}) then
				Archived = sepc .. &quot; &quot; .. 'Archived from the original on ' .. ArchiveDate;	-- format already styled
			else																-- DeadURL is empty, 'yes', 'true', or 'y'
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURLorigin ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL') ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL') ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURLorigin );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin );
	end

	local Publisher;
	if is_set(Periodical) and
		not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap_msg ('published', PublicationDate);
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap_msg ('published', PublicationDate) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
			Language, Edition, Publisher, Agency, Volume}, sepc );
		
	elseif in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(Periodical) then		-- special cases for book cites
		if is_set (Contributors) then											-- when we are citing foreword, preface, introduction, etc
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Transcript, Language, Edition, Publisher}, sepc );
	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if is_set(Date) then
		if is_set (Authors) or is_set (Editors) then							-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;;				-- in paranetheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon,-1,-1) == sepc) then							-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigYear;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigYear;							-- Date begins with sepc
			end
		end
	end	
	if is_set(Authors) then
		if is_set(Coauthors) then
			if 'vanc' == NameListFormat then									-- separate authors and coauthors with proper name-list-separator
				Authors = Authors .. ', ' .. Coauthors;
			else
				Authors = Authors .. '; ' .. Coauthors;
			end
		end
		if not is_set (Date) then												-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then in_text = in_text:lower() end				-- lowercase for cs2
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if is_set (Contributors) then											-- book cite and we're citing the intro, preface, etc
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if is_set (Editors) then											-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if not is_set (Date) then											-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = config.CitationClass;
		options.class = &quot;citation &quot; .. config.CitationClass;					-- class=citation required for blue highlight when used with |ref=
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then								-- set reference anchor if appropriate
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
--			local year = first_set (Year, anchor_year);							-- Year first for legacy citations and for YMD dates that require disambiguation
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			id = anchor_id (namelist, year);									-- go make the CITEREF anchor
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then 
		text = '&lt;cite id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/cite&gt;&quot;;
	else
		text = '&lt;cite class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/cite&gt;&quot;;
	end		

	local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
	
	-- Note: Using display: none on the COinS span breaks some clients.
	local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
	text = text .. OCinS;
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. error_comment( v[1], v[2] );
				else
					text = text .. error_comment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end

	if #z.maintenance_cats ~= 0 then
		text = text .. '&lt;span class=&quot;citation-comment&quot; style=&quot;display:none; color:#33aa33&quot;&gt;';
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. ' ' .. v .. ' ([[:Category:' .. v ..'|link]])';
		end
		text = text .. '&lt;/span&gt;';	-- maintenance mesages (realy just the names of the categories for now)
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the first match.

Sometime after this module is done with rendering a citation, some C0 control characters are replaced with the
replacement character.  That replacement character is not detected by this test though it is visible to readers
of the rendered citation.  This function will detect the replacement character when it is part of the wikisource.

Output of this function is an error message that identifies the character or the Unicode group that the character
belongs to along with its position in the parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';
	local i=1;

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		position = mw.ustring.find (v, pattern)									-- see if the parameter value contains characters that match the pattern
		if position then
			table.insert( z.message_tail, { set_error( 'invisible_char', {char, wrap_style ('parameter', param), position}, true ) } );	-- add error message
			return;																-- and done with this parameter
		end
		i=i+1;																	-- bump our index
	end
end


--[[--------------------------&lt; Z . C I T A T I O N &gt;----------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

function z.citation(frame)
	local pframe = frame:getParent()
	local validation;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of Configuration and Whitelist and ...
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');	-- ... sandbox version of date validation code

	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of Configuration and Whitelist and ...
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		validation = require ('Module:Citation/CS1/Date_validation');			-- ... live version of date validation code
	end

	dates = validation.dates;													-- imported functions
	year_date_check = validation.year_date_check;

	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute( param, capture );				-- add the capture to the suggested parameter (typically the enumerator)
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, param}, true );	-- set the error message
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	

	for k, v in pairs( args ) do
		has_invisible_chars (k, v)
	end
	return citation0( config, args)
end

return z</text>
      <sha1>spwpca3e34x6ccu1p3gnae8ajggc42f</sha1>
    </revision>
    <revision>
      <id>4700</id>
      <parentid>4699</parentid>
      <timestamp>2015-12-12T10:16:43Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4700</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="185967" sha1="6mdn3u9f1k1zwn5my9w7noqjnnmiynj" xml:space="preserve">
local z = {
	error_categories = {};		-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};		-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};		-- for categorizing citations based on certain properties, language of source for instance
}

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]
local dates, year_date_check	-- functions in Module:Citation/CS1/Date_validation

local cfg = {};					-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};			-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist

--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.
This function is global because it is called from both this module and from Date validation

]]
function is_set( var )
	return not (var == nil or var == '');
end

--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end

--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end

--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]
local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end

--[[--------------------------&lt; S E T _ E R R O R &gt;--------------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

]]
local function set_error( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if in_array( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return error_comment( message, error_state.hidden );
end

--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maintenance_cats using names from the configuration file with additional text if any.
To prevent duplication, the added_maint_cats table lists the categories by key that have been added to z.maintenance_cats.

]]

local added_maint_cats = {}														-- list of maintenance categories that have been added to z.maintenance_cats
local function add_maint_cat (key, arguments)
	if not added_maint_cats [key] then
		added_maint_cats [key] = true;											-- note that we've added this category
		table.insert( z.maintenance_cats, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
	end
end

--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

]]

local added_prop_cats = {}														-- list of property categories that have been added to z.properties_cats
local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));		-- make name then add to table
	end
end

--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

]]

local added_vanc_errs;															-- flag so we only emit one Vancouver error / category
local function add_vanc_error ()
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a uri scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of tlds: https://www.iana.org/domains/root/db

rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the tld.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a url with a scheme) will be stripped
here.  Perhaps not necessary but retained incase it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	single-letter/digit second-level domains in the .org TLD
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and tld or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%a%d]') then										-- first character must be letter or digit
		return false;
	end
	
	if domain:match ('%f[%a%d][%a%d]%.org$') then								-- one character .org hostname
		return true;
	elseif domain:match ('%f[%a][qxz]%.com$') then								-- assigned one character .com hostname (x.com times out 2015-12-10)
		return true;
	elseif domain:match ('%f[%a][iq]%.net$') then								-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.%a%a$') then							-- one character hostname and cctld (2 chars)
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d]%.%a%a+$') then					-- two character hostname and tld
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.%a%a+$') then			-- three or more character hostname.hostname or hostname.tld
		return true;
	elseif domain:match ('^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?') then		-- IPv4 address
		return true;
	else
		return false;
	end
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a url appear to be a valid url; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if is_set (scheme) then														-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when url is protocol relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a url into a scheme, authority indicator, and domain.
If protocol relative url, return nil scheme and domain else return nil for both scheme and domain.

When not protocol relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters following the scheme's colon), make sure that there are only 2.

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('(%a)/.*', '%1');									-- strip path information (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol relative url
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		authority = authority:gsub ('//', '', 1);								-- replace place 1 pair of '/' with nothing;
		if is_set(authority) then												-- if anything left (1 or 3+ '/' where authority should be) then
			domain = nil;														-- set to nil which will cause an error message
		end
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link= etc for properly formatted content: no wikilinks, no urls

Link parameters are to hold the title of a wikipedia article so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki urls and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid url (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid url (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from url; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid url
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the url into scheme and domain
portions, or for protocol relative (//example.com) urls, just the domain.  Use is_url() to validate the two
portions of the url.  If both are valid, or for protocol relative if domain is valid, return true, else false.

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper url
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from url; 
	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a url.  The test will also find external wikilinks
that use protocol relative urls. Also finds bare urls.

The frontier pattern prevents a match on interwiki links which are similar to scheme:path urls.  The tests that
find bracketed urls are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	value = value:gsub ('([^%s/])/%a.*', '%1');									-- strip path information (the capture prevents false replacement of '//')

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = value:match ('%f[%[]%[(%a%S*:)(%S+).*%]')
	elseif value:match ('%f[%[]%[//%S*%.%S+.*%]') then							-- if protocol relative ext wikilink: [//yyyyy.zzz]
		domain = value:match ('%f[%[]%[//(%S*%.%S+).*%]');
	elseif value:match ('%a%S*:%S+') then										-- if bare url with scheme; may have leading or trailing plain text
		scheme, domain = value:match ('(%a%S*:)(%S+)');
	elseif value:match ('//%S*%.%S+') then										-- if protocol relative bare url: //yyyyy.zzz; may have leading or trailing plain text
		domain = value:match ('//(%S*%.%S+)');									-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a url
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then												-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ I T A L I C S &gt;----------------------------------------------

Protects a string that will be wrapped in wiki italic markup '' ... ''

Note: We cannot use &lt;i&gt; for italics, as the expected behavior for italics specified by ''...'' in the title is that
they will be inverted (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and '' tend to interact
poorly under Mediawiki's HTML tidy.

]]

local function safe_for_italics( str )
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end

--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

local function wrap_style (key, str)
	if not is_set( str ) then
		return &quot;&quot;;
	elseif in_array( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safe_for_italics( str );
	end

	return substitute( cfg.presentation[key], {str} );
end

--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source )
	local error_str = &quot;&quot;;
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url( label ), &quot;]&quot;, error_str });
end

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

]]

local page_in_deprecated_cat;													-- sticky flag so that the category is added only once
local function deprecated_parameter(name)
	if not page_in_deprecated_cat then
		page_in_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end

--[[--------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Call this function for chapter titles, for website titles, etc; not for book titles.

]]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	
	cap, cap2 = str:match (&quot;^([\&quot;\'])([^\'].+)&quot;);								-- match leading double or single quote but not double single quotes
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-left'], {cap, cap2});
	end

	cap, cap2 = str:match (&quot;^(.+[^\'])([\&quot;\'])$&quot;)
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-right'], {cap, cap2});
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title= and |script-chapter=

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, {'ar', 'bg', 'bs', 'dv', 'el', 'fa', 'he', 'hy', 'ja', 'ka', 'ko', 'ku', 'mk', 'ps', 'ru', 'sd', 'sr', 'th', 'uk', 'ug', 'yi', 'zh'}) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				add_prop_cat ('script')
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return substitute( msg, str );										-- including template text
	else
		return substitute( cfg.messages[key], str );
	end		
end


--[[-------------------------&lt; I S _ A L I A S _ U S E D &gt;-----------------------------------------------------

This function is used by select_one() to determine if one of a list of alias parameters is in the argument list
provided by the template.

Input:
	args – pointer to the arguments table from calling template
	alias – one of the list of possible aliases in the aliases lists from Module:Citation/CS1/Configuration
	index – for enumerated parameters, identifies which one
	enumerated – true/false flag used choose how enumerated aliases are examined
	value – value associated with an alias that has previously been selected; nil if not yet selected
	selected – the alias that has previously been selected; nil if not yet selected
	error_list – list of aliases that are duplicates of the alias already selected

Returns:
	value – value associated with alias we selected or that was previously selected or nil if an alias not yet selected
	selected – the alias we selected or the alias that was previously selected or nil if an alias not yet selected

]]

local function is_alias_used (args, alias, index, enumerated, value, selected, error_list)
	if enumerated then															-- is this a test for an enumerated parameters?
		alias = alias:gsub ('#', index);										-- replace '#' with the value in index
	else
		alias = alias:gsub ('#', '');											-- remove '#' if it exists
	end

	if is_set(args[alias]) then													-- alias is in the template's argument list
		if value ~= nil and selected ~= alias then								-- if we have already selected one of the aliases
			local skip;
			for _, v in ipairs(error_list) do									-- spin through the error list to see if we've added this alias
				if v == alias then
					skip = true;
					break;														-- has been added so stop looking 
				end
			end
			if not skip then													-- has not been added so
				table.insert( error_list, alias );								-- add error alias to the error list
			end
		else
			value = args[alias];												-- not yet selected an alias, so select this one
			selected = alias;
		end
	end
	return value, selected;														-- return newly selected alias, or previously selected alias
end


--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider.  The list of parameters to consider is just
names.  For parameters that may be enumerated, the position of the numerator in the parameter name is identified
by the '#' so |author-last1= and |author1-last= are represented as 'author-last#' and 'author#-last'.

Because enumerated parameter |&lt;param&gt;1= is an alias of |&lt;param&gt;= we must test for both possibilities.


Generates an error if more than one match is present.

]]

local function select_one( args, aliases_list, error_condition, index )
	local value = nil;															-- the value assigned to the selected parameter
	local selected = '';														-- the name of the parameter we have chosen
	local error_list = {};

	if index ~= nil then index = tostring(index); end

	for _, alias in ipairs( aliases_list ) do									-- for each alias in the aliases list
		if alias:match ('#') then												-- if this alias can be enumerated
			if '1' == index then												-- when index is 1 test for enumerated and non-enumerated aliases
				value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);	-- first test for non-enumerated alias
			end
			value, selected = is_alias_used (args, alias, index, true, value, selected, error_list);		-- test for enumerated alias
		else
			value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);		--test for non-enumerated alias
		end
	end

	if #error_list &gt; 0 and 'none' ~= error_condition then						-- for cases where this code is used outside of extract_names()
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap_style ('parameter', k);
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap_style ('parameter', selected);
		table.insert( z.message_tail, { set_error( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (scriptchapter, chapter, transchapter, chapterurl, chapter_url_source, no_quotes)
	local chapter_error = '';
	
	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);										-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
			chapter = wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, scriptchapter)						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (transchapter) then
		transchapter = wrap_style ('trans-quoted-title', transchapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. transchapter;
		else																	-- here when transchapter without chapter or script-chapter
			chapter = transchapter;												-- 
			chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
		end
	end

	if is_set (chapterurl) then
		chapter = external_link (chapterurl, chapter, chapter_url_source);		-- adds bare_url_missing_title error if appropriate
	end

	return chapter .. chapter_error;
end

--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Detects but ignores the character pattern that results from the transclusion of {{'}} templates.

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i=1;
	local stripmarker, apostrophe;

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position then
--			if 'nowiki' == capture or 'math' == capture or ('ref' == capture and 'quote' == param) then 	-- nowiki, math, or quote param and ref stripmarker (not an error condition)
			if 'nowiki' == capture or 'math' == capture then 					-- nowiki, math stripmarker (not an error condition)
				stripmarker = true;												-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			elseif 'apostrophe' == char then									-- apostrophe template uses &amp;zwj;, hair space and zero-width space
				apostrophe = true;
			elseif true == apostrophe and in_array (char, {'zero width joiner', 'zero width space', 'hair space'}) then
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { set_error( 'invisible_char', {err_msg, wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i=i+1;																	-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end


-- Formats a wiki style internal link
local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end

--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in check_isbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end

--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end

--[[--------------------------&lt; C H E C K _ I S M N &gt;------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the issn is invalid
	end 
	
	return text;
end

--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end

--[[
lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--[[
Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of the LCCN dictates the character type of the first 1-3 characters; the
rightmost eight are always digits. http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end

--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.

-- DOI names contain two parts: prefix and suffix separated by a forward slash.
--  Prefix: directory indicator '10.' followed by a registrant code
--  Suffix: character string of any length chosen by the registrant

-- This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes,
-- or, if it ends with a period or a comma, this function will emit a bad_doi error message.

-- DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
-- and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely if ever used in doi names.

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]
local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end

--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end

--[[--------------------------&lt; C L E A N _ I S B N &gt;----------------------------------------------------------

Removes irrelevant text and dashes from ISBN number
Similar to that used for Special:BookSources

]]

local function clean_isbn( isbn_str )
	return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]
local function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other lua magic pattern characters
	return argument;
end

--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	while true do
		if argument:match (&quot;%'%'%'%'%'&quot;) then									-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:match (&quot;%'%'%'%'&quot;) then									-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:match (&quot;%'%'%'&quot;) then									-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:match (&quot;%'%'&quot;) then										-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end

--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...
]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end

--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
local function remove_wiki_link( str )
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end

-- Converts a hyphen to a dash
local function hyphen_to_dash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end

--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if comp:sub(1,1) == duplicate_char then								-- is first charactier same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for th
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = str:sub(-1,-1);										-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = str:sub(1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = str:sub(1, -4) .. &quot;''&quot;;							-- remove them and add back ''
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then		-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then		-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then			-- if last two chars of str are sepc] external link
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;'']&quot; then		-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then				-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = str:sub(1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end		-- if duplicate_char not a letter then escape it
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )			-- remove duplicate_char if it follows html markup
					else
						value = value:sub( 2, -1 );								-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end  

--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

At the time of this writing, I had to write the 'if nil == mw.ustring.find ...' test ouside of the code editor and paste it here
because the code editor gets confused between character insertion point and cursor position.

]]

local function is_good_vanc_name (last, first)
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]*$&quot;) then
		add_vanc_error ();
		return false;															-- not a string of latin characters; Vancouver required Romanization
	end;
	return true;
end

--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  This form is not
currently supported by this code so correctly formed names like Smith JL 2nd are converted to Smith J2. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	if mw.ustring.match(first, &quot;^%u%u$&quot;) then return first end;					-- when first contains just two upper-case letters, nothing to do
	local initials = {}
	local i = 0;																-- counter for number of initials
	for word in mw.ustring.gmatch(first, &quot;[^%s%.%-]+&quot;) do						-- names separated by spaces, hyphens, or periods
		table.insert(initials, mw.ustring.sub(word,1,1))						-- Vancouver format does not include full stops.
		i = i + 1;																-- bump the counter 
		if 2 &lt;= i then break; end												-- only two initials allowed in Vancouver system; if 2, quit
	end
	return table.concat(initials)												-- Vancouver format does not include spaces.
end

--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal, list_name)					-- TODO: why is list_name here?  not used in this function
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = ',';																-- name-list separator between authors is a comma
		namesep = ' ';															-- last/first separator is a space
	else
		sep = ';'																-- name-list separator between authors is a semicolon
		namesep = ', '															-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then					-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first 
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;				-- link author/editor if this page is not the author's/editor's page
				end
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end

--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]
local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of author and editor name parameters for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the parameters |display-authors=etal or |display-editors=etal

]]

local function name_has_etal (name, etal, nocat)

	if is_set (name) then														-- name can be nil in which case just return
		local etal_pattern = &quot;[;,]? *[\&quot;']*%f[%a][Ee][Tt] *[Aa][Ll][%.\&quot;']*$&quot;	-- variations on the 'et al' theme
		local others_pattern = &quot;[;,]? *%f[%a]and [Oo]thers&quot;;					-- and alternate to et al.
		
		if name:match (etal_pattern) then										-- variants on et al.
			name = name:gsub (etal_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		elseif name:match (others_pattern) then									-- if not 'et al.', then 'and others'?
			name = name:gsub (others_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		end
	end
	return name, etal;															-- 
end

--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary
	while true do
		last = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false);								-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false);								-- find and remove variations on et al.

		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			if is_set (link) and false == link_param_ok (link) then				-- do this test here in case link is missing last
				table.insert( z.message_tail, { set_error( 'bad_paramlink', list_name:match (&quot;(%w+)List&quot;):lower() .. '-link' .. i )});			-- url or wikilink in author link;
			end
			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end

--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end
  

--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain html entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaced math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?
]]

local function coins_cleanup (value)
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;s&lt;/span&gt;', &quot;'s&quot;);	-- replace {{'s}} template with simple apostrophe-s
	value = value:gsub ('&amp;zwj;\226\128\138\039\226\128\139', &quot;'&quot;);				-- replace {{'}} with simple apostrophe
	value = value:gsub ('\226\128\138\039\226\128\139', &quot;'&quot;);					-- replace {{'}} with simple apostrophe (as of 2015-12-11)
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	value = value:gsub ('&amp;zwj;', '');											-- remove &amp;zwj; entities
	value = value:gsub ('[\226\128\141\226\128\139]', '')						-- remove zero-width joiner, zero-width space
	value = value:gsub ('[\194\173\009\010\013]', ' ');							-- replace soft hyphen, horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'journal', 'news'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if 'arxiv' == class then											-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			if is_set (data.Map) then
				OCinSoutput[&quot;rft.atitle&quot;] = data.Map;							-- for a map in a periodical
			else
				OCinSoutput[&quot;rft.atitle&quot;] = data.Title;							-- all other 'periodical' article titles
			end
																				-- these used onlu for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	--{'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation
	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		if k == 'ISBN' then v = clean_isbn( v ) end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v };	-- others; provide a url
		end
	end

--[[	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
]]
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki strip markers, non-printing or invisible characers
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 code.  Handles the special case that is Norwegian where
ISO639-1 code 'no' is mapped to language name 'Norwegian Bokmål' by Extention:CLDR.

Returns the language name and associated ISO639-1 code.  Because case of the source may be incorrect or different from the case that Wikimedia
uses, the name comparisons are done in lower case and when a match is found, the Wikimedia version (assumed to be correct) is returned along
with the code.  When there is no match, we return the original language name string.

mw.language.fetchLanguageNames() will return a list of languages that aren't part of ISO639-1. Names that aren't ISO639-1 but that are included
in the list will be found if that name is provided in the |language= parameter.  For example, if |language=Samaritan Aramaic, that name will be
found with the associated code 'sam', not an ISO639-1 code.  When names are found and the associated code is not two characters, this function
returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang)
	if 'norwegian' == lang:lower() then											-- special case related to Wikimedia remap of code 'no' at Extension:CLDR
		return 'Norwegian', 'no';												-- Make sure rendered version is properly capitalized
	end
	
	local languages = mw.language.fetchLanguageNames('en', 'all')				-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() then												-- ISO639-1 codes only
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the ISO639-1 code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for ISO639-1 code
end

--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Get language name from ISO639-1 code value provided.  If a code is valid use the returned name; if not, then use the value that was provided with the language parameter.

There is an exception.  There are three ISO639-1 codes for Norewegian language variants.  There are two official variants: Norwegian Bokmål (code 'nb') and
Norwegian Nynorsk (code 'nn').  The third, code 'no',  is defined by ISO639-1 as 'Norwegian' though in Norway this is pretty much meaningless.  However, it appears
that on enwiki, editors are for the most part unaware of the nb and nn variants (compare page counts for these variants at Category:Articles with non-English-language external links.

Because Norwegian Bokmål is the most common language variant, Media wiki has been modified to return Norwegian Bokmål for ISO639-1 code 'no'. Here we undo that and
return 'Norwegian' when editors use |language=no.  We presume that editors don't know about the variants or can't descriminate between them.

See Help talk:Citation Style_1#An ISO 639-1 language name test

When |language= contains a valid ISO639-1 code, the page is assigned to the category for that code: Category:Norwegian-language sources (no) if
the page is a mainspace page and the ISO639-1 code is not 'en'.  Similarly, if the  parameter is |language=Norwegian, it will be categorized in the same way.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the ISO639-1 two character code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang

		if lang:match ('^%a%a%-') then											-- strip ietf language tags from code
			lang = lang:match ('(%a%a)%-')										-- keep only 639-1 code portion to lang; TODO: do something with 3166 alpha 2 country code?
		end
		if 2 == lang:len() then													-- ISO639-1 language code are 2 characters (fetchLanguageName also supports 3 character codes)
			name = mw.language.fetchLanguageName( lang:lower(), &quot;en&quot; );			-- get ISO 639-1 language name if Language is a proper code
		end
	
		if is_set (name) then													-- if Language specified a valid ISO639-1 code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang);								-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then
			if 'no' == code then name = 'Norwegian' end;						-- override wikimedia when code is 'no'
			if 'en' ~= code then												-- English not the language
				add_prop_cat ('foreign_lang_source', {name, code})
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, ' and ')							-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		language_list[code] = 'and ' .. language_list[code];					-- prepend last name with 'and&lt;space&gt;'
		name = table.concat (language_list, ', ')								-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
	end
	if 'English' == name then
		return '';																-- if one language and that language is English return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
end

--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = '.';																-- terminate the rendered citation with a period
	end
	return '.', ps;																-- separator is a full stop
end

--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = '';																-- make sure it isn't nil
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return ',', ps, ref;														-- separator is a comma
end

--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end

--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extension, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf[%?#]?') or url:match ('%.PDF[%?#]?');
end

--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parenthases, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end

--[[--------------------------&lt; G E T _ D I S P L A Y _ A U T H O R S _ E D I T O R S &gt;------------------------

Returns a number that may or may not limit the length of the author or editor name lists.

When the value assigned to |display-authors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-authors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

]]

local function get_display_authors_editors (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count and 'authors' == list_name then	-- AUTHORS ONLY		-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_auth_ed', list_name);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset
		end
	elseif 'authors' == list_name then		-- AUTHORS ONLY	need to clear implicit et al category
		max = count + 1;														-- number of authors + 1
	end
	
	return max, etal;
end

--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
--	local good_pattern = '^P[^%.P%l]';
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
--	local bad_pattern = '^[Pp][Pp]';
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
--		if Page:match ('^[Pp]?[Pp]%.?[ %d]') or  Page:match ('^[Pp]ages?[ %d]') or
--			Pages:match ('^[Pp]?[Pp]%.?[ %d]') or  Pages:match ('^[Pp]ages?[ %d]') then
--				add_maint_cat ('extra_text');
--		end
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	if vparam:find ('%[%[') or vparam:find ('%]%]')	then						-- no wikilinking vauthors names
		add_vanc_error ();
	end
	v_name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;)								-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parenthese to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')
			corporate = true;
		elseif string.find(v_name, &quot;%s&quot;) then
		    lastfirstTable = {}
		    lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
		    first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
		    last  = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
		    if mw.ustring.match (last, '%a+%s+%u+%s+%a+') or mw.ustring.match (v_name, ' %u %u$') then
				add_vanc_error ();												-- matches last II last; the case when a comma is missing or a space between two intiials
			end
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) and not mw.ustring.match (first, &quot;^%u?%u$&quot;) then		-- first shall contain one or two upper-case letters, nothing else
			add_vanc_error ();
		end
																				-- this from extract_names ()
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice incase we have a first 1 without a last1
		select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, no, etc).  When the parameter value has not been assigned a value (missing or empty
in the source template) the function refurns true.  If the parameter value is one of the list of allowed values returns
true; else, emits an error message and returns false.

]]

local function is_valid_parameter_value (value, name, possible)
	if not is_set (value) then
		return true;															-- an empty parameter is ok
	elseif in_array(value:lower(), possible) then
		return true;
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list,-1,-1) == sepc) or (string.sub (name_list,-3,-1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terninate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not is_set (volume) and not is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end
	
	local vol = '';
		
	if is_set (volume) then
		if (4 &lt; mw.ustring.len(volume)) then
			vol = substitute (cfg.messages['j-vol'], {sepc, volume});
		else
			vol = wrap_style ('vol-bold', hyphen_to_dash(volume));
		end
	end
	if is_set (issue) then
		return vol .. substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'journal' == origin);

	if is_set (page) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif is_set(pages) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then										-- if pages is only digits, assume a single page number
			return '', substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end

--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
		end
	end

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
		end
	end

	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list
	local Contribution = A['Contribution'];
	if in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not is_set (Contribution) then									-- |contributor= requires |contribution=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if select_one (args, cfg.aliases['ContributorList-Last'], 'redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { set_error( 'contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if not is_valid_parameter_value (NameListFormat, 'name-list-format', cfg.keywords['name-list-format']) then			-- only accepted value for this parameter is 'vanc'
		NameListFormat = '';													-- anything else, set to empty string
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
		if is_set (TitleLink) and false == link_param_ok (TitleLink) then
			table.insert( z.message_tail, { set_error( 'bad_paramlink', A:ORIGIN('TitleLink'))});		-- url or wikilink in |title-link=;
		end

	local Chapter = A['Chapter'];
	local ScriptChapter = A['ScriptChapter'];
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];
	local ArchiveURL = A['ArchiveURL'];
	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];
	local Periodical_origin = A:ORIGIN('Periodical');							-- get the name of the periodical parameter

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if in_array (config.CitationClass, cfg.templates_using_volume) and not ('conference' == config.CitationClass and not is_set (Periodical)) then
		Volume = A['Volume'];
	end
	if in_array (config.CitationClass, cfg.templates_using_issue) and not (in_array (config.CitationClass, {'conference', 'map'}) and not is_set (Periodical))then
		Issue = A['Issue'];
	end
	local Position = '';
	if not in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash( A['Pages'] );	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
		if not is_valid_parameter_value (RegistrationRequired, 'registration', cfg.keywords ['yes_true_y']) then
			RegistrationRequired=nil;
		end
	local SubscriptionRequired = A['SubscriptionRequired'];
		if not is_valid_parameter_value (SubscriptionRequired, 'subscription', cfg.keywords ['yes_true_y']) then
			SubscriptionRequired=nil;
		end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local ArchiveDate = A['ArchiveDate'];
	local Agency = A['Agency'];
	local DeadURL = A['DeadURL']
		if not is_valid_parameter_value (DeadURL, 'dead-url', cfg.keywords ['deadurl']) then	-- set in config.defaults to 'yes'
			DeadURL = '';														-- anything else, set to empty string
		end

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
		if not is_valid_parameter_value (IgnoreISBN, 'ignore-isbn-error', cfg.keywords ['yes_true_y']) then
			IgnoreISBN = nil;													-- anything else, set to empty string
		end
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
		if not is_valid_parameter_value (LastAuthorAmp, 'last-author-amp', cfg.keywords ['yes_true_y']) then
			LastAuthorAmp = nil;													-- set to empty string
		end
	local no_tracking_cats = A['NoTracking'];
		if not is_valid_parameter_value (no_tracking_cats, 'no-tracking', cfg.keywords ['yes_true_y']) then
			no_tracking_cats = nil;												-- set to empty string
		end

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

-- set default parameter values defined by |mode= parameter.  If |mode= is empty or omitted, use CitationClass to set these values
	local Mode = A['Mode'];
	if not is_valid_parameter_value (Mode, 'mode', cfg.keywords['mode']) then
		Mode = '';
	end
	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	select_one( args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'redundant_parameters' );		-- this is a dummy call simply to get the error message and category

	local NoPP = A['NoPP'] 
	if is_set (NoPP) and is_valid_parameter_value (NoPP, 'nopp', cfg.keywords ['yes_true_y']) then
		NoPP = true;
	else
		NoPP = nil;																-- unset, used as a flag later
	end

	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Pages = '';															-- unset the others
			At = '';
		end
		extra_text_in_page_check (Page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.
	elseif is_set(Pages) then
		if is_set(At) then
			At = '';															-- unset
		end
		extra_text_in_page_check (Pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped
	|url maps to |chapterurl when |title is remapped

All other combinations of |encyclopedia, |title, and |article are not modified

]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					TransChapter = TransTitle;
					ChapterURL = URL;
					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter= '[[' .. TitleLink .. '|' .. Chapter .. ']]';
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			else																-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if is_set(A['Number']) then													-- cite techreport uses 'number', which other citations alias to 'issue'
			if not is_set(ID) then												-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];													-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', 'id') .. ' and ' .. wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Others) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Others;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Others;
			end
		else
			Others = '(Interview)';
		end
	end

-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	elseif 'mailinglist' == A:ORIGIN('Periodical') then
		Periodical = '';														-- unset because mailing list is only used for cite mailing list
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];
			if is_set (SeriesLink) and false == link_param_ok (SeriesLink) then
				table.insert( z.message_tail, { set_error( 'bad_paramlink', A:ORIGIN('SeriesLink'))});
			end
		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) and is_set (AirDate) then							-- promote airdate to date
			Date = AirDate;
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('series', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = '[[' .. ChapterLink .. '|' .. Chapter .. ']]';		-- ok to wikilink
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = '[[' .. ChapterLink .. '|' .. Series .. ']]';			-- series links with ChapterLink (episodelink -&gt; TitleLink -&gt; ChapterLink) ugly
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = '[[' .. SeriesLink .. '|' .. Series .. ']]';
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
-- end of {{cite episode}} stuff

-- Account for the oddities that are {{cite arxiv}}, before generation of COinS data.
	if 'arxiv' == config.CitationClass then
		if not is_set (ID_list['ARXIV']) then									-- |arxiv= or |eprint= required for cite arxiv
			table.insert( z.message_tail, { set_error( 'arxiv_missing', {}, true ) } );		-- add error message
		elseif is_set (Series) then												-- series is an alias of version
			ID_list['ARXIV'] = ID_list['ARXIV'] .. Series;						-- concatenate version onto the end of the arxiv identifier
			Series = '';														-- unset
			deprecated_parameter ('version');									-- deprecated parameter but only for cite arxiv
		end
		
		if first_set ({AccessDate, At, Chapter, Format, Page, Pages, Periodical, PublisherName, URL,	-- a crude list of parameters that are not supported by cite arxiv
			ID_list['ASIN'], ID_list['BIBCODE'], ID_list['DOI'], ID_list['ISBN'], ID_list['ISSN'],
			ID_list['JFM'], ID_list['JSTOR'], ID_list['LCCN'], ID_list['MR'], ID_list['OCLC'], ID_list['OL'],
			ID_list['OSTI'], ID_list['PMC'], ID_list['PMID'], ID_list['RFC'], ID_list['SSRN'], ID_list['USENETID'], ID_list['ZBL']},27) then
				table.insert( z.message_tail, { set_error( 'arxiv_params_not_supported', {}, true ) } );		-- add error message

				AccessDate= '';													-- set these to empty string; not supported in cite arXiv
				PublisherName = '';												-- (if the article has been published, use cite journal, or other)
				Chapter = '';
				URL = '';
				Format = '';
				Page = ''; Pages = ''; At = '';
		end
		Periodical = 'arXiv';													-- set to arXiv for COinS; after that, must be set to empty string
	end

-- handle type parameter for those CS1 citations that have default values
	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
	TitleType = substitute( cfg.messages['type'], TitleType);					-- display it in parentheses
	end

-- legacy: promote concatenation of |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	do	-- create defined block to contain local variables error_message and mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		anchor_year, error_message = dates({['access-date']=AccessDate, ['archive-date']=ArchiveDate, ['date']=Date, ['doi-broken-date']=DoiBroken,
			['embargo']=Embargo, ['lay-date']=LayDate, ['publication-date']=PublicationDate, ['year']=Year}, COinS_date);

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end

		if is_set(error_message) then
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end
	end	-- end of do

-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);											-- 

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
			if 'episode' == config.CitationClass then							-- special case for cite episode; TODO: is there a better way to do this?
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
			else
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
			end
	end
	
	if 'none' == Title and in_array (config.CitationClass, {'journal', 'citation'}) and is_set (Periodical) and 'journal' == A:ORIGIN('Periodical') then	-- special case for journal cites
		Title = '';																-- set title to empty string
		add_maint_cat ('untitled');
	end

	check_for_url ({															-- add error message when any of these parameters contains a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[A:ORIGIN('Periodical')]=Periodical,
		[A:ORIGIN('PublisherName')] = PublisherName,
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = Periodical,
		['Encyclopedia'] = Encyclopedia,
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Map'] = Map,
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

-- Account for the oddities that are {{cite arxiv}}, AFTER generation of COinS data.
	if 'arxiv' == config.CitationClass then										-- we have set rft.jtitle in COinS to arXiv, now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in cite arxiv; if article has been published, use cite journal
	end

-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = substitute (cfg.messages['newsgroup'], external_link( 'news:' .. PublisherName, PublisherName, A:ORIGIN('PublisherName') ));
		end
	end



	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local maximum;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text											-- get current page name so that we don't wikilink to it via editorlinkn
		};

		do																		-- do editor name list first because coauthors can modify control table
			maximum , editor_etal = get_display_authors_editors (A['DisplayEditors'], #e, 'editors', editor_etal);
			-- Preserve old-style implicit et al.
			if not is_set(maximum) and #e == 4 then 
				maximum = 3;
				table.insert( z.message_tail, { set_error('implict_etal_editor', {}, true) } );
			end

			control.maximum = maximum;
			
			last_first_list, EditorCount = list_people(control, e, editor_etal, 'editor');

			if is_set (Editors) then
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
					EditorCount = 2;											-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
				else
					EditorCount = 2;											-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
				end
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do translators
			control.maximum = #t;												-- number of translators
			Translators = list_people(control, t, false, 'translator');			-- et al not currently supported
		end
		do																		-- now do contributors
			control.maximum = #c;												-- number of contributors
			Contributors = list_people(control, c, false, 'contributor');		-- et al not currently supported
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_authors_editors (A['DisplayAuthors'], #a, 'authors', author_etal);

			if is_set(Coauthors) then											-- if the coauthor field is also used, prevent ampersand and et al. formatting.
				control.lastauthoramp = nil;
				control.maximum = #a + 1;
			end
			
			last_first_list = list_people(control, a, author_etal, 'author');

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false);	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do

		if not is_set(Authors) and is_set(Coauthors) then						-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
			table.insert( z.message_tail, { set_error('coauthors_missing_author', {}, true) } );	-- emit error message
		end
	end

-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

-- special case for chapter format so no error message or cat when chapter not supported
	if not (in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if  not is_set(URL) then --and
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then		-- Test if cite web or cite podcast |url= is missing or empty 
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- Test if accessdate is given without giving a URL
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when the others are not set; TODO: move this to a separate test?
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURLorigin, OriginalFormat;						-- TODO: swap chapter and title here so that archive applies to most specific if both are set?
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURLorigin = URLorigin;										-- name of url parameter for error messages
			OriginalFormat = Format;											-- and original |format=
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
			end
		elseif is_set (ChapterURL) then 										-- URL not set so if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURLorigin = ChapterURLorigin;								-- name of chapter-url parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |format=
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				ChapterURLorigin = A:ORIGIN('ArchiveURL')						-- name of archive-url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
			end
		end
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'arxiv'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			local chap_param;
			if is_set (Chapter) then											-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif is_set (ScriptChapter) then
				chap_param = A:ORIGIN ('ScriptChapter')
			else is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if is_set (chap_param) then											-- if we found one
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {chap_param}, true ) } );		-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if is_set (Contribution) and 0 &lt; #c then								-- if this is a contribution with contributor(s)
			if in_array (Contribution:lower(), cfg.keywords.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, Chapter, TransChapter, ChapterURL, ChapterURLorigin, no_quotes);		-- Contribution is also in Chapter
		if is_set (Chapter) then
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;
			end
			Chapter = Chapter .. ChapterFormat .. sepc .. ' ';
		elseif is_set (ChapterFormat) then										-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'mailinglist', 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
	
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then 
			Title = external_link( URL, Title, URLorigin ) .. TransError .. Format;
			URL = &quot;&quot;;
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURLorigin );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if is_set(Minutes) then
			if is_set (Time) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'minutes') .. ' and ' .. wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
		Others = sepc .. ' Translated by ' .. Translators .. Others; 
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

--[[
Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
note is displayed. There are no error messages for this condition.

]]
	if is_set (SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif is_set (RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if 'citation', lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text
																				-- neither of these work; don't know why; it seems that substitute() isn't being called	
		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then				-- if first and last characters of quote are quote marks
			Quote = Quote:sub(2,-2);											-- strip them off
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL') ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- DeadURL is empty, 'yes', 'true', 'y', 'unfit', 'usurped'
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if in_array (DeadURL, {'unfit', 'usurped'}) then
				Archived = sepc .. &quot; &quot; .. 'Archived from the original on ' .. ArchiveDate;	-- format already styled
			else																-- DeadURL is empty, 'yes', 'true', or 'y'
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURLorigin ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL') ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL') ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURLorigin );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin );
	end

	local Publisher;
	if is_set(Periodical) and
		not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap_msg ('published', PublicationDate);
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap_msg ('published', PublicationDate) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
			Language, Edition, Publisher, Agency, Volume}, sepc );
		
	elseif in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(Periodical) then		-- special cases for book cites
		if is_set (Contributors) then											-- when we are citing foreword, preface, introduction, etc
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Transcript, Language, Edition, Publisher}, sepc );
	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if is_set(Date) then
		if is_set (Authors) or is_set (Editors) then							-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;;				-- in paranetheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon,-1,-1) == sepc) then							-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigYear;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigYear;							-- Date begins with sepc
			end
		end
	end	
	if is_set(Authors) then
		if is_set(Coauthors) then
			if 'vanc' == NameListFormat then									-- separate authors and coauthors with proper name-list-separator
				Authors = Authors .. ', ' .. Coauthors;
			else
				Authors = Authors .. '; ' .. Coauthors;
			end
		end
		if not is_set (Date) then												-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then in_text = in_text:lower() end				-- lowercase for cs2
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if is_set (Contributors) then											-- book cite and we're citing the intro, preface, etc
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if is_set (Editors) then											-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if not is_set (Date) then											-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = config.CitationClass;
		options.class = &quot;citation &quot; .. config.CitationClass;					-- class=citation required for blue highlight when used with |ref=
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then								-- set reference anchor if appropriate
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
--			local year = first_set (Year, anchor_year);							-- Year first for legacy citations and for YMD dates that require disambiguation
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			id = anchor_id (namelist, year);									-- go make the CITEREF anchor
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then 
		text = '&lt;cite id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/cite&gt;&quot;;
	else
		text = '&lt;cite class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/cite&gt;&quot;;
	end		

	local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
	
	-- Note: Using display: none on the COinS span breaks some clients.
	local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
	text = text .. OCinS;
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. error_comment( v[1], v[2] );
				else
					text = text .. error_comment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end

	if #z.maintenance_cats ~= 0 then
		text = text .. '&lt;span class=&quot;citation-comment&quot; style=&quot;display:none; color:#33aa33&quot;&gt;';
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. ' ' .. v .. ' ([[:Category:' .. v ..'|link]])';
		end
		text = text .. '&lt;/span&gt;';	-- maintenance mesages (realy just the names of the categories for now)
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the first match.

Sometime after this module is done with rendering a citation, some C0 control characters are replaced with the
replacement character.  That replacement character is not detected by this test though it is visible to readers
of the rendered citation.  This function will detect the replacement character when it is part of the wikisource.

Output of this function is an error message that identifies the character or the Unicode group that the character
belongs to along with its position in the parameter value.

]]
--[[
local function has_invisible_chars (param, v)
	local position = '';
	local i=1;

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		v = mw.text.unstripNoWiki( v );											-- remove nowiki stripmarkers
		position = mw.ustring.find (v, pattern)									-- see if the parameter value contains characters that match the pattern
		if position then
			table.insert( z.message_tail, { set_error( 'invisible_char', {char, wrap_style ('parameter', param), position}, true ) } );	-- add error message
			return;																-- and done with this parameter
		end
		i=i+1;																	-- bump our index
	end
end
]]

--[[--------------------------&lt; Z . C I T A T I O N &gt;----------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

function z.citation(frame)
	local pframe = frame:getParent()
	local validation;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of Configuration and Whitelist and ...
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');	-- ... sandbox version of date validation code

	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of Configuration and Whitelist and ...
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		validation = require ('Module:Citation/CS1/Date_validation');			-- ... live version of date validation code
	end

	dates = validation.dates;													-- imported functions
	year_date_check = validation.year_date_check;

	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute( param, capture );				-- add the capture to the suggested parameter (typically the enumerator)
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, param}, true );	-- set the error message
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);
		end
	end
	return citation0( config, args)
end

return z</text>
      <sha1>6mdn3u9f1k1zwn5my9w7noqjnnmiynj</sha1>
    </revision>
    <revision>
      <id>4701</id>
      <parentid>4700</parentid>
      <timestamp>2015-12-12T14:42:33Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <minor />
      <comment>is_parameter_ext_wikilink() fix;</comment>
      <origin>4701</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="185970" sha1="oyu2e3b7r162g2dy8wzmplqoij0lo12" xml:space="preserve">
local z = {
	error_categories = {};		-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};		-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};		-- for categorizing citations based on certain properties, language of source for instance
}

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]
local dates, year_date_check	-- functions in Module:Citation/CS1/Date_validation

local cfg = {};					-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};			-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist

--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.
This function is global because it is called from both this module and from Date validation

]]
function is_set( var )
	return not (var == nil or var == '');
end

--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end

--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end

--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]
local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end

--[[--------------------------&lt; S E T _ E R R O R &gt;--------------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

]]
local function set_error( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if in_array( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return error_comment( message, error_state.hidden );
end

--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maintenance_cats using names from the configuration file with additional text if any.
To prevent duplication, the added_maint_cats table lists the categories by key that have been added to z.maintenance_cats.

]]

local added_maint_cats = {}														-- list of maintenance categories that have been added to z.maintenance_cats
local function add_maint_cat (key, arguments)
	if not added_maint_cats [key] then
		added_maint_cats [key] = true;											-- note that we've added this category
		table.insert( z.maintenance_cats, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
	end
end

--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

]]

local added_prop_cats = {}														-- list of property categories that have been added to z.properties_cats
local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));		-- make name then add to table
	end
end

--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

]]

local added_vanc_errs;															-- flag so we only emit one Vancouver error / category
local function add_vanc_error ()
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a uri scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of tlds: https://www.iana.org/domains/root/db

rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the tld.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a url with a scheme) will be stripped
here.  Perhaps not necessary but retained incase it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	single-letter/digit second-level domains in the .org TLD
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and tld or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%a%d]') then										-- first character must be letter or digit
		return false;
	end
	
	if domain:match ('%f[%a%d][%a%d]%.org$') then								-- one character .org hostname
		return true;
	elseif domain:match ('%f[%a][qxz]%.com$') then								-- assigned one character .com hostname (x.com times out 2015-12-10)
		return true;
	elseif domain:match ('%f[%a][iq]%.net$') then								-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.%a%a$') then							-- one character hostname and cctld (2 chars)
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d]%.%a%a+$') then					-- two character hostname and tld
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.%a%a+$') then			-- three or more character hostname.hostname or hostname.tld
		return true;
	elseif domain:match ('^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?') then		-- IPv4 address
		return true;
	else
		return false;
	end
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a url appear to be a valid url; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if is_set (scheme) then														-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when url is protocol relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a url into a scheme, authority indicator, and domain.
If protocol relative url, return nil scheme and domain else return nil for both scheme and domain.

When not protocol relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters following the scheme's colon), make sure that there are only 2.

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('(%a)/.*', '%1');									-- strip path information (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol relative url
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		authority = authority:gsub ('//', '', 1);								-- replace place 1 pair of '/' with nothing;
		if is_set(authority) then												-- if anything left (1 or 3+ '/' where authority should be) then
			domain = nil;														-- set to nil which will cause an error message
		end
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link= etc for properly formatted content: no wikilinks, no urls

Link parameters are to hold the title of a wikipedia article so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki urls and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid url (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid url (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from url; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid url
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the url into scheme and domain
portions, or for protocol relative (//example.com) urls, just the domain.  Use is_url() to validate the two
portions of the url.  If both are valid, or for protocol relative if domain is valid, return true, else false.

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper url
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from url; 
	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a url.  The test will also find external wikilinks
that use protocol relative urls. Also finds bare urls.

The frontier pattern prevents a match on interwiki links which are similar to scheme:path urls.  The tests that
find bracketed urls are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	value = value:gsub ('([^%s/])/[%a%d].*', '%1');								-- strip path information (the capture prevents false replacement of '//')

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = value:match ('%f[%[]%[(%a%S*:)(%S+).*%]')
	elseif value:match ('%f[%[]%[//%S*%.%S+.*%]') then							-- if protocol relative ext wikilink: [//yyyyy.zzz]
		domain = value:match ('%f[%[]%[//(%S*%.%S+).*%]');
	elseif value:match ('%a%S*:%S+') then										-- if bare url with scheme; may have leading or trailing plain text
		scheme, domain = value:match ('(%a%S*:)(%S+)');
	elseif value:match ('//%S*%.%S+') then										-- if protocol relative bare url: //yyyyy.zzz; may have leading or trailing plain text
		domain = value:match ('//(%S*%.%S+)');									-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a url
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then												-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ I T A L I C S &gt;----------------------------------------------

Protects a string that will be wrapped in wiki italic markup '' ... ''

Note: We cannot use &lt;i&gt; for italics, as the expected behavior for italics specified by ''...'' in the title is that
they will be inverted (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and '' tend to interact
poorly under Mediawiki's HTML tidy.

]]

local function safe_for_italics( str )
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end

--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

local function wrap_style (key, str)
	if not is_set( str ) then
		return &quot;&quot;;
	elseif in_array( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safe_for_italics( str );
	end

	return substitute( cfg.presentation[key], {str} );
end

--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source )
	local error_str = &quot;&quot;;
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url( label ), &quot;]&quot;, error_str });
end

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end

--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

]]

local page_in_deprecated_cat;													-- sticky flag so that the category is added only once
local function deprecated_parameter(name)
	if not page_in_deprecated_cat then
		page_in_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end

--[[--------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Call this function for chapter titles, for website titles, etc; not for book titles.

]]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	
	cap, cap2 = str:match (&quot;^([\&quot;\'])([^\'].+)&quot;);								-- match leading double or single quote but not double single quotes
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-left'], {cap, cap2});
	end

	cap, cap2 = str:match (&quot;^(.+[^\'])([\&quot;\'])$&quot;)
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-right'], {cap, cap2});
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title= and |script-chapter=

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, {'ar', 'bg', 'bs', 'dv', 'el', 'fa', 'he', 'hy', 'ja', 'ka', 'ko', 'ku', 'mk', 'ps', 'ru', 'sd', 'sr', 'th', 'uk', 'ug', 'yi', 'zh'}) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				add_prop_cat ('script')
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return substitute( msg, str );										-- including template text
	else
		return substitute( cfg.messages[key], str );
	end		
end


--[[-------------------------&lt; I S _ A L I A S _ U S E D &gt;-----------------------------------------------------

This function is used by select_one() to determine if one of a list of alias parameters is in the argument list
provided by the template.

Input:
	args – pointer to the arguments table from calling template
	alias – one of the list of possible aliases in the aliases lists from Module:Citation/CS1/Configuration
	index – for enumerated parameters, identifies which one
	enumerated – true/false flag used choose how enumerated aliases are examined
	value – value associated with an alias that has previously been selected; nil if not yet selected
	selected – the alias that has previously been selected; nil if not yet selected
	error_list – list of aliases that are duplicates of the alias already selected

Returns:
	value – value associated with alias we selected or that was previously selected or nil if an alias not yet selected
	selected – the alias we selected or the alias that was previously selected or nil if an alias not yet selected

]]

local function is_alias_used (args, alias, index, enumerated, value, selected, error_list)
	if enumerated then															-- is this a test for an enumerated parameters?
		alias = alias:gsub ('#', index);										-- replace '#' with the value in index
	else
		alias = alias:gsub ('#', '');											-- remove '#' if it exists
	end

	if is_set(args[alias]) then													-- alias is in the template's argument list
		if value ~= nil and selected ~= alias then								-- if we have already selected one of the aliases
			local skip;
			for _, v in ipairs(error_list) do									-- spin through the error list to see if we've added this alias
				if v == alias then
					skip = true;
					break;														-- has been added so stop looking 
				end
			end
			if not skip then													-- has not been added so
				table.insert( error_list, alias );								-- add error alias to the error list
			end
		else
			value = args[alias];												-- not yet selected an alias, so select this one
			selected = alias;
		end
	end
	return value, selected;														-- return newly selected alias, or previously selected alias
end


--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider.  The list of parameters to consider is just
names.  For parameters that may be enumerated, the position of the numerator in the parameter name is identified
by the '#' so |author-last1= and |author1-last= are represented as 'author-last#' and 'author#-last'.

Because enumerated parameter |&lt;param&gt;1= is an alias of |&lt;param&gt;= we must test for both possibilities.


Generates an error if more than one match is present.

]]

local function select_one( args, aliases_list, error_condition, index )
	local value = nil;															-- the value assigned to the selected parameter
	local selected = '';														-- the name of the parameter we have chosen
	local error_list = {};

	if index ~= nil then index = tostring(index); end

	for _, alias in ipairs( aliases_list ) do									-- for each alias in the aliases list
		if alias:match ('#') then												-- if this alias can be enumerated
			if '1' == index then												-- when index is 1 test for enumerated and non-enumerated aliases
				value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);	-- first test for non-enumerated alias
			end
			value, selected = is_alias_used (args, alias, index, true, value, selected, error_list);		-- test for enumerated alias
		else
			value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);		--test for non-enumerated alias
		end
	end

	if #error_list &gt; 0 and 'none' ~= error_condition then						-- for cases where this code is used outside of extract_names()
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap_style ('parameter', k);
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap_style ('parameter', selected);
		table.insert( z.message_tail, { set_error( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (scriptchapter, chapter, transchapter, chapterurl, chapter_url_source, no_quotes)
	local chapter_error = '';
	
	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);										-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
			chapter = wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, scriptchapter)						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (transchapter) then
		transchapter = wrap_style ('trans-quoted-title', transchapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. transchapter;
		else																	-- here when transchapter without chapter or script-chapter
			chapter = transchapter;												-- 
			chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
		end
	end

	if is_set (chapterurl) then
		chapter = external_link (chapterurl, chapter, chapter_url_source);		-- adds bare_url_missing_title error if appropriate
	end

	return chapter .. chapter_error;
end

--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Detects but ignores the character pattern that results from the transclusion of {{'}} templates.

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i=1;
	local stripmarker, apostrophe;

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position then
--			if 'nowiki' == capture or 'math' == capture or ('ref' == capture and 'quote' == param) then 	-- nowiki, math, or quote param and ref stripmarker (not an error condition)
			if 'nowiki' == capture or 'math' == capture then 					-- nowiki, math stripmarker (not an error condition)
				stripmarker = true;												-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			elseif 'apostrophe' == char then									-- apostrophe template uses &amp;zwj;, hair space and zero-width space
				apostrophe = true;
			elseif true == apostrophe and in_array (char, {'zero width joiner', 'zero width space', 'hair space'}) then
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { set_error( 'invisible_char', {err_msg, wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i=i+1;																	-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end


-- Formats a wiki style internal link
local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end

--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit. ISBN-13 is checked in check_isbn().
If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length and stripped of dashes,
spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end

--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end

--[[--------------------------&lt; C H E C K _ I S M N &gt;------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the issn is invalid
	end 
	
	return text;
end

--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but has separated the two groups of four
digits with a space.  When that condition occurred, the resulting link looked like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length and makes sure that the checkdigit agrees
with the calculated value.  Incorrect length (8 digits), characters other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn
error message.  The issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end

--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end

--[[
lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--[[
Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of the LCCN dictates the character type of the first 1-3 characters; the
rightmost eight are always digits. http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[
Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This code checks the PMID to see that it
contains only digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically as more PMIDs are issued.
]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end

--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end

--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end

-- Formats a DOI and checks for DOI errors.

-- DOI names contain two parts: prefix and suffix separated by a forward slash.
--  Prefix: directory indicator '10.' followed by a registrant code
--  Suffix: character string of any length chosen by the registrant

-- This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes,
-- or, if it ends with a period or a comma, this function will emit a bad_doi error message.

-- DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
-- and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely if ever used in doi names.

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]
local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end

--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end

--[[--------------------------&lt; C L E A N _ I S B N &gt;----------------------------------------------------------

Removes irrelevant text and dashes from ISBN number
Similar to that used for Special:BookSources

]]

local function clean_isbn( isbn_str )
	return isbn_str:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; );
end

--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]
local function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other lua magic pattern characters
	return argument;
end

--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	while true do
		if argument:match (&quot;%'%'%'%'%'&quot;) then									-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:match (&quot;%'%'%'%'&quot;) then									-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:match (&quot;%'%'%'&quot;) then									-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:match (&quot;%'%'&quot;) then										-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end

--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...
]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end

--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end

-- Gets the display text for a wikilink like [[A|B]] or [[B]] gives B
local function remove_wiki_link( str )
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end

-- Converts a hyphen to a dash
local function hyphen_to_dash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end

--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if comp:sub(1,1) == duplicate_char then								-- is first charactier same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for th
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = str:sub(-1,-1);										-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = str:sub(1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = str:sub(1, -4) .. &quot;''&quot;;							-- remove them and add back ''
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then		-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then		-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then			-- if last two chars of str are sepc] external link
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;'']&quot; then		-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then				-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = str:sub(1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end		-- if duplicate_char not a letter then escape it
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )			-- remove duplicate_char if it follows html markup
					else
						value = value:sub( 2, -1 );								-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end  

--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

At the time of this writing, I had to write the 'if nil == mw.ustring.find ...' test ouside of the code editor and paste it here
because the code editor gets confused between character insertion point and cursor position.

]]

local function is_good_vanc_name (last, first)
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]*$&quot;) then
		add_vanc_error ();
		return false;															-- not a string of latin characters; Vancouver required Romanization
	end;
	return true;
end

--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  This form is not
currently supported by this code so correctly formed names like Smith JL 2nd are converted to Smith J2. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	if mw.ustring.match(first, &quot;^%u%u$&quot;) then return first end;					-- when first contains just two upper-case letters, nothing to do
	local initials = {}
	local i = 0;																-- counter for number of initials
	for word in mw.ustring.gmatch(first, &quot;[^%s%.%-]+&quot;) do						-- names separated by spaces, hyphens, or periods
		table.insert(initials, mw.ustring.sub(word,1,1))						-- Vancouver format does not include full stops.
		i = i + 1;																-- bump the counter 
		if 2 &lt;= i then break; end												-- only two initials allowed in Vancouver system; if 2, quit
	end
	return table.concat(initials)												-- Vancouver format does not include spaces.
end

--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal, list_name)					-- TODO: why is list_name here?  not used in this function
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = ',';																-- name-list separator between authors is a comma
		namesep = ' ';															-- last/first separator is a space
	else
		sep = ';'																-- name-list separator between authors is a semicolon
		namesep = ', '															-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then					-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first 
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;				-- link author/editor if this page is not the author's/editor's page
				end
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end

--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]
local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of author and editor name parameters for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the parameters |display-authors=etal or |display-editors=etal

]]

local function name_has_etal (name, etal, nocat)

	if is_set (name) then														-- name can be nil in which case just return
		local etal_pattern = &quot;[;,]? *[\&quot;']*%f[%a][Ee][Tt] *[Aa][Ll][%.\&quot;']*$&quot;	-- variations on the 'et al' theme
		local others_pattern = &quot;[;,]? *%f[%a]and [Oo]thers&quot;;					-- and alternate to et al.
		
		if name:match (etal_pattern) then										-- variants on et al.
			name = name:gsub (etal_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		elseif name:match (others_pattern) then									-- if not 'et al.', then 'and others'?
			name = name:gsub (others_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		end
	end
	return name, etal;															-- 
end

--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary
	while true do
		last = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false);								-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false);								-- find and remove variations on et al.

		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			if is_set (link) and false == link_param_ok (link) then				-- do this test here in case link is missing last
				table.insert( z.message_tail, { set_error( 'bad_paramlink', list_name:match (&quot;(%w+)List&quot;):lower() .. '-link' .. i )});			-- url or wikilink in author link;
			end
			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end

--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end
  

--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain html entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaced math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?
]]

local function coins_cleanup (value)
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;s&lt;/span&gt;', &quot;'s&quot;);	-- replace {{'s}} template with simple apostrophe-s
	value = value:gsub ('&amp;zwj;\226\128\138\039\226\128\139', &quot;'&quot;);				-- replace {{'}} with simple apostrophe
	value = value:gsub ('\226\128\138\039\226\128\139', &quot;'&quot;);					-- replace {{'}} with simple apostrophe (as of 2015-12-11)
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	value = value:gsub ('&amp;zwj;', '');											-- remove &amp;zwj; entities
	value = value:gsub ('[\226\128\141\226\128\139]', '')						-- remove zero-width joiner, zero-width space
	value = value:gsub ('[\194\173\009\010\013]', ' ');							-- replace soft hyphen, horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'journal', 'news'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if 'arxiv' == class then											-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			if is_set (data.Map) then
				OCinSoutput[&quot;rft.atitle&quot;] = data.Map;							-- for a map in a periodical
			else
				OCinSoutput[&quot;rft.atitle&quot;] = data.Title;							-- all other 'periodical' article titles
			end
																				-- these used onlu for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	--{'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation
	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		if k == 'ISBN' then v = clean_isbn( v ) end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v };	-- others; provide a url
		end
	end

--[[	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
]]
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki strip markers, non-printing or invisible characers
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 code.  Handles the special case that is Norwegian where
ISO639-1 code 'no' is mapped to language name 'Norwegian Bokmål' by Extention:CLDR.

Returns the language name and associated ISO639-1 code.  Because case of the source may be incorrect or different from the case that Wikimedia
uses, the name comparisons are done in lower case and when a match is found, the Wikimedia version (assumed to be correct) is returned along
with the code.  When there is no match, we return the original language name string.

mw.language.fetchLanguageNames() will return a list of languages that aren't part of ISO639-1. Names that aren't ISO639-1 but that are included
in the list will be found if that name is provided in the |language= parameter.  For example, if |language=Samaritan Aramaic, that name will be
found with the associated code 'sam', not an ISO639-1 code.  When names are found and the associated code is not two characters, this function
returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang)
	if 'norwegian' == lang:lower() then											-- special case related to Wikimedia remap of code 'no' at Extension:CLDR
		return 'Norwegian', 'no';												-- Make sure rendered version is properly capitalized
	end
	
	local languages = mw.language.fetchLanguageNames('en', 'all')				-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() then												-- ISO639-1 codes only
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the ISO639-1 code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for ISO639-1 code
end

--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Get language name from ISO639-1 code value provided.  If a code is valid use the returned name; if not, then use the value that was provided with the language parameter.

There is an exception.  There are three ISO639-1 codes for Norewegian language variants.  There are two official variants: Norwegian Bokmål (code 'nb') and
Norwegian Nynorsk (code 'nn').  The third, code 'no',  is defined by ISO639-1 as 'Norwegian' though in Norway this is pretty much meaningless.  However, it appears
that on enwiki, editors are for the most part unaware of the nb and nn variants (compare page counts for these variants at Category:Articles with non-English-language external links.

Because Norwegian Bokmål is the most common language variant, Media wiki has been modified to return Norwegian Bokmål for ISO639-1 code 'no'. Here we undo that and
return 'Norwegian' when editors use |language=no.  We presume that editors don't know about the variants or can't descriminate between them.

See Help talk:Citation Style_1#An ISO 639-1 language name test

When |language= contains a valid ISO639-1 code, the page is assigned to the category for that code: Category:Norwegian-language sources (no) if
the page is a mainspace page and the ISO639-1 code is not 'en'.  Similarly, if the  parameter is |language=Norwegian, it will be categorized in the same way.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the ISO639-1 two character code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang

		if lang:match ('^%a%a%-') then											-- strip ietf language tags from code
			lang = lang:match ('(%a%a)%-')										-- keep only 639-1 code portion to lang; TODO: do something with 3166 alpha 2 country code?
		end
		if 2 == lang:len() then													-- ISO639-1 language code are 2 characters (fetchLanguageName also supports 3 character codes)
			name = mw.language.fetchLanguageName( lang:lower(), &quot;en&quot; );			-- get ISO 639-1 language name if Language is a proper code
		end
	
		if is_set (name) then													-- if Language specified a valid ISO639-1 code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang);								-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then
			if 'no' == code then name = 'Norwegian' end;						-- override wikimedia when code is 'no'
			if 'en' ~= code then												-- English not the language
				add_prop_cat ('foreign_lang_source', {name, code})
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, ' and ')							-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		language_list[code] = 'and ' .. language_list[code];					-- prepend last name with 'and&lt;space&gt;'
		name = table.concat (language_list, ', ')								-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
	end
	if 'English' == name then
		return '';																-- if one language and that language is English return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
end

--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = '.';																-- terminate the rendered citation with a period
	end
	return '.', ps;																-- separator is a full stop
end

--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = '';																-- make sure it isn't nil
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return ',', ps, ref;														-- separator is a comma
end

--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end

--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extension, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf[%?#]?') or url:match ('%.PDF[%?#]?');
end

--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parenthases, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end

--[[--------------------------&lt; G E T _ D I S P L A Y _ A U T H O R S _ E D I T O R S &gt;------------------------

Returns a number that may or may not limit the length of the author or editor name lists.

When the value assigned to |display-authors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-authors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

]]

local function get_display_authors_editors (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count and 'authors' == list_name then	-- AUTHORS ONLY		-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_auth_ed', list_name);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset
		end
	elseif 'authors' == list_name then		-- AUTHORS ONLY	need to clear implicit et al category
		max = count + 1;														-- number of authors + 1
	end
	
	return max, etal;
end

--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
--	local good_pattern = '^P[^%.P%l]';
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
--	local bad_pattern = '^[Pp][Pp]';
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
--		if Page:match ('^[Pp]?[Pp]%.?[ %d]') or  Page:match ('^[Pp]ages?[ %d]') or
--			Pages:match ('^[Pp]?[Pp]%.?[ %d]') or  Pages:match ('^[Pp]ages?[ %d]') then
--				add_maint_cat ('extra_text');
--		end
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	if vparam:find ('%[%[') or vparam:find ('%]%]')	then						-- no wikilinking vauthors names
		add_vanc_error ();
	end
	v_name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;)								-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parenthese to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')
			corporate = true;
		elseif string.find(v_name, &quot;%s&quot;) then
		    lastfirstTable = {}
		    lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
		    first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
		    last  = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
		    if mw.ustring.match (last, '%a+%s+%u+%s+%a+') or mw.ustring.match (v_name, ' %u %u$') then
				add_vanc_error ();												-- matches last II last; the case when a comma is missing or a space between two intiials
			end
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) and not mw.ustring.match (first, &quot;^%u?%u$&quot;) then		-- first shall contain one or two upper-case letters, nothing else
			add_vanc_error ();
		end
																				-- this from extract_names ()
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice incase we have a first 1 without a last1
		select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, no, etc).  When the parameter value has not been assigned a value (missing or empty
in the source template) the function refurns true.  If the parameter value is one of the list of allowed values returns
true; else, emits an error message and returns false.

]]

local function is_valid_parameter_value (value, name, possible)
	if not is_set (value) then
		return true;															-- an empty parameter is ok
	elseif in_array(value:lower(), possible) then
		return true;
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list,-1,-1) == sepc) or (string.sub (name_list,-3,-1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terninate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not is_set (volume) and not is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end
	
	local vol = '';
		
	if is_set (volume) then
		if (4 &lt; mw.ustring.len(volume)) then
			vol = substitute (cfg.messages['j-vol'], {sepc, volume});
		else
			vol = wrap_style ('vol-bold', hyphen_to_dash(volume));
		end
	end
	if is_set (issue) then
		return vol .. substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'journal' == origin);

	if is_set (page) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif is_set(pages) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then										-- if pages is only digits, assume a single page number
			return '', substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end

--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
		end
	end

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
		end
	end

	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list
	local Contribution = A['Contribution'];
	if in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not is_set (Contribution) then									-- |contributor= requires |contribution=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if select_one (args, cfg.aliases['ContributorList-Last'], 'redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { set_error( 'contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if not is_valid_parameter_value (NameListFormat, 'name-list-format', cfg.keywords['name-list-format']) then			-- only accepted value for this parameter is 'vanc'
		NameListFormat = '';													-- anything else, set to empty string
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
		if is_set (TitleLink) and false == link_param_ok (TitleLink) then
			table.insert( z.message_tail, { set_error( 'bad_paramlink', A:ORIGIN('TitleLink'))});		-- url or wikilink in |title-link=;
		end

	local Chapter = A['Chapter'];
	local ScriptChapter = A['ScriptChapter'];
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];
	local ArchiveURL = A['ArchiveURL'];
	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];
	local Periodical_origin = A:ORIGIN('Periodical');							-- get the name of the periodical parameter

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if in_array (config.CitationClass, cfg.templates_using_volume) and not ('conference' == config.CitationClass and not is_set (Periodical)) then
		Volume = A['Volume'];
	end
	if in_array (config.CitationClass, cfg.templates_using_issue) and not (in_array (config.CitationClass, {'conference', 'map'}) and not is_set (Periodical))then
		Issue = A['Issue'];
	end
	local Position = '';
	if not in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash( A['Pages'] );	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
		if not is_valid_parameter_value (RegistrationRequired, 'registration', cfg.keywords ['yes_true_y']) then
			RegistrationRequired=nil;
		end
	local SubscriptionRequired = A['SubscriptionRequired'];
		if not is_valid_parameter_value (SubscriptionRequired, 'subscription', cfg.keywords ['yes_true_y']) then
			SubscriptionRequired=nil;
		end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local ArchiveDate = A['ArchiveDate'];
	local Agency = A['Agency'];
	local DeadURL = A['DeadURL']
		if not is_valid_parameter_value (DeadURL, 'dead-url', cfg.keywords ['deadurl']) then	-- set in config.defaults to 'yes'
			DeadURL = '';														-- anything else, set to empty string
		end

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
		if not is_valid_parameter_value (IgnoreISBN, 'ignore-isbn-error', cfg.keywords ['yes_true_y']) then
			IgnoreISBN = nil;													-- anything else, set to empty string
		end
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
		if not is_valid_parameter_value (LastAuthorAmp, 'last-author-amp', cfg.keywords ['yes_true_y']) then
			LastAuthorAmp = nil;													-- set to empty string
		end
	local no_tracking_cats = A['NoTracking'];
		if not is_valid_parameter_value (no_tracking_cats, 'no-tracking', cfg.keywords ['yes_true_y']) then
			no_tracking_cats = nil;												-- set to empty string
		end

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

-- set default parameter values defined by |mode= parameter.  If |mode= is empty or omitted, use CitationClass to set these values
	local Mode = A['Mode'];
	if not is_valid_parameter_value (Mode, 'mode', cfg.keywords['mode']) then
		Mode = '';
	end
	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	select_one( args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'redundant_parameters' );		-- this is a dummy call simply to get the error message and category

	local NoPP = A['NoPP'] 
	if is_set (NoPP) and is_valid_parameter_value (NoPP, 'nopp', cfg.keywords ['yes_true_y']) then
		NoPP = true;
	else
		NoPP = nil;																-- unset, used as a flag later
	end

	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Pages = '';															-- unset the others
			At = '';
		end
		extra_text_in_page_check (Page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.
	elseif is_set(Pages) then
		if is_set(At) then
			At = '';															-- unset
		end
		extra_text_in_page_check (Pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped
	|url maps to |chapterurl when |title is remapped

All other combinations of |encyclopedia, |title, and |article are not modified

]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					TransChapter = TransTitle;
					ChapterURL = URL;
					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter= '[[' .. TitleLink .. '|' .. Chapter .. ']]';
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			else																-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if is_set(A['Number']) then													-- cite techreport uses 'number', which other citations alias to 'issue'
			if not is_set(ID) then												-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];													-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', 'id') .. ' and ' .. wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Others) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Others;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Others;
			end
		else
			Others = '(Interview)';
		end
	end

-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	elseif 'mailinglist' == A:ORIGIN('Periodical') then
		Periodical = '';														-- unset because mailing list is only used for cite mailing list
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];
			if is_set (SeriesLink) and false == link_param_ok (SeriesLink) then
				table.insert( z.message_tail, { set_error( 'bad_paramlink', A:ORIGIN('SeriesLink'))});
			end
		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) and is_set (AirDate) then							-- promote airdate to date
			Date = AirDate;
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('series', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = '[[' .. ChapterLink .. '|' .. Chapter .. ']]';		-- ok to wikilink
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = '[[' .. ChapterLink .. '|' .. Series .. ']]';			-- series links with ChapterLink (episodelink -&gt; TitleLink -&gt; ChapterLink) ugly
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = '[[' .. SeriesLink .. '|' .. Series .. ']]';
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
-- end of {{cite episode}} stuff

-- Account for the oddities that are {{cite arxiv}}, before generation of COinS data.
	if 'arxiv' == config.CitationClass then
		if not is_set (ID_list['ARXIV']) then									-- |arxiv= or |eprint= required for cite arxiv
			table.insert( z.message_tail, { set_error( 'arxiv_missing', {}, true ) } );		-- add error message
		elseif is_set (Series) then												-- series is an alias of version
			ID_list['ARXIV'] = ID_list['ARXIV'] .. Series;						-- concatenate version onto the end of the arxiv identifier
			Series = '';														-- unset
			deprecated_parameter ('version');									-- deprecated parameter but only for cite arxiv
		end
		
		if first_set ({AccessDate, At, Chapter, Format, Page, Pages, Periodical, PublisherName, URL,	-- a crude list of parameters that are not supported by cite arxiv
			ID_list['ASIN'], ID_list['BIBCODE'], ID_list['DOI'], ID_list['ISBN'], ID_list['ISSN'],
			ID_list['JFM'], ID_list['JSTOR'], ID_list['LCCN'], ID_list['MR'], ID_list['OCLC'], ID_list['OL'],
			ID_list['OSTI'], ID_list['PMC'], ID_list['PMID'], ID_list['RFC'], ID_list['SSRN'], ID_list['USENETID'], ID_list['ZBL']},27) then
				table.insert( z.message_tail, { set_error( 'arxiv_params_not_supported', {}, true ) } );		-- add error message

				AccessDate= '';													-- set these to empty string; not supported in cite arXiv
				PublisherName = '';												-- (if the article has been published, use cite journal, or other)
				Chapter = '';
				URL = '';
				Format = '';
				Page = ''; Pages = ''; At = '';
		end
		Periodical = 'arXiv';													-- set to arXiv for COinS; after that, must be set to empty string
	end

-- handle type parameter for those CS1 citations that have default values
	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
	TitleType = substitute( cfg.messages['type'], TitleType);					-- display it in parentheses
	end

-- legacy: promote concatenation of |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	do	-- create defined block to contain local variables error_message and mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		anchor_year, error_message = dates({['access-date']=AccessDate, ['archive-date']=ArchiveDate, ['date']=Date, ['doi-broken-date']=DoiBroken,
			['embargo']=Embargo, ['lay-date']=LayDate, ['publication-date']=PublicationDate, ['year']=Year}, COinS_date);

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end

		if is_set(error_message) then
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end
	end	-- end of do

-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);											-- 

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
			if 'episode' == config.CitationClass then							-- special case for cite episode; TODO: is there a better way to do this?
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
			else
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
			end
	end
	
	if 'none' == Title and in_array (config.CitationClass, {'journal', 'citation'}) and is_set (Periodical) and 'journal' == A:ORIGIN('Periodical') then	-- special case for journal cites
		Title = '';																-- set title to empty string
		add_maint_cat ('untitled');
	end

	check_for_url ({															-- add error message when any of these parameters contains a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[A:ORIGIN('Periodical')]=Periodical,
		[A:ORIGIN('PublisherName')] = PublisherName,
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = Periodical,
		['Encyclopedia'] = Encyclopedia,
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Map'] = Map,
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

-- Account for the oddities that are {{cite arxiv}}, AFTER generation of COinS data.
	if 'arxiv' == config.CitationClass then										-- we have set rft.jtitle in COinS to arXiv, now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in cite arxiv; if article has been published, use cite journal
	end

-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = substitute (cfg.messages['newsgroup'], external_link( 'news:' .. PublisherName, PublisherName, A:ORIGIN('PublisherName') ));
		end
	end



	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local maximum;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text											-- get current page name so that we don't wikilink to it via editorlinkn
		};

		do																		-- do editor name list first because coauthors can modify control table
			maximum , editor_etal = get_display_authors_editors (A['DisplayEditors'], #e, 'editors', editor_etal);
			-- Preserve old-style implicit et al.
			if not is_set(maximum) and #e == 4 then 
				maximum = 3;
				table.insert( z.message_tail, { set_error('implict_etal_editor', {}, true) } );
			end

			control.maximum = maximum;
			
			last_first_list, EditorCount = list_people(control, e, editor_etal, 'editor');

			if is_set (Editors) then
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
					EditorCount = 2;											-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
				else
					EditorCount = 2;											-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
				end
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do translators
			control.maximum = #t;												-- number of translators
			Translators = list_people(control, t, false, 'translator');			-- et al not currently supported
		end
		do																		-- now do contributors
			control.maximum = #c;												-- number of contributors
			Contributors = list_people(control, c, false, 'contributor');		-- et al not currently supported
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_authors_editors (A['DisplayAuthors'], #a, 'authors', author_etal);

			if is_set(Coauthors) then											-- if the coauthor field is also used, prevent ampersand and et al. formatting.
				control.lastauthoramp = nil;
				control.maximum = #a + 1;
			end
			
			last_first_list = list_people(control, a, author_etal, 'author');

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false);	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do

		if not is_set(Authors) and is_set(Coauthors) then						-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
			table.insert( z.message_tail, { set_error('coauthors_missing_author', {}, true) } );	-- emit error message
		end
	end

-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

-- special case for chapter format so no error message or cat when chapter not supported
	if not (in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if  not is_set(URL) then --and
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then		-- Test if cite web or cite podcast |url= is missing or empty 
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- Test if accessdate is given without giving a URL
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when the others are not set; TODO: move this to a separate test?
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURLorigin, OriginalFormat;						-- TODO: swap chapter and title here so that archive applies to most specific if both are set?
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURLorigin = URLorigin;										-- name of url parameter for error messages
			OriginalFormat = Format;											-- and original |format=
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
			end
		elseif is_set (ChapterURL) then 										-- URL not set so if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURLorigin = ChapterURLorigin;								-- name of chapter-url parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |format=
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				ChapterURLorigin = A:ORIGIN('ArchiveURL')						-- name of archive-url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
			end
		end
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'arxiv'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			local chap_param;
			if is_set (Chapter) then											-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif is_set (ScriptChapter) then
				chap_param = A:ORIGIN ('ScriptChapter')
			else is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if is_set (chap_param) then											-- if we found one
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {chap_param}, true ) } );		-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if is_set (Contribution) and 0 &lt; #c then								-- if this is a contribution with contributor(s)
			if in_array (Contribution:lower(), cfg.keywords.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, Chapter, TransChapter, ChapterURL, ChapterURLorigin, no_quotes);		-- Contribution is also in Chapter
		if is_set (Chapter) then
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;
			end
			Chapter = Chapter .. ChapterFormat .. sepc .. ' ';
		elseif is_set (ChapterFormat) then										-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'mailinglist', 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
	
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then 
			Title = external_link( URL, Title, URLorigin ) .. TransError .. Format;
			URL = &quot;&quot;;
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURLorigin );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if is_set(Minutes) then
			if is_set (Time) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'minutes') .. ' and ' .. wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
		Others = sepc .. ' Translated by ' .. Translators .. Others; 
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

--[[
Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
note is displayed. There are no error messages for this condition.

]]
	if is_set (SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif is_set (RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if 'citation', lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text
																				-- neither of these work; don't know why; it seems that substitute() isn't being called	
		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then				-- if first and last characters of quote are quote marks
			Quote = Quote:sub(2,-2);											-- strip them off
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL') ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- DeadURL is empty, 'yes', 'true', 'y', 'unfit', 'usurped'
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if in_array (DeadURL, {'unfit', 'usurped'}) then
				Archived = sepc .. &quot; &quot; .. 'Archived from the original on ' .. ArchiveDate;	-- format already styled
			else																-- DeadURL is empty, 'yes', 'true', or 'y'
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURLorigin ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL') ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL') ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURLorigin );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin );
	end

	local Publisher;
	if is_set(Periodical) and
		not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap_msg ('published', PublicationDate);
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap_msg ('published', PublicationDate) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
			Language, Edition, Publisher, Agency, Volume}, sepc );
		
	elseif in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(Periodical) then		-- special cases for book cites
		if is_set (Contributors) then											-- when we are citing foreword, preface, introduction, etc
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Transcript, Language, Edition, Publisher}, sepc );
	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if is_set(Date) then
		if is_set (Authors) or is_set (Editors) then							-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;;				-- in paranetheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon,-1,-1) == sepc) then							-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigYear;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigYear;							-- Date begins with sepc
			end
		end
	end	
	if is_set(Authors) then
		if is_set(Coauthors) then
			if 'vanc' == NameListFormat then									-- separate authors and coauthors with proper name-list-separator
				Authors = Authors .. ', ' .. Coauthors;
			else
				Authors = Authors .. '; ' .. Coauthors;
			end
		end
		if not is_set (Date) then												-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then in_text = in_text:lower() end				-- lowercase for cs2
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if is_set (Contributors) then											-- book cite and we're citing the intro, preface, etc
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if is_set (Editors) then											-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if not is_set (Date) then											-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = config.CitationClass;
		options.class = &quot;citation &quot; .. config.CitationClass;					-- class=citation required for blue highlight when used with |ref=
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then								-- set reference anchor if appropriate
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
--			local year = first_set (Year, anchor_year);							-- Year first for legacy citations and for YMD dates that require disambiguation
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			id = anchor_id (namelist, year);									-- go make the CITEREF anchor
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then 
		text = '&lt;cite id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/cite&gt;&quot;;
	else
		text = '&lt;cite class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/cite&gt;&quot;;
	end		

	local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
	
	-- Note: Using display: none on the COinS span breaks some clients.
	local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
	text = text .. OCinS;
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. error_comment( v[1], v[2] );
				else
					text = text .. error_comment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end

	if #z.maintenance_cats ~= 0 then
		text = text .. '&lt;span class=&quot;citation-comment&quot; style=&quot;display:none; color:#33aa33&quot;&gt;';
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. ' ' .. v .. ' ([[:Category:' .. v ..'|link]])';
		end
		text = text .. '&lt;/span&gt;';	-- maintenance mesages (realy just the names of the categories for now)
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the first match.

Sometime after this module is done with rendering a citation, some C0 control characters are replaced with the
replacement character.  That replacement character is not detected by this test though it is visible to readers
of the rendered citation.  This function will detect the replacement character when it is part of the wikisource.

Output of this function is an error message that identifies the character or the Unicode group that the character
belongs to along with its position in the parameter value.

]]
--[[
local function has_invisible_chars (param, v)
	local position = '';
	local i=1;

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		v = mw.text.unstripNoWiki( v );											-- remove nowiki stripmarkers
		position = mw.ustring.find (v, pattern)									-- see if the parameter value contains characters that match the pattern
		if position then
			table.insert( z.message_tail, { set_error( 'invisible_char', {char, wrap_style ('parameter', param), position}, true ) } );	-- add error message
			return;																-- and done with this parameter
		end
		i=i+1;																	-- bump our index
	end
end
]]

--[[--------------------------&lt; Z . C I T A T I O N &gt;----------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

function z.citation(frame)
	local pframe = frame:getParent()
	local validation;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of Configuration and Whitelist and ...
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');	-- ... sandbox version of date validation code

	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of Configuration and Whitelist and ...
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		validation = require ('Module:Citation/CS1/Date_validation');			-- ... live version of date validation code
	end

	dates = validation.dates;													-- imported functions
	year_date_check = validation.year_date_check;

	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute( param, capture );				-- add the capture to the suggested parameter (typically the enumerator)
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, param}, true );	-- set the error message
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);
		end
	end
	return citation0( config, args)
end

return z</text>
      <sha1>oyu2e3b7r162g2dy8wzmplqoij0lo12</sha1>
    </revision>
    <revision>
      <id>4702</id>
      <parentid>4701</parentid>
      <timestamp>2016-01-16T13:07:02Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4702</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="139271" sha1="cd9vsiqqinhjwttmtwbudaagqvsheb3" xml:space="preserve">
local cs1 ={};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local dates, year_date_check, reformat_dates									-- functions in Module:Citation/CS1/Date_validation

local is_set, in_array, substitute, error_comment, set_error, select_one,		-- functions in Module:Citation/CS1/Utilities
	add_maint_cat, wrap_style, safe_for_italics, remove_wiki_link;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local extract_ids, build_id_list, is_embargoed;									-- functions in Module:Citation/CS1/Identifiers

local make_coins_title, get_coins_pages, COinS;									-- functions in Module:Citation/CS1/COinS

local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist

--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end

--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

]]

local added_prop_cats = {}														-- list of property categories that have been added to z.properties_cats
local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));		-- make name then add to table
	end
end

--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

]]

local added_vanc_errs;															-- flag so we only emit one Vancouver error / category
local function add_vanc_error ()
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a uri scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of tlds: https://www.iana.org/domains/root/db

rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the tld.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a url with a scheme) will be stripped
here.  Perhaps not necessary but retained incase it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	single-letter/digit second-level domains in the .org TLD
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and tld or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%a%d]') then										-- first character must be letter or digit
		return false;
	end
																				-- Do most common case first
	if domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.%a%a+$') then			    -- three or more character hostname.hostname or hostname.tld
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.org$') then							-- one character .org hostname
		return true;
	elseif domain:match ('%f[%a][qxz]%.com$') then								-- assigned one character .com hostname (x.com times out 2015-12-10)
		return true;
	elseif domain:match ('%f[%a][iq]%.net$') then								-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.%a%a$') then							-- one character hostname and cctld (2 chars)
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d]%.%a%a+$') then					-- two character hostname and tld
		return true;
	elseif domain:match ('^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?') then		-- IPv4 address
		return true;
	else
		return false;
	end
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a url appear to be a valid url; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if is_set (scheme) then														-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when url is protocol relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a url into a scheme, authority indicator, and domain.
If protocol relative url, return nil scheme and domain else return nil for both scheme and domain.

When not protocol relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?/.*$', '%1');							-- strip FQDN terminator and path (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol relative url
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		authority = authority:gsub ('//', '', 1);								-- replace place 1 pair of '/' with nothing;
		if is_set(authority) then												-- if anything left (1 or 3+ '/' where authority should be) then
			return scheme;														-- return scheme only making domain nil which will cause an error message
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link= etc for properly formatted content: no wikilinks, no urls

Link parameters are to hold the title of a wikipedia article so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki urls and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid url (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid url (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from url; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid url
end

--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wikilinked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

]]

local function link_title_ok (link, lorig, title, torig)
local orig;

	if is_set (link) then 														-- don't bother if link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif not link_param_ok (title) then									-- check |&lt;title&gt;-link= markup
			orig = torig;														-- identify the failing link parameter
		end
	end

	if is_set (orig) then
		table.insert( z.message_tail, { set_error( 'bad_paramlink', orig)});	-- url or wikilink in |title= with |title-link=;
	end
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the url into scheme and domain
portions, or for protocol relative (//example.com) urls, just the domain.  Use is_url() to validate the two
portions of the url.  If both are valid, or for protocol relative if domain is valid, return true, else false.

Because it is different from a standard url, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper url
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from url;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a url.  The test will also find external wikilinks
that use protocol relative urls. Also finds bare urls.

The frontier pattern prevents a match on interwiki links which are similar to scheme:path urls.  The tests that
find bracketed urls are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol relative ext wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare url with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol relative bare url: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a url
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then												-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source )
	local error_str = &quot;&quot;;
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url( label ), &quot;]&quot;, error_str });
end

--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

]]

local page_in_deprecated_cat;													-- sticky flag so that the category is added only once
local function deprecated_parameter(name)
	if not page_in_deprecated_cat then
		page_in_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end

--[[--------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Call this function for chapter titles, for website titles, etc; not for book titles.

]]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	
	cap, cap2 = str:match (&quot;^([\&quot;\'])([^\'].+)&quot;);								-- match leading double or single quote but not double single quotes
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-left'], {cap, cap2});
	end

	cap, cap2 = str:match (&quot;^(.+[^\'])([\&quot;\'])$&quot;)
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-right'], {cap, cap2});
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title= and |script-chapter=

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, {'am', 'ar', 'bg', 'bs', 'dv', 'el', 'fa', 'he', 'hy', 'ja', 'ka', 'ko', 'ku', 'mk', 'ml', 'ps', 'ru', 'sd', 'sr', 'th', 'uk', 'ug', 'yi', 'zh'}) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				add_prop_cat ('script')
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return substitute( msg, str );										-- including template text
	else
		return substitute( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (scriptchapter, chapter, transchapter, chapterurl, chapter_url_source, no_quotes)
	local chapter_error = '';
	
	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);										-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
			chapter = wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, scriptchapter)						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (transchapter) then
		transchapter = wrap_style ('trans-quoted-title', transchapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. transchapter;
		else																	-- here when transchapter without chapter or script-chapter
			chapter = transchapter;												-- 
			chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
		end
	end

	if is_set (chapterurl) then
		chapter = external_link (chapterurl, chapter, chapter_url_source);		-- adds bare_url_missing_title error if appropriate
	end

	return chapter .. chapter_error;
end

--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Detects but ignores the character pattern that results from the transclusion of {{'}} templates.

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i=1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- Test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position then
--			if 'nowiki' == capture or 'math' == capture or ('ref' == capture and 'quote' == param) then 	-- nowiki, math, or quote param and ref stripmarker (not an error condition)
			if 'nowiki' == capture or 'math' == capture then 					-- nowiki, math stripmarker (not an error condition)
				stripmarker = true;												-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			elseif 'apostrophe' == char then									-- apostrophe template uses &amp;zwj;, hair space and zero-width space
				apostrophe = true;
			elseif true == apostrophe and in_array (char, {'zero width joiner', 'zero width space', 'hair space'}) then
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { set_error( 'invisible_char', {err_msg, wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i=i+1;																	-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end

--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash

]]

local function hyphen_to_dash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if comp:sub(1,1) == duplicate_char then								-- is first charactier same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for th
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = str:sub(-1,-1);										-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = str:sub(1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = str:sub(1, -4) .. &quot;''&quot;;							-- remove them and add back ''
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then		-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then		-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then			-- if last two chars of str are sepc] external link
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;'']&quot; then		-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then				-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = str:sub(1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end		-- if duplicate_char not a letter then escape it
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )			-- remove duplicate_char if it follows html markup
					else
						value = value:sub( 2, -1 );								-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end  

--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

At the time of this writing, I had to write the 'if nil == mw.ustring.find ...' test ouside of the code editor and paste it here
because the code editor gets confused between character insertion point and cursor position.

]]

local function is_good_vanc_name (last, first)
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]*$&quot;) then
		add_vanc_error ();
		return false;															-- not a string of latin characters; Vancouver required Romanization
	end;
	return true;
end

--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  This form is not
currently supported by this code so correctly formed names like Smith JL 2nd are converted to Smith J2. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	if mw.ustring.match(first, &quot;^%u%u$&quot;) then return first end;					-- when first contains just two upper-case letters, nothing to do
	local initials = {}
	local i = 0;																-- counter for number of initials
	for word in mw.ustring.gmatch(first, &quot;[^%s%.%-]+&quot;) do						-- names separated by spaces, hyphens, or periods
		table.insert(initials, mw.ustring.sub(word,1,1))						-- Vancouver format does not include full stops.
		i = i + 1;																-- bump the counter 
		if 2 &lt;= i then break; end												-- only two initials allowed in Vancouver system; if 2, quit
	end
	return table.concat(initials)												-- Vancouver format does not include spaces.
end

--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal, list_name)					-- TODO: why is list_name here?  not used in this function
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = ',';																-- name-list separator between authors is a comma
		namesep = ' ';															-- last/first separator is a space
	else
		sep = ';'																-- name-list separator between authors is a semicolon
		namesep = ', '															-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then					-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first 
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;				-- link author/editor if this page is not the author's/editor's page
				end
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end

--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]
local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of author and editor name parameters for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the parameters |display-authors=etal or |display-editors=etal

]]

local function name_has_etal (name, etal, nocat)

	if is_set (name) then														-- name can be nil in which case just return
		local etal_pattern = &quot;[;,]? *[\&quot;']*%f[%a][Ee][Tt] *[Aa][Ll][%.\&quot;']*$&quot;	-- variations on the 'et al' theme
		local others_pattern = &quot;[;,]? *%f[%a]and [Oo]thers&quot;;					-- and alternate to et al.
		
		if name:match (etal_pattern) then										-- variants on et al.
			name = name:gsub (etal_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		elseif name:match (others_pattern) then									-- if not 'et al.', then 'and others'?
			name = name:gsub (others_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		end
	end
	return name, etal;															-- 
end

--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary
	while true do
		last = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false);								-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false);								-- find and remove variations on et al.

		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			link_title_ok (link, list_name:match (&quot;(%w+)List&quot;):lower() .. '-link' .. i, last, list_name:match (&quot;(%w+)List&quot;):lower() .. '-last' .. i);	-- check for improper wikimarkup

			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 code.  Handles the special case that is Norwegian where
ISO639-1 code 'no' is mapped to language name 'Norwegian Bokmål' by Extention:CLDR.

Returns the language name and associated ISO639-1 code.  Because case of the source may be incorrect or different from the case that Wikimedia
uses, the name comparisons are done in lower case and when a match is found, the Wikimedia version (assumed to be correct) is returned along
with the code.  When there is no match, we return the original language name string.

mw.language.fetchLanguageNames() will return a list of languages that aren't part of ISO639-1. Names that aren't ISO639-1 but that are included
in the list will be found if that name is provided in the |language= parameter.  For example, if |language=Samaritan Aramaic, that name will be
found with the associated code 'sam', not an ISO639-1 code.  When names are found and the associated code is not two characters, this function
returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang)
	if 'norwegian' == lang:lower() then											-- special case related to Wikimedia remap of code 'no' at Extension:CLDR
		return 'Norwegian', 'no';												-- Make sure rendered version is properly capitalized
	end
	
	local languages = mw.language.fetchLanguageNames('en', 'all')				-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() then												-- ISO639-1 codes only
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the ISO639-1 code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for ISO639-1 code
end

--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Get language name from ISO639-1 code value provided.  If a code is valid use the returned name; if not, then use the value that was provided with the language parameter.

There is an exception.  There are three ISO639-1 codes for Norewegian language variants.  There are two official variants: Norwegian Bokmål (code 'nb') and
Norwegian Nynorsk (code 'nn').  The third, code 'no',  is defined by ISO639-1 as 'Norwegian' though in Norway this is pretty much meaningless.  However, it appears
that on enwiki, editors are for the most part unaware of the nb and nn variants (compare page counts for these variants at Category:Articles with non-English-language external links.

Because Norwegian Bokmål is the most common language variant, Media wiki has been modified to return Norwegian Bokmål for ISO639-1 code 'no'. Here we undo that and
return 'Norwegian' when editors use |language=no.  We presume that editors don't know about the variants or can't descriminate between them.

See Help talk:Citation Style_1#An ISO 639-1 language name test

When |language= contains a valid ISO639-1 code, the page is assigned to the category for that code: Category:Norwegian-language sources (no) if
the page is a mainspace page and the ISO639-1 code is not 'en'.  Similarly, if the  parameter is |language=Norwegian, it will be categorized in the same way.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the ISO639-1 two character code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang

		if lang:match ('^%a%a%-') then											-- strip ietf language tags from code
			lang = lang:match ('(%a%a)%-')										-- keep only 639-1 code portion to lang; TODO: do something with 3166 alpha 2 country code?
		end
		if 2 == lang:len() then													-- ISO639-1 language code are 2 characters (fetchLanguageName also supports 3 character codes)
			name = mw.language.fetchLanguageName( lang:lower(), &quot;en&quot; );			-- get ISO 639-1 language name if Language is a proper code
		end
	
		if is_set (name) then													-- if Language specified a valid ISO639-1 code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang);								-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then
			if 'no' == code then name = 'Norwegian' end;						-- override wikimedia when code is 'no'
			if 'en' ~= code then												-- English not the language
				add_prop_cat ('foreign_lang_source', {name, code})
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, ' and ')							-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		language_list[code] = 'and ' .. language_list[code];					-- prepend last name with 'and&lt;space&gt;'
		name = table.concat (language_list, ', ')								-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
	end
	if 'English' == name then
		return '';																-- if one language and that language is English return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
end

--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = '.';																-- terminate the rendered citation with a period
	end
	return '.', ps;																-- separator is a full stop
end

--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = '';																-- make sure it isn't nil
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return ',', ps, ref;														-- separator is a comma
end

--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end

--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extension, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf[%?#]?') or url:match ('%.PDF[%?#]?');
end

--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parenthases, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end

--[[--------------------------&lt; G E T _ D I S P L A Y _ A U T H O R S _ E D I T O R S &gt;------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_authors_editors (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_auth_ed', list_name);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end

--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
--	local good_pattern = '^P[^%.P%l]';
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
--	local bad_pattern = '^[Pp][Pp]';
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
--		if Page:match ('^[Pp]?[Pp]%.?[ %d]') or  Page:match ('^[Pp]ages?[ %d]') or
--			Pages:match ('^[Pp]?[Pp]%.?[ %d]') or  Pages:match ('^[Pp]ages?[ %d]') then
--				add_maint_cat ('extra_text');
--		end
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	if vparam:find ('%[%[') or vparam:find ('%]%]')	then						-- no wikilinking vauthors names
		add_vanc_error ();
	end
	v_name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;)								-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parenthese to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')
			corporate = true;
		elseif string.find(v_name, &quot;%s&quot;) then
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
			last  = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') or mw.ustring.match (v_name, ' %u %u$') then
				add_vanc_error ();												-- matches last II last; the case when a comma is missing or a space between two intiials
			end
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) and not mw.ustring.match (first, &quot;^%u?%u$&quot;) then		-- first shall contain one or two upper-case letters, nothing else
			add_vanc_error ();
		end
																				-- this from extract_names ()
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice incase we have a first 1 without a last1
		select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, no, etc).  When the parameter value has not been assigned a value (missing or empty
in the source template) the function refurns true.  If the parameter value is one of the list of allowed values returns
true; else, emits an error message and returns false.

]]

local function is_valid_parameter_value (value, name, possible)
	if not is_set (value) then
		return true;															-- an empty parameter is ok
	elseif in_array(value:lower(), possible) then
		return true;
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list,-1,-1) == sepc) or (string.sub (name_list,-3,-1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terninate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not is_set (volume) and not is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end
	
	local vol = '';
		
	if is_set (volume) then
		if (4 &lt; mw.ustring.len(volume)) then
			vol = substitute (cfg.messages['j-vol'], {sepc, volume});
		else
			vol = wrap_style ('vol-bold', hyphen_to_dash(volume));
		end
	end
	if is_set (issue) then
		return vol .. substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end






--[[-------------------------&lt; N O R M A L I Z E _ P A G E _ L I S T &gt;-----------------------------------------

not currently used

normalizes a comma, ampersand, and/or space separated list to be '&lt;value&gt;, &lt;value&gt;, ..., &lt;value&gt;'
returns list unchanged if there are no commas else strips whitespace and then reformats the list

]]
--[[
local function normalize_page_list (list)
	if not list:find ('[,&amp; ]') then return list end								-- if list is not delimited with commas, ampersands, or spaces; done
	
	list = mw.text.split (list, '[,&amp;%s]+');										-- make a table of values
	list = table.concat (list, ', ');											-- and now make a normalized list
	return list;
end
]]

--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'journal' == origin);

	if is_set (page) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif is_set(pages) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then										-- if pages is only digits, assume a single page number
			return '', substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end

--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
		end
		if is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
		end
	end

	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list
	local Contribution = A['Contribution'];
	if in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not is_set (Contribution) then									-- |contributor= requires |contribution=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if select_one (args, cfg.aliases['ContributorList-Last'], 'redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { set_error( 'contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if not is_valid_parameter_value (NameListFormat, 'name-list-format', cfg.keywords['name-list-format']) then			-- only accepted value for this parameter is 'vanc'
		NameListFormat = '';													-- anything else, set to empty string
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
			link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wikimarkup in |title-link= or wikimarkup in |title= when |title-link= is set

	local Chapter = A['Chapter'];
	local ScriptChapter = A['ScriptChapter'];
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];
	local ArchiveURL = A['ArchiveURL'];
	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];
	local Periodical_origin = A:ORIGIN('Periodical');							-- get the name of the periodical parameter

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if in_array (config.CitationClass, cfg.templates_using_volume) and not ('conference' == config.CitationClass and not is_set (Periodical)) then
		Volume = A['Volume'];
	end
	if in_array (config.CitationClass, cfg.templates_using_issue) and not (in_array (config.CitationClass, {'conference', 'map'}) and not is_set (Periodical))then
		Issue = A['Issue'];
	end
	local Position = '';
	if not in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash( A['Pages'] );	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
		if not is_valid_parameter_value (RegistrationRequired, 'registration', cfg.keywords ['yes_true_y']) then
			RegistrationRequired=nil;
		end
	local SubscriptionRequired = A['SubscriptionRequired'];
		if not is_valid_parameter_value (SubscriptionRequired, 'subscription', cfg.keywords ['yes_true_y']) then
			SubscriptionRequired=nil;
		end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local ArchiveDate = A['ArchiveDate'];
	local Agency = A['Agency'];
	local DeadURL = A['DeadURL']
		if not is_valid_parameter_value (DeadURL, 'dead-url', cfg.keywords ['deadurl']) then	-- set in config.defaults to 'yes'
			DeadURL = '';														-- anything else, set to empty string
		end

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
		if not is_valid_parameter_value (IgnoreISBN, 'ignore-isbn-error', cfg.keywords ['yes_true_y']) then
			IgnoreISBN = nil;													-- anything else, set to empty string
		end
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
		if not is_valid_parameter_value (LastAuthorAmp, 'last-author-amp', cfg.keywords ['yes_true_y']) then
			LastAuthorAmp = nil;													-- set to empty string
		end
	local no_tracking_cats = A['NoTracking'];
		if not is_valid_parameter_value (no_tracking_cats, 'no-tracking', cfg.keywords ['yes_true_y']) then
			no_tracking_cats = nil;												-- set to empty string
		end

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = A['DF'];															-- date format set in cs1|2 template
	if not is_valid_parameter_value (DF, 'df', cfg.keywords['date-format']) then	-- validate reformatting keyword
		DF = '';																-- not valid, set to empty string
	end

-- set default parameter values defined by |mode= parameter.  If |mode= is empty or omitted, use CitationClass to set these values
	local Mode = A['Mode'];
	if not is_valid_parameter_value (Mode, 'mode', cfg.keywords['mode']) then
		Mode = '';
	end
	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	select_one( args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'redundant_parameters' );		-- this is a dummy call simply to get the error message and category

	local NoPP = A['NoPP'] 
	if is_set (NoPP) and is_valid_parameter_value (NoPP, 'nopp', cfg.keywords ['yes_true_y']) then
		NoPP = true;
	else
		NoPP = nil;																-- unset, used as a flag later
	end

	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Pages = '';															-- unset the others
			At = '';
		end
		extra_text_in_page_check (Page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.
	elseif is_set(Pages) then
		if is_set(At) then
			At = '';															-- unset
		end
		extra_text_in_page_check (Pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped
	|url maps to |chapterurl when |title is remapped

All other combinations of |encyclopedia, |title, and |article are not modified

]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					TransChapter = TransTitle;
					ChapterURL = URL;
					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter= '[[' .. TitleLink .. '|' .. Chapter .. ']]';
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			else																-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if is_set(A['Number']) then													-- cite techreport uses 'number', which other citations alias to 'issue'
			if not is_set(ID) then												-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];													-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', 'id') .. ' and ' .. wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Others) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Others;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Others;
			end
		else
			Others = '(Interview)';
		end
	end

-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	elseif 'mailinglist' == A:ORIGIN('Periodical') then
		Periodical = '';														-- unset because mailing list is only used for cite mailing list
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];

		link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wikimarkup in |series-link= or wikimarkup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) and is_set (AirDate) then							-- promote airdate to date
			Date = AirDate;
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('series', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = '[[' .. ChapterLink .. '|' .. Chapter .. ']]';		-- ok to wikilink
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = '[[' .. ChapterLink .. '|' .. Series .. ']]';			-- series links with ChapterLink (episodelink -&gt; TitleLink -&gt; ChapterLink) ugly
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = '[[' .. SeriesLink .. '|' .. Series .. ']]';
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
-- end of {{cite episode}} stuff

-- Account for the oddities that are {{cite arxiv}}, before generation of COinS data.
	if 'arxiv' == config.CitationClass then
		if not is_set (ID_list['ARXIV']) then									-- |arxiv= or |eprint= required for cite arxiv
			table.insert( z.message_tail, { set_error( 'arxiv_missing', {}, true ) } );		-- add error message
		elseif is_set (Series) then												-- series is an alias of version
			ID_list['ARXIV'] = ID_list['ARXIV'] .. Series;						-- concatenate version onto the end of the arxiv identifier
			Series = '';														-- unset
			deprecated_parameter ('version');									-- deprecated parameter but only for cite arxiv
		end
		
		if first_set ({AccessDate, At, Chapter, Format, Page, Pages, Periodical, PublisherName, URL,	-- a crude list of parameters that are not supported by cite arxiv
			ID_list['ASIN'], ID_list['BIBCODE'], ID_list['DOI'], ID_list['ISBN'], ID_list['ISSN'],
			ID_list['JFM'], ID_list['JSTOR'], ID_list['LCCN'], ID_list['MR'], ID_list['OCLC'], ID_list['OL'],
			ID_list['OSTI'], ID_list['PMC'], ID_list['PMID'], ID_list['RFC'], ID_list['SSRN'], ID_list['USENETID'], ID_list['ZBL']},27) then
				table.insert( z.message_tail, { set_error( 'arxiv_params_not_supported', {}, true ) } );		-- add error message

				AccessDate= '';													-- set these to empty string; not supported in cite arXiv
				PublisherName = '';												-- (if the article has been published, use cite journal, or other)
				Chapter = '';
				URL = '';
				Format = '';
				Page = ''; Pages = ''; At = '';
		end
		Periodical = 'arXiv';													-- set to arXiv for COinS; after that, must be set to empty string
	end

-- handle type parameter for those CS1 citations that have default values
	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
	TitleType = substitute( cfg.messages['type'], TitleType);					-- display it in parentheses
	end

-- legacy: promote concatenation of |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	do	-- create defined block to contain local variables error_message and mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		anchor_year, error_message = dates({['access-date']=AccessDate, ['archive-date']=ArchiveDate, ['date']=Date, ['doi-broken-date']=DoiBroken,
			['embargo']=Embargo, ['lay-date']=LayDate, ['publication-date']=PublicationDate, ['year']=Year}, COinS_date);

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end

		if is_set(error_message) then
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		elseif is_set (DF) then
			local date_parameters_list = {['access-date']=AccessDate, ['archive-date']=ArchiveDate, ['date']=Date, ['doi-broken-date']=DoiBroken,
				['embargo']=Embargo, ['lay-date']=LayDate, ['publication-date']=PublicationDate};
			
			if reformat_dates (date_parameters_list, DF, false) then			-- reformat to DF format, use long month names if appropriate
				AccessDate = date_parameters_list['access-date'];				-- overwrite date holding parameters with reformatted values
				ArchiveDate = date_parameters_list['archive-date'];				-- TODO: move all dates into this table at the beginning and ...
				Date = date_parameters_list['date'];							-- ... use them from this table? no in-and-out like we're doing here
				DoiBroken = date_parameters_list['doi-broken-date'];
				Embargo = date_parameters_list['embargo'];
				LayDate = date_parameters_list['lay-date'];
				PublicationDate = date_parameters_list['publication-date'];
			end
		end
	end	-- end of do

-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);											-- 

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
			if 'episode' == config.CitationClass then							-- special case for cite episode; TODO: is there a better way to do this?
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
			else
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
			end
	end
	
	if 'none' == Title and in_array (config.CitationClass, {'journal', 'citation'}) and is_set (Periodical) and 'journal' == A:ORIGIN('Periodical') then	-- special case for journal cites
		Title = '';																-- set title to empty string
		add_maint_cat ('untitled');
	end

	check_for_url ({															-- add error message when any of these parameters contains a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[A:ORIGIN('Periodical')]=Periodical,
		[A:ORIGIN('PublisherName')] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = Periodical,
		['Encyclopedia'] = Encyclopedia,
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

-- Account for the oddities that are {{cite arxiv}}, AFTER generation of COinS data.
	if 'arxiv' == config.CitationClass then										-- we have set rft.jtitle in COinS to arXiv, now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in cite arxiv; if article has been published, use cite journal
	end

-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = substitute (cfg.messages['newsgroup'], external_link( 'news:' .. PublisherName, PublisherName, A:ORIGIN('PublisherName') ));
		end
	end



	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
--		local maximum;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text											-- get current page name so that we don't wikilink to it via editorlinkn
		};

		do																		-- do editor name list first because coauthors can modify control table
			control.maximum , editor_etal = get_display_authors_editors (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal, 'editor');

			if is_set (Editors) then
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
					EditorCount = 2;											-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
				else
					EditorCount = 2;											-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
				end
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do translators
			control.maximum = #t;												-- number of translators
			Translators = list_people(control, t, false, 'translator');			-- et al not currently supported
		end
		do																		-- now do contributors
			control.maximum = #c;												-- number of contributors
			Contributors = list_people(control, c, false, 'contributor');		-- et al not currently supported
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_authors_editors (A['DisplayAuthors'], #a, 'authors', author_etal);

			if is_set(Coauthors) then											-- if the coauthor field is also used, prevent ampersand and et al. formatting.
				control.lastauthoramp = nil;
				control.maximum = #a + 1;
			end
			
			last_first_list = list_people(control, a, author_etal, 'author');

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false);	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if is_set (Authors) and is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

		if not is_set(Authors) and is_set(Coauthors) then						-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
			table.insert( z.message_tail, { set_error('coauthors_missing_author', {}, true) } );	-- emit error message
		end
	end

-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

-- special case for chapter format so no error message or cat when chapter not supported
	if not (in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if  not is_set(URL) then --and
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then		-- Test if cite web or cite podcast |url= is missing or empty 
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- Test if accessdate is given without giving a URL
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when the others are not set; TODO: move this to a separate test?
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURLorigin, OriginalFormat;						-- TODO: swap chapter and title here so that archive applies to most specific if both are set?
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURLorigin = URLorigin;										-- name of url parameter for error messages
			OriginalFormat = Format;											-- and original |format=
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
			end
		elseif is_set (ChapterURL) then 										-- URL not set so if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURLorigin = ChapterURLorigin;								-- name of chapter-url parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |format=
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				ChapterURLorigin = A:ORIGIN('ArchiveURL')						-- name of archive-url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
			end
		end
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'arxiv'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			local chap_param;
			if is_set (Chapter) then											-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif is_set (ScriptChapter) then
				chap_param = A:ORIGIN ('ScriptChapter')
			else is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if is_set (chap_param) then											-- if we found one
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {chap_param}, true ) } );		-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if is_set (Contribution) and 0 &lt; #c then								-- if this is a contribution with contributor(s)
			if in_array (Contribution:lower(), cfg.keywords.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, Chapter, TransChapter, ChapterURL, ChapterURLorigin, no_quotes);		-- Contribution is also in Chapter
		if is_set (Chapter) then
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;
			end
			Chapter = Chapter .. ChapterFormat .. sepc .. ' ';
		elseif is_set (ChapterFormat) then										-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'mailinglist', 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
	
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then 
			Title = external_link( URL, Title, URLorigin ) .. TransError .. Format;
			URL = &quot;&quot;;
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURLorigin );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if is_set(Minutes) then
			if is_set (Time) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'minutes') .. ' and ' .. wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
		Others = sepc .. ' Translated by ' .. Translators .. Others; 
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

--[[
Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
note is displayed. There are no error messages for this condition.

]]
	if is_set (SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif is_set (RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if 'citation', lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text
																				-- neither of these work; don't know why; it seems that substitute() isn't being called	
		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then				-- if first and last characters of quote are quote marks
			Quote = Quote:sub(2,-2);											-- strip them off
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL') ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- DeadURL is empty, 'yes', 'true', 'y', 'unfit', 'usurped'
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if in_array (DeadURL, {'unfit', 'usurped'}) then
				Archived = sepc .. &quot; &quot; .. 'Archived from the original on ' .. ArchiveDate;	-- format already styled
			else																-- DeadURL is empty, 'yes', 'true', or 'y'
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURLorigin ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL') ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL') ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURLorigin );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin );
	end

	local Publisher;
	if is_set(Periodical) and
		not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap_msg ('published', PublicationDate);
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap_msg ('published', PublicationDate) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
			Language, Edition, Publisher, Agency, Volume}, sepc );
		
	elseif in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(Periodical) then		-- special cases for book cites
		if is_set (Contributors) then											-- when we are citing foreword, preface, introduction, etc
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Transcript, Language, Edition, Publisher}, sepc );
	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if is_set(Date) then
		if is_set (Authors) or is_set (Editors) then							-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;;				-- in paranetheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon,-1,-1) == sepc) then							-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigYear;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigYear;							-- Date begins with sepc
			end
		end
	end	
	if is_set(Authors) then
		if is_set(Coauthors) then
			if 'vanc' == NameListFormat then									-- separate authors and coauthors with proper name-list-separator
				Authors = Authors .. ', ' .. Coauthors;
			else
				Authors = Authors .. '; ' .. Coauthors;
			end
		end
		if not is_set (Date) then												-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then in_text = in_text:lower() end				-- lowercase for cs2
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if is_set (Contributors) then											-- book cite and we're citing the intro, preface, etc
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if is_set (Editors) then											-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if not is_set (Date) then											-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = config.CitationClass;
		options.class = &quot;citation &quot; .. config.CitationClass;					-- class=citation required for blue highlight when used with |ref=
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then								-- set reference anchor if appropriate
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			id = anchor_id (namelist, year);									-- go make the CITEREF anchor
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then 
		text = '&lt;cite id=&quot;' .. mw.uri.anchorEncode(options.id) ..'&quot; class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/cite&gt;&quot;;
	else
		text = '&lt;cite class=&quot;' .. mw.text.nowiki(options.class) .. '&quot;&gt;' .. text .. &quot;&lt;/cite&gt;&quot;;
	end		

	local empty_span = '&lt;span style=&quot;display:none;&quot;&gt;&amp;nbsp;&lt;/span&gt;';
	
	-- Note: Using display: none on the COinS span breaks some clients.
	local OCinS = '&lt;span title=&quot;' .. OCinSoutput .. '&quot; class=&quot;Z3988&quot;&gt;' .. empty_span .. '&lt;/span&gt;';
	text = text .. OCinS;
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. error_comment( v[1], v[2] );
				else
					text = text .. error_comment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end

	if #z.maintenance_cats ~= 0 then
		text = text .. '&lt;span class=&quot;citation-comment&quot; style=&quot;display:none; color:#33aa33&quot;&gt;';
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. ' ' .. v .. ' ([[:Category:' .. v ..'|link]])';
		end
		text = text .. '&lt;/span&gt;';	-- maintenance mesages (realy just the names of the categories for now)
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

--[[--------------------------&lt; C S 1 . C I T A T I O N &gt;------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

function cs1.citation(frame)
	local pframe = frame:getParent()
	local validation, utilities, identifiers, metadata;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (utilities);								-- so that functions in Date validataion can see the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	dates = validation.dates;													-- imported functions from Module:Citation/CS1/Date validation
	year_date_check = validation.year_date_check;
	reformat_dates = validation.reformat_dates;
	
	is_set = utilities.is_set;													-- imported functions from Module:Citation/CS1/Utilities
	in_array = utilities.in_array;
	substitute = utilities.substitute;
	error_comment = utilities.error_comment;
	set_error = utilities.set_error;
	select_one = utilities.select_one;
	add_maint_cat = utilities.add_maint_cat;
	wrap_style = utilities.wrap_style;
	safe_for_italics = utilities.safe_for_italics;
	remove_wiki_link = utilities.remove_wiki_link;

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	extract_ids = identifiers.extract_ids;										-- imported functions from Module:Citation/CS1/Utilities
	build_id_list = identifiers.build_id_list;
	is_embargoed = identifiers.is_embargoed;
	
	make_coins_title = metadata.make_coins_title;								-- imported functions from Module:Citation/CS1/COinS
	get_coins_pages = metadata.get_coins_pages;
	COinS = metadata.COinS;

	
	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute( param, capture );				-- add the capture to the suggested parameter (typically the enumerator)
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, param}, true );	-- set the error message
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);
		end
	end
	return citation0( config, args)
end

return cs1;</text>
      <sha1>cd9vsiqqinhjwttmtwbudaagqvsheb3</sha1>
    </revision>
    <revision>
      <id>4703</id>
      <parentid>4702</parentid>
      <timestamp>2016-02-20T11:35:27Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4703</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="138671" sha1="7qql2qcetvnc8lpft35vd3qbalbhe4e" xml:space="preserve">
local cs1 ={};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local dates, year_date_check, reformat_dates									-- functions in Module:Citation/CS1/Date_validation

local is_set, in_array, substitute, error_comment, set_error, select_one,		-- functions in Module:Citation/CS1/Utilities
	add_maint_cat, wrap_style, safe_for_italics, remove_wiki_link;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local extract_ids, build_id_list, is_embargoed;									-- functions in Module:Citation/CS1/Identifiers

local make_coins_title, get_coins_pages, COinS;									-- functions in Module:Citation/CS1/COinS

local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist

--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end

--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

]]

local added_prop_cats = {}														-- list of property categories that have been added to z.properties_cats
local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));		-- make name then add to table
	end
end

--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

]]

local added_vanc_errs;															-- flag so we only emit one Vancouver error / category
local function add_vanc_error ()
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a uri scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of tlds: https://www.iana.org/domains/root/db

rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the tld.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a url with a scheme) will be stripped
here.  Perhaps not necessary but retained incase it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	single-letter/digit second-level domains in the .org TLD
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and tld or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%a%d]') then										-- first character must be letter or digit
		return false;
	end
																				-- Do most common case first
	if domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.%a%a+$') then			    -- three or more character hostname.hostname or hostname.tld
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.org$') then							-- one character .org hostname
		return true;
	elseif domain:match ('%f[%a][qxz]%.com$') then								-- assigned one character .com hostname (x.com times out 2015-12-10)
		return true;
	elseif domain:match ('%f[%a][iq]%.net$') then								-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.%a%a$') then							-- one character hostname and cctld (2 chars)
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d]%.%a%a+$') then					-- two character hostname and tld
		return true;
	elseif domain:match ('^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?') then		-- IPv4 address
		return true;
	else
		return false;
	end
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a url appear to be a valid url; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if is_set (scheme) then														-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when url is protocol relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a url into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following tld) (if any) and any path(/), query(?) or fragment(#).

If protocol relative url, return nil scheme and domain else return nil for both scheme and domain.

When not protocol relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol relative url
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		authority = authority:gsub ('//', '', 1);								-- replace place 1 pair of '/' with nothing;
		if is_set(authority) then												-- if anything left (1 or 3+ '/' where authority should be) then
			return scheme;														-- return scheme only making domain nil which will cause an error message
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link= etc for properly formatted content: no wikilinks, no urls

Link parameters are to hold the title of a wikipedia article so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki urls and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid url (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid url (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from url; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid url
end

--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wikilinked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

]]

local function link_title_ok (link, lorig, title, torig)
local orig;

	if is_set (link) then 														-- don't bother if link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing link parameter
		end
	end

	if is_set (orig) then
		table.insert( z.message_tail, { set_error( 'bad_paramlink', orig)});	-- url or wikilink in |title= with |title-link=;
	end
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the url into scheme and domain
portions, or for protocol relative (//example.com) urls, just the domain.  Use is_url() to validate the two
portions of the url.  If both are valid, or for protocol relative if domain is valid, return true, else false.

Because it is different from a standard url, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper url
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from url;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a url.  The test will also find external wikilinks
that use protocol relative urls. Also finds bare urls.

The frontier pattern prevents a match on interwiki links which are similar to scheme:path urls.  The tests that
find bracketed urls are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol relative ext wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare url with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol relative bare url: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a url
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then												-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source )
	local error_str = &quot;&quot;;
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url( label ), &quot;]&quot;, error_str });
end

--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

]]

local page_in_deprecated_cat;													-- sticky flag so that the category is added only once
local function deprecated_parameter(name)
	if not page_in_deprecated_cat then
		page_in_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end

--[[--------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Call this function for chapter titles, for website titles, etc; not for book titles.

]]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	
	cap, cap2 = str:match (&quot;^([\&quot;\'])([^\'].+)&quot;);								-- match leading double or single quote but not double single quotes
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-left'], {cap, cap2});
	end

	cap, cap2 = str:match (&quot;^(.+[^\'])([\&quot;\'])$&quot;)
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-right'], {cap, cap2});
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title= and |script-chapter=

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, {'am', 'ar', 'be', 'bg', 'bs', 'dv', 'el', 'fa', 'he', 'hy', 'ja', 'ka', 'ko', 'ku', 'mk', 'ml', 'ps', 'ru', 'sd', 'sr', 'th', 'uk', 'ug', 'yi', 'zh'}) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				add_prop_cat ('script')
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return substitute( msg, str );										-- including template text
	else
		return substitute( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (scriptchapter, chapter, transchapter, chapterurl, chapter_url_source, no_quotes)
	local chapter_error = '';
	
	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);										-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
			chapter = wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, scriptchapter)						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (transchapter) then
		transchapter = wrap_style ('trans-quoted-title', transchapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. transchapter;
		else																	-- here when transchapter without chapter or script-chapter
			chapter = transchapter;												-- 
			chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
		end
	end

	if is_set (chapterurl) then
		chapter = external_link (chapterurl, chapter, chapter_url_source);		-- adds bare_url_missing_title error if appropriate
	end

	return chapter .. chapter_error;
end

--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Detects but ignores the character pattern that results from the transclusion of {{'}} templates.

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i=1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- Test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position then
--			if 'nowiki' == capture or 'math' == capture or ('ref' == capture and 'quote' == param) then 	-- nowiki, math, or quote param and ref stripmarker (not an error condition)
			if 'nowiki' == capture or 'math' == capture then 					-- nowiki, math stripmarker (not an error condition)
				stripmarker = true;												-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			elseif 'apostrophe' == char then									-- apostrophe template uses &amp;zwj;, hair space and zero-width space
				apostrophe = true;
			elseif true == apostrophe and in_array (char, {'zero width joiner', 'zero width space', 'hair space'}) then
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { set_error( 'invisible_char', {err_msg, wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i=i+1;																	-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end

--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash

]]

local function hyphen_to_dash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if comp:sub(1,1) == duplicate_char then								-- is first charactier same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for th
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = str:sub(-1,-1);										-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = str:sub(1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = str:sub(1, -4) .. &quot;''&quot;;							-- remove them and add back ''
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then		-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then		-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then			-- if last two chars of str are sepc] external link
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;'']&quot; then		-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then				-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = str:sub(1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end		-- if duplicate_char not a letter then escape it
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )			-- remove duplicate_char if it follows html markup
					else
						value = value:sub( 2, -1 );								-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end  

--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

At the time of this writing, I had to write the 'if nil == mw.ustring.find ...' test ouside of the code editor and paste it here
because the code editor gets confused between character insertion point and cursor position.

]]

local function is_good_vanc_name (last, first)
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]*$&quot;) then
		add_vanc_error ();
		return false;															-- not a string of latin characters; Vancouver required Romanization
	end;
	return true;
end

--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  This form is not
currently supported by this code so correctly formed names like Smith JL 2nd are converted to Smith J2. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	if mw.ustring.match(first, &quot;^%u%u$&quot;) then return first end;					-- when first contains just two upper-case letters, nothing to do
	local initials = {}
	local i = 0;																-- counter for number of initials
	for word in mw.ustring.gmatch(first, &quot;[^%s%.%-]+&quot;) do						-- names separated by spaces, hyphens, or periods
		table.insert(initials, mw.ustring.sub(word,1,1))						-- Vancouver format does not include full stops.
		i = i + 1;																-- bump the counter 
		if 2 &lt;= i then break; end												-- only two initials allowed in Vancouver system; if 2, quit
	end
	return table.concat(initials)												-- Vancouver format does not include spaces.
end

--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal, list_name)					-- TODO: why is list_name here?  not used in this function
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = ',';																-- name-list separator between authors is a comma
		namesep = ' ';															-- last/first separator is a space
	else
		sep = ';'																-- name-list separator between authors is a semicolon
		namesep = ', '															-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then					-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first 
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;				-- link author/editor if this page is not the author's/editor's page
				end
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end

--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]
local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of author and editor name parameters for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the parameters |display-authors=etal or |display-editors=etal

]]

local function name_has_etal (name, etal, nocat)

	if is_set (name) then														-- name can be nil in which case just return
		local etal_pattern = &quot;[;,]? *[\&quot;']*%f[%a][Ee][Tt] *[Aa][Ll][%.\&quot;']*$&quot;	-- variations on the 'et al' theme
		local others_pattern = &quot;[;,]? *%f[%a]and [Oo]thers&quot;;					-- and alternate to et al.
		
		if name:match (etal_pattern) then										-- variants on et al.
			name = name:gsub (etal_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		elseif name:match (others_pattern) then									-- if not 'et al.', then 'and others'?
			name = name:gsub (others_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		end
	end
	return name, etal;															-- 
end

--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary
	while true do
		last = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false);								-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false);								-- find and remove variations on et al.

		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			link_title_ok (link, list_name:match (&quot;(%w+)List&quot;):lower() .. '-link' .. i, last, list_name:match (&quot;(%w+)List&quot;):lower() .. '-last' .. i);	-- check for improper wikimarkup

			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 code.

Returns the language name and associated ISO639-1 code.  Because case of the source may be incorrect or different from the case that Wikimedia
uses, the name comparisons are done in lower case and when a match is found, the Wikimedia version (assumed to be correct) is returned along
with the code.  When there is no match, we return the original language name string.

mw.language.fetchLanguageNames() will return a list of languages that aren't part of ISO639-1. Names that aren't ISO639-1 but that are included
in the list will be found if that name is provided in the |language= parameter.  For example, if |language=Samaritan Aramaic, that name will be
found with the associated code 'sam', not an ISO639-1 code.  When names are found and the associated code is not two characters, this function
returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	local languages = mw.language.fetchLanguageNames(this_wiki_code, 'all')		-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() then												-- ISO639-1 codes only
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the ISO639-1 code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for ISO639-1 code
end

--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Get language name from ISO639-1 code value provided.  If a code is valid use the returned name; if not, then use the value that was provided with the language parameter.

When |language= contains a valid ISO639-1 code, the page is assigned to the category for that code: Category:Norwegian-language sources (no) if
the page is a mainspace page and the ISO639-1 code is not the local wiki's language code.  Similarly, if the  parameter is |language=Norwegian,
it will be categorized in the same way.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the ISO639-1 two character code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki = mw.getContentLanguage();									-- get a language object for this wiki
	local this_wiki_code = this_wiki:getCode()									-- get this wiki's language code
	local this_wiki_name = mw.language.fetchLanguageName(this_wiki_code, this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang

		if lang:match ('^%a%a%-') then											-- strip ietf language tags from code
			lang = lang:match ('(%a%a)%-')										-- keep only 639-1 code portion to lang; TODO: do something with 3166 alpha 2 country code?
		end
		if 2 == lang:len() then													-- ISO639-1 language code are 2 characters (fetchLanguageName also supports 3 character codes)
			name = mw.language.fetchLanguageName( lang:lower(), this_wiki_code);			-- get ISO 639-1 language name if Language is a proper code
		end
	
		if is_set (name) then													-- if Language specified a valid ISO639-1 code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang);								-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then
			if this_wiki_code ~= code then										-- when the language is not the same as this wiki's language
				add_prop_cat ('foreign_lang_source', {name, code})				-- categorize it
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, ' and ')							-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		language_list[code] = 'and ' .. language_list[code];					-- prepend last name with 'and&lt;space&gt;'
		name = table.concat (language_list, ', ')								-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
	end
	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
end

--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = '.';																-- terminate the rendered citation with a period
	end
	return '.', ps;																-- separator is a full stop
end

--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = '';																-- make sure it isn't nil
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return ',', ps, ref;														-- separator is a comma
end

--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end

--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extension, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf[%?#]?') or url:match ('%.PDF[%?#]?');
end

--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parenthases, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end

--[[--------------------------&lt; G E T _ D I S P L A Y _ A U T H O R S _ E D I T O R S &gt;------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_authors_editors (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_auth_ed', list_name);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end

--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
--	local good_pattern = '^P[^%.P%l]';
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
--	local bad_pattern = '^[Pp][Pp]';
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
--		if Page:match ('^[Pp]?[Pp]%.?[ %d]') or  Page:match ('^[Pp]ages?[ %d]') or
--			Pages:match ('^[Pp]?[Pp]%.?[ %d]') or  Pages:match ('^[Pp]ages?[ %d]') then
--				add_maint_cat ('extra_text');
--		end
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

TODO: check for names like Coon V JS (Coon JS 5th at PMID 25205766, John S. Coon V at doi:10.1093/humupd/dmu048)?

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	if vparam:find ('%[%[') or vparam:find ('%]%]')	then						-- no wikilinking vauthors names
		add_vanc_error ();
	end
	v_name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;)								-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parenthese to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')
			corporate = true;
		elseif string.find(v_name, &quot;%s&quot;) then
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
			last  = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') or mw.ustring.match (v_name, ' %u %u$') then
				add_vanc_error ();												-- matches last II last; the case when a comma is missing or a space between two intiials
			end
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) and not mw.ustring.match (first, &quot;^%u?%u$&quot;) then		-- first shall contain one or two upper-case letters, nothing else
			add_vanc_error ();
		end
																				-- this from extract_names ()
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice incase we have a first 1 without a last1
		select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, no, etc).  When the parameter value has not been assigned a value (missing or empty
in the source template) the function refurns true.  If the parameter value is one of the list of allowed values returns
true; else, emits an error message and returns false.

]]

local function is_valid_parameter_value (value, name, possible)
	if not is_set (value) then
		return true;															-- an empty parameter is ok
	elseif in_array(value:lower(), possible) then
		return true;
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list,-1,-1) == sepc) or (string.sub (name_list,-3,-1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terninate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not is_set (volume) and not is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end
	
	local vol = '';
		
	if is_set (volume) then
		if (4 &lt; mw.ustring.len(volume)) then
			vol = substitute (cfg.messages['j-vol'], {sepc, volume});
		else
			vol = wrap_style ('vol-bold', hyphen_to_dash(volume));
		end
	end
	if is_set (issue) then
		return vol .. substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end






--[[-------------------------&lt; N O R M A L I Z E _ P A G E _ L I S T &gt;-----------------------------------------

not currently used

normalizes a comma, ampersand, and/or space separated list to be '&lt;value&gt;, &lt;value&gt;, ..., &lt;value&gt;'
returns list unchanged if there are no commas else strips whitespace and then reformats the list

]]
--[[
local function normalize_page_list (list)
	if not list:find ('[,&amp; ]') then return list end								-- if list is not delimited with commas, ampersands, or spaces; done
	
	list = mw.text.split (list, '[,&amp;%s]+');										-- make a table of values
	list = table.concat (list, ', ');											-- and now make a normalized list
	return list;
end
]]

--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'journal' == origin);

	if is_set (page) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif is_set(pages) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then										-- if pages is only digits, assume a single page number
			return '', substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end

--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
		end
		if is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
		end
	end

	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list
	local Contribution = A['Contribution'];
	if in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not is_set (Contribution) then									-- |contributor= requires |contribution=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if select_one (args, cfg.aliases['ContributorList-Last'], 'redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { set_error( 'contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if not is_valid_parameter_value (NameListFormat, 'name-list-format', cfg.keywords['name-list-format']) then			-- only accepted value for this parameter is 'vanc'
		NameListFormat = '';													-- anything else, set to empty string
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
			link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wikimarkup in |title-link= or wikimarkup in |title= when |title-link= is set

	local Chapter = A['Chapter'];
	local ScriptChapter = A['ScriptChapter'];
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];
	local ArchiveURL = A['ArchiveURL'];
	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];
	local Periodical_origin = A:ORIGIN('Periodical');							-- get the name of the periodical parameter

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if in_array (config.CitationClass, cfg.templates_using_volume) and not ('conference' == config.CitationClass and not is_set (Periodical)) then
		Volume = A['Volume'];
	end
	if in_array (config.CitationClass, cfg.templates_using_issue) and not (in_array (config.CitationClass, {'conference', 'map'}) and not is_set (Periodical))then
		Issue = A['Issue'];
	end
	local Position = '';
	if not in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash( A['Pages'] );	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
		if not is_valid_parameter_value (RegistrationRequired, 'registration', cfg.keywords ['yes_true_y']) then
			RegistrationRequired=nil;
		end
	local SubscriptionRequired = A['SubscriptionRequired'];
		if not is_valid_parameter_value (SubscriptionRequired, 'subscription', cfg.keywords ['yes_true_y']) then
			SubscriptionRequired=nil;
		end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local ArchiveDate = A['ArchiveDate'];
	local Agency = A['Agency'];
	local DeadURL = A['DeadURL']
		if not is_valid_parameter_value (DeadURL, 'dead-url', cfg.keywords ['deadurl']) then	-- set in config.defaults to 'yes'
			DeadURL = '';														-- anything else, set to empty string
		end

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
		if not is_valid_parameter_value (IgnoreISBN, 'ignore-isbn-error', cfg.keywords ['yes_true_y']) then
			IgnoreISBN = nil;													-- anything else, set to empty string
		end
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
		if not is_valid_parameter_value (LastAuthorAmp, 'last-author-amp', cfg.keywords ['yes_true_y']) then
			LastAuthorAmp = nil;													-- set to empty string
		end
	local no_tracking_cats = A['NoTracking'];
		if not is_valid_parameter_value (no_tracking_cats, 'no-tracking', cfg.keywords ['yes_true_y']) then
			no_tracking_cats = nil;												-- set to empty string
		end

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = A['DF'];															-- date format set in cs1|2 template
	if not is_valid_parameter_value (DF, 'df', cfg.keywords['date-format']) then	-- validate reformatting keyword
		DF = '';																-- not valid, set to empty string
	end

-- set default parameter values defined by |mode= parameter.  If |mode= is empty or omitted, use CitationClass to set these values
	local Mode = A['Mode'];
	if not is_valid_parameter_value (Mode, 'mode', cfg.keywords['mode']) then
		Mode = '';
	end
	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	select_one( args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'redundant_parameters' );		-- this is a dummy call simply to get the error message and category

	local NoPP = A['NoPP'] 
	if is_set (NoPP) and is_valid_parameter_value (NoPP, 'nopp', cfg.keywords ['yes_true_y']) then
		NoPP = true;
	else
		NoPP = nil;																-- unset, used as a flag later
	end

	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Pages = '';															-- unset the others
			At = '';
		end
		extra_text_in_page_check (Page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.
	elseif is_set(Pages) then
		if is_set(At) then
			At = '';															-- unset
		end
		extra_text_in_page_check (Pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped
	|url maps to |chapterurl when |title is remapped

All other combinations of |encyclopedia, |title, and |article are not modified

]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					TransChapter = TransTitle;
					ChapterURL = URL;
					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter= '[[' .. TitleLink .. '|' .. Chapter .. ']]';
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			else																-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if is_set(A['Number']) then													-- cite techreport uses 'number', which other citations alias to 'issue'
			if not is_set(ID) then												-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];													-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', 'id') .. ' and ' .. wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Others) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Others;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Others;
			end
		else
			Others = '(Interview)';
		end
	end

-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	elseif 'mailinglist' == A:ORIGIN('Periodical') then
		Periodical = '';														-- unset because mailing list is only used for cite mailing list
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];

		link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wikimarkup in |series-link= or wikimarkup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) and is_set (AirDate) then							-- promote airdate to date
			Date = AirDate;
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('series', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = '[[' .. ChapterLink .. '|' .. Chapter .. ']]';		-- ok to wikilink
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = '[[' .. ChapterLink .. '|' .. Series .. ']]';			-- series links with ChapterLink (episodelink -&gt; TitleLink -&gt; ChapterLink) ugly
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = '[[' .. SeriesLink .. '|' .. Series .. ']]';
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
-- end of {{cite episode}} stuff

-- Account for the oddities that are {{cite arxiv}}, before generation of COinS data.
	if 'arxiv' == config.CitationClass then
		if not is_set (ID_list['ARXIV']) then									-- |arxiv= or |eprint= required for cite arxiv
			table.insert( z.message_tail, { set_error( 'arxiv_missing', {}, true ) } );		-- add error message
		elseif is_set (Series) then												-- series is an alias of version
			ID_list['ARXIV'] = ID_list['ARXIV'] .. Series;						-- concatenate version onto the end of the arxiv identifier
			Series = '';														-- unset
			deprecated_parameter ('version');									-- deprecated parameter but only for cite arxiv
		end
		
		if first_set ({AccessDate, At, Chapter, Format, Page, Pages, Periodical, PublisherName, URL,	-- a crude list of parameters that are not supported by cite arxiv
			ID_list['ASIN'], ID_list['BIBCODE'], ID_list['DOI'], ID_list['ISBN'], ID_list['ISSN'],
			ID_list['JFM'], ID_list['JSTOR'], ID_list['LCCN'], ID_list['MR'], ID_list['OCLC'], ID_list['OL'],
			ID_list['OSTI'], ID_list['PMC'], ID_list['PMID'], ID_list['RFC'], ID_list['SSRN'], ID_list['USENETID'], ID_list['ZBL']},27) then
				table.insert( z.message_tail, { set_error( 'arxiv_params_not_supported', {}, true ) } );		-- add error message

				AccessDate= '';													-- set these to empty string; not supported in cite arXiv
				PublisherName = '';												-- (if the article has been published, use cite journal, or other)
				Chapter = '';
				URL = '';
				Format = '';
				Page = ''; Pages = ''; At = '';
		end
		Periodical = 'arXiv';													-- set to arXiv for COinS; after that, must be set to empty string
	end

-- handle type parameter for those CS1 citations that have default values
	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
	TitleType = substitute( cfg.messages['type'], TitleType);					-- display it in parentheses
	end

-- legacy: promote concatenation of |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	do	-- create defined block to contain local variables error_message and mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		anchor_year, error_message = dates({['access-date']=AccessDate, ['archive-date']=ArchiveDate, ['date']=Date, ['doi-broken-date']=DoiBroken,
			['embargo']=Embargo, ['lay-date']=LayDate, ['publication-date']=PublicationDate, ['year']=Year}, COinS_date);

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end

		if is_set(error_message) then
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		elseif is_set (DF) then
			local date_parameters_list = {['access-date']=AccessDate, ['archive-date']=ArchiveDate, ['date']=Date, ['doi-broken-date']=DoiBroken,
				['embargo']=Embargo, ['lay-date']=LayDate, ['publication-date']=PublicationDate};
			
			if reformat_dates (date_parameters_list, DF, false) then			-- reformat to DF format, use long month names if appropriate
				AccessDate = date_parameters_list['access-date'];				-- overwrite date holding parameters with reformatted values
				ArchiveDate = date_parameters_list['archive-date'];				-- TODO: move all dates into this table at the beginning and ...
				Date = date_parameters_list['date'];							-- ... use them from this table? no in-and-out like we're doing here
				DoiBroken = date_parameters_list['doi-broken-date'];
				Embargo = date_parameters_list['embargo'];
				LayDate = date_parameters_list['lay-date'];
				PublicationDate = date_parameters_list['publication-date'];
			end
		end
	end	-- end of do

-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);											-- 

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
			if 'episode' == config.CitationClass then							-- special case for cite episode; TODO: is there a better way to do this?
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
			else
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
			end
	end
	
	if 'none' == Title and in_array (config.CitationClass, {'journal', 'citation'}) and is_set (Periodical) and 'journal' == A:ORIGIN('Periodical') then	-- special case for journal cites
		Title = '';																-- set title to empty string
		add_maint_cat ('untitled');
	end

	check_for_url ({															-- add error message when any of these parameters contains a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[A:ORIGIN('Periodical')]=Periodical,
		[A:ORIGIN('PublisherName')] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = Periodical,
		['Encyclopedia'] = Encyclopedia,
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

-- Account for the oddities that are {{cite arxiv}}, AFTER generation of COinS data.
	if 'arxiv' == config.CitationClass then										-- we have set rft.jtitle in COinS to arXiv, now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in cite arxiv; if article has been published, use cite journal
	end

-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = substitute (cfg.messages['newsgroup'], external_link( 'news:' .. PublisherName, PublisherName, A:ORIGIN('PublisherName') ));
		end
	end



	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
--		local maximum;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text											-- get current page name so that we don't wikilink to it via editorlinkn
		};

		do																		-- do editor name list first because coauthors can modify control table
			control.maximum , editor_etal = get_display_authors_editors (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal, 'editor');

			if is_set (Editors) then
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
					EditorCount = 2;											-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
				else
					EditorCount = 2;											-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
				end
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do translators
			control.maximum = #t;												-- number of translators
			Translators = list_people(control, t, false, 'translator');			-- et al not currently supported
		end
		do																		-- now do contributors
			control.maximum = #c;												-- number of contributors
			Contributors = list_people(control, c, false, 'contributor');		-- et al not currently supported
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_authors_editors (A['DisplayAuthors'], #a, 'authors', author_etal);

			if is_set(Coauthors) then											-- if the coauthor field is also used, prevent ampersand and et al. formatting.
				control.lastauthoramp = nil;
				control.maximum = #a + 1;
			end
			
			last_first_list = list_people(control, a, author_etal, 'author');

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false);	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if is_set (Authors) and is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

		if not is_set(Authors) and is_set(Coauthors) then						-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
			table.insert( z.message_tail, { set_error('coauthors_missing_author', {}, true) } );	-- emit error message
		end
	end

-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

-- special case for chapter format so no error message or cat when chapter not supported
	if not (in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not is_set(URL) then
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then		-- test if cite web or cite podcast |url= is missing or empty 
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- test if accessdate is given without giving a URL
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when the others are not set; TODO: move this to a separate test?
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURLorigin, OriginalFormat;						-- TODO: swap chapter and title here so that archive applies to most specific if both are set?
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURLorigin = URLorigin;										-- name of url parameter for error messages
			OriginalFormat = Format;											-- and original |format=
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
			end
		elseif is_set (ChapterURL) then 										-- URL not set so if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURLorigin = ChapterURLorigin;								-- name of chapter-url parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |format=
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				ChapterURLorigin = A:ORIGIN('ArchiveURL')						-- name of archive-url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
			end
		end
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'arxiv'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			local chap_param;
			if is_set (Chapter) then											-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif is_set (ScriptChapter) then
				chap_param = A:ORIGIN ('ScriptChapter')
			else is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if is_set (chap_param) then											-- if we found one
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {chap_param}, true ) } );		-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if is_set (Contribution) and 0 &lt; #c then								-- if this is a contribution with contributor(s)
			if in_array (Contribution:lower(), cfg.keywords.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, Chapter, TransChapter, ChapterURL, ChapterURLorigin, no_quotes);		-- Contribution is also in Chapter
		if is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter.. sepc .. ' ';
		elseif is_set (ChapterFormat) then										-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'mailinglist', 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
	
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then 
			Title = external_link( URL, Title, URLorigin ) .. TransError .. Format;
			URL = &quot;&quot;;
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURLorigin );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if is_set(Minutes) then
			if is_set (Time) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'minutes') .. ' and ' .. wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
		Others = sepc .. ' Translated by ' .. Translators .. Others; 
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

--[[
Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
note is displayed. There are no error messages for this condition.

]]
	if is_set (SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif is_set (RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if 'citation', lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text
																				-- neither of these work; don't know why; it seems that substitute() isn't being called	
		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then				-- if first and last characters of quote are quote marks
			Quote = Quote:sub(2,-2);											-- strip them off
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL') ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- DeadURL is empty, 'yes', 'true', 'y', 'unfit', 'usurped'
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if in_array (DeadURL, {'unfit', 'usurped'}) then
				Archived = sepc .. &quot; &quot; .. 'Archived from the original on ' .. ArchiveDate;	-- format already styled
			else																-- DeadURL is empty, 'yes', 'true', or 'y'
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURLorigin ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL') ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL') ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURLorigin );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin );
	end

	local Publisher;
	if is_set(Periodical) and
		not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap_msg ('published', PublicationDate);
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap_msg ('published', PublicationDate) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
			Language, Edition, Publisher, Agency, Volume}, sepc );
		
	elseif in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(Periodical) then		-- special cases for book cites
		if is_set (Contributors) then											-- when we are citing foreword, preface, introduction, etc
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Transcript, Language, Edition, Publisher}, sepc );
	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if is_set(Date) then
		if is_set (Authors) or is_set (Editors) then							-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;;				-- in paranetheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon,-1,-1) == sepc) then							-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigYear;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigYear;							-- Date begins with sepc
			end
		end
	end	
	if is_set(Authors) then
		if is_set(Coauthors) then
			if 'vanc' == NameListFormat then									-- separate authors and coauthors with proper name-list-separator
				Authors = Authors .. ', ' .. Coauthors;
			else
				Authors = Authors .. '; ' .. Coauthors;
			end
		end
		if not is_set (Date) then												-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then in_text = in_text:lower() end				-- lowercase for cs2
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if is_set (Contributors) then											-- book cite and we're citing the intro, preface, etc
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if is_set (Editors) then											-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if not is_set (Date) then											-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = config.CitationClass;
		options.class = &quot;citation &quot; .. config.CitationClass;					-- class=citation required for blue highlight when used with |ref=
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then								-- set reference anchor if appropriate
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			id = anchor_id (namelist, year);									-- go make the CITEREF anchor
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then													-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		text = substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text});	-- when |ref= is set
	else
		text = substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text});	-- all other cases
	end		

	text = text .. substitute (cfg.presentation['ocins'], {OCinSoutput});		-- append metadata to the citation
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. error_comment( v[1], v[2] );
				else
					text = text .. error_comment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end

	if #z.maintenance_cats ~= 0 then
		text = text .. '&lt;span class=&quot;citation-comment&quot; style=&quot;display:none; color:#33aa33&quot;&gt;';
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. ' ' .. v .. ' ([[:Category:' .. v ..'|link]])';
		end
		text = text .. '&lt;/span&gt;';	-- maintenance mesages (realy just the names of the categories for now)
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

--[[--------------------------&lt; C S 1 . C I T A T I O N &gt;------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

function cs1.citation(frame)
	local pframe = frame:getParent()
	local validation, utilities, identifiers, metadata;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (utilities);								-- so that functions in Date validataion can see the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	dates = validation.dates;													-- imported functions from Module:Citation/CS1/Date validation
	year_date_check = validation.year_date_check;
	reformat_dates = validation.reformat_dates;
	
	is_set = utilities.is_set;													-- imported functions from Module:Citation/CS1/Utilities
	in_array = utilities.in_array;
	substitute = utilities.substitute;
	error_comment = utilities.error_comment;
	set_error = utilities.set_error;
	select_one = utilities.select_one;
	add_maint_cat = utilities.add_maint_cat;
	wrap_style = utilities.wrap_style;
	safe_for_italics = utilities.safe_for_italics;
	remove_wiki_link = utilities.remove_wiki_link;

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	extract_ids = identifiers.extract_ids;										-- imported functions from Module:Citation/CS1/Utilities
	build_id_list = identifiers.build_id_list;
	is_embargoed = identifiers.is_embargoed;
	
	make_coins_title = metadata.make_coins_title;								-- imported functions from Module:Citation/CS1/COinS
	get_coins_pages = metadata.get_coins_pages;
	COinS = metadata.COinS;

	
	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute( param, capture );				-- add the capture to the suggested parameter (typically the enumerator)
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, param}, true );	-- set the error message
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);
		end
	end
	return citation0( config, args)
end

return cs1;</text>
      <sha1>7qql2qcetvnc8lpft35vd3qbalbhe4e</sha1>
    </revision>
    <revision>
      <id>4704</id>
      <parentid>4703</parentid>
      <timestamp>2016-02-20T15:34:26Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>bug fix in language_parameter();</comment>
      <origin>4704</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="138684" sha1="m109sdj115cxqkquhc7qhvbaod7adv1" xml:space="preserve">

local cs1 ={};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local dates, year_date_check, reformat_dates									-- functions in Module:Citation/CS1/Date_validation

local is_set, in_array, substitute, error_comment, set_error, select_one,		-- functions in Module:Citation/CS1/Utilities
	add_maint_cat, wrap_style, safe_for_italics, remove_wiki_link;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local extract_ids, build_id_list, is_embargoed;									-- functions in Module:Citation/CS1/Identifiers

local make_coins_title, get_coins_pages, COinS;									-- functions in Module:Citation/CS1/COinS

local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist

--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end

--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

]]

local added_prop_cats = {}														-- list of property categories that have been added to z.properties_cats
local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));		-- make name then add to table
	end
end

--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

]]

local added_vanc_errs;															-- flag so we only emit one Vancouver error / category
local function add_vanc_error ()
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a uri scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of tlds: https://www.iana.org/domains/root/db

rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the tld.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a url with a scheme) will be stripped
here.  Perhaps not necessary but retained incase it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	single-letter/digit second-level domains in the .org TLD
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and tld or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%a%d]') then										-- first character must be letter or digit
		return false;
	end
																				-- Do most common case first
	if domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.%a%a+$') then			    -- three or more character hostname.hostname or hostname.tld
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.org$') then							-- one character .org hostname
		return true;
	elseif domain:match ('%f[%a][qxz]%.com$') then								-- assigned one character .com hostname (x.com times out 2015-12-10)
		return true;
	elseif domain:match ('%f[%a][iq]%.net$') then								-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.%a%a$') then							-- one character hostname and cctld (2 chars)
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d]%.%a%a+$') then					-- two character hostname and tld
		return true;
	elseif domain:match ('^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?') then		-- IPv4 address
		return true;
	else
		return false;
	end
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a url appear to be a valid url; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if is_set (scheme) then														-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when url is protocol relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a url into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following tld) (if any) and any path(/), query(?) or fragment(#).

If protocol relative url, return nil scheme and domain else return nil for both scheme and domain.

When not protocol relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol relative url
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		authority = authority:gsub ('//', '', 1);								-- replace place 1 pair of '/' with nothing;
		if is_set(authority) then												-- if anything left (1 or 3+ '/' where authority should be) then
			return scheme;														-- return scheme only making domain nil which will cause an error message
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link= etc for properly formatted content: no wikilinks, no urls

Link parameters are to hold the title of a wikipedia article so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki urls and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid url (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid url (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from url; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid url
end

--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wikilinked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

]]

local function link_title_ok (link, lorig, title, torig)
local orig;

	if is_set (link) then 														-- don't bother if link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing link parameter
		end
	end

	if is_set (orig) then
		table.insert( z.message_tail, { set_error( 'bad_paramlink', orig)});	-- url or wikilink in |title= with |title-link=;
	end
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the url into scheme and domain
portions, or for protocol relative (//example.com) urls, just the domain.  Use is_url() to validate the two
portions of the url.  If both are valid, or for protocol relative if domain is valid, return true, else false.

Because it is different from a standard url, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper url
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from url;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a url.  The test will also find external wikilinks
that use protocol relative urls. Also finds bare urls.

The frontier pattern prevents a match on interwiki links which are similar to scheme:path urls.  The tests that
find bracketed urls are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol relative ext wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare url with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol relative bare url: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a url
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then												-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source )
	local error_str = &quot;&quot;;
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url( label ), &quot;]&quot;, error_str });
end

--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

]]

local page_in_deprecated_cat;													-- sticky flag so that the category is added only once
local function deprecated_parameter(name)
	if not page_in_deprecated_cat then
		page_in_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end

--[[--------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Call this function for chapter titles, for website titles, etc; not for book titles.

]]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	
	cap, cap2 = str:match (&quot;^([\&quot;\'])([^\'].+)&quot;);								-- match leading double or single quote but not double single quotes
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-left'], {cap, cap2});
	end

	cap, cap2 = str:match (&quot;^(.+[^\'])([\&quot;\'])$&quot;)
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-right'], {cap, cap2});
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title= and |script-chapter=

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, {'am', 'ar', 'be', 'bg', 'bs', 'dv', 'el', 'fa', 'he', 'hy', 'ja', 'ka', 'ko', 'ku', 'mk', 'ml', 'ps', 'ru', 'sd', 'sr', 'th', 'uk', 'ug', 'yi', 'zh'}) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				add_prop_cat ('script')
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return substitute( msg, str );										-- including template text
	else
		return substitute( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (scriptchapter, chapter, transchapter, chapterurl, chapter_url_source, no_quotes)
	local chapter_error = '';
	
	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);										-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
			chapter = wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, scriptchapter)						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (transchapter) then
		transchapter = wrap_style ('trans-quoted-title', transchapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. transchapter;
		else																	-- here when transchapter without chapter or script-chapter
			chapter = transchapter;												-- 
			chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
		end
	end

	if is_set (chapterurl) then
		chapter = external_link (chapterurl, chapter, chapter_url_source);		-- adds bare_url_missing_title error if appropriate
	end

	return chapter .. chapter_error;
end

--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Detects but ignores the character pattern that results from the transclusion of {{'}} templates.

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i=1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- Test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position then
--			if 'nowiki' == capture or 'math' == capture or ('ref' == capture and 'quote' == param) then 	-- nowiki, math, or quote param and ref stripmarker (not an error condition)
			if 'nowiki' == capture or 'math' == capture then 					-- nowiki, math stripmarker (not an error condition)
				stripmarker = true;												-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			elseif 'apostrophe' == char then									-- apostrophe template uses &amp;zwj;, hair space and zero-width space
				apostrophe = true;
			elseif true == apostrophe and in_array (char, {'zero width joiner', 'zero width space', 'hair space'}) then
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { set_error( 'invisible_char', {err_msg, wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i=i+1;																	-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end

--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash

]]

local function hyphen_to_dash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if comp:sub(1,1) == duplicate_char then								-- is first charactier same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for th
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = str:sub(-1,-1);										-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = str:sub(1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = str:sub(1, -4) .. &quot;''&quot;;							-- remove them and add back ''
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then		-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then		-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then			-- if last two chars of str are sepc] external link
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;'']&quot; then		-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then				-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = str:sub(1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end		-- if duplicate_char not a letter then escape it
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )			-- remove duplicate_char if it follows html markup
					else
						value = value:sub( 2, -1 );								-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end  

--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

At the time of this writing, I had to write the 'if nil == mw.ustring.find ...' test ouside of the code editor and paste it here
because the code editor gets confused between character insertion point and cursor position.

]]

local function is_good_vanc_name (last, first)
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]*$&quot;) then
		add_vanc_error ();
		return false;															-- not a string of latin characters; Vancouver required Romanization
	end;
	return true;
end

--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  This form is not
currently supported by this code so correctly formed names like Smith JL 2nd are converted to Smith J2. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	if mw.ustring.match(first, &quot;^%u%u$&quot;) then return first end;					-- when first contains just two upper-case letters, nothing to do
	local initials = {}
	local i = 0;																-- counter for number of initials
	for word in mw.ustring.gmatch(first, &quot;[^%s%.%-]+&quot;) do						-- names separated by spaces, hyphens, or periods
		table.insert(initials, mw.ustring.sub(word,1,1))						-- Vancouver format does not include full stops.
		i = i + 1;																-- bump the counter 
		if 2 &lt;= i then break; end												-- only two initials allowed in Vancouver system; if 2, quit
	end
	return table.concat(initials)												-- Vancouver format does not include spaces.
end

--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal, list_name)					-- TODO: why is list_name here?  not used in this function
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = ',';																-- name-list separator between authors is a comma
		namesep = ' ';															-- last/first separator is a space
	else
		sep = ';'																-- name-list separator between authors is a semicolon
		namesep = ', '															-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then					-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first 
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;				-- link author/editor if this page is not the author's/editor's page
				end
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end

--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]
local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of author and editor name parameters for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the parameters |display-authors=etal or |display-editors=etal

]]

local function name_has_etal (name, etal, nocat)

	if is_set (name) then														-- name can be nil in which case just return
		local etal_pattern = &quot;[;,]? *[\&quot;']*%f[%a][Ee][Tt] *[Aa][Ll][%.\&quot;']*$&quot;	-- variations on the 'et al' theme
		local others_pattern = &quot;[;,]? *%f[%a]and [Oo]thers&quot;;					-- and alternate to et al.
		
		if name:match (etal_pattern) then										-- variants on et al.
			name = name:gsub (etal_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		elseif name:match (others_pattern) then									-- if not 'et al.', then 'and others'?
			name = name:gsub (others_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		end
	end
	return name, etal;															-- 
end

--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary
	while true do
		last = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false);								-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false);								-- find and remove variations on et al.

		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			link_title_ok (link, list_name:match (&quot;(%w+)List&quot;):lower() .. '-link' .. i, last, list_name:match (&quot;(%w+)List&quot;):lower() .. '-last' .. i);	-- check for improper wikimarkup

			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 code.

Returns the language name and associated ISO639-1 code.  Because case of the source may be incorrect or different from the case that Wikimedia
uses, the name comparisons are done in lower case and when a match is found, the Wikimedia version (assumed to be correct) is returned along
with the code.  When there is no match, we return the original language name string.

mw.language.fetchLanguageNames() will return a list of languages that aren't part of ISO639-1. Names that aren't ISO639-1 but that are included
in the list will be found if that name is provided in the |language= parameter.  For example, if |language=Samaritan Aramaic, that name will be
found with the associated code 'sam', not an ISO639-1 code.  When names are found and the associated code is not two characters, this function
returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	local languages = mw.language.fetchLanguageNames(this_wiki_code, 'all')		-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() then												-- ISO639-1 codes only
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the ISO639-1 code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for ISO639-1 code
end

--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Get language name from ISO639-1 code value provided.  If a code is valid use the returned name; if not, then use the value that was provided with the language parameter.

When |language= contains a valid ISO639-1 code, the page is assigned to the category for that code: Category:Norwegian-language sources (no) if
the page is a mainspace page and the ISO639-1 code is not the local wiki's language code.  Similarly, if the  parameter is |language=Norwegian,
it will be categorized in the same way.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the ISO639-1 two character code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki = mw.getContentLanguage();									-- get a language object for this wiki
	local this_wiki_code = this_wiki:getCode()									-- get this wiki's language code
	local this_wiki_name = mw.language.fetchLanguageName(this_wiki_code, this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang

		if lang:match ('^%a%a%-') then											-- strip ietf language tags from code
			lang = lang:match ('(%a%a)%-')										-- keep only 639-1 code portion to lang; TODO: do something with 3166 alpha 2 country code?
		end
		if 2 == lang:len() then													-- ISO639-1 language code are 2 characters (fetchLanguageName also supports 3 character codes)
			name = mw.language.fetchLanguageName( lang:lower(), this_wiki_code);			-- get ISO 639-1 language name if Language is a proper code
		end
	
		if is_set (name) then													-- if Language specified a valid ISO639-1 code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, this_wiki_code);				-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then
			if this_wiki_code ~= code then										-- when the language is not the same as this wiki's language
				add_prop_cat ('foreign_lang_source', {name, code})				-- categorize it
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, ' and ')							-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		language_list[code] = 'and ' .. language_list[code];					-- prepend last name with 'and&lt;space&gt;'
		name = table.concat (language_list, ', ')								-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
	end
	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
end

--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = '.';																-- terminate the rendered citation with a period
	end
	return '.', ps;																-- separator is a full stop
end

--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = '';																-- make sure it isn't nil
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return ',', ps, ref;														-- separator is a comma
end

--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end

--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extension, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf[%?#]?') or url:match ('%.PDF[%?#]?');
end

--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parenthases, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end

--[[--------------------------&lt; G E T _ D I S P L A Y _ A U T H O R S _ E D I T O R S &gt;------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_authors_editors (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_auth_ed', list_name);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end

--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
--	local good_pattern = '^P[^%.P%l]';
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
--	local bad_pattern = '^[Pp][Pp]';
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
--		if Page:match ('^[Pp]?[Pp]%.?[ %d]') or  Page:match ('^[Pp]ages?[ %d]') or
--			Pages:match ('^[Pp]?[Pp]%.?[ %d]') or  Pages:match ('^[Pp]ages?[ %d]') then
--				add_maint_cat ('extra_text');
--		end
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

TODO: check for names like Coon V JS (Coon JS 5th at PMID 25205766, John S. Coon V at doi:10.1093/humupd/dmu048)?

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	if vparam:find ('%[%[') or vparam:find ('%]%]')	then						-- no wikilinking vauthors names
		add_vanc_error ();
	end
	v_name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;)								-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parenthese to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')
			corporate = true;
		elseif string.find(v_name, &quot;%s&quot;) then
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
			last  = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') or mw.ustring.match (v_name, ' %u %u$') then
				add_vanc_error ();												-- matches last II last; the case when a comma is missing or a space between two intiials
			end
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) and not mw.ustring.match (first, &quot;^%u?%u$&quot;) then		-- first shall contain one or two upper-case letters, nothing else
			add_vanc_error ();
		end
																				-- this from extract_names ()
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice incase we have a first 1 without a last1
		select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, no, etc).  When the parameter value has not been assigned a value (missing or empty
in the source template) the function refurns true.  If the parameter value is one of the list of allowed values returns
true; else, emits an error message and returns false.

]]

local function is_valid_parameter_value (value, name, possible)
	if not is_set (value) then
		return true;															-- an empty parameter is ok
	elseif in_array(value:lower(), possible) then
		return true;
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list,-1,-1) == sepc) or (string.sub (name_list,-3,-1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terninate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not is_set (volume) and not is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end
	
	local vol = '';
		
	if is_set (volume) then
		if (4 &lt; mw.ustring.len(volume)) then
			vol = substitute (cfg.messages['j-vol'], {sepc, volume});
		else
			vol = wrap_style ('vol-bold', hyphen_to_dash(volume));
		end
	end
	if is_set (issue) then
		return vol .. substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end






--[[-------------------------&lt; N O R M A L I Z E _ P A G E _ L I S T &gt;-----------------------------------------

not currently used

normalizes a comma, ampersand, and/or space separated list to be '&lt;value&gt;, &lt;value&gt;, ..., &lt;value&gt;'
returns list unchanged if there are no commas else strips whitespace and then reformats the list

]]
--[[
local function normalize_page_list (list)
	if not list:find ('[,&amp; ]') then return list end								-- if list is not delimited with commas, ampersands, or spaces; done
	
	list = mw.text.split (list, '[,&amp;%s]+');										-- make a table of values
	list = table.concat (list, ', ');											-- and now make a normalized list
	return list;
end
]]

--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'journal' == origin);

	if is_set (page) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif is_set(pages) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then										-- if pages is only digits, assume a single page number
			return '', substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end

--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
		end
		if is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
		end
	end

	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list
	local Contribution = A['Contribution'];
	if in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not is_set (Contribution) then									-- |contributor= requires |contribution=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if select_one (args, cfg.aliases['ContributorList-Last'], 'redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { set_error( 'contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if not is_valid_parameter_value (NameListFormat, 'name-list-format', cfg.keywords['name-list-format']) then			-- only accepted value for this parameter is 'vanc'
		NameListFormat = '';													-- anything else, set to empty string
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
			link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wikimarkup in |title-link= or wikimarkup in |title= when |title-link= is set

	local Chapter = A['Chapter'];
	local ScriptChapter = A['ScriptChapter'];
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];
	local ArchiveURL = A['ArchiveURL'];
	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];
	local Periodical_origin = A:ORIGIN('Periodical');							-- get the name of the periodical parameter

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if in_array (config.CitationClass, cfg.templates_using_volume) and not ('conference' == config.CitationClass and not is_set (Periodical)) then
		Volume = A['Volume'];
	end
	if in_array (config.CitationClass, cfg.templates_using_issue) and not (in_array (config.CitationClass, {'conference', 'map'}) and not is_set (Periodical))then
		Issue = A['Issue'];
	end
	local Position = '';
	if not in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash( A['Pages'] );	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
		if not is_valid_parameter_value (RegistrationRequired, 'registration', cfg.keywords ['yes_true_y']) then
			RegistrationRequired=nil;
		end
	local SubscriptionRequired = A['SubscriptionRequired'];
		if not is_valid_parameter_value (SubscriptionRequired, 'subscription', cfg.keywords ['yes_true_y']) then
			SubscriptionRequired=nil;
		end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local ArchiveDate = A['ArchiveDate'];
	local Agency = A['Agency'];
	local DeadURL = A['DeadURL']
		if not is_valid_parameter_value (DeadURL, 'dead-url', cfg.keywords ['deadurl']) then	-- set in config.defaults to 'yes'
			DeadURL = '';														-- anything else, set to empty string
		end

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
		if not is_valid_parameter_value (IgnoreISBN, 'ignore-isbn-error', cfg.keywords ['yes_true_y']) then
			IgnoreISBN = nil;													-- anything else, set to empty string
		end
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
		if not is_valid_parameter_value (LastAuthorAmp, 'last-author-amp', cfg.keywords ['yes_true_y']) then
			LastAuthorAmp = nil;													-- set to empty string
		end
	local no_tracking_cats = A['NoTracking'];
		if not is_valid_parameter_value (no_tracking_cats, 'no-tracking', cfg.keywords ['yes_true_y']) then
			no_tracking_cats = nil;												-- set to empty string
		end

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = A['DF'];															-- date format set in cs1|2 template
	if not is_valid_parameter_value (DF, 'df', cfg.keywords['date-format']) then	-- validate reformatting keyword
		DF = '';																-- not valid, set to empty string
	end

-- set default parameter values defined by |mode= parameter.  If |mode= is empty or omitted, use CitationClass to set these values
	local Mode = A['Mode'];
	if not is_valid_parameter_value (Mode, 'mode', cfg.keywords['mode']) then
		Mode = '';
	end
	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	select_one( args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'redundant_parameters' );		-- this is a dummy call simply to get the error message and category

	local NoPP = A['NoPP'] 
	if is_set (NoPP) and is_valid_parameter_value (NoPP, 'nopp', cfg.keywords ['yes_true_y']) then
		NoPP = true;
	else
		NoPP = nil;																-- unset, used as a flag later
	end

	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Pages = '';															-- unset the others
			At = '';
		end
		extra_text_in_page_check (Page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.
	elseif is_set(Pages) then
		if is_set(At) then
			At = '';															-- unset
		end
		extra_text_in_page_check (Pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped
	|url maps to |chapterurl when |title is remapped

All other combinations of |encyclopedia, |title, and |article are not modified

]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					TransChapter = TransTitle;
					ChapterURL = URL;
					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter= '[[' .. TitleLink .. '|' .. Chapter .. ']]';
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			else																-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if is_set(A['Number']) then													-- cite techreport uses 'number', which other citations alias to 'issue'
			if not is_set(ID) then												-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];													-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', 'id') .. ' and ' .. wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Others) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Others;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Others;
			end
		else
			Others = '(Interview)';
		end
	end

-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	elseif 'mailinglist' == A:ORIGIN('Periodical') then
		Periodical = '';														-- unset because mailing list is only used for cite mailing list
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];

		link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wikimarkup in |series-link= or wikimarkup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) and is_set (AirDate) then							-- promote airdate to date
			Date = AirDate;
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('series', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = '[[' .. ChapterLink .. '|' .. Chapter .. ']]';		-- ok to wikilink
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = '[[' .. ChapterLink .. '|' .. Series .. ']]';			-- series links with ChapterLink (episodelink -&gt; TitleLink -&gt; ChapterLink) ugly
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = '[[' .. SeriesLink .. '|' .. Series .. ']]';
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
-- end of {{cite episode}} stuff

-- Account for the oddities that are {{cite arxiv}}, before generation of COinS data.
	if 'arxiv' == config.CitationClass then
		if not is_set (ID_list['ARXIV']) then									-- |arxiv= or |eprint= required for cite arxiv
			table.insert( z.message_tail, { set_error( 'arxiv_missing', {}, true ) } );		-- add error message
		elseif is_set (Series) then												-- series is an alias of version
			ID_list['ARXIV'] = ID_list['ARXIV'] .. Series;						-- concatenate version onto the end of the arxiv identifier
			Series = '';														-- unset
			deprecated_parameter ('version');									-- deprecated parameter but only for cite arxiv
		end
		
		if first_set ({AccessDate, At, Chapter, Format, Page, Pages, Periodical, PublisherName, URL,	-- a crude list of parameters that are not supported by cite arxiv
			ID_list['ASIN'], ID_list['BIBCODE'], ID_list['DOI'], ID_list['ISBN'], ID_list['ISSN'],
			ID_list['JFM'], ID_list['JSTOR'], ID_list['LCCN'], ID_list['MR'], ID_list['OCLC'], ID_list['OL'],
			ID_list['OSTI'], ID_list['PMC'], ID_list['PMID'], ID_list['RFC'], ID_list['SSRN'], ID_list['USENETID'], ID_list['ZBL']},27) then
				table.insert( z.message_tail, { set_error( 'arxiv_params_not_supported', {}, true ) } );		-- add error message

				AccessDate= '';													-- set these to empty string; not supported in cite arXiv
				PublisherName = '';												-- (if the article has been published, use cite journal, or other)
				Chapter = '';
				URL = '';
				Format = '';
				Page = ''; Pages = ''; At = '';
		end
		Periodical = 'arXiv';													-- set to arXiv for COinS; after that, must be set to empty string
	end

-- handle type parameter for those CS1 citations that have default values
	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
	TitleType = substitute( cfg.messages['type'], TitleType);					-- display it in parentheses
	end

-- legacy: promote concatenation of |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	do	-- create defined block to contain local variables error_message and mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		anchor_year, error_message = dates({['access-date']=AccessDate, ['archive-date']=ArchiveDate, ['date']=Date, ['doi-broken-date']=DoiBroken,
			['embargo']=Embargo, ['lay-date']=LayDate, ['publication-date']=PublicationDate, ['year']=Year}, COinS_date);

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end

		if is_set(error_message) then
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		elseif is_set (DF) then
			local date_parameters_list = {['access-date']=AccessDate, ['archive-date']=ArchiveDate, ['date']=Date, ['doi-broken-date']=DoiBroken,
				['embargo']=Embargo, ['lay-date']=LayDate, ['publication-date']=PublicationDate};
			
			if reformat_dates (date_parameters_list, DF, false) then			-- reformat to DF format, use long month names if appropriate
				AccessDate = date_parameters_list['access-date'];				-- overwrite date holding parameters with reformatted values
				ArchiveDate = date_parameters_list['archive-date'];				-- TODO: move all dates into this table at the beginning and ...
				Date = date_parameters_list['date'];							-- ... use them from this table? no in-and-out like we're doing here
				DoiBroken = date_parameters_list['doi-broken-date'];
				Embargo = date_parameters_list['embargo'];
				LayDate = date_parameters_list['lay-date'];
				PublicationDate = date_parameters_list['publication-date'];
			end
		end
	end	-- end of do

-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);											-- 

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
			if 'episode' == config.CitationClass then							-- special case for cite episode; TODO: is there a better way to do this?
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
			else
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
			end
	end
	
	if 'none' == Title and in_array (config.CitationClass, {'journal', 'citation'}) and is_set (Periodical) and 'journal' == A:ORIGIN('Periodical') then	-- special case for journal cites
		Title = '';																-- set title to empty string
		add_maint_cat ('untitled');
	end

	check_for_url ({															-- add error message when any of these parameters contains a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[A:ORIGIN('Periodical')]=Periodical,
		[A:ORIGIN('PublisherName')] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = Periodical,
		['Encyclopedia'] = Encyclopedia,
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

-- Account for the oddities that are {{cite arxiv}}, AFTER generation of COinS data.
	if 'arxiv' == config.CitationClass then										-- we have set rft.jtitle in COinS to arXiv, now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in cite arxiv; if article has been published, use cite journal
	end

-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = substitute (cfg.messages['newsgroup'], external_link( 'news:' .. PublisherName, PublisherName, A:ORIGIN('PublisherName') ));
		end
	end



	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
--		local maximum;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text											-- get current page name so that we don't wikilink to it via editorlinkn
		};

		do																		-- do editor name list first because coauthors can modify control table
			control.maximum , editor_etal = get_display_authors_editors (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal, 'editor');

			if is_set (Editors) then
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
					EditorCount = 2;											-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
				else
					EditorCount = 2;											-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
				end
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do translators
			control.maximum = #t;												-- number of translators
			Translators = list_people(control, t, false, 'translator');			-- et al not currently supported
		end
		do																		-- now do contributors
			control.maximum = #c;												-- number of contributors
			Contributors = list_people(control, c, false, 'contributor');		-- et al not currently supported
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_authors_editors (A['DisplayAuthors'], #a, 'authors', author_etal);

			if is_set(Coauthors) then											-- if the coauthor field is also used, prevent ampersand and et al. formatting.
				control.lastauthoramp = nil;
				control.maximum = #a + 1;
			end
			
			last_first_list = list_people(control, a, author_etal, 'author');

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false);	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if is_set (Authors) and is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

		if not is_set(Authors) and is_set(Coauthors) then						-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
			table.insert( z.message_tail, { set_error('coauthors_missing_author', {}, true) } );	-- emit error message
		end
	end

-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

-- special case for chapter format so no error message or cat when chapter not supported
	if not (in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not is_set(URL) then
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then		-- test if cite web or cite podcast |url= is missing or empty 
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- test if accessdate is given without giving a URL
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when the others are not set; TODO: move this to a separate test?
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURLorigin, OriginalFormat;						-- TODO: swap chapter and title here so that archive applies to most specific if both are set?
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURLorigin = URLorigin;										-- name of url parameter for error messages
			OriginalFormat = Format;											-- and original |format=
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
			end
		elseif is_set (ChapterURL) then 										-- URL not set so if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURLorigin = ChapterURLorigin;								-- name of chapter-url parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |format=
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				ChapterURLorigin = A:ORIGIN('ArchiveURL')						-- name of archive-url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
			end
		end
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'arxiv'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			local chap_param;
			if is_set (Chapter) then											-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif is_set (ScriptChapter) then
				chap_param = A:ORIGIN ('ScriptChapter')
			else is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if is_set (chap_param) then											-- if we found one
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {chap_param}, true ) } );		-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if is_set (Contribution) and 0 &lt; #c then								-- if this is a contribution with contributor(s)
			if in_array (Contribution:lower(), cfg.keywords.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, Chapter, TransChapter, ChapterURL, ChapterURLorigin, no_quotes);		-- Contribution is also in Chapter
		if is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter.. sepc .. ' ';
		elseif is_set (ChapterFormat) then										-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'mailinglist', 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
	
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then 
			Title = external_link( URL, Title, URLorigin ) .. TransError .. Format;
			URL = &quot;&quot;;
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURLorigin );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if is_set(Minutes) then
			if is_set (Time) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'minutes') .. ' and ' .. wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
		Others = sepc .. ' Translated by ' .. Translators .. Others; 
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

--[[
Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
note is displayed. There are no error messages for this condition.

]]
	if is_set (SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif is_set (RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if 'citation', lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text
																				-- neither of these work; don't know why; it seems that substitute() isn't being called	
		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then				-- if first and last characters of quote are quote marks
			Quote = Quote:sub(2,-2);											-- strip them off
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL') ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- DeadURL is empty, 'yes', 'true', 'y', 'unfit', 'usurped'
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if in_array (DeadURL, {'unfit', 'usurped'}) then
				Archived = sepc .. &quot; &quot; .. 'Archived from the original on ' .. ArchiveDate;	-- format already styled
			else																-- DeadURL is empty, 'yes', 'true', or 'y'
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURLorigin ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL') ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL') ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURLorigin );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin );
	end

	local Publisher;
	if is_set(Periodical) and
		not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap_msg ('published', PublicationDate);
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap_msg ('published', PublicationDate) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
			Language, Edition, Publisher, Agency, Volume}, sepc );
		
	elseif in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(Periodical) then		-- special cases for book cites
		if is_set (Contributors) then											-- when we are citing foreword, preface, introduction, etc
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Transcript, Language, Edition, Publisher}, sepc );
	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if is_set(Date) then
		if is_set (Authors) or is_set (Editors) then							-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;;				-- in paranetheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon,-1,-1) == sepc) then							-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigYear;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigYear;							-- Date begins with sepc
			end
		end
	end	
	if is_set(Authors) then
		if is_set(Coauthors) then
			if 'vanc' == NameListFormat then									-- separate authors and coauthors with proper name-list-separator
				Authors = Authors .. ', ' .. Coauthors;
			else
				Authors = Authors .. '; ' .. Coauthors;
			end
		end
		if not is_set (Date) then												-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then in_text = in_text:lower() end				-- lowercase for cs2
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if is_set (Contributors) then											-- book cite and we're citing the intro, preface, etc
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if is_set (Editors) then											-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if not is_set (Date) then											-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = config.CitationClass;
		options.class = &quot;citation &quot; .. config.CitationClass;					-- class=citation required for blue highlight when used with |ref=
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then								-- set reference anchor if appropriate
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			id = anchor_id (namelist, year);									-- go make the CITEREF anchor
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then													-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		text = substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text});	-- when |ref= is set
	else
		text = substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text});	-- all other cases
	end		

	text = text .. substitute (cfg.presentation['ocins'], {OCinSoutput});		-- append metadata to the citation
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. error_comment( v[1], v[2] );
				else
					text = text .. error_comment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end

	if #z.maintenance_cats ~= 0 then
		text = text .. '&lt;span class=&quot;citation-comment&quot; style=&quot;display:none; color:#33aa33&quot;&gt;';
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. ' ' .. v .. ' ([[:Category:' .. v ..'|link]])';
		end
		text = text .. '&lt;/span&gt;';	-- maintenance mesages (realy just the names of the categories for now)
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

--[[--------------------------&lt; C S 1 . C I T A T I O N &gt;------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

function cs1.citation(frame)
	local pframe = frame:getParent()
	local validation, utilities, identifiers, metadata;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (utilities);								-- so that functions in Date validataion can see the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	dates = validation.dates;													-- imported functions from Module:Citation/CS1/Date validation
	year_date_check = validation.year_date_check;
	reformat_dates = validation.reformat_dates;
	
	is_set = utilities.is_set;													-- imported functions from Module:Citation/CS1/Utilities
	in_array = utilities.in_array;
	substitute = utilities.substitute;
	error_comment = utilities.error_comment;
	set_error = utilities.set_error;
	select_one = utilities.select_one;
	add_maint_cat = utilities.add_maint_cat;
	wrap_style = utilities.wrap_style;
	safe_for_italics = utilities.safe_for_italics;
	remove_wiki_link = utilities.remove_wiki_link;

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	extract_ids = identifiers.extract_ids;										-- imported functions from Module:Citation/CS1/Utilities
	build_id_list = identifiers.build_id_list;
	is_embargoed = identifiers.is_embargoed;
	
	make_coins_title = metadata.make_coins_title;								-- imported functions from Module:Citation/CS1/COinS
	get_coins_pages = metadata.get_coins_pages;
	COinS = metadata.COinS;

	
	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute( param, capture );				-- add the capture to the suggested parameter (typically the enumerator)
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, param}, true );	-- set the error message
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);
		end
	end
	return citation0( config, args)
end

return cs1;</text>
      <sha1>m109sdj115cxqkquhc7qhvbaod7adv1</sha1>
    </revision>
    <revision>
      <id>4705</id>
      <parentid>4704</parentid>
      <timestamp>2016-04-16T10:52:10Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4705</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="144937" sha1="k0lpv6lukx36vlb8s9bsh88nk9fuipx" xml:space="preserve">
local cs1 ={};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local dates, year_date_check, reformat_dates									-- functions in Module:Citation/CS1/Date_validation

local is_set, in_array, substitute, error_comment, set_error, select_one,		-- functions in Module:Citation/CS1/Utilities
	add_maint_cat, wrap_style, safe_for_italics, remove_wiki_link;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local extract_ids, build_id_list, is_embargoed;									-- functions in Module:Citation/CS1/Identifiers

local make_coins_title, get_coins_pages, COinS;									-- functions in Module:Citation/CS1/COinS

local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist

--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end

--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

]]

local added_prop_cats = {}														-- list of property categories that have been added to z.properties_cats
local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));		-- make name then add to table
	end
end

--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

]]

local added_vanc_errs;															-- flag so we only emit one Vancouver error / category
local function add_vanc_error ()
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a uri scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of tlds: https://www.iana.org/domains/root/db

rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the tld.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a url with a scheme) will be stripped
here.  Perhaps not necessary but retained incase it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ascii characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the tld) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org TLD
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and tld or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%a%d]') then										-- first character must be letter or digit
		return false;
	end
																				-- Do most common case first
	if domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.%a%a+$') then				-- three or more character hostname.hostname or hostname.tld
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.xn%-%-[%a%d]+$') then	-- internationalized domain name with ACE prefix
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.org$') then							-- one character .org hostname
		return true;
	elseif domain:match ('%f[%a][qxz]%.com$') then								-- assigned one character .com hostname (x.com times out 2015-12-10)
		return true;
	elseif domain:match ('%f[%a][iq]%.net$') then								-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.%a%a$') then							-- one character hostname and cctld (2 chars)
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d]%.%a%a+$') then					-- two character hostname and tld
		return true;
	elseif domain:match ('^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?') then		-- IPv4 address
		return true;
	else
		return false;
	end
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a url appear to be a valid url; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if is_set (scheme) then														-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when url is protocol relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a url into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following tld) (if any) and any path(/), query(?) or fragment(#).

If protocol relative url, return nil scheme and domain else return nil for both scheme and domain.

When not protocol relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol relative url
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		authority = authority:gsub ('//', '', 1);								-- replace place 1 pair of '/' with nothing;
		if is_set(authority) then												-- if anything left (1 or 3+ '/' where authority should be) then
			return scheme;														-- return scheme only making domain nil which will cause an error message
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link= etc for properly formatted content: no wikilinks, no urls

Link parameters are to hold the title of a wikipedia article so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki urls and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid url (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid url (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from url; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid url
end

--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wikilinked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

]]

local function link_title_ok (link, lorig, title, torig)
local orig;

	if is_set (link) then 														-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		end
	end

	if is_set (orig) then
		table.insert( z.message_tail, { set_error( 'bad_paramlink', orig)});	-- url or wikilink in |title= with |title-link=;
	end
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the url into scheme and domain
portions, or for protocol relative (//example.com) urls, just the domain.  Use is_url() to validate the two
portions of the url.  If both are valid, or for protocol relative if domain is valid, return true, else false.

Because it is different from a standard url, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper url
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from url;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a url.  The test will also find external wikilinks
that use protocol relative urls. Also finds bare urls.

The frontier pattern prevents a match on interwiki links which are similar to scheme:path urls.  The tests that
find bracketed urls are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol relative ext wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare url with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol relative bare url: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a url
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then												-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source )
	local error_str = &quot;&quot;;
	local domain;
	local path;
	
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the url into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['[']='%5b',[']']='%5d'});					-- replace '[' and ']' with their percent encoded values
		URL=domain..path;														-- and reassemble
	end
	
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url( label ), &quot;]&quot;, error_str });
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

]]

local page_in_deprecated_cat;													-- sticky flag so that the category is added only once
local function deprecated_parameter(name)
	if not page_in_deprecated_cat then
		page_in_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end

--[[--------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Call this function for chapter titles, for website titles, etc; not for book titles.

]]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	
	cap, cap2 = str:match (&quot;^([\&quot;\'])([^\'].+)&quot;);								-- match leading double or single quote but not double single quotes
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-left'], {cap, cap2});
	end

	cap, cap2 = str:match (&quot;^(.+[^\'])([\&quot;\'])$&quot;)
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-right'], {cap, cap2});
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title= and |script-chapter=

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, {'am', 'ar', 'be', 'bg', 'bs', 'dv', 'el', 'fa', 'he', 'hy', 'ja', 'ka', 'ko', 'ku', 'mk', 'ml', 'ps', 'ru', 'sd', 'sr', 'th', 'uk', 'ug', 'yi', 'zh'}) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				add_prop_cat ('script')
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return substitute( msg, str );										-- including template text
	else
		return substitute( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (scriptchapter, chapter, transchapter, chapterurl, chapter_url_source, no_quotes)
	local chapter_error = '';
	
	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);										-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
			chapter = wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, scriptchapter)						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (transchapter) then
		transchapter = wrap_style ('trans-quoted-title', transchapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. transchapter;
		else																	-- here when transchapter without chapter or script-chapter
			chapter = transchapter;												-- 
			chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
		end
	end

	if is_set (chapterurl) then
		chapter = external_link (chapterurl, chapter, chapter_url_source);		-- adds bare_url_missing_title error if appropriate
	end

	return chapter .. chapter_error;
end

--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Detects but ignores the character pattern that results from the transclusion of {{'}} templates.

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i=1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- Test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position then
			if 'nowiki' == capture or 'math' == capture then 					-- nowiki, math stripmarker (not an error condition)
				stripmarker = true;												-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { set_error( 'invisible_char', {err_msg, wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i=i+1;																	-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end

--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash

]]

local function hyphen_to_dash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if comp:sub(1,1) == duplicate_char then								-- is first charactier same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for th
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = str:sub(-1,-1);										-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = str:sub(1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = str:sub(1, -4) .. &quot;''&quot;;							-- remove them and add back ''
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then		-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then		-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then			-- if last two chars of str are sepc] external link
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;'']&quot; then		-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then				-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = str:sub(1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end		-- if duplicate_char not a letter then escape it
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )			-- remove duplicate_char if it follows html markup
					else
						value = value:sub( 2, -1 );								-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end  

--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

At the time of this writing, I had to write the 'if nil == mw.ustring.find ...' test ouside of the code editor and paste it here
because the code editor gets confused between character insertion point and cursor position.

]]

local function is_good_vanc_name (last, first)
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]*$&quot;) then
		add_vanc_error ();
		return false;															-- not a string of latin characters; Vancouver required Romanization
	end;
	return true;
end

--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  This form is not
currently supported by this code so correctly formed names like Smith JL 2nd are converted to Smith J2. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	if mw.ustring.match(first, &quot;^%u%u$&quot;) then return first end;					-- when first contains just two upper-case letters, nothing to do
	local initials = {}
	local i = 0;																-- counter for number of initials
	for word in mw.ustring.gmatch(first, &quot;[^%s%.%-]+&quot;) do						-- names separated by spaces, hyphens, or periods
		table.insert(initials, mw.ustring.sub(word,1,1))						-- Vancouver format does not include full stops.
		i = i + 1;																-- bump the counter 
		if 2 &lt;= i then break; end												-- only two initials allowed in Vancouver system; if 2, quit
	end
	return table.concat(initials)												-- Vancouver format does not include spaces.
end

--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = ',';																-- name-list separator between authors is a comma
		namesep = ' ';															-- last/first separator is a space
	else
		sep = ';'																-- name-list separator between authors is a semicolon
		namesep = ', '															-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then					-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first 
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;				-- link author/editor if this page is not the author's/editor's page
				end
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end

--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]
local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of author and editor name parameters for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the parameters |display-authors=etal or |display-editors=etal

]]

local function name_has_etal (name, etal, nocat)

	if is_set (name) then														-- name can be nil in which case just return
		local etal_pattern = &quot;[;,]? *[\&quot;']*%f[%a][Ee][Tt] *[Aa][Ll][%.\&quot;']*$&quot;	-- variations on the 'et al' theme
		local others_pattern = &quot;[;,]? *%f[%a]and [Oo]thers&quot;;					-- and alternate to et al.
		
		if name:match (etal_pattern) then										-- variants on et al.
			name = name:gsub (etal_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		elseif name:match (others_pattern) then									-- if not 'et al.', then 'and others'?
			name = name:gsub (others_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		end
	end
	return name, etal;															-- 
end

--[[--------------------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;----------------------------------------

Evaluates the content of author and editor (surnames only) parameters for multiple names.  Multiple names are
indicated if there is more than one comma and or semicolon.  If found, the function adds the multiple name
(author or editor) maintenance category.

]]

local function name_has_mult_names (name, list_name)
local count, _;
	if is_set (name) then
		if name:match ('^%(%(.*%)%)$') then										-- if wrapped in doubled parentheses, ignore 
			name = name:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			_, count = name:gsub ('[;,]', '');									-- count the number of separator-like characters
			
			if 1 &lt; count then													-- param could be |author= or |editor= so one separactor character is acceptable
				add_maint_cat ('mult_names', list_name:lower());				-- more than one separator indicates multiple names so add a maint cat for this template
			end
		end
	end
	return name;																-- and done
end

--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary
	while true do
		last = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false);							-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false);						-- find and remove variations on et al.
		last = name_has_mult_names (last, err_msg_list_name);					-- check for multiple names in last and its aliases
		
		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			link_title_ok (link, list_name:match (&quot;(%w+)List&quot;):lower() .. '-link' .. i, last, list_name:match (&quot;(%w+)List&quot;):lower() .. '-last' .. i);	-- check for improper wikimarkup

			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because case of the source may be incorrect
or different from the case that WikiMedia uses, the name comparisons are done in lower case and when a match is
found, the Wikimedia version (assumed to be correct) is returned along with the code.  When there is no match, we
return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') return a list of languages that in some cases may include
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.

Names but that are included in the list will be found if that name is provided in the |language= parameter.  For example,
if |language=Chavacano de Zamboanga, that name will be found with the associated code 'cbk-zam'.  When names are found
and the associated code is not two or three characters, this function returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	local languages = mw.language.fetchLanguageNames(this_wiki_code, 'all')		-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() and 3 ~= code:len() then							-- two- or three-character codes only; extensions not supported
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the the code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for the code
end

--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code is recognized by MediaWiki,
use the returned name; if not, then use the value that was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is assigned to the category for
that code: Category:Norwegian-language sources (no).  For valid three-character code languages, the page is assigned
to the single category for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does not recognize three-character
equivalents of two-character codes: code 'ar' is recognized bit code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are
separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki = mw.getContentLanguage();									-- get a language object for this wiki
	local this_wiki_code = this_wiki:getCode()									-- get this wiki's language code
	local this_wiki_name = mw.language.fetchLanguageName(this_wiki_code, this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang

		if lang:match ('^%a%a%-') then											-- strip ietf language tags from code; TODO: is there a need to support 3-char with tag?
			lang = lang:match ('(%a%a)%-')										-- keep only 639-1 code portion to lang; TODO: do something with 3166 alpha 2 country code?
		end
		if 2 == lang:len() or 3 == lang:len() then								-- if two-or three-character code
			name = mw.language.fetchLanguageName( lang:lower(), this_wiki_code);	-- get language name if |language= is a proper code
		end
	
		if is_set (name) then													-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, this_wiki_code);				-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then													-- only 2- or 3-character codes
			if this_wiki_code ~= code then										-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					add_prop_cat ('foreign_lang_source', {name, code})			-- categorize it
				else															-- or is a recognized language (but has a three-character code)
					add_prop_cat ('foreign_lang_source_2', {code})				-- categorize it differently TODO: support mutliple three-character code categories per cs1|2 template
				end
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, ' and ')							-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		language_list[code] = 'and ' .. language_list[code];					-- prepend last name with 'and&lt;space&gt;'
		name = table.concat (language_list, ', ')								-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
	end
	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
end

--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = '.';																-- terminate the rendered citation with a period
	end
	return '.', ps;																-- separator is a full stop
end

--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = '';																-- make sure it isn't nil
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return ',', ps, ref;														-- separator is a comma
end

--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end

--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extension, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf[%?#]?') or url:match ('%.PDF[%?#]?');
end

--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parenthases, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end

--[[--------------------------&lt; G E T _ D I S P L A Y _ A U T H O R S _ E D I T O R S &gt;------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_authors_editors (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_auth_ed', list_name);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end

--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
--	local good_pattern = '^P[^%.P%l]';
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
--	local bad_pattern = '^[Pp][Pp]';
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
--		if Page:match ('^[Pp]?[Pp]%.?[ %d]') or  Page:match ('^[Pp]ages?[ %d]') or
--			Pages:match ('^[Pp]?[Pp]%.?[ %d]') or  Pages:match ('^[Pp]ages?[ %d]') then
--				add_maint_cat ('extra_text');
--		end
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

TODO: check for names like Coon V JS (Coon JS 5th at PMID 25205766, John S. Coon V at doi:10.1093/humupd/dmu048)?

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	if vparam:find ('%[%[') or vparam:find ('%]%]')	then						-- no wikilinking vauthors names
		add_vanc_error ();
	end
	v_name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;)								-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parenthese to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')
			corporate = true;
		elseif string.find(v_name, &quot;%s&quot;) then
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
			last  = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') or mw.ustring.match (v_name, ' %u %u$') then
				add_vanc_error ();												-- matches last II last; the case when a comma is missing or a space between two intiials
			end
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) and not mw.ustring.match (first, &quot;^%u?%u$&quot;) then		-- first shall contain one or two upper-case letters, nothing else
			add_vanc_error ();
		end
																				-- this from extract_names ()
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice incase we have a first 1 without a last1
		select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, no, etc).  When the parameter value has not been assigned a value (missing or empty
in the source template) the function refurns true.  If the parameter value is one of the list of allowed values returns
true; else, emits an error message and returns false.

]]

local function is_valid_parameter_value (value, name, possible)
	if not is_set (value) then
		return true;															-- an empty parameter is ok
	elseif in_array(value:lower(), possible) then
		return true;
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list,-1,-1) == sepc) or (string.sub (name_list,-3,-1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terninate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not is_set (volume) and not is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end
	
	local vol = '';
		
	if is_set (volume) then
		if (4 &lt; mw.ustring.len(volume)) then
			vol = substitute (cfg.messages['j-vol'], {sepc, volume});
		else
			vol = wrap_style ('vol-bold', hyphen_to_dash(volume));
		end
	end
	if is_set (issue) then
		return vol .. substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end






--[[-------------------------&lt; N O R M A L I Z E _ P A G E _ L I S T &gt;-----------------------------------------

not currently used

normalizes a comma, ampersand, and/or space separated list to be '&lt;value&gt;, &lt;value&gt;, ..., &lt;value&gt;'
returns list unchanged if there are no commas else strips whitespace and then reformats the list

]]
--[[
local function normalize_page_list (list)
	if not list:find ('[,&amp; ]') then return list end								-- if list is not delimited with commas, ampersands, or spaces; done
	
	list = mw.text.split (list, '[,&amp;%s]+');										-- make a table of values
	list = table.concat (list, ', ');											-- and now make a normalized list
	return list;
end
]]

--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'journal' == origin);

	if is_set (page) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif is_set(pages) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then										-- if pages is only digits, assume a single page number
			return '', substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org urls to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot url.  When the archive url is 'https://web.archive.org/save/' (or http://...) archive.org saves a snapshot
of the target page in the url.  That is something that Wikipedia should not allow unwitting readers to do.

When the archive.org url does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command url
	|archive-url= is an archive.org url that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the correct place
otherwise returns |archive-url= and |archive-date=

]=]

local function archive_url_check (url, date)
	if url:match('//web\.archive\.org/') then									-- for archive.org urls:
		if url:match('//web\.archive\.org/save/') then							-- if a save command url, we don't want to save target page 
			table.insert( z.message_tail, { set_error( 'archive_url', {'save command'}, true ) } );	-- add error message
			return '', '';														-- return empty strings for archiveURL and ArchiveDate
		elseif url:match('//web\.archive\.org/web/%d%d%d%d%d%d%d%d%d%d%d%d%d%d/') then	-- if there is what looks like a correct timestamp
			return url, date;													-- return archiveURL and ArchiveDate
		else																	-- malformed url
			table.insert( z.message_tail, { set_error( 'archive_url', {'timestamp'}, true ) } );	-- add error message
			return '', '';														-- return empty strings for archiveURL and ArchiveDate
		end
	end
	return url, date;															-- not an archive.org archive
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe:
	{{cite ... |title=Title access-date=2016-03-17}}

cs1|2 shares some parameter names with xml/html atributes: class=, title=, etc.  To prevent false positives xml/html
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove xml/html tags because attributes: class=, title=, etc 

	capture = value:match ('%s+(%a[%a%d]+)%s*=') or value:match ('^(%a[%a%d]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then								-- if the capture is a valid parameter name
		add_maint_cat ('missing_pipe');
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
		end
		if is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
		end
	end

	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list
	local Contribution = A['Contribution'];
	if in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not is_set (Contribution) then									-- |contributor= requires |contribution=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if select_one (args, cfg.aliases['ContributorList-Last'], 'redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { set_error( 'contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if not is_valid_parameter_value (NameListFormat, 'name-list-format', cfg.keywords['name-list-format']) then			-- only accepted value for this parameter is 'vanc'
		NameListFormat = '';													-- anything else, set to empty string
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
			link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wikimarkup in |title-link= or wikimarkup in |title= when |title-link= is set

	local Chapter = A['Chapter'];
	local ScriptChapter = A['ScriptChapter'];
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];

	local ArchiveDate;
	local ArchiveURL;

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	
--	local ArchiveDate = A['ArchiveDate'];
--	local ArchiveURL = A['ArchiveURL'];
--		if ArchiveURL:match('//web\.archive\.org/save/') then				-- if an archive.org save command url, we don't want to save target page ...
--			ArchiveURL = '';													-- every time a reader clicks the link so
--			ArchiveDate = '';													-- unset these
--			table.insert( z.message_tail, { set_error( 'archive_save', {}, true ) } );	-- and add error message
--		end
	local DeadURL = A['DeadURL']
		if not is_valid_parameter_value (DeadURL, 'dead-url', cfg.keywords ['deadurl']) then	-- set in config.defaults to 'yes'
			DeadURL = '';														-- anything else, set to empty string
		end

	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];
	local Periodical_origin = A:ORIGIN('Periodical');							-- get the name of the periodical parameter

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if in_array (config.CitationClass, cfg.templates_using_volume) and not ('conference' == config.CitationClass and not is_set (Periodical)) then
		Volume = A['Volume'];
	end
	if in_array (config.CitationClass, cfg.templates_using_issue) and not (in_array (config.CitationClass, {'conference', 'map'}) and not is_set (Periodical))then
		Issue = A['Issue'];
	end
	local Position = '';
	if not in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash( A['Pages'] );	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
		if not is_valid_parameter_value (RegistrationRequired, 'registration', cfg.keywords ['yes_true_y']) then
			RegistrationRequired=nil;
		end
	local SubscriptionRequired = A['SubscriptionRequired'];
		if not is_valid_parameter_value (SubscriptionRequired, 'subscription', cfg.keywords ['yes_true_y']) then
			SubscriptionRequired=nil;
		end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local Agency = A['Agency'];

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
		if not is_valid_parameter_value (IgnoreISBN, 'ignore-isbn-error', cfg.keywords ['yes_true_y']) then
			IgnoreISBN = nil;													-- anything else, set to empty string
		end
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
		if not is_valid_parameter_value (LastAuthorAmp, 'last-author-amp', cfg.keywords ['yes_true_y']) then
			LastAuthorAmp = nil;													-- set to empty string
		end
	local no_tracking_cats = A['NoTracking'];
		if not is_valid_parameter_value (no_tracking_cats, 'no-tracking', cfg.keywords ['yes_true_y']) then
			no_tracking_cats = nil;												-- set to empty string
		end

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = A['DF'];															-- date format set in cs1|2 template
	if not is_valid_parameter_value (DF, 'df', cfg.keywords['date-format']) then	-- validate reformatting keyword
		DF = '';																-- not valid, set to empty string
	end

-- set default parameter values defined by |mode= parameter.  If |mode= is empty or omitted, use CitationClass to set these values
	local Mode = A['Mode'];
	if not is_valid_parameter_value (Mode, 'mode', cfg.keywords['mode']) then
		Mode = '';
	end
	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	select_one( args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'redundant_parameters' );		-- this is a dummy call simply to get the error message and category

	local NoPP = A['NoPP'] 
	if is_set (NoPP) and is_valid_parameter_value (NoPP, 'nopp', cfg.keywords ['yes_true_y']) then
		NoPP = true;
	else
		NoPP = nil;																-- unset, used as a flag later
	end

	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Pages = '';															-- unset the others
			At = '';
		end
		extra_text_in_page_check (Page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.
	elseif is_set(Pages) then
		if is_set(At) then
			At = '';															-- unset
		end
		extra_text_in_page_check (Pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped
	|url maps to |chapterurl when |title is remapped

All other combinations of |encyclopedia, |title, and |article are not modified

]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					TransChapter = TransTitle;
					ChapterURL = URL;
					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter= '[[' .. TitleLink .. '|' .. Chapter .. ']]';
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			else																-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if is_set(A['Number']) then													-- cite techreport uses 'number', which other citations alias to 'issue'
			if not is_set(ID) then												-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];													-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', 'id') .. ' and ' .. wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Others) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Others;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Others;
			end
		else
			Others = '(Interview)';
		end
	end

-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	elseif 'mailinglist' == A:ORIGIN('Periodical') then
		Periodical = '';														-- unset because mailing list is only used for cite mailing list
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];

		link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wikimarkup in |series-link= or wikimarkup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) and is_set (AirDate) then							-- promote airdate to date
			Date = AirDate;
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('series', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = '[[' .. ChapterLink .. '|' .. Chapter .. ']]';		-- ok to wikilink
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = '[[' .. ChapterLink .. '|' .. Series .. ']]';			-- series links with ChapterLink (episodelink -&gt; TitleLink -&gt; ChapterLink) ugly
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = '[[' .. SeriesLink .. '|' .. Series .. ']]';
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
-- end of {{cite episode}} stuff

-- Account for the oddities that are {{cite arxiv}}, before generation of COinS data.
	if 'arxiv' == config.CitationClass then
		if not is_set (ID_list['ARXIV']) then									-- |arxiv= or |eprint= required for cite arxiv
			table.insert( z.message_tail, { set_error( 'arxiv_missing', {}, true ) } );		-- add error message
		elseif is_set (Series) then												-- series is an alias of version
			ID_list['ARXIV'] = ID_list['ARXIV'] .. Series;						-- concatenate version onto the end of the arxiv identifier
			Series = '';														-- unset
			deprecated_parameter ('version');									-- deprecated parameter but only for cite arxiv
		end
		
		if first_set ({AccessDate, At, Chapter, Format, Page, Pages, Periodical, PublisherName, URL,	-- a crude list of parameters that are not supported by cite arxiv
			ID_list['ASIN'], ID_list['BIBCODE'], ID_list['DOI'], ID_list['ISBN'], ID_list['ISSN'],
			ID_list['JFM'], ID_list['JSTOR'], ID_list['LCCN'], ID_list['MR'], ID_list['OCLC'], ID_list['OL'],
			ID_list['OSTI'], ID_list['PMC'], ID_list['PMID'], ID_list['RFC'], ID_list['SSRN'], ID_list['USENETID'], ID_list['ZBL']},27) then
				table.insert( z.message_tail, { set_error( 'arxiv_params_not_supported', {}, true ) } );		-- add error message

				AccessDate= '';													-- set these to empty string; not supported in cite arXiv
				PublisherName = '';												-- (if the article has been published, use cite journal, or other)
				Chapter = '';
				URL = '';
				Format = '';
				Page = ''; Pages = ''; At = '';
		end
		Periodical = 'arXiv';													-- set to arXiv for COinS; after that, must be set to empty string
	end

-- handle type parameter for those CS1 citations that have default values
	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
	TitleType = substitute( cfg.messages['type'], TitleType);					-- display it in parentheses
	end

-- legacy: promote concatenation of |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {['access-date']=AccessDate, ['archive-date']=ArchiveDate, ['date']=Date, ['doi-broken-date']=DoiBroken,
				['embargo']=Embargo, ['lay-date']=LayDate, ['publication-date']=PublicationDate, ['year']=Year};

		anchor_year, Embargo, error_message = dates(date_parameters_list, COinS_date);

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end

		if is_set(error_message) then
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		elseif is_set (DF) then
			if reformat_dates (date_parameters_list, DF, false) then			-- reformat to DF format, use long month names if appropriate
				AccessDate = date_parameters_list['access-date'];				-- overwrite date holding parameters with reformatted values
				ArchiveDate = date_parameters_list['archive-date'];
				Date = date_parameters_list['date'];
				DoiBroken = date_parameters_list['doi-broken-date'];
				LayDate = date_parameters_list['lay-date'];
				PublicationDate = date_parameters_list['publication-date'];
			end
		end
	end	-- end of do

-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);											-- 

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
			if 'episode' == config.CitationClass then							-- special case for cite episode; TODO: is there a better way to do this?
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
			else
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
			end
	end
	
	if 'none' == Title and in_array (config.CitationClass, {'journal', 'citation'}) and is_set (Periodical) and 'journal' == A:ORIGIN('Periodical') then	-- special case for journal cites
		Title = '';																-- set title to empty string
		add_maint_cat ('untitled');
	end

	check_for_url ({															-- add error message when any of these parameters contains a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[A:ORIGIN('Periodical')]=Periodical,
		[A:ORIGIN('PublisherName')] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = Periodical,
		['Encyclopedia'] = Encyclopedia,
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

-- Account for the oddities that are {{cite arxiv}}, AFTER generation of COinS data.
	if 'arxiv' == config.CitationClass then										-- we have set rft.jtitle in COinS to arXiv, now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in cite arxiv; if article has been published, use cite journal
	end

-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = substitute (cfg.messages['newsgroup'], external_link( 'news:' .. PublisherName, PublisherName, A:ORIGIN('PublisherName') ));
		end
	end



	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
--		local maximum;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text											-- get current page name so that we don't wikilink to it via editorlinkn
		};

		do																		-- do editor name list first because coauthors can modify control table
			control.maximum , editor_etal = get_display_authors_editors (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if is_set (Editors) then
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
					EditorCount = 2;											-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
				else
					EditorCount = 2;											-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
				end
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do translators
			control.maximum = #t;												-- number of translators
			Translators = list_people(control, t, false);						-- et al not currently supported
		end
		do																		-- now do contributors
			control.maximum = #c;												-- number of contributors
			Contributors = list_people(control, c, false);						-- et al not currently supported
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_authors_editors (A['DisplayAuthors'], #a, 'authors', author_etal);

			if is_set(Coauthors) then											-- if the coauthor field is also used, prevent ampersand and et al. formatting.
				control.lastauthoramp = nil;
				control.maximum = #a + 1;
			end
			
			last_first_list = list_people(control, a, author_etal);

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false);	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if is_set (Authors) and is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

		if not is_set(Authors) and is_set(Coauthors) then						-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
			table.insert( z.message_tail, { set_error('coauthors_missing_author', {}, true) } );	-- emit error message
		end
	end

-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

-- special case for chapter format so no error message or cat when chapter not supported
	if not (in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not is_set(URL) then
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then	-- |url= required for cite web, cite podcast, and cite mailinglist
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURLorigin, OriginalFormat;						-- TODO: swap chapter and title here so that archive applies to most specific if both are set?
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (ChapterURL) then 	-- swapped									-- URL not set so if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURLorigin = ChapterURLorigin;								-- name of chapter-url parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |format=
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				ChapterURLorigin = A:ORIGIN('ArchiveURL')						-- name of archive-url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
			end
		elseif is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURLorigin = URLorigin;										-- name of url parameter for error messages
			OriginalFormat = Format;											-- and original |format=
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
			end
 		end
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'arxiv'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			local chap_param;
			if is_set (Chapter) then											-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif is_set (ScriptChapter) then
				chap_param = A:ORIGIN ('ScriptChapter')
			else is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if is_set (chap_param) then											-- if we found one
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {chap_param}, true ) } );		-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if is_set (Contribution) and 0 &lt; #c then								-- if this is a contribution with contributor(s)
			if in_array (Contribution:lower(), cfg.keywords.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, Chapter, TransChapter, ChapterURL, ChapterURLorigin, no_quotes);		-- Contribution is also in Chapter
		if is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter.. sepc .. ' ';
		elseif is_set (ChapterFormat) then										-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'mailinglist', 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
	
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then
			Title = external_link( URL, Title, URLorigin ) .. TransError .. Format;
-- this experiment hidden 2016-04-10; see Help_talk:Citation_Style_1#Recycled_urls
--			local temp_title = external_link( URL, Title, URLorigin ) .. TransError .. Format;	-- do this so we get error message even if url is usurped no archive
--			if in_array (DeadURL, {'unfit no archive', 'usurped no archive'}) then	-- when url links to inappropriate location and there is no archive of original source available
--				local err_msg
--				if temp_title:match ('%[%S+%s+(.+)%](&lt;.+)') then				-- if there is an error message
--					Title, err_msg = temp_title:match ('%[%S+%s+(.+)%](&lt;.+)');	-- strip off external link; TODO: find a better to do this
--					Title = Title .. (err_msg or '');
--				end
--			else
--				Title = temp_title;
--			end

			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURLorigin );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if is_set(Minutes) then
			if is_set (Time) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'minutes') .. ' and ' .. wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
		Others = sepc .. ' Translated by ' .. Translators .. Others; 
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

--[[
Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
note is displayed. There are no error messages for this condition.

]]
	if is_set (SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif is_set (RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if 'citation', lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text
																				-- neither of these work; don't know why; it seems that substitute() isn't being called	
		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then				-- if first and last characters of quote are quote marks
			Quote = Quote:sub(2,-2);											-- strip them off
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL') ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- DeadURL is empty, 'yes', 'true', 'y', 'unfit', 'usurped'
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if in_array (DeadURL, {'unfit', 'usurped'}) then
				Archived = sepc .. &quot; &quot; .. 'Archived from the original on ' .. ArchiveDate;	-- format already styled
			else																-- DeadURL is empty, 'yes', 'true', or 'y'
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURLorigin ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL') ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL') ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURLorigin );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin );
	end

	local Publisher;
	if is_set(Periodical) and
		not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap_msg ('published', PublicationDate);
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap_msg ('published', PublicationDate) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
			Language, Edition, Publisher, Agency, Volume}, sepc );
		
	elseif in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(Periodical) then		-- special cases for book cites
		if is_set (Contributors) then											-- when we are citing foreword, preface, introduction, etc
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Transcript, Language, Edition, Publisher}, sepc );
	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if is_set(Date) then
		if is_set (Authors) or is_set (Editors) then							-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;;				-- in paranetheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon,-1,-1) == sepc) then							-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigYear;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigYear;							-- Date begins with sepc
			end
		end
	end	
	if is_set(Authors) then
		if is_set(Coauthors) then
			if 'vanc' == NameListFormat then									-- separate authors and coauthors with proper name-list-separator
				Authors = Authors .. ', ' .. Coauthors;
			else
				Authors = Authors .. '; ' .. Coauthors;
			end
		end
		if not is_set (Date) then												-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then in_text = in_text:lower() end				-- lowercase for cs2
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if is_set (Contributors) then											-- book cite and we're citing the intro, preface, etc
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if is_set (Editors) then											-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if not is_set (Date) then											-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = config.CitationClass;
		options.class = &quot;citation &quot; .. config.CitationClass;					-- class=citation required for blue highlight when used with |ref=
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then								-- set reference anchor if appropriate
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			id = anchor_id (namelist, year);									-- go make the CITEREF anchor
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then													-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		text = substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text});	-- when |ref= is set
	else
		text = substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text});	-- all other cases
	end		

	text = text .. substitute (cfg.presentation['ocins'], {OCinSoutput});		-- append metadata to the citation
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. error_comment( v[1], v[2] );
				else
					text = text .. error_comment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end

	if #z.maintenance_cats ~= 0 then
		text = text .. '&lt;span class=&quot;citation-comment&quot; style=&quot;display:none; color:#33aa33&quot;&gt;';
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. ' ' .. v .. ' ([[:Category:' .. v ..'|link]])';
		end
		text = text .. '&lt;/span&gt;';	-- maintenance mesages (realy just the names of the categories for now)
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

--[[--------------------------&lt; C S 1 . C I T A T I O N &gt;------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

function cs1.citation(frame)
	local pframe = frame:getParent()
	local validation, utilities, identifiers, metadata;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (utilities);								-- so that functions in Date validataion can see the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	dates = validation.dates;													-- imported functions from Module:Citation/CS1/Date validation
	year_date_check = validation.year_date_check;
	reformat_dates = validation.reformat_dates;
	
	is_set = utilities.is_set;													-- imported functions from Module:Citation/CS1/Utilities
	in_array = utilities.in_array;
	substitute = utilities.substitute;
	error_comment = utilities.error_comment;
	set_error = utilities.set_error;
	select_one = utilities.select_one;
	add_maint_cat = utilities.add_maint_cat;
	wrap_style = utilities.wrap_style;
	safe_for_italics = utilities.safe_for_italics;
	remove_wiki_link = utilities.remove_wiki_link;

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	extract_ids = identifiers.extract_ids;										-- imported functions from Module:Citation/CS1/Utilities
	build_id_list = identifiers.build_id_list;
	is_embargoed = identifiers.is_embargoed;
	
	make_coins_title = metadata.make_coins_title;								-- imported functions from Module:Citation/CS1/COinS
	get_coins_pages = metadata.get_coins_pages;
	COinS = metadata.COinS;

	
	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute( param, capture );				-- add the capture to the suggested parameter (typically the enumerator)
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, param}, true );	-- set the error message
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			missing_pipe_check (v);												-- do we think that there is a parameter that is missing a pipe?
			
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);
		end
	end
	return citation0( config, args)
end

return cs1;</text>
      <sha1>k0lpv6lukx36vlb8s9bsh88nk9fuipx</sha1>
    </revision>
    <revision>
      <id>4706</id>
      <parentid>4705</parentid>
      <timestamp>2016-04-16T11:37:17Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>fix archive_url_check();</comment>
      <origin>4706</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="145072" sha1="3jc0trrl3ej8pp0lu14wbwxj2xwcgz0" xml:space="preserve">
local cs1 ={};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local dates, year_date_check, reformat_dates									-- functions in Module:Citation/CS1/Date_validation

local is_set, in_array, substitute, error_comment, set_error, select_one,		-- functions in Module:Citation/CS1/Utilities
	add_maint_cat, wrap_style, safe_for_italics, remove_wiki_link;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local extract_ids, build_id_list, is_embargoed;									-- functions in Module:Citation/CS1/Identifiers

local make_coins_title, get_coins_pages, COinS;									-- functions in Module:Citation/CS1/COinS

local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist

--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end

--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

]]

local added_prop_cats = {}														-- list of property categories that have been added to z.properties_cats
local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));		-- make name then add to table
	end
end

--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

]]

local added_vanc_errs;															-- flag so we only emit one Vancouver error / category
local function add_vanc_error ()
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a uri scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of tlds: https://www.iana.org/domains/root/db

rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the tld.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a url with a scheme) will be stripped
here.  Perhaps not necessary but retained incase it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ascii characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the tld) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org TLD
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and tld or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%a%d]') then										-- first character must be letter or digit
		return false;
	end
																				-- Do most common case first
	if domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.%a%a+$') then				-- three or more character hostname.hostname or hostname.tld
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.xn%-%-[%a%d]+$') then	-- internationalized domain name with ACE prefix
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.org$') then							-- one character .org hostname
		return true;
	elseif domain:match ('%f[%a][qxz]%.com$') then								-- assigned one character .com hostname (x.com times out 2015-12-10)
		return true;
	elseif domain:match ('%f[%a][iq]%.net$') then								-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.%a%a$') then							-- one character hostname and cctld (2 chars)
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d]%.%a%a+$') then					-- two character hostname and tld
		return true;
	elseif domain:match ('^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?') then		-- IPv4 address
		return true;
	else
		return false;
	end
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a url appear to be a valid url; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if is_set (scheme) then														-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when url is protocol relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a url into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following tld) (if any) and any path(/), query(?) or fragment(#).

If protocol relative url, return nil scheme and domain else return nil for both scheme and domain.

When not protocol relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol relative url
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		authority = authority:gsub ('//', '', 1);								-- replace place 1 pair of '/' with nothing;
		if is_set(authority) then												-- if anything left (1 or 3+ '/' where authority should be) then
			return scheme;														-- return scheme only making domain nil which will cause an error message
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link= etc for properly formatted content: no wikilinks, no urls

Link parameters are to hold the title of a wikipedia article so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki urls and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid url (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid url (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from url; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid url
end

--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wikilinked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

]]

local function link_title_ok (link, lorig, title, torig)
local orig;

	if is_set (link) then 														-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		end
	end

	if is_set (orig) then
		table.insert( z.message_tail, { set_error( 'bad_paramlink', orig)});	-- url or wikilink in |title= with |title-link=;
	end
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the url into scheme and domain
portions, or for protocol relative (//example.com) urls, just the domain.  Use is_url() to validate the two
portions of the url.  If both are valid, or for protocol relative if domain is valid, return true, else false.

Because it is different from a standard url, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper url
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from url;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a url.  The test will also find external wikilinks
that use protocol relative urls. Also finds bare urls.

The frontier pattern prevents a match on interwiki links which are similar to scheme:path urls.  The tests that
find bracketed urls are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol relative ext wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare url with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol relative bare url: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a url
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then												-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source )
	local error_str = &quot;&quot;;
	local domain;
	local path;
	
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the url into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['[']='%5b',[']']='%5d'});					-- replace '[' and ']' with their percent encoded values
		URL=domain..path;														-- and reassemble
	end
	
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url( label ), &quot;]&quot;, error_str });
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

]]

local page_in_deprecated_cat;													-- sticky flag so that the category is added only once
local function deprecated_parameter(name)
	if not page_in_deprecated_cat then
		page_in_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end

--[[--------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Call this function for chapter titles, for website titles, etc; not for book titles.

]]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	
	cap, cap2 = str:match (&quot;^([\&quot;\'])([^\'].+)&quot;);								-- match leading double or single quote but not double single quotes
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-left'], {cap, cap2});
	end

	cap, cap2 = str:match (&quot;^(.+[^\'])([\&quot;\'])$&quot;)
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-right'], {cap, cap2});
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title= and |script-chapter=

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, {'am', 'ar', 'be', 'bg', 'bs', 'dv', 'el', 'fa', 'he', 'hy', 'ja', 'ka', 'ko', 'ku', 'mk', 'ml', 'ps', 'ru', 'sd', 'sr', 'th', 'uk', 'ug', 'yi', 'zh'}) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				add_prop_cat ('script')
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return substitute( msg, str );										-- including template text
	else
		return substitute( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (scriptchapter, chapter, transchapter, chapterurl, chapter_url_source, no_quotes)
	local chapter_error = '';
	
	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);										-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
			chapter = wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, scriptchapter)						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (transchapter) then
		transchapter = wrap_style ('trans-quoted-title', transchapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. transchapter;
		else																	-- here when transchapter without chapter or script-chapter
			chapter = transchapter;												-- 
			chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
		end
	end

	if is_set (chapterurl) then
		chapter = external_link (chapterurl, chapter, chapter_url_source);		-- adds bare_url_missing_title error if appropriate
	end

	return chapter .. chapter_error;
end

--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Detects but ignores the character pattern that results from the transclusion of {{'}} templates.

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i=1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- Test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position then
			if 'nowiki' == capture or 'math' == capture then 					-- nowiki, math stripmarker (not an error condition)
				stripmarker = true;												-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { set_error( 'invisible_char', {err_msg, wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i=i+1;																	-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end

--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash

]]

local function hyphen_to_dash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if comp:sub(1,1) == duplicate_char then								-- is first charactier same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for th
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = str:sub(-1,-1);										-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = str:sub(1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = str:sub(1, -4) .. &quot;''&quot;;							-- remove them and add back ''
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then		-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then		-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then			-- if last two chars of str are sepc] external link
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;'']&quot; then		-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then				-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = str:sub(1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end		-- if duplicate_char not a letter then escape it
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )			-- remove duplicate_char if it follows html markup
					else
						value = value:sub( 2, -1 );								-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end  

--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

At the time of this writing, I had to write the 'if nil == mw.ustring.find ...' test ouside of the code editor and paste it here
because the code editor gets confused between character insertion point and cursor position.

]]

local function is_good_vanc_name (last, first)
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]*$&quot;) then
		add_vanc_error ();
		return false;															-- not a string of latin characters; Vancouver required Romanization
	end;
	return true;
end

--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  This form is not
currently supported by this code so correctly formed names like Smith JL 2nd are converted to Smith J2. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	if mw.ustring.match(first, &quot;^%u%u$&quot;) then return first end;					-- when first contains just two upper-case letters, nothing to do
	local initials = {}
	local i = 0;																-- counter for number of initials
	for word in mw.ustring.gmatch(first, &quot;[^%s%.%-]+&quot;) do						-- names separated by spaces, hyphens, or periods
		table.insert(initials, mw.ustring.sub(word,1,1))						-- Vancouver format does not include full stops.
		i = i + 1;																-- bump the counter 
		if 2 &lt;= i then break; end												-- only two initials allowed in Vancouver system; if 2, quit
	end
	return table.concat(initials)												-- Vancouver format does not include spaces.
end

--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = ',';																-- name-list separator between authors is a comma
		namesep = ' ';															-- last/first separator is a space
	else
		sep = ';'																-- name-list separator between authors is a semicolon
		namesep = ', '															-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then					-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first 
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;				-- link author/editor if this page is not the author's/editor's page
				end
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end

--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]
local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of author and editor name parameters for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the parameters |display-authors=etal or |display-editors=etal

]]

local function name_has_etal (name, etal, nocat)

	if is_set (name) then														-- name can be nil in which case just return
		local etal_pattern = &quot;[;,]? *[\&quot;']*%f[%a][Ee][Tt] *[Aa][Ll][%.\&quot;']*$&quot;	-- variations on the 'et al' theme
		local others_pattern = &quot;[;,]? *%f[%a]and [Oo]thers&quot;;					-- and alternate to et al.
		
		if name:match (etal_pattern) then										-- variants on et al.
			name = name:gsub (etal_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		elseif name:match (others_pattern) then									-- if not 'et al.', then 'and others'?
			name = name:gsub (others_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		end
	end
	return name, etal;															-- 
end

--[[--------------------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;----------------------------------------

Evaluates the content of author and editor (surnames only) parameters for multiple names.  Multiple names are
indicated if there is more than one comma and or semicolon.  If found, the function adds the multiple name
(author or editor) maintenance category.

]]

local function name_has_mult_names (name, list_name)
local count, _;
	if is_set (name) then
		if name:match ('^%(%(.*%)%)$') then										-- if wrapped in doubled parentheses, ignore 
			name = name:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			_, count = name:gsub ('[;,]', '');									-- count the number of separator-like characters
			
			if 1 &lt; count then													-- param could be |author= or |editor= so one separactor character is acceptable
				add_maint_cat ('mult_names', list_name:lower());				-- more than one separator indicates multiple names so add a maint cat for this template
			end
		end
	end
	return name;																-- and done
end

--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary
	while true do
		last = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false);							-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false);						-- find and remove variations on et al.
		last = name_has_mult_names (last, err_msg_list_name);					-- check for multiple names in last and its aliases
		
		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			link_title_ok (link, list_name:match (&quot;(%w+)List&quot;):lower() .. '-link' .. i, last, list_name:match (&quot;(%w+)List&quot;):lower() .. '-last' .. i);	-- check for improper wikimarkup

			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because case of the source may be incorrect
or different from the case that WikiMedia uses, the name comparisons are done in lower case and when a match is
found, the Wikimedia version (assumed to be correct) is returned along with the code.  When there is no match, we
return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') return a list of languages that in some cases may include
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.

Names but that are included in the list will be found if that name is provided in the |language= parameter.  For example,
if |language=Chavacano de Zamboanga, that name will be found with the associated code 'cbk-zam'.  When names are found
and the associated code is not two or three characters, this function returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	local languages = mw.language.fetchLanguageNames(this_wiki_code, 'all')		-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() and 3 ~= code:len() then							-- two- or three-character codes only; extensions not supported
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the the code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for the code
end

--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code is recognized by MediaWiki,
use the returned name; if not, then use the value that was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is assigned to the category for
that code: Category:Norwegian-language sources (no).  For valid three-character code languages, the page is assigned
to the single category for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does not recognize three-character
equivalents of two-character codes: code 'ar' is recognized bit code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are
separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki = mw.getContentLanguage();									-- get a language object for this wiki
	local this_wiki_code = this_wiki:getCode()									-- get this wiki's language code
	local this_wiki_name = mw.language.fetchLanguageName(this_wiki_code, this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang

		if lang:match ('^%a%a%-') then											-- strip ietf language tags from code; TODO: is there a need to support 3-char with tag?
			lang = lang:match ('(%a%a)%-')										-- keep only 639-1 code portion to lang; TODO: do something with 3166 alpha 2 country code?
		end
		if 2 == lang:len() or 3 == lang:len() then								-- if two-or three-character code
			name = mw.language.fetchLanguageName( lang:lower(), this_wiki_code);	-- get language name if |language= is a proper code
		end
	
		if is_set (name) then													-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, this_wiki_code);				-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then													-- only 2- or 3-character codes
			if this_wiki_code ~= code then										-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					add_prop_cat ('foreign_lang_source', {name, code})			-- categorize it
				else															-- or is a recognized language (but has a three-character code)
					add_prop_cat ('foreign_lang_source_2', {code})				-- categorize it differently TODO: support mutliple three-character code categories per cs1|2 template
				end
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, ' and ')							-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		language_list[code] = 'and ' .. language_list[code];					-- prepend last name with 'and&lt;space&gt;'
		name = table.concat (language_list, ', ')								-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
	end
	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
end

--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = '.';																-- terminate the rendered citation with a period
	end
	return '.', ps;																-- separator is a full stop
end

--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = '';																-- make sure it isn't nil
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return ',', ps, ref;														-- separator is a comma
end

--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end

--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extension, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf[%?#]?') or url:match ('%.PDF[%?#]?');
end

--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parenthases, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end

--[[--------------------------&lt; G E T _ D I S P L A Y _ A U T H O R S _ E D I T O R S &gt;------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_authors_editors (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_auth_ed', list_name);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end

--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
--	local good_pattern = '^P[^%.P%l]';
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
--	local bad_pattern = '^[Pp][Pp]';
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
--		if Page:match ('^[Pp]?[Pp]%.?[ %d]') or  Page:match ('^[Pp]ages?[ %d]') or
--			Pages:match ('^[Pp]?[Pp]%.?[ %d]') or  Pages:match ('^[Pp]ages?[ %d]') then
--				add_maint_cat ('extra_text');
--		end
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

TODO: check for names like Coon V JS (Coon JS 5th at PMID 25205766, John S. Coon V at doi:10.1093/humupd/dmu048)?

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	if vparam:find ('%[%[') or vparam:find ('%]%]')	then						-- no wikilinking vauthors names
		add_vanc_error ();
	end
	v_name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;)								-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parenthese to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')
			corporate = true;
		elseif string.find(v_name, &quot;%s&quot;) then
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
			last  = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') or mw.ustring.match (v_name, ' %u %u$') then
				add_vanc_error ();												-- matches last II last; the case when a comma is missing or a space between two intiials
			end
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) and not mw.ustring.match (first, &quot;^%u?%u$&quot;) then		-- first shall contain one or two upper-case letters, nothing else
			add_vanc_error ();
		end
																				-- this from extract_names ()
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice incase we have a first 1 without a last1
		select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, no, etc).  When the parameter value has not been assigned a value (missing or empty
in the source template) the function refurns true.  If the parameter value is one of the list of allowed values returns
true; else, emits an error message and returns false.

]]

local function is_valid_parameter_value (value, name, possible)
	if not is_set (value) then
		return true;															-- an empty parameter is ok
	elseif in_array(value:lower(), possible) then
		return true;
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list,-1,-1) == sepc) or (string.sub (name_list,-3,-1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terninate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not is_set (volume) and not is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end
	
	local vol = '';
		
	if is_set (volume) then
		if (4 &lt; mw.ustring.len(volume)) then
			vol = substitute (cfg.messages['j-vol'], {sepc, volume});
		else
			vol = wrap_style ('vol-bold', hyphen_to_dash(volume));
		end
	end
	if is_set (issue) then
		return vol .. substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end






--[[-------------------------&lt; N O R M A L I Z E _ P A G E _ L I S T &gt;-----------------------------------------

not currently used

normalizes a comma, ampersand, and/or space separated list to be '&lt;value&gt;, &lt;value&gt;, ..., &lt;value&gt;'
returns list unchanged if there are no commas else strips whitespace and then reformats the list

]]
--[[
local function normalize_page_list (list)
	if not list:find ('[,&amp; ]') then return list end								-- if list is not delimited with commas, ampersands, or spaces; done
	
	list = mw.text.split (list, '[,&amp;%s]+');										-- make a table of values
	list = table.concat (list, ', ');											-- and now make a normalized list
	return list;
end
]]

--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'journal' == origin);

	if is_set (page) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif is_set(pages) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then										-- if pages is only digits, assume a single page number
			return '', substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org urls to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot url.  When the archive url is 'https://web.archive.org/save/' (or http://...) archive.org saves a snapshot
of the target page in the url.  That is something that Wikipedia should not allow unwitting readers to do.

When the archive.org url does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command url
	|archive-url= is an archive.org url that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the correct place
otherwise returns |archive-url= and |archive-date=

]=]

local function archive_url_check (url, date)
	if url:match('//web\.archive\.org/') then									-- for archive.org urls:
		if url:match('//web\.archive\.org/save/') then							-- if a save command url, we don't want to save target page 
			table.insert( z.message_tail, { set_error( 'archive_url', {'save command'}, true ) } );	-- add error message
			return '', '';														-- return empty strings for archiveURL and ArchiveDate
		elseif url:match('//web\.archive\.org/web/%d%d%d%d%d%d%d%d%d%d%d%d%d%d/') or	-- if there is what looks like a correct timestamp
			url:match('//web\.archive\.org/%d%d%d%d%d%d%d%d%d%d%d%d%d%d/') then			-- without /web/ gets remapped to have the /web/ by archive.org
				return url, date;												-- return archiveURL and ArchiveDate
		else																	-- malformed url
			table.insert( z.message_tail, { set_error( 'archive_url', {'timestamp'}, true ) } );	-- add error message
			return '', '';														-- return empty strings for archiveURL and ArchiveDate
		end
	end
	return url, date;															-- not an archive.org archive
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe:
	{{cite ... |title=Title access-date=2016-03-17}}

cs1|2 shares some parameter names with xml/html atributes: class=, title=, etc.  To prevent false positives xml/html
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove xml/html tags because attributes: class=, title=, etc 

	capture = value:match ('%s+(%a[%a%d]+)%s*=') or value:match ('^(%a[%a%d]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then								-- if the capture is a valid parameter name
		add_maint_cat ('missing_pipe');
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
		end
		if is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
		end
	end

	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list
	local Contribution = A['Contribution'];
	if in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not is_set (Contribution) then									-- |contributor= requires |contribution=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if select_one (args, cfg.aliases['ContributorList-Last'], 'redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { set_error( 'contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if not is_valid_parameter_value (NameListFormat, 'name-list-format', cfg.keywords['name-list-format']) then			-- only accepted value for this parameter is 'vanc'
		NameListFormat = '';													-- anything else, set to empty string
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
			link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wikimarkup in |title-link= or wikimarkup in |title= when |title-link= is set

	local Chapter = A['Chapter'];
	local ScriptChapter = A['ScriptChapter'];
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];

	local ArchiveDate;
	local ArchiveURL;

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	
--	local ArchiveDate = A['ArchiveDate'];
--	local ArchiveURL = A['ArchiveURL'];
--		if ArchiveURL:match('//web\.archive\.org/save/') then				-- if an archive.org save command url, we don't want to save target page ...
--			ArchiveURL = '';													-- every time a reader clicks the link so
--			ArchiveDate = '';													-- unset these
--			table.insert( z.message_tail, { set_error( 'archive_save', {}, true ) } );	-- and add error message
--		end
	local DeadURL = A['DeadURL']
		if not is_valid_parameter_value (DeadURL, 'dead-url', cfg.keywords ['deadurl']) then	-- set in config.defaults to 'yes'
			DeadURL = '';														-- anything else, set to empty string
		end

	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];
	local Periodical_origin = A:ORIGIN('Periodical');							-- get the name of the periodical parameter

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if in_array (config.CitationClass, cfg.templates_using_volume) and not ('conference' == config.CitationClass and not is_set (Periodical)) then
		Volume = A['Volume'];
	end
	if in_array (config.CitationClass, cfg.templates_using_issue) and not (in_array (config.CitationClass, {'conference', 'map'}) and not is_set (Periodical))then
		Issue = A['Issue'];
	end
	local Position = '';
	if not in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash( A['Pages'] );	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
		if not is_valid_parameter_value (RegistrationRequired, 'registration', cfg.keywords ['yes_true_y']) then
			RegistrationRequired=nil;
		end
	local SubscriptionRequired = A['SubscriptionRequired'];
		if not is_valid_parameter_value (SubscriptionRequired, 'subscription', cfg.keywords ['yes_true_y']) then
			SubscriptionRequired=nil;
		end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local Agency = A['Agency'];

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
		if not is_valid_parameter_value (IgnoreISBN, 'ignore-isbn-error', cfg.keywords ['yes_true_y']) then
			IgnoreISBN = nil;													-- anything else, set to empty string
		end
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
		if not is_valid_parameter_value (LastAuthorAmp, 'last-author-amp', cfg.keywords ['yes_true_y']) then
			LastAuthorAmp = nil;													-- set to empty string
		end
	local no_tracking_cats = A['NoTracking'];
		if not is_valid_parameter_value (no_tracking_cats, 'no-tracking', cfg.keywords ['yes_true_y']) then
			no_tracking_cats = nil;												-- set to empty string
		end

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = A['DF'];															-- date format set in cs1|2 template
	if not is_valid_parameter_value (DF, 'df', cfg.keywords['date-format']) then	-- validate reformatting keyword
		DF = '';																-- not valid, set to empty string
	end

-- set default parameter values defined by |mode= parameter.  If |mode= is empty or omitted, use CitationClass to set these values
	local Mode = A['Mode'];
	if not is_valid_parameter_value (Mode, 'mode', cfg.keywords['mode']) then
		Mode = '';
	end
	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	select_one( args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'redundant_parameters' );		-- this is a dummy call simply to get the error message and category

	local NoPP = A['NoPP'] 
	if is_set (NoPP) and is_valid_parameter_value (NoPP, 'nopp', cfg.keywords ['yes_true_y']) then
		NoPP = true;
	else
		NoPP = nil;																-- unset, used as a flag later
	end

	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Pages = '';															-- unset the others
			At = '';
		end
		extra_text_in_page_check (Page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.
	elseif is_set(Pages) then
		if is_set(At) then
			At = '';															-- unset
		end
		extra_text_in_page_check (Pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped
	|url maps to |chapterurl when |title is remapped

All other combinations of |encyclopedia, |title, and |article are not modified

]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					TransChapter = TransTitle;
					ChapterURL = URL;
					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter= '[[' .. TitleLink .. '|' .. Chapter .. ']]';
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			else																-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if is_set(A['Number']) then													-- cite techreport uses 'number', which other citations alias to 'issue'
			if not is_set(ID) then												-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];													-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', 'id') .. ' and ' .. wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Others) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Others;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Others;
			end
		else
			Others = '(Interview)';
		end
	end

-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	elseif 'mailinglist' == A:ORIGIN('Periodical') then
		Periodical = '';														-- unset because mailing list is only used for cite mailing list
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];

		link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wikimarkup in |series-link= or wikimarkup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) and is_set (AirDate) then							-- promote airdate to date
			Date = AirDate;
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('series', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = '[[' .. ChapterLink .. '|' .. Chapter .. ']]';		-- ok to wikilink
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = '[[' .. ChapterLink .. '|' .. Series .. ']]';			-- series links with ChapterLink (episodelink -&gt; TitleLink -&gt; ChapterLink) ugly
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = '[[' .. SeriesLink .. '|' .. Series .. ']]';
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
-- end of {{cite episode}} stuff

-- Account for the oddities that are {{cite arxiv}}, before generation of COinS data.
	if 'arxiv' == config.CitationClass then
		if not is_set (ID_list['ARXIV']) then									-- |arxiv= or |eprint= required for cite arxiv
			table.insert( z.message_tail, { set_error( 'arxiv_missing', {}, true ) } );		-- add error message
		elseif is_set (Series) then												-- series is an alias of version
			ID_list['ARXIV'] = ID_list['ARXIV'] .. Series;						-- concatenate version onto the end of the arxiv identifier
			Series = '';														-- unset
			deprecated_parameter ('version');									-- deprecated parameter but only for cite arxiv
		end
		
		if first_set ({AccessDate, At, Chapter, Format, Page, Pages, Periodical, PublisherName, URL,	-- a crude list of parameters that are not supported by cite arxiv
			ID_list['ASIN'], ID_list['BIBCODE'], ID_list['DOI'], ID_list['ISBN'], ID_list['ISSN'],
			ID_list['JFM'], ID_list['JSTOR'], ID_list['LCCN'], ID_list['MR'], ID_list['OCLC'], ID_list['OL'],
			ID_list['OSTI'], ID_list['PMC'], ID_list['PMID'], ID_list['RFC'], ID_list['SSRN'], ID_list['USENETID'], ID_list['ZBL']},27) then
				table.insert( z.message_tail, { set_error( 'arxiv_params_not_supported', {}, true ) } );		-- add error message

				AccessDate= '';													-- set these to empty string; not supported in cite arXiv
				PublisherName = '';												-- (if the article has been published, use cite journal, or other)
				Chapter = '';
				URL = '';
				Format = '';
				Page = ''; Pages = ''; At = '';
		end
		Periodical = 'arXiv';													-- set to arXiv for COinS; after that, must be set to empty string
	end

-- handle type parameter for those CS1 citations that have default values
	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
	TitleType = substitute( cfg.messages['type'], TitleType);					-- display it in parentheses
	end

-- legacy: promote concatenation of |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {['access-date']=AccessDate, ['archive-date']=ArchiveDate, ['date']=Date, ['doi-broken-date']=DoiBroken,
				['embargo']=Embargo, ['lay-date']=LayDate, ['publication-date']=PublicationDate, ['year']=Year};

		anchor_year, Embargo, error_message = dates(date_parameters_list, COinS_date);

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end

		if is_set(error_message) then
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		elseif is_set (DF) then
			if reformat_dates (date_parameters_list, DF, false) then			-- reformat to DF format, use long month names if appropriate
				AccessDate = date_parameters_list['access-date'];				-- overwrite date holding parameters with reformatted values
				ArchiveDate = date_parameters_list['archive-date'];
				Date = date_parameters_list['date'];
				DoiBroken = date_parameters_list['doi-broken-date'];
				LayDate = date_parameters_list['lay-date'];
				PublicationDate = date_parameters_list['publication-date'];
			end
		end
	end	-- end of do

-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);											-- 

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
			if 'episode' == config.CitationClass then							-- special case for cite episode; TODO: is there a better way to do this?
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
			else
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
			end
	end
	
	if 'none' == Title and in_array (config.CitationClass, {'journal', 'citation'}) and is_set (Periodical) and 'journal' == A:ORIGIN('Periodical') then	-- special case for journal cites
		Title = '';																-- set title to empty string
		add_maint_cat ('untitled');
	end

	check_for_url ({															-- add error message when any of these parameters contains a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[A:ORIGIN('Periodical')]=Periodical,
		[A:ORIGIN('PublisherName')] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = Periodical,
		['Encyclopedia'] = Encyclopedia,
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

-- Account for the oddities that are {{cite arxiv}}, AFTER generation of COinS data.
	if 'arxiv' == config.CitationClass then										-- we have set rft.jtitle in COinS to arXiv, now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in cite arxiv; if article has been published, use cite journal
	end

-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = substitute (cfg.messages['newsgroup'], external_link( 'news:' .. PublisherName, PublisherName, A:ORIGIN('PublisherName') ));
		end
	end



	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
--		local maximum;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text											-- get current page name so that we don't wikilink to it via editorlinkn
		};

		do																		-- do editor name list first because coauthors can modify control table
			control.maximum , editor_etal = get_display_authors_editors (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if is_set (Editors) then
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
					EditorCount = 2;											-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
				else
					EditorCount = 2;											-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
				end
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do translators
			control.maximum = #t;												-- number of translators
			Translators = list_people(control, t, false);						-- et al not currently supported
		end
		do																		-- now do contributors
			control.maximum = #c;												-- number of contributors
			Contributors = list_people(control, c, false);						-- et al not currently supported
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_authors_editors (A['DisplayAuthors'], #a, 'authors', author_etal);

			if is_set(Coauthors) then											-- if the coauthor field is also used, prevent ampersand and et al. formatting.
				control.lastauthoramp = nil;
				control.maximum = #a + 1;
			end
			
			last_first_list = list_people(control, a, author_etal);

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false);	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if is_set (Authors) and is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

		if not is_set(Authors) and is_set(Coauthors) then						-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
			table.insert( z.message_tail, { set_error('coauthors_missing_author', {}, true) } );	-- emit error message
		end
	end

-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

-- special case for chapter format so no error message or cat when chapter not supported
	if not (in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not is_set(URL) then
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then	-- |url= required for cite web, cite podcast, and cite mailinglist
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURLorigin, OriginalFormat;						-- TODO: swap chapter and title here so that archive applies to most specific if both are set?
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (ChapterURL) then 	-- swapped									-- URL not set so if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURLorigin = ChapterURLorigin;								-- name of chapter-url parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |format=
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				ChapterURLorigin = A:ORIGIN('ArchiveURL')						-- name of archive-url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
			end
		elseif is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURLorigin = URLorigin;										-- name of url parameter for error messages
			OriginalFormat = Format;											-- and original |format=
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
			end
 		end
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'arxiv'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			local chap_param;
			if is_set (Chapter) then											-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif is_set (ScriptChapter) then
				chap_param = A:ORIGIN ('ScriptChapter')
			else is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if is_set (chap_param) then											-- if we found one
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {chap_param}, true ) } );		-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if is_set (Contribution) and 0 &lt; #c then								-- if this is a contribution with contributor(s)
			if in_array (Contribution:lower(), cfg.keywords.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, Chapter, TransChapter, ChapterURL, ChapterURLorigin, no_quotes);		-- Contribution is also in Chapter
		if is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter.. sepc .. ' ';
		elseif is_set (ChapterFormat) then										-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'mailinglist', 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
	
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then
			Title = external_link( URL, Title, URLorigin ) .. TransError .. Format;
-- this experiment hidden 2016-04-10; see Help_talk:Citation_Style_1#Recycled_urls
--			local temp_title = external_link( URL, Title, URLorigin ) .. TransError .. Format;	-- do this so we get error message even if url is usurped no archive
--			if in_array (DeadURL, {'unfit no archive', 'usurped no archive'}) then	-- when url links to inappropriate location and there is no archive of original source available
--				local err_msg
--				if temp_title:match ('%[%S+%s+(.+)%](&lt;.+)') then				-- if there is an error message
--					Title, err_msg = temp_title:match ('%[%S+%s+(.+)%](&lt;.+)');	-- strip off external link; TODO: find a better to do this
--					Title = Title .. (err_msg or '');
--				end
--			else
--				Title = temp_title;
--			end

			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURLorigin );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if is_set(Minutes) then
			if is_set (Time) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'minutes') .. ' and ' .. wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
		Others = sepc .. ' Translated by ' .. Translators .. Others; 
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

--[[
Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
note is displayed. There are no error messages for this condition.

]]
	if is_set (SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif is_set (RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if 'citation', lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text
																				-- neither of these work; don't know why; it seems that substitute() isn't being called	
		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then				-- if first and last characters of quote are quote marks
			Quote = Quote:sub(2,-2);											-- strip them off
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL') ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- DeadURL is empty, 'yes', 'true', 'y', 'unfit', 'usurped'
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if in_array (DeadURL, {'unfit', 'usurped'}) then
				Archived = sepc .. &quot; &quot; .. 'Archived from the original on ' .. ArchiveDate;	-- format already styled
			else																-- DeadURL is empty, 'yes', 'true', or 'y'
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURLorigin ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL') ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL') ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURLorigin );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin );
	end

	local Publisher;
	if is_set(Periodical) and
		not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap_msg ('published', PublicationDate);
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap_msg ('published', PublicationDate) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
			Language, Edition, Publisher, Agency, Volume}, sepc );
		
	elseif in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(Periodical) then		-- special cases for book cites
		if is_set (Contributors) then											-- when we are citing foreword, preface, introduction, etc
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Transcript, Language, Edition, Publisher}, sepc );
	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if is_set(Date) then
		if is_set (Authors) or is_set (Editors) then							-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;;				-- in paranetheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon,-1,-1) == sepc) then							-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigYear;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigYear;							-- Date begins with sepc
			end
		end
	end	
	if is_set(Authors) then
		if is_set(Coauthors) then
			if 'vanc' == NameListFormat then									-- separate authors and coauthors with proper name-list-separator
				Authors = Authors .. ', ' .. Coauthors;
			else
				Authors = Authors .. '; ' .. Coauthors;
			end
		end
		if not is_set (Date) then												-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then in_text = in_text:lower() end				-- lowercase for cs2
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if is_set (Contributors) then											-- book cite and we're citing the intro, preface, etc
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if is_set (Editors) then											-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if not is_set (Date) then											-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = config.CitationClass;
		options.class = &quot;citation &quot; .. config.CitationClass;					-- class=citation required for blue highlight when used with |ref=
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then								-- set reference anchor if appropriate
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			id = anchor_id (namelist, year);									-- go make the CITEREF anchor
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then													-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		text = substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text});	-- when |ref= is set
	else
		text = substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text});	-- all other cases
	end		

	text = text .. substitute (cfg.presentation['ocins'], {OCinSoutput});		-- append metadata to the citation
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. error_comment( v[1], v[2] );
				else
					text = text .. error_comment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end

	if #z.maintenance_cats ~= 0 then
		text = text .. '&lt;span class=&quot;citation-comment&quot; style=&quot;display:none; color:#33aa33&quot;&gt;';
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. ' ' .. v .. ' ([[:Category:' .. v ..'|link]])';
		end
		text = text .. '&lt;/span&gt;';	-- maintenance mesages (realy just the names of the categories for now)
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

--[[--------------------------&lt; C S 1 . C I T A T I O N &gt;------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

function cs1.citation(frame)
	local pframe = frame:getParent()
	local validation, utilities, identifiers, metadata;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (utilities);								-- so that functions in Date validataion can see the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	dates = validation.dates;													-- imported functions from Module:Citation/CS1/Date validation
	year_date_check = validation.year_date_check;
	reformat_dates = validation.reformat_dates;
	
	is_set = utilities.is_set;													-- imported functions from Module:Citation/CS1/Utilities
	in_array = utilities.in_array;
	substitute = utilities.substitute;
	error_comment = utilities.error_comment;
	set_error = utilities.set_error;
	select_one = utilities.select_one;
	add_maint_cat = utilities.add_maint_cat;
	wrap_style = utilities.wrap_style;
	safe_for_italics = utilities.safe_for_italics;
	remove_wiki_link = utilities.remove_wiki_link;

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	extract_ids = identifiers.extract_ids;										-- imported functions from Module:Citation/CS1/Utilities
	build_id_list = identifiers.build_id_list;
	is_embargoed = identifiers.is_embargoed;
	
	make_coins_title = metadata.make_coins_title;								-- imported functions from Module:Citation/CS1/COinS
	get_coins_pages = metadata.get_coins_pages;
	COinS = metadata.COinS;

	
	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute( param, capture );				-- add the capture to the suggested parameter (typically the enumerator)
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, param}, true );	-- set the error message
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			missing_pipe_check (v);												-- do we think that there is a parameter that is missing a pipe?
			
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);
		end
	end
	return citation0( config, args)
end

return cs1;</text>
      <sha1>3jc0trrl3ej8pp0lu14wbwxj2xwcgz0</sha1>
    </revision>
    <revision>
      <id>4707</id>
      <parentid>4706</parentid>
      <timestamp>2016-04-17T19:16:37Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>revised archive url check</comment>
      <origin>4707</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="146555" sha1="gbnqozm27iqaj677tjhbh2pfiw6xtww" xml:space="preserve">
local cs1 ={};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local dates, year_date_check, reformat_dates									-- functions in Module:Citation/CS1/Date_validation

local is_set, in_array, substitute, error_comment, set_error, select_one,		-- functions in Module:Citation/CS1/Utilities
	add_maint_cat, wrap_style, safe_for_italics, remove_wiki_link;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local extract_ids, build_id_list, is_embargoed;									-- functions in Module:Citation/CS1/Identifiers

local make_coins_title, get_coins_pages, COinS;									-- functions in Module:Citation/CS1/COinS

local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist

--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end

--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

]]

local added_prop_cats = {}														-- list of property categories that have been added to z.properties_cats
local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));		-- make name then add to table
	end
end

--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

]]

local added_vanc_errs;															-- flag so we only emit one Vancouver error / category
local function add_vanc_error ()
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a uri scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of tlds: https://www.iana.org/domains/root/db

rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the tld.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a url with a scheme) will be stripped
here.  Perhaps not necessary but retained incase it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ascii characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the tld) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org TLD
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and tld or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%a%d]') then										-- first character must be letter or digit
		return false;
	end
																				-- Do most common case first
	if domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.%a%a+$') then				-- three or more character hostname.hostname or hostname.tld
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.xn%-%-[%a%d]+$') then	-- internationalized domain name with ACE prefix
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.org$') then							-- one character .org hostname
		return true;
	elseif domain:match ('%f[%a][qxz]%.com$') then								-- assigned one character .com hostname (x.com times out 2015-12-10)
		return true;
	elseif domain:match ('%f[%a][iq]%.net$') then								-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.%a%a$') then							-- one character hostname and cctld (2 chars)
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d]%.%a%a+$') then					-- two character hostname and tld
		return true;
	elseif domain:match ('^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?') then		-- IPv4 address
		return true;
	else
		return false;
	end
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a url appear to be a valid url; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if is_set (scheme) then														-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when url is protocol relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a url into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following tld) (if any) and any path(/), query(?) or fragment(#).

If protocol relative url, return nil scheme and domain else return nil for both scheme and domain.

When not protocol relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol relative url
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		authority = authority:gsub ('//', '', 1);								-- replace place 1 pair of '/' with nothing;
		if is_set(authority) then												-- if anything left (1 or 3+ '/' where authority should be) then
			return scheme;														-- return scheme only making domain nil which will cause an error message
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link= etc for properly formatted content: no wikilinks, no urls

Link parameters are to hold the title of a wikipedia article so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki urls and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid url (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid url (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from url; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid url
end

--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wikilinked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

]]

local function link_title_ok (link, lorig, title, torig)
local orig;

	if is_set (link) then 														-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		end
	end

	if is_set (orig) then
		table.insert( z.message_tail, { set_error( 'bad_paramlink', orig)});	-- url or wikilink in |title= with |title-link=;
	end
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the url into scheme and domain
portions, or for protocol relative (//example.com) urls, just the domain.  Use is_url() to validate the two
portions of the url.  If both are valid, or for protocol relative if domain is valid, return true, else false.

Because it is different from a standard url, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper url
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from url;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a url.  The test will also find external wikilinks
that use protocol relative urls. Also finds bare urls.

The frontier pattern prevents a match on interwiki links which are similar to scheme:path urls.  The tests that
find bracketed urls are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol relative ext wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare url with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol relative bare url: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a url
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then												-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source )
	local error_str = &quot;&quot;;
	local domain;
	local path;
	
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the url into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['[']='%5b',[']']='%5d'});					-- replace '[' and ']' with their percent encoded values
		URL=domain..path;														-- and reassemble
	end
	
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url( label ), &quot;]&quot;, error_str });
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

]]

local page_in_deprecated_cat;													-- sticky flag so that the category is added only once
local function deprecated_parameter(name)
	if not page_in_deprecated_cat then
		page_in_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end

--[[--------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Call this function for chapter titles, for website titles, etc; not for book titles.

]]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	
	cap, cap2 = str:match (&quot;^([\&quot;\'])([^\'].+)&quot;);								-- match leading double or single quote but not double single quotes
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-left'], {cap, cap2});
	end

	cap, cap2 = str:match (&quot;^(.+[^\'])([\&quot;\'])$&quot;)
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-right'], {cap, cap2});
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title= and |script-chapter=

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, {'am', 'ar', 'be', 'bg', 'bs', 'dv', 'el', 'fa', 'he', 'hy', 'ja', 'ka', 'ko', 'ku', 'mk', 'ml', 'ps', 'ru', 'sd', 'sr', 'th', 'uk', 'ug', 'yi', 'zh'}) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				add_prop_cat ('script')
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return substitute( msg, str );										-- including template text
	else
		return substitute( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (scriptchapter, chapter, transchapter, chapterurl, chapter_url_source, no_quotes)
	local chapter_error = '';
	
	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);										-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
			chapter = wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, scriptchapter)						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (transchapter) then
		transchapter = wrap_style ('trans-quoted-title', transchapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. transchapter;
		else																	-- here when transchapter without chapter or script-chapter
			chapter = transchapter;												-- 
			chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
		end
	end

	if is_set (chapterurl) then
		chapter = external_link (chapterurl, chapter, chapter_url_source);		-- adds bare_url_missing_title error if appropriate
	end

	return chapter .. chapter_error;
end

--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Detects but ignores the character pattern that results from the transclusion of {{'}} templates.

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i=1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- Test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position then
			if 'nowiki' == capture or 'math' == capture then 					-- nowiki, math stripmarker (not an error condition)
				stripmarker = true;												-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { set_error( 'invisible_char', {err_msg, wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i=i+1;																	-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end

--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash

]]

local function hyphen_to_dash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if comp:sub(1,1) == duplicate_char then								-- is first charactier same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for th
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = str:sub(-1,-1);										-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = str:sub(1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = str:sub(1, -4) .. &quot;''&quot;;							-- remove them and add back ''
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then		-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then		-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then			-- if last two chars of str are sepc] external link
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;'']&quot; then		-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then				-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = str:sub(1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end		-- if duplicate_char not a letter then escape it
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )			-- remove duplicate_char if it follows html markup
					else
						value = value:sub( 2, -1 );								-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end  

--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

At the time of this writing, I had to write the 'if nil == mw.ustring.find ...' test ouside of the code editor and paste it here
because the code editor gets confused between character insertion point and cursor position.

]]

local function is_good_vanc_name (last, first)
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]*$&quot;) then
		add_vanc_error ();
		return false;															-- not a string of latin characters; Vancouver required Romanization
	end;
	return true;
end

--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  This form is not
currently supported by this code so correctly formed names like Smith JL 2nd are converted to Smith J2. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	if mw.ustring.match(first, &quot;^%u%u$&quot;) then return first end;					-- when first contains just two upper-case letters, nothing to do
	local initials = {}
	local i = 0;																-- counter for number of initials
	for word in mw.ustring.gmatch(first, &quot;[^%s%.%-]+&quot;) do						-- names separated by spaces, hyphens, or periods
		table.insert(initials, mw.ustring.sub(word,1,1))						-- Vancouver format does not include full stops.
		i = i + 1;																-- bump the counter 
		if 2 &lt;= i then break; end												-- only two initials allowed in Vancouver system; if 2, quit
	end
	return table.concat(initials)												-- Vancouver format does not include spaces.
end

--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = ',';																-- name-list separator between authors is a comma
		namesep = ' ';															-- last/first separator is a space
	else
		sep = ';'																-- name-list separator between authors is a semicolon
		namesep = ', '															-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then					-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first 
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;				-- link author/editor if this page is not the author's/editor's page
				end
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end

--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]
local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of author and editor name parameters for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the parameters |display-authors=etal or |display-editors=etal

]]

local function name_has_etal (name, etal, nocat)

	if is_set (name) then														-- name can be nil in which case just return
		local etal_pattern = &quot;[;,]? *[\&quot;']*%f[%a][Ee][Tt] *[Aa][Ll][%.\&quot;']*$&quot;	-- variations on the 'et al' theme
		local others_pattern = &quot;[;,]? *%f[%a]and [Oo]thers&quot;;					-- and alternate to et al.
		
		if name:match (etal_pattern) then										-- variants on et al.
			name = name:gsub (etal_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		elseif name:match (others_pattern) then									-- if not 'et al.', then 'and others'?
			name = name:gsub (others_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		end
	end
	return name, etal;															-- 
end

--[[--------------------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;----------------------------------------

Evaluates the content of author and editor (surnames only) parameters for multiple names.  Multiple names are
indicated if there is more than one comma and or semicolon.  If found, the function adds the multiple name
(author or editor) maintenance category.

]]

local function name_has_mult_names (name, list_name)
local count, _;
	if is_set (name) then
		if name:match ('^%(%(.*%)%)$') then										-- if wrapped in doubled parentheses, ignore 
			name = name:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			_, count = name:gsub ('[;,]', '');									-- count the number of separator-like characters
			
			if 1 &lt; count then													-- param could be |author= or |editor= so one separactor character is acceptable
				add_maint_cat ('mult_names', list_name:lower());				-- more than one separator indicates multiple names so add a maint cat for this template
			end
		end
	end
	return name;																-- and done
end

--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary
	while true do
		last = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false);							-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false);						-- find and remove variations on et al.
		last = name_has_mult_names (last, err_msg_list_name);					-- check for multiple names in last and its aliases
		
		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			link_title_ok (link, list_name:match (&quot;(%w+)List&quot;):lower() .. '-link' .. i, last, list_name:match (&quot;(%w+)List&quot;):lower() .. '-last' .. i);	-- check for improper wikimarkup

			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because case of the source may be incorrect
or different from the case that WikiMedia uses, the name comparisons are done in lower case and when a match is
found, the Wikimedia version (assumed to be correct) is returned along with the code.  When there is no match, we
return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') return a list of languages that in some cases may include
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.

Names but that are included in the list will be found if that name is provided in the |language= parameter.  For example,
if |language=Chavacano de Zamboanga, that name will be found with the associated code 'cbk-zam'.  When names are found
and the associated code is not two or three characters, this function returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	local languages = mw.language.fetchLanguageNames(this_wiki_code, 'all')		-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() and 3 ~= code:len() then							-- two- or three-character codes only; extensions not supported
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the the code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for the code
end

--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code is recognized by MediaWiki,
use the returned name; if not, then use the value that was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is assigned to the category for
that code: Category:Norwegian-language sources (no).  For valid three-character code languages, the page is assigned
to the single category for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does not recognize three-character
equivalents of two-character codes: code 'ar' is recognized bit code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are
separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki = mw.getContentLanguage();									-- get a language object for this wiki
	local this_wiki_code = this_wiki:getCode()									-- get this wiki's language code
	local this_wiki_name = mw.language.fetchLanguageName(this_wiki_code, this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang

		if lang:match ('^%a%a%-') then											-- strip ietf language tags from code; TODO: is there a need to support 3-char with tag?
			lang = lang:match ('(%a%a)%-')										-- keep only 639-1 code portion to lang; TODO: do something with 3166 alpha 2 country code?
		end
		if 2 == lang:len() or 3 == lang:len() then								-- if two-or three-character code
			name = mw.language.fetchLanguageName( lang:lower(), this_wiki_code);	-- get language name if |language= is a proper code
		end
	
		if is_set (name) then													-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, this_wiki_code);				-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then													-- only 2- or 3-character codes
			if this_wiki_code ~= code then										-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					add_prop_cat ('foreign_lang_source', {name, code})			-- categorize it
				else															-- or is a recognized language (but has a three-character code)
					add_prop_cat ('foreign_lang_source_2', {code})				-- categorize it differently TODO: support mutliple three-character code categories per cs1|2 template
				end
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, ' and ')							-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		language_list[code] = 'and ' .. language_list[code];					-- prepend last name with 'and&lt;space&gt;'
		name = table.concat (language_list, ', ')								-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
	end
	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
end

--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = '.';																-- terminate the rendered citation with a period
	end
	return '.', ps;																-- separator is a full stop
end

--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = '';																-- make sure it isn't nil
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return ',', ps, ref;														-- separator is a comma
end

--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end

--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extension, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf[%?#]?') or url:match ('%.PDF[%?#]?');
end

--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parenthases, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end

--[[--------------------------&lt; G E T _ D I S P L A Y _ A U T H O R S _ E D I T O R S &gt;------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_authors_editors (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_auth_ed', list_name);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end

--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
--	local good_pattern = '^P[^%.P%l]';
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
--	local bad_pattern = '^[Pp][Pp]';
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
--		if Page:match ('^[Pp]?[Pp]%.?[ %d]') or  Page:match ('^[Pp]ages?[ %d]') or
--			Pages:match ('^[Pp]?[Pp]%.?[ %d]') or  Pages:match ('^[Pp]ages?[ %d]') then
--				add_maint_cat ('extra_text');
--		end
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

TODO: check for names like Coon V JS (Coon JS 5th at PMID 25205766, John S. Coon V at doi:10.1093/humupd/dmu048)?

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	if vparam:find ('%[%[') or vparam:find ('%]%]')	then						-- no wikilinking vauthors names
		add_vanc_error ();
	end
	v_name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;)								-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parenthese to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')
			corporate = true;
		elseif string.find(v_name, &quot;%s&quot;) then
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
			last  = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') or mw.ustring.match (v_name, ' %u %u$') then
				add_vanc_error ();												-- matches last II last; the case when a comma is missing or a space between two intiials
			end
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) and not mw.ustring.match (first, &quot;^%u?%u$&quot;) then		-- first shall contain one or two upper-case letters, nothing else
			add_vanc_error ();
		end
																				-- this from extract_names ()
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice incase we have a first 1 without a last1
		select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, no, etc).  When the parameter value has not been assigned a value (missing or empty
in the source template) the function refurns true.  If the parameter value is one of the list of allowed values returns
true; else, emits an error message and returns false.

]]

local function is_valid_parameter_value (value, name, possible)
	if not is_set (value) then
		return true;															-- an empty parameter is ok
	elseif in_array(value:lower(), possible) then
		return true;
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list,-1,-1) == sepc) or (string.sub (name_list,-3,-1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terninate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not is_set (volume) and not is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end
	
	local vol = '';
		
	if is_set (volume) then
		if (4 &lt; mw.ustring.len(volume)) then
			vol = substitute (cfg.messages['j-vol'], {sepc, volume});
		else
			vol = wrap_style ('vol-bold', hyphen_to_dash(volume));
		end
	end
	if is_set (issue) then
		return vol .. substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end






--[[-------------------------&lt; N O R M A L I Z E _ P A G E _ L I S T &gt;-----------------------------------------

not currently used

normalizes a comma, ampersand, and/or space separated list to be '&lt;value&gt;, &lt;value&gt;, ..., &lt;value&gt;'
returns list unchanged if there are no commas else strips whitespace and then reformats the list

]]
--[[
local function normalize_page_list (list)
	if not list:find ('[,&amp; ]') then return list end								-- if list is not delimited with commas, ampersands, or spaces; done
	
	list = mw.text.split (list, '[,&amp;%s]+');										-- make a table of values
	list = table.concat (list, ', ');											-- and now make a normalized list
	return list;
end
]]

--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'journal' == origin);

	if is_set (page) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif is_set(pages) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then										-- if pages is only digits, assume a single page number
			return '', substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org urls to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot url.  When the archive url is 'https://web.archive.org/save/' (or http://...) archive.org saves a snapshot
of the target page in the url.  That is something that Wikipedia should not allow unwitting readers to do.

When the archive.org url does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command url
	|archive-url= is an archive.org url that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org urls:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.or url
	
	if not url:match('//web%.archive%.org/') then
		return url, date;														-- not an archive.org archive, return archiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command url, we don't want to allow saving of the target page 
		table.insert( z.message_tail, { set_error( 'archive_url', {'save command'}, true ) } );	-- add error message
		return '', '';															-- return empty strings for archiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/web/%*/') or url:match('//web%.archive%.org/%*/') then	-- wildcard with or without 'web/' path element
		table.insert( z.message_tail, { set_error( 'archive_url', {'wildcard'}, true ) } );		-- add error message and
		return '', '';																			-- return empty strings for archiveURL and ArchiveDate
	end
	
	path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');			-- split out some of the url parts for evaluation

	if not is_set(timestamp) or 14 ~= timestamp:len() then						-- path and flag optional, must have 14-digit timestamp here
		err_msg = 'timestamp';
	elseif is_set(path) and 'web/' ~= path then									-- older archive urls do not have the extra 'web/' path element
		err_msg = 'path';
	elseif is_set (flag) and not is_set (path) then								-- flag not allowed with the old form url (without the 'web/' path element)
		err_msg = 'flag';
	elseif is_set (flag) and not flag:match ('%a%a_') then						-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
		err_msg = 'flag';
	else
		return url, date;														-- return archiveURL and ArchiveDate
	end
																				-- if here something not right so
	table.insert( z.message_tail, { set_error( 'archive_url', {err_msg}, true ) } );	-- add error message and
	return '', '';																-- return empty strings for archiveURL and ArchiveDate
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe:
	{{cite ... |title=Title access-date=2016-03-17}}

cs1|2 shares some parameter names with xml/html atributes: class=, title=, etc.  To prevent false positives xml/html
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove xml/html tags because attributes: class=, title=, etc 

	capture = value:match ('%s+(%a[%a%d]+)%s*=') or value:match ('^(%a[%a%d]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then								-- if the capture is a valid parameter name
		add_maint_cat ('missing_pipe');
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
		end
		if is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
		end
	end

	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list
	local Contribution = A['Contribution'];
	if in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not is_set (Contribution) then									-- |contributor= requires |contribution=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if select_one (args, cfg.aliases['ContributorList-Last'], 'redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { set_error( 'contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if not is_valid_parameter_value (NameListFormat, 'name-list-format', cfg.keywords['name-list-format']) then			-- only accepted value for this parameter is 'vanc'
		NameListFormat = '';													-- anything else, set to empty string
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
			link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wikimarkup in |title-link= or wikimarkup in |title= when |title-link= is set

	local Chapter = A['Chapter'];
	local ScriptChapter = A['ScriptChapter'];
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];

	local ArchiveDate;
	local ArchiveURL;

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	
--	local ArchiveDate = A['ArchiveDate'];
--	local ArchiveURL = A['ArchiveURL'];
--		if ArchiveURL:match('//web%.archive%.org/save/') then				-- if an archive.org save command url, we don't want to save target page ...
--			ArchiveURL = '';													-- every time a reader clicks the link so
--			ArchiveDate = '';													-- unset these
--			table.insert( z.message_tail, { set_error( 'archive_save', {}, true ) } );	-- and add error message
--		end
	local DeadURL = A['DeadURL']
		if not is_valid_parameter_value (DeadURL, 'dead-url', cfg.keywords ['deadurl']) then	-- set in config.defaults to 'yes'
			DeadURL = '';														-- anything else, set to empty string
		end

	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];
	local Periodical_origin = A:ORIGIN('Periodical');							-- get the name of the periodical parameter

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if in_array (config.CitationClass, cfg.templates_using_volume) and not ('conference' == config.CitationClass and not is_set (Periodical)) then
		Volume = A['Volume'];
	end
	if in_array (config.CitationClass, cfg.templates_using_issue) and not (in_array (config.CitationClass, {'conference', 'map'}) and not is_set (Periodical))then
		Issue = A['Issue'];
	end
	local Position = '';
	if not in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash( A['Pages'] );	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
		if not is_valid_parameter_value (RegistrationRequired, 'registration', cfg.keywords ['yes_true_y']) then
			RegistrationRequired=nil;
		end
	local SubscriptionRequired = A['SubscriptionRequired'];
		if not is_valid_parameter_value (SubscriptionRequired, 'subscription', cfg.keywords ['yes_true_y']) then
			SubscriptionRequired=nil;
		end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local Agency = A['Agency'];

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
		if not is_valid_parameter_value (IgnoreISBN, 'ignore-isbn-error', cfg.keywords ['yes_true_y']) then
			IgnoreISBN = nil;													-- anything else, set to empty string
		end
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
		if not is_valid_parameter_value (LastAuthorAmp, 'last-author-amp', cfg.keywords ['yes_true_y']) then
			LastAuthorAmp = nil;													-- set to empty string
		end
	local no_tracking_cats = A['NoTracking'];
		if not is_valid_parameter_value (no_tracking_cats, 'no-tracking', cfg.keywords ['yes_true_y']) then
			no_tracking_cats = nil;												-- set to empty string
		end

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = A['DF'];															-- date format set in cs1|2 template
	if not is_valid_parameter_value (DF, 'df', cfg.keywords['date-format']) then	-- validate reformatting keyword
		DF = '';																-- not valid, set to empty string
	end

-- set default parameter values defined by |mode= parameter.  If |mode= is empty or omitted, use CitationClass to set these values
	local Mode = A['Mode'];
	if not is_valid_parameter_value (Mode, 'mode', cfg.keywords['mode']) then
		Mode = '';
	end
	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	select_one( args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'redundant_parameters' );		-- this is a dummy call simply to get the error message and category

	local NoPP = A['NoPP'] 
	if is_set (NoPP) and is_valid_parameter_value (NoPP, 'nopp', cfg.keywords ['yes_true_y']) then
		NoPP = true;
	else
		NoPP = nil;																-- unset, used as a flag later
	end

	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Pages = '';															-- unset the others
			At = '';
		end
		extra_text_in_page_check (Page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.
	elseif is_set(Pages) then
		if is_set(At) then
			At = '';															-- unset
		end
		extra_text_in_page_check (Pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped
	|url maps to |chapterurl when |title is remapped

All other combinations of |encyclopedia, |title, and |article are not modified

]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					TransChapter = TransTitle;
					ChapterURL = URL;
					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter= '[[' .. TitleLink .. '|' .. Chapter .. ']]';
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			else																-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if is_set(A['Number']) then													-- cite techreport uses 'number', which other citations alias to 'issue'
			if not is_set(ID) then												-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];													-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', 'id') .. ' and ' .. wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Others) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Others;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Others;
			end
		else
			Others = '(Interview)';
		end
	end

-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	elseif 'mailinglist' == A:ORIGIN('Periodical') then
		Periodical = '';														-- unset because mailing list is only used for cite mailing list
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];

		link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wikimarkup in |series-link= or wikimarkup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) and is_set (AirDate) then							-- promote airdate to date
			Date = AirDate;
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('series', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = '[[' .. ChapterLink .. '|' .. Chapter .. ']]';		-- ok to wikilink
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = '[[' .. ChapterLink .. '|' .. Series .. ']]';			-- series links with ChapterLink (episodelink -&gt; TitleLink -&gt; ChapterLink) ugly
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = '[[' .. SeriesLink .. '|' .. Series .. ']]';
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
-- end of {{cite episode}} stuff

-- Account for the oddities that are {{cite arxiv}}, before generation of COinS data.
	if 'arxiv' == config.CitationClass then
		if not is_set (ID_list['ARXIV']) then									-- |arxiv= or |eprint= required for cite arxiv
			table.insert( z.message_tail, { set_error( 'arxiv_missing', {}, true ) } );		-- add error message
		elseif is_set (Series) then												-- series is an alias of version
			ID_list['ARXIV'] = ID_list['ARXIV'] .. Series;						-- concatenate version onto the end of the arxiv identifier
			Series = '';														-- unset
			deprecated_parameter ('version');									-- deprecated parameter but only for cite arxiv
		end
		
		if first_set ({AccessDate, At, Chapter, Format, Page, Pages, Periodical, PublisherName, URL,	-- a crude list of parameters that are not supported by cite arxiv
			ID_list['ASIN'], ID_list['BIBCODE'], ID_list['DOI'], ID_list['ISBN'], ID_list['ISSN'],
			ID_list['JFM'], ID_list['JSTOR'], ID_list['LCCN'], ID_list['MR'], ID_list['OCLC'], ID_list['OL'],
			ID_list['OSTI'], ID_list['PMC'], ID_list['PMID'], ID_list['RFC'], ID_list['SSRN'], ID_list['USENETID'], ID_list['ZBL']},27) then
				table.insert( z.message_tail, { set_error( 'arxiv_params_not_supported', {}, true ) } );		-- add error message

				AccessDate= '';													-- set these to empty string; not supported in cite arXiv
				PublisherName = '';												-- (if the article has been published, use cite journal, or other)
				Chapter = '';
				URL = '';
				Format = '';
				Page = ''; Pages = ''; At = '';
		end
		Periodical = 'arXiv';													-- set to arXiv for COinS; after that, must be set to empty string
	end

-- handle type parameter for those CS1 citations that have default values
	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
	TitleType = substitute( cfg.messages['type'], TitleType);					-- display it in parentheses
	end

-- legacy: promote concatenation of |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {['access-date']=AccessDate, ['archive-date']=ArchiveDate, ['date']=Date, ['doi-broken-date']=DoiBroken,
				['embargo']=Embargo, ['lay-date']=LayDate, ['publication-date']=PublicationDate, ['year']=Year};

		anchor_year, Embargo, error_message = dates(date_parameters_list, COinS_date);

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end

		if is_set(error_message) then
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		elseif is_set (DF) then
			if reformat_dates (date_parameters_list, DF, false) then			-- reformat to DF format, use long month names if appropriate
				AccessDate = date_parameters_list['access-date'];				-- overwrite date holding parameters with reformatted values
				ArchiveDate = date_parameters_list['archive-date'];
				Date = date_parameters_list['date'];
				DoiBroken = date_parameters_list['doi-broken-date'];
				LayDate = date_parameters_list['lay-date'];
				PublicationDate = date_parameters_list['publication-date'];
			end
		end
	end	-- end of do

-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);											-- 

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
			if 'episode' == config.CitationClass then							-- special case for cite episode; TODO: is there a better way to do this?
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
			else
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
			end
	end
	
	if 'none' == Title and in_array (config.CitationClass, {'journal', 'citation'}) and is_set (Periodical) and 'journal' == A:ORIGIN('Periodical') then	-- special case for journal cites
		Title = '';																-- set title to empty string
		add_maint_cat ('untitled');
	end

	check_for_url ({															-- add error message when any of these parameters contains a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[A:ORIGIN('Periodical')]=Periodical,
		[A:ORIGIN('PublisherName')] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = Periodical,
		['Encyclopedia'] = Encyclopedia,
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

-- Account for the oddities that are {{cite arxiv}}, AFTER generation of COinS data.
	if 'arxiv' == config.CitationClass then										-- we have set rft.jtitle in COinS to arXiv, now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in cite arxiv; if article has been published, use cite journal
	end

-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = substitute (cfg.messages['newsgroup'], external_link( 'news:' .. PublisherName, PublisherName, A:ORIGIN('PublisherName') ));
		end
	end



	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
--		local maximum;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text											-- get current page name so that we don't wikilink to it via editorlinkn
		};

		do																		-- do editor name list first because coauthors can modify control table
			control.maximum , editor_etal = get_display_authors_editors (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if is_set (Editors) then
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
					EditorCount = 2;											-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
				else
					EditorCount = 2;											-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
				end
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do translators
			control.maximum = #t;												-- number of translators
			Translators = list_people(control, t, false);						-- et al not currently supported
		end
		do																		-- now do contributors
			control.maximum = #c;												-- number of contributors
			Contributors = list_people(control, c, false);						-- et al not currently supported
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_authors_editors (A['DisplayAuthors'], #a, 'authors', author_etal);

			if is_set(Coauthors) then											-- if the coauthor field is also used, prevent ampersand and et al. formatting.
				control.lastauthoramp = nil;
				control.maximum = #a + 1;
			end
			
			last_first_list = list_people(control, a, author_etal);

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false);	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if is_set (Authors) and is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

		if not is_set(Authors) and is_set(Coauthors) then						-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
			table.insert( z.message_tail, { set_error('coauthors_missing_author', {}, true) } );	-- emit error message
		end
	end

-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

-- special case for chapter format so no error message or cat when chapter not supported
	if not (in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not is_set(URL) then
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then	-- |url= required for cite web, cite podcast, and cite mailinglist
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURLorigin, OriginalFormat;						-- TODO: swap chapter and title here so that archive applies to most specific if both are set?
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (ChapterURL) then 	-- swapped									-- URL not set so if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURLorigin = ChapterURLorigin;								-- name of chapter-url parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |format=
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				ChapterURLorigin = A:ORIGIN('ArchiveURL')						-- name of archive-url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
			end
		elseif is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURLorigin = URLorigin;										-- name of url parameter for error messages
			OriginalFormat = Format;											-- and original |format=
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
			end
 		end
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'arxiv'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			local chap_param;
			if is_set (Chapter) then											-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif is_set (ScriptChapter) then
				chap_param = A:ORIGIN ('ScriptChapter')
			else is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if is_set (chap_param) then											-- if we found one
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {chap_param}, true ) } );		-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if is_set (Contribution) and 0 &lt; #c then								-- if this is a contribution with contributor(s)
			if in_array (Contribution:lower(), cfg.keywords.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, Chapter, TransChapter, ChapterURL, ChapterURLorigin, no_quotes);		-- Contribution is also in Chapter
		if is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter.. sepc .. ' ';
		elseif is_set (ChapterFormat) then										-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'mailinglist', 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
	
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then
			Title = external_link( URL, Title, URLorigin ) .. TransError .. Format;
-- this experiment hidden 2016-04-10; see Help_talk:Citation_Style_1#Recycled_urls
--			local temp_title = external_link( URL, Title, URLorigin ) .. TransError .. Format;	-- do this so we get error message even if url is usurped no archive
--			if in_array (DeadURL, {'unfit no archive', 'usurped no archive'}) then	-- when url links to inappropriate location and there is no archive of original source available
--				local err_msg
--				if temp_title:match ('%[%S+%s+(.+)%](&lt;.+)') then				-- if there is an error message
--					Title, err_msg = temp_title:match ('%[%S+%s+(.+)%](&lt;.+)');	-- strip off external link; TODO: find a better to do this
--					Title = Title .. (err_msg or '');
--				end
--			else
--				Title = temp_title;
--			end

			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURLorigin );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if is_set(Minutes) then
			if is_set (Time) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'minutes') .. ' and ' .. wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
		Others = sepc .. ' Translated by ' .. Translators .. Others; 
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

--[[
Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
note is displayed. There are no error messages for this condition.

]]
	if is_set (SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif is_set (RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if 'citation', lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text
																				-- neither of these work; don't know why; it seems that substitute() isn't being called	
		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then				-- if first and last characters of quote are quote marks
			Quote = Quote:sub(2,-2);											-- strip them off
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL') ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- DeadURL is empty, 'yes', 'true', 'y', 'unfit', 'usurped'
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if in_array (DeadURL, {'unfit', 'usurped'}) then
				Archived = sepc .. &quot; &quot; .. 'Archived from the original on ' .. ArchiveDate;	-- format already styled
			else																-- DeadURL is empty, 'yes', 'true', or 'y'
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURLorigin ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL') ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL') ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURLorigin );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin );
	end

	local Publisher;
	if is_set(Periodical) and
		not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap_msg ('published', PublicationDate);
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap_msg ('published', PublicationDate) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
			Language, Edition, Publisher, Agency, Volume}, sepc );
		
	elseif in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(Periodical) then		-- special cases for book cites
		if is_set (Contributors) then											-- when we are citing foreword, preface, introduction, etc
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Transcript, Language, Edition, Publisher}, sepc );
	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if is_set(Date) then
		if is_set (Authors) or is_set (Editors) then							-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;;				-- in paranetheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon,-1,-1) == sepc) then							-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigYear;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigYear;							-- Date begins with sepc
			end
		end
	end	
	if is_set(Authors) then
		if is_set(Coauthors) then
			if 'vanc' == NameListFormat then									-- separate authors and coauthors with proper name-list-separator
				Authors = Authors .. ', ' .. Coauthors;
			else
				Authors = Authors .. '; ' .. Coauthors;
			end
		end
		if not is_set (Date) then												-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then in_text = in_text:lower() end				-- lowercase for cs2
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if is_set (Contributors) then											-- book cite and we're citing the intro, preface, etc
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if is_set (Editors) then											-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if not is_set (Date) then											-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if config.CitationClass==&quot;journal&quot; and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = config.CitationClass;
		options.class = &quot;citation &quot; .. config.CitationClass;					-- class=citation required for blue highlight when used with |ref=
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then								-- set reference anchor if appropriate
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			id = anchor_id (namelist, year);									-- go make the CITEREF anchor
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then													-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		text = substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text});	-- when |ref= is set
	else
		text = substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text});	-- all other cases
	end		

	text = text .. substitute (cfg.presentation['ocins'], {OCinSoutput});		-- append metadata to the citation
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. error_comment( v[1], v[2] );
				else
					text = text .. error_comment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end

	if #z.maintenance_cats ~= 0 then
		text = text .. '&lt;span class=&quot;citation-comment&quot; style=&quot;display:none; color:#33aa33&quot;&gt;';
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. ' ' .. v .. ' ([[:Category:' .. v ..'|link]])';
		end
		text = text .. '&lt;/span&gt;';	-- maintenance mesages (realy just the names of the categories for now)
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

--[[--------------------------&lt; C S 1 . C I T A T I O N &gt;------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

function cs1.citation(frame)
	local pframe = frame:getParent()
	local validation, utilities, identifiers, metadata;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (utilities);								-- so that functions in Date validataion can see the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	dates = validation.dates;													-- imported functions from Module:Citation/CS1/Date validation
	year_date_check = validation.year_date_check;
	reformat_dates = validation.reformat_dates;
	
	is_set = utilities.is_set;													-- imported functions from Module:Citation/CS1/Utilities
	in_array = utilities.in_array;
	substitute = utilities.substitute;
	error_comment = utilities.error_comment;
	set_error = utilities.set_error;
	select_one = utilities.select_one;
	add_maint_cat = utilities.add_maint_cat;
	wrap_style = utilities.wrap_style;
	safe_for_italics = utilities.safe_for_italics;
	remove_wiki_link = utilities.remove_wiki_link;

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	extract_ids = identifiers.extract_ids;										-- imported functions from Module:Citation/CS1/Utilities
	build_id_list = identifiers.build_id_list;
	is_embargoed = identifiers.is_embargoed;
	
	make_coins_title = metadata.make_coins_title;								-- imported functions from Module:Citation/CS1/COinS
	get_coins_pages = metadata.get_coins_pages;
	COinS = metadata.COinS;

	
	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute( param, capture );				-- add the capture to the suggested parameter (typically the enumerator)
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, param}, true );	-- set the error message
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			missing_pipe_check (v);												-- do we think that there is a parameter that is missing a pipe?
			
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);
		end
	end
	return citation0( config, args)
end

return cs1;</text>
      <sha1>gbnqozm27iqaj677tjhbh2pfiw6xtww</sha1>
    </revision>
    <revision>
      <id>4708</id>
      <parentid>4707</parentid>
      <timestamp>2016-06-04T17:42:27Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4708</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="153212" sha1="3htqnmev3c8azos369wufap3kf85n00" xml:space="preserve">
local cs1 ={};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local dates, year_date_check, reformat_dates, date_hyphen_to_dash				-- functions in Module:Citation/CS1/Date_validation

local is_set, in_array, substitute, error_comment, set_error, select_one,		-- functions in Module:Citation/CS1/Utilities
	add_maint_cat, wrap_style, safe_for_italics, remove_wiki_link;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local extract_ids, build_id_list, is_embargoed;									-- functions in Module:Citation/CS1/Identifiers

local make_coins_title, get_coins_pages, COinS;									-- functions in Module:Citation/CS1/COinS

local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

delare variables here that have page-wide scope

]]

local Preview_mode = false;														-- flag indicating that we are rendering a preview page (Show preview button)

--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end

--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

]]

local added_prop_cats = {}														-- list of property categories that have been added to z.properties_cats
local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));		-- make name then add to table
	end
end

--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

]]

local added_vanc_errs;															-- flag so we only emit one Vancouver error / category
local function add_vanc_error (source)
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {source}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a uri scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of tlds: https://www.iana.org/domains/root/db

rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the tld.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a url with a scheme) will be stripped
here.  Perhaps not necessary but retained incase it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ascii characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the tld) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org TLD
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and tld or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%a%d]') then										-- first character must be letter or digit
		return false;
	end
																				-- Do most common case first
	if domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.%a%a+$') then				-- three or more character hostname.hostname or hostname.tld
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.xn%-%-[%a%d]+$') then	-- internationalized domain name with ACE prefix
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.org$') then							-- one character .org hostname
		return true;
	elseif domain:match ('%f[%a][qxz]%.com$') then								-- assigned one character .com hostname (x.com times out 2015-12-10)
		return true;
	elseif domain:match ('%f[%a][iq]%.net$') then								-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.%a%a$') then							-- one character hostname and cctld (2 chars)
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d]%.%a%a+$') then					-- two character hostname and tld
		return true;
	elseif domain:match ('^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?') then		-- IPv4 address
		return true;
	else
		return false;
	end
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a url appear to be a valid url; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if is_set (scheme) then														-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when url is protocol relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a url into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following tld) (if any) and any path(/), query(?) or fragment(#).

If protocol relative url, return nil scheme and domain else return nil for both scheme and domain.

When not protocol relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol relative url
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		authority = authority:gsub ('//', '', 1);								-- replace place 1 pair of '/' with nothing;
		if is_set(authority) then												-- if anything left (1 or 3+ '/' where authority should be) then
			return scheme;														-- return scheme only making domain nil which will cause an error message
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link= etc for properly formatted content: no wikilinks, no urls

Link parameters are to hold the title of a wikipedia article so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki urls and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid url (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid url (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from url; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid url
end

--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wikilinked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

]]

local function link_title_ok (link, lorig, title, torig)
local orig;

	if is_set (link) then 														-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		end
	end

	if is_set (orig) then
		table.insert( z.message_tail, { set_error( 'bad_paramlink', orig)});	-- url or wikilink in |title= with |title-link=;
	end
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the url into scheme and domain
portions, or for protocol relative (//example.com) urls, just the domain.  Use is_url() to validate the two
portions of the url.  If both are valid, or for protocol relative if domain is valid, return true, else false.

Because it is different from a standard url, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper url
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from url;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a url.  The test will also find external wikilinks
that use protocol relative urls. Also finds bare urls.

The frontier pattern prevents a match on interwiki links which are similar to scheme:path urls.  The tests that
find bracketed urls are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol relative ext wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare url with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol relative bare url: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a url
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then												-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source )
	local error_str = &quot;&quot;;
	local domain;
	local path;
	
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the url into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['[']='%5b',[']']='%5d'});					-- replace '[' and ']' with their percent encoded values
		URL=domain..path;														-- and reassemble
	end
	
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url( label ), &quot;]&quot;, error_str });
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

]]

local page_in_deprecated_cat;													-- sticky flag so that the category is added only once
local function deprecated_parameter(name)
	if not page_in_deprecated_cat then
		page_in_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end

--[[--------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Call this function for chapter titles, for website titles, etc; not for book titles.

]]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	
	cap, cap2 = str:match (&quot;^([\&quot;\'])([^\'].+)&quot;);								-- match leading double or single quote but not double single quotes
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-left'], {cap, cap2});
	end

	cap, cap2 = str:match (&quot;^(.+[^\'])([\&quot;\'])$&quot;)
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-right'], {cap, cap2});
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title= and |script-chapter=

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, cfg.script_lang_codes) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				add_prop_cat ('script')
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return substitute( msg, str );										-- including template text
	else
		return substitute( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (scriptchapter, chapter, transchapter, chapterurl, chapter_url_source, no_quotes)
	local chapter_error = '';
	
	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);										-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
			chapter = wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, scriptchapter)						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (transchapter) then
		transchapter = wrap_style ('trans-quoted-title', transchapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. transchapter;
		else																	-- here when transchapter without chapter or script-chapter
			chapter = transchapter;												-- 
			chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
		end
	end

	if is_set (chapterurl) then
		chapter = external_link (chapterurl, chapter, chapter_url_source);		-- adds bare_url_missing_title error if appropriate
	end

	return chapter .. chapter_error;
end

--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Detects but ignores the character pattern that results from the transclusion of {{'}} templates.

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i=1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- Test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position then
			if 'nowiki' == capture or 'math' == capture then 					-- nowiki, math stripmarker (not an error condition)
				stripmarker = true;												-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { set_error( 'invisible_char', {err_msg, wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i=i+1;																	-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end

--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash

]]

local function hyphen_to_dash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if comp:sub(1,1) == duplicate_char then								-- is first charactier same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for th
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = str:sub(-1,-1);										-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = str:sub(1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = str:sub(1, -4) .. &quot;''&quot;;							-- remove them and add back ''
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then		-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then		-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then			-- if last two chars of str are sepc] external link
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;'']&quot; then		-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then				-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = str:sub(1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end		-- if duplicate_char not a letter then escape it
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )			-- remove duplicate_char if it follows html markup
					else
						value = value:sub( 2, -1 );								-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end  


--[[--------------------------&lt; I S _ S U F F I X &gt;------------------------------------------------------------

returns true is suffix is properly formed Jr, Sr, or ordinal in the range 2–9.  Puncutation not allowed.

]]

local function is_suffix (suffix)
	if in_array (suffix, {'Jr', 'Sr', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end

--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written ouside of the code editor and pasted here because the code editor gets confused between character insertion point and cursor position.
The test has been rewritten to use decimal character escape sequence for the individual bytes of the unicode characters so that it is not necessary
to use an external editor to maintain this code.

	\195\128-\195\150 – À-Ö
	\195\152-\195\182 – Ø-ö
	\195\184-\198\191 – ø-ƿ
	\199\132-\201\143 – Ǆ-ɏ%

]]

local function is_good_vanc_name (last, first)
	local first, suffix = first:match ('(.-),?%s*([%dJS][%drndth]+)%.?$') or first;		-- if first has something that looks like a generational suffix, get it

	if is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error ('suffix');
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error ('non-Latin character');
			return false;														-- not a string of latin characters; Vancouver requires Romanization
	end;
	return true;
end

--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generaltional suffix in the Vancouver format because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just intials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; name:len() then													-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error ('suffix');									-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word


	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i],1,1));				-- insert the intial at end of initials table
		end
		i = i+1;																-- bump the counter
	end
			
--	for word in mw.ustring.gmatch(first, &quot;[^%s%.%-]+&quot;) do						-- names separated by spaces, hyphens, or periods
--		table.insert(initials, mw.ustring.sub(word,1,1))						-- Vancouver format does not include full stops.
--		i = i + 1;																-- bump the counter 
--		if 2 &lt;= i then break; end												-- only two initials allowed in Vancouver system; if 2, quit
--	end
	return table.concat(initials)												-- Vancouver format does not include spaces.
end

--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = ',';																-- name-list separator between authors is a comma
		namesep = ' ';															-- last/first separator is a space
	else
		sep = ';'																-- name-list separator between authors is a semicolon
		namesep = ', '															-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then					-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first 
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;				-- link author/editor if this page is not the author's/editor's page
				end
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end

--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]
local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of author and editor name parameters for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the parameters |display-authors=etal or |display-editors=etal

]]

local function name_has_etal (name, etal, nocat)

	if is_set (name) then														-- name can be nil in which case just return
		local etal_pattern = &quot;[;,]? *[\&quot;']*%f[%a][Ee][Tt] *[Aa][Ll][%.\&quot;']*$&quot;	-- variations on the 'et al' theme
		local others_pattern = &quot;[;,]? *%f[%a]and [Oo]thers&quot;;					-- and alternate to et al.
		
		if name:match (etal_pattern) then										-- variants on et al.
			name = name:gsub (etal_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		elseif name:match (others_pattern) then									-- if not 'et al.', then 'and others'?
			name = name:gsub (others_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		end
	end
	return name, etal;															-- 
end

--[[--------------------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;----------------------------------------

Evaluates the content of author and editor (surnames only) parameters for multiple names.  Multiple names are
indicated if there is more than one comma and or semicolon.  If found, the function adds the multiple name
(author or editor) maintenance category.

]]

local function name_has_mult_names (name, list_name)
local count, _;
	if is_set (name) then
		if name:match ('^%(%(.*%)%)$') then										-- if wrapped in doubled parentheses, ignore 
			name = name:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			_, count = name:gsub ('[;,]', '');									-- count the number of separator-like characters
			
			if 1 &lt; count then													-- param could be |author= or |editor= so one separactor character is acceptable
				add_maint_cat ('mult_names', list_name:lower());				-- more than one separator indicates multiple names so add a maint cat for this template
			end
		end
	end
	return name;																-- and done
end

--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary
	while true do
		last = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false);							-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false);						-- find and remove variations on et al.
		last = name_has_mult_names (last, err_msg_list_name);					-- check for multiple names in last and its aliases
		
		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			link_title_ok (link, list_name:match (&quot;(%w+)List&quot;):lower() .. '-link' .. i, last, list_name:match (&quot;(%w+)List&quot;):lower() .. '-last' .. i);	-- check for improper wikimarkup

			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because case of the source may be incorrect
or different from the case that WikiMedia uses, the name comparisons are done in lower case and when a match is
found, the Wikimedia version (assumed to be correct) is returned along with the code.  When there is no match, we
return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') return a list of languages that in some cases may include
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.

Names but that are included in the list will be found if that name is provided in the |language= parameter.  For example,
if |language=Chavacano de Zamboanga, that name will be found with the associated code 'cbk-zam'.  When names are found
and the associated code is not two or three characters, this function returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	local languages = mw.language.fetchLanguageNames(this_wiki_code, 'all')		-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() and 3 ~= code:len() then							-- two- or three-character codes only; extensions not supported
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the the code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for the code
end

--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code is recognized by MediaWiki,
use the returned name; if not, then use the value that was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is assigned to the category for
that code: Category:Norwegian-language sources (no).  For valid three-character code languages, the page is assigned
to the single category for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does not recognize three-character
equivalents of two-character codes: code 'ar' is recognized bit code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are
separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki = mw.getContentLanguage();									-- get a language object for this wiki
	local this_wiki_code = this_wiki:getCode()									-- get this wiki's language code
	local this_wiki_name = mw.language.fetchLanguageName(this_wiki_code, this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang

		if lang:match ('^%a%a%-') then											-- strip ietf language tags from code; TODO: is there a need to support 3-char with tag?
			lang = lang:match ('(%a%a)%-')										-- keep only 639-1 code portion to lang; TODO: do something with 3166 alpha 2 country code?
		end
		if 2 == lang:len() or 3 == lang:len() then								-- if two-or three-character code
			name = mw.language.fetchLanguageName( lang:lower(), this_wiki_code);	-- get language name if |language= is a proper code
		end
	
		if is_set (name) then													-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, this_wiki_code);				-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then													-- only 2- or 3-character codes
			if this_wiki_code ~= code then										-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					add_prop_cat ('foreign_lang_source', {name, code})			-- categorize it
				else															-- or is a recognized language (but has a three-character code)
					add_prop_cat ('foreign_lang_source_2', {code})				-- categorize it differently TODO: support mutliple three-character code categories per cs1|2 template
				end
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, ' and ')							-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		language_list[code] = 'and ' .. language_list[code];					-- prepend last name with 'and&lt;space&gt;'
		name = table.concat (language_list, ', ')								-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
	end
	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
end

--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = '.';																-- terminate the rendered citation with a period
	end
	return '.', ps;																-- separator is a full stop
end

--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = '';																-- make sure it isn't nil
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return ',', ps, ref;														-- separator is a comma
end

--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end

--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extension, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf[%?#]?') or url:match ('%.PDF[%?#]?');
end

--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parenthases, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end

--[[--------------------------&lt; G E T _ D I S P L A Y _ A U T H O R S _ E D I T O R S &gt;------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_authors_editors (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_auth_ed', list_name);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end

--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
--	local good_pattern = '^P[^%.P%l]';
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
--	local bad_pattern = '^[Pp][Pp]';
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
--		if Page:match ('^[Pp]?[Pp]%.?[ %d]') or  Page:match ('^[Pp]ages?[ %d]') or
--			Pages:match ('^[Pp]?[Pp]%.?[ %d]') or  Pages:match ('^[Pp]ages?[ %d]') then
--				add_maint_cat ('extra_text');
--		end
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	if vparam:find ('%[%[') or vparam:find ('%]%]')	then						-- no wikilinking vauthors names
		add_vanc_error ('wikilink');
	end
	v_name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;)								-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parentheses to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')								-- remove doubled parntheses
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error ('punctuation');
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
			if is_suffix (first) then											-- if a valid suffix
				suffix = first													-- save it as a suffix and
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end																	-- no suffix error message here because letter combination may be result of Romanization; check for digits?
			last = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error ('missing comma');								-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error ('name');										-- matches a space between two intiials
			end
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error ('initials');									-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first);									-- check first and last before restoring the suffix which may have a non-Latin digit
			if is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
			end
		else
			is_good_vanc_name (last, '');
		end
	
			
																				-- this from extract_names ()
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice incase we have a first 1 without a last1
		select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, no, etc).  When the parameter value has not been assigned a value (missing or empty
in the source template) the function refurns true.  If the parameter value is one of the list of allowed values returns
true; else, emits an error message and returns false.

]]

local function is_valid_parameter_value (value, name, possible)
	if not is_set (value) then
		return true;															-- an empty parameter is ok
	elseif in_array(value:lower(), possible) then
		return true;
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list,-1,-1) == sepc) or (string.sub (name_list,-3,-1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terninate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not is_set (volume) and not is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end
	
	local vol = '';
		
	if is_set (volume) then
		if (4 &lt; mw.ustring.len(volume)) then
			vol = substitute (cfg.messages['j-vol'], {sepc, volume});
		else
			vol = wrap_style ('vol-bold', hyphen_to_dash(volume));
		end
	end
	if is_set (issue) then
		return vol .. substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end






--[[-------------------------&lt; N O R M A L I Z E _ P A G E _ L I S T &gt;-----------------------------------------

not currently used

normalizes a comma, ampersand, and/or space separated list to be '&lt;value&gt;, &lt;value&gt;, ..., &lt;value&gt;'
returns list unchanged if there are no commas else strips whitespace and then reformats the list

]]
--[[
local function normalize_page_list (list)
	if not list:find ('[,&amp; ]') then return list end								-- if list is not delimited with commas, ampersands, or spaces; done
	
	list = mw.text.split (list, '[,&amp;%s]+');										-- make a table of values
	list = table.concat (list, ', ');											-- and now make a normalized list
	return list;
end
]]

--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'journal' == origin);

	if is_set (page) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif is_set(pages) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then										-- if pages is only digits, assume a single page number
			return '', substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org urls to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot url or to calendar pages.  When the archive url is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the url.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org url does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command url
	|archive-url= is an archive.org url that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org urls:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this funct may return a modified
archive url:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the url unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.or url
	
	if not url:match('//web%.archive%.org/') then
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command url, we don't want to allow saving of the target page 
		table.insert( z.message_tail, { set_error( 'archive_url', {'save command'}, true ) } );	-- add error message
		if Preview_mode then
			return url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1), date;	-- preview mode: modify and return ArchiveURL and ArchiveDate
		else
			return '', '';														-- return empty strings for archiveURL and ArchiveDate
		end
	end

--	if url:match('//web%.archive%.org/web/%*/') or url:match('//web%.archive%.org/%*/') then	-- wildcard with or without 'web/' path element
--		table.insert( z.message_tail, { set_error( 'archive_url', {'wildcard'}, true ) } );		-- add error message and
--		return '', '';																			-- return empty strings for archiveURL and ArchiveDate
--	end
	
	path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');		-- split out some of the url parts for evaluation
	
	if not is_set(timestamp) or 14 ~= timestamp:len() then								-- path and flag optional, must have 14-digit timestamp here
		err_msg = 'timestamp';
		if '*' ~= flag then
			url=url:gsub ('(//web%.archive%.org/[^%d]*%d?%d?%d?%d?%d?%d?)[^/]*', '%1*', 1)	-- for preview, modify ts to be yearmo* max (0-6 digits plus splat)
		end
	elseif is_set(path) and 'web/' ~= path then									-- older archive urls do not have the extra 'web/' path element
		err_msg = 'path';
	elseif is_set (flag) and not is_set (path) then								-- flag not allowed with the old form url (without the 'web/' path element)
		err_msg = 'flag';
	elseif is_set (flag) and not flag:match ('%a%a_') then						-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
		err_msg = 'flag';
	else
		return url, date;														-- return archiveURL and ArchiveDate
	end
																				-- if here something not right so
	table.insert( z.message_tail, { set_error( 'archive_url', {err_msg}, true ) } );	-- add error message and
	if Preview_mode then
		return url, date;														-- preview mode so return archiveURL and ArchiveDate
	else
		return '', '';															-- return empty strings for archiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe:
	{{cite ... |title=Title access-date=2016-03-17}}

cs1|2 shares some parameter names with xml/html atributes: class=, title=, etc.  To prevent false positives xml/html
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove xml/html tags because attributes: class=, title=, etc 

	capture = value:match ('%s+(%a[%a%d]+)%s*=') or value:match ('^(%a[%a%d]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then								-- if the capture is a valid parameter name
		add_maint_cat ('missing_pipe');
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
		end
		if is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
		end
	end

	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list
	local Contribution = A['Contribution'];
	if in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not is_set (Contribution) then									-- |contributor= requires |contribution=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if select_one (args, cfg.aliases['ContributorList-Last'], 'redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { set_error( 'contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if not is_valid_parameter_value (NameListFormat, 'name-list-format', cfg.keywords['name-list-format']) then			-- only accepted value for this parameter is 'vanc'
		NameListFormat = '';													-- anything else, set to empty string
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
			link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wikimarkup in |title-link= or wikimarkup in |title= when |title-link= is set

	local Chapter = A['Chapter'];
	local ScriptChapter = A['ScriptChapter'];
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];

	local ArchiveDate;
	local ArchiveURL;

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	
	local DeadURL = A['DeadURL']
		if not is_valid_parameter_value (DeadURL, 'dead-url', cfg.keywords ['deadurl']) then	-- set in config.defaults to 'yes'
			DeadURL = '';														-- anything else, set to empty string
		end

	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];
	local Periodical_origin = A:ORIGIN('Periodical');							-- get the name of the periodical parameter

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if in_array (config.CitationClass, cfg.templates_using_volume) and not ('conference' == config.CitationClass and not is_set (Periodical)) then
		Volume = A['Volume'];
	end
	if in_array (config.CitationClass, cfg.templates_using_issue) and not (in_array (config.CitationClass, {'conference', 'map'}) and not is_set (Periodical))then
		Issue = A['Issue'];
	end
	local Position = '';
	if not in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash( A['Pages'] );	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
		if not is_valid_parameter_value (RegistrationRequired, 'registration', cfg.keywords ['yes_true_y']) then
			RegistrationRequired=nil;
		end
	local SubscriptionRequired = A['SubscriptionRequired'];
		if not is_valid_parameter_value (SubscriptionRequired, 'subscription', cfg.keywords ['yes_true_y']) then
			SubscriptionRequired=nil;
		end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local Agency = A['Agency'];

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
		if not is_valid_parameter_value (IgnoreISBN, 'ignore-isbn-error', cfg.keywords ['yes_true_y']) then
			IgnoreISBN = nil;													-- anything else, set to empty string
		end
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
		if not is_valid_parameter_value (LastAuthorAmp, 'last-author-amp', cfg.keywords ['yes_true_y']) then
			LastAuthorAmp = nil;													-- set to empty string
		end
	local no_tracking_cats = A['NoTracking'];
		if not is_valid_parameter_value (no_tracking_cats, 'no-tracking', cfg.keywords ['yes_true_y']) then
			no_tracking_cats = nil;												-- set to empty string
		end

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = A['DF'];															-- date format set in cs1|2 template
	if not is_valid_parameter_value (DF, 'df', cfg.keywords['date-format']) then	-- validate reformatting keyword
		DF = '';																-- not valid, set to empty string
	end

-- set default parameter values defined by |mode= parameter.  If |mode= is empty or omitted, use CitationClass to set these values
	local Mode = A['Mode'];
	if not is_valid_parameter_value (Mode, 'mode', cfg.keywords['mode']) then
		Mode = '';
	end
	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	select_one( args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'redundant_parameters' );		-- this is a dummy call simply to get the error message and category

	local NoPP = A['NoPP'] 
	if is_set (NoPP) and is_valid_parameter_value (NoPP, 'nopp', cfg.keywords ['yes_true_y']) then
		NoPP = true;
	else
		NoPP = nil;																-- unset, used as a flag later
	end

	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Pages = '';															-- unset the others
			At = '';
		end
		extra_text_in_page_check (Page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.
	elseif is_set(Pages) then
		if is_set(At) then
			At = '';															-- unset
		end
		extra_text_in_page_check (Pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped
	|url maps to |chapterurl when |title is remapped

All other combinations of |encyclopedia, |title, and |article are not modified

]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					TransChapter = TransTitle;
					ChapterURL = URL;
					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter= '[[' .. TitleLink .. '|' .. Chapter .. ']]';
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			else																-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if is_set(A['Number']) then													-- cite techreport uses 'number', which other citations alias to 'issue'
			if not is_set(ID) then												-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];													-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', 'id') .. ' and ' .. wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Others) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Others;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Others;
			end
		else
			Others = '(Interview)';
		end
	end

-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	elseif 'mailinglist' == A:ORIGIN('Periodical') then
		Periodical = '';														-- unset because mailing list is only used for cite mailing list
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];

		link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wikimarkup in |series-link= or wikimarkup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) and is_set (AirDate) then							-- promote airdate to date
			Date = AirDate;
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('series', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = '[[' .. ChapterLink .. '|' .. Chapter .. ']]';		-- ok to wikilink
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = '[[' .. ChapterLink .. '|' .. Series .. ']]';			-- series links with ChapterLink (episodelink -&gt; TitleLink -&gt; ChapterLink) ugly
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = '[[' .. SeriesLink .. '|' .. Series .. ']]';
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
-- end of {{cite episode}} stuff

-- Account for the oddities that are {{cite arxiv}}, before generation of COinS data.
	if 'arxiv' == config.CitationClass then
		if not is_set (ID_list['ARXIV']) then									-- |arxiv= or |eprint= required for cite arxiv
			table.insert( z.message_tail, { set_error( 'arxiv_missing', {}, true ) } );		-- add error message
		elseif is_set (Series) then												-- series is an alias of version
			ID_list['ARXIV'] = ID_list['ARXIV'] .. Series;						-- concatenate version onto the end of the arxiv identifier
			Series = '';														-- unset
			deprecated_parameter ('version');									-- deprecated parameter but only for cite arxiv
		end
		
		if first_set ({AccessDate, At, Chapter, Format, Page, Pages, Periodical, PublisherName, URL,	-- a crude list of parameters that are not supported by cite arxiv
			ID_list['ASIN'], ID_list['BIBCODE'], ID_list['DOI'], ID_list['ISBN'], ID_list['ISSN'],
			ID_list['JFM'], ID_list['JSTOR'], ID_list['LCCN'], ID_list['MR'], ID_list['OCLC'], ID_list['OL'],
			ID_list['OSTI'], ID_list['PMC'], ID_list['PMID'], ID_list['RFC'], ID_list['SSRN'], ID_list['USENETID'], ID_list['ZBL']},27) then
				table.insert( z.message_tail, { set_error( 'arxiv_params_not_supported', {}, true ) } );		-- add error message

				AccessDate= '';													-- set these to empty string; not supported in cite arXiv
				PublisherName = '';												-- (if the article has been published, use cite journal, or other)
				Chapter = '';
				URL = '';
				Format = '';
				Page = ''; Pages = ''; At = '';
		end
		Periodical = 'arXiv';													-- set to arXiv for COinS; after that, must be set to empty string
	end

-- handle type parameter for those CS1 citations that have default values
	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
	TitleType = substitute( cfg.messages['type'], TitleType);					-- display it in parentheses
	end

-- legacy: promote concatenation of |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {['access-date']=AccessDate, ['archive-date']=ArchiveDate, ['date']=Date, ['doi-broken-date']=DoiBroken,
				['embargo']=Embargo, ['lay-date']=LayDate, ['publication-date']=PublicationDate, ['year']=Year};

		anchor_year, Embargo, error_message = dates(date_parameters_list, COinS_date);

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end
		
		if not is_set(error_message) then										-- error free dates only
			local modified = false;												-- flag
			if is_set (DF) then													-- if we need to reformat dates
				modified = reformat_dates (date_parameters_list, DF, false);	-- reformat to DF format, use long month names if appropriate
			end

			if true == date_hyphen_to_dash (date_parameters_list) then					-- convert hyphens to dashes where appropriate
				modified = true;
				add_maint_cat ('date_format');									-- hyphens were converted so add maint category
			end
			
			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'];				-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'];
				Date = date_parameters_list['date'];
				DoiBroken = date_parameters_list['doi-broken-date'];
				LayDate = date_parameters_list['lay-date'];
				PublicationDate = date_parameters_list['publication-date'];
			end
		else
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end

--		if is_set(error_message) then
--			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
--		elseif is_set (DF) then
--			if reformat_dates (date_parameters_list, DF, false) then			-- reformat to DF format, use long month names if appropriate
--				AccessDate = date_parameters_list['access-date'];				-- overwrite date holding parameters with reformatted values
--				ArchiveDate = date_parameters_list['archive-date'];
--				Date = date_parameters_list['date'];
--				DoiBroken = date_parameters_list['doi-broken-date'];
--				LayDate = date_parameters_list['lay-date'];
--				PublicationDate = date_parameters_list['publication-date'];
--			end
--		end
	end	-- end of do

-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);											-- 

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
			if 'episode' == config.CitationClass then							-- special case for cite episode; TODO: is there a better way to do this?
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
			else
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
			end
	end
	
	if 'none' == Title and in_array (config.CitationClass, {'journal', 'citation'}) and is_set (Periodical) and 'journal' == A:ORIGIN('Periodical') then	-- special case for journal cites
		Title = '';																-- set title to empty string
		add_maint_cat ('untitled');
	end

	check_for_url ({															-- add error message when any of these parameters contains a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[A:ORIGIN('Periodical')]=Periodical,
		[A:ORIGIN('PublisherName')] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = Periodical,
		['Encyclopedia'] = Encyclopedia,
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

-- Account for the oddities that are {{cite arxiv}}, AFTER generation of COinS data.
	if 'arxiv' == config.CitationClass then										-- we have set rft.jtitle in COinS to arXiv, now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in cite arxiv; if article has been published, use cite journal
	end

-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = substitute (cfg.messages['newsgroup'], external_link( 'news:' .. PublisherName, PublisherName, A:ORIGIN('PublisherName') ));
		end
	end



	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
--		local maximum;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text											-- get current page name so that we don't wikilink to it via editorlinkn
		};

		do																		-- do editor name list first because coauthors can modify control table
			control.maximum , editor_etal = get_display_authors_editors (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if is_set (Editors) then
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
					EditorCount = 2;											-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
				else
					EditorCount = 2;											-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
				end
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do translators
			control.maximum = #t;												-- number of translators
			Translators = list_people(control, t, false);						-- et al not currently supported
		end
		do																		-- now do contributors
			control.maximum = #c;												-- number of contributors
			Contributors = list_people(control, c, false);						-- et al not currently supported
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_authors_editors (A['DisplayAuthors'], #a, 'authors', author_etal);

			if is_set(Coauthors) then											-- if the coauthor field is also used, prevent ampersand and et al. formatting.
				control.lastauthoramp = nil;
				control.maximum = #a + 1;
			end
			
			last_first_list = list_people(control, a, author_etal);

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false);	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if is_set (Authors) and is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

		if not is_set(Authors) and is_set(Coauthors) then						-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
			table.insert( z.message_tail, { set_error('coauthors_missing_author', {}, true) } );	-- emit error message
		end
	end

-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

-- special case for chapter format so no error message or cat when chapter not supported
	if not (in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not is_set(URL) then
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then	-- |url= required for cite web, cite podcast, and cite mailinglist
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURLorigin, OriginalFormat;						-- TODO: swap chapter and title here so that archive applies to most specific if both are set?
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (ChapterURL) then 	-- swapped									-- URL not set so if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURLorigin = ChapterURLorigin;								-- name of chapter-url parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |format=
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				ChapterURLorigin = A:ORIGIN('ArchiveURL')						-- name of archive-url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
			end
		elseif is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURLorigin = URLorigin;										-- name of url parameter for error messages
			OriginalFormat = Format;											-- and original |format=
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
			end
 		end
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'arxiv'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			local chap_param;
			if is_set (Chapter) then											-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif is_set (ScriptChapter) then
				chap_param = A:ORIGIN ('ScriptChapter')
			else is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if is_set (chap_param) then											-- if we found one
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {chap_param}, true ) } );		-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if is_set (Contribution) and 0 &lt; #c then								-- if this is a contribution with contributor(s)
			if in_array (Contribution:lower(), cfg.keywords.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, Chapter, TransChapter, ChapterURL, ChapterURLorigin, no_quotes);		-- Contribution is also in Chapter
		if is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter.. sepc .. ' ';
		elseif is_set (ChapterFormat) then										-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'mailinglist', 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
	
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then
			Title = external_link( URL, Title, URLorigin ) .. TransError .. Format;
-- this experiment hidden 2016-04-10; see Help_talk:Citation_Style_1#Recycled_urls
--			local temp_title = external_link( URL, Title, URLorigin ) .. TransError .. Format;	-- do this so we get error message even if url is usurped no archive
--			if in_array (DeadURL, {'unfit no archive', 'usurped no archive'}) then	-- when url links to inappropriate location and there is no archive of original source available
--				local err_msg
--				if temp_title:match ('%[%S+%s+(.+)%](&lt;.+)') then				-- if there is an error message
--					Title, err_msg = temp_title:match ('%[%S+%s+(.+)%](&lt;.+)');	-- strip off external link; TODO: find a better to do this
--					Title = Title .. (err_msg or '');
--				end
--			else
--				Title = temp_title;
--			end

			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURLorigin );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if is_set(Minutes) then
			if is_set (Time) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'minutes') .. ' and ' .. wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
--		Others = sepc .. ' Translated by ' .. Translators .. Others; 
		Others = sepc .. ' ' .. wrap_msg ('translated', Translators, use_lowercase) .. Others; 
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

--[[
Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
note is displayed. There are no error messages for this condition.

]]
	if is_set (SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif is_set (RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if 'citation', lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text
																				-- neither of these work; don't know why; it seems that substitute() isn't being called	
		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then				-- if first and last characters of quote are quote marks
			Quote = Quote:sub(2,-2);											-- strip them off
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL') ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- DeadURL is empty, 'yes', 'true', 'y', 'unfit', 'usurped'
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if in_array (DeadURL, {'unfit', 'usurped'}) then
				Archived = sepc .. &quot; &quot; .. 'Archived from the original on ' .. ArchiveDate;	-- format already styled
			else																-- DeadURL is empty, 'yes', 'true', or 'y'
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURLorigin ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL') ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL') ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURLorigin );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin );
	end

	local Publisher;
	if is_set(Periodical) and
		not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap_msg ('published', PublicationDate);
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap_msg ('published', PublicationDate) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
			Language, Edition, Publisher, Agency, Volume}, sepc );
		
	elseif in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(Periodical) then		-- special cases for book cites
		if is_set (Contributors) then											-- when we are citing foreword, preface, introduction, etc
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Transcript, Language, Edition, Publisher}, sepc );
	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if is_set(Date) then
		if is_set (Authors) or is_set (Editors) then							-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;;				-- in paranetheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon,-1,-1) == sepc) then							-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigYear;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigYear;							-- Date begins with sepc
			end
		end
	end	
	if is_set(Authors) then
		if is_set(Coauthors) then
			if 'vanc' == NameListFormat then									-- separate authors and coauthors with proper name-list-separator
				Authors = Authors .. ', ' .. Coauthors;
			else
				Authors = Authors .. '; ' .. Coauthors;
			end
		end
		if not is_set (Date) then												-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then in_text = in_text:lower() end				-- lowercase for cs2
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if is_set (Contributors) then											-- book cite and we're citing the intro, preface, etc
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if is_set (Editors) then											-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if not is_set (Date) then											-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = config.CitationClass;
		options.class = &quot;citation &quot; .. config.CitationClass;					-- class=citation required for blue highlight when used with |ref=
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then								-- set reference anchor if appropriate
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			if #namelist &gt; 0 then												-- if there are names in namelist
				id = anchor_id (namelist, year);								-- go make the CITEREF anchor
			else
				id = '';														-- unset
			end
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then													-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		text = substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text});	-- when |ref= is set
	else
		text = substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text});	-- all other cases
	end		

	text = text .. substitute (cfg.presentation['ocins'], {OCinSoutput});		-- append metadata to the citation
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. error_comment( v[1], v[2] );
				else
					text = text .. error_comment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end

	if #z.maintenance_cats ~= 0 then
		text = text .. '&lt;span class=&quot;citation-comment&quot; style=&quot;display:none; color:#33aa33&quot;&gt;';
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. ' ' .. v .. ' ([[:Category:' .. v ..'|link]])';
		end
		text = text .. '&lt;/span&gt;';	-- maintenance mesages (realy just the names of the categories for now)
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

--[[--------------------------&lt; C S 1 . C I T A T I O N &gt;------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

function cs1.citation(frame)
	local pframe = frame:getParent()
	local validation, utilities, identifiers, metadata;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (utilities);								-- so that functions in Date validataion can see the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	dates = validation.dates;													-- imported functions from Module:Citation/CS1/Date validation
	year_date_check = validation.year_date_check;
	reformat_dates = validation.reformat_dates;
	date_hyphen_to_dash = validation.date_hyphen_to_dash;
	
	is_set = utilities.is_set;													-- imported functions from Module:Citation/CS1/Utilities
	in_array = utilities.in_array;
	substitute = utilities.substitute;
	error_comment = utilities.error_comment;
	set_error = utilities.set_error;
	select_one = utilities.select_one;
	add_maint_cat = utilities.add_maint_cat;
	wrap_style = utilities.wrap_style;
	safe_for_italics = utilities.safe_for_italics;
	remove_wiki_link = utilities.remove_wiki_link;

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	extract_ids = identifiers.extract_ids;										-- imported functions from Module:Citation/CS1/Utilities
	build_id_list = identifiers.build_id_list;
	is_embargoed = identifiers.is_embargoed;
	
	make_coins_title = metadata.make_coins_title;								-- imported functions from Module:Citation/CS1/COinS
	get_coins_pages = metadata.get_coins_pages;
	COinS = metadata.COinS;

	
	Preview_mode = frame:preprocess('{{REVISIONID}}');							-- use magic word to get revision id
	if is_set (Preview_mode) then												-- if there is a value then this is not a preiview
		Preview_mode = false;
	else
		Preview_mode = true;													-- no value (nil or empty string) so this is a preview
	end
	
	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute( param, capture );				-- add the capture to the suggested parameter (typically the enumerator)
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, param}, true );	-- set the error message
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			missing_pipe_check (v);												-- do we think that there is a parameter that is missing a pipe?
			
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);
		end
	end
	return citation0( config, args)
end

return cs1;</text>
      <sha1>3htqnmev3c8azos369wufap3kf85n00</sha1>
    </revision>
    <revision>
      <id>4709</id>
      <parentid>4708</parentid>
      <timestamp>2016-06-06T00:27:14Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>vauthors generational suffix fix;</comment>
      <origin>4709</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="153285" sha1="1o9wj33708mavdvycwmox8hop12mjfu" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local dates, year_date_check, reformat_dates, date_hyphen_to_dash				-- functions in Module:Citation/CS1/Date_validation

local is_set, in_array, substitute, error_comment, set_error, select_one,		-- functions in Module:Citation/CS1/Utilities
	add_maint_cat, wrap_style, safe_for_italics, remove_wiki_link;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local extract_ids, build_id_list, is_embargoed;									-- functions in Module:Citation/CS1/Identifiers

local make_coins_title, get_coins_pages, COinS;									-- functions in Module:Citation/CS1/COinS

local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

delare variables here that have page-wide scope

]]

local Preview_mode = false;														-- flag indicating that we are rendering a preview page (Show preview button)

--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end

--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

]]

local added_prop_cats = {}														-- list of property categories that have been added to z.properties_cats
local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));		-- make name then add to table
	end
end

--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

]]

local added_vanc_errs;															-- flag so we only emit one Vancouver error / category
local function add_vanc_error (source)
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {source}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a uri scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of tlds: https://www.iana.org/domains/root/db

rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the tld.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a url with a scheme) will be stripped
here.  Perhaps not necessary but retained incase it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ascii characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the tld) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org TLD
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and tld or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%a%d]') then										-- first character must be letter or digit
		return false;
	end
																				-- Do most common case first
	if domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.%a%a+$') then				-- three or more character hostname.hostname or hostname.tld
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.xn%-%-[%a%d]+$') then	-- internationalized domain name with ACE prefix
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.org$') then							-- one character .org hostname
		return true;
	elseif domain:match ('%f[%a][qxz]%.com$') then								-- assigned one character .com hostname (x.com times out 2015-12-10)
		return true;
	elseif domain:match ('%f[%a][iq]%.net$') then								-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.%a%a$') then							-- one character hostname and cctld (2 chars)
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d]%.%a%a+$') then					-- two character hostname and tld
		return true;
	elseif domain:match ('^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?') then		-- IPv4 address
		return true;
	else
		return false;
	end
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a url appear to be a valid url; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if is_set (scheme) then														-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when url is protocol relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a url into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following tld) (if any) and any path(/), query(?) or fragment(#).

If protocol relative url, return nil scheme and domain else return nil for both scheme and domain.

When not protocol relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol relative url
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		authority = authority:gsub ('//', '', 1);								-- replace place 1 pair of '/' with nothing;
		if is_set(authority) then												-- if anything left (1 or 3+ '/' where authority should be) then
			return scheme;														-- return scheme only making domain nil which will cause an error message
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link= etc for properly formatted content: no wikilinks, no urls

Link parameters are to hold the title of a wikipedia article so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki urls and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid url (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid url (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from url; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid url
end

--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wikilinked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

]]

local function link_title_ok (link, lorig, title, torig)
local orig;

	if is_set (link) then 														-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		end
	end

	if is_set (orig) then
		table.insert( z.message_tail, { set_error( 'bad_paramlink', orig)});	-- url or wikilink in |title= with |title-link=;
	end
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the url into scheme and domain
portions, or for protocol relative (//example.com) urls, just the domain.  Use is_url() to validate the two
portions of the url.  If both are valid, or for protocol relative if domain is valid, return true, else false.

Because it is different from a standard url, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper url
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from url;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a url.  The test will also find external wikilinks
that use protocol relative urls. Also finds bare urls.

The frontier pattern prevents a match on interwiki links which are similar to scheme:path urls.  The tests that
find bracketed urls are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol relative ext wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare url with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol relative bare url: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a url
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then												-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source )
	local error_str = &quot;&quot;;
	local domain;
	local path;
	
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the url into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['[']='%5b',[']']='%5d'});					-- replace '[' and ']' with their percent encoded values
		URL=domain..path;														-- and reassemble
	end
	
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url( label ), &quot;]&quot;, error_str });
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

]]

local page_in_deprecated_cat;													-- sticky flag so that the category is added only once
local function deprecated_parameter(name)
	if not page_in_deprecated_cat then
		page_in_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end

--[[--------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Call this function for chapter titles, for website titles, etc; not for book titles.

]]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	
	cap, cap2 = str:match (&quot;^([\&quot;\'])([^\'].+)&quot;);								-- match leading double or single quote but not double single quotes
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-left'], {cap, cap2});
	end

	cap, cap2 = str:match (&quot;^(.+[^\'])([\&quot;\'])$&quot;)
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-right'], {cap, cap2});
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title= and |script-chapter=

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, cfg.script_lang_codes) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				add_prop_cat ('script')
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return substitute( msg, str );										-- including template text
	else
		return substitute( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (scriptchapter, chapter, transchapter, chapterurl, chapter_url_source, no_quotes)
	local chapter_error = '';
	
	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);										-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
			chapter = wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, scriptchapter)						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (transchapter) then
		transchapter = wrap_style ('trans-quoted-title', transchapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. transchapter;
		else																	-- here when transchapter without chapter or script-chapter
			chapter = transchapter;												-- 
			chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
		end
	end

	if is_set (chapterurl) then
		chapter = external_link (chapterurl, chapter, chapter_url_source);		-- adds bare_url_missing_title error if appropriate
	end

	return chapter .. chapter_error;
end

--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Detects but ignores the character pattern that results from the transclusion of {{'}} templates.

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i=1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- Test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position then
			if 'nowiki' == capture or 'math' == capture then 					-- nowiki, math stripmarker (not an error condition)
				stripmarker = true;												-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { set_error( 'invisible_char', {err_msg, wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i=i+1;																	-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end

--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash

]]

local function hyphen_to_dash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if comp:sub(1,1) == duplicate_char then								-- is first charactier same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for th
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = str:sub(-1,-1);										-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = str:sub(1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = str:sub(1, -4) .. &quot;''&quot;;							-- remove them and add back ''
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then		-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then		-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then			-- if last two chars of str are sepc] external link
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;'']&quot; then		-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then				-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = str:sub(1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end		-- if duplicate_char not a letter then escape it
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )			-- remove duplicate_char if it follows html markup
					else
						value = value:sub( 2, -1 );								-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end  


--[[--------------------------&lt; I S _ S U F F I X &gt;------------------------------------------------------------

returns true is suffix is properly formed Jr, Sr, or ordinal in the range 2–9.  Puncutation not allowed.

]]

local function is_suffix (suffix)
	if in_array (suffix, {'Jr', 'Sr', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end

--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written ouside of the code editor and pasted here because the code editor gets confused between character insertion point and cursor position.
The test has been rewritten to use decimal character escape sequence for the individual bytes of the unicode characters so that it is not necessary
to use an external editor to maintain this code.

	\195\128-\195\150 – À-Ö
	\195\152-\195\182 – Ø-ö
	\195\184-\198\191 – ø-ƿ
	\199\132-\201\143 – Ǆ-ɏ%

]]

local function is_good_vanc_name (last, first)
	local first, suffix = first:match ('(.-),?%s*([%dJS][%drndth]+)%.?$') or first;		-- if first has something that looks like a generational suffix, get it

	if is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error ('suffix');
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error ('non-Latin character');
			return false;														-- not a string of latin characters; Vancouver requires Romanization
	end;
	return true;
end

--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just intials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; name:len() then													-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error ('suffix');									-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word


	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i],1,1));				-- insert the intial at end of initials table
		end
		i = i+1;																-- bump the counter
	end
			
--	for word in mw.ustring.gmatch(first, &quot;[^%s%.%-]+&quot;) do						-- names separated by spaces, hyphens, or periods
--		table.insert(initials, mw.ustring.sub(word,1,1))						-- Vancouver format does not include full stops.
--		i = i + 1;																-- bump the counter 
--		if 2 &lt;= i then break; end												-- only two initials allowed in Vancouver system; if 2, quit
--	end
	return table.concat(initials)												-- Vancouver format does not include spaces.
end

--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = ',';																-- name-list separator between authors is a comma
		namesep = ' ';															-- last/first separator is a space
	else
		sep = ';'																-- name-list separator between authors is a semicolon
		namesep = ', '															-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then					-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first 
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;				-- link author/editor if this page is not the author's/editor's page
				end
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end

--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]
local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of author and editor name parameters for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the parameters |display-authors=etal or |display-editors=etal

]]

local function name_has_etal (name, etal, nocat)

	if is_set (name) then														-- name can be nil in which case just return
		local etal_pattern = &quot;[;,]? *[\&quot;']*%f[%a][Ee][Tt] *[Aa][Ll][%.\&quot;']*$&quot;	-- variations on the 'et al' theme
		local others_pattern = &quot;[;,]? *%f[%a]and [Oo]thers&quot;;					-- and alternate to et al.
		
		if name:match (etal_pattern) then										-- variants on et al.
			name = name:gsub (etal_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		elseif name:match (others_pattern) then									-- if not 'et al.', then 'and others'?
			name = name:gsub (others_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		end
	end
	return name, etal;															-- 
end

--[[--------------------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;----------------------------------------

Evaluates the content of author and editor (surnames only) parameters for multiple names.  Multiple names are
indicated if there is more than one comma and or semicolon.  If found, the function adds the multiple name
(author or editor) maintenance category.

]]

local function name_has_mult_names (name, list_name)
local count, _;
	if is_set (name) then
		if name:match ('^%(%(.*%)%)$') then										-- if wrapped in doubled parentheses, ignore 
			name = name:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			_, count = name:gsub ('[;,]', '');									-- count the number of separator-like characters
			
			if 1 &lt; count then													-- param could be |author= or |editor= so one separactor character is acceptable
				add_maint_cat ('mult_names', list_name:lower());				-- more than one separator indicates multiple names so add a maint cat for this template
			end
		end
	end
	return name;																-- and done
end

--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary
	while true do
		last = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false);							-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false);						-- find and remove variations on et al.
		last = name_has_mult_names (last, err_msg_list_name);					-- check for multiple names in last and its aliases
		
		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			link_title_ok (link, list_name:match (&quot;(%w+)List&quot;):lower() .. '-link' .. i, last, list_name:match (&quot;(%w+)List&quot;):lower() .. '-last' .. i);	-- check for improper wikimarkup

			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because case of the source may be incorrect
or different from the case that WikiMedia uses, the name comparisons are done in lower case and when a match is
found, the Wikimedia version (assumed to be correct) is returned along with the code.  When there is no match, we
return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') return a list of languages that in some cases may include
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.

Names but that are included in the list will be found if that name is provided in the |language= parameter.  For example,
if |language=Chavacano de Zamboanga, that name will be found with the associated code 'cbk-zam'.  When names are found
and the associated code is not two or three characters, this function returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	local languages = mw.language.fetchLanguageNames(this_wiki_code, 'all')		-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() and 3 ~= code:len() then							-- two- or three-character codes only; extensions not supported
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the the code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for the code
end

--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code is recognized by MediaWiki,
use the returned name; if not, then use the value that was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is assigned to the category for
that code: Category:Norwegian-language sources (no).  For valid three-character code languages, the page is assigned
to the single category for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does not recognize three-character
equivalents of two-character codes: code 'ar' is recognized bit code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are
separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki = mw.getContentLanguage();									-- get a language object for this wiki
	local this_wiki_code = this_wiki:getCode()									-- get this wiki's language code
	local this_wiki_name = mw.language.fetchLanguageName(this_wiki_code, this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang

		if lang:match ('^%a%a%-') then											-- strip ietf language tags from code; TODO: is there a need to support 3-char with tag?
			lang = lang:match ('(%a%a)%-')										-- keep only 639-1 code portion to lang; TODO: do something with 3166 alpha 2 country code?
		end
		if 2 == lang:len() or 3 == lang:len() then								-- if two-or three-character code
			name = mw.language.fetchLanguageName( lang:lower(), this_wiki_code);	-- get language name if |language= is a proper code
		end
	
		if is_set (name) then													-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, this_wiki_code);				-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then													-- only 2- or 3-character codes
			if this_wiki_code ~= code then										-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					add_prop_cat ('foreign_lang_source', {name, code})			-- categorize it
				else															-- or is a recognized language (but has a three-character code)
					add_prop_cat ('foreign_lang_source_2', {code})				-- categorize it differently TODO: support mutliple three-character code categories per cs1|2 template
				end
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, ' and ')							-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		language_list[code] = 'and ' .. language_list[code];					-- prepend last name with 'and&lt;space&gt;'
		name = table.concat (language_list, ', ')								-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
	end
	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
end

--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = '.';																-- terminate the rendered citation with a period
	end
	return '.', ps;																-- separator is a full stop
end

--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = '';																-- make sure it isn't nil
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return ',', ps, ref;														-- separator is a comma
end

--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end

--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extension, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf[%?#]?') or url:match ('%.PDF[%?#]?');
end

--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parenthases, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end

--[[--------------------------&lt; G E T _ D I S P L A Y _ A U T H O R S _ E D I T O R S &gt;------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_authors_editors (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_auth_ed', list_name);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end

--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
--	local good_pattern = '^P[^%.P%l]';
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
--	local bad_pattern = '^[Pp][Pp]';
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
--		if Page:match ('^[Pp]?[Pp]%.?[ %d]') or  Page:match ('^[Pp]ages?[ %d]') or
--			Pages:match ('^[Pp]?[Pp]%.?[ %d]') or  Pages:match ('^[Pp]ages?[ %d]') then
--				add_maint_cat ('extra_text');
--		end
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	if vparam:find ('%[%[') or vparam:find ('%]%]')	then						-- no wikilinking vauthors names
		add_vanc_error ('wikilink');
	end
	v_name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;)								-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parentheses to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')								-- remove doubled parntheses
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error ('punctuation');
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
			if is_suffix (first) then											-- if a valid suffix
				suffix = first													-- save it as a suffix and
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end																	-- no suffix error message here because letter combination may be result of Romanization; check for digits?
			last = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error ('missing comma');								-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error ('name');										-- matches a space between two intiials
			end
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error ('initials');									-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first);									-- check first and last before restoring the suffix which may have a non-Latin digit
			if is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			is_good_vanc_name (last, '');
		end
	
			
																				-- this from extract_names ()
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice incase we have a first 1 without a last1
		select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, no, etc).  When the parameter value has not been assigned a value (missing or empty
in the source template) the function refurns true.  If the parameter value is one of the list of allowed values returns
true; else, emits an error message and returns false.

]]

local function is_valid_parameter_value (value, name, possible)
	if not is_set (value) then
		return true;															-- an empty parameter is ok
	elseif in_array(value:lower(), possible) then
		return true;
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list,-1,-1) == sepc) or (string.sub (name_list,-3,-1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terninate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not is_set (volume) and not is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end
	
	local vol = '';
		
	if is_set (volume) then
		if (4 &lt; mw.ustring.len(volume)) then
			vol = substitute (cfg.messages['j-vol'], {sepc, volume});
		else
			vol = wrap_style ('vol-bold', hyphen_to_dash(volume));
		end
	end
	if is_set (issue) then
		return vol .. substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end






--[[-------------------------&lt; N O R M A L I Z E _ P A G E _ L I S T &gt;-----------------------------------------

not currently used

normalizes a comma, ampersand, and/or space separated list to be '&lt;value&gt;, &lt;value&gt;, ..., &lt;value&gt;'
returns list unchanged if there are no commas else strips whitespace and then reformats the list

]]
--[[
local function normalize_page_list (list)
	if not list:find ('[,&amp; ]') then return list end								-- if list is not delimited with commas, ampersands, or spaces; done
	
	list = mw.text.split (list, '[,&amp;%s]+');										-- make a table of values
	list = table.concat (list, ', ');											-- and now make a normalized list
	return list;
end
]]

--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'journal' == origin);

	if is_set (page) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif is_set(pages) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then										-- if pages is only digits, assume a single page number
			return '', substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org urls to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot url or to calendar pages.  When the archive url is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the url.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org url does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command url
	|archive-url= is an archive.org url that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org urls:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this funct may return a modified
archive url:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the url unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.or url
	
	if not url:match('//web%.archive%.org/') then
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command url, we don't want to allow saving of the target page 
		table.insert( z.message_tail, { set_error( 'archive_url', {'save command'}, true ) } );	-- add error message
		if Preview_mode then
			return url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1), date;	-- preview mode: modify and return ArchiveURL and ArchiveDate
		else
			return '', '';														-- return empty strings for archiveURL and ArchiveDate
		end
	end

--	if url:match('//web%.archive%.org/web/%*/') or url:match('//web%.archive%.org/%*/') then	-- wildcard with or without 'web/' path element
--		table.insert( z.message_tail, { set_error( 'archive_url', {'wildcard'}, true ) } );		-- add error message and
--		return '', '';																			-- return empty strings for archiveURL and ArchiveDate
--	end
	
	path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');		-- split out some of the url parts for evaluation
	
	if not is_set(timestamp) or 14 ~= timestamp:len() then								-- path and flag optional, must have 14-digit timestamp here
		err_msg = 'timestamp';
		if '*' ~= flag then
			url=url:gsub ('(//web%.archive%.org/[^%d]*%d?%d?%d?%d?%d?%d?)[^/]*', '%1*', 1)	-- for preview, modify ts to be yearmo* max (0-6 digits plus splat)
		end
	elseif is_set(path) and 'web/' ~= path then									-- older archive urls do not have the extra 'web/' path element
		err_msg = 'path';
	elseif is_set (flag) and not is_set (path) then								-- flag not allowed with the old form url (without the 'web/' path element)
		err_msg = 'flag';
	elseif is_set (flag) and not flag:match ('%a%a_') then						-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
		err_msg = 'flag';
	else
		return url, date;														-- return archiveURL and ArchiveDate
	end
																				-- if here something not right so
	table.insert( z.message_tail, { set_error( 'archive_url', {err_msg}, true ) } );	-- add error message and
	if Preview_mode then
		return url, date;														-- preview mode so return archiveURL and ArchiveDate
	else
		return '', '';															-- return empty strings for archiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe:
	{{cite ... |title=Title access-date=2016-03-17}}

cs1|2 shares some parameter names with xml/html atributes: class=, title=, etc.  To prevent false positives xml/html
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove xml/html tags because attributes: class=, title=, etc 

	capture = value:match ('%s+(%a[%a%d]+)%s*=') or value:match ('^(%a[%a%d]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then								-- if the capture is a valid parameter name
		add_maint_cat ('missing_pipe');
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
		end
		if is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
		end
	end

	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list
	local Contribution = A['Contribution'];
	if in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not is_set (Contribution) then									-- |contributor= requires |contribution=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if select_one (args, cfg.aliases['ContributorList-Last'], 'redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { set_error( 'contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if not is_valid_parameter_value (NameListFormat, 'name-list-format', cfg.keywords['name-list-format']) then			-- only accepted value for this parameter is 'vanc'
		NameListFormat = '';													-- anything else, set to empty string
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
			link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wikimarkup in |title-link= or wikimarkup in |title= when |title-link= is set

	local Chapter = A['Chapter'];
	local ScriptChapter = A['ScriptChapter'];
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];

	local ArchiveDate;
	local ArchiveURL;

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	
	local DeadURL = A['DeadURL']
		if not is_valid_parameter_value (DeadURL, 'dead-url', cfg.keywords ['deadurl']) then	-- set in config.defaults to 'yes'
			DeadURL = '';														-- anything else, set to empty string
		end

	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];
	local Periodical_origin = A:ORIGIN('Periodical');							-- get the name of the periodical parameter

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if in_array (config.CitationClass, cfg.templates_using_volume) and not ('conference' == config.CitationClass and not is_set (Periodical)) then
		Volume = A['Volume'];
	end
	if in_array (config.CitationClass, cfg.templates_using_issue) and not (in_array (config.CitationClass, {'conference', 'map'}) and not is_set (Periodical))then
		Issue = A['Issue'];
	end
	local Position = '';
	if not in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash( A['Pages'] );	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
		if not is_valid_parameter_value (RegistrationRequired, 'registration', cfg.keywords ['yes_true_y']) then
			RegistrationRequired=nil;
		end
	local SubscriptionRequired = A['SubscriptionRequired'];
		if not is_valid_parameter_value (SubscriptionRequired, 'subscription', cfg.keywords ['yes_true_y']) then
			SubscriptionRequired=nil;
		end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local Agency = A['Agency'];

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
		if not is_valid_parameter_value (IgnoreISBN, 'ignore-isbn-error', cfg.keywords ['yes_true_y']) then
			IgnoreISBN = nil;													-- anything else, set to empty string
		end
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
		if not is_valid_parameter_value (LastAuthorAmp, 'last-author-amp', cfg.keywords ['yes_true_y']) then
			LastAuthorAmp = nil;													-- set to empty string
		end
	local no_tracking_cats = A['NoTracking'];
		if not is_valid_parameter_value (no_tracking_cats, 'no-tracking', cfg.keywords ['yes_true_y']) then
			no_tracking_cats = nil;												-- set to empty string
		end

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = A['DF'];															-- date format set in cs1|2 template
	if not is_valid_parameter_value (DF, 'df', cfg.keywords['date-format']) then	-- validate reformatting keyword
		DF = '';																-- not valid, set to empty string
	end

-- set default parameter values defined by |mode= parameter.  If |mode= is empty or omitted, use CitationClass to set these values
	local Mode = A['Mode'];
	if not is_valid_parameter_value (Mode, 'mode', cfg.keywords['mode']) then
		Mode = '';
	end
	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	select_one( args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'redundant_parameters' );		-- this is a dummy call simply to get the error message and category

	local NoPP = A['NoPP'] 
	if is_set (NoPP) and is_valid_parameter_value (NoPP, 'nopp', cfg.keywords ['yes_true_y']) then
		NoPP = true;
	else
		NoPP = nil;																-- unset, used as a flag later
	end

	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Pages = '';															-- unset the others
			At = '';
		end
		extra_text_in_page_check (Page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.
	elseif is_set(Pages) then
		if is_set(At) then
			At = '';															-- unset
		end
		extra_text_in_page_check (Pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped
	|url maps to |chapterurl when |title is remapped

All other combinations of |encyclopedia, |title, and |article are not modified

]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					TransChapter = TransTitle;
					ChapterURL = URL;
					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter= '[[' .. TitleLink .. '|' .. Chapter .. ']]';
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			else																-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if is_set(A['Number']) then													-- cite techreport uses 'number', which other citations alias to 'issue'
			if not is_set(ID) then												-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];													-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', 'id') .. ' and ' .. wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Others) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Others;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Others;
			end
		else
			Others = '(Interview)';
		end
	end

-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	elseif 'mailinglist' == A:ORIGIN('Periodical') then
		Periodical = '';														-- unset because mailing list is only used for cite mailing list
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];

		link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wikimarkup in |series-link= or wikimarkup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) and is_set (AirDate) then							-- promote airdate to date
			Date = AirDate;
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('series', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = '[[' .. ChapterLink .. '|' .. Chapter .. ']]';		-- ok to wikilink
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = '[[' .. ChapterLink .. '|' .. Series .. ']]';			-- series links with ChapterLink (episodelink -&gt; TitleLink -&gt; ChapterLink) ugly
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = '[[' .. SeriesLink .. '|' .. Series .. ']]';
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
-- end of {{cite episode}} stuff

-- Account for the oddities that are {{cite arxiv}}, before generation of COinS data.
	if 'arxiv' == config.CitationClass then
		if not is_set (ID_list['ARXIV']) then									-- |arxiv= or |eprint= required for cite arxiv
			table.insert( z.message_tail, { set_error( 'arxiv_missing', {}, true ) } );		-- add error message
		elseif is_set (Series) then												-- series is an alias of version
			ID_list['ARXIV'] = ID_list['ARXIV'] .. Series;						-- concatenate version onto the end of the arxiv identifier
			Series = '';														-- unset
			deprecated_parameter ('version');									-- deprecated parameter but only for cite arxiv
		end
		
		if first_set ({AccessDate, At, Chapter, Format, Page, Pages, Periodical, PublisherName, URL,	-- a crude list of parameters that are not supported by cite arxiv
			ID_list['ASIN'], ID_list['BIBCODE'], ID_list['DOI'], ID_list['ISBN'], ID_list['ISSN'],
			ID_list['JFM'], ID_list['JSTOR'], ID_list['LCCN'], ID_list['MR'], ID_list['OCLC'], ID_list['OL'],
			ID_list['OSTI'], ID_list['PMC'], ID_list['PMID'], ID_list['RFC'], ID_list['SSRN'], ID_list['USENETID'], ID_list['ZBL']},27) then
				table.insert( z.message_tail, { set_error( 'arxiv_params_not_supported', {}, true ) } );		-- add error message

				AccessDate= '';													-- set these to empty string; not supported in cite arXiv
				PublisherName = '';												-- (if the article has been published, use cite journal, or other)
				Chapter = '';
				URL = '';
				Format = '';
				Page = ''; Pages = ''; At = '';
		end
		Periodical = 'arXiv';													-- set to arXiv for COinS; after that, must be set to empty string
	end

-- handle type parameter for those CS1 citations that have default values
	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
	TitleType = substitute( cfg.messages['type'], TitleType);					-- display it in parentheses
	end

-- legacy: promote concatenation of |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {['access-date']=AccessDate, ['archive-date']=ArchiveDate, ['date']=Date, ['doi-broken-date']=DoiBroken,
				['embargo']=Embargo, ['lay-date']=LayDate, ['publication-date']=PublicationDate, ['year']=Year};

		anchor_year, Embargo, error_message = dates(date_parameters_list, COinS_date);

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end
		
		if not is_set(error_message) then										-- error free dates only
			local modified = false;												-- flag
			if is_set (DF) then													-- if we need to reformat dates
				modified = reformat_dates (date_parameters_list, DF, false);	-- reformat to DF format, use long month names if appropriate
			end

			if true == date_hyphen_to_dash (date_parameters_list) then					-- convert hyphens to dashes where appropriate
				modified = true;
				add_maint_cat ('date_format');									-- hyphens were converted so add maint category
			end
			
			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'];				-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'];
				Date = date_parameters_list['date'];
				DoiBroken = date_parameters_list['doi-broken-date'];
				LayDate = date_parameters_list['lay-date'];
				PublicationDate = date_parameters_list['publication-date'];
			end
		else
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end

--		if is_set(error_message) then
--			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
--		elseif is_set (DF) then
--			if reformat_dates (date_parameters_list, DF, false) then			-- reformat to DF format, use long month names if appropriate
--				AccessDate = date_parameters_list['access-date'];				-- overwrite date holding parameters with reformatted values
--				ArchiveDate = date_parameters_list['archive-date'];
--				Date = date_parameters_list['date'];
--				DoiBroken = date_parameters_list['doi-broken-date'];
--				LayDate = date_parameters_list['lay-date'];
--				PublicationDate = date_parameters_list['publication-date'];
--			end
--		end
	end	-- end of do

-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);											-- 

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
			if 'episode' == config.CitationClass then							-- special case for cite episode; TODO: is there a better way to do this?
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
			else
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
			end
	end
	
	if 'none' == Title and in_array (config.CitationClass, {'journal', 'citation'}) and is_set (Periodical) and 'journal' == A:ORIGIN('Periodical') then	-- special case for journal cites
		Title = '';																-- set title to empty string
		add_maint_cat ('untitled');
	end

	check_for_url ({															-- add error message when any of these parameters contains a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[A:ORIGIN('Periodical')]=Periodical,
		[A:ORIGIN('PublisherName')] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = Periodical,
		['Encyclopedia'] = Encyclopedia,
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

-- Account for the oddities that are {{cite arxiv}}, AFTER generation of COinS data.
	if 'arxiv' == config.CitationClass then										-- we have set rft.jtitle in COinS to arXiv, now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in cite arxiv; if article has been published, use cite journal
	end

-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = substitute (cfg.messages['newsgroup'], external_link( 'news:' .. PublisherName, PublisherName, A:ORIGIN('PublisherName') ));
		end
	end



	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
--		local maximum;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text											-- get current page name so that we don't wikilink to it via editorlinkn
		};

		do																		-- do editor name list first because coauthors can modify control table
			control.maximum , editor_etal = get_display_authors_editors (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if is_set (Editors) then
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
					EditorCount = 2;											-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
				else
					EditorCount = 2;											-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
				end
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do translators
			control.maximum = #t;												-- number of translators
			Translators = list_people(control, t, false);						-- et al not currently supported
		end
		do																		-- now do contributors
			control.maximum = #c;												-- number of contributors
			Contributors = list_people(control, c, false);						-- et al not currently supported
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_authors_editors (A['DisplayAuthors'], #a, 'authors', author_etal);

			if is_set(Coauthors) then											-- if the coauthor field is also used, prevent ampersand and et al. formatting.
				control.lastauthoramp = nil;
				control.maximum = #a + 1;
			end
			
			last_first_list = list_people(control, a, author_etal);

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false);	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if is_set (Authors) and is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

		if not is_set(Authors) and is_set(Coauthors) then						-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
			table.insert( z.message_tail, { set_error('coauthors_missing_author', {}, true) } );	-- emit error message
		end
	end

-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

-- special case for chapter format so no error message or cat when chapter not supported
	if not (in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not is_set(URL) then
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then	-- |url= required for cite web, cite podcast, and cite mailinglist
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURLorigin, OriginalFormat;						-- TODO: swap chapter and title here so that archive applies to most specific if both are set?
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (ChapterURL) then 	-- swapped									-- URL not set so if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURLorigin = ChapterURLorigin;								-- name of chapter-url parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |format=
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				ChapterURLorigin = A:ORIGIN('ArchiveURL')						-- name of archive-url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
			end
		elseif is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURLorigin = URLorigin;										-- name of url parameter for error messages
			OriginalFormat = Format;											-- and original |format=
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
			end
 		end
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'arxiv'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			local chap_param;
			if is_set (Chapter) then											-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif is_set (ScriptChapter) then
				chap_param = A:ORIGIN ('ScriptChapter')
			else is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if is_set (chap_param) then											-- if we found one
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {chap_param}, true ) } );		-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if is_set (Contribution) and 0 &lt; #c then								-- if this is a contribution with contributor(s)
			if in_array (Contribution:lower(), cfg.keywords.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, Chapter, TransChapter, ChapterURL, ChapterURLorigin, no_quotes);		-- Contribution is also in Chapter
		if is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter.. sepc .. ' ';
		elseif is_set (ChapterFormat) then										-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'mailinglist', 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
	
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then
			Title = external_link( URL, Title, URLorigin ) .. TransError .. Format;
-- this experiment hidden 2016-04-10; see Help_talk:Citation_Style_1#Recycled_urls
--			local temp_title = external_link( URL, Title, URLorigin ) .. TransError .. Format;	-- do this so we get error message even if url is usurped no archive
--			if in_array (DeadURL, {'unfit no archive', 'usurped no archive'}) then	-- when url links to inappropriate location and there is no archive of original source available
--				local err_msg
--				if temp_title:match ('%[%S+%s+(.+)%](&lt;.+)') then				-- if there is an error message
--					Title, err_msg = temp_title:match ('%[%S+%s+(.+)%](&lt;.+)');	-- strip off external link; TODO: find a better to do this
--					Title = Title .. (err_msg or '');
--				end
--			else
--				Title = temp_title;
--			end

			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURLorigin );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if is_set(Minutes) then
			if is_set (Time) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'minutes') .. ' and ' .. wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
--		Others = sepc .. ' Translated by ' .. Translators .. Others; 
		Others = sepc .. ' ' .. wrap_msg ('translated', Translators, use_lowercase) .. Others; 
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

--[[
Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
note is displayed. There are no error messages for this condition.

]]
	if is_set (SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif is_set (RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if 'citation', lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text
																				-- neither of these work; don't know why; it seems that substitute() isn't being called	
		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then				-- if first and last characters of quote are quote marks
			Quote = Quote:sub(2,-2);											-- strip them off
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL') ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- DeadURL is empty, 'yes', 'true', 'y', 'unfit', 'usurped'
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if in_array (DeadURL, {'unfit', 'usurped'}) then
				Archived = sepc .. &quot; &quot; .. 'Archived from the original on ' .. ArchiveDate;	-- format already styled
			else																-- DeadURL is empty, 'yes', 'true', or 'y'
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURLorigin ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL') ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL') ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURLorigin );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin );
	end

	local Publisher;
	if is_set(Periodical) and
		not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap_msg ('published', PublicationDate);
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap_msg ('published', PublicationDate) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
			Language, Edition, Publisher, Agency, Volume}, sepc );
		
	elseif in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(Periodical) then		-- special cases for book cites
		if is_set (Contributors) then											-- when we are citing foreword, preface, introduction, etc
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Transcript, Language, Edition, Publisher}, sepc );
	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if is_set(Date) then
		if is_set (Authors) or is_set (Editors) then							-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;;				-- in paranetheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon,-1,-1) == sepc) then							-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigYear;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigYear;							-- Date begins with sepc
			end
		end
	end	
	if is_set(Authors) then
		if is_set(Coauthors) then
			if 'vanc' == NameListFormat then									-- separate authors and coauthors with proper name-list-separator
				Authors = Authors .. ', ' .. Coauthors;
			else
				Authors = Authors .. '; ' .. Coauthors;
			end
		end
		if not is_set (Date) then												-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then in_text = in_text:lower() end				-- lowercase for cs2
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if is_set (Contributors) then											-- book cite and we're citing the intro, preface, etc
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if is_set (Editors) then											-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if not is_set (Date) then											-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = config.CitationClass;
		options.class = &quot;citation &quot; .. config.CitationClass;					-- class=citation required for blue highlight when used with |ref=
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then								-- set reference anchor if appropriate
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			if #namelist &gt; 0 then												-- if there are names in namelist
				id = anchor_id (namelist, year);								-- go make the CITEREF anchor
			else
				id = '';														-- unset
			end
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then													-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		text = substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text});	-- when |ref= is set
	else
		text = substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text});	-- all other cases
	end		

	text = text .. substitute (cfg.presentation['ocins'], {OCinSoutput});		-- append metadata to the citation
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. error_comment( v[1], v[2] );
				else
					text = text .. error_comment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end

	if #z.maintenance_cats ~= 0 then
		text = text .. '&lt;span class=&quot;citation-comment&quot; style=&quot;display:none; color:#33aa33&quot;&gt;';
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. ' ' .. v .. ' ([[:Category:' .. v ..'|link]])';
		end
		text = text .. '&lt;/span&gt;';	-- maintenance mesages (realy just the names of the categories for now)
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

--[[--------------------------&lt; C S 1 . C I T A T I O N &gt;------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

function cs1.citation(frame)
	local pframe = frame:getParent()
	local validation, utilities, identifiers, metadata;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (utilities);								-- so that functions in Date validataion can see the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	dates = validation.dates;													-- imported functions from Module:Citation/CS1/Date validation
	year_date_check = validation.year_date_check;
	reformat_dates = validation.reformat_dates;
	date_hyphen_to_dash = validation.date_hyphen_to_dash;
	
	is_set = utilities.is_set;													-- imported functions from Module:Citation/CS1/Utilities
	in_array = utilities.in_array;
	substitute = utilities.substitute;
	error_comment = utilities.error_comment;
	set_error = utilities.set_error;
	select_one = utilities.select_one;
	add_maint_cat = utilities.add_maint_cat;
	wrap_style = utilities.wrap_style;
	safe_for_italics = utilities.safe_for_italics;
	remove_wiki_link = utilities.remove_wiki_link;

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	extract_ids = identifiers.extract_ids;										-- imported functions from Module:Citation/CS1/Utilities
	build_id_list = identifiers.build_id_list;
	is_embargoed = identifiers.is_embargoed;
	
	make_coins_title = metadata.make_coins_title;								-- imported functions from Module:Citation/CS1/COinS
	get_coins_pages = metadata.get_coins_pages;
	COinS = metadata.COinS;

	
	Preview_mode = frame:preprocess('{{REVISIONID}}');							-- use magic word to get revision id
	if is_set (Preview_mode) then												-- if there is a value then this is not a preiview
		Preview_mode = false;
	else
		Preview_mode = true;													-- no value (nil or empty string) so this is a preview
	end
	
	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute( param, capture );				-- add the capture to the suggested parameter (typically the enumerator)
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, param}, true );	-- set the error message
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			missing_pipe_check (v);												-- do we think that there is a parameter that is missing a pipe?
			
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);
		end
	end
	return citation0( config, args)
end

return cs1;</text>
      <sha1>1o9wj33708mavdvycwmox8hop12mjfu</sha1>
    </revision>
    <revision>
      <id>4710</id>
      <parentid>4709</parentid>
      <timestamp>2016-06-06T00:30:11Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Undid revision 723906674 by [[Special:Contributions/Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]])</comment>
      <origin>4710</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="153212" sha1="3htqnmev3c8azos369wufap3kf85n00" xml:space="preserve">
local cs1 ={};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local dates, year_date_check, reformat_dates, date_hyphen_to_dash				-- functions in Module:Citation/CS1/Date_validation

local is_set, in_array, substitute, error_comment, set_error, select_one,		-- functions in Module:Citation/CS1/Utilities
	add_maint_cat, wrap_style, safe_for_italics, remove_wiki_link;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local extract_ids, build_id_list, is_embargoed;									-- functions in Module:Citation/CS1/Identifiers

local make_coins_title, get_coins_pages, COinS;									-- functions in Module:Citation/CS1/COinS

local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

delare variables here that have page-wide scope

]]

local Preview_mode = false;														-- flag indicating that we are rendering a preview page (Show preview button)

--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end

--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

]]

local added_prop_cats = {}														-- list of property categories that have been added to z.properties_cats
local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));		-- make name then add to table
	end
end

--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

]]

local added_vanc_errs;															-- flag so we only emit one Vancouver error / category
local function add_vanc_error (source)
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {source}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a uri scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of tlds: https://www.iana.org/domains/root/db

rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the tld.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a url with a scheme) will be stripped
here.  Perhaps not necessary but retained incase it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ascii characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the tld) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org TLD
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and tld or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%a%d]') then										-- first character must be letter or digit
		return false;
	end
																				-- Do most common case first
	if domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.%a%a+$') then				-- three or more character hostname.hostname or hostname.tld
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.xn%-%-[%a%d]+$') then	-- internationalized domain name with ACE prefix
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.org$') then							-- one character .org hostname
		return true;
	elseif domain:match ('%f[%a][qxz]%.com$') then								-- assigned one character .com hostname (x.com times out 2015-12-10)
		return true;
	elseif domain:match ('%f[%a][iq]%.net$') then								-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.%a%a$') then							-- one character hostname and cctld (2 chars)
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d]%.%a%a+$') then					-- two character hostname and tld
		return true;
	elseif domain:match ('^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?') then		-- IPv4 address
		return true;
	else
		return false;
	end
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a url appear to be a valid url; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if is_set (scheme) then														-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when url is protocol relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a url into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following tld) (if any) and any path(/), query(?) or fragment(#).

If protocol relative url, return nil scheme and domain else return nil for both scheme and domain.

When not protocol relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol relative url
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		authority = authority:gsub ('//', '', 1);								-- replace place 1 pair of '/' with nothing;
		if is_set(authority) then												-- if anything left (1 or 3+ '/' where authority should be) then
			return scheme;														-- return scheme only making domain nil which will cause an error message
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link= etc for properly formatted content: no wikilinks, no urls

Link parameters are to hold the title of a wikipedia article so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki urls and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid url (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid url (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from url; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid url
end

--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wikilinked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

]]

local function link_title_ok (link, lorig, title, torig)
local orig;

	if is_set (link) then 														-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		end
	end

	if is_set (orig) then
		table.insert( z.message_tail, { set_error( 'bad_paramlink', orig)});	-- url or wikilink in |title= with |title-link=;
	end
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the url into scheme and domain
portions, or for protocol relative (//example.com) urls, just the domain.  Use is_url() to validate the two
portions of the url.  If both are valid, or for protocol relative if domain is valid, return true, else false.

Because it is different from a standard url, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper url
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from url;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a url.  The test will also find external wikilinks
that use protocol relative urls. Also finds bare urls.

The frontier pattern prevents a match on interwiki links which are similar to scheme:path urls.  The tests that
find bracketed urls are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol relative ext wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare url with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol relative bare url: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a url
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then												-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source )
	local error_str = &quot;&quot;;
	local domain;
	local path;
	
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the url into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['[']='%5b',[']']='%5d'});					-- replace '[' and ']' with their percent encoded values
		URL=domain..path;														-- and reassemble
	end
	
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url( label ), &quot;]&quot;, error_str });
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

]]

local page_in_deprecated_cat;													-- sticky flag so that the category is added only once
local function deprecated_parameter(name)
	if not page_in_deprecated_cat then
		page_in_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end

--[[--------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Call this function for chapter titles, for website titles, etc; not for book titles.

]]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	
	cap, cap2 = str:match (&quot;^([\&quot;\'])([^\'].+)&quot;);								-- match leading double or single quote but not double single quotes
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-left'], {cap, cap2});
	end

	cap, cap2 = str:match (&quot;^(.+[^\'])([\&quot;\'])$&quot;)
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-right'], {cap, cap2});
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title= and |script-chapter=

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, cfg.script_lang_codes) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				add_prop_cat ('script')
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return substitute( msg, str );										-- including template text
	else
		return substitute( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (scriptchapter, chapter, transchapter, chapterurl, chapter_url_source, no_quotes)
	local chapter_error = '';
	
	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);										-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
			chapter = wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, scriptchapter)						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (transchapter) then
		transchapter = wrap_style ('trans-quoted-title', transchapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. transchapter;
		else																	-- here when transchapter without chapter or script-chapter
			chapter = transchapter;												-- 
			chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
		end
	end

	if is_set (chapterurl) then
		chapter = external_link (chapterurl, chapter, chapter_url_source);		-- adds bare_url_missing_title error if appropriate
	end

	return chapter .. chapter_error;
end

--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Detects but ignores the character pattern that results from the transclusion of {{'}} templates.

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i=1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- Test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position then
			if 'nowiki' == capture or 'math' == capture then 					-- nowiki, math stripmarker (not an error condition)
				stripmarker = true;												-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { set_error( 'invisible_char', {err_msg, wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i=i+1;																	-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end

--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash

]]

local function hyphen_to_dash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if comp:sub(1,1) == duplicate_char then								-- is first charactier same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for th
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = str:sub(-1,-1);										-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = str:sub(1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = str:sub(1, -4) .. &quot;''&quot;;							-- remove them and add back ''
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then		-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then		-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then			-- if last two chars of str are sepc] external link
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;'']&quot; then		-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then				-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = str:sub(1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end		-- if duplicate_char not a letter then escape it
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )			-- remove duplicate_char if it follows html markup
					else
						value = value:sub( 2, -1 );								-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end  


--[[--------------------------&lt; I S _ S U F F I X &gt;------------------------------------------------------------

returns true is suffix is properly formed Jr, Sr, or ordinal in the range 2–9.  Puncutation not allowed.

]]

local function is_suffix (suffix)
	if in_array (suffix, {'Jr', 'Sr', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end

--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written ouside of the code editor and pasted here because the code editor gets confused between character insertion point and cursor position.
The test has been rewritten to use decimal character escape sequence for the individual bytes of the unicode characters so that it is not necessary
to use an external editor to maintain this code.

	\195\128-\195\150 – À-Ö
	\195\152-\195\182 – Ø-ö
	\195\184-\198\191 – ø-ƿ
	\199\132-\201\143 – Ǆ-ɏ%

]]

local function is_good_vanc_name (last, first)
	local first, suffix = first:match ('(.-),?%s*([%dJS][%drndth]+)%.?$') or first;		-- if first has something that looks like a generational suffix, get it

	if is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error ('suffix');
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error ('non-Latin character');
			return false;														-- not a string of latin characters; Vancouver requires Romanization
	end;
	return true;
end

--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generaltional suffix in the Vancouver format because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just intials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; name:len() then													-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error ('suffix');									-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word


	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i],1,1));				-- insert the intial at end of initials table
		end
		i = i+1;																-- bump the counter
	end
			
--	for word in mw.ustring.gmatch(first, &quot;[^%s%.%-]+&quot;) do						-- names separated by spaces, hyphens, or periods
--		table.insert(initials, mw.ustring.sub(word,1,1))						-- Vancouver format does not include full stops.
--		i = i + 1;																-- bump the counter 
--		if 2 &lt;= i then break; end												-- only two initials allowed in Vancouver system; if 2, quit
--	end
	return table.concat(initials)												-- Vancouver format does not include spaces.
end

--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = ',';																-- name-list separator between authors is a comma
		namesep = ' ';															-- last/first separator is a space
	else
		sep = ';'																-- name-list separator between authors is a semicolon
		namesep = ', '															-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then					-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first 
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;				-- link author/editor if this page is not the author's/editor's page
				end
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end

--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]
local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of author and editor name parameters for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the parameters |display-authors=etal or |display-editors=etal

]]

local function name_has_etal (name, etal, nocat)

	if is_set (name) then														-- name can be nil in which case just return
		local etal_pattern = &quot;[;,]? *[\&quot;']*%f[%a][Ee][Tt] *[Aa][Ll][%.\&quot;']*$&quot;	-- variations on the 'et al' theme
		local others_pattern = &quot;[;,]? *%f[%a]and [Oo]thers&quot;;					-- and alternate to et al.
		
		if name:match (etal_pattern) then										-- variants on et al.
			name = name:gsub (etal_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		elseif name:match (others_pattern) then									-- if not 'et al.', then 'and others'?
			name = name:gsub (others_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		end
	end
	return name, etal;															-- 
end

--[[--------------------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;----------------------------------------

Evaluates the content of author and editor (surnames only) parameters for multiple names.  Multiple names are
indicated if there is more than one comma and or semicolon.  If found, the function adds the multiple name
(author or editor) maintenance category.

]]

local function name_has_mult_names (name, list_name)
local count, _;
	if is_set (name) then
		if name:match ('^%(%(.*%)%)$') then										-- if wrapped in doubled parentheses, ignore 
			name = name:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			_, count = name:gsub ('[;,]', '');									-- count the number of separator-like characters
			
			if 1 &lt; count then													-- param could be |author= or |editor= so one separactor character is acceptable
				add_maint_cat ('mult_names', list_name:lower());				-- more than one separator indicates multiple names so add a maint cat for this template
			end
		end
	end
	return name;																-- and done
end

--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary
	while true do
		last = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false);							-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false);						-- find and remove variations on et al.
		last = name_has_mult_names (last, err_msg_list_name);					-- check for multiple names in last and its aliases
		
		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			link_title_ok (link, list_name:match (&quot;(%w+)List&quot;):lower() .. '-link' .. i, last, list_name:match (&quot;(%w+)List&quot;):lower() .. '-last' .. i);	-- check for improper wikimarkup

			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because case of the source may be incorrect
or different from the case that WikiMedia uses, the name comparisons are done in lower case and when a match is
found, the Wikimedia version (assumed to be correct) is returned along with the code.  When there is no match, we
return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') return a list of languages that in some cases may include
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.

Names but that are included in the list will be found if that name is provided in the |language= parameter.  For example,
if |language=Chavacano de Zamboanga, that name will be found with the associated code 'cbk-zam'.  When names are found
and the associated code is not two or three characters, this function returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	local languages = mw.language.fetchLanguageNames(this_wiki_code, 'all')		-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() and 3 ~= code:len() then							-- two- or three-character codes only; extensions not supported
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the the code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for the code
end

--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code is recognized by MediaWiki,
use the returned name; if not, then use the value that was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is assigned to the category for
that code: Category:Norwegian-language sources (no).  For valid three-character code languages, the page is assigned
to the single category for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does not recognize three-character
equivalents of two-character codes: code 'ar' is recognized bit code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are
separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki = mw.getContentLanguage();									-- get a language object for this wiki
	local this_wiki_code = this_wiki:getCode()									-- get this wiki's language code
	local this_wiki_name = mw.language.fetchLanguageName(this_wiki_code, this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang

		if lang:match ('^%a%a%-') then											-- strip ietf language tags from code; TODO: is there a need to support 3-char with tag?
			lang = lang:match ('(%a%a)%-')										-- keep only 639-1 code portion to lang; TODO: do something with 3166 alpha 2 country code?
		end
		if 2 == lang:len() or 3 == lang:len() then								-- if two-or three-character code
			name = mw.language.fetchLanguageName( lang:lower(), this_wiki_code);	-- get language name if |language= is a proper code
		end
	
		if is_set (name) then													-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, this_wiki_code);				-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then													-- only 2- or 3-character codes
			if this_wiki_code ~= code then										-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					add_prop_cat ('foreign_lang_source', {name, code})			-- categorize it
				else															-- or is a recognized language (but has a three-character code)
					add_prop_cat ('foreign_lang_source_2', {code})				-- categorize it differently TODO: support mutliple three-character code categories per cs1|2 template
				end
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, ' and ')							-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		language_list[code] = 'and ' .. language_list[code];					-- prepend last name with 'and&lt;space&gt;'
		name = table.concat (language_list, ', ')								-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
	end
	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
end

--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = '.';																-- terminate the rendered citation with a period
	end
	return '.', ps;																-- separator is a full stop
end

--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = '';																-- make sure it isn't nil
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return ',', ps, ref;														-- separator is a comma
end

--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end

--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extension, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf[%?#]?') or url:match ('%.PDF[%?#]?');
end

--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parenthases, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end

--[[--------------------------&lt; G E T _ D I S P L A Y _ A U T H O R S _ E D I T O R S &gt;------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_authors_editors (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_auth_ed', list_name);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end

--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
--	local good_pattern = '^P[^%.P%l]';
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
--	local bad_pattern = '^[Pp][Pp]';
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
--		if Page:match ('^[Pp]?[Pp]%.?[ %d]') or  Page:match ('^[Pp]ages?[ %d]') or
--			Pages:match ('^[Pp]?[Pp]%.?[ %d]') or  Pages:match ('^[Pp]ages?[ %d]') then
--				add_maint_cat ('extra_text');
--		end
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	if vparam:find ('%[%[') or vparam:find ('%]%]')	then						-- no wikilinking vauthors names
		add_vanc_error ('wikilink');
	end
	v_name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;)								-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parentheses to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')								-- remove doubled parntheses
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error ('punctuation');
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
			if is_suffix (first) then											-- if a valid suffix
				suffix = first													-- save it as a suffix and
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end																	-- no suffix error message here because letter combination may be result of Romanization; check for digits?
			last = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error ('missing comma');								-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error ('name');										-- matches a space between two intiials
			end
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error ('initials');									-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first);									-- check first and last before restoring the suffix which may have a non-Latin digit
			if is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
			end
		else
			is_good_vanc_name (last, '');
		end
	
			
																				-- this from extract_names ()
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice incase we have a first 1 without a last1
		select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, no, etc).  When the parameter value has not been assigned a value (missing or empty
in the source template) the function refurns true.  If the parameter value is one of the list of allowed values returns
true; else, emits an error message and returns false.

]]

local function is_valid_parameter_value (value, name, possible)
	if not is_set (value) then
		return true;															-- an empty parameter is ok
	elseif in_array(value:lower(), possible) then
		return true;
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list,-1,-1) == sepc) or (string.sub (name_list,-3,-1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terninate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not is_set (volume) and not is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end
	
	local vol = '';
		
	if is_set (volume) then
		if (4 &lt; mw.ustring.len(volume)) then
			vol = substitute (cfg.messages['j-vol'], {sepc, volume});
		else
			vol = wrap_style ('vol-bold', hyphen_to_dash(volume));
		end
	end
	if is_set (issue) then
		return vol .. substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end






--[[-------------------------&lt; N O R M A L I Z E _ P A G E _ L I S T &gt;-----------------------------------------

not currently used

normalizes a comma, ampersand, and/or space separated list to be '&lt;value&gt;, &lt;value&gt;, ..., &lt;value&gt;'
returns list unchanged if there are no commas else strips whitespace and then reformats the list

]]
--[[
local function normalize_page_list (list)
	if not list:find ('[,&amp; ]') then return list end								-- if list is not delimited with commas, ampersands, or spaces; done
	
	list = mw.text.split (list, '[,&amp;%s]+');										-- make a table of values
	list = table.concat (list, ', ');											-- and now make a normalized list
	return list;
end
]]

--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'journal' == origin);

	if is_set (page) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif is_set(pages) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then										-- if pages is only digits, assume a single page number
			return '', substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org urls to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot url or to calendar pages.  When the archive url is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the url.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org url does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command url
	|archive-url= is an archive.org url that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org urls:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this funct may return a modified
archive url:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the url unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.or url
	
	if not url:match('//web%.archive%.org/') then
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command url, we don't want to allow saving of the target page 
		table.insert( z.message_tail, { set_error( 'archive_url', {'save command'}, true ) } );	-- add error message
		if Preview_mode then
			return url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1), date;	-- preview mode: modify and return ArchiveURL and ArchiveDate
		else
			return '', '';														-- return empty strings for archiveURL and ArchiveDate
		end
	end

--	if url:match('//web%.archive%.org/web/%*/') or url:match('//web%.archive%.org/%*/') then	-- wildcard with or without 'web/' path element
--		table.insert( z.message_tail, { set_error( 'archive_url', {'wildcard'}, true ) } );		-- add error message and
--		return '', '';																			-- return empty strings for archiveURL and ArchiveDate
--	end
	
	path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');		-- split out some of the url parts for evaluation
	
	if not is_set(timestamp) or 14 ~= timestamp:len() then								-- path and flag optional, must have 14-digit timestamp here
		err_msg = 'timestamp';
		if '*' ~= flag then
			url=url:gsub ('(//web%.archive%.org/[^%d]*%d?%d?%d?%d?%d?%d?)[^/]*', '%1*', 1)	-- for preview, modify ts to be yearmo* max (0-6 digits plus splat)
		end
	elseif is_set(path) and 'web/' ~= path then									-- older archive urls do not have the extra 'web/' path element
		err_msg = 'path';
	elseif is_set (flag) and not is_set (path) then								-- flag not allowed with the old form url (without the 'web/' path element)
		err_msg = 'flag';
	elseif is_set (flag) and not flag:match ('%a%a_') then						-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
		err_msg = 'flag';
	else
		return url, date;														-- return archiveURL and ArchiveDate
	end
																				-- if here something not right so
	table.insert( z.message_tail, { set_error( 'archive_url', {err_msg}, true ) } );	-- add error message and
	if Preview_mode then
		return url, date;														-- preview mode so return archiveURL and ArchiveDate
	else
		return '', '';															-- return empty strings for archiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe:
	{{cite ... |title=Title access-date=2016-03-17}}

cs1|2 shares some parameter names with xml/html atributes: class=, title=, etc.  To prevent false positives xml/html
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove xml/html tags because attributes: class=, title=, etc 

	capture = value:match ('%s+(%a[%a%d]+)%s*=') or value:match ('^(%a[%a%d]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then								-- if the capture is a valid parameter name
		add_maint_cat ('missing_pipe');
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
		end
		if is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
		end
	end

	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list
	local Contribution = A['Contribution'];
	if in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not is_set (Contribution) then									-- |contributor= requires |contribution=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if select_one (args, cfg.aliases['ContributorList-Last'], 'redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { set_error( 'contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if not is_valid_parameter_value (NameListFormat, 'name-list-format', cfg.keywords['name-list-format']) then			-- only accepted value for this parameter is 'vanc'
		NameListFormat = '';													-- anything else, set to empty string
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
			link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wikimarkup in |title-link= or wikimarkup in |title= when |title-link= is set

	local Chapter = A['Chapter'];
	local ScriptChapter = A['ScriptChapter'];
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];

	local ArchiveDate;
	local ArchiveURL;

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	
	local DeadURL = A['DeadURL']
		if not is_valid_parameter_value (DeadURL, 'dead-url', cfg.keywords ['deadurl']) then	-- set in config.defaults to 'yes'
			DeadURL = '';														-- anything else, set to empty string
		end

	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];
	local Periodical_origin = A:ORIGIN('Periodical');							-- get the name of the periodical parameter

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if in_array (config.CitationClass, cfg.templates_using_volume) and not ('conference' == config.CitationClass and not is_set (Periodical)) then
		Volume = A['Volume'];
	end
	if in_array (config.CitationClass, cfg.templates_using_issue) and not (in_array (config.CitationClass, {'conference', 'map'}) and not is_set (Periodical))then
		Issue = A['Issue'];
	end
	local Position = '';
	if not in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash( A['Pages'] );	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
		if not is_valid_parameter_value (RegistrationRequired, 'registration', cfg.keywords ['yes_true_y']) then
			RegistrationRequired=nil;
		end
	local SubscriptionRequired = A['SubscriptionRequired'];
		if not is_valid_parameter_value (SubscriptionRequired, 'subscription', cfg.keywords ['yes_true_y']) then
			SubscriptionRequired=nil;
		end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local Agency = A['Agency'];

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
		if not is_valid_parameter_value (IgnoreISBN, 'ignore-isbn-error', cfg.keywords ['yes_true_y']) then
			IgnoreISBN = nil;													-- anything else, set to empty string
		end
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
		if not is_valid_parameter_value (LastAuthorAmp, 'last-author-amp', cfg.keywords ['yes_true_y']) then
			LastAuthorAmp = nil;													-- set to empty string
		end
	local no_tracking_cats = A['NoTracking'];
		if not is_valid_parameter_value (no_tracking_cats, 'no-tracking', cfg.keywords ['yes_true_y']) then
			no_tracking_cats = nil;												-- set to empty string
		end

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = A['DF'];															-- date format set in cs1|2 template
	if not is_valid_parameter_value (DF, 'df', cfg.keywords['date-format']) then	-- validate reformatting keyword
		DF = '';																-- not valid, set to empty string
	end

-- set default parameter values defined by |mode= parameter.  If |mode= is empty or omitted, use CitationClass to set these values
	local Mode = A['Mode'];
	if not is_valid_parameter_value (Mode, 'mode', cfg.keywords['mode']) then
		Mode = '';
	end
	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	select_one( args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'redundant_parameters' );		-- this is a dummy call simply to get the error message and category

	local NoPP = A['NoPP'] 
	if is_set (NoPP) and is_valid_parameter_value (NoPP, 'nopp', cfg.keywords ['yes_true_y']) then
		NoPP = true;
	else
		NoPP = nil;																-- unset, used as a flag later
	end

	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Pages = '';															-- unset the others
			At = '';
		end
		extra_text_in_page_check (Page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.
	elseif is_set(Pages) then
		if is_set(At) then
			At = '';															-- unset
		end
		extra_text_in_page_check (Pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped
	|url maps to |chapterurl when |title is remapped

All other combinations of |encyclopedia, |title, and |article are not modified

]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					TransChapter = TransTitle;
					ChapterURL = URL;
					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter= '[[' .. TitleLink .. '|' .. Chapter .. ']]';
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			else																-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if is_set(A['Number']) then													-- cite techreport uses 'number', which other citations alias to 'issue'
			if not is_set(ID) then												-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];													-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', 'id') .. ' and ' .. wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Others) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Others;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Others;
			end
		else
			Others = '(Interview)';
		end
	end

-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	elseif 'mailinglist' == A:ORIGIN('Periodical') then
		Periodical = '';														-- unset because mailing list is only used for cite mailing list
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];

		link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wikimarkup in |series-link= or wikimarkup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) and is_set (AirDate) then							-- promote airdate to date
			Date = AirDate;
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('series', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = '[[' .. ChapterLink .. '|' .. Chapter .. ']]';		-- ok to wikilink
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = '[[' .. ChapterLink .. '|' .. Series .. ']]';			-- series links with ChapterLink (episodelink -&gt; TitleLink -&gt; ChapterLink) ugly
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = '[[' .. SeriesLink .. '|' .. Series .. ']]';
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
-- end of {{cite episode}} stuff

-- Account for the oddities that are {{cite arxiv}}, before generation of COinS data.
	if 'arxiv' == config.CitationClass then
		if not is_set (ID_list['ARXIV']) then									-- |arxiv= or |eprint= required for cite arxiv
			table.insert( z.message_tail, { set_error( 'arxiv_missing', {}, true ) } );		-- add error message
		elseif is_set (Series) then												-- series is an alias of version
			ID_list['ARXIV'] = ID_list['ARXIV'] .. Series;						-- concatenate version onto the end of the arxiv identifier
			Series = '';														-- unset
			deprecated_parameter ('version');									-- deprecated parameter but only for cite arxiv
		end
		
		if first_set ({AccessDate, At, Chapter, Format, Page, Pages, Periodical, PublisherName, URL,	-- a crude list of parameters that are not supported by cite arxiv
			ID_list['ASIN'], ID_list['BIBCODE'], ID_list['DOI'], ID_list['ISBN'], ID_list['ISSN'],
			ID_list['JFM'], ID_list['JSTOR'], ID_list['LCCN'], ID_list['MR'], ID_list['OCLC'], ID_list['OL'],
			ID_list['OSTI'], ID_list['PMC'], ID_list['PMID'], ID_list['RFC'], ID_list['SSRN'], ID_list['USENETID'], ID_list['ZBL']},27) then
				table.insert( z.message_tail, { set_error( 'arxiv_params_not_supported', {}, true ) } );		-- add error message

				AccessDate= '';													-- set these to empty string; not supported in cite arXiv
				PublisherName = '';												-- (if the article has been published, use cite journal, or other)
				Chapter = '';
				URL = '';
				Format = '';
				Page = ''; Pages = ''; At = '';
		end
		Periodical = 'arXiv';													-- set to arXiv for COinS; after that, must be set to empty string
	end

-- handle type parameter for those CS1 citations that have default values
	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
	TitleType = substitute( cfg.messages['type'], TitleType);					-- display it in parentheses
	end

-- legacy: promote concatenation of |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {['access-date']=AccessDate, ['archive-date']=ArchiveDate, ['date']=Date, ['doi-broken-date']=DoiBroken,
				['embargo']=Embargo, ['lay-date']=LayDate, ['publication-date']=PublicationDate, ['year']=Year};

		anchor_year, Embargo, error_message = dates(date_parameters_list, COinS_date);

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end
		
		if not is_set(error_message) then										-- error free dates only
			local modified = false;												-- flag
			if is_set (DF) then													-- if we need to reformat dates
				modified = reformat_dates (date_parameters_list, DF, false);	-- reformat to DF format, use long month names if appropriate
			end

			if true == date_hyphen_to_dash (date_parameters_list) then					-- convert hyphens to dashes where appropriate
				modified = true;
				add_maint_cat ('date_format');									-- hyphens were converted so add maint category
			end
			
			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'];				-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'];
				Date = date_parameters_list['date'];
				DoiBroken = date_parameters_list['doi-broken-date'];
				LayDate = date_parameters_list['lay-date'];
				PublicationDate = date_parameters_list['publication-date'];
			end
		else
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end

--		if is_set(error_message) then
--			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
--		elseif is_set (DF) then
--			if reformat_dates (date_parameters_list, DF, false) then			-- reformat to DF format, use long month names if appropriate
--				AccessDate = date_parameters_list['access-date'];				-- overwrite date holding parameters with reformatted values
--				ArchiveDate = date_parameters_list['archive-date'];
--				Date = date_parameters_list['date'];
--				DoiBroken = date_parameters_list['doi-broken-date'];
--				LayDate = date_parameters_list['lay-date'];
--				PublicationDate = date_parameters_list['publication-date'];
--			end
--		end
	end	-- end of do

-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);											-- 

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
			if 'episode' == config.CitationClass then							-- special case for cite episode; TODO: is there a better way to do this?
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
			else
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
			end
	end
	
	if 'none' == Title and in_array (config.CitationClass, {'journal', 'citation'}) and is_set (Periodical) and 'journal' == A:ORIGIN('Periodical') then	-- special case for journal cites
		Title = '';																-- set title to empty string
		add_maint_cat ('untitled');
	end

	check_for_url ({															-- add error message when any of these parameters contains a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[A:ORIGIN('Periodical')]=Periodical,
		[A:ORIGIN('PublisherName')] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = Periodical,
		['Encyclopedia'] = Encyclopedia,
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

-- Account for the oddities that are {{cite arxiv}}, AFTER generation of COinS data.
	if 'arxiv' == config.CitationClass then										-- we have set rft.jtitle in COinS to arXiv, now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in cite arxiv; if article has been published, use cite journal
	end

-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = substitute (cfg.messages['newsgroup'], external_link( 'news:' .. PublisherName, PublisherName, A:ORIGIN('PublisherName') ));
		end
	end



	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
--		local maximum;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text											-- get current page name so that we don't wikilink to it via editorlinkn
		};

		do																		-- do editor name list first because coauthors can modify control table
			control.maximum , editor_etal = get_display_authors_editors (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if is_set (Editors) then
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
					EditorCount = 2;											-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
				else
					EditorCount = 2;											-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
				end
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do translators
			control.maximum = #t;												-- number of translators
			Translators = list_people(control, t, false);						-- et al not currently supported
		end
		do																		-- now do contributors
			control.maximum = #c;												-- number of contributors
			Contributors = list_people(control, c, false);						-- et al not currently supported
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_authors_editors (A['DisplayAuthors'], #a, 'authors', author_etal);

			if is_set(Coauthors) then											-- if the coauthor field is also used, prevent ampersand and et al. formatting.
				control.lastauthoramp = nil;
				control.maximum = #a + 1;
			end
			
			last_first_list = list_people(control, a, author_etal);

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false);	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if is_set (Authors) and is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

		if not is_set(Authors) and is_set(Coauthors) then						-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
			table.insert( z.message_tail, { set_error('coauthors_missing_author', {}, true) } );	-- emit error message
		end
	end

-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

-- special case for chapter format so no error message or cat when chapter not supported
	if not (in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not is_set(URL) then
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then	-- |url= required for cite web, cite podcast, and cite mailinglist
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURLorigin, OriginalFormat;						-- TODO: swap chapter and title here so that archive applies to most specific if both are set?
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (ChapterURL) then 	-- swapped									-- URL not set so if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURLorigin = ChapterURLorigin;								-- name of chapter-url parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |format=
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				ChapterURLorigin = A:ORIGIN('ArchiveURL')						-- name of archive-url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
			end
		elseif is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURLorigin = URLorigin;										-- name of url parameter for error messages
			OriginalFormat = Format;											-- and original |format=
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
			end
 		end
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'arxiv'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			local chap_param;
			if is_set (Chapter) then											-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif is_set (ScriptChapter) then
				chap_param = A:ORIGIN ('ScriptChapter')
			else is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if is_set (chap_param) then											-- if we found one
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {chap_param}, true ) } );		-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if is_set (Contribution) and 0 &lt; #c then								-- if this is a contribution with contributor(s)
			if in_array (Contribution:lower(), cfg.keywords.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, Chapter, TransChapter, ChapterURL, ChapterURLorigin, no_quotes);		-- Contribution is also in Chapter
		if is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter.. sepc .. ' ';
		elseif is_set (ChapterFormat) then										-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'mailinglist', 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
	
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then
			Title = external_link( URL, Title, URLorigin ) .. TransError .. Format;
-- this experiment hidden 2016-04-10; see Help_talk:Citation_Style_1#Recycled_urls
--			local temp_title = external_link( URL, Title, URLorigin ) .. TransError .. Format;	-- do this so we get error message even if url is usurped no archive
--			if in_array (DeadURL, {'unfit no archive', 'usurped no archive'}) then	-- when url links to inappropriate location and there is no archive of original source available
--				local err_msg
--				if temp_title:match ('%[%S+%s+(.+)%](&lt;.+)') then				-- if there is an error message
--					Title, err_msg = temp_title:match ('%[%S+%s+(.+)%](&lt;.+)');	-- strip off external link; TODO: find a better to do this
--					Title = Title .. (err_msg or '');
--				end
--			else
--				Title = temp_title;
--			end

			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURLorigin );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if is_set(Minutes) then
			if is_set (Time) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'minutes') .. ' and ' .. wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
--		Others = sepc .. ' Translated by ' .. Translators .. Others; 
		Others = sepc .. ' ' .. wrap_msg ('translated', Translators, use_lowercase) .. Others; 
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

--[[
Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
note is displayed. There are no error messages for this condition.

]]
	if is_set (SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif is_set (RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if 'citation', lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text
																				-- neither of these work; don't know why; it seems that substitute() isn't being called	
		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then				-- if first and last characters of quote are quote marks
			Quote = Quote:sub(2,-2);											-- strip them off
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL') ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- DeadURL is empty, 'yes', 'true', 'y', 'unfit', 'usurped'
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if in_array (DeadURL, {'unfit', 'usurped'}) then
				Archived = sepc .. &quot; &quot; .. 'Archived from the original on ' .. ArchiveDate;	-- format already styled
			else																-- DeadURL is empty, 'yes', 'true', or 'y'
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURLorigin ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL') ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL') ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURLorigin );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin );
	end

	local Publisher;
	if is_set(Periodical) and
		not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap_msg ('published', PublicationDate);
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap_msg ('published', PublicationDate) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
			Language, Edition, Publisher, Agency, Volume}, sepc );
		
	elseif in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(Periodical) then		-- special cases for book cites
		if is_set (Contributors) then											-- when we are citing foreword, preface, introduction, etc
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Transcript, Language, Edition, Publisher}, sepc );
	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if is_set(Date) then
		if is_set (Authors) or is_set (Editors) then							-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;;				-- in paranetheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon,-1,-1) == sepc) then							-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigYear;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigYear;							-- Date begins with sepc
			end
		end
	end	
	if is_set(Authors) then
		if is_set(Coauthors) then
			if 'vanc' == NameListFormat then									-- separate authors and coauthors with proper name-list-separator
				Authors = Authors .. ', ' .. Coauthors;
			else
				Authors = Authors .. '; ' .. Coauthors;
			end
		end
		if not is_set (Date) then												-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then in_text = in_text:lower() end				-- lowercase for cs2
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if is_set (Contributors) then											-- book cite and we're citing the intro, preface, etc
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if is_set (Editors) then											-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if not is_set (Date) then											-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = config.CitationClass;
		options.class = &quot;citation &quot; .. config.CitationClass;					-- class=citation required for blue highlight when used with |ref=
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then								-- set reference anchor if appropriate
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			if #namelist &gt; 0 then												-- if there are names in namelist
				id = anchor_id (namelist, year);								-- go make the CITEREF anchor
			else
				id = '';														-- unset
			end
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then													-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		text = substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text});	-- when |ref= is set
	else
		text = substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text});	-- all other cases
	end		

	text = text .. substitute (cfg.presentation['ocins'], {OCinSoutput});		-- append metadata to the citation
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. error_comment( v[1], v[2] );
				else
					text = text .. error_comment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end

	if #z.maintenance_cats ~= 0 then
		text = text .. '&lt;span class=&quot;citation-comment&quot; style=&quot;display:none; color:#33aa33&quot;&gt;';
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. ' ' .. v .. ' ([[:Category:' .. v ..'|link]])';
		end
		text = text .. '&lt;/span&gt;';	-- maintenance mesages (realy just the names of the categories for now)
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

--[[--------------------------&lt; C S 1 . C I T A T I O N &gt;------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

function cs1.citation(frame)
	local pframe = frame:getParent()
	local validation, utilities, identifiers, metadata;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (utilities);								-- so that functions in Date validataion can see the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	dates = validation.dates;													-- imported functions from Module:Citation/CS1/Date validation
	year_date_check = validation.year_date_check;
	reformat_dates = validation.reformat_dates;
	date_hyphen_to_dash = validation.date_hyphen_to_dash;
	
	is_set = utilities.is_set;													-- imported functions from Module:Citation/CS1/Utilities
	in_array = utilities.in_array;
	substitute = utilities.substitute;
	error_comment = utilities.error_comment;
	set_error = utilities.set_error;
	select_one = utilities.select_one;
	add_maint_cat = utilities.add_maint_cat;
	wrap_style = utilities.wrap_style;
	safe_for_italics = utilities.safe_for_italics;
	remove_wiki_link = utilities.remove_wiki_link;

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	extract_ids = identifiers.extract_ids;										-- imported functions from Module:Citation/CS1/Utilities
	build_id_list = identifiers.build_id_list;
	is_embargoed = identifiers.is_embargoed;
	
	make_coins_title = metadata.make_coins_title;								-- imported functions from Module:Citation/CS1/COinS
	get_coins_pages = metadata.get_coins_pages;
	COinS = metadata.COinS;

	
	Preview_mode = frame:preprocess('{{REVISIONID}}');							-- use magic word to get revision id
	if is_set (Preview_mode) then												-- if there is a value then this is not a preiview
		Preview_mode = false;
	else
		Preview_mode = true;													-- no value (nil or empty string) so this is a preview
	end
	
	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute( param, capture );				-- add the capture to the suggested parameter (typically the enumerator)
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, param}, true );	-- set the error message
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			missing_pipe_check (v);												-- do we think that there is a parameter that is missing a pipe?
			
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);
		end
	end
	return citation0( config, args)
end

return cs1;</text>
      <sha1>3htqnmev3c8azos369wufap3kf85n00</sha1>
    </revision>
    <revision>
      <id>4711</id>
      <parentid>4710</parentid>
      <timestamp>2016-06-06T00:33:10Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>try again; vauthors generational suffix fix;</comment>
      <origin>4711</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="153301" sha1="pinu69tg9rzox8evpj9osvxn3njoyww" xml:space="preserve">
local cs1 ={};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local dates, year_date_check, reformat_dates, date_hyphen_to_dash				-- functions in Module:Citation/CS1/Date_validation

local is_set, in_array, substitute, error_comment, set_error, select_one,		-- functions in Module:Citation/CS1/Utilities
	add_maint_cat, wrap_style, safe_for_italics, remove_wiki_link;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local extract_ids, build_id_list, is_embargoed;									-- functions in Module:Citation/CS1/Identifiers

local make_coins_title, get_coins_pages, COinS;									-- functions in Module:Citation/CS1/COinS

local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

delare variables here that have page-wide scope

]]

local Preview_mode = false;														-- flag indicating that we are rendering a preview page (Show preview button)

--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end

--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

]]

local added_prop_cats = {}														-- list of property categories that have been added to z.properties_cats
local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));		-- make name then add to table
	end
end

--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

]]

local added_vanc_errs;															-- flag so we only emit one Vancouver error / category
local function add_vanc_error (source)
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {source}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a uri scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of tlds: https://www.iana.org/domains/root/db

rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the tld.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a url with a scheme) will be stripped
here.  Perhaps not necessary but retained incase it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ascii characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the tld) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org TLD
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and tld or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%a%d]') then										-- first character must be letter or digit
		return false;
	end
																				-- Do most common case first
	if domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.%a%a+$') then				-- three or more character hostname.hostname or hostname.tld
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.xn%-%-[%a%d]+$') then	-- internationalized domain name with ACE prefix
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.org$') then							-- one character .org hostname
		return true;
	elseif domain:match ('%f[%a][qxz]%.com$') then								-- assigned one character .com hostname (x.com times out 2015-12-10)
		return true;
	elseif domain:match ('%f[%a][iq]%.net$') then								-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.%a%a$') then							-- one character hostname and cctld (2 chars)
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d]%.%a%a+$') then					-- two character hostname and tld
		return true;
	elseif domain:match ('^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?') then		-- IPv4 address
		return true;
	else
		return false;
	end
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a url appear to be a valid url; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if is_set (scheme) then														-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when url is protocol relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a url into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following tld) (if any) and any path(/), query(?) or fragment(#).

If protocol relative url, return nil scheme and domain else return nil for both scheme and domain.

When not protocol relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol relative url
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		authority = authority:gsub ('//', '', 1);								-- replace place 1 pair of '/' with nothing;
		if is_set(authority) then												-- if anything left (1 or 3+ '/' where authority should be) then
			return scheme;														-- return scheme only making domain nil which will cause an error message
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link= etc for properly formatted content: no wikilinks, no urls

Link parameters are to hold the title of a wikipedia article so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki urls and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid url (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid url (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from url; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid url
end

--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wikilinked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

]]

local function link_title_ok (link, lorig, title, torig)
local orig;

	if is_set (link) then 														-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		end
	end

	if is_set (orig) then
		table.insert( z.message_tail, { set_error( 'bad_paramlink', orig)});	-- url or wikilink in |title= with |title-link=;
	end
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the url into scheme and domain
portions, or for protocol relative (//example.com) urls, just the domain.  Use is_url() to validate the two
portions of the url.  If both are valid, or for protocol relative if domain is valid, return true, else false.

Because it is different from a standard url, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper url
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from url;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a url.  The test will also find external wikilinks
that use protocol relative urls. Also finds bare urls.

The frontier pattern prevents a match on interwiki links which are similar to scheme:path urls.  The tests that
find bracketed urls are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol relative ext wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare url with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol relative bare url: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a url
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then												-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source )
	local error_str = &quot;&quot;;
	local domain;
	local path;
	
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the url into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['[']='%5b',[']']='%5d'});					-- replace '[' and ']' with their percent encoded values
		URL=domain..path;														-- and reassemble
	end
	
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url( label ), &quot;]&quot;, error_str });
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

]]

local page_in_deprecated_cat;													-- sticky flag so that the category is added only once
local function deprecated_parameter(name)
	if not page_in_deprecated_cat then
		page_in_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end

--[[--------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Call this function for chapter titles, for website titles, etc; not for book titles.

]]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	
	cap, cap2 = str:match (&quot;^([\&quot;\'])([^\'].+)&quot;);								-- match leading double or single quote but not double single quotes
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-left'], {cap, cap2});
	end

	cap, cap2 = str:match (&quot;^(.+[^\'])([\&quot;\'])$&quot;)
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-right'], {cap, cap2});
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title= and |script-chapter=

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, cfg.script_lang_codes) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				add_prop_cat ('script')
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return substitute( msg, str );										-- including template text
	else
		return substitute( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (scriptchapter, chapter, transchapter, chapterurl, chapter_url_source, no_quotes)
	local chapter_error = '';
	
	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);										-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
			chapter = wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, scriptchapter)						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (transchapter) then
		transchapter = wrap_style ('trans-quoted-title', transchapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. transchapter;
		else																	-- here when transchapter without chapter or script-chapter
			chapter = transchapter;												-- 
			chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
		end
	end

	if is_set (chapterurl) then
		chapter = external_link (chapterurl, chapter, chapter_url_source);		-- adds bare_url_missing_title error if appropriate
	end

	return chapter .. chapter_error;
end

--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Detects but ignores the character pattern that results from the transclusion of {{'}} templates.

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i=1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- Test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position then
			if 'nowiki' == capture or 'math' == capture then 					-- nowiki, math stripmarker (not an error condition)
				stripmarker = true;												-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { set_error( 'invisible_char', {err_msg, wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i=i+1;																	-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end

--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash

]]

local function hyphen_to_dash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if comp:sub(1,1) == duplicate_char then								-- is first charactier same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for th
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = str:sub(-1,-1);										-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = str:sub(1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = str:sub(1, -4) .. &quot;''&quot;;							-- remove them and add back ''
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then		-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then		-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then			-- if last two chars of str are sepc] external link
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;'']&quot; then		-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then				-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = str:sub(1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end		-- if duplicate_char not a letter then escape it
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )			-- remove duplicate_char if it follows html markup
					else
						value = value:sub( 2, -1 );								-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end  


--[[--------------------------&lt; I S _ S U F F I X &gt;------------------------------------------------------------

returns true is suffix is properly formed Jr, Sr, or ordinal in the range 2–9.  Puncutation not allowed.

]]

local function is_suffix (suffix)
	if in_array (suffix, {'Jr', 'Sr', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end

--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written ouside of the code editor and pasted here because the code editor gets confused between character insertion point and cursor position.
The test has been rewritten to use decimal character escape sequence for the individual bytes of the unicode characters so that it is not necessary
to use an external editor to maintain this code.

	\195\128-\195\150 – À-Ö
	\195\152-\195\182 – Ø-ö
	\195\184-\198\191 – ø-ƿ
	\199\132-\201\143 – Ǆ-ɏ%

]]

local function is_good_vanc_name (last, first)
	local first, suffix = first:match ('(.-),?%s*([%dJS][%drndth]+)%.?$') or first;		-- if first has something that looks like a generational suffix, get it

	if is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error ('suffix');
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error ('non-Latin character');
			return false;														-- not a string of latin characters; Vancouver requires Romanization
	end;
	return true;
end

--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just intials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; name:len() then													-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error ('suffix');									-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word


	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i],1,1));				-- insert the intial at end of initials table
		end
		i = i+1;																-- bump the counter
	end
			
--	for word in mw.ustring.gmatch(first, &quot;[^%s%.%-]+&quot;) do						-- names separated by spaces, hyphens, or periods
--		table.insert(initials, mw.ustring.sub(word,1,1))						-- Vancouver format does not include full stops.
--		i = i + 1;																-- bump the counter 
--		if 2 &lt;= i then break; end												-- only two initials allowed in Vancouver system; if 2, quit
--	end
	return table.concat(initials)												-- Vancouver format does not include spaces.
end

--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = ',';																-- name-list separator between authors is a comma
		namesep = ' ';															-- last/first separator is a space
	else
		sep = ';'																-- name-list separator between authors is a semicolon
		namesep = ', '															-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then					-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first 
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;				-- link author/editor if this page is not the author's/editor's page
				end
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end

--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]
local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of author and editor name parameters for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the parameters |display-authors=etal or |display-editors=etal

]]

local function name_has_etal (name, etal, nocat)

	if is_set (name) then														-- name can be nil in which case just return
		local etal_pattern = &quot;[;,]? *[\&quot;']*%f[%a][Ee][Tt] *[Aa][Ll][%.\&quot;']*$&quot;	-- variations on the 'et al' theme
		local others_pattern = &quot;[;,]? *%f[%a]and [Oo]thers&quot;;					-- and alternate to et al.
		
		if name:match (etal_pattern) then										-- variants on et al.
			name = name:gsub (etal_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		elseif name:match (others_pattern) then									-- if not 'et al.', then 'and others'?
			name = name:gsub (others_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		end
	end
	return name, etal;															-- 
end

--[[--------------------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;----------------------------------------

Evaluates the content of author and editor (surnames only) parameters for multiple names.  Multiple names are
indicated if there is more than one comma and or semicolon.  If found, the function adds the multiple name
(author or editor) maintenance category.

]]

local function name_has_mult_names (name, list_name)
local count, _;
	if is_set (name) then
		if name:match ('^%(%(.*%)%)$') then										-- if wrapped in doubled parentheses, ignore 
			name = name:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			_, count = name:gsub ('[;,]', '');									-- count the number of separator-like characters
			
			if 1 &lt; count then													-- param could be |author= or |editor= so one separactor character is acceptable
				add_maint_cat ('mult_names', list_name:lower());				-- more than one separator indicates multiple names so add a maint cat for this template
			end
		end
	end
	return name;																-- and done
end

--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary
	while true do
		last = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false);							-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false);						-- find and remove variations on et al.
		last = name_has_mult_names (last, err_msg_list_name);					-- check for multiple names in last and its aliases
		
		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			link_title_ok (link, list_name:match (&quot;(%w+)List&quot;):lower() .. '-link' .. i, last, list_name:match (&quot;(%w+)List&quot;):lower() .. '-last' .. i);	-- check for improper wikimarkup

			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because case of the source may be incorrect
or different from the case that WikiMedia uses, the name comparisons are done in lower case and when a match is
found, the Wikimedia version (assumed to be correct) is returned along with the code.  When there is no match, we
return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') return a list of languages that in some cases may include
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.

Names but that are included in the list will be found if that name is provided in the |language= parameter.  For example,
if |language=Chavacano de Zamboanga, that name will be found with the associated code 'cbk-zam'.  When names are found
and the associated code is not two or three characters, this function returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	local languages = mw.language.fetchLanguageNames(this_wiki_code, 'all')		-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() and 3 ~= code:len() then							-- two- or three-character codes only; extensions not supported
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the the code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for the code
end

--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code is recognized by MediaWiki,
use the returned name; if not, then use the value that was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is assigned to the category for
that code: Category:Norwegian-language sources (no).  For valid three-character code languages, the page is assigned
to the single category for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does not recognize three-character
equivalents of two-character codes: code 'ar' is recognized bit code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are
separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki = mw.getContentLanguage();									-- get a language object for this wiki
	local this_wiki_code = this_wiki:getCode()									-- get this wiki's language code
	local this_wiki_name = mw.language.fetchLanguageName(this_wiki_code, this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang

		if lang:match ('^%a%a%-') then											-- strip ietf language tags from code; TODO: is there a need to support 3-char with tag?
			lang = lang:match ('(%a%a)%-')										-- keep only 639-1 code portion to lang; TODO: do something with 3166 alpha 2 country code?
		end
		if 2 == lang:len() or 3 == lang:len() then								-- if two-or three-character code
			name = mw.language.fetchLanguageName( lang:lower(), this_wiki_code);	-- get language name if |language= is a proper code
		end
	
		if is_set (name) then													-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, this_wiki_code);				-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then													-- only 2- or 3-character codes
			if this_wiki_code ~= code then										-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					add_prop_cat ('foreign_lang_source', {name, code})			-- categorize it
				else															-- or is a recognized language (but has a three-character code)
					add_prop_cat ('foreign_lang_source_2', {code})				-- categorize it differently TODO: support mutliple three-character code categories per cs1|2 template
				end
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, ' and ')							-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		language_list[code] = 'and ' .. language_list[code];					-- prepend last name with 'and&lt;space&gt;'
		name = table.concat (language_list, ', ')								-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
	end
	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
end

--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = '.';																-- terminate the rendered citation with a period
	end
	return '.', ps;																-- separator is a full stop
end

--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = '';																-- make sure it isn't nil
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return ',', ps, ref;														-- separator is a comma
end

--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end

--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extension, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf[%?#]?') or url:match ('%.PDF[%?#]?');
end

--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parenthases, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end

--[[--------------------------&lt; G E T _ D I S P L A Y _ A U T H O R S _ E D I T O R S &gt;------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_authors_editors (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_auth_ed', list_name);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end

--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
--	local good_pattern = '^P[^%.P%l]';
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
--	local bad_pattern = '^[Pp][Pp]';
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
--		if Page:match ('^[Pp]?[Pp]%.?[ %d]') or  Page:match ('^[Pp]ages?[ %d]') or
--			Pages:match ('^[Pp]?[Pp]%.?[ %d]') or  Pages:match ('^[Pp]ages?[ %d]') then
--				add_maint_cat ('extra_text');
--		end
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	if vparam:find ('%[%[') or vparam:find ('%]%]')	then						-- no wikilinking vauthors names
		add_vanc_error ('wikilink');
	end
	v_name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;)								-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parentheses to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')								-- remove doubled parntheses
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error ('punctuation');
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
			if is_suffix (first) then											-- if a valid suffix
				suffix = first													-- save it as a suffix and
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end																	-- no suffix error message here because letter combination may be result of Romanization; check for digits?
			last = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error ('missing comma');								-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error ('name');										-- matches a space between two intiials
			end
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error ('initials');									-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first);									-- check first and last before restoring the suffix which may have a non-Latin digit
			if is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			is_good_vanc_name (last, '');
		end
	
			
																				-- this from extract_names ()
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice incase we have a first 1 without a last1
		select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, no, etc).  When the parameter value has not been assigned a value (missing or empty
in the source template) the function refurns true.  If the parameter value is one of the list of allowed values returns
true; else, emits an error message and returns false.

]]

local function is_valid_parameter_value (value, name, possible)
	if not is_set (value) then
		return true;															-- an empty parameter is ok
	elseif in_array(value:lower(), possible) then
		return true;
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list,-1,-1) == sepc) or (string.sub (name_list,-3,-1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terninate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not is_set (volume) and not is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end
	
	local vol = '';
		
	if is_set (volume) then
		if (4 &lt; mw.ustring.len(volume)) then
			vol = substitute (cfg.messages['j-vol'], {sepc, volume});
		else
			vol = wrap_style ('vol-bold', hyphen_to_dash(volume));
		end
	end
	if is_set (issue) then
		return vol .. substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end






--[[-------------------------&lt; N O R M A L I Z E _ P A G E _ L I S T &gt;-----------------------------------------

not currently used

normalizes a comma, ampersand, and/or space separated list to be '&lt;value&gt;, &lt;value&gt;, ..., &lt;value&gt;'
returns list unchanged if there are no commas else strips whitespace and then reformats the list

]]
--[[
local function normalize_page_list (list)
	if not list:find ('[,&amp; ]') then return list end								-- if list is not delimited with commas, ampersands, or spaces; done
	
	list = mw.text.split (list, '[,&amp;%s]+');										-- make a table of values
	list = table.concat (list, ', ');											-- and now make a normalized list
	return list;
end
]]

--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'journal' == origin);

	if is_set (page) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif is_set(pages) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then										-- if pages is only digits, assume a single page number
			return '', substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org urls to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot url or to calendar pages.  When the archive url is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the url.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org url does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command url
	|archive-url= is an archive.org url that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org urls:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this funct may return a modified
archive url:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the url unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.or url
	
	if not url:match('//web%.archive%.org/') then
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command url, we don't want to allow saving of the target page 
		table.insert( z.message_tail, { set_error( 'archive_url', {'save command'}, true ) } );	-- add error message
		if Preview_mode then
			return url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1), date;	-- preview mode: modify and return ArchiveURL and ArchiveDate
		else
			return '', '';														-- return empty strings for archiveURL and ArchiveDate
		end
	end

--	if url:match('//web%.archive%.org/web/%*/') or url:match('//web%.archive%.org/%*/') then	-- wildcard with or without 'web/' path element
--		table.insert( z.message_tail, { set_error( 'archive_url', {'wildcard'}, true ) } );		-- add error message and
--		return '', '';																			-- return empty strings for archiveURL and ArchiveDate
--	end
	
	path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');		-- split out some of the url parts for evaluation
	
	if not is_set(timestamp) or 14 ~= timestamp:len() then								-- path and flag optional, must have 14-digit timestamp here
		err_msg = 'timestamp';
		if '*' ~= flag then
			url=url:gsub ('(//web%.archive%.org/[^%d]*%d?%d?%d?%d?%d?%d?)[^/]*', '%1*', 1)	-- for preview, modify ts to be yearmo* max (0-6 digits plus splat)
		end
	elseif is_set(path) and 'web/' ~= path then									-- older archive urls do not have the extra 'web/' path element
		err_msg = 'path';
	elseif is_set (flag) and not is_set (path) then								-- flag not allowed with the old form url (without the 'web/' path element)
		err_msg = 'flag';
	elseif is_set (flag) and not flag:match ('%a%a_') then						-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
		err_msg = 'flag';
	else
		return url, date;														-- return archiveURL and ArchiveDate
	end
																				-- if here something not right so
	table.insert( z.message_tail, { set_error( 'archive_url', {err_msg}, true ) } );	-- add error message and
	if Preview_mode then
		return url, date;														-- preview mode so return archiveURL and ArchiveDate
	else
		return '', '';															-- return empty strings for archiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe:
	{{cite ... |title=Title access-date=2016-03-17}}

cs1|2 shares some parameter names with xml/html atributes: class=, title=, etc.  To prevent false positives xml/html
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove xml/html tags because attributes: class=, title=, etc 

	capture = value:match ('%s+(%a[%a%d]+)%s*=') or value:match ('^(%a[%a%d]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then								-- if the capture is a valid parameter name
		add_maint_cat ('missing_pipe');
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
		end
		if is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
		end
	end

	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list
	local Contribution = A['Contribution'];
	if in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not is_set (Contribution) then									-- |contributor= requires |contribution=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if select_one (args, cfg.aliases['ContributorList-Last'], 'redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { set_error( 'contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if not is_valid_parameter_value (NameListFormat, 'name-list-format', cfg.keywords['name-list-format']) then			-- only accepted value for this parameter is 'vanc'
		NameListFormat = '';													-- anything else, set to empty string
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
			link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wikimarkup in |title-link= or wikimarkup in |title= when |title-link= is set

	local Chapter = A['Chapter'];
	local ScriptChapter = A['ScriptChapter'];
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];

	local ArchiveDate;
	local ArchiveURL;

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	
	local DeadURL = A['DeadURL']
		if not is_valid_parameter_value (DeadURL, 'dead-url', cfg.keywords ['deadurl']) then	-- set in config.defaults to 'yes'
			DeadURL = '';														-- anything else, set to empty string
		end

	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];
	local Periodical_origin = A:ORIGIN('Periodical');							-- get the name of the periodical parameter

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if in_array (config.CitationClass, cfg.templates_using_volume) and not ('conference' == config.CitationClass and not is_set (Periodical)) then
		Volume = A['Volume'];
	end
	if in_array (config.CitationClass, cfg.templates_using_issue) and not (in_array (config.CitationClass, {'conference', 'map'}) and not is_set (Periodical))then
		Issue = A['Issue'];
	end
	local Position = '';
	if not in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash( A['Pages'] );	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
		if not is_valid_parameter_value (RegistrationRequired, 'registration', cfg.keywords ['yes_true_y']) then
			RegistrationRequired=nil;
		end
	local SubscriptionRequired = A['SubscriptionRequired'];
		if not is_valid_parameter_value (SubscriptionRequired, 'subscription', cfg.keywords ['yes_true_y']) then
			SubscriptionRequired=nil;
		end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local Agency = A['Agency'];

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
		if not is_valid_parameter_value (IgnoreISBN, 'ignore-isbn-error', cfg.keywords ['yes_true_y']) then
			IgnoreISBN = nil;													-- anything else, set to empty string
		end
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
		if not is_valid_parameter_value (LastAuthorAmp, 'last-author-amp', cfg.keywords ['yes_true_y']) then
			LastAuthorAmp = nil;													-- set to empty string
		end
	local no_tracking_cats = A['NoTracking'];
		if not is_valid_parameter_value (no_tracking_cats, 'no-tracking', cfg.keywords ['yes_true_y']) then
			no_tracking_cats = nil;												-- set to empty string
		end

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = A['DF'];															-- date format set in cs1|2 template
	if not is_valid_parameter_value (DF, 'df', cfg.keywords['date-format']) then	-- validate reformatting keyword
		DF = '';																-- not valid, set to empty string
	end

-- set default parameter values defined by |mode= parameter.  If |mode= is empty or omitted, use CitationClass to set these values
	local Mode = A['Mode'];
	if not is_valid_parameter_value (Mode, 'mode', cfg.keywords['mode']) then
		Mode = '';
	end
	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	select_one( args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'redundant_parameters' );		-- this is a dummy call simply to get the error message and category

	local NoPP = A['NoPP'] 
	if is_set (NoPP) and is_valid_parameter_value (NoPP, 'nopp', cfg.keywords ['yes_true_y']) then
		NoPP = true;
	else
		NoPP = nil;																-- unset, used as a flag later
	end

	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Pages = '';															-- unset the others
			At = '';
		end
		extra_text_in_page_check (Page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.
	elseif is_set(Pages) then
		if is_set(At) then
			At = '';															-- unset
		end
		extra_text_in_page_check (Pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped
	|url maps to |chapterurl when |title is remapped

All other combinations of |encyclopedia, |title, and |article are not modified

]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					TransChapter = TransTitle;
					ChapterURL = URL;
					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter= '[[' .. TitleLink .. '|' .. Chapter .. ']]';
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			else																-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if is_set(A['Number']) then													-- cite techreport uses 'number', which other citations alias to 'issue'
			if not is_set(ID) then												-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];													-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', 'id') .. ' and ' .. wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

-- special case for cite interview
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Others) then
			if is_set(TitleType) then
				Others = ' ' .. TitleType .. ' with ' .. Others;
				TitleType = '';
			else
				Others = ' ' .. 'Interview with ' .. Others;
			end
		else
			Others = '(Interview)';
		end
	end

-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	elseif 'mailinglist' == A:ORIGIN('Periodical') then
		Periodical = '';														-- unset because mailing list is only used for cite mailing list
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];

		link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wikimarkup in |series-link= or wikimarkup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) and is_set (AirDate) then							-- promote airdate to date
			Date = AirDate;
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('series', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = '[[' .. ChapterLink .. '|' .. Chapter .. ']]';		-- ok to wikilink
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = '[[' .. ChapterLink .. '|' .. Series .. ']]';			-- series links with ChapterLink (episodelink -&gt; TitleLink -&gt; ChapterLink) ugly
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = '[[' .. SeriesLink .. '|' .. Series .. ']]';
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
-- end of {{cite episode}} stuff

-- Account for the oddities that are {{cite arxiv}}, before generation of COinS data.
	if 'arxiv' == config.CitationClass then
		if not is_set (ID_list['ARXIV']) then									-- |arxiv= or |eprint= required for cite arxiv
			table.insert( z.message_tail, { set_error( 'arxiv_missing', {}, true ) } );		-- add error message
		elseif is_set (Series) then												-- series is an alias of version
			ID_list['ARXIV'] = ID_list['ARXIV'] .. Series;						-- concatenate version onto the end of the arxiv identifier
			Series = '';														-- unset
			deprecated_parameter ('version');									-- deprecated parameter but only for cite arxiv
		end
		
		if first_set ({AccessDate, At, Chapter, Format, Page, Pages, Periodical, PublisherName, URL,	-- a crude list of parameters that are not supported by cite arxiv
			ID_list['ASIN'], ID_list['BIBCODE'], ID_list['DOI'], ID_list['ISBN'], ID_list['ISSN'],
			ID_list['JFM'], ID_list['JSTOR'], ID_list['LCCN'], ID_list['MR'], ID_list['OCLC'], ID_list['OL'],
			ID_list['OSTI'], ID_list['PMC'], ID_list['PMID'], ID_list['RFC'], ID_list['SSRN'], ID_list['USENETID'], ID_list['ZBL']},27) then
				table.insert( z.message_tail, { set_error( 'arxiv_params_not_supported', {}, true ) } );		-- add error message

				AccessDate= '';													-- set these to empty string; not supported in cite arXiv
				PublisherName = '';												-- (if the article has been published, use cite journal, or other)
				Chapter = '';
				URL = '';
				Format = '';
				Page = ''; Pages = ''; At = '';
		end
		Periodical = 'arXiv';													-- set to arXiv for COinS; after that, must be set to empty string
	end

-- handle type parameter for those CS1 citations that have default values
	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. &quot; thesis&quot;;
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
	TitleType = substitute( cfg.messages['type'], TitleType);					-- display it in parentheses
	end

-- legacy: promote concatenation of |month=, and |year= to Date if Date not set; or, promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {['access-date']=AccessDate, ['archive-date']=ArchiveDate, ['date']=Date, ['doi-broken-date']=DoiBroken,
				['embargo']=Embargo, ['lay-date']=LayDate, ['publication-date']=PublicationDate, ['year']=Year};

		anchor_year, Embargo, error_message = dates(date_parameters_list, COinS_date);

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end
		
		if not is_set(error_message) then										-- error free dates only
			local modified = false;												-- flag
			if is_set (DF) then													-- if we need to reformat dates
				modified = reformat_dates (date_parameters_list, DF, false);	-- reformat to DF format, use long month names if appropriate
			end

			if true == date_hyphen_to_dash (date_parameters_list) then					-- convert hyphens to dashes where appropriate
				modified = true;
				add_maint_cat ('date_format');									-- hyphens were converted so add maint category
			end
			
			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'];				-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'];
				Date = date_parameters_list['date'];
				DoiBroken = date_parameters_list['doi-broken-date'];
				LayDate = date_parameters_list['lay-date'];
				PublicationDate = date_parameters_list['publication-date'];
			end
		else
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end

--		if is_set(error_message) then
--			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
--		elseif is_set (DF) then
--			if reformat_dates (date_parameters_list, DF, false) then			-- reformat to DF format, use long month names if appropriate
--				AccessDate = date_parameters_list['access-date'];				-- overwrite date holding parameters with reformatted values
--				ArchiveDate = date_parameters_list['archive-date'];
--				Date = date_parameters_list['date'];
--				DoiBroken = date_parameters_list['doi-broken-date'];
--				LayDate = date_parameters_list['lay-date'];
--				PublicationDate = date_parameters_list['publication-date'];
--			end
--		end
	end	-- end of do

-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);											-- 

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
		end
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
			if 'episode' == config.CitationClass then							-- special case for cite episode; TODO: is there a better way to do this?
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
			else
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
			end
	end
	
	if 'none' == Title and in_array (config.CitationClass, {'journal', 'citation'}) and is_set (Periodical) and 'journal' == A:ORIGIN('Periodical') then	-- special case for journal cites
		Title = '';																-- set title to empty string
		add_maint_cat ('untitled');
	end

	check_for_url ({															-- add error message when any of these parameters contains a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[A:ORIGIN('Periodical')]=Periodical,
		[A:ORIGIN('PublisherName')] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = Periodical,
		['Encyclopedia'] = Encyclopedia,
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

-- Account for the oddities that are {{cite arxiv}}, AFTER generation of COinS data.
	if 'arxiv' == config.CitationClass then										-- we have set rft.jtitle in COinS to arXiv, now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in cite arxiv; if article has been published, use cite journal
	end

-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = substitute (cfg.messages['newsgroup'], external_link( 'news:' .. PublisherName, PublisherName, A:ORIGIN('PublisherName') ));
		end
	end



	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
--		local maximum;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text											-- get current page name so that we don't wikilink to it via editorlinkn
		};

		do																		-- do editor name list first because coauthors can modify control table
			control.maximum , editor_etal = get_display_authors_editors (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if is_set (Editors) then
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
					EditorCount = 2;											-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
				else
					EditorCount = 2;											-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
				end
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do translators
			control.maximum = #t;												-- number of translators
			Translators = list_people(control, t, false);						-- et al not currently supported
		end
		do																		-- now do contributors
			control.maximum = #c;												-- number of contributors
			Contributors = list_people(control, c, false);						-- et al not currently supported
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_authors_editors (A['DisplayAuthors'], #a, 'authors', author_etal);

			if is_set(Coauthors) then											-- if the coauthor field is also used, prevent ampersand and et al. formatting.
				control.lastauthoramp = nil;
				control.maximum = #a + 1;
			end
			
			last_first_list = list_people(control, a, author_etal);

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false);	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if is_set (Authors) and is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

		if not is_set(Authors) and is_set(Coauthors) then						-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
			table.insert( z.message_tail, { set_error('coauthors_missing_author', {}, true) } );	-- emit error message
		end
	end

-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

-- special case for chapter format so no error message or cat when chapter not supported
	if not (in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not is_set(URL) then
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then	-- |url= required for cite web, cite podcast, and cite mailinglist
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURLorigin, OriginalFormat;						-- TODO: swap chapter and title here so that archive applies to most specific if both are set?
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (ChapterURL) then 	-- swapped									-- URL not set so if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURLorigin = ChapterURLorigin;								-- name of chapter-url parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |format=
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				ChapterURLorigin = A:ORIGIN('ArchiveURL')						-- name of archive-url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
			end
		elseif is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURLorigin = URLorigin;										-- name of url parameter for error messages
			OriginalFormat = Format;											-- and original |format=
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
			end
 		end
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'arxiv'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			local chap_param;
			if is_set (Chapter) then											-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif is_set (ScriptChapter) then
				chap_param = A:ORIGIN ('ScriptChapter')
			else is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if is_set (chap_param) then											-- if we found one
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {chap_param}, true ) } );		-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if is_set (Contribution) and 0 &lt; #c then								-- if this is a contribution with contributor(s)
			if in_array (Contribution:lower(), cfg.keywords.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, Chapter, TransChapter, ChapterURL, ChapterURLorigin, no_quotes);		-- Contribution is also in Chapter
		if is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter.. sepc .. ' ';
		elseif is_set (ChapterFormat) then										-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'mailinglist', 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
	
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then
			Title = external_link( URL, Title, URLorigin ) .. TransError .. Format;
-- this experiment hidden 2016-04-10; see Help_talk:Citation_Style_1#Recycled_urls
--			local temp_title = external_link( URL, Title, URLorigin ) .. TransError .. Format;	-- do this so we get error message even if url is usurped no archive
--			if in_array (DeadURL, {'unfit no archive', 'usurped no archive'}) then	-- when url links to inappropriate location and there is no archive of original source available
--				local err_msg
--				if temp_title:match ('%[%S+%s+(.+)%](&lt;.+)') then				-- if there is an error message
--					Title, err_msg = temp_title:match ('%[%S+%s+(.+)%](&lt;.+)');	-- strip off external link; TODO: find a better to do this
--					Title = Title .. (err_msg or '');
--				end
--			else
--				Title = temp_title;
--			end

			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURLorigin );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if is_set(Minutes) then
			if is_set (Time) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'minutes') .. ' and ' .. wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
--		Others = sepc .. ' Translated by ' .. Translators .. Others; 
		Others = sepc .. ' ' .. wrap_msg ('translated', Translators, use_lowercase) .. Others; 
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

--[[
Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
note is displayed. There are no error messages for this condition.

]]
	if is_set (SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif is_set (RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if 'citation', lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text
																				-- neither of these work; don't know why; it seems that substitute() isn't being called	
		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then				-- if first and last characters of quote are quote marks
			Quote = Quote:sub(2,-2);											-- strip them off
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL') ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- DeadURL is empty, 'yes', 'true', 'y', 'unfit', 'usurped'
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if in_array (DeadURL, {'unfit', 'usurped'}) then
				Archived = sepc .. &quot; &quot; .. 'Archived from the original on ' .. ArchiveDate;	-- format already styled
			else																-- DeadURL is empty, 'yes', 'true', or 'y'
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURLorigin ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL') ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL') ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURLorigin );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin );
	end

	local Publisher;
	if is_set(Periodical) and
		not in_array(config.CitationClass, {&quot;encyclopaedia&quot;,&quot;web&quot;,&quot;pressrelease&quot;,&quot;podcast&quot;}) then
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = PublicationPlace .. &quot;: &quot; .. PublisherName;
			else
				Publisher = PublisherName;  
			end
		elseif is_set(PublicationPlace) then
			Publisher= PublicationPlace;
		else 
			Publisher = &quot;&quot;;
		end
		if is_set(PublicationDate) then
			if is_set(Publisher) then
				Publisher = Publisher .. &quot;, &quot; .. wrap_msg ('published', PublicationDate);
			else
				Publisher = PublicationDate;
			end
		end
		if is_set(Publisher) then
			Publisher = &quot; (&quot; .. Publisher .. &quot;)&quot;;
		end
	else
		if is_set(PublicationDate) then
			PublicationDate = &quot; (&quot; .. wrap_msg ('published', PublicationDate) .. &quot;)&quot;;
		end
		if is_set(PublisherName) then
			if is_set(PublicationPlace) then
				Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
			else
				Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
			end			
		elseif is_set(PublicationPlace) then 
			Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
		else 
			Publisher = PublicationDate;
		end
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
			Language, Edition, Publisher, Agency, Volume}, sepc );
		
	elseif in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(Periodical) then		-- special cases for book cites
		if is_set (Contributors) then											-- when we are citing foreword, preface, introduction, etc
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Transcript, Language, Edition, Publisher}, sepc );
	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if is_set(Date) then
		if is_set (Authors) or is_set (Editors) then							-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;;				-- in paranetheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon,-1,-1) == sepc) then							-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigYear;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigYear;							-- Date begins with sepc
			end
		end
	end	
	if is_set(Authors) then
		if is_set(Coauthors) then
			if 'vanc' == NameListFormat then									-- separate authors and coauthors with proper name-list-separator
				Authors = Authors .. ', ' .. Coauthors;
			else
				Authors = Authors .. '; ' .. Coauthors;
			end
		end
		if not is_set (Date) then												-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then in_text = in_text:lower() end				-- lowercase for cs2
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if is_set (Contributors) then											-- book cite and we're citing the intro, preface, etc
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if is_set (Editors) then											-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if not is_set (Date) then											-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = config.CitationClass;
		options.class = &quot;citation &quot; .. config.CitationClass;					-- class=citation required for blue highlight when used with |ref=
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then								-- set reference anchor if appropriate
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			if #namelist &gt; 0 then												-- if there are names in namelist
				id = anchor_id (namelist, year);								-- go make the CITEREF anchor
			else
				id = '';														-- unset
			end
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then													-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		text = substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text});	-- when |ref= is set
	else
		text = substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text});	-- all other cases
	end		

	text = text .. substitute (cfg.presentation['ocins'], {OCinSoutput});		-- append metadata to the citation
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. error_comment( v[1], v[2] );
				else
					text = text .. error_comment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end

	if #z.maintenance_cats ~= 0 then
		text = text .. '&lt;span class=&quot;citation-comment&quot; style=&quot;display:none; color:#33aa33&quot;&gt;';
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. ' ' .. v .. ' ([[:Category:' .. v ..'|link]])';
		end
		text = text .. '&lt;/span&gt;';	-- maintenance mesages (realy just the names of the categories for now)
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

--[[--------------------------&lt; C S 1 . C I T A T I O N &gt;------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

function cs1.citation(frame)
	local pframe = frame:getParent()
	local validation, utilities, identifiers, metadata;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (utilities);								-- so that functions in Date validataion can see the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	dates = validation.dates;													-- imported functions from Module:Citation/CS1/Date validation
	year_date_check = validation.year_date_check;
	reformat_dates = validation.reformat_dates;
	date_hyphen_to_dash = validation.date_hyphen_to_dash;
	
	is_set = utilities.is_set;													-- imported functions from Module:Citation/CS1/Utilities
	in_array = utilities.in_array;
	substitute = utilities.substitute;
	error_comment = utilities.error_comment;
	set_error = utilities.set_error;
	select_one = utilities.select_one;
	add_maint_cat = utilities.add_maint_cat;
	wrap_style = utilities.wrap_style;
	safe_for_italics = utilities.safe_for_italics;
	remove_wiki_link = utilities.remove_wiki_link;

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	extract_ids = identifiers.extract_ids;										-- imported functions from Module:Citation/CS1/Utilities
	build_id_list = identifiers.build_id_list;
	is_embargoed = identifiers.is_embargoed;
	
	make_coins_title = metadata.make_coins_title;								-- imported functions from Module:Citation/CS1/COinS
	get_coins_pages = metadata.get_coins_pages;
	COinS = metadata.COinS;

	
	Preview_mode = frame:preprocess('{{REVISIONID}}');							-- use magic word to get revision id
	if is_set (Preview_mode) then												-- if there is a value then this is not a preiview
		Preview_mode = false;
	else
		Preview_mode = true;													-- no value (nil or empty string) so this is a preview
	end
	
	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute( param, capture );				-- add the capture to the suggested parameter (typically the enumerator)
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, param}, true );	-- set the error message
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			missing_pipe_check (v);												-- do we think that there is a parameter that is missing a pipe?
			
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);
		end
	end
	return citation0( config, args)
end

return cs1;</text>
      <sha1>pinu69tg9rzox8evpj9osvxn3njoyww</sha1>
    </revision>
    <revision>
      <id>4712</id>
      <parentid>4711</parentid>
      <timestamp>2016-07-30T09:55:17Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4712</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="154117" sha1="c94piag8birnfkfjjy0153fsnarorn1" xml:space="preserve">
local cs1 ={};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local dates, year_date_check, reformat_dates, date_hyphen_to_dash				-- functions in Module:Citation/CS1/Date_validation

local is_set, in_array, substitute, error_comment, set_error, select_one,		-- functions in Module:Citation/CS1/Utilities
	add_maint_cat, wrap_style, safe_for_italics, remove_wiki_link;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local extract_ids, build_id_list, is_embargoed;									-- functions in Module:Citation/CS1/Identifiers

local make_coins_title, get_coins_pages, COinS;									-- functions in Module:Citation/CS1/COinS

local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

delare variables here that have page-wide scope that are not brought in from other modules; thatare created here
and used here

]]

local added_deprecated_cat;														-- boolean flag so that the category is added only once
local added_prop_cats = {};														-- list of property categories that have been added to z.properties_cats
local added_vanc_errs;															-- boolean flag so we only emit one Vancouver error / category

local Frame;																	-- holds the module's frame table


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end

--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

added_prop_cats is a table declared in page scope variables above

]]

local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));		-- make name then add to table
	end
end

--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a boolean declared in page scope variables above

]]

local function add_vanc_error (source)
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {source}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a uri scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of tlds: https://www.iana.org/domains/root/db

rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the tld.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a url with a scheme) will be stripped
here.  Perhaps not necessary but retained incase it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ascii characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the tld) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org TLD
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and tld or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%a%d]') then										-- first character must be letter or digit
		return false;
	end
																				-- Do most common case first
	if domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.%a%a+$') then				-- three or more character hostname.hostname or hostname.tld
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.xn%-%-[%a%d]+$') then	-- internationalized domain name with ACE prefix
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.org$') then							-- one character .org hostname
		return true;
	elseif domain:match ('%f[%a][qxz]%.com$') then								-- assigned one character .com hostname (x.com times out 2015-12-10)
		return true;
	elseif domain:match ('%f[%a][iq]%.net$') then								-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.%a%a$') then							-- one character hostname and cctld (2 chars)
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d]%.%a%a+$') then					-- two character hostname and tld
		return true;
	elseif domain:match ('^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?') then		-- IPv4 address
		return true;
	else
		return false;
	end
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a url appear to be a valid url; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if is_set (scheme) then														-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when url is protocol relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a url into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following tld) (if any) and any path(/), query(?) or fragment(#).

If protocol relative url, return nil scheme and domain else return nil for both scheme and domain.

When not protocol relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol relative url
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		authority = authority:gsub ('//', '', 1);								-- replace place 1 pair of '/' with nothing;
		if is_set(authority) then												-- if anything left (1 or 3+ '/' where authority should be) then
			return scheme;														-- return scheme only making domain nil which will cause an error message
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link= etc for properly formatted content: no wikilinks, no urls

Link parameters are to hold the title of a wikipedia article so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki urls and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid url (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid url (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from url; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid url
end

--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wikilinked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

]]

local function link_title_ok (link, lorig, title, torig)
local orig;

	if is_set (link) then 														-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		end
	end

	if is_set (orig) then
		table.insert( z.message_tail, { set_error( 'bad_paramlink', orig)});	-- url or wikilink in |title= with |title-link=;
	end
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the url into scheme and domain
portions, or for protocol relative (//example.com) urls, just the domain.  Use is_url() to validate the two
portions of the url.  If both are valid, or for protocol relative if domain is valid, return true, else false.

Because it is different from a standard url, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper url
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from url;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a url.  The test will also find external wikilinks
that use protocol relative urls. Also finds bare urls.

The frontier pattern prevents a match on interwiki links which are similar to scheme:path urls.  The tests that
find bracketed urls are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol relative ext wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare url with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol relative bare url: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a url
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then												-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source )
	local error_str = &quot;&quot;;
	local domain;
	local path;
	
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the url into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['[']='%5b',[']']='%5d'});					-- replace '[' and ']' with their percent encoded values
		URL=domain..path;														-- and reassemble
	end
	
	return table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url( label ), &quot;]&quot;, error_str });
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end

--[[--------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Replaces unicode quotemarks with typewriter quote marks regardless of the need for kerning.

Call this function for chapter titles, for website titles, etc; not for book titles.

]]

local function kern_quotes (str)
	local cap='';
	local cap2='';
																				-- TODO: move this elswhere so that all title-holding elements get these quote marks replaced?
	str= mw.ustring.gsub (str, '[“”]', '\&quot;');									-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
	str= mw.ustring.gsub (str, '[‘’]', '\'');									-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)
	
	cap, cap2 = str:match (&quot;^([\&quot;\'])([^\'].+)&quot;);								-- match leading double or single quote but not double single quotes
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-left'], {cap, cap2});
	end

	cap, cap2 = str:match (&quot;^(.+[^\'])([\&quot;\'])$&quot;)
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-right'], {cap, cap2});
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title= and |script-chapter=

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, cfg.script_lang_codes) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				add_prop_cat ('script')
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return substitute( msg, str );										-- including template text
	else
		return substitute( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (scriptchapter, chapter, transchapter, chapterurl, chapter_url_source, no_quotes)
	local chapter_error = '';
	
	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);										-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
			chapter = wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, scriptchapter)						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (transchapter) then
		transchapter = wrap_style ('trans-quoted-title', transchapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. transchapter;
		else																	-- here when transchapter without chapter or script-chapter
			chapter = transchapter;												-- 
			chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
		end
	end

	if is_set (chapterurl) then
		chapter = external_link (chapterurl, chapter, chapter_url_source);		-- adds bare_url_missing_title error if appropriate
	end

	return chapter .. chapter_error;
end

--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Detects but ignores the character pattern that results from the transclusion of {{'}} templates.

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i=1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- Test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position then
			if 'nowiki' == capture or 'math' == capture then 					-- nowiki, math stripmarker (not an error condition)
				stripmarker = true;												-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { set_error( 'invisible_char', {err_msg, wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i=i+1;																	-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end

--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash

]]

local function hyphen_to_dash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if comp:sub(1,1) == duplicate_char then								-- is first charactier same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for th
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = str:sub(-1,-1);										-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = str:sub(1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = str:sub(1, -4) .. &quot;''&quot;;							-- remove them and add back ''
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then		-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then		-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then			-- if last two chars of str are sepc] external link
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;'']&quot; then		-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then				-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = str:sub(1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end		-- if duplicate_char not a letter then escape it
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )			-- remove duplicate_char if it follows html markup
					else
						value = value:sub( 2, -1 );								-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end  


--[[--------------------------&lt; I S _ S U F F I X &gt;------------------------------------------------------------

returns true is suffix is properly formed Jr, Sr, or ordinal in the range 2–9.  Puncutation not allowed.

]]

local function is_suffix (suffix)
	if in_array (suffix, {'Jr', 'Sr', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end

--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written ouside of the code editor and pasted here because the code editor gets confused between character insertion point and cursor position.
The test has been rewritten to use decimal character escape sequence for the individual bytes of the unicode characters so that it is not necessary
to use an external editor to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first)
	local first, suffix = first:match ('(.-),?%s*([%dJS][%drndth]+)%.?$') or first;		-- if first has something that looks like a generational suffix, get it

	if is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error ('suffix');
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error ('non-Latin character');
			return false;														-- not a string of latin characters; Vancouver requires Romanization
	end;
	return true;
end

--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just intials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; name:len() then													-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error ('suffix');									-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word


	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i],1,1));				-- insert the intial at end of initials table
		end
		i = i+1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end

--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = ',';																-- name-list separator between authors is a comma
		namesep = ' ';															-- last/first separator is a space
	else
		sep = ';'																-- name-list separator between authors is a semicolon
		namesep = ', '															-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then 
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then					-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first 
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;				-- link author/editor if this page is not the author's/editor's page
				end
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end

--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]
local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of author and editor name parameters for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the parameters |display-authors=etal or |display-editors=etal

]]

local function name_has_etal (name, etal, nocat)

	if is_set (name) then														-- name can be nil in which case just return
		local etal_pattern = &quot;[;,]? *[\&quot;']*%f[%a][Ee][Tt] *[Aa][Ll][%.\&quot;']*$&quot;	-- variations on the 'et al' theme
		local others_pattern = &quot;[;,]? *%f[%a]and [Oo]thers&quot;;					-- and alternate to et al.
		
		if name:match (etal_pattern) then										-- variants on et al.
			name = name:gsub (etal_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		elseif name:match (others_pattern) then									-- if not 'et al.', then 'and others'?
			name = name:gsub (others_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		end
	end
	return name, etal;															-- 
end

--[[--------------------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;----------------------------------------

Evaluates the content of author and editor (surnames only) parameters for multiple names.  Multiple names are
indicated if there is more than one comma and or semicolon.  If found, the function adds the multiple name
(author or editor) maintenance category.

]]

local function name_has_mult_names (name, list_name)
local count, _;
	if is_set (name) then
		if name:match ('^%(%(.*%)%)$') then										-- if wrapped in doubled parentheses, ignore 
			name = name:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			_, count = name:gsub ('[;,]', '');									-- count the number of separator-like characters
			
			if 1 &lt; count then													-- param could be |author= or |editor= so one separactor character is acceptable
				add_maint_cat ('mult_names', list_name:lower());				-- more than one separator indicates multiple names so add a maint cat for this template
			end
		end
	end
	return name;																-- and done
end

--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary
	while true do
		last = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false);							-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false);						-- find and remove variations on et al.
		last = name_has_mult_names (last, err_msg_list_name);					-- check for multiple names in last and its aliases
		
		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			link_title_ok (link, list_name:match (&quot;(%w+)List&quot;):lower() .. '-link' .. i, last, list_name:match (&quot;(%w+)List&quot;):lower() .. '-last' .. i);	-- check for improper wikimarkup

			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because case of the source may be incorrect
or different from the case that WikiMedia uses, the name comparisons are done in lower case and when a match is
found, the Wikimedia version (assumed to be correct) is returned along with the code.  When there is no match, we
return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') return a list of languages that in some cases may include
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.

Names but that are included in the list will be found if that name is provided in the |language= parameter.  For example,
if |language=Chavacano de Zamboanga, that name will be found with the associated code 'cbk-zam'.  When names are found
and the associated code is not two or three characters, this function returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	local languages = mw.language.fetchLanguageNames(this_wiki_code, 'all')		-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() and 3 ~= code:len() then							-- two- or three-character codes only; extensions not supported
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the the code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for the code
end

--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code is recognized by MediaWiki,
use the returned name; if not, then use the value that was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is assigned to the category for
that code: Category:Norwegian-language sources (no).  For valid three-character code languages, the page is assigned
to the single category for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does not recognize three-character
equivalents of two-character codes: code 'ar' is recognized bit code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are
separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki = mw.getContentLanguage();									-- get a language object for this wiki
	local this_wiki_code = this_wiki:getCode()									-- get this wiki's language code
	local this_wiki_name = mw.language.fetchLanguageName(this_wiki_code, this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang

		if lang:match ('^%a%a%-') then											-- strip ietf language tags from code; TODO: is there a need to support 3-char with tag?
			lang = lang:match ('(%a%a)%-')										-- keep only 639-1 code portion to lang; TODO: do something with 3166 alpha 2 country code?
		end
		if 2 == lang:len() or 3 == lang:len() then								-- if two-or three-character code
			name = mw.language.fetchLanguageName( lang:lower(), this_wiki_code);	-- get language name if |language= is a proper code
		end
	
		if is_set (name) then													-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, this_wiki_code);				-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then													-- only 2- or 3-character codes
			if this_wiki_code ~= code then										-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					add_prop_cat ('foreign_lang_source', {name, code})			-- categorize it
				else															-- or is a recognized language (but has a three-character code)
					add_prop_cat ('foreign_lang_source_2', {code})				-- categorize it differently TODO: support mutliple three-character code categories per cs1|2 template
				end
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, ' and ')							-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		language_list[code] = 'and ' .. language_list[code];					-- prepend last name with 'and&lt;space&gt;'
		name = table.concat (language_list, ', ')								-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
	end
	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
end

--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = '.';																-- terminate the rendered citation with a period
	end
	return '.', ps;																-- separator is a full stop
end

--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = '';																-- make sure it isn't nil
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return ',', ps, ref;														-- separator is a comma
end

--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end

--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extension, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf[%?#]?') or url:match ('%.PDF[%?#]?');
end

--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parenthases, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end

--[[--------------------------&lt; G E T _ D I S P L A Y _ A U T H O R S _ E D I T O R S &gt;------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_authors_editors (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_auth_ed', list_name);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end

--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
--	local good_pattern = '^P[^%.P%l]';
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
--	local bad_pattern = '^[Pp][Pp]';
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
--		if Page:match ('^[Pp]?[Pp]%.?[ %d]') or  Page:match ('^[Pp]ages?[ %d]') or
--			Pages:match ('^[Pp]?[Pp]%.?[ %d]') or  Pages:match ('^[Pp]ages?[ %d]') then
--				add_maint_cat ('extra_text');
--		end
end

--[[--------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vautthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parnetheses were included in the
rendered citation and in the metadata.

	|vauthors=Jones AB, White EB, ((Black, Brown, and Co.))

This code is experimental and may not be retained.

]]
local function get_v_name_table (vparam, output_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parens
			local name = name_table[i];
			i=i+1;																-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parens
					break;														-- and done reassembling so
				end
				i=i+1;															-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
		else
			table.insert (output_table, name_table[i]);							-- add this name 
		end
		i = i+1;
	end	
	return output_table;
end

--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	if vparam:find ('%[%[') or vparam:find ('%]%]')	then						-- no wikilinking vauthors names
		add_vanc_error ('wikilink');
	end
	v_name_table = get_v_name_table (vparam, v_name_table);						-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parentheses to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')								-- remove doubled parntheses
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error ('punctuation');
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
			if is_suffix (first) then											-- if a valid suffix
				suffix = first													-- save it as a suffix and
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end																	-- no suffix error message here because letter combination may be result of Romanization; check for digits?
			last = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error ('missing comma');								-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error ('name');										-- matches a space between two intiials
			end
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error ('initials');									-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first);									-- check first and last before restoring the suffix which may have a non-Latin digit
			if is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '');
			end
		end
																				-- this from extract_names ()
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice incase we have a |first1= without a |last1=; this ...
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or	-- ... also catches the case where |first= is used with |vauthors=
		select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, no, etc).  When the parameter value has not been assigned a value (missing or empty
in the source template) the function refurns true.  If the parameter value is one of the list of allowed values returns
true; else, emits an error message and returns false.

]]

local function is_valid_parameter_value (value, name, possible)
	if not is_set (value) then
		return true;															-- an empty parameter is ok
	elseif in_array(value:lower(), possible) then
		return true;
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list,-1,-1) == sepc) or (string.sub (name_list,-3,-1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terninate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not is_set (volume) and not is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end

	local vol = '';
		
	if is_set (volume) then
		if (4 &lt; mw.ustring.len(volume)) then
			vol = substitute (cfg.messages['j-vol'], {sepc, volume});
		else
			vol = substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});
		end
	end
	if is_set (issue) then
		return vol .. substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end


--[[-------------------------&lt; N O R M A L I Z E _ P A G E _ L I S T &gt;-----------------------------------------

not currently used

normalizes a comma, ampersand, and/or space separated list to be '&lt;value&gt;, &lt;value&gt;, ..., &lt;value&gt;'
returns list unchanged if there are no commas else strips whitespace and then reformats the list

]]
--[[
local function normalize_page_list (list)
	if not list:find ('[,&amp; ]') then return list end								-- if list is not delimited with commas, ampersands, or spaces; done
	
	list = mw.text.split (list, '[,&amp;%s]+');										-- make a table of values
	list = table.concat (list, ', ');											-- and now make a normalized list
	return list;
end
]]


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'journal' == origin);

	if is_set (page) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif is_set(pages) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then										-- if pages is only digits, assume a single page number
			return '', substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org urls to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot url or to calendar pages.  When the archive url is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the url.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org url does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command url
	|archive-url= is an archive.org url that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org urls:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this funct may return a modified
archive url:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the url unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.or url
	
	if not url:match('//web%.archive%.org/') then
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command url, we don't want to allow saving of the target page 
		err_msg = 'save command';
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');		-- split out some of the url parts for evaluation
		
		if not is_set(timestamp) or 14 ~= timestamp:len() then					-- path and flag optional, must have 14-digit timestamp here
			err_msg = 'timestamp';
			if '*' ~= flag then
				url=url:gsub ('(//web%.archive%.org/[^%d]*%d?%d?%d?%d?%d?%d?)[^/]*', '%1*', 1)	-- for preview, modify ts to be yearmo* max (0-6 digits plus splat)
			end
		elseif is_set(path) and 'web/' ~= path then								-- older archive urls do not have the extra 'web/' path element
			err_msg = 'path';
		elseif is_set (flag) and not is_set (path) then							-- flag not allowed with the old form url (without the 'web/' path element)
			err_msg = 'flag';
		elseif is_set (flag) and not flag:match ('%a%a_') then					-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = 'flag';
		else
			return url, date;													-- return archiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	table.insert( z.message_tail, { set_error( 'archive_url', {err_msg}, true ) } );	-- add error message and
	if is_set (Frame:preprocess('{{REVISIONID}}')) then
		return '', '';															-- return empty strings for archiveURL and ArchiveDate
	else
		return url, date;														-- preview mode so return archiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe:
	{{cite ... |title=Title access-date=2016-03-17}}

cs1|2 shares some parameter names with xml/html atributes: class=, title=, etc.  To prevent false positives xml/html
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove xml/html tags because attributes: class=, title=, etc 

	capture = value:match ('%s+(%a[%a%d]+)%s*=') or value:match ('^(%a[%a%d]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then								-- if the capture is a valid parameter name
		add_maint_cat ('missing_pipe');
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	
	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				add_maint_cat ('authors');										-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
			add_maint_cat ('editors');											-- but add a maint cat because use of this parameter is discouraged
		end
	end

	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list
	local Contribution = A['Contribution'];
	if in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not is_set (Contribution) then									-- |contributor= requires |contribution=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if select_one (args, cfg.aliases['ContributorList-Last'], 'redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { set_error( 'contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if not is_valid_parameter_value (NameListFormat, 'name-list-format', cfg.keywords['name-list-format']) then			-- only accepted value for this parameter is 'vanc'
		NameListFormat = '';													-- anything else, set to empty string
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
			link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wikimarkup in |title-link= or wikimarkup in |title= when |title-link= is set

	local Chapter = A['Chapter'];
	local ScriptChapter = A['ScriptChapter'];
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];

	local ArchiveDate;
	local ArchiveURL;

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	
	local DeadURL = A['DeadURL']
		if not is_valid_parameter_value (DeadURL, 'dead-url', cfg.keywords ['deadurl']) then	-- set in config.defaults to 'yes'
			DeadURL = '';														-- anything else, set to empty string
		end

	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];
	local Periodical_origin = A:ORIGIN('Periodical');							-- get the name of the periodical parameter

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if in_array (config.CitationClass, cfg.templates_using_volume) and not ('conference' == config.CitationClass and not is_set (Periodical)) then
		Volume = A['Volume'];
	end
	if in_array (config.CitationClass, cfg.templates_using_issue) and not (in_array (config.CitationClass, {'conference', 'map'}) and not is_set (Periodical))then
		Issue = A['Issue'];
	end
	local Position = '';
	if not in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash( A['Pages'] );	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
		if not is_valid_parameter_value (RegistrationRequired, 'registration', cfg.keywords ['yes_true_y']) then
			RegistrationRequired=nil;
		end
	local SubscriptionRequired = A['SubscriptionRequired'];
		if not is_valid_parameter_value (SubscriptionRequired, 'subscription', cfg.keywords ['yes_true_y']) then
			SubscriptionRequired=nil;
		end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local Agency = A['Agency'];

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
		if not is_valid_parameter_value (IgnoreISBN, 'ignore-isbn-error', cfg.keywords ['yes_true_y']) then
			IgnoreISBN = nil;													-- anything else, set to empty string
		end
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
		if not is_valid_parameter_value (LastAuthorAmp, 'last-author-amp', cfg.keywords ['yes_true_y']) then
			LastAuthorAmp = nil;													-- set to empty string
		end
	local no_tracking_cats = A['NoTracking'];
		if not is_valid_parameter_value (no_tracking_cats, 'no-tracking', cfg.keywords ['yes_true_y']) then
			no_tracking_cats = nil;												-- set to empty string
		end

--these are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = A['DF'];															-- date format set in cs1|2 template
	if not is_valid_parameter_value (DF, 'df', cfg.keywords['date-format']) then	-- validate reformatting keyword
		DF = '';																-- not valid, set to empty string
	end

-- set default parameter values defined by |mode= parameter.  If |mode= is empty or omitted, use CitationClass to set these values
	local Mode = A['Mode'];
	if not is_valid_parameter_value (Mode, 'mode', cfg.keywords['mode']) then
		Mode = '';
	end
	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	select_one( args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'redundant_parameters' );		-- this is a dummy call simply to get the error message and category

	local NoPP = A['NoPP'] 
	if is_set (NoPP) and is_valid_parameter_value (NoPP, 'nopp', cfg.keywords ['yes_true_y']) then
		NoPP = true;
	else
		NoPP = nil;																-- unset, used as a flag later
	end

	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Pages = '';															-- unset the others
			At = '';
		end
		extra_text_in_page_check (Page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.
	elseif is_set(Pages) then
		if is_set(At) then
			At = '';															-- unset
		end
		extra_text_in_page_check (Pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped
	|url maps to |chapterurl when |title is remapped

All other combinations of |encyclopedia, |title, and |article are not modified

]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					TransChapter = TransTitle;
					ChapterURL = URL;
					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter= '[[' .. TitleLink .. '|' .. Chapter .. ']]';
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			else																-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if is_set(A['Number']) then												-- cite techreport uses 'number', which other citations alias to 'issue'
			if not is_set(ID) then												-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', 'id') .. ' and ' .. wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

-- special case for cite interview												-- TODO: make cite interveiw not need special cases
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			ID = ' ' .. Program;
		end
		if is_set(Callsign) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. Callsign;
			else
				ID = ' ' .. Callsign;
			end
		end
		if is_set(City) then
			if is_set(ID) then
				ID = ID .. sepc .. ' ' .. City;
			else
				ID = ' ' .. City;
			end
		end

		if is_set(Others) then
			if is_set(TitleType) then
				Others = substitute (cfg.messages['interview-type'], {TitleType, Others});
				TitleType = '';
			else
				Others = substitute (cfg.messages['interview'], Others)
			end
		else
			Others = cfg.title_types ['interview'];
		end
	end

-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	elseif 'mailinglist' == A:ORIGIN('Periodical') then
		Periodical = '';														-- unset because mailing list is only used for cite mailing list
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];

		link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wikimarkup in |series-link= or wikimarkup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) and is_set (AirDate) then							-- promote airdate to date
			Date = AirDate;
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('series', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = '[[' .. ChapterLink .. '|' .. Chapter .. ']]';		-- ok to wikilink
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = '[[' .. ChapterLink .. '|' .. Series .. ']]';			-- series links with ChapterLink (episodelink -&gt; TitleLink -&gt; ChapterLink) ugly
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = '[[' .. SeriesLink .. '|' .. Series .. ']]';
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
-- end of {{cite episode}} stuff

-- Account for the oddities that are {{cite arxiv}}, before generation of COinS data.
	if 'arxiv' == config.CitationClass then
		if not is_set (ID_list['ARXIV']) then									-- |arxiv= or |eprint= required for cite arxiv
			table.insert( z.message_tail, { set_error( 'arxiv_missing', {}, true ) } );		-- add error message
		elseif is_set (Series) then												-- series is an alias of version
			ID_list['ARXIV'] = ID_list['ARXIV'] .. Series;						-- concatenate version onto the end of the arxiv identifier
			Series = '';														-- unset
			deprecated_parameter ('version');									-- deprecated parameter but only for cite arxiv
		end
		
		if first_set ({AccessDate, At, Authors, Chapter, Format, Page, Pages, Periodical, PublisherName, URL,	-- a crude list of parameters that are not supported by cite arxiv
			ID_list['ASIN'], ID_list['BIBCODE'], ID_list['DOI'], ID_list['ISBN'], ID_list['ISSN'],		-- TODO: find a better way to do this
			ID_list['JFM'], ID_list['JSTOR'], ID_list['LCCN'], ID_list['MR'], ID_list['OCLC'], ID_list['OL'],
			ID_list['OSTI'], ID_list['PMC'], ID_list['PMID'], ID_list['RFC'], ID_list['SSRN'], ID_list['USENETID'], ID_list['ZBL']},27) then
				table.insert( z.message_tail, { set_error( 'arxiv_params_not_supported', {}, true ) } );		-- add error message

				AccessDate = '';												-- set these to empty string; not supported in cite arXiv
				Authors = '';
				PublisherName = '';												-- (if the article has been published, use cite journal, or other)
				Chapter = '';
				URL = '';
				Format = '';
				Page = ''; Pages = ''; At = '';
		end
		Periodical = 'arXiv';													-- set to arXiv for COinS; after that, must be set to empty string
	end

-- handle type parameter for those CS1 citations that have default values
	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;DVD-notes&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
	TitleType = substitute( cfg.messages['type'], TitleType);					-- display it in parentheses
	end

-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {['access-date']=AccessDate, ['archive-date']=ArchiveDate, ['date']=Date, ['doi-broken-date']=DoiBroken,
				['embargo']=Embargo, ['lay-date']=LayDate, ['publication-date']=PublicationDate, ['year']=Year};

		anchor_year, Embargo, error_message = dates(date_parameters_list, COinS_date);

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end
		
		if not is_set(error_message) then										-- error free dates only
			local modified = false;												-- flag
			if is_set (DF) then													-- if we need to reformat dates
				modified = reformat_dates (date_parameters_list, DF, false);	-- reformat to DF format, use long month names if appropriate
			end

			if true == date_hyphen_to_dash (date_parameters_list) then					-- convert hyphens to dashes where appropriate
				modified = true;
				add_maint_cat ('date_format');									-- hyphens were converted so add maint category
			end
			
			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'];				-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'];
				Date = date_parameters_list['date'];
				DoiBroken = date_parameters_list['doi-broken-date'];
				LayDate = date_parameters_list['lay-date'];
				PublicationDate = date_parameters_list['publication-date'];
			end
		else
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end
	end	-- end of do

-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);											-- 

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
			if is_set(AccessDate) then											-- access date requires |url=; pmc created url is not |url=
				table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
				AccessDate = '';												-- unset
			end

		end
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
			if 'episode' == config.CitationClass then							-- special case for cite episode; TODO: is there a better way to do this?
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
			else
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
			end
	end
	
	if 'none' == Title and in_array (config.CitationClass, {'journal', 'citation'}) and is_set (Periodical) and 'journal' == A:ORIGIN('Periodical') then	-- special case for journal cites
		Title = '';																-- set title to empty string
		add_maint_cat ('untitled');
	end

	check_for_url ({															-- add error message when any of these parameters contains a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[A:ORIGIN('Periodical')]=Periodical,
		[A:ORIGIN('PublisherName')] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = Periodical,
		['Encyclopedia'] = Encyclopedia,
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

-- Account for the oddities that are {{cite arxiv}}, AFTER generation of COinS data.
	if 'arxiv' == config.CitationClass then										-- we have set rft.jtitle in COinS to arXiv, now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in cite arxiv; if article has been published, use cite journal
	end

-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = substitute (cfg.messages['newsgroup'], external_link( 'news:' .. PublisherName, PublisherName, A:ORIGIN('PublisherName') ));
		end
	end



	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text											-- get current page name so that we don't wikilink to it via editorlinkn
		};

		do																		-- do editor name list first because coauthors can modify control table
			control.maximum , editor_etal = get_display_authors_editors (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if is_set (Editors) then
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
					EditorCount = 2;											-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
				else
					EditorCount = 2;											-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
				end
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do translators
			control.maximum = #t;												-- number of translators
			Translators = list_people(control, t, false);						-- et al not currently supported
		end
		do																		-- now do contributors
			control.maximum = #c;												-- number of contributors
			Contributors = list_people(control, c, false);						-- et al not currently supported
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_authors_editors (A['DisplayAuthors'], #a, 'authors', author_etal);

			if is_set(Coauthors) then											-- if the coauthor field is also used, prevent ampersand and et al. formatting.
				control.lastauthoramp = nil;
				control.maximum = #a + 1;
			end
			
			last_first_list = list_people(control, a, author_etal);

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false);	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if is_set (Authors) and is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

		if not is_set(Authors) and is_set(Coauthors) then						-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
			table.insert( z.message_tail, { set_error('coauthors_missing_author', {}, true) } );	-- emit error message
		end
	end

-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

-- special case for chapter format so no error message or cat when chapter not supported
	if not (in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not is_set(URL) then
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then	-- |url= required for cite web, cite podcast, and cite mailinglist
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURLorigin, OriginalFormat;
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (ChapterURL) then 											-- URL not set so if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURLorigin = ChapterURLorigin;								-- name of chapter-url parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |format=
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				ChapterURLorigin = A:ORIGIN('ArchiveURL')						-- name of archive-url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
			end
		elseif is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURLorigin = URLorigin;										-- name of url parameter for error messages
			OriginalFormat = Format;											-- and original |format=
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
			end
 		end
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'arxiv'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			local chap_param;
			if is_set (Chapter) then											-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif is_set (ScriptChapter) then
				chap_param = A:ORIGIN ('ScriptChapter')
			else is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if is_set (chap_param) then											-- if we found one
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {chap_param}, true ) } );		-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if is_set (Contribution) and 0 &lt; #c then								-- if this is a contribution with contributor(s)
			if in_array (Contribution:lower(), cfg.keywords.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, Chapter, TransChapter, ChapterURL, ChapterURLorigin, no_quotes);		-- Contribution is also in Chapter
		if is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter.. sepc .. ' ';
		elseif is_set (ChapterFormat) then										-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'mailinglist', 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then
			Title = external_link( URL, Title, URLorigin ) .. TransError .. Format;
-- this experiment hidden 2016-04-10; see Help_talk:Citation_Style_1#Recycled_urls
--			local temp_title = external_link( URL, Title, URLorigin ) .. TransError .. Format;	-- do this so we get error message even if url is usurped no archive
--			if in_array (DeadURL, {'unfit no archive', 'usurped no archive'}) then	-- when url links to inappropriate location and there is no archive of original source available
--				local err_msg
--				if temp_title:match ('%[%S+%s+(.+)%](&lt;.+)') then				-- if there is an error message
--					Title, err_msg = temp_title:match ('%[%S+%s+(.+)%](&lt;.+)');	-- strip off external link; TODO: find a better to do this
--					Title = Title .. (err_msg or '');
--				end
--			else
--				Title = temp_title;
--			end

			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURLorigin );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if is_set(Minutes) then
			if is_set (Time) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'minutes') .. ' and ' .. wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
		Others = sepc .. ' ' .. wrap_msg ('translated', Translators, use_lowercase) .. Others; 
	end

	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

--[[
Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
note is displayed. There are no error messages for this condition.

]]
	if is_set (SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif is_set (RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if 'citation', lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text
																				-- neither of these work; don't know why; it seems that substitute() isn't being called	
		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then				-- if first and last characters of quote are quote marks
			Quote = Quote:sub(2,-2);											-- strip them off
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL') ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- DeadURL is empty, 'yes', 'true', 'y', 'unfit', 'usurped'
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if in_array (DeadURL, {'unfit', 'usurped', 'bot: unknown'}) then
				Archived = sepc .. &quot; &quot; .. 'Archived from the original on ' .. ArchiveDate;	-- format already styled
				if 'bot: unknown' == DeadURL then
					add_maint_cat ('bot:_unknown');								-- and add a category if not already added
				else
					add_maint_cat ('unfit');									-- and add a category if not already added
				end
			else																-- DeadURL is empty, 'yes', 'true', or 'y'
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURLorigin ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL') ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL') ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURLorigin );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin );
	end

	local Publisher;
	if is_set(PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if is_set(PublisherName) then
		if is_set(PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif is_set(PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
			Language, Edition, Publisher, Agency, Volume}, sepc );
		
	elseif in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(Periodical) then		-- special cases for book cites
		if is_set (Contributors) then											-- when we are citing foreword, preface, introduction, etc
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Transcript, Language, Edition, Publisher}, sepc );
	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if is_set(Date) then
		if is_set (Authors) or is_set (Editors) then							-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;;				-- in paranetheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon,-1,-1) == sepc) then							-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigYear;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigYear;							-- Date begins with sepc
			end
		end
	end	
	if is_set(Authors) then
		if is_set(Coauthors) then
			if 'vanc' == NameListFormat then									-- separate authors and coauthors with proper name-list-separator
				Authors = Authors .. ', ' .. Coauthors;
			else
				Authors = Authors .. '; ' .. Coauthors;
			end
		end
		if not is_set (Date) then												-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then in_text = in_text:lower() end				-- lowercase for cs2
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if is_set (Contributors) then											-- book cite and we're citing the intro, preface, etc
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if is_set (Editors) then											-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if not is_set (Date) then											-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = config.CitationClass;
		options.class = &quot;citation &quot; .. config.CitationClass;					-- class=citation required for blue highlight when used with |ref=
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then								-- set reference anchor if appropriate
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			if #namelist &gt; 0 then												-- if there are names in namelist
				id = anchor_id (namelist, year);								-- go make the CITEREF anchor
			else
				id = '';														-- unset
			end
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;.-&lt;/span&gt;&quot;, &quot;&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then													-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		text = substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text});	-- when |ref= is set
	else
		text = substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text});	-- all other cases
	end		

	text = text .. substitute (cfg.presentation['ocins'], {OCinSoutput});		-- append metadata to the citation
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. error_comment( v[1], v[2] );
				else
					text = text .. error_comment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end

	if #z.maintenance_cats ~= 0 then
		text = text .. '&lt;span class=&quot;citation-comment&quot; style=&quot;display:none; color:#33aa33&quot;&gt;';
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. ' ' .. v .. ' ([[:Category:' .. v ..'|link]])';
		end
		text = text .. '&lt;/span&gt;';	-- maintenance mesages (realy just the names of the categories for now)
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

--[[--------------------------&lt; C S 1 . C I T A T I O N &gt;------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

function cs1.citation(frame)
	Frame = frame;																-- save a copy incase we need to display an error message in preview mode
	local pframe = frame:getParent()
	local validation, utilities, identifiers, metadata;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (utilities);								-- so that functions in Date validataion can see the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	dates = validation.dates;													-- imported functions from Module:Citation/CS1/Date validation
	year_date_check = validation.year_date_check;
	reformat_dates = validation.reformat_dates;
	date_hyphen_to_dash = validation.date_hyphen_to_dash;
	
	is_set = utilities.is_set;													-- imported functions from Module:Citation/CS1/Utilities
	in_array = utilities.in_array;
	substitute = utilities.substitute;
	error_comment = utilities.error_comment;
	set_error = utilities.set_error;
	select_one = utilities.select_one;
	add_maint_cat = utilities.add_maint_cat;
	wrap_style = utilities.wrap_style;
	safe_for_italics = utilities.safe_for_italics;
	remove_wiki_link = utilities.remove_wiki_link;

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	extract_ids = identifiers.extract_ids;										-- imported functions from Module:Citation/CS1/Utilities
	build_id_list = identifiers.build_id_list;
	is_embargoed = identifiers.is_embargoed;
	
	make_coins_title = metadata.make_coins_title;								-- imported functions from Module:Citation/CS1/COinS
	get_coins_pages = metadata.get_coins_pages;
	COinS = metadata.COinS;

	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute( param, capture );				-- add the capture to the suggested parameter (typically the enumerator)
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, param}, true );	-- set the error message
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			missing_pipe_check (v);												-- do we think that there is a parameter that is missing a pipe?
			
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);
		end
	end
	return citation0( config, args)
end

return cs1;</text>
      <sha1>c94piag8birnfkfjjy0153fsnarorn1</sha1>
    </revision>
    <revision>
      <id>4713</id>
      <parentid>4712</parentid>
      <timestamp>2016-10-29T08:52:20Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4713</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="161353" sha1="0l8kczoetghhj1q5rqovvclu7grxwyn" xml:space="preserve">
local cs1 ={};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local dates, year_date_check, reformat_dates, date_hyphen_to_dash				-- functions in Module:Citation/CS1/Date_validation

local is_set, in_array, substitute, error_comment, set_error, select_one,		-- functions in Module:Citation/CS1/Utilities
	add_maint_cat, wrap_style, safe_for_italics, remove_wiki_link;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local extract_ids, extract_id_access_levels, build_id_list, is_embargoed;					-- functions in Module:Citation/CS1/Identifiers

local make_coins_title, get_coins_pages, COinS;									-- functions in Module:Citation/CS1/COinS

local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

delare variables here that have page-wide scope that are not brought in from other modules; thatare created here
and used here

]]

local added_deprecated_cat;														-- boolean flag so that the category is added only once
local added_prop_cats = {};														-- list of property categories that have been added to z.properties_cats
local added_vanc_errs;															-- boolean flag so we only emit one Vancouver error / category

local Frame;																	-- holds the module's frame table


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end

--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

added_prop_cats is a table declared in page scope variables above

]]

local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));		-- make name then add to table
	end
end

--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a boolean declared in page scope variables above

]]

local function add_vanc_error (source)
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {source}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a uri scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of tlds: https://www.iana.org/domains/root/db

rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the tld.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a url with a scheme) will be stripped
here.  Perhaps not necessary but retained incase it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ascii characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the tld) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org TLD
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and tld or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%a%d]') then										-- first character must be letter or digit
		return false;
	end
																				-- Do most common case first
	if domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.%a%a+$') then				-- three or more character hostname.hostname or hostname.tld
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.xn%-%-[%a%d]+$') then	-- internationalized domain name with ACE prefix
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.org$') then							-- one character .org hostname
		return true;
	elseif domain:match ('%f[%a][qxz]%.com$') then								-- assigned one character .com hostname (x.com times out 2015-12-10)
		return true;
	elseif domain:match ('%f[%a][iq]%.net$') then								-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.%a%a$') then							-- one character hostname and cctld (2 chars)
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d]%.%a%a+$') then					-- two character hostname and tld
		return true;
	elseif domain:match ('^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?') then		-- IPv4 address
		return true;
	else
		return false;
	end
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a url appear to be a valid url; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if is_set (scheme) then														-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when url is protocol relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a url into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following tld) (if any) and any path(/), query(?) or fragment(#).

If protocol relative url, return nil scheme and domain else return nil for both scheme and domain.

When not protocol relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol relative url
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		authority = authority:gsub ('//', '', 1);								-- replace place 1 pair of '/' with nothing;
		if is_set(authority) then												-- if anything left (1 or 3+ '/' where authority should be) then
			return scheme;														-- return scheme only making domain nil which will cause an error message
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link= etc for properly formatted content: no wikilinks, no urls

Link parameters are to hold the title of a wikipedia article so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki urls and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid url (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid url (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from url; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid url
end

--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wikilinked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

]]

local function link_title_ok (link, lorig, title, torig)
local orig;

	if is_set (link) then 														-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		end
	end

	if is_set (orig) then
		table.insert( z.message_tail, { set_error( 'bad_paramlink', orig)});	-- url or wikilink in |title= with |title-link=;
	end
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the url into scheme and domain
portions, or for protocol relative (//example.com) urls, just the domain.  Use is_url() to validate the two
portions of the url.  If both are valid, or for protocol relative if domain is valid, return true, else false.

Because it is different from a standard url, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper url
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from url;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a url.  The test will also find external wikilinks
that use protocol relative urls. Also finds bare urls.

The frontier pattern prevents a match on interwiki links which are similar to scheme:path urls.  The tests that
find bracketed urls are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol relative ext wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare url with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol relative bare url: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a url
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then												-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source, access)
	local error_str = &quot;&quot;;
	local domain;
	local path;
	local base_url;
	
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the url into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['[']='%5b',[']']='%5d'});					-- replace '[' and ']' with their percent encoded values
		URL=domain..path;														-- and reassemble
	end
	
	base_url = table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url( label ), &quot;]&quot; });
	
	if is_set(access) then -- access level (free, paywalled, ...)
		base_url = substitute(cfg.presentation[access], base_url);
	end
	
	return table.concat({ base_url, error_str });
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end

--[[--------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Replaces unicode quotemarks with typewriter quote marks regardless of the need for kerning.

Call this function for chapter titles, for website titles, etc; not for book titles.

]]

local function kern_quotes (str)
	local cap='';
	local cap2='';
																				-- TODO: move this elswhere so that all title-holding elements get these quote marks replaced?
	str= mw.ustring.gsub (str, '[“”]', '\&quot;');									-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
	str= mw.ustring.gsub (str, '[‘’]', '\'');									-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)
	
	cap, cap2 = str:match (&quot;^([\&quot;\'])([^\'].+)&quot;);								-- match leading double or single quote but not double single quotes
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-left'], {cap, cap2});
	end

	cap, cap2 = str:match (&quot;^(.+[^\'])([\&quot;\'])$&quot;)
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-right'], {cap, cap2});
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title= and |script-chapter=

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, cfg.script_lang_codes) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				add_prop_cat ('script')
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return substitute( msg, str );										-- including template text
	else
		return substitute( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (scriptchapter, chapter, transchapter, chapterurl, chapter_url_source, no_quotes)
	local chapter_error = '';
	
	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);										-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
			chapter = wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, scriptchapter)						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (transchapter) then
		transchapter = wrap_style ('trans-quoted-title', transchapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. transchapter;
		else																	-- here when transchapter without chapter or script-chapter
			chapter = transchapter;												-- 
			chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
		end
	end

	if is_set (chapterurl) then
		chapter = external_link (chapterurl, chapter, chapter_url_source, nil);		-- adds bare_url_missing_title error if appropriate
	end

	return chapter .. chapter_error;
end

--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Detects but ignores the character pattern that results from the transclusion of {{'}} templates.

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i=1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- Test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position then
			if 'nowiki' == capture or 'math' == capture then 					-- nowiki, math stripmarker (not an error condition)
				stripmarker = true;												-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { set_error( 'invisible_char', {err_msg, wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i=i+1;																	-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------
Looks for a parameter's name in the whitelist.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate( name )
	local name = tostring( name );
	local state = whitelist.basic_arguments[ name ];
	
	-- Normal arguments
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	-- Arguments with numbers in them
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );				-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];
	if true == state then return true; end		-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);				-- parameter is deprecated but still supported
		return true;
	end
	
	return false;								-- Not supported because not found or name is set to nil
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end

--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash

]]

local function hyphen_to_dash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if comp:sub(1,1) == duplicate_char then								-- is first charactier same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for th
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = str:sub(-1,-1);										-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = str:sub(1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = str:sub(1, -4) .. &quot;''&quot;;							-- remove them and add back ''
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then		-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then		-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then			-- if last two chars of str are sepc] external link
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;'']&quot; then		-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then				-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = str:sub(1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end		-- if duplicate_char not a letter then escape it
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )			-- remove duplicate_char if it follows html markup
					else
						value = value:sub( 2, -1 );								-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end  


--[[--------------------------&lt; I S _ S U F F I X &gt;------------------------------------------------------------

returns true is suffix is properly formed Jr, Sr, or ordinal in the range 2–9.  Puncutation not allowed.

]]

local function is_suffix (suffix)
	if in_array (suffix, {'Jr', 'Sr', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end

--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written ouside of the code editor and pasted here because the code editor gets confused between character insertion point and cursor position.
The test has been rewritten to use decimal character escape sequence for the individual bytes of the unicode characters so that it is not necessary
to use an external editor to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first)
	local first, suffix = first:match ('(.-),?%s*([%dJS][%drndth]+)%.?$') or first;		-- if first has something that looks like a generational suffix, get it

	if is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error ('suffix');
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error ('non-Latin character');
			return false;														-- not a string of latin characters; Vancouver requires Romanization
	end;
	return true;
end

--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just intials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; name:len() then													-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error ('suffix');									-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word


	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i],1,1));				-- insert the intial at end of initials table
		end
		i = i+1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end

--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = ',';																-- name-list separator between authors is a comma
		namesep = ' ';															-- last/first separator is a space
	elseif 'mla' == control.mode then
		sep = ',';																-- name-list separator between authors is a comma
		namesep = ', '															-- last/first separator is &lt;comma&gt;&lt;space&gt;
	else
		sep = ';'																-- name-list separator between authors is a semicolon
		namesep = ', '															-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then
					if 'mla' == control.mode then 
						if i == 1 then											-- for mla
							one = one .. namesep .. first;						-- first name last, first
						else													-- all other names
							one = first .. ' ' .. one;							-- first last
						end
					else
						if ( &quot;vanc&quot; == format ) then								-- if vancouver format
							one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
							if not person.corporate and is_good_vanc_name (one, first) then					-- and name is all Latin characters; corporate authors not tested
								first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
							end
						end
						one = one .. namesep .. first;
					end
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;				-- link author/editor if this page is not the author's/editor's page
				end
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			if 'mla' == control.mode then
				text[#text-2] = &quot;, and &quot;;										-- replace last separator with ', and ' text
			else
				text[#text-2] = &quot; &amp; &quot;;											-- replace last separator with ampersand text
			end
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end

--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]
local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of author and editor name parameters for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the parameters |display-authors=etal or |display-editors=etal

]]

local function name_has_etal (name, etal, nocat)

	if is_set (name) then														-- name can be nil in which case just return
		local etal_pattern = &quot;[;,]? *[\&quot;']*%f[%a][Ee][Tt] *[Aa][Ll][%.\&quot;']*$&quot;	-- variations on the 'et al' theme
		local others_pattern = &quot;[;,]? *%f[%a]and [Oo]thers&quot;;					-- and alternate to et al.
		
		if name:match (etal_pattern) then										-- variants on et al.
			name = name:gsub (etal_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		elseif name:match (others_pattern) then									-- if not 'et al.', then 'and others'?
			name = name:gsub (others_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		end
	end
	return name, etal;															-- 
end

--[[--------------------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;----------------------------------------

Evaluates the content of author and editor (surnames only) parameters for multiple names.  Multiple names are
indicated if there is more than one comma and or semicolon.  If found, the function adds the multiple name
(author or editor) maintenance category.

]]

local function name_has_mult_names (name, list_name)
local count, _;
	if is_set (name) then
		if name:match ('^%(%(.*%)%)$') then										-- if wrapped in doubled parentheses, ignore 
			name = name:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			_, count = name:gsub ('[;,]', '');									-- count the number of separator-like characters
			
			if 1 &lt; count then													-- param could be |author= or |editor= so one separactor character is acceptable
				add_maint_cat ('mult_names', cfg.special_case_translation [list_name]);	-- more than one separator indicates multiple names so add a maint cat for this template
			end
		end
	end
	return name;																-- and done
end

--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary
	while true do
		last = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false);							-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false);						-- find and remove variations on et al.
--		last = name_has_mult_names (last, err_msg_list_name);					-- check for multiple names in last and its aliases
		last = name_has_mult_names (last, list_name);					-- check for multiple names in last and its aliases
		
		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			link_title_ok (link, list_name:match (&quot;(%w+)List&quot;):lower() .. '-link' .. i, last, list_name:match (&quot;(%w+)List&quot;):lower() .. '-last' .. i);	-- check for improper wikimarkup

			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because case of the source may be incorrect
or different from the case that WikiMedia uses, the name comparisons are done in lower case and when a match is
found, the Wikimedia version (assumed to be correct) is returned along with the code.  When there is no match, we
return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') return a list of languages that in some cases may include
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.

Names but that are included in the list will be found if that name is provided in the |language= parameter.  For example,
if |language=Chavacano de Zamboanga, that name will be found with the associated code 'cbk-zam'.  When names are found
and the associated code is not two or three characters, this function returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	local languages = mw.language.fetchLanguageNames(this_wiki_code, 'all')		-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() and 3 ~= code:len() then							-- two- or three-character codes only; extensions not supported
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the the code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for the code
end

--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code is recognized by MediaWiki,
use the returned name; if not, then use the value that was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is assigned to the category for
that code: Category:Norwegian-language sources (no).  For valid three-character code languages, the page is assigned
to the single category for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does not recognize three-character
equivalents of two-character codes: code 'ar' is recognized bit code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are
separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki = mw.getContentLanguage();									-- get a language object for this wiki
	local this_wiki_code = this_wiki:getCode()									-- get this wiki's language code
	local this_wiki_name = mw.language.fetchLanguageName(this_wiki_code, this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang

		if lang:match ('^%a%a%-') then											-- strip ietf language tags from code; TODO: is there a need to support 3-char with tag?
			lang = lang:match ('(%a%a)%-')										-- keep only 639-1 code portion to lang; TODO: do something with 3166 alpha 2 country code?
		end
		if 2 == lang:len() or 3 == lang:len() then								-- if two-or three-character code
			name = mw.language.fetchLanguageName( lang:lower(), this_wiki_code);	-- get language name if |language= is a proper code
		end
	
		if is_set (name) then													-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, this_wiki_code);				-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then													-- only 2- or 3-character codes
			if this_wiki_code ~= code then										-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					add_prop_cat ('foreign_lang_source', {name, code})			-- categorize it
				else															-- or is a recognized language (but has a three-character code)
					add_prop_cat ('foreign_lang_source_2', {code})				-- categorize it differently TODO: support mutliple three-character code categories per cs1|2 template
				end
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, ' and ')							-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		language_list[code] = 'and ' .. language_list[code];					-- prepend last name with 'and&lt;space&gt;'
		name = table.concat (language_list, ', ')								-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
	end
	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end

--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = '.';																-- terminate the rendered citation with a period
	end
	return '.', ps;																-- separator is a full stop
end

--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = '';																-- make sure it isn't nil
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return ',', ps, ref;														-- separator is a comma
end

--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	elseif 'mla' == mode then													-- if this template is to be rendered in mla style use cs1 for bot cs1 &amp; cs2 templates
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end

--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extension, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf[%?#]?') or url:match ('%.PDF[%?#]?');
end

--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parenthases, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end

--[[--------------------------&lt; G E T _ D I S P L A Y _ A U T H O R S _ E D I T O R S &gt;------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_authors_editors (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_auth_ed', cfg.special_case_translation [list_name]);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end

--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
--	local good_pattern = '^P[^%.P%l]';
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
--	local bad_pattern = '^[Pp][Pp]';
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
--		if Page:match ('^[Pp]?[Pp]%.?[ %d]') or  Page:match ('^[Pp]ages?[ %d]') or
--			Pages:match ('^[Pp]?[Pp]%.?[ %d]') or  Pages:match ('^[Pp]ages?[ %d]') then
--				add_maint_cat ('extra_text');
--		end
end

--[[--------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vautthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parnetheses were included in the
rendered citation and in the metadata.

	|vauthors=Jones AB, White EB, ((Black, Brown, and Co.))

This code is experimental and may not be retained.

]]
local function get_v_name_table (vparam, output_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parens
			local name = name_table[i];
			i=i+1;																-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parens
					break;														-- and done reassembling so
				end
				i=i+1;															-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
		else
			table.insert (output_table, name_table[i]);							-- add this name 
		end
		i = i+1;
	end	
	return output_table;
end

--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	if vparam:find ('%[%[') or vparam:find ('%]%]')	then						-- no wikilinking vauthors names
		add_vanc_error ('wikilink');
	end
	v_name_table = get_v_name_table (vparam, v_name_table);						-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parentheses to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')								-- remove doubled parntheses
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error ('punctuation');
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
			if is_suffix (first) then											-- if a valid suffix
				suffix = first													-- save it as a suffix and
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end																	-- no suffix error message here because letter combination may be result of Romanization; check for digits?
			last = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error ('missing comma');								-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error ('name');										-- matches a space between two intiials
			end
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error ('initials');									-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first);									-- check first and last before restoring the suffix which may have a non-Latin digit
			if is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '');
			end
		end
																				-- this from extract_names ()
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice incase we have a |first1= without a |last1=; this ...
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or	-- ... also catches the case where |first= is used with |vauthors=
		select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, no, etc).  When the parameter value has not been assigned a value (missing or empty
in the source template) the function refurns true.  If the parameter value is one of the list of allowed values returns
true; else, emits an error message and returns false.

]]

local function is_valid_parameter_value (value, name, possible, cite_class)
-- begin hack to limit |mode=mla to a specific set of templates
	if ('mode' == name) and ('mla' == value) and not in_array (cite_class, {'book', 'journal', 'news'}) then
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
-- end hack

	if not is_set (value) then
		return true;															-- an empty parameter is ok
	elseif in_array(value:lower(), possible) then
		return true;
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list,-1,-1) == sepc) or (string.sub (name_list,-3,-1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terninate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower, mode)
	if not is_set (volume) and not is_set (issue) then
		return '';
	end
	
	if ('mla' == mode) and ('journal' == cite_class) then						-- same as cs1 for magazines
		lower = true;															-- mla 8th edition; force these to lower case
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return '';
		end
	end

	if 'magazine' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end

	local vol = '';
		
	if is_set (volume) then
		if (4 &lt; mw.ustring.len(volume)) then
			vol = substitute (cfg.messages['j-vol'], {sepc, volume});
		else
			vol = substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});
		end
	end
	if is_set (issue) then
		return vol .. substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end


--[[-------------------------&lt; N O R M A L I Z E _ P A G E _ L I S T &gt;-----------------------------------------

not currently used

normalizes a comma, ampersand, and/or space separated list to be '&lt;value&gt;, &lt;value&gt;, ..., &lt;value&gt;'
returns list unchanged if there are no commas else strips whitespace and then reformats the list

]]
--[[
local function normalize_page_list (list)
	if not list:find ('[,&amp; ]') then return list end								-- if list is not delimited with commas, ampersands, or spaces; done
	
	list = mw.text.split (list, '[,&amp;%s]+');										-- make a table of values
	list = table.concat (list, ', ');											-- and now make a normalized list
	return list;
end
]]


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower, mode)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'journal' == origin);
	
	if is_journal and 'mla' == mode then
		is_journal = false;														-- mla always uses p &amp; pp
	end

	if is_set (page) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif is_set(pages) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then										-- if pages is only digits, assume a single page number
			return '', substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org urls to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot url or to calendar pages.  When the archive url is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the url.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org url does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command url
	|archive-url= is an archive.org url that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org urls:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this funct may return a modified
archive url:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the url unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.or url
	
	if not url:match('//web%.archive%.org/') then
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command url, we don't want to allow saving of the target page 
		err_msg = 'save command';
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');		-- split out some of the url parts for evaluation
		
		if not is_set(timestamp) or 14 ~= timestamp:len() then					-- path and flag optional, must have 14-digit timestamp here
			err_msg = 'timestamp';
			if '*' ~= flag then
				url=url:gsub ('(//web%.archive%.org/[^%d]*%d?%d?%d?%d?%d?%d?)[^/]*', '%1*', 1)	-- for preview, modify ts to be yearmo* max (0-6 digits plus splat)
			end
		elseif is_set(path) and 'web/' ~= path then								-- older archive urls do not have the extra 'web/' path element
			err_msg = 'path';
		elseif is_set (flag) and not is_set (path) then							-- flag not allowed with the old form url (without the 'web/' path element)
			err_msg = 'flag';
		elseif is_set (flag) and not flag:match ('%a%a_') then					-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = 'flag';
		else
			return url, date;													-- return archiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	table.insert( z.message_tail, { set_error( 'archive_url', {err_msg}, true ) } );	-- add error message and
	if is_set (Frame:preprocess('{{REVISIONID}}')) then
		return '', '';															-- return empty strings for archiveURL and ArchiveDate
	else
		return url, date;														-- preview mode so return archiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe:
	{{cite ... |title=Title access-date=2016-03-17}}

cs1|2 shares some parameter names with xml/html atributes: class=, title=, etc.  To prevent false positives xml/html
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove xml/html tags because attributes: class=, title=, etc 

	capture = value:match ('%s+(%a[%a%d]+)%s*=') or value:match ('^(%a[%a%d]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then								-- if the capture is a valid parameter name
		add_maint_cat ('missing_pipe');
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

-- set default parameter values defined by |mode= parameter.  If |mode= is empty or omitted, use CitationClass to set these values
	local Mode = A['Mode'];
	if not is_valid_parameter_value (Mode, 'mode', cfg.keywords['mode'], config.CitationClass) then
		Mode = '';
	end

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				add_maint_cat ('authors');										-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Coauthors = A['Coauthors'];
	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
			add_maint_cat ('editors');											-- but add a maint cat because use of this parameter is discouraged
		end
	end

	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	
	local Interviewers = A['Interviewers']
	
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list
	local Contribution = A['Contribution'];
	if in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not is_set (Contribution) then									-- |contributor= requires |contribution=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if select_one (args, cfg.aliases['ContributorList-Last'], 'redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { set_error( 'contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if not is_valid_parameter_value (NameListFormat, 'name-list-format', cfg.keywords['name-list-format']) then			-- only accepted value for this parameter is 'vanc'
		NameListFormat = '';													-- anything else, set to empty string
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
			link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wikimarkup in |title-link= or wikimarkup in |title= when |title-link= is set

	local Chapter = A['Chapter'];
	local ScriptChapter = A['ScriptChapter'];
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];

	local ArchiveDate;
	local ArchiveURL;

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	
	local DeadURL = A['DeadURL']
		if not is_valid_parameter_value (DeadURL, 'dead-url', cfg.keywords ['deadurl']) then	-- set in config.defaults to 'yes'
			DeadURL = '';														-- anything else, set to empty string
		end

	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];
	local Periodical_origin = A:ORIGIN('Periodical');							-- get the name of the periodical parameter

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;
																				-- previously conference books did not support volume
--	if in_array (config.CitationClass, cfg.templates_using_volume) and not ('conference' == config.CitationClass and not is_set (Periodical)) then
	if in_array (config.CitationClass, cfg.templates_using_volume) then
		Volume = A['Volume'];
	end
																				-- conference &amp; map books do not support issue
	if in_array (config.CitationClass, cfg.templates_using_issue) and not (in_array (config.CitationClass, {'conference', 'map'}) and not is_set (Periodical))then
		Issue = A['Issue'];
	end
	local Position = '';
	if not in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash( A['Pages'] );	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
		if not is_valid_parameter_value (RegistrationRequired, 'registration', cfg.keywords ['yes_true_y']) then
			RegistrationRequired=nil;
		end
	local SubscriptionRequired = A['SubscriptionRequired'];
		if not is_valid_parameter_value (SubscriptionRequired, 'subscription', cfg.keywords ['yes_true_y']) then
			SubscriptionRequired=nil;
		end
	local UrlAccess = A['UrlAccess'];
		if not is_valid_parameter_value (UrlAccess, 'url-access', cfg.keywords ['url-access']) then
			UrlAccess = nil;
		end
		if not is_set(URL) and is_set(UrlAccess) then
			UrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {'url'}, true ) } );
		end

		if is_set (UrlAccess) and is_set (SubscriptionRequired) then			-- while not aliases, these are much the same so if both are set
			table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'url-access') .. ' and ' .. wrap_style ('parameter', 'subscription')}, true ) } );		-- add error message
			SubscriptionRequired = nil;											-- unset; prefer |access= over |subscription=
		end
		if is_set (UrlAccess) and is_set (RegistrationRequired) then			-- these are not the same but contradictory so if both are set
			table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'url-access') .. ' and ' .. wrap_style ('parameter', 'registration')}, true ) } );		-- add error message
			RegistrationRequired = nil;											-- unset; prefer |access= over |registration=
		end


	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local Agency = A['Agency'];

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
		if not is_valid_parameter_value (IgnoreISBN, 'ignore-isbn-error', cfg.keywords ['yes_true_y']) then
			IgnoreISBN = nil;													-- anything else, set to empty string
		end
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );
	local ID_access_levels = extract_id_access_levels( args, ID_list );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
		if not is_valid_parameter_value (LastAuthorAmp, 'last-author-amp', cfg.keywords ['yes_true_y']) then
			LastAuthorAmp = nil;												-- set to empty string
		end
		if 'mla' == Mode then												
			LastAuthorAmp = 'yes';												-- replaces last author/editor separator with ' and ' text
		end
	local no_tracking_cats = A['NoTracking'];
		if not is_valid_parameter_value (no_tracking_cats, 'no-tracking', cfg.keywords ['yes_true_y']) then
			no_tracking_cats = nil;												-- set to empty string
		end

--these deprecated parameters are used by cite interview
	local Callsign = A['Callsign'];
	local City = A['City'];
	local Program = A['Program'];

--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = A['DF'];															-- date format set in cs1|2 template
	if not is_valid_parameter_value (DF, 'df', cfg.keywords['date-format']) then	-- validate reformatting keyword
		DF = '';																-- not valid, set to empty string
	end

	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	select_one( args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'redundant_parameters' );		-- this is a dummy call simply to get the error message and category

	local NoPP = A['NoPP'] 
	if is_set (NoPP) and is_valid_parameter_value (NoPP, 'nopp', cfg.keywords ['yes_true_y']) then
		NoPP = true;
	else
		NoPP = nil;																-- unset, used as a flag later
	end

	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Pages = '';															-- unset the others
			At = '';
		end
		extra_text_in_page_check (Page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.
	elseif is_set(Pages) then
		if is_set(At) then
			At = '';															-- unset
		end
		extra_text_in_page_check (Pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped
	|url maps to |chapterurl when |title is remapped

All other combinations of |encyclopedia, |title, and |article are not modified

]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					TransChapter = TransTitle;
					ChapterURL = URL;
					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter= '[[' .. TitleLink .. '|' .. Chapter .. ']]';
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			else																-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if is_set(A['Number']) then												-- cite techreport uses 'number', which other citations alias to 'issue'
			if not is_set(ID) then												-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', 'id') .. ' and ' .. wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

-- special case for cite interview
-- TODO: make cite interview not need any special cases
--[[
Program, Callsign, City deprecated, so avoid using /Configuration
for reassignment, which would allow these parameters' use outside interview
]]
	if (config.CitationClass == &quot;interview&quot;) then
		if is_set(Program) then
			if not is_set(Periodical) then
				Periodical = Program;
			end
		end
		if is_set(Callsign) then
			if not is_set(PublisherName) then
				PublisherName = Callsign;
			end
		end
		if is_set(City) then
			if not is_set(PublicationPlace) then
				PublicationPlace = City;
			end
		end
	end

-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	elseif 'mailinglist' == A:ORIGIN('Periodical') then
		Periodical = '';														-- unset because mailing list is only used for cite mailing list
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];

		link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wikimarkup in |series-link= or wikimarkup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) and is_set (AirDate) then							-- promote airdate to date
			Date = AirDate;
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('series', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = '[[' .. ChapterLink .. '|' .. Chapter .. ']]';		-- ok to wikilink
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = '[[' .. ChapterLink .. '|' .. Series .. ']]';			-- series links with ChapterLink (episodelink -&gt; TitleLink -&gt; ChapterLink) ugly
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = '[[' .. SeriesLink .. '|' .. Series .. ']]';
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
-- end of {{cite episode}} stuff

-- Account for the oddities that are {{cite arxiv}}, before generation of COinS data.
	if 'arxiv' == config.CitationClass then
		if not is_set (ID_list['ARXIV']) then									-- |arxiv= or |eprint= required for cite arxiv
			table.insert( z.message_tail, { set_error( 'arxiv_missing', {}, true ) } );		-- add error message
		elseif is_set (Series) then												-- series is an alias of version
			ID_list['ARXIV'] = ID_list['ARXIV'] .. Series;						-- concatenate version onto the end of the arxiv identifier
			Series = '';														-- unset
			deprecated_parameter ('version');									-- deprecated parameter but only for cite arxiv
		end
		
		if first_set ({AccessDate, At, Authors, Chapter, Format, Page, Pages, Periodical, PublisherName, URL,	-- a crude list of parameters that are not supported by cite arxiv
			ID_list['ASIN'], ID_list['BIBCODE'], ID_list['DOI'], ID_list['ISBN'], ID_list['ISSN'],		-- TODO: find a better way to do this
			ID_list['JFM'], ID_list['JSTOR'], ID_list['LCCN'], ID_list['MR'], ID_list['OCLC'], ID_list['OL'],
			ID_list['OSTI'], ID_list['PMC'], ID_list['PMID'], ID_list['RFC'], ID_list['SSRN'], ID_list['USENETID'], ID_list['ZBL']},27) then
				table.insert( z.message_tail, { set_error( 'arxiv_params_not_supported', {}, true ) } );		-- add error message

				AccessDate = '';												-- set these to empty string; not supported in cite arXiv
				Authors = '';
				PublisherName = '';												-- (if the article has been published, use cite journal, or other)
				Chapter = '';
				URL = '';
				Format = '';
				Page = ''; Pages = ''; At = '';
		end
		Periodical = 'arXiv';													-- set to arXiv for COinS; after that, must be set to empty string
	end

-- handle type parameter for those CS1 citations that have default values
	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;interview&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
		TitleType = substitute( cfg.messages['type'], TitleType);				-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {['access-date']=AccessDate, ['archive-date']=ArchiveDate, ['date']=Date, ['doi-broken-date']=DoiBroken,
				['embargo']=Embargo, ['lay-date']=LayDate, ['publication-date']=PublicationDate, ['year']=Year};

		anchor_year, Embargo, error_message = dates(date_parameters_list, COinS_date);

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end
		
		if not is_set(error_message) then										-- error free dates only
			local modified = false;												-- flag
			if is_set (DF) then													-- if we need to reformat dates
				modified = reformat_dates (date_parameters_list, DF, false);	-- reformat to DF format, use long month names if appropriate
			end

			if true == date_hyphen_to_dash (date_parameters_list) then					-- convert hyphens to dashes where appropriate
				modified = true;
				add_maint_cat ('date_format');									-- hyphens were converted so add maint category
			end
			
			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'];				-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'];
				Date = date_parameters_list['date'];
				DoiBroken = date_parameters_list['doi-broken-date'];
				LayDate = date_parameters_list['lay-date'];
				PublicationDate = date_parameters_list['publication-date'];
			end
		else
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end
	end	-- end of do

-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);											-- 

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
			if is_set(AccessDate) then											-- access date requires |url=; pmc created url is not |url=
				table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
				AccessDate = '';												-- unset
			end

		end
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
			if 'episode' == config.CitationClass then							-- special case for cite episode; TODO: is there a better way to do this?
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
			else
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
			end
	end
	
	if 'none' == Title and in_array (config.CitationClass, {'journal', 'citation'}) and is_set (Periodical) and 'journal' == A:ORIGIN('Periodical') then	-- special case for journal cites
		Title = '';																-- set title to empty string
		add_maint_cat ('untitled');
	end

	check_for_url ({															-- add error message when any of these parameters contains a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[A:ORIGIN('Periodical')]=Periodical,
		[A:ORIGIN('PublisherName')] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = Periodical,
		['Encyclopedia'] = Encyclopedia,
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

-- Account for the oddities that are {{cite arxiv}}, AFTER generation of COinS data.
	if 'arxiv' == config.CitationClass then										-- we have set rft.jtitle in COinS to arXiv, now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in cite arxiv; if article has been published, use cite journal
	end

-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = substitute (cfg.messages['newsgroup'], external_link( 'news:' .. PublisherName, PublisherName, A:ORIGIN('PublisherName'), nil ));
		end
	end



	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text,											-- get current page name so that we don't wikilink to it via editorlinkn
			mode = Mode
		};

		do																		-- do editor name list first because coauthors can modify control table
			control.maximum , editor_etal = get_display_authors_editors (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if is_set (Editors) then
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
					EditorCount = 2;											-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
				else
					EditorCount = 2;											-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
				end
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do translators
			control.maximum = #t;												-- number of translators
			Translators = list_people(control, t, false);						-- et al not currently supported
		end
		do																		-- now do contributors
			control.maximum = #c;												-- number of contributors
			Contributors = list_people(control, c, false);						-- et al not currently supported
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_authors_editors (A['DisplayAuthors'], #a, 'authors', author_etal);

			if is_set(Coauthors) then											-- if the coauthor field is also used, prevent ampersand and et al. formatting.
				control.lastauthoramp = nil;
				control.maximum = #a + 1;
			end
			
			last_first_list = list_people(control, a, author_etal);

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false);	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if is_set (Authors) and is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

		if not is_set(Authors) and is_set(Coauthors) then						-- coauthors aren't displayed if one of authors=, authorn=, or lastn= isn't specified
			table.insert( z.message_tail, { set_error('coauthors_missing_author', {}, true) } );	-- emit error message
		end
	end

-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

-- special case for chapter format so no error message or cat when chapter not supported
	if not (in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'arxiv'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not is_set(URL) then
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then	-- |url= required for cite web, cite podcast, and cite mailinglist
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURLorigin, OriginalFormat, OriginalAccess;
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (ChapterURL) then 											-- URL not set so if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURLorigin = ChapterURLorigin;								-- name of chapter-url parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |format=
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				ChapterURLorigin = A:ORIGIN('ArchiveURL')						-- name of archive-url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
			end
		elseif is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURLorigin = URLorigin;										-- name of url parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived urls
			end
 		end
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'arxiv'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			local chap_param;
			if is_set (Chapter) then											-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif is_set (ScriptChapter) then
				chap_param = A:ORIGIN ('ScriptChapter')
			else is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if is_set (chap_param) then											-- if we found one
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {chap_param}, true ) } );		-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if is_set (Contribution) and 0 &lt; #c then								-- if this is a contribution with contributor(s)
			if in_array (Contribution:lower(), cfg.keywords.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, Chapter, TransChapter, ChapterURL, ChapterURLorigin, no_quotes);		-- Contribution is also in Chapter
		if is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter.. sepc .. ' ';
		elseif is_set (ChapterFormat) then										-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease','podcast', 'newsgroup', 'mailinglist', 'arxiv', 'interview'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end
	
	Title = Title .. TransTitle;
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then
			
			Title = external_link( URL, Title, URLorigin, UrlAccess ) .. TransError .. Format;
-- this experiment hidden 2016-04-10; see Help_talk:Citation_Style_1#Recycled_urls
--			local temp_title = external_link( URL, Title, URLorigin ) .. TransError .. Format;	-- do this so we get error message even if url is usurped no archive
--			if in_array (DeadURL, {'unfit no archive', 'usurped no archive'}) then	-- when url links to inappropriate location and there is no archive of original source available
--				local err_msg
--				if temp_title:match ('%[%S+%s+(.+)%](&lt;.+)') then				-- if there is an error message
--					Title, err_msg = temp_title:match ('%[%S+%s+(.+)%](&lt;.+)');	-- strip off external link; TODO: find a better to do this
--					Title = Title .. (err_msg or '');
--				end
--			else
--				Title = temp_title;
--			end

			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		else
			Title = Title .. TransError;
		end
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURLorigin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin, nil );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if is_set(Minutes) then
			if is_set (Time) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'minutes') .. ' and ' .. wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase, Mode);

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
		if 'mla' == Mode then
			Others = sepc .. ' Trans. ' .. Translators .. Others;
		else
			Others = sepc .. ' ' .. wrap_msg ('translated', Translators, use_lowercase) .. Others;
		end
	end
	if is_set (Interviewers) then
		Others = sepc .. ' ' .. wrap_msg ('interview', Interviewers, use_lowercase) .. Others;
	end
	
	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		if 'mla' == Mode then
			Edition = '. ' .. Edition .. ' ed.';
		else
			Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
		end
	else
		Edition = '';
	end

	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	if 'mla' == Mode then														-- not in brackets for mla
		OrigYear = is_set(OrigYear) and (&quot;. &quot; .. OrigYear) or &quot;&quot;;
	else
		OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	end
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase, Mode);

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

--[[
Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
note is displayed. There are no error messages for this condition.

]]
	if is_set (SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif is_set (RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if 'mla' == Mode then													-- retrieved text not used in mla
			AccessDate = ' ' .. AccessDate;
		else
			if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end			-- if mode is cs2, lower case
			AccessDate = substitute (retrv_text, AccessDate);					-- add retrieved text
		end
		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {IdAccessLevels=ID_access_levels, DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin, Access );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then				-- if first and last characters of quote are quote marks
			Quote = Quote:sub(2,-2);											-- strip them off
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- DeadURL is empty, 'yes', 'true', 'y', 'unfit', 'usurped'
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if in_array (DeadURL, {'unfit', 'usurped', 'bot: unknown'}) then
				Archived = sepc .. &quot; &quot; .. 'Archived from the original on ' .. ArchiveDate;	-- format already styled
				if 'bot: unknown' == DeadURL then
					add_maint_cat ('bot:_unknown');								-- and add a category if not already added
				else
					add_maint_cat ('unfit');									-- and add a category if not already added
				end
			else																-- DeadURL is empty, 'yes', 'true', or 'y'
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURLorigin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURLorigin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin, nil );
	end

	local Publisher;
	if is_set(PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if is_set(PublisherName) then
		if is_set(PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif is_set(PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		if 'mla' == Mode then
			tcommon = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
		else
			tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
				Language, Edition, Publisher, Agency, Volume}, sepc );
		end		
	elseif in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(Periodical) then		-- special cases for book cites
		if is_set (Contributors) then											-- when we are citing foreword, preface, introduction, etc
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			if 'mla' == Mode then
				tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Edition, Publisher, Agency}, sepc );
			else
				tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
			end
		elseif 'mla' == Mode then
			tcommon = safe_join( {TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Transcript, Language, Edition, Publisher}, sepc );

	elseif ('news' == config.CitationClass) and ('mla' == Mode) then			-- special case for cite news in MLA mode
		tcommon = safe_join( {Periodical, Format, TitleType, Series, Language, Edition, Agency}, sepc );

	elseif ('web' == config.CitationClass) and ('mla' == Mode) then				-- special case for cite web in MLA mode
		tcommon = safe_join( {Periodical, Format, TitleType, Series, Language, 
			Edition, Publisher, Agency}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if is_set(Date) then
		if ('mla' == Mode) then
			if in_array (config.CitationClass, {'book', 'news', 'web'}) then
				Date = ', ' .. Date;											-- origyear follows title in mla
			elseif 'journal' == config.CitationClass then
				Date = ', (' .. Date .. ')';
			end
		elseif is_set (Authors) or is_set (Editors) then						-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;;				-- in paranetheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon,-1,-1) == sepc) then							-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigYear;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigYear;							-- Date begins with sepc
			end
		end
	end	
	if is_set(Authors) then
		if is_set(Coauthors) then
			if 'vanc' == NameListFormat then									-- separate authors and coauthors with proper name-list-separator
				Authors = Authors .. ', ' .. Coauthors;
			else
				Authors = Authors .. '; ' .. Coauthors;
			end
		end
		if (not is_set (Date)) or ('mla' == Mode) then							-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) and 0 == #c and 'mla' ~= Mode then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then in_text = in_text:lower() end				-- lowercase for cs2
			elseif is_set(Chapter) and 'mla' == Mode then
				if EditorCount &lt;= 1 then
					in_text = '. Ed. ';
				else
					in_text = '. Eds. ';
				end
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if is_set (Contributors) then											-- book cite and we're citing the intro, preface, etc
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if is_set (Editors) and ('mla' ~= Mode)then											-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not is_set (Date)) or ('mla' == Mode) then											-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			if 'mla' == Mode then
				text = safe_join( {Contributors, Chapter, tcommon, OrigYear, Authors, Place, Others, Editors, tcommon2, Date, pgtext, idcommon }, sepc );
			else
				text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
			end
		elseif 'mla' == Mode then
			tcommon = tcommon .. Date;											-- hack to avoid duplicate separators
			text = safe_join( {Authors, Chapter, Title, OrigYear, Others, Editors, Edition, Place, tcommon, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		if 'mla' == Mode then
			if in_array(config.CitationClass, {'journal', 'news', 'web'}) and is_set(Periodical) then
				text = safe_join( {Editors, Title, Place, tcommon, pgtext, Date, idcommon}, sepc );
			else
				text = safe_join( {Editors, Chapter, Title, Place, tcommon, Date, pgtext, idcommon}, sepc );
			end
		else
			text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
		end
	elseif 'mla' == Mode then
		if in_array(config.CitationClass, {'journal', 'news', 'web'}) and is_set(Periodical) then
			text = safe_join( {Title, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Title, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	else
		if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = config.CitationClass;
		options.class = &quot;citation &quot; .. config.CitationClass;					-- class=citation required for blue highlight when used with |ref=
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then								-- set reference anchor if appropriate
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			if #namelist &gt; 0 then												-- if there are names in namelist
				id = anchor_id (namelist, year);								-- go make the CITEREF anchor
			else
				id = '';														-- unset
			end
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;(.-)&lt;/span&gt;&quot;, &quot;%1&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then	-- remove &lt;span&gt; tags and other html-like markup; then get length of what remains
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then													-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		text = substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text});	-- when |ref= is set
	else
		text = substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text});	-- all other cases
	end		

	text = text .. substitute (cfg.presentation['ocins'], {OCinSoutput});		-- append metadata to the citation
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. error_comment( v[1], v[2] );
				else
					text = text .. error_comment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end

	if #z.maintenance_cats ~= 0 then
		text = text .. '&lt;span class=&quot;citation-comment&quot; style=&quot;display:none; color:#33aa33&quot;&gt;';
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. ' ' .. v .. ' ([[:Category:' .. v ..'|link]])';
		end
		text = text .. '&lt;/span&gt;';	-- maintenance mesages (realy just the names of the categories for now)
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end

--[[--------------------------&lt; C S 1 . C I T A T I O N &gt;------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

function cs1.citation(frame)
	Frame = frame;																-- save a copy incase we need to display an error message in preview mode
	local pframe = frame:getParent()
	local validation, utilities, identifiers, metadata;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (utilities);								-- so that functions in Date validataion can see the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	dates = validation.dates;													-- imported functions from Module:Citation/CS1/Date validation
	year_date_check = validation.year_date_check;
	reformat_dates = validation.reformat_dates;
	date_hyphen_to_dash = validation.date_hyphen_to_dash;
	
	is_set = utilities.is_set;													-- imported functions from Module:Citation/CS1/Utilities
	in_array = utilities.in_array;
	substitute = utilities.substitute;
	error_comment = utilities.error_comment;
	set_error = utilities.set_error;
	select_one = utilities.select_one;
	add_maint_cat = utilities.add_maint_cat;
	wrap_style = utilities.wrap_style;
	safe_for_italics = utilities.safe_for_italics;
	remove_wiki_link = utilities.remove_wiki_link;

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	extract_ids = identifiers.extract_ids;										-- imported functions from Module:Citation/CS1/Utilities
	build_id_list = identifiers.build_id_list;
	is_embargoed = identifiers.is_embargoed;
	extract_id_access_levels = identifiers.extract_id_access_levels;
	
	make_coins_title = metadata.make_coins_title;								-- imported functions from Module:Citation/CS1/COinS
	get_coins_pages = metadata.get_coins_pages;
	COinS = metadata.COinS;

	local args = {};
	local suggestions = {};
	local error_text, error_state;

	local config = {};
	for k, v in pairs( frame.args ) do
		config[k] = v;
		args[k] = v;	   
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower() ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute( param, capture );				-- add the capture to the suggested parameter (typically the enumerator)
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, param}, true );	-- set the error message
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			missing_pipe_check (v);												-- do we think that there is a parameter that is missing a pipe?
			
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);
		end
	end
	return citation0( config, args)
end

return cs1;</text>
      <sha1>0l8kczoetghhj1q5rqovvclu7grxwyn</sha1>
    </revision>
    <revision>
      <id>4714</id>
      <parentid>4713</parentid>
      <timestamp>2017-04-29T09:52:22Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>synch from sandbox;</comment>
      <origin>4714</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="167615" sha1="j0uqqa3frjxvinh9e9lg5413iaw2znz" xml:space="preserve">
local cs1 ={};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local dates, year_date_check, reformat_dates, date_hyphen_to_dash				-- functions in Module:Citation/CS1/Date_validation

local is_set, in_array, substitute, error_comment, set_error, select_one,		-- functions in Module:Citation/CS1/Utilities
	add_maint_cat, wrap_style, safe_for_italics, remove_wiki_link;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local extract_ids, extract_id_access_levels, build_id_list, is_embargoed;		-- functions in Module:Citation/CS1/Identifiers

local make_coins_title, get_coins_pages, COinS;									-- functions in Module:Citation/CS1/COinS

local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

delare variables here that have page-wide scope that are not brought in from other modules; thatare created here
and used here

]]

local added_deprecated_cat;														-- boolean flag so that the category is added only once
local added_prop_cats = {};														-- list of property categories that have been added to z.properties_cats
local added_vanc_errs;															-- boolean flag so we only emit one Vancouver error / category

local Frame;																	-- holds the module's frame table


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end

--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

added_prop_cats is a table declared in page scope variables above

]]

local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));		-- make name then add to table
	end
end

--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a boolean declared in page scope variables above

]]

local function add_vanc_error (source)
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {source}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a uri scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of tlds: https://www.iana.org/domains/root/db

rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the tld.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a url with a scheme) will be stripped
here.  Perhaps not necessary but retained incase it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ascii characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the tld) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org TLD
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and tld or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%a%d]') then										-- first character must be letter or digit
		return false;
	end
																				-- Do most common case first
	if domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.%a%a+$') then				-- three or more character hostname.hostname or hostname.tld
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.xn%-%-[%a%d]+$') then	-- internationalized domain name with ACE prefix
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.org$') then							-- one character .org hostname
		return true;
	elseif domain:match ('%f[%a][qxz]%.com$') then								-- assigned one character .com hostname (x.com times out 2015-12-10)
		return true;
	elseif domain:match ('%f[%a][iq]%.net$') then								-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.%a%a$') then							-- one character hostname and cctld (2 chars)
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d]%.%a%a+$') then					-- two character hostname and tld
		return true;
	elseif domain:match ('^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?') then		-- IPv4 address
		return true;
	else
		return false;
	end
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a url appear to be a valid url; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if is_set (scheme) then														-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when url is protocol relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a url into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following tld) (if any) and any path(/), query(?) or fragment(#).

If protocol relative url, return nil scheme and domain else return nil for both scheme and domain.

When not protocol relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol relative url
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		authority = authority:gsub ('//', '', 1);								-- replace place 1 pair of '/' with nothing;
		if is_set(authority) then												-- if anything left (1 or 3+ '/' where authority should be) then
			return scheme;														-- return scheme only making domain nil which will cause an error message
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link= etc for properly formatted content: no wikilinks, no urls

Link parameters are to hold the title of a wikipedia article so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki urls and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid url (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid url (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from url; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid url
end

--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wikilinked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

]]

local function link_title_ok (link, lorig, title, torig)
local orig;

	if is_set (link) then 														-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		end
	end

	if is_set (orig) then
		table.insert( z.message_tail, { set_error( 'bad_paramlink', orig)});	-- url or wikilink in |title= with |title-link=;
	end
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the url into scheme and domain
portions, or for protocol relative (//example.com) urls, just the domain.  Use is_url() to validate the two
portions of the url.  If both are valid, or for protocol relative if domain is valid, return true, else false.

Because it is different from a standard url, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper url
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from url;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a url.  The test will also find external wikilinks
that use protocol relative urls. Also finds bare urls.

The frontier pattern prevents a match on interwiki links which are similar to scheme:path urls.  The tests that
find bracketed urls are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol relative ext wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare url with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol relative bare url: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a url
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then												-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source, access)
	local error_str = &quot;&quot;;
	local domain;
	local path;
	local base_url;
	
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the url into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['[']='%5b',[']']='%5d'});					-- replace '[' and ']' with their percent encoded values
		URL=domain..path;														-- and reassemble
	end
	
	if is_set (access) then														-- access level (subscription, registration, limited)
		local label_head = '';
		local label_tail;
		local markup = '';														-- can't start a span inside italic markup and end it outside the italic markup

		label = safe_for_url (label);											-- replace square brackets and newlines (is this necessary? already done above?)
		if label:match (&quot;(.*)%s+(.+)('''?)$&quot;) then								-- for italicized titles (cite book, etc)
			label_head, label_tail, markup = label:match (&quot;(.*)%s+(.+)('''?)$&quot;);	-- split the label at the right-most space; separate the markup
		elseif label:match (&quot;(.*)%s+(.+)$&quot;) then								-- for upright titles (journal, news, magazine, etc)
			label_head, label_tail = label:match (&quot;(.*)%s+(.+)$&quot;);				-- split the label at the right-most space; no markup 
		elseif label:match (&quot;(.+)('''?)$&quot;) then									-- single word label with markup
			label_tail, markup = label:match (&quot;(.+)('''?)$&quot;);					-- save label text as label tail; separate the markup
		else
			label_tail = label;
		end

		base_url = table.concat (
			{
			'&lt;span class=&quot;plainlinks&quot;&gt;[',										-- opening css
			URL,																-- the url
			' ',																-- the required space
			label_head,															-- all but the last word of the label
			' &lt;span class=&quot;nowrap&quot;&gt;',											-- nowrap css for the last word and the signal icon
			label_tail,															-- last (or only) word of the label inside the span
			'&lt;span style=&quot;padding-left:0.15em&quot;&gt;',								-- signal spacing css
			cfg.presentation[access],											-- the appropriate icon
			'&lt;/span&gt;&lt;/span&gt;',													-- close signal spacing and nowrap spans
			markup,																-- insert italic markup if any
			']&lt;/span&gt;'															-- close the plain links span
			});
	else
		base_url = table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url( label ), &quot;]&quot; });	-- no signal markup
	end
	
	return table.concat({ base_url, error_str });
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end

--[[--------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Replaces unicode quotemarks with typewriter quote marks regardless of the need for kerning.

Call this function for chapter titles, for website titles, etc; not for book titles.

]]

local function kern_quotes (str)
	local cap='';
	local cap2='';
																				-- TODO: move this elswhere so that all title-holding elements get these quote marks replaced?
	str= mw.ustring.gsub (str, '[“”]', '\&quot;');									-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
	str= mw.ustring.gsub (str, '[‘’]', '\'');									-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)
	
	cap, cap2 = str:match (&quot;^([\&quot;\'])([^\'].+)&quot;);								-- match leading double or single quote but not double single quotes
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-left'], {cap, cap2});
	end

	cap, cap2 = str:match (&quot;^(.+[^\'])([\&quot;\'])$&quot;)
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-right'], {cap, cap2});
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title= and |script-chapter=

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, cfg.script_lang_codes) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				add_prop_cat ('script')
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return substitute( msg, str );										-- including template text
	else
		return substitute( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (scriptchapter, chapter, transchapter, chapterurl, chapter_url_source, no_quotes)
	local chapter_error = '';
	
	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);										-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
			chapter = wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, scriptchapter)						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (transchapter) then
		transchapter = wrap_style ('trans-quoted-title', transchapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. transchapter;
		else																	-- here when transchapter without chapter or script-chapter
			chapter = transchapter;												-- 
			chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
		end
	end

	if is_set (chapterurl) then
		chapter = external_link (chapterurl, chapter, chapter_url_source, nil);		-- adds bare_url_missing_title error if appropriate
	end

	return chapter .. chapter_error;
end

--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Detects but ignores the character pattern that results from the transclusion of {{'}} templates.

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i=1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- Test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position then
			if 'nowiki' == capture or 'math' == capture then 					-- nowiki, math stripmarker (not an error condition)
				stripmarker = true;												-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { set_error( 'invisible_char', {err_msg, wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i=i+1;																	-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

--local function validate( name )
local function validate( name, cite_class )
	local name = tostring( name );
	local state;
	
	if in_array (cite_class, {'arxiv', 'biorxiv', 'citeseerx'}) then				-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[ name ];
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end

		if 'arxiv' == cite_class then											-- basic parameters unique to these templates
			state = whitelist.arxiv_basic_arguments[name];
		end
		if 'biorxiv' == cite_class then
			state = whitelist.biorxiv_basic_arguments[name];
		end
		if 'citeseerx' == cite_class then
			state = whitelist.citeseerx_basic_arguments[name];
		end

		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
																				-- limited enumerated parameters list
		name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#)
		state = whitelist.limited_numbered_arguments[ name ];
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates
		
	state = whitelist.basic_arguments[ name ];									-- all other templates; all normal parameters allowed
											
	if true == state then return true; end										-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);											-- parameter is deprecated but still supported
		return true;
	end
																				-- all enumerated parameters allowed
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );												-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];

	if true == state then return true; end										-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);											-- parameter is deprecated but still supported
		return true;
	end
	
	return false;																-- not supported because not found or name is set to nil
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end

--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash

]]

local function hyphen_to_dash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if comp:sub(1,1) == duplicate_char then								-- is first charactier same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for th
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = str:sub(-1,-1);										-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = str:sub(1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = str:sub(1, -4) .. &quot;''&quot;;							-- remove them and add back ''
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then		-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then		-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then			-- if last two chars of str are sepc] external link
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;'']&quot; then		-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then				-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = str:sub(1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end		-- if duplicate_char not a letter then escape it
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )			-- remove duplicate_char if it follows html markup
					else
						value = value:sub( 2, -1 );								-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end  


--[[--------------------------&lt; I S _ S U F F I X &gt;------------------------------------------------------------

returns true is suffix is properly formed Jr, Sr, or ordinal in the range 2–9.  Puncutation not allowed.

]]

local function is_suffix (suffix)
	if in_array (suffix, {'Jr', 'Sr', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end

--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written ouside of the code editor and pasted here because the code editor gets confused between character insertion point and cursor position.
The test has been rewritten to use decimal character escape sequence for the individual bytes of the unicode characters so that it is not necessary
to use an external editor to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first)
	local first, suffix = first:match ('(.-),?%s*([%dJS][%drndth]+)%.?$') or first;		-- if first has something that looks like a generational suffix, get it

	if is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error ('suffix');
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error ('non-Latin character');
			return false;														-- not a string of latin characters; Vancouver requires Romanization
	end;
	return true;
end

--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just intials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error ('suffix');									-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word


	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i],1,1));				-- insert the intial at end of initials table
		end
		i = i+1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end

--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = ',';																-- name-list separator between authors is a comma
		namesep = ' ';															-- last/first separator is a space
	elseif 'mla' == control.mode then
		sep = ',';																-- name-list separator between authors is a comma
		namesep = ', '															-- last/first separator is &lt;comma&gt;&lt;space&gt;
	else
		sep = ';'																-- name-list separator between authors is a semicolon
		namesep = ', '															-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then
					if 'mla' == control.mode then 
						if i == 1 then											-- for mla
							one = one .. namesep .. first;						-- first name last, first
						else													-- all other names
							one = first .. ' ' .. one;							-- first last
						end
					else
						if ( &quot;vanc&quot; == format ) then								-- if vancouver format
							one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
							if not person.corporate and is_good_vanc_name (one, first) then					-- and name is all Latin characters; corporate authors not tested
								first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
							end
						end
						one = one .. namesep .. first;
					end
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;				-- link author/editor if this page is not the author's/editor's page
				end
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			if 'mla' == control.mode then
				text[#text-2] = &quot;, and &quot;;										-- replace last separator with ', and ' text
			else
				text[#text-2] = &quot; &amp; &quot;;											-- replace last separator with ampersand text
			end
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end

--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]
local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of author and editor name parameters for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the parameters |display-authors=etal or |display-editors=etal

]]

local function name_has_etal (name, etal, nocat)

	if is_set (name) then														-- name can be nil in which case just return
		local etal_pattern = &quot;[;,]? *[\&quot;']*%f[%a][Ee][Tt] *[Aa][Ll][%.\&quot;']*$&quot;	-- variations on the 'et al' theme
		local others_pattern = &quot;[;,]? *%f[%a]and [Oo]thers&quot;;					-- and alternate to et al.
		
		if name:match (etal_pattern) then										-- variants on et al.
			name = name:gsub (etal_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		elseif name:match (others_pattern) then									-- if not 'et al.', then 'and others'?
			name = name:gsub (others_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		end
	end
	return name, etal;															-- 
end


--[[--------------------------&lt; N A M E _ H A S _ E D _ M A R K U P &gt;------------------------------------------

Evaluates the content of author and editor parameters for extranious editor annotations: ed, ed., eds, (Ed.), etc.
These annotation do not belong in author parameters and are redundant in editor parameters.  If found, the function
adds the editor markup maintenance category.

]]

local function name_has_ed_markup (name, list_name)
	local _, pattern;
	local patterns = {															-- these patterns match annotations at end of name
		'%f[%(%[][%(%[]%s*[Ee][Dd][Ss]?%.?%s*[%)%]]?$',							-- (ed) or (eds): leading '(', case insensitive 'ed', optional 's', '.' and/or ')'
		'[,%.%s]%f[e]eds?%.?$',													-- ed or eds: without '('or ')'; case sensitive (ED could be initials Ed could be name)
		'%f[%(%[][%(%[]%s*[Ee][Dd][Ii][Tt][Oo][Rr][Ss]?%.?%s*[%)%]]?$',			-- (editor) or (editors): leading '(', case insensitive, optional '.' and/or ')'
		'[,%.%s]%f[Ee][Ee][Dd][Ii][Tt][Oo][Rr][Ss]?%.?$',						-- editor or editors: without '('or ')'; case insensitive
		
																				-- these patterns match annotations at beginning of name
		'^eds?[%.,;]',															-- ed. or eds.: lower case only, optional 's', requires '.'
		'^[%(%[]%s*[Ee][Dd][Ss]?%.?%s*[%)%]]',									-- (ed) or (eds): also sqare brackets, case insensitive, optional 's', '.'
		'^[%(%[]?%s*[Ee][Dd][Ii][Tt][Oo][Rr][Ss]?%A',							-- (editor or (editors: also sq brackets, case insensitive, optional brackets, 's'
		'^[%(%[]?%s*[Ee][Dd][Ii][Tt][Ee][Dd]%A',								-- (edited: also sq brackets, case insensitive, optional brackets

		}

	if is_set (name) then
		for _, pattern in ipairs (patterns) do									-- spin through patterns table and
			if name:match (pattern) then
				add_maint_cat ('extra_text_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
				break;
			end
		end
	end
	return name;																-- and done
end


--[[--------------------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;----------------------------------------

Evaluates the content of author and editor (surnames only) parameters for multiple names.  Multiple names are
indicated if there is more than one comma and or semicolon.  If found, the function adds the multiple name
(author or editor) maintenance category.

]]

local function name_has_mult_names (name, list_name)
local count, _;
	if is_set (name) then
		_, count = name:gsub ('[;,]', '');										-- count the number of separator-like characters
		
		if 1 &lt; count then														-- param could be |author= or |editor= so one separator character is acceptable
			add_maint_cat ('mult_names', cfg.special_case_translation [list_name]);	-- more than one separator indicates multiple names so add a maint cat for this template
		end
	end
	return name;																-- and done
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------
This function calls various name checking functions used to validate the content of the various name-holding
parameters.

]]

local function name_checks (last, first, list_name)
	if is_set (last) then
		if last:match ('^%(%(.*%)%)$') then										-- if wrapped in doubled parentheses, accept as written 
			last = last:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			last = name_has_mult_names (last, list_name);						-- check for multiple names in the parameter (last only)
			last = name_has_ed_markup (last, list_name);						-- check for extraneous 'editor' annotation
		end
	end
	if is_set (first) then
		if first:match ('^%(%(.*%)%)$') then									-- if wrapped in doubled parentheses, accept as written 
			first = first:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			first = name_has_ed_markup (first, list_name);						-- check for extraneous 'editor' annotation
		end
	end
	return last, first;															-- done
	end


--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary
	while true do
		last = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false);							-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false);						-- find and remove variations on et al.
		last, first= name_checks (last, first, list_name);						-- multiple names, extraneous annotation, etc checks
		
		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			link_title_ok (link, list_name:match (&quot;(%w+)List&quot;):lower() .. '-link' .. i, last, list_name:match (&quot;(%w+)List&quot;):lower() .. '-last' .. i);	-- check for improper wikimarkup

			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because case of the source may be incorrect
or different from the case that WikiMedia uses, the name comparisons are done in lower case and when a match is
found, the Wikimedia version (assumed to be correct) is returned along with the code.  When there is no match, we
return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') return a list of languages that in some cases may include
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.

Names but that are included in the list will be found if that name is provided in the |language= parameter.  For example,
if |language=Chavacano de Zamboanga, that name will be found with the associated code 'cbk-zam'.  When names are found
and the associated code is not two or three characters, this function returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	if 'bangla' == lang:lower() then											-- special case related to Wikimedia remap of code 'bn' at mw:Extension:CLDR
		return 'Bengali', 'bn';													-- make sure rendered version is properly capitalized
	end

	local languages = mw.language.fetchLanguageNames(this_wiki_code, 'all')		-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() and 3 ~= code:len() then							-- two- or three-character codes only; extensions not supported
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the the code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for the code
end


--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code is recognized by MediaWiki,
use the returned name; if not, then use the value that was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is assigned to the category for
that code: Category:Norwegian-language sources (no).  For valid three-character code languages, the page is assigned
to the single category for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does not recognize three-character
equivalents of two-character codes: code 'ar' is recognized bit code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are
separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki = mw.getContentLanguage();									-- get a language object for this wiki
	local this_wiki_code = this_wiki:getCode()									-- get this wiki's language code
	local this_wiki_name = mw.language.fetchLanguageName(this_wiki_code, this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang

		if lang:match ('^%a%a%-') then											-- strip ietf language tags from code; TODO: is there a need to support 3-char with tag?
			lang = lang:match ('(%a%a)%-')										-- keep only 639-1 code portion to lang; TODO: do something with 3166 alpha 2 country code?
		end
		if 2 == lang:len() or 3 == lang:len() then								-- if two-or three-character code
			name = mw.language.fetchLanguageName( lang:lower(), this_wiki_code);	-- get language name if |language= is a proper code
		end
	
		if is_set (name) then													-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, this_wiki_code);				-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then													-- only 2- or 3-character codes
			if 'bn' == code then name = 'Bengali' end;							-- override wikimedia when code is 'bn'
			if this_wiki_code ~= code then										-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					add_prop_cat ('foreign_lang_source', {name, code})			-- categorize it
				else															-- or is a recognized language (but has a three-character code)
					add_prop_cat ('foreign_lang_source_2', {code})				-- categorize it differently TODO: support mutliple three-character code categories per cs1|2 template
				end
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, ' and ')							-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		language_list[code] = 'and ' .. language_list[code];					-- prepend last name with 'and&lt;space&gt;'
		name = table.concat (language_list, ', ')								-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
	end
	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end

--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = '.';																-- terminate the rendered citation with a period
	end
	return '.', ps;																-- separator is a full stop
end

--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = '';																-- make sure it isn't nil
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return ',', ps, ref;														-- separator is a comma
end

--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	elseif 'mla' == mode then													-- if this template is to be rendered in mla style use cs1 for bot cs1 &amp; cs2 templates
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end

--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extension, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf[%?#]?') or url:match ('%.PDF[%?#]?');
end

--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parenthases, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end

--[[--------------------------&lt; G E T _ D I S P L A Y _ A U T H O R S _ E D I T O R S &gt;------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_authors_editors (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_auth_ed', cfg.special_case_translation [list_name]);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end

--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
--	local good_pattern = '^P[^%.P%l]';
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
--	local bad_pattern = '^[Pp][Pp]';
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
--		if Page:match ('^[Pp]?[Pp]%.?[ %d]') or  Page:match ('^[Pp]ages?[ %d]') or
--			Pages:match ('^[Pp]?[Pp]%.?[ %d]') or  Pages:match ('^[Pp]ages?[ %d]') then
--				add_maint_cat ('extra_text');
--		end
end

--[[--------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vautthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parnetheses were included in the
rendered citation and in the metadata.

	|vauthors=Jones AB, White EB, ((Black, Brown, and Co.))

This code is experimental and may not be retained.

]]
local function get_v_name_table (vparam, output_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parens
			local name = name_table[i];
			i=i+1;																-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parens
					break;														-- and done reassembling so
				end
				i=i+1;															-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
		else
			table.insert (output_table, name_table[i]);							-- add this name 
		end
		i = i+1;
	end	
	return output_table;
end

--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	if vparam:find ('%[%[') or vparam:find ('%]%]')	then						-- no wikilinking vauthors names
		add_vanc_error ('wikilink');
	end
	v_name_table = get_v_name_table (vparam, v_name_table);						-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parentheses to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')								-- remove doubled parntheses
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error ('punctuation');
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
			if is_suffix (first) then											-- if a valid suffix
				suffix = first													-- save it as a suffix and
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end																	-- no suffix error message here because letter combination may be result of Romanization; check for digits?
			last = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error ('missing comma');								-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error ('name');										-- matches a space between two intiials
			end
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error ('initials');									-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first);									-- check first and last before restoring the suffix which may have a non-Latin digit
			if is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '');
			end
		end
																				-- this from extract_names ()
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice incase we have a |first1= without a |last1=; this ...
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or	-- ... also catches the case where |first= is used with |vauthors=
		select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, no, etc).  When the parameter value has not been assigned a value (missing or empty
in the source template) the function refurns true.  If the parameter value is one of the list of allowed values returns
true; else, emits an error message and returns false.

]]

local function is_valid_parameter_value (value, name, possible, cite_class)
-- begin hack to limit |mode=mla to a specific set of templates
	if ('mode' == name) and ('mla' == value) and not in_array (cite_class, {'book', 'journal', 'news'}) then
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
-- end hack

	if not is_set (value) then
		return true;															-- an empty parameter is ok
	elseif in_array(value:lower(), possible) then
		return true;
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list,-3,-1) == sepc .. '. ') then						-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list,-1,-1) == sepc) or (string.sub (name_list,-3,-1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terninate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower, mode)
	if not is_set (volume) and not is_set (issue) then
		return '';
	end
	
	if ('mla' == mode) and ('journal' == cite_class) then						-- same as cs1 for magazines
		lower = true;															-- mla 8th edition; force these to lower case
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return '';
		end
	end

	if 'magazine' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end

	local vol = '';
		
	if is_set (volume) then
		if (4 &lt; mw.ustring.len(volume)) then
			vol = substitute (cfg.messages['j-vol'], {sepc, volume});
		else
			vol = substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});
		end
	end
	if is_set (issue) then
		return vol .. substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end


--[[-------------------------&lt; N O R M A L I Z E _ P A G E _ L I S T &gt;-----------------------------------------

not currently used

normalizes a comma, ampersand, and/or space separated list to be '&lt;value&gt;, &lt;value&gt;, ..., &lt;value&gt;'
returns list unchanged if there are no commas else strips whitespace and then reformats the list

]]
--[[
local function normalize_page_list (list)
	if not list:find ('[,&amp; ]') then return list end								-- if list is not delimited with commas, ampersands, or spaces; done
	
	list = mw.text.split (list, '[,&amp;%s]+');										-- make a table of values
	list = table.concat (list, ', ');											-- and now make a normalized list
	return list;
end
]]


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower, mode)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'journal' == origin);
	
	if is_journal and 'mla' == mode then
		is_journal = false;														-- mla always uses p &amp; pp
	end

	if is_set (page) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif is_set(pages) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then										-- if pages is only digits, assume a single page number
			return '', substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org urls to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot url or to calendar pages.  When the archive url is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the url.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org url does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command url
	|archive-url= is an archive.org url that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org urls:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this funct may return a modified
archive url:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the url unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.or url
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine url
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command url, we don't want to allow saving of the target page 
		err_msg = 'save command';
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = 'liveweb';
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');		-- split out some of the url parts for evaluation
		
		if not is_set(timestamp) or 14 ~= timestamp:len() then					-- path and flag optional, must have 14-digit timestamp here
			err_msg = 'timestamp';
			if '*' ~= flag then
				url=url:gsub ('(//web%.archive%.org/[^%d]*%d?%d?%d?%d?%d?%d?)[^/]*', '%1*', 1)	-- for preview, modify ts to be yearmo* max (0-6 digits plus splat)
			end
		elseif is_set(path) and 'web/' ~= path then								-- older archive urls do not have the extra 'web/' path element
			err_msg = 'path';
		elseif is_set (flag) and not is_set (path) then							-- flag not allowed with the old form url (without the 'web/' path element)
			err_msg = 'flag';
		elseif is_set (flag) and not flag:match ('%a%a_') then					-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = 'flag';
		else
			return url, date;													-- return archiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	table.insert( z.message_tail, { set_error( 'archive_url', {err_msg}, true ) } );	-- add error message and
	if is_set (Frame:preprocess('{{REVISIONID}}')) then
		return '', '';															-- return empty strings for archiveURL and ArchiveDate
	else
		return url, date;														-- preview mode so return archiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe:
	{{cite ... |title=Title access-date=2016-03-17}}

cs1|2 shares some parameter names with xml/html atributes: class=, title=, etc.  To prevent false positives xml/html
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove xml/html tags because attributes: class=, title=, etc 

	capture = value:match ('%s+(%a[%a%d]+)%s*=') or value:match ('^(%a[%a%d]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then								-- if the capture is a valid parameter name
		add_maint_cat ('missing_pipe');
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

-- set default parameter values defined by |mode= parameter.  If |mode= is empty or omitted, use CitationClass to set these values
	local Mode = A['Mode'];
	if not is_valid_parameter_value (Mode, 'mode', cfg.keywords['mode'], config.CitationClass) then
		Mode = '';
	end

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				add_maint_cat ('authors');										-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
			add_maint_cat ('editors');											-- but add a maint cat because use of this parameter is discouraged
		end
	end

	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	

	local interviewers_list = {};
	local Interviewers = A['Interviewers']
	if is_set (Interviewers) then												-- add a maint cat if the |interviewers= is used
		add_maint_cat ('interviewers');											-- because use of this parameter is discouraged
	else
		interviewers_list = extract_names (args, 'InterviewerList');			-- else, process preferred interviewers parameters
	end

	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list
	local Contribution = A['Contribution'];
	if in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not is_set (Contribution) then									-- |contributor= requires |contribution=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if select_one (args, cfg.aliases['ContributorList-Last'], 'redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { set_error( 'contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if not is_valid_parameter_value (NameListFormat, 'name-list-format', cfg.keywords['name-list-format']) then			-- only accepted value for this parameter is 'vanc'
		NameListFormat = '';													-- anything else, set to empty string
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
			link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wikimarkup in |title-link= or wikimarkup in |title= when |title-link= is set

	local Chapter = A['Chapter'];
	local ScriptChapter = A['ScriptChapter'];
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];

	local ArchiveDate;
	local ArchiveURL;

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	
	local DeadURL = A['DeadURL']
		if not is_valid_parameter_value (DeadURL, 'dead-url', cfg.keywords ['deadurl']) then	-- set in config.defaults to 'yes'
			DeadURL = '';														-- anything else, set to empty string
		end

	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];
	local Periodical_origin = A:ORIGIN('Periodical');							-- get the name of the periodical parameter

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;
																				-- previously conference books did not support volume
--	if in_array (config.CitationClass, cfg.templates_using_volume) and not ('conference' == config.CitationClass and not is_set (Periodical)) then
	if in_array (config.CitationClass, cfg.templates_using_volume) then
		Volume = A['Volume'];
	end
																				-- conference &amp; map books do not support issue
	if in_array (config.CitationClass, cfg.templates_using_issue) and not (in_array (config.CitationClass, {'conference', 'map'}) and not is_set (Periodical))then
		Issue = A['Issue'];
	end
	local Position = '';
	if not in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash( A['Pages'] );	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
		if not is_valid_parameter_value (RegistrationRequired, 'registration', cfg.keywords ['yes_true_y']) then
			RegistrationRequired=nil;
		end
	local SubscriptionRequired = A['SubscriptionRequired'];
		if not is_valid_parameter_value (SubscriptionRequired, 'subscription', cfg.keywords ['yes_true_y']) then
			SubscriptionRequired=nil;
		end
	local UrlAccess = A['UrlAccess'];
		if not is_valid_parameter_value (UrlAccess, 'url-access', cfg.keywords ['url-access']) then
			UrlAccess = nil;
		end
		if not is_set(URL) and is_set(UrlAccess) then
			UrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {'url'}, true ) } );
		end

		if is_set (UrlAccess) and is_set (SubscriptionRequired) then			-- while not aliases, these are much the same so if both are set
			table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'url-access') .. ' and ' .. wrap_style ('parameter', 'subscription')}, true ) } );		-- add error message
			SubscriptionRequired = nil;											-- unset; prefer |access= over |subscription=
		end
		if is_set (UrlAccess) and is_set (RegistrationRequired) then			-- these are not the same but contradictory so if both are set
			table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'url-access') .. ' and ' .. wrap_style ('parameter', 'registration')}, true ) } );		-- add error message
			RegistrationRequired = nil;											-- unset; prefer |access= over |registration=
		end


	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local Agency = A['Agency'];

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
		if not is_valid_parameter_value (IgnoreISBN, 'ignore-isbn-error', cfg.keywords ['yes_true_y']) then
			IgnoreISBN = nil;													-- anything else, set to empty string
		end
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );
	local ID_access_levels = extract_id_access_levels( args, ID_list );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
		if not is_valid_parameter_value (LastAuthorAmp, 'last-author-amp', cfg.keywords ['yes_true_y']) then
			LastAuthorAmp = nil;												-- set to empty string
		end
		if 'mla' == Mode then												
			LastAuthorAmp = 'yes';												-- replaces last author/editor separator with ' and ' text
		end
	local no_tracking_cats = A['NoTracking'];
		if not is_valid_parameter_value (no_tracking_cats, 'no-tracking', cfg.keywords ['yes_true_y']) then
			no_tracking_cats = nil;												-- set to empty string
		end

--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = A['DF'];															-- date format set in cs1|2 template
	if not is_valid_parameter_value (DF, 'df', cfg.keywords['date-format']) then	-- validate reformatting keyword
		DF = '';																-- not valid, set to empty string
	end

	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	select_one( args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'redundant_parameters' );		-- this is a dummy call simply to get the error message and category

	local NoPP = A['NoPP'] 
	if is_set (NoPP) and is_valid_parameter_value (NoPP, 'nopp', cfg.keywords ['yes_true_y']) then
		NoPP = true;
	else
		NoPP = nil;																-- unset, used as a flag later
	end

	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Pages = '';															-- unset the others
			At = '';
		end
		extra_text_in_page_check (Page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.
	elseif is_set(Pages) then
		if is_set(At) then
			At = '';															-- unset
		end
		extra_text_in_page_check (Pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped
	|url maps to |chapterurl when |title is remapped

All other combinations of |encyclopedia, |title, and |article are not modified

]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					TransChapter = TransTitle;
					ChapterURL = URL;
					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter= '[[' .. TitleLink .. '|' .. Chapter .. ']]';
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			else																-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if is_set(A['Number']) then												-- cite techreport uses 'number', which other citations alias to 'issue'
			if not is_set(ID) then												-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', 'id') .. ' and ' .. wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	elseif 'mailinglist' == A:ORIGIN('Periodical') then
		Periodical = '';														-- unset because mailing list is only used for cite mailing list
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];

		link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wikimarkup in |series-link= or wikimarkup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) and is_set (AirDate) then							-- promote airdate to date
			Date = AirDate;
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('series', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = '[[' .. ChapterLink .. '|' .. Chapter .. ']]';		-- ok to wikilink
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = '[[' .. ChapterLink .. '|' .. Series .. ']]';			-- series links with ChapterLink (episodelink -&gt; TitleLink -&gt; ChapterLink) ugly
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = '[[' .. SeriesLink .. '|' .. Series .. ']]';
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
-- end of {{cite episode}} stuff

-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, before generation of COinS data.
	do
		if in_array (config.CitationClass, {'arxiv', 'biorxiv', 'citeseerx'}) then
			if not is_set (ID_list[config.CitationClass:upper()]) then			-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp; |citeseerx= required for their templates
				table.insert( z.message_tail, { set_error( config.CitationClass .. '_missing', {}, true ) } );		-- add error message
			elseif is_set (Series) then											-- series is an alias of version (deprecated for cite arxiv) (not allowed for biorxiv and citeseerx)
				ID_list['ARXIV'] = ID_list['ARXIV'] .. Series;					-- concatenate version onto the end of the arxiv identifier
				Series = '';													-- unset
			end
			
			if 'arxiv' == config.CitationClass then
				Periodical = 'arXiv';											-- set to arXiv for COinS; after that, must be set to empty string
			end
			if 'biorxiv' == config.CitationClass then
				Periodical = 'bioRxiv';											-- set to bioRxiv for COinS; after that, must be set to empty string
			end
			if 'citeseerx' == config.CitationClass then
				Periodical = 'CiteSeerX';										-- set to CiteSeerX for COinS; after that, must be set to empty string
			end
		end
	end

-- handle type parameter for those CS1 citations that have default values
	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;interview&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
		TitleType = substitute( cfg.messages['type'], TitleType);				-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {['access-date']=AccessDate, ['archive-date']=ArchiveDate, ['date']=Date, ['doi-broken-date']=DoiBroken,
				['embargo']=Embargo, ['lay-date']=LayDate, ['publication-date']=PublicationDate, ['year']=Year};

		anchor_year, Embargo, error_message = dates(date_parameters_list, COinS_date);

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end
		
		if not is_set(error_message) then										-- error free dates only
			local modified = false;												-- flag
			if is_set (DF) then													-- if we need to reformat dates
				modified = reformat_dates (date_parameters_list, DF, false);	-- reformat to DF format, use long month names if appropriate
			end

			if true == date_hyphen_to_dash (date_parameters_list) then					-- convert hyphens to dashes where appropriate
				modified = true;
				add_maint_cat ('date_format');									-- hyphens were converted so add maint category
			end
			
			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'];				-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'];
				Date = date_parameters_list['date'];
				DoiBroken = date_parameters_list['doi-broken-date'];
				LayDate = date_parameters_list['lay-date'];
				PublicationDate = date_parameters_list['publication-date'];
			end
		else
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end
	end	-- end of do

-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);											-- 

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
			if is_set(AccessDate) then											-- access date requires |url=; pmc created url is not |url=
				table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
				AccessDate = '';												-- unset
			end

		end
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
			if 'episode' == config.CitationClass then							-- special case for cite episode; TODO: is there a better way to do this?
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
			else
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
			end
	end
	
	if 'none' == Title and in_array (config.CitationClass, {'journal', 'citation'}) and is_set (Periodical) and 'journal' == A:ORIGIN('Periodical') then	-- special case for journal cites
		Title = '';																-- set title to empty string
		add_maint_cat ('untitled');
	end

	check_for_url ({															-- add error message when any of these parameters contains a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[A:ORIGIN('Periodical')]=Periodical,
		[A:ORIGIN('PublisherName')] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = Periodical,
		['Encyclopedia'] = Encyclopedia,
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

-- Account for the oddities that are {{cite arxiv}}, AFTER generation of COinS data.
--	if 'arxiv' == config.CitationClass then										-- we have set rft.jtitle in COinS to arXiv, now unset so it isn't displayed
	if in_array (config.CitationClass, {'arxiv', 'biorxiv', 'citeseerx'}) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, or CiteSeerX now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = substitute (cfg.messages['newsgroup'], external_link( 'news:' .. PublisherName, PublisherName, A:ORIGIN('PublisherName'), nil ));
		end
	end



	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text,											-- get current page name so that we don't wikilink to it via editorlinkn
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_authors_editors (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if is_set (Editors) then
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
					EditorCount = 2;											-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
				else
					EditorCount = 2;											-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
				end
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum = #interviewers_list;							-- number of interviewerss
			Interviewers = list_people(control, interviewers_list, false);	-- et al not currently supported
		end
		do																		-- now do translators
			control.maximum = #t;												-- number of translators
			Translators = list_people(control, t, false);						-- et al not currently supported
		end
		do																		-- now do contributors
			control.maximum = #c;												-- number of contributors
			Contributors = list_people(control, c, false);						-- et al not currently supported
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_authors_editors (A['DisplayAuthors'], #a, 'authors', author_etal);

			last_first_list = list_people(control, a, author_etal);

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false);	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if is_set (Authors) and is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

-- special case for chapter format so no error message or cat when chapter not supported
	if not (in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not is_set(URL) then
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then	-- |url= required for cite web, cite podcast, and cite mailinglist
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURLorigin, OriginalFormat, OriginalAccess;
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (ChapterURL) then 											-- URL not set so if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURLorigin = ChapterURLorigin;								-- name of chapter-url parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |format=
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				ChapterURLorigin = A:ORIGIN('ArchiveURL')						-- name of archive-url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
			end
		elseif is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURLorigin = URLorigin;										-- name of url parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived urls
			end
 		end
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			local chap_param;
			if is_set (Chapter) then											-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif is_set (ScriptChapter) then
				chap_param = A:ORIGIN ('ScriptChapter')
			else is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if is_set (chap_param) then											-- if we found one
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {chap_param}, true ) } );		-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if is_set (Contribution) and 0 &lt; #c then								-- if this is a contribution with contributor(s)
			if in_array (Contribution:lower(), cfg.keywords.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, Chapter, TransChapter, ChapterURL, ChapterURLorigin, no_quotes);		-- Contribution is also in Chapter
		if is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter.. sepc .. ' ';
		elseif is_set (ChapterFormat) then										-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then
			
			Title = external_link( URL, Title, URLorigin, UrlAccess ) .. TransTitle .. TransError .. Format;
-- this experiment hidden 2016-04-10; see Help_talk:Citation_Style_1#Recycled_urls
--			local temp_title = external_link( URL, Title, URLorigin ) .. TransError .. Format;	-- do this so we get error message even if url is usurped no archive
--			if in_array (DeadURL, {'unfit no archive', 'usurped no archive'}) then	-- when url links to inappropriate location and there is no archive of original source available
--				local err_msg
--				if temp_title:match ('%[%S+%s+(.+)%](&lt;.+)') then				-- if there is an error message
--					Title, err_msg = temp_title:match ('%[%S+%s+(.+)%](&lt;.+)');	-- strip off external link; TODO: find a better to do this
--					Title = Title .. (err_msg or '');
--				end
--			else
--				Title = temp_title;
--			end

			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		else
			Title = Title .. TransTitle .. TransError;
		end
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURLorigin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin, nil );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if is_set(Minutes) then
			if is_set (Time) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'minutes') .. ' and ' .. wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase, Mode);

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
		if 'mla' == Mode then
			Others = sepc .. ' Trans. ' .. Translators .. Others;
		else
			Others = sepc .. ' ' .. wrap_msg ('translated', Translators, use_lowercase) .. Others;
		end
	end
	if is_set (Interviewers) then
		Others = sepc .. ' ' .. wrap_msg ('interview', Interviewers, use_lowercase) .. Others;
	end
	
	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		if 'mla' == Mode then
			Edition = '. ' .. Edition .. ' ed.';
		else
			Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
		end
	else
		Edition = '';
	end

	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	if 'mla' == Mode then														-- not in brackets for mla
		OrigYear = is_set(OrigYear) and (&quot;. &quot; .. OrigYear) or &quot;&quot;;
	else
		OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	end
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase, Mode);

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

--[[
Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
note is displayed. There are no error messages for this condition.

]]
	if is_set (SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif is_set (RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if 'mla' == Mode then													-- retrieved text not used in mla
			AccessDate = ' ' .. AccessDate;
		else
			if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end			-- if mode is cs2, lower case
			AccessDate = substitute (retrv_text, AccessDate);					-- add retrieved text
		end
		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {IdAccessLevels=ID_access_levels, DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin, UrlAccess );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then				-- if first and last characters of quote are quote marks
			Quote = Quote:sub(2,-2);											-- strip them off
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- DeadURL is empty, 'yes', 'true', 'y', 'unfit', 'usurped'
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if in_array (DeadURL, {'unfit', 'usurped', 'bot: unknown'}) then
				Archived = sepc .. &quot; &quot; .. 'Archived from the original on ' .. ArchiveDate;	-- format already styled
				if 'bot: unknown' == DeadURL then
					add_maint_cat ('bot:_unknown');								-- and add a category if not already added
				else
					add_maint_cat ('unfit');									-- and add a category if not already added
				end
			else																-- DeadURL is empty, 'yes', 'true', or 'y'
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURLorigin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURLorigin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin, nil );
	end

	local Publisher;
	if is_set(PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if is_set(PublisherName) then
		if is_set(PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif is_set(PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		if 'mla' == Mode then
			tcommon = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
		else
			tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
				Language, Edition, Publisher, Agency, Volume}, sepc );
		end		
	elseif in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(Periodical) then		-- special cases for book cites
		if is_set (Contributors) then											-- when we are citing foreword, preface, introduction, etc
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			if 'mla' == Mode then
				tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Edition, Publisher, Agency}, sepc );
			else
				tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
			end
		elseif 'mla' == Mode then
			tcommon = safe_join( {TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Transcript, Language, Edition, Publisher}, sepc );

	elseif ('news' == config.CitationClass) and ('mla' == Mode) then			-- special case for cite news in MLA mode
		tcommon = safe_join( {Periodical, Format, TitleType, Series, Language, Edition, Agency}, sepc );

	elseif ('web' == config.CitationClass) and ('mla' == Mode) then				-- special case for cite web in MLA mode
		tcommon = safe_join( {Periodical, Format, TitleType, Series, Language, 
			Edition, Publisher, Agency}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if is_set(Date) then
		if ('mla' == Mode) then
			if in_array (config.CitationClass, {'book', 'news', 'web'}) then
				Date = ', ' .. Date;											-- origyear follows title in mla
			elseif 'journal' == config.CitationClass then
				Date = ', (' .. Date .. ')';
			end
		elseif is_set (Authors) or is_set (Editors) then						-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;;				-- in paranetheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon,-1,-1) == sepc) then							-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigYear;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigYear;							-- Date begins with sepc
			end
		end
	end	
	if is_set(Authors) then
		if (not is_set (Date)) or ('mla' == Mode) then							-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) and 0 == #c and 'mla' ~= Mode then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then in_text = in_text:lower() end				-- lowercase for cs2
			elseif is_set(Chapter) and 'mla' == Mode then
				if EditorCount &lt;= 1 then
					in_text = '. Ed. ';
				else
					in_text = '. Eds. ';
				end
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if is_set (Contributors) then											-- book cite and we're citing the intro, preface, etc
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if is_set (Editors) and is_set (Date) and ('mla' ~= Mode) then		-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not is_set (Date)) or ('mla' == Mode) then											-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			if 'mla' == Mode then
				text = safe_join( {Contributors, Chapter, tcommon, OrigYear, Authors, Place, Others, Editors, tcommon2, Date, pgtext, idcommon }, sepc );
			else
				text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
			end
		elseif 'mla' == Mode then
			tcommon = tcommon .. Date;											-- hack to avoid duplicate separators
			text = safe_join( {Authors, Chapter, Title, OrigYear, Others, Editors, Edition, Place, tcommon, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		if 'mla' == Mode then
			if in_array(config.CitationClass, {'journal', 'news', 'web'}) and is_set(Periodical) then
				text = safe_join( {Editors, Title, Place, tcommon, pgtext, Date, idcommon}, sepc );
			else
				text = safe_join( {Editors, Chapter, Title, Place, tcommon, Date, pgtext, idcommon}, sepc );
			end
		else
			text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
		end
	elseif 'mla' == Mode then
		if in_array(config.CitationClass, {'journal', 'news', 'web'}) and is_set(Periodical) then
			text = safe_join( {Title, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Title, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	else
		if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = config.CitationClass;
		options.class = &quot;citation &quot; .. config.CitationClass;					-- class=citation required for blue highlight when used with |ref=
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then								-- set reference anchor if appropriate
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			if #namelist &gt; 0 then												-- if there are names in namelist
				id = anchor_id (namelist, year);								-- go make the CITEREF anchor
			else
				id = '';														-- unset
			end
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;(.-)&lt;/span&gt;&quot;, &quot;%1&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then	-- remove &lt;span&gt; tags and other html-like markup; then get length of what remains
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then													-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		text = substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text});	-- when |ref= is set
	else
		text = substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text});	-- all other cases
	end		

	text = text .. substitute (cfg.presentation['ocins'], {OCinSoutput});		-- append metadata to the citation
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. error_comment( v[1], v[2] );
				else
					text = text .. error_comment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end

	if #z.maintenance_cats ~= 0 then
		text = text .. '&lt;span class=&quot;citation-comment&quot; style=&quot;display:none; color:#33aa33; margin-left:0.3em&quot;&gt;';
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. v .. ' ([[:Category:' .. v ..'|link]])';
		end
		text = text .. '&lt;/span&gt;';												-- maintenance mesages (realy just the names of the categories for now)
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end


--[[--------------------------&lt; C S 1 . C I T A T I O N &gt;------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

function cs1.citation(frame)
	Frame = frame;																-- save a copy incase we need to display an error message in preview mode
	local pframe = frame:getParent()
	local validation, utilities, identifiers, metadata;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (utilities);								-- so that functions in Date validataion can see the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	dates = validation.dates;													-- imported functions from Module:Citation/CS1/Date validation
	year_date_check = validation.year_date_check;
	reformat_dates = validation.reformat_dates;
	date_hyphen_to_dash = validation.date_hyphen_to_dash;
	
	is_set = utilities.is_set;													-- imported functions from Module:Citation/CS1/Utilities
	in_array = utilities.in_array;
	substitute = utilities.substitute;
	error_comment = utilities.error_comment;
	set_error = utilities.set_error;
	select_one = utilities.select_one;
	add_maint_cat = utilities.add_maint_cat;
	wrap_style = utilities.wrap_style;
	safe_for_italics = utilities.safe_for_italics;
	remove_wiki_link = utilities.remove_wiki_link;

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	extract_ids = identifiers.extract_ids;										-- imported functions from Module:Citation/CS1/Identifiers
	build_id_list = identifiers.build_id_list;
	is_embargoed = identifiers.is_embargoed;
	extract_id_access_levels = identifiers.extract_id_access_levels;
	
	make_coins_title = metadata.make_coins_title;								-- imported functions from Module:Citation/CS1/COinS
	get_coins_pages = metadata.get_coins_pages;
	COinS = metadata.COinS;

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text, error_state;

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do
		config[k] = v;
--		args[k] = v;															-- debug tool that allows us to render a citation from module {{#invoke:}}
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k, config.CitationClass ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower(), config.CitationClass ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute( param, capture );				-- add the capture to the suggested parameter (typically the enumerator)
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, param}, true );	-- set the error message
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			missing_pipe_check (v);												-- do we think that there is a parameter that is missing a pipe?
			
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);
		end
	end
	return citation0( config, args)
end

return cs1;</text>
      <sha1>j0uqqa3frjxvinh9e9lg5413iaw2znz</sha1>
    </revision>
    <revision>
      <id>4715</id>
      <parentid>4714</parentid>
      <timestamp>2017-04-30T09:40:55Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>unsuport |version= for cite arxiv;</comment>
      <origin>4715</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="167320" sha1="joycwwvkv1un67jzdwyyhg1pdnutfbe" xml:space="preserve">
local cs1 ={};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local dates, year_date_check, reformat_dates, date_hyphen_to_dash				-- functions in Module:Citation/CS1/Date_validation

local is_set, in_array, substitute, error_comment, set_error, select_one,		-- functions in Module:Citation/CS1/Utilities
	add_maint_cat, wrap_style, safe_for_italics, remove_wiki_link;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local extract_ids, extract_id_access_levels, build_id_list, is_embargoed;		-- functions in Module:Citation/CS1/Identifiers

local make_coins_title, get_coins_pages, COinS;									-- functions in Module:Citation/CS1/COinS

local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

delare variables here that have page-wide scope that are not brought in from other modules; thatare created here
and used here

]]

local added_deprecated_cat;														-- boolean flag so that the category is added only once
local added_prop_cats = {};														-- list of property categories that have been added to z.properties_cats
local added_vanc_errs;															-- boolean flag so we only emit one Vancouver error / category

local Frame;																	-- holds the module's frame table


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end

--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

added_prop_cats is a table declared in page scope variables above

]]

local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));		-- make name then add to table
	end
end

--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a boolean declared in page scope variables above

]]

local function add_vanc_error (source)
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {source}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a uri scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of tlds: https://www.iana.org/domains/root/db

rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the tld.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a url with a scheme) will be stripped
here.  Perhaps not necessary but retained incase it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ascii characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the tld) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org TLD
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and tld or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%a%d]') then										-- first character must be letter or digit
		return false;
	end
																				-- Do most common case first
	if domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.%a%a+$') then				-- three or more character hostname.hostname or hostname.tld
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.xn%-%-[%a%d]+$') then	-- internationalized domain name with ACE prefix
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.org$') then							-- one character .org hostname
		return true;
	elseif domain:match ('%f[%a][qxz]%.com$') then								-- assigned one character .com hostname (x.com times out 2015-12-10)
		return true;
	elseif domain:match ('%f[%a][iq]%.net$') then								-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.%a%a$') then							-- one character hostname and cctld (2 chars)
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d]%.%a%a+$') then					-- two character hostname and tld
		return true;
	elseif domain:match ('^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?') then		-- IPv4 address
		return true;
	else
		return false;
	end
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a url appear to be a valid url; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if is_set (scheme) then														-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when url is protocol relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a url into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following tld) (if any) and any path(/), query(?) or fragment(#).

If protocol relative url, return nil scheme and domain else return nil for both scheme and domain.

When not protocol relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol relative url
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		authority = authority:gsub ('//', '', 1);								-- replace place 1 pair of '/' with nothing;
		if is_set(authority) then												-- if anything left (1 or 3+ '/' where authority should be) then
			return scheme;														-- return scheme only making domain nil which will cause an error message
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link= etc for properly formatted content: no wikilinks, no urls

Link parameters are to hold the title of a wikipedia article so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki urls and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid url (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid url (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from url; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid url
end

--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wikilinked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

]]

local function link_title_ok (link, lorig, title, torig)
local orig;

	if is_set (link) then 														-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		end
	end

	if is_set (orig) then
		table.insert( z.message_tail, { set_error( 'bad_paramlink', orig)});	-- url or wikilink in |title= with |title-link=;
	end
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the url into scheme and domain
portions, or for protocol relative (//example.com) urls, just the domain.  Use is_url() to validate the two
portions of the url.  If both are valid, or for protocol relative if domain is valid, return true, else false.

Because it is different from a standard url, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper url
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from url;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a url.  The test will also find external wikilinks
that use protocol relative urls. Also finds bare urls.

The frontier pattern prevents a match on interwiki links which are similar to scheme:path urls.  The tests that
find bracketed urls are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol relative ext wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare url with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol relative bare url: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a url
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then												-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source, access)
	local error_str = &quot;&quot;;
	local domain;
	local path;
	local base_url;
	
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the url into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['[']='%5b',[']']='%5d'});					-- replace '[' and ']' with their percent encoded values
		URL=domain..path;														-- and reassemble
	end
	
	if is_set (access) then														-- access level (subscription, registration, limited)
		local label_head = '';
		local label_tail;
		local markup = '';														-- can't start a span inside italic markup and end it outside the italic markup

		label = safe_for_url (label);											-- replace square brackets and newlines (is this necessary? already done above?)
		if label:match (&quot;(.*)%s+(.+)('''?)$&quot;) then								-- for italicized titles (cite book, etc)
			label_head, label_tail, markup = label:match (&quot;(.*)%s+(.+)('''?)$&quot;);	-- split the label at the right-most space; separate the markup
		elseif label:match (&quot;(.*)%s+(.+)$&quot;) then								-- for upright titles (journal, news, magazine, etc)
			label_head, label_tail = label:match (&quot;(.*)%s+(.+)$&quot;);				-- split the label at the right-most space; no markup 
		elseif label:match (&quot;(.+)('''?)$&quot;) then									-- single word label with markup
			label_tail, markup = label:match (&quot;(.+)('''?)$&quot;);					-- save label text as label tail; separate the markup
		else
			label_tail = label;
		end

		base_url = table.concat (
			{
			'&lt;span class=&quot;plainlinks&quot;&gt;[',										-- opening css
			URL,																-- the url
			' ',																-- the required space
			label_head,															-- all but the last word of the label
			' &lt;span class=&quot;nowrap&quot;&gt;',											-- nowrap css for the last word and the signal icon
			label_tail,															-- last (or only) word of the label inside the span
			'&lt;span style=&quot;padding-left:0.15em&quot;&gt;',								-- signal spacing css
			cfg.presentation[access],											-- the appropriate icon
			'&lt;/span&gt;&lt;/span&gt;',													-- close signal spacing and nowrap spans
			markup,																-- insert italic markup if any
			']&lt;/span&gt;'															-- close the plain links span
			});
	else
		base_url = table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url( label ), &quot;]&quot; });	-- no signal markup
	end
	
	return table.concat({ base_url, error_str });
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end

--[[--------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Replaces unicode quotemarks with typewriter quote marks regardless of the need for kerning.

Call this function for chapter titles, for website titles, etc; not for book titles.

]]

local function kern_quotes (str)
	local cap='';
	local cap2='';
																				-- TODO: move this elswhere so that all title-holding elements get these quote marks replaced?
	str= mw.ustring.gsub (str, '[“”]', '\&quot;');									-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
	str= mw.ustring.gsub (str, '[‘’]', '\'');									-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)
	
	cap, cap2 = str:match (&quot;^([\&quot;\'])([^\'].+)&quot;);								-- match leading double or single quote but not double single quotes
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-left'], {cap, cap2});
	end

	cap, cap2 = str:match (&quot;^(.+[^\'])([\&quot;\'])$&quot;)
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-right'], {cap, cap2});
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title= and |script-chapter=

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, cfg.script_lang_codes) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				add_prop_cat ('script')
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return substitute( msg, str );										-- including template text
	else
		return substitute( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (scriptchapter, chapter, transchapter, chapterurl, chapter_url_source, no_quotes)
	local chapter_error = '';
	
	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);										-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
			chapter = wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, scriptchapter)						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (transchapter) then
		transchapter = wrap_style ('trans-quoted-title', transchapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. transchapter;
		else																	-- here when transchapter without chapter or script-chapter
			chapter = transchapter;												-- 
			chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
		end
	end

	if is_set (chapterurl) then
		chapter = external_link (chapterurl, chapter, chapter_url_source, nil);		-- adds bare_url_missing_title error if appropriate
	end

	return chapter .. chapter_error;
end

--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Detects but ignores the character pattern that results from the transclusion of {{'}} templates.

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i=1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- Test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position then
			if 'nowiki' == capture or 'math' == capture then 					-- nowiki, math stripmarker (not an error condition)
				stripmarker = true;												-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { set_error( 'invisible_char', {err_msg, wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i=i+1;																	-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

--local function validate( name )
local function validate( name, cite_class )
	local name = tostring( name );
	local state;
	
	if in_array (cite_class, {'arxiv', 'biorxiv', 'citeseerx'}) then				-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[ name ];
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end

		if 'arxiv' == cite_class then											-- basic parameters unique to these templates
			state = whitelist.arxiv_basic_arguments[name];
		end
		if 'biorxiv' == cite_class then
			state = whitelist.biorxiv_basic_arguments[name];
		end
		if 'citeseerx' == cite_class then
			state = whitelist.citeseerx_basic_arguments[name];
		end

		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
																				-- limited enumerated parameters list
		name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#)
		state = whitelist.limited_numbered_arguments[ name ];
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates
		
	state = whitelist.basic_arguments[ name ];									-- all other templates; all normal parameters allowed
											
	if true == state then return true; end										-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);											-- parameter is deprecated but still supported
		return true;
	end
																				-- all enumerated parameters allowed
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );												-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];

	if true == state then return true; end										-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);											-- parameter is deprecated but still supported
		return true;
	end
	
	return false;																-- not supported because not found or name is set to nil
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end

--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash

]]

local function hyphen_to_dash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if comp:sub(1,1) == duplicate_char then								-- is first charactier same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for th
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = str:sub(-1,-1);										-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = str:sub(1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = str:sub(1, -4) .. &quot;''&quot;;							-- remove them and add back ''
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then		-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then		-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then			-- if last two chars of str are sepc] external link
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;'']&quot; then		-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then				-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = str:sub(1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end		-- if duplicate_char not a letter then escape it
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )			-- remove duplicate_char if it follows html markup
					else
						value = value:sub( 2, -1 );								-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end  


--[[--------------------------&lt; I S _ S U F F I X &gt;------------------------------------------------------------

returns true is suffix is properly formed Jr, Sr, or ordinal in the range 2–9.  Puncutation not allowed.

]]

local function is_suffix (suffix)
	if in_array (suffix, {'Jr', 'Sr', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end

--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written ouside of the code editor and pasted here because the code editor gets confused between character insertion point and cursor position.
The test has been rewritten to use decimal character escape sequence for the individual bytes of the unicode characters so that it is not necessary
to use an external editor to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first)
	local first, suffix = first:match ('(.-),?%s*([%dJS][%drndth]+)%.?$') or first;		-- if first has something that looks like a generational suffix, get it

	if is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error ('suffix');
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error ('non-Latin character');
			return false;														-- not a string of latin characters; Vancouver requires Romanization
	end;
	return true;
end

--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just intials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error ('suffix');									-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word


	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i],1,1));				-- insert the intial at end of initials table
		end
		i = i+1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end

--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = ',';																-- name-list separator between authors is a comma
		namesep = ' ';															-- last/first separator is a space
	elseif 'mla' == control.mode then
		sep = ',';																-- name-list separator between authors is a comma
		namesep = ', '															-- last/first separator is &lt;comma&gt;&lt;space&gt;
	else
		sep = ';'																-- name-list separator between authors is a semicolon
		namesep = ', '															-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then
					if 'mla' == control.mode then 
						if i == 1 then											-- for mla
							one = one .. namesep .. first;						-- first name last, first
						else													-- all other names
							one = first .. ' ' .. one;							-- first last
						end
					else
						if ( &quot;vanc&quot; == format ) then								-- if vancouver format
							one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
							if not person.corporate and is_good_vanc_name (one, first) then					-- and name is all Latin characters; corporate authors not tested
								first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
							end
						end
						one = one .. namesep .. first;
					end
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;				-- link author/editor if this page is not the author's/editor's page
				end
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			if 'mla' == control.mode then
				text[#text-2] = &quot;, and &quot;;										-- replace last separator with ', and ' text
			else
				text[#text-2] = &quot; &amp; &quot;;											-- replace last separator with ampersand text
			end
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end

--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]
local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of author and editor name parameters for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the parameters |display-authors=etal or |display-editors=etal

]]

local function name_has_etal (name, etal, nocat)

	if is_set (name) then														-- name can be nil in which case just return
		local etal_pattern = &quot;[;,]? *[\&quot;']*%f[%a][Ee][Tt] *[Aa][Ll][%.\&quot;']*$&quot;	-- variations on the 'et al' theme
		local others_pattern = &quot;[;,]? *%f[%a]and [Oo]thers&quot;;					-- and alternate to et al.
		
		if name:match (etal_pattern) then										-- variants on et al.
			name = name:gsub (etal_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		elseif name:match (others_pattern) then									-- if not 'et al.', then 'and others'?
			name = name:gsub (others_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		end
	end
	return name, etal;															-- 
end


--[[--------------------------&lt; N A M E _ H A S _ E D _ M A R K U P &gt;------------------------------------------

Evaluates the content of author and editor parameters for extranious editor annotations: ed, ed., eds, (Ed.), etc.
These annotation do not belong in author parameters and are redundant in editor parameters.  If found, the function
adds the editor markup maintenance category.

]]

local function name_has_ed_markup (name, list_name)
	local _, pattern;
	local patterns = {															-- these patterns match annotations at end of name
		'%f[%(%[][%(%[]%s*[Ee][Dd][Ss]?%.?%s*[%)%]]?$',							-- (ed) or (eds): leading '(', case insensitive 'ed', optional 's', '.' and/or ')'
		'[,%.%s]%f[e]eds?%.?$',													-- ed or eds: without '('or ')'; case sensitive (ED could be initials Ed could be name)
		'%f[%(%[][%(%[]%s*[Ee][Dd][Ii][Tt][Oo][Rr][Ss]?%.?%s*[%)%]]?$',			-- (editor) or (editors): leading '(', case insensitive, optional '.' and/or ')'
		'[,%.%s]%f[Ee][Ee][Dd][Ii][Tt][Oo][Rr][Ss]?%.?$',						-- editor or editors: without '('or ')'; case insensitive
		
																				-- these patterns match annotations at beginning of name
		'^eds?[%.,;]',															-- ed. or eds.: lower case only, optional 's', requires '.'
		'^[%(%[]%s*[Ee][Dd][Ss]?%.?%s*[%)%]]',									-- (ed) or (eds): also sqare brackets, case insensitive, optional 's', '.'
		'^[%(%[]?%s*[Ee][Dd][Ii][Tt][Oo][Rr][Ss]?%A',							-- (editor or (editors: also sq brackets, case insensitive, optional brackets, 's'
		'^[%(%[]?%s*[Ee][Dd][Ii][Tt][Ee][Dd]%A',								-- (edited: also sq brackets, case insensitive, optional brackets

		}

	if is_set (name) then
		for _, pattern in ipairs (patterns) do									-- spin through patterns table and
			if name:match (pattern) then
				add_maint_cat ('extra_text_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
				break;
			end
		end
	end
	return name;																-- and done
end


--[[--------------------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;----------------------------------------

Evaluates the content of author and editor (surnames only) parameters for multiple names.  Multiple names are
indicated if there is more than one comma and or semicolon.  If found, the function adds the multiple name
(author or editor) maintenance category.

]]

local function name_has_mult_names (name, list_name)
local count, _;
	if is_set (name) then
		_, count = name:gsub ('[;,]', '');										-- count the number of separator-like characters
		
		if 1 &lt; count then														-- param could be |author= or |editor= so one separator character is acceptable
			add_maint_cat ('mult_names', cfg.special_case_translation [list_name]);	-- more than one separator indicates multiple names so add a maint cat for this template
		end
	end
	return name;																-- and done
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------
This function calls various name checking functions used to validate the content of the various name-holding
parameters.

]]

local function name_checks (last, first, list_name)
	if is_set (last) then
		if last:match ('^%(%(.*%)%)$') then										-- if wrapped in doubled parentheses, accept as written 
			last = last:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			last = name_has_mult_names (last, list_name);						-- check for multiple names in the parameter (last only)
			last = name_has_ed_markup (last, list_name);						-- check for extraneous 'editor' annotation
		end
	end
	if is_set (first) then
		if first:match ('^%(%(.*%)%)$') then									-- if wrapped in doubled parentheses, accept as written 
			first = first:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			first = name_has_ed_markup (first, list_name);						-- check for extraneous 'editor' annotation
		end
	end
	return last, first;															-- done
	end


--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary
	while true do
		last = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false);							-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false);						-- find and remove variations on et al.
		last, first= name_checks (last, first, list_name);						-- multiple names, extraneous annotation, etc checks
		
		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			link_title_ok (link, list_name:match (&quot;(%w+)List&quot;):lower() .. '-link' .. i, last, list_name:match (&quot;(%w+)List&quot;):lower() .. '-last' .. i);	-- check for improper wikimarkup

			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because case of the source may be incorrect
or different from the case that WikiMedia uses, the name comparisons are done in lower case and when a match is
found, the Wikimedia version (assumed to be correct) is returned along with the code.  When there is no match, we
return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') return a list of languages that in some cases may include
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.

Names but that are included in the list will be found if that name is provided in the |language= parameter.  For example,
if |language=Chavacano de Zamboanga, that name will be found with the associated code 'cbk-zam'.  When names are found
and the associated code is not two or three characters, this function returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	if 'bangla' == lang:lower() then											-- special case related to Wikimedia remap of code 'bn' at mw:Extension:CLDR
		return 'Bengali', 'bn';													-- make sure rendered version is properly capitalized
	end

	local languages = mw.language.fetchLanguageNames(this_wiki_code, 'all')		-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() and 3 ~= code:len() then							-- two- or three-character codes only; extensions not supported
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the the code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for the code
end


--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code is recognized by MediaWiki,
use the returned name; if not, then use the value that was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is assigned to the category for
that code: Category:Norwegian-language sources (no).  For valid three-character code languages, the page is assigned
to the single category for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does not recognize three-character
equivalents of two-character codes: code 'ar' is recognized bit code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are
separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki = mw.getContentLanguage();									-- get a language object for this wiki
	local this_wiki_code = this_wiki:getCode()									-- get this wiki's language code
	local this_wiki_name = mw.language.fetchLanguageName(this_wiki_code, this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang

		if lang:match ('^%a%a%-') then											-- strip ietf language tags from code; TODO: is there a need to support 3-char with tag?
			lang = lang:match ('(%a%a)%-')										-- keep only 639-1 code portion to lang; TODO: do something with 3166 alpha 2 country code?
		end
		if 2 == lang:len() or 3 == lang:len() then								-- if two-or three-character code
			name = mw.language.fetchLanguageName( lang:lower(), this_wiki_code);	-- get language name if |language= is a proper code
		end
	
		if is_set (name) then													-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, this_wiki_code);				-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then													-- only 2- or 3-character codes
			if 'bn' == code then name = 'Bengali' end;							-- override wikimedia when code is 'bn'
			if this_wiki_code ~= code then										-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					add_prop_cat ('foreign_lang_source', {name, code})			-- categorize it
				else															-- or is a recognized language (but has a three-character code)
					add_prop_cat ('foreign_lang_source_2', {code})				-- categorize it differently TODO: support mutliple three-character code categories per cs1|2 template
				end
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, ' and ')							-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		language_list[code] = 'and ' .. language_list[code];					-- prepend last name with 'and&lt;space&gt;'
		name = table.concat (language_list, ', ')								-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
	end
	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end

--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = '.';																-- terminate the rendered citation with a period
	end
	return '.', ps;																-- separator is a full stop
end

--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = '';																-- make sure it isn't nil
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return ',', ps, ref;														-- separator is a comma
end

--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	elseif 'mla' == mode then													-- if this template is to be rendered in mla style use cs1 for bot cs1 &amp; cs2 templates
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end

--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extension, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf[%?#]?') or url:match ('%.PDF[%?#]?');
end

--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parenthases, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end

--[[--------------------------&lt; G E T _ D I S P L A Y _ A U T H O R S _ E D I T O R S &gt;------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_authors_editors (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_auth_ed', cfg.special_case_translation [list_name]);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end

--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
--	local good_pattern = '^P[^%.P%l]';
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
--	local bad_pattern = '^[Pp][Pp]';
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
--		if Page:match ('^[Pp]?[Pp]%.?[ %d]') or  Page:match ('^[Pp]ages?[ %d]') or
--			Pages:match ('^[Pp]?[Pp]%.?[ %d]') or  Pages:match ('^[Pp]ages?[ %d]') then
--				add_maint_cat ('extra_text');
--		end
end

--[[--------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vautthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parnetheses were included in the
rendered citation and in the metadata.

	|vauthors=Jones AB, White EB, ((Black, Brown, and Co.))

This code is experimental and may not be retained.

]]
local function get_v_name_table (vparam, output_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parens
			local name = name_table[i];
			i=i+1;																-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parens
					break;														-- and done reassembling so
				end
				i=i+1;															-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
		else
			table.insert (output_table, name_table[i]);							-- add this name 
		end
		i = i+1;
	end	
	return output_table;
end

--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	if vparam:find ('%[%[') or vparam:find ('%]%]')	then						-- no wikilinking vauthors names
		add_vanc_error ('wikilink');
	end
	v_name_table = get_v_name_table (vparam, v_name_table);						-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parentheses to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')								-- remove doubled parntheses
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error ('punctuation');
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
			if is_suffix (first) then											-- if a valid suffix
				suffix = first													-- save it as a suffix and
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end																	-- no suffix error message here because letter combination may be result of Romanization; check for digits?
			last = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error ('missing comma');								-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error ('name');										-- matches a space between two intiials
			end
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error ('initials');									-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first);									-- check first and last before restoring the suffix which may have a non-Latin digit
			if is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '');
			end
		end
																				-- this from extract_names ()
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice incase we have a |first1= without a |last1=; this ...
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or	-- ... also catches the case where |first= is used with |vauthors=
		select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, no, etc).  When the parameter value has not been assigned a value (missing or empty
in the source template) the function refurns true.  If the parameter value is one of the list of allowed values returns
true; else, emits an error message and returns false.

]]

local function is_valid_parameter_value (value, name, possible, cite_class)
-- begin hack to limit |mode=mla to a specific set of templates
	if ('mode' == name) and ('mla' == value) and not in_array (cite_class, {'book', 'journal', 'news'}) then
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
-- end hack

	if not is_set (value) then
		return true;															-- an empty parameter is ok
	elseif in_array(value:lower(), possible) then
		return true;
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list,-3,-1) == sepc .. '. ') then						-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list,-1,-1) == sepc) or (string.sub (name_list,-3,-1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terninate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower, mode)
	if not is_set (volume) and not is_set (issue) then
		return '';
	end
	
	if ('mla' == mode) and ('journal' == cite_class) then						-- same as cs1 for magazines
		lower = true;															-- mla 8th edition; force these to lower case
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return '';
		end
	end

	if 'magazine' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end

	local vol = '';
		
	if is_set (volume) then
		if (4 &lt; mw.ustring.len(volume)) then
			vol = substitute (cfg.messages['j-vol'], {sepc, volume});
		else
			vol = substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});
		end
	end
	if is_set (issue) then
		return vol .. substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end


--[[-------------------------&lt; N O R M A L I Z E _ P A G E _ L I S T &gt;-----------------------------------------

not currently used

normalizes a comma, ampersand, and/or space separated list to be '&lt;value&gt;, &lt;value&gt;, ..., &lt;value&gt;'
returns list unchanged if there are no commas else strips whitespace and then reformats the list

]]
--[[
local function normalize_page_list (list)
	if not list:find ('[,&amp; ]') then return list end								-- if list is not delimited with commas, ampersands, or spaces; done
	
	list = mw.text.split (list, '[,&amp;%s]+');										-- make a table of values
	list = table.concat (list, ', ');											-- and now make a normalized list
	return list;
end
]]


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower, mode)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'journal' == origin);
	
	if is_journal and 'mla' == mode then
		is_journal = false;														-- mla always uses p &amp; pp
	end

	if is_set (page) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif is_set(pages) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then										-- if pages is only digits, assume a single page number
			return '', substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org urls to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot url or to calendar pages.  When the archive url is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the url.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org url does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command url
	|archive-url= is an archive.org url that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org urls:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this funct may return a modified
archive url:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the url unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.or url
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine url
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command url, we don't want to allow saving of the target page 
		err_msg = 'save command';
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = 'liveweb';
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');		-- split out some of the url parts for evaluation
		
		if not is_set(timestamp) or 14 ~= timestamp:len() then					-- path and flag optional, must have 14-digit timestamp here
			err_msg = 'timestamp';
			if '*' ~= flag then
				url=url:gsub ('(//web%.archive%.org/[^%d]*%d?%d?%d?%d?%d?%d?)[^/]*', '%1*', 1)	-- for preview, modify ts to be yearmo* max (0-6 digits plus splat)
			end
		elseif is_set(path) and 'web/' ~= path then								-- older archive urls do not have the extra 'web/' path element
			err_msg = 'path';
		elseif is_set (flag) and not is_set (path) then							-- flag not allowed with the old form url (without the 'web/' path element)
			err_msg = 'flag';
		elseif is_set (flag) and not flag:match ('%a%a_') then					-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = 'flag';
		else
			return url, date;													-- return archiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	table.insert( z.message_tail, { set_error( 'archive_url', {err_msg}, true ) } );	-- add error message and
	if is_set (Frame:preprocess('{{REVISIONID}}')) then
		return '', '';															-- return empty strings for archiveURL and ArchiveDate
	else
		return url, date;														-- preview mode so return archiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe:
	{{cite ... |title=Title access-date=2016-03-17}}

cs1|2 shares some parameter names with xml/html atributes: class=, title=, etc.  To prevent false positives xml/html
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove xml/html tags because attributes: class=, title=, etc 

	capture = value:match ('%s+(%a[%a%d]+)%s*=') or value:match ('^(%a[%a%d]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then								-- if the capture is a valid parameter name
		add_maint_cat ('missing_pipe');
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

-- set default parameter values defined by |mode= parameter.  If |mode= is empty or omitted, use CitationClass to set these values
	local Mode = A['Mode'];
	if not is_valid_parameter_value (Mode, 'mode', cfg.keywords['mode'], config.CitationClass) then
		Mode = '';
	end

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				add_maint_cat ('authors');										-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
			add_maint_cat ('editors');											-- but add a maint cat because use of this parameter is discouraged
		end
	end

	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	

	local interviewers_list = {};
	local Interviewers = A['Interviewers']
	if is_set (Interviewers) then												-- add a maint cat if the |interviewers= is used
		add_maint_cat ('interviewers');											-- because use of this parameter is discouraged
	else
		interviewers_list = extract_names (args, 'InterviewerList');			-- else, process preferred interviewers parameters
	end

	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list
	local Contribution = A['Contribution'];
	if in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not is_set (Contribution) then									-- |contributor= requires |contribution=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if select_one (args, cfg.aliases['ContributorList-Last'], 'redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { set_error( 'contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if not is_valid_parameter_value (NameListFormat, 'name-list-format', cfg.keywords['name-list-format']) then			-- only accepted value for this parameter is 'vanc'
		NameListFormat = '';													-- anything else, set to empty string
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
			link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wikimarkup in |title-link= or wikimarkup in |title= when |title-link= is set

	local Chapter = A['Chapter'];
	local ScriptChapter = A['ScriptChapter'];
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];

	local ArchiveDate;
	local ArchiveURL;

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	
	local DeadURL = A['DeadURL']
		if not is_valid_parameter_value (DeadURL, 'dead-url', cfg.keywords ['deadurl']) then	-- set in config.defaults to 'yes'
			DeadURL = '';														-- anything else, set to empty string
		end

	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];
	local Periodical_origin = A:ORIGIN('Periodical');							-- get the name of the periodical parameter

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;
																				-- previously conference books did not support volume
--	if in_array (config.CitationClass, cfg.templates_using_volume) and not ('conference' == config.CitationClass and not is_set (Periodical)) then
	if in_array (config.CitationClass, cfg.templates_using_volume) then
		Volume = A['Volume'];
	end
																				-- conference &amp; map books do not support issue
	if in_array (config.CitationClass, cfg.templates_using_issue) and not (in_array (config.CitationClass, {'conference', 'map'}) and not is_set (Periodical))then
		Issue = A['Issue'];
	end
	local Position = '';
	if not in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash( A['Pages'] );	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
		if not is_valid_parameter_value (RegistrationRequired, 'registration', cfg.keywords ['yes_true_y']) then
			RegistrationRequired=nil;
		end
	local SubscriptionRequired = A['SubscriptionRequired'];
		if not is_valid_parameter_value (SubscriptionRequired, 'subscription', cfg.keywords ['yes_true_y']) then
			SubscriptionRequired=nil;
		end
	local UrlAccess = A['UrlAccess'];
		if not is_valid_parameter_value (UrlAccess, 'url-access', cfg.keywords ['url-access']) then
			UrlAccess = nil;
		end
		if not is_set(URL) and is_set(UrlAccess) then
			UrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {'url'}, true ) } );
		end

		if is_set (UrlAccess) and is_set (SubscriptionRequired) then			-- while not aliases, these are much the same so if both are set
			table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'url-access') .. ' and ' .. wrap_style ('parameter', 'subscription')}, true ) } );		-- add error message
			SubscriptionRequired = nil;											-- unset; prefer |access= over |subscription=
		end
		if is_set (UrlAccess) and is_set (RegistrationRequired) then			-- these are not the same but contradictory so if both are set
			table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'url-access') .. ' and ' .. wrap_style ('parameter', 'registration')}, true ) } );		-- add error message
			RegistrationRequired = nil;											-- unset; prefer |access= over |registration=
		end


	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local Agency = A['Agency'];

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
		if not is_valid_parameter_value (IgnoreISBN, 'ignore-isbn-error', cfg.keywords ['yes_true_y']) then
			IgnoreISBN = nil;													-- anything else, set to empty string
		end
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );
	local ID_access_levels = extract_id_access_levels( args, ID_list );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
		if not is_valid_parameter_value (LastAuthorAmp, 'last-author-amp', cfg.keywords ['yes_true_y']) then
			LastAuthorAmp = nil;												-- set to empty string
		end
		if 'mla' == Mode then												
			LastAuthorAmp = 'yes';												-- replaces last author/editor separator with ' and ' text
		end
	local no_tracking_cats = A['NoTracking'];
		if not is_valid_parameter_value (no_tracking_cats, 'no-tracking', cfg.keywords ['yes_true_y']) then
			no_tracking_cats = nil;												-- set to empty string
		end

--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = A['DF'];															-- date format set in cs1|2 template
	if not is_valid_parameter_value (DF, 'df', cfg.keywords['date-format']) then	-- validate reformatting keyword
		DF = '';																-- not valid, set to empty string
	end

	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	select_one( args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'redundant_parameters' );		-- this is a dummy call simply to get the error message and category

	local NoPP = A['NoPP'] 
	if is_set (NoPP) and is_valid_parameter_value (NoPP, 'nopp', cfg.keywords ['yes_true_y']) then
		NoPP = true;
	else
		NoPP = nil;																-- unset, used as a flag later
	end

	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Pages = '';															-- unset the others
			At = '';
		end
		extra_text_in_page_check (Page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.
	elseif is_set(Pages) then
		if is_set(At) then
			At = '';															-- unset
		end
		extra_text_in_page_check (Pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped
	|url maps to |chapterurl when |title is remapped

All other combinations of |encyclopedia, |title, and |article are not modified

]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					TransChapter = TransTitle;
					ChapterURL = URL;
					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter= '[[' .. TitleLink .. '|' .. Chapter .. ']]';
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			else																-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if is_set(A['Number']) then												-- cite techreport uses 'number', which other citations alias to 'issue'
			if not is_set(ID) then												-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', 'id') .. ' and ' .. wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	elseif 'mailinglist' == A:ORIGIN('Periodical') then
		Periodical = '';														-- unset because mailing list is only used for cite mailing list
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];

		link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wikimarkup in |series-link= or wikimarkup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) and is_set (AirDate) then							-- promote airdate to date
			Date = AirDate;
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('series', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = '[[' .. ChapterLink .. '|' .. Chapter .. ']]';		-- ok to wikilink
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = '[[' .. ChapterLink .. '|' .. Series .. ']]';			-- series links with ChapterLink (episodelink -&gt; TitleLink -&gt; ChapterLink) ugly
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = '[[' .. SeriesLink .. '|' .. Series .. ']]';
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
-- end of {{cite episode}} stuff

-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, before generation of COinS data.
	do
		if in_array (config.CitationClass, {'arxiv', 'biorxiv', 'citeseerx'}) then
			if not is_set (ID_list[config.CitationClass:upper()]) then			-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp; |citeseerx= required for their templates
				table.insert( z.message_tail, { set_error( config.CitationClass .. '_missing', {}, true ) } );		-- add error message
			end
			
			if 'arxiv' == config.CitationClass then
				Periodical = 'arXiv';											-- set to arXiv for COinS; after that, must be set to empty string
			end
			if 'biorxiv' == config.CitationClass then
				Periodical = 'bioRxiv';											-- set to bioRxiv for COinS; after that, must be set to empty string
			end
			if 'citeseerx' == config.CitationClass then
				Periodical = 'CiteSeerX';										-- set to CiteSeerX for COinS; after that, must be set to empty string
			end
		end
	end

-- handle type parameter for those CS1 citations that have default values
	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;interview&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
		TitleType = substitute( cfg.messages['type'], TitleType);				-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {['access-date']=AccessDate, ['archive-date']=ArchiveDate, ['date']=Date, ['doi-broken-date']=DoiBroken,
				['embargo']=Embargo, ['lay-date']=LayDate, ['publication-date']=PublicationDate, ['year']=Year};

		anchor_year, Embargo, error_message = dates(date_parameters_list, COinS_date);

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end
		
		if not is_set(error_message) then										-- error free dates only
			local modified = false;												-- flag
			if is_set (DF) then													-- if we need to reformat dates
				modified = reformat_dates (date_parameters_list, DF, false);	-- reformat to DF format, use long month names if appropriate
			end

			if true == date_hyphen_to_dash (date_parameters_list) then					-- convert hyphens to dashes where appropriate
				modified = true;
				add_maint_cat ('date_format');									-- hyphens were converted so add maint category
			end
			
			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'];				-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'];
				Date = date_parameters_list['date'];
				DoiBroken = date_parameters_list['doi-broken-date'];
				LayDate = date_parameters_list['lay-date'];
				PublicationDate = date_parameters_list['publication-date'];
			end
		else
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end
	end	-- end of do

-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);											-- 

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
			if is_set(AccessDate) then											-- access date requires |url=; pmc created url is not |url=
				table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
				AccessDate = '';												-- unset
			end

		end
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
			if 'episode' == config.CitationClass then							-- special case for cite episode; TODO: is there a better way to do this?
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
			else
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
			end
	end
	
	if 'none' == Title and in_array (config.CitationClass, {'journal', 'citation'}) and is_set (Periodical) and 'journal' == A:ORIGIN('Periodical') then	-- special case for journal cites
		Title = '';																-- set title to empty string
		add_maint_cat ('untitled');
	end

	check_for_url ({															-- add error message when any of these parameters contains a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[A:ORIGIN('Periodical')]=Periodical,
		[A:ORIGIN('PublisherName')] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = Periodical,
		['Encyclopedia'] = Encyclopedia,
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

-- Account for the oddities that are {{cite arxiv}}, AFTER generation of COinS data.
--	if 'arxiv' == config.CitationClass then										-- we have set rft.jtitle in COinS to arXiv, now unset so it isn't displayed
	if in_array (config.CitationClass, {'arxiv', 'biorxiv', 'citeseerx'}) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, or CiteSeerX now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = substitute (cfg.messages['newsgroup'], external_link( 'news:' .. PublisherName, PublisherName, A:ORIGIN('PublisherName'), nil ));
		end
	end



	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text,											-- get current page name so that we don't wikilink to it via editorlinkn
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_authors_editors (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if is_set (Editors) then
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
					EditorCount = 2;											-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
				else
					EditorCount = 2;											-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
				end
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum = #interviewers_list;							-- number of interviewerss
			Interviewers = list_people(control, interviewers_list, false);	-- et al not currently supported
		end
		do																		-- now do translators
			control.maximum = #t;												-- number of translators
			Translators = list_people(control, t, false);						-- et al not currently supported
		end
		do																		-- now do contributors
			control.maximum = #c;												-- number of contributors
			Contributors = list_people(control, c, false);						-- et al not currently supported
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_authors_editors (A['DisplayAuthors'], #a, 'authors', author_etal);

			last_first_list = list_people(control, a, author_etal);

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false);	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if is_set (Authors) and is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

-- special case for chapter format so no error message or cat when chapter not supported
	if not (in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not is_set(URL) then
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then	-- |url= required for cite web, cite podcast, and cite mailinglist
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURLorigin, OriginalFormat, OriginalAccess;
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (ChapterURL) then 											-- URL not set so if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURLorigin = ChapterURLorigin;								-- name of chapter-url parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |format=
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				ChapterURLorigin = A:ORIGIN('ArchiveURL')						-- name of archive-url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
			end
		elseif is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURLorigin = URLorigin;										-- name of url parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived urls
			end
 		end
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			local chap_param;
			if is_set (Chapter) then											-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif is_set (ScriptChapter) then
				chap_param = A:ORIGIN ('ScriptChapter')
			else is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if is_set (chap_param) then											-- if we found one
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {chap_param}, true ) } );		-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if is_set (Contribution) and 0 &lt; #c then								-- if this is a contribution with contributor(s)
			if in_array (Contribution:lower(), cfg.keywords.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, Chapter, TransChapter, ChapterURL, ChapterURLorigin, no_quotes);		-- Contribution is also in Chapter
		if is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter.. sepc .. ' ';
		elseif is_set (ChapterFormat) then										-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then
			
			Title = external_link( URL, Title, URLorigin, UrlAccess ) .. TransTitle .. TransError .. Format;
-- this experiment hidden 2016-04-10; see Help_talk:Citation_Style_1#Recycled_urls
--			local temp_title = external_link( URL, Title, URLorigin ) .. TransError .. Format;	-- do this so we get error message even if url is usurped no archive
--			if in_array (DeadURL, {'unfit no archive', 'usurped no archive'}) then	-- when url links to inappropriate location and there is no archive of original source available
--				local err_msg
--				if temp_title:match ('%[%S+%s+(.+)%](&lt;.+)') then				-- if there is an error message
--					Title, err_msg = temp_title:match ('%[%S+%s+(.+)%](&lt;.+)');	-- strip off external link; TODO: find a better to do this
--					Title = Title .. (err_msg or '');
--				end
--			else
--				Title = temp_title;
--			end

			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		else
			Title = Title .. TransTitle .. TransError;
		end
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURLorigin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin, nil );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if is_set(Minutes) then
			if is_set (Time) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'minutes') .. ' and ' .. wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase, Mode);

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
		if 'mla' == Mode then
			Others = sepc .. ' Trans. ' .. Translators .. Others;
		else
			Others = sepc .. ' ' .. wrap_msg ('translated', Translators, use_lowercase) .. Others;
		end
	end
	if is_set (Interviewers) then
		Others = sepc .. ' ' .. wrap_msg ('interview', Interviewers, use_lowercase) .. Others;
	end
	
	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		if 'mla' == Mode then
			Edition = '. ' .. Edition .. ' ed.';
		else
			Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
		end
	else
		Edition = '';
	end

	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	if 'mla' == Mode then														-- not in brackets for mla
		OrigYear = is_set(OrigYear) and (&quot;. &quot; .. OrigYear) or &quot;&quot;;
	else
		OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	end
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase, Mode);

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

--[[
Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
note is displayed. There are no error messages for this condition.

]]
	if is_set (SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif is_set (RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if 'mla' == Mode then													-- retrieved text not used in mla
			AccessDate = ' ' .. AccessDate;
		else
			if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end			-- if mode is cs2, lower case
			AccessDate = substitute (retrv_text, AccessDate);					-- add retrieved text
		end
		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {IdAccessLevels=ID_access_levels, DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin, UrlAccess );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then				-- if first and last characters of quote are quote marks
			Quote = Quote:sub(2,-2);											-- strip them off
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- DeadURL is empty, 'yes', 'true', 'y', 'unfit', 'usurped'
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if in_array (DeadURL, {'unfit', 'usurped', 'bot: unknown'}) then
				Archived = sepc .. &quot; &quot; .. 'Archived from the original on ' .. ArchiveDate;	-- format already styled
				if 'bot: unknown' == DeadURL then
					add_maint_cat ('bot:_unknown');								-- and add a category if not already added
				else
					add_maint_cat ('unfit');									-- and add a category if not already added
				end
			else																-- DeadURL is empty, 'yes', 'true', or 'y'
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURLorigin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURLorigin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin, nil );
	end

	local Publisher;
	if is_set(PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if is_set(PublisherName) then
		if is_set(PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif is_set(PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		if 'mla' == Mode then
			tcommon = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
		else
			tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
				Language, Edition, Publisher, Agency, Volume}, sepc );
		end		
	elseif in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(Periodical) then		-- special cases for book cites
		if is_set (Contributors) then											-- when we are citing foreword, preface, introduction, etc
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			if 'mla' == Mode then
				tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Edition, Publisher, Agency}, sepc );
			else
				tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
			end
		elseif 'mla' == Mode then
			tcommon = safe_join( {TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Transcript, Language, Edition, Publisher}, sepc );

	elseif ('news' == config.CitationClass) and ('mla' == Mode) then			-- special case for cite news in MLA mode
		tcommon = safe_join( {Periodical, Format, TitleType, Series, Language, Edition, Agency}, sepc );

	elseif ('web' == config.CitationClass) and ('mla' == Mode) then				-- special case for cite web in MLA mode
		tcommon = safe_join( {Periodical, Format, TitleType, Series, Language, 
			Edition, Publisher, Agency}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if is_set(Date) then
		if ('mla' == Mode) then
			if in_array (config.CitationClass, {'book', 'news', 'web'}) then
				Date = ', ' .. Date;											-- origyear follows title in mla
			elseif 'journal' == config.CitationClass then
				Date = ', (' .. Date .. ')';
			end
		elseif is_set (Authors) or is_set (Editors) then						-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;;				-- in paranetheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon,-1,-1) == sepc) then							-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigYear;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigYear;							-- Date begins with sepc
			end
		end
	end	
	if is_set(Authors) then
		if (not is_set (Date)) or ('mla' == Mode) then							-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) and 0 == #c and 'mla' ~= Mode then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then in_text = in_text:lower() end				-- lowercase for cs2
			elseif is_set(Chapter) and 'mla' == Mode then
				if EditorCount &lt;= 1 then
					in_text = '. Ed. ';
				else
					in_text = '. Eds. ';
				end
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if is_set (Contributors) then											-- book cite and we're citing the intro, preface, etc
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if is_set (Editors) and is_set (Date) and ('mla' ~= Mode) then		-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not is_set (Date)) or ('mla' == Mode) then											-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			if 'mla' == Mode then
				text = safe_join( {Contributors, Chapter, tcommon, OrigYear, Authors, Place, Others, Editors, tcommon2, Date, pgtext, idcommon }, sepc );
			else
				text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
			end
		elseif 'mla' == Mode then
			tcommon = tcommon .. Date;											-- hack to avoid duplicate separators
			text = safe_join( {Authors, Chapter, Title, OrigYear, Others, Editors, Edition, Place, tcommon, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		if 'mla' == Mode then
			if in_array(config.CitationClass, {'journal', 'news', 'web'}) and is_set(Periodical) then
				text = safe_join( {Editors, Title, Place, tcommon, pgtext, Date, idcommon}, sepc );
			else
				text = safe_join( {Editors, Chapter, Title, Place, tcommon, Date, pgtext, idcommon}, sepc );
			end
		else
			text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
		end
	elseif 'mla' == Mode then
		if in_array(config.CitationClass, {'journal', 'news', 'web'}) and is_set(Periodical) then
			text = safe_join( {Title, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Title, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	else
		if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = config.CitationClass;
		options.class = &quot;citation &quot; .. config.CitationClass;					-- class=citation required for blue highlight when used with |ref=
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then								-- set reference anchor if appropriate
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			if #namelist &gt; 0 then												-- if there are names in namelist
				id = anchor_id (namelist, year);								-- go make the CITEREF anchor
			else
				id = '';														-- unset
			end
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;(.-)&lt;/span&gt;&quot;, &quot;%1&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then	-- remove &lt;span&gt; tags and other html-like markup; then get length of what remains
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then													-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		text = substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text});	-- when |ref= is set
	else
		text = substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text});	-- all other cases
	end		

	text = text .. substitute (cfg.presentation['ocins'], {OCinSoutput});		-- append metadata to the citation
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. error_comment( v[1], v[2] );
				else
					text = text .. error_comment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end

	if #z.maintenance_cats ~= 0 then
		text = text .. '&lt;span class=&quot;citation-comment&quot; style=&quot;display:none; color:#33aa33; margin-left:0.3em&quot;&gt;';
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. v .. ' ([[:Category:' .. v ..'|link]])';
		end
		text = text .. '&lt;/span&gt;';												-- maintenance mesages (realy just the names of the categories for now)
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end


--[[--------------------------&lt; C S 1 . C I T A T I O N &gt;------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

function cs1.citation(frame)
	Frame = frame;																-- save a copy incase we need to display an error message in preview mode
	local pframe = frame:getParent()
	local validation, utilities, identifiers, metadata;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (utilities);								-- so that functions in Date validataion can see the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	dates = validation.dates;													-- imported functions from Module:Citation/CS1/Date validation
	year_date_check = validation.year_date_check;
	reformat_dates = validation.reformat_dates;
	date_hyphen_to_dash = validation.date_hyphen_to_dash;
	
	is_set = utilities.is_set;													-- imported functions from Module:Citation/CS1/Utilities
	in_array = utilities.in_array;
	substitute = utilities.substitute;
	error_comment = utilities.error_comment;
	set_error = utilities.set_error;
	select_one = utilities.select_one;
	add_maint_cat = utilities.add_maint_cat;
	wrap_style = utilities.wrap_style;
	safe_for_italics = utilities.safe_for_italics;
	remove_wiki_link = utilities.remove_wiki_link;

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	extract_ids = identifiers.extract_ids;										-- imported functions from Module:Citation/CS1/Identifiers
	build_id_list = identifiers.build_id_list;
	is_embargoed = identifiers.is_embargoed;
	extract_id_access_levels = identifiers.extract_id_access_levels;
	
	make_coins_title = metadata.make_coins_title;								-- imported functions from Module:Citation/CS1/COinS
	get_coins_pages = metadata.get_coins_pages;
	COinS = metadata.COinS;

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text, error_state;

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do
		config[k] = v;
--		args[k] = v;															-- debug tool that allows us to render a citation from module {{#invoke:}}
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k, config.CitationClass ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower(), config.CitationClass ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute( param, capture );				-- add the capture to the suggested parameter (typically the enumerator)
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, param}, true );	-- set the error message
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			missing_pipe_check (v);												-- do we think that there is a parameter that is missing a pipe?
			
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);
		end
	end
	return citation0( config, args)
end

return cs1;</text>
      <sha1>joycwwvkv1un67jzdwyyhg1pdnutfbe</sha1>
    </revision>
    <revision>
      <id>4716</id>
      <parentid>4715</parentid>
      <timestamp>2017-05-28T13:34:26Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>interim fix to kern_quotes(); see [[Help_talk:Citation_Style_1#single_quote_for_an_ASCII_quote|discussion]];</comment>
      <origin>4716</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="167324" sha1="3f3q4btal4dccpz3fgm2gs5lzro4q94" xml:space="preserve">
local cs1 ={};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local dates, year_date_check, reformat_dates, date_hyphen_to_dash				-- functions in Module:Citation/CS1/Date_validation

local is_set, in_array, substitute, error_comment, set_error, select_one,		-- functions in Module:Citation/CS1/Utilities
	add_maint_cat, wrap_style, safe_for_italics, remove_wiki_link;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local extract_ids, extract_id_access_levels, build_id_list, is_embargoed;		-- functions in Module:Citation/CS1/Identifiers

local make_coins_title, get_coins_pages, COinS;									-- functions in Module:Citation/CS1/COinS

local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

delare variables here that have page-wide scope that are not brought in from other modules; thatare created here
and used here

]]

local added_deprecated_cat;														-- boolean flag so that the category is added only once
local added_prop_cats = {};														-- list of property categories that have been added to z.properties_cats
local added_vanc_errs;															-- boolean flag so we only emit one Vancouver error / category

local Frame;																	-- holds the module's frame table


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end

--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

added_prop_cats is a table declared in page scope variables above

]]

local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));		-- make name then add to table
	end
end

--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a boolean declared in page scope variables above

]]

local function add_vanc_error (source)
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {source}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a uri scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of tlds: https://www.iana.org/domains/root/db

rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the tld.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a url with a scheme) will be stripped
here.  Perhaps not necessary but retained incase it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ascii characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the tld) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org TLD
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and tld or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%a%d]') then										-- first character must be letter or digit
		return false;
	end
																				-- Do most common case first
	if domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.%a%a+$') then				-- three or more character hostname.hostname or hostname.tld
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.xn%-%-[%a%d]+$') then	-- internationalized domain name with ACE prefix
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.org$') then							-- one character .org hostname
		return true;
	elseif domain:match ('%f[%a][qxz]%.com$') then								-- assigned one character .com hostname (x.com times out 2015-12-10)
		return true;
	elseif domain:match ('%f[%a][iq]%.net$') then								-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.%a%a$') then							-- one character hostname and cctld (2 chars)
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d]%.%a%a+$') then					-- two character hostname and tld
		return true;
	elseif domain:match ('^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?') then		-- IPv4 address
		return true;
	else
		return false;
	end
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a url appear to be a valid url; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if is_set (scheme) then														-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when url is protocol relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a url into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following tld) (if any) and any path(/), query(?) or fragment(#).

If protocol relative url, return nil scheme and domain else return nil for both scheme and domain.

When not protocol relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol relative url
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		authority = authority:gsub ('//', '', 1);								-- replace place 1 pair of '/' with nothing;
		if is_set(authority) then												-- if anything left (1 or 3+ '/' where authority should be) then
			return scheme;														-- return scheme only making domain nil which will cause an error message
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link= etc for properly formatted content: no wikilinks, no urls

Link parameters are to hold the title of a wikipedia article so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki urls and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid url (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid url (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from url; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid url
end

--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wikilinked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

]]

local function link_title_ok (link, lorig, title, torig)
local orig;

	if is_set (link) then 														-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		end
	end

	if is_set (orig) then
		table.insert( z.message_tail, { set_error( 'bad_paramlink', orig)});	-- url or wikilink in |title= with |title-link=;
	end
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the url into scheme and domain
portions, or for protocol relative (//example.com) urls, just the domain.  Use is_url() to validate the two
portions of the url.  If both are valid, or for protocol relative if domain is valid, return true, else false.

Because it is different from a standard url, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper url
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from url;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a url.  The test will also find external wikilinks
that use protocol relative urls. Also finds bare urls.

The frontier pattern prevents a match on interwiki links which are similar to scheme:path urls.  The tests that
find bracketed urls are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol relative ext wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare url with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol relative bare url: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a url
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then												-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end

--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source, access)
	local error_str = &quot;&quot;;
	local domain;
	local path;
	local base_url;
	
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the url into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['[']='%5b',[']']='%5d'});					-- replace '[' and ']' with their percent encoded values
		URL=domain..path;														-- and reassemble
	end
	
	if is_set (access) then														-- access level (subscription, registration, limited)
		local label_head = '';
		local label_tail;
		local markup = '';														-- can't start a span inside italic markup and end it outside the italic markup

		label = safe_for_url (label);											-- replace square brackets and newlines (is this necessary? already done above?)
		if label:match (&quot;(.*)%s+(.+)('''?)$&quot;) then								-- for italicized titles (cite book, etc)
			label_head, label_tail, markup = label:match (&quot;(.*)%s+(.+)('''?)$&quot;);	-- split the label at the right-most space; separate the markup
		elseif label:match (&quot;(.*)%s+(.+)$&quot;) then								-- for upright titles (journal, news, magazine, etc)
			label_head, label_tail = label:match (&quot;(.*)%s+(.+)$&quot;);				-- split the label at the right-most space; no markup 
		elseif label:match (&quot;(.+)('''?)$&quot;) then									-- single word label with markup
			label_tail, markup = label:match (&quot;(.+)('''?)$&quot;);					-- save label text as label tail; separate the markup
		else
			label_tail = label;
		end

		base_url = table.concat (
			{
			'&lt;span class=&quot;plainlinks&quot;&gt;[',										-- opening css
			URL,																-- the url
			' ',																-- the required space
			label_head,															-- all but the last word of the label
			' &lt;span class=&quot;nowrap&quot;&gt;',											-- nowrap css for the last word and the signal icon
			label_tail,															-- last (or only) word of the label inside the span
			'&lt;span style=&quot;padding-left:0.15em&quot;&gt;',								-- signal spacing css
			cfg.presentation[access],											-- the appropriate icon
			'&lt;/span&gt;&lt;/span&gt;',													-- close signal spacing and nowrap spans
			markup,																-- insert italic markup if any
			']&lt;/span&gt;'															-- close the plain links span
			});
	else
		base_url = table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url( label ), &quot;]&quot; });	-- no signal markup
	end
	
	return table.concat({ base_url, error_str });
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end

--[[--------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote mark contained in a |title= or |chapter= parameter's value.
This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Replaces unicode quotemarks with typewriter quote marks regardless of the need for kerning.

Call this function for chapter titles, for website titles, etc; not for book titles.

]]

local function kern_quotes (str)
	local cap='';
	local cap2='';
																				-- TODO: move this elswhere so that all title-holding elements get these quote marks replaced?
--	str= mw.ustring.gsub (str, '[“”]', '\&quot;');									-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
--	str= mw.ustring.gsub (str, '[‘’]', '\'');									-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)
	
	cap, cap2 = str:match (&quot;^([\&quot;\'])([^\'].+)&quot;);								-- match leading double or single quote but not double single quotes
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-left'], {cap, cap2});
	end

	cap, cap2 = str:match (&quot;^(.+[^\'])([\&quot;\'])$&quot;)
	if is_set (cap) then
		str = substitute (cfg.presentation['kern-right'], {cap, cap2});
	end
	return str;
end

--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title= and |script-chapter=

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, cfg.script_lang_codes) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				add_prop_cat ('script')
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end

--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return substitute( msg, str );										-- including template text
	else
		return substitute( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (scriptchapter, chapter, transchapter, chapterurl, chapter_url_source, no_quotes)
	local chapter_error = '';
	
	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);										-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
			chapter = wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, scriptchapter)						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (transchapter) then
		transchapter = wrap_style ('trans-quoted-title', transchapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. transchapter;
		else																	-- here when transchapter without chapter or script-chapter
			chapter = transchapter;												-- 
			chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
		end
	end

	if is_set (chapterurl) then
		chapter = external_link (chapterurl, chapter, chapter_url_source, nil);		-- adds bare_url_missing_title error if appropriate
	end

	return chapter .. chapter_error;
end

--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Detects but ignores the character pattern that results from the transclusion of {{'}} templates.

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i=1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- Test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position then
			if 'nowiki' == capture or 'math' == capture then 					-- nowiki, math stripmarker (not an error condition)
				stripmarker = true;												-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { set_error( 'invisible_char', {err_msg, wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i=i+1;																	-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end

--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

--local function validate( name )
local function validate( name, cite_class )
	local name = tostring( name );
	local state;
	
	if in_array (cite_class, {'arxiv', 'biorxiv', 'citeseerx'}) then				-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[ name ];
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end

		if 'arxiv' == cite_class then											-- basic parameters unique to these templates
			state = whitelist.arxiv_basic_arguments[name];
		end
		if 'biorxiv' == cite_class then
			state = whitelist.biorxiv_basic_arguments[name];
		end
		if 'citeseerx' == cite_class then
			state = whitelist.citeseerx_basic_arguments[name];
		end

		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
																				-- limited enumerated parameters list
		name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#)
		state = whitelist.limited_numbered_arguments[ name ];
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates
		
	state = whitelist.basic_arguments[ name ];									-- all other templates; all normal parameters allowed
											
	if true == state then return true; end										-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);											-- parameter is deprecated but still supported
		return true;
	end
																				-- all enumerated parameters allowed
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );												-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];

	if true == state then return true; end										-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);											-- parameter is deprecated but still supported
		return true;
	end
	
	return false;																-- not supported because not found or name is set to nil
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end

--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash

]]

local function hyphen_to_dash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if comp:sub(1,1) == duplicate_char then								-- is first charactier same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for th
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = str:sub(-1,-1);										-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = str:sub(1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = str:sub(1, -4) .. &quot;''&quot;;							-- remove them and add back ''
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then		-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then		-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then			-- if last two chars of str are sepc] external link
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;'']&quot; then		-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then				-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = str:sub(1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end		-- if duplicate_char not a letter then escape it
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )			-- remove duplicate_char if it follows html markup
					else
						value = value:sub( 2, -1 );								-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end  


--[[--------------------------&lt; I S _ S U F F I X &gt;------------------------------------------------------------

returns true is suffix is properly formed Jr, Sr, or ordinal in the range 2–9.  Puncutation not allowed.

]]

local function is_suffix (suffix)
	if in_array (suffix, {'Jr', 'Sr', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end

--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written ouside of the code editor and pasted here because the code editor gets confused between character insertion point and cursor position.
The test has been rewritten to use decimal character escape sequence for the individual bytes of the unicode characters so that it is not necessary
to use an external editor to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first)
	local first, suffix = first:match ('(.-),?%s*([%dJS][%drndth]+)%.?$') or first;		-- if first has something that looks like a generational suffix, get it

	if is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error ('suffix');
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error ('non-Latin character');
			return false;														-- not a string of latin characters; Vancouver requires Romanization
	end;
	return true;
end

--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just intials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error ('suffix');									-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word


	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i],1,1));				-- insert the intial at end of initials table
		end
		i = i+1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end

--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = ',';																-- name-list separator between authors is a comma
		namesep = ' ';															-- last/first separator is a space
	elseif 'mla' == control.mode then
		sep = ',';																-- name-list separator between authors is a comma
		namesep = ', '															-- last/first separator is &lt;comma&gt;&lt;space&gt;
	else
		sep = ';'																-- name-list separator between authors is a semicolon
		namesep = ', '															-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then
					if 'mla' == control.mode then 
						if i == 1 then											-- for mla
							one = one .. namesep .. first;						-- first name last, first
						else													-- all other names
							one = first .. ' ' .. one;							-- first last
						end
					else
						if ( &quot;vanc&quot; == format ) then								-- if vancouver format
							one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
							if not person.corporate and is_good_vanc_name (one, first) then					-- and name is all Latin characters; corporate authors not tested
								first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
							end
						end
						one = one .. namesep .. first;
					end
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = &quot;[[&quot; .. person.link .. &quot;|&quot; .. one .. &quot;]]&quot;				-- link author/editor if this page is not the author's/editor's page
				end
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			if 'mla' == control.mode then
				text[#text-2] = &quot;, and &quot;;										-- replace last separator with ', and ' text
			else
				text[#text-2] = &quot; &amp; &quot;;											-- replace last separator with ampersand text
			end
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end

--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]
local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of author and editor name parameters for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the parameters |display-authors=etal or |display-editors=etal

]]

local function name_has_etal (name, etal, nocat)

	if is_set (name) then														-- name can be nil in which case just return
		local etal_pattern = &quot;[;,]? *[\&quot;']*%f[%a][Ee][Tt] *[Aa][Ll][%.\&quot;']*$&quot;	-- variations on the 'et al' theme
		local others_pattern = &quot;[;,]? *%f[%a]and [Oo]thers&quot;;					-- and alternate to et al.
		
		if name:match (etal_pattern) then										-- variants on et al.
			name = name:gsub (etal_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		elseif name:match (others_pattern) then									-- if not 'et al.', then 'and others'?
			name = name:gsub (others_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		end
	end
	return name, etal;															-- 
end


--[[--------------------------&lt; N A M E _ H A S _ E D _ M A R K U P &gt;------------------------------------------

Evaluates the content of author and editor parameters for extranious editor annotations: ed, ed., eds, (Ed.), etc.
These annotation do not belong in author parameters and are redundant in editor parameters.  If found, the function
adds the editor markup maintenance category.

]]

local function name_has_ed_markup (name, list_name)
	local _, pattern;
	local patterns = {															-- these patterns match annotations at end of name
		'%f[%(%[][%(%[]%s*[Ee][Dd][Ss]?%.?%s*[%)%]]?$',							-- (ed) or (eds): leading '(', case insensitive 'ed', optional 's', '.' and/or ')'
		'[,%.%s]%f[e]eds?%.?$',													-- ed or eds: without '('or ')'; case sensitive (ED could be initials Ed could be name)
		'%f[%(%[][%(%[]%s*[Ee][Dd][Ii][Tt][Oo][Rr][Ss]?%.?%s*[%)%]]?$',			-- (editor) or (editors): leading '(', case insensitive, optional '.' and/or ')'
		'[,%.%s]%f[Ee][Ee][Dd][Ii][Tt][Oo][Rr][Ss]?%.?$',						-- editor or editors: without '('or ')'; case insensitive
		
																				-- these patterns match annotations at beginning of name
		'^eds?[%.,;]',															-- ed. or eds.: lower case only, optional 's', requires '.'
		'^[%(%[]%s*[Ee][Dd][Ss]?%.?%s*[%)%]]',									-- (ed) or (eds): also sqare brackets, case insensitive, optional 's', '.'
		'^[%(%[]?%s*[Ee][Dd][Ii][Tt][Oo][Rr][Ss]?%A',							-- (editor or (editors: also sq brackets, case insensitive, optional brackets, 's'
		'^[%(%[]?%s*[Ee][Dd][Ii][Tt][Ee][Dd]%A',								-- (edited: also sq brackets, case insensitive, optional brackets

		}

	if is_set (name) then
		for _, pattern in ipairs (patterns) do									-- spin through patterns table and
			if name:match (pattern) then
				add_maint_cat ('extra_text_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
				break;
			end
		end
	end
	return name;																-- and done
end


--[[--------------------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;----------------------------------------

Evaluates the content of author and editor (surnames only) parameters for multiple names.  Multiple names are
indicated if there is more than one comma and or semicolon.  If found, the function adds the multiple name
(author or editor) maintenance category.

]]

local function name_has_mult_names (name, list_name)
local count, _;
	if is_set (name) then
		_, count = name:gsub ('[;,]', '');										-- count the number of separator-like characters
		
		if 1 &lt; count then														-- param could be |author= or |editor= so one separator character is acceptable
			add_maint_cat ('mult_names', cfg.special_case_translation [list_name]);	-- more than one separator indicates multiple names so add a maint cat for this template
		end
	end
	return name;																-- and done
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------
This function calls various name checking functions used to validate the content of the various name-holding
parameters.

]]

local function name_checks (last, first, list_name)
	if is_set (last) then
		if last:match ('^%(%(.*%)%)$') then										-- if wrapped in doubled parentheses, accept as written 
			last = last:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			last = name_has_mult_names (last, list_name);						-- check for multiple names in the parameter (last only)
			last = name_has_ed_markup (last, list_name);						-- check for extraneous 'editor' annotation
		end
	end
	if is_set (first) then
		if first:match ('^%(%(.*%)%)$') then									-- if wrapped in doubled parentheses, accept as written 
			first = first:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			first = name_has_ed_markup (first, list_name);						-- check for extraneous 'editor' annotation
		end
	end
	return last, first;															-- done
	end


--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary
	while true do
		last = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false);							-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false);						-- find and remove variations on et al.
		last, first= name_checks (last, first, list_name);						-- multiple names, extraneous annotation, etc checks
		
		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			link_title_ok (link, list_name:match (&quot;(%w+)List&quot;):lower() .. '-link' .. i, last, list_name:match (&quot;(%w+)List&quot;):lower() .. '-last' .. i);	-- check for improper wikimarkup

			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end

--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because case of the source may be incorrect
or different from the case that WikiMedia uses, the name comparisons are done in lower case and when a match is
found, the Wikimedia version (assumed to be correct) is returned along with the code.  When there is no match, we
return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') return a list of languages that in some cases may include
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.

Names but that are included in the list will be found if that name is provided in the |language= parameter.  For example,
if |language=Chavacano de Zamboanga, that name will be found with the associated code 'cbk-zam'.  When names are found
and the associated code is not two or three characters, this function returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	if 'bangla' == lang:lower() then											-- special case related to Wikimedia remap of code 'bn' at mw:Extension:CLDR
		return 'Bengali', 'bn';													-- make sure rendered version is properly capitalized
	end

	local languages = mw.language.fetchLanguageNames(this_wiki_code, 'all')		-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() and 3 ~= code:len() then							-- two- or three-character codes only; extensions not supported
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the the code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for the code
end


--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code is recognized by MediaWiki,
use the returned name; if not, then use the value that was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is assigned to the category for
that code: Category:Norwegian-language sources (no).  For valid three-character code languages, the page is assigned
to the single category for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does not recognize three-character
equivalents of two-character codes: code 'ar' is recognized bit code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are
separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki = mw.getContentLanguage();									-- get a language object for this wiki
	local this_wiki_code = this_wiki:getCode()									-- get this wiki's language code
	local this_wiki_name = mw.language.fetchLanguageName(this_wiki_code, this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang

		if lang:match ('^%a%a%-') then											-- strip ietf language tags from code; TODO: is there a need to support 3-char with tag?
			lang = lang:match ('(%a%a)%-')										-- keep only 639-1 code portion to lang; TODO: do something with 3166 alpha 2 country code?
		end
		if 2 == lang:len() or 3 == lang:len() then								-- if two-or three-character code
			name = mw.language.fetchLanguageName( lang:lower(), this_wiki_code);	-- get language name if |language= is a proper code
		end
	
		if is_set (name) then													-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, this_wiki_code);				-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then													-- only 2- or 3-character codes
			if 'bn' == code then name = 'Bengali' end;							-- override wikimedia when code is 'bn'
			if this_wiki_code ~= code then										-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					add_prop_cat ('foreign_lang_source', {name, code})			-- categorize it
				else															-- or is a recognized language (but has a three-character code)
					add_prop_cat ('foreign_lang_source_2', {code})				-- categorize it differently TODO: support mutliple three-character code categories per cs1|2 template
				end
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, ' and ')							-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		language_list[code] = 'and ' .. language_list[code];					-- prepend last name with 'and&lt;space&gt;'
		name = table.concat (language_list, ', ')								-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
	end
	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end

--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = '.';																-- terminate the rendered citation with a period
	end
	return '.', ps;																-- separator is a full stop
end

--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = '';																-- make sure it isn't nil
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return ',', ps, ref;														-- separator is a comma
end

--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	elseif 'mla' == mode then													-- if this template is to be rendered in mla style use cs1 for bot cs1 &amp; cs2 templates
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end

--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extension, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf[%?#]?') or url:match ('%.PDF[%?#]?');
end

--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parenthases, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end

--[[--------------------------&lt; G E T _ D I S P L A Y _ A U T H O R S _ E D I T O R S &gt;------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_authors_editors (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_auth_ed', cfg.special_case_translation [list_name]);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end

--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
--	local good_pattern = '^P[^%.P%l]';
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
--	local bad_pattern = '^[Pp][Pp]';
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
--		if Page:match ('^[Pp]?[Pp]%.?[ %d]') or  Page:match ('^[Pp]ages?[ %d]') or
--			Pages:match ('^[Pp]?[Pp]%.?[ %d]') or  Pages:match ('^[Pp]ages?[ %d]') then
--				add_maint_cat ('extra_text');
--		end
end

--[[--------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vautthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parnetheses were included in the
rendered citation and in the metadata.

	|vauthors=Jones AB, White EB, ((Black, Brown, and Co.))

This code is experimental and may not be retained.

]]
local function get_v_name_table (vparam, output_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parens
			local name = name_table[i];
			i=i+1;																-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parens
					break;														-- and done reassembling so
				end
				i=i+1;															-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
		else
			table.insert (output_table, name_table[i]);							-- add this name 
		end
		i = i+1;
	end	
	return output_table;
end

--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	if vparam:find ('%[%[') or vparam:find ('%]%]')	then						-- no wikilinking vauthors names
		add_vanc_error ('wikilink');
	end
	v_name_table = get_v_name_table (vparam, v_name_table);						-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parentheses to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')								-- remove doubled parntheses
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error ('punctuation');
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
			if is_suffix (first) then											-- if a valid suffix
				suffix = first													-- save it as a suffix and
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end																	-- no suffix error message here because letter combination may be result of Romanization; check for digits?
			last = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error ('missing comma');								-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error ('name');										-- matches a space between two intiials
			end
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error ('initials');									-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first);									-- check first and last before restoring the suffix which may have a non-Latin digit
			if is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '');
			end
		end
																				-- this from extract_names ()
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice incase we have a |first1= without a |last1=; this ...
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or	-- ... also catches the case where |first= is used with |vauthors=
		select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, no, etc).  When the parameter value has not been assigned a value (missing or empty
in the source template) the function refurns true.  If the parameter value is one of the list of allowed values returns
true; else, emits an error message and returns false.

]]

local function is_valid_parameter_value (value, name, possible, cite_class)
-- begin hack to limit |mode=mla to a specific set of templates
	if ('mode' == name) and ('mla' == value) and not in_array (cite_class, {'book', 'journal', 'news'}) then
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
-- end hack

	if not is_set (value) then
		return true;															-- an empty parameter is ok
	elseif in_array(value:lower(), possible) then
		return true;
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list,-3,-1) == sepc .. '. ') then						-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list,-1,-1) == sepc) or (string.sub (name_list,-3,-1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terninate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower, mode)
	if not is_set (volume) and not is_set (issue) then
		return '';
	end
	
	if ('mla' == mode) and ('journal' == cite_class) then						-- same as cs1 for magazines
		lower = true;															-- mla 8th edition; force these to lower case
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return '';
		end
	end

	if 'magazine' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end

	local vol = '';
		
	if is_set (volume) then
		if (4 &lt; mw.ustring.len(volume)) then
			vol = substitute (cfg.messages['j-vol'], {sepc, volume});
		else
			vol = substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});
		end
	end
	if is_set (issue) then
		return vol .. substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end


--[[-------------------------&lt; N O R M A L I Z E _ P A G E _ L I S T &gt;-----------------------------------------

not currently used

normalizes a comma, ampersand, and/or space separated list to be '&lt;value&gt;, &lt;value&gt;, ..., &lt;value&gt;'
returns list unchanged if there are no commas else strips whitespace and then reformats the list

]]
--[[
local function normalize_page_list (list)
	if not list:find ('[,&amp; ]') then return list end								-- if list is not delimited with commas, ampersands, or spaces; done
	
	list = mw.text.split (list, '[,&amp;%s]+');										-- make a table of values
	list = table.concat (list, ', ');											-- and now make a normalized list
	return list;
end
]]


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower, mode)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'journal' == origin);
	
	if is_journal and 'mla' == mode then
		is_journal = false;														-- mla always uses p &amp; pp
	end

	if is_set (page) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif is_set(pages) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then										-- if pages is only digits, assume a single page number
			return '', substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org urls to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot url or to calendar pages.  When the archive url is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the url.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org url does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command url
	|archive-url= is an archive.org url that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org urls:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this funct may return a modified
archive url:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the url unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.or url
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine url
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command url, we don't want to allow saving of the target page 
		err_msg = 'save command';
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = 'liveweb';
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');		-- split out some of the url parts for evaluation
		
		if not is_set(timestamp) or 14 ~= timestamp:len() then					-- path and flag optional, must have 14-digit timestamp here
			err_msg = 'timestamp';
			if '*' ~= flag then
				url=url:gsub ('(//web%.archive%.org/[^%d]*%d?%d?%d?%d?%d?%d?)[^/]*', '%1*', 1)	-- for preview, modify ts to be yearmo* max (0-6 digits plus splat)
			end
		elseif is_set(path) and 'web/' ~= path then								-- older archive urls do not have the extra 'web/' path element
			err_msg = 'path';
		elseif is_set (flag) and not is_set (path) then							-- flag not allowed with the old form url (without the 'web/' path element)
			err_msg = 'flag';
		elseif is_set (flag) and not flag:match ('%a%a_') then					-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = 'flag';
		else
			return url, date;													-- return archiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	table.insert( z.message_tail, { set_error( 'archive_url', {err_msg}, true ) } );	-- add error message and
	if is_set (Frame:preprocess('{{REVISIONID}}')) then
		return '', '';															-- return empty strings for archiveURL and ArchiveDate
	else
		return url, date;														-- preview mode so return archiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe:
	{{cite ... |title=Title access-date=2016-03-17}}

cs1|2 shares some parameter names with xml/html atributes: class=, title=, etc.  To prevent false positives xml/html
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove xml/html tags because attributes: class=, title=, etc 

	capture = value:match ('%s+(%a[%a%d]+)%s*=') or value:match ('^(%a[%a%d]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then								-- if the capture is a valid parameter name
		add_maint_cat ('missing_pipe');
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

-- set default parameter values defined by |mode= parameter.  If |mode= is empty or omitted, use CitationClass to set these values
	local Mode = A['Mode'];
	if not is_valid_parameter_value (Mode, 'mode', cfg.keywords['mode'], config.CitationClass) then
		Mode = '';
	end

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				add_maint_cat ('authors');										-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
			add_maint_cat ('editors');											-- but add a maint cat because use of this parameter is discouraged
		end
	end

	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	

	local interviewers_list = {};
	local Interviewers = A['Interviewers']
	if is_set (Interviewers) then												-- add a maint cat if the |interviewers= is used
		add_maint_cat ('interviewers');											-- because use of this parameter is discouraged
	else
		interviewers_list = extract_names (args, 'InterviewerList');			-- else, process preferred interviewers parameters
	end

	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list
	local Contribution = A['Contribution'];
	if in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not is_set (Contribution) then									-- |contributor= requires |contribution=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if select_one (args, cfg.aliases['ContributorList-Last'], 'redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { set_error( 'contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if not is_valid_parameter_value (NameListFormat, 'name-list-format', cfg.keywords['name-list-format']) then			-- only accepted value for this parameter is 'vanc'
		NameListFormat = '';													-- anything else, set to empty string
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
			link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wikimarkup in |title-link= or wikimarkup in |title= when |title-link= is set

	local Chapter = A['Chapter'];
	local ScriptChapter = A['ScriptChapter'];
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];

	local ArchiveDate;
	local ArchiveURL;

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	
	local DeadURL = A['DeadURL']
		if not is_valid_parameter_value (DeadURL, 'dead-url', cfg.keywords ['deadurl']) then	-- set in config.defaults to 'yes'
			DeadURL = '';														-- anything else, set to empty string
		end

	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];
	local Periodical_origin = A:ORIGIN('Periodical');							-- get the name of the periodical parameter

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;
																				-- previously conference books did not support volume
--	if in_array (config.CitationClass, cfg.templates_using_volume) and not ('conference' == config.CitationClass and not is_set (Periodical)) then
	if in_array (config.CitationClass, cfg.templates_using_volume) then
		Volume = A['Volume'];
	end
																				-- conference &amp; map books do not support issue
	if in_array (config.CitationClass, cfg.templates_using_issue) and not (in_array (config.CitationClass, {'conference', 'map'}) and not is_set (Periodical))then
		Issue = A['Issue'];
	end
	local Position = '';
	if not in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash( A['Pages'] );	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
		if not is_valid_parameter_value (RegistrationRequired, 'registration', cfg.keywords ['yes_true_y']) then
			RegistrationRequired=nil;
		end
	local SubscriptionRequired = A['SubscriptionRequired'];
		if not is_valid_parameter_value (SubscriptionRequired, 'subscription', cfg.keywords ['yes_true_y']) then
			SubscriptionRequired=nil;
		end
	local UrlAccess = A['UrlAccess'];
		if not is_valid_parameter_value (UrlAccess, 'url-access', cfg.keywords ['url-access']) then
			UrlAccess = nil;
		end
		if not is_set(URL) and is_set(UrlAccess) then
			UrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {'url'}, true ) } );
		end

		if is_set (UrlAccess) and is_set (SubscriptionRequired) then			-- while not aliases, these are much the same so if both are set
			table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'url-access') .. ' and ' .. wrap_style ('parameter', 'subscription')}, true ) } );		-- add error message
			SubscriptionRequired = nil;											-- unset; prefer |access= over |subscription=
		end
		if is_set (UrlAccess) and is_set (RegistrationRequired) then			-- these are not the same but contradictory so if both are set
			table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'url-access') .. ' and ' .. wrap_style ('parameter', 'registration')}, true ) } );		-- add error message
			RegistrationRequired = nil;											-- unset; prefer |access= over |registration=
		end


	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local Agency = A['Agency'];

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
		if not is_valid_parameter_value (IgnoreISBN, 'ignore-isbn-error', cfg.keywords ['yes_true_y']) then
			IgnoreISBN = nil;													-- anything else, set to empty string
		end
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );
	local ID_access_levels = extract_id_access_levels( args, ID_list );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
		if not is_valid_parameter_value (LastAuthorAmp, 'last-author-amp', cfg.keywords ['yes_true_y']) then
			LastAuthorAmp = nil;												-- set to empty string
		end
		if 'mla' == Mode then												
			LastAuthorAmp = 'yes';												-- replaces last author/editor separator with ' and ' text
		end
	local no_tracking_cats = A['NoTracking'];
		if not is_valid_parameter_value (no_tracking_cats, 'no-tracking', cfg.keywords ['yes_true_y']) then
			no_tracking_cats = nil;												-- set to empty string
		end

--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = A['DF'];															-- date format set in cs1|2 template
	if not is_valid_parameter_value (DF, 'df', cfg.keywords['date-format']) then	-- validate reformatting keyword
		DF = '';																-- not valid, set to empty string
	end

	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	select_one( args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'redundant_parameters' );		-- this is a dummy call simply to get the error message and category

	local NoPP = A['NoPP'] 
	if is_set (NoPP) and is_valid_parameter_value (NoPP, 'nopp', cfg.keywords ['yes_true_y']) then
		NoPP = true;
	else
		NoPP = nil;																-- unset, used as a flag later
	end

	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Pages = '';															-- unset the others
			At = '';
		end
		extra_text_in_page_check (Page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.
	elseif is_set(Pages) then
		if is_set(At) then
			At = '';															-- unset
		end
		extra_text_in_page_check (Pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.
	end	

-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
--[[
Parameter remapping for cite encyclopedia:
When the citation has these parameters:
	|encyclopedia and |title then map |title to |article and |encyclopedia to |title
	|encyclopedia and |article then map |encyclopedia to |title
	|encyclopedia then map |encyclopedia to |title

	|trans_title maps to |trans_chapter when |title is re-mapped
	|url maps to |chapterurl when |title is remapped

All other combinations of |encyclopedia, |title, and |article are not modified

]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					TransChapter = TransTitle;
					ChapterURL = URL;
					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter= '[[' .. TitleLink .. '|' .. Chapter .. ']]';
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			else																-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if is_set(A['Number']) then												-- cite techreport uses 'number', which other citations alias to 'issue'
			if not is_set(ID) then												-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', 'id') .. ' and ' .. wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	elseif 'mailinglist' == A:ORIGIN('Periodical') then
		Periodical = '';														-- unset because mailing list is only used for cite mailing list
	end

-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];

		link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wikimarkup in |series-link= or wikimarkup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) and is_set (AirDate) then							-- promote airdate to date
			Date = AirDate;
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('series', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = '[[' .. ChapterLink .. '|' .. Chapter .. ']]';		-- ok to wikilink
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = '[[' .. ChapterLink .. '|' .. Series .. ']]';			-- series links with ChapterLink (episodelink -&gt; TitleLink -&gt; ChapterLink) ugly
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = '[[' .. SeriesLink .. '|' .. Series .. ']]';
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
-- end of {{cite episode}} stuff

-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, before generation of COinS data.
	do
		if in_array (config.CitationClass, {'arxiv', 'biorxiv', 'citeseerx'}) then
			if not is_set (ID_list[config.CitationClass:upper()]) then			-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp; |citeseerx= required for their templates
				table.insert( z.message_tail, { set_error( config.CitationClass .. '_missing', {}, true ) } );		-- add error message
			end
			
			if 'arxiv' == config.CitationClass then
				Periodical = 'arXiv';											-- set to arXiv for COinS; after that, must be set to empty string
			end
			if 'biorxiv' == config.CitationClass then
				Periodical = 'bioRxiv';											-- set to bioRxiv for COinS; after that, must be set to empty string
			end
			if 'citeseerx' == config.CitationClass then
				Periodical = 'CiteSeerX';										-- set to CiteSeerX for COinS; after that, must be set to empty string
			end
		end
	end

-- handle type parameter for those CS1 citations that have default values
	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;interview&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
		TitleType = substitute( cfg.messages['type'], TitleType);				-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

--[[
Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
we get the date used in the metadata.

Date validation supporting code is in Module:Citation/CS1/Date_validation
]]
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {['access-date']=AccessDate, ['archive-date']=ArchiveDate, ['date']=Date, ['doi-broken-date']=DoiBroken,
				['embargo']=Embargo, ['lay-date']=LayDate, ['publication-date']=PublicationDate, ['year']=Year};

		anchor_year, Embargo, error_message = dates(date_parameters_list, COinS_date);

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end
		
		if not is_set(error_message) then										-- error free dates only
			local modified = false;												-- flag
			if is_set (DF) then													-- if we need to reformat dates
				modified = reformat_dates (date_parameters_list, DF, false);	-- reformat to DF format, use long month names if appropriate
			end

			if true == date_hyphen_to_dash (date_parameters_list) then					-- convert hyphens to dashes where appropriate
				modified = true;
				add_maint_cat ('date_format');									-- hyphens were converted so add maint category
			end
			
			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'];				-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'];
				Date = date_parameters_list['date'];
				DoiBroken = date_parameters_list['doi-broken-date'];
				LayDate = date_parameters_list['lay-date'];
				PublicationDate = date_parameters_list['publication-date'];
			end
		else
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end
	end	-- end of do

-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);											-- 

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
			if is_set(AccessDate) then											-- access date requires |url=; pmc created url is not |url=
				table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
				AccessDate = '';												-- unset
			end

		end
	end

-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
			if 'episode' == config.CitationClass then							-- special case for cite episode; TODO: is there a better way to do this?
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
			else
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
			end
	end
	
	if 'none' == Title and in_array (config.CitationClass, {'journal', 'citation'}) and is_set (Periodical) and 'journal' == A:ORIGIN('Periodical') then	-- special case for journal cites
		Title = '';																-- set title to empty string
		add_maint_cat ('untitled');
	end

	check_for_url ({															-- add error message when any of these parameters contains a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[A:ORIGIN('Periodical')]=Periodical,
		[A:ORIGIN('PublisherName')] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = Periodical,
		['Encyclopedia'] = Encyclopedia,
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

-- Account for the oddities that are {{cite arxiv}}, AFTER generation of COinS data.
--	if 'arxiv' == config.CitationClass then										-- we have set rft.jtitle in COinS to arXiv, now unset so it isn't displayed
	if in_array (config.CitationClass, {'arxiv', 'biorxiv', 'citeseerx'}) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, or CiteSeerX now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = substitute (cfg.messages['newsgroup'], external_link( 'news:' .. PublisherName, PublisherName, A:ORIGIN('PublisherName'), nil ));
		end
	end



	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text,											-- get current page name so that we don't wikilink to it via editorlinkn
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_authors_editors (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if is_set (Editors) then
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
					EditorCount = 2;											-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
				else
					EditorCount = 2;											-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
				end
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum = #interviewers_list;							-- number of interviewerss
			Interviewers = list_people(control, interviewers_list, false);	-- et al not currently supported
		end
		do																		-- now do translators
			control.maximum = #t;												-- number of translators
			Translators = list_people(control, t, false);						-- et al not currently supported
		end
		do																		-- now do contributors
			control.maximum = #c;												-- number of contributors
			Contributors = list_people(control, c, false);						-- et al not currently supported
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_authors_editors (A['DisplayAuthors'], #a, 'authors', author_etal);

			last_first_list = list_people(control, a, author_etal);

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false);	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if is_set (Authors) and is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

-- special case for chapter format so no error message or cat when chapter not supported
	if not (in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not is_set(URL) then
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then	-- |url= required for cite web, cite podcast, and cite mailinglist
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURLorigin, OriginalFormat, OriginalAccess;
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (ChapterURL) then 											-- URL not set so if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURLorigin = ChapterURLorigin;								-- name of chapter-url parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |format=
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				ChapterURLorigin = A:ORIGIN('ArchiveURL')						-- name of archive-url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
			end
		elseif is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURLorigin = URLorigin;										-- name of url parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived urls
			end
 		end
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			local chap_param;
			if is_set (Chapter) then											-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif is_set (ScriptChapter) then
				chap_param = A:ORIGIN ('ScriptChapter')
			else is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if is_set (chap_param) then											-- if we found one
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {chap_param}, true ) } );		-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if is_set (Contribution) and 0 &lt; #c then								-- if this is a contribution with contributor(s)
			if in_array (Contribution:lower(), cfg.keywords.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, Chapter, TransChapter, ChapterURL, ChapterURLorigin, no_quotes);		-- Contribution is also in Chapter
		if is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter.. sepc .. ' ';
		elseif is_set (ChapterFormat) then										-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title.
	if is_set(TitleLink) and is_set(Title) then
		Title = &quot;[[&quot; .. TitleLink .. &quot;|&quot; .. Title .. &quot;]]&quot;
	end

	if in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then
			
			Title = external_link( URL, Title, URLorigin, UrlAccess ) .. TransTitle .. TransError .. Format;
-- this experiment hidden 2016-04-10; see Help_talk:Citation_Style_1#Recycled_urls
--			local temp_title = external_link( URL, Title, URLorigin ) .. TransError .. Format;	-- do this so we get error message even if url is usurped no archive
--			if in_array (DeadURL, {'unfit no archive', 'usurped no archive'}) then	-- when url links to inappropriate location and there is no archive of original source available
--				local err_msg
--				if temp_title:match ('%[%S+%s+(.+)%](&lt;.+)') then				-- if there is an error message
--					Title, err_msg = temp_title:match ('%[%S+%s+(.+)%](&lt;.+)');	-- strip off external link; TODO: find a better to do this
--					Title = Title .. (err_msg or '');
--				end
--			else
--				Title = temp_title;
--			end

			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		else
			Title = Title .. TransTitle .. TransError;
		end
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURLorigin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin, nil );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if is_set(Minutes) then
			if is_set (Time) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'minutes') .. ' and ' .. wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase, Mode);

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
		if 'mla' == Mode then
			Others = sepc .. ' Trans. ' .. Translators .. Others;
		else
			Others = sepc .. ' ' .. wrap_msg ('translated', Translators, use_lowercase) .. Others;
		end
	end
	if is_set (Interviewers) then
		Others = sepc .. ' ' .. wrap_msg ('interview', Interviewers, use_lowercase) .. Others;
	end
	
	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		if 'mla' == Mode then
			Edition = '. ' .. Edition .. ' ed.';
		else
			Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
		end
	else
		Edition = '';
	end

	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
	if 'mla' == Mode then														-- not in brackets for mla
		OrigYear = is_set(OrigYear) and (&quot;. &quot; .. OrigYear) or &quot;&quot;;
	else
		OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;
	end
	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase, Mode);

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

--[[
Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
note is displayed. There are no error messages for this condition.

]]
	if is_set (SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif is_set (RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if 'mla' == Mode then													-- retrieved text not used in mla
			AccessDate = ' ' .. AccessDate;
		else
			if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end			-- if mode is cs2, lower case
			AccessDate = substitute (retrv_text, AccessDate);					-- add retrieved text
		end
		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {IdAccessLevels=ID_access_levels, DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin, UrlAccess );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then				-- if first and last characters of quote are quote marks
			Quote = Quote:sub(2,-2);											-- strip them off
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- DeadURL is empty, 'yes', 'true', 'y', 'unfit', 'usurped'
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if in_array (DeadURL, {'unfit', 'usurped', 'bot: unknown'}) then
				Archived = sepc .. &quot; &quot; .. 'Archived from the original on ' .. ArchiveDate;	-- format already styled
				if 'bot: unknown' == DeadURL then
					add_maint_cat ('bot:_unknown');								-- and add a category if not already added
				else
					add_maint_cat ('unfit');									-- and add a category if not already added
				end
			else																-- DeadURL is empty, 'yes', 'true', or 'y'
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURLorigin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURLorigin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin, nil );
	end

	local Publisher;
	if is_set(PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if is_set(PublisherName) then
		if is_set(PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif is_set(PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

--[[
Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		if 'mla' == Mode then
			tcommon = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
		else
			tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, 
				Language, Edition, Publisher, Agency, Volume}, sepc );
		end		
	elseif in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(Periodical) then		-- special cases for book cites
		if is_set (Contributors) then											-- when we are citing foreword, preface, introduction, etc
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			if 'mla' == Mode then
				tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Edition, Publisher, Agency}, sepc );
			else
				tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
			end
		elseif 'mla' == Mode then
			tcommon = safe_join( {TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Transcript, Language, Edition, Publisher}, sepc );

	elseif ('news' == config.CitationClass) and ('mla' == Mode) then			-- special case for cite news in MLA mode
		tcommon = safe_join( {Periodical, Format, TitleType, Series, Language, Edition, Agency}, sepc );

	elseif ('web' == config.CitationClass) and ('mla' == Mode) then				-- special case for cite web in MLA mode
		tcommon = safe_join( {Periodical, Format, TitleType, Series, Language, 
			Edition, Publisher, Agency}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if is_set(Date) then
		if ('mla' == Mode) then
			if in_array (config.CitationClass, {'book', 'news', 'web'}) then
				Date = ', ' .. Date;											-- origyear follows title in mla
			elseif 'journal' == config.CitationClass then
				Date = ', (' .. Date .. ')';
			end
		elseif is_set (Authors) or is_set (Editors) then						-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;;				-- in paranetheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon,-1,-1) == sepc) then							-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigYear;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigYear;							-- Date begins with sepc
			end
		end
	end	
	if is_set(Authors) then
		if (not is_set (Date)) or ('mla' == Mode) then							-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) and 0 == #c and 'mla' ~= Mode then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then in_text = in_text:lower() end				-- lowercase for cs2
			elseif is_set(Chapter) and 'mla' == Mode then
				if EditorCount &lt;= 1 then
					in_text = '. Ed. ';
				else
					in_text = '. Eds. ';
				end
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if is_set (Contributors) then											-- book cite and we're citing the intro, preface, etc
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if is_set (Editors) and is_set (Date) and ('mla' ~= Mode) then		-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not is_set (Date)) or ('mla' == Mode) then											-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			if 'mla' == Mode then
				text = safe_join( {Contributors, Chapter, tcommon, OrigYear, Authors, Place, Others, Editors, tcommon2, Date, pgtext, idcommon }, sepc );
			else
				text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
			end
		elseif 'mla' == Mode then
			tcommon = tcommon .. Date;											-- hack to avoid duplicate separators
			text = safe_join( {Authors, Chapter, Title, OrigYear, Others, Editors, Edition, Place, tcommon, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		if 'mla' == Mode then
			if in_array(config.CitationClass, {'journal', 'news', 'web'}) and is_set(Periodical) then
				text = safe_join( {Editors, Title, Place, tcommon, pgtext, Date, idcommon}, sepc );
			else
				text = safe_join( {Editors, Chapter, Title, Place, tcommon, Date, pgtext, idcommon}, sepc );
			end
		else
			text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
		end
	elseif 'mla' == Mode then
		if in_array(config.CitationClass, {'journal', 'news', 'web'}) and is_set(Periodical) then
			text = safe_join( {Title, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Title, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	else
		if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = config.CitationClass;
		options.class = &quot;citation &quot; .. config.CitationClass;					-- class=citation required for blue highlight when used with |ref=
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then								-- set reference anchor if appropriate
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			if #namelist &gt; 0 then												-- if there are names in namelist
				id = anchor_id (namelist, year);								-- go make the CITEREF anchor
			else
				id = '';														-- unset
			end
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;(.-)&lt;/span&gt;&quot;, &quot;%1&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then	-- remove &lt;span&gt; tags and other html-like markup; then get length of what remains
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	if is_set(options.id) then													-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		text = substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text});	-- when |ref= is set
	else
		text = substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text});	-- all other cases
	end		

	text = text .. substitute (cfg.presentation['ocins'], {OCinSoutput});		-- append metadata to the citation
	
	if #z.message_tail ~= 0 then
		text = text .. &quot; &quot;;
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					text = text .. error_comment( v[1], v[2] );
				else
					text = text .. error_comment( v[1] .. &quot;; &quot;, v[2] );
				end
			end
		end
	end

	if #z.maintenance_cats ~= 0 then
		text = text .. '&lt;span class=&quot;citation-comment&quot; style=&quot;display:none; color:#33aa33; margin-left:0.3em&quot;&gt;';
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. v .. ' ([[:Category:' .. v ..'|link]])';
		end
		text = text .. '&lt;/span&gt;';												-- maintenance mesages (realy just the names of the categories for now)
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
		for _, v in ipairs( z.properties_cats ) do								-- append maintenance categories
			text = text .. '[[Category:' .. v ..']]';
		end
	end
	
	return text
end


--[[--------------------------&lt; C S 1 . C I T A T I O N &gt;------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

function cs1.citation(frame)
	Frame = frame;																-- save a copy incase we need to display an error message in preview mode
	local pframe = frame:getParent()
	local validation, utilities, identifiers, metadata;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (utilities);								-- so that functions in Date validataion can see the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	dates = validation.dates;													-- imported functions from Module:Citation/CS1/Date validation
	year_date_check = validation.year_date_check;
	reformat_dates = validation.reformat_dates;
	date_hyphen_to_dash = validation.date_hyphen_to_dash;
	
	is_set = utilities.is_set;													-- imported functions from Module:Citation/CS1/Utilities
	in_array = utilities.in_array;
	substitute = utilities.substitute;
	error_comment = utilities.error_comment;
	set_error = utilities.set_error;
	select_one = utilities.select_one;
	add_maint_cat = utilities.add_maint_cat;
	wrap_style = utilities.wrap_style;
	safe_for_italics = utilities.safe_for_italics;
	remove_wiki_link = utilities.remove_wiki_link;

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	extract_ids = identifiers.extract_ids;										-- imported functions from Module:Citation/CS1/Identifiers
	build_id_list = identifiers.build_id_list;
	is_embargoed = identifiers.is_embargoed;
	extract_id_access_levels = identifiers.extract_id_access_levels;
	
	make_coins_title = metadata.make_coins_title;								-- imported functions from Module:Citation/CS1/COinS
	get_coins_pages = metadata.get_coins_pages;
	COinS = metadata.COinS;

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text, error_state;

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do
		config[k] = v;
--		args[k] = v;															-- debug tool that allows us to render a citation from module {{#invoke:}}
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k, config.CitationClass ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower(), config.CitationClass ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute( param, capture );				-- add the capture to the suggested parameter (typically the enumerator)
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, param}, true );	-- set the error message
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			missing_pipe_check (v);												-- do we think that there is a parameter that is missing a pipe?
			
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);
		end
	end
	return citation0( config, args)
end

return cs1;</text>
      <sha1>3f3q4btal4dccpz3fgm2gs5lzro4q94</sha1>
    </revision>
    <revision>
      <id>4717</id>
      <parentid>4716</parentid>
      <timestamp>2017-11-04T10:41:27Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>synch from sandbox;</comment>
      <origin>4717</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="163266" sha1="rfgy4t0rhkedydsipwgno5eqfxioklp" xml:space="preserve">
local cs1 ={};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local dates, year_date_check, reformat_dates, date_hyphen_to_dash,				-- functions in Module:Citation/CS1/Date_validation
	date_name_xlate

local is_set, in_array, substitute, error_comment, set_error, select_one,		-- functions in Module:Citation/CS1/Utilities
	add_maint_cat, wrap_style, safe_for_italics, is_wikilink, make_wikilink;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local extract_ids, extract_id_access_levels, build_id_list, is_embargoed;		-- functions in Module:Citation/CS1/Identifiers

local make_coins_title, get_coins_pages, COinS;									-- functions in Module:Citation/CS1/COinS

local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

delare variables here that have page-wide scope that are not brought in from other modules; thatare created here
and used here

]]

local added_deprecated_cat;														-- boolean flag so that the category is added only once
local added_prop_cats = {};														-- list of property categories that have been added to z.properties_cats
local added_vanc_errs;															-- boolean flag so we only emit one Vancouver error / category

local Frame;																	-- holds the module's frame table


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

foreign_lang_source and foreign_lang_source_2 keys have a language code appended to them so that multiple languages
may be categorized but multiples of the same language are not categorized.

added_prop_cats is a table declared in page scope variables above

]]

local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		key = key:gsub ('(foreign_lang_source_?2?)%a%a%a?', '%1');				-- strip lang code from keyname
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));		-- make name then add to table
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a boolean declared in page scope variables above

]]

local function add_vanc_error (source)
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {source}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a uri scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of tlds: https://www.iana.org/domains/root/db

rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the tld.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a url with a scheme) will be stripped
here.  Perhaps not necessary but retained incase it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ascii characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the tld) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org and .cash TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and tld or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%a%d]') then										-- first character must be letter or digit
		return false;
	end
																				-- Do most common case first
	if domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.%a%a+$') then				-- three or more character hostname.hostname or hostname.tld
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.xn%-%-[%a%d]+$') then	-- internationalized domain name with ACE prefix
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.cash$') then							-- one character/digit .cash hostname
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.org$') then							-- one character/digit .org hostname
		return true;
	elseif domain:match ('%f[%a][qxz]%.com$') then								-- assigned one character .com hostname (x.com times out 2015-12-10)
		return true;
	elseif domain:match ('%f[%a][iq]%.net$') then								-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.%a%a$') then							-- one character hostname and cctld (2 chars)
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d]%.%a%a+$') then					-- two character hostname and tld
		return true;
	elseif domain:match ('^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?') then		-- IPv4 address
		return true;
	else
		return false;
	end
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a url appear to be a valid url; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if is_set (scheme) then														-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when url is protocol relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a url into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following tld) (if any) and any path(/), query(?) or fragment(#).

If protocol relative url, return nil scheme and domain else return nil for both scheme and domain.

When not protocol relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol relative url
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		authority = authority:gsub ('//', '', 1);								-- replace place 1 pair of '/' with nothing;
		if is_set(authority) then												-- if anything left (1 or 3+ '/' where authority should be) then
			return scheme;														-- return scheme only making domain nil which will cause an error message
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link= etc for properly formatted content: no wikilinks, no urls

Link parameters are to hold the title of a wikipedia article so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki urls and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid url (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid url (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from url; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid url
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wikilinked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

]]

local function link_title_ok (link, lorig, title, torig)
local orig;

	if is_set (link) then 														-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		end
	end

	if is_set (orig) then
		table.insert( z.message_tail, { set_error( 'bad_paramlink', orig)});	-- url or wikilink in |title= with |title-link=;
	end
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the url into scheme and domain
portions, or for protocol relative (//example.com) urls, just the domain.  Use is_url() to validate the two
portions of the url.  If both are valid, or for protocol relative if domain is valid, return true, else false.

Because it is different from a standard url, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper url
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from url;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a url.  The test will also find external wikilinks
that use protocol relative urls. Also finds bare urls.

The frontier pattern prevents a match on interwiki links which are similar to scheme:path urls.  The tests that
find bracketed urls are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol relative ext wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare url with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol relative bare url: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a url
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then												-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source, access)
	local error_str = &quot;&quot;;
	local domain;
	local path;
	local base_url;
	
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the url into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['[']='%5b',[']']='%5d'});					-- replace '[' and ']' with their percent encoded values
		URL=domain..path;														-- and reassemble
	end
	
	if is_set (access) then														-- access level (subscription, registration, limited)
		label = safe_for_url (label);											-- replace square brackets and newlines

		base_url = table.concat (												-- assemble external link with access signal
			{
			'&lt;span class=&quot;plainlinks&quot;&gt;[',										-- opening css and url markup
			URL,																-- the url
			' ',																-- the required space
			label,
			'&lt;span style=&quot;padding-left:0.15em&quot;&gt;',								-- signal spacing css
			cfg.presentation[access],											-- the appropriate icon
			'&lt;/span&gt;',															-- close signal spacing span
			']&lt;/span&gt;'															-- close url markup and plain links span
			});
	else
		base_url = table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url( label ), &quot;]&quot; });	-- no signal markup
	end
	
	return table.concat({ base_url, error_str });
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Replaces unicode quotemarks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc; not for book titles.

]=]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	local wl_type, label, link;

	wl_type, label, link = is_wikilink (str);									-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = substitute (cfg.presentation['kern-wl-both'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = substitute (cfg.presentation['kern-wl-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = substitute (cfg.presentation['kern-wl-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label= mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label= mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap, cap2 = mw.ustring.match (label, &quot;^([\&quot;\'])([^\'].+)&quot;);				-- match leading double or single quote but not doubled single quotes (italic markup)
		if is_set (cap) then
			label = substitute (cfg.presentation['kern-left'], {cap, cap2});
		end
	
		cap, cap2 = mw.ustring.match (label, &quot;^(.+[^\'])([\&quot;\'])$&quot;)				-- match trailing double or single quote but not doubled single quotes (italic markup)
		if is_set (cap) then
			label = substitute (cfg.presentation['kern-right'], {cap, cap2});
		end
		
		if 2 == wl_type then
			str = make_wikilink (link, label);									-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title= and |script-chapter=

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, cfg.script_lang_codes) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				add_prop_cat ('script')
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return substitute( msg, str );										-- including template text
	else
		return substitute( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (scriptchapter, chapter, transchapter, chapterurl, chapter_url_source, no_quotes, access)
	local chapter_error = '';
	
	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
			chapter = wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, scriptchapter)						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (transchapter) then
		transchapter = wrap_style ('trans-quoted-title', transchapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. transchapter;
		else																	-- here when transchapter without chapter or script-chapter
			chapter = transchapter;												-- 
			chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
		end
	end

	if is_set (chapterurl) then
		chapter = external_link (chapterurl, chapter, chapter_url_source, access);		-- adds bare_url_missing_title error if appropriate
	end

	return chapter .. chapter_error;
end


--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Detects but ignores the character pattern that results from the transclusion of {{'}} templates.

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i=1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- Test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position and (char == 'zero width joiner') then						-- if we found a zero width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- its ok if one of the indic scripts
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture then 					-- nowiki, math stripmarker (not an error condition)
				stripmarker = true;												-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { set_error( 'invisible_char', {err_msg, wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i=i+1;																	-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate( name, cite_class )
	local name = tostring( name );
	local state;
	
	if in_array (cite_class, {'arxiv', 'biorxiv', 'citeseerx'}) then			-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[ name ];
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end

		if 'arxiv' == cite_class then											-- basic parameters unique to these templates
			state = whitelist.arxiv_basic_arguments[name];
		end
		if 'biorxiv' == cite_class then
			state = whitelist.biorxiv_basic_arguments[name];
		end
		if 'citeseerx' == cite_class then
			state = whitelist.citeseerx_basic_arguments[name];
		end

		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
																				-- limited enumerated parameters list
		name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#)
		state = whitelist.limited_numbered_arguments[ name ];
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates
		
	state = whitelist.basic_arguments[ name ];									-- all other templates; all normal parameters allowed
											
	if true == state then return true; end										-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);											-- parameter is deprecated but still supported
		return true;
	end
																				-- all enumerated parameters allowed
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );												-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];

	if true == state then return true; end										-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);											-- parameter is deprecated but still supported
		return true;
	end
	
	return false;																-- not supported because not found or name is set to nil
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash

]]

local function hyphen_to_dash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if comp:sub(1,1) == duplicate_char then								-- is first charactier same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for th
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = str:sub(-1,-1);										-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = str:sub(1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = str:sub(1, -4) .. &quot;''&quot;;							-- remove them and add back ''
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then		-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then		-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif str:sub(-3,-1) == duplicate_char .. '&quot;]' then		-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then			-- if last two chars of str are sepc] external link
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;'']&quot; then		-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then				-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = str:sub(1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end		-- if duplicate_char not a letter then escape it
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )			-- remove duplicate_char if it follows html markup
					else
						value = value:sub( 2, -1 );								-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end  


--[[--------------------------&lt; I S _ S U F F I X &gt;------------------------------------------------------------

returns true is suffix is properly formed Jr, Sr, or ordinal in the range 2–9.  Puncutation not allowed.

]]

local function is_suffix (suffix)
	if in_array (suffix, {'Jr', 'Sr', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written ouside of the code editor and pasted here because the code editor gets confused between character insertion point and cursor position.
The test has been rewritten to use decimal character escape sequence for the individual bytes of the unicode characters so that it is not necessary
to use an external editor to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first)
	local first, suffix = first:match ('(.-),?%s*([%dJS][%drndth]+)%.?$') or first;		-- if first has something that looks like a generational suffix, get it

	if is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error ('suffix');
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error ('non-Latin character');
			return false;														-- not a string of latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just intials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error ('suffix');									-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word


	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i],1,1));				-- insert the intial at end of initials table
		end
		i = i+1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = ',';																-- name-list separator between authors is a comma
		namesep = ' ';															-- last/first separator is a space
	else
		sep = ';'																-- name-list separator between authors is a semicolon
		namesep = ', '															-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = make_wikilink (person.link, one);						-- link author/editor if this page is not the author's/editor's page
				end
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end


--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]
local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of author and editor name parameters for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the parameters |display-authors=etal or |display-editors=etal

]]

local function name_has_etal (name, etal, nocat)

	if is_set (name) then														-- name can be nil in which case just return
		local etal_pattern = &quot;[;,]? *[\&quot;']*%f[%a][Ee][Tt] *[Aa][Ll][%.\&quot;']*$&quot;	-- variations on the 'et al' theme
		local others_pattern = &quot;[;,]? *%f[%a]and [Oo]thers&quot;;					-- and alternate to et al.
		
		if name:match (etal_pattern) then										-- variants on et al.
			name = name:gsub (etal_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		elseif name:match (others_pattern) then									-- if not 'et al.', then 'and others'?
			name = name:gsub (others_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		end
	end
	return name, etal;															-- 
end


--[[--------------------------&lt; N A M E _ H A S _ E D _ M A R K U P &gt;------------------------------------------

Evaluates the content of author and editor parameters for extranious editor annotations: ed, ed., eds, (Ed.), etc.
These annotation do not belong in author parameters and are redundant in editor parameters.  If found, the function
adds the editor markup maintenance category.

]]

local function name_has_ed_markup (name, list_name)
	local _, pattern;
	local patterns = {															-- these patterns match annotations at end of name
		'%f[%(%[][%(%[]%s*[Ee][Dd][Ss]?%.?%s*[%)%]]?$',							-- (ed) or (eds): leading '(', case insensitive 'ed', optional 's', '.' and/or ')'
		'[,%.%s]%f[e]eds?%.?$',													-- ed or eds: without '('or ')'; case sensitive (ED could be initials Ed could be name)
		'%f[%(%[][%(%[]%s*[Ee][Dd][Ii][Tt][Oo][Rr][Ss]?%.?%s*[%)%]]?$',			-- (editor) or (editors): leading '(', case insensitive, optional '.' and/or ')'
		'[,%.%s]%f[Ee][Ee][Dd][Ii][Tt][Oo][Rr][Ss]?%.?$',						-- editor or editors: without '('or ')'; case insensitive
		
																				-- these patterns match annotations at beginning of name
		'^eds?[%.,;]',															-- ed. or eds.: lower case only, optional 's', requires '.'
		'^[%(%[]%s*[Ee][Dd][Ss]?%.?%s*[%)%]]',									-- (ed) or (eds): also sqare brackets, case insensitive, optional 's', '.'
		'^[%(%[]?%s*[Ee][Dd][Ii][Tt][Oo][Rr][Ss]?%A',							-- (editor or (editors: also sq brackets, case insensitive, optional brackets, 's'
		'^[%(%[]?%s*[Ee][Dd][Ii][Tt][Ee][Dd]%A',								-- (edited: also sq brackets, case insensitive, optional brackets
		}

	if is_set (name) then
		for _, pattern in ipairs (patterns) do									-- spin through patterns table and
			if name:match (pattern) then
				add_maint_cat ('extra_text_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
				break;
			end
		end
	end
	return name;																-- and done
end


--[[--------------------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;----------------------------------------

Evaluates the content of author and editor (surnames only) parameters for multiple names.  Multiple names are
indicated if there is more than one comma and or semicolon.  If found, the function adds the multiple name
(author or editor) maintenance category.

]]

local function name_has_mult_names (name, list_name)
local count, _;
	if is_set (name) then
		_, count = name:gsub ('[;,]', '');										-- count the number of separator-like characters
		
		if 1 &lt; count then														-- param could be |author= or |editor= so one separator character is acceptable
			add_maint_cat ('mult_names', cfg.special_case_translation [list_name]);	-- more than one separator indicates multiple names so add a maint cat for this template
		end
	end
	return name;																-- and done
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------
This function calls various name checking functions used to validate the content of the various name-holding
parameters.

]]

local function name_checks (last, first, list_name)
	if is_set (last) then
		if last:match ('^%(%(.*%)%)$') then										-- if wrapped in doubled parentheses, accept as written 
			last = last:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			last = name_has_mult_names (last, list_name);						-- check for multiple names in the parameter (last only)
			last = name_has_ed_markup (last, list_name);						-- check for extraneous 'editor' annotation
		end
	end
	if is_set (first) then
		if first:match ('^%(%(.*%)%)$') then									-- if wrapped in doubled parentheses, accept as written 
			first = first:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			first = name_has_ed_markup (first, list_name);						-- check for extraneous 'editor' annotation
		end
	end
	return last, first;															-- done
	end


--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary
	while true do
		last = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false);							-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false);						-- find and remove variations on et al.
		last, first= name_checks (last, first, list_name);						-- multiple names, extraneous annotation, etc checks
		
		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			link_title_ok (link, list_name:match (&quot;(%w+)List&quot;):lower() .. '-link' .. i, last, list_name:match (&quot;(%w+)List&quot;):lower() .. '-last' .. i);	-- check for improper wikimarkup

			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because case of the source may be incorrect
or different from the case that WikiMedia uses, the name comparisons are done in lower case and when a match is
found, the Wikimedia version (assumed to be correct) is returned along with the code.  When there is no match, we
return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') return a list of languages that in some cases may include
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.

Names but that are included in the list will be found if that name is provided in the |language= parameter.  For example,
if |language=Chavacano de Zamboanga, that name will be found with the associated code 'cbk-zam'.  When names are found
and the associated code is not two or three characters, this function returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	if 'bangla' == lang:lower() then											-- special case related to Wikimedia remap of code 'bn' at mw:Extension:CLDR
		return 'Bengali', 'bn';													-- make sure rendered version is properly capitalized
	end

	local languages = mw.language.fetchLanguageNames(this_wiki_code, 'all')		-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() and 3 ~= code:len() then							-- two- or three-character codes only; extensions not supported
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the the code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for the code
end


--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code is recognized by MediaWiki,
use the returned name; if not, then use the value that was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is assigned to the category for
that code: Category:Norwegian-language sources (no).  For valid three-character code languages, the page is assigned
to the single category for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does not recognize three-character
equivalents of two-character codes: code 'ar' is recognized bit code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are
separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki = mw.getContentLanguage();									-- get a language object for this wiki
	local this_wiki_code = this_wiki:getCode()									-- get this wiki's language code
	local this_wiki_name = mw.language.fetchLanguageName(this_wiki_code, this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang

		if lang:match ('^%a%a%-') then											-- strip ietf language tags from code; TODO: is there a need to support 3-char with tag?
			lang = lang:match ('(%a%a)%-')										-- keep only 639-1 code portion to lang; TODO: do something with 3166 alpha 2 country code?
		end
		if 2 == lang:len() or 3 == lang:len() then								-- if two-or three-character code
			name = mw.language.fetchLanguageName( lang:lower(), this_wiki_code);	-- get language name if |language= is a proper code
		end
	
		if is_set (name) then													-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, this_wiki_code);				-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then													-- only 2- or 3-character codes
			if 'bn' == code then name = 'Bengali' end;							-- override wikimedia when code is 'bn'
			if this_wiki_code ~= code then										-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					add_prop_cat ('foreign_lang_source' .. code, {name, code})			-- categorize it
				else															-- or is a recognized language (but has a three-character code)
					add_prop_cat ('foreign_lang_source_2' .. code, {code})				-- categorize it differently TODO: support mutliple three-character code categories per cs1|2 template
				end
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, ' and ')							-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		language_list[code] = 'and ' .. language_list[code];					-- prepend last name with 'and&lt;space&gt;'
		name = table.concat (language_list, ', ')								-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
	end
	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = '.';																-- terminate the rendered citation with a period
	end
	return '.', ps;																-- separator is a full stop
end


--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = '';																-- make sure it isn't nil
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return ',', ps, ref;														-- separator is a comma
end


--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end


--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end


--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parentheses, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[--------------------------&lt; G E T _ D I S P L A Y _ A U T H O R S _ E D I T O R S &gt;------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_authors_editors (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_auth_ed', cfg.special_case_translation [list_name]);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parnetheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a place holder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parens
			local name = name_table[i];
			i=i+1;																-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parens
					break;														-- and done reassembling so
				end
				i=i+1;															-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = is_wikilink (name_table[i]);					-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i+1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);						-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parentheses to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')								-- remove doubled parntheses
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error ('punctuation');
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
			if is_suffix (first) then											-- if a valid suffix
				suffix = first													-- save it as a suffix and
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end																	-- no suffix error message here because letter combination may be result of Romanization; check for digits?
			last = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error ('missing comma');								-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error ('name');										-- matches a space between two intiials
			end
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error ('initials');									-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first);									-- check first and last before restoring the suffix which may have a non-Latin digit
			if is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '');
			end
		end

		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ) or v_link_table[i];
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice incase we have a |first1= without a |last1=; this ...
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or	-- ... also catches the case where |first= is used with |vauthors=
		select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, no, etc).  When the parameter value has not been assigned a value (missing or empty
in the source template) the function returns true.  If the parameter value is one of the list of allowed values returns
true; else, emits an error message and returns false.

]]

local function is_valid_parameter_value (value, name, possible)
	if not is_set (value) then
		return true;															-- an empty parameter is ok
	elseif in_array(value:lower(), possible) then
		return true;
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list,-3,-1) == sepc .. '. ') then						-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list,-1,-1) == sepc) or (string.sub (name_list,-3,-1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terninate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not is_set (volume) and not is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end

	local vol = '';
		
	if is_set (volume) then
		if (4 &lt; mw.ustring.len(volume)) then
			vol = substitute (cfg.messages['j-vol'], {sepc, volume});
		else
			vol = substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});
		end
	end
	if is_set (issue) then
		return vol .. substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'journal' == origin);
	
	if is_set (page) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif is_set(pages) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then										-- if pages is only digits, assume a single page number
			return '', substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org urls to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot url or to calendar pages.  When the archive url is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the url.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org url does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command url
	|archive-url= is an archive.org url that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org urls:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this funct may return a modified
archive url:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the url unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.or url
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine url
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command url, we don't want to allow saving of the target page 
		err_msg = 'save command';
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = 'liveweb';
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');		-- split out some of the url parts for evaluation
		
		if not is_set(timestamp) or 14 ~= timestamp:len() then					-- path and flag optional, must have 14-digit timestamp here
			err_msg = 'timestamp';
			if '*' ~= flag then
				url=url:gsub ('(//web%.archive%.org/[^%d]*%d?%d?%d?%d?%d?%d?)[^/]*', '%1*', 1)	-- for preview, modify ts to be yearmo* max (0-6 digits plus splat)
			end
		elseif is_set(path) and 'web/' ~= path then								-- older archive urls do not have the extra 'web/' path element
			err_msg = 'path';
		elseif is_set (flag) and not is_set (path) then							-- flag not allowed with the old form url (without the 'web/' path element)
			err_msg = 'flag';
		elseif is_set (flag) and not flag:match ('%a%a_') then					-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = 'flag';
		else
			return url, date;													-- return archiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	table.insert( z.message_tail, { set_error( 'archive_url', {err_msg}, true ) } );	-- add error message and
	if is_set (Frame:preprocess('{{REVISIONID}}')) then
		return '', '';															-- return empty strings for archiveURL and ArchiveDate
	else
		return url, date;														-- preview mode so return archiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe:
	{{cite ... |title=Title access-date=2016-03-17}}

cs1|2 shares some parameter names with xml/html atributes: class=, title=, etc.  To prevent false positives xml/html
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove xml/html tags because attributes: class=, title=, etc 

	capture = value:match ('%s+(%a[%a%d]+)%s*=') or value:match ('^(%a[%a%d]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then								-- if the capture is a valid parameter name
		add_maint_cat ('missing_pipe');
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

-- set default parameter values defined by |mode= parameter.
	local Mode = A['Mode'];
	if not is_valid_parameter_value (Mode, 'mode', cfg.keywords['mode']) then
		Mode = '';
	end

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				add_maint_cat ('authors');										-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
			add_maint_cat ('editors');											-- but add a maint cat because use of this parameter is discouraged
		end
	end

	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=

	local interviewers_list = {};
	local Interviewers = A['Interviewers']
	if is_set (Interviewers) then												-- add a maint cat if the |interviewers= is used
		add_maint_cat ('interviewers');											-- because use of this parameter is discouraged
	else
		interviewers_list = extract_names (args, 'InterviewerList');			-- else, process preferred interviewers parameters
	end

	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list
	local Contribution = A['Contribution'];
	if in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not is_set (Contribution) then									-- |contributor= requires |contribution=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if select_one (args, cfg.aliases['ContributorList-Last'], 'redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { set_error( 'contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if not is_valid_parameter_value (NameListFormat, 'name-list-format', cfg.keywords['name-list-format']) then			-- only accepted value for this parameter is 'vanc'
		NameListFormat = '';													-- anything else, set to empty string
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
			link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wikimarkup in |title-link= or wikimarkup in |title= when |title-link= is set

	local Chapter = A['Chapter'];
	local ScriptChapter = A['ScriptChapter'];
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];

	local ArchiveDate;
	local ArchiveURL;

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	
	local DeadURL = A['DeadURL']
		if not is_valid_parameter_value (DeadURL, 'dead-url', cfg.keywords ['deadurl']) then	-- set in config.defaults to 'yes'
			DeadURL = '';														-- anything else, set to empty string
		end

	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];
	local Periodical_origin = A:ORIGIN('Periodical');							-- get the name of the periodical parameter

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if in_array (config.CitationClass, cfg.templates_using_volume) then
		Volume = A['Volume'];
	end
																				-- conference &amp; map books do not support issue
	if in_array (config.CitationClass, cfg.templates_using_issue) and not (in_array (config.CitationClass, {'conference', 'map'}) and not is_set (Periodical))then
		Issue = A['Issue'];
	end
	local Position = '';
	if not in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash( A['Pages'] );	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
		if not is_valid_parameter_value (RegistrationRequired, 'registration', cfg.keywords ['yes_true_y']) then
			RegistrationRequired=nil;
		end

	local SubscriptionRequired = A['SubscriptionRequired'];
		if not is_valid_parameter_value (SubscriptionRequired, 'subscription', cfg.keywords ['yes_true_y']) then
			SubscriptionRequired=nil;
		end

	local UrlAccess = A['UrlAccess'];
		if not is_valid_parameter_value (UrlAccess, 'url-access', cfg.keywords ['url-access']) then
			UrlAccess = nil;
		end
		if not is_set(URL) and is_set(UrlAccess) then
			UrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {'url'}, true ) } );
		end

		if is_set (UrlAccess) and is_set (SubscriptionRequired) then			-- while not aliases, these are much the same so if both are set
			table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'url-access') .. ' and ' .. wrap_style ('parameter', 'subscription')}, true ) } );		-- add error message
			SubscriptionRequired = nil;											-- unset; prefer |access= over |subscription=
		end
		if is_set (UrlAccess) and is_set (RegistrationRequired) then			-- these are not the same but contradictory so if both are set
			table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'url-access') .. ' and ' .. wrap_style ('parameter', 'registration')}, true ) } );		-- add error message
			RegistrationRequired = nil;											-- unset; prefer |access= over |registration=
		end

	local ChapterUrlAccess = A['ChapterUrlAccess'];
		if not is_valid_parameter_value (ChapterUrlAccess, 'chapter-url-access', cfg.keywords ['url-access']) then	-- same as url-access
			ChapterUrlAccess = nil;
		end
		if not is_set(ChapterURL) and is_set(ChapterUrlAccess) then
			ChapterUrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {'chapter-url'}, true ) } );
		end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local Agency = A['Agency'];

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
		if not is_valid_parameter_value (IgnoreISBN, 'ignore-isbn-error', cfg.keywords ['yes_true_y']) then
			IgnoreISBN = nil;													-- anything else, set to empty string
		end
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );
	local ID_access_levels = extract_id_access_levels( args, ID_list );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
		if not is_valid_parameter_value (LastAuthorAmp, 'last-author-amp', cfg.keywords ['yes_true_y']) then
			LastAuthorAmp = nil;												-- set to empty string
		end

	local no_tracking_cats = A['NoTracking'];
		if not is_valid_parameter_value (no_tracking_cats, 'no-tracking', cfg.keywords ['yes_true_y']) then
			no_tracking_cats = nil;												-- set to empty string
		end

	--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = A['DF'];															-- date format set in cs1|2 template
	if not is_valid_parameter_value (DF, 'df', cfg.keywords['date-format']) then	-- validate reformatting keyword
		DF = '';																-- not valid, set to empty string
	end

	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

	--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

	-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	select_one( args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'redundant_parameters' );		-- this is a dummy call simply to get the error message and category

	local NoPP = A['NoPP'] 
	if is_set (NoPP) and is_valid_parameter_value (NoPP, 'nopp', cfg.keywords ['yes_true_y']) then
		NoPP = true;
	else
		NoPP = nil;																-- unset, used as a flag later
	end

	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Pages = '';															-- unset the others
			At = '';
		end
		extra_text_in_page_check (Page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.
	elseif is_set(Pages) then
		if is_set(At) then
			At = '';															-- unset
		end
		extra_text_in_page_check (Pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.
	end	

	-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia and |title then map |title to |article and |encyclopedia to |title
		|encyclopedia and |article then map |encyclopedia to |title
		|encyclopedia then map |encyclopedia to |title
	
		|trans_title maps to |trans_chapter when |title is re-mapped
		|url maps to |chapterurl when |title is remapped
	
	All other combinations of |encyclopedia, |title, and |article are not modified
	
	]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterUrlAccess = UrlAccess;

					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter = make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			else																-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if is_set(A['Number']) then												-- cite techreport uses 'number', which other citations alias to 'issue'
			if not is_set(ID) then												-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', 'id') .. ' and ' .. wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

	-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	elseif 'mailinglist' == A:ORIGIN('Periodical') then
		Periodical = '';														-- unset because mailing list is only used for cite mailing list
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		ChapterUrlAccess = UrlAccess;
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];

		link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wikimarkup in |series-link= or wikimarkup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) and is_set (AirDate) then							-- promote airdate to date
			Date = AirDate;
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('series', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = make_wikilink (ChapterLink, Chapter);
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = make_wikilink (SeriesLink, Series);
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, before generation of COinS data.
	do
		if in_array (config.CitationClass, {'arxiv', 'biorxiv', 'citeseerx'}) then
			if not is_set (ID_list[config.CitationClass:upper()]) then			-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp; |citeseerx= required for their templates
				table.insert( z.message_tail, { set_error( config.CitationClass .. '_missing', {}, true ) } );		-- add error message
			end
			
			if 'arxiv' == config.CitationClass then
				Periodical = 'arXiv';											-- set to arXiv for COinS; after that, must be set to empty string
			end

			if 'biorxiv' == config.CitationClass then
				Periodical = 'bioRxiv';											-- set to bioRxiv for COinS; after that, must be set to empty string
			end

			if 'citeseerx' == config.CitationClass then
				Periodical = 'CiteSeerX';										-- set to CiteSeerX for COinS; after that, must be set to empty string
			end
		end
	end

	-- handle type parameter for those CS1 citations that have default values
	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;interview&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
		TitleType = substitute( cfg.messages['type'], TitleType);				-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {['access-date']=AccessDate, ['archive-date']=ArchiveDate, ['date']=Date, ['doi-broken-date']=DoiBroken,
				['embargo']=Embargo, ['lay-date']=LayDate, ['publication-date']=PublicationDate, ['year']=Year};

		anchor_year, Embargo, error_message = dates(date_parameters_list, COinS_date);

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end
		
		if not is_set(error_message) then										-- error free dates only
			local modified = false;												-- flag
			
			if is_set (DF) then													-- if we need to reformat dates
				modified = reformat_dates (date_parameters_list, DF, false);	-- reformat to DF format, use long month names if appropriate
			end

			if true == date_hyphen_to_dash (date_parameters_list) then			-- convert hyphens to dashes where appropriate
				modified = true;
				add_maint_cat ('date_format');									-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language,
	-- uncomment these three lines.  Not supported by en.wiki (for obvious reasons)
--			if date_name_xlate (date_parameters_list) then
--				modified = true;
--			end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'];				-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'];
				Date = date_parameters_list['date'];
				DoiBroken = date_parameters_list['doi-broken-date'];
				LayDate = date_parameters_list['lay-date'];
				PublicationDate = date_parameters_list['publication-date'];
			end
		else
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end
	end	-- end of do

	-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
	-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
			if is_set(AccessDate) then											-- access date requires |url=; pmc created url is not |url=
				table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
				AccessDate = '';												-- unset
			end

		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
			if 'episode' == config.CitationClass then							-- special case for cite episode; TODO: is there a better way to do this?
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
			else
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
			end
	end
	
	if 'none' == Title and in_array (config.CitationClass, {'journal', 'citation'}) and is_set (Periodical) and 'journal' == A:ORIGIN('Periodical') then	-- special case for journal cites
		Title = '';																-- set title to empty string
		add_maint_cat ('untitled');
	end

	check_for_url ({															-- add error message when any of these parameters contains a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[A:ORIGIN('Periodical')]=Periodical,
		[A:ORIGIN('PublisherName')] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = Periodical,
		['Encyclopedia'] = Encyclopedia,
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, and {{cite citeseerx}} AFTER generation of COinS data.
	if in_array (config.CitationClass, {'arxiv', 'biorxiv', 'citeseerx'}) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, or CiteSeerX now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = substitute (cfg.messages['newsgroup'], external_link( 'news:' .. PublisherName, PublisherName, A:ORIGIN('PublisherName'), nil ));
		end
	end



	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text,											-- get current page name so that we don't wikilink to it via editorlinkn
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_authors_editors (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if is_set (Editors) then
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
					EditorCount = 2;											-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
				else
					EditorCount = 2;											-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
				end
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum = #interviewers_list;							-- number of interviewerss
			Interviewers = list_people(control, interviewers_list, false);	-- et al not currently supported
		end
		do																		-- now do translators
			control.maximum = #t;												-- number of translators
			Translators = list_people(control, t, false);						-- et al not currently supported
		end
		do																		-- now do contributors
			control.maximum = #c;												-- number of contributors
			Contributors = list_people(control, c, false);						-- et al not currently supported
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_authors_editors (A['DisplayAuthors'], #a, 'authors', author_etal);

			last_first_list = list_people(control, a, author_etal);

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false);	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if is_set (Authors) and is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
	-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not is_set(URL) then
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then	-- |url= required for cite web, cite podcast, and cite mailinglist
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURLorigin, OriginalFormat, OriginalAccess;
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (ChapterURL) then 											-- URL not set so if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURLorigin = ChapterURLorigin;								-- name of chapter-url parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |format=
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				ChapterURLorigin = A:ORIGIN('ArchiveURL')						-- name of archive-url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
			end
		elseif is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURLorigin = URLorigin;										-- name of url parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived urls
			end
 		end
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			local chap_param;
			if is_set (Chapter) then											-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif is_set (ScriptChapter) then
				chap_param = A:ORIGIN ('ScriptChapter')
			else is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if is_set (chap_param) then											-- if we found one
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {chap_param}, true ) } );		-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if is_set (Contribution) and 0 &lt; #c then								-- if this is a contribution with contributor(s)
			if in_array (Contribution:lower(), cfg.keywords.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, Chapter, TransChapter, ChapterURL, ChapterURLorigin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter.. sepc .. ' ';
		elseif is_set (ChapterFormat) then										-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title.
	Title = mw.ustring.gsub(Title, '%'..sepc..'$', '');							-- remove any trailing separator character
	if is_set(TitleLink) and is_set(Title) then
		Title = make_wikilink (TitleLink, Title);
	end

	if in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then
			
			Title = external_link( URL, Title, URLorigin, UrlAccess ) .. TransTitle .. TransError .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		else
			Title = Title .. TransTitle .. TransError;
		end
	else
		Title = TransTitle .. TransError;
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURLorigin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin, nil );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if is_set(Minutes) then
			if is_set (Time) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'minutes') .. ' and ' .. wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
		Others = sepc .. ' ' .. wrap_msg ('translated', Translators, use_lowercase) .. Others;
	end
	if is_set (Interviewers) then
		Others = sepc .. ' ' .. wrap_msg ('interview', Interviewers, use_lowercase) .. Others;
	end
	
	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
		OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;		-- TODO: presentation

	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

	--[[
	Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
	note is displayed. There are no error messages for this condition.
	
	]]
	if is_set (SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif is_set (RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text

		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {IdAccessLevels=ID_access_levels, DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin, UrlAccess );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then				-- if first and last characters of quote are quote marks
			Quote = Quote:sub(2,-2);											-- strip them off
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- DeadURL is empty, 'yes', 'true', 'y', 'unfit', 'usurped'
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if in_array (DeadURL, {'unfit', 'usurped', 'bot: unknown'}) then
				Archived = sepc .. &quot; &quot; .. 'Archived from the original on ' .. ArchiveDate;	-- format already styled
				if 'bot: unknown' == DeadURL then
					add_maint_cat ('bot:_unknown');								-- and add a category if not already added
				else
					add_maint_cat ('unfit');									-- and add a category if not already added
				end
			else																-- DeadURL is empty, 'yes', 'true', or 'y'
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURLorigin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURLorigin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin, nil );
	end

	local Publisher;
	if is_set(PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if is_set(PublisherName) then
		if is_set(PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif is_set(PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(Periodical) then		-- special cases for book cites
		if is_set (Contributors) then											-- when we are citing foreword, preface, introduction, etc
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Transcript, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if is_set(Date) then
		if is_set (Authors) or is_set (Editors) then							-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;;				-- in paranetheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon,-1,-1) == sepc) then							-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigYear;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigYear;							-- Date begins with sepc
			end
		end
	end	
	if is_set(Authors) then
		if (not is_set (Date)) then												-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then
					in_text = in_text:lower()									-- lowercase for cs2
				 end
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if is_set (Contributors) then											-- book cite and we're citing the intro, preface, etc
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if is_set (Editors) and is_set (Date) then							-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not is_set (Date)) then											-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = config.CitationClass;
		options.class = &quot;citation &quot; .. config.CitationClass;					-- class=citation required for blue highlight when used with |ref=
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then								-- set reference anchor if appropriate
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			if #namelist &gt; 0 then												-- if there are names in namelist
				id = anchor_id (namelist, year);								-- go make the CITEREF anchor
			else
				id = '';														-- unset
			end
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;(.-)&lt;/span&gt;&quot;, &quot;%1&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then	-- remove &lt;span&gt; tags and other html-like markup; then get length of what remains
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	local render = {};															-- here we collect the final bits for concatenation into the rendered citation

	if is_set(options.id) then													-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render, substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text}));	-- when |ref= is set
	else
		table.insert (render, substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text}));	-- all other cases
	end		

	table.insert (render, substitute (cfg.presentation['ocins'], {OCinSoutput}));		-- append metadata to the citation

	if #z.message_tail ~= 0 then
		table.insert (render, ' ');
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					table.insert (render, error_comment( v[1], v[2] ));
				else
					table.insert (render, error_comment( v[1] .. &quot;; &quot;, v[2] ));
				end
			end
		end
	end

	if #z.maintenance_cats ~= 0 then
		table.insert (render, '&lt;span class=&quot;citation-comment&quot; style=&quot;display:none; color:#33aa33; margin-left:0.3em&quot;&gt;');
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			table.insert (render, v);
			table.insert (render, ' (');
			table.insert (render, make_wikilink (':Category:' .. v, 'link'));
			table.insert (render, ') ');
		end
		table.insert (render, '&lt;/span&gt;');
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			table.insert (render, make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			table.insert (render, make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.properties_cats ) do								-- append properties categories
			table.insert (render, make_wikilink ('Category:' .. v));
		end
	end

	return table.concat (render);	
end


--[[--------------------------&lt; C S 1 . C I T A T I O N &gt;------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

function cs1.citation(frame)
	Frame = frame;																-- save a copy incase we need to display an error message in preview mode
	local pframe = frame:getParent()
	local validation, utilities, identifiers, metadata;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	dates = validation.dates;													-- imported functions from Module:Citation/CS1/Date validation
	year_date_check = validation.year_date_check;
	reformat_dates = validation.reformat_dates;
	date_hyphen_to_dash = validation.date_hyphen_to_dash;
	date_name_xlate = validation.date_name_xlate;

	is_set = utilities.is_set;													-- imported functions from Module:Citation/CS1/Utilities
	in_array = utilities.in_array;
	substitute = utilities.substitute;
	error_comment = utilities.error_comment;
	set_error = utilities.set_error;
	select_one = utilities.select_one;
	add_maint_cat = utilities.add_maint_cat;
	wrap_style = utilities.wrap_style;
	safe_for_italics = utilities.safe_for_italics;
	is_wikilink = utilities.is_wikilink;
	make_wikilink = utilities.make_wikilink;

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	extract_ids = identifiers.extract_ids;										-- imported functions from Module:Citation/CS1/Identifiers
	build_id_list = identifiers.build_id_list;
	is_embargoed = identifiers.is_embargoed;
	extract_id_access_levels = identifiers.extract_id_access_levels;
	
	make_coins_title = metadata.make_coins_title;								-- imported functions from Module:Citation/CS1/COinS
	get_coins_pages = metadata.get_coins_pages;
	COinS = metadata.COinS;

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text, error_state;

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do
		config[k] = v;
--		args[k] = v;															-- debug tool that allows us to render a citation from module {{#invoke:}}
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k, config.CitationClass ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower(), config.CitationClass ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute( param, capture );				-- add the capture to the suggested parameter (typically the enumerator)
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, param}, true );	-- set the error message
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			missing_pipe_check (v);												-- do we think that there is a parameter that is missing a pipe?
			
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);
		end
	end
	return citation0( config, args)
end

return cs1;</text>
      <sha1>rfgy4t0rhkedydsipwgno5eqfxioklp</sha1>
    </revision>
    <revision>
      <id>4718</id>
      <parentid>4717</parentid>
      <timestamp>2018-02-17T14:52:23Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4718</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="164808" sha1="p7he7iz3bxgxc5kjp3g2mrtmgcn4d8h" xml:space="preserve">
local cs1 ={};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local dates, year_date_check, reformat_dates, date_hyphen_to_dash,				-- functions in Module:Citation/CS1/Date_validation
	date_name_xlate

local is_set, in_array, substitute, error_comment, set_error, select_one,		-- functions in Module:Citation/CS1/Utilities
	add_maint_cat, wrap_style, safe_for_italics, is_wikilink, make_wikilink;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local extract_ids, extract_id_access_levels, build_id_list, is_embargoed;		-- functions in Module:Citation/CS1/Identifiers

local make_coins_title, get_coins_pages, COinS;									-- functions in Module:Citation/CS1/COinS

local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

delare variables here that have page-wide scope that are not brought in from other modules; thatare created here
and used here

]]

local added_deprecated_cat;														-- boolean flag so that the category is added only once
local added_prop_cats = {};														-- list of property categories that have been added to z.properties_cats
local added_vanc_errs;															-- boolean flag so we only emit one Vancouver error / category

local Frame;																	-- holds the module's frame table


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

foreign_lang_source and foreign_lang_source_2 keys have a language code appended to them so that multiple languages
may be categorized but multiples of the same language are not categorized.

added_prop_cats is a table declared in page scope variables above

]]

local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		key = key:gsub ('(foreign_lang_source_?2?)%a%a%a?', '%1');				-- strip lang code from keyname
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));		-- make name then add to table
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a boolean declared in page scope variables above

]]

local function add_vanc_error (source)
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {source}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a uri scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of tlds: https://www.iana.org/domains/root/db

rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the tld.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a url with a scheme) will be stripped
here.  Perhaps not necessary but retained incase it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ascii characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the tld) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org and .cash TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and tld or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%a%d]') then										-- first character must be letter or digit
		return false;
	end
																				-- Do most common case first
	if domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.%a%a+$') then				-- three or more character hostname.hostname or hostname.tld
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.xn%-%-[%a%d]+$') then	-- internationalized domain name with ACE prefix
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.cash$') then							-- one character/digit .cash hostname
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.org$') then							-- one character/digit .org hostname
		return true;
	elseif domain:match ('%f[%a][qxz]%.com$') then								-- assigned one character .com hostname (x.com times out 2015-12-10)
		return true;
	elseif domain:match ('%f[%a][iq]%.net$') then								-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.%a%a$') then							-- one character hostname and cctld (2 chars)
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d]%.%a%a+$') then					-- two character hostname and tld
		return true;
	elseif domain:match ('^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?') then		-- IPv4 address
		return true;
	else
		return false;
	end
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a url appear to be a valid url; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if is_set (scheme) then														-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when url is protocol relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a url into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following tld) (if any) and any path(/), query(?) or fragment(#).

If protocol relative url, return nil scheme and domain else return nil for both scheme and domain.

When not protocol relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol relative url
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		authority = authority:gsub ('//', '', 1);								-- replace place 1 pair of '/' with nothing;
		if is_set(authority) then												-- if anything left (1 or 3+ '/' where authority should be) then
			return scheme;														-- return scheme only making domain nil which will cause an error message
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link= etc for properly formatted content: no wikilinks, no urls

Link parameters are to hold the title of a wikipedia article so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki urls and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid url (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid url (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from url; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid url
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wikilinked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

]]

local function link_title_ok (link, lorig, title, torig)
local orig;

	if is_set (link) then 														-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		end
	end

	if is_set (orig) then
		table.insert( z.message_tail, { set_error( 'bad_paramlink', orig)});	-- url or wikilink in |title= with |title-link=;
	end
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the url into scheme and domain
portions, or for protocol relative (//example.com) urls, just the domain.  Use is_url() to validate the two
portions of the url.  If both are valid, or for protocol relative if domain is valid, return true, else false.

Because it is different from a standard url, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper url
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from url;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a url.  The test will also find external wikilinks
that use protocol relative urls. Also finds bare urls.

The frontier pattern prevents a match on interwiki links which are similar to scheme:path urls.  The tests that
find bracketed urls are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol relative ext wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare url with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol relative bare url: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a url
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then												-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source, access)
	local error_str = &quot;&quot;;
	local domain;
	local path;
	local base_url;
	
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the url into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['[']='%5b',[']']='%5d'});					-- replace '[' and ']' with their percent encoded values
		URL=domain..path;														-- and reassemble
	end
	
	if is_set (access) then														-- access level (subscription, registration, limited)
		label = safe_for_url (label);											-- replace square brackets and newlines

		base_url = table.concat (												-- assemble external link with access signal
			{
			'&lt;span class=&quot;plainlinks&quot;&gt;[',										-- opening css and url markup
			URL,																-- the url
			' ',																-- the required space
			label,
			'&lt;span style=&quot;padding-left:0.15em&quot;&gt;',								-- signal spacing css
			cfg.presentation[access],											-- the appropriate icon
			'&lt;/span&gt;',															-- close signal spacing span
			']&lt;/span&gt;'															-- close url markup and plain links span
			});
	else
		base_url = table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url( label ), &quot;]&quot; });	-- no signal markup
	end
	
	return table.concat({ base_url, error_str });
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Replaces unicode quotemarks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc; not for book titles.

]=]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	local wl_type, label, link;

	wl_type, label, link = is_wikilink (str);									-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = substitute (cfg.presentation['kern-wl-both'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = substitute (cfg.presentation['kern-wl-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = substitute (cfg.presentation['kern-wl-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label= mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label= mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap, cap2 = mw.ustring.match (label, &quot;^([\&quot;\'])([^\'].+)&quot;);				-- match leading double or single quote but not doubled single quotes (italic markup)
		if is_set (cap) then
			label = substitute (cfg.presentation['kern-left'], {cap, cap2});
		end
	
		cap, cap2 = mw.ustring.match (label, &quot;^(.+[^\'])([\&quot;\'])$&quot;)				-- match trailing double or single quote but not doubled single quotes (italic markup)
		if is_set (cap) then
			label = substitute (cfg.presentation['kern-right'], {cap, cap2});
		end
		
		if 2 == wl_type then
			str = make_wikilink (link, label);									-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title= and |script-chapter=

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = mw.language.fetchLanguageName( lang, &quot;en&quot; );						-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, cfg.script_lang_codes) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				add_prop_cat ('script')
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return substitute( msg, str );										-- including template text
	else
		return substitute( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (scriptchapter, chapter, transchapter, chapterurl, chapter_url_source, no_quotes, access)
	local chapter_error = '';
	
	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
			chapter = wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, scriptchapter)						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (transchapter) then
		transchapter = wrap_style ('trans-quoted-title', transchapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. transchapter;
		else																	-- here when transchapter without chapter or script-chapter
			chapter = transchapter;												-- 
			chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
		end
	end

	if is_set (chapterurl) then
		chapter = external_link (chapterurl, chapter, chapter_url_source, access);		-- adds bare_url_missing_title error if appropriate
	end

	return chapter .. chapter_error;
end


--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Detects but ignores the character pattern that results from the transclusion of {{'}} templates.

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i=1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- Test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position and (char == 'zero width joiner') then						-- if we found a zero width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- its ok if one of the indic scripts
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture then 					-- nowiki, math stripmarker (not an error condition)
				stripmarker = true;												-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { set_error( 'invisible_char', {err_msg, wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i=i+1;																	-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate( name, cite_class )
	local name = tostring( name );
	local state;
	
	if in_array (cite_class, {'arxiv', 'biorxiv', 'citeseerx'}) then			-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[ name ];
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end

		if 'arxiv' == cite_class then											-- basic parameters unique to these templates
			state = whitelist.arxiv_basic_arguments[name];
		end
		if 'biorxiv' == cite_class then
			state = whitelist.biorxiv_basic_arguments[name];
		end
		if 'citeseerx' == cite_class then
			state = whitelist.citeseerx_basic_arguments[name];
		end

		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
																				-- limited enumerated parameters list
		name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#)
		state = whitelist.limited_numbered_arguments[ name ];
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates
		
	state = whitelist.basic_arguments[ name ];									-- all other templates; all normal parameters allowed
											
	if true == state then return true; end										-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);											-- parameter is deprecated but still supported
		return true;
	end
																				-- all enumerated parameters allowed
	name = name:gsub( &quot;%d+&quot;, &quot;#&quot; );												-- replace digit(s) with # (last25 becomes last#
	state = whitelist.numbered_arguments[ name ];

	if true == state then return true; end										-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);											-- parameter is deprecated but still supported
		return true;
	end
	
	return false;																-- not supported because not found or name is set to nil
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash

]]

local function hyphen_to_dash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	--[[
	Note: we use string functions here, rather than ustring functions.
	
	This has considerably faster performance and should work correctly as 
	long as the duplicate_char is strict ASCII.  The strings
	in tbl may be ASCII or UTF8.
	]]
	
	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if comp:sub(1,1) == duplicate_char then								-- is first charactier same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for th
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = str:sub(-1,-1);										-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = str:sub(1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = str:sub(1, -4) .. &quot;''&quot;;							-- remove them and add back ''
					elseif str:sub(-5,-1) == duplicate_char .. &quot;]]''&quot; then		-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif str:sub(-4,-1) == duplicate_char .. &quot;]''&quot; then		-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if str:sub(-3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif str:sub(-3,-1) == duplicate_char .. '&quot;]' then		-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif str:sub(-2,-1) == duplicate_char .. &quot;]&quot; then			-- if last two chars of str are sepc] external link
						trim = true;
					elseif str:sub(-4,-1) == duplicate_char .. &quot;'']&quot; then		-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if str:sub(-2,-1) == duplicate_char .. &quot; &quot; then				-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = str:sub(1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if dup2:match( &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end		-- if duplicate_char not a letter then escape it
						
						value = value:gsub( &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )			-- remove duplicate_char if it follows html markup
					else
						value = value:sub( 2, -1 );								-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end  


--[[--------------------------&lt; I S _ S U F F I X &gt;------------------------------------------------------------

returns true is suffix is properly formed Jr, Sr, or ordinal in the range 2–9.  Puncutation not allowed.

]]

local function is_suffix (suffix)
	if in_array (suffix, {'Jr', 'Sr', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written ouside of the code editor and pasted here because the code editor gets confused between character insertion point and cursor position.
The test has been rewritten to use decimal character escape sequence for the individual bytes of the unicode characters so that it is not necessary
to use an external editor to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first)
	local first, suffix = first:match ('(.-),?%s*([%dJS][%drndth]+)%.?$') or first;		-- if first has something that looks like a generational suffix, get it

	if is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error ('suffix');
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error ('non-Latin character');
			return false;														-- not a string of latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just intials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error ('suffix');									-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word


	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i],1,1));				-- insert the intial at end of initials table
		end
		i = i+1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = ',';																-- name-list separator between authors is a comma
		namesep = ' ';															-- last/first separator is a space
	else
		sep = ';'																-- name-list separator between authors is a semicolon
		namesep = ', '															-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = make_wikilink (person.link, one);						-- link author/editor if this page is not the author's/editor's page
				end
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end


--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]
local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of author and editor name parameters for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the parameters |display-authors=etal or |display-editors=etal

]]

local function name_has_etal (name, etal, nocat)

	if is_set (name) then														-- name can be nil in which case just return
		local etal_pattern = &quot;[;,]? *[\&quot;']*%f[%a][Ee][Tt] *[Aa][Ll][%.\&quot;']*$&quot;	-- variations on the 'et al' theme
		local others_pattern = &quot;[;,]? *%f[%a]and [Oo]thers&quot;;					-- and alternate to et al.
		
		if name:match (etal_pattern) then										-- variants on et al.
			name = name:gsub (etal_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		elseif name:match (others_pattern) then									-- if not 'et al.', then 'and others'?
			name = name:gsub (others_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		end
	end
	return name, etal;															-- 
end


--[[--------------------------&lt; N A M E _ H A S _ E D _ M A R K U P &gt;------------------------------------------

Evaluates the content of author and editor parameters for extranious editor annotations: ed, ed., eds, (Ed.), etc.
These annotation do not belong in author parameters and are redundant in editor parameters.  If found, the function
adds the editor markup maintenance category.

]]

local function name_has_ed_markup (name, list_name)
	local _, pattern;
	local patterns = {															-- these patterns match annotations at end of name
		'%f[%(%[][%(%[]%s*[Ee][Dd][Ss]?%.?%s*[%)%]]?$',							-- (ed) or (eds): leading '(', case insensitive 'ed', optional 's', '.' and/or ')'
		'[,%.%s]%f[e]eds?%.?$',													-- ed or eds: without '('or ')'; case sensitive (ED could be initials Ed could be name)
		'%f[%(%[][%(%[]%s*[Ee][Dd][Ii][Tt][Oo][Rr][Ss]?%.?%s*[%)%]]?$',			-- (editor) or (editors): leading '(', case insensitive, optional '.' and/or ')'
		'[,%.%s]%f[Ee][Ee][Dd][Ii][Tt][Oo][Rr][Ss]?%.?$',						-- editor or editors: without '('or ')'; case insensitive
		
																				-- these patterns match annotations at beginning of name
		'^eds?[%.,;]',															-- ed. or eds.: lower case only, optional 's', requires '.'
		'^[%(%[]%s*[Ee][Dd][Ss]?%.?%s*[%)%]]',									-- (ed) or (eds): also sqare brackets, case insensitive, optional 's', '.'
		'^[%(%[]?%s*[Ee][Dd][Ii][Tt][Oo][Rr][Ss]?%A',							-- (editor or (editors: also sq brackets, case insensitive, optional brackets, 's'
		'^[%(%[]?%s*[Ee][Dd][Ii][Tt][Ee][Dd]%A',								-- (edited: also sq brackets, case insensitive, optional brackets
		}

	if is_set (name) then
		for _, pattern in ipairs (patterns) do									-- spin through patterns table and
			if name:match (pattern) then
				add_maint_cat ('extra_text_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
				break;
			end
		end
	end
	return name;																-- and done
end


--[[--------------------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;----------------------------------------

Evaluates the content of author and editor (surnames only) parameters for multiple names.  Multiple names are
indicated if there is more than one comma and or semicolon.  If found, the function adds the multiple name
(author or editor) maintenance category.

]]

local function name_has_mult_names (name, list_name)
local count, _;
	if is_set (name) then
		_, count = name:gsub ('[;,]', '');										-- count the number of separator-like characters
		
		if 1 &lt; count then														-- param could be |author= or |editor= so one separator character is acceptable
			add_maint_cat ('mult_names', cfg.special_case_translation [list_name]);	-- more than one separator indicates multiple names so add a maint cat for this template
		end
	end
	return name;																-- and done
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------
This function calls various name checking functions used to validate the content of the various name-holding
parameters.

]]

local function name_checks (last, first, list_name)
	if is_set (last) then
		if last:match ('^%(%(.*%)%)$') then										-- if wrapped in doubled parentheses, accept as written 
			last = last:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			last = name_has_mult_names (last, list_name);						-- check for multiple names in the parameter (last only)
			last = name_has_ed_markup (last, list_name);						-- check for extraneous 'editor' annotation
		end
	end
	if is_set (first) then
		if first:match ('^%(%(.*%)%)$') then									-- if wrapped in doubled parentheses, accept as written 
			first = first:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			first = name_has_ed_markup (first, list_name);						-- check for extraneous 'editor' annotation
		end
	end
	return last, first;															-- done
	end


--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary
	while true do
		last = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false);							-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false);						-- find and remove variations on et al.
		last, first= name_checks (last, first, list_name);						-- multiple names, extraneous annotation, etc checks
		
		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			link_title_ok (link, list_name:match (&quot;(%w+)List&quot;):lower() .. '-link' .. i, last, list_name:match (&quot;(%w+)List&quot;):lower() .. '-last' .. i);	-- check for improper wikimarkup

			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because case of the source may be incorrect
or different from the case that WikiMedia uses, the name comparisons are done in lower case and when a match is
found, the Wikimedia version (assumed to be correct) is returned along with the code.  When there is no match, we
return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') returns a list of languages that in some cases may include
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.  Most (all?) of these languages are not used a 'language' codes per se, rather they
are used as sub-domain names: cbk-zam.wikipedia.org.  These names can be found (for the time being) at
https://phabricator.wikimedia.org/diffusion/ECLD/browse/master/LocalNames/LocalNamesEn.php

Names but that are included in the list will be found if that name is provided in the |language= parameter.  For example,
if |language=Chavacano de Zamboanga, that name will be found with the associated code 'cbk-zam'.  When names are found
and the associated code is not two or three characters, this function returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	local remap = {
		['bangla'] = {'Bengali', 'bn'},											-- MediaWiki returns Bangla (the endonym) but we want Bengali (the exonym); here we remap
		['bengali'] = {'Bengali', 'bn'},										-- MediaWiki doesn't use exonym so here we provide correct language name and 639-1 code
		['bihari'] = {'Bihari', 'bh'},											-- MediaWiki replace 'Bihari' with 'Bhojpuri' so 'Bihari' cannot be found
		['bhojpuri'] = {'Bhojpuri', 'bho'},										-- MediaWiki uses 'bh' as a subdomain name for Bhojpuri wWikipedia: bh.wikipedia.org
	}
	
	if remap[lang:lower()] then
		return remap[lang:lower()][1], remap[lang:lower()][2];					-- for this language 'name', return a possibly new name and appropriate code
	end

	local languages = mw.language.fetchLanguageNames(this_wiki_code, 'all')		-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() and 3 ~= code:len() then							-- two- or three-character codes only; extensions not supported
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the the code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for the code
end


--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code is recognized by MediaWiki,
use the returned name; if not, then use the value that was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is assigned to the category for
that code: Category:Norwegian-language sources (no).  For valid three-character code languages, the page is assigned
to the single category for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does not recognize three-character
equivalents of two-character codes: code 'ar' is recognized bit code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are
separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki = mw.getContentLanguage();									-- get a language object for this wiki
	local this_wiki_code = this_wiki:getCode()									-- get this wiki's language code
	local this_wiki_name = mw.language.fetchLanguageName(this_wiki_code, this_wiki_code);	-- get this wiki's language name

	local remap = {
		['bh'] = 'Bihari',														-- MediaWiki uses 'bh' as a subdomain name for Bhojpuri wWikipedia: bh.wikipedia.org
		['bn'] = 'Bengali',														-- MediaWiki returns Bangla
	}

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang

		if lang:match ('^%a%a%-') then											-- strip ietf language tags from code; TODO: is there a need to support 3-char with tag?
			lang = lang:match ('(%a%a)%-')										-- keep only 639-1 code portion to lang; TODO: do something with 3166 alpha 2 country code?
		end
		if 2 == lang:len() or 3 == lang:len() then								-- if two-or three-character code
			name = mw.language.fetchLanguageName( lang:lower(), this_wiki_code);	-- get language name if |language= is a proper code
		end
	
		if is_set (name) then													-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, this_wiki_code);				-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then													-- only 2- or 3-character codes
			name = remap[code] or name;											-- override wikimedia when they misuse language codes/names

			if this_wiki_code ~= code then										-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					add_prop_cat ('foreign_lang_source' .. code, {name, code})			-- categorize it
				else															-- or is a recognized language (but has a three-character code)
					add_prop_cat ('foreign_lang_source_2' .. code, {code})				-- categorize it differently TODO: support mutliple three-character code categories per cs1|2 template
				end
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, ' and ')							-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		language_list[code] = 'and ' .. language_list[code];					-- prepend last name with 'and&lt;space&gt;'
		name = table.concat (language_list, ', ')								-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
	end
	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = '.';																-- terminate the rendered citation with a period
	end
	return '.', ps;																-- separator is a full stop
end


--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = '';																-- make sure it isn't nil
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return ',', ps, ref;														-- separator is a comma
end


--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end


--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end


--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parentheses, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[--------------------------&lt; G E T _ D I S P L A Y _ A U T H O R S _ E D I T O R S &gt;------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_authors_editors (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_auth_ed', cfg.special_case_translation [list_name]);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parnetheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a place holder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parens
			local name = name_table[i];
			i=i+1;																-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parens
					break;														-- and done reassembling so
				end
				i=i+1;															-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = is_wikilink (name_table[i]);					-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i+1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);						-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parentheses to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')								-- remove doubled parntheses
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error ('punctuation');
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
			if is_suffix (first) then											-- if a valid suffix
				suffix = first													-- save it as a suffix and
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end																	-- no suffix error message here because letter combination may be result of Romanization; check for digits?
			last = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error ('missing comma');								-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error ('name');										-- matches a space between two intiials
			end
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error ('initials');									-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first);									-- check first and last before restoring the suffix which may have a non-Latin digit
			if is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '');
			end
		end

		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ) or v_link_table[i];
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice incase we have a |first1= without a |last1=; this ...
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or	-- ... also catches the case where |first= is used with |vauthors=
		select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, no, etc).  When the parameter value has not been assigned a value (missing or empty
in the source template) the function returns true.  If the parameter value is one of the list of allowed values returns
true; else, emits an error message and returns false.

]]

local function is_valid_parameter_value (value, name, possible)
	if not is_set (value) then
		return true;															-- an empty parameter is ok
	elseif in_array(value:lower(), possible) then
		return true;
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list,-3,-1) == sepc .. '. ') then						-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list,-1,-1) == sepc) or (string.sub (name_list,-3,-1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terninate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not is_set (volume) and not is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end

	local vol = '';
		
	if is_set (volume) then
		if (4 &lt; mw.ustring.len(volume)) then
			vol = substitute (cfg.messages['j-vol'], {sepc, volume});
		else
			vol = substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});
		end
	end
	if is_set (issue) then
		return vol .. substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'journal' == origin);
	
	if is_set (page) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif is_set(pages) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then										-- if pages is only digits, assume a single page number
			return '', substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org urls to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot url or to calendar pages.  When the archive url is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the url.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org url does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command url
	|archive-url= is an archive.org url that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org urls:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this funct may return a modified
archive url:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the url unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.or url
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine url
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command url, we don't want to allow saving of the target page 
		err_msg = 'save command';
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = 'liveweb';
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');		-- split out some of the url parts for evaluation
		
		if not is_set(timestamp) or 14 ~= timestamp:len() then					-- path and flag optional, must have 14-digit timestamp here
			err_msg = 'timestamp';
			if '*' ~= flag then
				url=url:gsub ('(//web%.archive%.org/[^%d]*%d?%d?%d?%d?%d?%d?)[^/]*', '%1*', 1)	-- for preview, modify ts to be yearmo* max (0-6 digits plus splat)
			end
		elseif is_set(path) and 'web/' ~= path then								-- older archive urls do not have the extra 'web/' path element
			err_msg = 'path';
		elseif is_set (flag) and not is_set (path) then							-- flag not allowed with the old form url (without the 'web/' path element)
			err_msg = 'flag';
		elseif is_set (flag) and not flag:match ('%a%a_') then					-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = 'flag';
		else
			return url, date;													-- return archiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	table.insert( z.message_tail, { set_error( 'archive_url', {err_msg}, true ) } );	-- add error message and
	if is_set (Frame:preprocess('{{REVISIONID}}')) then
		return '', '';															-- return empty strings for archiveURL and ArchiveDate
	else
		return url, date;														-- preview mode so return archiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe:
	{{cite ... |title=Title access-date=2016-03-17}}

cs1|2 shares some parameter names with xml/html atributes: class=, title=, etc.  To prevent false positives xml/html
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove xml/html tags because attributes: class=, title=, etc 

	capture = value:match ('%s+(%a[%a%d]+)%s*=') or value:match ('^(%a[%a%d]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then								-- if the capture is a valid parameter name
		add_maint_cat ('missing_pipe');
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

-- set default parameter values defined by |mode= parameter.
	local Mode = A['Mode'];
	if not is_valid_parameter_value (Mode, 'mode', cfg.keywords['mode']) then
		Mode = '';
	end

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				add_maint_cat ('authors');										-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
			add_maint_cat ('editors');											-- but add a maint cat because use of this parameter is discouraged
		end
	end

	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=

	local interviewers_list = {};
	local Interviewers = A['Interviewers']
	if is_set (Interviewers) then												-- add a maint cat if the |interviewers= is used
		add_maint_cat ('interviewers');											-- because use of this parameter is discouraged
	else
		interviewers_list = extract_names (args, 'InterviewerList');			-- else, process preferred interviewers parameters
	end

	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list
	local Contribution = A['Contribution'];
	if in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not is_set (Contribution) then									-- |contributor= requires |contribution=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if select_one (args, cfg.aliases['ContributorList-Last'], 'redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { set_error( 'contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if not is_valid_parameter_value (NameListFormat, 'name-list-format', cfg.keywords['name-list-format']) then			-- only accepted value for this parameter is 'vanc'
		NameListFormat = '';													-- anything else, set to empty string
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
			link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wikimarkup in |title-link= or wikimarkup in |title= when |title-link= is set

	local Chapter = A['Chapter'];
	local ScriptChapter = A['ScriptChapter'];
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];

	local ArchiveDate;
	local ArchiveURL;

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	
	local DeadURL = A['DeadURL']
		if not is_valid_parameter_value (DeadURL, 'dead-url', cfg.keywords ['deadurl']) then	-- set in config.defaults to 'yes'
			DeadURL = '';														-- anything else, set to empty string
		end

	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];
	local Periodical_origin = A:ORIGIN('Periodical');							-- get the name of the periodical parameter

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if in_array (config.CitationClass, cfg.templates_using_volume) then
		Volume = A['Volume'];
	end
																				-- conference &amp; map books do not support issue
	if in_array (config.CitationClass, cfg.templates_using_issue) and not (in_array (config.CitationClass, {'conference', 'map'}) and not is_set (Periodical))then
		Issue = A['Issue'];
	end
	local Position = '';
	if not in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash( A['Pages'] );	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
		if not is_valid_parameter_value (RegistrationRequired, 'registration', cfg.keywords ['yes_true_y']) then
			RegistrationRequired=nil;
		end

	local SubscriptionRequired = A['SubscriptionRequired'];
		if not is_valid_parameter_value (SubscriptionRequired, 'subscription', cfg.keywords ['yes_true_y']) then
			SubscriptionRequired=nil;
		end

	local UrlAccess = A['UrlAccess'];
		if not is_valid_parameter_value (UrlAccess, 'url-access', cfg.keywords ['url-access']) then
			UrlAccess = nil;
		end
		if not is_set(URL) and is_set(UrlAccess) then
			UrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {'url'}, true ) } );
		end

		if is_set (UrlAccess) and is_set (SubscriptionRequired) then			-- while not aliases, these are much the same so if both are set
			table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'url-access') .. ' and ' .. wrap_style ('parameter', 'subscription')}, true ) } );		-- add error message
			SubscriptionRequired = nil;											-- unset; prefer |access= over |subscription=
		end
		if is_set (UrlAccess) and is_set (RegistrationRequired) then			-- these are not the same but contradictory so if both are set
			table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'url-access') .. ' and ' .. wrap_style ('parameter', 'registration')}, true ) } );		-- add error message
			RegistrationRequired = nil;											-- unset; prefer |access= over |registration=
		end

	local ChapterUrlAccess = A['ChapterUrlAccess'];
		if not is_valid_parameter_value (ChapterUrlAccess, 'chapter-url-access', cfg.keywords ['url-access']) then	-- same as url-access
			ChapterUrlAccess = nil;
		end
		if not is_set(ChapterURL) and is_set(ChapterUrlAccess) then
			ChapterUrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {'chapter-url'}, true ) } );
		end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local Agency = A['Agency'];

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
		if not is_valid_parameter_value (IgnoreISBN, 'ignore-isbn-error', cfg.keywords ['yes_true_y']) then
			IgnoreISBN = nil;													-- anything else, set to empty string
		end
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );
	local ID_access_levels = extract_id_access_levels( args, ID_list );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
		if not is_valid_parameter_value (LastAuthorAmp, 'last-author-amp', cfg.keywords ['yes_true_y']) then
			LastAuthorAmp = nil;												-- set to empty string
		end

	local no_tracking_cats = A['NoTracking'];
		if not is_valid_parameter_value (no_tracking_cats, 'no-tracking', cfg.keywords ['yes_true_y']) then
			no_tracking_cats = nil;												-- set to empty string
		end

	--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = A['DF'];															-- date format set in cs1|2 template
	if not is_valid_parameter_value (DF, 'df', cfg.keywords['date-format']) then	-- validate reformatting keyword
		DF = '';																-- not valid, set to empty string
	end

	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

	--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

	-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	select_one( args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'redundant_parameters' );		-- this is a dummy call simply to get the error message and category

	local NoPP = A['NoPP'] 
	if is_set (NoPP) and is_valid_parameter_value (NoPP, 'nopp', cfg.keywords ['yes_true_y']) then
		NoPP = true;
	else
		NoPP = nil;																-- unset, used as a flag later
	end

	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Pages = '';															-- unset the others
			At = '';
		end
		extra_text_in_page_check (Page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.
	elseif is_set(Pages) then
		if is_set(At) then
			At = '';															-- unset
		end
		extra_text_in_page_check (Pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.
	end	

	-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia and |title then map |title to |article and |encyclopedia to |title
		|encyclopedia and |article then map |encyclopedia to |title
		|encyclopedia then map |encyclopedia to |title
	
		|trans-title maps to |trans-chapter when |title is re-mapped
		|url maps to |chapterurl when |title is remapped
	
	All other combinations of |encyclopedia, |title, and |article are not modified
	
	]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterUrlAccess = UrlAccess;

					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter = make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			else																-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if is_set(A['Number']) then												-- cite techreport uses 'number', which other citations alias to 'issue'
			if not is_set(ID) then												-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', 'id') .. ' and ' .. wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

	-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	elseif 'mailinglist' == A:ORIGIN('Periodical') then
		Periodical = '';														-- unset because mailing list is only used for cite mailing list
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		ChapterUrlAccess = UrlAccess;
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];

		link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wikimarkup in |series-link= or wikimarkup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) and is_set (AirDate) then							-- promote airdate to date
			Date = AirDate;
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('series', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = make_wikilink (ChapterLink, Chapter);
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = make_wikilink (SeriesLink, Series);
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, before generation of COinS data.
	do
		if in_array (config.CitationClass, {'arxiv', 'biorxiv', 'citeseerx'}) then
			if not is_set (ID_list[config.CitationClass:upper()]) then			-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp; |citeseerx= required for their templates
				table.insert( z.message_tail, { set_error( config.CitationClass .. '_missing', {}, true ) } );		-- add error message
			end
			
			if 'arxiv' == config.CitationClass then
				Periodical = 'arXiv';											-- set to arXiv for COinS; after that, must be set to empty string
			end

			if 'biorxiv' == config.CitationClass then
				Periodical = 'bioRxiv';											-- set to bioRxiv for COinS; after that, must be set to empty string
			end

			if 'citeseerx' == config.CitationClass then
				Periodical = 'CiteSeerX';										-- set to CiteSeerX for COinS; after that, must be set to empty string
			end
		end
	end

	-- handle type parameter for those CS1 citations that have default values
	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;interview&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
		TitleType = substitute( cfg.messages['type'], TitleType);				-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
		end
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {['access-date']=AccessDate, ['archive-date']=ArchiveDate, ['date']=Date, ['doi-broken-date']=DoiBroken,
				['embargo']=Embargo, ['lay-date']=LayDate, ['publication-date']=PublicationDate, ['year']=Year};

		anchor_year, Embargo, error_message = dates(date_parameters_list, COinS_date);
-- start temporary Julian / Gregorian calendar uncertainty categorization
		if COinS_date.inter_cal_cat then
			add_prop_cat ('jul_greg_uncertainty');
		end
-- end temporary Julian / Gregorian calendar uncertainty categorization

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end
		
		if not is_set(error_message) then										-- error free dates only
			local modified = false;												-- flag
			
			if is_set (DF) then													-- if we need to reformat dates
				modified = reformat_dates (date_parameters_list, DF, false);	-- reformat to DF format, use long month names if appropriate
			end

			if true == date_hyphen_to_dash (date_parameters_list) then			-- convert hyphens to dashes where appropriate
				modified = true;
				add_maint_cat ('date_format');									-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language,
	-- uncomment these three lines.  Not supported by en.wiki (for obvious reasons)
--			if date_name_xlate (date_parameters_list) then
--				modified = true;
--			end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'];				-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'];
				Date = date_parameters_list['date'];
				DoiBroken = date_parameters_list['doi-broken-date'];
				LayDate = date_parameters_list['lay-date'];
				PublicationDate = date_parameters_list['publication-date'];
			end
		else
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end
	end	-- end of do

	-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
	-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
			if is_set(AccessDate) then											-- access date requires |url=; pmc created url is not |url=
				table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
				AccessDate = '';												-- unset
			end

		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
			if 'episode' == config.CitationClass then							-- special case for cite episode; TODO: is there a better way to do this?
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
			else
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
			end
	end
	
	if 'none' == Title and in_array (config.CitationClass, {'journal', 'citation'}) and is_set (Periodical) and 'journal' == A:ORIGIN('Periodical') then	-- special case for journal cites
		Title = '';																-- set title to empty string
		add_maint_cat ('untitled');
	end

	check_for_url ({															-- add error message when any of these parameters contains a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[A:ORIGIN('Periodical')]=Periodical,
		[A:ORIGIN('PublisherName')] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = Periodical,
		['Encyclopedia'] = Encyclopedia,
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, and {{cite citeseerx}} AFTER generation of COinS data.
	if in_array (config.CitationClass, {'arxiv', 'biorxiv', 'citeseerx'}) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, or CiteSeerX now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = substitute (cfg.messages['newsgroup'], external_link( 'news:' .. PublisherName, PublisherName, A:ORIGIN('PublisherName'), nil ));
		end
	end



	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text,											-- get current page name so that we don't wikilink to it via editorlinkn
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_authors_editors (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if is_set (Editors) then
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
					EditorCount = 2;											-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
				else
					EditorCount = 2;											-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
				end
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum = #interviewers_list;							-- number of interviewerss
			Interviewers = list_people(control, interviewers_list, false);	-- et al not currently supported
		end
		do																		-- now do translators
			control.maximum = #t;												-- number of translators
			Translators = list_people(control, t, false);						-- et al not currently supported
		end
		do																		-- now do contributors
			control.maximum = #c;												-- number of contributors
			Contributors = list_people(control, c, false);						-- et al not currently supported
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_authors_editors (A['DisplayAuthors'], #a, 'authors', author_etal);

			last_first_list = list_people(control, a, author_etal);

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false);	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if is_set (Authors) and is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
	-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not is_set(URL) then
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then	-- |url= required for cite web, cite podcast, and cite mailinglist
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURLorigin, OriginalFormat, OriginalAccess;
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (ChapterURL) then 											-- URL not set so if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURLorigin = ChapterURLorigin;								-- name of chapter-url parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |format=
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				ChapterURLorigin = A:ORIGIN('ArchiveURL')						-- name of archive-url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
			end
		elseif is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURLorigin = URLorigin;										-- name of url parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived urls
			end
 		end
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			local chap_param;
			if is_set (Chapter) then											-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif is_set (ScriptChapter) then
				chap_param = A:ORIGIN ('ScriptChapter')
			else is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if is_set (chap_param) then											-- if we found one
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {chap_param}, true ) } );		-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if is_set (Contribution) and 0 &lt; #c then								-- if this is a contribution with contributor(s)
			if in_array (Contribution:lower(), cfg.keywords.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, Chapter, TransChapter, ChapterURL, ChapterURLorigin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter.. sepc .. ' ';
		elseif is_set (ChapterFormat) then										-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title.
	if '...' == Title:sub (-3) then												-- if elipsis is the last three characters of |title=
		Title = mw.ustring.gsub (Title, '(%.%.%.)%.+$', '%1');					-- limit the number of dots to three
	elseif not mw.ustring.find (Title, '%.%s*%a%.') then						-- end of title is not a 'dot-(optional space-)letter-dot' initialism
		Title = mw.ustring.gsub(Title, '%'..sepc..'$', '');						-- remove any trailing separator character
	end
	if is_set(TitleLink) and is_set(Title) then
		Title = make_wikilink (TitleLink, Title);
	end

	if in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then
			
			Title = external_link( URL, Title, URLorigin, UrlAccess ) .. TransTitle .. TransError .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		else
			Title = Title .. TransTitle .. TransError;
		end
	else
		Title = TransTitle .. TransError;
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURLorigin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin, nil );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if is_set(Minutes) then
			if is_set (Time) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'minutes') .. ' and ' .. wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
		Others = sepc .. ' ' .. wrap_msg ('translated', Translators, use_lowercase) .. Others;
	end
	if is_set (Interviewers) then
		Others = sepc .. ' ' .. wrap_msg ('interview', Interviewers, use_lowercase) .. Others;
	end
	
	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
		OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;		-- TODO: presentation

	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

	--[[
	Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
	note is displayed. There are no error messages for this condition.
	
	]]
	if is_set (SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif is_set (RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text

		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {IdAccessLevels=ID_access_levels, DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin, UrlAccess );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then				-- if first and last characters of quote are quote marks
			Quote = Quote:sub(2,-2);											-- strip them off
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- DeadURL is empty, 'yes', 'true', 'y', 'unfit', 'usurped'
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if in_array (DeadURL, {'unfit', 'usurped', 'bot: unknown'}) then
				Archived = sepc .. &quot; &quot; .. 'Archived from the original on ' .. ArchiveDate;	-- format already styled
				if 'bot: unknown' == DeadURL then
					add_maint_cat ('bot:_unknown');								-- and add a category if not already added
				else
					add_maint_cat ('unfit');									-- and add a category if not already added
				end
			else																-- DeadURL is empty, 'yes', 'true', or 'y'
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURLorigin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURLorigin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin, nil );
	end

	local Publisher;
	if is_set(PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if is_set(PublisherName) then
		if is_set(PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif is_set(PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = Others .. sepc .. &quot; &quot; end
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(Periodical) then		-- special cases for book cites
		if is_set (Contributors) then											-- when we are citing foreword, preface, introduction, etc
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Transcript, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if is_set(Date) then
		if is_set (Authors) or is_set (Editors) then							-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;;				-- in paranetheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon,-1,-1) == sepc) then							-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigYear;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigYear;							-- Date begins with sepc
			end
		end
	end	
	if is_set(Authors) then
		if (not is_set (Date)) then												-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then
					in_text = in_text:lower()									-- lowercase for cs2
				 end
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if is_set (Contributors) then											-- book cite and we're citing the intro, preface, etc
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if is_set (Editors) and is_set (Date) then							-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not is_set (Date)) then											-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = config.CitationClass;
		options.class = &quot;citation &quot; .. config.CitationClass;					-- class=citation required for blue highlight when used with |ref=
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then								-- set reference anchor if appropriate
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			if #namelist &gt; 0 then												-- if there are names in namelist
				id = anchor_id (namelist, year);								-- go make the CITEREF anchor
			else
				id = '';														-- unset
			end
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;(.-)&lt;/span&gt;&quot;, &quot;%1&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then	-- remove &lt;span&gt; tags and other html-like markup; then get length of what remains
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	local render = {};															-- here we collect the final bits for concatenation into the rendered citation

	if is_set(options.id) then													-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render, substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text}));	-- when |ref= is set
	else
		table.insert (render, substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text}));	-- all other cases
	end		

	table.insert (render, substitute (cfg.presentation['ocins'], {OCinSoutput}));		-- append metadata to the citation

	if #z.message_tail ~= 0 then
		table.insert (render, ' ');
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					table.insert (render, error_comment( v[1], v[2] ));
				else
					table.insert (render, error_comment( v[1] .. &quot;; &quot;, v[2] ));
				end
			end
		end
	end

	if #z.maintenance_cats ~= 0 then
		table.insert (render, '&lt;span class=&quot;citation-comment&quot; style=&quot;display:none; color:#33aa33; margin-left:0.3em&quot;&gt;');
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			table.insert (render, v);
			table.insert (render, ' (');
			table.insert (render, make_wikilink (':Category:' .. v, 'link'));
			table.insert (render, ') ');
		end
		table.insert (render, '&lt;/span&gt;');
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			table.insert (render, make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			table.insert (render, make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.properties_cats ) do								-- append properties categories
			table.insert (render, make_wikilink ('Category:' .. v));
		end
	end

	return table.concat (render);	
end


--[[--------------------------&lt; C S 1 . C I T A T I O N &gt;------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

function cs1.citation(frame)
	Frame = frame;																-- save a copy incase we need to display an error message in preview mode
	local pframe = frame:getParent()
	local validation, utilities, identifiers, metadata;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	dates = validation.dates;													-- imported functions from Module:Citation/CS1/Date validation
	year_date_check = validation.year_date_check;
	reformat_dates = validation.reformat_dates;
	date_hyphen_to_dash = validation.date_hyphen_to_dash;
	date_name_xlate = validation.date_name_xlate;

	is_set = utilities.is_set;													-- imported functions from Module:Citation/CS1/Utilities
	in_array = utilities.in_array;
	substitute = utilities.substitute;
	error_comment = utilities.error_comment;
	set_error = utilities.set_error;
	select_one = utilities.select_one;
	add_maint_cat = utilities.add_maint_cat;
	wrap_style = utilities.wrap_style;
	safe_for_italics = utilities.safe_for_italics;
	is_wikilink = utilities.is_wikilink;
	make_wikilink = utilities.make_wikilink;

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	extract_ids = identifiers.extract_ids;										-- imported functions from Module:Citation/CS1/Identifiers
	build_id_list = identifiers.build_id_list;
	is_embargoed = identifiers.is_embargoed;
	extract_id_access_levels = identifiers.extract_id_access_levels;
	
	make_coins_title = metadata.make_coins_title;								-- imported functions from Module:Citation/CS1/COinS
	get_coins_pages = metadata.get_coins_pages;
	COinS = metadata.COinS;

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text, error_state;

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do
		config[k] = v;
--		args[k] = v;															-- debug tool that allows us to render a citation from module {{#invoke:}}
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if not validate( k, config.CitationClass ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower(), config.CitationClass ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute( param, capture );				-- add the capture to the suggested parameter (typically the enumerator)
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, param}, true );	-- set the error message
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			missing_pipe_check (v);												-- do we think that there is a parameter that is missing a pipe?
			
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then
			args[k] = v;
		end		
	end	

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);
		end
	end
	return citation0( config, args)
end

return cs1;</text>
      <sha1>p7he7iz3bxgxc5kjp3g2mrtmgcn4d8h</sha1>
    </revision>
    <revision>
      <id>4719</id>
      <parentid>4718</parentid>
      <timestamp>2018-06-09T21:37:08Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>synch from sandbox;</comment>
      <origin>4719</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="166834" sha1="5buuffhlp1g9lk1bcu8ewmra56i6h7l" xml:space="preserve">
local cs1 ={};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local dates, year_date_check, reformat_dates, date_hyphen_to_dash,				-- functions in Module:Citation/CS1/Date_validation
	date_name_xlate

local is_set, in_array, substitute, error_comment, set_error, select_one,		-- functions in Module:Citation/CS1/Utilities
	add_maint_cat, wrap_style, safe_for_italics, is_wikilink, make_wikilink;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local extract_ids, extract_id_access_levels, build_id_list, is_embargoed;		-- functions in Module:Citation/CS1/Identifiers

local make_coins_title, get_coins_pages, COinS;									-- functions in Module:Citation/CS1/COinS

local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

delare variables here that have page-wide scope that are not brought in from other modules; thatare created here
and used here

]]

local added_deprecated_cat;														-- boolean flag so that the category is added only once
local added_prop_cats = {};														-- list of property categories that have been added to z.properties_cats
local added_vanc_errs;															-- boolean flag so we only emit one Vancouver error / category

local Frame;																	-- holds the module's frame table


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

foreign_lang_source and foreign_lang_source_2 keys have a language code appended to them so that multiple languages
may be categorized but multiples of the same language are not categorized.

added_prop_cats is a table declared in page scope variables above

]]

local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		key = key:gsub ('(foreign_lang_source_?2?)%a%a%a?', '%1');				-- strip lang code from keyname
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));		-- make name then add to table
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a boolean declared in page scope variables above

]]

local function add_vanc_error (source)
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {source}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a uri scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of tlds: https://www.iana.org/domains/root/db

rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the tld.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a url with a scheme) will be stripped
here.  Perhaps not necessary but retained incase it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ascii characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the tld) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org and .cash TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and tld or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%a%d]') then										-- first character must be letter or digit
		return false;
	end
																				-- Do most common case first
	if domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.%a%a+$') then				-- three or more character hostname.hostname or hostname.tld
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.xn%-%-[%a%d]+$') then	-- internationalized domain name with ACE prefix
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.cash$') then							-- one character/digit .cash hostname
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.org$') then							-- one character/digit .org hostname
		return true;
	elseif domain:match ('%f[%a][qxz]%.com$') then								-- assigned one character .com hostname (x.com times out 2015-12-10)
		return true;
	elseif domain:match ('%f[%a][iq]%.net$') then								-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.%a%a$') then							-- one character hostname and cctld (2 chars)
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d]%.%a%a+$') then					-- two character hostname and tld
		return true;
	elseif domain:match ('^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?') then		-- IPv4 address
		return true;
	else
		return false;
	end
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a url appear to be a valid url; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if is_set (scheme) then														-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when url is protocol relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a url into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following tld) (if any) and any path(/), query(?) or fragment(#).

If protocol relative url, return nil scheme and domain else return nil for both scheme and domain.

When not protocol relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol relative url
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		authority = authority:gsub ('//', '', 1);								-- replace place 1 pair of '/' with nothing;
		if is_set(authority) then												-- if anything left (1 or 3+ '/' where authority should be) then
			return scheme;														-- return scheme only making domain nil which will cause an error message
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link= etc for properly formatted content: no wikilinks, no urls

Link parameters are to hold the title of a wikipedia article so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki urls and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid url (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid url (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from url; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid url
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wikilinked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

]]

local function link_title_ok (link, lorig, title, torig)
local orig;

	if is_set (link) then 														-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		end
	end

	if is_set (orig) then
		table.insert( z.message_tail, { set_error( 'bad_paramlink', orig)});	-- url or wikilink in |title= with |title-link=;
	end
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the url into scheme and domain
portions, or for protocol relative (//example.com) urls, just the domain.  Use is_url() to validate the two
portions of the url.  If both are valid, or for protocol relative if domain is valid, return true, else false.

Because it is different from a standard url, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper url
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from url;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a url.  The test will also find external wikilinks
that use protocol relative urls. Also finds bare urls.

The frontier pattern prevents a match on interwiki links which are similar to scheme:path urls.  The tests that
find bracketed urls are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol relative ext wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare url with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol relative bare url: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a url
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then												-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source, access)
	local error_str = &quot;&quot;;
	local domain;
	local path;
	local base_url;
	
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the url into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['[']='%5b',[']']='%5d'});					-- replace '[' and ']' with their percent encoded values
		URL=domain..path;														-- and reassemble
	end
	
	if is_set (access) then														-- access level (subscription, registration, limited)
		label = safe_for_url (label);											-- replace square brackets and newlines

		base_url = table.concat (												-- assemble external link with access signal
			{
			'&lt;span class=&quot;plainlinks&quot;&gt;[',										-- opening css and url markup
			URL,																-- the url
			' ',																-- the required space
			label,
			'&lt;span style=&quot;padding-left:0.15em&quot;&gt;',								-- signal spacing css
			cfg.presentation[access],											-- the appropriate icon
			'&lt;/span&gt;',															-- close signal spacing span
			']&lt;/span&gt;'															-- close url markup and plain links span
			});
	else
		base_url = table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url( label ), &quot;]&quot; });	-- no signal markup
	end
	
	return table.concat({ base_url, error_str });
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Replaces unicode quotemarks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc; not for book titles.

]=]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	local wl_type, label, link;

	wl_type, label, link = is_wikilink (str);									-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = substitute (cfg.presentation['kern-wl-both'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = substitute (cfg.presentation['kern-wl-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = substitute (cfg.presentation['kern-wl-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label= mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label= mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap, cap2 = mw.ustring.match (label, &quot;^([\&quot;\'])([^\'].+)&quot;);				-- match leading double or single quote but not doubled single quotes (italic markup)
		if is_set (cap) then
			label = substitute (cfg.presentation['kern-left'], {cap, cap2});
		end
	
		cap, cap2 = mw.ustring.match (label, &quot;^(.+[^\'])([\&quot;\'])$&quot;)				-- match trailing double or single quote but not doubled single quotes (italic markup)
		if is_set (cap) then
			label = substitute (cfg.presentation['kern-right'], {cap, cap2});
		end
		
		if 2 == wl_type then
			str = make_wikilink (link, label);									-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title= and |script-chapter=

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_code_remap[lang] or mw.language.fetchLanguageName( lang, &quot;en&quot; );	-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, cfg.script_lang_codes) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				add_prop_cat ('script')
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return substitute( msg, str );										-- including template text
	else
		return substitute( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (scriptchapter, chapter, transchapter, chapterurl, chapter_url_source, no_quotes, access)
	local chapter_error = '';
	
	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
			chapter = wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, scriptchapter)						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (chapterurl) then
		chapter = external_link (chapterurl, chapter, chapter_url_source, access);		-- adds bare_url_missing_title error if appropriate
	end

	if is_set (transchapter) then
		transchapter = wrap_style ('trans-quoted-title', transchapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. transchapter;
		else																	-- here when transchapter without chapter or script-chapter
			chapter = transchapter;												-- 
			chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
		end
	end

--	if is_set (chapterurl) then
--		chapter = external_link (chapterurl, chapter, chapter_url_source, access);		-- adds bare_url_missing_title error if appropriate
--	end

	return chapter .. chapter_error;
end


--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Detects but ignores the character pattern that results from the transclusion of {{'}} templates.

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i=1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- Test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position and (char == 'zero width joiner') then						-- if we found a zero width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- its ok if one of the indic scripts
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture then 					-- nowiki, math stripmarker (not an error condition)
				stripmarker = true;												-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { set_error( 'invisible_char', {err_msg, wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i=i+1;																	-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate( name, cite_class )
	local name = tostring( name );
	local state;
	
	if in_array (cite_class, {'arxiv', 'biorxiv', 'citeseerx'}) then			-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[ name ];
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end

		if 'arxiv' == cite_class then											-- basic parameters unique to these templates
			state = whitelist.arxiv_basic_arguments[name];
		end
		if 'biorxiv' == cite_class then
			state = whitelist.biorxiv_basic_arguments[name];
		end
		if 'citeseerx' == cite_class then
			state = whitelist.citeseerx_basic_arguments[name];
		end

		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
																				-- limited enumerated parameters list
		name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
		state = whitelist.limited_numbered_arguments[ name ];
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates
		
	state = whitelist.basic_arguments[ name ];									-- all other templates; all normal parameters allowed
											
	if true == state then return true; end										-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);											-- parameter is deprecated but still supported
		return true;
	end
																				-- all enumerated parameters allowed
	name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );												-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
	state = whitelist.numbered_arguments[ name ];

	if true == state then return true; end										-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);											-- parameter is deprecated but still supported
		return true;
	end
	
	return false;																-- not supported because not found or name is set to nil
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash

]]

local function hyphen_to_dash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'dupicate character'
		if 1 == #duplicate_char then											-- for single byte ascii characters use the string library functions
			f.gsub=string.gsub
			f.match=string.match
			f.sub=string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub=mw.ustring.gsub
			f.match=mw.ustring.match
			f.sub=mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1,1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = f.sub(str, -1,-1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if f.sub(str, -3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5,-1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4,-1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if f.sub(str, -3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3,-1) == duplicate_char .. '&quot;]' then		-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2,-1) == duplicate_char .. &quot;]&quot; then		-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4,-1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2,-1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows html markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;------------------------------------------------------------

returns true is suffix is properly formed Jr, Sr, or ordinal in the range 2–9.  Puncutation not allowed.

]]

local function is_suffix (suffix)
	if in_array (suffix, {'Jr', 'Sr', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written ouside of the code editor and pasted here because the code editor gets confused between character insertion point and cursor position.
The test has been rewritten to use decimal character escape sequence for the individual bytes of the unicode characters so that it is not necessary
to use an external editor to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first)
	local first, suffix = first:match ('(.-),?%s*([%dJS][%drndth]+)%.?$') or first;		-- if first has something that looks like a generational suffix, get it

	if is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error ('suffix');
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error ('non-Latin character');
			return false;														-- not a string of latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just intials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error ('suffix');									-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word


	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i],1,1));				-- insert the intial at end of initials table
		end
		i = i+1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between authors is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between authors is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = make_wikilink (person.link, one);						-- link author/editor if this page is not the author's/editor's page
				end
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end


--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]
local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of author and editor name parameters for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the parameters |display-authors=etal or |display-editors=etal

]]

local function name_has_etal (name, etal, nocat)

	if is_set (name) then														-- name can be nil in which case just return
		local etal_pattern = &quot;[;,]? *[\&quot;']*%f[%a][Ee][Tt] *[Aa][Ll][%.\&quot;']*$&quot;	-- variations on the 'et al' theme
		local others_pattern = &quot;[;,]? *%f[%a]and [Oo]thers&quot;;					-- and alternate to et al.
		
		if name:match (etal_pattern) then										-- variants on et al.
			name = name:gsub (etal_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		elseif name:match (others_pattern) then									-- if not 'et al.', then 'and others'?
			name = name:gsub (others_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		end
	end
	return name, etal;															-- 
end


--[[--------------------------&lt; N A M E _ H A S _ E D _ M A R K U P &gt;------------------------------------------

Evaluates the content of author and editor parameters for extranious editor annotations: ed, ed., eds, (Ed.), etc.
These annotation do not belong in author parameters and are redundant in editor parameters.  If found, the function
adds the editor markup maintenance category.

]]

local function name_has_ed_markup (name, list_name)
	local _, pattern;
	local patterns = {															-- these patterns match annotations at end of name
		'%f[%(%[][%(%[]%s*[Ee][Dd][Ss]?%.?%s*[%)%]]?$',							-- (ed) or (eds): leading '(', case insensitive 'ed', optional 's', '.' and/or ')'
		'[,%.%s]%f[e]eds?%.?$',													-- ed or eds: without '('or ')'; case sensitive (ED could be initials Ed could be name)
		'%f[%(%[][%(%[]%s*[Ee][Dd][Ii][Tt][Oo][Rr][Ss]?%.?%s*[%)%]]?$',			-- (editor) or (editors): leading '(', case insensitive, optional '.' and/or ')'
		'[,%.%s]%f[Ee][Ee][Dd][Ii][Tt][Oo][Rr][Ss]?%.?$',						-- editor or editors: without '('or ')'; case insensitive
		
																				-- these patterns match annotations at beginning of name
		'^eds?[%.,;]',															-- ed. or eds.: lower case only, optional 's', requires '.'
		'^[%(%[]%s*[Ee][Dd][Ss]?%.?%s*[%)%]]',									-- (ed) or (eds): also sqare brackets, case insensitive, optional 's', '.'
		'^[%(%[]?%s*[Ee][Dd][Ii][Tt][Oo][Rr][Ss]?%A',							-- (editor or (editors: also sq brackets, case insensitive, optional brackets, 's'
		'^[%(%[]?%s*[Ee][Dd][Ii][Tt][Ee][Dd]%A',								-- (edited: also sq brackets, case insensitive, optional brackets
		}

	if is_set (name) then
		for _, pattern in ipairs (patterns) do									-- spin through patterns table and
			if name:match (pattern) then
				add_maint_cat ('extra_text_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
				break;
			end
		end
	end
	return name;																-- and done
end


--[[--------------------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;----------------------------------------

Evaluates the content of author and editor (surnames only) parameters for multiple names.  Multiple names are
indicated if there is more than one comma and or semicolon.  If found, the function adds the multiple name
(author or editor) maintenance category.

]]

local function name_has_mult_names (name, list_name)
local count, _;
	if is_set (name) then
		_, count = name:gsub ('[;,]', '');										-- count the number of separator-like characters
		
		if 1 &lt; count then														-- param could be |author= or |editor= so one separator character is acceptable
			add_maint_cat ('mult_names', cfg.special_case_translation [list_name]);	-- more than one separator indicates multiple names so add a maint cat for this template
		end
	end
	return name;																-- and done
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------
This function calls various name checking functions used to validate the content of the various name-holding
parameters.

]]

local function name_checks (last, first, list_name)
	if is_set (last) then
		if last:match ('^%(%(.*%)%)$') then										-- if wrapped in doubled parentheses, accept as written 
			last = last:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			last = name_has_mult_names (last, list_name);						-- check for multiple names in the parameter (last only)
			last = name_has_ed_markup (last, list_name);						-- check for extraneous 'editor' annotation
		end
	end
	if is_set (first) then
		if first:match ('^%(%(.*%)%)$') then									-- if wrapped in doubled parentheses, accept as written 
			first = first:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			first = name_has_ed_markup (first, list_name);						-- check for extraneous 'editor' annotation
		end
	end
	return last, first;															-- done
	end


--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary
	while true do
		last = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false);							-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false);						-- find and remove variations on et al.
		last, first= name_checks (last, first, list_name);						-- multiple names, extraneous annotation, etc checks
		
		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			link_title_ok (link, list_name:match (&quot;(%w+)List&quot;):lower() .. '-link' .. i, last, list_name:match (&quot;(%w+)List&quot;):lower() .. '-last' .. i);	-- check for improper wikimarkup

			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because case of the source may be incorrect
or different from the case that WikiMedia uses, the name comparisons are done in lower case and when a match is
found, the Wikimedia version (assumed to be correct) is returned along with the code.  When there is no match, we
return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') returns a list of languages that in some cases may include
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.  Most (all?) of these languages are not used a 'language' codes per se, rather they
are used as sub-domain names: cbk-zam.wikipedia.org.  These names can be found (for the time being) at
https://phabricator.wikimedia.org/diffusion/ECLD/browse/master/LocalNames/LocalNamesEn.php

Names but that are included in the list will be found if that name is provided in the |language= parameter.  For example,
if |language=Chavacano de Zamboanga, that name will be found with the associated code 'cbk-zam'.  When names are found
and the associated code is not two or three characters, this function returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	if cfg.lang_name_remap[lang:lower()] then									-- if there is a remapped name (because MediaWiki uses something that we don't think is correct)
		return cfg.lang_name_remap[lang:lower()][1], cfg.lang_name_remap[lang:lower()][2];	-- for this language 'name', return a possibly new name and appropriate code
	end

	local languages = mw.language.fetchLanguageNames(this_wiki_code, 'all')		-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() and 3 ~= code:len() then							-- two- or three-character codes only; extensions not supported
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the the code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for the code
end


--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code is recognized by MediaWiki,
use the returned name; if not, then use the value that was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is assigned to the category for
that code: Category:Norwegian-language sources (no).  For valid three-character code languages, the page is assigned
to the single category for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does not recognize three-character
equivalents of two-character codes: code 'ar' is recognized bit code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are
separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki = mw.getContentLanguage();									-- get a language object for this wiki
	local this_wiki_code = this_wiki:getCode()									-- get this wiki's language code
	local this_wiki_name = mw.language.fetchLanguageName(this_wiki_code, this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang

		if lang:match ('^%a%a%-') then											-- strip ietf language tags from code; TODO: is there a need to support 3-char with tag?
			lang = lang:match ('(%a%a)%-')										-- keep only 639-1 code portion to lang; TODO: do something with 3166 alpha 2 country code?
		end
		if 2 == lang:len() or 3 == lang:len() then								-- if two-or three-character code
			name = mw.language.fetchLanguageName( lang:lower(), this_wiki_code);	-- get language name if |language= is a proper code
			if not is_set (name) then
				name = cfg.lang_code_remap[lang];								-- not supported by MediaWiki; is it in remap?
			end
		end
	
		if is_set (name) then													-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, this_wiki_code);				-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then													-- only 2- or 3-character codes
			name = cfg.lang_code_remap[code] or name;							-- override wikimedia when they misuse language codes/names

			if this_wiki_code ~= code then										-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					add_prop_cat ('foreign_lang_source' .. code, {name, code})	-- categorize it
				else															-- or is a recognized language (but has a three-character code)
					add_prop_cat ('foreign_lang_source_2' .. code, {code})		-- categorize it differently TODO: support mutliple three-character code categories per cs1|2 template
				end
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, ' and ')							-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		language_list[code] = 'and ' .. language_list[code];					-- prepend last name with 'and&lt;space&gt;'
		name = table.concat (language_list, ', ')								-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
	end
	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings
At en.wiki, for cs1:
	ps gets:	'.'
	sep gets:	'.'

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = cfg.presentation['ps_cs1'];										-- terminate the rendered citation
	end
	return cfg.presentation['sep_cs1'], ps;										-- element separator
end


--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings
At en.wiki, for cs2:
	ps gets:	'' (empty string - no terminal punctuation)
	sep gets:	','

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = cfg.presentation['ps_cs2'];										-- terminate the rendered citation
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return cfg.presentation['sep_cs2'], ps, ref;								-- element separator
end


--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end


--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end


--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parentheses, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[--------------------------&lt; G E T _ D I S P L A Y _ A U T H O R S _ E D I T O R S &gt;------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_authors_editors (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_auth_ed', cfg.special_case_translation [list_name]);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parnetheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a place holder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parens
			local name = name_table[i];
			i=i+1;																-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parens
					break;														-- and done reassembling so
				end
				i=i+1;															-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = is_wikilink (name_table[i]);					-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i+1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);						-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parentheses to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')								-- remove doubled parntheses
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error ('punctuation');
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
			if is_suffix (first) then											-- if a valid suffix
				suffix = first													-- save it as a suffix and
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end																	-- no suffix error message here because letter combination may be result of Romanization; check for digits?
			last = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error ('missing comma');								-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error ('name');										-- matches a space between two intiials
			end
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error ('initials');									-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first);									-- check first and last before restoring the suffix which may have a non-Latin digit
			if is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '');
			end
		end

		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ) or v_link_table[i];
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice incase we have a |first1= without a |last1=; this ...
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or	-- ... also catches the case where |first= is used with |vauthors=
		select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, no, etc).  When the parameter value has not been assigned a value (missing or empty
in the source template) the function returns true.  If the parameter value is one of the list of allowed values returns
true; else, emits an error message and returns false.

]]

local function is_valid_parameter_value (value, name, possible)
	if not is_set (value) then
		return true;															-- an empty parameter is ok
	elseif in_array(value:lower(), possible) then
		return true;
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list,-3,-1) == sepc .. '. ') then						-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list,-1,-1) == sepc) or (string.sub (name_list,-3,-1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terninate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not is_set (volume) and not is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end

	local vol = '';
		
	if is_set (volume) then
		if (4 &lt; mw.ustring.len(volume)) then
			vol = substitute (cfg.messages['j-vol'], {sepc, volume});
		else
			vol = substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});
		end
	end
	if is_set (issue) then
		return vol .. substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if is_set (page) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif is_set(pages) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then										-- if pages is only digits, assume a single page number
			return '', substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org urls to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot url or to calendar pages.  When the archive url is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the url.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org url does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command url
	|archive-url= is an archive.org url that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org urls:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this funct may return a modified
archive url:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the url unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.or url
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine url
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command url, we don't want to allow saving of the target page 
		err_msg = 'save command';
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = 'liveweb';
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');		-- split out some of the url parts for evaluation
		
		if not is_set(timestamp) or 14 ~= timestamp:len() then					-- path and flag optional, must have 14-digit timestamp here
			err_msg = 'timestamp';
			if '*' ~= flag then
				url=url:gsub ('(//web%.archive%.org/[^%d]*%d?%d?%d?%d?%d?%d?)[^/]*', '%1*', 1)	-- for preview, modify ts to be yearmo* max (0-6 digits plus splat)
			end
		elseif is_set(path) and 'web/' ~= path then								-- older archive urls do not have the extra 'web/' path element
			err_msg = 'path';
		elseif is_set (flag) and not is_set (path) then							-- flag not allowed with the old form url (without the 'web/' path element)
			err_msg = 'flag';
		elseif is_set (flag) and not flag:match ('%a%a_') then					-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = 'flag';
		else
			return url, date;													-- return archiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	table.insert( z.message_tail, { set_error( 'archive_url', {err_msg}, true ) } );	-- add error message and
	if is_set (Frame:preprocess('{{REVISIONID}}')) then
		return '', '';															-- return empty strings for archiveURL and ArchiveDate
	else
		return url, date;														-- preview mode so return archiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe:
	{{cite ... |title=Title access-date=2016-03-17}}

cs1|2 shares some parameter names with xml/html atributes: class=, title=, etc.  To prevent false positives xml/html
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove xml/html tags because attributes: class=, title=, etc 

	capture = value:match ('%s+(%a[%a%d]+)%s*=') or value:match ('^(%a[%a%d]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then								-- if the capture is a valid parameter name
		add_maint_cat ('missing_pipe');
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

-- set default parameter values defined by |mode= parameter.
	local Mode = A['Mode'];
	if not is_valid_parameter_value (Mode, 'mode', cfg.keywords['mode']) then
		Mode = '';
	end

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				add_maint_cat ('authors');										-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
			add_maint_cat ('editors');											-- but add a maint cat because use of this parameter is discouraged
		end
	end

	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=

	local interviewers_list = {};
	local Interviewers = A['Interviewers']
	if is_set (Interviewers) then												-- add a maint cat if the |interviewers= is used
		add_maint_cat ('interviewers');											-- because use of this parameter is discouraged
	else
		interviewers_list = extract_names (args, 'InterviewerList');			-- else, process preferred interviewers parameters
	end

	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list
	local Contribution = A['Contribution'];
	if in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not is_set (Contribution) then									-- |contributor= requires |contribution=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if select_one (args, cfg.aliases['ContributorList-Last'], 'redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { set_error( 'contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if not is_valid_parameter_value (NameListFormat, 'name-list-format', cfg.keywords['name-list-format']) then			-- only accepted value for this parameter is 'vanc'
		NameListFormat = '';													-- anything else, set to empty string
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
			link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wikimarkup in |title-link= or wikimarkup in |title= when |title-link= is set

	local Chapter = A['Chapter'];
	local ScriptChapter = A['ScriptChapter'];
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];

	local ArchiveDate;
	local ArchiveURL;

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	
	local DeadURL = A['DeadURL']
		if not is_valid_parameter_value (DeadURL, 'dead-url', cfg.keywords ['deadurl']) then	-- set in config.defaults to 'yes'
			DeadURL = '';														-- anything else, set to empty string
		end

	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];
	local Periodical_origin = A:ORIGIN('Periodical');							-- get the name of the periodical parameter

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if in_array (config.CitationClass, cfg.templates_using_volume) then
		Volume = A['Volume'];
	end
																				-- conference &amp; map books do not support issue
	if in_array (config.CitationClass, cfg.templates_using_issue) and not (in_array (config.CitationClass, {'conference', 'map'}) and not is_set (Periodical))then
		Issue = A['Issue'];
	end
	local Position = '';
	if not in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash( A['Pages'] );	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
		if not is_valid_parameter_value (RegistrationRequired, 'registration', cfg.keywords ['yes_true_y']) then
			RegistrationRequired=nil;
		end

	local SubscriptionRequired = A['SubscriptionRequired'];
		if not is_valid_parameter_value (SubscriptionRequired, 'subscription', cfg.keywords ['yes_true_y']) then
			SubscriptionRequired=nil;
		end

	local UrlAccess = A['UrlAccess'];
		if not is_valid_parameter_value (UrlAccess, 'url-access', cfg.keywords ['url-access']) then
			UrlAccess = nil;
		end
		if not is_set(URL) and is_set(UrlAccess) then
			UrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {'url'}, true ) } );
		end

		if is_set (UrlAccess) and is_set (SubscriptionRequired) then			-- while not aliases, these are much the same so if both are set
			table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'url-access') .. ' and ' .. wrap_style ('parameter', 'subscription')}, true ) } );		-- add error message
			SubscriptionRequired = nil;											-- unset; prefer |access= over |subscription=
		end
		if is_set (UrlAccess) and is_set (RegistrationRequired) then			-- these are not the same but contradictory so if both are set
			table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'url-access') .. ' and ' .. wrap_style ('parameter', 'registration')}, true ) } );		-- add error message
			RegistrationRequired = nil;											-- unset; prefer |access= over |registration=
		end

	local ChapterUrlAccess = A['ChapterUrlAccess'];
		if not is_valid_parameter_value (ChapterUrlAccess, 'chapter-url-access', cfg.keywords ['url-access']) then	-- same as url-access
			ChapterUrlAccess = nil;
		end
		if not is_set(ChapterURL) and is_set(ChapterUrlAccess) then
			ChapterUrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {'chapter-url'}, true ) } );
		end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local Agency = A['Agency'];

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
		if not is_valid_parameter_value (IgnoreISBN, 'ignore-isbn-error', cfg.keywords ['yes_true_y']) then
			IgnoreISBN = nil;													-- anything else, set to empty string
		end
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );
	local ID_access_levels = extract_id_access_levels( args, ID_list );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
		if not is_valid_parameter_value (LastAuthorAmp, 'last-author-amp', cfg.keywords ['yes_true_y']) then
			LastAuthorAmp = nil;												-- set to empty string
		end

	local no_tracking_cats = A['NoTracking'];
		if not is_valid_parameter_value (no_tracking_cats, 'no-tracking', cfg.keywords ['yes_true_y']) then
			no_tracking_cats = nil;												-- set to empty string
		end

	--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = A['DF'];															-- date format set in cs1|2 template
	if not is_valid_parameter_value (DF, 'df', cfg.keywords['date-format']) then	-- validate reformatting keyword
		DF = '';																-- not valid, set to empty string
	end

	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

	--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

	-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	select_one( args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'redundant_parameters' );		-- this is a dummy call simply to get the error message and category

	local NoPP = A['NoPP'] 
	if is_set (NoPP) and is_valid_parameter_value (NoPP, 'nopp', cfg.keywords ['yes_true_y']) then
		NoPP = true;
	else
		NoPP = nil;																-- unset, used as a flag later
	end

	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Pages = '';															-- unset the others
			At = '';
		end
		extra_text_in_page_check (Page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.
	elseif is_set(Pages) then
		if is_set(At) then
			At = '';															-- unset
		end
		extra_text_in_page_check (Pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.
	end	

	-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia and |title then map |title to |article and |encyclopedia to |title
		|encyclopedia and |article then map |encyclopedia to |title
		|encyclopedia then map |encyclopedia to |title
	
		|trans-title maps to |trans-chapter when |title is re-mapped
		|url maps to |chapterurl when |title is remapped
	
	All other combinations of |encyclopedia, |title, and |article are not modified
	
	]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterUrlAccess = UrlAccess;

					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter = make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			else																-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if is_set(A['Number']) then												-- cite techreport uses 'number', which other citations alias to 'issue'
			if not is_set(ID) then												-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', 'id') .. ' and ' .. wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

	-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	elseif 'mailinglist' == A:ORIGIN('Periodical') then
		Periodical = '';														-- unset because mailing list is only used for cite mailing list
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		ChapterUrlAccess = UrlAccess;
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];

		link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wikimarkup in |series-link= or wikimarkup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) and is_set (AirDate) then							-- promote airdate to date
			Date = AirDate;
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('series', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = make_wikilink (ChapterLink, Chapter);
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = make_wikilink (SeriesLink, Series);
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, before generation of COinS data.
	do
		if in_array (config.CitationClass, {'arxiv', 'biorxiv', 'citeseerx'}) then
			if not is_set (ID_list[config.CitationClass:upper()]) then			-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp; |citeseerx= required for their templates
				table.insert( z.message_tail, { set_error( config.CitationClass .. '_missing', {}, true ) } );		-- add error message
			end
			
			if 'arxiv' == config.CitationClass then
				Periodical = 'arXiv';											-- set to arXiv for COinS; after that, must be set to empty string
			end

			if 'biorxiv' == config.CitationClass then
				Periodical = 'bioRxiv';											-- set to bioRxiv for COinS; after that, must be set to empty string
			end

			if 'citeseerx' == config.CitationClass then
				Periodical = 'CiteSeerX';										-- set to CiteSeerX for COinS; after that, must be set to empty string
			end
		end
	end

	-- handle type parameter for those CS1 citations that have default values
	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;interview&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
		TitleType = substitute( cfg.messages['type'], TitleType);				-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging

	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
--		local date_parameters_list = {['access-date']=AccessDate, ['archive-date']=ArchiveDate, ['date']=Date, ['doi-broken-date']=DoiBroken,
--				['embargo']=Embargo, ['lay-date']=LayDate, ['publication-date']=PublicationDate, ['year']=Year};

		local date_parameters_list = {
			['access-date'] = {val=AccessDate, name=A:ORIGIN ('AccessDate')},
			['archive-date'] = {val=ArchiveDate, name=A:ORIGIN ('ArchiveDate')},
			['date'] = {val=Date, name=Date_origin},
			['doi-broken-date'] = {val=DoiBroken, name=A:ORIGIN ('DoiBroken')},
			['embargo'] = {val=Embargo, name=A:ORIGIN ('Embargo')},
			['lay-date'] = {val=LayDate, name=A:ORIGIN ('LayDate')},
			['publication-date'] ={val=PublicationDate, name=A:ORIGIN ('PublicationDate')},
			['year'] = {val=Year, name=A:ORIGIN ('Year')},
			};
		anchor_year, Embargo, error_message = dates(date_parameters_list, COinS_date);

-- start temporary Julian / Gregorian calendar uncertainty categorization
		if COinS_date.inter_cal_cat then
			add_prop_cat ('jul_greg_uncertainty');
		end
-- end temporary Julian / Gregorian calendar uncertainty categorization

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end
		
		if not is_set(error_message) then										-- error free dates only
			local modified = false;												-- flag
			
			if is_set (DF) then													-- if we need to reformat dates
				modified = reformat_dates (date_parameters_list, DF, false);	-- reformat to DF format, use long month names if appropriate
			end

			if true == date_hyphen_to_dash (date_parameters_list) then			-- convert hyphens to dashes where appropriate
				modified = true;
				add_maint_cat ('date_format');									-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language,
	-- uncomment these three lines.  Not supported by en.wiki (for obvious reasons)
	-- set date_name_xlate() second argument to true to translate English digits to local digits (will translate ymd dates)
--			if date_name_xlate (date_parameters_list, false) then
--				modified = true;
--			end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				LayDate = date_parameters_list['lay-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end
		else
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end
	end	-- end of do

	-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
	-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
			if is_set(AccessDate) then											-- access date requires |url=; pmc created url is not |url=
				table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
				AccessDate = '';												-- unset
			end

		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
			if 'episode' == config.CitationClass then							-- special case for cite episode; TODO: is there a better way to do this?
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
			else
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
			end
	end
	
	if 'none' == Title and in_array (config.CitationClass, {'journal', 'citation'}) and is_set (Periodical) and 'journal' == A:ORIGIN('Periodical') then	-- special case for journal cites
		Title = '';																-- set title to empty string
		add_maint_cat ('untitled');
	end

	check_for_url ({															-- add error message when any of these parameters contains a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[A:ORIGIN('Periodical')]=Periodical,
		[A:ORIGIN('PublisherName')] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = Periodical,
		['Encyclopedia'] = Encyclopedia,
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, and {{cite citeseerx}} AFTER generation of COinS data.
	if in_array (config.CitationClass, {'arxiv', 'biorxiv', 'citeseerx'}) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, or CiteSeerX now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = substitute (cfg.messages['newsgroup'], external_link( 'news:' .. PublisherName, PublisherName, A:ORIGIN('PublisherName'), nil ));
		end
	end



	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text,											-- get current page name so that we don't wikilink to it via editorlinkn
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_authors_editors (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if is_set (Editors) then
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
					EditorCount = 2;											-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
				else
					EditorCount = 2;											-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
				end
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum = #interviewers_list;							-- number of interviewerss
			Interviewers = list_people(control, interviewers_list, false);	-- et al not currently supported
		end
		do																		-- now do translators
			control.maximum = #t;												-- number of translators
			Translators = list_people(control, t, false);						-- et al not currently supported
		end
		do																		-- now do contributors
			control.maximum = #c;												-- number of contributors
			Contributors = list_people(control, c, false);						-- et al not currently supported
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_authors_editors (A['DisplayAuthors'], #a, 'authors', author_etal);

			last_first_list = list_people(control, a, author_etal);

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false);	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if is_set (Authors) and is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
	-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not is_set(URL) then
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then	-- |url= required for cite web, cite podcast, and cite mailinglist
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURLorigin, OriginalFormat, OriginalAccess;
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (ChapterURL) then 											-- if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURLorigin = ChapterURLorigin;								-- name of chapter-url parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				ChapterURLorigin = A:ORIGIN('ArchiveURL')						-- name of archive-url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived urls
			end
		elseif is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURLorigin = URLorigin;										-- name of url parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived urls
			end
 		end
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			local chap_param;
			if is_set (Chapter) then											-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif is_set (ScriptChapter) then
				chap_param = A:ORIGIN ('ScriptChapter')
			else is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if is_set (chap_param) then											-- if we found one
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {chap_param}, true ) } );		-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if is_set (Contribution) and 0 &lt; #c then								-- if this is a contribution with contributor(s)
			if in_array (Contribution:lower(), cfg.keywords.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, Chapter, TransChapter, ChapterURL, ChapterURLorigin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter.. sepc .. ' ';
		elseif is_set (ChapterFormat) then										-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title.
	if '...' == Title:sub (-3) then												-- if elipsis is the last three characters of |title=
		Title = mw.ustring.gsub (Title, '(%.%.%.)%.+$', '%1');					-- limit the number of dots to three
	elseif not mw.ustring.find (Title, '%.%s*%a%.') then						-- end of title is not a 'dot-(optional space-)letter-dot' initialism
		Title = mw.ustring.gsub(Title, '%'..sepc..'$', '');						-- remove any trailing separator character
	end
	if is_set(TitleLink) and is_set(Title) then
		Title = make_wikilink (TitleLink, Title);
	end

	if in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then
			
			Title = external_link( URL, Title, URLorigin, UrlAccess ) .. TransTitle .. TransError .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		else
			Title = Title .. TransTitle .. TransError;
		end
	else
		Title = TransTitle .. TransError;
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURLorigin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin, nil );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if is_set(Minutes) then
			if is_set (Time) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'minutes') .. ' and ' .. wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
		OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;		-- TODO: presentation

	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

	--[[
	Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
	note is displayed. There are no error messages for this condition.
	
	]]
	if is_set (SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif is_set (RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text

		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {IdAccessLevels=ID_access_levels, DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin, UrlAccess );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then				-- if first and last characters of quote are quote marks
			Quote = Quote:sub(2,-2);											-- strip them off
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- DeadURL is empty, 'yes', 'true', 'y', 'unfit', 'usurped'
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if in_array (DeadURL, {'unfit', 'usurped', 'bot: unknown'}) then
				Archived = sepc .. &quot; &quot; .. 'Archived from the original on ' .. ArchiveDate;	-- format already styled
				if 'bot: unknown' == DeadURL then
					add_maint_cat ('bot:_unknown');								-- and add a category if not already added
				else
					add_maint_cat ('unfit');									-- and add a category if not already added
				end
			else																-- DeadURL is empty, 'yes', 'true', or 'y'
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURLorigin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURLorigin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin, nil );
	end

	local Publisher;
	if is_set(PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if is_set(PublisherName) then
		if is_set(PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif is_set(PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = safe_join ({Others, sepc .. &quot; &quot;}, sepc) end		-- add terminal punctuation &amp; space; check for dup sepc; TODO why do we need to do this here?
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(Periodical) then		-- special cases for book cites
		if is_set (Contributors) then											-- when we are citing foreword, preface, introduction, etc
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Transcript, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if is_set(Date) then
		if is_set (Authors) or is_set (Editors) then							-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;;				-- in paranetheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon,-1,-1) == sepc) then							-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigYear;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigYear;							-- Date begins with sepc
			end
		end
	end	
	if is_set(Authors) then
		if (not is_set (Date)) then												-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then
					in_text = in_text:lower()									-- lowercase for cs2
				 end
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if is_set (Contributors) then											-- book cite and we're citing the intro, preface, etc
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if is_set (Editors) and is_set (Date) then							-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not is_set (Date)) then											-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = config.CitationClass;
		options.class = &quot;citation &quot; .. config.CitationClass;					-- class=citation required for blue highlight when used with |ref=
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then								-- set reference anchor if appropriate
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			if #namelist &gt; 0 then												-- if there are names in namelist
				id = anchor_id (namelist, year);								-- go make the CITEREF anchor
			else
				id = '';														-- unset
			end
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;(.-)&lt;/span&gt;&quot;, &quot;%1&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then	-- remove &lt;span&gt; tags and other html-like markup; then get length of what remains
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	local render = {};															-- here we collect the final bits for concatenation into the rendered citation

	if is_set(options.id) then													-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render, substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text}));	-- when |ref= is set
	else
		table.insert (render, substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text}));	-- all other cases
	end		

	table.insert (render, substitute (cfg.presentation['ocins'], {OCinSoutput}));		-- append metadata to the citation

	if #z.message_tail ~= 0 then
		table.insert (render, ' ');
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					table.insert (render, error_comment( v[1], v[2] ));
				else
					table.insert (render, error_comment( v[1] .. &quot;; &quot;, v[2] ));
				end
			end
		end
	end

	if #z.maintenance_cats ~= 0 then
		table.insert (render, '&lt;span class=&quot;citation-comment&quot; style=&quot;display:none; color:#33aa33; margin-left:0.3em&quot;&gt;');
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			table.insert (render, v);
			table.insert (render, ' (');
			table.insert (render, make_wikilink (':Category:' .. v, 'link'));
			table.insert (render, ') ');
		end
		table.insert (render, '&lt;/span&gt;');
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			table.insert (render, make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			table.insert (render, make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.properties_cats ) do								-- append properties categories
			table.insert (render, make_wikilink ('Category:' .. v));
		end
	end

	return table.concat (render);	
end


--[[--------------------------&lt; C S 1 . C I T A T I O N &gt;------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

function cs1.citation(frame)
	Frame = frame;																-- save a copy incase we need to display an error message in preview mode
	local pframe = frame:getParent()
	local validation, utilities, identifiers, metadata;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	dates = validation.dates;													-- imported functions from Module:Citation/CS1/Date validation
	year_date_check = validation.year_date_check;
	reformat_dates = validation.reformat_dates;
	date_hyphen_to_dash = validation.date_hyphen_to_dash;
	date_name_xlate = validation.date_name_xlate;

	is_set = utilities.is_set;													-- imported functions from Module:Citation/CS1/Utilities
	in_array = utilities.in_array;
	substitute = utilities.substitute;
	error_comment = utilities.error_comment;
	set_error = utilities.set_error;
	select_one = utilities.select_one;
	add_maint_cat = utilities.add_maint_cat;
	wrap_style = utilities.wrap_style;
	safe_for_italics = utilities.safe_for_italics;
	is_wikilink = utilities.is_wikilink;
	make_wikilink = utilities.make_wikilink;

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	extract_ids = identifiers.extract_ids;										-- imported functions from Module:Citation/CS1/Identifiers
	build_id_list = identifiers.build_id_list;
	is_embargoed = identifiers.is_embargoed;
	extract_id_access_levels = identifiers.extract_id_access_levels;
	
	make_coins_title = metadata.make_coins_title;								-- imported functions from Module:Citation/CS1/COinS
	get_coins_pages = metadata.get_coins_pages;
	COinS = metadata.COinS;

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text, error_state;

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do
		config[k] = v;
--		args[k] = v;															-- debug tool that allows us to render a citation from module {{#invoke:}}
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);			-- for enumerated parameters, translate 'local' digits to Western 0-9
			if not validate( k, config.CitationClass ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower(), config.CitationClass ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute( param, capture );				-- add the capture to the suggested parameter (typically the enumerator)
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, param}, true );	-- set the error message
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			missing_pipe_check (v);												-- do we think that there is a parameter that is missing a pipe?
																				-- TODO: is this the best place for this translation?
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then						-- here when v is empty string
			args[k] = v;														-- why do we do this?  we don't support 'empty' parameters
		end		
	end	

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);
		end
	end
	return citation0( config, args)
end

return cs1;</text>
      <sha1>5buuffhlp1g9lk1bcu8ewmra56i6h7l</sha1>
    </revision>
    <revision>
      <id>4720</id>
      <parentid>4719</parentid>
      <timestamp>2018-06-10T22:34:34Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>synch from sandbox;</comment>
      <origin>4720</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="166876" sha1="02mk368stf6s7pbv1r3s6h5lpsymrh8" xml:space="preserve">
local cs1 ={};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local dates, year_date_check, reformat_dates, date_hyphen_to_dash,				-- functions in Module:Citation/CS1/Date_validation
	date_name_xlate

local is_set, in_array, substitute, error_comment, set_error, select_one,		-- functions in Module:Citation/CS1/Utilities
	add_maint_cat, wrap_style, safe_for_italics, is_wikilink, make_wikilink;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local extract_ids, extract_id_access_levels, build_id_list, is_embargoed;		-- functions in Module:Citation/CS1/Identifiers

local make_coins_title, get_coins_pages, COinS;									-- functions in Module:Citation/CS1/COinS

local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

delare variables here that have page-wide scope that are not brought in from other modules; thatare created here
and used here

]]

local added_deprecated_cat;														-- boolean flag so that the category is added only once
local added_prop_cats = {};														-- list of property categories that have been added to z.properties_cats
local added_vanc_errs;															-- boolean flag so we only emit one Vancouver error / category

local Frame;																	-- holds the module's frame table


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

foreign_lang_source and foreign_lang_source_2 keys have a language code appended to them so that multiple languages
may be categorized but multiples of the same language are not categorized.

added_prop_cats is a table declared in page scope variables above

]]

local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		key = key:gsub ('(foreign_lang_source_?2?)%a%a%a?', '%1');				-- strip lang code from keyname
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));		-- make name then add to table
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a boolean declared in page scope variables above

]]

local function add_vanc_error (source)
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {source}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a uri scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of tlds: https://www.iana.org/domains/root/db

rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the tld.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a url with a scheme) will be stripped
here.  Perhaps not necessary but retained incase it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ascii characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the tld) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org and .cash TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and tld or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%a%d]') then										-- first character must be letter or digit
		return false;
	end
																				-- Do most common case first
	if domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.%a%a+$') then				-- three or more character hostname.hostname or hostname.tld
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.xn%-%-[%a%d]+$') then	-- internationalized domain name with ACE prefix
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.cash$') then							-- one character/digit .cash hostname
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.org$') then							-- one character/digit .org hostname
		return true;
	elseif domain:match ('%f[%a][qxz]%.com$') then								-- assigned one character .com hostname (x.com times out 2015-12-10)
		return true;
	elseif domain:match ('%f[%a][iq]%.net$') then								-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.%a%a$') then							-- one character hostname and cctld (2 chars)
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d]%.%a%a+$') then					-- two character hostname and tld
		return true;
	elseif domain:match ('^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?') then		-- IPv4 address
		return true;
	else
		return false;
	end
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a url appear to be a valid url; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if is_set (scheme) then														-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when url is protocol relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a url into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following tld) (if any) and any path(/), query(?) or fragment(#).

If protocol relative url, return nil scheme and domain else return nil for both scheme and domain.

When not protocol relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol relative url
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		authority = authority:gsub ('//', '', 1);								-- replace place 1 pair of '/' with nothing;
		if is_set(authority) then												-- if anything left (1 or 3+ '/' where authority should be) then
			return scheme;														-- return scheme only making domain nil which will cause an error message
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link= etc for properly formatted content: no wikilinks, no urls

Link parameters are to hold the title of a wikipedia article so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki urls and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid url (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid url (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from url; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid url
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wikilinked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

]]

local function link_title_ok (link, lorig, title, torig)
local orig;

	if is_set (link) then 														-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		end
	end

	if is_set (orig) then
		table.insert( z.message_tail, { set_error( 'bad_paramlink', orig)});	-- url or wikilink in |title= with |title-link=;
	end
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the url into scheme and domain
portions, or for protocol relative (//example.com) urls, just the domain.  Use is_url() to validate the two
portions of the url.  If both are valid, or for protocol relative if domain is valid, return true, else false.

Because it is different from a standard url, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper url
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from url;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a url.  The test will also find external wikilinks
that use protocol relative urls. Also finds bare urls.

The frontier pattern prevents a match on interwiki links which are similar to scheme:path urls.  The tests that
find bracketed urls are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol relative ext wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare url with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol relative bare url: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a url
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then												-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source, access)
	local error_str = &quot;&quot;;
	local domain;
	local path;
	local base_url;
	
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the url into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['[']='%5b',[']']='%5d'});					-- replace '[' and ']' with their percent encoded values
		URL=domain..path;														-- and reassemble
	end
	
	if is_set (access) then														-- access level (subscription, registration, limited)
		label = safe_for_url (label);											-- replace square brackets and newlines

		base_url = table.concat (												-- assemble external link with access signal
			{
			'&lt;span class=&quot;plainlinks&quot;&gt;[',										-- opening css and url markup
			URL,																-- the url
			' ',																-- the required space
			label,
			'&lt;span style=&quot;padding-left:0.15em&quot;&gt;',								-- signal spacing css
			cfg.presentation[access],											-- the appropriate icon
			'&lt;/span&gt;',															-- close signal spacing span
			']&lt;/span&gt;'															-- close url markup and plain links span
			});
	else
		base_url = table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url( label ), &quot;]&quot; });	-- no signal markup
	end
	
	return table.concat({ base_url, error_str });
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Replaces unicode quotemarks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc; not for book titles.

]=]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	local wl_type, label, link;

	wl_type, label, link = is_wikilink (str);									-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = substitute (cfg.presentation['kern-wl-both'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = substitute (cfg.presentation['kern-wl-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = substitute (cfg.presentation['kern-wl-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label= mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label= mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap, cap2 = mw.ustring.match (label, &quot;^([\&quot;\'])([^\'].+)&quot;);				-- match leading double or single quote but not doubled single quotes (italic markup)
		if is_set (cap) then
			label = substitute (cfg.presentation['kern-left'], {cap, cap2});
		end
	
		cap, cap2 = mw.ustring.match (label, &quot;^(.+[^\'])([\&quot;\'])$&quot;)				-- match trailing double or single quote but not doubled single quotes (italic markup)
		if is_set (cap) then
			label = substitute (cfg.presentation['kern-right'], {cap, cap2});
		end
		
		if 2 == wl_type then
			str = make_wikilink (link, label);									-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title= and |script-chapter=

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_code_remap[lang] or mw.language.fetchLanguageName( lang, &quot;en&quot; );	-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, cfg.script_lang_codes) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				add_prop_cat ('script')
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return substitute( msg, str );										-- including template text
	else
		return substitute( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (scriptchapter, chapter, transchapter, chapterurl, chapter_url_source, no_quotes, access)
	local chapter_error = '';
	
	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
			chapter = wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, scriptchapter)						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (chapterurl) then
		chapter = external_link (chapterurl, chapter, chapter_url_source, access);		-- adds bare_url_missing_title error if appropriate
	end

	if is_set (transchapter) then
		transchapter = wrap_style ('trans-quoted-title', transchapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. transchapter;
		else																	-- here when transchapter without chapter or script-chapter
			chapter = transchapter;												-- 
			chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
		end
	end

--	if is_set (chapterurl) then
--		chapter = external_link (chapterurl, chapter, chapter_url_source, access);		-- adds bare_url_missing_title error if appropriate
--	end

	return chapter .. chapter_error;
end


--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Detects but ignores the character pattern that results from the transclusion of {{'}} templates.

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i=1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- Test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position and (char == 'zero width joiner') then						-- if we found a zero width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- its ok if one of the indic scripts
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture then 					-- nowiki, math stripmarker (not an error condition)
				stripmarker = true;												-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { set_error( 'invisible_char', {err_msg, wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i=i+1;																	-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate( name, cite_class )
	local name = tostring( name );
	local state;
	
	if in_array (cite_class, {'arxiv', 'biorxiv', 'citeseerx'}) then			-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[ name ];
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end

		if 'arxiv' == cite_class then											-- basic parameters unique to these templates
			state = whitelist.arxiv_basic_arguments[name];
		end
		if 'biorxiv' == cite_class then
			state = whitelist.biorxiv_basic_arguments[name];
		end
		if 'citeseerx' == cite_class then
			state = whitelist.citeseerx_basic_arguments[name];
		end

		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
																				-- limited enumerated parameters list
		name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
		state = whitelist.limited_numbered_arguments[ name ];
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates
		
	state = whitelist.basic_arguments[ name ];									-- all other templates; all normal parameters allowed
											
	if true == state then return true; end										-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);											-- parameter is deprecated but still supported
		return true;
	end
																				-- all enumerated parameters allowed
	name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );												-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
	state = whitelist.numbered_arguments[ name ];

	if true == state then return true; end										-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);											-- parameter is deprecated but still supported
		return true;
	end
	
	return false;																-- not supported because not found or name is set to nil
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash

]]

local function hyphen_to_dash( str )
	if not is_set(str) or str:match( &quot;[%[%]{}&lt;&gt;]&quot; ) ~= nil then
		return str;
	end	
	return str:gsub( '-', '–' );
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'dupicate character'
		if 1 == #duplicate_char then											-- for single byte ascii characters use the string library functions
			f.gsub=string.gsub
			f.match=string.match
			f.sub=string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub=mw.ustring.gsub
			f.match=mw.ustring.match
			f.sub=mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1,1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = f.sub(str, -1,-1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if f.sub(str, -3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5,-1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4,-1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if f.sub(str, -3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3,-1) == duplicate_char .. '&quot;]' then		-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2,-1) == duplicate_char .. &quot;]&quot; then		-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4,-1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2,-1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows html markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;------------------------------------------------------------

returns true is suffix is properly formed Jr, Sr, or ordinal in the range 2–9.  Puncutation not allowed.

]]

local function is_suffix (suffix)
	if in_array (suffix, {'Jr', 'Sr', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written ouside of the code editor and pasted here because the code editor gets confused between character insertion point and cursor position.
The test has been rewritten to use decimal character escape sequence for the individual bytes of the unicode characters so that it is not necessary
to use an external editor to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first)
	local first, suffix = first:match ('(.-),?%s*([%dJS][%drndth]+)%.?$') or first;		-- if first has something that looks like a generational suffix, get it

	if is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error ('suffix');
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error ('non-Latin character');
			return false;														-- not a string of latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just intials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error ('suffix');									-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word


	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i],1,1));				-- insert the intial at end of initials table
		end
		i = i+1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between authors is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between authors is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = make_wikilink (person.link, one);						-- link author/editor if this page is not the author's/editor's page
				end
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end


--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]
local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of author and editor name parameters for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the parameters |display-authors=etal or |display-editors=etal

]]

local function name_has_etal (name, etal, nocat)

	if is_set (name) then														-- name can be nil in which case just return
		local etal_pattern = &quot;[;,]? *[\&quot;']*%f[%a][Ee][Tt] *[Aa][Ll][%.\&quot;']*$&quot;	-- variations on the 'et al' theme
		local others_pattern = &quot;[;,]? *%f[%a]and [Oo]thers&quot;;					-- and alternate to et al.
		
		if name:match (etal_pattern) then										-- variants on et al.
			name = name:gsub (etal_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		elseif name:match (others_pattern) then									-- if not 'et al.', then 'and others'?
			name = name:gsub (others_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		end
	end
	return name, etal;															-- 
end


--[[--------------------------&lt; N A M E _ H A S _ E D _ M A R K U P &gt;------------------------------------------

Evaluates the content of author and editor parameters for extranious editor annotations: ed, ed., eds, (Ed.), etc.
These annotation do not belong in author parameters and are redundant in editor parameters.  If found, the function
adds the editor markup maintenance category.

]]

local function name_has_ed_markup (name, list_name)
	local _, pattern;
	local patterns = {															-- these patterns match annotations at end of name
		'%f[%(%[][%(%[]%s*[Ee][Dd][Ss]?%.?%s*[%)%]]?$',							-- (ed) or (eds): leading '(', case insensitive 'ed', optional 's', '.' and/or ')'
		'[,%.%s]%f[e]eds?%.?$',													-- ed or eds: without '('or ')'; case sensitive (ED could be initials Ed could be name)
		'%f[%(%[][%(%[]%s*[Ee][Dd][Ii][Tt][Oo][Rr][Ss]?%.?%s*[%)%]]?$',			-- (editor) or (editors): leading '(', case insensitive, optional '.' and/or ')'
		'[,%.%s]%f[Ee][Ee][Dd][Ii][Tt][Oo][Rr][Ss]?%.?$',						-- editor or editors: without '('or ')'; case insensitive
		
																				-- these patterns match annotations at beginning of name
		'^eds?[%.,;]',															-- ed. or eds.: lower case only, optional 's', requires '.'
		'^[%(%[]%s*[Ee][Dd][Ss]?%.?%s*[%)%]]',									-- (ed) or (eds): also sqare brackets, case insensitive, optional 's', '.'
		'^[%(%[]?%s*[Ee][Dd][Ii][Tt][Oo][Rr][Ss]?%A',							-- (editor or (editors: also sq brackets, case insensitive, optional brackets, 's'
		'^[%(%[]?%s*[Ee][Dd][Ii][Tt][Ee][Dd]%A',								-- (edited: also sq brackets, case insensitive, optional brackets
		}

	if is_set (name) then
		for _, pattern in ipairs (patterns) do									-- spin through patterns table and
			if name:match (pattern) then
				add_maint_cat ('extra_text_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
				break;
			end
		end
	end
	return name;																-- and done
end


--[[--------------------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;----------------------------------------

Evaluates the content of author and editor (surnames only) parameters for multiple names.  Multiple names are
indicated if there is more than one comma and or semicolon.  If found, the function adds the multiple name
(author or editor) maintenance category.

]]

local function name_has_mult_names (name, list_name)
local count, _;
	if is_set (name) then
		_, count = name:gsub ('[;,]', '');										-- count the number of separator-like characters
		
		if 1 &lt; count then														-- param could be |author= or |editor= so one separator character is acceptable
			add_maint_cat ('mult_names', cfg.special_case_translation [list_name]);	-- more than one separator indicates multiple names so add a maint cat for this template
		end
	end
	return name;																-- and done
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------
This function calls various name checking functions used to validate the content of the various name-holding
parameters.

]]

local function name_checks (last, first, list_name)
	if is_set (last) then
		if last:match ('^%(%(.*%)%)$') then										-- if wrapped in doubled parentheses, accept as written 
			last = last:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			last = name_has_mult_names (last, list_name);						-- check for multiple names in the parameter (last only)
			last = name_has_ed_markup (last, list_name);						-- check for extraneous 'editor' annotation
		end
	end
	if is_set (first) then
		if first:match ('^%(%(.*%)%)$') then									-- if wrapped in doubled parentheses, accept as written 
			first = first:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			first = name_has_ed_markup (first, list_name);						-- check for extraneous 'editor' annotation
		end
	end
	return last, first;															-- done
	end


--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary
	while true do
		last = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false);							-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false);						-- find and remove variations on et al.
		last, first= name_checks (last, first, list_name);						-- multiple names, extraneous annotation, etc checks
		
		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			link_title_ok (link, list_name:match (&quot;(%w+)List&quot;):lower() .. '-link' .. i, last, list_name:match (&quot;(%w+)List&quot;):lower() .. '-last' .. i);	-- check for improper wikimarkup

			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because case of the source may be incorrect
or different from the case that WikiMedia uses, the name comparisons are done in lower case and when a match is
found, the Wikimedia version (assumed to be correct) is returned along with the code.  When there is no match, we
return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') returns a list of languages that in some cases may include
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.  Most (all?) of these languages are not used a 'language' codes per se, rather they
are used as sub-domain names: cbk-zam.wikipedia.org.  These names can be found (for the time being) at
https://phabricator.wikimedia.org/diffusion/ECLD/browse/master/LocalNames/LocalNamesEn.php

Names but that are included in the list will be found if that name is provided in the |language= parameter.  For example,
if |language=Chavacano de Zamboanga, that name will be found with the associated code 'cbk-zam'.  When names are found
and the associated code is not two or three characters, this function returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	if cfg.lang_name_remap[lang:lower()] then									-- if there is a remapped name (because MediaWiki uses something that we don't think is correct)
		return cfg.lang_name_remap[lang:lower()][1], cfg.lang_name_remap[lang:lower()][2];	-- for this language 'name', return a possibly new name and appropriate code
	end

	local languages = mw.language.fetchLanguageNames(this_wiki_code, 'all')		-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() and 3 ~= code:len() then							-- two- or three-character codes only; extensions not supported
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the the code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for the code
end


--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code is recognized by MediaWiki,
use the returned name; if not, then use the value that was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is assigned to the category for
that code: Category:Norwegian-language sources (no).  For valid three-character code languages, the page is assigned
to the single category for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does not recognize three-character
equivalents of two-character codes: code 'ar' is recognized bit code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are
separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki = mw.getContentLanguage();									-- get a language object for this wiki
	local this_wiki_code = this_wiki:getCode()									-- get this wiki's language code
	local this_wiki_name = mw.language.fetchLanguageName(this_wiki_code, this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang

		if lang:match ('^%a%a%-') then											-- strip ietf language tags from code; TODO: is there a need to support 3-char with tag?
			lang = lang:match ('(%a%a)%-')										-- keep only 639-1 code portion to lang; TODO: do something with 3166 alpha 2 country code?
		end
		if 2 == lang:len() or 3 == lang:len() then								-- if two-or three-character code
			name = mw.language.fetchLanguageName( lang:lower(), this_wiki_code);	-- get language name if |language= is a proper code
			if not is_set (name) then
				name = cfg.lang_code_remap[lang];								-- not supported by MediaWiki; is it in remap?
			end
		end
	
		if is_set (name) then													-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, this_wiki_code);				-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then													-- only 2- or 3-character codes
			name = cfg.lang_code_remap[code] or name;							-- override wikimedia when they misuse language codes/names

			if this_wiki_code ~= code then										-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					add_prop_cat ('foreign_lang_source' .. code, {name, code})	-- categorize it
				else															-- or is a recognized language (but has a three-character code)
					add_prop_cat ('foreign_lang_source_2' .. code, {code})		-- categorize it differently TODO: support mutliple three-character code categories per cs1|2 template
				end
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, ' and ')							-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		language_list[code] = 'and ' .. language_list[code];					-- prepend last name with 'and&lt;space&gt;'
		name = table.concat (language_list, ', ')								-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
	end
	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings
At en.wiki, for cs1:
	ps gets:	'.'
	sep gets:	'.'

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = cfg.presentation['ps_cs1'];										-- terminate the rendered citation
	end
	return cfg.presentation['sep_cs1'], ps;										-- element separator
end


--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings
At en.wiki, for cs2:
	ps gets:	'' (empty string - no terminal punctuation)
	sep gets:	','

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = cfg.presentation['ps_cs2'];										-- terminate the rendered citation
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return cfg.presentation['sep_cs2'], ps, ref;								-- element separator
end


--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end


--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end


--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parentheses, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[--------------------------&lt; G E T _ D I S P L A Y _ A U T H O R S _ E D I T O R S &gt;------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_authors_editors (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_auth_ed', cfg.special_case_translation [list_name]);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parnetheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a place holder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parens
			local name = name_table[i];
			i=i+1;																-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parens
					break;														-- and done reassembling so
				end
				i=i+1;															-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = is_wikilink (name_table[i]);					-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i+1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);						-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parentheses to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')								-- remove doubled parntheses
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error ('punctuation');
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
			if is_suffix (first) then											-- if a valid suffix
				suffix = first													-- save it as a suffix and
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end																	-- no suffix error message here because letter combination may be result of Romanization; check for digits?
			last = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error ('missing comma');								-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error ('name');										-- matches a space between two intiials
			end
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error ('initials');									-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first);									-- check first and last before restoring the suffix which may have a non-Latin digit
			if is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '');
			end
		end

		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ) or v_link_table[i];
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice incase we have a |first1= without a |last1=; this ...
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or	-- ... also catches the case where |first= is used with |vauthors=
		select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, no, etc).  When the parameter value has not been assigned a value (missing or empty
in the source template) the function returns true.  If the parameter value is one of the list of allowed values returns
true; else, emits an error message and returns false.

]]

local function is_valid_parameter_value (value, name, possible)
	if not is_set (value) then
		return true;															-- an empty parameter is ok
	elseif in_array(value:lower(), possible) then
		return true;
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list,-3,-1) == sepc .. '. ') then						-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list,-1,-1) == sepc) or (string.sub (name_list,-3,-1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terninate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not is_set (volume) and not is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end

	local vol = '';
		
	if is_set (volume) then
		if (4 &lt; mw.ustring.len(volume)) then
			vol = substitute (cfg.messages['j-vol'], {sepc, volume});
		else
			vol = substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});
		end
	end
	if is_set (issue) then
		return vol .. substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if is_set (page) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif is_set(pages) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then										-- if pages is only digits, assume a single page number
			return '', substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org urls to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot url or to calendar pages.  When the archive url is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the url.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org url does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command url
	|archive-url= is an archive.org url that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org urls:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this funct may return a modified
archive url:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the url unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.or url
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine url
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command url, we don't want to allow saving of the target page 
		err_msg = 'save command';
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = 'liveweb';
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');		-- split out some of the url parts for evaluation
		
		if not is_set(timestamp) or 14 ~= timestamp:len() then					-- path and flag optional, must have 14-digit timestamp here
			err_msg = 'timestamp';
			if '*' ~= flag then
				url=url:gsub ('(//web%.archive%.org/[^%d]*%d?%d?%d?%d?%d?%d?)[^/]*', '%1*', 1)	-- for preview, modify ts to be yearmo* max (0-6 digits plus splat)
			end
		elseif is_set(path) and 'web/' ~= path then								-- older archive urls do not have the extra 'web/' path element
			err_msg = 'path';
		elseif is_set (flag) and not is_set (path) then							-- flag not allowed with the old form url (without the 'web/' path element)
			err_msg = 'flag';
		elseif is_set (flag) and not flag:match ('%a%a_') then					-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = 'flag';
		else
			return url, date;													-- return archiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	table.insert( z.message_tail, { set_error( 'archive_url', {err_msg}, true ) } );	-- add error message and
	if is_set (Frame:preprocess('{{REVISIONID}}')) then
		return '', '';															-- return empty strings for archiveURL and ArchiveDate
	else
		return url, date;														-- preview mode so return archiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe:
	{{cite ... |title=Title access-date=2016-03-17}}

cs1|2 shares some parameter names with xml/html atributes: class=, title=, etc.  To prevent false positives xml/html
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove xml/html tags because attributes: class=, title=, etc 

	capture = value:match ('%s+(%a[%a%d]+)%s*=') or value:match ('^(%a[%a%d]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then								-- if the capture is a valid parameter name
		add_maint_cat ('missing_pipe');
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

-- set default parameter values defined by |mode= parameter.
	local Mode = A['Mode'];
	if not is_valid_parameter_value (Mode, 'mode', cfg.keywords['mode']) then
		Mode = '';
	end

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				add_maint_cat ('authors');										-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
			add_maint_cat ('editors');											-- but add a maint cat because use of this parameter is discouraged
		end
	end

	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=

	local interviewers_list = {};
	local Interviewers = A['Interviewers']
	if is_set (Interviewers) then												-- add a maint cat if the |interviewers= is used
		add_maint_cat ('interviewers');											-- because use of this parameter is discouraged
	else
		interviewers_list = extract_names (args, 'InterviewerList');			-- else, process preferred interviewers parameters
	end

	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list
	local Contribution = A['Contribution'];
	if in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not is_set (Contribution) then									-- |contributor= requires |contribution=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if select_one (args, cfg.aliases['ContributorList-Last'], 'redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { set_error( 'contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if not is_valid_parameter_value (NameListFormat, 'name-list-format', cfg.keywords['name-list-format']) then			-- only accepted value for this parameter is 'vanc'
		NameListFormat = '';													-- anything else, set to empty string
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
			link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wikimarkup in |title-link= or wikimarkup in |title= when |title-link= is set

	local Chapter = A['Chapter'];
	local ScriptChapter = A['ScriptChapter'];
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];

	local ArchiveDate;
	local ArchiveURL;

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	
	local DeadURL = A['DeadURL']
		if not is_valid_parameter_value (DeadURL, 'dead-url', cfg.keywords ['deadurl']) then	-- set in config.defaults to 'yes'
			DeadURL = '';														-- anything else, set to empty string
		end

	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];
	local Periodical_origin = A:ORIGIN('Periodical');							-- get the name of the periodical parameter

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if in_array (config.CitationClass, cfg.templates_using_volume) then
		Volume = A['Volume'];
	end
																				-- conference &amp; map books do not support issue
	if in_array (config.CitationClass, cfg.templates_using_issue) and not (in_array (config.CitationClass, {'conference', 'map'}) and not is_set (Periodical))then
		Issue = A['Issue'];
	end
	local Position = '';
	if not in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash( A['Pages'] );	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
		if not is_valid_parameter_value (RegistrationRequired, 'registration', cfg.keywords ['yes_true_y']) then
			RegistrationRequired=nil;
		end

	local SubscriptionRequired = A['SubscriptionRequired'];
		if not is_valid_parameter_value (SubscriptionRequired, 'subscription', cfg.keywords ['yes_true_y']) then
			SubscriptionRequired=nil;
		end

	local UrlAccess = A['UrlAccess'];
		if not is_valid_parameter_value (UrlAccess, 'url-access', cfg.keywords ['url-access']) then
			UrlAccess = nil;
		end
		if not is_set(URL) and is_set(UrlAccess) then
			UrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {'url'}, true ) } );
		end

		if is_set (UrlAccess) and is_set (SubscriptionRequired) then			-- while not aliases, these are much the same so if both are set
			table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'url-access') .. ' and ' .. wrap_style ('parameter', 'subscription')}, true ) } );		-- add error message
			SubscriptionRequired = nil;											-- unset; prefer |access= over |subscription=
		end
		if is_set (UrlAccess) and is_set (RegistrationRequired) then			-- these are not the same but contradictory so if both are set
			table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'url-access') .. ' and ' .. wrap_style ('parameter', 'registration')}, true ) } );		-- add error message
			RegistrationRequired = nil;											-- unset; prefer |access= over |registration=
		end

	local ChapterUrlAccess = A['ChapterUrlAccess'];
		if not is_valid_parameter_value (ChapterUrlAccess, 'chapter-url-access', cfg.keywords ['url-access']) then	-- same as url-access
			ChapterUrlAccess = nil;
		end
		if not is_set(ChapterURL) and is_set(ChapterUrlAccess) then
			ChapterUrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {'chapter-url'}, true ) } );
		end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local Agency = A['Agency'];

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
		if not is_valid_parameter_value (IgnoreISBN, 'ignore-isbn-error', cfg.keywords ['yes_true_y']) then
			IgnoreISBN = nil;													-- anything else, set to empty string
		end
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );
	local ID_access_levels = extract_id_access_levels( args, ID_list );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
		if not is_valid_parameter_value (LastAuthorAmp, 'last-author-amp', cfg.keywords ['yes_true_y']) then
			LastAuthorAmp = nil;												-- set to empty string
		end

	local no_tracking_cats = A['NoTracking'];
		if not is_valid_parameter_value (no_tracking_cats, 'no-tracking', cfg.keywords ['yes_true_y']) then
			no_tracking_cats = nil;												-- set to empty string
		end

	--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = A['DF'];															-- date format set in cs1|2 template
	if not is_valid_parameter_value (DF, 'df', cfg.keywords['date-format']) then	-- validate reformatting keyword
		DF = '';																-- not valid, set to empty string
	end

	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

	--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

	-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	select_one( args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'redundant_parameters' );		-- this is a dummy call simply to get the error message and category

	local NoPP = A['NoPP'] 
	if is_set (NoPP) and is_valid_parameter_value (NoPP, 'nopp', cfg.keywords ['yes_true_y']) then
		NoPP = true;
	else
		NoPP = nil;																-- unset, used as a flag later
	end

	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Pages = '';															-- unset the others
			At = '';
		end
		extra_text_in_page_check (Page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.
	elseif is_set(Pages) then
		if is_set(At) then
			At = '';															-- unset
		end
		extra_text_in_page_check (Pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.
	end	

	-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia and |title then map |title to |article and |encyclopedia to |title
		|encyclopedia and |article then map |encyclopedia to |title
		|encyclopedia then map |encyclopedia to |title
	
		|trans-title maps to |trans-chapter when |title is re-mapped
		|url maps to |chapterurl when |title is remapped
	
	All other combinations of |encyclopedia, |title, and |article are not modified
	
	]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterUrlAccess = UrlAccess;

					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter = make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			else																-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if is_set(A['Number']) then												-- cite techreport uses 'number', which other citations alias to 'issue'
			if not is_set(ID) then												-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', 'id') .. ' and ' .. wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

	-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	elseif 'mailinglist' == A:ORIGIN('Periodical') then
		Periodical = '';														-- unset because mailing list is only used for cite mailing list
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		ChapterUrlAccess = UrlAccess;
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];

		link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wikimarkup in |series-link= or wikimarkup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) and is_set (AirDate) then							-- promote airdate to date
			Date = AirDate;
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('series', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = make_wikilink (ChapterLink, Chapter);
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = make_wikilink (SeriesLink, Series);
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, before generation of COinS data.
	do
		if in_array (config.CitationClass, {'arxiv', 'biorxiv', 'citeseerx'}) then
			if not is_set (ID_list[config.CitationClass:upper()]) then			-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp; |citeseerx= required for their templates
				table.insert( z.message_tail, { set_error( config.CitationClass .. '_missing', {}, true ) } );		-- add error message
			end
			
			if 'arxiv' == config.CitationClass then
				Periodical = 'arXiv';											-- set to arXiv for COinS; after that, must be set to empty string
			end

			if 'biorxiv' == config.CitationClass then
				Periodical = 'bioRxiv';											-- set to bioRxiv for COinS; after that, must be set to empty string
			end

			if 'citeseerx' == config.CitationClass then
				Periodical = 'CiteSeerX';										-- set to CiteSeerX for COinS; after that, must be set to empty string
			end
		end
	end

	-- handle type parameter for those CS1 citations that have default values
	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;interview&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
		TitleType = substitute( cfg.messages['type'], TitleType);				-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging

	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
--		local date_parameters_list = {['access-date']=AccessDate, ['archive-date']=ArchiveDate, ['date']=Date, ['doi-broken-date']=DoiBroken,
--				['embargo']=Embargo, ['lay-date']=LayDate, ['publication-date']=PublicationDate, ['year']=Year};

		local date_parameters_list = {
			['access-date'] = {val=AccessDate, name=A:ORIGIN ('AccessDate')},
			['archive-date'] = {val=ArchiveDate, name=A:ORIGIN ('ArchiveDate')},
			['date'] = {val=Date, name=Date_origin},
			['doi-broken-date'] = {val=DoiBroken, name=A:ORIGIN ('DoiBroken')},
			['embargo'] = {val=Embargo, name=A:ORIGIN ('Embargo')},
			['lay-date'] = {val=LayDate, name=A:ORIGIN ('LayDate')},
			['publication-date'] ={val=PublicationDate, name=A:ORIGIN ('PublicationDate')},
			['year'] = {val=Year, name=A:ORIGIN ('Year')},
			};
		anchor_year, Embargo, error_message = dates(date_parameters_list, COinS_date);

-- start temporary Julian / Gregorian calendar uncertainty categorization
		if COinS_date.inter_cal_cat then
			add_prop_cat ('jul_greg_uncertainty');
		end
-- end temporary Julian / Gregorian calendar uncertainty categorization

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end
		
		if not is_set(error_message) then										-- error free dates only
			local modified = false;												-- flag
			
			if is_set (DF) then													-- if we need to reformat dates
				modified = reformat_dates (date_parameters_list, DF, false);	-- reformat to DF format, use long month names if appropriate
			end

			if true == date_hyphen_to_dash (date_parameters_list) then			-- convert hyphens to dashes where appropriate
				modified = true;
				add_maint_cat ('date_format');									-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language,
	-- uncomment these three lines.  Not supported by en.wiki (for obvious reasons)
	-- set date_name_xlate() second argument to true to translate English digits to local digits (will translate ymd dates)
--			if date_name_xlate (date_parameters_list, false) then
--				modified = true;
--			end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				LayDate = date_parameters_list['lay-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end
		else
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end
	end	-- end of do

	-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
	-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
			if is_set(AccessDate) then											-- access date requires |url=; pmc created url is not |url=
				table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
				AccessDate = '';												-- unset
			end

		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
			if 'episode' == config.CitationClass then							-- special case for cite episode; TODO: is there a better way to do this?
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
			else
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
			end
	end
	
	if 'none' == Title and in_array (config.CitationClass, {'journal', 'citation'}) and is_set (Periodical) and 'journal' == A:ORIGIN('Periodical') then	-- special case for journal cites
		Title = '';																-- set title to empty string
		add_maint_cat ('untitled');
	end

	check_for_url ({															-- add error message when any of these parameters contains a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[A:ORIGIN('Periodical')]=Periodical,
		[A:ORIGIN('PublisherName')] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = Periodical,
		['Encyclopedia'] = Encyclopedia,
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, and {{cite citeseerx}} AFTER generation of COinS data.
	if in_array (config.CitationClass, {'arxiv', 'biorxiv', 'citeseerx'}) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, or CiteSeerX now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = substitute (cfg.messages['newsgroup'], external_link( 'news:' .. PublisherName, PublisherName, A:ORIGIN('PublisherName'), nil ));
		end
	end



	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text,											-- get current page name so that we don't wikilink to it via editorlinkn
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_authors_editors (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if is_set (Editors) then
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
					EditorCount = 2;											-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
				else
					EditorCount = 2;											-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
				end
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum = #interviewers_list;							-- number of interviewerss
			Interviewers = list_people(control, interviewers_list, false);	-- et al not currently supported
		end
		do																		-- now do translators
			control.maximum = #t;												-- number of translators
			Translators = list_people(control, t, false);						-- et al not currently supported
		end
		do																		-- now do contributors
			control.maximum = #c;												-- number of contributors
			Contributors = list_people(control, c, false);						-- et al not currently supported
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_authors_editors (A['DisplayAuthors'], #a, 'authors', author_etal);

			last_first_list = list_people(control, a, author_etal);

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false);	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if is_set (Authors) and is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
	-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not is_set(URL) then
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then	-- |url= required for cite web, cite podcast, and cite mailinglist
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURLorigin, OriginalFormat, OriginalAccess;
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (ChapterURL) then 											-- if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURLorigin = ChapterURLorigin;								-- name of chapter-url parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				ChapterURLorigin = A:ORIGIN('ArchiveURL')						-- name of archive-url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived urls
			end
		elseif is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURLorigin = URLorigin;										-- name of url parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived urls
			end
 		end
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			local chap_param;
			if is_set (Chapter) then											-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif is_set (ScriptChapter) then
				chap_param = A:ORIGIN ('ScriptChapter')
			else is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if is_set (chap_param) then											-- if we found one
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {chap_param}, true ) } );		-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if is_set (Contribution) and 0 &lt; #c then								-- if this is a contribution with contributor(s)
			if in_array (Contribution:lower(), cfg.keywords.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, Chapter, TransChapter, ChapterURL, ChapterURLorigin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter.. sepc .. ' ';
		elseif is_set (ChapterFormat) then										-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title.
	if '...' == Title:sub (-3) then												-- if elipsis is the last three characters of |title=
		Title = mw.ustring.gsub (Title, '(%.%.%.)%.+$', '%1');					-- limit the number of dots to three
	elseif not mw.ustring.find (Title, '%.%s*%a%.') then						-- end of title is not a 'dot-(optional space-)letter-dot' initialism
		Title = mw.ustring.gsub(Title, '%'..sepc..'$', '');						-- remove any trailing separator character
	end
	if is_set(TitleLink) and is_set(Title) then
		Title = make_wikilink (TitleLink, Title);
	end

	if in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then
			
			Title = external_link( URL, Title, URLorigin, UrlAccess ) .. TransTitle .. TransError .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		else
			Title = Title .. TransTitle .. TransError;
		end
	else
		Title = TransTitle .. TransError;
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURLorigin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin, nil );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if is_set(Minutes) then
			if is_set (Time) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'minutes') .. ' and ' .. wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
		OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;		-- TODO: presentation

	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

	--[[
	Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
	note is displayed. There are no error messages for this condition.
	
	]]
	if is_set (SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif is_set (RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text

		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {IdAccessLevels=ID_access_levels, DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin, UrlAccess );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then				-- if first and last characters of quote are quote marks
			Quote = Quote:sub(2,-2);											-- strip them off
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- DeadURL is empty, 'yes', 'true', 'y', 'unfit', 'usurped'
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if in_array (DeadURL, {'unfit', 'usurped', 'bot: unknown'}) then
				Archived = sepc .. &quot; &quot; .. 'Archived from the original on ' .. ArchiveDate;	-- format already styled
				if 'bot: unknown' == DeadURL then
					add_maint_cat ('bot:_unknown');								-- and add a category if not already added
				else
					add_maint_cat ('unfit');									-- and add a category if not already added
				end
			else																-- DeadURL is empty, 'yes', 'true', or 'y'
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURLorigin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURLorigin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin, nil );
	end

	local Publisher;
	if is_set(PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if is_set(PublisherName) then
		if is_set(PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif is_set(PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = safe_join ({Others, sepc .. &quot; &quot;}, sepc) end		-- add terminal punctuation &amp; space; check for dup sepc; TODO why do we need to do this here?
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(Periodical) then		-- special cases for book cites
		if is_set (Contributors) then											-- when we are citing foreword, preface, introduction, etc
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Transcript, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if is_set(Date) then
		if is_set (Authors) or is_set (Editors) then							-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;;				-- in paranetheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon,-1,-1) == sepc) then							-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigYear;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigYear;							-- Date begins with sepc
			end
		end
	end	
	if is_set(Authors) then
		if (not is_set (Date)) then												-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then
					in_text = in_text:lower()									-- lowercase for cs2
				 end
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if is_set (Contributors) then											-- book cite and we're citing the intro, preface, etc
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if is_set (Editors) and is_set (Date) then							-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not is_set (Date)) then											-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = config.CitationClass;
		options.class = &quot;citation &quot; .. config.CitationClass;					-- class=citation required for blue highlight when used with |ref=
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then								-- set reference anchor if appropriate
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			if #namelist &gt; 0 then												-- if there are names in namelist
				id = anchor_id (namelist, year);								-- go make the CITEREF anchor
			else
				id = '';														-- unset
			end
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;(.-)&lt;/span&gt;&quot;, &quot;%1&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then	-- remove &lt;span&gt; tags and other html-like markup; then get length of what remains
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	local render = {};															-- here we collect the final bits for concatenation into the rendered citation

	if is_set(options.id) then													-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render, substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text}));	-- when |ref= is set
	else
		table.insert (render, substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text}));	-- all other cases
	end		

	table.insert (render, substitute (cfg.presentation['ocins'], {OCinSoutput}));		-- append metadata to the citation

	if #z.message_tail ~= 0 then
		table.insert (render, ' ');
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					table.insert (render, error_comment( v[1], v[2] ));
				else
					table.insert (render, error_comment( v[1] .. &quot;; &quot;, v[2] ));
				end
			end
		end
	end

	if #z.maintenance_cats ~= 0 then
		table.insert (render, '&lt;span class=&quot;citation-comment&quot; style=&quot;display:none; color:#33aa33; margin-left:0.3em&quot;&gt;');
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			table.insert (render, v);
			table.insert (render, ' (');
			table.insert (render, make_wikilink (':Category:' .. v, 'link'));
			table.insert (render, ') ');
		end
		table.insert (render, '&lt;/span&gt;');
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			table.insert (render, make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			table.insert (render, make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.properties_cats ) do								-- append properties categories
			table.insert (render, make_wikilink ('Category:' .. v));
		end
	end

	return table.concat (render);	
end


--[[--------------------------&lt; C S 1 . C I T A T I O N &gt;------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

function cs1.citation(frame)
	Frame = frame;																-- save a copy incase we need to display an error message in preview mode
	local pframe = frame:getParent()
	local validation, utilities, identifiers, metadata;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	dates = validation.dates;													-- imported functions from Module:Citation/CS1/Date validation
	year_date_check = validation.year_date_check;
	reformat_dates = validation.reformat_dates;
	date_hyphen_to_dash = validation.date_hyphen_to_dash;
	date_name_xlate = validation.date_name_xlate;

	is_set = utilities.is_set;													-- imported functions from Module:Citation/CS1/Utilities
	in_array = utilities.in_array;
	substitute = utilities.substitute;
	error_comment = utilities.error_comment;
	set_error = utilities.set_error;
	select_one = utilities.select_one;
	add_maint_cat = utilities.add_maint_cat;
	wrap_style = utilities.wrap_style;
	safe_for_italics = utilities.safe_for_italics;
	is_wikilink = utilities.is_wikilink;
	make_wikilink = utilities.make_wikilink;

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	extract_ids = identifiers.extract_ids;										-- imported functions from Module:Citation/CS1/Identifiers
	build_id_list = identifiers.build_id_list;
	is_embargoed = identifiers.is_embargoed;
	extract_id_access_levels = identifiers.extract_id_access_levels;
	
	make_coins_title = metadata.make_coins_title;								-- imported functions from Module:Citation/CS1/COinS
	get_coins_pages = metadata.get_coins_pages;
	COinS = metadata.COinS;

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text, error_state;

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do
		config[k] = v;
--		args[k] = v;															-- debug tool that allows us to render a citation from module {{#invoke:}}
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);			-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower(), config.CitationClass ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute( param, capture );				-- add the capture to the suggested parameter (typically the enumerator)
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, param}, true );	-- set the error message
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			missing_pipe_check (v);												-- do we think that there is a parameter that is missing a pipe?
																				-- TODO: is this the best place for this translation?
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then						-- here when v is empty string
			args[k] = v;														-- why do we do this?  we don't support 'empty' parameters
		end		
	end	

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);
		end
	end
	return citation0( config, args)
end

return cs1;</text>
      <sha1>02mk368stf6s7pbv1r3s6h5lpsymrh8</sha1>
    </revision>
    <revision>
      <id>4721</id>
      <parentid>4720</parentid>
      <timestamp>2018-09-29T13:26:31Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>synch from sandbox;</comment>
      <origin>4721</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="169709" sha1="lmfkibi5fsoufxp0atzohk1dd467vmu" xml:space="preserve">
local cs1 ={};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local dates, year_date_check, reformat_dates, date_hyphen_to_dash,				-- functions in Module:Citation/CS1/Date_validation
	date_name_xlate

local is_set, in_array, substitute, error_comment, set_error, select_one,		-- functions in Module:Citation/CS1/Utilities
	add_maint_cat, wrap_style, safe_for_italics, is_wikilink, make_wikilink;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local extract_ids, extract_id_access_levels, build_id_list, is_embargoed;		-- functions in Module:Citation/CS1/Identifiers

local make_coins_title, get_coins_pages, COinS;									-- functions in Module:Citation/CS1/COinS

local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

delare variables here that have page-wide scope that are not brought in from other modules; thatare created here
and used here

]]

local added_deprecated_cat;														-- boolean flag so that the category is added only once
local added_prop_cats = {};														-- list of property categories that have been added to z.properties_cats
local added_vanc_errs;															-- boolean flag so we only emit one Vancouver error / category

local Frame;																	-- holds the module's frame table


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

foreign_lang_source and foreign_lang_source_2 keys have a language code appended to them so that multiple languages
may be categorized but multiples of the same language are not categorized.

added_prop_cats is a table declared in page scope variables above

]]

local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		key = key:gsub ('(foreign_lang_source_?2?)%a%a%a?', '%1');				-- strip lang code from keyname
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));		-- make name then add to table
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a boolean declared in page scope variables above

]]

local function add_vanc_error (source)
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {source}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a uri scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of tlds: https://www.iana.org/domains/root/db

rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the tld.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a url with a scheme) will be stripped
here.  Perhaps not necessary but retained incase it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ascii characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the tld) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org and .cash TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and tld or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%a%d]') then										-- first character must be letter or digit
		return false;
	end
																				-- Do most common case first
	if domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.%a%a+$') then				-- three or more character hostname.hostname or hostname.tld
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.xn%-%-[%a%d]+$') then	-- internationalized domain name with ACE prefix
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.cash$') then							-- one character/digit .cash hostname
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.org$') then							-- one character/digit .org hostname
		return true;
	elseif domain:match ('%f[%a][qxz]%.com$') then								-- assigned one character .com hostname (x.com times out 2015-12-10)
		return true;
	elseif domain:match ('%f[%a][iq]%.net$') then								-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.%a%a$') then							-- one character hostname and cctld (2 chars)
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d]%.%a%a+$') then					-- two character hostname and tld
		return true;
	elseif domain:match ('^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?') then		-- IPv4 address
		return true;
	else
		return false;
	end
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a url appear to be a valid url; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if is_set (scheme) then														-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when url is protocol relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a url into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following tld) (if any) and any path(/), query(?) or fragment(#).

If protocol relative url, return nil scheme and domain else return nil for both scheme and domain.

When not protocol relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol relative url
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		authority = authority:gsub ('//', '', 1);								-- replace place 1 pair of '/' with nothing;
		if is_set(authority) then												-- if anything left (1 or 3+ '/' where authority should be) then
			return scheme;														-- return scheme only making domain nil which will cause an error message
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link= etc for properly formatted content: no wikilinks, no urls

Link parameters are to hold the title of a wikipedia article so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki urls and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid url (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid url (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from url; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid url
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wikilinked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

]]

local function link_title_ok (link, lorig, title, torig)
local orig;

	if is_set (link) then 														-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		end
	end

	if is_set (orig) then
		table.insert( z.message_tail, { set_error( 'bad_paramlink', orig)});	-- url or wikilink in |title= with |title-link=;
	end
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the url into scheme and domain
portions, or for protocol relative (//example.com) urls, just the domain.  Use is_url() to validate the two
portions of the url.  If both are valid, or for protocol relative if domain is valid, return true, else false.

Because it is different from a standard url, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper url
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from url;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a url.  The test will also find external wikilinks
that use protocol relative urls. Also finds bare urls.

The frontier pattern prevents a match on interwiki links which are similar to scheme:path urls.  The tests that
find bracketed urls are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol relative ext wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare url with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol relative bare url: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a url
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then												-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source, access)
	local error_str = &quot;&quot;;
	local domain;
	local path;
	local base_url;
	
	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the url into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['[']='%5b',[']']='%5d'});					-- replace '[' and ']' with their percent encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wikimarkup url
	
	if is_set (access) then														-- access level (subscription, registration, limited)
		base_url = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end
	
	return table.concat ({base_url, error_str});
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Replaces unicode quotemarks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc; not for book titles.

]=]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	local wl_type, label, link;

	wl_type, label, link = is_wikilink (str);									-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = substitute (cfg.presentation['kern-wl-both'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = substitute (cfg.presentation['kern-wl-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = substitute (cfg.presentation['kern-wl-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label= mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label= mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap, cap2 = mw.ustring.match (label, &quot;^([\&quot;\'])([^\'].+)&quot;);				-- match leading double or single quote but not doubled single quotes (italic markup)
		if is_set (cap) then
			label = substitute (cfg.presentation['kern-left'], {cap, cap2});
		end
	
		cap, cap2 = mw.ustring.match (label, &quot;^(.+[^\'])([\&quot;\'])$&quot;)				-- match trailing double or single quote but not doubled single quotes (italic markup)
		if is_set (cap) then
			label = substitute (cfg.presentation['kern-right'], {cap, cap2});
		end
		
		if 2 == wl_type then
			str = make_wikilink (link, label);									-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title= and |script-chapter=

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_code_remap[lang] or mw.language.fetchLanguageName( lang, &quot;en&quot; );	-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, cfg.script_lang_codes) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				add_prop_cat ('script')
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return substitute( msg, str );										-- including template text
	else
		return substitute( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (scriptchapter, chapter, transchapter, chapterurl, chapter_url_source, no_quotes, access)
	local chapter_error = '';
	
	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
			chapter = wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, scriptchapter)						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (chapterurl) then
		chapter = external_link (chapterurl, chapter, chapter_url_source, access);		-- adds bare_url_missing_title error if appropriate
	end

	if is_set (transchapter) then
		transchapter = wrap_style ('trans-quoted-title', transchapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. transchapter;
		else																	-- here when transchapter without chapter or script-chapter
			chapter = transchapter;												-- 
			chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
		end
	end

--	if is_set (chapterurl) then
--		chapter = external_link (chapterurl, chapter, chapter_url_source, access);		-- adds bare_url_missing_title error if appropriate
--	end

	return chapter .. chapter_error;
end


--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Detects but ignores the character pattern that results from the transclusion of {{'}} templates.

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i=1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- Test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position and (char == 'zero width joiner') then						-- if we found a zero width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- its ok if one of the indic scripts
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { set_error( 'invisible_char', {err_msg, wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i=i+1;																	-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash under certain conditions.  The hyphen must separate like items; unlike items are
returned unmodified.  These forms are modified:
	letter - letter (A - B)
	digit - digit (4-5)
	digit separator digit - digit separator digit (4.1-4.5 or 4-1-4-5)
	letterdigit - letterdigit (A1-A5) (an optional separator between letter and digit is supported – a.1-a.5 or a-1-a-5)
	digitletter - digitletter (5a - 5d) (an optional separator between letter and digit is supported – 5.a-5.d or 5-a-5-d)

any other forms are returned unmodified.

str may be a comma- or semicolon-separated list

]]

local function hyphen_to_dash( str )
	if not is_set (str) then
		return str;
	end
	
	str, count = str:gsub ('^%(%((.+)%)%)$', '%1');								-- remove accept-this-as-written markup when it wraps all of str
	if 0 ~= count then															-- non-zero when markup removed; zero else
		return str;																-- nothing to do, we're done
	end
	
	local out = {};
	local list = mw.text.split (str, '%s*[,;]%s*');								-- split str at comma or semicolon separators if there are any

	for _, item in ipairs (list) do												-- for each item in the list
		if mw.ustring.match (item, '^%w*[%.%-]?%w+%s*[%-–—]%s*%w*[%.%-]?%w+$') then	-- if a hyphenated range or has endash or emdash separators
			if item:match ('%a+[%.%-]?%d+%s*%-%s*%a+[%.%-]?%d+') or				-- letterdigit hyphen letterdigit (optional separator between letter and digit)
				item:match ('%d+[%.%-]?%a+%s*%-%s*%d+[%.%-]?%a+') or			-- digitletter hyphen digitletter (optional separator between digit and letter)
				item:match ('%d+[%.%-]%d+%s*%-%s*%d+[%.%-]%d+') or				-- digit separator digit hyphen digit separator digit
				item:match ('%d+%s*%-%s*%d+') or								-- digit hyphen digit
				item:match ('%a+%s*%-%s*%a+') then								-- letter hyphen letter
					item = item:gsub ('(%w*[%.%-]?%w+)%s*%-%s*(%w*[%.%-]?%w+)', '%1–%2');	-- replace hyphen, remove extraneous space characters
			else
				item = mw.ustring.gsub (item, '%s*[–—]%s*', '–');				-- for endash or emdash separated ranges, replace em with en, remove extraneous white space
			end
		end
		item = item:gsub ('^%(%((.+)%)%)$', '%1');								-- remove the accept-this-as-written markup
		table.insert (out, item);												-- add the (possibly modified) item to the output table
	end

	return table.concat (out, ', ');											-- concatenate the output table into a comma separated string
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'dupicate character'
		if 1 == #duplicate_char then											-- for single byte ascii characters use the string library functions
			f.gsub=string.gsub
			f.match=string.match
			f.sub=string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub=mw.ustring.gsub
			f.match=mw.ustring.match
			f.sub=mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1,1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = f.sub(str, -1,-1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if f.sub(str, -3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5,-1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4,-1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if f.sub(str, -3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3,-1) == duplicate_char .. '&quot;]' then		-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2,-1) == duplicate_char .. &quot;]&quot; then		-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4,-1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2,-1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows html markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;------------------------------------------------------------

returns true is suffix is properly formed Jr, Sr, or ordinal in the range 2–9.  Puncutation not allowed.

]]

local function is_suffix (suffix)
	if in_array (suffix, {'Jr', 'Sr', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written ouside of the code editor and pasted here because the code editor gets confused between character insertion point and cursor position.
The test has been rewritten to use decimal character escape sequence for the individual bytes of the unicode characters so that it is not necessary
to use an external editor to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first)
	local first, suffix = first:match ('(.-),?%s*([%dJS][%drndth]+)%.?$') or first;		-- if first has something that looks like a generational suffix, get it

	if is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error ('suffix');
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error ('non-Latin character');
			return false;														-- not a string of latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just intials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error ('suffix');									-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word


	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i],1,1));				-- insert the intial at end of initials table
		end
		i = i+1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between authors is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between authors is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = make_wikilink (person.link, one);						-- link author/editor if this page is not the author's/editor's page
				end
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end


--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]
local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of author and editor name parameters for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the parameters |display-authors=etal or |display-editors=etal

]]

local function name_has_etal (name, etal, nocat)

	if is_set (name) then														-- name can be nil in which case just return
		local etal_pattern = &quot;[;,]? *[\&quot;']*%f[%a][Ee][Tt] *[Aa][Ll][%.\&quot;']*$&quot;	-- variations on the 'et al' theme
		local others_pattern = &quot;[;,]? *%f[%a]and [Oo]thers&quot;;					-- and alternate to et al.
		
		if name:match (etal_pattern) then										-- variants on et al.
			name = name:gsub (etal_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		elseif name:match (others_pattern) then									-- if not 'et al.', then 'and others'?
			name = name:gsub (others_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		end
	end
	return name, etal;															-- 
end


--[[--------------------------&lt; N A M E _ H A S _ E D _ M A R K U P &gt;------------------------------------------

Evaluates the content of author and editor parameters for extranious editor annotations: ed, ed., eds, (Ed.), etc.
These annotation do not belong in author parameters and are redundant in editor parameters.  If found, the function
adds the editor markup maintenance category.

]]

local function name_has_ed_markup (name, list_name)
	local _, pattern;
	local patterns = {															-- these patterns match annotations at end of name
		'%f[%(%[][%(%[]%s*[Ee][Dd][Ss]?%.?%s*[%)%]]?$',							-- (ed) or (eds): leading '(', case insensitive 'ed', optional 's', '.' and/or ')'
		'[,%.%s]%f[e]eds?%.?$',													-- ed or eds: without '('or ')'; case sensitive (ED could be initials Ed could be name)
		'%f[%(%[][%(%[]%s*[Ee][Dd][Ii][Tt][Oo][Rr][Ss]?%.?%s*[%)%]]?$',			-- (editor) or (editors): leading '(', case insensitive, optional '.' and/or ')'
		'[,%.%s]%f[Ee][Ee][Dd][Ii][Tt][Oo][Rr][Ss]?%.?$',						-- editor or editors: without '('or ')'; case insensitive
		
																				-- these patterns match annotations at beginning of name
		'^eds?[%.,;]',															-- ed. or eds.: lower case only, optional 's', requires '.'
		'^[%(%[]%s*[Ee][Dd][Ss]?%.?%s*[%)%]]',									-- (ed) or (eds): also sqare brackets, case insensitive, optional 's', '.'
		'^[%(%[]?%s*[Ee][Dd][Ii][Tt][Oo][Rr][Ss]?%A',							-- (editor or (editors: also sq brackets, case insensitive, optional brackets, 's'
		'^[%(%[]?%s*[Ee][Dd][Ii][Tt][Ee][Dd]%A',								-- (edited: also sq brackets, case insensitive, optional brackets
		}

	if is_set (name) then
		for _, pattern in ipairs (patterns) do									-- spin through patterns table and
			if name:match (pattern) then
				add_maint_cat ('extra_text_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
				break;
			end
		end
	end
	return name;																-- and done
end


--[[--------------------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;----------------------------------------

Evaluates the content of author and editor (surnames only) parameters for multiple names.  Multiple names are
indicated if there is more than one comma and or semicolon.  If found, the function adds the multiple name
(author or editor) maintenance category.

]]

local function name_has_mult_names (name, list_name)
local count, _;
	if is_set (name) then
		_, count = name:gsub ('[;,]', '');										-- count the number of separator-like characters
		
		if 1 &lt; count then														-- param could be |author= or |editor= so one separator character is acceptable
			add_maint_cat ('mult_names', cfg.special_case_translation [list_name]);	-- more than one separator indicates multiple names so add a maint cat for this template
		end
	end
	return name;																-- and done
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------
This function calls various name checking functions used to validate the content of the various name-holding
parameters.

]]

local function name_checks (last, first, list_name)
	if is_set (last) then
		if last:match ('^%(%(.*%)%)$') then										-- if wrapped in doubled parentheses, accept as written 
			last = last:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			last = name_has_mult_names (last, list_name);						-- check for multiple names in the parameter (last only)
			last = name_has_ed_markup (last, list_name);						-- check for extraneous 'editor' annotation
		end
	end
	if is_set (first) then
		if first:match ('^%(%(.*%)%)$') then									-- if wrapped in doubled parentheses, accept as written 
			first = first:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			first = name_has_ed_markup (first, list_name);						-- check for extraneous 'editor' annotation
		end
	end
	return last, first;															-- done
	end


--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary
	while true do
		last = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false);							-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false);						-- find and remove variations on et al.
		last, first= name_checks (last, first, list_name);						-- multiple names, extraneous annotation, etc checks
		
		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			link_title_ok (link, list_name:match (&quot;(%w+)List&quot;):lower() .. '-link' .. i, last, list_name:match (&quot;(%w+)List&quot;):lower() .. '-last' .. i);	-- check for improper wikimarkup

			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because case of the source may be incorrect
or different from the case that WikiMedia uses, the name comparisons are done in lower case and when a match is
found, the Wikimedia version (assumed to be correct) is returned along with the code.  When there is no match, we
return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') returns a list of languages that in some cases may include
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.  Most (all?) of these languages are not used a 'language' codes per se, rather they
are used as sub-domain names: cbk-zam.wikipedia.org.  These names can be found (for the time being) at
https://phabricator.wikimedia.org/diffusion/ECLD/browse/master/LocalNames/LocalNamesEn.php

Names but that are included in the list will be found if that name is provided in the |language= parameter.  For example,
if |language=Chavacano de Zamboanga, that name will be found with the associated code 'cbk-zam'.  When names are found
and the associated code is not two or three characters, this function returns only the Wikimedia language name.

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	if cfg.lang_name_remap[lang:lower()] then									-- if there is a remapped name (because MediaWiki uses something that we don't think is correct)
		return cfg.lang_name_remap[lang:lower()][1], cfg.lang_name_remap[lang:lower()][2];	-- for this language 'name', return a possibly new name and appropriate code
	end

	local languages = mw.language.fetchLanguageNames(this_wiki_code, 'all')		-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons
	
	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 ~= code:len() and 3 ~= code:len() then							-- two- or three-character codes only; extensions not supported
				return name;													-- so return the name but not the code
			end
			return name, code;													-- found it, return name to ensure proper capitalization and the the code
		end
	end
	return lang;																-- not valid language; return language in original case and nil for the code
end


--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code is recognized by MediaWiki,
use the returned name; if not, then use the value that was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is assigned to the category for
that code: Category:Norwegian-language sources (no).  For valid three-character code languages, the page is assigned
to the single category for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does not recognize three-character
equivalents of two-character codes: code 'ar' is recognized bit code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are
separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki = mw.getContentLanguage();									-- get a language object for this wiki
	local this_wiki_code = this_wiki:getCode()									-- get this wiki's language code
	local this_wiki_name = mw.language.fetchLanguageName(this_wiki_code, this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang

		if lang:match ('^%a%a%-') then											-- strip ietf language tags from code; TODO: is there a need to support 3-char with tag?
			lang = lang:match ('(%a%a)%-')										-- keep only 639-1 code portion to lang; TODO: do something with 3166 alpha 2 country code?
		end
		if 2 == lang:len() or 3 == lang:len() then								-- if two-or three-character code
			name = mw.language.fetchLanguageName( lang:lower(), this_wiki_code);	-- get language name if |language= is a proper code
			if not is_set (name) then
				name = cfg.lang_code_remap[lang];								-- not supported by MediaWiki; is it in remap?
			end
		end
	
		if is_set (name) then													-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, this_wiki_code);				-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then													-- only 2- or 3-character codes
			name = cfg.lang_code_remap[code] or name;							-- override wikimedia when they misuse language codes/names

			if this_wiki_code ~= code then										-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					add_prop_cat ('foreign_lang_source' .. code, {name, code})	-- categorize it
				else															-- or is a recognized language (but has a three-character code)
					add_prop_cat ('foreign_lang_source_2' .. code, {code})		-- categorize it differently TODO: support mutliple three-character code categories per cs1|2 template
				end
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, ' and ')							-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		language_list[code] = 'and ' .. language_list[code];					-- prepend last name with 'and&lt;space&gt;'
		name = table.concat (language_list, ', ')								-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
	end
	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings
At en.wiki, for cs1:
	ps gets:	'.'
	sep gets:	'.'

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = cfg.presentation['ps_cs1'];										-- terminate the rendered citation
	end
	return cfg.presentation['sep_cs1'], ps;										-- element separator
end


--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings
At en.wiki, for cs2:
	ps gets:	'' (empty string - no terminal punctuation)
	sep gets:	','

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = cfg.presentation['ps_cs2'];										-- terminate the rendered citation
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return cfg.presentation['sep_cs2'], ps, ref;								-- element separator
end


--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end


--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end


--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parentheses, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[--------------------------&lt; G E T _ D I S P L A Y _ A U T H O R S _ E D I T O R S &gt;------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_authors_editors (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_auth_ed', cfg.special_case_translation [list_name]);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parnetheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a place holder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parens
			local name = name_table[i];
			i=i+1;																-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parens
					break;														-- and done reassembling so
				end
				i=i+1;															-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = is_wikilink (name_table[i]);					-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i+1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);						-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parentheses to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')								-- remove doubled parntheses
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error ('punctuation');
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
			if is_suffix (first) then											-- if a valid suffix
				suffix = first													-- save it as a suffix and
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end																	-- no suffix error message here because letter combination may be result of Romanization; check for digits?
			last = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error ('missing comma');								-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error ('name');										-- matches a space between two intiials
			end
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error ('initials');									-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first);									-- check first and last before restoring the suffix which may have a non-Latin digit
			if is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '');
			end
		end

		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ) or v_link_table[i];
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice incase we have a |first1= without a |last1=; this ...
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or	-- ... also catches the case where |first= is used with |vauthors=
		select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, no, etc).  When the parameter value has not been assigned a value (missing or empty
in the source template) the function returns true.  If the parameter value is one of the list of allowed values returns
true; else, emits an error message and returns false.

]]

local function is_valid_parameter_value (value, name, possible)
	if not is_set (value) then
		return true;															-- an empty parameter is ok
	elseif in_array(value:lower(), possible) then
		return true;
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list,-3,-1) == sepc .. '. ') then						-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list,-1,-1) == sepc) or (string.sub (name_list,-3,-1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terninate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not is_set (volume) and not is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end

	local vol = '';
		
	if is_set (volume) then
		if (4 &lt; mw.ustring.len(volume)) then
			vol = substitute (cfg.messages['j-vol'], {sepc, volume});
		else
			vol = substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});
		end
	end
	if is_set (issue) then
		return vol .. substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if is_set (page) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif is_set(pages) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then										-- if pages is only digits, assume a single page number
			return '', substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org urls to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot url or to calendar pages.  When the archive url is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the url.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org url does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command url
	|archive-url= is an archive.org url that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org urls:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this funct may return a modified
archive url:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the url unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.or url
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine url
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command url, we don't want to allow saving of the target page 
		err_msg = 'save command';
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = 'liveweb';
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');		-- split out some of the url parts for evaluation
		
		if not is_set(timestamp) or 14 ~= timestamp:len() then					-- path and flag optional, must have 14-digit timestamp here
			err_msg = 'timestamp';
			if '*' ~= flag then
				url=url:gsub ('(//web%.archive%.org/[^%d]*%d?%d?%d?%d?%d?%d?)[^/]*', '%1*', 1)	-- for preview, modify ts to be yearmo* max (0-6 digits plus splat)
			end
		elseif is_set(path) and 'web/' ~= path then								-- older archive urls do not have the extra 'web/' path element
			err_msg = 'path';
		elseif is_set (flag) and not is_set (path) then							-- flag not allowed with the old form url (without the 'web/' path element)
			err_msg = 'flag';
		elseif is_set (flag) and not flag:match ('%a%a_') then					-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = 'flag';
		else
			return url, date;													-- return archiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	table.insert( z.message_tail, { set_error( 'archive_url', {err_msg}, true ) } );	-- add error message and
	if is_set (Frame:preprocess('{{REVISIONID}}')) then
		return '', '';															-- return empty strings for archiveURL and ArchiveDate
	else
		return url, date;														-- preview mode so return archiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

-- set default parameter values defined by |mode= parameter.
	local Mode = A['Mode'];
	if not is_valid_parameter_value (Mode, 'mode', cfg.keywords['mode']) then
		Mode = '';
	end

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				add_maint_cat ('authors');										-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
			add_maint_cat ('editors');											-- but add a maint cat because use of this parameter is discouraged
		end
	end

	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=

	local interviewers_list = {};
	local Interviewers = A['Interviewers']
	if is_set (Interviewers) then												-- add a maint cat if the |interviewers= is used
		add_maint_cat ('interviewers');											-- because use of this parameter is discouraged
	else
		interviewers_list = extract_names (args, 'InterviewerList');			-- else, process preferred interviewers parameters
	end

	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list
	local Contribution = A['Contribution'];
	if in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not is_set (Contribution) then									-- |contributor= requires |contribution=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if select_one (args, cfg.aliases['ContributorList-Last'], 'redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { set_error( 'contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if not is_valid_parameter_value (NameListFormat, 'name-list-format', cfg.keywords['name-list-format']) then			-- only accepted value for this parameter is 'vanc'
		NameListFormat = '';													-- anything else, set to empty string
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
			link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wikimarkup in |title-link= or wikimarkup in |title= when |title-link= is set

	local Chapter = A['Chapter'];
	local ScriptChapter = A['ScriptChapter'];
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];

	local ArchiveDate;
	local ArchiveURL;

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	
	local DeadURL = A['DeadURL']
		if not is_valid_parameter_value (DeadURL, 'dead-url', cfg.keywords ['deadurl']) then	-- set in config.defaults to 'yes'
			DeadURL = '';														-- anything else, set to empty string
		end

	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];
	local Periodical_origin = A:ORIGIN('Periodical');							-- get the name of the periodical parameter

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if in_array (config.CitationClass, cfg.templates_using_volume) then
		Volume = A['Volume'];
	end
																				-- conference &amp; map books do not support issue
	if in_array (config.CitationClass, cfg.templates_using_issue) and not (in_array (config.CitationClass, {'conference', 'map'}) and not is_set (Periodical))then
		Issue = hyphen_to_dash (A['Issue']);
	end
	local Position = '';
	if not in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash (A['Pages']);	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
		if not is_valid_parameter_value (RegistrationRequired, 'registration', cfg.keywords ['yes_true_y']) then
			RegistrationRequired=nil;
		end

	local SubscriptionRequired = A['SubscriptionRequired'];
		if not is_valid_parameter_value (SubscriptionRequired, 'subscription', cfg.keywords ['yes_true_y']) then
			SubscriptionRequired=nil;
		end

	local UrlAccess = A['UrlAccess'];
		if not is_valid_parameter_value (UrlAccess, 'url-access', cfg.keywords ['url-access']) then
			UrlAccess = nil;
		end
		if not is_set(URL) and is_set(UrlAccess) then
			UrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {'url'}, true ) } );
		end

		if is_set (UrlAccess) and is_set (SubscriptionRequired) then			-- while not aliases, these are much the same so if both are set
			table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'url-access') .. ' and ' .. wrap_style ('parameter', 'subscription')}, true ) } );		-- add error message
			SubscriptionRequired = nil;											-- unset; prefer |access= over |subscription=
		end
		if is_set (UrlAccess) and is_set (RegistrationRequired) then			-- these are not the same but contradictory so if both are set
			table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'url-access') .. ' and ' .. wrap_style ('parameter', 'registration')}, true ) } );		-- add error message
			RegistrationRequired = nil;											-- unset; prefer |access= over |registration=
		end

	local ChapterUrlAccess = A['ChapterUrlAccess'];
		if not is_valid_parameter_value (ChapterUrlAccess, 'chapter-url-access', cfg.keywords ['url-access']) then	-- same as url-access
			ChapterUrlAccess = nil;
		end
		if not is_set(ChapterURL) and is_set(ChapterUrlAccess) then
			ChapterUrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {'chapter-url'}, true ) } );
		end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local Agency = A['Agency'];

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
		if not is_valid_parameter_value (IgnoreISBN, 'ignore-isbn-error', cfg.keywords ['yes_true_y']) then
			IgnoreISBN = nil;													-- anything else, set to empty string
		end
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );
	local ID_access_levels = extract_id_access_levels( args, ID_list );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
		if not is_valid_parameter_value (LastAuthorAmp, 'last-author-amp', cfg.keywords ['yes_true_y']) then
			LastAuthorAmp = nil;												-- set to empty string
		end

	local no_tracking_cats = A['NoTracking'];
		if not is_valid_parameter_value (no_tracking_cats, 'no-tracking', cfg.keywords ['yes_true_y']) then
			no_tracking_cats = nil;												-- set to empty string
		end

	--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = A['DF'];															-- date format set in cs1|2 template
	if not is_valid_parameter_value (DF, 'df', cfg.keywords['date-format']) then	-- validate reformatting keyword
		DF = '';																-- not valid, set to empty string
	end

	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

	--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

	-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	select_one( args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'redundant_parameters' );		-- this is a dummy call simply to get the error message and category

	local NoPP = A['NoPP'] 
	if is_set (NoPP) and is_valid_parameter_value (NoPP, 'nopp', cfg.keywords ['yes_true_y']) then
		NoPP = true;
	else
		NoPP = nil;																-- unset, used as a flag later
	end

	if is_set(Page) then
		if is_set(Pages) or is_set(At) then
			Pages = '';															-- unset the others
			At = '';
		end
		extra_text_in_page_check (Page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.
	elseif is_set(Pages) then
		if is_set(At) then
			At = '';															-- unset
		end
		extra_text_in_page_check (Pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.
	end	

	-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia and |title then map |title to |article and |encyclopedia to |title
		|encyclopedia and |article then map |encyclopedia to |title
		|encyclopedia then map |encyclopedia to |title
	
		|trans-title maps to |trans-chapter when |title is re-mapped
		|url maps to |chapterurl when |title is remapped
	
	All other combinations of |encyclopedia, |title, and |article are not modified
	
	]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterUrlAccess = UrlAccess;

					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter = make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			else																-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if is_set(A['Number']) then												-- cite techreport uses 'number', which other citations alias to 'issue'
			if not is_set(ID) then												-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', 'id') .. ' and ' .. wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

	-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	elseif 'mailinglist' == A:ORIGIN('Periodical') then
		Periodical = '';														-- unset because mailing list is only used for cite mailing list
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		ChapterUrlAccess = UrlAccess;
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];

		link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wikimarkup in |series-link= or wikimarkup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) and is_set (AirDate) then							-- promote airdate to date
			Date = AirDate;
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('series', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = make_wikilink (ChapterLink, Chapter);
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = make_wikilink (SeriesLink, Series);
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, before generation of COinS data.
	do
		if in_array (config.CitationClass, {'arxiv', 'biorxiv', 'citeseerx'}) then
			if not is_set (ID_list[config.CitationClass:upper()]) then			-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp; |citeseerx= required for their templates
				table.insert( z.message_tail, { set_error( config.CitationClass .. '_missing', {}, true ) } );		-- add error message
			end
			
			if 'arxiv' == config.CitationClass then
				Periodical = 'arXiv';											-- set to arXiv for COinS; after that, must be set to empty string
			end

			if 'biorxiv' == config.CitationClass then
				Periodical = 'bioRxiv';											-- set to bioRxiv for COinS; after that, must be set to empty string
			end

			if 'citeseerx' == config.CitationClass then
				Periodical = 'CiteSeerX';										-- set to CiteSeerX for COinS; after that, must be set to empty string
			end
		end
	end

	-- handle type parameter for those CS1 citations that have default values
	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;interview&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
		TitleType = substitute( cfg.messages['type'], TitleType);				-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging

	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val=AccessDate, name=A:ORIGIN ('AccessDate')},
			['archive-date'] = {val=ArchiveDate, name=A:ORIGIN ('ArchiveDate')},
			['date'] = {val=Date, name=Date_origin},
			['doi-broken-date'] = {val=DoiBroken, name=A:ORIGIN ('DoiBroken')},
			['embargo'] = {val=Embargo, name=A:ORIGIN ('Embargo')},
			['lay-date'] = {val=LayDate, name=A:ORIGIN ('LayDate')},
			['publication-date'] ={val=PublicationDate, name=A:ORIGIN ('PublicationDate')},
			['year'] = {val=Year, name=A:ORIGIN ('Year')},
			};
		anchor_year, Embargo, error_message = dates(date_parameters_list, COinS_date);

-- start temporary Julian / Gregorian calendar uncertainty categorization
		if COinS_date.inter_cal_cat then
			add_prop_cat ('jul_greg_uncertainty');
		end
-- end temporary Julian / Gregorian calendar uncertainty categorization

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end
		
		if not is_set(error_message) then										-- error free dates only
			local modified = false;												-- flag
			
			if is_set (DF) then													-- if we need to reformat dates
				modified = reformat_dates (date_parameters_list, DF, false);	-- reformat to DF format, use long month names if appropriate
			end

			if true == date_hyphen_to_dash (date_parameters_list) then			-- convert hyphens to dashes where appropriate
				modified = true;
				add_maint_cat ('date_format');									-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language,
	-- uncomment these three lines.  Not supported by en.wiki (for obvious reasons)
	-- set date_name_xlate() second argument to true to translate English digits to local digits (will translate ymd dates)
--			if date_name_xlate (date_parameters_list, false) then
--				modified = true;
--			end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				LayDate = date_parameters_list['lay-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end
		else
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end
	end	-- end of do

	-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
	-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
			if is_set(AccessDate) then											-- access date requires |url=; pmc created url is not |url=
				table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
				AccessDate = '';												-- unset
			end

		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
			if 'episode' == config.CitationClass then							-- special case for cite episode; TODO: is there a better way to do this?
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
			else
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
			end
	end
	
	if 'none' == Title and in_array (config.CitationClass, {'journal', 'citation'}) and is_set (Periodical) and 'journal' == A:ORIGIN('Periodical') then	-- special case for journal cites
		Title = '';																-- set title to empty string
		add_maint_cat ('untitled');
	end

	check_for_url ({															-- add error message when any of these parameters contains a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[A:ORIGIN('Periodical')]=Periodical,
		[A:ORIGIN('PublisherName')] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = Periodical,
		['Encyclopedia'] = Encyclopedia,
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, and {{cite citeseerx}} AFTER generation of COinS data.
	if in_array (config.CitationClass, {'arxiv', 'biorxiv', 'citeseerx'}) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, or CiteSeerX now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = substitute (cfg.messages['newsgroup'], external_link( 'news:' .. PublisherName, PublisherName, A:ORIGIN('PublisherName'), nil ));
		end
	end



	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text,											-- get current page name so that we don't wikilink to it via editorlinkn
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_authors_editors (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if is_set (Editors) then
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
					EditorCount = 2;											-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
				else
					EditorCount = 2;											-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
				end
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum = #interviewers_list;							-- number of interviewerss
			Interviewers = list_people(control, interviewers_list, false);	-- et al not currently supported
		end
		do																		-- now do translators
			control.maximum = #t;												-- number of translators
			Translators = list_people(control, t, false);						-- et al not currently supported
		end
		do																		-- now do contributors
			control.maximum = #c;												-- number of contributors
			Contributors = list_people(control, c, false);						-- et al not currently supported
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_authors_editors (A['DisplayAuthors'], #a, 'authors', author_etal);

			last_first_list = list_people(control, a, author_etal);

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false);	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if is_set (Authors) and is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
	-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not is_set(URL) then
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then	-- |url= required for cite web, cite podcast, and cite mailinglist
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURLorigin, OriginalFormat, OriginalAccess;
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (ChapterURL) then 											-- if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURLorigin = ChapterURLorigin;								-- name of chapter-url parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				ChapterURLorigin = A:ORIGIN('ArchiveURL')						-- name of archive-url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived urls
			end
		elseif is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURLorigin = URLorigin;										-- name of url parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived urls
			end
 		end
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			local chap_param;
			if is_set (Chapter) then											-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif is_set (ScriptChapter) then
				chap_param = A:ORIGIN ('ScriptChapter')
			else is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if is_set (chap_param) then											-- if we found one
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {chap_param}, true ) } );		-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if is_set (Contribution) and 0 &lt; #c then								-- if this is a contribution with contributor(s)
			if in_array (Contribution:lower(), cfg.keywords.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, Chapter, TransChapter, ChapterURL, ChapterURLorigin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter.. sepc .. ' ';
		elseif is_set (ChapterFormat) then										-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title.
	if is_set (ArchiveURL) and mw.ustring.match (mw.ustring.lower(Title), cfg.special_case_translation['archived_copy']) then	-- if title is 'Archived copy' (place holder added by bots that can't find proper title)
		add_maint_cat ('archived_copy');										-- add maintenance category before we modify the content of Title
	end

	if Title:match ('^%(%(.*%)%)$') then										-- if keep as written markup:
		Title= Title:gsub ('^%(%((.*)%)%)$', '%1')								-- remove the markup
	else
		if '...' == Title:sub (-3) then											-- if elipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%'..sepc..'$', '');				-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end
	end
	
	if is_set(TitleLink) and is_set(Title) then
		Title = make_wikilink (TitleLink, Title);
	end

	if in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end
	
	if is_set(Title) then
		if not is_set(TitleLink) and is_set(URL) then
			
			Title = external_link( URL, Title, URLorigin, UrlAccess ) .. TransTitle .. TransError .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		else
			Title = Title .. TransTitle .. TransError;
		end
	else
		Title = TransTitle .. TransError;
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURLorigin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin, nil );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if is_set(Minutes) then
			if is_set (Time) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'minutes') .. ' and ' .. wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
		OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;		-- TODO: presentation

	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

	--[[
	Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
	note is displayed. There are no error messages for this condition.
	
	]]
	if is_set (SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif is_set (RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text

		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {IdAccessLevels=ID_access_levels, DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin, UrlAccess );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then				-- if first and last characters of quote are quote marks
			Quote = Quote:sub(2,-2);											-- strip them off
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- DeadURL is empty, 'yes', 'true', 'y', 'unfit', 'usurped'
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if in_array (DeadURL, {'unfit', 'usurped', 'bot: unknown'}) then
				Archived = sepc .. &quot; &quot; .. 'Archived from the original on ' .. ArchiveDate;	-- format already styled
				if 'bot: unknown' == DeadURL then
					add_maint_cat ('bot:_unknown');								-- and add a category if not already added
				else
					add_maint_cat ('unfit');									-- and add a category if not already added
				end
			else																-- DeadURL is empty, 'yes', 'true', or 'y'
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURLorigin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURLorigin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin, nil );
	end

	local Publisher;
	if is_set(PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if is_set(PublisherName) then
		if is_set(PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif is_set(PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = safe_join ({Others, sepc .. &quot; &quot;}, sepc) end		-- add terminal punctuation &amp; space; check for dup sepc; TODO why do we need to do this here?
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(Periodical) then		-- special cases for book cites
		if is_set (Contributors) then											-- when we are citing foreword, preface, introduction, etc
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Transcript, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if is_set(Date) then
		if is_set (Authors) or is_set (Editors) then							-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;;				-- in paranetheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon,-1,-1) == sepc) then							-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigYear;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigYear;							-- Date begins with sepc
			end
		end
	end	
	if is_set(Authors) then
		if (not is_set (Date)) then												-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then
					in_text = in_text:lower()									-- lowercase for cs2
				 end
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if is_set (Contributors) then											-- book cite and we're citing the intro, preface, etc
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if is_set (Editors) and is_set (Date) then							-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not is_set (Date)) then											-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = config.CitationClass;
		options.class = &quot;citation &quot; .. config.CitationClass;					-- class=citation required for blue highlight when used with |ref=
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then								-- set reference anchor if appropriate
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			if #namelist &gt; 0 then												-- if there are names in namelist
				id = anchor_id (namelist, year);								-- go make the CITEREF anchor
			else
				id = '';														-- unset
			end
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;(.-)&lt;/span&gt;&quot;, &quot;%1&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then	-- remove &lt;span&gt; tags and other html-like markup; then get length of what remains
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	local render = {};															-- here we collect the final bits for concatenation into the rendered citation

	if is_set(options.id) then													-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render, substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text}));	-- when |ref= is set
	else
		table.insert (render, substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text}));	-- all other cases
	end		

	table.insert (render, substitute (cfg.presentation['ocins'], {OCinSoutput}));		-- append metadata to the citation

	if #z.message_tail ~= 0 then
		table.insert (render, ' ');
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					table.insert (render, error_comment( v[1], v[2] ));
				else
					table.insert (render, error_comment( v[1] .. &quot;; &quot;, v[2] ));
				end
			end
		end
	end

	if #z.maintenance_cats ~= 0 then
		table.insert (render, '&lt;span class=&quot;citation-comment&quot; style=&quot;display:none; color:#33aa33; margin-left:0.3em&quot;&gt;');
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			table.insert (render, v);
			table.insert (render, ' (');
			table.insert (render, make_wikilink (':Category:' .. v, 'link'));
			table.insert (render, ') ');
		end
		table.insert (render, '&lt;/span&gt;');
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			table.insert (render, make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			table.insert (render, make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.properties_cats ) do								-- append properties categories
			table.insert (render, make_wikilink ('Category:' .. v));
		end
	end

	return table.concat (render);	
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class)
	local name = tostring (name);
	local state;
	
	if in_array (cite_class, {'arxiv', 'biorxiv', 'citeseerx'}) then			-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[name];
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end

		state = whitelist[cite_class .. '_basic_arguments'][name];				-- look in the parameter-list for the template identified by cite_class

		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
																				-- limited enumerated parameters list
		name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
		state = whitelist.limited_numbered_arguments[name];
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates
		
	state = whitelist.basic_arguments[name];									-- all other templates; all normal parameters allowed
											
	if true == state then return true; end										-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);											-- parameter is deprecated but still supported
		return true;
	end
																				-- all enumerated parameters allowed
	name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );												-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
	state = whitelist.numbered_arguments[name];

	if true == state then return true; end										-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);											-- parameter is deprecated but still supported
		return true;
	end
	
	return false;																-- not supported because not found or name is set to nil
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe:
	{{cite ... |title=Title access-date=2016-03-17}}

cs1|2 shares some parameter names with xml/html atributes: class=, title=, etc.  To prevent false positives xml/html
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove xml/html tags because attributes: class=, title=, etc 

	capture = value:match ('%s+(%a[%a%d]+)%s*=') or value:match ('^(%a[%a%d]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then								-- if the capture is a valid parameter name
		add_maint_cat ('missing_pipe');
	end
end


--[[--------------------------&lt; C S 1 . C I T A T I O N &gt;------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

function cs1.citation(frame)
	Frame = frame;																-- save a copy incase we need to display an error message in preview mode
	local pframe = frame:getParent()
	local validation, utilities, identifiers, metadata, styles;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		styles = 'Module:Citation/CS1/sandbox/styles.css';
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
		styles = 'Module:Citation/CS1/styles.css';

	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	dates = validation.dates;													-- imported functions from Module:Citation/CS1/Date validation
	year_date_check = validation.year_date_check;
	reformat_dates = validation.reformat_dates;
	date_hyphen_to_dash = validation.date_hyphen_to_dash;
	date_name_xlate = validation.date_name_xlate;

	is_set = utilities.is_set;													-- imported functions from Module:Citation/CS1/Utilities
	in_array = utilities.in_array;
	substitute = utilities.substitute;
	error_comment = utilities.error_comment;
	set_error = utilities.set_error;
	select_one = utilities.select_one;
	add_maint_cat = utilities.add_maint_cat;
	wrap_style = utilities.wrap_style;
	safe_for_italics = utilities.safe_for_italics;
	is_wikilink = utilities.is_wikilink;
	make_wikilink = utilities.make_wikilink;

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	extract_ids = identifiers.extract_ids;										-- imported functions from Module:Citation/CS1/Identifiers
	build_id_list = identifiers.build_id_list;
	is_embargoed = identifiers.is_embargoed;
	extract_id_access_levels = identifiers.extract_id_access_levels;
	
	make_coins_title = metadata.make_coins_title;								-- imported functions from Module:Citation/CS1/COinS
	get_coins_pages = metadata.get_coins_pages;
	COinS = metadata.COinS;

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text, error_state;

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do
		config[k] = v;
--		args[k] = v;															-- debug tool that allows us to render a citation from module {{#invoke:}}
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower(), config.CitationClass ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute (param, capture);				-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text, error_state = set_error ('parameter_ignored_suggest', {k, param}, true);	-- set the suggestion error message
							else
								error_text, error_state = set_error( 'parameter_ignored', {param}, true );	-- suggested param not supported by this template
							end
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			missing_pipe_check (v);												-- do we think that there is a parameter that is missing a pipe?
																				-- TODO: is this the best place for this translation?
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then						-- here when v is empty string
			args[k] = v;														-- why do we do this?  we don't support 'empty' parameters
		end		
	end	

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);
		end
	end
	return table.concat ({citation0( config, args), frame:extensionTag ('templatestyles', '', {src=styles})});
end

return cs1;</text>
      <sha1>lmfkibi5fsoufxp0atzohk1dd467vmu</sha1>
    </revision>
    <revision>
      <id>4722</id>
      <parentid>4721</parentid>
      <timestamp>2019-01-19T10:58:34Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>synch from sandbox;</comment>
      <origin>4722</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="178069" sha1="joi81l849z6qez35g2part0ri125vm5" xml:space="preserve">
local cs1 ={};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local dates, year_date_check, reformat_dates, date_hyphen_to_dash,				-- functions in Module:Citation/CS1/Date_validation
	date_name_xlate

local is_set, in_array, substitute, error_comment, set_error, select_one,		-- functions in Module:Citation/CS1/Utilities
	add_maint_cat, wrap_style, safe_for_italics, is_wikilink, make_wikilink;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local extract_ids, extract_id_access_levels, build_id_list, is_embargoed;		-- functions in Module:Citation/CS1/Identifiers

local make_coins_title, get_coins_pages, COinS;									-- functions in Module:Citation/CS1/COinS

local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

delare variables here that have page-wide scope that are not brought in from other modules; thatare created here
and used here

]]

local added_deprecated_cat;														-- boolean flag so that the category is added only once
local added_prop_cats = {};														-- list of property categories that have been added to z.properties_cats
local added_vanc_errs;															-- boolean flag so we only emit one Vancouver error / category

local Frame;																	-- holds the module's frame table


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

foreign_lang_source and foreign_lang_source_2 keys have a language code appended to them so that multiple languages
may be categorized but multiples of the same language are not categorized.

added_prop_cats is a table declared in page scope variables above

]]

local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		key = key:gsub ('(foreign_lang_source_?2?)%a%a%a?', '%1');				-- strip lang code from keyname
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));		-- make name then add to table
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a boolean declared in page scope variables above

]]

local function add_vanc_error (source)
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {source}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a uri scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of tlds: https://www.iana.org/domains/root/db

rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the tld.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a url with a scheme) will be stripped
here.  Perhaps not necessary but retained incase it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ascii characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the tld) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org and .cash TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and tld or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%a%d]') then										-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at wikisource
		return false;
	end
																				-- Do most common case first
	if domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.%a%a+$') then				-- three or more character hostname.hostname or hostname.tld
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.xn%-%-[%a%d]+$') then	-- internationalized domain name with ACE prefix
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.cash$') then							-- one character/digit .cash hostname
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.org$') then							-- one character/digit .org hostname
		return true;
	elseif domain:match ('%f[%a][qxz]%.com$') then								-- assigned one character .com hostname (x.com times out 2015-12-10)
		return true;
	elseif domain:match ('%f[%a][iq]%.net$') then								-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.%a%a$') then							-- one character hostname and cctld (2 chars)
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d]%.%a%a+$') then					-- two character hostname and tld
		return true;
	elseif domain:match ('^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?') then		-- IPv4 address
		return true;
	else
		return false;
	end
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a url appear to be a valid url; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if is_set (scheme) then														-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when url is protocol relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a url into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following tld) (if any) and any path(/), query(?) or fragment(#).

If protocol relative url, return nil scheme and domain else return nil for both scheme and domain.

When not protocol relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol relative url
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		authority = authority:gsub ('//', '', 1);								-- replace place 1 pair of '/' with nothing;
		if is_set(authority) then												-- if anything left (1 or 3+ '/' where authority should be) then
			return scheme;														-- return scheme only making domain nil which will cause an error message
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link= etc for properly formatted content: no wikilinks, no urls

Link parameters are to hold the title of a wikipedia article so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki urls and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid url (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid url (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from url; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid url
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wikilinked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

]]

local function link_title_ok (link, lorig, title, torig)
local orig;

	if is_set (link) then 														-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		end
	end

	if is_set (orig) then
		table.insert( z.message_tail, { set_error( 'bad_paramlink', orig)});	-- url or wikilink in |title= with |title-link=;
	end
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the url into scheme and domain
portions, or for protocol relative (//example.com) urls, just the domain.  Use is_url() to validate the two
portions of the url.  If both are valid, or for protocol relative if domain is valid, return true, else false.

Because it is different from a standard url, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper url
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from url;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a url.  The test will also find external wikilinks
that use protocol relative urls. Also finds bare urls.

The frontier pattern prevents a match on interwiki links which are similar to scheme:path urls.  The tests that
find bracketed urls are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol relative ext wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare url with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol relative bare url: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a url
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then												-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source, access)
	local error_str = &quot;&quot;;
	local domain;
	local path;
	local base_url;

	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the url into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['[']='%5b',[']']='%5d'});					-- replace '[' and ']' with their percent encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wikimarkup url

	if is_set (access) then														-- access level (subscription, registration, limited)
		base_url = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end
	
	return table.concat ({base_url, error_str});
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Replaces unicode quotemarks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc; not for book titles.

]=]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	local wl_type, label, link;

	wl_type, label, link = is_wikilink (str);									-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = substitute (cfg.presentation['kern-wl-both'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = substitute (cfg.presentation['kern-wl-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = substitute (cfg.presentation['kern-wl-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label= mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label= mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap, cap2 = mw.ustring.match (label, &quot;^([\&quot;\'])([^\'].+)&quot;);				-- match leading double or single quote but not doubled single quotes (italic markup)
		if is_set (cap) then
			label = substitute (cfg.presentation['kern-left'], {cap, cap2});
		end
	
		cap, cap2 = mw.ustring.match (label, &quot;^(.+[^\'])([\&quot;\'])$&quot;)				-- match trailing double or single quote but not doubled single quotes (italic markup)
		if is_set (cap) then
			label = substitute (cfg.presentation['kern-right'], {cap, cap2});
		end
		
		if 2 == wl_type then
			str = make_wikilink (link, label);									-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title= and |script-chapter=

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_code_remap[lang] or mw.language.fetchLanguageName( lang, &quot;en&quot; );	-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, cfg.script_lang_codes) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				add_prop_cat ('script')
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return substitute( msg, str );										-- including template text
	else
		return substitute( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;----------------------------------------

makes a wikisource url from wikisource interwiki link.  returns the url and appropriate label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;

	wl_type, D, L = is_wikilink (str);											-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if is_set (str) then
			ws_url = table.concat ({											-- build a wikisource url
				'https://en.wikisource.org/wiki/',								-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the url
		end
	elseif 1 == wl_type then														-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if is_set (str) then
			ws_url = table.concat ({											-- build a wikisource url
				'https://en.wikisource.org/wiki/',								-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the url
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a wikisource url
				'https://en.wikisource.org/wiki/',								-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end
	
	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable url
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent encoding of anchor
	end

	return ws_url, ws_label, L or D;													-- return proper url or nil and a label or nil
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (scriptchapter, chapter, transchapter, chapterurl, chapter_url_source, no_quotes, access)
	local chapter_error = '';

	local ws_url, ws_label, L = wikisource_url_make (chapter);						-- make a wikisource url and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', '');										-- replace underscore separaters with space characters
		chapter = ws_label;
	end

	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
			chapter = wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, scriptchapter)						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (chapterurl) then
		chapter = external_link (chapterurl, chapter, chapter_url_source, access);		-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');		-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if is_set (transchapter) then
		transchapter = wrap_style ('trans-quoted-title', transchapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. transchapter;
		else																	-- here when transchapter without chapter or script-chapter
			chapter = transchapter;												-- 
			chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
		end
	end

--	if is_set (chapterurl) then
--		chapter = external_link (chapterurl, chapter, chapter_url_source, access);		-- adds bare_url_missing_title error if appropriate
--	end

	return chapter .. chapter_error;
end


--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Detects but ignores the character pattern that results from the transclusion of {{'}} templates.

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i=1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- Test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position and (char == 'zero width joiner') then						-- if we found a zero width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- its ok if one of the indic scripts
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { set_error( 'invisible_char', {err_msg, wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i=i+1;																	-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash under certain conditions.  The hyphen must separate like items; unlike items are
returned unmodified.  These forms are modified:
	letter - letter (A - B)
	digit - digit (4-5)
	digit separator digit - digit separator digit (4.1-4.5 or 4-1-4-5)
	letterdigit - letterdigit (A1-A5) (an optional separator between letter and digit is supported – a.1-a.5 or a-1-a-5)
	digitletter - digitletter (5a - 5d) (an optional separator between letter and digit is supported – 5.a-5.d or 5-a-5-d)

any other forms are returned unmodified.

str may be a comma- or semicolon-separated list

]]

local function hyphen_to_dash( str )
	if not is_set (str) then
		return str;
	end
	
	str, count = str:gsub ('^%(%((.+)%)%)$', '%1');								-- remove accept-this-as-written markup when it wraps all of str
	if 0 ~= count then															-- non-zero when markup removed; zero else
		return str;																-- nothing to do, we're done
	end
	
	str = str:gsub ('&amp;[nm]dash;', {['&amp;ndash;'] = '–', ['&amp;mdash;'] = '—'});		-- replace &amp;mdash; and &amp;ndash; entities  with their characters; semicolon mucks up the text.split
	
	local out = {};
	local list = mw.text.split (str, '%s*[,;]%s*');								-- split str at comma or semicolon separators if there are any

	for _, item in ipairs (list) do												-- for each item in the list
		if mw.ustring.match (item, '^%w*[%.%-]?%w+%s*[%-–—]%s*%w*[%.%-]?%w+$') then	-- if a hyphenated range or has endash or emdash separators
			if item:match ('%a+[%.%-]?%d+%s*%-%s*%a+[%.%-]?%d+') or				-- letterdigit hyphen letterdigit (optional separator between letter and digit)
				item:match ('%d+[%.%-]?%a+%s*%-%s*%d+[%.%-]?%a+') or			-- digitletter hyphen digitletter (optional separator between digit and letter)
				item:match ('%d+[%.%-]%d+%s*%-%s*%d+[%.%-]%d+') or				-- digit separator digit hyphen digit separator digit
				item:match ('%d+%s*%-%s*%d+') or								-- digit hyphen digit
				item:match ('%a+%s*%-%s*%a+') then								-- letter hyphen letter
					item = item:gsub ('(%w*[%.%-]?%w+)%s*%-%s*(%w*[%.%-]?%w+)', '%1–%2');	-- replace hyphen, remove extraneous space characters
			else
				item = mw.ustring.gsub (item, '%s*[–—]%s*', '–');				-- for endash or emdash separated ranges, replace em with en, remove extraneous white space
			end
		end
		item = item:gsub ('^%(%((.+)%)%)$', '%1');								-- remove the accept-this-as-written markup
		table.insert (out, item);												-- add the (possibly modified) item to the output table
	end

	return table.concat (out, ', ');											-- concatenate the output table into a comma separated string
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'dupicate character'
		if 1 == #duplicate_char then											-- for single byte ascii characters use the string library functions
			f.gsub=string.gsub
			f.match=string.match
			f.sub=string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub=mw.ustring.gsub
			f.match=mw.ustring.match
			f.sub=mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1,1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = f.sub(str, -1,-1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if f.sub(str, -3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5,-1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4,-1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if f.sub(str, -3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3,-1) == duplicate_char .. '&quot;]' then		-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2,-1) == duplicate_char .. &quot;]&quot; then		-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4,-1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2,-1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows html markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;------------------------------------------------------------

returns true is suffix is properly formed Jr, Sr, or ordinal in the range 2–9.  Puncutation not allowed.

]]

local function is_suffix (suffix)
	if in_array (suffix, {'Jr', 'Sr', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written ouside of the code editor and pasted here because the code editor gets confused between character insertion point and cursor position.
The test has been rewritten to use decimal character escape sequence for the individual bytes of the unicode characters so that it is not necessary
to use an external editor to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first)
	local first, suffix = first:match ('(.-),?%s*([%dJS][%drndth]+)%.?$') or first;		-- if first has something that looks like a generational suffix, get it

	if is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error ('suffix');
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error ('non-Latin character');
			return false;														-- not a string of latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just intials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error ('suffix');									-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word


	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i],1,1));				-- insert the intial at end of initials table
		end
		i = i+1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between authors is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between authors is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = make_wikilink (person.link, one);						-- link author/editor if this page is not the author's/editor's page
				end
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end


--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]
local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of author and editor name parameters for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the parameters |display-authors=etal or |display-editors=etal

]]

local function name_has_etal (name, etal, nocat)

	if is_set (name) then														-- name can be nil in which case just return
		local etal_pattern = &quot;[;,]? *[\&quot;']*%f[%a][Ee][Tt] *[Aa][Ll][%.\&quot;']*$&quot;	-- variations on the 'et al' theme
		local others_pattern = &quot;[;,]? *%f[%a]and [Oo]thers&quot;;					-- and alternate to et al.
		
		if name:match (etal_pattern) then										-- variants on et al.
			name = name:gsub (etal_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		elseif name:match (others_pattern) then									-- if not 'et al.', then 'and others'?
			name = name:gsub (others_pattern, '');								-- if found, remove
			etal = true;														-- set flag (may have been set previously here or by |display-authors=etal)
			if not nocat then													-- no categorization for |vauthors=
				add_maint_cat ('etal');											-- and add a category if not already added
			end
		end
	end
	return name, etal;															-- 
end


--[[--------------------------&lt; N A M E _ H A S _ E D _ M A R K U P &gt;------------------------------------------

Evaluates the content of author and editor parameters for extranious editor annotations: ed, ed., eds, (Ed.), etc.
These annotation do not belong in author parameters and are redundant in editor parameters.  If found, the function
adds the editor markup maintenance category.

]]

local function name_has_ed_markup (name, list_name)
	local _, pattern;
	local patterns = {															-- these patterns match annotations at end of name
		'%f[%(%[][%(%[]%s*[Ee][Dd][Ss]?%.?%s*[%)%]]?$',							-- (ed) or (eds): leading '(', case insensitive 'ed', optional 's', '.' and/or ')'
		'[,%.%s]%f[e]eds?%.?$',													-- ed or eds: without '('or ')'; case sensitive (ED could be initials Ed could be name)
		'%f[%(%[][%(%[]%s*[Ee][Dd][Ii][Tt][Oo][Rr][Ss]?%.?%s*[%)%]]?$',			-- (editor) or (editors): leading '(', case insensitive, optional '.' and/or ')'
		'[,%.%s]%f[Ee][Ee][Dd][Ii][Tt][Oo][Rr][Ss]?%.?$',						-- editor or editors: without '('or ')'; case insensitive
		
																				-- these patterns match annotations at beginning of name
		'^eds?[%.,;]',															-- ed. or eds.: lower case only, optional 's', requires '.'
		'^[%(%[]%s*[Ee][Dd][Ss]?%.?%s*[%)%]]',									-- (ed) or (eds): also sqare brackets, case insensitive, optional 's', '.'
		'^[%(%[]?%s*[Ee][Dd][Ii][Tt][Oo][Rr][Ss]?%A',							-- (editor or (editors: also sq brackets, case insensitive, optional brackets, 's'
		'^[%(%[]?%s*[Ee][Dd][Ii][Tt][Ee][Dd]%A',								-- (edited: also sq brackets, case insensitive, optional brackets
		}

	if is_set (name) then
		for _, pattern in ipairs (patterns) do									-- spin through patterns table and
			if name:match (pattern) then
				add_maint_cat ('extra_text_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
				break;
			end
		end
	end
	return name;																-- and done
end


--[[--------------------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;----------------------------------------

Evaluates the content of author and editor (surnames only) parameters for multiple names.  Multiple names are
indicated if there is more than one comma and or semicolon.  If found, the function adds the multiple name
(author or editor) maintenance category.

]]

local function name_has_mult_names (name, list_name)
local count, _;
	if is_set (name) then
		_, count = name:gsub ('[;,]', '');										-- count the number of separator-like characters
		
		if 1 &lt; count then														-- param could be |author= or |editor= so one separator character is acceptable
			add_maint_cat ('mult_names', cfg.special_case_translation [list_name]);	-- more than one separator indicates multiple names so add a maint cat for this template
		end
	end
	return name;																-- and done
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------
This function calls various name checking functions used to validate the content of the various name-holding
parameters.

]]

local function name_checks (last, first, list_name)
	if is_set (last) then
		if last:match ('^%(%(.*%)%)$') then										-- if wrapped in doubled parentheses, accept as written 
			last = last:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			last = name_has_mult_names (last, list_name);						-- check for multiple names in the parameter (last only)
			last = name_has_ed_markup (last, list_name);						-- check for extraneous 'editor' annotation
		end
	end
	if is_set (first) then
		if first:match ('^%(%(.*%)%)$') then									-- if wrapped in doubled parentheses, accept as written 
			first = first:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			first = name_has_ed_markup (first, list_name);						-- check for extraneous 'editor' annotation
		end
	end
	return last, first;															-- done
	end


--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local err_msg_list_name = list_name:match (&quot;(%w+)List&quot;) .. 's list';		-- modify AuthorList or EditorList for use in error messages if necessary
	while true do
		last = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false);							-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false);						-- find and remove variations on et al.
		last, first= name_checks (last, first, list_name);						-- multiple names, extraneous annotation, etc checks
		
		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {err_msg_list_name, i}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			link_title_ok (link, list_name:match (&quot;(%w+)List&quot;):lower() .. '-link' .. i, last, list_name:match (&quot;(%w+)List&quot;):lower() .. '-last' .. i);	-- check for improper wikimarkup

			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {err_msg_list_name, i-1}, true ) } );		-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because case of the source may be incorrect
or different from the case that WikiMedia uses, the name comparisons are done in lower case and when a match is
found, the Wikimedia version (assumed to be correct) is returned along with the code.  When there is no match, we
return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') returns a list of languages that in some cases may include
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.  Most (all?) of these languages are not used a 'language' codes per se, rather they
are used as sub-domain names: cbk-zam.wikipedia.org.  A list of language names and codes supported by fetchLanguageNames()
can be found at Template:Citation Style documentation/language/doc

Names that are included in the list will be found if that name is provided in the |language= parameter.  For example,
if |language=Chavacano de Zamboanga, that name will be found with the associated code 'cbk-zam'.  When names are found
and the associated code is not two or three characters, this function returns only the WikiMedia language name.

Some language names have multiple entries under different codes:
	Aromanian has code rup and code roa-rup
When this occurs, this function returns the language name and the 2- or 3-character code

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	if cfg.lang_name_remap[lang:lower()] then									-- if there is a remapped name (because MediaWiki uses something that we don't think is correct)
		return cfg.lang_name_remap[lang:lower()][1], cfg.lang_name_remap[lang:lower()][2];	-- for this language 'name', return a possibly new name and appropriate code
	end

	local ietf_code;															-- because some languages have both ietf-like codes and iso 639-like codes
	local ietf_name;
	
	local languages = mw.language.fetchLanguageNames(this_wiki_code, 'all')		-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons

	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 == code:len() or 3 == code:len() then							-- two- or three-character codes only; extensions not supported
				return name, code;												-- so return the name and the code
			end
			ietf_code = code;													-- remember that we found an ietf-like code and save its name
			ietf_name = name;													-- but keep looking for a 2- or 3-char code
		end
	end
																				-- didn't find name with 2- or 3-char code; if ietf-like code found return
	return ietf_code and ietf_name or lang;										-- associated name; return original language text else
end


--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code is recognized by MediaWiki,
use the returned name; if not, then use the value that was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is assigned to the category for
that code: Category:Norwegian-language sources (no).  For valid three-character code languages, the page is assigned
to the single category for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does not recognize three-character
equivalents of two-character codes: code 'ar' is recognized bit code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are
separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki = mw.getContentLanguage();									-- get a language object for this wiki
	local this_wiki_code = this_wiki:getCode()									-- get this wiki's language code
	local this_wiki_name = mw.language.fetchLanguageName(this_wiki_code, this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang
		name = cfg.lang_code_remap[lang:lower()];								-- first see if this is a code that is not supported by MediaWiki but is in remap

		if name then															-- there was a remapped code so
			lang = lang:gsub ('^(%a%a%a?)%-.*', '%1');							-- strip ietf tags from code
		else
			if lang:match ('^%a%a%-') then										-- strip ietf tags from code; TODO: is there a need to support 3-char with tag?
				lang = lang:match ('(%a%a)%-')									-- keep only 639-1 code portion to lang; TODO: do something with 3166 alpha 2 country code?
			end
			if 2 == lang:len() or 3 == lang:len() then							-- if two-or three-character code
				name = mw.language.fetchLanguageName (lang:lower(), this_wiki_code);	-- get language name if |language= is a proper code
			end
		end

		if is_set (name) then													-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, this_wiki_code);				-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then													-- only 2- or 3-character codes
			name = cfg.lang_code_remap[code] or name;							-- override wikimedia when they misuse language codes/names

			if this_wiki_code ~= code then										-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					add_prop_cat ('foreign_lang_source' .. code, {name, code})	-- categorize it
				else															-- or is a recognized language (but has a three-character code)
					add_prop_cat ('foreign_lang_source_2' .. code, {code})		-- categorize it differently TODO: support mutliple three-character code categories per cs1|2 template
				end
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, cfg.messages['parameter-pair-separator'])		-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		name = table.concat (language_list, ', ');											-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
		name = name:gsub (', ([^,]+)$', cfg.messages['parameter-final-separator'] .. '%1');	-- replace last '&lt;comma&gt;&lt;space&gt;' separator with '&lt;comma&gt;&lt;space&gt;and&lt;space&gt;' separator
	end
	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings
At en.wiki, for cs1:
	ps gets:	'.'
	sep gets:	'.'

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = cfg.presentation['ps_cs1'];										-- terminate the rendered citation
	end
	return cfg.presentation['sep_cs1'], ps;										-- element separator
end


--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings
At en.wiki, for cs2:
	ps gets:	'' (empty string - no terminal punctuation)
	sep gets:	','

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = cfg.presentation['ps_cs2'];										-- terminate the rendered citation
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return cfg.presentation['sep_cs2'], ps, ref;								-- element separator
end


--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end


--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end


--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parentheses, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[--------------------------&lt; G E T _ D I S P L A Y _ A U T H O R S _ E D I T O R S &gt;------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_authors_editors (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_auth_ed', cfg.special_case_translation [list_name]);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parnetheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a place holder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parens
			local name = name_table[i];
			i=i+1;																-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parens
					break;														-- and done reassembling so
				end
				i=i+1;															-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = is_wikilink (name_table[i]);					-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i+1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);						-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parentheses to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')								-- remove doubled parntheses
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error ('punctuation');
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
			if is_suffix (first) then											-- if a valid suffix
				suffix = first													-- save it as a suffix and
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end																	-- no suffix error message here because letter combination may be result of Romanization; check for digits?
			last = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error ('missing comma');								-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error ('name');										-- matches a space between two intiials
			end
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error ('initials');									-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first);									-- check first and last before restoring the suffix which may have a non-Latin digit
			if is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '');
			end
		end

		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ) or v_link_table[i];
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice incase we have a |first1= without a |last1=; this ...
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or	-- ... also catches the case where |first= is used with |vauthors=
		select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, no, etc).  When the parameter value has not been assigned a value (missing or empty
in the source template) the function returns true.  If the parameter value is one of the list of allowed values returns
true; else, emits an error message and returns false.

]]

local function is_valid_parameter_value (value, name, possible)
	if not is_set (value) then
		return true;															-- an empty parameter is ok
	elseif in_array(value:lower(), possible) then
		return true;
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list,-3,-1) == sepc .. '. ') then						-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list,-1,-1) == sepc) or (string.sub (name_list,-3,-1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terninate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not is_set (volume) and not is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end

	local vol = '';																-- here for all cites except magazine
		
	if is_set (volume) then
		if volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$')then			-- volume value is all digits or all uppercase roman numerals
			vol = substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});	-- render in bold face
		elseif (4 &lt; mw.ustring.len(volume)) then								-- not all digits or roman numerals and longer than 4 characters
			vol = substitute (cfg.messages['j-vol'], {sepc, volume});			-- not bold
			add_prop_cat ('long_vol');
		else																	-- four or less characters
			vol = substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});	-- bold
		end
	end
	if is_set (issue) then
		return vol .. substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if is_set (page) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif is_set(pages) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then										-- if pages is only digits, assume a single page number
			return '', substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to wikisource, returns the label portion of the interwikilink as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki link to and external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, pages, at)
	local ws_url, ws_label, coins_pages, L;										-- for wikisource interwikilinks; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if is_set (page) then
		if is_set (pages) or is_set(at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws url from |page= interwiki link; link portion L becomes tool tip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif is_set (pages) then
		if is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws url from |pages= interwiki link; link portion L becomes tool tip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws url from |at= interwiki link; link portion L becomes tool tip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end



--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org urls to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot url or to calendar pages.  When the archive url is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the url.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org url does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command url
	|archive-url= is an archive.org url that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org urls:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this funct may return a modified
archive url:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the url unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.or url
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine url
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command url, we don't want to allow saving of the target page 
		err_msg = 'save command';
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = 'liveweb';
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');		-- split out some of the url parts for evaluation
		
		if not is_set(timestamp) or 14 ~= timestamp:len() then					-- path and flag optional, must have 14-digit timestamp here
			err_msg = 'timestamp';
			if '*' ~= flag then
				url=url:gsub ('(//web%.archive%.org/[^%d]*%d?%d?%d?%d?%d?%d?)[^/]*', '%1*', 1)	-- for preview, modify ts to be yearmo* max (0-6 digits plus splat)
			end
		elseif is_set(path) and 'web/' ~= path then								-- older archive urls do not have the extra 'web/' path element
			err_msg = 'path';
		elseif is_set (flag) and not is_set (path) then							-- flag not allowed with the old form url (without the 'web/' path element)
			err_msg = 'flag';
		elseif is_set (flag) and not flag:match ('%a%a_') then					-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = 'flag';
		else
			return url, date;													-- return archiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	table.insert( z.message_tail, { set_error( 'archive_url', {err_msg}, true ) } );	-- add error message and
	if is_set (Frame:preprocess('{{REVISIONID}}')) then
		return '', '';															-- return empty strings for archiveURL and ArchiveDate
	else
		return url, date;														-- preview mode so return archiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

-- set default parameter values defined by |mode= parameter.
	local Mode = A['Mode'];
	if not is_valid_parameter_value (Mode, 'mode', cfg.keywords['mode']) then
		Mode = '';
	end

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				add_maint_cat ('authors');										-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
			add_maint_cat ('editors');											-- but add a maint cat because use of this parameter is discouraged
		end
	end

	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=

	local interviewers_list = {};												
	local Interviewers;															-- used later
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters

	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list
	local Contribution = A['Contribution'];
	if in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not is_set (Contribution) then									-- |contributor= requires |contribution=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if select_one (args, cfg.aliases['ContributorList-Last'], 'redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { set_error( 'contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if not is_valid_parameter_value (NameListFormat, 'name-list-format', cfg.keywords['name-list-format']) then			-- only accepted value for this parameter is 'vanc'
		NameListFormat = '';													-- anything else, set to empty string
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
			link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wikimarkup in |title-link= or wikimarkup in |title= when |title-link= is set

	local Chapter = A['Chapter'];
	local ScriptChapter = A['ScriptChapter'];
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];

	local ArchiveDate;
	local ArchiveURL;

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	
	local DeadURL = A['DeadURL']
		if not is_valid_parameter_value (DeadURL, 'dead-url', cfg.keywords ['deadurl']) then	-- set in config.defaults to 'yes'
			DeadURL = '';														-- anything else, set to empty string
		end

	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];
	local Periodical_origin = A:ORIGIN('Periodical');							-- get the name of the periodical parameter

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if in_array (config.CitationClass, cfg.templates_using_volume) then
		Volume = A['Volume'];
	end
																				-- conference &amp; map books do not support issue
	if in_array (config.CitationClass, cfg.templates_using_issue) and not (in_array (config.CitationClass, {'conference', 'map'}) and not is_set (Periodical))then
		Issue = hyphen_to_dash (A['Issue']);
	end
	local Position = '';
	if not in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash (A['Pages']);	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
		if not is_valid_parameter_value (RegistrationRequired, 'registration', cfg.keywords ['yes_true_y']) then
			RegistrationRequired=nil;
		end

	local SubscriptionRequired = A['SubscriptionRequired'];
		if not is_valid_parameter_value (SubscriptionRequired, 'subscription', cfg.keywords ['yes_true_y']) then
			SubscriptionRequired=nil;
		end

	local UrlAccess = A['UrlAccess'];
		if not is_valid_parameter_value (UrlAccess, 'url-access', cfg.keywords ['url-access']) then
			UrlAccess = nil;
		end
		if not is_set(URL) and is_set(UrlAccess) then
			UrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {'url'}, true ) } );
		end

		if is_set (UrlAccess) and is_set (SubscriptionRequired) then			-- while not aliases, these are much the same so if both are set
			table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'url-access') .. ' and ' .. wrap_style ('parameter', 'subscription')}, true ) } );		-- add error message
			SubscriptionRequired = nil;											-- unset; prefer |access= over |subscription=
		end
		if is_set (UrlAccess) and is_set (RegistrationRequired) then			-- these are not the same but contradictory so if both are set
			table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'url-access') .. ' and ' .. wrap_style ('parameter', 'registration')}, true ) } );		-- add error message
			RegistrationRequired = nil;											-- unset; prefer |access= over |registration=
		end

	local ChapterUrlAccess = A['ChapterUrlAccess'];
		if not is_valid_parameter_value (ChapterUrlAccess, 'chapter-url-access', cfg.keywords ['url-access']) then	-- same as url-access
			ChapterUrlAccess = nil;
		end
		if not is_set(ChapterURL) and is_set(ChapterUrlAccess) then
			ChapterUrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {'chapter-url'}, true ) } );
		end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local Agency = A['Agency'];

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
		if not is_valid_parameter_value (IgnoreISBN, 'ignore-isbn-error', cfg.keywords ['yes_true_y']) then
			IgnoreISBN = nil;													-- anything else, set to empty string
		end
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );
	local ID_access_levels = extract_id_access_levels( args, ID_list );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
		if not is_valid_parameter_value (LastAuthorAmp, 'last-author-amp', cfg.keywords ['yes_true_y']) then
			LastAuthorAmp = nil;												-- set to empty string
		end

	local no_tracking_cats = A['NoTracking'];
		if not is_valid_parameter_value (no_tracking_cats, 'no-tracking', cfg.keywords ['yes_true_y']) then
			no_tracking_cats = nil;												-- set to empty string
		end

	--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = A['DF'];															-- date format set in cs1|2 template
	if not is_valid_parameter_value (DF, 'df', cfg.keywords['date-format']) then	-- validate reformatting keyword
		DF = '';																-- not valid, set to empty string
	end

	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

	--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

	-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	select_one( args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'redundant_parameters' );		-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, Pages, At);

	local NoPP = A['NoPP'] 
	if is_set (NoPP) and is_valid_parameter_value (NoPP, 'nopp', cfg.keywords ['yes_true_y']) then
		NoPP = true;
	else
		NoPP = nil;																-- unset, used as a flag later
	end

	-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia and |title then map |title to |article and |encyclopedia to |title
		|encyclopedia and |article then map |encyclopedia to |title
		|encyclopedia then map |encyclopedia to |title
	
		|trans-title maps to |trans-chapter when |title is re-mapped
		|url maps to |chapterurl when |title is remapped
	
	All other combinations of |encyclopedia, |title, and |article are not modified
	
	]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterUrlAccess = UrlAccess;

					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter = make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			else																-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if is_set(A['Number']) then												-- cite techreport uses 'number', which other citations alias to 'issue'
			if not is_set(ID) then												-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', 'id') .. ' and ' .. wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

	-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	elseif 'mailinglist' == A:ORIGIN('Periodical') then
		Periodical = '';														-- unset because mailing list is only used for cite mailing list
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		ChapterUrlAccess = UrlAccess;
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];

		link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wikimarkup in |series-link= or wikimarkup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) and is_set (AirDate) then							-- promote airdate to date
			Date = AirDate;
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('series', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = make_wikilink (ChapterLink, Chapter);
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = make_wikilink (SeriesLink, Series);
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, before generation of COinS data.
	do
		if in_array (config.CitationClass, {'arxiv', 'biorxiv', 'citeseerx'}) then
			if not is_set (ID_list[config.CitationClass:upper()]) then			-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp; |citeseerx= required for their templates
				table.insert( z.message_tail, { set_error( config.CitationClass .. '_missing', {}, true ) } );		-- add error message
			end
			
			if 'arxiv' == config.CitationClass then
				Periodical = 'arXiv';											-- set to arXiv for COinS; after that, must be set to empty string
			end

			if 'biorxiv' == config.CitationClass then
				Periodical = 'bioRxiv';											-- set to bioRxiv for COinS; after that, must be set to empty string
			end

			if 'citeseerx' == config.CitationClass then
				Periodical = 'CiteSeerX';										-- set to CiteSeerX for COinS; after that, must be set to empty string
			end
		end
	end

	-- handle type parameter for those CS1 citations that have default values
	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;interview&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
		TitleType = substitute( cfg.messages['type'], TitleType);				-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging

	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val=AccessDate, name=A:ORIGIN ('AccessDate')},
			['archive-date'] = {val=ArchiveDate, name=A:ORIGIN ('ArchiveDate')},
			['date'] = {val=Date, name=Date_origin},
			['doi-broken-date'] = {val=DoiBroken, name=A:ORIGIN ('DoiBroken')},
			['embargo'] = {val=Embargo, name=A:ORIGIN ('Embargo')},
			['lay-date'] = {val=LayDate, name=A:ORIGIN ('LayDate')},
			['publication-date'] ={val=PublicationDate, name=A:ORIGIN ('PublicationDate')},
			['year'] = {val=Year, name=A:ORIGIN ('Year')},
			};
		anchor_year, Embargo, error_message = dates(date_parameters_list, COinS_date);

-- start temporary Julian / Gregorian calendar uncertainty categorization
		if COinS_date.inter_cal_cat then
			add_prop_cat ('jul_greg_uncertainty');
		end
-- end temporary Julian / Gregorian calendar uncertainty categorization

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end
		
		if not is_set(error_message) then										-- error free dates only
			local modified = false;												-- flag
			
			if is_set (DF) then													-- if we need to reformat dates
				modified = reformat_dates (date_parameters_list, DF, false);	-- reformat to DF format, use long month names if appropriate
			end

			if true == date_hyphen_to_dash (date_parameters_list) then			-- convert hyphens to dashes where appropriate
				modified = true;
				add_maint_cat ('date_format');									-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language,
	-- uncomment these three lines.  Not supported by en.wiki (for obvious reasons)
	-- set date_name_xlate() second argument to true to translate English digits to local digits (will translate ymd dates)
--			if date_name_xlate (date_parameters_list, false) then
--				modified = true;
--			end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				LayDate = date_parameters_list['lay-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end
		else
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end
	end	-- end of do

	-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
	-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
			if is_set(AccessDate) then											-- access date requires |url=; pmc created url is not |url=
				table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
				AccessDate = '';												-- unset
			end

		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
			if 'episode' == config.CitationClass then							-- special case for cite episode; TODO: is there a better way to do this?
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
			else
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
			end
	end
	
	if 'none' == Title and in_array (config.CitationClass, {'journal', 'citation'}) and is_set (Periodical) and 'journal' == A:ORIGIN('Periodical') then	-- special case for journal cites
		Title = '';																-- set title to empty string
		add_maint_cat ('untitled');
	end

	check_for_url ({															-- add error message when any of these parameters contains a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[A:ORIGIN('Periodical')]=Periodical,
		[A:ORIGIN('PublisherName')] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = Periodical,
		['Encyclopedia'] = Encyclopedia,
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = coins_pages or get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, and {{cite citeseerx}} AFTER generation of COinS data.
	if in_array (config.CitationClass, {'arxiv', 'biorxiv', 'citeseerx'}) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, or CiteSeerX now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = substitute (cfg.messages['newsgroup'], external_link( 'news:' .. PublisherName, PublisherName, A:ORIGIN('PublisherName'), nil ));
		end
	end



	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text,											-- get current page name so that we don't wikilink to it via editorlinkn
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_authors_editors (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if is_set (Editors) then
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
					EditorCount = 2;											-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
				else
					EditorCount = 2;											-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
				end
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum = #interviewers_list;							-- number of interviewerss
			Interviewers = list_people(control, interviewers_list, false);	-- et al not currently supported
		end
		do																		-- now do translators
			control.maximum = #t;												-- number of translators
			Translators = list_people(control, t, false);						-- et al not currently supported
		end
		do																		-- now do contributors
			control.maximum = #c;												-- number of contributors
			Contributors = list_people(control, c, false);						-- et al not currently supported
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_authors_editors (A['DisplayAuthors'], #a, 'authors', author_etal);

			last_first_list = list_people(control, a, author_etal);

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false);	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if is_set (Authors) and is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
	-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not is_set(URL) then
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then	-- |url= required for cite web, cite podcast, and cite mailinglist
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURLorigin, OriginalFormat, OriginalAccess;
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (ChapterURL) then 											-- if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURLorigin = ChapterURLorigin;								-- name of chapter-url parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				ChapterURLorigin = A:ORIGIN('ArchiveURL')						-- name of archive-url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived urls
			end
		elseif is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURLorigin = URLorigin;										-- name of url parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived urls
			end
 		end
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			local chap_param;
			if is_set (Chapter) then											-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif is_set (ScriptChapter) then
				chap_param = A:ORIGIN ('ScriptChapter')
			else is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if is_set (chap_param) then											-- if we found one
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {chap_param}, true ) } );		-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if is_set (Contribution) and 0 &lt; #c then								-- if this is a contribution with contributor(s)
			if in_array (Contribution:lower(), cfg.keywords.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, Chapter, TransChapter, ChapterURL, ChapterURLorigin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter.. sepc .. ' ';
		elseif is_set (ChapterFormat) then										-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title.
	if is_set (ArchiveURL) and mw.ustring.match (mw.ustring.lower(Title), cfg.special_case_translation['archived_copy']) then	-- if title is 'Archived copy' (place holder added by bots that can't find proper title)
		add_maint_cat ('archived_copy');										-- add maintenance category before we modify the content of Title
	end

	if Title:match ('^%(%(.*%)%)$') then										-- if keep as written markup:
		Title= Title:gsub ('^%(%((.*)%)%)$', '%1')								-- remove the markup
	else
		if '...' == Title:sub (-3) then											-- if elipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%'..sepc..'$', '');				-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end
	end
	
	if in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end

	if is_set(Title) then
		if not is_set (TitleLink) and is_set (URL) then
			Title = external_link (URL, Title, URLorigin, UrlAccess) .. TransTitle .. TransError .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif is_set (TitleLink) and not is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = make_wikilink (TitleLink, Title) .. TransTitle .. TransError;
			end
		else
			local ws_url, ws_label;
			ws_url, ws_label, L = wikisource_url_make (Title);					-- make ws url from |title= interwiki link; link portion L becomes tool tip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = Title .. TransTitle .. TransError;
			end
		end
	else
		Title = TransTitle .. TransError;
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURLorigin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin, nil );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if is_set(Minutes) then
			if is_set (Time) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'minutes') .. ' and ' .. wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
		OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;		-- TODO: presentation

	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

	--[[
	Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
	note is displayed. There are no error messages for this condition.
	
	]]
	if is_set (SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif is_set (RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text

		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {IdAccessLevels=ID_access_levels, DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin, UrlAccess );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then				-- if first and last characters of quote are quote marks
			Quote = Quote:sub(2,-2);											-- strip them off
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- DeadURL is empty, 'yes', 'true', 'y', 'unfit', 'usurped'
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if in_array (DeadURL, {'unfit', 'usurped', 'bot: unknown'}) then
				Archived = sepc .. &quot; &quot; .. 'Archived from the original on ' .. ArchiveDate;	-- format already styled
				if 'bot: unknown' == DeadURL then
					add_maint_cat ('bot:_unknown');								-- and add a category if not already added
				else
					add_maint_cat ('unfit');									-- and add a category if not already added
				end
			else																-- DeadURL is empty, 'yes', 'true', or 'y'
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURLorigin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURLorigin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin, nil );
	end

	local Publisher;
	if is_set(PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if is_set(PublisherName) then
		if is_set(PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif is_set(PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = safe_join ({Others, sepc .. &quot; &quot;}, sepc) end		-- add terminal punctuation &amp; space; check for dup sepc; TODO why do we need to do this here?
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(Periodical) then		-- special cases for book cites
		if is_set (Contributors) then											-- when we are citing foreword, preface, introduction, etc
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Transcript, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if is_set(Date) then
		if is_set (Authors) or is_set (Editors) then							-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;;				-- in paranetheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon,-1,-1) == sepc) then							-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigYear;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigYear;							-- Date begins with sepc
			end
		end
	end	
	if is_set(Authors) then
		if (not is_set (Date)) then												-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then
					in_text = in_text:lower()									-- lowercase for cs2
				 end
			else
				if EditorCount &lt;= 1 then
					post_text = &quot;, &quot; .. cfg.messages['editor'];
				else
					post_text = &quot;, &quot; .. cfg.messages['editors'];
				end
			end 
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if is_set (Contributors) then											-- book cite and we're citing the intro, preface, etc
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if is_set (Editors) and is_set (Date) then							-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not is_set (Date)) then											-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = config.CitationClass;
		options.class = &quot;citation &quot; .. config.CitationClass;					-- class=citation required for blue highlight when used with |ref=
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then								-- set reference anchor if appropriate
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			if #namelist &gt; 0 then												-- if there are names in namelist
				id = anchor_id (namelist, year);								-- go make the CITEREF anchor
			else
				id = '';														-- unset
			end
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;(.-)&lt;/span&gt;&quot;, &quot;%1&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then	-- remove &lt;span&gt; tags and other html-like markup; then get length of what remains
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	local render = {};															-- here we collect the final bits for concatenation into the rendered citation

	if is_set(options.id) then													-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render, substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text}));	-- when |ref= is set
	else
		table.insert (render, substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text}));	-- all other cases
	end		

	table.insert (render, substitute (cfg.presentation['ocins'], {OCinSoutput}));		-- append metadata to the citation

	if 0 ~= #z.message_tail then
		table.insert (render, ' ');
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					table.insert (render, error_comment( v[1], v[2] ));
				else
					table.insert (render, error_comment( v[1] .. &quot;; &quot;, v[2] ));
				end
			end
		end
	end

	if 0 ~= #z.maintenance_cats then
		local maint_msgs = {};													-- here we collect all of the maint messages
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			local maint = {};													-- here we assemble a maintenence message
			table.insert (maint, v);											-- maint msg is the category name
			table.insert (maint, ' (');											-- open the link text
			table.insert (maint, make_wikilink (':Category:' .. v, 'link'));	-- add the link
			table.insert (maint, ')');											-- and close it
			table.insert (maint_msgs, table.concat (maint));					-- assemble new maint message and add it to the maint_msgs table
		end
		table.insert (render, substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs, ' ')));	-- wrap the group of maint message with proper presentation and save
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			table.insert (render, make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			table.insert (render, make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.properties_cats ) do								-- append properties categories
			table.insert (render, make_wikilink ('Category:' .. v));
		end
	end

	return table.concat (render);	
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class)
	local name = tostring (name);
	local state;
	
	if in_array (cite_class, {'arxiv', 'biorxiv', 'citeseerx'}) then			-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[name];
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end

		state = whitelist[cite_class .. '_basic_arguments'][name];				-- look in the parameter-list for the template identified by cite_class

		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
																				-- limited enumerated parameters list
		name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
		state = whitelist.limited_numbered_arguments[name];
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates
		
	state = whitelist.basic_arguments[name];									-- all other templates; all normal parameters allowed
											
	if true == state then return true; end										-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);											-- parameter is deprecated but still supported
		return true;
	end
																				-- all enumerated parameters allowed
	name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );												-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
	state = whitelist.numbered_arguments[name];

	if true == state then return true; end										-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);											-- parameter is deprecated but still supported
		return true;
	end
	
	return false;																-- not supported because not found or name is set to nil
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe:
	{{cite ... |title=Title access-date=2016-03-17}}

cs1|2 shares some parameter names with xml/html atributes: class=, title=, etc.  To prevent false positives xml/html
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove xml/html tags because attributes: class=, title=, etc 

	capture = value:match ('%s+(%a[%a%d]+)%s*=') or value:match ('^(%a[%a%d]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then								-- if the capture is a valid parameter name
		add_maint_cat ('missing_pipe');
	end
end


--[[--------------------------&lt; C S 1 . C I T A T I O N &gt;------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

function cs1.citation(frame)
	Frame = frame;																-- save a copy incase we need to display an error message in preview mode
	local pframe = frame:getParent()
	local validation, utilities, identifiers, metadata, styles;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		styles = 'Module:Citation/CS1/sandbox/styles.css';
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
		styles = 'Module:Citation/CS1/styles.css';

	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	dates = validation.dates;													-- imported functions from Module:Citation/CS1/Date validation
	year_date_check = validation.year_date_check;
	reformat_dates = validation.reformat_dates;
	date_hyphen_to_dash = validation.date_hyphen_to_dash;
	date_name_xlate = validation.date_name_xlate;

	is_set = utilities.is_set;													-- imported functions from Module:Citation/CS1/Utilities
	in_array = utilities.in_array;
	substitute = utilities.substitute;
	error_comment = utilities.error_comment;
	set_error = utilities.set_error;
	select_one = utilities.select_one;
	add_maint_cat = utilities.add_maint_cat;
	wrap_style = utilities.wrap_style;
	safe_for_italics = utilities.safe_for_italics;
	is_wikilink = utilities.is_wikilink;
	make_wikilink = utilities.make_wikilink;

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	extract_ids = identifiers.extract_ids;										-- imported functions from Module:Citation/CS1/Identifiers
	build_id_list = identifiers.build_id_list;
	is_embargoed = identifiers.is_embargoed;
	extract_id_access_levels = identifiers.extract_id_access_levels;
	
	make_coins_title = metadata.make_coins_title;								-- imported functions from Module:Citation/CS1/COinS
	get_coins_pages = metadata.get_coins_pages;
	COinS = metadata.COinS;

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text, error_state;

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do
		config[k] = v;
--		args[k] = v;															-- debug tool that allows us to render a citation from module {{#invoke:}}
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower(), config.CitationClass ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute (param, capture);				-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text, error_state = set_error ('parameter_ignored_suggest', {k, param}, true);	-- set the suggestion error message
							else
								error_text, error_state = set_error( 'parameter_ignored', {param}, true );	-- suggested param not supported by this template
							end
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			missing_pipe_check (v);												-- do we think that there is a parameter that is missing a pipe?
																				-- TODO: is this the best place for this translation?
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then						-- here when v is empty string
			args[k] = v;														-- why do we do this?  we don't support 'empty' parameters
		end		
	end	

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);
		end
	end
	return table.concat ({citation0( config, args), frame:extensionTag ('templatestyles', '', {src=styles})});
end

return cs1;</text>
      <sha1>joi81l849z6qez35g2part0ri125vm5</sha1>
    </revision>
    <revision>
      <id>4723</id>
      <parentid>4722</parentid>
      <timestamp>2019-04-20T13:20:22Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4723</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="177894" sha1="jzwo2dr3jrjgr6d0tp46g4ca3srpo7r" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local dates, year_date_check, reformat_dates, date_hyphen_to_dash,				-- functions in Module:Citation/CS1/Date_validation
	date_name_xlate

local is_set, in_array, substitute, error_comment, set_error, select_one,		-- functions in Module:Citation/CS1/Utilities
	add_maint_cat, wrap_style, safe_for_italics, is_wikilink, make_wikilink;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local extract_ids, extract_id_access_levels, build_id_list, is_embargoed;		-- functions in Module:Citation/CS1/Identifiers

local make_coins_title, get_coins_pages, COinS;									-- functions in Module:Citation/CS1/COinS

local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

delare variables here that have page-wide scope that are not brought in from other modules; thatare created here
and used here

]]

local added_deprecated_cat;														-- boolean flag so that the category is added only once
local added_prop_cats = {};														-- list of property categories that have been added to z.properties_cats
local added_vanc_errs;															-- boolean flag so we only emit one Vancouver error / category

local Frame;																	-- holds the module's frame table


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

foreign_lang_source and foreign_lang_source_2 keys have a language code appended to them so that multiple languages
may be categorized but multiples of the same language are not categorized.

added_prop_cats is a table declared in page scope variables above

]]

local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		key = key:gsub ('(foreign_lang_source_?2?)%a%a%a?', '%1');				-- strip lang code from keyname
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));		-- make name then add to table
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a boolean declared in page scope variables above

]]

local function add_vanc_error (source)
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {source}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a uri scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of tlds: https://www.iana.org/domains/root/db

rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the tld.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a url with a scheme) will be stripped
here.  Perhaps not necessary but retained incase it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ascii characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the tld) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and tld or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%a%d]') then										-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at wikisource
		return false;
	end
																				-- Do most common case first
	if domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.%a%a+$') then				-- three or more character hostname.hostname or hostname.tld
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.xn%-%-[%a%d]+$') then	-- internationalized domain name with ACE prefix
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.cash$') then							-- one character/digit .cash hostname
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.today') then							-- one character/digit .today hostname
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.org$') then							-- one character/digit .org hostname
		return true;
	elseif domain:match ('%f[%a][qxz]%.com$') then								-- assigned one character .com hostname (x.com times out 2015-12-10)
		return true;
	elseif domain:match ('%f[%a][iq]%.net$') then								-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.%a%a$') then							-- one character hostname and cctld (2 chars)
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d]%.%a%a+$') then					-- two character hostname and tld
		return true;
	elseif domain:match ('^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?') then		-- IPv4 address
		return true;
	else
		return false;
	end
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a url appear to be a valid url; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if is_set (scheme) then														-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when url is protocol relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a url into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following tld) (if any) and any path(/), query(?) or fragment(#).

If protocol relative url, return nil scheme and domain else return nil for both scheme and domain.

When not protocol relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol relative url
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		authority = authority:gsub ('//', '', 1);								-- replace place 1 pair of '/' with nothing;
		if is_set(authority) then												-- if anything left (1 or 3+ '/' where authority should be) then
			return scheme;														-- return scheme only making domain nil which will cause an error message
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link= etc for properly formatted content: no wikilinks, no urls

Link parameters are to hold the title of a wikipedia article so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki urls and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid url (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid url (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from url; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid url
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wikilinked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

]]

local function link_title_ok (link, lorig, title, torig)
local orig;

	if is_set (link) then 														-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		end
	end

	if is_set (orig) then
		table.insert( z.message_tail, { set_error( 'bad_paramlink', orig)});	-- url or wikilink in |title= with |title-link=;
	end
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the url into scheme and domain
portions, or for protocol relative (//example.com) urls, just the domain.  Use is_url() to validate the two
portions of the url.  If both are valid, or for protocol relative if domain is valid, return true, else false.

Because it is different from a standard url, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper url
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from url;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a url.  The test will also find external wikilinks
that use protocol relative urls. Also finds bare urls.

The frontier pattern prevents a match on interwiki links which are similar to scheme:path urls.  The tests that
find bracketed urls are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol relative ext wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare url with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol relative bare url: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a url
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then												-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source, access)
	local error_str = &quot;&quot;;
	local domain;
	local path;
	local base_url;

	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the url into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['[']='%5b',[']']='%5d'});					-- replace '[' and ']' with their percent encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wikimarkup url

	if is_set (access) then														-- access level (subscription, registration, limited)
		base_url = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end
	
	return table.concat ({base_url, error_str});
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Replaces unicode quotemarks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc; not for book titles.

]=]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	local wl_type, label, link;

	wl_type, label, link = is_wikilink (str);									-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = substitute (cfg.presentation['kern-wl-both'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = substitute (cfg.presentation['kern-wl-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = substitute (cfg.presentation['kern-wl-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label= mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label= mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap, cap2 = mw.ustring.match (label, &quot;^([\&quot;\'])([^\'].+)&quot;);				-- match leading double or single quote but not doubled single quotes (italic markup)
		if is_set (cap) then
			label = substitute (cfg.presentation['kern-left'], {cap, cap2});
		end
	
		cap, cap2 = mw.ustring.match (label, &quot;^(.+[^\'])([\&quot;\'])$&quot;)				-- match trailing double or single quote but not doubled single quotes (italic markup)
		if is_set (cap) then
			label = substitute (cfg.presentation['kern-right'], {cap, cap2});
		end
		
		if 2 == wl_type then
			str = make_wikilink (link, label);									-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title= and |script-chapter=

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_code_remap[lang] or mw.language.fetchLanguageName( lang, &quot;en&quot; );	-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, cfg.script_lang_codes) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				add_prop_cat ('script')
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return substitute( msg, str );										-- including template text
	else
		return substitute( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;----------------------------------------

makes a wikisource url from wikisource interwiki link.  returns the url and appropriate label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;

	wl_type, D, L = is_wikilink (str);											-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if is_set (str) then
			ws_url = table.concat ({											-- build a wikisource url
				'https://en.wikisource.org/wiki/',								-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the url
		end
	elseif 1 == wl_type then														-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if is_set (str) then
			ws_url = table.concat ({											-- build a wikisource url
				'https://en.wikisource.org/wiki/',								-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the url
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a wikisource url
				'https://en.wikisource.org/wiki/',								-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end
	
	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable url
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent encoding of anchor
	end

	return ws_url, ws_label, L or D;													-- return proper url or nil and a label or nil
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (scriptchapter, chapter, transchapter, chapterurl, chapter_url_source, no_quotes, access)
	local chapter_error = '';

	local ws_url, ws_label, L = wikisource_url_make (chapter);						-- make a wikisource url and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', '');										-- replace underscore separaters with space characters
		chapter = ws_label;
	end

	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
			chapter = wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, scriptchapter)						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (chapterurl) then
		chapter = external_link (chapterurl, chapter, chapter_url_source, access);		-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');		-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if is_set (transchapter) then
		transchapter = wrap_style ('trans-quoted-title', transchapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. transchapter;
		else																	-- here when transchapter without chapter or script-chapter
			chapter = transchapter;												-- 
			chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
		end
	end

--	if is_set (chapterurl) then
--		chapter = external_link (chapterurl, chapter, chapter_url_source, access);		-- adds bare_url_missing_title error if appropriate
--	end

	return chapter .. chapter_error;
end


--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i=1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- Test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position and (char == 'zero width joiner') then						-- if we found a zero width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- its ok if one of the indic scripts
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { set_error( 'invisible_char', {err_msg, wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i=i+1;																	-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash under certain conditions.  The hyphen must separate like items; unlike items are
returned unmodified.  These forms are modified:
	letter - letter (A - B)
	digit - digit (4-5)
	digit separator digit - digit separator digit (4.1-4.5 or 4-1-4-5)
	letterdigit - letterdigit (A1-A5) (an optional separator between letter and digit is supported – a.1-a.5 or a-1-a-5)
	digitletter - digitletter (5a - 5d) (an optional separator between letter and digit is supported – 5.a-5.d or 5-a-5-d)

any other forms are returned unmodified.

str may be a comma- or semicolon-separated list

]]

local function hyphen_to_dash( str )
	if not is_set (str) then
		return str;
	end
	
	str, count = str:gsub ('^%(%((.+)%)%)$', '%1');								-- remove accept-this-as-written markup when it wraps all of str
	if 0 ~= count then															-- non-zero when markup removed; zero else
		return str;																-- nothing to do, we're done
	end
	
	str = str:gsub ('&amp;[nm]dash;', {['&amp;ndash;'] = '–', ['&amp;mdash;'] = '—'});		-- replace &amp;mdash; and &amp;ndash; entities  with their characters; semicolon mucks up the text.split
	
	local out = {};
	local list = mw.text.split (str, '%s*[,;]%s*');								-- split str at comma or semicolon separators if there are any

	for _, item in ipairs (list) do												-- for each item in the list
		if mw.ustring.match (item, '^%w*[%.%-]?%w+%s*[%-–—]%s*%w*[%.%-]?%w+$') then	-- if a hyphenated range or has endash or emdash separators
			if item:match ('%a+[%.%-]?%d+%s*%-%s*%a+[%.%-]?%d+') or				-- letterdigit hyphen letterdigit (optional separator between letter and digit)
				item:match ('%d+[%.%-]?%a+%s*%-%s*%d+[%.%-]?%a+') or			-- digitletter hyphen digitletter (optional separator between digit and letter)
				item:match ('%d+[%.%-]%d+%s*%-%s*%d+[%.%-]%d+') or				-- digit separator digit hyphen digit separator digit
				item:match ('%d+%s*%-%s*%d+') or								-- digit hyphen digit
				item:match ('%a+%s*%-%s*%a+') then								-- letter hyphen letter
					item = item:gsub ('(%w*[%.%-]?%w+)%s*%-%s*(%w*[%.%-]?%w+)', '%1–%2');	-- replace hyphen, remove extraneous space characters
			else
				item = mw.ustring.gsub (item, '%s*[–—]%s*', '–');				-- for endash or emdash separated ranges, replace em with en, remove extraneous white space
			end
		end
		item = item:gsub ('^%(%((.+)%)%)$', '%1');								-- remove the accept-this-as-written markup
		table.insert (out, item);												-- add the (possibly modified) item to the output table
	end

	return table.concat (out, ', ');											-- concatenate the output table into a comma separated string
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'dupicate character'
		if 1 == #duplicate_char then											-- for single byte ascii characters use the string library functions
			f.gsub=string.gsub
			f.match=string.match
			f.sub=string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub=mw.ustring.gsub
			f.match=mw.ustring.match
			f.sub=mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1,1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = f.sub(str, -1,-1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if f.sub(str, -3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5,-1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4,-1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if f.sub(str, -3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3,-1) == duplicate_char .. '&quot;]' then		-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2,-1) == duplicate_char .. &quot;]&quot; then		-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4,-1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2,-1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows html markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;------------------------------------------------------------

returns true is suffix is properly formed Jr, Sr, or ordinal in the range 2–9.  Puncutation not allowed.

]]

local function is_suffix (suffix)
	if in_array (suffix, {'Jr', 'Sr', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written ouside of the code editor and pasted here because the code editor gets confused between character insertion point and cursor position.
The test has been rewritten to use decimal character escape sequence for the individual bytes of the unicode characters so that it is not necessary
to use an external editor to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first)
	local first, suffix = first:match ('(.-),?%s*([%dJS][%drndth]+)%.?$') or first;		-- if first has something that looks like a generational suffix, get it

	if is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error ('suffix');
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error ('non-Latin character');
			return false;														-- not a string of latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just intials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error ('suffix');									-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word


	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i],1,1));				-- insert the intial at end of initials table
		end
		i = i+1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between authors is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between authors is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = make_wikilink (person.link, one);						-- link author/editor if this page is not the author's/editor's page
				end
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end


--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]
local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of name parameters (author, editor, etc) for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the associated |display-&lt;names&gt;=etal parameter

]]

local function name_has_etal (name, etal, nocat, param)

	if is_set (name) then														-- name can be nil in which case just return
		local patterns = cfg.et_al_patterns;									--get patterns from configuration
		
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns
			if name:match (pattern) then										-- if this 'et al' pattern is found in name
				name = name:gsub (pattern, '');									-- remove the offending text
				etal = true;													-- set flag (may have been set previously here or by |display-&lt;names&gt;=etal)
				if not nocat then												-- no categorization for |vauthors=
					table.insert( z.message_tail, {set_error ('etal', {param})});		-- and set an error if not added
				end
			end
		end
	end

	return name, etal;															-- 
end


--[[--------------------------&lt; N A M E _ H A S _ E D _ M A R K U P &gt;------------------------------------------

Evaluates the content of author and editor parameters for extranious editor annotations: ed, ed., eds, (Ed.), etc.
These annotation do not belong in author parameters and are redundant in editor parameters.  If found, the function
adds the editor markup maintenance category.

]]

local function name_has_ed_markup (name, list_name)
	local _, pattern;
	local patterns = cfg.editor_markup_patterns;								-- get patterns from configuration

	if is_set (name) then
		for _, pattern in ipairs (patterns) do									-- spin through patterns table and
			if name:match (pattern) then
				add_maint_cat ('extra_text_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
				break;
			end
		end
	end
	return name;																-- and done
end


--[[--------------------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;----------------------------------------

Evaluates the content of author and editor (surnames only) parameters for multiple names.  Multiple names are
indicated if there is more than one comma and or semicolon.  If found, the function adds the multiple name
(author or editor) maintenance category.

]]

local function name_has_mult_names (name, list_name)
local count, _;
	if is_set (name) then
		_, count = name:gsub ('[;,]', '');										-- count the number of separator-like characters
		
		if 1 &lt; count then														-- param could be |author= or |editor= so one separator character is acceptable
			add_maint_cat ('mult_names', cfg.special_case_translation [list_name]);	-- more than one separator indicates multiple names so add a maint cat for this template
		end
	end
	return name;																-- and done
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------
This function calls various name checking functions used to validate the content of the various name-holding
parameters.

]]

local function name_checks (last, first, list_name)
	if is_set (last) then
		if last:match ('^%(%(.*%)%)$') then										-- if wrapped in doubled parentheses, accept as written 
			last = last:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			last = name_has_mult_names (last, list_name);						-- check for multiple names in the parameter (last only)
			last = name_has_ed_markup (last, list_name);						-- check for extraneous 'editor' annotation
		end
	end
	if is_set (first) then
		if first:match ('^%(%(.*%)%)$') then									-- if wrapped in doubled parentheses, accept as written 
			first = first:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			first = name_has_ed_markup (first, list_name);						-- check for extraneous 'editor' annotation
		end
	end
	return last, first;															-- done
	end


--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local last_alias, first_alias;												-- selected parameter aliases used in error messaging
	while true do
		last, last_alias = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first, first_alias = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.
		last, first= name_checks (last, first, list_name);						-- multiple names, extraneous annotation, etc checks
		
		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {first_alias, first_alias:gsub('first', 'last')}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			link_title_ok (link, list_name:match (&quot;(%w+)List&quot;):lower() .. '-link' .. i, last, list_name:match (&quot;(%w+)List&quot;):lower() .. '-last' .. i);	-- check for improper wikimarkup

			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {list_name:match (&quot;(%w+)List&quot;):lower(), i-1}, true ) } );	-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because case of the source may be incorrect
or different from the case that WikiMedia uses, the name comparisons are done in lower case and when a match is
found, the Wikimedia version (assumed to be correct) is returned along with the code.  When there is no match, we
return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') returns a list of languages that in some cases may include
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.  Most (all?) of these languages are not used a 'language' codes per se, rather they
are used as sub-domain names: cbk-zam.wikipedia.org.  A list of language names and codes supported by fetchLanguageNames()
can be found at Template:Citation Style documentation/language/doc

Names that are included in the list will be found if that name is provided in the |language= parameter.  For example,
if |language=Chavacano de Zamboanga, that name will be found with the associated code 'cbk-zam'.  When names are found
and the associated code is not two or three characters, this function returns only the WikiMedia language name.

Some language names have multiple entries under different codes:
	Aromanian has code rup and code roa-rup
When this occurs, this function returns the language name and the 2- or 3-character code

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	if cfg.lang_name_remap[lang:lower()] then									-- if there is a remapped name (because MediaWiki uses something that we don't think is correct)
		return cfg.lang_name_remap[lang:lower()][1], cfg.lang_name_remap[lang:lower()][2];	-- for this language 'name', return a possibly new name and appropriate code
	end

	local ietf_code;															-- because some languages have both ietf-like codes and iso 639-like codes
	local ietf_name;
	
	local languages = mw.language.fetchLanguageNames(this_wiki_code, 'all')		-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons

	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 == code:len() or 3 == code:len() then							-- two- or three-character codes only; extensions not supported
				return name, code;												-- so return the name and the code
			end
			ietf_code = code;													-- remember that we found an ietf-like code and save its name
			ietf_name = name;													-- but keep looking for a 2- or 3-char code
		end
	end
																				-- didn't find name with 2- or 3-char code; if ietf-like code found return
	return ietf_code and ietf_name or lang;										-- associated name; return original language text else
end


--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code is recognized by MediaWiki,
use the returned name; if not, then use the value that was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is assigned to the category for
that code: Category:Norwegian-language sources (no).  For valid three-character code languages, the page is assigned
to the single category for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does not recognize three-character
equivalents of two-character codes: code 'ar' is recognized bit code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are
separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki = mw.getContentLanguage();									-- get a language object for this wiki
	local this_wiki_code = this_wiki:getCode()									-- get this wiki's language code
	local this_wiki_name = mw.language.fetchLanguageName(this_wiki_code, this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang
		name = cfg.lang_code_remap[lang:lower()];								-- first see if this is a code that is not supported by MediaWiki but is in remap

		if name then															-- there was a remapped code so
			lang = lang:gsub ('^(%a%a%a?)%-.*', '%1');							-- strip ietf tags from code
		else
			if lang:match ('^%a%a%-') then										-- strip ietf tags from code; TODO: is there a need to support 3-char with tag?
				lang = lang:match ('(%a%a)%-')									-- keep only 639-1 code portion to lang; TODO: do something with 3166 alpha 2 country code?
			end
			if 2 == lang:len() or 3 == lang:len() then							-- if two-or three-character code
				name = mw.language.fetchLanguageName (lang:lower(), this_wiki_code);	-- get language name if |language= is a proper code
			end
		end

		if is_set (name) then													-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, this_wiki_code);				-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then													-- only 2- or 3-character codes
			name = cfg.lang_code_remap[code] or name;							-- override wikimedia when they misuse language codes/names

			if this_wiki_code ~= code then										-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					add_prop_cat ('foreign_lang_source' .. code, {name, code})	-- categorize it
				else															-- or is a recognized language (but has a three-character code)
					add_prop_cat ('foreign_lang_source_2' .. code, {code})		-- categorize it differently TODO: support mutliple three-character code categories per cs1|2 template
				end
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, cfg.messages['parameter-pair-separator'])		-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		name = table.concat (language_list, ', ');											-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
		name = name:gsub (', ([^,]+)$', cfg.messages['parameter-final-separator'] .. '%1');	-- replace last '&lt;comma&gt;&lt;space&gt;' separator with '&lt;comma&gt;&lt;space&gt;and&lt;space&gt;' separator
	end
	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings
At en.wiki, for cs1:
	ps gets:	'.'
	sep gets:	'.'

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = cfg.presentation['ps_cs1'];										-- terminate the rendered citation
	end
	return cfg.presentation['sep_cs1'], ps;										-- element separator
end


--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings
At en.wiki, for cs2:
	ps gets:	'' (empty string - no terminal punctuation)
	sep gets:	','

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = cfg.presentation['ps_cs2'];										-- terminate the rendered citation
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return cfg.presentation['sep_cs2'], ps, ref;								-- element separator
end


--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end


--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end


--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or
		url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
		url:match ('%.PDF&amp;#035') or url:match ('%.pdf&amp;#035');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parentheses, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[--------------------------&lt; G E T _ D I S P L A Y _ N A M E S &gt;--------------------------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_names (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_name', cfg.special_case_translation [list_name]);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parnetheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a place holder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parens
			local name = name_table[i];
			i=i+1;																-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parens
					break;														-- and done reassembling so
				end
				i=i+1;															-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = is_wikilink (name_table[i]);					-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i+1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parentheses to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')								-- remove doubled parntheses
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error ('punctuation');
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
			if is_suffix (first) then											-- if a valid suffix
				suffix = first													-- save it as a suffix and
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end																	-- no suffix error message here because letter combination may be result of Romanization; check for digits?
			last = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error ('missing comma');								-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error ('name');										-- matches a space between two intiials
			end
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error ('initials');									-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first);									-- check first and last before restoring the suffix which may have a non-Latin digit
			if is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '');
			end
		end

		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ) or v_link_table[i];
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice incase we have a |first1= without a |last1=; this ...
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or	-- ... also catches the case where |first= is used with |vauthors=
		select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, no, etc).  When the parameter value has not been assigned a value (missing or empty
in the source template) the function returns true.  If the parameter value is one of the list of allowed values returns
true; else, emits an error message and returns false.

]]

local function is_valid_parameter_value (value, name, possible)
	if not is_set (value) then
		return true;															-- an empty parameter is ok
	elseif in_array(value:lower(), possible) then
		return true;
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list,-3,-1) == sepc .. '. ') then						-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list,-1,-1) == sepc) or (string.sub (name_list,-3,-1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terninate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not is_set (volume) and not is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end

	local vol = '';																-- here for all cites except magazine
		
	if is_set (volume) then
		if volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$')then			-- volume value is all digits or all uppercase roman numerals
			vol = substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});	-- render in bold face
		elseif (4 &lt; mw.ustring.len(volume)) then								-- not all digits or roman numerals and longer than 4 characters
			vol = substitute (cfg.messages['j-vol'], {sepc, volume});			-- not bold
			add_prop_cat ('long_vol');
		else																	-- four or less characters
			vol = substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});	-- bold
		end
	end
	if is_set (issue) then
		return vol .. substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if is_set (page) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif is_set(pages) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then										-- if pages is only digits, assume a single page number
			return '', substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to wikisource, returns the label portion of the interwikilink as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki link to and external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, pages, at)
	local ws_url, ws_label, coins_pages, L;										-- for wikisource interwikilinks; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if is_set (page) then
		if is_set (pages) or is_set(at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws url from |page= interwiki link; link portion L becomes tool tip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif is_set (pages) then
		if is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws url from |pages= interwiki link; link portion L becomes tool tip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws url from |at= interwiki link; link portion L becomes tool tip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end



--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org urls to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot url or to calendar pages.  When the archive url is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the url.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org url does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command url
	|archive-url= is an archive.org url that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org urls:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this funct may return a modified
archive url:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the url unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.or url
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine url
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command url, we don't want to allow saving of the target page 
		err_msg = 'save command';
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = 'liveweb';
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');		-- split out some of the url parts for evaluation
		
		if not is_set(timestamp) or 14 ~= timestamp:len() then					-- path and flag optional, must have 14-digit timestamp here
			err_msg = 'timestamp';
			if '*' ~= flag then
				url=url:gsub ('(//web%.archive%.org/[^%d]*%d?%d?%d?%d?%d?%d?)[^/]*', '%1*', 1)	-- for preview, modify ts to be yearmo* max (0-6 digits plus splat)
			end
		elseif is_set(path) and 'web/' ~= path then								-- older archive urls do not have the extra 'web/' path element
			err_msg = 'path';
		elseif is_set (flag) and not is_set (path) then							-- flag not allowed with the old form url (without the 'web/' path element)
			err_msg = 'flag';
		elseif is_set (flag) and not flag:match ('%a%a_') then					-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = 'flag';
		else
			return url, date;													-- return archiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	table.insert( z.message_tail, { set_error( 'archive_url', {err_msg}, true ) } );	-- add error message and
	if is_set (Frame:preprocess('{{REVISIONID}}')) then
		return '', '';															-- return empty strings for archiveURL and ArchiveDate
	else
		return url, date;														-- preview mode so return archiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

-- set default parameter values defined by |mode= parameter.
	local Mode = A['Mode'];
	if not is_valid_parameter_value (Mode, 'mode', cfg.keywords['mode']) then
		Mode = '';
	end

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				add_maint_cat ('authors');										-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
			add_maint_cat ('editors');											-- but add a maint cat because use of this parameter is discouraged
		end
	end

	local translator_etal;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=

	local interviewer_etal;
	local interviewers_list = {};												
	local Interviewers;															-- used later
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters

	local contributor_etal;
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list
	local Contribution = A['Contribution'];
	if in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not is_set (Contribution) then									-- |contributor= requires |contribution=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if select_one (args, cfg.aliases['ContributorList-Last'], 'redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { set_error( 'contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if not is_valid_parameter_value (NameListFormat, 'name-list-format', cfg.keywords['name-list-format']) then			-- only accepted value for this parameter is 'vanc'
		NameListFormat = '';													-- anything else, set to empty string
	end

if is_set (Others) then
	if 0 == #a and 0 == #e then									-- add maint cat when |others= has value and used without |author=, |editor=
		add_maint_cat ('others');
	end
end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
			link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wikimarkup in |title-link= or wikimarkup in |title= when |title-link= is set

	local Chapter = A['Chapter'];
	local ScriptChapter = A['ScriptChapter'];
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];

	local ArchiveDate;
	local ArchiveURL;

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	
	local DeadURL = A['DeadURL']
		if not is_valid_parameter_value (DeadURL, 'dead-url', cfg.keywords ['deadurl']) then	-- set in config.defaults to 'yes'
			DeadURL = '';														-- anything else, set to empty string
		end

	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];
	local Periodical_origin = A:ORIGIN('Periodical');							-- get the name of the periodical parameter

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if in_array (config.CitationClass, cfg.templates_using_volume) then
		Volume = A['Volume'];
	end
																				-- conference &amp; map books do not support issue
	if in_array (config.CitationClass, cfg.templates_using_issue) and not (in_array (config.CitationClass, {'conference', 'map'}) and not is_set (Periodical))then
		Issue = hyphen_to_dash (A['Issue']);
	end
	local Position = '';
	if not in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash (A['Pages']);	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
		if not is_valid_parameter_value (RegistrationRequired, 'registration', cfg.keywords ['yes_true_y']) then
			RegistrationRequired=nil;
		end

	local SubscriptionRequired = A['SubscriptionRequired'];
		if not is_valid_parameter_value (SubscriptionRequired, 'subscription', cfg.keywords ['yes_true_y']) then
			SubscriptionRequired=nil;
		end

	local UrlAccess = A['UrlAccess'];
		if not is_valid_parameter_value (UrlAccess, 'url-access', cfg.keywords ['url-access']) then
			UrlAccess = nil;
		end
		if not is_set(URL) and is_set(UrlAccess) then
			UrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {'url'}, true ) } );
		end

		if is_set (UrlAccess) and is_set (SubscriptionRequired) then			-- while not aliases, these are much the same so if both are set
			table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'url-access') .. ' and ' .. wrap_style ('parameter', 'subscription')}, true ) } );		-- add error message
			SubscriptionRequired = nil;											-- unset; prefer |access= over |subscription=
		end
		if is_set (UrlAccess) and is_set (RegistrationRequired) then			-- these are not the same but contradictory so if both are set
			table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'url-access') .. ' and ' .. wrap_style ('parameter', 'registration')}, true ) } );		-- add error message
			RegistrationRequired = nil;											-- unset; prefer |access= over |registration=
		end

	local ChapterUrlAccess = A['ChapterUrlAccess'];
		if not is_valid_parameter_value (ChapterUrlAccess, 'chapter-url-access', cfg.keywords ['url-access']) then	-- same as url-access
			ChapterUrlAccess = nil;
		end
		if not is_set(ChapterURL) and is_set(ChapterUrlAccess) then
			ChapterUrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {'chapter-url'}, true ) } );
		end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local Agency = A['Agency'];

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
		if not is_valid_parameter_value (IgnoreISBN, 'ignore-isbn-error', cfg.keywords ['yes_true_y']) then
			IgnoreISBN = nil;													-- anything else, set to empty string
		end
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );
	local ID_access_levels = extract_id_access_levels( args, ID_list );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
		if not is_valid_parameter_value (LastAuthorAmp, 'last-author-amp', cfg.keywords ['yes_true_y']) then
			LastAuthorAmp = nil;												-- set to empty string
		end

	local no_tracking_cats = A['NoTracking'];
		if not is_valid_parameter_value (no_tracking_cats, 'no-tracking', cfg.keywords ['yes_true_y']) then
			no_tracking_cats = nil;												-- set to empty string
		end

	--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = A['DF'];															-- date format set in cs1|2 template
	if not is_valid_parameter_value (DF, 'df', cfg.keywords['date-format']) then	-- validate reformatting keyword
		DF = '';																-- not valid, set to empty string
	end
	if not is_set (DF) then
		DF = cfg.global_df;
	end

	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

	--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

	-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	select_one( args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'redundant_parameters' );		-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, Pages, At);

	local NoPP = A['NoPP'] 
	if is_set (NoPP) and is_valid_parameter_value (NoPP, 'nopp', cfg.keywords ['yes_true_y']) then
		NoPP = true;
	else
		NoPP = nil;																-- unset, used as a flag later
	end

	-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia and |title then map |title to |article and |encyclopedia to |title
		|encyclopedia and |article then map |encyclopedia to |title
		|encyclopedia then map |encyclopedia to |title
	
		|trans-title maps to |trans-chapter when |title is re-mapped
		|url maps to |chapterurl when |title is remapped
	
	All other combinations of |encyclopedia, |title, and |article are not modified
	
	]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterUrlAccess = UrlAccess;

					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter = make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			else																-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if is_set(A['Number']) then												-- cite techreport uses 'number', which other citations alias to 'issue'
			if not is_set(ID) then												-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', 'id') .. ' and ' .. wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

	-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	elseif 'mailinglist' == A:ORIGIN('Periodical') then
		Periodical = '';														-- unset because mailing list is only used for cite mailing list
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		ChapterUrlAccess = UrlAccess;
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];

		link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wikimarkup in |series-link= or wikimarkup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) and is_set (AirDate) then							-- promote airdate to date
			Date = AirDate;
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('series', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = make_wikilink (ChapterLink, Chapter);
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = make_wikilink (SeriesLink, Series);
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, before generation of COinS data.
	do
		if in_array (config.CitationClass, {'arxiv', 'biorxiv', 'citeseerx'}) then
			if not is_set (ID_list[config.CitationClass:upper()]) then			-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp; |citeseerx= required for their templates
				table.insert( z.message_tail, { set_error( config.CitationClass .. '_missing', {}, true ) } );		-- add error message
			end
			
			if 'arxiv' == config.CitationClass then
				Periodical = 'arXiv';											-- set to arXiv for COinS; after that, must be set to empty string
			end

			if 'biorxiv' == config.CitationClass then
				Periodical = 'bioRxiv';											-- set to bioRxiv for COinS; after that, must be set to empty string
			end

			if 'citeseerx' == config.CitationClass then
				Periodical = 'CiteSeerX';										-- set to CiteSeerX for COinS; after that, must be set to empty string
			end
		end
	end

	-- handle type parameter for those CS1 citations that have default values
	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;interview&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
		TitleType = substitute( cfg.messages['type'], TitleType);				-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging

	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val=AccessDate, name=A:ORIGIN ('AccessDate')},
			['archive-date'] = {val=ArchiveDate, name=A:ORIGIN ('ArchiveDate')},
			['date'] = {val=Date, name=Date_origin},
			['doi-broken-date'] = {val=DoiBroken, name=A:ORIGIN ('DoiBroken')},
			['embargo'] = {val=Embargo, name=A:ORIGIN ('Embargo')},
			['lay-date'] = {val=LayDate, name=A:ORIGIN ('LayDate')},
			['publication-date'] ={val=PublicationDate, name=A:ORIGIN ('PublicationDate')},
			['year'] = {val=Year, name=A:ORIGIN ('Year')},
			};
		anchor_year, Embargo, error_message = dates(date_parameters_list, COinS_date);

-- start temporary Julian / Gregorian calendar uncertainty categorization
		if COinS_date.inter_cal_cat then
			add_prop_cat ('jul_greg_uncertainty');
		end
-- end temporary Julian / Gregorian calendar uncertainty categorization

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end
		
		if not is_set(error_message) then										-- error free dates only
			local modified = false;												-- flag
			
			if is_set (DF) then													-- if we need to reformat dates
				modified = reformat_dates (date_parameters_list, DF, false);	-- reformat to DF format, use long month names if appropriate
			end

			if true == date_hyphen_to_dash (date_parameters_list) then			-- convert hyphens to dashes where appropriate
				modified = true;
				add_maint_cat ('date_format');									-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language,
	-- uncomment these three lines.  Not supported by en.wiki (for obvious reasons)
	-- set date_name_xlate() second argument to true to translate English digits to local digits (will translate ymd dates)
--			if date_name_xlate (date_parameters_list, false) then
--				modified = true;
--			end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				LayDate = date_parameters_list['lay-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end
		else
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end
	end	-- end of do

	-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
	-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
			if is_set(AccessDate) then											-- access date requires |url=; pmc created url is not |url=
				table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
				AccessDate = '';												-- unset
			end

		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
			if 'episode' == config.CitationClass then							-- special case for cite episode; TODO: is there a better way to do this?
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
			else
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
			end
	end
	
	if 'none' == Title and in_array (config.CitationClass, {'journal', 'citation'}) and is_set (Periodical) and 'journal' == A:ORIGIN('Periodical') then	-- special case for journal cites
		Title = '';																-- set title to empty string
		add_maint_cat ('untitled');
	end

	check_for_url ({															-- add error message when any of these parameters contains a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[A:ORIGIN('Periodical')]=Periodical,
		[A:ORIGIN('PublisherName')] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = Periodical,
		['Encyclopedia'] = Encyclopedia,
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = coins_pages or get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, and {{cite citeseerx}} AFTER generation of COinS data.
	if in_array (config.CitationClass, {'arxiv', 'biorxiv', 'citeseerx'}) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, or CiteSeerX now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = substitute (cfg.messages['newsgroup'], external_link( 'news:' .. PublisherName, PublisherName, A:ORIGIN('PublisherName'), nil ));
		end
	end



	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text,											-- get current page name so that we don't wikilink to it via editorlinkn
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_names (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if is_set (Editors) then
				Editors, editor_etal = name_has_etal (Editors, editor_etal, false, 'editors');	-- find and remove variations on et al.
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
					EditorCount = 2;											-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
				else
					EditorCount = 2;											-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
				end
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum , interviewer_etal = get_display_names (A['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal);
			Interviewers = list_people (control, interviewers_list, interviewer_etal);
		end
		do																		-- now do translators
			control.maximum , translator_etal = get_display_names (A['DisplayTranslators'], #t, 'translators', translator_etal);
			Translators = list_people (control, t, translator_etal);
		end
		do																		-- now do contributors
			control.maximum , contributor_etal = get_display_names (A['DisplayContributors'], #c, 'contributors', contributor_etal);
			Contributors = list_people (control, c, contributor_etal);
--			control.maximum = #c;												-- number of contributors
--			Contributors = list_people(control, c, false);						-- et al not currently supported
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_names (A['DisplayAuthors'], #a, 'authors', author_etal);

			last_first_list = list_people(control, a, author_etal);

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors');	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if is_set (Authors) and is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
	-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not is_set(URL) then
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then	-- |url= required for cite web, cite podcast, and cite mailinglist
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURLorigin, OriginalFormat, OriginalAccess;
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (ChapterURL) then 											-- if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURLorigin = ChapterURLorigin;								-- name of chapter-url parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				ChapterURLorigin = A:ORIGIN('ArchiveURL')						-- name of archive-url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived urls
			end
		elseif is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURLorigin = URLorigin;										-- name of url parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived urls
			end
 		end
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			local chap_param;
			if is_set (Chapter) then											-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif is_set (ScriptChapter) then
				chap_param = A:ORIGIN ('ScriptChapter')
			else is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if is_set (chap_param) then											-- if we found one
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {chap_param}, true ) } );		-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if is_set (Contribution) and 0 &lt; #c then								-- if this is a contribution with contributor(s)
			if in_array (Contribution:lower(), cfg.keywords.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, Chapter, TransChapter, ChapterURL, ChapterURLorigin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter.. sepc .. ' ';
		elseif is_set (ChapterFormat) then										-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title.
	if is_set (ArchiveURL) and mw.ustring.match (mw.ustring.lower(Title), cfg.special_case_translation['archived_copy']) then	-- if title is 'Archived copy' (place holder added by bots that can't find proper title)
		add_maint_cat ('archived_copy');										-- add maintenance category before we modify the content of Title
	end

	if Title:match ('^%(%(.*%)%)$') then										-- if keep as written markup:
		Title= Title:gsub ('^%(%((.*)%)%)$', '%1')								-- remove the markup
	else
		if '...' == Title:sub (-3) then											-- if elipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%'..sepc..'$', '');				-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end
	end
	
	if in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end

	if is_set(Title) then
		if not is_set (TitleLink) and is_set (URL) then
			Title = external_link (URL, Title, URLorigin, UrlAccess) .. TransTitle .. TransError .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif is_set (TitleLink) and not is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = make_wikilink (TitleLink, Title) .. TransTitle .. TransError;
			end
		else
			local ws_url, ws_label;
			ws_url, ws_label, L = wikisource_url_make (Title);					-- make ws url from |title= interwiki link; link portion L becomes tool tip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = Title .. TransTitle .. TransError;
			end
		end
	else
		Title = TransTitle .. TransError;
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURLorigin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin, nil );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if is_set(Minutes) then
			if is_set (Time) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'minutes') .. ' and ' .. wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
		OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;		-- TODO: presentation

	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

	--[[
	Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
	note is displayed. There are no error messages for this condition.
	
	]]
	if is_set (SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif is_set (RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text

		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {IdAccessLevels=ID_access_levels, DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin, UrlAccess );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then				-- if first and last characters of quote are quote marks
			Quote = Quote:sub(2,-2);											-- strip them off
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- DeadURL is empty, 'yes', 'true', 'y', 'unfit', 'usurped'
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if in_array (DeadURL, {'unfit', 'usurped', 'bot: unknown'}) then
				Archived = sepc .. &quot; &quot; .. 'Archived from the original on ' .. ArchiveDate;	-- format already styled
				if 'bot: unknown' == DeadURL then
					add_maint_cat ('bot:_unknown');								-- and add a category if not already added
				else
					add_maint_cat ('unfit');									-- and add a category if not already added
				end
			else																-- DeadURL is empty, 'yes', 'true', or 'y'
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURLorigin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURLorigin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin, nil );
	end

	local Publisher;
	if is_set(PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if is_set(PublisherName) then
		if is_set(PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif is_set(PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = safe_join ({Others, sepc .. &quot; &quot;}, sepc) end		-- add terminal punctuation &amp; space; check for dup sepc; TODO why do we need to do this here?
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(Periodical) then		-- special cases for book cites
		if is_set (Contributors) then											-- when we are citing foreword, preface, introduction, etc
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon;
	if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then	-- special case for cite AV media &amp; cite episode position transcript
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	else
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	end
	
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if is_set(Date) then
		if is_set (Authors) or is_set (Editors) then							-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;;				-- in paranetheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon,-1,-1) == sepc) then							-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigYear;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigYear;							-- Date begins with sepc
			end
		end
	end	
	if is_set(Authors) then
		if (not is_set (Date)) then												-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then
					in_text = in_text:lower()									-- lowercase for cs2
				end
			end
			if EditorCount &lt;= 1 then
				post_text = &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot;;				-- be consistent with no-author, no-date case
			else
				post_text = &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot;;
			end
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if is_set (Contributors) then											-- book cite and we're citing the intro, preface, etc
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if is_set (Editors) and is_set (Date) then							-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not is_set (Date)) then											-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = config.CitationClass;
		options.class = &quot;citation &quot; .. config.CitationClass;					-- class=citation required for blue highlight when used with |ref=
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then								-- set reference anchor if appropriate
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			if #namelist &gt; 0 then												-- if there are names in namelist
				id = anchor_id (namelist, year);								-- go make the CITEREF anchor
			else
				id = '';														-- unset
			end
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;(.-)&lt;/span&gt;&quot;, &quot;%1&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then	-- remove &lt;span&gt; tags and other html-like markup; then get length of what remains
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	local render = {};															-- here we collect the final bits for concatenation into the rendered citation

	if is_set(options.id) then													-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render, substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text}));	-- when |ref= is set
	else
		table.insert (render, substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text}));	-- all other cases
	end		

	table.insert (render, substitute (cfg.presentation['ocins'], {OCinSoutput}));		-- append metadata to the citation

	if 0 ~= #z.message_tail then
		table.insert (render, ' ');
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					table.insert (render, error_comment( v[1], v[2] ));
				else
					table.insert (render, error_comment( v[1] .. &quot;; &quot;, v[2] ));
				end
			end
		end
	end

	if 0 ~= #z.maintenance_cats then
		local maint_msgs = {};													-- here we collect all of the maint messages
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			local maint = {};													-- here we assemble a maintenence message
			table.insert (maint, v);											-- maint msg is the category name
			table.insert (maint, ' (');											-- open the link text
			table.insert (maint, make_wikilink (':Category:' .. v, 'link'));	-- add the link
			table.insert (maint, ')');											-- and close it
			table.insert (maint_msgs, table.concat (maint));					-- assemble new maint message and add it to the maint_msgs table
		end
		table.insert (render, substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs, ' ')));	-- wrap the group of maint message with proper presentation and save
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			table.insert (render, make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			table.insert (render, make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.properties_cats ) do								-- append properties categories
			table.insert (render, make_wikilink ('Category:' .. v));
		end
	end

	return table.concat (render);	
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class)
	local name = tostring (name);
	local state;
	
	if in_array (cite_class, {'arxiv', 'biorxiv', 'citeseerx'}) then			-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[name];
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end

		state = whitelist[cite_class .. '_basic_arguments'][name];				-- look in the parameter-list for the template identified by cite_class

		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
																				-- limited enumerated parameters list
		name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
		state = whitelist.limited_numbered_arguments[name];
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates
		
	state = whitelist.basic_arguments[name];									-- all other templates; all normal parameters allowed
											
	if true == state then return true; end										-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);											-- parameter is deprecated but still supported
		return true;
	end
																				-- all enumerated parameters allowed
	name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );												-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
	state = whitelist.numbered_arguments[name];

	if true == state then return true; end										-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);											-- parameter is deprecated but still supported
		return true;
	end
	
	return false;																-- not supported because not found or name is set to nil
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe:
	{{cite ... |title=Title access-date=2016-03-17}}

cs1|2 shares some parameter names with xml/html atributes: class=, title=, etc.  To prevent false positives xml/html
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (parameter, value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove xml/html tags because attributes: class=, title=, etc 

	capture = value:match ('%s+(%a[%a%d]+)%s*=') or value:match ('^(%a[%a%d]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then								-- if the capture is a valid parameter name
		table.insert( z.message_tail, {set_error ('missing_pipe',parameter)});
	end
end


--[[--------------------------&lt; C S 1 . C I T A T I O N &gt;------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

local function citation(frame)
	Frame = frame;																-- save a copy incase we need to display an error message in preview mode
	local pframe = frame:getParent()
	local validation, utilities, identifiers, metadata, styles;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		styles = 'Module:Citation/CS1/sandbox/styles.css';
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
		styles = 'Module:Citation/CS1/styles.css';

	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	dates = validation.dates;													-- imported functions from Module:Citation/CS1/Date validation
	year_date_check = validation.year_date_check;
	reformat_dates = validation.reformat_dates;
	date_hyphen_to_dash = validation.date_hyphen_to_dash;
	date_name_xlate = validation.date_name_xlate;

	is_set = utilities.is_set;													-- imported functions from Module:Citation/CS1/Utilities
	in_array = utilities.in_array;
	substitute = utilities.substitute;
	error_comment = utilities.error_comment;
	set_error = utilities.set_error;
	select_one = utilities.select_one;
	add_maint_cat = utilities.add_maint_cat;
	wrap_style = utilities.wrap_style;
	safe_for_italics = utilities.safe_for_italics;
	is_wikilink = utilities.is_wikilink;
	make_wikilink = utilities.make_wikilink;

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	extract_ids = identifiers.extract_ids;										-- imported functions from Module:Citation/CS1/Identifiers
	build_id_list = identifiers.build_id_list;
	is_embargoed = identifiers.is_embargoed;
	extract_id_access_levels = identifiers.extract_id_access_levels;
	
	make_coins_title = metadata.make_coins_title;								-- imported functions from Module:Citation/CS1/COinS
	get_coins_pages = metadata.get_coins_pages;
	COinS = metadata.COinS;

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text, error_state;

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do
		config[k] = v;
--		args[k] = v;															-- debug tool that allows us to render a citation from module {{#invoke:}}
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower(), config.CitationClass ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute (param, capture);				-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text, error_state = set_error ('parameter_ignored_suggest', {k, param}, true);	-- set the suggestion error message
							else
								error_text, error_state = set_error( 'parameter_ignored', {param}, true );	-- suggested param not supported by this template
							end
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?
																				-- TODO: is this the best place for this translation?
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then						-- here when v is empty string
			args[k] = v;														-- why do we do this?  we don't support 'empty' parameters
		end		
	end	

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);
		end
	end
	return table.concat ({citation0( config, args), frame:extensionTag ('templatestyles', '', {src=styles})});
end

--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {citation = citation};</text>
      <sha1>jzwo2dr3jrjgr6d0tp46g4ca3srpo7r</sha1>
    </revision>
    <revision>
      <id>4724</id>
      <parentid>4723</parentid>
      <timestamp>2019-09-03T11:06:03Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4724</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="185337" sha1="s1ptsqky6jla2ch3vxqftih7lhqkoeh" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local dates, year_date_check, reformat_dates, date_hyphen_to_dash,				-- functions in Module:Citation/CS1/Date_validation
	date_name_xlate

local is_set, in_array, substitute, error_comment, set_error, select_one,		-- functions in Module:Citation/CS1/Utilities
	add_maint_cat, wrap_style, safe_for_italics, is_wikilink, make_wikilink,
	strip_apostrophe_markup;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local extract_ids, extract_id_access_levels, build_id_list, is_embargoed;		-- functions in Module:Citation/CS1/Identifiers

local make_coins_title, get_coins_pages, COinS;									-- functions in Module:Citation/CS1/COinS

local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

delare variables here that have page-wide scope that are not brought in from other modules; thatare created here
and used here

]]

local added_deprecated_cat;														-- boolean flag so that the category is added only once
local added_prop_cats = {};														-- list of property categories that have been added to z.properties_cats
local added_vanc_errs;															-- boolean flag so we only emit one Vancouver error / category

local Frame;																	-- holds the module's frame table


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

foreign_lang_source and foreign_lang_source_2 keys have a language code appended to them so that multiple languages
may be categorized but multiples of the same language are not categorized.

added_prop_cats is a table declared in page scope variables above

]]

local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		key = key:gsub ('(foreign_lang_source_?2?)%a%a%a?', '%1');				-- strip lang code from keyname
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));	-- make name then add to table
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a boolean declared in page scope variables above

]]

local function add_vanc_error (source)
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {source}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a uri scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of tlds: https://www.iana.org/domains/root/db

rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the tld.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a url with a scheme) will be stripped
here.  Perhaps not necessary but retained incase it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ascii characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the tld) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and tld or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%w]') then											-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at wikisource
		return false;
	end

	local patterns = {															-- patterns that look like urls
		'%f[%w][%w][%w%-]+[%w]%.%a%a+$',										-- three or more character hostname.hostname or hostname.tld
		'%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$',									-- internationalized domain name with ACE prefix
		'%f[%a][qxz]%.com$',													-- assigned one character .com hostname (x.com times out 2015-12-10)
		'%f[%a][iq]%.net$',														-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		'%f[%w][%w]%.%a%a$',													-- one character hostname and cctld (2 chars)
		'%f[%w][%w][%w]%.%a%a+$',												-- two character hostname and tld
		'^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?',								-- IPv4 address
		}

	for _, pattern in ipairs (patterns) do										-- loop through the patterns list
		if domain:match (pattern) then
			return true;														-- if a match then we think that this thing that purports to be a url is a url
		end
	end

	for _, d in ipairs ({'cash', 'company', 'today', 'org'}) do					-- look for single letter second level domain names for these top level domains
		if domain:match ('%f[%w][%w]%.' .. d) then
			return true
		end
	end
	return false;																-- no matches, we don't know what this thing is
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a url appear to be a valid url; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if is_set (scheme) then														-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when url is protocol relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a url into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following tld) (if any) and any path(/), query(?) or fragment(#).

If protocol relative url, return nil scheme and domain else return nil for both scheme and domain.

When not protocol relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol relative url
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		authority = authority:gsub ('//', '', 1);								-- replace place 1 pair of '/' with nothing;
		if is_set(authority) then												-- if anything left (1 or 3+ '/' where authority should be) then
			return scheme;														-- return scheme only making domain nil which will cause an error message
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link= etc for properly formatted content: no wikilinks, no urls

Link parameters are to hold the title of a wikipedia article so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki urls and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid url (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid url (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from url; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid url
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wikilinked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

]]

local function link_title_ok (link, lorig, title, torig)
local orig;

	if is_set (link) then 														-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		end
	end

	if is_set (orig) then
		table.insert( z.message_tail, { set_error( 'bad_paramlink', orig)});	-- url or wikilink in |title= with |title-link=;
	end
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the url into scheme and domain
portions, or for protocol relative (//example.com) urls, just the domain.  Use is_url() to validate the two
portions of the url.  If both are valid, or for protocol relative if domain is valid, return true, else false.

Because it is different from a standard url, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper url
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from url;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a url.  The test will also find external wikilinks
that use protocol relative urls. Also finds bare urls.

The frontier pattern prevents a match on interwiki links which are similar to scheme:path urls.  The tests that
find bracketed urls are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol relative ext wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare url with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol relative bare url: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a url
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then												-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source, access)
	local error_str = &quot;&quot;;
	local domain;
	local path;
	local base_url;

	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the url into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['[']='%5b',[']']='%5d'});					-- replace '[' and ']' with their percent encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wikimarkup url

	if is_set (access) then														-- access level (subscription, registration, limited)
		base_url = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end
	
	return table.concat ({base_url, error_str});
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );	-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Replaces unicode quotemarks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc; not for book titles.

]=]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	local wl_type, label, link;

	wl_type, label, link = is_wikilink (str);									-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = substitute (cfg.presentation['kern-wl-both'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = substitute (cfg.presentation['kern-wl-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = substitute (cfg.presentation['kern-wl-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label= mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label= mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap, cap2 = mw.ustring.match (label, &quot;^([\&quot;\'])([^\'].+)&quot;);				-- match leading double or single quote but not doubled single quotes (italic markup)
		if is_set (cap) then
			label = substitute (cfg.presentation['kern-left'], {cap, cap2});
		end
	
		cap, cap2 = mw.ustring.match (label, &quot;^(.+[^\'])([\&quot;\'])$&quot;)				-- match trailing double or single quote but not doubled single quotes (italic markup)
		if is_set (cap) then
			label = substitute (cfg.presentation['kern-right'], {cap, cap2});
		end
		
		if 2 == wl_type then
			str = make_wikilink (link, label);									-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title=, |script-chapter=, |script-&lt;periodical&gt;=

]]

local function format_script_value (script_value, script_param)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			table.insert( z.message_tail, { set_error( 'script_parameter', {script_param, 'missing title part'}, true ) } );		-- prefix without 'title'; add error message
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_code_remap[lang] or mw.language.fetchLanguageName( lang, &quot;en&quot; );	-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, cfg.script_lang_codes) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				table.insert( z.message_tail, { set_error( 'script_parameter', {script_param, 'unknown language code'}, true ) } );	-- unknown script-language; add error message
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			table.insert( z.message_tail, { set_error( 'script_parameter', {script_param, 'invalid language code'}, true ) } );		-- invalid language code; add error message
			lang = '';															-- invalid so set lang to empty string
		end
	else
		table.insert( z.message_tail, { set_error( 'script_parameter', {script_param, 'missing prefix'}, true ) } );				-- no language code prefix; add error message
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script, script_param)
	if is_set (script) then
		script = format_script_value (script, script_param);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return substitute( msg, str );											-- including template text
	else
		return substitute( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;----------------------------------------

makes a wikisource url from wikisource interwiki link.  returns the url and appropriate label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;

	wl_type, D, L = is_wikilink (str);											-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if is_set (str) then
			ws_url = table.concat ({											-- build a wikisource url
				'https://en.wikisource.org/wiki/',								-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the url
		end
	elseif 1 == wl_type then														-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if is_set (str) then
			ws_url = table.concat ({											-- build a wikisource url
				'https://en.wikisource.org/wiki/',								-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the url
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a wikisource url
				'https://en.wikisource.org/wiki/',								-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end
	
	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable url
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent encoding of anchor
	end

	return ws_url, ws_label, L or D;											-- return proper url or nil and a label or nil
end


--[[--------------------------&lt; F O R M A T _ P E R I O D I C A L &gt;--------------------------------------------

Format the four periodical parameters: |script-&lt;periodical&gt;=, |&lt;periodical&gt;=, and |trans-&lt;periodical&gt;= into a single Periodical meta-
parameter.

]]

local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)
	local periodical_error = '';

	if not is_set (periodical) then
		periodical = '';														-- to be safe for concatenation
	else
		periodical = wrap_style ('italic-title', periodical);					-- style 
	end

	periodical = script_concatenate (periodical, script_periodical, script_periodical_source);	-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (trans_periodical) then
		trans_periodical = wrap_style ('trans-italic-title', trans_periodical);
		if is_set (periodical) then
			periodical = periodical ..  ' ' .. trans_periodical;
		else																	-- here when transchapter without chapter or script-chapter
			periodical = trans_periodical;
			periodical_error = ' ' .. set_error ('trans_missing_title', {'periodical'});
		end
	end

	return periodical .. periodical_error;
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (scriptchapter, script_chapter_source, chapter, transchapter, chapterurl, chapter_url_source, no_quotes, access)
	local chapter_error = '';

	local ws_url, ws_label, L = wikisource_url_make (chapter);					-- make a wikisource url and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', '');										-- replace underscore separaters with space characters
		chapter = ws_label;
	end

	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
			chapter = wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, scriptchapter, script_chapter_source);	-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (chapterurl) then
		chapter = external_link (chapterurl, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');	-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if is_set (transchapter) then
		transchapter = wrap_style ('trans-quoted-title', transchapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. transchapter;
		else																	-- here when transchapter without chapter or script-chapter
			chapter = transchapter;
			chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
		end
	end

--	if is_set (chapterurl) then
--		chapter = external_link (chapterurl, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
--	end

	return chapter .. chapter_error;
end


--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i=1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- Test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position and (char == 'zero width joiner') then						-- if we found a zero width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- its ok if one of the indic scripts
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { set_error( 'invisible_char', {err_msg, wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i=i+1;																	-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] .. ': ' .. k);
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash under certain conditions.  The hyphen must separate like items; unlike items are
returned unmodified.  These forms are modified:
	letter - letter (A - B)
	digit - digit (4-5)
	digit separator digit - digit separator digit (4.1-4.5 or 4-1-4-5)
	letterdigit - letterdigit (A1-A5) (an optional separator between letter and digit is supported – a.1-a.5 or a-1-a-5)
	digitletter - digitletter (5a - 5d) (an optional separator between letter and digit is supported – 5.a-5.d or 5-a-5-d)

any other forms are returned unmodified.

str may be a comma- or semicolon-separated list

]]

local function hyphen_to_dash( str )
	if not is_set (str) then
		return str;
	end
	
	str, count = str:gsub ('^%(%((.+)%)%)$', '%1');								-- remove accept-this-as-written markup when it wraps all of str
	if 0 ~= count then															-- non-zero when markup removed; zero else
		return str;																-- nothing to do, we're done
	end
	
	str = str:gsub ('&amp;[nm]dash;', {['&amp;ndash;'] = '–', ['&amp;mdash;'] = '—'});		-- replace &amp;mdash; and &amp;ndash; entities  with their characters; semicolon mucks up the text.split
	
	local out = {};
	local list = mw.text.split (str, '%s*[,;]%s*');								-- split str at comma or semicolon separators if there are any

	for _, item in ipairs (list) do												-- for each item in the list
		if mw.ustring.match (item, '^%w*[%.%-]?%w+%s*[%-–—]%s*%w*[%.%-]?%w+$') then	-- if a hyphenated range or has endash or emdash separators
			if item:match ('%a+[%.%-]?%d+%s*%-%s*%a+[%.%-]?%d+') or				-- letterdigit hyphen letterdigit (optional separator between letter and digit)
				item:match ('%d+[%.%-]?%a+%s*%-%s*%d+[%.%-]?%a+') or			-- digitletter hyphen digitletter (optional separator between digit and letter)
				item:match ('%d+[%.%-]%d+%s*%-%s*%d+[%.%-]%d+') or				-- digit separator digit hyphen digit separator digit
				item:match ('%d+%s*%-%s*%d+') or								-- digit hyphen digit
				item:match ('%a+%s*%-%s*%a+') then								-- letter hyphen letter
					item = item:gsub ('(%w*[%.%-]?%w+)%s*%-%s*(%w*[%.%-]?%w+)', '%1–%2');	-- replace hyphen, remove extraneous space characters
			else
				item = mw.ustring.gsub (item, '%s*[–—]%s*', '–');				-- for endash or emdash separated ranges, replace em with en, remove extraneous white space
			end
		end
		item = item:gsub ('^%(%((.+)%)%)$', '%1');								-- remove the accept-this-as-written markup
		table.insert (out, item);												-- add the (possibly modified) item to the output table
	end

	return table.concat (out, ', ');											-- concatenate the output table into a comma separated string
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'dupicate character'
		if 1 == #duplicate_char then											-- for single byte ascii characters use the string library functions
			f.gsub=string.gsub
			f.match=string.match
			f.sub=string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub=mw.ustring.gsub
			f.match=mw.ustring.match
			f.sub=mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1,1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = f.sub(str, -1,-1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if f.sub(str, -3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5,-1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4,-1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if f.sub(str, -3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3,-1) == duplicate_char .. '&quot;]' then		-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2,-1) == duplicate_char .. &quot;]&quot; then		-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4,-1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2,-1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows html markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;------------------------------------------------------------

returns true is suffix is properly formed Jr, Sr, or ordinal in the range 2–9.  Puncutation not allowed.

]]

local function is_suffix (suffix)
	if in_array (suffix, {'Jr', 'Sr', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written ouside of the code editor and pasted here because the code editor gets confused between character insertion point and cursor position.
The test has been rewritten to use decimal character escape sequence for the individual bytes of the unicode characters so that it is not necessary
to use an external editor to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first)
	local first, suffix = first:match ('(.-),?%s*([%dJS][%drndth]+)%.?$') or first;	-- if first has something that looks like a generational suffix, get it

	if is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error ('suffix');
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error ('non-Latin character');
			return false;														-- not a string of latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just intials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error ('suffix');									-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word


	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i],1,1));				-- insert the intial at end of initials table
		end
		i = i+1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between authors is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between authors is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = make_wikilink (person.link, one);						-- link author/editor if this page is not the author's/editor's page
				end
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end


--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]
local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of name parameters (author, editor, etc) for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the associated |display-&lt;names&gt;=etal parameter

]]

local function name_has_etal (name, etal, nocat, param)

	if is_set (name) then														-- name can be nil in which case just return
		local patterns = cfg.et_al_patterns;									--get patterns from configuration
		
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns
			if name:match (pattern) then										-- if this 'et al' pattern is found in name
				name = name:gsub (pattern, '');									-- remove the offending text
				etal = true;													-- set flag (may have been set previously here or by |display-&lt;names&gt;=etal)
				if not nocat then												-- no categorization for |vauthors=
					table.insert( z.message_tail, {set_error ('etal', {param})});	-- and set an error if not added
				end
			end
		end
	end

	return name, etal;															-- 
end


--[[--------------------------&lt; N A M E _ H A S _ E D _ M A R K U P &gt;------------------------------------------

Evaluates the content of author and editor parameters for extranious editor annotations: ed, ed., eds, (Ed.), etc.
These annotation do not belong in author parameters and are redundant in editor parameters.  If found, the function
adds the editor markup maintenance category.

]]

local function name_has_ed_markup (name, list_name)
	local _, pattern;
	local patterns = cfg.editor_markup_patterns;								-- get patterns from configuration

	if is_set (name) then
		for _, pattern in ipairs (patterns) do									-- spin through patterns table and
			if name:match (pattern) then
				add_maint_cat ('extra_text_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
				break;
			end
		end
	end
	return name;																-- and done
end


--[[--------------------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;----------------------------------------

Evaluates the content of author and editor (surnames only) parameters for multiple names.  Multiple names are
indicated if there is more than one comma and or semicolon.  If found, the function adds the multiple name
(author or editor) maintenance category.

]]

local function name_has_mult_names (name, list_name)
local count, _;
	if is_set (name) then
		_, count = name:gsub ('[;,]', '');										-- count the number of separator-like characters
		
		if 1 &lt; count then														-- param could be |author= or |editor= so one separator character is acceptable
			add_maint_cat ('mult_names', cfg.special_case_translation [list_name]);	-- more than one separator indicates multiple names so add a maint cat for this template
		end
	end
	return name;																-- and done
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------
This function calls various name checking functions used to validate the content of the various name-holding
parameters.

]]

local function name_checks (last, first, list_name)
	if is_set (last) then
		if last:match ('^%(%(.*%)%)$') then										-- if wrapped in doubled parentheses, accept as written 
			last = last:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			last = name_has_mult_names (last, list_name);						-- check for multiple names in the parameter (last only)
			last = name_has_ed_markup (last, list_name);						-- check for extraneous 'editor' annotation
		end
	end
	if is_set (first) then
		if first:match ('^%(%(.*%)%)$') then									-- if wrapped in doubled parentheses, accept as written 
			first = first:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			first = name_has_ed_markup (first, list_name);						-- check for extraneous 'editor' annotation
		end
	end
	return last, first;															-- done
	end


--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local last_alias, first_alias;												-- selected parameter aliases used in error messaging
	while true do
		last, last_alias = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first, first_alias = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.
		last, first= name_checks (last, first, list_name);						-- multiple names, extraneous annotation, etc checks
		
		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {first_alias, first_alias:gsub('first', 'last')}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			link_title_ok (link, list_name:match (&quot;(%w+)List&quot;):lower() .. '-link' .. i, last, list_name:match (&quot;(%w+)List&quot;):lower() .. '-last' .. i);	-- check for improper wikimarkup

			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {list_name:match (&quot;(%w+)List&quot;):lower(), i-1}, true ) } );	-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because case of the source may be incorrect
or different from the case that WikiMedia uses, the name comparisons are done in lower case and when a match is
found, the Wikimedia version (assumed to be correct) is returned along with the code.  When there is no match, we
return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') returns a list of languages that in some cases may include
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.  Most (all?) of these languages are not used a 'language' codes per se, rather they
are used as sub-domain names: cbk-zam.wikipedia.org.  A list of language names and codes supported by fetchLanguageNames()
can be found at Template:Citation Style documentation/language/doc

Names that are included in the list will be found if that name is provided in the |language= parameter.  For example,
if |language=Chavacano de Zamboanga, that name will be found with the associated code 'cbk-zam'.  When names are found
and the associated code is not two or three characters, this function returns only the WikiMedia language name.

Some language names have multiple entries under different codes:
	Aromanian has code rup and code roa-rup
When this occurs, this function returns the language name and the 2- or 3-character code

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	if cfg.lang_name_remap[lang:lower()] then									-- if there is a remapped name (because MediaWiki uses something that we don't think is correct)
		return cfg.lang_name_remap[lang:lower()][1], cfg.lang_name_remap[lang:lower()][2];	-- for this language 'name', return a possibly new name and appropriate code
	end

	local ietf_code;															-- because some languages have both ietf-like codes and iso 639-like codes
	local ietf_name;
	
	local languages = mw.language.fetchLanguageNames(this_wiki_code, 'all')		-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons

	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 == code:len() or 3 == code:len() then							-- two- or three-character codes only; extensions not supported
				return name, code;												-- so return the name and the code
			end
			ietf_code = code;													-- remember that we found an ietf-like code and save its name
			ietf_name = name;													-- but keep looking for a 2- or 3-char code
		end
	end
																				-- didn't find name with 2- or 3-char code; if ietf-like code found return
	return ietf_code and ietf_name or lang;										-- associated name; return original language text else
end


--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code is recognized by MediaWiki,
use the returned name; if not, then use the value that was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is assigned to the category for
that code: Category:Norwegian-language sources (no).  For valid three-character code languages, the page is assigned
to the single category for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does not recognize three-character
equivalents of two-character codes: code 'ar' is recognized bit code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are
separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki = mw.getContentLanguage();									-- get a language object for this wiki
	local this_wiki_code = this_wiki:getCode()									-- get this wiki's language code
	local this_wiki_name = mw.language.fetchLanguageName(this_wiki_code, this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang
		name = cfg.lang_code_remap[lang:lower()];								-- first see if this is a code that is not supported by MediaWiki but is in remap

		if name then															-- there was a remapped code so
			lang = lang:gsub ('^(%a%a%a?)%-.*', '%1');							-- strip ietf tags from code
		else
			if lang:match ('^%a%a%-') then										-- strip ietf tags from code; TODO: is there a need to support 3-char with tag?
				lang = lang:match ('(%a%a)%-')									-- keep only 639-1 code portion to lang; TODO: do something with 3166 alpha 2 country code?
			end
			if 2 == lang:len() or 3 == lang:len() then							-- if two-or three-character code
				name = mw.language.fetchLanguageName (lang:lower(), this_wiki_code);	-- get language name if |language= is a proper code
			end
		end

		if is_set (name) then													-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, this_wiki_code);				-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then													-- only 2- or 3-character codes
			name = cfg.lang_code_remap[code] or name;							-- override wikimedia when they misuse language codes/names

			if this_wiki_code ~= code then										-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					add_prop_cat ('foreign_lang_source' .. code, {name, code})	-- categorize it
				else															-- or is a recognized language (but has a three-character code)
					add_prop_cat ('foreign_lang_source_2' .. code, {code})		-- categorize it differently TODO: support mutliple three-character code categories per cs1|2 template
				end
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, cfg.messages['parameter-pair-separator'])		-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		name = table.concat (language_list, ', ');											-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
		name = name:gsub (', ([^,]+)$', cfg.messages['parameter-final-separator'] .. '%1');	-- replace last '&lt;comma&gt;&lt;space&gt;' separator with '&lt;comma&gt;&lt;space&gt;and&lt;space&gt;' separator
	end
	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings
At en.wiki, for cs1:
	ps gets:	'.'
	sep gets:	'.'

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = cfg.presentation['ps_cs1'];										-- terminate the rendered citation
	end
	return cfg.presentation['sep_cs1'], ps;										-- element separator
end


--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings
At en.wiki, for cs2:
	ps gets:	'' (empty string - no terminal punctuation)
	sep gets:	','

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = cfg.presentation['ps_cs2'];										-- terminate the rendered citation
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return cfg.presentation['sep_cs2'], ps, ref;								-- element separator
end


--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end


--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end


--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or
		url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
		url:match ('%.PDF&amp;#035') or url:match ('%.pdf&amp;#035');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parentheses, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[--------------------------&lt; G E T _ D I S P L A Y _ N A M E S &gt;--------------------------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_names (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_name', cfg.special_case_translation [list_name]);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parnetheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a place holder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parens
			local name = name_table[i];
			i=i+1;																-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parens
					break;														-- and done reassembling so
				end
				i=i+1;															-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = is_wikilink (name_table[i]);					-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i+1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parentheses to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')								-- remove doubled parntheses
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error ('punctuation');
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
			if is_suffix (first) then											-- if a valid suffix
				suffix = first													-- save it as a suffix and
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end																	-- no suffix error message here because letter combination may be result of Romanization; check for digits?
			last = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error ('missing comma');								-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error ('name');										-- matches a space between two intiials
			end
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error ('initials');									-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first);									-- check first and last before restoring the suffix which may have a non-Latin digit
			if is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '');
			end
		end

		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ) or v_link_table[i];
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice incase we have a |first1= without a |last1=; this ...
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or	-- ... also catches the case where |first= is used with |vauthors=
		select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, no, etc).  When the parameter value has not been assigned a value (missing or empty
in the source template) the function returns true.  If the parameter value is one of the list of allowed values returns
true; else, emits an error message and returns false.

]]

local function is_valid_parameter_value (value, name, possible)
	if not is_set (value) then
		return true;															-- an empty parameter is ok
	elseif in_array (value, possible) then
		return true;
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list,-3,-1) == sepc .. '. ') then						-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list,-1,-1) == sepc) or (string.sub (name_list,-3,-1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terninate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not is_set (volume) and not is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end

	local vol = '';																-- here for all cites except magazine
		
	if is_set (volume) then
		if volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$')then			-- volume value is all digits or all uppercase roman numerals
			vol = substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});	-- render in bold face
		elseif (4 &lt; mw.ustring.len(volume)) then								-- not all digits or roman numerals and longer than 4 characters
			vol = substitute (cfg.messages['j-vol'], {sepc, volume});			-- not bold
			add_prop_cat ('long_vol');
		else																	-- four or less characters
			vol = substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});	-- bold
		end
	end
	if is_set (issue) then
		return vol .. substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if is_set (page) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif is_set(pages) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then							-- if pages is only digits, assume a single page number
			return '', substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to wikisource, returns the label portion of the interwikilink as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki link to and external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, pages, at)
	local ws_url, ws_label, coins_pages, L;										-- for wikisource interwikilinks; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if is_set (page) then
		if is_set (pages) or is_set(at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws url from |page= interwiki link; link portion L becomes tool tip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif is_set (pages) then
		if is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws url from |pages= interwiki link; link portion L becomes tool tip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws url from |at= interwiki link; link portion L becomes tool tip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end



--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org urls to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot url or to calendar pages.  When the archive url is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the url.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org url does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command url
	|archive-url= is an archive.org url that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org urls:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this funct may return a modified
archive url:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the url unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.or url
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine url
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command url, we don't want to allow saving of the target page 
		err_msg = 'save command';
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = 'liveweb';
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');	-- split out some of the url parts for evaluation
		
		if not is_set(timestamp) or 14 ~= timestamp:len() then					-- path and flag optional, must have 14-digit timestamp here
			err_msg = 'timestamp';
			if '*' ~= flag then
				url=url:gsub ('(//web%.archive%.org/[^%d]*%d?%d?%d?%d?%d?%d?)[^/]*', '%1*', 1)	-- for preview, modify ts to be yearmo* max (0-6 digits plus splat)
			end
		elseif is_set(path) and 'web/' ~= path then								-- older archive urls do not have the extra 'web/' path element
			err_msg = 'path';
		elseif is_set (flag) and not is_set (path) then							-- flag not allowed with the old form url (without the 'web/' path element)
			err_msg = 'flag';
		elseif is_set (flag) and not flag:match ('%a%a_') then					-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = 'flag';
		else
			return url, date;													-- return archiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	table.insert( z.message_tail, { set_error( 'archive_url', {err_msg}, true ) } );	-- add error message and
	if is_set (Frame:preprocess('{{REVISIONID}}')) then
		return '', '';															-- return empty strings for archiveURL and ArchiveDate
	else
		return url, date;														-- preview mode so return archiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

-- set default parameter values defined by |mode= parameter.
	local Mode = A['Mode'];
	if not is_valid_parameter_value (Mode, 'mode', cfg.keywords['mode']) then
		Mode = '';
	end

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				add_maint_cat ('authors');										-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
			add_maint_cat ('editors');											-- but add a maint cat because use of this parameter is discouraged
		end
	end

	local translator_etal;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=

	local interviewer_etal;
	local interviewers_list = {};												
	local Interviewers;															-- used later
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters

	local contributor_etal;
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list
	local Contribution = A['Contribution'];
	if in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not is_set (Contribution) then									-- |contributor= requires |contribution=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if select_one (args, cfg.aliases['ContributorList-Last'], 'redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { set_error( 'contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if not is_valid_parameter_value (NameListFormat, 'name-list-format', cfg.keywords['name-list-format']) then	-- only accepted value for this parameter is 'vanc'
		NameListFormat = '';													-- anything else, set to empty string
	end

	if is_set (Others) then
		if 0 == #a and 0 == #e then												-- add maint cat when |others= has value and used without |author=, |editor=
			add_maint_cat ('others');
		end
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
			link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wikimarkup in |title-link= or wikimarkup in |title= when |title-link= is set

	local Chapter = A['Chapter'];
	local ScriptChapter = A['ScriptChapter'];
	local ScriptChapterOrigin = A:ORIGIN ('ScriptChapter');
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];

	local ArchiveDate;
	local ArchiveURL;

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	
	local UrlStatus = A['UrlStatus'];
	if 'url-status' == A:ORIGIN ('UrlStatus') then								-- interim: TODO: this line goes away
		if not is_valid_parameter_value (UrlStatus, 'url-status', cfg.keywords ['url-status']) then	-- set in config.defaults to 'dead'
			UrlStatus = '';														-- anything else, set to empty string
		end																		-- interim: TODO: this line goes away
	elseif is_set (A:ORIGIN ('UrlStatus')) then									-- interim: while both |dead-url= and |url-status= allowed use separate keyword lists; TODO: remove this section
		if not is_valid_parameter_value (UrlStatus, A:ORIGIN ('UrlStatus'), cfg.keywords ['deadurl']) then	-- interim: assume |dead-url=; use those keywords; TODO: this line goes away
			UrlStatus = '';														-- anything else, set to empty string; interim: TODO: this line goes away
		end																		-- interim: TODO: this line goes away
	end																			-- interim: TODO: this line goes away
	
	if in_array (UrlStatus, {'yes', 'true', 'y'}) then							-- TODO: remove this whole thing when |dead-url=[yes|no] parameters removed from articles
		UrlStatus = 'dead';
	elseif 'no' == UrlStatus then
		UrlStatus = 'live';
	end
	
	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];
	local Periodical_origin = '';
		if is_set (Periodical) then
			Periodical_origin = A:ORIGIN('Periodical');							-- get the name of the periodical parameter
			local i;
			Periodical, i = strip_apostrophe_markup (Periodical);				-- strip appostrophe markup so that metadata isn't contaminated 
			if i then															-- non-zero when markup was stripped so emit an error message
				table.insert( z.message_tail, {set_error ('apostrophe_markup', {Periodical_origin}, true)});
			end
		end

	local ScriptPeriodical = A['ScriptPeriodical'];
	local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');

		if not (is_set (Periodical) or is_set (ScriptPeriodical)) then			-- 'periodical' templates require periodical parameter
			local p = {['journal'] = 'journal', ['magazine'] = 'magazine', ['news'] = 'newspaper', ['web'] = 'website'};	-- for error message
			if p[config.CitationClass]  then
				table.insert( z.message_tail, {set_error ('missing_periodical', {config.CitationClass, p[config.CitationClass]}, true)});
			end
		end

	local TransPeriodical =  A['TransPeriodical'];

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if 'citation' == config.CitationClass then
		if is_set (Periodical) then
			if not in_array (Periodical_origin, {'website', 'mailinglist'}) then	-- {{citation}} does not render volume for these 'periodicals'
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		elseif is_set (ScriptPeriodical) then
			if 'script-website' ~= ScriptPeriodical_origin then					-- {{citation}} does not render volume for |script-website=
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		else
			Volume = A['Volume'];												-- and does for non-'periodical' cites
		end
	elseif in_array (config.CitationClass, cfg.templates_using_volume) then		-- render |volume= for cs1 according to the configuration settings
		Volume = A['Volume'];
	end	

	if 'citation' == config.CitationClass then
		if is_set (Periodical) and in_array (Periodical_origin, {'journal', 'magazine', 'newspaper', 'periodical', 'work'}) or	-- {{citation}} renders issue for these 'periodicals'
			is_set (ScriptPeriodical) and in_array (ScriptPeriodical_origin, {'script-journal', 'script-magazine', 'script-newspaper', 'script-periodical', 'script-work'}) then -- and these 'script-periodicals'
				Issue = hyphen_to_dash (A['Issue']);
		end
	elseif in_array (config.CitationClass, cfg.templates_using_issue) then		-- conference &amp; map books do not support issue; {{citation}} listed here because included in settings table
		if not (in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (is_set (Periodical) or is_set (ScriptPeriodical))) then
			Issue = hyphen_to_dash (A['Issue']);
		end
	end

	local Position = '';
	if not in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash (A['Pages']);	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local PublisherName_origin = A:ORIGIN('PublisherName');
		if is_set (PublisherName) then
			local i=0;
			PublisherName, i = strip_apostrophe_markup (PublisherName);			-- strip appostrophe markup so that metadata isn't contaminated; publisher is never italicized

			if i then															-- non-zero when markup was stripped so emit an error message
				table.insert( z.message_tail, {set_error ('apostrophe_markup', {PublisherName_origin}, true)});
			end
		end

	local RegistrationRequired = A['RegistrationRequired'];
		if not is_valid_parameter_value (RegistrationRequired, 'registration', cfg.keywords ['yes_true_y']) then
			RegistrationRequired=nil;
		end

	local SubscriptionRequired = A['SubscriptionRequired'];
		if not is_valid_parameter_value (SubscriptionRequired, 'subscription', cfg.keywords ['yes_true_y']) then
			SubscriptionRequired=nil;
		end

	local UrlAccess = A['UrlAccess'];
		if not is_valid_parameter_value (UrlAccess, 'url-access', cfg.keywords ['url-access']) then
			UrlAccess = nil;
		end
		if not is_set(URL) and is_set(UrlAccess) then
			UrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {'url'}, true ) } );
		end
		
		if is_set (UrlAccess) and is_set (SubscriptionRequired) then			-- while not aliases, these are much the same so if both are set
			table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'url-access') .. ' and ' .. wrap_style ('parameter', 'subscription')}, true ) } );		-- add error message
			SubscriptionRequired = nil;											-- unset; prefer |access= over |subscription=
		end
		if is_set (UrlAccess) and is_set (RegistrationRequired) then			-- these are not the same but contradictory so if both are set
			table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'url-access') .. ' and ' .. wrap_style ('parameter', 'registration')}, true ) } );		-- add error message
			RegistrationRequired = nil;											-- unset; prefer |access= over |registration=
		end

	local ChapterUrlAccess = A['ChapterUrlAccess'];
		if not is_valid_parameter_value (ChapterUrlAccess, A:ORIGIN('ChapterUrlAccess'), cfg.keywords ['url-access']) then	-- same as url-access
			ChapterUrlAccess = nil;
		end
		if not is_set(ChapterURL) and is_set(ChapterUrlAccess) then
			ChapterUrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {A:ORIGIN('ChapterUrlAccess'):gsub ('%-access', '')}, true ) } );
		end

	local MapUrlAccess = A['MapUrlAccess'];
		if not is_valid_parameter_value (MapUrlAccess, 'map-url-access', cfg.keywords ['url-access']) then
			MapUrlAccess = nil;
		end
		if not is_set(A['MapURL']) and is_set(MapUrlAccess) then
			MapUrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {'map-url'}, true ) } );
		end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local Agency = A['Agency'];

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
		if not is_valid_parameter_value (IgnoreISBN, 'ignore-isbn-error', cfg.keywords ['yes_true_y']) then
			IgnoreISBN = nil;													-- anything else, set to empty string
		end
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );
		if is_set (DoiBroken) and not ID_list['DOI'] then
			table.insert( z.message_tail, { set_error( 'doibroken_missing_doi', A:ORIGIN('DoiBroken'))});
		end
	local ID_access_levels = extract_id_access_levels( args, ID_list );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
		if not is_valid_parameter_value (LastAuthorAmp, 'last-author-amp', cfg.keywords ['yes_true_y']) then
			LastAuthorAmp = nil;												-- set to empty string
		end

	local no_tracking_cats = A['NoTracking'];
		if not is_valid_parameter_value (no_tracking_cats, 'no-tracking', cfg.keywords ['yes_true_y']) then
			no_tracking_cats = nil;												-- set to empty string
		end

	--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = A['DF'];															-- date format set in cs1|2 template
	if not is_valid_parameter_value (DF, 'df', cfg.keywords['date-format']) then	-- validate reformatting keyword
		DF = '';																-- not valid, set to empty string
	end
	if not is_set (DF) then
		DF = cfg.global_df;
	end

	local sepc;																	-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );											-- used to control capitalization for certain static text

	--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

	-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	select_one( args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'redundant_parameters' );	-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, Pages, At);

	local NoPP = A['NoPP'] 
	if is_set (NoPP) and is_valid_parameter_value (NoPP, 'nopp', cfg.keywords ['yes_true_y']) then
		NoPP = true;
	else
		NoPP = nil;																-- unset, used as a flag later
	end

	if not is_set(PublicationPlace) and is_set(Place) then						-- both |publication-place= and |place= (|location=) allowed if different
		PublicationPlace = Place;												-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end							-- don't need both if they are the same
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia and |title then map |title to |article and |encyclopedia to |title
		|encyclopedia and |article then map |encyclopedia to |title

		|trans-title maps to |trans-chapter when |title is re-mapped
		|url maps to |chapterurl when |title is remapped
	
	All other combinations of |encyclopedia, |title, and |article are not modified
	
	]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set (Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					ScriptChapterOrigin = 'title';
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterUrlAccess = UrlAccess;

					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter = make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			elseif is_set (Chapter) then										-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if is_set(A['Number']) then												-- cite techreport uses 'number', which other citations alias to 'issue'
			if not is_set(ID) then												-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', 'id') .. ' and ' .. wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

	-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	elseif 'mailinglist' == Periodical_origin then
		Periodical = '';														-- unset because mailing list is only used for cite mailing list
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		ChapterUrlAccess = MapUrlAccess;
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];

		link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wikimarkup in |series-link= or wikimarkup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) and is_set (AirDate) then							-- promote airdate to date
			Date = AirDate;
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('seriesnum', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ScriptChapterOrigin = 'title';
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = make_wikilink (ChapterLink, Chapter);
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = make_wikilink (SeriesLink, Series);
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite ssrn}}, before generation of COinS data.
	do
		if in_array (config.CitationClass, {'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) then
			if not is_set (ID_list[config.CitationClass:upper()]) then			-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp; |citeseerx= required for their templates
				table.insert( z.message_tail, { set_error( config.CitationClass .. '_missing', {}, true ) } );	-- add error message
			end

			Periodical = ({['arxiv'] = 'arXiv', ['biorxiv'] = bioRxiv, ['citeseerx'] = 'CiteSeerX', ['ssrn'] = 'Social Science Research Network'})[config.CitationClass];
		end
	end

	-- handle type parameter for those CS1 citations that have default values
	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;interview&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
		TitleType = substitute( cfg.messages['type'], TitleType);				-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging

	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val=AccessDate, name=A:ORIGIN ('AccessDate')},
			['archive-date'] = {val=ArchiveDate, name=A:ORIGIN ('ArchiveDate')},
			['date'] = {val=Date, name=Date_origin},
			['doi-broken-date'] = {val=DoiBroken, name=A:ORIGIN ('DoiBroken')},
			['embargo'] = {val=Embargo, name=A:ORIGIN ('Embargo')},
			['lay-date'] = {val=LayDate, name=A:ORIGIN ('LayDate')},
			['publication-date'] ={val=PublicationDate, name=A:ORIGIN ('PublicationDate')},
			['year'] = {val=Year, name=A:ORIGIN ('Year')},
			};
		anchor_year, Embargo, error_message = dates(date_parameters_list, COinS_date);

-- start temporary Julian / Gregorian calendar uncertainty categorization
		if COinS_date.inter_cal_cat then
			add_prop_cat ('jul_greg_uncertainty');
		end
-- end temporary Julian / Gregorian calendar uncertainty categorization

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end
		
		if not is_set(error_message) then										-- error free dates only
			local modified = false;												-- flag
			
			if is_set (DF) then													-- if we need to reformat dates
				modified = reformat_dates (date_parameters_list, DF, false);	-- reformat to DF format, use long month names if appropriate
			end

			if true == date_hyphen_to_dash (date_parameters_list) then			-- convert hyphens to dashes where appropriate
				modified = true;
				add_maint_cat ('date_format');									-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language,
	-- uncomment these three lines.  Not supported by en.wiki (for obvious reasons)
	-- set date_name_xlate() second argument to true to translate English digits to local digits (will translate ymd dates)
--			if date_name_xlate (date_parameters_list, false) then
--				modified = true;
--			end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				LayDate = date_parameters_list['lay-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end
		else
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end
	end	-- end of do

	-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
	-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
			if is_set(AccessDate) then											-- access date requires |url=; pmc created url is not |url=
				table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
				AccessDate = '';												-- unset
			end

		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
			if 'episode' == config.CitationClass then							-- special case for cite episode; TODO: is there a better way to do this?
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
			else
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
			end
	end

	if 'none' == Title and
			in_array (config.CitationClass, {'journal', 'citation'}) and
			(is_set (Periodical) or is_set (ScriptPeriodical)) and
			('journal' == Periodical_origin or 'script-journal' == ScriptPeriodical_origin) then	-- special case for journal cites
				Title = '';														-- set title to empty string
				add_maint_cat ('untitled');
	end

	check_for_url ({															-- add error message when any of these parameters hold a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[Periodical_origin] = Periodical,
		[PublisherName_origin] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = strip_apostrophe_markup (Periodical),					-- no markup in the metadata
		['Encyclopedia'] = strip_apostrophe_markup (Encyclopedia),
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = coins_pages or get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,										-- any apostrophe markup already removed
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, and {{cite ssrn}} AFTER generation of COinS data.
	if in_array (config.CitationClass, {'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, CiteSeerX, or ssrn now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = substitute (cfg.messages['newsgroup'], external_link( 'news:' .. PublisherName, PublisherName, PublisherName_origin, nil ));
		end
	end

	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text,											-- get current page name so that we don't wikilink to it via editorlinkn
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_names (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if is_set (Editors) then
				Editors, editor_etal = name_has_etal (Editors, editor_etal, false, 'editors');	-- find and remove variations on et al.
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
					EditorCount = 2;											-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
				else
					EditorCount = 2;											-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
				end
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum , interviewer_etal = get_display_names (A['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal);
			Interviewers = list_people (control, interviewers_list, interviewer_etal);
		end
		do																		-- now do translators
			control.maximum , translator_etal = get_display_names (A['DisplayTranslators'], #t, 'translators', translator_etal);
			Translators = list_people (control, t, translator_etal);
		end
		do																		-- now do contributors
			control.maximum , contributor_etal = get_display_names (A['DisplayContributors'], #c, 'contributors', contributor_etal);
			Contributors = list_people (control, c, contributor_etal);
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_names (A['DisplayAuthors'], #a, 'authors', author_etal);

			last_first_list = list_people(control, a, author_etal);

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors');	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if is_set (Authors) and is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
	-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (is_set (Periodical) or is_set (ScriptPeriodical)) and not is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not is_set(URL) then
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) or		-- |url= required for cite web, cite podcast, and cite mailinglist
			('citation' == config.CitationClass and ('website' == Periodical_origin or 'script-website' == ScriptPeriodical_origin)) then	-- and required for {{citation}} with |website= or |script-website=
				table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURLorigin, OriginalFormat, OriginalAccess;
--	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	UrlStatus = UrlStatus:lower();												-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (ChapterURL) then 											-- if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURLorigin = ChapterURLorigin;								-- name of chapter-url parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=
--			if 'no' ~= DeadURL then
			if 'live' ~= UrlStatus then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				ChapterURLorigin = A:ORIGIN('ArchiveURL')						-- name of archive-url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived urls
			end
		elseif is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURLorigin = URLorigin;										-- name of url parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;
--			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
			if 'live' ~= UrlStatus then											-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived urls
			end
 		end
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and (is_set (Periodical) or is_set (ScriptPeriodical)) and not is_set (Encyclopedia)) then
			local chap_param;
			if is_set (Chapter) then											-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif is_set (ScriptChapter) then
				chap_param = ScriptChapterOrigin;
			else is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if is_set (chap_param) then											-- if we found one
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {chap_param}, true ) } );		-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if is_set (Contribution) and 0 &lt; #c then								-- if this is a contribution with contributor(s)
			if in_array (Contribution:lower(), cfg.keywords.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, ScriptChapterOrigin, Chapter, TransChapter, ChapterURL, ChapterURLorigin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter.. sepc .. ' ';
		elseif is_set (ChapterFormat) then										-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title.
	if is_set (ArchiveURL) and mw.ustring.match (mw.ustring.lower(Title), cfg.special_case_translation['archived_copy']) then	-- if title is 'Archived copy' (place holder added by bots that can't find proper title)
		add_maint_cat ('archived_copy');										-- add maintenance category before we modify the content of Title
	end

	if Title:match ('^%(%(.*%)%)$') then										-- if keep as written markup:
		Title= Title:gsub ('^%(%((.*)%)%)$', '%1')								-- remove the markup
	else
		if '...' == Title:sub (-3) then											-- if elipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%'..sepc..'$', '');				-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end
	end
	
	if in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (is_set (Periodical) or is_set (ScriptPeriodical)) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and (is_set (Periodical) or is_set (ScriptPeriodical))) then		-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle, 'script-title');	-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end

	if is_set(Title) then
		if not is_set (TitleLink) and is_set (URL) then
			Title = external_link (URL, Title, URLorigin, UrlAccess) .. TransTitle .. TransError .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif is_set (TitleLink) and not is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = make_wikilink (TitleLink, Title) .. TransTitle .. TransError;
			end
		else
			local ws_url, ws_label;
			ws_url, ws_label, L = wikisource_url_make (Title);					-- make ws url from |title= interwiki link; link portion L becomes tool tip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = Title .. TransTitle .. TransError;
			end
		end
	else
		Title = TransTitle .. TransError;
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURLorigin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin, nil );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if is_set(Minutes) then
			if is_set (Time) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'minutes') .. ' and ' .. wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = is_set (Series) and wrap_msg ('series', {sepc, Series}) or &quot;&quot;;		-- not the same as SeriesNum
	OrigYear = is_set (OrigYear) and wrap_msg ('origyear', OrigYear) or '';
	Agency = is_set (Agency) and wrap_msg ('agency', {sepc, Agency}) or &quot;&quot;;
	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	Via = is_set (Via) and  wrap_msg ('via', Via) or '';

	--[[
	Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
	note is displayed. There are no error messages for this condition.
	
	]]
	if is_set (SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif is_set (RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text

		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {IdAccessLevels=ID_access_levels, DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin, UrlAccess );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then				-- if first and last characters of quote are quote marks
			Quote = Quote:sub(2,-2);											-- strip them off
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;live&quot; == UrlStatus then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-live'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- UrlStatus is empty, 'dead', 'unfit', 'usurped', 'bot: unknown'
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if in_array (UrlStatus, {'unfit', 'usurped', 'bot: unknown'}) then
				Archived = sepc .. &quot; &quot; .. 'Archived from the original on ' .. ArchiveDate;	-- format already styled
				if 'bot: unknown' == UrlStatus then
					add_maint_cat ('bot:_unknown');								-- and add a category if not already added
				else
					add_maint_cat ('unfit');									-- and add a category if not already added
				end
			else																-- UrlStatus is empty, 'dead'
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURLorigin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURLorigin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin, nil );
	end

	local Publisher;
	if is_set(PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if is_set(PublisherName) then
		if is_set(PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif is_set(PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if (is_set (Periodical) or is_set (ScriptPeriodical) or is_set (TransPeriodical)) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical);
		else 
			Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical);
		end
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then									-- cite speech only
		TitleNote = &quot; (Speech)&quot;;												-- annotate the citation
		if is_set (Periodical) then												-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then											-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;							-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = safe_join ({Others, sepc .. &quot; &quot;}, sepc) end		-- add terminal punctuation &amp; space; check for dup sepc; TODO why do we need to do this here?
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(Periodical) then		-- special cases for book cites
		if is_set (Contributors) then											-- when we are citing foreword, preface, introduction, etc
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon;
	if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then	-- special case for cite AV media &amp; cite episode position transcript
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	else
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	end
	
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if is_set(Date) then
		if is_set (Authors) or is_set (Editors) then							-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;;				-- in paranetheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon,-1,-1) == sepc) then							-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigYear;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigYear;							-- Date begins with sepc
			end
		end
	end	
	if is_set(Authors) then
		if (not is_set (Date)) then												-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then
					in_text = in_text:lower()									-- lowercase for cs2
				end
			end
			if EditorCount &lt;= 1 then
				post_text = &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot;;				-- be consistent with no-author, no-date case
			else
				post_text = &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot;;
			end
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if is_set (Contributors) then											-- book cite and we're citing the intro, preface, etc
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if is_set (Editors) and is_set (Date) then							-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not is_set (Date)) then											-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc ); 								--Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = config.CitationClass;
		options.class = &quot;citation &quot; .. config.CitationClass;					-- class=citation required for blue highlight when used with |ref=
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then								-- set reference anchor if appropriate
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			if #namelist &gt; 0 then												-- if there are names in namelist
				id = anchor_id (namelist, year);								-- go make the CITEREF anchor
			else
				id = '';														-- unset
			end
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;(.-)&lt;/span&gt;&quot;, &quot;%1&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then	-- remove &lt;span&gt; tags and other html-like markup; then get length of what remains
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	local render = {};															-- here we collect the final bits for concatenation into the rendered citation

	if is_set(options.id) then													-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render, substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text}));	-- when |ref= is set
	else
		table.insert (render, substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text}));	-- all other cases
	end		

	table.insert (render, substitute (cfg.presentation['ocins'], {OCinSoutput}));	-- append metadata to the citation

	if 0 ~= #z.message_tail then
		table.insert (render, ' ');
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					table.insert (render, error_comment( v[1], v[2] ));
				else
					table.insert (render, error_comment( v[1] .. &quot;; &quot;, v[2] ));
				end
			end
		end
	end

	if 0 ~= #z.maintenance_cats then
		local maint_msgs = {};													-- here we collect all of the maint messages
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			local maint = {};													-- here we assemble a maintenence message
			table.insert (maint, v);											-- maint msg is the category name
			table.insert (maint, ' (');											-- open the link text
			table.insert (maint, make_wikilink (':Category:' .. v, 'link'));	-- add the link
			table.insert (maint, ')');											-- and close it
			table.insert (maint_msgs, table.concat (maint));					-- assemble new maint message and add it to the maint_msgs table
		end
		table.insert (render, substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs, ' ')));	-- wrap the group of maint message with proper presentation and save
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			table.insert (render, make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			table.insert (render, make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.properties_cats ) do								-- append properties categories
			table.insert (render, make_wikilink ('Category:' .. v));
		end
	end

	return table.concat (render);	
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class)
	local name = tostring (name);
	local state;
	
	if in_array (cite_class, {'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) then	-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[name];
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end

		state = whitelist[cite_class .. '_basic_arguments'][name];				-- look in the parameter-list for the template identified by cite_class

		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
																				-- limited enumerated parameters list
		name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
		state = whitelist.limited_numbered_arguments[name];
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates
		
	state = whitelist.basic_arguments[name];									-- all other templates; all normal parameters allowed
											
	if true == state then return true; end										-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);											-- parameter is deprecated but still supported
		return true;
	end
																				-- all enumerated parameters allowed
	name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );												-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
	state = whitelist.numbered_arguments[name];

	if true == state then return true; end										-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);											-- parameter is deprecated but still supported
		return true;
	end
	
	return false;																-- not supported because not found or name is set to nil
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe:
	{{cite ... |title=Title access-date=2016-03-17}}

cs1|2 shares some parameter names with xml/html atributes: class=, title=, etc.  To prevent false positives xml/html
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (parameter, value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove xml/html tags because attributes: class=, title=, etc 

	capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then								-- if the capture is a valid parameter name
		table.insert( z.message_tail, {set_error ('missing_pipe',parameter)});
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ P U N C T &gt;--------------------------------------

look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_punc (param, value)
	if cfg.punct_skip[param] then
		return;																	-- parameter name found in the skip table so done
	end
	
	if value:match ('[,;:]$') then
		add_maint_cat ('extra_punct');											-- has extraneous punctuation; add maint cat
	end
end


--[[--------------------------&lt; C I T A T I O N &gt;--------------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

local function citation(frame)
	Frame = frame;																-- save a copy incase we need to display an error message in preview mode
	local pframe = frame:getParent()
	local validation, utilities, identifiers, metadata, styles;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		styles = 'Module:Citation/CS1/sandbox/styles.css';
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
		styles = 'Module:Citation/CS1/styles.css';

	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	dates = validation.dates;													-- imported functions from Module:Citation/CS1/Date validation
	year_date_check = validation.year_date_check;
	reformat_dates = validation.reformat_dates;
	date_hyphen_to_dash = validation.date_hyphen_to_dash;
	date_name_xlate = validation.date_name_xlate;

	is_set = utilities.is_set;													-- imported functions from Module:Citation/CS1/Utilities
	in_array = utilities.in_array;
	substitute = utilities.substitute;
	error_comment = utilities.error_comment;
	set_error = utilities.set_error;
	select_one = utilities.select_one;
	add_maint_cat = utilities.add_maint_cat;
	wrap_style = utilities.wrap_style;
	safe_for_italics = utilities.safe_for_italics;
	is_wikilink = utilities.is_wikilink;
	make_wikilink = utilities.make_wikilink;
	strip_apostrophe_markup = utilities.strip_apostrophe_markup;

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	extract_ids = identifiers.extract_ids;										-- imported functions from Module:Citation/CS1/Identifiers
	build_id_list = identifiers.build_id_list;
	is_embargoed = identifiers.is_embargoed;
	extract_id_access_levels = identifiers.extract_id_access_levels;
	
	make_coins_title = metadata.make_coins_title;								-- imported functions from Module:Citation/CS1/COinS
	get_coins_pages = metadata.get_coins_pages;
	COinS = metadata.COinS;

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text, error_state;

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do
		config[k] = v;
--		args[k] = v;															-- debug tool that allows us to render a citation from module {{#invoke:}}
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower(), config.CitationClass ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute (param, capture);				-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text, error_state = set_error ('parameter_ignored_suggest', {k, param}, true);	-- set the suggestion error message
							else
								error_text, error_state = set_error( 'parameter_ignored', {param}, true );	-- suggested param not supported by this template
							end
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?
																				-- TODO: is this the best place for this translation?
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then						-- here when v is empty string
			args[k] = v;														-- why do we do this?  we don't support 'empty' parameters
		end		
	end	

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);
			has_extraneous_punc (k, v);											-- look for extraneous terminal punctuation in parameter values
		end
	end
	return table.concat ({citation0( config, args), frame:extensionTag ('templatestyles', '', {src=styles})});
end

--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {citation = citation};</text>
      <sha1>s1ptsqky6jla2ch3vxqftih7lhqkoeh</sha1>
    </revision>
    <revision>
      <id>4725</id>
      <parentid>4724</parentid>
      <timestamp>2019-09-03T13:03:21Z</timestamp>
      <contributor>
        <username>Ivanvector</username>
        <id>816</id>
      </contributor>
      <comment>Undid revision 913814858 by [[Special:Contributions/Trappist the monk|Trappist the monk]] ([[User talk:Trappist the monk|talk]]) This edit has introduced citation errors all over the project. Please troubleshoot before implementing this change. See [https://en.wikipedia.org/wiki/Wikipedia:Administrators%27_noticeboard#Is_there_a_semi-automated_tool_that_could_fix_these_annoying_%22Cite_Web%22_errors?]</comment>
      <origin>4725</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="177894" sha1="jzwo2dr3jrjgr6d0tp46g4ca3srpo7r" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local dates, year_date_check, reformat_dates, date_hyphen_to_dash,				-- functions in Module:Citation/CS1/Date_validation
	date_name_xlate

local is_set, in_array, substitute, error_comment, set_error, select_one,		-- functions in Module:Citation/CS1/Utilities
	add_maint_cat, wrap_style, safe_for_italics, is_wikilink, make_wikilink;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local extract_ids, extract_id_access_levels, build_id_list, is_embargoed;		-- functions in Module:Citation/CS1/Identifiers

local make_coins_title, get_coins_pages, COinS;									-- functions in Module:Citation/CS1/COinS

local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

delare variables here that have page-wide scope that are not brought in from other modules; thatare created here
and used here

]]

local added_deprecated_cat;														-- boolean flag so that the category is added only once
local added_prop_cats = {};														-- list of property categories that have been added to z.properties_cats
local added_vanc_errs;															-- boolean flag so we only emit one Vancouver error / category

local Frame;																	-- holds the module's frame table


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

foreign_lang_source and foreign_lang_source_2 keys have a language code appended to them so that multiple languages
may be categorized but multiples of the same language are not categorized.

added_prop_cats is a table declared in page scope variables above

]]

local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		key = key:gsub ('(foreign_lang_source_?2?)%a%a%a?', '%1');				-- strip lang code from keyname
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));		-- make name then add to table
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a boolean declared in page scope variables above

]]

local function add_vanc_error (source)
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {source}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a uri scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of tlds: https://www.iana.org/domains/root/db

rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the tld.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a url with a scheme) will be stripped
here.  Perhaps not necessary but retained incase it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ascii characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the tld) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and tld or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%a%d]') then										-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at wikisource
		return false;
	end
																				-- Do most common case first
	if domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.%a%a+$') then				-- three or more character hostname.hostname or hostname.tld
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d%-]+[%a%d]%.xn%-%-[%a%d]+$') then	-- internationalized domain name with ACE prefix
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.cash$') then							-- one character/digit .cash hostname
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.today') then							-- one character/digit .today hostname
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.org$') then							-- one character/digit .org hostname
		return true;
	elseif domain:match ('%f[%a][qxz]%.com$') then								-- assigned one character .com hostname (x.com times out 2015-12-10)
		return true;
	elseif domain:match ('%f[%a][iq]%.net$') then								-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		return true;
	elseif domain:match ('%f[%a%d][%a%d]%.%a%a$') then							-- one character hostname and cctld (2 chars)
		return true;
	elseif domain:match ('%f[%a%d][%a%d][%a%d]%.%a%a+$') then					-- two character hostname and tld
		return true;
	elseif domain:match ('^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?') then		-- IPv4 address
		return true;
	else
		return false;
	end
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a url appear to be a valid url; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if is_set (scheme) then														-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when url is protocol relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a url into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following tld) (if any) and any path(/), query(?) or fragment(#).

If protocol relative url, return nil scheme and domain else return nil for both scheme and domain.

When not protocol relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol relative url
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		authority = authority:gsub ('//', '', 1);								-- replace place 1 pair of '/' with nothing;
		if is_set(authority) then												-- if anything left (1 or 3+ '/' where authority should be) then
			return scheme;														-- return scheme only making domain nil which will cause an error message
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link= etc for properly formatted content: no wikilinks, no urls

Link parameters are to hold the title of a wikipedia article so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki urls and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid url (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid url (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from url; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid url
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wikilinked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

]]

local function link_title_ok (link, lorig, title, torig)
local orig;

	if is_set (link) then 														-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		end
	end

	if is_set (orig) then
		table.insert( z.message_tail, { set_error( 'bad_paramlink', orig)});	-- url or wikilink in |title= with |title-link=;
	end
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the url into scheme and domain
portions, or for protocol relative (//example.com) urls, just the domain.  Use is_url() to validate the two
portions of the url.  If both are valid, or for protocol relative if domain is valid, return true, else false.

Because it is different from a standard url, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper url
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from url;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a url.  The test will also find external wikilinks
that use protocol relative urls. Also finds bare urls.

The frontier pattern prevents a match on interwiki links which are similar to scheme:path urls.  The tests that
find bracketed urls are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol relative ext wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare url with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol relative bare url: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a url
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then												-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source, access)
	local error_str = &quot;&quot;;
	local domain;
	local path;
	local base_url;

	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the url into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['[']='%5b',[']']='%5d'});					-- replace '[' and ']' with their percent encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wikimarkup url

	if is_set (access) then														-- access level (subscription, registration, limited)
		base_url = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end
	
	return table.concat ({base_url, error_str});
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );		-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Replaces unicode quotemarks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc; not for book titles.

]=]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	local wl_type, label, link;

	wl_type, label, link = is_wikilink (str);									-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = substitute (cfg.presentation['kern-wl-both'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = substitute (cfg.presentation['kern-wl-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = substitute (cfg.presentation['kern-wl-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label= mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label= mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap, cap2 = mw.ustring.match (label, &quot;^([\&quot;\'])([^\'].+)&quot;);				-- match leading double or single quote but not doubled single quotes (italic markup)
		if is_set (cap) then
			label = substitute (cfg.presentation['kern-left'], {cap, cap2});
		end
	
		cap, cap2 = mw.ustring.match (label, &quot;^(.+[^\'])([\&quot;\'])$&quot;)				-- match trailing double or single quote but not doubled single quotes (italic markup)
		if is_set (cap) then
			label = substitute (cfg.presentation['kern-right'], {cap, cap2});
		end
		
		if 2 == wl_type then
			str = make_wikilink (link, label);									-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title= and |script-chapter=

TODO: error messages when prefix is invalid ISO639-1 code; when script_value has prefix but no script;
]]

local function format_script_value (script_value)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_code_remap[lang] or mw.language.fetchLanguageName( lang, &quot;en&quot; );	-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, cfg.script_lang_codes) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				add_prop_cat ('script')
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			lang = '';															-- invalid so set lang to empty string
		end
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script)
	if is_set (script) then
		script = format_script_value (script);									-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return substitute( msg, str );										-- including template text
	else
		return substitute( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;----------------------------------------

makes a wikisource url from wikisource interwiki link.  returns the url and appropriate label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;

	wl_type, D, L = is_wikilink (str);											-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if is_set (str) then
			ws_url = table.concat ({											-- build a wikisource url
				'https://en.wikisource.org/wiki/',								-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the url
		end
	elseif 1 == wl_type then														-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if is_set (str) then
			ws_url = table.concat ({											-- build a wikisource url
				'https://en.wikisource.org/wiki/',								-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the url
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a wikisource url
				'https://en.wikisource.org/wiki/',								-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end
	
	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable url
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent encoding of anchor
	end

	return ws_url, ws_label, L or D;													-- return proper url or nil and a label or nil
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (scriptchapter, chapter, transchapter, chapterurl, chapter_url_source, no_quotes, access)
	local chapter_error = '';

	local ws_url, ws_label, L = wikisource_url_make (chapter);						-- make a wikisource url and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', '');										-- replace underscore separaters with space characters
		chapter = ws_label;
	end

	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
			chapter = wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, scriptchapter)						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (chapterurl) then
		chapter = external_link (chapterurl, chapter, chapter_url_source, access);		-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');		-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if is_set (transchapter) then
		transchapter = wrap_style ('trans-quoted-title', transchapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. transchapter;
		else																	-- here when transchapter without chapter or script-chapter
			chapter = transchapter;												-- 
			chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
		end
	end

--	if is_set (chapterurl) then
--		chapter = external_link (chapterurl, chapter, chapter_url_source, access);		-- adds bare_url_missing_title error if appropriate
--	end

	return chapter .. chapter_error;
end


--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i=1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- Test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position and (char == 'zero width joiner') then						-- if we found a zero width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- its ok if one of the indic scripts
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { set_error( 'invisible_char', {err_msg, wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i=i+1;																	-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] );
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash under certain conditions.  The hyphen must separate like items; unlike items are
returned unmodified.  These forms are modified:
	letter - letter (A - B)
	digit - digit (4-5)
	digit separator digit - digit separator digit (4.1-4.5 or 4-1-4-5)
	letterdigit - letterdigit (A1-A5) (an optional separator between letter and digit is supported – a.1-a.5 or a-1-a-5)
	digitletter - digitletter (5a - 5d) (an optional separator between letter and digit is supported – 5.a-5.d or 5-a-5-d)

any other forms are returned unmodified.

str may be a comma- or semicolon-separated list

]]

local function hyphen_to_dash( str )
	if not is_set (str) then
		return str;
	end
	
	str, count = str:gsub ('^%(%((.+)%)%)$', '%1');								-- remove accept-this-as-written markup when it wraps all of str
	if 0 ~= count then															-- non-zero when markup removed; zero else
		return str;																-- nothing to do, we're done
	end
	
	str = str:gsub ('&amp;[nm]dash;', {['&amp;ndash;'] = '–', ['&amp;mdash;'] = '—'});		-- replace &amp;mdash; and &amp;ndash; entities  with their characters; semicolon mucks up the text.split
	
	local out = {};
	local list = mw.text.split (str, '%s*[,;]%s*');								-- split str at comma or semicolon separators if there are any

	for _, item in ipairs (list) do												-- for each item in the list
		if mw.ustring.match (item, '^%w*[%.%-]?%w+%s*[%-–—]%s*%w*[%.%-]?%w+$') then	-- if a hyphenated range or has endash or emdash separators
			if item:match ('%a+[%.%-]?%d+%s*%-%s*%a+[%.%-]?%d+') or				-- letterdigit hyphen letterdigit (optional separator between letter and digit)
				item:match ('%d+[%.%-]?%a+%s*%-%s*%d+[%.%-]?%a+') or			-- digitletter hyphen digitletter (optional separator between digit and letter)
				item:match ('%d+[%.%-]%d+%s*%-%s*%d+[%.%-]%d+') or				-- digit separator digit hyphen digit separator digit
				item:match ('%d+%s*%-%s*%d+') or								-- digit hyphen digit
				item:match ('%a+%s*%-%s*%a+') then								-- letter hyphen letter
					item = item:gsub ('(%w*[%.%-]?%w+)%s*%-%s*(%w*[%.%-]?%w+)', '%1–%2');	-- replace hyphen, remove extraneous space characters
			else
				item = mw.ustring.gsub (item, '%s*[–—]%s*', '–');				-- for endash or emdash separated ranges, replace em with en, remove extraneous white space
			end
		end
		item = item:gsub ('^%(%((.+)%)%)$', '%1');								-- remove the accept-this-as-written markup
		table.insert (out, item);												-- add the (possibly modified) item to the output table
	end

	return table.concat (out, ', ');											-- concatenate the output table into a comma separated string
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'dupicate character'
		if 1 == #duplicate_char then											-- for single byte ascii characters use the string library functions
			f.gsub=string.gsub
			f.match=string.match
			f.sub=string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub=mw.ustring.gsub
			f.match=mw.ustring.match
			f.sub=mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1,1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = f.sub(str, -1,-1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if f.sub(str, -3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5,-1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4,-1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if f.sub(str, -3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3,-1) == duplicate_char .. '&quot;]' then		-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2,-1) == duplicate_char .. &quot;]&quot; then		-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4,-1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2,-1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows html markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;------------------------------------------------------------

returns true is suffix is properly formed Jr, Sr, or ordinal in the range 2–9.  Puncutation not allowed.

]]

local function is_suffix (suffix)
	if in_array (suffix, {'Jr', 'Sr', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written ouside of the code editor and pasted here because the code editor gets confused between character insertion point and cursor position.
The test has been rewritten to use decimal character escape sequence for the individual bytes of the unicode characters so that it is not necessary
to use an external editor to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first)
	local first, suffix = first:match ('(.-),?%s*([%dJS][%drndth]+)%.?$') or first;		-- if first has something that looks like a generational suffix, get it

	if is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error ('suffix');
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error ('non-Latin character');
			return false;														-- not a string of latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just intials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error ('suffix');									-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word


	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i],1,1));				-- insert the intial at end of initials table
		end
		i = i+1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between authors is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between authors is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = make_wikilink (person.link, one);						-- link author/editor if this page is not the author's/editor's page
				end
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end


--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]
local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of name parameters (author, editor, etc) for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the associated |display-&lt;names&gt;=etal parameter

]]

local function name_has_etal (name, etal, nocat, param)

	if is_set (name) then														-- name can be nil in which case just return
		local patterns = cfg.et_al_patterns;									--get patterns from configuration
		
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns
			if name:match (pattern) then										-- if this 'et al' pattern is found in name
				name = name:gsub (pattern, '');									-- remove the offending text
				etal = true;													-- set flag (may have been set previously here or by |display-&lt;names&gt;=etal)
				if not nocat then												-- no categorization for |vauthors=
					table.insert( z.message_tail, {set_error ('etal', {param})});		-- and set an error if not added
				end
			end
		end
	end

	return name, etal;															-- 
end


--[[--------------------------&lt; N A M E _ H A S _ E D _ M A R K U P &gt;------------------------------------------

Evaluates the content of author and editor parameters for extranious editor annotations: ed, ed., eds, (Ed.), etc.
These annotation do not belong in author parameters and are redundant in editor parameters.  If found, the function
adds the editor markup maintenance category.

]]

local function name_has_ed_markup (name, list_name)
	local _, pattern;
	local patterns = cfg.editor_markup_patterns;								-- get patterns from configuration

	if is_set (name) then
		for _, pattern in ipairs (patterns) do									-- spin through patterns table and
			if name:match (pattern) then
				add_maint_cat ('extra_text_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
				break;
			end
		end
	end
	return name;																-- and done
end


--[[--------------------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;----------------------------------------

Evaluates the content of author and editor (surnames only) parameters for multiple names.  Multiple names are
indicated if there is more than one comma and or semicolon.  If found, the function adds the multiple name
(author or editor) maintenance category.

]]

local function name_has_mult_names (name, list_name)
local count, _;
	if is_set (name) then
		_, count = name:gsub ('[;,]', '');										-- count the number of separator-like characters
		
		if 1 &lt; count then														-- param could be |author= or |editor= so one separator character is acceptable
			add_maint_cat ('mult_names', cfg.special_case_translation [list_name]);	-- more than one separator indicates multiple names so add a maint cat for this template
		end
	end
	return name;																-- and done
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------
This function calls various name checking functions used to validate the content of the various name-holding
parameters.

]]

local function name_checks (last, first, list_name)
	if is_set (last) then
		if last:match ('^%(%(.*%)%)$') then										-- if wrapped in doubled parentheses, accept as written 
			last = last:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			last = name_has_mult_names (last, list_name);						-- check for multiple names in the parameter (last only)
			last = name_has_ed_markup (last, list_name);						-- check for extraneous 'editor' annotation
		end
	end
	if is_set (first) then
		if first:match ('^%(%(.*%)%)$') then									-- if wrapped in doubled parentheses, accept as written 
			first = first:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			first = name_has_ed_markup (first, list_name);						-- check for extraneous 'editor' annotation
		end
	end
	return last, first;															-- done
	end


--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local last_alias, first_alias;												-- selected parameter aliases used in error messaging
	while true do
		last, last_alias = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first, first_alias = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.
		last, first= name_checks (last, first, list_name);						-- multiple names, extraneous annotation, etc checks
		
		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {first_alias, first_alias:gsub('first', 'last')}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			link_title_ok (link, list_name:match (&quot;(%w+)List&quot;):lower() .. '-link' .. i, last, list_name:match (&quot;(%w+)List&quot;):lower() .. '-last' .. i);	-- check for improper wikimarkup

			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {list_name:match (&quot;(%w+)List&quot;):lower(), i-1}, true ) } );	-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because case of the source may be incorrect
or different from the case that WikiMedia uses, the name comparisons are done in lower case and when a match is
found, the Wikimedia version (assumed to be correct) is returned along with the code.  When there is no match, we
return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') returns a list of languages that in some cases may include
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.  Most (all?) of these languages are not used a 'language' codes per se, rather they
are used as sub-domain names: cbk-zam.wikipedia.org.  A list of language names and codes supported by fetchLanguageNames()
can be found at Template:Citation Style documentation/language/doc

Names that are included in the list will be found if that name is provided in the |language= parameter.  For example,
if |language=Chavacano de Zamboanga, that name will be found with the associated code 'cbk-zam'.  When names are found
and the associated code is not two or three characters, this function returns only the WikiMedia language name.

Some language names have multiple entries under different codes:
	Aromanian has code rup and code roa-rup
When this occurs, this function returns the language name and the 2- or 3-character code

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	if cfg.lang_name_remap[lang:lower()] then									-- if there is a remapped name (because MediaWiki uses something that we don't think is correct)
		return cfg.lang_name_remap[lang:lower()][1], cfg.lang_name_remap[lang:lower()][2];	-- for this language 'name', return a possibly new name and appropriate code
	end

	local ietf_code;															-- because some languages have both ietf-like codes and iso 639-like codes
	local ietf_name;
	
	local languages = mw.language.fetchLanguageNames(this_wiki_code, 'all')		-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons

	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 == code:len() or 3 == code:len() then							-- two- or three-character codes only; extensions not supported
				return name, code;												-- so return the name and the code
			end
			ietf_code = code;													-- remember that we found an ietf-like code and save its name
			ietf_name = name;													-- but keep looking for a 2- or 3-char code
		end
	end
																				-- didn't find name with 2- or 3-char code; if ietf-like code found return
	return ietf_code and ietf_name or lang;										-- associated name; return original language text else
end


--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code is recognized by MediaWiki,
use the returned name; if not, then use the value that was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is assigned to the category for
that code: Category:Norwegian-language sources (no).  For valid three-character code languages, the page is assigned
to the single category for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does not recognize three-character
equivalents of two-character codes: code 'ar' is recognized bit code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are
separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki = mw.getContentLanguage();									-- get a language object for this wiki
	local this_wiki_code = this_wiki:getCode()									-- get this wiki's language code
	local this_wiki_name = mw.language.fetchLanguageName(this_wiki_code, this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang
		name = cfg.lang_code_remap[lang:lower()];								-- first see if this is a code that is not supported by MediaWiki but is in remap

		if name then															-- there was a remapped code so
			lang = lang:gsub ('^(%a%a%a?)%-.*', '%1');							-- strip ietf tags from code
		else
			if lang:match ('^%a%a%-') then										-- strip ietf tags from code; TODO: is there a need to support 3-char with tag?
				lang = lang:match ('(%a%a)%-')									-- keep only 639-1 code portion to lang; TODO: do something with 3166 alpha 2 country code?
			end
			if 2 == lang:len() or 3 == lang:len() then							-- if two-or three-character code
				name = mw.language.fetchLanguageName (lang:lower(), this_wiki_code);	-- get language name if |language= is a proper code
			end
		end

		if is_set (name) then													-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, this_wiki_code);				-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then													-- only 2- or 3-character codes
			name = cfg.lang_code_remap[code] or name;							-- override wikimedia when they misuse language codes/names

			if this_wiki_code ~= code then										-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					add_prop_cat ('foreign_lang_source' .. code, {name, code})	-- categorize it
				else															-- or is a recognized language (but has a three-character code)
					add_prop_cat ('foreign_lang_source_2' .. code, {code})		-- categorize it differently TODO: support mutliple three-character code categories per cs1|2 template
				end
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, cfg.messages['parameter-pair-separator'])		-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		name = table.concat (language_list, ', ');											-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
		name = name:gsub (', ([^,]+)$', cfg.messages['parameter-final-separator'] .. '%1');	-- replace last '&lt;comma&gt;&lt;space&gt;' separator with '&lt;comma&gt;&lt;space&gt;and&lt;space&gt;' separator
	end
	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings
At en.wiki, for cs1:
	ps gets:	'.'
	sep gets:	'.'

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = cfg.presentation['ps_cs1'];										-- terminate the rendered citation
	end
	return cfg.presentation['sep_cs1'], ps;										-- element separator
end


--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings
At en.wiki, for cs2:
	ps gets:	'' (empty string - no terminal punctuation)
	sep gets:	','

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = cfg.presentation['ps_cs2'];										-- terminate the rendered citation
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return cfg.presentation['sep_cs2'], ps, ref;								-- element separator
end


--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end


--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end


--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or
		url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
		url:match ('%.PDF&amp;#035') or url:match ('%.pdf&amp;#035');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parentheses, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[--------------------------&lt; G E T _ D I S P L A Y _ N A M E S &gt;--------------------------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_names (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_name', cfg.special_case_translation [list_name]);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parnetheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a place holder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parens
			local name = name_table[i];
			i=i+1;																-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parens
					break;														-- and done reassembling so
				end
				i=i+1;															-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = is_wikilink (name_table[i]);					-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i+1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parentheses to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')								-- remove doubled parntheses
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error ('punctuation');
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
			if is_suffix (first) then											-- if a valid suffix
				suffix = first													-- save it as a suffix and
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end																	-- no suffix error message here because letter combination may be result of Romanization; check for digits?
			last = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error ('missing comma');								-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error ('name');										-- matches a space between two intiials
			end
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error ('initials');									-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first);									-- check first and last before restoring the suffix which may have a non-Latin digit
			if is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '');
			end
		end

		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ) or v_link_table[i];
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice incase we have a |first1= without a |last1=; this ...
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or	-- ... also catches the case where |first= is used with |vauthors=
		select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, no, etc).  When the parameter value has not been assigned a value (missing or empty
in the source template) the function returns true.  If the parameter value is one of the list of allowed values returns
true; else, emits an error message and returns false.

]]

local function is_valid_parameter_value (value, name, possible)
	if not is_set (value) then
		return true;															-- an empty parameter is ok
	elseif in_array(value:lower(), possible) then
		return true;
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list,-3,-1) == sepc .. '. ') then						-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list,-1,-1) == sepc) or (string.sub (name_list,-3,-1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terninate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not is_set (volume) and not is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end

	local vol = '';																-- here for all cites except magazine
		
	if is_set (volume) then
		if volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$')then			-- volume value is all digits or all uppercase roman numerals
			vol = substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});	-- render in bold face
		elseif (4 &lt; mw.ustring.len(volume)) then								-- not all digits or roman numerals and longer than 4 characters
			vol = substitute (cfg.messages['j-vol'], {sepc, volume});			-- not bold
			add_prop_cat ('long_vol');
		else																	-- four or less characters
			vol = substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});	-- bold
		end
	end
	if is_set (issue) then
		return vol .. substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if is_set (page) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif is_set(pages) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then										-- if pages is only digits, assume a single page number
			return '', substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to wikisource, returns the label portion of the interwikilink as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki link to and external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, pages, at)
	local ws_url, ws_label, coins_pages, L;										-- for wikisource interwikilinks; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if is_set (page) then
		if is_set (pages) or is_set(at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws url from |page= interwiki link; link portion L becomes tool tip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif is_set (pages) then
		if is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws url from |pages= interwiki link; link portion L becomes tool tip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws url from |at= interwiki link; link portion L becomes tool tip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end



--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org urls to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot url or to calendar pages.  When the archive url is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the url.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org url does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command url
	|archive-url= is an archive.org url that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org urls:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this funct may return a modified
archive url:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the url unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.or url
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine url
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command url, we don't want to allow saving of the target page 
		err_msg = 'save command';
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = 'liveweb';
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');		-- split out some of the url parts for evaluation
		
		if not is_set(timestamp) or 14 ~= timestamp:len() then					-- path and flag optional, must have 14-digit timestamp here
			err_msg = 'timestamp';
			if '*' ~= flag then
				url=url:gsub ('(//web%.archive%.org/[^%d]*%d?%d?%d?%d?%d?%d?)[^/]*', '%1*', 1)	-- for preview, modify ts to be yearmo* max (0-6 digits plus splat)
			end
		elseif is_set(path) and 'web/' ~= path then								-- older archive urls do not have the extra 'web/' path element
			err_msg = 'path';
		elseif is_set (flag) and not is_set (path) then							-- flag not allowed with the old form url (without the 'web/' path element)
			err_msg = 'flag';
		elseif is_set (flag) and not flag:match ('%a%a_') then					-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = 'flag';
		else
			return url, date;													-- return archiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	table.insert( z.message_tail, { set_error( 'archive_url', {err_msg}, true ) } );	-- add error message and
	if is_set (Frame:preprocess('{{REVISIONID}}')) then
		return '', '';															-- return empty strings for archiveURL and ArchiveDate
	else
		return url, date;														-- preview mode so return archiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

-- set default parameter values defined by |mode= parameter.
	local Mode = A['Mode'];
	if not is_valid_parameter_value (Mode, 'mode', cfg.keywords['mode']) then
		Mode = '';
	end

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				add_maint_cat ('authors');										-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
			add_maint_cat ('editors');											-- but add a maint cat because use of this parameter is discouraged
		end
	end

	local translator_etal;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=

	local interviewer_etal;
	local interviewers_list = {};												
	local Interviewers;															-- used later
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters

	local contributor_etal;
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list
	local Contribution = A['Contribution'];
	if in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not is_set (Contribution) then									-- |contributor= requires |contribution=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if select_one (args, cfg.aliases['ContributorList-Last'], 'redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { set_error( 'contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if not is_valid_parameter_value (NameListFormat, 'name-list-format', cfg.keywords['name-list-format']) then			-- only accepted value for this parameter is 'vanc'
		NameListFormat = '';													-- anything else, set to empty string
	end

if is_set (Others) then
	if 0 == #a and 0 == #e then									-- add maint cat when |others= has value and used without |author=, |editor=
		add_maint_cat ('others');
	end
end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
			link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wikimarkup in |title-link= or wikimarkup in |title= when |title-link= is set

	local Chapter = A['Chapter'];
	local ScriptChapter = A['ScriptChapter'];
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];

	local ArchiveDate;
	local ArchiveURL;

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	
	local DeadURL = A['DeadURL']
		if not is_valid_parameter_value (DeadURL, 'dead-url', cfg.keywords ['deadurl']) then	-- set in config.defaults to 'yes'
			DeadURL = '';														-- anything else, set to empty string
		end

	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];
	local Periodical_origin = A:ORIGIN('Periodical');							-- get the name of the periodical parameter

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if in_array (config.CitationClass, cfg.templates_using_volume) then
		Volume = A['Volume'];
	end
																				-- conference &amp; map books do not support issue
	if in_array (config.CitationClass, cfg.templates_using_issue) and not (in_array (config.CitationClass, {'conference', 'map'}) and not is_set (Periodical))then
		Issue = hyphen_to_dash (A['Issue']);
	end
	local Position = '';
	if not in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash (A['Pages']);	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local RegistrationRequired = A['RegistrationRequired'];
		if not is_valid_parameter_value (RegistrationRequired, 'registration', cfg.keywords ['yes_true_y']) then
			RegistrationRequired=nil;
		end

	local SubscriptionRequired = A['SubscriptionRequired'];
		if not is_valid_parameter_value (SubscriptionRequired, 'subscription', cfg.keywords ['yes_true_y']) then
			SubscriptionRequired=nil;
		end

	local UrlAccess = A['UrlAccess'];
		if not is_valid_parameter_value (UrlAccess, 'url-access', cfg.keywords ['url-access']) then
			UrlAccess = nil;
		end
		if not is_set(URL) and is_set(UrlAccess) then
			UrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {'url'}, true ) } );
		end

		if is_set (UrlAccess) and is_set (SubscriptionRequired) then			-- while not aliases, these are much the same so if both are set
			table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'url-access') .. ' and ' .. wrap_style ('parameter', 'subscription')}, true ) } );		-- add error message
			SubscriptionRequired = nil;											-- unset; prefer |access= over |subscription=
		end
		if is_set (UrlAccess) and is_set (RegistrationRequired) then			-- these are not the same but contradictory so if both are set
			table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'url-access') .. ' and ' .. wrap_style ('parameter', 'registration')}, true ) } );		-- add error message
			RegistrationRequired = nil;											-- unset; prefer |access= over |registration=
		end

	local ChapterUrlAccess = A['ChapterUrlAccess'];
		if not is_valid_parameter_value (ChapterUrlAccess, 'chapter-url-access', cfg.keywords ['url-access']) then	-- same as url-access
			ChapterUrlAccess = nil;
		end
		if not is_set(ChapterURL) and is_set(ChapterUrlAccess) then
			ChapterUrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {'chapter-url'}, true ) } );
		end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local Agency = A['Agency'];

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
		if not is_valid_parameter_value (IgnoreISBN, 'ignore-isbn-error', cfg.keywords ['yes_true_y']) then
			IgnoreISBN = nil;													-- anything else, set to empty string
		end
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );
	local ID_access_levels = extract_id_access_levels( args, ID_list );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
		if not is_valid_parameter_value (LastAuthorAmp, 'last-author-amp', cfg.keywords ['yes_true_y']) then
			LastAuthorAmp = nil;												-- set to empty string
		end

	local no_tracking_cats = A['NoTracking'];
		if not is_valid_parameter_value (no_tracking_cats, 'no-tracking', cfg.keywords ['yes_true_y']) then
			no_tracking_cats = nil;												-- set to empty string
		end

	--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = A['DF'];															-- date format set in cs1|2 template
	if not is_valid_parameter_value (DF, 'df', cfg.keywords['date-format']) then	-- validate reformatting keyword
		DF = '';																-- not valid, set to empty string
	end
	if not is_set (DF) then
		DF = cfg.global_df;
	end

	local sepc;											-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );					-- used to control capitalization for certain static text

	--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

	-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	select_one( args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'redundant_parameters' );		-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, Pages, At);

	local NoPP = A['NoPP'] 
	if is_set (NoPP) and is_valid_parameter_value (NoPP, 'nopp', cfg.keywords ['yes_true_y']) then
		NoPP = true;
	else
		NoPP = nil;																-- unset, used as a flag later
	end

	-- both |publication-place= and |place= (|location=) allowed if different
	if not is_set(PublicationPlace) and is_set(Place) then
		PublicationPlace = Place;							-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end		-- don't need both if they are the same
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia and |title then map |title to |article and |encyclopedia to |title
		|encyclopedia and |article then map |encyclopedia to |title
		|encyclopedia then map |encyclopedia to |title
	
		|trans-title maps to |trans-chapter when |title is re-mapped
		|url maps to |chapterurl when |title is remapped
	
	All other combinations of |encyclopedia, |title, and |article are not modified
	
	]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set(Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterUrlAccess = UrlAccess;

					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter = make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			else																-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set or not set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if is_set(A['Number']) then												-- cite techreport uses 'number', which other citations alias to 'issue'
			if not is_set(ID) then												-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', 'id') .. ' and ' .. wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

	-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	elseif 'mailinglist' == A:ORIGIN('Periodical') then
		Periodical = '';														-- unset because mailing list is only used for cite mailing list
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		ChapterUrlAccess = UrlAccess;
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];

		link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wikimarkup in |series-link= or wikimarkup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) and is_set (AirDate) then							-- promote airdate to date
			Date = AirDate;
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('series', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = make_wikilink (ChapterLink, Chapter);
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = make_wikilink (SeriesLink, Series);
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, before generation of COinS data.
	do
		if in_array (config.CitationClass, {'arxiv', 'biorxiv', 'citeseerx'}) then
			if not is_set (ID_list[config.CitationClass:upper()]) then			-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp; |citeseerx= required for their templates
				table.insert( z.message_tail, { set_error( config.CitationClass .. '_missing', {}, true ) } );		-- add error message
			end
			
			if 'arxiv' == config.CitationClass then
				Periodical = 'arXiv';											-- set to arXiv for COinS; after that, must be set to empty string
			end

			if 'biorxiv' == config.CitationClass then
				Periodical = 'bioRxiv';											-- set to bioRxiv for COinS; after that, must be set to empty string
			end

			if 'citeseerx' == config.CitationClass then
				Periodical = 'CiteSeerX';										-- set to CiteSeerX for COinS; after that, must be set to empty string
			end
		end
	end

	-- handle type parameter for those CS1 citations that have default values
	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;interview&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
		TitleType = substitute( cfg.messages['type'], TitleType);				-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging

	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val=AccessDate, name=A:ORIGIN ('AccessDate')},
			['archive-date'] = {val=ArchiveDate, name=A:ORIGIN ('ArchiveDate')},
			['date'] = {val=Date, name=Date_origin},
			['doi-broken-date'] = {val=DoiBroken, name=A:ORIGIN ('DoiBroken')},
			['embargo'] = {val=Embargo, name=A:ORIGIN ('Embargo')},
			['lay-date'] = {val=LayDate, name=A:ORIGIN ('LayDate')},
			['publication-date'] ={val=PublicationDate, name=A:ORIGIN ('PublicationDate')},
			['year'] = {val=Year, name=A:ORIGIN ('Year')},
			};
		anchor_year, Embargo, error_message = dates(date_parameters_list, COinS_date);

-- start temporary Julian / Gregorian calendar uncertainty categorization
		if COinS_date.inter_cal_cat then
			add_prop_cat ('jul_greg_uncertainty');
		end
-- end temporary Julian / Gregorian calendar uncertainty categorization

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end
		
		if not is_set(error_message) then										-- error free dates only
			local modified = false;												-- flag
			
			if is_set (DF) then													-- if we need to reformat dates
				modified = reformat_dates (date_parameters_list, DF, false);	-- reformat to DF format, use long month names if appropriate
			end

			if true == date_hyphen_to_dash (date_parameters_list) then			-- convert hyphens to dashes where appropriate
				modified = true;
				add_maint_cat ('date_format');									-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language,
	-- uncomment these three lines.  Not supported by en.wiki (for obvious reasons)
	-- set date_name_xlate() second argument to true to translate English digits to local digits (will translate ymd dates)
--			if date_name_xlate (date_parameters_list, false) then
--				modified = true;
--			end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				LayDate = date_parameters_list['lay-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end
		else
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end
	end	-- end of do

	-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
	-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
			if is_set(AccessDate) then											-- access date requires |url=; pmc created url is not |url=
				table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
				AccessDate = '';												-- unset
			end

		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
			if 'episode' == config.CitationClass then							-- special case for cite episode; TODO: is there a better way to do this?
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
			else
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
			end
	end
	
	if 'none' == Title and in_array (config.CitationClass, {'journal', 'citation'}) and is_set (Periodical) and 'journal' == A:ORIGIN('Periodical') then	-- special case for journal cites
		Title = '';																-- set title to empty string
		add_maint_cat ('untitled');
	end

	check_for_url ({															-- add error message when any of these parameters contains a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[A:ORIGIN('Periodical')]=Periodical,
		[A:ORIGIN('PublisherName')] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = Periodical,
		['Encyclopedia'] = Encyclopedia,
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = coins_pages or get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),				-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, and {{cite citeseerx}} AFTER generation of COinS data.
	if in_array (config.CitationClass, {'arxiv', 'biorxiv', 'citeseerx'}) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, or CiteSeerX now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = substitute (cfg.messages['newsgroup'], external_link( 'news:' .. PublisherName, PublisherName, A:ORIGIN('PublisherName'), nil ));
		end
	end



	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text,											-- get current page name so that we don't wikilink to it via editorlinkn
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_names (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if is_set (Editors) then
				Editors, editor_etal = name_has_etal (Editors, editor_etal, false, 'editors');	-- find and remove variations on et al.
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
					EditorCount = 2;											-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
				else
					EditorCount = 2;											-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
				end
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum , interviewer_etal = get_display_names (A['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal);
			Interviewers = list_people (control, interviewers_list, interviewer_etal);
		end
		do																		-- now do translators
			control.maximum , translator_etal = get_display_names (A['DisplayTranslators'], #t, 'translators', translator_etal);
			Translators = list_people (control, t, translator_etal);
		end
		do																		-- now do contributors
			control.maximum , contributor_etal = get_display_names (A['DisplayContributors'], #c, 'contributors', contributor_etal);
			Contributors = list_people (control, c, contributor_etal);
--			control.maximum = #c;												-- number of contributors
--			Contributors = list_people(control, c, false);						-- et al not currently supported
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_names (A['DisplayAuthors'], #a, 'authors', author_etal);

			last_first_list = list_people(control, a, author_etal);

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors');	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if is_set (Authors) and is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
	-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not is_set(URL) then
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) then	-- |url= required for cite web, cite podcast, and cite mailinglist
			table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURLorigin, OriginalFormat, OriginalAccess;
	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (ChapterURL) then 											-- if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURLorigin = ChapterURLorigin;								-- name of chapter-url parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=
			if 'no' ~= DeadURL then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				ChapterURLorigin = A:ORIGIN('ArchiveURL')						-- name of archive-url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived urls
			end
		elseif is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURLorigin = URLorigin;										-- name of url parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;
			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived urls
			end
 		end
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) then
			local chap_param;
			if is_set (Chapter) then											-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif is_set (ScriptChapter) then
				chap_param = A:ORIGIN ('ScriptChapter')
			else is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if is_set (chap_param) then											-- if we found one
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {chap_param}, true ) } );		-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if is_set (Contribution) and 0 &lt; #c then								-- if this is a contribution with contributor(s)
			if in_array (Contribution:lower(), cfg.keywords.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, Chapter, TransChapter, ChapterURL, ChapterURLorigin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter.. sepc .. ' ';
		elseif is_set (ChapterFormat) then										-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title.
	if is_set (ArchiveURL) and mw.ustring.match (mw.ustring.lower(Title), cfg.special_case_translation['archived_copy']) then	-- if title is 'Archived copy' (place holder added by bots that can't find proper title)
		add_maint_cat ('archived_copy');										-- add maintenance category before we modify the content of Title
	end

	if Title:match ('^%(%(.*%)%)$') then										-- if keep as written markup:
		Title= Title:gsub ('^%(%((.*)%)%)$', '%1')								-- remove the markup
	else
		if '...' == Title:sub (-3) then											-- if elipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%'..sepc..'$', '');				-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end
	end
	
	if in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx'}) or
		('citation' == config.CitationClass and is_set (Periodical) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and is_set (Periodical)) then			-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle);						-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end

	if is_set(Title) then
		if not is_set (TitleLink) and is_set (URL) then
			Title = external_link (URL, Title, URLorigin, UrlAccess) .. TransTitle .. TransError .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif is_set (TitleLink) and not is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = make_wikilink (TitleLink, Title) .. TransTitle .. TransError;
			end
		else
			local ws_url, ws_label;
			ws_url, ws_label, L = wikisource_url_make (Title);					-- make ws url from |title= interwiki link; link portion L becomes tool tip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = Title .. TransTitle .. TransError;
			end
		end
	else
		Title = TransTitle .. TransError;
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURLorigin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin, nil );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if is_set(Minutes) then
			if is_set (Time) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'minutes') .. ' and ' .. wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = is_set(Series) and (sepc .. &quot; &quot; .. Series) or &quot;&quot;;
		OrigYear = is_set(OrigYear) and (&quot; [&quot; .. OrigYear .. &quot;]&quot;) or &quot;&quot;;		-- TODO: presentation

	Agency = is_set(Agency) and (sepc .. &quot; &quot; .. Agency) or &quot;&quot;;

	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	if is_set(Via) then
		Via = &quot; &quot; .. wrap_msg ('via', Via);
	end

	--[[
	Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
	note is displayed. There are no error messages for this condition.
	
	]]
	if is_set (SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif is_set (RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text

		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {IdAccessLevels=ID_access_levels, DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin, UrlAccess );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then				-- if first and last characters of quote are quote marks
			Quote = Quote:sub(2,-2);											-- strip them off
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;no&quot; == DeadURL then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-not-dead'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- DeadURL is empty, 'yes', 'true', 'y', 'unfit', 'usurped'
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if in_array (DeadURL, {'unfit', 'usurped', 'bot: unknown'}) then
				Archived = sepc .. &quot; &quot; .. 'Archived from the original on ' .. ArchiveDate;	-- format already styled
				if 'bot: unknown' == DeadURL then
					add_maint_cat ('bot:_unknown');								-- and add a category if not already added
				else
					add_maint_cat ('unfit');									-- and add a category if not already added
				end
			else																-- DeadURL is empty, 'yes', 'true', or 'y'
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURLorigin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURLorigin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin, nil );
	end

	local Publisher;
	if is_set(PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if is_set(PublisherName) then
		if is_set(PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif is_set(PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if is_set(Periodical) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. wrap_style ('italic-title', Periodical) 
		else 
			Periodical = wrap_style ('italic-title', Periodical)
		end
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then				-- cite speech only
		TitleNote = &quot; (Speech)&quot;;							-- annotate the citation
		if is_set (Periodical) then							-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then						-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;		-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = safe_join ({Others, sepc .. &quot; &quot;}, sepc) end		-- add terminal punctuation &amp; space; check for dup sepc; TODO why do we need to do this here?
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(Periodical) then		-- special cases for book cites
		if is_set (Contributors) then											-- when we are citing foreword, preface, introduction, etc
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon;
	if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then	-- special case for cite AV media &amp; cite episode position transcript
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	else
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	end
	
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if is_set(Date) then
		if is_set (Authors) or is_set (Editors) then							-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;;				-- in paranetheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon,-1,-1) == sepc) then							-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigYear;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigYear;							-- Date begins with sepc
			end
		end
	end	
	if is_set(Authors) then
		if (not is_set (Date)) then												-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then
					in_text = in_text:lower()									-- lowercase for cs2
				end
			end
			if EditorCount &lt;= 1 then
				post_text = &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot;;				-- be consistent with no-author, no-date case
			else
				post_text = &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot;;
			end
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if is_set (Contributors) then											-- book cite and we're citing the intro, preface, etc
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if is_set (Editors) and is_set (Date) then							-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not is_set (Date)) then											-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc );  --Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = config.CitationClass;
		options.class = &quot;citation &quot; .. config.CitationClass;					-- class=citation required for blue highlight when used with |ref=
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then								-- set reference anchor if appropriate
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			if #namelist &gt; 0 then												-- if there are names in namelist
				id = anchor_id (namelist, year);								-- go make the CITEREF anchor
			else
				id = '';														-- unset
			end
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;(.-)&lt;/span&gt;&quot;, &quot;%1&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then	-- remove &lt;span&gt; tags and other html-like markup; then get length of what remains
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	local render = {};															-- here we collect the final bits for concatenation into the rendered citation

	if is_set(options.id) then													-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render, substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text}));	-- when |ref= is set
	else
		table.insert (render, substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text}));	-- all other cases
	end		

	table.insert (render, substitute (cfg.presentation['ocins'], {OCinSoutput}));		-- append metadata to the citation

	if 0 ~= #z.message_tail then
		table.insert (render, ' ');
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					table.insert (render, error_comment( v[1], v[2] ));
				else
					table.insert (render, error_comment( v[1] .. &quot;; &quot;, v[2] ));
				end
			end
		end
	end

	if 0 ~= #z.maintenance_cats then
		local maint_msgs = {};													-- here we collect all of the maint messages
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			local maint = {};													-- here we assemble a maintenence message
			table.insert (maint, v);											-- maint msg is the category name
			table.insert (maint, ' (');											-- open the link text
			table.insert (maint, make_wikilink (':Category:' .. v, 'link'));	-- add the link
			table.insert (maint, ')');											-- and close it
			table.insert (maint_msgs, table.concat (maint));					-- assemble new maint message and add it to the maint_msgs table
		end
		table.insert (render, substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs, ' ')));	-- wrap the group of maint message with proper presentation and save
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			table.insert (render, make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			table.insert (render, make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.properties_cats ) do								-- append properties categories
			table.insert (render, make_wikilink ('Category:' .. v));
		end
	end

	return table.concat (render);	
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class)
	local name = tostring (name);
	local state;
	
	if in_array (cite_class, {'arxiv', 'biorxiv', 'citeseerx'}) then			-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[name];
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end

		state = whitelist[cite_class .. '_basic_arguments'][name];				-- look in the parameter-list for the template identified by cite_class

		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
																				-- limited enumerated parameters list
		name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
		state = whitelist.limited_numbered_arguments[name];
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates
		
	state = whitelist.basic_arguments[name];									-- all other templates; all normal parameters allowed
											
	if true == state then return true; end										-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);											-- parameter is deprecated but still supported
		return true;
	end
																				-- all enumerated parameters allowed
	name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );												-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
	state = whitelist.numbered_arguments[name];

	if true == state then return true; end										-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);											-- parameter is deprecated but still supported
		return true;
	end
	
	return false;																-- not supported because not found or name is set to nil
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe:
	{{cite ... |title=Title access-date=2016-03-17}}

cs1|2 shares some parameter names with xml/html atributes: class=, title=, etc.  To prevent false positives xml/html
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (parameter, value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove xml/html tags because attributes: class=, title=, etc 

	capture = value:match ('%s+(%a[%a%d]+)%s*=') or value:match ('^(%a[%a%d]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then								-- if the capture is a valid parameter name
		table.insert( z.message_tail, {set_error ('missing_pipe',parameter)});
	end
end


--[[--------------------------&lt; C S 1 . C I T A T I O N &gt;------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

local function citation(frame)
	Frame = frame;																-- save a copy incase we need to display an error message in preview mode
	local pframe = frame:getParent()
	local validation, utilities, identifiers, metadata, styles;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		styles = 'Module:Citation/CS1/sandbox/styles.css';
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
		styles = 'Module:Citation/CS1/styles.css';

	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	dates = validation.dates;													-- imported functions from Module:Citation/CS1/Date validation
	year_date_check = validation.year_date_check;
	reformat_dates = validation.reformat_dates;
	date_hyphen_to_dash = validation.date_hyphen_to_dash;
	date_name_xlate = validation.date_name_xlate;

	is_set = utilities.is_set;													-- imported functions from Module:Citation/CS1/Utilities
	in_array = utilities.in_array;
	substitute = utilities.substitute;
	error_comment = utilities.error_comment;
	set_error = utilities.set_error;
	select_one = utilities.select_one;
	add_maint_cat = utilities.add_maint_cat;
	wrap_style = utilities.wrap_style;
	safe_for_italics = utilities.safe_for_italics;
	is_wikilink = utilities.is_wikilink;
	make_wikilink = utilities.make_wikilink;

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	extract_ids = identifiers.extract_ids;										-- imported functions from Module:Citation/CS1/Identifiers
	build_id_list = identifiers.build_id_list;
	is_embargoed = identifiers.is_embargoed;
	extract_id_access_levels = identifiers.extract_id_access_levels;
	
	make_coins_title = metadata.make_coins_title;								-- imported functions from Module:Citation/CS1/COinS
	get_coins_pages = metadata.get_coins_pages;
	COinS = metadata.COinS;

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text, error_state;

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do
		config[k] = v;
--		args[k] = v;															-- debug tool that allows us to render a citation from module {{#invoke:}}
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower(), config.CitationClass ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute (param, capture);				-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text, error_state = set_error ('parameter_ignored_suggest', {k, param}, true);	-- set the suggestion error message
							else
								error_text, error_state = set_error( 'parameter_ignored', {param}, true );	-- suggested param not supported by this template
							end
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?
																				-- TODO: is this the best place for this translation?
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then						-- here when v is empty string
			args[k] = v;														-- why do we do this?  we don't support 'empty' parameters
		end		
	end	

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);
		end
	end
	return table.concat ({citation0( config, args), frame:extensionTag ('templatestyles', '', {src=styles})});
end

--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {citation = citation};</text>
      <sha1>jzwo2dr3jrjgr6d0tp46g4ca3srpo7r</sha1>
    </revision>
    <revision>
      <id>4726</id>
      <parentid>4725</parentid>
      <timestamp>2019-09-03T13:09:20Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Undid revision 913826030 by [[Special:Contributions/Ivanvector|Ivanvector]] ([[User talk:Ivanvector|talk]]) broke the cs1|2 templates;</comment>
      <origin>4726</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="185337" sha1="s1ptsqky6jla2ch3vxqftih7lhqkoeh" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local dates, year_date_check, reformat_dates, date_hyphen_to_dash,				-- functions in Module:Citation/CS1/Date_validation
	date_name_xlate

local is_set, in_array, substitute, error_comment, set_error, select_one,		-- functions in Module:Citation/CS1/Utilities
	add_maint_cat, wrap_style, safe_for_italics, is_wikilink, make_wikilink,
	strip_apostrophe_markup;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local extract_ids, extract_id_access_levels, build_id_list, is_embargoed;		-- functions in Module:Citation/CS1/Identifiers

local make_coins_title, get_coins_pages, COinS;									-- functions in Module:Citation/CS1/COinS

local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

delare variables here that have page-wide scope that are not brought in from other modules; thatare created here
and used here

]]

local added_deprecated_cat;														-- boolean flag so that the category is added only once
local added_prop_cats = {};														-- list of property categories that have been added to z.properties_cats
local added_vanc_errs;															-- boolean flag so we only emit one Vancouver error / category

local Frame;																	-- holds the module's frame table


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

foreign_lang_source and foreign_lang_source_2 keys have a language code appended to them so that multiple languages
may be categorized but multiples of the same language are not categorized.

added_prop_cats is a table declared in page scope variables above

]]

local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		key = key:gsub ('(foreign_lang_source_?2?)%a%a%a?', '%1');				-- strip lang code from keyname
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));	-- make name then add to table
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a boolean declared in page scope variables above

]]

local function add_vanc_error (source)
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {source}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a uri scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of tlds: https://www.iana.org/domains/root/db

rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the tld.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a url with a scheme) will be stripped
here.  Perhaps not necessary but retained incase it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ascii characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the tld) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and tld or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%w]') then											-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at wikisource
		return false;
	end

	local patterns = {															-- patterns that look like urls
		'%f[%w][%w][%w%-]+[%w]%.%a%a+$',										-- three or more character hostname.hostname or hostname.tld
		'%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$',									-- internationalized domain name with ACE prefix
		'%f[%a][qxz]%.com$',													-- assigned one character .com hostname (x.com times out 2015-12-10)
		'%f[%a][iq]%.net$',														-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		'%f[%w][%w]%.%a%a$',													-- one character hostname and cctld (2 chars)
		'%f[%w][%w][%w]%.%a%a+$',												-- two character hostname and tld
		'^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?',								-- IPv4 address
		}

	for _, pattern in ipairs (patterns) do										-- loop through the patterns list
		if domain:match (pattern) then
			return true;														-- if a match then we think that this thing that purports to be a url is a url
		end
	end

	for _, d in ipairs ({'cash', 'company', 'today', 'org'}) do					-- look for single letter second level domain names for these top level domains
		if domain:match ('%f[%w][%w]%.' .. d) then
			return true
		end
	end
	return false;																-- no matches, we don't know what this thing is
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a url appear to be a valid url; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if is_set (scheme) then														-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when url is protocol relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a url into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following tld) (if any) and any path(/), query(?) or fragment(#).

If protocol relative url, return nil scheme and domain else return nil for both scheme and domain.

When not protocol relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol relative url
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		authority = authority:gsub ('//', '', 1);								-- replace place 1 pair of '/' with nothing;
		if is_set(authority) then												-- if anything left (1 or 3+ '/' where authority should be) then
			return scheme;														-- return scheme only making domain nil which will cause an error message
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link= etc for properly formatted content: no wikilinks, no urls

Link parameters are to hold the title of a wikipedia article so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki urls and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid url (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid url (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from url; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid url
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wikilinked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

]]

local function link_title_ok (link, lorig, title, torig)
local orig;

	if is_set (link) then 														-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		end
	end

	if is_set (orig) then
		table.insert( z.message_tail, { set_error( 'bad_paramlink', orig)});	-- url or wikilink in |title= with |title-link=;
	end
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the url into scheme and domain
portions, or for protocol relative (//example.com) urls, just the domain.  Use is_url() to validate the two
portions of the url.  If both are valid, or for protocol relative if domain is valid, return true, else false.

Because it is different from a standard url, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper url
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from url;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a url.  The test will also find external wikilinks
that use protocol relative urls. Also finds bare urls.

The frontier pattern prevents a match on interwiki links which are similar to scheme:path urls.  The tests that
find bracketed urls are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol relative ext wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare url with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol relative bare url: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a url
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then												-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source, access)
	local error_str = &quot;&quot;;
	local domain;
	local path;
	local base_url;

	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the url into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['[']='%5b',[']']='%5d'});					-- replace '[' and ']' with their percent encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wikimarkup url

	if is_set (access) then														-- access level (subscription, registration, limited)
		base_url = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end
	
	return table.concat ({base_url, error_str});
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );	-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Replaces unicode quotemarks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc; not for book titles.

]=]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	local wl_type, label, link;

	wl_type, label, link = is_wikilink (str);									-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = substitute (cfg.presentation['kern-wl-both'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = substitute (cfg.presentation['kern-wl-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = substitute (cfg.presentation['kern-wl-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label= mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label= mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap, cap2 = mw.ustring.match (label, &quot;^([\&quot;\'])([^\'].+)&quot;);				-- match leading double or single quote but not doubled single quotes (italic markup)
		if is_set (cap) then
			label = substitute (cfg.presentation['kern-left'], {cap, cap2});
		end
	
		cap, cap2 = mw.ustring.match (label, &quot;^(.+[^\'])([\&quot;\'])$&quot;)				-- match trailing double or single quote but not doubled single quotes (italic markup)
		if is_set (cap) then
			label = substitute (cfg.presentation['kern-right'], {cap, cap2});
		end
		
		if 2 == wl_type then
			str = make_wikilink (link, label);									-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title=, |script-chapter=, |script-&lt;periodical&gt;=

]]

local function format_script_value (script_value, script_param)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			table.insert( z.message_tail, { set_error( 'script_parameter', {script_param, 'missing title part'}, true ) } );		-- prefix without 'title'; add error message
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_code_remap[lang] or mw.language.fetchLanguageName( lang, &quot;en&quot; );	-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, cfg.script_lang_codes) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				table.insert( z.message_tail, { set_error( 'script_parameter', {script_param, 'unknown language code'}, true ) } );	-- unknown script-language; add error message
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			table.insert( z.message_tail, { set_error( 'script_parameter', {script_param, 'invalid language code'}, true ) } );		-- invalid language code; add error message
			lang = '';															-- invalid so set lang to empty string
		end
	else
		table.insert( z.message_tail, { set_error( 'script_parameter', {script_param, 'missing prefix'}, true ) } );				-- no language code prefix; add error message
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script, script_param)
	if is_set (script) then
		script = format_script_value (script, script_param);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return substitute( msg, str );											-- including template text
	else
		return substitute( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;----------------------------------------

makes a wikisource url from wikisource interwiki link.  returns the url and appropriate label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;

	wl_type, D, L = is_wikilink (str);											-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if is_set (str) then
			ws_url = table.concat ({											-- build a wikisource url
				'https://en.wikisource.org/wiki/',								-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the url
		end
	elseif 1 == wl_type then														-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if is_set (str) then
			ws_url = table.concat ({											-- build a wikisource url
				'https://en.wikisource.org/wiki/',								-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the url
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a wikisource url
				'https://en.wikisource.org/wiki/',								-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end
	
	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable url
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent encoding of anchor
	end

	return ws_url, ws_label, L or D;											-- return proper url or nil and a label or nil
end


--[[--------------------------&lt; F O R M A T _ P E R I O D I C A L &gt;--------------------------------------------

Format the four periodical parameters: |script-&lt;periodical&gt;=, |&lt;periodical&gt;=, and |trans-&lt;periodical&gt;= into a single Periodical meta-
parameter.

]]

local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)
	local periodical_error = '';

	if not is_set (periodical) then
		periodical = '';														-- to be safe for concatenation
	else
		periodical = wrap_style ('italic-title', periodical);					-- style 
	end

	periodical = script_concatenate (periodical, script_periodical, script_periodical_source);	-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (trans_periodical) then
		trans_periodical = wrap_style ('trans-italic-title', trans_periodical);
		if is_set (periodical) then
			periodical = periodical ..  ' ' .. trans_periodical;
		else																	-- here when transchapter without chapter or script-chapter
			periodical = trans_periodical;
			periodical_error = ' ' .. set_error ('trans_missing_title', {'periodical'});
		end
	end

	return periodical .. periodical_error;
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (scriptchapter, script_chapter_source, chapter, transchapter, chapterurl, chapter_url_source, no_quotes, access)
	local chapter_error = '';

	local ws_url, ws_label, L = wikisource_url_make (chapter);					-- make a wikisource url and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', '');										-- replace underscore separaters with space characters
		chapter = ws_label;
	end

	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
			chapter = wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, scriptchapter, script_chapter_source);	-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (chapterurl) then
		chapter = external_link (chapterurl, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');	-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if is_set (transchapter) then
		transchapter = wrap_style ('trans-quoted-title', transchapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. transchapter;
		else																	-- here when transchapter without chapter or script-chapter
			chapter = transchapter;
			chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
		end
	end

--	if is_set (chapterurl) then
--		chapter = external_link (chapterurl, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
--	end

	return chapter .. chapter_error;
end


--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i=1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- Test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position and (char == 'zero width joiner') then						-- if we found a zero width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- its ok if one of the indic scripts
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { set_error( 'invisible_char', {err_msg, wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i=i+1;																	-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] .. ': ' .. k);
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash under certain conditions.  The hyphen must separate like items; unlike items are
returned unmodified.  These forms are modified:
	letter - letter (A - B)
	digit - digit (4-5)
	digit separator digit - digit separator digit (4.1-4.5 or 4-1-4-5)
	letterdigit - letterdigit (A1-A5) (an optional separator between letter and digit is supported – a.1-a.5 or a-1-a-5)
	digitletter - digitletter (5a - 5d) (an optional separator between letter and digit is supported – 5.a-5.d or 5-a-5-d)

any other forms are returned unmodified.

str may be a comma- or semicolon-separated list

]]

local function hyphen_to_dash( str )
	if not is_set (str) then
		return str;
	end
	
	str, count = str:gsub ('^%(%((.+)%)%)$', '%1');								-- remove accept-this-as-written markup when it wraps all of str
	if 0 ~= count then															-- non-zero when markup removed; zero else
		return str;																-- nothing to do, we're done
	end
	
	str = str:gsub ('&amp;[nm]dash;', {['&amp;ndash;'] = '–', ['&amp;mdash;'] = '—'});		-- replace &amp;mdash; and &amp;ndash; entities  with their characters; semicolon mucks up the text.split
	
	local out = {};
	local list = mw.text.split (str, '%s*[,;]%s*');								-- split str at comma or semicolon separators if there are any

	for _, item in ipairs (list) do												-- for each item in the list
		if mw.ustring.match (item, '^%w*[%.%-]?%w+%s*[%-–—]%s*%w*[%.%-]?%w+$') then	-- if a hyphenated range or has endash or emdash separators
			if item:match ('%a+[%.%-]?%d+%s*%-%s*%a+[%.%-]?%d+') or				-- letterdigit hyphen letterdigit (optional separator between letter and digit)
				item:match ('%d+[%.%-]?%a+%s*%-%s*%d+[%.%-]?%a+') or			-- digitletter hyphen digitletter (optional separator between digit and letter)
				item:match ('%d+[%.%-]%d+%s*%-%s*%d+[%.%-]%d+') or				-- digit separator digit hyphen digit separator digit
				item:match ('%d+%s*%-%s*%d+') or								-- digit hyphen digit
				item:match ('%a+%s*%-%s*%a+') then								-- letter hyphen letter
					item = item:gsub ('(%w*[%.%-]?%w+)%s*%-%s*(%w*[%.%-]?%w+)', '%1–%2');	-- replace hyphen, remove extraneous space characters
			else
				item = mw.ustring.gsub (item, '%s*[–—]%s*', '–');				-- for endash or emdash separated ranges, replace em with en, remove extraneous white space
			end
		end
		item = item:gsub ('^%(%((.+)%)%)$', '%1');								-- remove the accept-this-as-written markup
		table.insert (out, item);												-- add the (possibly modified) item to the output table
	end

	return table.concat (out, ', ');											-- concatenate the output table into a comma separated string
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'dupicate character'
		if 1 == #duplicate_char then											-- for single byte ascii characters use the string library functions
			f.gsub=string.gsub
			f.match=string.match
			f.sub=string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub=mw.ustring.gsub
			f.match=mw.ustring.match
			f.sub=mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1,1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = f.sub(str, -1,-1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if f.sub(str, -3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5,-1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4,-1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if f.sub(str, -3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3,-1) == duplicate_char .. '&quot;]' then		-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2,-1) == duplicate_char .. &quot;]&quot; then		-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4,-1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2,-1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows html markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;------------------------------------------------------------

returns true is suffix is properly formed Jr, Sr, or ordinal in the range 2–9.  Puncutation not allowed.

]]

local function is_suffix (suffix)
	if in_array (suffix, {'Jr', 'Sr', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written ouside of the code editor and pasted here because the code editor gets confused between character insertion point and cursor position.
The test has been rewritten to use decimal character escape sequence for the individual bytes of the unicode characters so that it is not necessary
to use an external editor to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first)
	local first, suffix = first:match ('(.-),?%s*([%dJS][%drndth]+)%.?$') or first;	-- if first has something that looks like a generational suffix, get it

	if is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error ('suffix');
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error ('non-Latin character');
			return false;														-- not a string of latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just intials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error ('suffix');									-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word


	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i],1,1));				-- insert the intial at end of initials table
		end
		i = i+1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between authors is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between authors is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = make_wikilink (person.link, one);						-- link author/editor if this page is not the author's/editor's page
				end
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end


--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]
local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of name parameters (author, editor, etc) for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the associated |display-&lt;names&gt;=etal parameter

]]

local function name_has_etal (name, etal, nocat, param)

	if is_set (name) then														-- name can be nil in which case just return
		local patterns = cfg.et_al_patterns;									--get patterns from configuration
		
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns
			if name:match (pattern) then										-- if this 'et al' pattern is found in name
				name = name:gsub (pattern, '');									-- remove the offending text
				etal = true;													-- set flag (may have been set previously here or by |display-&lt;names&gt;=etal)
				if not nocat then												-- no categorization for |vauthors=
					table.insert( z.message_tail, {set_error ('etal', {param})});	-- and set an error if not added
				end
			end
		end
	end

	return name, etal;															-- 
end


--[[--------------------------&lt; N A M E _ H A S _ E D _ M A R K U P &gt;------------------------------------------

Evaluates the content of author and editor parameters for extranious editor annotations: ed, ed., eds, (Ed.), etc.
These annotation do not belong in author parameters and are redundant in editor parameters.  If found, the function
adds the editor markup maintenance category.

]]

local function name_has_ed_markup (name, list_name)
	local _, pattern;
	local patterns = cfg.editor_markup_patterns;								-- get patterns from configuration

	if is_set (name) then
		for _, pattern in ipairs (patterns) do									-- spin through patterns table and
			if name:match (pattern) then
				add_maint_cat ('extra_text_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
				break;
			end
		end
	end
	return name;																-- and done
end


--[[--------------------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;----------------------------------------

Evaluates the content of author and editor (surnames only) parameters for multiple names.  Multiple names are
indicated if there is more than one comma and or semicolon.  If found, the function adds the multiple name
(author or editor) maintenance category.

]]

local function name_has_mult_names (name, list_name)
local count, _;
	if is_set (name) then
		_, count = name:gsub ('[;,]', '');										-- count the number of separator-like characters
		
		if 1 &lt; count then														-- param could be |author= or |editor= so one separator character is acceptable
			add_maint_cat ('mult_names', cfg.special_case_translation [list_name]);	-- more than one separator indicates multiple names so add a maint cat for this template
		end
	end
	return name;																-- and done
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------
This function calls various name checking functions used to validate the content of the various name-holding
parameters.

]]

local function name_checks (last, first, list_name)
	if is_set (last) then
		if last:match ('^%(%(.*%)%)$') then										-- if wrapped in doubled parentheses, accept as written 
			last = last:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			last = name_has_mult_names (last, list_name);						-- check for multiple names in the parameter (last only)
			last = name_has_ed_markup (last, list_name);						-- check for extraneous 'editor' annotation
		end
	end
	if is_set (first) then
		if first:match ('^%(%(.*%)%)$') then									-- if wrapped in doubled parentheses, accept as written 
			first = first:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			first = name_has_ed_markup (first, list_name);						-- check for extraneous 'editor' annotation
		end
	end
	return last, first;															-- done
	end


--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local last_alias, first_alias;												-- selected parameter aliases used in error messaging
	while true do
		last, last_alias = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first, first_alias = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.
		last, first= name_checks (last, first, list_name);						-- multiple names, extraneous annotation, etc checks
		
		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {first_alias, first_alias:gsub('first', 'last')}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			link_title_ok (link, list_name:match (&quot;(%w+)List&quot;):lower() .. '-link' .. i, last, list_name:match (&quot;(%w+)List&quot;):lower() .. '-last' .. i);	-- check for improper wikimarkup

			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {list_name:match (&quot;(%w+)List&quot;):lower(), i-1}, true ) } );	-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because case of the source may be incorrect
or different from the case that WikiMedia uses, the name comparisons are done in lower case and when a match is
found, the Wikimedia version (assumed to be correct) is returned along with the code.  When there is no match, we
return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') returns a list of languages that in some cases may include
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.  Most (all?) of these languages are not used a 'language' codes per se, rather they
are used as sub-domain names: cbk-zam.wikipedia.org.  A list of language names and codes supported by fetchLanguageNames()
can be found at Template:Citation Style documentation/language/doc

Names that are included in the list will be found if that name is provided in the |language= parameter.  For example,
if |language=Chavacano de Zamboanga, that name will be found with the associated code 'cbk-zam'.  When names are found
and the associated code is not two or three characters, this function returns only the WikiMedia language name.

Some language names have multiple entries under different codes:
	Aromanian has code rup and code roa-rup
When this occurs, this function returns the language name and the 2- or 3-character code

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	if cfg.lang_name_remap[lang:lower()] then									-- if there is a remapped name (because MediaWiki uses something that we don't think is correct)
		return cfg.lang_name_remap[lang:lower()][1], cfg.lang_name_remap[lang:lower()][2];	-- for this language 'name', return a possibly new name and appropriate code
	end

	local ietf_code;															-- because some languages have both ietf-like codes and iso 639-like codes
	local ietf_name;
	
	local languages = mw.language.fetchLanguageNames(this_wiki_code, 'all')		-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons

	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 == code:len() or 3 == code:len() then							-- two- or three-character codes only; extensions not supported
				return name, code;												-- so return the name and the code
			end
			ietf_code = code;													-- remember that we found an ietf-like code and save its name
			ietf_name = name;													-- but keep looking for a 2- or 3-char code
		end
	end
																				-- didn't find name with 2- or 3-char code; if ietf-like code found return
	return ietf_code and ietf_name or lang;										-- associated name; return original language text else
end


--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code is recognized by MediaWiki,
use the returned name; if not, then use the value that was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is assigned to the category for
that code: Category:Norwegian-language sources (no).  For valid three-character code languages, the page is assigned
to the single category for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does not recognize three-character
equivalents of two-character codes: code 'ar' is recognized bit code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are
separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki = mw.getContentLanguage();									-- get a language object for this wiki
	local this_wiki_code = this_wiki:getCode()									-- get this wiki's language code
	local this_wiki_name = mw.language.fetchLanguageName(this_wiki_code, this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang
		name = cfg.lang_code_remap[lang:lower()];								-- first see if this is a code that is not supported by MediaWiki but is in remap

		if name then															-- there was a remapped code so
			lang = lang:gsub ('^(%a%a%a?)%-.*', '%1');							-- strip ietf tags from code
		else
			if lang:match ('^%a%a%-') then										-- strip ietf tags from code; TODO: is there a need to support 3-char with tag?
				lang = lang:match ('(%a%a)%-')									-- keep only 639-1 code portion to lang; TODO: do something with 3166 alpha 2 country code?
			end
			if 2 == lang:len() or 3 == lang:len() then							-- if two-or three-character code
				name = mw.language.fetchLanguageName (lang:lower(), this_wiki_code);	-- get language name if |language= is a proper code
			end
		end

		if is_set (name) then													-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, this_wiki_code);				-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then													-- only 2- or 3-character codes
			name = cfg.lang_code_remap[code] or name;							-- override wikimedia when they misuse language codes/names

			if this_wiki_code ~= code then										-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					add_prop_cat ('foreign_lang_source' .. code, {name, code})	-- categorize it
				else															-- or is a recognized language (but has a three-character code)
					add_prop_cat ('foreign_lang_source_2' .. code, {code})		-- categorize it differently TODO: support mutliple three-character code categories per cs1|2 template
				end
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, cfg.messages['parameter-pair-separator'])		-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		name = table.concat (language_list, ', ');											-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
		name = name:gsub (', ([^,]+)$', cfg.messages['parameter-final-separator'] .. '%1');	-- replace last '&lt;comma&gt;&lt;space&gt;' separator with '&lt;comma&gt;&lt;space&gt;and&lt;space&gt;' separator
	end
	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings
At en.wiki, for cs1:
	ps gets:	'.'
	sep gets:	'.'

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = cfg.presentation['ps_cs1'];										-- terminate the rendered citation
	end
	return cfg.presentation['sep_cs1'], ps;										-- element separator
end


--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings
At en.wiki, for cs2:
	ps gets:	'' (empty string - no terminal punctuation)
	sep gets:	','

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = cfg.presentation['ps_cs2'];										-- terminate the rendered citation
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return cfg.presentation['sep_cs2'], ps, ref;								-- element separator
end


--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end


--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end


--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or
		url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
		url:match ('%.PDF&amp;#035') or url:match ('%.pdf&amp;#035');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parentheses, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[--------------------------&lt; G E T _ D I S P L A Y _ N A M E S &gt;--------------------------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_names (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_name', cfg.special_case_translation [list_name]);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parnetheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a place holder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parens
			local name = name_table[i];
			i=i+1;																-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parens
					break;														-- and done reassembling so
				end
				i=i+1;															-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = is_wikilink (name_table[i]);					-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i+1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parentheses to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')								-- remove doubled parntheses
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error ('punctuation');
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
			if is_suffix (first) then											-- if a valid suffix
				suffix = first													-- save it as a suffix and
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end																	-- no suffix error message here because letter combination may be result of Romanization; check for digits?
			last = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error ('missing comma');								-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error ('name');										-- matches a space between two intiials
			end
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error ('initials');									-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first);									-- check first and last before restoring the suffix which may have a non-Latin digit
			if is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '');
			end
		end

		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ) or v_link_table[i];
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice incase we have a |first1= without a |last1=; this ...
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or	-- ... also catches the case where |first= is used with |vauthors=
		select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, no, etc).  When the parameter value has not been assigned a value (missing or empty
in the source template) the function returns true.  If the parameter value is one of the list of allowed values returns
true; else, emits an error message and returns false.

]]

local function is_valid_parameter_value (value, name, possible)
	if not is_set (value) then
		return true;															-- an empty parameter is ok
	elseif in_array (value, possible) then
		return true;
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list,-3,-1) == sepc .. '. ') then						-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list,-1,-1) == sepc) or (string.sub (name_list,-3,-1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terninate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not is_set (volume) and not is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end

	local vol = '';																-- here for all cites except magazine
		
	if is_set (volume) then
		if volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$')then			-- volume value is all digits or all uppercase roman numerals
			vol = substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});	-- render in bold face
		elseif (4 &lt; mw.ustring.len(volume)) then								-- not all digits or roman numerals and longer than 4 characters
			vol = substitute (cfg.messages['j-vol'], {sepc, volume});			-- not bold
			add_prop_cat ('long_vol');
		else																	-- four or less characters
			vol = substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});	-- bold
		end
	end
	if is_set (issue) then
		return vol .. substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if is_set (page) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif is_set(pages) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then							-- if pages is only digits, assume a single page number
			return '', substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to wikisource, returns the label portion of the interwikilink as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki link to and external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, pages, at)
	local ws_url, ws_label, coins_pages, L;										-- for wikisource interwikilinks; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if is_set (page) then
		if is_set (pages) or is_set(at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws url from |page= interwiki link; link portion L becomes tool tip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif is_set (pages) then
		if is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws url from |pages= interwiki link; link portion L becomes tool tip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws url from |at= interwiki link; link portion L becomes tool tip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end



--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org urls to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot url or to calendar pages.  When the archive url is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the url.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org url does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command url
	|archive-url= is an archive.org url that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org urls:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this funct may return a modified
archive url:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the url unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.or url
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine url
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command url, we don't want to allow saving of the target page 
		err_msg = 'save command';
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = 'liveweb';
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');	-- split out some of the url parts for evaluation
		
		if not is_set(timestamp) or 14 ~= timestamp:len() then					-- path and flag optional, must have 14-digit timestamp here
			err_msg = 'timestamp';
			if '*' ~= flag then
				url=url:gsub ('(//web%.archive%.org/[^%d]*%d?%d?%d?%d?%d?%d?)[^/]*', '%1*', 1)	-- for preview, modify ts to be yearmo* max (0-6 digits plus splat)
			end
		elseif is_set(path) and 'web/' ~= path then								-- older archive urls do not have the extra 'web/' path element
			err_msg = 'path';
		elseif is_set (flag) and not is_set (path) then							-- flag not allowed with the old form url (without the 'web/' path element)
			err_msg = 'flag';
		elseif is_set (flag) and not flag:match ('%a%a_') then					-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = 'flag';
		else
			return url, date;													-- return archiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	table.insert( z.message_tail, { set_error( 'archive_url', {err_msg}, true ) } );	-- add error message and
	if is_set (Frame:preprocess('{{REVISIONID}}')) then
		return '', '';															-- return empty strings for archiveURL and ArchiveDate
	else
		return url, date;														-- preview mode so return archiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

-- set default parameter values defined by |mode= parameter.
	local Mode = A['Mode'];
	if not is_valid_parameter_value (Mode, 'mode', cfg.keywords['mode']) then
		Mode = '';
	end

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				add_maint_cat ('authors');										-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
			add_maint_cat ('editors');											-- but add a maint cat because use of this parameter is discouraged
		end
	end

	local translator_etal;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=

	local interviewer_etal;
	local interviewers_list = {};												
	local Interviewers;															-- used later
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters

	local contributor_etal;
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list
	local Contribution = A['Contribution'];
	if in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not is_set (Contribution) then									-- |contributor= requires |contribution=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if select_one (args, cfg.aliases['ContributorList-Last'], 'redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { set_error( 'contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if not is_valid_parameter_value (NameListFormat, 'name-list-format', cfg.keywords['name-list-format']) then	-- only accepted value for this parameter is 'vanc'
		NameListFormat = '';													-- anything else, set to empty string
	end

	if is_set (Others) then
		if 0 == #a and 0 == #e then												-- add maint cat when |others= has value and used without |author=, |editor=
			add_maint_cat ('others');
		end
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
			link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wikimarkup in |title-link= or wikimarkup in |title= when |title-link= is set

	local Chapter = A['Chapter'];
	local ScriptChapter = A['ScriptChapter'];
	local ScriptChapterOrigin = A:ORIGIN ('ScriptChapter');
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];

	local ArchiveDate;
	local ArchiveURL;

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	
	local UrlStatus = A['UrlStatus'];
	if 'url-status' == A:ORIGIN ('UrlStatus') then								-- interim: TODO: this line goes away
		if not is_valid_parameter_value (UrlStatus, 'url-status', cfg.keywords ['url-status']) then	-- set in config.defaults to 'dead'
			UrlStatus = '';														-- anything else, set to empty string
		end																		-- interim: TODO: this line goes away
	elseif is_set (A:ORIGIN ('UrlStatus')) then									-- interim: while both |dead-url= and |url-status= allowed use separate keyword lists; TODO: remove this section
		if not is_valid_parameter_value (UrlStatus, A:ORIGIN ('UrlStatus'), cfg.keywords ['deadurl']) then	-- interim: assume |dead-url=; use those keywords; TODO: this line goes away
			UrlStatus = '';														-- anything else, set to empty string; interim: TODO: this line goes away
		end																		-- interim: TODO: this line goes away
	end																			-- interim: TODO: this line goes away
	
	if in_array (UrlStatus, {'yes', 'true', 'y'}) then							-- TODO: remove this whole thing when |dead-url=[yes|no] parameters removed from articles
		UrlStatus = 'dead';
	elseif 'no' == UrlStatus then
		UrlStatus = 'live';
	end
	
	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];
	local Periodical_origin = '';
		if is_set (Periodical) then
			Periodical_origin = A:ORIGIN('Periodical');							-- get the name of the periodical parameter
			local i;
			Periodical, i = strip_apostrophe_markup (Periodical);				-- strip appostrophe markup so that metadata isn't contaminated 
			if i then															-- non-zero when markup was stripped so emit an error message
				table.insert( z.message_tail, {set_error ('apostrophe_markup', {Periodical_origin}, true)});
			end
		end

	local ScriptPeriodical = A['ScriptPeriodical'];
	local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');

		if not (is_set (Periodical) or is_set (ScriptPeriodical)) then			-- 'periodical' templates require periodical parameter
			local p = {['journal'] = 'journal', ['magazine'] = 'magazine', ['news'] = 'newspaper', ['web'] = 'website'};	-- for error message
			if p[config.CitationClass]  then
				table.insert( z.message_tail, {set_error ('missing_periodical', {config.CitationClass, p[config.CitationClass]}, true)});
			end
		end

	local TransPeriodical =  A['TransPeriodical'];

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if 'citation' == config.CitationClass then
		if is_set (Periodical) then
			if not in_array (Periodical_origin, {'website', 'mailinglist'}) then	-- {{citation}} does not render volume for these 'periodicals'
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		elseif is_set (ScriptPeriodical) then
			if 'script-website' ~= ScriptPeriodical_origin then					-- {{citation}} does not render volume for |script-website=
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		else
			Volume = A['Volume'];												-- and does for non-'periodical' cites
		end
	elseif in_array (config.CitationClass, cfg.templates_using_volume) then		-- render |volume= for cs1 according to the configuration settings
		Volume = A['Volume'];
	end	

	if 'citation' == config.CitationClass then
		if is_set (Periodical) and in_array (Periodical_origin, {'journal', 'magazine', 'newspaper', 'periodical', 'work'}) or	-- {{citation}} renders issue for these 'periodicals'
			is_set (ScriptPeriodical) and in_array (ScriptPeriodical_origin, {'script-journal', 'script-magazine', 'script-newspaper', 'script-periodical', 'script-work'}) then -- and these 'script-periodicals'
				Issue = hyphen_to_dash (A['Issue']);
		end
	elseif in_array (config.CitationClass, cfg.templates_using_issue) then		-- conference &amp; map books do not support issue; {{citation}} listed here because included in settings table
		if not (in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (is_set (Periodical) or is_set (ScriptPeriodical))) then
			Issue = hyphen_to_dash (A['Issue']);
		end
	end

	local Position = '';
	if not in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash (A['Pages']);	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local PublisherName_origin = A:ORIGIN('PublisherName');
		if is_set (PublisherName) then
			local i=0;
			PublisherName, i = strip_apostrophe_markup (PublisherName);			-- strip appostrophe markup so that metadata isn't contaminated; publisher is never italicized

			if i then															-- non-zero when markup was stripped so emit an error message
				table.insert( z.message_tail, {set_error ('apostrophe_markup', {PublisherName_origin}, true)});
			end
		end

	local RegistrationRequired = A['RegistrationRequired'];
		if not is_valid_parameter_value (RegistrationRequired, 'registration', cfg.keywords ['yes_true_y']) then
			RegistrationRequired=nil;
		end

	local SubscriptionRequired = A['SubscriptionRequired'];
		if not is_valid_parameter_value (SubscriptionRequired, 'subscription', cfg.keywords ['yes_true_y']) then
			SubscriptionRequired=nil;
		end

	local UrlAccess = A['UrlAccess'];
		if not is_valid_parameter_value (UrlAccess, 'url-access', cfg.keywords ['url-access']) then
			UrlAccess = nil;
		end
		if not is_set(URL) and is_set(UrlAccess) then
			UrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {'url'}, true ) } );
		end
		
		if is_set (UrlAccess) and is_set (SubscriptionRequired) then			-- while not aliases, these are much the same so if both are set
			table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'url-access') .. ' and ' .. wrap_style ('parameter', 'subscription')}, true ) } );		-- add error message
			SubscriptionRequired = nil;											-- unset; prefer |access= over |subscription=
		end
		if is_set (UrlAccess) and is_set (RegistrationRequired) then			-- these are not the same but contradictory so if both are set
			table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'url-access') .. ' and ' .. wrap_style ('parameter', 'registration')}, true ) } );		-- add error message
			RegistrationRequired = nil;											-- unset; prefer |access= over |registration=
		end

	local ChapterUrlAccess = A['ChapterUrlAccess'];
		if not is_valid_parameter_value (ChapterUrlAccess, A:ORIGIN('ChapterUrlAccess'), cfg.keywords ['url-access']) then	-- same as url-access
			ChapterUrlAccess = nil;
		end
		if not is_set(ChapterURL) and is_set(ChapterUrlAccess) then
			ChapterUrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {A:ORIGIN('ChapterUrlAccess'):gsub ('%-access', '')}, true ) } );
		end

	local MapUrlAccess = A['MapUrlAccess'];
		if not is_valid_parameter_value (MapUrlAccess, 'map-url-access', cfg.keywords ['url-access']) then
			MapUrlAccess = nil;
		end
		if not is_set(A['MapURL']) and is_set(MapUrlAccess) then
			MapUrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {'map-url'}, true ) } );
		end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local Agency = A['Agency'];

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
		if not is_valid_parameter_value (IgnoreISBN, 'ignore-isbn-error', cfg.keywords ['yes_true_y']) then
			IgnoreISBN = nil;													-- anything else, set to empty string
		end
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );
		if is_set (DoiBroken) and not ID_list['DOI'] then
			table.insert( z.message_tail, { set_error( 'doibroken_missing_doi', A:ORIGIN('DoiBroken'))});
		end
	local ID_access_levels = extract_id_access_levels( args, ID_list );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
		if not is_valid_parameter_value (LastAuthorAmp, 'last-author-amp', cfg.keywords ['yes_true_y']) then
			LastAuthorAmp = nil;												-- set to empty string
		end

	local no_tracking_cats = A['NoTracking'];
		if not is_valid_parameter_value (no_tracking_cats, 'no-tracking', cfg.keywords ['yes_true_y']) then
			no_tracking_cats = nil;												-- set to empty string
		end

	--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = A['DF'];															-- date format set in cs1|2 template
	if not is_valid_parameter_value (DF, 'df', cfg.keywords['date-format']) then	-- validate reformatting keyword
		DF = '';																-- not valid, set to empty string
	end
	if not is_set (DF) then
		DF = cfg.global_df;
	end

	local sepc;																	-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );											-- used to control capitalization for certain static text

	--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

	-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	select_one( args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'redundant_parameters' );	-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, Pages, At);

	local NoPP = A['NoPP'] 
	if is_set (NoPP) and is_valid_parameter_value (NoPP, 'nopp', cfg.keywords ['yes_true_y']) then
		NoPP = true;
	else
		NoPP = nil;																-- unset, used as a flag later
	end

	if not is_set(PublicationPlace) and is_set(Place) then						-- both |publication-place= and |place= (|location=) allowed if different
		PublicationPlace = Place;												-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end							-- don't need both if they are the same
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia and |title then map |title to |article and |encyclopedia to |title
		|encyclopedia and |article then map |encyclopedia to |title

		|trans-title maps to |trans-chapter when |title is re-mapped
		|url maps to |chapterurl when |title is remapped
	
	All other combinations of |encyclopedia, |title, and |article are not modified
	
	]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set (Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					ScriptChapterOrigin = 'title';
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterUrlAccess = UrlAccess;

					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter = make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			elseif is_set (Chapter) then										-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if is_set(A['Number']) then												-- cite techreport uses 'number', which other citations alias to 'issue'
			if not is_set(ID) then												-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', 'id') .. ' and ' .. wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

	-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	elseif 'mailinglist' == Periodical_origin then
		Periodical = '';														-- unset because mailing list is only used for cite mailing list
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		ChapterUrlAccess = MapUrlAccess;
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];

		link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wikimarkup in |series-link= or wikimarkup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) and is_set (AirDate) then							-- promote airdate to date
			Date = AirDate;
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('seriesnum', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ScriptChapterOrigin = 'title';
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = make_wikilink (ChapterLink, Chapter);
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = make_wikilink (SeriesLink, Series);
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite ssrn}}, before generation of COinS data.
	do
		if in_array (config.CitationClass, {'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) then
			if not is_set (ID_list[config.CitationClass:upper()]) then			-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp; |citeseerx= required for their templates
				table.insert( z.message_tail, { set_error( config.CitationClass .. '_missing', {}, true ) } );	-- add error message
			end

			Periodical = ({['arxiv'] = 'arXiv', ['biorxiv'] = bioRxiv, ['citeseerx'] = 'CiteSeerX', ['ssrn'] = 'Social Science Research Network'})[config.CitationClass];
		end
	end

	-- handle type parameter for those CS1 citations that have default values
	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;interview&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
		TitleType = substitute( cfg.messages['type'], TitleType);				-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging

	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val=AccessDate, name=A:ORIGIN ('AccessDate')},
			['archive-date'] = {val=ArchiveDate, name=A:ORIGIN ('ArchiveDate')},
			['date'] = {val=Date, name=Date_origin},
			['doi-broken-date'] = {val=DoiBroken, name=A:ORIGIN ('DoiBroken')},
			['embargo'] = {val=Embargo, name=A:ORIGIN ('Embargo')},
			['lay-date'] = {val=LayDate, name=A:ORIGIN ('LayDate')},
			['publication-date'] ={val=PublicationDate, name=A:ORIGIN ('PublicationDate')},
			['year'] = {val=Year, name=A:ORIGIN ('Year')},
			};
		anchor_year, Embargo, error_message = dates(date_parameters_list, COinS_date);

-- start temporary Julian / Gregorian calendar uncertainty categorization
		if COinS_date.inter_cal_cat then
			add_prop_cat ('jul_greg_uncertainty');
		end
-- end temporary Julian / Gregorian calendar uncertainty categorization

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end
		
		if not is_set(error_message) then										-- error free dates only
			local modified = false;												-- flag
			
			if is_set (DF) then													-- if we need to reformat dates
				modified = reformat_dates (date_parameters_list, DF, false);	-- reformat to DF format, use long month names if appropriate
			end

			if true == date_hyphen_to_dash (date_parameters_list) then			-- convert hyphens to dashes where appropriate
				modified = true;
				add_maint_cat ('date_format');									-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language,
	-- uncomment these three lines.  Not supported by en.wiki (for obvious reasons)
	-- set date_name_xlate() second argument to true to translate English digits to local digits (will translate ymd dates)
--			if date_name_xlate (date_parameters_list, false) then
--				modified = true;
--			end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				LayDate = date_parameters_list['lay-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end
		else
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end
	end	-- end of do

	-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
	-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
			if is_set(AccessDate) then											-- access date requires |url=; pmc created url is not |url=
				table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
				AccessDate = '';												-- unset
			end

		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
			if 'episode' == config.CitationClass then							-- special case for cite episode; TODO: is there a better way to do this?
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
			else
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
			end
	end

	if 'none' == Title and
			in_array (config.CitationClass, {'journal', 'citation'}) and
			(is_set (Periodical) or is_set (ScriptPeriodical)) and
			('journal' == Periodical_origin or 'script-journal' == ScriptPeriodical_origin) then	-- special case for journal cites
				Title = '';														-- set title to empty string
				add_maint_cat ('untitled');
	end

	check_for_url ({															-- add error message when any of these parameters hold a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[Periodical_origin] = Periodical,
		[PublisherName_origin] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = strip_apostrophe_markup (Periodical),					-- no markup in the metadata
		['Encyclopedia'] = strip_apostrophe_markup (Encyclopedia),
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = coins_pages or get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,										-- any apostrophe markup already removed
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, and {{cite ssrn}} AFTER generation of COinS data.
	if in_array (config.CitationClass, {'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, CiteSeerX, or ssrn now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = substitute (cfg.messages['newsgroup'], external_link( 'news:' .. PublisherName, PublisherName, PublisherName_origin, nil ));
		end
	end

	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text,											-- get current page name so that we don't wikilink to it via editorlinkn
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_names (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if is_set (Editors) then
				Editors, editor_etal = name_has_etal (Editors, editor_etal, false, 'editors');	-- find and remove variations on et al.
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
					EditorCount = 2;											-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
				else
					EditorCount = 2;											-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
				end
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum , interviewer_etal = get_display_names (A['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal);
			Interviewers = list_people (control, interviewers_list, interviewer_etal);
		end
		do																		-- now do translators
			control.maximum , translator_etal = get_display_names (A['DisplayTranslators'], #t, 'translators', translator_etal);
			Translators = list_people (control, t, translator_etal);
		end
		do																		-- now do contributors
			control.maximum , contributor_etal = get_display_names (A['DisplayContributors'], #c, 'contributors', contributor_etal);
			Contributors = list_people (control, c, contributor_etal);
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_names (A['DisplayAuthors'], #a, 'authors', author_etal);

			last_first_list = list_people(control, a, author_etal);

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors');	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if is_set (Authors) and is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
	-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (is_set (Periodical) or is_set (ScriptPeriodical)) and not is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not is_set(URL) then
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) or		-- |url= required for cite web, cite podcast, and cite mailinglist
			('citation' == config.CitationClass and ('website' == Periodical_origin or 'script-website' == ScriptPeriodical_origin)) then	-- and required for {{citation}} with |website= or |script-website=
				table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURLorigin, OriginalFormat, OriginalAccess;
--	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	UrlStatus = UrlStatus:lower();												-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (ChapterURL) then 											-- if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURLorigin = ChapterURLorigin;								-- name of chapter-url parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=
--			if 'no' ~= DeadURL then
			if 'live' ~= UrlStatus then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				ChapterURLorigin = A:ORIGIN('ArchiveURL')						-- name of archive-url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived urls
			end
		elseif is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURLorigin = URLorigin;										-- name of url parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;
--			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
			if 'live' ~= UrlStatus then											-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived urls
			end
 		end
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and (is_set (Periodical) or is_set (ScriptPeriodical)) and not is_set (Encyclopedia)) then
			local chap_param;
			if is_set (Chapter) then											-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif is_set (ScriptChapter) then
				chap_param = ScriptChapterOrigin;
			else is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if is_set (chap_param) then											-- if we found one
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {chap_param}, true ) } );		-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if is_set (Contribution) and 0 &lt; #c then								-- if this is a contribution with contributor(s)
			if in_array (Contribution:lower(), cfg.keywords.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, ScriptChapterOrigin, Chapter, TransChapter, ChapterURL, ChapterURLorigin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter.. sepc .. ' ';
		elseif is_set (ChapterFormat) then										-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title.
	if is_set (ArchiveURL) and mw.ustring.match (mw.ustring.lower(Title), cfg.special_case_translation['archived_copy']) then	-- if title is 'Archived copy' (place holder added by bots that can't find proper title)
		add_maint_cat ('archived_copy');										-- add maintenance category before we modify the content of Title
	end

	if Title:match ('^%(%(.*%)%)$') then										-- if keep as written markup:
		Title= Title:gsub ('^%(%((.*)%)%)$', '%1')								-- remove the markup
	else
		if '...' == Title:sub (-3) then											-- if elipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%'..sepc..'$', '');				-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end
	end
	
	if in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (is_set (Periodical) or is_set (ScriptPeriodical)) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and (is_set (Periodical) or is_set (ScriptPeriodical))) then		-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle, 'script-title');	-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end

	if is_set(Title) then
		if not is_set (TitleLink) and is_set (URL) then
			Title = external_link (URL, Title, URLorigin, UrlAccess) .. TransTitle .. TransError .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif is_set (TitleLink) and not is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = make_wikilink (TitleLink, Title) .. TransTitle .. TransError;
			end
		else
			local ws_url, ws_label;
			ws_url, ws_label, L = wikisource_url_make (Title);					-- make ws url from |title= interwiki link; link portion L becomes tool tip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = Title .. TransTitle .. TransError;
			end
		end
	else
		Title = TransTitle .. TransError;
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURLorigin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin, nil );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if is_set(Minutes) then
			if is_set (Time) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'minutes') .. ' and ' .. wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = is_set (Series) and wrap_msg ('series', {sepc, Series}) or &quot;&quot;;		-- not the same as SeriesNum
	OrigYear = is_set (OrigYear) and wrap_msg ('origyear', OrigYear) or '';
	Agency = is_set (Agency) and wrap_msg ('agency', {sepc, Agency}) or &quot;&quot;;
	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	Via = is_set (Via) and  wrap_msg ('via', Via) or '';

	--[[
	Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
	note is displayed. There are no error messages for this condition.
	
	]]
	if is_set (SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif is_set (RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text

		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {IdAccessLevels=ID_access_levels, DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin, UrlAccess );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then				-- if first and last characters of quote are quote marks
			Quote = Quote:sub(2,-2);											-- strip them off
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;live&quot; == UrlStatus then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-live'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- UrlStatus is empty, 'dead', 'unfit', 'usurped', 'bot: unknown'
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if in_array (UrlStatus, {'unfit', 'usurped', 'bot: unknown'}) then
				Archived = sepc .. &quot; &quot; .. 'Archived from the original on ' .. ArchiveDate;	-- format already styled
				if 'bot: unknown' == UrlStatus then
					add_maint_cat ('bot:_unknown');								-- and add a category if not already added
				else
					add_maint_cat ('unfit');									-- and add a category if not already added
				end
			else																-- UrlStatus is empty, 'dead'
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURLorigin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURLorigin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin, nil );
	end

	local Publisher;
	if is_set(PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if is_set(PublisherName) then
		if is_set(PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif is_set(PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if (is_set (Periodical) or is_set (ScriptPeriodical) or is_set (TransPeriodical)) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical);
		else 
			Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical);
		end
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then									-- cite speech only
		TitleNote = &quot; (Speech)&quot;;												-- annotate the citation
		if is_set (Periodical) then												-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then											-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;							-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = safe_join ({Others, sepc .. &quot; &quot;}, sepc) end		-- add terminal punctuation &amp; space; check for dup sepc; TODO why do we need to do this here?
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(Periodical) then		-- special cases for book cites
		if is_set (Contributors) then											-- when we are citing foreword, preface, introduction, etc
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon;
	if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then	-- special case for cite AV media &amp; cite episode position transcript
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	else
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	end
	
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if is_set(Date) then
		if is_set (Authors) or is_set (Editors) then							-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;;				-- in paranetheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon,-1,-1) == sepc) then							-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigYear;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigYear;							-- Date begins with sepc
			end
		end
	end	
	if is_set(Authors) then
		if (not is_set (Date)) then												-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then
					in_text = in_text:lower()									-- lowercase for cs2
				end
			end
			if EditorCount &lt;= 1 then
				post_text = &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot;;				-- be consistent with no-author, no-date case
			else
				post_text = &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot;;
			end
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if is_set (Contributors) then											-- book cite and we're citing the intro, preface, etc
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if is_set (Editors) and is_set (Date) then							-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not is_set (Date)) then											-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc ); 								--Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = config.CitationClass;
		options.class = &quot;citation &quot; .. config.CitationClass;					-- class=citation required for blue highlight when used with |ref=
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then								-- set reference anchor if appropriate
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			if #namelist &gt; 0 then												-- if there are names in namelist
				id = anchor_id (namelist, year);								-- go make the CITEREF anchor
			else
				id = '';														-- unset
			end
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;(.-)&lt;/span&gt;&quot;, &quot;%1&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then	-- remove &lt;span&gt; tags and other html-like markup; then get length of what remains
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	local render = {};															-- here we collect the final bits for concatenation into the rendered citation

	if is_set(options.id) then													-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render, substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text}));	-- when |ref= is set
	else
		table.insert (render, substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text}));	-- all other cases
	end		

	table.insert (render, substitute (cfg.presentation['ocins'], {OCinSoutput}));	-- append metadata to the citation

	if 0 ~= #z.message_tail then
		table.insert (render, ' ');
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					table.insert (render, error_comment( v[1], v[2] ));
				else
					table.insert (render, error_comment( v[1] .. &quot;; &quot;, v[2] ));
				end
			end
		end
	end

	if 0 ~= #z.maintenance_cats then
		local maint_msgs = {};													-- here we collect all of the maint messages
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			local maint = {};													-- here we assemble a maintenence message
			table.insert (maint, v);											-- maint msg is the category name
			table.insert (maint, ' (');											-- open the link text
			table.insert (maint, make_wikilink (':Category:' .. v, 'link'));	-- add the link
			table.insert (maint, ')');											-- and close it
			table.insert (maint_msgs, table.concat (maint));					-- assemble new maint message and add it to the maint_msgs table
		end
		table.insert (render, substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs, ' ')));	-- wrap the group of maint message with proper presentation and save
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			table.insert (render, make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			table.insert (render, make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.properties_cats ) do								-- append properties categories
			table.insert (render, make_wikilink ('Category:' .. v));
		end
	end

	return table.concat (render);	
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class)
	local name = tostring (name);
	local state;
	
	if in_array (cite_class, {'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) then	-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[name];
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end

		state = whitelist[cite_class .. '_basic_arguments'][name];				-- look in the parameter-list for the template identified by cite_class

		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
																				-- limited enumerated parameters list
		name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
		state = whitelist.limited_numbered_arguments[name];
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates
		
	state = whitelist.basic_arguments[name];									-- all other templates; all normal parameters allowed
											
	if true == state then return true; end										-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);											-- parameter is deprecated but still supported
		return true;
	end
																				-- all enumerated parameters allowed
	name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );												-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
	state = whitelist.numbered_arguments[name];

	if true == state then return true; end										-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);											-- parameter is deprecated but still supported
		return true;
	end
	
	return false;																-- not supported because not found or name is set to nil
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe:
	{{cite ... |title=Title access-date=2016-03-17}}

cs1|2 shares some parameter names with xml/html atributes: class=, title=, etc.  To prevent false positives xml/html
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (parameter, value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove xml/html tags because attributes: class=, title=, etc 

	capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then								-- if the capture is a valid parameter name
		table.insert( z.message_tail, {set_error ('missing_pipe',parameter)});
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ P U N C T &gt;--------------------------------------

look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_punc (param, value)
	if cfg.punct_skip[param] then
		return;																	-- parameter name found in the skip table so done
	end
	
	if value:match ('[,;:]$') then
		add_maint_cat ('extra_punct');											-- has extraneous punctuation; add maint cat
	end
end


--[[--------------------------&lt; C I T A T I O N &gt;--------------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

local function citation(frame)
	Frame = frame;																-- save a copy incase we need to display an error message in preview mode
	local pframe = frame:getParent()
	local validation, utilities, identifiers, metadata, styles;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		styles = 'Module:Citation/CS1/sandbox/styles.css';
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
		styles = 'Module:Citation/CS1/styles.css';

	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	dates = validation.dates;													-- imported functions from Module:Citation/CS1/Date validation
	year_date_check = validation.year_date_check;
	reformat_dates = validation.reformat_dates;
	date_hyphen_to_dash = validation.date_hyphen_to_dash;
	date_name_xlate = validation.date_name_xlate;

	is_set = utilities.is_set;													-- imported functions from Module:Citation/CS1/Utilities
	in_array = utilities.in_array;
	substitute = utilities.substitute;
	error_comment = utilities.error_comment;
	set_error = utilities.set_error;
	select_one = utilities.select_one;
	add_maint_cat = utilities.add_maint_cat;
	wrap_style = utilities.wrap_style;
	safe_for_italics = utilities.safe_for_italics;
	is_wikilink = utilities.is_wikilink;
	make_wikilink = utilities.make_wikilink;
	strip_apostrophe_markup = utilities.strip_apostrophe_markup;

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	extract_ids = identifiers.extract_ids;										-- imported functions from Module:Citation/CS1/Identifiers
	build_id_list = identifiers.build_id_list;
	is_embargoed = identifiers.is_embargoed;
	extract_id_access_levels = identifiers.extract_id_access_levels;
	
	make_coins_title = metadata.make_coins_title;								-- imported functions from Module:Citation/CS1/COinS
	get_coins_pages = metadata.get_coins_pages;
	COinS = metadata.COinS;

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text, error_state;

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do
		config[k] = v;
--		args[k] = v;															-- debug tool that allows us to render a citation from module {{#invoke:}}
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower(), config.CitationClass ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute (param, capture);				-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text, error_state = set_error ('parameter_ignored_suggest', {k, param}, true);	-- set the suggestion error message
							else
								error_text, error_state = set_error( 'parameter_ignored', {param}, true );	-- suggested param not supported by this template
							end
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?
																				-- TODO: is this the best place for this translation?
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then						-- here when v is empty string
			args[k] = v;														-- why do we do this?  we don't support 'empty' parameters
		end		
	end	

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);
			has_extraneous_punc (k, v);											-- look for extraneous terminal punctuation in parameter values
		end
	end
	return table.concat ({citation0( config, args), frame:extensionTag ('templatestyles', '', {src=styles})});
end

--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {citation = citation};</text>
      <sha1>s1ptsqky6jla2ch3vxqftih7lhqkoeh</sha1>
    </revision>
    <revision>
      <id>4727</id>
      <parentid>4726</parentid>
      <timestamp>2019-09-07T02:49:19Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4727</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="185661" sha1="hivne99v5j2ug6jkebltuioanprtwdq" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local dates, year_date_check, reformat_dates, date_hyphen_to_dash,				-- functions in Module:Citation/CS1/Date_validation
	date_name_xlate

local is_set, in_array, substitute, error_comment, set_error, select_one,		-- functions in Module:Citation/CS1/Utilities
	add_maint_cat, wrap_style, safe_for_italics, is_wikilink, make_wikilink,
	strip_apostrophe_markup;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local extract_ids, extract_id_access_levels, build_id_list, is_embargoed;		-- functions in Module:Citation/CS1/Identifiers

local make_coins_title, get_coins_pages, COinS;									-- functions in Module:Citation/CS1/COinS

local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

delare variables here that have page-wide scope that are not brought in from other modules; thatare created here
and used here

]]

local added_deprecated_cat;														-- boolean flag so that the category is added only once
local added_prop_cats = {};														-- list of property categories that have been added to z.properties_cats
local added_vanc_errs;															-- boolean flag so we only emit one Vancouver error / category

local Frame;																	-- holds the module's frame table


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

foreign_lang_source and foreign_lang_source_2 keys have a language code appended to them so that multiple languages
may be categorized but multiples of the same language are not categorized.

added_prop_cats is a table declared in page scope variables above

]]

local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		key = key:gsub ('(foreign_lang_source_?2?)%a%a%a?', '%1');				-- strip lang code from keyname
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));	-- make name then add to table
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a boolean declared in page scope variables above

]]

local function add_vanc_error (source)
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {source}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a uri scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of tlds: https://www.iana.org/domains/root/db

rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the tld.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a url with a scheme) will be stripped
here.  Perhaps not necessary but retained incase it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ascii characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the tld) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and tld or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%w]') then											-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at wikisource
		return false;
	end

	local patterns = {															-- patterns that look like urls
		'%f[%w][%w][%w%-]+[%w]%.%a%a+$',										-- three or more character hostname.hostname or hostname.tld
		'%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$',									-- internationalized domain name with ACE prefix
		'%f[%a][qxz]%.com$',													-- assigned one character .com hostname (x.com times out 2015-12-10)
		'%f[%a][iq]%.net$',														-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		'%f[%w][%w]%.%a%a$',													-- one character hostname and cctld (2 chars)
		'%f[%w][%w][%w]%.%a%a+$',												-- two character hostname and tld
		'^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?',								-- IPv4 address
		}

	for _, pattern in ipairs (patterns) do										-- loop through the patterns list
		if domain:match (pattern) then
			return true;														-- if a match then we think that this thing that purports to be a url is a url
		end
	end

	for _, d in ipairs ({'cash', 'company', 'today', 'org'}) do					-- look for single letter second level domain names for these top level domains
		if domain:match ('%f[%w][%w]%.' .. d) then
			return true
		end
	end
	return false;																-- no matches, we don't know what this thing is
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a url appear to be a valid url; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if is_set (scheme) then														-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when url is protocol relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a url into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following tld) (if any) and any path(/), query(?) or fragment(#).

If protocol relative url, return nil scheme and domain else return nil for both scheme and domain.

When not protocol relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol relative url
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		authority = authority:gsub ('//', '', 1);								-- replace place 1 pair of '/' with nothing;
		if is_set(authority) then												-- if anything left (1 or 3+ '/' where authority should be) then
			return scheme;														-- return scheme only making domain nil which will cause an error message
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link= etc for properly formatted content: no wikilinks, no urls

Link parameters are to hold the title of a wikipedia article so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki urls and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid url (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid url (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from url; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid url
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wikilinked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

]]

local function link_title_ok (link, lorig, title, torig)
local orig;

	if is_set (link) then 														-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		end
	end

	if is_set (orig) then
		table.insert( z.message_tail, { set_error( 'bad_paramlink', orig)});	-- url or wikilink in |title= with |title-link=;
	end
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the url into scheme and domain
portions, or for protocol relative (//example.com) urls, just the domain.  Use is_url() to validate the two
portions of the url.  If both are valid, or for protocol relative if domain is valid, return true, else false.

Because it is different from a standard url, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper url
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from url;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a url.  The test will also find external wikilinks
that use protocol relative urls. Also finds bare urls.

The frontier pattern prevents a match on interwiki links which are similar to scheme:path urls.  The tests that
find bracketed urls are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol relative ext wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare url with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol relative bare url: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a url
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then												-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source, access)
	local error_str = &quot;&quot;;
	local domain;
	local path;
	local base_url;

	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the url into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['[']='%5b',[']']='%5d'});					-- replace '[' and ']' with their percent encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wikimarkup url

	if is_set (access) then														-- access level (subscription, registration, limited)
		base_url = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end
	
	return table.concat ({base_url, error_str});
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );	-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Replaces unicode quotemarks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc; not for book titles.

]=]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	local wl_type, label, link;

	wl_type, label, link = is_wikilink (str);									-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = substitute (cfg.presentation['kern-wl-both'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = substitute (cfg.presentation['kern-wl-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = substitute (cfg.presentation['kern-wl-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label= mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label= mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap, cap2 = mw.ustring.match (label, &quot;^([\&quot;\'])([^\'].+)&quot;);				-- match leading double or single quote but not doubled single quotes (italic markup)
		if is_set (cap) then
			label = substitute (cfg.presentation['kern-left'], {cap, cap2});
		end
	
		cap, cap2 = mw.ustring.match (label, &quot;^(.+[^\'])([\&quot;\'])$&quot;)				-- match trailing double or single quote but not doubled single quotes (italic markup)
		if is_set (cap) then
			label = substitute (cfg.presentation['kern-right'], {cap, cap2});
		end
		
		if 2 == wl_type then
			str = make_wikilink (link, label);									-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title=, |script-chapter=, |script-&lt;periodical&gt;=

]]

local function format_script_value (script_value, script_param)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			table.insert( z.message_tail, { set_error( 'script_parameter', {script_param, 'missing title part'}, true ) } );		-- prefix without 'title'; add error message
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_code_remap[lang] or mw.language.fetchLanguageName( lang, &quot;en&quot; );	-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, cfg.script_lang_codes) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				table.insert( z.message_tail, { set_error( 'script_parameter', {script_param, 'unknown language code'}, true ) } );	-- unknown script-language; add error message
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			table.insert( z.message_tail, { set_error( 'script_parameter', {script_param, 'invalid language code'}, true ) } );		-- invalid language code; add error message
			lang = '';															-- invalid so set lang to empty string
		end
	else
		table.insert( z.message_tail, { set_error( 'script_parameter', {script_param, 'missing prefix'}, true ) } );				-- no language code prefix; add error message
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script, script_param)
	if is_set (script) then
		script = format_script_value (script, script_param);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return substitute( msg, str );											-- including template text
	else
		return substitute( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;----------------------------------------

makes a wikisource url from wikisource interwiki link.  returns the url and appropriate label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;

	wl_type, D, L = is_wikilink (str);											-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if is_set (str) then
			ws_url = table.concat ({											-- build a wikisource url
				'https://en.wikisource.org/wiki/',								-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the url
		end
	elseif 1 == wl_type then														-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if is_set (str) then
			ws_url = table.concat ({											-- build a wikisource url
				'https://en.wikisource.org/wiki/',								-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the url
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a wikisource url
				'https://en.wikisource.org/wiki/',								-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end
	
	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable url
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent encoding of anchor
	end

	return ws_url, ws_label, L or D;											-- return proper url or nil and a label or nil
end


--[[--------------------------&lt; F O R M A T _ P E R I O D I C A L &gt;--------------------------------------------

Format the four periodical parameters: |script-&lt;periodical&gt;=, |&lt;periodical&gt;=, and |trans-&lt;periodical&gt;= into a single Periodical meta-
parameter.

]]

local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)
	local periodical_error = '';

	if not is_set (periodical) then
		periodical = '';														-- to be safe for concatenation
	else
		periodical = wrap_style ('italic-title', periodical);					-- style 
	end

	periodical = script_concatenate (periodical, script_periodical, script_periodical_source);	-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (trans_periodical) then
		trans_periodical = wrap_style ('trans-italic-title', trans_periodical);
		if is_set (periodical) then
			periodical = periodical ..  ' ' .. trans_periodical;
		else																	-- here when transchapter without chapter or script-chapter
			periodical = trans_periodical;
			periodical_error = ' ' .. set_error ('trans_missing_title', {'periodical'});
		end
	end

	return periodical .. periodical_error;
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (scriptchapter, script_chapter_source, chapter, transchapter, chapterurl, chapter_url_source, no_quotes, access)
	local chapter_error = '';

	local ws_url, ws_label, L = wikisource_url_make (chapter);					-- make a wikisource url and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', '');										-- replace underscore separaters with space characters
		chapter = ws_label;
	end

	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
			chapter = wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, scriptchapter, script_chapter_source);	-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (chapterurl) then
		chapter = external_link (chapterurl, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');	-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if is_set (transchapter) then
		transchapter = wrap_style ('trans-quoted-title', transchapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. transchapter;
		else																	-- here when transchapter without chapter or script-chapter
			chapter = transchapter;
			chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
		end
	end

--	if is_set (chapterurl) then
--		chapter = external_link (chapterurl, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
--	end

	return chapter .. chapter_error;
end


--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i=1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- Test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position and (char == 'zero width joiner') then						-- if we found a zero width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- its ok if one of the indic scripts
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { set_error( 'invisible_char', {err_msg, wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i=i+1;																	-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] .. ': ' .. k);
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash under certain conditions.  The hyphen must separate like items; unlike items are
returned unmodified.  These forms are modified:
	letter - letter (A - B)
	digit - digit (4-5)
	digit separator digit - digit separator digit (4.1-4.5 or 4-1-4-5)
	letterdigit - letterdigit (A1-A5) (an optional separator between letter and digit is supported – a.1-a.5 or a-1-a-5)
	digitletter - digitletter (5a - 5d) (an optional separator between letter and digit is supported – 5.a-5.d or 5-a-5-d)

any other forms are returned unmodified.

str may be a comma- or semicolon-separated list

]]

local function hyphen_to_dash( str )
	if not is_set (str) then
		return str;
	end
	
	str, count = str:gsub ('^%(%((.+)%)%)$', '%1');								-- remove accept-this-as-written markup when it wraps all of str
	if 0 ~= count then															-- non-zero when markup removed; zero else
		return str;																-- nothing to do, we're done
	end
	
	str = str:gsub ('&amp;[nm]dash;', {['&amp;ndash;'] = '–', ['&amp;mdash;'] = '—'});		-- replace &amp;mdash; and &amp;ndash; entities  with their characters; semicolon mucks up the text.split
	
	local out = {};
	local list = mw.text.split (str, '%s*[,;]%s*');								-- split str at comma or semicolon separators if there are any

	for _, item in ipairs (list) do												-- for each item in the list
		if mw.ustring.match (item, '^%w*[%.%-]?%w+%s*[%-–—]%s*%w*[%.%-]?%w+$') then	-- if a hyphenated range or has endash or emdash separators
			if item:match ('%a+[%.%-]?%d+%s*%-%s*%a+[%.%-]?%d+') or				-- letterdigit hyphen letterdigit (optional separator between letter and digit)
				item:match ('%d+[%.%-]?%a+%s*%-%s*%d+[%.%-]?%a+') or			-- digitletter hyphen digitletter (optional separator between digit and letter)
				item:match ('%d+[%.%-]%d+%s*%-%s*%d+[%.%-]%d+') or				-- digit separator digit hyphen digit separator digit
				item:match ('%d+%s*%-%s*%d+') or								-- digit hyphen digit
				item:match ('%a+%s*%-%s*%a+') then								-- letter hyphen letter
					item = item:gsub ('(%w*[%.%-]?%w+)%s*%-%s*(%w*[%.%-]?%w+)', '%1–%2');	-- replace hyphen, remove extraneous space characters
			else
				item = mw.ustring.gsub (item, '%s*[–—]%s*', '–');				-- for endash or emdash separated ranges, replace em with en, remove extraneous white space
			end
		end
		item = item:gsub ('^%(%((.+)%)%)$', '%1');								-- remove the accept-this-as-written markup
		table.insert (out, item);												-- add the (possibly modified) item to the output table
	end

	return table.concat (out, ', ');											-- concatenate the output table into a comma separated string
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'dupicate character'
		if 1 == #duplicate_char then											-- for single byte ascii characters use the string library functions
			f.gsub=string.gsub
			f.match=string.match
			f.sub=string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub=mw.ustring.gsub
			f.match=mw.ustring.match
			f.sub=mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1,1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = f.sub(str, -1,-1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if f.sub(str, -3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5,-1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4,-1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if f.sub(str, -3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3,-1) == duplicate_char .. '&quot;]' then		-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2,-1) == duplicate_char .. &quot;]&quot; then		-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4,-1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2,-1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows html markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;------------------------------------------------------------

returns true is suffix is properly formed Jr, Sr, or ordinal in the range 2–9.  Puncutation not allowed.

]]

local function is_suffix (suffix)
	if in_array (suffix, {'Jr', 'Sr', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written ouside of the code editor and pasted here because the code editor gets confused between character insertion point and cursor position.
The test has been rewritten to use decimal character escape sequence for the individual bytes of the unicode characters so that it is not necessary
to use an external editor to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first)
	local first, suffix = first:match ('(.-),?%s*([%dJS][%drndth]+)%.?$') or first;	-- if first has something that looks like a generational suffix, get it

	if is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error ('suffix');
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error ('non-Latin character');
			return false;														-- not a string of latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just intials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error ('suffix');									-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word


	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i],1,1));				-- insert the intial at end of initials table
		end
		i = i+1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between authors is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between authors is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = make_wikilink (person.link, one);						-- link author/editor if this page is not the author's/editor's page
				end
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end


--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]
local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of name parameters (author, editor, etc) for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the associated |display-&lt;names&gt;=etal parameter

]]

local function name_has_etal (name, etal, nocat, param)

	if is_set (name) then														-- name can be nil in which case just return
		local patterns = cfg.et_al_patterns;									--get patterns from configuration
		
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns
			if name:match (pattern) then										-- if this 'et al' pattern is found in name
				name = name:gsub (pattern, '');									-- remove the offending text
				etal = true;													-- set flag (may have been set previously here or by |display-&lt;names&gt;=etal)
				if not nocat then												-- no categorization for |vauthors=
					table.insert( z.message_tail, {set_error ('etal', {param})});	-- and set an error if not added
				end
			end
		end
	end

	return name, etal;															-- 
end


--[[--------------------------&lt; N A M E _ H A S _ E D _ M A R K U P &gt;------------------------------------------

Evaluates the content of author and editor parameters for extranious editor annotations: ed, ed., eds, (Ed.), etc.
These annotation do not belong in author parameters and are redundant in editor parameters.  If found, the function
adds the editor markup maintenance category.

]]

local function name_has_ed_markup (name, list_name)
	local _, pattern;
	local patterns = cfg.editor_markup_patterns;								-- get patterns from configuration

	if is_set (name) then
		for _, pattern in ipairs (patterns) do									-- spin through patterns table and
			if name:match (pattern) then
				add_maint_cat ('extra_text_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
				break;
			end
		end
	end
	return name;																-- and done
end


--[[--------------------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;----------------------------------------

Evaluates the content of author and editor (surnames only) parameters for multiple names.  Multiple names are
indicated if there is more than one comma and or semicolon.  If found, the function adds the multiple name
(author or editor) maintenance category.

]]

local function name_has_mult_names (name, list_name)
local count, _;
	if is_set (name) then
		_, count = name:gsub ('[;,]', '');										-- count the number of separator-like characters
		
		if 1 &lt; count then														-- param could be |author= or |editor= so one separator character is acceptable
			add_maint_cat ('mult_names', cfg.special_case_translation [list_name]);	-- more than one separator indicates multiple names so add a maint cat for this template
		end
	end
	return name;																-- and done
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------
This function calls various name checking functions used to validate the content of the various name-holding
parameters.

]]

local function name_checks (last, first, list_name)
	if is_set (last) then
		if last:match ('^%(%(.*%)%)$') then										-- if wrapped in doubled parentheses, accept as written 
			last = last:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			last = name_has_mult_names (last, list_name);						-- check for multiple names in the parameter (last only)
			last = name_has_ed_markup (last, list_name);						-- check for extraneous 'editor' annotation
		end
	end
	if is_set (first) then
		if first:match ('^%(%(.*%)%)$') then									-- if wrapped in doubled parentheses, accept as written 
			first = first:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			first = name_has_ed_markup (first, list_name);						-- check for extraneous 'editor' annotation
		end
	end
	return last, first;															-- done
	end


--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local last_alias, first_alias;												-- selected parameter aliases used in error messaging
	while true do
		last, last_alias = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first, first_alias = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.
		last, first= name_checks (last, first, list_name);						-- multiple names, extraneous annotation, etc checks
		
		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {first_alias, first_alias:gsub('first', 'last')}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			link_title_ok (link, list_name:match (&quot;(%w+)List&quot;):lower() .. '-link' .. i, last, list_name:match (&quot;(%w+)List&quot;):lower() .. '-last' .. i);	-- check for improper wikimarkup

			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {list_name:match (&quot;(%w+)List&quot;):lower(), i-1}, true ) } );	-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because case of the source may be incorrect
or different from the case that WikiMedia uses, the name comparisons are done in lower case and when a match is
found, the Wikimedia version (assumed to be correct) is returned along with the code.  When there is no match, we
return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') returns a list of languages that in some cases may include
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.  Most (all?) of these languages are not used a 'language' codes per se, rather they
are used as sub-domain names: cbk-zam.wikipedia.org.  A list of language names and codes supported by fetchLanguageNames()
can be found at Template:Citation Style documentation/language/doc

Names that are included in the list will be found if that name is provided in the |language= parameter.  For example,
if |language=Chavacano de Zamboanga, that name will be found with the associated code 'cbk-zam'.  When names are found
and the associated code is not two or three characters, this function returns only the WikiMedia language name.

Some language names have multiple entries under different codes:
	Aromanian has code rup and code roa-rup
When this occurs, this function returns the language name and the 2- or 3-character code

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	if cfg.lang_name_remap[lang:lower()] then									-- if there is a remapped name (because MediaWiki uses something that we don't think is correct)
		return cfg.lang_name_remap[lang:lower()][1], cfg.lang_name_remap[lang:lower()][2];	-- for this language 'name', return a possibly new name and appropriate code
	end

	local ietf_code;															-- because some languages have both ietf-like codes and iso 639-like codes
	local ietf_name;
	
	local languages = mw.language.fetchLanguageNames(this_wiki_code, 'all')		-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons

	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 == code:len() or 3 == code:len() then							-- two- or three-character codes only; extensions not supported
				return name, code;												-- so return the name and the code
			end
			ietf_code = code;													-- remember that we found an ietf-like code and save its name
			ietf_name = name;													-- but keep looking for a 2- or 3-char code
		end
	end
																				-- didn't find name with 2- or 3-char code; if ietf-like code found return
	return ietf_code and ietf_name or lang;										-- associated name; return original language text else
end


--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code is recognized by MediaWiki,
use the returned name; if not, then use the value that was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is assigned to the category for
that code: Category:Norwegian-language sources (no).  For valid three-character code languages, the page is assigned
to the single category for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does not recognize three-character
equivalents of two-character codes: code 'ar' is recognized bit code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are
separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki = mw.getContentLanguage();									-- get a language object for this wiki
	local this_wiki_code = this_wiki:getCode()									-- get this wiki's language code
	local this_wiki_name = mw.language.fetchLanguageName(this_wiki_code, this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang
		name = cfg.lang_code_remap[lang:lower()];								-- first see if this is a code that is not supported by MediaWiki but is in remap

		if name then															-- there was a remapped code so
			lang = lang:gsub ('^(%a%a%a?)%-.*', '%1');							-- strip ietf tags from code
		else
			if lang:match ('^%a%a%-') then										-- strip ietf tags from code; TODO: is there a need to support 3-char with tag?
				lang = lang:match ('(%a%a)%-')									-- keep only 639-1 code portion to lang; TODO: do something with 3166 alpha 2 country code?
			end
			if 2 == lang:len() or 3 == lang:len() then							-- if two-or three-character code
				name = mw.language.fetchLanguageName (lang:lower(), this_wiki_code);	-- get language name if |language= is a proper code
			end
		end

		if is_set (name) then													-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, this_wiki_code);				-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then													-- only 2- or 3-character codes
			name = cfg.lang_code_remap[code] or name;							-- override wikimedia when they misuse language codes/names

			if this_wiki_code ~= code then										-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					add_prop_cat ('foreign_lang_source' .. code, {name, code})	-- categorize it
				else															-- or is a recognized language (but has a three-character code)
					add_prop_cat ('foreign_lang_source_2' .. code, {code})		-- categorize it differently TODO: support mutliple three-character code categories per cs1|2 template
				end
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, cfg.messages['parameter-pair-separator'])		-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		name = table.concat (language_list, ', ');											-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
		name = name:gsub (', ([^,]+)$', cfg.messages['parameter-final-separator'] .. '%1');	-- replace last '&lt;comma&gt;&lt;space&gt;' separator with '&lt;comma&gt;&lt;space&gt;and&lt;space&gt;' separator
	end
	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings
At en.wiki, for cs1:
	ps gets:	'.'
	sep gets:	'.'

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = cfg.presentation['ps_cs1'];										-- terminate the rendered citation
	end
	return cfg.presentation['sep_cs1'], ps;										-- element separator
end


--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings
At en.wiki, for cs2:
	ps gets:	'' (empty string - no terminal punctuation)
	sep gets:	','

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = cfg.presentation['ps_cs2'];										-- terminate the rendered citation
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return cfg.presentation['sep_cs2'], ps, ref;								-- element separator
end


--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end


--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end


--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or
		url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
		url:match ('%.PDF&amp;#035') or url:match ('%.pdf&amp;#035');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parentheses, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[--------------------------&lt; G E T _ D I S P L A Y _ N A M E S &gt;--------------------------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_names (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_name', cfg.special_case_translation [list_name]);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parnetheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a place holder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parens
			local name = name_table[i];
			i=i+1;																-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parens
					break;														-- and done reassembling so
				end
				i=i+1;															-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = is_wikilink (name_table[i]);					-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i+1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parentheses to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')								-- remove doubled parntheses
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error ('punctuation');
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
			if is_suffix (first) then											-- if a valid suffix
				suffix = first													-- save it as a suffix and
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end																	-- no suffix error message here because letter combination may be result of Romanization; check for digits?
			last = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error ('missing comma');								-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error ('name');										-- matches a space between two intiials
			end
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error ('initials');									-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first);									-- check first and last before restoring the suffix which may have a non-Latin digit
			if is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '');
			end
		end

		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ) or v_link_table[i];
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice incase we have a |first1= without a |last1=; this ...
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or	-- ... also catches the case where |first= is used with |vauthors=
		select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, no, etc).  When the parameter value has not been assigned a value (missing or empty
in the source template) the function returns true.  If the parameter value is one of the list of allowed values returns
true; else, emits an error message and returns false.

]]

local function is_valid_parameter_value (value, name, possible)
	if not is_set (value) then
		return true;															-- an empty parameter is ok
	elseif in_array (value, possible) then
		return true;
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list,-3,-1) == sepc .. '. ') then						-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list,-1,-1) == sepc) or (string.sub (name_list,-3,-1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terninate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not is_set (volume) and not is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end

	local vol = '';																-- here for all cites except magazine
		
	if is_set (volume) then
		if volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$')then			-- volume value is all digits or all uppercase roman numerals
			vol = substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});	-- render in bold face
		elseif (4 &lt; mw.ustring.len(volume)) then								-- not all digits or roman numerals and longer than 4 characters
			vol = substitute (cfg.messages['j-vol'], {sepc, volume});			-- not bold
			add_prop_cat ('long_vol');
		else																	-- four or less characters
			vol = substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});	-- bold
		end
	end
	if is_set (issue) then
		return vol .. substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if is_set (page) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif is_set(pages) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then							-- if pages is only digits, assume a single page number
			return '', substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to wikisource, returns the label portion of the interwikilink as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki link to and external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, pages, at)
	local ws_url, ws_label, coins_pages, L;										-- for wikisource interwikilinks; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if is_set (page) then
		if is_set (pages) or is_set(at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws url from |page= interwiki link; link portion L becomes tool tip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif is_set (pages) then
		if is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws url from |pages= interwiki link; link portion L becomes tool tip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws url from |at= interwiki link; link portion L becomes tool tip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end



--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org urls to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot url or to calendar pages.  When the archive url is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the url.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org url does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command url
	|archive-url= is an archive.org url that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org urls:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this funct may return a modified
archive url:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the url unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.or url
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine url
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command url, we don't want to allow saving of the target page 
		err_msg = 'save command';
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = 'liveweb';
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');	-- split out some of the url parts for evaluation
		
		if not is_set(timestamp) or 14 ~= timestamp:len() then					-- path and flag optional, must have 14-digit timestamp here
			err_msg = 'timestamp';
			if '*' ~= flag then
				url=url:gsub ('(//web%.archive%.org/[^%d]*%d?%d?%d?%d?%d?%d?)[^/]*', '%1*', 1)	-- for preview, modify ts to be yearmo* max (0-6 digits plus splat)
			end
		elseif is_set(path) and 'web/' ~= path then								-- older archive urls do not have the extra 'web/' path element
			err_msg = 'path';
		elseif is_set (flag) and not is_set (path) then							-- flag not allowed with the old form url (without the 'web/' path element)
			err_msg = 'flag';
		elseif is_set (flag) and not flag:match ('%a%a_') then					-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = 'flag';
		else
			return url, date;													-- return archiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	table.insert( z.message_tail, { set_error( 'archive_url', {err_msg}, true ) } );	-- add error message and
	if is_set (Frame:preprocess('{{REVISIONID}}')) then
		return '', '';															-- return empty strings for archiveURL and ArchiveDate
	else
		return url, date;														-- preview mode so return archiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

-- set default parameter values defined by |mode= parameter.
	local Mode = A['Mode'];
	if not is_valid_parameter_value (Mode, 'mode', cfg.keywords['mode']) then
		Mode = '';
	end

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				add_maint_cat ('authors');										-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
			add_maint_cat ('editors');											-- but add a maint cat because use of this parameter is discouraged
		end
	end

	local translator_etal;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=

	local interviewer_etal;
	local interviewers_list = {};												
	local Interviewers;															-- used later
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters

	local contributor_etal;
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list
	local Contribution = A['Contribution'];
	if in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not is_set (Contribution) then									-- |contributor= requires |contribution=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if select_one (args, cfg.aliases['ContributorList-Last'], 'redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { set_error( 'contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if not is_valid_parameter_value (NameListFormat, 'name-list-format', cfg.keywords['name-list-format']) then	-- only accepted value for this parameter is 'vanc'
		NameListFormat = '';													-- anything else, set to empty string
	end

	if is_set (Others) then
		if 0 == #a and 0 == #e then												-- add maint cat when |others= has value and used without |author=, |editor=
			add_maint_cat ('others');
		end
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
			link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wikimarkup in |title-link= or wikimarkup in |title= when |title-link= is set

	local Chapter = A['Chapter'];
	local ScriptChapter = A['ScriptChapter'];
	local ScriptChapterOrigin = A:ORIGIN ('ScriptChapter');
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];

	local ArchiveDate;
	local ArchiveURL;

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	
	local UrlStatus = A['UrlStatus'];
	if 'url-status' == A:ORIGIN ('UrlStatus') then								-- interim: TODO: this line goes away
		if not is_valid_parameter_value (UrlStatus, 'url-status', cfg.keywords ['url-status']) then	-- set in config.defaults to 'dead'
			UrlStatus = '';														-- anything else, set to empty string
		end																		-- interim: TODO: this line goes away
	elseif is_set (A:ORIGIN ('UrlStatus')) then									-- interim: while both |dead-url= and |url-status= allowed use separate keyword lists; TODO: remove this section
		if not is_valid_parameter_value (UrlStatus, A:ORIGIN ('UrlStatus'), cfg.keywords ['deadurl']) then	-- interim: assume |dead-url=; use those keywords; TODO: this line goes away
			UrlStatus = '';														-- anything else, set to empty string; interim: TODO: this line goes away
		end																		-- interim: TODO: this line goes away
	end																			-- interim: TODO: this line goes away
	
	if in_array (UrlStatus, {'yes', 'true', 'y'}) then							-- TODO: remove this whole thing when |dead-url=[yes|no] parameters removed from articles
		UrlStatus = 'dead';
	elseif 'no' == UrlStatus then
		UrlStatus = 'live';
	end
	
	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];
	local Periodical_origin = '';
		if is_set (Periodical) then
			Periodical_origin = A:ORIGIN('Periodical');							-- get the name of the periodical parameter
			local i;
			Periodical, i = strip_apostrophe_markup (Periodical);				-- strip appostrophe markup so that metadata isn't contaminated 
			if i then															-- non-zero when markup was stripped so emit an error message
				table.insert( z.message_tail, {set_error ('apostrophe_markup', {Periodical_origin}, true)});
			end
		end

	local ScriptPeriodical = A['ScriptPeriodical'];
	local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');
																				-- web and news not tested for now because of 
																				-- Wikipedia:Administrators%27_noticeboard#Is_there_a_semi-automated_tool_that_could_fix_these_annoying_&quot;Cite_Web&quot;_errors?
		if not (is_set (Periodical) or is_set (ScriptPeriodical)) then			-- 'periodical' templates require periodical parameter
--			local p = {['journal'] = 'journal', ['magazine'] = 'magazine', ['news'] = 'newspaper', ['web'] = 'website'};	-- for error message
			local p = {['journal'] = 'journal', ['magazine'] = 'magazine'};		-- for error message
			if p[config.CitationClass]  then
				table.insert( z.message_tail, {set_error ('missing_periodical', {config.CitationClass, p[config.CitationClass]}, true)});
			end
		end

	local TransPeriodical =  A['TransPeriodical'];

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if 'citation' == config.CitationClass then
		if is_set (Periodical) then
			if not in_array (Periodical_origin, {'website', 'mailinglist'}) then	-- {{citation}} does not render volume for these 'periodicals'
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		elseif is_set (ScriptPeriodical) then
			if 'script-website' ~= ScriptPeriodical_origin then					-- {{citation}} does not render volume for |script-website=
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		else
			Volume = A['Volume'];												-- and does for non-'periodical' cites
		end
	elseif in_array (config.CitationClass, cfg.templates_using_volume) then		-- render |volume= for cs1 according to the configuration settings
		Volume = A['Volume'];
	end	

	if 'citation' == config.CitationClass then
		if is_set (Periodical) and in_array (Periodical_origin, {'journal', 'magazine', 'newspaper', 'periodical', 'work'}) or	-- {{citation}} renders issue for these 'periodicals'
			is_set (ScriptPeriodical) and in_array (ScriptPeriodical_origin, {'script-journal', 'script-magazine', 'script-newspaper', 'script-periodical', 'script-work'}) then -- and these 'script-periodicals'
				Issue = hyphen_to_dash (A['Issue']);
		end
	elseif in_array (config.CitationClass, cfg.templates_using_issue) then		-- conference &amp; map books do not support issue; {{citation}} listed here because included in settings table
		if not (in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (is_set (Periodical) or is_set (ScriptPeriodical))) then
			Issue = hyphen_to_dash (A['Issue']);
		end
	end

	local Position = '';
	if not in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash (A['Pages']);	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local PublisherName_origin = A:ORIGIN('PublisherName');
		if is_set (PublisherName) then
			local i=0;
			PublisherName, i = strip_apostrophe_markup (PublisherName);			-- strip appostrophe markup so that metadata isn't contaminated; publisher is never italicized

			if i then															-- non-zero when markup was stripped so emit an error message
				table.insert( z.message_tail, {set_error ('apostrophe_markup', {PublisherName_origin}, true)});
			end
		end

	local RegistrationRequired = A['RegistrationRequired'];
		if not is_valid_parameter_value (RegistrationRequired, 'registration', cfg.keywords ['yes_true_y']) then
			RegistrationRequired=nil;
		end

	local SubscriptionRequired = A['SubscriptionRequired'];
		if not is_valid_parameter_value (SubscriptionRequired, 'subscription', cfg.keywords ['yes_true_y']) then
			SubscriptionRequired=nil;
		end

	local UrlAccess = A['UrlAccess'];
		if not is_valid_parameter_value (UrlAccess, 'url-access', cfg.keywords ['url-access']) then
			UrlAccess = nil;
		end
		if not is_set(URL) and is_set(UrlAccess) then
			UrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {'url'}, true ) } );
		end
		
		if is_set (UrlAccess) and is_set (SubscriptionRequired) then			-- while not aliases, these are much the same so if both are set
			table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'url-access') .. ' and ' .. wrap_style ('parameter', 'subscription')}, true ) } );		-- add error message
			SubscriptionRequired = nil;											-- unset; prefer |access= over |subscription=
		end
		if is_set (UrlAccess) and is_set (RegistrationRequired) then			-- these are not the same but contradictory so if both are set
			table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'url-access') .. ' and ' .. wrap_style ('parameter', 'registration')}, true ) } );		-- add error message
			RegistrationRequired = nil;											-- unset; prefer |access= over |registration=
		end

	local ChapterUrlAccess = A['ChapterUrlAccess'];
		if not is_valid_parameter_value (ChapterUrlAccess, A:ORIGIN('ChapterUrlAccess'), cfg.keywords ['url-access']) then	-- same as url-access
			ChapterUrlAccess = nil;
		end
		if not is_set(ChapterURL) and is_set(ChapterUrlAccess) then
			ChapterUrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {A:ORIGIN('ChapterUrlAccess'):gsub ('%-access', '')}, true ) } );
		end

	local MapUrlAccess = A['MapUrlAccess'];
		if not is_valid_parameter_value (MapUrlAccess, 'map-url-access', cfg.keywords ['url-access']) then
			MapUrlAccess = nil;
		end
		if not is_set(A['MapURL']) and is_set(MapUrlAccess) then
			MapUrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {'map-url'}, true ) } );
		end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local Agency = A['Agency'];

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
		if not is_valid_parameter_value (IgnoreISBN, 'ignore-isbn-error', cfg.keywords ['yes_true_y']) then
			IgnoreISBN = nil;													-- anything else, set to empty string
		end
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );
		if is_set (DoiBroken) and not ID_list['DOI'] then
			table.insert( z.message_tail, { set_error( 'doibroken_missing_doi', A:ORIGIN('DoiBroken'))});
		end
	local ID_access_levels = extract_id_access_levels( args, ID_list );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
		if not is_valid_parameter_value (LastAuthorAmp, 'last-author-amp', cfg.keywords ['yes_true_y']) then
			LastAuthorAmp = nil;												-- set to empty string
		end

	local no_tracking_cats = A['NoTracking'];
		if not is_valid_parameter_value (no_tracking_cats, 'no-tracking', cfg.keywords ['yes_true_y']) then
			no_tracking_cats = nil;												-- set to empty string
		end

	--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = A['DF'];															-- date format set in cs1|2 template
	if not is_valid_parameter_value (DF, 'df', cfg.keywords['date-format']) then	-- validate reformatting keyword
		DF = '';																-- not valid, set to empty string
	end
	if not is_set (DF) then
		DF = cfg.global_df;
	end

	local sepc;																	-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );											-- used to control capitalization for certain static text

	--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

	-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	select_one( args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'redundant_parameters' );	-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, Pages, At);

	local NoPP = A['NoPP'] 
	if is_set (NoPP) and is_valid_parameter_value (NoPP, 'nopp', cfg.keywords ['yes_true_y']) then
		NoPP = true;
	else
		NoPP = nil;																-- unset, used as a flag later
	end

	if not is_set(PublicationPlace) and is_set(Place) then						-- both |publication-place= and |place= (|location=) allowed if different
		PublicationPlace = Place;												-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end							-- don't need both if they are the same
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia and |title then map |title to |article and |encyclopedia to |title
		|encyclopedia and |article then map |encyclopedia to |title

		|trans-title maps to |trans-chapter when |title is re-mapped
		|url maps to |chapterurl when |title is remapped
	
	All other combinations of |encyclopedia, |title, and |article are not modified
	
	]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set (Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					ScriptChapterOrigin = 'title';
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterUrlAccess = UrlAccess;

					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter = make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			elseif is_set (Chapter) then										-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if is_set(A['Number']) then												-- cite techreport uses 'number', which other citations alias to 'issue'
			if not is_set(ID) then												-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', 'id') .. ' and ' .. wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

	-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	elseif 'mailinglist' == Periodical_origin then
		Periodical = '';														-- unset because mailing list is only used for cite mailing list
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		ChapterUrlAccess = MapUrlAccess;
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];

		link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wikimarkup in |series-link= or wikimarkup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) and is_set (AirDate) then							-- promote airdate to date
			Date = AirDate;
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('seriesnum', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ScriptChapterOrigin = 'title';
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = make_wikilink (ChapterLink, Chapter);
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = make_wikilink (SeriesLink, Series);
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite ssrn}}, before generation of COinS data.
	do
		if in_array (config.CitationClass, {'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) then
			if not is_set (ID_list[config.CitationClass:upper()]) then			-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp; |citeseerx= required for their templates
				table.insert( z.message_tail, { set_error( config.CitationClass .. '_missing', {}, true ) } );	-- add error message
			end

			Periodical = ({['arxiv'] = 'arXiv', ['biorxiv'] = bioRxiv, ['citeseerx'] = 'CiteSeerX', ['ssrn'] = 'Social Science Research Network'})[config.CitationClass];
		end
	end

	-- handle type parameter for those CS1 citations that have default values
	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;interview&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
		TitleType = substitute( cfg.messages['type'], TitleType);				-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging

	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val=AccessDate, name=A:ORIGIN ('AccessDate')},
			['archive-date'] = {val=ArchiveDate, name=A:ORIGIN ('ArchiveDate')},
			['date'] = {val=Date, name=Date_origin},
			['doi-broken-date'] = {val=DoiBroken, name=A:ORIGIN ('DoiBroken')},
			['embargo'] = {val=Embargo, name=A:ORIGIN ('Embargo')},
			['lay-date'] = {val=LayDate, name=A:ORIGIN ('LayDate')},
			['publication-date'] ={val=PublicationDate, name=A:ORIGIN ('PublicationDate')},
			['year'] = {val=Year, name=A:ORIGIN ('Year')},
			};
		anchor_year, Embargo, error_message = dates(date_parameters_list, COinS_date);

-- start temporary Julian / Gregorian calendar uncertainty categorization
		if COinS_date.inter_cal_cat then
			add_prop_cat ('jul_greg_uncertainty');
		end
-- end temporary Julian / Gregorian calendar uncertainty categorization

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end
		
		if not is_set(error_message) then										-- error free dates only
			local modified = false;												-- flag
			
			if is_set (DF) then													-- if we need to reformat dates
				modified = reformat_dates (date_parameters_list, DF, false);	-- reformat to DF format, use long month names if appropriate
			end

			if true == date_hyphen_to_dash (date_parameters_list) then			-- convert hyphens to dashes where appropriate
				modified = true;
				add_maint_cat ('date_format');									-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language,
	-- uncomment these three lines.  Not supported by en.wiki (for obvious reasons)
	-- set date_name_xlate() second argument to true to translate English digits to local digits (will translate ymd dates)
--			if date_name_xlate (date_parameters_list, false) then
--				modified = true;
--			end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				LayDate = date_parameters_list['lay-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end
		else
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end
	end	-- end of do

	-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
	-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
			if is_set(AccessDate) then											-- access date requires |url=; pmc created url is not |url=
				table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
				AccessDate = '';												-- unset
			end

		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
			if 'episode' == config.CitationClass then							-- special case for cite episode; TODO: is there a better way to do this?
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
			else
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
			end
	end

	if 'none' == Title and
			in_array (config.CitationClass, {'journal', 'citation'}) and
			(is_set (Periodical) or is_set (ScriptPeriodical)) and
			('journal' == Periodical_origin or 'script-journal' == ScriptPeriodical_origin) then	-- special case for journal cites
				Title = '';														-- set title to empty string
				add_maint_cat ('untitled');
	end

	check_for_url ({															-- add error message when any of these parameters hold a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[Periodical_origin] = Periodical,
		[PublisherName_origin] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = strip_apostrophe_markup (Periodical),					-- no markup in the metadata
		['Encyclopedia'] = strip_apostrophe_markup (Encyclopedia),
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = coins_pages or get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,										-- any apostrophe markup already removed
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, and {{cite ssrn}} AFTER generation of COinS data.
	if in_array (config.CitationClass, {'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, CiteSeerX, or ssrn now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = substitute (cfg.messages['newsgroup'], external_link( 'news:' .. PublisherName, PublisherName, PublisherName_origin, nil ));
		end
	end

	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text,											-- get current page name so that we don't wikilink to it via editorlinkn
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_names (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if is_set (Editors) then
				Editors, editor_etal = name_has_etal (Editors, editor_etal, false, 'editors');	-- find and remove variations on et al.
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
					EditorCount = 2;											-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
				else
					EditorCount = 2;											-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
				end
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum , interviewer_etal = get_display_names (A['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal);
			Interviewers = list_people (control, interviewers_list, interviewer_etal);
		end
		do																		-- now do translators
			control.maximum , translator_etal = get_display_names (A['DisplayTranslators'], #t, 'translators', translator_etal);
			Translators = list_people (control, t, translator_etal);
		end
		do																		-- now do contributors
			control.maximum , contributor_etal = get_display_names (A['DisplayContributors'], #c, 'contributors', contributor_etal);
			Contributors = list_people (control, c, contributor_etal);
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_names (A['DisplayAuthors'], #a, 'authors', author_etal);

			last_first_list = list_people(control, a, author_etal);

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors');	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if is_set (Authors) and is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
	-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (is_set (Periodical) or is_set (ScriptPeriodical)) and not is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not is_set(URL) then
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) or		-- |url= required for cite web, cite podcast, and cite mailinglist
			('citation' == config.CitationClass and ('website' == Periodical_origin or 'script-website' == ScriptPeriodical_origin)) then	-- and required for {{citation}} with |website= or |script-website=
				table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURLorigin, OriginalFormat, OriginalAccess;
--	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	UrlStatus = UrlStatus:lower();												-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (ChapterURL) then 											-- if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURLorigin = ChapterURLorigin;								-- name of chapter-url parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=
--			if 'no' ~= DeadURL then
			if 'live' ~= UrlStatus then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				ChapterURLorigin = A:ORIGIN('ArchiveURL')						-- name of archive-url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived urls
			end
		elseif is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURLorigin = URLorigin;										-- name of url parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;
--			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
			if 'live' ~= UrlStatus then											-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived urls
			end
 		end
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and (is_set (Periodical) or is_set (ScriptPeriodical)) and not is_set (Encyclopedia)) then
			local chap_param;
			if is_set (Chapter) then											-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif is_set (ScriptChapter) then
				chap_param = ScriptChapterOrigin;
			else is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if is_set (chap_param) then											-- if we found one
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {chap_param}, true ) } );		-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if is_set (Contribution) and 0 &lt; #c then								-- if this is a contribution with contributor(s)
			if in_array (Contribution:lower(), cfg.keywords.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, ScriptChapterOrigin, Chapter, TransChapter, ChapterURL, ChapterURLorigin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter.. sepc .. ' ';
		elseif is_set (ChapterFormat) then										-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title.
	if is_set (ArchiveURL) and mw.ustring.match (mw.ustring.lower(Title), cfg.special_case_translation['archived_copy']) then	-- if title is 'Archived copy' (place holder added by bots that can't find proper title)
		add_maint_cat ('archived_copy');										-- add maintenance category before we modify the content of Title
	end

	if Title:match ('^%(%(.*%)%)$') then										-- if keep as written markup:
		Title= Title:gsub ('^%(%((.*)%)%)$', '%1')								-- remove the markup
	else
		if '...' == Title:sub (-3) then											-- if elipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%'..sepc..'$', '');				-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end
	end
	
	if in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (is_set (Periodical) or is_set (ScriptPeriodical)) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and (is_set (Periodical) or is_set (ScriptPeriodical))) then		-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle, 'script-title');	-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end

	if is_set(Title) then
		if not is_set (TitleLink) and is_set (URL) then
			Title = external_link (URL, Title, URLorigin, UrlAccess) .. TransTitle .. TransError .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif is_set (TitleLink) and not is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = make_wikilink (TitleLink, Title) .. TransTitle .. TransError;
			end
		else
			local ws_url, ws_label;
			ws_url, ws_label, L = wikisource_url_make (Title);					-- make ws url from |title= interwiki link; link portion L becomes tool tip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = Title .. TransTitle .. TransError;
			end
		end
	else
		Title = TransTitle .. TransError;
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURLorigin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin, nil );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if is_set(Minutes) then
			if is_set (Time) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'minutes') .. ' and ' .. wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = is_set (Series) and wrap_msg ('series', {sepc, Series}) or &quot;&quot;;		-- not the same as SeriesNum
	OrigYear = is_set (OrigYear) and wrap_msg ('origyear', OrigYear) or '';
	Agency = is_set (Agency) and wrap_msg ('agency', {sepc, Agency}) or &quot;&quot;;
	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	Via = is_set (Via) and  wrap_msg ('via', Via) or '';

	--[[
	Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
	note is displayed. There are no error messages for this condition.
	
	]]
	if is_set (SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif is_set (RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text

		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {IdAccessLevels=ID_access_levels, DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin, UrlAccess );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then				-- if first and last characters of quote are quote marks
			Quote = Quote:sub(2,-2);											-- strip them off
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;live&quot; == UrlStatus then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-live'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- UrlStatus is empty, 'dead', 'unfit', 'usurped', 'bot: unknown'
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if in_array (UrlStatus, {'unfit', 'usurped', 'bot: unknown'}) then
				Archived = sepc .. &quot; &quot; .. 'Archived from the original on ' .. ArchiveDate;	-- format already styled
				if 'bot: unknown' == UrlStatus then
					add_maint_cat ('bot:_unknown');								-- and add a category if not already added
				else
					add_maint_cat ('unfit');									-- and add a category if not already added
				end
			else																-- UrlStatus is empty, 'dead'
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURLorigin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURLorigin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin, nil );
	end

	local Publisher;
	if is_set(PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if is_set(PublisherName) then
		if is_set(PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif is_set(PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if (is_set (Periodical) or is_set (ScriptPeriodical) or is_set (TransPeriodical)) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical);
		else 
			Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical);
		end
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then									-- cite speech only
		TitleNote = &quot; (Speech)&quot;;												-- annotate the citation
		if is_set (Periodical) then												-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then											-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;							-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = safe_join ({Others, sepc .. &quot; &quot;}, sepc) end		-- add terminal punctuation &amp; space; check for dup sepc; TODO why do we need to do this here?
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(Periodical) then		-- special cases for book cites
		if is_set (Contributors) then											-- when we are citing foreword, preface, introduction, etc
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon;
	if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then	-- special case for cite AV media &amp; cite episode position transcript
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	else
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	end
	
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if is_set(Date) then
		if is_set (Authors) or is_set (Editors) then							-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;;				-- in paranetheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon,-1,-1) == sepc) then							-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigYear;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigYear;							-- Date begins with sepc
			end
		end
	end	
	if is_set(Authors) then
		if (not is_set (Date)) then												-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then
					in_text = in_text:lower()									-- lowercase for cs2
				end
			end
			if EditorCount &lt;= 1 then
				post_text = &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot;;				-- be consistent with no-author, no-date case
			else
				post_text = &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot;;
			end
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if is_set (Contributors) then											-- book cite and we're citing the intro, preface, etc
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if is_set (Editors) and is_set (Date) then							-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not is_set (Date)) then											-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc ); 								--Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = config.CitationClass;
		options.class = &quot;citation &quot; .. config.CitationClass;					-- class=citation required for blue highlight when used with |ref=
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then								-- set reference anchor if appropriate
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			if #namelist &gt; 0 then												-- if there are names in namelist
				id = anchor_id (namelist, year);								-- go make the CITEREF anchor
			else
				id = '';														-- unset
			end
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;(.-)&lt;/span&gt;&quot;, &quot;%1&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then	-- remove &lt;span&gt; tags and other html-like markup; then get length of what remains
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	local render = {};															-- here we collect the final bits for concatenation into the rendered citation

	if is_set(options.id) then													-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render, substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text}));	-- when |ref= is set
	else
		table.insert (render, substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text}));	-- all other cases
	end		

	table.insert (render, substitute (cfg.presentation['ocins'], {OCinSoutput}));	-- append metadata to the citation

	if 0 ~= #z.message_tail then
		table.insert (render, ' ');
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					table.insert (render, error_comment( v[1], v[2] ));
				else
					table.insert (render, error_comment( v[1] .. &quot;; &quot;, v[2] ));
				end
			end
		end
	end

	if 0 ~= #z.maintenance_cats then
		local maint_msgs = {};													-- here we collect all of the maint messages
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			local maint = {};													-- here we assemble a maintenence message
			table.insert (maint, v);											-- maint msg is the category name
			table.insert (maint, ' (');											-- open the link text
			table.insert (maint, make_wikilink (':Category:' .. v, 'link'));	-- add the link
			table.insert (maint, ')');											-- and close it
			table.insert (maint_msgs, table.concat (maint));					-- assemble new maint message and add it to the maint_msgs table
		end
		table.insert (render, substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs, ' ')));	-- wrap the group of maint message with proper presentation and save
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			table.insert (render, make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			table.insert (render, make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.properties_cats ) do								-- append properties categories
			table.insert (render, make_wikilink ('Category:' .. v));
		end
	end

	return table.concat (render);	
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class)
	local name = tostring (name);
	local state;
	
	if in_array (cite_class, {'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) then	-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[name];
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end

		state = whitelist[cite_class .. '_basic_arguments'][name];				-- look in the parameter-list for the template identified by cite_class

		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
																				-- limited enumerated parameters list
		name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
		state = whitelist.limited_numbered_arguments[name];
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates
		
	state = whitelist.basic_arguments[name];									-- all other templates; all normal parameters allowed
											
	if true == state then return true; end										-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);											-- parameter is deprecated but still supported
		return true;
	end
																				-- all enumerated parameters allowed
	name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );												-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
	state = whitelist.numbered_arguments[name];

	if true == state then return true; end										-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);											-- parameter is deprecated but still supported
		return true;
	end
	
	return false;																-- not supported because not found or name is set to nil
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe:
	{{cite ... |title=Title access-date=2016-03-17}}

cs1|2 shares some parameter names with xml/html atributes: class=, title=, etc.  To prevent false positives xml/html
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (parameter, value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove xml/html tags because attributes: class=, title=, etc 

	capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then								-- if the capture is a valid parameter name
		table.insert( z.message_tail, {set_error ('missing_pipe',parameter)});
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ P U N C T &gt;--------------------------------------

look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_punc (param, value)
	if cfg.punct_skip[param] then
		return;																	-- parameter name found in the skip table so done
	end
	
	if value:match ('[,;:]$') then
		add_maint_cat ('extra_punct');											-- has extraneous punctuation; add maint cat
	end
end


--[[--------------------------&lt; C I T A T I O N &gt;--------------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

local function citation(frame)
	Frame = frame;																-- save a copy incase we need to display an error message in preview mode
	local pframe = frame:getParent()
	local validation, utilities, identifiers, metadata, styles;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		styles = 'Module:Citation/CS1/sandbox/styles.css';
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
		styles = 'Module:Citation/CS1/styles.css';

	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	dates = validation.dates;													-- imported functions from Module:Citation/CS1/Date validation
	year_date_check = validation.year_date_check;
	reformat_dates = validation.reformat_dates;
	date_hyphen_to_dash = validation.date_hyphen_to_dash;
	date_name_xlate = validation.date_name_xlate;

	is_set = utilities.is_set;													-- imported functions from Module:Citation/CS1/Utilities
	in_array = utilities.in_array;
	substitute = utilities.substitute;
	error_comment = utilities.error_comment;
	set_error = utilities.set_error;
	select_one = utilities.select_one;
	add_maint_cat = utilities.add_maint_cat;
	wrap_style = utilities.wrap_style;
	safe_for_italics = utilities.safe_for_italics;
	is_wikilink = utilities.is_wikilink;
	make_wikilink = utilities.make_wikilink;
	strip_apostrophe_markup = utilities.strip_apostrophe_markup;

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	extract_ids = identifiers.extract_ids;										-- imported functions from Module:Citation/CS1/Identifiers
	build_id_list = identifiers.build_id_list;
	is_embargoed = identifiers.is_embargoed;
	extract_id_access_levels = identifiers.extract_id_access_levels;
	
	make_coins_title = metadata.make_coins_title;								-- imported functions from Module:Citation/CS1/COinS
	get_coins_pages = metadata.get_coins_pages;
	COinS = metadata.COinS;

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text, error_state;

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do
		config[k] = v;
--		args[k] = v;															-- debug tool that allows us to render a citation from module {{#invoke:}}
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower(), config.CitationClass ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute (param, capture);				-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text, error_state = set_error ('parameter_ignored_suggest', {k, param}, true);	-- set the suggestion error message
							else
								error_text, error_state = set_error( 'parameter_ignored', {param}, true );	-- suggested param not supported by this template
							end
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?
																				-- TODO: is this the best place for this translation?
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then						-- here when v is empty string
			args[k] = v;														-- why do we do this?  we don't support 'empty' parameters
		end		
	end	

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);
			has_extraneous_punc (k, v);											-- look for extraneous terminal punctuation in parameter values
		end
	end
	return table.concat ({citation0( config, args), frame:extensionTag ('templatestyles', '', {src=styles, wrapper=&quot;.cs1-sandbox&quot;})});
end

--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {citation = citation};</text>
      <sha1>hivne99v5j2ug6jkebltuioanprtwdq</sha1>
    </revision>
    <revision>
      <id>4728</id>
      <parentid>4727</parentid>
      <timestamp>2019-09-07T03:39:57Z</timestamp>
      <contributor>
        <username>Izno</username>
        <id>817</id>
      </contributor>
      <comment>remove per tper</comment>
      <origin>4728</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="185637" sha1="mg282chfyjopoijk562t2mglqv0tj9o" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local dates, year_date_check, reformat_dates, date_hyphen_to_dash,				-- functions in Module:Citation/CS1/Date_validation
	date_name_xlate

local is_set, in_array, substitute, error_comment, set_error, select_one,		-- functions in Module:Citation/CS1/Utilities
	add_maint_cat, wrap_style, safe_for_italics, is_wikilink, make_wikilink,
	strip_apostrophe_markup;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local extract_ids, extract_id_access_levels, build_id_list, is_embargoed;		-- functions in Module:Citation/CS1/Identifiers

local make_coins_title, get_coins_pages, COinS;									-- functions in Module:Citation/CS1/COinS

local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

delare variables here that have page-wide scope that are not brought in from other modules; thatare created here
and used here

]]

local added_deprecated_cat;														-- boolean flag so that the category is added only once
local added_prop_cats = {};														-- list of property categories that have been added to z.properties_cats
local added_vanc_errs;															-- boolean flag so we only emit one Vancouver error / category

local Frame;																	-- holds the module's frame table


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

foreign_lang_source and foreign_lang_source_2 keys have a language code appended to them so that multiple languages
may be categorized but multiples of the same language are not categorized.

added_prop_cats is a table declared in page scope variables above

]]

local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		key = key:gsub ('(foreign_lang_source_?2?)%a%a%a?', '%1');				-- strip lang code from keyname
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));	-- make name then add to table
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a boolean declared in page scope variables above

]]

local function add_vanc_error (source)
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {source}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a uri scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of tlds: https://www.iana.org/domains/root/db

rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the tld.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a url with a scheme) will be stripped
here.  Perhaps not necessary but retained incase it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ascii characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the tld) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and tld or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%w]') then											-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at wikisource
		return false;
	end

	local patterns = {															-- patterns that look like urls
		'%f[%w][%w][%w%-]+[%w]%.%a%a+$',										-- three or more character hostname.hostname or hostname.tld
		'%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$',									-- internationalized domain name with ACE prefix
		'%f[%a][qxz]%.com$',													-- assigned one character .com hostname (x.com times out 2015-12-10)
		'%f[%a][iq]%.net$',														-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		'%f[%w][%w]%.%a%a$',													-- one character hostname and cctld (2 chars)
		'%f[%w][%w][%w]%.%a%a+$',												-- two character hostname and tld
		'^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?',								-- IPv4 address
		}

	for _, pattern in ipairs (patterns) do										-- loop through the patterns list
		if domain:match (pattern) then
			return true;														-- if a match then we think that this thing that purports to be a url is a url
		end
	end

	for _, d in ipairs ({'cash', 'company', 'today', 'org'}) do					-- look for single letter second level domain names for these top level domains
		if domain:match ('%f[%w][%w]%.' .. d) then
			return true
		end
	end
	return false;																-- no matches, we don't know what this thing is
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a url appear to be a valid url; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if is_set (scheme) then														-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when url is protocol relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a url into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following tld) (if any) and any path(/), query(?) or fragment(#).

If protocol relative url, return nil scheme and domain else return nil for both scheme and domain.

When not protocol relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol relative url
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		authority = authority:gsub ('//', '', 1);								-- replace place 1 pair of '/' with nothing;
		if is_set(authority) then												-- if anything left (1 or 3+ '/' where authority should be) then
			return scheme;														-- return scheme only making domain nil which will cause an error message
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link= etc for properly formatted content: no wikilinks, no urls

Link parameters are to hold the title of a wikipedia article so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki urls and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid url (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid url (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from url; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid url
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wikilinked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

]]

local function link_title_ok (link, lorig, title, torig)
local orig;

	if is_set (link) then 														-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		end
	end

	if is_set (orig) then
		table.insert( z.message_tail, { set_error( 'bad_paramlink', orig)});	-- url or wikilink in |title= with |title-link=;
	end
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the url into scheme and domain
portions, or for protocol relative (//example.com) urls, just the domain.  Use is_url() to validate the two
portions of the url.  If both are valid, or for protocol relative if domain is valid, return true, else false.

Because it is different from a standard url, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper url
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from url;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a url.  The test will also find external wikilinks
that use protocol relative urls. Also finds bare urls.

The frontier pattern prevents a match on interwiki links which are similar to scheme:path urls.  The tests that
find bracketed urls are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol relative ext wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare url with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol relative bare url: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a url
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then												-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source, access)
	local error_str = &quot;&quot;;
	local domain;
	local path;
	local base_url;

	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the url into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['[']='%5b',[']']='%5d'});					-- replace '[' and ']' with their percent encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wikimarkup url

	if is_set (access) then														-- access level (subscription, registration, limited)
		base_url = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end
	
	return table.concat ({base_url, error_str});
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );	-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Replaces unicode quotemarks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc; not for book titles.

]=]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	local wl_type, label, link;

	wl_type, label, link = is_wikilink (str);									-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = substitute (cfg.presentation['kern-wl-both'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = substitute (cfg.presentation['kern-wl-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = substitute (cfg.presentation['kern-wl-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label= mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label= mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap, cap2 = mw.ustring.match (label, &quot;^([\&quot;\'])([^\'].+)&quot;);				-- match leading double or single quote but not doubled single quotes (italic markup)
		if is_set (cap) then
			label = substitute (cfg.presentation['kern-left'], {cap, cap2});
		end
	
		cap, cap2 = mw.ustring.match (label, &quot;^(.+[^\'])([\&quot;\'])$&quot;)				-- match trailing double or single quote but not doubled single quotes (italic markup)
		if is_set (cap) then
			label = substitute (cfg.presentation['kern-right'], {cap, cap2});
		end
		
		if 2 == wl_type then
			str = make_wikilink (link, label);									-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title=, |script-chapter=, |script-&lt;periodical&gt;=

]]

local function format_script_value (script_value, script_param)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			table.insert( z.message_tail, { set_error( 'script_parameter', {script_param, 'missing title part'}, true ) } );		-- prefix without 'title'; add error message
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_code_remap[lang] or mw.language.fetchLanguageName( lang, &quot;en&quot; );	-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, cfg.script_lang_codes) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				table.insert( z.message_tail, { set_error( 'script_parameter', {script_param, 'unknown language code'}, true ) } );	-- unknown script-language; add error message
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			table.insert( z.message_tail, { set_error( 'script_parameter', {script_param, 'invalid language code'}, true ) } );		-- invalid language code; add error message
			lang = '';															-- invalid so set lang to empty string
		end
	else
		table.insert( z.message_tail, { set_error( 'script_parameter', {script_param, 'missing prefix'}, true ) } );				-- no language code prefix; add error message
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script, script_param)
	if is_set (script) then
		script = format_script_value (script, script_param);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return substitute( msg, str );											-- including template text
	else
		return substitute( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;----------------------------------------

makes a wikisource url from wikisource interwiki link.  returns the url and appropriate label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;

	wl_type, D, L = is_wikilink (str);											-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if is_set (str) then
			ws_url = table.concat ({											-- build a wikisource url
				'https://en.wikisource.org/wiki/',								-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the url
		end
	elseif 1 == wl_type then														-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if is_set (str) then
			ws_url = table.concat ({											-- build a wikisource url
				'https://en.wikisource.org/wiki/',								-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the url
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a wikisource url
				'https://en.wikisource.org/wiki/',								-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end
	
	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable url
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent encoding of anchor
	end

	return ws_url, ws_label, L or D;											-- return proper url or nil and a label or nil
end


--[[--------------------------&lt; F O R M A T _ P E R I O D I C A L &gt;--------------------------------------------

Format the four periodical parameters: |script-&lt;periodical&gt;=, |&lt;periodical&gt;=, and |trans-&lt;periodical&gt;= into a single Periodical meta-
parameter.

]]

local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)
	local periodical_error = '';

	if not is_set (periodical) then
		periodical = '';														-- to be safe for concatenation
	else
		periodical = wrap_style ('italic-title', periodical);					-- style 
	end

	periodical = script_concatenate (periodical, script_periodical, script_periodical_source);	-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (trans_periodical) then
		trans_periodical = wrap_style ('trans-italic-title', trans_periodical);
		if is_set (periodical) then
			periodical = periodical ..  ' ' .. trans_periodical;
		else																	-- here when transchapter without chapter or script-chapter
			periodical = trans_periodical;
			periodical_error = ' ' .. set_error ('trans_missing_title', {'periodical'});
		end
	end

	return periodical .. periodical_error;
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (scriptchapter, script_chapter_source, chapter, transchapter, chapterurl, chapter_url_source, no_quotes, access)
	local chapter_error = '';

	local ws_url, ws_label, L = wikisource_url_make (chapter);					-- make a wikisource url and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', '');										-- replace underscore separaters with space characters
		chapter = ws_label;
	end

	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
			chapter = wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, scriptchapter, script_chapter_source);	-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (chapterurl) then
		chapter = external_link (chapterurl, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');	-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if is_set (transchapter) then
		transchapter = wrap_style ('trans-quoted-title', transchapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. transchapter;
		else																	-- here when transchapter without chapter or script-chapter
			chapter = transchapter;
			chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
		end
	end

--	if is_set (chapterurl) then
--		chapter = external_link (chapterurl, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
--	end

	return chapter .. chapter_error;
end


--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i=1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- Test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position and (char == 'zero width joiner') then						-- if we found a zero width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- its ok if one of the indic scripts
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { set_error( 'invisible_char', {err_msg, wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i=i+1;																	-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] .. ': ' .. k);
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash under certain conditions.  The hyphen must separate like items; unlike items are
returned unmodified.  These forms are modified:
	letter - letter (A - B)
	digit - digit (4-5)
	digit separator digit - digit separator digit (4.1-4.5 or 4-1-4-5)
	letterdigit - letterdigit (A1-A5) (an optional separator between letter and digit is supported – a.1-a.5 or a-1-a-5)
	digitletter - digitletter (5a - 5d) (an optional separator between letter and digit is supported – 5.a-5.d or 5-a-5-d)

any other forms are returned unmodified.

str may be a comma- or semicolon-separated list

]]

local function hyphen_to_dash( str )
	if not is_set (str) then
		return str;
	end
	
	str, count = str:gsub ('^%(%((.+)%)%)$', '%1');								-- remove accept-this-as-written markup when it wraps all of str
	if 0 ~= count then															-- non-zero when markup removed; zero else
		return str;																-- nothing to do, we're done
	end
	
	str = str:gsub ('&amp;[nm]dash;', {['&amp;ndash;'] = '–', ['&amp;mdash;'] = '—'});		-- replace &amp;mdash; and &amp;ndash; entities  with their characters; semicolon mucks up the text.split
	
	local out = {};
	local list = mw.text.split (str, '%s*[,;]%s*');								-- split str at comma or semicolon separators if there are any

	for _, item in ipairs (list) do												-- for each item in the list
		if mw.ustring.match (item, '^%w*[%.%-]?%w+%s*[%-–—]%s*%w*[%.%-]?%w+$') then	-- if a hyphenated range or has endash or emdash separators
			if item:match ('%a+[%.%-]?%d+%s*%-%s*%a+[%.%-]?%d+') or				-- letterdigit hyphen letterdigit (optional separator between letter and digit)
				item:match ('%d+[%.%-]?%a+%s*%-%s*%d+[%.%-]?%a+') or			-- digitletter hyphen digitletter (optional separator between digit and letter)
				item:match ('%d+[%.%-]%d+%s*%-%s*%d+[%.%-]%d+') or				-- digit separator digit hyphen digit separator digit
				item:match ('%d+%s*%-%s*%d+') or								-- digit hyphen digit
				item:match ('%a+%s*%-%s*%a+') then								-- letter hyphen letter
					item = item:gsub ('(%w*[%.%-]?%w+)%s*%-%s*(%w*[%.%-]?%w+)', '%1–%2');	-- replace hyphen, remove extraneous space characters
			else
				item = mw.ustring.gsub (item, '%s*[–—]%s*', '–');				-- for endash or emdash separated ranges, replace em with en, remove extraneous white space
			end
		end
		item = item:gsub ('^%(%((.+)%)%)$', '%1');								-- remove the accept-this-as-written markup
		table.insert (out, item);												-- add the (possibly modified) item to the output table
	end

	return table.concat (out, ', ');											-- concatenate the output table into a comma separated string
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'dupicate character'
		if 1 == #duplicate_char then											-- for single byte ascii characters use the string library functions
			f.gsub=string.gsub
			f.match=string.match
			f.sub=string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub=mw.ustring.gsub
			f.match=mw.ustring.match
			f.sub=mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1,1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = f.sub(str, -1,-1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if f.sub(str, -3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5,-1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4,-1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if f.sub(str, -3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3,-1) == duplicate_char .. '&quot;]' then		-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2,-1) == duplicate_char .. &quot;]&quot; then		-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4,-1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2,-1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows html markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;------------------------------------------------------------

returns true is suffix is properly formed Jr, Sr, or ordinal in the range 2–9.  Puncutation not allowed.

]]

local function is_suffix (suffix)
	if in_array (suffix, {'Jr', 'Sr', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written ouside of the code editor and pasted here because the code editor gets confused between character insertion point and cursor position.
The test has been rewritten to use decimal character escape sequence for the individual bytes of the unicode characters so that it is not necessary
to use an external editor to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first)
	local first, suffix = first:match ('(.-),?%s*([%dJS][%drndth]+)%.?$') or first;	-- if first has something that looks like a generational suffix, get it

	if is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error ('suffix');
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error ('non-Latin character');
			return false;														-- not a string of latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just intials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error ('suffix');									-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word


	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i],1,1));				-- insert the intial at end of initials table
		end
		i = i+1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between authors is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between authors is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = make_wikilink (person.link, one);						-- link author/editor if this page is not the author's/editor's page
				end
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end


--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]
local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of name parameters (author, editor, etc) for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the associated |display-&lt;names&gt;=etal parameter

]]

local function name_has_etal (name, etal, nocat, param)

	if is_set (name) then														-- name can be nil in which case just return
		local patterns = cfg.et_al_patterns;									--get patterns from configuration
		
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns
			if name:match (pattern) then										-- if this 'et al' pattern is found in name
				name = name:gsub (pattern, '');									-- remove the offending text
				etal = true;													-- set flag (may have been set previously here or by |display-&lt;names&gt;=etal)
				if not nocat then												-- no categorization for |vauthors=
					table.insert( z.message_tail, {set_error ('etal', {param})});	-- and set an error if not added
				end
			end
		end
	end

	return name, etal;															-- 
end


--[[--------------------------&lt; N A M E _ H A S _ E D _ M A R K U P &gt;------------------------------------------

Evaluates the content of author and editor parameters for extranious editor annotations: ed, ed., eds, (Ed.), etc.
These annotation do not belong in author parameters and are redundant in editor parameters.  If found, the function
adds the editor markup maintenance category.

]]

local function name_has_ed_markup (name, list_name)
	local _, pattern;
	local patterns = cfg.editor_markup_patterns;								-- get patterns from configuration

	if is_set (name) then
		for _, pattern in ipairs (patterns) do									-- spin through patterns table and
			if name:match (pattern) then
				add_maint_cat ('extra_text_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
				break;
			end
		end
	end
	return name;																-- and done
end


--[[--------------------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;----------------------------------------

Evaluates the content of author and editor (surnames only) parameters for multiple names.  Multiple names are
indicated if there is more than one comma and or semicolon.  If found, the function adds the multiple name
(author or editor) maintenance category.

]]

local function name_has_mult_names (name, list_name)
local count, _;
	if is_set (name) then
		_, count = name:gsub ('[;,]', '');										-- count the number of separator-like characters
		
		if 1 &lt; count then														-- param could be |author= or |editor= so one separator character is acceptable
			add_maint_cat ('mult_names', cfg.special_case_translation [list_name]);	-- more than one separator indicates multiple names so add a maint cat for this template
		end
	end
	return name;																-- and done
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------
This function calls various name checking functions used to validate the content of the various name-holding
parameters.

]]

local function name_checks (last, first, list_name)
	if is_set (last) then
		if last:match ('^%(%(.*%)%)$') then										-- if wrapped in doubled parentheses, accept as written 
			last = last:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			last = name_has_mult_names (last, list_name);						-- check for multiple names in the parameter (last only)
			last = name_has_ed_markup (last, list_name);						-- check for extraneous 'editor' annotation
		end
	end
	if is_set (first) then
		if first:match ('^%(%(.*%)%)$') then									-- if wrapped in doubled parentheses, accept as written 
			first = first:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			first = name_has_ed_markup (first, list_name);						-- check for extraneous 'editor' annotation
		end
	end
	return last, first;															-- done
	end


--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local last_alias, first_alias;												-- selected parameter aliases used in error messaging
	while true do
		last, last_alias = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first, first_alias = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.
		last, first= name_checks (last, first, list_name);						-- multiple names, extraneous annotation, etc checks
		
		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {first_alias, first_alias:gsub('first', 'last')}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			link_title_ok (link, list_name:match (&quot;(%w+)List&quot;):lower() .. '-link' .. i, last, list_name:match (&quot;(%w+)List&quot;):lower() .. '-last' .. i);	-- check for improper wikimarkup

			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {list_name:match (&quot;(%w+)List&quot;):lower(), i-1}, true ) } );	-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because case of the source may be incorrect
or different from the case that WikiMedia uses, the name comparisons are done in lower case and when a match is
found, the Wikimedia version (assumed to be correct) is returned along with the code.  When there is no match, we
return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') returns a list of languages that in some cases may include
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.  Most (all?) of these languages are not used a 'language' codes per se, rather they
are used as sub-domain names: cbk-zam.wikipedia.org.  A list of language names and codes supported by fetchLanguageNames()
can be found at Template:Citation Style documentation/language/doc

Names that are included in the list will be found if that name is provided in the |language= parameter.  For example,
if |language=Chavacano de Zamboanga, that name will be found with the associated code 'cbk-zam'.  When names are found
and the associated code is not two or three characters, this function returns only the WikiMedia language name.

Some language names have multiple entries under different codes:
	Aromanian has code rup and code roa-rup
When this occurs, this function returns the language name and the 2- or 3-character code

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	if cfg.lang_name_remap[lang:lower()] then									-- if there is a remapped name (because MediaWiki uses something that we don't think is correct)
		return cfg.lang_name_remap[lang:lower()][1], cfg.lang_name_remap[lang:lower()][2];	-- for this language 'name', return a possibly new name and appropriate code
	end

	local ietf_code;															-- because some languages have both ietf-like codes and iso 639-like codes
	local ietf_name;
	
	local languages = mw.language.fetchLanguageNames(this_wiki_code, 'all')		-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons

	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 == code:len() or 3 == code:len() then							-- two- or three-character codes only; extensions not supported
				return name, code;												-- so return the name and the code
			end
			ietf_code = code;													-- remember that we found an ietf-like code and save its name
			ietf_name = name;													-- but keep looking for a 2- or 3-char code
		end
	end
																				-- didn't find name with 2- or 3-char code; if ietf-like code found return
	return ietf_code and ietf_name or lang;										-- associated name; return original language text else
end


--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code is recognized by MediaWiki,
use the returned name; if not, then use the value that was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is assigned to the category for
that code: Category:Norwegian-language sources (no).  For valid three-character code languages, the page is assigned
to the single category for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does not recognize three-character
equivalents of two-character codes: code 'ar' is recognized bit code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are
separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki = mw.getContentLanguage();									-- get a language object for this wiki
	local this_wiki_code = this_wiki:getCode()									-- get this wiki's language code
	local this_wiki_name = mw.language.fetchLanguageName(this_wiki_code, this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang
		name = cfg.lang_code_remap[lang:lower()];								-- first see if this is a code that is not supported by MediaWiki but is in remap

		if name then															-- there was a remapped code so
			lang = lang:gsub ('^(%a%a%a?)%-.*', '%1');							-- strip ietf tags from code
		else
			if lang:match ('^%a%a%-') then										-- strip ietf tags from code; TODO: is there a need to support 3-char with tag?
				lang = lang:match ('(%a%a)%-')									-- keep only 639-1 code portion to lang; TODO: do something with 3166 alpha 2 country code?
			end
			if 2 == lang:len() or 3 == lang:len() then							-- if two-or three-character code
				name = mw.language.fetchLanguageName (lang:lower(), this_wiki_code);	-- get language name if |language= is a proper code
			end
		end

		if is_set (name) then													-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, this_wiki_code);				-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then													-- only 2- or 3-character codes
			name = cfg.lang_code_remap[code] or name;							-- override wikimedia when they misuse language codes/names

			if this_wiki_code ~= code then										-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					add_prop_cat ('foreign_lang_source' .. code, {name, code})	-- categorize it
				else															-- or is a recognized language (but has a three-character code)
					add_prop_cat ('foreign_lang_source_2' .. code, {code})		-- categorize it differently TODO: support mutliple three-character code categories per cs1|2 template
				end
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, cfg.messages['parameter-pair-separator'])		-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		name = table.concat (language_list, ', ');											-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
		name = name:gsub (', ([^,]+)$', cfg.messages['parameter-final-separator'] .. '%1');	-- replace last '&lt;comma&gt;&lt;space&gt;' separator with '&lt;comma&gt;&lt;space&gt;and&lt;space&gt;' separator
	end
	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings
At en.wiki, for cs1:
	ps gets:	'.'
	sep gets:	'.'

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = cfg.presentation['ps_cs1'];										-- terminate the rendered citation
	end
	return cfg.presentation['sep_cs1'], ps;										-- element separator
end


--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings
At en.wiki, for cs2:
	ps gets:	'' (empty string - no terminal punctuation)
	sep gets:	','

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = cfg.presentation['ps_cs2'];										-- terminate the rendered citation
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return cfg.presentation['sep_cs2'], ps, ref;								-- element separator
end


--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end


--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end


--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or
		url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
		url:match ('%.PDF&amp;#035') or url:match ('%.pdf&amp;#035');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parentheses, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[--------------------------&lt; G E T _ D I S P L A Y _ N A M E S &gt;--------------------------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_names (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_name', cfg.special_case_translation [list_name]);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parnetheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a place holder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parens
			local name = name_table[i];
			i=i+1;																-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parens
					break;														-- and done reassembling so
				end
				i=i+1;															-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = is_wikilink (name_table[i]);					-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i+1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parentheses to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')								-- remove doubled parntheses
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error ('punctuation');
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
			if is_suffix (first) then											-- if a valid suffix
				suffix = first													-- save it as a suffix and
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end																	-- no suffix error message here because letter combination may be result of Romanization; check for digits?
			last = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error ('missing comma');								-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error ('name');										-- matches a space between two intiials
			end
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error ('initials');									-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first);									-- check first and last before restoring the suffix which may have a non-Latin digit
			if is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '');
			end
		end

		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ) or v_link_table[i];
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice incase we have a |first1= without a |last1=; this ...
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or	-- ... also catches the case where |first= is used with |vauthors=
		select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, no, etc).  When the parameter value has not been assigned a value (missing or empty
in the source template) the function returns true.  If the parameter value is one of the list of allowed values returns
true; else, emits an error message and returns false.

]]

local function is_valid_parameter_value (value, name, possible)
	if not is_set (value) then
		return true;															-- an empty parameter is ok
	elseif in_array (value, possible) then
		return true;
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return false
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list,-3,-1) == sepc .. '. ') then						-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list,-1,-1) == sepc) or (string.sub (name_list,-3,-1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terninate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not is_set (volume) and not is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end

	local vol = '';																-- here for all cites except magazine
		
	if is_set (volume) then
		if volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$')then			-- volume value is all digits or all uppercase roman numerals
			vol = substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});	-- render in bold face
		elseif (4 &lt; mw.ustring.len(volume)) then								-- not all digits or roman numerals and longer than 4 characters
			vol = substitute (cfg.messages['j-vol'], {sepc, volume});			-- not bold
			add_prop_cat ('long_vol');
		else																	-- four or less characters
			vol = substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});	-- bold
		end
	end
	if is_set (issue) then
		return vol .. substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if is_set (page) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif is_set(pages) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then							-- if pages is only digits, assume a single page number
			return '', substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to wikisource, returns the label portion of the interwikilink as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki link to and external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, pages, at)
	local ws_url, ws_label, coins_pages, L;										-- for wikisource interwikilinks; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if is_set (page) then
		if is_set (pages) or is_set(at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws url from |page= interwiki link; link portion L becomes tool tip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif is_set (pages) then
		if is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws url from |pages= interwiki link; link portion L becomes tool tip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws url from |at= interwiki link; link portion L becomes tool tip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end



--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org urls to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot url or to calendar pages.  When the archive url is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the url.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org url does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command url
	|archive-url= is an archive.org url that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org urls:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this funct may return a modified
archive url:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the url unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.or url
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine url
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command url, we don't want to allow saving of the target page 
		err_msg = 'save command';
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = 'liveweb';
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');	-- split out some of the url parts for evaluation
		
		if not is_set(timestamp) or 14 ~= timestamp:len() then					-- path and flag optional, must have 14-digit timestamp here
			err_msg = 'timestamp';
			if '*' ~= flag then
				url=url:gsub ('(//web%.archive%.org/[^%d]*%d?%d?%d?%d?%d?%d?)[^/]*', '%1*', 1)	-- for preview, modify ts to be yearmo* max (0-6 digits plus splat)
			end
		elseif is_set(path) and 'web/' ~= path then								-- older archive urls do not have the extra 'web/' path element
			err_msg = 'path';
		elseif is_set (flag) and not is_set (path) then							-- flag not allowed with the old form url (without the 'web/' path element)
			err_msg = 'flag';
		elseif is_set (flag) and not flag:match ('%a%a_') then					-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = 'flag';
		else
			return url, date;													-- return archiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	table.insert( z.message_tail, { set_error( 'archive_url', {err_msg}, true ) } );	-- add error message and
	if is_set (Frame:preprocess('{{REVISIONID}}')) then
		return '', '';															-- return empty strings for archiveURL and ArchiveDate
	else
		return url, date;														-- preview mode so return archiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

-- set default parameter values defined by |mode= parameter.
	local Mode = A['Mode'];
	if not is_valid_parameter_value (Mode, 'mode', cfg.keywords['mode']) then
		Mode = '';
	end

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListFormat = A['NameListFormat'];
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				add_maint_cat ('authors');										-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
			add_maint_cat ('editors');											-- but add a maint cat because use of this parameter is discouraged
		end
	end

	local translator_etal;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=

	local interviewer_etal;
	local interviewers_list = {};												
	local Interviewers;															-- used later
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters

	local contributor_etal;
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list
	local Contribution = A['Contribution'];
	if in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not is_set (Contribution) then									-- |contributor= requires |contribution=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if select_one (args, cfg.aliases['ContributorList-Last'], 'redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { set_error( 'contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if not is_valid_parameter_value (NameListFormat, 'name-list-format', cfg.keywords['name-list-format']) then	-- only accepted value for this parameter is 'vanc'
		NameListFormat = '';													-- anything else, set to empty string
	end

	if is_set (Others) then
		if 0 == #a and 0 == #e then												-- add maint cat when |others= has value and used without |author=, |editor=
			add_maint_cat ('others');
		end
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
			link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wikimarkup in |title-link= or wikimarkup in |title= when |title-link= is set

	local Chapter = A['Chapter'];
	local ScriptChapter = A['ScriptChapter'];
	local ScriptChapterOrigin = A:ORIGIN ('ScriptChapter');
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];

	local ArchiveDate;
	local ArchiveURL;

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	
	local UrlStatus = A['UrlStatus'];
	if 'url-status' == A:ORIGIN ('UrlStatus') then								-- interim: TODO: this line goes away
		if not is_valid_parameter_value (UrlStatus, 'url-status', cfg.keywords ['url-status']) then	-- set in config.defaults to 'dead'
			UrlStatus = '';														-- anything else, set to empty string
		end																		-- interim: TODO: this line goes away
	elseif is_set (A:ORIGIN ('UrlStatus')) then									-- interim: while both |dead-url= and |url-status= allowed use separate keyword lists; TODO: remove this section
		if not is_valid_parameter_value (UrlStatus, A:ORIGIN ('UrlStatus'), cfg.keywords ['deadurl']) then	-- interim: assume |dead-url=; use those keywords; TODO: this line goes away
			UrlStatus = '';														-- anything else, set to empty string; interim: TODO: this line goes away
		end																		-- interim: TODO: this line goes away
	end																			-- interim: TODO: this line goes away
	
	if in_array (UrlStatus, {'yes', 'true', 'y'}) then							-- TODO: remove this whole thing when |dead-url=[yes|no] parameters removed from articles
		UrlStatus = 'dead';
	elseif 'no' == UrlStatus then
		UrlStatus = 'live';
	end
	
	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];
	local Periodical_origin = '';
		if is_set (Periodical) then
			Periodical_origin = A:ORIGIN('Periodical');							-- get the name of the periodical parameter
			local i;
			Periodical, i = strip_apostrophe_markup (Periodical);				-- strip appostrophe markup so that metadata isn't contaminated 
			if i then															-- non-zero when markup was stripped so emit an error message
				table.insert( z.message_tail, {set_error ('apostrophe_markup', {Periodical_origin}, true)});
			end
		end

	local ScriptPeriodical = A['ScriptPeriodical'];
	local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');
																				-- web and news not tested for now because of 
																				-- Wikipedia:Administrators%27_noticeboard#Is_there_a_semi-automated_tool_that_could_fix_these_annoying_&quot;Cite_Web&quot;_errors?
		if not (is_set (Periodical) or is_set (ScriptPeriodical)) then			-- 'periodical' templates require periodical parameter
--			local p = {['journal'] = 'journal', ['magazine'] = 'magazine', ['news'] = 'newspaper', ['web'] = 'website'};	-- for error message
			local p = {['journal'] = 'journal', ['magazine'] = 'magazine'};		-- for error message
			if p[config.CitationClass]  then
				table.insert( z.message_tail, {set_error ('missing_periodical', {config.CitationClass, p[config.CitationClass]}, true)});
			end
		end

	local TransPeriodical =  A['TransPeriodical'];

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if 'citation' == config.CitationClass then
		if is_set (Periodical) then
			if not in_array (Periodical_origin, {'website', 'mailinglist'}) then	-- {{citation}} does not render volume for these 'periodicals'
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		elseif is_set (ScriptPeriodical) then
			if 'script-website' ~= ScriptPeriodical_origin then					-- {{citation}} does not render volume for |script-website=
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		else
			Volume = A['Volume'];												-- and does for non-'periodical' cites
		end
	elseif in_array (config.CitationClass, cfg.templates_using_volume) then		-- render |volume= for cs1 according to the configuration settings
		Volume = A['Volume'];
	end	

	if 'citation' == config.CitationClass then
		if is_set (Periodical) and in_array (Periodical_origin, {'journal', 'magazine', 'newspaper', 'periodical', 'work'}) or	-- {{citation}} renders issue for these 'periodicals'
			is_set (ScriptPeriodical) and in_array (ScriptPeriodical_origin, {'script-journal', 'script-magazine', 'script-newspaper', 'script-periodical', 'script-work'}) then -- and these 'script-periodicals'
				Issue = hyphen_to_dash (A['Issue']);
		end
	elseif in_array (config.CitationClass, cfg.templates_using_issue) then		-- conference &amp; map books do not support issue; {{citation}} listed here because included in settings table
		if not (in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (is_set (Periodical) or is_set (ScriptPeriodical))) then
			Issue = hyphen_to_dash (A['Issue']);
		end
	end

	local Position = '';
	if not in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash (A['Pages']);	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = A['PublicationPlace']
	local Place = A['Place'];
	
	local PublisherName = A['PublisherName'];
	local PublisherName_origin = A:ORIGIN('PublisherName');
		if is_set (PublisherName) then
			local i=0;
			PublisherName, i = strip_apostrophe_markup (PublisherName);			-- strip appostrophe markup so that metadata isn't contaminated; publisher is never italicized

			if i then															-- non-zero when markup was stripped so emit an error message
				table.insert( z.message_tail, {set_error ('apostrophe_markup', {PublisherName_origin}, true)});
			end
		end

	local RegistrationRequired = A['RegistrationRequired'];
		if not is_valid_parameter_value (RegistrationRequired, 'registration', cfg.keywords ['yes_true_y']) then
			RegistrationRequired=nil;
		end

	local SubscriptionRequired = A['SubscriptionRequired'];
		if not is_valid_parameter_value (SubscriptionRequired, 'subscription', cfg.keywords ['yes_true_y']) then
			SubscriptionRequired=nil;
		end

	local UrlAccess = A['UrlAccess'];
		if not is_valid_parameter_value (UrlAccess, 'url-access', cfg.keywords ['url-access']) then
			UrlAccess = nil;
		end
		if not is_set(URL) and is_set(UrlAccess) then
			UrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {'url'}, true ) } );
		end
		
		if is_set (UrlAccess) and is_set (SubscriptionRequired) then			-- while not aliases, these are much the same so if both are set
			table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'url-access') .. ' and ' .. wrap_style ('parameter', 'subscription')}, true ) } );		-- add error message
			SubscriptionRequired = nil;											-- unset; prefer |access= over |subscription=
		end
		if is_set (UrlAccess) and is_set (RegistrationRequired) then			-- these are not the same but contradictory so if both are set
			table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'url-access') .. ' and ' .. wrap_style ('parameter', 'registration')}, true ) } );		-- add error message
			RegistrationRequired = nil;											-- unset; prefer |access= over |registration=
		end

	local ChapterUrlAccess = A['ChapterUrlAccess'];
		if not is_valid_parameter_value (ChapterUrlAccess, A:ORIGIN('ChapterUrlAccess'), cfg.keywords ['url-access']) then	-- same as url-access
			ChapterUrlAccess = nil;
		end
		if not is_set(ChapterURL) and is_set(ChapterUrlAccess) then
			ChapterUrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {A:ORIGIN('ChapterUrlAccess'):gsub ('%-access', '')}, true ) } );
		end

	local MapUrlAccess = A['MapUrlAccess'];
		if not is_valid_parameter_value (MapUrlAccess, 'map-url-access', cfg.keywords ['url-access']) then
			MapUrlAccess = nil;
		end
		if not is_set(A['MapURL']) and is_set(MapUrlAccess) then
			MapUrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {'map-url'}, true ) } );
		end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local Agency = A['Agency'];

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = A['IgnoreISBN'];
		if not is_valid_parameter_value (IgnoreISBN, 'ignore-isbn-error', cfg.keywords ['yes_true_y']) then
			IgnoreISBN = nil;													-- anything else, set to empty string
		end
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );
		if is_set (DoiBroken) and not ID_list['DOI'] then
			table.insert( z.message_tail, { set_error( 'doibroken_missing_doi', A:ORIGIN('DoiBroken'))});
		end
	local ID_access_levels = extract_id_access_levels( args, ID_list );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = A['LastAuthorAmp'];
		if not is_valid_parameter_value (LastAuthorAmp, 'last-author-amp', cfg.keywords ['yes_true_y']) then
			LastAuthorAmp = nil;												-- set to empty string
		end

	local no_tracking_cats = A['NoTracking'];
		if not is_valid_parameter_value (no_tracking_cats, 'no-tracking', cfg.keywords ['yes_true_y']) then
			no_tracking_cats = nil;												-- set to empty string
		end

	--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = A['DF'];															-- date format set in cs1|2 template
	if not is_valid_parameter_value (DF, 'df', cfg.keywords['date-format']) then	-- validate reformatting keyword
		DF = '';																-- not valid, set to empty string
	end
	if not is_set (DF) then
		DF = cfg.global_df;
	end

	local sepc;																	-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );											-- used to control capitalization for certain static text

	--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

	-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	select_one( args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'redundant_parameters' );	-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, Pages, At);

	local NoPP = A['NoPP'] 
	if is_set (NoPP) and is_valid_parameter_value (NoPP, 'nopp', cfg.keywords ['yes_true_y']) then
		NoPP = true;
	else
		NoPP = nil;																-- unset, used as a flag later
	end

	if not is_set(PublicationPlace) and is_set(Place) then						-- both |publication-place= and |place= (|location=) allowed if different
		PublicationPlace = Place;												-- promote |place= (|location=) to |publication-place
	end
	
	if PublicationPlace == Place then Place = ''; end							-- don't need both if they are the same
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia and |title then map |title to |article and |encyclopedia to |title
		|encyclopedia and |article then map |encyclopedia to |title

		|trans-title maps to |trans-chapter when |title is re-mapped
		|url maps to |chapterurl when |title is remapped
	
	All other combinations of |encyclopedia, |title, and |article are not modified
	
	]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set (Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					ScriptChapterOrigin = 'title';
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterUrlAccess = UrlAccess;

					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter = make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			elseif is_set (Chapter) then										-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if is_set(A['Number']) then												-- cite techreport uses 'number', which other citations alias to 'issue'
			if not is_set(ID) then												-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', 'id') .. ' and ' .. wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

	-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	elseif 'mailinglist' == Periodical_origin then
		Periodical = '';														-- unset because mailing list is only used for cite mailing list
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		ChapterUrlAccess = MapUrlAccess;
		TransChapter = A['TransMap'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		ChapterFormat = A['MapFormat'];
		
		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];

		link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wikimarkup in |series-link= or wikimarkup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) and is_set (AirDate) then							-- promote airdate to date
			Date = AirDate;
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('seriesnum', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ScriptChapterOrigin = 'title';
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = make_wikilink (ChapterLink, Chapter);
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = make_wikilink (SeriesLink, Series);
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite ssrn}}, before generation of COinS data.
	do
		if in_array (config.CitationClass, {'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) then
			if not is_set (ID_list[config.CitationClass:upper()]) then			-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp; |citeseerx= required for their templates
				table.insert( z.message_tail, { set_error( config.CitationClass .. '_missing', {}, true ) } );	-- add error message
			end

			Periodical = ({['arxiv'] = 'arXiv', ['biorxiv'] = bioRxiv, ['citeseerx'] = 'CiteSeerX', ['ssrn'] = 'Social Science Research Network'})[config.CitationClass];
		end
	end

	-- handle type parameter for those CS1 citations that have default values
	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;interview&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
		TitleType = substitute( cfg.messages['type'], TitleType);				-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging

	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val=AccessDate, name=A:ORIGIN ('AccessDate')},
			['archive-date'] = {val=ArchiveDate, name=A:ORIGIN ('ArchiveDate')},
			['date'] = {val=Date, name=Date_origin},
			['doi-broken-date'] = {val=DoiBroken, name=A:ORIGIN ('DoiBroken')},
			['embargo'] = {val=Embargo, name=A:ORIGIN ('Embargo')},
			['lay-date'] = {val=LayDate, name=A:ORIGIN ('LayDate')},
			['publication-date'] ={val=PublicationDate, name=A:ORIGIN ('PublicationDate')},
			['year'] = {val=Year, name=A:ORIGIN ('Year')},
			};
		anchor_year, Embargo, error_message = dates(date_parameters_list, COinS_date);

-- start temporary Julian / Gregorian calendar uncertainty categorization
		if COinS_date.inter_cal_cat then
			add_prop_cat ('jul_greg_uncertainty');
		end
-- end temporary Julian / Gregorian calendar uncertainty categorization

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end
		
		if not is_set(error_message) then										-- error free dates only
			local modified = false;												-- flag
			
			if is_set (DF) then													-- if we need to reformat dates
				modified = reformat_dates (date_parameters_list, DF, false);	-- reformat to DF format, use long month names if appropriate
			end

			if true == date_hyphen_to_dash (date_parameters_list) then			-- convert hyphens to dashes where appropriate
				modified = true;
				add_maint_cat ('date_format');									-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language,
	-- uncomment these three lines.  Not supported by en.wiki (for obvious reasons)
	-- set date_name_xlate() second argument to true to translate English digits to local digits (will translate ymd dates)
--			if date_name_xlate (date_parameters_list, false) then
--				modified = true;
--			end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				LayDate = date_parameters_list['lay-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end
		else
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end
	end	-- end of do

	-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
	-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
			if is_set(AccessDate) then											-- access date requires |url=; pmc created url is not |url=
				table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
				AccessDate = '';												-- unset
			end

		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
			if 'episode' == config.CitationClass then							-- special case for cite episode; TODO: is there a better way to do this?
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
			else
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
			end
	end

	if 'none' == Title and
			in_array (config.CitationClass, {'journal', 'citation'}) and
			(is_set (Periodical) or is_set (ScriptPeriodical)) and
			('journal' == Periodical_origin or 'script-journal' == ScriptPeriodical_origin) then	-- special case for journal cites
				Title = '';														-- set title to empty string
				add_maint_cat ('untitled');
	end

	check_for_url ({															-- add error message when any of these parameters hold a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[Periodical_origin] = Periodical,
		[PublisherName_origin] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = strip_apostrophe_markup (Periodical),					-- no markup in the metadata
		['Encyclopedia'] = strip_apostrophe_markup (Encyclopedia),
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = coins_pages or get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,										-- any apostrophe markup already removed
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, and {{cite ssrn}} AFTER generation of COinS data.
	if in_array (config.CitationClass, {'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, CiteSeerX, or ssrn now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = substitute (cfg.messages['newsgroup'], external_link( 'news:' .. PublisherName, PublisherName, PublisherName_origin, nil ));
		end
	end

	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text,											-- get current page name so that we don't wikilink to it via editorlinkn
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_names (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if is_set (Editors) then
				Editors, editor_etal = name_has_etal (Editors, editor_etal, false, 'editors');	-- find and remove variations on et al.
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
					EditorCount = 2;											-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
				else
					EditorCount = 2;											-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
				end
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum , interviewer_etal = get_display_names (A['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal);
			Interviewers = list_people (control, interviewers_list, interviewer_etal);
		end
		do																		-- now do translators
			control.maximum , translator_etal = get_display_names (A['DisplayTranslators'], #t, 'translators', translator_etal);
			Translators = list_people (control, t, translator_etal);
		end
		do																		-- now do contributors
			control.maximum , contributor_etal = get_display_names (A['DisplayContributors'], #c, 'contributors', contributor_etal);
			Contributors = list_people (control, c, contributor_etal);
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_names (A['DisplayAuthors'], #a, 'authors', author_etal);

			last_first_list = list_people(control, a, author_etal);

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors');	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if is_set (Authors) and is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
	-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (is_set (Periodical) or is_set (ScriptPeriodical)) and not is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not is_set(URL) then
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) or		-- |url= required for cite web, cite podcast, and cite mailinglist
			('citation' == config.CitationClass and ('website' == Periodical_origin or 'script-website' == ScriptPeriodical_origin)) then	-- and required for {{citation}} with |website= or |script-website=
				table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURLorigin, OriginalFormat, OriginalAccess;
--	DeadURL = DeadURL:lower();													-- used later when assembling archived text
	UrlStatus = UrlStatus:lower();												-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (ChapterURL) then 											-- if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURLorigin = ChapterURLorigin;								-- name of chapter-url parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=
--			if 'no' ~= DeadURL then
			if 'live' ~= UrlStatus then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				ChapterURLorigin = A:ORIGIN('ArchiveURL')						-- name of archive-url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived urls
			end
		elseif is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURLorigin = URLorigin;										-- name of url parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;
--			if 'no' ~= DeadURL then												-- if URL set then archive-url applies to it
			if 'live' ~= UrlStatus then											-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived urls
			end
 		end
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and (is_set (Periodical) or is_set (ScriptPeriodical)) and not is_set (Encyclopedia)) then
			local chap_param;
			if is_set (Chapter) then											-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif is_set (ScriptChapter) then
				chap_param = ScriptChapterOrigin;
			else is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if is_set (chap_param) then											-- if we found one
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {chap_param}, true ) } );		-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if is_set (Contribution) and 0 &lt; #c then								-- if this is a contribution with contributor(s)
			if in_array (Contribution:lower(), cfg.keywords.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, ScriptChapterOrigin, Chapter, TransChapter, ChapterURL, ChapterURLorigin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter.. sepc .. ' ';
		elseif is_set (ChapterFormat) then										-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title.
	if is_set (ArchiveURL) and mw.ustring.match (mw.ustring.lower(Title), cfg.special_case_translation['archived_copy']) then	-- if title is 'Archived copy' (place holder added by bots that can't find proper title)
		add_maint_cat ('archived_copy');										-- add maintenance category before we modify the content of Title
	end

	if Title:match ('^%(%(.*%)%)$') then										-- if keep as written markup:
		Title= Title:gsub ('^%(%((.*)%)%)$', '%1')								-- remove the markup
	else
		if '...' == Title:sub (-3) then											-- if elipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%'..sepc..'$', '');				-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end
	end
	
	if in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (is_set (Periodical) or is_set (ScriptPeriodical)) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and (is_set (Periodical) or is_set (ScriptPeriodical))) then		-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle, 'script-title');	-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end

	if is_set(Title) then
		if not is_set (TitleLink) and is_set (URL) then
			Title = external_link (URL, Title, URLorigin, UrlAccess) .. TransTitle .. TransError .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif is_set (TitleLink) and not is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = make_wikilink (TitleLink, Title) .. TransTitle .. TransError;
			end
		else
			local ws_url, ws_label;
			ws_url, ws_label, L = wikisource_url_make (Title);					-- make ws url from |title= interwiki link; link portion L becomes tool tip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = Title .. TransTitle .. TransError;
			end
		end
	else
		Title = TransTitle .. TransError;
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURLorigin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin, nil );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if is_set(Minutes) then
			if is_set (Time) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'minutes') .. ' and ' .. wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = is_set (Series) and wrap_msg ('series', {sepc, Series}) or &quot;&quot;;		-- not the same as SeriesNum
	OrigYear = is_set (OrigYear) and wrap_msg ('origyear', OrigYear) or '';
	Agency = is_set (Agency) and wrap_msg ('agency', {sepc, Agency}) or &quot;&quot;;
	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	Via = is_set (Via) and  wrap_msg ('via', Via) or '';

	--[[
	Subscription implies paywall; Registration does not.  If both are used in a citation, the subscription required link
	note is displayed. There are no error messages for this condition.
	
	]]
	if is_set (SubscriptionRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['subscription'];		-- subscription required message
	elseif is_set (RegistrationRequired) then
		SubscriptionRequired = sepc .. &quot; &quot; .. cfg.messages['registration'];		-- registration required message
	else
		SubscriptionRequired = '';												-- either or both might be set to something other than yes true y
	end

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text

		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {IdAccessLevels=ID_access_levels, DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin, UrlAccess );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then				-- if first and last characters of quote are quote marks
			Quote = Quote:sub(2,-2);											-- strip them off
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;live&quot; == UrlStatus then
			local arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-live'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil ) .. ArchiveFormat, ArchiveDate } );
			if not is_set(OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- UrlStatus is empty, 'dead', 'unfit', 'usurped', 'bot: unknown'
			local arch_text = cfg.messages['archived-dead'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if in_array (UrlStatus, {'unfit', 'usurped', 'bot: unknown'}) then
				Archived = sepc .. &quot; &quot; .. 'Archived from the original on ' .. ArchiveDate;	-- format already styled
				if 'bot: unknown' == UrlStatus then
					add_maint_cat ('bot:_unknown');								-- and add a category if not already added
				else
					add_maint_cat ('unfit');									-- and add a category if not already added
				end
			else																-- UrlStatus is empty, 'dead'
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURLorigin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else
			local arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURLorigin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin, nil );
	end

	local Publisher;
	if is_set(PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if is_set(PublisherName) then
		if is_set(PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif is_set(PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if (is_set (Periodical) or is_set (ScriptPeriodical) or is_set (TransPeriodical)) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical);
		else 
			Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical);
		end
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then									-- cite speech only
		TitleNote = &quot; (Speech)&quot;;												-- annotate the citation
		if is_set (Periodical) then												-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then											-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;							-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = safe_join ({Others, sepc .. &quot; &quot;}, sepc) end		-- add terminal punctuation &amp; space; check for dup sepc; TODO why do we need to do this here?
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(Periodical) then		-- special cases for book cites
		if is_set (Contributors) then											-- when we are citing foreword, preface, introduction, etc
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon;
	if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then	-- special case for cite AV media &amp; cite episode position transcript
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	else
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, SubscriptionRequired, Lay, Quote }, sepc );
	end
	
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if is_set(Date) then
		if is_set (Authors) or is_set (Editors) then							-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;;				-- in paranetheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon,-1,-1) == sepc) then							-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigYear;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigYear;							-- Date begins with sepc
			end
		end
	end	
	if is_set(Authors) then
		if (not is_set (Date)) then												-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then
					in_text = in_text:lower()									-- lowercase for cs2
				end
			end
			if EditorCount &lt;= 1 then
				post_text = &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot;;				-- be consistent with no-author, no-date case
			else
				post_text = &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot;;
			end
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if is_set (Contributors) then											-- book cite and we're citing the intro, preface, etc
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if is_set (Editors) and is_set (Date) then							-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not is_set (Date)) then											-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc ); 								--Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = config.CitationClass;
		options.class = &quot;citation &quot; .. config.CitationClass;					-- class=citation required for blue highlight when used with |ref=
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then								-- set reference anchor if appropriate
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			if #namelist &gt; 0 then												-- if there are names in namelist
				id = anchor_id (namelist, year);								-- go make the CITEREF anchor
			else
				id = '';														-- unset
			end
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;(.-)&lt;/span&gt;&quot;, &quot;%1&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then	-- remove &lt;span&gt; tags and other html-like markup; then get length of what remains
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	local render = {};															-- here we collect the final bits for concatenation into the rendered citation

	if is_set(options.id) then													-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render, substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text}));	-- when |ref= is set
	else
		table.insert (render, substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text}));	-- all other cases
	end		

	table.insert (render, substitute (cfg.presentation['ocins'], {OCinSoutput}));	-- append metadata to the citation

	if 0 ~= #z.message_tail then
		table.insert (render, ' ');
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					table.insert (render, error_comment( v[1], v[2] ));
				else
					table.insert (render, error_comment( v[1] .. &quot;; &quot;, v[2] ));
				end
			end
		end
	end

	if 0 ~= #z.maintenance_cats then
		local maint_msgs = {};													-- here we collect all of the maint messages
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			local maint = {};													-- here we assemble a maintenence message
			table.insert (maint, v);											-- maint msg is the category name
			table.insert (maint, ' (');											-- open the link text
			table.insert (maint, make_wikilink (':Category:' .. v, 'link'));	-- add the link
			table.insert (maint, ')');											-- and close it
			table.insert (maint_msgs, table.concat (maint));					-- assemble new maint message and add it to the maint_msgs table
		end
		table.insert (render, substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs, ' ')));	-- wrap the group of maint message with proper presentation and save
	end
	
	no_tracking_cats = no_tracking_cats:lower();
	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
		for _, v in ipairs( z.error_categories ) do
			table.insert (render, make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			table.insert (render, make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.properties_cats ) do								-- append properties categories
			table.insert (render, make_wikilink ('Category:' .. v));
		end
	end

	return table.concat (render);	
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class)
	local name = tostring (name);
	local state;
	
	if in_array (cite_class, {'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) then	-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[name];
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end

		state = whitelist[cite_class .. '_basic_arguments'][name];				-- look in the parameter-list for the template identified by cite_class

		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
																				-- limited enumerated parameters list
		name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
		state = whitelist.limited_numbered_arguments[name];
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates
		
	state = whitelist.basic_arguments[name];									-- all other templates; all normal parameters allowed
											
	if true == state then return true; end										-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);											-- parameter is deprecated but still supported
		return true;
	end
																				-- all enumerated parameters allowed
	name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );												-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
	state = whitelist.numbered_arguments[name];

	if true == state then return true; end										-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);											-- parameter is deprecated but still supported
		return true;
	end
	
	return false;																-- not supported because not found or name is set to nil
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe:
	{{cite ... |title=Title access-date=2016-03-17}}

cs1|2 shares some parameter names with xml/html atributes: class=, title=, etc.  To prevent false positives xml/html
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (parameter, value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove xml/html tags because attributes: class=, title=, etc 

	capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then								-- if the capture is a valid parameter name
		table.insert( z.message_tail, {set_error ('missing_pipe',parameter)});
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ P U N C T &gt;--------------------------------------

look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_punc (param, value)
	if cfg.punct_skip[param] then
		return;																	-- parameter name found in the skip table so done
	end
	
	if value:match ('[,;:]$') then
		add_maint_cat ('extra_punct');											-- has extraneous punctuation; add maint cat
	end
end


--[[--------------------------&lt; C I T A T I O N &gt;--------------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

local function citation(frame)
	Frame = frame;																-- save a copy incase we need to display an error message in preview mode
	local pframe = frame:getParent()
	local validation, utilities, identifiers, metadata, styles;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		styles = 'Module:Citation/CS1/sandbox/styles.css';
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
		styles = 'Module:Citation/CS1/styles.css';

	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	dates = validation.dates;													-- imported functions from Module:Citation/CS1/Date validation
	year_date_check = validation.year_date_check;
	reformat_dates = validation.reformat_dates;
	date_hyphen_to_dash = validation.date_hyphen_to_dash;
	date_name_xlate = validation.date_name_xlate;

	is_set = utilities.is_set;													-- imported functions from Module:Citation/CS1/Utilities
	in_array = utilities.in_array;
	substitute = utilities.substitute;
	error_comment = utilities.error_comment;
	set_error = utilities.set_error;
	select_one = utilities.select_one;
	add_maint_cat = utilities.add_maint_cat;
	wrap_style = utilities.wrap_style;
	safe_for_italics = utilities.safe_for_italics;
	is_wikilink = utilities.is_wikilink;
	make_wikilink = utilities.make_wikilink;
	strip_apostrophe_markup = utilities.strip_apostrophe_markup;

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	extract_ids = identifiers.extract_ids;										-- imported functions from Module:Citation/CS1/Identifiers
	build_id_list = identifiers.build_id_list;
	is_embargoed = identifiers.is_embargoed;
	extract_id_access_levels = identifiers.extract_id_access_levels;
	
	make_coins_title = metadata.make_coins_title;								-- imported functions from Module:Citation/CS1/COinS
	get_coins_pages = metadata.get_coins_pages;
	COinS = metadata.COinS;

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text, error_state;

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do
		config[k] = v;
--		args[k] = v;															-- debug tool that allows us to render a citation from module {{#invoke:}}
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower(), config.CitationClass ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute (param, capture);				-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text, error_state = set_error ('parameter_ignored_suggest', {k, param}, true);	-- set the suggestion error message
							else
								error_text, error_state = set_error( 'parameter_ignored', {param}, true );	-- suggested param not supported by this template
							end
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?
																				-- TODO: is this the best place for this translation?
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then						-- here when v is empty string
			args[k] = v;														-- why do we do this?  we don't support 'empty' parameters
		end		
	end	

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);
			has_extraneous_punc (k, v);											-- look for extraneous terminal punctuation in parameter values
		end
	end
	return table.concat ({citation0( config, args), frame:extensionTag ('templatestyles', '', {src=styles})});
end

--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {citation = citation};</text>
      <sha1>mg282chfyjopoijk562t2mglqv0tj9o</sha1>
    </revision>
    <revision>
      <id>4729</id>
      <parentid>4728</parentid>
      <timestamp>2020-01-11T12:32:56Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4729</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="184607" sha1="je1ije7os9mk8jc7rz82qsprpz230uw" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local dates, year_date_check, reformat_dates, date_hyphen_to_dash,				-- functions in Module:Citation/CS1/Date_validation
	date_name_xlate

local is_set, in_array, substitute, error_comment, set_error, select_one,		-- functions in Module:Citation/CS1/Utilities
	add_maint_cat, wrap_style, safe_for_italics, is_wikilink, make_wikilink,
	strip_apostrophe_markup;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local extract_ids, extract_id_access_levels, build_id_list, is_embargoed;		-- functions in Module:Citation/CS1/Identifiers

local make_coins_title, get_coins_pages, COinS;									-- functions in Module:Citation/CS1/COinS

local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

delare variables here that have page-wide scope that are not brought in from other modules; thatare created here
and used here

]]

local added_deprecated_cat;														-- boolean flag so that the category is added only once
local added_prop_cats = {};														-- list of property categories that have been added to z.properties_cats
local added_vanc_errs;															-- boolean flag so we only emit one Vancouver error / category

local Frame;																	-- holds the module's frame table


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

foreign_lang_source and foreign_lang_source_2 keys have a language code appended to them so that multiple languages
may be categorized but multiples of the same language are not categorized.

added_prop_cats is a table declared in page scope variables above

]]

local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		key = key:gsub ('(foreign_lang_source_?2?)%a%a%a?[%a%-]*', '%1');		-- strip lang code from keyname
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));	-- make name then add to table
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a boolean declared in page scope variables above

]]

local function add_vanc_error (source)
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {source}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a uri scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of tlds: https://www.iana.org/domains/root/db

rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the tld.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a url with a scheme) will be stripped
here.  Perhaps not necessary but retained incase it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ascii characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the tld) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and tld or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%w]') then											-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at wikisource
		return false;
	end

	local patterns = {															-- patterns that look like urls
		'%f[%w][%w][%w%-]+[%w]%.%a%a+$',										-- three or more character hostname.hostname or hostname.tld
		'%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$',									-- internationalized domain name with ACE prefix
		'%f[%a][qxz]%.com$',													-- assigned one character .com hostname (x.com times out 2015-12-10)
		'%f[%a][iq]%.net$',														-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		'%f[%w][%w]%.%a%a$',													-- one character hostname and cctld (2 chars)
		'%f[%w][%w][%w]%.%a%a+$',												-- two character hostname and tld
		'^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?',								-- IPv4 address
		}

	for _, pattern in ipairs (patterns) do										-- loop through the patterns list
		if domain:match (pattern) then
			return true;														-- if a match then we think that this thing that purports to be a url is a url
		end
	end

	for _, d in ipairs ({'cash', 'company', 'today', 'org'}) do					-- look for single letter second level domain names for these top level domains
		if domain:match ('%f[%w][%w]%.' .. d) then
			return true
		end
	end
	return false;																-- no matches, we don't know what this thing is
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a url appear to be a valid url; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if is_set (scheme) then														-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when url is protocol relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a url into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following tld) (if any) and any path(/), query(?) or fragment(#).

If protocol relative url, return nil scheme and domain else return nil for both scheme and domain.

When not protocol relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol relative url
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		authority = authority:gsub ('//', '', 1);								-- replace place 1 pair of '/' with nothing;
		if is_set(authority) then												-- if anything left (1 or 3+ '/' where authority should be) then
			return scheme;														-- return scheme only making domain nil which will cause an error message
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link= etc for properly formatted content: no wikilinks, no urls

Link parameters are to hold the title of a wikipedia article so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki urls and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid url (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid url (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from url; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid url
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wikilinked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

]]

local function link_title_ok (link, lorig, title, torig)
local orig;

	if is_set (link) then 														-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		end
	end

	if is_set (orig) then
		table.insert( z.message_tail, { set_error( 'bad_paramlink', orig)});	-- url or wikilink in |title= with |title-link=;
	end
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the url into scheme and domain
portions, or for protocol relative (//example.com) urls, just the domain.  Use is_url() to validate the two
portions of the url.  If both are valid, or for protocol relative if domain is valid, return true, else false.

Because it is different from a standard url, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper url
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from url;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a url.  The test will also find external wikilinks
that use protocol relative urls. Also finds bare urls.

The frontier pattern prevents a match on interwiki links which are similar to scheme:path urls.  The tests that
find bracketed urls are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol relative ext wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare url with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol relative bare url: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a url
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then												-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source, access)
	local error_str = &quot;&quot;;
	local domain;
	local path;
	local base_url;

	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the url into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['[']='%5b',[']']='%5d'});					-- replace '[' and ']' with their percent encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wikimarkup url

	if is_set (access) then														-- access level (subscription, registration, limited)
		base_url = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end
	
	return table.concat ({base_url, error_str});
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );	-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Replaces unicode quotemarks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc; not for book titles.

]=]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	local wl_type, label, link;

	wl_type, label, link = is_wikilink (str);									-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = substitute (cfg.presentation['kern-wl-both'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = substitute (cfg.presentation['kern-wl-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = substitute (cfg.presentation['kern-wl-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label= mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label= mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap, cap2 = mw.ustring.match (label, &quot;^([\&quot;\'])([^\'].+)&quot;);				-- match leading double or single quote but not doubled single quotes (italic markup)
		if is_set (cap) then
			label = substitute (cfg.presentation['kern-left'], {cap, cap2});
		end
	
		cap, cap2 = mw.ustring.match (label, &quot;^(.+[^\'])([\&quot;\'])$&quot;)				-- match trailing double or single quote but not doubled single quotes (italic markup)
		if is_set (cap) then
			label = substitute (cfg.presentation['kern-right'], {cap, cap2});
		end
		
		if 2 == wl_type then
			str = make_wikilink (link, label);									-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title=, |script-chapter=, |script-&lt;periodical&gt;=

]]

local function format_script_value (script_value, script_param)
	local lang='';																-- initialize to empty string
	local name;
--	if script_value:match('^%l%l%s*:') then										-- if first 3 non-space characters are script language prefix
	if script_value:match('^%l%l%l?%s*:') then									-- if first 3 or 4 non-space characters are script language prefix
--		lang = script_value:match('^(%l%l)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		lang = script_value:match('^(%l%l%l?)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			table.insert( z.message_tail, { set_error( 'script_parameter', {script_param, 'missing title part'}, true ) } );		-- prefix without 'title'; add error message
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_code_remap[lang] or mw.language.fetchLanguageName( lang, cfg.this_wiki_code );	-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
--			script_value = script_value:gsub ('^%l%l%s*:%s*', '');				-- strip prefix from script
			script_value = script_value:gsub ('^%l+%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, cfg.script_lang_codes) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				table.insert( z.message_tail, { set_error( 'script_parameter', {script_param, 'unknown language code'}, true ) } );	-- unknown script-language; add error message
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			table.insert( z.message_tail, { set_error( 'script_parameter', {script_param, 'invalid language code'}, true ) } );		-- invalid language code; add error message
			lang = '';															-- invalid so set lang to empty string
		end
	else
		table.insert( z.message_tail, { set_error( 'script_parameter', {script_param, 'missing prefix'}, true ) } );				-- no language code prefix; add error message
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script, script_param)
	if is_set (script) then
		script = format_script_value (script, script_param);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return substitute( msg, str );											-- including template text
	else
		return substitute( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;----------------------------------------

makes a wikisource url from wikisource interwiki link.  returns the url and appropriate label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;

	wl_type, D, L = is_wikilink (str);											-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if is_set (str) then
			ws_url = table.concat ({											-- build a wikisource url
				'https://en.wikisource.org/wiki/',								-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the url
		end
	elseif 1 == wl_type then														-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if is_set (str) then
			ws_url = table.concat ({											-- build a wikisource url
				'https://en.wikisource.org/wiki/',								-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the url
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a wikisource url
				'https://en.wikisource.org/wiki/',								-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end
	
	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable url
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent encoding of anchor
	end

	return ws_url, ws_label, L or D;											-- return proper url or nil and a label or nil
end


--[[--------------------------&lt; F O R M A T _ P E R I O D I C A L &gt;--------------------------------------------

Format the four periodical parameters: |script-&lt;periodical&gt;=, |&lt;periodical&gt;=, and |trans-&lt;periodical&gt;= into a single Periodical meta-
parameter.

]]

local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)
	local periodical_error = '';

	if not is_set (periodical) then
		periodical = '';														-- to be safe for concatenation
	else
		periodical = wrap_style ('italic-title', periodical);					-- style 
	end

	periodical = script_concatenate (periodical, script_periodical, script_periodical_source);	-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (trans_periodical) then
		trans_periodical = wrap_style ('trans-italic-title', trans_periodical);
		if is_set (periodical) then
			periodical = periodical ..  ' ' .. trans_periodical;
		else																	-- here when transchapter without chapter or script-chapter
			periodical = trans_periodical;
			periodical_error = ' ' .. set_error ('trans_missing_title', {'periodical'});
		end
	end

	return periodical .. periodical_error;
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (scriptchapter, script_chapter_source, chapter, transchapter, chapterurl, chapter_url_source, no_quotes, access)
	local chapter_error = '';

	local ws_url, ws_label, L = wikisource_url_make (chapter);					-- make a wikisource url and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', '');										-- replace underscore separaters with space characters
		chapter = ws_label;
	end

	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
			chapter = wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, scriptchapter, script_chapter_source);	-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (chapterurl) then
		chapter = external_link (chapterurl, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');	-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if is_set (transchapter) then
		transchapter = wrap_style ('trans-quoted-title', transchapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. transchapter;
		else																	-- here when transchapter without chapter or script-chapter
			chapter = transchapter;
			chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
		end
	end

--	if is_set (chapterurl) then
--		chapter = external_link (chapterurl, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
--	end

	return chapter .. chapter_error;
end


--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i=1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- Test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position and (char == 'zero width joiner') then						-- if we found a zero width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- its ok if one of the indic scripts
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { set_error( 'invisible_char', {err_msg, wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i=i+1;																	-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] .. ': ' .. k);
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = cfg.defaults[k] or '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then
		if &quot;none&quot; == title_type then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash under certain conditions.  The hyphen must separate like items; unlike items are
returned unmodified.  These forms are modified:
	letter - letter (A - B)
	digit - digit (4-5)
	digit separator digit - digit separator digit (4.1-4.5 or 4-1-4-5)
	letterdigit - letterdigit (A1-A5) (an optional separator between letter and digit is supported – a.1-a.5 or a-1-a-5)
	digitletter - digitletter (5a - 5d) (an optional separator between letter and digit is supported – 5.a-5.d or 5-a-5-d)

any other forms are returned unmodified.

str may be a comma- or semicolon-separated list

]]

local function hyphen_to_dash( str )
	if not is_set (str) then
		return str;
	end
	
	str, count = str:gsub ('^%(%((.+)%)%)$', '%1');								-- remove accept-this-as-written markup when it wraps all of str
	if 0 ~= count then															-- non-zero when markup removed; zero else
		return str;																-- nothing to do, we're done
	end
	
	str = str:gsub ('&amp;[nm]dash;', {['&amp;ndash;'] = '–', ['&amp;mdash;'] = '—'});		-- replace &amp;mdash; and &amp;ndash; entities  with their characters; semicolon mucks up the text.split
	str = str:gsub ('&amp;#45;', '-');												-- replace html numeric entity with hyphen character
	
	local out = {};
	local list = mw.text.split (str, '%s*[,;]%s*');								-- split str at comma or semicolon separators if there are any

	for _, item in ipairs (list) do												-- for each item in the list
		if mw.ustring.match (item, '^%w*[%.%-]?%w+%s*[%-–—]%s*%w*[%.%-]?%w+$') then	-- if a hyphenated range or has endash or emdash separators
			if item:match ('^%a+[%.%-]?%d+%s*%-%s*%a+[%.%-]?%d+$') or			-- letterdigit hyphen letterdigit (optional separator between letter and digit)
				item:match ('^%d+[%.%-]?%a+%s*%-%s*%d+[%.%-]?%a+$') or			-- digitletter hyphen digitletter (optional separator between digit and letter)
				item:match ('^%d+[%.%-]%d+%s*%-%s*%d+[%.%-]%d+$') or			-- digit separator digit hyphen digit separator digit
				item:match ('^%d+%s*%-%s*%d+$') or								-- digit hyphen digit
				item:match ('^%a+%s*%-%s*%a+$') then							-- letter hyphen letter
					item = item:gsub ('(%w*[%.%-]?%w+)%s*%-%s*(%w*[%.%-]?%w+)', '%1–%2');	-- replace hyphen, remove extraneous space characters
			else
				item = mw.ustring.gsub (item, '%s*[–—]%s*', '–');				-- for endash or emdash separated ranges, replace em with en, remove extraneous white space
			end
		end
		item = item:gsub ('^%(%((.+)%)%)$', '%1');								-- remove the accept-this-as-written markup
		table.insert (out, item);												-- add the (possibly modified) item to the output table
	end

	return table.concat (out, ', ');											-- concatenate the output table into a comma separated string
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'dupicate character'
		if 1 == #duplicate_char then											-- for single byte ascii characters use the string library functions
			f.gsub=string.gsub
			f.match=string.match
			f.sub=string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub=mw.ustring.gsub
			f.match=mw.ustring.match
			f.sub=mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1,1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = f.sub(str, -1,-1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if f.sub(str, -3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5,-1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4,-1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if f.sub(str, -3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3,-1) == duplicate_char .. '&quot;]' then		-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2,-1) == duplicate_char .. &quot;]&quot; then		-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4,-1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2,-1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows html markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;------------------------------------------------------------

returns true is suffix is properly formed Jr, Sr, or ordinal in the range 2–9.  Puncutation not allowed.

]]

local function is_suffix (suffix)
	if in_array (suffix, {'Jr', 'Sr', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written ouside of the code editor and pasted here because the code editor gets confused between character insertion point and cursor position.
The test has been rewritten to use decimal character escape sequence for the individual bytes of the unicode characters so that it is not necessary
to use an external editor to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first)
	local first, suffix = first:match ('(.-),?%s*([%dJS][%drndth]+)%.?$') or first;	-- if first has something that looks like a generational suffix, get it

	if is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error ('suffix');
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error ('non-Latin character');
			return false;														-- not a string of latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just intials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error ('suffix');									-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word


	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i],1,1));				-- insert the intial at end of initials table
		end
		i = i+1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between authors is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
		lastauthoramp = nil;													-- unset because isn't used by Vancouver style
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between authors is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
				if is_set(person.link) and person.link ~= control.page_name then
					one = make_wikilink (person.link, one);						-- link author/editor if this page is not the author's/editor's page
				end
			end
			table.insert( text, one )
			table.insert( text, sep_one )
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end


--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]
local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of name parameters (author, editor, etc) for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the associated |display-&lt;names&gt;=etal parameter

]]

local function name_has_etal (name, etal, nocat, param)

	if is_set (name) then														-- name can be nil in which case just return
		local patterns = cfg.et_al_patterns;									--get patterns from configuration
		
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns
			if name:match (pattern) then										-- if this 'et al' pattern is found in name
				name = name:gsub (pattern, '');									-- remove the offending text
				etal = true;													-- set flag (may have been set previously here or by |display-&lt;names&gt;=etal)
				if not nocat then												-- no categorization for |vauthors=
					table.insert( z.message_tail, {set_error ('etal', {param})});	-- and set an error if not added
				end
			end
		end
	end

	return name, etal;															-- 
end


--[[--------------------------&lt; N A M E _ H A S _ E D _ M A R K U P &gt;------------------------------------------

Evaluates the content of author and editor parameters for extranious editor annotations: ed, ed., eds, (Ed.), etc.
These annotation do not belong in author parameters and are redundant in editor parameters.  If found, the function
adds the editor markup maintenance category.

]]

local function name_has_ed_markup (name, list_name)
	local _, pattern;
	local patterns = cfg.editor_markup_patterns;								-- get patterns from configuration

	if is_set (name) then
		for _, pattern in ipairs (patterns) do									-- spin through patterns table and
			if name:match (pattern) then
				add_maint_cat ('extra_text_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
				break;
			end
		end
	end
	return name;																-- and done
end


--[[--------------------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;----------------------------------------

Evaluates the content of author and editor (surnames only) parameters for multiple names.  Multiple names are
indicated if there is more than one comma and or semicolon.  If found, the function adds the multiple name
(author or editor) maintenance category.

]]

local function name_has_mult_names (name, list_name)
local count, _;
	if is_set (name) then
		_, count = name:gsub ('[;,]', '');										-- count the number of separator-like characters
		
		if 1 &lt; count then														-- param could be |author= or |editor= so one separator character is acceptable
			add_maint_cat ('mult_names', cfg.special_case_translation [list_name]);	-- more than one separator indicates multiple names so add a maint cat for this template
		end
	end
	return name;																-- and done
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------
This function calls various name checking functions used to validate the content of the various name-holding
parameters.

]]

local function name_checks (last, first, list_name)
	if is_set (last) then
		if last:match ('^%(%(.*%)%)$') then										-- if wrapped in doubled parentheses, accept as written 
			last = last:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			last = name_has_mult_names (last, list_name);						-- check for multiple names in the parameter (last only)
			last = name_has_ed_markup (last, list_name);						-- check for extraneous 'editor' annotation
		end
	end
	if is_set (first) then
		if first:match ('^%(%(.*%)%)$') then									-- if wrapped in doubled parentheses, accept as written 
			first = first:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			first = name_has_ed_markup (first, list_name);						-- check for extraneous 'editor' annotation
		end
	end
	return last, first;															-- done
	end


--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local last_alias, first_alias;												-- selected parameter aliases used in error messaging
	while true do
		last, last_alias = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first, first_alias = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.
		last, first= name_checks (last, first, list_name);						-- multiple names, extraneous annotation, etc checks
		
		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {first_alias, first_alias:gsub('first', 'last')}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			link_title_ok (link, list_name:match (&quot;(%w+)List&quot;):lower() .. '-link' .. i, last, list_name:match (&quot;(%w+)List&quot;):lower() .. '-last' .. i);	-- check for improper wikimarkup

			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {list_name:match (&quot;(%w+)List&quot;):lower(), i-1}, true ) } );	-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because case of the source may be incorrect
or different from the case that WikiMedia uses, the name comparisons are done in lower case and when a match is
found, the Wikimedia version (assumed to be correct) is returned along with the code.  When there is no match, we
return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') returns a list of languages that in some cases may include
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.  Most (all?) of these languages are not used a 'language' codes per se, rather they
are used as sub-domain names: cbk-zam.wikipedia.org.  A list of language names and codes supported by fetchLanguageNames()
can be found at Template:Citation Style documentation/language/doc

Names that are included in the list will be found if that name is provided in the |language= parameter.  For example,
if |language=Chavacano de Zamboanga, that name will be found with the associated code 'cbk-zam'.  When names are found
and the associated code is not two or three characters, this function returns only the WikiMedia language name.

Some language names have multiple entries under different codes:
	Aromanian has code rup and code roa-rup
When this occurs, this function returns the language name and the 2- or 3-character code

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	if cfg.lang_name_remap[lang:lower()] then									-- if there is a remapped name (because MediaWiki uses something that we don't think is correct)
		return cfg.lang_name_remap[lang:lower()][1], cfg.lang_name_remap[lang:lower()][2];	-- for this language 'name', return a possibly new name and appropriate code
	end

	local ietf_code;															-- because some languages have both ietf-like codes and iso 639-like codes
	local ietf_name;
	
	local languages = mw.language.fetchLanguageNames(this_wiki_code, 'all')		-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons

	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 == code:len() or 3 == code:len() then							-- two- or three-character codes only; extensions not supported
				return name, code;												-- so return the name and the code
			end
			ietf_code = code;													-- remember that we found an ietf-like code and save its name
			ietf_name = name;													-- but keep looking for a 2- or 3-char code
		end
	end
																				-- didn't find name with 2- or 3-char code; if ietf-like code found return
	return ietf_code and ietf_name or lang;										-- associated name; return original language text else
end


--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code is recognized by MediaWiki,
use the returned name; if not, then use the value that was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is assigned to the category for
that code: Category:Norwegian-language sources (no).  For valid three-character code languages, the page is assigned
to the single category for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does not recognize three-character
equivalents of two-character codes: code 'ar' is recognized bit code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are
separated from each other by commas.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki_name = mw.language.fetchLanguageName(cfg.this_wiki_code, cfg.this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang
		name = cfg.lang_code_remap[lang:lower()];								-- first see if this is a code that is not supported by MediaWiki but is in remap

		if name then															-- there was a remapped code so
			if not lang:match ('^%a%a%a?%-x%-%a+$') then						-- if not a private ietf tag
				lang = lang:gsub ('^(%a%a%a?)%-.*', '%1');						-- strip ietf tags from code
			end
		else
			if lang:match ('^%a%a%-') then										-- strip ietf tags from code; TODO: is there a need to support 3-char with tag?
				lang = lang:match ('(%a%a)%-')									-- keep only 639-1 code portion to lang; TODO: do something with 3166 alpha 2 country code?
			end
			if 2 == lang:len() or 3 == lang:len() then							-- if two-or three-character code
				name = mw.language.fetchLanguageName (lang:lower(), cfg.this_wiki_code);	-- get language name if |language= is a proper code
			end
		end

		if is_set (name) then													-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, cfg.this_wiki_code);				-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then													-- only 2- or 3-character codes
			name = cfg.lang_code_remap[code] or name;							-- override wikimedia when they misuse language codes/names

			if cfg.this_wiki_code ~= code then									-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					add_prop_cat ('foreign_lang_source' .. code, {name, code});	-- categorize it; code appended to allow for multiple language categorization
				else															-- or is a recognized language (but has a three-character code)
					add_prop_cat ('foreign_lang_source_2' .. code, {code});		-- categorize it differently TODO: support mutliple three-character code categories per cs1|2 template
				end
			elseif cfg.local_lang_cat_enable then								-- when the language and this wiki's language are the same and categorization is enabled
				add_prop_cat ('local_lang_source', {name, code});				-- categorize it
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, cfg.messages['parameter-pair-separator'])		-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		name = table.concat (language_list, ', ');											-- and concatenate with '&lt;comma&gt;&lt;space&gt;' separators
		name = name:gsub (', ([^,]+)$', cfg.messages['parameter-final-separator'] .. '%1');	-- replace last '&lt;comma&gt;&lt;space&gt;' separator with '&lt;comma&gt;&lt;space&gt;and&lt;space&gt;' separator
	end
	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings
At en.wiki, for cs1:
	ps gets:	'.'
	sep gets:	'.'

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitely set to something
		ps = cfg.presentation['ps_cs1'];										-- terminate the rendered citation
	end
	return cfg.presentation['sep_cs1'], ps;										-- element separator
end


--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings
At en.wiki, for cs2:
	ps gets:	'' (empty string - no terminal punctuation)
	sep gets:	','

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = cfg.presentation['ps_cs2'];										-- terminate the rendered citation
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return cfg.presentation['sep_cs2'], ps, ref;								-- element separator
end


--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end


--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end
	if 'none' == ps:lower() then												-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end


--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or
		url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
		url:match ('%.PDF&amp;#035') or url:match ('%.pdf&amp;#035');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parentheses, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[--------------------------&lt; G E T _ D I S P L A Y _ N A M E S &gt;--------------------------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_names (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_name', cfg.special_case_translation [list_name]);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parnetheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a place holder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parens
			local name = name_table[i];
			i=i+1;																-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parens
					break;														-- and done reassembling so
				end
				i=i+1;															-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = is_wikilink (name_table[i]);					-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i+1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parentheses to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')								-- remove doubled parntheses
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error ('punctuation');
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
			if is_suffix (first) then											-- if a valid suffix
				suffix = first													-- save it as a suffix and
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end																	-- no suffix error message here because letter combination may be result of Romanization; check for digits?
			last = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error ('missing comma');								-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error ('name');										-- matches a space between two intiials
			end
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error ('initials');									-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first);									-- check first and last before restoring the suffix which may have a non-Latin digit
			if is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '');
			end
		end

		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ) or v_link_table[i];
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice incase we have a |first1= without a |last1=; this ...
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or	-- ... also catches the case where |first= is used with |vauthors=
		select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, live, dead, etc).  When the parameter value has not been assigned a value (missing
or empty in the source template) the function returns the value specified by ret_val.  If the parameter value is one
of the list of allowed values returns the translated value; else, emits an error message and returns the value
specified by ret_val.

]]

local function is_valid_parameter_value (value, name, possible, ret_val)
	if not is_set (value) then
		return ret_val;															-- an empty parameter is ok
	elseif in_array (value, possible) then
		return cfg.keywords_xlate[value];										-- return translation of parameter keyword
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return ret_val;
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list,-3,-1) == sepc .. '. ') then						-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list,-1,-1) == sepc) or (string.sub (name_list,-3,-1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terninate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not is_set (volume) and not is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end

	if 'podcast' == cite_class and is_set (issue) then
		return wrap_msg ('issue', {sepc, issue}, lower);
	end

	local vol = '';																-- here for all cites except magazine
		
	if is_set (volume) then
		if volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$')then			-- volume value is all digits or all uppercase roman numerals
			vol = substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});	-- render in bold face
		elseif (4 &lt; mw.ustring.len(volume)) then								-- not all digits or roman numerals and longer than 4 characters
			vol = substitute (cfg.messages['j-vol'], {sepc, volume});			-- not bold
			add_prop_cat ('long_vol');
		else																	-- four or less characters
			vol = substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});	-- bold
		end
	end
	if is_set (issue) then
		return vol .. substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if is_set (page) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif is_set(pages) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then							-- if pages is only digits, assume a single page number
			return '', substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to wikisource, returns the label portion of the interwikilink as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki link to and external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, pages, at)
	local ws_url, ws_label, coins_pages, L;										-- for wikisource interwikilinks; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if is_set (page) then
		if is_set (pages) or is_set(at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws url from |page= interwiki link; link portion L becomes tool tip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif is_set (pages) then
		if is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws url from |pages= interwiki link; link portion L becomes tool tip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws url from |at= interwiki link; link portion L becomes tool tip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end



--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org urls to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot url or to calendar pages.  When the archive url is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the url.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org url does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command url
	|archive-url= is an archive.org url that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org urls:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this funct may return a modified
archive url:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the url unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.or url
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine url
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command url, we don't want to allow saving of the target page 
		err_msg = 'save command';
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = 'liveweb';
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');	-- split out some of the url parts for evaluation
		
		if not is_set(timestamp) or 14 ~= timestamp:len() then					-- path and flag optional, must have 14-digit timestamp here
			err_msg = 'timestamp';
			if '*' ~= flag then
				url=url:gsub ('(//web%.archive%.org/[^%d]*%d?%d?%d?%d?%d?%d?)[^/]*', '%1*', 1)	-- for preview, modify ts to be yearmo* max (0-6 digits plus splat)
			end
		elseif is_set(path) and 'web/' ~= path then								-- older archive urls do not have the extra 'web/' path element
			err_msg = 'path';
		elseif is_set (flag) and not is_set (path) then							-- flag not allowed with the old form url (without the 'web/' path element)
			err_msg = 'flag';
		elseif is_set (flag) and not flag:match ('%a%a_') then					-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = 'flag';
		else
			return url, date;													-- return archiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	table.insert( z.message_tail, { set_error( 'archive_url', {err_msg}, true ) } );	-- add error message and
	if is_set (Frame:preprocess('{{REVISIONID}}')) then
		return '', '';															-- return empty strings for archiveURL and ArchiveDate
	else
		return url, date;														-- preview mode so return archiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; P L A C E _ C H E C K &gt;--------------------------------------------------------

check |place=, |publication-place=, |location= to see if these params include digits.  This function added because
many editors mis-use location to specify the in-source location (|page(s)= and |at= are supposed to do that)

returns the original parameter value without modification; added maint cat when parameter value contains digits

]]

local function place_check (param_val)
	if not is_set (param_val) then													-- parameter empty or omitted
		return param_val;														-- return that empty state
	end
	
	if mw.ustring.find (param_val, '%d') then									-- not empty, are there digits in the parameter value
		add_maint_cat ('location');												-- yep, add maint cat
	end
	
	return param_val;															-- and done
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

	local Mode = is_valid_parameter_value (A['Mode'], A:ORIGIN('Mode'), cfg.keywords_lists['mode'], '');

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;

	local NameListFormat = is_valid_parameter_value (A['NameListFormat'], A:ORIGIN('NameListFormat'), cfg.keywords_lists['name-list-format'], '');
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				add_maint_cat ('authors');										-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
			add_maint_cat ('editors');											-- but add a maint cat because use of this parameter is discouraged
		end
	end

	local translator_etal;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=

	local interviewer_etal;
	local interviewers_list = {};												
	local Interviewers;															-- used later
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters

	local contributor_etal;
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list
	local Contribution = A['Contribution'];
	if in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not is_set (Contribution) then									-- |contributor= requires |contribution=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if select_one (args, cfg.aliases['ContributorList-Last'], 'redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { set_error( 'contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if is_set (Others) then
		if 0 == #a and 0 == #e then												-- add maint cat when |others= has value and used without |author=, |editor=
			add_maint_cat ('others');
		end
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
			link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wikimarkup in |title-link= or wikimarkup in |title= when |title-link= is set

	local Chapter = A['Chapter'];
	local ScriptChapter = A['ScriptChapter'];
	local ScriptChapterOrigin = A:ORIGIN ('ScriptChapter');
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];

	local ArchiveDate;
	local ArchiveURL;

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	
	local UrlStatus = is_valid_parameter_value (A['UrlStatus'], A:ORIGIN('UrlStatus'), cfg.keywords_lists['url-status'], '');


	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	local Periodical = A['Periodical'];
	local Periodical_origin = '';
		if is_set (Periodical) then
			Periodical_origin = A:ORIGIN('Periodical');							-- get the name of the periodical parameter
			local i;
			Periodical, i = strip_apostrophe_markup (Periodical);				-- strip appostrophe markup so that metadata isn't contaminated 
			if i then															-- non-zero when markup was stripped so emit an error message
				table.insert( z.message_tail, {set_error ('apostrophe_markup', {Periodical_origin}, true)});
			end
		end

	local ScriptPeriodical = A['ScriptPeriodical'];
	local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');
																				-- web and news not tested for now because of 
																				-- Wikipedia:Administrators%27_noticeboard#Is_there_a_semi-automated_tool_that_could_fix_these_annoying_&quot;Cite_Web&quot;_errors?
		if not (is_set (Periodical) or is_set (ScriptPeriodical)) then			-- 'periodical' templates require periodical parameter
--			local p = {['journal'] = 'journal', ['magazine'] = 'magazine', ['news'] = 'newspaper', ['web'] = 'website'};	-- for error message
			local p = {['journal'] = 'journal', ['magazine'] = 'magazine'};		-- for error message
			if p[config.CitationClass]  then
				table.insert( z.message_tail, {set_error ('missing_periodical', {config.CitationClass, p[config.CitationClass]}, true)});
			end
		end

	local TransPeriodical =  A['TransPeriodical'];

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if 'citation' == config.CitationClass then
		if is_set (Periodical) then
			if not in_array (Periodical_origin, {'website', 'mailinglist'}) then	-- {{citation}} does not render volume for these 'periodicals'
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		elseif is_set (ScriptPeriodical) then
			if 'script-website' ~= ScriptPeriodical_origin then					-- {{citation}} does not render volume for |script-website=
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		else
			Volume = A['Volume'];												-- and does for non-'periodical' cites
		end
	elseif in_array (config.CitationClass, cfg.templates_using_volume) then		-- render |volume= for cs1 according to the configuration settings
		Volume = A['Volume'];
	end	

	if 'citation' == config.CitationClass then
		if is_set (Periodical) and in_array (Periodical_origin, {'journal', 'magazine', 'newspaper', 'periodical', 'work'}) or	-- {{citation}} renders issue for these 'periodicals'
			is_set (ScriptPeriodical) and in_array (ScriptPeriodical_origin, {'script-journal', 'script-magazine', 'script-newspaper', 'script-periodical', 'script-work'}) then -- and these 'script-periodicals'
				Issue = hyphen_to_dash (A['Issue']);
		end
	elseif in_array (config.CitationClass, cfg.templates_using_issue) then		-- conference &amp; map books do not support issue; {{citation}} listed here because included in settings table
		if not (in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (is_set (Periodical) or is_set (ScriptPeriodical))) then
			Issue = hyphen_to_dash (A['Issue']);
		end
	end

	local Position = '';
	if not in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash (A['Pages']);	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = place_check (A['PublicationPlace'], A:ORIGIN('PublicationPlace'));
	local Place = place_check (A['Place'], A:ORIGIN('Place'));
	
	local PublisherName = A['PublisherName'];
	local PublisherName_origin = A:ORIGIN('PublisherName');
		if is_set (PublisherName) then
			local i=0;
			PublisherName, i = strip_apostrophe_markup (PublisherName);			-- strip appostrophe markup so that metadata isn't contaminated; publisher is never italicized

			if i then															-- non-zero when markup was stripped so emit an error message
				table.insert( z.message_tail, {set_error ('apostrophe_markup', {PublisherName_origin}, true)});
			end
		end

	local UrlAccess = is_valid_parameter_value (A['UrlAccess'], A:ORIGIN('UrlAccess'), cfg.keywords_lists['url-access'], nil);
		if not is_set(URL) and is_set(UrlAccess) then
			UrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {'url'}, true ) } );
		end
		
	local ChapterUrlAccess = is_valid_parameter_value (A['ChapterUrlAccess'], A:ORIGIN('ChapterUrlAccess'), cfg.keywords_lists['url-access'], nil);
		if not is_set(ChapterURL) and is_set(ChapterUrlAccess) then
			ChapterUrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {A:ORIGIN('ChapterUrlAccess'):gsub ('%-access', '')}, true ) } );
		end

	local MapUrlAccess = is_valid_parameter_value (A['MapUrlAccess'], A:ORIGIN('MapUrlAccess'), cfg.keywords_lists['url-access'], nil);
		if not is_set(A['MapURL']) and is_set(MapUrlAccess) then
			MapUrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {'map-url'}, true ) } );
		end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local Agency = A['Agency'];

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = is_valid_parameter_value (A['IgnoreISBN'], A:ORIGIN('IgnoreISBN'), cfg.keywords_lists['yes_true_y'], nil);
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );
		if is_set (DoiBroken) and not ID_list['DOI'] then
			table.insert( z.message_tail, { set_error( 'doibroken_missing_doi', A:ORIGIN('DoiBroken'))});
		end
	local ID_access_levels = extract_id_access_levels( args, ID_list );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = is_valid_parameter_value (A['LastAuthorAmp'], A:ORIGIN('LastAuthorAmp'), cfg.keywords_lists['yes_true_y'], nil);

	local no_tracking_cats = is_valid_parameter_value (A['NoTracking'], A:ORIGIN('NoTracking'), cfg.keywords_lists['yes_true_y'], nil);

	--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = is_valid_parameter_value (A['DF'], A:ORIGIN('DF'), cfg.keywords_lists['df'], '');
	if not is_set (DF) then
		DF = cfg.global_df;														-- local df if present overrides global df set by {{use xxx date}} template
	end

	local sepc;																	-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref;
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], A['Ref'], config.CitationClass);
	use_lowercase = ( sepc == ',' );											-- used to control capitalization for certain static text

	--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end

	-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	select_one( args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'redundant_parameters' );	-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, Pages, At);

	local NoPP = is_valid_parameter_value (A['NoPP'], A:ORIGIN('NoPP'), cfg.keywords_lists['yes_true_y'], nil);

	if is_set (PublicationPlace) and is_set (Place) then						-- both |publication-place= and |place= (|location=) allowed if different
		add_prop_cat ('location test');											-- add property cat to evaluate how often PublicationPlace and Place are used together
		if PublicationPlace == Place then
			Place = '';															-- unset; don't need both if they are the same
		end
	elseif not is_set (PublicationPlace) and is_set (Place) then				-- when only |place= (|location=) is set ...
		PublicationPlace = Place;												-- promote |place= (|location=) to |publication-place
	end

--	if not is_set(PublicationPlace) and is_set(Place) then						-- both |publication-place= and |place= (|location=) allowed if different
--		PublicationPlace = Place;												-- promote |place= (|location=) to |publication-place
--	end
--	
	if PublicationPlace == Place then Place = ''; end							-- don't need both if they are the same
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia and |title then map |title to |article and |encyclopedia to |title
		|encyclopedia and |article then map |encyclopedia to |title

		|trans-title maps to |trans-chapter when |title is re-mapped
		|url maps to |chapterurl when |title is remapped
	
	All other combinations of |encyclopedia, |title, and |article are not modified
	
	]]

local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set (Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					ScriptChapterOrigin = A:ORIGIN('ScriptTitle')
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterUrlAccess = UrlAccess;

					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter = make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			elseif is_set (Chapter) then										-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if is_set(A['Number']) then												-- cite techreport uses 'number', which other citations alias to 'issue'
			if not is_set(ID) then												-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', 'id') .. ' and ' .. wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

	-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then
		Periodical = A ['MailingList'];
	elseif 'mailinglist' == Periodical_origin then
		Periodical = '';														-- unset because mailing list is only used for cite mailing list
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
--			ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
--			TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		TransChapter = A['TransMap'];
		ScriptChapter = A['ScriptMap']
		ScriptChapterOrigin = A:ORIGIN('ScriptMap')

		ChapterUrlAccess = MapUrlAccess;
		ChapterFormat = A['MapFormat'];

		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local AirDate = A['AirDate'];
		local SeriesLink = A['SeriesLink'];

		link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wikimarkup in |series-link= or wikimarkup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if not is_set (Date) and is_set (AirDate) then							-- promote airdate to date
			Date = AirDate;
		end

		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('seriesnum', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
--			ScriptChapterOrigin = 'title';
			ScriptChapterOrigin = A:ORIGIN('ScriptTitle');
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = make_wikilink (ChapterLink, Chapter);
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = make_wikilink (SeriesLink, Series);
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite ssrn}}, before generation of COinS data.
	do
		if in_array (config.CitationClass, {'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) then
			if not is_set (ID_list[config.CitationClass:upper()]) then			-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp; |citeseerx= required for their templates
				table.insert( z.message_tail, { set_error( config.CitationClass .. '_missing', {}, true ) } );	-- add error message
			end

			Periodical = ({['arxiv'] = 'arXiv', ['biorxiv'] = 'bioRxiv', ['citeseerx'] = 'CiteSeerX', ['ssrn'] = 'Social Science Research Network'})[config.CitationClass];
		end
	end

	-- handle type parameter for those CS1 citations that have default values
	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;interview&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
		TitleType = substitute( cfg.messages['type'], TitleType);				-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging

	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val=AccessDate, name=A:ORIGIN ('AccessDate')},
			['archive-date'] = {val=ArchiveDate, name=A:ORIGIN ('ArchiveDate')},
			['date'] = {val=Date, name=Date_origin},
			['doi-broken-date'] = {val=DoiBroken, name=A:ORIGIN ('DoiBroken')},
			['embargo'] = {val=Embargo, name=A:ORIGIN ('Embargo')},
			['lay-date'] = {val=LayDate, name=A:ORIGIN ('LayDate')},
			['publication-date'] ={val=PublicationDate, name=A:ORIGIN ('PublicationDate')},
			['year'] = {val=Year, name=A:ORIGIN ('Year')},
			};
		anchor_year, Embargo, error_message = dates(date_parameters_list, COinS_date);

-- start temporary Julian / Gregorian calendar uncertainty categorization
		if COinS_date.inter_cal_cat then
			add_prop_cat ('jul_greg_uncertainty');
		end
-- end temporary Julian / Gregorian calendar uncertainty categorization

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end
		
		if not is_set(error_message) then										-- error free dates only
			local modified = false;												-- flag
			
			if is_set (DF) then													-- if we need to reformat dates
				modified = reformat_dates (date_parameters_list, DF, false);	-- reformat to DF format, use long month names if appropriate
			end

			if true == date_hyphen_to_dash (date_parameters_list) then			-- convert hyphens to dashes where appropriate
				modified = true;
				add_maint_cat ('date_format');									-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language,
	-- uncomment these three lines.  Not supported by en.wiki (for obvious reasons)
	-- set date_name_xlate() second argument to true to translate English digits to local digits (will translate ymd dates)
--			if date_name_xlate (date_parameters_list, false) then
--				modified = true;
--			end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				LayDate = date_parameters_list['lay-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end
		else
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end
	end	-- end of do

	-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
	-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
			if is_set(AccessDate) then											-- access date requires |url=; pmc created url is not |url=
				table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
				AccessDate = '';												-- unset
			end

		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
			if 'episode' == config.CitationClass then							-- special case for cite episode; TODO: is there a better way to do this?
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
			else
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
			end
	end

	if 'none' == Title and
			in_array (config.CitationClass, {'journal', 'citation'}) and
			(is_set (Periodical) or is_set (ScriptPeriodical)) and
			('journal' == Periodical_origin or 'script-journal' == ScriptPeriodical_origin) then	-- special case for journal cites
				Title = '';														-- set title to empty string
				add_maint_cat ('untitled');
	end

	check_for_url ({															-- add error message when any of these parameters hold a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[Periodical_origin] = Periodical,
		[PublisherName_origin] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = strip_apostrophe_markup (Periodical),					-- no markup in the metadata
		['Encyclopedia'] = strip_apostrophe_markup (Encyclopedia),
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = coins_pages or get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName,										-- any apostrophe markup already removed
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, and {{cite ssrn}} AFTER generation of COinS data.
	if in_array (config.CitationClass, {'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, CiteSeerX, or ssrn now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then
			PublisherName = substitute (cfg.messages['newsgroup'], external_link( 'news:' .. PublisherName, PublisherName, PublisherName_origin, nil ));
		end
	end

	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			page_name = this_page.text,											-- get current page name so that we don't wikilink to it via editorlinkn
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_names (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if is_set (Editors) then
				Editors, editor_etal = name_has_etal (Editors, editor_etal, false, 'editors');	-- find and remove variations on et al.
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
					EditorCount = 2;											-- with et al., |editors= is multiple names; spoof to display (eds.) annotation
				else
					EditorCount = 2;											-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
				end
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum , interviewer_etal = get_display_names (A['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal);
			Interviewers = list_people (control, interviewers_list, interviewer_etal);
		end
		do																		-- now do translators
			control.maximum , translator_etal = get_display_names (A['DisplayTranslators'], #t, 'translators', translator_etal);
			Translators = list_people (control, t, translator_etal);
		end
		do																		-- now do contributors
			control.maximum , contributor_etal = get_display_names (A['DisplayContributors'], #c, 'contributors', contributor_etal);
			Contributors = list_people (control, c, contributor_etal);
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_names (A['DisplayAuthors'], #a, 'authors', author_etal);

			last_first_list = list_people(control, a, author_etal);

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors');	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if is_set (Authors) and is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
	-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (is_set (Periodical) or is_set (ScriptPeriodical)) and not is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not is_set(URL) then
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) or		-- |url= required for cite web, cite podcast, and cite mailinglist
			('citation' == config.CitationClass and ('website' == Periodical_origin or 'script-website' == ScriptPeriodical_origin)) then	-- and required for {{citation}} with |website= or |script-website=
				table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURLorigin, OriginalFormat, OriginalAccess;
	UrlStatus = UrlStatus:lower();												-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (ChapterURL) then 											-- if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURLorigin = ChapterURLorigin;								-- name of chapter-url parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=

			if 'live' ~= UrlStatus then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				ChapterURLorigin = A:ORIGIN('ArchiveURL')						-- name of archive-url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived urls
			end
		elseif is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURLorigin = URLorigin;										-- name of url parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;

			if 'live' ~= UrlStatus then											-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived urls
			end
 		end
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and (is_set (Periodical) or is_set (ScriptPeriodical)) and not is_set (Encyclopedia)) then
			local chap_param;
			if is_set (Chapter) then											-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif is_set (ScriptChapter) then
				chap_param = ScriptChapterOrigin;
			else is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if is_set (chap_param) then											-- if we found one
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {chap_param}, true ) } );		-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if is_set (Contribution) and 0 &lt; #c then								-- if this is a contribution with contributor(s)
			if in_array (Contribution:lower(), cfg.keywords_lists.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, ScriptChapterOrigin, Chapter, TransChapter, ChapterURL, ChapterURLorigin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter.. sepc .. ' ';
		elseif is_set (ChapterFormat) then										-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title.
	if is_set (ArchiveURL) and mw.ustring.match (mw.ustring.lower(Title), cfg.special_case_translation['archived_copy']) then	-- if title is 'Archived copy' (place holder added by bots that can't find proper title)
		add_maint_cat ('archived_copy');										-- add maintenance category before we modify the content of Title
	end

	if Title:match ('^%(%(.*%)%)$') then										-- if keep as written markup:
		Title= Title:gsub ('^%(%((.*)%)%)$', '%1')								-- remove the markup
	else
		if '...' == Title:sub (-3) then											-- if elipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%'..sepc..'$', '');				-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end
	end
	
	if in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (is_set (Periodical) or is_set (ScriptPeriodical)) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and (is_set (Periodical) or is_set (ScriptPeriodical))) then		-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle, 'script-title');	-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end

	if is_set(Title) then
		if not is_set (TitleLink) and is_set (URL) then
			Title = external_link (URL, Title, URLorigin, UrlAccess) .. TransTitle .. TransError .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif is_set (TitleLink) and not is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = make_wikilink (TitleLink, Title) .. TransTitle .. TransError;
			end
		else
			local ws_url, ws_label;
			ws_url, ws_label, L = wikisource_url_make (Title);					-- make ws url from |title= interwiki link; link portion L becomes tool tip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = Title .. TransTitle .. TransError;
			end
		end
	else
		Title = TransTitle .. TransError;
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURLorigin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin, nil );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if is_set(Minutes) then
			if is_set (Time) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'minutes') .. ' and ' .. wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Section = A['Section'];
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = is_set (Series) and wrap_msg ('series', {sepc, Series}) or &quot;&quot;;		-- not the same as SeriesNum
	OrigYear = is_set (OrigYear) and wrap_msg ('origyear', OrigYear) or '';
	Agency = is_set (Agency) and wrap_msg ('agency', {sepc, Agency}) or &quot;&quot;;
	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	Via = is_set (Via) and  wrap_msg ('via', Via) or '';

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text

		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {IdAccessLevels=ID_access_levels, DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin, UrlAccess );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then				-- if first and last characters of quote are quote marks
			Quote = Quote:sub(2,-2);											-- strip them off
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		local arch_text;
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;live&quot; == UrlStatus then
			arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-live'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil ) .. ArchiveFormat, ArchiveDate } );
			if not is_set (OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- UrlStatus is empty, 'dead', 'unfit', 'usurped', 'bot: unknown'
			if in_array (UrlStatus, {'unfit', 'usurped', 'bot: unknown'}) then
				arch_text = cfg.messages['archived-unfit'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. &quot; &quot; .. arch_text .. ArchiveDate;				-- format already styled
				if 'bot: unknown' == UrlStatus then
					add_maint_cat ('bot:_unknown');								-- and add a category if not already added
				else
					add_maint_cat ('unfit');									-- and add a category if not already added
				end
			else																-- UrlStatus is empty, 'dead'
				arch_text = cfg.messages['archived-dead'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURLorigin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else																	-- OriginalUrl not set
			arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURLorigin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin, nil );
	end

	local Publisher;
	if is_set(PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if is_set(PublisherName) then
		if is_set(PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif is_set(PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if (is_set (Periodical) or is_set (ScriptPeriodical) or is_set (TransPeriodical)) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical);
		else 
			Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical);
		end
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then									-- cite speech only
		TitleNote = &quot; (Speech)&quot;;												-- annotate the citation
		if is_set (Periodical) then												-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then											-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;							-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = safe_join ({Others, sepc .. &quot; &quot;}, sepc) end		-- add terminal punctuation &amp; space; check for dup sepc; TODO why do we need to do this here?
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(Periodical) then		-- special cases for book cites
		if is_set (Contributors) then											-- when we are citing foreword, preface, introduction, etc
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon;
	if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then	-- special case for cite AV media &amp; cite episode position transcript
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, Lay, Quote }, sepc );
	else
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, Lay, Quote }, sepc );
	end
	
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if is_set(Date) then
		if is_set (Authors) or is_set (Editors) then							-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;;				-- in paranetheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon,-1,-1) == sepc) then							-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigYear;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigYear;							-- Date begins with sepc
			end
		end
	end	
	if is_set(Authors) then
		if (not is_set (Date)) then												-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then
					in_text = in_text:lower()									-- lowercase for cs2
				end
			end
			if EditorCount &lt;= 1 then
				post_text = &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot;;				-- be consistent with no-author, no-date case
			else
				post_text = &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot;;
			end
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if is_set (Contributors) then											-- book cite and we're citing the intro, preface, etc
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if is_set (Editors) and is_set (Date) then							-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not is_set (Date)) then											-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc ); 								--Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = config.CitationClass;
		options.class = &quot;citation &quot; .. config.CitationClass;					-- class=citation required for blue highlight when used with |ref=
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and Ref:lower() ~= &quot;none&quot; then								-- set reference anchor if appropriate
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			if #namelist &gt; 0 then												-- if there are names in namelist
				id = anchor_id (namelist, year);								-- go make the CITEREF anchor
			else
				id = '';														-- unset
			end
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;(.-)&lt;/span&gt;&quot;, &quot;%1&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then	-- remove &lt;span&gt; tags and other html-like markup; then get length of what remains
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	local render = {};															-- here we collect the final bits for concatenation into the rendered citation

	if is_set(options.id) then													-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render, substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text}));	-- when |ref= is set
	else
		table.insert (render, substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text}));	-- all other cases
	end		

	table.insert (render, substitute (cfg.presentation['ocins'], {OCinSoutput}));	-- append metadata to the citation

	if 0 ~= #z.message_tail then
		table.insert (render, ' ');
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					table.insert (render, error_comment( v[1], v[2] ));
				else
					table.insert (render, error_comment( v[1] .. &quot;; &quot;, v[2] ));
				end
			end
		end
	end

	if 0 ~= #z.maintenance_cats then
		local maint_msgs = {};													-- here we collect all of the maint messages
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			local maint = {};													-- here we assemble a maintenence message
			table.insert (maint, v);											-- maint msg is the category name
			table.insert (maint, ' (');											-- open the link text
			table.insert (maint, make_wikilink (':Category:' .. v, 'link'));	-- add the link
			table.insert (maint, ')');											-- and close it
			table.insert (maint_msgs, table.concat (maint));					-- assemble new maint message and add it to the maint_msgs table
		end
		table.insert (render, substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs, ' ')));	-- wrap the group of maint message with proper presentation and save
	end
	
--	no_tracking_cats = no_tracking_cats:lower();
--	if in_array(no_tracking_cats, {&quot;&quot;, &quot;no&quot;, &quot;false&quot;, &quot;n&quot;}) then
	if not no_tracking_cats then
		for _, v in ipairs( z.error_categories ) do
			table.insert (render, make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			table.insert (render, make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.properties_cats ) do								-- append properties categories
			table.insert (render, make_wikilink ('Category:' .. v));
		end
	end

	return table.concat (render);	
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class)
	local name = tostring (name);
	local state;
	
	if in_array (cite_class, {'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) then	-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[name];
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end

		state = whitelist[cite_class .. '_basic_arguments'][name];				-- look in the parameter-list for the template identified by cite_class

		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
																				-- limited enumerated parameters list
		name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
		state = whitelist.limited_numbered_arguments[name];
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates
		
	state = whitelist.basic_arguments[name];									-- all other templates; all normal parameters allowed
											
	if true == state then return true; end										-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);											-- parameter is deprecated but still supported
		return true;
	end
																				-- all enumerated parameters allowed
	name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );												-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
	state = whitelist.numbered_arguments[name];

	if true == state then return true; end										-- valid actively supported parameter
	if false == state then
		deprecated_parameter (name);											-- parameter is deprecated but still supported
		return true;
	end
	
	return false;																-- not supported because not found or name is set to nil
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe:
	{{cite ... |title=Title access-date=2016-03-17}}

cs1|2 shares some parameter names with xml/html atributes: class=, title=, etc.  To prevent false positives xml/html
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (parameter, value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove xml/html tags because attributes: class=, title=, etc 

	capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then								-- if the capture is a valid parameter name
		table.insert( z.message_tail, {set_error ('missing_pipe',parameter)});
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ P U N C T &gt;--------------------------------------

look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_punc (param, value)
	if cfg.punct_skip[param] then
		return;																	-- parameter name found in the skip table so done
	end
	
	if value:match ('[,;:]$') then
		add_maint_cat ('extra_punct');											-- has extraneous punctuation; add maint cat
	end
end


--[[--------------------------&lt; C I T A T I O N &gt;--------------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

local function citation(frame)
	Frame = frame;																-- save a copy incase we need to display an error message in preview mode
	local pframe = frame:getParent()
	local validation, utilities, identifiers, metadata, styles;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		styles = 'Module:Citation/CS1/sandbox/styles.css';
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
		styles = 'Module:Citation/CS1/styles.css';

	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	dates = validation.dates;													-- imported functions from Module:Citation/CS1/Date validation
	year_date_check = validation.year_date_check;
	reformat_dates = validation.reformat_dates;
	date_hyphen_to_dash = validation.date_hyphen_to_dash;
	date_name_xlate = validation.date_name_xlate;

	is_set = utilities.is_set;													-- imported functions from Module:Citation/CS1/Utilities
	in_array = utilities.in_array;
	substitute = utilities.substitute;
	error_comment = utilities.error_comment;
	set_error = utilities.set_error;
	select_one = utilities.select_one;
	add_maint_cat = utilities.add_maint_cat;
	wrap_style = utilities.wrap_style;
	safe_for_italics = utilities.safe_for_italics;
	is_wikilink = utilities.is_wikilink;
	make_wikilink = utilities.make_wikilink;
	strip_apostrophe_markup = utilities.strip_apostrophe_markup;

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	extract_ids = identifiers.extract_ids;										-- imported functions from Module:Citation/CS1/Identifiers
	build_id_list = identifiers.build_id_list;
	is_embargoed = identifiers.is_embargoed;
	extract_id_access_levels = identifiers.extract_id_access_levels;
	
	make_coins_title = metadata.make_coins_title;								-- imported functions from Module:Citation/CS1/COinS
	get_coins_pages = metadata.get_coins_pages;
	COinS = metadata.COinS;

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text, error_state;

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do
		config[k] = v;
--		args[k] = v;															-- debug tool that allows us to render a citation from module {{#invoke:}}
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower(), config.CitationClass ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute (param, capture);				-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text, error_state = set_error ('parameter_ignored_suggest', {k, param}, true);	-- set the suggestion error message
							else
								error_text, error_state = set_error( 'parameter_ignored', {param}, true );	-- suggested param not supported by this template
								v = '';											-- unset
							end
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?
																				-- TODO: is this the best place for this translation?
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then						-- here when v is empty string
			args[k] = v;														-- why do we do this?  we don't support 'empty' parameters
		end		
	end	

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);
			has_extraneous_punc (k, v);											-- look for extraneous terminal punctuation in parameter values
		end
	end

	return table.concat ({citation0( config, args), frame:extensionTag ('templatestyles', '', {src=styles})});
end

--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {citation = citation};</text>
      <sha1>je1ije7os9mk8jc7rz82qsprpz230uw</sha1>
    </revision>
    <revision>
      <id>4730</id>
      <parentid>4729</parentid>
      <timestamp>2020-04-18T12:50:55Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4730</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="186750" sha1="17ti8zx1nn1o0u381j04ctr9nfjwvis" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local dates, year_date_check, reformat_dates, date_hyphen_to_dash,				-- functions in Module:Citation/CS1/Date_validation
	date_name_xlate

local is_set, in_array, substitute, error_comment, set_error, select_one,		-- functions in Module:Citation/CS1/Utilities
	add_maint_cat, wrap_style, safe_for_italics, is_wikilink, make_wikilink,
	strip_apostrophe_markup;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local extract_ids, extract_id_access_levels, build_id_list, is_embargoed;		-- functions in Module:Citation/CS1/Identifiers

local make_coins_title, get_coins_pages, COinS;									-- functions in Module:Citation/CS1/COinS

local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

delare variables here that have page-wide scope that are not brought in from other modules; thatare created here
and used here

]]

local added_deprecated_cat;														-- boolean flag so that the category is added only once
local added_prop_cats = {};														-- list of property categories that have been added to z.properties_cats
local added_vanc_errs;															-- boolean flag so we only emit one Vancouver error / category

local Frame;																	-- holds the module's frame table


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

foreign_lang_source and foreign_lang_source_2 keys have a language code appended to them so that multiple languages
may be categorized but multiples of the same language are not categorized.

added_prop_cats is a table declared in page scope variables above

]]

local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		key = key:gsub ('(foreign_lang_source_?2?)%a%a%a?[%a%-]*', '%1');		-- strip lang code from keyname
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));	-- make name then add to table
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a boolean declared in page scope variables above

]]

local function add_vanc_error (source)
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {source}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a uri scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of tlds: https://www.iana.org/domains/root/db

rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the tld.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a url with a scheme) will be stripped
here.  Perhaps not necessary but retained incase it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ascii characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the tld) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and tld or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%w]') then											-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at wikisource
		return false;
	end

	local patterns = {															-- patterns that look like urls
		'%f[%w][%w][%w%-]+[%w]%.%a%a+$',										-- three or more character hostname.hostname or hostname.tld
		'%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$',									-- internationalized domain name with ACE prefix
		'%f[%a][qxz]%.com$',													-- assigned one character .com hostname (x.com times out 2015-12-10)
		'%f[%a][iq]%.net$',														-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		'%f[%w][%w]%.%a%a$',													-- one character hostname and cctld (2 chars)
		'%f[%w][%w][%w]%.%a%a+$',												-- two character hostname and tld
		'^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?',								-- IPv4 address
		}

	for _, pattern in ipairs (patterns) do										-- loop through the patterns list
		if domain:match (pattern) then
			return true;														-- if a match then we think that this thing that purports to be a url is a url
		end
	end

	for _, d in ipairs ({'cash', 'company', 'today', 'org'}) do					-- look for single letter second level domain names for these top level domains
		if domain:match ('%f[%w][%w]%.' .. d) then
			return true
		end
	end
	return false;																-- no matches, we don't know what this thing is
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a url appear to be a valid url; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if is_set (scheme) then														-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when url is protocol relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a url into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following tld) (if any) and any path(/), query(?) or fragment(#).

If protocol relative url, return nil scheme and domain else return nil for both scheme and domain.

When not protocol relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol relative url
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		authority = authority:gsub ('//', '', 1);								-- replace place 1 pair of '/' with nothing;
		if is_set(authority) then												-- if anything left (1 or 3+ '/' where authority should be) then
			return scheme;														-- return scheme only making domain nil which will cause an error message
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link= etc for properly formatted content: no wikilinks, no urls

Link parameters are to hold the title of a wikipedia article so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki urls and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid url (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid url (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from url; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid url
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wikilinked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

]]

local function link_title_ok (link, lorig, title, torig)
local orig;

	if is_set (link) then 														-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		end
	end

	if is_set (orig) then
		table.insert( z.message_tail, { set_error( 'bad_paramlink', orig)});	-- url or wikilink in |title= with |title-link=;
	end
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the url into scheme and domain
portions, or for protocol relative (//example.com) urls, just the domain.  Use is_url() to validate the two
portions of the url.  If both are valid, or for protocol relative if domain is valid, return true, else false.

Because it is different from a standard url, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper url
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from url;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a url.  The test will also find external wikilinks
that use protocol relative urls. Also finds bare urls.

The frontier pattern prevents a match on interwiki links which are similar to scheme:path urls.  The tests that
find bracketed urls are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol relative ext wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare url with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol relative bare url: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a url
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then												-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source, access)
	local error_str = &quot;&quot;;
	local domain;
	local path;
	local base_url;

	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the url into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['[']='%5b',[']']='%5d'});					-- replace '[' and ']' with their percent encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wikimarkup url

	if is_set (access) then														-- access level (subscription, registration, limited)
		base_url = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end
	
	return table.concat ({base_url, error_str});
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );	-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Replaces unicode quotemarks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc; not for book titles.

]=]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	local wl_type, label, link;

	wl_type, label, link = is_wikilink (str);									-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = substitute (cfg.presentation['kern-wl-both'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = substitute (cfg.presentation['kern-wl-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = substitute (cfg.presentation['kern-wl-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label= mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label= mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap, cap2 = mw.ustring.match (label, &quot;^([\&quot;\'])([^\'].+)&quot;);				-- match leading double or single quote but not doubled single quotes (italic markup)
		if is_set (cap) then
			label = substitute (cfg.presentation['kern-left'], {cap, cap2});
		end
	
		cap, cap2 = mw.ustring.match (label, &quot;^(.+[^\'])([\&quot;\'])$&quot;)				-- match trailing double or single quote but not doubled single quotes (italic markup)
		if is_set (cap) then
			label = substitute (cfg.presentation['kern-right'], {cap, cap2});
		end
		
		if 2 == wl_type then
			str = make_wikilink (link, label);									-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title=, |script-chapter=, |script-&lt;periodical&gt;=

]]

local function format_script_value (script_value, script_param)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%l?%s*:') then									-- if first 3 or 4 non-space characters are script language prefix
		lang = script_value:match('^(%l%l%l?)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			table.insert( z.message_tail, { set_error( 'script_parameter', {script_param, 'missing title part'}, true ) } );		-- prefix without 'title'; add error message
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_code_remap[lang] or mw.language.fetchLanguageName( lang, cfg.this_wiki_code );	-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l+%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, cfg.script_lang_codes) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				table.insert( z.message_tail, { set_error( 'script_parameter', {script_param, 'unknown language code'}, true ) } );	-- unknown script-language; add error message
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			table.insert( z.message_tail, { set_error( 'script_parameter', {script_param, 'invalid language code'}, true ) } );		-- invalid language code; add error message
			lang = '';															-- invalid so set lang to empty string
		end
	else
		table.insert( z.message_tail, { set_error( 'script_parameter', {script_param, 'missing prefix'}, true ) } );				-- no language code prefix; add error message
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script, script_param)
	if is_set (script) then
		script = format_script_value (script, script_param);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return substitute( msg, str );											-- including template text
	else
		return substitute( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;----------------------------------------

makes a wikisource url from wikisource interwiki link.  returns the url and appropriate label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;
	local wikisource_prefix = table.concat ({'https://', cfg.this_wiki_code, '.wikisource.org/wiki/'});

	wl_type, D, L = is_wikilink (str);											-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if is_set (str) then
			ws_url = table.concat ({											-- build a wikisource url
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the url
		end
	elseif 1 == wl_type then													-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if is_set (str) then
			ws_url = table.concat ({											-- build a wikisource url
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the url
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a wikisource url
				wikisource_prefix,												-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end
	
	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable url
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent encoding of fragment marker
	end

	return ws_url, ws_label, L or D;											-- return proper url or nil and a label or nil
end


--[[--------------------------&lt; F O R M A T _ P E R I O D I C A L &gt;--------------------------------------------

Format the three periodical parameters: |script-&lt;periodical&gt;=, |&lt;periodical&gt;=, and |trans-&lt;periodical&gt;= into a single Periodical meta-
parameter.

]]

local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)
	local periodical_error = '';

	if not is_set (periodical) then
		periodical = '';														-- to be safe for concatenation
	else
		periodical = wrap_style ('italic-title', periodical);					-- style 
	end

	periodical = script_concatenate (periodical, script_periodical, script_periodical_source);	-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (trans_periodical) then
		trans_periodical = wrap_style ('trans-italic-title', trans_periodical);
		if is_set (periodical) then
			periodical = periodical ..  ' ' .. trans_periodical;
		else																	-- here when trans-periodical without periodical or script-periodical
			periodical = trans_periodical;
			periodical_error = ' ' .. set_error ('trans_missing_title', {'periodical'});
		end
	end

	return periodical .. periodical_error;
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (scriptchapter, script_chapter_source, chapter, transchapter, chapterurl, chapter_url_source, no_quotes, access)
	local chapter_error = '';

	local ws_url, ws_label, L = wikisource_url_make (chapter);					-- make a wikisource url and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', '');										-- replace underscore separaters with space characters
		chapter = ws_label;
	end

	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
			chapter = wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, scriptchapter, script_chapter_source);	-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (chapterurl) then
		chapter = external_link (chapterurl, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');	-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if is_set (transchapter) then
		transchapter = wrap_style ('trans-quoted-title', transchapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. transchapter;
		else																	-- here when transchapter without chapter or script-chapter
			chapter = transchapter;
			chapter_error = ' ' .. set_error ('trans_missing_title', {'chapter'});
		end
	end

	return chapter .. chapter_error;
end


--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i=1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- Test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position and (char == 'zero width joiner') then						-- if we found a zero width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- its ok if one of the indic scripts
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { set_error( 'invisible_char', {err_msg, wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i=i+1;																	-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] .. ': ' .. k);
			end
			
			-- Empty strings, not nil;
			if v == nil then
--				v = cfg.defaults[k] or '';
				v = '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set(title_type) then

	if cfg.keywords_xlate[title_type] == 'none' then
			title_type = &quot;&quot;;													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash under certain conditions.  The hyphen must separate like items; unlike items are
returned unmodified.  These forms are modified:
	letter - letter (A - B)
	digit - digit (4-5)
	digit separator digit - digit separator digit (4.1-4.5 or 4-1-4-5)
	letterdigit - letterdigit (A1-A5) (an optional separator between letter and digit is supported – a.1-a.5 or a-1-a-5)
	digitletter - digitletter (5a - 5d) (an optional separator between letter and digit is supported – 5.a-5.d or 5-a-5-d)

any other forms are returned unmodified.

str may be a comma- or semicolon-separated list

]]

local function hyphen_to_dash( str )
	if not is_set (str) then
		return str;
	end
	
	str, count = str:gsub ('^%(%((.+)%)%)$', '%1');								-- remove accept-this-as-written markup when it wraps all of str
	if 0 ~= count then															-- non-zero when markup removed; zero else
		return str;																-- nothing to do, we're done
	end
	
	str = str:gsub ('&amp;[nm]dash;', {['&amp;ndash;'] = '–', ['&amp;mdash;'] = '—'});		-- replace &amp;mdash; and &amp;ndash; entities  with their characters; semicolon mucks up the text.split
	str = str:gsub ('&amp;#45;', '-');												-- replace html numeric entity with hyphen character
	str = str:gsub ('&amp;nbsp;', ' ');												-- replace &amp;nbsp; entity with generic keyboard space character
	
	local out = {};
	local list = mw.text.split (str, '%s*[,;]%s*');								-- split str at comma or semicolon separators if there are any

	for _, item in ipairs (list) do												-- for each item in the list
		if mw.ustring.match (item, '^%w*[%.%-]?%w+%s*[%-–—]%s*%w*[%.%-]?%w+$') then	-- if a hyphenated range or has endash or emdash separators
			if item:match ('^%a+[%.%-]?%d+%s*%-%s*%a+[%.%-]?%d+$') or			-- letterdigit hyphen letterdigit (optional separator between letter and digit)
				item:match ('^%d+[%.%-]?%a+%s*%-%s*%d+[%.%-]?%a+$') or			-- digitletter hyphen digitletter (optional separator between digit and letter)
				item:match ('^%d+[%.%-]%d+%s*%-%s*%d+[%.%-]%d+$') or			-- digit separator digit hyphen digit separator digit
				item:match ('^%d+%s*%-%s*%d+$') or								-- digit hyphen digit
				item:match ('^%a+%s*%-%s*%a+$') then							-- letter hyphen letter
					item = item:gsub ('(%w*[%.%-]?%w+)%s*%-%s*(%w*[%.%-]?%w+)', '%1–%2');	-- replace hyphen, remove extraneous space characters
			else
				item = mw.ustring.gsub (item, '%s*[–—]%s*', '–');				-- for endash or emdash separated ranges, replace em with en, remove extraneous white space
			end
		end
		item = item:gsub ('^%(%((.+)%)%)$', '%1');								-- remove the accept-this-as-written markup
		table.insert (out, item);												-- add the (possibly modified) item to the output table
	end

	return table.concat (out, ', ');											-- concatenate the output table into a comma separated string
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'dupicate character'
		if 1 == #duplicate_char then											-- for single byte ascii characters use the string library functions
			f.gsub=string.gsub
			f.match=string.match
			f.sub=string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub=mw.ustring.gsub
			f.match=mw.ustring.match
			f.sub=mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1,1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = f.sub(str, -1,-1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if f.sub(str, -3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5,-1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4,-1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if f.sub(str, -3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3,-1) == duplicate_char .. '&quot;]' then		-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2,-1) == duplicate_char .. &quot;]&quot; then		-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4,-1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2,-1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows html markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;------------------------------------------------------------

returns true is suffix is properly formed Jr, Sr, or ordinal in the range 2–9.  Puncutation not allowed.

]]

local function is_suffix (suffix)
	if in_array (suffix, {'Jr', 'Sr', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written ouside of the code editor and pasted here because the code editor gets confused between character insertion point and cursor position.
The test has been rewritten to use decimal character escape sequence for the individual bytes of the unicode characters so that it is not necessary
to use an external editor to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first)
	local first, suffix = first:match ('(.-),?%s*([%dJS][%drndth]+)%.?$') or first;	-- if first has something that looks like a generational suffix, get it

	if is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error (cfg.err_msg_supl.suffix);
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error (cfg.err_msg_supl['non-Latin character']);
			return false;														-- not a string of latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just intials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error (cfg.err_msg_supl.suffix);									-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word

	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i],1,1));				-- insert the intial at end of initials table
		end
		i = i+1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between authors is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
		lastauthoramp = nil;													-- unset because isn't used by Vancouver style
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between authors is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
			end
			if is_set (person.link) then
				one = make_wikilink (person.link, one);							-- link author/editor
			end
			table.insert (text, one)
			table.insert (text, sep_one)
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end


--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]

local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of name parameters (author, editor, etc) for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the associated |display-&lt;names&gt;=etal parameter

]]

local function name_has_etal (name, etal, nocat, param)

	if is_set (name) then														-- name can be nil in which case just return
		local patterns = cfg.et_al_patterns;									--get patterns from configuration
		
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns
			if name:match (pattern) then										-- if this 'et al' pattern is found in name
				name = name:gsub (pattern, '');									-- remove the offending text
				etal = true;													-- set flag (may have been set previously here or by |display-&lt;names&gt;=etal)
				if not nocat then												-- no categorization for |vauthors=
					table.insert( z.message_tail, {set_error ('etal', {param})});	-- and set an error if not added
				end
			end
		end
	end

	return name, etal;															-- 
end


--[[--------------------------&lt; N A M E _ I S _ N U M E R I C &gt;------------------------------------------------

Add maint cat when name parameter value does not contain letters.  Does not catch mixed alphanumeric names so
|last=A. Green (1922-1987) does not get caught in the current version of this test but |first=(1888) is caught.

returns nothing

]]

local function name_is_numeric (name, list_name)
	if is_set (name) then
		if mw.ustring.match (name, '^[%A]+$') then								-- when name does not contain any letters
			add_maint_cat ('numeric_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
		end
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E D _ M A R K U P &gt;------------------------------------------

Evaluates the content of author and editor parameters for extranious editor annotations: ed, ed., eds, (Ed.), etc.
These annotation do not belong in author parameters and are redundant in editor parameters.  If found, the function
adds the editor markup maintenance category.

returns nothing

]]

local function name_has_ed_markup (name, list_name)
	local patterns = cfg.editor_markup_patterns;								-- get patterns from configuration

	if is_set (name) then
		for _, pattern in ipairs (patterns) do									-- spin through patterns table and
			if name:match (pattern) then
				add_maint_cat ('extra_text_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
				break;
			end
		end
	end
end


--[[--------------------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;----------------------------------------

Evaluates the content of author and editor (surnames only) parameters for multiple names.  Multiple names are
indicated if there is more than one comma and or semicolon.  If found, the function adds the multiple name
(author or editor) maintenance category.

returns nothing

]]

local function name_has_mult_names (name, list_name)
	local _, count;
	if is_set (name) then
		_, count = name:gsub ('[;,]', '');										-- count the number of separator-like characters
		
		if 1 &lt; count then														-- param could be |author= or |editor= so one separator character is acceptable
			add_maint_cat ('mult_names', cfg.special_case_translation [list_name]);	-- more than one separator indicates multiple names so add a maint cat for this template
		end
	end
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------

This function calls various name checking functions used to validate the content of the various name-holding
parameters.

]]

local function name_checks (last, first, list_name)
	if is_set (last) then
		if last:match ('^%(%(.*%)%)$') then										-- if wrapped in doubled parentheses, accept as written 
			last = last:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			name_has_mult_names (last, list_name);								-- check for multiple names in the parameter (last only)
			name_has_ed_markup (last, list_name);								-- check for extraneous 'editor' annotation
			name_is_numeric (last, list_name);									-- check for names that are compsed of digits and punctuation
		end
	end
	if is_set (first) then
		if first:match ('^%(%(.*%)%)$') then									-- if wrapped in doubled parentheses, accept as written 
			first = first:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			name_has_ed_markup (first, list_name);								-- check for extraneous 'editor' annotation
			name_is_numeric (first, list_name);									-- check for names that are compsed of digits and punctuation
		end
	end
	return last, first;															-- done
	end


--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local last_alias, first_alias, link_alias;									-- selected parameter aliases used in error messaging
	while true do
		last, last_alias = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first, first_alias = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link, link_alias = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.
		last, first= name_checks (last, first, list_name);						-- multiple names, extraneous annotation, etc checks
		
		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {first_alias, first_alias:gsub('first', 'last')}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			link_title_ok (link, link_alias, last, last_alias);					-- check for improper wikimarkup
			if first then
				link_title_ok (link, link_alias, first, first_alias);			-- check for improper wikimarkup
			end

			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {list_name:match (&quot;(%w+)List&quot;):lower(), i-1}, true ) } );	-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because case of the source may be incorrect
or different from the case that WikiMedia uses, the name comparisons are done in lower case and when a match is
found, the Wikimedia version (assumed to be correct) is returned along with the code.  When there is no match, we
return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') returns a list of languages that in some cases may include
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.  Most (all?) of these languages are not used a 'language' codes per se, rather they
are used as sub-domain names: cbk-zam.wikipedia.org.  A list of language names and codes supported by fetchLanguageNames()
can be found at Template:Citation Style documentation/language/doc

Names that are included in the list will be found if that name is provided in the |language= parameter.  For example,
if |language=Chavacano de Zamboanga, that name will be found with the associated code 'cbk-zam'.  When names are found
and the associated code is not two or three characters, this function returns only the WikiMedia language name.

Some language names have multiple entries under different codes:
	Aromanian has code rup and code roa-rup
When this occurs, this function returns the language name and the 2- or 3-character code

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	if cfg.lang_name_remap[lang:lower()] then									-- if there is a remapped name (because MediaWiki uses something that we don't think is correct)
		return cfg.lang_name_remap[lang:lower()][1], cfg.lang_name_remap[lang:lower()][2];	-- for this language 'name', return a possibly new name and appropriate code
	end

	local ietf_code;															-- because some languages have both ietf-like codes and iso 639-like codes
	local ietf_name;
	
	local languages = mw.language.fetchLanguageNames(this_wiki_code, 'all')		-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons

	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 == code:len() or 3 == code:len() then							-- two- or three-character codes only; extensions not supported
				return name, code;												-- so return the name and the code
			end
			ietf_code = code;													-- remember that we found an ietf-like code and save its name
			ietf_name = name;													-- but keep looking for a 2- or 3-char code
		end
	end
																				-- didn't find name with 2- or 3-char code; if ietf-like code found return
	return ietf_code and ietf_name or lang;										-- associated name; return original language text else
end


--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code is recognized by MediaWiki,
use the returned name; if not, then use the value that was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is assigned to the category for
that code: Category:Norwegian-language sources (no).  For valid three-character code languages, the page is assigned
to the single category for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does not recognize three-character
equivalents of two-character codes: code 'ar' is recognized but code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are
separated from each other by commas with optional space characters.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki_name = mw.language.fetchLanguageName(cfg.this_wiki_code, cfg.this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang
		name = cfg.lang_code_remap[lang:lower()];								-- first see if this is a code that is not supported by MediaWiki but is in remap

		if name then															-- there was a remapped code so
			if not lang:match ('^%a%a%a?%-x%-%a+$') then						-- if not a private ietf tag
				lang = lang:gsub ('^(%a%a%a?)%-.*', '%1');						-- strip ietf tags from code
			end
		else
			lang = lang:gsub ('^(%a%a%a?)%-.*', '%1');							-- strip any ietf-like tags from code
			if 2 == lang:len() or 3 == lang:len() then							-- if two-or three-character code
				name = mw.language.fetchLanguageName (lang:lower(), cfg.this_wiki_code);	-- get language name if |language= is a proper code
			end
		end

		if is_set (name) then													-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, cfg.this_wiki_code);				-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then													-- only 2- or 3-character codes
			name = cfg.lang_code_remap[code] or name;							-- override wikimedia when they misuse language codes/names

			if cfg.this_wiki_code ~= code then									-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					add_prop_cat ('foreign_lang_source' .. code, {name, code});	-- categorize it; code appended to allow for multiple language categorization
				else															-- or is a recognized language (but has a three-character code)
					add_prop_cat ('foreign_lang_source_2' .. code, {code});		-- categorize it differently TODO: support mutliple three-character code categories per cs1|2 template
				end
			elseif cfg.local_lang_cat_enable then								-- when the language and this wiki's language are the same and categorization is enabled
				add_prop_cat ('local_lang_source', {name, code});				-- categorize it
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, cfg.messages['parameter-pair-separator'])		-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		name = table.concat (language_list, cfg.messages['parameter-separator'], 1, code-1);			-- concatenate all but last
		name = table.concat ({name, language_list[code]}, cfg.messages['parameter-final-separator']);	-- concatenate last with final separator
	end
	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings
At en.wiki, for cs1:
	ps gets:	'.'
	sep gets:	'.'

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitly set to something
		ps = cfg.presentation['ps_cs1'];										-- terminate the rendered citation
	end
	return cfg.presentation['sep_cs1'], ps;										-- element separator
end


--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings
At en.wiki, for cs2:
	ps gets:	'' (empty string - no terminal punctuation)
	sep gets:	','

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = cfg.presentation['ps_cs2'];										-- terminate the rendered citation
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return cfg.presentation['sep_cs2'], ps, ref;								-- element separator
end


--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end


--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end

	if cfg.keywords_xlate[ps:lower()] == 'none' then							-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end


--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or
		url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
		url:match ('%.PDF&amp;#035') or url:match ('%.pdf&amp;#035');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parentheses, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[--------------------------&lt; G E T _ D I S P L A Y _ N A M E S &gt;--------------------------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_names (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_name', cfg.special_case_translation [list_name]);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parnetheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a place holder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parens
			local name = name_table[i];
			i=i+1;																-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parens
					break;														-- and done reassembling so
				end
				i=i+1;															-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = is_wikilink (name_table[i]);					-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i+1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parentheses to supress vanc formatting and error detection
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name:match ('^%(%((.+)%)%)$')								-- remove doubled parntheses
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error (cfg.err_msg_supl.punctuation);
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be author intials
			if is_suffix (first) then											-- if a valid suffix
				suffix = first													-- save it as a suffix and
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end																	-- no suffix error message here because letter combination may be result of Romanization; check for digits?
			last = table.concat(lastfirstTable, &quot; &quot;)							-- returns a string that is the concatenation of all other names that are not initials
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error (cfg.err_msg_supl['missing comma']);								-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error (cfg.err_msg_supl.name);										-- matches a space between two intiials
			end
		else
			first = '';															-- set to empty string for concatenation and because it may have been set for previous author/editor
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error (cfg.err_msg_supl.initials);									-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first);									-- check first and last before restoring the suffix which may have a non-Latin digit
			if is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '');
			end
		end

		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ) or v_link_table[i];
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
	local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice incase we have a |first1= without a |last1=; this ...
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or	-- ... also catches the case where |first= is used with |vauthors=
		select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, live, dead, etc).  When the parameter value has not been assigned a value (missing
or empty in the source template) the function returns the value specified by ret_val.  If the parameter value is one
of the list of allowed values returns the translated value; else, emits an error message and returns the value
specified by ret_val.

]]

local function is_valid_parameter_value (value, name, possible, ret_val)
	if not is_set (value) then
		return ret_val;															-- an empty parameter is ok
	elseif in_array (value, possible) then
		return cfg.keywords_xlate[value];										-- return translation of parameter keyword
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return ret_val;
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list,-3,-1) == sepc .. '. ') then						-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list,-1,-1) == sepc) or (string.sub (name_list,-3,-1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terninate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not is_set (volume) and not is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end

	if 'podcast' == cite_class and is_set (issue) then
		return wrap_msg ('issue', {sepc, issue}, lower);
	end

	local vol = '';																-- here for all cites except magazine
		
	if is_set (volume) then
		if volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$')then			-- volume value is all digits or all uppercase roman numerals
			vol = substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});	-- render in bold face
		elseif (4 &lt; mw.ustring.len(volume)) then								-- not all digits or roman numerals and longer than 4 characters
			vol = substitute (cfg.messages['j-vol'], {sepc, volume});			-- not bold
			add_prop_cat ('long_vol');
		else																	-- four or less characters
			vol = substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});	-- bold
		end
	end
	if is_set (issue) then
		return vol .. substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if is_set (page) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif is_set(pages) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then							-- if pages is only digits, assume a single page number
			return '', substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to wikisource, returns the label portion of the interwikilink as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki link to and external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, pages, at)
	local ws_url, ws_label, coins_pages, L;										-- for wikisource interwikilinks; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if is_set (page) then
		if is_set (pages) or is_set(at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws url from |page= interwiki link; link portion L becomes tool tip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif is_set (pages) then
		if is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws url from |pages= interwiki link; link portion L becomes tool tip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws url from |at= interwiki link; link portion L becomes tool tip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org urls to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot url or to calendar pages.  When the archive url is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the url.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org url does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command url
	|archive-url= is an archive.org url that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org urls:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this funct may return a modified
archive url:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the url unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.or url
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine url
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command url, we don't want to allow saving of the target page 
		err_msg = cfg.err_msg_supl.save;
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = cfg.err_msg_supl.liveweb;
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');	-- split out some of the url parts for evaluation
		
		if not is_set(timestamp) or 14 ~= timestamp:len() then					-- path and flag optional, must have 14-digit timestamp here
			err_msg = cfg.err_msg_supl.timestamp;
			if '*' ~= flag then
				url=url:gsub ('(//web%.archive%.org/[^%d]*%d?%d?%d?%d?%d?%d?)[^/]*', '%1*', 1)	-- for preview, modify ts to be yearmo* max (0-6 digits plus splat)
			end
		elseif is_set(path) and 'web/' ~= path then								-- older archive urls do not have the extra 'web/' path element
			err_msg = cfg.err_msg_supl.path;
		elseif is_set (flag) and not is_set (path) then							-- flag not allowed with the old form url (without the 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		elseif is_set (flag) and not flag:match ('%a%a_') then					-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		else
			return url, date;													-- return ArchiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	table.insert( z.message_tail, { set_error( 'archive_url', {err_msg}, true ) } );	-- add error message and
	if is_set (Frame:preprocess('{{REVISIONID}}')) then
		return '', '';															-- return empty strings for ArchiveURL and ArchiveDate
	else
		return url, date;														-- preview mode so return ArchiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; P L A C E _ C H E C K &gt;--------------------------------------------------------

check |place=, |publication-place=, |location= to see if these params include digits.  This function added because
many editors mis-use location to specify the in-source location (|page(s)= and |at= are supposed to do that)

returns the original parameter value without modification; added maint cat when parameter value contains digits

]]

local function place_check (param_val)
	if not is_set (param_val) then												-- parameter empty or omitted
		return param_val;														-- return that empty state
	end
	
	if mw.ustring.find (param_val, '%d') then									-- not empty, are there digits in the parameter value
		add_maint_cat ('location');												-- yep, add maint cat
	end
	
	return param_val;															-- and done
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

	local Mode = is_valid_parameter_value (A['Mode'], A:ORIGIN('Mode'), cfg.keywords_lists['mode'], '');

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;

	local NameListFormat = is_valid_parameter_value (A['NameListFormat'], A:ORIGIN('NameListFormat'), cfg.keywords_lists['name-list-format'], '');
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				add_maint_cat ('authors');										-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
			add_maint_cat ('editors');											-- but add a maint cat because use of this parameter is discouraged
		end
	end

	local translator_etal;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=

	local interviewer_etal;
	local interviewers_list = {};												
	local Interviewers;															-- used later
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters

	local contributor_etal;
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list
	local Contribution = A['Contribution'];										-- TODO: move to after chapter use if A:ORIGIN ('Chapter') ... to set Contribution; this to remove duplicate in aliases list
	if in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not is_set (Contribution) then									-- |contributor= requires |contribution=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if select_one (args, cfg.aliases['ContributorList-Last'], 'redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { set_error( 'contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if is_set (Others) then
		if 0 == #a and 0 == #e then												-- add maint cat when |others= has value and used without |author=, |editor=
			add_maint_cat ('others');
		end
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
			link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wikimarkup in |title-link= or wikimarkup in |title= when |title-link= is set

	local Chapter = A['Chapter'];												-- TODO: insert test, assignment, and then unset Chapter when |section= in cite map; test is at c. line 3220
	local ScriptChapter = A['ScriptChapter'];
	local ScriptChapterOrigin = A:ORIGIN ('ScriptChapter');
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];

	local ArchiveDate;
	local ArchiveURL;

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	
	local UrlStatus = is_valid_parameter_value (A['UrlStatus'], A:ORIGIN('UrlStatus'), cfg.keywords_lists['url-status'], '');


	local URL = A['URL']
	local URLorigin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURLorigin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURLorigin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL

																				-- TODO: mailinglist should be removed from Periodical alias list; Periodical should be assigned value from |mailinglist= here wh
	local Periodical = A['Periodical'];											-- cite mailinglist or citation and |mailinglist=; error check for duplicate work params (Periodical already set)
	local Periodical_origin = '';
		if is_set (Periodical) then
			Periodical_origin = A:ORIGIN('Periodical');							-- get the name of the periodical parameter
			local i;
			Periodical, i = strip_apostrophe_markup (Periodical);				-- strip appostrophe markup so that metadata isn't contaminated 
			if i then															-- non-zero when markup was stripped so emit an error message
				table.insert( z.message_tail, {set_error ('apostrophe_markup', {Periodical_origin}, true)});
			end
		end
																				-- TODO: mailinglist assignment here? iff Periodical not set; err msg else; see TODO c. line 2607
	local ScriptPeriodical = A['ScriptPeriodical'];
	local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');
																				-- web and news not tested for now because of 
																				-- Wikipedia:Administrators%27_noticeboard#Is_there_a_semi-automated_tool_that_could_fix_these_annoying_&quot;Cite_Web&quot;_errors?
		if not (is_set (Periodical) or is_set (ScriptPeriodical)) then			-- 'periodical' templates require periodical parameter
	--		local p = {['journal'] = 'journal', ['magazine'] = 'magazine', ['news'] = 'newspaper', ['web'] = 'website'};	-- for error message
			local p = {['journal'] = 'journal', ['magazine'] = 'magazine'};		-- for error message
			if p[config.CitationClass]  then
				table.insert( z.message_tail, {set_error ('missing_periodical', {config.CitationClass, p[config.CitationClass]}, true)});
			end
		end

	local TransPeriodical =  A['TransPeriodical'];

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if 'citation' == config.CitationClass then
		if is_set (Periodical) then
			if not in_array (Periodical_origin, {'website', 'mailinglist'}) then	-- {{citation}} does not render volume for these 'periodicals'
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		elseif is_set (ScriptPeriodical) then
			if 'script-website' ~= ScriptPeriodical_origin then					-- {{citation}} does not render volume for |script-website=
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		else
			Volume = A['Volume'];												-- and does for non-'periodical' cites
		end
	elseif in_array (config.CitationClass, cfg.templates_using_volume) then		-- render |volume= for cs1 according to the configuration settings
		Volume = A['Volume'];
	end	

	if 'citation' == config.CitationClass then
		if is_set (Periodical) and in_array (Periodical_origin, {'journal', 'magazine', 'newspaper', 'periodical', 'work'}) or	-- {{citation}} renders issue for these 'periodicals'
			is_set (ScriptPeriodical) and in_array (ScriptPeriodical_origin, {'script-journal', 'script-magazine', 'script-newspaper', 'script-periodical', 'script-work'}) then -- and these 'script-periodicals'
				Issue = hyphen_to_dash (A['Issue']);
		end
	elseif in_array (config.CitationClass, cfg.templates_using_issue) then		-- conference &amp; map books do not support issue; {{citation}} listed here because included in settings table
		if not (in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (is_set (Periodical) or is_set (ScriptPeriodical))) then
			Issue = hyphen_to_dash (A['Issue']);
		end
	end

	local Position = '';
	if not in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash (A['Pages']);	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = place_check (A['PublicationPlace'], A:ORIGIN('PublicationPlace'));
	local Place = place_check (A['Place'], A:ORIGIN('Place'));
	
	local PublisherName = A['PublisherName'];
	local PublisherName_origin = A:ORIGIN('PublisherName');
		if is_set (PublisherName) then
			local i=0;
			PublisherName, i = strip_apostrophe_markup (PublisherName);			-- strip appostrophe markup so that metadata isn't contaminated; publisher is never italicized

			if i then															-- non-zero when markup was stripped so emit an error message
				table.insert( z.message_tail, {set_error ('apostrophe_markup', {PublisherName_origin}, true)});
			end
		end

	local Newsgroup = A['Newsgroup'];											-- TODO: strip apostrophe markup?
	local Newsgroup_origin = A:ORIGIN('Newsgroup');	

	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then											-- general use parmeter |publisher= not allowed in cite newsgroup
			local error_text = set_error ('parameter_ignored', {PublisherName_origin}, true);
			if is_set (error_text) then
				table.insert( z.message_tail, {error_text, error_state} );
			end				
		end

		PublisherName = nil;													-- ensure that this parameter is unset for the time being; will be used again after COinS
	end

	local UrlAccess = is_valid_parameter_value (A['UrlAccess'], A:ORIGIN('UrlAccess'), cfg.keywords_lists['url-access'], nil);
		if not is_set(URL) and is_set(UrlAccess) then
			UrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {'url'}, true ) } );
		end
		
	local ChapterUrlAccess = is_valid_parameter_value (A['ChapterUrlAccess'], A:ORIGIN('ChapterUrlAccess'), cfg.keywords_lists['url-access'], nil);
		if not is_set(ChapterURL) and is_set(ChapterUrlAccess) then
			ChapterUrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {A:ORIGIN('ChapterUrlAccess'):gsub ('%-access', '')}, true ) } );
		end

	local MapUrlAccess = is_valid_parameter_value (A['MapUrlAccess'], A:ORIGIN('MapUrlAccess'), cfg.keywords_lists['url-access'], nil);
		if not is_set(A['MapURL']) and is_set(MapUrlAccess) then
			MapUrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {'map-url'}, true ) } );
		end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local Agency = A['Agency'];

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = is_valid_parameter_value (A['IgnoreISBN'], A:ORIGIN('IgnoreISBN'), cfg.keywords_lists['yes_true_y'], nil);
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );
		if is_set (DoiBroken) and not ID_list['DOI'] then
			table.insert( z.message_tail, { set_error( 'doibroken_missing_doi', A:ORIGIN('DoiBroken'))});
		end
	local ID_access_levels = extract_id_access_levels( args, ID_list );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURLorigin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = is_valid_parameter_value (A['LastAuthorAmp'], A:ORIGIN('LastAuthorAmp'), cfg.keywords_lists['yes_true_y'], nil);

	local no_tracking_cats = is_valid_parameter_value (A['NoTracking'], A:ORIGIN('NoTracking'), cfg.keywords_lists['yes_true_y'], nil);

	--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = is_valid_parameter_value (A['DF'], A:ORIGIN('DF'), cfg.keywords_lists['df'], '');
	if not is_set (DF) then
		DF = cfg.global_df;														-- local df if present overrides global df set by {{use xxx date}} template
	end

	local sepc;																	-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref = A['Ref'];
	if 'harv' == Ref then
		add_maint_cat ('ref_harv');												-- add maint cat to identify templates that have this now-extraneous param value
	elseif not is_set (Ref) then
		Ref = 'harv';															-- set as default when not set externally
	end
	
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], Ref, config.CitationClass);
	use_lowercase = ( sepc == ',' );											-- used to control capitalization for certain static text

	--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end
																				-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	select_one (args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'redundant_parameters');	-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, Pages, At);

	local NoPP = is_valid_parameter_value (A['NoPP'], A:ORIGIN('NoPP'), cfg.keywords_lists['yes_true_y'], nil);

	if is_set (PublicationPlace) and is_set (Place) then						-- both |publication-place= and |place= (|location=) allowed if different
		add_prop_cat ('location test');											-- add property cat to evaluate how often PublicationPlace and Place are used together
		if PublicationPlace == Place then
			Place = '';															-- unset; don't need both if they are the same
		end
	elseif not is_set (PublicationPlace) and is_set (Place) then				-- when only |place= (|location=) is set ...
		PublicationPlace = Place;												-- promote |place= (|location=) to |publication-place
	end

	if PublicationPlace == Place then Place = ''; end							-- don't need both if they are the same
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia and |title then map |title to |article and |encyclopedia to |title
		|encyclopedia and |article then map |encyclopedia to |title

		|trans-title maps to |trans-chapter when |title is re-mapped
		|url maps to |chapterurl when |title is remapped
	
	All other combinations of |encyclopedia, |title, and |article are not modified
	
	]]

	local Encyclopedia = A['Encyclopedia'];

	if ( config.CitationClass == &quot;encyclopaedia&quot; ) or ( config.CitationClass == &quot;citation&quot; and is_set (Encyclopedia)) then	-- test code for citation
		if is_set (Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					ScriptChapterOrigin = A:ORIGIN('ScriptTitle')
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterURLorigin = A:ORIGIN('URL')

					ChapterUrlAccess = UrlAccess;

					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter = make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			elseif is_set (Chapter) then										-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if is_set(A['Number']) then												-- cite techreport uses 'number', which other citations alias to 'issue'
			if not is_set(ID) then												-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', 'id') .. ' and ' .. wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

	-- special case for cite mailing list
	if (config.CitationClass == &quot;mailinglist&quot;) then								-- TODO: move this to Periodical assignment; see TODOs at c. line 2360
		Periodical = A ['MailingList'];
	elseif 'mailinglist' == Periodical_origin then
		Periodical = '';														-- unset because mailing list is only used for cite mailing list
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
	--		ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURLorigin = URLorigin;
			URLorigin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			Title = BookTitle;
			Format = '';
	--		TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		Chapter = A['Map'];
		ChapterURL = A['MapURL'];
		ChapterURLorigin = A:ORIGIN('MapURL');
		TransChapter = A['TransMap'];
		ScriptChapter = A['ScriptMap']
		ScriptChapterOrigin = A:ORIGIN('ScriptMap')

		ChapterUrlAccess = MapUrlAccess;
		ChapterFormat = A['MapFormat'];

		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local SeriesLink = A['SeriesLink'];

		link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wikimarkup in |series-link= or wikimarkup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('seriesnum', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ScriptChapterOrigin = A:ORIGIN('ScriptTitle');
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURLorigin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = make_wikilink (ChapterLink, Chapter);
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = make_wikilink (SeriesLink, Series);
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite ssrn}}, before generation of COinS data.
	do
		if in_array (config.CitationClass, whitelist.preprint_template_list) then
			if not is_set (ID_list[config.CitationClass:upper()]) then			-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp; |citeseerx= required for their templates
				table.insert( z.message_tail, { set_error( config.CitationClass .. '_missing', {}, true ) } );	-- add error message
			end

			Periodical = ({['arxiv'] = 'arXiv', ['biorxiv'] = 'bioRxiv', ['citeseerx'] = 'CiteSeerX', ['ssrn'] = 'Social Science Research Network'})[config.CitationClass];
		end
	end

	-- handle type parameter for those CS1 citations that have default values
	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;interview&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
		TitleType = substitute( cfg.messages['type'], TitleType);				-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging

	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val=AccessDate, name=A:ORIGIN ('AccessDate')},
			['archive-date'] = {val=ArchiveDate, name=A:ORIGIN ('ArchiveDate')},
			['date'] = {val=Date, name=Date_origin},
			['doi-broken-date'] = {val=DoiBroken, name=A:ORIGIN ('DoiBroken')},
			['embargo'] = {val=Embargo, name=A:ORIGIN ('Embargo')},
			['lay-date'] = {val=LayDate, name=A:ORIGIN ('LayDate')},
			['publication-date'] ={val=PublicationDate, name=A:ORIGIN ('PublicationDate')},
			['year'] = {val=Year, name=A:ORIGIN ('Year')},
			};
		anchor_year, Embargo, error_message = dates(date_parameters_list, COinS_date);

-- start temporary Julian / Gregorian calendar uncertainty categorization
		if COinS_date.inter_cal_cat then
			add_prop_cat ('jul_greg_uncertainty');
		end
-- end temporary Julian / Gregorian calendar uncertainty categorization

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end
		
		if not is_set(error_message) then										-- error free dates only
			local modified = false;												-- flag
			
			if is_set (DF) then													-- if we need to reformat dates
				modified = reformat_dates (date_parameters_list, DF, false);	-- reformat to DF format, use long month names if appropriate
			end

			if true == date_hyphen_to_dash (date_parameters_list) then			-- convert hyphens to dashes where appropriate
				modified = true;
				add_maint_cat ('date_format');									-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language,
	-- uncomment these three lines.  Not supported by en.wiki (for obvious reasons)
	-- set date_name_xlate() second argument to true to translate English digits to local digits (will translate ymd dates)
	--		if date_name_xlate (date_parameters_list, false) then
	--			modified = true;
	--		end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				LayDate = date_parameters_list['lay-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end
		else
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end
	end	-- end of do

	-- Account for the oddity that is {{cite journal}} with |pmc= set and |url= not set.  Do this after date check but before COInS.
	-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);

	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and is_set(ID_list['PMC']) then
		if not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URLorigin = cfg.id_handlers['PMC'].parameters[1];					-- set URLorigin to parameter name for use in error message if citation is missing a |title=
			if is_set(AccessDate) then											-- access date requires |url=; pmc created url is not |url=
				table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
				AccessDate = '';												-- unset
			end

		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and
		not is_set(TransTitle) and
		not is_set(ScriptTitle) then
			if 'episode' == config.CitationClass then							-- special case for cite episode; TODO: is there a better way to do this?
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'series'}, true ) } );
			else
				table.insert( z.message_tail, { set_error( 'citation_missing_title', {'title'}, true ) } );
			end
	end

	if cfg.keywords_xlate[Title] == 'none' and
			in_array (config.CitationClass, {'journal', 'citation'}) and
			(is_set (Periodical) or is_set (ScriptPeriodical)) and
			('journal' == Periodical_origin or 'script-journal' == ScriptPeriodical_origin) then	-- special case for journal cites
				Title = '';														-- set title to empty string
				add_maint_cat ('untitled');
	end

	check_for_url ({															-- add error message when any of these parameters hold a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[Periodical_origin] = Periodical,
		[PublisherName_origin] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end
	
	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = strip_apostrophe_markup (Periodical),					-- no markup in the metadata
		['Encyclopedia'] = strip_apostrophe_markup (Encyclopedia),
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = coins_pages or get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName or Newsgroup,							-- any apostrophe markup already removed from PublisherName
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, and {{cite ssrn}} AFTER generation of COinS data.
	if in_array (config.CitationClass, whitelist.preprint_template_list) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, CiteSeerX, or ssrn now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass and is_set (Newsgroup) then
		PublisherName = substitute (cfg.messages['newsgroup'], external_link( 'news:' .. Newsgroup, Newsgroup, Newsgroup_origin, nil ));
	end

	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_names (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if is_set (Editors) then
				Editors, editor_etal = name_has_etal (Editors, editor_etal, false, 'editors');	-- find and remove variations on et al.
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
				end
				EditorCount = 2;												-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum , interviewer_etal = get_display_names (A['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal);
			Interviewers = list_people (control, interviewers_list, interviewer_etal);
		end
		do																		-- now do translators
			control.maximum , translator_etal = get_display_names (A['DisplayTranslators'], #t, 'translators', translator_etal);
			Translators = list_people (control, t, translator_etal);
		end
		do																		-- now do contributors
			control.maximum , contributor_etal = get_display_names (A['DisplayContributors'], #c, 'contributors', contributor_etal);
			Contributors = list_people (control, c, contributor_etal);
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_names (A['DisplayAuthors'], #a, 'authors', author_etal);

			last_first_list = list_people(control, a, author_etal);

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors');	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if is_set (Authors) and is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
	-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (is_set (Periodical) or is_set (ScriptPeriodical)) and not is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not is_set(URL) then
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) or		-- |url= required for cite web, cite podcast, and cite mailinglist
			('citation' == config.CitationClass and ('website' == Periodical_origin or 'script-website' == ScriptPeriodical_origin)) then	-- and required for {{citation}} with |website= or |script-website=
				table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURLorigin, OriginalFormat, OriginalAccess;
	UrlStatus = UrlStatus:lower();												-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (ChapterURL) then 											-- if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURLorigin = ChapterURLorigin;								-- name of chapter-url parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=

			if 'live' ~= UrlStatus then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				ChapterURLorigin = A:ORIGIN('ArchiveURL')						-- name of archive-url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived urls
			end
		elseif is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURLorigin = URLorigin;										-- name of url parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;

			if 'live' ~= UrlStatus then											-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URLorigin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived urls
			end
 		end
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and (is_set (Periodical) or is_set (ScriptPeriodical)) and not is_set (Encyclopedia)) then
			local chap_param;
			if is_set (Chapter) then											-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif is_set (ScriptChapter) then
				chap_param = ScriptChapterOrigin;
			else is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if is_set (chap_param) then											-- if we found one
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {chap_param}, true ) } );		-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if is_set (Contribution) and 0 &lt; #c then								-- if this is a contribution with contributor(s)
			if in_array (Contribution:lower(), cfg.keywords_lists.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, ScriptChapterOrigin, Chapter, TransChapter, ChapterURL, ChapterURLorigin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter.. sepc .. ' ';
		elseif is_set (ChapterFormat) then										-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title.	TODO: add support for non-English versions of 'Archived copy' when used on other-language wikis 
	if is_set (ArchiveURL) and 
		(mw.ustring.match (mw.ustring.lower(Title), cfg.special_case_translation.archived_copy.en) or	-- if title is 'Archived copy' (place holder added by bots that can't find proper title)
		mw.ustring.match (mw.ustring.lower(Title), cfg.special_case_translation.archived_copy['local'])) then	-- local-wiki's form
			add_maint_cat ('archived_copy');									-- add maintenance category before we modify the content of Title
	end

	if Title:match ('^%(%(.*%)%)$') then										-- if keep as written markup:
		Title= Title:gsub ('^%(%((.*)%)%)$', '%1')								-- remove the markup
	else
		if '...' == Title:sub (-3) then											-- if elipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%'..sepc..'$', '');				-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end
	end

	if in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (is_set (Periodical) or is_set (ScriptPeriodical)) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and (is_set (Periodical) or is_set (ScriptPeriodical))) then		-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle, 'script-title');	-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end

	if is_set (Title) then														-- TODO: is this the right place to be making wikisource urls?
		if not is_set (TitleLink) and is_set (URL) then
			Title = external_link (URL, Title, URLorigin, UrlAccess) .. TransTitle .. TransError .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif is_set (TitleLink) and not is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = make_wikilink (TitleLink, Title) .. TransTitle .. TransError;
			end
		else
			local ws_url, ws_label;												-- Title has italic or quote markup by the time we get here which causes is_wikilink() to return 0 (not a wikilink)
			ws_url, ws_label, L = wikisource_url_make (Title:gsub('[\'&quot;](.-)[\'&quot;]', '%1'));	-- make ws url from |title= interwiki link (strip italic or quote markup); link portion L becomes tool tip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = Title .. TransTitle .. TransError;
			end
		end
	else
		Title = TransTitle .. TransError;
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURLorigin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURLorigin, nil );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if is_set(Minutes) then
			if is_set (Time) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'minutes') .. ' and ' .. wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then										-- TODO copy this line and
		local Section = A['Section'];											-- TODO move this line to c. line 2337 so that separate Sections in aliases{} not required? then unset Chapter?
		local Sections = A['Sections'];
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = is_set (Series) and wrap_msg ('series', {sepc, Series}) or &quot;&quot;;		-- not the same as SeriesNum
	OrigYear = is_set (OrigYear) and wrap_msg ('origyear', OrigYear) or '';
	Agency = is_set (Agency) and wrap_msg ('agency', {sepc, Agency}) or &quot;&quot;;
	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	Via = is_set (Via) and  wrap_msg ('via', Via) or '';

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text

		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {IdAccessLevels=ID_access_levels, DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URLorigin, UrlAccess );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then				-- if first and last characters of quote are quote marks
			Quote = Quote:sub(2,-2);											-- strip them off
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		local arch_text;
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;live&quot; == UrlStatus then
			arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-live'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil ) .. ArchiveFormat, ArchiveDate } );
			if not is_set (OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- UrlStatus is empty, 'dead', 'unfit', 'usurped', 'bot: unknown'
			if in_array (UrlStatus, {'unfit', 'usurped', 'bot: unknown'}) then
				arch_text = cfg.messages['archived-unfit'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. &quot; &quot; .. arch_text .. ArchiveDate;				-- format already styled
				if 'bot: unknown' == UrlStatus then
					add_maint_cat ('bot:_unknown');								-- and add a category if not already added
				else
					add_maint_cat ('unfit');									-- and add a category if not already added
				end
			else																-- UrlStatus is empty, 'dead'
				arch_text = cfg.messages['archived-dead'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURLorigin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else																	-- OriginalUrl not set
			arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURLorigin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURLorigin, nil );
	end

	local Publisher;
	if is_set(PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if is_set(PublisherName) then
		if is_set(PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif is_set(PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if (is_set (Periodical) or is_set (ScriptPeriodical) or is_set (TransPeriodical)) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical);
		else 
			Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical);
		end
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then									-- cite speech only
		TitleNote = &quot; (Speech)&quot;;												-- annotate the citation
		if is_set (Periodical) then												-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then											-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;							-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = safe_join ({Others, sepc .. &quot; &quot;}, sepc) end		-- add terminal punctuation &amp; space; check for dup sepc; TODO why do we need to do this here?
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(Periodical) then		-- special cases for book cites
		if is_set (Contributors) then											-- when we are citing foreword, preface, introduction, etc
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon;
	if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then	-- special case for cite AV media &amp; cite episode position transcript
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, Lay, Quote }, sepc );
	else
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, Lay, Quote }, sepc );
	end
	
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if is_set(Date) then
		if is_set (Authors) or is_set (Editors) then							-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;;				-- in paranetheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon,-1,-1) == sepc) then							-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigYear;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigYear;							-- Date begins with sepc
			end
		end
	end	
	if is_set(Authors) then
		if (not is_set (Date)) then												-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then
					in_text = in_text:lower()									-- lowercase for cs2
				end
			end
			if EditorCount &lt;= 1 then
				post_text = &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot;;				-- be consistent with no-author, no-date case
			else
				post_text = &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot;;
			end
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if is_set (Contributors) then											-- book cite and we're citing the intro, preface, etc
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if is_set (Editors) and is_set (Date) then							-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not is_set (Date)) then											-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc ); 								--Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = config.CitationClass;
		options.class = &quot;citation &quot; .. config.CitationClass;					-- class=citation required for blue highlight when used with |ref=
	else
		options.class = &quot;citation&quot;;
	end
	
	if is_set(Ref) and 'none' ~= cfg.keywords_xlate[Ref:lower()] then
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			if #namelist &gt; 0 then												-- if there are names in namelist
				id = anchor_id (namelist, year);								-- go make the CITEREF anchor
			else
				id = '';														-- unset
			end
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;(.-)&lt;/span&gt;&quot;, &quot;%1&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then	-- remove &lt;span&gt; tags and other html-like markup; then get length of what remains
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	local render = {};															-- here we collect the final bits for concatenation into the rendered citation

	if is_set(options.id) then													-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render, substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text}));	-- when |ref= is set
	else
		table.insert (render, substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text}));	-- all other cases
	end		

	table.insert (render, substitute (cfg.presentation['ocins'], {OCinSoutput}));	-- append metadata to the citation

	if 0 ~= #z.message_tail then
		table.insert (render, ' ');
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					table.insert (render, error_comment( v[1], v[2] ));
				else
					table.insert (render, error_comment( v[1] .. &quot;; &quot;, v[2] ));
				end
			end
		end
	end

	if 0 ~= #z.maintenance_cats then
		local maint_msgs = {};													-- here we collect all of the maint messages
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			local maint = {};													-- here we assemble a maintenence message
			table.insert (maint, v);											-- maint msg is the category name
			table.insert (maint, ' (');											-- open the link text
			table.insert (maint, make_wikilink (':Category:' .. v, 'link'));	-- add the link
			table.insert (maint, ')');											-- and close it
			table.insert (maint_msgs, table.concat (maint));					-- assemble new maint message and add it to the maint_msgs table
		end
		table.insert (render, substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs, ' ')));	-- wrap the group of maint message with proper presentation and save
	end
	
	if not no_tracking_cats then
		for _, v in ipairs( z.error_categories ) do
			table.insert (render, make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			table.insert (render, make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.properties_cats ) do								-- append properties categories
			table.insert (render, make_wikilink ('Category:' .. v));
		end
	end

	return table.concat (render);	
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class)
	local name = tostring (name);
	local state;
	local function state_test (state, name)										-- local function to do testing of state values
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
		return nil;
	end		

	if name:find ('#') then														-- # is a cs1|2 reserved character so parameters with # not permitted
		return nil;
	end

	if in_array (cite_class, whitelist.preprint_template_list ) then			-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[name];
		if true == state_test (state, name) then return true; end

		state = whitelist.preprint_arguments[cite_class][name];					-- look in the parameter-list for the template identified by cite_class
		if true == state_test (state, name) then return true; end

																				-- limited enumerated parameters list
		name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
		state = whitelist.limited_numbered_arguments[name];
		if true == state_test (state, name) then return true; end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates

	if in_array (cite_class, whitelist.unique_param_template_list) then			-- experiment for template-specific parameters for templates that accept parameters from the basic argument list
		state = whitelist.unique_arguments[cite_class][name];					-- look in the template-specific parameter-lists for the template identified by cite_class
		if true == state_test (state, name) then return true; end
	end																			-- if here, fall into general validation
		
	state = whitelist.basic_arguments[name];									-- all other templates; all normal parameters allowed
	if true == state_test (state, name) then return true; end

																				-- all enumerated parameters allowed
	name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );												-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
	state = whitelist.numbered_arguments[name];
	if true == state_test (state, name) then return true; end

	return false;																-- not supported because not found or name is set to nil
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe:
	{{cite ... |title=Title access-date=2016-03-17}}

cs1|2 shares some parameter names with xml/html atributes: class=, title=, etc.  To prevent false positives xml/html
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (parameter, value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove xml/html tags because attributes: class=, title=, etc 

	capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then								-- if the capture is a valid parameter name
		table.insert( z.message_tail, {set_error ('missing_pipe',parameter)});
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ P U N C T &gt;--------------------------------------

look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_punc (param, value)
	if cfg.punct_skip[param] then
		return;																	-- parameter name found in the skip table so done
	end
	
	if value:match ('[,;:]$') then
		add_maint_cat ('extra_punct');											-- has extraneous punctuation; add maint cat
	end
end


--[[--------------------------&lt; C I T A T I O N &gt;--------------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

local function citation(frame)
	Frame = frame;																-- save a copy incase we need to display an error message in preview mode
	local pframe = frame:getParent()
	local validation, utilities, identifiers, metadata, styles;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		styles = 'Module:Citation/CS1/sandbox/styles.css';
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
		styles = 'Module:Citation/CS1/styles.css';

	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	dates = validation.dates;													-- imported functions from Module:Citation/CS1/Date validation
	year_date_check = validation.year_date_check;
	reformat_dates = validation.reformat_dates;
	date_hyphen_to_dash = validation.date_hyphen_to_dash;
	date_name_xlate = validation.date_name_xlate;

	is_set = utilities.is_set;													-- imported functions from Module:Citation/CS1/Utilities
	in_array = utilities.in_array;
	substitute = utilities.substitute;
	error_comment = utilities.error_comment;
	set_error = utilities.set_error;
	select_one = utilities.select_one;
	add_maint_cat = utilities.add_maint_cat;
	wrap_style = utilities.wrap_style;
	safe_for_italics = utilities.safe_for_italics;
	is_wikilink = utilities.is_wikilink;
	make_wikilink = utilities.make_wikilink;
	strip_apostrophe_markup = utilities.strip_apostrophe_markup;

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	extract_ids = identifiers.extract_ids;										-- imported functions from Module:Citation/CS1/Identifiers
	build_id_list = identifiers.build_id_list;
	is_embargoed = identifiers.is_embargoed;
	extract_id_access_levels = identifiers.extract_id_access_levels;
	
	make_coins_title = metadata.make_coins_title;								-- imported functions from Module:Citation/CS1/COinS
	get_coins_pages = metadata.get_coins_pages;
	COinS = metadata.COinS;

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text, error_state;

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do
		config[k] = v;
--		args[k] = v;															-- debug tool that allows us to render a citation from module {{#invoke:}}
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower(), config.CitationClass ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute (param, capture);				-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text, error_state = set_error ('parameter_ignored_suggest', {k, param}, true);	-- set the suggestion error message
							else
								error_text, error_state = set_error( 'parameter_ignored', {param}, true );	-- suggested param not supported by this template
								v = '';											-- unset
							end
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end
			missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?
																				-- TODO: is this the best place for this translation?
			args[k] = v;
		elseif args[k] ~= nil or (k == 'postscript') then						-- here when v is empty string
			args[k] = v;														-- why do we do this?  we don't support 'empty' parameters
		end		
	end	

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);
			has_extraneous_punc (k, v);											-- look for extraneous terminal punctuation in parameter values
		end
	end

	return table.concat ({citation0( config, args), frame:extensionTag ('templatestyles', '', {src=styles})});
end

--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {citation = citation};</text>
      <sha1>17ti8zx1nn1o0u381j04ctr9nfjwvis</sha1>
    </revision>
    <revision>
      <id>4731</id>
      <parentid>4730</parentid>
      <timestamp>2020-07-11T13:18:16Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4731</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="190168" sha1="nxhv2t6y6ntvoshbmqrbk8i5k1gs9ko" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local dates, year_date_check, reformat_dates, date_hyphen_to_dash,				-- functions in Module:Citation/CS1/Date_validation
	date_name_xlate

local is_set, in_array, substitute, error_comment, set_error, select_one,		-- functions in Module:Citation/CS1/Utilities
	add_maint_cat, wrap_style, safe_for_italics, is_wikilink, make_wikilink,
	strip_apostrophe_markup;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local extract_ids, extract_id_access_levels, build_id_list, is_embargoed;		-- functions in Module:Citation/CS1/Identifiers

local make_coins_title, get_coins_pages, COinS;									-- functions in Module:Citation/CS1/COinS

local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

declare variables here that have page-wide scope that are not brought in from other modules; that are created here and used here

]]

local added_deprecated_cat;														-- boolean flag so that the category is added only once
local added_prop_cats = {};														-- list of property categories that have been added to z.properties_cats
local added_vanc_errs;															-- boolean flag so we only emit one Vancouver error / category

local Frame;																	-- holds the module's frame table


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

foreign_lang_source and foreign_lang_source_2 keys have a language code appended to them so that multiple languages
may be categorized but multiples of the same language are not categorized.

added_prop_cats is a table declared in page scope variables above

]]

local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		key = key:gsub ('(foreign_lang_source_?2?)%a%a%a?[%a%-]*', '%1');		-- strip lang code from keyname
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));	-- make name then add to table
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a boolean declared in page scope variables above

]]

local function add_vanc_error (source)
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {source}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a uri scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of tlds: https://www.iana.org/domains/root/db

rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the tld.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a url with a scheme) will be stripped
here.  Perhaps not necessary but retained incase it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ascii characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the tld) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and tld or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%w]') then											-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at wikisource
		return false;
	end

	local patterns = {															-- patterns that look like urls
		'%f[%w][%w][%w%-]+[%w]%.%a%a+$',										-- three or more character hostname.hostname or hostname.tld
		'%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$',									-- internationalized domain name with ACE prefix
		'%f[%a][qxz]%.com$',													-- assigned one character .com hostname (x.com times out 2015-12-10)
		'%f[%a][iq]%.net$',														-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		'%f[%w][%w]%.%a%a$',													-- one character hostname and cctld (2 chars)
		'%f[%w][%w][%w]%.%a%a+$',												-- two character hostname and tld
		'^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?',								-- IPv4 address
		}

	for _, pattern in ipairs (patterns) do										-- loop through the patterns list
		if domain:match (pattern) then
			return true;														-- if a match then we think that this thing that purports to be a url is a url
		end
	end

	for _, d in ipairs ({'cash', 'company', 'today', 'org'}) do					-- look for single letter second level domain names for these top level domains
		if domain:match ('%f[%w][%w]%.' .. d) then
			return true
		end
	end
	return false;																-- no matches, we don't know what this thing is
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a url appear to be a valid url; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if is_set (scheme) then														-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when url is protocol relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a url into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following tld) (if any) and any path(/), query(?) or fragment(#).

If protocol relative url, return nil scheme and domain else return nil for both scheme and domain.

When not protocol relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol relative url
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		authority = authority:gsub ('//', '', 1);								-- replace place 1 pair of '/' with nothing;
		if is_set(authority) then												-- if anything left (1 or 3+ '/' where authority should be) then
			return scheme;														-- return scheme only making domain nil which will cause an error message
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link= etc for properly formatted content: no wikilinks, no urls

Link parameters are to hold the title of a wikipedia article so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki urls and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid url (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid url (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from url; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid url
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wikilinked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

]]

local function link_title_ok (link, lorig, title, torig)
local orig;

	if is_set (link) then 														-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		end
	end

	if is_set (orig) then
		table.insert( z.message_tail, { set_error( 'bad_paramlink', orig)});	-- url or wikilink in |title= with |title-link=;
	end
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the url into scheme and domain
portions, or for protocol relative (//example.com) urls, just the domain.  Use is_url() to validate the two
portions of the url.  If both are valid, or for protocol relative if domain is valid, return true, else false.

Because it is different from a standard url, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper url
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from url;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a url.  The test will also find external wikilinks
that use protocol relative urls. Also finds bare urls.

The frontier pattern prevents a match on interwiki links which are similar to scheme:path urls.  The tests that
find bracketed urls are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol relative ext wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare url with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol relative bare url: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a url
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then												-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source, access)
	local error_str = &quot;&quot;;
	local domain;
	local path;
	local base_url;

	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the url into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['[']='%5b',[']']='%5d'});					-- replace '[' and ']' with their percent encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wikimarkup url

	if is_set (access) then														-- access level (subscription, registration, limited)
		base_url = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end
	
	return table.concat ({base_url, error_str});
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );	-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Replaces unicode quotemarks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc; not for book titles.

]=]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	local wl_type, label, link;

	wl_type, label, link = is_wikilink (str);									-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = substitute (cfg.presentation['kern-wl-both'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = substitute (cfg.presentation['kern-wl-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = substitute (cfg.presentation['kern-wl-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label= mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label= mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap, cap2 = mw.ustring.match (label, &quot;^([\&quot;\'])([^\'].+)&quot;);				-- match leading double or single quote but not doubled single quotes (italic markup)
		if is_set (cap) then
			label = substitute (cfg.presentation['kern-left'], {cap, cap2});
		end
	
		cap, cap2 = mw.ustring.match (label, &quot;^(.+[^\'])([\&quot;\'])$&quot;)				-- match trailing double or single quote but not doubled single quotes (italic markup)
		if is_set (cap) then
			label = substitute (cfg.presentation['kern-right'], {cap, cap2});
		end
		
		if 2 == wl_type then
			str = make_wikilink (link, label);									-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title=, |script-chapter=, |script-&lt;periodical&gt;=

]]

local function format_script_value (script_value, script_param)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%l?%s*:') then									-- if first 3 or 4 non-space characters are script language prefix
		lang = script_value:match('^(%l%l%l?)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			table.insert( z.message_tail, { set_error( 'script_parameter', {script_param, 'missing title part'}, true ) } );		-- prefix without 'title'; add error message
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_code_remap[lang] or mw.language.fetchLanguageName( lang, cfg.this_wiki_code );	-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l+%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, cfg.script_lang_codes) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				table.insert( z.message_tail, { set_error( 'script_parameter', {script_param, 'unknown language code'}, true ) } );	-- unknown script-language; add error message
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			table.insert( z.message_tail, { set_error( 'script_parameter', {script_param, 'invalid language code'}, true ) } );		-- invalid language code; add error message
			lang = '';															-- invalid so set lang to empty string
		end
	else
		table.insert( z.message_tail, { set_error( 'script_parameter', {script_param, 'missing prefix'}, true ) } );				-- no language code prefix; add error message
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script, script_param)
	if is_set (script) then
		script = format_script_value (script, script_param);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return substitute( msg, str );											-- including template text
	else
		return substitute( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;----------------------------------------

makes a wikisource url from wikisource interwiki link.  returns the url and appropriate label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;
	local wikisource_prefix = table.concat ({'https://', cfg.this_wiki_code, '.wikisource.org/wiki/'});

	wl_type, D, L = is_wikilink (str);											-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if is_set (str) then
			ws_url = table.concat ({											-- build a wikisource url
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the url
		end
	elseif 1 == wl_type then													-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if is_set (str) then
			ws_url = table.concat ({											-- build a wikisource url
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the url
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a wikisource url
				wikisource_prefix,												-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end
	
	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable url
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent encoding of fragment marker
	end

	return ws_url, ws_label, L or D;											-- return proper url or nil and a label or nil
end


--[[--------------------------&lt; F O R M A T _ P E R I O D I C A L &gt;--------------------------------------------

Format the three periodical parameters: |script-&lt;periodical&gt;=, |&lt;periodical&gt;=, and |trans-&lt;periodical&gt;= into a single Periodical meta-
parameter.

]]

local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)
	local periodical_error = '';

	if not is_set (periodical) then
		periodical = '';														-- to be safe for concatenation
	else
		periodical = wrap_style ('italic-title', periodical);					-- style 
	end

	periodical = script_concatenate (periodical, script_periodical, script_periodical_source);	-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (trans_periodical) then
		trans_periodical = wrap_style ('trans-italic-title', trans_periodical);
		if is_set (periodical) then
			periodical = periodical ..  ' ' .. trans_periodical;
		else																	-- here when trans-periodical without periodical or script-periodical
			periodical = trans_periodical;
			periodical_error = ' ' .. set_error ('trans_missing_title', {'periodical'});
		end
	end

	return periodical .. periodical_error;
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (script_chapter, script_chapter_source, chapter, chapter_source, trans_chapter, trans_chapter_source, chapter_url, chapter_url_source, no_quotes, access)
	local chapter_error = '';

	local ws_url, ws_label, L = wikisource_url_make (chapter);					-- make a wikisource url and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', '');										-- replace underscore separaters with space characters
		chapter = ws_label;
	end

	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
			chapter = wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, script_chapter, script_chapter_source);	-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (chapter_url) then
		chapter = external_link (chapter_url, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');	-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if is_set (trans_chapter) then
		trans_chapter = wrap_style ('trans-quoted-title', trans_chapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. trans_chapter;
		else																	-- here when trans_chapter without chapter or script-chapter
			chapter = trans_chapter;
			chapter_source = trans_chapter_source:match ('trans%-?(.+)');		-- when no chapter, get matching name from trans-&lt;param&gt;
			chapter_error = ' ' .. set_error ('trans_missing_title', {chapter_source});
		end
	end

	return chapter .. chapter_error;
end


--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i=1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- Test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position and (char == 'zero width joiner') then						-- if we found a zero width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- its ok if one of the indic scripts
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { set_error( 'invisible_char', {err_msg, wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i=i+1;																	-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] .. ': ' .. k);
			end
			
			-- Empty strings, not nil;
			if v == nil then
--				v = cfg.defaults[k] or '';
				v = '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set (title_type) then
		if 'none' == cfg.keywords_xlate[title_type] then
			title_type = '';													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash under certain conditions.  The hyphen must separate like items; unlike items are
returned unmodified.  These forms are modified:
	letter - letter (A - B)
	digit - digit (4-5)
	digit separator digit - digit separator digit (4.1-4.5 or 4-1-4-5)
	letterdigit - letterdigit (A1-A5) (an optional separator between letter and digit is supported – a.1-a.5 or a-1-a-5)
	digitletter - digitletter (5a - 5d) (an optional separator between letter and digit is supported – 5.a-5.d or 5-a-5-d)

any other forms are returned unmodified.

str may be a comma- or semicolon-separated list

]]

local function hyphen_to_dash( str )
	if not is_set (str) then
		return str;
	end
	
	str, count = str:gsub ('^%(%((.+)%)%)$', '%1');								-- remove accept-this-as-written markup when it wraps all of str
	if 0 ~= count then															-- non-zero when markup removed; zero else
		return str;																-- nothing to do, we're done
	end
	
	str = str:gsub ('&amp;[nm]dash;', {['&amp;ndash;'] = '–', ['&amp;mdash;'] = '—'});		-- replace &amp;mdash; and &amp;ndash; entities  with their characters; semicolon mucks up the text.split
	str = str:gsub ('&amp;#45;', '-');												-- replace html numeric entity with hyphen character
	str = str:gsub ('&amp;nbsp;', ' ');												-- replace &amp;nbsp; entity with generic keyboard space character
	
	local out = {};
	local list = mw.text.split (str, '%s*[,;]%s*');								-- split str at comma or semicolon separators if there are any

	for _, item in ipairs (list) do												-- for each item in the list
		if mw.ustring.match (item, '^%w*[%.%-]?%w+%s*[%-–—]%s*%w*[%.%-]?%w+$') then	-- if a hyphenated range or has endash or emdash separators
			if item:match ('^%a+[%.%-]?%d+%s*%-%s*%a+[%.%-]?%d+$') or			-- letterdigit hyphen letterdigit (optional separator between letter and digit)
				item:match ('^%d+[%.%-]?%a+%s*%-%s*%d+[%.%-]?%a+$') or			-- digitletter hyphen digitletter (optional separator between digit and letter)
				item:match ('^%d+[%.%-]%d+%s*%-%s*%d+[%.%-]%d+$') or			-- digit separator digit hyphen digit separator digit
				item:match ('^%d+%s*%-%s*%d+$') or								-- digit hyphen digit
				item:match ('^%a+%s*%-%s*%a+$') then							-- letter hyphen letter
					item = item:gsub ('(%w*[%.%-]?%w+)%s*%-%s*(%w*[%.%-]?%w+)', '%1–%2');	-- replace hyphen, remove extraneous space characters
			else
				item = mw.ustring.gsub (item, '%s*[–—]%s*', '–');				-- for endash or emdash separated ranges, replace em with en, remove extraneous white space
			end
		end
		item = item:gsub ('^%(%((.+)%)%)$', '%1');								-- remove the accept-this-as-written markup
		table.insert (out, item);												-- add the (possibly modified) item to the output table
	end

	return table.concat (out, ', ');											-- concatenate the output table into a comma separated string
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'dupicate character'
		if 1 == #duplicate_char then											-- for single byte ascii characters use the string library functions
			f.gsub=string.gsub
			f.match=string.match
			f.sub=string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub=mw.ustring.gsub
			f.match=mw.ustring.match
			f.sub=mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1,1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = f.sub(str, -1,-1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if f.sub(str, -3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5,-1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4,-1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if f.sub(str, -3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3,-1) == duplicate_char .. '&quot;]' then		-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2,-1) == duplicate_char .. &quot;]&quot; then		-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4,-1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2,-1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows html markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;------------------------------------------------------------

returns true is suffix is properly formed Jr, Sr, or ordinal in the range 2–9.  Puncutation not allowed.

]]

local function is_suffix (suffix)
	if in_array (suffix, {'Jr', 'Sr', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written ouside of the code editor and pasted here because the code editor gets confused between character insertion point and cursor position.
The test has been rewritten to use decimal character escape sequence for the individual bytes of the unicode characters so that it is not necessary
to use an external editor to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first, suffix)
	if not suffix then
		if first:find ('[,%s]') then											-- when there is a space or comma, might be first name/initials + generational suffix
			first = first:match ('(.-)[,%s]+');									-- get name/initials
			suffix = first:match ('[,%s]+(.+)$');								-- get generational suffix
		end
	end
	if is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error (cfg.err_msg_supl.suffix);
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error (cfg.err_msg_supl['non-Latin char']);
			return false;														-- not a string of latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just intials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error (cfg.err_msg_supl.suffix);					-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word

	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i],1,1));				-- insert the intial at end of initials table
		end
		i = i+1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between authors is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
		lastauthoramp = nil;													-- unset because isn't used by Vancouver style
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between authors is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
			end
			if is_set (person.link) then
				one = make_wikilink (person.link, one);							-- link author/editor
			end
			table.insert (text, one)
			table.insert (text, sep_one)
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end


--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]

local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of name parameters (author, editor, etc) for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the associated |display-&lt;names&gt;=etal parameter

]]

local function name_has_etal (name, etal, nocat, param)

	if is_set (name) then														-- name can be nil in which case just return
		local patterns = cfg.et_al_patterns;									--get patterns from configuration
		
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns
			if name:match (pattern) then										-- if this 'et al' pattern is found in name
				name = name:gsub (pattern, '');									-- remove the offending text
				etal = true;													-- set flag (may have been set previously here or by |display-&lt;names&gt;=etal)
				if not nocat then												-- no categorization for |vauthors=
					table.insert( z.message_tail, {set_error ('etal', {param})});	-- and set an error if not added
				end
			end
		end
	end

	return name, etal;															-- 
end


--[[--------------------------&lt; N A M E _ I S _ N U M E R I C &gt;------------------------------------------------

Add maint cat when name parameter value does not contain letters.  Does not catch mixed alphanumeric names so
|last=A. Green (1922-1987) does not get caught in the current version of this test but |first=(1888) is caught.

returns nothing

]]

local function name_is_numeric (name, list_name)
	if is_set (name) then
		if mw.ustring.match (name, '^[%A]+$') then								-- when name does not contain any letters
			add_maint_cat ('numeric_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
		end
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E D _ M A R K U P &gt;------------------------------------------

Evaluates the content of author and editor parameters for extranious editor annotations: ed, ed., eds, (Ed.), etc.
These annotation do not belong in author parameters and are redundant in editor parameters.  If found, the function
adds the editor markup maintenance category.

returns nothing

]]

local function name_has_ed_markup (name, list_name)
	local patterns = cfg.editor_markup_patterns;								-- get patterns from configuration

	if is_set (name) then
		for _, pattern in ipairs (patterns) do									-- spin through patterns table and
			if name:match (pattern) then
				add_maint_cat ('extra_text_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
				break;
			end
		end
	end
end


--[[--------------------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;----------------------------------------

Evaluates the content of author and editor (surnames only) parameters for multiple names.  Multiple names are
indicated if there is more than one comma and or semicolon.  If found, the function adds the multiple name
(author or editor) maintenance category.

returns nothing

]]

local function name_has_mult_names (name, list_name)
	local _, count;
	if is_set (name) then
		_, count = name:gsub ('[;,]', '');										-- count the number of separator-like characters
		
		if 1 &lt; count then														-- param could be |author= or |editor= so one separator character is acceptable
			add_maint_cat ('mult_names', cfg.special_case_translation [list_name]);	-- more than one separator indicates multiple names so add a maint cat for this template
		end
	end
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------

This function calls various name checking functions used to validate the content of the various name-holding
parameters.

]]

local function name_checks (last, first, list_name)
	if is_set (last) then
		if last:match ('^%(%(.*%)%)$') then										-- if wrapped in doubled parentheses, accept as written 
			last = last:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			name_has_mult_names (last, list_name);								-- check for multiple names in the parameter (last only)
			name_has_ed_markup (last, list_name);								-- check for extraneous 'editor' annotation
			name_is_numeric (last, list_name);									-- check for names that are compsed of digits and punctuation
		end
	end
	if is_set (first) then
		if first:match ('^%(%(.*%)%)$') then									-- if wrapped in doubled parentheses, accept as written 
			first = first:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			name_has_ed_markup (first, list_name);								-- check for extraneous 'editor' annotation
			name_is_numeric (first, list_name);									-- check for names that are compsed of digits and punctuation
		end
	end
	return last, first;															-- done
	end


--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local last_alias, first_alias, link_alias;									-- selected parameter aliases used in error messaging
	while true do
		last, last_alias = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first, first_alias = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link, link_alias = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.
		last, first= name_checks (last, first, list_name);						-- multiple names, extraneous annotation, etc checks
		
		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {first_alias, first_alias:gsub('first', 'last')}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			link_title_ok (link, link_alias, last, last_alias);					-- check for improper wikimarkup
			if first then
				link_title_ok (link, link_alias, first, first_alias);			-- check for improper wikimarkup
			end

			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {list_name:match (&quot;(%w+)List&quot;):lower(), i-1}, true ) } );	-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because case of the source may be incorrect
or different from the case that WikiMedia uses, the name comparisons are done in lower case and when a match is
found, the Wikimedia version (assumed to be correct) is returned along with the code.  When there is no match, we
return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') returns a list of languages that in some cases may include
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.  Most (all?) of these languages are not used a 'language' codes per se, rather they
are used as sub-domain names: cbk-zam.wikipedia.org.  A list of language names and codes supported by fetchLanguageNames()
can be found at Template:Citation Style documentation/language/doc

Names that are included in the list will be found if that name is provided in the |language= parameter.  For example,
if |language=Chavacano de Zamboanga, that name will be found with the associated code 'cbk-zam'.  When names are found
and the associated code is not two or three characters, this function returns only the WikiMedia language name.

Some language names have multiple entries under different codes:
	Aromanian has code rup and code roa-rup
When this occurs, this function returns the language name and the 2- or 3-character code

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	if cfg.lang_name_remap[lang:lower()] then									-- if there is a remapped name (because MediaWiki uses something that we don't think is correct)
		return cfg.lang_name_remap[lang:lower()][1], cfg.lang_name_remap[lang:lower()][2];	-- for this language 'name', return a possibly new name and appropriate code
	end

	local ietf_code;															-- because some languages have both ietf-like codes and iso 639-like codes
	local ietf_name;
	
	local languages = mw.language.fetchLanguageNames(this_wiki_code, 'all')		-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons

	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 == code:len() or 3 == code:len() then							-- two- or three-character codes only; extensions not supported
				return name, code;												-- so return the name and the code
			end
			ietf_code = code;													-- remember that we found an ietf-like code and save its name
			ietf_name = name;													-- but keep looking for a 2- or 3-char code
		end
	end
																				-- didn't find name with 2- or 3-char code; if ietf-like code found return
	return ietf_code and ietf_name or lang;										-- associated name; return original language text else
end


--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code is recognized by MediaWiki,
use the returned name; if not, then use the value that was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is assigned to the category for
that code: Category:Norwegian-language sources (no).  For valid three-character code languages, the page is assigned
to the single category for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does not recognize three-character
equivalents of two-character codes: code 'ar' is recognized but code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are
separated from each other by commas with optional space characters.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki_name = mw.language.fetchLanguageName(cfg.this_wiki_code, cfg.this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang
		name = cfg.lang_code_remap[lang:lower()];								-- first see if this is a code that is not supported by MediaWiki but is in remap

		if name then															-- there was a remapped code so
			if not lang:match ('^%a%a%a?%-x%-%a+$') then						-- if not a private ietf tag
				lang = lang:gsub ('^(%a%a%a?)%-.*', '%1');						-- strip ietf tags from code
			end
		else
			lang = lang:gsub ('^(%a%a%a?)%-.*', '%1');							-- strip any ietf-like tags from code
			if 2 == lang:len() or 3 == lang:len() then							-- if two-or three-character code
				name = mw.language.fetchLanguageName (lang:lower(), cfg.this_wiki_code);	-- get language name if |language= is a proper code
			end
		end

		if is_set (name) then													-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, cfg.this_wiki_code);				-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then													-- only 2- or 3-character codes
			name = cfg.lang_code_remap[code] or name;							-- override wikimedia when they misuse language codes/names

			if cfg.this_wiki_code ~= code then									-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					add_prop_cat ('foreign_lang_source' .. code, {name, code});	-- categorize it; code appended to allow for multiple language categorization
				else															-- or is a recognized language (but has a three-character code)
					add_prop_cat ('foreign_lang_source_2' .. code, {code});		-- categorize it differently TODO: support multiple three-character code categories per cs1|2 template
				end
			elseif cfg.local_lang_cat_enable then								-- when the language and this wiki's language are the same and categorization is enabled
				add_prop_cat ('local_lang_source', {name, code});				-- categorize it
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, cfg.messages['parameter-pair-separator'])		-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		name = table.concat (language_list, cfg.messages['parameter-separator'], 1, code-1);			-- concatenate all but last
		name = table.concat ({name, language_list[code]}, cfg.messages['parameter-final-separator']);	-- concatenate last with final separator
	end
	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings
At en.wiki, for cs1:
	ps gets:	'.'
	sep gets:	'.'

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitly set to something
		ps = cfg.presentation['ps_cs1'];										-- terminate the rendered citation
	end
	return cfg.presentation['sep_cs1'], ps;										-- element separator
end


--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings
At en.wiki, for cs2:
	ps gets:	'' (empty string - no terminal punctuation)
	sep gets:	','

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = cfg.presentation['ps_cs2'];										-- terminate the rendered citation
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return cfg.presentation['sep_cs2'], ps, ref;								-- element separator
end


--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end


--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end

	if cfg.keywords_xlate[ps:lower()] == 'none' then							-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end


--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or
		url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
		url:match ('%.PDF&amp;#035') or url:match ('%.pdf&amp;#035');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parentheses, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[--------------------------&lt; G E T _ D I S P L A Y _ N A M E S &gt;--------------------------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_names (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_name', cfg.special_case_translation [list_name]);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parnetheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a place holder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parens
			local name = name_table[i];
			i=i+1;																-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parens
					break;														-- and done reassembling so
				end
				i=i+1;															-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = is_wikilink (name_table[i]);					-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i+1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		first = '';																-- set to empty string for concatenation and because it may have been set for previous author/editor
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parentheses to supress vanc formatting and error detection
			last = v_name:match ('^%(%((.+)%)%)$')								-- remove doubled parntheses
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error (cfg.err_msg_supl.punctuation);
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s+&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be intials or generational suffix

			if not mw.ustring.match (first, '^%u+$') then						-- mw.ustring here so that later we will catch non-latin characters
				suffix = first;													-- not initials so assume that whatever we got is a generational suffix
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end
			last = table.concat(lastfirstTable, ' ')							-- returns a string that is the concatenation of all other names that are not initials and generational suffix
			if not is_set (last) then
				first = '';														-- unset
				last = v_name;													-- last empty because something wrong with first
				add_vanc_error (cfg.err_msg_supl.name);
			end
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error (cfg.err_msg_supl['missing comma']);				-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error (cfg.err_msg_supl.name);							-- matches a space between two intiials
			end
		else
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error (cfg.err_msg_supl.initials);						-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first, suffix);							-- check first and last before restoring the suffix which may have a non-Latin digit
			if is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '');
			end
		end

		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ) or v_link_table[i];
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
	local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice incase we have a |first1= without a |last1=; this ...
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or	-- ... also catches the case where |first= is used with |vauthors=
		select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, live, dead, etc).  When the parameter value has not been assigned a value (missing
or empty in the source template) the function returns the value specified by ret_val.  If the parameter value is one
of the list of allowed values returns the translated value; else, emits an error message and returns the value
specified by ret_val.

]]

local function is_valid_parameter_value (value, name, possible, ret_val)
	if not is_set (value) then
		return ret_val;															-- an empty parameter is ok
	elseif in_array (value, possible) then
		return cfg.keywords_xlate[value];										-- return translation of parameter keyword
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return ret_val;
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list,-3,-1) == sepc .. '. ') then						-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list,-1,-1) == sepc) or (string.sub (name_list,-3,-1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terninate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not is_set (volume) and not is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end

	if 'podcast' == cite_class and is_set (issue) then
		return wrap_msg ('issue', {sepc, issue}, lower);
	end

	local vol = '';																-- here for all cites except magazine
		
	if is_set (volume) then
		if volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$')then			-- volume value is all digits or all uppercase roman numerals
			vol = substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});	-- render in bold face
		elseif (4 &lt; mw.ustring.len(volume)) then								-- not all digits or roman numerals and longer than 4 characters
			vol = substitute (cfg.messages['j-vol'], {sepc, volume});			-- not bold
			add_prop_cat ('long_vol');
		else																	-- four or less characters
			vol = substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});	-- bold
		end
	end
	if is_set (issue) then
		return vol .. substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if is_set (page) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif is_set(pages) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then							-- if pages is only digits, assume a single page number
			return '', substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to wikisource, returns the label portion of the interwikilink as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki link to and external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, pages, at)
	local ws_url, ws_label, coins_pages, L;										-- for wikisource interwikilinks; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if is_set (page) then
		if is_set (pages) or is_set(at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws url from |page= interwiki link; link portion L becomes tool tip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif is_set (pages) then
		if is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws url from |pages= interwiki link; link portion L becomes tool tip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws url from |at= interwiki link; link portion L becomes tool tip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org urls to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot url or to calendar pages.  When the archive url is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the url.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org url does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command url
	|archive-url= is an archive.org url that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org urls:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this funct may return a modified
archive url:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the url unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.or url
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine url
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command url, we don't want to allow saving of the target page 
		err_msg = cfg.err_msg_supl.save;
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = cfg.err_msg_supl.liveweb;
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');	-- split out some of the url parts for evaluation
		
		if not is_set(timestamp) or 14 ~= timestamp:len() then					-- path and flag optional, must have 14-digit timestamp here
			err_msg = cfg.err_msg_supl.timestamp;
			if '*' ~= flag then
				url=url:gsub ('(//web%.archive%.org/[^%d]*%d?%d?%d?%d?%d?%d?)[^/]*', '%1*', 1)	-- for preview, modify ts to be yearmo* max (0-6 digits plus splat)
			end
		elseif is_set(path) and 'web/' ~= path then								-- older archive urls do not have the extra 'web/' path element
			err_msg = cfg.err_msg_supl.path;
		elseif is_set (flag) and not is_set (path) then							-- flag not allowed with the old form url (without the 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		elseif is_set (flag) and not flag:match ('%a%a_') then					-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		else
			return url, date;													-- return ArchiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	table.insert( z.message_tail, { set_error( 'archive_url', {err_msg}, true ) } );	-- add error message and
	if is_set (Frame:preprocess('{{REVISIONID}}')) then
		return '', '';															-- return empty strings for ArchiveURL and ArchiveDate
	else
		return url, date;														-- preview mode so return ArchiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; P L A C E _ C H E C K &gt;--------------------------------------------------------

check |place=, |publication-place=, |location= to see if these params include digits.  This function added because
many editors mis-use location to specify the in-source location (|page(s)= and |at= are supposed to do that)

returns the original parameter value without modification; added maint cat when parameter value contains digits

]]

local function place_check (param_val)
	if not is_set (param_val) then												-- parameter empty or omitted
		return param_val;														-- return that empty state
	end
	
	if mw.ustring.find (param_val, '%d') then									-- not empty, are there digits in the parameter value
		add_maint_cat ('location');												-- yep, add maint cat
	end
	
	return param_val;															-- and done
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

	local Mode = is_valid_parameter_value (A['Mode'], A:ORIGIN('Mode'), cfg.keywords_lists['mode'], '');

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;

	local NameListFormat = is_valid_parameter_value (A['NameListFormat'], A:ORIGIN('NameListFormat'), cfg.keywords_lists['name-list-format'], '');
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				add_maint_cat ('authors');										-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
			add_maint_cat ('editors');											-- but add a maint cat because use of this parameter is discouraged
		end
	end

	local translator_etal;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=

	local interviewer_etal;
	local interviewers_list = {};												
	local Interviewers;															-- used later
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters

	local contributor_etal;
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list

	local Chapter = A['Chapter'];												-- done here so that we have access to |contribution= from |chapter= aliases
	local Chapter_origin = A:ORIGIN ('Chapter');
	local Contribution;															-- because contribution is required for contributor(s)
		if 'contribution' == A:ORIGIN ('Chapter') then
			Contribution = A['Chapter'];										-- get the name of the contribution
		end

	if in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not is_set (Contribution) then									-- |contributor= requires |contribution=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if select_one (args, cfg.aliases['ContributorList-Last'], 'redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { set_error( 'contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if is_set (Others) then
		if 0 == #a and 0 == #e then												-- add maint cat when |others= has value and used without |author=, |editor=
			add_maint_cat ('others');
		end
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TransTitle_origin = A:ORIGIN ('TransTitle');
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
			link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wikimarkup in |title-link= or wikimarkup in |title= when |title-link= is set

	local Section = '';															-- {{cite map}} only; preset to empty string for concatnation if not used
		if 'map' == config.CitationClass and 'section' == A:ORIGIN ('Chapter') then
			Section = A['Chapter'];												-- get |section= from |chapter= alias list; |chapter= and the other aliases not supported in {{cite map}}
			Chapter = '';														-- unset for now; will be reset later from |map= if present
		end

	local ScriptChapter = A['ScriptChapter'];
	local ScriptChapter_origin = A:ORIGIN ('ScriptChapter');
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TransChapter_origin = A:ORIGIN ('TransChapter');
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];

	local ArchiveDate;
	local ArchiveURL;

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	
	local UrlStatus = is_valid_parameter_value (A['UrlStatus'], A:ORIGIN('UrlStatus'), cfg.keywords_lists['url-status'], '');


	local URL = A['URL']
	local URL_origin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURL_origin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURL_origin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL

	local Periodical = A['Periodical'];
	local Periodical_origin = '';
		if is_set (Periodical) then
			Periodical_origin = A:ORIGIN('Periodical');							-- get the name of the periodical parameter
			local i;
			Periodical, i = strip_apostrophe_markup (Periodical);				-- strip appostrophe markup so that metadata isn't contaminated 
			if i then															-- non-zero when markup was stripped so emit an error message
				table.insert( z.message_tail, {set_error ('apostrophe_markup', {Periodical_origin}, true)});
			end
		end

	if 'mailinglist' == config.CitationClass then								-- special case for {{cite mailing list}}
		if is_set (Periodical) and is_set (A ['MailingList']) then						-- both set emit an error
			table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', Periodical_origin) .. ' and ' .. wrap_style ('parameter', 'mailinglist')}, true )});
		end

		Periodical = A ['MailingList'];											-- error or no, set Periodical to |mailinglist= value because this template is {{cite mailing list}}
		Periodical_origin = A:ORIGIN('MailingList');
	end



																				
	local ScriptPeriodical = A['ScriptPeriodical'];
	local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');
																				-- web and news not tested for now because of 
																				-- Wikipedia:Administrators%27_noticeboard#Is_there_a_semi-automated_tool_that_could_fix_these_annoying_&quot;Cite_Web&quot;_errors?
		if not (is_set (Periodical) or is_set (ScriptPeriodical)) then			-- 'periodical' templates require periodical parameter
	--		local p = {['journal'] = 'journal', ['magazine'] = 'magazine', ['news'] = 'newspaper', ['web'] = 'website'};	-- for error message
			local p = {['journal'] = 'journal', ['magazine'] = 'magazine'};		-- for error message
			if p[config.CitationClass]  then
				table.insert( z.message_tail, {set_error ('missing_periodical', {config.CitationClass, p[config.CitationClass]}, true)});
			end
		end

	local TransPeriodical =  A['TransPeriodical'];
	local TransPeriodical_origin =  A:ORIGIN ('TransPeriodical');

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if 'citation' == config.CitationClass then
		if is_set (Periodical) then
			if not in_array (Periodical_origin, {'website', 'mailinglist'}) then	-- {{citation}} does not render volume for these 'periodicals'
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		elseif is_set (ScriptPeriodical) then
			if 'script-website' ~= ScriptPeriodical_origin then					-- {{citation}} does not render volume for |script-website=
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		else
			Volume = A['Volume'];												-- and does for non-'periodical' cites
		end
	elseif in_array (config.CitationClass, cfg.templates_using_volume) then		-- render |volume= for cs1 according to the configuration settings
		Volume = A['Volume'];
	end	

	if 'citation' == config.CitationClass then
		if is_set (Periodical) and in_array (Periodical_origin, {'journal', 'magazine', 'newspaper', 'periodical', 'work'}) or	-- {{citation}} renders issue for these 'periodicals'
			is_set (ScriptPeriodical) and in_array (ScriptPeriodical_origin, {'script-journal', 'script-magazine', 'script-newspaper', 'script-periodical', 'script-work'}) then -- and these 'script-periodicals'
				Issue = hyphen_to_dash (A['Issue']);
		end
	elseif in_array (config.CitationClass, cfg.templates_using_issue) then		-- conference &amp; map books do not support issue; {{citation}} listed here because included in settings table
		if not (in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (is_set (Periodical) or is_set (ScriptPeriodical))) then
			Issue = hyphen_to_dash (A['Issue']);
		end
	end

	local Position = '';
	if not in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash (A['Pages']);	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = place_check (A['PublicationPlace'], A:ORIGIN('PublicationPlace'));
	local Place = place_check (A['Place'], A:ORIGIN('Place'));
	
	local PublisherName = A['PublisherName'];
	local PublisherName_origin = A:ORIGIN('PublisherName');
		if is_set (PublisherName) then
			local i=0;
			PublisherName, i = strip_apostrophe_markup (PublisherName);			-- strip appostrophe markup so that metadata isn't contaminated; publisher is never italicized

			if i then															-- non-zero when markup was stripped so emit an error message
				table.insert( z.message_tail, {set_error ('apostrophe_markup', {PublisherName_origin}, true)});
			end
		end

	local Newsgroup = A['Newsgroup'];											-- TODO: strip apostrophe markup?
	local Newsgroup_origin = A:ORIGIN('Newsgroup');	

	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then											-- general use parmeter |publisher= not allowed in cite newsgroup
			local error_text = set_error ('parameter_ignored', {PublisherName_origin}, true);
			if is_set (error_text) then
				table.insert( z.message_tail, {error_text, error_state} );
			end				
		end

		PublisherName = nil;													-- ensure that this parameter is unset for the time being; will be used again after COinS
	end

	local UrlAccess = is_valid_parameter_value (A['UrlAccess'], A:ORIGIN('UrlAccess'), cfg.keywords_lists['url-access'], nil);
		if not is_set(URL) and is_set(UrlAccess) then
			UrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {'url'}, true ) } );
		end
		
	local ChapterUrlAccess = is_valid_parameter_value (A['ChapterUrlAccess'], A:ORIGIN('ChapterUrlAccess'), cfg.keywords_lists['url-access'], nil);
		if not is_set(ChapterURL) and is_set(ChapterUrlAccess) then
			ChapterUrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {A:ORIGIN('ChapterUrlAccess'):gsub ('%-access', '')}, true ) } );
		end

	local MapUrlAccess = is_valid_parameter_value (A['MapUrlAccess'], A:ORIGIN('MapUrlAccess'), cfg.keywords_lists['url-access'], nil);
		if not is_set(A['MapURL']) and is_set(MapUrlAccess) then
			MapUrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {'map-url'}, true ) } );
		end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local Agency = A['Agency'];

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = is_valid_parameter_value (A['IgnoreISBN'], A:ORIGIN('IgnoreISBN'), cfg.keywords_lists['yes_true_y'], nil);
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );
		if is_set (DoiBroken) and not ID_list['DOI'] then
			table.insert( z.message_tail, { set_error( 'doibroken_missing_doi', A:ORIGIN('DoiBroken'))});
		end
	local ID_access_levels = extract_id_access_levels( args, ID_list );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURL_origin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = is_valid_parameter_value (A['LastAuthorAmp'], A:ORIGIN('LastAuthorAmp'), cfg.keywords_lists['yes_true_y'], nil);

	local no_tracking_cats = is_valid_parameter_value (A['NoTracking'], A:ORIGIN('NoTracking'), cfg.keywords_lists['yes_true_y'], nil);

	--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = is_valid_parameter_value (A['DF'], A:ORIGIN('DF'), cfg.keywords_lists['df'], '');
	if not is_set (DF) then
		DF = cfg.global_df;														-- local df if present overrides global df set by {{use xxx date}} template
	end

	local sepc;																	-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref = A['Ref'];
	if 'harv' == Ref then
		add_maint_cat ('ref_harv');												-- add maint cat to identify templates that have this now-extraneous param value
	elseif not is_set (Ref) then
		Ref = 'harv';															-- set as default when not set externally
	end
	
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], Ref, config.CitationClass);
	use_lowercase = ( sepc == ',' );											-- used to control capitalization for certain static text

	--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end
																				-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	select_one (args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'redundant_parameters');	-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, Pages, At);

	local NoPP = is_valid_parameter_value (A['NoPP'], A:ORIGIN('NoPP'), cfg.keywords_lists['yes_true_y'], nil);

	if is_set (PublicationPlace) and is_set (Place) then						-- both |publication-place= and |place= (|location=) allowed if different
		add_prop_cat ('location test');											-- add property cat to evaluate how often PublicationPlace and Place are used together
		if PublicationPlace == Place then
			Place = '';															-- unset; don't need both if they are the same
		end
	elseif not is_set (PublicationPlace) and is_set (Place) then				-- when only |place= (|location=) is set ...
		PublicationPlace = Place;												-- promote |place= (|location=) to |publication-place
	end

	if PublicationPlace == Place then Place = ''; end							-- don't need both if they are the same
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia and |title then map |title to |article and |encyclopedia to |title
		|encyclopedia and |article then map |encyclopedia to |title

		|trans-title maps to |trans-chapter when |title is re-mapped
		|url maps to |chapterurl when |title is remapped
	
	All other combinations of |encyclopedia, |title, and |article are not modified
	
	]]

	local Encyclopedia = A['Encyclopedia'];										-- used as a flag by this module and by ~/COinS

	if is_set (Encyclopedia) then												-- emit error message when Encyclopedia set but template is other than {{cite encyclopedia}} or {{citation}}
		if 'encyclopaedia' ~= config.CitationClass and 'citation' ~= config.CitationClass then
			table.insert (z.message_tail, {set_error ('parameter_ignored', {A:ORIGIN ('Encyclopedia')}, true)});
			Encyclopedia = nil;													-- unset because not supported by this template
		end
	end

	if ('encyclopaedia' == config.CitationClass) or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Periodical) and is_set (Encyclopedia) then					-- when both set emit an error
			table.insert (z.message_tail, {set_error('redundant_parameters', {wrap_style ('parameter', A:ORIGIN ('Encyclopedia')) .. ' and ' .. wrap_style ('parameter', Periodical_origin)}, true )});
		end

		if is_set (Encyclopedia) then
			Periodical = Encyclopedia;											-- error or no, set Periodical to Encyclopedia; allow periodical without encyclopedia
			Periodical_origin = A:ORIGIN ('Encyclopedia');
		end

		if is_set (Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					ScriptChapter_origin = A:ORIGIN('ScriptTitle')
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterURL_origin = A:ORIGIN('URL')

					ChapterUrlAccess = UrlAccess;

					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter = make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			elseif is_set (Chapter) then										-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if is_set(A['Number']) then												-- cite techreport uses 'number', which other citations alias to 'issue'
			if not is_set(ID) then												-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', 'id') .. ' and ' .. wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
			Chapter_origin = 'title';
	--		ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			URL_origin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			TransChapter_origin = TransTitle_origin;
			Title = BookTitle;
			Format = '';
	--		TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		if is_set (Chapter) then
			table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'map') .. ' and ' .. wrap_style ('parameter', Chapter_origin)}, true ) } );	-- add error message
		end
		Chapter = A['Map'];
		Chapter_origin = A:ORIGIN('Map');
		ChapterURL = A['MapURL'];
		ChapterURL_origin = A:ORIGIN('MapURL');
		TransChapter = A['TransMap'];
		ScriptChapter = A['ScriptMap']
		ScriptChapter_origin = A:ORIGIN('ScriptMap')

		ChapterUrlAccess = MapUrlAccess;
		ChapterFormat = A['MapFormat'];

		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local SeriesLink = A['SeriesLink'];

		link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wikimarkup in |series-link= or wikimarkup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('seriesnum', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ScriptChapter_origin = A:ORIGIN('ScriptTitle');
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = make_wikilink (ChapterLink, Chapter);
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = make_wikilink (SeriesLink, Series);
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite ssrn}}, before generation of COinS data.
	do
		if in_array (config.CitationClass, whitelist.preprint_template_list) then
			if not is_set (ID_list[config.CitationClass:upper()]) then			-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp; |citeseerx= required for their templates
				table.insert( z.message_tail, { set_error( config.CitationClass .. '_missing', {}, true ) } );	-- add error message
			end

			Periodical = ({['arxiv'] = 'arXiv', ['biorxiv'] = 'bioRxiv', ['citeseerx'] = 'CiteSeerX', ['ssrn'] = 'Social Science Research Network'})[config.CitationClass];
		end
	end

	-- handle type parameter for those CS1 citations that have default values
	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;interview&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
		TitleType = substitute( cfg.messages['type'], TitleType);				-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging

	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val=AccessDate, name=A:ORIGIN ('AccessDate')},
			['archive-date'] = {val=ArchiveDate, name=A:ORIGIN ('ArchiveDate')},
			['date'] = {val=Date, name=Date_origin},
			['doi-broken-date'] = {val=DoiBroken, name=A:ORIGIN ('DoiBroken')},
			['embargo'] = {val=Embargo, name=A:ORIGIN ('Embargo')},
			['lay-date'] = {val=LayDate, name=A:ORIGIN ('LayDate')},
			['publication-date'] ={val=PublicationDate, name=A:ORIGIN ('PublicationDate')},
			['year'] = {val=Year, name=A:ORIGIN ('Year')},
			};
		anchor_year, Embargo, error_message = dates(date_parameters_list, COinS_date);

-- start temporary Julian / Gregorian calendar uncertainty categorization
		if COinS_date.inter_cal_cat then
			add_prop_cat ('jul_greg_uncertainty');
		end
-- end temporary Julian / Gregorian calendar uncertainty categorization

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end
		
		if not is_set(error_message) then										-- error free dates only
			local modified = false;												-- flag
			
			if is_set (DF) then													-- if we need to reformat dates
				modified = reformat_dates (date_parameters_list, DF, false);	-- reformat to DF format, use long month names if appropriate
			end

			if true == date_hyphen_to_dash (date_parameters_list) then			-- convert hyphens to dashes where appropriate
				modified = true;
				add_maint_cat ('date_format');									-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language,
	-- uncomment these three lines.  Not supported by en.wiki (for obvious reasons)
	-- set date_name_xlate() second argument to true to translate English digits to local digits (will translate ymd dates)
	--		if date_name_xlate (date_parameters_list, false) then
	--			modified = true;
	--		end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				LayDate = date_parameters_list['lay-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end
		else
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end
	end	-- end of do

	-- Link the title of the work if no |url= was provided, but we have a |pmc= or a |doi= with |doi-access=free
	-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);
	
	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and not is_set(TitleLink) then
		if is_set(ID_list['PMC']) and not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URL_origin = cfg.id_handlers['PMC'].parameters[1];					-- set URL_origin to parameter name for use in error message if citation is missing a |title=
		elseif is_set(ID_list['DOI']) and ID_access_levels['DOI'] == &quot;free&quot; then
			URL=cfg.id_handlers['DOI'].prefix .. ID_list['DOI'];
			URL_origin = cfg.id_handlers['DOI'].parameters[1];
		end
		if is_set(URL) and is_set(AccessDate) then								-- access date requires |url=; pmc or doi created url is not |url=
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';												-- unset
		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and not is_set(TransTitle) and not is_set(ScriptTitle) then	-- has special case for cite episode
		table.insert( z.message_tail, { set_error( 'citation_missing_title', {'episode' == config.CitationClass and 'series' or 'title'}, true ) } );
	end

	if cfg.keywords_xlate[Title] == 'none' and
			in_array (config.CitationClass, {'journal', 'citation'}) and
			(is_set (Periodical) or is_set (ScriptPeriodical)) and
			('journal' == Periodical_origin or 'script-journal' == ScriptPeriodical_origin) then	-- special case for journal cites
				Title = '';														-- set title to empty string
				add_maint_cat ('untitled');
	end

	check_for_url ({															-- add error message when any of these parameters hold a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[Periodical_origin] = Periodical,
		[PublisherName_origin] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end
	
	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = strip_apostrophe_markup (Periodical),					-- no markup in the metadata
		['Encyclopedia'] = Encyclopedia,										-- just a flag; content ignored by ~/COinS
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Quarter'] = COinS_date.rftquarter,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = coins_pages or get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName or Newsgroup,							-- any apostrophe markup already removed from PublisherName
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, and {{cite ssrn}} AFTER generation of COinS data.
	if in_array (config.CitationClass, whitelist.preprint_template_list) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, CiteSeerX, or ssrn now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass and is_set (Newsgroup) then
		PublisherName = substitute (cfg.messages['newsgroup'], external_link( 'news:' .. Newsgroup, Newsgroup, Newsgroup_origin, nil ));
	end

	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_names (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if is_set (Editors) then
				Editors, editor_etal = name_has_etal (Editors, editor_etal, false, 'editors');	-- find and remove variations on et al.
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
				end
				EditorCount = 2;												-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum , interviewer_etal = get_display_names (A['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal);
			Interviewers = list_people (control, interviewers_list, interviewer_etal);
		end
		do																		-- now do translators
			control.maximum , translator_etal = get_display_names (A['DisplayTranslators'], #t, 'translators', translator_etal);
			Translators = list_people (control, t, translator_etal);
		end
		do																		-- now do contributors
			control.maximum , contributor_etal = get_display_names (A['DisplayContributors'], #c, 'contributors', contributor_etal);
			Contributors = list_people (control, c, contributor_etal);
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_names (A['DisplayAuthors'], #a, 'authors', author_etal);

			last_first_list = list_people(control, a, author_etal);

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors');	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if is_set (Authors) and is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
	-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (is_set (Periodical) or is_set (ScriptPeriodical)) and not is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not is_set(URL) then
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) or		-- |url= required for cite web, cite podcast, and cite mailinglist
			('citation' == config.CitationClass and ('website' == Periodical_origin or 'script-website' == ScriptPeriodical_origin)) then	-- and required for {{citation}} with |website= or |script-website=
				table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURL_origin, OriginalFormat, OriginalAccess;
	UrlStatus = UrlStatus:lower();												-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (ChapterURL) then 											-- if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURL_origin = ChapterURL_origin;								-- name of chapter-url parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=

			if 'live' ~= UrlStatus then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				ChapterURL_origin = A:ORIGIN('ArchiveURL')						-- name of archive-url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived urls
			end
		elseif is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURL_origin = URL_origin;										-- name of url parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;

			if 'live' ~= UrlStatus then											-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URL_origin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived urls
			end
 		end
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and (is_set (Periodical) or is_set (ScriptPeriodical)) and not is_set (Encyclopedia)) then
			local chap_param;
			if is_set (Chapter) then											-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif is_set (ScriptChapter) then
				chap_param = ScriptChapter_origin;
			else is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if is_set (chap_param) then											-- if we found one
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {chap_param}, true ) } );		-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if is_set (Contribution) and 0 &lt; #c then								-- if this is a contribution with contributor(s)
			if in_array (Contribution:lower(), cfg.keywords_lists.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, ScriptChapter_origin, Chapter, Chapter_origin, TransChapter, TransChapter_origin, ChapterURL, ChapterURL_origin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter.. sepc .. ' ';
		elseif is_set (ChapterFormat) then										-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title
	if is_set (ArchiveURL) and 
		(mw.ustring.match (mw.ustring.lower(Title), cfg.special_case_translation.archived_copy.en) or	-- if title is 'Archived copy' (place holder added by bots that can't find proper title)
		mw.ustring.match (mw.ustring.lower(Title), cfg.special_case_translation.archived_copy['local'])) then	-- local-wiki's form
			add_maint_cat ('archived_copy');									-- add maintenance category before we modify the content of Title
	end

	if Title:match ('^%(%(.*%)%)$') then										-- if keep as written markup:
		Title= Title:gsub ('^%(%((.*)%)%)$', '%1')								-- remove the markup
	else
		if '...' == Title:sub (-3) then											-- if elipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%'..sepc..'$', '');				-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end
	end

	if in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (is_set (Periodical) or is_set (ScriptPeriodical)) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and (is_set (Periodical) or is_set (ScriptPeriodical))) then		-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle, 'script-title');	-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end

	if is_set (Title) then														-- TODO: is this the right place to be making wikisource urls?
		if is_set (TitleLink) and is_set (URL) then
			table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );	-- set an error message because we can't have both
			TitleLink = '';														-- unset
		end
		
		if not is_set (TitleLink) and is_set (URL) then
			Title = external_link (URL, Title, URL_origin, UrlAccess) .. TransTitle .. TransError .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif is_set (TitleLink) and not is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = make_wikilink (TitleLink, Title) .. TransTitle .. TransError;
			end
		else
			local ws_url, ws_label;												-- Title has italic or quote markup by the time we get here which causes is_wikilink() to return 0 (not a wikilink)
			ws_url, ws_label, L = wikisource_url_make (Title:gsub('[\'&quot;](.-)[\'&quot;]', '%1'));	-- make ws url from |title= interwiki link (strip italic or quote markup); link portion L becomes tool tip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = Title .. TransTitle .. TransError;
			end
		end
	else
		Title = TransTitle .. TransError;
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURL_origin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURL_origin, nil );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if is_set(Minutes) then
			if is_set (Time) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'minutes') .. ' and ' .. wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Sections = A['Sections'];											-- Section (singular) is an alias of Chapter so set earlier
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = is_set (Series) and wrap_msg ('series', {sepc, Series}) or &quot;&quot;;		-- not the same as SeriesNum
	OrigYear = is_set (OrigYear) and wrap_msg ('origyear', OrigYear) or '';
	Agency = is_set (Agency) and wrap_msg ('agency', {sepc, Agency}) or &quot;&quot;;
	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	Via = is_set (Via) and  wrap_msg ('via', Via) or '';

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text

		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {IdAccessLevels=ID_access_levels, DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URL_origin, UrlAccess );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then				-- if first and last characters of quote are quote marks
			Quote = Quote:sub(2,-2);											-- strip them off
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		local arch_text;
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;live&quot; == UrlStatus then
			arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-live'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil ) .. ArchiveFormat, ArchiveDate } );
			if not is_set (OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- UrlStatus is empty, 'dead', 'unfit', 'usurped', 'bot: unknown'
			if in_array (UrlStatus, {'unfit', 'usurped', 'bot: unknown'}) then
				arch_text = cfg.messages['archived-unfit'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. &quot; &quot; .. arch_text .. ArchiveDate;				-- format already styled
				if 'bot: unknown' == UrlStatus then
					add_maint_cat ('bot:_unknown');								-- and add a category if not already added
				else
					add_maint_cat ('unfit');									-- and add a category if not already added
				end
			else																-- UrlStatus is empty, 'dead'
				arch_text = cfg.messages['archived-dead'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURL_origin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else																	-- OriginalUrl not set
			arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURL_origin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURL_origin, nil );
	end

	local Publisher;
	if is_set(PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if is_set(PublisherName) then
		if is_set(PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif is_set(PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if (is_set (Periodical) or is_set (ScriptPeriodical) or is_set (TransPeriodical)) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		else 
			Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		end
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then									-- cite speech only
		TitleNote = &quot; (Speech)&quot;;												-- annotate the citation
		if is_set (Periodical) then												-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then											-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;							-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = safe_join ({Others, sepc .. &quot; &quot;}, sepc) end		-- add terminal punctuation &amp; space; check for dup sepc; TODO why do we need to do this here?
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(Periodical) then		-- special cases for book cites
		if is_set (Contributors) then											-- when we are citing foreword, preface, introduction, etc
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon;
	if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then	-- special case for cite AV media &amp; cite episode position transcript
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, Lay, Quote }, sepc );
	else
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, Lay, Quote }, sepc );
	end
	
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if is_set(Date) then
		if is_set (Authors) or is_set (Editors) then							-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;;				-- in paranetheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon,-1,-1) == sepc) then							-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigYear;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigYear;							-- Date begins with sepc
			end
		end
	end	
	if is_set(Authors) then
		if (not is_set (Date)) then												-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then
					in_text = in_text:lower()									-- lowercase for cs2
				end
			end
			if EditorCount &lt;= 1 then
				post_text = &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot;;				-- be consistent with no-author, no-date case
			else
				post_text = &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot;;
			end
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if is_set (Contributors) then											-- book cite and we're citing the intro, preface, etc
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if is_set (Editors) and is_set (Date) then							-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not is_set (Date)) then											-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc ); 								--Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = string.format ('%s %s %s', 'citation', config.CitationClass, is_set (Mode) and Mode or 'cs1');	-- class=citation required for blue highlight when used with |ref=
	else
		options.class = string.format ('%s %s', 'citation', is_set (Mode) and Mode or 'cs2');
	end
	
	if is_set(Ref) and 'none' ~= cfg.keywords_xlate[Ref:lower()] then
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			if #namelist &gt; 0 then												-- if there are names in namelist
				id = anchor_id (namelist, year);								-- go make the CITEREF anchor
			else
				id = '';														-- unset
			end
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;(.-)&lt;/span&gt;&quot;, &quot;%1&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then	-- remove &lt;span&gt; tags and other html-like markup; then get length of what remains
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	local render = {};															-- here we collect the final bits for concatenation into the rendered citation

	if is_set(options.id) then													-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render, substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text}));	-- when |ref= is set
	else
		table.insert (render, substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text}));	-- all other cases
	end		

	table.insert (render, substitute (cfg.presentation['ocins'], {OCinSoutput}));	-- append metadata to the citation

	if 0 ~= #z.message_tail then
		table.insert (render, ' ');
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					table.insert (render, error_comment( v[1], v[2] ));
				else
					table.insert (render, error_comment( v[1] .. &quot;; &quot;, v[2] ));
				end
			end
		end
	end

	if 0 ~= #z.maintenance_cats then
		local maint_msgs = {};													-- here we collect all of the maint messages
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			local maint = {};													-- here we assemble a maintenence message
			table.insert (maint, v);											-- maint msg is the category name
			table.insert (maint, ' (');											-- open the link text
			table.insert (maint, make_wikilink (':Category:' .. v, 'link'));	-- add the link
			table.insert (maint, ')');											-- and close it
			table.insert (maint_msgs, table.concat (maint));					-- assemble new maint message and add it to the maint_msgs table
		end
		table.insert (render, substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs, ' ')));	-- wrap the group of maint message with proper presentation and save
	end
	
	if not no_tracking_cats then
		for _, v in ipairs( z.error_categories ) do
			table.insert (render, make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			table.insert (render, make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.properties_cats ) do								-- append properties categories
			table.insert (render, make_wikilink ('Category:' .. v));
		end
	end

	return table.concat (render);	
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class)
	local name = tostring (name);
	local state;
	local function state_test (state, name)										-- local function to do testing of state values
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
		return nil;
	end		

	if name:find ('#') then														-- # is a cs1|2 reserved character so parameters with # not permitted
		return nil;
	end

	if in_array (cite_class, whitelist.preprint_template_list ) then			-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[name];
		if true == state_test (state, name) then return true; end

		state = whitelist.preprint_arguments[cite_class][name];					-- look in the parameter-list for the template identified by cite_class
		if true == state_test (state, name) then return true; end

																				-- limited enumerated parameters list
		name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
		state = whitelist.limited_numbered_arguments[name];
		if true == state_test (state, name) then return true; end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates

	if in_array (cite_class, whitelist.unique_param_template_list) then			-- experiment for template-specific parameters for templates that accept parameters from the basic argument list
		state = whitelist.unique_arguments[cite_class][name];					-- look in the template-specific parameter-lists for the template identified by cite_class
		if true == state_test (state, name) then return true; end
	end																			-- if here, fall into general validation
		
	state = whitelist.basic_arguments[name];									-- all other templates; all normal parameters allowed
	if true == state_test (state, name) then return true; end

																				-- all enumerated parameters allowed
	name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );												-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
	state = whitelist.numbered_arguments[name];
	if true == state_test (state, name) then return true; end

	return false;																-- not supported because not found or name is set to nil
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe.  There are two tests made:
	{{cite ... |title=Title access-date=2016-03-17}}	-- the first parameter has a value and whitespace separates that value from the missing pipe parameter name
	{{cite ... |title=access-date=2016-03-17}}			-- the first parameter has no value (whitespace after the first = is trimmed by mediawiki)
cs1|2 shares some parameter names with xml/html atributes: class=, title=, etc.  To prevent false positives xml/html
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (parameter, value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove xml/html tags because attributes: class=, title=, etc 

	capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then										-- if the capture is a valid parameter name
		table.insert( z.message_tail, {set_error ('missing_pipe', parameter)});
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ P U N C T &gt;--------------------------------------

look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_punc (param, value)
	if 'number' == type (param) then
		return;
	end
	
	param = param:gsub ('%d+', '#');											-- enumerated name-list mask params allow terminal punct; normalize 
	if cfg.punct_skip[param] then
		return;																	-- parameter name found in the skip table so done
	end
	
	if value:match ('[,;:]$') then
		add_maint_cat ('extra_punct');											-- has extraneous punctuation; add maint cat
	end
end


--[[--------------------------&lt; C I T A T I O N &gt;--------------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

local function citation(frame)
	Frame = frame;																-- save a copy incase we need to display an error message in preview mode
	local pframe = frame:getParent()
	local validation, utilities, identifiers, metadata, styles;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		styles = 'Module:Citation/CS1/sandbox/styles.css';
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
		styles = 'Module:Citation/CS1/styles.css';

	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	dates = validation.dates;													-- imported functions from Module:Citation/CS1/Date validation
	year_date_check = validation.year_date_check;
	reformat_dates = validation.reformat_dates;
	date_hyphen_to_dash = validation.date_hyphen_to_dash;
	date_name_xlate = validation.date_name_xlate;

	is_set = utilities.is_set;													-- imported functions from Module:Citation/CS1/Utilities
	in_array = utilities.in_array;
	substitute = utilities.substitute;
	error_comment = utilities.error_comment;
	set_error = utilities.set_error;
	select_one = utilities.select_one;
	add_maint_cat = utilities.add_maint_cat;
	wrap_style = utilities.wrap_style;
	safe_for_italics = utilities.safe_for_italics;
	is_wikilink = utilities.is_wikilink;
	make_wikilink = utilities.make_wikilink;
	strip_apostrophe_markup = utilities.strip_apostrophe_markup;

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	extract_ids = identifiers.extract_ids;										-- imported functions from Module:Citation/CS1/Identifiers
	build_id_list = identifiers.build_id_list;
	is_embargoed = identifiers.is_embargoed;
	extract_id_access_levels = identifiers.extract_id_access_levels;
	
	make_coins_title = metadata.make_coins_title;								-- imported functions from Module:Citation/CS1/COinS
	get_coins_pages = metadata.get_coins_pages;
	COinS = metadata.COinS;

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text, error_state;

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do											-- get parameters from the {{#invoke}} frame
		config[k] = v;
	--	args[k] = v;															-- crude debug support that allows us to render a citation from module {{#invoke:}}; skips parameter validation; TODO: keep?
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do											-- get parameters from the parent (template) frame
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower(), config.CitationClass ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute (param, capture);				-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text, error_state = set_error ('parameter_ignored_suggest', {k, param}, true);	-- set the suggestion error message
							else
								error_text, error_state = set_error( 'parameter_ignored', {param}, true );	-- suggested param not supported by this template
								v = '';											-- unset
							end
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end

			args[k] = v;														-- save this parameter and its value

																				-- crude debug support that allows us to render a citation from module {{#invoke:}} TODO: keep?
	--	elseif args[k] ~= nil or (k == 'postscript') then						-- when args[k] has a value from {{#invoke}} frame (we don't normally do that)
	--		args[k] = v;														-- overwrite args[k] with empty string from pframe.args[k] (template frame); v is empty string here
		end																		-- not sure about the postscript bit; that gets handled in parameter validation; historical artifact?
	end	

	for k, v in pairs( args ) do
		has_invisible_chars (k, v);												-- look for invisible characters
		has_extraneous_punc (k, v);												-- look for extraneous terminal punctuation in parameter values
		missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?
	end

	return table.concat ({citation0( config, args), frame:extensionTag ('templatestyles', '', {src=styles})});
end

--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {citation = citation};</text>
      <sha1>nxhv2t6y6ntvoshbmqrbk8i5k1gs9ko</sha1>
    </revision>
    <revision>
      <id>4732</id>
      <parentid>4731</parentid>
      <timestamp>2020-07-11T15:30:31Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>don't evaluate positional parameters for invisible chars;</comment>
      <origin>4732</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="190255" sha1="7isf9y9invyhsn9r6zq9krk0bgh95rw" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local dates, year_date_check, reformat_dates, date_hyphen_to_dash,				-- functions in Module:Citation/CS1/Date_validation
	date_name_xlate

local is_set, in_array, substitute, error_comment, set_error, select_one,		-- functions in Module:Citation/CS1/Utilities
	add_maint_cat, wrap_style, safe_for_italics, is_wikilink, make_wikilink,
	strip_apostrophe_markup;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local extract_ids, extract_id_access_levels, build_id_list, is_embargoed;		-- functions in Module:Citation/CS1/Identifiers

local make_coins_title, get_coins_pages, COinS;									-- functions in Module:Citation/CS1/COinS

local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

declare variables here that have page-wide scope that are not brought in from other modules; that are created here and used here

]]

local added_deprecated_cat;														-- boolean flag so that the category is added only once
local added_prop_cats = {};														-- list of property categories that have been added to z.properties_cats
local added_vanc_errs;															-- boolean flag so we only emit one Vancouver error / category

local Frame;																	-- holds the module's frame table


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

foreign_lang_source and foreign_lang_source_2 keys have a language code appended to them so that multiple languages
may be categorized but multiples of the same language are not categorized.

added_prop_cats is a table declared in page scope variables above

]]

local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		key = key:gsub ('(foreign_lang_source_?2?)%a%a%a?[%a%-]*', '%1');		-- strip lang code from keyname
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));	-- make name then add to table
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a boolean declared in page scope variables above

]]

local function add_vanc_error (source)
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'vancouver', {source}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a uri scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of tlds: https://www.iana.org/domains/root/db

rfc952 (modified by rfc 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the tld.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a url with a scheme) will be stripped
here.  Perhaps not necessary but retained incase it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ascii characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the tld) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and tld or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%w]') then											-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at wikisource
		return false;
	end

	local patterns = {															-- patterns that look like urls
		'%f[%w][%w][%w%-]+[%w]%.%a%a+$',										-- three or more character hostname.hostname or hostname.tld
		'%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$',									-- internationalized domain name with ACE prefix
		'%f[%a][qxz]%.com$',													-- assigned one character .com hostname (x.com times out 2015-12-10)
		'%f[%a][iq]%.net$',														-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		'%f[%w][%w]%.%a%a$',													-- one character hostname and cctld (2 chars)
		'%f[%w][%w][%w]%.%a%a+$',												-- two character hostname and tld
		'^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?',								-- IPv4 address
		}

	for _, pattern in ipairs (patterns) do										-- loop through the patterns list
		if domain:match (pattern) then
			return true;														-- if a match then we think that this thing that purports to be a url is a url
		end
	end

	for _, d in ipairs ({'cash', 'company', 'today', 'org'}) do					-- look for single letter second level domain names for these top level domains
		if domain:match ('%f[%w][%w]%.' .. d) then
			return true
		end
	end
	return false;																-- no matches, we don't know what this thing is
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a url appear to be a valid url; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if is_set (scheme) then														-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when url is protocol relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a url into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following tld) (if any) and any path(/), query(?) or fragment(#).

If protocol relative url, return nil scheme and domain else return nil for both scheme and domain.

When not protocol relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol relative url
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		authority = authority:gsub ('//', '', 1);								-- replace place 1 pair of '/' with nothing;
		if is_set(authority) then												-- if anything left (1 or 3+ '/' where authority should be) then
			return scheme;														-- return scheme only making domain nil which will cause an error message
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link= etc for properly formatted content: no wikilinks, no urls

Link parameters are to hold the title of a wikipedia article so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki urls and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid url (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid url (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from url; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid url
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wikilinked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

]]

local function link_title_ok (link, lorig, title, torig)
local orig;

	if is_set (link) then 														-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		end
	end

	if is_set (orig) then
		table.insert( z.message_tail, { set_error( 'bad_paramlink', orig)});	-- url or wikilink in |title= with |title-link=;
	end
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the url into scheme and domain
portions, or for protocol relative (//example.com) urls, just the domain.  Use is_url() to validate the two
portions of the url.  If both are valid, or for protocol relative if domain is valid, return true, else false.

Because it is different from a standard url, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper url
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from url;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a url.  The test will also find external wikilinks
that use protocol relative urls. Also finds bare urls.

The frontier pattern prevents a match on interwiki links which are similar to scheme:path urls.  The tests that
find bracketed urls are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol relative ext wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare url with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol relative bare url: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a url
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid url
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a url add an error message
			if is_set(error_message) then										-- once we've added the first portion of the error message ...
				error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if is_set (error_message) then												-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { set_error( 'param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source, access)
	local error_str = &quot;&quot;;
	local domain;
	local path;
	local base_url;

	if not is_set( label ) then
		label = URL;
		if is_set( source ) then
			error_str = set_error( 'bare_url_missing_title', { wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = set_error( 'bad_url', {wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the url into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['[']='%5b',[']']='%5d'});					-- replace '[' and ']' with their percent encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wikimarkup url

	if is_set (access) then														-- access level (subscription, registration, limited)
		base_url = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end
	
	return table.concat ({base_url, error_str});
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { set_error( 'deprecated_params', {name}, true ) } );	-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the Module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wikimarkup) are not kerned.

Replaces unicode quotemarks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc; not for book titles.

]=]

local function kern_quotes (str)
	local cap='';
	local cap2='';
	local wl_type, label, link;

	wl_type, label, link = is_wikilink (str);									-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = substitute (cfg.presentation['kern-wl-both'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = substitute (cfg.presentation['kern-wl-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = substitute (cfg.presentation['kern-wl-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label= mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label= mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap, cap2 = mw.ustring.match (label, &quot;^([\&quot;\'])([^\'].+)&quot;);				-- match leading double or single quote but not doubled single quotes (italic markup)
		if is_set (cap) then
			label = substitute (cfg.presentation['kern-left'], {cap, cap2});
		end
	
		cap, cap2 = mw.ustring.match (label, &quot;^(.+[^\'])([\&quot;\'])$&quot;)				-- match trailing double or single quote but not doubled single quotes (italic markup)
		if is_set (cap) then
			label = substitute (cfg.presentation['kern-right'], {cap, cap2});
		end
		
		if 2 == wl_type then
			str = make_wikilink (link, label);									-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate rtl languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title=, |script-chapter=, |script-&lt;periodical&gt;=

]]

local function format_script_value (script_value, script_param)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%l?%s*:') then									-- if first 3 or 4 non-space characters are script language prefix
		lang = script_value:match('^(%l%l%l?)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not is_set (lang) then
			table.insert( z.message_tail, { set_error( 'script_parameter', {script_param, 'missing title part'}, true ) } );		-- prefix without 'title'; add error message
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_code_remap[lang] or mw.language.fetchLanguageName( lang, cfg.this_wiki_code );	-- get language name so that we can use it to categorize
		if is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l+%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if in_array (lang, cfg.script_lang_codes) then
				add_prop_cat ('script_with_name', {name, lang})
			else
				table.insert( z.message_tail, { set_error( 'script_parameter', {script_param, 'unknown language code'}, true ) } );	-- unknown script-language; add error message
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			table.insert( z.message_tail, { set_error( 'script_parameter', {script_param, 'invalid language code'}, true ) } );		-- invalid language code; add error message
			lang = '';															-- invalid so set lang to empty string
		end
	else
		table.insert( z.message_tail, { set_error( 'script_parameter', {script_param, 'missing prefix'}, true ) } );				-- no language code prefix; add error message
	end
	script_value = substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is rtl

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script, script_param)
	if is_set (script) then
		script = format_script_value (script, script_param);					-- &lt;bdi&gt; tags, lang atribute, categorization, etc; returns empty string on error
		if is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not is_set( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return substitute( msg, str );											-- including template text
	else
		return substitute( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;----------------------------------------

makes a wikisource url from wikisource interwiki link.  returns the url and appropriate label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;
	local wikisource_prefix = table.concat ({'https://', cfg.this_wiki_code, '.wikisource.org/wiki/'});

	wl_type, D, L = is_wikilink (str);											-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if is_set (str) then
			ws_url = table.concat ({											-- build a wikisource url
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the url
		end
	elseif 1 == wl_type then													-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if is_set (str) then
			ws_url = table.concat ({											-- build a wikisource url
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the url
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a wikisource url
				wikisource_prefix,												-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end
	
	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable url
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent encoding of fragment marker
	end

	return ws_url, ws_label, L or D;											-- return proper url or nil and a label or nil
end


--[[--------------------------&lt; F O R M A T _ P E R I O D I C A L &gt;--------------------------------------------

Format the three periodical parameters: |script-&lt;periodical&gt;=, |&lt;periodical&gt;=, and |trans-&lt;periodical&gt;= into a single Periodical meta-
parameter.

]]

local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)
	local periodical_error = '';

	if not is_set (periodical) then
		periodical = '';														-- to be safe for concatenation
	else
		periodical = wrap_style ('italic-title', periodical);					-- style 
	end

	periodical = script_concatenate (periodical, script_periodical, script_periodical_source);	-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (trans_periodical) then
		trans_periodical = wrap_style ('trans-italic-title', trans_periodical);
		if is_set (periodical) then
			periodical = periodical ..  ' ' .. trans_periodical;
		else																	-- here when trans-periodical without periodical or script-periodical
			periodical = trans_periodical;
			periodical_error = ' ' .. set_error ('trans_missing_title', {'periodical'});
		end
	end

	return periodical .. periodical_error;
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single Chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (script_chapter, script_chapter_source, chapter, chapter_source, trans_chapter, trans_chapter_source, chapter_url, chapter_url_source, no_quotes, access)
	local chapter_error = '';

	local ws_url, ws_label, L = wikisource_url_make (chapter);					-- make a wikisource url and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', '');										-- replace underscore separaters with space characters
		chapter = ws_label;
	end

	if not is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from Module provided quote marks
			chapter = wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, script_chapter, script_chapter_source);	-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped

	if is_set (chapter_url) then
		chapter = external_link (chapter_url, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');	-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if is_set (trans_chapter) then
		trans_chapter = wrap_style ('trans-quoted-title', trans_chapter);
		if is_set (chapter) then
			chapter = chapter ..  ' ' .. trans_chapter;
		else																	-- here when trans_chapter without chapter or script-chapter
			chapter = trans_chapter;
			chapter_source = trans_chapter_source:match ('trans%-?(.+)');		-- when no chapter, get matching name from trans-&lt;param&gt;
			chapter_error = ' ' .. set_error ('trans_missing_title', {chapter_source});
		end
	end

	return chapter .. chapter_error;
end


--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for nonprintable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i=1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- Test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char=cfg.invisible_chars[i][1]									-- the character or group name
		local pattern=cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position and (char == 'zero width joiner') then						-- if we found a zero width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- its ok if one of the indic scripts
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { set_error( 'invisible_char', {err_msg, wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i=i+1;																	-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = select_one( args, list, 'redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] .. ': ' .. k);
			end
			
			-- Empty strings, not nil;
			if v == nil then
--				v = cfg.defaults[k] or '';
				v = '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap='';
	local cap2='';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if is_set (title_type) then
		if 'none' == cfg.keywords_xlate[title_type] then
			title_type = '';													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash under certain conditions.  The hyphen must separate like items; unlike items are
returned unmodified.  These forms are modified:
	letter - letter (A - B)
	digit - digit (4-5)
	digit separator digit - digit separator digit (4.1-4.5 or 4-1-4-5)
	letterdigit - letterdigit (A1-A5) (an optional separator between letter and digit is supported – a.1-a.5 or a-1-a-5)
	digitletter - digitletter (5a - 5d) (an optional separator between letter and digit is supported – 5.a-5.d or 5-a-5-d)

any other forms are returned unmodified.

str may be a comma- or semicolon-separated list

]]

local function hyphen_to_dash( str )
	if not is_set (str) then
		return str;
	end
	
	str, count = str:gsub ('^%(%((.+)%)%)$', '%1');								-- remove accept-this-as-written markup when it wraps all of str
	if 0 ~= count then															-- non-zero when markup removed; zero else
		return str;																-- nothing to do, we're done
	end
	
	str = str:gsub ('&amp;[nm]dash;', {['&amp;ndash;'] = '–', ['&amp;mdash;'] = '—'});		-- replace &amp;mdash; and &amp;ndash; entities  with their characters; semicolon mucks up the text.split
	str = str:gsub ('&amp;#45;', '-');												-- replace html numeric entity with hyphen character
	str = str:gsub ('&amp;nbsp;', ' ');												-- replace &amp;nbsp; entity with generic keyboard space character
	
	local out = {};
	local list = mw.text.split (str, '%s*[,;]%s*');								-- split str at comma or semicolon separators if there are any

	for _, item in ipairs (list) do												-- for each item in the list
		if mw.ustring.match (item, '^%w*[%.%-]?%w+%s*[%-–—]%s*%w*[%.%-]?%w+$') then	-- if a hyphenated range or has endash or emdash separators
			if item:match ('^%a+[%.%-]?%d+%s*%-%s*%a+[%.%-]?%d+$') or			-- letterdigit hyphen letterdigit (optional separator between letter and digit)
				item:match ('^%d+[%.%-]?%a+%s*%-%s*%d+[%.%-]?%a+$') or			-- digitletter hyphen digitletter (optional separator between digit and letter)
				item:match ('^%d+[%.%-]%d+%s*%-%s*%d+[%.%-]%d+$') or			-- digit separator digit hyphen digit separator digit
				item:match ('^%d+%s*%-%s*%d+$') or								-- digit hyphen digit
				item:match ('^%a+%s*%-%s*%a+$') then							-- letter hyphen letter
					item = item:gsub ('(%w*[%.%-]?%w+)%s*%-%s*(%w*[%.%-]?%w+)', '%1–%2');	-- replace hyphen, remove extraneous space characters
			else
				item = mw.ustring.gsub (item, '%s*[–—]%s*', '–');				-- for endash or emdash separated ranges, replace em with en, remove extraneous white space
			end
		end
		item = item:gsub ('^%(%((.+)%)%)$', '%1');								-- remove the accept-this-as-written markup
		table.insert (out, item);												-- add the (possibly modified) item to the output table
	end

	return table.concat (out, ', ');											-- concatenate the output table into a comma separated string
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'dupicate character'
		if 1 == #duplicate_char then											-- for single byte ascii characters use the string library functions
			f.gsub=string.gsub
			f.match=string.match
			f.sub=string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub=mw.ustring.gsub
			f.match=mw.ustring.match
			f.sub=mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1,1) == '&lt;' then										-- Special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove html markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1,1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc?
				trim = false;
				end_chr = f.sub(str, -1,-1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr.. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1,-2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wikimarkup
					if f.sub(str, -3,-1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5,-1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4,-1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wikimarkup
					if f.sub(str, -3,-1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3,-1) == duplicate_char .. '&quot;]' then		-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2,-1) == duplicate_char .. &quot;]&quot; then		-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4,-1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2,-1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1,-3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains html markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows html markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;------------------------------------------------------------

returns true is suffix is properly formed Jr, Sr, or ordinal in the range 2–9.  Puncutation not allowed.

]]

local function is_suffix (suffix)
	if in_array (suffix, {'Jr', 'Sr', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver Style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written ouside of the code editor and pasted here because the code editor gets confused between character insertion point and cursor position.
The test has been rewritten to use decimal character escape sequence for the individual bytes of the unicode characters so that it is not necessary
to use an external editor to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first, suffix)
	if not suffix then
		if first:find ('[,%s]') then											-- when there is a space or comma, might be first name/initials + generational suffix
			first = first:match ('(.-)[,%s]+');									-- get name/initials
			suffix = first:match ('[,%s]+(.+)$');								-- get generational suffix
		end
	end
	if is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error (cfg.err_msg_supl.suffix);
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error (cfg.err_msg_supl['non-Latin char']);
			return false;														-- not a string of latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-format=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc) to be rendered as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just intials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error (cfg.err_msg_supl.suffix);					-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word

	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i],1,1));				-- insert the intial at end of initials table
		end
		i = i+1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; L I S T  _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors / editors) 

]]

local function list_people(control, people, etal)
	local sep;
	local namesep;
	local format = control.format
	local maximum = control.maximum
	local lastauthoramp = control.lastauthoramp;
	local text = {}

	if 'vanc' == format then													-- Vancouver-like author/editor name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between authors is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
		lastauthoramp = nil;													-- unset because isn't used by Vancouver style
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between authors is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub(-1,-1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end					-- returned 0 is for EditorCount; not used for authors
	
	for i,person in ipairs(people) do
		if is_set(person.last) then
			local mask = person.mask
			local one
			local sep_one = sep;
			if is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			elseif (mask ~= nil) then
				local n = tonumber(mask)
				if (n ~= nil) then
					one = string.rep(&quot;&amp;mdash;&quot;,n)
				else
					one = mask;
					sep_one = &quot; &quot;;
				end
			else
				one = person.last
				local first = person.first
				if is_set(first) then
					if ( &quot;vanc&quot; == format ) then								-- if vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials(first)					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
			end
			if is_set (person.link) then
				one = make_wikilink (person.link, one);							-- link author/editor
			end
			table.insert (text, one)
			table.insert (text, sep_one)
		end
	end

	local count = #text / 2;													-- (number of names + number of separators) divided by 2
	if count &gt; 0 then 
		if count &gt; 1 and is_set(lastauthoramp) and not etal then
			text[#text-2] = &quot; &amp; &quot;;												-- replace last separator with ampersand text
		end
		text[#text] = nil;														-- erase the last separator
	end
	
	local result = table.concat(text)											-- construct list
	if etal and is_set (result) then											-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've go a last-first list and etal so add et al.
	end
	
	return result, count
end


--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]

local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if is_set (id) then															-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of name parameters (author, editor, etc) for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the associated |display-&lt;names&gt;=etal parameter

]]

local function name_has_etal (name, etal, nocat, param)

	if is_set (name) then														-- name can be nil in which case just return
		local patterns = cfg.et_al_patterns;									--get patterns from configuration
		
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns
			if name:match (pattern) then										-- if this 'et al' pattern is found in name
				name = name:gsub (pattern, '');									-- remove the offending text
				etal = true;													-- set flag (may have been set previously here or by |display-&lt;names&gt;=etal)
				if not nocat then												-- no categorization for |vauthors=
					table.insert( z.message_tail, {set_error ('etal', {param})});	-- and set an error if not added
				end
			end
		end
	end

	return name, etal;															-- 
end


--[[--------------------------&lt; N A M E _ I S _ N U M E R I C &gt;------------------------------------------------

Add maint cat when name parameter value does not contain letters.  Does not catch mixed alphanumeric names so
|last=A. Green (1922-1987) does not get caught in the current version of this test but |first=(1888) is caught.

returns nothing

]]

local function name_is_numeric (name, list_name)
	if is_set (name) then
		if mw.ustring.match (name, '^[%A]+$') then								-- when name does not contain any letters
			add_maint_cat ('numeric_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
		end
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E D _ M A R K U P &gt;------------------------------------------

Evaluates the content of author and editor parameters for extranious editor annotations: ed, ed., eds, (Ed.), etc.
These annotation do not belong in author parameters and are redundant in editor parameters.  If found, the function
adds the editor markup maintenance category.

returns nothing

]]

local function name_has_ed_markup (name, list_name)
	local patterns = cfg.editor_markup_patterns;								-- get patterns from configuration

	if is_set (name) then
		for _, pattern in ipairs (patterns) do									-- spin through patterns table and
			if name:match (pattern) then
				add_maint_cat ('extra_text_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
				break;
			end
		end
	end
end


--[[--------------------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;----------------------------------------

Evaluates the content of author and editor (surnames only) parameters for multiple names.  Multiple names are
indicated if there is more than one comma and or semicolon.  If found, the function adds the multiple name
(author or editor) maintenance category.

returns nothing

]]

local function name_has_mult_names (name, list_name)
	local _, count;
	if is_set (name) then
		_, count = name:gsub ('[;,]', '');										-- count the number of separator-like characters
		
		if 1 &lt; count then														-- param could be |author= or |editor= so one separator character is acceptable
			add_maint_cat ('mult_names', cfg.special_case_translation [list_name]);	-- more than one separator indicates multiple names so add a maint cat for this template
		end
	end
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------

This function calls various name checking functions used to validate the content of the various name-holding
parameters.

]]

local function name_checks (last, first, list_name)
	if is_set (last) then
		if last:match ('^%(%(.*%)%)$') then										-- if wrapped in doubled parentheses, accept as written 
			last = last:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			name_has_mult_names (last, list_name);								-- check for multiple names in the parameter (last only)
			name_has_ed_markup (last, list_name);								-- check for extraneous 'editor' annotation
			name_is_numeric (last, list_name);									-- check for names that are compsed of digits and punctuation
		end
	end
	if is_set (first) then
		if first:match ('^%(%(.*%)%)$') then									-- if wrapped in doubled parentheses, accept as written 
			first = first:match ('^%(%((.*)%)%)$');								-- strip parens
		else
			name_has_ed_markup (first, list_name);								-- check for extraneous 'editor' annotation
			name_is_numeric (first, list_name);									-- check for names that are compsed of digits and punctuation
		end
	end
	return last, first;															-- done
	end


--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};			-- table of names
	local last;					-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;				-- loop counter/indexer
	local n = 1;				-- output table indexer
	local count = 0;			-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal=false;			-- return value set to true when we find some form of et al. in an author parameter

	local last_alias, first_alias, link_alias;									-- selected parameter aliases used in error messaging
	while true do
		last, last_alias = select_one( args, cfg.aliases[list_name .. '-Last'], 'redundant_parameters', i );		-- search through args for name components beginning at 1
		first, first_alias = select_one( args, cfg.aliases[list_name .. '-First'], 'redundant_parameters', i );
		link, link_alias = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i );
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.
		last, first= name_checks (last, first, list_name);						-- multiple names, extraneous annotation, etc checks
		
		if first and not last then												-- if there is a firstn without a matching lastn
			table.insert( z.message_tail, { set_error( 'first_missing_last', {first_alias, first_alias:gsub('first', 'last')}, true ) } );	-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			link_title_ok (link, link_alias, last, last_alias);					-- check for improper wikimarkup
			if first then
				link_title_ok (link, link_alias, first, first_alias);			-- check for improper wikimarkup
			end

			names[n] = {last = last, first = first, link = link, mask = mask, corporate=false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { set_error( 'missing_name', {list_name:match (&quot;(%w+)List&quot;):lower(), i-1}, true ) } );	-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because case of the source may be incorrect
or different from the case that WikiMedia uses, the name comparisons are done in lower case and when a match is
found, the Wikimedia version (assumed to be correct) is returned along with the code.  When there is no match, we
return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') returns a list of languages that in some cases may include
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.  Most (all?) of these languages are not used a 'language' codes per se, rather they
are used as sub-domain names: cbk-zam.wikipedia.org.  A list of language names and codes supported by fetchLanguageNames()
can be found at Template:Citation Style documentation/language/doc

Names that are included in the list will be found if that name is provided in the |language= parameter.  For example,
if |language=Chavacano de Zamboanga, that name will be found with the associated code 'cbk-zam'.  When names are found
and the associated code is not two or three characters, this function returns only the WikiMedia language name.

Some language names have multiple entries under different codes:
	Aromanian has code rup and code roa-rup
When this occurs, this function returns the language name and the 2- or 3-character code

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	if cfg.lang_name_remap[lang:lower()] then									-- if there is a remapped name (because MediaWiki uses something that we don't think is correct)
		return cfg.lang_name_remap[lang:lower()][1], cfg.lang_name_remap[lang:lower()][2];	-- for this language 'name', return a possibly new name and appropriate code
	end

	local ietf_code;															-- because some languages have both ietf-like codes and iso 639-like codes
	local ietf_name;
	
	local languages = mw.language.fetchLanguageNames(this_wiki_code, 'all')		-- get a list of language names known to Wikimedia
																				-- ('all' is required for North Ndebele, South Ndebele, and Ojibwa)
	local langlc = mw.ustring.lower(lang);										-- lower case version for comparisons

	for code, name in pairs(languages) do										-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower(name) then
			if 2 == code:len() or 3 == code:len() then							-- two- or three-character codes only; extensions not supported
				return name, code;												-- so return the name and the code
			end
			ietf_code = code;													-- remember that we found an ietf-like code and save its name
			ietf_name = name;													-- but keep looking for a 2- or 3-char code
		end
	end
																				-- didn't find name with 2- or 3-char code; if ietf-like code found return
	return ietf_code and ietf_name or lang;										-- associated name; return original language text else
end


--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code is recognized by MediaWiki,
use the returned name; if not, then use the value that was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is assigned to the category for
that code: Category:Norwegian-language sources (no).  For valid three-character code languages, the page is assigned
to the single category for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does not recognize three-character
equivalents of two-character codes: code 'ar' is recognized but code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are
separated from each other by commas with optional space characters.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki_name = mw.language.fetchLanguageName(cfg.this_wiki_code, cfg.this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang
		name = cfg.lang_code_remap[lang:lower()];								-- first see if this is a code that is not supported by MediaWiki but is in remap

		if name then															-- there was a remapped code so
			if not lang:match ('^%a%a%a?%-x%-%a+$') then						-- if not a private ietf tag
				lang = lang:gsub ('^(%a%a%a?)%-.*', '%1');						-- strip ietf tags from code
			end
		else
			lang = lang:gsub ('^(%a%a%a?)%-.*', '%1');							-- strip any ietf-like tags from code
			if 2 == lang:len() or 3 == lang:len() then							-- if two-or three-character code
				name = mw.language.fetchLanguageName (lang:lower(), cfg.this_wiki_code);	-- get language name if |language= is a proper code
			end
		end

		if is_set (name) then													-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, cfg.this_wiki_code);				-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if is_set (code) then													-- only 2- or 3-character codes
			name = cfg.lang_code_remap[code] or name;							-- override wikimedia when they misuse language codes/names

			if cfg.this_wiki_code ~= code then									-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					add_prop_cat ('foreign_lang_source' .. code, {name, code});	-- categorize it; code appended to allow for multiple language categorization
				else															-- or is a recognized language (but has a three-character code)
					add_prop_cat ('foreign_lang_source_2' .. code, {code});		-- categorize it differently TODO: support multiple three-character code categories per cs1|2 template
				end
			elseif cfg.local_lang_cat_enable then								-- when the language and this wiki's language are the same and categorization is enabled
				add_prop_cat ('local_lang_source', {name, code});				-- categorize it
			end
		else
			add_maint_cat ('unknown_lang');										-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
	
	code = #language_list														-- reuse code as number of languages in the list
	if 2 &gt;= code then
		name = table.concat (language_list, cfg.messages['parameter-pair-separator'])		-- insert '&lt;space&gt;and&lt;space&gt;' between two language names
	elseif 2 &lt; code then
		name = table.concat (language_list, cfg.messages['parameter-separator'], 1, code-1);			-- concatenate all but last
		name = table.concat ({name, language_list[code]}, cfg.messages['parameter-final-separator']);	-- concatenate last with final separator
	end
	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings
At en.wiki, for cs1:
	ps gets:	'.'
	sep gets:	'.'

]]

local function set_cs1_style (ps)
	if not is_set (ps) then														-- unless explicitly set to something
		ps = cfg.presentation['ps_cs1'];										-- terminate the rendered citation
	end
	return cfg.presentation['sep_cs1'], ps;										-- element separator
end


--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings
At en.wiki, for cs2:
	ps gets:	'' (empty string - no terminal punctuation)
	sep gets:	','

]]

local function set_cs2_style (ps, ref)
	if not is_set (ps) then														-- if |postscript= has not been set, set cs2 default
		ps = cfg.presentation['ps_cs2'];										-- terminate the rendered citation
	end
	if not is_set (ref) then													-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return cfg.presentation['sep_cs2'], ps, ref;								-- element separator
end


--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end


--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end

	if cfg.keywords_xlate[ps:lower()] == 'none' then							-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end


--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a url has the file extension that is one of the pdf file extensions used by [[MediaWiki:Common.css]] when
applying the pdf icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or
		url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
		url:match ('%.PDF&amp;#035') or url:match ('%.pdf&amp;#035');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies css style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching url parameter.  If the format parameter is not set and the url contains a file extension that
is recognized as a pdf document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if is_set (format) then
		format = wrap_style ('format', format);									-- add leading space, parentheses, resize
		if not is_set (url) then
			format = format .. set_error( 'format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if url is a pdf file then
		format = wrap_style ('format', 'PDF');									-- set format to pdf
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[--------------------------&lt; G E T _ D I S P L A Y _ N A M E S &gt;--------------------------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_names (max, count, list_name, etal)
	if is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				add_maint_cat ('disp_name', cfg.special_case_translation [list_name]);
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, { set_error( 'invalid_param_val', {'display-' .. list_name, max}, true ) } );		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		add_maint_cat ('extra_text');
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parnetheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a place holder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parens
			local name = name_table[i];
			i=i+1;																-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parens
					break;														-- and done reassembling so
				end
				i=i+1;															-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = is_wikilink (name_table[i]);					-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i+1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled paranethese ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the vancouver error when a reqired comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		first = '';																-- set to empty string for concatenation and because it may have been set for previous author/editor
		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parentheses to supress vanc formatting and error detection
			last = v_name:match ('^%(%((.+)%)%)$')								-- remove doubled parntheses
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error (cfg.err_msg_supl.punctuation);
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s+&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be intials or generational suffix

			if not mw.ustring.match (first, '^%u+$') then						-- mw.ustring here so that later we will catch non-latin characters
				suffix = first;													-- not initials so assume that whatever we got is a generational suffix
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end
			last = table.concat(lastfirstTable, ' ')							-- returns a string that is the concatenation of all other names that are not initials and generational suffix
			if not is_set (last) then
				first = '';														-- unset
				last = v_name;													-- last empty because something wrong with first
				add_vanc_error (cfg.err_msg_supl.name);
			end
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error (cfg.err_msg_supl['missing comma']);				-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error (cfg.err_msg_supl.name);							-- matches a space between two intiials
			end
		else
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
																
		if is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error (cfg.err_msg_supl.initials);						-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first, suffix);							-- check first and last before restoring the suffix which may have a non-Latin digit
			if is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '');
			end
		end

		link = select_one( args, cfg.aliases[list_name .. '-Link'], 'redundant_parameters', i ) or v_link_table[i];
		mask = select_one( args, cfg.aliases[list_name .. '-Mask'], 'redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate=corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
	local lastfirst = false;
	if select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice incase we have a |first1= without a |last1=; this ...
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or	-- ... also catches the case where |first= is used with |vauthors=
		select_one( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		select_one( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst=true;
	end

	if (is_set (vxxxxors) and true == lastfirst) or								-- these are the three error conditions
		(is_set (vxxxxors) and is_set (xxxxors)) or
		(true == lastfirst and is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { set_error( 'redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if is_set (vxxxxors) then return 2 end;
	if is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, live, dead, etc).  When the parameter value has not been assigned a value (missing
or empty in the source template) the function returns the value specified by ret_val.  If the parameter value is one
of the list of allowed values returns the translated value; else, emits an error message and returns the value
specified by ret_val.

]]

local function is_valid_parameter_value (value, name, possible, ret_val)
	if not is_set (value) then
		return ret_val;															-- an empty parameter is ok
	elseif in_array (value, possible) then
		return cfg.keywords_xlate[value];										-- return translation of parameter keyword
	else
		table.insert( z.message_tail, { set_error( 'invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return ret_val;
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list,-3,-1) == sepc .. '. ') then						-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list,-1,-1) == sepc) or (string.sub (name_list,-3,-1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terninate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not is_set (volume) and not is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if is_set (volume) and is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end

	if 'podcast' == cite_class and is_set (issue) then
		return wrap_msg ('issue', {sepc, issue}, lower);
	end

	local vol = '';																-- here for all cites except magazine
		
	if is_set (volume) then
		if volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$')then			-- volume value is all digits or all uppercase roman numerals
			vol = substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});	-- render in bold face
		elseif (4 &lt; mw.ustring.len(volume)) then								-- not all digits or roman numerals and longer than 4 characters
			vol = substitute (cfg.messages['j-vol'], {sepc, volume});			-- not bold
			add_prop_cat ('long_vol');
		else																	-- four or less characters
			vol = substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});	-- bold
		end
	end
	if is_set (issue) then
		return vol .. substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if is_set (page) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif is_set(pages) then
		if is_journal then
			return substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then							-- if pages is only digits, assume a single page number
			return '', substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to wikisource, returns the label portion of the interwikilink as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki link to and external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, pages, at)
	local ws_url, ws_label, coins_pages, L;										-- for wikisource interwikilinks; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if is_set (page) then
		if is_set (pages) or is_set(at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws url from |page= interwiki link; link portion L becomes tool tip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif is_set (pages) then
		if is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws url from |pages= interwiki link; link portion L becomes tool tip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws url from |at= interwiki link; link portion L becomes tool tip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org urls to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot url or to calendar pages.  When the archive url is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the url.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org url does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command url
	|archive-url= is an archive.org url that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org urls:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this funct may return a modified
archive url:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the url unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.or url
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine url
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command url, we don't want to allow saving of the target page 
		err_msg = cfg.err_msg_supl.save;
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = cfg.err_msg_supl.liveweb;
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');	-- split out some of the url parts for evaluation
		
		if not is_set(timestamp) or 14 ~= timestamp:len() then					-- path and flag optional, must have 14-digit timestamp here
			err_msg = cfg.err_msg_supl.timestamp;
			if '*' ~= flag then
				url=url:gsub ('(//web%.archive%.org/[^%d]*%d?%d?%d?%d?%d?%d?)[^/]*', '%1*', 1)	-- for preview, modify ts to be yearmo* max (0-6 digits plus splat)
			end
		elseif is_set(path) and 'web/' ~= path then								-- older archive urls do not have the extra 'web/' path element
			err_msg = cfg.err_msg_supl.path;
		elseif is_set (flag) and not is_set (path) then							-- flag not allowed with the old form url (without the 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		elseif is_set (flag) and not flag:match ('%a%a_') then					-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		else
			return url, date;													-- return ArchiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	table.insert( z.message_tail, { set_error( 'archive_url', {err_msg}, true ) } );	-- add error message and
	if is_set (Frame:preprocess('{{REVISIONID}}')) then
		return '', '';															-- return empty strings for ArchiveURL and ArchiveDate
	else
		return url, date;														-- preview mode so return ArchiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; P L A C E _ C H E C K &gt;--------------------------------------------------------

check |place=, |publication-place=, |location= to see if these params include digits.  This function added because
many editors mis-use location to specify the in-source location (|page(s)= and |at= are supposed to do that)

returns the original parameter value without modification; added maint cat when parameter value contains digits

]]

local function place_check (param_val)
	if not is_set (param_val) then												-- parameter empty or omitted
		return param_val;														-- return that empty state
	end
	
	if mw.ustring.find (param_val, '%d') then									-- not empty, are there digits in the parameter value
		add_maint_cat ('location');												-- yep, add maint cat
	end
	
	return param_val;															-- and done
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

	local Mode = is_valid_parameter_value (A['Mode'], A:ORIGIN('Mode'), cfg.keywords_lists['mode'], '');

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;

	local NameListFormat = is_valid_parameter_value (A['NameListFormat'], A:ORIGIN('NameListFormat'), cfg.keywords_lists['name-list-format'], '');
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				add_maint_cat ('authors');										-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListFormat = 'vanc';											-- override whatever |name-list-format= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
			add_maint_cat ('editors');											-- but add a maint cat because use of this parameter is discouraged
		end
	end

	local translator_etal;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=

	local interviewer_etal;
	local interviewers_list = {};												
	local Interviewers;															-- used later
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters

	local contributor_etal;
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list

	local Chapter = A['Chapter'];												-- done here so that we have access to |contribution= from |chapter= aliases
	local Chapter_origin = A:ORIGIN ('Chapter');
	local Contribution;															-- because contribution is required for contributor(s)
		if 'contribution' == A:ORIGIN ('Chapter') then
			Contribution = A['Chapter'];										-- get the name of the contribution
		end

	if in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not is_set (Contribution) then									-- |contributor= requires |contribution=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { set_error( 'contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if select_one (args, cfg.aliases['ContributorList-Last'], 'redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { set_error( 'contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if is_set (Others) then
		if 0 == #a and 0 == #e then												-- add maint cat when |others= has value and used without |author=, |editor=
			add_maint_cat ('others');
		end
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigYear = A['OrigYear'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TransTitle_origin = A:ORIGIN ('TransTitle');
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];
			link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wikimarkup in |title-link= or wikimarkup in |title= when |title-link= is set

	local Section = '';															-- {{cite map}} only; preset to empty string for concatnation if not used
		if 'map' == config.CitationClass and 'section' == A:ORIGIN ('Chapter') then
			Section = A['Chapter'];												-- get |section= from |chapter= alias list; |chapter= and the other aliases not supported in {{cite map}}
			Chapter = '';														-- unset for now; will be reset later from |map= if present
		end

	local ScriptChapter = A['ScriptChapter'];
	local ScriptChapter_origin = A:ORIGIN ('ScriptChapter');
	local ChapterLink	-- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TransChapter_origin = A:ORIGIN ('TransChapter');
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];

	local ArchiveDate;
	local ArchiveURL;

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	
	local UrlStatus = is_valid_parameter_value (A['UrlStatus'], A:ORIGIN('UrlStatus'), cfg.keywords_lists['url-status'], '');


	local URL = A['URL']
	local URL_origin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURL_origin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURL_origin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL

	local Periodical = A['Periodical'];
	local Periodical_origin = '';
		if is_set (Periodical) then
			Periodical_origin = A:ORIGIN('Periodical');							-- get the name of the periodical parameter
			local i;
			Periodical, i = strip_apostrophe_markup (Periodical);				-- strip appostrophe markup so that metadata isn't contaminated 
			if i then															-- non-zero when markup was stripped so emit an error message
				table.insert( z.message_tail, {set_error ('apostrophe_markup', {Periodical_origin}, true)});
			end
		end

	if 'mailinglist' == config.CitationClass then								-- special case for {{cite mailing list}}
		if is_set (Periodical) and is_set (A ['MailingList']) then						-- both set emit an error
			table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', Periodical_origin) .. ' and ' .. wrap_style ('parameter', 'mailinglist')}, true )});
		end

		Periodical = A ['MailingList'];											-- error or no, set Periodical to |mailinglist= value because this template is {{cite mailing list}}
		Periodical_origin = A:ORIGIN('MailingList');
	end



																				
	local ScriptPeriodical = A['ScriptPeriodical'];
	local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');
																				-- web and news not tested for now because of 
																				-- Wikipedia:Administrators%27_noticeboard#Is_there_a_semi-automated_tool_that_could_fix_these_annoying_&quot;Cite_Web&quot;_errors?
		if not (is_set (Periodical) or is_set (ScriptPeriodical)) then			-- 'periodical' templates require periodical parameter
	--		local p = {['journal'] = 'journal', ['magazine'] = 'magazine', ['news'] = 'newspaper', ['web'] = 'website'};	-- for error message
			local p = {['journal'] = 'journal', ['magazine'] = 'magazine'};		-- for error message
			if p[config.CitationClass]  then
				table.insert( z.message_tail, {set_error ('missing_periodical', {config.CitationClass, p[config.CitationClass]}, true)});
			end
		end

	local TransPeriodical =  A['TransPeriodical'];
	local TransPeriodical_origin =  A:ORIGIN ('TransPeriodical');

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if 'citation' == config.CitationClass then
		if is_set (Periodical) then
			if not in_array (Periodical_origin, {'website', 'mailinglist'}) then	-- {{citation}} does not render volume for these 'periodicals'
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		elseif is_set (ScriptPeriodical) then
			if 'script-website' ~= ScriptPeriodical_origin then					-- {{citation}} does not render volume for |script-website=
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		else
			Volume = A['Volume'];												-- and does for non-'periodical' cites
		end
	elseif in_array (config.CitationClass, cfg.templates_using_volume) then		-- render |volume= for cs1 according to the configuration settings
		Volume = A['Volume'];
	end	

	if 'citation' == config.CitationClass then
		if is_set (Periodical) and in_array (Periodical_origin, {'journal', 'magazine', 'newspaper', 'periodical', 'work'}) or	-- {{citation}} renders issue for these 'periodicals'
			is_set (ScriptPeriodical) and in_array (ScriptPeriodical_origin, {'script-journal', 'script-magazine', 'script-newspaper', 'script-periodical', 'script-work'}) then -- and these 'script-periodicals'
				Issue = hyphen_to_dash (A['Issue']);
		end
	elseif in_array (config.CitationClass, cfg.templates_using_issue) then		-- conference &amp; map books do not support issue; {{citation}} listed here because included in settings table
		if not (in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (is_set (Periodical) or is_set (ScriptPeriodical))) then
			Issue = hyphen_to_dash (A['Issue']);
		end
	end

	local Position = '';
	if not in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash (A['Pages']);	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = place_check (A['PublicationPlace'], A:ORIGIN('PublicationPlace'));
	local Place = place_check (A['Place'], A:ORIGIN('Place'));
	
	local PublisherName = A['PublisherName'];
	local PublisherName_origin = A:ORIGIN('PublisherName');
		if is_set (PublisherName) then
			local i=0;
			PublisherName, i = strip_apostrophe_markup (PublisherName);			-- strip appostrophe markup so that metadata isn't contaminated; publisher is never italicized

			if i then															-- non-zero when markup was stripped so emit an error message
				table.insert( z.message_tail, {set_error ('apostrophe_markup', {PublisherName_origin}, true)});
			end
		end

	local Newsgroup = A['Newsgroup'];											-- TODO: strip apostrophe markup?
	local Newsgroup_origin = A:ORIGIN('Newsgroup');	

	if 'newsgroup' == config.CitationClass then
		if is_set (PublisherName) then											-- general use parmeter |publisher= not allowed in cite newsgroup
			local error_text = set_error ('parameter_ignored', {PublisherName_origin}, true);
			if is_set (error_text) then
				table.insert( z.message_tail, {error_text, error_state} );
			end				
		end

		PublisherName = nil;													-- ensure that this parameter is unset for the time being; will be used again after COinS
	end

	local UrlAccess = is_valid_parameter_value (A['UrlAccess'], A:ORIGIN('UrlAccess'), cfg.keywords_lists['url-access'], nil);
		if not is_set(URL) and is_set(UrlAccess) then
			UrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {'url'}, true ) } );
		end
		
	local ChapterUrlAccess = is_valid_parameter_value (A['ChapterUrlAccess'], A:ORIGIN('ChapterUrlAccess'), cfg.keywords_lists['url-access'], nil);
		if not is_set(ChapterURL) and is_set(ChapterUrlAccess) then
			ChapterUrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {A:ORIGIN('ChapterUrlAccess'):gsub ('%-access', '')}, true ) } );
		end

	local MapUrlAccess = is_valid_parameter_value (A['MapUrlAccess'], A:ORIGIN('MapUrlAccess'), cfg.keywords_lists['url-access'], nil);
		if not is_set(A['MapURL']) and is_set(MapUrlAccess) then
			MapUrlAccess = nil;
			table.insert( z.message_tail, { set_error( 'param_access_requires_param', {'map-url'}, true ) } );
		end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local Agency = A['Agency'];

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = is_valid_parameter_value (A['IgnoreISBN'], A:ORIGIN('IgnoreISBN'), cfg.keywords_lists['yes_true_y'], nil);
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local ID_list = extract_ids( args );
		if is_set (DoiBroken) and not ID_list['DOI'] then
			table.insert( z.message_tail, { set_error( 'doibroken_missing_doi', A:ORIGIN('DoiBroken'))});
		end
	local ID_access_levels = extract_id_access_levels( args, ID_list );

	local Quote = A['Quote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURL_origin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = is_valid_parameter_value (A['LastAuthorAmp'], A:ORIGIN('LastAuthorAmp'), cfg.keywords_lists['yes_true_y'], nil);

	local no_tracking_cats = is_valid_parameter_value (A['NoTracking'], A:ORIGIN('NoTracking'), cfg.keywords_lists['yes_true_y'], nil);

	--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = is_valid_parameter_value (A['DF'], A:ORIGIN('DF'), cfg.keywords_lists['df'], '');
	if not is_set (DF) then
		DF = cfg.global_df;														-- local df if present overrides global df set by {{use xxx date}} template
	end

	local sepc;																	-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref = A['Ref'];
	if 'harv' == Ref then
		add_maint_cat ('ref_harv');												-- add maint cat to identify templates that have this now-extraneous param value
	elseif not is_set (Ref) then
		Ref = 'harv';															-- set as default when not set externally
	end
	
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], Ref, config.CitationClass);
	use_lowercase = ( sepc == ',' );											-- used to control capitalization for certain static text

	--check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not is_set (no_tracking_cats) then										-- ignore if we are already not going to categorize this page
		if in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _,v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end
																				-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	select_one (args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'redundant_parameters');	-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, Pages, At);

	local NoPP = is_valid_parameter_value (A['NoPP'], A:ORIGIN('NoPP'), cfg.keywords_lists['yes_true_y'], nil);

	if is_set (PublicationPlace) and is_set (Place) then						-- both |publication-place= and |place= (|location=) allowed if different
		add_prop_cat ('location test');											-- add property cat to evaluate how often PublicationPlace and Place are used together
		if PublicationPlace == Place then
			Place = '';															-- unset; don't need both if they are the same
		end
	elseif not is_set (PublicationPlace) and is_set (Place) then				-- when only |place= (|location=) is set ...
		PublicationPlace = Place;												-- promote |place= (|location=) to |publication-place
	end

	if PublicationPlace == Place then Place = ''; end							-- don't need both if they are the same
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia and |title then map |title to |article and |encyclopedia to |title
		|encyclopedia and |article then map |encyclopedia to |title

		|trans-title maps to |trans-chapter when |title is re-mapped
		|url maps to |chapterurl when |title is remapped
	
	All other combinations of |encyclopedia, |title, and |article are not modified
	
	]]

	local Encyclopedia = A['Encyclopedia'];										-- used as a flag by this module and by ~/COinS

	if is_set (Encyclopedia) then												-- emit error message when Encyclopedia set but template is other than {{cite encyclopedia}} or {{citation}}
		if 'encyclopaedia' ~= config.CitationClass and 'citation' ~= config.CitationClass then
			table.insert (z.message_tail, {set_error ('parameter_ignored', {A:ORIGIN ('Encyclopedia')}, true)});
			Encyclopedia = nil;													-- unset because not supported by this template
		end
	end

	if ('encyclopaedia' == config.CitationClass) or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Periodical) and is_set (Encyclopedia) then					-- when both set emit an error
			table.insert (z.message_tail, {set_error('redundant_parameters', {wrap_style ('parameter', A:ORIGIN ('Encyclopedia')) .. ' and ' .. wrap_style ('parameter', Periodical_origin)}, true )});
		end

		if is_set (Encyclopedia) then
			Periodical = Encyclopedia;											-- error or no, set Periodical to Encyclopedia; allow periodical without encyclopedia
			Periodical_origin = A:ORIGIN ('Encyclopedia');
		end

		if is_set (Periodical) then												-- Periodical is set when |encyclopedia is set
			if is_set(Title) or is_set (ScriptTitle) then
				if not is_set(Chapter) then
					Chapter = Title;											-- |encyclopedia and |title are set so map |title to |article and |encyclopedia to |title
					ScriptChapter = ScriptTitle;
					ScriptChapter_origin = A:ORIGIN('ScriptTitle')
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterURL_origin = A:ORIGIN('URL')

					ChapterUrlAccess = UrlAccess;

					if not is_set (ChapterURL) and is_set (TitleLink) then
						Chapter = make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			elseif is_set (Chapter) then										-- |title not set
				Title = Periodical;												-- |encyclopedia set and |article set so map |encyclopedia to |title
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- Special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if is_set(A['Number']) then												-- cite techreport uses 'number', which other citations alias to 'issue'
			if not is_set(ID) then												-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { set_error('redundant_parameters', {wrap_style ('parameter', 'id') .. ' and ' .. wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if is_set(BookTitle) then
			Chapter = Title;
			Chapter_origin = 'title';
	--		ChapterLink = TitleLink;											-- |chapterlink= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			URL_origin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			TransChapter_origin = TransTitle_origin;
			Title = BookTitle;
			Format = '';
	--		TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		if is_set (Chapter) then
			table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'map') .. ' and ' .. wrap_style ('parameter', Chapter_origin)}, true ) } );	-- add error message
		end
		Chapter = A['Map'];
		Chapter_origin = A:ORIGIN('Map');
		ChapterURL = A['MapURL'];
		ChapterURL_origin = A:ORIGIN('MapURL');
		TransChapter = A['TransMap'];
		ScriptChapter = A['ScriptMap']
		ScriptChapter_origin = A:ORIGIN('ScriptMap')

		ChapterUrlAccess = MapUrlAccess;
		ChapterFormat = A['MapFormat'];

		Cartography = A['Cartography'];
		if is_set( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if is_set( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local SeriesLink = A['SeriesLink'];

		link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wikimarkup in |series-link= or wikimarkup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if is_set(Network) then table.insert(n, Network); end
		if is_set(Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if is_set (Season) and is_set (SeriesNumber) then					-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'season') .. ' and ' .. wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if is_set(Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if is_set(SeriesNumber) then table.insert(s, wrap_msg ('seriesnum', SeriesNumber, use_lowercase)); end
			if is_set(Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ScriptChapter_origin = A:ORIGIN('ScriptTitle');
			ChapterLink = TitleLink;											-- alias episodelink
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if is_set (ChapterLink) and not is_set (ChapterURL) then			-- link but not URL
				Chapter = make_wikilink (ChapterLink, Chapter);
			elseif is_set (ChapterLink) and is_set (ChapterURL) then			-- if both are set, URL links episode;
				Series = make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if is_set (Series) and is_set (SeriesLink) then
				Series = make_wikilink (SeriesLink, Series);
			end
			Series = wrap_style ('italic-title', Series);						-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite ssrn}}, before generation of COinS data.
	do
		if in_array (config.CitationClass, whitelist.preprint_template_list) then
			if not is_set (ID_list[config.CitationClass:upper()]) then			-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp; |citeseerx= required for their templates
				table.insert( z.message_tail, { set_error( config.CitationClass .. '_missing', {}, true ) } );	-- add error message
			end

			Periodical = ({['arxiv'] = 'arXiv', ['biorxiv'] = 'bioRxiv', ['citeseerx'] = 'CiteSeerX', ['ssrn'] = 'Social Science Research Network'})[config.CitationClass];
		end
	end

	-- handle type parameter for those CS1 citations that have default values
	if in_array(config.CitationClass, {&quot;AV-media-notes&quot;, &quot;interview&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if is_set(Degree) and &quot;Thesis&quot; == TitleType then						-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if is_set(TitleType) then													-- if type parameter is specified
		TitleType = substitute( cfg.messages['type'], TitleType);				-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging

	if not is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not is_set (Date) and is_set(PublicationDate) then					-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val=AccessDate, name=A:ORIGIN ('AccessDate')},
			['archive-date'] = {val=ArchiveDate, name=A:ORIGIN ('ArchiveDate')},
			['date'] = {val=Date, name=Date_origin},
			['doi-broken-date'] = {val=DoiBroken, name=A:ORIGIN ('DoiBroken')},
			['embargo'] = {val=Embargo, name=A:ORIGIN ('Embargo')},
			['lay-date'] = {val=LayDate, name=A:ORIGIN ('LayDate')},
			['publication-date'] ={val=PublicationDate, name=A:ORIGIN ('PublicationDate')},
			['year'] = {val=Year, name=A:ORIGIN ('Year')},
			};
		anchor_year, Embargo, error_message = dates(date_parameters_list, COinS_date);

-- start temporary Julian / Gregorian calendar uncertainty categorization
		if COinS_date.inter_cal_cat then
			add_prop_cat ('jul_greg_uncertainty');
		end
-- end temporary Julian / Gregorian calendar uncertainty categorization

		if is_set (Year) and is_set (Date) then									-- both |date= and |year= not normally needed; 
			local mismatch = year_date_check (Year, Date)
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				if is_set (error_message) then									-- if there is already an error message
					error_message = error_message .. ', ';						-- tack on this additional message
				end
				error_message = error_message .. '&amp;#124;year= / &amp;#124;date= mismatch';
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				add_maint_cat ('date_year');
			end
		end
		
		if not is_set(error_message) then										-- error free dates only
			local modified = false;												-- flag
			
			if is_set (DF) then													-- if we need to reformat dates
				modified = reformat_dates (date_parameters_list, DF, false);	-- reformat to DF format, use long month names if appropriate
			end

			if true == date_hyphen_to_dash (date_parameters_list) then			-- convert hyphens to dashes where appropriate
				modified = true;
				add_maint_cat ('date_format');									-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language,
	-- uncomment these three lines.  Not supported by en.wiki (for obvious reasons)
	-- set date_name_xlate() second argument to true to translate English digits to local digits (will translate ymd dates)
	--		if date_name_xlate (date_parameters_list, false) then
	--			modified = true;
	--		end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				LayDate = date_parameters_list['lay-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end
		else
			table.insert( z.message_tail, { set_error( 'bad_date', {error_message}, true ) } );	-- add this error message
		end
	end	-- end of do

	-- Link the title of the work if no |url= was provided, but we have a |pmc= or a |doi= with |doi-access=free
	-- Here we unset Embargo if PMC not embargoed (|embargo= not set in the citation) or if the embargo time has expired. Otherwise, holds embargo date
	Embargo = is_embargoed (Embargo);
	
	if config.CitationClass == &quot;journal&quot; and not is_set(URL) and not is_set(TitleLink) then
		if is_set(ID_list['PMC']) and not is_set (Embargo) then											-- if not embargoed or embargo has expired
			URL=cfg.id_handlers['PMC'].prefix .. ID_list['PMC'];				-- set url to be the same as the PMC external link if not embargoed
			URL_origin = cfg.id_handlers['PMC'].parameters[1];					-- set URL_origin to parameter name for use in error message if citation is missing a |title=
		elseif is_set(ID_list['DOI']) and ID_access_levels['DOI'] == &quot;free&quot; then
			URL=cfg.id_handlers['DOI'].prefix .. ID_list['DOI'];
			URL_origin = cfg.id_handlers['DOI'].parameters[1];
		end
		if is_set(URL) and is_set(AccessDate) then								-- access date requires |url=; pmc or doi created url is not |url=
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';												-- unset
		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not is_set(Title) and not is_set(TransTitle) and not is_set(ScriptTitle) then	-- has special case for cite episode
		table.insert( z.message_tail, { set_error( 'citation_missing_title', {'episode' == config.CitationClass and 'series' or 'title'}, true ) } );
	end

	if cfg.keywords_xlate[Title] == 'none' and
			in_array (config.CitationClass, {'journal', 'citation'}) and
			(is_set (Periodical) or is_set (ScriptPeriodical)) and
			('journal' == Periodical_origin or 'script-journal' == ScriptPeriodical_origin) then	-- special case for journal cites
				Title = '';														-- set title to empty string
				add_maint_cat ('untitled');
	end

	check_for_url ({															-- add error message when any of these parameters hold a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[Periodical_origin] = Periodical,
		[PublisherName_origin] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and is_set (Encyclopedia)) then
		if is_set (Chapter) and is_set (Title) and is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end
	
	-- this is the function call to COinS()
	local OCinSoutput = COinS({
		['Periodical'] = strip_apostrophe_markup (Periodical),					-- no markup in the metadata
		['Encyclopedia'] = Encyclopedia,										-- just a flag; content ignored by ~/COinS
		['Chapter'] = make_coins_title (coins_chapter, ScriptChapter),			-- Chapter and ScriptChapter stripped of bold / italic wikimarkup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = make_coins_title (coins_title, ScriptTitle),				-- Title and ScriptTitle stripped of bold / italic wikimarkup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Quarter'] = COinS_date.rftquarter,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = coins_pages or get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName or Newsgroup,							-- any apostrophe markup already removed from PublisherName
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, and {{cite ssrn}} AFTER generation of COinS data.
	if in_array (config.CitationClass, whitelist.preprint_template_list) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, CiteSeerX, or ssrn now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass and is_set (Newsgroup) then
		PublisherName = substitute (cfg.messages['newsgroup'], external_link( 'news:' .. Newsgroup, Newsgroup, Newsgroup_origin, nil ));
	end

	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local control = { 
			format = NameListFormat,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_names (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if is_set (Editors) then
				Editors, editor_etal = name_has_etal (Editors, editor_etal, false, 'editors');	-- find and remove variations on et al.
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
				end
				EditorCount = 2;												-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum , interviewer_etal = get_display_names (A['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal);
			Interviewers = list_people (control, interviewers_list, interviewer_etal);
		end
		do																		-- now do translators
			control.maximum , translator_etal = get_display_names (A['DisplayTranslators'], #t, 'translators', translator_etal);
			Translators = list_people (control, t, translator_etal);
		end
		do																		-- now do contributors
			control.maximum , contributor_etal = get_display_names (A['DisplayContributors'], #c, 'contributors', contributor_etal);
			Contributors = list_people (control, c, contributor_etal);
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_names (A['DisplayAuthors'], #a, 'authors', author_etal);

			last_first_list = list_people(control, a, author_etal);

			if is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors');	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if is_set (Authors) and is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
	-- an error message if the associated url is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (is_set (Periodical) or is_set (ScriptPeriodical)) and not is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not is_set(URL) then
		if in_array(config.CitationClass, {&quot;web&quot;,&quot;podcast&quot;, &quot;mailinglist&quot;}) or		-- |url= required for cite web, cite podcast, and cite mailinglist
			('citation' == config.CitationClass and ('website' == Periodical_origin or 'script-website' == ScriptPeriodical_origin)) then	-- and required for {{citation}} with |website= or |script-website=
				table.insert( z.message_tail, { set_error( 'cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if is_set(AccessDate) and not is_set(ChapterURL)then					-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { set_error( 'accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURL_origin, OriginalFormat, OriginalAccess;
	UrlStatus = UrlStatus:lower();												-- used later when assembling archived text
	if is_set( ArchiveURL ) then
		if is_set (ChapterURL) then 											-- if chapter-url is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURL_origin = ChapterURL_origin;								-- name of chapter-url parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=

			if 'live' ~= UrlStatus then
				ChapterURL = ArchiveURL											-- swap-in the archive's url
				ChapterURL_origin = A:ORIGIN('ArchiveURL')						-- name of archive-url parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived urls
			end
		elseif is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURL_origin = URL_origin;										-- name of url parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;

			if 'live' ~= UrlStatus then											-- if URL set then archive-url applies to it
				URL = ArchiveURL												-- swap-in the archive's url
				URL_origin = A:ORIGIN('ArchiveURL')								-- name of archive url parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived urls
			end
 		end
	end

	if in_array(config.CitationClass, {'web','news','journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and (is_set (Periodical) or is_set (ScriptPeriodical)) and not is_set (Encyclopedia)) then
			local chap_param;
			if is_set (Chapter) then											-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif is_set (ScriptChapter) then
				chap_param = ScriptChapter_origin;
			else is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if is_set (chap_param) then											-- if we found one
				table.insert( z.message_tail, { set_error( 'chapter_ignored', {chap_param}, true ) } );		-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if is_set (Contribution) and 0 &lt; #c then								-- if this is a contribution with contributor(s)
			if in_array (Contribution:lower(), cfg.keywords_lists.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, ScriptChapter_origin, Chapter, Chapter_origin, TransChapter, TransChapter_origin, ChapterURL, ChapterURL_origin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter.. sepc .. ' ';
		elseif is_set (ChapterFormat) then										-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title
	if is_set (ArchiveURL) and 
		(mw.ustring.match (mw.ustring.lower(Title), cfg.special_case_translation.archived_copy.en) or	-- if title is 'Archived copy' (place holder added by bots that can't find proper title)
		mw.ustring.match (mw.ustring.lower(Title), cfg.special_case_translation.archived_copy['local'])) then	-- local-wiki's form
			add_maint_cat ('archived_copy');									-- add maintenance category before we modify the content of Title
	end

	if Title:match ('^%(%(.*%)%)$') then										-- if keep as written markup:
		Title= Title:gsub ('^%(%((.*)%)%)$', '%1')								-- remove the markup
	else
		if '...' == Title:sub (-3) then											-- if elipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%'..sepc..'$', '');				-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end
	end

	if in_array(config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (is_set (Periodical) or is_set (ScriptPeriodical)) and not is_set (Encyclopedia)) or
		('map' == config.CitationClass and (is_set (Periodical) or is_set (ScriptPeriodical))) then		-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from Module provided quote marks
			Title = wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle, 'script-title');	-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
			TransTitle= wrap_style ('trans-quoted-title', TransTitle );
	elseif 'report' == config.CitationClass then								-- no styling for cite report
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle= wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang atribute, categorization, etc; must be done after title is wrapped
		TransTitle = wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if is_set(TransTitle) then
		if is_set(Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. set_error( 'trans_missing_title', {'title'} );
		end
	end

	if is_set (Title) then														-- TODO: is this the right place to be making wikisource urls?
		if is_set (TitleLink) and is_set (URL) then
			table.insert( z.message_tail, { set_error( 'wikilink_in_url', {}, true ) } );	-- set an error message because we can't have both
			TitleLink = '';														-- unset
		end
		
		if not is_set (TitleLink) and is_set (URL) then
			Title = external_link (URL, Title, URL_origin, UrlAccess) .. TransTitle .. TransError .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif is_set (TitleLink) and not is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = make_wikilink (TitleLink, Title) .. TransTitle .. TransError;
			end
		else
			local ws_url, ws_label;												-- Title has italic or quote markup by the time we get here which causes is_wikilink() to return 0 (not a wikilink)
			ws_url, ws_label, L = wikisource_url_make (Title:gsub('[\'&quot;](.-)[\'&quot;]', '%1'));	-- make ws url from |title= interwiki link (strip italic or quote markup); link portion L becomes tool tip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = Title .. TransTitle .. TransError;
			end
		end
	else
		Title = TransTitle .. TransError;
	end

	if is_set(Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if is_set (Conference) then
		if is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURL_origin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif is_set(ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURL_origin, nil );
	end

	if not is_set(Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if is_set(Minutes) then
			if is_set (Time) then
				table.insert( z.message_tail, { set_error( 'redundant_parameters', {wrap_style ('parameter', 'minutes') .. ' and ' .. wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if is_set(Time) then
				local TimeCaption = A['TimeCaption']
				if not is_set(TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = is_set(At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = is_set(Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Sections = A['Sections'];											-- Section (singular) is an alias of Chapter so set earlier
		local Inset = A['Inset'];
		
		if is_set( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if is_set( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif is_set( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	Others = is_set(Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	TitleNote = is_set(TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			add_maint_cat ('extra_text', 'edition');
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = is_set (Series) and wrap_msg ('series', {sepc, Series}) or &quot;&quot;;		-- not the same as SeriesNum
	OrigYear = is_set (OrigYear) and wrap_msg ('origyear', OrigYear) or '';
	Agency = is_set (Agency) and wrap_msg ('agency', {sepc, Agency}) or &quot;&quot;;
	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	Via = is_set (Via) and  wrap_msg ('via', Via) or '';

	if is_set(AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = substitute (retrv_text, AccessDate);						-- add retrieved text

		AccessDate = substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if is_set(ID) then ID = sepc ..&quot; &quot;.. ID; end
   	if &quot;thesis&quot; == config.CitationClass and is_set(Docket) then
		ID = sepc ..&quot; Docket &quot;.. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and is_set(Docket) then					-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	ID_list = build_id_list( ID_list, {IdAccessLevels=ID_access_levels, DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo=Embargo, Class = Class} );

	if is_set(URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URL_origin, UrlAccess );
	end

	if is_set(Quote) then
		if Quote:sub(1,1) == '&quot;' and Quote:sub(-1,-1) == '&quot;' then				-- if first and last characters of quote are quote marks
			Quote = Quote:sub(2,-2);											-- strip them off
		end
		Quote = sepc ..&quot; &quot; .. wrap_style ('quoted-text', Quote ); 				-- wrap in &lt;q&gt;...&lt;/q&gt; tags
		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if is_set(ArchiveURL) then
		local arch_text;
		if not is_set(ArchiveDate) then
			ArchiveDate = set_error('archive_missing_date');
		end
		if &quot;live&quot; == UrlStatus then
			arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( cfg.messages['archived-live'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil ) .. ArchiveFormat, ArchiveDate } );
			if not is_set (OriginalURL) then
				Archived = Archived .. &quot; &quot; .. set_error('archive_missing_url');							   
			end
		elseif is_set(OriginalURL) then											-- UrlStatus is empty, 'dead', 'unfit', 'usurped', 'bot: unknown'
			if in_array (UrlStatus, {'unfit', 'usurped', 'bot: unknown'}) then
				arch_text = cfg.messages['archived-unfit'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. &quot; &quot; .. arch_text .. ArchiveDate;				-- format already styled
				if 'bot: unknown' == UrlStatus then
					add_maint_cat ('bot:_unknown');								-- and add a category if not already added
				else
					add_maint_cat ('unfit');									-- and add a category if not already added
				end
			else																-- UrlStatus is empty, 'dead'
				arch_text = cfg.messages['archived-dead'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. &quot; &quot; .. substitute( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURL_origin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else																	-- OriginalUrl not set
			arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. substitute( arch_text, 
				{ set_error('archive_missing_url'), ArchiveDate } );
		end
	elseif is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if is_set(LayURL) then
		if is_set(LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if is_set(LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. safe_for_italics(LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif is_set (LayFormat) then												-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if is_set(Transcript) then
		if is_set(TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURL_origin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif is_set(TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURL_origin, nil );
	end

	local Publisher;
	if is_set(PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if is_set(PublisherName) then
		if is_set(PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif is_set(PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if (is_set (Periodical) or is_set (ScriptPeriodical) or is_set (TransPeriodical)) then
		if is_set(Title) or is_set(TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		else 
			Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		end
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then									-- cite speech only
		TitleNote = &quot; (Speech)&quot;;												-- annotate the citation
		if is_set (Periodical) then												-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if is_set (Conference) then											-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;							-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
		if is_set(Others) then Others = safe_join ({Others, sepc .. &quot; &quot;}, sepc) end		-- add terminal punctuation &amp; space; check for dup sepc; TODO why do we need to do this here?
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif in_array(config.CitationClass, {&quot;book&quot;,&quot;citation&quot;}) and not is_set(Periodical) then		-- special cases for book cites
		if is_set (Contributors) then											-- when we are citing foreword, preface, introduction, etc
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if is_set (Chapter) then												-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif is_set (Periodical) then											-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon;
	if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then	-- special case for cite AV media &amp; cite episode position transcript
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, Lay, Quote }, sepc );
	else
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, Lay, Quote }, sepc );
	end
	
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if is_set(Date) then
		if is_set (Authors) or is_set (Editors) then							-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date ..&quot;)&quot; .. OrigYear .. sepc .. &quot; &quot;;				-- in paranetheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon,-1,-1) == sepc) then							-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigYear;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigYear;							-- Date begins with sepc
			end
		end
	end	
	if is_set(Authors) then
		if (not is_set (Date)) then												-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if is_set(Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if is_set(Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then
					in_text = in_text:lower()									-- lowercase for cs2
				end
			end
			if EditorCount &lt;= 1 then
				post_text = &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot;;				-- be consistent with no-author, no-date case
			else
				post_text = &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot;;
			end
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if is_set (Contributors) then											-- book cite and we're citing the intro, preface, etc
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if is_set (Editors) and is_set (Date) then							-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not is_set (Date)) then											-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif is_set(Editors) then
		if is_set(Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if in_array(config.CitationClass, {&quot;journal&quot;,&quot;citation&quot;}) and is_set(Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if is_set(PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc ); 								--Deals with italics, spaces, etc.
		text = text:sub(1,-sepc:len()-1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if is_set(config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = string.format ('%s %s %s', 'citation', config.CitationClass, is_set (Mode) and Mode or 'cs1');	-- class=citation required for blue highlight when used with |ref=
	else
		options.class = string.format ('%s %s', 'citation', is_set (Mode) and Mode or 'cs2');
	end
	
	if is_set(Ref) and 'none' ~= cfg.keywords_xlate[Ref:lower()] then
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			if #namelist &gt; 0 then												-- if there are names in namelist
				id = anchor_id (namelist, year);								-- go make the CITEREF anchor
			else
				id = '';														-- unset
			end
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;(.-)&lt;/span&gt;&quot;, &quot;%1&quot;):gsub(&quot;%b&lt;&gt;&quot;,&quot;&quot;)) &lt;= 2 then	-- remove &lt;span&gt; tags and other html-like markup; then get length of what remains
		z.error_categories = {};
		text = set_error('empty_citation');
		z.message_tail = {};
	end
	
	local render = {};															-- here we collect the final bits for concatenation into the rendered citation

	if is_set(options.id) then													-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render, substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text}));	-- when |ref= is set
	else
		table.insert (render, substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text}));	-- all other cases
	end		

	table.insert (render, substitute (cfg.presentation['ocins'], {OCinSoutput}));	-- append metadata to the citation

	if 0 ~= #z.message_tail then
		table.insert (render, ' ');
		for i,v in ipairs( z.message_tail ) do
			if is_set(v[1]) then
				if i == #z.message_tail then
					table.insert (render, error_comment( v[1], v[2] ));
				else
					table.insert (render, error_comment( v[1] .. &quot;; &quot;, v[2] ));
				end
			end
		end
	end

	if 0 ~= #z.maintenance_cats then
		local maint_msgs = {};													-- here we collect all of the maint messages
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			local maint = {};													-- here we assemble a maintenence message
			table.insert (maint, v);											-- maint msg is the category name
			table.insert (maint, ' (');											-- open the link text
			table.insert (maint, make_wikilink (':Category:' .. v, 'link'));	-- add the link
			table.insert (maint, ')');											-- and close it
			table.insert (maint_msgs, table.concat (maint));					-- assemble new maint message and add it to the maint_msgs table
		end
		table.insert (render, substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs, ' ')));	-- wrap the group of maint message with proper presentation and save
	end
	
	if not no_tracking_cats then
		for _, v in ipairs( z.error_categories ) do
			table.insert (render, make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			table.insert (render, make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.properties_cats ) do								-- append properties categories
			table.insert (render, make_wikilink ('Category:' .. v));
		end
	end

	return table.concat (render);	
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class)
	local name = tostring (name);
	local state;
	local function state_test (state, name)										-- local function to do testing of state values
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
		return nil;
	end		

	if name:find ('#') then														-- # is a cs1|2 reserved character so parameters with # not permitted
		return nil;
	end

	if in_array (cite_class, whitelist.preprint_template_list ) then			-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[name];
		if true == state_test (state, name) then return true; end

		state = whitelist.preprint_arguments[cite_class][name];					-- look in the parameter-list for the template identified by cite_class
		if true == state_test (state, name) then return true; end

																				-- limited enumerated parameters list
		name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
		state = whitelist.limited_numbered_arguments[name];
		if true == state_test (state, name) then return true; end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates

	if in_array (cite_class, whitelist.unique_param_template_list) then			-- experiment for template-specific parameters for templates that accept parameters from the basic argument list
		state = whitelist.unique_arguments[cite_class][name];					-- look in the template-specific parameter-lists for the template identified by cite_class
		if true == state_test (state, name) then return true; end
	end																			-- if here, fall into general validation
		
	state = whitelist.basic_arguments[name];									-- all other templates; all normal parameters allowed
	if true == state_test (state, name) then return true; end

																				-- all enumerated parameters allowed
	name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );												-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
	state = whitelist.numbered_arguments[name];
	if true == state_test (state, name) then return true; end

	return false;																-- not supported because not found or name is set to nil
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe.  There are two tests made:
	{{cite ... |title=Title access-date=2016-03-17}}	-- the first parameter has a value and whitespace separates that value from the missing pipe parameter name
	{{cite ... |title=access-date=2016-03-17}}			-- the first parameter has no value (whitespace after the first = is trimmed by mediawiki)
cs1|2 shares some parameter names with xml/html atributes: class=, title=, etc.  To prevent false positives xml/html
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (parameter, value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove xml/html tags because attributes: class=, title=, etc 

	capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then										-- if the capture is a valid parameter name
		table.insert( z.message_tail, {set_error ('missing_pipe', parameter)});
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ P U N C T &gt;--------------------------------------

look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_punc (param, value)
	if 'number' == type (param) then
		return;
	end
	
	param = param:gsub ('%d+', '#');											-- enumerated name-list mask params allow terminal punct; normalize 
	if cfg.punct_skip[param] then
		return;																	-- parameter name found in the skip table so done
	end
	
	if value:match ('[,;:]$') then
		add_maint_cat ('extra_punct');											-- has extraneous punctuation; add maint cat
	end
end


--[[--------------------------&lt; C I T A T I O N &gt;--------------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

local function citation(frame)
	Frame = frame;																-- save a copy incase we need to display an error message in preview mode
	local pframe = frame:getParent()
	local validation, utilities, identifiers, metadata, styles;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		styles = 'Module:Citation/CS1/sandbox/styles.css';
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
		styles = 'Module:Citation/CS1/styles.css';

	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	dates = validation.dates;													-- imported functions from Module:Citation/CS1/Date validation
	year_date_check = validation.year_date_check;
	reformat_dates = validation.reformat_dates;
	date_hyphen_to_dash = validation.date_hyphen_to_dash;
	date_name_xlate = validation.date_name_xlate;

	is_set = utilities.is_set;													-- imported functions from Module:Citation/CS1/Utilities
	in_array = utilities.in_array;
	substitute = utilities.substitute;
	error_comment = utilities.error_comment;
	set_error = utilities.set_error;
	select_one = utilities.select_one;
	add_maint_cat = utilities.add_maint_cat;
	wrap_style = utilities.wrap_style;
	safe_for_italics = utilities.safe_for_italics;
	is_wikilink = utilities.is_wikilink;
	make_wikilink = utilities.make_wikilink;
	strip_apostrophe_markup = utilities.strip_apostrophe_markup;

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	extract_ids = identifiers.extract_ids;										-- imported functions from Module:Citation/CS1/Identifiers
	build_id_list = identifiers.build_id_list;
	is_embargoed = identifiers.is_embargoed;
	extract_id_access_levels = identifiers.extract_id_access_levels;
	
	make_coins_title = metadata.make_coins_title;								-- imported functions from Module:Citation/CS1/COinS
	get_coins_pages = metadata.get_coins_pages;
	COinS = metadata.COinS;

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text, error_state;

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do											-- get parameters from the {{#invoke}} frame
		config[k] = v;
	--	args[k] = v;															-- crude debug support that allows us to render a citation from module {{#invoke:}}; skips parameter validation; TODO: keep?
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	for k, v in pairs( pframe.args ) do											-- get parameters from the parent (template) frame
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- Exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = set_error( 'text_ignored', {v}, true );
					end
				elseif validate( k:lower(), config.CitationClass ) then 
					error_text, error_state = set_error( 'parameter_ignored_suggest', {k, k:lower()}, true );	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no caputre in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = substitute (param, capture);				-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text, error_state = set_error ('parameter_ignored_suggest', {k, param}, true);	-- set the suggestion error message
							else
								error_text, error_state = set_error( 'parameter_ignored', {param}, true );	-- suggested param not supported by this template
								v = '';											-- unset
							end
						end
					end
					if not is_set (error_text) then								-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = set_error( 'parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = set_error( 'parameter_ignored', {k}, true );
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end

			args[k] = v;														-- save this parameter and its value

																				-- crude debug support that allows us to render a citation from module {{#invoke:}} TODO: keep?
	--	elseif args[k] ~= nil or (k == 'postscript') then						-- when args[k] has a value from {{#invoke}} frame (we don't normally do that)
	--		args[k] = v;														-- overwrite args[k] with empty string from pframe.args[k] (template frame); v is empty string here
		end																		-- not sure about the postscript bit; that gets handled in parameter validation; historical artifact?
	end	

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);											-- look for invisible characters
		end
		has_extraneous_punc (k, v);												-- look for extraneous terminal punctuation in parameter values
		missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?
	end

	return table.concat ({citation0( config, args), frame:extensionTag ('templatestyles', '', {src=styles})});
end

--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {citation = citation};</text>
      <sha1>7isf9y9invyhsn9r6zq9krk0bgh95rw</sha1>
    </revision>
    <revision>
      <id>4733</id>
      <parentid>4732</parentid>
      <timestamp>2020-10-10T13:23:05Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4733</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="203921" sha1="9edlfct2jxg3jf4jt3x74p2dekdt05l" xml:space="preserve">require('Module:No globals');

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------

each of these counts against the Lua upvalue limit

]]

local validation;																-- functions in Module:Citation/CS1/Date_validation

local utilities;																-- functions in Module:Citation/CS1/Utilities
local z ={};																	-- table of tables in Module:Citation/CS1/Utilities

local identifiers;																-- functions and tables in Module:Citation/CS1/Identifiers
local metadata;																	-- functions in Module:Citation/CS1/COinS
local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

declare variables here that have page-wide scope that are not brought in from other modules; that are created here and used here

]]

local added_deprecated_cat;														-- Boolean flag so that the category is added only once
local added_vanc_errs;															-- Boolean flag so we only emit one Vancouver error / category

local Frame;																	-- holds the module's frame table


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if utilities.is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a Boolean declared in page scope variables above

]]

local function add_vanc_error (source)
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { utilities.set_message ( 'err_vancouver', {source}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a URI scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of TLDs: https://www.iana.org/domains/root/db

RFC 952 (modified by RFC 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the TLD.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a URL with a scheme) will be stripped
here.  Perhaps not necessary but retained in case it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ASCII characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the TLD) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and TLD or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%w]') then											-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at Wikisource
		return false;
	end

	local patterns = {															-- patterns that look like URLs
		'%f[%w][%w][%w%-]+[%w]%.%a%a+$',										-- three or more character hostname.hostname or hostname.tld
		'%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$',									-- internationalized domain name with ACE prefix
		'%f[%a][qxz]%.com$',													-- assigned one character .com hostname (x.com times out 2015-12-10)
		'%f[%a][iq]%.net$',														-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		'%f[%w][%w]%.%a%a$',													-- one character hostname and ccTLD (2 chars)
		'%f[%w][%w][%w]%.%a%a+$',												-- two character hostname and TLD
		'^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?',								-- IPv4 address
		}

	for _, pattern in ipairs (patterns) do										-- loop through the patterns list
		if domain:match (pattern) then
			return true;														-- if a match then we think that this thing that purports to be a URL is a URL
		end
	end

	for _, d in ipairs ({'cash', 'company', 'today', 'org'}) do					-- look for single letter second level domain names for these top level domains
		if domain:match ('%f[%w][%w]%.' .. d) then
			return true
		end
	end
	return false;																-- no matches, we don't know what this thing is
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a URL appear to be a valid URL; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if utilities.is_set (scheme) then											-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when URL is protocol-relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a URL into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following TLD) (if any) and any path(/), query(?) or fragment(#).

If protocol-relative URL, return nil scheme and domain else return nil for both scheme and domain.

When not protocol-relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Any URL that does not have news: scheme must have authority indicator (//).  TODO: are there other common schemes
like news: that don't use authority indicator?

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol-relative URL
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		if utilities.is_set (authority) then
			authority = authority:gsub ('//', '', 1);							-- replace place 1 pair of '/' with nothing;
			if utilities.is_set(authority) then									-- if anything left (1 or 3+ '/' where authority should be) then
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		else
			if not scheme:match ('^news:') then									-- except for news:..., MediaWiki won't link URLs that do not have authority indicator; TODO: a better way to do this test?
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link=, etc. for properly formatted content: no wikilinks, no URLs

Link parameters are to hold the title of a Wikipedia article, so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki URLs and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid URL (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid URL (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from URL; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid URL
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wiki-linked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

check &lt;link&gt; for inter-language interwiki-link prefix.  prefix must be a MediaWiki-recognized language
code and must begin with a colon.

]]

local function link_title_ok (link, lorig, title, torig)
local orig;
	if utilities.is_set (link) then 											-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		elseif link:match ('^%a+:') then										-- if the link is what looks like an interwiki
			local prefix = link:match ('^(%a+):'):lower();						-- get the interwiki prefix

			if cfg.inter_wiki_map[prefix] then									-- if prefix is in the map, must have preceding colon
				orig = lorig;													-- flag as error
			end
		end
	end

	if utilities.is_set (orig) then
		link = '';																-- unset
		table.insert( z.message_tail, { utilities.set_message ( 'err_bad_paramlink', orig)});	-- URL or wikilink in |title= with |title-link=;
	end
	
	return link;																-- link if ok, empty string else
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the URL into scheme and domain
portions, or for protocol-relative (//example.com) URLs, just the domain.  Use is_url() to validate the two
portions of the URL.  If both are valid, or for protocol-relative if domain is valid, return true, else false.

Because it is different from a standard URL, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper URL
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from URL;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a URL.  The test will also find external wikilinks
that use protocol-relative URLs. Also finds bare URLs.

The frontier pattern prevents a match on interwiki-links which are similar to scheme:path URLs.  The tests that
find bracketed URLs are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext. wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol-relative ext. wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare URL with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol-relative bare URL: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a URL
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a URL add an error message
			if utilities.is_set(error_message) then								-- once we've added the first portion of the error message ...
				error_message = error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message = error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if utilities.is_set (error_message) then									-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { utilities.set_message ( 'err_param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { utilities.set_message ( 'err_wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source, access)
	local error_str = &quot;&quot;;
	local domain;
	local path;
	local base_url;

	if not utilities.is_set ( label ) then
		label = URL;
		if utilities.is_set ( source ) then
			error_str = utilities.set_message ( 'err_bare_url_missing_title', { utilities.wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = utilities.set_message ( 'err_bad_url', {utilities.wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the URL into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['['] = '%5b', [']'] = '%5d'});					-- replace '[' and ']' with their percent-encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wiki-markup URL

	if utilities.is_set (access) then											-- access level (subscription, registration, limited)
		base_url = utilities.substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end
	
	return table.concat ({base_url, error_str});
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a Boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { utilities.set_message ( 'err_deprecated_params', {name}, true ) } );	-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wiki-markup) are not kerned.

Replaces Unicode quote marks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc.; not for book titles.

]=]

local function kern_quotes (str)
	local cap = '';
	local cap2 = '';
	local wl_type, label, link;

	wl_type, label, link = utilities.is_wikilink (str);							-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-wl-both'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = utilities.substitute (cfg.presentation['kern-wl-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-wl-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label = mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label = mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap, cap2 = mw.ustring.match (label, &quot;^([\&quot;\'])([^\'].+)&quot;);				-- match leading double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-left'], {cap, cap2});
		end
	
		cap, cap2 = mw.ustring.match (label, &quot;^(.+[^\'])([\&quot;\'])$&quot;)				-- match trailing double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-right'], {cap, cap2});
		end
		
		if 2 == wl_type then
			str = utilities.make_wikilink (link, label);						-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin-based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate RTL languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO 639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO 639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title=, |script-chapter=, |script-&lt;periodical&gt;=

]]

local function format_script_value (script_value, script_param)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%l?%s*:') then									-- if first 3 or 4 non-space characters are script language prefix
		lang = script_value:match('^(%l%l%l?)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not utilities.is_set (lang) then
			table.insert( z.message_tail, { utilities.set_message ( 'err_script_parameter', {script_param, 'missing title part'}, true ) } );		-- prefix without 'title'; add error message
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_code_remap[lang] or mw.language.fetchLanguageName( lang, cfg.this_wiki_code );	-- get language name so that we can use it to categorize
		if utilities.is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l+%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if utilities.in_array (lang, cfg.script_lang_codes) then
				utilities.add_prop_cat ('script_with_name', {name, lang})
			else
				table.insert( z.message_tail, { utilities.set_message ( 'err_script_parameter', {script_param, 'unknown language code'}, true ) } );	-- unknown script-language; add error message
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			table.insert( z.message_tail, { utilities.set_message ( 'err_script_parameter', {script_param, 'invalid language code'}, true ) } );		-- invalid language code; add error message
			lang = '';															-- invalid so set lang to empty string
		end
	else
		table.insert( z.message_tail, { utilities.set_message ( 'err_script_parameter', {script_param, 'missing prefix'}, true ) } );				-- no language code prefix; add error message
	end
	script_value = utilities.substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is RTL

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script, script_param)
	if utilities.is_set (script) then
		script = format_script_value (script, script_param);					-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; returns empty string on error
		if utilities.is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not utilities.is_set ( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return utilities.substitute ( msg, str );								-- including template text
	else
		return utilities.substitute ( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;----------------------------------------

Makes a Wikisource URL from Wikisource interwiki-link.  Returns the URL and appropriate label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;
	local wikisource_prefix = table.concat ({'https://', cfg.this_wiki_code, '.wikisource.org/wiki/'});

	wl_type, D, L = utilities.is_wikilink (str);								-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 1 == wl_type then													-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end
	
	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable URL
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent encoding of fragment marker
	end

	return ws_url, ws_label, L or D;											-- return proper URL or nil and a label or nil
end


--[[--------------------------&lt; F O R M A T _ P E R I O D I C A L &gt;--------------------------------------------

Format the three periodical parameters: |script-&lt;periodical&gt;=, |&lt;periodical&gt;=, and |trans-&lt;periodical&gt;= into a single Periodical meta-
parameter.

]]

local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)
	local periodical_error = '';

	if not utilities.is_set (periodical) then
		periodical = '';														-- to be safe for concatenation
	else
		periodical = utilities.wrap_style ('italic-title', periodical);			-- style 
	end

	periodical = script_concatenate (periodical, script_periodical, script_periodical_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (trans_periodical) then
		trans_periodical = utilities.wrap_style ('trans-italic-title', trans_periodical);
		if utilities.is_set (periodical) then
			periodical = periodical .. ' ' .. trans_periodical;
		else																	-- here when trans-periodical without periodical or script-periodical
			periodical = trans_periodical;
			periodical_error = ' ' .. utilities.set_message ('err_trans_missing_title', {'periodical'});
		end
	end

	return periodical .. periodical_error;
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (script_chapter, script_chapter_source, chapter, chapter_source, trans_chapter, trans_chapter_source, chapter_url, chapter_url_source, no_quotes, access)
	local chapter_error = '';

	local ws_url, ws_label, L = wikisource_url_make (chapter);					-- make a wikisource URL and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', '');										-- replace underscore separaters with space characters
		chapter = ws_label;
	end

	if not utilities.is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from module provided quote marks
			chapter = utilities.wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, script_chapter, script_chapter_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (chapter_url) then
		chapter = external_link (chapter_url, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');	-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if utilities.is_set (trans_chapter) then
		trans_chapter = utilities.wrap_style ('trans-quoted-title', trans_chapter);
		if utilities.is_set (chapter) then
			chapter = chapter .. ' ' .. trans_chapter;
		else																	-- here when trans_chapter without chapter or script-chapter
			chapter = trans_chapter;
			chapter_source = trans_chapter_source:match ('trans%-?(.+)');		-- when no chapter, get matching name from trans-&lt;param&gt;
			chapter_error = ' ' .. utilities.set_message ('err_trans_missing_title', {chapter_source});
		end
	end

	return chapter .. chapter_error;
end


--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for non-printable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the Wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i = 1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no Unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char = cfg.invisible_chars[i][1]									-- the character or group name
		local pattern = cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position and (char == 'zero width joiner') then						-- if we found a zero-width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- it's ok if one of the Indic scripts
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and utilities.in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { utilities.set_message ( 'err_invisible_char', {err_msg, utilities.wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i = i+1;																-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper ( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function ( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = utilities.select_one ( args, list, 'err_redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] .. ': ' .. k);
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap = '';
	local cap2 = '';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = utilities.substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = utilities.substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if utilities.is_set (title_type) then
		if 'none' == cfg.keywords_xlate[title_type] then
			title_type = '';													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash under certain conditions.  The hyphen must separate like items; unlike items are
returned unmodified.  These forms are modified:
	letter - letter (A - B)
	digit - digit (4-5)
	digit separator digit - digit separator digit (4.1-4.5 or 4-1-4-5)
	letterdigit - letterdigit (A1-A5) (an optional separator between letter and digit is supported – a.1-a.5 or a-1-a-5)
	digitletter - digitletter (5a - 5d) (an optional separator between letter and digit is supported – 5.a-5.d or 5-a-5-d)

any other forms are returned unmodified.

str may be a comma- or semicolon-separated list

]]

local function hyphen_to_dash( str )
	if not utilities.is_set (str) then
		return str;
	end

	local accept;																-- Boolean
	str, accept = utilities.has_accept_as_written (str);						-- remove accept-this-as-written markup when it wraps all of str
	if accept then
		return str;																-- when markup removed, nothing to do, we're done
	end

	str = str:gsub ('&amp;[nm]dash;', {['&amp;ndash;'] = '–', ['&amp;mdash;'] = '—'});		-- replace &amp;mdash; and &amp;ndash; entities with their characters; semicolon mucks up the text.split
	str = str:gsub ('&amp;#45;', '-');												-- replace HTML numeric entity with hyphen character
	str = str:gsub ('&amp;nbsp;', ' ');												-- replace &amp;nbsp; entity with generic keyboard space character
	
	local out = {};
	local list = mw.text.split (str, '%s*[,;]%s*');								-- split str at comma or semicolon separators if there are any

	for _, item in ipairs (list) do												-- for each item in the list
		if mw.ustring.match (item, '^%w*[%.%-]?%w+%s*[%-–—]%s*%w*[%.%-]?%w+$') then	-- if a hyphenated range or has endash or emdash separators
			if item:match ('^%a+[%.%-]?%d+%s*%-%s*%a+[%.%-]?%d+$') or			-- letterdigit hyphen letterdigit (optional separator between letter and digit)
				item:match ('^%d+[%.%-]?%a+%s*%-%s*%d+[%.%-]?%a+$') or			-- digitletter hyphen digitletter (optional separator between digit and letter)
				item:match ('^%d+[%.%-]%d+%s*%-%s*%d+[%.%-]%d+$') or			-- digit separator digit hyphen digit separator digit
				item:match ('^%d+%s*%-%s*%d+$') or								-- digit hyphen digit
				item:match ('^%a+%s*%-%s*%a+$') then							-- letter hyphen letter
					item = item:gsub ('(%w*[%.%-]?%w+)%s*%-%s*(%w*[%.%-]?%w+)', '%1–%2');	-- replace hyphen, remove extraneous space characters
			else
				item = mw.ustring.gsub (item, '%s*[–—]%s*', '–');				-- for endash or emdash separated ranges, replace em with en, remove extraneous whitespace
			end
		end
		item = utilities.has_accept_as_written (item);							-- remove accept-this-as-written markup when it wraps all of str
		table.insert (out, item);												-- add the (possibly modified) item to the output table
	end

	return table.concat (out, ', ');											-- concatenate the output table into a comma separated string
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'duplicate character'
		if 1 == #duplicate_char then											-- for single byte ASCII characters use the string library functions
			f.gsub = string.gsub
			f.match = string.match
			f.sub = string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub = mw.ustring.gsub
			f.match = mw.ustring.match
			f.sub = mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1, 1) == '&lt;' then										-- special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove HTML markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1, 1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc.?
				trim = false;
				end_chr = f.sub(str, -1, -1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr .. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1, -2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5, -1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3, -1) == duplicate_char .. '&quot;]' then		-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2, -1) == duplicate_char .. &quot;]&quot; then		-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2, -1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1, -3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains HTML markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows HTML markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;------------------------------------------------------------

returns true is suffix is properly formed Jr, Sr, or ordinal in the range 1–9.  Puncutation not allowed.

]]

local function is_suffix (suffix)
	if utilities.in_array (suffix, {'Jr', 'Sr', 'Jnr', 'Snr', '1st', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written outside of the code editor and pasted here because the code editor gets confused between character insertion point and cursor position.
The test has been rewritten to use decimal character escape sequence for the individual bytes of the Unicode characters so that it is not necessary
to use an external editor to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first, suffix)
	if not suffix then
		if first:find ('[,%s]') then											-- when there is a space or comma, might be first name/initials + generational suffix
			first = first:match ('(.-)[,%s]+');									-- get name/initials
			suffix = first:match ('[,%s]+(.+)$');								-- get generational suffix
		end
	end
	if utilities.is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error (cfg.err_msg_supl.suffix);
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error (cfg.err_msg_supl['non-Latin char']);
			return false;														-- not a string of Latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-style=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc.) to be rendered as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the Unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just initials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error (cfg.err_msg_supl.suffix);					-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word

	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i], 1, 1));				-- insert the initial at end of initials table
		end
		i = i+1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; L I S T _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors, contributors, editors, interviewers, translators) 

names in the list will be linked when
	|&lt;name&gt;-link= has a value
	|&lt;name&gt;-mask- does NOT have a value; masked names are presumed to have been rendered previously so should have been linked there

when |&lt;name&gt;-mask=0, the associated name is not rendered

]]

local function list_people (control, people, etal)
	local sep;
	local namesep;
	local format = control.format;
	local maximum = control.maximum;
	local lastauthoramp = control.lastauthoramp;							-- TODO: delete after deprecation
	local name_list = {};

	if 'vanc' == format then													-- Vancouver-like name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between names is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
		lastauthoramp = nil;												-- TODO: delete after deprecation	-- unset because isn't used by Vancouver style
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between names is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub (-1, -1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if utilities.is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end		-- returned 0 is for EditorCount; not used for other names
	
	for i, person in ipairs (people) do
		if utilities.is_set (person.last) then
			local mask = person.mask;
			local one;
			local sep_one = sep;

			if utilities.is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			end
			
			if mask then
				local n = tonumber (mask);										-- convert to a number if it can be converted; nil else
				if n then
					one = 0 ~= n and string.rep(&quot;&amp;mdash;&quot;,n) or nil;			-- make a string of (n &gt; 0) mdashes, nil else, to replace name
					person.link = nil;											-- don't create link to name if name is replaces with mdash string or has been set nil
				else
					one = mask;													-- replace name with mask text (must include name-list separator)
					sep_one = &quot; &quot;;												-- modify name-list separator
				end
			else
				one = person.last;												-- get surname
				local first = person.first										-- get given name
				if utilities.is_set (first) then
					if (&quot;vanc&quot; == format) then									-- if Vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials (first);					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
			end
			if utilities.is_set (person.link) then
				one = utilities.make_wikilink (person.link, one);				-- link author/editor
			end
			if one then															-- if &lt;one&gt; has a value (name, mdash replacement, or mask text replacement)
				table.insert (name_list, one);									-- add it to the list of names
				table.insert (name_list, sep_one);								-- add the proper name-list separator
			end
		end
	end

	local count = #name_list / 2;												-- (number of names + number of separators) divided by 2
	if 0 &lt; count then 
		if 1 &lt; count and not etal then
			if 'amp' == format or utilities.is_set (lastauthoramp) then			-- TODO: delete lastauthoramp after deprecation
				name_list[#name_list-2] = &quot; &amp; &quot;;								-- replace last separator with ampersand text
			elseif 'and' == format then
				if 2 == count then
					name_list[#name_list-2] = cfg.presentation.sep_nl_and;		-- replace last separator with 'and' text
				else
					name_list[#name_list-2] = cfg.presentation.sep_nl_end;		-- replace last separator with '(sep) and' text
				end
			end
		end
		name_list[#name_list] = nil;											-- erase the last separator
	end

	local result = table.concat (name_list);									-- construct list
	if etal and utilities.is_set (result) then									-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've got a last-first list and etal so add et al.
	end
	
	return result, count;														-- return name-list string and count of number of names (count used for editor names only)
end


--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]

local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if utilities.is_set (id) then												-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of name parameters (author, editor, etc.) for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the associated |display-&lt;names&gt;=etal parameter

]]

local function name_has_etal (name, etal, nocat, param)

	if utilities.is_set (name) then												-- name can be nil in which case just return
		local patterns = cfg.et_al_patterns;									--get patterns from configuration
		
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns
			if name:match (pattern) then										-- if this 'et al' pattern is found in name
				name = name:gsub (pattern, '');									-- remove the offending text
				etal = true;													-- set flag (may have been set previously here or by |display-&lt;names&gt;=etal)
				if not nocat then												-- no categorization for |vauthors=
					table.insert( z.message_tail, {utilities.set_message ('err_etal', {param})});	-- and set an error if not added
				end
			end
		end
	end

	return name, etal;
end


--[[--------------------------&lt; N A M E _ I S _ N U M E R I C &gt;------------------------------------------------

Add maint cat when name parameter value does not contain letters.  Does not catch mixed alphanumeric names so
|last=A. Green (1922-1987) does not get caught in the current version of this test but |first=(1888) is caught.

returns nothing

]]

local function name_is_numeric (name, list_name)
	if utilities.is_set (name) then
		if mw.ustring.match (name, '^[%A]+$') then								-- when name does not contain any letters
			utilities.set_message ('maint_numeric_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
		end
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E D _ M A R K U P &gt;------------------------------------------

Evaluates the content of author and editor parameters for extraneous editor annotations: ed, ed., eds, (Ed.), etc.
These annotation do not belong in author parameters and are redundant in editor parameters.  If found, the function
adds the editor markup maintenance category.

returns nothing

]]

local function name_has_ed_markup (name, list_name)
	local patterns = cfg.editor_markup_patterns;								-- get patterns from configuration

	if utilities.is_set (name) then
		for _, pattern in ipairs (patterns) do									-- spin through patterns table and
			if name:match (pattern) then
				utilities.set_message ('maint_extra_text_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
				break;
			end
		end
	end
end


--[[--------------------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;----------------------------------------

Evaluates the content of last/surname (authors etc.) parameters for multiple names.  Multiple names are indicated
if there is more than one comma or any semicolons.  If found, the function adds the multiple name maintenance category.

returns nothing

]]

local function name_has_mult_names (name, list_name)
	local _, commas, semicolons;
	if utilities.is_set (name) then
		_, commas = name:gsub (',', '');										-- count the number of commas
		_, semicolons = name:gsub (';', '');									-- count the number of semicolons
		
		if 1 &lt; commas or 0 &lt; semicolons then												
			utilities.set_message ('maint_mult_names', cfg.special_case_translation [list_name]);	-- add a maint message
		end
	end
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------

This function calls various name checking functions used to validate the content of the various name-holding
parameters.

]]

local function name_checks (last, first, list_name)
	local accept_name;

	if utilities.is_set (last) then
		last, accept_name = utilities.has_accept_as_written (last);				-- remove accept-this-as-written markup when it wraps all of &lt;last&gt;
		
		if not accept_name then													-- &lt;last&gt; not wrapped in accept-as-written markup
			name_has_mult_names (last, list_name);								-- check for multiple names in the parameter (last only)
			name_has_ed_markup (last, list_name);								-- check for extraneous 'editor' annotation
			name_is_numeric (last, list_name);									-- check for names that are compsed of digits and punctuation
		end
	end

	if utilities.is_set (first) then
		first, accept_name = utilities.has_accept_as_written (first);			-- remove accept-this-as-written markup when it wraps all of &lt;first&gt;

		if not accept_name then														-- &lt;first&gt; not wrapped in accept-as-written markup
			name_has_ed_markup (first, list_name);								-- check for extraneous 'editor' annotation
			name_is_numeric (first, list_name);									-- check for names that are compsed of digits and punctuation
		end
	end

	return last, first;															-- done
end


--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};															-- table of names
	local last;																	-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;																-- loop counter/indexer
	local n = 1;																-- output table indexer
	local count = 0;															-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal = false;															-- return value set to true when we find some form of et al. in an author parameter

	local last_alias, first_alias, link_alias;									-- selected parameter aliases used in error messaging
	while true do
		last, last_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'err_redundant_parameters', i );		-- search through args for name components beginning at 1
		first, first_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'err_redundant_parameters', i );
		link, link_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i );
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.
		last, first = name_checks (last, first, list_name);						-- multiple names, extraneous annotation, etc. checks
		
		if first and not last then												-- if there is a firstn without a matching lastn
			local alias = first_alias:find ('given', 1, true) and 'given' or 'first';	-- get first or given form of the alias
			table.insert (z.message_tail, { utilities.set_message ( 'err_first_missing_last', {
				first_alias,													-- param name of alias missing its mate
				first_alias:gsub (alias, {['first'] = 'last', ['given'] = 'surname'}),	-- make param name appropriate to the alias form
				}, true ) } );													-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			local result;
			link = link_title_ok (link, link_alias, last, last_alias);			-- check for improper wiki-markup
			if first then
				link = link_title_ok (link, link_alias, first, first_alias);	-- check for improper wiki-markup
			end

			names[n] = {last = last, first = first, link = link, mask = mask, corporate = false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { utilities.set_message ( 'err_missing_name', {list_name:match (&quot;(%w+)List&quot;):lower(), i - 1}, true ) } );	-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names and the etal flag
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because case of the source may be incorrect
or different from the case that WikiMedia uses, the name comparisons are done in lower case and when a match is
found, the Wikimedia version (assumed to be correct) is returned along with the code.  When there is no match, we
return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') returns a list of languages that in some cases may include
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.  Most (all?) of these languages are not used a 'language' codes per se, rather they
are used as sub-domain names: cbk-zam.wikipedia.org.  A list of language names and codes supported by fetchLanguageNames()
can be found at Template:Citation Style documentation/language/doc

Names that are included in the list will be found if that name is provided in the |language= parameter.  For example,
if |language=Chavacano de Zamboanga, that name will be found with the associated code 'cbk-zam'.  When names are found
and the associated code is not two or three characters, this function returns only the WikiMedia language name.

Some language names have multiple entries under different codes:
	Aromanian has code rup and code roa-rup
When this occurs, this function returns the language name and the 2- or 3-character code

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	if cfg.lang_name_remap[lang:lower()] then									-- if there is a remapped name (because MediaWiki uses something that we don't think is correct)
		return cfg.lang_name_remap[lang:lower()][1], cfg.lang_name_remap[lang:lower()][2];	-- for this language 'name', return a possibly new name and appropriate code
	end

	local ietf_code;															-- because some languages have both IETF-like codes and ISO 639-like codes
	local ietf_name;
	
	local langlc = mw.ustring.lower (lang);										-- lower-case version for comparisons

	for code, name in pairs (cfg.languages) do									-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower (name) then
			if 2 == #code or 3 == #code then									-- two- or three-character codes only; IETF extensions not supported
				return name, code;												-- so return the name and the code
			end
			ietf_code = code;													-- remember that we found an IETF-like code and save its name
			ietf_name = name;													-- but keep looking for a 2- or 3-char code
		end
	end
																				-- didn't find name with 2- or 3-char code; if IETF-like code found return
	return ietf_code and ietf_name or lang;										-- associated name; return original language text else
end


--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code is recognized by MediaWiki,
use the returned name; if not, then use the value that was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is assigned to the category for
that code: Category:Norwegian-language sources (no).  For valid three-character code languages, the page is assigned
to the single category for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does not recognize three-character
equivalents of two-character codes: code 'ar' is recognized but code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are
separated from each other by commas with optional space characters.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki_name = mw.language.fetchLanguageName (cfg.this_wiki_code, cfg.this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang
		name = cfg.lang_code_remap[lang:lower()];								-- first see if this is a code that is not supported by MediaWiki but is in remap

		if name then															-- there was a remapped code so
			if not lang:match ('^%a%a%a?%-x%-%a+$') then						-- if not a private IETF tag
				lang = lang:gsub ('^(%a%a%a?)%-.*', '%1');						-- strip IETF tags from code
			end
		else
			lang = lang:gsub ('^(%a%a%a?)%-.*', '%1');							-- strip any IETF-like tags from code
			if 2 == lang:len() or 3 == lang:len() then							-- if two-or three-character code
				name = mw.language.fetchLanguageName (lang:lower(), cfg.this_wiki_code);	-- get language name if |language= is a proper code
			end
		end

		if utilities.is_set (name) then											-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, cfg.this_wiki_code);			-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if utilities.is_set (code) then											-- only 2- or 3-character codes
			name = cfg.lang_code_remap[code] or name;							-- override wikimedia when they misuse language codes/names

			if cfg.this_wiki_code ~= code then									-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					utilities.add_prop_cat ('foreign_lang_source' .. code, {name, code});	-- categorize it; code appended to allow for multiple language categorization
				else															-- or is a recognized language (but has a three-character code)
					utilities.add_prop_cat ('foreign_lang_source_2' .. code, {code});		-- categorize it differently TODO: support multiple three-character code categories per cs1|2 template
				end
			elseif cfg.local_lang_cat_enable then								-- when the language and this wiki's language are the same and categorization is enabled
				utilities.add_prop_cat ('local_lang_source', {name, code});		-- categorize it
			end
		else
			utilities.set_message ('maint_unknown_lang');						-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
 
	name = utilities.make_sep_list (#language_list, language_list);

	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings
At en.wiki, for cs1:
	ps gets:	'.'
	sep gets:	'.'

]]

local function set_cs1_style (ps)
	if not utilities.is_set (ps) then											-- unless explicitly set to something
		ps = cfg.presentation['ps_cs1'];										-- terminate the rendered citation
	end
	return cfg.presentation['sep_cs1'], ps;										-- element separator
end


--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings
At en.wiki, for cs2:
	ps gets:	'' (empty string - no terminal punctuation)
	sep gets:	','

]]

local function set_cs2_style (ps, ref)
	if not utilities.is_set (ps) then											-- if |postscript= has not been set, set cs2 default
		ps = cfg.presentation['ps_cs2'];										-- terminate the rendered citation
	end
	if not utilities.is_set (ref) then											-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return cfg.presentation['sep_cs2'], ps, ref;								-- element separator
end


--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end


--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end

	if cfg.keywords_xlate[ps:lower()] == 'none' then							-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end


--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a URL has the file extension that is one of the PDF file extensions used by [[MediaWiki:Common.css]] when
applying the PDF icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or
		url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
		url:match ('%.PDF&amp;#035') or url:match ('%.pdf&amp;#035');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies CSS style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching URL parameter.  If the format parameter is not set and the URL contains a file extension that
is recognized as a PDF document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if utilities.is_set (format) then
		format = utilities.wrap_style ('format', format);						-- add leading space, parentheses, resize
		if not utilities.is_set (url) then
			format = format .. ' ' .. utilities.set_message ( 'err_format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if URL is a PDF file then
		format = utilities.wrap_style ('format', 'PDF');						-- set format to PDF
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[--------------------------&lt; G E T _ D I S P L A Y _ N A M E S &gt;--------------------------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a Boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_names (max, count, list_name, etal)
	if utilities.is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				table.insert( z.message_tail, {utilities.set_message ('err_disp_name', {cfg.special_case_translation [list_name], max}, true)});	-- add error message
				max = nil;
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, {utilities.set_message ('err_disp_name', {cfg.special_case_translation [list_name], max}, true)});		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		utilities.set_message ('maint_extra_text');								-- add maint cat;
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parentheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a place holder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parentheses
			local name = name_table[i];
			i = i + 1;																-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parentheses
					break;														-- and done reassembling so
				end
				i = i + 1;														-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = utilities.is_wikilink (name_table[i]);		-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i + 1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled parentheses ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the Vancouver error when a required comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		first = '';																-- set to empty string for concatenation and because it may have been set for previous author/editor
		local accept_name;
		v_name, accept_name = utilities.has_accept_as_written (v_name);			-- remove accept-this-as-written markup when it wraps all of &lt;v_name&gt;

--		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parentheses to suppress vanc formatting and error detection
--			last = v_name:match ('^%(%((.+)%)%)$')								-- remove doubled parentheses
		if accept_name then
			last = v_name;
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error (cfg.err_msg_supl.punctuation);
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s+&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be initials or generational suffix

			if not mw.ustring.match (first, '^%u+$') then						-- mw.ustring here so that later we will catch non-Latin characters
				suffix = first;													-- not initials so assume that whatever we got is a generational suffix
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end
			last = table.concat(lastfirstTable, ' ')							-- returns a string that is the concatenation of all other names that are not initials and generational suffix
			if not utilities.is_set (last) then
				first = '';														-- unset
				last = v_name;													-- last empty because something wrong with first
				add_vanc_error (cfg.err_msg_supl.name);
			end
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error (cfg.err_msg_supl['missing comma']);				-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error (cfg.err_msg_supl.name);							-- matches a space between two initials
			end
		else
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
		
		if utilities.is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error (cfg.err_msg_supl.initials);						-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first, suffix);							-- check first and last before restoring the suffix which may have a non-Latin digit
			if utilities.is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '');
			end
		end

		link = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i ) or v_link_table[i];
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate = corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
	local lastfirst = false;
	if utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice in case we have a |first1= without a |last1=; this ...
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or		-- ... also catches the case where |first= is used with |vauthors=
		utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst = true;
	end

	if (utilities.is_set (vxxxxors) and true == lastfirst) or					-- these are the three error conditions
		(utilities.is_set (vxxxxors) and utilities.is_set (xxxxors)) or
		(true == lastfirst and utilities.is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { utilities.set_message ( 'err_redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if utilities.is_set (vxxxxors) then return 2 end;
	if utilities.is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, live, dead, etc.).  When the parameter value has not been assigned a value (missing
or empty in the source template) the function returns the value specified by ret_val.  If the parameter value is one
of the list of allowed values returns the translated value; else, emits an error message and returns the value
specified by ret_val.

]]

local function is_valid_parameter_value (value, name, possible, ret_val)
	if not utilities.is_set (value) then
		return ret_val;															-- an empty parameter is ok
	elseif utilities.in_array (value, possible) then
		return cfg.keywords_xlate[value];										-- return translation of parameter keyword
	else
		table.insert( z.message_tail, { utilities.set_message ( 'err_invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return ret_val;
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list, -3, -1) == sepc .. '. ') then					-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list, -1, -1) == sepc) or (string.sub (name_list, -3, -1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terminate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not utilities.is_set (volume) and not utilities.is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (utilities.in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if utilities.is_set (volume) and utilities.is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif utilities.is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end

	if 'podcast' == cite_class and utilities.is_set (issue) then
		return wrap_msg ('issue', {sepc, issue}, lower);
	end

	local vol = '';																-- here for all cites except magazine
		
	if utilities.is_set (volume) then
		if volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$') then			-- volume value is all digits or all uppercase Roman numerals
			vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});	-- render in bold face
		elseif (4 &lt; mw.ustring.len(volume)) then								-- not all digits or Roman numerals and longer than 4 characters
			vol = utilities.substitute (cfg.messages['j-vol'], {sepc, volume});	-- not bold
			utilities.add_prop_cat ('long_vol');
		else																	-- four or less characters
			vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});	-- bold
		end
	end
	if utilities.is_set (issue) then
		return vol .. utilities.substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if utilities.is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif utilities.is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if utilities.is_set (page) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return utilities.substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return utilities.substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif utilities.is_set (pages) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then							-- if pages is only digits, assume a single page number
			return '', utilities.substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', utilities.substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', utilities.substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to Wikisource, returns the label portion of the interwiki-link as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki-link to and external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, pages, at)
	local ws_url, ws_label, coins_pages, L;										-- for Wikisource interwiki-links; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if utilities.is_set (page) then
		if utilities.is_set (pages) or utilities.is_set (at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws URL from |page= interwiki link; link portion L becomes tooltip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (pages) then
		if utilities.is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws URL from |pages= interwiki link; link portion L becomes tooltip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws URL from |at= interwiki link; link portion L becomes tooltip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org URLs to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot URL or to calendar pages.  When the archive URL is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the URL.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org URL does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command URL
	|archive-url= is an archive.org URL that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org URLs:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this function may return a modified
archive URL:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the URL unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.org URL
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine URL
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command URL, we don't want to allow saving of the target page 
		err_msg = cfg.err_msg_supl.save;
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = cfg.err_msg_supl.liveweb;
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');	-- split out some of the URL parts for evaluation
		
		if not utilities.is_set (timestamp) or 14 ~= timestamp:len() then		-- path and flag optional, must have 14-digit timestamp here
			err_msg = cfg.err_msg_supl.timestamp;
			if '*' ~= flag then
				url=url:gsub ('(//web%.archive%.org/[^%d]*%d?%d?%d?%d?%d?%d?)[^/]*', '%1*', 1)	-- for preview, modify ts to be yearmo* max (0-6 digits plus splat)
			end
		elseif utilities.is_set (path) and 'web/' ~= path then					-- older archive URLs do not have the extra 'web/' path element
			err_msg = cfg.err_msg_supl.path;
		elseif utilities.is_set (flag) and not utilities.is_set (path) then		-- flag not allowed with the old form URL (without the 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		elseif utilities.is_set (flag) and not flag:match ('%a%a_') then		-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		else
			return url, date;													-- return ArchiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	table.insert( z.message_tail, { utilities.set_message ( 'err_archive_url', {err_msg}, true ) } );	-- add error message and
	if utilities.is_set (Frame:preprocess('{{REVISIONID}}')) then
		return '', '';															-- return empty strings for ArchiveURL and ArchiveDate
	else
		return url, date;														-- preview mode so return ArchiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; P L A C E _ C H E C K &gt;--------------------------------------------------------

check |place=, |publication-place=, |location= to see if these params include digits.  This function added because
many editors misuse location to specify the in-source location (|page(s)= and |at= are supposed to do that)

returns the original parameter value without modification; added maint cat when parameter value contains digits

]]

local function place_check (param_val)
	if not utilities.is_set (param_val) then									-- parameter empty or omitted
		return param_val;														-- return that empty state
	end
	
	if mw.ustring.find (param_val, '%d') then									-- not empty, are there digits in the parameter value
		utilities.set_message ('maint_location');								-- yep, add maint cat
	end
	
	return param_val;															-- and done
end


--[[--------------------------&lt; I S _ G E N E R I C _ T I T L E &gt;----------------------------------------------

compares |title= value against list of known generic title patterns.  Returns true when pattern matches; nil else

the k/v pairs in 'generic_titles' each contain two tables, one for English and one for another 'local' language
Each of those tables contain another table that holds the string or pattern (whole title or title fragment) in
index [1].  index [2] is a Boolean that tells string.find() or mw.ustring.find() to do plain-text search (true)
or a pattern search (false).  The intent of all this complexity is to make these searches as fast as possible so
that we don't run out of processing time on very large articles.

]]

local function is_generic_title (title)
	title = mw.ustring.lower(title);											-- switch title to lower case
	for _, generic_title in ipairs (cfg.special_case_translation['generic_titles']) do	--spin through the list of known generic title fragments
		if title:find (generic_title['en'][1], 1, generic_title['en'][2]) then
			return true;														-- found English generic title so done
		elseif generic_title['local'] then										-- to keep work load down, generic_title['local'] should be nil except when there is a local version of the generic title
			if mw.ustring.find (title, generic_title['local'][1], 1, generic_title['local'][2]) then	-- mw.ustring() because might not be Latin script
				return true;													-- found local generic title so done
			end
		end
	end
end


--[[--------------------------&lt; I S _ A R C H I V E D _ C O P Y &gt;----------------------------------------------

compares |title= to 'Archived copy' (place holder added by bots that can't find proper title); if matches, return true; nil else

]]

local function is_archived_copy (title)
	title = mw.ustring.lower(title);											-- switch title to lower case
	if title:find (cfg.special_case_translation.archived_copy.en) then			-- if title is 'Archived copy'
		return true;
	elseif cfg.special_case_translation.archived_copy['local'] then
		if mw.ustring.find (title, cfg.special_case_translation.archived_copy['local']) then	-- mw.ustring() because might not be Latin script
			return true;
		end
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper ( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

	local Mode = is_valid_parameter_value (A['Mode'], A:ORIGIN('Mode'), cfg.keywords_lists['mode'], '');

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;

	local NameListStyle = is_valid_parameter_value (A['NameListStyle'], A:ORIGIN('NameListStyle'), cfg.keywords_lists['name-list-style'], '');
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';											-- override whatever |name-list-style= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				utilities.set_message ('maint_authors');						-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if utilities.is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';											-- override whatever |name-list-style= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
		end
	end

	local translator_etal;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=

	local interviewer_etal;
	local interviewers_list = {};												
	local Interviewers;															-- used later
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters

	local contributor_etal;
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list

	local Chapter = A['Chapter'];												-- done here so that we have access to |contribution= from |chapter= aliases
	local Chapter_origin = A:ORIGIN ('Chapter');
	local Contribution;															-- because contribution is required for contributor(s)
		if 'contribution' == A:ORIGIN ('Chapter') then
			Contribution = A['Chapter'];										-- get the name of the contribution
		end

	if utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not utilities.is_set (Contribution) then							-- |contributor= requires |contribution=
				table.insert( z.message_tail, { utilities.set_message ( 'err_contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { utilities.set_message ( 'err_contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if utilities.select_one (args, cfg.aliases['ContributorList-Last'], 'err_redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { utilities.set_message ( 'err_contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if utilities.is_set (Others) then
		if 0 == #a and 0 == #e then												-- add maint cat when |others= has value and used without |author=, |editor=
			utilities.set_message ('maint_others');
		end
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigDate = A['OrigDate'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TransTitle_origin = A:ORIGIN ('TransTitle');
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];

	local auto_select = ''; -- default is auto
	local accept_link;
	TitleLink, accept_link = utilities.has_accept_as_written(TitleLink, true); -- test for accept-this-as-written markup
	if (not accept_link) and utilities.in_array (TitleLink, {'none', 'pmc', 'doi'}) then -- check for special keywords
		auto_select = TitleLink; -- remember selection for later
		TitleLink = ''; -- treat as if |title-link= would have been empty
	end

	TitleLink = link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wiki-markup in |title-link= or wiki-markup in |title= when |title-link= is set

	local Section = '';															-- {{cite map}} only; preset to empty string for concatenation if not used
		if 'map' == config.CitationClass and 'section' == A:ORIGIN ('Chapter') then
			Section = A['Chapter'];												-- get |section= from |chapter= alias list; |chapter= and the other aliases not supported in {{cite map}}
			Chapter = '';														-- unset for now; will be reset later from |map= if present
		end

	local ScriptChapter = A['ScriptChapter'];
	local ScriptChapter_origin = A:ORIGIN ('ScriptChapter');
	local ChapterLink -- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TransChapter_origin = A:ORIGIN ('TransChapter');
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];

	local ArchiveDate;
	local ArchiveURL;

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	
	local UrlStatus = is_valid_parameter_value (A['UrlStatus'], A:ORIGIN('UrlStatus'), cfg.keywords_lists['url-status'], '');

	local URL = A['URL']
	local URL_origin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURL_origin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURL_origin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL

	local Periodical = A['Periodical'];
	local Periodical_origin = '';
	if utilities.is_set (Periodical) then
		Periodical_origin = A:ORIGIN('Periodical');								-- get the name of the periodical parameter
		local i;
		Periodical, i = utilities.strip_apostrophe_markup (Periodical);			-- strip apostrophe markup so that metadata isn't contaminated 
		if i then																-- non-zero when markup was stripped so emit an error message
			table.insert( z.message_tail, {utilities.set_message ('err_apostrophe_markup', {Periodical_origin}, true)});
		end
	end

	if 'mailinglist' == config.CitationClass then								-- special case for {{cite mailing list}}
		if utilities.is_set (Periodical) and utilities.is_set (A ['MailingList']) then	-- both set emit an error
			table.insert( z.message_tail, {utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', Periodical_origin) .. ' and ' .. utilities.wrap_style ('parameter', 'mailinglist')}, true )});
		end

		Periodical = A ['MailingList'];											-- error or no, set Periodical to |mailinglist= value because this template is {{cite mailing list}}
		Periodical_origin = A:ORIGIN('MailingList');
	end

	local ScriptPeriodical = A['ScriptPeriodical'];
	local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');

	-- web and news not tested for now because of 
	-- Wikipedia:Administrators%27_noticeboard#Is_there_a_semi-automated_tool_that_could_fix_these_annoying_&quot;Cite_Web&quot;_errors?
	if not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) then	-- 'periodical' templates require periodical parameter
	--	local p = {['journal'] = 'journal', ['magazine'] = 'magazine', ['news'] = 'newspaper', ['web'] = 'website'};	-- for error message
		local p = {['journal'] = 'journal', ['magazine'] = 'magazine'};			-- for error message
		if p[config.CitationClass]  then
			table.insert( z.message_tail, {utilities.set_message ('err_missing_periodical', {config.CitationClass, p[config.CitationClass]}, true)});
		end
	end

	local TransPeriodical =  A['TransPeriodical'];
	local TransPeriodical_origin =  A:ORIGIN ('TransPeriodical');

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) then
			if not utilities.in_array (Periodical_origin, {'website', 'mailinglist'}) then	-- {{citation}} does not render volume for these 'periodicals'
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		elseif utilities.is_set (ScriptPeriodical) then
			if 'script-website' ~= ScriptPeriodical_origin then					-- {{citation}} does not render volume for |script-website=
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		else
			Volume = A['Volume'];												-- and does for non-'periodical' cites
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_volume) then	-- render |volume= for cs1 according to the configuration settings
		Volume = A['Volume'];
	end	

	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) and utilities.in_array (Periodical_origin, {'journal', 'magazine', 'newspaper', 'periodical', 'work'}) or	-- {{citation}} renders issue for these 'periodicals'
			utilities.is_set (ScriptPeriodical) and utilities.in_array (ScriptPeriodical_origin, {'script-journal', 'script-magazine', 'script-newspaper', 'script-periodical', 'script-work'}) then -- and these 'script-periodicals'
				Issue = hyphen_to_dash (A['Issue']);
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_issue) then	-- conference &amp; map books do not support issue; {{citation}} listed here because included in settings table
		if not (utilities.in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical))) then
			Issue = hyphen_to_dash (A['Issue']);
		end
	end

	local Position = '';
	if not utilities.in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash (A['Pages']);	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = place_check (A['PublicationPlace'], A:ORIGIN('PublicationPlace'));
	local Place = place_check (A['Place'], A:ORIGIN('Place'));
	
	local PublisherName = A['PublisherName'];
	local PublisherName_origin = A:ORIGIN('PublisherName');
	if utilities.is_set (PublisherName) then
		local i = 0;
		PublisherName, i = utilities.strip_apostrophe_markup (PublisherName);	-- strip apostrophe markup so that metadata isn't contaminated; publisher is never italicized
		if i then																-- non-zero when markup was stripped so emit an error message
			table.insert( z.message_tail, {utilities.set_message ('err_apostrophe_markup', {PublisherName_origin}, true)});
		end
	end

	local Newsgroup = A['Newsgroup'];											-- TODO: strip apostrophe markup?
	local Newsgroup_origin = A:ORIGIN('Newsgroup');	

	if 'newsgroup' == config.CitationClass then
		if utilities.is_set (PublisherName) then								-- general use parameter |publisher= not allowed in cite newsgroup
			local error_text, error_state = utilities.set_message ('err_parameter_ignored', {PublisherName_origin}, true);
			if utilities.is_set (error_text) then
				table.insert( z.message_tail, {error_text, error_state} );
			end				
		end

		PublisherName = nil;													-- ensure that this parameter is unset for the time being; will be used again after COinS
	end

	local UrlAccess = is_valid_parameter_value (A['UrlAccess'], A:ORIGIN('UrlAccess'), cfg.keywords_lists['url-access'], nil);
		if not utilities.is_set (URL) and utilities.is_set (UrlAccess) then
			UrlAccess = nil;
			table.insert( z.message_tail, { utilities.set_message ( 'err_param_access_requires_param', {'url'}, true ) } );
		end
		
	local ChapterUrlAccess = is_valid_parameter_value (A['ChapterUrlAccess'], A:ORIGIN('ChapterUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (ChapterURL) and utilities.is_set (ChapterUrlAccess) then
		ChapterUrlAccess = nil;
		table.insert( z.message_tail, { utilities.set_message ( 'err_param_access_requires_param', {A:ORIGIN('ChapterUrlAccess'):gsub ('%-access', '')}, true ) } );
	end

	local MapUrlAccess = is_valid_parameter_value (A['MapUrlAccess'], A:ORIGIN('MapUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (A['MapURL']) and utilities.is_set (MapUrlAccess) then
		MapUrlAccess = nil;
		table.insert( z.message_tail, { utilities.set_message ( 'err_param_access_requires_param', {'map-url'}, true ) } );
	end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local Agency = A['Agency'];

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = is_valid_parameter_value (A['IgnoreISBN'], A:ORIGIN('IgnoreISBN'), cfg.keywords_lists['yes_true_y'], nil);
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local Quote = A['Quote'];
	local QuotePage = A['QuotePage'];
	local QuotePages = A['QuotePages'];
	local ScriptQuote = A['ScriptQuote'];
	local TransQuote = A['TransQuote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURL_origin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = is_valid_parameter_value (A['LastAuthorAmp'], A:ORIGIN('LastAuthorAmp'), cfg.keywords_lists['yes_true_y'], nil);

	local no_tracking_cats = is_valid_parameter_value (A['NoTracking'], A:ORIGIN('NoTracking'), cfg.keywords_lists['yes_true_y'], nil);
	if 'nocat' == A:ORIGIN('NoTracking') then				
		utilities.set_message ('maint_nocat');
	end
	
	--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = is_valid_parameter_value (A['DF'], A:ORIGIN('DF'), cfg.keywords_lists['df'], '');
	if not utilities.is_set (DF) then
		DF = cfg.global_df;														-- local |df= if present overrides global df set by {{use xxx date}} template
	end

	local sepc;																	-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref = A['Ref'];
	if 'harv' == Ref then
		utilities.set_message ('maint_ref_harv');								-- add maint cat to identify templates that have this now-extraneous param value
	elseif not utilities.is_set (Ref) then
		Ref = 'harv';															-- set as default when not set externally
	end
	
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], Ref, config.CitationClass);
	use_lowercase = ( sepc == ',' ); 											-- used to control capitalization for certain static text

	-- check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not utilities.is_set (no_tracking_cats) then								-- ignore if we are already not going to categorize this page
		if utilities.in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _, v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end
																				-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	utilities.select_one (args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'err_redundant_parameters');	-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, Pages, At);

	local NoPP = is_valid_parameter_value (A['NoPP'], A:ORIGIN('NoPP'), cfg.keywords_lists['yes_true_y'], nil);

	if utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- both |publication-place= and |place= (|location=) allowed if different
		utilities.add_prop_cat ('location test');								-- add property cat to evaluate how often PublicationPlace and Place are used together
		if PublicationPlace == Place then
			Place = '';															-- unset; don't need both if they are the same
		end
	elseif not utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- when only |place= (|location=) is set ...
		PublicationPlace = Place;												-- promote |place= (|location=) to |publication-place
	end

	if PublicationPlace == Place then Place = ''; end							-- don't need both if they are the same
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia= and |title= then map |title= to |article= and |encyclopedia= to |title=
		|encyclopedia= and |article= then map |encyclopedia= to |title=

		|trans-title= maps to |trans-chapter= when |title= is re-mapped
		|url= maps to |chapter-url= when |title= is remapped
	
	All other combinations of |encyclopedia=, |title=, and |article= are not modified
	
	]]

	local Encyclopedia = A['Encyclopedia'];										-- used as a flag by this module and by ~/COinS

	if utilities.is_set (Encyclopedia) then										-- emit error message when Encyclopedia set but template is other than {{cite encyclopedia}} or {{citation}}
		if 'encyclopaedia' ~= config.CitationClass and 'citation' ~= config.CitationClass then
			table.insert (z.message_tail, {utilities.set_message ('err_parameter_ignored', {A:ORIGIN ('Encyclopedia')}, true)});
			Encyclopedia = nil;													-- unset because not supported by this template
		end
	end

	if ('encyclopaedia' == config.CitationClass) or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Periodical) and utilities.is_set (Encyclopedia) then	-- when both set emit an error
			table.insert (z.message_tail, {utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', A:ORIGIN ('Encyclopedia')) .. ' and ' .. utilities.wrap_style ('parameter', Periodical_origin)}, true )});
		end

		if utilities.is_set (Encyclopedia) then
			Periodical = Encyclopedia;											-- error or no, set Periodical to Encyclopedia; allow periodical without encyclopedia
			Periodical_origin = A:ORIGIN ('Encyclopedia');
		end

		if utilities.is_set (Periodical) then									-- Periodical is set when |encyclopedia= is set
			if utilities.is_set (Title) or utilities.is_set (ScriptTitle) then
				if not utilities.is_set (Chapter) then
					Chapter = Title;											-- |encyclopedia= and |title= are set so map |title= to |article= and |encyclopedia= to |title=
					ScriptChapter = ScriptTitle;
					ScriptChapter_origin = A:ORIGIN('ScriptTitle')
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterURL_origin = A:ORIGIN('URL')

					ChapterUrlAccess = UrlAccess;

					if not utilities.is_set (ChapterURL) and utilities.is_set (TitleLink) then
						Chapter = utilities.make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			elseif utilities.is_set (Chapter) then								-- |title= not set
				Title = Periodical;												-- |encyclopedia= set and |article= set so map |encyclopedia= to |title=
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if utilities.is_set (A['Number']) then									-- cite techreport uses 'number', which other citations alias to 'issue'
			if not utilities.is_set (ID) then									-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'id') .. ' and ' .. utilities.wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if utilities.is_set (BookTitle) then
			Chapter = Title;
			Chapter_origin = 'title';
	--		ChapterLink = TitleLink;											-- |chapter-link= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			URL_origin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			TransChapter_origin = TransTitle_origin;
			Title = BookTitle;
			Format = '';
	--		TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		if utilities.is_set (Chapter) then
			table.insert( z.message_tail, { utilities.set_message ( 'err_redundant_parameters', {utilities.wrap_style ('parameter', 'map') .. ' and ' .. utilities.wrap_style ('parameter', Chapter_origin)}, true ) } );	-- add error message
		end
		Chapter = A['Map'];
		Chapter_origin = A:ORIGIN('Map');
		ChapterURL = A['MapURL'];
		ChapterURL_origin = A:ORIGIN('MapURL');
		TransChapter = A['TransMap'];
		ScriptChapter = A['ScriptMap']
		ScriptChapter_origin = A:ORIGIN('ScriptMap')

		ChapterUrlAccess = MapUrlAccess;
		ChapterFormat = A['MapFormat'];

		Cartography = A['Cartography'];
		if utilities.is_set ( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if utilities.is_set ( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local SeriesLink = A['SeriesLink'];

		SeriesLink = link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wiki-markup in |series-link= or wiki-markup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if utilities.is_set (Network) then table.insert(n, Network); end
		if utilities.is_set (Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if utilities.is_set (Season) and utilities.is_set (SeriesNumber) then	-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { utilities.set_message ( 'err_redundant_parameters', {utilities.wrap_style ('parameter', 'season') .. ' and ' .. utilities.wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if utilities.is_set (Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if utilities.is_set (SeriesNumber) then table.insert(s, wrap_msg ('seriesnum', SeriesNumber, use_lowercase)); end
			if utilities.is_set (Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ScriptChapter_origin = A:ORIGIN('ScriptTitle');
			ChapterLink = TitleLink;											-- alias |episode-link=
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if utilities.is_set (ChapterLink) and not utilities.is_set (ChapterURL) then	-- link but not URL
				Chapter = utilities.make_wikilink (ChapterLink, Chapter);
			elseif utilities.is_set (ChapterLink) and utilities.is_set (ChapterURL) then	-- if both are set, URL links episode;
				Series = utilities.make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if utilities.is_set (Series) and utilities.is_set (SeriesLink) then
				Series = utilities.make_wikilink (SeriesLink, Series);
			end
			Series = utilities.wrap_style ('italic-title', Series);				-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- handle type parameter for those CS1 citations that have default values
	if utilities.in_array (config.CitationClass, {&quot;AV-media-notes&quot;, &quot;interview&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if utilities.is_set (Degree) and &quot;Thesis&quot; == TitleType then				-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if utilities.is_set (TitleType) then										-- if type parameter is specified
		TitleType = utilities.substitute ( cfg.messages['type'], TitleType);	-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging

	if not utilities.is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not utilities.is_set (Date) and utilities.is_set (PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val = AccessDate, name = A:ORIGIN ('AccessDate')},
			['archive-date'] = {val = ArchiveDate, name = A:ORIGIN ('ArchiveDate')},
			['date'] = {val = Date, name = Date_origin},
			['doi-broken-date'] = {val = DoiBroken, name = A:ORIGIN ('DoiBroken')},
			['pmc-embargo-date'] = {val = Embargo, name = A:ORIGIN ('Embargo')},
			['lay-date'] = {val = LayDate, name = A:ORIGIN ('LayDate')},
			['publication-date'] = {val = PublicationDate, name = A:ORIGIN ('PublicationDate')},
			['year'] = {val = Year, name = A:ORIGIN ('Year')},
			};

		local error_list = {};
		anchor_year, Embargo = validation.dates(date_parameters_list, COinS_date, error_list);

-- start temporary Julian / Gregorian calendar uncertainty categorization
		if COinS_date.inter_cal_cat then
			utilities.add_prop_cat ('jul_greg_uncertainty');
		end
-- end temporary Julian / Gregorian calendar uncertainty categorization

		if utilities.is_set (Year) and utilities.is_set (Date) then				-- both |date= and |year= not normally needed; 
			local mismatch = validation.year_date_check (Year, Date);
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				table.insert (error_list, '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;year= / &amp;#124;date= mismatch&lt;/code&gt;');
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				utilities.set_message ('maint_date_year');						-- add a maint cat
			end
		end
		
		if 0 == #error_list then												-- error free dates only; 0 when error_list is empty
			local modified = false;												-- flag
			
			if utilities.is_set (DF) then										-- if we need to reformat dates
				modified = validation.reformat_dates (date_parameters_list, DF);	-- reformat to DF format, use long month names if appropriate
			end

			if true == validation.date_hyphen_to_dash (date_parameters_list) then	-- convert hyphens to dashes where appropriate
				modified = true;
				utilities.set_message ('maint_date_format');					-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language,
	-- uncomment the next three lines.  Not supported by en.wiki (for obvious reasons)
	-- set validation.date_name_xlate() second argument to true to translate English digits to local digits (will translate ymd dates)
	--		if validation.date_name_xlate (date_parameters_list, false) then
	--			modified = true;
	--		end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				LayDate = date_parameters_list['lay-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end
		else
			table.insert (z.message_tail, {utilities.set_message ('err_bad_date', {utilities.make_sep_list (#error_list, error_list)}, true)});	-- add this error message
		end
	end	-- end of do

	local ID_list_coins = identifiers.extract_ids (args);						-- gets identifiers and their values from args; this list used for COinS and source for build_id_list()
		if utilities.is_set (DoiBroken) and not ID_list_coins['DOI'] then
			table.insert (z.message_tail, {utilities.set_message ('err_doibroken_missing_doi', A:ORIGIN('DoiBroken'))});
		end
	local ID_access_levels = identifiers.extract_id_access_levels (args, ID_list_coins);
	local ID_list = identifiers.build_id_list (ID_list_coins, {IdAccessLevels = ID_access_levels, DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo = Embargo, Class = Class});	-- render identifiers
	
	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite ssrn}}, before generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then
		if not utilities.is_set (ID_list_coins[config.CitationClass:upper()]) then 	-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp; |citeseerx= required for their templates
			table.insert (z.message_tail, {utilities.set_message ('err_' .. config.CitationClass .. '_missing', {}, true)});	-- add error message
		end

		Periodical = ({['arxiv'] = 'arXiv', ['biorxiv'] = 'bioRxiv', ['citeseerx'] = 'CiteSeerX', ['ssrn'] = 'Social Science Research Network'})[config.CitationClass];
	end

	-- Link the title of the work if no |url= was provided, but we have a |pmc= or a |doi= with |doi-access=free

	if config.CitationClass == &quot;journal&quot; and not utilities.is_set (URL) and not utilities.is_set (TitleLink) and not utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) then -- TODO: remove 'none' once existing citations have been switched to 'off', so 'none' can be used as token for &quot;no title&quot; instead
    		if 'none' ~= cfg.keywords_xlate[auto_select] then -- if auto-linking not disabled
 	 		if identifiers.auto_link_urls[auto_select] then -- manual selection
		 		URL = identifiers.auto_link_urls[auto_select]; -- set URL to be the same as identifier's external link
 				URL_origin = cfg.id_handlers[auto_select:upper()].parameters[1]; -- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['pmc'] then -- auto-select PMC
				URL = identifiers.auto_link_urls['pmc']; -- set URL to be the same as the PMC external link if not embargoed
				URL_origin = cfg.id_handlers['PMC'].parameters[1]; -- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['doi'] then -- auto-select DOI
				URL = identifiers.auto_link_urls['doi'];
				URL_origin = cfg.id_handlers['DOI'].parameters[1];
			end
 	 	end

		if utilities.is_set (URL) and utilities.is_set (AccessDate) then		-- access date requires |url=; identifier-created URL is not |url=
			table.insert( z.message_tail, { utilities.set_message ( 'err_accessdate_missing_url', {}, true ) } );	-- add an error message
			AccessDate = '';													-- unset
		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not utilities.is_set (Title) and not utilities.is_set (TransTitle) and not utilities.is_set (ScriptTitle) then	-- has special case for cite episode
		table.insert( z.message_tail, { utilities.set_message ( 'err_citation_missing_title', {'episode' == config.CitationClass and 'series' or 'title'}, true ) } );
	end

	if utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) and
			utilities.in_array (config.CitationClass, {'journal', 'citation'}) and
			(utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and
			('journal' == Periodical_origin or 'script-journal' == ScriptPeriodical_origin) then	-- special case for journal cites
				Title = '';														-- set title to empty string
				utilities.set_message ('maint_untitled');						-- add maint cat
	end

	check_for_url ({															-- add error message when any of these parameters hold a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[Periodical_origin] = Periodical,
		[PublisherName_origin] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Chapter) and utilities.is_set (Title) and utilities.is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = metadata.COinS({
		['Periodical'] = utilities.strip_apostrophe_markup (Periodical),		-- no markup in the metadata
		['Encyclopedia'] = Encyclopedia,										-- just a flag; content ignored by ~/COinS
		['Chapter'] = metadata.make_coins_title (coins_chapter, ScriptChapter),	-- Chapter and ScriptChapter stripped of bold / italic wiki-markup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = metadata.make_coins_title (coins_title, ScriptTitle),		-- Title and ScriptTitle stripped of bold / italic wiki-markup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Quarter'] = COinS_date.rftquarter,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = coins_pages or metadata.get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName or Newsgroup,							-- any apostrophe markup already removed from PublisherName
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list_coins,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, and {{cite ssrn}} AFTER generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, CiteSeerX, or ssrn now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass and utilities.is_set (Newsgroup) then
		PublisherName = utilities.substitute (cfg.messages['newsgroup'], external_link( 'news:' .. Newsgroup, Newsgroup, Newsgroup_origin, nil ));
	end

	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local control = { 
			format = NameListStyle,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_names (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if utilities.is_set (Editors) then
				Editors, editor_etal = name_has_etal (Editors, editor_etal, false, 'editors');	-- find and remove variations on et al.
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
				end
				EditorCount = 2;												-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum , interviewer_etal = get_display_names (A['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal);
			Interviewers = list_people (control, interviewers_list, interviewer_etal);
		end
		do																		-- now do translators
			control.maximum , translator_etal = get_display_names (A['DisplayTranslators'], #t, 'translators', translator_etal);
			Translators = list_people (control, t, translator_etal);
		end
		do																		-- now do contributors
			control.maximum , contributor_etal = get_display_names (A['DisplayContributors'], #c, 'contributors', contributor_etal);
			Contributors = list_people (control, c, contributor_etal);
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_names (A['DisplayAuthors'], #a, 'authors', author_etal);

			last_first_list = list_people(control, a, author_etal);

			if utilities.is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors');	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if utilities.is_set (Authors) and utilities.is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
	-- an error message if the associated URL is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not utilities.is_set (URL) then
		if utilities.in_array (config.CitationClass, {&quot;web&quot;, &quot;podcast&quot;, &quot;mailinglist&quot;}) or		-- |url= required for cite web, cite podcast, and cite mailinglist
			('citation' == config.CitationClass and ('website' == Periodical_origin or 'script-website' == ScriptPeriodical_origin)) then	-- and required for {{citation}} with |website= or |script-website=
				table.insert( z.message_tail, { utilities.set_message ( 'err_cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if utilities.is_set (AccessDate) and not utilities.is_set (ChapterURL) then		-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { utilities.set_message ( 'err_accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURL_origin, OriginalFormat, OriginalAccess;
	UrlStatus = UrlStatus:lower();												-- used later when assembling archived text
	if utilities.is_set ( ArchiveURL ) then
		if utilities.is_set (ChapterURL) then 									-- if chapter-url= is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURL_origin = ChapterURL_origin;								-- name of |chapter-url= parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=

			if 'live' ~= UrlStatus then
				ChapterURL = ArchiveURL											-- swap-in the archive's URL
				ChapterURL_origin = A:ORIGIN('ArchiveURL')						-- name of |archive-url= parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived URLs
			end
		elseif utilities.is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURL_origin = URL_origin;									-- name of URL parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;

			if 'live' ~= UrlStatus then											-- if URL set then |archive-url= applies to it
				URL = ArchiveURL												-- swap-in the archive's URL
				URL_origin = A:ORIGIN('ArchiveURL')								-- name of archive URL parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived URLs
			end
 		end
	end

	if utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) then
			local chap_param;
			if utilities.is_set (Chapter) then									-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif utilities.is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif utilities.is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif utilities.is_set (ScriptChapter) then
				chap_param = ScriptChapter_origin;
			else utilities.is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if utilities.is_set (chap_param) then								-- if we found one
				table.insert( z.message_tail, { utilities.set_message ( 'err_chapter_ignored', {chap_param}, true ) } );	-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if utilities.is_set (Contribution) and 0 &lt; #c then						-- if this is a contribution with contributor(s)
			if utilities.in_array (Contribution:lower(), cfg.keywords_lists.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, ScriptChapter_origin, Chapter, Chapter_origin, TransChapter, TransChapter_origin, ChapterURL, ChapterURL_origin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if utilities.is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and utilities.is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter .. sepc .. ' ';
		elseif utilities.is_set (ChapterFormat) then							-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title
	local plain_title = false;
	local accept_title;
	Title, accept_title = utilities.has_accept_as_written (Title, true);		-- remove accept-this-as-written markup when it wraps all of &lt;Title&gt;
	if accept_title and ('' == Title) then										-- only support forced empty for now &quot;(())&quot;
		Title = cfg.messages['notitle'];										-- replace by predefined &quot;No title&quot; message
			-- TODO: utilities.set_message ( 'err_redundant_parameters', ...);	-- issue proper error message instead of muting	 
			ScriptTitle = '';													-- just mute for now	 
			TransTitle = '';													-- just mute for now
 		plain_title = true;														-- suppress text decoration for descriptive title
		utilities.set_message ('maint_untitled');								-- add maint cat
	end

	if not accept_title then -- &lt;Title&gt; not wrapped in accept-as-written markup
		if '...' == Title:sub (-3) then											-- if ellipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%' .. sepc .. '$', '');			-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end

		if utilities.is_set (ArchiveURL) and is_archived_copy (Title) then
			utilities.set_message ('maint_archived_copy');						-- add maintenance category before we modify the content of Title
		end

		if is_generic_title (Title) then
			table.insert (z.message_tail, {utilities.set_message ( 'err_generic_title', {}, true ) } );	-- set an error message
		end
	end

	if (not plain_title) and (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) or
		('map' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)))) then		-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from module provided quote marks
			Title = utilities.wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle, 'script-title');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
			TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );
	elseif plain_title or ('report' == config.CitationClass) then								-- no styling for cite report and descriptive titles (otherwise same as above)
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = utilities.wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if utilities.is_set (TransTitle) then
		if utilities.is_set (Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. utilities.set_message ( 'err_trans_missing_title', {'title'} );
		end
	end

	if utilities.is_set (Title) then											-- TODO: is this the right place to be making Wikisource URLs?
		if utilities.is_set (TitleLink) and utilities.is_set (URL) then
			table.insert( z.message_tail, { utilities.set_message ( 'err_wikilink_in_url', {}, true ) } );	-- set an error message because we can't have both
			TitleLink = '';														-- unset
		end
		
		if not utilities.is_set (TitleLink) and utilities.is_set (URL) then
			Title = external_link (URL, Title, URL_origin, UrlAccess) .. TransTitle .. TransError .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif utilities.is_set (TitleLink) and not utilities.is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = utilities.make_wikilink (TitleLink, Title) .. TransTitle .. TransError;
			end
		else
			local ws_url, ws_label, L;											-- Title has italic or quote markup by the time we get here which causes is_wikilink() to return 0 (not a wikilink)
			ws_url, ws_label, L = wikisource_url_make (Title:gsub('[\'&quot;](.-)[\'&quot;]', '%1'));	-- make ws URL from |title= interwiki link (strip italic or quote markup); link portion L becomes tooltip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = Title .. TransTitle .. TransError;
			end
		end
	else
		Title = TransTitle .. TransError;
	end

	if utilities.is_set (Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if utilities.is_set (Conference) then
		if utilities.is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURL_origin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif utilities.is_set (ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURL_origin, nil );
	end

	if not utilities.is_set (Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if utilities.is_set (Minutes) then
			if utilities.is_set (Time) then
				table.insert( z.message_tail, { utilities.set_message ( 'err_redundant_parameters', {utilities.wrap_style ('parameter', 'minutes') .. ' and ' .. utilities.wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if utilities.is_set (Time) then
				local TimeCaption = A['TimeCaption']
				if not utilities.is_set (TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = utilities.is_set (At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = utilities.is_set (Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Sections = A['Sections'];											-- Section (singular) is an alias of Chapter so set earlier
		local Inset = A['Inset'];
		
		if utilities.is_set ( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if utilities.is_set ( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif utilities.is_set ( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if utilities.is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc.
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	Others = utilities.is_set (Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if utilities.is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if utilities.is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	TitleNote = utilities.is_set (TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if utilities.is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			utilities.set_message ('maint_extra_text', 'edition');				-- add maint cat
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = utilities.is_set (Series) and wrap_msg ('series', {sepc, Series}) or &quot;&quot;;	-- not the same as SeriesNum
	OrigDate = utilities.is_set (OrigDate) and wrap_msg ('origdate', OrigDate) or '';
	Agency = utilities.is_set (Agency) and wrap_msg ('agency', {sepc, Agency}) or &quot;&quot;;
	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	Via = utilities.is_set (Via) and  wrap_msg ('via', Via) or '';

	if utilities.is_set (AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = utilities.substitute (retrv_text, AccessDate);				-- add retrieved text

		AccessDate = utilities.substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if utilities.is_set (ID) then ID = sepc .. &quot; &quot; .. ID; end
   	if &quot;thesis&quot; == config.CitationClass and utilities.is_set (Docket) then
		ID = sepc .. &quot; Docket &quot; .. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and utilities.is_set (Docket) then		-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	if utilities.is_set (URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URL_origin, UrlAccess );
	end

	if utilities.is_set (Quote) or utilities.is_set (TransQuote) or utilities.is_set (ScriptQuote) then

		if utilities.is_set (Quote) then
			if Quote:sub(1, 1) == '&quot;' and Quote:sub(-1, -1) == '&quot;' then			-- if first and last characters of quote are quote marks
				Quote = Quote:sub(2, -2);										-- strip them off
			end
		end

		Quote = utilities.wrap_style ('quoted-text', Quote ); 	-- wrap in &lt;q&gt;...&lt;/q&gt; tags
	
		if utilities.is_set (ScriptQuote) then
			Quote = script_concatenate (Quote, ScriptQuote, 'script-quote'); -- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after quote is wrapped
		end

		if utilities.is_set (TransQuote) then
			if TransQuote:sub(1, 1) == '&quot;' and TransQuote:sub(-1, -1) == '&quot;' then -- if first and last characters of |trans-quote are quote marks
				TransQuote = TransQuote:sub(2, -2); -- strip them off
			end
			Quote = Quote .. &quot; &quot; .. utilities.wrap_style ('trans-quoted-title', TransQuote );
		end

		if utilities.is_set (QuotePage) or utilities.is_set (QuotePages) then	-- add page prefix
			local quote_prefix = '';
			if utilities.is_set (QuotePage) then
				if not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePage}), '', '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePage}), '', '', '';
				end
			elseif utilities.is_set (QuotePages) then
				if tonumber(QuotePages) ~= nil and not NoPP then				-- if only digits, assume single page
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePages}), '', '';
				elseif not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['pp-prefix'], {sepc, QuotePages}), '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePages}), '', '';
				end
			end
                        
			Quote = quote_prefix .. &quot;: &quot; .. Quote;
		else
			Quote = sepc .. &quot; &quot; .. Quote;
		end

		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if utilities.is_set (ArchiveURL) then
		local arch_text;
		if not utilities.is_set (ArchiveDate) then
			ArchiveDate = utilities.set_message ('err_archive_missing_date');
		end
		if &quot;live&quot; == UrlStatus then
			arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. utilities.substitute ( cfg.messages['archived-live'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil ) .. ArchiveFormat, ArchiveDate } );
			if not utilities.is_set (OriginalURL) then
				Archived = Archived .. &quot; &quot; .. utilities.set_message ('err_archive_missing_url');							   
			end
		elseif utilities.is_set (OriginalURL) then								-- UrlStatus is empty, 'dead', 'unfit', 'usurped', 'bot: unknown'
			if utilities.in_array (UrlStatus, {'unfit', 'usurped', 'bot: unknown'}) then
				arch_text = cfg.messages['archived-unfit'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. &quot; &quot; .. arch_text .. ArchiveDate;				-- format already styled
				if 'bot: unknown' == UrlStatus then
					utilities.set_message ('maint_bot_unknown');				-- and add a category if not already added
				else
					utilities.set_message ('maint_unfit');						-- and add a category if not already added
				end
			else																-- UrlStatus is empty, 'dead'
				arch_text = cfg.messages['archived-dead'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. &quot; &quot; .. utilities.substitute ( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURL_origin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else																	-- OriginalUrl not set
			arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. utilities.substitute ( arch_text, 
				{ utilities.set_message ('err_archive_missing_url'), ArchiveDate } );
		end
	elseif utilities.is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if utilities.is_set (LayURL) then
		if utilities.is_set (LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if utilities.is_set (LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. utilities.safe_for_italics (LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif utilities.is_set (LayFormat) then									-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if utilities.is_set (Transcript) then
		if utilities.is_set (TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURL_origin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif utilities.is_set (TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURL_origin, nil );
	end

	local Publisher;
	if utilities.is_set (PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if utilities.is_set (PublisherName) then
		if utilities.is_set (PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif utilities.is_set (PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical)) then
		if utilities.is_set (Title) or utilities.is_set (TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		else 
			Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		end
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then									-- cite speech only
		TitleNote = &quot; (Speech)&quot;;												-- annotate the citation
		if utilities.is_set (Periodical) then									-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if utilities.is_set (Conference) then								-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;							-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
		if utilities.is_set (Others) then Others = safe_join ({Others, sepc .. &quot; &quot;}, sepc) end		-- add terminal punctuation &amp; space; check for dup sepc; TODO why do we need to do this here?
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (Periodical) then		-- special cases for book cites
		if utilities.is_set (Contributors) then									-- when we are citing foreword, preface, introduction, etc.
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if utilities.is_set (Chapter) then										-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif utilities.is_set (Periodical) then								-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon;
	if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then	-- special case for cite AV media &amp; cite episode position transcript
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, Lay, Quote }, sepc );
	else
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, Lay, Quote }, sepc );
	end
	
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if utilities.is_set (Date) then
		if utilities.is_set (Authors) or utilities.is_set (Editors) then		-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date .. &quot;)&quot; .. OrigDate .. sepc .. &quot; &quot;;				-- in parentheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon, -1, -1) == sepc) then						-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigDate;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigDate;							-- Date begins with sepc
			end
		end
	end	
	if utilities.is_set (Authors) then
		if (not utilities.is_set (Date)) then									-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if utilities.is_set (Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then
					in_text = in_text:lower()									-- lowercase for cs2
				end
			end
			if EditorCount &lt;= 1 then
				post_text = &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot;;				-- be consistent with no-author, no-date case
			else
				post_text = &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot;;
			end
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Contributors) then									-- book cite and we're citing the intro, preface, etc.
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if utilities.is_set (Editors) and utilities.is_set (Date) then		-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not utilities.is_set (Date)) then								-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif utilities.is_set (Editors) then
		if utilities.is_set (Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if utilities.is_set (PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc ); 								--Deals with italics, spaces, etc.
		text = text:sub(1, -sepc:len() - 1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if utilities.is_set (config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = string.format ('%s %s %s', 'citation', config.CitationClass, utilities.is_set (Mode) and Mode or 'cs1');	-- class=citation required for blue highlight when used with |ref=
	else
		options.class = string.format ('%s %s', 'citation', utilities.is_set (Mode) and Mode or 'cs2');
	end
	
	if utilities.is_set (Ref) and 'none' ~= cfg.keywords_xlate[Ref:lower()] then
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			if #namelist &gt; 0 then												-- if there are names in namelist
				id = anchor_id (namelist, year);								-- go make the CITEREF anchor
			else
				id = '';														-- unset
			end
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;(.-)&lt;/span&gt;&quot;, &quot;%1&quot;):gsub(&quot;%b&lt;&gt;&quot;, &quot;&quot;)) &lt;= 2 then	-- remove &lt;span&gt; tags and other HTML-like markup; then get length of what remains
		z.error_categories = {};
		text = utilities.set_message ('err_empty_citation');
		z.message_tail = {};
	end
	
	local render = {};															-- here we collect the final bits for concatenation into the rendered citation

	if utilities.is_set (options.id) then										-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render, utilities.substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text}));	-- when |ref= is set
	else
		table.insert (render, utilities.substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text}));	-- all other cases
	end		

	table.insert (render, utilities.substitute (cfg.presentation['ocins'], {OCinSoutput}));	-- append metadata to the citation

	if 0 ~= #z.message_tail then
		table.insert (render, ' ');
		for i,v in ipairs( z.message_tail ) do
			if utilities.is_set (v[1]) then
				if i == #z.message_tail then
					table.insert (render, utilities.error_comment ( v[1], v[2] ));
				else
					table.insert (render, utilities.error_comment ( v[1] .. &quot;; &quot;, v[2] ));
				end
			end
		end
	end

	if 0 ~= #z.maintenance_cats then
		local maint_msgs = {};													-- here we collect all of the maint messages
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			local maint = {};													-- here we assemble a maintenence message
			table.insert (maint, v);											-- maint msg is the category name
			table.insert (maint, ' (');											-- open the link text
			table.insert (maint, utilities.make_wikilink (':Category:' .. v, 'link'));	-- add the link
			table.insert (maint, ')');											-- and close it
			table.insert (maint_msgs, table.concat (maint));					-- assemble new maint message and add it to the maint_msgs table
		end
		table.insert (render, utilities.substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs, ' ')));	-- wrap the group of maint message with proper presentation and save
	end
	
	if not no_tracking_cats then
		for _, v in ipairs( z.error_categories ) do
			table.insert (render, utilities.make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			table.insert (render, utilities.make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.properties_cats ) do								-- append properties categories
			table.insert (render, utilities.make_wikilink ('Category:' .. v));
		end
	end

	return table.concat (render);	
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class, empty)
	local name = tostring (name);
	local state;
	local function state_test (state, name)										-- local function to do testing of state values
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			if empty then return nil; end										-- deprecated empty parameters are treated as unknowns
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
		return nil;
	end		

	if name:find ('#') then														-- # is a cs1|2 reserved character so parameters with # not permitted
		return nil;
	end

	if utilities.in_array (cite_class, whitelist.preprint_template_list ) then	-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[name];
		if true == state_test (state, name) then return true; end

		state = whitelist.preprint_arguments[cite_class][name];					-- look in the parameter-list for the template identified by cite_class
		if true == state_test (state, name) then return true; end

																				-- limited enumerated parameters list
		name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
		state = whitelist.limited_numbered_arguments[name];
		if true == state_test (state, name) then return true; end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates

	if utilities.in_array (cite_class, whitelist.unique_param_template_list) then 	-- experiment for template-specific parameters for templates that accept parameters from the basic argument list
		state = whitelist.unique_arguments[cite_class][name];					-- look in the template-specific parameter-lists for the template identified by cite_class
		if true == state_test (state, name) then return true; end
	end																			-- if here, fall into general validation
		
	state = whitelist.basic_arguments[name];									-- all other templates; all normal parameters allowed
	if true == state_test (state, name) then return true; end

																				-- all enumerated parameters allowed
	name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );												-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
	state = whitelist.numbered_arguments[name];
	if true == state_test (state, name) then return true; end

	return false;																-- not supported because not found or name is set to nil
end


--[=[-------------------------&lt; I N T E R _ W I K I _ C H E C K &gt;----------------------------------------------

check &lt;value&gt; for inter-language interwiki-link markup.  &lt;prefix&gt; must be a MediaWiki-recognized language
code.  when these values have the form (without leading colon):
	[[&lt;prefix&gt;:link|label]] return label as plain-text
	[[&lt;prefix&gt;:link]] return &lt;prefix&gt;:link as plain-text

return value as is else

]=]

local function inter_wiki_check (parameter, value)
	local prefix = value:match ('%[%[(%a+):');									-- get an interwiki prefix if one exists
	local _;
	
	if prefix and cfg.inter_wiki_map[prefix:lower()] then						-- if prefix is in the map, needs preceding colon so
		table.insert( z.message_tail, {utilities.set_message ('err_bad_paramlink', parameter)});	-- emit an error message
		_, value, _ = utilities.is_wikilink (value);							-- extract label portion from wikilink
	end
	return value;
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe.  There are two tests made:
	{{cite ... |title=Title access-date=2016-03-17}}	-- the first parameter has a value and whitespace separates that value from the missing pipe parameter name
	{{cite ... |title=access-date=2016-03-17}}			-- the first parameter has no value (whitespace after the first = is trimmed by MediaWiki)
cs1|2 shares some parameter names with XML/HTML attributes: class=, title=, etc.  To prevent false positives XML/HTML
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (parameter, value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove XML/HTML tags because attributes: class=, title=, etc.

	capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then										-- if the capture is a valid parameter name
		table.insert( z.message_tail, {utilities.set_message ('err_missing_pipe', parameter)});
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ P U N C T &gt;--------------------------------------

look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_punc (param, value)
	if 'number' == type (param) then
		return;
	end
	
	param = param:gsub ('%d+', '#');											-- enumerated name-list mask params allow terminal punct; normalize 
	if cfg.punct_skip[param] then
		return;																	-- parameter name found in the skip table so done
	end
	
	if value:match ('[,;:]$') then
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
end


--[[--------------------------&lt; C I T A T I O N &gt;--------------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

local function citation(frame)
	Frame = frame;																-- save a copy in case we need to display an error message in preview mode
	local pframe = frame:getParent()
	local styles;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		styles = 'Module:Citation/CS1/sandbox/styles.css';
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
		styles = 'Module:Citation/CS1/styles.css';
	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the selected cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text, error_state;

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do											-- get parameters from the {{#invoke}} frame
		config[k] = v;
	--	args[k] = v;															-- crude debug support that allows us to render a citation from module {{#invoke:}}; skips parameter validation; TODO: keep?
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	local empty_unknowns = {};													-- sequence table to hold empty unknown params for error message listing
	for k, v in pairs( pframe.args ) do											-- get parameters from the parent (template) frame
		v = mw.ustring.gsub (v, '^%s*(.-)%s*$', '%1');							-- trim leading/trailing whitespace; when v is only whitespace, becomes empty string
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = utilities.set_message ( 'err_text_ignored', {v}, true );
					end
				elseif validate( k:lower(), config.CitationClass ) then 
					error_text, error_state = utilities.set_message ( 'err_parameter_ignored_suggest', {k, k:lower()}, true );	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no capture in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = utilities.substitute (param, capture);		-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text, error_state = utilities.set_message ('err_parameter_ignored_suggest', {k, param}, true);	-- set the suggestion error message
							else
								error_text, error_state = utilities.set_message ( 'err_parameter_ignored', {param}, true );	-- suggested param not supported by this template
								v = '';											-- unset
							end
						end
					end
					if not utilities.is_set (error_text) then					-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = utilities.set_message ( 'err_parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = utilities.set_message ( 'err_parameter_ignored', {k}, true );
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end

			args[k] = v;														-- save this parameter and its value

		elseif not utilities.is_set (v) then									-- for empty parameters
			if not validate (k, config.CitationClass, true) then				-- is this empty parameter a valid parameter
				table.insert (empty_unknowns, utilities.wrap_style ('parameter', k));	-- format for error message and add to the list
			end
																				-- crude debug support that allows us to render a citation from module {{#invoke:}} TODO: keep?
	--	elseif args[k] ~= nil or (k == 'postscript') then						-- when args[k] has a value from {{#invoke}} frame (we don't normally do that)
	--		args[k] = v;														-- overwrite args[k] with empty string from pframe.args[k] (template frame); v is empty string here
		end																		-- not sure about the postscript bit; that gets handled in parameter validation; historical artifact?
	end	

	if 0 ~= #empty_unknowns then												-- create empty unknown error message
		table.insert (z.message_tail, {utilities.set_message ('err_param_unknown_empty', {
			1 == #empty_unknowns and '' or 's',
			utilities.make_sep_list (#empty_unknowns, empty_unknowns)
			}, true )});
	end

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);											-- look for invisible characters
		end
		has_extraneous_punc (k, v);												-- look for extraneous terminal punctuation in parameter values
		missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?
		args[k] = inter_wiki_check (k, v);										-- when language interwiki-linked parameter missing leading colon replace with wiki-link label
	end

	return table.concat ({citation0( config, args), frame:extensionTag ('templatestyles', '', {src=styles})});
end

--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {citation = citation};</text>
      <sha1>9edlfct2jxg3jf4jt3x74p2dekdt05l</sha1>
    </revision>
    <revision>
      <id>4734</id>
      <parentid>4733</parentid>
      <timestamp>2020-10-10T14:07:33Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>can't track |nocat= without tracking |nocat=;</comment>
      <origin>4734</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="206655" sha1="b6pgic86ku87oycir87o8u0a3hnesxk" xml:space="preserve">--[[
History of changes since last sync: 2020-07-11

2020-07-16: Add editors to the deprecated list. See Help_talk:Citation_Style_1#Editors
2020-07-22: fix duplicate error message; see Help_talk:Citation_Style_1#duplicate_error_message
2020-07-29: auto-link bug fix; see Help_talk:Citation_Style_1#auto-link_bug_fix
2020-07-30: unify handling of error and maint messaging; see Help_talk:Citation_Style_1#Some_maintenance_items_to_upgrade_to_errors
2020-08-08: upgrade disp_names maintenance messaging to error,
    change unrecognized display name values from invalid_param_value to disp_name;
    see Help_talk:Citation_Style_1#Some_maintenance_items_to_upgrade_to_errors
2020-08-18: tweak |&lt;name&gt;-link= and |&lt;name&gt;-mask= interaction; see Help_talk:Citation_Style_1#Small_glitches_masking_and_linking_author_names
2020-08-30: fix given-missing-surname error message; see Help_talk:Citation_Style_1#Incorrect_error_message_when_given_param_is_used
2020-08-30: check for more than 0 semicolons; Help_talk:Citation_Style_1#Counting_semicolons
2020-09-02: {{para|orig-date}} preferred over {{para|orig-year}}, change metaparameters; see Help_talk:Citation_Style_1#cite_news_should_have_two_dates
2020-09-03: error messaging for 'Wayback Machine' and other generic titles; see Help_talk:Citation_Style_1#Wayback_Machine
2020-09-11: use common function to render comma-separated lists; see Help_talk:Citation_Style_1#last-author-amp=
2020-09-13: convert to &lt;module&gt;.&lt;function&gt;() calls to avoid upvalue limit; see Help_talk:Citation_Style_1#O_wicked_wall,_through_whom_I_see_no_bliss!
2020-09-26: move add_prop_cat() to Module:Citation/CS1/Utilities/sandbox; see Help_talk:Citation_Style_1#Request_for_new_maintenance_category_for_abbreviated_year_ranges_in_the_date%3D_parameter
2020-09-26: add keyword &quot;off&quot; to distinguish from &quot;none&quot; in |title=; see Help_talk:Citation_Style_1#Descriptive_titles_and_tokenizing_the_%22No_title%22_case
2020-09-26: add override and disable capability for auto-linking; see Help_talk:Citation_Style_1#Manual_override_of_auto-linking, Help_talk:Citation_Style_1#Guidance_on_title-linking:_update_after_RfC, Help_talk:Citation_Style_1/Archive_70#Towards_solving_pending_issues_of_the_auto-link_feature..., Help_talk:Citation_Style_1#Proceeding
2020-09-27: add trans/script/pages support for quotes; see Help_talk:Citation_Style_1#trans-quote?

]]

require('Module:No globals');

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------

each of these counts against the Lua upvalue limit

]]

local validation;																-- functions in Module:Citation/CS1/Date_validation

local utilities;																-- functions in Module:Citation/CS1/Utilities
local z ={};																	-- table of tables in Module:Citation/CS1/Utilities

local identifiers;																-- functions and tables in Module:Citation/CS1/Identifiers
local metadata;																	-- functions in Module:Citation/CS1/COinS
local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

declare variables here that have page-wide scope that are not brought in from other modules; that are created here and used here

]]

local added_deprecated_cat;														-- Boolean flag so that the category is added only once
local added_vanc_errs;															-- Boolean flag so we only emit one Vancouver error / category

local Frame;																	-- holds the module's frame table


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if utilities.is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a Boolean declared in page scope variables above

]]

local function add_vanc_error (source)
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { utilities.set_message ( 'err_vancouver', {source}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a URI scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of TLDs: https://www.iana.org/domains/root/db

RFC 952 (modified by RFC 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the TLD.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a URL with a scheme) will be stripped
here.  Perhaps not necessary but retained in case it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ASCII characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the TLD) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and TLD or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%w]') then											-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at Wikisource
		return false;
	end

	local patterns = {															-- patterns that look like URLs
		'%f[%w][%w][%w%-]+[%w]%.%a%a+$',										-- three or more character hostname.hostname or hostname.tld
		'%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$',									-- internationalized domain name with ACE prefix
		'%f[%a][qxz]%.com$',													-- assigned one character .com hostname (x.com times out 2015-12-10)
		'%f[%a][iq]%.net$',														-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		'%f[%w][%w]%.%a%a$',													-- one character hostname and ccTLD (2 chars)
		'%f[%w][%w][%w]%.%a%a+$',												-- two character hostname and TLD
		'^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?',								-- IPv4 address
		}

	for _, pattern in ipairs (patterns) do										-- loop through the patterns list
		if domain:match (pattern) then
			return true;														-- if a match then we think that this thing that purports to be a URL is a URL
		end
	end

	for _, d in ipairs ({'cash', 'company', 'today', 'org'}) do					-- look for single letter second level domain names for these top level domains
		if domain:match ('%f[%w][%w]%.' .. d) then
			return true
		end
	end
	return false;																-- no matches, we don't know what this thing is
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a URL appear to be a valid URL; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if utilities.is_set (scheme) then											-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when URL is protocol-relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a URL into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following TLD) (if any) and any path(/), query(?) or fragment(#).

If protocol-relative URL, return nil scheme and domain else return nil for both scheme and domain.

When not protocol-relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Any URL that does not have news: scheme must have authority indicator (//).  TODO: are there other common schemes
like news: that don't use authority indicator?

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol-relative URL
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		if utilities.is_set (authority) then
			authority = authority:gsub ('//', '', 1);							-- replace place 1 pair of '/' with nothing;
			if utilities.is_set(authority) then									-- if anything left (1 or 3+ '/' where authority should be) then
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		else
			if not scheme:match ('^news:') then									-- except for news:..., MediaWiki won't link URLs that do not have authority indicator; TODO: a better way to do this test?
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link=, etc. for properly formatted content: no wikilinks, no URLs

Link parameters are to hold the title of a Wikipedia article, so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki URLs and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid URL (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid URL (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from URL; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid URL
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wiki-linked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

check &lt;link&gt; for inter-language interwiki-link prefix.  prefix must be a MediaWiki-recognized language
code and must begin with a colon.

]]

local function link_title_ok (link, lorig, title, torig)
local orig;
	if utilities.is_set (link) then 											-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		elseif link:match ('^%a+:') then										-- if the link is what looks like an interwiki
			local prefix = link:match ('^(%a+):'):lower();						-- get the interwiki prefix

			if cfg.inter_wiki_map[prefix] then									-- if prefix is in the map, must have preceding colon
				orig = lorig;													-- flag as error
			end
		end
	end

	if utilities.is_set (orig) then
		link = '';																-- unset
		table.insert( z.message_tail, { utilities.set_message ( 'err_bad_paramlink', orig)});	-- URL or wikilink in |title= with |title-link=;
	end
	
	return link;																-- link if ok, empty string else
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the URL into scheme and domain
portions, or for protocol-relative (//example.com) URLs, just the domain.  Use is_url() to validate the two
portions of the URL.  If both are valid, or for protocol-relative if domain is valid, return true, else false.

Because it is different from a standard URL, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper URL
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from URL;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a URL.  The test will also find external wikilinks
that use protocol-relative URLs. Also finds bare URLs.

The frontier pattern prevents a match on interwiki-links which are similar to scheme:path URLs.  The tests that
find bracketed URLs are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext. wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol-relative ext. wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare URL with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol-relative bare URL: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a URL
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a URL add an error message
			if utilities.is_set(error_message) then								-- once we've added the first portion of the error message ...
				error_message = error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message = error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if utilities.is_set (error_message) then									-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { utilities.set_message ( 'err_param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { utilities.set_message ( 'err_wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source, access)
	local error_str = &quot;&quot;;
	local domain;
	local path;
	local base_url;

	if not utilities.is_set ( label ) then
		label = URL;
		if utilities.is_set ( source ) then
			error_str = utilities.set_message ( 'err_bare_url_missing_title', { utilities.wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = utilities.set_message ( 'err_bad_url', {utilities.wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the URL into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['['] = '%5b', [']'] = '%5d'});					-- replace '[' and ']' with their percent-encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wiki-markup URL

	if utilities.is_set (access) then											-- access level (subscription, registration, limited)
		base_url = utilities.substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end
	
	return table.concat ({base_url, error_str});
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a Boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { utilities.set_message ( 'err_deprecated_params', {name}, true ) } );	-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wiki-markup) are not kerned.

Replaces Unicode quote marks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc.; not for book titles.

]=]

local function kern_quotes (str)
	local cap = '';
	local cap2 = '';
	local wl_type, label, link;

	wl_type, label, link = utilities.is_wikilink (str);							-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-wl-both'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = utilities.substitute (cfg.presentation['kern-wl-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-wl-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label = mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label = mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap, cap2 = mw.ustring.match (label, &quot;^([\&quot;\'])([^\'].+)&quot;);				-- match leading double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-left'], {cap, cap2});
		end
	
		cap, cap2 = mw.ustring.match (label, &quot;^(.+[^\'])([\&quot;\'])$&quot;)				-- match trailing double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-right'], {cap, cap2});
		end
		
		if 2 == wl_type then
			str = utilities.make_wikilink (link, label);						-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin-based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate RTL languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO 639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO 639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title=, |script-chapter=, |script-&lt;periodical&gt;=

]]

local function format_script_value (script_value, script_param)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%l?%s*:') then									-- if first 3 or 4 non-space characters are script language prefix
		lang = script_value:match('^(%l%l%l?)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not utilities.is_set (lang) then
			table.insert( z.message_tail, { utilities.set_message ( 'err_script_parameter', {script_param, 'missing title part'}, true ) } );		-- prefix without 'title'; add error message
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_code_remap[lang] or mw.language.fetchLanguageName( lang, cfg.this_wiki_code );	-- get language name so that we can use it to categorize
		if utilities.is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l+%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if utilities.in_array (lang, cfg.script_lang_codes) then
				utilities.add_prop_cat ('script_with_name', {name, lang})
			else
				table.insert( z.message_tail, { utilities.set_message ( 'err_script_parameter', {script_param, 'unknown language code'}, true ) } );	-- unknown script-language; add error message
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			table.insert( z.message_tail, { utilities.set_message ( 'err_script_parameter', {script_param, 'invalid language code'}, true ) } );		-- invalid language code; add error message
			lang = '';															-- invalid so set lang to empty string
		end
	else
		table.insert( z.message_tail, { utilities.set_message ( 'err_script_parameter', {script_param, 'missing prefix'}, true ) } );				-- no language code prefix; add error message
	end
	script_value = utilities.substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is RTL

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script, script_param)
	if utilities.is_set (script) then
		script = format_script_value (script, script_param);					-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; returns empty string on error
		if utilities.is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not utilities.is_set ( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return utilities.substitute ( msg, str );								-- including template text
	else
		return utilities.substitute ( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;----------------------------------------

Makes a Wikisource URL from Wikisource interwiki-link.  Returns the URL and appropriate label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;
	local wikisource_prefix = table.concat ({'https://', cfg.this_wiki_code, '.wikisource.org/wiki/'});

	wl_type, D, L = utilities.is_wikilink (str);								-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 1 == wl_type then													-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end
	
	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable URL
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent encoding of fragment marker
	end

	return ws_url, ws_label, L or D;											-- return proper URL or nil and a label or nil
end


--[[--------------------------&lt; F O R M A T _ P E R I O D I C A L &gt;--------------------------------------------

Format the three periodical parameters: |script-&lt;periodical&gt;=, |&lt;periodical&gt;=, and |trans-&lt;periodical&gt;= into a single Periodical meta-
parameter.

]]

local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)
	local periodical_error = '';

	if not utilities.is_set (periodical) then
		periodical = '';														-- to be safe for concatenation
	else
		periodical = utilities.wrap_style ('italic-title', periodical);			-- style 
	end

	periodical = script_concatenate (periodical, script_periodical, script_periodical_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (trans_periodical) then
		trans_periodical = utilities.wrap_style ('trans-italic-title', trans_periodical);
		if utilities.is_set (periodical) then
			periodical = periodical .. ' ' .. trans_periodical;
		else																	-- here when trans-periodical without periodical or script-periodical
			periodical = trans_periodical;
			periodical_error = ' ' .. utilities.set_message ('err_trans_missing_title', {'periodical'});
		end
	end

	return periodical .. periodical_error;
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (script_chapter, script_chapter_source, chapter, chapter_source, trans_chapter, trans_chapter_source, chapter_url, chapter_url_source, no_quotes, access)
	local chapter_error = '';

	local ws_url, ws_label, L = wikisource_url_make (chapter);					-- make a wikisource URL and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', '');										-- replace underscore separaters with space characters
		chapter = ws_label;
	end

	if not utilities.is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from module provided quote marks
			chapter = utilities.wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, script_chapter, script_chapter_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (chapter_url) then
		chapter = external_link (chapter_url, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');	-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if utilities.is_set (trans_chapter) then
		trans_chapter = utilities.wrap_style ('trans-quoted-title', trans_chapter);
		if utilities.is_set (chapter) then
			chapter = chapter .. ' ' .. trans_chapter;
		else																	-- here when trans_chapter without chapter or script-chapter
			chapter = trans_chapter;
			chapter_source = trans_chapter_source:match ('trans%-?(.+)');		-- when no chapter, get matching name from trans-&lt;param&gt;
			chapter_error = ' ' .. utilities.set_message ('err_trans_missing_title', {chapter_source});
		end
	end

	return chapter .. chapter_error;
end


--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for non-printable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the Wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i = 1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no Unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char = cfg.invisible_chars[i][1]									-- the character or group name
		local pattern = cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position and (char == 'zero width joiner') then						-- if we found a zero-width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- it's ok if one of the Indic scripts
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and utilities.in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { utilities.set_message ( 'err_invisible_char', {err_msg, utilities.wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i = i+1;																-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper ( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function ( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = utilities.select_one ( args, list, 'err_redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] .. ': ' .. k);
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap = '';
	local cap2 = '';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = utilities.substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = utilities.substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if utilities.is_set (title_type) then
		if 'none' == cfg.keywords_xlate[title_type] then
			title_type = '';													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash under certain conditions.  The hyphen must separate like items; unlike items are
returned unmodified.  These forms are modified:
	letter - letter (A - B)
	digit - digit (4-5)
	digit separator digit - digit separator digit (4.1-4.5 or 4-1-4-5)
	letterdigit - letterdigit (A1-A5) (an optional separator between letter and digit is supported – a.1-a.5 or a-1-a-5)
	digitletter - digitletter (5a - 5d) (an optional separator between letter and digit is supported – 5.a-5.d or 5-a-5-d)

any other forms are returned unmodified.

str may be a comma- or semicolon-separated list

]]

local function hyphen_to_dash( str )
	if not utilities.is_set (str) then
		return str;
	end

	local accept;																-- Boolean
	str, accept = utilities.has_accept_as_written (str);						-- remove accept-this-as-written markup when it wraps all of str
	if accept then
		return str;																-- when markup removed, nothing to do, we're done
	end

	str = str:gsub ('&amp;[nm]dash;', {['&amp;ndash;'] = '–', ['&amp;mdash;'] = '—'});		-- replace &amp;mdash; and &amp;ndash; entities with their characters; semicolon mucks up the text.split
	str = str:gsub ('&amp;#45;', '-');												-- replace HTML numeric entity with hyphen character
	str = str:gsub ('&amp;nbsp;', ' ');												-- replace &amp;nbsp; entity with generic keyboard space character
	
	local out = {};
	local list = mw.text.split (str, '%s*[,;]%s*');								-- split str at comma or semicolon separators if there are any

	for _, item in ipairs (list) do												-- for each item in the list
		if mw.ustring.match (item, '^%w*[%.%-]?%w+%s*[%-–—]%s*%w*[%.%-]?%w+$') then	-- if a hyphenated range or has endash or emdash separators
			if item:match ('^%a+[%.%-]?%d+%s*%-%s*%a+[%.%-]?%d+$') or			-- letterdigit hyphen letterdigit (optional separator between letter and digit)
				item:match ('^%d+[%.%-]?%a+%s*%-%s*%d+[%.%-]?%a+$') or			-- digitletter hyphen digitletter (optional separator between digit and letter)
				item:match ('^%d+[%.%-]%d+%s*%-%s*%d+[%.%-]%d+$') or			-- digit separator digit hyphen digit separator digit
				item:match ('^%d+%s*%-%s*%d+$') or								-- digit hyphen digit
				item:match ('^%a+%s*%-%s*%a+$') then							-- letter hyphen letter
					item = item:gsub ('(%w*[%.%-]?%w+)%s*%-%s*(%w*[%.%-]?%w+)', '%1–%2');	-- replace hyphen, remove extraneous space characters
			else
				item = mw.ustring.gsub (item, '%s*[–—]%s*', '–');				-- for endash or emdash separated ranges, replace em with en, remove extraneous whitespace
			end
		end
		item = utilities.has_accept_as_written (item);							-- remove accept-this-as-written markup when it wraps all of str
		table.insert (out, item);												-- add the (possibly modified) item to the output table
	end

	return table.concat (out, ', ');											-- concatenate the output table into a comma separated string
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'duplicate character'
		if 1 == #duplicate_char then											-- for single byte ASCII characters use the string library functions
			f.gsub = string.gsub
			f.match = string.match
			f.sub = string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub = mw.ustring.gsub
			f.match = mw.ustring.match
			f.sub = mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1, 1) == '&lt;' then										-- special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove HTML markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1, 1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc.?
				trim = false;
				end_chr = f.sub(str, -1, -1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr .. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1, -2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5, -1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3, -1) == duplicate_char .. '&quot;]' then		-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2, -1) == duplicate_char .. &quot;]&quot; then		-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2, -1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1, -3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains HTML markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows HTML markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;------------------------------------------------------------

returns true is suffix is properly formed Jr, Sr, or ordinal in the range 1–9.  Puncutation not allowed.

]]

local function is_suffix (suffix)
	if utilities.in_array (suffix, {'Jr', 'Sr', 'Jnr', 'Snr', '1st', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written outside of the code editor and pasted here because the code editor gets confused between character insertion point and cursor position.
The test has been rewritten to use decimal character escape sequence for the individual bytes of the Unicode characters so that it is not necessary
to use an external editor to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first, suffix)
	if not suffix then
		if first:find ('[,%s]') then											-- when there is a space or comma, might be first name/initials + generational suffix
			first = first:match ('(.-)[,%s]+');									-- get name/initials
			suffix = first:match ('[,%s]+(.+)$');								-- get generational suffix
		end
	end
	if utilities.is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error (cfg.err_msg_supl.suffix);
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error (cfg.err_msg_supl['non-Latin char']);
			return false;														-- not a string of Latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-style=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc.) to be rendered as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the Unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just initials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error (cfg.err_msg_supl.suffix);					-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word

	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i], 1, 1));				-- insert the initial at end of initials table
		end
		i = i+1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; L I S T _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors, contributors, editors, interviewers, translators) 

names in the list will be linked when
	|&lt;name&gt;-link= has a value
	|&lt;name&gt;-mask- does NOT have a value; masked names are presumed to have been rendered previously so should have been linked there

when |&lt;name&gt;-mask=0, the associated name is not rendered

]]

local function list_people (control, people, etal)
	local sep;
	local namesep;
	local format = control.format;
	local maximum = control.maximum;
	local lastauthoramp = control.lastauthoramp;							-- TODO: delete after deprecation
	local name_list = {};

	if 'vanc' == format then													-- Vancouver-like name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between names is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
		lastauthoramp = nil;												-- TODO: delete after deprecation	-- unset because isn't used by Vancouver style
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between names is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub (-1, -1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if utilities.is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end		-- returned 0 is for EditorCount; not used for other names
	
	for i, person in ipairs (people) do
		if utilities.is_set (person.last) then
			local mask = person.mask;
			local one;
			local sep_one = sep;

			if utilities.is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			end
			
			if mask then
				local n = tonumber (mask);										-- convert to a number if it can be converted; nil else
				if n then
					one = 0 ~= n and string.rep(&quot;&amp;mdash;&quot;,n) or nil;			-- make a string of (n &gt; 0) mdashes, nil else, to replace name
					person.link = nil;											-- don't create link to name if name is replaces with mdash string or has been set nil
				else
					one = mask;													-- replace name with mask text (must include name-list separator)
					sep_one = &quot; &quot;;												-- modify name-list separator
				end
			else
				one = person.last;												-- get surname
				local first = person.first										-- get given name
				if utilities.is_set (first) then
					if (&quot;vanc&quot; == format) then									-- if Vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials (first);					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
			end
			if utilities.is_set (person.link) then
				one = utilities.make_wikilink (person.link, one);				-- link author/editor
			end
			if one then															-- if &lt;one&gt; has a value (name, mdash replacement, or mask text replacement)
				table.insert (name_list, one);									-- add it to the list of names
				table.insert (name_list, sep_one);								-- add the proper name-list separator
			end
		end
	end

	local count = #name_list / 2;												-- (number of names + number of separators) divided by 2
	if 0 &lt; count then 
		if 1 &lt; count and not etal then
			if 'amp' == format or utilities.is_set (lastauthoramp) then			-- TODO: delete lastauthoramp after deprecation
				name_list[#name_list-2] = &quot; &amp; &quot;;								-- replace last separator with ampersand text
			elseif 'and' == format then
				if 2 == count then
					name_list[#name_list-2] = cfg.presentation.sep_nl_and;		-- replace last separator with 'and' text
				else
					name_list[#name_list-2] = cfg.presentation.sep_nl_end;		-- replace last separator with '(sep) and' text
				end
			end
		end
		name_list[#name_list] = nil;											-- erase the last separator
	end

	local result = table.concat (name_list);									-- construct list
	if etal and utilities.is_set (result) then									-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've got a last-first list and etal so add et al.
	end
	
	return result, count;														-- return name-list string and count of number of names (count used for editor names only)
end


--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]

local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if utilities.is_set (id) then												-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of name parameters (author, editor, etc.) for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the associated |display-&lt;names&gt;=etal parameter

]]

local function name_has_etal (name, etal, nocat, param)

	if utilities.is_set (name) then												-- name can be nil in which case just return
		local patterns = cfg.et_al_patterns;									--get patterns from configuration
		
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns
			if name:match (pattern) then										-- if this 'et al' pattern is found in name
				name = name:gsub (pattern, '');									-- remove the offending text
				etal = true;													-- set flag (may have been set previously here or by |display-&lt;names&gt;=etal)
				if not nocat then												-- no categorization for |vauthors=
					table.insert( z.message_tail, {utilities.set_message ('err_etal', {param})});	-- and set an error if not added
				end
			end
		end
	end

	return name, etal;
end


--[[--------------------------&lt; N A M E _ I S _ N U M E R I C &gt;------------------------------------------------

Add maint cat when name parameter value does not contain letters.  Does not catch mixed alphanumeric names so
|last=A. Green (1922-1987) does not get caught in the current version of this test but |first=(1888) is caught.

returns nothing

]]

local function name_is_numeric (name, list_name)
	if utilities.is_set (name) then
		if mw.ustring.match (name, '^[%A]+$') then								-- when name does not contain any letters
			utilities.set_message ('maint_numeric_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
		end
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E D _ M A R K U P &gt;------------------------------------------

Evaluates the content of author and editor parameters for extraneous editor annotations: ed, ed., eds, (Ed.), etc.
These annotation do not belong in author parameters and are redundant in editor parameters.  If found, the function
adds the editor markup maintenance category.

returns nothing

]]

local function name_has_ed_markup (name, list_name)
	local patterns = cfg.editor_markup_patterns;								-- get patterns from configuration

	if utilities.is_set (name) then
		for _, pattern in ipairs (patterns) do									-- spin through patterns table and
			if name:match (pattern) then
				utilities.set_message ('maint_extra_text_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
				break;
			end
		end
	end
end


--[[--------------------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;----------------------------------------

Evaluates the content of last/surname (authors etc.) parameters for multiple names.  Multiple names are indicated
if there is more than one comma or any semicolons.  If found, the function adds the multiple name maintenance category.

returns nothing

]]

local function name_has_mult_names (name, list_name)
	local _, commas, semicolons;
	if utilities.is_set (name) then
		_, commas = name:gsub (',', '');										-- count the number of commas
		_, semicolons = name:gsub (';', '');									-- count the number of semicolons
		
		if 1 &lt; commas or 0 &lt; semicolons then												
			utilities.set_message ('maint_mult_names', cfg.special_case_translation [list_name]);	-- add a maint message
		end
	end
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------

This function calls various name checking functions used to validate the content of the various name-holding
parameters.

]]

local function name_checks (last, first, list_name)
	local accept_name;

	if utilities.is_set (last) then
		last, accept_name = utilities.has_accept_as_written (last);				-- remove accept-this-as-written markup when it wraps all of &lt;last&gt;
		
		if not accept_name then													-- &lt;last&gt; not wrapped in accept-as-written markup
			name_has_mult_names (last, list_name);								-- check for multiple names in the parameter (last only)
			name_has_ed_markup (last, list_name);								-- check for extraneous 'editor' annotation
			name_is_numeric (last, list_name);									-- check for names that are compsed of digits and punctuation
		end
	end

	if utilities.is_set (first) then
		first, accept_name = utilities.has_accept_as_written (first);			-- remove accept-this-as-written markup when it wraps all of &lt;first&gt;

		if not accept_name then														-- &lt;first&gt; not wrapped in accept-as-written markup
			name_has_ed_markup (first, list_name);								-- check for extraneous 'editor' annotation
			name_is_numeric (first, list_name);									-- check for names that are compsed of digits and punctuation
		end
	end

	return last, first;															-- done
end


--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};															-- table of names
	local last;																	-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;																-- loop counter/indexer
	local n = 1;																-- output table indexer
	local count = 0;															-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal = false;															-- return value set to true when we find some form of et al. in an author parameter

	local last_alias, first_alias, link_alias;									-- selected parameter aliases used in error messaging
	while true do
		last, last_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'err_redundant_parameters', i );		-- search through args for name components beginning at 1
		first, first_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'err_redundant_parameters', i );
		link, link_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i );
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.
		last, first = name_checks (last, first, list_name);						-- multiple names, extraneous annotation, etc. checks
		
		if first and not last then												-- if there is a firstn without a matching lastn
			local alias = first_alias:find ('given', 1, true) and 'given' or 'first';	-- get first or given form of the alias
			table.insert (z.message_tail, { utilities.set_message ( 'err_first_missing_last', {
				first_alias,													-- param name of alias missing its mate
				first_alias:gsub (alias, {['first'] = 'last', ['given'] = 'surname'}),	-- make param name appropriate to the alias form
				}, true ) } );													-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			local result;
			link = link_title_ok (link, link_alias, last, last_alias);			-- check for improper wiki-markup
			if first then
				link = link_title_ok (link, link_alias, first, first_alias);	-- check for improper wiki-markup
			end

			names[n] = {last = last, first = first, link = link, mask = mask, corporate = false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { utilities.set_message ( 'err_missing_name', {list_name:match (&quot;(%w+)List&quot;):lower(), i - 1}, true ) } );	-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names and the etal flag
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because case of the source may be incorrect
or different from the case that WikiMedia uses, the name comparisons are done in lower case and when a match is
found, the Wikimedia version (assumed to be correct) is returned along with the code.  When there is no match, we
return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') returns a list of languages that in some cases may include
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.  Most (all?) of these languages are not used a 'language' codes per se, rather they
are used as sub-domain names: cbk-zam.wikipedia.org.  A list of language names and codes supported by fetchLanguageNames()
can be found at Template:Citation Style documentation/language/doc

Names that are included in the list will be found if that name is provided in the |language= parameter.  For example,
if |language=Chavacano de Zamboanga, that name will be found with the associated code 'cbk-zam'.  When names are found
and the associated code is not two or three characters, this function returns only the WikiMedia language name.

Some language names have multiple entries under different codes:
	Aromanian has code rup and code roa-rup
When this occurs, this function returns the language name and the 2- or 3-character code

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	if cfg.lang_name_remap[lang:lower()] then									-- if there is a remapped name (because MediaWiki uses something that we don't think is correct)
		return cfg.lang_name_remap[lang:lower()][1], cfg.lang_name_remap[lang:lower()][2];	-- for this language 'name', return a possibly new name and appropriate code
	end

	local ietf_code;															-- because some languages have both IETF-like codes and ISO 639-like codes
	local ietf_name;
	
	local langlc = mw.ustring.lower (lang);										-- lower-case version for comparisons

	for code, name in pairs (cfg.languages) do									-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower (name) then
			if 2 == #code or 3 == #code then									-- two- or three-character codes only; IETF extensions not supported
				return name, code;												-- so return the name and the code
			end
			ietf_code = code;													-- remember that we found an IETF-like code and save its name
			ietf_name = name;													-- but keep looking for a 2- or 3-char code
		end
	end
																				-- didn't find name with 2- or 3-char code; if IETF-like code found return
	return ietf_code and ietf_name or lang;										-- associated name; return original language text else
end


--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code is recognized by MediaWiki,
use the returned name; if not, then use the value that was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is assigned to the category for
that code: Category:Norwegian-language sources (no).  For valid three-character code languages, the page is assigned
to the single category for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does not recognize three-character
equivalents of two-character codes: code 'ar' is recognized but code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are
separated from each other by commas with optional space characters.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki_name = mw.language.fetchLanguageName (cfg.this_wiki_code, cfg.this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang
		name = cfg.lang_code_remap[lang:lower()];								-- first see if this is a code that is not supported by MediaWiki but is in remap

		if name then															-- there was a remapped code so
			if not lang:match ('^%a%a%a?%-x%-%a+$') then						-- if not a private IETF tag
				lang = lang:gsub ('^(%a%a%a?)%-.*', '%1');						-- strip IETF tags from code
			end
		else
			lang = lang:gsub ('^(%a%a%a?)%-.*', '%1');							-- strip any IETF-like tags from code
			if 2 == lang:len() or 3 == lang:len() then							-- if two-or three-character code
				name = mw.language.fetchLanguageName (lang:lower(), cfg.this_wiki_code);	-- get language name if |language= is a proper code
			end
		end

		if utilities.is_set (name) then											-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, cfg.this_wiki_code);			-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if utilities.is_set (code) then											-- only 2- or 3-character codes
			name = cfg.lang_code_remap[code] or name;							-- override wikimedia when they misuse language codes/names

			if cfg.this_wiki_code ~= code then									-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					utilities.add_prop_cat ('foreign_lang_source' .. code, {name, code});	-- categorize it; code appended to allow for multiple language categorization
				else															-- or is a recognized language (but has a three-character code)
					utilities.add_prop_cat ('foreign_lang_source_2' .. code, {code});		-- categorize it differently TODO: support multiple three-character code categories per cs1|2 template
				end
			elseif cfg.local_lang_cat_enable then								-- when the language and this wiki's language are the same and categorization is enabled
				utilities.add_prop_cat ('local_lang_source', {name, code});		-- categorize it
			end
		else
			utilities.set_message ('maint_unknown_lang');						-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
 
	name = utilities.make_sep_list (#language_list, language_list);

	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings
At en.wiki, for cs1:
	ps gets:	'.'
	sep gets:	'.'

]]

local function set_cs1_style (ps)
	if not utilities.is_set (ps) then											-- unless explicitly set to something
		ps = cfg.presentation['ps_cs1'];										-- terminate the rendered citation
	end
	return cfg.presentation['sep_cs1'], ps;										-- element separator
end


--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings
At en.wiki, for cs2:
	ps gets:	'' (empty string - no terminal punctuation)
	sep gets:	','

]]

local function set_cs2_style (ps, ref)
	if not utilities.is_set (ps) then											-- if |postscript= has not been set, set cs2 default
		ps = cfg.presentation['ps_cs2'];										-- terminate the rendered citation
	end
	if not utilities.is_set (ref) then											-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return cfg.presentation['sep_cs2'], ps, ref;								-- element separator
end


--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end


--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end

	if cfg.keywords_xlate[ps:lower()] == 'none' then							-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end


--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a URL has the file extension that is one of the PDF file extensions used by [[MediaWiki:Common.css]] when
applying the PDF icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or
		url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
		url:match ('%.PDF&amp;#035') or url:match ('%.pdf&amp;#035');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies CSS style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching URL parameter.  If the format parameter is not set and the URL contains a file extension that
is recognized as a PDF document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if utilities.is_set (format) then
		format = utilities.wrap_style ('format', format);						-- add leading space, parentheses, resize
		if not utilities.is_set (url) then
			format = format .. ' ' .. utilities.set_message ( 'err_format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if URL is a PDF file then
		format = utilities.wrap_style ('format', 'PDF');						-- set format to PDF
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[--------------------------&lt; G E T _ D I S P L A Y _ N A M E S &gt;--------------------------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a Boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_names (max, count, list_name, etal)
	if utilities.is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				table.insert( z.message_tail, {utilities.set_message ('err_disp_name', {cfg.special_case_translation [list_name], max}, true)});	-- add error message
				max = nil;
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, {utilities.set_message ('err_disp_name', {cfg.special_case_translation [list_name], max}, true)});		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		utilities.set_message ('maint_extra_text');								-- add maint cat;
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parentheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a place holder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parentheses
			local name = name_table[i];
			i = i + 1;																-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parentheses
					break;														-- and done reassembling so
				end
				i = i + 1;														-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = utilities.is_wikilink (name_table[i]);		-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i + 1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled parentheses ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the Vancouver error when a required comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		first = '';																-- set to empty string for concatenation and because it may have been set for previous author/editor
		local accept_name;
		v_name, accept_name = utilities.has_accept_as_written (v_name);			-- remove accept-this-as-written markup when it wraps all of &lt;v_name&gt;

--		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parentheses to suppress vanc formatting and error detection
--			last = v_name:match ('^%(%((.+)%)%)$')								-- remove doubled parentheses
		if accept_name then
			last = v_name;
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error (cfg.err_msg_supl.punctuation);
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s+&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be initials or generational suffix

			if not mw.ustring.match (first, '^%u+$') then						-- mw.ustring here so that later we will catch non-Latin characters
				suffix = first;													-- not initials so assume that whatever we got is a generational suffix
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end
			last = table.concat(lastfirstTable, ' ')							-- returns a string that is the concatenation of all other names that are not initials and generational suffix
			if not utilities.is_set (last) then
				first = '';														-- unset
				last = v_name;													-- last empty because something wrong with first
				add_vanc_error (cfg.err_msg_supl.name);
			end
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error (cfg.err_msg_supl['missing comma']);				-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error (cfg.err_msg_supl.name);							-- matches a space between two initials
			end
		else
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
		
		if utilities.is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error (cfg.err_msg_supl.initials);						-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first, suffix);							-- check first and last before restoring the suffix which may have a non-Latin digit
			if utilities.is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '');
			end
		end

		link = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i ) or v_link_table[i];
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate = corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
	local lastfirst = false;
	if utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice in case we have a |first1= without a |last1=; this ...
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or		-- ... also catches the case where |first= is used with |vauthors=
		utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst = true;
	end

	if (utilities.is_set (vxxxxors) and true == lastfirst) or					-- these are the three error conditions
		(utilities.is_set (vxxxxors) and utilities.is_set (xxxxors)) or
		(true == lastfirst and utilities.is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { utilities.set_message ( 'err_redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if utilities.is_set (vxxxxors) then return 2 end;
	if utilities.is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, live, dead, etc.).  When the parameter value has not been assigned a value (missing
or empty in the source template) the function returns the value specified by ret_val.  If the parameter value is one
of the list of allowed values returns the translated value; else, emits an error message and returns the value
specified by ret_val.

]]

local function is_valid_parameter_value (value, name, possible, ret_val)
	if not utilities.is_set (value) then
		return ret_val;															-- an empty parameter is ok
	elseif utilities.in_array (value, possible) then
		return cfg.keywords_xlate[value];										-- return translation of parameter keyword
	else
		table.insert( z.message_tail, { utilities.set_message ( 'err_invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return ret_val;
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list, -3, -1) == sepc .. '. ') then					-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list, -1, -1) == sepc) or (string.sub (name_list, -3, -1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terminate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not utilities.is_set (volume) and not utilities.is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (utilities.in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if utilities.is_set (volume) and utilities.is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif utilities.is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end

	if 'podcast' == cite_class and utilities.is_set (issue) then
		return wrap_msg ('issue', {sepc, issue}, lower);
	end

	local vol = '';																-- here for all cites except magazine
		
	if utilities.is_set (volume) then
		if volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$') then			-- volume value is all digits or all uppercase Roman numerals
			vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});	-- render in bold face
		elseif (4 &lt; mw.ustring.len(volume)) then								-- not all digits or Roman numerals and longer than 4 characters
			vol = utilities.substitute (cfg.messages['j-vol'], {sepc, volume});	-- not bold
			utilities.add_prop_cat ('long_vol');
		else																	-- four or less characters
			vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});	-- bold
		end
	end
	if utilities.is_set (issue) then
		return vol .. utilities.substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if utilities.is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif utilities.is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if utilities.is_set (page) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return utilities.substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return utilities.substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif utilities.is_set (pages) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then							-- if pages is only digits, assume a single page number
			return '', utilities.substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', utilities.substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', utilities.substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to Wikisource, returns the label portion of the interwiki-link as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki-link to and external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, pages, at)
	local ws_url, ws_label, coins_pages, L;										-- for Wikisource interwiki-links; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if utilities.is_set (page) then
		if utilities.is_set (pages) or utilities.is_set (at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws URL from |page= interwiki link; link portion L becomes tooltip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (pages) then
		if utilities.is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws URL from |pages= interwiki link; link portion L becomes tooltip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws URL from |at= interwiki link; link portion L becomes tooltip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org URLs to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot URL or to calendar pages.  When the archive URL is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the URL.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org URL does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command URL
	|archive-url= is an archive.org URL that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org URLs:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this function may return a modified
archive URL:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the URL unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.org URL
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine URL
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command URL, we don't want to allow saving of the target page 
		err_msg = cfg.err_msg_supl.save;
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = cfg.err_msg_supl.liveweb;
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');	-- split out some of the URL parts for evaluation
		
		if not utilities.is_set (timestamp) or 14 ~= timestamp:len() then		-- path and flag optional, must have 14-digit timestamp here
			err_msg = cfg.err_msg_supl.timestamp;
			if '*' ~= flag then
				url=url:gsub ('(//web%.archive%.org/[^%d]*%d?%d?%d?%d?%d?%d?)[^/]*', '%1*', 1)	-- for preview, modify ts to be yearmo* max (0-6 digits plus splat)
			end
		elseif utilities.is_set (path) and 'web/' ~= path then					-- older archive URLs do not have the extra 'web/' path element
			err_msg = cfg.err_msg_supl.path;
		elseif utilities.is_set (flag) and not utilities.is_set (path) then		-- flag not allowed with the old form URL (without the 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		elseif utilities.is_set (flag) and not flag:match ('%a%a_') then		-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		else
			return url, date;													-- return ArchiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	table.insert( z.message_tail, { utilities.set_message ( 'err_archive_url', {err_msg}, true ) } );	-- add error message and
	if utilities.is_set (Frame:preprocess('{{REVISIONID}}')) then
		return '', '';															-- return empty strings for ArchiveURL and ArchiveDate
	else
		return url, date;														-- preview mode so return ArchiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; P L A C E _ C H E C K &gt;--------------------------------------------------------

check |place=, |publication-place=, |location= to see if these params include digits.  This function added because
many editors misuse location to specify the in-source location (|page(s)= and |at= are supposed to do that)

returns the original parameter value without modification; added maint cat when parameter value contains digits

]]

local function place_check (param_val)
	if not utilities.is_set (param_val) then									-- parameter empty or omitted
		return param_val;														-- return that empty state
	end
	
	if mw.ustring.find (param_val, '%d') then									-- not empty, are there digits in the parameter value
		utilities.set_message ('maint_location');								-- yep, add maint cat
	end
	
	return param_val;															-- and done
end


--[[--------------------------&lt; I S _ G E N E R I C _ T I T L E &gt;----------------------------------------------

compares |title= value against list of known generic title patterns.  Returns true when pattern matches; nil else

the k/v pairs in 'generic_titles' each contain two tables, one for English and one for another 'local' language
Each of those tables contain another table that holds the string or pattern (whole title or title fragment) in
index [1].  index [2] is a Boolean that tells string.find() or mw.ustring.find() to do plain-text search (true)
or a pattern search (false).  The intent of all this complexity is to make these searches as fast as possible so
that we don't run out of processing time on very large articles.

]]

local function is_generic_title (title)
	title = mw.ustring.lower(title);											-- switch title to lower case
	for _, generic_title in ipairs (cfg.special_case_translation['generic_titles']) do	--spin through the list of known generic title fragments
		if title:find (generic_title['en'][1], 1, generic_title['en'][2]) then
			return true;														-- found English generic title so done
		elseif generic_title['local'] then										-- to keep work load down, generic_title['local'] should be nil except when there is a local version of the generic title
			if mw.ustring.find (title, generic_title['local'][1], 1, generic_title['local'][2]) then	-- mw.ustring() because might not be Latin script
				return true;													-- found local generic title so done
			end
		end
	end
end


--[[--------------------------&lt; I S _ A R C H I V E D _ C O P Y &gt;----------------------------------------------

compares |title= to 'Archived copy' (place holder added by bots that can't find proper title); if matches, return true; nil else

]]

local function is_archived_copy (title)
	title = mw.ustring.lower(title);											-- switch title to lower case
	if title:find (cfg.special_case_translation.archived_copy.en) then			-- if title is 'Archived copy'
		return true;
	elseif cfg.special_case_translation.archived_copy['local'] then
		if mw.ustring.find (title, cfg.special_case_translation.archived_copy['local']) then	-- mw.ustring() because might not be Latin script
			return true;
		end
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper ( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

	local Mode = is_valid_parameter_value (A['Mode'], A:ORIGIN('Mode'), cfg.keywords_lists['mode'], '');

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;

	local NameListStyle = is_valid_parameter_value (A['NameListStyle'], A:ORIGIN('NameListStyle'), cfg.keywords_lists['name-list-style'], '');
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';											-- override whatever |name-list-style= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				utilities.set_message ('maint_authors');						-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if utilities.is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';											-- override whatever |name-list-style= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
		end
	end

	local translator_etal;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=

	local interviewer_etal;
	local interviewers_list = {};												
	local Interviewers;															-- used later
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters

	local contributor_etal;
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list

	local Chapter = A['Chapter'];												-- done here so that we have access to |contribution= from |chapter= aliases
	local Chapter_origin = A:ORIGIN ('Chapter');
	local Contribution;															-- because contribution is required for contributor(s)
		if 'contribution' == A:ORIGIN ('Chapter') then
			Contribution = A['Chapter'];										-- get the name of the contribution
		end

	if utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not utilities.is_set (Contribution) then							-- |contributor= requires |contribution=
				table.insert( z.message_tail, { utilities.set_message ( 'err_contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { utilities.set_message ( 'err_contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if utilities.select_one (args, cfg.aliases['ContributorList-Last'], 'err_redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { utilities.set_message ( 'err_contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if utilities.is_set (Others) then
		if 0 == #a and 0 == #e then												-- add maint cat when |others= has value and used without |author=, |editor=
			utilities.set_message ('maint_others');
		end
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigDate = A['OrigDate'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TransTitle_origin = A:ORIGIN ('TransTitle');
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];

	local auto_select = ''; -- default is auto
	local accept_link;
	TitleLink, accept_link = utilities.has_accept_as_written(TitleLink, true); -- test for accept-this-as-written markup
	if (not accept_link) and utilities.in_array (TitleLink, {'none', 'pmc', 'doi'}) then -- check for special keywords
		auto_select = TitleLink; -- remember selection for later
		TitleLink = ''; -- treat as if |title-link= would have been empty
	end

	TitleLink = link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wiki-markup in |title-link= or wiki-markup in |title= when |title-link= is set

	local Section = '';															-- {{cite map}} only; preset to empty string for concatenation if not used
		if 'map' == config.CitationClass and 'section' == A:ORIGIN ('Chapter') then
			Section = A['Chapter'];												-- get |section= from |chapter= alias list; |chapter= and the other aliases not supported in {{cite map}}
			Chapter = '';														-- unset for now; will be reset later from |map= if present
		end

	local ScriptChapter = A['ScriptChapter'];
	local ScriptChapter_origin = A:ORIGIN ('ScriptChapter');
	local ChapterLink -- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TransChapter_origin = A:ORIGIN ('TransChapter');
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];

	local ArchiveDate;
	local ArchiveURL;

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	
	local UrlStatus = is_valid_parameter_value (A['UrlStatus'], A:ORIGIN('UrlStatus'), cfg.keywords_lists['url-status'], '');

	local URL = A['URL']
	local URL_origin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURL_origin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURL_origin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL

	local Periodical = A['Periodical'];
	local Periodical_origin = '';
	if utilities.is_set (Periodical) then
		Periodical_origin = A:ORIGIN('Periodical');								-- get the name of the periodical parameter
		local i;
		Periodical, i = utilities.strip_apostrophe_markup (Periodical);			-- strip apostrophe markup so that metadata isn't contaminated 
		if i then																-- non-zero when markup was stripped so emit an error message
			table.insert( z.message_tail, {utilities.set_message ('err_apostrophe_markup', {Periodical_origin}, true)});
		end
	end

	if 'mailinglist' == config.CitationClass then								-- special case for {{cite mailing list}}
		if utilities.is_set (Periodical) and utilities.is_set (A ['MailingList']) then	-- both set emit an error
			table.insert( z.message_tail, {utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', Periodical_origin) .. ' and ' .. utilities.wrap_style ('parameter', 'mailinglist')}, true )});
		end

		Periodical = A ['MailingList'];											-- error or no, set Periodical to |mailinglist= value because this template is {{cite mailing list}}
		Periodical_origin = A:ORIGIN('MailingList');
	end

	local ScriptPeriodical = A['ScriptPeriodical'];
	local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');

	-- web and news not tested for now because of 
	-- Wikipedia:Administrators%27_noticeboard#Is_there_a_semi-automated_tool_that_could_fix_these_annoying_&quot;Cite_Web&quot;_errors?
	if not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) then	-- 'periodical' templates require periodical parameter
	--	local p = {['journal'] = 'journal', ['magazine'] = 'magazine', ['news'] = 'newspaper', ['web'] = 'website'};	-- for error message
		local p = {['journal'] = 'journal', ['magazine'] = 'magazine'};			-- for error message
		if p[config.CitationClass]  then
			table.insert( z.message_tail, {utilities.set_message ('err_missing_periodical', {config.CitationClass, p[config.CitationClass]}, true)});
		end
	end

	local TransPeriodical =  A['TransPeriodical'];
	local TransPeriodical_origin =  A:ORIGIN ('TransPeriodical');

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) then
			if not utilities.in_array (Periodical_origin, {'website', 'mailinglist'}) then	-- {{citation}} does not render volume for these 'periodicals'
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		elseif utilities.is_set (ScriptPeriodical) then
			if 'script-website' ~= ScriptPeriodical_origin then					-- {{citation}} does not render volume for |script-website=
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		else
			Volume = A['Volume'];												-- and does for non-'periodical' cites
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_volume) then	-- render |volume= for cs1 according to the configuration settings
		Volume = A['Volume'];
	end	

	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) and utilities.in_array (Periodical_origin, {'journal', 'magazine', 'newspaper', 'periodical', 'work'}) or	-- {{citation}} renders issue for these 'periodicals'
			utilities.is_set (ScriptPeriodical) and utilities.in_array (ScriptPeriodical_origin, {'script-journal', 'script-magazine', 'script-newspaper', 'script-periodical', 'script-work'}) then -- and these 'script-periodicals'
				Issue = hyphen_to_dash (A['Issue']);
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_issue) then	-- conference &amp; map books do not support issue; {{citation}} listed here because included in settings table
		if not (utilities.in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical))) then
			Issue = hyphen_to_dash (A['Issue']);
		end
	end

	local Position = '';
	if not utilities.in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash (A['Pages']);	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = place_check (A['PublicationPlace'], A:ORIGIN('PublicationPlace'));
	local Place = place_check (A['Place'], A:ORIGIN('Place'));
	
	local PublisherName = A['PublisherName'];
	local PublisherName_origin = A:ORIGIN('PublisherName');
	if utilities.is_set (PublisherName) then
		local i = 0;
		PublisherName, i = utilities.strip_apostrophe_markup (PublisherName);	-- strip apostrophe markup so that metadata isn't contaminated; publisher is never italicized
		if i then																-- non-zero when markup was stripped so emit an error message
			table.insert( z.message_tail, {utilities.set_message ('err_apostrophe_markup', {PublisherName_origin}, true)});
		end
	end

	local Newsgroup = A['Newsgroup'];											-- TODO: strip apostrophe markup?
	local Newsgroup_origin = A:ORIGIN('Newsgroup');	

	if 'newsgroup' == config.CitationClass then
		if utilities.is_set (PublisherName) then								-- general use parameter |publisher= not allowed in cite newsgroup
			local error_text, error_state = utilities.set_message ('err_parameter_ignored', {PublisherName_origin}, true);
			if utilities.is_set (error_text) then
				table.insert( z.message_tail, {error_text, error_state} );
			end				
		end

		PublisherName = nil;													-- ensure that this parameter is unset for the time being; will be used again after COinS
	end

	local UrlAccess = is_valid_parameter_value (A['UrlAccess'], A:ORIGIN('UrlAccess'), cfg.keywords_lists['url-access'], nil);
		if not utilities.is_set (URL) and utilities.is_set (UrlAccess) then
			UrlAccess = nil;
			table.insert( z.message_tail, { utilities.set_message ( 'err_param_access_requires_param', {'url'}, true ) } );
		end
		
	local ChapterUrlAccess = is_valid_parameter_value (A['ChapterUrlAccess'], A:ORIGIN('ChapterUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (ChapterURL) and utilities.is_set (ChapterUrlAccess) then
		ChapterUrlAccess = nil;
		table.insert( z.message_tail, { utilities.set_message ( 'err_param_access_requires_param', {A:ORIGIN('ChapterUrlAccess'):gsub ('%-access', '')}, true ) } );
	end

	local MapUrlAccess = is_valid_parameter_value (A['MapUrlAccess'], A:ORIGIN('MapUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (A['MapURL']) and utilities.is_set (MapUrlAccess) then
		MapUrlAccess = nil;
		table.insert( z.message_tail, { utilities.set_message ( 'err_param_access_requires_param', {'map-url'}, true ) } );
	end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local Agency = A['Agency'];

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = is_valid_parameter_value (A['IgnoreISBN'], A:ORIGIN('IgnoreISBN'), cfg.keywords_lists['yes_true_y'], nil);
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local Quote = A['Quote'];
	local QuotePage = A['QuotePage'];
	local QuotePages = A['QuotePages'];
	local ScriptQuote = A['ScriptQuote'];
	local TransQuote = A['TransQuote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURL_origin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = is_valid_parameter_value (A['LastAuthorAmp'], A:ORIGIN('LastAuthorAmp'), cfg.keywords_lists['yes_true_y'], nil);

	local no_tracking_cats = is_valid_parameter_value (A['NoTracking'], A:ORIGIN('NoTracking'), cfg.keywords_lists['yes_true_y'], nil);
	if 'nocat' == A:ORIGIN('NoTracking') then				
		utilities.set_message ('maint_nocat');									-- this one so that we get the message; see main categorization at end of citation0()
	end
	
	--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = is_valid_parameter_value (A['DF'], A:ORIGIN('DF'), cfg.keywords_lists['df'], '');
	if not utilities.is_set (DF) then
		DF = cfg.global_df;														-- local |df= if present overrides global df set by {{use xxx date}} template
	end

	local sepc;																	-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref = A['Ref'];
	if 'harv' == Ref then
		utilities.set_message ('maint_ref_harv');								-- add maint cat to identify templates that have this now-extraneous param value
	elseif not utilities.is_set (Ref) then
		Ref = 'harv';															-- set as default when not set externally
	end
	
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], Ref, config.CitationClass);
	use_lowercase = ( sepc == ',' ); 											-- used to control capitalization for certain static text

	-- check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not utilities.is_set (no_tracking_cats) then								-- ignore if we are already not going to categorize this page
		if utilities.in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _, v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end
																				-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	utilities.select_one (args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'err_redundant_parameters');	-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, Pages, At);

	local NoPP = is_valid_parameter_value (A['NoPP'], A:ORIGIN('NoPP'), cfg.keywords_lists['yes_true_y'], nil);

	if utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- both |publication-place= and |place= (|location=) allowed if different
		utilities.add_prop_cat ('location test');								-- add property cat to evaluate how often PublicationPlace and Place are used together
		if PublicationPlace == Place then
			Place = '';															-- unset; don't need both if they are the same
		end
	elseif not utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- when only |place= (|location=) is set ...
		PublicationPlace = Place;												-- promote |place= (|location=) to |publication-place
	end

	if PublicationPlace == Place then Place = ''; end							-- don't need both if they are the same
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia= and |title= then map |title= to |article= and |encyclopedia= to |title=
		|encyclopedia= and |article= then map |encyclopedia= to |title=

		|trans-title= maps to |trans-chapter= when |title= is re-mapped
		|url= maps to |chapter-url= when |title= is remapped
	
	All other combinations of |encyclopedia=, |title=, and |article= are not modified
	
	]]

	local Encyclopedia = A['Encyclopedia'];										-- used as a flag by this module and by ~/COinS

	if utilities.is_set (Encyclopedia) then										-- emit error message when Encyclopedia set but template is other than {{cite encyclopedia}} or {{citation}}
		if 'encyclopaedia' ~= config.CitationClass and 'citation' ~= config.CitationClass then
			table.insert (z.message_tail, {utilities.set_message ('err_parameter_ignored', {A:ORIGIN ('Encyclopedia')}, true)});
			Encyclopedia = nil;													-- unset because not supported by this template
		end
	end

	if ('encyclopaedia' == config.CitationClass) or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Periodical) and utilities.is_set (Encyclopedia) then	-- when both set emit an error
			table.insert (z.message_tail, {utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', A:ORIGIN ('Encyclopedia')) .. ' and ' .. utilities.wrap_style ('parameter', Periodical_origin)}, true )});
		end

		if utilities.is_set (Encyclopedia) then
			Periodical = Encyclopedia;											-- error or no, set Periodical to Encyclopedia; allow periodical without encyclopedia
			Periodical_origin = A:ORIGIN ('Encyclopedia');
		end

		if utilities.is_set (Periodical) then									-- Periodical is set when |encyclopedia= is set
			if utilities.is_set (Title) or utilities.is_set (ScriptTitle) then
				if not utilities.is_set (Chapter) then
					Chapter = Title;											-- |encyclopedia= and |title= are set so map |title= to |article= and |encyclopedia= to |title=
					ScriptChapter = ScriptTitle;
					ScriptChapter_origin = A:ORIGIN('ScriptTitle')
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterURL_origin = A:ORIGIN('URL')

					ChapterUrlAccess = UrlAccess;

					if not utilities.is_set (ChapterURL) and utilities.is_set (TitleLink) then
						Chapter = utilities.make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			elseif utilities.is_set (Chapter) then								-- |title= not set
				Title = Periodical;												-- |encyclopedia= set and |article= set so map |encyclopedia= to |title=
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if utilities.is_set (A['Number']) then									-- cite techreport uses 'number', which other citations alias to 'issue'
			if not utilities.is_set (ID) then									-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'id') .. ' and ' .. utilities.wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if utilities.is_set (BookTitle) then
			Chapter = Title;
			Chapter_origin = 'title';
	--		ChapterLink = TitleLink;											-- |chapter-link= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			URL_origin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			TransChapter_origin = TransTitle_origin;
			Title = BookTitle;
			Format = '';
	--		TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		if utilities.is_set (Chapter) then
			table.insert( z.message_tail, { utilities.set_message ( 'err_redundant_parameters', {utilities.wrap_style ('parameter', 'map') .. ' and ' .. utilities.wrap_style ('parameter', Chapter_origin)}, true ) } );	-- add error message
		end
		Chapter = A['Map'];
		Chapter_origin = A:ORIGIN('Map');
		ChapterURL = A['MapURL'];
		ChapterURL_origin = A:ORIGIN('MapURL');
		TransChapter = A['TransMap'];
		ScriptChapter = A['ScriptMap']
		ScriptChapter_origin = A:ORIGIN('ScriptMap')

		ChapterUrlAccess = MapUrlAccess;
		ChapterFormat = A['MapFormat'];

		Cartography = A['Cartography'];
		if utilities.is_set ( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if utilities.is_set ( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local SeriesLink = A['SeriesLink'];

		SeriesLink = link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wiki-markup in |series-link= or wiki-markup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if utilities.is_set (Network) then table.insert(n, Network); end
		if utilities.is_set (Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if utilities.is_set (Season) and utilities.is_set (SeriesNumber) then	-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { utilities.set_message ( 'err_redundant_parameters', {utilities.wrap_style ('parameter', 'season') .. ' and ' .. utilities.wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if utilities.is_set (Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if utilities.is_set (SeriesNumber) then table.insert(s, wrap_msg ('seriesnum', SeriesNumber, use_lowercase)); end
			if utilities.is_set (Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ScriptChapter_origin = A:ORIGIN('ScriptTitle');
			ChapterLink = TitleLink;											-- alias |episode-link=
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if utilities.is_set (ChapterLink) and not utilities.is_set (ChapterURL) then	-- link but not URL
				Chapter = utilities.make_wikilink (ChapterLink, Chapter);
			elseif utilities.is_set (ChapterLink) and utilities.is_set (ChapterURL) then	-- if both are set, URL links episode;
				Series = utilities.make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if utilities.is_set (Series) and utilities.is_set (SeriesLink) then
				Series = utilities.make_wikilink (SeriesLink, Series);
			end
			Series = utilities.wrap_style ('italic-title', Series);				-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- handle type parameter for those CS1 citations that have default values
	if utilities.in_array (config.CitationClass, {&quot;AV-media-notes&quot;, &quot;interview&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if utilities.is_set (Degree) and &quot;Thesis&quot; == TitleType then				-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if utilities.is_set (TitleType) then										-- if type parameter is specified
		TitleType = utilities.substitute ( cfg.messages['type'], TitleType);	-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging

	if not utilities.is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not utilities.is_set (Date) and utilities.is_set (PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val = AccessDate, name = A:ORIGIN ('AccessDate')},
			['archive-date'] = {val = ArchiveDate, name = A:ORIGIN ('ArchiveDate')},
			['date'] = {val = Date, name = Date_origin},
			['doi-broken-date'] = {val = DoiBroken, name = A:ORIGIN ('DoiBroken')},
			['pmc-embargo-date'] = {val = Embargo, name = A:ORIGIN ('Embargo')},
			['lay-date'] = {val = LayDate, name = A:ORIGIN ('LayDate')},
			['publication-date'] = {val = PublicationDate, name = A:ORIGIN ('PublicationDate')},
			['year'] = {val = Year, name = A:ORIGIN ('Year')},
			};

		local error_list = {};
		anchor_year, Embargo = validation.dates(date_parameters_list, COinS_date, error_list);

-- start temporary Julian / Gregorian calendar uncertainty categorization
		if COinS_date.inter_cal_cat then
			utilities.add_prop_cat ('jul_greg_uncertainty');
		end
-- end temporary Julian / Gregorian calendar uncertainty categorization

		if utilities.is_set (Year) and utilities.is_set (Date) then				-- both |date= and |year= not normally needed; 
			local mismatch = validation.year_date_check (Year, Date);
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				table.insert (error_list, '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;year= / &amp;#124;date= mismatch&lt;/code&gt;');
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				utilities.set_message ('maint_date_year');						-- add a maint cat
			end
		end
		
		if 0 == #error_list then												-- error free dates only; 0 when error_list is empty
			local modified = false;												-- flag
			
			if utilities.is_set (DF) then										-- if we need to reformat dates
				modified = validation.reformat_dates (date_parameters_list, DF);	-- reformat to DF format, use long month names if appropriate
			end

			if true == validation.date_hyphen_to_dash (date_parameters_list) then	-- convert hyphens to dashes where appropriate
				modified = true;
				utilities.set_message ('maint_date_format');					-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language,
	-- uncomment the next three lines.  Not supported by en.wiki (for obvious reasons)
	-- set validation.date_name_xlate() second argument to true to translate English digits to local digits (will translate ymd dates)
	--		if validation.date_name_xlate (date_parameters_list, false) then
	--			modified = true;
	--		end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				LayDate = date_parameters_list['lay-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end
		else
			table.insert (z.message_tail, {utilities.set_message ('err_bad_date', {utilities.make_sep_list (#error_list, error_list)}, true)});	-- add this error message
		end
	end	-- end of do

	local ID_list_coins = identifiers.extract_ids (args);						-- gets identifiers and their values from args; this list used for COinS and source for build_id_list()
		if utilities.is_set (DoiBroken) and not ID_list_coins['DOI'] then
			table.insert (z.message_tail, {utilities.set_message ('err_doibroken_missing_doi', A:ORIGIN('DoiBroken'))});
		end
	local ID_access_levels = identifiers.extract_id_access_levels (args, ID_list_coins);
	local ID_list = identifiers.build_id_list (ID_list_coins, {IdAccessLevels = ID_access_levels, DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo = Embargo, Class = Class});	-- render identifiers
	
	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite ssrn}}, before generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then
		if not utilities.is_set (ID_list_coins[config.CitationClass:upper()]) then 	-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp; |citeseerx= required for their templates
			table.insert (z.message_tail, {utilities.set_message ('err_' .. config.CitationClass .. '_missing', {}, true)});	-- add error message
		end

		Periodical = ({['arxiv'] = 'arXiv', ['biorxiv'] = 'bioRxiv', ['citeseerx'] = 'CiteSeerX', ['ssrn'] = 'Social Science Research Network'})[config.CitationClass];
	end

	-- Link the title of the work if no |url= was provided, but we have a |pmc= or a |doi= with |doi-access=free

	if config.CitationClass == &quot;journal&quot; and not utilities.is_set (URL) and not utilities.is_set (TitleLink) and not utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) then -- TODO: remove 'none' once existing citations have been switched to 'off', so 'none' can be used as token for &quot;no title&quot; instead
    		if 'none' ~= cfg.keywords_xlate[auto_select] then -- if auto-linking not disabled
 	 		if identifiers.auto_link_urls[auto_select] then -- manual selection
		 		URL = identifiers.auto_link_urls[auto_select]; -- set URL to be the same as identifier's external link
 				URL_origin = cfg.id_handlers[auto_select:upper()].parameters[1]; -- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['pmc'] then -- auto-select PMC
				URL = identifiers.auto_link_urls['pmc']; -- set URL to be the same as the PMC external link if not embargoed
				URL_origin = cfg.id_handlers['PMC'].parameters[1]; -- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['doi'] then -- auto-select DOI
				URL = identifiers.auto_link_urls['doi'];
				URL_origin = cfg.id_handlers['DOI'].parameters[1];
			end
 	 	end

		if utilities.is_set (URL) and utilities.is_set (AccessDate) then		-- access date requires |url=; identifier-created URL is not |url=
			table.insert( z.message_tail, { utilities.set_message ( 'err_accessdate_missing_url', {}, true ) } );	-- add an error message
			AccessDate = '';													-- unset
		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not utilities.is_set (Title) and not utilities.is_set (TransTitle) and not utilities.is_set (ScriptTitle) then	-- has special case for cite episode
		table.insert( z.message_tail, { utilities.set_message ( 'err_citation_missing_title', {'episode' == config.CitationClass and 'series' or 'title'}, true ) } );
	end

	if utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) and
			utilities.in_array (config.CitationClass, {'journal', 'citation'}) and
			(utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and
			('journal' == Periodical_origin or 'script-journal' == ScriptPeriodical_origin) then	-- special case for journal cites
				Title = '';														-- set title to empty string
				utilities.set_message ('maint_untitled');						-- add maint cat
	end

	check_for_url ({															-- add error message when any of these parameters hold a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[Periodical_origin] = Periodical,
		[PublisherName_origin] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Chapter) and utilities.is_set (Title) and utilities.is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = metadata.COinS({
		['Periodical'] = utilities.strip_apostrophe_markup (Periodical),		-- no markup in the metadata
		['Encyclopedia'] = Encyclopedia,										-- just a flag; content ignored by ~/COinS
		['Chapter'] = metadata.make_coins_title (coins_chapter, ScriptChapter),	-- Chapter and ScriptChapter stripped of bold / italic wiki-markup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = metadata.make_coins_title (coins_title, ScriptTitle),		-- Title and ScriptTitle stripped of bold / italic wiki-markup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Quarter'] = COinS_date.rftquarter,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = coins_pages or metadata.get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName or Newsgroup,							-- any apostrophe markup already removed from PublisherName
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list_coins,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, and {{cite ssrn}} AFTER generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, CiteSeerX, or ssrn now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass and utilities.is_set (Newsgroup) then
		PublisherName = utilities.substitute (cfg.messages['newsgroup'], external_link( 'news:' .. Newsgroup, Newsgroup, Newsgroup_origin, nil ));
	end

	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local control = { 
			format = NameListStyle,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_names (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if utilities.is_set (Editors) then
				Editors, editor_etal = name_has_etal (Editors, editor_etal, false, 'editors');	-- find and remove variations on et al.
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
				end
				EditorCount = 2;												-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum , interviewer_etal = get_display_names (A['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal);
			Interviewers = list_people (control, interviewers_list, interviewer_etal);
		end
		do																		-- now do translators
			control.maximum , translator_etal = get_display_names (A['DisplayTranslators'], #t, 'translators', translator_etal);
			Translators = list_people (control, t, translator_etal);
		end
		do																		-- now do contributors
			control.maximum , contributor_etal = get_display_names (A['DisplayContributors'], #c, 'contributors', contributor_etal);
			Contributors = list_people (control, c, contributor_etal);
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_names (A['DisplayAuthors'], #a, 'authors', author_etal);

			last_first_list = list_people(control, a, author_etal);

			if utilities.is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors');	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if utilities.is_set (Authors) and utilities.is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
	-- an error message if the associated URL is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not utilities.is_set (URL) then
		if utilities.in_array (config.CitationClass, {&quot;web&quot;, &quot;podcast&quot;, &quot;mailinglist&quot;}) or		-- |url= required for cite web, cite podcast, and cite mailinglist
			('citation' == config.CitationClass and ('website' == Periodical_origin or 'script-website' == ScriptPeriodical_origin)) then	-- and required for {{citation}} with |website= or |script-website=
				table.insert( z.message_tail, { utilities.set_message ( 'err_cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if utilities.is_set (AccessDate) and not utilities.is_set (ChapterURL) then		-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { utilities.set_message ( 'err_accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURL_origin, OriginalFormat, OriginalAccess;
	UrlStatus = UrlStatus:lower();												-- used later when assembling archived text
	if utilities.is_set ( ArchiveURL ) then
		if utilities.is_set (ChapterURL) then 									-- if chapter-url= is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURL_origin = ChapterURL_origin;								-- name of |chapter-url= parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=

			if 'live' ~= UrlStatus then
				ChapterURL = ArchiveURL											-- swap-in the archive's URL
				ChapterURL_origin = A:ORIGIN('ArchiveURL')						-- name of |archive-url= parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived URLs
			end
		elseif utilities.is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURL_origin = URL_origin;									-- name of URL parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;

			if 'live' ~= UrlStatus then											-- if URL set then |archive-url= applies to it
				URL = ArchiveURL												-- swap-in the archive's URL
				URL_origin = A:ORIGIN('ArchiveURL')								-- name of archive URL parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived URLs
			end
 		end
	end

	if utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) then
			local chap_param;
			if utilities.is_set (Chapter) then									-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif utilities.is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif utilities.is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif utilities.is_set (ScriptChapter) then
				chap_param = ScriptChapter_origin;
			else utilities.is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if utilities.is_set (chap_param) then								-- if we found one
				table.insert( z.message_tail, { utilities.set_message ( 'err_chapter_ignored', {chap_param}, true ) } );	-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if utilities.is_set (Contribution) and 0 &lt; #c then						-- if this is a contribution with contributor(s)
			if utilities.in_array (Contribution:lower(), cfg.keywords_lists.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, ScriptChapter_origin, Chapter, Chapter_origin, TransChapter, TransChapter_origin, ChapterURL, ChapterURL_origin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if utilities.is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and utilities.is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter .. sepc .. ' ';
		elseif utilities.is_set (ChapterFormat) then							-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title
	local plain_title = false;
	local accept_title;
	Title, accept_title = utilities.has_accept_as_written (Title, true);		-- remove accept-this-as-written markup when it wraps all of &lt;Title&gt;
	if accept_title and ('' == Title) then										-- only support forced empty for now &quot;(())&quot;
		Title = cfg.messages['notitle'];										-- replace by predefined &quot;No title&quot; message
			-- TODO: utilities.set_message ( 'err_redundant_parameters', ...);	-- issue proper error message instead of muting	 
			ScriptTitle = '';													-- just mute for now	 
			TransTitle = '';													-- just mute for now
 		plain_title = true;														-- suppress text decoration for descriptive title
		utilities.set_message ('maint_untitled');								-- add maint cat
	end

	if not accept_title then -- &lt;Title&gt; not wrapped in accept-as-written markup
		if '...' == Title:sub (-3) then											-- if ellipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%' .. sepc .. '$', '');			-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end

		if utilities.is_set (ArchiveURL) and is_archived_copy (Title) then
			utilities.set_message ('maint_archived_copy');						-- add maintenance category before we modify the content of Title
		end

		if is_generic_title (Title) then
			table.insert (z.message_tail, {utilities.set_message ( 'err_generic_title', {}, true ) } );	-- set an error message
		end
	end

	if (not plain_title) and (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) or
		('map' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)))) then		-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from module provided quote marks
			Title = utilities.wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle, 'script-title');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
			TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );
	elseif plain_title or ('report' == config.CitationClass) then								-- no styling for cite report and descriptive titles (otherwise same as above)
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = utilities.wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if utilities.is_set (TransTitle) then
		if utilities.is_set (Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. utilities.set_message ( 'err_trans_missing_title', {'title'} );
		end
	end

	if utilities.is_set (Title) then											-- TODO: is this the right place to be making Wikisource URLs?
		if utilities.is_set (TitleLink) and utilities.is_set (URL) then
			table.insert( z.message_tail, { utilities.set_message ( 'err_wikilink_in_url', {}, true ) } );	-- set an error message because we can't have both
			TitleLink = '';														-- unset
		end
		
		if not utilities.is_set (TitleLink) and utilities.is_set (URL) then
			Title = external_link (URL, Title, URL_origin, UrlAccess) .. TransTitle .. TransError .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif utilities.is_set (TitleLink) and not utilities.is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = utilities.make_wikilink (TitleLink, Title) .. TransTitle .. TransError;
			end
		else
			local ws_url, ws_label, L;											-- Title has italic or quote markup by the time we get here which causes is_wikilink() to return 0 (not a wikilink)
			ws_url, ws_label, L = wikisource_url_make (Title:gsub('[\'&quot;](.-)[\'&quot;]', '%1'));	-- make ws URL from |title= interwiki link (strip italic or quote markup); link portion L becomes tooltip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = Title .. TransTitle .. TransError;
			end
		end
	else
		Title = TransTitle .. TransError;
	end

	if utilities.is_set (Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if utilities.is_set (Conference) then
		if utilities.is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURL_origin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif utilities.is_set (ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURL_origin, nil );
	end

	if not utilities.is_set (Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if utilities.is_set (Minutes) then
			if utilities.is_set (Time) then
				table.insert( z.message_tail, { utilities.set_message ( 'err_redundant_parameters', {utilities.wrap_style ('parameter', 'minutes') .. ' and ' .. utilities.wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if utilities.is_set (Time) then
				local TimeCaption = A['TimeCaption']
				if not utilities.is_set (TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = utilities.is_set (At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = utilities.is_set (Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Sections = A['Sections'];											-- Section (singular) is an alias of Chapter so set earlier
		local Inset = A['Inset'];
		
		if utilities.is_set ( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if utilities.is_set ( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif utilities.is_set ( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if utilities.is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc.
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	Others = utilities.is_set (Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if utilities.is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if utilities.is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	TitleNote = utilities.is_set (TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if utilities.is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			utilities.set_message ('maint_extra_text', 'edition');				-- add maint cat
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = utilities.is_set (Series) and wrap_msg ('series', {sepc, Series}) or &quot;&quot;;	-- not the same as SeriesNum
	OrigDate = utilities.is_set (OrigDate) and wrap_msg ('origdate', OrigDate) or '';
	Agency = utilities.is_set (Agency) and wrap_msg ('agency', {sepc, Agency}) or &quot;&quot;;
	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	Via = utilities.is_set (Via) and  wrap_msg ('via', Via) or '';

	if utilities.is_set (AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = utilities.substitute (retrv_text, AccessDate);				-- add retrieved text

		AccessDate = utilities.substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if utilities.is_set (ID) then ID = sepc .. &quot; &quot; .. ID; end
   	if &quot;thesis&quot; == config.CitationClass and utilities.is_set (Docket) then
		ID = sepc .. &quot; Docket &quot; .. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and utilities.is_set (Docket) then		-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	if utilities.is_set (URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URL_origin, UrlAccess );
	end

	if utilities.is_set (Quote) or utilities.is_set (TransQuote) or utilities.is_set (ScriptQuote) then

		if utilities.is_set (Quote) then
			if Quote:sub(1, 1) == '&quot;' and Quote:sub(-1, -1) == '&quot;' then			-- if first and last characters of quote are quote marks
				Quote = Quote:sub(2, -2);										-- strip them off
			end
		end

		Quote = utilities.wrap_style ('quoted-text', Quote ); 	-- wrap in &lt;q&gt;...&lt;/q&gt; tags
	
		if utilities.is_set (ScriptQuote) then
			Quote = script_concatenate (Quote, ScriptQuote, 'script-quote'); -- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after quote is wrapped
		end

		if utilities.is_set (TransQuote) then
			if TransQuote:sub(1, 1) == '&quot;' and TransQuote:sub(-1, -1) == '&quot;' then -- if first and last characters of |trans-quote are quote marks
				TransQuote = TransQuote:sub(2, -2); -- strip them off
			end
			Quote = Quote .. &quot; &quot; .. utilities.wrap_style ('trans-quoted-title', TransQuote );
		end

		if utilities.is_set (QuotePage) or utilities.is_set (QuotePages) then	-- add page prefix
			local quote_prefix = '';
			if utilities.is_set (QuotePage) then
				if not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePage}), '', '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePage}), '', '', '';
				end
			elseif utilities.is_set (QuotePages) then
				if tonumber(QuotePages) ~= nil and not NoPP then				-- if only digits, assume single page
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePages}), '', '';
				elseif not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['pp-prefix'], {sepc, QuotePages}), '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePages}), '', '';
				end
			end
                        
			Quote = quote_prefix .. &quot;: &quot; .. Quote;
		else
			Quote = sepc .. &quot; &quot; .. Quote;
		end

		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if utilities.is_set (ArchiveURL) then
		local arch_text;
		if not utilities.is_set (ArchiveDate) then
			ArchiveDate = utilities.set_message ('err_archive_missing_date');
		end
		if &quot;live&quot; == UrlStatus then
			arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. utilities.substitute ( cfg.messages['archived-live'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil ) .. ArchiveFormat, ArchiveDate } );
			if not utilities.is_set (OriginalURL) then
				Archived = Archived .. &quot; &quot; .. utilities.set_message ('err_archive_missing_url');							   
			end
		elseif utilities.is_set (OriginalURL) then								-- UrlStatus is empty, 'dead', 'unfit', 'usurped', 'bot: unknown'
			if utilities.in_array (UrlStatus, {'unfit', 'usurped', 'bot: unknown'}) then
				arch_text = cfg.messages['archived-unfit'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. &quot; &quot; .. arch_text .. ArchiveDate;				-- format already styled
				if 'bot: unknown' == UrlStatus then
					utilities.set_message ('maint_bot_unknown');				-- and add a category if not already added
				else
					utilities.set_message ('maint_unfit');						-- and add a category if not already added
				end
			else																-- UrlStatus is empty, 'dead'
				arch_text = cfg.messages['archived-dead'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. &quot; &quot; .. utilities.substitute ( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURL_origin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else																	-- OriginalUrl not set
			arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. utilities.substitute ( arch_text, 
				{ utilities.set_message ('err_archive_missing_url'), ArchiveDate } );
		end
	elseif utilities.is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if utilities.is_set (LayURL) then
		if utilities.is_set (LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if utilities.is_set (LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. utilities.safe_for_italics (LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif utilities.is_set (LayFormat) then									-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if utilities.is_set (Transcript) then
		if utilities.is_set (TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURL_origin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif utilities.is_set (TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURL_origin, nil );
	end

	local Publisher;
	if utilities.is_set (PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if utilities.is_set (PublisherName) then
		if utilities.is_set (PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif utilities.is_set (PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical)) then
		if utilities.is_set (Title) or utilities.is_set (TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		else 
			Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		end
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then									-- cite speech only
		TitleNote = &quot; (Speech)&quot;;												-- annotate the citation
		if utilities.is_set (Periodical) then									-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if utilities.is_set (Conference) then								-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;							-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
		if utilities.is_set (Others) then Others = safe_join ({Others, sepc .. &quot; &quot;}, sepc) end		-- add terminal punctuation &amp; space; check for dup sepc; TODO why do we need to do this here?
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (Periodical) then		-- special cases for book cites
		if utilities.is_set (Contributors) then									-- when we are citing foreword, preface, introduction, etc.
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if utilities.is_set (Chapter) then										-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif utilities.is_set (Periodical) then								-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon;
	if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then	-- special case for cite AV media &amp; cite episode position transcript
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, Lay, Quote }, sepc );
	else
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, Lay, Quote }, sepc );
	end
	
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if utilities.is_set (Date) then
		if utilities.is_set (Authors) or utilities.is_set (Editors) then		-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date .. &quot;)&quot; .. OrigDate .. sepc .. &quot; &quot;;				-- in parentheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon, -1, -1) == sepc) then						-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigDate;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigDate;							-- Date begins with sepc
			end
		end
	end	
	if utilities.is_set (Authors) then
		if (not utilities.is_set (Date)) then									-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if utilities.is_set (Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then
					in_text = in_text:lower()									-- lowercase for cs2
				end
			end
			if EditorCount &lt;= 1 then
				post_text = &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot;;				-- be consistent with no-author, no-date case
			else
				post_text = &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot;;
			end
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Contributors) then									-- book cite and we're citing the intro, preface, etc.
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if utilities.is_set (Editors) and utilities.is_set (Date) then		-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not utilities.is_set (Date)) then								-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif utilities.is_set (Editors) then
		if utilities.is_set (Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if utilities.is_set (PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc ); 								--Deals with italics, spaces, etc.
		text = text:sub(1, -sepc:len() - 1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if utilities.is_set (config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = string.format ('%s %s %s', 'citation', config.CitationClass, utilities.is_set (Mode) and Mode or 'cs1');	-- class=citation required for blue highlight when used with |ref=
	else
		options.class = string.format ('%s %s', 'citation', utilities.is_set (Mode) and Mode or 'cs2');
	end
	
	if utilities.is_set (Ref) and 'none' ~= cfg.keywords_xlate[Ref:lower()] then
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			if #namelist &gt; 0 then												-- if there are names in namelist
				id = anchor_id (namelist, year);								-- go make the CITEREF anchor
			else
				id = '';														-- unset
			end
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;(.-)&lt;/span&gt;&quot;, &quot;%1&quot;):gsub(&quot;%b&lt;&gt;&quot;, &quot;&quot;)) &lt;= 2 then	-- remove &lt;span&gt; tags and other HTML-like markup; then get length of what remains
		z.error_categories = {};
		text = utilities.set_message ('err_empty_citation');
		z.message_tail = {};
	end
	
	local render = {};															-- here we collect the final bits for concatenation into the rendered citation

	if utilities.is_set (options.id) then										-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render, utilities.substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text}));	-- when |ref= is set
	else
		table.insert (render, utilities.substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text}));	-- all other cases
	end		

	table.insert (render, utilities.substitute (cfg.presentation['ocins'], {OCinSoutput}));	-- append metadata to the citation

	if 0 ~= #z.message_tail then
		table.insert (render, ' ');
		for i,v in ipairs( z.message_tail ) do
			if utilities.is_set (v[1]) then
				if i == #z.message_tail then
					table.insert (render, utilities.error_comment ( v[1], v[2] ));
				else
					table.insert (render, utilities.error_comment ( v[1] .. &quot;; &quot;, v[2] ));
				end
			end
		end
	end

	if 0 ~= #z.maintenance_cats then
		local maint_msgs = {};													-- here we collect all of the maint messages
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			local maint = {};													-- here we assemble a maintenence message
			table.insert (maint, v);											-- maint msg is the category name
			table.insert (maint, ' (');											-- open the link text
			table.insert (maint, utilities.make_wikilink (':Category:' .. v, 'link'));	-- add the link
			table.insert (maint, ')');											-- and close it
			table.insert (maint_msgs, table.concat (maint));					-- assemble new maint message and add it to the maint_msgs table
		end
		table.insert (render, utilities.substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs, ' ')));	-- wrap the group of maint message with proper presentation and save
	end
	
	if not no_tracking_cats then
		for _, v in ipairs( z.error_categories ) do
			table.insert (render, utilities.make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			table.insert (render, utilities.make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.properties_cats ) do								-- append properties categories
			table.insert (render, utilities.make_wikilink ('Category:' .. v));
		end
	elseif 'nocat' == A:ORIGIN('NoTracking') then								-- peculiar special case; can't track nocat without tracking nocat
		table.insert (render, utilities.make_wikilink ('Category:CS1 maint: nocat'));	-- hand-set this category because it is supposed to be temporary
	end

	return table.concat (render);	
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class, empty)
	local name = tostring (name);
	local state;
	local function state_test (state, name)										-- local function to do testing of state values
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			if empty then return nil; end										-- deprecated empty parameters are treated as unknowns
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
		return nil;
	end		

	if name:find ('#') then														-- # is a cs1|2 reserved character so parameters with # not permitted
		return nil;
	end

	if utilities.in_array (cite_class, whitelist.preprint_template_list ) then	-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[name];
		if true == state_test (state, name) then return true; end

		state = whitelist.preprint_arguments[cite_class][name];					-- look in the parameter-list for the template identified by cite_class
		if true == state_test (state, name) then return true; end

																				-- limited enumerated parameters list
		name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
		state = whitelist.limited_numbered_arguments[name];
		if true == state_test (state, name) then return true; end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates

	if utilities.in_array (cite_class, whitelist.unique_param_template_list) then 	-- experiment for template-specific parameters for templates that accept parameters from the basic argument list
		state = whitelist.unique_arguments[cite_class][name];					-- look in the template-specific parameter-lists for the template identified by cite_class
		if true == state_test (state, name) then return true; end
	end																			-- if here, fall into general validation
		
	state = whitelist.basic_arguments[name];									-- all other templates; all normal parameters allowed
	if true == state_test (state, name) then return true; end

																				-- all enumerated parameters allowed
	name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );												-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
	state = whitelist.numbered_arguments[name];
	if true == state_test (state, name) then return true; end

	return false;																-- not supported because not found or name is set to nil
end


--[=[-------------------------&lt; I N T E R _ W I K I _ C H E C K &gt;----------------------------------------------

check &lt;value&gt; for inter-language interwiki-link markup.  &lt;prefix&gt; must be a MediaWiki-recognized language
code.  when these values have the form (without leading colon):
	[[&lt;prefix&gt;:link|label]] return label as plain-text
	[[&lt;prefix&gt;:link]] return &lt;prefix&gt;:link as plain-text

return value as is else

]=]

local function inter_wiki_check (parameter, value)
	local prefix = value:match ('%[%[(%a+):');									-- get an interwiki prefix if one exists
	local _;
	
	if prefix and cfg.inter_wiki_map[prefix:lower()] then						-- if prefix is in the map, needs preceding colon so
		table.insert( z.message_tail, {utilities.set_message ('err_bad_paramlink', parameter)});	-- emit an error message
		_, value, _ = utilities.is_wikilink (value);							-- extract label portion from wikilink
	end
	return value;
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe.  There are two tests made:
	{{cite ... |title=Title access-date=2016-03-17}}	-- the first parameter has a value and whitespace separates that value from the missing pipe parameter name
	{{cite ... |title=access-date=2016-03-17}}			-- the first parameter has no value (whitespace after the first = is trimmed by MediaWiki)
cs1|2 shares some parameter names with XML/HTML attributes: class=, title=, etc.  To prevent false positives XML/HTML
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (parameter, value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove XML/HTML tags because attributes: class=, title=, etc.

	capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then										-- if the capture is a valid parameter name
		table.insert( z.message_tail, {utilities.set_message ('err_missing_pipe', parameter)});
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ P U N C T &gt;--------------------------------------

look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_punc (param, value)
	if 'number' == type (param) then
		return;
	end
	
	param = param:gsub ('%d+', '#');											-- enumerated name-list mask params allow terminal punct; normalize 
	if cfg.punct_skip[param] then
		return;																	-- parameter name found in the skip table so done
	end
	
	if value:match ('[,;:]$') then
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
end


--[[--------------------------&lt; C I T A T I O N &gt;--------------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

local function citation(frame)
	Frame = frame;																-- save a copy in case we need to display an error message in preview mode
	local pframe = frame:getParent()
	local styles;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		styles = 'Module:Citation/CS1/sandbox/styles.css';
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
		styles = 'Module:Citation/CS1/styles.css';
	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the selected cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text, error_state;

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do											-- get parameters from the {{#invoke}} frame
		config[k] = v;
	--	args[k] = v;															-- crude debug support that allows us to render a citation from module {{#invoke:}}; skips parameter validation; TODO: keep?
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	local empty_unknowns = {};													-- sequence table to hold empty unknown params for error message listing
	for k, v in pairs( pframe.args ) do											-- get parameters from the parent (template) frame
		v = mw.ustring.gsub (v, '^%s*(.-)%s*$', '%1');							-- trim leading/trailing whitespace; when v is only whitespace, becomes empty string
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = utilities.set_message ( 'err_text_ignored', {v}, true );
					end
				elseif validate( k:lower(), config.CitationClass ) then 
					error_text, error_state = utilities.set_message ( 'err_parameter_ignored_suggest', {k, k:lower()}, true );	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no capture in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = utilities.substitute (param, capture);		-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text, error_state = utilities.set_message ('err_parameter_ignored_suggest', {k, param}, true);	-- set the suggestion error message
							else
								error_text, error_state = utilities.set_message ( 'err_parameter_ignored', {param}, true );	-- suggested param not supported by this template
								v = '';											-- unset
							end
						end
					end
					if not utilities.is_set (error_text) then					-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = utilities.set_message ( 'err_parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = utilities.set_message ( 'err_parameter_ignored', {k}, true );
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end

			args[k] = v;														-- save this parameter and its value

		elseif not utilities.is_set (v) then									-- for empty parameters
			if not validate (k, config.CitationClass, true) then				-- is this empty parameter a valid parameter
				table.insert (empty_unknowns, utilities.wrap_style ('parameter', k));	-- format for error message and add to the list
			end
																				-- crude debug support that allows us to render a citation from module {{#invoke:}} TODO: keep?
	--	elseif args[k] ~= nil or (k == 'postscript') then						-- when args[k] has a value from {{#invoke}} frame (we don't normally do that)
	--		args[k] = v;														-- overwrite args[k] with empty string from pframe.args[k] (template frame); v is empty string here
		end																		-- not sure about the postscript bit; that gets handled in parameter validation; historical artifact?
	end	

	if 0 ~= #empty_unknowns then												-- create empty unknown error message
		table.insert (z.message_tail, {utilities.set_message ('err_param_unknown_empty', {
			1 == #empty_unknowns and '' or 's',
			utilities.make_sep_list (#empty_unknowns, empty_unknowns)
			}, true )});
	end

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);											-- look for invisible characters
		end
		has_extraneous_punc (k, v);												-- look for extraneous terminal punctuation in parameter values
		missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?
		args[k] = inter_wiki_check (k, v);										-- when language interwiki-linked parameter missing leading colon replace with wiki-link label
	end

	return table.concat ({citation0( config, args), frame:extensionTag ('templatestyles', '', {src=styles})});
end

--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {citation = citation};</text>
      <sha1>b6pgic86ku87oycir87o8u0a3hnesxk</sha1>
    </revision>
    <revision>
      <id>4735</id>
      <parentid>4734</parentid>
      <timestamp>2020-10-10T14:29:32Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4735</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="204282" sha1="p3s12cw5ycqpcgd4av6an8o035pnr5p" xml:space="preserve">
require('Module:No globals');

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------

each of these counts against the Lua upvalue limit

]]

local validation;																-- functions in Module:Citation/CS1/Date_validation

local utilities;																-- functions in Module:Citation/CS1/Utilities
local z ={};																	-- table of tables in Module:Citation/CS1/Utilities

local identifiers;																-- functions and tables in Module:Citation/CS1/Identifiers
local metadata;																	-- functions in Module:Citation/CS1/COinS
local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

declare variables here that have page-wide scope that are not brought in from other modules; that are created here and used here

]]

local added_deprecated_cat;														-- Boolean flag so that the category is added only once
local added_vanc_errs;															-- Boolean flag so we only emit one Vancouver error / category

local Frame;																	-- holds the module's frame table


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if utilities.is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a Boolean declared in page scope variables above

]]

local function add_vanc_error (source)
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { utilities.set_message ( 'err_vancouver', {source}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a URI scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of TLDs: https://www.iana.org/domains/root/db

RFC 952 (modified by RFC 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the TLD.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a URL with a scheme) will be stripped
here.  Perhaps not necessary but retained in case it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ASCII characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the TLD) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and TLD or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%w]') then											-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at Wikisource
		return false;
	end

	local patterns = {															-- patterns that look like URLs
		'%f[%w][%w][%w%-]+[%w]%.%a%a+$',										-- three or more character hostname.hostname or hostname.tld
		'%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$',									-- internationalized domain name with ACE prefix
		'%f[%a][qxz]%.com$',													-- assigned one character .com hostname (x.com times out 2015-12-10)
		'%f[%a][iq]%.net$',														-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		'%f[%w][%w]%.%a%a$',													-- one character hostname and ccTLD (2 chars)
		'%f[%w][%w][%w]%.%a%a+$',												-- two character hostname and TLD
		'^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?',								-- IPv4 address
		}

	for _, pattern in ipairs (patterns) do										-- loop through the patterns list
		if domain:match (pattern) then
			return true;														-- if a match then we think that this thing that purports to be a URL is a URL
		end
	end

	for _, d in ipairs ({'cash', 'company', 'today', 'org'}) do					-- look for single letter second level domain names for these top level domains
		if domain:match ('%f[%w][%w]%.' .. d) then
			return true
		end
	end
	return false;																-- no matches, we don't know what this thing is
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a URL appear to be a valid URL; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if utilities.is_set (scheme) then											-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when URL is protocol-relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a URL into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following TLD) (if any) and any path(/), query(?) or fragment(#).

If protocol-relative URL, return nil scheme and domain else return nil for both scheme and domain.

When not protocol-relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Any URL that does not have news: scheme must have authority indicator (//).  TODO: are there other common schemes
like news: that don't use authority indicator?

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol-relative URL
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		if utilities.is_set (authority) then
			authority = authority:gsub ('//', '', 1);							-- replace place 1 pair of '/' with nothing;
			if utilities.is_set(authority) then									-- if anything left (1 or 3+ '/' where authority should be) then
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		else
			if not scheme:match ('^news:') then									-- except for news:..., MediaWiki won't link URLs that do not have authority indicator; TODO: a better way to do this test?
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link=, etc. for properly formatted content: no wikilinks, no URLs

Link parameters are to hold the title of a Wikipedia article, so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki URLs and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid URL (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid URL (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from URL; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid URL
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wiki-linked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

check &lt;link&gt; for inter-language interwiki-link prefix.  prefix must be a MediaWiki-recognized language
code and must begin with a colon.

]]

local function link_title_ok (link, lorig, title, torig)
local orig;
	if utilities.is_set (link) then 											-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		elseif link:match ('^%a+:') then										-- if the link is what looks like an interwiki
			local prefix = link:match ('^(%a+):'):lower();						-- get the interwiki prefix

			if cfg.inter_wiki_map[prefix] then									-- if prefix is in the map, must have preceding colon
				orig = lorig;													-- flag as error
			end
		end
	end

	if utilities.is_set (orig) then
		link = '';																-- unset
		table.insert( z.message_tail, { utilities.set_message ( 'err_bad_paramlink', orig)});	-- URL or wikilink in |title= with |title-link=;
	end
	
	return link;																-- link if ok, empty string else
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the URL into scheme and domain
portions, or for protocol-relative (//example.com) URLs, just the domain.  Use is_url() to validate the two
portions of the URL.  If both are valid, or for protocol-relative if domain is valid, return true, else false.

Because it is different from a standard URL, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper URL
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from URL;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a URL.  The test will also find external wikilinks
that use protocol-relative URLs. Also finds bare URLs.

The frontier pattern prevents a match on interwiki-links which are similar to scheme:path URLs.  The tests that
find bracketed URLs are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext. wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol-relative ext. wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare URL with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol-relative bare URL: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a URL
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a URL add an error message
			if utilities.is_set(error_message) then								-- once we've added the first portion of the error message ...
				error_message = error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message = error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if utilities.is_set (error_message) then									-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { utilities.set_message ( 'err_param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { utilities.set_message ( 'err_wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source, access)
	local error_str = &quot;&quot;;
	local domain;
	local path;
	local base_url;

	if not utilities.is_set ( label ) then
		label = URL;
		if utilities.is_set ( source ) then
			error_str = utilities.set_message ( 'err_bare_url_missing_title', { utilities.wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = utilities.set_message ( 'err_bad_url', {utilities.wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the URL into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['['] = '%5b', [']'] = '%5d'});					-- replace '[' and ']' with their percent-encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wiki-markup URL

	if utilities.is_set (access) then											-- access level (subscription, registration, limited)
		base_url = utilities.substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end
	
	return table.concat ({base_url, error_str});
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a Boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { utilities.set_message ( 'err_deprecated_params', {name}, true ) } );	-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wiki-markup) are not kerned.

Replaces Unicode quote marks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc.; not for book titles.

]=]

local function kern_quotes (str)
	local cap = '';
	local cap2 = '';
	local wl_type, label, link;

	wl_type, label, link = utilities.is_wikilink (str);							-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-wl-both'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = utilities.substitute (cfg.presentation['kern-wl-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-wl-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label = mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label = mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap, cap2 = mw.ustring.match (label, &quot;^([\&quot;\'])([^\'].+)&quot;);				-- match leading double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-left'], {cap, cap2});
		end
	
		cap, cap2 = mw.ustring.match (label, &quot;^(.+[^\'])([\&quot;\'])$&quot;)				-- match trailing double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-right'], {cap, cap2});
		end
		
		if 2 == wl_type then
			str = utilities.make_wikilink (link, label);						-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin-based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate RTL languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO 639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO 639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title=, |script-chapter=, |script-&lt;periodical&gt;=

]]

local function format_script_value (script_value, script_param)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%l?%s*:') then									-- if first 3 or 4 non-space characters are script language prefix
		lang = script_value:match('^(%l%l%l?)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not utilities.is_set (lang) then
			table.insert( z.message_tail, { utilities.set_message ( 'err_script_parameter', {script_param, 'missing title part'}, true ) } );		-- prefix without 'title'; add error message
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_code_remap[lang] or mw.language.fetchLanguageName( lang, cfg.this_wiki_code );	-- get language name so that we can use it to categorize
		if utilities.is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l+%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if utilities.in_array (lang, cfg.script_lang_codes) then
				utilities.add_prop_cat ('script_with_name', {name, lang})
			else
				table.insert( z.message_tail, { utilities.set_message ( 'err_script_parameter', {script_param, 'unknown language code'}, true ) } );	-- unknown script-language; add error message
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			table.insert( z.message_tail, { utilities.set_message ( 'err_script_parameter', {script_param, 'invalid language code'}, true ) } );		-- invalid language code; add error message
			lang = '';															-- invalid so set lang to empty string
		end
	else
		table.insert( z.message_tail, { utilities.set_message ( 'err_script_parameter', {script_param, 'missing prefix'}, true ) } );				-- no language code prefix; add error message
	end
	script_value = utilities.substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is RTL

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script, script_param)
	if utilities.is_set (script) then
		script = format_script_value (script, script_param);					-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; returns empty string on error
		if utilities.is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not utilities.is_set ( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return utilities.substitute ( msg, str );								-- including template text
	else
		return utilities.substitute ( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;----------------------------------------

Makes a Wikisource URL from Wikisource interwiki-link.  Returns the URL and appropriate label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;
	local wikisource_prefix = table.concat ({'https://', cfg.this_wiki_code, '.wikisource.org/wiki/'});

	wl_type, D, L = utilities.is_wikilink (str);								-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 1 == wl_type then													-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end
	
	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable URL
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent encoding of fragment marker
	end

	return ws_url, ws_label, L or D;											-- return proper URL or nil and a label or nil
end


--[[--------------------------&lt; F O R M A T _ P E R I O D I C A L &gt;--------------------------------------------

Format the three periodical parameters: |script-&lt;periodical&gt;=, |&lt;periodical&gt;=, and |trans-&lt;periodical&gt;= into a single Periodical meta-
parameter.

]]

local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)
	local periodical_error = '';

	if not utilities.is_set (periodical) then
		periodical = '';														-- to be safe for concatenation
	else
		periodical = utilities.wrap_style ('italic-title', periodical);			-- style 
	end

	periodical = script_concatenate (periodical, script_periodical, script_periodical_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (trans_periodical) then
		trans_periodical = utilities.wrap_style ('trans-italic-title', trans_periodical);
		if utilities.is_set (periodical) then
			periodical = periodical .. ' ' .. trans_periodical;
		else																	-- here when trans-periodical without periodical or script-periodical
			periodical = trans_periodical;
			periodical_error = ' ' .. utilities.set_message ('err_trans_missing_title', {'periodical'});
		end
	end

	return periodical .. periodical_error;
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (script_chapter, script_chapter_source, chapter, chapter_source, trans_chapter, trans_chapter_source, chapter_url, chapter_url_source, no_quotes, access)
	local chapter_error = '';

	local ws_url, ws_label, L = wikisource_url_make (chapter);					-- make a wikisource URL and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', '');										-- replace underscore separaters with space characters
		chapter = ws_label;
	end

	if not utilities.is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from module provided quote marks
			chapter = utilities.wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, script_chapter, script_chapter_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (chapter_url) then
		chapter = external_link (chapter_url, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');	-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if utilities.is_set (trans_chapter) then
		trans_chapter = utilities.wrap_style ('trans-quoted-title', trans_chapter);
		if utilities.is_set (chapter) then
			chapter = chapter .. ' ' .. trans_chapter;
		else																	-- here when trans_chapter without chapter or script-chapter
			chapter = trans_chapter;
			chapter_source = trans_chapter_source:match ('trans%-?(.+)');		-- when no chapter, get matching name from trans-&lt;param&gt;
			chapter_error = ' ' .. utilities.set_message ('err_trans_missing_title', {chapter_source});
		end
	end

	return chapter .. chapter_error;
end


--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for non-printable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the Wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i = 1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no Unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char = cfg.invisible_chars[i][1]									-- the character or group name
		local pattern = cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position and (char == 'zero width joiner') then						-- if we found a zero-width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- it's ok if one of the Indic scripts
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and utilities.in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { utilities.set_message ( 'err_invisible_char', {err_msg, utilities.wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i = i+1;																-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper ( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function ( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = utilities.select_one ( args, list, 'err_redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] .. ': ' .. k);
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap = '';
	local cap2 = '';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = utilities.substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = utilities.substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if utilities.is_set (title_type) then
		if 'none' == cfg.keywords_xlate[title_type] then
			title_type = '';													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash under certain conditions.  The hyphen must separate like items; unlike items are
returned unmodified.  These forms are modified:
	letter - letter (A - B)
	digit - digit (4-5)
	digit separator digit - digit separator digit (4.1-4.5 or 4-1-4-5)
	letterdigit - letterdigit (A1-A5) (an optional separator between letter and digit is supported – a.1-a.5 or a-1-a-5)
	digitletter - digitletter (5a - 5d) (an optional separator between letter and digit is supported – 5.a-5.d or 5-a-5-d)

any other forms are returned unmodified.

str may be a comma- or semicolon-separated list

]]

local function hyphen_to_dash( str )
	if not utilities.is_set (str) then
		return str;
	end

	local accept;																-- Boolean
	str, accept = utilities.has_accept_as_written (str);						-- remove accept-this-as-written markup when it wraps all of str
	if accept then
		return str;																-- when markup removed, nothing to do, we're done
	end

	str = str:gsub ('&amp;[nm]dash;', {['&amp;ndash;'] = '–', ['&amp;mdash;'] = '—'});		-- replace &amp;mdash; and &amp;ndash; entities with their characters; semicolon mucks up the text.split
	str = str:gsub ('&amp;#45;', '-');												-- replace HTML numeric entity with hyphen character
	str = str:gsub ('&amp;nbsp;', ' ');												-- replace &amp;nbsp; entity with generic keyboard space character
	
	local out = {};
	local list = mw.text.split (str, '%s*[,;]%s*');								-- split str at comma or semicolon separators if there are any

	for _, item in ipairs (list) do												-- for each item in the list
		if mw.ustring.match (item, '^%w*[%.%-]?%w+%s*[%-–—]%s*%w*[%.%-]?%w+$') then	-- if a hyphenated range or has endash or emdash separators
			if item:match ('^%a+[%.%-]?%d+%s*%-%s*%a+[%.%-]?%d+$') or			-- letterdigit hyphen letterdigit (optional separator between letter and digit)
				item:match ('^%d+[%.%-]?%a+%s*%-%s*%d+[%.%-]?%a+$') or			-- digitletter hyphen digitletter (optional separator between digit and letter)
				item:match ('^%d+[%.%-]%d+%s*%-%s*%d+[%.%-]%d+$') or			-- digit separator digit hyphen digit separator digit
				item:match ('^%d+%s*%-%s*%d+$') or								-- digit hyphen digit
				item:match ('^%a+%s*%-%s*%a+$') then							-- letter hyphen letter
					item = item:gsub ('(%w*[%.%-]?%w+)%s*%-%s*(%w*[%.%-]?%w+)', '%1–%2');	-- replace hyphen, remove extraneous space characters
			else
				item = mw.ustring.gsub (item, '%s*[–—]%s*', '–');				-- for endash or emdash separated ranges, replace em with en, remove extraneous whitespace
			end
		end
		item = utilities.has_accept_as_written (item);							-- remove accept-this-as-written markup when it wraps all of str
		table.insert (out, item);												-- add the (possibly modified) item to the output table
	end

	return table.concat (out, ', ');											-- concatenate the output table into a comma separated string
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'duplicate character'
		if 1 == #duplicate_char then											-- for single byte ASCII characters use the string library functions
			f.gsub = string.gsub
			f.match = string.match
			f.sub = string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub = mw.ustring.gsub
			f.match = mw.ustring.match
			f.sub = mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1, 1) == '&lt;' then										-- special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove HTML markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1, 1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc.?
				trim = false;
				end_chr = f.sub(str, -1, -1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr .. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1, -2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5, -1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3, -1) == duplicate_char .. '&quot;]' then		-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2, -1) == duplicate_char .. &quot;]&quot; then		-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2, -1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1, -3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains HTML markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows HTML markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;------------------------------------------------------------

returns true is suffix is properly formed Jr, Sr, or ordinal in the range 1–9.  Puncutation not allowed.

]]

local function is_suffix (suffix)
	if utilities.in_array (suffix, {'Jr', 'Sr', 'Jnr', 'Snr', '1st', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written outside of the code editor and pasted here because the code editor gets confused between character insertion point and cursor position.
The test has been rewritten to use decimal character escape sequence for the individual bytes of the Unicode characters so that it is not necessary
to use an external editor to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first, suffix)
	if not suffix then
		if first:find ('[,%s]') then											-- when there is a space or comma, might be first name/initials + generational suffix
			first = first:match ('(.-)[,%s]+');									-- get name/initials
			suffix = first:match ('[,%s]+(.+)$');								-- get generational suffix
		end
	end
	if utilities.is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error (cfg.err_msg_supl.suffix);
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error (cfg.err_msg_supl['non-Latin char']);
			return false;														-- not a string of Latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-style=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc.) to be rendered as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the Unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just initials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error (cfg.err_msg_supl.suffix);					-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word

	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i], 1, 1));				-- insert the initial at end of initials table
		end
		i = i+1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; L I S T _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors, contributors, editors, interviewers, translators) 

names in the list will be linked when
	|&lt;name&gt;-link= has a value
	|&lt;name&gt;-mask- does NOT have a value; masked names are presumed to have been rendered previously so should have been linked there

when |&lt;name&gt;-mask=0, the associated name is not rendered

]]

local function list_people (control, people, etal)
	local sep;
	local namesep;
	local format = control.format;
	local maximum = control.maximum;
	local lastauthoramp = control.lastauthoramp;							-- TODO: delete after deprecation
	local name_list = {};

	if 'vanc' == format then													-- Vancouver-like name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between names is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
		lastauthoramp = nil;												-- TODO: delete after deprecation	-- unset because isn't used by Vancouver style
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between names is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub (-1, -1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if utilities.is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end		-- returned 0 is for EditorCount; not used for other names
	
	for i, person in ipairs (people) do
		if utilities.is_set (person.last) then
			local mask = person.mask;
			local one;
			local sep_one = sep;

			if utilities.is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			end
			
			if mask then
				local n = tonumber (mask);										-- convert to a number if it can be converted; nil else
				if n then
					one = 0 ~= n and string.rep(&quot;&amp;mdash;&quot;,n) or nil;			-- make a string of (n &gt; 0) mdashes, nil else, to replace name
					person.link = nil;											-- don't create link to name if name is replaces with mdash string or has been set nil
				else
					one = mask;													-- replace name with mask text (must include name-list separator)
					sep_one = &quot; &quot;;												-- modify name-list separator
				end
			else
				one = person.last;												-- get surname
				local first = person.first										-- get given name
				if utilities.is_set (first) then
					if (&quot;vanc&quot; == format) then									-- if Vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials (first);					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
			end
			if utilities.is_set (person.link) then
				one = utilities.make_wikilink (person.link, one);				-- link author/editor
			end
			if one then															-- if &lt;one&gt; has a value (name, mdash replacement, or mask text replacement)
				table.insert (name_list, one);									-- add it to the list of names
				table.insert (name_list, sep_one);								-- add the proper name-list separator
			end
		end
	end

	local count = #name_list / 2;												-- (number of names + number of separators) divided by 2
	if 0 &lt; count then 
		if 1 &lt; count and not etal then
			if 'amp' == format or utilities.is_set (lastauthoramp) then			-- TODO: delete lastauthoramp after deprecation
				name_list[#name_list-2] = &quot; &amp; &quot;;								-- replace last separator with ampersand text
			elseif 'and' == format then
				if 2 == count then
					name_list[#name_list-2] = cfg.presentation.sep_nl_and;		-- replace last separator with 'and' text
				else
					name_list[#name_list-2] = cfg.presentation.sep_nl_end;		-- replace last separator with '(sep) and' text
				end
			end
		end
		name_list[#name_list] = nil;											-- erase the last separator
	end

	local result = table.concat (name_list);									-- construct list
	if etal and utilities.is_set (result) then									-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've got a last-first list and etal so add et al.
	end
	
	return result, count;														-- return name-list string and count of number of names (count used for editor names only)
end


--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]

local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if utilities.is_set (id) then												-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of name parameters (author, editor, etc.) for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the associated |display-&lt;names&gt;=etal parameter

]]

local function name_has_etal (name, etal, nocat, param)

	if utilities.is_set (name) then												-- name can be nil in which case just return
		local patterns = cfg.et_al_patterns;									--get patterns from configuration
		
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns
			if name:match (pattern) then										-- if this 'et al' pattern is found in name
				name = name:gsub (pattern, '');									-- remove the offending text
				etal = true;													-- set flag (may have been set previously here or by |display-&lt;names&gt;=etal)
				if not nocat then												-- no categorization for |vauthors=
					table.insert( z.message_tail, {utilities.set_message ('err_etal', {param})});	-- and set an error if not added
				end
			end
		end
	end

	return name, etal;
end


--[[--------------------------&lt; N A M E _ I S _ N U M E R I C &gt;------------------------------------------------

Add maint cat when name parameter value does not contain letters.  Does not catch mixed alphanumeric names so
|last=A. Green (1922-1987) does not get caught in the current version of this test but |first=(1888) is caught.

returns nothing

]]

local function name_is_numeric (name, list_name)
	if utilities.is_set (name) then
		if mw.ustring.match (name, '^[%A]+$') then								-- when name does not contain any letters
			utilities.set_message ('maint_numeric_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
		end
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E D _ M A R K U P &gt;------------------------------------------

Evaluates the content of author and editor parameters for extraneous editor annotations: ed, ed., eds, (Ed.), etc.
These annotation do not belong in author parameters and are redundant in editor parameters.  If found, the function
adds the editor markup maintenance category.

returns nothing

]]

local function name_has_ed_markup (name, list_name)
	local patterns = cfg.editor_markup_patterns;								-- get patterns from configuration

	if utilities.is_set (name) then
		for _, pattern in ipairs (patterns) do									-- spin through patterns table and
			if name:match (pattern) then
				utilities.set_message ('maint_extra_text_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
				break;
			end
		end
	end
end


--[[--------------------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;----------------------------------------

Evaluates the content of last/surname (authors etc.) parameters for multiple names.  Multiple names are indicated
if there is more than one comma or any semicolons.  If found, the function adds the multiple name maintenance category.

returns nothing

]]

local function name_has_mult_names (name, list_name)
	local _, commas, semicolons;
	if utilities.is_set (name) then
		_, commas = name:gsub (',', '');										-- count the number of commas
		_, semicolons = name:gsub (';', '');									-- count the number of semicolons
		
		if 1 &lt; commas or 0 &lt; semicolons then												
			utilities.set_message ('maint_mult_names', cfg.special_case_translation [list_name]);	-- add a maint message
		end
	end
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------

This function calls various name checking functions used to validate the content of the various name-holding
parameters.

]]

local function name_checks (last, first, list_name)
	local accept_name;

	if utilities.is_set (last) then
		last, accept_name = utilities.has_accept_as_written (last);				-- remove accept-this-as-written markup when it wraps all of &lt;last&gt;
		
		if not accept_name then													-- &lt;last&gt; not wrapped in accept-as-written markup
			name_has_mult_names (last, list_name);								-- check for multiple names in the parameter (last only)
			name_has_ed_markup (last, list_name);								-- check for extraneous 'editor' annotation
			name_is_numeric (last, list_name);									-- check for names that are compsed of digits and punctuation
		end
	end

	if utilities.is_set (first) then
		first, accept_name = utilities.has_accept_as_written (first);			-- remove accept-this-as-written markup when it wraps all of &lt;first&gt;

		if not accept_name then														-- &lt;first&gt; not wrapped in accept-as-written markup
			name_has_ed_markup (first, list_name);								-- check for extraneous 'editor' annotation
			name_is_numeric (first, list_name);									-- check for names that are compsed of digits and punctuation
		end
	end

	return last, first;															-- done
end


--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};															-- table of names
	local last;																	-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;																-- loop counter/indexer
	local n = 1;																-- output table indexer
	local count = 0;															-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal = false;															-- return value set to true when we find some form of et al. in an author parameter

	local last_alias, first_alias, link_alias;									-- selected parameter aliases used in error messaging
	while true do
		last, last_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'err_redundant_parameters', i );		-- search through args for name components beginning at 1
		first, first_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'err_redundant_parameters', i );
		link, link_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i );
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.
		last, first = name_checks (last, first, list_name);						-- multiple names, extraneous annotation, etc. checks
		
		if first and not last then												-- if there is a firstn without a matching lastn
			local alias = first_alias:find ('given', 1, true) and 'given' or 'first';	-- get first or given form of the alias
			table.insert (z.message_tail, { utilities.set_message ( 'err_first_missing_last', {
				first_alias,													-- param name of alias missing its mate
				first_alias:gsub (alias, {['first'] = 'last', ['given'] = 'surname'}),	-- make param name appropriate to the alias form
				}, true ) } );													-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			local result;
			link = link_title_ok (link, link_alias, last, last_alias);			-- check for improper wiki-markup
			if first then
				link = link_title_ok (link, link_alias, first, first_alias);	-- check for improper wiki-markup
			end

			names[n] = {last = last, first = first, link = link, mask = mask, corporate = false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { utilities.set_message ( 'err_missing_name', {list_name:match (&quot;(%w+)List&quot;):lower(), i - 1}, true ) } );	-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names and the etal flag
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because case of the source may be incorrect
or different from the case that WikiMedia uses, the name comparisons are done in lower case and when a match is
found, the Wikimedia version (assumed to be correct) is returned along with the code.  When there is no match, we
return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') returns a list of languages that in some cases may include
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.  Most (all?) of these languages are not used a 'language' codes per se, rather they
are used as sub-domain names: cbk-zam.wikipedia.org.  A list of language names and codes supported by fetchLanguageNames()
can be found at Template:Citation Style documentation/language/doc

Names that are included in the list will be found if that name is provided in the |language= parameter.  For example,
if |language=Chavacano de Zamboanga, that name will be found with the associated code 'cbk-zam'.  When names are found
and the associated code is not two or three characters, this function returns only the WikiMedia language name.

Some language names have multiple entries under different codes:
	Aromanian has code rup and code roa-rup
When this occurs, this function returns the language name and the 2- or 3-character code

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	if cfg.lang_name_remap[lang:lower()] then									-- if there is a remapped name (because MediaWiki uses something that we don't think is correct)
		return cfg.lang_name_remap[lang:lower()][1], cfg.lang_name_remap[lang:lower()][2];	-- for this language 'name', return a possibly new name and appropriate code
	end

	local ietf_code;															-- because some languages have both IETF-like codes and ISO 639-like codes
	local ietf_name;
	
	local langlc = mw.ustring.lower (lang);										-- lower-case version for comparisons

	for code, name in pairs (cfg.languages) do									-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower (name) then
			if 2 == #code or 3 == #code then									-- two- or three-character codes only; IETF extensions not supported
				return name, code;												-- so return the name and the code
			end
			ietf_code = code;													-- remember that we found an IETF-like code and save its name
			ietf_name = name;													-- but keep looking for a 2- or 3-char code
		end
	end
																				-- didn't find name with 2- or 3-char code; if IETF-like code found return
	return ietf_code and ietf_name or lang;										-- associated name; return original language text else
end


--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code is recognized by MediaWiki,
use the returned name; if not, then use the value that was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is assigned to the category for
that code: Category:Norwegian-language sources (no).  For valid three-character code languages, the page is assigned
to the single category for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does not recognize three-character
equivalents of two-character codes: code 'ar' is recognized but code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are
separated from each other by commas with optional space characters.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki_name = mw.language.fetchLanguageName (cfg.this_wiki_code, cfg.this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang
		name = cfg.lang_code_remap[lang:lower()];								-- first see if this is a code that is not supported by MediaWiki but is in remap

		if name then															-- there was a remapped code so
			if not lang:match ('^%a%a%a?%-x%-%a+$') then						-- if not a private IETF tag
				lang = lang:gsub ('^(%a%a%a?)%-.*', '%1');						-- strip IETF tags from code
			end
		else
			lang = lang:gsub ('^(%a%a%a?)%-.*', '%1');							-- strip any IETF-like tags from code
			if 2 == lang:len() or 3 == lang:len() then							-- if two-or three-character code
				name = mw.language.fetchLanguageName (lang:lower(), cfg.this_wiki_code);	-- get language name if |language= is a proper code
			end
		end

		if utilities.is_set (name) then											-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, cfg.this_wiki_code);			-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if utilities.is_set (code) then											-- only 2- or 3-character codes
			name = cfg.lang_code_remap[code] or name;							-- override wikimedia when they misuse language codes/names

			if cfg.this_wiki_code ~= code then									-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					utilities.add_prop_cat ('foreign_lang_source' .. code, {name, code});	-- categorize it; code appended to allow for multiple language categorization
				else															-- or is a recognized language (but has a three-character code)
					utilities.add_prop_cat ('foreign_lang_source_2' .. code, {code});		-- categorize it differently TODO: support multiple three-character code categories per cs1|2 template
				end
			elseif cfg.local_lang_cat_enable then								-- when the language and this wiki's language are the same and categorization is enabled
				utilities.add_prop_cat ('local_lang_source', {name, code});		-- categorize it
			end
		else
			utilities.set_message ('maint_unknown_lang');						-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
 
	name = utilities.make_sep_list (#language_list, language_list);

	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings
At en.wiki, for cs1:
	ps gets:	'.'
	sep gets:	'.'

]]

local function set_cs1_style (ps)
	if not utilities.is_set (ps) then											-- unless explicitly set to something
		ps = cfg.presentation['ps_cs1'];										-- terminate the rendered citation
	end
	return cfg.presentation['sep_cs1'], ps;										-- element separator
end


--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings
At en.wiki, for cs2:
	ps gets:	'' (empty string - no terminal punctuation)
	sep gets:	','

]]

local function set_cs2_style (ps, ref)
	if not utilities.is_set (ps) then											-- if |postscript= has not been set, set cs2 default
		ps = cfg.presentation['ps_cs2'];										-- terminate the rendered citation
	end
	if not utilities.is_set (ref) then											-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return cfg.presentation['sep_cs2'], ps, ref;								-- element separator
end


--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end


--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end

	if cfg.keywords_xlate[ps:lower()] == 'none' then							-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end


--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a URL has the file extension that is one of the PDF file extensions used by [[MediaWiki:Common.css]] when
applying the PDF icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or
		url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
		url:match ('%.PDF&amp;#035') or url:match ('%.pdf&amp;#035');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies CSS style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching URL parameter.  If the format parameter is not set and the URL contains a file extension that
is recognized as a PDF document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if utilities.is_set (format) then
		format = utilities.wrap_style ('format', format);						-- add leading space, parentheses, resize
		if not utilities.is_set (url) then
			format = format .. ' ' .. utilities.set_message ( 'err_format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if URL is a PDF file then
		format = utilities.wrap_style ('format', 'PDF');						-- set format to PDF
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[--------------------------&lt; G E T _ D I S P L A Y _ N A M E S &gt;--------------------------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a Boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_names (max, count, list_name, etal)
	if utilities.is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				table.insert( z.message_tail, {utilities.set_message ('err_disp_name', {cfg.special_case_translation [list_name], max}, true)});	-- add error message
				max = nil;
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, {utilities.set_message ('err_disp_name', {cfg.special_case_translation [list_name], max}, true)});		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		utilities.set_message ('maint_extra_text');								-- add maint cat;
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parentheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a place holder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parentheses
			local name = name_table[i];
			i = i + 1;																-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parentheses
					break;														-- and done reassembling so
				end
				i = i + 1;														-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = utilities.is_wikilink (name_table[i]);		-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i + 1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled parentheses ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the Vancouver error when a required comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		first = '';																-- set to empty string for concatenation and because it may have been set for previous author/editor
		local accept_name;
		v_name, accept_name = utilities.has_accept_as_written (v_name);			-- remove accept-this-as-written markup when it wraps all of &lt;v_name&gt;

--		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parentheses to suppress vanc formatting and error detection
--			last = v_name:match ('^%(%((.+)%)%)$')								-- remove doubled parentheses
		if accept_name then
			last = v_name;
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error (cfg.err_msg_supl.punctuation);
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s+&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be initials or generational suffix

			if not mw.ustring.match (first, '^%u+$') then						-- mw.ustring here so that later we will catch non-Latin characters
				suffix = first;													-- not initials so assume that whatever we got is a generational suffix
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end
			last = table.concat(lastfirstTable, ' ')							-- returns a string that is the concatenation of all other names that are not initials and generational suffix
			if not utilities.is_set (last) then
				first = '';														-- unset
				last = v_name;													-- last empty because something wrong with first
				add_vanc_error (cfg.err_msg_supl.name);
			end
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error (cfg.err_msg_supl['missing comma']);				-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error (cfg.err_msg_supl.name);							-- matches a space between two initials
			end
		else
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
		
		if utilities.is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error (cfg.err_msg_supl.initials);						-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first, suffix);							-- check first and last before restoring the suffix which may have a non-Latin digit
			if utilities.is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '');
			end
		end

		link = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i ) or v_link_table[i];
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate = corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
	local lastfirst = false;
	if utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice in case we have a |first1= without a |last1=; this ...
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or		-- ... also catches the case where |first= is used with |vauthors=
		utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst = true;
	end

	if (utilities.is_set (vxxxxors) and true == lastfirst) or					-- these are the three error conditions
		(utilities.is_set (vxxxxors) and utilities.is_set (xxxxors)) or
		(true == lastfirst and utilities.is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { utilities.set_message ( 'err_redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if utilities.is_set (vxxxxors) then return 2 end;
	if utilities.is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, live, dead, etc.).  When the parameter value has not been assigned a value (missing
or empty in the source template) the function returns the value specified by ret_val.  If the parameter value is one
of the list of allowed values returns the translated value; else, emits an error message and returns the value
specified by ret_val.

]]

local function is_valid_parameter_value (value, name, possible, ret_val)
	if not utilities.is_set (value) then
		return ret_val;															-- an empty parameter is ok
	elseif utilities.in_array (value, possible) then
		return cfg.keywords_xlate[value];										-- return translation of parameter keyword
	else
		table.insert( z.message_tail, { utilities.set_message ( 'err_invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return ret_val;
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list, -3, -1) == sepc .. '. ') then					-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list, -1, -1) == sepc) or (string.sub (name_list, -3, -1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terminate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not utilities.is_set (volume) and not utilities.is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (utilities.in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if utilities.is_set (volume) and utilities.is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif utilities.is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end

	if 'podcast' == cite_class and utilities.is_set (issue) then
		return wrap_msg ('issue', {sepc, issue}, lower);
	end

	local vol = '';																-- here for all cites except magazine
		
	if utilities.is_set (volume) then
		if volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$') then			-- volume value is all digits or all uppercase Roman numerals
			vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});	-- render in bold face
		elseif (4 &lt; mw.ustring.len(volume)) then								-- not all digits or Roman numerals and longer than 4 characters
			vol = utilities.substitute (cfg.messages['j-vol'], {sepc, volume});	-- not bold
			utilities.add_prop_cat ('long_vol');
		else																	-- four or less characters
			vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});	-- bold
		end
	end
	if utilities.is_set (issue) then
		return vol .. utilities.substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if utilities.is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif utilities.is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if utilities.is_set (page) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return utilities.substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return utilities.substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif utilities.is_set (pages) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then							-- if pages is only digits, assume a single page number
			return '', utilities.substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', utilities.substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', utilities.substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to Wikisource, returns the label portion of the interwiki-link as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki-link to and external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, pages, at)
	local ws_url, ws_label, coins_pages, L;										-- for Wikisource interwiki-links; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if utilities.is_set (page) then
		if utilities.is_set (pages) or utilities.is_set (at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws URL from |page= interwiki link; link portion L becomes tooltip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (pages) then
		if utilities.is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws URL from |pages= interwiki link; link portion L becomes tooltip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws URL from |at= interwiki link; link portion L becomes tooltip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org URLs to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot URL or to calendar pages.  When the archive URL is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the URL.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org URL does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command URL
	|archive-url= is an archive.org URL that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org URLs:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this function may return a modified
archive URL:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the URL unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.org URL
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine URL
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command URL, we don't want to allow saving of the target page 
		err_msg = cfg.err_msg_supl.save;
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = cfg.err_msg_supl.liveweb;
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');	-- split out some of the URL parts for evaluation
		
		if not utilities.is_set (timestamp) or 14 ~= timestamp:len() then		-- path and flag optional, must have 14-digit timestamp here
			err_msg = cfg.err_msg_supl.timestamp;
			if '*' ~= flag then
				url=url:gsub ('(//web%.archive%.org/[^%d]*%d?%d?%d?%d?%d?%d?)[^/]*', '%1*', 1)	-- for preview, modify ts to be yearmo* max (0-6 digits plus splat)
			end
		elseif utilities.is_set (path) and 'web/' ~= path then					-- older archive URLs do not have the extra 'web/' path element
			err_msg = cfg.err_msg_supl.path;
		elseif utilities.is_set (flag) and not utilities.is_set (path) then		-- flag not allowed with the old form URL (without the 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		elseif utilities.is_set (flag) and not flag:match ('%a%a_') then		-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		else
			return url, date;													-- return ArchiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	table.insert( z.message_tail, { utilities.set_message ( 'err_archive_url', {err_msg}, true ) } );	-- add error message and
	if utilities.is_set (Frame:preprocess('{{REVISIONID}}')) then
		return '', '';															-- return empty strings for ArchiveURL and ArchiveDate
	else
		return url, date;														-- preview mode so return ArchiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; P L A C E _ C H E C K &gt;--------------------------------------------------------

check |place=, |publication-place=, |location= to see if these params include digits.  This function added because
many editors misuse location to specify the in-source location (|page(s)= and |at= are supposed to do that)

returns the original parameter value without modification; added maint cat when parameter value contains digits

]]

local function place_check (param_val)
	if not utilities.is_set (param_val) then									-- parameter empty or omitted
		return param_val;														-- return that empty state
	end
	
	if mw.ustring.find (param_val, '%d') then									-- not empty, are there digits in the parameter value
		utilities.set_message ('maint_location');								-- yep, add maint cat
	end
	
	return param_val;															-- and done
end


--[[--------------------------&lt; I S _ G E N E R I C _ T I T L E &gt;----------------------------------------------

compares |title= value against list of known generic title patterns.  Returns true when pattern matches; nil else

the k/v pairs in 'generic_titles' each contain two tables, one for English and one for another 'local' language
Each of those tables contain another table that holds the string or pattern (whole title or title fragment) in
index [1].  index [2] is a Boolean that tells string.find() or mw.ustring.find() to do plain-text search (true)
or a pattern search (false).  The intent of all this complexity is to make these searches as fast as possible so
that we don't run out of processing time on very large articles.

]]

local function is_generic_title (title)
	title = mw.ustring.lower(title);											-- switch title to lower case
	for _, generic_title in ipairs (cfg.special_case_translation['generic_titles']) do	--spin through the list of known generic title fragments
		if title:find (generic_title['en'][1], 1, generic_title['en'][2]) then
			return true;														-- found English generic title so done
		elseif generic_title['local'] then										-- to keep work load down, generic_title['local'] should be nil except when there is a local version of the generic title
			if mw.ustring.find (title, generic_title['local'][1], 1, generic_title['local'][2]) then	-- mw.ustring() because might not be Latin script
				return true;													-- found local generic title so done
			end
		end
	end
end


--[[--------------------------&lt; I S _ A R C H I V E D _ C O P Y &gt;----------------------------------------------

compares |title= to 'Archived copy' (place holder added by bots that can't find proper title); if matches, return true; nil else

]]

local function is_archived_copy (title)
	title = mw.ustring.lower(title);											-- switch title to lower case
	if title:find (cfg.special_case_translation.archived_copy.en) then			-- if title is 'Archived copy'
		return true;
	elseif cfg.special_case_translation.archived_copy['local'] then
		if mw.ustring.find (title, cfg.special_case_translation.archived_copy['local']) then	-- mw.ustring() because might not be Latin script
			return true;
		end
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper ( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

	local Mode = is_valid_parameter_value (A['Mode'], A:ORIGIN('Mode'), cfg.keywords_lists['mode'], '');

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;

	local NameListStyle = is_valid_parameter_value (A['NameListStyle'], A:ORIGIN('NameListStyle'), cfg.keywords_lists['name-list-style'], '');
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';											-- override whatever |name-list-style= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				utilities.set_message ('maint_authors');						-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if utilities.is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';											-- override whatever |name-list-style= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
		end
	end

	local translator_etal;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=

	local interviewer_etal;
	local interviewers_list = {};												
	local Interviewers;															-- used later
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters

	local contributor_etal;
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list

	local Chapter = A['Chapter'];												-- done here so that we have access to |contribution= from |chapter= aliases
	local Chapter_origin = A:ORIGIN ('Chapter');
	local Contribution;															-- because contribution is required for contributor(s)
		if 'contribution' == A:ORIGIN ('Chapter') then
			Contribution = A['Chapter'];										-- get the name of the contribution
		end

	if utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not utilities.is_set (Contribution) then							-- |contributor= requires |contribution=
				table.insert( z.message_tail, { utilities.set_message ( 'err_contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { utilities.set_message ( 'err_contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if utilities.select_one (args, cfg.aliases['ContributorList-Last'], 'err_redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { utilities.set_message ( 'err_contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if utilities.is_set (Others) then
		if 0 == #a and 0 == #e then												-- add maint cat when |others= has value and used without |author=, |editor=
			utilities.set_message ('maint_others');
		end
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigDate = A['OrigDate'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TransTitle_origin = A:ORIGIN ('TransTitle');
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];

	local auto_select = ''; -- default is auto
	local accept_link;
	TitleLink, accept_link = utilities.has_accept_as_written(TitleLink, true); -- test for accept-this-as-written markup
	if (not accept_link) and utilities.in_array (TitleLink, {'none', 'pmc', 'doi'}) then -- check for special keywords
		auto_select = TitleLink; -- remember selection for later
		TitleLink = ''; -- treat as if |title-link= would have been empty
	end

	TitleLink = link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wiki-markup in |title-link= or wiki-markup in |title= when |title-link= is set

	local Section = '';															-- {{cite map}} only; preset to empty string for concatenation if not used
		if 'map' == config.CitationClass and 'section' == A:ORIGIN ('Chapter') then
			Section = A['Chapter'];												-- get |section= from |chapter= alias list; |chapter= and the other aliases not supported in {{cite map}}
			Chapter = '';														-- unset for now; will be reset later from |map= if present
		end

	local ScriptChapter = A['ScriptChapter'];
	local ScriptChapter_origin = A:ORIGIN ('ScriptChapter');
	local ChapterLink -- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TransChapter_origin = A:ORIGIN ('TransChapter');
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];

	local ArchiveDate;
	local ArchiveURL;

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	
	local UrlStatus = is_valid_parameter_value (A['UrlStatus'], A:ORIGIN('UrlStatus'), cfg.keywords_lists['url-status'], '');

	local URL = A['URL']
	local URL_origin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURL_origin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURL_origin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL

	local Periodical = A['Periodical'];
	local Periodical_origin = '';
	if utilities.is_set (Periodical) then
		Periodical_origin = A:ORIGIN('Periodical');								-- get the name of the periodical parameter
		local i;
		Periodical, i = utilities.strip_apostrophe_markup (Periodical);			-- strip apostrophe markup so that metadata isn't contaminated 
		if i then																-- non-zero when markup was stripped so emit an error message
			table.insert( z.message_tail, {utilities.set_message ('err_apostrophe_markup', {Periodical_origin}, true)});
		end
	end

	if 'mailinglist' == config.CitationClass then								-- special case for {{cite mailing list}}
		if utilities.is_set (Periodical) and utilities.is_set (A ['MailingList']) then	-- both set emit an error
			table.insert( z.message_tail, {utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', Periodical_origin) .. ' and ' .. utilities.wrap_style ('parameter', 'mailinglist')}, true )});
		end

		Periodical = A ['MailingList'];											-- error or no, set Periodical to |mailinglist= value because this template is {{cite mailing list}}
		Periodical_origin = A:ORIGIN('MailingList');
	end

	local ScriptPeriodical = A['ScriptPeriodical'];
	local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');

	-- web and news not tested for now because of 
	-- Wikipedia:Administrators%27_noticeboard#Is_there_a_semi-automated_tool_that_could_fix_these_annoying_&quot;Cite_Web&quot;_errors?
	if not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) then	-- 'periodical' templates require periodical parameter
	--	local p = {['journal'] = 'journal', ['magazine'] = 'magazine', ['news'] = 'newspaper', ['web'] = 'website'};	-- for error message
		local p = {['journal'] = 'journal', ['magazine'] = 'magazine'};			-- for error message
		if p[config.CitationClass]  then
			table.insert( z.message_tail, {utilities.set_message ('err_missing_periodical', {config.CitationClass, p[config.CitationClass]}, true)});
		end
	end

	local TransPeriodical =  A['TransPeriodical'];
	local TransPeriodical_origin =  A:ORIGIN ('TransPeriodical');

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) then
			if not utilities.in_array (Periodical_origin, {'website', 'mailinglist'}) then	-- {{citation}} does not render volume for these 'periodicals'
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		elseif utilities.is_set (ScriptPeriodical) then
			if 'script-website' ~= ScriptPeriodical_origin then					-- {{citation}} does not render volume for |script-website=
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		else
			Volume = A['Volume'];												-- and does for non-'periodical' cites
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_volume) then	-- render |volume= for cs1 according to the configuration settings
		Volume = A['Volume'];
	end	

	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) and utilities.in_array (Periodical_origin, {'journal', 'magazine', 'newspaper', 'periodical', 'work'}) or	-- {{citation}} renders issue for these 'periodicals'
			utilities.is_set (ScriptPeriodical) and utilities.in_array (ScriptPeriodical_origin, {'script-journal', 'script-magazine', 'script-newspaper', 'script-periodical', 'script-work'}) then -- and these 'script-periodicals'
				Issue = hyphen_to_dash (A['Issue']);
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_issue) then	-- conference &amp; map books do not support issue; {{citation}} listed here because included in settings table
		if not (utilities.in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical))) then
			Issue = hyphen_to_dash (A['Issue']);
		end
	end

	local Position = '';
	if not utilities.in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash (A['Pages']);	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = place_check (A['PublicationPlace'], A:ORIGIN('PublicationPlace'));
	local Place = place_check (A['Place'], A:ORIGIN('Place'));
	
	local PublisherName = A['PublisherName'];
	local PublisherName_origin = A:ORIGIN('PublisherName');
	if utilities.is_set (PublisherName) then
		local i = 0;
		PublisherName, i = utilities.strip_apostrophe_markup (PublisherName);	-- strip apostrophe markup so that metadata isn't contaminated; publisher is never italicized
		if i then																-- non-zero when markup was stripped so emit an error message
			table.insert( z.message_tail, {utilities.set_message ('err_apostrophe_markup', {PublisherName_origin}, true)});
		end
	end

	local Newsgroup = A['Newsgroup'];											-- TODO: strip apostrophe markup?
	local Newsgroup_origin = A:ORIGIN('Newsgroup');	

	if 'newsgroup' == config.CitationClass then
		if utilities.is_set (PublisherName) then								-- general use parameter |publisher= not allowed in cite newsgroup
			local error_text, error_state = utilities.set_message ('err_parameter_ignored', {PublisherName_origin}, true);
			if utilities.is_set (error_text) then
				table.insert( z.message_tail, {error_text, error_state} );
			end				
		end

		PublisherName = nil;													-- ensure that this parameter is unset for the time being; will be used again after COinS
	end

	local UrlAccess = is_valid_parameter_value (A['UrlAccess'], A:ORIGIN('UrlAccess'), cfg.keywords_lists['url-access'], nil);
		if not utilities.is_set (URL) and utilities.is_set (UrlAccess) then
			UrlAccess = nil;
			table.insert( z.message_tail, { utilities.set_message ( 'err_param_access_requires_param', {'url'}, true ) } );
		end
		
	local ChapterUrlAccess = is_valid_parameter_value (A['ChapterUrlAccess'], A:ORIGIN('ChapterUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (ChapterURL) and utilities.is_set (ChapterUrlAccess) then
		ChapterUrlAccess = nil;
		table.insert( z.message_tail, { utilities.set_message ( 'err_param_access_requires_param', {A:ORIGIN('ChapterUrlAccess'):gsub ('%-access', '')}, true ) } );
	end

	local MapUrlAccess = is_valid_parameter_value (A['MapUrlAccess'], A:ORIGIN('MapUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (A['MapURL']) and utilities.is_set (MapUrlAccess) then
		MapUrlAccess = nil;
		table.insert( z.message_tail, { utilities.set_message ( 'err_param_access_requires_param', {'map-url'}, true ) } );
	end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local Agency = A['Agency'];

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = is_valid_parameter_value (A['IgnoreISBN'], A:ORIGIN('IgnoreISBN'), cfg.keywords_lists['yes_true_y'], nil);
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local Quote = A['Quote'];
	local QuotePage = A['QuotePage'];
	local QuotePages = A['QuotePages'];
	local ScriptQuote = A['ScriptQuote'];
	local TransQuote = A['TransQuote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURL_origin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = is_valid_parameter_value (A['LastAuthorAmp'], A:ORIGIN('LastAuthorAmp'), cfg.keywords_lists['yes_true_y'], nil);

	local no_tracking_cats = is_valid_parameter_value (A['NoTracking'], A:ORIGIN('NoTracking'), cfg.keywords_lists['yes_true_y'], nil);
	if 'nocat' == A:ORIGIN('NoTracking') then				
		utilities.set_message ('maint_nocat');									-- this one so that we get the message; see main categorization at end of citation0()
	end
	
	--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = is_valid_parameter_value (A['DF'], A:ORIGIN('DF'), cfg.keywords_lists['df'], '');
	if not utilities.is_set (DF) then
		DF = cfg.global_df;														-- local |df= if present overrides global df set by {{use xxx date}} template
	end

	local sepc;																	-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref = A['Ref'];
	if 'harv' == Ref then
		utilities.set_message ('maint_ref_harv');								-- add maint cat to identify templates that have this now-extraneous param value
	elseif not utilities.is_set (Ref) then
		Ref = 'harv';															-- set as default when not set externally
	end
	
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], Ref, config.CitationClass);
	use_lowercase = ( sepc == ',' ); 											-- used to control capitalization for certain static text

	-- check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not utilities.is_set (no_tracking_cats) then								-- ignore if we are already not going to categorize this page
		if utilities.in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _, v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end
																				-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	utilities.select_one (args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'err_redundant_parameters');	-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, Pages, At);

	local NoPP = is_valid_parameter_value (A['NoPP'], A:ORIGIN('NoPP'), cfg.keywords_lists['yes_true_y'], nil);

	if utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- both |publication-place= and |place= (|location=) allowed if different
		utilities.add_prop_cat ('location test');								-- add property cat to evaluate how often PublicationPlace and Place are used together
		if PublicationPlace == Place then
			Place = '';															-- unset; don't need both if they are the same
		end
	elseif not utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- when only |place= (|location=) is set ...
		PublicationPlace = Place;												-- promote |place= (|location=) to |publication-place
	end

	if PublicationPlace == Place then Place = ''; end							-- don't need both if they are the same
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia= and |title= then map |title= to |article= and |encyclopedia= to |title=
		|encyclopedia= and |article= then map |encyclopedia= to |title=

		|trans-title= maps to |trans-chapter= when |title= is re-mapped
		|url= maps to |chapter-url= when |title= is remapped
	
	All other combinations of |encyclopedia=, |title=, and |article= are not modified
	
	]]

	local Encyclopedia = A['Encyclopedia'];										-- used as a flag by this module and by ~/COinS

	if utilities.is_set (Encyclopedia) then										-- emit error message when Encyclopedia set but template is other than {{cite encyclopedia}} or {{citation}}
		if 'encyclopaedia' ~= config.CitationClass and 'citation' ~= config.CitationClass then
			table.insert (z.message_tail, {utilities.set_message ('err_parameter_ignored', {A:ORIGIN ('Encyclopedia')}, true)});
			Encyclopedia = nil;													-- unset because not supported by this template
		end
	end

	if ('encyclopaedia' == config.CitationClass) or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Periodical) and utilities.is_set (Encyclopedia) then	-- when both set emit an error
			table.insert (z.message_tail, {utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', A:ORIGIN ('Encyclopedia')) .. ' and ' .. utilities.wrap_style ('parameter', Periodical_origin)}, true )});
		end

		if utilities.is_set (Encyclopedia) then
			Periodical = Encyclopedia;											-- error or no, set Periodical to Encyclopedia; allow periodical without encyclopedia
			Periodical_origin = A:ORIGIN ('Encyclopedia');
		end

		if utilities.is_set (Periodical) then									-- Periodical is set when |encyclopedia= is set
			if utilities.is_set (Title) or utilities.is_set (ScriptTitle) then
				if not utilities.is_set (Chapter) then
					Chapter = Title;											-- |encyclopedia= and |title= are set so map |title= to |article= and |encyclopedia= to |title=
					ScriptChapter = ScriptTitle;
					ScriptChapter_origin = A:ORIGIN('ScriptTitle')
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterURL_origin = A:ORIGIN('URL')

					ChapterUrlAccess = UrlAccess;

					if not utilities.is_set (ChapterURL) and utilities.is_set (TitleLink) then
						Chapter = utilities.make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			elseif utilities.is_set (Chapter) then								-- |title= not set
				Title = Periodical;												-- |encyclopedia= set and |article= set so map |encyclopedia= to |title=
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if utilities.is_set (A['Number']) then									-- cite techreport uses 'number', which other citations alias to 'issue'
			if not utilities.is_set (ID) then									-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'id') .. ' and ' .. utilities.wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if utilities.is_set (BookTitle) then
			Chapter = Title;
			Chapter_origin = 'title';
	--		ChapterLink = TitleLink;											-- |chapter-link= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			URL_origin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			TransChapter_origin = TransTitle_origin;
			Title = BookTitle;
			Format = '';
	--		TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		if utilities.is_set (Chapter) then
			table.insert( z.message_tail, { utilities.set_message ( 'err_redundant_parameters', {utilities.wrap_style ('parameter', 'map') .. ' and ' .. utilities.wrap_style ('parameter', Chapter_origin)}, true ) } );	-- add error message
		end
		Chapter = A['Map'];
		Chapter_origin = A:ORIGIN('Map');
		ChapterURL = A['MapURL'];
		ChapterURL_origin = A:ORIGIN('MapURL');
		TransChapter = A['TransMap'];
		ScriptChapter = A['ScriptMap']
		ScriptChapter_origin = A:ORIGIN('ScriptMap')

		ChapterUrlAccess = MapUrlAccess;
		ChapterFormat = A['MapFormat'];

		Cartography = A['Cartography'];
		if utilities.is_set ( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if utilities.is_set ( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local SeriesLink = A['SeriesLink'];

		SeriesLink = link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wiki-markup in |series-link= or wiki-markup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if utilities.is_set (Network) then table.insert(n, Network); end
		if utilities.is_set (Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if utilities.is_set (Season) and utilities.is_set (SeriesNumber) then	-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { utilities.set_message ( 'err_redundant_parameters', {utilities.wrap_style ('parameter', 'season') .. ' and ' .. utilities.wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if utilities.is_set (Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if utilities.is_set (SeriesNumber) then table.insert(s, wrap_msg ('seriesnum', SeriesNumber, use_lowercase)); end
			if utilities.is_set (Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ScriptChapter_origin = A:ORIGIN('ScriptTitle');
			ChapterLink = TitleLink;											-- alias |episode-link=
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if utilities.is_set (ChapterLink) and not utilities.is_set (ChapterURL) then	-- link but not URL
				Chapter = utilities.make_wikilink (ChapterLink, Chapter);
			elseif utilities.is_set (ChapterLink) and utilities.is_set (ChapterURL) then	-- if both are set, URL links episode;
				Series = utilities.make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if utilities.is_set (Series) and utilities.is_set (SeriesLink) then
				Series = utilities.make_wikilink (SeriesLink, Series);
			end
			Series = utilities.wrap_style ('italic-title', Series);				-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- handle type parameter for those CS1 citations that have default values
	if utilities.in_array (config.CitationClass, {&quot;AV-media-notes&quot;, &quot;interview&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if utilities.is_set (Degree) and &quot;Thesis&quot; == TitleType then				-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if utilities.is_set (TitleType) then										-- if type parameter is specified
		TitleType = utilities.substitute ( cfg.messages['type'], TitleType);	-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging

	if not utilities.is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not utilities.is_set (Date) and utilities.is_set (PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val = AccessDate, name = A:ORIGIN ('AccessDate')},
			['archive-date'] = {val = ArchiveDate, name = A:ORIGIN ('ArchiveDate')},
			['date'] = {val = Date, name = Date_origin},
			['doi-broken-date'] = {val = DoiBroken, name = A:ORIGIN ('DoiBroken')},
			['pmc-embargo-date'] = {val = Embargo, name = A:ORIGIN ('Embargo')},
			['lay-date'] = {val = LayDate, name = A:ORIGIN ('LayDate')},
			['publication-date'] = {val = PublicationDate, name = A:ORIGIN ('PublicationDate')},
			['year'] = {val = Year, name = A:ORIGIN ('Year')},
			};

		local error_list = {};
		anchor_year, Embargo = validation.dates(date_parameters_list, COinS_date, error_list);

-- start temporary Julian / Gregorian calendar uncertainty categorization
		if COinS_date.inter_cal_cat then
			utilities.add_prop_cat ('jul_greg_uncertainty');
		end
-- end temporary Julian / Gregorian calendar uncertainty categorization

		if utilities.is_set (Year) and utilities.is_set (Date) then				-- both |date= and |year= not normally needed; 
			local mismatch = validation.year_date_check (Year, Date);
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				table.insert (error_list, '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;year= / &amp;#124;date= mismatch&lt;/code&gt;');
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				utilities.set_message ('maint_date_year');						-- add a maint cat
			end
		end
		
		if 0 == #error_list then												-- error free dates only; 0 when error_list is empty
			local modified = false;												-- flag
			
			if utilities.is_set (DF) then										-- if we need to reformat dates
				modified = validation.reformat_dates (date_parameters_list, DF);	-- reformat to DF format, use long month names if appropriate
			end

			if true == validation.date_hyphen_to_dash (date_parameters_list) then	-- convert hyphens to dashes where appropriate
				modified = true;
				utilities.set_message ('maint_date_format');					-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language,
	-- uncomment the next three lines.  Not supported by en.wiki (for obvious reasons)
	-- set validation.date_name_xlate() second argument to true to translate English digits to local digits (will translate ymd dates)
	--		if validation.date_name_xlate (date_parameters_list, false) then
	--			modified = true;
	--		end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				LayDate = date_parameters_list['lay-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end
		else
			table.insert (z.message_tail, {utilities.set_message ('err_bad_date', {utilities.make_sep_list (#error_list, error_list)}, true)});	-- add this error message
		end
	end	-- end of do

	local ID_list_coins = identifiers.extract_ids (args);						-- gets identifiers and their values from args; this list used for COinS and source for build_id_list()
		if utilities.is_set (DoiBroken) and not ID_list_coins['DOI'] then
			table.insert (z.message_tail, {utilities.set_message ('err_doibroken_missing_doi', A:ORIGIN('DoiBroken'))});
		end
	local ID_access_levels = identifiers.extract_id_access_levels (args, ID_list_coins);
	local ID_list = identifiers.build_id_list (ID_list_coins, {IdAccessLevels = ID_access_levels, DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo = Embargo, Class = Class});	-- render identifiers
	
	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite ssrn}}, before generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then
		if not utilities.is_set (ID_list_coins[config.CitationClass:upper()]) then 	-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp; |citeseerx= required for their templates
			table.insert (z.message_tail, {utilities.set_message ('err_' .. config.CitationClass .. '_missing', {}, true)});	-- add error message
		end

		Periodical = ({['arxiv'] = 'arXiv', ['biorxiv'] = 'bioRxiv', ['citeseerx'] = 'CiteSeerX', ['ssrn'] = 'Social Science Research Network'})[config.CitationClass];
	end

	-- Link the title of the work if no |url= was provided, but we have a |pmc= or a |doi= with |doi-access=free

	if config.CitationClass == &quot;journal&quot; and not utilities.is_set (URL) and not utilities.is_set (TitleLink) and not utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) then -- TODO: remove 'none' once existing citations have been switched to 'off', so 'none' can be used as token for &quot;no title&quot; instead
    		if 'none' ~= cfg.keywords_xlate[auto_select] then -- if auto-linking not disabled
 	 		if identifiers.auto_link_urls[auto_select] then -- manual selection
		 		URL = identifiers.auto_link_urls[auto_select]; -- set URL to be the same as identifier's external link
 				URL_origin = cfg.id_handlers[auto_select:upper()].parameters[1]; -- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['pmc'] then -- auto-select PMC
				URL = identifiers.auto_link_urls['pmc']; -- set URL to be the same as the PMC external link if not embargoed
				URL_origin = cfg.id_handlers['PMC'].parameters[1]; -- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['doi'] then -- auto-select DOI
				URL = identifiers.auto_link_urls['doi'];
				URL_origin = cfg.id_handlers['DOI'].parameters[1];
			end
 	 	end

		if utilities.is_set (URL) and utilities.is_set (AccessDate) then		-- access date requires |url=; identifier-created URL is not |url=
			table.insert( z.message_tail, { utilities.set_message ( 'err_accessdate_missing_url', {}, true ) } );	-- add an error message
			AccessDate = '';													-- unset
		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not utilities.is_set (Title) and not utilities.is_set (TransTitle) and not utilities.is_set (ScriptTitle) then	-- has special case for cite episode
		table.insert( z.message_tail, { utilities.set_message ( 'err_citation_missing_title', {'episode' == config.CitationClass and 'series' or 'title'}, true ) } );
	end

	if utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) and
			utilities.in_array (config.CitationClass, {'journal', 'citation'}) and
			(utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and
			('journal' == Periodical_origin or 'script-journal' == ScriptPeriodical_origin) then	-- special case for journal cites
				Title = '';														-- set title to empty string
				utilities.set_message ('maint_untitled');						-- add maint cat
	end

	check_for_url ({															-- add error message when any of these parameters hold a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[Periodical_origin] = Periodical,
		[PublisherName_origin] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Chapter) and utilities.is_set (Title) and utilities.is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = metadata.COinS({
		['Periodical'] = utilities.strip_apostrophe_markup (Periodical),		-- no markup in the metadata
		['Encyclopedia'] = Encyclopedia,										-- just a flag; content ignored by ~/COinS
		['Chapter'] = metadata.make_coins_title (coins_chapter, ScriptChapter),	-- Chapter and ScriptChapter stripped of bold / italic wiki-markup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = metadata.make_coins_title (coins_title, ScriptTitle),		-- Title and ScriptTitle stripped of bold / italic wiki-markup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Quarter'] = COinS_date.rftquarter,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = coins_pages or metadata.get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName or Newsgroup,							-- any apostrophe markup already removed from PublisherName
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list_coins,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, and {{cite ssrn}} AFTER generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, CiteSeerX, or ssrn now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass and utilities.is_set (Newsgroup) then
		PublisherName = utilities.substitute (cfg.messages['newsgroup'], external_link( 'news:' .. Newsgroup, Newsgroup, Newsgroup_origin, nil ));
	end

	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local control = { 
			format = NameListStyle,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_names (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if utilities.is_set (Editors) then
				Editors, editor_etal = name_has_etal (Editors, editor_etal, false, 'editors');	-- find and remove variations on et al.
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
				end
				EditorCount = 2;												-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum , interviewer_etal = get_display_names (A['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal);
			Interviewers = list_people (control, interviewers_list, interviewer_etal);
		end
		do																		-- now do translators
			control.maximum , translator_etal = get_display_names (A['DisplayTranslators'], #t, 'translators', translator_etal);
			Translators = list_people (control, t, translator_etal);
		end
		do																		-- now do contributors
			control.maximum , contributor_etal = get_display_names (A['DisplayContributors'], #c, 'contributors', contributor_etal);
			Contributors = list_people (control, c, contributor_etal);
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_names (A['DisplayAuthors'], #a, 'authors', author_etal);

			last_first_list = list_people(control, a, author_etal);

			if utilities.is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors');	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if utilities.is_set (Authors) and utilities.is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
	-- an error message if the associated URL is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not utilities.is_set (URL) then
		if utilities.in_array (config.CitationClass, {&quot;web&quot;, &quot;podcast&quot;, &quot;mailinglist&quot;}) or		-- |url= required for cite web, cite podcast, and cite mailinglist
			('citation' == config.CitationClass and ('website' == Periodical_origin or 'script-website' == ScriptPeriodical_origin)) then	-- and required for {{citation}} with |website= or |script-website=
				table.insert( z.message_tail, { utilities.set_message ( 'err_cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if utilities.is_set (AccessDate) and not utilities.is_set (ChapterURL) then		-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { utilities.set_message ( 'err_accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURL_origin, OriginalFormat, OriginalAccess;
	UrlStatus = UrlStatus:lower();												-- used later when assembling archived text
	if utilities.is_set ( ArchiveURL ) then
		if utilities.is_set (ChapterURL) then 									-- if chapter-url= is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURL_origin = ChapterURL_origin;								-- name of |chapter-url= parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=

			if 'live' ~= UrlStatus then
				ChapterURL = ArchiveURL											-- swap-in the archive's URL
				ChapterURL_origin = A:ORIGIN('ArchiveURL')						-- name of |archive-url= parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived URLs
			end
		elseif utilities.is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURL_origin = URL_origin;									-- name of URL parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;

			if 'live' ~= UrlStatus then											-- if URL set then |archive-url= applies to it
				URL = ArchiveURL												-- swap-in the archive's URL
				URL_origin = A:ORIGIN('ArchiveURL')								-- name of archive URL parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived URLs
			end
 		end
	end

	if utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) then
			local chap_param;
			if utilities.is_set (Chapter) then									-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif utilities.is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif utilities.is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif utilities.is_set (ScriptChapter) then
				chap_param = ScriptChapter_origin;
			else utilities.is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if utilities.is_set (chap_param) then								-- if we found one
				table.insert( z.message_tail, { utilities.set_message ( 'err_chapter_ignored', {chap_param}, true ) } );	-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if utilities.is_set (Contribution) and 0 &lt; #c then						-- if this is a contribution with contributor(s)
			if utilities.in_array (Contribution:lower(), cfg.keywords_lists.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, ScriptChapter_origin, Chapter, Chapter_origin, TransChapter, TransChapter_origin, ChapterURL, ChapterURL_origin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if utilities.is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and utilities.is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter .. sepc .. ' ';
		elseif utilities.is_set (ChapterFormat) then							-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title
	local plain_title = false;
	local accept_title;
	Title, accept_title = utilities.has_accept_as_written (Title, true);		-- remove accept-this-as-written markup when it wraps all of &lt;Title&gt;
	if accept_title and ('' == Title) then										-- only support forced empty for now &quot;(())&quot;
		Title = cfg.messages['notitle'];										-- replace by predefined &quot;No title&quot; message
			-- TODO: utilities.set_message ( 'err_redundant_parameters', ...);	-- issue proper error message instead of muting	 
			ScriptTitle = '';													-- just mute for now	 
			TransTitle = '';													-- just mute for now
 		plain_title = true;														-- suppress text decoration for descriptive title
		utilities.set_message ('maint_untitled');								-- add maint cat
	end

	if not accept_title then -- &lt;Title&gt; not wrapped in accept-as-written markup
		if '...' == Title:sub (-3) then											-- if ellipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%' .. sepc .. '$', '');			-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end

		if utilities.is_set (ArchiveURL) and is_archived_copy (Title) then
			utilities.set_message ('maint_archived_copy');						-- add maintenance category before we modify the content of Title
		end

		if is_generic_title (Title) then
			table.insert (z.message_tail, {utilities.set_message ( 'err_generic_title', {}, true ) } );	-- set an error message
		end
	end

	if (not plain_title) and (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) or
		('map' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)))) then		-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from module provided quote marks
			Title = utilities.wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle, 'script-title');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
			TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );
	elseif plain_title or ('report' == config.CitationClass) then								-- no styling for cite report and descriptive titles (otherwise same as above)
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = utilities.wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if utilities.is_set (TransTitle) then
		if utilities.is_set (Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. utilities.set_message ( 'err_trans_missing_title', {'title'} );
		end
	end

	if utilities.is_set (Title) then											-- TODO: is this the right place to be making Wikisource URLs?
		if utilities.is_set (TitleLink) and utilities.is_set (URL) then
			table.insert( z.message_tail, { utilities.set_message ( 'err_wikilink_in_url', {}, true ) } );	-- set an error message because we can't have both
			TitleLink = '';														-- unset
		end
		
		if not utilities.is_set (TitleLink) and utilities.is_set (URL) then
			Title = external_link (URL, Title, URL_origin, UrlAccess) .. TransTitle .. TransError .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif utilities.is_set (TitleLink) and not utilities.is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = utilities.make_wikilink (TitleLink, Title) .. TransTitle .. TransError;
			end
		else
			local ws_url, ws_label, L;											-- Title has italic or quote markup by the time we get here which causes is_wikilink() to return 0 (not a wikilink)
			ws_url, ws_label, L = wikisource_url_make (Title:gsub('[\'&quot;](.-)[\'&quot;]', '%1'));	-- make ws URL from |title= interwiki link (strip italic or quote markup); link portion L becomes tooltip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = Title .. TransTitle .. TransError;
			end
		end
	else
		Title = TransTitle .. TransError;
	end

	if utilities.is_set (Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if utilities.is_set (Conference) then
		if utilities.is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURL_origin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif utilities.is_set (ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURL_origin, nil );
	end

	if not utilities.is_set (Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if utilities.is_set (Minutes) then
			if utilities.is_set (Time) then
				table.insert( z.message_tail, { utilities.set_message ( 'err_redundant_parameters', {utilities.wrap_style ('parameter', 'minutes') .. ' and ' .. utilities.wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if utilities.is_set (Time) then
				local TimeCaption = A['TimeCaption']
				if not utilities.is_set (TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = utilities.is_set (At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = utilities.is_set (Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Sections = A['Sections'];											-- Section (singular) is an alias of Chapter so set earlier
		local Inset = A['Inset'];
		
		if utilities.is_set ( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if utilities.is_set ( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif utilities.is_set ( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if utilities.is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc.
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	Others = utilities.is_set (Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if utilities.is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if utilities.is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	TitleNote = utilities.is_set (TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if utilities.is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			utilities.set_message ('maint_extra_text', 'edition');				-- add maint cat
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = utilities.is_set (Series) and wrap_msg ('series', {sepc, Series}) or &quot;&quot;;	-- not the same as SeriesNum
	OrigDate = utilities.is_set (OrigDate) and wrap_msg ('origdate', OrigDate) or '';
	Agency = utilities.is_set (Agency) and wrap_msg ('agency', {sepc, Agency}) or &quot;&quot;;
	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	Via = utilities.is_set (Via) and  wrap_msg ('via', Via) or '';

	if utilities.is_set (AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = utilities.substitute (retrv_text, AccessDate);				-- add retrieved text

		AccessDate = utilities.substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if utilities.is_set (ID) then ID = sepc .. &quot; &quot; .. ID; end
   	if &quot;thesis&quot; == config.CitationClass and utilities.is_set (Docket) then
		ID = sepc .. &quot; Docket &quot; .. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and utilities.is_set (Docket) then		-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	if utilities.is_set (URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URL_origin, UrlAccess );
	end

	if utilities.is_set (Quote) or utilities.is_set (TransQuote) or utilities.is_set (ScriptQuote) then

		if utilities.is_set (Quote) then
			if Quote:sub(1, 1) == '&quot;' and Quote:sub(-1, -1) == '&quot;' then			-- if first and last characters of quote are quote marks
				Quote = Quote:sub(2, -2);										-- strip them off
			end
		end

		Quote = utilities.wrap_style ('quoted-text', Quote ); 	-- wrap in &lt;q&gt;...&lt;/q&gt; tags
	
		if utilities.is_set (ScriptQuote) then
			Quote = script_concatenate (Quote, ScriptQuote, 'script-quote'); -- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after quote is wrapped
		end

		if utilities.is_set (TransQuote) then
			if TransQuote:sub(1, 1) == '&quot;' and TransQuote:sub(-1, -1) == '&quot;' then -- if first and last characters of |trans-quote are quote marks
				TransQuote = TransQuote:sub(2, -2); -- strip them off
			end
			Quote = Quote .. &quot; &quot; .. utilities.wrap_style ('trans-quoted-title', TransQuote );
		end

		if utilities.is_set (QuotePage) or utilities.is_set (QuotePages) then	-- add page prefix
			local quote_prefix = '';
			if utilities.is_set (QuotePage) then
				if not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePage}), '', '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePage}), '', '', '';
				end
			elseif utilities.is_set (QuotePages) then
				if tonumber(QuotePages) ~= nil and not NoPP then				-- if only digits, assume single page
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePages}), '', '';
				elseif not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['pp-prefix'], {sepc, QuotePages}), '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePages}), '', '';
				end
			end
                        
			Quote = quote_prefix .. &quot;: &quot; .. Quote;
		else
			Quote = sepc .. &quot; &quot; .. Quote;
		end

		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if utilities.is_set (ArchiveURL) then
		local arch_text;
		if not utilities.is_set (ArchiveDate) then
			ArchiveDate = utilities.set_message ('err_archive_missing_date');
		end
		if &quot;live&quot; == UrlStatus then
			arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. utilities.substitute ( cfg.messages['archived-live'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil ) .. ArchiveFormat, ArchiveDate } );
			if not utilities.is_set (OriginalURL) then
				Archived = Archived .. &quot; &quot; .. utilities.set_message ('err_archive_missing_url');							   
			end
		elseif utilities.is_set (OriginalURL) then								-- UrlStatus is empty, 'dead', 'unfit', 'usurped', 'bot: unknown'
			if utilities.in_array (UrlStatus, {'unfit', 'usurped', 'bot: unknown'}) then
				arch_text = cfg.messages['archived-unfit'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. &quot; &quot; .. arch_text .. ArchiveDate;				-- format already styled
				if 'bot: unknown' == UrlStatus then
					utilities.set_message ('maint_bot_unknown');				-- and add a category if not already added
				else
					utilities.set_message ('maint_unfit');						-- and add a category if not already added
				end
			else																-- UrlStatus is empty, 'dead'
				arch_text = cfg.messages['archived-dead'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. &quot; &quot; .. utilities.substitute ( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURL_origin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else																	-- OriginalUrl not set
			arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. utilities.substitute ( arch_text, 
				{ utilities.set_message ('err_archive_missing_url'), ArchiveDate } );
		end
	elseif utilities.is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if utilities.is_set (LayURL) then
		if utilities.is_set (LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if utilities.is_set (LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. utilities.safe_for_italics (LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif utilities.is_set (LayFormat) then									-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if utilities.is_set (Transcript) then
		if utilities.is_set (TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURL_origin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif utilities.is_set (TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURL_origin, nil );
	end

	local Publisher;
	if utilities.is_set (PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if utilities.is_set (PublisherName) then
		if utilities.is_set (PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif utilities.is_set (PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical)) then
		if utilities.is_set (Title) or utilities.is_set (TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		else 
			Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		end
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then									-- cite speech only
		TitleNote = &quot; (Speech)&quot;;												-- annotate the citation
		if utilities.is_set (Periodical) then									-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if utilities.is_set (Conference) then								-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;							-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
		if utilities.is_set (Others) then Others = safe_join ({Others, sepc .. &quot; &quot;}, sepc) end		-- add terminal punctuation &amp; space; check for dup sepc; TODO why do we need to do this here?
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (Periodical) then		-- special cases for book cites
		if utilities.is_set (Contributors) then									-- when we are citing foreword, preface, introduction, etc.
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if utilities.is_set (Chapter) then										-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif utilities.is_set (Periodical) then								-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon;
	if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then	-- special case for cite AV media &amp; cite episode position transcript
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, Lay, Quote }, sepc );
	else
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, Lay, Quote }, sepc );
	end
	
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if utilities.is_set (Date) then
		if utilities.is_set (Authors) or utilities.is_set (Editors) then		-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date .. &quot;)&quot; .. OrigDate .. sepc .. &quot; &quot;;				-- in parentheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon, -1, -1) == sepc) then						-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigDate;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigDate;							-- Date begins with sepc
			end
		end
	end	
	if utilities.is_set (Authors) then
		if (not utilities.is_set (Date)) then									-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if utilities.is_set (Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then
					in_text = in_text:lower()									-- lowercase for cs2
				end
			end
			if EditorCount &lt;= 1 then
				post_text = &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot;;				-- be consistent with no-author, no-date case
			else
				post_text = &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot;;
			end
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Contributors) then									-- book cite and we're citing the intro, preface, etc.
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if utilities.is_set (Editors) and utilities.is_set (Date) then		-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not utilities.is_set (Date)) then								-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif utilities.is_set (Editors) then
		if utilities.is_set (Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if utilities.is_set (PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc ); 								--Deals with italics, spaces, etc.
		text = text:sub(1, -sepc:len() - 1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if utilities.is_set (config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = string.format ('%s %s %s', 'citation', config.CitationClass, utilities.is_set (Mode) and Mode or 'cs1');	-- class=citation required for blue highlight when used with |ref=
	else
		options.class = string.format ('%s %s', 'citation', utilities.is_set (Mode) and Mode or 'cs2');
	end
	
	if utilities.is_set (Ref) and 'none' ~= cfg.keywords_xlate[Ref:lower()] then
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			if #namelist &gt; 0 then												-- if there are names in namelist
				id = anchor_id (namelist, year);								-- go make the CITEREF anchor
			else
				id = '';														-- unset
			end
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;(.-)&lt;/span&gt;&quot;, &quot;%1&quot;):gsub(&quot;%b&lt;&gt;&quot;, &quot;&quot;)) &lt;= 2 then	-- remove &lt;span&gt; tags and other HTML-like markup; then get length of what remains
		z.error_categories = {};
		text = utilities.set_message ('err_empty_citation');
		z.message_tail = {};
	end
	
	local render = {};															-- here we collect the final bits for concatenation into the rendered citation

	if utilities.is_set (options.id) then										-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render, utilities.substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text}));	-- when |ref= is set
	else
		table.insert (render, utilities.substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text}));	-- all other cases
	end		

	table.insert (render, utilities.substitute (cfg.presentation['ocins'], {OCinSoutput}));	-- append metadata to the citation

	if 0 ~= #z.message_tail then
		table.insert (render, ' ');
		for i,v in ipairs( z.message_tail ) do
			if utilities.is_set (v[1]) then
				if i == #z.message_tail then
					table.insert (render, utilities.error_comment ( v[1], v[2] ));
				else
					table.insert (render, utilities.error_comment ( v[1] .. &quot;; &quot;, v[2] ));
				end
			end
		end
	end

	if 0 ~= #z.maintenance_cats then
		local maint_msgs = {};													-- here we collect all of the maint messages
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			local maint = {};													-- here we assemble a maintenence message
			table.insert (maint, v);											-- maint msg is the category name
			table.insert (maint, ' (');											-- open the link text
			table.insert (maint, utilities.make_wikilink (':Category:' .. v, 'link'));	-- add the link
			table.insert (maint, ')');											-- and close it
			table.insert (maint_msgs, table.concat (maint));					-- assemble new maint message and add it to the maint_msgs table
		end
		table.insert (render, utilities.substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs, ' ')));	-- wrap the group of maint message with proper presentation and save
	end
	
	if not no_tracking_cats then
		for _, v in ipairs( z.error_categories ) do
			table.insert (render, utilities.make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			table.insert (render, utilities.make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.properties_cats ) do								-- append properties categories
			table.insert (render, utilities.make_wikilink ('Category:' .. v));
		end
	elseif 'nocat' == A:ORIGIN('NoTracking') then								-- peculiar special case; can't track nocat without tracking nocat
		table.insert (render, utilities.make_wikilink ('Category:CS1 maint: nocat'));	-- hand-set this category because it is supposed to be temporary
	end

	return table.concat (render);	
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class, empty)
	local name = tostring (name);
	local state;
	local function state_test (state, name)										-- local function to do testing of state values
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			if empty then return nil; end										-- deprecated empty parameters are treated as unknowns
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
		return nil;
	end		

	if name:find ('#') then														-- # is a cs1|2 reserved character so parameters with # not permitted
		return nil;
	end

	if utilities.in_array (cite_class, whitelist.preprint_template_list ) then	-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[name];
		if true == state_test (state, name) then return true; end

		state = whitelist.preprint_arguments[cite_class][name];					-- look in the parameter-list for the template identified by cite_class
		if true == state_test (state, name) then return true; end

																				-- limited enumerated parameters list
		name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
		state = whitelist.limited_numbered_arguments[name];
		if true == state_test (state, name) then return true; end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates

	if utilities.in_array (cite_class, whitelist.unique_param_template_list) then 	-- experiment for template-specific parameters for templates that accept parameters from the basic argument list
		state = whitelist.unique_arguments[cite_class][name];					-- look in the template-specific parameter-lists for the template identified by cite_class
		if true == state_test (state, name) then return true; end
	end																			-- if here, fall into general validation
		
	state = whitelist.basic_arguments[name];									-- all other templates; all normal parameters allowed
	if true == state_test (state, name) then return true; end

																				-- all enumerated parameters allowed
	name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );												-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
	state = whitelist.numbered_arguments[name];
	if true == state_test (state, name) then return true; end

	return false;																-- not supported because not found or name is set to nil
end


--[=[-------------------------&lt; I N T E R _ W I K I _ C H E C K &gt;----------------------------------------------

check &lt;value&gt; for inter-language interwiki-link markup.  &lt;prefix&gt; must be a MediaWiki-recognized language
code.  when these values have the form (without leading colon):
	[[&lt;prefix&gt;:link|label]] return label as plain-text
	[[&lt;prefix&gt;:link]] return &lt;prefix&gt;:link as plain-text

return value as is else

]=]

local function inter_wiki_check (parameter, value)
	local prefix = value:match ('%[%[(%a+):');									-- get an interwiki prefix if one exists
	local _;
	
	if prefix and cfg.inter_wiki_map[prefix:lower()] then						-- if prefix is in the map, needs preceding colon so
		table.insert( z.message_tail, {utilities.set_message ('err_bad_paramlink', parameter)});	-- emit an error message
		_, value, _ = utilities.is_wikilink (value);							-- extract label portion from wikilink
	end
	return value;
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe.  There are two tests made:
	{{cite ... |title=Title access-date=2016-03-17}}	-- the first parameter has a value and whitespace separates that value from the missing pipe parameter name
	{{cite ... |title=access-date=2016-03-17}}			-- the first parameter has no value (whitespace after the first = is trimmed by MediaWiki)
cs1|2 shares some parameter names with XML/HTML attributes: class=, title=, etc.  To prevent false positives XML/HTML
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (parameter, value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove XML/HTML tags because attributes: class=, title=, etc.

	capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then										-- if the capture is a valid parameter name
		table.insert( z.message_tail, {utilities.set_message ('err_missing_pipe', parameter)});
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ P U N C T &gt;--------------------------------------

look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_punc (param, value)
	if 'number' == type (param) then
		return;
	end
	
	param = param:gsub ('%d+', '#');											-- enumerated name-list mask params allow terminal punct; normalize 
	if cfg.punct_skip[param] then
		return;																	-- parameter name found in the skip table so done
	end
	
	if value:match ('[,;:]$') then
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
end


--[[--------------------------&lt; C I T A T I O N &gt;--------------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

local function citation(frame)
	Frame = frame;																-- save a copy in case we need to display an error message in preview mode
	local pframe = frame:getParent()
	local styles;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		styles = 'Module:Citation/CS1/sandbox/styles.css';
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
		styles = 'Module:Citation/CS1/styles.css';
	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the selected cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text, error_state;

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do											-- get parameters from the {{#invoke}} frame
		config[k] = v;
	--	args[k] = v;															-- crude debug support that allows us to render a citation from module {{#invoke:}}; skips parameter validation; TODO: keep?
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	local empty_unknowns = {};													-- sequence table to hold empty unknown params for error message listing
	for k, v in pairs( pframe.args ) do											-- get parameters from the parent (template) frame
		v = mw.ustring.gsub (v, '^%s*(.-)%s*$', '%1');							-- trim leading/trailing whitespace; when v is only whitespace, becomes empty string
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = utilities.set_message ( 'err_text_ignored', {v}, true );
					end
				elseif validate( k:lower(), config.CitationClass ) then 
					error_text, error_state = utilities.set_message ( 'err_parameter_ignored_suggest', {k, k:lower()}, true );	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no capture in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = utilities.substitute (param, capture);		-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text, error_state = utilities.set_message ('err_parameter_ignored_suggest', {k, param}, true);	-- set the suggestion error message
							else
								error_text, error_state = utilities.set_message ( 'err_parameter_ignored', {param}, true );	-- suggested param not supported by this template
								v = '';											-- unset
							end
						end
					end
					if not utilities.is_set (error_text) then					-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = utilities.set_message ( 'err_parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = utilities.set_message ( 'err_parameter_ignored', {k}, true );
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end

			args[k] = v;														-- save this parameter and its value

		elseif not utilities.is_set (v) then									-- for empty parameters
			if not validate (k, config.CitationClass, true) then				-- is this empty parameter a valid parameter
				table.insert (empty_unknowns, utilities.wrap_style ('parameter', k));	-- format for error message and add to the list
			end
																				-- crude debug support that allows us to render a citation from module {{#invoke:}} TODO: keep?
	--	elseif args[k] ~= nil or (k == 'postscript') then						-- when args[k] has a value from {{#invoke}} frame (we don't normally do that)
	--		args[k] = v;														-- overwrite args[k] with empty string from pframe.args[k] (template frame); v is empty string here
		end																		-- not sure about the postscript bit; that gets handled in parameter validation; historical artifact?
	end	

	if 0 ~= #empty_unknowns then												-- create empty unknown error message
		table.insert (z.message_tail, {utilities.set_message ('err_param_unknown_empty', {
			1 == #empty_unknowns and '' or 's',
			utilities.make_sep_list (#empty_unknowns, empty_unknowns)
			}, true )});
	end

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);											-- look for invisible characters
		end
		has_extraneous_punc (k, v);												-- look for extraneous terminal punctuation in parameter values
		missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?
		args[k] = inter_wiki_check (k, v);										-- when language interwiki-linked parameter missing leading colon replace with wiki-link label
	end

	return table.concat ({citation0( config, args), frame:extensionTag ('templatestyles', '', {src=styles})});
end

--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {citation = citation};</text>
      <sha1>p3s12cw5ycqpcgd4av6an8o035pnr5p</sha1>
    </revision>
    <revision>
      <id>4736</id>
      <parentid>4735</parentid>
      <timestamp>2020-10-10T17:01:46Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4736</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="204428" sha1="6t8lqyk2oib1zd3nfnj2lpimhw8jygg" xml:space="preserve">
require('Module:No globals');

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------

each of these counts against the Lua upvalue limit

]]

local validation;																-- functions in Module:Citation/CS1/Date_validation

local utilities;																-- functions in Module:Citation/CS1/Utilities
local z ={};																	-- table of tables in Module:Citation/CS1/Utilities

local identifiers;																-- functions and tables in Module:Citation/CS1/Identifiers
local metadata;																	-- functions in Module:Citation/CS1/COinS
local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

declare variables here that have page-wide scope that are not brought in from other modules; that are created here and used here

]]

local added_deprecated_cat;														-- Boolean flag so that the category is added only once
local added_vanc_errs;															-- Boolean flag so we only emit one Vancouver error / category

local Frame;																	-- holds the module's frame table


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if utilities.is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a Boolean declared in page scope variables above

]]

local function add_vanc_error (source)
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { utilities.set_message ( 'err_vancouver', {source}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a URI scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of TLDs: https://www.iana.org/domains/root/db

RFC 952 (modified by RFC 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the TLD.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a URL with a scheme) will be stripped
here.  Perhaps not necessary but retained in case it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ASCII characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the TLD) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and TLD or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%w]') then											-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at Wikisource
		return false;
	end

	local patterns = {															-- patterns that look like URLs
		'%f[%w][%w][%w%-]+[%w]%.%a%a+$',										-- three or more character hostname.hostname or hostname.tld
		'%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$',									-- internationalized domain name with ACE prefix
		'%f[%a][qxz]%.com$',													-- assigned one character .com hostname (x.com times out 2015-12-10)
		'%f[%a][iq]%.net$',														-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		'%f[%w][%w]%.%a%a$',													-- one character hostname and ccTLD (2 chars)
		'%f[%w][%w][%w]%.%a%a+$',												-- two character hostname and TLD
		'^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?',								-- IPv4 address
		}

	for _, pattern in ipairs (patterns) do										-- loop through the patterns list
		if domain:match (pattern) then
			return true;														-- if a match then we think that this thing that purports to be a URL is a URL
		end
	end

	for _, d in ipairs ({'cash', 'company', 'today', 'org'}) do					-- look for single letter second level domain names for these top level domains
		if domain:match ('%f[%w][%w]%.' .. d) then
			return true
		end
	end
	return false;																-- no matches, we don't know what this thing is
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a URL appear to be a valid URL; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if utilities.is_set (scheme) then											-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when URL is protocol-relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a URL into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following TLD) (if any) and any path(/), query(?) or fragment(#).

If protocol-relative URL, return nil scheme and domain else return nil for both scheme and domain.

When not protocol-relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Any URL that does not have news: scheme must have authority indicator (//).  TODO: are there other common schemes
like news: that don't use authority indicator?

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol-relative URL
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		if utilities.is_set (authority) then
			authority = authority:gsub ('//', '', 1);							-- replace place 1 pair of '/' with nothing;
			if utilities.is_set(authority) then									-- if anything left (1 or 3+ '/' where authority should be) then
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		else
			if not scheme:match ('^news:') then									-- except for news:..., MediaWiki won't link URLs that do not have authority indicator; TODO: a better way to do this test?
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link=, etc. for properly formatted content: no wikilinks, no URLs

Link parameters are to hold the title of a Wikipedia article, so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki URLs and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid URL (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid URL (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from URL; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid URL
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wiki-linked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

check &lt;link&gt; for inter-language interwiki-link prefix.  prefix must be a MediaWiki-recognized language
code and must begin with a colon.

]]

local function link_title_ok (link, lorig, title, torig)
local orig;
	if utilities.is_set (link) then 											-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		elseif link:match ('^%a+:') then										-- if the link is what looks like an interwiki
			local prefix = link:match ('^(%a+):'):lower();						-- get the interwiki prefix

			if cfg.inter_wiki_map[prefix] then									-- if prefix is in the map, must have preceding colon
				orig = lorig;													-- flag as error
			end
		end
	end

	if utilities.is_set (orig) then
		link = '';																-- unset
		table.insert( z.message_tail, { utilities.set_message ( 'err_bad_paramlink', orig)});	-- URL or wikilink in |title= with |title-link=;
	end
	
	return link;																-- link if ok, empty string else
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the URL into scheme and domain
portions, or for protocol-relative (//example.com) URLs, just the domain.  Use is_url() to validate the two
portions of the URL.  If both are valid, or for protocol-relative if domain is valid, return true, else false.

Because it is different from a standard URL, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper URL
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from URL;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a URL.  The test will also find external wikilinks
that use protocol-relative URLs. Also finds bare URLs.

The frontier pattern prevents a match on interwiki-links which are similar to scheme:path URLs.  The tests that
find bracketed URLs are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext. wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol-relative ext. wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare URL with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol-relative bare URL: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a URL
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a URL add an error message
			if utilities.is_set(error_message) then								-- once we've added the first portion of the error message ...
				error_message = error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message = error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if utilities.is_set (error_message) then									-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { utilities.set_message ( 'err_param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { utilities.set_message ( 'err_wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source, access)
	local error_str = &quot;&quot;;
	local domain;
	local path;
	local base_url;

	if not utilities.is_set ( label ) then
		label = URL;
		if utilities.is_set ( source ) then
			error_str = utilities.set_message ( 'err_bare_url_missing_title', { utilities.wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = utilities.set_message ( 'err_bad_url', {utilities.wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the URL into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['['] = '%5b', [']'] = '%5d'});					-- replace '[' and ']' with their percent-encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wiki-markup URL

	if utilities.is_set (access) then											-- access level (subscription, registration, limited)
		base_url = utilities.substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end
	
	return table.concat ({base_url, error_str});
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a Boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { utilities.set_message ( 'err_deprecated_params', {name}, true ) } );	-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wiki-markup) are not kerned.

Replaces Unicode quote marks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc.; not for book titles.

]=]

local function kern_quotes (str)
	local cap = '';
	local cap2 = '';
	local wl_type, label, link;

	wl_type, label, link = utilities.is_wikilink (str);							-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-wl-both'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = utilities.substitute (cfg.presentation['kern-wl-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-wl-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label = mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label = mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap, cap2 = mw.ustring.match (label, &quot;^([\&quot;\'])([^\'].+)&quot;);				-- match leading double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-left'], {cap, cap2});
		end
	
		cap, cap2 = mw.ustring.match (label, &quot;^(.+[^\'])([\&quot;\'])$&quot;)				-- match trailing double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-right'], {cap, cap2});
		end
		
		if 2 == wl_type then
			str = utilities.make_wikilink (link, label);						-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin-based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate RTL languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO 639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO 639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title=, |script-chapter=, |script-&lt;periodical&gt;=

]]

local function format_script_value (script_value, script_param)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%l?%s*:') then									-- if first 3 or 4 non-space characters are script language prefix
		lang = script_value:match('^(%l%l%l?)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not utilities.is_set (lang) then
			table.insert( z.message_tail, { utilities.set_message ( 'err_script_parameter', {script_param, 'missing title part'}, true ) } );		-- prefix without 'title'; add error message
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_code_remap[lang] or mw.language.fetchLanguageName( lang, cfg.this_wiki_code );	-- get language name so that we can use it to categorize
		if utilities.is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l+%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if utilities.in_array (lang, cfg.script_lang_codes) then
				utilities.add_prop_cat ('script_with_name', {name, lang})
			else
				table.insert( z.message_tail, { utilities.set_message ( 'err_script_parameter', {script_param, 'unknown language code'}, true ) } );	-- unknown script-language; add error message
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			table.insert( z.message_tail, { utilities.set_message ( 'err_script_parameter', {script_param, 'invalid language code'}, true ) } );		-- invalid language code; add error message
			lang = '';															-- invalid so set lang to empty string
		end
	else
		table.insert( z.message_tail, { utilities.set_message ( 'err_script_parameter', {script_param, 'missing prefix'}, true ) } );				-- no language code prefix; add error message
	end
	script_value = utilities.substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is RTL

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script, script_param)
	if utilities.is_set (script) then
		script = format_script_value (script, script_param);					-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; returns empty string on error
		if utilities.is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not utilities.is_set ( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return utilities.substitute ( msg, str );								-- including template text
	else
		return utilities.substitute ( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;----------------------------------------

Makes a Wikisource URL from Wikisource interwiki-link.  Returns the URL and appropriate label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;
	local wikisource_prefix = table.concat ({'https://', cfg.this_wiki_code, '.wikisource.org/wiki/'});

	wl_type, D, L = utilities.is_wikilink (str);								-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 1 == wl_type then													-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end
	
	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable URL
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent encoding of fragment marker
	end

	return ws_url, ws_label, L or D;											-- return proper URL or nil and a label or nil
end


--[[--------------------------&lt; F O R M A T _ P E R I O D I C A L &gt;--------------------------------------------

Format the three periodical parameters: |script-&lt;periodical&gt;=, |&lt;periodical&gt;=, and |trans-&lt;periodical&gt;= into a single Periodical meta-
parameter.

]]

local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)
	local periodical_error = '';

	if not utilities.is_set (periodical) then
		periodical = '';														-- to be safe for concatenation
	else
		periodical = utilities.wrap_style ('italic-title', periodical);			-- style 
	end

	periodical = script_concatenate (periodical, script_periodical, script_periodical_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (trans_periodical) then
		trans_periodical = utilities.wrap_style ('trans-italic-title', trans_periodical);
		if utilities.is_set (periodical) then
			periodical = periodical .. ' ' .. trans_periodical;
		else																	-- here when trans-periodical without periodical or script-periodical
			periodical = trans_periodical;
			periodical_error = ' ' .. utilities.set_message ('err_trans_missing_title', {'periodical'});
		end
	end

	return periodical .. periodical_error;
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (script_chapter, script_chapter_source, chapter, chapter_source, trans_chapter, trans_chapter_source, chapter_url, chapter_url_source, no_quotes, access)
	local chapter_error = '';

	local ws_url, ws_label, L = wikisource_url_make (chapter);					-- make a wikisource URL and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', '');										-- replace underscore separaters with space characters
		chapter = ws_label;
	end

	if not utilities.is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from module provided quote marks
			chapter = utilities.wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, script_chapter, script_chapter_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (chapter_url) then
		chapter = external_link (chapter_url, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');	-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if utilities.is_set (trans_chapter) then
		trans_chapter = utilities.wrap_style ('trans-quoted-title', trans_chapter);
		if utilities.is_set (chapter) then
			chapter = chapter .. ' ' .. trans_chapter;
		else																	-- here when trans_chapter without chapter or script-chapter
			chapter = trans_chapter;
			chapter_source = trans_chapter_source:match ('trans%-?(.+)');		-- when no chapter, get matching name from trans-&lt;param&gt;
			chapter_error = ' ' .. utilities.set_message ('err_trans_missing_title', {chapter_source});
		end
	end

	return chapter .. chapter_error;
end


--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for non-printable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the Wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i = 1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no Unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char = cfg.invisible_chars[i][1]									-- the character or group name
		local pattern = cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position and (char == 'zero width joiner') then						-- if we found a zero-width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- it's ok if one of the Indic scripts
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and utilities.in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { utilities.set_message ( 'err_invisible_char', {err_msg, utilities.wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i = i+1;																-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper ( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function ( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = utilities.select_one ( args, list, 'err_redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] .. ': ' .. k);
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap = '';
	local cap2 = '';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = utilities.substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = utilities.substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if utilities.is_set (title_type) then
		if 'none' == cfg.keywords_xlate[title_type] then
			title_type = '';													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash under certain conditions.  The hyphen must separate like items; unlike items are
returned unmodified.  These forms are modified:
	letter - letter (A - B)
	digit - digit (4-5)
	digit separator digit - digit separator digit (4.1-4.5 or 4-1-4-5)
	letterdigit - letterdigit (A1-A5) (an optional separator between letter and digit is supported – a.1-a.5 or a-1-a-5)
	digitletter - digitletter (5a - 5d) (an optional separator between letter and digit is supported – 5.a-5.d or 5-a-5-d)

any other forms are returned unmodified.

str may be a comma- or semicolon-separated list

]]

local function hyphen_to_dash( str )
	if not utilities.is_set (str) then
		return str;
	end

	local accept;																-- Boolean
	str, accept = utilities.has_accept_as_written (str);						-- remove accept-this-as-written markup when it wraps all of str
	if accept then
		return str;																-- when markup removed, nothing to do, we're done
	end

	str = str:gsub ('&amp;[nm]dash;', {['&amp;ndash;'] = '–', ['&amp;mdash;'] = '—'});		-- replace &amp;mdash; and &amp;ndash; entities with their characters; semicolon mucks up the text.split
	str = str:gsub ('&amp;#45;', '-');												-- replace HTML numeric entity with hyphen character
	str = str:gsub ('&amp;nbsp;', ' ');												-- replace &amp;nbsp; entity with generic keyboard space character
	
	local out = {};
	local list = mw.text.split (str, '%s*[,;]%s*');								-- split str at comma or semicolon separators if there are any

	for _, item in ipairs (list) do												-- for each item in the list
		if mw.ustring.match (item, '^%w*[%.%-]?%w+%s*[%-–—]%s*%w*[%.%-]?%w+$') then	-- if a hyphenated range or has endash or emdash separators
			if item:match ('^%a+[%.%-]?%d+%s*%-%s*%a+[%.%-]?%d+$') or			-- letterdigit hyphen letterdigit (optional separator between letter and digit)
				item:match ('^%d+[%.%-]?%a+%s*%-%s*%d+[%.%-]?%a+$') or			-- digitletter hyphen digitletter (optional separator between digit and letter)
				item:match ('^%d+[%.%-]%d+%s*%-%s*%d+[%.%-]%d+$') or			-- digit separator digit hyphen digit separator digit
				item:match ('^%d+%s*%-%s*%d+$') or								-- digit hyphen digit
				item:match ('^%a+%s*%-%s*%a+$') then							-- letter hyphen letter
					item = item:gsub ('(%w*[%.%-]?%w+)%s*%-%s*(%w*[%.%-]?%w+)', '%1–%2');	-- replace hyphen, remove extraneous space characters
			else
				item = mw.ustring.gsub (item, '%s*[–—]%s*', '–');				-- for endash or emdash separated ranges, replace em with en, remove extraneous whitespace
			end
		end
		item = utilities.has_accept_as_written (item);							-- remove accept-this-as-written markup when it wraps all of str
		table.insert (out, item);												-- add the (possibly modified) item to the output table
	end

	return table.concat (out, ', ');											-- concatenate the output table into a comma separated string
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'duplicate character'
		if 1 == #duplicate_char then											-- for single byte ASCII characters use the string library functions
			f.gsub = string.gsub
			f.match = string.match
			f.sub = string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub = mw.ustring.gsub
			f.match = mw.ustring.match
			f.sub = mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1, 1) == '&lt;' then										-- special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove HTML markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1, 1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc.?
				trim = false;
				end_chr = f.sub(str, -1, -1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr .. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1, -2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5, -1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3, -1) == duplicate_char .. '&quot;]' then		-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2, -1) == duplicate_char .. &quot;]&quot; then		-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2, -1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1, -3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains HTML markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows HTML markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;------------------------------------------------------------

returns true is suffix is properly formed Jr, Sr, or ordinal in the range 1–9.  Puncutation not allowed.

]]

local function is_suffix (suffix)
	if utilities.in_array (suffix, {'Jr', 'Sr', 'Jnr', 'Snr', '1st', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written outside of the code editor and pasted here because the code editor gets confused between character insertion point and cursor position.
The test has been rewritten to use decimal character escape sequence for the individual bytes of the Unicode characters so that it is not necessary
to use an external editor to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first, suffix)
	if not suffix then
		if first:find ('[,%s]') then											-- when there is a space or comma, might be first name/initials + generational suffix
			first = first:match ('(.-)[,%s]+');									-- get name/initials
			suffix = first:match ('[,%s]+(.+)$');								-- get generational suffix
		end
	end
	if utilities.is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error (cfg.err_msg_supl.suffix);
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error (cfg.err_msg_supl['non-Latin char']);
			return false;														-- not a string of Latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-style=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc.) to be rendered as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the Unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just initials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error (cfg.err_msg_supl.suffix);					-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word

	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i], 1, 1));				-- insert the initial at end of initials table
		end
		i = i+1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; L I S T _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors, contributors, editors, interviewers, translators) 

names in the list will be linked when
	|&lt;name&gt;-link= has a value
	|&lt;name&gt;-mask- does NOT have a value; masked names are presumed to have been rendered previously so should have been linked there

when |&lt;name&gt;-mask=0, the associated name is not rendered

]]

local function list_people (control, people, etal)
	local sep;
	local namesep;
	local format = control.format;
	local maximum = control.maximum;
	local lastauthoramp = control.lastauthoramp;							-- TODO: delete after deprecation
	local name_list = {};

	if 'vanc' == format then													-- Vancouver-like name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between names is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
		lastauthoramp = nil;												-- TODO: delete after deprecation	-- unset because isn't used by Vancouver style
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between names is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub (-1, -1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if utilities.is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end		-- returned 0 is for EditorCount; not used for other names
	
	for i, person in ipairs (people) do
		if utilities.is_set (person.last) then
			local mask = person.mask;
			local one;
			local sep_one = sep;

			if utilities.is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			end
			
			if mask then
				local n = tonumber (mask);										-- convert to a number if it can be converted; nil else
				if n then
					one = 0 ~= n and string.rep(&quot;&amp;mdash;&quot;,n) or nil;			-- make a string of (n &gt; 0) mdashes, nil else, to replace name
					person.link = nil;											-- don't create link to name if name is replaces with mdash string or has been set nil
				else
					one = mask;													-- replace name with mask text (must include name-list separator)
					sep_one = &quot; &quot;;												-- modify name-list separator
				end
			else
				one = person.last;												-- get surname
				local first = person.first										-- get given name
				if utilities.is_set (first) then
					if (&quot;vanc&quot; == format) then									-- if Vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials (first);					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
			end
			if utilities.is_set (person.link) then
				one = utilities.make_wikilink (person.link, one);				-- link author/editor
			end
			if one then															-- if &lt;one&gt; has a value (name, mdash replacement, or mask text replacement)
				table.insert (name_list, one);									-- add it to the list of names
				table.insert (name_list, sep_one);								-- add the proper name-list separator
			end
		end
	end

	local count = #name_list / 2;												-- (number of names + number of separators) divided by 2
	if 0 &lt; count then 
		if 1 &lt; count and not etal then
			if 'amp' == format or utilities.is_set (lastauthoramp) then			-- TODO: delete lastauthoramp after deprecation
				name_list[#name_list-2] = &quot; &amp; &quot;;								-- replace last separator with ampersand text
			elseif 'and' == format then
				if 2 == count then
					name_list[#name_list-2] = cfg.presentation.sep_nl_and;		-- replace last separator with 'and' text
				else
					name_list[#name_list-2] = cfg.presentation.sep_nl_end;		-- replace last separator with '(sep) and' text
				end
			end
		end
		name_list[#name_list] = nil;											-- erase the last separator
	end

	local result = table.concat (name_list);									-- construct list
	if etal and utilities.is_set (result) then									-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've got a last-first list and etal so add et al.
	end
	
	return result, count;														-- return name-list string and count of number of names (count used for editor names only)
end


--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]

local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if utilities.is_set (id) then												-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of name parameters (author, editor, etc.) for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the associated |display-&lt;names&gt;=etal parameter

]]

local function name_has_etal (name, etal, nocat, param)

	if utilities.is_set (name) then												-- name can be nil in which case just return
		local patterns = cfg.et_al_patterns;									--get patterns from configuration
		
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns
			if name:match (pattern) then										-- if this 'et al' pattern is found in name
				name = name:gsub (pattern, '');									-- remove the offending text
				etal = true;													-- set flag (may have been set previously here or by |display-&lt;names&gt;=etal)
				if not nocat then												-- no categorization for |vauthors=
					table.insert( z.message_tail, {utilities.set_message ('err_etal', {param})});	-- and set an error if not added
				end
			end
		end
	end

	return name, etal;
end


--[[--------------------------&lt; N A M E _ I S _ N U M E R I C &gt;------------------------------------------------

Add maint cat when name parameter value does not contain letters.  Does not catch mixed alphanumeric names so
|last=A. Green (1922-1987) does not get caught in the current version of this test but |first=(1888) is caught.

returns nothing

]]

local function name_is_numeric (name, list_name)
	if utilities.is_set (name) then
		if mw.ustring.match (name, '^[%A]+$') then								-- when name does not contain any letters
			utilities.set_message ('maint_numeric_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
		end
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E D _ M A R K U P &gt;------------------------------------------

Evaluates the content of author and editor parameters for extraneous editor annotations: ed, ed., eds, (Ed.), etc.
These annotation do not belong in author parameters and are redundant in editor parameters.  If found, the function
adds the editor markup maintenance category.

returns nothing

]]

local function name_has_ed_markup (name, list_name)
	local patterns = cfg.editor_markup_patterns;								-- get patterns from configuration

	if utilities.is_set (name) then
		for _, pattern in ipairs (patterns) do									-- spin through patterns table and
			if name:match (pattern) then
				utilities.set_message ('maint_extra_text_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
				break;
			end
		end
	end
end


--[[--------------------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;----------------------------------------

Evaluates the content of last/surname (authors etc.) parameters for multiple names.  Multiple names are indicated
if there is more than one comma or any semicolons.  If found, the function adds the multiple name maintenance category.

returns nothing

]]

local function name_has_mult_names (name, list_name)
	local _, commas, semicolons;
	if utilities.is_set (name) then
		_, commas = name:gsub (',', '');										-- count the number of commas
		_, semicolons = name:gsub (';', '');									-- count the number of semicolons
		
		if 1 &lt; commas or 0 &lt; semicolons then												
			utilities.set_message ('maint_mult_names', cfg.special_case_translation [list_name]);	-- add a maint message
		end
	end
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------

This function calls various name checking functions used to validate the content of the various name-holding
parameters.

]]

local function name_checks (last, first, list_name)
	local accept_name;

	if utilities.is_set (last) then
		last, accept_name = utilities.has_accept_as_written (last);				-- remove accept-this-as-written markup when it wraps all of &lt;last&gt;
		
		if not accept_name then													-- &lt;last&gt; not wrapped in accept-as-written markup
			name_has_mult_names (last, list_name);								-- check for multiple names in the parameter (last only)
			name_has_ed_markup (last, list_name);								-- check for extraneous 'editor' annotation
			name_is_numeric (last, list_name);									-- check for names that are compsed of digits and punctuation
		end
	end

	if utilities.is_set (first) then
		first, accept_name = utilities.has_accept_as_written (first);			-- remove accept-this-as-written markup when it wraps all of &lt;first&gt;

		if not accept_name then														-- &lt;first&gt; not wrapped in accept-as-written markup
			name_has_ed_markup (first, list_name);								-- check for extraneous 'editor' annotation
			name_is_numeric (first, list_name);									-- check for names that are compsed of digits and punctuation
		end
	end

	return last, first;															-- done
end


--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};															-- table of names
	local last;																	-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;																-- loop counter/indexer
	local n = 1;																-- output table indexer
	local count = 0;															-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal = false;															-- return value set to true when we find some form of et al. in an author parameter

	local last_alias, first_alias, link_alias;									-- selected parameter aliases used in error messaging
	while true do
		last, last_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'err_redundant_parameters', i );		-- search through args for name components beginning at 1
		first, first_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'err_redundant_parameters', i );
		link, link_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i );
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.
		last, first = name_checks (last, first, list_name);						-- multiple names, extraneous annotation, etc. checks
		
		if first and not last then												-- if there is a firstn without a matching lastn
			local alias = first_alias:find ('given', 1, true) and 'given' or 'first';	-- get first or given form of the alias
			table.insert (z.message_tail, { utilities.set_message ( 'err_first_missing_last', {
				first_alias,													-- param name of alias missing its mate
				first_alias:gsub (alias, {['first'] = 'last', ['given'] = 'surname'}),	-- make param name appropriate to the alias form
				}, true ) } );													-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			local result;
			link = link_title_ok (link, link_alias, last, last_alias);			-- check for improper wiki-markup
			if first then
				link = link_title_ok (link, link_alias, first, first_alias);	-- check for improper wiki-markup
			end

			names[n] = {last = last, first = first, link = link, mask = mask, corporate = false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { utilities.set_message ( 'err_missing_name', {list_name:match (&quot;(%w+)List&quot;):lower(), i - 1}, true ) } );	-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names and the etal flag
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because case of the source may be incorrect
or different from the case that WikiMedia uses, the name comparisons are done in lower case and when a match is
found, the Wikimedia version (assumed to be correct) is returned along with the code.  When there is no match, we
return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') returns a list of languages that in some cases may include
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.  Most (all?) of these languages are not used a 'language' codes per se, rather they
are used as sub-domain names: cbk-zam.wikipedia.org.  A list of language names and codes supported by fetchLanguageNames()
can be found at Template:Citation Style documentation/language/doc

Names that are included in the list will be found if that name is provided in the |language= parameter.  For example,
if |language=Chavacano de Zamboanga, that name will be found with the associated code 'cbk-zam'.  When names are found
and the associated code is not two or three characters, this function returns only the WikiMedia language name.

Some language names have multiple entries under different codes:
	Aromanian has code rup and code roa-rup
When this occurs, this function returns the language name and the 2- or 3-character code

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	if cfg.lang_name_remap[lang:lower()] then									-- if there is a remapped name (because MediaWiki uses something that we don't think is correct)
		return cfg.lang_name_remap[lang:lower()][1], cfg.lang_name_remap[lang:lower()][2];	-- for this language 'name', return a possibly new name and appropriate code
	end

	local ietf_code;															-- because some languages have both IETF-like codes and ISO 639-like codes
	local ietf_name;
	
	local langlc = mw.ustring.lower (lang);										-- lower-case version for comparisons

	for code, name in pairs (cfg.languages) do									-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower (name) then
			if 2 == #code or 3 == #code then									-- two- or three-character codes only; IETF extensions not supported
				return name, code;												-- so return the name and the code
			end
			ietf_code = code;													-- remember that we found an IETF-like code and save its name
			ietf_name = name;													-- but keep looking for a 2- or 3-char code
		end
	end
																				-- didn't find name with 2- or 3-char code; if IETF-like code found return
	return ietf_code and ietf_name or lang;										-- associated name; return original language text else
end


--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code is recognized by MediaWiki,
use the returned name; if not, then use the value that was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is assigned to the category for
that code: Category:Norwegian-language sources (no).  For valid three-character code languages, the page is assigned
to the single category for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does not recognize three-character
equivalents of two-character codes: code 'ar' is recognized but code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are
separated from each other by commas with optional space characters.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki_name = mw.language.fetchLanguageName (cfg.this_wiki_code, cfg.this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang
		name = cfg.lang_code_remap[lang:lower()];								-- first see if this is a code that is not supported by MediaWiki but is in remap

		if name then															-- there was a remapped code so
			if not lang:match ('^%a%a%a?%-x%-%a+$') then						-- if not a private IETF tag
				lang = lang:gsub ('^(%a%a%a?)%-.*', '%1');						-- strip IETF tags from code
			end
		else
			lang = lang:gsub ('^(%a%a%a?)%-.*', '%1');							-- strip any IETF-like tags from code
			if 2 == lang:len() or 3 == lang:len() then							-- if two-or three-character code
				name = mw.language.fetchLanguageName (lang:lower(), cfg.this_wiki_code);	-- get language name if |language= is a proper code
			end
		end

		if utilities.is_set (name) then											-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, cfg.this_wiki_code);			-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if utilities.is_set (code) then											-- only 2- or 3-character codes
			name = cfg.lang_code_remap[code] or name;							-- override wikimedia when they misuse language codes/names

			if cfg.this_wiki_code ~= code then									-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					utilities.add_prop_cat ('foreign_lang_source' .. code, {name, code});	-- categorize it; code appended to allow for multiple language categorization
				else															-- or is a recognized language (but has a three-character code)
					utilities.add_prop_cat ('foreign_lang_source_2' .. code, {code});		-- categorize it differently TODO: support multiple three-character code categories per cs1|2 template
				end
			elseif cfg.local_lang_cat_enable then								-- when the language and this wiki's language are the same and categorization is enabled
				utilities.add_prop_cat ('local_lang_source', {name, code});		-- categorize it
			end
		else
			utilities.set_message ('maint_unknown_lang');						-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
 
	name = utilities.make_sep_list (#language_list, language_list);

	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings
At en.wiki, for cs1:
	ps gets:	'.'
	sep gets:	'.'

]]

local function set_cs1_style (ps)
	if not utilities.is_set (ps) then											-- unless explicitly set to something
		ps = cfg.presentation['ps_cs1'];										-- terminate the rendered citation
	end
	return cfg.presentation['sep_cs1'], ps;										-- element separator
end


--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings
At en.wiki, for cs2:
	ps gets:	'' (empty string - no terminal punctuation)
	sep gets:	','

]]

local function set_cs2_style (ps, ref)
	if not utilities.is_set (ps) then											-- if |postscript= has not been set, set cs2 default
		ps = cfg.presentation['ps_cs2'];										-- terminate the rendered citation
	end
	if not utilities.is_set (ref) then											-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return cfg.presentation['sep_cs2'], ps, ref;								-- element separator
end


--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end


--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end

	if cfg.keywords_xlate[ps:lower()] == 'none' then							-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end


--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a URL has the file extension that is one of the PDF file extensions used by [[MediaWiki:Common.css]] when
applying the PDF icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or
		url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
		url:match ('%.PDF&amp;#035') or url:match ('%.pdf&amp;#035');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies CSS style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching URL parameter.  If the format parameter is not set and the URL contains a file extension that
is recognized as a PDF document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if utilities.is_set (format) then
		format = utilities.wrap_style ('format', format);						-- add leading space, parentheses, resize
		if not utilities.is_set (url) then
			format = format .. ' ' .. utilities.set_message ( 'err_format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if URL is a PDF file then
		format = utilities.wrap_style ('format', 'PDF');						-- set format to PDF
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[--------------------------&lt; G E T _ D I S P L A Y _ N A M E S &gt;--------------------------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a Boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_names (max, count, list_name, etal)
	if utilities.is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				table.insert( z.message_tail, {utilities.set_message ('err_disp_name', {cfg.special_case_translation [list_name], max}, true)});	-- add error message
				max = nil;
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, {utilities.set_message ('err_disp_name', {cfg.special_case_translation [list_name], max}, true)});		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		utilities.set_message ('maint_extra_text');								-- add maint cat;
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parentheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a place holder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parentheses
			local name = name_table[i];
			i = i + 1;																-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parentheses
					break;														-- and done reassembling so
				end
				i = i + 1;														-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = utilities.is_wikilink (name_table[i]);		-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i + 1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled parentheses ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the Vancouver error when a required comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		first = '';																-- set to empty string for concatenation and because it may have been set for previous author/editor
		local accept_name;
		v_name, accept_name = utilities.has_accept_as_written (v_name);			-- remove accept-this-as-written markup when it wraps all of &lt;v_name&gt;

--		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parentheses to suppress vanc formatting and error detection
--			last = v_name:match ('^%(%((.+)%)%)$')								-- remove doubled parentheses
		if accept_name then
			last = v_name;
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error (cfg.err_msg_supl.punctuation);
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s+&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be initials or generational suffix

			if not mw.ustring.match (first, '^%u+$') then						-- mw.ustring here so that later we will catch non-Latin characters
				suffix = first;													-- not initials so assume that whatever we got is a generational suffix
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end
			last = table.concat(lastfirstTable, ' ')							-- returns a string that is the concatenation of all other names that are not initials and generational suffix
			if not utilities.is_set (last) then
				first = '';														-- unset
				last = v_name;													-- last empty because something wrong with first
				add_vanc_error (cfg.err_msg_supl.name);
			end
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error (cfg.err_msg_supl['missing comma']);				-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error (cfg.err_msg_supl.name);							-- matches a space between two initials
			end
		else
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
		
		if utilities.is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error (cfg.err_msg_supl.initials);						-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first, suffix);							-- check first and last before restoring the suffix which may have a non-Latin digit
			if utilities.is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '');
			end
		end

		link = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i ) or v_link_table[i];
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate = corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
	local lastfirst = false;
	if utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice in case we have a |first1= without a |last1=; this ...
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or		-- ... also catches the case where |first= is used with |vauthors=
		utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst = true;
	end

	if (utilities.is_set (vxxxxors) and true == lastfirst) or					-- these are the three error conditions
		(utilities.is_set (vxxxxors) and utilities.is_set (xxxxors)) or
		(true == lastfirst and utilities.is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { utilities.set_message ( 'err_redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if utilities.is_set (vxxxxors) then return 2 end;
	if utilities.is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, live, dead, etc.).  When the parameter value has not been assigned a value (missing
or empty in the source template) the function returns the value specified by ret_val.  If the parameter value is one
of the list of allowed values returns the translated value; else, emits an error message and returns the value
specified by ret_val.

]]

local function is_valid_parameter_value (value, name, possible, ret_val)
	if not utilities.is_set (value) then
		return ret_val;															-- an empty parameter is ok
	elseif utilities.in_array (value, possible) then
		return cfg.keywords_xlate[value];										-- return translation of parameter keyword
	else
		table.insert( z.message_tail, { utilities.set_message ( 'err_invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return ret_val;
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list, -3, -1) == sepc .. '. ') then					-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list, -1, -1) == sepc) or (string.sub (name_list, -3, -1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terminate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not utilities.is_set (volume) and not utilities.is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (utilities.in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if utilities.is_set (volume) and utilities.is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif utilities.is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end

	if 'podcast' == cite_class and utilities.is_set (issue) then
		return wrap_msg ('issue', {sepc, issue}, lower);
	end

	local vol = '';																-- here for all cites except magazine
		
	if utilities.is_set (volume) then
		if volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$') then			-- volume value is all digits or all uppercase Roman numerals
			vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});	-- render in bold face
		elseif (4 &lt; mw.ustring.len(volume)) then								-- not all digits or Roman numerals and longer than 4 characters
			vol = utilities.substitute (cfg.messages['j-vol'], {sepc, volume});	-- not bold
			utilities.add_prop_cat ('long_vol');
		else																	-- four or less characters
			vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});	-- bold
		end
	end
	if utilities.is_set (issue) then
		return vol .. utilities.substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if utilities.is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif utilities.is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if utilities.is_set (page) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return utilities.substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return utilities.substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif utilities.is_set (pages) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then							-- if pages is only digits, assume a single page number
			return '', utilities.substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', utilities.substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', utilities.substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to Wikisource, returns the label portion of the interwiki-link as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki-link to and external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, pages, at)
	local ws_url, ws_label, coins_pages, L;										-- for Wikisource interwiki-links; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if utilities.is_set (page) then
		if utilities.is_set (pages) or utilities.is_set (at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws URL from |page= interwiki link; link portion L becomes tooltip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (pages) then
		if utilities.is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws URL from |pages= interwiki link; link portion L becomes tooltip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws URL from |at= interwiki link; link portion L becomes tooltip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org URLs to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot URL or to calendar pages.  When the archive URL is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the URL.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org URL does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command URL
	|archive-url= is an archive.org URL that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org URLs:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this function may return a modified
archive URL:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the URL unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.org URL
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine URL
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command URL, we don't want to allow saving of the target page 
		err_msg = cfg.err_msg_supl.save;
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = cfg.err_msg_supl.liveweb;
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');	-- split out some of the URL parts for evaluation
		
		if not utilities.is_set (timestamp) or 14 ~= timestamp:len() then		-- path and flag optional, must have 14-digit timestamp here
			err_msg = cfg.err_msg_supl.timestamp;
			if '*' ~= flag then
				url=url:gsub ('(//web%.archive%.org/[^%d]*%d?%d?%d?%d?%d?%d?)[^/]*', '%1*', 1)	-- for preview, modify ts to be yearmo* max (0-6 digits plus splat)
			end
		elseif utilities.is_set (path) and 'web/' ~= path then					-- older archive URLs do not have the extra 'web/' path element
			err_msg = cfg.err_msg_supl.path;
		elseif utilities.is_set (flag) and not utilities.is_set (path) then		-- flag not allowed with the old form URL (without the 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		elseif utilities.is_set (flag) and not flag:match ('%a%a_') then		-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		else
			return url, date;													-- return ArchiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	table.insert( z.message_tail, { utilities.set_message ( 'err_archive_url', {err_msg}, true ) } );	-- add error message and
	if utilities.is_set (Frame:preprocess('{{REVISIONID}}')) then
		return '', '';															-- return empty strings for ArchiveURL and ArchiveDate
	else
		return url, date;														-- preview mode so return ArchiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; P L A C E _ C H E C K &gt;--------------------------------------------------------

check |place=, |publication-place=, |location= to see if these params include digits.  This function added because
many editors misuse location to specify the in-source location (|page(s)= and |at= are supposed to do that)

returns the original parameter value without modification; added maint cat when parameter value contains digits

]]

local function place_check (param_val)
	if not utilities.is_set (param_val) then									-- parameter empty or omitted
		return param_val;														-- return that empty state
	end
	
	if mw.ustring.find (param_val, '%d') then									-- not empty, are there digits in the parameter value
		utilities.set_message ('maint_location');								-- yep, add maint cat
	end
	
	return param_val;															-- and done
end


--[[--------------------------&lt; I S _ G E N E R I C _ T I T L E &gt;----------------------------------------------

compares |title= value against list of known generic title patterns.  Returns true when pattern matches; nil else

the k/v pairs in 'generic_titles' each contain two tables, one for English and one for another 'local' language
Each of those tables contain another table that holds the string or pattern (whole title or title fragment) in
index [1].  index [2] is a Boolean that tells string.find() or mw.ustring.find() to do plain-text search (true)
or a pattern search (false).  The intent of all this complexity is to make these searches as fast as possible so
that we don't run out of processing time on very large articles.

]]

local function is_generic_title (title)
	title = mw.ustring.lower(title);											-- switch title to lower case
	for _, generic_title in ipairs (cfg.special_case_translation['generic_titles']) do	--spin through the list of known generic title fragments
		if title:find (generic_title['en'][1], 1, generic_title['en'][2]) then
			return true;														-- found English generic title so done
		elseif generic_title['local'] then										-- to keep work load down, generic_title['local'] should be nil except when there is a local version of the generic title
			if mw.ustring.find (title, generic_title['local'][1], 1, generic_title['local'][2]) then	-- mw.ustring() because might not be Latin script
				return true;													-- found local generic title so done
			end
		end
	end
end


--[[--------------------------&lt; I S _ A R C H I V E D _ C O P Y &gt;----------------------------------------------

compares |title= to 'Archived copy' (place holder added by bots that can't find proper title); if matches, return true; nil else

]]

local function is_archived_copy (title)
	title = mw.ustring.lower(title);											-- switch title to lower case
	if title:find (cfg.special_case_translation.archived_copy.en) then			-- if title is 'Archived copy'
		return true;
	elseif cfg.special_case_translation.archived_copy['local'] then
		if mw.ustring.find (title, cfg.special_case_translation.archived_copy['local']) then	-- mw.ustring() because might not be Latin script
			return true;
		end
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper ( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

	local Mode = is_valid_parameter_value (A['Mode'], A:ORIGIN('Mode'), cfg.keywords_lists['mode'], '');

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;

	local NameListStyle = is_valid_parameter_value (A['NameListStyle'], A:ORIGIN('NameListStyle'), cfg.keywords_lists['name-list-style'], '');
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';											-- override whatever |name-list-style= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				utilities.set_message ('maint_authors');						-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if utilities.is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';											-- override whatever |name-list-style= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
		end
	end

	local translator_etal;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=

	local interviewer_etal;
	local interviewers_list = {};												
	local Interviewers;															-- used later
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters

	local contributor_etal;
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list

	local Chapter = A['Chapter'];												-- done here so that we have access to |contribution= from |chapter= aliases
	local Chapter_origin = A:ORIGIN ('Chapter');
	local Contribution;															-- because contribution is required for contributor(s)
		if 'contribution' == A:ORIGIN ('Chapter') then
			Contribution = A['Chapter'];										-- get the name of the contribution
		end

	if utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not utilities.is_set (Contribution) then							-- |contributor= requires |contribution=
				table.insert( z.message_tail, { utilities.set_message ( 'err_contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { utilities.set_message ( 'err_contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if utilities.select_one (args, cfg.aliases['ContributorList-Last'], 'err_redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { utilities.set_message ( 'err_contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if utilities.is_set (Others) then
		if 0 == #a and 0 == #e then												-- add maint cat when |others= has value and used without |author=, |editor=
			utilities.set_message ('maint_others');
		end
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigDate = A['OrigDate'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TransTitle_origin = A:ORIGIN ('TransTitle');
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];

	local auto_select = ''; -- default is auto
	local accept_link;
	TitleLink, accept_link = utilities.has_accept_as_written(TitleLink, true); -- test for accept-this-as-written markup
	if (not accept_link) and utilities.in_array (TitleLink, {'none', 'pmc', 'doi'}) then -- check for special keywords
		auto_select = TitleLink; -- remember selection for later
		TitleLink = ''; -- treat as if |title-link= would have been empty
	end

	TitleLink = link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wiki-markup in |title-link= or wiki-markup in |title= when |title-link= is set

	local Section = '';															-- {{cite map}} only; preset to empty string for concatenation if not used
		if 'map' == config.CitationClass and 'section' == A:ORIGIN ('Chapter') then
			Section = A['Chapter'];												-- get |section= from |chapter= alias list; |chapter= and the other aliases not supported in {{cite map}}
			Chapter = '';														-- unset for now; will be reset later from |map= if present
		end

	local ScriptChapter = A['ScriptChapter'];
	local ScriptChapter_origin = A:ORIGIN ('ScriptChapter');
	local ChapterLink -- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TransChapter_origin = A:ORIGIN ('TransChapter');
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];

	local ArchiveDate;
	local ArchiveURL;

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	
	local UrlStatus = is_valid_parameter_value (A['UrlStatus'], A:ORIGIN('UrlStatus'), cfg.keywords_lists['url-status'], '');

	local URL = A['URL']
	local URL_origin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURL_origin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURL_origin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL

	local Periodical = A['Periodical'];
	local Periodical_origin = '';
	if utilities.is_set (Periodical) then
		Periodical_origin = A:ORIGIN('Periodical');								-- get the name of the periodical parameter
		local i;
		Periodical, i = utilities.strip_apostrophe_markup (Periodical);			-- strip apostrophe markup so that metadata isn't contaminated 
		if i then																-- non-zero when markup was stripped so emit an error message
			table.insert( z.message_tail, {utilities.set_message ('err_apostrophe_markup', {Periodical_origin}, true)});
		end
	end

	if 'mailinglist' == config.CitationClass then								-- special case for {{cite mailing list}}
		if utilities.is_set (Periodical) and utilities.is_set (A ['MailingList']) then	-- both set emit an error
			table.insert( z.message_tail, {utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', Periodical_origin) .. ' and ' .. utilities.wrap_style ('parameter', 'mailinglist')}, true )});
		end

		Periodical = A ['MailingList'];											-- error or no, set Periodical to |mailinglist= value because this template is {{cite mailing list}}
		Periodical_origin = A:ORIGIN('MailingList');
	end

	local ScriptPeriodical = A['ScriptPeriodical'];
	local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');

	-- web and news not tested for now because of 
	-- Wikipedia:Administrators%27_noticeboard#Is_there_a_semi-automated_tool_that_could_fix_these_annoying_&quot;Cite_Web&quot;_errors?
	if not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) then	-- 'periodical' templates require periodical parameter
	--	local p = {['journal'] = 'journal', ['magazine'] = 'magazine', ['news'] = 'newspaper', ['web'] = 'website'};	-- for error message
		local p = {['journal'] = 'journal', ['magazine'] = 'magazine'};			-- for error message
		if p[config.CitationClass]  then
			table.insert( z.message_tail, {utilities.set_message ('err_missing_periodical', {config.CitationClass, p[config.CitationClass]}, true)});
		end
	end

	local TransPeriodical =  A['TransPeriodical'];
	local TransPeriodical_origin =  A:ORIGIN ('TransPeriodical');

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) then
			if not utilities.in_array (Periodical_origin, {'website', 'mailinglist'}) then	-- {{citation}} does not render volume for these 'periodicals'
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		elseif utilities.is_set (ScriptPeriodical) then
			if 'script-website' ~= ScriptPeriodical_origin then					-- {{citation}} does not render volume for |script-website=
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		else
			Volume = A['Volume'];												-- and does for non-'periodical' cites
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_volume) then	-- render |volume= for cs1 according to the configuration settings
		Volume = A['Volume'];
	end	

	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) and utilities.in_array (Periodical_origin, {'journal', 'magazine', 'newspaper', 'periodical', 'work'}) or	-- {{citation}} renders issue for these 'periodicals'
			utilities.is_set (ScriptPeriodical) and utilities.in_array (ScriptPeriodical_origin, {'script-journal', 'script-magazine', 'script-newspaper', 'script-periodical', 'script-work'}) then -- and these 'script-periodicals'
				Issue = hyphen_to_dash (A['Issue']);
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_issue) then	-- conference &amp; map books do not support issue; {{citation}} listed here because included in settings table
		if not (utilities.in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical))) then
			Issue = hyphen_to_dash (A['Issue']);
		end
	end

	local Position = '';
	if not utilities.in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash (A['Pages']);	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = place_check (A['PublicationPlace'], A:ORIGIN('PublicationPlace'));
	local Place = place_check (A['Place'], A:ORIGIN('Place'));
	
	local PublisherName = A['PublisherName'];
	local PublisherName_origin = A:ORIGIN('PublisherName');
	if utilities.is_set (PublisherName) then
		local i = 0;
		PublisherName, i = utilities.strip_apostrophe_markup (PublisherName);	-- strip apostrophe markup so that metadata isn't contaminated; publisher is never italicized
		if i then																-- non-zero when markup was stripped so emit an error message
			table.insert( z.message_tail, {utilities.set_message ('err_apostrophe_markup', {PublisherName_origin}, true)});
		end
	end

	local Newsgroup = A['Newsgroup'];											-- TODO: strip apostrophe markup?
	local Newsgroup_origin = A:ORIGIN('Newsgroup');	

	if 'newsgroup' == config.CitationClass then
		if utilities.is_set (PublisherName) then								-- general use parameter |publisher= not allowed in cite newsgroup
			local error_text, error_state = utilities.set_message ('err_parameter_ignored', {PublisherName_origin}, true);
			if utilities.is_set (error_text) then
				table.insert( z.message_tail, {error_text, error_state} );
			end				
		end

		PublisherName = nil;													-- ensure that this parameter is unset for the time being; will be used again after COinS
	end

	local UrlAccess = is_valid_parameter_value (A['UrlAccess'], A:ORIGIN('UrlAccess'), cfg.keywords_lists['url-access'], nil);
		if not utilities.is_set (URL) and utilities.is_set (UrlAccess) then
			UrlAccess = nil;
			table.insert( z.message_tail, { utilities.set_message ( 'err_param_access_requires_param', {'url'}, true ) } );
		end
		
	local ChapterUrlAccess = is_valid_parameter_value (A['ChapterUrlAccess'], A:ORIGIN('ChapterUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (ChapterURL) and utilities.is_set (ChapterUrlAccess) then
		ChapterUrlAccess = nil;
		table.insert( z.message_tail, { utilities.set_message ( 'err_param_access_requires_param', {A:ORIGIN('ChapterUrlAccess'):gsub ('%-access', '')}, true ) } );
	end

	local MapUrlAccess = is_valid_parameter_value (A['MapUrlAccess'], A:ORIGIN('MapUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (A['MapURL']) and utilities.is_set (MapUrlAccess) then
		MapUrlAccess = nil;
		table.insert( z.message_tail, { utilities.set_message ( 'err_param_access_requires_param', {'map-url'}, true ) } );
	end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local Agency = A['Agency'];

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = is_valid_parameter_value (A['IgnoreISBN'], A:ORIGIN('IgnoreISBN'), cfg.keywords_lists['yes_true_y'], nil);
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local Quote = A['Quote'];
	local QuotePage = A['QuotePage'];
	local QuotePages = A['QuotePages'];
	local ScriptQuote = A['ScriptQuote'];
	local TransQuote = A['TransQuote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURL_origin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = is_valid_parameter_value (A['LastAuthorAmp'], A:ORIGIN('LastAuthorAmp'), cfg.keywords_lists['yes_true_y'], nil);

	local no_tracking_cats = is_valid_parameter_value (A['NoTracking'], A:ORIGIN('NoTracking'), cfg.keywords_lists['yes_true_y'], nil);
	if 'nocat' == A:ORIGIN('NoTracking') then				
		utilities.set_message ('maint_nocat');									-- this one so that we get the message; see main categorization at end of citation0()
	end
	
	--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = is_valid_parameter_value (A['DF'], A:ORIGIN('DF'), cfg.keywords_lists['df'], '');
	if not utilities.is_set (DF) then
		DF = cfg.global_df;														-- local |df= if present overrides global df set by {{use xxx date}} template
	end

	local sepc;																	-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref = A['Ref'];
	if 'harv' == Ref then
		utilities.set_message ('maint_ref_harv');								-- add maint cat to identify templates that have this now-extraneous param value
	elseif not utilities.is_set (Ref) then
		Ref = 'harv';															-- set as default when not set externally
	end
	
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], Ref, config.CitationClass);
	use_lowercase = ( sepc == ',' ); 											-- used to control capitalization for certain static text

	-- check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not utilities.is_set (no_tracking_cats) then								-- ignore if we are already not going to categorize this page
		if utilities.in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _, v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end
																				-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	utilities.select_one (args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'err_redundant_parameters');	-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, Pages, At);

	local NoPP = is_valid_parameter_value (A['NoPP'], A:ORIGIN('NoPP'), cfg.keywords_lists['yes_true_y'], nil);

	if utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- both |publication-place= and |place= (|location=) allowed if different
		utilities.add_prop_cat ('location test');								-- add property cat to evaluate how often PublicationPlace and Place are used together
		if PublicationPlace == Place then
			Place = '';															-- unset; don't need both if they are the same
		end
	elseif not utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- when only |place= (|location=) is set ...
		PublicationPlace = Place;												-- promote |place= (|location=) to |publication-place
	end

	if PublicationPlace == Place then Place = ''; end							-- don't need both if they are the same
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia= and |title= then map |title= to |article= and |encyclopedia= to |title=
		|encyclopedia= and |article= then map |encyclopedia= to |title=

		|trans-title= maps to |trans-chapter= when |title= is re-mapped
		|url= maps to |chapter-url= when |title= is remapped
	
	All other combinations of |encyclopedia=, |title=, and |article= are not modified
	
	]]

	local Encyclopedia = A['Encyclopedia'];										-- used as a flag by this module and by ~/COinS

	if utilities.is_set (Encyclopedia) then										-- emit error message when Encyclopedia set but template is other than {{cite encyclopedia}} or {{citation}}
		if 'encyclopaedia' ~= config.CitationClass and 'citation' ~= config.CitationClass then
			table.insert (z.message_tail, {utilities.set_message ('err_parameter_ignored', {A:ORIGIN ('Encyclopedia')}, true)});
			Encyclopedia = nil;													-- unset because not supported by this template
		end
	end

	if ('encyclopaedia' == config.CitationClass) or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Periodical) and utilities.is_set (Encyclopedia) then	-- when both set emit an error
			table.insert (z.message_tail, {utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', A:ORIGIN ('Encyclopedia')) .. ' and ' .. utilities.wrap_style ('parameter', Periodical_origin)}, true )});
		end

		if utilities.is_set (Encyclopedia) then
			Periodical = Encyclopedia;											-- error or no, set Periodical to Encyclopedia; allow periodical without encyclopedia
			Periodical_origin = A:ORIGIN ('Encyclopedia');
		end

		if utilities.is_set (Periodical) then									-- Periodical is set when |encyclopedia= is set
			if utilities.is_set (Title) or utilities.is_set (ScriptTitle) then
				if not utilities.is_set (Chapter) then
					Chapter = Title;											-- |encyclopedia= and |title= are set so map |title= to |article= and |encyclopedia= to |title=
					ScriptChapter = ScriptTitle;
					ScriptChapter_origin = A:ORIGIN('ScriptTitle')
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterURL_origin = A:ORIGIN('URL')

					ChapterUrlAccess = UrlAccess;

					if not utilities.is_set (ChapterURL) and utilities.is_set (TitleLink) then
						Chapter = utilities.make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			elseif utilities.is_set (Chapter) then								-- |title= not set
				Title = Periodical;												-- |encyclopedia= set and |article= set so map |encyclopedia= to |title=
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if utilities.is_set (A['Number']) then									-- cite techreport uses 'number', which other citations alias to 'issue'
			if not utilities.is_set (ID) then									-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'id') .. ' and ' .. utilities.wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if utilities.is_set (BookTitle) then
			Chapter = Title;
			Chapter_origin = 'title';
	--		ChapterLink = TitleLink;											-- |chapter-link= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			URL_origin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			TransChapter_origin = TransTitle_origin;
			Title = BookTitle;
			Format = '';
	--		TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		if utilities.is_set (Chapter) then
			table.insert( z.message_tail, { utilities.set_message ( 'err_redundant_parameters', {utilities.wrap_style ('parameter', 'map') .. ' and ' .. utilities.wrap_style ('parameter', Chapter_origin)}, true ) } );	-- add error message
		end
		Chapter = A['Map'];
		Chapter_origin = A:ORIGIN('Map');
		ChapterURL = A['MapURL'];
		ChapterURL_origin = A:ORIGIN('MapURL');
		TransChapter = A['TransMap'];
		ScriptChapter = A['ScriptMap']
		ScriptChapter_origin = A:ORIGIN('ScriptMap')

		ChapterUrlAccess = MapUrlAccess;
		ChapterFormat = A['MapFormat'];

		Cartography = A['Cartography'];
		if utilities.is_set ( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if utilities.is_set ( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local SeriesLink = A['SeriesLink'];

		SeriesLink = link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wiki-markup in |series-link= or wiki-markup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if utilities.is_set (Network) then table.insert(n, Network); end
		if utilities.is_set (Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if utilities.is_set (Season) and utilities.is_set (SeriesNumber) then	-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { utilities.set_message ( 'err_redundant_parameters', {utilities.wrap_style ('parameter', 'season') .. ' and ' .. utilities.wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if utilities.is_set (Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if utilities.is_set (SeriesNumber) then table.insert(s, wrap_msg ('seriesnum', SeriesNumber, use_lowercase)); end
			if utilities.is_set (Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ScriptChapter_origin = A:ORIGIN('ScriptTitle');
			ChapterLink = TitleLink;											-- alias |episode-link=
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if utilities.is_set (ChapterLink) and not utilities.is_set (ChapterURL) then	-- link but not URL
				Chapter = utilities.make_wikilink (ChapterLink, Chapter);
			elseif utilities.is_set (ChapterLink) and utilities.is_set (ChapterURL) then	-- if both are set, URL links episode;
				Series = utilities.make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if utilities.is_set (Series) and utilities.is_set (SeriesLink) then
				Series = utilities.make_wikilink (SeriesLink, Series);
			end
			Series = utilities.wrap_style ('italic-title', Series);				-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- handle type parameter for those CS1 citations that have default values
	if utilities.in_array (config.CitationClass, {&quot;AV-media-notes&quot;, &quot;interview&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if utilities.is_set (Degree) and &quot;Thesis&quot; == TitleType then				-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if utilities.is_set (TitleType) then										-- if type parameter is specified
		TitleType = utilities.substitute ( cfg.messages['type'], TitleType);	-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging

	if not utilities.is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not utilities.is_set (Date) and utilities.is_set (PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val = AccessDate, name = A:ORIGIN ('AccessDate')},
			['archive-date'] = {val = ArchiveDate, name = A:ORIGIN ('ArchiveDate')},
			['date'] = {val = Date, name = Date_origin},
			['doi-broken-date'] = {val = DoiBroken, name = A:ORIGIN ('DoiBroken')},
			['pmc-embargo-date'] = {val = Embargo, name = A:ORIGIN ('Embargo')},
			['lay-date'] = {val = LayDate, name = A:ORIGIN ('LayDate')},
			['publication-date'] = {val = PublicationDate, name = A:ORIGIN ('PublicationDate')},
			['year'] = {val = Year, name = A:ORIGIN ('Year')},
			};

		local error_list = {};
		anchor_year, Embargo = validation.dates(date_parameters_list, COinS_date, error_list);

-- start temporary Julian / Gregorian calendar uncertainty categorization
		if COinS_date.inter_cal_cat then
			utilities.add_prop_cat ('jul_greg_uncertainty');
		end
-- end temporary Julian / Gregorian calendar uncertainty categorization

		if utilities.is_set (Year) and utilities.is_set (Date) then				-- both |date= and |year= not normally needed; 
			local mismatch = validation.year_date_check (Year, Date);
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				table.insert (error_list, '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;year= / &amp;#124;date= mismatch&lt;/code&gt;');
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				utilities.set_message ('maint_date_year');						-- add a maint cat
			end
		end
		
		if 0 == #error_list then												-- error free dates only; 0 when error_list is empty
			local modified = false;												-- flag
			
			if utilities.is_set (DF) then										-- if we need to reformat dates
				modified = validation.reformat_dates (date_parameters_list, DF);	-- reformat to DF format, use long month names if appropriate
			end

			if true == validation.date_hyphen_to_dash (date_parameters_list) then	-- convert hyphens to dashes where appropriate
				modified = true;
				utilities.set_message ('maint_date_format');					-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language,
	-- uncomment the next three lines.  Not supported by en.wiki (for obvious reasons)
	-- set validation.date_name_xlate() second argument to true to translate English digits to local digits (will translate ymd dates)
	--		if validation.date_name_xlate (date_parameters_list, false) then
	--			modified = true;
	--		end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				LayDate = date_parameters_list['lay-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end
		else
			table.insert (z.message_tail, {utilities.set_message ('err_bad_date', {utilities.make_sep_list (#error_list, error_list)}, true)});	-- add this error message
		end
	end	-- end of do

	local ID_list_coins = identifiers.extract_ids (args);						-- gets identifiers and their values from args; this list used for COinS and source for build_id_list()
		if utilities.is_set (DoiBroken) and not ID_list_coins['DOI'] then
			table.insert (z.message_tail, {utilities.set_message ('err_doibroken_missing_doi', A:ORIGIN('DoiBroken'))});
		end
	local ID_access_levels = identifiers.extract_id_access_levels (args, ID_list_coins);
	local ID_list = identifiers.build_id_list (ID_list_coins, {IdAccessLevels = ID_access_levels, DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo = Embargo, Class = Class});	-- render identifiers
	
	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite ssrn}}, before generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then
		if not utilities.is_set (ID_list_coins[config.CitationClass:upper()]) then 	-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp; |citeseerx= required for their templates
			table.insert (z.message_tail, {utilities.set_message ('err_' .. config.CitationClass .. '_missing', {}, true)});	-- add error message
		end

		Periodical = ({['arxiv'] = 'arXiv', ['biorxiv'] = 'bioRxiv', ['citeseerx'] = 'CiteSeerX', ['ssrn'] = 'Social Science Research Network'})[config.CitationClass];
	end

	-- Link the title of the work if no |url= was provided, but we have a |pmc= or a |doi= with |doi-access=free

	if config.CitationClass == &quot;journal&quot; and not utilities.is_set (URL) and not utilities.is_set (TitleLink) and not utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) then -- TODO: remove 'none' once existing citations have been switched to 'off', so 'none' can be used as token for &quot;no title&quot; instead
    		if 'none' ~= cfg.keywords_xlate[auto_select] then -- if auto-linking not disabled
 	 		if identifiers.auto_link_urls[auto_select] then -- manual selection
		 		URL = identifiers.auto_link_urls[auto_select]; -- set URL to be the same as identifier's external link
 				URL_origin = cfg.id_handlers[auto_select:upper()].parameters[1]; -- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['pmc'] then -- auto-select PMC
				URL = identifiers.auto_link_urls['pmc']; -- set URL to be the same as the PMC external link if not embargoed
				URL_origin = cfg.id_handlers['PMC'].parameters[1]; -- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['doi'] then -- auto-select DOI
				URL = identifiers.auto_link_urls['doi'];
				URL_origin = cfg.id_handlers['DOI'].parameters[1];
			end
 	 	end

		if utilities.is_set (URL) and utilities.is_set (AccessDate) then		-- access date requires |url=; identifier-created URL is not |url=
			table.insert( z.message_tail, { utilities.set_message ( 'err_accessdate_missing_url', {}, true ) } );	-- add an error message
			AccessDate = '';													-- unset
		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not utilities.is_set (Title) and not utilities.is_set (TransTitle) and not utilities.is_set (ScriptTitle) then	-- has special case for cite episode
		table.insert( z.message_tail, { utilities.set_message ( 'err_citation_missing_title', {'episode' == config.CitationClass and 'series' or 'title'}, true ) } );
	end

	if utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) and
			utilities.in_array (config.CitationClass, {'journal', 'citation'}) and
			(utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and
			('journal' == Periodical_origin or 'script-journal' == ScriptPeriodical_origin) then	-- special case for journal cites
				Title = '';														-- set title to empty string
				utilities.set_message ('maint_untitled');						-- add maint cat
	end

	check_for_url ({															-- add error message when any of these parameters hold a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[Periodical_origin] = Periodical,
		[PublisherName_origin] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Chapter) and utilities.is_set (Title) and utilities.is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = metadata.COinS({
		['Periodical'] = utilities.strip_apostrophe_markup (Periodical),		-- no markup in the metadata
		['Encyclopedia'] = Encyclopedia,										-- just a flag; content ignored by ~/COinS
		['Chapter'] = metadata.make_coins_title (coins_chapter, ScriptChapter),	-- Chapter and ScriptChapter stripped of bold / italic wiki-markup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = metadata.make_coins_title (coins_title, ScriptTitle),		-- Title and ScriptTitle stripped of bold / italic wiki-markup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Quarter'] = COinS_date.rftquarter,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = coins_pages or metadata.get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName or Newsgroup,							-- any apostrophe markup already removed from PublisherName
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list_coins,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, and {{cite ssrn}} AFTER generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, CiteSeerX, or ssrn now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass and utilities.is_set (Newsgroup) then
		PublisherName = utilities.substitute (cfg.messages['newsgroup'], external_link( 'news:' .. Newsgroup, Newsgroup, Newsgroup_origin, nil ));
	end

	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local control = { 
			format = NameListStyle,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_names (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if utilities.is_set (Editors) then
				Editors, editor_etal = name_has_etal (Editors, editor_etal, false, 'editors');	-- find and remove variations on et al.
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
				end
				EditorCount = 2;												-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum , interviewer_etal = get_display_names (A['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal);
			Interviewers = list_people (control, interviewers_list, interviewer_etal);
		end
		do																		-- now do translators
			control.maximum , translator_etal = get_display_names (A['DisplayTranslators'], #t, 'translators', translator_etal);
			Translators = list_people (control, t, translator_etal);
		end
		do																		-- now do contributors
			control.maximum , contributor_etal = get_display_names (A['DisplayContributors'], #c, 'contributors', contributor_etal);
			Contributors = list_people (control, c, contributor_etal);
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_names (A['DisplayAuthors'], #a, 'authors', author_etal);

			last_first_list = list_people(control, a, author_etal);

			if utilities.is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors');	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if utilities.is_set (Authors) and utilities.is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
	-- an error message if the associated URL is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not utilities.is_set (URL) then
		if utilities.in_array (config.CitationClass, {&quot;web&quot;, &quot;podcast&quot;, &quot;mailinglist&quot;}) or		-- |url= required for cite web, cite podcast, and cite mailinglist
			('citation' == config.CitationClass and ('website' == Periodical_origin or 'script-website' == ScriptPeriodical_origin)) then	-- and required for {{citation}} with |website= or |script-website=
				table.insert( z.message_tail, { utilities.set_message ( 'err_cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if utilities.is_set (AccessDate) and not utilities.is_set (ChapterURL) then		-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { utilities.set_message ( 'err_accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURL_origin, OriginalFormat, OriginalAccess;
	UrlStatus = UrlStatus:lower();												-- used later when assembling archived text
	if utilities.is_set ( ArchiveURL ) then
		if utilities.is_set (ChapterURL) then 									-- if chapter-url= is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURL_origin = ChapterURL_origin;								-- name of |chapter-url= parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=

			if 'live' ~= UrlStatus then
				ChapterURL = ArchiveURL											-- swap-in the archive's URL
				ChapterURL_origin = A:ORIGIN('ArchiveURL')						-- name of |archive-url= parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived URLs
			end
		elseif utilities.is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURL_origin = URL_origin;									-- name of URL parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;

			if 'live' ~= UrlStatus then											-- if URL set then |archive-url= applies to it
				URL = ArchiveURL												-- swap-in the archive's URL
				URL_origin = A:ORIGIN('ArchiveURL')								-- name of archive URL parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived URLs
			end
 		end
	end

	if utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) then
			local chap_param;
			if utilities.is_set (Chapter) then									-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif utilities.is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif utilities.is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif utilities.is_set (ScriptChapter) then
				chap_param = ScriptChapter_origin;
			else utilities.is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if utilities.is_set (chap_param) then								-- if we found one
				table.insert( z.message_tail, { utilities.set_message ( 'err_chapter_ignored', {chap_param}, true ) } );	-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if utilities.is_set (Contribution) and 0 &lt; #c then						-- if this is a contribution with contributor(s)
			if utilities.in_array (Contribution:lower(), cfg.keywords_lists.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, ScriptChapter_origin, Chapter, Chapter_origin, TransChapter, TransChapter_origin, ChapterURL, ChapterURL_origin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if utilities.is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and utilities.is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter .. sepc .. ' ';
		elseif utilities.is_set (ChapterFormat) then							-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title
	local plain_title = false;
	local accept_title;
	Title, accept_title = utilities.has_accept_as_written (Title, true);		-- remove accept-this-as-written markup when it wraps all of &lt;Title&gt;
	if accept_title and ('' == Title) then										-- only support forced empty for now &quot;(())&quot;
		Title = cfg.messages['notitle'];										-- replace by predefined &quot;No title&quot; message
			-- TODO: utilities.set_message ( 'err_redundant_parameters', ...);	-- issue proper error message instead of muting	 
			ScriptTitle = '';													-- just mute for now	 
			TransTitle = '';													-- just mute for now
 		plain_title = true;														-- suppress text decoration for descriptive title
		utilities.set_message ('maint_untitled');								-- add maint cat
	end

	if not accept_title then -- &lt;Title&gt; not wrapped in accept-as-written markup
		if '...' == Title:sub (-3) then											-- if ellipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%' .. sepc .. '$', '');			-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end

		if utilities.is_set (ArchiveURL) and is_archived_copy (Title) then
			utilities.set_message ('maint_archived_copy');						-- add maintenance category before we modify the content of Title
		end

		if is_generic_title (Title) then
			table.insert (z.message_tail, {utilities.set_message ( 'err_generic_title', {}, true ) } );	-- set an error message
		end
	end

	if (not plain_title) and (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) or
		('map' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)))) then		-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from module provided quote marks
			Title = utilities.wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle, 'script-title');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
			TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );
	elseif plain_title or ('report' == config.CitationClass) then								-- no styling for cite report and descriptive titles (otherwise same as above)
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = utilities.wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if utilities.is_set (TransTitle) then
		if utilities.is_set (Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. utilities.set_message ( 'err_trans_missing_title', {'title'} );
		end
	end

	if utilities.is_set (Title) then											-- TODO: is this the right place to be making Wikisource URLs?
		if utilities.is_set (TitleLink) and utilities.is_set (URL) then
			table.insert( z.message_tail, { utilities.set_message ( 'err_wikilink_in_url', {}, true ) } );	-- set an error message because we can't have both
			TitleLink = '';														-- unset
		end
		
		if not utilities.is_set (TitleLink) and utilities.is_set (URL) then
			Title = external_link (URL, Title, URL_origin, UrlAccess) .. TransTitle .. TransError .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif utilities.is_set (TitleLink) and not utilities.is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = utilities.make_wikilink (TitleLink, Title) .. TransTitle .. TransError;
			end
		else
			local ws_url, ws_label, L;											-- Title has italic or quote markup by the time we get here which causes is_wikilink() to return 0 (not a wikilink)
			ws_url, ws_label, L = wikisource_url_make (Title:gsub('[\'&quot;](.-)[\'&quot;]', '%1'));	-- make ws URL from |title= interwiki link (strip italic or quote markup); link portion L becomes tooltip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = Title .. TransTitle .. TransError;
			end
		end
	else
		Title = TransTitle .. TransError;
	end

	if utilities.is_set (Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if utilities.is_set (Conference) then
		if utilities.is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURL_origin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif utilities.is_set (ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURL_origin, nil );
	end

	if not utilities.is_set (Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if utilities.is_set (Minutes) then
			if utilities.is_set (Time) then
				table.insert( z.message_tail, { utilities.set_message ( 'err_redundant_parameters', {utilities.wrap_style ('parameter', 'minutes') .. ' and ' .. utilities.wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if utilities.is_set (Time) then
				local TimeCaption = A['TimeCaption']
				if not utilities.is_set (TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = utilities.is_set (At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = utilities.is_set (Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Sections = A['Sections'];											-- Section (singular) is an alias of Chapter so set earlier
		local Inset = A['Inset'];
		
		if utilities.is_set ( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if utilities.is_set ( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif utilities.is_set ( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if utilities.is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc.
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	Others = utilities.is_set (Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if utilities.is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if utilities.is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	TitleNote = utilities.is_set (TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if utilities.is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			utilities.set_message ('maint_extra_text', 'edition');				-- add maint cat
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = utilities.is_set (Series) and wrap_msg ('series', {sepc, Series}) or &quot;&quot;;	-- not the same as SeriesNum
	OrigDate = utilities.is_set (OrigDate) and wrap_msg ('origdate', OrigDate) or '';
	Agency = utilities.is_set (Agency) and wrap_msg ('agency', {sepc, Agency}) or &quot;&quot;;
	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	Via = utilities.is_set (Via) and  wrap_msg ('via', Via) or '';

	if utilities.is_set (AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = utilities.substitute (retrv_text, AccessDate);				-- add retrieved text

		AccessDate = utilities.substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if utilities.is_set (ID) then ID = sepc .. &quot; &quot; .. ID; end
   	if &quot;thesis&quot; == config.CitationClass and utilities.is_set (Docket) then
		ID = sepc .. &quot; Docket &quot; .. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and utilities.is_set (Docket) then		-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	if utilities.is_set (URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URL_origin, UrlAccess );
	end

	if utilities.is_set (Quote) or utilities.is_set (TransQuote) or utilities.is_set (ScriptQuote) then

		if utilities.is_set (Quote) then
			if Quote:sub(1, 1) == '&quot;' and Quote:sub(-1, -1) == '&quot;' then			-- if first and last characters of quote are quote marks
				Quote = Quote:sub(2, -2);										-- strip them off
			end
		end

		Quote = utilities.wrap_style ('quoted-text', Quote ); 	-- wrap in &lt;q&gt;...&lt;/q&gt; tags
	
		if utilities.is_set (ScriptQuote) then
			Quote = script_concatenate (Quote, ScriptQuote, 'script-quote'); -- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after quote is wrapped
		end

		if utilities.is_set (TransQuote) then
			if TransQuote:sub(1, 1) == '&quot;' and TransQuote:sub(-1, -1) == '&quot;' then -- if first and last characters of |trans-quote are quote marks
				TransQuote = TransQuote:sub(2, -2); -- strip them off
			end
			Quote = Quote .. &quot; &quot; .. utilities.wrap_style ('trans-quoted-title', TransQuote );
		end

		if utilities.is_set (QuotePage) or utilities.is_set (QuotePages) then	-- add page prefix
			local quote_prefix = '';
			if utilities.is_set (QuotePage) then
				if not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePage}), '', '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePage}), '', '', '';
				end
			elseif utilities.is_set (QuotePages) then
				if tonumber(QuotePages) ~= nil and not NoPP then				-- if only digits, assume single page
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePages}), '', '';
				elseif not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['pp-prefix'], {sepc, QuotePages}), '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePages}), '', '';
				end
			end
                        
			Quote = quote_prefix .. &quot;: &quot; .. Quote;
		else
			Quote = sepc .. &quot; &quot; .. Quote;
		end

		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if utilities.is_set (ArchiveURL) then
		local arch_text;
		if not utilities.is_set (ArchiveDate) then
			ArchiveDate = utilities.set_message ('err_archive_missing_date');
		end
		if &quot;live&quot; == UrlStatus then
			arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. utilities.substitute ( cfg.messages['archived-live'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil ) .. ArchiveFormat, ArchiveDate } );
			if not utilities.is_set (OriginalURL) then
				Archived = Archived .. &quot; &quot; .. utilities.set_message ('err_archive_missing_url');							   
			end
		elseif utilities.is_set (OriginalURL) then								-- UrlStatus is empty, 'dead', 'unfit', 'usurped', 'bot: unknown'
			if utilities.in_array (UrlStatus, {'unfit', 'usurped', 'bot: unknown'}) then
				arch_text = cfg.messages['archived-unfit'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. &quot; &quot; .. arch_text .. ArchiveDate;				-- format already styled
				if 'bot: unknown' == UrlStatus then
					utilities.set_message ('maint_bot_unknown');				-- and add a category if not already added
				else
					utilities.set_message ('maint_unfit');						-- and add a category if not already added
				end
			else																-- UrlStatus is empty, 'dead'
				arch_text = cfg.messages['archived-dead'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. &quot; &quot; .. utilities.substitute ( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURL_origin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else																	-- OriginalUrl not set
			arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. utilities.substitute ( arch_text, 
				{ utilities.set_message ('err_archive_missing_url'), ArchiveDate } );
		end
	elseif utilities.is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if utilities.is_set (LayURL) then
		if utilities.is_set (LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if utilities.is_set (LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. utilities.safe_for_italics (LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif utilities.is_set (LayFormat) then									-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if utilities.is_set (Transcript) then
		if utilities.is_set (TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURL_origin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif utilities.is_set (TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURL_origin, nil );
	end

	local Publisher;
	if utilities.is_set (PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if utilities.is_set (PublisherName) then
		if utilities.is_set (PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif utilities.is_set (PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical)) then
		if utilities.is_set (Title) or utilities.is_set (TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		else 
			Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		end
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then									-- cite speech only
		TitleNote = &quot; (Speech)&quot;;												-- annotate the citation
		if utilities.is_set (Periodical) then									-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if utilities.is_set (Conference) then								-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;							-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
		if utilities.is_set (Others) then Others = safe_join ({Others, sepc .. &quot; &quot;}, sepc) end		-- add terminal punctuation &amp; space; check for dup sepc; TODO why do we need to do this here?
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (Periodical) then		-- special cases for book cites
		if utilities.is_set (Contributors) then									-- when we are citing foreword, preface, introduction, etc.
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if utilities.is_set (Chapter) then										-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif utilities.is_set (Periodical) then								-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon;
	if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then	-- special case for cite AV media &amp; cite episode position transcript
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, Lay, Quote }, sepc );
	else
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, Lay, Quote }, sepc );
	end
	
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if utilities.is_set (Date) then
		if utilities.is_set (Authors) or utilities.is_set (Editors) then		-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date .. &quot;)&quot; .. OrigDate .. sepc .. &quot; &quot;;				-- in parentheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon, -1, -1) == sepc) then						-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigDate;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigDate;							-- Date begins with sepc
			end
		end
	end	
	if utilities.is_set (Authors) then
		if (not utilities.is_set (Date)) then									-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if utilities.is_set (Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then
					in_text = in_text:lower()									-- lowercase for cs2
				end
			end
			if EditorCount &lt;= 1 then
				post_text = &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot;;				-- be consistent with no-author, no-date case
			else
				post_text = &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot;;
			end
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Contributors) then									-- book cite and we're citing the intro, preface, etc.
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if utilities.is_set (Editors) and utilities.is_set (Date) then		-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not utilities.is_set (Date)) then								-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif utilities.is_set (Editors) then
		if utilities.is_set (Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if utilities.is_set (PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc ); 								--Deals with italics, spaces, etc.
		text = text:sub(1, -sepc:len() - 1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if utilities.is_set (config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = string.format ('%s %s %s', 'citation', config.CitationClass, utilities.is_set (Mode) and Mode or 'cs1');	-- class=citation required for blue highlight when used with |ref=
	else
		options.class = string.format ('%s %s', 'citation', utilities.is_set (Mode) and Mode or 'cs2');
	end
	
	if utilities.is_set (Ref) and 'none' ~= cfg.keywords_xlate[Ref:lower()] then
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			if #namelist &gt; 0 then												-- if there are names in namelist
				id = anchor_id (namelist, year);								-- go make the CITEREF anchor
			else
				id = '';														-- unset
			end
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;(.-)&lt;/span&gt;&quot;, &quot;%1&quot;):gsub(&quot;%b&lt;&gt;&quot;, &quot;&quot;)) &lt;= 2 then	-- remove &lt;span&gt; tags and other HTML-like markup; then get length of what remains
		z.error_categories = {};
		text = utilities.set_message ('err_empty_citation');
		z.message_tail = {};
	end
	
	local render = {};															-- here we collect the final bits for concatenation into the rendered citation

	if utilities.is_set (options.id) then										-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render, utilities.substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text}));	-- when |ref= is set
	else
		table.insert (render, utilities.substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text}));	-- all other cases
	end		

	table.insert (render, utilities.substitute (cfg.presentation['ocins'], {OCinSoutput}));	-- append metadata to the citation

	if 0 ~= #z.message_tail then
		table.insert (render, ' ');
		for i,v in ipairs( z.message_tail ) do
			if utilities.is_set (v[1]) then
				if i == #z.message_tail then
					table.insert (render, utilities.error_comment ( v[1], v[2] ));
				else
					table.insert (render, utilities.error_comment ( v[1] .. &quot;; &quot;, v[2] ));
				end
			end
		end
	end

	if 0 ~= #z.maintenance_cats then
		local maint_msgs = {};													-- here we collect all of the maint messages
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			local maint = {};													-- here we assemble a maintenence message
			table.insert (maint, v);											-- maint msg is the category name
			table.insert (maint, ' (');											-- open the link text
			table.insert (maint, utilities.make_wikilink (':Category:' .. v, 'link'));	-- add the link
			table.insert (maint, ')');											-- and close it
			table.insert (maint_msgs, table.concat (maint));					-- assemble new maint message and add it to the maint_msgs table
		end
		table.insert (render, utilities.substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs, ' ')));	-- wrap the group of maint message with proper presentation and save
	end
	
	if not no_tracking_cats then
		for _, v in ipairs( z.error_categories ) do
			table.insert (render, utilities.make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			table.insert (render, utilities.make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.properties_cats ) do								-- append properties categories
			table.insert (render, utilities.make_wikilink ('Category:' .. v));
		end
	elseif 'nocat' == A:ORIGIN('NoTracking') then								-- peculiar special case; can't track nocat without tracking nocat
		table.insert (render, utilities.make_wikilink ('Category:CS1 maint: nocat'));	-- hand-set this category because it is supposed to be temporary
	end

	return table.concat (render);	
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class, empty)
	local name = tostring (name);
	local state;
	local function state_test (state, name)										-- local function to do testing of state values
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			if empty then return nil; end										-- deprecated empty parameters are treated as unknowns
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
		return nil;
	end		

	if name:find ('#') then														-- # is a cs1|2 reserved character so parameters with # not permitted
		return nil;
	end

	if utilities.in_array (cite_class, whitelist.preprint_template_list ) then	-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[name];
		if true == state_test (state, name) then return true; end

		state = whitelist.preprint_arguments[cite_class][name];					-- look in the parameter-list for the template identified by cite_class
		if true == state_test (state, name) then return true; end

																				-- limited enumerated parameters list
		name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
		state = whitelist.limited_numbered_arguments[name];
		if true == state_test (state, name) then return true; end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates

	if utilities.in_array (cite_class, whitelist.unique_param_template_list) then 	-- experiment for template-specific parameters for templates that accept parameters from the basic argument list
		state = whitelist.unique_arguments[cite_class][name];					-- look in the template-specific parameter-lists for the template identified by cite_class
		if true == state_test (state, name) then return true; end
	end																			-- if here, fall into general validation
		
	state = whitelist.basic_arguments[name];									-- all other templates; all normal parameters allowed
	if true == state_test (state, name) then return true; end

																				-- all enumerated parameters allowed
	name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );												-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
	state = whitelist.numbered_arguments[name];
	if true == state_test (state, name) then return true; end

	return false;																-- not supported because not found or name is set to nil
end


--[=[-------------------------&lt; I N T E R _ W I K I _ C H E C K &gt;----------------------------------------------

check &lt;value&gt; for inter-language interwiki-link markup.  &lt;prefix&gt; must be a MediaWiki-recognized language
code.  when these values have the form (without leading colon):
	[[&lt;prefix&gt;:link|label]] return label as plain-text
	[[&lt;prefix&gt;:link]] return &lt;prefix&gt;:link as plain-text

return value as is else

]=]

local function inter_wiki_check (parameter, value)
	local prefix = value:match ('%[%[(%a+):');									-- get an interwiki prefix if one exists
	local _;
	
	if prefix and cfg.inter_wiki_map[prefix:lower()] then						-- if prefix is in the map, needs preceding colon so
		table.insert( z.message_tail, {utilities.set_message ('err_bad_paramlink', parameter)});	-- emit an error message
		_, value, _ = utilities.is_wikilink (value);							-- extract label portion from wikilink
	end
	return value;
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe.  There are two tests made:
	{{cite ... |title=Title access-date=2016-03-17}}	-- the first parameter has a value and whitespace separates that value from the missing pipe parameter name
	{{cite ... |title=access-date=2016-03-17}}			-- the first parameter has no value (whitespace after the first = is trimmed by MediaWiki)
cs1|2 shares some parameter names with XML/HTML attributes: class=, title=, etc.  To prevent false positives XML/HTML
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (parameter, value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove XML/HTML tags because attributes: class=, title=, etc.

	capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then										-- if the capture is a valid parameter name
		table.insert( z.message_tail, {utilities.set_message ('err_missing_pipe', parameter)});
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ P U N C T &gt;--------------------------------------

look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_punc (param, value)
	if 'number' == type (param) then
		return;
	end
	
	param = param:gsub ('%d+', '#');											-- enumerated name-list mask params allow terminal punct; normalize 
	if cfg.punct_skip[param] then
		return;																	-- parameter name found in the skip table so done
	end
	
	if value:match ('[,;:]$') then
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
end


--[[--------------------------&lt; C I T A T I O N &gt;--------------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

local function citation(frame)
	Frame = frame;																-- save a copy in case we need to display an error message in preview mode
	local pframe = frame:getParent()
	local styles;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		styles = 'Module:Citation/CS1/sandbox/styles.css';
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
		styles = 'Module:Citation/CS1/styles.css';
	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the selected cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text, error_state;

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do											-- get parameters from the {{#invoke}} frame
		config[k] = v;
	--	args[k] = v;															-- crude debug support that allows us to render a citation from module {{#invoke:}}; skips parameter validation; TODO: keep?
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	local empty_unknowns = {};													-- sequence table to hold empty unknown params for error message listing
	for k, v in pairs( pframe.args ) do											-- get parameters from the parent (template) frame
		v = mw.ustring.gsub (v, '^%s*(.-)%s*$', '%1');							-- trim leading/trailing whitespace; when v is only whitespace, becomes empty string
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = utilities.set_message ( 'err_text_ignored', {v}, true );
					end
				elseif validate( k:lower(), config.CitationClass ) then 
					error_text, error_state = utilities.set_message ( 'err_parameter_ignored_suggest', {k, k:lower()}, true );	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no capture in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = utilities.substitute (param, capture);		-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text, error_state = utilities.set_message ('err_parameter_ignored_suggest', {k, param}, true);	-- set the suggestion error message
							else
								error_text, error_state = utilities.set_message ( 'err_parameter_ignored', {param}, true );	-- suggested param not supported by this template
								v = '';											-- unset
							end
						end
					end
					if not utilities.is_set (error_text) then					-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = utilities.set_message ( 'err_parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = utilities.set_message ( 'err_parameter_ignored', {k}, true );
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end

			args[k] = v;														-- save this parameter and its value

		elseif not utilities.is_set (v) then									-- for empty parameters
			if not validate (k, config.CitationClass, true) then				-- is this empty parameter a valid parameter
				k = k:gsub ('^$', '(empty string)');							-- when k is empty string (or was space(s) trimmed to empty string), replace with descriptive text
				table.insert (empty_unknowns, utilities.wrap_style ('parameter', k));	-- format for error message and add to the list
			end
																				-- crude debug support that allows us to render a citation from module {{#invoke:}} TODO: keep?
	--	elseif args[k] ~= nil or (k == 'postscript') then						-- when args[k] has a value from {{#invoke}} frame (we don't normally do that)
	--		args[k] = v;														-- overwrite args[k] with empty string from pframe.args[k] (template frame); v is empty string here
		end																		-- not sure about the postscript bit; that gets handled in parameter validation; historical artifact?
	end	

	if 0 ~= #empty_unknowns then												-- create empty unknown error message
		table.insert (z.message_tail, {utilities.set_message ('err_param_unknown_empty', {
			1 == #empty_unknowns and '' or 's',
			utilities.make_sep_list (#empty_unknowns, empty_unknowns)
			}, true )});
	end

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);											-- look for invisible characters
		end
		has_extraneous_punc (k, v);												-- look for extraneous terminal punctuation in parameter values
		missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?
		args[k] = inter_wiki_check (k, v);										-- when language interwiki-linked parameter missing leading colon replace with wiki-link label
	end

	return table.concat ({citation0( config, args), frame:extensionTag ('templatestyles', '', {src=styles})});
end

--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {citation = citation};</text>
      <sha1>6t8lqyk2oib1zd3nfnj2lpimhw8jygg</sha1>
    </revision>
    <revision>
      <id>4737</id>
      <parentid>4736</parentid>
      <timestamp>2020-10-10T17:17:33Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4737</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="204447" sha1="g5r1sj962yc8asv8dj793xw4dsaa7ak" xml:space="preserve">
require('Module:No globals');

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------

each of these counts against the Lua upvalue limit

]]

local validation;																-- functions in Module:Citation/CS1/Date_validation

local utilities;																-- functions in Module:Citation/CS1/Utilities
local z ={};																	-- table of tables in Module:Citation/CS1/Utilities

local identifiers;																-- functions and tables in Module:Citation/CS1/Identifiers
local metadata;																	-- functions in Module:Citation/CS1/COinS
local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

declare variables here that have page-wide scope that are not brought in from other modules; that are created here and used here

]]

local added_deprecated_cat;														-- Boolean flag so that the category is added only once
local added_vanc_errs;															-- Boolean flag so we only emit one Vancouver error / category

local Frame;																	-- holds the module's frame table


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if utilities.is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a Boolean declared in page scope variables above

]]

local function add_vanc_error (source)
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { utilities.set_message ( 'err_vancouver', {source}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a URI scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of TLDs: https://www.iana.org/domains/root/db

RFC 952 (modified by RFC 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the TLD.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a URL with a scheme) will be stripped
here.  Perhaps not necessary but retained in case it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ASCII characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the TLD) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and TLD or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%w]') then											-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at Wikisource
		return false;
	end

	local patterns = {															-- patterns that look like URLs
		'%f[%w][%w][%w%-]+[%w]%.%a%a+$',										-- three or more character hostname.hostname or hostname.tld
		'%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$',									-- internationalized domain name with ACE prefix
		'%f[%a][qxz]%.com$',													-- assigned one character .com hostname (x.com times out 2015-12-10)
		'%f[%a][iq]%.net$',														-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		'%f[%w][%w]%.%a%a$',													-- one character hostname and ccTLD (2 chars)
		'%f[%w][%w][%w]%.%a%a+$',												-- two character hostname and TLD
		'^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?',								-- IPv4 address
		}

	for _, pattern in ipairs (patterns) do										-- loop through the patterns list
		if domain:match (pattern) then
			return true;														-- if a match then we think that this thing that purports to be a URL is a URL
		end
	end

	for _, d in ipairs ({'cash', 'company', 'today', 'org'}) do					-- look for single letter second level domain names for these top level domains
		if domain:match ('%f[%w][%w]%.' .. d) then
			return true
		end
	end
	return false;																-- no matches, we don't know what this thing is
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a URL appear to be a valid URL; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if utilities.is_set (scheme) then											-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when URL is protocol-relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a URL into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following TLD) (if any) and any path(/), query(?) or fragment(#).

If protocol-relative URL, return nil scheme and domain else return nil for both scheme and domain.

When not protocol-relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Any URL that does not have news: scheme must have authority indicator (//).  TODO: are there other common schemes
like news: that don't use authority indicator?

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol-relative URL
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		if utilities.is_set (authority) then
			authority = authority:gsub ('//', '', 1);							-- replace place 1 pair of '/' with nothing;
			if utilities.is_set(authority) then									-- if anything left (1 or 3+ '/' where authority should be) then
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		else
			if not scheme:match ('^news:') then									-- except for news:..., MediaWiki won't link URLs that do not have authority indicator; TODO: a better way to do this test?
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link=, etc. for properly formatted content: no wikilinks, no URLs

Link parameters are to hold the title of a Wikipedia article, so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki URLs and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid URL (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid URL (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from URL; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid URL
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wiki-linked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

check &lt;link&gt; for inter-language interwiki-link prefix.  prefix must be a MediaWiki-recognized language
code and must begin with a colon.

]]

local function link_title_ok (link, lorig, title, torig)
local orig;
	if utilities.is_set (link) then 											-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		elseif link:match ('^%a+:') then										-- if the link is what looks like an interwiki
			local prefix = link:match ('^(%a+):'):lower();						-- get the interwiki prefix

			if cfg.inter_wiki_map[prefix] then									-- if prefix is in the map, must have preceding colon
				orig = lorig;													-- flag as error
			end
		end
	end

	if utilities.is_set (orig) then
		link = '';																-- unset
		table.insert( z.message_tail, { utilities.set_message ( 'err_bad_paramlink', orig)});	-- URL or wikilink in |title= with |title-link=;
	end
	
	return link;																-- link if ok, empty string else
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the URL into scheme and domain
portions, or for protocol-relative (//example.com) URLs, just the domain.  Use is_url() to validate the two
portions of the URL.  If both are valid, or for protocol-relative if domain is valid, return true, else false.

Because it is different from a standard URL, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper URL
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from URL;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a URL.  The test will also find external wikilinks
that use protocol-relative URLs. Also finds bare URLs.

The frontier pattern prevents a match on interwiki-links which are similar to scheme:path URLs.  The tests that
find bracketed URLs are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext. wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol-relative ext. wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare URL with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol-relative bare URL: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a URL
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a URL add an error message
			if utilities.is_set(error_message) then								-- once we've added the first portion of the error message ...
				error_message = error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message = error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if utilities.is_set (error_message) then									-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { utilities.set_message ( 'err_param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { utilities.set_message ( 'err_wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source, access)
	local error_str = &quot;&quot;;
	local domain;
	local path;
	local base_url;

	if not utilities.is_set ( label ) then
		label = URL;
		if utilities.is_set ( source ) then
			error_str = utilities.set_message ( 'err_bare_url_missing_title', { utilities.wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = utilities.set_message ( 'err_bad_url', {utilities.wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the URL into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['['] = '%5b', [']'] = '%5d'});					-- replace '[' and ']' with their percent-encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wiki-markup URL

	if utilities.is_set (access) then											-- access level (subscription, registration, limited)
		base_url = utilities.substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end
	
	return table.concat ({base_url, error_str});
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a Boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { utilities.set_message ( 'err_deprecated_params', {name}, true ) } );	-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wiki-markup) are not kerned.

Replaces Unicode quote marks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc.; not for book titles.

]=]

local function kern_quotes (str)
	local cap = '';
	local cap2 = '';
	local wl_type, label, link;

	wl_type, label, link = utilities.is_wikilink (str);							-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-wl-both'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = utilities.substitute (cfg.presentation['kern-wl-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-wl-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label = mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label = mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap, cap2 = mw.ustring.match (label, &quot;^([\&quot;\'])([^\'].+)&quot;);				-- match leading double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-left'], {cap, cap2});
		end
	
		cap, cap2 = mw.ustring.match (label, &quot;^(.+[^\'])([\&quot;\'])$&quot;)				-- match trailing double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-right'], {cap, cap2});
		end
		
		if 2 == wl_type then
			str = utilities.make_wikilink (link, label);						-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin-based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate RTL languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO 639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO 639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title=, |script-chapter=, |script-&lt;periodical&gt;=

]]

local function format_script_value (script_value, script_param)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%l?%s*:') then									-- if first 3 or 4 non-space characters are script language prefix
		lang = script_value:match('^(%l%l%l?)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not utilities.is_set (lang) then
			table.insert( z.message_tail, { utilities.set_message ( 'err_script_parameter', {script_param, 'missing title part'}, true ) } );		-- prefix without 'title'; add error message
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_code_remap[lang] or mw.language.fetchLanguageName( lang, cfg.this_wiki_code );	-- get language name so that we can use it to categorize
		if utilities.is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l+%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if utilities.in_array (lang, cfg.script_lang_codes) then
				utilities.add_prop_cat ('script_with_name', {name, lang})
			else
				table.insert( z.message_tail, { utilities.set_message ( 'err_script_parameter', {script_param, 'unknown language code'}, true ) } );	-- unknown script-language; add error message
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			table.insert( z.message_tail, { utilities.set_message ( 'err_script_parameter', {script_param, 'invalid language code'}, true ) } );		-- invalid language code; add error message
			lang = '';															-- invalid so set lang to empty string
		end
	else
		table.insert( z.message_tail, { utilities.set_message ( 'err_script_parameter', {script_param, 'missing prefix'}, true ) } );				-- no language code prefix; add error message
	end
	script_value = utilities.substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is RTL

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script, script_param)
	if utilities.is_set (script) then
		script = format_script_value (script, script_param);					-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; returns empty string on error
		if utilities.is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not utilities.is_set ( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return utilities.substitute ( msg, str );								-- including template text
	else
		return utilities.substitute ( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;----------------------------------------

Makes a Wikisource URL from Wikisource interwiki-link.  Returns the URL and appropriate label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;
	local wikisource_prefix = table.concat ({'https://', cfg.this_wiki_code, '.wikisource.org/wiki/'});

	wl_type, D, L = utilities.is_wikilink (str);								-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 1 == wl_type then													-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end
	
	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable URL
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent encoding of fragment marker
	end

	return ws_url, ws_label, L or D;											-- return proper URL or nil and a label or nil
end


--[[--------------------------&lt; F O R M A T _ P E R I O D I C A L &gt;--------------------------------------------

Format the three periodical parameters: |script-&lt;periodical&gt;=, |&lt;periodical&gt;=, and |trans-&lt;periodical&gt;= into a single Periodical meta-
parameter.

]]

local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)
	local periodical_error = '';

	if not utilities.is_set (periodical) then
		periodical = '';														-- to be safe for concatenation
	else
		periodical = utilities.wrap_style ('italic-title', periodical);			-- style 
	end

	periodical = script_concatenate (periodical, script_periodical, script_periodical_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (trans_periodical) then
		trans_periodical = utilities.wrap_style ('trans-italic-title', trans_periodical);
		if utilities.is_set (periodical) then
			periodical = periodical .. ' ' .. trans_periodical;
		else																	-- here when trans-periodical without periodical or script-periodical
			periodical = trans_periodical;
			periodical_error = ' ' .. utilities.set_message ('err_trans_missing_title', {'periodical'});
		end
	end

	return periodical .. periodical_error;
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (script_chapter, script_chapter_source, chapter, chapter_source, trans_chapter, trans_chapter_source, chapter_url, chapter_url_source, no_quotes, access)
	local chapter_error = '';

	local ws_url, ws_label, L = wikisource_url_make (chapter);					-- make a wikisource URL and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', '');										-- replace underscore separaters with space characters
		chapter = ws_label;
	end

	if not utilities.is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from module provided quote marks
			chapter = utilities.wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, script_chapter, script_chapter_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (chapter_url) then
		chapter = external_link (chapter_url, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');	-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if utilities.is_set (trans_chapter) then
		trans_chapter = utilities.wrap_style ('trans-quoted-title', trans_chapter);
		if utilities.is_set (chapter) then
			chapter = chapter .. ' ' .. trans_chapter;
		else																	-- here when trans_chapter without chapter or script-chapter
			chapter = trans_chapter;
			chapter_source = trans_chapter_source:match ('trans%-?(.+)');		-- when no chapter, get matching name from trans-&lt;param&gt;
			chapter_error = ' ' .. utilities.set_message ('err_trans_missing_title', {chapter_source});
		end
	end

	return chapter .. chapter_error;
end


--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for non-printable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the Wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i = 1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no Unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char = cfg.invisible_chars[i][1]									-- the character or group name
		local pattern = cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position and (char == 'zero width joiner') then						-- if we found a zero-width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- it's ok if one of the Indic scripts
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and utilities.in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { utilities.set_message ( 'err_invisible_char', {err_msg, utilities.wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i = i+1;																-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper ( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function ( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = utilities.select_one ( args, list, 'err_redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] .. ': ' .. k);
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap = '';
	local cap2 = '';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = utilities.substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = utilities.substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if utilities.is_set (title_type) then
		if 'none' == cfg.keywords_xlate[title_type] then
			title_type = '';													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash under certain conditions.  The hyphen must separate like items; unlike items are
returned unmodified.  These forms are modified:
	letter - letter (A - B)
	digit - digit (4-5)
	digit separator digit - digit separator digit (4.1-4.5 or 4-1-4-5)
	letterdigit - letterdigit (A1-A5) (an optional separator between letter and digit is supported – a.1-a.5 or a-1-a-5)
	digitletter - digitletter (5a - 5d) (an optional separator between letter and digit is supported – 5.a-5.d or 5-a-5-d)

any other forms are returned unmodified.

str may be a comma- or semicolon-separated list

]]

local function hyphen_to_dash( str )
	if not utilities.is_set (str) then
		return str;
	end

	local accept;																-- Boolean
	str, accept = utilities.has_accept_as_written (str);						-- remove accept-this-as-written markup when it wraps all of str
	if accept then
		return str;																-- when markup removed, nothing to do, we're done
	end

	str = str:gsub ('&amp;[nm]dash;', {['&amp;ndash;'] = '–', ['&amp;mdash;'] = '—'});		-- replace &amp;mdash; and &amp;ndash; entities with their characters; semicolon mucks up the text.split
	str = str:gsub ('&amp;#45;', '-');												-- replace HTML numeric entity with hyphen character
	str = str:gsub ('&amp;nbsp;', ' ');												-- replace &amp;nbsp; entity with generic keyboard space character
	
	local out = {};
	local list = mw.text.split (str, '%s*[,;]%s*');								-- split str at comma or semicolon separators if there are any

	for _, item in ipairs (list) do												-- for each item in the list
		if mw.ustring.match (item, '^%w*[%.%-]?%w+%s*[%-–—]%s*%w*[%.%-]?%w+$') then	-- if a hyphenated range or has endash or emdash separators
			if item:match ('^%a+[%.%-]?%d+%s*%-%s*%a+[%.%-]?%d+$') or			-- letterdigit hyphen letterdigit (optional separator between letter and digit)
				item:match ('^%d+[%.%-]?%a+%s*%-%s*%d+[%.%-]?%a+$') or			-- digitletter hyphen digitletter (optional separator between digit and letter)
				item:match ('^%d+[%.%-]%d+%s*%-%s*%d+[%.%-]%d+$') or			-- digit separator digit hyphen digit separator digit
				item:match ('^%d+%s*%-%s*%d+$') or								-- digit hyphen digit
				item:match ('^%a+%s*%-%s*%a+$') then							-- letter hyphen letter
					item = item:gsub ('(%w*[%.%-]?%w+)%s*%-%s*(%w*[%.%-]?%w+)', '%1–%2');	-- replace hyphen, remove extraneous space characters
			else
				item = mw.ustring.gsub (item, '%s*[–—]%s*', '–');				-- for endash or emdash separated ranges, replace em with en, remove extraneous whitespace
			end
		end
		item = utilities.has_accept_as_written (item);							-- remove accept-this-as-written markup when it wraps all of str
		table.insert (out, item);												-- add the (possibly modified) item to the output table
	end

	return table.concat (out, ', ');											-- concatenate the output table into a comma separated string
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'duplicate character'
		if 1 == #duplicate_char then											-- for single byte ASCII characters use the string library functions
			f.gsub = string.gsub
			f.match = string.match
			f.sub = string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub = mw.ustring.gsub
			f.match = mw.ustring.match
			f.sub = mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1, 1) == '&lt;' then										-- special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove HTML markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1, 1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc.?
				trim = false;
				end_chr = f.sub(str, -1, -1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr .. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1, -2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5, -1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3, -1) == duplicate_char .. '&quot;]' then		-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2, -1) == duplicate_char .. &quot;]&quot; then		-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2, -1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1, -3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains HTML markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows HTML markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;------------------------------------------------------------

returns true is suffix is properly formed Jr, Sr, or ordinal in the range 1–9.  Puncutation not allowed.

]]

local function is_suffix (suffix)
	if utilities.in_array (suffix, {'Jr', 'Sr', 'Jnr', 'Snr', '1st', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written outside of the code editor and pasted here because the code editor gets confused between character insertion point and cursor position.
The test has been rewritten to use decimal character escape sequence for the individual bytes of the Unicode characters so that it is not necessary
to use an external editor to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first, suffix)
	if not suffix then
		if first:find ('[,%s]') then											-- when there is a space or comma, might be first name/initials + generational suffix
			first = first:match ('(.-)[,%s]+');									-- get name/initials
			suffix = first:match ('[,%s]+(.+)$');								-- get generational suffix
		end
	end
	if utilities.is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error (cfg.err_msg_supl.suffix);
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error (cfg.err_msg_supl['non-Latin char']);
			return false;														-- not a string of Latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-style=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc.) to be rendered as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the Unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just initials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error (cfg.err_msg_supl.suffix);					-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word

	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i], 1, 1));				-- insert the initial at end of initials table
		end
		i = i+1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; L I S T _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors, contributors, editors, interviewers, translators) 

names in the list will be linked when
	|&lt;name&gt;-link= has a value
	|&lt;name&gt;-mask- does NOT have a value; masked names are presumed to have been rendered previously so should have been linked there

when |&lt;name&gt;-mask=0, the associated name is not rendered

]]

local function list_people (control, people, etal)
	local sep;
	local namesep;
	local format = control.format;
	local maximum = control.maximum;
	local lastauthoramp = control.lastauthoramp;							-- TODO: delete after deprecation
	local name_list = {};

	if 'vanc' == format then													-- Vancouver-like name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between names is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
		lastauthoramp = nil;												-- TODO: delete after deprecation	-- unset because isn't used by Vancouver style
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between names is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub (-1, -1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if utilities.is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end		-- returned 0 is for EditorCount; not used for other names
	
	for i, person in ipairs (people) do
		if utilities.is_set (person.last) then
			local mask = person.mask;
			local one;
			local sep_one = sep;

			if utilities.is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			end
			
			if mask then
				local n = tonumber (mask);										-- convert to a number if it can be converted; nil else
				if n then
					one = 0 ~= n and string.rep(&quot;&amp;mdash;&quot;,n) or nil;			-- make a string of (n &gt; 0) mdashes, nil else, to replace name
					person.link = nil;											-- don't create link to name if name is replaces with mdash string or has been set nil
				else
					one = mask;													-- replace name with mask text (must include name-list separator)
					sep_one = &quot; &quot;;												-- modify name-list separator
				end
			else
				one = person.last;												-- get surname
				local first = person.first										-- get given name
				if utilities.is_set (first) then
					if (&quot;vanc&quot; == format) then									-- if Vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials (first);					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
			end
			if utilities.is_set (person.link) then
				one = utilities.make_wikilink (person.link, one);				-- link author/editor
			end
			if one then															-- if &lt;one&gt; has a value (name, mdash replacement, or mask text replacement)
				table.insert (name_list, one);									-- add it to the list of names
				table.insert (name_list, sep_one);								-- add the proper name-list separator
			end
		end
	end

	local count = #name_list / 2;												-- (number of names + number of separators) divided by 2
	if 0 &lt; count then 
		if 1 &lt; count and not etal then
			if 'amp' == format or utilities.is_set (lastauthoramp) then			-- TODO: delete lastauthoramp after deprecation
				name_list[#name_list-2] = &quot; &amp; &quot;;								-- replace last separator with ampersand text
			elseif 'and' == format then
				if 2 == count then
					name_list[#name_list-2] = cfg.presentation.sep_nl_and;		-- replace last separator with 'and' text
				else
					name_list[#name_list-2] = cfg.presentation.sep_nl_end;		-- replace last separator with '(sep) and' text
				end
			end
		end
		name_list[#name_list] = nil;											-- erase the last separator
	end

	local result = table.concat (name_list);									-- construct list
	if etal and utilities.is_set (result) then									-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've got a last-first list and etal so add et al.
	end
	
	return result, count;														-- return name-list string and count of number of names (count used for editor names only)
end


--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]

local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if utilities.is_set (id) then												-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of name parameters (author, editor, etc.) for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the associated |display-&lt;names&gt;=etal parameter

]]

local function name_has_etal (name, etal, nocat, param)

	if utilities.is_set (name) then												-- name can be nil in which case just return
		local patterns = cfg.et_al_patterns;									--get patterns from configuration
		
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns
			if name:match (pattern) then										-- if this 'et al' pattern is found in name
				name = name:gsub (pattern, '');									-- remove the offending text
				etal = true;													-- set flag (may have been set previously here or by |display-&lt;names&gt;=etal)
				if not nocat then												-- no categorization for |vauthors=
					table.insert( z.message_tail, {utilities.set_message ('err_etal', {param})});	-- and set an error if not added
				end
			end
		end
	end

	return name, etal;
end


--[[--------------------------&lt; N A M E _ I S _ N U M E R I C &gt;------------------------------------------------

Add maint cat when name parameter value does not contain letters.  Does not catch mixed alphanumeric names so
|last=A. Green (1922-1987) does not get caught in the current version of this test but |first=(1888) is caught.

returns nothing

]]

local function name_is_numeric (name, list_name)
	if utilities.is_set (name) then
		if mw.ustring.match (name, '^[%A]+$') then								-- when name does not contain any letters
			utilities.set_message ('maint_numeric_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
		end
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E D _ M A R K U P &gt;------------------------------------------

Evaluates the content of author and editor parameters for extraneous editor annotations: ed, ed., eds, (Ed.), etc.
These annotation do not belong in author parameters and are redundant in editor parameters.  If found, the function
adds the editor markup maintenance category.

returns nothing

]]

local function name_has_ed_markup (name, list_name)
	local patterns = cfg.editor_markup_patterns;								-- get patterns from configuration

	if utilities.is_set (name) then
		for _, pattern in ipairs (patterns) do									-- spin through patterns table and
			if name:match (pattern) then
				utilities.set_message ('maint_extra_text_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
				break;
			end
		end
	end
end


--[[--------------------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;----------------------------------------

Evaluates the content of last/surname (authors etc.) parameters for multiple names.  Multiple names are indicated
if there is more than one comma or any semicolons.  If found, the function adds the multiple name maintenance category.

returns nothing

]]

local function name_has_mult_names (name, list_name)
	local _, commas, semicolons;
	if utilities.is_set (name) then
		_, commas = name:gsub (',', '');										-- count the number of commas
		_, semicolons = name:gsub (';', '');									-- count the number of semicolons
		
		if 1 &lt; commas or 0 &lt; semicolons then												
			utilities.set_message ('maint_mult_names', cfg.special_case_translation [list_name]);	-- add a maint message
		end
	end
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------

This function calls various name checking functions used to validate the content of the various name-holding
parameters.

]]

local function name_checks (last, first, list_name)
	local accept_name;

	if utilities.is_set (last) then
		last, accept_name = utilities.has_accept_as_written (last);				-- remove accept-this-as-written markup when it wraps all of &lt;last&gt;
		
		if not accept_name then													-- &lt;last&gt; not wrapped in accept-as-written markup
			name_has_mult_names (last, list_name);								-- check for multiple names in the parameter (last only)
			name_has_ed_markup (last, list_name);								-- check for extraneous 'editor' annotation
			name_is_numeric (last, list_name);									-- check for names that are compsed of digits and punctuation
		end
	end

	if utilities.is_set (first) then
		first, accept_name = utilities.has_accept_as_written (first);			-- remove accept-this-as-written markup when it wraps all of &lt;first&gt;

		if not accept_name then														-- &lt;first&gt; not wrapped in accept-as-written markup
			name_has_ed_markup (first, list_name);								-- check for extraneous 'editor' annotation
			name_is_numeric (first, list_name);									-- check for names that are compsed of digits and punctuation
		end
	end

	return last, first;															-- done
end


--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};															-- table of names
	local last;																	-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;																-- loop counter/indexer
	local n = 1;																-- output table indexer
	local count = 0;															-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal = false;															-- return value set to true when we find some form of et al. in an author parameter

	local last_alias, first_alias, link_alias;									-- selected parameter aliases used in error messaging
	while true do
		last, last_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'err_redundant_parameters', i );		-- search through args for name components beginning at 1
		first, first_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'err_redundant_parameters', i );
		link, link_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i );
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.
		last, first = name_checks (last, first, list_name);						-- multiple names, extraneous annotation, etc. checks
		
		if first and not last then												-- if there is a firstn without a matching lastn
			local alias = first_alias:find ('given', 1, true) and 'given' or 'first';	-- get first or given form of the alias
			table.insert (z.message_tail, { utilities.set_message ( 'err_first_missing_last', {
				first_alias,													-- param name of alias missing its mate
				first_alias:gsub (alias, {['first'] = 'last', ['given'] = 'surname'}),	-- make param name appropriate to the alias form
				}, true ) } );													-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			local result;
			link = link_title_ok (link, link_alias, last, last_alias);			-- check for improper wiki-markup
			if first then
				link = link_title_ok (link, link_alias, first, first_alias);	-- check for improper wiki-markup
			end

			names[n] = {last = last, first = first, link = link, mask = mask, corporate = false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { utilities.set_message ( 'err_missing_name', {list_name:match (&quot;(%w+)List&quot;):lower(), i - 1}, true ) } );	-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names and the etal flag
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because case of the source may be incorrect
or different from the case that WikiMedia uses, the name comparisons are done in lower case and when a match is
found, the Wikimedia version (assumed to be correct) is returned along with the code.  When there is no match, we
return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') returns a list of languages that in some cases may include
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.  Most (all?) of these languages are not used a 'language' codes per se, rather they
are used as sub-domain names: cbk-zam.wikipedia.org.  A list of language names and codes supported by fetchLanguageNames()
can be found at Template:Citation Style documentation/language/doc

Names that are included in the list will be found if that name is provided in the |language= parameter.  For example,
if |language=Chavacano de Zamboanga, that name will be found with the associated code 'cbk-zam'.  When names are found
and the associated code is not two or three characters, this function returns only the WikiMedia language name.

Some language names have multiple entries under different codes:
	Aromanian has code rup and code roa-rup
When this occurs, this function returns the language name and the 2- or 3-character code

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	if cfg.lang_name_remap[lang:lower()] then									-- if there is a remapped name (because MediaWiki uses something that we don't think is correct)
		return cfg.lang_name_remap[lang:lower()][1], cfg.lang_name_remap[lang:lower()][2];	-- for this language 'name', return a possibly new name and appropriate code
	end

	local ietf_code;															-- because some languages have both IETF-like codes and ISO 639-like codes
	local ietf_name;
	
	local langlc = mw.ustring.lower (lang);										-- lower-case version for comparisons

	for code, name in pairs (cfg.languages) do									-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower (name) then
			if 2 == #code or 3 == #code then									-- two- or three-character codes only; IETF extensions not supported
				return name, code;												-- so return the name and the code
			end
			ietf_code = code;													-- remember that we found an IETF-like code and save its name
			ietf_name = name;													-- but keep looking for a 2- or 3-char code
		end
	end
																				-- didn't find name with 2- or 3-char code; if IETF-like code found return
	return ietf_code and ietf_name or lang;										-- associated name; return original language text else
end


--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code is recognized by MediaWiki,
use the returned name; if not, then use the value that was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is assigned to the category for
that code: Category:Norwegian-language sources (no).  For valid three-character code languages, the page is assigned
to the single category for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does not recognize three-character
equivalents of two-character codes: code 'ar' is recognized but code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are
separated from each other by commas with optional space characters.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki_name = mw.language.fetchLanguageName (cfg.this_wiki_code, cfg.this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang
		name = cfg.lang_code_remap[lang:lower()];								-- first see if this is a code that is not supported by MediaWiki but is in remap

		if name then															-- there was a remapped code so
			if not lang:match ('^%a%a%a?%-x%-%a+$') then						-- if not a private IETF tag
				lang = lang:gsub ('^(%a%a%a?)%-.*', '%1');						-- strip IETF tags from code
			end
		else
			lang = lang:gsub ('^(%a%a%a?)%-.*', '%1');							-- strip any IETF-like tags from code
			if 2 == lang:len() or 3 == lang:len() then							-- if two-or three-character code
				name = mw.language.fetchLanguageName (lang:lower(), cfg.this_wiki_code);	-- get language name if |language= is a proper code
			end
		end

		if utilities.is_set (name) then											-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, cfg.this_wiki_code);			-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if utilities.is_set (code) then											-- only 2- or 3-character codes
			name = cfg.lang_code_remap[code] or name;							-- override wikimedia when they misuse language codes/names

			if cfg.this_wiki_code ~= code then									-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					utilities.add_prop_cat ('foreign_lang_source' .. code, {name, code});	-- categorize it; code appended to allow for multiple language categorization
				else															-- or is a recognized language (but has a three-character code)
					utilities.add_prop_cat ('foreign_lang_source_2' .. code, {code});		-- categorize it differently TODO: support multiple three-character code categories per cs1|2 template
				end
			elseif cfg.local_lang_cat_enable then								-- when the language and this wiki's language are the same and categorization is enabled
				utilities.add_prop_cat ('local_lang_source', {name, code});		-- categorize it
			end
		else
			utilities.set_message ('maint_unknown_lang');						-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
 
	name = utilities.make_sep_list (#language_list, language_list);

	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings
At en.wiki, for cs1:
	ps gets:	'.'
	sep gets:	'.'

]]

local function set_cs1_style (ps)
	if not utilities.is_set (ps) then											-- unless explicitly set to something
		ps = cfg.presentation['ps_cs1'];										-- terminate the rendered citation
	end
	return cfg.presentation['sep_cs1'], ps;										-- element separator
end


--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings
At en.wiki, for cs2:
	ps gets:	'' (empty string - no terminal punctuation)
	sep gets:	','

]]

local function set_cs2_style (ps, ref)
	if not utilities.is_set (ps) then											-- if |postscript= has not been set, set cs2 default
		ps = cfg.presentation['ps_cs2'];										-- terminate the rendered citation
	end
	if not utilities.is_set (ref) then											-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return cfg.presentation['sep_cs2'], ps, ref;								-- element separator
end


--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end


--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end

	if cfg.keywords_xlate[ps:lower()] == 'none' then							-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end


--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a URL has the file extension that is one of the PDF file extensions used by [[MediaWiki:Common.css]] when
applying the PDF icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or
		url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
		url:match ('%.PDF&amp;#035') or url:match ('%.pdf&amp;#035');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies CSS style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching URL parameter.  If the format parameter is not set and the URL contains a file extension that
is recognized as a PDF document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if utilities.is_set (format) then
		format = utilities.wrap_style ('format', format);						-- add leading space, parentheses, resize
		if not utilities.is_set (url) then
			format = format .. ' ' .. utilities.set_message ( 'err_format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if URL is a PDF file then
		format = utilities.wrap_style ('format', 'PDF');						-- set format to PDF
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[--------------------------&lt; G E T _ D I S P L A Y _ N A M E S &gt;--------------------------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a Boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_names (max, count, list_name, etal)
	if utilities.is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				table.insert( z.message_tail, {utilities.set_message ('err_disp_name', {cfg.special_case_translation [list_name], max}, true)});	-- add error message
				max = nil;
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, {utilities.set_message ('err_disp_name', {cfg.special_case_translation [list_name], max}, true)});		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		utilities.set_message ('maint_extra_text');								-- add maint cat;
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parentheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a place holder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parentheses
			local name = name_table[i];
			i = i + 1;																-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parentheses
					break;														-- and done reassembling so
				end
				i = i + 1;														-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = utilities.is_wikilink (name_table[i]);		-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i + 1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled parentheses ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the Vancouver error when a required comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		first = '';																-- set to empty string for concatenation and because it may have been set for previous author/editor
		local accept_name;
		v_name, accept_name = utilities.has_accept_as_written (v_name);			-- remove accept-this-as-written markup when it wraps all of &lt;v_name&gt;

--		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parentheses to suppress vanc formatting and error detection
--			last = v_name:match ('^%(%((.+)%)%)$')								-- remove doubled parentheses
		if accept_name then
			last = v_name;
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error (cfg.err_msg_supl.punctuation);
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s+&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be initials or generational suffix

			if not mw.ustring.match (first, '^%u+$') then						-- mw.ustring here so that later we will catch non-Latin characters
				suffix = first;													-- not initials so assume that whatever we got is a generational suffix
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end
			last = table.concat(lastfirstTable, ' ')							-- returns a string that is the concatenation of all other names that are not initials and generational suffix
			if not utilities.is_set (last) then
				first = '';														-- unset
				last = v_name;													-- last empty because something wrong with first
				add_vanc_error (cfg.err_msg_supl.name);
			end
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error (cfg.err_msg_supl['missing comma']);				-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error (cfg.err_msg_supl.name);							-- matches a space between two initials
			end
		else
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
		
		if utilities.is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error (cfg.err_msg_supl.initials);						-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first, suffix);							-- check first and last before restoring the suffix which may have a non-Latin digit
			if utilities.is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '');
			end
		end

		link = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i ) or v_link_table[i];
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate = corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
	local lastfirst = false;
	if utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice in case we have a |first1= without a |last1=; this ...
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or		-- ... also catches the case where |first= is used with |vauthors=
		utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst = true;
	end

	if (utilities.is_set (vxxxxors) and true == lastfirst) or					-- these are the three error conditions
		(utilities.is_set (vxxxxors) and utilities.is_set (xxxxors)) or
		(true == lastfirst and utilities.is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { utilities.set_message ( 'err_redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if utilities.is_set (vxxxxors) then return 2 end;
	if utilities.is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, live, dead, etc.).  When the parameter value has not been assigned a value (missing
or empty in the source template) the function returns the value specified by ret_val.  If the parameter value is one
of the list of allowed values returns the translated value; else, emits an error message and returns the value
specified by ret_val.

]]

local function is_valid_parameter_value (value, name, possible, ret_val)
	if not utilities.is_set (value) then
		return ret_val;															-- an empty parameter is ok
	elseif utilities.in_array (value, possible) then
		return cfg.keywords_xlate[value];										-- return translation of parameter keyword
	else
		table.insert( z.message_tail, { utilities.set_message ( 'err_invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return ret_val;
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list, -3, -1) == sepc .. '. ') then					-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list, -1, -1) == sepc) or (string.sub (name_list, -3, -1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terminate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not utilities.is_set (volume) and not utilities.is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (utilities.in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if utilities.is_set (volume) and utilities.is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif utilities.is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end

	if 'podcast' == cite_class and utilities.is_set (issue) then
		return wrap_msg ('issue', {sepc, issue}, lower);
	end

	local vol = '';																-- here for all cites except magazine
		
	if utilities.is_set (volume) then
		if volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$') then			-- volume value is all digits or all uppercase Roman numerals
			vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});	-- render in bold face
		elseif (4 &lt; mw.ustring.len(volume)) then								-- not all digits or Roman numerals and longer than 4 characters
			vol = utilities.substitute (cfg.messages['j-vol'], {sepc, volume});	-- not bold
			utilities.add_prop_cat ('long_vol');
		else																	-- four or less characters
			vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});	-- bold
		end
	end
	if utilities.is_set (issue) then
		return vol .. utilities.substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if utilities.is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif utilities.is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if utilities.is_set (page) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return utilities.substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return utilities.substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif utilities.is_set (pages) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then							-- if pages is only digits, assume a single page number
			return '', utilities.substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', utilities.substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', utilities.substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to Wikisource, returns the label portion of the interwiki-link as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki-link to and external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, pages, at)
	local ws_url, ws_label, coins_pages, L;										-- for Wikisource interwiki-links; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if utilities.is_set (page) then
		if utilities.is_set (pages) or utilities.is_set (at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws URL from |page= interwiki link; link portion L becomes tooltip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (pages) then
		if utilities.is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws URL from |pages= interwiki link; link portion L becomes tooltip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws URL from |at= interwiki link; link portion L becomes tooltip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org URLs to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot URL or to calendar pages.  When the archive URL is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the URL.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org URL does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command URL
	|archive-url= is an archive.org URL that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org URLs:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this function may return a modified
archive URL:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the URL unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.org URL
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine URL
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command URL, we don't want to allow saving of the target page 
		err_msg = cfg.err_msg_supl.save;
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = cfg.err_msg_supl.liveweb;
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');	-- split out some of the URL parts for evaluation
		
		if not utilities.is_set (timestamp) or 14 ~= timestamp:len() then		-- path and flag optional, must have 14-digit timestamp here
			err_msg = cfg.err_msg_supl.timestamp;
			if '*' ~= flag then
				url=url:gsub ('(//web%.archive%.org/[^%d]*%d?%d?%d?%d?%d?%d?)[^/]*', '%1*', 1)	-- for preview, modify ts to be yearmo* max (0-6 digits plus splat)
			end
		elseif utilities.is_set (path) and 'web/' ~= path then					-- older archive URLs do not have the extra 'web/' path element
			err_msg = cfg.err_msg_supl.path;
		elseif utilities.is_set (flag) and not utilities.is_set (path) then		-- flag not allowed with the old form URL (without the 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		elseif utilities.is_set (flag) and not flag:match ('%a%a_') then		-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		else
			return url, date;													-- return ArchiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	table.insert( z.message_tail, { utilities.set_message ( 'err_archive_url', {err_msg}, true ) } );	-- add error message and
	if utilities.is_set (Frame:preprocess('{{REVISIONID}}')) then
		return '', '';															-- return empty strings for ArchiveURL and ArchiveDate
	else
		return url, date;														-- preview mode so return ArchiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; P L A C E _ C H E C K &gt;--------------------------------------------------------

check |place=, |publication-place=, |location= to see if these params include digits.  This function added because
many editors misuse location to specify the in-source location (|page(s)= and |at= are supposed to do that)

returns the original parameter value without modification; added maint cat when parameter value contains digits

]]

local function place_check (param_val)
	if not utilities.is_set (param_val) then									-- parameter empty or omitted
		return param_val;														-- return that empty state
	end
	
	if mw.ustring.find (param_val, '%d') then									-- not empty, are there digits in the parameter value
		utilities.set_message ('maint_location');								-- yep, add maint cat
	end
	
	return param_val;															-- and done
end


--[[--------------------------&lt; I S _ G E N E R I C _ T I T L E &gt;----------------------------------------------

compares |title= value against list of known generic title patterns.  Returns true when pattern matches; nil else

the k/v pairs in 'generic_titles' each contain two tables, one for English and one for another 'local' language
Each of those tables contain another table that holds the string or pattern (whole title or title fragment) in
index [1].  index [2] is a Boolean that tells string.find() or mw.ustring.find() to do plain-text search (true)
or a pattern search (false).  The intent of all this complexity is to make these searches as fast as possible so
that we don't run out of processing time on very large articles.

]]

local function is_generic_title (title)
	title = mw.ustring.lower(title);											-- switch title to lower case
	for _, generic_title in ipairs (cfg.special_case_translation['generic_titles']) do	--spin through the list of known generic title fragments
		if title:find (generic_title['en'][1], 1, generic_title['en'][2]) then
			return true;														-- found English generic title so done
		elseif generic_title['local'] then										-- to keep work load down, generic_title['local'] should be nil except when there is a local version of the generic title
			if mw.ustring.find (title, generic_title['local'][1], 1, generic_title['local'][2]) then	-- mw.ustring() because might not be Latin script
				return true;													-- found local generic title so done
			end
		end
	end
end


--[[--------------------------&lt; I S _ A R C H I V E D _ C O P Y &gt;----------------------------------------------

compares |title= to 'Archived copy' (place holder added by bots that can't find proper title); if matches, return true; nil else

]]

local function is_archived_copy (title)
	title = mw.ustring.lower(title);											-- switch title to lower case
	if title:find (cfg.special_case_translation.archived_copy.en) then			-- if title is 'Archived copy'
		return true;
	elseif cfg.special_case_translation.archived_copy['local'] then
		if mw.ustring.find (title, cfg.special_case_translation.archived_copy['local']) then	-- mw.ustring() because might not be Latin script
			return true;
		end
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper ( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

	local Mode = is_valid_parameter_value (A['Mode'], A:ORIGIN('Mode'), cfg.keywords_lists['mode'], '');

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;

	local NameListStyle = is_valid_parameter_value (A['NameListStyle'], A:ORIGIN('NameListStyle'), cfg.keywords_lists['name-list-style'], '');
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';											-- override whatever |name-list-style= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				utilities.set_message ('maint_authors');						-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if utilities.is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';											-- override whatever |name-list-style= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
		end
	end

	local translator_etal;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=

	local interviewer_etal;
	local interviewers_list = {};												
	local Interviewers;															-- used later
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters

	local contributor_etal;
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list

	local Chapter = A['Chapter'];												-- done here so that we have access to |contribution= from |chapter= aliases
	local Chapter_origin = A:ORIGIN ('Chapter');
	local Contribution;															-- because contribution is required for contributor(s)
		if 'contribution' == A:ORIGIN ('Chapter') then
			Contribution = A['Chapter'];										-- get the name of the contribution
		end

	if utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not utilities.is_set (Contribution) then							-- |contributor= requires |contribution=
				table.insert( z.message_tail, { utilities.set_message ( 'err_contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { utilities.set_message ( 'err_contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if utilities.select_one (args, cfg.aliases['ContributorList-Last'], 'err_redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { utilities.set_message ( 'err_contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if utilities.is_set (Others) then
		if 0 == #a and 0 == #e then												-- add maint cat when |others= has value and used without |author=, |editor=
			utilities.set_message ('maint_others');
		end
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigDate = A['OrigDate'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TransTitle_origin = A:ORIGIN ('TransTitle');
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];

	local auto_select = ''; -- default is auto
	local accept_link;
	TitleLink, accept_link = utilities.has_accept_as_written(TitleLink, true); -- test for accept-this-as-written markup
	if (not accept_link) and utilities.in_array (TitleLink, {'none', 'pmc', 'doi'}) then -- check for special keywords
		auto_select = TitleLink; -- remember selection for later
		TitleLink = ''; -- treat as if |title-link= would have been empty
	end

	TitleLink = link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wiki-markup in |title-link= or wiki-markup in |title= when |title-link= is set

	local Section = '';															-- {{cite map}} only; preset to empty string for concatenation if not used
		if 'map' == config.CitationClass and 'section' == A:ORIGIN ('Chapter') then
			Section = A['Chapter'];												-- get |section= from |chapter= alias list; |chapter= and the other aliases not supported in {{cite map}}
			Chapter = '';														-- unset for now; will be reset later from |map= if present
		end

	local ScriptChapter = A['ScriptChapter'];
	local ScriptChapter_origin = A:ORIGIN ('ScriptChapter');
	local ChapterLink -- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TransChapter_origin = A:ORIGIN ('TransChapter');
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];

	local ArchiveDate;
	local ArchiveURL;

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	
	local UrlStatus = is_valid_parameter_value (A['UrlStatus'], A:ORIGIN('UrlStatus'), cfg.keywords_lists['url-status'], '');

	local URL = A['URL']
	local URL_origin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURL_origin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURL_origin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL

	local Periodical = A['Periodical'];
	local Periodical_origin = '';
	if utilities.is_set (Periodical) then
		Periodical_origin = A:ORIGIN('Periodical');								-- get the name of the periodical parameter
		local i;
		Periodical, i = utilities.strip_apostrophe_markup (Periodical);			-- strip apostrophe markup so that metadata isn't contaminated 
		if i then																-- non-zero when markup was stripped so emit an error message
			table.insert( z.message_tail, {utilities.set_message ('err_apostrophe_markup', {Periodical_origin}, true)});
		end
	end

	if 'mailinglist' == config.CitationClass then								-- special case for {{cite mailing list}}
		if utilities.is_set (Periodical) and utilities.is_set (A ['MailingList']) then	-- both set emit an error
			table.insert( z.message_tail, {utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', Periodical_origin) .. ' and ' .. utilities.wrap_style ('parameter', 'mailinglist')}, true )});
		end

		Periodical = A ['MailingList'];											-- error or no, set Periodical to |mailinglist= value because this template is {{cite mailing list}}
		Periodical_origin = A:ORIGIN('MailingList');
	end

	local ScriptPeriodical = A['ScriptPeriodical'];
	local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');

	-- web and news not tested for now because of 
	-- Wikipedia:Administrators%27_noticeboard#Is_there_a_semi-automated_tool_that_could_fix_these_annoying_&quot;Cite_Web&quot;_errors?
	if not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) then	-- 'periodical' templates require periodical parameter
	--	local p = {['journal'] = 'journal', ['magazine'] = 'magazine', ['news'] = 'newspaper', ['web'] = 'website'};	-- for error message
		local p = {['journal'] = 'journal', ['magazine'] = 'magazine'};			-- for error message
		if p[config.CitationClass]  then
			table.insert( z.message_tail, {utilities.set_message ('err_missing_periodical', {config.CitationClass, p[config.CitationClass]}, true)});
		end
	end

	local TransPeriodical =  A['TransPeriodical'];
	local TransPeriodical_origin =  A:ORIGIN ('TransPeriodical');

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) then
			if not utilities.in_array (Periodical_origin, {'website', 'mailinglist'}) then	-- {{citation}} does not render volume for these 'periodicals'
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		elseif utilities.is_set (ScriptPeriodical) then
			if 'script-website' ~= ScriptPeriodical_origin then					-- {{citation}} does not render volume for |script-website=
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		else
			Volume = A['Volume'];												-- and does for non-'periodical' cites
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_volume) then	-- render |volume= for cs1 according to the configuration settings
		Volume = A['Volume'];
	end	

	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) and utilities.in_array (Periodical_origin, {'journal', 'magazine', 'newspaper', 'periodical', 'work'}) or	-- {{citation}} renders issue for these 'periodicals'
			utilities.is_set (ScriptPeriodical) and utilities.in_array (ScriptPeriodical_origin, {'script-journal', 'script-magazine', 'script-newspaper', 'script-periodical', 'script-work'}) then -- and these 'script-periodicals'
				Issue = hyphen_to_dash (A['Issue']);
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_issue) then	-- conference &amp; map books do not support issue; {{citation}} listed here because included in settings table
		if not (utilities.in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical))) then
			Issue = hyphen_to_dash (A['Issue']);
		end
	end

	local Position = '';
	if not utilities.in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash (A['Pages']);	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = place_check (A['PublicationPlace'], A:ORIGIN('PublicationPlace'));
	local Place = place_check (A['Place'], A:ORIGIN('Place'));
	
	local PublisherName = A['PublisherName'];
	local PublisherName_origin = A:ORIGIN('PublisherName');
	if utilities.is_set (PublisherName) then
		local i = 0;
		PublisherName, i = utilities.strip_apostrophe_markup (PublisherName);	-- strip apostrophe markup so that metadata isn't contaminated; publisher is never italicized
		if i then																-- non-zero when markup was stripped so emit an error message
			table.insert( z.message_tail, {utilities.set_message ('err_apostrophe_markup', {PublisherName_origin}, true)});
		end
	end

	local Newsgroup = A['Newsgroup'];											-- TODO: strip apostrophe markup?
	local Newsgroup_origin = A:ORIGIN('Newsgroup');	

	if 'newsgroup' == config.CitationClass then
		if utilities.is_set (PublisherName) then								-- general use parameter |publisher= not allowed in cite newsgroup
			local error_text, error_state = utilities.set_message ('err_parameter_ignored', {PublisherName_origin}, true);
			if utilities.is_set (error_text) then
				table.insert( z.message_tail, {error_text, error_state} );
			end				
		end

		PublisherName = nil;													-- ensure that this parameter is unset for the time being; will be used again after COinS
	end

	local UrlAccess = is_valid_parameter_value (A['UrlAccess'], A:ORIGIN('UrlAccess'), cfg.keywords_lists['url-access'], nil);
		if not utilities.is_set (URL) and utilities.is_set (UrlAccess) then
			UrlAccess = nil;
			table.insert( z.message_tail, { utilities.set_message ( 'err_param_access_requires_param', {'url'}, true ) } );
		end
		
	local ChapterUrlAccess = is_valid_parameter_value (A['ChapterUrlAccess'], A:ORIGIN('ChapterUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (ChapterURL) and utilities.is_set (ChapterUrlAccess) then
		ChapterUrlAccess = nil;
		table.insert( z.message_tail, { utilities.set_message ( 'err_param_access_requires_param', {A:ORIGIN('ChapterUrlAccess'):gsub ('%-access', '')}, true ) } );
	end

	local MapUrlAccess = is_valid_parameter_value (A['MapUrlAccess'], A:ORIGIN('MapUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (A['MapURL']) and utilities.is_set (MapUrlAccess) then
		MapUrlAccess = nil;
		table.insert( z.message_tail, { utilities.set_message ( 'err_param_access_requires_param', {'map-url'}, true ) } );
	end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local Agency = A['Agency'];

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = is_valid_parameter_value (A['IgnoreISBN'], A:ORIGIN('IgnoreISBN'), cfg.keywords_lists['yes_true_y'], nil);
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local Quote = A['Quote'];
	local QuotePage = A['QuotePage'];
	local QuotePages = A['QuotePages'];
	local ScriptQuote = A['ScriptQuote'];
	local TransQuote = A['TransQuote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURL_origin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = is_valid_parameter_value (A['LastAuthorAmp'], A:ORIGIN('LastAuthorAmp'), cfg.keywords_lists['yes_true_y'], nil);

	local no_tracking_cats = is_valid_parameter_value (A['NoTracking'], A:ORIGIN('NoTracking'), cfg.keywords_lists['yes_true_y'], nil);
	if 'nocat' == A:ORIGIN('NoTracking') then				
		utilities.set_message ('maint_nocat');									-- this one so that we get the message; see main categorization at end of citation0()
	end
	
	--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = is_valid_parameter_value (A['DF'], A:ORIGIN('DF'), cfg.keywords_lists['df'], '');
	if not utilities.is_set (DF) then
		DF = cfg.global_df;														-- local |df= if present overrides global df set by {{use xxx date}} template
	end

	local sepc;																	-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref = A['Ref'];
	if 'harv' == Ref then
		utilities.set_message ('maint_ref_harv');								-- add maint cat to identify templates that have this now-extraneous param value
	elseif not utilities.is_set (Ref) then
		Ref = 'harv';															-- set as default when not set externally
	end
	
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], Ref, config.CitationClass);
	use_lowercase = ( sepc == ',' ); 											-- used to control capitalization for certain static text

	-- check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not utilities.is_set (no_tracking_cats) then								-- ignore if we are already not going to categorize this page
		if utilities.in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _, v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end
																				-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	utilities.select_one (args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'err_redundant_parameters');	-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, Pages, At);

	local NoPP = is_valid_parameter_value (A['NoPP'], A:ORIGIN('NoPP'), cfg.keywords_lists['yes_true_y'], nil);

	if utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- both |publication-place= and |place= (|location=) allowed if different
		utilities.add_prop_cat ('location test');								-- add property cat to evaluate how often PublicationPlace and Place are used together
		if PublicationPlace == Place then
			Place = '';															-- unset; don't need both if they are the same
		end
	elseif not utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- when only |place= (|location=) is set ...
		PublicationPlace = Place;												-- promote |place= (|location=) to |publication-place
	end

	if PublicationPlace == Place then Place = ''; end							-- don't need both if they are the same
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia= and |title= then map |title= to |article= and |encyclopedia= to |title=
		|encyclopedia= and |article= then map |encyclopedia= to |title=

		|trans-title= maps to |trans-chapter= when |title= is re-mapped
		|url= maps to |chapter-url= when |title= is remapped
	
	All other combinations of |encyclopedia=, |title=, and |article= are not modified
	
	]]

	local Encyclopedia = A['Encyclopedia'];										-- used as a flag by this module and by ~/COinS

	if utilities.is_set (Encyclopedia) then										-- emit error message when Encyclopedia set but template is other than {{cite encyclopedia}} or {{citation}}
		if 'encyclopaedia' ~= config.CitationClass and 'citation' ~= config.CitationClass then
			table.insert (z.message_tail, {utilities.set_message ('err_parameter_ignored', {A:ORIGIN ('Encyclopedia')}, true)});
			Encyclopedia = nil;													-- unset because not supported by this template
		end
	end

	if ('encyclopaedia' == config.CitationClass) or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Periodical) and utilities.is_set (Encyclopedia) then	-- when both set emit an error
			table.insert (z.message_tail, {utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', A:ORIGIN ('Encyclopedia')) .. ' and ' .. utilities.wrap_style ('parameter', Periodical_origin)}, true )});
		end

		if utilities.is_set (Encyclopedia) then
			Periodical = Encyclopedia;											-- error or no, set Periodical to Encyclopedia; allow periodical without encyclopedia
			Periodical_origin = A:ORIGIN ('Encyclopedia');
		end

		if utilities.is_set (Periodical) then									-- Periodical is set when |encyclopedia= is set
			if utilities.is_set (Title) or utilities.is_set (ScriptTitle) then
				if not utilities.is_set (Chapter) then
					Chapter = Title;											-- |encyclopedia= and |title= are set so map |title= to |article= and |encyclopedia= to |title=
					ScriptChapter = ScriptTitle;
					ScriptChapter_origin = A:ORIGIN('ScriptTitle')
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterURL_origin = A:ORIGIN('URL')

					ChapterUrlAccess = UrlAccess;

					if not utilities.is_set (ChapterURL) and utilities.is_set (TitleLink) then
						Chapter = utilities.make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			elseif utilities.is_set (Chapter) then								-- |title= not set
				Title = Periodical;												-- |encyclopedia= set and |article= set so map |encyclopedia= to |title=
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if utilities.is_set (A['Number']) then									-- cite techreport uses 'number', which other citations alias to 'issue'
			if not utilities.is_set (ID) then									-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'id') .. ' and ' .. utilities.wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if utilities.is_set (BookTitle) then
			Chapter = Title;
			Chapter_origin = 'title';
	--		ChapterLink = TitleLink;											-- |chapter-link= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			URL_origin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			TransChapter_origin = TransTitle_origin;
			Title = BookTitle;
			Format = '';
	--		TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		if utilities.is_set (Chapter) then
			table.insert( z.message_tail, { utilities.set_message ( 'err_redundant_parameters', {utilities.wrap_style ('parameter', 'map') .. ' and ' .. utilities.wrap_style ('parameter', Chapter_origin)}, true ) } );	-- add error message
		end
		Chapter = A['Map'];
		Chapter_origin = A:ORIGIN('Map');
		ChapterURL = A['MapURL'];
		ChapterURL_origin = A:ORIGIN('MapURL');
		TransChapter = A['TransMap'];
		ScriptChapter = A['ScriptMap']
		ScriptChapter_origin = A:ORIGIN('ScriptMap')

		ChapterUrlAccess = MapUrlAccess;
		ChapterFormat = A['MapFormat'];

		Cartography = A['Cartography'];
		if utilities.is_set ( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if utilities.is_set ( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local SeriesLink = A['SeriesLink'];

		SeriesLink = link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wiki-markup in |series-link= or wiki-markup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if utilities.is_set (Network) then table.insert(n, Network); end
		if utilities.is_set (Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if utilities.is_set (Season) and utilities.is_set (SeriesNumber) then	-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { utilities.set_message ( 'err_redundant_parameters', {utilities.wrap_style ('parameter', 'season') .. ' and ' .. utilities.wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if utilities.is_set (Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if utilities.is_set (SeriesNumber) then table.insert(s, wrap_msg ('seriesnum', SeriesNumber, use_lowercase)); end
			if utilities.is_set (Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ScriptChapter_origin = A:ORIGIN('ScriptTitle');
			ChapterLink = TitleLink;											-- alias |episode-link=
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if utilities.is_set (ChapterLink) and not utilities.is_set (ChapterURL) then	-- link but not URL
				Chapter = utilities.make_wikilink (ChapterLink, Chapter);
			elseif utilities.is_set (ChapterLink) and utilities.is_set (ChapterURL) then	-- if both are set, URL links episode;
				Series = utilities.make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if utilities.is_set (Series) and utilities.is_set (SeriesLink) then
				Series = utilities.make_wikilink (SeriesLink, Series);
			end
			Series = utilities.wrap_style ('italic-title', Series);				-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- handle type parameter for those CS1 citations that have default values
	if utilities.in_array (config.CitationClass, {&quot;AV-media-notes&quot;, &quot;interview&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if utilities.is_set (Degree) and &quot;Thesis&quot; == TitleType then				-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if utilities.is_set (TitleType) then										-- if type parameter is specified
		TitleType = utilities.substitute ( cfg.messages['type'], TitleType);	-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging

	if not utilities.is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not utilities.is_set (Date) and utilities.is_set (PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val = AccessDate, name = A:ORIGIN ('AccessDate')},
			['archive-date'] = {val = ArchiveDate, name = A:ORIGIN ('ArchiveDate')},
			['date'] = {val = Date, name = Date_origin},
			['doi-broken-date'] = {val = DoiBroken, name = A:ORIGIN ('DoiBroken')},
			['pmc-embargo-date'] = {val = Embargo, name = A:ORIGIN ('Embargo')},
			['lay-date'] = {val = LayDate, name = A:ORIGIN ('LayDate')},
			['publication-date'] = {val = PublicationDate, name = A:ORIGIN ('PublicationDate')},
			['year'] = {val = Year, name = A:ORIGIN ('Year')},
			};

		local error_list = {};
		anchor_year, Embargo = validation.dates(date_parameters_list, COinS_date, error_list);

-- start temporary Julian / Gregorian calendar uncertainty categorization
		if COinS_date.inter_cal_cat then
			utilities.add_prop_cat ('jul_greg_uncertainty');
		end
-- end temporary Julian / Gregorian calendar uncertainty categorization

		if utilities.is_set (Year) and utilities.is_set (Date) then				-- both |date= and |year= not normally needed; 
			local mismatch = validation.year_date_check (Year, Date);
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				table.insert (error_list, '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;year= / &amp;#124;date= mismatch&lt;/code&gt;');
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				utilities.set_message ('maint_date_year');						-- add a maint cat
			end
		end
		
		if 0 == #error_list then												-- error free dates only; 0 when error_list is empty
			local modified = false;												-- flag
			
			if utilities.is_set (DF) then										-- if we need to reformat dates
				modified = validation.reformat_dates (date_parameters_list, DF);	-- reformat to DF format, use long month names if appropriate
			end

			if true == validation.date_hyphen_to_dash (date_parameters_list) then	-- convert hyphens to dashes where appropriate
				modified = true;
				utilities.set_message ('maint_date_format');					-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language,
	-- uncomment the next three lines.  Not supported by en.wiki (for obvious reasons)
	-- set validation.date_name_xlate() second argument to true to translate English digits to local digits (will translate ymd dates)
	--		if validation.date_name_xlate (date_parameters_list, false) then
	--			modified = true;
	--		end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				LayDate = date_parameters_list['lay-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end
		else
			table.insert (z.message_tail, {utilities.set_message ('err_bad_date', {utilities.make_sep_list (#error_list, error_list)}, true)});	-- add this error message
		end
	end	-- end of do

	local ID_list_coins = identifiers.extract_ids (args);						-- gets identifiers and their values from args; this list used for COinS and source for build_id_list()
		if utilities.is_set (DoiBroken) and not ID_list_coins['DOI'] then
			table.insert (z.message_tail, {utilities.set_message ('err_doibroken_missing_doi', A:ORIGIN('DoiBroken'))});
		end
	local ID_access_levels = identifiers.extract_id_access_levels (args, ID_list_coins);
	local ID_list = identifiers.build_id_list (ID_list_coins, {IdAccessLevels = ID_access_levels, DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo = Embargo, Class = Class});	-- render identifiers
	
	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite ssrn}}, before generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then
		if not utilities.is_set (ID_list_coins[config.CitationClass:upper()]) then 	-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp; |citeseerx= required for their templates
			table.insert (z.message_tail, {utilities.set_message ('err_' .. config.CitationClass .. '_missing', {}, true)});	-- add error message
		end

		Periodical = ({['arxiv'] = 'arXiv', ['biorxiv'] = 'bioRxiv', ['citeseerx'] = 'CiteSeerX', ['ssrn'] = 'Social Science Research Network'})[config.CitationClass];
	end

	-- Link the title of the work if no |url= was provided, but we have a |pmc= or a |doi= with |doi-access=free

	if config.CitationClass == &quot;journal&quot; and not utilities.is_set (URL) and not utilities.is_set (TitleLink) and not utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) then -- TODO: remove 'none' once existing citations have been switched to 'off', so 'none' can be used as token for &quot;no title&quot; instead
    		if 'none' ~= cfg.keywords_xlate[auto_select] then -- if auto-linking not disabled
 	 		if identifiers.auto_link_urls[auto_select] then -- manual selection
		 		URL = identifiers.auto_link_urls[auto_select]; -- set URL to be the same as identifier's external link
 				URL_origin = cfg.id_handlers[auto_select:upper()].parameters[1]; -- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['pmc'] then -- auto-select PMC
				URL = identifiers.auto_link_urls['pmc']; -- set URL to be the same as the PMC external link if not embargoed
				URL_origin = cfg.id_handlers['PMC'].parameters[1]; -- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['doi'] then -- auto-select DOI
				URL = identifiers.auto_link_urls['doi'];
				URL_origin = cfg.id_handlers['DOI'].parameters[1];
			end
 	 	end

		if utilities.is_set (URL) and utilities.is_set (AccessDate) then		-- access date requires |url=; identifier-created URL is not |url=
			table.insert( z.message_tail, { utilities.set_message ( 'err_accessdate_missing_url', {}, true ) } );	-- add an error message
			AccessDate = '';													-- unset
		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not utilities.is_set (Title) and not utilities.is_set (TransTitle) and not utilities.is_set (ScriptTitle) then	-- has special case for cite episode
		table.insert( z.message_tail, { utilities.set_message ( 'err_citation_missing_title', {'episode' == config.CitationClass and 'series' or 'title'}, true ) } );
	end

	if utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) and
			utilities.in_array (config.CitationClass, {'journal', 'citation'}) and
			(utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and
			('journal' == Periodical_origin or 'script-journal' == ScriptPeriodical_origin) then	-- special case for journal cites
				Title = '';														-- set title to empty string
				utilities.set_message ('maint_untitled');						-- add maint cat
	end

	check_for_url ({															-- add error message when any of these parameters hold a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[Periodical_origin] = Periodical,
		[PublisherName_origin] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Chapter) and utilities.is_set (Title) and utilities.is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = metadata.COinS({
		['Periodical'] = utilities.strip_apostrophe_markup (Periodical),		-- no markup in the metadata
		['Encyclopedia'] = Encyclopedia,										-- just a flag; content ignored by ~/COinS
		['Chapter'] = metadata.make_coins_title (coins_chapter, ScriptChapter),	-- Chapter and ScriptChapter stripped of bold / italic wiki-markup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = metadata.make_coins_title (coins_title, ScriptTitle),		-- Title and ScriptTitle stripped of bold / italic wiki-markup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Quarter'] = COinS_date.rftquarter,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = coins_pages or metadata.get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName or Newsgroup,							-- any apostrophe markup already removed from PublisherName
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list_coins,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, and {{cite ssrn}} AFTER generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, CiteSeerX, or ssrn now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass and utilities.is_set (Newsgroup) then
		PublisherName = utilities.substitute (cfg.messages['newsgroup'], external_link( 'news:' .. Newsgroup, Newsgroup, Newsgroup_origin, nil ));
	end

	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local control = { 
			format = NameListStyle,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_names (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if utilities.is_set (Editors) then
				Editors, editor_etal = name_has_etal (Editors, editor_etal, false, 'editors');	-- find and remove variations on et al.
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
				end
				EditorCount = 2;												-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum , interviewer_etal = get_display_names (A['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal);
			Interviewers = list_people (control, interviewers_list, interviewer_etal);
		end
		do																		-- now do translators
			control.maximum , translator_etal = get_display_names (A['DisplayTranslators'], #t, 'translators', translator_etal);
			Translators = list_people (control, t, translator_etal);
		end
		do																		-- now do contributors
			control.maximum , contributor_etal = get_display_names (A['DisplayContributors'], #c, 'contributors', contributor_etal);
			Contributors = list_people (control, c, contributor_etal);
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_names (A['DisplayAuthors'], #a, 'authors', author_etal);

			last_first_list = list_people(control, a, author_etal);

			if utilities.is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors');	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if utilities.is_set (Authors) and utilities.is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
	-- an error message if the associated URL is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not utilities.is_set (URL) then
		if utilities.in_array (config.CitationClass, {&quot;web&quot;, &quot;podcast&quot;, &quot;mailinglist&quot;}) or		-- |url= required for cite web, cite podcast, and cite mailinglist
			('citation' == config.CitationClass and ('website' == Periodical_origin or 'script-website' == ScriptPeriodical_origin)) then	-- and required for {{citation}} with |website= or |script-website=
				table.insert( z.message_tail, { utilities.set_message ( 'err_cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if utilities.is_set (AccessDate) and not utilities.is_set (ChapterURL) then		-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { utilities.set_message ( 'err_accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURL_origin, OriginalFormat, OriginalAccess;
	UrlStatus = UrlStatus:lower();												-- used later when assembling archived text
	if utilities.is_set ( ArchiveURL ) then
		if utilities.is_set (ChapterURL) then 									-- if chapter-url= is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURL_origin = ChapterURL_origin;								-- name of |chapter-url= parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=

			if 'live' ~= UrlStatus then
				ChapterURL = ArchiveURL											-- swap-in the archive's URL
				ChapterURL_origin = A:ORIGIN('ArchiveURL')						-- name of |archive-url= parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived URLs
			end
		elseif utilities.is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURL_origin = URL_origin;									-- name of URL parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;

			if 'live' ~= UrlStatus then											-- if URL set then |archive-url= applies to it
				URL = ArchiveURL												-- swap-in the archive's URL
				URL_origin = A:ORIGIN('ArchiveURL')								-- name of archive URL parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived URLs
			end
 		end
	end

	if utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) then
			local chap_param;
			if utilities.is_set (Chapter) then									-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif utilities.is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif utilities.is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif utilities.is_set (ScriptChapter) then
				chap_param = ScriptChapter_origin;
			else utilities.is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if utilities.is_set (chap_param) then								-- if we found one
				table.insert( z.message_tail, { utilities.set_message ( 'err_chapter_ignored', {chap_param}, true ) } );	-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if utilities.is_set (Contribution) and 0 &lt; #c then						-- if this is a contribution with contributor(s)
			if utilities.in_array (Contribution:lower(), cfg.keywords_lists.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, ScriptChapter_origin, Chapter, Chapter_origin, TransChapter, TransChapter_origin, ChapterURL, ChapterURL_origin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if utilities.is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and utilities.is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter .. sepc .. ' ';
		elseif utilities.is_set (ChapterFormat) then							-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title
	local plain_title = false;
	local accept_title;
	Title, accept_title = utilities.has_accept_as_written (Title, true);		-- remove accept-this-as-written markup when it wraps all of &lt;Title&gt;
	if accept_title and ('' == Title) then										-- only support forced empty for now &quot;(())&quot;
		Title = cfg.messages['notitle'];										-- replace by predefined &quot;No title&quot; message
			-- TODO: utilities.set_message ( 'err_redundant_parameters', ...);	-- issue proper error message instead of muting	 
			ScriptTitle = '';													-- just mute for now	 
			TransTitle = '';													-- just mute for now
 		plain_title = true;														-- suppress text decoration for descriptive title
		utilities.set_message ('maint_untitled');								-- add maint cat
	end

	if not accept_title then -- &lt;Title&gt; not wrapped in accept-as-written markup
		if '...' == Title:sub (-3) then											-- if ellipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%' .. sepc .. '$', '');			-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end

		if utilities.is_set (ArchiveURL) and is_archived_copy (Title) then
			utilities.set_message ('maint_archived_copy');						-- add maintenance category before we modify the content of Title
		end

		if is_generic_title (Title) then
			table.insert (z.message_tail, {utilities.set_message ( 'err_generic_title', {}, true ) } );	-- set an error message
		end
	end

	if (not plain_title) and (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) or
		('map' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)))) then		-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from module provided quote marks
			Title = utilities.wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle, 'script-title');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
			TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );
	elseif plain_title or ('report' == config.CitationClass) then								-- no styling for cite report and descriptive titles (otherwise same as above)
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = utilities.wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if utilities.is_set (TransTitle) then
		if utilities.is_set (Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. utilities.set_message ( 'err_trans_missing_title', {'title'} );
		end
	end

	if utilities.is_set (Title) then											-- TODO: is this the right place to be making Wikisource URLs?
		if utilities.is_set (TitleLink) and utilities.is_set (URL) then
			table.insert( z.message_tail, { utilities.set_message ( 'err_wikilink_in_url', {}, true ) } );	-- set an error message because we can't have both
			TitleLink = '';														-- unset
		end
		
		if not utilities.is_set (TitleLink) and utilities.is_set (URL) then
			Title = external_link (URL, Title, URL_origin, UrlAccess) .. TransTitle .. TransError .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif utilities.is_set (TitleLink) and not utilities.is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = utilities.make_wikilink (TitleLink, Title) .. TransTitle .. TransError;
			end
		else
			local ws_url, ws_label, L;											-- Title has italic or quote markup by the time we get here which causes is_wikilink() to return 0 (not a wikilink)
			ws_url, ws_label, L = wikisource_url_make (Title:gsub('[\'&quot;](.-)[\'&quot;]', '%1'));	-- make ws URL from |title= interwiki link (strip italic or quote markup); link portion L becomes tooltip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = Title .. TransTitle .. TransError;
			end
		end
	else
		Title = TransTitle .. TransError;
	end

	if utilities.is_set (Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if utilities.is_set (Conference) then
		if utilities.is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURL_origin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif utilities.is_set (ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURL_origin, nil );
	end

	if not utilities.is_set (Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if utilities.is_set (Minutes) then
			if utilities.is_set (Time) then
				table.insert( z.message_tail, { utilities.set_message ( 'err_redundant_parameters', {utilities.wrap_style ('parameter', 'minutes') .. ' and ' .. utilities.wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if utilities.is_set (Time) then
				local TimeCaption = A['TimeCaption']
				if not utilities.is_set (TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = utilities.is_set (At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = utilities.is_set (Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Sections = A['Sections'];											-- Section (singular) is an alias of Chapter so set earlier
		local Inset = A['Inset'];
		
		if utilities.is_set ( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if utilities.is_set ( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif utilities.is_set ( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if utilities.is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc.
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	Others = utilities.is_set (Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if utilities.is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if utilities.is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	TitleNote = utilities.is_set (TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if utilities.is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			utilities.set_message ('maint_extra_text', 'edition');				-- add maint cat
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = utilities.is_set (Series) and wrap_msg ('series', {sepc, Series}) or &quot;&quot;;	-- not the same as SeriesNum
	OrigDate = utilities.is_set (OrigDate) and wrap_msg ('origdate', OrigDate) or '';
	Agency = utilities.is_set (Agency) and wrap_msg ('agency', {sepc, Agency}) or &quot;&quot;;
	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	Via = utilities.is_set (Via) and  wrap_msg ('via', Via) or '';

	if utilities.is_set (AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = utilities.substitute (retrv_text, AccessDate);				-- add retrieved text

		AccessDate = utilities.substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if utilities.is_set (ID) then ID = sepc .. &quot; &quot; .. ID; end
   	if &quot;thesis&quot; == config.CitationClass and utilities.is_set (Docket) then
		ID = sepc .. &quot; Docket &quot; .. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and utilities.is_set (Docket) then		-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	if utilities.is_set (URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URL_origin, UrlAccess );
	end

	if utilities.is_set (Quote) or utilities.is_set (TransQuote) or utilities.is_set (ScriptQuote) then

		if utilities.is_set (Quote) then
			if Quote:sub(1, 1) == '&quot;' and Quote:sub(-1, -1) == '&quot;' then			-- if first and last characters of quote are quote marks
				Quote = Quote:sub(2, -2);										-- strip them off
			end
		end

		Quote = utilities.wrap_style ('quoted-text', Quote ); 	-- wrap in &lt;q&gt;...&lt;/q&gt; tags
	
		if utilities.is_set (ScriptQuote) then
			Quote = script_concatenate (Quote, ScriptQuote, 'script-quote'); -- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after quote is wrapped
		end

		if utilities.is_set (TransQuote) then
			if TransQuote:sub(1, 1) == '&quot;' and TransQuote:sub(-1, -1) == '&quot;' then -- if first and last characters of |trans-quote are quote marks
				TransQuote = TransQuote:sub(2, -2); -- strip them off
			end
			Quote = Quote .. &quot; &quot; .. utilities.wrap_style ('trans-quoted-title', TransQuote );
		end

		if utilities.is_set (QuotePage) or utilities.is_set (QuotePages) then	-- add page prefix
			local quote_prefix = '';
			if utilities.is_set (QuotePage) then
				if not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePage}), '', '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePage}), '', '', '';
				end
			elseif utilities.is_set (QuotePages) then
				if tonumber(QuotePages) ~= nil and not NoPP then				-- if only digits, assume single page
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePages}), '', '';
				elseif not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['pp-prefix'], {sepc, QuotePages}), '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePages}), '', '';
				end
			end
                        
			Quote = quote_prefix .. &quot;: &quot; .. Quote;
		else
			Quote = sepc .. &quot; &quot; .. Quote;
		end

		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if utilities.is_set (ArchiveURL) then
		local arch_text;
		if not utilities.is_set (ArchiveDate) then
			ArchiveDate = utilities.set_message ('err_archive_missing_date');
		end
		if &quot;live&quot; == UrlStatus then
			arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. utilities.substitute ( cfg.messages['archived-live'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil ) .. ArchiveFormat, ArchiveDate } );
			if not utilities.is_set (OriginalURL) then
				Archived = Archived .. &quot; &quot; .. utilities.set_message ('err_archive_missing_url');							   
			end
		elseif utilities.is_set (OriginalURL) then								-- UrlStatus is empty, 'dead', 'unfit', 'usurped', 'bot: unknown'
			if utilities.in_array (UrlStatus, {'unfit', 'usurped', 'bot: unknown'}) then
				arch_text = cfg.messages['archived-unfit'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. &quot; &quot; .. arch_text .. ArchiveDate;				-- format already styled
				if 'bot: unknown' == UrlStatus then
					utilities.set_message ('maint_bot_unknown');				-- and add a category if not already added
				else
					utilities.set_message ('maint_unfit');						-- and add a category if not already added
				end
			else																-- UrlStatus is empty, 'dead'
				arch_text = cfg.messages['archived-dead'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. &quot; &quot; .. utilities.substitute ( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURL_origin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else																	-- OriginalUrl not set
			arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. utilities.substitute ( arch_text, 
				{ utilities.set_message ('err_archive_missing_url'), ArchiveDate } );
		end
	elseif utilities.is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if utilities.is_set (LayURL) then
		if utilities.is_set (LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if utilities.is_set (LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. utilities.safe_for_italics (LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif utilities.is_set (LayFormat) then									-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if utilities.is_set (Transcript) then
		if utilities.is_set (TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURL_origin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif utilities.is_set (TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURL_origin, nil );
	end

	local Publisher;
	if utilities.is_set (PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if utilities.is_set (PublisherName) then
		if utilities.is_set (PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif utilities.is_set (PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical)) then
		if utilities.is_set (Title) or utilities.is_set (TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		else 
			Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		end
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then									-- cite speech only
		TitleNote = &quot; (Speech)&quot;;												-- annotate the citation
		if utilities.is_set (Periodical) then									-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if utilities.is_set (Conference) then								-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;							-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
		if utilities.is_set (Others) then Others = safe_join ({Others, sepc .. &quot; &quot;}, sepc) end		-- add terminal punctuation &amp; space; check for dup sepc; TODO why do we need to do this here?
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (Periodical) then		-- special cases for book cites
		if utilities.is_set (Contributors) then									-- when we are citing foreword, preface, introduction, etc.
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if utilities.is_set (Chapter) then										-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif utilities.is_set (Periodical) then								-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon;
	if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then	-- special case for cite AV media &amp; cite episode position transcript
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, Lay, Quote }, sepc );
	else
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, Lay, Quote }, sepc );
	end
	
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if utilities.is_set (Date) then
		if utilities.is_set (Authors) or utilities.is_set (Editors) then		-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date .. &quot;)&quot; .. OrigDate .. sepc .. &quot; &quot;;				-- in parentheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon, -1, -1) == sepc) then						-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigDate;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigDate;							-- Date begins with sepc
			end
		end
	end	
	if utilities.is_set (Authors) then
		if (not utilities.is_set (Date)) then									-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if utilities.is_set (Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then
					in_text = in_text:lower()									-- lowercase for cs2
				end
			end
			if EditorCount &lt;= 1 then
				post_text = &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot;;				-- be consistent with no-author, no-date case
			else
				post_text = &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot;;
			end
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Contributors) then									-- book cite and we're citing the intro, preface, etc.
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if utilities.is_set (Editors) and utilities.is_set (Date) then		-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not utilities.is_set (Date)) then								-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif utilities.is_set (Editors) then
		if utilities.is_set (Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if utilities.is_set (PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc ); 								--Deals with italics, spaces, etc.
		text = text:sub(1, -sepc:len() - 1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if utilities.is_set (config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = string.format ('%s %s %s', 'citation', config.CitationClass, utilities.is_set (Mode) and Mode or 'cs1');	-- class=citation required for blue highlight when used with |ref=
	else
		options.class = string.format ('%s %s', 'citation', utilities.is_set (Mode) and Mode or 'cs2');
	end
	
	if utilities.is_set (Ref) and 'none' ~= cfg.keywords_xlate[Ref:lower()] then
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			if #namelist &gt; 0 then												-- if there are names in namelist
				id = anchor_id (namelist, year);								-- go make the CITEREF anchor
			else
				id = '';														-- unset
			end
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;(.-)&lt;/span&gt;&quot;, &quot;%1&quot;):gsub(&quot;%b&lt;&gt;&quot;, &quot;&quot;)) &lt;= 2 then	-- remove &lt;span&gt; tags and other HTML-like markup; then get length of what remains
		z.error_categories = {};
		text = utilities.set_message ('err_empty_citation');
		z.message_tail = {};
	end
	
	local render = {};															-- here we collect the final bits for concatenation into the rendered citation

	if utilities.is_set (options.id) then										-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render, utilities.substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text}));	-- when |ref= is set
	else
		table.insert (render, utilities.substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text}));	-- all other cases
	end		

	table.insert (render, utilities.substitute (cfg.presentation['ocins'], {OCinSoutput}));	-- append metadata to the citation

	if 0 ~= #z.message_tail then
		table.insert (render, ' ');
		for i,v in ipairs( z.message_tail ) do
			if utilities.is_set (v[1]) then
				if i == #z.message_tail then
					table.insert (render, utilities.error_comment ( v[1], v[2] ));
				else
					table.insert (render, utilities.error_comment ( v[1] .. &quot;; &quot;, v[2] ));
				end
			end
		end
	end

	if 0 ~= #z.maintenance_cats then
		local maint_msgs = {};													-- here we collect all of the maint messages
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			local maint = {};													-- here we assemble a maintenence message
			table.insert (maint, v);											-- maint msg is the category name
			table.insert (maint, ' (');											-- open the link text
			table.insert (maint, utilities.make_wikilink (':Category:' .. v, 'link'));	-- add the link
			table.insert (maint, ')');											-- and close it
			table.insert (maint_msgs, table.concat (maint));					-- assemble new maint message and add it to the maint_msgs table
		end
		table.insert (render, utilities.substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs, ' ')));	-- wrap the group of maint message with proper presentation and save
	end
	
	if not no_tracking_cats then
		for _, v in ipairs( z.error_categories ) do
			table.insert (render, utilities.make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			table.insert (render, utilities.make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.properties_cats ) do								-- append properties categories
			table.insert (render, utilities.make_wikilink ('Category:' .. v));
		end
	elseif 'nocat' == A:ORIGIN('NoTracking') then								-- peculiar special case; can't track nocat without tracking nocat
		table.insert (render, utilities.make_wikilink ('Category:CS1 maint: nocat'));	-- hand-set this category because it is supposed to be temporary
	end

	return table.concat (render);	
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class, empty)
	local name = tostring (name);
	local state;
	local function state_test (state, name)										-- local function to do testing of state values
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			if empty then return nil; end										-- deprecated empty parameters are treated as unknowns
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
		return nil;
	end		

	if name:find ('#') then														-- # is a cs1|2 reserved character so parameters with # not permitted
		return nil;
	end

	if utilities.in_array (cite_class, whitelist.preprint_template_list ) then	-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[name];
		if true == state_test (state, name) then return true; end

		state = whitelist.preprint_arguments[cite_class][name];					-- look in the parameter-list for the template identified by cite_class
		if true == state_test (state, name) then return true; end

																				-- limited enumerated parameters list
		name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
		state = whitelist.limited_numbered_arguments[name];
		if true == state_test (state, name) then return true; end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates

	if utilities.in_array (cite_class, whitelist.unique_param_template_list) then 	-- experiment for template-specific parameters for templates that accept parameters from the basic argument list
		state = whitelist.unique_arguments[cite_class][name];					-- look in the template-specific parameter-lists for the template identified by cite_class
		if true == state_test (state, name) then return true; end
	end																			-- if here, fall into general validation
		
	state = whitelist.basic_arguments[name];									-- all other templates; all normal parameters allowed
	if true == state_test (state, name) then return true; end

																				-- all enumerated parameters allowed
	name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );												-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
	state = whitelist.numbered_arguments[name];
	if true == state_test (state, name) then return true; end

	return false;																-- not supported because not found or name is set to nil
end


--[=[-------------------------&lt; I N T E R _ W I K I _ C H E C K &gt;----------------------------------------------

check &lt;value&gt; for inter-language interwiki-link markup.  &lt;prefix&gt; must be a MediaWiki-recognized language
code.  when these values have the form (without leading colon):
	[[&lt;prefix&gt;:link|label]] return label as plain-text
	[[&lt;prefix&gt;:link]] return &lt;prefix&gt;:link as plain-text

return value as is else

]=]

local function inter_wiki_check (parameter, value)
	local prefix = value:match ('%[%[(%a+):');									-- get an interwiki prefix if one exists
	local _;
	
	if prefix and cfg.inter_wiki_map[prefix:lower()] then						-- if prefix is in the map, needs preceding colon so
		table.insert( z.message_tail, {utilities.set_message ('err_bad_paramlink', parameter)});	-- emit an error message
		_, value, _ = utilities.is_wikilink (value);							-- extract label portion from wikilink
	end
	return value;
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe.  There are two tests made:
	{{cite ... |title=Title access-date=2016-03-17}}	-- the first parameter has a value and whitespace separates that value from the missing pipe parameter name
	{{cite ... |title=access-date=2016-03-17}}			-- the first parameter has no value (whitespace after the first = is trimmed by MediaWiki)
cs1|2 shares some parameter names with XML/HTML attributes: class=, title=, etc.  To prevent false positives XML/HTML
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (parameter, value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove XML/HTML tags because attributes: class=, title=, etc.

	capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then										-- if the capture is a valid parameter name
		table.insert( z.message_tail, {utilities.set_message ('err_missing_pipe', parameter)});
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ P U N C T &gt;--------------------------------------

look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_punc (param, value)
	if 'number' == type (param) then
		return;
	end
	
	param = param:gsub ('%d+', '#');											-- enumerated name-list mask params allow terminal punct; normalize 
	if cfg.punct_skip[param] then
		return;																	-- parameter name found in the skip table so done
	end
	
	if value:match ('[,;:]$') then
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
end


--[[--------------------------&lt; C I T A T I O N &gt;--------------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

local function citation(frame)
	Frame = frame;																-- save a copy in case we need to display an error message in preview mode
	local pframe = frame:getParent()
	local styles;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		styles = 'Module:Citation/CS1/sandbox/styles.css';
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
		styles = 'Module:Citation/CS1/styles.css';
	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the selected cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text, error_state;

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do											-- get parameters from the {{#invoke}} frame
		config[k] = v;
	--	args[k] = v;															-- crude debug support that allows us to render a citation from module {{#invoke:}}; skips parameter validation; TODO: keep?
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	local empty_unknowns = {};													-- sequence table to hold empty unknown params for error message listing
	for k, v in pairs( pframe.args ) do											-- get parameters from the parent (template) frame
		v = mw.ustring.gsub (v, '^%s*(.-)%s*$', '%1');							-- trim leading/trailing whitespace; when v is only whitespace, becomes empty string
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = utilities.set_message ( 'err_text_ignored', {v}, true );
					end
				elseif validate( k:lower(), config.CitationClass ) then 
					error_text, error_state = utilities.set_message ( 'err_parameter_ignored_suggest', {k, k:lower()}, true );	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no capture in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = utilities.substitute (param, capture);		-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text, error_state = utilities.set_message ('err_parameter_ignored_suggest', {k, param}, true);	-- set the suggestion error message
							else
								error_text, error_state = utilities.set_message ( 'err_parameter_ignored', {param}, true );	-- suggested param not supported by this template
								v = '';											-- unset
							end
						end
					end
					if not utilities.is_set (error_text) then					-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = utilities.set_message ( 'err_parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = utilities.set_message ( 'err_parameter_ignored', {k}, true );
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end

			args[k] = v;														-- save this parameter and its value

		elseif not utilities.is_set (v) then									-- for empty parameters
			if not validate (k, config.CitationClass, true) then				-- is this empty parameter a valid parameter
				k = ('' == k) and k:gsub ('^$', '(empty string)') or k;							-- when k is empty string (or was space(s) trimmed to empty string), replace with descriptive text
				table.insert (empty_unknowns, utilities.wrap_style ('parameter', k));	-- format for error message and add to the list
			end
																				-- crude debug support that allows us to render a citation from module {{#invoke:}} TODO: keep?
	--	elseif args[k] ~= nil or (k == 'postscript') then						-- when args[k] has a value from {{#invoke}} frame (we don't normally do that)
	--		args[k] = v;														-- overwrite args[k] with empty string from pframe.args[k] (template frame); v is empty string here
		end																		-- not sure about the postscript bit; that gets handled in parameter validation; historical artifact?
	end	

	if 0 ~= #empty_unknowns then												-- create empty unknown error message
		table.insert (z.message_tail, {utilities.set_message ('err_param_unknown_empty', {
			1 == #empty_unknowns and '' or 's',
			utilities.make_sep_list (#empty_unknowns, empty_unknowns)
			}, true )});
	end

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);											-- look for invisible characters
		end
		has_extraneous_punc (k, v);												-- look for extraneous terminal punctuation in parameter values
		missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?
		args[k] = inter_wiki_check (k, v);										-- when language interwiki-linked parameter missing leading colon replace with wiki-link label
	end

	return table.concat ({citation0( config, args), frame:extensionTag ('templatestyles', '', {src=styles})});
end

--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {citation = citation};</text>
      <sha1>g5r1sj962yc8asv8dj793xw4dsaa7ak</sha1>
    </revision>
    <revision>
      <id>4738</id>
      <parentid>4737</parentid>
      <timestamp>2020-10-11T18:47:08Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <minor />
      <comment>deprecated enumerated parameter error message fix;</comment>
      <origin>4738</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="204553" sha1="m4thujyhbbwao63118b0ar80pgg4dwy" xml:space="preserve">
require('Module:No globals');

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------

each of these counts against the Lua upvalue limit

]]

local validation;																-- functions in Module:Citation/CS1/Date_validation

local utilities;																-- functions in Module:Citation/CS1/Utilities
local z ={};																	-- table of tables in Module:Citation/CS1/Utilities

local identifiers;																-- functions and tables in Module:Citation/CS1/Identifiers
local metadata;																	-- functions in Module:Citation/CS1/COinS
local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

declare variables here that have page-wide scope that are not brought in from other modules; that are created here and used here

]]

local added_deprecated_cat;														-- Boolean flag so that the category is added only once
local added_vanc_errs;															-- Boolean flag so we only emit one Vancouver error / category

local Frame;																	-- holds the module's frame table


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if utilities.is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a Boolean declared in page scope variables above

]]

local function add_vanc_error (source)
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { utilities.set_message ( 'err_vancouver', {source}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a URI scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of TLDs: https://www.iana.org/domains/root/db

RFC 952 (modified by RFC 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the TLD.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a URL with a scheme) will be stripped
here.  Perhaps not necessary but retained in case it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ASCII characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the TLD) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and TLD or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%w]') then											-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at Wikisource
		return false;
	end

	local patterns = {															-- patterns that look like URLs
		'%f[%w][%w][%w%-]+[%w]%.%a%a+$',										-- three or more character hostname.hostname or hostname.tld
		'%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$',									-- internationalized domain name with ACE prefix
		'%f[%a][qxz]%.com$',													-- assigned one character .com hostname (x.com times out 2015-12-10)
		'%f[%a][iq]%.net$',														-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		'%f[%w][%w]%.%a%a$',													-- one character hostname and ccTLD (2 chars)
		'%f[%w][%w][%w]%.%a%a+$',												-- two character hostname and TLD
		'^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?',								-- IPv4 address
		}

	for _, pattern in ipairs (patterns) do										-- loop through the patterns list
		if domain:match (pattern) then
			return true;														-- if a match then we think that this thing that purports to be a URL is a URL
		end
	end

	for _, d in ipairs ({'cash', 'company', 'today', 'org'}) do					-- look for single letter second level domain names for these top level domains
		if domain:match ('%f[%w][%w]%.' .. d) then
			return true
		end
	end
	return false;																-- no matches, we don't know what this thing is
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a URL appear to be a valid URL; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if utilities.is_set (scheme) then											-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when URL is protocol-relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a URL into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following TLD) (if any) and any path(/), query(?) or fragment(#).

If protocol-relative URL, return nil scheme and domain else return nil for both scheme and domain.

When not protocol-relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Any URL that does not have news: scheme must have authority indicator (//).  TODO: are there other common schemes
like news: that don't use authority indicator?

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol-relative URL
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		if utilities.is_set (authority) then
			authority = authority:gsub ('//', '', 1);							-- replace place 1 pair of '/' with nothing;
			if utilities.is_set(authority) then									-- if anything left (1 or 3+ '/' where authority should be) then
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		else
			if not scheme:match ('^news:') then									-- except for news:..., MediaWiki won't link URLs that do not have authority indicator; TODO: a better way to do this test?
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link=, etc. for properly formatted content: no wikilinks, no URLs

Link parameters are to hold the title of a Wikipedia article, so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki URLs and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid URL (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid URL (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from URL; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid URL
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wiki-linked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

check &lt;link&gt; for inter-language interwiki-link prefix.  prefix must be a MediaWiki-recognized language
code and must begin with a colon.

]]

local function link_title_ok (link, lorig, title, torig)
local orig;
	if utilities.is_set (link) then 											-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		elseif link:match ('^%a+:') then										-- if the link is what looks like an interwiki
			local prefix = link:match ('^(%a+):'):lower();						-- get the interwiki prefix

			if cfg.inter_wiki_map[prefix] then									-- if prefix is in the map, must have preceding colon
				orig = lorig;													-- flag as error
			end
		end
	end

	if utilities.is_set (orig) then
		link = '';																-- unset
		table.insert( z.message_tail, { utilities.set_message ( 'err_bad_paramlink', orig)});	-- URL or wikilink in |title= with |title-link=;
	end
	
	return link;																-- link if ok, empty string else
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the URL into scheme and domain
portions, or for protocol-relative (//example.com) URLs, just the domain.  Use is_url() to validate the two
portions of the URL.  If both are valid, or for protocol-relative if domain is valid, return true, else false.

Because it is different from a standard URL, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper URL
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from URL;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a URL.  The test will also find external wikilinks
that use protocol-relative URLs. Also finds bare URLs.

The frontier pattern prevents a match on interwiki-links which are similar to scheme:path URLs.  The tests that
find bracketed URLs are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext. wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol-relative ext. wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare URL with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol-relative bare URL: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a URL
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a URL add an error message
			if utilities.is_set(error_message) then								-- once we've added the first portion of the error message ...
				error_message = error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message = error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if utilities.is_set (error_message) then									-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { utilities.set_message ( 'err_param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { utilities.set_message ( 'err_wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source, access)
	local error_str = &quot;&quot;;
	local domain;
	local path;
	local base_url;

	if not utilities.is_set ( label ) then
		label = URL;
		if utilities.is_set ( source ) then
			error_str = utilities.set_message ( 'err_bare_url_missing_title', { utilities.wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = utilities.set_message ( 'err_bad_url', {utilities.wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the URL into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['['] = '%5b', [']'] = '%5d'});					-- replace '[' and ']' with their percent-encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wiki-markup URL

	if utilities.is_set (access) then											-- access level (subscription, registration, limited)
		base_url = utilities.substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end
	
	return table.concat ({base_url, error_str});
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a Boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { utilities.set_message ( 'err_deprecated_params', {name}, true ) } );	-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wiki-markup) are not kerned.

Replaces Unicode quote marks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc.; not for book titles.

]=]

local function kern_quotes (str)
	local cap = '';
	local cap2 = '';
	local wl_type, label, link;

	wl_type, label, link = utilities.is_wikilink (str);							-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-wl-both'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = utilities.substitute (cfg.presentation['kern-wl-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-wl-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label = mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label = mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap, cap2 = mw.ustring.match (label, &quot;^([\&quot;\'])([^\'].+)&quot;);				-- match leading double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-left'], {cap, cap2});
		end
	
		cap, cap2 = mw.ustring.match (label, &quot;^(.+[^\'])([\&quot;\'])$&quot;)				-- match trailing double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-right'], {cap, cap2});
		end
		
		if 2 == wl_type then
			str = utilities.make_wikilink (link, label);						-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin-based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate RTL languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO 639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO 639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title=, |script-chapter=, |script-&lt;periodical&gt;=

]]

local function format_script_value (script_value, script_param)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%l?%s*:') then									-- if first 3 or 4 non-space characters are script language prefix
		lang = script_value:match('^(%l%l%l?)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not utilities.is_set (lang) then
			table.insert( z.message_tail, { utilities.set_message ( 'err_script_parameter', {script_param, 'missing title part'}, true ) } );		-- prefix without 'title'; add error message
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_code_remap[lang] or mw.language.fetchLanguageName( lang, cfg.this_wiki_code );	-- get language name so that we can use it to categorize
		if utilities.is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l+%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if utilities.in_array (lang, cfg.script_lang_codes) then
				utilities.add_prop_cat ('script_with_name', {name, lang})
			else
				table.insert( z.message_tail, { utilities.set_message ( 'err_script_parameter', {script_param, 'unknown language code'}, true ) } );	-- unknown script-language; add error message
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			table.insert( z.message_tail, { utilities.set_message ( 'err_script_parameter', {script_param, 'invalid language code'}, true ) } );		-- invalid language code; add error message
			lang = '';															-- invalid so set lang to empty string
		end
	else
		table.insert( z.message_tail, { utilities.set_message ( 'err_script_parameter', {script_param, 'missing prefix'}, true ) } );				-- no language code prefix; add error message
	end
	script_value = utilities.substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is RTL

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script, script_param)
	if utilities.is_set (script) then
		script = format_script_value (script, script_param);					-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; returns empty string on error
		if utilities.is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not utilities.is_set ( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return utilities.substitute ( msg, str );								-- including template text
	else
		return utilities.substitute ( cfg.messages[key], str );
	end		
end


--[[--------------------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;----------------------------------------

Makes a Wikisource URL from Wikisource interwiki-link.  Returns the URL and appropriate label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;
	local wikisource_prefix = table.concat ({'https://', cfg.this_wiki_code, '.wikisource.org/wiki/'});

	wl_type, D, L = utilities.is_wikilink (str);								-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 1 == wl_type then													-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end
	
	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable URL
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent encoding of fragment marker
	end

	return ws_url, ws_label, L or D;											-- return proper URL or nil and a label or nil
end


--[[--------------------------&lt; F O R M A T _ P E R I O D I C A L &gt;--------------------------------------------

Format the three periodical parameters: |script-&lt;periodical&gt;=, |&lt;periodical&gt;=, and |trans-&lt;periodical&gt;= into a single Periodical meta-
parameter.

]]

local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)
	local periodical_error = '';

	if not utilities.is_set (periodical) then
		periodical = '';														-- to be safe for concatenation
	else
		periodical = utilities.wrap_style ('italic-title', periodical);			-- style 
	end

	periodical = script_concatenate (periodical, script_periodical, script_periodical_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (trans_periodical) then
		trans_periodical = utilities.wrap_style ('trans-italic-title', trans_periodical);
		if utilities.is_set (periodical) then
			periodical = periodical .. ' ' .. trans_periodical;
		else																	-- here when trans-periodical without periodical or script-periodical
			periodical = trans_periodical;
			periodical_error = ' ' .. utilities.set_message ('err_trans_missing_title', {'periodical'});
		end
	end

	return periodical .. periodical_error;
end


--[[--------------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;--------------------------------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=, and |chapter-url= into a single chapter meta-
parameter (chapter_url_source used for error messages).

]]

local function format_chapter_title (script_chapter, script_chapter_source, chapter, chapter_source, trans_chapter, trans_chapter_source, chapter_url, chapter_url_source, no_quotes, access)
	local chapter_error = '';

	local ws_url, ws_label, L = wikisource_url_make (chapter);					-- make a wikisource URL and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', '');										-- replace underscore separaters with space characters
		chapter = ws_label;
	end

	if not utilities.is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from module provided quote marks
			chapter = utilities.wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, script_chapter, script_chapter_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (chapter_url) then
		chapter = external_link (chapter_url, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');	-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if utilities.is_set (trans_chapter) then
		trans_chapter = utilities.wrap_style ('trans-quoted-title', trans_chapter);
		if utilities.is_set (chapter) then
			chapter = chapter .. ' ' .. trans_chapter;
		else																	-- here when trans_chapter without chapter or script-chapter
			chapter = trans_chapter;
			chapter_source = trans_chapter_source:match ('trans%-?(.+)');		-- when no chapter, get matching name from trans-&lt;param&gt;
			chapter_error = ' ' .. utilities.set_message ('err_trans_missing_title', {chapter_source});
		end
	end

	return chapter .. chapter_error;
end


--[[--------------------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;----------------------------------------

This function searches a parameter's value for non-printable or invisible characters.  The search stops at the
first match.

This function will detect the visible replacement character when it is part of the Wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers (gallery, math, pre, ref)
and identifies them with a slightly different error message.  See also coins_cleanup().

Output of this function is an error message that identifies the character or the Unicode group, or the stripmarker
that was detected along with its position (or, for multi-byte characters, the position of its first byte) in the
parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i = 1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no Unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char = cfg.invisible_chars[i][1]									-- the character or group name
		local pattern = cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position and (char == 'zero width joiner') then						-- if we found a zero-width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- it's ok if one of the Indic scripts
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and utilities.in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { utilities.set_message ( 'err_invisible_char', {err_msg, utilities.wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i = i+1;																-- bump our index
	end
end


--[[--------------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------------------------------

Argument wrapper.  This function provides support for argument mapping defined in the configuration file so that
multiple names can be transparently aliased to single internal variable.

]]

local function argument_wrapper ( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function ( self, k )
			local dummy = self[k]; --force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = utilities.select_one ( args, list, 'err_redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] .. ': ' .. k);
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;--------------------------------------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.  When date is DD MMMM YYYY or is
MMMM DD, YYYY then wrap in nowrap span: &lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap = '';
	local cap2 = '';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = utilities.substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = utilities.substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;----------------------------------------------------

This function sets default title types (equivalent to the citation including |type=&lt;default value&gt;) for those templates that have defaults.
Also handles the special case where it is desirable to omit the title type from the rendered citation (|type=none).

]]

local function set_titletype (cite_class, title_type)
	if utilities.is_set (title_type) then
		if 'none' == cfg.keywords_xlate[title_type] then
			title_type = '';													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash under certain conditions.  The hyphen must separate like items; unlike items are
returned unmodified.  These forms are modified:
	letter - letter (A - B)
	digit - digit (4-5)
	digit separator digit - digit separator digit (4.1-4.5 or 4-1-4-5)
	letterdigit - letterdigit (A1-A5) (an optional separator between letter and digit is supported – a.1-a.5 or a-1-a-5)
	digitletter - digitletter (5a - 5d) (an optional separator between letter and digit is supported – 5.a-5.d or 5-a-5-d)

any other forms are returned unmodified.

str may be a comma- or semicolon-separated list

]]

local function hyphen_to_dash( str )
	if not utilities.is_set (str) then
		return str;
	end

	local accept;																-- Boolean
	str, accept = utilities.has_accept_as_written (str);						-- remove accept-this-as-written markup when it wraps all of str
	if accept then
		return str;																-- when markup removed, nothing to do, we're done
	end

	str = str:gsub ('&amp;[nm]dash;', {['&amp;ndash;'] = '–', ['&amp;mdash;'] = '—'});		-- replace &amp;mdash; and &amp;ndash; entities with their characters; semicolon mucks up the text.split
	str = str:gsub ('&amp;#45;', '-');												-- replace HTML numeric entity with hyphen character
	str = str:gsub ('&amp;nbsp;', ' ');												-- replace &amp;nbsp; entity with generic keyboard space character
	
	local out = {};
	local list = mw.text.split (str, '%s*[,;]%s*');								-- split str at comma or semicolon separators if there are any

	for _, item in ipairs (list) do												-- for each item in the list
		if mw.ustring.match (item, '^%w*[%.%-]?%w+%s*[%-–—]%s*%w*[%.%-]?%w+$') then	-- if a hyphenated range or has endash or emdash separators
			if item:match ('^%a+[%.%-]?%d+%s*%-%s*%a+[%.%-]?%d+$') or			-- letterdigit hyphen letterdigit (optional separator between letter and digit)
				item:match ('^%d+[%.%-]?%a+%s*%-%s*%d+[%.%-]?%a+$') or			-- digitletter hyphen digitletter (optional separator between digit and letter)
				item:match ('^%d+[%.%-]%d+%s*%-%s*%d+[%.%-]%d+$') or			-- digit separator digit hyphen digit separator digit
				item:match ('^%d+%s*%-%s*%d+$') or								-- digit hyphen digit
				item:match ('^%a+%s*%-%s*%a+$') then							-- letter hyphen letter
					item = item:gsub ('(%w*[%.%-]?%w+)%s*%-%s*(%w*[%.%-]?%w+)', '%1–%2');	-- replace hyphen, remove extraneous space characters
			else
				item = mw.ustring.gsub (item, '%s*[–—]%s*', '–');				-- for endash or emdash separated ranges, replace em with en, remove extraneous whitespace
			end
		end
		item = utilities.has_accept_as_written (item);							-- remove accept-this-as-written markup when it wraps all of str
		table.insert (out, item);												-- add the (possibly modified) item to the output table
	end

	return table.concat (out, ', ');											-- concatenate the output table into a comma separated string
end


--[[--------------------------&lt; S A F E _ J O I N &gt;------------------------------------------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'duplicate character'
		if 1 == #duplicate_char then											-- for single byte ASCII characters use the string library functions
			f.gsub = string.gsub
			f.match = string.match
			f.sub = string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub = mw.ustring.gsub
			f.match = mw.ustring.match
			f.sub = mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1, 1) == '&lt;' then										-- special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove HTML markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1, 1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc.?
				trim = false;
				end_chr = f.sub(str, -1, -1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr .. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1, -2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5, -1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3, -1) == duplicate_char .. '&quot;]' then		-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2, -1) == duplicate_char .. &quot;]&quot; then		-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2, -1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1, -3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains HTML markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows HTML markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value;													--add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;------------------------------------------------------------

returns true is suffix is properly formed Jr, Sr, or ordinal in the range 1–9.  Puncutation not allowed.

]]

local function is_suffix (suffix)
	if utilities.in_array (suffix, {'Jr', 'Sr', 'Jnr', 'Snr', '1st', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;--------------------------------------------

For Vancouver style, author/editor names are supposed to be rendered in Latin (read ASCII) characters.  When a name
uses characters that contain diacritical marks, those characters are to converted to the corresponding Latin character.
When a name is written using a non-Latin alphabet or logogram, that name is to be transliterated into Latin characters.
These things are not currently possible in this module so are left to the editor to do.

This test allows |first= and |last= names to contain any of the letters defined in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes. (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;) or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written outside of the code editor and pasted here because the code editor gets confused between character insertion point and cursor position.
The test has been rewritten to use decimal character escape sequence for the individual bytes of the Unicode characters so that it is not necessary
to use an external editor to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first, suffix)
	if not suffix then
		if first:find ('[,%s]') then											-- when there is a space or comma, might be first name/initials + generational suffix
			first = first:match ('(.-)[,%s]+');									-- get name/initials
			suffix = first:match ('[,%s]+(.+)$');								-- get generational suffix
		end
	end
	if utilities.is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error (cfg.err_msg_supl.suffix);
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error (cfg.err_msg_supl['non-Latin char']);
			return false;														-- not a string of Latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-style=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period. See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc.) to be rendered as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the Unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just initials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error (cfg.err_msg_supl.suffix);					-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word

	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i], 1, 1));				-- insert the initial at end of initials table
		end
		i = i+1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; L I S T _ P E O P L E &gt;-------------------------------------------------------

Formats a list of people (e.g. authors, contributors, editors, interviewers, translators) 

names in the list will be linked when
	|&lt;name&gt;-link= has a value
	|&lt;name&gt;-mask- does NOT have a value; masked names are presumed to have been rendered previously so should have been linked there

when |&lt;name&gt;-mask=0, the associated name is not rendered

]]

local function list_people (control, people, etal)
	local sep;
	local namesep;
	local format = control.format;
	local maximum = control.maximum;
	local lastauthoramp = control.lastauthoramp;							-- TODO: delete after deprecation
	local name_list = {};

	if 'vanc' == format then													-- Vancouver-like name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between names is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
		lastauthoramp = nil;												-- TODO: delete after deprecation	-- unset because isn't used by Vancouver style
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between names is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub (-1, -1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if utilities.is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end		-- returned 0 is for EditorCount; not used for other names
	
	for i, person in ipairs (people) do
		if utilities.is_set (person.last) then
			local mask = person.mask;
			local one;
			local sep_one = sep;

			if utilities.is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			end
			
			if mask then
				local n = tonumber (mask);										-- convert to a number if it can be converted; nil else
				if n then
					one = 0 ~= n and string.rep(&quot;&amp;mdash;&quot;,n) or nil;			-- make a string of (n &gt; 0) mdashes, nil else, to replace name
					person.link = nil;											-- don't create link to name if name is replaces with mdash string or has been set nil
				else
					one = mask;													-- replace name with mask text (must include name-list separator)
					sep_one = &quot; &quot;;												-- modify name-list separator
				end
			else
				one = person.last;												-- get surname
				local first = person.first										-- get given name
				if utilities.is_set (first) then
					if (&quot;vanc&quot; == format) then									-- if Vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials (first);					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
			end
			if utilities.is_set (person.link) then
				one = utilities.make_wikilink (person.link, one);				-- link author/editor
			end
			if one then															-- if &lt;one&gt; has a value (name, mdash replacement, or mask text replacement)
				table.insert (name_list, one);									-- add it to the list of names
				table.insert (name_list, sep_one);								-- add the proper name-list separator
			end
		end
	end

	local count = #name_list / 2;												-- (number of names + number of separators) divided by 2
	if 0 &lt; count then 
		if 1 &lt; count and not etal then
			if 'amp' == format or utilities.is_set (lastauthoramp) then			-- TODO: delete lastauthoramp after deprecation
				name_list[#name_list-2] = &quot; &amp; &quot;;								-- replace last separator with ampersand text
			elseif 'and' == format then
				if 2 == count then
					name_list[#name_list-2] = cfg.presentation.sep_nl_and;		-- replace last separator with 'and' text
				else
					name_list[#name_list-2] = cfg.presentation.sep_nl_end;		-- replace last separator with '(sep) and' text
				end
			end
		end
		name_list[#name_list] = nil;											-- erase the last separator
	end

	local result = table.concat (name_list);									-- construct list
	if etal and utilities.is_set (result) then									-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've got a last-first list and etal so add et al.
	end
	
	return result, count;														-- return name-list string and count of number of names (count used for editor names only)
end


--[[--------------------------&lt; A N C H O R _ I D &gt;------------------------------------------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that order.  year is Year or anchor_year.

]]

local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if utilities.is_set (id) then												-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E T A L &gt;----------------------------------------------------

Evaluates the content of name parameters (author, editor, etc.) for variations on the theme of et al.  If found,
the et al. is removed, a flag is set to true and the function returns the modified name and the flag.

This function never sets the flag to false but returns it's previous state because it may have been set by
previous passes through this function or by the associated |display-&lt;names&gt;=etal parameter

]]

local function name_has_etal (name, etal, nocat, param)

	if utilities.is_set (name) then												-- name can be nil in which case just return
		local patterns = cfg.et_al_patterns;									--get patterns from configuration
		
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns
			if name:match (pattern) then										-- if this 'et al' pattern is found in name
				name = name:gsub (pattern, '');									-- remove the offending text
				etal = true;													-- set flag (may have been set previously here or by |display-&lt;names&gt;=etal)
				if not nocat then												-- no categorization for |vauthors=
					table.insert( z.message_tail, {utilities.set_message ('err_etal', {param})});	-- and set an error if not added
				end
			end
		end
	end

	return name, etal;
end


--[[--------------------------&lt; N A M E _ I S _ N U M E R I C &gt;------------------------------------------------

Add maint cat when name parameter value does not contain letters.  Does not catch mixed alphanumeric names so
|last=A. Green (1922-1987) does not get caught in the current version of this test but |first=(1888) is caught.

returns nothing

]]

local function name_is_numeric (name, list_name)
	if utilities.is_set (name) then
		if mw.ustring.match (name, '^[%A]+$') then								-- when name does not contain any letters
			utilities.set_message ('maint_numeric_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
		end
	end
end


--[[--------------------------&lt; N A M E _ H A S _ E D _ M A R K U P &gt;------------------------------------------

Evaluates the content of author and editor parameters for extraneous editor annotations: ed, ed., eds, (Ed.), etc.
These annotation do not belong in author parameters and are redundant in editor parameters.  If found, the function
adds the editor markup maintenance category.

returns nothing

]]

local function name_has_ed_markup (name, list_name)
	local patterns = cfg.editor_markup_patterns;								-- get patterns from configuration

	if utilities.is_set (name) then
		for _, pattern in ipairs (patterns) do									-- spin through patterns table and
			if name:match (pattern) then
				utilities.set_message ('maint_extra_text_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
				break;
			end
		end
	end
end


--[[--------------------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;----------------------------------------

Evaluates the content of last/surname (authors etc.) parameters for multiple names.  Multiple names are indicated
if there is more than one comma or any semicolons.  If found, the function adds the multiple name maintenance category.

returns nothing

]]

local function name_has_mult_names (name, list_name)
	local _, commas, semicolons;
	if utilities.is_set (name) then
		_, commas = name:gsub (',', '');										-- count the number of commas
		_, semicolons = name:gsub (';', '');									-- count the number of semicolons
		
		if 1 &lt; commas or 0 &lt; semicolons then												
			utilities.set_message ('maint_mult_names', cfg.special_case_translation [list_name]);	-- add a maint message
		end
	end
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------

This function calls various name checking functions used to validate the content of the various name-holding
parameters.

]]

local function name_checks (last, first, list_name)
	local accept_name;

	if utilities.is_set (last) then
		last, accept_name = utilities.has_accept_as_written (last);				-- remove accept-this-as-written markup when it wraps all of &lt;last&gt;
		
		if not accept_name then													-- &lt;last&gt; not wrapped in accept-as-written markup
			name_has_mult_names (last, list_name);								-- check for multiple names in the parameter (last only)
			name_has_ed_markup (last, list_name);								-- check for extraneous 'editor' annotation
			name_is_numeric (last, list_name);									-- check for names that are compsed of digits and punctuation
		end
	end

	if utilities.is_set (first) then
		first, accept_name = utilities.has_accept_as_written (first);			-- remove accept-this-as-written markup when it wraps all of &lt;first&gt;

		if not accept_name then														-- &lt;first&gt; not wrapped in accept-as-written markup
			name_has_ed_markup (first, list_name);								-- check for extraneous 'editor' annotation
			name_is_numeric (first, list_name);									-- check for names that are compsed of digits and punctuation
		end
	end

	return last, first;															-- done
end


--[[--------------------------&lt; E X T R A C T _ N A M E S &gt;----------------------------------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters (or their aliases), and their matching link and mask parameters.
Stops searching when both |lastn= and |firstn= are not found in args after two sequential attempts: found |last1=, |last2=, and |last3= but doesn't
find |last4= and |last5= then the search is done.

This function emits an error message when there is a |firstn= without a matching |lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.' is stripped from the parameter and a flag (etal) returned
that will cause list_people() to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps 'et al.' out of the 
template's metadata.  When this occurs, the page is added to a maintenance category.

]]

local function extract_names(args, list_name)
	local names = {};															-- table of names
	local last;																	-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;																-- loop counter/indexer
	local n = 1;																-- output table indexer
	local count = 0;															-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal = false;															-- return value set to true when we find some form of et al. in an author parameter

	local last_alias, first_alias, link_alias;									-- selected parameter aliases used in error messaging
	while true do
		last, last_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'err_redundant_parameters', i );		-- search through args for name components beginning at 1
		first, first_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'err_redundant_parameters', i );
		link, link_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i );
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.
		last, first = name_checks (last, first, list_name);						-- multiple names, extraneous annotation, etc. checks
		
		if first and not last then												-- if there is a firstn without a matching lastn
			local alias = first_alias:find ('given', 1, true) and 'given' or 'first';	-- get first or given form of the alias
			table.insert (z.message_tail, { utilities.set_message ( 'err_first_missing_last', {
				first_alias,													-- param name of alias missing its mate
				first_alias:gsub (alias, {['first'] = 'last', ['given'] = 'surname'}),	-- make param name appropriate to the alias form
				}, true ) } );													-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			local result;
			link = link_title_ok (link, link_alias, last, last_alias);			-- check for improper wiki-markup
			if first then
				link = link_title_ok (link, link_alias, first, first_alias);	-- check for improper wiki-markup
			end

			names[n] = {last = last, first = first, link = link, mask = mask, corporate = false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { utilities.set_message ( 'err_missing_name', {list_name:match (&quot;(%w+)List&quot;):lower(), i - 1}, true ) } );	-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names and the etal flag
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because case of the source may be incorrect
or different from the case that WikiMedia uses, the name comparisons are done in lower case and when a match is
found, the Wikimedia version (assumed to be correct) is returned along with the code.  When there is no match, we
return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') returns a list of languages that in some cases may include
extensions. For example, code 'cbk-zam' and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.  Most (all?) of these languages are not used a 'language' codes per se, rather they
are used as sub-domain names: cbk-zam.wikipedia.org.  A list of language names and codes supported by fetchLanguageNames()
can be found at Template:Citation Style documentation/language/doc

Names that are included in the list will be found if that name is provided in the |language= parameter.  For example,
if |language=Chavacano de Zamboanga, that name will be found with the associated code 'cbk-zam'.  When names are found
and the associated code is not two or three characters, this function returns only the WikiMedia language name.

Some language names have multiple entries under different codes:
	Aromanian has code rup and code roa-rup
When this occurs, this function returns the language name and the 2- or 3-character code

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	if cfg.lang_name_remap[lang:lower()] then									-- if there is a remapped name (because MediaWiki uses something that we don't think is correct)
		return cfg.lang_name_remap[lang:lower()][1], cfg.lang_name_remap[lang:lower()][2];	-- for this language 'name', return a possibly new name and appropriate code
	end

	local ietf_code;															-- because some languages have both IETF-like codes and ISO 639-like codes
	local ietf_name;
	
	local langlc = mw.ustring.lower (lang);										-- lower-case version for comparisons

	for code, name in pairs (cfg.languages) do									-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower (name) then
			if 2 == #code or 3 == #code then									-- two- or three-character codes only; IETF extensions not supported
				return name, code;												-- so return the name and the code
			end
			ietf_code = code;													-- remember that we found an IETF-like code and save its name
			ietf_name = name;													-- but keep looking for a 2- or 3-char code
		end
	end
																				-- didn't find name with 2- or 3-char code; if IETF-like code found return
	return ietf_code and ietf_name or lang;										-- associated name; return original language text else
end


--[[--------------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------------------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code is recognized by MediaWiki,
use the returned name; if not, then use the value that was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is assigned to the category for
that code: Category:Norwegian-language sources (no).  For valid three-character code languages, the page is assigned
to the single category for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does not recognize three-character
equivalents of two-character codes: code 'ar' is recognized but code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th where the language names or codes are
separated from each other by commas with optional space characters.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki_name = mw.language.fetchLanguageName (cfg.this_wiki_code, cfg.this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang
		name = cfg.lang_code_remap[lang:lower()];								-- first see if this is a code that is not supported by MediaWiki but is in remap

		if name then															-- there was a remapped code so
			if not lang:match ('^%a%a%a?%-x%-%a+$') then						-- if not a private IETF tag
				lang = lang:gsub ('^(%a%a%a?)%-.*', '%1');						-- strip IETF tags from code
			end
		else
			lang = lang:gsub ('^(%a%a%a?)%-.*', '%1');							-- strip any IETF-like tags from code
			if 2 == lang:len() or 3 == lang:len() then							-- if two-or three-character code
				name = mw.language.fetchLanguageName (lang:lower(), cfg.this_wiki_code);	-- get language name if |language= is a proper code
			end
		end

		if utilities.is_set (name) then											-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, cfg.this_wiki_code);			-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if utilities.is_set (code) then											-- only 2- or 3-character codes
			name = cfg.lang_code_remap[code] or name;							-- override wikimedia when they misuse language codes/names

			if cfg.this_wiki_code ~= code then									-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					utilities.add_prop_cat ('foreign_lang_source' .. code, {name, code});	-- categorize it; code appended to allow for multiple language categorization
				else															-- or is a recognized language (but has a three-character code)
					utilities.add_prop_cat ('foreign_lang_source_2' .. code, {code});		-- categorize it differently TODO: support multiple three-character code categories per cs1|2 template
				end
			elseif cfg.local_lang_cat_enable then								-- when the language and this wiki's language are the same and categorization is enabled
				utilities.add_prop_cat ('local_lang_source', {name, code});		-- categorize it
			end
		else
			utilities.set_message ('maint_unknown_lang');						-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
 
	name = utilities.make_sep_list (#language_list, language_list);

	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[--------------------------&lt; S E T _ C S 1 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings
At en.wiki, for cs1:
	ps gets:	'.'
	sep gets:	'.'

]]

local function set_cs1_style (ps)
	if not utilities.is_set (ps) then											-- unless explicitly set to something
		ps = cfg.presentation['ps_cs1'];										-- terminate the rendered citation
	end
	return cfg.presentation['sep_cs1'], ps;										-- element separator
end


--[[--------------------------&lt; S E T _ C S 2 _ S T Y L E &gt;----------------------------------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings
At en.wiki, for cs2:
	ps gets:	'' (empty string - no terminal punctuation)
	sep gets:	','

]]

local function set_cs2_style (ps, ref)
	if not utilities.is_set (ps) then											-- if |postscript= has not been set, set cs2 default
		ps = cfg.presentation['ps_cs2'];										-- terminate the rendered citation
	end
	if not utilities.is_set (ref) then											-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return cfg.presentation['sep_cs2'], ps, ref;								-- element separator
end


--[[--------------------------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;----------------------

When |mode= is not set or when its value is invalid, use config.CitationClass and parameter values to establish
rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end


--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation.  Uses |mode= if set and valid or uses
config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end

	if cfg.keywords_xlate[ps:lower()] == 'none' then							-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end


--[=[-------------------------&lt; I S _ P D F &gt;------------------------------------------------------------------

Determines if a URL has the file extension that is one of the PDF file extensions used by [[MediaWiki:Common.css]] when
applying the PDF icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or
		url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
		url:match ('%.PDF&amp;#035') or url:match ('%.pdf&amp;#035');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;------------------------------------------------------

Applies CSS style to |format=, |chapter-format=, etc.  Also emits an error message if the format parameter does
not have a matching URL parameter.  If the format parameter is not set and the URL contains a file extension that
is recognized as a PDF document by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if utilities.is_set (format) then
		format = utilities.wrap_style ('format', format);						-- add leading space, parentheses, resize
		if not utilities.is_set (url) then
			format = format .. ' ' .. utilities.set_message ( 'err_format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if URL is a PDF file then
		format = utilities.wrap_style ('format', 'PDF');						-- set format to PDF
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[--------------------------&lt; G E T _ D I S P L A Y _ N A M E S &gt;--------------------------------------------

Returns a number that defines the number of names displayed for author and editor name lists and a Boolean flag
to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero, return the number and
the previous state of the 'etal' flag (false by default but may have been set to true if the name list contains
some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number that is one greater than the
number of authors in the list and set the 'etal' flag true.  This will cause the list_people() to display all of
the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_names (max, count, list_name, etal)
	if utilities.is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				table.insert( z.message_tail, {utilities.set_message ('err_disp_name', {cfg.special_case_translation [list_name], max}, true)});	-- add error message
				max = nil;
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, {utilities.set_message ('err_disp_name', {cfg.special_case_translation [list_name], max}, true)});		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;------------------------------

Adds page to Category:CS1 maint: extra text if |page= or |pages= has what appears to be some form of p. or pp. 
abbreviation in the first characters of the parameter content.

check Page and Pages for extraneous p, p., pp, and pp. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when |page(s)= begins PX or P# but not Px where x and X are letters and # is a dgiit
	bad pattern: '^[Pp][Pp]' matches matches when |page(s)= begins pp or pP or Pp or PP

]]

local function extra_text_in_page_check (page)
	local good_pattern = '^P[^%.Pp]';											-- ok to begin with uppercase P: P7 (pg 7 of section P) but not p123 (page 123) TODO: add Gg for PG or Pg?
	local bad_pattern = '^[Pp]?[Pp]%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or  page:match ('^[Pp]ages?')) then
		utilities.set_message ('maint_extra_text');								-- add maint cat;
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parentheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a place holder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parentheses
			local name = name_table[i];
			i = i + 1;																-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parentheses
					break;														-- and done reassembling so
				end
				i = i + 1;														-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = utilities.is_wikilink (name_table[i]);		-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i + 1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled parentheses ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the Vancouver error when a required comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		first = '';																-- set to empty string for concatenation and because it may have been set for previous author/editor
		local accept_name;
		v_name, accept_name = utilities.has_accept_as_written (v_name);			-- remove accept-this-as-written markup when it wraps all of &lt;v_name&gt;

--		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parentheses to suppress vanc formatting and error detection
--			last = v_name:match ('^%(%((.+)%)%)$')								-- remove doubled parentheses
		if accept_name then
			last = v_name;
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error (cfg.err_msg_supl.punctuation);
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s+&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be initials or generational suffix

			if not mw.ustring.match (first, '^%u+$') then						-- mw.ustring here so that later we will catch non-Latin characters
				suffix = first;													-- not initials so assume that whatever we got is a generational suffix
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end
			last = table.concat(lastfirstTable, ' ')							-- returns a string that is the concatenation of all other names that are not initials and generational suffix
			if not utilities.is_set (last) then
				first = '';														-- unset
				last = v_name;													-- last empty because something wrong with first
				add_vanc_error (cfg.err_msg_supl.name);
			end
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error (cfg.err_msg_supl['missing comma']);				-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error (cfg.err_msg_supl.name);							-- matches a space between two initials
			end
		else
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
		
		if utilities.is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error (cfg.err_msg_supl.initials);						-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first, suffix);							-- check first and last before restoring the suffix which may have a non-Latin digit
			if utilities.is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '');
			end
		end

		link = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i ) or v_link_table[i];
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate = corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editors=, |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest and
similarly, |editorn= (and aliases) highest and |editors= lowest

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors or editors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
	local lastfirst = false;
	if utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice in case we have a |first1= without a |last1=; this ...
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or		-- ... also catches the case where |first= is used with |vauthors=
		utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst = true;
	end

	if (utilities.is_set (vxxxxors) and true == lastfirst) or					-- these are the three error conditions
		(utilities.is_set (vxxxxors) and utilities.is_set (xxxxors)) or
		(true == lastfirst and utilities.is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { utilities.set_message ( 'err_redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if utilities.is_set (vxxxxors) then return 2 end;
	if utilities.is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, live, dead, etc.).  When the parameter value has not been assigned a value (missing
or empty in the source template) the function returns the value specified by ret_val.  If the parameter value is one
of the list of allowed values returns the translated value; else, emits an error message and returns the value
specified by ret_val.

]]

local function is_valid_parameter_value (value, name, possible, ret_val)
	if not utilities.is_set (value) then
		return ret_val;															-- an empty parameter is ok
	elseif utilities.in_array (value, possible) then
		return cfg.keywords_xlate[value];										-- return translation of parameter keyword
	else
		table.insert( z.message_tail, { utilities.set_message ( 'err_invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return ret_val;
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list, -3, -1) == sepc .. '. ') then					-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list, -1, -1) == sepc) or (string.sub (name_list, -3, -1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terminate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not utilities.is_set (volume) and not utilities.is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (utilities.in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if utilities.is_set (volume) and utilities.is_set (issue) then
			return wrap_msg ('vol-no', {sepc, volume, issue}, lower);
		elseif utilities.is_set (volume) then
			return wrap_msg ('vol', {sepc, volume}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end

	if 'podcast' == cite_class and utilities.is_set (issue) then
		return wrap_msg ('issue', {sepc, issue}, lower);
	end

	local vol = '';																-- here for all cites except magazine
		
	if utilities.is_set (volume) then
		if volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$') then			-- volume value is all digits or all uppercase Roman numerals
			vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});	-- render in bold face
		elseif (4 &lt; mw.ustring.len(volume)) then								-- not all digits or Roman numerals and longer than 4 characters
			vol = utilities.substitute (cfg.messages['j-vol'], {sepc, volume});	-- not bold
			utilities.add_prop_cat ('long_vol');
		else																	-- four or less characters
			vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash(volume)});	-- bold
		end
	end
	if utilities.is_set (issue) then
		return vol .. utilities.substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if utilities.is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif utilities.is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if utilities.is_set (page) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return utilities.substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return utilities.substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif utilities.is_set (pages) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then							-- if pages is only digits, assume a single page number
			return '', utilities.substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', utilities.substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', utilities.substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to Wikisource, returns the label portion of the interwiki-link as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki-link to and external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, pages, at)
	local ws_url, ws_label, coins_pages, L;										-- for Wikisource interwiki-links; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if utilities.is_set (page) then
		if utilities.is_set (pages) or utilities.is_set (at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page);										-- add this page to maint cat if |page= value begins with what looks like p. or pp.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws URL from |page= interwiki link; link portion L becomes tooltip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (pages) then
		if utilities.is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages);										-- add this page to maint cat if |pages= value begins with what looks like p. or pp.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws URL from |pages= interwiki link; link portion L becomes tooltip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws URL from |at= interwiki link; link portion L becomes tooltip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org URLs to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot URL or to calendar pages.  When the archive URL is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the URL.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org URL does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command URL
	|archive-url= is an archive.org URL that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org URLs:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this function may return a modified
archive URL:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the URL unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.org URL
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine URL
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command URL, we don't want to allow saving of the target page 
		err_msg = cfg.err_msg_supl.save;
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = cfg.err_msg_supl.liveweb;
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');	-- split out some of the URL parts for evaluation
		
		if not utilities.is_set (timestamp) or 14 ~= timestamp:len() then		-- path and flag optional, must have 14-digit timestamp here
			err_msg = cfg.err_msg_supl.timestamp;
			if '*' ~= flag then
				url=url:gsub ('(//web%.archive%.org/[^%d]*%d?%d?%d?%d?%d?%d?)[^/]*', '%1*', 1)	-- for preview, modify ts to be yearmo* max (0-6 digits plus splat)
			end
		elseif utilities.is_set (path) and 'web/' ~= path then					-- older archive URLs do not have the extra 'web/' path element
			err_msg = cfg.err_msg_supl.path;
		elseif utilities.is_set (flag) and not utilities.is_set (path) then		-- flag not allowed with the old form URL (without the 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		elseif utilities.is_set (flag) and not flag:match ('%a%a_') then		-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		else
			return url, date;													-- return ArchiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	table.insert( z.message_tail, { utilities.set_message ( 'err_archive_url', {err_msg}, true ) } );	-- add error message and
	if utilities.is_set (Frame:preprocess('{{REVISIONID}}')) then
		return '', '';															-- return empty strings for ArchiveURL and ArchiveDate
	else
		return url, date;														-- preview mode so return ArchiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; P L A C E _ C H E C K &gt;--------------------------------------------------------

check |place=, |publication-place=, |location= to see if these params include digits.  This function added because
many editors misuse location to specify the in-source location (|page(s)= and |at= are supposed to do that)

returns the original parameter value without modification; added maint cat when parameter value contains digits

]]

local function place_check (param_val)
	if not utilities.is_set (param_val) then									-- parameter empty or omitted
		return param_val;														-- return that empty state
	end
	
	if mw.ustring.find (param_val, '%d') then									-- not empty, are there digits in the parameter value
		utilities.set_message ('maint_location');								-- yep, add maint cat
	end
	
	return param_val;															-- and done
end


--[[--------------------------&lt; I S _ G E N E R I C _ T I T L E &gt;----------------------------------------------

compares |title= value against list of known generic title patterns.  Returns true when pattern matches; nil else

the k/v pairs in 'generic_titles' each contain two tables, one for English and one for another 'local' language
Each of those tables contain another table that holds the string or pattern (whole title or title fragment) in
index [1].  index [2] is a Boolean that tells string.find() or mw.ustring.find() to do plain-text search (true)
or a pattern search (false).  The intent of all this complexity is to make these searches as fast as possible so
that we don't run out of processing time on very large articles.

]]

local function is_generic_title (title)
	title = mw.ustring.lower(title);											-- switch title to lower case
	for _, generic_title in ipairs (cfg.special_case_translation['generic_titles']) do	--spin through the list of known generic title fragments
		if title:find (generic_title['en'][1], 1, generic_title['en'][2]) then
			return true;														-- found English generic title so done
		elseif generic_title['local'] then										-- to keep work load down, generic_title['local'] should be nil except when there is a local version of the generic title
			if mw.ustring.find (title, generic_title['local'][1], 1, generic_title['local'][2]) then	-- mw.ustring() because might not be Latin script
				return true;													-- found local generic title so done
			end
		end
	end
end


--[[--------------------------&lt; I S _ A R C H I V E D _ C O P Y &gt;----------------------------------------------

compares |title= to 'Archived copy' (place holder added by bots that can't find proper title); if matches, return true; nil else

]]

local function is_archived_copy (title)
	title = mw.ustring.lower(title);											-- switch title to lower case
	if title:find (cfg.special_case_translation.archived_copy.en) then			-- if title is 'Archived copy'
		return true;
	elseif cfg.special_case_translation.archived_copy['local'] then
		if mw.ustring.find (title, cfg.special_case_translation.archived_copy['local']) then	-- mw.ustring() because might not be Latin script
			return true;
		end
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper ( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

	local Mode = is_valid_parameter_value (A['Mode'], A:ORIGIN('Mode'), cfg.keywords_lists['mode'], '');

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;

	local NameListStyle = is_valid_parameter_value (A['NameListStyle'], A:ORIGIN('NameListStyle'), cfg.keywords_lists['name-list-style'], '');
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';											-- override whatever |name-list-style= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				utilities.set_message ('maint_authors');						-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if utilities.is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], A['Editors'], args, 'EditorList');
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';											-- override whatever |name-list-style= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		elseif 3 == selected then
			Editors = A['Editors'];												-- use content of |editors=
		end
	end

	local translator_etal;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=

	local interviewer_etal;
	local interviewers_list = {};												
	local Interviewers;															-- used later
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters

	local contributor_etal;
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list

	local Chapter = A['Chapter'];												-- done here so that we have access to |contribution= from |chapter= aliases
	local Chapter_origin = A:ORIGIN ('Chapter');
	local Contribution;															-- because contribution is required for contributor(s)
		if 'contribution' == A:ORIGIN ('Chapter') then
			Contribution = A['Chapter'];										-- get the name of the contribution
		end

	if utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not utilities.is_set (Contribution) then							-- |contributor= requires |contribution=
				table.insert( z.message_tail, { utilities.set_message ( 'err_contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { utilities.set_message ( 'err_contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if utilities.select_one (args, cfg.aliases['ContributorList-Last'], 'err_redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { utilities.set_message ( 'err_contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if utilities.is_set (Others) then
		if 0 == #a and 0 == #e then												-- add maint cat when |others= has value and used without |author=, |editor=
			utilities.set_message ('maint_others');
		end
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigDate = A['OrigDate'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TransTitle_origin = A:ORIGIN ('TransTitle');
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];

	local auto_select = ''; -- default is auto
	local accept_link;
	TitleLink, accept_link = utilities.has_accept_as_written(TitleLink, true); -- test for accept-this-as-written markup
	if (not accept_link) and utilities.in_array (TitleLink, {'none', 'pmc', 'doi'}) then -- check for special keywords
		auto_select = TitleLink; -- remember selection for later
		TitleLink = ''; -- treat as if |title-link= would have been empty
	end

	TitleLink = link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wiki-markup in |title-link= or wiki-markup in |title= when |title-link= is set

	local Section = '';															-- {{cite map}} only; preset to empty string for concatenation if not used
		if 'map' == config.CitationClass and 'section' == A:ORIGIN ('Chapter') then
			Section = A['Chapter'];												-- get |section= from |chapter= alias list; |chapter= and the other aliases not supported in {{cite map}}
			Chapter = '';														-- unset for now; will be reset later from |map= if present
		end

	local ScriptChapter = A['ScriptChapter'];
	local ScriptChapter_origin = A:ORIGIN ('ScriptChapter');
	local ChapterLink -- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TransChapter_origin = A:ORIGIN ('TransChapter');
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];

	local ArchiveDate;
	local ArchiveURL;

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	
	local UrlStatus = is_valid_parameter_value (A['UrlStatus'], A:ORIGIN('UrlStatus'), cfg.keywords_lists['url-status'], '');

	local URL = A['URL']
	local URL_origin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURL_origin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURL_origin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL

	local Periodical = A['Periodical'];
	local Periodical_origin = '';
	if utilities.is_set (Periodical) then
		Periodical_origin = A:ORIGIN('Periodical');								-- get the name of the periodical parameter
		local i;
		Periodical, i = utilities.strip_apostrophe_markup (Periodical);			-- strip apostrophe markup so that metadata isn't contaminated 
		if i then																-- non-zero when markup was stripped so emit an error message
			table.insert( z.message_tail, {utilities.set_message ('err_apostrophe_markup', {Periodical_origin}, true)});
		end
	end

	if 'mailinglist' == config.CitationClass then								-- special case for {{cite mailing list}}
		if utilities.is_set (Periodical) and utilities.is_set (A ['MailingList']) then	-- both set emit an error
			table.insert( z.message_tail, {utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', Periodical_origin) .. ' and ' .. utilities.wrap_style ('parameter', 'mailinglist')}, true )});
		end

		Periodical = A ['MailingList'];											-- error or no, set Periodical to |mailinglist= value because this template is {{cite mailing list}}
		Periodical_origin = A:ORIGIN('MailingList');
	end

	local ScriptPeriodical = A['ScriptPeriodical'];
	local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');

	-- web and news not tested for now because of 
	-- Wikipedia:Administrators%27_noticeboard#Is_there_a_semi-automated_tool_that_could_fix_these_annoying_&quot;Cite_Web&quot;_errors?
	if not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) then	-- 'periodical' templates require periodical parameter
	--	local p = {['journal'] = 'journal', ['magazine'] = 'magazine', ['news'] = 'newspaper', ['web'] = 'website'};	-- for error message
		local p = {['journal'] = 'journal', ['magazine'] = 'magazine'};			-- for error message
		if p[config.CitationClass]  then
			table.insert( z.message_tail, {utilities.set_message ('err_missing_periodical', {config.CitationClass, p[config.CitationClass]}, true)});
		end
	end

	local TransPeriodical =  A['TransPeriodical'];
	local TransPeriodical_origin =  A:ORIGIN ('TransPeriodical');

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) then
			if not utilities.in_array (Periodical_origin, {'website', 'mailinglist'}) then	-- {{citation}} does not render volume for these 'periodicals'
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		elseif utilities.is_set (ScriptPeriodical) then
			if 'script-website' ~= ScriptPeriodical_origin then					-- {{citation}} does not render volume for |script-website=
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		else
			Volume = A['Volume'];												-- and does for non-'periodical' cites
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_volume) then	-- render |volume= for cs1 according to the configuration settings
		Volume = A['Volume'];
	end	

	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) and utilities.in_array (Periodical_origin, {'journal', 'magazine', 'newspaper', 'periodical', 'work'}) or	-- {{citation}} renders issue for these 'periodicals'
			utilities.is_set (ScriptPeriodical) and utilities.in_array (ScriptPeriodical_origin, {'script-journal', 'script-magazine', 'script-newspaper', 'script-periodical', 'script-work'}) then -- and these 'script-periodicals'
				Issue = hyphen_to_dash (A['Issue']);
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_issue) then	-- conference &amp; map books do not support issue; {{citation}} listed here because included in settings table
		if not (utilities.in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical))) then
			Issue = hyphen_to_dash (A['Issue']);
		end
	end

	local Position = '';
	if not utilities.in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash (A['Pages']);	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = place_check (A['PublicationPlace'], A:ORIGIN('PublicationPlace'));
	local Place = place_check (A['Place'], A:ORIGIN('Place'));
	
	local PublisherName = A['PublisherName'];
	local PublisherName_origin = A:ORIGIN('PublisherName');
	if utilities.is_set (PublisherName) then
		local i = 0;
		PublisherName, i = utilities.strip_apostrophe_markup (PublisherName);	-- strip apostrophe markup so that metadata isn't contaminated; publisher is never italicized
		if i then																-- non-zero when markup was stripped so emit an error message
			table.insert( z.message_tail, {utilities.set_message ('err_apostrophe_markup', {PublisherName_origin}, true)});
		end
	end

	local Newsgroup = A['Newsgroup'];											-- TODO: strip apostrophe markup?
	local Newsgroup_origin = A:ORIGIN('Newsgroup');	

	if 'newsgroup' == config.CitationClass then
		if utilities.is_set (PublisherName) then								-- general use parameter |publisher= not allowed in cite newsgroup
			local error_text, error_state = utilities.set_message ('err_parameter_ignored', {PublisherName_origin}, true);
			if utilities.is_set (error_text) then
				table.insert( z.message_tail, {error_text, error_state} );
			end				
		end

		PublisherName = nil;													-- ensure that this parameter is unset for the time being; will be used again after COinS
	end

	local UrlAccess = is_valid_parameter_value (A['UrlAccess'], A:ORIGIN('UrlAccess'), cfg.keywords_lists['url-access'], nil);
		if not utilities.is_set (URL) and utilities.is_set (UrlAccess) then
			UrlAccess = nil;
			table.insert( z.message_tail, { utilities.set_message ( 'err_param_access_requires_param', {'url'}, true ) } );
		end
		
	local ChapterUrlAccess = is_valid_parameter_value (A['ChapterUrlAccess'], A:ORIGIN('ChapterUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (ChapterURL) and utilities.is_set (ChapterUrlAccess) then
		ChapterUrlAccess = nil;
		table.insert( z.message_tail, { utilities.set_message ( 'err_param_access_requires_param', {A:ORIGIN('ChapterUrlAccess'):gsub ('%-access', '')}, true ) } );
	end

	local MapUrlAccess = is_valid_parameter_value (A['MapUrlAccess'], A:ORIGIN('MapUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (A['MapURL']) and utilities.is_set (MapUrlAccess) then
		MapUrlAccess = nil;
		table.insert( z.message_tail, { utilities.set_message ( 'err_param_access_requires_param', {'map-url'}, true ) } );
	end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local Agency = A['Agency'];

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local IgnoreISBN = is_valid_parameter_value (A['IgnoreISBN'], A:ORIGIN('IgnoreISBN'), cfg.keywords_lists['yes_true_y'], nil);
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local Quote = A['Quote'];
	local QuotePage = A['QuotePage'];
	local QuotePages = A['QuotePages'];
	local ScriptQuote = A['ScriptQuote'];
	local TransQuote = A['TransQuote'];

	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURL_origin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local LastAuthorAmp = is_valid_parameter_value (A['LastAuthorAmp'], A:ORIGIN('LastAuthorAmp'), cfg.keywords_lists['yes_true_y'], nil);

	local no_tracking_cats = is_valid_parameter_value (A['NoTracking'], A:ORIGIN('NoTracking'), cfg.keywords_lists['yes_true_y'], nil);
	if 'nocat' == A:ORIGIN('NoTracking') then				
		utilities.set_message ('maint_nocat');									-- this one so that we get the message; see main categorization at end of citation0()
	end
	
	--local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = is_valid_parameter_value (A['DF'], A:ORIGIN('DF'), cfg.keywords_lists['df'], '');
	if not utilities.is_set (DF) then
		DF = cfg.global_df;														-- local |df= if present overrides global df set by {{use xxx date}} template
	end

	local sepc;																	-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref = A['Ref'];
	if 'harv' == Ref then
		utilities.set_message ('maint_ref_harv');								-- add maint cat to identify templates that have this now-extraneous param value
	elseif not utilities.is_set (Ref) then
		Ref = 'harv';															-- set as default when not set externally
	end
	
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], Ref, config.CitationClass);
	use_lowercase = ( sepc == ',' ); 											-- used to control capitalization for certain static text

	-- check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not utilities.is_set (no_tracking_cats) then								-- ignore if we are already not going to categorize this page
		if utilities.in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _, v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end
																				-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	utilities.select_one (args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'err_redundant_parameters');	-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, Pages, At);

	local NoPP = is_valid_parameter_value (A['NoPP'], A:ORIGIN('NoPP'), cfg.keywords_lists['yes_true_y'], nil);

	if utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- both |publication-place= and |place= (|location=) allowed if different
		utilities.add_prop_cat ('location test');								-- add property cat to evaluate how often PublicationPlace and Place are used together
		if PublicationPlace == Place then
			Place = '';															-- unset; don't need both if they are the same
		end
	elseif not utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- when only |place= (|location=) is set ...
		PublicationPlace = Place;												-- promote |place= (|location=) to |publication-place
	end

	if PublicationPlace == Place then Place = ''; end							-- don't need both if they are the same
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia= and |title= then map |title= to |article= and |encyclopedia= to |title=
		|encyclopedia= and |article= then map |encyclopedia= to |title=

		|trans-title= maps to |trans-chapter= when |title= is re-mapped
		|url= maps to |chapter-url= when |title= is remapped
	
	All other combinations of |encyclopedia=, |title=, and |article= are not modified
	
	]]

	local Encyclopedia = A['Encyclopedia'];										-- used as a flag by this module and by ~/COinS

	if utilities.is_set (Encyclopedia) then										-- emit error message when Encyclopedia set but template is other than {{cite encyclopedia}} or {{citation}}
		if 'encyclopaedia' ~= config.CitationClass and 'citation' ~= config.CitationClass then
			table.insert (z.message_tail, {utilities.set_message ('err_parameter_ignored', {A:ORIGIN ('Encyclopedia')}, true)});
			Encyclopedia = nil;													-- unset because not supported by this template
		end
	end

	if ('encyclopaedia' == config.CitationClass) or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Periodical) and utilities.is_set (Encyclopedia) then	-- when both set emit an error
			table.insert (z.message_tail, {utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', A:ORIGIN ('Encyclopedia')) .. ' and ' .. utilities.wrap_style ('parameter', Periodical_origin)}, true )});
		end

		if utilities.is_set (Encyclopedia) then
			Periodical = Encyclopedia;											-- error or no, set Periodical to Encyclopedia; allow periodical without encyclopedia
			Periodical_origin = A:ORIGIN ('Encyclopedia');
		end

		if utilities.is_set (Periodical) then									-- Periodical is set when |encyclopedia= is set
			if utilities.is_set (Title) or utilities.is_set (ScriptTitle) then
				if not utilities.is_set (Chapter) then
					Chapter = Title;											-- |encyclopedia= and |title= are set so map |title= to |article= and |encyclopedia= to |title=
					ScriptChapter = ScriptTitle;
					ScriptChapter_origin = A:ORIGIN('ScriptTitle')
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterURL_origin = A:ORIGIN('URL')

					ChapterUrlAccess = UrlAccess;

					if not utilities.is_set (ChapterURL) and utilities.is_set (TitleLink) then
						Chapter = utilities.make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			elseif utilities.is_set (Chapter) then								-- |title= not set
				Title = Periodical;												-- |encyclopedia= set and |article= set so map |encyclopedia= to |title=
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if utilities.is_set (A['Number']) then									-- cite techreport uses 'number', which other citations alias to 'issue'
			if not utilities.is_set (ID) then									-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'id') .. ' and ' .. utilities.wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if utilities.is_set (BookTitle) then
			Chapter = Title;
			Chapter_origin = 'title';
	--		ChapterLink = TitleLink;											-- |chapter-link= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			URL_origin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			TransChapter_origin = TransTitle_origin;
			Title = BookTitle;
			Format = '';
	--		TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		if utilities.is_set (Chapter) then
			table.insert( z.message_tail, { utilities.set_message ( 'err_redundant_parameters', {utilities.wrap_style ('parameter', 'map') .. ' and ' .. utilities.wrap_style ('parameter', Chapter_origin)}, true ) } );	-- add error message
		end
		Chapter = A['Map'];
		Chapter_origin = A:ORIGIN('Map');
		ChapterURL = A['MapURL'];
		ChapterURL_origin = A:ORIGIN('MapURL');
		TransChapter = A['TransMap'];
		ScriptChapter = A['ScriptMap']
		ScriptChapter_origin = A:ORIGIN('ScriptMap')

		ChapterUrlAccess = MapUrlAccess;
		ChapterFormat = A['MapFormat'];

		Cartography = A['Cartography'];
		if utilities.is_set ( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if utilities.is_set ( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local SeriesLink = A['SeriesLink'];

		SeriesLink = link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wiki-markup in |series-link= or wiki-markup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if utilities.is_set (Network) then table.insert(n, Network); end
		if utilities.is_set (Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if utilities.is_set (Season) and utilities.is_set (SeriesNumber) then	-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { utilities.set_message ( 'err_redundant_parameters', {utilities.wrap_style ('parameter', 'season') .. ' and ' .. utilities.wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if utilities.is_set (Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if utilities.is_set (SeriesNumber) then table.insert(s, wrap_msg ('seriesnum', SeriesNumber, use_lowercase)); end
			if utilities.is_set (Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ScriptChapter_origin = A:ORIGIN('ScriptTitle');
			ChapterLink = TitleLink;											-- alias |episode-link=
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if utilities.is_set (ChapterLink) and not utilities.is_set (ChapterURL) then	-- link but not URL
				Chapter = utilities.make_wikilink (ChapterLink, Chapter);
			elseif utilities.is_set (ChapterLink) and utilities.is_set (ChapterURL) then	-- if both are set, URL links episode;
				Series = utilities.make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if utilities.is_set (Series) and utilities.is_set (SeriesLink) then
				Series = utilities.make_wikilink (SeriesLink, Series);
			end
			Series = utilities.wrap_style ('italic-title', Series);				-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- handle type parameter for those CS1 citations that have default values
	if utilities.in_array (config.CitationClass, {&quot;AV-media-notes&quot;, &quot;interview&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if utilities.is_set (Degree) and &quot;Thesis&quot; == TitleType then				-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if utilities.is_set (TitleType) then										-- if type parameter is specified
		TitleType = utilities.substitute ( cfg.messages['type'], TitleType);	-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging

	if not utilities.is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not utilities.is_set (Date) and utilities.is_set (PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val = AccessDate, name = A:ORIGIN ('AccessDate')},
			['archive-date'] = {val = ArchiveDate, name = A:ORIGIN ('ArchiveDate')},
			['date'] = {val = Date, name = Date_origin},
			['doi-broken-date'] = {val = DoiBroken, name = A:ORIGIN ('DoiBroken')},
			['pmc-embargo-date'] = {val = Embargo, name = A:ORIGIN ('Embargo')},
			['lay-date'] = {val = LayDate, name = A:ORIGIN ('LayDate')},
			['publication-date'] = {val = PublicationDate, name = A:ORIGIN ('PublicationDate')},
			['year'] = {val = Year, name = A:ORIGIN ('Year')},
			};

		local error_list = {};
		anchor_year, Embargo = validation.dates(date_parameters_list, COinS_date, error_list);

-- start temporary Julian / Gregorian calendar uncertainty categorization
		if COinS_date.inter_cal_cat then
			utilities.add_prop_cat ('jul_greg_uncertainty');
		end
-- end temporary Julian / Gregorian calendar uncertainty categorization

		if utilities.is_set (Year) and utilities.is_set (Date) then				-- both |date= and |year= not normally needed; 
			local mismatch = validation.year_date_check (Year, Date);
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				table.insert (error_list, '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;year= / &amp;#124;date= mismatch&lt;/code&gt;');
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				utilities.set_message ('maint_date_year');						-- add a maint cat
			end
		end
		
		if 0 == #error_list then												-- error free dates only; 0 when error_list is empty
			local modified = false;												-- flag
			
			if utilities.is_set (DF) then										-- if we need to reformat dates
				modified = validation.reformat_dates (date_parameters_list, DF);	-- reformat to DF format, use long month names if appropriate
			end

			if true == validation.date_hyphen_to_dash (date_parameters_list) then	-- convert hyphens to dashes where appropriate
				modified = true;
				utilities.set_message ('maint_date_format');					-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language,
	-- uncomment the next three lines.  Not supported by en.wiki (for obvious reasons)
	-- set validation.date_name_xlate() second argument to true to translate English digits to local digits (will translate ymd dates)
	--		if validation.date_name_xlate (date_parameters_list, false) then
	--			modified = true;
	--		end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				LayDate = date_parameters_list['lay-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end
		else
			table.insert (z.message_tail, {utilities.set_message ('err_bad_date', {utilities.make_sep_list (#error_list, error_list)}, true)});	-- add this error message
		end
	end	-- end of do

	local ID_list_coins = identifiers.extract_ids (args);						-- gets identifiers and their values from args; this list used for COinS and source for build_id_list()
		if utilities.is_set (DoiBroken) and not ID_list_coins['DOI'] then
			table.insert (z.message_tail, {utilities.set_message ('err_doibroken_missing_doi', A:ORIGIN('DoiBroken'))});
		end
	local ID_access_levels = identifiers.extract_id_access_levels (args, ID_list_coins);
	local ID_list = identifiers.build_id_list (ID_list_coins, {IdAccessLevels = ID_access_levels, DoiBroken = DoiBroken, ASINTLD = ASINTLD, IgnoreISBN = IgnoreISBN, Embargo = Embargo, Class = Class});	-- render identifiers
	
	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite ssrn}}, before generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then
		if not utilities.is_set (ID_list_coins[config.CitationClass:upper()]) then 	-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp; |citeseerx= required for their templates
			table.insert (z.message_tail, {utilities.set_message ('err_' .. config.CitationClass .. '_missing', {}, true)});	-- add error message
		end

		Periodical = ({['arxiv'] = 'arXiv', ['biorxiv'] = 'bioRxiv', ['citeseerx'] = 'CiteSeerX', ['ssrn'] = 'Social Science Research Network'})[config.CitationClass];
	end

	-- Link the title of the work if no |url= was provided, but we have a |pmc= or a |doi= with |doi-access=free

	if config.CitationClass == &quot;journal&quot; and not utilities.is_set (URL) and not utilities.is_set (TitleLink) and not utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) then -- TODO: remove 'none' once existing citations have been switched to 'off', so 'none' can be used as token for &quot;no title&quot; instead
    		if 'none' ~= cfg.keywords_xlate[auto_select] then -- if auto-linking not disabled
 	 		if identifiers.auto_link_urls[auto_select] then -- manual selection
		 		URL = identifiers.auto_link_urls[auto_select]; -- set URL to be the same as identifier's external link
 				URL_origin = cfg.id_handlers[auto_select:upper()].parameters[1]; -- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['pmc'] then -- auto-select PMC
				URL = identifiers.auto_link_urls['pmc']; -- set URL to be the same as the PMC external link if not embargoed
				URL_origin = cfg.id_handlers['PMC'].parameters[1]; -- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['doi'] then -- auto-select DOI
				URL = identifiers.auto_link_urls['doi'];
				URL_origin = cfg.id_handlers['DOI'].parameters[1];
			end
 	 	end

		if utilities.is_set (URL) and utilities.is_set (AccessDate) then		-- access date requires |url=; identifier-created URL is not |url=
			table.insert( z.message_tail, { utilities.set_message ( 'err_accessdate_missing_url', {}, true ) } );	-- add an error message
			AccessDate = '';													-- unset
		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not utilities.is_set (Title) and not utilities.is_set (TransTitle) and not utilities.is_set (ScriptTitle) then	-- has special case for cite episode
		table.insert( z.message_tail, { utilities.set_message ( 'err_citation_missing_title', {'episode' == config.CitationClass and 'series' or 'title'}, true ) } );
	end

	if utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) and
			utilities.in_array (config.CitationClass, {'journal', 'citation'}) and
			(utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and
			('journal' == Periodical_origin or 'script-journal' == ScriptPeriodical_origin) then	-- special case for journal cites
				Title = '';														-- set title to empty string
				utilities.set_message ('maint_untitled');						-- add maint cat
	end

	check_for_url ({															-- add error message when any of these parameters hold a URL
		['title']=Title,
		[A:ORIGIN('Chapter')]=Chapter,
		[Periodical_origin] = Periodical,
		[PublisherName_origin] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Chapter) and utilities.is_set (Title) and utilities.is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = metadata.COinS({
		['Periodical'] = utilities.strip_apostrophe_markup (Periodical),		-- no markup in the metadata
		['Encyclopedia'] = Encyclopedia,										-- just a flag; content ignored by ~/COinS
		['Chapter'] = metadata.make_coins_title (coins_chapter, ScriptChapter),	-- Chapter and ScriptChapter stripped of bold / italic wiki-markup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = metadata.make_coins_title (coins_title, ScriptTitle),		-- Title and ScriptTitle stripped of bold / italic wiki-markup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Quarter'] = COinS_date.rftquarter,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = coins_pages or metadata.get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At}, 5)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName or Newsgroup,							-- any apostrophe markup already removed from PublisherName
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list_coins,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, and {{cite ssrn}} AFTER generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, CiteSeerX, or ssrn now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass and utilities.is_set (Newsgroup) then
		PublisherName = utilities.substitute (cfg.messages['newsgroup'], external_link( 'news:' .. Newsgroup, Newsgroup, Newsgroup_origin, nil ));
	end

	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local control = { 
			format = NameListStyle,											-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			lastauthoramp = LastAuthorAmp,
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_names (A['DisplayEditors'], #e, 'editors', editor_etal);
			last_first_list, EditorCount = list_people(control, e, editor_etal);

			if utilities.is_set (Editors) then
				Editors, editor_etal = name_has_etal (Editors, editor_etal, false, 'editors');	-- find and remove variations on et al.
				if editor_etal then
					Editors = Editors .. ' ' .. cfg.messages['et al'];			-- add et al. to editors parameter beause |display-editors=etal
				end
				EditorCount = 2;												-- we don't know but assume |editors= is multiple names; spoof to display (eds.) annotation
			else
				Editors = last_first_list;										-- either an author name list or an empty string
			end

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum , interviewer_etal = get_display_names (A['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal);
			Interviewers = list_people (control, interviewers_list, interviewer_etal);
		end
		do																		-- now do translators
			control.maximum , translator_etal = get_display_names (A['DisplayTranslators'], #t, 'translators', translator_etal);
			Translators = list_people (control, t, translator_etal);
		end
		do																		-- now do contributors
			control.maximum , contributor_etal = get_display_names (A['DisplayContributors'], #c, 'contributors', contributor_etal);
			Contributors = list_people (control, c, contributor_etal);
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_names (A['DisplayAuthors'], #a, 'authors', author_etal);

			last_first_list = list_people(control, a, author_etal);

			if utilities.is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors');	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if utilities.is_set (Authors) and utilities.is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
	-- an error message if the associated URL is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not utilities.is_set (URL) then
		if utilities.in_array (config.CitationClass, {&quot;web&quot;, &quot;podcast&quot;, &quot;mailinglist&quot;}) or		-- |url= required for cite web, cite podcast, and cite mailinglist
			('citation' == config.CitationClass and ('website' == Periodical_origin or 'script-website' == ScriptPeriodical_origin)) then	-- and required for {{citation}} with |website= or |script-website=
				table.insert( z.message_tail, { utilities.set_message ( 'err_cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if utilities.is_set (AccessDate) and not utilities.is_set (ChapterURL) then		-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { utilities.set_message ( 'err_accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURL_origin, OriginalFormat, OriginalAccess;
	UrlStatus = UrlStatus:lower();												-- used later when assembling archived text
	if utilities.is_set ( ArchiveURL ) then
		if utilities.is_set (ChapterURL) then 									-- if chapter-url= is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURL_origin = ChapterURL_origin;								-- name of |chapter-url= parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=

			if 'live' ~= UrlStatus then
				ChapterURL = ArchiveURL											-- swap-in the archive's URL
				ChapterURL_origin = A:ORIGIN('ArchiveURL')						-- name of |archive-url= parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived URLs
			end
		elseif utilities.is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURL_origin = URL_origin;									-- name of URL parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;

			if 'live' ~= UrlStatus then											-- if URL set then |archive-url= applies to it
				URL = ArchiveURL												-- swap-in the archive's URL
				URL_origin = A:ORIGIN('ArchiveURL')								-- name of archive URL parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived URLs
			end
 		end
	end

	if utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) then
			local chap_param;
			if utilities.is_set (Chapter) then									-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif utilities.is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif utilities.is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif utilities.is_set (ScriptChapter) then
				chap_param = ScriptChapter_origin;
			else utilities.is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if utilities.is_set (chap_param) then								-- if we found one
				table.insert( z.message_tail, { utilities.set_message ( 'err_chapter_ignored', {chap_param}, true ) } );	-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if utilities.is_set (Contribution) and 0 &lt; #c then						-- if this is a contribution with contributor(s)
			if utilities.in_array (Contribution:lower(), cfg.keywords_lists.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, ScriptChapter_origin, Chapter, Chapter_origin, TransChapter, TransChapter_origin, ChapterURL, ChapterURL_origin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if utilities.is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and utilities.is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter .. sepc .. ' ';
		elseif utilities.is_set (ChapterFormat) then							-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title
	local plain_title = false;
	local accept_title;
	Title, accept_title = utilities.has_accept_as_written (Title, true);		-- remove accept-this-as-written markup when it wraps all of &lt;Title&gt;
	if accept_title and ('' == Title) then										-- only support forced empty for now &quot;(())&quot;
		Title = cfg.messages['notitle'];										-- replace by predefined &quot;No title&quot; message
			-- TODO: utilities.set_message ( 'err_redundant_parameters', ...);	-- issue proper error message instead of muting	 
			ScriptTitle = '';													-- just mute for now	 
			TransTitle = '';													-- just mute for now
 		plain_title = true;														-- suppress text decoration for descriptive title
		utilities.set_message ('maint_untitled');								-- add maint cat
	end

	if not accept_title then -- &lt;Title&gt; not wrapped in accept-as-written markup
		if '...' == Title:sub (-3) then											-- if ellipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%' .. sepc .. '$', '');			-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end

		if utilities.is_set (ArchiveURL) and is_archived_copy (Title) then
			utilities.set_message ('maint_archived_copy');						-- add maintenance category before we modify the content of Title
		end

		if is_generic_title (Title) then
			table.insert (z.message_tail, {utilities.set_message ( 'err_generic_title', {}, true ) } );	-- set an error message
		end
	end

	if (not plain_title) and (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) or
		('map' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)))) then		-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from module provided quote marks
			Title = utilities.wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle, 'script-title');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
			TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );
	elseif plain_title or ('report' == config.CitationClass) then								-- no styling for cite report and descriptive titles (otherwise same as above)
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = utilities.wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if utilities.is_set (TransTitle) then
		if utilities.is_set (Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. utilities.set_message ( 'err_trans_missing_title', {'title'} );
		end
	end

	if utilities.is_set (Title) then											-- TODO: is this the right place to be making Wikisource URLs?
		if utilities.is_set (TitleLink) and utilities.is_set (URL) then
			table.insert( z.message_tail, { utilities.set_message ( 'err_wikilink_in_url', {}, true ) } );	-- set an error message because we can't have both
			TitleLink = '';														-- unset
		end
		
		if not utilities.is_set (TitleLink) and utilities.is_set (URL) then
			Title = external_link (URL, Title, URL_origin, UrlAccess) .. TransTitle .. TransError .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif utilities.is_set (TitleLink) and not utilities.is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = utilities.make_wikilink (TitleLink, Title) .. TransTitle .. TransError;
			end
		else
			local ws_url, ws_label, L;											-- Title has italic or quote markup by the time we get here which causes is_wikilink() to return 0 (not a wikilink)
			ws_url, ws_label, L = wikisource_url_make (Title:gsub('[\'&quot;](.-)[\'&quot;]', '%1'));	-- make ws URL from |title= interwiki link (strip italic or quote markup); link portion L becomes tooltip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = Title .. TransTitle .. TransError;
			end
		end
	else
		Title = TransTitle .. TransError;
	end

	if utilities.is_set (Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if utilities.is_set (Conference) then
		if utilities.is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURL_origin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif utilities.is_set (ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURL_origin, nil );
	end

	if not utilities.is_set (Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if utilities.is_set (Minutes) then
			if utilities.is_set (Time) then
				table.insert( z.message_tail, { utilities.set_message ( 'err_redundant_parameters', {utilities.wrap_style ('parameter', 'minutes') .. ' and ' .. utilities.wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if utilities.is_set (Time) then
				local TimeCaption = A['TimeCaption']
				if not utilities.is_set (TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = utilities.is_set (At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = utilities.is_set (Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Sections = A['Sections'];											-- Section (singular) is an alias of Chapter so set earlier
		local Inset = A['Inset'];
		
		if utilities.is_set ( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if utilities.is_set ( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif utilities.is_set ( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if utilities.is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc.
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	Others = utilities.is_set (Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if utilities.is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if utilities.is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	TitleNote = utilities.is_set (TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if utilities.is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%.?$') or Edition:match ('%f[%a][Ee]dition$') then
			utilities.set_message ('maint_extra_text', 'edition');				-- add maint cat
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = utilities.is_set (Series) and wrap_msg ('series', {sepc, Series}) or &quot;&quot;;	-- not the same as SeriesNum
	OrigDate = utilities.is_set (OrigDate) and wrap_msg ('origdate', OrigDate) or '';
	Agency = utilities.is_set (Agency) and wrap_msg ('agency', {sepc, Agency}) or &quot;&quot;;
	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	Via = utilities.is_set (Via) and  wrap_msg ('via', Via) or '';

	if utilities.is_set (AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = utilities.substitute (retrv_text, AccessDate);				-- add retrieved text

		AccessDate = utilities.substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if utilities.is_set (ID) then ID = sepc .. &quot; &quot; .. ID; end
   	if &quot;thesis&quot; == config.CitationClass and utilities.is_set (Docket) then
		ID = sepc .. &quot; Docket &quot; .. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and utilities.is_set (Docket) then		-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	if utilities.is_set (URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URL_origin, UrlAccess );
	end

	if utilities.is_set (Quote) or utilities.is_set (TransQuote) or utilities.is_set (ScriptQuote) then

		if utilities.is_set (Quote) then
			if Quote:sub(1, 1) == '&quot;' and Quote:sub(-1, -1) == '&quot;' then			-- if first and last characters of quote are quote marks
				Quote = Quote:sub(2, -2);										-- strip them off
			end
		end

		Quote = utilities.wrap_style ('quoted-text', Quote ); 	-- wrap in &lt;q&gt;...&lt;/q&gt; tags
	
		if utilities.is_set (ScriptQuote) then
			Quote = script_concatenate (Quote, ScriptQuote, 'script-quote'); -- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after quote is wrapped
		end

		if utilities.is_set (TransQuote) then
			if TransQuote:sub(1, 1) == '&quot;' and TransQuote:sub(-1, -1) == '&quot;' then -- if first and last characters of |trans-quote are quote marks
				TransQuote = TransQuote:sub(2, -2); -- strip them off
			end
			Quote = Quote .. &quot; &quot; .. utilities.wrap_style ('trans-quoted-title', TransQuote );
		end

		if utilities.is_set (QuotePage) or utilities.is_set (QuotePages) then	-- add page prefix
			local quote_prefix = '';
			if utilities.is_set (QuotePage) then
				if not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePage}), '', '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePage}), '', '', '';
				end
			elseif utilities.is_set (QuotePages) then
				if tonumber(QuotePages) ~= nil and not NoPP then				-- if only digits, assume single page
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePages}), '', '';
				elseif not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['pp-prefix'], {sepc, QuotePages}), '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePages}), '', '';
				end
			end
                        
			Quote = quote_prefix .. &quot;: &quot; .. Quote;
		else
			Quote = sepc .. &quot; &quot; .. Quote;
		end

		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if utilities.is_set (ArchiveURL) then
		local arch_text;
		if not utilities.is_set (ArchiveDate) then
			ArchiveDate = utilities.set_message ('err_archive_missing_date');
		end
		if &quot;live&quot; == UrlStatus then
			arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. utilities.substitute ( cfg.messages['archived-live'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil ) .. ArchiveFormat, ArchiveDate } );
			if not utilities.is_set (OriginalURL) then
				Archived = Archived .. &quot; &quot; .. utilities.set_message ('err_archive_missing_url');							   
			end
		elseif utilities.is_set (OriginalURL) then								-- UrlStatus is empty, 'dead', 'unfit', 'usurped', 'bot: unknown'
			if utilities.in_array (UrlStatus, {'unfit', 'usurped', 'bot: unknown'}) then
				arch_text = cfg.messages['archived-unfit'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. &quot; &quot; .. arch_text .. ArchiveDate;				-- format already styled
				if 'bot: unknown' == UrlStatus then
					utilities.set_message ('maint_bot_unknown');				-- and add a category if not already added
				else
					utilities.set_message ('maint_unfit');						-- and add a category if not already added
				end
			else																-- UrlStatus is empty, 'dead'
				arch_text = cfg.messages['archived-dead'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. &quot; &quot; .. utilities.substitute ( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURL_origin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else																	-- OriginalUrl not set
			arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. utilities.substitute ( arch_text, 
				{ utilities.set_message ('err_archive_missing_url'), ArchiveDate } );
		end
	elseif utilities.is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if utilities.is_set (LayURL) then
		if utilities.is_set (LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if utilities.is_set (LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. utilities.safe_for_italics (LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif utilities.is_set (LayFormat) then									-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if utilities.is_set (Transcript) then
		if utilities.is_set (TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURL_origin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif utilities.is_set (TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURL_origin, nil );
	end

	local Publisher;
	if utilities.is_set (PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if utilities.is_set (PublisherName) then
		if utilities.is_set (PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif utilities.is_set (PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical)) then
		if utilities.is_set (Title) or utilities.is_set (TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		else 
			Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		end
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then									-- cite speech only
		TitleNote = &quot; (Speech)&quot;;												-- annotate the citation
		if utilities.is_set (Periodical) then									-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if utilities.is_set (Conference) then								-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;							-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
		if utilities.is_set (Others) then Others = safe_join ({Others, sepc .. &quot; &quot;}, sepc) end		-- add terminal punctuation &amp; space; check for dup sepc; TODO why do we need to do this here?
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (Periodical) then		-- special cases for book cites
		if utilities.is_set (Contributors) then									-- when we are citing foreword, preface, introduction, etc.
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if utilities.is_set (Chapter) then										-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif utilities.is_set (Periodical) then								-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon;
	if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then	-- special case for cite AV media &amp; cite episode position transcript
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, Lay, Quote }, sepc );
	else
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, Lay, Quote }, sepc );
	end
	
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if utilities.is_set (Date) then
		if utilities.is_set (Authors) or utilities.is_set (Editors) then		-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date .. &quot;)&quot; .. OrigDate .. sepc .. &quot; &quot;;				-- in parentheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon, -1, -1) == sepc) then						-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigDate;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigDate;							-- Date begins with sepc
			end
		end
	end	
	if utilities.is_set (Authors) then
		if (not utilities.is_set (Date)) then									-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if utilities.is_set (Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then
					in_text = in_text:lower()									-- lowercase for cs2
				end
			end
			if EditorCount &lt;= 1 then
				post_text = &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot;;				-- be consistent with no-author, no-date case
			else
				post_text = &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot;;
			end
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Contributors) then									-- book cite and we're citing the intro, preface, etc.
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if utilities.is_set (Editors) and utilities.is_set (Date) then		-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not utilities.is_set (Date)) then								-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif utilities.is_set (Editors) then
		if utilities.is_set (Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if utilities.is_set (PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc ); 								--Deals with italics, spaces, etc.
		text = text:sub(1, -sepc:len() - 1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if utilities.is_set (config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = string.format ('%s %s %s', 'citation', config.CitationClass, utilities.is_set (Mode) and Mode or 'cs1');	-- class=citation required for blue highlight when used with |ref=
	else
		options.class = string.format ('%s %s', 'citation', utilities.is_set (Mode) and Mode or 'cs2');
	end
	
	if utilities.is_set (Ref) and 'none' ~= cfg.keywords_xlate[Ref:lower()] then
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			if #namelist &gt; 0 then												-- if there are names in namelist
				id = anchor_id (namelist, year);								-- go make the CITEREF anchor
			else
				id = '';														-- unset
			end
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;(.-)&lt;/span&gt;&quot;, &quot;%1&quot;):gsub(&quot;%b&lt;&gt;&quot;, &quot;&quot;)) &lt;= 2 then	-- remove &lt;span&gt; tags and other HTML-like markup; then get length of what remains
		z.error_categories = {};
		text = utilities.set_message ('err_empty_citation');
		z.message_tail = {};
	end
	
	local render = {};															-- here we collect the final bits for concatenation into the rendered citation

	if utilities.is_set (options.id) then										-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render, utilities.substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text}));	-- when |ref= is set
	else
		table.insert (render, utilities.substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text}));	-- all other cases
	end		

	table.insert (render, utilities.substitute (cfg.presentation['ocins'], {OCinSoutput}));	-- append metadata to the citation

	if 0 ~= #z.message_tail then
		table.insert (render, ' ');
		for i,v in ipairs( z.message_tail ) do
			if utilities.is_set (v[1]) then
				if i == #z.message_tail then
					table.insert (render, utilities.error_comment ( v[1], v[2] ));
				else
					table.insert (render, utilities.error_comment ( v[1] .. &quot;; &quot;, v[2] ));
				end
			end
		end
	end

	if 0 ~= #z.maintenance_cats then
		local maint_msgs = {};													-- here we collect all of the maint messages
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			local maint = {};													-- here we assemble a maintenence message
			table.insert (maint, v);											-- maint msg is the category name
			table.insert (maint, ' (');											-- open the link text
			table.insert (maint, utilities.make_wikilink (':Category:' .. v, 'link'));	-- add the link
			table.insert (maint, ')');											-- and close it
			table.insert (maint_msgs, table.concat (maint));					-- assemble new maint message and add it to the maint_msgs table
		end
		table.insert (render, utilities.substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs, ' ')));	-- wrap the group of maint message with proper presentation and save
	end
	
	if not no_tracking_cats then
		for _, v in ipairs( z.error_categories ) do
			table.insert (render, utilities.make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			table.insert (render, utilities.make_wikilink ('Category:' .. v));
		end
		for _, v in ipairs( z.properties_cats ) do								-- append properties categories
			table.insert (render, utilities.make_wikilink ('Category:' .. v));
		end
	elseif 'nocat' == A:ORIGIN('NoTracking') then								-- peculiar special case; can't track nocat without tracking nocat
		table.insert (render, utilities.make_wikilink ('Category:CS1 maint: nocat'));	-- hand-set this category because it is supposed to be temporary
	end

	return table.concat (render);	
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class, empty)
	local name = tostring (name);
	local enum_name;															-- for enumerated parameters, is name with enumerator replaced with '#'
	local state;
	local function state_test (state, name)										-- local function to do testing of state values
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			if empty then return nil; end										-- deprecated empty parameters are treated as unknowns
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
		return nil;
	end		

	if name:find ('#') then														-- # is a cs1|2 reserved character so parameters with # not permitted
		return nil;
	end

	if utilities.in_array (cite_class, whitelist.preprint_template_list ) then	-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[name];
		if true == state_test (state, name) then return true; end

		state = whitelist.preprint_arguments[cite_class][name];					-- look in the parameter-list for the template identified by cite_class
		if true == state_test (state, name) then return true; end

																				-- limited enumerated parameters list
		enum_name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );										-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
		state = whitelist.limited_numbered_arguments[enum_name];
		if true == state_test (state, name) then return true; end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates

	if utilities.in_array (cite_class, whitelist.unique_param_template_list) then 	-- experiment for template-specific parameters for templates that accept parameters from the basic argument list
		state = whitelist.unique_arguments[cite_class][name];					-- look in the template-specific parameter-lists for the template identified by cite_class
		if true == state_test (state, name) then return true; end
	end																			-- if here, fall into general validation
		
	state = whitelist.basic_arguments[name];									-- all other templates; all normal parameters allowed
	if true == state_test (state, name) then return true; end

																				-- all enumerated parameters allowed
	enum_name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
	state = whitelist.numbered_arguments[enum_name];
	if true == state_test (state, name) then return true; end

	return false;																-- not supported because not found or name is set to nil
end


--[=[-------------------------&lt; I N T E R _ W I K I _ C H E C K &gt;----------------------------------------------

check &lt;value&gt; for inter-language interwiki-link markup.  &lt;prefix&gt; must be a MediaWiki-recognized language
code.  when these values have the form (without leading colon):
	[[&lt;prefix&gt;:link|label]] return label as plain-text
	[[&lt;prefix&gt;:link]] return &lt;prefix&gt;:link as plain-text

return value as is else

]=]

local function inter_wiki_check (parameter, value)
	local prefix = value:match ('%[%[(%a+):');									-- get an interwiki prefix if one exists
	local _;
	
	if prefix and cfg.inter_wiki_map[prefix:lower()] then						-- if prefix is in the map, needs preceding colon so
		table.insert( z.message_tail, {utilities.set_message ('err_bad_paramlink', parameter)});	-- emit an error message
		_, value, _ = utilities.is_wikilink (value);							-- extract label portion from wikilink
	end
	return value;
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe.  There are two tests made:
	{{cite ... |title=Title access-date=2016-03-17}}	-- the first parameter has a value and whitespace separates that value from the missing pipe parameter name
	{{cite ... |title=access-date=2016-03-17}}			-- the first parameter has no value (whitespace after the first = is trimmed by MediaWiki)
cs1|2 shares some parameter names with XML/HTML attributes: class=, title=, etc.  To prevent false positives XML/HTML
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (parameter, value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove XML/HTML tags because attributes: class=, title=, etc.

	capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then										-- if the capture is a valid parameter name
		table.insert( z.message_tail, {utilities.set_message ('err_missing_pipe', parameter)});
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ P U N C T &gt;--------------------------------------

look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_punc (param, value)
	if 'number' == type (param) then
		return;
	end
	
	param = param:gsub ('%d+', '#');											-- enumerated name-list mask params allow terminal punct; normalize 
	if cfg.punct_skip[param] then
		return;																	-- parameter name found in the skip table so done
	end
	
	if value:match ('[,;:]$') then
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
end


--[[--------------------------&lt; C I T A T I O N &gt;--------------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

local function citation(frame)
	Frame = frame;																-- save a copy in case we need to display an error message in preview mode
	local pframe = frame:getParent()
	local styles;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		styles = 'Module:Citation/CS1/sandbox/styles.css';
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
		styles = 'Module:Citation/CS1/styles.css';
	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the selected cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text, error_state;

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do											-- get parameters from the {{#invoke}} frame
		config[k] = v;
	--	args[k] = v;															-- crude debug support that allows us to render a citation from module {{#invoke:}}; skips parameter validation; TODO: keep?
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	local empty_unknowns = {};													-- sequence table to hold empty unknown params for error message listing
	for k, v in pairs( pframe.args ) do											-- get parameters from the parent (template) frame
		v = mw.ustring.gsub (v, '^%s*(.-)%s*$', '%1');							-- trim leading/trailing whitespace; when v is only whitespace, becomes empty string
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = utilities.set_message ( 'err_text_ignored', {v}, true );
					end
				elseif validate( k:lower(), config.CitationClass ) then 
					error_text, error_state = utilities.set_message ( 'err_parameter_ignored_suggest', {k, k:lower()}, true );	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no capture in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = utilities.substitute (param, capture);		-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text, error_state = utilities.set_message ('err_parameter_ignored_suggest', {k, param}, true);	-- set the suggestion error message
							else
								error_text, error_state = utilities.set_message ( 'err_parameter_ignored', {param}, true );	-- suggested param not supported by this template
								v = '';											-- unset
							end
						end
					end
					if not utilities.is_set (error_text) then					-- couldn't match with a pattern, is there an expicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = utilities.set_message ( 'err_parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = utilities.set_message ( 'err_parameter_ignored', {k}, true );
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end

			args[k] = v;														-- save this parameter and its value

		elseif not utilities.is_set (v) then									-- for empty parameters
			if not validate (k, config.CitationClass, true) then				-- is this empty parameter a valid parameter
				k = ('' == k) and '(empty string)' or k;						-- when k is empty string (or was space(s) trimmed to empty string), replace with descriptive text
				table.insert (empty_unknowns, utilities.wrap_style ('parameter', k));	-- format for error message and add to the list
			end
																				-- crude debug support that allows us to render a citation from module {{#invoke:}} TODO: keep?
	--	elseif args[k] ~= nil or (k == 'postscript') then						-- when args[k] has a value from {{#invoke}} frame (we don't normally do that)
	--		args[k] = v;														-- overwrite args[k] with empty string from pframe.args[k] (template frame); v is empty string here
		end																		-- not sure about the postscript bit; that gets handled in parameter validation; historical artifact?
	end	

	if 0 ~= #empty_unknowns then												-- create empty unknown error message
		table.insert (z.message_tail, {utilities.set_message ('err_param_unknown_empty', {
			1 == #empty_unknowns and '' or 's',
			utilities.make_sep_list (#empty_unknowns, empty_unknowns)
			}, true )});
	end

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);											-- look for invisible characters
		end
		has_extraneous_punc (k, v);												-- look for extraneous terminal punctuation in parameter values
		missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?
		args[k] = inter_wiki_check (k, v);										-- when language interwiki-linked parameter missing leading colon replace with wiki-link label
	end

	return table.concat ({citation0( config, args), frame:extensionTag ('templatestyles', '', {src=styles})});
end

--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {citation = citation};</text>
      <sha1>m4thujyhbbwao63118b0ar80pgg4dwy</sha1>
    </revision>
    <revision>
      <id>4739</id>
      <parentid>4738</parentid>
      <timestamp>2021-01-09T14:11:20Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4739</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="203425" sha1="mrol5zdo98hyrm4oo4fptd61rlfao1c" xml:space="preserve">
require('Module:No globals');

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------

each of these counts against the Lua upvalue limit

]]

local validation;																-- functions in Module:Citation/CS1/Date_validation

local utilities;																-- functions in Module:Citation/CS1/Utilities
local z ={};																	-- table of tables in Module:Citation/CS1/Utilities

local identifiers;																-- functions and tables in Module:Citation/CS1/Identifiers
local metadata;																	-- functions in Module:Citation/CS1/COinS
local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

declare variables here that have page-wide scope that are not brought in from other modules; that are created here and used here

]]

local added_deprecated_cat;														-- Boolean flag so that the category is added only once
local added_vanc_errs;															-- Boolean flag so we only emit one Vancouver error / category

local Frame;																	-- holds the module's frame table


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if utilities.is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a Boolean declared in page scope variables above

]]

local function add_vanc_error (source)
	if not added_vanc_errs then
		added_vanc_errs = true;													-- note that we've added this category
		table.insert( z.message_tail, { utilities.set_message ( 'err_vancouver', {source}, true ) } );
	end
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a URI scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of TLDs: https://www.iana.org/domains/root/db

RFC 952 (modified by RFC 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the TLD.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a URL with a scheme) will be stripped
here.  Perhaps not necessary but retained in case it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ASCII characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the TLD) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and TLD or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%w]') then											-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at Wikisource
		return false;
	end

	local patterns = {															-- patterns that look like URLs
		'%f[%w][%w][%w%-]+[%w]%.%a%a+$',										-- three or more character hostname.hostname or hostname.tld
		'%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$',									-- internationalized domain name with ACE prefix
		'%f[%a][qxz]%.com$',													-- assigned one character .com hostname (x.com times out 2015-12-10)
		'%f[%a][iq]%.net$',														-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		'%f[%w][%w]%.%a%a$',													-- one character hostname and ccTLD (2 chars)
		'%f[%w][%w][%w]%.%a%a+$',												-- two character hostname and TLD
		'^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?',								-- IPv4 address
		}

	for _, pattern in ipairs (patterns) do										-- loop through the patterns list
		if domain:match (pattern) then
			return true;														-- if a match then we think that this thing that purports to be a URL is a URL
		end
	end

	for _, d in ipairs ({'cash', 'company', 'today', 'org'}) do					-- look for single letter second level domain names for these top level domains
		if domain:match ('%f[%w][%w]%.' .. d) then
			return true
		end
	end
	return false;																-- no matches, we don't know what this thing is
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a URL appear to be a valid URL; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if utilities.is_set (scheme) then											-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when URL is protocol-relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a URL into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following TLD) (if any) and any path(/), query(?) or fragment(#).

If protocol-relative URL, return nil scheme and domain else return nil for both scheme and domain.

When not protocol-relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Any URL that does not have news: scheme must have authority indicator (//).  TODO: are there other common schemes
like news: that don't use authority indicator?

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol-relative URL
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		if utilities.is_set (authority) then
			authority = authority:gsub ('//', '', 1);							-- replace place 1 pair of '/' with nothing;
			if utilities.is_set(authority) then									-- if anything left (1 or 3+ '/' where authority should be) then
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		else
			if not scheme:match ('^news:') then									-- except for news:..., MediaWiki won't link URLs that do not have authority indicator; TODO: a better way to do this test?
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link=, etc. for properly formatted content: no wikilinks, no URLs

Link parameters are to hold the title of a Wikipedia article, so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki URLs and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid URL (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid URL (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from URL; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid URL
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wiki-linked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

check &lt;link&gt; for inter-language interwiki-link prefix.  prefix must be a MediaWiki-recognized language
code and must begin with a colon.

]]

local function link_title_ok (link, lorig, title, torig)
local orig;
	if utilities.is_set (link) then 											-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		elseif link:match ('^%a+:') then										-- if the link is what looks like an interwiki
			local prefix = link:match ('^(%a+):'):lower();						-- get the interwiki prefix

			if cfg.inter_wiki_map[prefix] then									-- if prefix is in the map, must have preceding colon
				orig = lorig;													-- flag as error
			end
		end
	end

	if utilities.is_set (orig) then
		link = '';																-- unset
		table.insert( z.message_tail, { utilities.set_message ( 'err_bad_paramlink', orig)});	-- URL or wikilink in |title= with |title-link=;
	end
	
	return link;																-- link if ok, empty string else
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the URL into scheme and domain
portions, or for protocol-relative (//example.com) URLs, just the domain.  Use is_url() to validate the two
portions of the URL.  If both are valid, or for protocol-relative if domain is valid, return true, else false.

Because it is different from a standard URL, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper URL
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from URL;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a URL.  The test will also find external wikilinks
that use protocol-relative URLs. Also finds bare URLs.

The frontier pattern prevents a match on interwiki-links which are similar to scheme:path URLs.  The tests that
find bracketed URLs are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext. wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol-relative ext. wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare URL with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol-relative bare URL: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a URL
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a URL add an error message
			if utilities.is_set(error_message) then								-- once we've added the first portion of the error message ...
				error_message = error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message = error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if utilities.is_set (error_message) then									-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { utilities.set_message ( 'err_param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { utilities.set_message ( 'err_wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source, access)
	local error_str = &quot;&quot;;
	local domain;
	local path;
	local base_url;

	if not utilities.is_set ( label ) then
		label = URL;
		if utilities.is_set ( source ) then
			error_str = utilities.set_message ( 'err_bare_url_missing_title', { utilities.wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = utilities.set_message ( 'err_bad_url', {utilities.wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the URL into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['['] = '%5b', [']'] = '%5d'});					-- replace '[' and ']' with their percent-encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wiki-markup URL

	if utilities.is_set (access) then											-- access level (subscription, registration, limited)
		base_url = utilities.substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end
	
	return table.concat ({base_url, error_str});
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a Boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { utilities.set_message ( 'err_deprecated_params', {name}, true ) } );	-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wiki-markup) are not kerned.

Replaces Unicode quote marks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc.; not for book titles.

]=]

local function kern_quotes (str)
	local cap = '';
	local cap2 = '';
	local wl_type, label, link;

	wl_type, label, link = utilities.is_wikilink (str);							-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-wl-both'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = utilities.substitute (cfg.presentation['kern-wl-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-wl-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label = mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label = mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap, cap2 = mw.ustring.match (label, &quot;^([\&quot;\'])([^\'].+)&quot;);				-- match leading double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-left'], {cap, cap2});
		end
	
		cap, cap2 = mw.ustring.match (label, &quot;^(.+[^\'])([\&quot;\'])$&quot;)				-- match trailing double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-right'], {cap, cap2});
		end
		
		if 2 == wl_type then
			str = utilities.make_wikilink (link, label);						-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin-based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate RTL languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO 639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO 639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title=, |script-chapter=, |script-&lt;periodical&gt;=

]]

local function format_script_value (script_value, script_param)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%l?%s*:') then									-- if first 3 or 4 non-space characters are script language prefix
		lang = script_value:match('^(%l%l%l?)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not utilities.is_set (lang) then
			table.insert( z.message_tail, { utilities.set_message ( 'err_script_parameter', {script_param, 'missing title part'}, true ) } );		-- prefix without 'title'; add error message
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_code_remap[lang] or mw.language.fetchLanguageName( lang, cfg.this_wiki_code );	-- get language name so that we can use it to categorize
		if utilities.is_set (name) then													-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l+%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if utilities.in_array (lang, cfg.script_lang_codes) then
				utilities.add_prop_cat ('script_with_name', {name, lang})
			else
				table.insert( z.message_tail, { utilities.set_message ( 'err_script_parameter', {script_param, 'unknown language code'}, true ) } );	-- unknown script-language; add error message
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			table.insert( z.message_tail, { utilities.set_message ( 'err_script_parameter', {script_param, 'invalid language code'}, true ) } );		-- invalid language code; add error message
			lang = '';															-- invalid so set lang to empty string
		end
	else
		table.insert( z.message_tail, { utilities.set_message ( 'err_script_parameter', {script_param, 'missing prefix'}, true ) } );				-- no language code prefix; add error message
	end
	script_value = utilities.substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is RTL

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script, script_param)
	if utilities.is_set (script) then
		script = format_script_value (script, script_param);					-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; returns empty string on error
		if utilities.is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not utilities.is_set ( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return utilities.substitute ( msg, str );								-- including template text
	else
		return utilities.substitute ( cfg.messages[key], str );
	end		
end


--[[----------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;-------------------

Makes a Wikisource URL from Wikisource interwiki-link.  Returns the URL and appropriate
label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;
	local wikisource_prefix = table.concat ({'https://', cfg.this_wiki_code, '.wikisource.org/wiki/'});

	wl_type, D, L = utilities.is_wikilink (str);								-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 1 == wl_type then													-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end

	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable URL
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent-encoding of fragment marker
	end

	return ws_url, ws_label, L or D;											-- return proper URL or nil and a label or nil
end


--[[----------------&lt; F O R M A T _ P E R I O D I C A L &gt;-----------------------

Format the three periodical parameters: |script-&lt;periodical&gt;=, |&lt;periodical&gt;=,
and |trans-&lt;periodical&gt;= into a single Periodical meta-parameter.

]]

local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)
	local periodical_error = '';

	if not utilities.is_set (periodical) then
		periodical = '';														-- to be safe for concatenation
	else
		periodical = utilities.wrap_style ('italic-title', periodical);			-- style 
	end

	periodical = script_concatenate (periodical, script_periodical, script_periodical_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (trans_periodical) then
		trans_periodical = utilities.wrap_style ('trans-italic-title', trans_periodical);
		if utilities.is_set (periodical) then
			periodical = periodical .. ' ' .. trans_periodical;
		else																	-- here when trans-periodical without periodical or script-periodical
			periodical = trans_periodical;
			periodical_error = ' ' .. utilities.set_message ('err_trans_missing_title', {'periodical'});
		end
	end

	return periodical .. periodical_error;
end


--[[------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;---------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=,
and |chapter-url= into a single chapter meta- parameter (chapter_url_source used
for error messages).

]]

local function format_chapter_title (script_chapter, script_chapter_source, chapter, chapter_source, trans_chapter, trans_chapter_source, chapter_url, chapter_url_source, no_quotes, access)
	local chapter_error = '';

	local ws_url, ws_label, L = wikisource_url_make (chapter);					-- make a wikisource URL and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', ' ');									-- replace underscore separators with space characters
		chapter = ws_label;
	end

	if not utilities.is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from module provided quote marks
			chapter = utilities.wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, script_chapter, script_chapter_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (chapter_url) then
		chapter = external_link (chapter_url, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');	-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if utilities.is_set (trans_chapter) then
		trans_chapter = utilities.wrap_style ('trans-quoted-title', trans_chapter);
		if utilities.is_set (chapter) then
			chapter = chapter .. ' ' .. trans_chapter;
		else																	-- here when trans_chapter without chapter or script-chapter
			chapter = trans_chapter;
			chapter_source = trans_chapter_source:match ('trans%-?(.+)');		-- when no chapter, get matching name from trans-&lt;param&gt;
			chapter_error = ' ' .. utilities.set_message ('err_trans_missing_title', {chapter_source});
		end
	end

	return chapter .. chapter_error;
end


--[[----------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;-------------------

This function searches a parameter's value for non-printable or invisible characters.
The search stops at the first match.

This function will detect the visible replacement character when it is part of the Wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers
(gallery, math, pre, ref) and identifies them with a slightly different error message.
See also coins_cleanup().

Output of this function is an error message that identifies the character or the
Unicode group, or the stripmarker that was detected along with its position (or,
for multi-byte characters, the position of its first byte) in the parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local dummy;																-- end of matching string; not used but required to hold end position when a capture is returned
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local i = 1;
	local stripmarker, apostrophe;
	
	capture = string.match (v, '[%w%p ]*');										-- test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no Unicode characters
		return;
	end

	while cfg.invisible_chars[i] do
		local char = cfg.invisible_chars[i][1]									-- the character or group name
		local pattern = cfg.invisible_chars[i][2]									-- the pattern used to find it
		position, dummy, capture = mw.ustring.find (v, pattern)					-- see if the parameter value contains characters that match the pattern
		
		if position and (char == 'zero width joiner') then						-- if we found a zero-width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- it's ok if one of the Indic scripts
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and utilities.in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and 'delete' == char then				-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture then
					err_msg = capture .. ' ' .. char;
				else
					err_msg = char .. ' ' .. 'character';
				end

				table.insert( z.message_tail, { utilities.set_message ( 'err_invisible_char', {err_msg, utilities.wrap_style ('parameter', param), position}, true ) } );	-- add error message
				return;															-- and done with this parameter
			end
		end
		i = i + 1;																-- bump our index
	end
end


--[[-------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------

Argument wrapper.  This function provides support for argument mapping defined
in the configuration file so that multiple names can be transparently aliased to
single internal variable.

]]

local function argument_wrapper ( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function ( self, k )
			local dummy = self[k]; -- force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = utilities.select_one ( args, list, 'err_redundant_parameters' );
				if origin[k] == nil then
					origin[k] = ''; -- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] .. ': ' .. k);
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;-------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.
When date is DD MMMM YYYY or is MMMM DD, YYYY then wrap in nowrap span:
&lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap = '';
	local cap2 = '';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = utilities.substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = utilities.substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;---------------------

This function sets default title types (equivalent to the citation including
|type=&lt;default value&gt;) for those templates that have defaults. Also handles the
special case where it is desirable to omit the title type from the rendered citation
(|type=none).

]]

local function set_titletype (cite_class, title_type)
	if utilities.is_set (title_type) then
		if 'none' == cfg.keywords_xlate[title_type] then
			title_type = '';													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash under certain conditions.  The hyphen must separate
like items; unlike items are returned unmodified.  These forms are modified:
	letter - letter (A - B)
	digit - digit (4-5)
	digit separator digit - digit separator digit (4.1-4.5 or 4-1-4-5)
	letterdigit - letterdigit (A1-A5) (an optional separator between letter and
		digit is supported – a.1-a.5 or a-1-a-5)
	digitletter - digitletter (5a - 5d) (an optional separator between letter and
		digit is supported – 5.a-5.d or 5-a-5-d)

any other forms are returned unmodified.

str may be a comma- or semicolon-separated list

]]

local function hyphen_to_dash( str )
	if not utilities.is_set (str) then
		return str;
	end

	local accept; -- Boolean

	str = str:gsub ('&amp;[nm]dash;', {['&amp;ndash;'] = '–', ['&amp;mdash;'] = '—'});		-- replace &amp;mdash; and &amp;ndash; entities with their characters; semicolon mucks up the text.split
	str = str:gsub ('&amp;#45;', '-'); -- replace HTML numeric entity with hyphen character
	str = str:gsub ('[^%-]%-%-%-[^%-]', '—'); -- replace triple-hyphen with emdash
	str = str:gsub ('[^%-]%-%-[^%-]', '–'); -- replace double-hyphen (as found in BibTeX entries) with endash

	str = str:gsub ('&amp;nbsp;', ' '); -- replace &amp;nbsp; entity with generic keyboard space character
	
	local out = {};
	local list = mw.text.split (str, '%s*[,;]%s*');								-- split str at comma or semicolon separators if there are any

	for _, item in ipairs (list) do												-- for each item in the list
		item, accept = utilities.has_accept_as_written (item); -- remove accept-this-as-written markup when it wraps all of item
		if not accept and mw.ustring.match (item, '^%w*[%.%-]?%w+%s*[%-–—]%s*%w*[%.%-]?%w+$') then	-- if a hyphenated range or has endash or emdash separators
			if item:match ('^%a+[%.%-]?%d+%s*%-%s*%a+[%.%-]?%d+$') or			-- letterdigit hyphen letterdigit (optional separator between letter and digit)
				item:match ('^%d+[%.%-]?%a+%s*%-%s*%d+[%.%-]?%a+$') or			-- digitletter hyphen digitletter (optional separator between digit and letter)
				item:match ('^%d+[%.%-]%d+%s*%-%s*%d+[%.%-]%d+$') or			-- digit separator digit hyphen digit separator digit
				item:match ('^%d+%s*%-%s*%d+$') or								-- digit hyphen digit
				item:match ('^%a+%s*%-%s*%a+$') then							-- letter hyphen letter
					item = item:gsub ('(%w*[%.%-]?%w+)%s*%-%s*(%w*[%.%-]?%w+)', '%1–%2');	-- replace hyphen, remove extraneous space characters
			else
				item = mw.ustring.gsub (item, '%s*[–—]%s*', '–');				-- for endash or emdash separated ranges, replace em with en, remove extraneous whitespace
			end
		end
		table.insert (out, item);												-- add the (possibly modified) item to the output table
	end

        local temp_str = ''; -- concatenate the output table into a comma separated string
	temp_str, accept = utilities.has_accept_as_written (table.concat (out, ', ')); -- remove accept-this-as-written markup when it wraps all of concatenated out
	if accept then
		return utilities.has_accept_as_written (str); -- when global markup removed, return original str
	else
		return temp_str; -- else, return assembled temp_str
	end
end

--[[--------------------------&lt; S A F E _ J O I N &gt;-----------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'duplicate character'
		if 1 == #duplicate_char then											-- for single byte ASCII characters use the string library functions
			f.gsub = string.gsub
			f.match = string.match
			f.sub = string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub = mw.ustring.gsub
			f.match = mw.ustring.match
			f.sub = mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1, 1) == '&lt;' then										-- special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove HTML markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1, 1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc.?
				trim = false;
				end_chr = f.sub(str, -1, -1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr .. &quot;)&quot;					-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1, -2);										-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;''&quot; then			-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5, -1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;]]&quot; then			-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3, -1) == duplicate_char .. '&quot;]' then		-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2, -1) == duplicate_char .. &quot;]&quot; then		-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2, -1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1, -3);									-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains HTML markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows HTML markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value; 													-- add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;-----------------------------

returns true is suffix is properly formed Jr, Sr, or ordinal in the range 1–9.
Puncutation not allowed.

]]

local function is_suffix (suffix)
	if utilities.in_array (suffix, {'Jr', 'Sr', 'Jnr', 'Snr', '1st', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;-------------------

For Vancouver style, author/editor names are supposed to be rendered in Latin
(read ASCII) characters.  When a name uses characters that contain diacritical marks,
those characters are to converted to the corresponding Latin character. When a name
is written using a non-Latin alphabet or logogram, that name is to be transliterated
into Latin characters. The module doesn't do this so editors may/must.

This test allows |first= and |last= names to contain any of the letters defined
in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes.
	(http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;)
	or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written outside of the code editor and pasted here because the code editor
gets confused between character insertion point and cursor position. The test has
been rewritten to use decimal character escape sequence for the individual bytes
of the Unicode characters so that it is not necessary to use an external editor
to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first, suffix)
	if not suffix then
		if first:find ('[,%s]') then											-- when there is a space or comma, might be first name/initials + generational suffix
			first = first:match ('(.-)[,%s]+');									-- get name/initials
			suffix = first:match ('[,%s]+(.+)$');								-- get generational suffix
		end
	end
	if utilities.is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error (cfg.err_msg_supl.suffix);
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error (cfg.err_msg_supl['non-Latin char']);
			return false;														-- not a string of Latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-style=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period.
See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc.) to be rendered
as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format
because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the
Unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just initials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error (cfg.err_msg_supl.suffix);					-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word

	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i], 1, 1));				-- insert the initial at end of initials table
		end
		i = i + 1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; L I S T _ P E O P L E &gt;--------------------------

Formats a list of people (authors, contributors, editors, interviewers, translators) 

names in the list will be linked when
	|&lt;name&gt;-link= has a value
	|&lt;name&gt;-mask- does NOT have a value; masked names are presumed to have been
		rendered previously so should have been linked there

when |&lt;name&gt;-mask=0, the associated name is not rendered

]]

local function list_people (control, people, etal)
	local sep;
	local namesep;
	local format = control.format;
	local maximum = control.maximum;
	local name_list = {};

	if 'vanc' == format then													-- Vancouver-like name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between names is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between names is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub (-1, -1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if utilities.is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end		-- returned 0 is for EditorCount; not used for other names
	
	for i, person in ipairs (people) do
		if utilities.is_set (person.last) then
			local mask = person.mask;
			local one;
			local sep_one = sep;

			if utilities.is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			end
			
			if mask then
				local n = tonumber (mask);										-- convert to a number if it can be converted; nil else
				if n then
					one = 0 ~= n and string.rep(&quot;&amp;mdash;&quot;, n) or nil;			-- make a string of (n &gt; 0) mdashes, nil else, to replace name
					person.link = nil;											-- don't create link to name if name is replaces with mdash string or has been set nil
				else
					one = mask;													-- replace name with mask text (must include name-list separator)
					sep_one = &quot; &quot;;												-- modify name-list separator
				end
			else
				one = person.last;												-- get surname
				local first = person.first										-- get given name
				if utilities.is_set (first) then
					if (&quot;vanc&quot; == format) then									-- if Vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials (first);					-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
			end
			if utilities.is_set (person.link) then
				one = utilities.make_wikilink (person.link, one);				-- link author/editor
			end
			if one then															-- if &lt;one&gt; has a value (name, mdash replacement, or mask text replacement)
				table.insert (name_list, one);									-- add it to the list of names
				table.insert (name_list, sep_one);								-- add the proper name-list separator
			end
		end
	end

	local count = #name_list / 2;												-- (number of names + number of separators) divided by 2
	if 0 &lt; count then 
		if 1 &lt; count and not etal then
			if 'amp' == format then
				name_list[#name_list-2] = &quot; &amp; &quot;;								-- replace last separator with ampersand text
			elseif 'and' == format then
				if 2 == count then
					name_list[#name_list-2] = cfg.presentation.sep_nl_and;		-- replace last separator with 'and' text
				else
					name_list[#name_list-2] = cfg.presentation.sep_nl_end;		-- replace last separator with '(sep) and' text
				end
			end
		end
		name_list[#name_list] = nil;											-- erase the last separator
	end

	local result = table.concat (name_list);									-- construct list
	if etal and utilities.is_set (result) then									-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've got a last-first list and etal so add et al.
	end
	
	return result, count;														-- return name-list string and count of number of names (count used for editor names only)
end


--[[--------------------------&lt; A N C H O R _ I D &gt;-----------------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise
returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that
order.  year is Year or anchor_year.

]]

local function anchor_id (namelist, year)
	local names={};																-- a table for the one to four names and year
	for i,v in ipairs (namelist) do												-- loop through the list and take up to the first four last names
		names[i] = v.last 
		if i == 4 then break end												-- if four then done
	end
	table.insert (names, year);													-- add the year at the end
	local id = table.concat(names);												-- concatenate names and year for CITEREF id
	if utilities.is_set (id) then												-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;													-- add the CITEREF portion
	else
		return '';																-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[---------------------&lt; N A M E _ H A S _ E T A L &gt;--------------------------

Evaluates the content of name parameters (author, editor, etc.) for variations on
the theme of et al.  If found, the et al. is removed, a flag is set to true and
the function returns the modified name and the flag.

This function never sets the flag to false but returns its previous state because
it may have been set by previous passes through this function or by the associated
|display-&lt;names&gt;=etal parameter

]]

local function name_has_etal (name, etal, nocat, param)

	if utilities.is_set (name) then												-- name can be nil in which case just return
		local patterns = cfg.et_al_patterns; 									-- get patterns from configuration
		
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns
			if name:match (pattern) then										-- if this 'et al' pattern is found in name
				name = name:gsub (pattern, '');									-- remove the offending text
				etal = true;													-- set flag (may have been set previously here or by |display-&lt;names&gt;=etal)
				if not nocat then												-- no categorization for |vauthors=
					table.insert( z.message_tail, {utilities.set_message ('err_etal', {param})});	-- and set an error if not added
				end
			end
		end
	end

	return name, etal;
end


--[[---------------------&lt; N A M E _ I S _ N U M E R I C &gt;----------------------

Add maint cat when name parameter value does not contain letters.  Does not catch
mixed alphanumeric names so |last=A. Green (1922-1987) does not get caught in the
current version of this test but |first=(1888) is caught.

returns nothing

]]

local function name_is_numeric (name, list_name)
	if utilities.is_set (name) then
		if mw.ustring.match (name, '^[%A]+$') then								-- when name does not contain any letters
			utilities.set_message ('maint_numeric_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
		end
	end
end


--[[-------------------&lt; N A M E _ H A S _ E D _ M A R K U P &gt;------------------

Evaluates the content of author and editor parameters for extraneous editor annotations:
ed, ed., eds, (Ed.), etc. These annotations do not belong in author parameters and
are redundant in editor parameters.  If found, the function adds the editor markup
maintenance category.

returns nothing

]]

local function name_has_ed_markup (name, list_name)
	local patterns = cfg.editor_markup_patterns;								-- get patterns from configuration

	if utilities.is_set (name) then
		for _, pattern in ipairs (patterns) do									-- spin through patterns table and
			if name:match (pattern) then
				utilities.set_message ('maint_extra_text_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
				break;
			end
		end
	end
end


--[[-----------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;------------------

Evaluates the content of last/surname (authors etc.) parameters for multiple names.
Multiple names are indicated if there is more than one comma or any &quot;unescaped&quot;
semicolons. Escaped semicolons are ones used as part of selected HTML entities.
If the condition is met, the function adds the multiple name maintenance category.

returns nothing

]]

local function name_has_mult_names (name, list_name)
	local _, commas, semicolons, nbsps;
	if utilities.is_set (name) then
		_, commas = name:gsub (',', '');										-- count the number of commas
		_, semicolons = name:gsub (';', '');									-- count the number of semicolons
		-- nbsps probably should be its own separate count rather than merged in
		-- some way with semicolons because Lua patterns do not support the
		-- grouping operator that regex does, which means there is no way to add
		-- more entities to escape except by adding more counts with the new
		-- entities
		_, nbsps = name:gsub ('&amp;nbsp;','');										-- count nbsps
		
		-- There is exactly 1 semicolon per &amp;nbsp; entity, so subtract nbsps
		-- from semicolons to 'escape' them. If additional entities are added,
		-- they also can be subtracted.
		if 1 &lt; commas or 0 &lt; (semicolons - nbsps) then
			utilities.set_message ('maint_mult_names', cfg.special_case_translation [list_name]);	-- add a maint message
		end
	end
end


--[[------------------------&lt; N A M E _ C H E C K S &gt;---------------------------

This function calls various name checking functions used to validate the content
of the various name-holding parameters.

]]

local function name_checks (last, first, list_name)
	local accept_name;

	if utilities.is_set (last) then
		last, accept_name = utilities.has_accept_as_written (last);				-- remove accept-this-as-written markup when it wraps all of &lt;last&gt;
		
		if not accept_name then													-- &lt;last&gt; not wrapped in accept-as-written markup
			name_has_mult_names (last, list_name);								-- check for multiple names in the parameter (last only)
			name_has_ed_markup (last, list_name);								-- check for extraneous 'editor' annotation
			name_is_numeric (last, list_name);									-- check for names that are composed of digits and punctuation
		end
	end

	if utilities.is_set (first) then
		first, accept_name = utilities.has_accept_as_written (first);			-- remove accept-this-as-written markup when it wraps all of &lt;first&gt;

		if not accept_name then														-- &lt;first&gt; not wrapped in accept-as-written markup
			name_has_ed_markup (first, list_name);								-- check for extraneous 'editor' annotation
			name_is_numeric (first, list_name);									-- check for names that are composed of digits and punctuation
		end
	end

	return last, first;															-- done
end


--[[----------------------&lt; E X T R A C T _ N A M E S &gt;-------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters
(or their aliases), and their matching link and mask parameters. Stops searching
when both |lastn= and |firstn= are not found in args after two sequential attempts:
found |last1=, |last2=, and |last3= but doesn't find |last4= and |last5= then the
search is done.

This function emits an error message when there is a |firstn= without a matching
|lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not
required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.'
is stripped from the parameter and a flag (etal) returned that will cause list_people()
to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps
'et al.' out of the template's metadata.  When this occurs, an error is emitted.

]]

local function extract_names(args, list_name)
	local names = {};															-- table of names
	local last;																	-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;																-- loop counter/indexer
	local n = 1;																-- output table indexer
	local count = 0;															-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal = false;															-- return value set to true when we find some form of et al. in an author parameter

	local last_alias, first_alias, link_alias;									-- selected parameter aliases used in error messaging
	while true do
		last, last_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'err_redundant_parameters', i );		-- search through args for name components beginning at 1
		first, first_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'err_redundant_parameters', i );
		link, link_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i );
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.
		last, first = name_checks (last, first, list_name);						-- multiple names, extraneous annotation, etc. checks
		
		if first and not last then												-- if there is a firstn without a matching lastn
			local alias = first_alias:find ('given', 1, true) and 'given' or 'first';	-- get first or given form of the alias
			table.insert (z.message_tail, { utilities.set_message ( 'err_first_missing_last', {
				first_alias,													-- param name of alias missing its mate
				first_alias:gsub (alias, {['first'] = 'last', ['given'] = 'surname'}),	-- make param name appropriate to the alias form
				}, true ) } );													-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			local result;
			link = link_title_ok (link, link_alias, last, last_alias);			-- check for improper wiki-markup
			if first then
				link = link_title_ok (link, link_alias, first, first_alias);	-- check for improper wiki-markup
			end

			names[n] = {last = last, first = first, link = link, mask = mask, corporate = false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { utilities.set_message ( 'err_missing_name', {list_name:match (&quot;(%w+)List&quot;):lower(), i - 1}, true ) } );	-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names and the etal flag
end


--[[--------------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;------------------------------------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because
case of the source may be incorrect or different from the case that WikiMedia uses,
the name comparisons are done in lower case and when a match is found, the Wikimedia
version (assumed to be correct) is returned along with the code.  When there is no
match, we return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') returns a list of
languages that in some cases may include extensions. For example, code 'cbk-zam'
and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.  Most (all?) of these languages are not used a
'language' codes per se, rather they are used as sub-domain names: cbk-zam.wikipedia.org.
A list of language names and codes supported by fetchLanguageNames() can be found
at Template:Citation Style documentation/language/doc

Names that are included in the list will be found if that name is provided in the
|language= parameter.  For example, if |language=Chavacano de Zamboanga, that name
will be found with the associated code 'cbk-zam'.  When names are found and the
associated code is not two or three characters, this function returns only the
WikiMedia language name.

Some language names have multiple entries under different codes:
	Aromanian has code rup and code roa-rup
When this occurs, this function returns the language name and the 2- or 3-character code

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	if cfg.lang_name_remap[lang:lower()] then									-- if there is a remapped name (because MediaWiki uses something that we don't think is correct)
		return cfg.lang_name_remap[lang:lower()][1], cfg.lang_name_remap[lang:lower()][2];	-- for this language 'name', return a possibly new name and appropriate code
	end

	local ietf_code;															-- because some languages have both IETF-like codes and ISO 639-like codes
	local ietf_name;
	
	local langlc = mw.ustring.lower (lang);										-- lower-case version for comparisons

	for code, name in pairs (cfg.languages) do									-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower (name) then
			if 2 == #code or 3 == #code then									-- two- or three-character codes only; IETF extensions not supported
				return name, code;												-- so return the name and the code
			end
			ietf_code = code;													-- remember that we found an IETF-like code and save its name
			ietf_name = name;													-- but keep looking for a 2- or 3-char code
		end
	end
																				-- didn't find name with 2- or 3-char code; if IETF-like code found return
	return ietf_code and ietf_name or lang;										-- associated name; return original language text else
end


--[[-------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code
is recognized by MediaWiki, use the returned name; if not, then use the value that
was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is
assigned to the category for that code: Category:Norwegian-language sources (no).
For valid three-character code languages, the page is assigned to the single category
for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does
not recognize three-character equivalents of two-character codes: code 'ar' is
recognized but code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th
where the language names or codes are separated from each other by commas with
optional space characters.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki_name = mw.language.fetchLanguageName (cfg.this_wiki_code, cfg.this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang
		name = cfg.lang_code_remap[lang:lower()];								-- first see if this is a code that is not supported by MediaWiki but is in remap

		if name then															-- there was a remapped code so
			if not lang:match ('^%a%a%a?%-x%-%a+$') then						-- if not a private IETF tag
				lang = lang:gsub ('^(%a%a%a?)%-.*', '%1');						-- strip IETF tags from code
			end
		else
			lang = lang:gsub ('^(%a%a%a?)%-.*', '%1');							-- strip any IETF-like tags from code
			if 2 == lang:len() or 3 == lang:len() then							-- if two-or three-character code
				name = mw.language.fetchLanguageName (lang:lower(), cfg.this_wiki_code);	-- get language name if |language= is a proper code
			end
		end

		if utilities.is_set (name) then											-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, cfg.this_wiki_code);			-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if utilities.is_set (code) then											-- only 2- or 3-character codes
			name = cfg.lang_code_remap[code] or name;							-- override wikimedia when they misuse language codes/names

			if cfg.this_wiki_code ~= code then									-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					utilities.add_prop_cat ('foreign_lang_source' .. code, {name, code});	-- categorize it; code appended to allow for multiple language categorization
				else															-- or is a recognized language (but has a three-character code)
					utilities.add_prop_cat ('foreign_lang_source_2' .. code, {code});		-- categorize it differently TODO: support multiple three-character code categories per cs1|2 template
				end
			elseif cfg.local_lang_cat_enable then								-- when the language and this wiki's language are the same and categorization is enabled
				utilities.add_prop_cat ('local_lang_source', {name, code});		-- categorize it
			end
		else
			utilities.set_message ('maint_unknown_lang');						-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
 
	name = utilities.make_sep_list (#language_list, language_list);

	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[----------------------&lt; S E T _ C S 1 _ S T Y L E &gt;-------------------------

Set style settings for CS1 citation templates. Returns separator and postscript settings
At en.wiki, for cs1:
	ps gets:	'.'
	sep gets:	'.'

]]

local function set_cs1_style (ps)
	if not utilities.is_set (ps) then											-- unless explicitly set to something
		ps = cfg.presentation['ps_cs1'];										-- terminate the rendered citation
	end
	return cfg.presentation['sep_cs1'], ps;										-- element separator
end


--[[-----------------------&lt; S E T _ C S 2 _ S T Y L E &gt;------------------------

Set style settings for CS2 citation templates. Returns separator, postscript, ref settings
At en.wiki, for cs2:
	ps gets:	'' (empty string - no terminal punctuation)
	sep gets:	','

]]

local function set_cs2_style (ps, ref)
	if not utilities.is_set (ps) then											-- if |postscript= has not been set, set cs2 default
		ps = cfg.presentation['ps_cs2'];										-- terminate the rendered citation
	end
	if not utilities.is_set (ref) then											-- if |ref= is not set
		ref = &quot;harv&quot;;															-- set default |ref=harv
	end
	return cfg.presentation['sep_cs2'], ps, ref;								-- element separator
end


--[[---------&lt; G E T _ S E T T I N G S _ F R O M _ C I T E _ C L A S S &gt;--------

When |mode= is not set or when its value is invalid, use config.CitationClass and
parameter values to establish rendered style.

]]

local function get_settings_from_cite_class (ps, ref, cite_class)
	local sep;
	if (cite_class == &quot;citation&quot;) then											-- for citation templates (CS2)
		sep, ps, ref = set_cs2_style (ps, ref);
	else																		-- not a citation template so CS1
		sep, ps = set_cs1_style (ps);
	end

	return sep, ps, ref															-- return them all
end


--[[--------------------------&lt; S E T _ S T Y L E &gt;------------------------------------------------------------

Establish basic style settings to be used when rendering the citation. Uses |mode=
if set and valid or uses config.CitationClass from the template's #invoke: to establish style.

]]

local function set_style (mode, ps, ref, cite_class)
	local sep;
	if 'cs2' == mode then														-- if this template is to be rendered in CS2 (citation) style
		sep, ps, ref = set_cs2_style (ps, ref);
	elseif 'cs1' == mode then													-- if this template is to be rendered in CS1 (cite xxx) style
		sep, ps = set_cs1_style (ps);
	else																		-- anything but cs1 or cs2
		sep, ps, ref = get_settings_from_cite_class (ps, ref, cite_class);		-- get settings based on the template's CitationClass
	end

	if cfg.keywords_xlate[ps:lower()] == 'none' then							-- if assigned value is 'none' then
		ps = '';																-- set to empty string
	end
	
	return sep, ps, ref
end


--[=[-------------------------&lt; I S _ P D F &gt;-----------------------------------

Determines if a URL has the file extension that is one of the PDF file extensions
used by [[MediaWiki:Common.css]] when applying the PDF icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or
		url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
		url:match ('%.PDF&amp;#035') or url:match ('%.pdf&amp;#035');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;-----------------------

Applies CSS style to |format=, |chapter-format=, etc.  Also emits an error message
if the format parameter does not have a matching URL parameter.  If the format parameter
is not set and the URL contains a file extension that is recognized as a PDF document
by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if utilities.is_set (format) then
		format = utilities.wrap_style ('format', format);						-- add leading space, parentheses, resize
		if not utilities.is_set (url) then
			format = format .. ' ' .. utilities.set_message ( 'err_format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if URL is a PDF file then
		format = utilities.wrap_style ('format', 'PDF');						-- set format to PDF
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[---------------------&lt; G E T _ D I S P L A Y _ N A M E S &gt;------------------

Returns a number that defines the number of names displayed for author and editor
name lists and a Boolean flag to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero,
return the number and the previous state of the 'etal' flag (false by default
but may have been set to true if the name list contains some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number
that is one greater than the number of authors in the list and set the 'etal' flag true.
This will cause the list_people() to display all of the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_names (max, count, list_name, etal)
	if utilities.is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				table.insert( z.message_tail, {utilities.set_message ('err_disp_name', {cfg.special_case_translation [list_name], max}, true)});	-- add error message
				max = nil;
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, {utilities.set_message ('err_disp_name', {cfg.special_case_translation [list_name], max}, true)});		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[----------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;---------------

Adds error if |page=, |pages=, |quote-page=, |quote-pages= has what appears to be
some form of p. or pp. abbreviation in the first characters of the parameter content.

check page for extraneous p, p., pp, pp., pg, pg. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when page begins PX or P# but not Px
		      where x and X are letters and # is a digit
	bad pattern:  '^[Pp][PpGg]' matches when page begins pp, pP, Pp, PP, pg, pG, Pg, PG

]]

local function extra_text_in_page_check (page)
	local good_pattern = '^P[^%.PpGg]'; -- OK to begin with uppercase P: P7 (page 7 of section P), but not p123 (page 123)
	local bad_pattern = '^[Pp][PpGg]?%.?[ %d]';

	if not page:match (good_pattern) and (page:match (bad_pattern) or page:match ('^[Pp]ages?') or page:match ('^[Pp]gs.?')) then
		table.insert( z.message_tail, { utilities.set_message ( 'err_extra_text_pages')}); -- add error
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parentheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a placeholder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parentheses
			local name = name_table[i];
			i = i + 1;																-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parentheses
					break;														-- and done reassembling so
				end
				i = i + 1;														-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = utilities.is_wikilink (name_table[i]);		-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i + 1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled parentheses ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the Vancouver error when a required comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		first = '';																-- set to empty string for concatenation and because it may have been set for previous author/editor
		local accept_name;
		v_name, accept_name = utilities.has_accept_as_written (v_name);			-- remove accept-this-as-written markup when it wraps all of &lt;v_name&gt;

--		if v_name:match ('^%(%(.+%)%)$') then									-- corporate authors are wrapped in doubled parentheses to suppress vanc formatting and error detection
--			last = v_name:match ('^%(%((.+)%)%)$')								-- remove doubled parentheses
		if accept_name then
			last = v_name;
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error (cfg.err_msg_supl.punctuation);
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s+&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be initials or generational suffix

			if not mw.ustring.match (first, '^%u+$') then						-- mw.ustring here so that later we will catch non-Latin characters
				suffix = first;													-- not initials so assume that whatever we got is a generational suffix
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end
			last = table.concat(lastfirstTable, ' ')							-- returns a string that is the concatenation of all other names that are not initials and generational suffix
			if not utilities.is_set (last) then
				first = '';														-- unset
				last = v_name;													-- last empty because something wrong with first
				add_vanc_error (cfg.err_msg_supl.name);
			end
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error (cfg.err_msg_supl['missing comma']);				-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error (cfg.err_msg_supl.name);							-- matches a space between two initials
			end
		else
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
		
		if utilities.is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error (cfg.err_msg_supl.initials);						-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first, suffix);							-- check first and last before restoring the suffix which may have a non-Latin digit
			if utilities.is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '');
			end
		end

		link = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i ) or v_link_table[i];
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate = corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest;
|editorn= (and aliases) highest and |veditors= lowest (support for |editors= withdrawn)

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
	local lastfirst = false;
	if utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice in case we have a |first1= without a |last1=; this ...
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or		-- ... also catches the case where |first= is used with |vauthors=
		utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst = true;
	end

	if (utilities.is_set (vxxxxors) and true == lastfirst) or					-- these are the three error conditions
		(utilities.is_set (vxxxxors) and utilities.is_set (xxxxors)) or
		(true == lastfirst and utilities.is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { utilities.set_message ( 'err_redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if utilities.is_set (vxxxxors) then return 2 end;
	if utilities.is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, live, dead, etc.).  When the parameter value has not been assigned a value (missing
or empty in the source template) the function returns the value specified by ret_val.  If the parameter value is one
of the list of allowed values returns the translated value; else, emits an error message and returns the value
specified by ret_val.

]]

local function is_valid_parameter_value (value, name, possible, ret_val)
	if not utilities.is_set (value) then
		return ret_val;															-- an empty parameter is ok
	elseif utilities.in_array (value, possible) then
		return cfg.keywords_xlate[value];										-- return translation of parameter keyword
	else
		table.insert( z.message_tail, { utilities.set_message ( 'err_invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return ret_val;
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list, -3, -1) == sepc .. '. ') then					-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list, -1, -1) == sepc) or (string.sub (name_list, -3, -1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terminate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not utilities.is_set (volume) and not utilities.is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (utilities.in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if utilities.is_set (volume) and utilities.is_set (issue) then
			return wrap_msg ('vol-no', {sepc, hyphen_to_dash (volume), issue}, lower);
		elseif utilities.is_set (volume) then
			return wrap_msg ('vol', {sepc, hyphen_to_dash (volume)}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end

	if 'podcast' == cite_class and utilities.is_set (issue) then
		return wrap_msg ('issue', {sepc, issue}, lower);
	end

	local vol = '';																-- here for all cites except magazine
		
	if utilities.is_set (volume) then
		if volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$') then			-- volume value is all digits or all uppercase Roman numerals
			vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, volume});	-- render in bold face
		elseif (4 &lt; mw.ustring.len(volume)) then								-- not all digits or Roman numerals and longer than 4 characters
			vol = utilities.substitute (cfg.messages['j-vol'], {sepc, hyphen_to_dash (volume)});	-- not bold
			utilities.add_prop_cat ('long_vol');
		else																	-- four or less characters
			vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash (volume)});	-- bold
		end
	end
	if utilities.is_set (issue) then
		return vol .. utilities.substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if utilities.is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif utilities.is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if utilities.is_set (page) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return utilities.substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return utilities.substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif utilities.is_set (pages) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then							-- if pages is only digits, assume a single page number
			return '', utilities.substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', utilities.substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', utilities.substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to Wikisource, returns the label portion of the interwiki-link as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki-link to an external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, pages, at)
	local ws_url, ws_label, coins_pages, L;										-- for Wikisource interwiki-links; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if utilities.is_set (page) then
		if utilities.is_set (pages) or utilities.is_set (at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page);										-- add this page to maint cat if |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws URL from |page= interwiki link; link portion L becomes tooltip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (pages) then
		if utilities.is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages);										-- add this page to maint cat if |pages= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws URL from |pages= interwiki link; link portion L becomes tooltip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws URL from |at= interwiki link; link portion L becomes tooltip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org URLs to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot URL or to calendar pages.  When the archive URL is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the URL.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org URL does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command URL
	|archive-url= is an archive.org URL that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org URLs:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this function may return a modified
archive URL:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the URL unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.org URL
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine URL
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command URL, we don't want to allow saving of the target page 
		err_msg = cfg.err_msg_supl.save;
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = cfg.err_msg_supl.liveweb;
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');	-- split out some of the URL parts for evaluation
		
		if not utilities.is_set (timestamp) or 14 ~= timestamp:len() then		-- path and flag optional, must have 14-digit timestamp here
			err_msg = cfg.err_msg_supl.timestamp;
			if '*' ~= flag then
				url=url:gsub ('(//web%.archive%.org/[^%d]*%d?%d?%d?%d?%d?%d?)[^/]*', '%1*', 1)	-- for preview, modify ts to be yearmo* max (0-6 digits plus splat)
			end
		elseif utilities.is_set (path) and 'web/' ~= path then					-- older archive URLs do not have the extra 'web/' path element
			err_msg = cfg.err_msg_supl.path;
		elseif utilities.is_set (flag) and not utilities.is_set (path) then		-- flag not allowed with the old form URL (without the 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		elseif utilities.is_set (flag) and not flag:match ('%a%a_') then		-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		else
			return url, date;													-- return ArchiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	table.insert( z.message_tail, { utilities.set_message ( 'err_archive_url', {err_msg}, true ) } );	-- add error message and
	if utilities.is_set (Frame:preprocess('{{REVISIONID}}')) then
		return '', '';															-- return empty strings for ArchiveURL and ArchiveDate
	else
		return url, date;														-- preview mode so return ArchiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; P L A C E _ C H E C K &gt;--------------------------------------------------------

check |place=, |publication-place=, |location= to see if these params include digits.  This function added because
many editors misuse location to specify the in-source location (|page(s)= and |at= are supposed to do that)

returns the original parameter value without modification; added maint cat when parameter value contains digits

]]

local function place_check (param_val)
	if not utilities.is_set (param_val) then									-- parameter empty or omitted
		return param_val;														-- return that empty state
	end
	
	if mw.ustring.find (param_val, '%d') then									-- not empty, are there digits in the parameter value
		utilities.set_message ('maint_location');								-- yep, add maint cat
	end
	
	return param_val;															-- and done
end


--[[--------------------------&lt; I S _ G E N E R I C _ T I T L E &gt;----------------------------------------------

compares |title= value against list of known generic title patterns.  Returns true when pattern matches; nil else

the k/v pairs in 'generic_titles' each contain two tables, one for English and one for another 'local' language
Each of those tables contain another table that holds the string or pattern (whole title or title fragment) in
index [1].  index [2] is a Boolean that tells string.find() or mw.ustring.find() to do plain-text search (true)
or a pattern search (false).  The intent of all this complexity is to make these searches as fast as possible so
that we don't run out of processing time on very large articles.

]]

local function is_generic_title (title)
	title = mw.ustring.lower(title);											-- switch title to lower case
	for _, generic_title in ipairs (cfg.special_case_translation['generic_titles']) do 	-- spin through the list of known generic title fragments
		if title:find (generic_title['en'][1], 1, generic_title['en'][2]) then
			return true;														-- found English generic title so done
		elseif generic_title['local'] then										-- to keep work load down, generic_title['local'] should be nil except when there is a local version of the generic title
			if mw.ustring.find (title, generic_title['local'][1], 1, generic_title['local'][2]) then	-- mw.ustring() because might not be Latin script
				return true;													-- found local generic title so done
			end
		end
	end
end


--[[--------------------------&lt; I S _ A R C H I V E D _ C O P Y &gt;----------------------------------------------

compares |title= to 'Archived copy' (placeholder added by bots that can't find proper title); if matches, return true; nil else

]]

local function is_archived_copy (title)
	title = mw.ustring.lower(title);											-- switch title to lower case
	if title:find (cfg.special_case_translation.archived_copy.en) then			-- if title is 'Archived copy'
		return true;
	elseif cfg.special_case_translation.archived_copy['local'] then
		if mw.ustring.find (title, cfg.special_case_translation.archived_copy['local']) then	-- mw.ustring() because might not be Latin script
			return true;
		end
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args)
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper ( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

	local Mode = is_valid_parameter_value (A['Mode'], A:ORIGIN('Mode'), cfg.keywords_lists['mode'], '');

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;

	local NameListStyle = is_valid_parameter_value (A['NameListStyle'], A:ORIGIN('NameListStyle'), cfg.keywords_lists['name-list-style'], '');
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';											-- override whatever |name-list-style= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				utilities.set_message ('maint_authors');						-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if utilities.is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local Others = A['Others'];

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=
	local Editors;

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], nil, args, 'EditorList');	-- support for |editors= withdrawn
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		end
	end

	local translator_etal;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	local Translators;															-- assembled translators name list
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=

	local interviewer_etal;
	local interviewers_list = {};												
	local Interviewers;															-- used later
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters

	local contributor_etal;
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	local Contributors;															-- assembled contributors name list

	local Chapter = A['Chapter'];												-- done here so that we have access to |contribution= from |chapter= aliases
	local Chapter_origin = A:ORIGIN ('Chapter');
	local Contribution;															-- because contribution is required for contributor(s)
		if 'contribution' == A:ORIGIN ('Chapter') then
			Contribution = A['Chapter'];										-- get the name of the contribution
		end

	if utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not utilities.is_set (Contribution) then							-- |contributor= requires |contribution=
				table.insert( z.message_tail, { utilities.set_message ( 'err_contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { utilities.set_message ( 'err_contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if utilities.select_one (args, cfg.aliases['ContributorList-Last'], 'err_redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { utilities.set_message ( 'err_contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	if utilities.is_set (Others) then
		if 0 == #a and 0 == #e then												-- add maint cat when |others= has value and used without |author=, |editor=
			utilities.set_message ('maint_others');
		end
	end

	local Year = A['Year'];
	local PublicationDate = A['PublicationDate'];
	local OrigDate = A['OrigDate'];
	local Date = A['Date'];
	local LayDate = A['LayDate'];
	------------------------------------------------- Get title data
	local Title = A['Title'];
	local ScriptTitle = A['ScriptTitle'];
	local BookTitle = A['BookTitle'];
	local Conference = A['Conference'];
	local TransTitle = A['TransTitle'];
	local TransTitle_origin = A:ORIGIN ('TransTitle');
	local TitleNote = A['TitleNote'];
	local TitleLink = A['TitleLink'];

	local auto_select = ''; -- default is auto
	local accept_link;
	TitleLink, accept_link = utilities.has_accept_as_written(TitleLink, true); -- test for accept-this-as-written markup
	if (not accept_link) and utilities.in_array (TitleLink, {'none', 'pmc', 'doi'}) then -- check for special keywords
		auto_select = TitleLink; -- remember selection for later
		TitleLink = ''; -- treat as if |title-link= would have been empty
	end

	TitleLink = link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wiki-markup in |title-link= or wiki-markup in |title= when |title-link= is set

	local Section = '';															-- {{cite map}} only; preset to empty string for concatenation if not used
		if 'map' == config.CitationClass and 'section' == A:ORIGIN ('Chapter') then
			Section = A['Chapter'];												-- get |section= from |chapter= alias list; |chapter= and the other aliases not supported in {{cite map}}
			Chapter = '';														-- unset for now; will be reset later from |map= if present
		end

	local ScriptChapter = A['ScriptChapter'];
	local ScriptChapter_origin = A:ORIGIN ('ScriptChapter');
	local ChapterLink -- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local TransChapter = A['TransChapter'];
	local TransChapter_origin = A:ORIGIN ('TransChapter');
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	local Docket = A['Docket'];
	local ArchiveFormat = A['ArchiveFormat'];

	local ArchiveDate;
	local ArchiveURL;

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	
	local UrlStatus = is_valid_parameter_value (A['UrlStatus'], A:ORIGIN('UrlStatus'), cfg.keywords_lists['url-status'], '');

	local URL = A['URL']
	local URL_origin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL = A['ChapterURL'];
	local ChapterURL_origin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	local ConferenceURL_origin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL

	local Periodical = A['Periodical'];
	local Periodical_origin = '';
	if utilities.is_set (Periodical) then
		Periodical_origin = A:ORIGIN('Periodical');								-- get the name of the periodical parameter
		local i;
		Periodical, i = utilities.strip_apostrophe_markup (Periodical);			-- strip apostrophe markup so that metadata isn't contaminated 
		if i then																-- non-zero when markup was stripped so emit an error message
			table.insert( z.message_tail, {utilities.set_message ('err_apostrophe_markup', {Periodical_origin}, true)});
		end
	end

	if 'mailinglist' == config.CitationClass then								-- special case for {{cite mailing list}}
		if utilities.is_set (Periodical) and utilities.is_set (A ['MailingList']) then	-- both set emit an error
			table.insert( z.message_tail, {utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', Periodical_origin) .. ' and ' .. utilities.wrap_style ('parameter', 'mailinglist')}, true )});
		end

		Periodical = A ['MailingList'];											-- error or no, set Periodical to |mailinglist= value because this template is {{cite mailing list}}
		Periodical_origin = A:ORIGIN('MailingList');
	end

	local ScriptPeriodical = A['ScriptPeriodical'];
	local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');

	-- web and news not tested for now because of 
	-- Wikipedia:Administrators%27_noticeboard#Is_there_a_semi-automated_tool_that_could_fix_these_annoying_&quot;Cite_Web&quot;_errors?
	if not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) then	-- 'periodical' templates require periodical parameter
	--	local p = {['journal'] = 'journal', ['magazine'] = 'magazine', ['news'] = 'newspaper', ['web'] = 'website'};	-- for error message
		local p = {['journal'] = 'journal', ['magazine'] = 'magazine'};			-- for error message
		if p[config.CitationClass]  then
			table.insert( z.message_tail, {utilities.set_message ('err_missing_periodical', {config.CitationClass, p[config.CitationClass]}, true)});
		end
	end

	local TransPeriodical =  A['TransPeriodical'];
	local TransPeriodical_origin =  A:ORIGIN ('TransPeriodical');

	local Series = A['Series'];
	
	local Volume;
	local Issue;
	local Page;
	local Pages;
	local At;

	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) then
			if not utilities.in_array (Periodical_origin, {'website', 'mailinglist'}) then	-- {{citation}} does not render volume for these 'periodicals'
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		elseif utilities.is_set (ScriptPeriodical) then
			if 'script-website' ~= ScriptPeriodical_origin then					-- {{citation}} does not render volume for |script-website=
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		else
			Volume = A['Volume'];												-- and does for non-'periodical' cites
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_volume) then	-- render |volume= for cs1 according to the configuration settings
		Volume = A['Volume'];
	end	

	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) and utilities.in_array (Periodical_origin, {'journal', 'magazine', 'newspaper', 'periodical', 'work'}) or	-- {{citation}} renders issue for these 'periodicals'
			utilities.is_set (ScriptPeriodical) and utilities.in_array (ScriptPeriodical_origin, {'script-journal', 'script-magazine', 'script-newspaper', 'script-periodical', 'script-work'}) then -- and these 'script-periodicals'
				Issue = hyphen_to_dash (A['Issue']);
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_issue) then	-- conference &amp; map books do not support issue; {{citation}} listed here because included in settings table
		if not (utilities.in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical))) then
			Issue = hyphen_to_dash (A['Issue']);
		end
	end

	local Position = '';
	if not utilities.in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash (A['Pages']);	
		At = A['At'];
	end
	local QuotePage = A['QuotePage'];
	local QuotePages = hyphen_to_dash (A['QuotePages']);

	local Edition = A['Edition'];
	local PublicationPlace = place_check (A['PublicationPlace'], A:ORIGIN('PublicationPlace'));
	local Place = place_check (A['Place'], A:ORIGIN('Place'));
	
	local PublisherName = A['PublisherName'];
	local PublisherName_origin = A:ORIGIN('PublisherName');
	if utilities.is_set (PublisherName) then
		local i = 0;
		PublisherName, i = utilities.strip_apostrophe_markup (PublisherName);	-- strip apostrophe markup so that metadata isn't contaminated; publisher is never italicized
		if i then																-- non-zero when markup was stripped so emit an error message
			table.insert( z.message_tail, {utilities.set_message ('err_apostrophe_markup', {PublisherName_origin}, true)});
		end
	end

	local Newsgroup = A['Newsgroup'];											-- TODO: strip apostrophe markup?
	local Newsgroup_origin = A:ORIGIN('Newsgroup');	

	if 'newsgroup' == config.CitationClass then
		if utilities.is_set (PublisherName) then								-- general use parameter |publisher= not allowed in cite newsgroup
			local error_text, error_state = utilities.set_message ('err_parameter_ignored', {PublisherName_origin}, true);
			if utilities.is_set (error_text) then
				table.insert( z.message_tail, {error_text, error_state} );
			end				
		end

		PublisherName = nil;													-- ensure that this parameter is unset for the time being; will be used again after COinS
	end

	local UrlAccess = is_valid_parameter_value (A['UrlAccess'], A:ORIGIN('UrlAccess'), cfg.keywords_lists['url-access'], nil);
		if not utilities.is_set (URL) and utilities.is_set (UrlAccess) then
			UrlAccess = nil;
			table.insert( z.message_tail, { utilities.set_message ( 'err_param_access_requires_param', {'url'}, true ) } );
		end
		
	local ChapterUrlAccess = is_valid_parameter_value (A['ChapterUrlAccess'], A:ORIGIN('ChapterUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (ChapterURL) and utilities.is_set (ChapterUrlAccess) then
		ChapterUrlAccess = nil;
		table.insert( z.message_tail, { utilities.set_message ( 'err_param_access_requires_param', {A:ORIGIN('ChapterUrlAccess'):gsub ('%-access', '')}, true ) } );
	end

	local MapUrlAccess = is_valid_parameter_value (A['MapUrlAccess'], A:ORIGIN('MapUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (A['MapURL']) and utilities.is_set (MapUrlAccess) then
		MapUrlAccess = nil;
		table.insert( z.message_tail, { utilities.set_message ( 'err_param_access_requires_param', {'map-url'}, true ) } );
	end

	local Via = A['Via'];
	local AccessDate = A['AccessDate'];
	local Agency = A['Agency'];

	local Language = A['Language'];
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local DoiBroken = A['DoiBroken'];
	local ID = A['ID'];
	local ASINTLD = A['ASINTLD'];
	local Embargo = A['Embargo'];
	local Class = A['Class'];													-- arxiv class identifier

	local Quote = A['Quote'];
	local ScriptQuote = A['ScriptQuote'];
	local TransQuote = A['TransQuote'];
	local LayFormat = A['LayFormat'];
	local LayURL = A['LayURL'];
	local LaySource = A['LaySource'];
	local Transcript = A['Transcript'];
	local TranscriptFormat = A['TranscriptFormat'];
	local TranscriptURL = A['TranscriptURL'] 
	local TranscriptURL_origin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL

	local no_tracking_cats = is_valid_parameter_value (A['NoTracking'], A:ORIGIN('NoTracking'), cfg.keywords_lists['yes_true_y'], nil);

	-- local variables that are not cs1 parameters
	local use_lowercase;														-- controls capitalization of certain static text
	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local anchor_year;															-- used in the CITEREF identifier
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification

	local DF = is_valid_parameter_value (A['DF'], A:ORIGIN('DF'), cfg.keywords_lists['df'], '');
	if not utilities.is_set (DF) then
		DF = cfg.global_df;														-- local |df= if present overrides global df set by {{use xxx date}} template
	end

	local sepc;																	-- separator between citation elements for CS1 a period, for CS2, a comma
	local PostScript;
	local Ref = A['Ref'];
	if 'harv' == Ref then
		utilities.set_message ('maint_ref_harv');								-- add maint cat to identify templates that have this now-extraneous param value
	elseif not utilities.is_set (Ref) then
		Ref = 'harv';															-- set as default when not set externally
	end
	
	sepc, PostScript, Ref = set_style (Mode:lower(), A['PostScript'], Ref, config.CitationClass);
	use_lowercase = ( sepc == ',' ); 											-- used to control capitalization for certain static text

	-- check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not utilities.is_set (no_tracking_cats) then								-- ignore if we are already not going to categorize this page
		if utilities.in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _, v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end
																				-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	utilities.select_one (args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'err_redundant_parameters');	-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, Pages, At);

	local NoPP = is_valid_parameter_value (A['NoPP'], A:ORIGIN('NoPP'), cfg.keywords_lists['yes_true_y'], nil);

	if utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- both |publication-place= and |place= (|location=) allowed if different
		utilities.add_prop_cat ('location test');								-- add property cat to evaluate how often PublicationPlace and Place are used together
		if PublicationPlace == Place then
			Place = '';															-- unset; don't need both if they are the same
		end
	elseif not utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- when only |place= (|location=) is set ...
		PublicationPlace = Place;												-- promote |place= (|location=) to |publication-place
	end

	if PublicationPlace == Place then Place = ''; end							-- don't need both if they are the same
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia= and |title= then map |title= to |article= and |encyclopedia= to |title=
		|encyclopedia= and |article= then map |encyclopedia= to |title=

		|trans-title= maps to |trans-chapter= when |title= is re-mapped
		|url= maps to |chapter-url= when |title= is remapped
	
	All other combinations of |encyclopedia=, |title=, and |article= are not modified
	
	]]

	local Encyclopedia = A['Encyclopedia'];										-- used as a flag by this module and by ~/COinS

	if utilities.is_set (Encyclopedia) then										-- emit error message when Encyclopedia set but template is other than {{cite encyclopedia}} or {{citation}}
		if 'encyclopaedia' ~= config.CitationClass and 'citation' ~= config.CitationClass then
			table.insert (z.message_tail, {utilities.set_message ('err_parameter_ignored', {A:ORIGIN ('Encyclopedia')}, true)});
			Encyclopedia = nil;													-- unset because not supported by this template
		end
	end

	if ('encyclopaedia' == config.CitationClass) or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Periodical) and utilities.is_set (Encyclopedia) then	-- when both set emit an error
			table.insert (z.message_tail, {utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', A:ORIGIN ('Encyclopedia')) .. ' and ' .. utilities.wrap_style ('parameter', Periodical_origin)}, true )});
		end

		if utilities.is_set (Encyclopedia) then
			Periodical = Encyclopedia;											-- error or no, set Periodical to Encyclopedia; allow periodical without encyclopedia
			Periodical_origin = A:ORIGIN ('Encyclopedia');
		end

		if utilities.is_set (Periodical) then									-- Periodical is set when |encyclopedia= is set
			if utilities.is_set (Title) or utilities.is_set (ScriptTitle) then
				if not utilities.is_set (Chapter) then
					Chapter = Title;											-- |encyclopedia= and |title= are set so map |title= to |article= and |encyclopedia= to |title=
					ScriptChapter = ScriptTitle;
					ScriptChapter_origin = A:ORIGIN('ScriptTitle')
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterURL_origin = A:ORIGIN('URL')

					ChapterUrlAccess = UrlAccess;

					if not utilities.is_set (ChapterURL) and utilities.is_set (TitleLink) then
						Chapter = utilities.make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			elseif utilities.is_set (Chapter) then								-- |title= not set
				Title = Periodical;												-- |encyclopedia= set and |article= set so map |encyclopedia= to |title=
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- special case for cite techreport.
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if utilities.is_set (A['Number']) then									-- cite techreport uses 'number', which other citations alias to 'issue'
			if not utilities.is_set (ID) then									-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'id') .. ' and ' .. utilities.wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	if 'conference' == config.CitationClass then
		if utilities.is_set (BookTitle) then
			Chapter = Title;
			Chapter_origin = 'title';
	--		ChapterLink = TitleLink;											-- |chapter-link= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			URL_origin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			TransChapter_origin = TransTitle_origin;
			Title = BookTitle;
			Format = '';
	--		TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end

	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		if utilities.is_set (Chapter) then
			table.insert( z.message_tail, { utilities.set_message ( 'err_redundant_parameters', {utilities.wrap_style ('parameter', 'map') .. ' and ' .. utilities.wrap_style ('parameter', Chapter_origin)}, true ) } );	-- add error message
		end
		Chapter = A['Map'];
		Chapter_origin = A:ORIGIN('Map');
		ChapterURL = A['MapURL'];
		ChapterURL_origin = A:ORIGIN('MapURL');
		TransChapter = A['TransMap'];
		ScriptChapter = A['ScriptMap']
		ScriptChapter_origin = A:ORIGIN('ScriptMap')

		ChapterUrlAccess = MapUrlAccess;
		ChapterFormat = A['MapFormat'];

		Cartography = A['Cartography'];
		if utilities.is_set ( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if utilities.is_set ( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local SeriesLink = A['SeriesLink'];

		SeriesLink = link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wiki-markup in |series-link= or wiki-markup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if utilities.is_set (Network) then table.insert(n, Network); end
		if utilities.is_set (Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if utilities.is_set (Season) and utilities.is_set (SeriesNumber) then	-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { utilities.set_message ( 'err_redundant_parameters', {utilities.wrap_style ('parameter', 'season') .. ' and ' .. utilities.wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if utilities.is_set (Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if utilities.is_set (SeriesNumber) then table.insert(s, wrap_msg ('seriesnum', SeriesNumber, use_lowercase)); end
			if utilities.is_set (Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ScriptChapter_origin = A:ORIGIN('ScriptTitle');
			ChapterLink = TitleLink;											-- alias |episode-link=
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = A:ORIGIN('URL');
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if utilities.is_set (ChapterLink) and not utilities.is_set (ChapterURL) then	-- link but not URL
				Chapter = utilities.make_wikilink (ChapterLink, Chapter);
			elseif utilities.is_set (ChapterLink) and utilities.is_set (ChapterURL) then	-- if both are set, URL links episode;
				Series = utilities.make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if utilities.is_set (Series) and utilities.is_set (SeriesLink) then
				Series = utilities.make_wikilink (SeriesLink, Series);
			end
			Series = utilities.wrap_style ('italic-title', Series);				-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- handle type parameter for those CS1 citations that have default values
	if utilities.in_array (config.CitationClass, {&quot;AV-media-notes&quot;, &quot;interview&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if utilities.is_set (Degree) and &quot;Thesis&quot; == TitleType then				-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if utilities.is_set (TitleType) then										-- if type parameter is specified
		TitleType = utilities.substitute ( cfg.messages['type'], TitleType);	-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging

	if not utilities.is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not utilities.is_set (Date) and utilities.is_set (PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val = AccessDate, name = A:ORIGIN ('AccessDate')},
			['archive-date'] = {val = ArchiveDate, name = A:ORIGIN ('ArchiveDate')},
			['date'] = {val = Date, name = Date_origin},
			['doi-broken-date'] = {val = DoiBroken, name = A:ORIGIN ('DoiBroken')},
			['pmc-embargo-date'] = {val = Embargo, name = A:ORIGIN ('Embargo')},
			['lay-date'] = {val = LayDate, name = A:ORIGIN ('LayDate')},
			['publication-date'] = {val = PublicationDate, name = A:ORIGIN ('PublicationDate')},
			['year'] = {val = Year, name = A:ORIGIN ('Year')},
			};

		local error_list = {};
		anchor_year, Embargo = validation.dates(date_parameters_list, COinS_date, error_list);

-- start temporary Julian / Gregorian calendar uncertainty categorization
		if COinS_date.inter_cal_cat then
			utilities.add_prop_cat ('jul_greg_uncertainty');
		end
-- end temporary Julian / Gregorian calendar uncertainty categorization

		if utilities.is_set (Year) and utilities.is_set (Date) then				-- both |date= and |year= not normally needed; 
			local mismatch = validation.year_date_check (Year, Date);
			if 0 == mismatch then												-- |year= does not match a year-value in |date=
				table.insert (error_list, '&lt;code class=&quot;cs1-code&quot;&gt;&amp;#124;year= / &amp;#124;date= mismatch&lt;/code&gt;');
			elseif 1 == mismatch then											-- |year= matches year-value in |date=
				utilities.set_message ('maint_date_year');						-- add a maint cat
			end
		end
		
		if 0 == #error_list then												-- error free dates only; 0 when error_list is empty
			local modified = false;												-- flag
			
			if utilities.is_set (DF) then										-- if we need to reformat dates
				modified = validation.reformat_dates (date_parameters_list, DF);	-- reformat to DF format, use long month names if appropriate
			end

			if true == validation.date_hyphen_to_dash (date_parameters_list) then	-- convert hyphens to dashes where appropriate
				modified = true;
				utilities.set_message ('maint_date_format');					-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language,
	-- uncomment the next three lines.  Not supported by en.wiki (for obvious reasons)
	-- set validation.date_name_xlate() second argument to true to translate English digits to local digits (will translate ymd dates)
	--		if validation.date_name_xlate (date_parameters_list, false) then
	--			modified = true;
	--		end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				LayDate = date_parameters_list['lay-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end
		else
			table.insert (z.message_tail, {utilities.set_message ('err_bad_date', {utilities.make_sep_list (#error_list, error_list)}, true)});	-- add this error message
		end
	end	-- end of do

	local ID_list = {};															-- sequence table of rendered identifiers
	local ID_list_coins = {};													-- table of identifiers and their values from args; key is same as cfg.id_handlers's key
	ID_list, ID_list_coins = identifiers.identifier_lists_get (args, {DoiBroken = DoiBroken, ASINTLD = ASINTLD, Embargo = Embargo, Class = Class});

	if utilities.is_set (DoiBroken) and not ID_list_coins['DOI'] then
		table.insert (z.message_tail, {utilities.set_message ('err_doibroken_missing_doi', A:ORIGIN('DoiBroken'))});
	end

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite ssrn}}, before generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then
		if not utilities.is_set (ID_list_coins[config.CitationClass:upper()]) then 	-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp; |citeseerx= required for their templates
			table.insert (z.message_tail, {utilities.set_message ('err_' .. config.CitationClass .. '_missing', {}, true)});	-- add error message
		end

		Periodical = ({['arxiv'] = 'arXiv', ['biorxiv'] = 'bioRxiv', ['citeseerx'] = 'CiteSeerX', ['ssrn'] = 'Social Science Research Network'})[config.CitationClass];
	end

	-- Link the title of the work if no |url= was provided, but we have a |pmc= or a |doi= with |doi-access=free

	if config.CitationClass == &quot;journal&quot; and not utilities.is_set (URL) and not utilities.is_set (TitleLink) and not utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) then -- TODO: remove 'none' once existing citations have been switched to 'off', so 'none' can be used as token for &quot;no title&quot; instead
    		if 'none' ~= cfg.keywords_xlate[auto_select] then -- if auto-linking not disabled
 	 		if identifiers.auto_link_urls[auto_select] then -- manual selection
		 		URL = identifiers.auto_link_urls[auto_select]; -- set URL to be the same as identifier's external link
 				URL_origin = cfg.id_handlers[auto_select:upper()].parameters[1]; -- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['pmc'] then -- auto-select PMC
				URL = identifiers.auto_link_urls['pmc']; -- set URL to be the same as the PMC external link if not embargoed
				URL_origin = cfg.id_handlers['PMC'].parameters[1]; -- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['doi'] then -- auto-select DOI
				URL = identifiers.auto_link_urls['doi'];
				URL_origin = cfg.id_handlers['DOI'].parameters[1];
			end
 	 	end

		if utilities.is_set (URL) and utilities.is_set (AccessDate) then		-- access date requires |url=; identifier-created URL is not |url=
			table.insert( z.message_tail, { utilities.set_message ( 'err_accessdate_missing_url', {}, true ) } );	-- add an error message
			AccessDate = '';													-- unset
		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not utilities.is_set (Title) and not utilities.is_set (TransTitle) and not utilities.is_set (ScriptTitle) then	-- has special case for cite episode
		table.insert( z.message_tail, { utilities.set_message ( 'err_citation_missing_title', {'episode' == config.CitationClass and 'series' or 'title'}, true ) } );
	end

	if utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) and
			utilities.in_array (config.CitationClass, {'journal', 'citation'}) and
			(utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and
			('journal' == Periodical_origin or 'script-journal' == ScriptPeriodical_origin) then	-- special case for journal cites
				Title = '';														-- set title to empty string
				utilities.set_message ('maint_untitled');						-- add maint cat
	end

	check_for_url ({															-- add error message when any of these parameters hold a URL
		['title'] = Title,
		[A:ORIGIN('Chapter')] = Chapter,
		[Periodical_origin] = Periodical,
		[PublisherName_origin] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Chapter) and utilities.is_set (Title) and utilities.is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end

	-- this is the function call to COinS()
	local OCinSoutput = metadata.COinS({
		['Periodical'] = utilities.strip_apostrophe_markup (Periodical),		-- no markup in the metadata
		['Encyclopedia'] = Encyclopedia,										-- just a flag; content ignored by ~/COinS
		['Chapter'] = metadata.make_coins_title (coins_chapter, ScriptChapter),	-- Chapter and ScriptChapter stripped of bold / italic wiki-markup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = metadata.make_coins_title (coins_title, ScriptTitle),		-- Title and ScriptTitle stripped of bold / italic wiki-markup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Quarter'] = COinS_date.rftquarter,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = coins_pages or metadata.get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At, QuotePage, QuotePages}, 7)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName or Newsgroup,							-- any apostrophe markup already removed from PublisherName
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list_coins,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, and {{cite ssrn}} AFTER generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, CiteSeerX, or ssrn now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass and utilities.is_set (Newsgroup) then
		PublisherName = utilities.substitute (cfg.messages['newsgroup'], external_link( 'news:' .. Newsgroup, Newsgroup, Newsgroup_origin, nil ));
	end

	-- Now perform various field 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.
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	do
		local last_first_list;
		local control = { 
			format = NameListStyle,												-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_names (A['DisplayEditors'], #e, 'editors', editor_etal);
			Editors, EditorCount = list_people (control, e, editor_etal);

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum , interviewer_etal = get_display_names (A['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal);
			Interviewers = list_people (control, interviewers_list, interviewer_etal);
		end
		do																		-- now do translators
			control.maximum , translator_etal = get_display_names (A['DisplayTranslators'], #t, 'translators', translator_etal);
			Translators = list_people (control, t, translator_etal);
		end
		do																		-- now do contributors
			control.maximum , contributor_etal = get_display_names (A['DisplayContributors'], #c, 'contributors', contributor_etal);
			Contributors = list_people (control, c, contributor_etal);
		end
		do																		-- now do authors
			control.maximum , author_etal = get_display_names (A['DisplayAuthors'], #a, 'authors', author_etal);

			last_first_list = list_people(control, a, author_etal);

			if utilities.is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors');	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if utilities.is_set (Authors) and utilities.is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	-- apply |[xx-]format= styling; at the end, these parameters hold correctly styled format annotation,
	-- an error message if the associated URL is not set, or an empty string for concatenation
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not utilities.is_set (URL) then
		if utilities.in_array (config.CitationClass, {&quot;web&quot;, &quot;podcast&quot;, &quot;mailinglist&quot;}) or		-- |url= required for cite web, cite podcast, and cite mailinglist
			('citation' == config.CitationClass and ('website' == Periodical_origin or 'script-website' == ScriptPeriodical_origin)) then	-- and required for {{citation}} with |website= or |script-website=
				table.insert( z.message_tail, { utilities.set_message ( 'err_cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if utilities.is_set (AccessDate) and not utilities.is_set (ChapterURL) then		-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { utilities.set_message ( 'err_accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local OriginalURL, OriginalURL_origin, OriginalFormat, OriginalAccess;
	UrlStatus = UrlStatus:lower();												-- used later when assembling archived text
	if utilities.is_set ( ArchiveURL ) then
		if utilities.is_set (ChapterURL) then 									-- if chapter-url= is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURL_origin = ChapterURL_origin;								-- name of |chapter-url= parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=

			if 'live' ~= UrlStatus then
				ChapterURL = ArchiveURL											-- swap-in the archive's URL
				ChapterURL_origin = A:ORIGIN('ArchiveURL')						-- name of |archive-url= parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived URLs
			end
		elseif utilities.is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURL_origin = URL_origin;									-- name of URL parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;

			if 'live' ~= UrlStatus then											-- if URL set then |archive-url= applies to it
				URL = ArchiveURL												-- swap-in the archive's URL
				URL_origin = A:ORIGIN('ArchiveURL')								-- name of archive URL parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived URLs
			end
 		end
	end

	if utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) then
			local chap_param;
			if utilities.is_set (Chapter) then									-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif utilities.is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif utilities.is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif utilities.is_set (ScriptChapter) then
				chap_param = ScriptChapter_origin;
			else utilities.is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if utilities.is_set (chap_param) then								-- if we found one
				table.insert( z.message_tail, { utilities.set_message ( 'err_chapter_ignored', {chap_param}, true ) } );	-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if utilities.is_set (Contribution) and 0 &lt; #c then						-- if this is a contribution with contributor(s)
			if utilities.in_array (Contribution:lower(), cfg.keywords_lists.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, ScriptChapter_origin, Chapter, Chapter_origin, TransChapter, TransChapter_origin, ChapterURL, ChapterURL_origin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if utilities.is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and utilities.is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter .. sepc .. ' ';
		elseif utilities.is_set (ChapterFormat) then							-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title
	local plain_title = false;
	local accept_title;
	Title, accept_title = utilities.has_accept_as_written (Title, true);		-- remove accept-this-as-written markup when it wraps all of &lt;Title&gt;
	if accept_title and ('' == Title) then										-- only support forced empty for now &quot;(())&quot;
		Title = cfg.messages['notitle'];										-- replace by predefined &quot;No title&quot; message
			-- TODO: utilities.set_message ( 'err_redundant_parameters', ...);	-- issue proper error message instead of muting	 
			ScriptTitle = '';													-- just mute for now	 
			TransTitle = '';													-- just mute for now
 		plain_title = true;														-- suppress text decoration for descriptive title
		utilities.set_message ('maint_untitled');								-- add maint cat
	end

	if not accept_title then -- &lt;Title&gt; not wrapped in accept-as-written markup
		if '...' == Title:sub (-3) then											-- if ellipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%' .. sepc .. '$', '');			-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end

		if utilities.is_set (ArchiveURL) and is_archived_copy (Title) then
			utilities.set_message ('maint_archived_copy');						-- add maintenance category before we modify the content of Title
		end

		if is_generic_title (Title) then
			table.insert (z.message_tail, {utilities.set_message ( 'err_generic_title', {}, true ) } );	-- set an error message
		end
	end

	if (not plain_title) and (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) or
		('map' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)))) then		-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from module provided quote marks
			Title = utilities.wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle, 'script-title');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
			TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );
	elseif plain_title or ('report' == config.CitationClass) then								-- no styling for cite report and descriptive titles (otherwise same as above)
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = utilities.wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if utilities.is_set (TransTitle) then
		if utilities.is_set (Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. utilities.set_message ( 'err_trans_missing_title', {'title'} );
		end
	end

	if utilities.is_set (Title) then											-- TODO: is this the right place to be making Wikisource URLs?
		if utilities.is_set (TitleLink) and utilities.is_set (URL) then
			table.insert( z.message_tail, { utilities.set_message ( 'err_wikilink_in_url', {}, true ) } );	-- set an error message because we can't have both
			TitleLink = '';														-- unset
		end
	
		if not utilities.is_set (TitleLink) and utilities.is_set (URL) then
			Title = external_link (URL, Title, URL_origin, UrlAccess) .. TransTitle .. TransError .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif utilities.is_set (TitleLink) and not utilities.is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = utilities.make_wikilink (TitleLink, Title) .. TransTitle .. TransError;
			end
		else
			local ws_url, ws_label, L;											-- Title has italic or quote markup by the time we get here which causes is_wikilink() to return 0 (not a wikilink)
			ws_url, ws_label, L = wikisource_url_make (Title:gsub('^[\'&quot;]*(.-)[\'&quot;]*$', '%1'));	-- make ws URL from |title= interwiki link (strip italic or quote markup); link portion L becomes tooltip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = Title .. TransTitle .. TransError;
			end
		end
	else
		Title = TransTitle .. TransError;
	end

	if utilities.is_set (Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	if utilities.is_set (Conference) then
		if utilities.is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURL_origin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif utilities.is_set (ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURL_origin, nil );
	end

	if not utilities.is_set (Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if utilities.is_set (Minutes) then
			if utilities.is_set (Time) then
				table.insert( z.message_tail, { utilities.set_message ( 'err_redundant_parameters', {utilities.wrap_style ('parameter', 'minutes') .. ' and ' .. utilities.wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if utilities.is_set (Time) then
				local TimeCaption = A['TimeCaption']
				if not utilities.is_set (TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = utilities.is_set (At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = utilities.is_set (Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Sections = A['Sections'];											-- Section (singular) is an alias of Chapter so set earlier
		local Inset = A['Inset'];
		
		if utilities.is_set ( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if utilities.is_set ( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif utilities.is_set ( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	if utilities.is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc.
	else
		Language=&quot;&quot;;															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	Others = utilities.is_set (Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if utilities.is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if utilities.is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	TitleNote = utilities.is_set (TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if utilities.is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%n?%.?$') or Edition:match ('%f[%a][Ee]dition$') then -- Ed, ed, Ed., ed., Edn, edn, Edn., edn.
			table.insert( z.message_tail, { utilities.set_message ( 'err_extra_text_edition')}); -- add error
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = utilities.is_set (Series) and wrap_msg ('series', {sepc, Series}) or &quot;&quot;;	-- not the same as SeriesNum
	OrigDate = utilities.is_set (OrigDate) and wrap_msg ('origdate', OrigDate) or '';
	Agency = utilities.is_set (Agency) and wrap_msg ('agency', {sepc, Agency}) or &quot;&quot;;
	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	------------------------------------ totally unrelated data
	Via = utilities.is_set (Via) and  wrap_msg ('via', Via) or '';

	if utilities.is_set (AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = utilities.substitute (retrv_text, AccessDate);				-- add retrieved text

		AccessDate = utilities.substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if utilities.is_set (ID) then ID = sepc .. &quot; &quot; .. ID; end
   	if &quot;thesis&quot; == config.CitationClass and utilities.is_set (Docket) then
		ID = sepc .. &quot; Docket &quot; .. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and utilities.is_set (Docket) then		-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	if utilities.is_set (URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URL_origin, UrlAccess );
	end

	if utilities.is_set (Quote) or utilities.is_set (TransQuote) or utilities.is_set (ScriptQuote) then

		if utilities.is_set (Quote) then
			if Quote:sub(1, 1) == '&quot;' and Quote:sub(-1, -1) == '&quot;' then			-- if first and last characters of quote are quote marks
				Quote = Quote:sub(2, -2);										-- strip them off
			end
		end

		Quote = utilities.wrap_style ('quoted-text', Quote ); 	-- wrap in &lt;q&gt;...&lt;/q&gt; tags
	
		if utilities.is_set (ScriptQuote) then
			Quote = script_concatenate (Quote, ScriptQuote, 'script-quote'); -- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after quote is wrapped
		end

		if utilities.is_set (TransQuote) then
			if TransQuote:sub(1, 1) == '&quot;' and TransQuote:sub(-1, -1) == '&quot;' then -- if first and last characters of |trans-quote are quote marks
				TransQuote = TransQuote:sub(2, -2); -- strip them off
			end
			Quote = Quote .. &quot; &quot; .. utilities.wrap_style ('trans-quoted-title', TransQuote );
		end

--		if not utilities.in_array (config.CitationClass, cfg.templates_not_using_page)
		if utilities.is_set (QuotePage) or utilities.is_set (QuotePages) then	 -- add page prefix
			local quote_prefix = '';
			if utilities.is_set (QuotePage) then
				extra_text_in_page_check (QuotePage); -- add to maint cat if |quote-page= value begins with what looks like p., pp., etc.
				if not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePage}), '', '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePage}), '', '', '';
				end
			elseif utilities.is_set (QuotePages) then
				extra_text_in_page_check (QuotePages); -- add to maint cat if |quote-pages= value begins with what looks like p., pp., etc.
				if tonumber(QuotePages) ~= nil and not NoPP then				-- if only digits, assume single page
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePages}), '', '';
				elseif not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['pp-prefix'], {sepc, QuotePages}), '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePages}), '', '';
				end
			end
                        
			Quote = quote_prefix .. &quot;: &quot; .. Quote;
		else
			Quote = sepc .. &quot; &quot; .. Quote;
		end

		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	local Archived
	if utilities.is_set (ArchiveURL) then
		local arch_text;
		if not utilities.is_set (ArchiveDate) then
			ArchiveDate = utilities.set_message ('err_archive_missing_date');
		end
		if &quot;live&quot; == UrlStatus then
			arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. utilities.substitute ( cfg.messages['archived-live'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil ) .. ArchiveFormat, ArchiveDate } );
			if not utilities.is_set (OriginalURL) then
				Archived = Archived .. &quot; &quot; .. utilities.set_message ('err_archive_missing_url');							   
			end
		elseif utilities.is_set (OriginalURL) then								-- UrlStatus is empty, 'dead', 'unfit', 'usurped', 'bot: unknown'
			if utilities.in_array (UrlStatus, {'unfit', 'usurped', 'bot: unknown'}) then
				arch_text = cfg.messages['archived-unfit'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. &quot; &quot; .. arch_text .. ArchiveDate;				-- format already styled
				if 'bot: unknown' == UrlStatus then
					utilities.set_message ('maint_bot_unknown');				-- and add a category if not already added
				else
					utilities.set_message ('maint_unfit');						-- and add a category if not already added
				end
			else																-- UrlStatus is empty, 'dead'
				arch_text = cfg.messages['archived-dead'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. &quot; &quot; .. utilities.substitute ( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURL_origin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else																	-- OriginalUrl not set
			arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. utilities.substitute ( arch_text, 
				{ utilities.set_message ('err_archive_missing_url'), ArchiveDate } );
		end
	elseif utilities.is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	if utilities.is_set (LayURL) then
		if utilities.is_set (LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if utilities.is_set (LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. utilities.safe_for_italics (LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif utilities.is_set (LayFormat) then									-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	if utilities.is_set (Transcript) then
		if utilities.is_set (TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURL_origin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif utilities.is_set (TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURL_origin, nil );
	end

	local Publisher;
	if utilities.is_set (PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if utilities.is_set (PublisherName) then
		if utilities.is_set (PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif utilities.is_set (PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical)) then
		if utilities.is_set (Title) or utilities.is_set (TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		else 
			Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		end
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then									-- cite speech only
		TitleNote = &quot; (Speech)&quot;;												-- annotate the citation
		if utilities.is_set (Periodical) then									-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if utilities.is_set (Conference) then								-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;							-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
		if utilities.is_set (Others) then Others = safe_join ({Others, sepc .. &quot; &quot;}, sepc) end		-- add terminal punctuation &amp; space; check for dup sepc; TODO why do we need to do this here?
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (Periodical) then		-- special cases for book cites
		if utilities.is_set (Contributors) then									-- when we are citing foreword, preface, introduction, etc.
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if utilities.is_set (Chapter) then										-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif utilities.is_set (Periodical) then								-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local idcommon;
	if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then	-- special case for cite AV media &amp; cite episode position transcript
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, Lay, Quote }, sepc );
	else
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, Lay, Quote }, sepc );
	end
	
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	if utilities.is_set (Date) then
		if utilities.is_set (Authors) or utilities.is_set (Editors) then		-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date .. &quot;)&quot; .. OrigDate .. sepc .. &quot; &quot;;				-- in parentheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon, -1, -1) == sepc) then						-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigDate;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigDate;							-- Date begins with sepc
			end
		end
	end	
	if utilities.is_set (Authors) then
		if (not utilities.is_set (Date)) then									-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if utilities.is_set (Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then
					in_text = in_text:lower()									-- lowercase for cs2
				end
			end
			if EditorCount &lt;= 1 then
				post_text = &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot;;				-- be consistent with no-author, no-date case
			else
				post_text = &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot;;
			end
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Contributors) then									-- book cite and we're citing the intro, preface, etc.
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if utilities.is_set (Editors) and utilities.is_set (Date) then		-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not utilities.is_set (Date)) then								-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif utilities.is_set (Editors) then
		if utilities.is_set (Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if utilities.is_set (PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc ); 								-- Deals with italics, spaces, etc.
		text = text:sub(1, -sepc:len() - 1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite/&gt; element
	local options = {};
	
	if utilities.is_set (config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = string.format ('%s %s %s', 'citation', config.CitationClass, utilities.is_set (Mode) and Mode or 'cs1');	-- class=citation required for blue highlight when used with |ref=
	else
		options.class = string.format ('%s %s', 'citation', utilities.is_set (Mode) and Mode or 'cs2');
	end
	
	if utilities.is_set (Ref) and 'none' ~= cfg.keywords_xlate[Ref:lower()] then
		local id = Ref
		if ('harv' == Ref ) then
			local namelist = {};												-- holds selected contributor, author, editor name list
			local year = first_set ({Year, anchor_year}, 2);					-- Year first for legacy citations and for YMD dates that require disambiguation

			if #c &gt; 0 then														-- if there is a contributor list
				namelist = c;													-- select it
			elseif #a &gt; 0 then													-- or an author list
				namelist = a;
			elseif #e &gt; 0 then													-- or an editor list
				namelist = e;
			end
			if #namelist &gt; 0 then												-- if there are names in namelist
				id = anchor_id (namelist, year);								-- go make the CITEREF anchor
			else
				id = '';														-- unset
			end
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;(.-)&lt;/span&gt;&quot;, &quot;%1&quot;):gsub(&quot;%b&lt;&gt;&quot;, &quot;&quot;)) &lt;= 2 then	-- remove &lt;span&gt; tags and other HTML-like markup; then get length of what remains
		z.error_categories = {};
		text = utilities.set_message ('err_empty_citation');
		z.message_tail = {};
	end
	
	local render = {};															-- here we collect the final bits for concatenation into the rendered citation

	if utilities.is_set (options.id) then										-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render, utilities.substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text}));	-- when |ref= is set
	else
		table.insert (render, utilities.substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text}));	-- all other cases
	end		

	table.insert (render, utilities.substitute (cfg.presentation['ocins'], {OCinSoutput}));	-- append metadata to the citation

	if 0 ~= #z.message_tail then
		table.insert (render, ' ');
		for i,v in ipairs( z.message_tail ) do
			if utilities.is_set (v[1]) then
				if i == #z.message_tail then
					table.insert (render, utilities.error_comment ( v[1], v[2] ));
				else
					table.insert (render, utilities.error_comment ( v[1] .. &quot;; &quot;, v[2] ));
				end
			end
		end
	end

	if 0 ~= #z.maintenance_cats then
		local maint_msgs = {};													-- here we collect all of the maint messages
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			local maint = {};													-- here we assemble a maintenence message
			table.insert (maint, v);											-- maint msg is the category name
			table.insert (maint, ' (');											-- open the link text
			table.insert (maint, utilities.substitute (cfg.messages[':cat wikilink'], {v}));	-- add the link
			table.insert (maint, ')');											-- and close it
			table.insert (maint_msgs, table.concat (maint));					-- assemble new maint message and add it to the maint_msgs table
		end
		table.insert (render, utilities.substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs, ' ')));	-- wrap the group of maint message with proper presentation and save
	end
	
	if not no_tracking_cats then
		for _, v in ipairs( z.error_categories ) do								-- append error categories
			table.insert (render, utilities.substitute (cfg.messages['cat wikilink'], {v}));
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			table.insert (render, utilities.substitute (cfg.messages['cat wikilink'], {v}));
		end
		for _, v in ipairs( z.properties_cats ) do								-- append properties categories
			table.insert (render, utilities.substitute (cfg.messages['cat wikilink'], {v}));
		end
	end

	return table.concat (render);	
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class, empty)
	local name = tostring (name);
	local enum_name;															-- for enumerated parameters, is name with enumerator replaced with '#'
	local state;
	local function state_test (state, name)										-- local function to do testing of state values
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			if empty then return nil; end										-- deprecated empty parameters are treated as unknowns
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
		return nil;
	end		

	if name:find ('#') then														-- # is a cs1|2 reserved character so parameters with # not permitted
		return nil;
	end

	if utilities.in_array (cite_class, whitelist.preprint_template_list ) then	-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[name];
		if true == state_test (state, name) then return true; end

		state = whitelist.preprint_arguments[cite_class][name];					-- look in the parameter-list for the template identified by cite_class
		if true == state_test (state, name) then return true; end

																				-- limited enumerated parameters list
		enum_name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );										-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
		state = whitelist.limited_numbered_arguments[enum_name];
		if true == state_test (state, name) then return true; end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates

	if utilities.in_array (cite_class, whitelist.unique_param_template_list) then 	-- experiment for template-specific parameters for templates that accept parameters from the basic argument list
		state = whitelist.unique_arguments[cite_class][name];					-- look in the template-specific parameter-lists for the template identified by cite_class
		if true == state_test (state, name) then return true; end
	end																			-- if here, fall into general validation
		
	state = whitelist.basic_arguments[name];									-- all other templates; all normal parameters allowed
	if true == state_test (state, name) then return true; end

																				-- all enumerated parameters allowed
	enum_name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
	state = whitelist.numbered_arguments[enum_name];
	if true == state_test (state, name) then return true; end

	return false;																-- not supported because not found or name is set to nil
end


--[=[-------------------------&lt; I N T E R _ W I K I _ C H E C K &gt;----------------------------------------------

check &lt;value&gt; for inter-language interwiki-link markup.  &lt;prefix&gt; must be a MediaWiki-recognized language
code.  when these values have the form (without leading colon):
	[[&lt;prefix&gt;:link|label]] return label as plain-text
	[[&lt;prefix&gt;:link]] return &lt;prefix&gt;:link as plain-text

return value as is else

]=]

local function inter_wiki_check (parameter, value)
	local prefix = value:match ('%[%[(%a+):');									-- get an interwiki prefix if one exists
	local _;
	
	if prefix and cfg.inter_wiki_map[prefix:lower()] then						-- if prefix is in the map, needs preceding colon so
		table.insert( z.message_tail, {utilities.set_message ('err_bad_paramlink', parameter)});	-- emit an error message
		_, value, _ = utilities.is_wikilink (value);							-- extract label portion from wikilink
	end
	return value;
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe.  There are two tests made:
	{{cite ... |title=Title access-date=2016-03-17}}	-- the first parameter has a value and whitespace separates that value from the missing pipe parameter name
	{{cite ... |title=access-date=2016-03-17}}			-- the first parameter has no value (whitespace after the first = is trimmed by MediaWiki)
cs1|2 shares some parameter names with XML/HTML attributes: class=, title=, etc.  To prevent false positives XML/HTML
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (parameter, value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove XML/HTML tags because attributes: class=, title=, etc.

	capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then										-- if the capture is a valid parameter name
		table.insert( z.message_tail, {utilities.set_message ('err_missing_pipe', parameter)});
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ P U N C T &gt;--------------------------------------

look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_punc (param, value)
	if 'number' == type (param) then
		return;
	end
	
	param = param:gsub ('%d+', '#');											-- enumerated name-list mask params allow terminal punct; normalize 
	if cfg.punct_skip[param] then
		return;																	-- parameter name found in the skip table so done
	end
	
	if value:match ('[,;:]$') then
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
end


--[[--------------------------&lt; C I T A T I O N &gt;--------------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

local function citation(frame)
	Frame = frame;																-- save a copy in case we need to display an error message in preview mode
	local pframe = frame:getParent()
	local styles;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		styles = 'Module:Citation/CS1/sandbox/styles.css';
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
		styles = 'Module:Citation/CS1/styles.css';
	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the selected cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text, error_state;

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do											-- get parameters from the {{#invoke}} frame
		config[k] = v;
	--	args[k] = v;															-- crude debug support that allows us to render a citation from module {{#invoke:}}; skips parameter validation; TODO: keep?
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	local empty_unknowns = {};													-- sequence table to hold empty unknown params for error message listing
	for k, v in pairs( pframe.args ) do											-- get parameters from the parent (template) frame
		v = mw.ustring.gsub (v, '^%s*(.-)%s*$', '%1');							-- trim leading/trailing whitespace; when v is only whitespace, becomes empty string
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = utilities.set_message ( 'err_text_ignored', {v}, true );
					end
				elseif validate( k:lower(), config.CitationClass ) then 
					error_text, error_state = utilities.set_message ( 'err_parameter_ignored_suggest', {k, k:lower()}, true );	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no capture in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = utilities.substitute (param, capture);		-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text, error_state = utilities.set_message ('err_parameter_ignored_suggest', {k, param}, true);	-- set the suggestion error message
							else
								error_text, error_state = utilities.set_message ( 'err_parameter_ignored', {param}, true );	-- suggested param not supported by this template
								v = '';											-- unset
							end
						end
					end
					if not utilities.is_set (error_text) then					-- couldn't match with a pattern, is there an explicit suggestion?
						if suggestions.suggestions[ k:lower() ] ~= nil then
							error_text, error_state = utilities.set_message ( 'err_parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = utilities.set_message ( 'err_parameter_ignored', {k}, true );
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end

			args[k] = v;														-- save this parameter and its value

		elseif not utilities.is_set (v) then									-- for empty parameters
			if not validate (k, config.CitationClass, true) then				-- is this empty parameter a valid parameter
				k = ('' == k) and '(empty string)' or k;						-- when k is empty string (or was space(s) trimmed to empty string), replace with descriptive text
				table.insert (empty_unknowns, utilities.wrap_style ('parameter', k));	-- format for error message and add to the list
			end
																				-- crude debug support that allows us to render a citation from module {{#invoke:}} TODO: keep?
	--	elseif args[k] ~= nil or (k == 'postscript') then						-- when args[k] has a value from {{#invoke}} frame (we don't normally do that)
	--		args[k] = v;														-- overwrite args[k] with empty string from pframe.args[k] (template frame); v is empty string here
		end																		-- not sure about the postscript bit; that gets handled in parameter validation; historical artifact?
	end	

	if 0 ~= #empty_unknowns then												-- create empty unknown error message
		table.insert (z.message_tail, {utilities.set_message ('err_param_unknown_empty', {
			1 == #empty_unknowns and '' or 's',
			utilities.make_sep_list (#empty_unknowns, empty_unknowns)
			}, true )});
	end

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);											-- look for invisible characters
		end
		has_extraneous_punc (k, v);												-- look for extraneous terminal punctuation in parameter values
		missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?
		args[k] = inter_wiki_check (k, v);										-- when language interwiki-linked parameter missing leading colon replace with wiki-link label
	end

	return table.concat ({
		frame:extensionTag ('templatestyles', '', {src=styles}),
		citation0( config, args)
	});
end

--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {citation = citation};</text>
      <sha1>mrol5zdo98hyrm4oo4fptd61rlfao1c</sha1>
    </revision>
    <revision>
      <id>4740</id>
      <parentid>4739</parentid>
      <timestamp>2021-04-10T13:14:55Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4740</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="206230" sha1="drxm43taynzqso60mz2oj9lx8zguwgx" xml:space="preserve">
require('Module:No globals');

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
each of these counts against the Lua upvalue limit
]]

local validation;																-- functions in Module:Citation/CS1/Date_validation

local utilities;																-- functions in Module:Citation/CS1/Utilities
local z ={};																	-- table of tables in Module:Citation/CS1/Utilities

local identifiers;																-- functions and tables in Module:Citation/CS1/Identifiers
local metadata;																	-- functions in Module:Citation/CS1/COinS
local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist

--[[------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;---------------
declare variables here that have page-wide scope that are not brought in from
other modules; that are created here and used here
]]
local added_deprecated_cat;														-- Boolean flag so that the category is added only once
local added_discouraged_cat;													-- Boolean flag so that the category is added only once
local added_vanc_errs;															-- Boolean flag so we only emit one Vancouver error / category
local Frame;																	-- holds the module's frame table

--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if utilities.is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a Boolean declared in page scope variables above

]]

local function add_vanc_error (source, position)
	if added_vanc_errs then return end
		
	added_vanc_errs = true;														-- note that we've added this category
	table.insert( z.message_tail, { utilities.set_message ( 'err_vancouver', {source, position}, true ) } );
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a URI scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of TLDs: https://www.iana.org/domains/root/db

RFC 952 (modified by RFC 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the TLD.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a URL with a scheme) will be stripped
here.  Perhaps not necessary but retained in case it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ASCII characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the TLD) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and TLD or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%w]') then											-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at Wikisource
		return false;
	end

	local patterns = {															-- patterns that look like URLs
		'%f[%w][%w][%w%-]+[%w]%.%a%a+$',										-- three or more character hostname.hostname or hostname.tld
		'%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$',									-- internationalized domain name with ACE prefix
		'%f[%a][qxz]%.com$',													-- assigned one character .com hostname (x.com times out 2015-12-10)
		'%f[%a][iq]%.net$',														-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		'%f[%w][%w]%.%a%a$',													-- one character hostname and ccTLD (2 chars)
		'%f[%w][%w][%w]%.%a%a+$',												-- two character hostname and TLD
		'^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?',								-- IPv4 address
		}

	for _, pattern in ipairs (patterns) do										-- loop through the patterns list
		if domain:match (pattern) then
			return true;														-- if a match then we think that this thing that purports to be a URL is a URL
		end
	end

	for _, d in ipairs ({'cash', 'company', 'today', 'org'}) do					-- look for single letter second level domain names for these top level domains
		if domain:match ('%f[%w][%w]%.' .. d) then
			return true
		end
	end
	return false;																-- no matches, we don't know what this thing is
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a URL appear to be a valid URL; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if utilities.is_set (scheme) then											-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when URL is protocol-relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a URL into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following TLD) (if any) and any path(/), query(?) or fragment(#).

If protocol-relative URL, return nil scheme and domain else return nil for both scheme and domain.

When not protocol-relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Any URL that does not have news: scheme must have authority indicator (//).  TODO: are there other common schemes
like news: that don't use authority indicator?

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol-relative URL
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		if utilities.is_set (authority) then
			authority = authority:gsub ('//', '', 1);							-- replace place 1 pair of '/' with nothing;
			if utilities.is_set(authority) then									-- if anything left (1 or 3+ '/' where authority should be) then
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		else
			if not scheme:match ('^news:') then									-- except for news:..., MediaWiki won't link URLs that do not have authority indicator; TODO: a better way to do this test?
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link=, etc. for properly formatted content: no wikilinks, no URLs

Link parameters are to hold the title of a Wikipedia article, so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki URLs and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid URL (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid URL (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from URL; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid URL
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wiki-linked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

check &lt;link&gt; for inter-language interwiki-link prefix.  prefix must be a MediaWiki-recognized language
code and must begin with a colon.

]]

local function link_title_ok (link, lorig, title, torig)
local orig;
	if utilities.is_set (link) then 											-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		elseif link:match ('^%a+:') then										-- if the link is what looks like an interwiki
			local prefix = link:match ('^(%a+):'):lower();						-- get the interwiki prefix

			if cfg.inter_wiki_map[prefix] then									-- if prefix is in the map, must have preceding colon
				orig = lorig;													-- flag as error
			end
		end
	end

	if utilities.is_set (orig) then
		link = '';																-- unset
		table.insert( z.message_tail, { utilities.set_message ( 'err_bad_paramlink', orig)});	-- URL or wikilink in |title= with |title-link=;
	end
	
	return link;																-- link if ok, empty string else
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the URL into scheme and domain
portions, or for protocol-relative (//example.com) URLs, just the domain.  Use is_url() to validate the two
portions of the URL.  If both are valid, or for protocol-relative if domain is valid, return true, else false.

Because it is different from a standard URL, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper URL
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from URL;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a URL.  The test will also find external wikilinks
that use protocol-relative URLs. Also finds bare URLs.

The frontier pattern prevents a match on interwiki-links which are similar to scheme:path URLs.  The tests that
find bracketed URLs are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext. wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol-relative ext. wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare URL with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol-relative bare URL: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a URL
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a URL add an error message
			if utilities.is_set(error_message) then								-- once we've added the first portion of the error message ...
				error_message = error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message = error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if utilities.is_set (error_message) then									-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { utilities.set_message ( 'err_param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { utilities.set_message ( 'err_wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source, access)
	local error_str = &quot;&quot;;
	local domain;
	local path;
	local base_url;

	if not utilities.is_set ( label ) then
		label = URL;
		if utilities.is_set ( source ) then
			error_str = utilities.set_message ( 'err_bare_url_missing_title', { utilities.wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = utilities.set_message ( 'err_bad_url', {utilities.wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the URL into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['['] = '%5b', [']'] = '%5d'});			-- replace '[' and ']' with their percent-encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wiki-markup URL

	if utilities.is_set (access) then											-- access level (subscription, registration, limited)
		base_url = utilities.substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end
	
	return table.concat ({base_url, error_str});
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a Boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { utilities.set_message ( 'err_deprecated_params', {name}, true ) } );	-- add error message
	end
end


--[[--------------------------&lt; D I S C O U R A G E D _ P A R A M E T E R &gt;------------------------------------

Categorize and emit an maintenance message when the citation contains one or more discouraged parameters.  Only
one error message is emitted regardless of the number of discouraged parameters in the citation.

added_discouraged_cat is a Boolean declared in page scope variables above

]]

local function discouraged_parameter(name)
	if not added_discouraged_cat then
		added_discouraged_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { utilities.set_message ( 'maint_discouraged', {name}, true ) } );	-- add maint message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wiki-markup) are not kerned.

Replaces Unicode quote marks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc.; not for book titles.

]=]

local function kern_quotes (str)
	local cap = '';
	local cap2 = '';
	local wl_type, label, link;

	wl_type, label, link = utilities.is_wikilink (str);							-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-wl-both'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = utilities.substitute (cfg.presentation['kern-wl-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-wl-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label = mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label = mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap, cap2 = mw.ustring.match (label, &quot;^([\&quot;\'])([^\'].+)&quot;);				-- match leading double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-left'], {cap, cap2});
		end
	
		cap, cap2 = mw.ustring.match (label, &quot;^(.+[^\'])([\&quot;\'])$&quot;)				-- match trailing double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-right'], {cap, cap2});
		end
		
		if 2 == wl_type then
			str = utilities.make_wikilink (link, label);						-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin-based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate RTL languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO 639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO 639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title=, |script-chapter=, |script-&lt;periodical&gt;=

]]

local function format_script_value (script_value, script_param)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%l?%s*:') then									-- if first 3 or 4 non-space characters are script language prefix
		lang = script_value:match('^(%l%l%l?)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not utilities.is_set (lang) then
			table.insert( z.message_tail, { utilities.set_message ( 'err_script_parameter', {script_param, 'missing title part'}, true ) } );		-- prefix without 'title'; add error message
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_code_remap[lang] or mw.language.fetchLanguageName( lang, cfg.this_wiki_code );	-- get language name so that we can use it to categorize
		if utilities.is_set (name) then											-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l+%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if utilities.in_array (lang, cfg.script_lang_codes) then
				utilities.add_prop_cat ('script_with_name', {name, lang})
			else
				table.insert( z.message_tail, { utilities.set_message ( 'err_script_parameter', {script_param, 'unknown language code'}, true ) } );	-- unknown script-language; add error message
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			table.insert( z.message_tail, { utilities.set_message ( 'err_script_parameter', {script_param, 'invalid language code'}, true ) } );		-- invalid language code; add error message
			lang = '';															-- invalid so set lang to empty string
		end
	else
		table.insert( z.message_tail, { utilities.set_message ( 'err_script_parameter', {script_param, 'missing prefix'}, true ) } );				-- no language code prefix; add error message
	end
	script_value = utilities.substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is RTL

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script, script_param)
	if utilities.is_set (script) then
		script = format_script_value (script, script_param);					-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; returns empty string on error
		if utilities.is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not utilities.is_set ( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return utilities.substitute ( msg, str );								-- including template text
	else
		return utilities.substitute ( cfg.messages[key], str );
	end		
end


--[[----------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;-------------------

Makes a Wikisource URL from Wikisource interwiki-link.  Returns the URL and appropriate
label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;
	local wikisource_prefix = table.concat ({'https://', cfg.this_wiki_code, '.wikisource.org/wiki/'});

	wl_type, D, L = utilities.is_wikilink (str);								-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 1 == wl_type then													-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end

	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable URL
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent-encoding of fragment marker
	end

	return ws_url, ws_label, L or D;											-- return proper URL or nil and a label or nil
end


--[[----------------&lt; F O R M A T _ P E R I O D I C A L &gt;-----------------------

Format the three periodical parameters: |script-&lt;periodical&gt;=, |&lt;periodical&gt;=,
and |trans-&lt;periodical&gt;= into a single Periodical meta-parameter.

]]

local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)
	local periodical_error = '';

	if not utilities.is_set (periodical) then
		periodical = '';														-- to be safe for concatenation
	else
		periodical = utilities.wrap_style ('italic-title', periodical);			-- style 
	end

	periodical = script_concatenate (periodical, script_periodical, script_periodical_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (trans_periodical) then
		trans_periodical = utilities.wrap_style ('trans-italic-title', trans_periodical);
		if utilities.is_set (periodical) then
			periodical = periodical .. ' ' .. trans_periodical;
		else																	-- here when trans-periodical without periodical or script-periodical
			periodical = trans_periodical;
			periodical_error = ' ' .. utilities.set_message ('err_trans_missing_title', {'periodical'});
		end
	end

	return periodical .. periodical_error;
end


--[[------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;---------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=,
and |chapter-url= into a single chapter meta- parameter (chapter_url_source used
for error messages).

]]

local function format_chapter_title (script_chapter, script_chapter_source, chapter, chapter_source, trans_chapter, trans_chapter_source, chapter_url, chapter_url_source, no_quotes, access)
	local chapter_error = '';

	local ws_url, ws_label, L = wikisource_url_make (chapter);					-- make a wikisource URL and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', ' ');									-- replace underscore separators with space characters
		chapter = ws_label;
	end

	if not utilities.is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from module provided quote marks
			chapter = utilities.wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, script_chapter, script_chapter_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (chapter_url) then
		chapter = external_link (chapter_url, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');	-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if utilities.is_set (trans_chapter) then
		trans_chapter = utilities.wrap_style ('trans-quoted-title', trans_chapter);
		if utilities.is_set (chapter) then
			chapter = chapter .. ' ' .. trans_chapter;
		else																	-- here when trans_chapter without chapter or script-chapter
			chapter = trans_chapter;
			chapter_source = trans_chapter_source:match ('trans%-?(.+)');		-- when no chapter, get matching name from trans-&lt;param&gt;
			chapter_error = ' ' .. utilities.set_message ('err_trans_missing_title', {chapter_source});
		end
	end

	return chapter .. chapter_error;
end


--[[----------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;-------------------

This function searches a parameter's value for non-printable or invisible characters.
The search stops at the first match.

This function will detect the visible replacement character when it is part of the Wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers
(gallery, math, pre, ref) and identifies them with a slightly different error message.
See also coins_cleanup().

Output of this function is an error message that identifies the character or the
Unicode group, or the stripmarker that was detected along with its position (or,
for multi-byte characters, the position of its first byte) in the parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local stripmarker;															-- boolean set true when a stripmarker is found

	capture = string.match (v, '[%w%p ]*');										-- test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no Unicode characters
		return;
	end

	for _, invisible_char in ipairs (cfg.invisible_chars) do
		local char_name = invisible_char[1];									-- the character or group name
		local pattern = invisible_char[2];										-- the pattern used to find it
		position, _, capture = mw.ustring.find (v, pattern);					-- see if the parameter value contains characters that match the pattern
		
		if position and (cfg.invisible_defs.zwj == capture) then				-- if we found a zero-width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- it's ok if one of the Indic scripts
				position = nil;													-- unset position
			elseif cfg.emoji[mw.ustring.codepoint (v, position+1)] then			-- is zwj followed by a character listed in emoji{}?
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and utilities.in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and cfg.invisible_defs.del == capture then	-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture and not (cfg.invisible_defs.del == capture or cfg.invisible_defs.zwj == capture) then
					err_msg = capture .. ' ' .. char_name;
				else
					err_msg = char_name .. ' ' .. 'character';
				end

				table.insert (z.message_tail, {utilities.set_message ('err_invisible_char', {err_msg, utilities.wrap_style ('parameter', param), position}, true)});	-- add error message
				return;															-- and done with this parameter
			end
		end
	end
end


--[[-------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------

Argument wrapper.  This function provides support for argument mapping defined
in the configuration file so that multiple names can be transparently aliased to
single internal variable.

]]

local function argument_wrapper ( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function ( self, k )
			local dummy = self[k];												-- force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = utilities.select_one ( args, list, 'err_redundant_parameters' );
				if origin[k] == nil then
					origin[k] = '';												-- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] .. ': ' .. k);
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;-------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.
When date is DD MMMM YYYY or is MMMM DD, YYYY then wrap in nowrap span:
&lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap = '';
	local cap2 = '';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = utilities.substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = utilities.substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;---------------------

This function sets default title types (equivalent to the citation including
|type=&lt;default value&gt;) for those templates that have defaults. Also handles the
special case where it is desirable to omit the title type from the rendered citation
(|type=none).

]]

local function set_titletype (cite_class, title_type)
	if utilities.is_set (title_type) then
		if 'none' == cfg.keywords_xlate[title_type] then
			title_type = '';													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash under certain conditions.  The hyphen must separate
like items; unlike items are returned unmodified.  These forms are modified:
	letter - letter (A - B)
	digit - digit (4-5)
	digit separator digit - digit separator digit (4.1-4.5 or 4-1-4-5)
	letterdigit - letterdigit (A1-A5) (an optional separator between letter and
		digit is supported – a.1-a.5 or a-1-a-5)
	digitletter - digitletter (5a - 5d) (an optional separator between letter and
		digit is supported – 5.a-5.d or 5-a-5-d)

any other forms are returned unmodified.

str may be a comma- or semicolon-separated list

]]

local function hyphen_to_dash( str )
	if not utilities.is_set (str) then
		return str;
	end

	local accept; -- Boolean

	str = str:gsub ('&amp;[nm]dash;', {['&amp;ndash;'] = '–', ['&amp;mdash;'] = '—'});		-- replace &amp;mdash; and &amp;ndash; entities with their characters; semicolon mucks up the text.split
	str = str:gsub ('&amp;#45;', '-'); -- replace HTML numeric entity with hyphen character

	str = str:gsub ('&amp;nbsp;', ' '); -- replace &amp;nbsp; entity with generic keyboard space character
	
	local out = {};
	local list = mw.text.split (str, '%s*[,;]%s*');								-- split str at comma or semicolon separators if there are any

	for _, item in ipairs (list) do												-- for each item in the list
		item, accept = utilities.has_accept_as_written (item);					-- remove accept-this-as-written markup when it wraps all of item
		if not accept and mw.ustring.match (item, '^%w*[%.%-]?%w+%s*[%-–—]%s*%w*[%.%-]?%w+$') then	-- if a hyphenated range or has endash or emdash separators
			if item:match ('^%a+[%.%-]?%d+%s*%-%s*%a+[%.%-]?%d+$') or			-- letterdigit hyphen letterdigit (optional separator between letter and digit)
				item:match ('^%d+[%.%-]?%a+%s*%-%s*%d+[%.%-]?%a+$') or			-- digitletter hyphen digitletter (optional separator between digit and letter)
				item:match ('^%d+[%.%-]%d+%s*%-%s*%d+[%.%-]%d+$') or			-- digit separator digit hyphen digit separator digit
				item:match ('^%d+%s*%-%s*%d+$') or								-- digit hyphen digit
				item:match ('^%a+%s*%-%s*%a+$') then							-- letter hyphen letter
					item = item:gsub ('(%w*[%.%-]?%w+)%s*%-%s*(%w*[%.%-]?%w+)', '%1–%2');	-- replace hyphen, remove extraneous space characters
			else
				item = mw.ustring.gsub (item, '%s*[–—]%s*', '–');				-- for endash or emdash separated ranges, replace em with en, remove extraneous whitespace
			end
		end
		table.insert (out, item);												-- add the (possibly modified) item to the output table
	end

        local temp_str = ''; -- concatenate the output table into a comma separated string
	temp_str, accept = utilities.has_accept_as_written (table.concat (out, ', ')); -- remove accept-this-as-written markup when it wraps all of concatenated out
	if accept then
		return utilities.has_accept_as_written (str);							-- when global markup removed, return original str
	else
		return temp_str; -- else, return assembled temp_str
	end
end

--[[--------------------------&lt; S A F E _ J O I N &gt;-----------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'duplicate character'
		if 1 == #duplicate_char then											-- for single byte ASCII characters use the string library functions
			f.gsub = string.gsub
			f.match = string.match
			f.sub = string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub = mw.ustring.gsub
			f.match = mw.ustring.match
			f.sub = mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1, 1) == '&lt;' then										-- special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove HTML markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1, 1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc.?
				trim = false;
				end_chr = f.sub(str, -1, -1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr .. &quot;)&quot;				-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1, -2);									-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;''&quot; then		-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5, -1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;]]&quot; then		-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3, -1) == duplicate_char .. '&quot;]' then	-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2, -1) == duplicate_char .. &quot;]&quot; then	-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2, -1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1, -3);								-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains HTML markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows HTML markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value; 												-- add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;-----------------------------

returns true is suffix is properly formed Jr, Sr, or ordinal in the range 1–9.
Puncutation not allowed.

]]

local function is_suffix (suffix)
	if utilities.in_array (suffix, {'Jr', 'Sr', 'Jnr', 'Snr', '1st', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;-------------------

For Vancouver style, author/editor names are supposed to be rendered in Latin
(read ASCII) characters.  When a name uses characters that contain diacritical
marks, those characters are to be converted to the corresponding Latin
character. When a name is written using a non-Latin alphabet or logogram, that
name is to be transliterated into Latin characters. The module doesn't do this
so editors may/must.

This test allows |first= and |last= names to contain any of the letters defined
in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes.
	(http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;)
	or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written outside of the code editor and pasted here because the code editor
gets confused between character insertion point and cursor position. The test has
been rewritten to use decimal character escape sequence for the individual bytes
of the Unicode characters so that it is not necessary to use an external editor
to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first, suffix, position)
	if not suffix then
		if first:find ('[,%s]') then											-- when there is a space or comma, might be first name/initials + generational suffix
			first = first:match ('(.-)[,%s]+');									-- get name/initials
			suffix = first:match ('[,%s]+(.+)$');								-- get generational suffix
		end
	end
	if utilities.is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error (cfg.err_msg_supl.suffix, position);
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error (cfg.err_msg_supl['non-Latin char'], position);
			return false;														-- not a string of Latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-style=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period.
See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc.) to be rendered
as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format
because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the
Unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first, position)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just initials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error (cfg.err_msg_supl.suffix, position);			-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word

	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i], 1, 1));			-- insert the initial at end of initials table
		end
		i = i + 1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; L I S T _ P E O P L E &gt;--------------------------

Formats a list of people (authors, contributors, editors, interviewers, translators) 

names in the list will be linked when
	|&lt;name&gt;-link= has a value
	|&lt;name&gt;-mask- does NOT have a value; masked names are presumed to have been
		rendered previously so should have been linked there

when |&lt;name&gt;-mask=0, the associated name is not rendered

]]

local function list_people (control, people, etal)
	local sep;
	local namesep;
	local format = control.format;
	local maximum = control.maximum;
	local name_list = {};

	if 'vanc' == format then													-- Vancouver-like name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between names is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between names is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub (-1, -1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if utilities.is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end		-- returned 0 is for EditorCount; not used for other names
	
	for i, person in ipairs (people) do
		if utilities.is_set (person.last) then
			local mask = person.mask;
			local one;
			local sep_one = sep;

			if utilities.is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			end
			
			if mask then
				local n = tonumber (mask);										-- convert to a number if it can be converted; nil else
				if n then
					one = 0 ~= n and string.rep(&quot;&amp;mdash;&quot;, n) or nil;			-- make a string of (n &gt; 0) mdashes, nil else, to replace name
					person.link = nil;											-- don't create link to name if name is replaces with mdash string or has been set nil
				else
					one = mask;													-- replace name with mask text (must include name-list separator)
					sep_one = &quot; &quot;;												-- modify name-list separator
				end
			else
				one = person.last;												-- get surname
				local first = person.first										-- get given name
				if utilities.is_set (first) then
					if (&quot;vanc&quot; == format) then									-- if Vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first, nil, i) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials (first, i);				-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
			end
			if utilities.is_set (person.link) then
				one = utilities.make_wikilink (person.link, one);				-- link author/editor
			end
			if one then															-- if &lt;one&gt; has a value (name, mdash replacement, or mask text replacement)
				table.insert (name_list, one);									-- add it to the list of names
				table.insert (name_list, sep_one);								-- add the proper name-list separator
			end
		end
	end

	local count = #name_list / 2;												-- (number of names + number of separators) divided by 2
	if 0 &lt; count then 
		if 1 &lt; count and not etal then
			if 'amp' == format then
				name_list[#name_list-2] = &quot; &amp; &quot;;								-- replace last separator with ampersand text
			elseif 'and' == format then
				if 2 == count then
					name_list[#name_list-2] = cfg.presentation.sep_nl_and;		-- replace last separator with 'and' text
				else
					name_list[#name_list-2] = cfg.presentation.sep_nl_end;		-- replace last separator with '(sep) and' text
				end
			end
		end
		name_list[#name_list] = nil;											-- erase the last separator
	end

	local result = table.concat (name_list);									-- construct list
	if etal and utilities.is_set (result) then									-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've got a last-first list and etal so add et al.
	end
	
	return result, count;														-- return name-list string and count of number of names (count used for editor names only)
end

--[[--------------------&lt; M A K E _ C I T E R E F _ I D &gt;-----------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise
returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that
order.  year is Year or anchor_year.

]]

local function make_citeref_id (namelist, year)
	local names={};							-- a table for the one to four names and year
	for i,v in ipairs (namelist) do			-- loop through the list and take up to the first four last names
		names[i] = v.last
		if i == 4 then break end			-- if four then done
	end
	table.insert (names, year);				-- add the year at the end
	local id = table.concat(names);			-- concatenate names and year for CITEREF id
	if utilities.is_set (id) then			-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;				-- add the CITEREF portion
	else
		return '';							-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[---------------------&lt; N A M E _ H A S _ E T A L &gt;--------------------------

Evaluates the content of name parameters (author, editor, etc.) for variations on
the theme of et al.  If found, the et al. is removed, a flag is set to true and
the function returns the modified name and the flag.

This function never sets the flag to false but returns its previous state because
it may have been set by previous passes through this function or by the associated
|display-&lt;names&gt;=etal parameter

]]

local function name_has_etal (name, etal, nocat, param)

	if utilities.is_set (name) then												-- name can be nil in which case just return
		local patterns = cfg.et_al_patterns; 									-- get patterns from configuration
		
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns
			if name:match (pattern) then										-- if this 'et al' pattern is found in name
				name = name:gsub (pattern, '');									-- remove the offending text
				etal = true;													-- set flag (may have been set previously here or by |display-&lt;names&gt;=etal)
				if not nocat then												-- no categorization for |vauthors=
					table.insert( z.message_tail, {utilities.set_message ('err_etal', {param})});	-- and set an error if not added
				end
			end
		end
	end

	return name, etal;
end


--[[---------------------&lt; N A M E _ I S _ N U M E R I C &gt;----------------------

Add maint cat when name parameter value does not contain letters.  Does not catch
mixed alphanumeric names so |last=A. Green (1922-1987) does not get caught in the
current version of this test but |first=(1888) is caught.

returns nothing

]]

local function name_is_numeric (name, list_name)
	if utilities.is_set (name) then
		if mw.ustring.match (name, '^[%A]+$') then								-- when name does not contain any letters
			utilities.set_message ('maint_numeric_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
		end
	end
end


--[[-------------------&lt; N A M E _ H A S _ E D _ M A R K U P &gt;------------------

Evaluates the content of author and editor parameters for extraneous editor annotations:
ed, ed., eds, (Ed.), etc. These annotations do not belong in author parameters and
are redundant in editor parameters.  If found, the function adds the editor markup
maintenance category.

returns nothing

]]

local function name_has_ed_markup (name, list_name)
	local patterns = cfg.editor_markup_patterns;								-- get patterns from configuration

	if utilities.is_set (name) then
		for _, pattern in ipairs (patterns) do									-- spin through patterns table and
			if name:match (pattern) then
				utilities.set_message ('maint_extra_text_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
				break;
			end
		end
	end
end


--[[-----------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;------------------

Evaluates the content of last/surname (authors etc.) parameters for multiple names.
Multiple names are indicated if there is more than one comma or any &quot;unescaped&quot;
semicolons. Escaped semicolons are ones used as part of selected HTML entities.
If the condition is met, the function adds the multiple name maintenance category.

returns nothing

]]

local function name_has_mult_names (name, list_name)
	local _, commas, semicolons, nbsps;
	if utilities.is_set (name) then
		_, commas = name:gsub (',', '');										-- count the number of commas
		_, semicolons = name:gsub (';', '');									-- count the number of semicolons
		-- nbsps probably should be its own separate count rather than merged in
		-- some way with semicolons because Lua patterns do not support the
		-- grouping operator that regex does, which means there is no way to add
		-- more entities to escape except by adding more counts with the new
		-- entities
		_, nbsps = name:gsub ('&amp;nbsp;','');										-- count nbsps
		
		-- There is exactly 1 semicolon per &amp;nbsp; entity, so subtract nbsps
		-- from semicolons to 'escape' them. If additional entities are added,
		-- they also can be subtracted.
		if 1 &lt; commas or 0 &lt; (semicolons - nbsps) then
			utilities.set_message ('maint_mult_names', cfg.special_case_translation [list_name]);	-- add a maint message
		end
	end
end


--[[------------------------&lt; N A M E _ C H E C K S &gt;---------------------------

This function calls various name checking functions used to validate the content
of the various name-holding parameters.

]]

local function name_checks (last, first, list_name)
	local accept_name;

	if utilities.is_set (last) then
		last, accept_name = utilities.has_accept_as_written (last);				-- remove accept-this-as-written markup when it wraps all of &lt;last&gt;
		
		if not accept_name then													-- &lt;last&gt; not wrapped in accept-as-written markup
			name_has_mult_names (last, list_name);								-- check for multiple names in the parameter (last only)
			name_has_ed_markup (last, list_name);								-- check for extraneous 'editor' annotation
			name_is_numeric (last, list_name);									-- check for names that are composed of digits and punctuation
		end
	end

	if utilities.is_set (first) then
		first, accept_name = utilities.has_accept_as_written (first);			-- remove accept-this-as-written markup when it wraps all of &lt;first&gt;

		if not accept_name then													-- &lt;first&gt; not wrapped in accept-as-written markup
			name_has_ed_markup (first, list_name);								-- check for extraneous 'editor' annotation
			name_is_numeric (first, list_name);									-- check for names that are composed of digits and punctuation
		end
	end

	return last, first;															-- done
end


--[[----------------------&lt; E X T R A C T _ N A M E S &gt;-------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters
(or their aliases), and their matching link and mask parameters. Stops searching
when both |lastn= and |firstn= are not found in args after two sequential attempts:
found |last1=, |last2=, and |last3= but doesn't find |last4= and |last5= then the
search is done.

This function emits an error message when there is a |firstn= without a matching
|lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not
required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.'
is stripped from the parameter and a flag (etal) returned that will cause list_people()
to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps
'et al.' out of the template's metadata.  When this occurs, an error is emitted.

]]

local function extract_names(args, list_name)
	local names = {};															-- table of names
	local last;																	-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;																-- loop counter/indexer
	local n = 1;																-- output table indexer
	local count = 0;															-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal = false;															-- return value set to true when we find some form of et al. in an author parameter

	local last_alias, first_alias, link_alias;									-- selected parameter aliases used in error messaging
	while true do
		last, last_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'err_redundant_parameters', i );		-- search through args for name components beginning at 1
		first, first_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'err_redundant_parameters', i );
		link, link_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i );
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.
		last, first = name_checks (last, first, list_name);						-- multiple names, extraneous annotation, etc. checks
		
		if first and not last then												-- if there is a firstn without a matching lastn
			local alias = first_alias:find ('given', 1, true) and 'given' or 'first';	-- get first or given form of the alias
			table.insert (z.message_tail, { utilities.set_message ( 'err_first_missing_last', {
				first_alias,													-- param name of alias missing its mate
				first_alias:gsub (alias, {['first'] = 'last', ['given'] = 'surname'}),	-- make param name appropriate to the alias form
				}, true ) } );													-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			local result;
			link = link_title_ok (link, link_alias, last, last_alias);			-- check for improper wiki-markup
			if first then
				link = link_title_ok (link, link_alias, first, first_alias);	-- check for improper wiki-markup
			end

			names[n] = {last = last, first = first, link = link, mask = mask, corporate = false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { utilities.set_message ( 'err_missing_name', {list_name:match (&quot;(%w+)List&quot;):lower(), i - 1}, true ) } );	-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names and the etal flag
end


--[[---------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;----------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because
case of the source may be incorrect or different from the case that WikiMedia uses,
the name comparisons are done in lower case and when a match is found, the Wikimedia
version (assumed to be correct) is returned along with the code.  When there is no
match, we return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') returns a list of
languages that in some cases may include extensions. For example, code 'cbk-zam'
and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.  Most (all?) of these languages are not used a
'language' codes per se, rather they are used as sub-domain names: cbk-zam.wikipedia.org.
A list of language names and codes supported by fetchLanguageNames() can be found
at Template:Citation Style documentation/language/doc

Names that are included in the list will be found if that name is provided in the
|language= parameter.  For example, if |language=Chavacano de Zamboanga, that name
will be found with the associated code 'cbk-zam'.  When names are found and the
associated code is not two or three characters, this function returns only the
WikiMedia language name.

Some language names have multiple entries under different codes:
	Aromanian has code rup and code roa-rup
When this occurs, this function returns the language name and the 2- or 3-character code

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	if cfg.lang_name_remap[lang:lower()] then									-- if there is a remapped name (because MediaWiki uses something that we don't think is correct)
		return cfg.lang_name_remap[lang:lower()][1], cfg.lang_name_remap[lang:lower()][2];	-- for this language 'name', return a possibly new name and appropriate code
	end

	local ietf_code;															-- because some languages have both IETF-like codes and ISO 639-like codes
	local ietf_name;
	
	local langlc = mw.ustring.lower (lang);										-- lower-case version for comparisons

	for code, name in pairs (cfg.languages) do									-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower (name) then
			if 2 == #code or 3 == #code then									-- two- or three-character codes only; IETF extensions not supported
				return name, code;												-- so return the name and the code
			end
			ietf_code = code;													-- remember that we found an IETF-like code and save its name
			ietf_name = name;													-- but keep looking for a 2- or 3-char code
		end
	end
																				-- didn't find name with 2- or 3-char code; if IETF-like code found return
	return ietf_code and ietf_name or lang;										-- associated name; return original language text else
end


--[[-------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code
is recognized by MediaWiki, use the returned name; if not, then use the value that
was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is
assigned to the category for that code: Category:Norwegian-language sources (no).
For valid three-character code languages, the page is assigned to the single category
for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does
not recognize three-character equivalents of two-character codes: code 'ar' is
recognized but code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th
where the language names or codes are separated from each other by commas with
optional space characters.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki_name = mw.language.fetchLanguageName (cfg.this_wiki_code, cfg.this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang
		name = cfg.lang_code_remap[lang:lower()];								-- first see if this is a code that is not supported by MediaWiki but is in remap

		if name then															-- there was a remapped code so
			if not lang:match ('^%a%a%a?%-x%-%a+$') then						-- if not a private IETF tag
				lang = lang:gsub ('^(%a%a%a?)%-.*', '%1');						-- strip IETF tags from code
			end
		else
			lang = lang:gsub ('^(%a%a%a?)%-.*', '%1');							-- strip any IETF-like tags from code
			if 2 == lang:len() or 3 == lang:len() then							-- if two-or three-character code
				name = mw.language.fetchLanguageName (lang:lower(), cfg.this_wiki_code);	-- get language name if |language= is a proper code
			end
		end

		if utilities.is_set (name) then											-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, cfg.this_wiki_code);			-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if utilities.is_set (code) then											-- only 2- or 3-character codes
			name = cfg.lang_code_remap[code] or name;							-- override wikimedia when they misuse language codes/names

			if cfg.this_wiki_code ~= code then									-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					utilities.add_prop_cat ('foreign_lang_source' .. code, {name, code});	-- categorize it; code appended to allow for multiple language categorization
				else															-- or is a recognized language (but has a three-character code)
					utilities.add_prop_cat ('foreign_lang_source_2' .. code, {code});		-- categorize it differently TODO: support multiple three-character code categories per cs1|2 template
				end
			elseif cfg.local_lang_cat_enable then								-- when the language and this wiki's language are the same and categorization is enabled
				utilities.add_prop_cat ('local_lang_source', {name, code});		-- categorize it
			end
		else
			utilities.set_message ('maint_unknown_lang');						-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
 
	name = utilities.make_sep_list (#language_list, language_list);

	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end

--[[-----------------------&lt; S E T _ C S _ S T Y L E &gt;--------------------------
Gets the default CS style configuration for the given mode.
Returns default separator and either postscript as passed in or the default.
In CS1, the default postscript and separator are '.'.
In CS2, the default postscript is the empty string and the default separator is ','.
]]
local function set_cs_style (postscript, mode)
	if utilities.is_set(postscript) then
		-- emit a maintenance message if user postscript is the default cs1 postscript
		-- we catch the opposite case for cs2 in set_style
		if mode == 'cs1' and postscript == cfg.presentation['ps_' .. mode] then
			utilities.set_message ('maint_postscript');
		end
	else
		postscript = cfg.presentation['ps_' .. mode];
	end
	return cfg.presentation['sep_' .. mode], postscript;
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;-----------------------------
Sets the separator and postscript styles. Checks the |mode= first and the
#invoke CitationClass second. Removes the postscript if postscript == none.
]]
local function set_style (mode, postscript, cite_class)
	local sep;
	if 'cs2' == mode then
		sep, postscript = set_cs_style (postscript, 'cs2');
	elseif 'cs1' == mode then
		sep, postscript = set_cs_style (postscript, 'cs1');
	elseif 'citation' == cite_class	then
		sep, postscript = set_cs_style (postscript, 'cs2');
	else
		sep, postscript = set_cs_style (postscript, 'cs1');
	end

	if cfg.keywords_xlate[postscript:lower()] == 'none' then
		-- emit a maintenance message if user postscript is the default cs2 postscript
		-- we catch the opposite case for cs1 in set_cs_style
		if 'cs2' == mode or 'citation' == cite_class then
			utilities.set_message ('maint_postscript');
		end
		postscript = '';
	end
	
	return sep, postscript
end

--[=[-------------------------&lt; I S _ P D F &gt;-----------------------------------

Determines if a URL has the file extension that is one of the PDF file extensions
used by [[MediaWiki:Common.css]] when applying the PDF icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or
		url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
		url:match ('%.PDF&amp;#035') or url:match ('%.pdf&amp;#035');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;-----------------------

Applies CSS style to |format=, |chapter-format=, etc.  Also emits an error message
if the format parameter does not have a matching URL parameter.  If the format parameter
is not set and the URL contains a file extension that is recognized as a PDF document
by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if utilities.is_set (format) then
		format = utilities.wrap_style ('format', format);						-- add leading space, parentheses, resize
		if not utilities.is_set (url) then
			format = format .. ' ' .. utilities.set_message ( 'err_format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if URL is a PDF file then
		format = utilities.wrap_style ('format', 'PDF');						-- set format to PDF
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[---------------------&lt; G E T _ D I S P L A Y _ N A M E S &gt;------------------

Returns a number that defines the number of names displayed for author and editor
name lists and a Boolean flag to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero,
return the number and the previous state of the 'etal' flag (false by default
but may have been set to true if the name list contains some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number
that is one greater than the number of authors in the list and set the 'etal' flag true.
This will cause the list_people() to display all of the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_names (max, count, list_name, etal, param)
	if utilities.is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				table.insert( z.message_tail, {utilities.set_message ('err_disp_name', {param, max}, true)});	-- add error message
				max = nil;
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, {utilities.set_message ('err_disp_name', {param, max}, true)});		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[----------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;---------------

Adds error if |page=, |pages=, |quote-page=, |quote-pages= has what appears to be
some form of p. or pp. abbreviation in the first characters of the parameter content.

check page for extraneous p, p., pp, pp., pg, pg. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when page begins PX or P# but not Px
		      where x and X are letters and # is a digit
	bad pattern:  '^[Pp][PpGg]' matches when page begins pp, pP, Pp, PP, pg, pG, Pg, PG

]]

local function extra_text_in_page_check (val, name)
	if not val:match (cfg.vol_iss_pg_patterns.good_ppattern) then
		for _, pattern in ipairs (cfg.vol_iss_pg_patterns.bad_ppatterns) do		-- spin through the selected sequence table of patterns
			if val:match (pattern) then											-- when a match, error so
				table.insert (z.message_tail, {utilities.set_message ('err_extra_text_pages', {name}, true)}); -- add error message
				return;															-- and done
			end
		end
	end		
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ V O L _ I S S _ C H E C K &gt;------------------------

Adds error if |volume= or |issue= has what appears to be some form of redundant 'type' indicator.

For |volume=:
	'V.', or 'Vol.' (with or without the dot) abbreviations or 'Volume' in the first characters of the parameter
	content (all case insensitive). 'V' and 'v' (without the dot) are presumed to be roman numerals so
	are allowed.

For |issue=:
	'No.', 'I.', 'Iss.' (with or without the dot) abbreviations, or 'Issue' in the first characters of the
	parameter content (all case insensitive).
	
Single character values ('v', 'i', 'n') allowed when not followed by separator character ('.', ':', '=', or
whitespace character) – param values are trimmed of whitespace by MediaWiki before delivered to the module.
	
&lt;val&gt; is |volume= or |issue= parameter value
&lt;name&gt; is |volume= or |issue= parameter name for error message
&lt;selector&gt; is 'v' for |volume=, 'i' for |issue=

sets error message on failure; returns nothing

]]

local function extra_text_in_vol_iss_check (val, name, selector)
	if not utilities.is_set (val) then
		return;
	end
	
	local patterns = 'v' == selector and cfg.vol_iss_pg_patterns.vpatterns or cfg.vol_iss_pg_patterns.ipatterns;

	local handler = 'v' == selector and 'err_extra_text_volume' or 'err_extra_text_issue';
	val = val:lower();															-- force parameter value to lower case
	for _, pattern in ipairs (patterns) do										-- spin through the selected sequence table of patterns
		if val:match (pattern) then												-- when a match, error so
			table.insert (z.message_tail, {utilities.set_message (handler, {name}, true)}); -- add error message
			return;																-- and done
		end
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parentheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a placeholder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parentheses
			local name = name_table[i];
			i = i + 1;															-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parentheses
					break;														-- and done reassembling so
				end
				i = i + 1;														-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = utilities.is_wikilink (name_table[i]);		-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i + 1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled parentheses ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the Vancouver error when a required comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		first = '';																-- set to empty string for concatenation and because it may have been set for previous author/editor
		local accept_name;
		v_name, accept_name = utilities.has_accept_as_written (v_name);			-- remove accept-this-as-written markup when it wraps all of &lt;v_name&gt;

		if accept_name then
			last = v_name;
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error (cfg.err_msg_supl.punctuation, i);
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s+&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be initials or generational suffix

			if not mw.ustring.match (first, '^%u+$') then						-- mw.ustring here so that later we will catch non-Latin characters
				suffix = first;													-- not initials so assume that whatever we got is a generational suffix
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end
			last = table.concat(lastfirstTable, ' ')							-- returns a string that is the concatenation of all other names that are not initials and generational suffix
			if not utilities.is_set (last) then
				first = '';														-- unset
				last = v_name;													-- last empty because something wrong with first
				add_vanc_error (cfg.err_msg_supl.name, i);
			end
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error (cfg.err_msg_supl['missing comma'], i);			-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- matches a space between two initials
			end
		else
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
		
		if utilities.is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first, suffix, i);							-- check first and last before restoring the suffix which may have a non-Latin digit
			if utilities.is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '', nil, i);
			end
		end

		link = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i ) or v_link_table[i];
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate = corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest;
|editorn= (and aliases) highest and |veditors= lowest (support for |editors= withdrawn)

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
	local lastfirst = false;
	if utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice in case we have a |first1= without a |last1=; this ...
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or		-- ... also catches the case where |first= is used with |vauthors=
		utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst = true;
	end

	if (utilities.is_set (vxxxxors) and true == lastfirst) or					-- these are the three error conditions
		(utilities.is_set (vxxxxors) and utilities.is_set (xxxxors)) or
		(true == lastfirst and utilities.is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { utilities.set_message ( 'err_redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if utilities.is_set (vxxxxors) then return 2 end;
	if utilities.is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, live, dead, etc.).  When the parameter value has not been assigned a value (missing
or empty in the source template) the function returns the value specified by ret_val.  If the parameter value is one
of the list of allowed values returns the translated value; else, emits an error message and returns the value
specified by ret_val.

]]

local function is_valid_parameter_value (value, name, possible, ret_val)
	if not utilities.is_set (value) then
		return ret_val;															-- an empty parameter is ok
	elseif utilities.in_array (value, possible) then
		return cfg.keywords_xlate[value];										-- return translation of parameter keyword
	else
		table.insert( z.message_tail, { utilities.set_message ( 'err_invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return ret_val;
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list, -3, -1) == sepc .. '. ') then					-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list, -1, -1) == sepc) or (string.sub (name_list, -3, -1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terminate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not utilities.is_set (volume) and not utilities.is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (utilities.in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if utilities.is_set (volume) and utilities.is_set (issue) then
			return wrap_msg ('vol-no', {sepc, hyphen_to_dash (volume), issue}, lower);
		elseif utilities.is_set (volume) then
			return wrap_msg ('vol', {sepc, hyphen_to_dash (volume)}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end

	if 'podcast' == cite_class and utilities.is_set (issue) then
		return wrap_msg ('issue', {sepc, issue}, lower);
	end

	local vol = '';																-- here for all cites except magazine
		
	if utilities.is_set (volume) then
		if volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$') then			-- volume value is all digits or all uppercase Roman numerals
			vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, volume});	-- render in bold face
		elseif (4 &lt; mw.ustring.len(volume)) then								-- not all digits or Roman numerals and longer than 4 characters
			vol = utilities.substitute (cfg.messages['j-vol'], {sepc, hyphen_to_dash (volume)});	-- not bold
			utilities.add_prop_cat ('long_vol');
		else																	-- four or less characters
			vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash (volume)});	-- bold
		end
	end
	if utilities.is_set (issue) then
		return vol .. utilities.substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if utilities.is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif utilities.is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if utilities.is_set (page) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return utilities.substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return utilities.substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif utilities.is_set (pages) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then							-- if pages is only digits, assume a single page number
			return '', utilities.substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', utilities.substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', utilities.substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to Wikisource, returns the label portion of the interwiki-link as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki-link to an external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, page_orig, pages, pages_orig, at)
	local ws_url, ws_label, coins_pages, L;										-- for Wikisource interwiki-links; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if utilities.is_set (page) then
		if utilities.is_set (pages) or utilities.is_set (at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page, page_orig);								-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws URL from |page= interwiki link; link portion L becomes tooltip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (pages) then
		if utilities.is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages, pages_orig);							-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws URL from |pages= interwiki link; link portion L becomes tooltip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws URL from |at= interwiki link; link portion L becomes tooltip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end

--[[--------------------------&lt; I S _ U N I Q U E _ A R C H I V E _ U R L &gt;------------------------------------

add error message when |archive-url= value is same as |url= or chapter-url= (or alias...) value

]]

local function is_unique_archive_url (archive, url, c_url, source, date)
	if utilities.is_set (archive) then
		if archive == url or archive == c_url then
			table.insert (z.message_tail, {utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)}, true)});	-- add error message
			return '', '';														-- unset |archive-url= and |archive-date= because same as |url= or |chapter-url=
		end
	end

	return archive, date;
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org URLs to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot URL or to calendar pages.  When the archive URL is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the URL.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org URL does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command URL
	|archive-url= is an archive.org URL that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org URLs:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this function may return a modified
archive URL:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the URL unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.org URL
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine URL
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command URL, we don't want to allow saving of the target page 
		err_msg = cfg.err_msg_supl.save;
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = cfg.err_msg_supl.liveweb;
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');	-- split out some of the URL parts for evaluation
		
		if not utilities.is_set (timestamp) or 14 ~= timestamp:len() then		-- path and flag optional, must have 14-digit timestamp here
			err_msg = cfg.err_msg_supl.timestamp;
			if '*' ~= flag then
				url=url:gsub ('(//web%.archive%.org/[^%d]*%d?%d?%d?%d?%d?%d?)[^/]*', '%1*', 1)	-- for preview, modify ts to be yearmo* max (0-6 digits plus splat)
			end
		elseif utilities.is_set (path) and 'web/' ~= path then					-- older archive URLs do not have the extra 'web/' path element
			err_msg = cfg.err_msg_supl.path;
		elseif utilities.is_set (flag) and not utilities.is_set (path) then		-- flag not allowed with the old form URL (without the 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		elseif utilities.is_set (flag) and not flag:match ('%a%a_') then		-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		else
			return url, date;													-- return ArchiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	table.insert( z.message_tail, { utilities.set_message ( 'err_archive_url', {err_msg}, true ) } );	-- add error message and
	if utilities.is_set (Frame:preprocess('{{REVISIONID}}')) then
		return '', '';															-- return empty strings for ArchiveURL and ArchiveDate
	else
		return url, date;														-- preview mode so return ArchiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; P L A C E _ C H E C K &gt;--------------------------------------------------------

check |place=, |publication-place=, |location= to see if these params include digits.  This function added because
many editors misuse location to specify the in-source location (|page(s)= and |at= are supposed to do that)

returns the original parameter value without modification; added maint cat when parameter value contains digits

]]

local function place_check (param_val)
	if not utilities.is_set (param_val) then									-- parameter empty or omitted
		return param_val;														-- return that empty state
	end
	
	if mw.ustring.find (param_val, '%d') then									-- not empty, are there digits in the parameter value
		utilities.set_message ('maint_location');								-- yep, add maint cat
	end
	
	return param_val;															-- and done
end


--[[--------------------------&lt; I S _ G E N E R I C _ T I T L E &gt;----------------------------------------------

compares |title= value against list of known generic title patterns.  Returns true when pattern matches; nil else

the k/v pairs in 'generic_titles' each contain two tables, one for English and one for another 'local' language
Each of those tables contain another table that holds the string or pattern (whole title or title fragment) in
index [1].  index [2] is a Boolean that tells string.find() or mw.ustring.find() to do plain-text search (true)
or a pattern search (false).  The intent of all this complexity is to make these searches as fast as possible so
that we don't run out of processing time on very large articles.

]]

local function is_generic_title (title)
	title = mw.ustring.lower(title);											-- switch title to lower case
	for _, generic_title in ipairs (cfg.special_case_translation['generic_titles']) do 	-- spin through the list of known generic title fragments
		if title:find (generic_title['en'][1], 1, generic_title['en'][2]) then
			return true;														-- found English generic title so done
		elseif generic_title['local'] then										-- to keep work load down, generic_title['local'] should be nil except when there is a local version of the generic title
			if mw.ustring.find (title, generic_title['local'][1], 1, generic_title['local'][2]) then	-- mw.ustring() because might not be Latin script
				return true;													-- found local generic title so done
			end
		end
	end
end


--[[--------------------------&lt; I S _ A R C H I V E D _ C O P Y &gt;----------------------------------------------

compares |title= to 'Archived copy' (placeholder added by bots that can't find proper title); if matches, return true; nil else

]]

local function is_archived_copy (title)
	title = mw.ustring.lower(title);											-- switch title to lower case
	if title:find (cfg.special_case_translation.archived_copy.en) then			-- if title is 'Archived copy'
		return true;
	elseif cfg.special_case_translation.archived_copy['local'] then
		if mw.ustring.find (title, cfg.special_case_translation.archived_copy['local']) then	-- mw.ustring() because might not be Latin script
			return true;
		end
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args )
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper ( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListStyle = is_valid_parameter_value (A['NameListStyle'], A:ORIGIN('NameListStyle'), cfg.keywords_lists['name-list-style'], '');
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				utilities.set_message ('maint_authors');						-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if utilities.is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], nil, args, 'EditorList');	-- support for |editors= withdrawn
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		end
	end
							
	local Chapter = A['Chapter'];												-- done here so that we have access to |contribution= from |chapter= aliases
	local Chapter_origin = A:ORIGIN ('Chapter');
	local Contribution;															-- because contribution is required for contributor(s)
		if 'contribution' == Chapter_origin then
			Contribution = Chapter;												-- get the name of the contribution
		end
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	
	if utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not utilities.is_set (Contribution) then							-- |contributor= requires |contribution=
				table.insert( z.message_tail, { utilities.set_message ( 'err_contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { utilities.set_message ( 'err_contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if utilities.select_one (args, cfg.aliases['ContributorList-Last'], 'err_redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { utilities.set_message ( 'err_contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	local Title = A['Title'];
	local TitleLink = A['TitleLink'];

	local auto_select = ''; -- default is auto
	local accept_link;
	TitleLink, accept_link = utilities.has_accept_as_written(TitleLink, true);	-- test for accept-this-as-written markup
	if (not accept_link) and utilities.in_array (TitleLink, {'none', 'pmc', 'doi'}) then -- check for special keywords
		auto_select = TitleLink;												-- remember selection for later
		TitleLink = '';															-- treat as if |title-link= would have been empty
	end

	TitleLink = link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wiki-markup in |title-link= or wiki-markup in |title= when |title-link= is set

	local Section = '';															-- {{cite map}} only; preset to empty string for concatenation if not used
	if 'map' == config.CitationClass and 'section' == Chapter_origin then
		Section = A['Chapter'];													-- get |section= from |chapter= alias list; |chapter= and the other aliases not supported in {{cite map}}
		Chapter = '';															-- unset for now; will be reset later from |map= if present
	end

	local Periodical = A['Periodical'];
	local Periodical_origin = '';
	if utilities.is_set (Periodical) then
		Periodical_origin = A:ORIGIN('Periodical');								-- get the name of the periodical parameter
		local i;
		Periodical, i = utilities.strip_apostrophe_markup (Periodical);			-- strip apostrophe markup so that metadata isn't contaminated 
		if i then																-- non-zero when markup was stripped so emit an error message
			table.insert( z.message_tail, {utilities.set_message ('err_apostrophe_markup', {Periodical_origin}, true)});
		end
	end

	if 'mailinglist' == config.CitationClass then								-- special case for {{cite mailing list}}
		if utilities.is_set (Periodical) and utilities.is_set (A ['MailingList']) then	-- both set emit an error
			table.insert( z.message_tail, {utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', Periodical_origin) .. ' and ' .. utilities.wrap_style ('parameter', 'mailinglist')}, true )});
		end

		Periodical = A ['MailingList'];											-- error or no, set Periodical to |mailinglist= value because this template is {{cite mailing list}}
		Periodical_origin = A:ORIGIN('MailingList');
	end

	local ScriptPeriodical = A['ScriptPeriodical'];

	-- web and news not tested for now because of 
	-- Wikipedia:Administrators%27_noticeboard#Is_there_a_semi-automated_tool_that_could_fix_these_annoying_&quot;Cite_Web&quot;_errors?
	if not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) then	-- 'periodical' templates require periodical parameter
	--	local p = {['journal'] = 'journal', ['magazine'] = 'magazine', ['news'] = 'newspaper', ['web'] = 'website'};	-- for error message
		local p = {['journal'] = 'journal', ['magazine'] = 'magazine'};			-- for error message
		if p[config.CitationClass]  then
			table.insert( z.message_tail, {utilities.set_message ('err_missing_periodical', {config.CitationClass, p[config.CitationClass]}, true)});
		end
	end
	
	local Volume;
	local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) then
			if not utilities.in_array (Periodical_origin, {'website', 'mailinglist'}) then	-- {{citation}} does not render volume for these 'periodicals'
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		elseif utilities.is_set (ScriptPeriodical) then
			if 'script-website' ~= ScriptPeriodical_origin then					-- {{citation}} does not render volume for |script-website=
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		else
			Volume = A['Volume'];												-- and does for non-'periodical' cites
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_volume) then	-- render |volume= for cs1 according to the configuration settings
		Volume = A['Volume'];
	end	
	extra_text_in_vol_iss_check (Volume, A:ORIGIN ('Volume'), 'v');	

	local Issue;
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) and utilities.in_array (Periodical_origin, {'journal', 'magazine', 'newspaper', 'periodical', 'work'}) or	-- {{citation}} renders issue for these 'periodicals'
			utilities.is_set (ScriptPeriodical) and utilities.in_array (ScriptPeriodical_origin, {'script-journal', 'script-magazine', 'script-newspaper', 'script-periodical', 'script-work'}) then -- and these 'script-periodicals'
				Issue = hyphen_to_dash (A['Issue']);
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_issue) then	-- conference &amp; map books do not support issue; {{citation}} listed here because included in settings table
		if not (utilities.in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical))) then
			Issue = hyphen_to_dash (A['Issue']);
		end
	end
	extra_text_in_vol_iss_check (Issue, A:ORIGIN ('Issue'), 'i');	

	local Page;
	local Pages;
	local At;
	if not utilities.in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash (A['Pages']);	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = place_check (A['PublicationPlace'], A:ORIGIN('PublicationPlace'));
	local Place = place_check (A['Place'], A:ORIGIN('Place'));
	
	local PublisherName = A['PublisherName'];
	local PublisherName_origin = A:ORIGIN('PublisherName');
	if utilities.is_set (PublisherName) then
		local i = 0;
		PublisherName, i = utilities.strip_apostrophe_markup (PublisherName);	-- strip apostrophe markup so that metadata isn't contaminated; publisher is never italicized
		if i then																-- non-zero when markup was stripped so emit an error message
			table.insert( z.message_tail, {utilities.set_message ('err_apostrophe_markup', {PublisherName_origin}, true)});
		end
	end

	local Newsgroup = A['Newsgroup'];											-- TODO: strip apostrophe markup?
	local Newsgroup_origin = A:ORIGIN('Newsgroup');	

	if 'newsgroup' == config.CitationClass then
		if utilities.is_set (PublisherName) then								-- general use parameter |publisher= not allowed in cite newsgroup
			local error_text, error_state = utilities.set_message ('err_parameter_ignored', {PublisherName_origin}, true);
			if utilities.is_set (error_text) then
				table.insert( z.message_tail, {error_text, error_state} );
			end				
		end

		PublisherName = nil;													-- ensure that this parameter is unset for the time being; will be used again after COinS
	end

	local URL = A['URL']
	local UrlAccess = is_valid_parameter_value (A['UrlAccess'], A:ORIGIN('UrlAccess'), cfg.keywords_lists['url-access'], nil);
	
	if not utilities.is_set (URL) and utilities.is_set (UrlAccess) then
		UrlAccess = nil;
		table.insert( z.message_tail, { utilities.set_message ( 'err_param_access_requires_param', {'url'}, true ) } );
	end
	
	local ChapterURL = A['ChapterURL'];
	local ChapterUrlAccess = is_valid_parameter_value (A['ChapterUrlAccess'], A:ORIGIN('ChapterUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (ChapterURL) and utilities.is_set (ChapterUrlAccess) then
		ChapterUrlAccess = nil;
		table.insert( z.message_tail, { utilities.set_message ( 'err_param_access_requires_param', {A:ORIGIN('ChapterUrlAccess'):gsub ('%-access', '')}, true ) } );
	end

	local MapUrlAccess = is_valid_parameter_value (A['MapUrlAccess'], A:ORIGIN('MapUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (A['MapURL']) and utilities.is_set (MapUrlAccess) then
		MapUrlAccess = nil;
		table.insert( z.message_tail, { utilities.set_message ( 'err_param_access_requires_param', {'map-url'}, true ) } );
	end

	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local no_tracking_cats = is_valid_parameter_value (A['NoTracking'], A:ORIGIN('NoTracking'), cfg.keywords_lists['yes_true_y'], nil);

	-- check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not utilities.is_set (no_tracking_cats) then								-- ignore if we are already not going to categorize this page
		if utilities.in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _, v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end
																				-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	utilities.select_one (args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'err_redundant_parameters');	-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, A:ORIGIN('Page'), Pages, A:ORIGIN('Pages'), At);

	local NoPP = is_valid_parameter_value (A['NoPP'], A:ORIGIN('NoPP'), cfg.keywords_lists['yes_true_y'], nil);

	if utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- both |publication-place= and |place= (|location=) allowed if different
		utilities.add_prop_cat ('location test');								-- add property cat to evaluate how often PublicationPlace and Place are used together
		if PublicationPlace == Place then
			Place = '';															-- unset; don't need both if they are the same
		end
	elseif not utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- when only |place= (|location=) is set ...
		PublicationPlace = Place;												-- promote |place= (|location=) to |publication-place
	end

	if PublicationPlace == Place then Place = ''; end							-- don't need both if they are the same
	
	local URL_origin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL_origin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ScriptChapter = A['ScriptChapter'];
	local ScriptChapter_origin = A:ORIGIN ('ScriptChapter');
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local TransChapter = A['TransChapter'];
	local TransChapter_origin = A:ORIGIN ('TransChapter');
	local TransTitle = A['TransTitle'];
	local ScriptTitle = A['ScriptTitle'];
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia= and |title= then map |title= to |article= and |encyclopedia= to |title=
		|encyclopedia= and |article= then map |encyclopedia= to |title=

		|trans-title= maps to |trans-chapter= when |title= is re-mapped
		|url= maps to |chapter-url= when |title= is remapped
	
	All other combinations of |encyclopedia=, |title=, and |article= are not modified
	
	]]

	local Encyclopedia = A['Encyclopedia'];										-- used as a flag by this module and by ~/COinS

	if utilities.is_set (Encyclopedia) then										-- emit error message when Encyclopedia set but template is other than {{cite encyclopedia}} or {{citation}}
		if 'encyclopaedia' ~= config.CitationClass and 'citation' ~= config.CitationClass then
			table.insert (z.message_tail, {utilities.set_message ('err_parameter_ignored', {A:ORIGIN ('Encyclopedia')}, true)});
			Encyclopedia = nil;													-- unset because not supported by this template
		end
	end

	if ('encyclopaedia' == config.CitationClass) or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Periodical) and utilities.is_set (Encyclopedia) then	-- when both set emit an error
			table.insert (z.message_tail, {utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', A:ORIGIN ('Encyclopedia')) .. ' and ' .. utilities.wrap_style ('parameter', Periodical_origin)}, true )});
		end

		if utilities.is_set (Encyclopedia) then
			Periodical = Encyclopedia;											-- error or no, set Periodical to Encyclopedia; allow periodical without encyclopedia
			Periodical_origin = A:ORIGIN ('Encyclopedia');
		end

		if utilities.is_set (Periodical) then									-- Periodical is set when |encyclopedia= is set
			if utilities.is_set (Title) or utilities.is_set (ScriptTitle) then
				if not utilities.is_set (Chapter) then
					Chapter = Title;											-- |encyclopedia= and |title= are set so map |title= to |article= and |encyclopedia= to |title=
					ScriptChapter = ScriptTitle;
					ScriptChapter_origin = A:ORIGIN('ScriptTitle')
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterURL_origin = URL_origin;

					ChapterUrlAccess = UrlAccess;

					if not utilities.is_set (ChapterURL) and utilities.is_set (TitleLink) then
						Chapter = utilities.make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			elseif utilities.is_set (Chapter) then								-- |title= not set
				Title = Periodical;												-- |encyclopedia= set and |article= set so map |encyclopedia= to |title=
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- special case for cite techreport.
	local ID = A['ID'];
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if utilities.is_set (A['Number']) then									-- cite techreport uses 'number', which other citations alias to 'issue'
			if not utilities.is_set (ID) then									-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'id') .. ' and ' .. utilities.wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	local ChapterLink -- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local Conference = A['Conference'];
	local BookTitle = A['BookTitle'];
	local TransTitle_origin = A:ORIGIN ('TransTitle');
	if 'conference' == config.CitationClass then
		if utilities.is_set (BookTitle) then
			Chapter = Title;
			Chapter_origin = 'title';
	--		ChapterLink = TitleLink;											-- |chapter-link= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			URL_origin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			TransChapter_origin = TransTitle_origin;
			Title = BookTitle;
			Format = '';
	--		TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end
	
	-- CS1/2 mode
	local Mode = is_valid_parameter_value (A['Mode'], A:ORIGIN('Mode'), cfg.keywords_lists['mode'], '');
	-- separator character and postscript
	local sepc, PostScript = set_style (Mode:lower(), A['PostScript'], config.CitationClass);
	-- controls capitalization of certain static text
	local use_lowercase = ( sepc == ',' );
	
	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		if utilities.is_set (Chapter) then
			table.insert( z.message_tail, { utilities.set_message ( 'err_redundant_parameters', {utilities.wrap_style ('parameter', 'map') .. ' and ' .. utilities.wrap_style ('parameter', Chapter_origin)}, true ) } );	-- add error message
		end
		Chapter = A['Map'];
		Chapter_origin = A:ORIGIN('Map');
		ChapterURL = A['MapURL'];
		ChapterURL_origin = A:ORIGIN('MapURL');
		TransChapter = A['TransMap'];
		ScriptChapter = A['ScriptMap']
		ScriptChapter_origin = A:ORIGIN('ScriptMap')

		ChapterUrlAccess = MapUrlAccess;
		ChapterFormat = A['MapFormat'];

		Cartography = A['Cartography'];
		if utilities.is_set ( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if utilities.is_set ( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	local Series = A['Series'];
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local SeriesLink = A['SeriesLink'];

		SeriesLink = link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wiki-markup in |series-link= or wiki-markup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if utilities.is_set (Network) then table.insert(n, Network); end
		if utilities.is_set (Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if utilities.is_set (Season) and utilities.is_set (SeriesNumber) then	-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { utilities.set_message ( 'err_redundant_parameters', {utilities.wrap_style ('parameter', 'season') .. ' and ' .. utilities.wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if utilities.is_set (Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if utilities.is_set (SeriesNumber) then table.insert(s, wrap_msg ('seriesnum', SeriesNumber, use_lowercase)); end
			if utilities.is_set (Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ScriptChapter_origin = A:ORIGIN('ScriptTitle');
			ChapterLink = TitleLink;											-- alias |episode-link=
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if utilities.is_set (ChapterLink) and not utilities.is_set (ChapterURL) then	-- link but not URL
				Chapter = utilities.make_wikilink (ChapterLink, Chapter);
			elseif utilities.is_set (ChapterLink) and utilities.is_set (ChapterURL) then	-- if both are set, URL links episode;
				Series = utilities.make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if utilities.is_set (Series) and utilities.is_set (SeriesLink) then
				Series = utilities.make_wikilink (SeriesLink, Series);
			end
			Series = utilities.wrap_style ('italic-title', Series);				-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- handle type parameter for those CS1 citations that have default values
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	if utilities.in_array (config.CitationClass, {&quot;AV-media-notes&quot;, &quot;interview&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if utilities.is_set (Degree) and &quot;Thesis&quot; == TitleType then				-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if utilities.is_set (TitleType) then										-- if type parameter is specified
		TitleType = utilities.substitute ( cfg.messages['type'], TitleType);	-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
	local Date = A['Date'];
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging
	local PublicationDate = A['PublicationDate'];
	local Year = A['Year'];

	if not utilities.is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not utilities.is_set (Date) and utilities.is_set (PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]

	local DF = is_valid_parameter_value (A['DF'], A:ORIGIN('DF'), cfg.keywords_lists['df'], '');
	if not utilities.is_set (DF) then
		DF = cfg.global_df;														-- local |df= if present overrides global df set by {{use xxx date}} template
	end

	local ArchiveURL;
	local ArchiveDate;
	local ArchiveFormat = A['ArchiveFormat'];

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	
	ArchiveURL, ArchiveDate = is_unique_archive_url (ArchiveURL, URL, ChapterURL, A:ORIGIN('ArchiveURL'), ArchiveDate);		-- add error message when URL or ChapterURL == ArchiveURL

	
	local AccessDate = A['AccessDate'];
	local LayDate = A['LayDate'];
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification
	local DoiBroken = A['DoiBroken'];
	local Embargo = A['Embargo'];
	local anchor_year;															-- used in the CITEREF identifier
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val = AccessDate, name = A:ORIGIN ('AccessDate')},
			['archive-date'] = {val = ArchiveDate, name = A:ORIGIN ('ArchiveDate')},
			['date'] = {val = Date, name = Date_origin},
			['doi-broken-date'] = {val = DoiBroken, name = A:ORIGIN ('DoiBroken')},
			['pmc-embargo-date'] = {val = Embargo, name = A:ORIGIN ('Embargo')},
			['lay-date'] = {val = LayDate, name = A:ORIGIN ('LayDate')},
			['publication-date'] = {val = PublicationDate, name = A:ORIGIN ('PublicationDate')},
			['year'] = {val = Year, name = A:ORIGIN ('Year')},
			};

		local error_list = {};
		anchor_year, Embargo = validation.dates(date_parameters_list, COinS_date, error_list);

-- start temporary Julian / Gregorian calendar uncertainty categorization
		if COinS_date.inter_cal_cat then
			utilities.add_prop_cat ('jul_greg_uncertainty');
		end
-- end temporary Julian / Gregorian calendar uncertainty categorization

		if utilities.is_set (Year) and utilities.is_set (Date) then				-- both |date= and |year= not normally needed; 
			validation.year_date_check (Year, A:ORIGIN ('Year'), Date, A:ORIGIN ('Date'), error_list);
		end
		
		if 0 == #error_list then												-- error free dates only; 0 when error_list is empty
			local modified = false;												-- flag
			
			if validation.edtf_transform (date_parameters_list) then			-- edtf dates to MOS compliant format
				modified = true;
			end

			if utilities.is_set (DF) then										-- if we need to reformat dates
				modified = validation.reformat_dates (date_parameters_list, DF);	-- reformat to DF format, use long month names if appropriate
			end

			if true == validation.date_hyphen_to_dash (date_parameters_list) then	-- convert hyphens to dashes where appropriate
				modified = true;
				utilities.set_message ('maint_date_format');					-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language,
	-- uncomment the next three lines.  Not supported by en.wiki (for obvious reasons)
	-- set validation.date_name_xlate() second argument to true to translate English digits to local digits (will translate ymd dates)
	--		if validation.date_name_xlate (date_parameters_list, false) then
	--			modified = true;
	--		end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				LayDate = date_parameters_list['lay-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end
		else
			table.insert (z.message_tail, {utilities.set_message ('err_bad_date', {utilities.make_sep_list (#error_list, error_list)}, true)});	-- add this error message
		end
	end	-- end of do

	local ID_list = {};															-- sequence table of rendered identifiers
	local ID_list_coins = {};													-- table of identifiers and their values from args; key is same as cfg.id_handlers's key
	local Class = A['Class'];													-- arxiv class identifier
	
	local ID_support = {
		{A['ASINTLD'], 'ASIN', 'err_asintld_missing_asin', A:ORIGIN ('ASINTLD')},				
		{DoiBroken, 'DOI', 'err_doibroken_missing_doi', A:ORIGIN ('DoiBroken')},
		{Embargo, 'PMC', 'err_embargo_missing_pmc', A:ORIGIN ('Embargo')},
		}

	ID_list, ID_list_coins = identifiers.identifier_lists_get (args, {DoiBroken = DoiBroken, ASINTLD = A['ASINTLD'], Embargo = Embargo, Class = Class}, ID_support);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite ssrn}}, before generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then
		if not utilities.is_set (ID_list_coins[config.CitationClass:upper()]) then 	-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp; |citeseerx= required for their templates
			table.insert (z.message_tail, {utilities.set_message ('err_' .. config.CitationClass .. '_missing', {}, true)});	-- add error message
		end

		Periodical = ({['arxiv'] = 'arXiv', ['biorxiv'] = 'bioRxiv', ['citeseerx'] = 'CiteSeerX', ['ssrn'] = 'Social Science Research Network'})[config.CitationClass];
	end

	-- Link the title of the work if no |url= was provided, but we have a |pmc= or a |doi= with |doi-access=free

	if config.CitationClass == &quot;journal&quot; and not utilities.is_set (URL) and not utilities.is_set (TitleLink) and not utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) then -- TODO: remove 'none' once existing citations have been switched to 'off', so 'none' can be used as token for &quot;no title&quot; instead
		if 'none' ~= cfg.keywords_xlate[auto_select] then						-- if auto-linking not disabled
 	 		if identifiers.auto_link_urls[auto_select] then						-- manual selection
		 		URL = identifiers.auto_link_urls[auto_select];					-- set URL to be the same as identifier's external link
 				URL_origin = cfg.id_handlers[auto_select:upper()].parameters[1];	-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['pmc'] then						-- auto-select PMC
				URL = identifiers.auto_link_urls['pmc'];						-- set URL to be the same as the PMC external link if not embargoed
				URL_origin = cfg.id_handlers['PMC'].parameters[1];				-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['doi'] then						-- auto-select DOI
				URL = identifiers.auto_link_urls['doi'];
				URL_origin = cfg.id_handlers['DOI'].parameters[1];
			end
 	 	end

		if utilities.is_set (URL) and utilities.is_set (AccessDate) then		-- access date requires |url=; identifier-created URL is not |url=
			table.insert( z.message_tail, { utilities.set_message ( 'err_accessdate_missing_url', {}, true ) } );	-- add an error message
			AccessDate = '';													-- unset
		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not utilities.is_set (Title) and not utilities.is_set (TransTitle) and not utilities.is_set (ScriptTitle) then	-- has special case for cite episode
		table.insert( z.message_tail, { utilities.set_message ( 'err_citation_missing_title', {'episode' == config.CitationClass and 'series' or 'title'}, true ) } );
	end

	if utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) and
			utilities.in_array (config.CitationClass, {'journal', 'citation'}) and
			(utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and
			('journal' == Periodical_origin or 'script-journal' == ScriptPeriodical_origin) then	-- special case for journal cites
				Title = '';														-- set title to empty string
				utilities.set_message ('maint_untitled');						-- add maint cat
	end

	check_for_url ({															-- add error message when any of these parameters hold a URL
		['title'] = Title,
		[A:ORIGIN('Chapter')] = Chapter,
		[Periodical_origin] = Periodical,
		[PublisherName_origin] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Chapter) and utilities.is_set (Title) and utilities.is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end
	
	local QuotePage = A['QuotePage'];
	local QuotePages = hyphen_to_dash (A['QuotePages']);

	-- this is the function call to COinS()
	local OCinSoutput = metadata.COinS({
		['Periodical'] = utilities.strip_apostrophe_markup (Periodical),		-- no markup in the metadata
		['Encyclopedia'] = Encyclopedia,										-- just a flag; content ignored by ~/COinS
		['Chapter'] = metadata.make_coins_title (coins_chapter, ScriptChapter),	-- Chapter and ScriptChapter stripped of bold / italic wiki-markup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = metadata.make_coins_title (coins_title, ScriptTitle),		-- Title and ScriptTitle stripped of bold / italic wiki-markup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Quarter'] = COinS_date.rftquarter,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = coins_pages or metadata.get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At, QuotePage, QuotePages}, 7)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName or Newsgroup,							-- any apostrophe markup already removed from PublisherName
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list_coins,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, and {{cite ssrn}} AFTER generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, CiteSeerX, or ssrn now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass and utilities.is_set (Newsgroup) then
		PublisherName = utilities.substitute (cfg.messages['newsgroup'], external_link( 'news:' .. Newsgroup, Newsgroup, Newsgroup_origin, nil ));
	end

	local Editors;
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	local Contributors;															-- assembled contributors name list
	local contributor_etal;
	local Translators;															-- assembled translators name list
	local translator_etal;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	local Interviewers;															
	local interviewers_list = {};					
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters
	local interviewer_etal;
	
	-- Now perform various field 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.
	do
		local last_first_list;
		local control = { 
			format = NameListStyle,												-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_names (A['DisplayEditors'], #e, 'editors', editor_etal, A:ORIGIN ('DisplayEditors'));
			Editors, EditorCount = list_people (control, e, editor_etal);

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum, interviewer_etal = get_display_names (A['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal, A:ORIGIN ('DisplayInterviewers'));
			Interviewers = list_people (control, interviewers_list, interviewer_etal);
		end
		do																		-- now do translators
			control.maximum, translator_etal = get_display_names (A['DisplayTranslators'], #t, 'translators', translator_etal, A:ORIGIN ('DisplayTranslators'));
			Translators = list_people (control, t, translator_etal);
		end
		do																		-- now do contributors
			control.maximum, contributor_etal = get_display_names (A['DisplayContributors'], #c, 'contributors', contributor_etal, A:ORIGIN ('DisplayContributors'));
			Contributors = list_people (control, c, contributor_etal);
		end
		do																		-- now do authors
			control.maximum, author_etal = get_display_names (A['DisplayAuthors'], #a, 'authors', author_etal, A:ORIGIN ('DisplayAuthors'));

			last_first_list = list_people (control, a, author_etal);

			if utilities.is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors');	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if utilities.is_set (Authors) and utilities.is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not utilities.is_set (URL) then
		if utilities.in_array (config.CitationClass, {&quot;web&quot;, &quot;podcast&quot;, &quot;mailinglist&quot;}) or		-- |url= required for cite web, cite podcast, and cite mailinglist
			('citation' == config.CitationClass and ('website' == Periodical_origin or 'script-website' == ScriptPeriodical_origin)) then	-- and required for {{citation}} with |website= or |script-website=
				table.insert( z.message_tail, { utilities.set_message ( 'err_cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if utilities.is_set (AccessDate) and not utilities.is_set (ChapterURL) then		-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { utilities.set_message ( 'err_accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local UrlStatus = is_valid_parameter_value (A['UrlStatus'], A:ORIGIN('UrlStatus'), cfg.keywords_lists['url-status'], '');
	local OriginalURL
	local OriginalURL_origin
	local OriginalFormat
	local OriginalAccess;
	UrlStatus = UrlStatus:lower();												-- used later when assembling archived text
	if utilities.is_set ( ArchiveURL ) then
		if utilities.is_set (ChapterURL) then 									-- if chapter-url= is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURL_origin = ChapterURL_origin;								-- name of |chapter-url= parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=

			if 'live' ~= UrlStatus then
				ChapterURL = ArchiveURL											-- swap-in the archive's URL
				ChapterURL_origin = A:ORIGIN('ArchiveURL')						-- name of |archive-url= parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived URLs
			end
		elseif utilities.is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURL_origin = URL_origin;									-- name of URL parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;

			if 'live' ~= UrlStatus then											-- if URL set then |archive-url= applies to it
				URL = ArchiveURL												-- swap-in the archive's URL
				URL_origin = A:ORIGIN('ArchiveURL')								-- name of archive URL parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived URLs
			end
 		end
	end

	if utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) then
			local chap_param;
			if utilities.is_set (Chapter) then									-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif utilities.is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif utilities.is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif utilities.is_set (ScriptChapter) then
				chap_param = ScriptChapter_origin;
			else utilities.is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if utilities.is_set (chap_param) then								-- if we found one
				table.insert( z.message_tail, { utilities.set_message ( 'err_chapter_ignored', {chap_param}, true ) } );	-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if utilities.is_set (Contribution) and 0 &lt; #c then						-- if this is a contribution with contributor(s)
			if utilities.in_array (Contribution:lower(), cfg.keywords_lists.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, ScriptChapter_origin, Chapter, Chapter_origin, TransChapter, TransChapter_origin, ChapterURL, ChapterURL_origin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if utilities.is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and utilities.is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter .. sepc .. ' ';
		elseif utilities.is_set (ChapterFormat) then							-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title
	local plain_title = false;
	local accept_title;
	Title, accept_title = utilities.has_accept_as_written (Title, true);		-- remove accept-this-as-written markup when it wraps all of &lt;Title&gt;
	if accept_title and ('' == Title) then										-- only support forced empty for now &quot;(())&quot;
		Title = cfg.messages['notitle'];										-- replace by predefined &quot;No title&quot; message
			-- TODO: utilities.set_message ( 'err_redundant_parameters', ...);	-- issue proper error message instead of muting	 
			ScriptTitle = '';													-- just mute for now	 
			TransTitle = '';													-- just mute for now
 		plain_title = true;														-- suppress text decoration for descriptive title
		utilities.set_message ('maint_untitled');								-- add maint cat
	end

	if not accept_title then -- &lt;Title&gt; not wrapped in accept-as-written markup
		if '...' == Title:sub (-3) then											-- if ellipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%' .. sepc .. '$', '');			-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end

		if utilities.is_set (ArchiveURL) and is_archived_copy (Title) then
			utilities.set_message ('maint_archived_copy');						-- add maintenance category before we modify the content of Title
		end

		if is_generic_title (Title) then
			table.insert (z.message_tail, {utilities.set_message ( 'err_generic_title', {}, true ) } );	-- set an error message
		end
	end

	if (not plain_title) and (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) or
		('map' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)))) then		-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from module provided quote marks
			Title = utilities.wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle, 'script-title');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
			TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );
	elseif plain_title or ('report' == config.CitationClass) then								-- no styling for cite report and descriptive titles (otherwise same as above)
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = utilities.wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if utilities.is_set (TransTitle) then
		if utilities.is_set (Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. utilities.set_message ( 'err_trans_missing_title', {'title'} );
		end
	end

	if utilities.is_set (Title) then											-- TODO: is this the right place to be making Wikisource URLs?
		if utilities.is_set (TitleLink) and utilities.is_set (URL) then
			table.insert( z.message_tail, { utilities.set_message ( 'err_wikilink_in_url', {}, true ) } );	-- set an error message because we can't have both
			TitleLink = '';														-- unset
		end
	
		if not utilities.is_set (TitleLink) and utilities.is_set (URL) then
			Title = external_link (URL, Title, URL_origin, UrlAccess) .. TransTitle .. TransError .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif utilities.is_set (TitleLink) and not utilities.is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = utilities.make_wikilink (TitleLink, Title) .. TransTitle .. TransError;
			end
		else
			local ws_url, ws_label, L;											-- Title has italic or quote markup by the time we get here which causes is_wikilink() to return 0 (not a wikilink)
			ws_url, ws_label, L = wikisource_url_make (Title:gsub('^[\'&quot;]*(.-)[\'&quot;]*$', '%1'));	-- make ws URL from |title= interwiki link (strip italic or quote markup); link portion L becomes tooltip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = Title .. TransTitle .. TransError;
			end
		end
	else
		Title = TransTitle .. TransError;
	end

	if utilities.is_set (Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	local ConferenceURL_origin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	if utilities.is_set (Conference) then
		if utilities.is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURL_origin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif utilities.is_set (ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURL_origin, nil );
	end

	local Position = '';
	if not utilities.is_set (Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if utilities.is_set (Minutes) then
			if utilities.is_set (Time) then
				table.insert( z.message_tail, { utilities.set_message ( 'err_redundant_parameters', {utilities.wrap_style ('parameter', 'minutes') .. ' and ' .. utilities.wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if utilities.is_set (Time) then
				local TimeCaption = A['TimeCaption']
				if not utilities.is_set (TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = utilities.is_set (At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = utilities.is_set (Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Sections = A['Sections'];											-- Section (singular) is an alias of Chapter so set earlier
		local Inset = A['Inset'];
		
		if utilities.is_set ( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if utilities.is_set ( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif utilities.is_set ( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	local Others = A['Others'];
	if utilities.is_set (Others) and 0 == #a and 0 == #e then					-- add maint cat when |others= has value and used without |author=, |editor=
		if config.CitationClass == &quot;AV-media-notes&quot;
		or config.CitationClass == &quot;audio-visual&quot; then							-- special maint for AV/M which has a lot of 'false' positives right now
			utilities.set_message ('maint_others_avm')
		else
			utilities.set_message ('maint_others');
		end
	end
	Others = utilities.is_set (Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if utilities.is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if utilities.is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	local TitleNote = A['TitleNote'];
	TitleNote = utilities.is_set (TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if utilities.is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%n?%.?$') or Edition:match ('%f[%a][Ee]dition$') then -- Ed, ed, Ed., ed., Edn, edn, Edn., edn.
			table.insert( z.message_tail, { utilities.set_message ( 'err_extra_text_edition')}); -- add error
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = utilities.is_set (Series) and wrap_msg ('series', {sepc, Series}) or &quot;&quot;;	-- not the same as SeriesNum
	local Agency = A['Agency'];
	Agency = utilities.is_set (Agency) and wrap_msg ('agency', {sepc, Agency}) or &quot;&quot;;
	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	if utilities.is_set (AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = utilities.substitute (retrv_text, AccessDate);				-- add retrieved text

		AccessDate = utilities.substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if utilities.is_set (ID) then ID = sepc .. &quot; &quot; .. ID; end
	
	local Docket = A['Docket'];
   	if &quot;thesis&quot; == config.CitationClass and utilities.is_set (Docket) then
		ID = sepc .. &quot; Docket &quot; .. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and utilities.is_set (Docket) then		-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	if utilities.is_set (URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URL_origin, UrlAccess );
	end

	local Quote = A['Quote'];
	local TransQuote = A['TransQuote'];
	local ScriptQuote = A['ScriptQuote'];
	if utilities.is_set (Quote) or utilities.is_set (TransQuote) or utilities.is_set (ScriptQuote) then

		if utilities.is_set (Quote) then
			if Quote:sub(1, 1) == '&quot;' and Quote:sub(-1, -1) == '&quot;' then			-- if first and last characters of quote are quote marks
				Quote = Quote:sub(2, -2);										-- strip them off
			end
		end

		Quote = utilities.wrap_style ('quoted-text', Quote );					-- wrap in &lt;q&gt;...&lt;/q&gt; tags
	
		if utilities.is_set (ScriptQuote) then
			Quote = script_concatenate (Quote, ScriptQuote, 'script-quote');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after quote is wrapped
		end

		if utilities.is_set (TransQuote) then
			if TransQuote:sub(1, 1) == '&quot;' and TransQuote:sub(-1, -1) == '&quot;' then -- if first and last characters of |trans-quote are quote marks
				TransQuote = TransQuote:sub(2, -2); -- strip them off
			end
			Quote = Quote .. &quot; &quot; .. utilities.wrap_style ('trans-quoted-title', TransQuote );
		end

		if utilities.is_set (QuotePage) or utilities.is_set (QuotePages) then	-- add page prefix
			local quote_prefix = '';
			if utilities.is_set (QuotePage) then
				extra_text_in_page_check (QuotePage, 'quote-page');				-- add to maint cat if |quote-page= value begins with what looks like p., pp., etc.
				if not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePage}), '', '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePage}), '', '', '';
				end
			elseif utilities.is_set (QuotePages) then
				extra_text_in_page_check (QuotePages, 'quote-pages');			-- add to maint cat if |quote-pages= value begins with what looks like p., pp., etc.
				if tonumber(QuotePages) ~= nil and not NoPP then				-- if only digits, assume single page
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePages}), '', '';
				elseif not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['pp-prefix'], {sepc, QuotePages}), '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePages}), '', '';
				end
			end
                        
			Quote = quote_prefix .. &quot;: &quot; .. Quote;
		else
			Quote = sepc .. &quot; &quot; .. Quote;
		end

		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	-- We check length of PostScript here because it will have been nuked by
	-- the quote parameters. We'd otherwise emit a message even if there wasn't
	-- a displayed postscript.
	-- TODO: Should the max size (1) be configurable?
	-- TODO: Should we check a specific pattern?
	if utilities.is_set(PostScript) and mw.ustring.len(PostScript) &gt; 1 then
		utilities.set_message('maint_postscript')
	end
	
	local Archived
	if utilities.is_set (ArchiveURL) then
		local arch_text;
		if not utilities.is_set (ArchiveDate) then
			ArchiveDate = utilities.set_message ('err_archive_missing_date');
		end
		if &quot;live&quot; == UrlStatus then
			arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. utilities.substitute ( cfg.messages['archived-live'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil ) .. ArchiveFormat, ArchiveDate } );
			if not utilities.is_set (OriginalURL) then
				Archived = Archived .. &quot; &quot; .. utilities.set_message ('err_archive_missing_url');							   
			end
		elseif utilities.is_set (OriginalURL) then								-- UrlStatus is empty, 'dead', 'unfit', 'usurped', 'bot: unknown'
			if utilities.in_array (UrlStatus, {'unfit', 'usurped', 'bot: unknown'}) then
				arch_text = cfg.messages['archived-unfit'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. &quot; &quot; .. arch_text .. ArchiveDate;				-- format already styled
				if 'bot: unknown' == UrlStatus then
					utilities.set_message ('maint_bot_unknown');				-- and add a category if not already added
				else
					utilities.set_message ('maint_unfit');						-- and add a category if not already added
				end
			else																-- UrlStatus is empty, 'dead'
				arch_text = cfg.messages['archived-dead'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. &quot; &quot; .. utilities.substitute ( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURL_origin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else																	-- OriginalUrl not set
			arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. utilities.substitute ( arch_text, 
				{ utilities.set_message ('err_archive_missing_url'), ArchiveDate } );
		end
	elseif utilities.is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	local LaySource = A['LaySource'];
	local LayURL = A['LayURL'];
	local LayFormat = A['LayFormat'];
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	if utilities.is_set (LayURL) then
		if utilities.is_set (LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if utilities.is_set (LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. utilities.safe_for_italics (LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif utilities.is_set (LayFormat) then									-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	local TranscriptURL = A['TranscriptURL']
	local TranscriptFormat = A['TranscriptFormat'];
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');
	local Transcript = A['Transcript'];
	local TranscriptURL_origin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL
	if utilities.is_set (Transcript) then
		if utilities.is_set (TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURL_origin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif utilities.is_set (TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURL_origin, nil );
	end

	local Publisher;
	if utilities.is_set (PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if utilities.is_set (PublisherName) then
		if utilities.is_set (PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif utilities.is_set (PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	local TransPeriodical =  A['TransPeriodical'];
	local TransPeriodical_origin =  A:ORIGIN ('TransPeriodical');
	-- Several of the above rely upon detecting this as nil, so do it last.
	if (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical)) then
		if utilities.is_set (Title) or utilities.is_set (TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		else 
			Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		end
	end
	
	local Language = A['Language'];
	if utilities.is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc.
	else
		Language='';															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then									-- cite speech only
		TitleNote = &quot; (Speech)&quot;;												-- annotate the citation
		if utilities.is_set (Periodical) then									-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if utilities.is_set (Conference) then								-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;							-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
		if utilities.is_set (Others) then Others = safe_join ({Others, sepc .. &quot; &quot;}, sepc) end		-- add terminal punctuation &amp; space; check for dup sepc; TODO why do we need to do this here?
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (Periodical) then		-- special cases for book cites
		if utilities.is_set (Contributors) then									-- when we are citing foreword, preface, introduction, etc.
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if utilities.is_set (Chapter) then										-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif utilities.is_set (Periodical) then								-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local Via = A['Via'];
	Via = utilities.is_set (Via) and  wrap_msg ('via', Via) or '';
	local idcommon;
	if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then	-- special case for cite AV media &amp; cite episode position transcript
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, Lay, Quote }, sepc );
	else
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, Lay, Quote }, sepc );
	end
	
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	local OrigDate = A['OrigDate'];
	OrigDate = utilities.is_set (OrigDate) and wrap_msg ('origdate', OrigDate) or '';
	if utilities.is_set (Date) then
		if utilities.is_set (Authors) or utilities.is_set (Editors) then		-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date .. &quot;)&quot; .. OrigDate .. sepc .. &quot; &quot;;				-- in parentheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon, -1, -1) == sepc) then						-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigDate;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigDate;							-- Date begins with sepc
			end
		end
	end	
	if utilities.is_set (Authors) then
		if (not utilities.is_set (Date)) then									-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if utilities.is_set (Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then
					in_text = in_text:lower()									-- lowercase for cs2
				end
			end
			if EditorCount &lt;= 1 then
				post_text = &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot;;				-- be consistent with no-author, no-date case
			else
				post_text = &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot;;
			end
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Contributors) then									-- book cite and we're citing the intro, preface, etc.
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if utilities.is_set (Editors) and utilities.is_set (Date) then		-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not utilities.is_set (Date)) then								-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif utilities.is_set (Editors) then
		if utilities.is_set (Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if utilities.is_set (PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc ); 								-- Deals with italics, spaces, etc.
		text = text:sub(1, -sepc:len() - 1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite&gt; element
	local options = {};
	
	if utilities.is_set (config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = string.format ('%s %s %s', 'citation', config.CitationClass, utilities.is_set (Mode) and Mode or 'cs1');	-- class=citation required for blue highlight when used with |ref=
	else
		options.class = string.format ('%s %s', 'citation', utilities.is_set (Mode) and Mode or 'cs2');
	end

	local Ref = A['Ref'];
	if 'harv' == Ref then														-- need to check this before setting to default
		utilities.set_message ('maint_ref_harv');								-- add maint cat to identify templates that have this now-extraneous param value
	elseif not utilities.is_set (Ref) then
		Ref = 'harv';															-- set as default when not set externally
	end
	if 'none' ~= cfg.keywords_xlate[Ref:lower()] then
		local id = Ref
		local namelist = {};													-- holds selected contributor, author, editor name list
		local year = first_set ({Year, anchor_year}, 2);						-- Year first for legacy citations and for YMD dates that require disambiguation

		if #c &gt; 0 then															-- if there is a contributor list
			namelist = c;														-- select it
		elseif #a &gt; 0 then														-- or an author list
			namelist = a;
		elseif #e &gt; 0 then														-- or an editor list
			namelist = e;
		end
		local citeref_id
		if #namelist &gt; 0 then													-- if there are names in namelist
			citeref_id = make_citeref_id (namelist, year);						-- go make the CITEREF anchor
		else
			citeref_id = '';													-- unset
		end
		if citeref_id == Ref then
			utilities.set_message ('maint_ref_duplicates_default');
		end
		if 'harv' == Ref then
			id = citeref_id
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;(.-)&lt;/span&gt;&quot;, &quot;%1&quot;):gsub(&quot;%b&lt;&gt;&quot;, &quot;&quot;)) &lt;= 2 then	-- remove &lt;span&gt; tags and other HTML-like markup; then get length of what remains
		z.error_categories = {};
		text = utilities.set_message ('err_empty_citation');
		z.message_tail = {};
	end
	
	local render = {};															-- here we collect the final bits for concatenation into the rendered citation

	if utilities.is_set (options.id) then										-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render, utilities.substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text}));	-- when |ref= is set
	else
		table.insert (render, utilities.substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text}));	-- all other cases
	end		

	table.insert (render, utilities.substitute (cfg.presentation['ocins'], {OCinSoutput}));	-- append metadata to the citation

	if 0 ~= #z.message_tail then
		table.insert (render, ' ');
		for i,v in ipairs( z.message_tail ) do
			if utilities.is_set (v[1]) then
				if i == #z.message_tail then
					table.insert (render, utilities.error_comment ( v[1], v[2] ));
				else
					table.insert (render, utilities.error_comment ( v[1] .. &quot;; &quot;, v[2] ));
				end
			end
		end
	end

	if 0 ~= #z.maintenance_cats then
		local maint_msgs = {};													-- here we collect all of the maint messages
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			local maint = {};													-- here we assemble a maintenence message
			table.insert (maint, v);											-- maint msg is the category name
			table.insert (maint, ' (');											-- open the link text
			table.insert (maint, utilities.substitute (cfg.messages[':cat wikilink'], {v}));	-- add the link
			table.insert (maint, ')');											-- and close it
			table.insert (maint_msgs, table.concat (maint));					-- assemble new maint message and add it to the maint_msgs table
		end
		table.insert (render, utilities.substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs, ' ')));	-- wrap the group of maint message with proper presentation and save
	end
	
	if not no_tracking_cats then
		for _, v in ipairs( z.error_categories ) do								-- append error categories
			table.insert (render, utilities.substitute (cfg.messages['cat wikilink'], {v}));
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			table.insert (render, utilities.substitute (cfg.messages['cat wikilink'], {v}));
		end
		for _, v in ipairs( z.properties_cats ) do								-- append properties categories
			table.insert (render, utilities.substitute (cfg.messages['cat wikilink'], {v}));
		end
	end

	return table.concat (render);	
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class, empty)
	local name = tostring (name);
	local enum_name;															-- for enumerated parameters, is name with enumerator replaced with '#'
	local state;
	local function state_test (state, name)										-- local function to do testing of state values
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			if empty then return nil; end										-- empty deprecated parameters are treated as unknowns
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
		if 'discouraged' == state then
			discouraged_parameter (name);										-- parameter is discouraged but still supported
			return true;
		end
		return nil;
	end		

	if name:find ('#') then														-- # is a cs1|2 reserved character so parameters with # not permitted
		return nil;
	end

	if utilities.in_array (cite_class, whitelist.preprint_template_list ) then	-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[name];
		if true == state_test (state, name) then return true; end

		state = whitelist.preprint_arguments[cite_class][name];					-- look in the parameter-list for the template identified by cite_class
		if true == state_test (state, name) then return true; end

																				-- limited enumerated parameters list
		enum_name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );										-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
		state = whitelist.limited_numbered_arguments[enum_name];
		if true == state_test (state, name) then return true; end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates

	if utilities.in_array (cite_class, whitelist.unique_param_template_list) then 	-- experiment for template-specific parameters for templates that accept parameters from the basic argument list
		state = whitelist.unique_arguments[cite_class][name];					-- look in the template-specific parameter-lists for the template identified by cite_class
		if true == state_test (state, name) then return true; end
	end																			-- if here, fall into general validation
		
	state = whitelist.basic_arguments[name];									-- all other templates; all normal parameters allowed
	if true == state_test (state, name) then return true; end

																				-- all enumerated parameters allowed
	enum_name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
	state = whitelist.numbered_arguments[enum_name];
	if true == state_test (state, name) then return true; end

	return false;																-- not supported because not found or name is set to nil
end


--[=[-------------------------&lt; I N T E R _ W I K I _ C H E C K &gt;----------------------------------------------

check &lt;value&gt; for inter-language interwiki-link markup.  &lt;prefix&gt; must be a MediaWiki-recognized language
code.  when these values have the form (without leading colon):
	[[&lt;prefix&gt;:link|label]] return label as plain-text
	[[&lt;prefix&gt;:link]] return &lt;prefix&gt;:link as plain-text

return value as is else

]=]

local function inter_wiki_check (parameter, value)
	local prefix = value:match ('%[%[(%a+):');									-- get an interwiki prefix if one exists
	local _;
	
	if prefix and cfg.inter_wiki_map[prefix:lower()] then						-- if prefix is in the map, needs preceding colon so
		table.insert( z.message_tail, {utilities.set_message ('err_bad_paramlink', parameter)});	-- emit an error message
		_, value, _ = utilities.is_wikilink (value);							-- extract label portion from wikilink
	end
	return value;
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe.  There are two tests made:
	{{cite ... |title=Title access-date=2016-03-17}}	-- the first parameter has a value and whitespace separates that value from the missing pipe parameter name
	{{cite ... |title=access-date=2016-03-17}}			-- the first parameter has no value (whitespace after the first = is trimmed by MediaWiki)
cs1|2 shares some parameter names with XML/HTML attributes: class=, title=, etc.  To prevent false positives XML/HTML
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (parameter, value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove XML/HTML tags because attributes: class=, title=, etc.

	capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then										-- if the capture is a valid parameter name
		table.insert( z.message_tail, {utilities.set_message ('err_missing_pipe', parameter)});
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ P U N C T &gt;--------------------------------------

look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_punc (param, value)
	if 'number' == type (param) then
		return;
	end
	
	param = param:gsub ('%d+', '#');											-- enumerated name-list mask params allow terminal punct; normalize 
	if cfg.punct_skip[param] then
		return;																	-- parameter name found in the skip table so done
	end
	
	if value:match ('[,;:]$') then
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
end


--[[--------------------------&lt; C I T A T I O N &gt;--------------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

local function citation(frame)
	Frame = frame;																-- save a copy in case we need to display an error message in preview mode
	local pframe = frame:getParent()
	local styles;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		styles = 'Module:Citation/CS1/sandbox/styles.css';
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
		styles = 'Module:Citation/CS1/styles.css';
	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the selected cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text, error_state;

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do											-- get parameters from the {{#invoke}} frame
		config[k] = v;
	--	args[k] = v;															-- crude debug support that allows us to render a citation from module {{#invoke:}}; skips parameter validation; TODO: keep?
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	local empty_unknowns = {};													-- sequence table to hold empty unknown params for error message listing
	for k, v in pairs( pframe.args ) do											-- get parameters from the parent (template) frame
		v = mw.ustring.gsub (v, '^%s*(.-)%s*$', '%1');							-- trim leading/trailing whitespace; when v is only whitespace, becomes empty string
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = utilities.set_message ( 'err_text_ignored', {v}, true );
					end
				elseif validate( k:lower(), config.CitationClass ) then 
					error_text, error_state = utilities.set_message ( 'err_parameter_ignored_suggest', {k, k:lower()}, true );	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no capture in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = utilities.substitute (param, capture);		-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text, error_state = utilities.set_message ('err_parameter_ignored_suggest', {k, param}, true);	-- set the suggestion error message
							else
								error_text, error_state = utilities.set_message ( 'err_parameter_ignored', {k}, true );	-- suggested param not supported by this template
								v = '';											-- unset
							end
						end
					end
					if not utilities.is_set (error_text) then					-- couldn't match with a pattern, is there an explicit suggestion?						
						if (suggestions.suggestions[ k:lower() ] ~= nil) and validate (suggestions.suggestions[ k:lower() ], config.CitationClass) then
							error_text, error_state = utilities.set_message ( 'err_parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = utilities.set_message ( 'err_parameter_ignored', {k}, true );
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end

			args[k] = v;														-- save this parameter and its value

		elseif not utilities.is_set (v) then									-- for empty parameters
			if not validate (k, config.CitationClass, true) then				-- is this empty parameter a valid parameter
				k = ('' == k) and '(empty string)' or k;						-- when k is empty string (or was space(s) trimmed to empty string), replace with descriptive text
				table.insert (empty_unknowns, utilities.wrap_style ('parameter', k));	-- format for error message and add to the list
			end
																				-- crude debug support that allows us to render a citation from module {{#invoke:}} TODO: keep?
	--	elseif args[k] ~= nil or (k == 'postscript') then						-- when args[k] has a value from {{#invoke}} frame (we don't normally do that)
	--		args[k] = v;														-- overwrite args[k] with empty string from pframe.args[k] (template frame); v is empty string here
		end																		-- not sure about the postscript bit; that gets handled in parameter validation; historical artifact?
	end	

	if 0 ~= #empty_unknowns then												-- create empty unknown error message
		table.insert (z.message_tail, {utilities.set_message ('err_param_unknown_empty', {
			1 == #empty_unknowns and '' or 's',
			utilities.make_sep_list (#empty_unknowns, empty_unknowns)
			}, true )});
	end

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);											-- look for invisible characters
		end
		has_extraneous_punc (k, v);												-- look for extraneous terminal punctuation in parameter values
		missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?
		args[k] = inter_wiki_check (k, v);										-- when language interwiki-linked parameter missing leading colon replace with wiki-link label
	end

	return table.concat ({
		frame:extensionTag ('templatestyles', '', {src=styles}),
		citation0( config, args)
	});
end

--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {citation = citation};</text>
      <sha1>drxm43taynzqso60mz2oj9lx8zguwgx</sha1>
    </revision>
    <revision>
      <id>4741</id>
      <parentid>4740</parentid>
      <timestamp>2021-04-14T01:13:35Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>hyphen_to_dash() fix;</comment>
      <origin>4741</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="206328" sha1="llxiik9jlezm96f6q6dit9v5zjxt2m0" xml:space="preserve">
require('Module:No globals');

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
each of these counts against the Lua upvalue limit
]]

local validation;																-- functions in Module:Citation/CS1/Date_validation

local utilities;																-- functions in Module:Citation/CS1/Utilities
local z ={};																	-- table of tables in Module:Citation/CS1/Utilities

local identifiers;																-- functions and tables in Module:Citation/CS1/Identifiers
local metadata;																	-- functions in Module:Citation/CS1/COinS
local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist

--[[------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;---------------
declare variables here that have page-wide scope that are not brought in from
other modules; that are created here and used here
]]
local added_deprecated_cat;														-- Boolean flag so that the category is added only once
local added_discouraged_cat;													-- Boolean flag so that the category is added only once
local added_vanc_errs;															-- Boolean flag so we only emit one Vancouver error / category
local Frame;																	-- holds the module's frame table

--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if utilities.is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a Boolean declared in page scope variables above

]]

local function add_vanc_error (source, position)
	if added_vanc_errs then return end
		
	added_vanc_errs = true;														-- note that we've added this category
	table.insert( z.message_tail, { utilities.set_message ( 'err_vancouver', {source, position}, true ) } );
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a URI scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of TLDs: https://www.iana.org/domains/root/db

RFC 952 (modified by RFC 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the TLD.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a URL with a scheme) will be stripped
here.  Perhaps not necessary but retained in case it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ASCII characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the TLD) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and TLD or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%w]') then											-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at Wikisource
		return false;
	end

	local patterns = {															-- patterns that look like URLs
		'%f[%w][%w][%w%-]+[%w]%.%a%a+$',										-- three or more character hostname.hostname or hostname.tld
		'%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$',									-- internationalized domain name with ACE prefix
		'%f[%a][qxz]%.com$',													-- assigned one character .com hostname (x.com times out 2015-12-10)
		'%f[%a][iq]%.net$',														-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		'%f[%w][%w]%.%a%a$',													-- one character hostname and ccTLD (2 chars)
		'%f[%w][%w][%w]%.%a%a+$',												-- two character hostname and TLD
		'^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?',								-- IPv4 address
		}

	for _, pattern in ipairs (patterns) do										-- loop through the patterns list
		if domain:match (pattern) then
			return true;														-- if a match then we think that this thing that purports to be a URL is a URL
		end
	end

	for _, d in ipairs ({'cash', 'company', 'today', 'org'}) do					-- look for single letter second level domain names for these top level domains
		if domain:match ('%f[%w][%w]%.' .. d) then
			return true
		end
	end
	return false;																-- no matches, we don't know what this thing is
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a URL appear to be a valid URL; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if utilities.is_set (scheme) then											-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when URL is protocol-relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a URL into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following TLD) (if any) and any path(/), query(?) or fragment(#).

If protocol-relative URL, return nil scheme and domain else return nil for both scheme and domain.

When not protocol-relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Any URL that does not have news: scheme must have authority indicator (//).  TODO: are there other common schemes
like news: that don't use authority indicator?

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol-relative URL
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		if utilities.is_set (authority) then
			authority = authority:gsub ('//', '', 1);							-- replace place 1 pair of '/' with nothing;
			if utilities.is_set(authority) then									-- if anything left (1 or 3+ '/' where authority should be) then
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		else
			if not scheme:match ('^news:') then									-- except for news:..., MediaWiki won't link URLs that do not have authority indicator; TODO: a better way to do this test?
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link=, etc. for properly formatted content: no wikilinks, no URLs

Link parameters are to hold the title of a Wikipedia article, so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki URLs and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid URL (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid URL (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from URL; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid URL
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wiki-linked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

check &lt;link&gt; for inter-language interwiki-link prefix.  prefix must be a MediaWiki-recognized language
code and must begin with a colon.

]]

local function link_title_ok (link, lorig, title, torig)
local orig;
	if utilities.is_set (link) then 											-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		elseif link:match ('^%a+:') then										-- if the link is what looks like an interwiki
			local prefix = link:match ('^(%a+):'):lower();						-- get the interwiki prefix

			if cfg.inter_wiki_map[prefix] then									-- if prefix is in the map, must have preceding colon
				orig = lorig;													-- flag as error
			end
		end
	end

	if utilities.is_set (orig) then
		link = '';																-- unset
		table.insert( z.message_tail, { utilities.set_message ( 'err_bad_paramlink', orig)});	-- URL or wikilink in |title= with |title-link=;
	end
	
	return link;																-- link if ok, empty string else
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the URL into scheme and domain
portions, or for protocol-relative (//example.com) URLs, just the domain.  Use is_url() to validate the two
portions of the URL.  If both are valid, or for protocol-relative if domain is valid, return true, else false.

Because it is different from a standard URL, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper URL
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from URL;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a URL.  The test will also find external wikilinks
that use protocol-relative URLs. Also finds bare URLs.

The frontier pattern prevents a match on interwiki-links which are similar to scheme:path URLs.  The tests that
find bracketed URLs are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext. wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol-relative ext. wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare URL with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol-relative bare URL: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a URL
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list)
local error_message = '';
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a URL add an error message
			if utilities.is_set(error_message) then								-- once we've added the first portion of the error message ...
				error_message = error_message .. &quot;, &quot;;							-- ... add a comma space separator
			end
			error_message = error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
		end
	end
	if utilities.is_set (error_message) then									-- done looping, if there is an error message, display it
		table.insert( z.message_tail, { utilities.set_message ( 'err_param_has_ext_link', {error_message}, true ) } );
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		table.insert( z.message_tail, { utilities.set_message ( 'err_wikilink_in_url', {}, true ) } );
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link( URL, label, source, access)
	local error_str = &quot;&quot;;
	local domain;
	local path;
	local base_url;

	if not utilities.is_set ( label ) then
		label = URL;
		if utilities.is_set ( source ) then
			error_str = utilities.set_message ( 'err_bare_url_missing_title', { utilities.wrap_style ('parameter', source) }, false, &quot; &quot; );
		else
			error( cfg.messages[&quot;bare_url_no_origin&quot;] );
		end			
	end
	if not check_url( URL ) then
		error_str = utilities.set_message ( 'err_bad_url', {utilities.wrap_style ('parameter', source)}, false, &quot; &quot; ) .. error_str;
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the URL into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['['] = '%5b', [']'] = '%5d'});			-- replace '[' and ']' with their percent-encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wiki-markup URL

	if utilities.is_set (access) then											-- access level (subscription, registration, limited)
		base_url = utilities.substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end
	
	return table.concat ({base_url, error_str});
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a Boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { utilities.set_message ( 'err_deprecated_params', {name}, true ) } );	-- add error message
	end
end


--[[--------------------------&lt; D I S C O U R A G E D _ P A R A M E T E R &gt;------------------------------------

Categorize and emit an maintenance message when the citation contains one or more discouraged parameters.  Only
one error message is emitted regardless of the number of discouraged parameters in the citation.

added_discouraged_cat is a Boolean declared in page scope variables above

]]

local function discouraged_parameter(name)
	if not added_discouraged_cat then
		added_discouraged_cat = true;											-- note that we've added this category
		table.insert( z.message_tail, { utilities.set_message ( 'maint_discouraged', {name}, true ) } );	-- add maint message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wiki-markup) are not kerned.

Replaces Unicode quote marks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc.; not for book titles.

]=]

local function kern_quotes (str)
	local cap = '';
	local cap2 = '';
	local wl_type, label, link;

	wl_type, label, link = utilities.is_wikilink (str);							-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-wl-both'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = utilities.substitute (cfg.presentation['kern-wl-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-wl-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label = mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label = mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap, cap2 = mw.ustring.match (label, &quot;^([\&quot;\'])([^\'].+)&quot;);				-- match leading double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-left'], {cap, cap2});
		end
	
		cap, cap2 = mw.ustring.match (label, &quot;^(.+[^\'])([\&quot;\'])$&quot;)				-- match trailing double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-right'], {cap, cap2});
		end
		
		if 2 == wl_type then
			str = utilities.make_wikilink (link, label);						-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin-based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate RTL languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO 639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO 639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title=, |script-chapter=, |script-&lt;periodical&gt;=

]]

local function format_script_value (script_value, script_param)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%l?%s*:') then									-- if first 3 or 4 non-space characters are script language prefix
		lang = script_value:match('^(%l%l%l?)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not utilities.is_set (lang) then
			table.insert( z.message_tail, { utilities.set_message ( 'err_script_parameter', {script_param, 'missing title part'}, true ) } );		-- prefix without 'title'; add error message
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_code_remap[lang] or mw.language.fetchLanguageName( lang, cfg.this_wiki_code );	-- get language name so that we can use it to categorize
		if utilities.is_set (name) then											-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l+%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if utilities.in_array (lang, cfg.script_lang_codes) then
				utilities.add_prop_cat ('script_with_name', {name, lang})
			else
				table.insert( z.message_tail, { utilities.set_message ( 'err_script_parameter', {script_param, 'unknown language code'}, true ) } );	-- unknown script-language; add error message
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			table.insert( z.message_tail, { utilities.set_message ( 'err_script_parameter', {script_param, 'invalid language code'}, true ) } );		-- invalid language code; add error message
			lang = '';															-- invalid so set lang to empty string
		end
	else
		table.insert( z.message_tail, { utilities.set_message ( 'err_script_parameter', {script_param, 'missing prefix'}, true ) } );				-- no language code prefix; add error message
	end
	script_value = utilities.substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is RTL

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script value has been 
wrapped in &lt;bdi&gt; tags.
]]

local function script_concatenate (title, script, script_param)
	if utilities.is_set (script) then
		script = format_script_value (script, script_param);					-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; returns empty string on error
		if utilities.is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not utilities.is_set ( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return utilities.substitute ( msg, str );								-- including template text
	else
		return utilities.substitute ( cfg.messages[key], str );
	end		
end


--[[----------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;-------------------

Makes a Wikisource URL from Wikisource interwiki-link.  Returns the URL and appropriate
label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;
	local wikisource_prefix = table.concat ({'https://', cfg.this_wiki_code, '.wikisource.org/wiki/'});

	wl_type, D, L = utilities.is_wikilink (str);								-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 1 == wl_type then													-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end

	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable URL
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent-encoding of fragment marker
	end

	return ws_url, ws_label, L or D;											-- return proper URL or nil and a label or nil
end


--[[----------------&lt; F O R M A T _ P E R I O D I C A L &gt;-----------------------

Format the three periodical parameters: |script-&lt;periodical&gt;=, |&lt;periodical&gt;=,
and |trans-&lt;periodical&gt;= into a single Periodical meta-parameter.

]]

local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)
	local periodical_error = '';

	if not utilities.is_set (periodical) then
		periodical = '';														-- to be safe for concatenation
	else
		periodical = utilities.wrap_style ('italic-title', periodical);			-- style 
	end

	periodical = script_concatenate (periodical, script_periodical, script_periodical_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (trans_periodical) then
		trans_periodical = utilities.wrap_style ('trans-italic-title', trans_periodical);
		if utilities.is_set (periodical) then
			periodical = periodical .. ' ' .. trans_periodical;
		else																	-- here when trans-periodical without periodical or script-periodical
			periodical = trans_periodical;
			periodical_error = ' ' .. utilities.set_message ('err_trans_missing_title', {'periodical'});
		end
	end

	return periodical .. periodical_error;
end


--[[------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;---------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=,
and |chapter-url= into a single chapter meta- parameter (chapter_url_source used
for error messages).

]]

local function format_chapter_title (script_chapter, script_chapter_source, chapter, chapter_source, trans_chapter, trans_chapter_source, chapter_url, chapter_url_source, no_quotes, access)
	local chapter_error = '';

	local ws_url, ws_label, L = wikisource_url_make (chapter);					-- make a wikisource URL and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', ' ');									-- replace underscore separators with space characters
		chapter = ws_label;
	end

	if not utilities.is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from module provided quote marks
			chapter = utilities.wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, script_chapter, script_chapter_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (chapter_url) then
		chapter = external_link (chapter_url, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');	-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if utilities.is_set (trans_chapter) then
		trans_chapter = utilities.wrap_style ('trans-quoted-title', trans_chapter);
		if utilities.is_set (chapter) then
			chapter = chapter .. ' ' .. trans_chapter;
		else																	-- here when trans_chapter without chapter or script-chapter
			chapter = trans_chapter;
			chapter_source = trans_chapter_source:match ('trans%-?(.+)');		-- when no chapter, get matching name from trans-&lt;param&gt;
			chapter_error = ' ' .. utilities.set_message ('err_trans_missing_title', {chapter_source});
		end
	end

	return chapter .. chapter_error;
end


--[[----------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;-------------------

This function searches a parameter's value for non-printable or invisible characters.
The search stops at the first match.

This function will detect the visible replacement character when it is part of the Wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers
(gallery, math, pre, ref) and identifies them with a slightly different error message.
See also coins_cleanup().

Output of this function is an error message that identifies the character or the
Unicode group, or the stripmarker that was detected along with its position (or,
for multi-byte characters, the position of its first byte) in the parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local stripmarker;															-- boolean set true when a stripmarker is found

	capture = string.match (v, '[%w%p ]*');										-- test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no Unicode characters
		return;
	end

	for _, invisible_char in ipairs (cfg.invisible_chars) do
		local char_name = invisible_char[1];									-- the character or group name
		local pattern = invisible_char[2];										-- the pattern used to find it
		position, _, capture = mw.ustring.find (v, pattern);					-- see if the parameter value contains characters that match the pattern
		
		if position and (cfg.invisible_defs.zwj == capture) then				-- if we found a zero-width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- it's ok if one of the Indic scripts
				position = nil;													-- unset position
			elseif cfg.emoji[mw.ustring.codepoint (v, position+1)] then			-- is zwj followed by a character listed in emoji{}?
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and utilities.in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and cfg.invisible_defs.del == capture then	-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture and not (cfg.invisible_defs.del == capture or cfg.invisible_defs.zwj == capture) then
					err_msg = capture .. ' ' .. char_name;
				else
					err_msg = char_name .. ' ' .. 'character';
				end

				table.insert (z.message_tail, {utilities.set_message ('err_invisible_char', {err_msg, utilities.wrap_style ('parameter', param), position}, true)});	-- add error message
				return;															-- and done with this parameter
			end
		end
	end
end


--[[-------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------

Argument wrapper.  This function provides support for argument mapping defined
in the configuration file so that multiple names can be transparently aliased to
single internal variable.

]]

local function argument_wrapper ( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function ( self, k )
			local dummy = self[k];												-- force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = utilities.select_one ( args, list, 'err_redundant_parameters' );
				if origin[k] == nil then
					origin[k] = '';												-- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] .. ': ' .. k);
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;-------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.
When date is DD MMMM YYYY or is MMMM DD, YYYY then wrap in nowrap span:
&lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap = '';
	local cap2 = '';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = utilities.substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = utilities.substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;---------------------

This function sets default title types (equivalent to the citation including
|type=&lt;default value&gt;) for those templates that have defaults. Also handles the
special case where it is desirable to omit the title type from the rendered citation
(|type=none).

]]

local function set_titletype (cite_class, title_type)
	if utilities.is_set (title_type) then
		if 'none' == cfg.keywords_xlate[title_type] then
			title_type = '';													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash under certain conditions.  The hyphen must separate
like items; unlike items are returned unmodified.  These forms are modified:
	letter - letter (A - B)
	digit - digit (4-5)
	digit separator digit - digit separator digit (4.1-4.5 or 4-1-4-5)
	letterdigit - letterdigit (A1-A5) (an optional separator between letter and
		digit is supported – a.1-a.5 or a-1-a-5)
	digitletter - digitletter (5a - 5d) (an optional separator between letter and
		digit is supported – 5.a-5.d or 5-a-5-d)

any other forms are returned unmodified.

str may be a comma- or semicolon-separated list

]]

local function hyphen_to_dash( str )
	if not utilities.is_set (str) then
		return str;
	end

	local accept; -- Boolean

	str = str:gsub ('&amp;[nm]dash;', {['&amp;ndash;'] = '–', ['&amp;mdash;'] = '—'});		-- replace &amp;mdash; and &amp;ndash; entities with their characters; semicolon mucks up the text.split
	str = str:gsub ('&amp;#45;', '-'); -- replace HTML numeric entity with hyphen character

	str = str:gsub ('&amp;nbsp;', ' '); -- replace &amp;nbsp; entity with generic keyboard space character
	
	local out = {};
	local list = mw.text.split (str, '%s*[,;]%s*');								-- split str at comma or semicolon separators if there are any

	for _, item in ipairs (list) do												-- for each item in the list
		item, accept = utilities.has_accept_as_written (item);					-- remove accept-this-as-written markup when it wraps all of item
		if not accept and mw.ustring.match (item, '^%w*[%.%-]?%w+%s*[%-–—]%s*%w*[%.%-]?%w+$') then	-- if a hyphenated range or has endash or emdash separators
			if item:match ('^%a+[%.%-]?%d+%s*%-%s*%a+[%.%-]?%d+$') or			-- letterdigit hyphen letterdigit (optional separator between letter and digit)
				item:match ('^%d+[%.%-]?%a+%s*%-%s*%d+[%.%-]?%a+$') or			-- digitletter hyphen digitletter (optional separator between digit and letter)
				item:match ('^%d+[%.%-]%d+%s*%-%s*%d+[%.%-]%d+$') or			-- digit separator digit hyphen digit separator digit
				item:match ('^%d+%s*%-%s*%d+$') or								-- digit hyphen digit
				item:match ('^%a+%s*%-%s*%a+$') then							-- letter hyphen letter
					item = item:gsub ('(%w*[%.%-]?%w+)%s*%-%s*(%w*[%.%-]?%w+)', '%1–%2');	-- replace hyphen, remove extraneous space characters
			else
				item = mw.ustring.gsub (item, '%s*[–—]%s*', '–');				-- for endash or emdash separated ranges, replace em with en, remove extraneous whitespace
			end
		end
		table.insert (out, item);												-- add the (possibly modified) item to the output table
	end

	local temp_str = '';														-- concatenate the output table into a comma separated string
	temp_str, accept = utilities.has_accept_as_written (table.concat (out, ', ')); -- remove accept-this-as-written markup when it wraps all of concatenated out
	if accept then
		temp_str = utilities.has_accept_as_written (str);						-- when global markup removed, return original str; do it this way to suppress boolean second return value
		return temp_str;
	else
		return temp_str;														-- else, return assembled temp_str
	end
end


--[[--------------------------&lt; S A F E _ J O I N &gt;-----------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'duplicate character'
		if 1 == #duplicate_char then											-- for single byte ASCII characters use the string library functions
			f.gsub = string.gsub
			f.match = string.match
			f.sub = string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub = mw.ustring.gsub
			f.match = mw.ustring.match
			f.sub = mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1, 1) == '&lt;' then										-- special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove HTML markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1, 1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc.?
				trim = false;
				end_chr = f.sub(str, -1, -1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr .. &quot;)&quot;				-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1, -2);									-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;''&quot; then		-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5, -1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;]]&quot; then		-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3, -1) == duplicate_char .. '&quot;]' then	-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2, -1) == duplicate_char .. &quot;]&quot; then	-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2, -1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1, -3);								-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains HTML markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows HTML markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value; 												-- add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;-----------------------------

returns true is suffix is properly formed Jr, Sr, or ordinal in the range 1–9.
Puncutation not allowed.

]]

local function is_suffix (suffix)
	if utilities.in_array (suffix, {'Jr', 'Sr', 'Jnr', 'Snr', '1st', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;-------------------

For Vancouver style, author/editor names are supposed to be rendered in Latin
(read ASCII) characters.  When a name uses characters that contain diacritical
marks, those characters are to be converted to the corresponding Latin
character. When a name is written using a non-Latin alphabet or logogram, that
name is to be transliterated into Latin characters. The module doesn't do this
so editors may/must.

This test allows |first= and |last= names to contain any of the letters defined
in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes.
	(http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;)
	or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written outside of the code editor and pasted here because the code editor
gets confused between character insertion point and cursor position. The test has
been rewritten to use decimal character escape sequence for the individual bytes
of the Unicode characters so that it is not necessary to use an external editor
to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first, suffix, position)
	if not suffix then
		if first:find ('[,%s]') then											-- when there is a space or comma, might be first name/initials + generational suffix
			first = first:match ('(.-)[,%s]+');									-- get name/initials
			suffix = first:match ('[,%s]+(.+)$');								-- get generational suffix
		end
	end
	if utilities.is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error (cfg.err_msg_supl.suffix, position);
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error (cfg.err_msg_supl['non-Latin char'], position);
			return false;														-- not a string of Latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-style=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period.
See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc.) to be rendered
as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format
because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the
Unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first, position)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just initials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error (cfg.err_msg_supl.suffix, position);			-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word

	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i], 1, 1));			-- insert the initial at end of initials table
		end
		i = i + 1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; L I S T _ P E O P L E &gt;--------------------------

Formats a list of people (authors, contributors, editors, interviewers, translators) 

names in the list will be linked when
	|&lt;name&gt;-link= has a value
	|&lt;name&gt;-mask- does NOT have a value; masked names are presumed to have been
		rendered previously so should have been linked there

when |&lt;name&gt;-mask=0, the associated name is not rendered

]]

local function list_people (control, people, etal)
	local sep;
	local namesep;
	local format = control.format;
	local maximum = control.maximum;
	local name_list = {};

	if 'vanc' == format then													-- Vancouver-like name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between names is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between names is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub (-1, -1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if utilities.is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end		-- returned 0 is for EditorCount; not used for other names
	
	for i, person in ipairs (people) do
		if utilities.is_set (person.last) then
			local mask = person.mask;
			local one;
			local sep_one = sep;

			if utilities.is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			end
			
			if mask then
				local n = tonumber (mask);										-- convert to a number if it can be converted; nil else
				if n then
					one = 0 ~= n and string.rep(&quot;&amp;mdash;&quot;, n) or nil;			-- make a string of (n &gt; 0) mdashes, nil else, to replace name
					person.link = nil;											-- don't create link to name if name is replaces with mdash string or has been set nil
				else
					one = mask;													-- replace name with mask text (must include name-list separator)
					sep_one = &quot; &quot;;												-- modify name-list separator
				end
			else
				one = person.last;												-- get surname
				local first = person.first										-- get given name
				if utilities.is_set (first) then
					if (&quot;vanc&quot; == format) then									-- if Vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first, nil, i) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials (first, i);				-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
			end
			if utilities.is_set (person.link) then
				one = utilities.make_wikilink (person.link, one);				-- link author/editor
			end
			if one then															-- if &lt;one&gt; has a value (name, mdash replacement, or mask text replacement)
				table.insert (name_list, one);									-- add it to the list of names
				table.insert (name_list, sep_one);								-- add the proper name-list separator
			end
		end
	end

	local count = #name_list / 2;												-- (number of names + number of separators) divided by 2
	if 0 &lt; count then 
		if 1 &lt; count and not etal then
			if 'amp' == format then
				name_list[#name_list-2] = &quot; &amp; &quot;;								-- replace last separator with ampersand text
			elseif 'and' == format then
				if 2 == count then
					name_list[#name_list-2] = cfg.presentation.sep_nl_and;		-- replace last separator with 'and' text
				else
					name_list[#name_list-2] = cfg.presentation.sep_nl_end;		-- replace last separator with '(sep) and' text
				end
			end
		end
		name_list[#name_list] = nil;											-- erase the last separator
	end

	local result = table.concat (name_list);									-- construct list
	if etal and utilities.is_set (result) then									-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've got a last-first list and etal so add et al.
	end
	
	return result, count;														-- return name-list string and count of number of names (count used for editor names only)
end

--[[--------------------&lt; M A K E _ C I T E R E F _ I D &gt;-----------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise
returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that
order.  year is Year or anchor_year.

]]

local function make_citeref_id (namelist, year)
	local names={};							-- a table for the one to four names and year
	for i,v in ipairs (namelist) do			-- loop through the list and take up to the first four last names
		names[i] = v.last
		if i == 4 then break end			-- if four then done
	end
	table.insert (names, year);				-- add the year at the end
	local id = table.concat(names);			-- concatenate names and year for CITEREF id
	if utilities.is_set (id) then			-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;				-- add the CITEREF portion
	else
		return '';							-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[---------------------&lt; N A M E _ H A S _ E T A L &gt;--------------------------

Evaluates the content of name parameters (author, editor, etc.) for variations on
the theme of et al.  If found, the et al. is removed, a flag is set to true and
the function returns the modified name and the flag.

This function never sets the flag to false but returns its previous state because
it may have been set by previous passes through this function or by the associated
|display-&lt;names&gt;=etal parameter

]]

local function name_has_etal (name, etal, nocat, param)

	if utilities.is_set (name) then												-- name can be nil in which case just return
		local patterns = cfg.et_al_patterns; 									-- get patterns from configuration
		
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns
			if name:match (pattern) then										-- if this 'et al' pattern is found in name
				name = name:gsub (pattern, '');									-- remove the offending text
				etal = true;													-- set flag (may have been set previously here or by |display-&lt;names&gt;=etal)
				if not nocat then												-- no categorization for |vauthors=
					table.insert( z.message_tail, {utilities.set_message ('err_etal', {param})});	-- and set an error if not added
				end
			end
		end
	end

	return name, etal;
end


--[[---------------------&lt; N A M E _ I S _ N U M E R I C &gt;----------------------

Add maint cat when name parameter value does not contain letters.  Does not catch
mixed alphanumeric names so |last=A. Green (1922-1987) does not get caught in the
current version of this test but |first=(1888) is caught.

returns nothing

]]

local function name_is_numeric (name, list_name)
	if utilities.is_set (name) then
		if mw.ustring.match (name, '^[%A]+$') then								-- when name does not contain any letters
			utilities.set_message ('maint_numeric_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
		end
	end
end


--[[-------------------&lt; N A M E _ H A S _ E D _ M A R K U P &gt;------------------

Evaluates the content of author and editor parameters for extraneous editor annotations:
ed, ed., eds, (Ed.), etc. These annotations do not belong in author parameters and
are redundant in editor parameters.  If found, the function adds the editor markup
maintenance category.

returns nothing

]]

local function name_has_ed_markup (name, list_name)
	local patterns = cfg.editor_markup_patterns;								-- get patterns from configuration

	if utilities.is_set (name) then
		for _, pattern in ipairs (patterns) do									-- spin through patterns table and
			if name:match (pattern) then
				utilities.set_message ('maint_extra_text_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
				break;
			end
		end
	end
end


--[[-----------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;------------------

Evaluates the content of last/surname (authors etc.) parameters for multiple names.
Multiple names are indicated if there is more than one comma or any &quot;unescaped&quot;
semicolons. Escaped semicolons are ones used as part of selected HTML entities.
If the condition is met, the function adds the multiple name maintenance category.

returns nothing

]]

local function name_has_mult_names (name, list_name)
	local _, commas, semicolons, nbsps;
	if utilities.is_set (name) then
		_, commas = name:gsub (',', '');										-- count the number of commas
		_, semicolons = name:gsub (';', '');									-- count the number of semicolons
		-- nbsps probably should be its own separate count rather than merged in
		-- some way with semicolons because Lua patterns do not support the
		-- grouping operator that regex does, which means there is no way to add
		-- more entities to escape except by adding more counts with the new
		-- entities
		_, nbsps = name:gsub ('&amp;nbsp;','');										-- count nbsps
		
		-- There is exactly 1 semicolon per &amp;nbsp; entity, so subtract nbsps
		-- from semicolons to 'escape' them. If additional entities are added,
		-- they also can be subtracted.
		if 1 &lt; commas or 0 &lt; (semicolons - nbsps) then
			utilities.set_message ('maint_mult_names', cfg.special_case_translation [list_name]);	-- add a maint message
		end
	end
end


--[[------------------------&lt; N A M E _ C H E C K S &gt;---------------------------

This function calls various name checking functions used to validate the content
of the various name-holding parameters.

]]

local function name_checks (last, first, list_name)
	local accept_name;

	if utilities.is_set (last) then
		last, accept_name = utilities.has_accept_as_written (last);				-- remove accept-this-as-written markup when it wraps all of &lt;last&gt;
		
		if not accept_name then													-- &lt;last&gt; not wrapped in accept-as-written markup
			name_has_mult_names (last, list_name);								-- check for multiple names in the parameter (last only)
			name_has_ed_markup (last, list_name);								-- check for extraneous 'editor' annotation
			name_is_numeric (last, list_name);									-- check for names that are composed of digits and punctuation
		end
	end

	if utilities.is_set (first) then
		first, accept_name = utilities.has_accept_as_written (first);			-- remove accept-this-as-written markup when it wraps all of &lt;first&gt;

		if not accept_name then													-- &lt;first&gt; not wrapped in accept-as-written markup
			name_has_ed_markup (first, list_name);								-- check for extraneous 'editor' annotation
			name_is_numeric (first, list_name);									-- check for names that are composed of digits and punctuation
		end
	end

	return last, first;															-- done
end


--[[----------------------&lt; E X T R A C T _ N A M E S &gt;-------------------------
Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters
(or their aliases), and their matching link and mask parameters. Stops searching
when both |lastn= and |firstn= are not found in args after two sequential attempts:
found |last1=, |last2=, and |last3= but doesn't find |last4= and |last5= then the
search is done.

This function emits an error message when there is a |firstn= without a matching
|lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not
required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.'
is stripped from the parameter and a flag (etal) returned that will cause list_people()
to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps
'et al.' out of the template's metadata.  When this occurs, an error is emitted.

]]

local function extract_names(args, list_name)
	local names = {};															-- table of names
	local last;																	-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;																-- loop counter/indexer
	local n = 1;																-- output table indexer
	local count = 0;															-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal = false;															-- return value set to true when we find some form of et al. in an author parameter

	local last_alias, first_alias, link_alias;									-- selected parameter aliases used in error messaging
	while true do
		last, last_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'err_redundant_parameters', i );		-- search through args for name components beginning at 1
		first, first_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'err_redundant_parameters', i );
		link, link_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i );
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.
		last, first = name_checks (last, first, list_name);						-- multiple names, extraneous annotation, etc. checks
		
		if first and not last then												-- if there is a firstn without a matching lastn
			local alias = first_alias:find ('given', 1, true) and 'given' or 'first';	-- get first or given form of the alias
			table.insert (z.message_tail, { utilities.set_message ( 'err_first_missing_last', {
				first_alias,													-- param name of alias missing its mate
				first_alias:gsub (alias, {['first'] = 'last', ['given'] = 'surname'}),	-- make param name appropriate to the alias form
				}, true ) } );													-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			local result;
			link = link_title_ok (link, link_alias, last, last_alias);			-- check for improper wiki-markup
			if first then
				link = link_title_ok (link, link_alias, first, first_alias);	-- check for improper wiki-markup
			end

			names[n] = {last = last, first = first, link = link, mask = mask, corporate = false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				table.insert( z.message_tail, { utilities.set_message ( 'err_missing_name', {list_name:match (&quot;(%w+)List&quot;):lower(), i - 1}, true ) } );	-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names and the etal flag
end


--[[---------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;----------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because
case of the source may be incorrect or different from the case that WikiMedia uses,
the name comparisons are done in lower case and when a match is found, the Wikimedia
version (assumed to be correct) is returned along with the code.  When there is no
match, we return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') returns a list of
languages that in some cases may include extensions. For example, code 'cbk-zam'
and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.  Most (all?) of these languages are not used a
'language' codes per se, rather they are used as sub-domain names: cbk-zam.wikipedia.org.
A list of language names and codes supported by fetchLanguageNames() can be found
at Template:Citation Style documentation/language/doc

Names that are included in the list will be found if that name is provided in the
|language= parameter.  For example, if |language=Chavacano de Zamboanga, that name
will be found with the associated code 'cbk-zam'.  When names are found and the
associated code is not two or three characters, this function returns only the
WikiMedia language name.

Some language names have multiple entries under different codes:
	Aromanian has code rup and code roa-rup
When this occurs, this function returns the language name and the 2- or 3-character code

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	if cfg.lang_name_remap[lang:lower()] then									-- if there is a remapped name (because MediaWiki uses something that we don't think is correct)
		return cfg.lang_name_remap[lang:lower()][1], cfg.lang_name_remap[lang:lower()][2];	-- for this language 'name', return a possibly new name and appropriate code
	end

	local ietf_code;															-- because some languages have both IETF-like codes and ISO 639-like codes
	local ietf_name;
	
	local langlc = mw.ustring.lower (lang);										-- lower-case version for comparisons

	for code, name in pairs (cfg.languages) do									-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower (name) then
			if 2 == #code or 3 == #code then									-- two- or three-character codes only; IETF extensions not supported
				return name, code;												-- so return the name and the code
			end
			ietf_code = code;													-- remember that we found an IETF-like code and save its name
			ietf_name = name;													-- but keep looking for a 2- or 3-char code
		end
	end
																				-- didn't find name with 2- or 3-char code; if IETF-like code found return
	return ietf_code and ietf_name or lang;										-- associated name; return original language text else
end


--[[-------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code
is recognized by MediaWiki, use the returned name; if not, then use the value that
was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is
assigned to the category for that code: Category:Norwegian-language sources (no).
For valid three-character code languages, the page is assigned to the single category
for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does
not recognize three-character equivalents of two-character codes: code 'ar' is
recognized but code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th
where the language names or codes are separated from each other by commas with
optional space characters.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki_name = mw.language.fetchLanguageName (cfg.this_wiki_code, cfg.this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang
		name = cfg.lang_code_remap[lang:lower()];								-- first see if this is a code that is not supported by MediaWiki but is in remap

		if name then															-- there was a remapped code so
			if not lang:match ('^%a%a%a?%-x%-%a+$') then						-- if not a private IETF tag
				lang = lang:gsub ('^(%a%a%a?)%-.*', '%1');						-- strip IETF tags from code
			end
		else
			lang = lang:gsub ('^(%a%a%a?)%-.*', '%1');							-- strip any IETF-like tags from code
			if 2 == lang:len() or 3 == lang:len() then							-- if two-or three-character code
				name = mw.language.fetchLanguageName (lang:lower(), cfg.this_wiki_code);	-- get language name if |language= is a proper code
			end
		end

		if utilities.is_set (name) then											-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, cfg.this_wiki_code);			-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end
	
		if utilities.is_set (code) then											-- only 2- or 3-character codes
			name = cfg.lang_code_remap[code] or name;							-- override wikimedia when they misuse language codes/names

			if cfg.this_wiki_code ~= code then									-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					utilities.add_prop_cat ('foreign_lang_source' .. code, {name, code});	-- categorize it; code appended to allow for multiple language categorization
				else															-- or is a recognized language (but has a three-character code)
					utilities.add_prop_cat ('foreign_lang_source_2' .. code, {code});		-- categorize it differently TODO: support multiple three-character code categories per cs1|2 template
				end
			elseif cfg.local_lang_cat_enable then								-- when the language and this wiki's language are the same and categorization is enabled
				utilities.add_prop_cat ('local_lang_source', {name, code});		-- categorize it
			end
		else
			utilities.set_message ('maint_unknown_lang');						-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
 
	name = utilities.make_sep_list (#language_list, language_list);

	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end

--[[-----------------------&lt; S E T _ C S _ S T Y L E &gt;--------------------------
Gets the default CS style configuration for the given mode.
Returns default separator and either postscript as passed in or the default.
In CS1, the default postscript and separator are '.'.
In CS2, the default postscript is the empty string and the default separator is ','.
]]
local function set_cs_style (postscript, mode)
	if utilities.is_set(postscript) then
		-- emit a maintenance message if user postscript is the default cs1 postscript
		-- we catch the opposite case for cs2 in set_style
		if mode == 'cs1' and postscript == cfg.presentation['ps_' .. mode] then
			utilities.set_message ('maint_postscript');
		end
	else
		postscript = cfg.presentation['ps_' .. mode];
	end
	return cfg.presentation['sep_' .. mode], postscript;
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;-----------------------------
Sets the separator and postscript styles. Checks the |mode= first and the
#invoke CitationClass second. Removes the postscript if postscript == none.
]]
local function set_style (mode, postscript, cite_class)
	local sep;
	if 'cs2' == mode then
		sep, postscript = set_cs_style (postscript, 'cs2');
	elseif 'cs1' == mode then
		sep, postscript = set_cs_style (postscript, 'cs1');
	elseif 'citation' == cite_class	then
		sep, postscript = set_cs_style (postscript, 'cs2');
	else
		sep, postscript = set_cs_style (postscript, 'cs1');
	end

	if cfg.keywords_xlate[postscript:lower()] == 'none' then
		-- emit a maintenance message if user postscript is the default cs2 postscript
		-- we catch the opposite case for cs1 in set_cs_style
		if 'cs2' == mode or 'citation' == cite_class then
			utilities.set_message ('maint_postscript');
		end
		postscript = '';
	end
	
	return sep, postscript
end

--[=[-------------------------&lt; I S _ P D F &gt;-----------------------------------

Determines if a URL has the file extension that is one of the PDF file extensions
used by [[MediaWiki:Common.css]] when applying the PDF icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or
		url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
		url:match ('%.PDF&amp;#035') or url:match ('%.pdf&amp;#035');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;-----------------------

Applies CSS style to |format=, |chapter-format=, etc.  Also emits an error message
if the format parameter does not have a matching URL parameter.  If the format parameter
is not set and the URL contains a file extension that is recognized as a PDF document
by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if utilities.is_set (format) then
		format = utilities.wrap_style ('format', format);						-- add leading space, parentheses, resize
		if not utilities.is_set (url) then
			format = format .. ' ' .. utilities.set_message ( 'err_format_missing_url', {fmt_param, url_param} );	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if URL is a PDF file then
		format = utilities.wrap_style ('format', 'PDF');						-- set format to PDF
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[---------------------&lt; G E T _ D I S P L A Y _ N A M E S &gt;------------------

Returns a number that defines the number of names displayed for author and editor
name lists and a Boolean flag to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero,
return the number and the previous state of the 'etal' flag (false by default
but may have been set to true if the name list contains some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number
that is one greater than the number of authors in the list and set the 'etal' flag true.
This will cause the list_people() to display all of the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_names (max, count, list_name, etal, param)
	if utilities.is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				table.insert( z.message_tail, {utilities.set_message ('err_disp_name', {param, max}, true)});	-- add error message
				max = nil;
			end
		else																	-- not a valid keyword or number
			table.insert( z.message_tail, {utilities.set_message ('err_disp_name', {param, max}, true)});		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[----------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;---------------

Adds error if |page=, |pages=, |quote-page=, |quote-pages= has what appears to be
some form of p. or pp. abbreviation in the first characters of the parameter content.

check page for extraneous p, p., pp, pp., pg, pg. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when page begins PX or P# but not Px
		      where x and X are letters and # is a digit
	bad pattern:  '^[Pp][PpGg]' matches when page begins pp, pP, Pp, PP, pg, pG, Pg, PG

]]

local function extra_text_in_page_check (val, name)
	if not val:match (cfg.vol_iss_pg_patterns.good_ppattern) then
		for _, pattern in ipairs (cfg.vol_iss_pg_patterns.bad_ppatterns) do		-- spin through the selected sequence table of patterns
			if val:match (pattern) then											-- when a match, error so
				table.insert (z.message_tail, {utilities.set_message ('err_extra_text_pages', {name}, true)}); -- add error message
				return;															-- and done
			end
		end
	end		
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ V O L _ I S S _ C H E C K &gt;------------------------

Adds error if |volume= or |issue= has what appears to be some form of redundant 'type' indicator.

For |volume=:
	'V.', or 'Vol.' (with or without the dot) abbreviations or 'Volume' in the first characters of the parameter
	content (all case insensitive). 'V' and 'v' (without the dot) are presumed to be roman numerals so
	are allowed.

For |issue=:
	'No.', 'I.', 'Iss.' (with or without the dot) abbreviations, or 'Issue' in the first characters of the
	parameter content (all case insensitive).
	
Single character values ('v', 'i', 'n') allowed when not followed by separator character ('.', ':', '=', or
whitespace character) – param values are trimmed of whitespace by MediaWiki before delivered to the module.
	
&lt;val&gt; is |volume= or |issue= parameter value
&lt;name&gt; is |volume= or |issue= parameter name for error message
&lt;selector&gt; is 'v' for |volume=, 'i' for |issue=

sets error message on failure; returns nothing

]]

local function extra_text_in_vol_iss_check (val, name, selector)
	if not utilities.is_set (val) then
		return;
	end
	
	local patterns = 'v' == selector and cfg.vol_iss_pg_patterns.vpatterns or cfg.vol_iss_pg_patterns.ipatterns;

	local handler = 'v' == selector and 'err_extra_text_volume' or 'err_extra_text_issue';
	val = val:lower();															-- force parameter value to lower case
	for _, pattern in ipairs (patterns) do										-- spin through the selected sequence table of patterns
		if val:match (pattern) then												-- when a match, error so
			table.insert (z.message_tail, {utilities.set_message (handler, {name}, true)}); -- add error message
			return;																-- and done
		end
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parentheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a placeholder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parentheses
			local name = name_table[i];
			i = i + 1;															-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parentheses
					break;														-- and done reassembling so
				end
				i = i + 1;														-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = utilities.is_wikilink (name_table[i]);		-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i + 1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled parentheses ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the Vancouver error when a required comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		first = '';																-- set to empty string for concatenation and because it may have been set for previous author/editor
		local accept_name;
		v_name, accept_name = utilities.has_accept_as_written (v_name);			-- remove accept-this-as-written markup when it wraps all of &lt;v_name&gt;

		if accept_name then
			last = v_name;
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error (cfg.err_msg_supl.punctuation, i);
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s+&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be initials or generational suffix

			if not mw.ustring.match (first, '^%u+$') then						-- mw.ustring here so that later we will catch non-Latin characters
				suffix = first;													-- not initials so assume that whatever we got is a generational suffix
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end
			last = table.concat(lastfirstTable, ' ')							-- returns a string that is the concatenation of all other names that are not initials and generational suffix
			if not utilities.is_set (last) then
				first = '';														-- unset
				last = v_name;													-- last empty because something wrong with first
				add_vanc_error (cfg.err_msg_supl.name, i);
			end
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error (cfg.err_msg_supl['missing comma'], i);			-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- matches a space between two initials
			end
		else
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
		
		if utilities.is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first, suffix, i);							-- check first and last before restoring the suffix which may have a non-Latin digit
			if utilities.is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '', nil, i);
			end
		end

		link = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i ) or v_link_table[i];
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate = corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest;
|editorn= (and aliases) highest and |veditors= lowest (support for |editors= withdrawn)

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
	local lastfirst = false;
	if utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice in case we have a |first1= without a |last1=; this ...
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or		-- ... also catches the case where |first= is used with |vauthors=
		utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst = true;
	end

	if (utilities.is_set (vxxxxors) and true == lastfirst) or					-- these are the three error conditions
		(utilities.is_set (vxxxxors) and utilities.is_set (xxxxors)) or
		(true == lastfirst and utilities.is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			table.insert( z.message_tail, { utilities.set_message ( 'err_redundant_parameters',
				{err_name .. '-name-list parameters'}, true ) } );				-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if utilities.is_set (vxxxxors) then return 2 end;
	if utilities.is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, live, dead, etc.).  When the parameter value has not been assigned a value (missing
or empty in the source template) the function returns the value specified by ret_val.  If the parameter value is one
of the list of allowed values returns the translated value; else, emits an error message and returns the value
specified by ret_val.

]]

local function is_valid_parameter_value (value, name, possible, ret_val)
	if not utilities.is_set (value) then
		return ret_val;															-- an empty parameter is ok
	elseif utilities.in_array (value, possible) then
		return cfg.keywords_xlate[value];										-- return translation of parameter keyword
	else
		table.insert( z.message_tail, { utilities.set_message ( 'err_invalid_param_val', {name, value}, true ) } );	-- not an allowed value so add error message
		return ret_val;
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list, -3, -1) == sepc .. '. ') then					-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list, -1, -1) == sepc) or (string.sub (name_list, -3, -1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terminate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not utilities.is_set (volume) and not utilities.is_set (issue) then
		return '';
	end
	
	if 'magazine' == cite_class or (utilities.in_array (cite_class, {'citation', 'map'}) and 'magazine' == origin) then
		if utilities.is_set (volume) and utilities.is_set (issue) then
			return wrap_msg ('vol-no', {sepc, hyphen_to_dash (volume), issue}, lower);
		elseif utilities.is_set (volume) then
			return wrap_msg ('vol', {sepc, hyphen_to_dash (volume)}, lower);
		else
			return wrap_msg ('issue', {sepc, issue}, lower);
		end
	end

	if 'podcast' == cite_class and utilities.is_set (issue) then
		return wrap_msg ('issue', {sepc, issue}, lower);
	end

	local vol = '';																-- here for all cites except magazine
		
	if utilities.is_set (volume) then
		if volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$') then			-- volume value is all digits or all uppercase Roman numerals
			vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, volume});	-- render in bold face
		elseif (4 &lt; mw.ustring.len(volume)) then								-- not all digits or Roman numerals and longer than 4 characters
			vol = utilities.substitute (cfg.messages['j-vol'], {sepc, hyphen_to_dash (volume)});	-- not bold
			utilities.add_prop_cat ('long_vol');
		else																	-- four or less characters
			vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, hyphen_to_dash (volume)});	-- bold
		end
	end
	if utilities.is_set (issue) then
		return vol .. utilities.substitute (cfg.messages['j-issue'], issue);
	end
	return vol;
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if utilities.is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif utilities.is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if utilities.is_set (page) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return utilities.substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return utilities.substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif utilities.is_set (pages) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then							-- if pages is only digits, assume a single page number
			return '', utilities.substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', utilities.substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', utilities.substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to Wikisource, returns the label portion of the interwiki-link as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki-link to an external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, page_orig, pages, pages_orig, at)
	local ws_url, ws_label, coins_pages, L;										-- for Wikisource interwiki-links; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if utilities.is_set (page) then
		if utilities.is_set (pages) or utilities.is_set (at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page, page_orig);								-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws URL from |page= interwiki link; link portion L becomes tooltip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (pages) then
		if utilities.is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages, pages_orig);							-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws URL from |pages= interwiki link; link portion L becomes tooltip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws URL from |at= interwiki link; link portion L becomes tooltip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end

--[[--------------------------&lt; I S _ U N I Q U E _ A R C H I V E _ U R L &gt;------------------------------------

add error message when |archive-url= value is same as |url= or chapter-url= (or alias...) value

]]

local function is_unique_archive_url (archive, url, c_url, source, date)
	if utilities.is_set (archive) then
		if archive == url or archive == c_url then
			table.insert (z.message_tail, {utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)}, true)});	-- add error message
			return '', '';														-- unset |archive-url= and |archive-date= because same as |url= or |chapter-url=
		end
	end

	return archive, date;
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org URLs to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot URL or to calendar pages.  When the archive URL is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the URL.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org URL does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command URL
	|archive-url= is an archive.org URL that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org URLs:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this function may return a modified
archive URL:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the URL unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.org URL
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine URL
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command URL, we don't want to allow saving of the target page 
		err_msg = cfg.err_msg_supl.save;
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = cfg.err_msg_supl.liveweb;
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');	-- split out some of the URL parts for evaluation
		
		if not utilities.is_set (timestamp) or 14 ~= timestamp:len() then		-- path and flag optional, must have 14-digit timestamp here
			err_msg = cfg.err_msg_supl.timestamp;
			if '*' ~= flag then
				url=url:gsub ('(//web%.archive%.org/[^%d]*%d?%d?%d?%d?%d?%d?)[^/]*', '%1*', 1)	-- for preview, modify ts to be yearmo* max (0-6 digits plus splat)
			end
		elseif utilities.is_set (path) and 'web/' ~= path then					-- older archive URLs do not have the extra 'web/' path element
			err_msg = cfg.err_msg_supl.path;
		elseif utilities.is_set (flag) and not utilities.is_set (path) then		-- flag not allowed with the old form URL (without the 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		elseif utilities.is_set (flag) and not flag:match ('%a%a_') then		-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		else
			return url, date;													-- return ArchiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	table.insert( z.message_tail, { utilities.set_message ( 'err_archive_url', {err_msg}, true ) } );	-- add error message and
	if utilities.is_set (Frame:preprocess('{{REVISIONID}}')) then
		return '', '';															-- return empty strings for ArchiveURL and ArchiveDate
	else
		return url, date;														-- preview mode so return ArchiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; P L A C E _ C H E C K &gt;--------------------------------------------------------

check |place=, |publication-place=, |location= to see if these params include digits.  This function added because
many editors misuse location to specify the in-source location (|page(s)= and |at= are supposed to do that)

returns the original parameter value without modification; added maint cat when parameter value contains digits

]]

local function place_check (param_val)
	if not utilities.is_set (param_val) then									-- parameter empty or omitted
		return param_val;														-- return that empty state
	end
	
	if mw.ustring.find (param_val, '%d') then									-- not empty, are there digits in the parameter value
		utilities.set_message ('maint_location');								-- yep, add maint cat
	end
	
	return param_val;															-- and done
end


--[[--------------------------&lt; I S _ G E N E R I C _ T I T L E &gt;----------------------------------------------

compares |title= value against list of known generic title patterns.  Returns true when pattern matches; nil else

the k/v pairs in 'generic_titles' each contain two tables, one for English and one for another 'local' language
Each of those tables contain another table that holds the string or pattern (whole title or title fragment) in
index [1].  index [2] is a Boolean that tells string.find() or mw.ustring.find() to do plain-text search (true)
or a pattern search (false).  The intent of all this complexity is to make these searches as fast as possible so
that we don't run out of processing time on very large articles.

]]

local function is_generic_title (title)
	title = mw.ustring.lower(title);											-- switch title to lower case
	for _, generic_title in ipairs (cfg.special_case_translation['generic_titles']) do 	-- spin through the list of known generic title fragments
		if title:find (generic_title['en'][1], 1, generic_title['en'][2]) then
			return true;														-- found English generic title so done
		elseif generic_title['local'] then										-- to keep work load down, generic_title['local'] should be nil except when there is a local version of the generic title
			if mw.ustring.find (title, generic_title['local'][1], 1, generic_title['local'][2]) then	-- mw.ustring() because might not be Latin script
				return true;													-- found local generic title so done
			end
		end
	end
end


--[[--------------------------&lt; I S _ A R C H I V E D _ C O P Y &gt;----------------------------------------------

compares |title= to 'Archived copy' (placeholder added by bots that can't find proper title); if matches, return true; nil else

]]

local function is_archived_copy (title)
	title = mw.ustring.lower(title);											-- switch title to lower case
	if title:find (cfg.special_case_translation.archived_copy.en) then			-- if title is 'Archived copy'
		return true;
	elseif cfg.special_case_translation.archived_copy['local'] then
		if mw.ustring.find (title, cfg.special_case_translation.archived_copy['local']) then	-- mw.ustring() because might not be Latin script
			return true;
		end
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args )
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper ( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListStyle = is_valid_parameter_value (A['NameListStyle'], A:ORIGIN('NameListStyle'), cfg.keywords_lists['name-list-style'], '');
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				utilities.set_message ('maint_authors');						-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if utilities.is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], nil, args, 'EditorList');	-- support for |editors= withdrawn
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		end
	end
							
	local Chapter = A['Chapter'];												-- done here so that we have access to |contribution= from |chapter= aliases
	local Chapter_origin = A:ORIGIN ('Chapter');
	local Contribution;															-- because contribution is required for contributor(s)
		if 'contribution' == Chapter_origin then
			Contribution = Chapter;												-- get the name of the contribution
		end
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	
	if utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not utilities.is_set (Contribution) then							-- |contributor= requires |contribution=
				table.insert( z.message_tail, { utilities.set_message ( 'err_contributor_missing_required_param', 'contribution')});	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				table.insert( z.message_tail, { utilities.set_message ( 'err_contributor_missing_required_param', 'author')});	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if utilities.select_one (args, cfg.aliases['ContributorList-Last'], 'err_redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			table.insert( z.message_tail, { utilities.set_message ( 'err_contributor_ignored')});	-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	local Title = A['Title'];
	local TitleLink = A['TitleLink'];

	local auto_select = ''; -- default is auto
	local accept_link;
	TitleLink, accept_link = utilities.has_accept_as_written(TitleLink, true);	-- test for accept-this-as-written markup
	if (not accept_link) and utilities.in_array (TitleLink, {'none', 'pmc', 'doi'}) then -- check for special keywords
		auto_select = TitleLink;												-- remember selection for later
		TitleLink = '';															-- treat as if |title-link= would have been empty
	end

	TitleLink = link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wiki-markup in |title-link= or wiki-markup in |title= when |title-link= is set

	local Section = '';															-- {{cite map}} only; preset to empty string for concatenation if not used
	if 'map' == config.CitationClass and 'section' == Chapter_origin then
		Section = A['Chapter'];													-- get |section= from |chapter= alias list; |chapter= and the other aliases not supported in {{cite map}}
		Chapter = '';															-- unset for now; will be reset later from |map= if present
	end

	local Periodical = A['Periodical'];
	local Periodical_origin = '';
	if utilities.is_set (Periodical) then
		Periodical_origin = A:ORIGIN('Periodical');								-- get the name of the periodical parameter
		local i;
		Periodical, i = utilities.strip_apostrophe_markup (Periodical);			-- strip apostrophe markup so that metadata isn't contaminated 
		if i then																-- non-zero when markup was stripped so emit an error message
			table.insert( z.message_tail, {utilities.set_message ('err_apostrophe_markup', {Periodical_origin}, true)});
		end
	end

	if 'mailinglist' == config.CitationClass then								-- special case for {{cite mailing list}}
		if utilities.is_set (Periodical) and utilities.is_set (A ['MailingList']) then	-- both set emit an error
			table.insert( z.message_tail, {utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', Periodical_origin) .. ' and ' .. utilities.wrap_style ('parameter', 'mailinglist')}, true )});
		end

		Periodical = A ['MailingList'];											-- error or no, set Periodical to |mailinglist= value because this template is {{cite mailing list}}
		Periodical_origin = A:ORIGIN('MailingList');
	end

	local ScriptPeriodical = A['ScriptPeriodical'];

	-- web and news not tested for now because of 
	-- Wikipedia:Administrators%27_noticeboard#Is_there_a_semi-automated_tool_that_could_fix_these_annoying_&quot;Cite_Web&quot;_errors?
	if not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) then	-- 'periodical' templates require periodical parameter
	--	local p = {['journal'] = 'journal', ['magazine'] = 'magazine', ['news'] = 'newspaper', ['web'] = 'website'};	-- for error message
		local p = {['journal'] = 'journal', ['magazine'] = 'magazine'};			-- for error message
		if p[config.CitationClass]  then
			table.insert( z.message_tail, {utilities.set_message ('err_missing_periodical', {config.CitationClass, p[config.CitationClass]}, true)});
		end
	end
	
	local Volume;
	local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) then
			if not utilities.in_array (Periodical_origin, {'website', 'mailinglist'}) then	-- {{citation}} does not render volume for these 'periodicals'
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		elseif utilities.is_set (ScriptPeriodical) then
			if 'script-website' ~= ScriptPeriodical_origin then					-- {{citation}} does not render volume for |script-website=
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		else
			Volume = A['Volume'];												-- and does for non-'periodical' cites
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_volume) then	-- render |volume= for cs1 according to the configuration settings
		Volume = A['Volume'];
	end	
	extra_text_in_vol_iss_check (Volume, A:ORIGIN ('Volume'), 'v');	

	local Issue;
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) and utilities.in_array (Periodical_origin, {'journal', 'magazine', 'newspaper', 'periodical', 'work'}) or	-- {{citation}} renders issue for these 'periodicals'
			utilities.is_set (ScriptPeriodical) and utilities.in_array (ScriptPeriodical_origin, {'script-journal', 'script-magazine', 'script-newspaper', 'script-periodical', 'script-work'}) then -- and these 'script-periodicals'
				Issue = hyphen_to_dash (A['Issue']);
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_issue) then	-- conference &amp; map books do not support issue; {{citation}} listed here because included in settings table
		if not (utilities.in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical))) then
			Issue = hyphen_to_dash (A['Issue']);
		end
	end
	extra_text_in_vol_iss_check (Issue, A:ORIGIN ('Issue'), 'i');	

	local Page;
	local Pages;
	local At;
	if not utilities.in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = hyphen_to_dash (A['Pages']);	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = place_check (A['PublicationPlace'], A:ORIGIN('PublicationPlace'));
	local Place = place_check (A['Place'], A:ORIGIN('Place'));
	
	local PublisherName = A['PublisherName'];
	local PublisherName_origin = A:ORIGIN('PublisherName');
	if utilities.is_set (PublisherName) then
		local i = 0;
		PublisherName, i = utilities.strip_apostrophe_markup (PublisherName);	-- strip apostrophe markup so that metadata isn't contaminated; publisher is never italicized
		if i then																-- non-zero when markup was stripped so emit an error message
			table.insert( z.message_tail, {utilities.set_message ('err_apostrophe_markup', {PublisherName_origin}, true)});
		end
	end

	local Newsgroup = A['Newsgroup'];											-- TODO: strip apostrophe markup?
	local Newsgroup_origin = A:ORIGIN('Newsgroup');	

	if 'newsgroup' == config.CitationClass then
		if utilities.is_set (PublisherName) then								-- general use parameter |publisher= not allowed in cite newsgroup
			local error_text, error_state = utilities.set_message ('err_parameter_ignored', {PublisherName_origin}, true);
			if utilities.is_set (error_text) then
				table.insert( z.message_tail, {error_text, error_state} );
			end				
		end

		PublisherName = nil;													-- ensure that this parameter is unset for the time being; will be used again after COinS
	end

	local URL = A['URL']
	local UrlAccess = is_valid_parameter_value (A['UrlAccess'], A:ORIGIN('UrlAccess'), cfg.keywords_lists['url-access'], nil);
	
	if not utilities.is_set (URL) and utilities.is_set (UrlAccess) then
		UrlAccess = nil;
		table.insert( z.message_tail, { utilities.set_message ( 'err_param_access_requires_param', {'url'}, true ) } );
	end
	
	local ChapterURL = A['ChapterURL'];
	local ChapterUrlAccess = is_valid_parameter_value (A['ChapterUrlAccess'], A:ORIGIN('ChapterUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (ChapterURL) and utilities.is_set (ChapterUrlAccess) then
		ChapterUrlAccess = nil;
		table.insert( z.message_tail, { utilities.set_message ( 'err_param_access_requires_param', {A:ORIGIN('ChapterUrlAccess'):gsub ('%-access', '')}, true ) } );
	end

	local MapUrlAccess = is_valid_parameter_value (A['MapUrlAccess'], A:ORIGIN('MapUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (A['MapURL']) and utilities.is_set (MapUrlAccess) then
		MapUrlAccess = nil;
		table.insert( z.message_tail, { utilities.set_message ( 'err_param_access_requires_param', {'map-url'}, true ) } );
	end

	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local no_tracking_cats = is_valid_parameter_value (A['NoTracking'], A:ORIGIN('NoTracking'), cfg.keywords_lists['yes_true_y'], nil);

	-- check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not utilities.is_set (no_tracking_cats) then								-- ignore if we are already not going to categorize this page
		if utilities.in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _, v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end
																				-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	utilities.select_one (args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'err_redundant_parameters');	-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, A:ORIGIN('Page'), Pages, A:ORIGIN('Pages'), At);

	local NoPP = is_valid_parameter_value (A['NoPP'], A:ORIGIN('NoPP'), cfg.keywords_lists['yes_true_y'], nil);

	if utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- both |publication-place= and |place= (|location=) allowed if different
		utilities.add_prop_cat ('location test');								-- add property cat to evaluate how often PublicationPlace and Place are used together
		if PublicationPlace == Place then
			Place = '';															-- unset; don't need both if they are the same
		end
	elseif not utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- when only |place= (|location=) is set ...
		PublicationPlace = Place;												-- promote |place= (|location=) to |publication-place
	end

	if PublicationPlace == Place then Place = ''; end							-- don't need both if they are the same
	
	local URL_origin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL_origin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ScriptChapter = A['ScriptChapter'];
	local ScriptChapter_origin = A:ORIGIN ('ScriptChapter');
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local TransChapter = A['TransChapter'];
	local TransChapter_origin = A:ORIGIN ('TransChapter');
	local TransTitle = A['TransTitle'];
	local ScriptTitle = A['ScriptTitle'];
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia= and |title= then map |title= to |article= and |encyclopedia= to |title=
		|encyclopedia= and |article= then map |encyclopedia= to |title=

		|trans-title= maps to |trans-chapter= when |title= is re-mapped
		|url= maps to |chapter-url= when |title= is remapped
	
	All other combinations of |encyclopedia=, |title=, and |article= are not modified
	
	]]

	local Encyclopedia = A['Encyclopedia'];										-- used as a flag by this module and by ~/COinS

	if utilities.is_set (Encyclopedia) then										-- emit error message when Encyclopedia set but template is other than {{cite encyclopedia}} or {{citation}}
		if 'encyclopaedia' ~= config.CitationClass and 'citation' ~= config.CitationClass then
			table.insert (z.message_tail, {utilities.set_message ('err_parameter_ignored', {A:ORIGIN ('Encyclopedia')}, true)});
			Encyclopedia = nil;													-- unset because not supported by this template
		end
	end

	if ('encyclopaedia' == config.CitationClass) or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Periodical) and utilities.is_set (Encyclopedia) then	-- when both set emit an error
			table.insert (z.message_tail, {utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', A:ORIGIN ('Encyclopedia')) .. ' and ' .. utilities.wrap_style ('parameter', Periodical_origin)}, true )});
		end

		if utilities.is_set (Encyclopedia) then
			Periodical = Encyclopedia;											-- error or no, set Periodical to Encyclopedia; allow periodical without encyclopedia
			Periodical_origin = A:ORIGIN ('Encyclopedia');
		end

		if utilities.is_set (Periodical) then									-- Periodical is set when |encyclopedia= is set
			if utilities.is_set (Title) or utilities.is_set (ScriptTitle) then
				if not utilities.is_set (Chapter) then
					Chapter = Title;											-- |encyclopedia= and |title= are set so map |title= to |article= and |encyclopedia= to |title=
					ScriptChapter = ScriptTitle;
					ScriptChapter_origin = A:ORIGIN('ScriptTitle')
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterURL_origin = URL_origin;

					ChapterUrlAccess = UrlAccess;

					if not utilities.is_set (ChapterURL) and utilities.is_set (TitleLink) then
						Chapter = utilities.make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			elseif utilities.is_set (Chapter) then								-- |title= not set
				Title = Periodical;												-- |encyclopedia= set and |article= set so map |encyclopedia= to |title=
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- special case for cite techreport.
	local ID = A['ID'];
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if utilities.is_set (A['Number']) then									-- cite techreport uses 'number', which other citations alias to 'issue'
			if not utilities.is_set (ID) then									-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				table.insert( z.message_tail, { utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'id') .. ' and ' .. utilities.wrap_style ('parameter', 'number')}, true )});
			end
		end	
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	local ChapterLink -- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local Conference = A['Conference'];
	local BookTitle = A['BookTitle'];
	local TransTitle_origin = A:ORIGIN ('TransTitle');
	if 'conference' == config.CitationClass then
		if utilities.is_set (BookTitle) then
			Chapter = Title;
			Chapter_origin = 'title';
	--		ChapterLink = TitleLink;											-- |chapter-link= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			URL_origin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			TransChapter_origin = TransTitle_origin;
			Title = BookTitle;
			Format = '';
	--		TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end
	
	-- CS1/2 mode
	local Mode = is_valid_parameter_value (A['Mode'], A:ORIGIN('Mode'), cfg.keywords_lists['mode'], '');
	-- separator character and postscript
	local sepc, PostScript = set_style (Mode:lower(), A['PostScript'], config.CitationClass);
	-- controls capitalization of certain static text
	local use_lowercase = ( sepc == ',' );
	
	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		if utilities.is_set (Chapter) then
			table.insert( z.message_tail, { utilities.set_message ( 'err_redundant_parameters', {utilities.wrap_style ('parameter', 'map') .. ' and ' .. utilities.wrap_style ('parameter', Chapter_origin)}, true ) } );	-- add error message
		end
		Chapter = A['Map'];
		Chapter_origin = A:ORIGIN('Map');
		ChapterURL = A['MapURL'];
		ChapterURL_origin = A:ORIGIN('MapURL');
		TransChapter = A['TransMap'];
		ScriptChapter = A['ScriptMap']
		ScriptChapter_origin = A:ORIGIN('ScriptMap')

		ChapterUrlAccess = MapUrlAccess;
		ChapterFormat = A['MapFormat'];

		Cartography = A['Cartography'];
		if utilities.is_set ( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if utilities.is_set ( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	local Series = A['Series'];
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local SeriesLink = A['SeriesLink'];

		SeriesLink = link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wiki-markup in |series-link= or wiki-markup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if utilities.is_set (Network) then table.insert(n, Network); end
		if utilities.is_set (Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if utilities.is_set (Season) and utilities.is_set (SeriesNumber) then	-- these are mutually exclusive so if both are set
				table.insert( z.message_tail, { utilities.set_message ( 'err_redundant_parameters', {utilities.wrap_style ('parameter', 'season') .. ' and ' .. utilities.wrap_style ('parameter', 'seriesno')}, true ) } );		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if utilities.is_set (Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if utilities.is_set (SeriesNumber) then table.insert(s, wrap_msg ('seriesnum', SeriesNumber, use_lowercase)); end
			if utilities.is_set (Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ScriptChapter_origin = A:ORIGIN('ScriptTitle');
			ChapterLink = TitleLink;											-- alias |episode-link=
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if utilities.is_set (ChapterLink) and not utilities.is_set (ChapterURL) then	-- link but not URL
				Chapter = utilities.make_wikilink (ChapterLink, Chapter);
			elseif utilities.is_set (ChapterLink) and utilities.is_set (ChapterURL) then	-- if both are set, URL links episode;
				Series = utilities.make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if utilities.is_set (Series) and utilities.is_set (SeriesLink) then
				Series = utilities.make_wikilink (SeriesLink, Series);
			end
			Series = utilities.wrap_style ('italic-title', Series);				-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- handle type parameter for those CS1 citations that have default values
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	if utilities.in_array (config.CitationClass, {&quot;AV-media-notes&quot;, &quot;interview&quot;, &quot;mailinglist&quot;, &quot;map&quot;, &quot;podcast&quot;, &quot;pressrelease&quot;, &quot;report&quot;, &quot;techreport&quot;, &quot;thesis&quot;}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if utilities.is_set (Degree) and &quot;Thesis&quot; == TitleType then				-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if utilities.is_set (TitleType) then										-- if type parameter is specified
		TitleType = utilities.substitute ( cfg.messages['type'], TitleType);	-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
	local Date = A['Date'];
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging
	local PublicationDate = A['PublicationDate'];
	local Year = A['Year'];

	if not utilities.is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not utilities.is_set (Date) and utilities.is_set (PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]

	local DF = is_valid_parameter_value (A['DF'], A:ORIGIN('DF'), cfg.keywords_lists['df'], '');
	if not utilities.is_set (DF) then
		DF = cfg.global_df;														-- local |df= if present overrides global df set by {{use xxx date}} template
	end

	local ArchiveURL;
	local ArchiveDate;
	local ArchiveFormat = A['ArchiveFormat'];

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	
	ArchiveURL, ArchiveDate = is_unique_archive_url (ArchiveURL, URL, ChapterURL, A:ORIGIN('ArchiveURL'), ArchiveDate);		-- add error message when URL or ChapterURL == ArchiveURL

	
	local AccessDate = A['AccessDate'];
	local LayDate = A['LayDate'];
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification
	local DoiBroken = A['DoiBroken'];
	local Embargo = A['Embargo'];
	local anchor_year;															-- used in the CITEREF identifier
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val = AccessDate, name = A:ORIGIN ('AccessDate')},
			['archive-date'] = {val = ArchiveDate, name = A:ORIGIN ('ArchiveDate')},
			['date'] = {val = Date, name = Date_origin},
			['doi-broken-date'] = {val = DoiBroken, name = A:ORIGIN ('DoiBroken')},
			['pmc-embargo-date'] = {val = Embargo, name = A:ORIGIN ('Embargo')},
			['lay-date'] = {val = LayDate, name = A:ORIGIN ('LayDate')},
			['publication-date'] = {val = PublicationDate, name = A:ORIGIN ('PublicationDate')},
			['year'] = {val = Year, name = A:ORIGIN ('Year')},
			};

		local error_list = {};
		anchor_year, Embargo = validation.dates(date_parameters_list, COinS_date, error_list);

-- start temporary Julian / Gregorian calendar uncertainty categorization
		if COinS_date.inter_cal_cat then
			utilities.add_prop_cat ('jul_greg_uncertainty');
		end
-- end temporary Julian / Gregorian calendar uncertainty categorization

		if utilities.is_set (Year) and utilities.is_set (Date) then				-- both |date= and |year= not normally needed; 
			validation.year_date_check (Year, A:ORIGIN ('Year'), Date, A:ORIGIN ('Date'), error_list);
		end
		
		if 0 == #error_list then												-- error free dates only; 0 when error_list is empty
			local modified = false;												-- flag
			
			if validation.edtf_transform (date_parameters_list) then			-- edtf dates to MOS compliant format
				modified = true;
			end

			if utilities.is_set (DF) then										-- if we need to reformat dates
				modified = validation.reformat_dates (date_parameters_list, DF);	-- reformat to DF format, use long month names if appropriate
			end

			if true == validation.date_hyphen_to_dash (date_parameters_list) then	-- convert hyphens to dashes where appropriate
				modified = true;
				utilities.set_message ('maint_date_format');					-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language,
	-- uncomment the next three lines.  Not supported by en.wiki (for obvious reasons)
	-- set validation.date_name_xlate() second argument to true to translate English digits to local digits (will translate ymd dates)
	--		if validation.date_name_xlate (date_parameters_list, false) then
	--			modified = true;
	--		end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				LayDate = date_parameters_list['lay-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end
		else
			table.insert (z.message_tail, {utilities.set_message ('err_bad_date', {utilities.make_sep_list (#error_list, error_list)}, true)});	-- add this error message
		end
	end	-- end of do

	local ID_list = {};															-- sequence table of rendered identifiers
	local ID_list_coins = {};													-- table of identifiers and their values from args; key is same as cfg.id_handlers's key
	local Class = A['Class'];													-- arxiv class identifier
	
	local ID_support = {
		{A['ASINTLD'], 'ASIN', 'err_asintld_missing_asin', A:ORIGIN ('ASINTLD')},				
		{DoiBroken, 'DOI', 'err_doibroken_missing_doi', A:ORIGIN ('DoiBroken')},
		{Embargo, 'PMC', 'err_embargo_missing_pmc', A:ORIGIN ('Embargo')},
		}

	ID_list, ID_list_coins = identifiers.identifier_lists_get (args, {DoiBroken = DoiBroken, ASINTLD = A['ASINTLD'], Embargo = Embargo, Class = Class}, ID_support);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite ssrn}}, before generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then
		if not utilities.is_set (ID_list_coins[config.CitationClass:upper()]) then 	-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp; |citeseerx= required for their templates
			table.insert (z.message_tail, {utilities.set_message ('err_' .. config.CitationClass .. '_missing', {}, true)});	-- add error message
		end

		Periodical = ({['arxiv'] = 'arXiv', ['biorxiv'] = 'bioRxiv', ['citeseerx'] = 'CiteSeerX', ['ssrn'] = 'Social Science Research Network'})[config.CitationClass];
	end

	-- Link the title of the work if no |url= was provided, but we have a |pmc= or a |doi= with |doi-access=free

	if config.CitationClass == &quot;journal&quot; and not utilities.is_set (URL) and not utilities.is_set (TitleLink) and not utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) then -- TODO: remove 'none' once existing citations have been switched to 'off', so 'none' can be used as token for &quot;no title&quot; instead
		if 'none' ~= cfg.keywords_xlate[auto_select] then						-- if auto-linking not disabled
 	 		if identifiers.auto_link_urls[auto_select] then						-- manual selection
		 		URL = identifiers.auto_link_urls[auto_select];					-- set URL to be the same as identifier's external link
 				URL_origin = cfg.id_handlers[auto_select:upper()].parameters[1];	-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['pmc'] then						-- auto-select PMC
				URL = identifiers.auto_link_urls['pmc'];						-- set URL to be the same as the PMC external link if not embargoed
				URL_origin = cfg.id_handlers['PMC'].parameters[1];				-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['doi'] then						-- auto-select DOI
				URL = identifiers.auto_link_urls['doi'];
				URL_origin = cfg.id_handlers['DOI'].parameters[1];
			end
 	 	end

		if utilities.is_set (URL) and utilities.is_set (AccessDate) then		-- access date requires |url=; identifier-created URL is not |url=
			table.insert( z.message_tail, { utilities.set_message ( 'err_accessdate_missing_url', {}, true ) } );	-- add an error message
			AccessDate = '';													-- unset
		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not utilities.is_set (Title) and not utilities.is_set (TransTitle) and not utilities.is_set (ScriptTitle) then	-- has special case for cite episode
		table.insert( z.message_tail, { utilities.set_message ( 'err_citation_missing_title', {'episode' == config.CitationClass and 'series' or 'title'}, true ) } );
	end

	if utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) and
			utilities.in_array (config.CitationClass, {'journal', 'citation'}) and
			(utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and
			('journal' == Periodical_origin or 'script-journal' == ScriptPeriodical_origin) then	-- special case for journal cites
				Title = '';														-- set title to empty string
				utilities.set_message ('maint_untitled');						-- add maint cat
	end

	check_for_url ({															-- add error message when any of these parameters hold a URL
		['title'] = Title,
		[A:ORIGIN('Chapter')] = Chapter,
		[Periodical_origin] = Periodical,
		[PublisherName_origin] = PublisherName
		});

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Chapter) and utilities.is_set (Title) and utilities.is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end
	
	local QuotePage = A['QuotePage'];
	local QuotePages = hyphen_to_dash (A['QuotePages']);

	-- this is the function call to COinS()
	local OCinSoutput = metadata.COinS({
		['Periodical'] = utilities.strip_apostrophe_markup (Periodical),		-- no markup in the metadata
		['Encyclopedia'] = Encyclopedia,										-- just a flag; content ignored by ~/COinS
		['Chapter'] = metadata.make_coins_title (coins_chapter, ScriptChapter),	-- Chapter and ScriptChapter stripped of bold / italic wiki-markup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = metadata.make_coins_title (coins_title, ScriptTitle),		-- Title and ScriptTitle stripped of bold / italic wiki-markup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Quarter'] = COinS_date.rftquarter,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = coins_pages or metadata.get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At, QuotePage, QuotePages}, 7)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName or Newsgroup,							-- any apostrophe markup already removed from PublisherName
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list_coins,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, and {{cite ssrn}} AFTER generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, CiteSeerX, or ssrn now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass and utilities.is_set (Newsgroup) then
		PublisherName = utilities.substitute (cfg.messages['newsgroup'], external_link( 'news:' .. Newsgroup, Newsgroup, Newsgroup_origin, nil ));
	end

	local Editors;
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	local Contributors;															-- assembled contributors name list
	local contributor_etal;
	local Translators;															-- assembled translators name list
	local translator_etal;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	local Interviewers;															
	local interviewers_list = {};					
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters
	local interviewer_etal;
	
	-- Now perform various field 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.
	do
		local last_first_list;
		local control = { 
			format = NameListStyle,												-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_names (A['DisplayEditors'], #e, 'editors', editor_etal, A:ORIGIN ('DisplayEditors'));
			Editors, EditorCount = list_people (control, e, editor_etal);

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum, interviewer_etal = get_display_names (A['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal, A:ORIGIN ('DisplayInterviewers'));
			Interviewers = list_people (control, interviewers_list, interviewer_etal);
		end
		do																		-- now do translators
			control.maximum, translator_etal = get_display_names (A['DisplayTranslators'], #t, 'translators', translator_etal, A:ORIGIN ('DisplayTranslators'));
			Translators = list_people (control, t, translator_etal);
		end
		do																		-- now do contributors
			control.maximum, contributor_etal = get_display_names (A['DisplayContributors'], #c, 'contributors', contributor_etal, A:ORIGIN ('DisplayContributors'));
			Contributors = list_people (control, c, contributor_etal);
		end
		do																		-- now do authors
			control.maximum, author_etal = get_display_names (A['DisplayAuthors'], #a, 'authors', author_etal, A:ORIGIN ('DisplayAuthors'));

			last_first_list = list_people (control, a, author_etal);

			if utilities.is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors');	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if utilities.is_set (Authors) and utilities.is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not utilities.is_set (URL) then
		if utilities.in_array (config.CitationClass, {&quot;web&quot;, &quot;podcast&quot;, &quot;mailinglist&quot;}) or		-- |url= required for cite web, cite podcast, and cite mailinglist
			('citation' == config.CitationClass and ('website' == Periodical_origin or 'script-website' == ScriptPeriodical_origin)) then	-- and required for {{citation}} with |website= or |script-website=
				table.insert( z.message_tail, { utilities.set_message ( 'err_cite_web_url', {}, true ) } );
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if utilities.is_set (AccessDate) and not utilities.is_set (ChapterURL) then		-- ChapterURL may be set when URL is not set;
			table.insert( z.message_tail, { utilities.set_message ( 'err_accessdate_missing_url', {}, true ) } );
			AccessDate = '';
		end
	end

	local UrlStatus = is_valid_parameter_value (A['UrlStatus'], A:ORIGIN('UrlStatus'), cfg.keywords_lists['url-status'], '');
	local OriginalURL
	local OriginalURL_origin
	local OriginalFormat
	local OriginalAccess;
	UrlStatus = UrlStatus:lower();												-- used later when assembling archived text
	if utilities.is_set ( ArchiveURL ) then
		if utilities.is_set (ChapterURL) then 									-- if chapter-url= is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURL_origin = ChapterURL_origin;								-- name of |chapter-url= parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=

			if 'live' ~= UrlStatus then
				ChapterURL = ArchiveURL											-- swap-in the archive's URL
				ChapterURL_origin = A:ORIGIN('ArchiveURL')						-- name of |archive-url= parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived URLs
			end
		elseif utilities.is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURL_origin = URL_origin;									-- name of URL parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;

			if 'live' ~= UrlStatus then											-- if URL set then |archive-url= applies to it
				URL = ArchiveURL												-- swap-in the archive's URL
				URL_origin = A:ORIGIN('ArchiveURL')								-- name of archive URL parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived URLs
			end
 		end
	end

	if utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) then
			local chap_param;
			if utilities.is_set (Chapter) then									-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif utilities.is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif utilities.is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif utilities.is_set (ScriptChapter) then
				chap_param = ScriptChapter_origin;
			else utilities.is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if utilities.is_set (chap_param) then								-- if we found one
				table.insert( z.message_tail, { utilities.set_message ( 'err_chapter_ignored', {chap_param}, true ) } );	-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if utilities.is_set (Contribution) and 0 &lt; #c then						-- if this is a contribution with contributor(s)
			if utilities.in_array (Contribution:lower(), cfg.keywords_lists.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, ScriptChapter_origin, Chapter, Chapter_origin, TransChapter, TransChapter_origin, ChapterURL, ChapterURL_origin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if utilities.is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and utilities.is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter .. sepc .. ' ';
		elseif utilities.is_set (ChapterFormat) then							-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title
	local plain_title = false;
	local accept_title;
	Title, accept_title = utilities.has_accept_as_written (Title, true);		-- remove accept-this-as-written markup when it wraps all of &lt;Title&gt;
	if accept_title and ('' == Title) then										-- only support forced empty for now &quot;(())&quot;
		Title = cfg.messages['notitle'];										-- replace by predefined &quot;No title&quot; message
			-- TODO: utilities.set_message ( 'err_redundant_parameters', ...);	-- issue proper error message instead of muting	 
			ScriptTitle = '';													-- just mute for now	 
			TransTitle = '';													-- just mute for now
 		plain_title = true;														-- suppress text decoration for descriptive title
		utilities.set_message ('maint_untitled');								-- add maint cat
	end

	if not accept_title then -- &lt;Title&gt; not wrapped in accept-as-written markup
		if '...' == Title:sub (-3) then											-- if ellipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%' .. sepc .. '$', '');			-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end

		if utilities.is_set (ArchiveURL) and is_archived_copy (Title) then
			utilities.set_message ('maint_archived_copy');						-- add maintenance category before we modify the content of Title
		end

		if is_generic_title (Title) then
			table.insert (z.message_tail, {utilities.set_message ( 'err_generic_title', {}, true ) } );	-- set an error message
		end
	end

	if (not plain_title) and (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) or
		('map' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)))) then		-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from module provided quote marks
			Title = utilities.wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle, 'script-title');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
			TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );
	elseif plain_title or ('report' == config.CitationClass) then								-- no styling for cite report and descriptive titles (otherwise same as above)
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );				-- for cite report, use this form for trans-title
	else
		Title = utilities.wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-italic-title', TransTitle);
	end

	local TransError = &quot;&quot;;
	if utilities.is_set (TransTitle) then
		if utilities.is_set (Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			TransError = &quot; &quot; .. utilities.set_message ( 'err_trans_missing_title', {'title'} );
		end
	end

	if utilities.is_set (Title) then											-- TODO: is this the right place to be making Wikisource URLs?
		if utilities.is_set (TitleLink) and utilities.is_set (URL) then
			table.insert( z.message_tail, { utilities.set_message ( 'err_wikilink_in_url', {}, true ) } );	-- set an error message because we can't have both
			TitleLink = '';														-- unset
		end
	
		if not utilities.is_set (TitleLink) and utilities.is_set (URL) then
			Title = external_link (URL, Title, URL_origin, UrlAccess) .. TransTitle .. TransError .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif utilities.is_set (TitleLink) and not utilities.is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = utilities.make_wikilink (TitleLink, Title) .. TransTitle .. TransError;
			end
		else
			local ws_url, ws_label, L;											-- Title has italic or quote markup by the time we get here which causes is_wikilink() to return 0 (not a wikilink)
			ws_url, ws_label, L = wikisource_url_make (Title:gsub('^[\'&quot;]*(.-)[\'&quot;]*$', '%1'));	-- make ws URL from |title= interwiki link (strip italic or quote markup); link portion L becomes tooltip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle .. TransError;
			else
				Title = Title .. TransTitle .. TransError;
			end
		end
	else
		Title = TransTitle .. TransError;
	end

	if utilities.is_set (Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	local ConferenceURL_origin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	if utilities.is_set (Conference) then
		if utilities.is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURL_origin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif utilities.is_set (ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURL_origin, nil );
	end

	local Position = '';
	if not utilities.is_set (Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if utilities.is_set (Minutes) then
			if utilities.is_set (Time) then
				table.insert( z.message_tail, { utilities.set_message ( 'err_redundant_parameters', {utilities.wrap_style ('parameter', 'minutes') .. ' and ' .. utilities.wrap_style ('parameter', 'time')}, true ) } );
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if utilities.is_set (Time) then
				local TimeCaption = A['TimeCaption']
				if not utilities.is_set (TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = utilities.is_set (At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = utilities.is_set (Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Sections = A['Sections'];											-- Section (singular) is an alias of Chapter so set earlier
		local Inset = A['Inset'];
		
		if utilities.is_set ( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if utilities.is_set ( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif utilities.is_set ( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	local Others = A['Others'];
	if utilities.is_set (Others) and 0 == #a and 0 == #e then					-- add maint cat when |others= has value and used without |author=, |editor=
		if config.CitationClass == &quot;AV-media-notes&quot;
		or config.CitationClass == &quot;audio-visual&quot; then							-- special maint for AV/M which has a lot of 'false' positives right now
			utilities.set_message ('maint_others_avm')
		else
			utilities.set_message ('maint_others');
		end
	end
	Others = utilities.is_set (Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if utilities.is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if utilities.is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	local TitleNote = A['TitleNote'];
	TitleNote = utilities.is_set (TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if utilities.is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%n?%.?$') or Edition:match ('%f[%a][Ee]dition$') then -- Ed, ed, Ed., ed., Edn, edn, Edn., edn.
			table.insert( z.message_tail, { utilities.set_message ( 'err_extra_text_edition')}); -- add error
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = utilities.is_set (Series) and wrap_msg ('series', {sepc, Series}) or &quot;&quot;;	-- not the same as SeriesNum
	local Agency = A['Agency'];
	Agency = utilities.is_set (Agency) and wrap_msg ('agency', {sepc, Agency}) or &quot;&quot;;
	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	if utilities.is_set (AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = utilities.substitute (retrv_text, AccessDate);				-- add retrieved text

		AccessDate = utilities.substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if utilities.is_set (ID) then ID = sepc .. &quot; &quot; .. ID; end
	
	local Docket = A['Docket'];
   	if &quot;thesis&quot; == config.CitationClass and utilities.is_set (Docket) then
		ID = sepc .. &quot; Docket &quot; .. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and utilities.is_set (Docket) then		-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	if utilities.is_set (URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URL_origin, UrlAccess );
	end

	local Quote = A['Quote'];
	local TransQuote = A['TransQuote'];
	local ScriptQuote = A['ScriptQuote'];
	if utilities.is_set (Quote) or utilities.is_set (TransQuote) or utilities.is_set (ScriptQuote) then

		if utilities.is_set (Quote) then
			if Quote:sub(1, 1) == '&quot;' and Quote:sub(-1, -1) == '&quot;' then			-- if first and last characters of quote are quote marks
				Quote = Quote:sub(2, -2);										-- strip them off
			end
		end

		Quote = utilities.wrap_style ('quoted-text', Quote );					-- wrap in &lt;q&gt;...&lt;/q&gt; tags
	
		if utilities.is_set (ScriptQuote) then
			Quote = script_concatenate (Quote, ScriptQuote, 'script-quote');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after quote is wrapped
		end

		if utilities.is_set (TransQuote) then
			if TransQuote:sub(1, 1) == '&quot;' and TransQuote:sub(-1, -1) == '&quot;' then -- if first and last characters of |trans-quote are quote marks
				TransQuote = TransQuote:sub(2, -2); -- strip them off
			end
			Quote = Quote .. &quot; &quot; .. utilities.wrap_style ('trans-quoted-title', TransQuote );
		end

		if utilities.is_set (QuotePage) or utilities.is_set (QuotePages) then	-- add page prefix
			local quote_prefix = '';
			if utilities.is_set (QuotePage) then
				extra_text_in_page_check (QuotePage, 'quote-page');				-- add to maint cat if |quote-page= value begins with what looks like p., pp., etc.
				if not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePage}), '', '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePage}), '', '', '';
				end
			elseif utilities.is_set (QuotePages) then
				extra_text_in_page_check (QuotePages, 'quote-pages');			-- add to maint cat if |quote-pages= value begins with what looks like p., pp., etc.
				if tonumber(QuotePages) ~= nil and not NoPP then				-- if only digits, assume single page
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePages}), '', '';
				elseif not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['pp-prefix'], {sepc, QuotePages}), '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePages}), '', '';
				end
			end
                        
			Quote = quote_prefix .. &quot;: &quot; .. Quote;
		else
			Quote = sepc .. &quot; &quot; .. Quote;
		end

		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	-- We check length of PostScript here because it will have been nuked by
	-- the quote parameters. We'd otherwise emit a message even if there wasn't
	-- a displayed postscript.
	-- TODO: Should the max size (1) be configurable?
	-- TODO: Should we check a specific pattern?
	if utilities.is_set(PostScript) and mw.ustring.len(PostScript) &gt; 1 then
		utilities.set_message('maint_postscript')
	end
	
	local Archived
	if utilities.is_set (ArchiveURL) then
		local arch_text;
		if not utilities.is_set (ArchiveDate) then
			ArchiveDate = utilities.set_message ('err_archive_missing_date');
		end
		if &quot;live&quot; == UrlStatus then
			arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. utilities.substitute ( cfg.messages['archived-live'],
				{ external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil ) .. ArchiveFormat, ArchiveDate } );
			if not utilities.is_set (OriginalURL) then
				Archived = Archived .. &quot; &quot; .. utilities.set_message ('err_archive_missing_url');							   
			end
		elseif utilities.is_set (OriginalURL) then								-- UrlStatus is empty, 'dead', 'unfit', 'usurped', 'bot: unknown'
			if utilities.in_array (UrlStatus, {'unfit', 'usurped', 'bot: unknown'}) then
				arch_text = cfg.messages['archived-unfit'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. &quot; &quot; .. arch_text .. ArchiveDate;				-- format already styled
				if 'bot: unknown' == UrlStatus then
					utilities.set_message ('maint_bot_unknown');				-- and add a category if not already added
				else
					utilities.set_message ('maint_unfit');						-- and add a category if not already added
				end
			else																-- UrlStatus is empty, 'dead'
				arch_text = cfg.messages['archived-dead'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. &quot; &quot; .. utilities.substitute ( arch_text,
					{ external_link( OriginalURL, cfg.messages['original'], OriginalURL_origin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
			end	
		else																	-- OriginalUrl not set
			arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			Archived = sepc .. &quot; &quot; .. utilities.substitute ( arch_text, 
				{ utilities.set_message ('err_archive_missing_url'), ArchiveDate } );
		end
	elseif utilities.is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = &quot;&quot;
	end
	
	local Lay = '';
	local LaySource = A['LaySource'];
	local LayURL = A['LayURL'];
	local LayFormat = A['LayFormat'];
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	if utilities.is_set (LayURL) then
		if utilities.is_set (LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if utilities.is_set (LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. utilities.safe_for_italics (LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif utilities.is_set (LayFormat) then									-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	local TranscriptURL = A['TranscriptURL']
	local TranscriptFormat = A['TranscriptFormat'];
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');
	local Transcript = A['Transcript'];
	local TranscriptURL_origin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL
	if utilities.is_set (Transcript) then
		if utilities.is_set (TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURL_origin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif utilities.is_set (TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURL_origin, nil );
	end

	local Publisher;
	if utilities.is_set (PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if utilities.is_set (PublisherName) then
		if utilities.is_set (PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif utilities.is_set (PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	local TransPeriodical =  A['TransPeriodical'];
	local TransPeriodical_origin =  A:ORIGIN ('TransPeriodical');
	-- Several of the above rely upon detecting this as nil, so do it last.
	if (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical)) then
		if utilities.is_set (Title) or utilities.is_set (TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		else 
			Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		end
	end
	
	local Language = A['Language'];
	if utilities.is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc.
	else
		Language='';															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then									-- cite speech only
		TitleNote = &quot; (Speech)&quot;;												-- annotate the citation
		if utilities.is_set (Periodical) then									-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if utilities.is_set (Conference) then								-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;							-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
		if utilities.is_set (Others) then Others = safe_join ({Others, sepc .. &quot; &quot;}, sepc) end		-- add terminal punctuation &amp; space; check for dup sepc; TODO why do we need to do this here?
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (Periodical) then		-- special cases for book cites
		if utilities.is_set (Contributors) then									-- when we are citing foreword, preface, introduction, etc.
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if utilities.is_set (Chapter) then										-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif utilities.is_set (Periodical) then								-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local Via = A['Via'];
	Via = utilities.is_set (Via) and  wrap_msg ('via', Via) or '';
	local idcommon;
	if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then	-- special case for cite AV media &amp; cite episode position transcript
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, Lay, Quote }, sepc );
	else
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, Lay, Quote }, sepc );
	end
	
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	local OrigDate = A['OrigDate'];
	OrigDate = utilities.is_set (OrigDate) and wrap_msg ('origdate', OrigDate) or '';
	if utilities.is_set (Date) then
		if utilities.is_set (Authors) or utilities.is_set (Editors) then		-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date .. &quot;)&quot; .. OrigDate .. sepc .. &quot; &quot;;				-- in parentheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon, -1, -1) == sepc) then						-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigDate;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigDate;							-- Date begins with sepc
			end
		end
	end	
	if utilities.is_set (Authors) then
		if (not utilities.is_set (Date)) then									-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if utilities.is_set (Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then
					in_text = in_text:lower()									-- lowercase for cs2
				end
			end
			if EditorCount &lt;= 1 then
				post_text = &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot;;				-- be consistent with no-author, no-date case
			else
				post_text = &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot;;
			end
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Contributors) then									-- book cite and we're citing the intro, preface, etc.
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if utilities.is_set (Editors) and utilities.is_set (Date) then		-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not utilities.is_set (Date)) then								-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif utilities.is_set (Editors) then
		if utilities.is_set (Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if utilities.is_set (PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc ); 								-- Deals with italics, spaces, etc.
		text = text:sub(1, -sepc:len() - 1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite&gt; element
	local options = {};
	
	if utilities.is_set (config.CitationClass) and config.CitationClass ~= &quot;citation&quot; then
		options.class = string.format ('%s %s %s', 'citation', config.CitationClass, utilities.is_set (Mode) and Mode or 'cs1');	-- class=citation required for blue highlight when used with |ref=
	else
		options.class = string.format ('%s %s', 'citation', utilities.is_set (Mode) and Mode or 'cs2');
	end

	local Ref = A['Ref'];
	if 'harv' == Ref then														-- need to check this before setting to default
		utilities.set_message ('maint_ref_harv');								-- add maint cat to identify templates that have this now-extraneous param value
	elseif not utilities.is_set (Ref) then
		Ref = 'harv';															-- set as default when not set externally
	end
	if 'none' ~= cfg.keywords_xlate[Ref:lower()] then
		local id = Ref
		local namelist = {};													-- holds selected contributor, author, editor name list
		local year = first_set ({Year, anchor_year}, 2);						-- Year first for legacy citations and for YMD dates that require disambiguation

		if #c &gt; 0 then															-- if there is a contributor list
			namelist = c;														-- select it
		elseif #a &gt; 0 then														-- or an author list
			namelist = a;
		elseif #e &gt; 0 then														-- or an editor list
			namelist = e;
		end
		local citeref_id
		if #namelist &gt; 0 then													-- if there are names in namelist
			citeref_id = make_citeref_id (namelist, year);						-- go make the CITEREF anchor
		else
			citeref_id = '';													-- unset
		end
		if citeref_id == Ref then
			utilities.set_message ('maint_ref_duplicates_default');
		end
		if 'harv' == Ref then
			id = citeref_id
		end
		options.id = id;
	end
	
	if string.len(text:gsub(&quot;&lt;span[^&gt;/]*&gt;(.-)&lt;/span&gt;&quot;, &quot;%1&quot;):gsub(&quot;%b&lt;&gt;&quot;, &quot;&quot;)) &lt;= 2 then	-- remove &lt;span&gt; tags and other HTML-like markup; then get length of what remains
		z.error_categories = {};
		text = utilities.set_message ('err_empty_citation');
		z.message_tail = {};
	end
	
	local render = {};															-- here we collect the final bits for concatenation into the rendered citation

	if utilities.is_set (options.id) then										-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render, utilities.substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options.id), mw.text.nowiki(options.class), text}));	-- when |ref= is set
	else
		table.insert (render, utilities.substitute (cfg.presentation['cite'], {mw.text.nowiki(options.class), text}));	-- all other cases
	end		

	table.insert (render, utilities.substitute (cfg.presentation['ocins'], {OCinSoutput}));	-- append metadata to the citation

	if 0 ~= #z.message_tail then
		table.insert (render, ' ');
		for i,v in ipairs( z.message_tail ) do
			if utilities.is_set (v[1]) then
				if i == #z.message_tail then
					table.insert (render, utilities.error_comment ( v[1], v[2] ));
				else
					table.insert (render, utilities.error_comment ( v[1] .. &quot;; &quot;, v[2] ));
				end
			end
		end
	end

	if 0 ~= #z.maintenance_cats then
		local maint_msgs = {};													-- here we collect all of the maint messages
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			local maint = {};													-- here we assemble a maintenence message
			table.insert (maint, v);											-- maint msg is the category name
			table.insert (maint, ' (');											-- open the link text
			table.insert (maint, utilities.substitute (cfg.messages[':cat wikilink'], {v}));	-- add the link
			table.insert (maint, ')');											-- and close it
			table.insert (maint_msgs, table.concat (maint));					-- assemble new maint message and add it to the maint_msgs table
		end
		table.insert (render, utilities.substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs, ' ')));	-- wrap the group of maint message with proper presentation and save
	end
	
	if not no_tracking_cats then
		for _, v in ipairs( z.error_categories ) do								-- append error categories
			table.insert (render, utilities.substitute (cfg.messages['cat wikilink'], {v}));
		end
		for _, v in ipairs( z.maintenance_cats ) do								-- append maintenance categories
			table.insert (render, utilities.substitute (cfg.messages['cat wikilink'], {v}));
		end
		for _, v in ipairs( z.properties_cats ) do								-- append properties categories
			table.insert (render, utilities.substitute (cfg.messages['cat wikilink'], {v}));
		end
	end

	return table.concat (render);	
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class, empty)
	local name = tostring (name);
	local enum_name;															-- for enumerated parameters, is name with enumerator replaced with '#'
	local state;
	local function state_test (state, name)										-- local function to do testing of state values
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			if empty then return nil; end										-- empty deprecated parameters are treated as unknowns
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
		if 'discouraged' == state then
			discouraged_parameter (name);										-- parameter is discouraged but still supported
			return true;
		end
		return nil;
	end		

	if name:find ('#') then														-- # is a cs1|2 reserved character so parameters with # not permitted
		return nil;
	end

	if utilities.in_array (cite_class, whitelist.preprint_template_list ) then	-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[name];
		if true == state_test (state, name) then return true; end

		state = whitelist.preprint_arguments[cite_class][name];					-- look in the parameter-list for the template identified by cite_class
		if true == state_test (state, name) then return true; end

																				-- limited enumerated parameters list
		enum_name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );										-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
		state = whitelist.limited_numbered_arguments[enum_name];
		if true == state_test (state, name) then return true; end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates

	if utilities.in_array (cite_class, whitelist.unique_param_template_list) then 	-- experiment for template-specific parameters for templates that accept parameters from the basic argument list
		state = whitelist.unique_arguments[cite_class][name];					-- look in the template-specific parameter-lists for the template identified by cite_class
		if true == state_test (state, name) then return true; end
	end																			-- if here, fall into general validation
		
	state = whitelist.basic_arguments[name];									-- all other templates; all normal parameters allowed
	if true == state_test (state, name) then return true; end

																				-- all enumerated parameters allowed
	enum_name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
	state = whitelist.numbered_arguments[enum_name];
	if true == state_test (state, name) then return true; end

	return false;																-- not supported because not found or name is set to nil
end


--[=[-------------------------&lt; I N T E R _ W I K I _ C H E C K &gt;----------------------------------------------

check &lt;value&gt; for inter-language interwiki-link markup.  &lt;prefix&gt; must be a MediaWiki-recognized language
code.  when these values have the form (without leading colon):
	[[&lt;prefix&gt;:link|label]] return label as plain-text
	[[&lt;prefix&gt;:link]] return &lt;prefix&gt;:link as plain-text

return value as is else

]=]

local function inter_wiki_check (parameter, value)
	local prefix = value:match ('%[%[(%a+):');									-- get an interwiki prefix if one exists
	local _;
	
	if prefix and cfg.inter_wiki_map[prefix:lower()] then						-- if prefix is in the map, needs preceding colon so
		table.insert( z.message_tail, {utilities.set_message ('err_bad_paramlink', parameter)});	-- emit an error message
		_, value, _ = utilities.is_wikilink (value);							-- extract label portion from wikilink
	end
	return value;
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe.  There are two tests made:
	{{cite ... |title=Title access-date=2016-03-17}}	-- the first parameter has a value and whitespace separates that value from the missing pipe parameter name
	{{cite ... |title=access-date=2016-03-17}}			-- the first parameter has no value (whitespace after the first = is trimmed by MediaWiki)
cs1|2 shares some parameter names with XML/HTML attributes: class=, title=, etc.  To prevent false positives XML/HTML
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (parameter, value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove XML/HTML tags because attributes: class=, title=, etc.

	capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then										-- if the capture is a valid parameter name
		table.insert( z.message_tail, {utilities.set_message ('err_missing_pipe', parameter)});
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ P U N C T &gt;--------------------------------------

look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_punc (param, value)
	if 'number' == type (param) then
		return;
	end
	
	param = param:gsub ('%d+', '#');											-- enumerated name-list mask params allow terminal punct; normalize 
	if cfg.punct_skip[param] then
		return;																	-- parameter name found in the skip table so done
	end
	
	if value:match ('[,;:]$') then
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
end


--[[--------------------------&lt; C I T A T I O N &gt;--------------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

local function citation(frame)
	Frame = frame;																-- save a copy in case we need to display an error message in preview mode
	local pframe = frame:getParent()
	local styles;
	
	if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		styles = 'Module:Citation/CS1/sandbox/styles.css';
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
		styles = 'Module:Citation/CS1/styles.css';
	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the selected cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text, error_state;

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do											-- get parameters from the {{#invoke}} frame
		config[k] = v;
	--	args[k] = v;															-- crude debug support that allows us to render a citation from module {{#invoke:}}; skips parameter validation; TODO: keep?
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	local empty_unknowns = {};													-- sequence table to hold empty unknown params for error message listing
	for k, v in pairs( pframe.args ) do											-- get parameters from the parent (template) frame
		v = mw.ustring.gsub (v, '^%s*(.-)%s*$', '%1');							-- trim leading/trailing whitespace; when v is only whitespace, becomes empty string
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				error_text = &quot;&quot;;
				if type( k ) ~= 'string' then
					-- exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text, error_state = utilities.set_message ( 'err_text_ignored', {v}, true );
					end
				elseif validate( k:lower(), config.CitationClass ) then 
					error_text, error_state = utilities.set_message ( 'err_parameter_ignored_suggest', {k, k:lower()}, true );	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if nil ~= string.find (frame:getTitle(), 'sandbox', 1, true) then			-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no capture in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = utilities.substitute (param, capture);		-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text, error_state = utilities.set_message ('err_parameter_ignored_suggest', {k, param}, true);	-- set the suggestion error message
							else
								error_text, error_state = utilities.set_message ( 'err_parameter_ignored', {k}, true );	-- suggested param not supported by this template
								v = '';											-- unset
							end
						end
					end
					if not utilities.is_set (error_text) then					-- couldn't match with a pattern, is there an explicit suggestion?						
						if (suggestions.suggestions[ k:lower() ] ~= nil) and validate (suggestions.suggestions[ k:lower() ], config.CitationClass) then
							error_text, error_state = utilities.set_message ( 'err_parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]}, true );
						else
							error_text, error_state = utilities.set_message ( 'err_parameter_ignored', {k}, true );
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
				if error_text ~= '' then
					table.insert( z.message_tail, {error_text, error_state} );
				end				
			end

			args[k] = v;														-- save this parameter and its value

		elseif not utilities.is_set (v) then									-- for empty parameters
			if not validate (k, config.CitationClass, true) then				-- is this empty parameter a valid parameter
				k = ('' == k) and '(empty string)' or k;						-- when k is empty string (or was space(s) trimmed to empty string), replace with descriptive text
				table.insert (empty_unknowns, utilities.wrap_style ('parameter', k));	-- format for error message and add to the list
			end
																				-- crude debug support that allows us to render a citation from module {{#invoke:}} TODO: keep?
	--	elseif args[k] ~= nil or (k == 'postscript') then						-- when args[k] has a value from {{#invoke}} frame (we don't normally do that)
	--		args[k] = v;														-- overwrite args[k] with empty string from pframe.args[k] (template frame); v is empty string here
		end																		-- not sure about the postscript bit; that gets handled in parameter validation; historical artifact?
	end	

	if 0 ~= #empty_unknowns then												-- create empty unknown error message
		table.insert (z.message_tail, {utilities.set_message ('err_param_unknown_empty', {
			1 == #empty_unknowns and '' or 's',
			utilities.make_sep_list (#empty_unknowns, empty_unknowns)
			}, true )});
	end

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);											-- look for invisible characters
		end
		has_extraneous_punc (k, v);												-- look for extraneous terminal punctuation in parameter values
		missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?
		args[k] = inter_wiki_check (k, v);										-- when language interwiki-linked parameter missing leading colon replace with wiki-link label
	end

	return table.concat ({
		frame:extensionTag ('templatestyles', '', {src=styles}),
		citation0( config, args)
	});
end

--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {citation = citation};</text>
      <sha1>llxiik9jlezm96f6q6dit9v5zjxt2m0</sha1>
    </revision>
    <revision>
      <id>4742</id>
      <parentid>4741</parentid>
      <timestamp>2022-01-22T14:11:27Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>update per [[Wikipedia:Village_pump_(proposals)#rfc:_shall_we_update_cs1/2?|RfC]];</comment>
      <origin>4742</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="206157" sha1="irdywuuc25u4ivt5yhd0ece4iusxk6t" xml:space="preserve">require ('Module:No globals');

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------

each of these counts against the Lua upvalue limit

]]

local validation;																-- functions in Module:Citation/CS1/Date_validation

local utilities;																-- functions in Module:Citation/CS1/Utilities
local z ={};																	-- table of tables in Module:Citation/CS1/Utilities

local identifiers;																-- functions and tables in Module:Citation/CS1/Identifiers
local metadata;																	-- functions in Module:Citation/CS1/COinS
local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;---------------

declare variables here that have page-wide scope that are not brought in from
other modules; that are created here and used here

]]

local added_deprecated_cat;														-- Boolean flag so that the category is added only once
local added_vanc_errs;															-- Boolean flag so we only emit one Vancouver error / category
local added_generic_name_errs;													-- Boolean flag so we only emit one generic name error / category and stop testing names once an error is encountered
local Frame;																	-- holds the module's frame table
local is_preview_mode;															-- true when article is in preview mode; false when using 'Preview page with this template' (previewing the module)
local is_sandbox;																-- true when using sandbox modules to render citation


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if utilities.is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a Boolean declared in page scope variables above

]]

local function add_vanc_error (source, position)
	if added_vanc_errs then return end
		
	added_vanc_errs = true;														-- note that we've added this category
	utilities.set_message ('err_vancouver', {source, position});
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a URI scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of TLDs: https://www.iana.org/domains/root/db

RFC 952 (modified by RFC 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the TLD.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a URL with a scheme) will be stripped
here.  Perhaps not necessary but retained in case it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ASCII characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the TLD) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and TLD or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%w]') then											-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at Wikisource
		return false;
	end

	local patterns = {															-- patterns that look like URLs
		'%f[%w][%w][%w%-]+[%w]%.%a%a+$',										-- three or more character hostname.hostname or hostname.tld
		'%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$',									-- internationalized domain name with ACE prefix
		'%f[%a][qxz]%.com$',													-- assigned one character .com hostname (x.com times out 2015-12-10)
		'%f[%a][iq]%.net$',														-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		'%f[%w][%w]%.%a%a$',													-- one character hostname and ccTLD (2 chars)
		'%f[%w][%w][%w]%.%a%a+$',												-- two character hostname and TLD
		'^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?',								-- IPv4 address
		}

	for _, pattern in ipairs (patterns) do										-- loop through the patterns list
		if domain:match (pattern) then
			return true;														-- if a match then we think that this thing that purports to be a URL is a URL
		end
	end

	for _, d in ipairs ({'cash', 'company', 'today', 'org'}) do					-- look for single letter second level domain names for these top level domains
		if domain:match ('%f[%w][%w]%.' .. d) then
			return true
		end
	end
	return false;																-- no matches, we don't know what this thing is
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a URL appear to be a valid URL; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if utilities.is_set (scheme) then											-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when URL is protocol-relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a URL into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following TLD) (if any) and any path(/), query(?) or fragment(#).

If protocol-relative URL, return nil scheme and domain else return nil for both scheme and domain.

When not protocol-relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Any URL that does not have news: scheme must have authority indicator (//).  TODO: are there other common schemes
like news: that don't use authority indicator?

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol-relative URL
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		if utilities.is_set (authority) then
			authority = authority:gsub ('//', '', 1);							-- replace place 1 pair of '/' with nothing;
			if utilities.is_set(authority) then									-- if anything left (1 or 3+ '/' where authority should be) then
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		else
			if not scheme:match ('^news:') then									-- except for news:..., MediaWiki won't link URLs that do not have authority indicator; TODO: a better way to do this test?
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link=, etc. for properly formatted content: no wikilinks, no URLs

Link parameters are to hold the title of a Wikipedia article, so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki URLs and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid URL (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid URL (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from URL; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid URL
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wiki-linked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

check &lt;link&gt; for inter-language interwiki-link prefix.  prefix must be a MediaWiki-recognized language
code and must begin with a colon.

]]

local function link_title_ok (link, lorig, title, torig)
local orig;
	if utilities.is_set (link) then 											-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		elseif link:match ('^%a+:') then										-- if the link is what looks like an interwiki
			local prefix = link:match ('^(%a+):'):lower();						-- get the interwiki prefix

			if cfg.inter_wiki_map[prefix] then									-- if prefix is in the map, must have preceding colon
				orig = lorig;													-- flag as error
			end
		end
	end

	if utilities.is_set (orig) then
		link = '';																-- unset
		utilities.set_message ('err_bad_paramlink', orig);						-- URL or wikilink in |title= with |title-link=;
	end
	
	return link;																-- link if ok, empty string else
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the URL into scheme and domain
portions, or for protocol-relative (//example.com) URLs, just the domain.  Use is_url() to validate the two
portions of the URL.  If both are valid, or for protocol-relative if domain is valid, return true, else false.

Because it is different from a standard URL, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper URL
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from URL;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a URL.  The test will also find external wikilinks
that use protocol-relative URLs. Also finds bare URLs.

The frontier pattern prevents a match on interwiki-links which are similar to scheme:path URLs.  The tests that
find bracketed URLs are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext. wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol-relative ext. wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare URL with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol-relative bare URL: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a URL
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list, error_list)
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a URL add an error message
			table.insert (error_list, utilities.wrap_style ('parameter', k));
		end
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		utilities.set_message ('err_wikilink_in_url', {});
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link (URL, label, source, access)
	local err_msg = '';
	local domain;
	local path;
	local base_url;

	if not utilities.is_set (label) then
		label = URL;
		if utilities.is_set (source) then
			utilities.set_message ('err_bare_url_missing_title', {utilities.wrap_style ('parameter', source)});
		else
			error (cfg.messages[&quot;bare_url_no_origin&quot;]);
		end			
	end
	if not check_url (URL) then
		utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)});
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the URL into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['['] = '%5b', [']'] = '%5d'});			-- replace '[' and ']' with their percent-encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat ({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wiki-markup URL

	if utilities.is_set (access) then											-- access level (subscription, registration, limited)
		base_url = utilities.substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end

	return base_url;
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a Boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		utilities.set_message ('err_deprecated_params', {name});				-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wiki-markup) are not kerned.

Replaces Unicode quote marks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc.; not for book titles.

]=]

local function kern_quotes (str)
	local cap = '';
	local wl_type, label, link;

	wl_type, label, link = utilities.is_wikilink (str);							-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-left'], str);
			str = utilities.substitute (cfg.presentation['kern-right'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = utilities.substitute (cfg.presentation['kern-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label = mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label = mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap = mw.ustring.match (label, &quot;^([\&quot;\'][^\'].+)&quot;);						-- match leading double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-left'], cap);
		end
	
		cap = mw.ustring.match (label, &quot;^(.+[^\'][\&quot;\'])$&quot;)						-- match trailing double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-right'], cap);
		end
		
		if 2 == wl_type then
			str = utilities.make_wikilink (link, label);						-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin-based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate RTL languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO 639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO 639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title=, |script-chapter=, |script-&lt;periodical&gt;=

]]

local function format_script_value (script_value, script_param)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%l?%s*:') then									-- if first 3 or 4 non-space characters are script language prefix
		lang = script_value:match('^(%l%l%l?)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not utilities.is_set (lang) then
			utilities.set_message ('err_script_parameter', {script_param, 'missing title part'});		-- prefix without 'title'; add error message
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_code_remap[lang] or mw.language.fetchLanguageName( lang, cfg.this_wiki_code );	-- get language name so that we can use it to categorize
		if utilities.is_set (name) then											-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l+%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if utilities.in_array (lang, cfg.script_lang_codes) then
				utilities.add_prop_cat ('script', {name, lang})
			else
				utilities.set_message ('err_script_parameter', {script_param, 'unknown language code'});	-- unknown script-language; add error message
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			utilities.set_message ('err_script_parameter', {script_param, 'invalid language code'});		-- invalid language code; add error message
			lang = '';															-- invalid so set lang to empty string
		end
	else
		utilities.set_message ('err_script_parameter', {script_param, 'missing prefix'});				-- no language code prefix; add error message
	end
	script_value = utilities.substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is RTL

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script
value has been wrapped in &lt;bdi&gt; tags.

]]

local function script_concatenate (title, script, script_param)
	if utilities.is_set (script) then
		script = format_script_value (script, script_param);					-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; returns empty string on error
		if utilities.is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not utilities.is_set ( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return utilities.substitute ( msg, str );								-- including template text
	else
		return utilities.substitute ( cfg.messages[key], str );
	end		
end


--[[----------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;-------------------

Makes a Wikisource URL from Wikisource interwiki-link.  Returns the URL and appropriate
label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;
	local wikisource_prefix = table.concat ({'https://', cfg.this_wiki_code, '.wikisource.org/wiki/'});

	wl_type, D, L = utilities.is_wikilink (str);								-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 1 == wl_type then													-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end

	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable URL
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent-encoding of fragment marker
	end

	return ws_url, ws_label, L or D;											-- return proper URL or nil and a label or nil
end


--[[----------------&lt; F O R M A T _ P E R I O D I C A L &gt;-----------------------

Format the three periodical parameters: |script-&lt;periodical&gt;=, |&lt;periodical&gt;=,
and |trans-&lt;periodical&gt;= into a single Periodical meta-parameter.

]]

local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)

	if not utilities.is_set (periodical) then
		periodical = '';														-- to be safe for concatenation
	else
		periodical = utilities.wrap_style ('italic-title', periodical);			-- style 
	end

	periodical = script_concatenate (periodical, script_periodical, script_periodical_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (trans_periodical) then
		trans_periodical = utilities.wrap_style ('trans-italic-title', trans_periodical);
		if utilities.is_set (periodical) then
			periodical = periodical .. ' ' .. trans_periodical;
		else																	-- here when trans-periodical without periodical or script-periodical
			periodical = trans_periodical;
			utilities.set_message ('err_trans_missing_title', {'periodical'});
		end
	end

	return periodical;
end


--[[------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;---------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=,
and |chapter-url= into a single chapter meta- parameter (chapter_url_source used
for error messages).

]]

local function format_chapter_title (script_chapter, script_chapter_source, chapter, chapter_source, trans_chapter, trans_chapter_source, chapter_url, chapter_url_source, no_quotes, access)
	local ws_url, ws_label, L = wikisource_url_make (chapter);					-- make a wikisource URL and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', ' ');									-- replace underscore separators with space characters
		chapter = ws_label;
	end

	if not utilities.is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from module provided quote marks
			chapter = utilities.wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, script_chapter, script_chapter_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (chapter_url) then
		chapter = external_link (chapter_url, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');	-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if utilities.is_set (trans_chapter) then
		trans_chapter = utilities.wrap_style ('trans-quoted-title', trans_chapter);
		if utilities.is_set (chapter) then
			chapter = chapter .. ' ' .. trans_chapter;
		else																	-- here when trans_chapter without chapter or script-chapter
			chapter = trans_chapter;
			chapter_source = trans_chapter_source:match ('trans%-?(.+)');		-- when no chapter, get matching name from trans-&lt;param&gt;
			utilities.set_message ('err_trans_missing_title', {chapter_source});
		end
	end

	return chapter;
end


--[[----------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;-------------------

This function searches a parameter's value for non-printable or invisible characters.
The search stops at the first match.

This function will detect the visible replacement character when it is part of the Wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers
(gallery, math, pre, ref) and identifies them with a slightly different error message.
See also coins_cleanup().

Output of this function is an error message that identifies the character or the
Unicode group, or the stripmarker that was detected along with its position (or,
for multi-byte characters, the position of its first byte) in the parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local stripmarker;															-- boolean set true when a stripmarker is found

	capture = string.match (v, '[%w%p ]*');										-- test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no Unicode characters
		return;
	end

	for _, invisible_char in ipairs (cfg.invisible_chars) do
		local char_name = invisible_char[1];									-- the character or group name
		local pattern = invisible_char[2];										-- the pattern used to find it
		position, _, capture = mw.ustring.find (v, pattern);					-- see if the parameter value contains characters that match the pattern
		
		if position and (cfg.invisible_defs.zwj == capture) then				-- if we found a zero-width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- it's ok if one of the Indic scripts
				position = nil;													-- unset position
			elseif cfg.emoji[mw.ustring.codepoint (v, position+1)] then			-- is zwj followed by a character listed in emoji{}?
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and utilities.in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and cfg.invisible_defs.del == capture then	-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture and not (cfg.invisible_defs.del == capture or cfg.invisible_defs.zwj == capture) then
					err_msg = capture .. ' ' .. char_name;
				else
					err_msg = char_name .. ' ' .. 'character';
				end

				utilities.set_message ('err_invisible_char', {err_msg, utilities.wrap_style ('parameter', param), position});	-- add error message
				return;															-- and done with this parameter
			end
		end
	end
end


--[[-------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------

Argument wrapper.  This function provides support for argument mapping defined
in the configuration file so that multiple names can be transparently aliased to
single internal variable.

]]

local function argument_wrapper ( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function ( self, k )
			local dummy = self[k];												-- force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = utilities.select_one ( args, list, 'err_redundant_parameters' );
				if origin[k] == nil then
					origin[k] = '';												-- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] .. ': ' .. k);
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;-------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.
When date is DD MMMM YYYY or is MMMM DD, YYYY then wrap in nowrap span:
&lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap = '';
	local cap2 = '';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = utilities.substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = utilities.substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;---------------------

This function sets default title types (equivalent to the citation including
|type=&lt;default value&gt;) for those templates that have defaults. Also handles the
special case where it is desirable to omit the title type from the rendered citation
(|type=none).

]]

local function set_titletype (cite_class, title_type)
	if utilities.is_set (title_type) then
		if 'none' == cfg.keywords_xlate[title_type] then
			title_type = '';													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; S A F E _ J O I N &gt;-----------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'duplicate character'
		if 1 == #duplicate_char then											-- for single byte ASCII characters use the string library functions
			f.gsub = string.gsub
			f.match = string.match
			f.sub = string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub = mw.ustring.gsub
			f.match = mw.ustring.match
			f.sub = mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1, 1) == '&lt;' then										-- special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove HTML markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1, 1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc.?
				trim = false;
				end_chr = f.sub(str, -1, -1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr .. &quot;)&quot;				-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1, -2);									-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;''&quot; then		-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5, -1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;]]&quot; then		-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3, -1) == duplicate_char .. '&quot;]' then	-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2, -1) == duplicate_char .. &quot;]&quot; then	-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2, -1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1, -3);								-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains HTML markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows HTML markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value; 												-- add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;-----------------------------

returns true if suffix is properly formed Jr, Sr, or ordinal in the range 1–9.
Puncutation not allowed.

]]

local function is_suffix (suffix)
	if utilities.in_array (suffix, {'Jr', 'Sr', 'Jnr', 'Snr', '1st', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;-------------------

For Vancouver style, author/editor names are supposed to be rendered in Latin
(read ASCII) characters.  When a name uses characters that contain diacritical
marks, those characters are to be converted to the corresponding Latin
character. When a name is written using a non-Latin alphabet or logogram, that
name is to be transliterated into Latin characters. The module doesn't do this
so editors may/must.

This test allows |first= and |last= names to contain any of the letters defined
in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes.
	(http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;)
	or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written outside of the code editor and pasted here because the code editor
gets confused between character insertion point and cursor position. The test has
been rewritten to use decimal character escape sequence for the individual bytes
of the Unicode characters so that it is not necessary to use an external editor
to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first, suffix, position)
	if not suffix then
		if first:find ('[,%s]') then											-- when there is a space or comma, might be first name/initials + generational suffix
			first = first:match ('(.-)[,%s]+');									-- get name/initials
			suffix = first:match ('[,%s]+(.+)$');								-- get generational suffix
		end
	end
	if utilities.is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error (cfg.err_msg_supl.suffix, position);
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error (cfg.err_msg_supl['non-Latin char'], position);
			return false;														-- not a string of Latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-style=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period.
See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc.) to be rendered
as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format
because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the
Unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first, position)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just initials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error (cfg.err_msg_supl.suffix, position);			-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word

	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i], 1, 1));			-- insert the initial at end of initials table
		end
		i = i + 1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; L I S T _ P E O P L E &gt;--------------------------

Formats a list of people (authors, contributors, editors, interviewers, translators) 

names in the list will be linked when
	|&lt;name&gt;-link= has a value
	|&lt;name&gt;-mask- does NOT have a value; masked names are presumed to have been
		rendered previously so should have been linked there

when |&lt;name&gt;-mask=0, the associated name is not rendered

]]

local function list_people (control, people, etal)
	local sep;
	local namesep;
	local format = control.format;
	local maximum = control.maximum;
	local name_list = {};

	if 'vanc' == format then													-- Vancouver-like name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between names is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between names is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub (-1, -1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if utilities.is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end		-- returned 0 is for EditorCount; not used for other names
	
	for i, person in ipairs (people) do
		if utilities.is_set (person.last) then
			local mask = person.mask;
			local one;
			local sep_one = sep;

			if utilities.is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			end
			
			if mask then
				local n = tonumber (mask);										-- convert to a number if it can be converted; nil else
				if n then
					one = 0 ~= n and string.rep(&quot;&amp;mdash;&quot;, n) or nil;			-- make a string of (n &gt; 0) mdashes, nil else, to replace name
					person.link = nil;											-- don't create link to name if name is replaces with mdash string or has been set nil
				else
					one = mask;													-- replace name with mask text (must include name-list separator)
					sep_one = &quot; &quot;;												-- modify name-list separator
				end
			else
				one = person.last;												-- get surname
				local first = person.first										-- get given name
				if utilities.is_set (first) then
					if (&quot;vanc&quot; == format) then									-- if Vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first, nil, i) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials (first, i);				-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
			end
			if utilities.is_set (person.link) then
				one = utilities.make_wikilink (person.link, one);				-- link author/editor
			end
			if one then															-- if &lt;one&gt; has a value (name, mdash replacement, or mask text replacement)
				table.insert (name_list, one);									-- add it to the list of names
				table.insert (name_list, sep_one);								-- add the proper name-list separator
			end
		end
	end

	local count = #name_list / 2;												-- (number of names + number of separators) divided by 2
	if 0 &lt; count then 
		if 1 &lt; count and not etal then
			if 'amp' == format then
				name_list[#name_list-2] = &quot; &amp; &quot;;								-- replace last separator with ampersand text
			elseif 'and' == format then
				if 2 == count then
					name_list[#name_list-2] = cfg.presentation.sep_nl_and;		-- replace last separator with 'and' text
				else
					name_list[#name_list-2] = cfg.presentation.sep_nl_end;		-- replace last separator with '(sep) and' text
				end
			end
		end
		name_list[#name_list] = nil;											-- erase the last separator
	end

	local result = table.concat (name_list);									-- construct list
	if etal and utilities.is_set (result) then									-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've got a last-first list and etal so add et al.
	end
	
	return result, count;														-- return name-list string and count of number of names (count used for editor names only)
end


--[[--------------------&lt; M A K E _ C I T E R E F _ I D &gt;-----------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise
returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that
order.  year is Year or anchor_year.

]]

local function make_citeref_id (namelist, year)
	local names={};							-- a table for the one to four names and year
	for i,v in ipairs (namelist) do			-- loop through the list and take up to the first four last names
		names[i] = v.last
		if i == 4 then break end			-- if four then done
	end
	table.insert (names, year);				-- add the year at the end
	local id = table.concat(names);			-- concatenate names and year for CITEREF id
	if utilities.is_set (id) then			-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;				-- add the CITEREF portion
	else
		return '';							-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; C I T E _ C L A S S _A T T R I B U T E _M A K E &gt;------------------------------

construct &lt;cite&gt; tag class attribute for this citation.

&lt;cite_class&gt; – config.CitationClass from calling template
&lt;mode&gt; – value from |mode= parameter

]]

local function cite_class_attribute_make (cite_class, mode)
	local class_t = {};
	table.insert (class_t, 'citation');											-- required for blue highlight
	if 'citation' ~= cite_class then
		table.insert (class_t, cite_class);										-- identify this template for user css
		table.insert (class_t, utilities.is_set (mode) and mode or 'cs1');		-- identify the citation style for user css or javascript
	else
		table.insert (class_t, utilities.is_set (mode) and mode or 'cs2');		-- identify the citation style for user css or javascript
	end
	for _, prop_key in ipairs (z.prop_keys_t) do
		table.insert (class_t, prop_key);										-- identify various properties for user css or javascript
	end

	return table.concat (class_t, ' ');											-- make a big string and done
end


--[[---------------------&lt; N A M E _ H A S _ E T A L &gt;--------------------------

Evaluates the content of name parameters (author, editor, etc.) for variations on
the theme of et al.  If found, the et al. is removed, a flag is set to true and
the function returns the modified name and the flag.

This function never sets the flag to false but returns its previous state because
it may have been set by previous passes through this function or by the associated
|display-&lt;names&gt;=etal parameter

]]

local function name_has_etal (name, etal, nocat, param)

	if utilities.is_set (name) then												-- name can be nil in which case just return
		local patterns = cfg.et_al_patterns; 									-- get patterns from configuration
		
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns
			if name:match (pattern) then										-- if this 'et al' pattern is found in name
				name = name:gsub (pattern, '');									-- remove the offending text
				etal = true;													-- set flag (may have been set previously here or by |display-&lt;names&gt;=etal)
				if not nocat then												-- no categorization for |vauthors=
					utilities.set_message ('err_etal', {param});				-- and set an error if not added
				end
			end
		end
	end

	return name, etal;
end


--[[---------------------&lt; N A M E _ I S _ N U M E R I C &gt;----------------------

Add maint cat when name parameter value does not contain letters.  Does not catch
mixed alphanumeric names so |last=A. Green (1922-1987) does not get caught in the
current version of this test but |first=(1888) is caught.

returns nothing

]]

local function name_is_numeric (name, list_name)
	if utilities.is_set (name) then
		if mw.ustring.match (name, '^[%A]+$') then								-- when name does not contain any letters
			utilities.set_message ('maint_numeric_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
		end
	end
end


--[[-------------------&lt; N A M E _ H A S _ E D _ M A R K U P &gt;------------------

Evaluates the content of author and editor parameters for extraneous editor annotations:
ed, ed., eds, (Ed.), etc. These annotations do not belong in author parameters and
are redundant in editor parameters.  If found, the function adds the editor markup
maintenance category.

returns nothing

]]

local function name_has_ed_markup (name, list_name)
	local patterns = cfg.editor_markup_patterns;								-- get patterns from configuration

	if utilities.is_set (name) then
		for _, pattern in ipairs (patterns) do									-- spin through patterns table and
			if name:match (pattern) then
				utilities.set_message ('maint_extra_text_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
				break;
			end
		end
	end
end


--[[-----------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;------------------

Evaluates the content of last/surname (authors etc.) parameters for multiple names.
Multiple names are indicated if there is more than one comma or any &quot;unescaped&quot;
semicolons. Escaped semicolons are ones used as part of selected HTML entities.
If the condition is met, the function adds the multiple name maintenance category.

returns nothing

]]

local function name_has_mult_names (name, list_name)
	local _, commas, semicolons, nbsps;
	if utilities.is_set (name) then
		_, commas = name:gsub (',', '');										-- count the number of commas
		_, semicolons = name:gsub (';', '');									-- count the number of semicolons
		-- nbsps probably should be its own separate count rather than merged in
		-- some way with semicolons because Lua patterns do not support the
		-- grouping operator that regex does, which means there is no way to add
		-- more entities to escape except by adding more counts with the new
		-- entities
		_, nbsps = name:gsub ('&amp;nbsp;','');										-- count nbsps
		
		-- There is exactly 1 semicolon per &amp;nbsp; entity, so subtract nbsps
		-- from semicolons to 'escape' them. If additional entities are added,
		-- they also can be subtracted.
		if 1 &lt; commas or 0 &lt; (semicolons - nbsps) then
			utilities.set_message ('maint_mult_names', cfg.special_case_translation [list_name]);	-- add a maint message
		end
	end
end


--[[--------------------------&lt; I S _ G E N E R I C &gt;----------------------------------------------------------

Compares values assigned to various parameter according to the string provided as &lt;item&gt; in the function call:
	'generic_names': |last=, |first=, |editor-last=, etc value against list of known generic name patterns
	'generic_titles': |title=
Returns true when pattern matches; nil else

The k/v pairs in cfg.special_case_translation[item] each contain two tables, one for English and one for another
'local' language.Each of those tables contain another table that holds the string or pattern (whole or fragment)
in index [1]. index [2] is a Boolean that tells string.find() or mw.ustring.find() to do plain-text search (true)
or a pattern search (false).  The intent of all this complexity is to make these searches as fast as possible so
that we don't run out of processing time on very large articles.

]]

local function is_generic (item, value)
	value = mw.ustring.lower(value);											-- switch value to lower case
	for _, generic_value in ipairs (cfg.special_case_translation[item]) do		-- spin through the list of known generic value fragments
		if value:find (generic_value['en'][1], 1, generic_value['en'][2]) then
			return true;														-- found English generic value so done
		elseif generic_value['local'] then										-- to keep work load down, generic_&lt;value&gt;['local'] should be nil except when there is a local version of the generic value
			if mw.ustring.find (value, generic_value['local'][1], 1, generic_value['local'][2]) then	-- mw.ustring() because might not be Latin script
				return true;													-- found local generic value so done
			end
		end
	end
end


--[[--------------------------&lt; N A M E _ I S _ G E N E R I C &gt;------------------------------------------------

calls is_generic() to determine if &lt;name&gt; is a 'generic name' listed in cfg.generic_names; &lt;name_alias&gt; is the
parameter name used in error messaging

]]

local function name_is_generic (name, name_alias)
	if not added_generic_name_errs  and is_generic ('generic_names', name) then
		utilities.set_message ('err_generic_name', name_alias);					-- set an error message
		added_generic_name_errs = true;
	end
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------

This function calls various name checking functions used to validate the content of the various name-holding parameters.

]]

local function name_checks (last, first, list_name, last_alias, first_alias)
	local accept_name;

	if utilities.is_set (last) then
		last, accept_name = utilities.has_accept_as_written (last);				-- remove accept-this-as-written markup when it wraps all of &lt;last&gt;

		if not accept_name then													-- &lt;last&gt; not wrapped in accept-as-written markup
			name_has_mult_names (last, list_name);								-- check for multiple names in the parameter (last only)
			name_has_ed_markup (last, list_name);								-- check for extraneous 'editor' annotation
			name_is_numeric (last, list_name);									-- check for names that are composed of digits and punctuation
			name_is_generic (last, last_alias);									-- check for names found in the generic names list
		end
	end

	if utilities.is_set (first) then
		first, accept_name = utilities.has_accept_as_written (first);			-- remove accept-this-as-written markup when it wraps all of &lt;first&gt;

		if not accept_name then													-- &lt;first&gt; not wrapped in accept-as-written markup
			name_has_ed_markup (first, list_name);								-- check for extraneous 'editor' annotation
			name_is_numeric (first, list_name);									-- check for names that are composed of digits and punctuation
			name_is_generic (first, first_alias);								-- check for names found in the generic names list
		end
		local wl_type, D = utilities.is_wikilink (first);
		if 0 ~= wl_type then
			first = D;
			utilities.set_message ('err_bad_paramlink', first_alias);
		end
	end

	return last, first;															-- done
end


--[[----------------------&lt; E X T R A C T _ N A M E S &gt;-------------------------

Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters
(or their aliases), and their matching link and mask parameters. Stops searching
when both |lastn= and |firstn= are not found in args after two sequential attempts:
found |last1=, |last2=, and |last3= but doesn't find |last4= and |last5= then the
search is done.

This function emits an error message when there is a |firstn= without a matching
|lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not
required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.'
is stripped from the parameter and a flag (etal) returned that will cause list_people()
to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps
'et al.' out of the template's metadata.  When this occurs, an error is emitted.

]]

local function extract_names(args, list_name)
	local names = {};															-- table of names
	local last;																	-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;																-- loop counter/indexer
	local n = 1;																-- output table indexer
	local count = 0;															-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal = false;															-- return value set to true when we find some form of et al. in an author parameter

	local last_alias, first_alias, link_alias;									-- selected parameter aliases used in error messaging
	while true do
		last, last_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'err_redundant_parameters', i );		-- search through args for name components beginning at 1
		first, first_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'err_redundant_parameters', i );
		link, link_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i );
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.
		last, first = name_checks (last, first, list_name, last_alias, first_alias);						-- multiple names, extraneous annotation, etc. checks

		if first and not last then												-- if there is a firstn without a matching lastn
			local alias = first_alias:find ('given', 1, true) and 'given' or 'first';	-- get first or given form of the alias
			utilities.set_message ('err_first_missing_last', {
				first_alias,													-- param name of alias missing its mate
				first_alias:gsub (alias, {['first'] = 'last', ['given'] = 'surname'}),	-- make param name appropriate to the alias form
				});																-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			local result;
			link = link_title_ok (link, link_alias, last, last_alias);			-- check for improper wiki-markup

			if first then
				link = link_title_ok (link, link_alias, first, first_alias);	-- check for improper wiki-markup
			end

			names[n] = {last = last, first = first, link = link, mask = mask, corporate = false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				utilities.set_message ('err_missing_name', {list_name:match (&quot;(%w+)List&quot;):lower(), i - 1});	-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names and the etal flag
end


--[[---------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;----------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because
case of the source may be incorrect or different from the case that WikiMedia uses,
the name comparisons are done in lower case and when a match is found, the Wikimedia
version (assumed to be correct) is returned along with the code.  When there is no
match, we return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') returns a list of
languages that in some cases may include extensions. For example, code 'cbk-zam'
and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.  Most (all?) of these languages are not used a
'language' codes per se, rather they are used as sub-domain names: cbk-zam.wikipedia.org.
A list of language names and codes supported by fetchLanguageNames() can be found
at Template:Citation Style documentation/language/doc

Names that are included in the list will be found if that name is provided in the
|language= parameter.  For example, if |language=Chavacano de Zamboanga, that name
will be found with the associated code 'cbk-zam'.  When names are found and the
associated code is not two or three characters, this function returns only the
WikiMedia language name.

Some language names have multiple entries under different codes:
	Aromanian has code rup and code roa-rup
When this occurs, this function returns the language name and the 2- or 3-character code

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	if cfg.lang_name_remap[lang:lower()] then									-- if there is a remapped name (because MediaWiki uses something that we don't think is correct)
		return cfg.lang_name_remap[lang:lower()][1], cfg.lang_name_remap[lang:lower()][2];	-- for this language 'name', return a possibly new name and appropriate code
	end

	local ietf_tag;																-- because some languages have both IETF-like tags and ISO 639-like tags
	local ietf_name;
	
	local langlc = mw.ustring.lower (lang);										-- lower-case version for comparisons

	for tag, name in pairs (cfg.languages) do									-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower (name) then
			if 2 == #tag or 3 == #tag then										-- two- or three-character tags preferred over IETF-like tags with the same name
				return name, tag;												-- found it so return the name and the tag
			end
			ietf_tag = tag;														-- remember that we found an IETF-like tag and save its name and tag
			ietf_name = name;													-- but keep looking for a 2- or 3-char tag version
		end
	end
	
	if ietf_tag and ietf_name then												-- when we didn't find name with 2- or 3-char tag but did find IETF-like tag
		return ietf_name, ietf_tag;												-- return name with IETF-like tag
	else
		return lang;															-- not found, return original language text
	end
end


--[[-------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code
is recognized by MediaWiki, use the returned name; if not, then use the value that
was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is
assigned to the category for that code: Category:Norwegian-language sources (no).
For valid three-character code languages, the page is assigned to the single category
for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does
not recognize three-character equivalents of two-character codes: code 'ar' is
recognized but code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th
where the language names or codes are separated from each other by commas with
optional space characters.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki_name = mw.language.fetchLanguageName (cfg.this_wiki_code, cfg.this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang
		name = cfg.lang_code_remap[lang:lower()];								-- first see if this is a code that is not supported by MediaWiki but is in remap

		if not name then
			name = mw.language.fetchLanguageName (lang:lower(), cfg.this_wiki_code);	-- get language name if &lt;lang&gt; is a MediaWiki known code; empty string if not known
		end

		if utilities.is_set (name) then											-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, cfg.this_wiki_code);			-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end

		if utilities.is_set (code) then
			name = cfg.lang_code_remap[code] or name;							-- override wikimedia when they misuse language codes/names

			code = code:gsub ('^(%a%a%a?)%-.*', '%1');							-- for categorization, strip any IETF-like tags from language tag

			if cfg.this_wiki_code ~= code then									-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					utilities.add_prop_cat ('foreign-lang-source', {name, code}, code);		-- categorize it; code appended to allow for multiple language categorization
				else															-- or is a recognized language (but has a three-character code)
					utilities.add_prop_cat ('foreign-lang-source-2', {code}, code);			-- categorize it differently TODO: support multiple three-character code categories per cs1|2 template
				end
			elseif cfg.local_lang_cat_enable then								-- when the language and this wiki's language are the same and categorization is enabled
				utilities.add_prop_cat ('local-lang-source', {name, code});		-- categorize it
			end
		else
			utilities.set_message ('maint_unknown_lang');						-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
 
	name = utilities.make_sep_list (#language_list, language_list);

	if this_wiki_name == name then
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[-----------------------&lt; S E T _ C S _ S T Y L E &gt;--------------------------

Gets the default CS style configuration for the given mode.
Returns default separator and either postscript as passed in or the default.
In CS1, the default postscript and separator are '.'.
In CS2, the default postscript is the empty string and the default separator is ','.

]]

local function set_cs_style (postscript, mode)
	if utilities.is_set(postscript) then
		-- emit a maintenance message if user postscript is the default cs1 postscript
		-- we catch the opposite case for cs2 in set_style
		if mode == 'cs1' and postscript == cfg.presentation['ps_' .. mode] then
			utilities.set_message ('maint_postscript');
		end
	else
		postscript = cfg.presentation['ps_' .. mode];
	end
	return cfg.presentation['sep_' .. mode], postscript;
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;-----------------------------

Sets the separator and postscript styles. Checks the |mode= first and the
#invoke CitationClass second. Removes the postscript if postscript == none.

]]

local function set_style (mode, postscript, cite_class)
	local sep;
	if 'cs2' == mode then
		sep, postscript = set_cs_style (postscript, 'cs2');
	elseif 'cs1' == mode then
		sep, postscript = set_cs_style (postscript, 'cs1');
	elseif 'citation' == cite_class	then
		sep, postscript = set_cs_style (postscript, 'cs2');
	else
		sep, postscript = set_cs_style (postscript, 'cs1');
	end

	if cfg.keywords_xlate[postscript:lower()] == 'none' then
		-- emit a maintenance message if user postscript is the default cs2 postscript
		-- we catch the opposite case for cs1 in set_cs_style
		if 'cs2' == mode or 'citation' == cite_class then
			utilities.set_message ('maint_postscript');
		end
		postscript = '';
	end
	
	return sep, postscript
end


--[=[-------------------------&lt; I S _ P D F &gt;-----------------------------------

Determines if a URL has the file extension that is one of the PDF file extensions
used by [[MediaWiki:Common.css]] when applying the PDF icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or
		url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
		url:match ('%.PDF&amp;#035') or url:match ('%.pdf&amp;#035');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;-----------------------

Applies CSS style to |format=, |chapter-format=, etc.  Also emits an error message
if the format parameter does not have a matching URL parameter.  If the format parameter
is not set and the URL contains a file extension that is recognized as a PDF document
by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if utilities.is_set (format) then
		format = utilities.wrap_style ('format', format);						-- add leading space, parentheses, resize
		if not utilities.is_set (url) then
			utilities.set_message ('err_format_missing_url', {fmt_param, url_param});	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if URL is a PDF file then
		format = utilities.wrap_style ('format', 'PDF');						-- set format to PDF
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[---------------------&lt; G E T _ D I S P L A Y _ N A M E S &gt;------------------

Returns a number that defines the number of names displayed for author and editor
name lists and a Boolean flag to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero,
return the number and the previous state of the 'etal' flag (false by default
but may have been set to true if the name list contains some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number
that is one greater than the number of authors in the list and set the 'etal' flag true.
This will cause the list_people() to display all of the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_names (max, count, list_name, etal, param)
	if utilities.is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				utilities.set_message ('err_disp_name', {param, max});			-- add error message
				max = nil;
			end
		else																	-- not a valid keyword or number
			utilities.set_message ('err_disp_name', {param, max});		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[----------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;---------------

Adds error if |page=, |pages=, |quote-page=, |quote-pages= has what appears to be
some form of p. or pp. abbreviation in the first characters of the parameter content.

check page for extraneous p, p., pp, pp., pg, pg. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when page begins PX or P# but not Px
		      where x and X are letters and # is a digit
	bad pattern:  '^[Pp][PpGg]' matches when page begins pp, pP, Pp, PP, pg, pG, Pg, PG

]]

local function extra_text_in_page_check (val, name)
	if not val:match (cfg.vol_iss_pg_patterns.good_ppattern) then
		for _, pattern in ipairs (cfg.vol_iss_pg_patterns.bad_ppatterns) do		-- spin through the selected sequence table of patterns
			if val:match (pattern) then											-- when a match, error so
				utilities.set_message ('err_extra_text_pages', name);	 		-- add error message
				return;															-- and done
			end
		end
	end		
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ V O L _ I S S _ C H E C K &gt;------------------------

Adds error if |volume= or |issue= has what appears to be some form of redundant 'type' indicator.

For |volume=:
	'V.', or 'Vol.' (with or without the dot) abbreviations or 'Volume' in the first characters of the parameter
	content (all case insensitive). 'V' and 'v' (without the dot) are presumed to be roman numerals so
	are allowed.

For |issue=:
	'No.', 'I.', 'Iss.' (with or without the dot) abbreviations, or 'Issue' in the first characters of the
	parameter content (all case insensitive).
	
Single character values ('v', 'i', 'n') allowed when not followed by separator character ('.', ':', '=', or
whitespace character) – param values are trimmed of whitespace by MediaWiki before delivered to the module.
	
&lt;val&gt; is |volume= or |issue= parameter value
&lt;name&gt; is |volume= or |issue= parameter name for error message
&lt;selector&gt; is 'v' for |volume=, 'i' for |issue=

sets error message on failure; returns nothing

]]

local function extra_text_in_vol_iss_check (val, name, selector)
	if not utilities.is_set (val) then
		return;
	end
	
	local patterns = 'v' == selector and cfg.vol_iss_pg_patterns.vpatterns or cfg.vol_iss_pg_patterns.ipatterns;

	local handler = 'v' == selector and 'err_extra_text_volume' or 'err_extra_text_issue';
	val = val:lower();															-- force parameter value to lower case
	for _, pattern in ipairs (patterns) do										-- spin through the selected sequence table of patterns
		if val:match (pattern) then												-- when a match, error so
			utilities.set_message (handler, name);								-- add error message
			return;																-- and done
		end
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parentheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a placeholder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parentheses
			local name = name_table[i];
			i = i + 1;															-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parentheses
					break;														-- and done reassembling so
				end
				i = i + 1;														-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = utilities.is_wikilink (name_table[i]);		-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i + 1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled parentheses ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the Vancouver error when a required comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		first = '';																-- set to empty string for concatenation and because it may have been set for previous author/editor
		local accept_name;
		v_name, accept_name = utilities.has_accept_as_written (v_name);			-- remove accept-this-as-written markup when it wraps all of &lt;v_name&gt;

		if accept_name then
			last = v_name;
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error (cfg.err_msg_supl.punctuation, i);
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s+&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be initials or generational suffix

			if not mw.ustring.match (first, '^%u+$') then						-- mw.ustring here so that later we will catch non-Latin characters
				suffix = first;													-- not initials so assume that whatever we got is a generational suffix
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end
			last = table.concat(lastfirstTable, ' ')							-- returns a string that is the concatenation of all other names that are not initials and generational suffix
			if not utilities.is_set (last) then
				first = '';														-- unset
				last = v_name;													-- last empty because something wrong with first
				add_vanc_error (cfg.err_msg_supl.name, i);
			end
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error (cfg.err_msg_supl['missing comma'], i);			-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- matches a space between two initials
			end
		else
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
		
		if utilities.is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first, suffix, i);							-- check first and last before restoring the suffix which may have a non-Latin digit
			if utilities.is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '', nil, i);
			end
		end

		link = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i ) or v_link_table[i];
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate = corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest;
|editorn= (and aliases) highest and |veditors= lowest (support for |editors= withdrawn)

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
	local lastfirst = false;
	if utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice in case we have a |first1= without a |last1=; this ...
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or		-- ... also catches the case where |first= is used with |vauthors=
		utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst = true;
	end

	if (utilities.is_set (vxxxxors) and true == lastfirst) or					-- these are the three error conditions
		(utilities.is_set (vxxxxors) and utilities.is_set (xxxxors)) or
		(true == lastfirst and utilities.is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			utilities.set_message ('err_redundant_parameters', err_name .. '-name-list parameters');	-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if utilities.is_set (vxxxxors) then return 2 end;
	if utilities.is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, live, dead, etc.).  When the parameter value has not been assigned a value (missing
or empty in the source template) the function returns the value specified by ret_val.  If the parameter value is one
of the list of allowed values returns the translated value; else, emits an error message and returns the value
specified by ret_val.

TODO: explain &lt;invert&gt;

]]

local function is_valid_parameter_value (value, name, possible, ret_val, invert)
	if not utilities.is_set (value) then
		return ret_val;															-- an empty parameter is ok
	end

	if (not invert and utilities.in_array (value, possible)) then				-- normal; &lt;value&gt; is in &lt;possible&gt; table
		return cfg.keywords_xlate[value];										-- return translation of parameter keyword
	elseif invert and not utilities.in_array (value, possible) then				-- invert; &lt;value&gt; is not in &lt;possible&gt; table
		return value;															-- return &lt;value&gt; as it is
	else
		utilities.set_message ('err_invalid_param_val', {name, value});			-- not an allowed value so add error message
		return ret_val;
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list, -3, -1) == sepc .. '. ') then					-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list, -1, -1) == sepc) or (string.sub (name_list, -3, -1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terminate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not utilities.is_set (volume) and not utilities.is_set (issue) then
		return '';
	end

	-- same condition as in format_pages_sheets()
	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);

	local is_numeric_vol = volume and (volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$'));	-- is only uppercase roman numerals or only digits?
	local is_long_vol = volume and (4 &lt; mw.ustring.len(volume));				-- is |volume= value longer than 4 characters?
	
	if volume and (not is_numeric_vol and is_long_vol) then						-- when not all digits or Roman numerals, is |volume= longer than 4 characters?
		utilities.add_prop_cat ('long-vol');									-- yes, add properties cat
	end

	if is_journal then															-- journal-style formatting
		local vol = '';
		
		if utilities.is_set (volume) then
			if is_numeric_vol then												-- |volume= value all digits or all uppercase Roman numerals?
				vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, volume});	-- render in bold face
			elseif is_long_vol then												-- not all digits or Roman numerals; longer than 4 characters?
				vol = utilities.substitute (cfg.messages['j-vol'], {sepc, utilities.hyphen_to_dash (volume)});	-- not bold
			else																-- four or fewer characters
				vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, utilities.hyphen_to_dash (volume)});	-- bold
			end
		end
		if utilities.is_set (issue) then
			return vol .. utilities.substitute (cfg.messages['j-issue'], issue);
		end
		return vol;
	end
	
	if 'podcast' == cite_class and utilities.is_set (issue) then
		return wrap_msg ('issue', {sepc, issue}, lower);
	end

	-- all other types of citation
	if utilities.is_set (volume) and utilities.is_set (issue) then
		return wrap_msg ('vol-no', {sepc, utilities.hyphen_to_dash (volume), issue}, lower);
	elseif utilities.is_set (volume) then
		return wrap_msg ('vol', {sepc, utilities.hyphen_to_dash (volume)}, lower);
	else
		return wrap_msg ('issue', {sepc, issue}, lower);
	end
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if utilities.is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif utilities.is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if utilities.is_set (page) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return utilities.substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return utilities.substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif utilities.is_set (pages) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then							-- if pages is only digits, assume a single page number
			return '', utilities.substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', utilities.substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', utilities.substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to Wikisource, returns the label portion of the interwiki-link as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki-link to an external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, page_orig, pages, pages_orig, at)
	local ws_url, ws_label, coins_pages, L;										-- for Wikisource interwiki-links; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if utilities.is_set (page) then
		if utilities.is_set (pages) or utilities.is_set (at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page, page_orig);								-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws URL from |page= interwiki link; link portion L becomes tooltip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (pages) then
		if utilities.is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages, pages_orig);							-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws URL from |pages= interwiki link; link portion L becomes tooltip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws URL from |at= interwiki link; link portion L becomes tooltip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end

--[[--------------------------&lt; I S _ U N I Q U E _ A R C H I V E _ U R L &gt;------------------------------------

add error message when |archive-url= value is same as |url= or chapter-url= (or alias...) value

]]

local function is_unique_archive_url (archive, url, c_url, source, date)
	if utilities.is_set (archive) then
		if archive == url or archive == c_url then
			utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)});	-- add error message
			return '', '';														-- unset |archive-url= and |archive-date= because same as |url= or |chapter-url=
		end
	end

	return archive, date;
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org URLs to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot URL or to calendar pages.  When the archive URL is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the URL.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org URL does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command URL
	|archive-url= is an archive.org URL that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org URLs:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this function may return a modified
archive URL:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the URL unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.org URL
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine URL
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command URL, we don't want to allow saving of the target page 
		err_msg = cfg.err_msg_supl.save;
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = cfg.err_msg_supl.liveweb;
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');	-- split out some of the URL parts for evaluation
		if not path then														-- malformed in some way; pattern did not match
			err_msg = cfg.err_msg_supl.timestamp;
		elseif 14 ~= timestamp:len() then										-- path and flag optional, must have 14-digit timestamp here
			err_msg = cfg.err_msg_supl.timestamp;
			if '*' ~= flag then
				local replacement = timestamp:match ('^%d%d%d%d%d%d') or timestamp:match ('^%d%d%d%d');	-- get the first 6 (YYYYMM) or first 4 digits (YYYY)
				if replacement then												-- nil if there aren't at least 4 digits (year)
					replacement = replacement .. string.rep ('0', 14 - replacement:len());	-- year or yearmo (4 or 6 digits) zero-fill to make 14-digit timestamp
					url=url:gsub ('(//web%.archive%.org/[^%d]*)%d[^/]*', '%1' .. replacement .. '*', 1)	-- for preview, modify ts to 14 digits plus splat for calendar display
				end
			end
		elseif utilities.is_set (path) and 'web/' ~= path then					-- older archive URLs do not have the extra 'web/' path element
			err_msg = cfg.err_msg_supl.path;
		elseif utilities.is_set (flag) and not utilities.is_set (path) then		-- flag not allowed with the old form URL (without the 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		elseif utilities.is_set (flag) and not flag:match ('%a%a_') then		-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		else
			return url, date;													-- return ArchiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	utilities.set_message ('err_archive_url', {err_msg});						-- add error message and

	if is_preview_mode then
		return url, date;														-- preview mode so return ArchiveURL and ArchiveDate
	else
		return '', '';															-- return empty strings for ArchiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; P L A C E _ C H E C K &gt;--------------------------------------------------------

check |place=, |publication-place=, |location= to see if these params include digits.  This function added because
many editors misuse location to specify the in-source location (|page(s)= and |at= are supposed to do that)

returns the original parameter value without modification; added maint cat when parameter value contains digits

]]

local function place_check (param_val)
	if not utilities.is_set (param_val) then									-- parameter empty or omitted
		return param_val;														-- return that empty state
	end
	
	if mw.ustring.find (param_val, '%d') then									-- not empty, are there digits in the parameter value
		utilities.set_message ('maint_location');								-- yep, add maint cat
	end
	
	return param_val;															-- and done
end


--[[--------------------------&lt; I S _ A R C H I V E D _ C O P Y &gt;----------------------------------------------

compares |title= to 'Archived copy' (placeholder added by bots that can't find proper title); if matches, return true; nil else

]]

local function is_archived_copy (title)
	title = mw.ustring.lower(title);											-- switch title to lower case
	if title:find (cfg.special_case_translation.archived_copy.en) then			-- if title is 'Archived copy'
		return true;
	elseif cfg.special_case_translation.archived_copy['local'] then
		if mw.ustring.find (title, cfg.special_case_translation.archived_copy['local']) then	-- mw.ustring() because might not be Latin script
			return true;
		end
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args )
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper ( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListStyle = is_valid_parameter_value (A['NameListStyle'], A:ORIGIN('NameListStyle'), cfg.keywords_lists['name-list-style'], '');
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				utilities.set_message ('maint_authors');						-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if utilities.is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], nil, args, 'EditorList');	-- support for |editors= withdrawn
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		end
	end
							
	local Chapter = A['Chapter'];												-- done here so that we have access to |contribution= from |chapter= aliases
	local Chapter_origin = A:ORIGIN ('Chapter');
	local Contribution;															-- because contribution is required for contributor(s)
		if 'contribution' == Chapter_origin then
			Contribution = Chapter;												-- get the name of the contribution
		end
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	
	if utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not utilities.is_set (Contribution) then							-- |contributor= requires |contribution=
				utilities.set_message ('err_contributor_missing_required_param', 'contribution');	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				utilities.set_message ('err_contributor_missing_required_param', 'author');	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if utilities.select_one (args, cfg.aliases['ContributorList-Last'], 'err_redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			utilities.set_message ('err_contributor_ignored');					-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	local Title = A['Title'];
	local TitleLink = A['TitleLink'];

	local auto_select = ''; -- default is auto
	local accept_link;
	TitleLink, accept_link = utilities.has_accept_as_written (TitleLink, true);	-- test for accept-this-as-written markup
	if (not accept_link) and utilities.in_array (TitleLink, {'none', 'pmc', 'doi'}) then -- check for special keywords
		auto_select = TitleLink;												-- remember selection for later
		TitleLink = '';															-- treat as if |title-link= would have been empty
	end

	TitleLink = link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wiki-markup in |title-link= or wiki-markup in |title= when |title-link= is set

	local Section = '';															-- {{cite map}} only; preset to empty string for concatenation if not used
	if 'map' == config.CitationClass and 'section' == Chapter_origin then
		Section = A['Chapter'];													-- get |section= from |chapter= alias list; |chapter= and the other aliases not supported in {{cite map}}
		Chapter = '';															-- unset for now; will be reset later from |map= if present
	end

	local Periodical = A['Periodical'];
	local Periodical_origin = '';
	if utilities.is_set (Periodical) then
		Periodical_origin = A:ORIGIN('Periodical');								-- get the name of the periodical parameter
		local i;
		Periodical, i = utilities.strip_apostrophe_markup (Periodical);			-- strip apostrophe markup so that metadata isn't contaminated 
		if i then																-- non-zero when markup was stripped so emit an error message
			utilities.set_message ('err_apostrophe_markup', {Periodical_origin});
		end
	end

	if 'mailinglist' == config.CitationClass then								-- special case for {{cite mailing list}}
		if utilities.is_set (Periodical) and utilities.is_set (A ['MailingList']) then	-- both set emit an error TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', Periodical_origin) .. ' and ' .. utilities.wrap_style ('parameter', 'mailinglist')});
		end

		Periodical = A ['MailingList'];											-- error or no, set Periodical to |mailinglist= value because this template is {{cite mailing list}}
		Periodical_origin = A:ORIGIN('MailingList');
	end

	local ScriptPeriodical = A['ScriptPeriodical'];

	-- web and news not tested for now because of 
	-- Wikipedia:Administrators%27_noticeboard#Is_there_a_semi-automated_tool_that_could_fix_these_annoying_&quot;Cite_Web&quot;_errors?
	if not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) then	-- 'periodical' templates require periodical parameter
	--	local p = {['journal'] = 'journal', ['magazine'] = 'magazine', ['news'] = 'newspaper', ['web'] = 'website'};	-- for error message
		local p = {['journal'] = 'journal', ['magazine'] = 'magazine'};			-- for error message
		if p[config.CitationClass]  then
			utilities.set_message ('err_missing_periodical', {config.CitationClass, p[config.CitationClass]});
		end
	end
	
	local Volume;
	local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) then
			if not utilities.in_array (Periodical_origin, {'website', 'mailinglist'}) then	-- {{citation}} does not render volume for these 'periodicals' --TODO: move 'array' to ~/Configuration
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		elseif utilities.is_set (ScriptPeriodical) then
			if 'script-website' ~= ScriptPeriodical_origin then					-- {{citation}} does not render volume for |script-website=
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		else
			Volume = A['Volume'];												-- and does for non-'periodical' cites
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_volume) then	-- render |volume= for cs1 according to the configuration settings
		Volume = A['Volume'];
	end	
	extra_text_in_vol_iss_check (Volume, A:ORIGIN ('Volume'), 'v');	

	local Issue;
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) and utilities.in_array (Periodical_origin, {'journal', 'magazine', 'newspaper', 'periodical', 'work'}) or	-- {{citation}} renders issue for these 'periodicals'--TODO: move 'array' to ~/Configuration
			utilities.is_set (ScriptPeriodical) and utilities.in_array (ScriptPeriodical_origin, {'script-journal', 'script-magazine', 'script-newspaper', 'script-periodical', 'script-work'}) then -- and these 'script-periodicals'
				Issue = utilities.hyphen_to_dash (A['Issue']);
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_issue) then	-- conference &amp; map books do not support issue; {{citation}} listed here because included in settings table
		if not (utilities.in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical))) then
			Issue = utilities.hyphen_to_dash (A['Issue']);
		end
	end
	extra_text_in_vol_iss_check (Issue, A:ORIGIN ('Issue'), 'i');	

	local Page;
	local Pages;
	local At;
	if not utilities.in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = utilities.hyphen_to_dash (A['Pages']);	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = place_check (A['PublicationPlace'], A:ORIGIN('PublicationPlace'));
	local Place = place_check (A['Place'], A:ORIGIN('Place'));
	
	local PublisherName = A['PublisherName'];
	local PublisherName_origin = A:ORIGIN('PublisherName');
	if utilities.is_set (PublisherName) then
		local i = 0;
		PublisherName, i = utilities.strip_apostrophe_markup (PublisherName);	-- strip apostrophe markup so that metadata isn't contaminated; publisher is never italicized
		if i then																-- non-zero when markup was stripped so emit an error message
			utilities.set_message ('err_apostrophe_markup', {PublisherName_origin});
		end
	end

	local Newsgroup = A['Newsgroup'];											-- TODO: strip apostrophe markup?
	local Newsgroup_origin = A:ORIGIN('Newsgroup');	

	if 'newsgroup' == config.CitationClass then
		if utilities.is_set (PublisherName) then								-- general use parameter |publisher= not allowed in cite newsgroup
			utilities.set_message ('err_parameter_ignored', {PublisherName_origin});
		end

		PublisherName = nil;													-- ensure that this parameter is unset for the time being; will be used again after COinS
	end

	local URL = A['URL'];														-- TODO: better way to do this for URL, ChapterURL, and MapURL?
	local UrlAccess = is_valid_parameter_value (A['UrlAccess'], A:ORIGIN('UrlAccess'), cfg.keywords_lists['url-access'], nil);
	
	if not utilities.is_set (URL) and utilities.is_set (UrlAccess) then
		UrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', 'url');
	end
	
	local ChapterURL = A['ChapterURL'];
	local ChapterUrlAccess = is_valid_parameter_value (A['ChapterUrlAccess'], A:ORIGIN('ChapterUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (ChapterURL) and utilities.is_set (ChapterUrlAccess) then
		ChapterUrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', {A:ORIGIN('ChapterUrlAccess'):gsub ('%-access', '')});
	end

	local MapUrlAccess = is_valid_parameter_value (A['MapUrlAccess'], A:ORIGIN('MapUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (A['MapURL']) and utilities.is_set (MapUrlAccess) then
		MapUrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', {'map-url'});
	end

	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local no_tracking_cats = is_valid_parameter_value (A['NoTracking'], A:ORIGIN('NoTracking'), cfg.keywords_lists['yes_true_y'], nil);

	-- check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not utilities.is_set (no_tracking_cats) then								-- ignore if we are already not going to categorize this page
		if utilities.in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _, v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end
																				-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	utilities.select_one (args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'err_redundant_parameters');	-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, A:ORIGIN('Page'), Pages, A:ORIGIN('Pages'), At);

	local NoPP = is_valid_parameter_value (A['NoPP'], A:ORIGIN('NoPP'), cfg.keywords_lists['yes_true_y'], nil);

	if utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- both |publication-place= and |place= (|location=) allowed if different
		utilities.add_prop_cat ('location-test');								-- add property cat to evaluate how often PublicationPlace and Place are used together
		if PublicationPlace == Place then
			Place = '';															-- unset; don't need both if they are the same
		end
	elseif not utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- when only |place= (|location=) is set ...
		PublicationPlace = Place;												-- promote |place= (|location=) to |publication-place
	end

	if PublicationPlace == Place then Place = ''; end							-- don't need both if they are the same
	
	local URL_origin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL_origin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ScriptChapter = A['ScriptChapter'];
	local ScriptChapter_origin = A:ORIGIN ('ScriptChapter');
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local TransChapter = A['TransChapter'];
	local TransChapter_origin = A:ORIGIN ('TransChapter');
	local TransTitle = A['TransTitle'];
	local ScriptTitle = A['ScriptTitle'];
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia= and |title= then map |title= to |article= and |encyclopedia= to |title=
		|encyclopedia= and |article= then map |encyclopedia= to |title=

		|trans-title= maps to |trans-chapter= when |title= is re-mapped
		|url= maps to |chapter-url= when |title= is remapped
	
	All other combinations of |encyclopedia=, |title=, and |article= are not modified
	
	]]

	local Encyclopedia = A['Encyclopedia'];										-- used as a flag by this module and by ~/COinS

	if utilities.is_set (Encyclopedia) then										-- emit error message when Encyclopedia set but template is other than {{cite encyclopedia}} or {{citation}}
		if 'encyclopaedia' ~= config.CitationClass and 'citation' ~= config.CitationClass then
			utilities.set_message ('err_parameter_ignored', {A:ORIGIN ('Encyclopedia')});
			Encyclopedia = nil;													-- unset because not supported by this template
		end
	end

	if ('encyclopaedia' == config.CitationClass) or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Periodical) and utilities.is_set (Encyclopedia) then	-- when both set emit an error TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', A:ORIGIN ('Encyclopedia')) .. ' and ' .. utilities.wrap_style ('parameter', Periodical_origin)});
		end

		if utilities.is_set (Encyclopedia) then
			Periodical = Encyclopedia;											-- error or no, set Periodical to Encyclopedia; allow periodical without encyclopedia
			Periodical_origin = A:ORIGIN ('Encyclopedia');
		end

		if utilities.is_set (Periodical) then									-- Periodical is set when |encyclopedia= is set
			if utilities.is_set (Title) or utilities.is_set (ScriptTitle) then
				if not utilities.is_set (Chapter) then
					Chapter = Title;											-- |encyclopedia= and |title= are set so map |title= to |article= and |encyclopedia= to |title=
					ScriptChapter = ScriptTitle;
					ScriptChapter_origin = A:ORIGIN('ScriptTitle')
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterURL_origin = URL_origin;

					ChapterUrlAccess = UrlAccess;

					if not utilities.is_set (ChapterURL) and utilities.is_set (TitleLink) then
						Chapter = utilities.make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			elseif utilities.is_set (Chapter) or utilities.is_set (ScriptChapter) then								-- |title= not set
				Title = Periodical;												-- |encyclopedia= set and |article= set so map |encyclopedia= to |title=
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- special case for cite techreport.
	local ID = A['ID'];
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if utilities.is_set (A['Number']) then									-- cite techreport uses 'number', which other citations alias to 'issue'
			if not utilities.is_set (ID) then									-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'id') .. ' and ' .. utilities.wrap_style ('parameter', 'number')});
			end
		end	
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	local ChapterLink -- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local Conference = A['Conference'];
	local BookTitle = A['BookTitle'];
	local TransTitle_origin = A:ORIGIN ('TransTitle');
	if 'conference' == config.CitationClass then
		if utilities.is_set (BookTitle) then
			Chapter = Title;
			Chapter_origin = 'title';
	--		ChapterLink = TitleLink;											-- |chapter-link= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			URL_origin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			TransChapter_origin = TransTitle_origin;
			Title = BookTitle;
			Format = '';
	--		TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end
	
	-- CS1/2 mode
	local Mode = is_valid_parameter_value (A['Mode'], A:ORIGIN('Mode'), cfg.keywords_lists['mode'], '');
	-- separator character and postscript
	local sepc, PostScript = set_style (Mode:lower(), A['PostScript'], config.CitationClass);
	-- controls capitalization of certain static text
	local use_lowercase = ( sepc == ',' );
	
	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		if utilities.is_set (Chapter) then										--TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'map') .. ' and ' .. utilities.wrap_style ('parameter', Chapter_origin)});	-- add error message
		end
		Chapter = A['Map'];
		Chapter_origin = A:ORIGIN('Map');
		ChapterURL = A['MapURL'];
		ChapterURL_origin = A:ORIGIN('MapURL');
		TransChapter = A['TransMap'];
		ScriptChapter = A['ScriptMap']
		ScriptChapter_origin = A:ORIGIN('ScriptMap')

		ChapterUrlAccess = MapUrlAccess;
		ChapterFormat = A['MapFormat'];

		Cartography = A['Cartography'];
		if utilities.is_set ( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if utilities.is_set ( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	local Series = A['Series'];
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local SeriesLink = A['SeriesLink'];

		SeriesLink = link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wiki-markup in |series-link= or wiki-markup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if utilities.is_set (Network) then table.insert(n, Network); end
		if utilities.is_set (Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if utilities.is_set (Season) and utilities.is_set (SeriesNumber) then	-- these are mutually exclusive so if both are set TODO: make a function for this and similar?
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'season') .. ' and ' .. utilities.wrap_style ('parameter', 'seriesno')});		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if utilities.is_set (Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if utilities.is_set (SeriesNumber) then table.insert(s, wrap_msg ('seriesnum', SeriesNumber, use_lowercase)); end
			if utilities.is_set (Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ScriptChapter_origin = A:ORIGIN('ScriptTitle');
			ChapterLink = TitleLink;											-- alias |episode-link=
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if utilities.is_set (ChapterLink) and not utilities.is_set (ChapterURL) then	-- link but not URL
				Chapter = utilities.make_wikilink (ChapterLink, Chapter);
			elseif utilities.is_set (ChapterLink) and utilities.is_set (ChapterURL) then	-- if both are set, URL links episode;
				Series = utilities.make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if utilities.is_set (Series) and utilities.is_set (SeriesLink) then
				Series = utilities.make_wikilink (SeriesLink, Series);
			end
			Series = utilities.wrap_style ('italic-title', Series);				-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- handle type parameter for those CS1 citations that have default values
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	if utilities.in_array (config.CitationClass, {'AV-media-notes', 'interview', 'mailinglist', 'map', 'podcast', 'pressrelease', 'report', 'speech', 'techreport', 'thesis'}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if utilities.is_set (Degree) and &quot;Thesis&quot; == TitleType then				-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if utilities.is_set (TitleType) then										-- if type parameter is specified
		TitleType = utilities.substitute ( cfg.messages['type'], TitleType);	-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
	local Date = A['Date'];
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging
	local PublicationDate = A['PublicationDate'];
	local Year = A['Year'];

	if not utilities.is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not utilities.is_set (Date) and utilities.is_set (PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]

	local DF = is_valid_parameter_value (A['DF'], A:ORIGIN('DF'), cfg.keywords_lists['df'], '');
	if not utilities.is_set (DF) then
		DF = cfg.global_df;														-- local |df= if present overrides global df set by {{use xxx date}} template
	end

	local ArchiveURL;
	local ArchiveDate;
	local ArchiveFormat = A['ArchiveFormat'];

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	
	ArchiveURL, ArchiveDate = is_unique_archive_url (ArchiveURL, URL, ChapterURL, A:ORIGIN('ArchiveURL'), ArchiveDate);		-- add error message when URL or ChapterURL == ArchiveURL

	
	local AccessDate = A['AccessDate'];
	local LayDate = A['LayDate'];
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification
	local DoiBroken = A['DoiBroken'];
	local Embargo = A['Embargo'];
	local anchor_year;															-- used in the CITEREF identifier
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val = AccessDate, name = A:ORIGIN ('AccessDate')},
			['archive-date'] = {val = ArchiveDate, name = A:ORIGIN ('ArchiveDate')},
			['date'] = {val = Date, name = Date_origin},
			['doi-broken-date'] = {val = DoiBroken, name = A:ORIGIN ('DoiBroken')},
			['pmc-embargo-date'] = {val = Embargo, name = A:ORIGIN ('Embargo')},
			['lay-date'] = {val = LayDate, name = A:ORIGIN ('LayDate')},
			['publication-date'] = {val = PublicationDate, name = A:ORIGIN ('PublicationDate')},
			['year'] = {val = Year, name = A:ORIGIN ('Year')},
			};

		local error_list = {};
		anchor_year, Embargo = validation.dates(date_parameters_list, COinS_date, error_list);

-- start temporary Julian / Gregorian calendar uncertainty categorization
		if COinS_date.inter_cal_cat then
			utilities.add_prop_cat ('jul-greg-uncertainty');
		end
-- end temporary Julian / Gregorian calendar uncertainty categorization

		if utilities.is_set (Year) and utilities.is_set (Date) then				-- both |date= and |year= not normally needed; 
			validation.year_date_check (Year, A:ORIGIN ('Year'), Date, A:ORIGIN ('Date'), error_list);
		end
		
		if 0 == #error_list then												-- error free dates only; 0 when error_list is empty
			local modified = false;												-- flag
			
			if utilities.is_set (DF) then										-- if we need to reformat dates
				modified = validation.reformat_dates (date_parameters_list, DF);	-- reformat to DF format, use long month names if appropriate
			end

			if true == validation.date_hyphen_to_dash (date_parameters_list) then	-- convert hyphens to dashes where appropriate
				modified = true;
				utilities.set_message ('maint_date_format');					-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language; not supported at en.wiki
			if cfg.date_name_auto_xlate_enable and validation.date_name_xlate (date_parameters_list, cfg.date_digit_auto_xlate_enable ) then
				utilities.set_message ('maint_date_auto_xlated');				-- add maint cat
				modified = true;
			end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				LayDate = date_parameters_list['lay-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end
		else
			utilities.set_message ('err_bad_date', {utilities.make_sep_list (#error_list, error_list)});	-- add this error message
		end
	end	-- end of do

	local ID_list = {};															-- sequence table of rendered identifiers
	local ID_list_coins = {};													-- table of identifiers and their values from args; key is same as cfg.id_handlers's key
	local Class = A['Class'];													-- arxiv class identifier
	
	local ID_support = {
		{A['ASINTLD'], 'ASIN', 'err_asintld_missing_asin', A:ORIGIN ('ASINTLD')},				
		{DoiBroken, 'DOI', 'err_doibroken_missing_doi', A:ORIGIN ('DoiBroken')},
		{Embargo, 'PMC', 'err_embargo_missing_pmc', A:ORIGIN ('Embargo')},
		}

	ID_list, ID_list_coins = identifiers.identifier_lists_get (args, {DoiBroken = DoiBroken, ASINTLD = A['ASINTLD'], Embargo = Embargo, Class = Class}, ID_support);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite ssrn}}, before generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then
		if not utilities.is_set (ID_list_coins[config.CitationClass:upper()]) then 	-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp; |citeseerx= required for their templates
			utilities.set_message ('err_' .. config.CitationClass .. '_missing');	-- add error message
		end

		Periodical = ({['arxiv'] = 'arXiv', ['biorxiv'] = 'bioRxiv', ['citeseerx'] = 'CiteSeerX', ['ssrn'] = 'Social Science Research Network'})[config.CitationClass];
	end

	-- Link the title of the work if no |url= was provided, but we have a |pmc= or a |doi= with |doi-access=free

	if config.CitationClass == &quot;journal&quot; and not utilities.is_set (URL) and not utilities.is_set (TitleLink) and not utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) then -- TODO: remove 'none' once existing citations have been switched to 'off', so 'none' can be used as token for &quot;no title&quot; instead
		if 'none' ~= cfg.keywords_xlate[auto_select] then						-- if auto-linking not disabled
 	 		if identifiers.auto_link_urls[auto_select] then						-- manual selection
		 		URL = identifiers.auto_link_urls[auto_select];					-- set URL to be the same as identifier's external link
 				URL_origin = cfg.id_handlers[auto_select:upper()].parameters[1];	-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['pmc'] then						-- auto-select PMC
				URL = identifiers.auto_link_urls['pmc'];						-- set URL to be the same as the PMC external link if not embargoed
				URL_origin = cfg.id_handlers['PMC'].parameters[1];				-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['doi'] then						-- auto-select DOI
				URL = identifiers.auto_link_urls['doi'];
				URL_origin = cfg.id_handlers['DOI'].parameters[1];
			end
 	 	end

		if utilities.is_set (URL) and utilities.is_set (AccessDate) then		-- access date requires |url=; identifier-created URL is not |url=
			utilities.set_message ('err_accessdate_missing_url');				-- add an error message
			AccessDate = '';													-- unset
		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not utilities.is_set (Title) and not utilities.is_set (TransTitle) and not utilities.is_set (ScriptTitle) then	-- has special case for cite episode
		utilities.set_message ('err_citation_missing_title', {'episode' == config.CitationClass and 'series' or 'title'});
	end

	if utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) and
			utilities.in_array (config.CitationClass, {'journal', 'citation'}) and
			(utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and
			('journal' == Periodical_origin or 'script-journal' == ScriptPeriodical_origin) then	-- special case for journal cites
				Title = '';														-- set title to empty string
				utilities.set_message ('maint_untitled');						-- add maint cat
	end

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Chapter) and utilities.is_set (Title) and utilities.is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end
	
	local QuotePage = A['QuotePage'];
	local QuotePages = utilities.hyphen_to_dash (A['QuotePages']);

	-- this is the function call to COinS()
	local OCinSoutput = metadata.COinS({
		['Periodical'] = utilities.strip_apostrophe_markup (Periodical),		-- no markup in the metadata
		['Encyclopedia'] = Encyclopedia,										-- just a flag; content ignored by ~/COinS
		['Chapter'] = metadata.make_coins_title (coins_chapter, ScriptChapter),	-- Chapter and ScriptChapter stripped of bold / italic / accept-as-written markup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = metadata.make_coins_title (coins_title, ScriptTitle),		-- Title and ScriptTitle stripped of bold / italic / accept-as-written markup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Quarter'] = COinS_date.rftquarter,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = coins_pages or metadata.get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At, QuotePage, QuotePages}, 7)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName or Newsgroup,							-- any apostrophe markup already removed from PublisherName
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list_coins,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, and {{cite ssrn}} AFTER generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, CiteSeerX, or ssrn now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass and utilities.is_set (Newsgroup) then
		PublisherName = utilities.substitute (cfg.messages['newsgroup'], external_link( 'news:' .. Newsgroup, Newsgroup, Newsgroup_origin, nil ));
	end

	local Editors;
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	local Contributors;															-- assembled contributors name list
	local contributor_etal;
	local Translators;															-- assembled translators name list
	local translator_etal;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	local Interviewers;															
	local interviewers_list = {};					
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters
	local interviewer_etal;
	
	-- Now perform various field 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.
	do
		local last_first_list;
		local control = { 
			format = NameListStyle,												-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_names (A['DisplayEditors'], #e, 'editors', editor_etal, A:ORIGIN ('DisplayEditors'));
			Editors, EditorCount = list_people (control, e, editor_etal);

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum, interviewer_etal = get_display_names (A['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal, A:ORIGIN ('DisplayInterviewers'));
			Interviewers = list_people (control, interviewers_list, interviewer_etal);
		end
		do																		-- now do translators
			control.maximum, translator_etal = get_display_names (A['DisplayTranslators'], #t, 'translators', translator_etal, A:ORIGIN ('DisplayTranslators'));
			Translators = list_people (control, t, translator_etal);
		end
		do																		-- now do contributors
			control.maximum, contributor_etal = get_display_names (A['DisplayContributors'], #c, 'contributors', contributor_etal, A:ORIGIN ('DisplayContributors'));
			Contributors = list_people (control, c, contributor_etal);
		end
		do																		-- now do authors
			control.maximum, author_etal = get_display_names (A['DisplayAuthors'], #a, 'authors', author_etal, A:ORIGIN ('DisplayAuthors'));

			last_first_list = list_people (control, a, author_etal);

			if utilities.is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors');	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if utilities.is_set (Authors) and utilities.is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not utilities.is_set (URL) then
		if utilities.in_array (config.CitationClass, {&quot;web&quot;, &quot;podcast&quot;, &quot;mailinglist&quot;}) or		-- |url= required for cite web, cite podcast, and cite mailinglist
			('citation' == config.CitationClass and ('website' == Periodical_origin or 'script-website' == ScriptPeriodical_origin)) then	-- and required for {{citation}} with |website= or |script-website=
				utilities.set_message ('err_cite_web_url');
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if utilities.is_set (AccessDate) and not utilities.is_set (ChapterURL) then		-- ChapterURL may be set when URL is not set;
			utilities.set_message ('err_accessdate_missing_url');
			AccessDate = '';
		end
	end

	local UrlStatus = is_valid_parameter_value (A['UrlStatus'], A:ORIGIN('UrlStatus'), cfg.keywords_lists['url-status'], '');
	local OriginalURL
	local OriginalURL_origin
	local OriginalFormat
	local OriginalAccess;
	UrlStatus = UrlStatus:lower();												-- used later when assembling archived text
	if utilities.is_set ( ArchiveURL ) then
		if utilities.is_set (ChapterURL) then 									-- if chapter-url= is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURL_origin = ChapterURL_origin;								-- name of |chapter-url= parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=

			if 'live' ~= UrlStatus then
				ChapterURL = ArchiveURL											-- swap-in the archive's URL
				ChapterURL_origin = A:ORIGIN('ArchiveURL')						-- name of |archive-url= parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived URLs
			end
		elseif utilities.is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURL_origin = URL_origin;									-- name of URL parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;

			if 'live' ~= UrlStatus then											-- if URL set then |archive-url= applies to it
				URL = ArchiveURL												-- swap-in the archive's URL
				URL_origin = A:ORIGIN('ArchiveURL')								-- name of archive URL parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived URLs
			end
		end
	elseif utilities.is_set (UrlStatus) then									-- if |url-status= is set when |archive-url= is not set
 		utilities.set_message ('maint_url_status');								-- add maint cat
	end

	if utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) then
			local chap_param;
			if utilities.is_set (Chapter) then									-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif utilities.is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif utilities.is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif utilities.is_set (ScriptChapter) then
				chap_param = ScriptChapter_origin;
			else utilities.is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if utilities.is_set (chap_param) then								-- if we found one
				utilities.set_message ('err_chapter_ignored', {chap_param});	-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if utilities.is_set (Contribution) and 0 &lt; #c then						-- if this is a contribution with contributor(s)
			if utilities.in_array (Contribution:lower(), cfg.keywords_lists.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, ScriptChapter_origin, Chapter, Chapter_origin, TransChapter, TransChapter_origin, ChapterURL, ChapterURL_origin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if utilities.is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and utilities.is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter .. sepc .. ' ';
		elseif utilities.is_set (ChapterFormat) then							-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title
	local plain_title = false;
	local accept_title;
	Title, accept_title = utilities.has_accept_as_written (Title, true);		-- remove accept-this-as-written markup when it wraps all of &lt;Title&gt;
	if accept_title and ('' == Title) then										-- only support forced empty for now &quot;(())&quot;
		Title = cfg.messages['notitle'];										-- replace by predefined &quot;No title&quot; message
			-- TODO: utilities.set_message ( 'err_redundant_parameters', ...);	-- issue proper error message instead of muting	 
			ScriptTitle = '';													-- just mute for now	 
			TransTitle = '';													-- just mute for now
 		plain_title = true;														-- suppress text decoration for descriptive title
		utilities.set_message ('maint_untitled');								-- add maint cat
	end

	if not accept_title then													-- &lt;Title&gt; not wrapped in accept-as-written markup
		if '...' == Title:sub (-3) then											-- if ellipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%' .. sepc .. '$', '');			-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end

		if utilities.is_set (ArchiveURL) and is_archived_copy (Title) then
			utilities.set_message ('maint_archived_copy');						-- add maintenance category before we modify the content of Title
		end

		if is_generic ('generic_titles', Title) then
			utilities.set_message ('err_generic_title');						-- set an error message
		end
	end

	if (not plain_title) and (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) or
		('map' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)))) then		-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from module provided quote marks
			Title = utilities.wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle, 'script-title');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
			TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );
	elseif plain_title or ('report' == config.CitationClass) then				-- no styling for cite report and descriptive titles (otherwise same as above)
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );	-- for cite report, use this form for trans-title
	else
		Title = utilities.wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-italic-title', TransTitle);
	end

	if utilities.is_set (TransTitle) then
		if utilities.is_set (Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			utilities.set_message ('err_trans_missing_title', {'title'});
		end
	end

	if utilities.is_set (Title) then											-- TODO: is this the right place to be making Wikisource URLs?
		if utilities.is_set (TitleLink) and utilities.is_set (URL) then
			utilities.set_message ('err_wikilink_in_url');						-- set an error message because we can't have both
			TitleLink = '';														-- unset
		end
	
		if not utilities.is_set (TitleLink) and utilities.is_set (URL) then
			Title = external_link (URL, Title, URL_origin, UrlAccess) .. TransTitle .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif utilities.is_set (TitleLink) and not utilities.is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle;
			else
				Title = utilities.make_wikilink (TitleLink, Title) .. TransTitle;
			end
		else
			local ws_url, ws_label, L;											-- Title has italic or quote markup by the time we get here which causes is_wikilink() to return 0 (not a wikilink)
			ws_url, ws_label, L = wikisource_url_make (Title:gsub('^[\'&quot;]*(.-)[\'&quot;]*$', '%1'));	-- make ws URL from |title= interwiki link (strip italic or quote markup); link portion L becomes tooltip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle;
			else
				Title = Title .. TransTitle;
			end
		end
	else
		Title = TransTitle;
	end

	if utilities.is_set (Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	local ConferenceURL_origin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	if utilities.is_set (Conference) then
		if utilities.is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURL_origin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif utilities.is_set (ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURL_origin, nil );
	end

	local Position = '';
	if not utilities.is_set (Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if utilities.is_set (Minutes) then
			if utilities.is_set (Time) then		--TODO: make a function for this and similar?
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'minutes') .. ' and ' .. utilities.wrap_style ('parameter', 'time')});
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if utilities.is_set (Time) then
				local TimeCaption = A['TimeCaption']
				if not utilities.is_set (TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = utilities.is_set (At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = utilities.is_set (Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Sections = A['Sections'];											-- Section (singular) is an alias of Chapter so set earlier
		local Inset = A['Inset'];
		
		if utilities.is_set ( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if utilities.is_set ( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif utilities.is_set ( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	local Others = A['Others'];
	if utilities.is_set (Others) and 0 == #a and 0 == #e then					-- add maint cat when |others= has value and used without |author=, |editor=
		if config.CitationClass == &quot;AV-media-notes&quot;
		or config.CitationClass == &quot;audio-visual&quot; then							-- special maint for AV/M which has a lot of 'false' positives right now
			utilities.set_message ('maint_others_avm')
		else
			utilities.set_message ('maint_others');
		end
	end
	Others = utilities.is_set (Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if utilities.is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if utilities.is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	local TitleNote = A['TitleNote'];
	TitleNote = utilities.is_set (TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if utilities.is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%n?%.?$') or Edition:match ('%f[%a][Ee]dition$') then -- Ed, ed, Ed., ed., Edn, edn, Edn., edn.
			utilities.set_message ('err_extra_text_edition');					 -- add error message
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = utilities.is_set (Series) and wrap_msg ('series', {sepc, Series}) or &quot;&quot;;	-- not the same as SeriesNum
	local Agency = A['Agency'];
	Agency = utilities.is_set (Agency) and wrap_msg ('agency', {sepc, Agency}) or &quot;&quot;;
	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	if utilities.is_set (AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = utilities.substitute (retrv_text, AccessDate);				-- add retrieved text

		AccessDate = utilities.substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if utilities.is_set (ID) then ID = sepc .. &quot; &quot; .. ID; end
	
	local Docket = A['Docket'];
   	if &quot;thesis&quot; == config.CitationClass and utilities.is_set (Docket) then
		ID = sepc .. &quot; Docket &quot; .. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and utilities.is_set (Docket) then		-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	if utilities.is_set (URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URL_origin, UrlAccess );
	end

	local Quote = A['Quote'];
	local TransQuote = A['TransQuote'];
	local ScriptQuote = A['ScriptQuote'];
	if utilities.is_set (Quote) or utilities.is_set (TransQuote) or utilities.is_set (ScriptQuote) then

		if utilities.is_set (Quote) then
			if Quote:sub(1, 1) == '&quot;' and Quote:sub(-1, -1) == '&quot;' then			-- if first and last characters of quote are quote marks
				Quote = Quote:sub(2, -2);										-- strip them off
			end
		end

		Quote = utilities.wrap_style ('quoted-text', Quote );					-- wrap in &lt;q&gt;...&lt;/q&gt; tags
	
		if utilities.is_set (ScriptQuote) then
			Quote = script_concatenate (Quote, ScriptQuote, 'script-quote');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after quote is wrapped
		end

		if utilities.is_set (TransQuote) then
			if TransQuote:sub(1, 1) == '&quot;' and TransQuote:sub(-1, -1) == '&quot;' then -- if first and last characters of |trans-quote are quote marks
				TransQuote = TransQuote:sub(2, -2); -- strip them off
			end
			Quote = Quote .. &quot; &quot; .. utilities.wrap_style ('trans-quoted-title', TransQuote );
		end

		if utilities.is_set (QuotePage) or utilities.is_set (QuotePages) then	-- add page prefix
			local quote_prefix = '';
			if utilities.is_set (QuotePage) then
				extra_text_in_page_check (QuotePage, 'quote-page');				-- add to maint cat if |quote-page= value begins with what looks like p., pp., etc.
				if not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePage}), '', '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePage}), '', '', '';
				end
			elseif utilities.is_set (QuotePages) then
				extra_text_in_page_check (QuotePages, 'quote-pages');			-- add to maint cat if |quote-pages= value begins with what looks like p., pp., etc.
				if tonumber(QuotePages) ~= nil and not NoPP then				-- if only digits, assume single page
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePages}), '', '';
				elseif not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['pp-prefix'], {sepc, QuotePages}), '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePages}), '', '';
				end
			end
                        
			Quote = quote_prefix .. &quot;: &quot; .. Quote;
		else
			Quote = sepc .. &quot; &quot; .. Quote;
		end

		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	-- We check length of PostScript here because it will have been nuked by
	-- the quote parameters. We'd otherwise emit a message even if there wasn't
	-- a displayed postscript.
	-- TODO: Should the max size (1) be configurable?
	-- TODO: Should we check a specific pattern?
	if utilities.is_set(PostScript) and mw.ustring.len(PostScript) &gt; 1 then
		utilities.set_message ('maint_postscript')
	end
	
	local Archived;
	if utilities.is_set (ArchiveURL) then
		local arch_text;
		if not utilities.is_set (ArchiveDate) then
			utilities.set_message ('err_archive_missing_date');
			ArchiveDate = '';													-- empty string for concatenation
		end
		if &quot;live&quot; == UrlStatus then
			arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if utilities.is_set (ArchiveDate) then
				Archived = sepc .. ' ' .. utilities.substitute ( cfg.messages['archived-live'],
					{external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil) .. ArchiveFormat, ArchiveDate } );
			else
				Archived = '';
			end
			if not utilities.is_set (OriginalURL) then
				utilities.set_message ('err_archive_missing_url');
				Archived = '';													-- empty string for concatenation
			end
		elseif utilities.is_set (OriginalURL) then								-- UrlStatus is empty, 'dead', 'unfit', 'usurped', 'bot: unknown'
			if utilities.in_array (UrlStatus, {'unfit', 'usurped', 'bot: unknown'}) then
				arch_text = cfg.messages['archived-unfit'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. ' ' .. arch_text .. ArchiveDate;				-- format already styled
				if 'bot: unknown' == UrlStatus then
					utilities.set_message ('maint_bot_unknown');				-- and add a category if not already added
				else
					utilities.set_message ('maint_unfit');						-- and add a category if not already added
				end
			else																-- UrlStatus is empty, 'dead'
				arch_text = cfg.messages['archived-dead'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				if utilities.is_set (ArchiveDate) then
					Archived = sepc .. &quot; &quot; .. utilities.substitute ( arch_text,
						{ external_link( OriginalURL, cfg.messages['original'], OriginalURL_origin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
				else
					Archived = '';												-- unset for concatenation
				end
			end	
		else																	-- OriginalUrl not set
			arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			utilities.set_message ('err_archive_missing_url');
			Archived = '';														-- empty string for concatenation
		end
	elseif utilities.is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = '';
	end
	
	local Lay = '';
	local LaySource = A['LaySource'];
	local LayURL = A['LayURL'];
	local LayFormat = A['LayFormat'];
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	if utilities.is_set (LayURL) then
		if utilities.is_set (LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if utilities.is_set (LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. utilities.safe_for_italics (LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif utilities.is_set (LayFormat) then									-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	local TranscriptURL = A['TranscriptURL']
	local TranscriptFormat = A['TranscriptFormat'];
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');
	local Transcript = A['Transcript'];
	local TranscriptURL_origin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL
	if utilities.is_set (Transcript) then
		if utilities.is_set (TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURL_origin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif utilities.is_set (TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURL_origin, nil );
	end

	local Publisher;
	if utilities.is_set (PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if utilities.is_set (PublisherName) then
		if utilities.is_set (PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif utilities.is_set (PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	local TransPeriodical =  A['TransPeriodical'];
	local TransPeriodical_origin =  A:ORIGIN ('TransPeriodical');
	-- Several of the above rely upon detecting this as nil, so do it last.
	if (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical)) then
		if utilities.is_set (Title) or utilities.is_set (TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		else 
			Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		end
	end
	
	local Language = A['Language'];
	if utilities.is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc.
	else
		Language='';															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then									-- cite speech only
		TitleNote = TitleType;													-- move TitleType to TitleNote so that it renders ahead of |event=
		TitleType = '';															-- and unset

		if utilities.is_set (Periodical) then									-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if utilities.is_set (Conference) then								-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;							-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
		if utilities.is_set (Others) then Others = safe_join ({Others, sepc .. &quot; &quot;}, sepc) end		-- add terminal punctuation &amp; space; check for dup sepc; TODO why do we need to do this here?
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (Periodical) then		-- special cases for book cites
		if utilities.is_set (Contributors) then									-- when we are citing foreword, preface, introduction, etc.
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if utilities.is_set (Chapter) then										-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif utilities.is_set (Periodical) then								-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local Via = A['Via'];
	Via = utilities.is_set (Via) and  wrap_msg ('via', Via) or '';
	local idcommon;
	if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then	-- special case for cite AV media &amp; cite episode position transcript
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, Lay, Quote }, sepc );
	else
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, Lay, Quote }, sepc );
	end
	
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	local OrigDate = A['OrigDate'];
	OrigDate = utilities.is_set (OrigDate) and wrap_msg ('origdate', OrigDate) or '';
	if utilities.is_set (Date) then
		if utilities.is_set (Authors) or utilities.is_set (Editors) then		-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date .. &quot;)&quot; .. OrigDate .. sepc .. &quot; &quot;;				-- in parentheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon, -1, -1) == sepc) then						-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigDate;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigDate;							-- Date begins with sepc
			end
		end
	end	
	if utilities.is_set (Authors) then
		if (not utilities.is_set (Date)) then									-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if utilities.is_set (Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then
					in_text = in_text:lower()									-- lowercase for cs2
				end
			end
			if EditorCount &lt;= 1 then
				post_text = &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot;;				-- be consistent with no-author, no-date case
			else
				post_text = &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot;;
			end
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Contributors) then									-- book cite and we're citing the intro, preface, etc.
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if utilities.is_set (Editors) and utilities.is_set (Date) then		-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not utilities.is_set (Date)) then								-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif utilities.is_set (Editors) then
		if utilities.is_set (Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if utilities.is_set (PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc ); 								-- Deals with italics, spaces, etc.
		text = text:sub(1, -sepc:len() - 1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite&gt; element
	local options_t = {};
	options_t.class = cite_class_attribute_make (config.CitationClass, Mode);

	local Ref = is_valid_parameter_value (A['Ref'], A:ORIGIN('Ref'), cfg.keywords_lists['ref'], nil, true);	-- nil when |ref=harv; A['Ref'] else

	if 'none' ~= cfg.keywords_xlate[(Ref and Ref:lower()) or ''] then
		local namelist_t = {};													-- holds selected contributor, author, editor name list
		local year = first_set ({Year, anchor_year}, 2);						-- Year first for legacy citations and for YMD dates that require disambiguation

		if #c &gt; 0 then															-- if there is a contributor list
			namelist_t = c;														-- select it
		elseif #a &gt; 0 then														-- or an author list
			namelist_t = a;
		elseif #e &gt; 0 then														-- or an editor list
			namelist_t = e;
		end
		local citeref_id;
		if #namelist_t &gt; 0 then													-- if there are names in namelist_t
			citeref_id = make_citeref_id (namelist_t, year);					-- go make the CITEREF anchor
			if mw.uri.anchorEncode (citeref_id) == ((Ref and mw.uri.anchorEncode (Ref)) or '') then	-- Ref may already be encoded (by {{sfnref}}) so citeref_id must be encoded before comparison
				utilities.set_message ('maint_ref_duplicates_default');
			end
		else
			citeref_id = '';													-- unset
		end
		options_t.id = Ref or citeref_id;
	end

	if string.len (text:gsub('%b&lt;&gt;', '')) &lt;= 2 then								-- remove html and html-like tags; then get length of what remains; 
		z.error_cats_t = {};													-- blank the categories list
		z.error_msgs_t = {};													-- blank the error messages list
		OCinSoutput = nil;														-- blank the metadata string
		text = '';																-- blank the the citation
		utilities.set_message ('err_empty_citation');							-- set empty citation message and category
	end
	
	local render_t = {};														-- here we collect the final bits for concatenation into the rendered citation

	if utilities.is_set (options_t.id) then										-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render_t, utilities.substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options_t.id), mw.text.nowiki(options_t.class), text}));	-- when |ref= is set or when there is a namelist
	else
		table.insert (render_t, utilities.substitute (cfg.presentation['cite'], {mw.text.nowiki(options_t.class), text}));	-- when |ref=none or when namelist_t empty and |ref= is missing or is empty
	end		

	if OCinSoutput then															-- blanked when citation is 'empty' so don't bother to add boilerplate metadata span
		table.insert (render_t, utilities.substitute (cfg.presentation['ocins'], OCinSoutput));	-- format and append metadata to the citation
	end

	local template_name = ('citation' == config.CitationClass) and 'citation' or 'cite ' .. (cfg.citation_class_map_t[config.CitationClass] or config.CitationClass);
	local template_link = '[[Template:' .. template_name .. '|' .. template_name .. ']]';	-- TODO: if kept, these require some sort of i18n
	local msg_prefix = '&lt;code class=&quot;cs1-code&quot;&gt;{{' .. template_link .. '}}&lt;/code&gt;: ';

	if 0 ~= #z.error_msgs_t then
		mw.addWarning (utilities.substitute (cfg.messages.warning_msg_e, template_link));

		table.insert (render_t, ' ');											-- insert a space between citation and its error messages
		table.sort (z.error_msgs_t);											-- sort the error messages list; sorting includes wrapping &lt;span&gt; and &lt;code&gt; tags; hidden-error sorts ahead of visible-error

		local hidden = true;													-- presume that the only error messages emited by this template are hidden
		for _, v in ipairs (z.error_msgs_t) do									-- spin through the list of error messages
			if v:find ('cs1-visible-error', 1, true) then						-- look for the visible error class name
				hidden = false;													-- found one; so don't hide the error message prefix
				break;															-- and done because no need to look further
			end
		end

		z.error_msgs_t[1] = table.concat ({utilities.error_comment (msg_prefix, hidden), z.error_msgs_t[1]});	-- add error message prefix to first error message to prevent extraneous punctuation
		table.insert (render_t, table.concat (z.error_msgs_t, '; '));			-- make a big string of error messages and add it to the rendering
	end

	if 0 ~= #z.maint_cats_t then
		mw.addWarning (utilities.substitute (cfg.messages.warning_msg_m, template_link));

		table.sort (z.maint_cats_t);											-- sort the maintenance messages list

		local maint_msgs_t = {};												-- here we collect all of the maint messages

		if 0 == #z.error_msgs_t then											-- if no error messages
			table.insert (maint_msgs_t, msg_prefix);							-- insert message prefix in maint message livery
		end
		
		for _, v in ipairs( z.maint_cats_t ) do									-- append maintenance categories
			table.insert (maint_msgs_t, 										-- assemble new maint message and add it to the maint_msgs_t table
				table.concat ({v, ' (', utilities.substitute (cfg.messages[':cat wikilink'], v), ')'})
				);
		end
		table.insert (render_t, utilities.substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs_t, ' ')));	-- wrap the group of maint messages with proper presentation and save
	end

	if not no_tracking_cats then
		for _, v in ipairs (z.error_cats_t) do									-- append error categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
		end
		for _, v in ipairs (z.maint_cats_t) do									-- append maintenance categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
		end
		for _, v in ipairs (z.prop_cats_t) do									-- append properties categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
		end
	end

	return table.concat (render_t);												-- make a big string and done
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class, empty)
	local name = tostring (name);
	local enum_name;															-- for enumerated parameters, is name with enumerator replaced with '#'
	local state;
	local function state_test (state, name)										-- local function to do testing of state values
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			if empty then return nil; end										-- empty deprecated parameters are treated as unknowns
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
		if 'tracked' == state then
			local base_name = name:gsub ('%d', '');								-- strip enumerators from parameter names that have them to get the base name
			utilities.add_prop_cat ('tracked-param', {base_name}, base_name);	-- add a properties category; &lt;base_name&gt; modifies &lt;key&gt;
			return true;
		end
		return nil;
	end		

	if name:find ('#') then														-- # is a cs1|2 reserved character so parameters with # not permitted
		return nil;
	end

	if utilities.in_array (cite_class, whitelist.preprint_template_list ) then	-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[name];
		if true == state_test (state, name) then return true; end

		state = whitelist.preprint_arguments[cite_class][name];					-- look in the parameter-list for the template identified by cite_class
		if true == state_test (state, name) then return true; end

																				-- limited enumerated parameters list
		enum_name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );										-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
		state = whitelist.limited_numbered_arguments[enum_name];
		if true == state_test (state, name) then return true; end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates

	if utilities.in_array (cite_class, whitelist.unique_param_template_list) then 	-- experiment for template-specific parameters for templates that accept parameters from the basic argument list
		state = whitelist.unique_arguments[cite_class][name];					-- look in the template-specific parameter-lists for the template identified by cite_class
		if true == state_test (state, name) then return true; end
	end																			-- if here, fall into general validation
		
	state = whitelist.basic_arguments[name];									-- all other templates; all normal parameters allowed
	if true == state_test (state, name) then return true; end

																				-- all enumerated parameters allowed
	enum_name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
	state = whitelist.numbered_arguments[enum_name];
	if true == state_test (state, name) then return true; end

	return false;																-- not supported because not found or name is set to nil
end


--[=[-------------------------&lt; I N T E R _ W I K I _ C H E C K &gt;----------------------------------------------

check &lt;value&gt; for inter-language interwiki-link markup.  &lt;prefix&gt; must be a MediaWiki-recognized language
code.  when these values have the form (without leading colon):
	[[&lt;prefix&gt;:link|label]] return label as plain-text
	[[&lt;prefix&gt;:link]] return &lt;prefix&gt;:link as plain-text

return value as is else

]=]

local function inter_wiki_check (parameter, value)
	local prefix = value:match ('%[%[(%a+):');									-- get an interwiki prefix if one exists
	local _;
	
	if prefix and cfg.inter_wiki_map[prefix:lower()] then						-- if prefix is in the map, needs preceding colon so
		utilities.set_message ('err_bad_paramlink', parameter);					-- emit an error message
		_, value, _ = utilities.is_wikilink (value);							-- extract label portion from wikilink
	end
	return value;
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe.  There are two tests made:
	{{cite ... |title=Title access-date=2016-03-17}}	-- the first parameter has a value and whitespace separates that value from the missing pipe parameter name
	{{cite ... |title=access-date=2016-03-17}}			-- the first parameter has no value (whitespace after the first = is trimmed by MediaWiki)
cs1|2 shares some parameter names with XML/HTML attributes: class=, title=, etc.  To prevent false positives XML/HTML
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (parameter, value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove XML/HTML tags because attributes: class=, title=, etc.

	capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then										-- if the capture is a valid parameter name
		utilities.set_message ('err_missing_pipe', parameter);
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ P U N C T &gt;--------------------------------------

look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_punc (param, value)
	if 'number' == type (param) then
		return;
	end
	
	param = param:gsub ('%d+', '#');											-- enumerated name-list mask params allow terminal punct; normalize 
	if cfg.punct_skip[param] then
		return;																	-- parameter name found in the skip table so done
	end
	
	if value:match ('[,;:]$') then
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
	if value:match ('^=') then													-- sometimes an extraneous '=' character appears ...
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ U R L &gt;------------------------------------------

look for extraneous url parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_url (url_param_t)
	local url_error_t = {};
	
	check_for_url (url_param_t, url_error_t);									-- extraneous url check
	if 0 ~= #url_error_t then													-- non-zero when there are errors
		table.sort (url_error_t);
		utilities.set_message ('err_param_has_ext_link', {utilities.make_sep_list (#url_error_t, url_error_t)});	-- add this error message
	end
end


--[[--------------------------&lt; C I T A T I O N &gt;--------------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

local function citation(frame)
	Frame = frame;																-- save a copy in case we need to display an error message in preview mode
	is_sandbox = nil ~= string.find (frame:getTitle(), 'sandbox', 1, true);
	local pframe = frame:getParent()
	local styles;
	
	if is_sandbox then															-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		styles = 'Module:Citation/CS1/sandbox/styles.css';
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
		styles = 'Module:Citation/CS1/styles.css';
	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the selected cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	is_preview_mode = not utilities.is_set (frame:preprocess ('{{REVISIONID}}'));

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text;															-- used as a flag

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do											-- get parameters from the {{#invoke}} frame
		config[k] = v;
	--	args[k] = v;															-- crude debug support that allows us to render a citation from module {{#invoke:}}; skips parameter validation; TODO: keep?
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	local empty_unknowns = {};													-- sequence table to hold empty unknown params for error message listing
	for k, v in pairs( pframe.args ) do											-- get parameters from the parent (template) frame
		v = mw.ustring.gsub (v, '^%s*(.-)%s*$', '%1');							-- trim leading/trailing whitespace; when v is only whitespace, becomes empty string
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				if type (k) ~= 'string' then									-- exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text = utilities.set_message ('err_text_ignored', {v});
					end
				elseif validate (k:lower(), config.CitationClass) then 
					error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, k:lower()});	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if is_sandbox then										-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no capture in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = utilities.substitute (param, capture);		-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, param});	-- set the suggestion error message
							else
								error_text = utilities.set_message ('err_parameter_ignored', {k});	-- suggested param not supported by this template
								v = '';											-- unset
							end
						end
					end
					if not utilities.is_set (error_text) then					-- couldn't match with a pattern, is there an explicit suggestion?						
						if (suggestions.suggestions[ k:lower() ] ~= nil) and validate (suggestions.suggestions[ k:lower() ], config.CitationClass) then
							utilities.set_message ('err_parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]});
						else
							utilities.set_message ('err_parameter_ignored', {k});
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
			end

			args[k] = v;														-- save this parameter and its value

		elseif not utilities.is_set (v) then									-- for empty parameters
			if not validate (k, config.CitationClass, true) then				-- is this empty parameter a valid parameter
				k = ('' == k) and '(empty string)' or k;						-- when k is empty string (or was space(s) trimmed to empty string), replace with descriptive text
				table.insert (empty_unknowns, utilities.wrap_style ('parameter', k));	-- format for error message and add to the list
			end
																				-- crude debug support that allows us to render a citation from module {{#invoke:}} TODO: keep?
	--	elseif args[k] ~= nil or (k == 'postscript') then						-- when args[k] has a value from {{#invoke}} frame (we don't normally do that)
	--		args[k] = v;														-- overwrite args[k] with empty string from pframe.args[k] (template frame); v is empty string here
		end																		-- not sure about the postscript bit; that gets handled in parameter validation; historical artifact?
	end	

	if 0 ~= #empty_unknowns then												-- create empty unknown error message
		utilities.set_message ('err_param_unknown_empty', {
			1 == #empty_unknowns and '' or 's',
			utilities.make_sep_list (#empty_unknowns, empty_unknowns)
			});
	end

	local url_param_t = {};

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);											-- look for invisible characters
		end
		has_extraneous_punc (k, v);												-- look for extraneous terminal punctuation in parameter values
		missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?
		args[k] = inter_wiki_check (k, v);										-- when language interwiki-linked parameter missing leading colon replace with wiki-link label

		if 'string' == type (k) and not cfg.url_skip[k] then					-- when parameter k is not positional and not in url skip table
			url_param_t[k] = v;													-- make a parameter/value list for extraneous url check
		end
	end

	has_extraneous_url (url_param_t);											-- look for url in parameter values where a url does not belong

	return table.concat ({
		frame:extensionTag ('templatestyles', '', {src=styles}),
		citation0( config, args)
	});
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {citation = citation};</text>
      <sha1>irdywuuc25u4ivt5yhd0ece4iusxk6t</sha1>
    </revision>
    <revision>
      <id>4743</id>
      <parentid>4742</parentid>
      <timestamp>2022-01-24T00:41:03Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>post-update update;</comment>
      <origin>4743</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="205286" sha1="a6b1ib2whvprbl21imv4b7dzfbo4l6r" xml:space="preserve">require ('Module:No globals');

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------

each of these counts against the Lua upvalue limit

]]

local validation;																-- functions in Module:Citation/CS1/Date_validation

local utilities;																-- functions in Module:Citation/CS1/Utilities
local z ={};																	-- table of tables in Module:Citation/CS1/Utilities

local identifiers;																-- functions and tables in Module:Citation/CS1/Identifiers
local metadata;																	-- functions in Module:Citation/CS1/COinS
local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;---------------

declare variables here that have page-wide scope that are not brought in from
other modules; that are created here and used here

]]

local added_deprecated_cat;														-- Boolean flag so that the category is added only once
local added_vanc_errs;															-- Boolean flag so we only emit one Vancouver error / category
local added_generic_name_errs;													-- Boolean flag so we only emit one generic name error / category and stop testing names once an error is encountered
local Frame;																	-- holds the module's frame table
local is_preview_mode;															-- true when article is in preview mode; false when using 'Preview page with this template' (previewing the module)
local is_sandbox;																-- true when using sandbox modules to render citation


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if utilities.is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a Boolean declared in page scope variables above

]]

local function add_vanc_error (source, position)
	if added_vanc_errs then return end
		
	added_vanc_errs = true;														-- note that we've added this category
	utilities.set_message ('err_vancouver', {source, position});
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a URI scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of TLDs: https://www.iana.org/domains/root/db

RFC 952 (modified by RFC 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the TLD.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a URL with a scheme) will be stripped
here.  Perhaps not necessary but retained in case it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ASCII characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the TLD) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and TLD or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%w]') then											-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at Wikisource
		return false;
	end

	local patterns = {															-- patterns that look like URLs
		'%f[%w][%w][%w%-]+[%w]%.%a%a+$',										-- three or more character hostname.hostname or hostname.tld
		'%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$',									-- internationalized domain name with ACE prefix
		'%f[%a][qxz]%.com$',													-- assigned one character .com hostname (x.com times out 2015-12-10)
		'%f[%a][iq]%.net$',														-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		'%f[%w][%w]%.%a%a$',													-- one character hostname and ccTLD (2 chars)
		'%f[%w][%w][%w]%.%a%a+$',												-- two character hostname and TLD
		'^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?',								-- IPv4 address
		}

	for _, pattern in ipairs (patterns) do										-- loop through the patterns list
		if domain:match (pattern) then
			return true;														-- if a match then we think that this thing that purports to be a URL is a URL
		end
	end

	for _, d in ipairs ({'cash', 'company', 'today', 'org'}) do					-- look for single letter second level domain names for these top level domains
		if domain:match ('%f[%w][%w]%.' .. d) then
			return true
		end
	end
	return false;																-- no matches, we don't know what this thing is
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a URL appear to be a valid URL; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if utilities.is_set (scheme) then											-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when URL is protocol-relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a URL into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following TLD) (if any) and any path(/), query(?) or fragment(#).

If protocol-relative URL, return nil scheme and domain else return nil for both scheme and domain.

When not protocol-relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Any URL that does not have news: scheme must have authority indicator (//).  TODO: are there other common schemes
like news: that don't use authority indicator?

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol-relative URL
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		if utilities.is_set (authority) then
			authority = authority:gsub ('//', '', 1);							-- replace place 1 pair of '/' with nothing;
			if utilities.is_set(authority) then									-- if anything left (1 or 3+ '/' where authority should be) then
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		else
			if not scheme:match ('^news:') then									-- except for news:..., MediaWiki won't link URLs that do not have authority indicator; TODO: a better way to do this test?
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link=, etc. for properly formatted content: no wikilinks, no URLs

Link parameters are to hold the title of a Wikipedia article, so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki URLs and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid URL (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid URL (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from URL; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid URL
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wiki-linked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

check &lt;link&gt; for inter-language interwiki-link prefix.  prefix must be a MediaWiki-recognized language
code and must begin with a colon.

]]

local function link_title_ok (link, lorig, title, torig)
local orig;
	if utilities.is_set (link) then 											-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		elseif link:match ('^%a+:') then										-- if the link is what looks like an interwiki
			local prefix = link:match ('^(%a+):'):lower();						-- get the interwiki prefix

			if cfg.inter_wiki_map[prefix] then									-- if prefix is in the map, must have preceding colon
				orig = lorig;													-- flag as error
			end
		end
	end

	if utilities.is_set (orig) then
		link = '';																-- unset
		utilities.set_message ('err_bad_paramlink', orig);						-- URL or wikilink in |title= with |title-link=;
	end
	
	return link;																-- link if ok, empty string else
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the URL into scheme and domain
portions, or for protocol-relative (//example.com) URLs, just the domain.  Use is_url() to validate the two
portions of the URL.  If both are valid, or for protocol-relative if domain is valid, return true, else false.

Because it is different from a standard URL, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper URL
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from URL;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a URL.  The test will also find external wikilinks
that use protocol-relative URLs. Also finds bare URLs.

The frontier pattern prevents a match on interwiki-links which are similar to scheme:path URLs.  The tests that
find bracketed URLs are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext. wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol-relative ext. wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare URL with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol-relative bare URL: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a URL
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list, error_list)
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a URL add an error message
			table.insert (error_list, utilities.wrap_style ('parameter', k));
		end
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		utilities.set_message ('err_wikilink_in_url', {});
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link (URL, label, source, access)
	local err_msg = '';
	local domain;
	local path;
	local base_url;

	if not utilities.is_set (label) then
		label = URL;
		if utilities.is_set (source) then
			utilities.set_message ('err_bare_url_missing_title', {utilities.wrap_style ('parameter', source)});
		else
			error (cfg.messages[&quot;bare_url_no_origin&quot;]);
		end			
	end
	if not check_url (URL) then
		utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)});
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the URL into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['['] = '%5b', [']'] = '%5d'});			-- replace '[' and ']' with their percent-encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat ({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wiki-markup URL

	if utilities.is_set (access) then											-- access level (subscription, registration, limited)
		base_url = utilities.substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end

	return base_url;
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a Boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		utilities.set_message ('err_deprecated_params', {name});				-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wiki-markup) are not kerned.

Replaces Unicode quote marks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc.; not for book titles.

]=]

local function kern_quotes (str)
	local cap = '';
	local wl_type, label, link;

	wl_type, label, link = utilities.is_wikilink (str);							-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-left'], str);
			str = utilities.substitute (cfg.presentation['kern-right'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = utilities.substitute (cfg.presentation['kern-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label = mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label = mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap = mw.ustring.match (label, &quot;^([\&quot;\'][^\'].+)&quot;);						-- match leading double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-left'], cap);
		end
	
		cap = mw.ustring.match (label, &quot;^(.+[^\'][\&quot;\'])$&quot;)						-- match trailing double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-right'], cap);
		end
		
		if 2 == wl_type then
			str = utilities.make_wikilink (link, label);						-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin-based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate RTL languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO 639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO 639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title=, |script-chapter=, |script-&lt;periodical&gt;=

]]

local function format_script_value (script_value, script_param)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%l?%s*:') then									-- if first 3 or 4 non-space characters are script language prefix
		lang = script_value:match('^(%l%l%l?)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not utilities.is_set (lang) then
			utilities.set_message ('err_script_parameter', {script_param, 'missing title part'});		-- prefix without 'title'; add error message
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_code_remap[lang] or mw.language.fetchLanguageName( lang, cfg.this_wiki_code );	-- get language name so that we can use it to categorize
		if utilities.is_set (name) then											-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l+%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if utilities.in_array (lang, cfg.script_lang_codes) then
				utilities.add_prop_cat ('script', {name, lang})
			else
				utilities.set_message ('err_script_parameter', {script_param, 'unknown language code'});	-- unknown script-language; add error message
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			utilities.set_message ('err_script_parameter', {script_param, 'invalid language code'});		-- invalid language code; add error message
			lang = '';															-- invalid so set lang to empty string
		end
	else
		utilities.set_message ('err_script_parameter', {script_param, 'missing prefix'});				-- no language code prefix; add error message
	end
	script_value = utilities.substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is RTL

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script
value has been wrapped in &lt;bdi&gt; tags.

]]

local function script_concatenate (title, script, script_param)
	if utilities.is_set (script) then
		script = format_script_value (script, script_param);					-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; returns empty string on error
		if utilities.is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not utilities.is_set ( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return utilities.substitute ( msg, str );								-- including template text
	else
		return utilities.substitute ( cfg.messages[key], str );
	end		
end


--[[----------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;-------------------

Makes a Wikisource URL from Wikisource interwiki-link.  Returns the URL and appropriate
label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;
	local wikisource_prefix = table.concat ({'https://', cfg.this_wiki_code, '.wikisource.org/wiki/'});

	wl_type, D, L = utilities.is_wikilink (str);								-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 1 == wl_type then													-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end

	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable URL
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent-encoding of fragment marker
	end

	return ws_url, ws_label, L or D;											-- return proper URL or nil and a label or nil
end


--[[----------------&lt; F O R M A T _ P E R I O D I C A L &gt;-----------------------

Format the three periodical parameters: |script-&lt;periodical&gt;=, |&lt;periodical&gt;=,
and |trans-&lt;periodical&gt;= into a single Periodical meta-parameter.

]]

local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)

	if not utilities.is_set (periodical) then
		periodical = '';														-- to be safe for concatenation
	else
		periodical = utilities.wrap_style ('italic-title', periodical);			-- style 
	end

	periodical = script_concatenate (periodical, script_periodical, script_periodical_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (trans_periodical) then
		trans_periodical = utilities.wrap_style ('trans-italic-title', trans_periodical);
		if utilities.is_set (periodical) then
			periodical = periodical .. ' ' .. trans_periodical;
		else																	-- here when trans-periodical without periodical or script-periodical
			periodical = trans_periodical;
			utilities.set_message ('err_trans_missing_title', {'periodical'});
		end
	end

	return periodical;
end


--[[------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;---------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=,
and |chapter-url= into a single chapter meta- parameter (chapter_url_source used
for error messages).

]]

local function format_chapter_title (script_chapter, script_chapter_source, chapter, chapter_source, trans_chapter, trans_chapter_source, chapter_url, chapter_url_source, no_quotes, access)
	local ws_url, ws_label, L = wikisource_url_make (chapter);					-- make a wikisource URL and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', ' ');									-- replace underscore separators with space characters
		chapter = ws_label;
	end

	if not utilities.is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from module provided quote marks
			chapter = utilities.wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, script_chapter, script_chapter_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (chapter_url) then
		chapter = external_link (chapter_url, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');	-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if utilities.is_set (trans_chapter) then
		trans_chapter = utilities.wrap_style ('trans-quoted-title', trans_chapter);
		if utilities.is_set (chapter) then
			chapter = chapter .. ' ' .. trans_chapter;
		else																	-- here when trans_chapter without chapter or script-chapter
			chapter = trans_chapter;
			chapter_source = trans_chapter_source:match ('trans%-?(.+)');		-- when no chapter, get matching name from trans-&lt;param&gt;
			utilities.set_message ('err_trans_missing_title', {chapter_source});
		end
	end

	return chapter;
end


--[[----------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;-------------------

This function searches a parameter's value for non-printable or invisible characters.
The search stops at the first match.

This function will detect the visible replacement character when it is part of the Wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers
(gallery, math, pre, ref) and identifies them with a slightly different error message.
See also coins_cleanup().

Output of this function is an error message that identifies the character or the
Unicode group, or the stripmarker that was detected along with its position (or,
for multi-byte characters, the position of its first byte) in the parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local stripmarker;															-- boolean set true when a stripmarker is found

	capture = string.match (v, '[%w%p ]*');										-- test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no Unicode characters
		return;
	end

	for _, invisible_char in ipairs (cfg.invisible_chars) do
		local char_name = invisible_char[1];									-- the character or group name
		local pattern = invisible_char[2];										-- the pattern used to find it
		position, _, capture = mw.ustring.find (v, pattern);					-- see if the parameter value contains characters that match the pattern
		
		if position and (cfg.invisible_defs.zwj == capture) then				-- if we found a zero-width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- it's ok if one of the Indic scripts
				position = nil;													-- unset position
			elseif cfg.emoji[mw.ustring.codepoint (v, position+1)] then			-- is zwj followed by a character listed in emoji{}?
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and utilities.in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and cfg.invisible_defs.del == capture then	-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture and not (cfg.invisible_defs.del == capture or cfg.invisible_defs.zwj == capture) then
					err_msg = capture .. ' ' .. char_name;
				else
					err_msg = char_name .. ' ' .. 'character';
				end

				utilities.set_message ('err_invisible_char', {err_msg, utilities.wrap_style ('parameter', param), position});	-- add error message
				return;															-- and done with this parameter
			end
		end
	end
end


--[[-------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------

Argument wrapper.  This function provides support for argument mapping defined
in the configuration file so that multiple names can be transparently aliased to
single internal variable.

]]

local function argument_wrapper ( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function ( self, k )
			local dummy = self[k];												-- force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = utilities.select_one ( args, list, 'err_redundant_parameters' );
				if origin[k] == nil then
					origin[k] = '';												-- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] .. ': ' .. k);
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;-------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.
When date is DD MMMM YYYY or is MMMM DD, YYYY then wrap in nowrap span:
&lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap = '';
	local cap2 = '';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = utilities.substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = utilities.substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;---------------------

This function sets default title types (equivalent to the citation including
|type=&lt;default value&gt;) for those templates that have defaults. Also handles the
special case where it is desirable to omit the title type from the rendered citation
(|type=none).

]]

local function set_titletype (cite_class, title_type)
	if utilities.is_set (title_type) then
		if 'none' == cfg.keywords_xlate[title_type] then
			title_type = '';													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; S A F E _ J O I N &gt;-----------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'duplicate character'
		if 1 == #duplicate_char then											-- for single byte ASCII characters use the string library functions
			f.gsub = string.gsub
			f.match = string.match
			f.sub = string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub = mw.ustring.gsub
			f.match = mw.ustring.match
			f.sub = mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1, 1) == '&lt;' then										-- special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove HTML markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1, 1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc.?
				trim = false;
				end_chr = f.sub(str, -1, -1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr .. &quot;)&quot;				-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1, -2);									-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;''&quot; then		-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5, -1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;]]&quot; then		-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3, -1) == duplicate_char .. '&quot;]' then	-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2, -1) == duplicate_char .. &quot;]&quot; then	-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2, -1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1, -3);								-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains HTML markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows HTML markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value; 												-- add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;-----------------------------

returns true if suffix is properly formed Jr, Sr, or ordinal in the range 1–9.
Puncutation not allowed.

]]

local function is_suffix (suffix)
	if utilities.in_array (suffix, {'Jr', 'Sr', 'Jnr', 'Snr', '1st', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;-------------------

For Vancouver style, author/editor names are supposed to be rendered in Latin
(read ASCII) characters.  When a name uses characters that contain diacritical
marks, those characters are to be converted to the corresponding Latin
character. When a name is written using a non-Latin alphabet or logogram, that
name is to be transliterated into Latin characters. The module doesn't do this
so editors may/must.

This test allows |first= and |last= names to contain any of the letters defined
in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes.
	(http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;)
	or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written outside of the code editor and pasted here because the code editor
gets confused between character insertion point and cursor position. The test has
been rewritten to use decimal character escape sequence for the individual bytes
of the Unicode characters so that it is not necessary to use an external editor
to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first, suffix, position)
	if not suffix then
		if first:find ('[,%s]') then											-- when there is a space or comma, might be first name/initials + generational suffix
			first = first:match ('(.-)[,%s]+');									-- get name/initials
			suffix = first:match ('[,%s]+(.+)$');								-- get generational suffix
		end
	end
	if utilities.is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error (cfg.err_msg_supl.suffix, position);
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error (cfg.err_msg_supl['non-Latin char'], position);
			return false;														-- not a string of Latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-style=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period.
See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc.) to be rendered
as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format
because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the
Unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first, position)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just initials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error (cfg.err_msg_supl.suffix, position);			-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word

	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i], 1, 1));			-- insert the initial at end of initials table
		end
		i = i + 1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; L I S T _ P E O P L E &gt;--------------------------

Formats a list of people (authors, contributors, editors, interviewers, translators) 

names in the list will be linked when
	|&lt;name&gt;-link= has a value
	|&lt;name&gt;-mask- does NOT have a value; masked names are presumed to have been
		rendered previously so should have been linked there

when |&lt;name&gt;-mask=0, the associated name is not rendered

]]

local function list_people (control, people, etal)
	local sep;
	local namesep;
	local format = control.format;
	local maximum = control.maximum;
	local name_list = {};

	if 'vanc' == format then													-- Vancouver-like name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between names is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between names is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub (-1, -1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if utilities.is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end		-- returned 0 is for EditorCount; not used for other names
	
	for i, person in ipairs (people) do
		if utilities.is_set (person.last) then
			local mask = person.mask;
			local one;
			local sep_one = sep;

			if utilities.is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			end
			
			if mask then
				local n = tonumber (mask);										-- convert to a number if it can be converted; nil else
				if n then
					one = 0 ~= n and string.rep(&quot;&amp;mdash;&quot;, n) or nil;			-- make a string of (n &gt; 0) mdashes, nil else, to replace name
					person.link = nil;											-- don't create link to name if name is replaces with mdash string or has been set nil
				else
					one = mask;													-- replace name with mask text (must include name-list separator)
					sep_one = &quot; &quot;;												-- modify name-list separator
				end
			else
				one = person.last;												-- get surname
				local first = person.first										-- get given name
				if utilities.is_set (first) then
					if (&quot;vanc&quot; == format) then									-- if Vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first, nil, i) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials (first, i);				-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
			end
			if utilities.is_set (person.link) then
				one = utilities.make_wikilink (person.link, one);				-- link author/editor
			end
			if one then															-- if &lt;one&gt; has a value (name, mdash replacement, or mask text replacement)
				table.insert (name_list, one);									-- add it to the list of names
				table.insert (name_list, sep_one);								-- add the proper name-list separator
			end
		end
	end

	local count = #name_list / 2;												-- (number of names + number of separators) divided by 2
	if 0 &lt; count then 
		if 1 &lt; count and not etal then
			if 'amp' == format then
				name_list[#name_list-2] = &quot; &amp; &quot;;								-- replace last separator with ampersand text
			elseif 'and' == format then
				if 2 == count then
					name_list[#name_list-2] = cfg.presentation.sep_nl_and;		-- replace last separator with 'and' text
				else
					name_list[#name_list-2] = cfg.presentation.sep_nl_end;		-- replace last separator with '(sep) and' text
				end
			end
		end
		name_list[#name_list] = nil;											-- erase the last separator
	end

	local result = table.concat (name_list);									-- construct list
	if etal and utilities.is_set (result) then									-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've got a last-first list and etal so add et al.
	end
	
	return result, count;														-- return name-list string and count of number of names (count used for editor names only)
end


--[[--------------------&lt; M A K E _ C I T E R E F _ I D &gt;-----------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise
returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that
order.  year is Year or anchor_year.

]]

local function make_citeref_id (namelist, year)
	local names={};							-- a table for the one to four names and year
	for i,v in ipairs (namelist) do			-- loop through the list and take up to the first four last names
		names[i] = v.last
		if i == 4 then break end			-- if four then done
	end
	table.insert (names, year);				-- add the year at the end
	local id = table.concat(names);			-- concatenate names and year for CITEREF id
	if utilities.is_set (id) then			-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;				-- add the CITEREF portion
	else
		return '';							-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; C I T E _ C L A S S _A T T R I B U T E _M A K E &gt;------------------------------

construct &lt;cite&gt; tag class attribute for this citation.

&lt;cite_class&gt; – config.CitationClass from calling template
&lt;mode&gt; – value from |mode= parameter

]]

local function cite_class_attribute_make (cite_class, mode)
	local class_t = {};
	table.insert (class_t, 'citation');											-- required for blue highlight
	if 'citation' ~= cite_class then
		table.insert (class_t, cite_class);										-- identify this template for user css
		table.insert (class_t, utilities.is_set (mode) and mode or 'cs1');		-- identify the citation style for user css or javascript
	else
		table.insert (class_t, utilities.is_set (mode) and mode or 'cs2');		-- identify the citation style for user css or javascript
	end
	for _, prop_key in ipairs (z.prop_keys_t) do
		table.insert (class_t, prop_key);										-- identify various properties for user css or javascript
	end

	return table.concat (class_t, ' ');											-- make a big string and done
end


--[[---------------------&lt; N A M E _ H A S _ E T A L &gt;--------------------------

Evaluates the content of name parameters (author, editor, etc.) for variations on
the theme of et al.  If found, the et al. is removed, a flag is set to true and
the function returns the modified name and the flag.

This function never sets the flag to false but returns its previous state because
it may have been set by previous passes through this function or by the associated
|display-&lt;names&gt;=etal parameter

]]

local function name_has_etal (name, etal, nocat, param)

	if utilities.is_set (name) then												-- name can be nil in which case just return
		local patterns = cfg.et_al_patterns; 									-- get patterns from configuration
		
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns
			if name:match (pattern) then										-- if this 'et al' pattern is found in name
				name = name:gsub (pattern, '');									-- remove the offending text
				etal = true;													-- set flag (may have been set previously here or by |display-&lt;names&gt;=etal)
				if not nocat then												-- no categorization for |vauthors=
					utilities.set_message ('err_etal', {param});				-- and set an error if not added
				end
			end
		end
	end

	return name, etal;
end


--[[---------------------&lt; N A M E _ I S _ N U M E R I C &gt;----------------------

Add maint cat when name parameter value does not contain letters.  Does not catch
mixed alphanumeric names so |last=A. Green (1922-1987) does not get caught in the
current version of this test but |first=(1888) is caught.

returns nothing

]]

local function name_is_numeric (name, list_name)
	if utilities.is_set (name) then
		if mw.ustring.match (name, '^[%A]+$') then								-- when name does not contain any letters
			utilities.set_message ('maint_numeric_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
		end
	end
end


--[[-----------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;------------------

Evaluates the content of last/surname (authors etc.) parameters for multiple names.
Multiple names are indicated if there is more than one comma or any &quot;unescaped&quot;
semicolons. Escaped semicolons are ones used as part of selected HTML entities.
If the condition is met, the function adds the multiple name maintenance category.

returns nothing

]]

local function name_has_mult_names (name, list_name)
	local _, commas, semicolons, nbsps;
	if utilities.is_set (name) then
		_, commas = name:gsub (',', '');										-- count the number of commas
		_, semicolons = name:gsub (';', '');									-- count the number of semicolons
		-- nbsps probably should be its own separate count rather than merged in
		-- some way with semicolons because Lua patterns do not support the
		-- grouping operator that regex does, which means there is no way to add
		-- more entities to escape except by adding more counts with the new
		-- entities
		_, nbsps = name:gsub ('&amp;nbsp;','');										-- count nbsps
		
		-- There is exactly 1 semicolon per &amp;nbsp; entity, so subtract nbsps
		-- from semicolons to 'escape' them. If additional entities are added,
		-- they also can be subtracted.
		if 1 &lt; commas or 0 &lt; (semicolons - nbsps) then
			utilities.set_message ('maint_mult_names', cfg.special_case_translation [list_name]);	-- add a maint message
		end
	end
end


--[[--------------------------&lt; I S _ G E N E R I C &gt;----------------------------------------------------------

Compares values assigned to various parameter according to the string provided as &lt;item&gt; in the function call:
	'generic_names': |last=, |first=, |editor-last=, etc value against list of known generic name patterns
	'generic_titles': |title=
Returns true when pattern matches; nil else

The k/v pairs in cfg.special_case_translation[item] each contain two tables, one for English and one for another
'local' language.Each of those tables contain another table that holds the string or pattern (whole or fragment)
in index [1]. index [2] is a Boolean that tells string.find() or mw.ustring.find() to do plain-text search (true)
or a pattern search (false).  The intent of all this complexity is to make these searches as fast as possible so
that we don't run out of processing time on very large articles.

]]

local function is_generic (item, value)
	value = mw.ustring.lower(value);											-- switch value to lower case
	for _, generic_value in ipairs (cfg.special_case_translation[item]) do		-- spin through the list of known generic value fragments
		if value:find (generic_value['en'][1], 1, generic_value['en'][2]) then
			return true;														-- found English generic value so done
		elseif generic_value['local'] then										-- to keep work load down, generic_&lt;value&gt;['local'] should be nil except when there is a local version of the generic value
			if mw.ustring.find (value, generic_value['local'][1], 1, generic_value['local'][2]) then	-- mw.ustring() because might not be Latin script
				return true;													-- found local generic value so done
			end
		end
	end
end


--[[--------------------------&lt; N A M E _ I S _ G E N E R I C &gt;------------------------------------------------

calls is_generic() to determine if &lt;name&gt; is a 'generic name' listed in cfg.generic_names; &lt;name_alias&gt; is the
parameter name used in error messaging

]]

local function name_is_generic (name, name_alias)
	if not added_generic_name_errs  and is_generic ('generic_names', name) then
		utilities.set_message ('err_generic_name', name_alias);					-- set an error message
		added_generic_name_errs = true;
	end
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------

This function calls various name checking functions used to validate the content of the various name-holding parameters.

]]

local function name_checks (last, first, list_name, last_alias, first_alias)
	local accept_name;

	if utilities.is_set (last) then
		last, accept_name = utilities.has_accept_as_written (last);				-- remove accept-this-as-written markup when it wraps all of &lt;last&gt;

		if not accept_name then													-- &lt;last&gt; not wrapped in accept-as-written markup
			name_has_mult_names (last, list_name);								-- check for multiple names in the parameter (last only)
			name_is_numeric (last, list_name);									-- check for names that are composed of digits and punctuation
			name_is_generic (last, last_alias);									-- check for names found in the generic names list
		end
	end

	if utilities.is_set (first) then
		first, accept_name = utilities.has_accept_as_written (first);			-- remove accept-this-as-written markup when it wraps all of &lt;first&gt;

		if not accept_name then													-- &lt;first&gt; not wrapped in accept-as-written markup
			name_is_numeric (first, list_name);									-- check for names that are composed of digits and punctuation
			name_is_generic (first, first_alias);								-- check for names found in the generic names list
		end
		local wl_type, D = utilities.is_wikilink (first);
		if 0 ~= wl_type then
			first = D;
			utilities.set_message ('err_bad_paramlink', first_alias);
		end
	end

	return last, first;															-- done
end


--[[----------------------&lt; E X T R A C T _ N A M E S &gt;-------------------------

Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters
(or their aliases), and their matching link and mask parameters. Stops searching
when both |lastn= and |firstn= are not found in args after two sequential attempts:
found |last1=, |last2=, and |last3= but doesn't find |last4= and |last5= then the
search is done.

This function emits an error message when there is a |firstn= without a matching
|lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not
required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.'
is stripped from the parameter and a flag (etal) returned that will cause list_people()
to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps
'et al.' out of the template's metadata.  When this occurs, an error is emitted.

]]

local function extract_names(args, list_name)
	local names = {};															-- table of names
	local last;																	-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;																-- loop counter/indexer
	local n = 1;																-- output table indexer
	local count = 0;															-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal = false;															-- return value set to true when we find some form of et al. in an author parameter

	local last_alias, first_alias, link_alias;									-- selected parameter aliases used in error messaging
	while true do
		last, last_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'err_redundant_parameters', i );		-- search through args for name components beginning at 1
		first, first_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'err_redundant_parameters', i );
		link, link_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i );
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.
		last, first = name_checks (last, first, list_name, last_alias, first_alias);						-- multiple names, extraneous annotation, etc. checks

		if first and not last then												-- if there is a firstn without a matching lastn
			local alias = first_alias:find ('given', 1, true) and 'given' or 'first';	-- get first or given form of the alias
			utilities.set_message ('err_first_missing_last', {
				first_alias,													-- param name of alias missing its mate
				first_alias:gsub (alias, {['first'] = 'last', ['given'] = 'surname'}),	-- make param name appropriate to the alias form
				});																-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			local result;
			link = link_title_ok (link, link_alias, last, last_alias);			-- check for improper wiki-markup

			if first then
				link = link_title_ok (link, link_alias, first, first_alias);	-- check for improper wiki-markup
			end

			names[n] = {last = last, first = first, link = link, mask = mask, corporate = false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				utilities.set_message ('err_missing_name', {list_name:match (&quot;(%w+)List&quot;):lower(), i - 1});	-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names and the etal flag
end


--[[---------------------&lt; G E T _ I S O 6 3 9 _ C O D E &gt;----------------------

Validates language names provided in |language= parameter if not an ISO639-1 or 639-2 code.

Returns the language name and associated two- or three-character code.  Because
case of the source may be incorrect or different from the case that WikiMedia uses,
the name comparisons are done in lower case and when a match is found, the Wikimedia
version (assumed to be correct) is returned along with the code.  When there is no
match, we return the original language name string.

mw.language.fetchLanguageNames(&lt;local wiki language&gt;, 'all') returns a list of
languages that in some cases may include extensions. For example, code 'cbk-zam'
and its associated name 'Chavacano de Zamboanga' (MediaWiki does not support
code 'cbk' or name 'Chavacano'.  Most (all?) of these languages are not used a
'language' codes per se, rather they are used as sub-domain names: cbk-zam.wikipedia.org.
A list of language names and codes supported by fetchLanguageNames() can be found
at Template:Citation Style documentation/language/doc

Names that are included in the list will be found if that name is provided in the
|language= parameter.  For example, if |language=Chavacano de Zamboanga, that name
will be found with the associated code 'cbk-zam'.  When names are found and the
associated code is not two or three characters, this function returns only the
WikiMedia language name.

Some language names have multiple entries under different codes:
	Aromanian has code rup and code roa-rup
When this occurs, this function returns the language name and the 2- or 3-character code

Adapted from code taken from Module:Check ISO 639-1.

]]

local function get_iso639_code (lang, this_wiki_code)
	if cfg.lang_name_remap[lang:lower()] then									-- if there is a remapped name (because MediaWiki uses something that we don't think is correct)
		return cfg.lang_name_remap[lang:lower()][1], cfg.lang_name_remap[lang:lower()][2];	-- for this language 'name', return a possibly new name and appropriate code
	end

	local ietf_tag;																-- because some languages have both IETF-like tags and ISO 639-like tags
	local ietf_name;
	
	local langlc = mw.ustring.lower (lang);										-- lower-case version for comparisons

	for tag, name in pairs (cfg.languages) do									-- scan the list to see if we can find our language
		if langlc == mw.ustring.lower (name) then
			if 2 == #tag or 3 == #tag then										-- two- or three-character tags preferred over IETF-like tags with the same name
				return name, tag;												-- found it so return the name and the tag
			end
			ietf_tag = tag;														-- remember that we found an IETF-like tag and save its name and tag
			ietf_name = name;													-- but keep looking for a 2- or 3-char tag version
		end
	end
	
	if ietf_tag and ietf_name then												-- when we didn't find name with 2- or 3-char tag but did find IETF-like tag
		return ietf_name, ietf_tag;												-- return name with IETF-like tag
	else
		return lang;															-- not found, return original language text
	end
end


--[[-------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code
is recognized by MediaWiki, use the returned name; if not, then use the value that
was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is
assigned to the category for that code: Category:Norwegian-language sources (no).
For valid three-character code languages, the page is assigned to the single category
for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does
not recognize three-character equivalents of two-character codes: code 'ar' is
recognized but code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th
where the language names or codes are separated from each other by commas with
optional space characters.

]]

local function language_parameter (lang)
	local code;																	-- the two- or three-character language code
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_table = {};														-- table made from the value assigned to |language=

	local this_wiki_name = mw.language.fetchLanguageName (cfg.this_wiki_code, cfg.this_wiki_code);	-- get this wiki's language name

	names_table = mw.text.split (lang, '%s*,%s*');								-- names should be a comma separated list

	for _, lang in ipairs (names_table) do										-- reuse lang
		name = cfg.lang_code_remap[lang:lower()];								-- first see if this is a code that is not supported by MediaWiki but is in remap

		if not name then
			name = mw.language.fetchLanguageName (lang:lower(), cfg.this_wiki_code);	-- get language name if &lt;lang&gt; is a MediaWiki known code; empty string if not known
		end

		if utilities.is_set (name) then											-- if |language= specified a valid code
			code = lang:lower();												-- save it
		else
			name, code = get_iso639_code (lang, cfg.this_wiki_code);			-- attempt to get code from name (assign name here so that we are sure of proper capitalization)
		end

		if utilities.is_set (code) then
			name = cfg.lang_code_remap[code] or name;							-- override wikimedia when they misuse language codes/names

			code = code:gsub ('^(%a%a%a?)%-.*', '%1');							-- for categorization, strip any IETF-like tags from language tag

			if cfg.this_wiki_code ~= code then									-- when the language is not the same as this wiki's language
				if 2 == code:len() then											-- and is a two-character code
					utilities.add_prop_cat ('foreign-lang-source', {name, code}, code);		-- categorize it; code appended to allow for multiple language categorization
				else															-- or is a recognized language (but has a three-character code)
					utilities.add_prop_cat ('foreign-lang-source-2', {code}, code);			-- categorize it differently TODO: support multiple three-character code categories per cs1|2 template
				end
			elseif cfg.local_lang_cat_enable then								-- when the language and this wiki's language are the same and categorization is enabled
				utilities.add_prop_cat ('local-lang-source', {name, code});		-- categorize it
			end
		else
			utilities.set_message ('maint_unknown_lang');						-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
 
	name = utilities.make_sep_list (#language_list, language_list);
	if (1 == #language_list) and (code == cfg.this_wiki_code) then				-- when only one language, find lang name in this wiki lang name; for |language=en-us, 'English' in 'American English'
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[-----------------------&lt; S E T _ C S _ S T Y L E &gt;--------------------------

Gets the default CS style configuration for the given mode.
Returns default separator and either postscript as passed in or the default.
In CS1, the default postscript and separator are '.'.
In CS2, the default postscript is the empty string and the default separator is ','.

]]

local function set_cs_style (postscript, mode)
	if utilities.is_set(postscript) then
		-- emit a maintenance message if user postscript is the default cs1 postscript
		-- we catch the opposite case for cs2 in set_style
		if mode == 'cs1' and postscript == cfg.presentation['ps_' .. mode] then
			utilities.set_message ('maint_postscript');
		end
	else
		postscript = cfg.presentation['ps_' .. mode];
	end
	return cfg.presentation['sep_' .. mode], postscript;
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;-----------------------------

Sets the separator and postscript styles. Checks the |mode= first and the
#invoke CitationClass second. Removes the postscript if postscript == none.

]]

local function set_style (mode, postscript, cite_class)
	local sep;
	if 'cs2' == mode then
		sep, postscript = set_cs_style (postscript, 'cs2');
	elseif 'cs1' == mode then
		sep, postscript = set_cs_style (postscript, 'cs1');
	elseif 'citation' == cite_class	then
		sep, postscript = set_cs_style (postscript, 'cs2');
	else
		sep, postscript = set_cs_style (postscript, 'cs1');
	end

	if cfg.keywords_xlate[postscript:lower()] == 'none' then
		-- emit a maintenance message if user postscript is the default cs2 postscript
		-- we catch the opposite case for cs1 in set_cs_style
		if 'cs2' == mode or 'citation' == cite_class then
			utilities.set_message ('maint_postscript');
		end
		postscript = '';
	end
	
	return sep, postscript
end


--[=[-------------------------&lt; I S _ P D F &gt;-----------------------------------

Determines if a URL has the file extension that is one of the PDF file extensions
used by [[MediaWiki:Common.css]] when applying the PDF icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or
		url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
		url:match ('%.PDF&amp;#035') or url:match ('%.pdf&amp;#035');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;-----------------------

Applies CSS style to |format=, |chapter-format=, etc.  Also emits an error message
if the format parameter does not have a matching URL parameter.  If the format parameter
is not set and the URL contains a file extension that is recognized as a PDF document
by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if utilities.is_set (format) then
		format = utilities.wrap_style ('format', format);						-- add leading space, parentheses, resize
		if not utilities.is_set (url) then
			utilities.set_message ('err_format_missing_url', {fmt_param, url_param});	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if URL is a PDF file then
		format = utilities.wrap_style ('format', 'PDF');						-- set format to PDF
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[---------------------&lt; G E T _ D I S P L A Y _ N A M E S &gt;------------------

Returns a number that defines the number of names displayed for author and editor
name lists and a Boolean flag to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero,
return the number and the previous state of the 'etal' flag (false by default
but may have been set to true if the name list contains some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number
that is one greater than the number of authors in the list and set the 'etal' flag true.
This will cause the list_people() to display all of the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_names (max, count, list_name, etal, param)
	if utilities.is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				utilities.set_message ('err_disp_name', {param, max});			-- add error message
				max = nil;
			end
		else																	-- not a valid keyword or number
			utilities.set_message ('err_disp_name', {param, max});		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[----------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;---------------

Adds error if |page=, |pages=, |quote-page=, |quote-pages= has what appears to be
some form of p. or pp. abbreviation in the first characters of the parameter content.

check page for extraneous p, p., pp, pp., pg, pg. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when page begins PX or P# but not Px
		      where x and X are letters and # is a digit
	bad pattern:  '^[Pp][PpGg]' matches when page begins pp, pP, Pp, PP, pg, pG, Pg, PG

]]

local function extra_text_in_page_check (val, name)
	if not val:match (cfg.vol_iss_pg_patterns.good_ppattern) then
		for _, pattern in ipairs (cfg.vol_iss_pg_patterns.bad_ppatterns) do		-- spin through the selected sequence table of patterns
			if val:match (pattern) then											-- when a match, error so
				utilities.set_message ('err_extra_text_pages', name);	 		-- add error message
				return;															-- and done
			end
		end
	end		
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ V O L _ I S S _ C H E C K &gt;------------------------

Adds error if |volume= or |issue= has what appears to be some form of redundant 'type' indicator.

For |volume=:
	'V.', or 'Vol.' (with or without the dot) abbreviations or 'Volume' in the first characters of the parameter
	content (all case insensitive). 'V' and 'v' (without the dot) are presumed to be roman numerals so
	are allowed.

For |issue=:
	'No.', 'I.', 'Iss.' (with or without the dot) abbreviations, or 'Issue' in the first characters of the
	parameter content (all case insensitive).
	
Single character values ('v', 'i', 'n') allowed when not followed by separator character ('.', ':', '=', or
whitespace character) – param values are trimmed of whitespace by MediaWiki before delivered to the module.
	
&lt;val&gt; is |volume= or |issue= parameter value
&lt;name&gt; is |volume= or |issue= parameter name for error message
&lt;selector&gt; is 'v' for |volume=, 'i' for |issue=

sets error message on failure; returns nothing

]]

local function extra_text_in_vol_iss_check (val, name, selector)
	if not utilities.is_set (val) then
		return;
	end
	
	local patterns = 'v' == selector and cfg.vol_iss_pg_patterns.vpatterns or cfg.vol_iss_pg_patterns.ipatterns;

	local handler = 'v' == selector and 'err_extra_text_volume' or 'err_extra_text_issue';
	val = val:lower();															-- force parameter value to lower case
	for _, pattern in ipairs (patterns) do										-- spin through the selected sequence table of patterns
		if val:match (pattern) then												-- when a match, error so
			utilities.set_message (handler, name);								-- add error message
			return;																-- and done
		end
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parentheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a placeholder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parentheses
			local name = name_table[i];
			i = i + 1;															-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parentheses
					break;														-- and done reassembling so
				end
				i = i + 1;														-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = utilities.is_wikilink (name_table[i]);		-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i + 1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled parentheses ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the Vancouver error when a required comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		first = '';																-- set to empty string for concatenation and because it may have been set for previous author/editor
		local accept_name;
		v_name, accept_name = utilities.has_accept_as_written (v_name);			-- remove accept-this-as-written markup when it wraps all of &lt;v_name&gt;

		if accept_name then
			last = v_name;
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error (cfg.err_msg_supl.punctuation, i);
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s+&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be initials or generational suffix

			if not mw.ustring.match (first, '^%u+$') then						-- mw.ustring here so that later we will catch non-Latin characters
				suffix = first;													-- not initials so assume that whatever we got is a generational suffix
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end
			last = table.concat(lastfirstTable, ' ')							-- returns a string that is the concatenation of all other names that are not initials and generational suffix
			if not utilities.is_set (last) then
				first = '';														-- unset
				last = v_name;													-- last empty because something wrong with first
				add_vanc_error (cfg.err_msg_supl.name, i);
			end
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error (cfg.err_msg_supl['missing comma'], i);			-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- matches a space between two initials
			end
		else
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
		
		if utilities.is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first, suffix, i);							-- check first and last before restoring the suffix which may have a non-Latin digit
			if utilities.is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '', nil, i);
			end
		end

		link = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i ) or v_link_table[i];
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate = corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest;
|editorn= (and aliases) highest and |veditors= lowest (support for |editors= withdrawn)

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
	local lastfirst = false;
	if utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice in case we have a |first1= without a |last1=; this ...
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or		-- ... also catches the case where |first= is used with |vauthors=
		utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst = true;
	end

	if (utilities.is_set (vxxxxors) and true == lastfirst) or					-- these are the three error conditions
		(utilities.is_set (vxxxxors) and utilities.is_set (xxxxors)) or
		(true == lastfirst and utilities.is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			utilities.set_message ('err_redundant_parameters', err_name .. '-name-list parameters');	-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if utilities.is_set (vxxxxors) then return 2 end;
	if utilities.is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, live, dead, etc.).  When the parameter value has not been assigned a value (missing
or empty in the source template) the function returns the value specified by ret_val.  If the parameter value is one
of the list of allowed values returns the translated value; else, emits an error message and returns the value
specified by ret_val.

TODO: explain &lt;invert&gt;

]]

local function is_valid_parameter_value (value, name, possible, ret_val, invert)
	if not utilities.is_set (value) then
		return ret_val;															-- an empty parameter is ok
	end

	if (not invert and utilities.in_array (value, possible)) then				-- normal; &lt;value&gt; is in &lt;possible&gt; table
		return cfg.keywords_xlate[value];										-- return translation of parameter keyword
	elseif invert and not utilities.in_array (value, possible) then				-- invert; &lt;value&gt; is not in &lt;possible&gt; table
		return value;															-- return &lt;value&gt; as it is
	else
		utilities.set_message ('err_invalid_param_val', {name, value});			-- not an allowed value so add error message
		return ret_val;
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list, -3, -1) == sepc .. '. ') then					-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list, -1, -1) == sepc) or (string.sub (name_list, -3, -1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terminate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not utilities.is_set (volume) and not utilities.is_set (issue) then
		return '';
	end

	-- same condition as in format_pages_sheets()
	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);

	local is_numeric_vol = volume and (volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$'));	-- is only uppercase roman numerals or only digits?
	local is_long_vol = volume and (4 &lt; mw.ustring.len(volume));				-- is |volume= value longer than 4 characters?
	
	if volume and (not is_numeric_vol and is_long_vol) then						-- when not all digits or Roman numerals, is |volume= longer than 4 characters?
		utilities.add_prop_cat ('long-vol');									-- yes, add properties cat
	end

	if is_journal then															-- journal-style formatting
		local vol = '';
		
		if utilities.is_set (volume) then
			if is_numeric_vol then												-- |volume= value all digits or all uppercase Roman numerals?
				vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, volume});	-- render in bold face
			elseif is_long_vol then												-- not all digits or Roman numerals; longer than 4 characters?
				vol = utilities.substitute (cfg.messages['j-vol'], {sepc, utilities.hyphen_to_dash (volume)});	-- not bold
			else																-- four or fewer characters
				vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, utilities.hyphen_to_dash (volume)});	-- bold
			end
		end
		if utilities.is_set (issue) then
			return vol .. utilities.substitute (cfg.messages['j-issue'], issue);
		end
		return vol;
	end
	
	if 'podcast' == cite_class and utilities.is_set (issue) then
		return wrap_msg ('issue', {sepc, issue}, lower);
	end

	-- all other types of citation
	if utilities.is_set (volume) and utilities.is_set (issue) then
		return wrap_msg ('vol-no', {sepc, utilities.hyphen_to_dash (volume), issue}, lower);
	elseif utilities.is_set (volume) then
		return wrap_msg ('vol', {sepc, utilities.hyphen_to_dash (volume)}, lower);
	else
		return wrap_msg ('issue', {sepc, issue}, lower);
	end
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if utilities.is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif utilities.is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if utilities.is_set (page) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return utilities.substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return utilities.substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif utilities.is_set (pages) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then							-- if pages is only digits, assume a single page number
			return '', utilities.substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', utilities.substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', utilities.substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to Wikisource, returns the label portion of the interwiki-link as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki-link to an external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, page_orig, pages, pages_orig, at)
	local ws_url, ws_label, coins_pages, L;										-- for Wikisource interwiki-links; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if utilities.is_set (page) then
		if utilities.is_set (pages) or utilities.is_set (at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page, page_orig);								-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws URL from |page= interwiki link; link portion L becomes tooltip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (pages) then
		if utilities.is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages, pages_orig);							-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws URL from |pages= interwiki link; link portion L becomes tooltip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws URL from |at= interwiki link; link portion L becomes tooltip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end

--[[--------------------------&lt; I S _ U N I Q U E _ A R C H I V E _ U R L &gt;------------------------------------

add error message when |archive-url= value is same as |url= or chapter-url= (or alias...) value

]]

local function is_unique_archive_url (archive, url, c_url, source, date)
	if utilities.is_set (archive) then
		if archive == url or archive == c_url then
			utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)});	-- add error message
			return '', '';														-- unset |archive-url= and |archive-date= because same as |url= or |chapter-url=
		end
	end

	return archive, date;
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org URLs to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot URL or to calendar pages.  When the archive URL is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the URL.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org URL does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command URL
	|archive-url= is an archive.org URL that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org URLs:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this function may return a modified
archive URL:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the URL unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.org URL
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine URL
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command URL, we don't want to allow saving of the target page 
		err_msg = cfg.err_msg_supl.save;
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = cfg.err_msg_supl.liveweb;
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');	-- split out some of the URL parts for evaluation
		if not path then														-- malformed in some way; pattern did not match
			err_msg = cfg.err_msg_supl.timestamp;
		elseif 14 ~= timestamp:len() then										-- path and flag optional, must have 14-digit timestamp here
			err_msg = cfg.err_msg_supl.timestamp;
			if '*' ~= flag then
				local replacement = timestamp:match ('^%d%d%d%d%d%d') or timestamp:match ('^%d%d%d%d');	-- get the first 6 (YYYYMM) or first 4 digits (YYYY)
				if replacement then												-- nil if there aren't at least 4 digits (year)
					replacement = replacement .. string.rep ('0', 14 - replacement:len());	-- year or yearmo (4 or 6 digits) zero-fill to make 14-digit timestamp
					url=url:gsub ('(//web%.archive%.org/[^%d]*)%d[^/]*', '%1' .. replacement .. '*', 1)	-- for preview, modify ts to 14 digits plus splat for calendar display
				end
			end
		elseif utilities.is_set (path) and 'web/' ~= path then					-- older archive URLs do not have the extra 'web/' path element
			err_msg = cfg.err_msg_supl.path;
		elseif utilities.is_set (flag) and not utilities.is_set (path) then		-- flag not allowed with the old form URL (without the 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		elseif utilities.is_set (flag) and not flag:match ('%a%a_') then		-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		else
			return url, date;													-- return ArchiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	utilities.set_message ('err_archive_url', {err_msg});						-- add error message and

	if is_preview_mode then
		return url, date;														-- preview mode so return ArchiveURL and ArchiveDate
	else
		return '', '';															-- return empty strings for ArchiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; P L A C E _ C H E C K &gt;--------------------------------------------------------

check |place=, |publication-place=, |location= to see if these params include digits.  This function added because
many editors misuse location to specify the in-source location (|page(s)= and |at= are supposed to do that)

returns the original parameter value without modification; added maint cat when parameter value contains digits

]]

local function place_check (param_val)
	if not utilities.is_set (param_val) then									-- parameter empty or omitted
		return param_val;														-- return that empty state
	end
	
	if mw.ustring.find (param_val, '%d') then									-- not empty, are there digits in the parameter value
		utilities.set_message ('maint_location');								-- yep, add maint cat
	end
	
	return param_val;															-- and done
end


--[[--------------------------&lt; I S _ A R C H I V E D _ C O P Y &gt;----------------------------------------------

compares |title= to 'Archived copy' (placeholder added by bots that can't find proper title); if matches, return true; nil else

]]

local function is_archived_copy (title)
	title = mw.ustring.lower(title);											-- switch title to lower case
	if title:find (cfg.special_case_translation.archived_copy.en) then			-- if title is 'Archived copy'
		return true;
	elseif cfg.special_case_translation.archived_copy['local'] then
		if mw.ustring.find (title, cfg.special_case_translation.archived_copy['local']) then	-- mw.ustring() because might not be Latin script
			return true;
		end
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args )
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper ( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListStyle = is_valid_parameter_value (A['NameListStyle'], A:ORIGIN('NameListStyle'), cfg.keywords_lists['name-list-style'], '');
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				utilities.set_message ('maint_authors');						-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if utilities.is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], nil, args, 'EditorList');	-- support for |editors= withdrawn
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		end
	end
							
	local Chapter = A['Chapter'];												-- done here so that we have access to |contribution= from |chapter= aliases
	local Chapter_origin = A:ORIGIN ('Chapter');
	local Contribution;															-- because contribution is required for contributor(s)
		if 'contribution' == Chapter_origin then
			Contribution = Chapter;												-- get the name of the contribution
		end
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	
	if utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not utilities.is_set (Contribution) then							-- |contributor= requires |contribution=
				utilities.set_message ('err_contributor_missing_required_param', 'contribution');	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				utilities.set_message ('err_contributor_missing_required_param', 'author');	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if utilities.select_one (args, cfg.aliases['ContributorList-Last'], 'err_redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			utilities.set_message ('err_contributor_ignored');					-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	local Title = A['Title'];
	local TitleLink = A['TitleLink'];

	local auto_select = ''; -- default is auto
	local accept_link;
	TitleLink, accept_link = utilities.has_accept_as_written (TitleLink, true);	-- test for accept-this-as-written markup
	if (not accept_link) and utilities.in_array (TitleLink, {'none', 'pmc', 'doi'}) then -- check for special keywords
		auto_select = TitleLink;												-- remember selection for later
		TitleLink = '';															-- treat as if |title-link= would have been empty
	end

	TitleLink = link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wiki-markup in |title-link= or wiki-markup in |title= when |title-link= is set

	local Section = '';															-- {{cite map}} only; preset to empty string for concatenation if not used
	if 'map' == config.CitationClass and 'section' == Chapter_origin then
		Section = A['Chapter'];													-- get |section= from |chapter= alias list; |chapter= and the other aliases not supported in {{cite map}}
		Chapter = '';															-- unset for now; will be reset later from |map= if present
	end

	local Periodical = A['Periodical'];
	local Periodical_origin = '';
	if utilities.is_set (Periodical) then
		Periodical_origin = A:ORIGIN('Periodical');								-- get the name of the periodical parameter
		local i;
		Periodical, i = utilities.strip_apostrophe_markup (Periodical);			-- strip apostrophe markup so that metadata isn't contaminated 
		if i then																-- non-zero when markup was stripped so emit an error message
			utilities.set_message ('err_apostrophe_markup', {Periodical_origin});
		end
	end

	if 'mailinglist' == config.CitationClass then								-- special case for {{cite mailing list}}
		if utilities.is_set (Periodical) and utilities.is_set (A ['MailingList']) then	-- both set emit an error TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', Periodical_origin) .. ' and ' .. utilities.wrap_style ('parameter', 'mailinglist')});
		end

		Periodical = A ['MailingList'];											-- error or no, set Periodical to |mailinglist= value because this template is {{cite mailing list}}
		Periodical_origin = A:ORIGIN('MailingList');
	end

	local ScriptPeriodical = A['ScriptPeriodical'];

	-- web and news not tested for now because of 
	-- Wikipedia:Administrators%27_noticeboard#Is_there_a_semi-automated_tool_that_could_fix_these_annoying_&quot;Cite_Web&quot;_errors?
	if not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) then	-- 'periodical' templates require periodical parameter
	--	local p = {['journal'] = 'journal', ['magazine'] = 'magazine', ['news'] = 'newspaper', ['web'] = 'website'};	-- for error message
		local p = {['journal'] = 'journal', ['magazine'] = 'magazine'};			-- for error message
		if p[config.CitationClass]  then
			utilities.set_message ('err_missing_periodical', {config.CitationClass, p[config.CitationClass]});
		end
	end
	
	local Volume;
	local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) then
			if not utilities.in_array (Periodical_origin, {'website', 'mailinglist'}) then	-- {{citation}} does not render volume for these 'periodicals' --TODO: move 'array' to ~/Configuration
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		elseif utilities.is_set (ScriptPeriodical) then
			if 'script-website' ~= ScriptPeriodical_origin then					-- {{citation}} does not render volume for |script-website=
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		else
			Volume = A['Volume'];												-- and does for non-'periodical' cites
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_volume) then	-- render |volume= for cs1 according to the configuration settings
		Volume = A['Volume'];
	end	
	extra_text_in_vol_iss_check (Volume, A:ORIGIN ('Volume'), 'v');	

	local Issue;
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) and utilities.in_array (Periodical_origin, {'journal', 'magazine', 'newspaper', 'periodical', 'work'}) or	-- {{citation}} renders issue for these 'periodicals'--TODO: move 'array' to ~/Configuration
			utilities.is_set (ScriptPeriodical) and utilities.in_array (ScriptPeriodical_origin, {'script-journal', 'script-magazine', 'script-newspaper', 'script-periodical', 'script-work'}) then -- and these 'script-periodicals'
				Issue = utilities.hyphen_to_dash (A['Issue']);
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_issue) then	-- conference &amp; map books do not support issue; {{citation}} listed here because included in settings table
		if not (utilities.in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical))) then
			Issue = utilities.hyphen_to_dash (A['Issue']);
		end
	end
	extra_text_in_vol_iss_check (Issue, A:ORIGIN ('Issue'), 'i');	

	local Page;
	local Pages;
	local At;
	if not utilities.in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = utilities.hyphen_to_dash (A['Pages']);	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = place_check (A['PublicationPlace'], A:ORIGIN('PublicationPlace'));
	local Place = place_check (A['Place'], A:ORIGIN('Place'));
	
	local PublisherName = A['PublisherName'];
	local PublisherName_origin = A:ORIGIN('PublisherName');
	if utilities.is_set (PublisherName) then
		local i = 0;
		PublisherName, i = utilities.strip_apostrophe_markup (PublisherName);	-- strip apostrophe markup so that metadata isn't contaminated; publisher is never italicized
		if i then																-- non-zero when markup was stripped so emit an error message
			utilities.set_message ('err_apostrophe_markup', {PublisherName_origin});
		end
	end

	local Newsgroup = A['Newsgroup'];											-- TODO: strip apostrophe markup?
	local Newsgroup_origin = A:ORIGIN('Newsgroup');	

	if 'newsgroup' == config.CitationClass then
		if utilities.is_set (PublisherName) then								-- general use parameter |publisher= not allowed in cite newsgroup
			utilities.set_message ('err_parameter_ignored', {PublisherName_origin});
		end

		PublisherName = nil;													-- ensure that this parameter is unset for the time being; will be used again after COinS
	end

	local URL = A['URL'];														-- TODO: better way to do this for URL, ChapterURL, and MapURL?
	local UrlAccess = is_valid_parameter_value (A['UrlAccess'], A:ORIGIN('UrlAccess'), cfg.keywords_lists['url-access'], nil);
	
	if not utilities.is_set (URL) and utilities.is_set (UrlAccess) then
		UrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', 'url');
	end
	
	local ChapterURL = A['ChapterURL'];
	local ChapterUrlAccess = is_valid_parameter_value (A['ChapterUrlAccess'], A:ORIGIN('ChapterUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (ChapterURL) and utilities.is_set (ChapterUrlAccess) then
		ChapterUrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', {A:ORIGIN('ChapterUrlAccess'):gsub ('%-access', '')});
	end

	local MapUrlAccess = is_valid_parameter_value (A['MapUrlAccess'], A:ORIGIN('MapUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (A['MapURL']) and utilities.is_set (MapUrlAccess) then
		MapUrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', {'map-url'});
	end

	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local no_tracking_cats = is_valid_parameter_value (A['NoTracking'], A:ORIGIN('NoTracking'), cfg.keywords_lists['yes_true_y'], nil);

	-- check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not utilities.is_set (no_tracking_cats) then								-- ignore if we are already not going to categorize this page
		if utilities.in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _, v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end
																				-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	utilities.select_one (args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'err_redundant_parameters');	-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, A:ORIGIN('Page'), Pages, A:ORIGIN('Pages'), At);

	local NoPP = is_valid_parameter_value (A['NoPP'], A:ORIGIN('NoPP'), cfg.keywords_lists['yes_true_y'], nil);

	if utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- both |publication-place= and |place= (|location=) allowed if different
		utilities.add_prop_cat ('location-test');								-- add property cat to evaluate how often PublicationPlace and Place are used together
		if PublicationPlace == Place then
			Place = '';															-- unset; don't need both if they are the same
		end
	elseif not utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- when only |place= (|location=) is set ...
		PublicationPlace = Place;												-- promote |place= (|location=) to |publication-place
	end

	if PublicationPlace == Place then Place = ''; end							-- don't need both if they are the same
	
	local URL_origin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL_origin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ScriptChapter = A['ScriptChapter'];
	local ScriptChapter_origin = A:ORIGIN ('ScriptChapter');
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local TransChapter = A['TransChapter'];
	local TransChapter_origin = A:ORIGIN ('TransChapter');
	local TransTitle = A['TransTitle'];
	local ScriptTitle = A['ScriptTitle'];
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia= and |title= then map |title= to |article= and |encyclopedia= to |title=
		|encyclopedia= and |article= then map |encyclopedia= to |title=

		|trans-title= maps to |trans-chapter= when |title= is re-mapped
		|url= maps to |chapter-url= when |title= is remapped
	
	All other combinations of |encyclopedia=, |title=, and |article= are not modified
	
	]]

	local Encyclopedia = A['Encyclopedia'];										-- used as a flag by this module and by ~/COinS

	if utilities.is_set (Encyclopedia) then										-- emit error message when Encyclopedia set but template is other than {{cite encyclopedia}} or {{citation}}
		if 'encyclopaedia' ~= config.CitationClass and 'citation' ~= config.CitationClass then
			utilities.set_message ('err_parameter_ignored', {A:ORIGIN ('Encyclopedia')});
			Encyclopedia = nil;													-- unset because not supported by this template
		end
	end

	if ('encyclopaedia' == config.CitationClass) or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Periodical) and utilities.is_set (Encyclopedia) then	-- when both set emit an error TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', A:ORIGIN ('Encyclopedia')) .. ' and ' .. utilities.wrap_style ('parameter', Periodical_origin)});
		end

		if utilities.is_set (Encyclopedia) then
			Periodical = Encyclopedia;											-- error or no, set Periodical to Encyclopedia; allow periodical without encyclopedia
			Periodical_origin = A:ORIGIN ('Encyclopedia');
		end

		if utilities.is_set (Periodical) then									-- Periodical is set when |encyclopedia= is set
			if utilities.is_set (Title) or utilities.is_set (ScriptTitle) then
				if not utilities.is_set (Chapter) then
					Chapter = Title;											-- |encyclopedia= and |title= are set so map |title= to |article= and |encyclopedia= to |title=
					ScriptChapter = ScriptTitle;
					ScriptChapter_origin = A:ORIGIN('ScriptTitle')
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterURL_origin = URL_origin;

					ChapterUrlAccess = UrlAccess;

					if not utilities.is_set (ChapterURL) and utilities.is_set (TitleLink) then
						Chapter = utilities.make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			elseif utilities.is_set (Chapter) or utilities.is_set (ScriptChapter) then								-- |title= not set
				Title = Periodical;												-- |encyclopedia= set and |article= set so map |encyclopedia= to |title=
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- special case for cite techreport.
	local ID = A['ID'];
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if utilities.is_set (A['Number']) then									-- cite techreport uses 'number', which other citations alias to 'issue'
			if not utilities.is_set (ID) then									-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'id') .. ' and ' .. utilities.wrap_style ('parameter', 'number')});
			end
		end	
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	local ChapterLink -- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local Conference = A['Conference'];
	local BookTitle = A['BookTitle'];
	local TransTitle_origin = A:ORIGIN ('TransTitle');
	if 'conference' == config.CitationClass then
		if utilities.is_set (BookTitle) then
			Chapter = Title;
			Chapter_origin = 'title';
	--		ChapterLink = TitleLink;											-- |chapter-link= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			URL_origin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			TransChapter_origin = TransTitle_origin;
			Title = BookTitle;
			Format = '';
	--		TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end
	
	-- CS1/2 mode
	local Mode = is_valid_parameter_value (A['Mode'], A:ORIGIN('Mode'), cfg.keywords_lists['mode'], '');
	-- separator character and postscript
	local sepc, PostScript = set_style (Mode:lower(), A['PostScript'], config.CitationClass);
	-- controls capitalization of certain static text
	local use_lowercase = ( sepc == ',' );
	
	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		if utilities.is_set (Chapter) then										--TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'map') .. ' and ' .. utilities.wrap_style ('parameter', Chapter_origin)});	-- add error message
		end
		Chapter = A['Map'];
		Chapter_origin = A:ORIGIN('Map');
		ChapterURL = A['MapURL'];
		ChapterURL_origin = A:ORIGIN('MapURL');
		TransChapter = A['TransMap'];
		ScriptChapter = A['ScriptMap']
		ScriptChapter_origin = A:ORIGIN('ScriptMap')

		ChapterUrlAccess = MapUrlAccess;
		ChapterFormat = A['MapFormat'];

		Cartography = A['Cartography'];
		if utilities.is_set ( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if utilities.is_set ( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	local Series = A['Series'];
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local SeriesLink = A['SeriesLink'];

		SeriesLink = link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wiki-markup in |series-link= or wiki-markup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if utilities.is_set (Network) then table.insert(n, Network); end
		if utilities.is_set (Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if utilities.is_set (Season) and utilities.is_set (SeriesNumber) then	-- these are mutually exclusive so if both are set TODO: make a function for this and similar?
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'season') .. ' and ' .. utilities.wrap_style ('parameter', 'seriesno')});		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if utilities.is_set (Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if utilities.is_set (SeriesNumber) then table.insert(s, wrap_msg ('seriesnum', SeriesNumber, use_lowercase)); end
			if utilities.is_set (Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ScriptChapter_origin = A:ORIGIN('ScriptTitle');
			ChapterLink = TitleLink;											-- alias |episode-link=
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if utilities.is_set (ChapterLink) and not utilities.is_set (ChapterURL) then	-- link but not URL
				Chapter = utilities.make_wikilink (ChapterLink, Chapter);
			elseif utilities.is_set (ChapterLink) and utilities.is_set (ChapterURL) then	-- if both are set, URL links episode;
				Series = utilities.make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if utilities.is_set (Series) and utilities.is_set (SeriesLink) then
				Series = utilities.make_wikilink (SeriesLink, Series);
			end
			Series = utilities.wrap_style ('italic-title', Series);				-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- handle type parameter for those CS1 citations that have default values
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	if utilities.in_array (config.CitationClass, {'AV-media-notes', 'interview', 'mailinglist', 'map', 'podcast', 'pressrelease', 'report', 'speech', 'techreport', 'thesis'}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if utilities.is_set (Degree) and &quot;Thesis&quot; == TitleType then				-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if utilities.is_set (TitleType) then										-- if type parameter is specified
		TitleType = utilities.substitute ( cfg.messages['type'], TitleType);	-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
	local Date = A['Date'];
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging
	local PublicationDate = A['PublicationDate'];
	local Year = A['Year'];

	if not utilities.is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not utilities.is_set (Date) and utilities.is_set (PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]

	local DF = is_valid_parameter_value (A['DF'], A:ORIGIN('DF'), cfg.keywords_lists['df'], '');
	if not utilities.is_set (DF) then
		DF = cfg.global_df;														-- local |df= if present overrides global df set by {{use xxx date}} template
	end

	local ArchiveURL;
	local ArchiveDate;
	local ArchiveFormat = A['ArchiveFormat'];

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	
	ArchiveURL, ArchiveDate = is_unique_archive_url (ArchiveURL, URL, ChapterURL, A:ORIGIN('ArchiveURL'), ArchiveDate);		-- add error message when URL or ChapterURL == ArchiveURL

	
	local AccessDate = A['AccessDate'];
	local LayDate = A['LayDate'];
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification
	local DoiBroken = A['DoiBroken'];
	local Embargo = A['Embargo'];
	local anchor_year;															-- used in the CITEREF identifier
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val = AccessDate, name = A:ORIGIN ('AccessDate')},
			['archive-date'] = {val = ArchiveDate, name = A:ORIGIN ('ArchiveDate')},
			['date'] = {val = Date, name = Date_origin},
			['doi-broken-date'] = {val = DoiBroken, name = A:ORIGIN ('DoiBroken')},
			['pmc-embargo-date'] = {val = Embargo, name = A:ORIGIN ('Embargo')},
			['lay-date'] = {val = LayDate, name = A:ORIGIN ('LayDate')},
			['publication-date'] = {val = PublicationDate, name = A:ORIGIN ('PublicationDate')},
			['year'] = {val = Year, name = A:ORIGIN ('Year')},
			};

		local error_list = {};
		anchor_year, Embargo = validation.dates(date_parameters_list, COinS_date, error_list);

-- start temporary Julian / Gregorian calendar uncertainty categorization
		if COinS_date.inter_cal_cat then
			utilities.add_prop_cat ('jul-greg-uncertainty');
		end
-- end temporary Julian / Gregorian calendar uncertainty categorization

		if utilities.is_set (Year) and utilities.is_set (Date) then				-- both |date= and |year= not normally needed; 
			validation.year_date_check (Year, A:ORIGIN ('Year'), Date, A:ORIGIN ('Date'), error_list);
		end
		
		if 0 == #error_list then												-- error free dates only; 0 when error_list is empty
			local modified = false;												-- flag
			
			if utilities.is_set (DF) then										-- if we need to reformat dates
				modified = validation.reformat_dates (date_parameters_list, DF);	-- reformat to DF format, use long month names if appropriate
			end

			if true == validation.date_hyphen_to_dash (date_parameters_list) then	-- convert hyphens to dashes where appropriate
				modified = true;
				utilities.set_message ('maint_date_format');					-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language; not supported at en.wiki
			if cfg.date_name_auto_xlate_enable and validation.date_name_xlate (date_parameters_list, cfg.date_digit_auto_xlate_enable ) then
				utilities.set_message ('maint_date_auto_xlated');				-- add maint cat
				modified = true;
			end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				LayDate = date_parameters_list['lay-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end
		else
			utilities.set_message ('err_bad_date', {utilities.make_sep_list (#error_list, error_list)});	-- add this error message
		end
	end	-- end of do

	local ID_list = {};															-- sequence table of rendered identifiers
	local ID_list_coins = {};													-- table of identifiers and their values from args; key is same as cfg.id_handlers's key
	local Class = A['Class'];													-- arxiv class identifier
	
	local ID_support = {
		{A['ASINTLD'], 'ASIN', 'err_asintld_missing_asin', A:ORIGIN ('ASINTLD')},				
		{DoiBroken, 'DOI', 'err_doibroken_missing_doi', A:ORIGIN ('DoiBroken')},
		{Embargo, 'PMC', 'err_embargo_missing_pmc', A:ORIGIN ('Embargo')},
		}

	ID_list, ID_list_coins = identifiers.identifier_lists_get (args, {DoiBroken = DoiBroken, ASINTLD = A['ASINTLD'], Embargo = Embargo, Class = Class}, ID_support);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite ssrn}}, before generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then
		if not utilities.is_set (ID_list_coins[config.CitationClass:upper()]) then 	-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp; |citeseerx= required for their templates
			utilities.set_message ('err_' .. config.CitationClass .. '_missing');	-- add error message
		end

		Periodical = ({['arxiv'] = 'arXiv', ['biorxiv'] = 'bioRxiv', ['citeseerx'] = 'CiteSeerX', ['ssrn'] = 'Social Science Research Network'})[config.CitationClass];
	end

	-- Link the title of the work if no |url= was provided, but we have a |pmc= or a |doi= with |doi-access=free

	if config.CitationClass == &quot;journal&quot; and not utilities.is_set (URL) and not utilities.is_set (TitleLink) and not utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) then -- TODO: remove 'none' once existing citations have been switched to 'off', so 'none' can be used as token for &quot;no title&quot; instead
		if 'none' ~= cfg.keywords_xlate[auto_select] then						-- if auto-linking not disabled
 	 		if identifiers.auto_link_urls[auto_select] then						-- manual selection
		 		URL = identifiers.auto_link_urls[auto_select];					-- set URL to be the same as identifier's external link
 				URL_origin = cfg.id_handlers[auto_select:upper()].parameters[1];	-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['pmc'] then						-- auto-select PMC
				URL = identifiers.auto_link_urls['pmc'];						-- set URL to be the same as the PMC external link if not embargoed
				URL_origin = cfg.id_handlers['PMC'].parameters[1];				-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['doi'] then						-- auto-select DOI
				URL = identifiers.auto_link_urls['doi'];
				URL_origin = cfg.id_handlers['DOI'].parameters[1];
			end
 	 	end

		if utilities.is_set (URL) and utilities.is_set (AccessDate) then		-- access date requires |url=; identifier-created URL is not |url=
			utilities.set_message ('err_accessdate_missing_url');				-- add an error message
			AccessDate = '';													-- unset
		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not utilities.is_set (Title) and not utilities.is_set (TransTitle) and not utilities.is_set (ScriptTitle) then	-- has special case for cite episode
		utilities.set_message ('err_citation_missing_title', {'episode' == config.CitationClass and 'series' or 'title'});
	end

	if utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) and
			utilities.in_array (config.CitationClass, {'journal', 'citation'}) and
			(utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and
			('journal' == Periodical_origin or 'script-journal' == ScriptPeriodical_origin) then	-- special case for journal cites
				Title = '';														-- set title to empty string
				utilities.set_message ('maint_untitled');						-- add maint cat
	end

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Chapter) and utilities.is_set (Title) and utilities.is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end
	
	local QuotePage = A['QuotePage'];
	local QuotePages = utilities.hyphen_to_dash (A['QuotePages']);

	-- this is the function call to COinS()
	local OCinSoutput = metadata.COinS({
		['Periodical'] = utilities.strip_apostrophe_markup (Periodical),		-- no markup in the metadata
		['Encyclopedia'] = Encyclopedia,										-- just a flag; content ignored by ~/COinS
		['Chapter'] = metadata.make_coins_title (coins_chapter, ScriptChapter),	-- Chapter and ScriptChapter stripped of bold / italic / accept-as-written markup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = metadata.make_coins_title (coins_title, ScriptTitle),		-- Title and ScriptTitle stripped of bold / italic / accept-as-written markup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Quarter'] = COinS_date.rftquarter,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = coins_pages or metadata.get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At, QuotePage, QuotePages}, 7)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName or Newsgroup,							-- any apostrophe markup already removed from PublisherName
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list_coins,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, and {{cite ssrn}} AFTER generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, CiteSeerX, or ssrn now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass and utilities.is_set (Newsgroup) then
		PublisherName = utilities.substitute (cfg.messages['newsgroup'], external_link( 'news:' .. Newsgroup, Newsgroup, Newsgroup_origin, nil ));
	end

	local Editors;
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	local Contributors;															-- assembled contributors name list
	local contributor_etal;
	local Translators;															-- assembled translators name list
	local translator_etal;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	local Interviewers;															
	local interviewers_list = {};					
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters
	local interviewer_etal;
	
	-- Now perform various field 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.
	do
		local last_first_list;
		local control = { 
			format = NameListStyle,												-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_names (A['DisplayEditors'], #e, 'editors', editor_etal, A:ORIGIN ('DisplayEditors'));
			Editors, EditorCount = list_people (control, e, editor_etal);

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum, interviewer_etal = get_display_names (A['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal, A:ORIGIN ('DisplayInterviewers'));
			Interviewers = list_people (control, interviewers_list, interviewer_etal);
		end
		do																		-- now do translators
			control.maximum, translator_etal = get_display_names (A['DisplayTranslators'], #t, 'translators', translator_etal, A:ORIGIN ('DisplayTranslators'));
			Translators = list_people (control, t, translator_etal);
		end
		do																		-- now do contributors
			control.maximum, contributor_etal = get_display_names (A['DisplayContributors'], #c, 'contributors', contributor_etal, A:ORIGIN ('DisplayContributors'));
			Contributors = list_people (control, c, contributor_etal);
		end
		do																		-- now do authors
			control.maximum, author_etal = get_display_names (A['DisplayAuthors'], #a, 'authors', author_etal, A:ORIGIN ('DisplayAuthors'));

			last_first_list = list_people (control, a, author_etal);

			if utilities.is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors');	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if utilities.is_set (Authors) and utilities.is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not utilities.is_set (URL) then
		if utilities.in_array (config.CitationClass, {&quot;web&quot;, &quot;podcast&quot;, &quot;mailinglist&quot;}) or		-- |url= required for cite web, cite podcast, and cite mailinglist
			('citation' == config.CitationClass and ('website' == Periodical_origin or 'script-website' == ScriptPeriodical_origin)) then	-- and required for {{citation}} with |website= or |script-website=
				utilities.set_message ('err_cite_web_url');
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if utilities.is_set (AccessDate) and not utilities.is_set (ChapterURL) then		-- ChapterURL may be set when URL is not set;
			utilities.set_message ('err_accessdate_missing_url');
			AccessDate = '';
		end
	end

	local UrlStatus = is_valid_parameter_value (A['UrlStatus'], A:ORIGIN('UrlStatus'), cfg.keywords_lists['url-status'], '');
	local OriginalURL
	local OriginalURL_origin
	local OriginalFormat
	local OriginalAccess;
	UrlStatus = UrlStatus:lower();												-- used later when assembling archived text
	if utilities.is_set ( ArchiveURL ) then
		if utilities.is_set (ChapterURL) then 									-- if chapter-url= is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURL_origin = ChapterURL_origin;								-- name of |chapter-url= parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=

			if 'live' ~= UrlStatus then
				ChapterURL = ArchiveURL											-- swap-in the archive's URL
				ChapterURL_origin = A:ORIGIN('ArchiveURL')						-- name of |archive-url= parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived URLs
			end
		elseif utilities.is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURL_origin = URL_origin;									-- name of URL parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;

			if 'live' ~= UrlStatus then											-- if URL set then |archive-url= applies to it
				URL = ArchiveURL												-- swap-in the archive's URL
				URL_origin = A:ORIGIN('ArchiveURL')								-- name of archive URL parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived URLs
			end
		end
	elseif utilities.is_set (UrlStatus) then									-- if |url-status= is set when |archive-url= is not set
 		utilities.set_message ('maint_url_status');								-- add maint cat
	end

	if utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) then
			local chap_param;
			if utilities.is_set (Chapter) then									-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif utilities.is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif utilities.is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif utilities.is_set (ScriptChapter) then
				chap_param = ScriptChapter_origin;
			else utilities.is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if utilities.is_set (chap_param) then								-- if we found one
				utilities.set_message ('err_chapter_ignored', {chap_param});	-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if utilities.is_set (Contribution) and 0 &lt; #c then						-- if this is a contribution with contributor(s)
			if utilities.in_array (Contribution:lower(), cfg.keywords_lists.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, ScriptChapter_origin, Chapter, Chapter_origin, TransChapter, TransChapter_origin, ChapterURL, ChapterURL_origin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if utilities.is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and utilities.is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter .. sepc .. ' ';
		elseif utilities.is_set (ChapterFormat) then							-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title
	local plain_title = false;
	local accept_title;
	Title, accept_title = utilities.has_accept_as_written (Title, true);		-- remove accept-this-as-written markup when it wraps all of &lt;Title&gt;
	if accept_title and ('' == Title) then										-- only support forced empty for now &quot;(())&quot;
		Title = cfg.messages['notitle'];										-- replace by predefined &quot;No title&quot; message
			-- TODO: utilities.set_message ( 'err_redundant_parameters', ...);	-- issue proper error message instead of muting	 
			ScriptTitle = '';													-- just mute for now	 
			TransTitle = '';													-- just mute for now
 		plain_title = true;														-- suppress text decoration for descriptive title
		utilities.set_message ('maint_untitled');								-- add maint cat
	end

	if not accept_title then													-- &lt;Title&gt; not wrapped in accept-as-written markup
		if '...' == Title:sub (-3) then											-- if ellipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%' .. sepc .. '$', '');			-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end

		if utilities.is_set (ArchiveURL) and is_archived_copy (Title) then
			utilities.set_message ('maint_archived_copy');						-- add maintenance category before we modify the content of Title
		end

		if is_generic ('generic_titles', Title) then
			utilities.set_message ('err_generic_title');						-- set an error message
		end
	end

	if (not plain_title) and (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) or
		('map' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)))) then		-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from module provided quote marks
			Title = utilities.wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle, 'script-title');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
			TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );
	elseif plain_title or ('report' == config.CitationClass) then				-- no styling for cite report and descriptive titles (otherwise same as above)
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );	-- for cite report, use this form for trans-title
	else
		Title = utilities.wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-italic-title', TransTitle);
	end

	if utilities.is_set (TransTitle) then
		if utilities.is_set (Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			utilities.set_message ('err_trans_missing_title', {'title'});
		end
	end

	if utilities.is_set (Title) then											-- TODO: is this the right place to be making Wikisource URLs?
		if utilities.is_set (TitleLink) and utilities.is_set (URL) then
			utilities.set_message ('err_wikilink_in_url');						-- set an error message because we can't have both
			TitleLink = '';														-- unset
		end
	
		if not utilities.is_set (TitleLink) and utilities.is_set (URL) then
			Title = external_link (URL, Title, URL_origin, UrlAccess) .. TransTitle .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif utilities.is_set (TitleLink) and not utilities.is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle;
			else
				Title = utilities.make_wikilink (TitleLink, Title) .. TransTitle;
			end
		else
			local ws_url, ws_label, L;											-- Title has italic or quote markup by the time we get here which causes is_wikilink() to return 0 (not a wikilink)
			ws_url, ws_label, L = wikisource_url_make (Title:gsub('^[\'&quot;]*(.-)[\'&quot;]*$', '%1'));	-- make ws URL from |title= interwiki link (strip italic or quote markup); link portion L becomes tooltip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle;
			else
				Title = Title .. TransTitle;
			end
		end
	else
		Title = TransTitle;
	end

	if utilities.is_set (Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	local ConferenceURL_origin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	if utilities.is_set (Conference) then
		if utilities.is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURL_origin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif utilities.is_set (ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURL_origin, nil );
	end

	local Position = '';
	if not utilities.is_set (Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if utilities.is_set (Minutes) then
			if utilities.is_set (Time) then		--TODO: make a function for this and similar?
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'minutes') .. ' and ' .. utilities.wrap_style ('parameter', 'time')});
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if utilities.is_set (Time) then
				local TimeCaption = A['TimeCaption']
				if not utilities.is_set (TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = utilities.is_set (At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = utilities.is_set (Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Sections = A['Sections'];											-- Section (singular) is an alias of Chapter so set earlier
		local Inset = A['Inset'];
		
		if utilities.is_set ( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if utilities.is_set ( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif utilities.is_set ( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	local Others = A['Others'];
	if utilities.is_set (Others) and 0 == #a and 0 == #e then					-- add maint cat when |others= has value and used without |author=, |editor=
		if config.CitationClass == &quot;AV-media-notes&quot;
		or config.CitationClass == &quot;audio-visual&quot; then							-- special maint for AV/M which has a lot of 'false' positives right now
			utilities.set_message ('maint_others_avm')
		else
			utilities.set_message ('maint_others');
		end
	end
	Others = utilities.is_set (Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if utilities.is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if utilities.is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	local TitleNote = A['TitleNote'];
	TitleNote = utilities.is_set (TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if utilities.is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%n?%.?$') or Edition:match ('%f[%a][Ee]dition$') then -- Ed, ed, Ed., ed., Edn, edn, Edn., edn.
			utilities.set_message ('err_extra_text_edition');					 -- add error message
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = utilities.is_set (Series) and wrap_msg ('series', {sepc, Series}) or &quot;&quot;;	-- not the same as SeriesNum
	local Agency = A['Agency'];
	Agency = utilities.is_set (Agency) and wrap_msg ('agency', {sepc, Agency}) or &quot;&quot;;
	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	if utilities.is_set (AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = utilities.substitute (retrv_text, AccessDate);				-- add retrieved text

		AccessDate = utilities.substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if utilities.is_set (ID) then ID = sepc .. &quot; &quot; .. ID; end
	
	local Docket = A['Docket'];
   	if &quot;thesis&quot; == config.CitationClass and utilities.is_set (Docket) then
		ID = sepc .. &quot; Docket &quot; .. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and utilities.is_set (Docket) then		-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	if utilities.is_set (URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URL_origin, UrlAccess );
	end

	local Quote = A['Quote'];
	local TransQuote = A['TransQuote'];
	local ScriptQuote = A['ScriptQuote'];
	if utilities.is_set (Quote) or utilities.is_set (TransQuote) or utilities.is_set (ScriptQuote) then

		if utilities.is_set (Quote) then
			if Quote:sub(1, 1) == '&quot;' and Quote:sub(-1, -1) == '&quot;' then			-- if first and last characters of quote are quote marks
				Quote = Quote:sub(2, -2);										-- strip them off
			end
		end

		Quote = utilities.wrap_style ('quoted-text', Quote );					-- wrap in &lt;q&gt;...&lt;/q&gt; tags
	
		if utilities.is_set (ScriptQuote) then
			Quote = script_concatenate (Quote, ScriptQuote, 'script-quote');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after quote is wrapped
		end

		if utilities.is_set (TransQuote) then
			if TransQuote:sub(1, 1) == '&quot;' and TransQuote:sub(-1, -1) == '&quot;' then -- if first and last characters of |trans-quote are quote marks
				TransQuote = TransQuote:sub(2, -2); -- strip them off
			end
			Quote = Quote .. &quot; &quot; .. utilities.wrap_style ('trans-quoted-title', TransQuote );
		end

		if utilities.is_set (QuotePage) or utilities.is_set (QuotePages) then	-- add page prefix
			local quote_prefix = '';
			if utilities.is_set (QuotePage) then
				extra_text_in_page_check (QuotePage, 'quote-page');				-- add to maint cat if |quote-page= value begins with what looks like p., pp., etc.
				if not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePage}), '', '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePage}), '', '', '';
				end
			elseif utilities.is_set (QuotePages) then
				extra_text_in_page_check (QuotePages, 'quote-pages');			-- add to maint cat if |quote-pages= value begins with what looks like p., pp., etc.
				if tonumber(QuotePages) ~= nil and not NoPP then				-- if only digits, assume single page
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePages}), '', '';
				elseif not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['pp-prefix'], {sepc, QuotePages}), '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePages}), '', '';
				end
			end
                        
			Quote = quote_prefix .. &quot;: &quot; .. Quote;
		else
			Quote = sepc .. &quot; &quot; .. Quote;
		end

		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	-- We check length of PostScript here because it will have been nuked by
	-- the quote parameters. We'd otherwise emit a message even if there wasn't
	-- a displayed postscript.
	-- TODO: Should the max size (1) be configurable?
	-- TODO: Should we check a specific pattern?
	if utilities.is_set(PostScript) and mw.ustring.len(PostScript) &gt; 1 then
		utilities.set_message ('maint_postscript')
	end
	
	local Archived;
	if utilities.is_set (ArchiveURL) then
		local arch_text;
		if not utilities.is_set (ArchiveDate) then
			utilities.set_message ('err_archive_missing_date');
			ArchiveDate = '';													-- empty string for concatenation
		end
		if &quot;live&quot; == UrlStatus then
			arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if utilities.is_set (ArchiveDate) then
				Archived = sepc .. ' ' .. utilities.substitute ( cfg.messages['archived-live'],
					{external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil) .. ArchiveFormat, ArchiveDate } );
			else
				Archived = '';
			end
			if not utilities.is_set (OriginalURL) then
				utilities.set_message ('err_archive_missing_url');
				Archived = '';													-- empty string for concatenation
			end
		elseif utilities.is_set (OriginalURL) then								-- UrlStatus is empty, 'dead', 'unfit', 'usurped', 'bot: unknown'
			if utilities.in_array (UrlStatus, {'unfit', 'usurped', 'bot: unknown'}) then
				arch_text = cfg.messages['archived-unfit'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. ' ' .. arch_text .. ArchiveDate;				-- format already styled
				if 'bot: unknown' == UrlStatus then
					utilities.set_message ('maint_bot_unknown');				-- and add a category if not already added
				else
					utilities.set_message ('maint_unfit');						-- and add a category if not already added
				end
			else																-- UrlStatus is empty, 'dead'
				arch_text = cfg.messages['archived-dead'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				if utilities.is_set (ArchiveDate) then
					Archived = sepc .. &quot; &quot; .. utilities.substitute ( arch_text,
						{ external_link( OriginalURL, cfg.messages['original'], OriginalURL_origin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
				else
					Archived = '';												-- unset for concatenation
				end
			end	
		else																	-- OriginalUrl not set
			arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			utilities.set_message ('err_archive_missing_url');
			Archived = '';														-- empty string for concatenation
		end
	elseif utilities.is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = '';
	end
	
	local Lay = '';
	local LaySource = A['LaySource'];
	local LayURL = A['LayURL'];
	local LayFormat = A['LayFormat'];
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	if utilities.is_set (LayURL) then
		if utilities.is_set (LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if utilities.is_set (LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. utilities.safe_for_italics (LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif utilities.is_set (LayFormat) then									-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	local TranscriptURL = A['TranscriptURL']
	local TranscriptFormat = A['TranscriptFormat'];
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');
	local Transcript = A['Transcript'];
	local TranscriptURL_origin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL
	if utilities.is_set (Transcript) then
		if utilities.is_set (TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURL_origin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif utilities.is_set (TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURL_origin, nil );
	end

	local Publisher;
	if utilities.is_set (PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if utilities.is_set (PublisherName) then
		if utilities.is_set (PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif utilities.is_set (PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	local TransPeriodical =  A['TransPeriodical'];
	local TransPeriodical_origin =  A:ORIGIN ('TransPeriodical');
	-- Several of the above rely upon detecting this as nil, so do it last.
	if (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical)) then
		if utilities.is_set (Title) or utilities.is_set (TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		else 
			Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		end
	end
	
	local Language = A['Language'];
	if utilities.is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc.
	else
		Language='';															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then									-- cite speech only
		TitleNote = TitleType;													-- move TitleType to TitleNote so that it renders ahead of |event=
		TitleType = '';															-- and unset

		if utilities.is_set (Periodical) then									-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if utilities.is_set (Conference) then								-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;							-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
		if utilities.is_set (Others) then Others = safe_join ({Others, sepc .. &quot; &quot;}, sepc) end		-- add terminal punctuation &amp; space; check for dup sepc; TODO why do we need to do this here?
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (Periodical) then		-- special cases for book cites
		if utilities.is_set (Contributors) then									-- when we are citing foreword, preface, introduction, etc.
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if utilities.is_set (Chapter) then										-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif utilities.is_set (Periodical) then								-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local Via = A['Via'];
	Via = utilities.is_set (Via) and  wrap_msg ('via', Via) or '';
	local idcommon;
	if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then	-- special case for cite AV media &amp; cite episode position transcript
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, Lay, Quote }, sepc );
	else
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, Lay, Quote }, sepc );
	end
	
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	local OrigDate = A['OrigDate'];
	OrigDate = utilities.is_set (OrigDate) and wrap_msg ('origdate', OrigDate) or '';
	if utilities.is_set (Date) then
		if utilities.is_set (Authors) or utilities.is_set (Editors) then		-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date .. &quot;)&quot; .. OrigDate .. sepc .. &quot; &quot;;				-- in parentheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon, -1, -1) == sepc) then						-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigDate;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigDate;							-- Date begins with sepc
			end
		end
	end	
	if utilities.is_set (Authors) then
		if (not utilities.is_set (Date)) then									-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if utilities.is_set (Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then
					in_text = in_text:lower()									-- lowercase for cs2
				end
			end
			if EditorCount &lt;= 1 then
				post_text = &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot;;				-- be consistent with no-author, no-date case
			else
				post_text = &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot;;
			end
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Contributors) then									-- book cite and we're citing the intro, preface, etc.
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if utilities.is_set (Editors) and utilities.is_set (Date) then		-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not utilities.is_set (Date)) then								-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif utilities.is_set (Editors) then
		if utilities.is_set (Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if utilities.is_set (PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc ); 								-- Deals with italics, spaces, etc.
		text = text:sub(1, -sepc:len() - 1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite&gt; element
	local options_t = {};
	options_t.class = cite_class_attribute_make (config.CitationClass, Mode);

	local Ref = is_valid_parameter_value (A['Ref'], A:ORIGIN('Ref'), cfg.keywords_lists['ref'], nil, true);	-- nil when |ref=harv; A['Ref'] else

	if 'none' ~= cfg.keywords_xlate[(Ref and Ref:lower()) or ''] then
		local namelist_t = {};													-- holds selected contributor, author, editor name list
		local year = first_set ({Year, anchor_year}, 2);						-- Year first for legacy citations and for YMD dates that require disambiguation

		if #c &gt; 0 then															-- if there is a contributor list
			namelist_t = c;														-- select it
		elseif #a &gt; 0 then														-- or an author list
			namelist_t = a;
		elseif #e &gt; 0 then														-- or an editor list
			namelist_t = e;
		end
		local citeref_id;
		if #namelist_t &gt; 0 then													-- if there are names in namelist_t
			citeref_id = make_citeref_id (namelist_t, year);					-- go make the CITEREF anchor
			if mw.uri.anchorEncode (citeref_id) == ((Ref and mw.uri.anchorEncode (Ref)) or '') then	-- Ref may already be encoded (by {{sfnref}}) so citeref_id must be encoded before comparison
				utilities.set_message ('maint_ref_duplicates_default');
			end
		else
			citeref_id = '';													-- unset
		end
		options_t.id = Ref or citeref_id;
	end

	if string.len (text:gsub('%b&lt;&gt;', '')) &lt;= 2 then								-- remove html and html-like tags; then get length of what remains; 
		z.error_cats_t = {};													-- blank the categories list
		z.error_msgs_t = {};													-- blank the error messages list
		OCinSoutput = nil;														-- blank the metadata string
		text = '';																-- blank the the citation
		utilities.set_message ('err_empty_citation');							-- set empty citation message and category
	end
	
	local render_t = {};														-- here we collect the final bits for concatenation into the rendered citation

	if utilities.is_set (options_t.id) then										-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render_t, utilities.substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options_t.id), mw.text.nowiki(options_t.class), text}));	-- when |ref= is set or when there is a namelist
	else
		table.insert (render_t, utilities.substitute (cfg.presentation['cite'], {mw.text.nowiki(options_t.class), text}));	-- when |ref=none or when namelist_t empty and |ref= is missing or is empty
	end		

	if OCinSoutput then															-- blanked when citation is 'empty' so don't bother to add boilerplate metadata span
		table.insert (render_t, utilities.substitute (cfg.presentation['ocins'], OCinSoutput));	-- format and append metadata to the citation
	end

	local template_name = ('citation' == config.CitationClass) and 'citation' or 'cite ' .. (cfg.citation_class_map_t[config.CitationClass] or config.CitationClass);
	local template_link = '[[Template:' .. template_name .. '|' .. template_name .. ']]';	-- TODO: if kept, these require some sort of i18n
	local msg_prefix = '&lt;code class=&quot;cs1-code&quot;&gt;{{' .. template_link .. '}}&lt;/code&gt;: ';

	if 0 ~= #z.error_msgs_t then
		mw.addWarning (utilities.substitute (cfg.messages.warning_msg_e, template_link));

		table.insert (render_t, ' ');											-- insert a space between citation and its error messages
		table.sort (z.error_msgs_t);											-- sort the error messages list; sorting includes wrapping &lt;span&gt; and &lt;code&gt; tags; hidden-error sorts ahead of visible-error

		local hidden = true;													-- presume that the only error messages emited by this template are hidden
		for _, v in ipairs (z.error_msgs_t) do									-- spin through the list of error messages
			if v:find ('cs1-visible-error', 1, true) then						-- look for the visible error class name
				hidden = false;													-- found one; so don't hide the error message prefix
				break;															-- and done because no need to look further
			end
		end

		z.error_msgs_t[1] = table.concat ({utilities.error_comment (msg_prefix, hidden), z.error_msgs_t[1]});	-- add error message prefix to first error message to prevent extraneous punctuation
		table.insert (render_t, table.concat (z.error_msgs_t, '; '));			-- make a big string of error messages and add it to the rendering
	end

	if 0 ~= #z.maint_cats_t then
		mw.addWarning (utilities.substitute (cfg.messages.warning_msg_m, template_link));

		table.sort (z.maint_cats_t);											-- sort the maintenance messages list

		local maint_msgs_t = {};												-- here we collect all of the maint messages

		if 0 == #z.error_msgs_t then											-- if no error messages
			table.insert (maint_msgs_t, msg_prefix);							-- insert message prefix in maint message livery
		end
		
		for _, v in ipairs( z.maint_cats_t ) do									-- append maintenance categories
			table.insert (maint_msgs_t, 										-- assemble new maint message and add it to the maint_msgs_t table
				table.concat ({v, ' (', utilities.substitute (cfg.messages[':cat wikilink'], v), ')'})
				);
		end
		table.insert (render_t, utilities.substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs_t, ' ')));	-- wrap the group of maint messages with proper presentation and save
	end

	if not no_tracking_cats then
		for _, v in ipairs (z.error_cats_t) do									-- append error categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
		end
		for _, v in ipairs (z.maint_cats_t) do									-- append maintenance categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
		end
		for _, v in ipairs (z.prop_cats_t) do									-- append properties categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
		end
	end

	return table.concat (render_t);												-- make a big string and done
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class, empty)
	local name = tostring (name);
	local enum_name;															-- for enumerated parameters, is name with enumerator replaced with '#'
	local state;
	local function state_test (state, name)										-- local function to do testing of state values
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			if empty then return nil; end										-- empty deprecated parameters are treated as unknowns
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
		if 'tracked' == state then
			local base_name = name:gsub ('%d', '');								-- strip enumerators from parameter names that have them to get the base name
			utilities.add_prop_cat ('tracked-param', {base_name}, base_name);	-- add a properties category; &lt;base_name&gt; modifies &lt;key&gt;
			return true;
		end
		return nil;
	end		

	if name:find ('#') then														-- # is a cs1|2 reserved character so parameters with # not permitted
		return nil;
	end

	if utilities.in_array (cite_class, whitelist.preprint_template_list ) then	-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[name];
		if true == state_test (state, name) then return true; end

		state = whitelist.preprint_arguments[cite_class][name];					-- look in the parameter-list for the template identified by cite_class
		if true == state_test (state, name) then return true; end

																				-- limited enumerated parameters list
		enum_name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );										-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
		state = whitelist.limited_numbered_arguments[enum_name];
		if true == state_test (state, name) then return true; end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates

	if utilities.in_array (cite_class, whitelist.unique_param_template_list) then 	-- experiment for template-specific parameters for templates that accept parameters from the basic argument list
		state = whitelist.unique_arguments[cite_class][name];					-- look in the template-specific parameter-lists for the template identified by cite_class
		if true == state_test (state, name) then return true; end
	end																			-- if here, fall into general validation
		
	state = whitelist.basic_arguments[name];									-- all other templates; all normal parameters allowed
	if true == state_test (state, name) then return true; end

																				-- all enumerated parameters allowed
	enum_name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
	state = whitelist.numbered_arguments[enum_name];
	if true == state_test (state, name) then return true; end

	return false;																-- not supported because not found or name is set to nil
end


--[=[-------------------------&lt; I N T E R _ W I K I _ C H E C K &gt;----------------------------------------------

check &lt;value&gt; for inter-language interwiki-link markup.  &lt;prefix&gt; must be a MediaWiki-recognized language
code.  when these values have the form (without leading colon):
	[[&lt;prefix&gt;:link|label]] return label as plain-text
	[[&lt;prefix&gt;:link]] return &lt;prefix&gt;:link as plain-text

return value as is else

]=]

local function inter_wiki_check (parameter, value)
	local prefix = value:match ('%[%[(%a+):');									-- get an interwiki prefix if one exists
	local _;
	
	if prefix and cfg.inter_wiki_map[prefix:lower()] then						-- if prefix is in the map, needs preceding colon so
		utilities.set_message ('err_bad_paramlink', parameter);					-- emit an error message
		_, value, _ = utilities.is_wikilink (value);							-- extract label portion from wikilink
	end
	return value;
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe.  There are two tests made:
	{{cite ... |title=Title access-date=2016-03-17}}	-- the first parameter has a value and whitespace separates that value from the missing pipe parameter name
	{{cite ... |title=access-date=2016-03-17}}			-- the first parameter has no value (whitespace after the first = is trimmed by MediaWiki)
cs1|2 shares some parameter names with XML/HTML attributes: class=, title=, etc.  To prevent false positives XML/HTML
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (parameter, value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove XML/HTML tags because attributes: class=, title=, etc.

	capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then										-- if the capture is a valid parameter name
		utilities.set_message ('err_missing_pipe', parameter);
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ P U N C T &gt;--------------------------------------

look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_punc (param, value)
	if 'number' == type (param) then
		return;
	end
	
	param = param:gsub ('%d+', '#');											-- enumerated name-list mask params allow terminal punct; normalize 
	if cfg.punct_skip[param] then
		return;																	-- parameter name found in the skip table so done
	end
	
	if value:match ('[,;:]$') then
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
	if value:match ('^=') then													-- sometimes an extraneous '=' character appears ...
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ U R L &gt;------------------------------------------

look for extraneous url parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_url (url_param_t)
	local url_error_t = {};
	
	check_for_url (url_param_t, url_error_t);									-- extraneous url check
	if 0 ~= #url_error_t then													-- non-zero when there are errors
		table.sort (url_error_t);
		utilities.set_message ('err_param_has_ext_link', {utilities.make_sep_list (#url_error_t, url_error_t)});	-- add this error message
	end
end


--[[--------------------------&lt; C I T A T I O N &gt;--------------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

local function citation(frame)
	Frame = frame;																-- save a copy in case we need to display an error message in preview mode
	is_sandbox = nil ~= string.find (frame:getTitle(), 'sandbox', 1, true);
	local pframe = frame:getParent()
	local styles;
	
	if is_sandbox then															-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		styles = 'Module:Citation/CS1/sandbox/styles.css';
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
		styles = 'Module:Citation/CS1/styles.css';
	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the selected cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	is_preview_mode = not utilities.is_set (frame:preprocess ('{{REVISIONID}}'));

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text;															-- used as a flag

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do											-- get parameters from the {{#invoke}} frame
		config[k] = v;
	--	args[k] = v;															-- crude debug support that allows us to render a citation from module {{#invoke:}}; skips parameter validation; TODO: keep?
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	local empty_unknowns = {};													-- sequence table to hold empty unknown params for error message listing
	for k, v in pairs( pframe.args ) do											-- get parameters from the parent (template) frame
		v = mw.ustring.gsub (v, '^%s*(.-)%s*$', '%1');							-- trim leading/trailing whitespace; when v is only whitespace, becomes empty string
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				if type (k) ~= 'string' then									-- exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text = utilities.set_message ('err_text_ignored', {v});
					end
				elseif validate (k:lower(), config.CitationClass) then 
					error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, k:lower()});	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if is_sandbox then										-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no capture in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = utilities.substitute (param, capture);		-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, param});	-- set the suggestion error message
							else
								error_text = utilities.set_message ('err_parameter_ignored', {k});	-- suggested param not supported by this template
								v = '';											-- unset
							end
						end
					end
					if not utilities.is_set (error_text) then					-- couldn't match with a pattern, is there an explicit suggestion?						
						if (suggestions.suggestions[ k:lower() ] ~= nil) and validate (suggestions.suggestions[ k:lower() ], config.CitationClass) then
							utilities.set_message ('err_parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]});
						else
							utilities.set_message ('err_parameter_ignored', {k});
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
			end

			args[k] = v;														-- save this parameter and its value

		elseif not utilities.is_set (v) then									-- for empty parameters
			if not validate (k, config.CitationClass, true) then				-- is this empty parameter a valid parameter
				k = ('' == k) and '(empty string)' or k;						-- when k is empty string (or was space(s) trimmed to empty string), replace with descriptive text
				table.insert (empty_unknowns, utilities.wrap_style ('parameter', k));	-- format for error message and add to the list
			end
																				-- crude debug support that allows us to render a citation from module {{#invoke:}} TODO: keep?
	--	elseif args[k] ~= nil or (k == 'postscript') then						-- when args[k] has a value from {{#invoke}} frame (we don't normally do that)
	--		args[k] = v;														-- overwrite args[k] with empty string from pframe.args[k] (template frame); v is empty string here
		end																		-- not sure about the postscript bit; that gets handled in parameter validation; historical artifact?
	end	

	if 0 ~= #empty_unknowns then												-- create empty unknown error message
		utilities.set_message ('err_param_unknown_empty', {
			1 == #empty_unknowns and '' or 's',
			utilities.make_sep_list (#empty_unknowns, empty_unknowns)
			});
	end

	local url_param_t = {};

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);											-- look for invisible characters
		end
		has_extraneous_punc (k, v);												-- look for extraneous terminal punctuation in parameter values
		missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?
		args[k] = inter_wiki_check (k, v);										-- when language interwiki-linked parameter missing leading colon replace with wiki-link label

		if 'string' == type (k) and not cfg.url_skip[k] then					-- when parameter k is not positional and not in url skip table
			url_param_t[k] = v;													-- make a parameter/value list for extraneous url check
		end
	end

	has_extraneous_url (url_param_t);											-- look for url in parameter values where a url does not belong

	return table.concat ({
		frame:extensionTag ('templatestyles', '', {src=styles}),
		citation0( config, args)
	});
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {citation = citation};</text>
      <sha1>a6b1ib2whvprbl21imv4b7dzfbo4l6r</sha1>
    </revision>
    <revision>
      <id>4744</id>
      <parentid>4743</parentid>
      <timestamp>2022-01-26T00:37:06Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>language; generic name;</comment>
      <origin>4744</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="204711" sha1="ilt6iz2ned3py3aovqo8p76cri4utmr" xml:space="preserve">require ('Module:No globals');

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------

each of these counts against the Lua upvalue limit

]]

local validation;																-- functions in Module:Citation/CS1/Date_validation

local utilities;																-- functions in Module:Citation/CS1/Utilities
local z ={};																	-- table of tables in Module:Citation/CS1/Utilities

local identifiers;																-- functions and tables in Module:Citation/CS1/Identifiers
local metadata;																	-- functions in Module:Citation/CS1/COinS
local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;---------------

declare variables here that have page-wide scope that are not brought in from
other modules; that are created here and used here

]]

local added_deprecated_cat;														-- Boolean flag so that the category is added only once
local added_vanc_errs;															-- Boolean flag so we only emit one Vancouver error / category
local added_generic_name_errs;													-- Boolean flag so we only emit one generic name error / category and stop testing names once an error is encountered
local Frame;																	-- holds the module's frame table
local is_preview_mode;															-- true when article is in preview mode; false when using 'Preview page with this template' (previewing the module)
local is_sandbox;																-- true when using sandbox modules to render citation


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if utilities.is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a Boolean declared in page scope variables above

]]

local function add_vanc_error (source, position)
	if added_vanc_errs then return end
		
	added_vanc_errs = true;														-- note that we've added this category
	utilities.set_message ('err_vancouver', {source, position});
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a URI scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of TLDs: https://www.iana.org/domains/root/db

RFC 952 (modified by RFC 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the TLD.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a URL with a scheme) will be stripped
here.  Perhaps not necessary but retained in case it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ASCII characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the TLD) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and TLD or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%w]') then											-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at Wikisource
		return false;
	end

	local patterns = {															-- patterns that look like URLs
		'%f[%w][%w][%w%-]+[%w]%.%a%a+$',										-- three or more character hostname.hostname or hostname.tld
		'%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$',									-- internationalized domain name with ACE prefix
		'%f[%a][qxz]%.com$',													-- assigned one character .com hostname (x.com times out 2015-12-10)
		'%f[%a][iq]%.net$',														-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		'%f[%w][%w]%.%a%a$',													-- one character hostname and ccTLD (2 chars)
		'%f[%w][%w][%w]%.%a%a+$',												-- two character hostname and TLD
		'^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?',								-- IPv4 address
		}

	for _, pattern in ipairs (patterns) do										-- loop through the patterns list
		if domain:match (pattern) then
			return true;														-- if a match then we think that this thing that purports to be a URL is a URL
		end
	end

	for _, d in ipairs ({'cash', 'company', 'today', 'org'}) do					-- look for single letter second level domain names for these top level domains
		if domain:match ('%f[%w][%w]%.' .. d) then
			return true
		end
	end
	return false;																-- no matches, we don't know what this thing is
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a URL appear to be a valid URL; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if utilities.is_set (scheme) then											-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when URL is protocol-relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a URL into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following TLD) (if any) and any path(/), query(?) or fragment(#).

If protocol-relative URL, return nil scheme and domain else return nil for both scheme and domain.

When not protocol-relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Any URL that does not have news: scheme must have authority indicator (//).  TODO: are there other common schemes
like news: that don't use authority indicator?

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol-relative URL
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		if utilities.is_set (authority) then
			authority = authority:gsub ('//', '', 1);							-- replace place 1 pair of '/' with nothing;
			if utilities.is_set(authority) then									-- if anything left (1 or 3+ '/' where authority should be) then
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		else
			if not scheme:match ('^news:') then									-- except for news:..., MediaWiki won't link URLs that do not have authority indicator; TODO: a better way to do this test?
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link=, etc. for properly formatted content: no wikilinks, no URLs

Link parameters are to hold the title of a Wikipedia article, so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki URLs and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid URL (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid URL (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from URL; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid URL
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wiki-linked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

check &lt;link&gt; for inter-language interwiki-link prefix.  prefix must be a MediaWiki-recognized language
code and must begin with a colon.

]]

local function link_title_ok (link, lorig, title, torig)
local orig;
	if utilities.is_set (link) then 											-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		elseif link:match ('^%a+:') then										-- if the link is what looks like an interwiki
			local prefix = link:match ('^(%a+):'):lower();						-- get the interwiki prefix

			if cfg.inter_wiki_map[prefix] then									-- if prefix is in the map, must have preceding colon
				orig = lorig;													-- flag as error
			end
		end
	end

	if utilities.is_set (orig) then
		link = '';																-- unset
		utilities.set_message ('err_bad_paramlink', orig);						-- URL or wikilink in |title= with |title-link=;
	end
	
	return link;																-- link if ok, empty string else
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the URL into scheme and domain
portions, or for protocol-relative (//example.com) URLs, just the domain.  Use is_url() to validate the two
portions of the URL.  If both are valid, or for protocol-relative if domain is valid, return true, else false.

Because it is different from a standard URL, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper URL
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from URL;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a URL.  The test will also find external wikilinks
that use protocol-relative URLs. Also finds bare URLs.

The frontier pattern prevents a match on interwiki-links which are similar to scheme:path URLs.  The tests that
find bracketed URLs are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext. wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol-relative ext. wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare URL with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol-relative bare URL: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a URL
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list, error_list)
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a URL add an error message
			table.insert (error_list, utilities.wrap_style ('parameter', k));
		end
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		utilities.set_message ('err_wikilink_in_url', {});
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link (URL, label, source, access)
	local err_msg = '';
	local domain;
	local path;
	local base_url;

	if not utilities.is_set (label) then
		label = URL;
		if utilities.is_set (source) then
			utilities.set_message ('err_bare_url_missing_title', {utilities.wrap_style ('parameter', source)});
		else
			error (cfg.messages[&quot;bare_url_no_origin&quot;]);
		end			
	end
	if not check_url (URL) then
		utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)});
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the URL into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['['] = '%5b', [']'] = '%5d'});			-- replace '[' and ']' with their percent-encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat ({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wiki-markup URL

	if utilities.is_set (access) then											-- access level (subscription, registration, limited)
		base_url = utilities.substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end

	return base_url;
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a Boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		utilities.set_message ('err_deprecated_params', {name});				-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wiki-markup) are not kerned.

Replaces Unicode quote marks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc.; not for book titles.

]=]

local function kern_quotes (str)
	local cap = '';
	local wl_type, label, link;

	wl_type, label, link = utilities.is_wikilink (str);							-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-left'], str);
			str = utilities.substitute (cfg.presentation['kern-right'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = utilities.substitute (cfg.presentation['kern-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label = mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label = mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap = mw.ustring.match (label, &quot;^([\&quot;\'][^\'].+)&quot;);						-- match leading double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-left'], cap);
		end
	
		cap = mw.ustring.match (label, &quot;^(.+[^\'][\&quot;\'])$&quot;)						-- match trailing double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-right'], cap);
		end
		
		if 2 == wl_type then
			str = utilities.make_wikilink (link, label);						-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin-based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate RTL languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO 639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO 639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title=, |script-chapter=, |script-&lt;periodical&gt;=

]]

local function format_script_value (script_value, script_param)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%l?%s*:') then									-- if first 3 or 4 non-space characters are script language prefix
		lang = script_value:match('^(%l%l%l?)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not utilities.is_set (lang) then
			utilities.set_message ('err_script_parameter', {script_param, 'missing title part'});		-- prefix without 'title'; add error message
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_code_remap[lang] or mw.language.fetchLanguageName( lang, cfg.this_wiki_code );	-- get language name so that we can use it to categorize
		if utilities.is_set (name) then											-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l+%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if utilities.in_array (lang, cfg.script_lang_codes) then
				utilities.add_prop_cat ('script', {name, lang})
			else
				utilities.set_message ('err_script_parameter', {script_param, 'unknown language code'});	-- unknown script-language; add error message
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			utilities.set_message ('err_script_parameter', {script_param, 'invalid language code'});		-- invalid language code; add error message
			lang = '';															-- invalid so set lang to empty string
		end
	else
		utilities.set_message ('err_script_parameter', {script_param, 'missing prefix'});				-- no language code prefix; add error message
	end
	script_value = utilities.substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is RTL

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script
value has been wrapped in &lt;bdi&gt; tags.

]]

local function script_concatenate (title, script, script_param)
	if utilities.is_set (script) then
		script = format_script_value (script, script_param);					-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; returns empty string on error
		if utilities.is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not utilities.is_set ( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return utilities.substitute ( msg, str );								-- including template text
	else
		return utilities.substitute ( cfg.messages[key], str );
	end		
end


--[[----------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;-------------------

Makes a Wikisource URL from Wikisource interwiki-link.  Returns the URL and appropriate
label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;
	local wikisource_prefix = table.concat ({'https://', cfg.this_wiki_code, '.wikisource.org/wiki/'});

	wl_type, D, L = utilities.is_wikilink (str);								-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 1 == wl_type then													-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end

	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable URL
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent-encoding of fragment marker
	end

	return ws_url, ws_label, L or D;											-- return proper URL or nil and a label or nil
end


--[[----------------&lt; F O R M A T _ P E R I O D I C A L &gt;-----------------------

Format the three periodical parameters: |script-&lt;periodical&gt;=, |&lt;periodical&gt;=,
and |trans-&lt;periodical&gt;= into a single Periodical meta-parameter.

]]

local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)

	if not utilities.is_set (periodical) then
		periodical = '';														-- to be safe for concatenation
	else
		periodical = utilities.wrap_style ('italic-title', periodical);			-- style 
	end

	periodical = script_concatenate (periodical, script_periodical, script_periodical_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (trans_periodical) then
		trans_periodical = utilities.wrap_style ('trans-italic-title', trans_periodical);
		if utilities.is_set (periodical) then
			periodical = periodical .. ' ' .. trans_periodical;
		else																	-- here when trans-periodical without periodical or script-periodical
			periodical = trans_periodical;
			utilities.set_message ('err_trans_missing_title', {'periodical'});
		end
	end

	return periodical;
end


--[[------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;---------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=,
and |chapter-url= into a single chapter meta- parameter (chapter_url_source used
for error messages).

]]

local function format_chapter_title (script_chapter, script_chapter_source, chapter, chapter_source, trans_chapter, trans_chapter_source, chapter_url, chapter_url_source, no_quotes, access)
	local ws_url, ws_label, L = wikisource_url_make (chapter);					-- make a wikisource URL and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', ' ');									-- replace underscore separators with space characters
		chapter = ws_label;
	end

	if not utilities.is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from module provided quote marks
			chapter = utilities.wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, script_chapter, script_chapter_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (chapter_url) then
		chapter = external_link (chapter_url, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');	-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if utilities.is_set (trans_chapter) then
		trans_chapter = utilities.wrap_style ('trans-quoted-title', trans_chapter);
		if utilities.is_set (chapter) then
			chapter = chapter .. ' ' .. trans_chapter;
		else																	-- here when trans_chapter without chapter or script-chapter
			chapter = trans_chapter;
			chapter_source = trans_chapter_source:match ('trans%-?(.+)');		-- when no chapter, get matching name from trans-&lt;param&gt;
			utilities.set_message ('err_trans_missing_title', {chapter_source});
		end
	end

	return chapter;
end


--[[----------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;-------------------

This function searches a parameter's value for non-printable or invisible characters.
The search stops at the first match.

This function will detect the visible replacement character when it is part of the Wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers
(gallery, math, pre, ref) and identifies them with a slightly different error message.
See also coins_cleanup().

Output of this function is an error message that identifies the character or the
Unicode group, or the stripmarker that was detected along with its position (or,
for multi-byte characters, the position of its first byte) in the parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local stripmarker;															-- boolean set true when a stripmarker is found

	capture = string.match (v, '[%w%p ]*');										-- test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no Unicode characters
		return;
	end

	for _, invisible_char in ipairs (cfg.invisible_chars) do
		local char_name = invisible_char[1];									-- the character or group name
		local pattern = invisible_char[2];										-- the pattern used to find it
		position, _, capture = mw.ustring.find (v, pattern);					-- see if the parameter value contains characters that match the pattern
		
		if position and (cfg.invisible_defs.zwj == capture) then				-- if we found a zero-width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- it's ok if one of the Indic scripts
				position = nil;													-- unset position
			elseif cfg.emoji[mw.ustring.codepoint (v, position+1)] then			-- is zwj followed by a character listed in emoji{}?
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and utilities.in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and cfg.invisible_defs.del == capture then	-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture and not (cfg.invisible_defs.del == capture or cfg.invisible_defs.zwj == capture) then
					err_msg = capture .. ' ' .. char_name;
				else
					err_msg = char_name .. ' ' .. 'character';
				end

				utilities.set_message ('err_invisible_char', {err_msg, utilities.wrap_style ('parameter', param), position});	-- add error message
				return;															-- and done with this parameter
			end
		end
	end
end


--[[-------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------

Argument wrapper.  This function provides support for argument mapping defined
in the configuration file so that multiple names can be transparently aliased to
single internal variable.

]]

local function argument_wrapper ( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function ( self, k )
			local dummy = self[k];												-- force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = utilities.select_one ( args, list, 'err_redundant_parameters' );
				if origin[k] == nil then
					origin[k] = '';												-- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] .. ': ' .. k);
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;-------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.
When date is DD MMMM YYYY or is MMMM DD, YYYY then wrap in nowrap span:
&lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap = '';
	local cap2 = '';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = utilities.substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = utilities.substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;---------------------

This function sets default title types (equivalent to the citation including
|type=&lt;default value&gt;) for those templates that have defaults. Also handles the
special case where it is desirable to omit the title type from the rendered citation
(|type=none).

]]

local function set_titletype (cite_class, title_type)
	if utilities.is_set (title_type) then
		if 'none' == cfg.keywords_xlate[title_type] then
			title_type = '';													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; S A F E _ J O I N &gt;-----------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'duplicate character'
		if 1 == #duplicate_char then											-- for single byte ASCII characters use the string library functions
			f.gsub = string.gsub
			f.match = string.match
			f.sub = string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub = mw.ustring.gsub
			f.match = mw.ustring.match
			f.sub = mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1, 1) == '&lt;' then										-- special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove HTML markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1, 1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc.?
				trim = false;
				end_chr = f.sub(str, -1, -1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr .. &quot;)&quot;				-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1, -2);									-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;''&quot; then		-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5, -1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;]]&quot; then		-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3, -1) == duplicate_char .. '&quot;]' then	-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2, -1) == duplicate_char .. &quot;]&quot; then	-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2, -1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1, -3);								-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains HTML markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows HTML markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value; 												-- add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;-----------------------------

returns true if suffix is properly formed Jr, Sr, or ordinal in the range 1–9.
Puncutation not allowed.

]]

local function is_suffix (suffix)
	if utilities.in_array (suffix, {'Jr', 'Sr', 'Jnr', 'Snr', '1st', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;-------------------

For Vancouver style, author/editor names are supposed to be rendered in Latin
(read ASCII) characters.  When a name uses characters that contain diacritical
marks, those characters are to be converted to the corresponding Latin
character. When a name is written using a non-Latin alphabet or logogram, that
name is to be transliterated into Latin characters. The module doesn't do this
so editors may/must.

This test allows |first= and |last= names to contain any of the letters defined
in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes.
	(http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;)
	or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written outside of the code editor and pasted here because the code editor
gets confused between character insertion point and cursor position. The test has
been rewritten to use decimal character escape sequence for the individual bytes
of the Unicode characters so that it is not necessary to use an external editor
to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first, suffix, position)
	if not suffix then
		if first:find ('[,%s]') then											-- when there is a space or comma, might be first name/initials + generational suffix
			first = first:match ('(.-)[,%s]+');									-- get name/initials
			suffix = first:match ('[,%s]+(.+)$');								-- get generational suffix
		end
	end
	if utilities.is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error (cfg.err_msg_supl.suffix, position);
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error (cfg.err_msg_supl['non-Latin char'], position);
			return false;														-- not a string of Latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-style=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period.
See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc.) to be rendered
as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format
because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the
Unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first, position)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just initials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error (cfg.err_msg_supl.suffix, position);			-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word

	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i], 1, 1));			-- insert the initial at end of initials table
		end
		i = i + 1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; L I S T _ P E O P L E &gt;--------------------------

Formats a list of people (authors, contributors, editors, interviewers, translators) 

names in the list will be linked when
	|&lt;name&gt;-link= has a value
	|&lt;name&gt;-mask- does NOT have a value; masked names are presumed to have been
		rendered previously so should have been linked there

when |&lt;name&gt;-mask=0, the associated name is not rendered

]]

local function list_people (control, people, etal)
	local sep;
	local namesep;
	local format = control.format;
	local maximum = control.maximum;
	local name_list = {};

	if 'vanc' == format then													-- Vancouver-like name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between names is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between names is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub (-1, -1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if utilities.is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end		-- returned 0 is for EditorCount; not used for other names
	
	for i, person in ipairs (people) do
		if utilities.is_set (person.last) then
			local mask = person.mask;
			local one;
			local sep_one = sep;

			if utilities.is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			end
			
			if mask then
				local n = tonumber (mask);										-- convert to a number if it can be converted; nil else
				if n then
					one = 0 ~= n and string.rep(&quot;&amp;mdash;&quot;, n) or nil;			-- make a string of (n &gt; 0) mdashes, nil else, to replace name
					person.link = nil;											-- don't create link to name if name is replaces with mdash string or has been set nil
				else
					one = mask;													-- replace name with mask text (must include name-list separator)
					sep_one = &quot; &quot;;												-- modify name-list separator
				end
			else
				one = person.last;												-- get surname
				local first = person.first										-- get given name
				if utilities.is_set (first) then
					if (&quot;vanc&quot; == format) then									-- if Vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first, nil, i) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials (first, i);				-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
			end
			if utilities.is_set (person.link) then
				one = utilities.make_wikilink (person.link, one);				-- link author/editor
			end
			if one then															-- if &lt;one&gt; has a value (name, mdash replacement, or mask text replacement)
				table.insert (name_list, one);									-- add it to the list of names
				table.insert (name_list, sep_one);								-- add the proper name-list separator
			end
		end
	end

	local count = #name_list / 2;												-- (number of names + number of separators) divided by 2
	if 0 &lt; count then 
		if 1 &lt; count and not etal then
			if 'amp' == format then
				name_list[#name_list-2] = &quot; &amp; &quot;;								-- replace last separator with ampersand text
			elseif 'and' == format then
				if 2 == count then
					name_list[#name_list-2] = cfg.presentation.sep_nl_and;		-- replace last separator with 'and' text
				else
					name_list[#name_list-2] = cfg.presentation.sep_nl_end;		-- replace last separator with '(sep) and' text
				end
			end
		end
		name_list[#name_list] = nil;											-- erase the last separator
	end

	local result = table.concat (name_list);									-- construct list
	if etal and utilities.is_set (result) then									-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've got a last-first list and etal so add et al.
	end
	
	return result, count;														-- return name-list string and count of number of names (count used for editor names only)
end


--[[--------------------&lt; M A K E _ C I T E R E F _ I D &gt;-----------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise
returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that
order.  year is Year or anchor_year.

]]

local function make_citeref_id (namelist, year)
	local names={};							-- a table for the one to four names and year
	for i,v in ipairs (namelist) do			-- loop through the list and take up to the first four last names
		names[i] = v.last
		if i == 4 then break end			-- if four then done
	end
	table.insert (names, year);				-- add the year at the end
	local id = table.concat(names);			-- concatenate names and year for CITEREF id
	if utilities.is_set (id) then			-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;				-- add the CITEREF portion
	else
		return '';							-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; C I T E _ C L A S S _A T T R I B U T E _M A K E &gt;------------------------------

construct &lt;cite&gt; tag class attribute for this citation.

&lt;cite_class&gt; – config.CitationClass from calling template
&lt;mode&gt; – value from |mode= parameter

]]

local function cite_class_attribute_make (cite_class, mode)
	local class_t = {};
	table.insert (class_t, 'citation');											-- required for blue highlight
	if 'citation' ~= cite_class then
		table.insert (class_t, cite_class);										-- identify this template for user css
		table.insert (class_t, utilities.is_set (mode) and mode or 'cs1');		-- identify the citation style for user css or javascript
	else
		table.insert (class_t, utilities.is_set (mode) and mode or 'cs2');		-- identify the citation style for user css or javascript
	end
	for _, prop_key in ipairs (z.prop_keys_t) do
		table.insert (class_t, prop_key);										-- identify various properties for user css or javascript
	end

	return table.concat (class_t, ' ');											-- make a big string and done
end


--[[---------------------&lt; N A M E _ H A S _ E T A L &gt;--------------------------

Evaluates the content of name parameters (author, editor, etc.) for variations on
the theme of et al.  If found, the et al. is removed, a flag is set to true and
the function returns the modified name and the flag.

This function never sets the flag to false but returns its previous state because
it may have been set by previous passes through this function or by the associated
|display-&lt;names&gt;=etal parameter

]]

local function name_has_etal (name, etal, nocat, param)

	if utilities.is_set (name) then												-- name can be nil in which case just return
		local patterns = cfg.et_al_patterns; 									-- get patterns from configuration
		
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns
			if name:match (pattern) then										-- if this 'et al' pattern is found in name
				name = name:gsub (pattern, '');									-- remove the offending text
				etal = true;													-- set flag (may have been set previously here or by |display-&lt;names&gt;=etal)
				if not nocat then												-- no categorization for |vauthors=
					utilities.set_message ('err_etal', {param});				-- and set an error if not added
				end
			end
		end
	end

	return name, etal;
end


--[[---------------------&lt; N A M E _ I S _ N U M E R I C &gt;----------------------

Add maint cat when name parameter value does not contain letters.  Does not catch
mixed alphanumeric names so |last=A. Green (1922-1987) does not get caught in the
current version of this test but |first=(1888) is caught.

returns nothing

]]

local function name_is_numeric (name, list_name)
	if utilities.is_set (name) then
		if mw.ustring.match (name, '^[%A]+$') then								-- when name does not contain any letters
			utilities.set_message ('maint_numeric_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
		end
	end
end


--[[-----------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;------------------

Evaluates the content of last/surname (authors etc.) parameters for multiple names.
Multiple names are indicated if there is more than one comma or any &quot;unescaped&quot;
semicolons. Escaped semicolons are ones used as part of selected HTML entities.
If the condition is met, the function adds the multiple name maintenance category.

returns nothing

]]

local function name_has_mult_names (name, list_name)
	local _, commas, semicolons, nbsps;
	if utilities.is_set (name) then
		_, commas = name:gsub (',', '');										-- count the number of commas
		_, semicolons = name:gsub (';', '');									-- count the number of semicolons
		-- nbsps probably should be its own separate count rather than merged in
		-- some way with semicolons because Lua patterns do not support the
		-- grouping operator that regex does, which means there is no way to add
		-- more entities to escape except by adding more counts with the new
		-- entities
		_, nbsps = name:gsub ('&amp;nbsp;','');										-- count nbsps
		
		-- There is exactly 1 semicolon per &amp;nbsp; entity, so subtract nbsps
		-- from semicolons to 'escape' them. If additional entities are added,
		-- they also can be subtracted.
		if 1 &lt; commas or 0 &lt; (semicolons - nbsps) then
			utilities.set_message ('maint_mult_names', cfg.special_case_translation [list_name]);	-- add a maint message
		end
	end
end


--[[--------------------------&lt; I S _ G E N E R I C &gt;----------------------------------------------------------

Compares values assigned to various parameter according to the string provided as &lt;item&gt; in the function call:
	'generic_names': |last=, |first=, |editor-last=, etc value against list of known generic name patterns
	'generic_titles': |title=
Returns true when pattern matches; nil else

The k/v pairs in cfg.special_case_translation[item] each contain two tables, one for English and one for another
'local' language.Each of those tables contain another table that holds the string or pattern (whole or fragment)
in index [1]. index [2] is a Boolean that tells string.find() or mw.ustring.find() to do plain-text search (true)
or a pattern search (false).  The intent of all this complexity is to make these searches as fast as possible so
that we don't run out of processing time on very large articles.

]]

local function is_generic (item, value)
	local test_val;

	for _, generic_value in ipairs (cfg.special_case_translation[item]) do		-- spin through the list of known generic value fragments
		test_val = generic_value['en'][2] and value:lower() or value;			-- when set to 'true', plaintext search using lowercase value

		if test_val:find (generic_value['en'][1], 1, generic_value['en'][2]) then
			return true;														-- found English generic value so done

		elseif generic_value['local'] then										-- to keep work load down, generic_&lt;value&gt;['local'] should be nil except when there is a local version of the generic value
			test_val = generic_value['local'][2] and mw.ustring.lower(value) or value;	-- when set to 'true', plaintext search using lowercase value

			if mw.ustring.find (test_val, generic_value['local'][1], 1, generic_value['local'][2]) then	-- mw.ustring() because might not be Latin script
				return true;													-- found local generic value so done
			end
		end
	end
end


--[[--------------------------&lt; N A M E _ I S _ G E N E R I C &gt;------------------------------------------------

calls is_generic() to determine if &lt;name&gt; is a 'generic name' listed in cfg.generic_names; &lt;name_alias&gt; is the
parameter name used in error messaging

]]

local function name_is_generic (name, name_alias)
	if not added_generic_name_errs  and is_generic ('generic_names', name) then
		utilities.set_message ('err_generic_name', name_alias);					-- set an error message
		added_generic_name_errs = true;
	end
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------

This function calls various name checking functions used to validate the content of the various name-holding parameters.

]]

local function name_checks (last, first, list_name, last_alias, first_alias)
	local accept_name;

	if utilities.is_set (last) then
		last, accept_name = utilities.has_accept_as_written (last);				-- remove accept-this-as-written markup when it wraps all of &lt;last&gt;

		if not accept_name then													-- &lt;last&gt; not wrapped in accept-as-written markup
			name_has_mult_names (last, list_name);								-- check for multiple names in the parameter (last only)
			name_is_numeric (last, list_name);									-- check for names that are composed of digits and punctuation
			name_is_generic (last, last_alias);									-- check for names found in the generic names list
		end
	end

	if utilities.is_set (first) then
		first, accept_name = utilities.has_accept_as_written (first);			-- remove accept-this-as-written markup when it wraps all of &lt;first&gt;

		if not accept_name then													-- &lt;first&gt; not wrapped in accept-as-written markup
			name_is_numeric (first, list_name);									-- check for names that are composed of digits and punctuation
			name_is_generic (first, first_alias);								-- check for names found in the generic names list
		end
		local wl_type, D = utilities.is_wikilink (first);
		if 0 ~= wl_type then
			first = D;
			utilities.set_message ('err_bad_paramlink', first_alias);
		end
	end

	return last, first;															-- done
end


--[[----------------------&lt; E X T R A C T _ N A M E S &gt;-------------------------

Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters
(or their aliases), and their matching link and mask parameters. Stops searching
when both |lastn= and |firstn= are not found in args after two sequential attempts:
found |last1=, |last2=, and |last3= but doesn't find |last4= and |last5= then the
search is done.

This function emits an error message when there is a |firstn= without a matching
|lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not
required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.'
is stripped from the parameter and a flag (etal) returned that will cause list_people()
to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps
'et al.' out of the template's metadata.  When this occurs, an error is emitted.

]]

local function extract_names(args, list_name)
	local names = {};															-- table of names
	local last;																	-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;																-- loop counter/indexer
	local n = 1;																-- output table indexer
	local count = 0;															-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal = false;															-- return value set to true when we find some form of et al. in an author parameter

	local last_alias, first_alias, link_alias;									-- selected parameter aliases used in error messaging
	while true do
		last, last_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'err_redundant_parameters', i );		-- search through args for name components beginning at 1
		first, first_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'err_redundant_parameters', i );
		link, link_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i );
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.
		last, first = name_checks (last, first, list_name, last_alias, first_alias);						-- multiple names, extraneous annotation, etc. checks

		if first and not last then												-- if there is a firstn without a matching lastn
			local alias = first_alias:find ('given', 1, true) and 'given' or 'first';	-- get first or given form of the alias
			utilities.set_message ('err_first_missing_last', {
				first_alias,													-- param name of alias missing its mate
				first_alias:gsub (alias, {['first'] = 'last', ['given'] = 'surname'}),	-- make param name appropriate to the alias form
				});																-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			local result;
			link = link_title_ok (link, link_alias, last, last_alias);			-- check for improper wiki-markup

			if first then
				link = link_title_ok (link, link_alias, first, first_alias);	-- check for improper wiki-markup
			end

			names[n] = {last = last, first = first, link = link, mask = mask, corporate = false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				utilities.set_message ('err_missing_name', {list_name:match (&quot;(%w+)List&quot;):lower(), i - 1});	-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names and the etal flag
end


--[[--------------------------&lt; N A M E _ T A G _ G E T &gt;------------------------------------------------------

attempt to decode |language=&lt;lang_param&gt; and return language name and matching tag; nil else.

This function looks for:
	&lt;lang_param&gt; as a tag in cfg.lang_code_remap{}
	&lt;lang_param&gt; as a name in cfg.lang_name_remap{}
	
	&lt;lang_param&gt; as a name in cfg.mw_languages_by_name_t
	&lt;lang_param&gt; as a tag in cfg.mw_languages_by_tag_t
when those fail, presume that &lt;lang_param&gt; is an IETF-like tag that MediaWiki does not recognize.  Strip all
script, region, variant, whatever subtags from &lt;lang_param&gt; to leave just a two or three character language tag
and look for the new &lt;lang_param&gt; in cfg.mw_languages_by_tag_t{}

on success, return name and matching tag; on failure return nil

]]

local function name_tag_get (lang_param)
	local lang_param_lc = mw.ustring.lower (lang_param);						-- use lowercase as an index into the various tables

	local name = cfg.lang_code_remap[lang_param_lc];							-- assume &lt;lang_param_lc&gt; is a tag; attempt to get remapped language name 
	if name then																-- when &lt;name&gt;, &lt;lang_param&gt; is a tag for a remapped language name
		return name, lang_param;												-- so return &lt;name&gt; from remap and &lt;lang_param&gt;
	end

	if cfg.lang_name_remap[lang_param_lc] then									-- not a tag, assume &lt;lang_param_lc&gt; is a name; attempt to get remapped language tag 
		return cfg.lang_name_remap[lang_param_lc][1], cfg.lang_name_remap[lang_param_lc][2];	-- for this &lt;lang_param_lc&gt;, return a (possibly) new name and appropriate tag
	end

	local tag = cfg.mw_languages_by_name_t[lang_param_lc];						-- assume that &lt;lang_param_lc&gt; is a language name; attempt to get its matching tag
	
	if tag then
		return cfg.mw_languages_by_tag_t[tag], tag;								-- &lt;lang_param_lc&gt; is a name so return the name from the table and &lt;tag&gt;
	end

	name = cfg.mw_languages_by_tag_t[lang_param_lc];							-- assume that &lt;lang_param_lc&gt; is a tag; attempt to get its matching language name
	
	if name then
		return name, lang_param;												-- &lt;lang_param_lc&gt; is a tag so return &lt;name&gt; and the tag
	end
	
	tag = lang_param_lc:match ('^(%a%a%a?)%-.*');								-- is tag an IETF-like tag that MediaWiki doesn't recognize? &lt;tag&gt; gets the language subtag; nil else

	if tag then
		name = cfg.mw_languages_by_tag_t[tag];									-- attempt to get a language name using the shortened &lt;tag&gt;
		if name then
			return name, tag;													-- &lt;lang_param_lc&gt; is an unrecognized IETF-like tag so return &lt;name&gt; and language subtag
		end
	end
end


--[[-------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code
is recognized by MediaWiki, use the returned name; if not, then use the value that
was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is
assigned to the category for that code: Category:Norwegian-language sources (no).
For valid three-character code languages, the page is assigned to the single category
for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does
not recognize three-character equivalents of two-character codes: code 'ar' is
recognized but code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th
where the language names or codes are separated from each other by commas with
optional space characters.

]]

local function language_parameter (lang)
	local tag;																	-- some form of IETF-like language tag; language subtag with optional region, sript, vatiant, etc subtags
	local lang_subtag;															-- ve populates |language= with mostly unecessary region subtags the MediaWiki does not recognize; this is the base language subtag
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_t = {};															-- table made from the value assigned to |language=

	local this_wiki_name = mw.language.fetchLanguageName (cfg.this_wiki_code, cfg.this_wiki_code);	-- get this wiki's language name

	names_t = mw.text.split (lang, '%s*,%s*');									-- names should be a comma separated list

	for _, lang in ipairs (names_t) do											-- reuse lang here because we don't yet know if lang is a language name or a language tag
		name, tag = name_tag_get (lang);										-- attempt to get name/tag pair for &lt;lang&gt;

		if utilities.is_set (tag) then
			lang_subtag = tag:gsub ('^(%a%a%a?)%-.*', '%1');					-- for categorization, strip any IETF-like tags from language tag

			if cfg.this_wiki_code ~= lang_subtag then							-- when the language is not the same as this wiki's language
				if 2 == lang_subtag:len() then									-- and is a two-character tag
					utilities.add_prop_cat ('foreign-lang-source', {name, lang_subtag}, lang_subtag);		-- categorize it; tag appended to allow for multiple language categorization
				else															-- or is a recognized language (but has a three-character tag)
					utilities.add_prop_cat ('foreign-lang-source-2', {lang_subtag}, lang_subtag);			-- categorize it differently TODO: support multiple three-character tag categories per cs1|2 template?
				end
			elseif cfg.local_lang_cat_enable then								-- when the language and this wiki's language are the same and categorization is enabled
				utilities.add_prop_cat ('local-lang-source', {name, lang_subtag});		-- categorize it
			end
		else
			name = lang;														-- return whatever &lt;lang&gt; has so that we show something
			utilities.set_message ('maint_unknown_lang');						-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
 
	name = utilities.make_sep_list (#language_list, language_list);
	if (1 == #language_list) and (tag == cfg.this_wiki_code) then				-- when only one language, find lang name in this wiki lang name; for |language=en-us, 'English' in 'American English'
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[-----------------------&lt; S E T _ C S _ S T Y L E &gt;--------------------------

Gets the default CS style configuration for the given mode.
Returns default separator and either postscript as passed in or the default.
In CS1, the default postscript and separator are '.'.
In CS2, the default postscript is the empty string and the default separator is ','.

]]

local function set_cs_style (postscript, mode)
	if utilities.is_set(postscript) then
		-- emit a maintenance message if user postscript is the default cs1 postscript
		-- we catch the opposite case for cs2 in set_style
		if mode == 'cs1' and postscript == cfg.presentation['ps_' .. mode] then
			utilities.set_message ('maint_postscript');
		end
	else
		postscript = cfg.presentation['ps_' .. mode];
	end
	return cfg.presentation['sep_' .. mode], postscript;
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;-----------------------------

Sets the separator and postscript styles. Checks the |mode= first and the
#invoke CitationClass second. Removes the postscript if postscript == none.

]]

local function set_style (mode, postscript, cite_class)
	local sep;
	if 'cs2' == mode then
		sep, postscript = set_cs_style (postscript, 'cs2');
	elseif 'cs1' == mode then
		sep, postscript = set_cs_style (postscript, 'cs1');
	elseif 'citation' == cite_class	then
		sep, postscript = set_cs_style (postscript, 'cs2');
	else
		sep, postscript = set_cs_style (postscript, 'cs1');
	end

	if cfg.keywords_xlate[postscript:lower()] == 'none' then
		-- emit a maintenance message if user postscript is the default cs2 postscript
		-- we catch the opposite case for cs1 in set_cs_style
		if 'cs2' == mode or 'citation' == cite_class then
			utilities.set_message ('maint_postscript');
		end
		postscript = '';
	end
	
	return sep, postscript
end


--[=[-------------------------&lt; I S _ P D F &gt;-----------------------------------

Determines if a URL has the file extension that is one of the PDF file extensions
used by [[MediaWiki:Common.css]] when applying the PDF icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or
		url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
		url:match ('%.PDF&amp;#035') or url:match ('%.pdf&amp;#035');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;-----------------------

Applies CSS style to |format=, |chapter-format=, etc.  Also emits an error message
if the format parameter does not have a matching URL parameter.  If the format parameter
is not set and the URL contains a file extension that is recognized as a PDF document
by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if utilities.is_set (format) then
		format = utilities.wrap_style ('format', format);						-- add leading space, parentheses, resize
		if not utilities.is_set (url) then
			utilities.set_message ('err_format_missing_url', {fmt_param, url_param});	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if URL is a PDF file then
		format = utilities.wrap_style ('format', 'PDF');						-- set format to PDF
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[---------------------&lt; G E T _ D I S P L A Y _ N A M E S &gt;------------------

Returns a number that defines the number of names displayed for author and editor
name lists and a Boolean flag to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero,
return the number and the previous state of the 'etal' flag (false by default
but may have been set to true if the name list contains some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number
that is one greater than the number of authors in the list and set the 'etal' flag true.
This will cause the list_people() to display all of the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_names (max, count, list_name, etal, param)
	if utilities.is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				utilities.set_message ('err_disp_name', {param, max});			-- add error message
				max = nil;
			end
		else																	-- not a valid keyword or number
			utilities.set_message ('err_disp_name', {param, max});		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[----------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;---------------

Adds error if |page=, |pages=, |quote-page=, |quote-pages= has what appears to be
some form of p. or pp. abbreviation in the first characters of the parameter content.

check page for extraneous p, p., pp, pp., pg, pg. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when page begins PX or P# but not Px
		      where x and X are letters and # is a digit
	bad pattern:  '^[Pp][PpGg]' matches when page begins pp, pP, Pp, PP, pg, pG, Pg, PG

]]

local function extra_text_in_page_check (val, name)
	if not val:match (cfg.vol_iss_pg_patterns.good_ppattern) then
		for _, pattern in ipairs (cfg.vol_iss_pg_patterns.bad_ppatterns) do		-- spin through the selected sequence table of patterns
			if val:match (pattern) then											-- when a match, error so
				utilities.set_message ('err_extra_text_pages', name);	 		-- add error message
				return;															-- and done
			end
		end
	end		
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ V O L _ I S S _ C H E C K &gt;------------------------

Adds error if |volume= or |issue= has what appears to be some form of redundant 'type' indicator.

For |volume=:
	'V.', or 'Vol.' (with or without the dot) abbreviations or 'Volume' in the first characters of the parameter
	content (all case insensitive). 'V' and 'v' (without the dot) are presumed to be roman numerals so
	are allowed.

For |issue=:
	'No.', 'I.', 'Iss.' (with or without the dot) abbreviations, or 'Issue' in the first characters of the
	parameter content (all case insensitive).
	
Single character values ('v', 'i', 'n') allowed when not followed by separator character ('.', ':', '=', or
whitespace character) – param values are trimmed of whitespace by MediaWiki before delivered to the module.
	
&lt;val&gt; is |volume= or |issue= parameter value
&lt;name&gt; is |volume= or |issue= parameter name for error message
&lt;selector&gt; is 'v' for |volume=, 'i' for |issue=

sets error message on failure; returns nothing

]]

local function extra_text_in_vol_iss_check (val, name, selector)
	if not utilities.is_set (val) then
		return;
	end
	
	local patterns = 'v' == selector and cfg.vol_iss_pg_patterns.vpatterns or cfg.vol_iss_pg_patterns.ipatterns;

	local handler = 'v' == selector and 'err_extra_text_volume' or 'err_extra_text_issue';
	val = val:lower();															-- force parameter value to lower case
	for _, pattern in ipairs (patterns) do										-- spin through the selected sequence table of patterns
		if val:match (pattern) then												-- when a match, error so
			utilities.set_message (handler, name);								-- add error message
			return;																-- and done
		end
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parentheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a placeholder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parentheses
			local name = name_table[i];
			i = i + 1;															-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parentheses
					break;														-- and done reassembling so
				end
				i = i + 1;														-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = utilities.is_wikilink (name_table[i]);		-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i + 1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled parentheses ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the Vancouver error when a required comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		first = '';																-- set to empty string for concatenation and because it may have been set for previous author/editor
		local accept_name;
		v_name, accept_name = utilities.has_accept_as_written (v_name);			-- remove accept-this-as-written markup when it wraps all of &lt;v_name&gt;

		if accept_name then
			last = v_name;
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error (cfg.err_msg_supl.punctuation, i);
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s+&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be initials or generational suffix

			if not mw.ustring.match (first, '^%u+$') then						-- mw.ustring here so that later we will catch non-Latin characters
				suffix = first;													-- not initials so assume that whatever we got is a generational suffix
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end
			last = table.concat(lastfirstTable, ' ')							-- returns a string that is the concatenation of all other names that are not initials and generational suffix
			if not utilities.is_set (last) then
				first = '';														-- unset
				last = v_name;													-- last empty because something wrong with first
				add_vanc_error (cfg.err_msg_supl.name, i);
			end
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error (cfg.err_msg_supl['missing comma'], i);			-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- matches a space between two initials
			end
		else
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
		
		if utilities.is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first, suffix, i);							-- check first and last before restoring the suffix which may have a non-Latin digit
			if utilities.is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '', nil, i);
			end
		end

		link = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i ) or v_link_table[i];
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate = corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest;
|editorn= (and aliases) highest and |veditors= lowest (support for |editors= withdrawn)

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
	local lastfirst = false;
	if utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice in case we have a |first1= without a |last1=; this ...
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or		-- ... also catches the case where |first= is used with |vauthors=
		utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst = true;
	end

	if (utilities.is_set (vxxxxors) and true == lastfirst) or					-- these are the three error conditions
		(utilities.is_set (vxxxxors) and utilities.is_set (xxxxors)) or
		(true == lastfirst and utilities.is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			utilities.set_message ('err_redundant_parameters', err_name .. '-name-list parameters');	-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if utilities.is_set (vxxxxors) then return 2 end;
	if utilities.is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, live, dead, etc.).  When the parameter value has not been assigned a value (missing
or empty in the source template) the function returns the value specified by ret_val.  If the parameter value is one
of the list of allowed values returns the translated value; else, emits an error message and returns the value
specified by ret_val.

TODO: explain &lt;invert&gt;

]]

local function is_valid_parameter_value (value, name, possible, ret_val, invert)
	if not utilities.is_set (value) then
		return ret_val;															-- an empty parameter is ok
	end

	if (not invert and utilities.in_array (value, possible)) then				-- normal; &lt;value&gt; is in &lt;possible&gt; table
		return cfg.keywords_xlate[value];										-- return translation of parameter keyword
	elseif invert and not utilities.in_array (value, possible) then				-- invert; &lt;value&gt; is not in &lt;possible&gt; table
		return value;															-- return &lt;value&gt; as it is
	else
		utilities.set_message ('err_invalid_param_val', {name, value});			-- not an allowed value so add error message
		return ret_val;
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list, -3, -1) == sepc .. '. ') then					-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list, -1, -1) == sepc) or (string.sub (name_list, -3, -1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terminate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not utilities.is_set (volume) and not utilities.is_set (issue) then
		return '';
	end

	-- same condition as in format_pages_sheets()
	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);

	local is_numeric_vol = volume and (volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$'));	-- is only uppercase roman numerals or only digits?
	local is_long_vol = volume and (4 &lt; mw.ustring.len(volume));				-- is |volume= value longer than 4 characters?
	
	if volume and (not is_numeric_vol and is_long_vol) then						-- when not all digits or Roman numerals, is |volume= longer than 4 characters?
		utilities.add_prop_cat ('long-vol');									-- yes, add properties cat
	end

	if is_journal then															-- journal-style formatting
		local vol = '';
		
		if utilities.is_set (volume) then
			if is_numeric_vol then												-- |volume= value all digits or all uppercase Roman numerals?
				vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, volume});	-- render in bold face
			elseif is_long_vol then												-- not all digits or Roman numerals; longer than 4 characters?
				vol = utilities.substitute (cfg.messages['j-vol'], {sepc, utilities.hyphen_to_dash (volume)});	-- not bold
			else																-- four or fewer characters
				vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, utilities.hyphen_to_dash (volume)});	-- bold
			end
		end
		if utilities.is_set (issue) then
			return vol .. utilities.substitute (cfg.messages['j-issue'], issue);
		end
		return vol;
	end
	
	if 'podcast' == cite_class and utilities.is_set (issue) then
		return wrap_msg ('issue', {sepc, issue}, lower);
	end

	-- all other types of citation
	if utilities.is_set (volume) and utilities.is_set (issue) then
		return wrap_msg ('vol-no', {sepc, utilities.hyphen_to_dash (volume), issue}, lower);
	elseif utilities.is_set (volume) then
		return wrap_msg ('vol', {sepc, utilities.hyphen_to_dash (volume)}, lower);
	else
		return wrap_msg ('issue', {sepc, issue}, lower);
	end
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if utilities.is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif utilities.is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if utilities.is_set (page) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return utilities.substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return utilities.substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif utilities.is_set (pages) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then							-- if pages is only digits, assume a single page number
			return '', utilities.substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', utilities.substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', utilities.substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to Wikisource, returns the label portion of the interwiki-link as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki-link to an external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, page_orig, pages, pages_orig, at)
	local ws_url, ws_label, coins_pages, L;										-- for Wikisource interwiki-links; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if utilities.is_set (page) then
		if utilities.is_set (pages) or utilities.is_set (at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page, page_orig);								-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws URL from |page= interwiki link; link portion L becomes tooltip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (pages) then
		if utilities.is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages, pages_orig);							-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws URL from |pages= interwiki link; link portion L becomes tooltip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws URL from |at= interwiki link; link portion L becomes tooltip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end

--[[--------------------------&lt; I S _ U N I Q U E _ A R C H I V E _ U R L &gt;------------------------------------

add error message when |archive-url= value is same as |url= or chapter-url= (or alias...) value

]]

local function is_unique_archive_url (archive, url, c_url, source, date)
	if utilities.is_set (archive) then
		if archive == url or archive == c_url then
			utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)});	-- add error message
			return '', '';														-- unset |archive-url= and |archive-date= because same as |url= or |chapter-url=
		end
	end

	return archive, date;
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org URLs to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot URL or to calendar pages.  When the archive URL is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the URL.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org URL does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command URL
	|archive-url= is an archive.org URL that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org URLs:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this function may return a modified
archive URL:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the URL unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.org URL
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine URL
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command URL, we don't want to allow saving of the target page 
		err_msg = cfg.err_msg_supl.save;
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = cfg.err_msg_supl.liveweb;
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');	-- split out some of the URL parts for evaluation
		if not path then														-- malformed in some way; pattern did not match
			err_msg = cfg.err_msg_supl.timestamp;
		elseif 14 ~= timestamp:len() then										-- path and flag optional, must have 14-digit timestamp here
			err_msg = cfg.err_msg_supl.timestamp;
			if '*' ~= flag then
				local replacement = timestamp:match ('^%d%d%d%d%d%d') or timestamp:match ('^%d%d%d%d');	-- get the first 6 (YYYYMM) or first 4 digits (YYYY)
				if replacement then												-- nil if there aren't at least 4 digits (year)
					replacement = replacement .. string.rep ('0', 14 - replacement:len());	-- year or yearmo (4 or 6 digits) zero-fill to make 14-digit timestamp
					url=url:gsub ('(//web%.archive%.org/[^%d]*)%d[^/]*', '%1' .. replacement .. '*', 1)	-- for preview, modify ts to 14 digits plus splat for calendar display
				end
			end
		elseif utilities.is_set (path) and 'web/' ~= path then					-- older archive URLs do not have the extra 'web/' path element
			err_msg = cfg.err_msg_supl.path;
		elseif utilities.is_set (flag) and not utilities.is_set (path) then		-- flag not allowed with the old form URL (without the 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		elseif utilities.is_set (flag) and not flag:match ('%a%a_') then		-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		else
			return url, date;													-- return ArchiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	utilities.set_message ('err_archive_url', {err_msg});						-- add error message and

	if is_preview_mode then
		return url, date;														-- preview mode so return ArchiveURL and ArchiveDate
	else
		return '', '';															-- return empty strings for ArchiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; P L A C E _ C H E C K &gt;--------------------------------------------------------

check |place=, |publication-place=, |location= to see if these params include digits.  This function added because
many editors misuse location to specify the in-source location (|page(s)= and |at= are supposed to do that)

returns the original parameter value without modification; added maint cat when parameter value contains digits

]]

local function place_check (param_val)
	if not utilities.is_set (param_val) then									-- parameter empty or omitted
		return param_val;														-- return that empty state
	end
	
	if mw.ustring.find (param_val, '%d') then									-- not empty, are there digits in the parameter value
		utilities.set_message ('maint_location');								-- yep, add maint cat
	end
	
	return param_val;															-- and done
end


--[[--------------------------&lt; I S _ A R C H I V E D _ C O P Y &gt;----------------------------------------------

compares |title= to 'Archived copy' (placeholder added by bots that can't find proper title); if matches, return true; nil else

]]

local function is_archived_copy (title)
	title = mw.ustring.lower(title);											-- switch title to lower case
	if title:find (cfg.special_case_translation.archived_copy.en) then			-- if title is 'Archived copy'
		return true;
	elseif cfg.special_case_translation.archived_copy['local'] then
		if mw.ustring.find (title, cfg.special_case_translation.archived_copy['local']) then	-- mw.ustring() because might not be Latin script
			return true;
		end
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args )
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper ( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListStyle = is_valid_parameter_value (A['NameListStyle'], A:ORIGIN('NameListStyle'), cfg.keywords_lists['name-list-style'], '');
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				utilities.set_message ('maint_authors');						-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if utilities.is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], nil, args, 'EditorList');	-- support for |editors= withdrawn
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		end
	end
							
	local Chapter = A['Chapter'];												-- done here so that we have access to |contribution= from |chapter= aliases
	local Chapter_origin = A:ORIGIN ('Chapter');
	local Contribution;															-- because contribution is required for contributor(s)
		if 'contribution' == Chapter_origin then
			Contribution = Chapter;												-- get the name of the contribution
		end
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	
	if utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not utilities.is_set (Contribution) then							-- |contributor= requires |contribution=
				utilities.set_message ('err_contributor_missing_required_param', 'contribution');	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				utilities.set_message ('err_contributor_missing_required_param', 'author');	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if utilities.select_one (args, cfg.aliases['ContributorList-Last'], 'err_redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			utilities.set_message ('err_contributor_ignored');					-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	local Title = A['Title'];
	local TitleLink = A['TitleLink'];

	local auto_select = ''; -- default is auto
	local accept_link;
	TitleLink, accept_link = utilities.has_accept_as_written (TitleLink, true);	-- test for accept-this-as-written markup
	if (not accept_link) and utilities.in_array (TitleLink, {'none', 'pmc', 'doi'}) then -- check for special keywords
		auto_select = TitleLink;												-- remember selection for later
		TitleLink = '';															-- treat as if |title-link= would have been empty
	end

	TitleLink = link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wiki-markup in |title-link= or wiki-markup in |title= when |title-link= is set

	local Section = '';															-- {{cite map}} only; preset to empty string for concatenation if not used
	if 'map' == config.CitationClass and 'section' == Chapter_origin then
		Section = A['Chapter'];													-- get |section= from |chapter= alias list; |chapter= and the other aliases not supported in {{cite map}}
		Chapter = '';															-- unset for now; will be reset later from |map= if present
	end

	local Periodical = A['Periodical'];
	local Periodical_origin = '';
	if utilities.is_set (Periodical) then
		Periodical_origin = A:ORIGIN('Periodical');								-- get the name of the periodical parameter
		local i;
		Periodical, i = utilities.strip_apostrophe_markup (Periodical);			-- strip apostrophe markup so that metadata isn't contaminated 
		if i then																-- non-zero when markup was stripped so emit an error message
			utilities.set_message ('err_apostrophe_markup', {Periodical_origin});
		end
	end

	if 'mailinglist' == config.CitationClass then								-- special case for {{cite mailing list}}
		if utilities.is_set (Periodical) and utilities.is_set (A ['MailingList']) then	-- both set emit an error TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', Periodical_origin) .. ' and ' .. utilities.wrap_style ('parameter', 'mailinglist')});
		end

		Periodical = A ['MailingList'];											-- error or no, set Periodical to |mailinglist= value because this template is {{cite mailing list}}
		Periodical_origin = A:ORIGIN('MailingList');
	end

	local ScriptPeriodical = A['ScriptPeriodical'];

	-- web and news not tested for now because of 
	-- Wikipedia:Administrators%27_noticeboard#Is_there_a_semi-automated_tool_that_could_fix_these_annoying_&quot;Cite_Web&quot;_errors?
	if not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) then	-- 'periodical' templates require periodical parameter
	--	local p = {['journal'] = 'journal', ['magazine'] = 'magazine', ['news'] = 'newspaper', ['web'] = 'website'};	-- for error message
		local p = {['journal'] = 'journal', ['magazine'] = 'magazine'};			-- for error message
		if p[config.CitationClass]  then
			utilities.set_message ('err_missing_periodical', {config.CitationClass, p[config.CitationClass]});
		end
	end
	
	local Volume;
	local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) then
			if not utilities.in_array (Periodical_origin, {'website', 'mailinglist'}) then	-- {{citation}} does not render volume for these 'periodicals' --TODO: move 'array' to ~/Configuration
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		elseif utilities.is_set (ScriptPeriodical) then
			if 'script-website' ~= ScriptPeriodical_origin then					-- {{citation}} does not render volume for |script-website=
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		else
			Volume = A['Volume'];												-- and does for non-'periodical' cites
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_volume) then	-- render |volume= for cs1 according to the configuration settings
		Volume = A['Volume'];
	end	
	extra_text_in_vol_iss_check (Volume, A:ORIGIN ('Volume'), 'v');	

	local Issue;
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) and utilities.in_array (Periodical_origin, {'journal', 'magazine', 'newspaper', 'periodical', 'work'}) or	-- {{citation}} renders issue for these 'periodicals'--TODO: move 'array' to ~/Configuration
			utilities.is_set (ScriptPeriodical) and utilities.in_array (ScriptPeriodical_origin, {'script-journal', 'script-magazine', 'script-newspaper', 'script-periodical', 'script-work'}) then -- and these 'script-periodicals'
				Issue = utilities.hyphen_to_dash (A['Issue']);
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_issue) then	-- conference &amp; map books do not support issue; {{citation}} listed here because included in settings table
		if not (utilities.in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical))) then
			Issue = utilities.hyphen_to_dash (A['Issue']);
		end
	end
	extra_text_in_vol_iss_check (Issue, A:ORIGIN ('Issue'), 'i');	

	local Page;
	local Pages;
	local At;
	if not utilities.in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = utilities.hyphen_to_dash (A['Pages']);	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = place_check (A['PublicationPlace'], A:ORIGIN('PublicationPlace'));
	local Place = place_check (A['Place'], A:ORIGIN('Place'));
	
	local PublisherName = A['PublisherName'];
	local PublisherName_origin = A:ORIGIN('PublisherName');
	if utilities.is_set (PublisherName) then
		local i = 0;
		PublisherName, i = utilities.strip_apostrophe_markup (PublisherName);	-- strip apostrophe markup so that metadata isn't contaminated; publisher is never italicized
		if i then																-- non-zero when markup was stripped so emit an error message
			utilities.set_message ('err_apostrophe_markup', {PublisherName_origin});
		end
	end

	local Newsgroup = A['Newsgroup'];											-- TODO: strip apostrophe markup?
	local Newsgroup_origin = A:ORIGIN('Newsgroup');	

	if 'newsgroup' == config.CitationClass then
		if utilities.is_set (PublisherName) then								-- general use parameter |publisher= not allowed in cite newsgroup
			utilities.set_message ('err_parameter_ignored', {PublisherName_origin});
		end

		PublisherName = nil;													-- ensure that this parameter is unset for the time being; will be used again after COinS
	end

	local URL = A['URL'];														-- TODO: better way to do this for URL, ChapterURL, and MapURL?
	local UrlAccess = is_valid_parameter_value (A['UrlAccess'], A:ORIGIN('UrlAccess'), cfg.keywords_lists['url-access'], nil);
	
	if not utilities.is_set (URL) and utilities.is_set (UrlAccess) then
		UrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', 'url');
	end
	
	local ChapterURL = A['ChapterURL'];
	local ChapterUrlAccess = is_valid_parameter_value (A['ChapterUrlAccess'], A:ORIGIN('ChapterUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (ChapterURL) and utilities.is_set (ChapterUrlAccess) then
		ChapterUrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', {A:ORIGIN('ChapterUrlAccess'):gsub ('%-access', '')});
	end

	local MapUrlAccess = is_valid_parameter_value (A['MapUrlAccess'], A:ORIGIN('MapUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (A['MapURL']) and utilities.is_set (MapUrlAccess) then
		MapUrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', {'map-url'});
	end

	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local no_tracking_cats = is_valid_parameter_value (A['NoTracking'], A:ORIGIN('NoTracking'), cfg.keywords_lists['yes_true_y'], nil);

	-- check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not utilities.is_set (no_tracking_cats) then								-- ignore if we are already not going to categorize this page
		if utilities.in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _, v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end
																				-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	utilities.select_one (args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'err_redundant_parameters');	-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, A:ORIGIN('Page'), Pages, A:ORIGIN('Pages'), At);

	local NoPP = is_valid_parameter_value (A['NoPP'], A:ORIGIN('NoPP'), cfg.keywords_lists['yes_true_y'], nil);

	if utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- both |publication-place= and |place= (|location=) allowed if different
		utilities.add_prop_cat ('location-test');								-- add property cat to evaluate how often PublicationPlace and Place are used together
		if PublicationPlace == Place then
			Place = '';															-- unset; don't need both if they are the same
		end
	elseif not utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- when only |place= (|location=) is set ...
		PublicationPlace = Place;												-- promote |place= (|location=) to |publication-place
	end

	if PublicationPlace == Place then Place = ''; end							-- don't need both if they are the same
	
	local URL_origin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL_origin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ScriptChapter = A['ScriptChapter'];
	local ScriptChapter_origin = A:ORIGIN ('ScriptChapter');
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local TransChapter = A['TransChapter'];
	local TransChapter_origin = A:ORIGIN ('TransChapter');
	local TransTitle = A['TransTitle'];
	local ScriptTitle = A['ScriptTitle'];
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia= and |title= then map |title= to |article= and |encyclopedia= to |title=
		|encyclopedia= and |article= then map |encyclopedia= to |title=

		|trans-title= maps to |trans-chapter= when |title= is re-mapped
		|url= maps to |chapter-url= when |title= is remapped
	
	All other combinations of |encyclopedia=, |title=, and |article= are not modified
	
	]]

	local Encyclopedia = A['Encyclopedia'];										-- used as a flag by this module and by ~/COinS

	if utilities.is_set (Encyclopedia) then										-- emit error message when Encyclopedia set but template is other than {{cite encyclopedia}} or {{citation}}
		if 'encyclopaedia' ~= config.CitationClass and 'citation' ~= config.CitationClass then
			utilities.set_message ('err_parameter_ignored', {A:ORIGIN ('Encyclopedia')});
			Encyclopedia = nil;													-- unset because not supported by this template
		end
	end

	if ('encyclopaedia' == config.CitationClass) or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Periodical) and utilities.is_set (Encyclopedia) then	-- when both set emit an error TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', A:ORIGIN ('Encyclopedia')) .. ' and ' .. utilities.wrap_style ('parameter', Periodical_origin)});
		end

		if utilities.is_set (Encyclopedia) then
			Periodical = Encyclopedia;											-- error or no, set Periodical to Encyclopedia; allow periodical without encyclopedia
			Periodical_origin = A:ORIGIN ('Encyclopedia');
		end

		if utilities.is_set (Periodical) then									-- Periodical is set when |encyclopedia= is set
			if utilities.is_set (Title) or utilities.is_set (ScriptTitle) then
				if not utilities.is_set (Chapter) then
					Chapter = Title;											-- |encyclopedia= and |title= are set so map |title= to |article= and |encyclopedia= to |title=
					ScriptChapter = ScriptTitle;
					ScriptChapter_origin = A:ORIGIN('ScriptTitle')
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterURL_origin = URL_origin;

					ChapterUrlAccess = UrlAccess;

					if not utilities.is_set (ChapterURL) and utilities.is_set (TitleLink) then
						Chapter = utilities.make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			elseif utilities.is_set (Chapter) or utilities.is_set (ScriptChapter) then								-- |title= not set
				Title = Periodical;												-- |encyclopedia= set and |article= set so map |encyclopedia= to |title=
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- special case for cite techreport.
	local ID = A['ID'];
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if utilities.is_set (A['Number']) then									-- cite techreport uses 'number', which other citations alias to 'issue'
			if not utilities.is_set (ID) then									-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'id') .. ' and ' .. utilities.wrap_style ('parameter', 'number')});
			end
		end	
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	local ChapterLink -- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local Conference = A['Conference'];
	local BookTitle = A['BookTitle'];
	local TransTitle_origin = A:ORIGIN ('TransTitle');
	if 'conference' == config.CitationClass then
		if utilities.is_set (BookTitle) then
			Chapter = Title;
			Chapter_origin = 'title';
	--		ChapterLink = TitleLink;											-- |chapter-link= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			URL_origin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			TransChapter_origin = TransTitle_origin;
			Title = BookTitle;
			Format = '';
	--		TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end
	
	-- CS1/2 mode
	local Mode = is_valid_parameter_value (A['Mode'], A:ORIGIN('Mode'), cfg.keywords_lists['mode'], '');
	-- separator character and postscript
	local sepc, PostScript = set_style (Mode:lower(), A['PostScript'], config.CitationClass);
	-- controls capitalization of certain static text
	local use_lowercase = ( sepc == ',' );
	
	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		if utilities.is_set (Chapter) then										--TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'map') .. ' and ' .. utilities.wrap_style ('parameter', Chapter_origin)});	-- add error message
		end
		Chapter = A['Map'];
		Chapter_origin = A:ORIGIN('Map');
		ChapterURL = A['MapURL'];
		ChapterURL_origin = A:ORIGIN('MapURL');
		TransChapter = A['TransMap'];
		ScriptChapter = A['ScriptMap']
		ScriptChapter_origin = A:ORIGIN('ScriptMap')

		ChapterUrlAccess = MapUrlAccess;
		ChapterFormat = A['MapFormat'];

		Cartography = A['Cartography'];
		if utilities.is_set ( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if utilities.is_set ( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	local Series = A['Series'];
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local SeriesLink = A['SeriesLink'];

		SeriesLink = link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wiki-markup in |series-link= or wiki-markup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if utilities.is_set (Network) then table.insert(n, Network); end
		if utilities.is_set (Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if utilities.is_set (Season) and utilities.is_set (SeriesNumber) then	-- these are mutually exclusive so if both are set TODO: make a function for this and similar?
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'season') .. ' and ' .. utilities.wrap_style ('parameter', 'seriesno')});		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if utilities.is_set (Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if utilities.is_set (SeriesNumber) then table.insert(s, wrap_msg ('seriesnum', SeriesNumber, use_lowercase)); end
			if utilities.is_set (Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ScriptChapter_origin = A:ORIGIN('ScriptTitle');
			ChapterLink = TitleLink;											-- alias |episode-link=
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if utilities.is_set (ChapterLink) and not utilities.is_set (ChapterURL) then	-- link but not URL
				Chapter = utilities.make_wikilink (ChapterLink, Chapter);
			elseif utilities.is_set (ChapterLink) and utilities.is_set (ChapterURL) then	-- if both are set, URL links episode;
				Series = utilities.make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if utilities.is_set (Series) and utilities.is_set (SeriesLink) then
				Series = utilities.make_wikilink (SeriesLink, Series);
			end
			Series = utilities.wrap_style ('italic-title', Series);				-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- handle type parameter for those CS1 citations that have default values
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	if utilities.in_array (config.CitationClass, {'AV-media-notes', 'interview', 'mailinglist', 'map', 'podcast', 'pressrelease', 'report', 'speech', 'techreport', 'thesis'}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if utilities.is_set (Degree) and &quot;Thesis&quot; == TitleType then				-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if utilities.is_set (TitleType) then										-- if type parameter is specified
		TitleType = utilities.substitute ( cfg.messages['type'], TitleType);	-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
	local Date = A['Date'];
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging
	local PublicationDate = A['PublicationDate'];
	local Year = A['Year'];

	if not utilities.is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not utilities.is_set (Date) and utilities.is_set (PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]

	local DF = is_valid_parameter_value (A['DF'], A:ORIGIN('DF'), cfg.keywords_lists['df'], '');
	if not utilities.is_set (DF) then
		DF = cfg.global_df;														-- local |df= if present overrides global df set by {{use xxx date}} template
	end

	local ArchiveURL;
	local ArchiveDate;
	local ArchiveFormat = A['ArchiveFormat'];

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	
	ArchiveURL, ArchiveDate = is_unique_archive_url (ArchiveURL, URL, ChapterURL, A:ORIGIN('ArchiveURL'), ArchiveDate);		-- add error message when URL or ChapterURL == ArchiveURL

	
	local AccessDate = A['AccessDate'];
	local LayDate = A['LayDate'];
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification
	local DoiBroken = A['DoiBroken'];
	local Embargo = A['Embargo'];
	local anchor_year;															-- used in the CITEREF identifier
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val = AccessDate, name = A:ORIGIN ('AccessDate')},
			['archive-date'] = {val = ArchiveDate, name = A:ORIGIN ('ArchiveDate')},
			['date'] = {val = Date, name = Date_origin},
			['doi-broken-date'] = {val = DoiBroken, name = A:ORIGIN ('DoiBroken')},
			['pmc-embargo-date'] = {val = Embargo, name = A:ORIGIN ('Embargo')},
			['lay-date'] = {val = LayDate, name = A:ORIGIN ('LayDate')},
			['publication-date'] = {val = PublicationDate, name = A:ORIGIN ('PublicationDate')},
			['year'] = {val = Year, name = A:ORIGIN ('Year')},
			};

		local error_list = {};
		anchor_year, Embargo = validation.dates(date_parameters_list, COinS_date, error_list);

-- start temporary Julian / Gregorian calendar uncertainty categorization
		if COinS_date.inter_cal_cat then
			utilities.add_prop_cat ('jul-greg-uncertainty');
		end
-- end temporary Julian / Gregorian calendar uncertainty categorization

		if utilities.is_set (Year) and utilities.is_set (Date) then				-- both |date= and |year= not normally needed; 
			validation.year_date_check (Year, A:ORIGIN ('Year'), Date, A:ORIGIN ('Date'), error_list);
		end
		
		if 0 == #error_list then												-- error free dates only; 0 when error_list is empty
			local modified = false;												-- flag
			
			if utilities.is_set (DF) then										-- if we need to reformat dates
				modified = validation.reformat_dates (date_parameters_list, DF);	-- reformat to DF format, use long month names if appropriate
			end

			if true == validation.date_hyphen_to_dash (date_parameters_list) then	-- convert hyphens to dashes where appropriate
				modified = true;
				utilities.set_message ('maint_date_format');					-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language; not supported at en.wiki
			if cfg.date_name_auto_xlate_enable and validation.date_name_xlate (date_parameters_list, cfg.date_digit_auto_xlate_enable ) then
				utilities.set_message ('maint_date_auto_xlated');				-- add maint cat
				modified = true;
			end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				LayDate = date_parameters_list['lay-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end
		else
			utilities.set_message ('err_bad_date', {utilities.make_sep_list (#error_list, error_list)});	-- add this error message
		end
	end	-- end of do

	local ID_list = {};															-- sequence table of rendered identifiers
	local ID_list_coins = {};													-- table of identifiers and their values from args; key is same as cfg.id_handlers's key
	local Class = A['Class'];													-- arxiv class identifier
	
	local ID_support = {
		{A['ASINTLD'], 'ASIN', 'err_asintld_missing_asin', A:ORIGIN ('ASINTLD')},				
		{DoiBroken, 'DOI', 'err_doibroken_missing_doi', A:ORIGIN ('DoiBroken')},
		{Embargo, 'PMC', 'err_embargo_missing_pmc', A:ORIGIN ('Embargo')},
		}

	ID_list, ID_list_coins = identifiers.identifier_lists_get (args, {DoiBroken = DoiBroken, ASINTLD = A['ASINTLD'], Embargo = Embargo, Class = Class}, ID_support);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite ssrn}}, before generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then
		if not utilities.is_set (ID_list_coins[config.CitationClass:upper()]) then 	-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp; |citeseerx= required for their templates
			utilities.set_message ('err_' .. config.CitationClass .. '_missing');	-- add error message
		end

		Periodical = ({['arxiv'] = 'arXiv', ['biorxiv'] = 'bioRxiv', ['citeseerx'] = 'CiteSeerX', ['ssrn'] = 'Social Science Research Network'})[config.CitationClass];
	end

	-- Link the title of the work if no |url= was provided, but we have a |pmc= or a |doi= with |doi-access=free

	if config.CitationClass == &quot;journal&quot; and not utilities.is_set (URL) and not utilities.is_set (TitleLink) and not utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) then -- TODO: remove 'none' once existing citations have been switched to 'off', so 'none' can be used as token for &quot;no title&quot; instead
		if 'none' ~= cfg.keywords_xlate[auto_select] then						-- if auto-linking not disabled
 	 		if identifiers.auto_link_urls[auto_select] then						-- manual selection
		 		URL = identifiers.auto_link_urls[auto_select];					-- set URL to be the same as identifier's external link
 				URL_origin = cfg.id_handlers[auto_select:upper()].parameters[1];	-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['pmc'] then						-- auto-select PMC
				URL = identifiers.auto_link_urls['pmc'];						-- set URL to be the same as the PMC external link if not embargoed
				URL_origin = cfg.id_handlers['PMC'].parameters[1];				-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['doi'] then						-- auto-select DOI
				URL = identifiers.auto_link_urls['doi'];
				URL_origin = cfg.id_handlers['DOI'].parameters[1];
			end
 	 	end

		if utilities.is_set (URL) and utilities.is_set (AccessDate) then		-- access date requires |url=; identifier-created URL is not |url=
			utilities.set_message ('err_accessdate_missing_url');				-- add an error message
			AccessDate = '';													-- unset
		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not utilities.is_set (Title) and not utilities.is_set (TransTitle) and not utilities.is_set (ScriptTitle) then	-- has special case for cite episode
		utilities.set_message ('err_citation_missing_title', {'episode' == config.CitationClass and 'series' or 'title'});
	end

	if utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) and
			utilities.in_array (config.CitationClass, {'journal', 'citation'}) and
			(utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and
			('journal' == Periodical_origin or 'script-journal' == ScriptPeriodical_origin) then	-- special case for journal cites
				Title = '';														-- set title to empty string
				utilities.set_message ('maint_untitled');						-- add maint cat
	end

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Chapter) and utilities.is_set (Title) and utilities.is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end
	
	local QuotePage = A['QuotePage'];
	local QuotePages = utilities.hyphen_to_dash (A['QuotePages']);

	-- this is the function call to COinS()
	local OCinSoutput = metadata.COinS({
		['Periodical'] = utilities.strip_apostrophe_markup (Periodical),		-- no markup in the metadata
		['Encyclopedia'] = Encyclopedia,										-- just a flag; content ignored by ~/COinS
		['Chapter'] = metadata.make_coins_title (coins_chapter, ScriptChapter),	-- Chapter and ScriptChapter stripped of bold / italic / accept-as-written markup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = metadata.make_coins_title (coins_title, ScriptTitle),		-- Title and ScriptTitle stripped of bold / italic / accept-as-written markup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Quarter'] = COinS_date.rftquarter,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = coins_pages or metadata.get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At, QuotePage, QuotePages}, 7)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName or Newsgroup,							-- any apostrophe markup already removed from PublisherName
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list_coins,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, and {{cite ssrn}} AFTER generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, CiteSeerX, or ssrn now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass and utilities.is_set (Newsgroup) then
		PublisherName = utilities.substitute (cfg.messages['newsgroup'], external_link( 'news:' .. Newsgroup, Newsgroup, Newsgroup_origin, nil ));
	end

	local Editors;
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	local Contributors;															-- assembled contributors name list
	local contributor_etal;
	local Translators;															-- assembled translators name list
	local translator_etal;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	local Interviewers;															
	local interviewers_list = {};					
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters
	local interviewer_etal;
	
	-- Now perform various field 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.
	do
		local last_first_list;
		local control = { 
			format = NameListStyle,												-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_names (A['DisplayEditors'], #e, 'editors', editor_etal, A:ORIGIN ('DisplayEditors'));
			Editors, EditorCount = list_people (control, e, editor_etal);

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum, interviewer_etal = get_display_names (A['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal, A:ORIGIN ('DisplayInterviewers'));
			Interviewers = list_people (control, interviewers_list, interviewer_etal);
		end
		do																		-- now do translators
			control.maximum, translator_etal = get_display_names (A['DisplayTranslators'], #t, 'translators', translator_etal, A:ORIGIN ('DisplayTranslators'));
			Translators = list_people (control, t, translator_etal);
		end
		do																		-- now do contributors
			control.maximum, contributor_etal = get_display_names (A['DisplayContributors'], #c, 'contributors', contributor_etal, A:ORIGIN ('DisplayContributors'));
			Contributors = list_people (control, c, contributor_etal);
		end
		do																		-- now do authors
			control.maximum, author_etal = get_display_names (A['DisplayAuthors'], #a, 'authors', author_etal, A:ORIGIN ('DisplayAuthors'));

			last_first_list = list_people (control, a, author_etal);

			if utilities.is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors');	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if utilities.is_set (Authors) and utilities.is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not utilities.is_set (URL) then
		if utilities.in_array (config.CitationClass, {&quot;web&quot;, &quot;podcast&quot;, &quot;mailinglist&quot;}) or		-- |url= required for cite web, cite podcast, and cite mailinglist
			('citation' == config.CitationClass and ('website' == Periodical_origin or 'script-website' == ScriptPeriodical_origin)) then	-- and required for {{citation}} with |website= or |script-website=
				utilities.set_message ('err_cite_web_url');
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if utilities.is_set (AccessDate) and not utilities.is_set (ChapterURL) then		-- ChapterURL may be set when URL is not set;
			utilities.set_message ('err_accessdate_missing_url');
			AccessDate = '';
		end
	end

	local UrlStatus = is_valid_parameter_value (A['UrlStatus'], A:ORIGIN('UrlStatus'), cfg.keywords_lists['url-status'], '');
	local OriginalURL
	local OriginalURL_origin
	local OriginalFormat
	local OriginalAccess;
	UrlStatus = UrlStatus:lower();												-- used later when assembling archived text
	if utilities.is_set ( ArchiveURL ) then
		if utilities.is_set (ChapterURL) then 									-- if chapter-url= is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURL_origin = ChapterURL_origin;								-- name of |chapter-url= parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=

			if 'live' ~= UrlStatus then
				ChapterURL = ArchiveURL											-- swap-in the archive's URL
				ChapterURL_origin = A:ORIGIN('ArchiveURL')						-- name of |archive-url= parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived URLs
			end
		elseif utilities.is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURL_origin = URL_origin;									-- name of URL parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;

			if 'live' ~= UrlStatus then											-- if URL set then |archive-url= applies to it
				URL = ArchiveURL												-- swap-in the archive's URL
				URL_origin = A:ORIGIN('ArchiveURL')								-- name of archive URL parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived URLs
			end
		end
	elseif utilities.is_set (UrlStatus) then									-- if |url-status= is set when |archive-url= is not set
 		utilities.set_message ('maint_url_status');								-- add maint cat
	end

	if utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) then
			local chap_param;
			if utilities.is_set (Chapter) then									-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif utilities.is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif utilities.is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif utilities.is_set (ScriptChapter) then
				chap_param = ScriptChapter_origin;
			else utilities.is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if utilities.is_set (chap_param) then								-- if we found one
				utilities.set_message ('err_chapter_ignored', {chap_param});	-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if utilities.is_set (Contribution) and 0 &lt; #c then						-- if this is a contribution with contributor(s)
			if utilities.in_array (Contribution:lower(), cfg.keywords_lists.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, ScriptChapter_origin, Chapter, Chapter_origin, TransChapter, TransChapter_origin, ChapterURL, ChapterURL_origin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if utilities.is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and utilities.is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter .. sepc .. ' ';
		elseif utilities.is_set (ChapterFormat) then							-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title
	local plain_title = false;
	local accept_title;
	Title, accept_title = utilities.has_accept_as_written (Title, true);		-- remove accept-this-as-written markup when it wraps all of &lt;Title&gt;
	if accept_title and ('' == Title) then										-- only support forced empty for now &quot;(())&quot;
		Title = cfg.messages['notitle'];										-- replace by predefined &quot;No title&quot; message
			-- TODO: utilities.set_message ( 'err_redundant_parameters', ...);	-- issue proper error message instead of muting	 
			ScriptTitle = '';													-- just mute for now	 
			TransTitle = '';													-- just mute for now
 		plain_title = true;														-- suppress text decoration for descriptive title
		utilities.set_message ('maint_untitled');								-- add maint cat
	end

	if not accept_title then													-- &lt;Title&gt; not wrapped in accept-as-written markup
		if '...' == Title:sub (-3) then											-- if ellipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%' .. sepc .. '$', '');			-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end

		if utilities.is_set (ArchiveURL) and is_archived_copy (Title) then
			utilities.set_message ('maint_archived_copy');						-- add maintenance category before we modify the content of Title
		end

		if is_generic ('generic_titles', Title) then
			utilities.set_message ('err_generic_title');						-- set an error message
		end
	end

	if (not plain_title) and (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) or
		('map' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)))) then		-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from module provided quote marks
			Title = utilities.wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle, 'script-title');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
			TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );
	elseif plain_title or ('report' == config.CitationClass) then				-- no styling for cite report and descriptive titles (otherwise same as above)
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );	-- for cite report, use this form for trans-title
	else
		Title = utilities.wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-italic-title', TransTitle);
	end

	if utilities.is_set (TransTitle) then
		if utilities.is_set (Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			utilities.set_message ('err_trans_missing_title', {'title'});
		end
	end

	if utilities.is_set (Title) then											-- TODO: is this the right place to be making Wikisource URLs?
		if utilities.is_set (TitleLink) and utilities.is_set (URL) then
			utilities.set_message ('err_wikilink_in_url');						-- set an error message because we can't have both
			TitleLink = '';														-- unset
		end
	
		if not utilities.is_set (TitleLink) and utilities.is_set (URL) then
			Title = external_link (URL, Title, URL_origin, UrlAccess) .. TransTitle .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif utilities.is_set (TitleLink) and not utilities.is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle;
			else
				Title = utilities.make_wikilink (TitleLink, Title) .. TransTitle;
			end
		else
			local ws_url, ws_label, L;											-- Title has italic or quote markup by the time we get here which causes is_wikilink() to return 0 (not a wikilink)
			ws_url, ws_label, L = wikisource_url_make (Title:gsub('^[\'&quot;]*(.-)[\'&quot;]*$', '%1'));	-- make ws URL from |title= interwiki link (strip italic or quote markup); link portion L becomes tooltip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle;
			else
				Title = Title .. TransTitle;
			end
		end
	else
		Title = TransTitle;
	end

	if utilities.is_set (Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	local ConferenceURL_origin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	if utilities.is_set (Conference) then
		if utilities.is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURL_origin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif utilities.is_set (ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURL_origin, nil );
	end

	local Position = '';
	if not utilities.is_set (Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if utilities.is_set (Minutes) then
			if utilities.is_set (Time) then		--TODO: make a function for this and similar?
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'minutes') .. ' and ' .. utilities.wrap_style ('parameter', 'time')});
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if utilities.is_set (Time) then
				local TimeCaption = A['TimeCaption']
				if not utilities.is_set (TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = utilities.is_set (At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = utilities.is_set (Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Sections = A['Sections'];											-- Section (singular) is an alias of Chapter so set earlier
		local Inset = A['Inset'];
		
		if utilities.is_set ( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if utilities.is_set ( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif utilities.is_set ( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	local Others = A['Others'];
	if utilities.is_set (Others) and 0 == #a and 0 == #e then					-- add maint cat when |others= has value and used without |author=, |editor=
		if config.CitationClass == &quot;AV-media-notes&quot;
		or config.CitationClass == &quot;audio-visual&quot; then							-- special maint for AV/M which has a lot of 'false' positives right now
			utilities.set_message ('maint_others_avm')
		else
			utilities.set_message ('maint_others');
		end
	end
	Others = utilities.is_set (Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if utilities.is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if utilities.is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	local TitleNote = A['TitleNote'];
	TitleNote = utilities.is_set (TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if utilities.is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%n?%.?$') or Edition:match ('%f[%a][Ee]dition$') then -- Ed, ed, Ed., ed., Edn, edn, Edn., edn.
			utilities.set_message ('err_extra_text_edition');					 -- add error message
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = utilities.is_set (Series) and wrap_msg ('series', {sepc, Series}) or &quot;&quot;;	-- not the same as SeriesNum
	local Agency = A['Agency'];
	Agency = utilities.is_set (Agency) and wrap_msg ('agency', {sepc, Agency}) or &quot;&quot;;
	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	if utilities.is_set (AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = utilities.substitute (retrv_text, AccessDate);				-- add retrieved text

		AccessDate = utilities.substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if utilities.is_set (ID) then ID = sepc .. &quot; &quot; .. ID; end
	
	local Docket = A['Docket'];
   	if &quot;thesis&quot; == config.CitationClass and utilities.is_set (Docket) then
		ID = sepc .. &quot; Docket &quot; .. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and utilities.is_set (Docket) then		-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	if utilities.is_set (URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URL_origin, UrlAccess );
	end

	local Quote = A['Quote'];
	local TransQuote = A['TransQuote'];
	local ScriptQuote = A['ScriptQuote'];
	if utilities.is_set (Quote) or utilities.is_set (TransQuote) or utilities.is_set (ScriptQuote) then

		if utilities.is_set (Quote) then
			if Quote:sub(1, 1) == '&quot;' and Quote:sub(-1, -1) == '&quot;' then			-- if first and last characters of quote are quote marks
				Quote = Quote:sub(2, -2);										-- strip them off
			end
		end

		Quote = utilities.wrap_style ('quoted-text', Quote );					-- wrap in &lt;q&gt;...&lt;/q&gt; tags
	
		if utilities.is_set (ScriptQuote) then
			Quote = script_concatenate (Quote, ScriptQuote, 'script-quote');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after quote is wrapped
		end

		if utilities.is_set (TransQuote) then
			if TransQuote:sub(1, 1) == '&quot;' and TransQuote:sub(-1, -1) == '&quot;' then -- if first and last characters of |trans-quote are quote marks
				TransQuote = TransQuote:sub(2, -2); -- strip them off
			end
			Quote = Quote .. &quot; &quot; .. utilities.wrap_style ('trans-quoted-title', TransQuote );
		end

		if utilities.is_set (QuotePage) or utilities.is_set (QuotePages) then	-- add page prefix
			local quote_prefix = '';
			if utilities.is_set (QuotePage) then
				extra_text_in_page_check (QuotePage, 'quote-page');				-- add to maint cat if |quote-page= value begins with what looks like p., pp., etc.
				if not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePage}), '', '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePage}), '', '', '';
				end
			elseif utilities.is_set (QuotePages) then
				extra_text_in_page_check (QuotePages, 'quote-pages');			-- add to maint cat if |quote-pages= value begins with what looks like p., pp., etc.
				if tonumber(QuotePages) ~= nil and not NoPP then				-- if only digits, assume single page
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePages}), '', '';
				elseif not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['pp-prefix'], {sepc, QuotePages}), '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePages}), '', '';
				end
			end
                        
			Quote = quote_prefix .. &quot;: &quot; .. Quote;
		else
			Quote = sepc .. &quot; &quot; .. Quote;
		end

		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	-- We check length of PostScript here because it will have been nuked by
	-- the quote parameters. We'd otherwise emit a message even if there wasn't
	-- a displayed postscript.
	-- TODO: Should the max size (1) be configurable?
	-- TODO: Should we check a specific pattern?
	if utilities.is_set(PostScript) and mw.ustring.len(PostScript) &gt; 1 then
		utilities.set_message ('maint_postscript')
	end
	
	local Archived;
	if utilities.is_set (ArchiveURL) then
		local arch_text;
		if not utilities.is_set (ArchiveDate) then
			utilities.set_message ('err_archive_missing_date');
			ArchiveDate = '';													-- empty string for concatenation
		end
		if &quot;live&quot; == UrlStatus then
			arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if utilities.is_set (ArchiveDate) then
				Archived = sepc .. ' ' .. utilities.substitute ( cfg.messages['archived-live'],
					{external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil) .. ArchiveFormat, ArchiveDate } );
			else
				Archived = '';
			end
			if not utilities.is_set (OriginalURL) then
				utilities.set_message ('err_archive_missing_url');
				Archived = '';													-- empty string for concatenation
			end
		elseif utilities.is_set (OriginalURL) then								-- UrlStatus is empty, 'dead', 'unfit', 'usurped', 'bot: unknown'
			if utilities.in_array (UrlStatus, {'unfit', 'usurped', 'bot: unknown'}) then
				arch_text = cfg.messages['archived-unfit'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. ' ' .. arch_text .. ArchiveDate;				-- format already styled
				if 'bot: unknown' == UrlStatus then
					utilities.set_message ('maint_bot_unknown');				-- and add a category if not already added
				else
					utilities.set_message ('maint_unfit');						-- and add a category if not already added
				end
			else																-- UrlStatus is empty, 'dead'
				arch_text = cfg.messages['archived-dead'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				if utilities.is_set (ArchiveDate) then
					Archived = sepc .. &quot; &quot; .. utilities.substitute ( arch_text,
						{ external_link( OriginalURL, cfg.messages['original'], OriginalURL_origin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
				else
					Archived = '';												-- unset for concatenation
				end
			end	
		else																	-- OriginalUrl not set
			arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			utilities.set_message ('err_archive_missing_url');
			Archived = '';														-- empty string for concatenation
		end
	elseif utilities.is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = '';
	end
	
	local Lay = '';
	local LaySource = A['LaySource'];
	local LayURL = A['LayURL'];
	local LayFormat = A['LayFormat'];
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	if utilities.is_set (LayURL) then
		if utilities.is_set (LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if utilities.is_set (LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. utilities.safe_for_italics (LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif utilities.is_set (LayFormat) then									-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	local TranscriptURL = A['TranscriptURL']
	local TranscriptFormat = A['TranscriptFormat'];
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');
	local Transcript = A['Transcript'];
	local TranscriptURL_origin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL
	if utilities.is_set (Transcript) then
		if utilities.is_set (TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURL_origin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif utilities.is_set (TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURL_origin, nil );
	end

	local Publisher;
	if utilities.is_set (PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if utilities.is_set (PublisherName) then
		if utilities.is_set (PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif utilities.is_set (PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	local TransPeriodical =  A['TransPeriodical'];
	local TransPeriodical_origin =  A:ORIGIN ('TransPeriodical');
	-- Several of the above rely upon detecting this as nil, so do it last.
	if (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical)) then
		if utilities.is_set (Title) or utilities.is_set (TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		else 
			Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		end
	end
	
	local Language = A['Language'];
	if utilities.is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc.
	else
		Language='';															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then									-- cite speech only
		TitleNote = TitleType;													-- move TitleType to TitleNote so that it renders ahead of |event=
		TitleType = '';															-- and unset

		if utilities.is_set (Periodical) then									-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if utilities.is_set (Conference) then								-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;							-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
		if utilities.is_set (Others) then Others = safe_join ({Others, sepc .. &quot; &quot;}, sepc) end		-- add terminal punctuation &amp; space; check for dup sepc; TODO why do we need to do this here?
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (Periodical) then		-- special cases for book cites
		if utilities.is_set (Contributors) then									-- when we are citing foreword, preface, introduction, etc.
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if utilities.is_set (Chapter) then										-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif utilities.is_set (Periodical) then								-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local Via = A['Via'];
	Via = utilities.is_set (Via) and  wrap_msg ('via', Via) or '';
	local idcommon;
	if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then	-- special case for cite AV media &amp; cite episode position transcript
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, Lay, Quote }, sepc );
	else
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, Lay, Quote }, sepc );
	end
	
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	local OrigDate = A['OrigDate'];
	OrigDate = utilities.is_set (OrigDate) and wrap_msg ('origdate', OrigDate) or '';
	if utilities.is_set (Date) then
		if utilities.is_set (Authors) or utilities.is_set (Editors) then		-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date .. &quot;)&quot; .. OrigDate .. sepc .. &quot; &quot;;				-- in parentheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon, -1, -1) == sepc) then						-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigDate;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigDate;							-- Date begins with sepc
			end
		end
	end	
	if utilities.is_set (Authors) then
		if (not utilities.is_set (Date)) then									-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if utilities.is_set (Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then
					in_text = in_text:lower()									-- lowercase for cs2
				end
			end
			if EditorCount &lt;= 1 then
				post_text = &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot;;				-- be consistent with no-author, no-date case
			else
				post_text = &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot;;
			end
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Contributors) then									-- book cite and we're citing the intro, preface, etc.
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if utilities.is_set (Editors) and utilities.is_set (Date) then		-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not utilities.is_set (Date)) then								-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif utilities.is_set (Editors) then
		if utilities.is_set (Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if utilities.is_set (PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc ); 								-- Deals with italics, spaces, etc.
		text = text:sub(1, -sepc:len() - 1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite&gt; element
	local options_t = {};
	options_t.class = cite_class_attribute_make (config.CitationClass, Mode);

	local Ref = is_valid_parameter_value (A['Ref'], A:ORIGIN('Ref'), cfg.keywords_lists['ref'], nil, true);	-- nil when |ref=harv; A['Ref'] else

	if 'none' ~= cfg.keywords_xlate[(Ref and Ref:lower()) or ''] then
		local namelist_t = {};													-- holds selected contributor, author, editor name list
		local year = first_set ({Year, anchor_year}, 2);						-- Year first for legacy citations and for YMD dates that require disambiguation

		if #c &gt; 0 then															-- if there is a contributor list
			namelist_t = c;														-- select it
		elseif #a &gt; 0 then														-- or an author list
			namelist_t = a;
		elseif #e &gt; 0 then														-- or an editor list
			namelist_t = e;
		end
		local citeref_id;
		if #namelist_t &gt; 0 then													-- if there are names in namelist_t
			citeref_id = make_citeref_id (namelist_t, year);					-- go make the CITEREF anchor
			if mw.uri.anchorEncode (citeref_id) == ((Ref and mw.uri.anchorEncode (Ref)) or '') then	-- Ref may already be encoded (by {{sfnref}}) so citeref_id must be encoded before comparison
				utilities.set_message ('maint_ref_duplicates_default');
			end
		else
			citeref_id = '';													-- unset
		end
		options_t.id = Ref or citeref_id;
	end

	if string.len (text:gsub('%b&lt;&gt;', '')) &lt;= 2 then								-- remove html and html-like tags; then get length of what remains; 
		z.error_cats_t = {};													-- blank the categories list
		z.error_msgs_t = {};													-- blank the error messages list
		OCinSoutput = nil;														-- blank the metadata string
		text = '';																-- blank the the citation
		utilities.set_message ('err_empty_citation');							-- set empty citation message and category
	end
	
	local render_t = {};														-- here we collect the final bits for concatenation into the rendered citation

	if utilities.is_set (options_t.id) then										-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render_t, utilities.substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options_t.id), mw.text.nowiki(options_t.class), text}));	-- when |ref= is set or when there is a namelist
	else
		table.insert (render_t, utilities.substitute (cfg.presentation['cite'], {mw.text.nowiki(options_t.class), text}));	-- when |ref=none or when namelist_t empty and |ref= is missing or is empty
	end		

	if OCinSoutput then															-- blanked when citation is 'empty' so don't bother to add boilerplate metadata span
		table.insert (render_t, utilities.substitute (cfg.presentation['ocins'], OCinSoutput));	-- format and append metadata to the citation
	end

	local template_name = ('citation' == config.CitationClass) and 'citation' or 'cite ' .. (cfg.citation_class_map_t[config.CitationClass] or config.CitationClass);
	local template_link = '[[Template:' .. template_name .. '|' .. template_name .. ']]';	-- TODO: if kept, these require some sort of i18n
	local msg_prefix = '&lt;code class=&quot;cs1-code&quot;&gt;{{' .. template_link .. '}}&lt;/code&gt;: ';

	if 0 ~= #z.error_msgs_t then
		mw.addWarning (utilities.substitute (cfg.messages.warning_msg_e, template_link));

		table.insert (render_t, ' ');											-- insert a space between citation and its error messages
		table.sort (z.error_msgs_t);											-- sort the error messages list; sorting includes wrapping &lt;span&gt; and &lt;code&gt; tags; hidden-error sorts ahead of visible-error

		local hidden = true;													-- presume that the only error messages emited by this template are hidden
		for _, v in ipairs (z.error_msgs_t) do									-- spin through the list of error messages
			if v:find ('cs1-visible-error', 1, true) then						-- look for the visible error class name
				hidden = false;													-- found one; so don't hide the error message prefix
				break;															-- and done because no need to look further
			end
		end

		z.error_msgs_t[1] = table.concat ({utilities.error_comment (msg_prefix, hidden), z.error_msgs_t[1]});	-- add error message prefix to first error message to prevent extraneous punctuation
		table.insert (render_t, table.concat (z.error_msgs_t, '; '));			-- make a big string of error messages and add it to the rendering
	end

	if 0 ~= #z.maint_cats_t then
		mw.addWarning (utilities.substitute (cfg.messages.warning_msg_m, template_link));

		table.sort (z.maint_cats_t);											-- sort the maintenance messages list

		local maint_msgs_t = {};												-- here we collect all of the maint messages

		if 0 == #z.error_msgs_t then											-- if no error messages
			table.insert (maint_msgs_t, msg_prefix);							-- insert message prefix in maint message livery
		end
		
		for _, v in ipairs( z.maint_cats_t ) do									-- append maintenance categories
			table.insert (maint_msgs_t, 										-- assemble new maint message and add it to the maint_msgs_t table
				table.concat ({v, ' (', utilities.substitute (cfg.messages[':cat wikilink'], v), ')'})
				);
		end
		table.insert (render_t, utilities.substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs_t, ' ')));	-- wrap the group of maint messages with proper presentation and save
	end

	if not no_tracking_cats then
		for _, v in ipairs (z.error_cats_t) do									-- append error categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
		end
		for _, v in ipairs (z.maint_cats_t) do									-- append maintenance categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
		end
		for _, v in ipairs (z.prop_cats_t) do									-- append properties categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
		end
	end

	return table.concat (render_t);												-- make a big string and done
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class, empty)
	local name = tostring (name);
	local enum_name;															-- for enumerated parameters, is name with enumerator replaced with '#'
	local state;
	local function state_test (state, name)										-- local function to do testing of state values
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			if empty then return nil; end										-- empty deprecated parameters are treated as unknowns
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
		if 'tracked' == state then
			local base_name = name:gsub ('%d', '');								-- strip enumerators from parameter names that have them to get the base name
			utilities.add_prop_cat ('tracked-param', {base_name}, base_name);	-- add a properties category; &lt;base_name&gt; modifies &lt;key&gt;
			return true;
		end
		return nil;
	end		

	if name:find ('#') then														-- # is a cs1|2 reserved character so parameters with # not permitted
		return nil;
	end

	if utilities.in_array (cite_class, whitelist.preprint_template_list ) then	-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[name];
		if true == state_test (state, name) then return true; end

		state = whitelist.preprint_arguments[cite_class][name];					-- look in the parameter-list for the template identified by cite_class
		if true == state_test (state, name) then return true; end

																				-- limited enumerated parameters list
		enum_name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );										-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
		state = whitelist.limited_numbered_arguments[enum_name];
		if true == state_test (state, name) then return true; end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates

	if utilities.in_array (cite_class, whitelist.unique_param_template_list) then 	-- experiment for template-specific parameters for templates that accept parameters from the basic argument list
		state = whitelist.unique_arguments[cite_class][name];					-- look in the template-specific parameter-lists for the template identified by cite_class
		if true == state_test (state, name) then return true; end
	end																			-- if here, fall into general validation
		
	state = whitelist.basic_arguments[name];									-- all other templates; all normal parameters allowed
	if true == state_test (state, name) then return true; end

																				-- all enumerated parameters allowed
	enum_name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
	state = whitelist.numbered_arguments[enum_name];
	if true == state_test (state, name) then return true; end

	return false;																-- not supported because not found or name is set to nil
end


--[=[-------------------------&lt; I N T E R _ W I K I _ C H E C K &gt;----------------------------------------------

check &lt;value&gt; for inter-language interwiki-link markup.  &lt;prefix&gt; must be a MediaWiki-recognized language
code.  when these values have the form (without leading colon):
	[[&lt;prefix&gt;:link|label]] return label as plain-text
	[[&lt;prefix&gt;:link]] return &lt;prefix&gt;:link as plain-text

return value as is else

]=]

local function inter_wiki_check (parameter, value)
	local prefix = value:match ('%[%[(%a+):');									-- get an interwiki prefix if one exists
	local _;
	
	if prefix and cfg.inter_wiki_map[prefix:lower()] then						-- if prefix is in the map, needs preceding colon so
		utilities.set_message ('err_bad_paramlink', parameter);					-- emit an error message
		_, value, _ = utilities.is_wikilink (value);							-- extract label portion from wikilink
	end
	return value;
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe.  There are two tests made:
	{{cite ... |title=Title access-date=2016-03-17}}	-- the first parameter has a value and whitespace separates that value from the missing pipe parameter name
	{{cite ... |title=access-date=2016-03-17}}			-- the first parameter has no value (whitespace after the first = is trimmed by MediaWiki)
cs1|2 shares some parameter names with XML/HTML attributes: class=, title=, etc.  To prevent false positives XML/HTML
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (parameter, value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove XML/HTML tags because attributes: class=, title=, etc.

	capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then										-- if the capture is a valid parameter name
		utilities.set_message ('err_missing_pipe', parameter);
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ P U N C T &gt;--------------------------------------

look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_punc (param, value)
	if 'number' == type (param) then
		return;
	end
	
	param = param:gsub ('%d+', '#');											-- enumerated name-list mask params allow terminal punct; normalize 
	if cfg.punct_skip[param] then
		return;																	-- parameter name found in the skip table so done
	end
	
	if value:match ('[,;:]$') then
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
	if value:match ('^=') then													-- sometimes an extraneous '=' character appears ...
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ U R L &gt;------------------------------------------

look for extraneous url parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_url (url_param_t)
	local url_error_t = {};
	
	check_for_url (url_param_t, url_error_t);									-- extraneous url check
	if 0 ~= #url_error_t then													-- non-zero when there are errors
		table.sort (url_error_t);
		utilities.set_message ('err_param_has_ext_link', {utilities.make_sep_list (#url_error_t, url_error_t)});	-- add this error message
	end
end


--[[--------------------------&lt; C I T A T I O N &gt;--------------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

local function citation(frame)
	Frame = frame;																-- save a copy in case we need to display an error message in preview mode
	is_sandbox = nil ~= string.find (frame:getTitle(), 'sandbox', 1, true);
	local pframe = frame:getParent()
	local styles;
	
	if is_sandbox then															-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		styles = 'Module:Citation/CS1/sandbox/styles.css';
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
		styles = 'Module:Citation/CS1/styles.css';
	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the selected cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	is_preview_mode = not utilities.is_set (frame:preprocess ('{{REVISIONID}}'));

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text;															-- used as a flag

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do											-- get parameters from the {{#invoke}} frame
		config[k] = v;
	--	args[k] = v;															-- crude debug support that allows us to render a citation from module {{#invoke:}}; skips parameter validation; TODO: keep?
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	local empty_unknowns = {};													-- sequence table to hold empty unknown params for error message listing
	for k, v in pairs( pframe.args ) do											-- get parameters from the parent (template) frame
		v = mw.ustring.gsub (v, '^%s*(.-)%s*$', '%1');							-- trim leading/trailing whitespace; when v is only whitespace, becomes empty string
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				if type (k) ~= 'string' then									-- exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text = utilities.set_message ('err_text_ignored', {v});
					end
				elseif validate (k:lower(), config.CitationClass) then 
					error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, k:lower()});	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if is_sandbox then										-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no capture in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = utilities.substitute (param, capture);		-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, param});	-- set the suggestion error message
							else
								error_text = utilities.set_message ('err_parameter_ignored', {k});	-- suggested param not supported by this template
								v = '';											-- unset
							end
						end
					end
					if not utilities.is_set (error_text) then					-- couldn't match with a pattern, is there an explicit suggestion?						
						if (suggestions.suggestions[ k:lower() ] ~= nil) and validate (suggestions.suggestions[ k:lower() ], config.CitationClass) then
							utilities.set_message ('err_parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]});
						else
							utilities.set_message ('err_parameter_ignored', {k});
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
			end

			args[k] = v;														-- save this parameter and its value

		elseif not utilities.is_set (v) then									-- for empty parameters
			if not validate (k, config.CitationClass, true) then				-- is this empty parameter a valid parameter
				k = ('' == k) and '(empty string)' or k;						-- when k is empty string (or was space(s) trimmed to empty string), replace with descriptive text
				table.insert (empty_unknowns, utilities.wrap_style ('parameter', k));	-- format for error message and add to the list
			end
																				-- crude debug support that allows us to render a citation from module {{#invoke:}} TODO: keep?
	--	elseif args[k] ~= nil or (k == 'postscript') then						-- when args[k] has a value from {{#invoke}} frame (we don't normally do that)
	--		args[k] = v;														-- overwrite args[k] with empty string from pframe.args[k] (template frame); v is empty string here
		end																		-- not sure about the postscript bit; that gets handled in parameter validation; historical artifact?
	end	

	if 0 ~= #empty_unknowns then												-- create empty unknown error message
		utilities.set_message ('err_param_unknown_empty', {
			1 == #empty_unknowns and '' or 's',
			utilities.make_sep_list (#empty_unknowns, empty_unknowns)
			});
	end

	local url_param_t = {};

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);											-- look for invisible characters
		end
		has_extraneous_punc (k, v);												-- look for extraneous terminal punctuation in parameter values
		missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?
		args[k] = inter_wiki_check (k, v);										-- when language interwiki-linked parameter missing leading colon replace with wiki-link label

		if 'string' == type (k) and not cfg.url_skip[k] then					-- when parameter k is not positional and not in url skip table
			url_param_t[k] = v;													-- make a parameter/value list for extraneous url check
		end
	end

	has_extraneous_url (url_param_t);											-- look for url in parameter values where a url does not belong

	return table.concat ({
		frame:extensionTag ('templatestyles', '', {src=styles}),
		citation0( config, args)
	});
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {citation = citation};</text>
      <sha1>ilt6iz2ned3py3aovqo8p76cri4utmr</sha1>
    </revision>
    <revision>
      <id>4745</id>
      <parentid>4744</parentid>
      <timestamp>2022-01-26T04:03:54Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4745</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="204717" sha1="5t576heqoynv9oflrb526o412end3g8" xml:space="preserve">require ('Module:No globals');

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------

each of these counts against the Lua upvalue limit

]]

local validation;																-- functions in Module:Citation/CS1/Date_validation

local utilities;																-- functions in Module:Citation/CS1/Utilities
local z ={};																	-- table of tables in Module:Citation/CS1/Utilities

local identifiers;																-- functions and tables in Module:Citation/CS1/Identifiers
local metadata;																	-- functions in Module:Citation/CS1/COinS
local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;---------------

declare variables here that have page-wide scope that are not brought in from
other modules; that are created here and used here

]]

local added_deprecated_cat;														-- Boolean flag so that the category is added only once
local added_vanc_errs;															-- Boolean flag so we only emit one Vancouver error / category
local added_generic_name_errs;													-- Boolean flag so we only emit one generic name error / category and stop testing names once an error is encountered
local Frame;																	-- holds the module's frame table
local is_preview_mode;															-- true when article is in preview mode; false when using 'Preview page with this template' (previewing the module)
local is_sandbox;																-- true when using sandbox modules to render citation


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if utilities.is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a Boolean declared in page scope variables above

]]

local function add_vanc_error (source, position)
	if added_vanc_errs then return end
		
	added_vanc_errs = true;														-- note that we've added this category
	utilities.set_message ('err_vancouver', {source, position});
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a URI scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of TLDs: https://www.iana.org/domains/root/db

RFC 952 (modified by RFC 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the TLD.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a URL with a scheme) will be stripped
here.  Perhaps not necessary but retained in case it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ASCII characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the TLD) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and TLD or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%w]') then											-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at Wikisource
		return false;
	end

	local patterns = {															-- patterns that look like URLs
		'%f[%w][%w][%w%-]+[%w]%.%a%a+$',										-- three or more character hostname.hostname or hostname.tld
		'%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$',									-- internationalized domain name with ACE prefix
		'%f[%a][qxz]%.com$',													-- assigned one character .com hostname (x.com times out 2015-12-10)
		'%f[%a][iq]%.net$',														-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		'%f[%w][%w]%.%a%a$',													-- one character hostname and ccTLD (2 chars)
		'%f[%w][%w][%w]%.%a%a+$',												-- two character hostname and TLD
		'^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?',								-- IPv4 address
		}

	for _, pattern in ipairs (patterns) do										-- loop through the patterns list
		if domain:match (pattern) then
			return true;														-- if a match then we think that this thing that purports to be a URL is a URL
		end
	end

	for _, d in ipairs ({'cash', 'company', 'today', 'org'}) do					-- look for single letter second level domain names for these top level domains
		if domain:match ('%f[%w][%w]%.' .. d) then
			return true
		end
	end
	return false;																-- no matches, we don't know what this thing is
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a URL appear to be a valid URL; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if utilities.is_set (scheme) then											-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when URL is protocol-relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a URL into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following TLD) (if any) and any path(/), query(?) or fragment(#).

If protocol-relative URL, return nil scheme and domain else return nil for both scheme and domain.

When not protocol-relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Any URL that does not have news: scheme must have authority indicator (//).  TODO: are there other common schemes
like news: that don't use authority indicator?

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol-relative URL
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		if utilities.is_set (authority) then
			authority = authority:gsub ('//', '', 1);							-- replace place 1 pair of '/' with nothing;
			if utilities.is_set(authority) then									-- if anything left (1 or 3+ '/' where authority should be) then
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		else
			if not scheme:match ('^news:') then									-- except for news:..., MediaWiki won't link URLs that do not have authority indicator; TODO: a better way to do this test?
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link=, etc. for properly formatted content: no wikilinks, no URLs

Link parameters are to hold the title of a Wikipedia article, so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki URLs and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid URL (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid URL (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from URL; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid URL
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wiki-linked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

check &lt;link&gt; for inter-language interwiki-link prefix.  prefix must be a MediaWiki-recognized language
code and must begin with a colon.

]]

local function link_title_ok (link, lorig, title, torig)
local orig;
	if utilities.is_set (link) then 											-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		elseif link:match ('^%a+:') then										-- if the link is what looks like an interwiki
			local prefix = link:match ('^(%a+):'):lower();						-- get the interwiki prefix

			if cfg.inter_wiki_map[prefix] then									-- if prefix is in the map, must have preceding colon
				orig = lorig;													-- flag as error
			end
		end
	end

	if utilities.is_set (orig) then
		link = '';																-- unset
		utilities.set_message ('err_bad_paramlink', orig);						-- URL or wikilink in |title= with |title-link=;
	end
	
	return link;																-- link if ok, empty string else
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the URL into scheme and domain
portions, or for protocol-relative (//example.com) URLs, just the domain.  Use is_url() to validate the two
portions of the URL.  If both are valid, or for protocol-relative if domain is valid, return true, else false.

Because it is different from a standard URL, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper URL
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from URL;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a URL.  The test will also find external wikilinks
that use protocol-relative URLs. Also finds bare URLs.

The frontier pattern prevents a match on interwiki-links which are similar to scheme:path URLs.  The tests that
find bracketed URLs are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext. wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol-relative ext. wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare URL with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol-relative bare URL: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a URL
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list, error_list)
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a URL add an error message
			table.insert (error_list, utilities.wrap_style ('parameter', k));
		end
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		utilities.set_message ('err_wikilink_in_url', {});
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link (URL, label, source, access)
	local err_msg = '';
	local domain;
	local path;
	local base_url;

	if not utilities.is_set (label) then
		label = URL;
		if utilities.is_set (source) then
			utilities.set_message ('err_bare_url_missing_title', {utilities.wrap_style ('parameter', source)});
		else
			error (cfg.messages[&quot;bare_url_no_origin&quot;]);
		end			
	end
	if not check_url (URL) then
		utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)});
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the URL into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['['] = '%5b', [']'] = '%5d'});			-- replace '[' and ']' with their percent-encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat ({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wiki-markup URL

	if utilities.is_set (access) then											-- access level (subscription, registration, limited)
		base_url = utilities.substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end

	return base_url;
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a Boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		utilities.set_message ('err_deprecated_params', {name});				-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wiki-markup) are not kerned.

Replaces Unicode quote marks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc.; not for book titles.

]=]

local function kern_quotes (str)
	local cap = '';
	local wl_type, label, link;

	wl_type, label, link = utilities.is_wikilink (str);							-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-left'], str);
			str = utilities.substitute (cfg.presentation['kern-right'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = utilities.substitute (cfg.presentation['kern-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label = mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label = mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap = mw.ustring.match (label, &quot;^([\&quot;\'][^\'].+)&quot;);						-- match leading double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-left'], cap);
		end
	
		cap = mw.ustring.match (label, &quot;^(.+[^\'][\&quot;\'])$&quot;)						-- match trailing double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-right'], cap);
		end
		
		if 2 == wl_type then
			str = utilities.make_wikilink (link, label);						-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin-based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate RTL languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO 639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO 639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title=, |script-chapter=, |script-&lt;periodical&gt;=

]]

local function format_script_value (script_value, script_param)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%l?%s*:') then									-- if first 3 or 4 non-space characters are script language prefix
		lang = script_value:match('^(%l%l%l?)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not utilities.is_set (lang) then
			utilities.set_message ('err_script_parameter', {script_param, 'missing title part'});		-- prefix without 'title'; add error message
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_code_remap[lang] or mw.language.fetchLanguageName( lang, cfg.this_wiki_code );	-- get language name so that we can use it to categorize
		if utilities.is_set (name) then											-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l+%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if utilities.in_array (lang, cfg.script_lang_codes) then
				utilities.add_prop_cat ('script', {name, lang})
			else
				utilities.set_message ('err_script_parameter', {script_param, 'unknown language code'});	-- unknown script-language; add error message
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			utilities.set_message ('err_script_parameter', {script_param, 'invalid language code'});		-- invalid language code; add error message
			lang = '';															-- invalid so set lang to empty string
		end
	else
		utilities.set_message ('err_script_parameter', {script_param, 'missing prefix'});				-- no language code prefix; add error message
	end
	script_value = utilities.substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is RTL

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script
value has been wrapped in &lt;bdi&gt; tags.

]]

local function script_concatenate (title, script, script_param)
	if utilities.is_set (script) then
		script = format_script_value (script, script_param);					-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; returns empty string on error
		if utilities.is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not utilities.is_set ( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return utilities.substitute ( msg, str );								-- including template text
	else
		return utilities.substitute ( cfg.messages[key], str );
	end		
end


--[[----------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;-------------------

Makes a Wikisource URL from Wikisource interwiki-link.  Returns the URL and appropriate
label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;
	local wikisource_prefix = table.concat ({'https://', cfg.this_wiki_code, '.wikisource.org/wiki/'});

	wl_type, D, L = utilities.is_wikilink (str);								-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 1 == wl_type then													-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end

	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable URL
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent-encoding of fragment marker
	end

	return ws_url, ws_label, L or D;											-- return proper URL or nil and a label or nil
end


--[[----------------&lt; F O R M A T _ P E R I O D I C A L &gt;-----------------------

Format the three periodical parameters: |script-&lt;periodical&gt;=, |&lt;periodical&gt;=,
and |trans-&lt;periodical&gt;= into a single Periodical meta-parameter.

]]

local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)

	if not utilities.is_set (periodical) then
		periodical = '';														-- to be safe for concatenation
	else
		periodical = utilities.wrap_style ('italic-title', periodical);			-- style 
	end

	periodical = script_concatenate (periodical, script_periodical, script_periodical_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (trans_periodical) then
		trans_periodical = utilities.wrap_style ('trans-italic-title', trans_periodical);
		if utilities.is_set (periodical) then
			periodical = periodical .. ' ' .. trans_periodical;
		else																	-- here when trans-periodical without periodical or script-periodical
			periodical = trans_periodical;
			utilities.set_message ('err_trans_missing_title', {'periodical'});
		end
	end

	return periodical;
end


--[[------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;---------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=,
and |chapter-url= into a single chapter meta- parameter (chapter_url_source used
for error messages).

]]

local function format_chapter_title (script_chapter, script_chapter_source, chapter, chapter_source, trans_chapter, trans_chapter_source, chapter_url, chapter_url_source, no_quotes, access)
	local ws_url, ws_label, L = wikisource_url_make (chapter);					-- make a wikisource URL and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', ' ');									-- replace underscore separators with space characters
		chapter = ws_label;
	end

	if not utilities.is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from module provided quote marks
			chapter = utilities.wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, script_chapter, script_chapter_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (chapter_url) then
		chapter = external_link (chapter_url, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');	-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if utilities.is_set (trans_chapter) then
		trans_chapter = utilities.wrap_style ('trans-quoted-title', trans_chapter);
		if utilities.is_set (chapter) then
			chapter = chapter .. ' ' .. trans_chapter;
		else																	-- here when trans_chapter without chapter or script-chapter
			chapter = trans_chapter;
			chapter_source = trans_chapter_source:match ('trans%-?(.+)');		-- when no chapter, get matching name from trans-&lt;param&gt;
			utilities.set_message ('err_trans_missing_title', {chapter_source});
		end
	end

	return chapter;
end


--[[----------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;-------------------

This function searches a parameter's value for non-printable or invisible characters.
The search stops at the first match.

This function will detect the visible replacement character when it is part of the Wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers
(gallery, math, pre, ref) and identifies them with a slightly different error message.
See also coins_cleanup().

Output of this function is an error message that identifies the character or the
Unicode group, or the stripmarker that was detected along with its position (or,
for multi-byte characters, the position of its first byte) in the parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local stripmarker;															-- boolean set true when a stripmarker is found

	capture = string.match (v, '[%w%p ]*');										-- test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no Unicode characters
		return;
	end

	for _, invisible_char in ipairs (cfg.invisible_chars) do
		local char_name = invisible_char[1];									-- the character or group name
		local pattern = invisible_char[2];										-- the pattern used to find it
		position, _, capture = mw.ustring.find (v, pattern);					-- see if the parameter value contains characters that match the pattern
		
		if position and (cfg.invisible_defs.zwj == capture) then				-- if we found a zero-width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- it's ok if one of the Indic scripts
				position = nil;													-- unset position
			elseif cfg.emoji[mw.ustring.codepoint (v, position+1)] then			-- is zwj followed by a character listed in emoji{}?
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and utilities.in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and cfg.invisible_defs.del == capture then	-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture and not (cfg.invisible_defs.del == capture or cfg.invisible_defs.zwj == capture) then
					err_msg = capture .. ' ' .. char_name;
				else
					err_msg = char_name .. ' ' .. 'character';
				end

				utilities.set_message ('err_invisible_char', {err_msg, utilities.wrap_style ('parameter', param), position});	-- add error message
				return;															-- and done with this parameter
			end
		end
	end
end


--[[-------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------

Argument wrapper.  This function provides support for argument mapping defined
in the configuration file so that multiple names can be transparently aliased to
single internal variable.

]]

local function argument_wrapper ( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function ( self, k )
			local dummy = self[k];												-- force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = utilities.select_one ( args, list, 'err_redundant_parameters' );
				if origin[k] == nil then
					origin[k] = '';												-- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] .. ': ' .. k);
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;-------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.
When date is DD MMMM YYYY or is MMMM DD, YYYY then wrap in nowrap span:
&lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap = '';
	local cap2 = '';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = utilities.substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = utilities.substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;---------------------

This function sets default title types (equivalent to the citation including
|type=&lt;default value&gt;) for those templates that have defaults. Also handles the
special case where it is desirable to omit the title type from the rendered citation
(|type=none).

]]

local function set_titletype (cite_class, title_type)
	if utilities.is_set (title_type) then
		if 'none' == cfg.keywords_xlate[title_type] then
			title_type = '';													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; S A F E _ J O I N &gt;-----------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'duplicate character'
		if 1 == #duplicate_char then											-- for single byte ASCII characters use the string library functions
			f.gsub = string.gsub
			f.match = string.match
			f.sub = string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub = mw.ustring.gsub
			f.match = mw.ustring.match
			f.sub = mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1, 1) == '&lt;' then										-- special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove HTML markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1, 1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc.?
				trim = false;
				end_chr = f.sub(str, -1, -1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr .. &quot;)&quot;				-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1, -2);									-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;''&quot; then		-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5, -1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;]]&quot; then		-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3, -1) == duplicate_char .. '&quot;]' then	-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2, -1) == duplicate_char .. &quot;]&quot; then	-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2, -1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1, -3);								-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains HTML markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows HTML markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value; 												-- add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;-----------------------------

returns true if suffix is properly formed Jr, Sr, or ordinal in the range 1–9.
Puncutation not allowed.

]]

local function is_suffix (suffix)
	if utilities.in_array (suffix, {'Jr', 'Sr', 'Jnr', 'Snr', '1st', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;-------------------

For Vancouver style, author/editor names are supposed to be rendered in Latin
(read ASCII) characters.  When a name uses characters that contain diacritical
marks, those characters are to be converted to the corresponding Latin
character. When a name is written using a non-Latin alphabet or logogram, that
name is to be transliterated into Latin characters. The module doesn't do this
so editors may/must.

This test allows |first= and |last= names to contain any of the letters defined
in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes.
	(http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;)
	or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written outside of the code editor and pasted here because the code editor
gets confused between character insertion point and cursor position. The test has
been rewritten to use decimal character escape sequence for the individual bytes
of the Unicode characters so that it is not necessary to use an external editor
to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first, suffix, position)
	if not suffix then
		if first:find ('[,%s]') then											-- when there is a space or comma, might be first name/initials + generational suffix
			first = first:match ('(.-)[,%s]+');									-- get name/initials
			suffix = first:match ('[,%s]+(.+)$');								-- get generational suffix
		end
	end
	if utilities.is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error (cfg.err_msg_supl.suffix, position);
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error (cfg.err_msg_supl['non-Latin char'], position);
			return false;														-- not a string of Latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-style=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period.
See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc.) to be rendered
as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format
because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the
Unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first, position)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just initials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error (cfg.err_msg_supl.suffix, position);			-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word

	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i], 1, 1));			-- insert the initial at end of initials table
		end
		i = i + 1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; L I S T _ P E O P L E &gt;--------------------------

Formats a list of people (authors, contributors, editors, interviewers, translators) 

names in the list will be linked when
	|&lt;name&gt;-link= has a value
	|&lt;name&gt;-mask- does NOT have a value; masked names are presumed to have been
		rendered previously so should have been linked there

when |&lt;name&gt;-mask=0, the associated name is not rendered

]]

local function list_people (control, people, etal)
	local sep;
	local namesep;
	local format = control.format;
	local maximum = control.maximum;
	local name_list = {};

	if 'vanc' == format then													-- Vancouver-like name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between names is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between names is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub (-1, -1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if utilities.is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end		-- returned 0 is for EditorCount; not used for other names
	
	for i, person in ipairs (people) do
		if utilities.is_set (person.last) then
			local mask = person.mask;
			local one;
			local sep_one = sep;

			if utilities.is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			end
			
			if mask then
				local n = tonumber (mask);										-- convert to a number if it can be converted; nil else
				if n then
					one = 0 ~= n and string.rep(&quot;&amp;mdash;&quot;, n) or nil;			-- make a string of (n &gt; 0) mdashes, nil else, to replace name
					person.link = nil;											-- don't create link to name if name is replaces with mdash string or has been set nil
				else
					one = mask;													-- replace name with mask text (must include name-list separator)
					sep_one = &quot; &quot;;												-- modify name-list separator
				end
			else
				one = person.last;												-- get surname
				local first = person.first										-- get given name
				if utilities.is_set (first) then
					if (&quot;vanc&quot; == format) then									-- if Vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first, nil, i) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials (first, i);				-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
			end
			if utilities.is_set (person.link) then
				one = utilities.make_wikilink (person.link, one);				-- link author/editor
			end
			if one then															-- if &lt;one&gt; has a value (name, mdash replacement, or mask text replacement)
				table.insert (name_list, one);									-- add it to the list of names
				table.insert (name_list, sep_one);								-- add the proper name-list separator
			end
		end
	end

	local count = #name_list / 2;												-- (number of names + number of separators) divided by 2
	if 0 &lt; count then 
		if 1 &lt; count and not etal then
			if 'amp' == format then
				name_list[#name_list-2] = &quot; &amp; &quot;;								-- replace last separator with ampersand text
			elseif 'and' == format then
				if 2 == count then
					name_list[#name_list-2] = cfg.presentation.sep_nl_and;		-- replace last separator with 'and' text
				else
					name_list[#name_list-2] = cfg.presentation.sep_nl_end;		-- replace last separator with '(sep) and' text
				end
			end
		end
		name_list[#name_list] = nil;											-- erase the last separator
	end

	local result = table.concat (name_list);									-- construct list
	if etal and utilities.is_set (result) then									-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've got a last-first list and etal so add et al.
	end
	
	return result, count;														-- return name-list string and count of number of names (count used for editor names only)
end


--[[--------------------&lt; M A K E _ C I T E R E F _ I D &gt;-----------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise
returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that
order.  year is Year or anchor_year.

]]

local function make_citeref_id (namelist, year)
	local names={};							-- a table for the one to four names and year
	for i,v in ipairs (namelist) do			-- loop through the list and take up to the first four last names
		names[i] = v.last
		if i == 4 then break end			-- if four then done
	end
	table.insert (names, year);				-- add the year at the end
	local id = table.concat(names);			-- concatenate names and year for CITEREF id
	if utilities.is_set (id) then			-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;				-- add the CITEREF portion
	else
		return '';							-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; C I T E _ C L A S S _A T T R I B U T E _M A K E &gt;------------------------------

construct &lt;cite&gt; tag class attribute for this citation.

&lt;cite_class&gt; – config.CitationClass from calling template
&lt;mode&gt; – value from |mode= parameter

]]

local function cite_class_attribute_make (cite_class, mode)
	local class_t = {};
	table.insert (class_t, 'citation');											-- required for blue highlight
	if 'citation' ~= cite_class then
		table.insert (class_t, cite_class);										-- identify this template for user css
		table.insert (class_t, utilities.is_set (mode) and mode or 'cs1');		-- identify the citation style for user css or javascript
	else
		table.insert (class_t, utilities.is_set (mode) and mode or 'cs2');		-- identify the citation style for user css or javascript
	end
	for _, prop_key in ipairs (z.prop_keys_t) do
		table.insert (class_t, prop_key);										-- identify various properties for user css or javascript
	end

	return table.concat (class_t, ' ');											-- make a big string and done
end


--[[---------------------&lt; N A M E _ H A S _ E T A L &gt;--------------------------

Evaluates the content of name parameters (author, editor, etc.) for variations on
the theme of et al.  If found, the et al. is removed, a flag is set to true and
the function returns the modified name and the flag.

This function never sets the flag to false but returns its previous state because
it may have been set by previous passes through this function or by the associated
|display-&lt;names&gt;=etal parameter

]]

local function name_has_etal (name, etal, nocat, param)

	if utilities.is_set (name) then												-- name can be nil in which case just return
		local patterns = cfg.et_al_patterns; 									-- get patterns from configuration
		
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns
			if name:match (pattern) then										-- if this 'et al' pattern is found in name
				name = name:gsub (pattern, '');									-- remove the offending text
				etal = true;													-- set flag (may have been set previously here or by |display-&lt;names&gt;=etal)
				if not nocat then												-- no categorization for |vauthors=
					utilities.set_message ('err_etal', {param});				-- and set an error if not added
				end
			end
		end
	end

	return name, etal;
end


--[[---------------------&lt; N A M E _ I S _ N U M E R I C &gt;----------------------

Add maint cat when name parameter value does not contain letters.  Does not catch
mixed alphanumeric names so |last=A. Green (1922-1987) does not get caught in the
current version of this test but |first=(1888) is caught.

returns nothing

]]

local function name_is_numeric (name, list_name)
	if utilities.is_set (name) then
		if mw.ustring.match (name, '^[%A]+$') then								-- when name does not contain any letters
			utilities.set_message ('maint_numeric_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
		end
	end
end


--[[-----------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;------------------

Evaluates the content of last/surname (authors etc.) parameters for multiple names.
Multiple names are indicated if there is more than one comma or any &quot;unescaped&quot;
semicolons. Escaped semicolons are ones used as part of selected HTML entities.
If the condition is met, the function adds the multiple name maintenance category.

returns nothing

]]

local function name_has_mult_names (name, list_name)
	local _, commas, semicolons, nbsps;
	if utilities.is_set (name) then
		_, commas = name:gsub (',', '');										-- count the number of commas
		_, semicolons = name:gsub (';', '');									-- count the number of semicolons
		-- nbsps probably should be its own separate count rather than merged in
		-- some way with semicolons because Lua patterns do not support the
		-- grouping operator that regex does, which means there is no way to add
		-- more entities to escape except by adding more counts with the new
		-- entities
		_, nbsps = name:gsub ('&amp;nbsp;','');										-- count nbsps
		
		-- There is exactly 1 semicolon per &amp;nbsp; entity, so subtract nbsps
		-- from semicolons to 'escape' them. If additional entities are added,
		-- they also can be subtracted.
		if 1 &lt; commas or 0 &lt; (semicolons - nbsps) then
			utilities.set_message ('maint_mult_names', cfg.special_case_translation [list_name]);	-- add a maint message
		end
	end
end


--[[--------------------------&lt; I S _ G E N E R I C &gt;----------------------------------------------------------

Compares values assigned to various parameter according to the string provided as &lt;item&gt; in the function call:
	'generic_names': |last=, |first=, |editor-last=, etc value against list of known generic name patterns
	'generic_titles': |title=
Returns true when pattern matches; nil else

The k/v pairs in cfg.special_case_translation[item] each contain two tables, one for English and one for another
'local' language.Each of those tables contain another table that holds the string or pattern (whole or fragment)
in index [1]. index [2] is a Boolean that tells string.find() or mw.ustring.find() to do plain-text search (true)
or a pattern search (false).  The intent of all this complexity is to make these searches as fast as possible so
that we don't run out of processing time on very large articles.

]]

local function is_generic (item, value)
	local test_val;

	for _, generic_value in ipairs (cfg.special_case_translation[item]) do		-- spin through the list of known generic value fragments
		test_val = generic_value['en'][2] and value:lower() or value;			-- when set to 'true', plaintext search using lowercase value

		if test_val:find (generic_value['en'][1], 1, generic_value['en'][2]) then
			return true;														-- found English generic value so done

		elseif generic_value['local'] then										-- to keep work load down, generic_&lt;value&gt;['local'] should be nil except when there is a local version of the generic value
			test_val = generic_value['local'][2] and mw.ustring.lower(value) or value;	-- when set to 'true', plaintext search using lowercase value

			if mw.ustring.find (test_val, generic_value['local'][1], 1, generic_value['local'][2]) then	-- mw.ustring() because might not be Latin script
				return true;													-- found local generic value so done
			end
		end
	end
end


--[[--------------------------&lt; N A M E _ I S _ G E N E R I C &gt;------------------------------------------------

calls is_generic() to determine if &lt;name&gt; is a 'generic name' listed in cfg.generic_names; &lt;name_alias&gt; is the
parameter name used in error messaging

]]

local function name_is_generic (name, name_alias)
	if not added_generic_name_errs  and is_generic ('generic_names', name) then
		utilities.set_message ('err_generic_name', name_alias);					-- set an error message
		added_generic_name_errs = true;
	end
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------

This function calls various name checking functions used to validate the content of the various name-holding parameters.

]]

local function name_checks (last, first, list_name, last_alias, first_alias)
	local accept_name;

	if utilities.is_set (last) then
		last, accept_name = utilities.has_accept_as_written (last);				-- remove accept-this-as-written markup when it wraps all of &lt;last&gt;

		if not accept_name then													-- &lt;last&gt; not wrapped in accept-as-written markup
			name_has_mult_names (last, list_name);								-- check for multiple names in the parameter (last only)
			name_is_numeric (last, list_name);									-- check for names that are composed of digits and punctuation
			name_is_generic (last, last_alias);									-- check for names found in the generic names list
		end
	end

	if utilities.is_set (first) then
		first, accept_name = utilities.has_accept_as_written (first);			-- remove accept-this-as-written markup when it wraps all of &lt;first&gt;

		if not accept_name then													-- &lt;first&gt; not wrapped in accept-as-written markup
			name_is_numeric (first, list_name);									-- check for names that are composed of digits and punctuation
			name_is_generic (first, first_alias);								-- check for names found in the generic names list
		end
		local wl_type, D = utilities.is_wikilink (first);
		if 0 ~= wl_type then
			first = D;
			utilities.set_message ('err_bad_paramlink', first_alias);
		end
	end

	return last, first;															-- done
end


--[[----------------------&lt; E X T R A C T _ N A M E S &gt;-------------------------

Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters
(or their aliases), and their matching link and mask parameters. Stops searching
when both |lastn= and |firstn= are not found in args after two sequential attempts:
found |last1=, |last2=, and |last3= but doesn't find |last4= and |last5= then the
search is done.

This function emits an error message when there is a |firstn= without a matching
|lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not
required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.'
is stripped from the parameter and a flag (etal) returned that will cause list_people()
to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps
'et al.' out of the template's metadata.  When this occurs, an error is emitted.

]]

local function extract_names(args, list_name)
	local names = {};															-- table of names
	local last;																	-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;																-- loop counter/indexer
	local n = 1;																-- output table indexer
	local count = 0;															-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal = false;															-- return value set to true when we find some form of et al. in an author parameter

	local last_alias, first_alias, link_alias;									-- selected parameter aliases used in error messaging
	while true do
		last, last_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'err_redundant_parameters', i );		-- search through args for name components beginning at 1
		first, first_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'err_redundant_parameters', i );
		link, link_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i );
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.
		last, first = name_checks (last, first, list_name, last_alias, first_alias);						-- multiple names, extraneous annotation, etc. checks

		if first and not last then												-- if there is a firstn without a matching lastn
			local alias = first_alias:find ('given', 1, true) and 'given' or 'first';	-- get first or given form of the alias
			utilities.set_message ('err_first_missing_last', {
				first_alias,													-- param name of alias missing its mate
				first_alias:gsub (alias, {['first'] = 'last', ['given'] = 'surname'}),	-- make param name appropriate to the alias form
				});																-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			local result;
			link = link_title_ok (link, link_alias, last, last_alias);			-- check for improper wiki-markup

			if first then
				link = link_title_ok (link, link_alias, first, first_alias);	-- check for improper wiki-markup
			end

			names[n] = {last = last, first = first, link = link, mask = mask, corporate = false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				utilities.set_message ('err_missing_name', {list_name:match (&quot;(%w+)List&quot;):lower(), i - 1});	-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names and the etal flag
end


--[[--------------------------&lt; N A M E _ T A G _ G E T &gt;------------------------------------------------------

attempt to decode |language=&lt;lang_param&gt; and return language name and matching tag; nil else.

This function looks for:
	&lt;lang_param&gt; as a tag in cfg.lang_code_remap{}
	&lt;lang_param&gt; as a name in cfg.lang_name_remap{}
	
	&lt;lang_param&gt; as a name in cfg.mw_languages_by_name_t
	&lt;lang_param&gt; as a tag in cfg.mw_languages_by_tag_t
when those fail, presume that &lt;lang_param&gt; is an IETF-like tag that MediaWiki does not recognize.  Strip all
script, region, variant, whatever subtags from &lt;lang_param&gt; to leave just a two or three character language tag
and look for the new &lt;lang_param&gt; in cfg.mw_languages_by_tag_t{}

on success, return name and matching tag; on failure return nil

]]

local function name_tag_get (lang_param)
	local lang_param_lc = mw.ustring.lower (lang_param);						-- use lowercase as an index into the various tables

	local name = cfg.lang_code_remap[lang_param_lc];							-- assume &lt;lang_param_lc&gt; is a tag; attempt to get remapped language name 
	if name then																-- when &lt;name&gt;, &lt;lang_param&gt; is a tag for a remapped language name
		return name, lang_param;												-- so return &lt;name&gt; from remap and &lt;lang_param&gt;
	end

	if cfg.lang_name_remap[lang_param_lc] then									-- not a tag, assume &lt;lang_param_lc&gt; is a name; attempt to get remapped language tag 
		return cfg.lang_name_remap[lang_param_lc][1], cfg.lang_name_remap[lang_param_lc][2];	-- for this &lt;lang_param_lc&gt;, return a (possibly) new name and appropriate tag
	end

	local tag = cfg.mw_languages_by_name_t[lang_param_lc];						-- assume that &lt;lang_param_lc&gt; is a language name; attempt to get its matching tag
	
	if tag then
		return cfg.mw_languages_by_tag_t[tag], tag;								-- &lt;lang_param_lc&gt; is a name so return the name from the table and &lt;tag&gt;
	end

	name = cfg.mw_languages_by_tag_t[lang_param_lc];							-- assume that &lt;lang_param_lc&gt; is a tag; attempt to get its matching language name
	
	if name then
		return name, lang_param;												-- &lt;lang_param_lc&gt; is a tag so return &lt;name&gt; and the tag
	end
	
	tag = lang_param_lc:match ('^(%a%a%a?)%-.*');								-- is tag an IETF-like tag that MediaWiki doesn't recognize? &lt;tag&gt; gets the language subtag; nil else

	if tag then
		name = cfg.mw_languages_by_tag_t[tag];									-- attempt to get a language name using the shortened &lt;tag&gt;
		if name then
			return name, tag;													-- &lt;lang_param_lc&gt; is an unrecognized IETF-like tag so return &lt;name&gt; and language subtag
		end
	end
end


--[[-------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code
is recognized by MediaWiki, use the returned name; if not, then use the value that
was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is
assigned to the category for that code: Category:Norwegian-language sources (no).
For valid three-character code languages, the page is assigned to the single category
for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does
not recognize three-character equivalents of two-character codes: code 'ar' is
recognized but code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th
where the language names or codes are separated from each other by commas with
optional space characters.

]]

local function language_parameter (lang)
	local tag;																	-- some form of IETF-like language tag; language subtag with optional region, sript, vatiant, etc subtags
	local lang_subtag;															-- ve populates |language= with mostly unecessary region subtags the MediaWiki does not recognize; this is the base language subtag
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_t = {};															-- table made from the value assigned to |language=

	local this_wiki_name = mw.language.fetchLanguageName (cfg.this_wiki_code, cfg.this_wiki_code);	-- get this wiki's language name

	names_t = mw.text.split (lang, '%s*,%s*');									-- names should be a comma separated list

	for _, lang in ipairs (names_t) do											-- reuse lang here because we don't yet know if lang is a language name or a language tag
		name, tag = name_tag_get (lang);										-- attempt to get name/tag pair for &lt;lang&gt;

		if utilities.is_set (tag) then
			lang_subtag = tag:lower():gsub ('^(%a%a%a?)%-.*', '%1');			-- for categorization, strip any IETF-like tags from language tag

			if cfg.this_wiki_code ~= lang_subtag then							-- when the language is not the same as this wiki's language
				if 2 == lang_subtag:len() then									-- and is a two-character tag
					utilities.add_prop_cat ('foreign-lang-source', {name, lang_subtag}, lang_subtag);		-- categorize it; tag appended to allow for multiple language categorization
				else															-- or is a recognized language (but has a three-character tag)
					utilities.add_prop_cat ('foreign-lang-source-2', {lang_subtag}, lang_subtag);			-- categorize it differently TODO: support multiple three-character tag categories per cs1|2 template?
				end
			elseif cfg.local_lang_cat_enable then								-- when the language and this wiki's language are the same and categorization is enabled
				utilities.add_prop_cat ('local-lang-source', {name, lang_subtag});		-- categorize it
			end
		else
			name = lang;														-- return whatever &lt;lang&gt; has so that we show something
			utilities.set_message ('maint_unknown_lang');						-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
 
	name = utilities.make_sep_list (#language_list, language_list);
	if (1 == #language_list) and (tag == cfg.this_wiki_code) then				-- when only one language, find lang name in this wiki lang name; for |language=en-us, 'English' in 'American English'
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[-----------------------&lt; S E T _ C S _ S T Y L E &gt;--------------------------

Gets the default CS style configuration for the given mode.
Returns default separator and either postscript as passed in or the default.
In CS1, the default postscript and separator are '.'.
In CS2, the default postscript is the empty string and the default separator is ','.

]]

local function set_cs_style (postscript, mode)
	if utilities.is_set(postscript) then
		-- emit a maintenance message if user postscript is the default cs1 postscript
		-- we catch the opposite case for cs2 in set_style
		if mode == 'cs1' and postscript == cfg.presentation['ps_' .. mode] then
			utilities.set_message ('maint_postscript');
		end
	else
		postscript = cfg.presentation['ps_' .. mode];
	end
	return cfg.presentation['sep_' .. mode], postscript;
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;-----------------------------

Sets the separator and postscript styles. Checks the |mode= first and the
#invoke CitationClass second. Removes the postscript if postscript == none.

]]

local function set_style (mode, postscript, cite_class)
	local sep;
	if 'cs2' == mode then
		sep, postscript = set_cs_style (postscript, 'cs2');
	elseif 'cs1' == mode then
		sep, postscript = set_cs_style (postscript, 'cs1');
	elseif 'citation' == cite_class	then
		sep, postscript = set_cs_style (postscript, 'cs2');
	else
		sep, postscript = set_cs_style (postscript, 'cs1');
	end

	if cfg.keywords_xlate[postscript:lower()] == 'none' then
		-- emit a maintenance message if user postscript is the default cs2 postscript
		-- we catch the opposite case for cs1 in set_cs_style
		if 'cs2' == mode or 'citation' == cite_class then
			utilities.set_message ('maint_postscript');
		end
		postscript = '';
	end
	
	return sep, postscript
end


--[=[-------------------------&lt; I S _ P D F &gt;-----------------------------------

Determines if a URL has the file extension that is one of the PDF file extensions
used by [[MediaWiki:Common.css]] when applying the PDF icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or
		url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
		url:match ('%.PDF&amp;#035') or url:match ('%.pdf&amp;#035');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;-----------------------

Applies CSS style to |format=, |chapter-format=, etc.  Also emits an error message
if the format parameter does not have a matching URL parameter.  If the format parameter
is not set and the URL contains a file extension that is recognized as a PDF document
by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if utilities.is_set (format) then
		format = utilities.wrap_style ('format', format);						-- add leading space, parentheses, resize
		if not utilities.is_set (url) then
			utilities.set_message ('err_format_missing_url', {fmt_param, url_param});	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if URL is a PDF file then
		format = utilities.wrap_style ('format', 'PDF');						-- set format to PDF
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[---------------------&lt; G E T _ D I S P L A Y _ N A M E S &gt;------------------

Returns a number that defines the number of names displayed for author and editor
name lists and a Boolean flag to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero,
return the number and the previous state of the 'etal' flag (false by default
but may have been set to true if the name list contains some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number
that is one greater than the number of authors in the list and set the 'etal' flag true.
This will cause the list_people() to display all of the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_names (max, count, list_name, etal, param)
	if utilities.is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				utilities.set_message ('err_disp_name', {param, max});			-- add error message
				max = nil;
			end
		else																	-- not a valid keyword or number
			utilities.set_message ('err_disp_name', {param, max});		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[----------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;---------------

Adds error if |page=, |pages=, |quote-page=, |quote-pages= has what appears to be
some form of p. or pp. abbreviation in the first characters of the parameter content.

check page for extraneous p, p., pp, pp., pg, pg. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when page begins PX or P# but not Px
		      where x and X are letters and # is a digit
	bad pattern:  '^[Pp][PpGg]' matches when page begins pp, pP, Pp, PP, pg, pG, Pg, PG

]]

local function extra_text_in_page_check (val, name)
	if not val:match (cfg.vol_iss_pg_patterns.good_ppattern) then
		for _, pattern in ipairs (cfg.vol_iss_pg_patterns.bad_ppatterns) do		-- spin through the selected sequence table of patterns
			if val:match (pattern) then											-- when a match, error so
				utilities.set_message ('err_extra_text_pages', name);	 		-- add error message
				return;															-- and done
			end
		end
	end		
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ V O L _ I S S _ C H E C K &gt;------------------------

Adds error if |volume= or |issue= has what appears to be some form of redundant 'type' indicator.

For |volume=:
	'V.', or 'Vol.' (with or without the dot) abbreviations or 'Volume' in the first characters of the parameter
	content (all case insensitive). 'V' and 'v' (without the dot) are presumed to be roman numerals so
	are allowed.

For |issue=:
	'No.', 'I.', 'Iss.' (with or without the dot) abbreviations, or 'Issue' in the first characters of the
	parameter content (all case insensitive).
	
Single character values ('v', 'i', 'n') allowed when not followed by separator character ('.', ':', '=', or
whitespace character) – param values are trimmed of whitespace by MediaWiki before delivered to the module.
	
&lt;val&gt; is |volume= or |issue= parameter value
&lt;name&gt; is |volume= or |issue= parameter name for error message
&lt;selector&gt; is 'v' for |volume=, 'i' for |issue=

sets error message on failure; returns nothing

]]

local function extra_text_in_vol_iss_check (val, name, selector)
	if not utilities.is_set (val) then
		return;
	end
	
	local patterns = 'v' == selector and cfg.vol_iss_pg_patterns.vpatterns or cfg.vol_iss_pg_patterns.ipatterns;

	local handler = 'v' == selector and 'err_extra_text_volume' or 'err_extra_text_issue';
	val = val:lower();															-- force parameter value to lower case
	for _, pattern in ipairs (patterns) do										-- spin through the selected sequence table of patterns
		if val:match (pattern) then												-- when a match, error so
			utilities.set_message (handler, name);								-- add error message
			return;																-- and done
		end
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parentheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a placeholder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parentheses
			local name = name_table[i];
			i = i + 1;															-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parentheses
					break;														-- and done reassembling so
				end
				i = i + 1;														-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = utilities.is_wikilink (name_table[i]);		-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i + 1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled parentheses ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the Vancouver error when a required comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		first = '';																-- set to empty string for concatenation and because it may have been set for previous author/editor
		local accept_name;
		v_name, accept_name = utilities.has_accept_as_written (v_name);			-- remove accept-this-as-written markup when it wraps all of &lt;v_name&gt;

		if accept_name then
			last = v_name;
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error (cfg.err_msg_supl.punctuation, i);
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s+&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be initials or generational suffix

			if not mw.ustring.match (first, '^%u+$') then						-- mw.ustring here so that later we will catch non-Latin characters
				suffix = first;													-- not initials so assume that whatever we got is a generational suffix
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end
			last = table.concat(lastfirstTable, ' ')							-- returns a string that is the concatenation of all other names that are not initials and generational suffix
			if not utilities.is_set (last) then
				first = '';														-- unset
				last = v_name;													-- last empty because something wrong with first
				add_vanc_error (cfg.err_msg_supl.name, i);
			end
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error (cfg.err_msg_supl['missing comma'], i);			-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- matches a space between two initials
			end
		else
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
		
		if utilities.is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first, suffix, i);							-- check first and last before restoring the suffix which may have a non-Latin digit
			if utilities.is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '', nil, i);
			end
		end

		link = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i ) or v_link_table[i];
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate = corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest;
|editorn= (and aliases) highest and |veditors= lowest (support for |editors= withdrawn)

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
	local lastfirst = false;
	if utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice in case we have a |first1= without a |last1=; this ...
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or		-- ... also catches the case where |first= is used with |vauthors=
		utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst = true;
	end

	if (utilities.is_set (vxxxxors) and true == lastfirst) or					-- these are the three error conditions
		(utilities.is_set (vxxxxors) and utilities.is_set (xxxxors)) or
		(true == lastfirst and utilities.is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			utilities.set_message ('err_redundant_parameters', err_name .. '-name-list parameters');	-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if utilities.is_set (vxxxxors) then return 2 end;
	if utilities.is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, live, dead, etc.).  When the parameter value has not been assigned a value (missing
or empty in the source template) the function returns the value specified by ret_val.  If the parameter value is one
of the list of allowed values returns the translated value; else, emits an error message and returns the value
specified by ret_val.

TODO: explain &lt;invert&gt;

]]

local function is_valid_parameter_value (value, name, possible, ret_val, invert)
	if not utilities.is_set (value) then
		return ret_val;															-- an empty parameter is ok
	end

	if (not invert and utilities.in_array (value, possible)) then				-- normal; &lt;value&gt; is in &lt;possible&gt; table
		return cfg.keywords_xlate[value];										-- return translation of parameter keyword
	elseif invert and not utilities.in_array (value, possible) then				-- invert; &lt;value&gt; is not in &lt;possible&gt; table
		return value;															-- return &lt;value&gt; as it is
	else
		utilities.set_message ('err_invalid_param_val', {name, value});			-- not an allowed value so add error message
		return ret_val;
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list, -3, -1) == sepc .. '. ') then					-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list, -1, -1) == sepc) or (string.sub (name_list, -3, -1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terminate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not utilities.is_set (volume) and not utilities.is_set (issue) then
		return '';
	end

	-- same condition as in format_pages_sheets()
	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);

	local is_numeric_vol = volume and (volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$'));	-- is only uppercase roman numerals or only digits?
	local is_long_vol = volume and (4 &lt; mw.ustring.len(volume));				-- is |volume= value longer than 4 characters?
	
	if volume and (not is_numeric_vol and is_long_vol) then						-- when not all digits or Roman numerals, is |volume= longer than 4 characters?
		utilities.add_prop_cat ('long-vol');									-- yes, add properties cat
	end

	if is_journal then															-- journal-style formatting
		local vol = '';
		
		if utilities.is_set (volume) then
			if is_numeric_vol then												-- |volume= value all digits or all uppercase Roman numerals?
				vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, volume});	-- render in bold face
			elseif is_long_vol then												-- not all digits or Roman numerals; longer than 4 characters?
				vol = utilities.substitute (cfg.messages['j-vol'], {sepc, utilities.hyphen_to_dash (volume)});	-- not bold
			else																-- four or fewer characters
				vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, utilities.hyphen_to_dash (volume)});	-- bold
			end
		end
		if utilities.is_set (issue) then
			return vol .. utilities.substitute (cfg.messages['j-issue'], issue);
		end
		return vol;
	end
	
	if 'podcast' == cite_class and utilities.is_set (issue) then
		return wrap_msg ('issue', {sepc, issue}, lower);
	end

	-- all other types of citation
	if utilities.is_set (volume) and utilities.is_set (issue) then
		return wrap_msg ('vol-no', {sepc, utilities.hyphen_to_dash (volume), issue}, lower);
	elseif utilities.is_set (volume) then
		return wrap_msg ('vol', {sepc, utilities.hyphen_to_dash (volume)}, lower);
	else
		return wrap_msg ('issue', {sepc, issue}, lower);
	end
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if utilities.is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif utilities.is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if utilities.is_set (page) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return utilities.substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return utilities.substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif utilities.is_set (pages) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then							-- if pages is only digits, assume a single page number
			return '', utilities.substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', utilities.substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', utilities.substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to Wikisource, returns the label portion of the interwiki-link as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki-link to an external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, page_orig, pages, pages_orig, at)
	local ws_url, ws_label, coins_pages, L;										-- for Wikisource interwiki-links; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if utilities.is_set (page) then
		if utilities.is_set (pages) or utilities.is_set (at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page, page_orig);								-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws URL from |page= interwiki link; link portion L becomes tooltip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (pages) then
		if utilities.is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages, pages_orig);							-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws URL from |pages= interwiki link; link portion L becomes tooltip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws URL from |at= interwiki link; link portion L becomes tooltip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end

--[[--------------------------&lt; I S _ U N I Q U E _ A R C H I V E _ U R L &gt;------------------------------------

add error message when |archive-url= value is same as |url= or chapter-url= (or alias...) value

]]

local function is_unique_archive_url (archive, url, c_url, source, date)
	if utilities.is_set (archive) then
		if archive == url or archive == c_url then
			utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)});	-- add error message
			return '', '';														-- unset |archive-url= and |archive-date= because same as |url= or |chapter-url=
		end
	end

	return archive, date;
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org URLs to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot URL or to calendar pages.  When the archive URL is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the URL.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org URL does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command URL
	|archive-url= is an archive.org URL that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org URLs:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this function may return a modified
archive URL:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the URL unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.org URL
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine URL
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command URL, we don't want to allow saving of the target page 
		err_msg = cfg.err_msg_supl.save;
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = cfg.err_msg_supl.liveweb;
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');	-- split out some of the URL parts for evaluation
		if not path then														-- malformed in some way; pattern did not match
			err_msg = cfg.err_msg_supl.timestamp;
		elseif 14 ~= timestamp:len() then										-- path and flag optional, must have 14-digit timestamp here
			err_msg = cfg.err_msg_supl.timestamp;
			if '*' ~= flag then
				local replacement = timestamp:match ('^%d%d%d%d%d%d') or timestamp:match ('^%d%d%d%d');	-- get the first 6 (YYYYMM) or first 4 digits (YYYY)
				if replacement then												-- nil if there aren't at least 4 digits (year)
					replacement = replacement .. string.rep ('0', 14 - replacement:len());	-- year or yearmo (4 or 6 digits) zero-fill to make 14-digit timestamp
					url=url:gsub ('(//web%.archive%.org/[^%d]*)%d[^/]*', '%1' .. replacement .. '*', 1)	-- for preview, modify ts to 14 digits plus splat for calendar display
				end
			end
		elseif utilities.is_set (path) and 'web/' ~= path then					-- older archive URLs do not have the extra 'web/' path element
			err_msg = cfg.err_msg_supl.path;
		elseif utilities.is_set (flag) and not utilities.is_set (path) then		-- flag not allowed with the old form URL (without the 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		elseif utilities.is_set (flag) and not flag:match ('%a%a_') then		-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		else
			return url, date;													-- return ArchiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	utilities.set_message ('err_archive_url', {err_msg});						-- add error message and

	if is_preview_mode then
		return url, date;														-- preview mode so return ArchiveURL and ArchiveDate
	else
		return '', '';															-- return empty strings for ArchiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; P L A C E _ C H E C K &gt;--------------------------------------------------------

check |place=, |publication-place=, |location= to see if these params include digits.  This function added because
many editors misuse location to specify the in-source location (|page(s)= and |at= are supposed to do that)

returns the original parameter value without modification; added maint cat when parameter value contains digits

]]

local function place_check (param_val)
	if not utilities.is_set (param_val) then									-- parameter empty or omitted
		return param_val;														-- return that empty state
	end
	
	if mw.ustring.find (param_val, '%d') then									-- not empty, are there digits in the parameter value
		utilities.set_message ('maint_location');								-- yep, add maint cat
	end
	
	return param_val;															-- and done
end


--[[--------------------------&lt; I S _ A R C H I V E D _ C O P Y &gt;----------------------------------------------

compares |title= to 'Archived copy' (placeholder added by bots that can't find proper title); if matches, return true; nil else

]]

local function is_archived_copy (title)
	title = mw.ustring.lower(title);											-- switch title to lower case
	if title:find (cfg.special_case_translation.archived_copy.en) then			-- if title is 'Archived copy'
		return true;
	elseif cfg.special_case_translation.archived_copy['local'] then
		if mw.ustring.find (title, cfg.special_case_translation.archived_copy['local']) then	-- mw.ustring() because might not be Latin script
			return true;
		end
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args )
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper ( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListStyle = is_valid_parameter_value (A['NameListStyle'], A:ORIGIN('NameListStyle'), cfg.keywords_lists['name-list-style'], '');
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				utilities.set_message ('maint_authors');						-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if utilities.is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], nil, args, 'EditorList');	-- support for |editors= withdrawn
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		end
	end
							
	local Chapter = A['Chapter'];												-- done here so that we have access to |contribution= from |chapter= aliases
	local Chapter_origin = A:ORIGIN ('Chapter');
	local Contribution;															-- because contribution is required for contributor(s)
		if 'contribution' == Chapter_origin then
			Contribution = Chapter;												-- get the name of the contribution
		end
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	
	if utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not utilities.is_set (Contribution) then							-- |contributor= requires |contribution=
				utilities.set_message ('err_contributor_missing_required_param', 'contribution');	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				utilities.set_message ('err_contributor_missing_required_param', 'author');	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if utilities.select_one (args, cfg.aliases['ContributorList-Last'], 'err_redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			utilities.set_message ('err_contributor_ignored');					-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	local Title = A['Title'];
	local TitleLink = A['TitleLink'];

	local auto_select = ''; -- default is auto
	local accept_link;
	TitleLink, accept_link = utilities.has_accept_as_written (TitleLink, true);	-- test for accept-this-as-written markup
	if (not accept_link) and utilities.in_array (TitleLink, {'none', 'pmc', 'doi'}) then -- check for special keywords
		auto_select = TitleLink;												-- remember selection for later
		TitleLink = '';															-- treat as if |title-link= would have been empty
	end

	TitleLink = link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wiki-markup in |title-link= or wiki-markup in |title= when |title-link= is set

	local Section = '';															-- {{cite map}} only; preset to empty string for concatenation if not used
	if 'map' == config.CitationClass and 'section' == Chapter_origin then
		Section = A['Chapter'];													-- get |section= from |chapter= alias list; |chapter= and the other aliases not supported in {{cite map}}
		Chapter = '';															-- unset for now; will be reset later from |map= if present
	end

	local Periodical = A['Periodical'];
	local Periodical_origin = '';
	if utilities.is_set (Periodical) then
		Periodical_origin = A:ORIGIN('Periodical');								-- get the name of the periodical parameter
		local i;
		Periodical, i = utilities.strip_apostrophe_markup (Periodical);			-- strip apostrophe markup so that metadata isn't contaminated 
		if i then																-- non-zero when markup was stripped so emit an error message
			utilities.set_message ('err_apostrophe_markup', {Periodical_origin});
		end
	end

	if 'mailinglist' == config.CitationClass then								-- special case for {{cite mailing list}}
		if utilities.is_set (Periodical) and utilities.is_set (A ['MailingList']) then	-- both set emit an error TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', Periodical_origin) .. ' and ' .. utilities.wrap_style ('parameter', 'mailinglist')});
		end

		Periodical = A ['MailingList'];											-- error or no, set Periodical to |mailinglist= value because this template is {{cite mailing list}}
		Periodical_origin = A:ORIGIN('MailingList');
	end

	local ScriptPeriodical = A['ScriptPeriodical'];

	-- web and news not tested for now because of 
	-- Wikipedia:Administrators%27_noticeboard#Is_there_a_semi-automated_tool_that_could_fix_these_annoying_&quot;Cite_Web&quot;_errors?
	if not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) then	-- 'periodical' templates require periodical parameter
	--	local p = {['journal'] = 'journal', ['magazine'] = 'magazine', ['news'] = 'newspaper', ['web'] = 'website'};	-- for error message
		local p = {['journal'] = 'journal', ['magazine'] = 'magazine'};			-- for error message
		if p[config.CitationClass]  then
			utilities.set_message ('err_missing_periodical', {config.CitationClass, p[config.CitationClass]});
		end
	end
	
	local Volume;
	local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) then
			if not utilities.in_array (Periodical_origin, {'website', 'mailinglist'}) then	-- {{citation}} does not render volume for these 'periodicals' --TODO: move 'array' to ~/Configuration
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		elseif utilities.is_set (ScriptPeriodical) then
			if 'script-website' ~= ScriptPeriodical_origin then					-- {{citation}} does not render volume for |script-website=
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		else
			Volume = A['Volume'];												-- and does for non-'periodical' cites
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_volume) then	-- render |volume= for cs1 according to the configuration settings
		Volume = A['Volume'];
	end	
	extra_text_in_vol_iss_check (Volume, A:ORIGIN ('Volume'), 'v');	

	local Issue;
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) and utilities.in_array (Periodical_origin, {'journal', 'magazine', 'newspaper', 'periodical', 'work'}) or	-- {{citation}} renders issue for these 'periodicals'--TODO: move 'array' to ~/Configuration
			utilities.is_set (ScriptPeriodical) and utilities.in_array (ScriptPeriodical_origin, {'script-journal', 'script-magazine', 'script-newspaper', 'script-periodical', 'script-work'}) then -- and these 'script-periodicals'
				Issue = utilities.hyphen_to_dash (A['Issue']);
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_issue) then	-- conference &amp; map books do not support issue; {{citation}} listed here because included in settings table
		if not (utilities.in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical))) then
			Issue = utilities.hyphen_to_dash (A['Issue']);
		end
	end
	extra_text_in_vol_iss_check (Issue, A:ORIGIN ('Issue'), 'i');	

	local Page;
	local Pages;
	local At;
	if not utilities.in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = utilities.hyphen_to_dash (A['Pages']);	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = place_check (A['PublicationPlace'], A:ORIGIN('PublicationPlace'));
	local Place = place_check (A['Place'], A:ORIGIN('Place'));
	
	local PublisherName = A['PublisherName'];
	local PublisherName_origin = A:ORIGIN('PublisherName');
	if utilities.is_set (PublisherName) then
		local i = 0;
		PublisherName, i = utilities.strip_apostrophe_markup (PublisherName);	-- strip apostrophe markup so that metadata isn't contaminated; publisher is never italicized
		if i then																-- non-zero when markup was stripped so emit an error message
			utilities.set_message ('err_apostrophe_markup', {PublisherName_origin});
		end
	end

	local Newsgroup = A['Newsgroup'];											-- TODO: strip apostrophe markup?
	local Newsgroup_origin = A:ORIGIN('Newsgroup');	

	if 'newsgroup' == config.CitationClass then
		if utilities.is_set (PublisherName) then								-- general use parameter |publisher= not allowed in cite newsgroup
			utilities.set_message ('err_parameter_ignored', {PublisherName_origin});
		end

		PublisherName = nil;													-- ensure that this parameter is unset for the time being; will be used again after COinS
	end

	local URL = A['URL'];														-- TODO: better way to do this for URL, ChapterURL, and MapURL?
	local UrlAccess = is_valid_parameter_value (A['UrlAccess'], A:ORIGIN('UrlAccess'), cfg.keywords_lists['url-access'], nil);
	
	if not utilities.is_set (URL) and utilities.is_set (UrlAccess) then
		UrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', 'url');
	end
	
	local ChapterURL = A['ChapterURL'];
	local ChapterUrlAccess = is_valid_parameter_value (A['ChapterUrlAccess'], A:ORIGIN('ChapterUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (ChapterURL) and utilities.is_set (ChapterUrlAccess) then
		ChapterUrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', {A:ORIGIN('ChapterUrlAccess'):gsub ('%-access', '')});
	end

	local MapUrlAccess = is_valid_parameter_value (A['MapUrlAccess'], A:ORIGIN('MapUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (A['MapURL']) and utilities.is_set (MapUrlAccess) then
		MapUrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', {'map-url'});
	end

	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local no_tracking_cats = is_valid_parameter_value (A['NoTracking'], A:ORIGIN('NoTracking'), cfg.keywords_lists['yes_true_y'], nil);

	-- check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not utilities.is_set (no_tracking_cats) then								-- ignore if we are already not going to categorize this page
		if utilities.in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _, v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end
																				-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	utilities.select_one (args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'err_redundant_parameters');	-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, A:ORIGIN('Page'), Pages, A:ORIGIN('Pages'), At);

	local NoPP = is_valid_parameter_value (A['NoPP'], A:ORIGIN('NoPP'), cfg.keywords_lists['yes_true_y'], nil);

	if utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- both |publication-place= and |place= (|location=) allowed if different
		utilities.add_prop_cat ('location-test');								-- add property cat to evaluate how often PublicationPlace and Place are used together
		if PublicationPlace == Place then
			Place = '';															-- unset; don't need both if they are the same
		end
	elseif not utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- when only |place= (|location=) is set ...
		PublicationPlace = Place;												-- promote |place= (|location=) to |publication-place
	end

	if PublicationPlace == Place then Place = ''; end							-- don't need both if they are the same
	
	local URL_origin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL_origin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ScriptChapter = A['ScriptChapter'];
	local ScriptChapter_origin = A:ORIGIN ('ScriptChapter');
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local TransChapter = A['TransChapter'];
	local TransChapter_origin = A:ORIGIN ('TransChapter');
	local TransTitle = A['TransTitle'];
	local ScriptTitle = A['ScriptTitle'];
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia= and |title= then map |title= to |article= and |encyclopedia= to |title=
		|encyclopedia= and |article= then map |encyclopedia= to |title=

		|trans-title= maps to |trans-chapter= when |title= is re-mapped
		|url= maps to |chapter-url= when |title= is remapped
	
	All other combinations of |encyclopedia=, |title=, and |article= are not modified
	
	]]

	local Encyclopedia = A['Encyclopedia'];										-- used as a flag by this module and by ~/COinS

	if utilities.is_set (Encyclopedia) then										-- emit error message when Encyclopedia set but template is other than {{cite encyclopedia}} or {{citation}}
		if 'encyclopaedia' ~= config.CitationClass and 'citation' ~= config.CitationClass then
			utilities.set_message ('err_parameter_ignored', {A:ORIGIN ('Encyclopedia')});
			Encyclopedia = nil;													-- unset because not supported by this template
		end
	end

	if ('encyclopaedia' == config.CitationClass) or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Periodical) and utilities.is_set (Encyclopedia) then	-- when both set emit an error TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', A:ORIGIN ('Encyclopedia')) .. ' and ' .. utilities.wrap_style ('parameter', Periodical_origin)});
		end

		if utilities.is_set (Encyclopedia) then
			Periodical = Encyclopedia;											-- error or no, set Periodical to Encyclopedia; allow periodical without encyclopedia
			Periodical_origin = A:ORIGIN ('Encyclopedia');
		end

		if utilities.is_set (Periodical) then									-- Periodical is set when |encyclopedia= is set
			if utilities.is_set (Title) or utilities.is_set (ScriptTitle) then
				if not utilities.is_set (Chapter) then
					Chapter = Title;											-- |encyclopedia= and |title= are set so map |title= to |article= and |encyclopedia= to |title=
					ScriptChapter = ScriptTitle;
					ScriptChapter_origin = A:ORIGIN('ScriptTitle')
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterURL_origin = URL_origin;

					ChapterUrlAccess = UrlAccess;

					if not utilities.is_set (ChapterURL) and utilities.is_set (TitleLink) then
						Chapter = utilities.make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			elseif utilities.is_set (Chapter) or utilities.is_set (ScriptChapter) then								-- |title= not set
				Title = Periodical;												-- |encyclopedia= set and |article= set so map |encyclopedia= to |title=
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- special case for cite techreport.
	local ID = A['ID'];
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if utilities.is_set (A['Number']) then									-- cite techreport uses 'number', which other citations alias to 'issue'
			if not utilities.is_set (ID) then									-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'id') .. ' and ' .. utilities.wrap_style ('parameter', 'number')});
			end
		end	
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	local ChapterLink -- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local Conference = A['Conference'];
	local BookTitle = A['BookTitle'];
	local TransTitle_origin = A:ORIGIN ('TransTitle');
	if 'conference' == config.CitationClass then
		if utilities.is_set (BookTitle) then
			Chapter = Title;
			Chapter_origin = 'title';
	--		ChapterLink = TitleLink;											-- |chapter-link= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			URL_origin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			TransChapter_origin = TransTitle_origin;
			Title = BookTitle;
			Format = '';
	--		TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end
	
	-- CS1/2 mode
	local Mode = is_valid_parameter_value (A['Mode'], A:ORIGIN('Mode'), cfg.keywords_lists['mode'], '');
	-- separator character and postscript
	local sepc, PostScript = set_style (Mode:lower(), A['PostScript'], config.CitationClass);
	-- controls capitalization of certain static text
	local use_lowercase = ( sepc == ',' );
	
	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		if utilities.is_set (Chapter) then										--TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'map') .. ' and ' .. utilities.wrap_style ('parameter', Chapter_origin)});	-- add error message
		end
		Chapter = A['Map'];
		Chapter_origin = A:ORIGIN('Map');
		ChapterURL = A['MapURL'];
		ChapterURL_origin = A:ORIGIN('MapURL');
		TransChapter = A['TransMap'];
		ScriptChapter = A['ScriptMap']
		ScriptChapter_origin = A:ORIGIN('ScriptMap')

		ChapterUrlAccess = MapUrlAccess;
		ChapterFormat = A['MapFormat'];

		Cartography = A['Cartography'];
		if utilities.is_set ( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if utilities.is_set ( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	local Series = A['Series'];
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local SeriesLink = A['SeriesLink'];

		SeriesLink = link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wiki-markup in |series-link= or wiki-markup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if utilities.is_set (Network) then table.insert(n, Network); end
		if utilities.is_set (Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if utilities.is_set (Season) and utilities.is_set (SeriesNumber) then	-- these are mutually exclusive so if both are set TODO: make a function for this and similar?
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'season') .. ' and ' .. utilities.wrap_style ('parameter', 'seriesno')});		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if utilities.is_set (Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if utilities.is_set (SeriesNumber) then table.insert(s, wrap_msg ('seriesnum', SeriesNumber, use_lowercase)); end
			if utilities.is_set (Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ScriptChapter_origin = A:ORIGIN('ScriptTitle');
			ChapterLink = TitleLink;											-- alias |episode-link=
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if utilities.is_set (ChapterLink) and not utilities.is_set (ChapterURL) then	-- link but not URL
				Chapter = utilities.make_wikilink (ChapterLink, Chapter);
			elseif utilities.is_set (ChapterLink) and utilities.is_set (ChapterURL) then	-- if both are set, URL links episode;
				Series = utilities.make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if utilities.is_set (Series) and utilities.is_set (SeriesLink) then
				Series = utilities.make_wikilink (SeriesLink, Series);
			end
			Series = utilities.wrap_style ('italic-title', Series);				-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- handle type parameter for those CS1 citations that have default values
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	if utilities.in_array (config.CitationClass, {'AV-media-notes', 'interview', 'mailinglist', 'map', 'podcast', 'pressrelease', 'report', 'speech', 'techreport', 'thesis'}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if utilities.is_set (Degree) and &quot;Thesis&quot; == TitleType then				-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if utilities.is_set (TitleType) then										-- if type parameter is specified
		TitleType = utilities.substitute ( cfg.messages['type'], TitleType);	-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
	local Date = A['Date'];
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging
	local PublicationDate = A['PublicationDate'];
	local Year = A['Year'];

	if not utilities.is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not utilities.is_set (Date) and utilities.is_set (PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]

	local DF = is_valid_parameter_value (A['DF'], A:ORIGIN('DF'), cfg.keywords_lists['df'], '');
	if not utilities.is_set (DF) then
		DF = cfg.global_df;														-- local |df= if present overrides global df set by {{use xxx date}} template
	end

	local ArchiveURL;
	local ArchiveDate;
	local ArchiveFormat = A['ArchiveFormat'];

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	
	ArchiveURL, ArchiveDate = is_unique_archive_url (ArchiveURL, URL, ChapterURL, A:ORIGIN('ArchiveURL'), ArchiveDate);		-- add error message when URL or ChapterURL == ArchiveURL

	
	local AccessDate = A['AccessDate'];
	local LayDate = A['LayDate'];
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification
	local DoiBroken = A['DoiBroken'];
	local Embargo = A['Embargo'];
	local anchor_year;															-- used in the CITEREF identifier
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val = AccessDate, name = A:ORIGIN ('AccessDate')},
			['archive-date'] = {val = ArchiveDate, name = A:ORIGIN ('ArchiveDate')},
			['date'] = {val = Date, name = Date_origin},
			['doi-broken-date'] = {val = DoiBroken, name = A:ORIGIN ('DoiBroken')},
			['pmc-embargo-date'] = {val = Embargo, name = A:ORIGIN ('Embargo')},
			['lay-date'] = {val = LayDate, name = A:ORIGIN ('LayDate')},
			['publication-date'] = {val = PublicationDate, name = A:ORIGIN ('PublicationDate')},
			['year'] = {val = Year, name = A:ORIGIN ('Year')},
			};

		local error_list = {};
		anchor_year, Embargo = validation.dates(date_parameters_list, COinS_date, error_list);

-- start temporary Julian / Gregorian calendar uncertainty categorization
		if COinS_date.inter_cal_cat then
			utilities.add_prop_cat ('jul-greg-uncertainty');
		end
-- end temporary Julian / Gregorian calendar uncertainty categorization

		if utilities.is_set (Year) and utilities.is_set (Date) then				-- both |date= and |year= not normally needed; 
			validation.year_date_check (Year, A:ORIGIN ('Year'), Date, A:ORIGIN ('Date'), error_list);
		end
		
		if 0 == #error_list then												-- error free dates only; 0 when error_list is empty
			local modified = false;												-- flag
			
			if utilities.is_set (DF) then										-- if we need to reformat dates
				modified = validation.reformat_dates (date_parameters_list, DF);	-- reformat to DF format, use long month names if appropriate
			end

			if true == validation.date_hyphen_to_dash (date_parameters_list) then	-- convert hyphens to dashes where appropriate
				modified = true;
				utilities.set_message ('maint_date_format');					-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language; not supported at en.wiki
			if cfg.date_name_auto_xlate_enable and validation.date_name_xlate (date_parameters_list, cfg.date_digit_auto_xlate_enable ) then
				utilities.set_message ('maint_date_auto_xlated');				-- add maint cat
				modified = true;
			end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				LayDate = date_parameters_list['lay-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end
		else
			utilities.set_message ('err_bad_date', {utilities.make_sep_list (#error_list, error_list)});	-- add this error message
		end
	end	-- end of do

	local ID_list = {};															-- sequence table of rendered identifiers
	local ID_list_coins = {};													-- table of identifiers and their values from args; key is same as cfg.id_handlers's key
	local Class = A['Class'];													-- arxiv class identifier
	
	local ID_support = {
		{A['ASINTLD'], 'ASIN', 'err_asintld_missing_asin', A:ORIGIN ('ASINTLD')},				
		{DoiBroken, 'DOI', 'err_doibroken_missing_doi', A:ORIGIN ('DoiBroken')},
		{Embargo, 'PMC', 'err_embargo_missing_pmc', A:ORIGIN ('Embargo')},
		}

	ID_list, ID_list_coins = identifiers.identifier_lists_get (args, {DoiBroken = DoiBroken, ASINTLD = A['ASINTLD'], Embargo = Embargo, Class = Class}, ID_support);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite ssrn}}, before generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then
		if not utilities.is_set (ID_list_coins[config.CitationClass:upper()]) then 	-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp; |citeseerx= required for their templates
			utilities.set_message ('err_' .. config.CitationClass .. '_missing');	-- add error message
		end

		Periodical = ({['arxiv'] = 'arXiv', ['biorxiv'] = 'bioRxiv', ['citeseerx'] = 'CiteSeerX', ['ssrn'] = 'Social Science Research Network'})[config.CitationClass];
	end

	-- Link the title of the work if no |url= was provided, but we have a |pmc= or a |doi= with |doi-access=free

	if config.CitationClass == &quot;journal&quot; and not utilities.is_set (URL) and not utilities.is_set (TitleLink) and not utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) then -- TODO: remove 'none' once existing citations have been switched to 'off', so 'none' can be used as token for &quot;no title&quot; instead
		if 'none' ~= cfg.keywords_xlate[auto_select] then						-- if auto-linking not disabled
 	 		if identifiers.auto_link_urls[auto_select] then						-- manual selection
		 		URL = identifiers.auto_link_urls[auto_select];					-- set URL to be the same as identifier's external link
 				URL_origin = cfg.id_handlers[auto_select:upper()].parameters[1];	-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['pmc'] then						-- auto-select PMC
				URL = identifiers.auto_link_urls['pmc'];						-- set URL to be the same as the PMC external link if not embargoed
				URL_origin = cfg.id_handlers['PMC'].parameters[1];				-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['doi'] then						-- auto-select DOI
				URL = identifiers.auto_link_urls['doi'];
				URL_origin = cfg.id_handlers['DOI'].parameters[1];
			end
 	 	end

		if utilities.is_set (URL) and utilities.is_set (AccessDate) then		-- access date requires |url=; identifier-created URL is not |url=
			utilities.set_message ('err_accessdate_missing_url');				-- add an error message
			AccessDate = '';													-- unset
		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not utilities.is_set (Title) and not utilities.is_set (TransTitle) and not utilities.is_set (ScriptTitle) then	-- has special case for cite episode
		utilities.set_message ('err_citation_missing_title', {'episode' == config.CitationClass and 'series' or 'title'});
	end

	if utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) and
			utilities.in_array (config.CitationClass, {'journal', 'citation'}) and
			(utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and
			('journal' == Periodical_origin or 'script-journal' == ScriptPeriodical_origin) then	-- special case for journal cites
				Title = '';														-- set title to empty string
				utilities.set_message ('maint_untitled');						-- add maint cat
	end

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Chapter) and utilities.is_set (Title) and utilities.is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end
	
	local QuotePage = A['QuotePage'];
	local QuotePages = utilities.hyphen_to_dash (A['QuotePages']);

	-- this is the function call to COinS()
	local OCinSoutput = metadata.COinS({
		['Periodical'] = utilities.strip_apostrophe_markup (Periodical),		-- no markup in the metadata
		['Encyclopedia'] = Encyclopedia,										-- just a flag; content ignored by ~/COinS
		['Chapter'] = metadata.make_coins_title (coins_chapter, ScriptChapter),	-- Chapter and ScriptChapter stripped of bold / italic / accept-as-written markup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = metadata.make_coins_title (coins_title, ScriptTitle),		-- Title and ScriptTitle stripped of bold / italic / accept-as-written markup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Quarter'] = COinS_date.rftquarter,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = coins_pages or metadata.get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At, QuotePage, QuotePages}, 7)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName or Newsgroup,							-- any apostrophe markup already removed from PublisherName
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list_coins,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, and {{cite ssrn}} AFTER generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, CiteSeerX, or ssrn now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass and utilities.is_set (Newsgroup) then
		PublisherName = utilities.substitute (cfg.messages['newsgroup'], external_link( 'news:' .. Newsgroup, Newsgroup, Newsgroup_origin, nil ));
	end

	local Editors;
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	local Contributors;															-- assembled contributors name list
	local contributor_etal;
	local Translators;															-- assembled translators name list
	local translator_etal;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	local Interviewers;															
	local interviewers_list = {};					
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters
	local interviewer_etal;
	
	-- Now perform various field 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.
	do
		local last_first_list;
		local control = { 
			format = NameListStyle,												-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_names (A['DisplayEditors'], #e, 'editors', editor_etal, A:ORIGIN ('DisplayEditors'));
			Editors, EditorCount = list_people (control, e, editor_etal);

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum, interviewer_etal = get_display_names (A['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal, A:ORIGIN ('DisplayInterviewers'));
			Interviewers = list_people (control, interviewers_list, interviewer_etal);
		end
		do																		-- now do translators
			control.maximum, translator_etal = get_display_names (A['DisplayTranslators'], #t, 'translators', translator_etal, A:ORIGIN ('DisplayTranslators'));
			Translators = list_people (control, t, translator_etal);
		end
		do																		-- now do contributors
			control.maximum, contributor_etal = get_display_names (A['DisplayContributors'], #c, 'contributors', contributor_etal, A:ORIGIN ('DisplayContributors'));
			Contributors = list_people (control, c, contributor_etal);
		end
		do																		-- now do authors
			control.maximum, author_etal = get_display_names (A['DisplayAuthors'], #a, 'authors', author_etal, A:ORIGIN ('DisplayAuthors'));

			last_first_list = list_people (control, a, author_etal);

			if utilities.is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors');	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if utilities.is_set (Authors) and utilities.is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not utilities.is_set (URL) then
		if utilities.in_array (config.CitationClass, {&quot;web&quot;, &quot;podcast&quot;, &quot;mailinglist&quot;}) or		-- |url= required for cite web, cite podcast, and cite mailinglist
			('citation' == config.CitationClass and ('website' == Periodical_origin or 'script-website' == ScriptPeriodical_origin)) then	-- and required for {{citation}} with |website= or |script-website=
				utilities.set_message ('err_cite_web_url');
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if utilities.is_set (AccessDate) and not utilities.is_set (ChapterURL) then		-- ChapterURL may be set when URL is not set;
			utilities.set_message ('err_accessdate_missing_url');
			AccessDate = '';
		end
	end

	local UrlStatus = is_valid_parameter_value (A['UrlStatus'], A:ORIGIN('UrlStatus'), cfg.keywords_lists['url-status'], '');
	local OriginalURL
	local OriginalURL_origin
	local OriginalFormat
	local OriginalAccess;
	UrlStatus = UrlStatus:lower();												-- used later when assembling archived text
	if utilities.is_set ( ArchiveURL ) then
		if utilities.is_set (ChapterURL) then 									-- if chapter-url= is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURL_origin = ChapterURL_origin;								-- name of |chapter-url= parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=

			if 'live' ~= UrlStatus then
				ChapterURL = ArchiveURL											-- swap-in the archive's URL
				ChapterURL_origin = A:ORIGIN('ArchiveURL')						-- name of |archive-url= parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived URLs
			end
		elseif utilities.is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURL_origin = URL_origin;									-- name of URL parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;

			if 'live' ~= UrlStatus then											-- if URL set then |archive-url= applies to it
				URL = ArchiveURL												-- swap-in the archive's URL
				URL_origin = A:ORIGIN('ArchiveURL')								-- name of archive URL parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived URLs
			end
		end
	elseif utilities.is_set (UrlStatus) then									-- if |url-status= is set when |archive-url= is not set
 		utilities.set_message ('maint_url_status');								-- add maint cat
	end

	if utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) then
			local chap_param;
			if utilities.is_set (Chapter) then									-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif utilities.is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif utilities.is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif utilities.is_set (ScriptChapter) then
				chap_param = ScriptChapter_origin;
			else utilities.is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if utilities.is_set (chap_param) then								-- if we found one
				utilities.set_message ('err_chapter_ignored', {chap_param});	-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if utilities.is_set (Contribution) and 0 &lt; #c then						-- if this is a contribution with contributor(s)
			if utilities.in_array (Contribution:lower(), cfg.keywords_lists.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, ScriptChapter_origin, Chapter, Chapter_origin, TransChapter, TransChapter_origin, ChapterURL, ChapterURL_origin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if utilities.is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and utilities.is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter .. sepc .. ' ';
		elseif utilities.is_set (ChapterFormat) then							-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title
	local plain_title = false;
	local accept_title;
	Title, accept_title = utilities.has_accept_as_written (Title, true);		-- remove accept-this-as-written markup when it wraps all of &lt;Title&gt;
	if accept_title and ('' == Title) then										-- only support forced empty for now &quot;(())&quot;
		Title = cfg.messages['notitle'];										-- replace by predefined &quot;No title&quot; message
			-- TODO: utilities.set_message ( 'err_redundant_parameters', ...);	-- issue proper error message instead of muting	 
			ScriptTitle = '';													-- just mute for now	 
			TransTitle = '';													-- just mute for now
 		plain_title = true;														-- suppress text decoration for descriptive title
		utilities.set_message ('maint_untitled');								-- add maint cat
	end

	if not accept_title then													-- &lt;Title&gt; not wrapped in accept-as-written markup
		if '...' == Title:sub (-3) then											-- if ellipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%' .. sepc .. '$', '');			-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end

		if utilities.is_set (ArchiveURL) and is_archived_copy (Title) then
			utilities.set_message ('maint_archived_copy');						-- add maintenance category before we modify the content of Title
		end

		if is_generic ('generic_titles', Title) then
			utilities.set_message ('err_generic_title');						-- set an error message
		end
	end

	if (not plain_title) and (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) or
		('map' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)))) then		-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from module provided quote marks
			Title = utilities.wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle, 'script-title');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
			TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );
	elseif plain_title or ('report' == config.CitationClass) then				-- no styling for cite report and descriptive titles (otherwise same as above)
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );	-- for cite report, use this form for trans-title
	else
		Title = utilities.wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-italic-title', TransTitle);
	end

	if utilities.is_set (TransTitle) then
		if utilities.is_set (Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			utilities.set_message ('err_trans_missing_title', {'title'});
		end
	end

	if utilities.is_set (Title) then											-- TODO: is this the right place to be making Wikisource URLs?
		if utilities.is_set (TitleLink) and utilities.is_set (URL) then
			utilities.set_message ('err_wikilink_in_url');						-- set an error message because we can't have both
			TitleLink = '';														-- unset
		end
	
		if not utilities.is_set (TitleLink) and utilities.is_set (URL) then
			Title = external_link (URL, Title, URL_origin, UrlAccess) .. TransTitle .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif utilities.is_set (TitleLink) and not utilities.is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle;
			else
				Title = utilities.make_wikilink (TitleLink, Title) .. TransTitle;
			end
		else
			local ws_url, ws_label, L;											-- Title has italic or quote markup by the time we get here which causes is_wikilink() to return 0 (not a wikilink)
			ws_url, ws_label, L = wikisource_url_make (Title:gsub('^[\'&quot;]*(.-)[\'&quot;]*$', '%1'));	-- make ws URL from |title= interwiki link (strip italic or quote markup); link portion L becomes tooltip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle;
			else
				Title = Title .. TransTitle;
			end
		end
	else
		Title = TransTitle;
	end

	if utilities.is_set (Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	local ConferenceURL_origin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	if utilities.is_set (Conference) then
		if utilities.is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURL_origin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif utilities.is_set (ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURL_origin, nil );
	end

	local Position = '';
	if not utilities.is_set (Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if utilities.is_set (Minutes) then
			if utilities.is_set (Time) then		--TODO: make a function for this and similar?
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'minutes') .. ' and ' .. utilities.wrap_style ('parameter', 'time')});
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if utilities.is_set (Time) then
				local TimeCaption = A['TimeCaption']
				if not utilities.is_set (TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = utilities.is_set (At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = utilities.is_set (Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Sections = A['Sections'];											-- Section (singular) is an alias of Chapter so set earlier
		local Inset = A['Inset'];
		
		if utilities.is_set ( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if utilities.is_set ( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif utilities.is_set ( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	local Others = A['Others'];
	if utilities.is_set (Others) and 0 == #a and 0 == #e then					-- add maint cat when |others= has value and used without |author=, |editor=
		if config.CitationClass == &quot;AV-media-notes&quot;
		or config.CitationClass == &quot;audio-visual&quot; then							-- special maint for AV/M which has a lot of 'false' positives right now
			utilities.set_message ('maint_others_avm')
		else
			utilities.set_message ('maint_others');
		end
	end
	Others = utilities.is_set (Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if utilities.is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if utilities.is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	local TitleNote = A['TitleNote'];
	TitleNote = utilities.is_set (TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if utilities.is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%n?%.?$') or Edition:match ('%f[%a][Ee]dition$') then -- Ed, ed, Ed., ed., Edn, edn, Edn., edn.
			utilities.set_message ('err_extra_text_edition');					 -- add error message
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = utilities.is_set (Series) and wrap_msg ('series', {sepc, Series}) or &quot;&quot;;	-- not the same as SeriesNum
	local Agency = A['Agency'];
	Agency = utilities.is_set (Agency) and wrap_msg ('agency', {sepc, Agency}) or &quot;&quot;;
	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	if utilities.is_set (AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = utilities.substitute (retrv_text, AccessDate);				-- add retrieved text

		AccessDate = utilities.substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if utilities.is_set (ID) then ID = sepc .. &quot; &quot; .. ID; end
	
	local Docket = A['Docket'];
   	if &quot;thesis&quot; == config.CitationClass and utilities.is_set (Docket) then
		ID = sepc .. &quot; Docket &quot; .. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and utilities.is_set (Docket) then		-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	if utilities.is_set (URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URL_origin, UrlAccess );
	end

	local Quote = A['Quote'];
	local TransQuote = A['TransQuote'];
	local ScriptQuote = A['ScriptQuote'];
	if utilities.is_set (Quote) or utilities.is_set (TransQuote) or utilities.is_set (ScriptQuote) then

		if utilities.is_set (Quote) then
			if Quote:sub(1, 1) == '&quot;' and Quote:sub(-1, -1) == '&quot;' then			-- if first and last characters of quote are quote marks
				Quote = Quote:sub(2, -2);										-- strip them off
			end
		end

		Quote = utilities.wrap_style ('quoted-text', Quote );					-- wrap in &lt;q&gt;...&lt;/q&gt; tags
	
		if utilities.is_set (ScriptQuote) then
			Quote = script_concatenate (Quote, ScriptQuote, 'script-quote');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after quote is wrapped
		end

		if utilities.is_set (TransQuote) then
			if TransQuote:sub(1, 1) == '&quot;' and TransQuote:sub(-1, -1) == '&quot;' then -- if first and last characters of |trans-quote are quote marks
				TransQuote = TransQuote:sub(2, -2); -- strip them off
			end
			Quote = Quote .. &quot; &quot; .. utilities.wrap_style ('trans-quoted-title', TransQuote );
		end

		if utilities.is_set (QuotePage) or utilities.is_set (QuotePages) then	-- add page prefix
			local quote_prefix = '';
			if utilities.is_set (QuotePage) then
				extra_text_in_page_check (QuotePage, 'quote-page');				-- add to maint cat if |quote-page= value begins with what looks like p., pp., etc.
				if not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePage}), '', '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePage}), '', '', '';
				end
			elseif utilities.is_set (QuotePages) then
				extra_text_in_page_check (QuotePages, 'quote-pages');			-- add to maint cat if |quote-pages= value begins with what looks like p., pp., etc.
				if tonumber(QuotePages) ~= nil and not NoPP then				-- if only digits, assume single page
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePages}), '', '';
				elseif not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['pp-prefix'], {sepc, QuotePages}), '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePages}), '', '';
				end
			end
                        
			Quote = quote_prefix .. &quot;: &quot; .. Quote;
		else
			Quote = sepc .. &quot; &quot; .. Quote;
		end

		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	-- We check length of PostScript here because it will have been nuked by
	-- the quote parameters. We'd otherwise emit a message even if there wasn't
	-- a displayed postscript.
	-- TODO: Should the max size (1) be configurable?
	-- TODO: Should we check a specific pattern?
	if utilities.is_set(PostScript) and mw.ustring.len(PostScript) &gt; 1 then
		utilities.set_message ('maint_postscript')
	end
	
	local Archived;
	if utilities.is_set (ArchiveURL) then
		local arch_text;
		if not utilities.is_set (ArchiveDate) then
			utilities.set_message ('err_archive_missing_date');
			ArchiveDate = '';													-- empty string for concatenation
		end
		if &quot;live&quot; == UrlStatus then
			arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if utilities.is_set (ArchiveDate) then
				Archived = sepc .. ' ' .. utilities.substitute ( cfg.messages['archived-live'],
					{external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil) .. ArchiveFormat, ArchiveDate } );
			else
				Archived = '';
			end
			if not utilities.is_set (OriginalURL) then
				utilities.set_message ('err_archive_missing_url');
				Archived = '';													-- empty string for concatenation
			end
		elseif utilities.is_set (OriginalURL) then								-- UrlStatus is empty, 'dead', 'unfit', 'usurped', 'bot: unknown'
			if utilities.in_array (UrlStatus, {'unfit', 'usurped', 'bot: unknown'}) then
				arch_text = cfg.messages['archived-unfit'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. ' ' .. arch_text .. ArchiveDate;				-- format already styled
				if 'bot: unknown' == UrlStatus then
					utilities.set_message ('maint_bot_unknown');				-- and add a category if not already added
				else
					utilities.set_message ('maint_unfit');						-- and add a category if not already added
				end
			else																-- UrlStatus is empty, 'dead'
				arch_text = cfg.messages['archived-dead'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				if utilities.is_set (ArchiveDate) then
					Archived = sepc .. &quot; &quot; .. utilities.substitute ( arch_text,
						{ external_link( OriginalURL, cfg.messages['original'], OriginalURL_origin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
				else
					Archived = '';												-- unset for concatenation
				end
			end	
		else																	-- OriginalUrl not set
			arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			utilities.set_message ('err_archive_missing_url');
			Archived = '';														-- empty string for concatenation
		end
	elseif utilities.is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = '';
	end
	
	local Lay = '';
	local LaySource = A['LaySource'];
	local LayURL = A['LayURL'];
	local LayFormat = A['LayFormat'];
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	if utilities.is_set (LayURL) then
		if utilities.is_set (LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if utilities.is_set (LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. utilities.safe_for_italics (LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif utilities.is_set (LayFormat) then									-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	local TranscriptURL = A['TranscriptURL']
	local TranscriptFormat = A['TranscriptFormat'];
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');
	local Transcript = A['Transcript'];
	local TranscriptURL_origin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL
	if utilities.is_set (Transcript) then
		if utilities.is_set (TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURL_origin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif utilities.is_set (TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURL_origin, nil );
	end

	local Publisher;
	if utilities.is_set (PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if utilities.is_set (PublisherName) then
		if utilities.is_set (PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif utilities.is_set (PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	local TransPeriodical =  A['TransPeriodical'];
	local TransPeriodical_origin =  A:ORIGIN ('TransPeriodical');
	-- Several of the above rely upon detecting this as nil, so do it last.
	if (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical)) then
		if utilities.is_set (Title) or utilities.is_set (TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		else 
			Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		end
	end
	
	local Language = A['Language'];
	if utilities.is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc.
	else
		Language='';															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then									-- cite speech only
		TitleNote = TitleType;													-- move TitleType to TitleNote so that it renders ahead of |event=
		TitleType = '';															-- and unset

		if utilities.is_set (Periodical) then									-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if utilities.is_set (Conference) then								-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;							-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
		if utilities.is_set (Others) then Others = safe_join ({Others, sepc .. &quot; &quot;}, sepc) end		-- add terminal punctuation &amp; space; check for dup sepc; TODO why do we need to do this here?
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (Periodical) then		-- special cases for book cites
		if utilities.is_set (Contributors) then									-- when we are citing foreword, preface, introduction, etc.
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if utilities.is_set (Chapter) then										-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif utilities.is_set (Periodical) then								-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local Via = A['Via'];
	Via = utilities.is_set (Via) and  wrap_msg ('via', Via) or '';
	local idcommon;
	if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then	-- special case for cite AV media &amp; cite episode position transcript
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, Lay, Quote }, sepc );
	else
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, Lay, Quote }, sepc );
	end
	
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	local OrigDate = A['OrigDate'];
	OrigDate = utilities.is_set (OrigDate) and wrap_msg ('origdate', OrigDate) or '';
	if utilities.is_set (Date) then
		if utilities.is_set (Authors) or utilities.is_set (Editors) then		-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date .. &quot;)&quot; .. OrigDate .. sepc .. &quot; &quot;;				-- in parentheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon, -1, -1) == sepc) then						-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigDate;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigDate;							-- Date begins with sepc
			end
		end
	end	
	if utilities.is_set (Authors) then
		if (not utilities.is_set (Date)) then									-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if utilities.is_set (Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then
					in_text = in_text:lower()									-- lowercase for cs2
				end
			end
			if EditorCount &lt;= 1 then
				post_text = &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot;;				-- be consistent with no-author, no-date case
			else
				post_text = &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot;;
			end
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Contributors) then									-- book cite and we're citing the intro, preface, etc.
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if utilities.is_set (Editors) and utilities.is_set (Date) then		-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not utilities.is_set (Date)) then								-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif utilities.is_set (Editors) then
		if utilities.is_set (Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if utilities.is_set (PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc ); 								-- Deals with italics, spaces, etc.
		text = text:sub(1, -sepc:len() - 1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite&gt; element
	local options_t = {};
	options_t.class = cite_class_attribute_make (config.CitationClass, Mode);

	local Ref = is_valid_parameter_value (A['Ref'], A:ORIGIN('Ref'), cfg.keywords_lists['ref'], nil, true);	-- nil when |ref=harv; A['Ref'] else

	if 'none' ~= cfg.keywords_xlate[(Ref and Ref:lower()) or ''] then
		local namelist_t = {};													-- holds selected contributor, author, editor name list
		local year = first_set ({Year, anchor_year}, 2);						-- Year first for legacy citations and for YMD dates that require disambiguation

		if #c &gt; 0 then															-- if there is a contributor list
			namelist_t = c;														-- select it
		elseif #a &gt; 0 then														-- or an author list
			namelist_t = a;
		elseif #e &gt; 0 then														-- or an editor list
			namelist_t = e;
		end
		local citeref_id;
		if #namelist_t &gt; 0 then													-- if there are names in namelist_t
			citeref_id = make_citeref_id (namelist_t, year);					-- go make the CITEREF anchor
			if mw.uri.anchorEncode (citeref_id) == ((Ref and mw.uri.anchorEncode (Ref)) or '') then	-- Ref may already be encoded (by {{sfnref}}) so citeref_id must be encoded before comparison
				utilities.set_message ('maint_ref_duplicates_default');
			end
		else
			citeref_id = '';													-- unset
		end
		options_t.id = Ref or citeref_id;
	end

	if string.len (text:gsub('%b&lt;&gt;', '')) &lt;= 2 then								-- remove html and html-like tags; then get length of what remains; 
		z.error_cats_t = {};													-- blank the categories list
		z.error_msgs_t = {};													-- blank the error messages list
		OCinSoutput = nil;														-- blank the metadata string
		text = '';																-- blank the the citation
		utilities.set_message ('err_empty_citation');							-- set empty citation message and category
	end
	
	local render_t = {};														-- here we collect the final bits for concatenation into the rendered citation

	if utilities.is_set (options_t.id) then										-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render_t, utilities.substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options_t.id), mw.text.nowiki(options_t.class), text}));	-- when |ref= is set or when there is a namelist
	else
		table.insert (render_t, utilities.substitute (cfg.presentation['cite'], {mw.text.nowiki(options_t.class), text}));	-- when |ref=none or when namelist_t empty and |ref= is missing or is empty
	end		

	if OCinSoutput then															-- blanked when citation is 'empty' so don't bother to add boilerplate metadata span
		table.insert (render_t, utilities.substitute (cfg.presentation['ocins'], OCinSoutput));	-- format and append metadata to the citation
	end

	local template_name = ('citation' == config.CitationClass) and 'citation' or 'cite ' .. (cfg.citation_class_map_t[config.CitationClass] or config.CitationClass);
	local template_link = '[[Template:' .. template_name .. '|' .. template_name .. ']]';	-- TODO: if kept, these require some sort of i18n
	local msg_prefix = '&lt;code class=&quot;cs1-code&quot;&gt;{{' .. template_link .. '}}&lt;/code&gt;: ';

	if 0 ~= #z.error_msgs_t then
		mw.addWarning (utilities.substitute (cfg.messages.warning_msg_e, template_link));

		table.insert (render_t, ' ');											-- insert a space between citation and its error messages
		table.sort (z.error_msgs_t);											-- sort the error messages list; sorting includes wrapping &lt;span&gt; and &lt;code&gt; tags; hidden-error sorts ahead of visible-error

		local hidden = true;													-- presume that the only error messages emited by this template are hidden
		for _, v in ipairs (z.error_msgs_t) do									-- spin through the list of error messages
			if v:find ('cs1-visible-error', 1, true) then						-- look for the visible error class name
				hidden = false;													-- found one; so don't hide the error message prefix
				break;															-- and done because no need to look further
			end
		end

		z.error_msgs_t[1] = table.concat ({utilities.error_comment (msg_prefix, hidden), z.error_msgs_t[1]});	-- add error message prefix to first error message to prevent extraneous punctuation
		table.insert (render_t, table.concat (z.error_msgs_t, '; '));			-- make a big string of error messages and add it to the rendering
	end

	if 0 ~= #z.maint_cats_t then
		mw.addWarning (utilities.substitute (cfg.messages.warning_msg_m, template_link));

		table.sort (z.maint_cats_t);											-- sort the maintenance messages list

		local maint_msgs_t = {};												-- here we collect all of the maint messages

		if 0 == #z.error_msgs_t then											-- if no error messages
			table.insert (maint_msgs_t, msg_prefix);							-- insert message prefix in maint message livery
		end
		
		for _, v in ipairs( z.maint_cats_t ) do									-- append maintenance categories
			table.insert (maint_msgs_t, 										-- assemble new maint message and add it to the maint_msgs_t table
				table.concat ({v, ' (', utilities.substitute (cfg.messages[':cat wikilink'], v), ')'})
				);
		end
		table.insert (render_t, utilities.substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs_t, ' ')));	-- wrap the group of maint messages with proper presentation and save
	end

	if not no_tracking_cats then
		for _, v in ipairs (z.error_cats_t) do									-- append error categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
		end
		for _, v in ipairs (z.maint_cats_t) do									-- append maintenance categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
		end
		for _, v in ipairs (z.prop_cats_t) do									-- append properties categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
		end
	end

	return table.concat (render_t);												-- make a big string and done
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class, empty)
	local name = tostring (name);
	local enum_name;															-- for enumerated parameters, is name with enumerator replaced with '#'
	local state;
	local function state_test (state, name)										-- local function to do testing of state values
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			if empty then return nil; end										-- empty deprecated parameters are treated as unknowns
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
		if 'tracked' == state then
			local base_name = name:gsub ('%d', '');								-- strip enumerators from parameter names that have them to get the base name
			utilities.add_prop_cat ('tracked-param', {base_name}, base_name);	-- add a properties category; &lt;base_name&gt; modifies &lt;key&gt;
			return true;
		end
		return nil;
	end		

	if name:find ('#') then														-- # is a cs1|2 reserved character so parameters with # not permitted
		return nil;
	end

	if utilities.in_array (cite_class, whitelist.preprint_template_list ) then	-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[name];
		if true == state_test (state, name) then return true; end

		state = whitelist.preprint_arguments[cite_class][name];					-- look in the parameter-list for the template identified by cite_class
		if true == state_test (state, name) then return true; end

																				-- limited enumerated parameters list
		enum_name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );										-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
		state = whitelist.limited_numbered_arguments[enum_name];
		if true == state_test (state, name) then return true; end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates

	if utilities.in_array (cite_class, whitelist.unique_param_template_list) then 	-- experiment for template-specific parameters for templates that accept parameters from the basic argument list
		state = whitelist.unique_arguments[cite_class][name];					-- look in the template-specific parameter-lists for the template identified by cite_class
		if true == state_test (state, name) then return true; end
	end																			-- if here, fall into general validation
		
	state = whitelist.basic_arguments[name];									-- all other templates; all normal parameters allowed
	if true == state_test (state, name) then return true; end

																				-- all enumerated parameters allowed
	enum_name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
	state = whitelist.numbered_arguments[enum_name];
	if true == state_test (state, name) then return true; end

	return false;																-- not supported because not found or name is set to nil
end


--[=[-------------------------&lt; I N T E R _ W I K I _ C H E C K &gt;----------------------------------------------

check &lt;value&gt; for inter-language interwiki-link markup.  &lt;prefix&gt; must be a MediaWiki-recognized language
code.  when these values have the form (without leading colon):
	[[&lt;prefix&gt;:link|label]] return label as plain-text
	[[&lt;prefix&gt;:link]] return &lt;prefix&gt;:link as plain-text

return value as is else

]=]

local function inter_wiki_check (parameter, value)
	local prefix = value:match ('%[%[(%a+):');									-- get an interwiki prefix if one exists
	local _;
	
	if prefix and cfg.inter_wiki_map[prefix:lower()] then						-- if prefix is in the map, needs preceding colon so
		utilities.set_message ('err_bad_paramlink', parameter);					-- emit an error message
		_, value, _ = utilities.is_wikilink (value);							-- extract label portion from wikilink
	end
	return value;
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe.  There are two tests made:
	{{cite ... |title=Title access-date=2016-03-17}}	-- the first parameter has a value and whitespace separates that value from the missing pipe parameter name
	{{cite ... |title=access-date=2016-03-17}}			-- the first parameter has no value (whitespace after the first = is trimmed by MediaWiki)
cs1|2 shares some parameter names with XML/HTML attributes: class=, title=, etc.  To prevent false positives XML/HTML
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (parameter, value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove XML/HTML tags because attributes: class=, title=, etc.

	capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then										-- if the capture is a valid parameter name
		utilities.set_message ('err_missing_pipe', parameter);
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ P U N C T &gt;--------------------------------------

look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_punc (param, value)
	if 'number' == type (param) then
		return;
	end
	
	param = param:gsub ('%d+', '#');											-- enumerated name-list mask params allow terminal punct; normalize 
	if cfg.punct_skip[param] then
		return;																	-- parameter name found in the skip table so done
	end
	
	if value:match ('[,;:]$') then
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
	if value:match ('^=') then													-- sometimes an extraneous '=' character appears ...
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ U R L &gt;------------------------------------------

look for extraneous url parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_url (url_param_t)
	local url_error_t = {};
	
	check_for_url (url_param_t, url_error_t);									-- extraneous url check
	if 0 ~= #url_error_t then													-- non-zero when there are errors
		table.sort (url_error_t);
		utilities.set_message ('err_param_has_ext_link', {utilities.make_sep_list (#url_error_t, url_error_t)});	-- add this error message
	end
end


--[[--------------------------&lt; C I T A T I O N &gt;--------------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

local function citation(frame)
	Frame = frame;																-- save a copy in case we need to display an error message in preview mode
	is_sandbox = nil ~= string.find (frame:getTitle(), 'sandbox', 1, true);
	local pframe = frame:getParent()
	local styles;
	
	if is_sandbox then															-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		styles = 'Module:Citation/CS1/sandbox/styles.css';
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
		styles = 'Module:Citation/CS1/styles.css';
	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the selected cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	is_preview_mode = not utilities.is_set (frame:preprocess ('{{REVISIONID}}'));

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text;															-- used as a flag

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do											-- get parameters from the {{#invoke}} frame
		config[k] = v;
	--	args[k] = v;															-- crude debug support that allows us to render a citation from module {{#invoke:}}; skips parameter validation; TODO: keep?
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	local empty_unknowns = {};													-- sequence table to hold empty unknown params for error message listing
	for k, v in pairs( pframe.args ) do											-- get parameters from the parent (template) frame
		v = mw.ustring.gsub (v, '^%s*(.-)%s*$', '%1');							-- trim leading/trailing whitespace; when v is only whitespace, becomes empty string
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				if type (k) ~= 'string' then									-- exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text = utilities.set_message ('err_text_ignored', {v});
					end
				elseif validate (k:lower(), config.CitationClass) then 
					error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, k:lower()});	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if is_sandbox then										-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no capture in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = utilities.substitute (param, capture);		-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, param});	-- set the suggestion error message
							else
								error_text = utilities.set_message ('err_parameter_ignored', {k});	-- suggested param not supported by this template
								v = '';											-- unset
							end
						end
					end
					if not utilities.is_set (error_text) then					-- couldn't match with a pattern, is there an explicit suggestion?						
						if (suggestions.suggestions[ k:lower() ] ~= nil) and validate (suggestions.suggestions[ k:lower() ], config.CitationClass) then
							utilities.set_message ('err_parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]});
						else
							utilities.set_message ('err_parameter_ignored', {k});
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
			end

			args[k] = v;														-- save this parameter and its value

		elseif not utilities.is_set (v) then									-- for empty parameters
			if not validate (k, config.CitationClass, true) then				-- is this empty parameter a valid parameter
				k = ('' == k) and '(empty string)' or k;						-- when k is empty string (or was space(s) trimmed to empty string), replace with descriptive text
				table.insert (empty_unknowns, utilities.wrap_style ('parameter', k));	-- format for error message and add to the list
			end
																				-- crude debug support that allows us to render a citation from module {{#invoke:}} TODO: keep?
	--	elseif args[k] ~= nil or (k == 'postscript') then						-- when args[k] has a value from {{#invoke}} frame (we don't normally do that)
	--		args[k] = v;														-- overwrite args[k] with empty string from pframe.args[k] (template frame); v is empty string here
		end																		-- not sure about the postscript bit; that gets handled in parameter validation; historical artifact?
	end	

	if 0 ~= #empty_unknowns then												-- create empty unknown error message
		utilities.set_message ('err_param_unknown_empty', {
			1 == #empty_unknowns and '' or 's',
			utilities.make_sep_list (#empty_unknowns, empty_unknowns)
			});
	end

	local url_param_t = {};

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);											-- look for invisible characters
		end
		has_extraneous_punc (k, v);												-- look for extraneous terminal punctuation in parameter values
		missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?
		args[k] = inter_wiki_check (k, v);										-- when language interwiki-linked parameter missing leading colon replace with wiki-link label

		if 'string' == type (k) and not cfg.url_skip[k] then					-- when parameter k is not positional and not in url skip table
			url_param_t[k] = v;													-- make a parameter/value list for extraneous url check
		end
	end

	has_extraneous_url (url_param_t);											-- look for url in parameter values where a url does not belong

	return table.concat ({
		frame:extensionTag ('templatestyles', '', {src=styles}),
		citation0( config, args)
	});
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {citation = citation};</text>
      <sha1>5t576heqoynv9oflrb526o412end3g8</sha1>
    </revision>
    <revision>
      <id>4746</id>
      <parentid>4745</parentid>
      <timestamp>2022-01-26T14:01:48Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4746</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="205166" sha1="kpzwmdqxhrh3hamiw6chl3i9rsg8izd" xml:space="preserve">require ('Module:No globals');

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------

each of these counts against the Lua upvalue limit

]]

local validation;																-- functions in Module:Citation/CS1/Date_validation

local utilities;																-- functions in Module:Citation/CS1/Utilities
local z ={};																	-- table of tables in Module:Citation/CS1/Utilities

local identifiers;																-- functions and tables in Module:Citation/CS1/Identifiers
local metadata;																	-- functions in Module:Citation/CS1/COinS
local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;---------------

declare variables here that have page-wide scope that are not brought in from
other modules; that are created here and used here

]]

local added_deprecated_cat;														-- Boolean flag so that the category is added only once
local added_vanc_errs;															-- Boolean flag so we only emit one Vancouver error / category
local added_generic_name_errs;													-- Boolean flag so we only emit one generic name error / category and stop testing names once an error is encountered
local Frame;																	-- holds the module's frame table
local is_preview_mode;															-- true when article is in preview mode; false when using 'Preview page with this template' (previewing the module)
local is_sandbox;																-- true when using sandbox modules to render citation


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if utilities.is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a Boolean declared in page scope variables above

]]

local function add_vanc_error (source, position)
	if added_vanc_errs then return end
		
	added_vanc_errs = true;														-- note that we've added this category
	utilities.set_message ('err_vancouver', {source, position});
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a URI scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of TLDs: https://www.iana.org/domains/root/db

RFC 952 (modified by RFC 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the TLD.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a URL with a scheme) will be stripped
here.  Perhaps not necessary but retained in case it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ASCII characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the TLD) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and TLD or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%w]') then											-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at Wikisource
		return false;
	end

	local patterns = {															-- patterns that look like URLs
		'%f[%w][%w][%w%-]+[%w]%.%a%a+$',										-- three or more character hostname.hostname or hostname.tld
		'%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$',									-- internationalized domain name with ACE prefix
		'%f[%a][qxz]%.com$',													-- assigned one character .com hostname (x.com times out 2015-12-10)
		'%f[%a][iq]%.net$',														-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		'%f[%w][%w]%.%a%a$',													-- one character hostname and ccTLD (2 chars)
		'%f[%w][%w][%w]%.%a%a+$',												-- two character hostname and TLD
		'^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?',								-- IPv4 address
		}

	for _, pattern in ipairs (patterns) do										-- loop through the patterns list
		if domain:match (pattern) then
			return true;														-- if a match then we think that this thing that purports to be a URL is a URL
		end
	end

	for _, d in ipairs ({'cash', 'company', 'today', 'org'}) do					-- look for single letter second level domain names for these top level domains
		if domain:match ('%f[%w][%w]%.' .. d) then
			return true
		end
	end
	return false;																-- no matches, we don't know what this thing is
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a URL appear to be a valid URL; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if utilities.is_set (scheme) then											-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when URL is protocol-relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a URL into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following TLD) (if any) and any path(/), query(?) or fragment(#).

If protocol-relative URL, return nil scheme and domain else return nil for both scheme and domain.

When not protocol-relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Any URL that does not have news: scheme must have authority indicator (//).  TODO: are there other common schemes
like news: that don't use authority indicator?

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol-relative URL
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		if utilities.is_set (authority) then
			authority = authority:gsub ('//', '', 1);							-- replace place 1 pair of '/' with nothing;
			if utilities.is_set(authority) then									-- if anything left (1 or 3+ '/' where authority should be) then
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		else
			if not scheme:match ('^news:') then									-- except for news:..., MediaWiki won't link URLs that do not have authority indicator; TODO: a better way to do this test?
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link=, etc. for properly formatted content: no wikilinks, no URLs

Link parameters are to hold the title of a Wikipedia article, so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki URLs and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid URL (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid URL (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from URL; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid URL
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wiki-linked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

check &lt;link&gt; for inter-language interwiki-link prefix.  prefix must be a MediaWiki-recognized language
code and must begin with a colon.

]]

local function link_title_ok (link, lorig, title, torig)
local orig;
	if utilities.is_set (link) then 											-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		elseif link:match ('^%a+:') then										-- if the link is what looks like an interwiki
			local prefix = link:match ('^(%a+):'):lower();						-- get the interwiki prefix

			if cfg.inter_wiki_map[prefix] then									-- if prefix is in the map, must have preceding colon
				orig = lorig;													-- flag as error
			end
		end
	end

	if utilities.is_set (orig) then
		link = '';																-- unset
		utilities.set_message ('err_bad_paramlink', orig);						-- URL or wikilink in |title= with |title-link=;
	end
	
	return link;																-- link if ok, empty string else
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the URL into scheme and domain
portions, or for protocol-relative (//example.com) URLs, just the domain.  Use is_url() to validate the two
portions of the URL.  If both are valid, or for protocol-relative if domain is valid, return true, else false.

Because it is different from a standard URL, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper URL
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from URL;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a URL.  The test will also find external wikilinks
that use protocol-relative URLs. Also finds bare URLs.

The frontier pattern prevents a match on interwiki-links which are similar to scheme:path URLs.  The tests that
find bracketed URLs are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext. wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol-relative ext. wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare URL with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol-relative bare URL: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a URL
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list, error_list)
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a URL add an error message
			table.insert (error_list, utilities.wrap_style ('parameter', k));
		end
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		utilities.set_message ('err_wikilink_in_url', {});
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link (URL, label, source, access)
	local err_msg = '';
	local domain;
	local path;
	local base_url;

	if not utilities.is_set (label) then
		label = URL;
		if utilities.is_set (source) then
			utilities.set_message ('err_bare_url_missing_title', {utilities.wrap_style ('parameter', source)});
		else
			error (cfg.messages[&quot;bare_url_no_origin&quot;]);
		end			
	end
	if not check_url (URL) then
		utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)});
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the URL into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['['] = '%5b', [']'] = '%5d'});			-- replace '[' and ']' with their percent-encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat ({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wiki-markup URL

	if utilities.is_set (access) then											-- access level (subscription, registration, limited)
		base_url = utilities.substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end

	return base_url;
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a Boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		utilities.set_message ('err_deprecated_params', {name});				-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wiki-markup) are not kerned.

Replaces Unicode quote marks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc.; not for book titles.

]=]

local function kern_quotes (str)
	local cap = '';
	local wl_type, label, link;

	wl_type, label, link = utilities.is_wikilink (str);							-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-left'], str);
			str = utilities.substitute (cfg.presentation['kern-right'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = utilities.substitute (cfg.presentation['kern-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label = mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label = mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap = mw.ustring.match (label, &quot;^([\&quot;\'][^\'].+)&quot;);						-- match leading double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-left'], cap);
		end
	
		cap = mw.ustring.match (label, &quot;^(.+[^\'][\&quot;\'])$&quot;)						-- match trailing double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-right'], cap);
		end
		
		if 2 == wl_type then
			str = utilities.make_wikilink (link, label);						-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin-based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate RTL languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO 639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO 639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title=, |script-chapter=, |script-&lt;periodical&gt;=

]]

local function format_script_value (script_value, script_param)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%l?%s*:') then									-- if first 3 or 4 non-space characters are script language prefix
		lang = script_value:match('^(%l%l%l?)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not utilities.is_set (lang) then
			utilities.set_message ('err_script_parameter', {script_param, 'missing title part'});		-- prefix without 'title'; add error message
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_code_remap[lang] or mw.language.fetchLanguageName( lang, cfg.this_wiki_code );	-- get language name so that we can use it to categorize
		if utilities.is_set (name) then											-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l+%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if utilities.in_array (lang, cfg.script_lang_codes) then
				utilities.add_prop_cat ('script', {name, lang})
			else
				utilities.set_message ('err_script_parameter', {script_param, 'unknown language code'});	-- unknown script-language; add error message
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			utilities.set_message ('err_script_parameter', {script_param, 'invalid language code'});		-- invalid language code; add error message
			lang = '';															-- invalid so set lang to empty string
		end
	else
		utilities.set_message ('err_script_parameter', {script_param, 'missing prefix'});				-- no language code prefix; add error message
	end
	script_value = utilities.substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is RTL

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script
value has been wrapped in &lt;bdi&gt; tags.

]]

local function script_concatenate (title, script, script_param)
	if utilities.is_set (script) then
		script = format_script_value (script, script_param);					-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; returns empty string on error
		if utilities.is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not utilities.is_set ( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return utilities.substitute ( msg, str );								-- including template text
	else
		return utilities.substitute ( cfg.messages[key], str );
	end		
end


--[[----------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;-------------------

Makes a Wikisource URL from Wikisource interwiki-link.  Returns the URL and appropriate
label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;
	local wikisource_prefix = table.concat ({'https://', cfg.this_wiki_code, '.wikisource.org/wiki/'});

	wl_type, D, L = utilities.is_wikilink (str);								-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 1 == wl_type then													-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end

	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable URL
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent-encoding of fragment marker
	end

	return ws_url, ws_label, L or D;											-- return proper URL or nil and a label or nil
end


--[[----------------&lt; F O R M A T _ P E R I O D I C A L &gt;-----------------------

Format the three periodical parameters: |script-&lt;periodical&gt;=, |&lt;periodical&gt;=,
and |trans-&lt;periodical&gt;= into a single Periodical meta-parameter.

]]

local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)

	if not utilities.is_set (periodical) then
		periodical = '';														-- to be safe for concatenation
	else
		periodical = utilities.wrap_style ('italic-title', periodical);			-- style 
	end

	periodical = script_concatenate (periodical, script_periodical, script_periodical_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (trans_periodical) then
		trans_periodical = utilities.wrap_style ('trans-italic-title', trans_periodical);
		if utilities.is_set (periodical) then
			periodical = periodical .. ' ' .. trans_periodical;
		else																	-- here when trans-periodical without periodical or script-periodical
			periodical = trans_periodical;
			utilities.set_message ('err_trans_missing_title', {'periodical'});
		end
	end

	return periodical;
end


--[[------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;---------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=,
and |chapter-url= into a single chapter meta- parameter (chapter_url_source used
for error messages).

]]

local function format_chapter_title (script_chapter, script_chapter_source, chapter, chapter_source, trans_chapter, trans_chapter_source, chapter_url, chapter_url_source, no_quotes, access)
	local ws_url, ws_label, L = wikisource_url_make (chapter);					-- make a wikisource URL and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', ' ');									-- replace underscore separators with space characters
		chapter = ws_label;
	end

	if not utilities.is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from module provided quote marks
			chapter = utilities.wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, script_chapter, script_chapter_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (chapter_url) then
		chapter = external_link (chapter_url, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');	-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if utilities.is_set (trans_chapter) then
		trans_chapter = utilities.wrap_style ('trans-quoted-title', trans_chapter);
		if utilities.is_set (chapter) then
			chapter = chapter .. ' ' .. trans_chapter;
		else																	-- here when trans_chapter without chapter or script-chapter
			chapter = trans_chapter;
			chapter_source = trans_chapter_source:match ('trans%-?(.+)');		-- when no chapter, get matching name from trans-&lt;param&gt;
			utilities.set_message ('err_trans_missing_title', {chapter_source});
		end
	end

	return chapter;
end


--[[----------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;-------------------

This function searches a parameter's value for non-printable or invisible characters.
The search stops at the first match.

This function will detect the visible replacement character when it is part of the Wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers
(gallery, math, pre, ref) and identifies them with a slightly different error message.
See also coins_cleanup().

Output of this function is an error message that identifies the character or the
Unicode group, or the stripmarker that was detected along with its position (or,
for multi-byte characters, the position of its first byte) in the parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local stripmarker;															-- boolean set true when a stripmarker is found

	capture = string.match (v, '[%w%p ]*');										-- test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no Unicode characters
		return;
	end

	for _, invisible_char in ipairs (cfg.invisible_chars) do
		local char_name = invisible_char[1];									-- the character or group name
		local pattern = invisible_char[2];										-- the pattern used to find it
		position, _, capture = mw.ustring.find (v, pattern);					-- see if the parameter value contains characters that match the pattern
		
		if position and (cfg.invisible_defs.zwj == capture) then				-- if we found a zero-width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- it's ok if one of the Indic scripts
				position = nil;													-- unset position
			elseif cfg.emoji[mw.ustring.codepoint (v, position+1)] then			-- is zwj followed by a character listed in emoji{}?
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and utilities.in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and cfg.invisible_defs.del == capture then	-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture and not (cfg.invisible_defs.del == capture or cfg.invisible_defs.zwj == capture) then
					err_msg = capture .. ' ' .. char_name;
				else
					err_msg = char_name .. ' ' .. 'character';
				end

				utilities.set_message ('err_invisible_char', {err_msg, utilities.wrap_style ('parameter', param), position});	-- add error message
				return;															-- and done with this parameter
			end
		end
	end
end


--[[-------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------

Argument wrapper.  This function provides support for argument mapping defined
in the configuration file so that multiple names can be transparently aliased to
single internal variable.

]]

local function argument_wrapper ( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function ( self, k )
			local dummy = self[k];												-- force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = utilities.select_one ( args, list, 'err_redundant_parameters' );
				if origin[k] == nil then
					origin[k] = '';												-- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] .. ': ' .. k);
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;-------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.
When date is DD MMMM YYYY or is MMMM DD, YYYY then wrap in nowrap span:
&lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap = '';
	local cap2 = '';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = utilities.substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = utilities.substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;---------------------

This function sets default title types (equivalent to the citation including
|type=&lt;default value&gt;) for those templates that have defaults. Also handles the
special case where it is desirable to omit the title type from the rendered citation
(|type=none).

]]

local function set_titletype (cite_class, title_type)
	if utilities.is_set (title_type) then
		if 'none' == cfg.keywords_xlate[title_type] then
			title_type = '';													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; S A F E _ J O I N &gt;-----------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'duplicate character'
		if 1 == #duplicate_char then											-- for single byte ASCII characters use the string library functions
			f.gsub = string.gsub
			f.match = string.match
			f.sub = string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub = mw.ustring.gsub
			f.match = mw.ustring.match
			f.sub = mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1, 1) == '&lt;' then										-- special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove HTML markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1, 1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc.?
				trim = false;
				end_chr = f.sub(str, -1, -1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr .. &quot;)&quot;				-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1, -2);									-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;''&quot; then		-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5, -1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;]]&quot; then		-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3, -1) == duplicate_char .. '&quot;]' then	-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2, -1) == duplicate_char .. &quot;]&quot; then	-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2, -1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1, -3);								-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains HTML markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows HTML markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value; 												-- add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;-----------------------------

returns true if suffix is properly formed Jr, Sr, or ordinal in the range 1–9.
Puncutation not allowed.

]]

local function is_suffix (suffix)
	if utilities.in_array (suffix, {'Jr', 'Sr', 'Jnr', 'Snr', '1st', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;-------------------

For Vancouver style, author/editor names are supposed to be rendered in Latin
(read ASCII) characters.  When a name uses characters that contain diacritical
marks, those characters are to be converted to the corresponding Latin
character. When a name is written using a non-Latin alphabet or logogram, that
name is to be transliterated into Latin characters. The module doesn't do this
so editors may/must.

This test allows |first= and |last= names to contain any of the letters defined
in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes.
	(http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;)
	or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written outside of the code editor and pasted here because the code editor
gets confused between character insertion point and cursor position. The test has
been rewritten to use decimal character escape sequence for the individual bytes
of the Unicode characters so that it is not necessary to use an external editor
to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first, suffix, position)
	if not suffix then
		if first:find ('[,%s]') then											-- when there is a space or comma, might be first name/initials + generational suffix
			first = first:match ('(.-)[,%s]+');									-- get name/initials
			suffix = first:match ('[,%s]+(.+)$');								-- get generational suffix
		end
	end
	if utilities.is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error (cfg.err_msg_supl.suffix, position);
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error (cfg.err_msg_supl['non-Latin char'], position);
			return false;														-- not a string of Latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-style=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period.
See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc.) to be rendered
as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format
because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the
Unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first, position)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just initials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error (cfg.err_msg_supl.suffix, position);			-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word

	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i], 1, 1));			-- insert the initial at end of initials table
		end
		i = i + 1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; L I S T _ P E O P L E &gt;--------------------------

Formats a list of people (authors, contributors, editors, interviewers, translators) 

names in the list will be linked when
	|&lt;name&gt;-link= has a value
	|&lt;name&gt;-mask- does NOT have a value; masked names are presumed to have been
		rendered previously so should have been linked there

when |&lt;name&gt;-mask=0, the associated name is not rendered

]]

local function list_people (control, people, etal)
	local sep;
	local namesep;
	local format = control.format;
	local maximum = control.maximum;
	local name_list = {};

	if 'vanc' == format then													-- Vancouver-like name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between names is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between names is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub (-1, -1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if utilities.is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end		-- returned 0 is for EditorCount; not used for other names
	
	for i, person in ipairs (people) do
		if utilities.is_set (person.last) then
			local mask = person.mask;
			local one;
			local sep_one = sep;

			if utilities.is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			end
			
			if mask then
				local n = tonumber (mask);										-- convert to a number if it can be converted; nil else
				if n then
					one = 0 ~= n and string.rep(&quot;&amp;mdash;&quot;, n) or nil;			-- make a string of (n &gt; 0) mdashes, nil else, to replace name
					person.link = nil;											-- don't create link to name if name is replaces with mdash string or has been set nil
				else
					one = mask;													-- replace name with mask text (must include name-list separator)
					sep_one = &quot; &quot;;												-- modify name-list separator
				end
			else
				one = person.last;												-- get surname
				local first = person.first										-- get given name
				if utilities.is_set (first) then
					if (&quot;vanc&quot; == format) then									-- if Vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first, nil, i) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials (first, i);				-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
			end
			if utilities.is_set (person.link) then
				one = utilities.make_wikilink (person.link, one);				-- link author/editor
			end
			if one then															-- if &lt;one&gt; has a value (name, mdash replacement, or mask text replacement)
				table.insert (name_list, one);									-- add it to the list of names
				table.insert (name_list, sep_one);								-- add the proper name-list separator
			end
		end
	end

	local count = #name_list / 2;												-- (number of names + number of separators) divided by 2
	if 0 &lt; count then 
		if 1 &lt; count and not etal then
			if 'amp' == format then
				name_list[#name_list-2] = &quot; &amp; &quot;;								-- replace last separator with ampersand text
			elseif 'and' == format then
				if 2 == count then
					name_list[#name_list-2] = cfg.presentation.sep_nl_and;		-- replace last separator with 'and' text
				else
					name_list[#name_list-2] = cfg.presentation.sep_nl_end;		-- replace last separator with '(sep) and' text
				end
			end
		end
		name_list[#name_list] = nil;											-- erase the last separator
	end

	local result = table.concat (name_list);									-- construct list
	if etal and utilities.is_set (result) then									-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've got a last-first list and etal so add et al.
	end
	
	return result, count;														-- return name-list string and count of number of names (count used for editor names only)
end


--[[--------------------&lt; M A K E _ C I T E R E F _ I D &gt;-----------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise
returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that
order.  year is Year or anchor_year.

]]

local function make_citeref_id (namelist, year)
	local names={};							-- a table for the one to four names and year
	for i,v in ipairs (namelist) do			-- loop through the list and take up to the first four last names
		names[i] = v.last
		if i == 4 then break end			-- if four then done
	end
	table.insert (names, year);				-- add the year at the end
	local id = table.concat(names);			-- concatenate names and year for CITEREF id
	if utilities.is_set (id) then			-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;				-- add the CITEREF portion
	else
		return '';							-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; C I T E _ C L A S S _A T T R I B U T E _M A K E &gt;------------------------------

construct &lt;cite&gt; tag class attribute for this citation.

&lt;cite_class&gt; – config.CitationClass from calling template
&lt;mode&gt; – value from |mode= parameter

]]

local function cite_class_attribute_make (cite_class, mode)
	local class_t = {};
	table.insert (class_t, 'citation');											-- required for blue highlight
	if 'citation' ~= cite_class then
		table.insert (class_t, cite_class);										-- identify this template for user css
		table.insert (class_t, utilities.is_set (mode) and mode or 'cs1');		-- identify the citation style for user css or javascript
	else
		table.insert (class_t, utilities.is_set (mode) and mode or 'cs2');		-- identify the citation style for user css or javascript
	end
	for _, prop_key in ipairs (z.prop_keys_t) do
		table.insert (class_t, prop_key);										-- identify various properties for user css or javascript
	end

	return table.concat (class_t, ' ');											-- make a big string and done
end


--[[---------------------&lt; N A M E _ H A S _ E T A L &gt;--------------------------

Evaluates the content of name parameters (author, editor, etc.) for variations on
the theme of et al.  If found, the et al. is removed, a flag is set to true and
the function returns the modified name and the flag.

This function never sets the flag to false but returns its previous state because
it may have been set by previous passes through this function or by the associated
|display-&lt;names&gt;=etal parameter

]]

local function name_has_etal (name, etal, nocat, param)

	if utilities.is_set (name) then												-- name can be nil in which case just return
		local patterns = cfg.et_al_patterns; 									-- get patterns from configuration
		
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns
			if name:match (pattern) then										-- if this 'et al' pattern is found in name
				name = name:gsub (pattern, '');									-- remove the offending text
				etal = true;													-- set flag (may have been set previously here or by |display-&lt;names&gt;=etal)
				if not nocat then												-- no categorization for |vauthors=
					utilities.set_message ('err_etal', {param});				-- and set an error if not added
				end
			end
		end
	end

	return name, etal;
end


--[[---------------------&lt; N A M E _ I S _ N U M E R I C &gt;----------------------

Add maint cat when name parameter value does not contain letters.  Does not catch
mixed alphanumeric names so |last=A. Green (1922-1987) does not get caught in the
current version of this test but |first=(1888) is caught.

returns nothing

]]

local function name_is_numeric (name, list_name)
	if utilities.is_set (name) then
		if mw.ustring.match (name, '^[%A]+$') then								-- when name does not contain any letters
			utilities.set_message ('maint_numeric_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
		end
	end
end


--[[-----------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;------------------

Evaluates the content of last/surname (authors etc.) parameters for multiple names.
Multiple names are indicated if there is more than one comma or any &quot;unescaped&quot;
semicolons. Escaped semicolons are ones used as part of selected HTML entities.
If the condition is met, the function adds the multiple name maintenance category.

returns nothing

]]

local function name_has_mult_names (name, list_name)
	local _, commas, semicolons, nbsps;
	if utilities.is_set (name) then
		_, commas = name:gsub (',', '');										-- count the number of commas
		_, semicolons = name:gsub (';', '');									-- count the number of semicolons
		-- nbsps probably should be its own separate count rather than merged in
		-- some way with semicolons because Lua patterns do not support the
		-- grouping operator that regex does, which means there is no way to add
		-- more entities to escape except by adding more counts with the new
		-- entities
		_, nbsps = name:gsub ('&amp;nbsp;','');										-- count nbsps
		
		-- There is exactly 1 semicolon per &amp;nbsp; entity, so subtract nbsps
		-- from semicolons to 'escape' them. If additional entities are added,
		-- they also can be subtracted.
		if 1 &lt; commas or 0 &lt; (semicolons - nbsps) then
			utilities.set_message ('maint_mult_names', cfg.special_case_translation [list_name]);	-- add a maint message
		end
	end
end


--[[--------------------------&lt; I S _ G E N E R I C &gt;----------------------------------------------------------

Compares values assigned to various parameter according to the string provided as &lt;item&gt; in the function call:
	'generic_names': |last=, |first=, |editor-last=, etc value against list of known generic name patterns
	'generic_titles': |title=
Returns true when pattern matches; nil else

The k/v pairs in cfg.special_case_translation[item] each contain two tables, one for English and one for another
'local' language.Each of those tables contain another table that holds the string or pattern (whole or fragment)
in index [1]. index [2] is a Boolean that tells string.find() or mw.ustring.find() to do plain-text search (true)
or a pattern search (false).  The intent of all this complexity is to make these searches as fast as possible so
that we don't run out of processing time on very large articles.

]]

local function is_generic (item, value)
	local test_val;

	for _, generic_value in ipairs (cfg.special_case_translation[item]) do		-- spin through the list of known generic value fragments
		test_val = generic_value['en'][2] and value:lower() or value;			-- when set to 'true', plaintext search using lowercase value

		if test_val:find (generic_value['en'][1], 1, generic_value['en'][2]) then
			return true;														-- found English generic value so done

		elseif generic_value['local'] then										-- to keep work load down, generic_&lt;value&gt;['local'] should be nil except when there is a local version of the generic value
			test_val = generic_value['local'][2] and mw.ustring.lower(value) or value;	-- when set to 'true', plaintext search using lowercase value

			if mw.ustring.find (test_val, generic_value['local'][1], 1, generic_value['local'][2]) then	-- mw.ustring() because might not be Latin script
				return true;													-- found local generic value so done
			end
		end
	end
end


--[[--------------------------&lt; N A M E _ I S _ G E N E R I C &gt;------------------------------------------------

calls is_generic() to determine if &lt;name&gt; is a 'generic name' listed in cfg.generic_names; &lt;name_alias&gt; is the
parameter name used in error messaging

]]

local function name_is_generic (name, name_alias)
	if not added_generic_name_errs  and is_generic ('generic_names', name) then
		utilities.set_message ('err_generic_name', name_alias);					-- set an error message
		added_generic_name_errs = true;
	end
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------

This function calls various name checking functions used to validate the content of the various name-holding parameters.

]]

local function name_checks (last, first, list_name, last_alias, first_alias)
	local accept_name;

	if utilities.is_set (last) then
		last, accept_name = utilities.has_accept_as_written (last);				-- remove accept-this-as-written markup when it wraps all of &lt;last&gt;

		if not accept_name then													-- &lt;last&gt; not wrapped in accept-as-written markup
			name_has_mult_names (last, list_name);								-- check for multiple names in the parameter (last only)
			name_is_numeric (last, list_name);									-- check for names that are composed of digits and punctuation
			name_is_generic (last, last_alias);									-- check for names found in the generic names list
		end
	end

	if utilities.is_set (first) then
		first, accept_name = utilities.has_accept_as_written (first);			-- remove accept-this-as-written markup when it wraps all of &lt;first&gt;

		if not accept_name then													-- &lt;first&gt; not wrapped in accept-as-written markup
			name_is_numeric (first, list_name);									-- check for names that are composed of digits and punctuation
			name_is_generic (first, first_alias);								-- check for names found in the generic names list
		end
		local wl_type, D = utilities.is_wikilink (first);
		if 0 ~= wl_type then
			first = D;
			utilities.set_message ('err_bad_paramlink', first_alias);
		end
	end

	return last, first;															-- done
end


--[[----------------------&lt; E X T R A C T _ N A M E S &gt;-------------------------

Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters
(or their aliases), and their matching link and mask parameters. Stops searching
when both |lastn= and |firstn= are not found in args after two sequential attempts:
found |last1=, |last2=, and |last3= but doesn't find |last4= and |last5= then the
search is done.

This function emits an error message when there is a |firstn= without a matching
|lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not
required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.'
is stripped from the parameter and a flag (etal) returned that will cause list_people()
to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps
'et al.' out of the template's metadata.  When this occurs, an error is emitted.

]]

local function extract_names(args, list_name)
	local names = {};															-- table of names
	local last;																	-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;																-- loop counter/indexer
	local n = 1;																-- output table indexer
	local count = 0;															-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal = false;															-- return value set to true when we find some form of et al. in an author parameter

	local last_alias, first_alias, link_alias;									-- selected parameter aliases used in error messaging
	while true do
		last, last_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'err_redundant_parameters', i );		-- search through args for name components beginning at 1
		first, first_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'err_redundant_parameters', i );
		link, link_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i );
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.
		last, first = name_checks (last, first, list_name, last_alias, first_alias);						-- multiple names, extraneous annotation, etc. checks

		if first and not last then												-- if there is a firstn without a matching lastn
			local alias = first_alias:find ('given', 1, true) and 'given' or 'first';	-- get first or given form of the alias
			utilities.set_message ('err_first_missing_last', {
				first_alias,													-- param name of alias missing its mate
				first_alias:gsub (alias, {['first'] = 'last', ['given'] = 'surname'}),	-- make param name appropriate to the alias form
				});																-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			local result;
			link = link_title_ok (link, link_alias, last, last_alias);			-- check for improper wiki-markup

			if first then
				link = link_title_ok (link, link_alias, first, first_alias);	-- check for improper wiki-markup
			end

			names[n] = {last = last, first = first, link = link, mask = mask, corporate = false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				utilities.set_message ('err_missing_name', {list_name:match (&quot;(%w+)List&quot;):lower(), i - 1});	-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names and the etal flag
end


--[[--------------------------&lt; N A M E _ T A G _ G E T &gt;------------------------------------------------------

attempt to decode |language=&lt;lang_param&gt; and return language name and matching tag; nil else.

This function looks for:
	&lt;lang_param&gt; as a tag in cfg.lang_code_remap{}
	&lt;lang_param&gt; as a name in cfg.lang_name_remap{}
	
	&lt;lang_param&gt; as a name in cfg.mw_languages_by_name_t
	&lt;lang_param&gt; as a tag in cfg.mw_languages_by_tag_t
when those fail, presume that &lt;lang_param&gt; is an IETF-like tag that MediaWiki does not recognize.  Strip all
script, region, variant, whatever subtags from &lt;lang_param&gt; to leave just a two or three character language tag
and look for the new &lt;lang_param&gt; in cfg.mw_languages_by_tag_t{}

on success, return name and matching tag; on failure return nil

]]

local function name_tag_get (lang_param)
	local lang_param_lc = mw.ustring.lower (lang_param);						-- use lowercase as an index into the various tables
	local name;
	local tag;

	name = cfg.lang_code_remap[lang_param_lc];									-- assume &lt;lang_param_lc&gt; is a tag; attempt to get remapped language name 
	if name then																-- when &lt;name&gt;, &lt;lang_param&gt; is a tag for a remapped language name
		return name, lang_param;												-- so return &lt;name&gt; from remap and &lt;lang_param&gt;
	end

	tag = lang_param_lc:match ('^(%a%a%a?)%-.*');								-- still assuming that &lt;lang_param_lc&gt; is a tag; strip script, region, variant subtags
	name = cfg.lang_code_remap[tag];											-- attempt to get remapped language name with language subtag only
	if name then																-- when &lt;name&gt;, &lt;tag&gt; is a tag for a remapped language name
		return name, tag;														-- so return &lt;name&gt; from remap and &lt;tag&gt;
	end

	if cfg.lang_name_remap[lang_param_lc] then									-- not a tag, assume &lt;lang_param_lc&gt; is a name; attempt to get remapped language tag 
		return cfg.lang_name_remap[lang_param_lc][1], cfg.lang_name_remap[lang_param_lc][2];	-- for this &lt;lang_param_lc&gt;, return a (possibly) new name and appropriate tag
	end

	tag = cfg.mw_languages_by_name_t[lang_param_lc];							-- assume that &lt;lang_param_lc&gt; is a language name; attempt to get its matching tag
	
	if tag then
		return cfg.mw_languages_by_tag_t[tag], tag;								-- &lt;lang_param_lc&gt; is a name so return the name from the table and &lt;tag&gt;
	end

	name = cfg.mw_languages_by_tag_t[lang_param_lc];							-- assume that &lt;lang_param_lc&gt; is a tag; attempt to get its matching language name
	
	if name then
		return name, lang_param;												-- &lt;lang_param_lc&gt; is a tag so return &lt;name&gt; and the tag
	end
	
	tag = lang_param_lc:match ('^(%a%a%a?)%-.*');								-- is &lt;lang_param_lc&gt; an IETF-like tag that MediaWiki doesn't recognize? &lt;tag&gt; gets the language subtag; nil else

	if tag then
		name = cfg.mw_languages_by_tag_t[tag];									-- attempt to get a language name using the shortened &lt;tag&gt;
		if name then
			return name, tag;													-- &lt;lang_param_lc&gt; is an unrecognized IETF-like tag so return &lt;name&gt; and language subtag
		end
	end
end


--[[-------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code
is recognized by MediaWiki, use the returned name; if not, then use the value that
was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is
assigned to the category for that code: Category:Norwegian-language sources (no).
For valid three-character code languages, the page is assigned to the single category
for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does
not recognize three-character equivalents of two-character codes: code 'ar' is
recognized but code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th
where the language names or codes are separated from each other by commas with
optional space characters.

]]

local function language_parameter (lang)
	local tag;																	-- some form of IETF-like language tag; language subtag with optional region, sript, vatiant, etc subtags
	local lang_subtag;															-- ve populates |language= with mostly unecessary region subtags the MediaWiki does not recognize; this is the base language subtag
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_t = {};															-- table made from the value assigned to |language=

	local this_wiki_name = mw.language.fetchLanguageName (cfg.this_wiki_code, cfg.this_wiki_code);	-- get this wiki's language name

	names_t = mw.text.split (lang, '%s*,%s*');									-- names should be a comma separated list

	for _, lang in ipairs (names_t) do											-- reuse lang here because we don't yet know if lang is a language name or a language tag
		name, tag = name_tag_get (lang);										-- attempt to get name/tag pair for &lt;lang&gt;

		if utilities.is_set (tag) then
			lang_subtag = tag:lower():gsub ('^(%a%a%a?)%-.*', '%1');			-- for categorization, strip any IETF-like tags from language tag

			if cfg.this_wiki_code ~= lang_subtag then							-- when the language is not the same as this wiki's language
				if 2 == lang_subtag:len() then									-- and is a two-character tag
					utilities.add_prop_cat ('foreign-lang-source', {name, lang_subtag}, lang_subtag);		-- categorize it; tag appended to allow for multiple language categorization
				else															-- or is a recognized language (but has a three-character tag)
					utilities.add_prop_cat ('foreign-lang-source-2', {lang_subtag}, lang_subtag);			-- categorize it differently TODO: support multiple three-character tag categories per cs1|2 template?
				end
			elseif cfg.local_lang_cat_enable then								-- when the language and this wiki's language are the same and categorization is enabled
				utilities.add_prop_cat ('local-lang-source', {name, lang_subtag});		-- categorize it
			end
		else
			name = lang;														-- return whatever &lt;lang&gt; has so that we show something
			utilities.set_message ('maint_unknown_lang');						-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
 
	name = utilities.make_sep_list (#language_list, language_list);
	if (1 == #language_list) and (tag == cfg.this_wiki_code) then				-- when only one language, find lang name in this wiki lang name; for |language=en-us, 'English' in 'American English'
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[-----------------------&lt; S E T _ C S _ S T Y L E &gt;--------------------------

Gets the default CS style configuration for the given mode.
Returns default separator and either postscript as passed in or the default.
In CS1, the default postscript and separator are '.'.
In CS2, the default postscript is the empty string and the default separator is ','.

]]

local function set_cs_style (postscript, mode)
	if utilities.is_set(postscript) then
		-- emit a maintenance message if user postscript is the default cs1 postscript
		-- we catch the opposite case for cs2 in set_style
		if mode == 'cs1' and postscript == cfg.presentation['ps_' .. mode] then
			utilities.set_message ('maint_postscript');
		end
	else
		postscript = cfg.presentation['ps_' .. mode];
	end
	return cfg.presentation['sep_' .. mode], postscript;
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;-----------------------------

Sets the separator and postscript styles. Checks the |mode= first and the
#invoke CitationClass second. Removes the postscript if postscript == none.

]]

local function set_style (mode, postscript, cite_class)
	local sep;
	if 'cs2' == mode then
		sep, postscript = set_cs_style (postscript, 'cs2');
	elseif 'cs1' == mode then
		sep, postscript = set_cs_style (postscript, 'cs1');
	elseif 'citation' == cite_class	then
		sep, postscript = set_cs_style (postscript, 'cs2');
	else
		sep, postscript = set_cs_style (postscript, 'cs1');
	end

	if cfg.keywords_xlate[postscript:lower()] == 'none' then
		-- emit a maintenance message if user postscript is the default cs2 postscript
		-- we catch the opposite case for cs1 in set_cs_style
		if 'cs2' == mode or 'citation' == cite_class then
			utilities.set_message ('maint_postscript');
		end
		postscript = '';
	end
	
	return sep, postscript
end


--[=[-------------------------&lt; I S _ P D F &gt;-----------------------------------

Determines if a URL has the file extension that is one of the PDF file extensions
used by [[MediaWiki:Common.css]] when applying the PDF icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or
		url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
		url:match ('%.PDF&amp;#035') or url:match ('%.pdf&amp;#035');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;-----------------------

Applies CSS style to |format=, |chapter-format=, etc.  Also emits an error message
if the format parameter does not have a matching URL parameter.  If the format parameter
is not set and the URL contains a file extension that is recognized as a PDF document
by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if utilities.is_set (format) then
		format = utilities.wrap_style ('format', format);						-- add leading space, parentheses, resize
		if not utilities.is_set (url) then
			utilities.set_message ('err_format_missing_url', {fmt_param, url_param});	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if URL is a PDF file then
		format = utilities.wrap_style ('format', 'PDF');						-- set format to PDF
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[---------------------&lt; G E T _ D I S P L A Y _ N A M E S &gt;------------------

Returns a number that defines the number of names displayed for author and editor
name lists and a Boolean flag to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero,
return the number and the previous state of the 'etal' flag (false by default
but may have been set to true if the name list contains some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number
that is one greater than the number of authors in the list and set the 'etal' flag true.
This will cause the list_people() to display all of the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_names (max, count, list_name, etal, param)
	if utilities.is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				utilities.set_message ('err_disp_name', {param, max});			-- add error message
				max = nil;
			end
		else																	-- not a valid keyword or number
			utilities.set_message ('err_disp_name', {param, max});		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[----------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;---------------

Adds error if |page=, |pages=, |quote-page=, |quote-pages= has what appears to be
some form of p. or pp. abbreviation in the first characters of the parameter content.

check page for extraneous p, p., pp, pp., pg, pg. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when page begins PX or P# but not Px
		      where x and X are letters and # is a digit
	bad pattern:  '^[Pp][PpGg]' matches when page begins pp, pP, Pp, PP, pg, pG, Pg, PG

]]

local function extra_text_in_page_check (val, name)
	if not val:match (cfg.vol_iss_pg_patterns.good_ppattern) then
		for _, pattern in ipairs (cfg.vol_iss_pg_patterns.bad_ppatterns) do		-- spin through the selected sequence table of patterns
			if val:match (pattern) then											-- when a match, error so
				utilities.set_message ('err_extra_text_pages', name);	 		-- add error message
				return;															-- and done
			end
		end
	end		
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ V O L _ I S S _ C H E C K &gt;------------------------

Adds error if |volume= or |issue= has what appears to be some form of redundant 'type' indicator.

For |volume=:
	'V.', or 'Vol.' (with or without the dot) abbreviations or 'Volume' in the first characters of the parameter
	content (all case insensitive). 'V' and 'v' (without the dot) are presumed to be roman numerals so
	are allowed.

For |issue=:
	'No.', 'I.', 'Iss.' (with or without the dot) abbreviations, or 'Issue' in the first characters of the
	parameter content (all case insensitive).
	
Single character values ('v', 'i', 'n') allowed when not followed by separator character ('.', ':', '=', or
whitespace character) – param values are trimmed of whitespace by MediaWiki before delivered to the module.
	
&lt;val&gt; is |volume= or |issue= parameter value
&lt;name&gt; is |volume= or |issue= parameter name for error message
&lt;selector&gt; is 'v' for |volume=, 'i' for |issue=

sets error message on failure; returns nothing

]]

local function extra_text_in_vol_iss_check (val, name, selector)
	if not utilities.is_set (val) then
		return;
	end
	
	local patterns = 'v' == selector and cfg.vol_iss_pg_patterns.vpatterns or cfg.vol_iss_pg_patterns.ipatterns;

	local handler = 'v' == selector and 'err_extra_text_volume' or 'err_extra_text_issue';
	val = val:lower();															-- force parameter value to lower case
	for _, pattern in ipairs (patterns) do										-- spin through the selected sequence table of patterns
		if val:match (pattern) then												-- when a match, error so
			utilities.set_message (handler, name);								-- add error message
			return;																-- and done
		end
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parentheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a placeholder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parentheses
			local name = name_table[i];
			i = i + 1;															-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parentheses
					break;														-- and done reassembling so
				end
				i = i + 1;														-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = utilities.is_wikilink (name_table[i]);		-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i + 1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled parentheses ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the Vancouver error when a required comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		first = '';																-- set to empty string for concatenation and because it may have been set for previous author/editor
		local accept_name;
		v_name, accept_name = utilities.has_accept_as_written (v_name);			-- remove accept-this-as-written markup when it wraps all of &lt;v_name&gt;

		if accept_name then
			last = v_name;
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error (cfg.err_msg_supl.punctuation, i);
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s+&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be initials or generational suffix

			if not mw.ustring.match (first, '^%u+$') then						-- mw.ustring here so that later we will catch non-Latin characters
				suffix = first;													-- not initials so assume that whatever we got is a generational suffix
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end
			last = table.concat(lastfirstTable, ' ')							-- returns a string that is the concatenation of all other names that are not initials and generational suffix
			if not utilities.is_set (last) then
				first = '';														-- unset
				last = v_name;													-- last empty because something wrong with first
				add_vanc_error (cfg.err_msg_supl.name, i);
			end
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error (cfg.err_msg_supl['missing comma'], i);			-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- matches a space between two initials
			end
		else
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
		
		if utilities.is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first, suffix, i);							-- check first and last before restoring the suffix which may have a non-Latin digit
			if utilities.is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '', nil, i);
			end
		end

		link = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i ) or v_link_table[i];
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate = corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest;
|editorn= (and aliases) highest and |veditors= lowest (support for |editors= withdrawn)

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
	local lastfirst = false;
	if utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice in case we have a |first1= without a |last1=; this ...
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or		-- ... also catches the case where |first= is used with |vauthors=
		utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst = true;
	end

	if (utilities.is_set (vxxxxors) and true == lastfirst) or					-- these are the three error conditions
		(utilities.is_set (vxxxxors) and utilities.is_set (xxxxors)) or
		(true == lastfirst and utilities.is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			utilities.set_message ('err_redundant_parameters', err_name .. '-name-list parameters');	-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if utilities.is_set (vxxxxors) then return 2 end;
	if utilities.is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, live, dead, etc.).  When the parameter value has not been assigned a value (missing
or empty in the source template) the function returns the value specified by ret_val.  If the parameter value is one
of the list of allowed values returns the translated value; else, emits an error message and returns the value
specified by ret_val.

TODO: explain &lt;invert&gt;

]]

local function is_valid_parameter_value (value, name, possible, ret_val, invert)
	if not utilities.is_set (value) then
		return ret_val;															-- an empty parameter is ok
	end

	if (not invert and utilities.in_array (value, possible)) then				-- normal; &lt;value&gt; is in &lt;possible&gt; table
		return cfg.keywords_xlate[value];										-- return translation of parameter keyword
	elseif invert and not utilities.in_array (value, possible) then				-- invert; &lt;value&gt; is not in &lt;possible&gt; table
		return value;															-- return &lt;value&gt; as it is
	else
		utilities.set_message ('err_invalid_param_val', {name, value});			-- not an allowed value so add error message
		return ret_val;
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list, -3, -1) == sepc .. '. ') then					-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list, -1, -1) == sepc) or (string.sub (name_list, -3, -1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terminate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not utilities.is_set (volume) and not utilities.is_set (issue) then
		return '';
	end

	-- same condition as in format_pages_sheets()
	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);

	local is_numeric_vol = volume and (volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$'));	-- is only uppercase roman numerals or only digits?
	local is_long_vol = volume and (4 &lt; mw.ustring.len(volume));				-- is |volume= value longer than 4 characters?
	
	if volume and (not is_numeric_vol and is_long_vol) then						-- when not all digits or Roman numerals, is |volume= longer than 4 characters?
		utilities.add_prop_cat ('long-vol');									-- yes, add properties cat
	end

	if is_journal then															-- journal-style formatting
		local vol = '';
		
		if utilities.is_set (volume) then
			if is_numeric_vol then												-- |volume= value all digits or all uppercase Roman numerals?
				vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, volume});	-- render in bold face
			elseif is_long_vol then												-- not all digits or Roman numerals; longer than 4 characters?
				vol = utilities.substitute (cfg.messages['j-vol'], {sepc, utilities.hyphen_to_dash (volume)});	-- not bold
			else																-- four or fewer characters
				vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, utilities.hyphen_to_dash (volume)});	-- bold
			end
		end
		if utilities.is_set (issue) then
			return vol .. utilities.substitute (cfg.messages['j-issue'], issue);
		end
		return vol;
	end
	
	if 'podcast' == cite_class and utilities.is_set (issue) then
		return wrap_msg ('issue', {sepc, issue}, lower);
	end

	-- all other types of citation
	if utilities.is_set (volume) and utilities.is_set (issue) then
		return wrap_msg ('vol-no', {sepc, utilities.hyphen_to_dash (volume), issue}, lower);
	elseif utilities.is_set (volume) then
		return wrap_msg ('vol', {sepc, utilities.hyphen_to_dash (volume)}, lower);
	else
		return wrap_msg ('issue', {sepc, issue}, lower);
	end
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if utilities.is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif utilities.is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if utilities.is_set (page) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return utilities.substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return utilities.substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif utilities.is_set (pages) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then							-- if pages is only digits, assume a single page number
			return '', utilities.substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', utilities.substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', utilities.substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to Wikisource, returns the label portion of the interwiki-link as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki-link to an external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, page_orig, pages, pages_orig, at)
	local ws_url, ws_label, coins_pages, L;										-- for Wikisource interwiki-links; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if utilities.is_set (page) then
		if utilities.is_set (pages) or utilities.is_set (at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page, page_orig);								-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws URL from |page= interwiki link; link portion L becomes tooltip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (pages) then
		if utilities.is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages, pages_orig);							-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws URL from |pages= interwiki link; link portion L becomes tooltip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws URL from |at= interwiki link; link portion L becomes tooltip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end

--[[--------------------------&lt; I S _ U N I Q U E _ A R C H I V E _ U R L &gt;------------------------------------

add error message when |archive-url= value is same as |url= or chapter-url= (or alias...) value

]]

local function is_unique_archive_url (archive, url, c_url, source, date)
	if utilities.is_set (archive) then
		if archive == url or archive == c_url then
			utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)});	-- add error message
			return '', '';														-- unset |archive-url= and |archive-date= because same as |url= or |chapter-url=
		end
	end

	return archive, date;
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org URLs to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot URL or to calendar pages.  When the archive URL is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the URL.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org URL does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command URL
	|archive-url= is an archive.org URL that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org URLs:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this function may return a modified
archive URL:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the URL unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.org URL
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine URL
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command URL, we don't want to allow saving of the target page 
		err_msg = cfg.err_msg_supl.save;
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = cfg.err_msg_supl.liveweb;
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');	-- split out some of the URL parts for evaluation
		if not path then														-- malformed in some way; pattern did not match
			err_msg = cfg.err_msg_supl.timestamp;
		elseif 14 ~= timestamp:len() then										-- path and flag optional, must have 14-digit timestamp here
			err_msg = cfg.err_msg_supl.timestamp;
			if '*' ~= flag then
				local replacement = timestamp:match ('^%d%d%d%d%d%d') or timestamp:match ('^%d%d%d%d');	-- get the first 6 (YYYYMM) or first 4 digits (YYYY)
				if replacement then												-- nil if there aren't at least 4 digits (year)
					replacement = replacement .. string.rep ('0', 14 - replacement:len());	-- year or yearmo (4 or 6 digits) zero-fill to make 14-digit timestamp
					url=url:gsub ('(//web%.archive%.org/[^%d]*)%d[^/]*', '%1' .. replacement .. '*', 1)	-- for preview, modify ts to 14 digits plus splat for calendar display
				end
			end
		elseif utilities.is_set (path) and 'web/' ~= path then					-- older archive URLs do not have the extra 'web/' path element
			err_msg = cfg.err_msg_supl.path;
		elseif utilities.is_set (flag) and not utilities.is_set (path) then		-- flag not allowed with the old form URL (without the 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		elseif utilities.is_set (flag) and not flag:match ('%a%a_') then		-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		else
			return url, date;													-- return ArchiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	utilities.set_message ('err_archive_url', {err_msg});						-- add error message and

	if is_preview_mode then
		return url, date;														-- preview mode so return ArchiveURL and ArchiveDate
	else
		return '', '';															-- return empty strings for ArchiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; P L A C E _ C H E C K &gt;--------------------------------------------------------

check |place=, |publication-place=, |location= to see if these params include digits.  This function added because
many editors misuse location to specify the in-source location (|page(s)= and |at= are supposed to do that)

returns the original parameter value without modification; added maint cat when parameter value contains digits

]]

local function place_check (param_val)
	if not utilities.is_set (param_val) then									-- parameter empty or omitted
		return param_val;														-- return that empty state
	end
	
	if mw.ustring.find (param_val, '%d') then									-- not empty, are there digits in the parameter value
		utilities.set_message ('maint_location');								-- yep, add maint cat
	end
	
	return param_val;															-- and done
end


--[[--------------------------&lt; I S _ A R C H I V E D _ C O P Y &gt;----------------------------------------------

compares |title= to 'Archived copy' (placeholder added by bots that can't find proper title); if matches, return true; nil else

]]

local function is_archived_copy (title)
	title = mw.ustring.lower(title);											-- switch title to lower case
	if title:find (cfg.special_case_translation.archived_copy.en) then			-- if title is 'Archived copy'
		return true;
	elseif cfg.special_case_translation.archived_copy['local'] then
		if mw.ustring.find (title, cfg.special_case_translation.archived_copy['local']) then	-- mw.ustring() because might not be Latin script
			return true;
		end
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args )
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper ( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListStyle = is_valid_parameter_value (A['NameListStyle'], A:ORIGIN('NameListStyle'), cfg.keywords_lists['name-list-style'], '');
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				utilities.set_message ('maint_authors');						-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if utilities.is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], nil, args, 'EditorList');	-- support for |editors= withdrawn
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		end
	end
							
	local Chapter = A['Chapter'];												-- done here so that we have access to |contribution= from |chapter= aliases
	local Chapter_origin = A:ORIGIN ('Chapter');
	local Contribution;															-- because contribution is required for contributor(s)
		if 'contribution' == Chapter_origin then
			Contribution = Chapter;												-- get the name of the contribution
		end
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	
	if utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not utilities.is_set (Contribution) then							-- |contributor= requires |contribution=
				utilities.set_message ('err_contributor_missing_required_param', 'contribution');	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				utilities.set_message ('err_contributor_missing_required_param', 'author');	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if utilities.select_one (args, cfg.aliases['ContributorList-Last'], 'err_redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			utilities.set_message ('err_contributor_ignored');					-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	local Title = A['Title'];
	local TitleLink = A['TitleLink'];

	local auto_select = ''; -- default is auto
	local accept_link;
	TitleLink, accept_link = utilities.has_accept_as_written (TitleLink, true);	-- test for accept-this-as-written markup
	if (not accept_link) and utilities.in_array (TitleLink, {'none', 'pmc', 'doi'}) then -- check for special keywords
		auto_select = TitleLink;												-- remember selection for later
		TitleLink = '';															-- treat as if |title-link= would have been empty
	end

	TitleLink = link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wiki-markup in |title-link= or wiki-markup in |title= when |title-link= is set

	local Section = '';															-- {{cite map}} only; preset to empty string for concatenation if not used
	if 'map' == config.CitationClass and 'section' == Chapter_origin then
		Section = A['Chapter'];													-- get |section= from |chapter= alias list; |chapter= and the other aliases not supported in {{cite map}}
		Chapter = '';															-- unset for now; will be reset later from |map= if present
	end

	local Periodical = A['Periodical'];
	local Periodical_origin = '';
	if utilities.is_set (Periodical) then
		Periodical_origin = A:ORIGIN('Periodical');								-- get the name of the periodical parameter
		local i;
		Periodical, i = utilities.strip_apostrophe_markup (Periodical);			-- strip apostrophe markup so that metadata isn't contaminated 
		if i then																-- non-zero when markup was stripped so emit an error message
			utilities.set_message ('err_apostrophe_markup', {Periodical_origin});
		end
	end

	if 'mailinglist' == config.CitationClass then								-- special case for {{cite mailing list}}
		if utilities.is_set (Periodical) and utilities.is_set (A ['MailingList']) then	-- both set emit an error TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', Periodical_origin) .. ' and ' .. utilities.wrap_style ('parameter', 'mailinglist')});
		end

		Periodical = A ['MailingList'];											-- error or no, set Periodical to |mailinglist= value because this template is {{cite mailing list}}
		Periodical_origin = A:ORIGIN('MailingList');
	end

	local ScriptPeriodical = A['ScriptPeriodical'];

	-- web and news not tested for now because of 
	-- Wikipedia:Administrators%27_noticeboard#Is_there_a_semi-automated_tool_that_could_fix_these_annoying_&quot;Cite_Web&quot;_errors?
	if not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) then	-- 'periodical' templates require periodical parameter
	--	local p = {['journal'] = 'journal', ['magazine'] = 'magazine', ['news'] = 'newspaper', ['web'] = 'website'};	-- for error message
		local p = {['journal'] = 'journal', ['magazine'] = 'magazine'};			-- for error message
		if p[config.CitationClass]  then
			utilities.set_message ('err_missing_periodical', {config.CitationClass, p[config.CitationClass]});
		end
	end
	
	local Volume;
	local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) then
			if not utilities.in_array (Periodical_origin, {'website', 'mailinglist'}) then	-- {{citation}} does not render volume for these 'periodicals' --TODO: move 'array' to ~/Configuration
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		elseif utilities.is_set (ScriptPeriodical) then
			if 'script-website' ~= ScriptPeriodical_origin then					-- {{citation}} does not render volume for |script-website=
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		else
			Volume = A['Volume'];												-- and does for non-'periodical' cites
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_volume) then	-- render |volume= for cs1 according to the configuration settings
		Volume = A['Volume'];
	end	
	extra_text_in_vol_iss_check (Volume, A:ORIGIN ('Volume'), 'v');	

	local Issue;
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) and utilities.in_array (Periodical_origin, {'journal', 'magazine', 'newspaper', 'periodical', 'work'}) or	-- {{citation}} renders issue for these 'periodicals'--TODO: move 'array' to ~/Configuration
			utilities.is_set (ScriptPeriodical) and utilities.in_array (ScriptPeriodical_origin, {'script-journal', 'script-magazine', 'script-newspaper', 'script-periodical', 'script-work'}) then -- and these 'script-periodicals'
				Issue = utilities.hyphen_to_dash (A['Issue']);
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_issue) then	-- conference &amp; map books do not support issue; {{citation}} listed here because included in settings table
		if not (utilities.in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical))) then
			Issue = utilities.hyphen_to_dash (A['Issue']);
		end
	end
	extra_text_in_vol_iss_check (Issue, A:ORIGIN ('Issue'), 'i');	

	local Page;
	local Pages;
	local At;
	if not utilities.in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = utilities.hyphen_to_dash (A['Pages']);	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = place_check (A['PublicationPlace'], A:ORIGIN('PublicationPlace'));
	local Place = place_check (A['Place'], A:ORIGIN('Place'));
	
	local PublisherName = A['PublisherName'];
	local PublisherName_origin = A:ORIGIN('PublisherName');
	if utilities.is_set (PublisherName) then
		local i = 0;
		PublisherName, i = utilities.strip_apostrophe_markup (PublisherName);	-- strip apostrophe markup so that metadata isn't contaminated; publisher is never italicized
		if i then																-- non-zero when markup was stripped so emit an error message
			utilities.set_message ('err_apostrophe_markup', {PublisherName_origin});
		end
	end

	local Newsgroup = A['Newsgroup'];											-- TODO: strip apostrophe markup?
	local Newsgroup_origin = A:ORIGIN('Newsgroup');	

	if 'newsgroup' == config.CitationClass then
		if utilities.is_set (PublisherName) then								-- general use parameter |publisher= not allowed in cite newsgroup
			utilities.set_message ('err_parameter_ignored', {PublisherName_origin});
		end

		PublisherName = nil;													-- ensure that this parameter is unset for the time being; will be used again after COinS
	end

	local URL = A['URL'];														-- TODO: better way to do this for URL, ChapterURL, and MapURL?
	local UrlAccess = is_valid_parameter_value (A['UrlAccess'], A:ORIGIN('UrlAccess'), cfg.keywords_lists['url-access'], nil);
	
	if not utilities.is_set (URL) and utilities.is_set (UrlAccess) then
		UrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', 'url');
	end
	
	local ChapterURL = A['ChapterURL'];
	local ChapterUrlAccess = is_valid_parameter_value (A['ChapterUrlAccess'], A:ORIGIN('ChapterUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (ChapterURL) and utilities.is_set (ChapterUrlAccess) then
		ChapterUrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', {A:ORIGIN('ChapterUrlAccess'):gsub ('%-access', '')});
	end

	local MapUrlAccess = is_valid_parameter_value (A['MapUrlAccess'], A:ORIGIN('MapUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (A['MapURL']) and utilities.is_set (MapUrlAccess) then
		MapUrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', {'map-url'});
	end

	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local no_tracking_cats = is_valid_parameter_value (A['NoTracking'], A:ORIGIN('NoTracking'), cfg.keywords_lists['yes_true_y'], nil);

	-- check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not utilities.is_set (no_tracking_cats) then								-- ignore if we are already not going to categorize this page
		if utilities.in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _, v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end
																				-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	utilities.select_one (args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'err_redundant_parameters');	-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, A:ORIGIN('Page'), Pages, A:ORIGIN('Pages'), At);

	local NoPP = is_valid_parameter_value (A['NoPP'], A:ORIGIN('NoPP'), cfg.keywords_lists['yes_true_y'], nil);

	if utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- both |publication-place= and |place= (|location=) allowed if different
		utilities.add_prop_cat ('location-test');								-- add property cat to evaluate how often PublicationPlace and Place are used together
		if PublicationPlace == Place then
			Place = '';															-- unset; don't need both if they are the same
		end
	elseif not utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- when only |place= (|location=) is set ...
		PublicationPlace = Place;												-- promote |place= (|location=) to |publication-place
	end

	if PublicationPlace == Place then Place = ''; end							-- don't need both if they are the same
	
	local URL_origin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL_origin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ScriptChapter = A['ScriptChapter'];
	local ScriptChapter_origin = A:ORIGIN ('ScriptChapter');
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local TransChapter = A['TransChapter'];
	local TransChapter_origin = A:ORIGIN ('TransChapter');
	local TransTitle = A['TransTitle'];
	local ScriptTitle = A['ScriptTitle'];
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia= and |title= then map |title= to |article= and |encyclopedia= to |title=
		|encyclopedia= and |article= then map |encyclopedia= to |title=

		|trans-title= maps to |trans-chapter= when |title= is re-mapped
		|url= maps to |chapter-url= when |title= is remapped
	
	All other combinations of |encyclopedia=, |title=, and |article= are not modified
	
	]]

	local Encyclopedia = A['Encyclopedia'];										-- used as a flag by this module and by ~/COinS

	if utilities.is_set (Encyclopedia) then										-- emit error message when Encyclopedia set but template is other than {{cite encyclopedia}} or {{citation}}
		if 'encyclopaedia' ~= config.CitationClass and 'citation' ~= config.CitationClass then
			utilities.set_message ('err_parameter_ignored', {A:ORIGIN ('Encyclopedia')});
			Encyclopedia = nil;													-- unset because not supported by this template
		end
	end

	if ('encyclopaedia' == config.CitationClass) or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Periodical) and utilities.is_set (Encyclopedia) then	-- when both set emit an error TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', A:ORIGIN ('Encyclopedia')) .. ' and ' .. utilities.wrap_style ('parameter', Periodical_origin)});
		end

		if utilities.is_set (Encyclopedia) then
			Periodical = Encyclopedia;											-- error or no, set Periodical to Encyclopedia; allow periodical without encyclopedia
			Periodical_origin = A:ORIGIN ('Encyclopedia');
		end

		if utilities.is_set (Periodical) then									-- Periodical is set when |encyclopedia= is set
			if utilities.is_set (Title) or utilities.is_set (ScriptTitle) then
				if not utilities.is_set (Chapter) then
					Chapter = Title;											-- |encyclopedia= and |title= are set so map |title= to |article= and |encyclopedia= to |title=
					ScriptChapter = ScriptTitle;
					ScriptChapter_origin = A:ORIGIN('ScriptTitle')
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterURL_origin = URL_origin;

					ChapterUrlAccess = UrlAccess;

					if not utilities.is_set (ChapterURL) and utilities.is_set (TitleLink) then
						Chapter = utilities.make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			elseif utilities.is_set (Chapter) or utilities.is_set (ScriptChapter) then								-- |title= not set
				Title = Periodical;												-- |encyclopedia= set and |article= set so map |encyclopedia= to |title=
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- special case for cite techreport.
	local ID = A['ID'];
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if utilities.is_set (A['Number']) then									-- cite techreport uses 'number', which other citations alias to 'issue'
			if not utilities.is_set (ID) then									-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'id') .. ' and ' .. utilities.wrap_style ('parameter', 'number')});
			end
		end	
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	local ChapterLink -- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local Conference = A['Conference'];
	local BookTitle = A['BookTitle'];
	local TransTitle_origin = A:ORIGIN ('TransTitle');
	if 'conference' == config.CitationClass then
		if utilities.is_set (BookTitle) then
			Chapter = Title;
			Chapter_origin = 'title';
	--		ChapterLink = TitleLink;											-- |chapter-link= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			URL_origin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			TransChapter_origin = TransTitle_origin;
			Title = BookTitle;
			Format = '';
	--		TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end
	
	-- CS1/2 mode
	local Mode = is_valid_parameter_value (A['Mode'], A:ORIGIN('Mode'), cfg.keywords_lists['mode'], '');
	-- separator character and postscript
	local sepc, PostScript = set_style (Mode:lower(), A['PostScript'], config.CitationClass);
	-- controls capitalization of certain static text
	local use_lowercase = ( sepc == ',' );
	
	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		if utilities.is_set (Chapter) then										--TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'map') .. ' and ' .. utilities.wrap_style ('parameter', Chapter_origin)});	-- add error message
		end
		Chapter = A['Map'];
		Chapter_origin = A:ORIGIN('Map');
		ChapterURL = A['MapURL'];
		ChapterURL_origin = A:ORIGIN('MapURL');
		TransChapter = A['TransMap'];
		ScriptChapter = A['ScriptMap']
		ScriptChapter_origin = A:ORIGIN('ScriptMap')

		ChapterUrlAccess = MapUrlAccess;
		ChapterFormat = A['MapFormat'];

		Cartography = A['Cartography'];
		if utilities.is_set ( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if utilities.is_set ( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	local Series = A['Series'];
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local SeriesLink = A['SeriesLink'];

		SeriesLink = link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wiki-markup in |series-link= or wiki-markup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if utilities.is_set (Network) then table.insert(n, Network); end
		if utilities.is_set (Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if utilities.is_set (Season) and utilities.is_set (SeriesNumber) then	-- these are mutually exclusive so if both are set TODO: make a function for this and similar?
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'season') .. ' and ' .. utilities.wrap_style ('parameter', 'seriesno')});		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if utilities.is_set (Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if utilities.is_set (SeriesNumber) then table.insert(s, wrap_msg ('seriesnum', SeriesNumber, use_lowercase)); end
			if utilities.is_set (Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ScriptChapter_origin = A:ORIGIN('ScriptTitle');
			ChapterLink = TitleLink;											-- alias |episode-link=
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if utilities.is_set (ChapterLink) and not utilities.is_set (ChapterURL) then	-- link but not URL
				Chapter = utilities.make_wikilink (ChapterLink, Chapter);
			elseif utilities.is_set (ChapterLink) and utilities.is_set (ChapterURL) then	-- if both are set, URL links episode;
				Series = utilities.make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if utilities.is_set (Series) and utilities.is_set (SeriesLink) then
				Series = utilities.make_wikilink (SeriesLink, Series);
			end
			Series = utilities.wrap_style ('italic-title', Series);				-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- handle type parameter for those CS1 citations that have default values
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	if utilities.in_array (config.CitationClass, {'AV-media-notes', 'interview', 'mailinglist', 'map', 'podcast', 'pressrelease', 'report', 'speech', 'techreport', 'thesis'}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if utilities.is_set (Degree) and &quot;Thesis&quot; == TitleType then				-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if utilities.is_set (TitleType) then										-- if type parameter is specified
		TitleType = utilities.substitute ( cfg.messages['type'], TitleType);	-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
	local Date = A['Date'];
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging
	local PublicationDate = A['PublicationDate'];
	local Year = A['Year'];

	if not utilities.is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not utilities.is_set (Date) and utilities.is_set (PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]

	local DF = is_valid_parameter_value (A['DF'], A:ORIGIN('DF'), cfg.keywords_lists['df'], '');
	if not utilities.is_set (DF) then
		DF = cfg.global_df;														-- local |df= if present overrides global df set by {{use xxx date}} template
	end

	local ArchiveURL;
	local ArchiveDate;
	local ArchiveFormat = A['ArchiveFormat'];

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	
	ArchiveURL, ArchiveDate = is_unique_archive_url (ArchiveURL, URL, ChapterURL, A:ORIGIN('ArchiveURL'), ArchiveDate);		-- add error message when URL or ChapterURL == ArchiveURL

	
	local AccessDate = A['AccessDate'];
	local LayDate = A['LayDate'];
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification
	local DoiBroken = A['DoiBroken'];
	local Embargo = A['Embargo'];
	local anchor_year;															-- used in the CITEREF identifier
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val = AccessDate, name = A:ORIGIN ('AccessDate')},
			['archive-date'] = {val = ArchiveDate, name = A:ORIGIN ('ArchiveDate')},
			['date'] = {val = Date, name = Date_origin},
			['doi-broken-date'] = {val = DoiBroken, name = A:ORIGIN ('DoiBroken')},
			['pmc-embargo-date'] = {val = Embargo, name = A:ORIGIN ('Embargo')},
			['lay-date'] = {val = LayDate, name = A:ORIGIN ('LayDate')},
			['publication-date'] = {val = PublicationDate, name = A:ORIGIN ('PublicationDate')},
			['year'] = {val = Year, name = A:ORIGIN ('Year')},
			};

		local error_list = {};
		anchor_year, Embargo = validation.dates(date_parameters_list, COinS_date, error_list);

-- start temporary Julian / Gregorian calendar uncertainty categorization
		if COinS_date.inter_cal_cat then
			utilities.add_prop_cat ('jul-greg-uncertainty');
		end
-- end temporary Julian / Gregorian calendar uncertainty categorization

		if utilities.is_set (Year) and utilities.is_set (Date) then				-- both |date= and |year= not normally needed; 
			validation.year_date_check (Year, A:ORIGIN ('Year'), Date, A:ORIGIN ('Date'), error_list);
		end
		
		if 0 == #error_list then												-- error free dates only; 0 when error_list is empty
			local modified = false;												-- flag
			
			if utilities.is_set (DF) then										-- if we need to reformat dates
				modified = validation.reformat_dates (date_parameters_list, DF);	-- reformat to DF format, use long month names if appropriate
			end

			if true == validation.date_hyphen_to_dash (date_parameters_list) then	-- convert hyphens to dashes where appropriate
				modified = true;
				utilities.set_message ('maint_date_format');					-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language; not supported at en.wiki
			if cfg.date_name_auto_xlate_enable and validation.date_name_xlate (date_parameters_list, cfg.date_digit_auto_xlate_enable ) then
				utilities.set_message ('maint_date_auto_xlated');				-- add maint cat
				modified = true;
			end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				LayDate = date_parameters_list['lay-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end
		else
			utilities.set_message ('err_bad_date', {utilities.make_sep_list (#error_list, error_list)});	-- add this error message
		end
	end	-- end of do

	local ID_list = {};															-- sequence table of rendered identifiers
	local ID_list_coins = {};													-- table of identifiers and their values from args; key is same as cfg.id_handlers's key
	local Class = A['Class'];													-- arxiv class identifier
	
	local ID_support = {
		{A['ASINTLD'], 'ASIN', 'err_asintld_missing_asin', A:ORIGIN ('ASINTLD')},				
		{DoiBroken, 'DOI', 'err_doibroken_missing_doi', A:ORIGIN ('DoiBroken')},
		{Embargo, 'PMC', 'err_embargo_missing_pmc', A:ORIGIN ('Embargo')},
		}

	ID_list, ID_list_coins = identifiers.identifier_lists_get (args, {DoiBroken = DoiBroken, ASINTLD = A['ASINTLD'], Embargo = Embargo, Class = Class}, ID_support);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite ssrn}}, before generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then
		if not utilities.is_set (ID_list_coins[config.CitationClass:upper()]) then 	-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp; |citeseerx= required for their templates
			utilities.set_message ('err_' .. config.CitationClass .. '_missing');	-- add error message
		end

		Periodical = ({['arxiv'] = 'arXiv', ['biorxiv'] = 'bioRxiv', ['citeseerx'] = 'CiteSeerX', ['ssrn'] = 'Social Science Research Network'})[config.CitationClass];
	end

	-- Link the title of the work if no |url= was provided, but we have a |pmc= or a |doi= with |doi-access=free

	if config.CitationClass == &quot;journal&quot; and not utilities.is_set (URL) and not utilities.is_set (TitleLink) and not utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) then -- TODO: remove 'none' once existing citations have been switched to 'off', so 'none' can be used as token for &quot;no title&quot; instead
		if 'none' ~= cfg.keywords_xlate[auto_select] then						-- if auto-linking not disabled
 	 		if identifiers.auto_link_urls[auto_select] then						-- manual selection
		 		URL = identifiers.auto_link_urls[auto_select];					-- set URL to be the same as identifier's external link
 				URL_origin = cfg.id_handlers[auto_select:upper()].parameters[1];	-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['pmc'] then						-- auto-select PMC
				URL = identifiers.auto_link_urls['pmc'];						-- set URL to be the same as the PMC external link if not embargoed
				URL_origin = cfg.id_handlers['PMC'].parameters[1];				-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['doi'] then						-- auto-select DOI
				URL = identifiers.auto_link_urls['doi'];
				URL_origin = cfg.id_handlers['DOI'].parameters[1];
			end
 	 	end

		if utilities.is_set (URL) and utilities.is_set (AccessDate) then		-- access date requires |url=; identifier-created URL is not |url=
			utilities.set_message ('err_accessdate_missing_url');				-- add an error message
			AccessDate = '';													-- unset
		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not utilities.is_set (Title) and not utilities.is_set (TransTitle) and not utilities.is_set (ScriptTitle) then	-- has special case for cite episode
		utilities.set_message ('err_citation_missing_title', {'episode' == config.CitationClass and 'series' or 'title'});
	end

	if utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) and
			utilities.in_array (config.CitationClass, {'journal', 'citation'}) and
			(utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and
			('journal' == Periodical_origin or 'script-journal' == ScriptPeriodical_origin) then	-- special case for journal cites
				Title = '';														-- set title to empty string
				utilities.set_message ('maint_untitled');						-- add maint cat
	end

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Chapter) and utilities.is_set (Title) and utilities.is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end
	
	local QuotePage = A['QuotePage'];
	local QuotePages = utilities.hyphen_to_dash (A['QuotePages']);

	-- this is the function call to COinS()
	local OCinSoutput = metadata.COinS({
		['Periodical'] = utilities.strip_apostrophe_markup (Periodical),		-- no markup in the metadata
		['Encyclopedia'] = Encyclopedia,										-- just a flag; content ignored by ~/COinS
		['Chapter'] = metadata.make_coins_title (coins_chapter, ScriptChapter),	-- Chapter and ScriptChapter stripped of bold / italic / accept-as-written markup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = metadata.make_coins_title (coins_title, ScriptTitle),		-- Title and ScriptTitle stripped of bold / italic / accept-as-written markup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Quarter'] = COinS_date.rftquarter,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = coins_pages or metadata.get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At, QuotePage, QuotePages}, 7)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName or Newsgroup,							-- any apostrophe markup already removed from PublisherName
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list_coins,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, and {{cite ssrn}} AFTER generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, CiteSeerX, or ssrn now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass and utilities.is_set (Newsgroup) then
		PublisherName = utilities.substitute (cfg.messages['newsgroup'], external_link( 'news:' .. Newsgroup, Newsgroup, Newsgroup_origin, nil ));
	end

	local Editors;
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	local Contributors;															-- assembled contributors name list
	local contributor_etal;
	local Translators;															-- assembled translators name list
	local translator_etal;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	local Interviewers;															
	local interviewers_list = {};					
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters
	local interviewer_etal;
	
	-- Now perform various field 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.
	do
		local last_first_list;
		local control = { 
			format = NameListStyle,												-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_names (A['DisplayEditors'], #e, 'editors', editor_etal, A:ORIGIN ('DisplayEditors'));
			Editors, EditorCount = list_people (control, e, editor_etal);

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum, interviewer_etal = get_display_names (A['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal, A:ORIGIN ('DisplayInterviewers'));
			Interviewers = list_people (control, interviewers_list, interviewer_etal);
		end
		do																		-- now do translators
			control.maximum, translator_etal = get_display_names (A['DisplayTranslators'], #t, 'translators', translator_etal, A:ORIGIN ('DisplayTranslators'));
			Translators = list_people (control, t, translator_etal);
		end
		do																		-- now do contributors
			control.maximum, contributor_etal = get_display_names (A['DisplayContributors'], #c, 'contributors', contributor_etal, A:ORIGIN ('DisplayContributors'));
			Contributors = list_people (control, c, contributor_etal);
		end
		do																		-- now do authors
			control.maximum, author_etal = get_display_names (A['DisplayAuthors'], #a, 'authors', author_etal, A:ORIGIN ('DisplayAuthors'));

			last_first_list = list_people (control, a, author_etal);

			if utilities.is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors');	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if utilities.is_set (Authors) and utilities.is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not utilities.is_set (URL) then
		if utilities.in_array (config.CitationClass, {&quot;web&quot;, &quot;podcast&quot;, &quot;mailinglist&quot;}) or		-- |url= required for cite web, cite podcast, and cite mailinglist
			('citation' == config.CitationClass and ('website' == Periodical_origin or 'script-website' == ScriptPeriodical_origin)) then	-- and required for {{citation}} with |website= or |script-website=
				utilities.set_message ('err_cite_web_url');
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if utilities.is_set (AccessDate) and not utilities.is_set (ChapterURL) then		-- ChapterURL may be set when URL is not set;
			utilities.set_message ('err_accessdate_missing_url');
			AccessDate = '';
		end
	end

	local UrlStatus = is_valid_parameter_value (A['UrlStatus'], A:ORIGIN('UrlStatus'), cfg.keywords_lists['url-status'], '');
	local OriginalURL
	local OriginalURL_origin
	local OriginalFormat
	local OriginalAccess;
	UrlStatus = UrlStatus:lower();												-- used later when assembling archived text
	if utilities.is_set ( ArchiveURL ) then
		if utilities.is_set (ChapterURL) then 									-- if chapter-url= is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURL_origin = ChapterURL_origin;								-- name of |chapter-url= parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=

			if 'live' ~= UrlStatus then
				ChapterURL = ArchiveURL											-- swap-in the archive's URL
				ChapterURL_origin = A:ORIGIN('ArchiveURL')						-- name of |archive-url= parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived URLs
			end
		elseif utilities.is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURL_origin = URL_origin;									-- name of URL parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;

			if 'live' ~= UrlStatus then											-- if URL set then |archive-url= applies to it
				URL = ArchiveURL												-- swap-in the archive's URL
				URL_origin = A:ORIGIN('ArchiveURL')								-- name of archive URL parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived URLs
			end
		end
	elseif utilities.is_set (UrlStatus) then									-- if |url-status= is set when |archive-url= is not set
 		utilities.set_message ('maint_url_status');								-- add maint cat
	end

	if utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) then
			local chap_param;
			if utilities.is_set (Chapter) then									-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif utilities.is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif utilities.is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif utilities.is_set (ScriptChapter) then
				chap_param = ScriptChapter_origin;
			else utilities.is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if utilities.is_set (chap_param) then								-- if we found one
				utilities.set_message ('err_chapter_ignored', {chap_param});	-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if utilities.is_set (Contribution) and 0 &lt; #c then						-- if this is a contribution with contributor(s)
			if utilities.in_array (Contribution:lower(), cfg.keywords_lists.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, ScriptChapter_origin, Chapter, Chapter_origin, TransChapter, TransChapter_origin, ChapterURL, ChapterURL_origin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if utilities.is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and utilities.is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter .. sepc .. ' ';
		elseif utilities.is_set (ChapterFormat) then							-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title
	local plain_title = false;
	local accept_title;
	Title, accept_title = utilities.has_accept_as_written (Title, true);		-- remove accept-this-as-written markup when it wraps all of &lt;Title&gt;
	if accept_title and ('' == Title) then										-- only support forced empty for now &quot;(())&quot;
		Title = cfg.messages['notitle'];										-- replace by predefined &quot;No title&quot; message
			-- TODO: utilities.set_message ( 'err_redundant_parameters', ...);	-- issue proper error message instead of muting	 
			ScriptTitle = '';													-- just mute for now	 
			TransTitle = '';													-- just mute for now
 		plain_title = true;														-- suppress text decoration for descriptive title
		utilities.set_message ('maint_untitled');								-- add maint cat
	end

	if not accept_title then													-- &lt;Title&gt; not wrapped in accept-as-written markup
		if '...' == Title:sub (-3) then											-- if ellipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%' .. sepc .. '$', '');			-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end

		if utilities.is_set (ArchiveURL) and is_archived_copy (Title) then
			utilities.set_message ('maint_archived_copy');						-- add maintenance category before we modify the content of Title
		end

		if is_generic ('generic_titles', Title) then
			utilities.set_message ('err_generic_title');						-- set an error message
		end
	end

	if (not plain_title) and (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) or
		('map' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)))) then		-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from module provided quote marks
			Title = utilities.wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle, 'script-title');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
			TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );
	elseif plain_title or ('report' == config.CitationClass) then				-- no styling for cite report and descriptive titles (otherwise same as above)
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );	-- for cite report, use this form for trans-title
	else
		Title = utilities.wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-italic-title', TransTitle);
	end

	if utilities.is_set (TransTitle) then
		if utilities.is_set (Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			utilities.set_message ('err_trans_missing_title', {'title'});
		end
	end

	if utilities.is_set (Title) then											-- TODO: is this the right place to be making Wikisource URLs?
		if utilities.is_set (TitleLink) and utilities.is_set (URL) then
			utilities.set_message ('err_wikilink_in_url');						-- set an error message because we can't have both
			TitleLink = '';														-- unset
		end
	
		if not utilities.is_set (TitleLink) and utilities.is_set (URL) then
			Title = external_link (URL, Title, URL_origin, UrlAccess) .. TransTitle .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif utilities.is_set (TitleLink) and not utilities.is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle;
			else
				Title = utilities.make_wikilink (TitleLink, Title) .. TransTitle;
			end
		else
			local ws_url, ws_label, L;											-- Title has italic or quote markup by the time we get here which causes is_wikilink() to return 0 (not a wikilink)
			ws_url, ws_label, L = wikisource_url_make (Title:gsub('^[\'&quot;]*(.-)[\'&quot;]*$', '%1'));	-- make ws URL from |title= interwiki link (strip italic or quote markup); link portion L becomes tooltip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle;
			else
				Title = Title .. TransTitle;
			end
		end
	else
		Title = TransTitle;
	end

	if utilities.is_set (Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	local ConferenceURL_origin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	if utilities.is_set (Conference) then
		if utilities.is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURL_origin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif utilities.is_set (ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURL_origin, nil );
	end

	local Position = '';
	if not utilities.is_set (Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if utilities.is_set (Minutes) then
			if utilities.is_set (Time) then		--TODO: make a function for this and similar?
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'minutes') .. ' and ' .. utilities.wrap_style ('parameter', 'time')});
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if utilities.is_set (Time) then
				local TimeCaption = A['TimeCaption']
				if not utilities.is_set (TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = utilities.is_set (At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = utilities.is_set (Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Sections = A['Sections'];											-- Section (singular) is an alias of Chapter so set earlier
		local Inset = A['Inset'];
		
		if utilities.is_set ( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if utilities.is_set ( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif utilities.is_set ( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	local Others = A['Others'];
	if utilities.is_set (Others) and 0 == #a and 0 == #e then					-- add maint cat when |others= has value and used without |author=, |editor=
		if config.CitationClass == &quot;AV-media-notes&quot;
		or config.CitationClass == &quot;audio-visual&quot; then							-- special maint for AV/M which has a lot of 'false' positives right now
			utilities.set_message ('maint_others_avm')
		else
			utilities.set_message ('maint_others');
		end
	end
	Others = utilities.is_set (Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if utilities.is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if utilities.is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	local TitleNote = A['TitleNote'];
	TitleNote = utilities.is_set (TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if utilities.is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%n?%.?$') or Edition:match ('%f[%a][Ee]dition$') then -- Ed, ed, Ed., ed., Edn, edn, Edn., edn.
			utilities.set_message ('err_extra_text_edition');					 -- add error message
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = utilities.is_set (Series) and wrap_msg ('series', {sepc, Series}) or &quot;&quot;;	-- not the same as SeriesNum
	local Agency = A['Agency'];
	Agency = utilities.is_set (Agency) and wrap_msg ('agency', {sepc, Agency}) or &quot;&quot;;
	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	if utilities.is_set (AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = utilities.substitute (retrv_text, AccessDate);				-- add retrieved text

		AccessDate = utilities.substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if utilities.is_set (ID) then ID = sepc .. &quot; &quot; .. ID; end
	
	local Docket = A['Docket'];
   	if &quot;thesis&quot; == config.CitationClass and utilities.is_set (Docket) then
		ID = sepc .. &quot; Docket &quot; .. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and utilities.is_set (Docket) then		-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	if utilities.is_set (URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URL_origin, UrlAccess );
	end

	local Quote = A['Quote'];
	local TransQuote = A['TransQuote'];
	local ScriptQuote = A['ScriptQuote'];
	if utilities.is_set (Quote) or utilities.is_set (TransQuote) or utilities.is_set (ScriptQuote) then

		if utilities.is_set (Quote) then
			if Quote:sub(1, 1) == '&quot;' and Quote:sub(-1, -1) == '&quot;' then			-- if first and last characters of quote are quote marks
				Quote = Quote:sub(2, -2);										-- strip them off
			end
		end

		Quote = utilities.wrap_style ('quoted-text', Quote );					-- wrap in &lt;q&gt;...&lt;/q&gt; tags
	
		if utilities.is_set (ScriptQuote) then
			Quote = script_concatenate (Quote, ScriptQuote, 'script-quote');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after quote is wrapped
		end

		if utilities.is_set (TransQuote) then
			if TransQuote:sub(1, 1) == '&quot;' and TransQuote:sub(-1, -1) == '&quot;' then -- if first and last characters of |trans-quote are quote marks
				TransQuote = TransQuote:sub(2, -2); -- strip them off
			end
			Quote = Quote .. &quot; &quot; .. utilities.wrap_style ('trans-quoted-title', TransQuote );
		end

		if utilities.is_set (QuotePage) or utilities.is_set (QuotePages) then	-- add page prefix
			local quote_prefix = '';
			if utilities.is_set (QuotePage) then
				extra_text_in_page_check (QuotePage, 'quote-page');				-- add to maint cat if |quote-page= value begins with what looks like p., pp., etc.
				if not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePage}), '', '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePage}), '', '', '';
				end
			elseif utilities.is_set (QuotePages) then
				extra_text_in_page_check (QuotePages, 'quote-pages');			-- add to maint cat if |quote-pages= value begins with what looks like p., pp., etc.
				if tonumber(QuotePages) ~= nil and not NoPP then				-- if only digits, assume single page
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePages}), '', '';
				elseif not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['pp-prefix'], {sepc, QuotePages}), '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePages}), '', '';
				end
			end
                        
			Quote = quote_prefix .. &quot;: &quot; .. Quote;
		else
			Quote = sepc .. &quot; &quot; .. Quote;
		end

		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	-- We check length of PostScript here because it will have been nuked by
	-- the quote parameters. We'd otherwise emit a message even if there wasn't
	-- a displayed postscript.
	-- TODO: Should the max size (1) be configurable?
	-- TODO: Should we check a specific pattern?
	if utilities.is_set(PostScript) and mw.ustring.len(PostScript) &gt; 1 then
		utilities.set_message ('maint_postscript')
	end
	
	local Archived;
	if utilities.is_set (ArchiveURL) then
		local arch_text;
		if not utilities.is_set (ArchiveDate) then
			utilities.set_message ('err_archive_missing_date');
			ArchiveDate = '';													-- empty string for concatenation
		end
		if &quot;live&quot; == UrlStatus then
			arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if utilities.is_set (ArchiveDate) then
				Archived = sepc .. ' ' .. utilities.substitute ( cfg.messages['archived-live'],
					{external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil) .. ArchiveFormat, ArchiveDate } );
			else
				Archived = '';
			end
			if not utilities.is_set (OriginalURL) then
				utilities.set_message ('err_archive_missing_url');
				Archived = '';													-- empty string for concatenation
			end
		elseif utilities.is_set (OriginalURL) then								-- UrlStatus is empty, 'dead', 'unfit', 'usurped', 'bot: unknown'
			if utilities.in_array (UrlStatus, {'unfit', 'usurped', 'bot: unknown'}) then
				arch_text = cfg.messages['archived-unfit'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. ' ' .. arch_text .. ArchiveDate;				-- format already styled
				if 'bot: unknown' == UrlStatus then
					utilities.set_message ('maint_bot_unknown');				-- and add a category if not already added
				else
					utilities.set_message ('maint_unfit');						-- and add a category if not already added
				end
			else																-- UrlStatus is empty, 'dead'
				arch_text = cfg.messages['archived-dead'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				if utilities.is_set (ArchiveDate) then
					Archived = sepc .. &quot; &quot; .. utilities.substitute ( arch_text,
						{ external_link( OriginalURL, cfg.messages['original'], OriginalURL_origin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
				else
					Archived = '';												-- unset for concatenation
				end
			end	
		else																	-- OriginalUrl not set
			arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			utilities.set_message ('err_archive_missing_url');
			Archived = '';														-- empty string for concatenation
		end
	elseif utilities.is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = '';
	end
	
	local Lay = '';
	local LaySource = A['LaySource'];
	local LayURL = A['LayURL'];
	local LayFormat = A['LayFormat'];
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	if utilities.is_set (LayURL) then
		if utilities.is_set (LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if utilities.is_set (LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. utilities.safe_for_italics (LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif utilities.is_set (LayFormat) then									-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	local TranscriptURL = A['TranscriptURL']
	local TranscriptFormat = A['TranscriptFormat'];
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');
	local Transcript = A['Transcript'];
	local TranscriptURL_origin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL
	if utilities.is_set (Transcript) then
		if utilities.is_set (TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURL_origin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif utilities.is_set (TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURL_origin, nil );
	end

	local Publisher;
	if utilities.is_set (PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if utilities.is_set (PublisherName) then
		if utilities.is_set (PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif utilities.is_set (PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	local TransPeriodical =  A['TransPeriodical'];
	local TransPeriodical_origin =  A:ORIGIN ('TransPeriodical');
	-- Several of the above rely upon detecting this as nil, so do it last.
	if (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical)) then
		if utilities.is_set (Title) or utilities.is_set (TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		else 
			Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		end
	end
	
	local Language = A['Language'];
	if utilities.is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc.
	else
		Language='';															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then									-- cite speech only
		TitleNote = TitleType;													-- move TitleType to TitleNote so that it renders ahead of |event=
		TitleType = '';															-- and unset

		if utilities.is_set (Periodical) then									-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if utilities.is_set (Conference) then								-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;							-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
		if utilities.is_set (Others) then Others = safe_join ({Others, sepc .. &quot; &quot;}, sepc) end		-- add terminal punctuation &amp; space; check for dup sepc; TODO why do we need to do this here?
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (Periodical) then		-- special cases for book cites
		if utilities.is_set (Contributors) then									-- when we are citing foreword, preface, introduction, etc.
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if utilities.is_set (Chapter) then										-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif utilities.is_set (Periodical) then								-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local Via = A['Via'];
	Via = utilities.is_set (Via) and  wrap_msg ('via', Via) or '';
	local idcommon;
	if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then	-- special case for cite AV media &amp; cite episode position transcript
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, Lay, Quote }, sepc );
	else
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, Lay, Quote }, sepc );
	end
	
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	local OrigDate = A['OrigDate'];
	OrigDate = utilities.is_set (OrigDate) and wrap_msg ('origdate', OrigDate) or '';
	if utilities.is_set (Date) then
		if utilities.is_set (Authors) or utilities.is_set (Editors) then		-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date .. &quot;)&quot; .. OrigDate .. sepc .. &quot; &quot;;				-- in parentheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon, -1, -1) == sepc) then						-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigDate;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigDate;							-- Date begins with sepc
			end
		end
	end	
	if utilities.is_set (Authors) then
		if (not utilities.is_set (Date)) then									-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if utilities.is_set (Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then
					in_text = in_text:lower()									-- lowercase for cs2
				end
			end
			if EditorCount &lt;= 1 then
				post_text = &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot;;				-- be consistent with no-author, no-date case
			else
				post_text = &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot;;
			end
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Contributors) then									-- book cite and we're citing the intro, preface, etc.
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if utilities.is_set (Editors) and utilities.is_set (Date) then		-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not utilities.is_set (Date)) then								-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif utilities.is_set (Editors) then
		if utilities.is_set (Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if utilities.is_set (PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc ); 								-- Deals with italics, spaces, etc.
		text = text:sub(1, -sepc:len() - 1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite&gt; element
	local options_t = {};
	options_t.class = cite_class_attribute_make (config.CitationClass, Mode);

	local Ref = is_valid_parameter_value (A['Ref'], A:ORIGIN('Ref'), cfg.keywords_lists['ref'], nil, true);	-- nil when |ref=harv; A['Ref'] else

	if 'none' ~= cfg.keywords_xlate[(Ref and Ref:lower()) or ''] then
		local namelist_t = {};													-- holds selected contributor, author, editor name list
		local year = first_set ({Year, anchor_year}, 2);						-- Year first for legacy citations and for YMD dates that require disambiguation

		if #c &gt; 0 then															-- if there is a contributor list
			namelist_t = c;														-- select it
		elseif #a &gt; 0 then														-- or an author list
			namelist_t = a;
		elseif #e &gt; 0 then														-- or an editor list
			namelist_t = e;
		end
		local citeref_id;
		if #namelist_t &gt; 0 then													-- if there are names in namelist_t
			citeref_id = make_citeref_id (namelist_t, year);					-- go make the CITEREF anchor
			if mw.uri.anchorEncode (citeref_id) == ((Ref and mw.uri.anchorEncode (Ref)) or '') then	-- Ref may already be encoded (by {{sfnref}}) so citeref_id must be encoded before comparison
				utilities.set_message ('maint_ref_duplicates_default');
			end
		else
			citeref_id = '';													-- unset
		end
		options_t.id = Ref or citeref_id;
	end

	if string.len (text:gsub('%b&lt;&gt;', '')) &lt;= 2 then								-- remove html and html-like tags; then get length of what remains; 
		z.error_cats_t = {};													-- blank the categories list
		z.error_msgs_t = {};													-- blank the error messages list
		OCinSoutput = nil;														-- blank the metadata string
		text = '';																-- blank the the citation
		utilities.set_message ('err_empty_citation');							-- set empty citation message and category
	end
	
	local render_t = {};														-- here we collect the final bits for concatenation into the rendered citation

	if utilities.is_set (options_t.id) then										-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render_t, utilities.substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options_t.id), mw.text.nowiki(options_t.class), text}));	-- when |ref= is set or when there is a namelist
	else
		table.insert (render_t, utilities.substitute (cfg.presentation['cite'], {mw.text.nowiki(options_t.class), text}));	-- when |ref=none or when namelist_t empty and |ref= is missing or is empty
	end		

	if OCinSoutput then															-- blanked when citation is 'empty' so don't bother to add boilerplate metadata span
		table.insert (render_t, utilities.substitute (cfg.presentation['ocins'], OCinSoutput));	-- format and append metadata to the citation
	end

	local template_name = ('citation' == config.CitationClass) and 'citation' or 'cite ' .. (cfg.citation_class_map_t[config.CitationClass] or config.CitationClass);
	local template_link = '[[Template:' .. template_name .. '|' .. template_name .. ']]';	-- TODO: if kept, these require some sort of i18n
	local msg_prefix = '&lt;code class=&quot;cs1-code&quot;&gt;{{' .. template_link .. '}}&lt;/code&gt;: ';

	if 0 ~= #z.error_msgs_t then
		mw.addWarning (utilities.substitute (cfg.messages.warning_msg_e, template_link));

		table.insert (render_t, ' ');											-- insert a space between citation and its error messages
		table.sort (z.error_msgs_t);											-- sort the error messages list; sorting includes wrapping &lt;span&gt; and &lt;code&gt; tags; hidden-error sorts ahead of visible-error

		local hidden = true;													-- presume that the only error messages emited by this template are hidden
		for _, v in ipairs (z.error_msgs_t) do									-- spin through the list of error messages
			if v:find ('cs1-visible-error', 1, true) then						-- look for the visible error class name
				hidden = false;													-- found one; so don't hide the error message prefix
				break;															-- and done because no need to look further
			end
		end

		z.error_msgs_t[1] = table.concat ({utilities.error_comment (msg_prefix, hidden), z.error_msgs_t[1]});	-- add error message prefix to first error message to prevent extraneous punctuation
		table.insert (render_t, table.concat (z.error_msgs_t, '; '));			-- make a big string of error messages and add it to the rendering
	end

	if 0 ~= #z.maint_cats_t then
		mw.addWarning (utilities.substitute (cfg.messages.warning_msg_m, template_link));

		table.sort (z.maint_cats_t);											-- sort the maintenance messages list

		local maint_msgs_t = {};												-- here we collect all of the maint messages

		if 0 == #z.error_msgs_t then											-- if no error messages
			table.insert (maint_msgs_t, msg_prefix);							-- insert message prefix in maint message livery
		end
		
		for _, v in ipairs( z.maint_cats_t ) do									-- append maintenance categories
			table.insert (maint_msgs_t, 										-- assemble new maint message and add it to the maint_msgs_t table
				table.concat ({v, ' (', utilities.substitute (cfg.messages[':cat wikilink'], v), ')'})
				);
		end
		table.insert (render_t, utilities.substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs_t, ' ')));	-- wrap the group of maint messages with proper presentation and save
	end

	if not no_tracking_cats then
		for _, v in ipairs (z.error_cats_t) do									-- append error categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
		end
		for _, v in ipairs (z.maint_cats_t) do									-- append maintenance categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
		end
		for _, v in ipairs (z.prop_cats_t) do									-- append properties categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
		end
	end

	return table.concat (render_t);												-- make a big string and done
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class, empty)
	local name = tostring (name);
	local enum_name;															-- for enumerated parameters, is name with enumerator replaced with '#'
	local state;
	local function state_test (state, name)										-- local function to do testing of state values
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			if empty then return nil; end										-- empty deprecated parameters are treated as unknowns
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
		if 'tracked' == state then
			local base_name = name:gsub ('%d', '');								-- strip enumerators from parameter names that have them to get the base name
			utilities.add_prop_cat ('tracked-param', {base_name}, base_name);	-- add a properties category; &lt;base_name&gt; modifies &lt;key&gt;
			return true;
		end
		return nil;
	end		

	if name:find ('#') then														-- # is a cs1|2 reserved character so parameters with # not permitted
		return nil;
	end

	if utilities.in_array (cite_class, whitelist.preprint_template_list ) then	-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[name];
		if true == state_test (state, name) then return true; end

		state = whitelist.preprint_arguments[cite_class][name];					-- look in the parameter-list for the template identified by cite_class
		if true == state_test (state, name) then return true; end

																				-- limited enumerated parameters list
		enum_name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );										-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
		state = whitelist.limited_numbered_arguments[enum_name];
		if true == state_test (state, name) then return true; end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates

	if utilities.in_array (cite_class, whitelist.unique_param_template_list) then 	-- experiment for template-specific parameters for templates that accept parameters from the basic argument list
		state = whitelist.unique_arguments[cite_class][name];					-- look in the template-specific parameter-lists for the template identified by cite_class
		if true == state_test (state, name) then return true; end
	end																			-- if here, fall into general validation
		
	state = whitelist.basic_arguments[name];									-- all other templates; all normal parameters allowed
	if true == state_test (state, name) then return true; end

																				-- all enumerated parameters allowed
	enum_name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
	state = whitelist.numbered_arguments[enum_name];
	if true == state_test (state, name) then return true; end

	return false;																-- not supported because not found or name is set to nil
end


--[=[-------------------------&lt; I N T E R _ W I K I _ C H E C K &gt;----------------------------------------------

check &lt;value&gt; for inter-language interwiki-link markup.  &lt;prefix&gt; must be a MediaWiki-recognized language
code.  when these values have the form (without leading colon):
	[[&lt;prefix&gt;:link|label]] return label as plain-text
	[[&lt;prefix&gt;:link]] return &lt;prefix&gt;:link as plain-text

return value as is else

]=]

local function inter_wiki_check (parameter, value)
	local prefix = value:match ('%[%[(%a+):');									-- get an interwiki prefix if one exists
	local _;
	
	if prefix and cfg.inter_wiki_map[prefix:lower()] then						-- if prefix is in the map, needs preceding colon so
		utilities.set_message ('err_bad_paramlink', parameter);					-- emit an error message
		_, value, _ = utilities.is_wikilink (value);							-- extract label portion from wikilink
	end
	return value;
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe.  There are two tests made:
	{{cite ... |title=Title access-date=2016-03-17}}	-- the first parameter has a value and whitespace separates that value from the missing pipe parameter name
	{{cite ... |title=access-date=2016-03-17}}			-- the first parameter has no value (whitespace after the first = is trimmed by MediaWiki)
cs1|2 shares some parameter names with XML/HTML attributes: class=, title=, etc.  To prevent false positives XML/HTML
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (parameter, value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove XML/HTML tags because attributes: class=, title=, etc.

	capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then										-- if the capture is a valid parameter name
		utilities.set_message ('err_missing_pipe', parameter);
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ P U N C T &gt;--------------------------------------

look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_punc (param, value)
	if 'number' == type (param) then
		return;
	end
	
	param = param:gsub ('%d+', '#');											-- enumerated name-list mask params allow terminal punct; normalize 
	if cfg.punct_skip[param] then
		return;																	-- parameter name found in the skip table so done
	end
	
	if value:match ('[,;:]$') then
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
	if value:match ('^=') then													-- sometimes an extraneous '=' character appears ...
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ U R L &gt;------------------------------------------

look for extraneous url parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_url (url_param_t)
	local url_error_t = {};
	
	check_for_url (url_param_t, url_error_t);									-- extraneous url check
	if 0 ~= #url_error_t then													-- non-zero when there are errors
		table.sort (url_error_t);
		utilities.set_message ('err_param_has_ext_link', {utilities.make_sep_list (#url_error_t, url_error_t)});	-- add this error message
	end
end


--[[--------------------------&lt; C I T A T I O N &gt;--------------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

local function citation(frame)
	Frame = frame;																-- save a copy in case we need to display an error message in preview mode
	is_sandbox = nil ~= string.find (frame:getTitle(), 'sandbox', 1, true);
	local pframe = frame:getParent()
	local styles;
	
	if is_sandbox then															-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		styles = 'Module:Citation/CS1/sandbox/styles.css';
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
		styles = 'Module:Citation/CS1/styles.css';
	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the selected cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	is_preview_mode = not utilities.is_set (frame:preprocess ('{{REVISIONID}}'));

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text;															-- used as a flag

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do											-- get parameters from the {{#invoke}} frame
		config[k] = v;
	--	args[k] = v;															-- crude debug support that allows us to render a citation from module {{#invoke:}}; skips parameter validation; TODO: keep?
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	local empty_unknowns = {};													-- sequence table to hold empty unknown params for error message listing
	for k, v in pairs( pframe.args ) do											-- get parameters from the parent (template) frame
		v = mw.ustring.gsub (v, '^%s*(.-)%s*$', '%1');							-- trim leading/trailing whitespace; when v is only whitespace, becomes empty string
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				if type (k) ~= 'string' then									-- exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text = utilities.set_message ('err_text_ignored', {v});
					end
				elseif validate (k:lower(), config.CitationClass) then 
					error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, k:lower()});	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if is_sandbox then										-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no capture in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = utilities.substitute (param, capture);		-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, param});	-- set the suggestion error message
							else
								error_text = utilities.set_message ('err_parameter_ignored', {k});	-- suggested param not supported by this template
								v = '';											-- unset
							end
						end
					end
					if not utilities.is_set (error_text) then					-- couldn't match with a pattern, is there an explicit suggestion?						
						if (suggestions.suggestions[ k:lower() ] ~= nil) and validate (suggestions.suggestions[ k:lower() ], config.CitationClass) then
							utilities.set_message ('err_parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]});
						else
							utilities.set_message ('err_parameter_ignored', {k});
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
			end

			args[k] = v;														-- save this parameter and its value

		elseif not utilities.is_set (v) then									-- for empty parameters
			if not validate (k, config.CitationClass, true) then				-- is this empty parameter a valid parameter
				k = ('' == k) and '(empty string)' or k;						-- when k is empty string (or was space(s) trimmed to empty string), replace with descriptive text
				table.insert (empty_unknowns, utilities.wrap_style ('parameter', k));	-- format for error message and add to the list
			end
																				-- crude debug support that allows us to render a citation from module {{#invoke:}} TODO: keep?
	--	elseif args[k] ~= nil or (k == 'postscript') then						-- when args[k] has a value from {{#invoke}} frame (we don't normally do that)
	--		args[k] = v;														-- overwrite args[k] with empty string from pframe.args[k] (template frame); v is empty string here
		end																		-- not sure about the postscript bit; that gets handled in parameter validation; historical artifact?
	end	

	if 0 ~= #empty_unknowns then												-- create empty unknown error message
		utilities.set_message ('err_param_unknown_empty', {
			1 == #empty_unknowns and '' or 's',
			utilities.make_sep_list (#empty_unknowns, empty_unknowns)
			});
	end

	local url_param_t = {};

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);											-- look for invisible characters
		end
		has_extraneous_punc (k, v);												-- look for extraneous terminal punctuation in parameter values
		missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?
		args[k] = inter_wiki_check (k, v);										-- when language interwiki-linked parameter missing leading colon replace with wiki-link label

		if 'string' == type (k) and not cfg.url_skip[k] then					-- when parameter k is not positional and not in url skip table
			url_param_t[k] = v;													-- make a parameter/value list for extraneous url check
		end
	end

	has_extraneous_url (url_param_t);											-- look for url in parameter values where a url does not belong

	return table.concat ({
		frame:extensionTag ('templatestyles', '', {src=styles}),
		citation0( config, args)
	});
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {citation = citation};</text>
      <sha1>kpzwmdqxhrh3hamiw6chl3i9rsg8izd</sha1>
    </revision>
    <revision>
      <id>4747</id>
      <parentid>4746</parentid>
      <timestamp>2022-01-26T14:22:30Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4747</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="205172" sha1="og2ozrff88n7bwcpf68543a6wbtutg6" xml:space="preserve">require ('Module:No globals');

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------

each of these counts against the Lua upvalue limit

]]

local validation;																-- functions in Module:Citation/CS1/Date_validation

local utilities;																-- functions in Module:Citation/CS1/Utilities
local z ={};																	-- table of tables in Module:Citation/CS1/Utilities

local identifiers;																-- functions and tables in Module:Citation/CS1/Identifiers
local metadata;																	-- functions in Module:Citation/CS1/COinS
local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;---------------

declare variables here that have page-wide scope that are not brought in from
other modules; that are created here and used here

]]

local added_deprecated_cat;														-- Boolean flag so that the category is added only once
local added_vanc_errs;															-- Boolean flag so we only emit one Vancouver error / category
local added_generic_name_errs;													-- Boolean flag so we only emit one generic name error / category and stop testing names once an error is encountered
local Frame;																	-- holds the module's frame table
local is_preview_mode;															-- true when article is in preview mode; false when using 'Preview page with this template' (previewing the module)
local is_sandbox;																-- true when using sandbox modules to render citation


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if utilities.is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a Boolean declared in page scope variables above

]]

local function add_vanc_error (source, position)
	if added_vanc_errs then return end
		
	added_vanc_errs = true;														-- note that we've added this category
	utilities.set_message ('err_vancouver', {source, position});
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a URI scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of TLDs: https://www.iana.org/domains/root/db

RFC 952 (modified by RFC 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the TLD.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a URL with a scheme) will be stripped
here.  Perhaps not necessary but retained in case it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ASCII characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the TLD) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and TLD or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%w]') then											-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at Wikisource
		return false;
	end

	local patterns = {															-- patterns that look like URLs
		'%f[%w][%w][%w%-]+[%w]%.%a%a+$',										-- three or more character hostname.hostname or hostname.tld
		'%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$',									-- internationalized domain name with ACE prefix
		'%f[%a][qxz]%.com$',													-- assigned one character .com hostname (x.com times out 2015-12-10)
		'%f[%a][iq]%.net$',														-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		'%f[%w][%w]%.%a%a$',													-- one character hostname and ccTLD (2 chars)
		'%f[%w][%w][%w]%.%a%a+$',												-- two character hostname and TLD
		'^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?',								-- IPv4 address
		}

	for _, pattern in ipairs (patterns) do										-- loop through the patterns list
		if domain:match (pattern) then
			return true;														-- if a match then we think that this thing that purports to be a URL is a URL
		end
	end

	for _, d in ipairs ({'cash', 'company', 'today', 'org'}) do					-- look for single letter second level domain names for these top level domains
		if domain:match ('%f[%w][%w]%.' .. d) then
			return true
		end
	end
	return false;																-- no matches, we don't know what this thing is
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a URL appear to be a valid URL; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if utilities.is_set (scheme) then											-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when URL is protocol-relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a URL into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following TLD) (if any) and any path(/), query(?) or fragment(#).

If protocol-relative URL, return nil scheme and domain else return nil for both scheme and domain.

When not protocol-relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Any URL that does not have news: scheme must have authority indicator (//).  TODO: are there other common schemes
like news: that don't use authority indicator?

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol-relative URL
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		if utilities.is_set (authority) then
			authority = authority:gsub ('//', '', 1);							-- replace place 1 pair of '/' with nothing;
			if utilities.is_set(authority) then									-- if anything left (1 or 3+ '/' where authority should be) then
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		else
			if not scheme:match ('^news:') then									-- except for news:..., MediaWiki won't link URLs that do not have authority indicator; TODO: a better way to do this test?
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link=, etc. for properly formatted content: no wikilinks, no URLs

Link parameters are to hold the title of a Wikipedia article, so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki URLs and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid URL (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid URL (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from URL; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid URL
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wiki-linked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

check &lt;link&gt; for inter-language interwiki-link prefix.  prefix must be a MediaWiki-recognized language
code and must begin with a colon.

]]

local function link_title_ok (link, lorig, title, torig)
local orig;
	if utilities.is_set (link) then 											-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		elseif link:match ('^%a+:') then										-- if the link is what looks like an interwiki
			local prefix = link:match ('^(%a+):'):lower();						-- get the interwiki prefix

			if cfg.inter_wiki_map[prefix] then									-- if prefix is in the map, must have preceding colon
				orig = lorig;													-- flag as error
			end
		end
	end

	if utilities.is_set (orig) then
		link = '';																-- unset
		utilities.set_message ('err_bad_paramlink', orig);						-- URL or wikilink in |title= with |title-link=;
	end
	
	return link;																-- link if ok, empty string else
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the URL into scheme and domain
portions, or for protocol-relative (//example.com) URLs, just the domain.  Use is_url() to validate the two
portions of the URL.  If both are valid, or for protocol-relative if domain is valid, return true, else false.

Because it is different from a standard URL, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper URL
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from URL;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a URL.  The test will also find external wikilinks
that use protocol-relative URLs. Also finds bare URLs.

The frontier pattern prevents a match on interwiki-links which are similar to scheme:path URLs.  The tests that
find bracketed URLs are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext. wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol-relative ext. wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare URL with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol-relative bare URL: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a URL
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list, error_list)
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a URL add an error message
			table.insert (error_list, utilities.wrap_style ('parameter', k));
		end
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		utilities.set_message ('err_wikilink_in_url', {});
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link (URL, label, source, access)
	local err_msg = '';
	local domain;
	local path;
	local base_url;

	if not utilities.is_set (label) then
		label = URL;
		if utilities.is_set (source) then
			utilities.set_message ('err_bare_url_missing_title', {utilities.wrap_style ('parameter', source)});
		else
			error (cfg.messages[&quot;bare_url_no_origin&quot;]);
		end			
	end
	if not check_url (URL) then
		utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)});
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the URL into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['['] = '%5b', [']'] = '%5d'});			-- replace '[' and ']' with their percent-encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat ({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wiki-markup URL

	if utilities.is_set (access) then											-- access level (subscription, registration, limited)
		base_url = utilities.substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end

	return base_url;
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a Boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		utilities.set_message ('err_deprecated_params', {name});				-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wiki-markup) are not kerned.

Replaces Unicode quote marks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc.; not for book titles.

]=]

local function kern_quotes (str)
	local cap = '';
	local wl_type, label, link;

	wl_type, label, link = utilities.is_wikilink (str);							-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-left'], str);
			str = utilities.substitute (cfg.presentation['kern-right'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = utilities.substitute (cfg.presentation['kern-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label = mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label = mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap = mw.ustring.match (label, &quot;^([\&quot;\'][^\'].+)&quot;);						-- match leading double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-left'], cap);
		end
	
		cap = mw.ustring.match (label, &quot;^(.+[^\'][\&quot;\'])$&quot;)						-- match trailing double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-right'], cap);
		end
		
		if 2 == wl_type then
			str = utilities.make_wikilink (link, label);						-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin-based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate RTL languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO 639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO 639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title=, |script-chapter=, |script-&lt;periodical&gt;=

]]

local function format_script_value (script_value, script_param)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%l?%s*:') then									-- if first 3 or 4 non-space characters are script language prefix
		lang = script_value:match('^(%l%l%l?)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not utilities.is_set (lang) then
			utilities.set_message ('err_script_parameter', {script_param, 'missing title part'});		-- prefix without 'title'; add error message
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_code_remap[lang] or mw.language.fetchLanguageName( lang, cfg.this_wiki_code );	-- get language name so that we can use it to categorize
		if utilities.is_set (name) then											-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l+%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if utilities.in_array (lang, cfg.script_lang_codes) then
				utilities.add_prop_cat ('script', {name, lang})
			else
				utilities.set_message ('err_script_parameter', {script_param, 'unknown language code'});	-- unknown script-language; add error message
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			utilities.set_message ('err_script_parameter', {script_param, 'invalid language code'});		-- invalid language code; add error message
			lang = '';															-- invalid so set lang to empty string
		end
	else
		utilities.set_message ('err_script_parameter', {script_param, 'missing prefix'});				-- no language code prefix; add error message
	end
	script_value = utilities.substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is RTL

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script
value has been wrapped in &lt;bdi&gt; tags.

]]

local function script_concatenate (title, script, script_param)
	if utilities.is_set (script) then
		script = format_script_value (script, script_param);					-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; returns empty string on error
		if utilities.is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not utilities.is_set ( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return utilities.substitute ( msg, str );								-- including template text
	else
		return utilities.substitute ( cfg.messages[key], str );
	end		
end


--[[----------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;-------------------

Makes a Wikisource URL from Wikisource interwiki-link.  Returns the URL and appropriate
label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;
	local wikisource_prefix = table.concat ({'https://', cfg.this_wiki_code, '.wikisource.org/wiki/'});

	wl_type, D, L = utilities.is_wikilink (str);								-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 1 == wl_type then													-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end

	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable URL
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent-encoding of fragment marker
	end

	return ws_url, ws_label, L or D;											-- return proper URL or nil and a label or nil
end


--[[----------------&lt; F O R M A T _ P E R I O D I C A L &gt;-----------------------

Format the three periodical parameters: |script-&lt;periodical&gt;=, |&lt;periodical&gt;=,
and |trans-&lt;periodical&gt;= into a single Periodical meta-parameter.

]]

local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)

	if not utilities.is_set (periodical) then
		periodical = '';														-- to be safe for concatenation
	else
		periodical = utilities.wrap_style ('italic-title', periodical);			-- style 
	end

	periodical = script_concatenate (periodical, script_periodical, script_periodical_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (trans_periodical) then
		trans_periodical = utilities.wrap_style ('trans-italic-title', trans_periodical);
		if utilities.is_set (periodical) then
			periodical = periodical .. ' ' .. trans_periodical;
		else																	-- here when trans-periodical without periodical or script-periodical
			periodical = trans_periodical;
			utilities.set_message ('err_trans_missing_title', {'periodical'});
		end
	end

	return periodical;
end


--[[------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;---------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=,
and |chapter-url= into a single chapter meta- parameter (chapter_url_source used
for error messages).

]]

local function format_chapter_title (script_chapter, script_chapter_source, chapter, chapter_source, trans_chapter, trans_chapter_source, chapter_url, chapter_url_source, no_quotes, access)
	local ws_url, ws_label, L = wikisource_url_make (chapter);					-- make a wikisource URL and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', ' ');									-- replace underscore separators with space characters
		chapter = ws_label;
	end

	if not utilities.is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from module provided quote marks
			chapter = utilities.wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, script_chapter, script_chapter_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (chapter_url) then
		chapter = external_link (chapter_url, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');	-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if utilities.is_set (trans_chapter) then
		trans_chapter = utilities.wrap_style ('trans-quoted-title', trans_chapter);
		if utilities.is_set (chapter) then
			chapter = chapter .. ' ' .. trans_chapter;
		else																	-- here when trans_chapter without chapter or script-chapter
			chapter = trans_chapter;
			chapter_source = trans_chapter_source:match ('trans%-?(.+)');		-- when no chapter, get matching name from trans-&lt;param&gt;
			utilities.set_message ('err_trans_missing_title', {chapter_source});
		end
	end

	return chapter;
end


--[[----------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;-------------------

This function searches a parameter's value for non-printable or invisible characters.
The search stops at the first match.

This function will detect the visible replacement character when it is part of the Wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers
(gallery, math, pre, ref) and identifies them with a slightly different error message.
See also coins_cleanup().

Output of this function is an error message that identifies the character or the
Unicode group, or the stripmarker that was detected along with its position (or,
for multi-byte characters, the position of its first byte) in the parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local stripmarker;															-- boolean set true when a stripmarker is found

	capture = string.match (v, '[%w%p ]*');										-- test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no Unicode characters
		return;
	end

	for _, invisible_char in ipairs (cfg.invisible_chars) do
		local char_name = invisible_char[1];									-- the character or group name
		local pattern = invisible_char[2];										-- the pattern used to find it
		position, _, capture = mw.ustring.find (v, pattern);					-- see if the parameter value contains characters that match the pattern
		
		if position and (cfg.invisible_defs.zwj == capture) then				-- if we found a zero-width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- it's ok if one of the Indic scripts
				position = nil;													-- unset position
			elseif cfg.emoji[mw.ustring.codepoint (v, position+1)] then			-- is zwj followed by a character listed in emoji{}?
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and utilities.in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and cfg.invisible_defs.del == capture then	-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture and not (cfg.invisible_defs.del == capture or cfg.invisible_defs.zwj == capture) then
					err_msg = capture .. ' ' .. char_name;
				else
					err_msg = char_name .. ' ' .. 'character';
				end

				utilities.set_message ('err_invisible_char', {err_msg, utilities.wrap_style ('parameter', param), position});	-- add error message
				return;															-- and done with this parameter
			end
		end
	end
end


--[[-------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------

Argument wrapper.  This function provides support for argument mapping defined
in the configuration file so that multiple names can be transparently aliased to
single internal variable.

]]

local function argument_wrapper ( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function ( self, k )
			local dummy = self[k];												-- force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = utilities.select_one ( args, list, 'err_redundant_parameters' );
				if origin[k] == nil then
					origin[k] = '';												-- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] .. ': ' .. k);
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;-------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.
When date is DD MMMM YYYY or is MMMM DD, YYYY then wrap in nowrap span:
&lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap = '';
	local cap2 = '';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = utilities.substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = utilities.substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;---------------------

This function sets default title types (equivalent to the citation including
|type=&lt;default value&gt;) for those templates that have defaults. Also handles the
special case where it is desirable to omit the title type from the rendered citation
(|type=none).

]]

local function set_titletype (cite_class, title_type)
	if utilities.is_set (title_type) then
		if 'none' == cfg.keywords_xlate[title_type] then
			title_type = '';													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; S A F E _ J O I N &gt;-----------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'duplicate character'
		if 1 == #duplicate_char then											-- for single byte ASCII characters use the string library functions
			f.gsub = string.gsub
			f.match = string.match
			f.sub = string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub = mw.ustring.gsub
			f.match = mw.ustring.match
			f.sub = mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1, 1) == '&lt;' then										-- special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove HTML markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1, 1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc.?
				trim = false;
				end_chr = f.sub(str, -1, -1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr .. &quot;)&quot;				-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1, -2);									-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;''&quot; then		-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5, -1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;]]&quot; then		-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3, -1) == duplicate_char .. '&quot;]' then	-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2, -1) == duplicate_char .. &quot;]&quot; then	-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2, -1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1, -3);								-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains HTML markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows HTML markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value; 												-- add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;-----------------------------

returns true if suffix is properly formed Jr, Sr, or ordinal in the range 1–9.
Puncutation not allowed.

]]

local function is_suffix (suffix)
	if utilities.in_array (suffix, {'Jr', 'Sr', 'Jnr', 'Snr', '1st', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;-------------------

For Vancouver style, author/editor names are supposed to be rendered in Latin
(read ASCII) characters.  When a name uses characters that contain diacritical
marks, those characters are to be converted to the corresponding Latin
character. When a name is written using a non-Latin alphabet or logogram, that
name is to be transliterated into Latin characters. The module doesn't do this
so editors may/must.

This test allows |first= and |last= names to contain any of the letters defined
in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes.
	(http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;)
	or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written outside of the code editor and pasted here because the code editor
gets confused between character insertion point and cursor position. The test has
been rewritten to use decimal character escape sequence for the individual bytes
of the Unicode characters so that it is not necessary to use an external editor
to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first, suffix, position)
	if not suffix then
		if first:find ('[,%s]') then											-- when there is a space or comma, might be first name/initials + generational suffix
			first = first:match ('(.-)[,%s]+');									-- get name/initials
			suffix = first:match ('[,%s]+(.+)$');								-- get generational suffix
		end
	end
	if utilities.is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error (cfg.err_msg_supl.suffix, position);
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error (cfg.err_msg_supl['non-Latin char'], position);
			return false;														-- not a string of Latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-style=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period.
See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc.) to be rendered
as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format
because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the
Unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first, position)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just initials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error (cfg.err_msg_supl.suffix, position);			-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word

	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i], 1, 1));			-- insert the initial at end of initials table
		end
		i = i + 1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; L I S T _ P E O P L E &gt;--------------------------

Formats a list of people (authors, contributors, editors, interviewers, translators) 

names in the list will be linked when
	|&lt;name&gt;-link= has a value
	|&lt;name&gt;-mask- does NOT have a value; masked names are presumed to have been
		rendered previously so should have been linked there

when |&lt;name&gt;-mask=0, the associated name is not rendered

]]

local function list_people (control, people, etal)
	local sep;
	local namesep;
	local format = control.format;
	local maximum = control.maximum;
	local name_list = {};

	if 'vanc' == format then													-- Vancouver-like name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between names is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between names is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub (-1, -1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if utilities.is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end		-- returned 0 is for EditorCount; not used for other names
	
	for i, person in ipairs (people) do
		if utilities.is_set (person.last) then
			local mask = person.mask;
			local one;
			local sep_one = sep;

			if utilities.is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			end
			
			if mask then
				local n = tonumber (mask);										-- convert to a number if it can be converted; nil else
				if n then
					one = 0 ~= n and string.rep(&quot;&amp;mdash;&quot;, n) or nil;			-- make a string of (n &gt; 0) mdashes, nil else, to replace name
					person.link = nil;											-- don't create link to name if name is replaces with mdash string or has been set nil
				else
					one = mask;													-- replace name with mask text (must include name-list separator)
					sep_one = &quot; &quot;;												-- modify name-list separator
				end
			else
				one = person.last;												-- get surname
				local first = person.first										-- get given name
				if utilities.is_set (first) then
					if (&quot;vanc&quot; == format) then									-- if Vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first, nil, i) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials (first, i);				-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
			end
			if utilities.is_set (person.link) then
				one = utilities.make_wikilink (person.link, one);				-- link author/editor
			end
			if one then															-- if &lt;one&gt; has a value (name, mdash replacement, or mask text replacement)
				table.insert (name_list, one);									-- add it to the list of names
				table.insert (name_list, sep_one);								-- add the proper name-list separator
			end
		end
	end

	local count = #name_list / 2;												-- (number of names + number of separators) divided by 2
	if 0 &lt; count then 
		if 1 &lt; count and not etal then
			if 'amp' == format then
				name_list[#name_list-2] = &quot; &amp; &quot;;								-- replace last separator with ampersand text
			elseif 'and' == format then
				if 2 == count then
					name_list[#name_list-2] = cfg.presentation.sep_nl_and;		-- replace last separator with 'and' text
				else
					name_list[#name_list-2] = cfg.presentation.sep_nl_end;		-- replace last separator with '(sep) and' text
				end
			end
		end
		name_list[#name_list] = nil;											-- erase the last separator
	end

	local result = table.concat (name_list);									-- construct list
	if etal and utilities.is_set (result) then									-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've got a last-first list and etal so add et al.
	end
	
	return result, count;														-- return name-list string and count of number of names (count used for editor names only)
end


--[[--------------------&lt; M A K E _ C I T E R E F _ I D &gt;-----------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise
returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that
order.  year is Year or anchor_year.

]]

local function make_citeref_id (namelist, year)
	local names={};							-- a table for the one to four names and year
	for i,v in ipairs (namelist) do			-- loop through the list and take up to the first four last names
		names[i] = v.last
		if i == 4 then break end			-- if four then done
	end
	table.insert (names, year);				-- add the year at the end
	local id = table.concat(names);			-- concatenate names and year for CITEREF id
	if utilities.is_set (id) then			-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;				-- add the CITEREF portion
	else
		return '';							-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; C I T E _ C L A S S _A T T R I B U T E _M A K E &gt;------------------------------

construct &lt;cite&gt; tag class attribute for this citation.

&lt;cite_class&gt; – config.CitationClass from calling template
&lt;mode&gt; – value from |mode= parameter

]]

local function cite_class_attribute_make (cite_class, mode)
	local class_t = {};
	table.insert (class_t, 'citation');											-- required for blue highlight
	if 'citation' ~= cite_class then
		table.insert (class_t, cite_class);										-- identify this template for user css
		table.insert (class_t, utilities.is_set (mode) and mode or 'cs1');		-- identify the citation style for user css or javascript
	else
		table.insert (class_t, utilities.is_set (mode) and mode or 'cs2');		-- identify the citation style for user css or javascript
	end
	for _, prop_key in ipairs (z.prop_keys_t) do
		table.insert (class_t, prop_key);										-- identify various properties for user css or javascript
	end

	return table.concat (class_t, ' ');											-- make a big string and done
end


--[[---------------------&lt; N A M E _ H A S _ E T A L &gt;--------------------------

Evaluates the content of name parameters (author, editor, etc.) for variations on
the theme of et al.  If found, the et al. is removed, a flag is set to true and
the function returns the modified name and the flag.

This function never sets the flag to false but returns its previous state because
it may have been set by previous passes through this function or by the associated
|display-&lt;names&gt;=etal parameter

]]

local function name_has_etal (name, etal, nocat, param)

	if utilities.is_set (name) then												-- name can be nil in which case just return
		local patterns = cfg.et_al_patterns; 									-- get patterns from configuration
		
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns
			if name:match (pattern) then										-- if this 'et al' pattern is found in name
				name = name:gsub (pattern, '');									-- remove the offending text
				etal = true;													-- set flag (may have been set previously here or by |display-&lt;names&gt;=etal)
				if not nocat then												-- no categorization for |vauthors=
					utilities.set_message ('err_etal', {param});				-- and set an error if not added
				end
			end
		end
	end

	return name, etal;
end


--[[---------------------&lt; N A M E _ I S _ N U M E R I C &gt;----------------------

Add maint cat when name parameter value does not contain letters.  Does not catch
mixed alphanumeric names so |last=A. Green (1922-1987) does not get caught in the
current version of this test but |first=(1888) is caught.

returns nothing

]]

local function name_is_numeric (name, list_name)
	if utilities.is_set (name) then
		if mw.ustring.match (name, '^[%A]+$') then								-- when name does not contain any letters
			utilities.set_message ('maint_numeric_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
		end
	end
end


--[[-----------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;------------------

Evaluates the content of last/surname (authors etc.) parameters for multiple names.
Multiple names are indicated if there is more than one comma or any &quot;unescaped&quot;
semicolons. Escaped semicolons are ones used as part of selected HTML entities.
If the condition is met, the function adds the multiple name maintenance category.

returns nothing

]]

local function name_has_mult_names (name, list_name)
	local _, commas, semicolons, nbsps;
	if utilities.is_set (name) then
		_, commas = name:gsub (',', '');										-- count the number of commas
		_, semicolons = name:gsub (';', '');									-- count the number of semicolons
		-- nbsps probably should be its own separate count rather than merged in
		-- some way with semicolons because Lua patterns do not support the
		-- grouping operator that regex does, which means there is no way to add
		-- more entities to escape except by adding more counts with the new
		-- entities
		_, nbsps = name:gsub ('&amp;nbsp;','');										-- count nbsps
		
		-- There is exactly 1 semicolon per &amp;nbsp; entity, so subtract nbsps
		-- from semicolons to 'escape' them. If additional entities are added,
		-- they also can be subtracted.
		if 1 &lt; commas or 0 &lt; (semicolons - nbsps) then
			utilities.set_message ('maint_mult_names', cfg.special_case_translation [list_name]);	-- add a maint message
		end
	end
end


--[[--------------------------&lt; I S _ G E N E R I C &gt;----------------------------------------------------------

Compares values assigned to various parameter according to the string provided as &lt;item&gt; in the function call:
	'generic_names': |last=, |first=, |editor-last=, etc value against list of known generic name patterns
	'generic_titles': |title=
Returns true when pattern matches; nil else

The k/v pairs in cfg.special_case_translation[item] each contain two tables, one for English and one for another
'local' language.Each of those tables contain another table that holds the string or pattern (whole or fragment)
in index [1]. index [2] is a Boolean that tells string.find() or mw.ustring.find() to do plain-text search (true)
or a pattern search (false).  The intent of all this complexity is to make these searches as fast as possible so
that we don't run out of processing time on very large articles.

]]

local function is_generic (item, value)
	local test_val;

	for _, generic_value in ipairs (cfg.special_case_translation[item]) do		-- spin through the list of known generic value fragments
		test_val = generic_value['en'][2] and value:lower() or value;			-- when set to 'true', plaintext search using lowercase value

		if test_val:find (generic_value['en'][1], 1, generic_value['en'][2]) then
			return true;														-- found English generic value so done

		elseif generic_value['local'] then										-- to keep work load down, generic_&lt;value&gt;['local'] should be nil except when there is a local version of the generic value
			test_val = generic_value['local'][2] and mw.ustring.lower(value) or value;	-- when set to 'true', plaintext search using lowercase value

			if mw.ustring.find (test_val, generic_value['local'][1], 1, generic_value['local'][2]) then	-- mw.ustring() because might not be Latin script
				return true;													-- found local generic value so done
			end
		end
	end
end


--[[--------------------------&lt; N A M E _ I S _ G E N E R I C &gt;------------------------------------------------

calls is_generic() to determine if &lt;name&gt; is a 'generic name' listed in cfg.generic_names; &lt;name_alias&gt; is the
parameter name used in error messaging

]]

local function name_is_generic (name, name_alias)
	if not added_generic_name_errs  and is_generic ('generic_names', name) then
		utilities.set_message ('err_generic_name', name_alias);					-- set an error message
		added_generic_name_errs = true;
	end
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------

This function calls various name checking functions used to validate the content of the various name-holding parameters.

]]

local function name_checks (last, first, list_name, last_alias, first_alias)
	local accept_name;

	if utilities.is_set (last) then
		last, accept_name = utilities.has_accept_as_written (last);				-- remove accept-this-as-written markup when it wraps all of &lt;last&gt;

		if not accept_name then													-- &lt;last&gt; not wrapped in accept-as-written markup
			name_has_mult_names (last, list_name);								-- check for multiple names in the parameter (last only)
			name_is_numeric (last, list_name);									-- check for names that are composed of digits and punctuation
			name_is_generic (last, last_alias);									-- check for names found in the generic names list
		end
	end

	if utilities.is_set (first) then
		first, accept_name = utilities.has_accept_as_written (first);			-- remove accept-this-as-written markup when it wraps all of &lt;first&gt;

		if not accept_name then													-- &lt;first&gt; not wrapped in accept-as-written markup
			name_is_numeric (first, list_name);									-- check for names that are composed of digits and punctuation
			name_is_generic (first, first_alias);								-- check for names found in the generic names list
		end
		local wl_type, D = utilities.is_wikilink (first);
		if 0 ~= wl_type then
			first = D;
			utilities.set_message ('err_bad_paramlink', first_alias);
		end
	end

	return last, first;															-- done
end


--[[----------------------&lt; E X T R A C T _ N A M E S &gt;-------------------------

Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters
(or their aliases), and their matching link and mask parameters. Stops searching
when both |lastn= and |firstn= are not found in args after two sequential attempts:
found |last1=, |last2=, and |last3= but doesn't find |last4= and |last5= then the
search is done.

This function emits an error message when there is a |firstn= without a matching
|lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not
required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.'
is stripped from the parameter and a flag (etal) returned that will cause list_people()
to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps
'et al.' out of the template's metadata.  When this occurs, an error is emitted.

]]

local function extract_names(args, list_name)
	local names = {};															-- table of names
	local last;																	-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;																-- loop counter/indexer
	local n = 1;																-- output table indexer
	local count = 0;															-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal = false;															-- return value set to true when we find some form of et al. in an author parameter

	local last_alias, first_alias, link_alias;									-- selected parameter aliases used in error messaging
	while true do
		last, last_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'err_redundant_parameters', i );		-- search through args for name components beginning at 1
		first, first_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'err_redundant_parameters', i );
		link, link_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i );
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.
		last, first = name_checks (last, first, list_name, last_alias, first_alias);						-- multiple names, extraneous annotation, etc. checks

		if first and not last then												-- if there is a firstn without a matching lastn
			local alias = first_alias:find ('given', 1, true) and 'given' or 'first';	-- get first or given form of the alias
			utilities.set_message ('err_first_missing_last', {
				first_alias,													-- param name of alias missing its mate
				first_alias:gsub (alias, {['first'] = 'last', ['given'] = 'surname'}),	-- make param name appropriate to the alias form
				});																-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			local result;
			link = link_title_ok (link, link_alias, last, last_alias);			-- check for improper wiki-markup

			if first then
				link = link_title_ok (link, link_alias, first, first_alias);	-- check for improper wiki-markup
			end

			names[n] = {last = last, first = first, link = link, mask = mask, corporate = false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				utilities.set_message ('err_missing_name', {list_name:match (&quot;(%w+)List&quot;):lower(), i - 1});	-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names and the etal flag
end


--[[--------------------------&lt; N A M E _ T A G _ G E T &gt;------------------------------------------------------

attempt to decode |language=&lt;lang_param&gt; and return language name and matching tag; nil else.

This function looks for:
	&lt;lang_param&gt; as a tag in cfg.lang_code_remap{}
	&lt;lang_param&gt; as a name in cfg.lang_name_remap{}
	
	&lt;lang_param&gt; as a name in cfg.mw_languages_by_name_t
	&lt;lang_param&gt; as a tag in cfg.mw_languages_by_tag_t
when those fail, presume that &lt;lang_param&gt; is an IETF-like tag that MediaWiki does not recognize.  Strip all
script, region, variant, whatever subtags from &lt;lang_param&gt; to leave just a two or three character language tag
and look for the new &lt;lang_param&gt; in cfg.mw_languages_by_tag_t{}

on success, return name and matching tag; on failure return nil

]]

local function name_tag_get (lang_param)
	local lang_param_lc = mw.ustring.lower (lang_param);						-- use lowercase as an index into the various tables
	local name;
	local tag;

	name = cfg.lang_code_remap[lang_param_lc];									-- assume &lt;lang_param_lc&gt; is a tag; attempt to get remapped language name 
	if name then																-- when &lt;name&gt;, &lt;lang_param&gt; is a tag for a remapped language name
		return name, lang_param;												-- so return &lt;name&gt; from remap and &lt;lang_param&gt;
	end

	tag = lang_param_lc:match ('^(%a%a%a?)%-.*');								-- still assuming that &lt;lang_param_lc&gt; is a tag; strip script, region, variant subtags
	name = cfg.lang_code_remap[tag];											-- attempt to get remapped language name with language subtag only
	if name then																-- when &lt;name&gt;, &lt;tag&gt; is a tag for a remapped language name
		return name, tag;														-- so return &lt;name&gt; from remap and &lt;tag&gt;
	end

	if cfg.lang_name_remap[lang_param_lc] then									-- not a tag, assume &lt;lang_param_lc&gt; is a name; attempt to get remapped language tag 
		return cfg.lang_name_remap[lang_param_lc][1], cfg.lang_name_remap[lang_param_lc][2];	-- for this &lt;lang_param_lc&gt;, return a (possibly) new name and appropriate tag
	end

	tag = cfg.mw_languages_by_name_t[lang_param_lc];							-- assume that &lt;lang_param_lc&gt; is a language name; attempt to get its matching tag
	
	if tag then
		return cfg.mw_languages_by_tag_t[tag], tag;								-- &lt;lang_param_lc&gt; is a name so return the name from the table and &lt;tag&gt;
	end

	name = cfg.mw_languages_by_tag_t[lang_param_lc];							-- assume that &lt;lang_param_lc&gt; is a tag; attempt to get its matching language name
	
	if name then
		return name, lang_param;												-- &lt;lang_param_lc&gt; is a tag so return &lt;name&gt; and the tag
	end
	
	tag = lang_param_lc:match ('^(%a%a%a?)%-.*');								-- is &lt;lang_param_lc&gt; an IETF-like tag that MediaWiki doesn't recognize? &lt;tag&gt; gets the language subtag; nil else

	if tag then
		name = cfg.mw_languages_by_tag_t[tag];									-- attempt to get a language name using the shortened &lt;tag&gt;
		if name then
			return name, tag;													-- &lt;lang_param_lc&gt; is an unrecognized IETF-like tag so return &lt;name&gt; and language subtag
		end
	end
end


--[[-------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code
is recognized by MediaWiki, use the returned name; if not, then use the value that
was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is
assigned to the category for that code: Category:Norwegian-language sources (no).
For valid three-character code languages, the page is assigned to the single category
for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does
not recognize three-character equivalents of two-character codes: code 'ar' is
recognized but code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th
where the language names or codes are separated from each other by commas with
optional space characters.

]]

local function language_parameter (lang)
	local tag;																	-- some form of IETF-like language tag; language subtag with optional region, sript, vatiant, etc subtags
	local lang_subtag;															-- ve populates |language= with mostly unecessary region subtags the MediaWiki does not recognize; this is the base language subtag
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_t = {};															-- table made from the value assigned to |language=

	local this_wiki_name = mw.language.fetchLanguageName (cfg.this_wiki_code, cfg.this_wiki_code);	-- get this wiki's language name

	names_t = mw.text.split (lang, '%s*,%s*');									-- names should be a comma separated list

	for _, lang in ipairs (names_t) do											-- reuse lang here because we don't yet know if lang is a language name or a language tag
		name, tag = name_tag_get (lang);										-- attempt to get name/tag pair for &lt;lang&gt;

		if utilities.is_set (tag) then
			lang_subtag = tag:lower():gsub ('^(%a%a%a?)%-.*', '%1');			-- for categorization, strip any IETF-like tags from language tag

			if cfg.this_wiki_code ~= lang_subtag then							-- when the language is not the same as this wiki's language
				if 2 == lang_subtag:len() then									-- and is a two-character tag
					utilities.add_prop_cat ('foreign-lang-source', {name, lang_subtag}, lang_subtag);		-- categorize it; tag appended to allow for multiple language categorization
				else															-- or is a recognized language (but has a three-character tag)
					utilities.add_prop_cat ('foreign-lang-source-2', {lang_subtag}, lang_subtag);			-- categorize it differently TODO: support multiple three-character tag categories per cs1|2 template?
				end
			elseif cfg.local_lang_cat_enable then								-- when the language and this wiki's language are the same and categorization is enabled
				utilities.add_prop_cat ('local-lang-source', {name, lang_subtag});		-- categorize it
			end
		else
			name = lang;														-- return whatever &lt;lang&gt; has so that we show something
			utilities.set_message ('maint_unknown_lang');						-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
 
	name = utilities.make_sep_list (#language_list, language_list);
	if (1 == #language_list) and (lang_subtag == cfg.this_wiki_code) then		-- when only one language, find lang name in this wiki lang name; for |language=en-us, 'English' in 'American English'
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[-----------------------&lt; S E T _ C S _ S T Y L E &gt;--------------------------

Gets the default CS style configuration for the given mode.
Returns default separator and either postscript as passed in or the default.
In CS1, the default postscript and separator are '.'.
In CS2, the default postscript is the empty string and the default separator is ','.

]]

local function set_cs_style (postscript, mode)
	if utilities.is_set(postscript) then
		-- emit a maintenance message if user postscript is the default cs1 postscript
		-- we catch the opposite case for cs2 in set_style
		if mode == 'cs1' and postscript == cfg.presentation['ps_' .. mode] then
			utilities.set_message ('maint_postscript');
		end
	else
		postscript = cfg.presentation['ps_' .. mode];
	end
	return cfg.presentation['sep_' .. mode], postscript;
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;-----------------------------

Sets the separator and postscript styles. Checks the |mode= first and the
#invoke CitationClass second. Removes the postscript if postscript == none.

]]

local function set_style (mode, postscript, cite_class)
	local sep;
	if 'cs2' == mode then
		sep, postscript = set_cs_style (postscript, 'cs2');
	elseif 'cs1' == mode then
		sep, postscript = set_cs_style (postscript, 'cs1');
	elseif 'citation' == cite_class	then
		sep, postscript = set_cs_style (postscript, 'cs2');
	else
		sep, postscript = set_cs_style (postscript, 'cs1');
	end

	if cfg.keywords_xlate[postscript:lower()] == 'none' then
		-- emit a maintenance message if user postscript is the default cs2 postscript
		-- we catch the opposite case for cs1 in set_cs_style
		if 'cs2' == mode or 'citation' == cite_class then
			utilities.set_message ('maint_postscript');
		end
		postscript = '';
	end
	
	return sep, postscript
end


--[=[-------------------------&lt; I S _ P D F &gt;-----------------------------------

Determines if a URL has the file extension that is one of the PDF file extensions
used by [[MediaWiki:Common.css]] when applying the PDF icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or
		url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
		url:match ('%.PDF&amp;#035') or url:match ('%.pdf&amp;#035');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;-----------------------

Applies CSS style to |format=, |chapter-format=, etc.  Also emits an error message
if the format parameter does not have a matching URL parameter.  If the format parameter
is not set and the URL contains a file extension that is recognized as a PDF document
by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if utilities.is_set (format) then
		format = utilities.wrap_style ('format', format);						-- add leading space, parentheses, resize
		if not utilities.is_set (url) then
			utilities.set_message ('err_format_missing_url', {fmt_param, url_param});	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if URL is a PDF file then
		format = utilities.wrap_style ('format', 'PDF');						-- set format to PDF
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[---------------------&lt; G E T _ D I S P L A Y _ N A M E S &gt;------------------

Returns a number that defines the number of names displayed for author and editor
name lists and a Boolean flag to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero,
return the number and the previous state of the 'etal' flag (false by default
but may have been set to true if the name list contains some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number
that is one greater than the number of authors in the list and set the 'etal' flag true.
This will cause the list_people() to display all of the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_names (max, count, list_name, etal, param)
	if utilities.is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				utilities.set_message ('err_disp_name', {param, max});			-- add error message
				max = nil;
			end
		else																	-- not a valid keyword or number
			utilities.set_message ('err_disp_name', {param, max});		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[----------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;---------------

Adds error if |page=, |pages=, |quote-page=, |quote-pages= has what appears to be
some form of p. or pp. abbreviation in the first characters of the parameter content.

check page for extraneous p, p., pp, pp., pg, pg. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when page begins PX or P# but not Px
		      where x and X are letters and # is a digit
	bad pattern:  '^[Pp][PpGg]' matches when page begins pp, pP, Pp, PP, pg, pG, Pg, PG

]]

local function extra_text_in_page_check (val, name)
	if not val:match (cfg.vol_iss_pg_patterns.good_ppattern) then
		for _, pattern in ipairs (cfg.vol_iss_pg_patterns.bad_ppatterns) do		-- spin through the selected sequence table of patterns
			if val:match (pattern) then											-- when a match, error so
				utilities.set_message ('err_extra_text_pages', name);	 		-- add error message
				return;															-- and done
			end
		end
	end		
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ V O L _ I S S _ C H E C K &gt;------------------------

Adds error if |volume= or |issue= has what appears to be some form of redundant 'type' indicator.

For |volume=:
	'V.', or 'Vol.' (with or without the dot) abbreviations or 'Volume' in the first characters of the parameter
	content (all case insensitive). 'V' and 'v' (without the dot) are presumed to be roman numerals so
	are allowed.

For |issue=:
	'No.', 'I.', 'Iss.' (with or without the dot) abbreviations, or 'Issue' in the first characters of the
	parameter content (all case insensitive).
	
Single character values ('v', 'i', 'n') allowed when not followed by separator character ('.', ':', '=', or
whitespace character) – param values are trimmed of whitespace by MediaWiki before delivered to the module.
	
&lt;val&gt; is |volume= or |issue= parameter value
&lt;name&gt; is |volume= or |issue= parameter name for error message
&lt;selector&gt; is 'v' for |volume=, 'i' for |issue=

sets error message on failure; returns nothing

]]

local function extra_text_in_vol_iss_check (val, name, selector)
	if not utilities.is_set (val) then
		return;
	end
	
	local patterns = 'v' == selector and cfg.vol_iss_pg_patterns.vpatterns or cfg.vol_iss_pg_patterns.ipatterns;

	local handler = 'v' == selector and 'err_extra_text_volume' or 'err_extra_text_issue';
	val = val:lower();															-- force parameter value to lower case
	for _, pattern in ipairs (patterns) do										-- spin through the selected sequence table of patterns
		if val:match (pattern) then												-- when a match, error so
			utilities.set_message (handler, name);								-- add error message
			return;																-- and done
		end
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parentheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a placeholder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parentheses
			local name = name_table[i];
			i = i + 1;															-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parentheses
					break;														-- and done reassembling so
				end
				i = i + 1;														-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = utilities.is_wikilink (name_table[i]);		-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i + 1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled parentheses ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the Vancouver error when a required comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		first = '';																-- set to empty string for concatenation and because it may have been set for previous author/editor
		local accept_name;
		v_name, accept_name = utilities.has_accept_as_written (v_name);			-- remove accept-this-as-written markup when it wraps all of &lt;v_name&gt;

		if accept_name then
			last = v_name;
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error (cfg.err_msg_supl.punctuation, i);
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s+&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be initials or generational suffix

			if not mw.ustring.match (first, '^%u+$') then						-- mw.ustring here so that later we will catch non-Latin characters
				suffix = first;													-- not initials so assume that whatever we got is a generational suffix
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end
			last = table.concat(lastfirstTable, ' ')							-- returns a string that is the concatenation of all other names that are not initials and generational suffix
			if not utilities.is_set (last) then
				first = '';														-- unset
				last = v_name;													-- last empty because something wrong with first
				add_vanc_error (cfg.err_msg_supl.name, i);
			end
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error (cfg.err_msg_supl['missing comma'], i);			-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- matches a space between two initials
			end
		else
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
		
		if utilities.is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first, suffix, i);							-- check first and last before restoring the suffix which may have a non-Latin digit
			if utilities.is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '', nil, i);
			end
		end

		link = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i ) or v_link_table[i];
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate = corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest;
|editorn= (and aliases) highest and |veditors= lowest (support for |editors= withdrawn)

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
	local lastfirst = false;
	if utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice in case we have a |first1= without a |last1=; this ...
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or		-- ... also catches the case where |first= is used with |vauthors=
		utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst = true;
	end

	if (utilities.is_set (vxxxxors) and true == lastfirst) or					-- these are the three error conditions
		(utilities.is_set (vxxxxors) and utilities.is_set (xxxxors)) or
		(true == lastfirst and utilities.is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			utilities.set_message ('err_redundant_parameters', err_name .. '-name-list parameters');	-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if utilities.is_set (vxxxxors) then return 2 end;
	if utilities.is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, live, dead, etc.).  When the parameter value has not been assigned a value (missing
or empty in the source template) the function returns the value specified by ret_val.  If the parameter value is one
of the list of allowed values returns the translated value; else, emits an error message and returns the value
specified by ret_val.

TODO: explain &lt;invert&gt;

]]

local function is_valid_parameter_value (value, name, possible, ret_val, invert)
	if not utilities.is_set (value) then
		return ret_val;															-- an empty parameter is ok
	end

	if (not invert and utilities.in_array (value, possible)) then				-- normal; &lt;value&gt; is in &lt;possible&gt; table
		return cfg.keywords_xlate[value];										-- return translation of parameter keyword
	elseif invert and not utilities.in_array (value, possible) then				-- invert; &lt;value&gt; is not in &lt;possible&gt; table
		return value;															-- return &lt;value&gt; as it is
	else
		utilities.set_message ('err_invalid_param_val', {name, value});			-- not an allowed value so add error message
		return ret_val;
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list, -3, -1) == sepc .. '. ') then					-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list, -1, -1) == sepc) or (string.sub (name_list, -3, -1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terminate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not utilities.is_set (volume) and not utilities.is_set (issue) then
		return '';
	end

	-- same condition as in format_pages_sheets()
	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);

	local is_numeric_vol = volume and (volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$'));	-- is only uppercase roman numerals or only digits?
	local is_long_vol = volume and (4 &lt; mw.ustring.len(volume));				-- is |volume= value longer than 4 characters?
	
	if volume and (not is_numeric_vol and is_long_vol) then						-- when not all digits or Roman numerals, is |volume= longer than 4 characters?
		utilities.add_prop_cat ('long-vol');									-- yes, add properties cat
	end

	if is_journal then															-- journal-style formatting
		local vol = '';
		
		if utilities.is_set (volume) then
			if is_numeric_vol then												-- |volume= value all digits or all uppercase Roman numerals?
				vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, volume});	-- render in bold face
			elseif is_long_vol then												-- not all digits or Roman numerals; longer than 4 characters?
				vol = utilities.substitute (cfg.messages['j-vol'], {sepc, utilities.hyphen_to_dash (volume)});	-- not bold
			else																-- four or fewer characters
				vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, utilities.hyphen_to_dash (volume)});	-- bold
			end
		end
		if utilities.is_set (issue) then
			return vol .. utilities.substitute (cfg.messages['j-issue'], issue);
		end
		return vol;
	end
	
	if 'podcast' == cite_class and utilities.is_set (issue) then
		return wrap_msg ('issue', {sepc, issue}, lower);
	end

	-- all other types of citation
	if utilities.is_set (volume) and utilities.is_set (issue) then
		return wrap_msg ('vol-no', {sepc, utilities.hyphen_to_dash (volume), issue}, lower);
	elseif utilities.is_set (volume) then
		return wrap_msg ('vol', {sepc, utilities.hyphen_to_dash (volume)}, lower);
	else
		return wrap_msg ('issue', {sepc, issue}, lower);
	end
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if utilities.is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif utilities.is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if utilities.is_set (page) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return utilities.substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return utilities.substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif utilities.is_set (pages) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then							-- if pages is only digits, assume a single page number
			return '', utilities.substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', utilities.substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', utilities.substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to Wikisource, returns the label portion of the interwiki-link as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki-link to an external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, page_orig, pages, pages_orig, at)
	local ws_url, ws_label, coins_pages, L;										-- for Wikisource interwiki-links; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if utilities.is_set (page) then
		if utilities.is_set (pages) or utilities.is_set (at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page, page_orig);								-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws URL from |page= interwiki link; link portion L becomes tooltip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (pages) then
		if utilities.is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages, pages_orig);							-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws URL from |pages= interwiki link; link portion L becomes tooltip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws URL from |at= interwiki link; link portion L becomes tooltip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end

--[[--------------------------&lt; I S _ U N I Q U E _ A R C H I V E _ U R L &gt;------------------------------------

add error message when |archive-url= value is same as |url= or chapter-url= (or alias...) value

]]

local function is_unique_archive_url (archive, url, c_url, source, date)
	if utilities.is_set (archive) then
		if archive == url or archive == c_url then
			utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)});	-- add error message
			return '', '';														-- unset |archive-url= and |archive-date= because same as |url= or |chapter-url=
		end
	end

	return archive, date;
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org URLs to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot URL or to calendar pages.  When the archive URL is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the URL.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org URL does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command URL
	|archive-url= is an archive.org URL that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org URLs:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this function may return a modified
archive URL:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the URL unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.org URL
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine URL
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command URL, we don't want to allow saving of the target page 
		err_msg = cfg.err_msg_supl.save;
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = cfg.err_msg_supl.liveweb;
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');	-- split out some of the URL parts for evaluation
		if not path then														-- malformed in some way; pattern did not match
			err_msg = cfg.err_msg_supl.timestamp;
		elseif 14 ~= timestamp:len() then										-- path and flag optional, must have 14-digit timestamp here
			err_msg = cfg.err_msg_supl.timestamp;
			if '*' ~= flag then
				local replacement = timestamp:match ('^%d%d%d%d%d%d') or timestamp:match ('^%d%d%d%d');	-- get the first 6 (YYYYMM) or first 4 digits (YYYY)
				if replacement then												-- nil if there aren't at least 4 digits (year)
					replacement = replacement .. string.rep ('0', 14 - replacement:len());	-- year or yearmo (4 or 6 digits) zero-fill to make 14-digit timestamp
					url=url:gsub ('(//web%.archive%.org/[^%d]*)%d[^/]*', '%1' .. replacement .. '*', 1)	-- for preview, modify ts to 14 digits plus splat for calendar display
				end
			end
		elseif utilities.is_set (path) and 'web/' ~= path then					-- older archive URLs do not have the extra 'web/' path element
			err_msg = cfg.err_msg_supl.path;
		elseif utilities.is_set (flag) and not utilities.is_set (path) then		-- flag not allowed with the old form URL (without the 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		elseif utilities.is_set (flag) and not flag:match ('%a%a_') then		-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		else
			return url, date;													-- return ArchiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	utilities.set_message ('err_archive_url', {err_msg});						-- add error message and

	if is_preview_mode then
		return url, date;														-- preview mode so return ArchiveURL and ArchiveDate
	else
		return '', '';															-- return empty strings for ArchiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; P L A C E _ C H E C K &gt;--------------------------------------------------------

check |place=, |publication-place=, |location= to see if these params include digits.  This function added because
many editors misuse location to specify the in-source location (|page(s)= and |at= are supposed to do that)

returns the original parameter value without modification; added maint cat when parameter value contains digits

]]

local function place_check (param_val)
	if not utilities.is_set (param_val) then									-- parameter empty or omitted
		return param_val;														-- return that empty state
	end
	
	if mw.ustring.find (param_val, '%d') then									-- not empty, are there digits in the parameter value
		utilities.set_message ('maint_location');								-- yep, add maint cat
	end
	
	return param_val;															-- and done
end


--[[--------------------------&lt; I S _ A R C H I V E D _ C O P Y &gt;----------------------------------------------

compares |title= to 'Archived copy' (placeholder added by bots that can't find proper title); if matches, return true; nil else

]]

local function is_archived_copy (title)
	title = mw.ustring.lower(title);											-- switch title to lower case
	if title:find (cfg.special_case_translation.archived_copy.en) then			-- if title is 'Archived copy'
		return true;
	elseif cfg.special_case_translation.archived_copy['local'] then
		if mw.ustring.find (title, cfg.special_case_translation.archived_copy['local']) then	-- mw.ustring() because might not be Latin script
			return true;
		end
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args )
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper ( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListStyle = is_valid_parameter_value (A['NameListStyle'], A:ORIGIN('NameListStyle'), cfg.keywords_lists['name-list-style'], '');
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				utilities.set_message ('maint_authors');						-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if utilities.is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], nil, args, 'EditorList');	-- support for |editors= withdrawn
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		end
	end
							
	local Chapter = A['Chapter'];												-- done here so that we have access to |contribution= from |chapter= aliases
	local Chapter_origin = A:ORIGIN ('Chapter');
	local Contribution;															-- because contribution is required for contributor(s)
		if 'contribution' == Chapter_origin then
			Contribution = Chapter;												-- get the name of the contribution
		end
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	
	if utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not utilities.is_set (Contribution) then							-- |contributor= requires |contribution=
				utilities.set_message ('err_contributor_missing_required_param', 'contribution');	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				utilities.set_message ('err_contributor_missing_required_param', 'author');	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if utilities.select_one (args, cfg.aliases['ContributorList-Last'], 'err_redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			utilities.set_message ('err_contributor_ignored');					-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	local Title = A['Title'];
	local TitleLink = A['TitleLink'];

	local auto_select = ''; -- default is auto
	local accept_link;
	TitleLink, accept_link = utilities.has_accept_as_written (TitleLink, true);	-- test for accept-this-as-written markup
	if (not accept_link) and utilities.in_array (TitleLink, {'none', 'pmc', 'doi'}) then -- check for special keywords
		auto_select = TitleLink;												-- remember selection for later
		TitleLink = '';															-- treat as if |title-link= would have been empty
	end

	TitleLink = link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wiki-markup in |title-link= or wiki-markup in |title= when |title-link= is set

	local Section = '';															-- {{cite map}} only; preset to empty string for concatenation if not used
	if 'map' == config.CitationClass and 'section' == Chapter_origin then
		Section = A['Chapter'];													-- get |section= from |chapter= alias list; |chapter= and the other aliases not supported in {{cite map}}
		Chapter = '';															-- unset for now; will be reset later from |map= if present
	end

	local Periodical = A['Periodical'];
	local Periodical_origin = '';
	if utilities.is_set (Periodical) then
		Periodical_origin = A:ORIGIN('Periodical');								-- get the name of the periodical parameter
		local i;
		Periodical, i = utilities.strip_apostrophe_markup (Periodical);			-- strip apostrophe markup so that metadata isn't contaminated 
		if i then																-- non-zero when markup was stripped so emit an error message
			utilities.set_message ('err_apostrophe_markup', {Periodical_origin});
		end
	end

	if 'mailinglist' == config.CitationClass then								-- special case for {{cite mailing list}}
		if utilities.is_set (Periodical) and utilities.is_set (A ['MailingList']) then	-- both set emit an error TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', Periodical_origin) .. ' and ' .. utilities.wrap_style ('parameter', 'mailinglist')});
		end

		Periodical = A ['MailingList'];											-- error or no, set Periodical to |mailinglist= value because this template is {{cite mailing list}}
		Periodical_origin = A:ORIGIN('MailingList');
	end

	local ScriptPeriodical = A['ScriptPeriodical'];

	-- web and news not tested for now because of 
	-- Wikipedia:Administrators%27_noticeboard#Is_there_a_semi-automated_tool_that_could_fix_these_annoying_&quot;Cite_Web&quot;_errors?
	if not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) then	-- 'periodical' templates require periodical parameter
	--	local p = {['journal'] = 'journal', ['magazine'] = 'magazine', ['news'] = 'newspaper', ['web'] = 'website'};	-- for error message
		local p = {['journal'] = 'journal', ['magazine'] = 'magazine'};			-- for error message
		if p[config.CitationClass]  then
			utilities.set_message ('err_missing_periodical', {config.CitationClass, p[config.CitationClass]});
		end
	end
	
	local Volume;
	local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) then
			if not utilities.in_array (Periodical_origin, {'website', 'mailinglist'}) then	-- {{citation}} does not render volume for these 'periodicals' --TODO: move 'array' to ~/Configuration
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		elseif utilities.is_set (ScriptPeriodical) then
			if 'script-website' ~= ScriptPeriodical_origin then					-- {{citation}} does not render volume for |script-website=
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		else
			Volume = A['Volume'];												-- and does for non-'periodical' cites
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_volume) then	-- render |volume= for cs1 according to the configuration settings
		Volume = A['Volume'];
	end	
	extra_text_in_vol_iss_check (Volume, A:ORIGIN ('Volume'), 'v');	

	local Issue;
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) and utilities.in_array (Periodical_origin, {'journal', 'magazine', 'newspaper', 'periodical', 'work'}) or	-- {{citation}} renders issue for these 'periodicals'--TODO: move 'array' to ~/Configuration
			utilities.is_set (ScriptPeriodical) and utilities.in_array (ScriptPeriodical_origin, {'script-journal', 'script-magazine', 'script-newspaper', 'script-periodical', 'script-work'}) then -- and these 'script-periodicals'
				Issue = utilities.hyphen_to_dash (A['Issue']);
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_issue) then	-- conference &amp; map books do not support issue; {{citation}} listed here because included in settings table
		if not (utilities.in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical))) then
			Issue = utilities.hyphen_to_dash (A['Issue']);
		end
	end
	extra_text_in_vol_iss_check (Issue, A:ORIGIN ('Issue'), 'i');	

	local Page;
	local Pages;
	local At;
	if not utilities.in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = utilities.hyphen_to_dash (A['Pages']);	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = place_check (A['PublicationPlace'], A:ORIGIN('PublicationPlace'));
	local Place = place_check (A['Place'], A:ORIGIN('Place'));
	
	local PublisherName = A['PublisherName'];
	local PublisherName_origin = A:ORIGIN('PublisherName');
	if utilities.is_set (PublisherName) then
		local i = 0;
		PublisherName, i = utilities.strip_apostrophe_markup (PublisherName);	-- strip apostrophe markup so that metadata isn't contaminated; publisher is never italicized
		if i then																-- non-zero when markup was stripped so emit an error message
			utilities.set_message ('err_apostrophe_markup', {PublisherName_origin});
		end
	end

	local Newsgroup = A['Newsgroup'];											-- TODO: strip apostrophe markup?
	local Newsgroup_origin = A:ORIGIN('Newsgroup');	

	if 'newsgroup' == config.CitationClass then
		if utilities.is_set (PublisherName) then								-- general use parameter |publisher= not allowed in cite newsgroup
			utilities.set_message ('err_parameter_ignored', {PublisherName_origin});
		end

		PublisherName = nil;													-- ensure that this parameter is unset for the time being; will be used again after COinS
	end

	local URL = A['URL'];														-- TODO: better way to do this for URL, ChapterURL, and MapURL?
	local UrlAccess = is_valid_parameter_value (A['UrlAccess'], A:ORIGIN('UrlAccess'), cfg.keywords_lists['url-access'], nil);
	
	if not utilities.is_set (URL) and utilities.is_set (UrlAccess) then
		UrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', 'url');
	end
	
	local ChapterURL = A['ChapterURL'];
	local ChapterUrlAccess = is_valid_parameter_value (A['ChapterUrlAccess'], A:ORIGIN('ChapterUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (ChapterURL) and utilities.is_set (ChapterUrlAccess) then
		ChapterUrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', {A:ORIGIN('ChapterUrlAccess'):gsub ('%-access', '')});
	end

	local MapUrlAccess = is_valid_parameter_value (A['MapUrlAccess'], A:ORIGIN('MapUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (A['MapURL']) and utilities.is_set (MapUrlAccess) then
		MapUrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', {'map-url'});
	end

	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local no_tracking_cats = is_valid_parameter_value (A['NoTracking'], A:ORIGIN('NoTracking'), cfg.keywords_lists['yes_true_y'], nil);

	-- check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not utilities.is_set (no_tracking_cats) then								-- ignore if we are already not going to categorize this page
		if utilities.in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _, v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end
																				-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	utilities.select_one (args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'err_redundant_parameters');	-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, A:ORIGIN('Page'), Pages, A:ORIGIN('Pages'), At);

	local NoPP = is_valid_parameter_value (A['NoPP'], A:ORIGIN('NoPP'), cfg.keywords_lists['yes_true_y'], nil);

	if utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- both |publication-place= and |place= (|location=) allowed if different
		utilities.add_prop_cat ('location-test');								-- add property cat to evaluate how often PublicationPlace and Place are used together
		if PublicationPlace == Place then
			Place = '';															-- unset; don't need both if they are the same
		end
	elseif not utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- when only |place= (|location=) is set ...
		PublicationPlace = Place;												-- promote |place= (|location=) to |publication-place
	end

	if PublicationPlace == Place then Place = ''; end							-- don't need both if they are the same
	
	local URL_origin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL_origin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ScriptChapter = A['ScriptChapter'];
	local ScriptChapter_origin = A:ORIGIN ('ScriptChapter');
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local TransChapter = A['TransChapter'];
	local TransChapter_origin = A:ORIGIN ('TransChapter');
	local TransTitle = A['TransTitle'];
	local ScriptTitle = A['ScriptTitle'];
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia= and |title= then map |title= to |article= and |encyclopedia= to |title=
		|encyclopedia= and |article= then map |encyclopedia= to |title=

		|trans-title= maps to |trans-chapter= when |title= is re-mapped
		|url= maps to |chapter-url= when |title= is remapped
	
	All other combinations of |encyclopedia=, |title=, and |article= are not modified
	
	]]

	local Encyclopedia = A['Encyclopedia'];										-- used as a flag by this module and by ~/COinS

	if utilities.is_set (Encyclopedia) then										-- emit error message when Encyclopedia set but template is other than {{cite encyclopedia}} or {{citation}}
		if 'encyclopaedia' ~= config.CitationClass and 'citation' ~= config.CitationClass then
			utilities.set_message ('err_parameter_ignored', {A:ORIGIN ('Encyclopedia')});
			Encyclopedia = nil;													-- unset because not supported by this template
		end
	end

	if ('encyclopaedia' == config.CitationClass) or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Periodical) and utilities.is_set (Encyclopedia) then	-- when both set emit an error TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', A:ORIGIN ('Encyclopedia')) .. ' and ' .. utilities.wrap_style ('parameter', Periodical_origin)});
		end

		if utilities.is_set (Encyclopedia) then
			Periodical = Encyclopedia;											-- error or no, set Periodical to Encyclopedia; allow periodical without encyclopedia
			Periodical_origin = A:ORIGIN ('Encyclopedia');
		end

		if utilities.is_set (Periodical) then									-- Periodical is set when |encyclopedia= is set
			if utilities.is_set (Title) or utilities.is_set (ScriptTitle) then
				if not utilities.is_set (Chapter) then
					Chapter = Title;											-- |encyclopedia= and |title= are set so map |title= to |article= and |encyclopedia= to |title=
					ScriptChapter = ScriptTitle;
					ScriptChapter_origin = A:ORIGIN('ScriptTitle')
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterURL_origin = URL_origin;

					ChapterUrlAccess = UrlAccess;

					if not utilities.is_set (ChapterURL) and utilities.is_set (TitleLink) then
						Chapter = utilities.make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			elseif utilities.is_set (Chapter) or utilities.is_set (ScriptChapter) then								-- |title= not set
				Title = Periodical;												-- |encyclopedia= set and |article= set so map |encyclopedia= to |title=
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- special case for cite techreport.
	local ID = A['ID'];
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if utilities.is_set (A['Number']) then									-- cite techreport uses 'number', which other citations alias to 'issue'
			if not utilities.is_set (ID) then									-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'id') .. ' and ' .. utilities.wrap_style ('parameter', 'number')});
			end
		end	
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	local ChapterLink -- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local Conference = A['Conference'];
	local BookTitle = A['BookTitle'];
	local TransTitle_origin = A:ORIGIN ('TransTitle');
	if 'conference' == config.CitationClass then
		if utilities.is_set (BookTitle) then
			Chapter = Title;
			Chapter_origin = 'title';
	--		ChapterLink = TitleLink;											-- |chapter-link= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			URL_origin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			TransChapter_origin = TransTitle_origin;
			Title = BookTitle;
			Format = '';
	--		TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end
	
	-- CS1/2 mode
	local Mode = is_valid_parameter_value (A['Mode'], A:ORIGIN('Mode'), cfg.keywords_lists['mode'], '');
	-- separator character and postscript
	local sepc, PostScript = set_style (Mode:lower(), A['PostScript'], config.CitationClass);
	-- controls capitalization of certain static text
	local use_lowercase = ( sepc == ',' );
	
	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		if utilities.is_set (Chapter) then										--TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'map') .. ' and ' .. utilities.wrap_style ('parameter', Chapter_origin)});	-- add error message
		end
		Chapter = A['Map'];
		Chapter_origin = A:ORIGIN('Map');
		ChapterURL = A['MapURL'];
		ChapterURL_origin = A:ORIGIN('MapURL');
		TransChapter = A['TransMap'];
		ScriptChapter = A['ScriptMap']
		ScriptChapter_origin = A:ORIGIN('ScriptMap')

		ChapterUrlAccess = MapUrlAccess;
		ChapterFormat = A['MapFormat'];

		Cartography = A['Cartography'];
		if utilities.is_set ( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if utilities.is_set ( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	local Series = A['Series'];
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local SeriesLink = A['SeriesLink'];

		SeriesLink = link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wiki-markup in |series-link= or wiki-markup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if utilities.is_set (Network) then table.insert(n, Network); end
		if utilities.is_set (Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if utilities.is_set (Season) and utilities.is_set (SeriesNumber) then	-- these are mutually exclusive so if both are set TODO: make a function for this and similar?
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'season') .. ' and ' .. utilities.wrap_style ('parameter', 'seriesno')});		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if utilities.is_set (Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if utilities.is_set (SeriesNumber) then table.insert(s, wrap_msg ('seriesnum', SeriesNumber, use_lowercase)); end
			if utilities.is_set (Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ScriptChapter_origin = A:ORIGIN('ScriptTitle');
			ChapterLink = TitleLink;											-- alias |episode-link=
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			
			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if utilities.is_set (ChapterLink) and not utilities.is_set (ChapterURL) then	-- link but not URL
				Chapter = utilities.make_wikilink (ChapterLink, Chapter);
			elseif utilities.is_set (ChapterLink) and utilities.is_set (ChapterURL) then	-- if both are set, URL links episode;
				Series = utilities.make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if utilities.is_set (Series) and utilities.is_set (SeriesLink) then
				Series = utilities.make_wikilink (SeriesLink, Series);
			end
			Series = utilities.wrap_style ('italic-title', Series);				-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- handle type parameter for those CS1 citations that have default values
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	if utilities.in_array (config.CitationClass, {'AV-media-notes', 'interview', 'mailinglist', 'map', 'podcast', 'pressrelease', 'report', 'speech', 'techreport', 'thesis'}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if utilities.is_set (Degree) and &quot;Thesis&quot; == TitleType then				-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if utilities.is_set (TitleType) then										-- if type parameter is specified
		TitleType = utilities.substitute ( cfg.messages['type'], TitleType);	-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
	local Date = A['Date'];
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging
	local PublicationDate = A['PublicationDate'];
	local Year = A['Year'];

	if not utilities.is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not utilities.is_set (Date) and utilities.is_set (PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]

	local DF = is_valid_parameter_value (A['DF'], A:ORIGIN('DF'), cfg.keywords_lists['df'], '');
	if not utilities.is_set (DF) then
		DF = cfg.global_df;														-- local |df= if present overrides global df set by {{use xxx date}} template
	end

	local ArchiveURL;
	local ArchiveDate;
	local ArchiveFormat = A['ArchiveFormat'];

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	
	ArchiveURL, ArchiveDate = is_unique_archive_url (ArchiveURL, URL, ChapterURL, A:ORIGIN('ArchiveURL'), ArchiveDate);		-- add error message when URL or ChapterURL == ArchiveURL

	
	local AccessDate = A['AccessDate'];
	local LayDate = A['LayDate'];
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification
	local DoiBroken = A['DoiBroken'];
	local Embargo = A['Embargo'];
	local anchor_year;															-- used in the CITEREF identifier
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val = AccessDate, name = A:ORIGIN ('AccessDate')},
			['archive-date'] = {val = ArchiveDate, name = A:ORIGIN ('ArchiveDate')},
			['date'] = {val = Date, name = Date_origin},
			['doi-broken-date'] = {val = DoiBroken, name = A:ORIGIN ('DoiBroken')},
			['pmc-embargo-date'] = {val = Embargo, name = A:ORIGIN ('Embargo')},
			['lay-date'] = {val = LayDate, name = A:ORIGIN ('LayDate')},
			['publication-date'] = {val = PublicationDate, name = A:ORIGIN ('PublicationDate')},
			['year'] = {val = Year, name = A:ORIGIN ('Year')},
			};

		local error_list = {};
		anchor_year, Embargo = validation.dates(date_parameters_list, COinS_date, error_list);

-- start temporary Julian / Gregorian calendar uncertainty categorization
		if COinS_date.inter_cal_cat then
			utilities.add_prop_cat ('jul-greg-uncertainty');
		end
-- end temporary Julian / Gregorian calendar uncertainty categorization

		if utilities.is_set (Year) and utilities.is_set (Date) then				-- both |date= and |year= not normally needed; 
			validation.year_date_check (Year, A:ORIGIN ('Year'), Date, A:ORIGIN ('Date'), error_list);
		end
		
		if 0 == #error_list then												-- error free dates only; 0 when error_list is empty
			local modified = false;												-- flag
			
			if utilities.is_set (DF) then										-- if we need to reformat dates
				modified = validation.reformat_dates (date_parameters_list, DF);	-- reformat to DF format, use long month names if appropriate
			end

			if true == validation.date_hyphen_to_dash (date_parameters_list) then	-- convert hyphens to dashes where appropriate
				modified = true;
				utilities.set_message ('maint_date_format');					-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language; not supported at en.wiki
			if cfg.date_name_auto_xlate_enable and validation.date_name_xlate (date_parameters_list, cfg.date_digit_auto_xlate_enable ) then
				utilities.set_message ('maint_date_auto_xlated');				-- add maint cat
				modified = true;
			end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				LayDate = date_parameters_list['lay-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end
		else
			utilities.set_message ('err_bad_date', {utilities.make_sep_list (#error_list, error_list)});	-- add this error message
		end
	end	-- end of do

	local ID_list = {};															-- sequence table of rendered identifiers
	local ID_list_coins = {};													-- table of identifiers and their values from args; key is same as cfg.id_handlers's key
	local Class = A['Class'];													-- arxiv class identifier
	
	local ID_support = {
		{A['ASINTLD'], 'ASIN', 'err_asintld_missing_asin', A:ORIGIN ('ASINTLD')},				
		{DoiBroken, 'DOI', 'err_doibroken_missing_doi', A:ORIGIN ('DoiBroken')},
		{Embargo, 'PMC', 'err_embargo_missing_pmc', A:ORIGIN ('Embargo')},
		}

	ID_list, ID_list_coins = identifiers.identifier_lists_get (args, {DoiBroken = DoiBroken, ASINTLD = A['ASINTLD'], Embargo = Embargo, Class = Class}, ID_support);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite ssrn}}, before generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then
		if not utilities.is_set (ID_list_coins[config.CitationClass:upper()]) then 	-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp; |citeseerx= required for their templates
			utilities.set_message ('err_' .. config.CitationClass .. '_missing');	-- add error message
		end

		Periodical = ({['arxiv'] = 'arXiv', ['biorxiv'] = 'bioRxiv', ['citeseerx'] = 'CiteSeerX', ['ssrn'] = 'Social Science Research Network'})[config.CitationClass];
	end

	-- Link the title of the work if no |url= was provided, but we have a |pmc= or a |doi= with |doi-access=free

	if config.CitationClass == &quot;journal&quot; and not utilities.is_set (URL) and not utilities.is_set (TitleLink) and not utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) then -- TODO: remove 'none' once existing citations have been switched to 'off', so 'none' can be used as token for &quot;no title&quot; instead
		if 'none' ~= cfg.keywords_xlate[auto_select] then						-- if auto-linking not disabled
 	 		if identifiers.auto_link_urls[auto_select] then						-- manual selection
		 		URL = identifiers.auto_link_urls[auto_select];					-- set URL to be the same as identifier's external link
 				URL_origin = cfg.id_handlers[auto_select:upper()].parameters[1];	-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['pmc'] then						-- auto-select PMC
				URL = identifiers.auto_link_urls['pmc'];						-- set URL to be the same as the PMC external link if not embargoed
				URL_origin = cfg.id_handlers['PMC'].parameters[1];				-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['doi'] then						-- auto-select DOI
				URL = identifiers.auto_link_urls['doi'];
				URL_origin = cfg.id_handlers['DOI'].parameters[1];
			end
 	 	end

		if utilities.is_set (URL) and utilities.is_set (AccessDate) then		-- access date requires |url=; identifier-created URL is not |url=
			utilities.set_message ('err_accessdate_missing_url');				-- add an error message
			AccessDate = '';													-- unset
		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not utilities.is_set (Title) and not utilities.is_set (TransTitle) and not utilities.is_set (ScriptTitle) then	-- has special case for cite episode
		utilities.set_message ('err_citation_missing_title', {'episode' == config.CitationClass and 'series' or 'title'});
	end

	if utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) and
			utilities.in_array (config.CitationClass, {'journal', 'citation'}) and
			(utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and
			('journal' == Periodical_origin or 'script-journal' == ScriptPeriodical_origin) then	-- special case for journal cites
				Title = '';														-- set title to empty string
				utilities.set_message ('maint_untitled');						-- add maint cat
	end

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Chapter) and utilities.is_set (Title) and utilities.is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end
	
	local QuotePage = A['QuotePage'];
	local QuotePages = utilities.hyphen_to_dash (A['QuotePages']);

	-- this is the function call to COinS()
	local OCinSoutput = metadata.COinS({
		['Periodical'] = utilities.strip_apostrophe_markup (Periodical),		-- no markup in the metadata
		['Encyclopedia'] = Encyclopedia,										-- just a flag; content ignored by ~/COinS
		['Chapter'] = metadata.make_coins_title (coins_chapter, ScriptChapter),	-- Chapter and ScriptChapter stripped of bold / italic / accept-as-written markup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = metadata.make_coins_title (coins_title, ScriptTitle),		-- Title and ScriptTitle stripped of bold / italic / accept-as-written markup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Quarter'] = COinS_date.rftquarter,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = coins_pages or metadata.get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At, QuotePage, QuotePages}, 7)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName or Newsgroup,							-- any apostrophe markup already removed from PublisherName
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list_coins,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, and {{cite ssrn}} AFTER generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, CiteSeerX, or ssrn now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass and utilities.is_set (Newsgroup) then
		PublisherName = utilities.substitute (cfg.messages['newsgroup'], external_link( 'news:' .. Newsgroup, Newsgroup, Newsgroup_origin, nil ));
	end

	local Editors;
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	local Contributors;															-- assembled contributors name list
	local contributor_etal;
	local Translators;															-- assembled translators name list
	local translator_etal;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	local Interviewers;															
	local interviewers_list = {};					
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters
	local interviewer_etal;
	
	-- Now perform various field 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.
	do
		local last_first_list;
		local control = { 
			format = NameListStyle,												-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_names (A['DisplayEditors'], #e, 'editors', editor_etal, A:ORIGIN ('DisplayEditors'));
			Editors, EditorCount = list_people (control, e, editor_etal);

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum, interviewer_etal = get_display_names (A['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal, A:ORIGIN ('DisplayInterviewers'));
			Interviewers = list_people (control, interviewers_list, interviewer_etal);
		end
		do																		-- now do translators
			control.maximum, translator_etal = get_display_names (A['DisplayTranslators'], #t, 'translators', translator_etal, A:ORIGIN ('DisplayTranslators'));
			Translators = list_people (control, t, translator_etal);
		end
		do																		-- now do contributors
			control.maximum, contributor_etal = get_display_names (A['DisplayContributors'], #c, 'contributors', contributor_etal, A:ORIGIN ('DisplayContributors'));
			Contributors = list_people (control, c, contributor_etal);
		end
		do																		-- now do authors
			control.maximum, author_etal = get_display_names (A['DisplayAuthors'], #a, 'authors', author_etal, A:ORIGIN ('DisplayAuthors'));

			last_first_list = list_people (control, a, author_etal);

			if utilities.is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors');	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if utilities.is_set (Authors) and utilities.is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not utilities.is_set (URL) then
		if utilities.in_array (config.CitationClass, {&quot;web&quot;, &quot;podcast&quot;, &quot;mailinglist&quot;}) or		-- |url= required for cite web, cite podcast, and cite mailinglist
			('citation' == config.CitationClass and ('website' == Periodical_origin or 'script-website' == ScriptPeriodical_origin)) then	-- and required for {{citation}} with |website= or |script-website=
				utilities.set_message ('err_cite_web_url');
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if utilities.is_set (AccessDate) and not utilities.is_set (ChapterURL) then		-- ChapterURL may be set when URL is not set;
			utilities.set_message ('err_accessdate_missing_url');
			AccessDate = '';
		end
	end

	local UrlStatus = is_valid_parameter_value (A['UrlStatus'], A:ORIGIN('UrlStatus'), cfg.keywords_lists['url-status'], '');
	local OriginalURL
	local OriginalURL_origin
	local OriginalFormat
	local OriginalAccess;
	UrlStatus = UrlStatus:lower();												-- used later when assembling archived text
	if utilities.is_set ( ArchiveURL ) then
		if utilities.is_set (ChapterURL) then 									-- if chapter-url= is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURL_origin = ChapterURL_origin;								-- name of |chapter-url= parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=

			if 'live' ~= UrlStatus then
				ChapterURL = ArchiveURL											-- swap-in the archive's URL
				ChapterURL_origin = A:ORIGIN('ArchiveURL')						-- name of |archive-url= parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived URLs
			end
		elseif utilities.is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURL_origin = URL_origin;									-- name of URL parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;

			if 'live' ~= UrlStatus then											-- if URL set then |archive-url= applies to it
				URL = ArchiveURL												-- swap-in the archive's URL
				URL_origin = A:ORIGIN('ArchiveURL')								-- name of archive URL parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived URLs
			end
		end
	elseif utilities.is_set (UrlStatus) then									-- if |url-status= is set when |archive-url= is not set
 		utilities.set_message ('maint_url_status');								-- add maint cat
	end

	if utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) then
			local chap_param;
			if utilities.is_set (Chapter) then									-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif utilities.is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif utilities.is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif utilities.is_set (ScriptChapter) then
				chap_param = ScriptChapter_origin;
			else utilities.is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if utilities.is_set (chap_param) then								-- if we found one
				utilities.set_message ('err_chapter_ignored', {chap_param});	-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if utilities.is_set (Contribution) and 0 &lt; #c then						-- if this is a contribution with contributor(s)
			if utilities.in_array (Contribution:lower(), cfg.keywords_lists.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, ScriptChapter_origin, Chapter, Chapter_origin, TransChapter, TransChapter_origin, ChapterURL, ChapterURL_origin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if utilities.is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and utilities.is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter .. sepc .. ' ';
		elseif utilities.is_set (ChapterFormat) then							-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title
	local plain_title = false;
	local accept_title;
	Title, accept_title = utilities.has_accept_as_written (Title, true);		-- remove accept-this-as-written markup when it wraps all of &lt;Title&gt;
	if accept_title and ('' == Title) then										-- only support forced empty for now &quot;(())&quot;
		Title = cfg.messages['notitle'];										-- replace by predefined &quot;No title&quot; message
			-- TODO: utilities.set_message ( 'err_redundant_parameters', ...);	-- issue proper error message instead of muting	 
			ScriptTitle = '';													-- just mute for now	 
			TransTitle = '';													-- just mute for now
 		plain_title = true;														-- suppress text decoration for descriptive title
		utilities.set_message ('maint_untitled');								-- add maint cat
	end

	if not accept_title then													-- &lt;Title&gt; not wrapped in accept-as-written markup
		if '...' == Title:sub (-3) then											-- if ellipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%' .. sepc .. '$', '');			-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end

		if utilities.is_set (ArchiveURL) and is_archived_copy (Title) then
			utilities.set_message ('maint_archived_copy');						-- add maintenance category before we modify the content of Title
		end

		if is_generic ('generic_titles', Title) then
			utilities.set_message ('err_generic_title');						-- set an error message
		end
	end

	if (not plain_title) and (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) or
		('map' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)))) then		-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from module provided quote marks
			Title = utilities.wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle, 'script-title');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
			TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );
	elseif plain_title or ('report' == config.CitationClass) then				-- no styling for cite report and descriptive titles (otherwise same as above)
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );	-- for cite report, use this form for trans-title
	else
		Title = utilities.wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-italic-title', TransTitle);
	end

	if utilities.is_set (TransTitle) then
		if utilities.is_set (Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			utilities.set_message ('err_trans_missing_title', {'title'});
		end
	end

	if utilities.is_set (Title) then											-- TODO: is this the right place to be making Wikisource URLs?
		if utilities.is_set (TitleLink) and utilities.is_set (URL) then
			utilities.set_message ('err_wikilink_in_url');						-- set an error message because we can't have both
			TitleLink = '';														-- unset
		end
	
		if not utilities.is_set (TitleLink) and utilities.is_set (URL) then
			Title = external_link (URL, Title, URL_origin, UrlAccess) .. TransTitle .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif utilities.is_set (TitleLink) and not utilities.is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle;
			else
				Title = utilities.make_wikilink (TitleLink, Title) .. TransTitle;
			end
		else
			local ws_url, ws_label, L;											-- Title has italic or quote markup by the time we get here which causes is_wikilink() to return 0 (not a wikilink)
			ws_url, ws_label, L = wikisource_url_make (Title:gsub('^[\'&quot;]*(.-)[\'&quot;]*$', '%1'));	-- make ws URL from |title= interwiki link (strip italic or quote markup); link portion L becomes tooltip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle;
			else
				Title = Title .. TransTitle;
			end
		end
	else
		Title = TransTitle;
	end

	if utilities.is_set (Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	local ConferenceURL_origin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	if utilities.is_set (Conference) then
		if utilities.is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURL_origin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif utilities.is_set (ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURL_origin, nil );
	end

	local Position = '';
	if not utilities.is_set (Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if utilities.is_set (Minutes) then
			if utilities.is_set (Time) then		--TODO: make a function for this and similar?
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'minutes') .. ' and ' .. utilities.wrap_style ('parameter', 'time')});
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if utilities.is_set (Time) then
				local TimeCaption = A['TimeCaption']
				if not utilities.is_set (TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = utilities.is_set (At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = utilities.is_set (Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Sections = A['Sections'];											-- Section (singular) is an alias of Chapter so set earlier
		local Inset = A['Inset'];
		
		if utilities.is_set ( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if utilities.is_set ( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif utilities.is_set ( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	local Others = A['Others'];
	if utilities.is_set (Others) and 0 == #a and 0 == #e then					-- add maint cat when |others= has value and used without |author=, |editor=
		if config.CitationClass == &quot;AV-media-notes&quot;
		or config.CitationClass == &quot;audio-visual&quot; then							-- special maint for AV/M which has a lot of 'false' positives right now
			utilities.set_message ('maint_others_avm')
		else
			utilities.set_message ('maint_others');
		end
	end
	Others = utilities.is_set (Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if utilities.is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if utilities.is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	local TitleNote = A['TitleNote'];
	TitleNote = utilities.is_set (TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if utilities.is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%n?%.?$') or Edition:match ('%f[%a][Ee]dition$') then -- Ed, ed, Ed., ed., Edn, edn, Edn., edn.
			utilities.set_message ('err_extra_text_edition');					 -- add error message
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = utilities.is_set (Series) and wrap_msg ('series', {sepc, Series}) or &quot;&quot;;	-- not the same as SeriesNum
	local Agency = A['Agency'];
	Agency = utilities.is_set (Agency) and wrap_msg ('agency', {sepc, Agency}) or &quot;&quot;;
	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	if utilities.is_set (AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = utilities.substitute (retrv_text, AccessDate);				-- add retrieved text

		AccessDate = utilities.substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if utilities.is_set (ID) then ID = sepc .. &quot; &quot; .. ID; end
	
	local Docket = A['Docket'];
   	if &quot;thesis&quot; == config.CitationClass and utilities.is_set (Docket) then
		ID = sepc .. &quot; Docket &quot; .. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and utilities.is_set (Docket) then		-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	if utilities.is_set (URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URL_origin, UrlAccess );
	end

	local Quote = A['Quote'];
	local TransQuote = A['TransQuote'];
	local ScriptQuote = A['ScriptQuote'];
	if utilities.is_set (Quote) or utilities.is_set (TransQuote) or utilities.is_set (ScriptQuote) then

		if utilities.is_set (Quote) then
			if Quote:sub(1, 1) == '&quot;' and Quote:sub(-1, -1) == '&quot;' then			-- if first and last characters of quote are quote marks
				Quote = Quote:sub(2, -2);										-- strip them off
			end
		end

		Quote = utilities.wrap_style ('quoted-text', Quote );					-- wrap in &lt;q&gt;...&lt;/q&gt; tags
	
		if utilities.is_set (ScriptQuote) then
			Quote = script_concatenate (Quote, ScriptQuote, 'script-quote');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after quote is wrapped
		end

		if utilities.is_set (TransQuote) then
			if TransQuote:sub(1, 1) == '&quot;' and TransQuote:sub(-1, -1) == '&quot;' then -- if first and last characters of |trans-quote are quote marks
				TransQuote = TransQuote:sub(2, -2); -- strip them off
			end
			Quote = Quote .. &quot; &quot; .. utilities.wrap_style ('trans-quoted-title', TransQuote );
		end

		if utilities.is_set (QuotePage) or utilities.is_set (QuotePages) then	-- add page prefix
			local quote_prefix = '';
			if utilities.is_set (QuotePage) then
				extra_text_in_page_check (QuotePage, 'quote-page');				-- add to maint cat if |quote-page= value begins with what looks like p., pp., etc.
				if not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePage}), '', '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePage}), '', '', '';
				end
			elseif utilities.is_set (QuotePages) then
				extra_text_in_page_check (QuotePages, 'quote-pages');			-- add to maint cat if |quote-pages= value begins with what looks like p., pp., etc.
				if tonumber(QuotePages) ~= nil and not NoPP then				-- if only digits, assume single page
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePages}), '', '';
				elseif not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['pp-prefix'], {sepc, QuotePages}), '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePages}), '', '';
				end
			end
                        
			Quote = quote_prefix .. &quot;: &quot; .. Quote;
		else
			Quote = sepc .. &quot; &quot; .. Quote;
		end

		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	-- We check length of PostScript here because it will have been nuked by
	-- the quote parameters. We'd otherwise emit a message even if there wasn't
	-- a displayed postscript.
	-- TODO: Should the max size (1) be configurable?
	-- TODO: Should we check a specific pattern?
	if utilities.is_set(PostScript) and mw.ustring.len(PostScript) &gt; 1 then
		utilities.set_message ('maint_postscript')
	end
	
	local Archived;
	if utilities.is_set (ArchiveURL) then
		local arch_text;
		if not utilities.is_set (ArchiveDate) then
			utilities.set_message ('err_archive_missing_date');
			ArchiveDate = '';													-- empty string for concatenation
		end
		if &quot;live&quot; == UrlStatus then
			arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if utilities.is_set (ArchiveDate) then
				Archived = sepc .. ' ' .. utilities.substitute ( cfg.messages['archived-live'],
					{external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil) .. ArchiveFormat, ArchiveDate } );
			else
				Archived = '';
			end
			if not utilities.is_set (OriginalURL) then
				utilities.set_message ('err_archive_missing_url');
				Archived = '';													-- empty string for concatenation
			end
		elseif utilities.is_set (OriginalURL) then								-- UrlStatus is empty, 'dead', 'unfit', 'usurped', 'bot: unknown'
			if utilities.in_array (UrlStatus, {'unfit', 'usurped', 'bot: unknown'}) then
				arch_text = cfg.messages['archived-unfit'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. ' ' .. arch_text .. ArchiveDate;				-- format already styled
				if 'bot: unknown' == UrlStatus then
					utilities.set_message ('maint_bot_unknown');				-- and add a category if not already added
				else
					utilities.set_message ('maint_unfit');						-- and add a category if not already added
				end
			else																-- UrlStatus is empty, 'dead'
				arch_text = cfg.messages['archived-dead'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				if utilities.is_set (ArchiveDate) then
					Archived = sepc .. &quot; &quot; .. utilities.substitute ( arch_text,
						{ external_link( OriginalURL, cfg.messages['original'], OriginalURL_origin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
				else
					Archived = '';												-- unset for concatenation
				end
			end	
		else																	-- OriginalUrl not set
			arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			utilities.set_message ('err_archive_missing_url');
			Archived = '';														-- empty string for concatenation
		end
	elseif utilities.is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = '';
	end
	
	local Lay = '';
	local LaySource = A['LaySource'];
	local LayURL = A['LayURL'];
	local LayFormat = A['LayFormat'];
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	if utilities.is_set (LayURL) then
		if utilities.is_set (LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if utilities.is_set (LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. utilities.safe_for_italics (LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif utilities.is_set (LayFormat) then									-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	local TranscriptURL = A['TranscriptURL']
	local TranscriptFormat = A['TranscriptFormat'];
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');
	local Transcript = A['Transcript'];
	local TranscriptURL_origin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL
	if utilities.is_set (Transcript) then
		if utilities.is_set (TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURL_origin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif utilities.is_set (TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURL_origin, nil );
	end

	local Publisher;
	if utilities.is_set (PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if utilities.is_set (PublisherName) then
		if utilities.is_set (PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif utilities.is_set (PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	local TransPeriodical =  A['TransPeriodical'];
	local TransPeriodical_origin =  A:ORIGIN ('TransPeriodical');
	-- Several of the above rely upon detecting this as nil, so do it last.
	if (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical)) then
		if utilities.is_set (Title) or utilities.is_set (TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		else 
			Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		end
	end
	
	local Language = A['Language'];
	if utilities.is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc.
	else
		Language='';															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then									-- cite speech only
		TitleNote = TitleType;													-- move TitleType to TitleNote so that it renders ahead of |event=
		TitleType = '';															-- and unset

		if utilities.is_set (Periodical) then									-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if utilities.is_set (Conference) then								-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;							-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
		if utilities.is_set (Others) then Others = safe_join ({Others, sepc .. &quot; &quot;}, sepc) end		-- add terminal punctuation &amp; space; check for dup sepc; TODO why do we need to do this here?
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (Periodical) then		-- special cases for book cites
		if utilities.is_set (Contributors) then									-- when we are citing foreword, preface, introduction, etc.
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if utilities.is_set (Chapter) then										-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif utilities.is_set (Periodical) then								-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local Via = A['Via'];
	Via = utilities.is_set (Via) and  wrap_msg ('via', Via) or '';
	local idcommon;
	if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then	-- special case for cite AV media &amp; cite episode position transcript
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, Lay, Quote }, sepc );
	else
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, Lay, Quote }, sepc );
	end
	
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	local OrigDate = A['OrigDate'];
	OrigDate = utilities.is_set (OrigDate) and wrap_msg ('origdate', OrigDate) or '';
	if utilities.is_set (Date) then
		if utilities.is_set (Authors) or utilities.is_set (Editors) then		-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date .. &quot;)&quot; .. OrigDate .. sepc .. &quot; &quot;;				-- in parentheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon, -1, -1) == sepc) then						-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigDate;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigDate;							-- Date begins with sepc
			end
		end
	end	
	if utilities.is_set (Authors) then
		if (not utilities.is_set (Date)) then									-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if utilities.is_set (Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then
					in_text = in_text:lower()									-- lowercase for cs2
				end
			end
			if EditorCount &lt;= 1 then
				post_text = &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot;;				-- be consistent with no-author, no-date case
			else
				post_text = &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot;;
			end
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Contributors) then									-- book cite and we're citing the intro, preface, etc.
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if utilities.is_set (Editors) and utilities.is_set (Date) then		-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not utilities.is_set (Date)) then								-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif utilities.is_set (Editors) then
		if utilities.is_set (Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if utilities.is_set (PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc ); 								-- Deals with italics, spaces, etc.
		text = text:sub(1, -sepc:len() - 1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite&gt; element
	local options_t = {};
	options_t.class = cite_class_attribute_make (config.CitationClass, Mode);

	local Ref = is_valid_parameter_value (A['Ref'], A:ORIGIN('Ref'), cfg.keywords_lists['ref'], nil, true);	-- nil when |ref=harv; A['Ref'] else

	if 'none' ~= cfg.keywords_xlate[(Ref and Ref:lower()) or ''] then
		local namelist_t = {};													-- holds selected contributor, author, editor name list
		local year = first_set ({Year, anchor_year}, 2);						-- Year first for legacy citations and for YMD dates that require disambiguation

		if #c &gt; 0 then															-- if there is a contributor list
			namelist_t = c;														-- select it
		elseif #a &gt; 0 then														-- or an author list
			namelist_t = a;
		elseif #e &gt; 0 then														-- or an editor list
			namelist_t = e;
		end
		local citeref_id;
		if #namelist_t &gt; 0 then													-- if there are names in namelist_t
			citeref_id = make_citeref_id (namelist_t, year);					-- go make the CITEREF anchor
			if mw.uri.anchorEncode (citeref_id) == ((Ref and mw.uri.anchorEncode (Ref)) or '') then	-- Ref may already be encoded (by {{sfnref}}) so citeref_id must be encoded before comparison
				utilities.set_message ('maint_ref_duplicates_default');
			end
		else
			citeref_id = '';													-- unset
		end
		options_t.id = Ref or citeref_id;
	end

	if string.len (text:gsub('%b&lt;&gt;', '')) &lt;= 2 then								-- remove html and html-like tags; then get length of what remains; 
		z.error_cats_t = {};													-- blank the categories list
		z.error_msgs_t = {};													-- blank the error messages list
		OCinSoutput = nil;														-- blank the metadata string
		text = '';																-- blank the the citation
		utilities.set_message ('err_empty_citation');							-- set empty citation message and category
	end
	
	local render_t = {};														-- here we collect the final bits for concatenation into the rendered citation

	if utilities.is_set (options_t.id) then										-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render_t, utilities.substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options_t.id), mw.text.nowiki(options_t.class), text}));	-- when |ref= is set or when there is a namelist
	else
		table.insert (render_t, utilities.substitute (cfg.presentation['cite'], {mw.text.nowiki(options_t.class), text}));	-- when |ref=none or when namelist_t empty and |ref= is missing or is empty
	end		

	if OCinSoutput then															-- blanked when citation is 'empty' so don't bother to add boilerplate metadata span
		table.insert (render_t, utilities.substitute (cfg.presentation['ocins'], OCinSoutput));	-- format and append metadata to the citation
	end

	local template_name = ('citation' == config.CitationClass) and 'citation' or 'cite ' .. (cfg.citation_class_map_t[config.CitationClass] or config.CitationClass);
	local template_link = '[[Template:' .. template_name .. '|' .. template_name .. ']]';	-- TODO: if kept, these require some sort of i18n
	local msg_prefix = '&lt;code class=&quot;cs1-code&quot;&gt;{{' .. template_link .. '}}&lt;/code&gt;: ';

	if 0 ~= #z.error_msgs_t then
		mw.addWarning (utilities.substitute (cfg.messages.warning_msg_e, template_link));

		table.insert (render_t, ' ');											-- insert a space between citation and its error messages
		table.sort (z.error_msgs_t);											-- sort the error messages list; sorting includes wrapping &lt;span&gt; and &lt;code&gt; tags; hidden-error sorts ahead of visible-error

		local hidden = true;													-- presume that the only error messages emited by this template are hidden
		for _, v in ipairs (z.error_msgs_t) do									-- spin through the list of error messages
			if v:find ('cs1-visible-error', 1, true) then						-- look for the visible error class name
				hidden = false;													-- found one; so don't hide the error message prefix
				break;															-- and done because no need to look further
			end
		end

		z.error_msgs_t[1] = table.concat ({utilities.error_comment (msg_prefix, hidden), z.error_msgs_t[1]});	-- add error message prefix to first error message to prevent extraneous punctuation
		table.insert (render_t, table.concat (z.error_msgs_t, '; '));			-- make a big string of error messages and add it to the rendering
	end

	if 0 ~= #z.maint_cats_t then
		mw.addWarning (utilities.substitute (cfg.messages.warning_msg_m, template_link));

		table.sort (z.maint_cats_t);											-- sort the maintenance messages list

		local maint_msgs_t = {};												-- here we collect all of the maint messages

		if 0 == #z.error_msgs_t then											-- if no error messages
			table.insert (maint_msgs_t, msg_prefix);							-- insert message prefix in maint message livery
		end
		
		for _, v in ipairs( z.maint_cats_t ) do									-- append maintenance categories
			table.insert (maint_msgs_t, 										-- assemble new maint message and add it to the maint_msgs_t table
				table.concat ({v, ' (', utilities.substitute (cfg.messages[':cat wikilink'], v), ')'})
				);
		end
		table.insert (render_t, utilities.substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs_t, ' ')));	-- wrap the group of maint messages with proper presentation and save
	end

	if not no_tracking_cats then
		for _, v in ipairs (z.error_cats_t) do									-- append error categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
		end
		for _, v in ipairs (z.maint_cats_t) do									-- append maintenance categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
		end
		for _, v in ipairs (z.prop_cats_t) do									-- append properties categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
		end
	end

	return table.concat (render_t);												-- make a big string and done
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class, empty)
	local name = tostring (name);
	local enum_name;															-- for enumerated parameters, is name with enumerator replaced with '#'
	local state;
	local function state_test (state, name)										-- local function to do testing of state values
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			if empty then return nil; end										-- empty deprecated parameters are treated as unknowns
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
		if 'tracked' == state then
			local base_name = name:gsub ('%d', '');								-- strip enumerators from parameter names that have them to get the base name
			utilities.add_prop_cat ('tracked-param', {base_name}, base_name);	-- add a properties category; &lt;base_name&gt; modifies &lt;key&gt;
			return true;
		end
		return nil;
	end		

	if name:find ('#') then														-- # is a cs1|2 reserved character so parameters with # not permitted
		return nil;
	end

	if utilities.in_array (cite_class, whitelist.preprint_template_list ) then	-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[name];
		if true == state_test (state, name) then return true; end

		state = whitelist.preprint_arguments[cite_class][name];					-- look in the parameter-list for the template identified by cite_class
		if true == state_test (state, name) then return true; end

																				-- limited enumerated parameters list
		enum_name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );										-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
		state = whitelist.limited_numbered_arguments[enum_name];
		if true == state_test (state, name) then return true; end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates

	if utilities.in_array (cite_class, whitelist.unique_param_template_list) then 	-- experiment for template-specific parameters for templates that accept parameters from the basic argument list
		state = whitelist.unique_arguments[cite_class][name];					-- look in the template-specific parameter-lists for the template identified by cite_class
		if true == state_test (state, name) then return true; end
	end																			-- if here, fall into general validation
		
	state = whitelist.basic_arguments[name];									-- all other templates; all normal parameters allowed
	if true == state_test (state, name) then return true; end

																				-- all enumerated parameters allowed
	enum_name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
	state = whitelist.numbered_arguments[enum_name];
	if true == state_test (state, name) then return true; end

	return false;																-- not supported because not found or name is set to nil
end


--[=[-------------------------&lt; I N T E R _ W I K I _ C H E C K &gt;----------------------------------------------

check &lt;value&gt; for inter-language interwiki-link markup.  &lt;prefix&gt; must be a MediaWiki-recognized language
code.  when these values have the form (without leading colon):
	[[&lt;prefix&gt;:link|label]] return label as plain-text
	[[&lt;prefix&gt;:link]] return &lt;prefix&gt;:link as plain-text

return value as is else

]=]

local function inter_wiki_check (parameter, value)
	local prefix = value:match ('%[%[(%a+):');									-- get an interwiki prefix if one exists
	local _;
	
	if prefix and cfg.inter_wiki_map[prefix:lower()] then						-- if prefix is in the map, needs preceding colon so
		utilities.set_message ('err_bad_paramlink', parameter);					-- emit an error message
		_, value, _ = utilities.is_wikilink (value);							-- extract label portion from wikilink
	end
	return value;
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe.  There are two tests made:
	{{cite ... |title=Title access-date=2016-03-17}}	-- the first parameter has a value and whitespace separates that value from the missing pipe parameter name
	{{cite ... |title=access-date=2016-03-17}}			-- the first parameter has no value (whitespace after the first = is trimmed by MediaWiki)
cs1|2 shares some parameter names with XML/HTML attributes: class=, title=, etc.  To prevent false positives XML/HTML
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (parameter, value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove XML/HTML tags because attributes: class=, title=, etc.

	capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then										-- if the capture is a valid parameter name
		utilities.set_message ('err_missing_pipe', parameter);
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ P U N C T &gt;--------------------------------------

look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_punc (param, value)
	if 'number' == type (param) then
		return;
	end
	
	param = param:gsub ('%d+', '#');											-- enumerated name-list mask params allow terminal punct; normalize 
	if cfg.punct_skip[param] then
		return;																	-- parameter name found in the skip table so done
	end
	
	if value:match ('[,;:]$') then
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
	if value:match ('^=') then													-- sometimes an extraneous '=' character appears ...
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ U R L &gt;------------------------------------------

look for extraneous url parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_url (url_param_t)
	local url_error_t = {};
	
	check_for_url (url_param_t, url_error_t);									-- extraneous url check
	if 0 ~= #url_error_t then													-- non-zero when there are errors
		table.sort (url_error_t);
		utilities.set_message ('err_param_has_ext_link', {utilities.make_sep_list (#url_error_t, url_error_t)});	-- add this error message
	end
end


--[[--------------------------&lt; C I T A T I O N &gt;--------------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

local function citation(frame)
	Frame = frame;																-- save a copy in case we need to display an error message in preview mode
	is_sandbox = nil ~= string.find (frame:getTitle(), 'sandbox', 1, true);
	local pframe = frame:getParent()
	local styles;
	
	if is_sandbox then															-- did the {{#invoke:}} use sandbox version?
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');		-- load sandbox versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist/sandbox');
		utilities = require ('Module:Citation/CS1/Utilities/sandbox');
		validation = require ('Module:Citation/CS1/Date_validation/sandbox');
		identifiers = require ('Module:Citation/CS1/Identifiers/sandbox');
		metadata = require ('Module:Citation/CS1/COinS/sandbox');
		styles = 'Module:Citation/CS1/sandbox/styles.css';
		
	else																		-- otherwise
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');				-- load live versions of support modules
		whitelist = mw.loadData ('Module:Citation/CS1/Whitelist');
		utilities = require ('Module:Citation/CS1/Utilities');
		validation = require ('Module:Citation/CS1/Date_validation');
		identifiers = require ('Module:Citation/CS1/Identifiers');
		metadata = require ('Module:Citation/CS1/COinS');
		styles = 'Module:Citation/CS1/styles.css';
	end

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the selected cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	is_preview_mode = not utilities.is_set (frame:preprocess ('{{REVISIONID}}'));

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text;															-- used as a flag

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do											-- get parameters from the {{#invoke}} frame
		config[k] = v;
	--	args[k] = v;															-- crude debug support that allows us to render a citation from module {{#invoke:}}; skips parameter validation; TODO: keep?
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	local empty_unknowns = {};													-- sequence table to hold empty unknown params for error message listing
	for k, v in pairs( pframe.args ) do											-- get parameters from the parent (template) frame
		v = mw.ustring.gsub (v, '^%s*(.-)%s*$', '%1');							-- trim leading/trailing whitespace; when v is only whitespace, becomes empty string
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				if type (k) ~= 'string' then									-- exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text = utilities.set_message ('err_text_ignored', {v});
					end
				elseif validate (k:lower(), config.CitationClass) then 
					error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, k:lower()});	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if is_sandbox then										-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no capture in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = utilities.substitute (param, capture);		-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, param});	-- set the suggestion error message
							else
								error_text = utilities.set_message ('err_parameter_ignored', {k});	-- suggested param not supported by this template
								v = '';											-- unset
							end
						end
					end
					if not utilities.is_set (error_text) then					-- couldn't match with a pattern, is there an explicit suggestion?						
						if (suggestions.suggestions[ k:lower() ] ~= nil) and validate (suggestions.suggestions[ k:lower() ], config.CitationClass) then
							utilities.set_message ('err_parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]});
						else
							utilities.set_message ('err_parameter_ignored', {k});
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
			end

			args[k] = v;														-- save this parameter and its value

		elseif not utilities.is_set (v) then									-- for empty parameters
			if not validate (k, config.CitationClass, true) then				-- is this empty parameter a valid parameter
				k = ('' == k) and '(empty string)' or k;						-- when k is empty string (or was space(s) trimmed to empty string), replace with descriptive text
				table.insert (empty_unknowns, utilities.wrap_style ('parameter', k));	-- format for error message and add to the list
			end
																				-- crude debug support that allows us to render a citation from module {{#invoke:}} TODO: keep?
	--	elseif args[k] ~= nil or (k == 'postscript') then						-- when args[k] has a value from {{#invoke}} frame (we don't normally do that)
	--		args[k] = v;														-- overwrite args[k] with empty string from pframe.args[k] (template frame); v is empty string here
		end																		-- not sure about the postscript bit; that gets handled in parameter validation; historical artifact?
	end	

	if 0 ~= #empty_unknowns then												-- create empty unknown error message
		utilities.set_message ('err_param_unknown_empty', {
			1 == #empty_unknowns and '' or 's',
			utilities.make_sep_list (#empty_unknowns, empty_unknowns)
			});
	end

	local url_param_t = {};

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);											-- look for invisible characters
		end
		has_extraneous_punc (k, v);												-- look for extraneous terminal punctuation in parameter values
		missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?
		args[k] = inter_wiki_check (k, v);										-- when language interwiki-linked parameter missing leading colon replace with wiki-link label

		if 'string' == type (k) and not cfg.url_skip[k] then					-- when parameter k is not positional and not in url skip table
			url_param_t[k] = v;													-- make a parameter/value list for extraneous url check
		end
	end

	has_extraneous_url (url_param_t);											-- look for url in parameter values where a url does not belong

	return table.concat ({
		frame:extensionTag ('templatestyles', '', {src=styles}),
		citation0( config, args)
	});
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {citation = citation};</text>
      <sha1>og2ozrff88n7bwcpf68543a6wbtutg6</sha1>
    </revision>
    <revision>
      <id>4748</id>
      <parentid>4747</parentid>
      <timestamp>2022-07-01T17:45:25Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4748</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="206384" sha1="ap25rq0kh3819w7lon63qbjh3bjokuz" xml:space="preserve">require ('Module:No globals');

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------

each of these counts against the Lua upvalue limit

]]

local validation;																-- functions in Module:Citation/CS1/Date_validation

local utilities;																-- functions in Module:Citation/CS1/Utilities
local z ={};																	-- table of tables in Module:Citation/CS1/Utilities

local identifiers;																-- functions and tables in Module:Citation/CS1/Identifiers
local metadata;																	-- functions in Module:Citation/CS1/COinS
local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;---------------

declare variables here that have page-wide scope that are not brought in from
other modules; that are created here and used here

]]

local added_deprecated_cat;														-- Boolean flag so that the category is added only once
local added_vanc_errs;															-- Boolean flag so we only emit one Vancouver error / category
local added_generic_name_errs;													-- Boolean flag so we only emit one generic name error / category and stop testing names once an error is encountered
local Frame;																	-- holds the module's frame table
local is_preview_mode;															-- true when article is in preview mode; false when using 'Preview page with this template' (previewing the module)
local is_sandbox;																-- true when using sandbox modules to render citation


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if utilities.is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a Boolean declared in page scope variables above

]]

local function add_vanc_error (source, position)
	if added_vanc_errs then return end
		
	added_vanc_errs = true;														-- note that we've added this category
	utilities.set_message ('err_vancouver', {source, position});
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a URI scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of TLDs: https://www.iana.org/domains/root/db

RFC 952 (modified by RFC 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the TLD.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a URL with a scheme) will be stripped
here.  Perhaps not necessary but retained in case it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ASCII characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the TLD) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and TLD or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%w]') then											-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at Wikisource
		return false;
	end

	local patterns = {															-- patterns that look like URLs
		'%f[%w][%w][%w%-]+[%w]%.%a%a+$',										-- three or more character hostname.hostname or hostname.tld
		'%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$',									-- internationalized domain name with ACE prefix
		'%f[%a][qxz]%.com$',													-- assigned one character .com hostname (x.com times out 2015-12-10)
		'%f[%a][iq]%.net$',														-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		'%f[%w][%w]%.%a%a$',													-- one character hostname and ccTLD (2 chars)
		'%f[%w][%w][%w]%.%a%a+$',												-- two character hostname and TLD
		'^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?',								-- IPv4 address
		}

	for _, pattern in ipairs (patterns) do										-- loop through the patterns list
		if domain:match (pattern) then
			return true;														-- if a match then we think that this thing that purports to be a URL is a URL
		end
	end

	for _, d in ipairs ({'cash', 'company', 'today', 'org'}) do					-- look for single letter second level domain names for these top level domains
		if domain:match ('%f[%w][%w]%.' .. d) then
			return true
		end
	end
	return false;																-- no matches, we don't know what this thing is
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a URL appear to be a valid URL; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if utilities.is_set (scheme) then											-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when URL is protocol-relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a URL into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following TLD) (if any) and any path(/), query(?) or fragment(#).

If protocol-relative URL, return nil scheme and domain else return nil for both scheme and domain.

When not protocol-relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Any URL that does not have news: scheme must have authority indicator (//).  TODO: are there other common schemes
like news: that don't use authority indicator?

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol-relative URL
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		if utilities.is_set (authority) then
			authority = authority:gsub ('//', '', 1);							-- replace place 1 pair of '/' with nothing;
			if utilities.is_set(authority) then									-- if anything left (1 or 3+ '/' where authority should be) then
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		else
			if not scheme:match ('^news:') then									-- except for news:..., MediaWiki won't link URLs that do not have authority indicator; TODO: a better way to do this test?
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link=, etc. for properly formatted content: no wikilinks, no URLs

Link parameters are to hold the title of a Wikipedia article, so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki URLs and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid URL (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid URL (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from URL; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid URL
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wiki-linked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

check &lt;link&gt; for inter-language interwiki-link prefix.  prefix must be a MediaWiki-recognized language
code and must begin with a colon.

]]

local function link_title_ok (link, lorig, title, torig)
local orig;
	if utilities.is_set (link) then 											-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		elseif link:match ('^%a+:') then										-- if the link is what looks like an interwiki
			local prefix = link:match ('^(%a+):'):lower();						-- get the interwiki prefix

			if cfg.inter_wiki_map[prefix] then									-- if prefix is in the map, must have preceding colon
				orig = lorig;													-- flag as error
			end
		end
	end

	if utilities.is_set (orig) then
		link = '';																-- unset
		utilities.set_message ('err_bad_paramlink', orig);						-- URL or wikilink in |title= with |title-link=;
	end
	
	return link;																-- link if ok, empty string else
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the URL into scheme and domain
portions, or for protocol-relative (//example.com) URLs, just the domain.  Use is_url() to validate the two
portions of the URL.  If both are valid, or for protocol-relative if domain is valid, return true, else false.

Because it is different from a standard URL, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper URL
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from URL;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a URL.  The test will also find external wikilinks
that use protocol-relative URLs. Also finds bare URLs.

The frontier pattern prevents a match on interwiki-links which are similar to scheme:path URLs.  The tests that
find bracketed URLs are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext. wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol-relative ext. wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare URL with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol-relative bare URL: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a URL
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list, error_list)
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a URL add an error message
			table.insert (error_list, utilities.wrap_style ('parameter', k));
		end
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		utilities.set_message ('err_wikilink_in_url', {});
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link (URL, label, source, access)
	local err_msg = '';
	local domain;
	local path;
	local base_url;

	if not utilities.is_set (label) then
		label = URL;
		if utilities.is_set (source) then
			utilities.set_message ('err_bare_url_missing_title', {utilities.wrap_style ('parameter', source)});
		else
			error (cfg.messages[&quot;bare_url_no_origin&quot;]);
		end			
	end
	if not check_url (URL) then
		utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)});
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the URL into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['['] = '%5b', [']'] = '%5d'});			-- replace '[' and ']' with their percent-encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat ({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wiki-markup URL

	if utilities.is_set (access) then											-- access level (subscription, registration, limited)
		base_url = utilities.substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end

	return base_url;
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a Boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		utilities.set_message ('err_deprecated_params', {name});				-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wiki-markup) are not kerned.

Replaces Unicode quote marks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc.; not for book titles.

]=]

local function kern_quotes (str)
	local cap = '';
	local wl_type, label, link;

	wl_type, label, link = utilities.is_wikilink (str);							-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-left'], str);
			str = utilities.substitute (cfg.presentation['kern-right'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = utilities.substitute (cfg.presentation['kern-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label = mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label = mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap = mw.ustring.match (label, &quot;^([\&quot;\'][^\'].+)&quot;);						-- match leading double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-left'], cap);
		end
	
		cap = mw.ustring.match (label, &quot;^(.+[^\'][\&quot;\'])$&quot;)						-- match trailing double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-right'], cap);
		end
		
		if 2 == wl_type then
			str = utilities.make_wikilink (link, label);						-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin-based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate RTL languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO 639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO 639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title=, |script-chapter=, |script-&lt;periodical&gt;=

]]

local function format_script_value (script_value, script_param)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%l?%s*:') then									-- if first 3 or 4 non-space characters are script language prefix
		lang = script_value:match('^(%l%l%l?)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not utilities.is_set (lang) then
			utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['missing title part']});		-- prefix without 'title'; add error message
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_code_remap[lang] or mw.language.fetchLanguageName( lang, cfg.this_wiki_code );	-- get language name so that we can use it to categorize
		if utilities.is_set (name) then											-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l+%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if utilities.in_array (lang, cfg.script_lang_codes) then
				utilities.add_prop_cat ('script', {name, lang})
			else
				utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['unknown language code']});	-- unknown script-language; add error message
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['invalid language code']});		-- invalid language code; add error message
			lang = '';															-- invalid so set lang to empty string
		end
	else
		utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['missing prefix']});				-- no language code prefix; add error message
	end
	script_value = utilities.substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is RTL

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script
value has been wrapped in &lt;bdi&gt; tags.

]]

local function script_concatenate (title, script, script_param)
	if utilities.is_set (script) then
		script = format_script_value (script, script_param);					-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; returns empty string on error
		if utilities.is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not utilities.is_set ( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return utilities.substitute ( msg, str );								-- including template text
	else
		return utilities.substitute ( cfg.messages[key], str );
	end		
end


--[[----------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;-------------------

Makes a Wikisource URL from Wikisource interwiki-link.  Returns the URL and appropriate
label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;
	local wikisource_prefix = table.concat ({'https://', cfg.this_wiki_code, '.wikisource.org/wiki/'});

	wl_type, D, L = utilities.is_wikilink (str);								-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 1 == wl_type then													-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end

	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable URL
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent-encoding of fragment marker
	end

	return ws_url, ws_label, L or D;											-- return proper URL or nil and a label or nil
end


--[[----------------&lt; F O R M A T _ P E R I O D I C A L &gt;-----------------------

Format the three periodical parameters: |script-&lt;periodical&gt;=, |&lt;periodical&gt;=,
and |trans-&lt;periodical&gt;= into a single Periodical meta-parameter.

]]

local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)

	if not utilities.is_set (periodical) then
		periodical = '';														-- to be safe for concatenation
	else
		periodical = utilities.wrap_style ('italic-title', periodical);			-- style 
	end

	periodical = script_concatenate (periodical, script_periodical, script_periodical_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (trans_periodical) then
		trans_periodical = utilities.wrap_style ('trans-italic-title', trans_periodical);
		if utilities.is_set (periodical) then
			periodical = periodical .. ' ' .. trans_periodical;
		else																	-- here when trans-periodical without periodical or script-periodical
			periodical = trans_periodical;
			utilities.set_message ('err_trans_missing_title', {'periodical'});
		end
	end

	return periodical;
end


--[[------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;---------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=,
and |chapter-url= into a single chapter meta- parameter (chapter_url_source used
for error messages).

]]

local function format_chapter_title (script_chapter, script_chapter_source, chapter, chapter_source, trans_chapter, trans_chapter_source, chapter_url, chapter_url_source, no_quotes, access)
	local ws_url, ws_label, L = wikisource_url_make (chapter);					-- make a wikisource URL and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', ' ');									-- replace underscore separators with space characters
		chapter = ws_label;
	end

	if not utilities.is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from module provided quote marks
			chapter = utilities.wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, script_chapter, script_chapter_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (chapter_url) then
		chapter = external_link (chapter_url, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');	-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if utilities.is_set (trans_chapter) then
		trans_chapter = utilities.wrap_style ('trans-quoted-title', trans_chapter);
		if utilities.is_set (chapter) then
			chapter = chapter .. ' ' .. trans_chapter;
		else																	-- here when trans_chapter without chapter or script-chapter
			chapter = trans_chapter;
			chapter_source = trans_chapter_source:match ('trans%-?(.+)');		-- when no chapter, get matching name from trans-&lt;param&gt;
			utilities.set_message ('err_trans_missing_title', {chapter_source});
		end
	end

	return chapter;
end


--[[----------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;-------------------

This function searches a parameter's value for non-printable or invisible characters.
The search stops at the first match.

This function will detect the visible replacement character when it is part of the Wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers
(gallery, math, pre, ref) and identifies them with a slightly different error message.
See also coins_cleanup().

Output of this function is an error message that identifies the character or the
Unicode group, or the stripmarker that was detected along with its position (or,
for multi-byte characters, the position of its first byte) in the parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local stripmarker;															-- boolean set true when a stripmarker is found

	capture = string.match (v, '[%w%p ]*');										-- test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no Unicode characters
		return;
	end

	for _, invisible_char in ipairs (cfg.invisible_chars) do
		local char_name = invisible_char[1];									-- the character or group name
		local pattern = invisible_char[2];										-- the pattern used to find it
		position, _, capture = mw.ustring.find (v, pattern);					-- see if the parameter value contains characters that match the pattern
		
		if position and (cfg.invisible_defs.zwj == capture) then				-- if we found a zero-width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- it's ok if one of the Indic scripts
				position = nil;													-- unset position
			elseif cfg.emoji[mw.ustring.codepoint (v, position+1)] then			-- is zwj followed by a character listed in emoji{}?
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and utilities.in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and cfg.invisible_defs.del == capture then	-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture and not (cfg.invisible_defs.del == capture or cfg.invisible_defs.zwj == capture) then
					err_msg = capture .. ' ' .. char_name;
				else
					err_msg = char_name .. ' ' .. 'character';
				end

				utilities.set_message ('err_invisible_char', {err_msg, utilities.wrap_style ('parameter', param), position});	-- add error message
				return;															-- and done with this parameter
			end
		end
	end
end


--[[-------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------

Argument wrapper.  This function provides support for argument mapping defined
in the configuration file so that multiple names can be transparently aliased to
single internal variable.

]]

local function argument_wrapper ( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function ( self, k )
			local dummy = self[k];												-- force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = utilities.select_one ( args, list, 'err_redundant_parameters' );
				if origin[k] == nil then
					origin[k] = '';												-- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] .. ': ' .. k);
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;-------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.
When date is DD MMMM YYYY or is MMMM DD, YYYY then wrap in nowrap span:
&lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap = '';
	local cap2 = '';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = utilities.substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = utilities.substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;---------------------

This function sets default title types (equivalent to the citation including
|type=&lt;default value&gt;) for those templates that have defaults. Also handles the
special case where it is desirable to omit the title type from the rendered citation
(|type=none).

]]

local function set_titletype (cite_class, title_type)
	if utilities.is_set (title_type) then
		if 'none' == cfg.keywords_xlate[title_type] then
			title_type = '';													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; S A F E _ J O I N &gt;-----------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'duplicate character'
		if 1 == #duplicate_char then											-- for single byte ASCII characters use the string library functions
			f.gsub = string.gsub
			f.match = string.match
			f.sub = string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub = mw.ustring.gsub
			f.match = mw.ustring.match
			f.sub = mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1, 1) == '&lt;' then										-- special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove HTML markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1, 1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc.?
				trim = false;
				end_chr = f.sub(str, -1, -1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr .. &quot;)&quot;				-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1, -2);									-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;''&quot; then		-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5, -1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;]]&quot; then		-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3, -1) == duplicate_char .. '&quot;]' then	-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2, -1) == duplicate_char .. &quot;]&quot; then	-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2, -1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1, -3);								-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains HTML markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows HTML markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value; 												-- add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;-----------------------------

returns true if suffix is properly formed Jr, Sr, or ordinal in the range 1–9.
Puncutation not allowed.

]]

local function is_suffix (suffix)
	if utilities.in_array (suffix, {'Jr', 'Sr', 'Jnr', 'Snr', '1st', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;-------------------

For Vancouver style, author/editor names are supposed to be rendered in Latin
(read ASCII) characters.  When a name uses characters that contain diacritical
marks, those characters are to be converted to the corresponding Latin
character. When a name is written using a non-Latin alphabet or logogram, that
name is to be transliterated into Latin characters. The module doesn't do this
so editors may/must.

This test allows |first= and |last= names to contain any of the letters defined
in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes.
	(http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;)
	or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written outside of the code editor and pasted here because the code editor
gets confused between character insertion point and cursor position. The test has
been rewritten to use decimal character escape sequence for the individual bytes
of the Unicode characters so that it is not necessary to use an external editor
to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first, suffix, position)
	if not suffix then
		if first:find ('[,%s]') then											-- when there is a space or comma, might be first name/initials + generational suffix
			first = first:match ('(.-)[,%s]+');									-- get name/initials
			suffix = first:match ('[,%s]+(.+)$');								-- get generational suffix
		end
	end
	if utilities.is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error (cfg.err_msg_supl.suffix, position);
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error (cfg.err_msg_supl['non-Latin char'], position);
			return false;														-- not a string of Latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-style=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period.
See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc.) to be rendered
as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format
because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the
Unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first, position)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just initials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error (cfg.err_msg_supl.suffix, position);			-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word

	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i], 1, 1));			-- insert the initial at end of initials table
		end
		i = i + 1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; L I S T _ P E O P L E &gt;--------------------------

Formats a list of people (authors, contributors, editors, interviewers, translators) 

names in the list will be linked when
	|&lt;name&gt;-link= has a value
	|&lt;name&gt;-mask- does NOT have a value; masked names are presumed to have been
		rendered previously so should have been linked there

when |&lt;name&gt;-mask=0, the associated name is not rendered

]]

local function list_people (control, people, etal)
	local sep;
	local namesep;
	local format = control.format;
	local maximum = control.maximum;
	local name_list = {};

	if 'vanc' == format then													-- Vancouver-like name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between names is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between names is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub (-1, -1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if utilities.is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end		-- returned 0 is for EditorCount; not used for other names
	
	for i, person in ipairs (people) do
		if utilities.is_set (person.last) then
			local mask = person.mask;
			local one;
			local sep_one = sep;

			if utilities.is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			end
			
			if mask then
				local n = tonumber (mask);										-- convert to a number if it can be converted; nil else
				if n then
					one = 0 ~= n and string.rep(&quot;&amp;mdash;&quot;, n) or nil;			-- make a string of (n &gt; 0) mdashes, nil else, to replace name
					person.link = nil;											-- don't create link to name if name is replaces with mdash string or has been set nil
				else
					one = mask;													-- replace name with mask text (must include name-list separator)
					sep_one = &quot; &quot;;												-- modify name-list separator
				end
			else
				one = person.last;												-- get surname
				local first = person.first										-- get given name
				if utilities.is_set (first) then
					if (&quot;vanc&quot; == format) then									-- if Vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first, nil, i) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials (first, i);				-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
			end
			if utilities.is_set (person.link) then
				one = utilities.make_wikilink (person.link, one);				-- link author/editor
			end
			if one then															-- if &lt;one&gt; has a value (name, mdash replacement, or mask text replacement)
				table.insert (name_list, one);									-- add it to the list of names
				table.insert (name_list, sep_one);								-- add the proper name-list separator
			end
		end
	end

	local count = #name_list / 2;												-- (number of names + number of separators) divided by 2
	if 0 &lt; count then 
		if 1 &lt; count and not etal then
			if 'amp' == format then
				name_list[#name_list-2] = &quot; &amp; &quot;;								-- replace last separator with ampersand text
			elseif 'and' == format then
				if 2 == count then
					name_list[#name_list-2] = cfg.presentation.sep_nl_and;		-- replace last separator with 'and' text
				else
					name_list[#name_list-2] = cfg.presentation.sep_nl_end;		-- replace last separator with '(sep) and' text
				end
			end
		end
		name_list[#name_list] = nil;											-- erase the last separator
	end

	local result = table.concat (name_list);									-- construct list
	if etal and utilities.is_set (result) then									-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've got a last-first list and etal so add et al.
	end
	
	return result, count;														-- return name-list string and count of number of names (count used for editor names only)
end


--[[--------------------&lt; M A K E _ C I T E R E F _ I D &gt;-----------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise
returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that
order.  year is Year or anchor_year.

]]

local function make_citeref_id (namelist, year)
	local names={};							-- a table for the one to four names and year
	for i,v in ipairs (namelist) do			-- loop through the list and take up to the first four last names
		names[i] = v.last
		if i == 4 then break end			-- if four then done
	end
	table.insert (names, year);				-- add the year at the end
	local id = table.concat(names);			-- concatenate names and year for CITEREF id
	if utilities.is_set (id) then			-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;				-- add the CITEREF portion
	else
		return '';							-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; C I T E _ C L A S S _A T T R I B U T E _M A K E &gt;------------------------------

construct &lt;cite&gt; tag class attribute for this citation.

&lt;cite_class&gt; – config.CitationClass from calling template
&lt;mode&gt; – value from |mode= parameter

]]

local function cite_class_attribute_make (cite_class, mode)
	local class_t = {};
	table.insert (class_t, 'citation');											-- required for blue highlight
	if 'citation' ~= cite_class then
		table.insert (class_t, cite_class);										-- identify this template for user css
		table.insert (class_t, utilities.is_set (mode) and mode or 'cs1');		-- identify the citation style for user css or javascript
	else
		table.insert (class_t, utilities.is_set (mode) and mode or 'cs2');		-- identify the citation style for user css or javascript
	end
	for _, prop_key in ipairs (z.prop_keys_t) do
		table.insert (class_t, prop_key);										-- identify various properties for user css or javascript
	end

	return table.concat (class_t, ' ');											-- make a big string and done
end


--[[---------------------&lt; N A M E _ H A S _ E T A L &gt;--------------------------

Evaluates the content of name parameters (author, editor, etc.) for variations on
the theme of et al.  If found, the et al. is removed, a flag is set to true and
the function returns the modified name and the flag.

This function never sets the flag to false but returns its previous state because
it may have been set by previous passes through this function or by the associated
|display-&lt;names&gt;=etal parameter

]]

local function name_has_etal (name, etal, nocat, param)

	if utilities.is_set (name) then												-- name can be nil in which case just return
		local patterns = cfg.et_al_patterns; 									-- get patterns from configuration
		
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns
			if name:match (pattern) then										-- if this 'et al' pattern is found in name
				name = name:gsub (pattern, '');									-- remove the offending text
				etal = true;													-- set flag (may have been set previously here or by |display-&lt;names&gt;=etal)
				if not nocat then												-- no categorization for |vauthors=
					utilities.set_message ('err_etal', {param});				-- and set an error if not added
				end
			end
		end
	end

	return name, etal;
end


--[[---------------------&lt; N A M E _ I S _ N U M E R I C &gt;----------------------

Add maint cat when name parameter value does not contain letters.  Does not catch
mixed alphanumeric names so |last=A. Green (1922-1987) does not get caught in the
current version of this test but |first=(1888) is caught.

returns nothing

]]

local function name_is_numeric (name, list_name)
	if utilities.is_set (name) then
		if mw.ustring.match (name, '^[%A]+$') then								-- when name does not contain any letters
			utilities.set_message ('maint_numeric_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
		end
	end
end


--[[-----------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;------------------

Evaluates the content of last/surname (authors etc.) parameters for multiple names.
Multiple names are indicated if there is more than one comma or any &quot;unescaped&quot;
semicolons. Escaped semicolons are ones used as part of selected HTML entities.
If the condition is met, the function adds the multiple name maintenance category.

returns nothing

]]

local function name_has_mult_names (name, list_name)
	local _, commas, semicolons, nbsps;
	if utilities.is_set (name) then
		_, commas = name:gsub (',', '');										-- count the number of commas
		_, semicolons = name:gsub (';', '');									-- count the number of semicolons
		-- nbsps probably should be its own separate count rather than merged in
		-- some way with semicolons because Lua patterns do not support the
		-- grouping operator that regex does, which means there is no way to add
		-- more entities to escape except by adding more counts with the new
		-- entities
		_, nbsps = name:gsub ('&amp;nbsp;','');										-- count nbsps
		
		-- There is exactly 1 semicolon per &amp;nbsp; entity, so subtract nbsps
		-- from semicolons to 'escape' them. If additional entities are added,
		-- they also can be subtracted.
		if 1 &lt; commas or 0 &lt; (semicolons - nbsps) then
			utilities.set_message ('maint_mult_names', cfg.special_case_translation [list_name]);	-- add a maint message
		end
	end
end


--[=[-------------------------&lt; I S _ G E N E R I C &gt;----------------------------------------------------------

Compares values assigned to various parameters according to the string provided as &lt;item&gt; in the function call.
&lt;item&gt; can have on of two values:
	'generic_names' – for name-holding parameters: |last=, |first=, |editor-last=, etc
	'generic_titles' – for |title=

There are two types of generic tests.  The 'accept' tests look for a pattern that should not be rejected by the
'reject' test.  For example,
	|author=[[John Smith (author)|Smith, John]]
would be rejected by the 'author' reject test.  But piped wikilinks with 'author' disambiguation should not be
rejected so the 'accept' test prevents that from happening.  Accept tests are always performed before reject
tests.

Each of the 'accept' and 'reject' sequence tables hold tables for en.wiki (['en']) and local.wiki (['local'])
that each can hold a test sequence table  The sequence table holds, at index [1], a test pattern, and, at index
[2], a boolean control value.  The control value tells string.find() or mw.ustring.find() to do plain-text search (true)
or a pattern search (false).  The intent of all this complexity is to make these searches as fast as possible so
that we don't run out of processing time on very large articles.

Returns
	true when a reject test finds the pattern or string
	false when an accept test finds the pattern or string
	nil else

]=]

local function is_generic (item, value, wiki)
	local test_val;
	local str_lower = {															-- use string.lower() for en.wiki (['en']) and use mw.ustring.lower() or local.wiki (['local'])
		['en'] = string.lower,
		['local'] = mw.ustring.lower,
		}
	local str_find = {															-- use string.find() for en.wiki (['en']) and use mw.ustring.find() or local.wiki (['local'])
		['en'] = string.find,
		['local'] = mw.ustring.find,
		}

	local function test (val, test_t, wiki)										-- local function to do the testing; &lt;wiki&gt; selects lower() and find() functions
		val = test_t[2] and str_lower[wiki](value) or val;						-- when &lt;test_t[2]&gt; set to 'true', plaintext search using lowercase value
		return str_find[wiki] (val, test_t[1], 1, test_t[2]);					-- return nil when not found or matched
	end
		
	local test_types_t = {'accept', 'reject'};									-- test accept patterns first, then reject patterns
	local wikis_t = {'en', 'local'};											-- do tests for each of these keys; en.wiki first, local.wiki second

	for _, test_type in ipairs (test_types_t) do								-- for each test type
		for _, generic_value in pairs (cfg.special_case_translation[item][test_type]) do	-- spin through the list of generic value fragments to accept or reject
			for _, wiki in ipairs (wikis_t) do
				if generic_value[wiki] then
					if test (value, generic_value[wiki], wiki) then				-- go do the test
						return ('reject' == test_type);							-- param value rejected, return true; false else
					end
				end
			end
		end
	end
end


--[[--------------------------&lt; N A M E _ I S _ G E N E R I C &gt;------------------------------------------------

calls is_generic() to determine if &lt;name&gt; is a 'generic name' listed in cfg.generic_names; &lt;name_alias&gt; is the
parameter name used in error messaging

]]

local function name_is_generic (name, name_alias)
	if not added_generic_name_errs  and is_generic ('generic_names', name) then
		utilities.set_message ('err_generic_name', name_alias);					-- set an error message
		added_generic_name_errs = true;
	end
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------

This function calls various name checking functions used to validate the content of the various name-holding parameters.

]]

local function name_checks (last, first, list_name, last_alias, first_alias)
	local accept_name;

	if utilities.is_set (last) then
		last, accept_name = utilities.has_accept_as_written (last);				-- remove accept-this-as-written markup when it wraps all of &lt;last&gt;

		if not accept_name then													-- &lt;last&gt; not wrapped in accept-as-written markup
			name_has_mult_names (last, list_name);								-- check for multiple names in the parameter (last only)
			name_is_numeric (last, list_name);									-- check for names that are composed of digits and punctuation
			name_is_generic (last, last_alias);									-- check for names found in the generic names list
		end
	end

	if utilities.is_set (first) then
		first, accept_name = utilities.has_accept_as_written (first);			-- remove accept-this-as-written markup when it wraps all of &lt;first&gt;

		if not accept_name then													-- &lt;first&gt; not wrapped in accept-as-written markup
			name_is_numeric (first, list_name);									-- check for names that are composed of digits and punctuation
			name_is_generic (first, first_alias);								-- check for names found in the generic names list
		end
		local wl_type, D = utilities.is_wikilink (first);
		if 0 ~= wl_type then
			first = D;
			utilities.set_message ('err_bad_paramlink', first_alias);
		end
	end

	return last, first;															-- done
end


--[[----------------------&lt; E X T R A C T _ N A M E S &gt;-------------------------

Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters
(or their aliases), and their matching link and mask parameters. Stops searching
when both |lastn= and |firstn= are not found in args after two sequential attempts:
found |last1=, |last2=, and |last3= but doesn't find |last4= and |last5= then the
search is done.

This function emits an error message when there is a |firstn= without a matching
|lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not
required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.'
is stripped from the parameter and a flag (etal) returned that will cause list_people()
to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps
'et al.' out of the template's metadata.  When this occurs, an error is emitted.

]]

local function extract_names(args, list_name)
	local names = {};															-- table of names
	local last;																	-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;																-- loop counter/indexer
	local n = 1;																-- output table indexer
	local count = 0;															-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal = false;															-- return value set to true when we find some form of et al. in an author parameter

	local last_alias, first_alias, link_alias;									-- selected parameter aliases used in error messaging
	while true do
		last, last_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'err_redundant_parameters', i );		-- search through args for name components beginning at 1
		first, first_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'err_redundant_parameters', i );
		link, link_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i );
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.
		last, first = name_checks (last, first, list_name, last_alias, first_alias);						-- multiple names, extraneous annotation, etc. checks

		if first and not last then												-- if there is a firstn without a matching lastn
			local alias = first_alias:find ('given', 1, true) and 'given' or 'first';	-- get first or given form of the alias
			utilities.set_message ('err_first_missing_last', {
				first_alias,													-- param name of alias missing its mate
				first_alias:gsub (alias, {['first'] = 'last', ['given'] = 'surname'}),	-- make param name appropriate to the alias form
				});																-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			local result;
			link = link_title_ok (link, link_alias, last, last_alias);			-- check for improper wiki-markup

			if first then
				link = link_title_ok (link, link_alias, first, first_alias);	-- check for improper wiki-markup
			end

			names[n] = {last = last, first = first, link = link, mask = mask, corporate = false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				utilities.set_message ('err_missing_name', {list_name:match (&quot;(%w+)List&quot;):lower(), i - 1});	-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names and the etal flag
end


--[[--------------------------&lt; N A M E _ T A G _ G E T &gt;------------------------------------------------------

attempt to decode |language=&lt;lang_param&gt; and return language name and matching tag; nil else.

This function looks for:
	&lt;lang_param&gt; as a tag in cfg.lang_code_remap{}
	&lt;lang_param&gt; as a name in cfg.lang_name_remap{}
	
	&lt;lang_param&gt; as a name in cfg.mw_languages_by_name_t
	&lt;lang_param&gt; as a tag in cfg.mw_languages_by_tag_t
when those fail, presume that &lt;lang_param&gt; is an IETF-like tag that MediaWiki does not recognize.  Strip all
script, region, variant, whatever subtags from &lt;lang_param&gt; to leave just a two or three character language tag
and look for the new &lt;lang_param&gt; in cfg.mw_languages_by_tag_t{}

on success, returns name (in properly capitalized form) and matching tag (in lowercase); on failure returns nil

]]

local function name_tag_get (lang_param)
	local lang_param_lc = mw.ustring.lower (lang_param);						-- use lowercase as an index into the various tables
	local name;
	local tag;

	name = cfg.lang_code_remap[lang_param_lc];									-- assume &lt;lang_param_lc&gt; is a tag; attempt to get remapped language name 
	if name then																-- when &lt;name&gt;, &lt;lang_param&gt; is a tag for a remapped language name
		return name, lang_param_lc;												-- so return &lt;name&gt; from remap and &lt;lang_param_lc&gt;
	end

	tag = lang_param_lc:match ('^(%a%a%a?)%-.*');								-- still assuming that &lt;lang_param_lc&gt; is a tag; strip script, region, variant subtags
	name = cfg.lang_code_remap[tag];											-- attempt to get remapped language name with language subtag only
	if name then																-- when &lt;name&gt;, &lt;tag&gt; is a tag for a remapped language name
		return name, tag;														-- so return &lt;name&gt; from remap and &lt;tag&gt;
	end

	if cfg.lang_name_remap[lang_param_lc] then									-- not a tag, assume &lt;lang_param_lc&gt; is a name; attempt to get remapped language tag 
		return cfg.lang_name_remap[lang_param_lc][1], cfg.lang_name_remap[lang_param_lc][2];	-- for this &lt;lang_param_lc&gt;, return a (possibly) new name and appropriate tag
	end

	tag = cfg.mw_languages_by_name_t[lang_param_lc];							-- assume that &lt;lang_param_lc&gt; is a language name; attempt to get its matching tag
	
	if tag then
		return cfg.mw_languages_by_tag_t[tag], tag;								-- &lt;lang_param_lc&gt; is a name so return the name from the table and &lt;tag&gt;
	end

	name = cfg.mw_languages_by_tag_t[lang_param_lc];							-- assume that &lt;lang_param_lc&gt; is a tag; attempt to get its matching language name
	
	if name then
		return name, lang_param_lc;												-- &lt;lang_param_lc&gt; is a tag so return it and &lt;name&gt;
	end
	
	tag = lang_param_lc:match ('^(%a%a%a?)%-.*');								-- is &lt;lang_param_lc&gt; an IETF-like tag that MediaWiki doesn't recognize? &lt;tag&gt; gets the language subtag; nil else

	if tag then
		name = cfg.mw_languages_by_tag_t[tag];									-- attempt to get a language name using the shortened &lt;tag&gt;
		if name then
			return name, tag;													-- &lt;lang_param_lc&gt; is an unrecognized IETF-like tag so return &lt;name&gt; and language subtag
		end
	end
end


--[[-------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code
is recognized by MediaWiki, use the returned name; if not, then use the value that
was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is
assigned to the category for that code: Category:Norwegian-language sources (no).
For valid three-character code languages, the page is assigned to the single category
for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does
not recognize three-character equivalents of two-character codes: code 'ar' is
recognized but code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th
where the language names or codes are separated from each other by commas with
optional space characters.

]]

local function language_parameter (lang)
	local tag;																	-- some form of IETF-like language tag; language subtag with optional region, sript, vatiant, etc subtags
	local lang_subtag;															-- ve populates |language= with mostly unecessary region subtags the MediaWiki does not recognize; this is the base language subtag
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_t = {};															-- table made from the value assigned to |language=

	local this_wiki_name = mw.language.fetchLanguageName (cfg.this_wiki_code, cfg.this_wiki_code);	-- get this wiki's language name

	names_t = mw.text.split (lang, '%s*,%s*');									-- names should be a comma separated list

	for _, lang in ipairs (names_t) do											-- reuse lang here because we don't yet know if lang is a language name or a language tag
		name, tag = name_tag_get (lang);										-- attempt to get name/tag pair for &lt;lang&gt;; &lt;name&gt; has proper capitalization; &lt;tag&gt; is lowercase

		if utilities.is_set (tag) then
			lang_subtag = tag:gsub ('^(%a%a%a?)%-.*', '%1');					-- for categorization, strip any IETF-like tags from language tag

			if cfg.this_wiki_code ~= lang_subtag then							-- when the language is not the same as this wiki's language
				if 2 == lang_subtag:len() then									-- and is a two-character tag
--					utilities.add_prop_cat ('foreign-lang-source', {name, lang_subtag}, lang_subtag);		-- categorize it; tag appended to allow for multiple language categorization
					utilities.add_prop_cat ('foreign-lang-source', {name, tag}, lang_subtag);		-- categorize it; tag appended to allow for multiple language categorization
				else															-- or is a recognized language (but has a three-character tag)
					utilities.add_prop_cat ('foreign-lang-source-2', {lang_subtag}, lang_subtag);			-- categorize it differently TODO: support multiple three-character tag categories per cs1|2 template?
				end
			elseif cfg.local_lang_cat_enable then								-- when the language and this wiki's language are the same and categorization is enabled
				utilities.add_prop_cat ('local-lang-source', {name, lang_subtag});		-- categorize it
			end
		else
			name = lang;														-- return whatever &lt;lang&gt; has so that we show something
			utilities.set_message ('maint_unknown_lang');						-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
 
	name = utilities.make_sep_list (#language_list, language_list);
	if (1 == #language_list) and (lang_subtag == cfg.this_wiki_code) then		-- when only one language, find lang name in this wiki lang name; for |language=en-us, 'English' in 'American English'
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[-----------------------&lt; S E T _ C S _ S T Y L E &gt;--------------------------

Gets the default CS style configuration for the given mode.
Returns default separator and either postscript as passed in or the default.
In CS1, the default postscript and separator are '.'.
In CS2, the default postscript is the empty string and the default separator is ','.

]]

local function set_cs_style (postscript, mode)
	if utilities.is_set(postscript) then
		-- emit a maintenance message if user postscript is the default cs1 postscript
		-- we catch the opposite case for cs2 in set_style
		if mode == 'cs1' and postscript == cfg.presentation['ps_' .. mode] then
			utilities.set_message ('maint_postscript');
		end
	else
		postscript = cfg.presentation['ps_' .. mode];
	end
	return cfg.presentation['sep_' .. mode], postscript;
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;-----------------------------

Sets the separator and postscript styles. Checks the |mode= first and the
#invoke CitationClass second. Removes the postscript if postscript == none.

]]

local function set_style (mode, postscript, cite_class)
	local sep;
	if 'cs2' == mode then
		sep, postscript = set_cs_style (postscript, 'cs2');
	elseif 'cs1' == mode then
		sep, postscript = set_cs_style (postscript, 'cs1');
	elseif 'citation' == cite_class	then
		sep, postscript = set_cs_style (postscript, 'cs2');
	else
		sep, postscript = set_cs_style (postscript, 'cs1');
	end

	if cfg.keywords_xlate[postscript:lower()] == 'none' then
		-- emit a maintenance message if user postscript is the default cs2 postscript
		-- we catch the opposite case for cs1 in set_cs_style
		if 'cs2' == mode or 'citation' == cite_class then
			utilities.set_message ('maint_postscript');
		end
		postscript = '';
	end
	
	return sep, postscript
end


--[=[-------------------------&lt; I S _ P D F &gt;-----------------------------------

Determines if a URL has the file extension that is one of the PDF file extensions
used by [[MediaWiki:Common.css]] when applying the PDF icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or
		url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
		url:match ('%.PDF&amp;#035') or url:match ('%.pdf&amp;#035');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;-----------------------

Applies CSS style to |format=, |chapter-format=, etc.  Also emits an error message
if the format parameter does not have a matching URL parameter.  If the format parameter
is not set and the URL contains a file extension that is recognized as a PDF document
by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if utilities.is_set (format) then
		format = utilities.wrap_style ('format', format);						-- add leading space, parentheses, resize
		if not utilities.is_set (url) then
			utilities.set_message ('err_format_missing_url', {fmt_param, url_param});	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if URL is a PDF file then
		format = utilities.wrap_style ('format', 'PDF');						-- set format to PDF
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[---------------------&lt; G E T _ D I S P L A Y _ N A M E S &gt;------------------

Returns a number that defines the number of names displayed for author and editor
name lists and a Boolean flag to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero,
return the number and the previous state of the 'etal' flag (false by default
but may have been set to true if the name list contains some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number
that is one greater than the number of authors in the list and set the 'etal' flag true.
This will cause the list_people() to display all of the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_names (max, count, list_name, etal, param)
	if utilities.is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				utilities.set_message ('err_disp_name', {param, max});			-- add error message
				max = nil;
			end
		else																	-- not a valid keyword or number
			utilities.set_message ('err_disp_name', {param, max});		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[----------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;---------------

Adds error if |page=, |pages=, |quote-page=, |quote-pages= has what appears to be
some form of p. or pp. abbreviation in the first characters of the parameter content.

check page for extraneous p, p., pp, pp., pg, pg. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when page begins PX or P# but not Px
		      where x and X are letters and # is a digit
	bad pattern:  '^[Pp][PpGg]' matches when page begins pp, pP, Pp, PP, pg, pG, Pg, PG

]]

local function extra_text_in_page_check (val, name)
	if not val:match (cfg.vol_iss_pg_patterns.good_ppattern) then
		for _, pattern in ipairs (cfg.vol_iss_pg_patterns.bad_ppatterns) do		-- spin through the selected sequence table of patterns
			if val:match (pattern) then											-- when a match, error so
				utilities.set_message ('err_extra_text_pages', name);	 		-- add error message
				return;															-- and done
			end
		end
	end		
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ V O L _ I S S _ C H E C K &gt;------------------------

Adds error if |volume= or |issue= has what appears to be some form of redundant 'type' indicator.

For |volume=:
	'V.', or 'Vol.' (with or without the dot) abbreviations or 'Volume' in the first characters of the parameter
	content (all case insensitive). 'V' and 'v' (without the dot) are presumed to be roman numerals so
	are allowed.

For |issue=:
	'No.', 'I.', 'Iss.' (with or without the dot) abbreviations, or 'Issue' in the first characters of the
	parameter content (all case insensitive).
	
Single character values ('v', 'i', 'n') allowed when not followed by separator character ('.', ':', '=', or
whitespace character) – param values are trimmed of whitespace by MediaWiki before delivered to the module.
	
&lt;val&gt; is |volume= or |issue= parameter value
&lt;name&gt; is |volume= or |issue= parameter name for error message
&lt;selector&gt; is 'v' for |volume=, 'i' for |issue=

sets error message on failure; returns nothing

]]

local function extra_text_in_vol_iss_check (val, name, selector)
	if not utilities.is_set (val) then
		return;
	end
	
	local patterns = 'v' == selector and cfg.vol_iss_pg_patterns.vpatterns or cfg.vol_iss_pg_patterns.ipatterns;

	local handler = 'v' == selector and 'err_extra_text_volume' or 'err_extra_text_issue';
	val = val:lower();															-- force parameter value to lower case
	for _, pattern in ipairs (patterns) do										-- spin through the selected sequence table of patterns
		if val:match (pattern) then												-- when a match, error so
			utilities.set_message (handler, name);								-- add error message
			return;																-- and done
		end
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parentheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a placeholder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parentheses
			local name = name_table[i];
			i = i + 1;															-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parentheses
					break;														-- and done reassembling so
				end
				i = i + 1;														-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = utilities.is_wikilink (name_table[i]);		-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i + 1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled parentheses ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the Vancouver error when a required comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		first = '';																-- set to empty string for concatenation and because it may have been set for previous author/editor
		local accept_name;
		v_name, accept_name = utilities.has_accept_as_written (v_name);			-- remove accept-this-as-written markup when it wraps all of &lt;v_name&gt;

		if accept_name then
			last = v_name;
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error (cfg.err_msg_supl.punctuation, i);
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s+&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be initials or generational suffix

			if not mw.ustring.match (first, '^%u+$') then						-- mw.ustring here so that later we will catch non-Latin characters
				suffix = first;													-- not initials so assume that whatever we got is a generational suffix
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end
			last = table.concat(lastfirstTable, ' ')							-- returns a string that is the concatenation of all other names that are not initials and generational suffix
			if not utilities.is_set (last) then
				first = '';														-- unset
				last = v_name;													-- last empty because something wrong with first
				add_vanc_error (cfg.err_msg_supl.name, i);
			end
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error (cfg.err_msg_supl['missing comma'], i);			-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- matches a space between two initials
			end
		else
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
		
		if utilities.is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first, suffix, i);							-- check first and last before restoring the suffix which may have a non-Latin digit
			if utilities.is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '', nil, i);
			end
		end

		link = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i ) or v_link_table[i];
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate = corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest;
|editorn= (and aliases) highest and |veditors= lowest (support for |editors= withdrawn)

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
	local lastfirst = false;
	if utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice in case we have a |first1= without a |last1=; this ...
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or		-- ... also catches the case where |first= is used with |vauthors=
		utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst = true;
	end

	if (utilities.is_set (vxxxxors) and true == lastfirst) or					-- these are the three error conditions
		(utilities.is_set (vxxxxors) and utilities.is_set (xxxxors)) or
		(true == lastfirst and utilities.is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			utilities.set_message ('err_redundant_parameters', err_name .. '-name-list parameters');	-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if utilities.is_set (vxxxxors) then return 2 end;
	if utilities.is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, live, dead, etc.).  When the parameter value has not been assigned a value (missing
or empty in the source template) the function returns the value specified by ret_val.  If the parameter value is one
of the list of allowed values returns the translated value; else, emits an error message and returns the value
specified by ret_val.

TODO: explain &lt;invert&gt;

]]

local function is_valid_parameter_value (value, name, possible, ret_val, invert)
	if not utilities.is_set (value) then
		return ret_val;															-- an empty parameter is ok
	end

	if (not invert and utilities.in_array (value, possible)) then				-- normal; &lt;value&gt; is in &lt;possible&gt; table
		return cfg.keywords_xlate[value];										-- return translation of parameter keyword
	elseif invert and not utilities.in_array (value, possible) then				-- invert; &lt;value&gt; is not in &lt;possible&gt; table
		return value;															-- return &lt;value&gt; as it is
	else
		utilities.set_message ('err_invalid_param_val', {name, value});			-- not an allowed value so add error message
		return ret_val;
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list, -3, -1) == sepc .. '. ') then					-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list, -1, -1) == sepc) or (string.sub (name_list, -3, -1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terminate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not utilities.is_set (volume) and not utilities.is_set (issue) then
		return '';
	end

	-- same condition as in format_pages_sheets()
	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);

	local is_numeric_vol = volume and (volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$'));	-- is only uppercase roman numerals or only digits?
	local is_long_vol = volume and (4 &lt; mw.ustring.len(volume));				-- is |volume= value longer than 4 characters?
	
	if volume and (not is_numeric_vol and is_long_vol) then						-- when not all digits or Roman numerals, is |volume= longer than 4 characters?
		utilities.add_prop_cat ('long-vol');									-- yes, add properties cat
	end

	if is_journal then															-- journal-style formatting
		local vol = '';
		
		if utilities.is_set (volume) then
			if is_numeric_vol then												-- |volume= value all digits or all uppercase Roman numerals?
				vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, volume});	-- render in bold face
			elseif is_long_vol then												-- not all digits or Roman numerals; longer than 4 characters?
				vol = utilities.substitute (cfg.messages['j-vol'], {sepc, utilities.hyphen_to_dash (volume)});	-- not bold
			else																-- four or fewer characters
				vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, utilities.hyphen_to_dash (volume)});	-- bold
			end
		end
		if utilities.is_set (issue) then
			return vol .. utilities.substitute (cfg.messages['j-issue'], issue);
		end
		return vol;
	end
	
	if 'podcast' == cite_class and utilities.is_set (issue) then
		return wrap_msg ('issue', {sepc, issue}, lower);
	end

	-- all other types of citation
	if utilities.is_set (volume) and utilities.is_set (issue) then
		return wrap_msg ('vol-no', {sepc, utilities.hyphen_to_dash (volume), issue}, lower);
	elseif utilities.is_set (volume) then
		return wrap_msg ('vol', {sepc, utilities.hyphen_to_dash (volume)}, lower);
	else
		return wrap_msg ('issue', {sepc, issue}, lower);
	end
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if utilities.is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif utilities.is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if utilities.is_set (page) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return utilities.substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return utilities.substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif utilities.is_set (pages) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then							-- if pages is only digits, assume a single page number
			return '', utilities.substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', utilities.substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', utilities.substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to Wikisource, returns the label portion of the interwiki-link as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki-link to an external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, page_orig, pages, pages_orig, at)
	local ws_url, ws_label, coins_pages, L;										-- for Wikisource interwiki-links; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if utilities.is_set (page) then
		if utilities.is_set (pages) or utilities.is_set (at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page, page_orig);								-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws URL from |page= interwiki link; link portion L becomes tooltip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (pages) then
		if utilities.is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages, pages_orig);							-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws URL from |pages= interwiki link; link portion L becomes tooltip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws URL from |at= interwiki link; link portion L becomes tooltip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end

--[[--------------------------&lt; I S _ U N I Q U E _ A R C H I V E _ U R L &gt;------------------------------------

add error message when |archive-url= value is same as |url= or chapter-url= (or alias...) value

]]

local function is_unique_archive_url (archive, url, c_url, source, date)
	if utilities.is_set (archive) then
		if archive == url or archive == c_url then
			utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)});	-- add error message
			return '', '';														-- unset |archive-url= and |archive-date= because same as |url= or |chapter-url=
		end
	end

	return archive, date;
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org URLs to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot URL or to calendar pages.  When the archive URL is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the URL.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org URL does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command URL
	|archive-url= is an archive.org URL that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org URLs:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this function may return a modified
archive URL:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the URL unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.org URL
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine URL
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command URL, we don't want to allow saving of the target page 
		err_msg = cfg.err_msg_supl.save;
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = cfg.err_msg_supl.liveweb;
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');	-- split out some of the URL parts for evaluation
		if not path then														-- malformed in some way; pattern did not match
			err_msg = cfg.err_msg_supl.timestamp;
		elseif 14 ~= timestamp:len() then										-- path and flag optional, must have 14-digit timestamp here
			err_msg = cfg.err_msg_supl.timestamp;
			if '*' ~= flag then
				local replacement = timestamp:match ('^%d%d%d%d%d%d') or timestamp:match ('^%d%d%d%d');	-- get the first 6 (YYYYMM) or first 4 digits (YYYY)
				if replacement then												-- nil if there aren't at least 4 digits (year)
					replacement = replacement .. string.rep ('0', 14 - replacement:len());	-- year or yearmo (4 or 6 digits) zero-fill to make 14-digit timestamp
					url=url:gsub ('(//web%.archive%.org/[^%d]*)%d[^/]*', '%1' .. replacement .. '*', 1)	-- for preview, modify ts to 14 digits plus splat for calendar display
				end
			end
		elseif utilities.is_set (path) and 'web/' ~= path then					-- older archive URLs do not have the extra 'web/' path element
			err_msg = cfg.err_msg_supl.path;
		elseif utilities.is_set (flag) and not utilities.is_set (path) then		-- flag not allowed with the old form URL (without the 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		elseif utilities.is_set (flag) and not flag:match ('%a%a_') then		-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		else
			return url, date;													-- return ArchiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	utilities.set_message ('err_archive_url', {err_msg});						-- add error message and

	if is_preview_mode then
		return url, date;														-- preview mode so return ArchiveURL and ArchiveDate
	else
		return '', '';															-- return empty strings for ArchiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; P L A C E _ C H E C K &gt;--------------------------------------------------------

check |place=, |publication-place=, |location= to see if these params include digits.  This function added because
many editors misuse location to specify the in-source location (|page(s)= and |at= are supposed to do that)

returns the original parameter value without modification; added maint cat when parameter value contains digits

]]

local function place_check (param_val)
	if not utilities.is_set (param_val) then									-- parameter empty or omitted
		return param_val;														-- return that empty state
	end
	
	if mw.ustring.find (param_val, '%d') then									-- not empty, are there digits in the parameter value
		utilities.set_message ('maint_location');								-- yep, add maint cat
	end
	
	return param_val;															-- and done
end


--[[--------------------------&lt; I S _ A R C H I V E D _ C O P Y &gt;----------------------------------------------

compares |title= to 'Archived copy' (placeholder added by bots that can't find proper title); if matches, return true; nil else

]]

local function is_archived_copy (title)
	title = mw.ustring.lower(title);											-- switch title to lower case
	if title:find (cfg.special_case_translation.archived_copy.en) then			-- if title is 'Archived copy'
		return true;
	elseif cfg.special_case_translation.archived_copy['local'] then
		if mw.ustring.find (title, cfg.special_case_translation.archived_copy['local']) then	-- mw.ustring() because might not be Latin script
			return true;
		end
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args )
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper ( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListStyle = is_valid_parameter_value (A['NameListStyle'], A:ORIGIN('NameListStyle'), cfg.keywords_lists['name-list-style'], '');
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				utilities.set_message ('maint_authors');						-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if utilities.is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], nil, args, 'EditorList');	-- support for |editors= withdrawn
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		end
	end
							
	local Chapter = A['Chapter'];												-- done here so that we have access to |contribution= from |chapter= aliases
	local Chapter_origin = A:ORIGIN ('Chapter');
	local Contribution;															-- because contribution is required for contributor(s)
		if 'contribution' == Chapter_origin then
			Contribution = Chapter;												-- get the name of the contribution
		end
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	
	if utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not utilities.is_set (Contribution) then							-- |contributor= requires |contribution=
				utilities.set_message ('err_contributor_missing_required_param', 'contribution');	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				utilities.set_message ('err_contributor_missing_required_param', 'author');	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if utilities.select_one (args, cfg.aliases['ContributorList-Last'], 'err_redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			utilities.set_message ('err_contributor_ignored');					-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	local Title = A['Title'];
	local TitleLink = A['TitleLink'];

	local auto_select = ''; -- default is auto
	local accept_link;
	TitleLink, accept_link = utilities.has_accept_as_written (TitleLink, true);	-- test for accept-this-as-written markup
	if (not accept_link) and utilities.in_array (TitleLink, {'none', 'pmc', 'doi'}) then -- check for special keywords
		auto_select = TitleLink;												-- remember selection for later
		TitleLink = '';															-- treat as if |title-link= would have been empty
	end

	TitleLink = link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wiki-markup in |title-link= or wiki-markup in |title= when |title-link= is set

	local Section = '';															-- {{cite map}} only; preset to empty string for concatenation if not used
	if 'map' == config.CitationClass and 'section' == Chapter_origin then
		Section = A['Chapter'];													-- get |section= from |chapter= alias list; |chapter= and the other aliases not supported in {{cite map}}
		Chapter = '';															-- unset for now; will be reset later from |map= if present
	end

	local Periodical = A['Periodical'];
	local Periodical_origin = '';
	if utilities.is_set (Periodical) then
		Periodical_origin = A:ORIGIN('Periodical');								-- get the name of the periodical parameter
		local i;
		Periodical, i = utilities.strip_apostrophe_markup (Periodical);			-- strip apostrophe markup so that metadata isn't contaminated 
		if i then																-- non-zero when markup was stripped so emit an error message
			utilities.set_message ('err_apostrophe_markup', {Periodical_origin});
		end
	end

	if 'mailinglist' == config.CitationClass then								-- special case for {{cite mailing list}}
		if utilities.is_set (Periodical) and utilities.is_set (A ['MailingList']) then	-- both set emit an error TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', Periodical_origin) .. ' and ' .. utilities.wrap_style ('parameter', 'mailinglist')});
		end

		Periodical = A ['MailingList'];											-- error or no, set Periodical to |mailinglist= value because this template is {{cite mailing list}}
		Periodical_origin = A:ORIGIN('MailingList');
	end

	local ScriptPeriodical = A['ScriptPeriodical'];

	-- web and news not tested for now because of 
	-- Wikipedia:Administrators%27_noticeboard#Is_there_a_semi-automated_tool_that_could_fix_these_annoying_&quot;Cite_Web&quot;_errors?
	if not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) then	-- 'periodical' templates require periodical parameter
	--	local p = {['journal'] = 'journal', ['magazine'] = 'magazine', ['news'] = 'newspaper', ['web'] = 'website'};	-- for error message
		local p = {['journal'] = 'journal', ['magazine'] = 'magazine'};			-- for error message
		if p[config.CitationClass]  then
			utilities.set_message ('err_missing_periodical', {config.CitationClass, p[config.CitationClass]});
		end
	end
	
	local Volume;
	local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) then
			if not utilities.in_array (Periodical_origin, cfg.citation_no_volume_t) then	-- {{citation}} does not render |volume= when these parameters are used
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		elseif utilities.is_set (ScriptPeriodical) then
			if 'script-website' ~= ScriptPeriodical_origin then					-- {{citation}} does not render volume for |script-website=
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		else
			Volume = A['Volume'];												-- and does for non-'periodical' cites
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_volume) then	-- render |volume= for cs1 according to the configuration settings
		Volume = A['Volume'];
	end	
	extra_text_in_vol_iss_check (Volume, A:ORIGIN ('Volume'), 'v');	

	local Issue;
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) and utilities.in_array (Periodical_origin, cfg.citation_issue_t) then	-- {{citation}} may render |issue= when these parameters are used
			Issue = utilities.hyphen_to_dash (A['Issue']);
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_issue) then	-- conference &amp; map books do not support issue; {{citation}} listed here because included in settings table
		if not (utilities.in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical))) then
			Issue = utilities.hyphen_to_dash (A['Issue']);
		end
	end
	extra_text_in_vol_iss_check (Issue, A:ORIGIN ('Issue'), 'i');	

	local Page;
	local Pages;
	local At;
	if not utilities.in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = utilities.hyphen_to_dash (A['Pages']);	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = place_check (A['PublicationPlace'], A:ORIGIN('PublicationPlace'));
	local Place = place_check (A['Place'], A:ORIGIN('Place'));
	
	local PublisherName = A['PublisherName'];
	local PublisherName_origin = A:ORIGIN('PublisherName');
	if utilities.is_set (PublisherName) then
		local i = 0;
		PublisherName, i = utilities.strip_apostrophe_markup (PublisherName);	-- strip apostrophe markup so that metadata isn't contaminated; publisher is never italicized
		if i then																-- non-zero when markup was stripped so emit an error message
			utilities.set_message ('err_apostrophe_markup', {PublisherName_origin});
		end
	end

	local Newsgroup = A['Newsgroup'];											-- TODO: strip apostrophe markup?
	local Newsgroup_origin = A:ORIGIN('Newsgroup');	

	if 'newsgroup' == config.CitationClass then
		if utilities.is_set (PublisherName) then								-- general use parameter |publisher= not allowed in cite newsgroup
			utilities.set_message ('err_parameter_ignored', {PublisherName_origin});
		end

		PublisherName = nil;													-- ensure that this parameter is unset for the time being; will be used again after COinS
	end

	local URL = A['URL'];														-- TODO: better way to do this for URL, ChapterURL, and MapURL?
	local UrlAccess = is_valid_parameter_value (A['UrlAccess'], A:ORIGIN('UrlAccess'), cfg.keywords_lists['url-access'], nil);
	
	if not utilities.is_set (URL) and utilities.is_set (UrlAccess) then
		UrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', 'url');
	end
	
	local ChapterURL = A['ChapterURL'];
	local ChapterUrlAccess = is_valid_parameter_value (A['ChapterUrlAccess'], A:ORIGIN('ChapterUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (ChapterURL) and utilities.is_set (ChapterUrlAccess) then
		ChapterUrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', {A:ORIGIN('ChapterUrlAccess'):gsub ('%-access', '')});
	end

	local MapUrlAccess = is_valid_parameter_value (A['MapUrlAccess'], A:ORIGIN('MapUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (A['MapURL']) and utilities.is_set (MapUrlAccess) then
		MapUrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', {'map-url'});
	end

	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local no_tracking_cats = is_valid_parameter_value (A['NoTracking'], A:ORIGIN('NoTracking'), cfg.keywords_lists['yes_true_y'], nil);

	-- check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not utilities.is_set (no_tracking_cats) then								-- ignore if we are already not going to categorize this page
		if utilities.in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _, v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end
																				-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	utilities.select_one (args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'err_redundant_parameters');	-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, A:ORIGIN('Page'), Pages, A:ORIGIN('Pages'), At);

	local NoPP = is_valid_parameter_value (A['NoPP'], A:ORIGIN('NoPP'), cfg.keywords_lists['yes_true_y'], nil);

	if utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- both |publication-place= and |place= (|location=) allowed if different
		utilities.add_prop_cat ('location-test');								-- add property cat to evaluate how often PublicationPlace and Place are used together
		if PublicationPlace == Place then
			Place = '';															-- unset; don't need both if they are the same
		end
	elseif not utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- when only |place= (|location=) is set ...
		PublicationPlace = Place;												-- promote |place= (|location=) to |publication-place
	end

	if PublicationPlace == Place then Place = ''; end							-- don't need both if they are the same
	
	local URL_origin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL_origin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ScriptChapter = A['ScriptChapter'];
	local ScriptChapter_origin = A:ORIGIN ('ScriptChapter');
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local TransChapter = A['TransChapter'];
	local TransChapter_origin = A:ORIGIN ('TransChapter');
	local TransTitle = A['TransTitle'];
	local ScriptTitle = A['ScriptTitle'];
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia= and |title= then map |title= to |article= and |encyclopedia= to |title=
		|encyclopedia= and |article= then map |encyclopedia= to |title=

		|trans-title= maps to |trans-chapter= when |title= is re-mapped
		|url= maps to |chapter-url= when |title= is remapped
	
	All other combinations of |encyclopedia=, |title=, and |article= are not modified
	
	]]

	local Encyclopedia = A['Encyclopedia'];										-- used as a flag by this module and by ~/COinS

	if utilities.is_set (Encyclopedia) then										-- emit error message when Encyclopedia set but template is other than {{cite encyclopedia}} or {{citation}}
		if 'encyclopaedia' ~= config.CitationClass and 'citation' ~= config.CitationClass then
			utilities.set_message ('err_parameter_ignored', {A:ORIGIN ('Encyclopedia')});
			Encyclopedia = nil;													-- unset because not supported by this template
		end
	end

	if ('encyclopaedia' == config.CitationClass) or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Periodical) and utilities.is_set (Encyclopedia) then	-- when both set emit an error TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', A:ORIGIN ('Encyclopedia')) .. ' and ' .. utilities.wrap_style ('parameter', Periodical_origin)});
		end

		if utilities.is_set (Encyclopedia) then
			Periodical = Encyclopedia;											-- error or no, set Periodical to Encyclopedia; allow periodical without encyclopedia
			Periodical_origin = A:ORIGIN ('Encyclopedia');
		end

		if utilities.is_set (Periodical) then									-- Periodical is set when |encyclopedia= is set
			if utilities.is_set (Title) or utilities.is_set (ScriptTitle) then
				if not utilities.is_set (Chapter) then
					Chapter = Title;											-- |encyclopedia= and |title= are set so map |title= to |article= and |encyclopedia= to |title=
					ScriptChapter = ScriptTitle;
					ScriptChapter_origin = A:ORIGIN('ScriptTitle')
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterURL_origin = URL_origin;

					ChapterUrlAccess = UrlAccess;

					if not utilities.is_set (ChapterURL) and utilities.is_set (TitleLink) then
						Chapter = utilities.make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			elseif utilities.is_set (Chapter) or utilities.is_set (ScriptChapter) then								-- |title= not set
				Title = Periodical;												-- |encyclopedia= set and |article= set so map |encyclopedia= to |title=
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- special case for cite techreport.
	local ID = A['ID'];
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if utilities.is_set (A['Number']) then									-- cite techreport uses 'number', which other citations alias to 'issue'
			if not utilities.is_set (ID) then									-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'id') .. ' and ' .. utilities.wrap_style ('parameter', 'number')});
			end
		end	
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	local ChapterLink -- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local Conference = A['Conference'];
	local BookTitle = A['BookTitle'];
	local TransTitle_origin = A:ORIGIN ('TransTitle');
	if 'conference' == config.CitationClass then
		if utilities.is_set (BookTitle) then
			Chapter = Title;
			Chapter_origin = 'title';
	--		ChapterLink = TitleLink;											-- |chapter-link= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			URL_origin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			TransChapter_origin = TransTitle_origin;
			Title = BookTitle;
			Format = '';
	--		TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end
	
	-- CS1/2 mode
	local Mode = is_valid_parameter_value (A['Mode'], A:ORIGIN('Mode'), cfg.keywords_lists['mode'], '');
	-- separator character and postscript
	local sepc, PostScript = set_style (Mode:lower(), A['PostScript'], config.CitationClass);
	-- controls capitalization of certain static text
	local use_lowercase = ( sepc == ',' );
	
	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		if utilities.is_set (Chapter) then										--TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'map') .. ' and ' .. utilities.wrap_style ('parameter', Chapter_origin)});	-- add error message
		end
		Chapter = A['Map'];
		Chapter_origin = A:ORIGIN('Map');
		ChapterURL = A['MapURL'];
		ChapterURL_origin = A:ORIGIN('MapURL');
		TransChapter = A['TransMap'];
		ScriptChapter = A['ScriptMap']
		ScriptChapter_origin = A:ORIGIN('ScriptMap')

		ChapterUrlAccess = MapUrlAccess;
		ChapterFormat = A['MapFormat'];

		Cartography = A['Cartography'];
		if utilities.is_set ( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if utilities.is_set ( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	local Series = A['Series'];
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local SeriesLink = A['SeriesLink'];

		SeriesLink = link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wiki-markup in |series-link= or wiki-markup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if utilities.is_set (Network) then table.insert(n, Network); end
		if utilities.is_set (Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if utilities.is_set (Season) and utilities.is_set (SeriesNumber) then	-- these are mutually exclusive so if both are set TODO: make a function for this and similar?
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'season') .. ' and ' .. utilities.wrap_style ('parameter', 'seriesno')});		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if utilities.is_set (Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if utilities.is_set (SeriesNumber) then table.insert(s, wrap_msg ('seriesnum', SeriesNumber, use_lowercase)); end
			if utilities.is_set (Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ScriptChapter_origin = A:ORIGIN('ScriptTitle');
			ChapterLink = TitleLink;											-- alias |episode-link=
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			ChapterFormat = Format;

			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if utilities.is_set (ChapterLink) and not utilities.is_set (ChapterURL) then	-- link but not URL
				Chapter = utilities.make_wikilink (ChapterLink, Chapter);
			elseif utilities.is_set (ChapterLink) and utilities.is_set (ChapterURL) then	-- if both are set, URL links episode;
				Series = utilities.make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			Format = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if utilities.is_set (Series) and utilities.is_set (SeriesLink) then
				Series = utilities.make_wikilink (SeriesLink, Series);
			end
			Series = utilities.wrap_style ('italic-title', Series);				-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- handle type parameter for those CS1 citations that have default values
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	if utilities.in_array (config.CitationClass, {'AV-media-notes', 'interview', 'mailinglist', 'map', 'podcast', 'pressrelease', 'report', 'speech', 'techreport', 'thesis'}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if utilities.is_set (Degree) and &quot;Thesis&quot; == TitleType then				-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if utilities.is_set (TitleType) then										-- if type parameter is specified
		TitleType = utilities.substitute ( cfg.messages['type'], TitleType);	-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
	local Date = A['Date'];
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging
	local PublicationDate = A['PublicationDate'];
	local Year = A['Year'];

	if not utilities.is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not utilities.is_set (Date) and utilities.is_set (PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]

	local DF = is_valid_parameter_value (A['DF'], A:ORIGIN('DF'), cfg.keywords_lists['df'], '');
	if not utilities.is_set (DF) then
		DF = cfg.global_df;														-- local |df= if present overrides global df set by {{use xxx date}} template
	end

	local ArchiveURL;
	local ArchiveDate;
	local ArchiveFormat = A['ArchiveFormat'];

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	
	ArchiveURL, ArchiveDate = is_unique_archive_url (ArchiveURL, URL, ChapterURL, A:ORIGIN('ArchiveURL'), ArchiveDate);		-- add error message when URL or ChapterURL == ArchiveURL

	
	local AccessDate = A['AccessDate'];
	local LayDate = A['LayDate'];
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification
	local DoiBroken = A['DoiBroken'];
	local Embargo = A['Embargo'];
	local anchor_year;															-- used in the CITEREF identifier
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val = AccessDate, name = A:ORIGIN ('AccessDate')},
			['archive-date'] = {val = ArchiveDate, name = A:ORIGIN ('ArchiveDate')},
			['date'] = {val = Date, name = Date_origin},
			['doi-broken-date'] = {val = DoiBroken, name = A:ORIGIN ('DoiBroken')},
			['pmc-embargo-date'] = {val = Embargo, name = A:ORIGIN ('Embargo')},
			['lay-date'] = {val = LayDate, name = A:ORIGIN ('LayDate')},
			['publication-date'] = {val = PublicationDate, name = A:ORIGIN ('PublicationDate')},
			['year'] = {val = Year, name = A:ORIGIN ('Year')},
			};

		local error_list = {};
		anchor_year, Embargo = validation.dates(date_parameters_list, COinS_date, error_list);

-- start temporary Julian / Gregorian calendar uncertainty categorization
		if COinS_date.inter_cal_cat then
			utilities.add_prop_cat ('jul-greg-uncertainty');
		end
-- end temporary Julian / Gregorian calendar uncertainty categorization

		if utilities.is_set (Year) and utilities.is_set (Date) then				-- both |date= and |year= not normally needed; 
			validation.year_date_check (Year, A:ORIGIN ('Year'), Date, A:ORIGIN ('Date'), error_list);
		end
		
		if 0 == #error_list then												-- error free dates only; 0 when error_list is empty
			local modified = false;												-- flag
			
			if utilities.is_set (DF) then										-- if we need to reformat dates
				modified = validation.reformat_dates (date_parameters_list, DF);	-- reformat to DF format, use long month names if appropriate
			end

			if true == validation.date_hyphen_to_dash (date_parameters_list) then	-- convert hyphens to dashes where appropriate
				modified = true;
				utilities.set_message ('maint_date_format');					-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language; not supported at en.wiki
			if cfg.date_name_auto_xlate_enable and validation.date_name_xlate (date_parameters_list, cfg.date_digit_auto_xlate_enable ) then
				utilities.set_message ('maint_date_auto_xlated');				-- add maint cat
				modified = true;
			end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				LayDate = date_parameters_list['lay-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end
		else
			utilities.set_message ('err_bad_date', {utilities.make_sep_list (#error_list, error_list)});	-- add this error message
		end
	end	-- end of do

	local ID_list = {};															-- sequence table of rendered identifiers
	local ID_list_coins = {};													-- table of identifiers and their values from args; key is same as cfg.id_handlers's key
	local Class = A['Class'];													-- arxiv class identifier
	
	local ID_support = {
		{A['ASINTLD'], 'ASIN', 'err_asintld_missing_asin', A:ORIGIN ('ASINTLD')},				
		{DoiBroken, 'DOI', 'err_doibroken_missing_doi', A:ORIGIN ('DoiBroken')},
		{Embargo, 'PMC', 'err_embargo_missing_pmc', A:ORIGIN ('Embargo')},
		}

	ID_list, ID_list_coins = identifiers.identifier_lists_get (args, {DoiBroken = DoiBroken, ASINTLD = A['ASINTLD'], Embargo = Embargo, Class = Class}, ID_support);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite ssrn}}, before generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then
		if not utilities.is_set (ID_list_coins[config.CitationClass:upper()]) then 	-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp; |citeseerx= required for their templates
			utilities.set_message ('err_' .. config.CitationClass .. '_missing');	-- add error message
		end

		Periodical = ({['arxiv'] = 'arXiv', ['biorxiv'] = 'bioRxiv', ['citeseerx'] = 'CiteSeerX', ['ssrn'] = 'Social Science Research Network'})[config.CitationClass];
	end

	-- Link the title of the work if no |url= was provided, but we have a |pmc= or a |doi= with |doi-access=free

	if config.CitationClass == &quot;journal&quot; and not utilities.is_set (URL) and not utilities.is_set (TitleLink) and not utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) then -- TODO: remove 'none' once existing citations have been switched to 'off', so 'none' can be used as token for &quot;no title&quot; instead
		if 'none' ~= cfg.keywords_xlate[auto_select] then						-- if auto-linking not disabled
 	 		if identifiers.auto_link_urls[auto_select] then						-- manual selection
		 		URL = identifiers.auto_link_urls[auto_select];					-- set URL to be the same as identifier's external link
 				URL_origin = cfg.id_handlers[auto_select:upper()].parameters[1];	-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['pmc'] then						-- auto-select PMC
				URL = identifiers.auto_link_urls['pmc'];						-- set URL to be the same as the PMC external link if not embargoed
				URL_origin = cfg.id_handlers['PMC'].parameters[1];				-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['doi'] then						-- auto-select DOI
				URL = identifiers.auto_link_urls['doi'];
				URL_origin = cfg.id_handlers['DOI'].parameters[1];
			end
 	 	end

		if utilities.is_set (URL) then											-- set when using an identifier-created URL
			if utilities.is_set (AccessDate) then								-- |access-date= requires |url=; identifier-created URL is not |url=
				utilities.set_message ('err_accessdate_missing_url');			-- add an error message
				AccessDate = '';												-- unset
			end

			if utilities.is_set (ArchiveURL) then								-- |archive-url= requires |url=; identifier-created URL is not |url=
				utilities.set_message ('err_archive_missing_url');				-- add an error message
				ArchiveURL = '';												-- unset
			end
		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not utilities.is_set (Title) and not utilities.is_set (TransTitle) and not utilities.is_set (ScriptTitle) then	-- has special case for cite episode
		utilities.set_message ('err_citation_missing_title', {'episode' == config.CitationClass and 'series' or 'title'});
	end

	if utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) and
			utilities.in_array (config.CitationClass, {'journal', 'citation'}) and
			(utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and
			('journal' == Periodical_origin or 'script-journal' == ScriptPeriodical_origin) then	-- special case for journal cites
				Title = '';														-- set title to empty string
				utilities.set_message ('maint_untitled');						-- add maint cat
	end

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Chapter) and utilities.is_set (Title) and utilities.is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end
	
	local QuotePage = A['QuotePage'];
	local QuotePages = utilities.hyphen_to_dash (A['QuotePages']);

	-- this is the function call to COinS()
	local OCinSoutput = metadata.COinS({
		['Periodical'] = utilities.strip_apostrophe_markup (Periodical),		-- no markup in the metadata
		['Encyclopedia'] = Encyclopedia,										-- just a flag; content ignored by ~/COinS
		['Chapter'] = metadata.make_coins_title (coins_chapter, ScriptChapter),	-- Chapter and ScriptChapter stripped of bold / italic / accept-as-written markup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = metadata.make_coins_title (coins_title, ScriptTitle),		-- Title and ScriptTitle stripped of bold / italic / accept-as-written markup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Quarter'] = COinS_date.rftquarter,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = coins_pages or metadata.get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At, QuotePage, QuotePages}, 7)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName or Newsgroup,							-- any apostrophe markup already removed from PublisherName
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list_coins,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, and {{cite ssrn}} AFTER generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, CiteSeerX, or ssrn now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass and utilities.is_set (Newsgroup) then
		PublisherName = utilities.substitute (cfg.messages['newsgroup'], external_link( 'news:' .. Newsgroup, Newsgroup, Newsgroup_origin, nil ));
	end

	local Editors;
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	local Contributors;															-- assembled contributors name list
	local contributor_etal;
	local Translators;															-- assembled translators name list
	local translator_etal;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	local Interviewers;															
	local interviewers_list = {};					
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters
	local interviewer_etal;
	
	-- Now perform various field 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.
	do
		local last_first_list;
		local control = { 
			format = NameListStyle,												-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_names (A['DisplayEditors'], #e, 'editors', editor_etal, A:ORIGIN ('DisplayEditors'));
			Editors, EditorCount = list_people (control, e, editor_etal);

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum, interviewer_etal = get_display_names (A['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal, A:ORIGIN ('DisplayInterviewers'));
			Interviewers = list_people (control, interviewers_list, interviewer_etal);
		end
		do																		-- now do translators
			control.maximum, translator_etal = get_display_names (A['DisplayTranslators'], #t, 'translators', translator_etal, A:ORIGIN ('DisplayTranslators'));
			Translators = list_people (control, t, translator_etal);
		end
		do																		-- now do contributors
			control.maximum, contributor_etal = get_display_names (A['DisplayContributors'], #c, 'contributors', contributor_etal, A:ORIGIN ('DisplayContributors'));
			Contributors = list_people (control, c, contributor_etal);
		end
		do																		-- now do authors
			control.maximum, author_etal = get_display_names (A['DisplayAuthors'], #a, 'authors', author_etal, A:ORIGIN ('DisplayAuthors'));

			last_first_list = list_people (control, a, author_etal);

			if utilities.is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors');	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if utilities.is_set (Authors) and utilities.is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not utilities.is_set (URL) then
		if utilities.in_array (config.CitationClass, {&quot;web&quot;, &quot;podcast&quot;, &quot;mailinglist&quot;}) or		-- |url= required for cite web, cite podcast, and cite mailinglist
			('citation' == config.CitationClass and ('website' == Periodical_origin or 'script-website' == ScriptPeriodical_origin)) then	-- and required for {{citation}} with |website= or |script-website=
				utilities.set_message ('err_cite_web_url');
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if utilities.is_set (AccessDate) and not utilities.is_set (ChapterURL) then		-- ChapterURL may be set when URL is not set;
			utilities.set_message ('err_accessdate_missing_url');
			AccessDate = '';
		end
	end

	local UrlStatus = is_valid_parameter_value (A['UrlStatus'], A:ORIGIN('UrlStatus'), cfg.keywords_lists['url-status'], '');
	local OriginalURL
	local OriginalURL_origin
	local OriginalFormat
	local OriginalAccess;
	UrlStatus = UrlStatus:lower();												-- used later when assembling archived text
	if utilities.is_set ( ArchiveURL ) then
		if utilities.is_set (ChapterURL) then 									-- if chapter-url= is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURL_origin = ChapterURL_origin;								-- name of |chapter-url= parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=

			if 'live' ~= UrlStatus then
				ChapterURL = ArchiveURL											-- swap-in the archive's URL
				ChapterURL_origin = A:ORIGIN('ArchiveURL')						-- name of |archive-url= parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived URLs
			end
		elseif utilities.is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURL_origin = URL_origin;									-- name of URL parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;

			if 'live' ~= UrlStatus then											-- if URL set then |archive-url= applies to it
				URL = ArchiveURL												-- swap-in the archive's URL
				URL_origin = A:ORIGIN('ArchiveURL')								-- name of archive URL parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived URLs
			end
		end
	elseif utilities.is_set (UrlStatus) then									-- if |url-status= is set when |archive-url= is not set
 		utilities.set_message ('maint_url_status');								-- add maint cat
	end

	if utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) then
			local chap_param;
			if utilities.is_set (Chapter) then									-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif utilities.is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif utilities.is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif utilities.is_set (ScriptChapter) then
				chap_param = ScriptChapter_origin;
			else utilities.is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if utilities.is_set (chap_param) then								-- if we found one
				utilities.set_message ('err_chapter_ignored', {chap_param});	-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if utilities.is_set (Contribution) and 0 &lt; #c then						-- if this is a contribution with contributor(s)
			if utilities.in_array (Contribution:lower(), cfg.keywords_lists.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, ScriptChapter_origin, Chapter, Chapter_origin, TransChapter, TransChapter_origin, ChapterURL, ChapterURL_origin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if utilities.is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and utilities.is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter .. sepc .. ' ';
		elseif utilities.is_set (ChapterFormat) then							-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title
	local plain_title = false;
	local accept_title;
	Title, accept_title = utilities.has_accept_as_written (Title, true);		-- remove accept-this-as-written markup when it wraps all of &lt;Title&gt;
	if accept_title and ('' == Title) then										-- only support forced empty for now &quot;(())&quot;
		Title = cfg.messages['notitle'];										-- replace by predefined &quot;No title&quot; message
			-- TODO: utilities.set_message ( 'err_redundant_parameters', ...);	-- issue proper error message instead of muting	 
			ScriptTitle = '';													-- just mute for now	 
			TransTitle = '';													-- just mute for now
 		plain_title = true;														-- suppress text decoration for descriptive title
		utilities.set_message ('maint_untitled');								-- add maint cat
	end

	if not accept_title then													-- &lt;Title&gt; not wrapped in accept-as-written markup
		if '...' == Title:sub (-3) then											-- if ellipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%' .. sepc .. '$', '');			-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end

		if utilities.is_set (ArchiveURL) and is_archived_copy (Title) then
			utilities.set_message ('maint_archived_copy');						-- add maintenance category before we modify the content of Title
		end

		if is_generic ('generic_titles', Title) then
			utilities.set_message ('err_generic_title');						-- set an error message
		end
	end

	if (not plain_title) and (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) or
		('map' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)))) then		-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from module provided quote marks
			Title = utilities.wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle, 'script-title');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
			TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );
	elseif plain_title or ('report' == config.CitationClass) then				-- no styling for cite report and descriptive titles (otherwise same as above)
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );	-- for cite report, use this form for trans-title
	else
		Title = utilities.wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-italic-title', TransTitle);
	end

	if utilities.is_set (TransTitle) then
		if utilities.is_set (Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			utilities.set_message ('err_trans_missing_title', {'title'});
		end
	end

	if utilities.is_set (Title) then											-- TODO: is this the right place to be making Wikisource URLs?
		if utilities.is_set (TitleLink) and utilities.is_set (URL) then
			utilities.set_message ('err_wikilink_in_url');						-- set an error message because we can't have both
			TitleLink = '';														-- unset
		end
	
		if not utilities.is_set (TitleLink) and utilities.is_set (URL) then
			Title = external_link (URL, Title, URL_origin, UrlAccess) .. TransTitle .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif utilities.is_set (TitleLink) and not utilities.is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle;
			else
				Title = utilities.make_wikilink (TitleLink, Title) .. TransTitle;
			end
		else
			local ws_url, ws_label, L;											-- Title has italic or quote markup by the time we get here which causes is_wikilink() to return 0 (not a wikilink)
			ws_url, ws_label, L = wikisource_url_make (Title:gsub('^[\'&quot;]*(.-)[\'&quot;]*$', '%1'));	-- make ws URL from |title= interwiki link (strip italic or quote markup); link portion L becomes tooltip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle;
			else
				Title = Title .. TransTitle;
			end
		end
	else
		Title = TransTitle;
	end

	if utilities.is_set (Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	local ConferenceURL_origin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	if utilities.is_set (Conference) then
		if utilities.is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURL_origin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif utilities.is_set (ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURL_origin, nil );
	end

	local Position = '';
	if not utilities.is_set (Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if utilities.is_set (Minutes) then
			if utilities.is_set (Time) then		--TODO: make a function for this and similar?
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'minutes') .. ' and ' .. utilities.wrap_style ('parameter', 'time')});
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if utilities.is_set (Time) then
				local TimeCaption = A['TimeCaption']
				if not utilities.is_set (TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = utilities.is_set (At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = utilities.is_set (Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Sections = A['Sections'];											-- Section (singular) is an alias of Chapter so set earlier
		local Inset = A['Inset'];
		
		if utilities.is_set ( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if utilities.is_set ( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif utilities.is_set ( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	local Others = A['Others'];
	if utilities.is_set (Others) and 0 == #a and 0 == #e then					-- add maint cat when |others= has value and used without |author=, |editor=
		if config.CitationClass == &quot;AV-media-notes&quot;
		or config.CitationClass == &quot;audio-visual&quot; then							-- special maint for AV/M which has a lot of 'false' positives right now
			utilities.set_message ('maint_others_avm')
		else
			utilities.set_message ('maint_others');
		end
	end
	Others = utilities.is_set (Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if utilities.is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if utilities.is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	local TitleNote = A['TitleNote'];
	TitleNote = utilities.is_set (TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if utilities.is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%n?%.?$') or Edition:match ('%f[%a][Ee]dition$') then -- Ed, ed, Ed., ed., Edn, edn, Edn., edn.
			utilities.set_message ('err_extra_text_edition');					 -- add error message
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = utilities.is_set (Series) and wrap_msg ('series', {sepc, Series}) or &quot;&quot;;	-- not the same as SeriesNum
	local Agency = A['Agency'];
	Agency = utilities.is_set (Agency) and wrap_msg ('agency', {sepc, Agency}) or &quot;&quot;;
	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	if utilities.is_set (AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = utilities.substitute (retrv_text, AccessDate);				-- add retrieved text

		AccessDate = utilities.substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if utilities.is_set (ID) then ID = sepc .. &quot; &quot; .. ID; end
	
	local Docket = A['Docket'];
   	if &quot;thesis&quot; == config.CitationClass and utilities.is_set (Docket) then
		ID = sepc .. &quot; Docket &quot; .. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and utilities.is_set (Docket) then		-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	if utilities.is_set (URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URL_origin, UrlAccess );
	end

	local Quote = A['Quote'];
	local TransQuote = A['TransQuote'];
	local ScriptQuote = A['ScriptQuote'];
	if utilities.is_set (Quote) or utilities.is_set (TransQuote) or utilities.is_set (ScriptQuote) then

		if utilities.is_set (Quote) then
			if Quote:sub(1, 1) == '&quot;' and Quote:sub(-1, -1) == '&quot;' then			-- if first and last characters of quote are quote marks
				Quote = Quote:sub(2, -2);										-- strip them off
			end
		end

		Quote = utilities.wrap_style ('quoted-text', Quote );					-- wrap in &lt;q&gt;...&lt;/q&gt; tags
	
		if utilities.is_set (ScriptQuote) then
			Quote = script_concatenate (Quote, ScriptQuote, 'script-quote');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after quote is wrapped
		end

		if utilities.is_set (TransQuote) then
			if TransQuote:sub(1, 1) == '&quot;' and TransQuote:sub(-1, -1) == '&quot;' then -- if first and last characters of |trans-quote are quote marks
				TransQuote = TransQuote:sub(2, -2); -- strip them off
			end
			Quote = Quote .. &quot; &quot; .. utilities.wrap_style ('trans-quoted-title', TransQuote );
		end

		if utilities.is_set (QuotePage) or utilities.is_set (QuotePages) then	-- add page prefix
			local quote_prefix = '';
			if utilities.is_set (QuotePage) then
				extra_text_in_page_check (QuotePage, 'quote-page');				-- add to maint cat if |quote-page= value begins with what looks like p., pp., etc.
				if not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePage}), '', '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePage}), '', '', '';
				end
			elseif utilities.is_set (QuotePages) then
				extra_text_in_page_check (QuotePages, 'quote-pages');			-- add to maint cat if |quote-pages= value begins with what looks like p., pp., etc.
				if tonumber(QuotePages) ~= nil and not NoPP then				-- if only digits, assume single page
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePages}), '', '';
				elseif not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['pp-prefix'], {sepc, QuotePages}), '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePages}), '', '';
				end
			end
                        
			Quote = quote_prefix .. &quot;: &quot; .. Quote;
		else
			Quote = sepc .. &quot; &quot; .. Quote;
		end

		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	-- We check length of PostScript here because it will have been nuked by
	-- the quote parameters. We'd otherwise emit a message even if there wasn't
	-- a displayed postscript.
	-- TODO: Should the max size (1) be configurable?
	-- TODO: Should we check a specific pattern?
	if utilities.is_set(PostScript) and mw.ustring.len(PostScript) &gt; 1 then
		utilities.set_message ('maint_postscript')
	end
	
	local Archived;
	if utilities.is_set (ArchiveURL) then
		local arch_text;
		if not utilities.is_set (ArchiveDate) then
			utilities.set_message ('err_archive_missing_date');
			ArchiveDate = '';													-- empty string for concatenation
		end
		if &quot;live&quot; == UrlStatus then
			arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if utilities.is_set (ArchiveDate) then
				Archived = sepc .. ' ' .. utilities.substitute ( cfg.messages['archived-live'],
					{external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil) .. ArchiveFormat, ArchiveDate } );
			else
				Archived = '';
			end
			if not utilities.is_set (OriginalURL) then
				utilities.set_message ('err_archive_missing_url');
				Archived = '';													-- empty string for concatenation
			end
		elseif utilities.is_set (OriginalURL) then								-- UrlStatus is empty, 'dead', 'unfit', 'usurped', 'bot: unknown'
			if utilities.in_array (UrlStatus, {'unfit', 'usurped', 'bot: unknown'}) then
				arch_text = cfg.messages['archived-unfit'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. ' ' .. arch_text .. ArchiveDate;				-- format already styled
				if 'bot: unknown' == UrlStatus then
					utilities.set_message ('maint_bot_unknown');				-- and add a category if not already added
				else
					utilities.set_message ('maint_unfit');						-- and add a category if not already added
				end
			else																-- UrlStatus is empty, 'dead'
				arch_text = cfg.messages['archived-dead'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				if utilities.is_set (ArchiveDate) then
					Archived = sepc .. &quot; &quot; .. utilities.substitute ( arch_text,
						{ external_link( OriginalURL, cfg.messages['original'], OriginalURL_origin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
				else
					Archived = '';												-- unset for concatenation
				end
			end	
		else																	-- OriginalUrl not set
			arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			utilities.set_message ('err_archive_missing_url');
			Archived = '';														-- empty string for concatenation
		end
	elseif utilities.is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = '';
	end
	
	local Lay = '';
	local LaySource = A['LaySource'];
	local LayURL = A['LayURL'];
	local LayFormat = A['LayFormat'];
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	if utilities.is_set (LayURL) then
		if utilities.is_set (LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if utilities.is_set (LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. utilities.safe_for_italics (LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif utilities.is_set (LayFormat) then									-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	local TranscriptURL = A['TranscriptURL']
	local TranscriptFormat = A['TranscriptFormat'];
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');
	local Transcript = A['Transcript'];
	local TranscriptURL_origin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL
	if utilities.is_set (Transcript) then
		if utilities.is_set (TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURL_origin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif utilities.is_set (TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURL_origin, nil );
	end

	local Publisher;
	if utilities.is_set (PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if utilities.is_set (PublisherName) then
		if utilities.is_set (PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif utilities.is_set (PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	local TransPeriodical =  A['TransPeriodical'];
	local TransPeriodical_origin =  A:ORIGIN ('TransPeriodical');
	-- Several of the above rely upon detecting this as nil, so do it last.
	if (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical)) then
		if utilities.is_set (Title) or utilities.is_set (TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		else 
			Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		end
	end
	
	local Language = A['Language'];
	if utilities.is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc.
	else
		Language='';															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then									-- cite speech only
		TitleNote = TitleType;													-- move TitleType to TitleNote so that it renders ahead of |event=
		TitleType = '';															-- and unset

		if utilities.is_set (Periodical) then									-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if utilities.is_set (Conference) then								-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;							-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
		if utilities.is_set (Others) then Others = safe_join ({Others, sepc .. &quot; &quot;}, sepc) end		-- add terminal punctuation &amp; space; check for dup sepc; TODO why do we need to do this here?
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (Periodical) then		-- special cases for book cites
		if utilities.is_set (Contributors) then									-- when we are citing foreword, preface, introduction, etc.
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if utilities.is_set (Chapter) then										-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif utilities.is_set (Periodical) then								-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local Via = A['Via'];
	Via = utilities.is_set (Via) and  wrap_msg ('via', Via) or '';
	local idcommon;
	if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then	-- special case for cite AV media &amp; cite episode position transcript
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, Lay, Quote }, sepc );
	else
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, Lay, Quote }, sepc );
	end
	
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	local OrigDate = A['OrigDate'];
	OrigDate = utilities.is_set (OrigDate) and wrap_msg ('origdate', OrigDate) or '';
	if utilities.is_set (Date) then
		if utilities.is_set (Authors) or utilities.is_set (Editors) then		-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date .. &quot;)&quot; .. OrigDate .. sepc .. &quot; &quot;;				-- in parentheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon, -1, -1) == sepc) then						-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigDate;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigDate;							-- Date begins with sepc
			end
		end
	end	
	if utilities.is_set (Authors) then
		if (not utilities.is_set (Date)) then									-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if utilities.is_set (Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then
					in_text = in_text:lower()									-- lowercase for cs2
				end
			end
			if EditorCount &lt;= 1 then
				post_text = &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot;;				-- be consistent with no-author, no-date case
			else
				post_text = &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot;;
			end
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Contributors) then									-- book cite and we're citing the intro, preface, etc.
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if utilities.is_set (Editors) and utilities.is_set (Date) then		-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not utilities.is_set (Date)) then								-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif utilities.is_set (Editors) then
		if utilities.is_set (Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if utilities.is_set (PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc ); 								-- Deals with italics, spaces, etc.
		text = text:sub(1, -sepc:len() - 1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite&gt; element
	local options_t = {};
	options_t.class = cite_class_attribute_make (config.CitationClass, Mode);

	local Ref = is_valid_parameter_value (A['Ref'], A:ORIGIN('Ref'), cfg.keywords_lists['ref'], nil, true);	-- nil when |ref=harv; A['Ref'] else

	if 'none' ~= cfg.keywords_xlate[(Ref and Ref:lower()) or ''] then
		local namelist_t = {};													-- holds selected contributor, author, editor name list
		local year = first_set ({Year, anchor_year}, 2);						-- Year first for legacy citations and for YMD dates that require disambiguation

		if #c &gt; 0 then															-- if there is a contributor list
			namelist_t = c;														-- select it
		elseif #a &gt; 0 then														-- or an author list
			namelist_t = a;
		elseif #e &gt; 0 then														-- or an editor list
			namelist_t = e;
		end
		local citeref_id;
		if #namelist_t &gt; 0 then													-- if there are names in namelist_t
			citeref_id = make_citeref_id (namelist_t, year);					-- go make the CITEREF anchor
			if mw.uri.anchorEncode (citeref_id) == ((Ref and mw.uri.anchorEncode (Ref)) or '') then	-- Ref may already be encoded (by {{sfnref}}) so citeref_id must be encoded before comparison
				utilities.set_message ('maint_ref_duplicates_default');
			end
		else
			citeref_id = '';													-- unset
		end
		options_t.id = Ref or citeref_id;
	end

	if string.len (text:gsub('%b&lt;&gt;', '')) &lt;= 2 then								-- remove html and html-like tags; then get length of what remains; 
		z.error_cats_t = {};													-- blank the categories list
		z.error_msgs_t = {};													-- blank the error messages list
		OCinSoutput = nil;														-- blank the metadata string
		text = '';																-- blank the the citation
		utilities.set_message ('err_empty_citation');							-- set empty citation message and category
	end
	
	local render_t = {};														-- here we collect the final bits for concatenation into the rendered citation

	if utilities.is_set (options_t.id) then										-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render_t, utilities.substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options_t.id), mw.text.nowiki(options_t.class), text}));	-- when |ref= is set or when there is a namelist
	else
		table.insert (render_t, utilities.substitute (cfg.presentation['cite'], {mw.text.nowiki(options_t.class), text}));	-- when |ref=none or when namelist_t empty and |ref= is missing or is empty
	end		

	if OCinSoutput then															-- blanked when citation is 'empty' so don't bother to add boilerplate metadata span
		table.insert (render_t, utilities.substitute (cfg.presentation['ocins'], OCinSoutput));	-- format and append metadata to the citation
	end

	local template_name = ('citation' == config.CitationClass) and 'citation' or 'cite ' .. (cfg.citation_class_map_t[config.CitationClass] or config.CitationClass);
	local template_link = '[[Template:' .. template_name .. '|' .. template_name .. ']]';
	local msg_prefix = '&lt;code class=&quot;cs1-code&quot;&gt;{{' .. template_link .. '}}&lt;/code&gt;: ';

	if 0 ~= #z.error_msgs_t then
		mw.addWarning (utilities.substitute (cfg.messages.warning_msg_e, template_link));

		table.insert (render_t, ' ');											-- insert a space between citation and its error messages
		table.sort (z.error_msgs_t);											-- sort the error messages list; sorting includes wrapping &lt;span&gt; and &lt;code&gt; tags; hidden-error sorts ahead of visible-error

		local hidden = true;													-- presume that the only error messages emited by this template are hidden
		for _, v in ipairs (z.error_msgs_t) do									-- spin through the list of error messages
			if v:find ('cs1-visible-error', 1, true) then						-- look for the visible error class name
				hidden = false;													-- found one; so don't hide the error message prefix
				break;															-- and done because no need to look further
			end
		end

		z.error_msgs_t[1] = table.concat ({utilities.error_comment (msg_prefix, hidden), z.error_msgs_t[1]});	-- add error message prefix to first error message to prevent extraneous punctuation
		table.insert (render_t, table.concat (z.error_msgs_t, '; '));			-- make a big string of error messages and add it to the rendering
	end

	if 0 ~= #z.maint_cats_t then
		mw.addWarning (utilities.substitute (cfg.messages.warning_msg_m, template_link));

		table.sort (z.maint_cats_t);											-- sort the maintenance messages list

		local maint_msgs_t = {};												-- here we collect all of the maint messages

		if 0 == #z.error_msgs_t then											-- if no error messages
			table.insert (maint_msgs_t, msg_prefix);							-- insert message prefix in maint message livery
		end
		
		for _, v in ipairs( z.maint_cats_t ) do									-- append maintenance categories
			table.insert (maint_msgs_t, 										-- assemble new maint message and add it to the maint_msgs_t table
				table.concat ({v, ' (', utilities.substitute (cfg.messages[':cat wikilink'], v), ')'})
				);
		end
		table.insert (render_t, utilities.substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs_t, ' ')));	-- wrap the group of maint messages with proper presentation and save
	end

	if not no_tracking_cats then
		for _, v in ipairs (z.error_cats_t) do									-- append error categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
		end
		for _, v in ipairs (z.maint_cats_t) do									-- append maintenance categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
		end
		for _, v in ipairs (z.prop_cats_t) do									-- append properties categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
		end
	end

	return table.concat (render_t);												-- make a big string and done
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class, empty)
	local name = tostring (name);
	local enum_name;															-- for enumerated parameters, is name with enumerator replaced with '#'
	local state;
	local function state_test (state, name)										-- local function to do testing of state values
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			if empty then return nil; end										-- empty deprecated parameters are treated as unknowns
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
		if 'tracked' == state then
			local base_name = name:gsub ('%d', '');								-- strip enumerators from parameter names that have them to get the base name
			utilities.add_prop_cat ('tracked-param', {base_name}, base_name);	-- add a properties category; &lt;base_name&gt; modifies &lt;key&gt;
			return true;
		end
		return nil;
	end		

	if name:find ('#') then														-- # is a cs1|2 reserved character so parameters with # not permitted
		return nil;
	end

	if utilities.in_array (cite_class, whitelist.preprint_template_list ) then	-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[name];
		if true == state_test (state, name) then return true; end

		state = whitelist.preprint_arguments[cite_class][name];					-- look in the parameter-list for the template identified by cite_class
		if true == state_test (state, name) then return true; end

																				-- limited enumerated parameters list
		enum_name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );										-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
		state = whitelist.limited_numbered_arguments[enum_name];
		if true == state_test (state, name) then return true; end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates

	if utilities.in_array (cite_class, whitelist.unique_param_template_list) then 	-- experiment for template-specific parameters for templates that accept parameters from the basic argument list
		state = whitelist.unique_arguments[cite_class][name];					-- look in the template-specific parameter-lists for the template identified by cite_class
		if true == state_test (state, name) then return true; end
	end																			-- if here, fall into general validation
		
	state = whitelist.basic_arguments[name];									-- all other templates; all normal parameters allowed
	if true == state_test (state, name) then return true; end

																				-- all enumerated parameters allowed
	enum_name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
	state = whitelist.numbered_arguments[enum_name];
	if true == state_test (state, name) then return true; end

	return false;																-- not supported because not found or name is set to nil
end


--[=[-------------------------&lt; I N T E R _ W I K I _ C H E C K &gt;----------------------------------------------

check &lt;value&gt; for inter-language interwiki-link markup.  &lt;prefix&gt; must be a MediaWiki-recognized language
code.  when these values have the form (without leading colon):
	[[&lt;prefix&gt;:link|label]] return label as plain-text
	[[&lt;prefix&gt;:link]] return &lt;prefix&gt;:link as plain-text

return value as is else

]=]

local function inter_wiki_check (parameter, value)
	local prefix = value:match ('%[%[(%a+):');									-- get an interwiki prefix if one exists
	local _;
	
	if prefix and cfg.inter_wiki_map[prefix:lower()] then						-- if prefix is in the map, needs preceding colon so
		utilities.set_message ('err_bad_paramlink', parameter);					-- emit an error message
		_, value, _ = utilities.is_wikilink (value);							-- extract label portion from wikilink
	end
	return value;
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe.  There are two tests made:
	{{cite ... |title=Title access-date=2016-03-17}}	-- the first parameter has a value and whitespace separates that value from the missing pipe parameter name
	{{cite ... |title=access-date=2016-03-17}}			-- the first parameter has no value (whitespace after the first = is trimmed by MediaWiki)
cs1|2 shares some parameter names with XML/HTML attributes: class=, title=, etc.  To prevent false positives XML/HTML
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (parameter, value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove XML/HTML tags because attributes: class=, title=, etc.

	capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then										-- if the capture is a valid parameter name
		utilities.set_message ('err_missing_pipe', parameter);
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ P U N C T &gt;--------------------------------------

look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_punc (param, value)
	if 'number' == type (param) then
		return;
	end
	
	param = param:gsub ('%d+', '#');											-- enumerated name-list mask params allow terminal punct; normalize 
	if cfg.punct_skip[param] then
		return;																	-- parameter name found in the skip table so done
	end
	
	if value:match ('[,;:]$') then
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
	if value:match ('^=') then													-- sometimes an extraneous '=' character appears ...
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ U R L &gt;------------------------------------------

look for extraneous url parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_url (url_param_t)
	local url_error_t = {};
	
	check_for_url (url_param_t, url_error_t);									-- extraneous url check
	if 0 ~= #url_error_t then													-- non-zero when there are errors
		table.sort (url_error_t);
		utilities.set_message ('err_param_has_ext_link', {utilities.make_sep_list (#url_error_t, url_error_t)});	-- add this error message
	end
end


--[[--------------------------&lt; C I T A T I O N &gt;--------------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

local function citation(frame)
	Frame = frame;																-- save a copy in case we need to display an error message in preview mode
	local sandbox = '/sandbox'													-- i18n: replace this rvalue with the name that your wiki uses to identify sandbox subpages
	is_sandbox = nil ~= string.find (frame:getTitle(), sandbox, 1, true);		-- is this invoke the sandbox module?
	sandbox = is_sandbox and sandbox or '';										-- use i18n sandbox to load sandbox modules when this module is the sandox; live modules else

	local pframe = frame:getParent()
	local styles;
	
	cfg = mw.loadData ('Module:Citation/CS1/Configuration' .. sandbox);			-- load sandbox versions of support modules when {{#invoke:Citation/CS1/sandbox|...}}; live modules else
	whitelist = mw.loadData ('Module:Citation/CS1/Whitelist' .. sandbox);
	utilities = require ('Module:Citation/CS1/Utilities' .. sandbox);
	validation = require ('Module:Citation/CS1/Date_validation' .. sandbox);
	identifiers = require ('Module:Citation/CS1/Identifiers' .. sandbox);
	metadata = require ('Module:Citation/CS1/COinS' .. sandbox);
	styles = 'Module:Citation/CS1' .. sandbox .. '/styles.css';

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the selected cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	is_preview_mode = not utilities.is_set (frame:preprocess ('{{REVISIONID}}'));

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text;															-- used as a flag

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do											-- get parameters from the {{#invoke}} frame
		config[k] = v;
	--	args[k] = v;															-- crude debug support that allows us to render a citation from module {{#invoke:}}; skips parameter validation; TODO: keep?
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	local empty_unknowns = {};													-- sequence table to hold empty unknown params for error message listing
	for k, v in pairs( pframe.args ) do											-- get parameters from the parent (template) frame
		v = mw.ustring.gsub (v, '^%s*(.-)%s*$', '%1');							-- trim leading/trailing whitespace; when v is only whitespace, becomes empty string
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				if type (k) ~= 'string' then									-- exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text = utilities.set_message ('err_text_ignored', {v});
					end
				elseif validate (k:lower(), config.CitationClass) then 
					error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, k:lower()});	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if is_sandbox then										-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no capture in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = utilities.substitute (param, capture);		-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, param});	-- set the suggestion error message
							else
								error_text = utilities.set_message ('err_parameter_ignored', {k});	-- suggested param not supported by this template
								v = '';											-- unset
							end
						end
					end
					if not utilities.is_set (error_text) then					-- couldn't match with a pattern, is there an explicit suggestion?						
						if (suggestions.suggestions[ k:lower() ] ~= nil) and validate (suggestions.suggestions[ k:lower() ], config.CitationClass) then
							utilities.set_message ('err_parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]});
						else
							utilities.set_message ('err_parameter_ignored', {k});
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
			end

			args[k] = v;														-- save this parameter and its value

		elseif not utilities.is_set (v) then									-- for empty parameters
			if not validate (k, config.CitationClass, true) then				-- is this empty parameter a valid parameter
				k = ('' == k) and '(empty string)' or k;						-- when k is empty string (or was space(s) trimmed to empty string), replace with descriptive text
				table.insert (empty_unknowns, utilities.wrap_style ('parameter', k));	-- format for error message and add to the list
			end
																				-- crude debug support that allows us to render a citation from module {{#invoke:}} TODO: keep?
	--	elseif args[k] ~= nil or (k == 'postscript') then						-- when args[k] has a value from {{#invoke}} frame (we don't normally do that)
	--		args[k] = v;														-- overwrite args[k] with empty string from pframe.args[k] (template frame); v is empty string here
		end																		-- not sure about the postscript bit; that gets handled in parameter validation; historical artifact?
	end	

	if 0 ~= #empty_unknowns then												-- create empty unknown error message
		utilities.set_message ('err_param_unknown_empty', {
			1 == #empty_unknowns and '' or 's',
			utilities.make_sep_list (#empty_unknowns, empty_unknowns)
			});
	end

	local url_param_t = {};

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);											-- look for invisible characters
		end
		has_extraneous_punc (k, v);												-- look for extraneous terminal punctuation in parameter values
		missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?
		args[k] = inter_wiki_check (k, v);										-- when language interwiki-linked parameter missing leading colon replace with wiki-link label

		if 'string' == type (k) and not cfg.url_skip[k] then					-- when parameter k is not positional and not in url skip table
			url_param_t[k] = v;													-- make a parameter/value list for extraneous url check
		end
	end

	has_extraneous_url (url_param_t);											-- look for url in parameter values where a url does not belong

	return table.concat ({
		frame:extensionTag ('templatestyles', '', {src=styles}),
		citation0( config, args)
	});
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {citation = citation};</text>
      <sha1>ap25rq0kh3819w7lon63qbjh3bjokuz</sha1>
    </revision>
    <revision>
      <id>4749</id>
      <parentid>4748</parentid>
      <timestamp>2022-10-23T04:17:58Z</timestamp>
      <contributor>
        <username>Legoktm</username>
        <id>818</id>
      </contributor>
      <comment>Replace [[Module:No globals]] with require( &quot;strict&quot; )</comment>
      <origin>4749</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="206373" sha1="5n16iqneaigpy2t8yngx92i9b4sg6ua" xml:space="preserve">require ('strict');

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------

each of these counts against the Lua upvalue limit

]]

local validation;																-- functions in Module:Citation/CS1/Date_validation

local utilities;																-- functions in Module:Citation/CS1/Utilities
local z ={};																	-- table of tables in Module:Citation/CS1/Utilities

local identifiers;																-- functions and tables in Module:Citation/CS1/Identifiers
local metadata;																	-- functions in Module:Citation/CS1/COinS
local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;---------------

declare variables here that have page-wide scope that are not brought in from
other modules; that are created here and used here

]]

local added_deprecated_cat;														-- Boolean flag so that the category is added only once
local added_vanc_errs;															-- Boolean flag so we only emit one Vancouver error / category
local added_generic_name_errs;													-- Boolean flag so we only emit one generic name error / category and stop testing names once an error is encountered
local Frame;																	-- holds the module's frame table
local is_preview_mode;															-- true when article is in preview mode; false when using 'Preview page with this template' (previewing the module)
local is_sandbox;																-- true when using sandbox modules to render citation


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if utilities.is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a Boolean declared in page scope variables above

]]

local function add_vanc_error (source, position)
	if added_vanc_errs then return end
		
	added_vanc_errs = true;														-- note that we've added this category
	utilities.set_message ('err_vancouver', {source, position});
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a URI scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of TLDs: https://www.iana.org/domains/root/db

RFC 952 (modified by RFC 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the TLD.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a URL with a scheme) will be stripped
here.  Perhaps not necessary but retained in case it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ASCII characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the TLD) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and TLD or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%w]') then											-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at Wikisource
		return false;
	end

	local patterns = {															-- patterns that look like URLs
		'%f[%w][%w][%w%-]+[%w]%.%a%a+$',										-- three or more character hostname.hostname or hostname.tld
		'%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$',									-- internationalized domain name with ACE prefix
		'%f[%a][qxz]%.com$',													-- assigned one character .com hostname (x.com times out 2015-12-10)
		'%f[%a][iq]%.net$',														-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		'%f[%w][%w]%.%a%a$',													-- one character hostname and ccTLD (2 chars)
		'%f[%w][%w][%w]%.%a%a+$',												-- two character hostname and TLD
		'^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?',								-- IPv4 address
		}

	for _, pattern in ipairs (patterns) do										-- loop through the patterns list
		if domain:match (pattern) then
			return true;														-- if a match then we think that this thing that purports to be a URL is a URL
		end
	end

	for _, d in ipairs ({'cash', 'company', 'today', 'org'}) do					-- look for single letter second level domain names for these top level domains
		if domain:match ('%f[%w][%w]%.' .. d) then
			return true
		end
	end
	return false;																-- no matches, we don't know what this thing is
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a URL appear to be a valid URL; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if utilities.is_set (scheme) then											-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when URL is protocol-relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a URL into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following TLD) (if any) and any path(/), query(?) or fragment(#).

If protocol-relative URL, return nil scheme and domain else return nil for both scheme and domain.

When not protocol-relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Any URL that does not have news: scheme must have authority indicator (//).  TODO: are there other common schemes
like news: that don't use authority indicator?

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol-relative URL
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		if utilities.is_set (authority) then
			authority = authority:gsub ('//', '', 1);							-- replace place 1 pair of '/' with nothing;
			if utilities.is_set(authority) then									-- if anything left (1 or 3+ '/' where authority should be) then
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		else
			if not scheme:match ('^news:') then									-- except for news:..., MediaWiki won't link URLs that do not have authority indicator; TODO: a better way to do this test?
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link=, etc. for properly formatted content: no wikilinks, no URLs

Link parameters are to hold the title of a Wikipedia article, so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki URLs and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid URL (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid URL (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from URL; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid URL
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wiki-linked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

check &lt;link&gt; for inter-language interwiki-link prefix.  prefix must be a MediaWiki-recognized language
code and must begin with a colon.

]]

local function link_title_ok (link, lorig, title, torig)
local orig;
	if utilities.is_set (link) then 											-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		elseif link:match ('^%a+:') then										-- if the link is what looks like an interwiki
			local prefix = link:match ('^(%a+):'):lower();						-- get the interwiki prefix

			if cfg.inter_wiki_map[prefix] then									-- if prefix is in the map, must have preceding colon
				orig = lorig;													-- flag as error
			end
		end
	end

	if utilities.is_set (orig) then
		link = '';																-- unset
		utilities.set_message ('err_bad_paramlink', orig);						-- URL or wikilink in |title= with |title-link=;
	end
	
	return link;																-- link if ok, empty string else
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the URL into scheme and domain
portions, or for protocol-relative (//example.com) URLs, just the domain.  Use is_url() to validate the two
portions of the URL.  If both are valid, or for protocol-relative if domain is valid, return true, else false.

Because it is different from a standard URL, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper URL
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from URL;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a URL.  The test will also find external wikilinks
that use protocol-relative URLs. Also finds bare URLs.

The frontier pattern prevents a match on interwiki-links which are similar to scheme:path URLs.  The tests that
find bracketed URLs are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext. wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol-relative ext. wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare URL with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol-relative bare URL: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a URL
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list, error_list)
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a URL add an error message
			table.insert (error_list, utilities.wrap_style ('parameter', k));
		end
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		utilities.set_message ('err_wikilink_in_url', {});
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link (URL, label, source, access)
	local err_msg = '';
	local domain;
	local path;
	local base_url;

	if not utilities.is_set (label) then
		label = URL;
		if utilities.is_set (source) then
			utilities.set_message ('err_bare_url_missing_title', {utilities.wrap_style ('parameter', source)});
		else
			error (cfg.messages[&quot;bare_url_no_origin&quot;]);
		end			
	end
	if not check_url (URL) then
		utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)});
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the URL into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['['] = '%5b', [']'] = '%5d'});			-- replace '[' and ']' with their percent-encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat ({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wiki-markup URL

	if utilities.is_set (access) then											-- access level (subscription, registration, limited)
		base_url = utilities.substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end

	return base_url;
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a Boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		utilities.set_message ('err_deprecated_params', {name});				-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wiki-markup) are not kerned.

Replaces Unicode quote marks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc.; not for book titles.

]=]

local function kern_quotes (str)
	local cap = '';
	local wl_type, label, link;

	wl_type, label, link = utilities.is_wikilink (str);							-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-left'], str);
			str = utilities.substitute (cfg.presentation['kern-right'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = utilities.substitute (cfg.presentation['kern-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label = mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label = mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap = mw.ustring.match (label, &quot;^([\&quot;\'][^\'].+)&quot;);						-- match leading double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-left'], cap);
		end
	
		cap = mw.ustring.match (label, &quot;^(.+[^\'][\&quot;\'])$&quot;)						-- match trailing double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-right'], cap);
		end
		
		if 2 == wl_type then
			str = utilities.make_wikilink (link, label);						-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin-based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate RTL languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO 639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO 639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title=, |script-chapter=, |script-&lt;periodical&gt;=

]]

local function format_script_value (script_value, script_param)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%l?%s*:') then									-- if first 3 or 4 non-space characters are script language prefix
		lang = script_value:match('^(%l%l%l?)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not utilities.is_set (lang) then
			utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['missing title part']});		-- prefix without 'title'; add error message
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_code_remap[lang] or mw.language.fetchLanguageName( lang, cfg.this_wiki_code );	-- get language name so that we can use it to categorize
		if utilities.is_set (name) then											-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l+%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if utilities.in_array (lang, cfg.script_lang_codes) then
				utilities.add_prop_cat ('script', {name, lang})
			else
				utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['unknown language code']});	-- unknown script-language; add error message
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['invalid language code']});		-- invalid language code; add error message
			lang = '';															-- invalid so set lang to empty string
		end
	else
		utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['missing prefix']});				-- no language code prefix; add error message
	end
	script_value = utilities.substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is RTL

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script
value has been wrapped in &lt;bdi&gt; tags.

]]

local function script_concatenate (title, script, script_param)
	if utilities.is_set (script) then
		script = format_script_value (script, script_param);					-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; returns empty string on error
		if utilities.is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not utilities.is_set ( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return utilities.substitute ( msg, str );								-- including template text
	else
		return utilities.substitute ( cfg.messages[key], str );
	end		
end


--[[----------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;-------------------

Makes a Wikisource URL from Wikisource interwiki-link.  Returns the URL and appropriate
label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;
	local wikisource_prefix = table.concat ({'https://', cfg.this_wiki_code, '.wikisource.org/wiki/'});

	wl_type, D, L = utilities.is_wikilink (str);								-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 1 == wl_type then													-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end

	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable URL
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent-encoding of fragment marker
	end

	return ws_url, ws_label, L or D;											-- return proper URL or nil and a label or nil
end


--[[----------------&lt; F O R M A T _ P E R I O D I C A L &gt;-----------------------

Format the three periodical parameters: |script-&lt;periodical&gt;=, |&lt;periodical&gt;=,
and |trans-&lt;periodical&gt;= into a single Periodical meta-parameter.

]]

local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)

	if not utilities.is_set (periodical) then
		periodical = '';														-- to be safe for concatenation
	else
		periodical = utilities.wrap_style ('italic-title', periodical);			-- style 
	end

	periodical = script_concatenate (periodical, script_periodical, script_periodical_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (trans_periodical) then
		trans_periodical = utilities.wrap_style ('trans-italic-title', trans_periodical);
		if utilities.is_set (periodical) then
			periodical = periodical .. ' ' .. trans_periodical;
		else																	-- here when trans-periodical without periodical or script-periodical
			periodical = trans_periodical;
			utilities.set_message ('err_trans_missing_title', {'periodical'});
		end
	end

	return periodical;
end


--[[------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;---------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=,
and |chapter-url= into a single chapter meta- parameter (chapter_url_source used
for error messages).

]]

local function format_chapter_title (script_chapter, script_chapter_source, chapter, chapter_source, trans_chapter, trans_chapter_source, chapter_url, chapter_url_source, no_quotes, access)
	local ws_url, ws_label, L = wikisource_url_make (chapter);					-- make a wikisource URL and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', ' ');									-- replace underscore separators with space characters
		chapter = ws_label;
	end

	if not utilities.is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from module provided quote marks
			chapter = utilities.wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, script_chapter, script_chapter_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (chapter_url) then
		chapter = external_link (chapter_url, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');	-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if utilities.is_set (trans_chapter) then
		trans_chapter = utilities.wrap_style ('trans-quoted-title', trans_chapter);
		if utilities.is_set (chapter) then
			chapter = chapter .. ' ' .. trans_chapter;
		else																	-- here when trans_chapter without chapter or script-chapter
			chapter = trans_chapter;
			chapter_source = trans_chapter_source:match ('trans%-?(.+)');		-- when no chapter, get matching name from trans-&lt;param&gt;
			utilities.set_message ('err_trans_missing_title', {chapter_source});
		end
	end

	return chapter;
end


--[[----------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;-------------------

This function searches a parameter's value for non-printable or invisible characters.
The search stops at the first match.

This function will detect the visible replacement character when it is part of the Wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers
(gallery, math, pre, ref) and identifies them with a slightly different error message.
See also coins_cleanup().

Output of this function is an error message that identifies the character or the
Unicode group, or the stripmarker that was detected along with its position (or,
for multi-byte characters, the position of its first byte) in the parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local stripmarker;															-- boolean set true when a stripmarker is found

	capture = string.match (v, '[%w%p ]*');										-- test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no Unicode characters
		return;
	end

	for _, invisible_char in ipairs (cfg.invisible_chars) do
		local char_name = invisible_char[1];									-- the character or group name
		local pattern = invisible_char[2];										-- the pattern used to find it
		position, _, capture = mw.ustring.find (v, pattern);					-- see if the parameter value contains characters that match the pattern
		
		if position and (cfg.invisible_defs.zwj == capture) then				-- if we found a zero-width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- it's ok if one of the Indic scripts
				position = nil;													-- unset position
			elseif cfg.emoji[mw.ustring.codepoint (v, position+1)] then			-- is zwj followed by a character listed in emoji{}?
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and utilities.in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and cfg.invisible_defs.del == capture then	-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture and not (cfg.invisible_defs.del == capture or cfg.invisible_defs.zwj == capture) then
					err_msg = capture .. ' ' .. char_name;
				else
					err_msg = char_name .. ' ' .. 'character';
				end

				utilities.set_message ('err_invisible_char', {err_msg, utilities.wrap_style ('parameter', param), position});	-- add error message
				return;															-- and done with this parameter
			end
		end
	end
end


--[[-------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------

Argument wrapper.  This function provides support for argument mapping defined
in the configuration file so that multiple names can be transparently aliased to
single internal variable.

]]

local function argument_wrapper ( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function ( self, k )
			local dummy = self[k];												-- force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = utilities.select_one ( args, list, 'err_redundant_parameters' );
				if origin[k] == nil then
					origin[k] = '';												-- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] .. ': ' .. k);
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;-------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.
When date is DD MMMM YYYY or is MMMM DD, YYYY then wrap in nowrap span:
&lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap = '';
	local cap2 = '';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = utilities.substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = utilities.substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;---------------------

This function sets default title types (equivalent to the citation including
|type=&lt;default value&gt;) for those templates that have defaults. Also handles the
special case where it is desirable to omit the title type from the rendered citation
(|type=none).

]]

local function set_titletype (cite_class, title_type)
	if utilities.is_set (title_type) then
		if 'none' == cfg.keywords_xlate[title_type] then
			title_type = '';													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; S A F E _ J O I N &gt;-----------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'duplicate character'
		if 1 == #duplicate_char then											-- for single byte ASCII characters use the string library functions
			f.gsub = string.gsub
			f.match = string.match
			f.sub = string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub = mw.ustring.gsub
			f.match = mw.ustring.match
			f.sub = mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1, 1) == '&lt;' then										-- special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove HTML markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1, 1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc.?
				trim = false;
				end_chr = f.sub(str, -1, -1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr .. &quot;)&quot;				-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1, -2);									-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;''&quot; then		-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5, -1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;]]&quot; then		-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3, -1) == duplicate_char .. '&quot;]' then	-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2, -1) == duplicate_char .. &quot;]&quot; then	-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2, -1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1, -3);								-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains HTML markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows HTML markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value; 												-- add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;-----------------------------

returns true if suffix is properly formed Jr, Sr, or ordinal in the range 1–9.
Puncutation not allowed.

]]

local function is_suffix (suffix)
	if utilities.in_array (suffix, {'Jr', 'Sr', 'Jnr', 'Snr', '1st', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;-------------------

For Vancouver style, author/editor names are supposed to be rendered in Latin
(read ASCII) characters.  When a name uses characters that contain diacritical
marks, those characters are to be converted to the corresponding Latin
character. When a name is written using a non-Latin alphabet or logogram, that
name is to be transliterated into Latin characters. The module doesn't do this
so editors may/must.

This test allows |first= and |last= names to contain any of the letters defined
in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes.
	(http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;)
	or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written outside of the code editor and pasted here because the code editor
gets confused between character insertion point and cursor position. The test has
been rewritten to use decimal character escape sequence for the individual bytes
of the Unicode characters so that it is not necessary to use an external editor
to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first, suffix, position)
	if not suffix then
		if first:find ('[,%s]') then											-- when there is a space or comma, might be first name/initials + generational suffix
			first = first:match ('(.-)[,%s]+');									-- get name/initials
			suffix = first:match ('[,%s]+(.+)$');								-- get generational suffix
		end
	end
	if utilities.is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error (cfg.err_msg_supl.suffix, position);
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error (cfg.err_msg_supl['non-Latin char'], position);
			return false;														-- not a string of Latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-style=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period.
See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc.) to be rendered
as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format
because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the
Unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first, position)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just initials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error (cfg.err_msg_supl.suffix, position);			-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word

	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i], 1, 1));			-- insert the initial at end of initials table
		end
		i = i + 1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; L I S T _ P E O P L E &gt;--------------------------

Formats a list of people (authors, contributors, editors, interviewers, translators) 

names in the list will be linked when
	|&lt;name&gt;-link= has a value
	|&lt;name&gt;-mask- does NOT have a value; masked names are presumed to have been
		rendered previously so should have been linked there

when |&lt;name&gt;-mask=0, the associated name is not rendered

]]

local function list_people (control, people, etal)
	local sep;
	local namesep;
	local format = control.format;
	local maximum = control.maximum;
	local name_list = {};

	if 'vanc' == format then													-- Vancouver-like name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between names is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between names is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub (-1, -1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if utilities.is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end		-- returned 0 is for EditorCount; not used for other names
	
	for i, person in ipairs (people) do
		if utilities.is_set (person.last) then
			local mask = person.mask;
			local one;
			local sep_one = sep;

			if utilities.is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			end
			
			if mask then
				local n = tonumber (mask);										-- convert to a number if it can be converted; nil else
				if n then
					one = 0 ~= n and string.rep(&quot;&amp;mdash;&quot;, n) or nil;			-- make a string of (n &gt; 0) mdashes, nil else, to replace name
					person.link = nil;											-- don't create link to name if name is replaces with mdash string or has been set nil
				else
					one = mask;													-- replace name with mask text (must include name-list separator)
					sep_one = &quot; &quot;;												-- modify name-list separator
				end
			else
				one = person.last;												-- get surname
				local first = person.first										-- get given name
				if utilities.is_set (first) then
					if (&quot;vanc&quot; == format) then									-- if Vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first, nil, i) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials (first, i);				-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
			end
			if utilities.is_set (person.link) then
				one = utilities.make_wikilink (person.link, one);				-- link author/editor
			end
			if one then															-- if &lt;one&gt; has a value (name, mdash replacement, or mask text replacement)
				table.insert (name_list, one);									-- add it to the list of names
				table.insert (name_list, sep_one);								-- add the proper name-list separator
			end
		end
	end

	local count = #name_list / 2;												-- (number of names + number of separators) divided by 2
	if 0 &lt; count then 
		if 1 &lt; count and not etal then
			if 'amp' == format then
				name_list[#name_list-2] = &quot; &amp; &quot;;								-- replace last separator with ampersand text
			elseif 'and' == format then
				if 2 == count then
					name_list[#name_list-2] = cfg.presentation.sep_nl_and;		-- replace last separator with 'and' text
				else
					name_list[#name_list-2] = cfg.presentation.sep_nl_end;		-- replace last separator with '(sep) and' text
				end
			end
		end
		name_list[#name_list] = nil;											-- erase the last separator
	end

	local result = table.concat (name_list);									-- construct list
	if etal and utilities.is_set (result) then									-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've got a last-first list and etal so add et al.
	end
	
	return result, count;														-- return name-list string and count of number of names (count used for editor names only)
end


--[[--------------------&lt; M A K E _ C I T E R E F _ I D &gt;-----------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise
returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that
order.  year is Year or anchor_year.

]]

local function make_citeref_id (namelist, year)
	local names={};							-- a table for the one to four names and year
	for i,v in ipairs (namelist) do			-- loop through the list and take up to the first four last names
		names[i] = v.last
		if i == 4 then break end			-- if four then done
	end
	table.insert (names, year);				-- add the year at the end
	local id = table.concat(names);			-- concatenate names and year for CITEREF id
	if utilities.is_set (id) then			-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;				-- add the CITEREF portion
	else
		return '';							-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; C I T E _ C L A S S _A T T R I B U T E _M A K E &gt;------------------------------

construct &lt;cite&gt; tag class attribute for this citation.

&lt;cite_class&gt; – config.CitationClass from calling template
&lt;mode&gt; – value from |mode= parameter

]]

local function cite_class_attribute_make (cite_class, mode)
	local class_t = {};
	table.insert (class_t, 'citation');											-- required for blue highlight
	if 'citation' ~= cite_class then
		table.insert (class_t, cite_class);										-- identify this template for user css
		table.insert (class_t, utilities.is_set (mode) and mode or 'cs1');		-- identify the citation style for user css or javascript
	else
		table.insert (class_t, utilities.is_set (mode) and mode or 'cs2');		-- identify the citation style for user css or javascript
	end
	for _, prop_key in ipairs (z.prop_keys_t) do
		table.insert (class_t, prop_key);										-- identify various properties for user css or javascript
	end

	return table.concat (class_t, ' ');											-- make a big string and done
end


--[[---------------------&lt; N A M E _ H A S _ E T A L &gt;--------------------------

Evaluates the content of name parameters (author, editor, etc.) for variations on
the theme of et al.  If found, the et al. is removed, a flag is set to true and
the function returns the modified name and the flag.

This function never sets the flag to false but returns its previous state because
it may have been set by previous passes through this function or by the associated
|display-&lt;names&gt;=etal parameter

]]

local function name_has_etal (name, etal, nocat, param)

	if utilities.is_set (name) then												-- name can be nil in which case just return
		local patterns = cfg.et_al_patterns; 									-- get patterns from configuration
		
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns
			if name:match (pattern) then										-- if this 'et al' pattern is found in name
				name = name:gsub (pattern, '');									-- remove the offending text
				etal = true;													-- set flag (may have been set previously here or by |display-&lt;names&gt;=etal)
				if not nocat then												-- no categorization for |vauthors=
					utilities.set_message ('err_etal', {param});				-- and set an error if not added
				end
			end
		end
	end

	return name, etal;
end


--[[---------------------&lt; N A M E _ I S _ N U M E R I C &gt;----------------------

Add maint cat when name parameter value does not contain letters.  Does not catch
mixed alphanumeric names so |last=A. Green (1922-1987) does not get caught in the
current version of this test but |first=(1888) is caught.

returns nothing

]]

local function name_is_numeric (name, list_name)
	if utilities.is_set (name) then
		if mw.ustring.match (name, '^[%A]+$') then								-- when name does not contain any letters
			utilities.set_message ('maint_numeric_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
		end
	end
end


--[[-----------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;------------------

Evaluates the content of last/surname (authors etc.) parameters for multiple names.
Multiple names are indicated if there is more than one comma or any &quot;unescaped&quot;
semicolons. Escaped semicolons are ones used as part of selected HTML entities.
If the condition is met, the function adds the multiple name maintenance category.

returns nothing

]]

local function name_has_mult_names (name, list_name)
	local _, commas, semicolons, nbsps;
	if utilities.is_set (name) then
		_, commas = name:gsub (',', '');										-- count the number of commas
		_, semicolons = name:gsub (';', '');									-- count the number of semicolons
		-- nbsps probably should be its own separate count rather than merged in
		-- some way with semicolons because Lua patterns do not support the
		-- grouping operator that regex does, which means there is no way to add
		-- more entities to escape except by adding more counts with the new
		-- entities
		_, nbsps = name:gsub ('&amp;nbsp;','');										-- count nbsps
		
		-- There is exactly 1 semicolon per &amp;nbsp; entity, so subtract nbsps
		-- from semicolons to 'escape' them. If additional entities are added,
		-- they also can be subtracted.
		if 1 &lt; commas or 0 &lt; (semicolons - nbsps) then
			utilities.set_message ('maint_mult_names', cfg.special_case_translation [list_name]);	-- add a maint message
		end
	end
end


--[=[-------------------------&lt; I S _ G E N E R I C &gt;----------------------------------------------------------

Compares values assigned to various parameters according to the string provided as &lt;item&gt; in the function call.
&lt;item&gt; can have on of two values:
	'generic_names' – for name-holding parameters: |last=, |first=, |editor-last=, etc
	'generic_titles' – for |title=

There are two types of generic tests.  The 'accept' tests look for a pattern that should not be rejected by the
'reject' test.  For example,
	|author=[[John Smith (author)|Smith, John]]
would be rejected by the 'author' reject test.  But piped wikilinks with 'author' disambiguation should not be
rejected so the 'accept' test prevents that from happening.  Accept tests are always performed before reject
tests.

Each of the 'accept' and 'reject' sequence tables hold tables for en.wiki (['en']) and local.wiki (['local'])
that each can hold a test sequence table  The sequence table holds, at index [1], a test pattern, and, at index
[2], a boolean control value.  The control value tells string.find() or mw.ustring.find() to do plain-text search (true)
or a pattern search (false).  The intent of all this complexity is to make these searches as fast as possible so
that we don't run out of processing time on very large articles.

Returns
	true when a reject test finds the pattern or string
	false when an accept test finds the pattern or string
	nil else

]=]

local function is_generic (item, value, wiki)
	local test_val;
	local str_lower = {															-- use string.lower() for en.wiki (['en']) and use mw.ustring.lower() or local.wiki (['local'])
		['en'] = string.lower,
		['local'] = mw.ustring.lower,
		}
	local str_find = {															-- use string.find() for en.wiki (['en']) and use mw.ustring.find() or local.wiki (['local'])
		['en'] = string.find,
		['local'] = mw.ustring.find,
		}

	local function test (val, test_t, wiki)										-- local function to do the testing; &lt;wiki&gt; selects lower() and find() functions
		val = test_t[2] and str_lower[wiki](value) or val;						-- when &lt;test_t[2]&gt; set to 'true', plaintext search using lowercase value
		return str_find[wiki] (val, test_t[1], 1, test_t[2]);					-- return nil when not found or matched
	end
		
	local test_types_t = {'accept', 'reject'};									-- test accept patterns first, then reject patterns
	local wikis_t = {'en', 'local'};											-- do tests for each of these keys; en.wiki first, local.wiki second

	for _, test_type in ipairs (test_types_t) do								-- for each test type
		for _, generic_value in pairs (cfg.special_case_translation[item][test_type]) do	-- spin through the list of generic value fragments to accept or reject
			for _, wiki in ipairs (wikis_t) do
				if generic_value[wiki] then
					if test (value, generic_value[wiki], wiki) then				-- go do the test
						return ('reject' == test_type);							-- param value rejected, return true; false else
					end
				end
			end
		end
	end
end


--[[--------------------------&lt; N A M E _ I S _ G E N E R I C &gt;------------------------------------------------

calls is_generic() to determine if &lt;name&gt; is a 'generic name' listed in cfg.generic_names; &lt;name_alias&gt; is the
parameter name used in error messaging

]]

local function name_is_generic (name, name_alias)
	if not added_generic_name_errs  and is_generic ('generic_names', name) then
		utilities.set_message ('err_generic_name', name_alias);					-- set an error message
		added_generic_name_errs = true;
	end
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------

This function calls various name checking functions used to validate the content of the various name-holding parameters.

]]

local function name_checks (last, first, list_name, last_alias, first_alias)
	local accept_name;

	if utilities.is_set (last) then
		last, accept_name = utilities.has_accept_as_written (last);				-- remove accept-this-as-written markup when it wraps all of &lt;last&gt;

		if not accept_name then													-- &lt;last&gt; not wrapped in accept-as-written markup
			name_has_mult_names (last, list_name);								-- check for multiple names in the parameter (last only)
			name_is_numeric (last, list_name);									-- check for names that are composed of digits and punctuation
			name_is_generic (last, last_alias);									-- check for names found in the generic names list
		end
	end

	if utilities.is_set (first) then
		first, accept_name = utilities.has_accept_as_written (first);			-- remove accept-this-as-written markup when it wraps all of &lt;first&gt;

		if not accept_name then													-- &lt;first&gt; not wrapped in accept-as-written markup
			name_is_numeric (first, list_name);									-- check for names that are composed of digits and punctuation
			name_is_generic (first, first_alias);								-- check for names found in the generic names list
		end
		local wl_type, D = utilities.is_wikilink (first);
		if 0 ~= wl_type then
			first = D;
			utilities.set_message ('err_bad_paramlink', first_alias);
		end
	end

	return last, first;															-- done
end


--[[----------------------&lt; E X T R A C T _ N A M E S &gt;-------------------------

Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters
(or their aliases), and their matching link and mask parameters. Stops searching
when both |lastn= and |firstn= are not found in args after two sequential attempts:
found |last1=, |last2=, and |last3= but doesn't find |last4= and |last5= then the
search is done.

This function emits an error message when there is a |firstn= without a matching
|lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not
required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.'
is stripped from the parameter and a flag (etal) returned that will cause list_people()
to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps
'et al.' out of the template's metadata.  When this occurs, an error is emitted.

]]

local function extract_names(args, list_name)
	local names = {};															-- table of names
	local last;																	-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;																-- loop counter/indexer
	local n = 1;																-- output table indexer
	local count = 0;															-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal = false;															-- return value set to true when we find some form of et al. in an author parameter

	local last_alias, first_alias, link_alias;									-- selected parameter aliases used in error messaging
	while true do
		last, last_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'err_redundant_parameters', i );		-- search through args for name components beginning at 1
		first, first_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'err_redundant_parameters', i );
		link, link_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i );
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );

		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.
		last, first = name_checks (last, first, list_name, last_alias, first_alias);						-- multiple names, extraneous annotation, etc. checks

		if first and not last then												-- if there is a firstn without a matching lastn
			local alias = first_alias:find ('given', 1, true) and 'given' or 'first';	-- get first or given form of the alias
			utilities.set_message ('err_first_missing_last', {
				first_alias,													-- param name of alias missing its mate
				first_alias:gsub (alias, {['first'] = 'last', ['given'] = 'surname'}),	-- make param name appropriate to the alias form
				});																-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			local result;
			link = link_title_ok (link, link_alias, last, last_alias);			-- check for improper wiki-markup

			if first then
				link = link_title_ok (link, link_alias, first, first_alias);	-- check for improper wiki-markup
			end

			names[n] = {last = last, first = first, link = link, mask = mask, corporate = false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				utilities.set_message ('err_missing_name', {list_name:match (&quot;(%w+)List&quot;):lower(), i - 1});	-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names and the etal flag
end


--[[--------------------------&lt; N A M E _ T A G _ G E T &gt;------------------------------------------------------

attempt to decode |language=&lt;lang_param&gt; and return language name and matching tag; nil else.

This function looks for:
	&lt;lang_param&gt; as a tag in cfg.lang_code_remap{}
	&lt;lang_param&gt; as a name in cfg.lang_name_remap{}
	
	&lt;lang_param&gt; as a name in cfg.mw_languages_by_name_t
	&lt;lang_param&gt; as a tag in cfg.mw_languages_by_tag_t
when those fail, presume that &lt;lang_param&gt; is an IETF-like tag that MediaWiki does not recognize.  Strip all
script, region, variant, whatever subtags from &lt;lang_param&gt; to leave just a two or three character language tag
and look for the new &lt;lang_param&gt; in cfg.mw_languages_by_tag_t{}

on success, returns name (in properly capitalized form) and matching tag (in lowercase); on failure returns nil

]]

local function name_tag_get (lang_param)
	local lang_param_lc = mw.ustring.lower (lang_param);						-- use lowercase as an index into the various tables
	local name;
	local tag;

	name = cfg.lang_code_remap[lang_param_lc];									-- assume &lt;lang_param_lc&gt; is a tag; attempt to get remapped language name 
	if name then																-- when &lt;name&gt;, &lt;lang_param&gt; is a tag for a remapped language name
		return name, lang_param_lc;												-- so return &lt;name&gt; from remap and &lt;lang_param_lc&gt;
	end

	tag = lang_param_lc:match ('^(%a%a%a?)%-.*');								-- still assuming that &lt;lang_param_lc&gt; is a tag; strip script, region, variant subtags
	name = cfg.lang_code_remap[tag];											-- attempt to get remapped language name with language subtag only
	if name then																-- when &lt;name&gt;, &lt;tag&gt; is a tag for a remapped language name
		return name, tag;														-- so return &lt;name&gt; from remap and &lt;tag&gt;
	end

	if cfg.lang_name_remap[lang_param_lc] then									-- not a tag, assume &lt;lang_param_lc&gt; is a name; attempt to get remapped language tag 
		return cfg.lang_name_remap[lang_param_lc][1], cfg.lang_name_remap[lang_param_lc][2];	-- for this &lt;lang_param_lc&gt;, return a (possibly) new name and appropriate tag
	end

	tag = cfg.mw_languages_by_name_t[lang_param_lc];							-- assume that &lt;lang_param_lc&gt; is a language name; attempt to get its matching tag
	
	if tag then
		return cfg.mw_languages_by_tag_t[tag], tag;								-- &lt;lang_param_lc&gt; is a name so return the name from the table and &lt;tag&gt;
	end

	name = cfg.mw_languages_by_tag_t[lang_param_lc];							-- assume that &lt;lang_param_lc&gt; is a tag; attempt to get its matching language name
	
	if name then
		return name, lang_param_lc;												-- &lt;lang_param_lc&gt; is a tag so return it and &lt;name&gt;
	end
	
	tag = lang_param_lc:match ('^(%a%a%a?)%-.*');								-- is &lt;lang_param_lc&gt; an IETF-like tag that MediaWiki doesn't recognize? &lt;tag&gt; gets the language subtag; nil else

	if tag then
		name = cfg.mw_languages_by_tag_t[tag];									-- attempt to get a language name using the shortened &lt;tag&gt;
		if name then
			return name, tag;													-- &lt;lang_param_lc&gt; is an unrecognized IETF-like tag so return &lt;name&gt; and language subtag
		end
	end
end


--[[-------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code
is recognized by MediaWiki, use the returned name; if not, then use the value that
was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is
assigned to the category for that code: Category:Norwegian-language sources (no).
For valid three-character code languages, the page is assigned to the single category
for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does
not recognize three-character equivalents of two-character codes: code 'ar' is
recognized but code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th
where the language names or codes are separated from each other by commas with
optional space characters.

]]

local function language_parameter (lang)
	local tag;																	-- some form of IETF-like language tag; language subtag with optional region, sript, vatiant, etc subtags
	local lang_subtag;															-- ve populates |language= with mostly unecessary region subtags the MediaWiki does not recognize; this is the base language subtag
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_t = {};															-- table made from the value assigned to |language=

	local this_wiki_name = mw.language.fetchLanguageName (cfg.this_wiki_code, cfg.this_wiki_code);	-- get this wiki's language name

	names_t = mw.text.split (lang, '%s*,%s*');									-- names should be a comma separated list

	for _, lang in ipairs (names_t) do											-- reuse lang here because we don't yet know if lang is a language name or a language tag
		name, tag = name_tag_get (lang);										-- attempt to get name/tag pair for &lt;lang&gt;; &lt;name&gt; has proper capitalization; &lt;tag&gt; is lowercase

		if utilities.is_set (tag) then
			lang_subtag = tag:gsub ('^(%a%a%a?)%-.*', '%1');					-- for categorization, strip any IETF-like tags from language tag

			if cfg.this_wiki_code ~= lang_subtag then							-- when the language is not the same as this wiki's language
				if 2 == lang_subtag:len() then									-- and is a two-character tag
--					utilities.add_prop_cat ('foreign-lang-source', {name, lang_subtag}, lang_subtag);		-- categorize it; tag appended to allow for multiple language categorization
					utilities.add_prop_cat ('foreign-lang-source', {name, tag}, lang_subtag);		-- categorize it; tag appended to allow for multiple language categorization
				else															-- or is a recognized language (but has a three-character tag)
					utilities.add_prop_cat ('foreign-lang-source-2', {lang_subtag}, lang_subtag);			-- categorize it differently TODO: support multiple three-character tag categories per cs1|2 template?
				end
			elseif cfg.local_lang_cat_enable then								-- when the language and this wiki's language are the same and categorization is enabled
				utilities.add_prop_cat ('local-lang-source', {name, lang_subtag});		-- categorize it
			end
		else
			name = lang;														-- return whatever &lt;lang&gt; has so that we show something
			utilities.set_message ('maint_unknown_lang');						-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
 
	name = utilities.make_sep_list (#language_list, language_list);
	if (1 == #language_list) and (lang_subtag == cfg.this_wiki_code) then		-- when only one language, find lang name in this wiki lang name; for |language=en-us, 'English' in 'American English'
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[-----------------------&lt; S E T _ C S _ S T Y L E &gt;--------------------------

Gets the default CS style configuration for the given mode.
Returns default separator and either postscript as passed in or the default.
In CS1, the default postscript and separator are '.'.
In CS2, the default postscript is the empty string and the default separator is ','.

]]

local function set_cs_style (postscript, mode)
	if utilities.is_set(postscript) then
		-- emit a maintenance message if user postscript is the default cs1 postscript
		-- we catch the opposite case for cs2 in set_style
		if mode == 'cs1' and postscript == cfg.presentation['ps_' .. mode] then
			utilities.set_message ('maint_postscript');
		end
	else
		postscript = cfg.presentation['ps_' .. mode];
	end
	return cfg.presentation['sep_' .. mode], postscript;
end

--[[--------------------------&lt; S E T _ S T Y L E &gt;-----------------------------

Sets the separator and postscript styles. Checks the |mode= first and the
#invoke CitationClass second. Removes the postscript if postscript == none.

]]

local function set_style (mode, postscript, cite_class)
	local sep;
	if 'cs2' == mode then
		sep, postscript = set_cs_style (postscript, 'cs2');
	elseif 'cs1' == mode then
		sep, postscript = set_cs_style (postscript, 'cs1');
	elseif 'citation' == cite_class	then
		sep, postscript = set_cs_style (postscript, 'cs2');
	else
		sep, postscript = set_cs_style (postscript, 'cs1');
	end

	if cfg.keywords_xlate[postscript:lower()] == 'none' then
		-- emit a maintenance message if user postscript is the default cs2 postscript
		-- we catch the opposite case for cs1 in set_cs_style
		if 'cs2' == mode or 'citation' == cite_class then
			utilities.set_message ('maint_postscript');
		end
		postscript = '';
	end
	
	return sep, postscript
end


--[=[-------------------------&lt; I S _ P D F &gt;-----------------------------------

Determines if a URL has the file extension that is one of the PDF file extensions
used by [[MediaWiki:Common.css]] when applying the PDF icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or
		url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
		url:match ('%.PDF&amp;#035') or url:match ('%.pdf&amp;#035');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;-----------------------

Applies CSS style to |format=, |chapter-format=, etc.  Also emits an error message
if the format parameter does not have a matching URL parameter.  If the format parameter
is not set and the URL contains a file extension that is recognized as a PDF document
by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if utilities.is_set (format) then
		format = utilities.wrap_style ('format', format);						-- add leading space, parentheses, resize
		if not utilities.is_set (url) then
			utilities.set_message ('err_format_missing_url', {fmt_param, url_param});	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if URL is a PDF file then
		format = utilities.wrap_style ('format', 'PDF');						-- set format to PDF
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[---------------------&lt; G E T _ D I S P L A Y _ N A M E S &gt;------------------

Returns a number that defines the number of names displayed for author and editor
name lists and a Boolean flag to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero,
return the number and the previous state of the 'etal' flag (false by default
but may have been set to true if the name list contains some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number
that is one greater than the number of authors in the list and set the 'etal' flag true.
This will cause the list_people() to display all of the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_names (max, count, list_name, etal, param)
	if utilities.is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				utilities.set_message ('err_disp_name', {param, max});			-- add error message
				max = nil;
			end
		else																	-- not a valid keyword or number
			utilities.set_message ('err_disp_name', {param, max});		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[----------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;---------------

Adds error if |page=, |pages=, |quote-page=, |quote-pages= has what appears to be
some form of p. or pp. abbreviation in the first characters of the parameter content.

check page for extraneous p, p., pp, pp., pg, pg. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when page begins PX or P# but not Px
		      where x and X are letters and # is a digit
	bad pattern:  '^[Pp][PpGg]' matches when page begins pp, pP, Pp, PP, pg, pG, Pg, PG

]]

local function extra_text_in_page_check (val, name)
	if not val:match (cfg.vol_iss_pg_patterns.good_ppattern) then
		for _, pattern in ipairs (cfg.vol_iss_pg_patterns.bad_ppatterns) do		-- spin through the selected sequence table of patterns
			if val:match (pattern) then											-- when a match, error so
				utilities.set_message ('err_extra_text_pages', name);	 		-- add error message
				return;															-- and done
			end
		end
	end		
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ V O L _ I S S _ C H E C K &gt;------------------------

Adds error if |volume= or |issue= has what appears to be some form of redundant 'type' indicator.

For |volume=:
	'V.', or 'Vol.' (with or without the dot) abbreviations or 'Volume' in the first characters of the parameter
	content (all case insensitive). 'V' and 'v' (without the dot) are presumed to be roman numerals so
	are allowed.

For |issue=:
	'No.', 'I.', 'Iss.' (with or without the dot) abbreviations, or 'Issue' in the first characters of the
	parameter content (all case insensitive).
	
Single character values ('v', 'i', 'n') allowed when not followed by separator character ('.', ':', '=', or
whitespace character) – param values are trimmed of whitespace by MediaWiki before delivered to the module.
	
&lt;val&gt; is |volume= or |issue= parameter value
&lt;name&gt; is |volume= or |issue= parameter name for error message
&lt;selector&gt; is 'v' for |volume=, 'i' for |issue=

sets error message on failure; returns nothing

]]

local function extra_text_in_vol_iss_check (val, name, selector)
	if not utilities.is_set (val) then
		return;
	end
	
	local patterns = 'v' == selector and cfg.vol_iss_pg_patterns.vpatterns or cfg.vol_iss_pg_patterns.ipatterns;

	local handler = 'v' == selector and 'err_extra_text_volume' or 'err_extra_text_issue';
	val = val:lower();															-- force parameter value to lower case
	for _, pattern in ipairs (patterns) do										-- spin through the selected sequence table of patterns
		if val:match (pattern) then												-- when a match, error so
			utilities.set_message (handler, name);								-- add error message
			return;																-- and done
		end
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parentheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a placeholder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parentheses
			local name = name_table[i];
			i = i + 1;															-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parentheses
					break;														-- and done reassembling so
				end
				i = i + 1;														-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = utilities.is_wikilink (name_table[i]);		-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i + 1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled parentheses ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the Vancouver error when a required comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		first = '';																-- set to empty string for concatenation and because it may have been set for previous author/editor
		local accept_name;
		v_name, accept_name = utilities.has_accept_as_written (v_name);			-- remove accept-this-as-written markup when it wraps all of &lt;v_name&gt;

		if accept_name then
			last = v_name;
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error (cfg.err_msg_supl.punctuation, i);
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s+&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be initials or generational suffix

			if not mw.ustring.match (first, '^%u+$') then						-- mw.ustring here so that later we will catch non-Latin characters
				suffix = first;													-- not initials so assume that whatever we got is a generational suffix
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end
			last = table.concat(lastfirstTable, ' ')							-- returns a string that is the concatenation of all other names that are not initials and generational suffix
			if not utilities.is_set (last) then
				first = '';														-- unset
				last = v_name;													-- last empty because something wrong with first
				add_vanc_error (cfg.err_msg_supl.name, i);
			end
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error (cfg.err_msg_supl['missing comma'], i);			-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- matches a space between two initials
			end
		else
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
		
		if utilities.is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first, suffix, i);							-- check first and last before restoring the suffix which may have a non-Latin digit
			if utilities.is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '', nil, i);
			end
		end

		link = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i ) or v_link_table[i];
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate = corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest;
|editorn= (and aliases) highest and |veditors= lowest (support for |editors= withdrawn)

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
	local lastfirst = false;
	if utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice in case we have a |first1= without a |last1=; this ...
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or		-- ... also catches the case where |first= is used with |vauthors=
		utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst = true;
	end

	if (utilities.is_set (vxxxxors) and true == lastfirst) or					-- these are the three error conditions
		(utilities.is_set (vxxxxors) and utilities.is_set (xxxxors)) or
		(true == lastfirst and utilities.is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			utilities.set_message ('err_redundant_parameters', err_name .. '-name-list parameters');	-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if utilities.is_set (vxxxxors) then return 2 end;
	if utilities.is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, live, dead, etc.).  When the parameter value has not been assigned a value (missing
or empty in the source template) the function returns the value specified by ret_val.  If the parameter value is one
of the list of allowed values returns the translated value; else, emits an error message and returns the value
specified by ret_val.

TODO: explain &lt;invert&gt;

]]

local function is_valid_parameter_value (value, name, possible, ret_val, invert)
	if not utilities.is_set (value) then
		return ret_val;															-- an empty parameter is ok
	end

	if (not invert and utilities.in_array (value, possible)) then				-- normal; &lt;value&gt; is in &lt;possible&gt; table
		return cfg.keywords_xlate[value];										-- return translation of parameter keyword
	elseif invert and not utilities.in_array (value, possible) then				-- invert; &lt;value&gt; is not in &lt;possible&gt; table
		return value;															-- return &lt;value&gt; as it is
	else
		utilities.set_message ('err_invalid_param_val', {name, value});			-- not an allowed value so add error message
		return ret_val;
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list, -3, -1) == sepc .. '. ') then					-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list, -1, -1) == sepc) or (string.sub (name_list, -3, -1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terminate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;----------------------------------------

returns the concatenation of the formatted volume and issue parameters as a single string; or formatted volume
or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, cite_class, origin, sepc, lower)
	if not utilities.is_set (volume) and not utilities.is_set (issue) then
		return '';
	end

	-- same condition as in format_pages_sheets()
	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);

	local is_numeric_vol = volume and (volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$'));	-- is only uppercase roman numerals or only digits?
	local is_long_vol = volume and (4 &lt; mw.ustring.len(volume));				-- is |volume= value longer than 4 characters?
	
	if volume and (not is_numeric_vol and is_long_vol) then						-- when not all digits or Roman numerals, is |volume= longer than 4 characters?
		utilities.add_prop_cat ('long-vol');									-- yes, add properties cat
	end

	if is_journal then															-- journal-style formatting
		local vol = '';
		
		if utilities.is_set (volume) then
			if is_numeric_vol then												-- |volume= value all digits or all uppercase Roman numerals?
				vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, volume});	-- render in bold face
			elseif is_long_vol then												-- not all digits or Roman numerals; longer than 4 characters?
				vol = utilities.substitute (cfg.messages['j-vol'], {sepc, utilities.hyphen_to_dash (volume)});	-- not bold
			else																-- four or fewer characters
				vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, utilities.hyphen_to_dash (volume)});	-- bold
			end
		end
		if utilities.is_set (issue) then
			return vol .. utilities.substitute (cfg.messages['j-issue'], issue);
		end
		return vol;
	end
	
	if 'podcast' == cite_class and utilities.is_set (issue) then
		return wrap_msg ('issue', {sepc, issue}, lower);
	end

	-- all other types of citation
	if utilities.is_set (volume) and utilities.is_set (issue) then
		return wrap_msg ('vol-no', {sepc, utilities.hyphen_to_dash (volume), issue}, lower);
	elseif utilities.is_set (volume) then
		return wrap_msg ('vol', {sepc, utilities.hyphen_to_dash (volume)}, lower);
	else
		return wrap_msg ('issue', {sepc, issue}, lower);
	end
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if utilities.is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif utilities.is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if utilities.is_set (page) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return utilities.substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return utilities.substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif utilities.is_set (pages) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then							-- if pages is only digits, assume a single page number
			return '', utilities.substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', utilities.substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', utilities.substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to Wikisource, returns the label portion of the interwiki-link as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki-link to an external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, page_orig, pages, pages_orig, at)
	local ws_url, ws_label, coins_pages, L;										-- for Wikisource interwiki-links; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if utilities.is_set (page) then
		if utilities.is_set (pages) or utilities.is_set (at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page, page_orig);								-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws URL from |page= interwiki link; link portion L becomes tooltip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (pages) then
		if utilities.is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages, pages_orig);							-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws URL from |pages= interwiki link; link portion L becomes tooltip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws URL from |at= interwiki link; link portion L becomes tooltip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end

--[[--------------------------&lt; I S _ U N I Q U E _ A R C H I V E _ U R L &gt;------------------------------------

add error message when |archive-url= value is same as |url= or chapter-url= (or alias...) value

]]

local function is_unique_archive_url (archive, url, c_url, source, date)
	if utilities.is_set (archive) then
		if archive == url or archive == c_url then
			utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)});	-- add error message
			return '', '';														-- unset |archive-url= and |archive-date= because same as |url= or |chapter-url=
		end
	end

	return archive, date;
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org URLs to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot URL or to calendar pages.  When the archive URL is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the URL.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org URL does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command URL
	|archive-url= is an archive.org URL that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org URLs:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this function may return a modified
archive URL:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the URL unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.org URL
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine URL
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command URL, we don't want to allow saving of the target page 
		err_msg = cfg.err_msg_supl.save;
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = cfg.err_msg_supl.liveweb;
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');	-- split out some of the URL parts for evaluation
		if not path then														-- malformed in some way; pattern did not match
			err_msg = cfg.err_msg_supl.timestamp;
		elseif 14 ~= timestamp:len() then										-- path and flag optional, must have 14-digit timestamp here
			err_msg = cfg.err_msg_supl.timestamp;
			if '*' ~= flag then
				local replacement = timestamp:match ('^%d%d%d%d%d%d') or timestamp:match ('^%d%d%d%d');	-- get the first 6 (YYYYMM) or first 4 digits (YYYY)
				if replacement then												-- nil if there aren't at least 4 digits (year)
					replacement = replacement .. string.rep ('0', 14 - replacement:len());	-- year or yearmo (4 or 6 digits) zero-fill to make 14-digit timestamp
					url=url:gsub ('(//web%.archive%.org/[^%d]*)%d[^/]*', '%1' .. replacement .. '*', 1)	-- for preview, modify ts to 14 digits plus splat for calendar display
				end
			end
		elseif utilities.is_set (path) and 'web/' ~= path then					-- older archive URLs do not have the extra 'web/' path element
			err_msg = cfg.err_msg_supl.path;
		elseif utilities.is_set (flag) and not utilities.is_set (path) then		-- flag not allowed with the old form URL (without the 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		elseif utilities.is_set (flag) and not flag:match ('%a%a_') then		-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		else
			return url, date;													-- return ArchiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	utilities.set_message ('err_archive_url', {err_msg});						-- add error message and

	if is_preview_mode then
		return url, date;														-- preview mode so return ArchiveURL and ArchiveDate
	else
		return '', '';															-- return empty strings for ArchiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; P L A C E _ C H E C K &gt;--------------------------------------------------------

check |place=, |publication-place=, |location= to see if these params include digits.  This function added because
many editors misuse location to specify the in-source location (|page(s)= and |at= are supposed to do that)

returns the original parameter value without modification; added maint cat when parameter value contains digits

]]

local function place_check (param_val)
	if not utilities.is_set (param_val) then									-- parameter empty or omitted
		return param_val;														-- return that empty state
	end
	
	if mw.ustring.find (param_val, '%d') then									-- not empty, are there digits in the parameter value
		utilities.set_message ('maint_location');								-- yep, add maint cat
	end
	
	return param_val;															-- and done
end


--[[--------------------------&lt; I S _ A R C H I V E D _ C O P Y &gt;----------------------------------------------

compares |title= to 'Archived copy' (placeholder added by bots that can't find proper title); if matches, return true; nil else

]]

local function is_archived_copy (title)
	title = mw.ustring.lower(title);											-- switch title to lower case
	if title:find (cfg.special_case_translation.archived_copy.en) then			-- if title is 'Archived copy'
		return true;
	elseif cfg.special_case_translation.archived_copy['local'] then
		if mw.ustring.find (title, cfg.special_case_translation.archived_copy['local']) then	-- mw.ustring() because might not be Latin script
			return true;
		end
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args )
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper ( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListStyle = is_valid_parameter_value (A['NameListStyle'], A:ORIGIN('NameListStyle'), cfg.keywords_lists['name-list-style'], '');
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				utilities.set_message ('maint_authors');						-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if utilities.is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], nil, args, 'EditorList');	-- support for |editors= withdrawn
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		end
	end
							
	local Chapter = A['Chapter'];												-- done here so that we have access to |contribution= from |chapter= aliases
	local Chapter_origin = A:ORIGIN ('Chapter');
	local Contribution;															-- because contribution is required for contributor(s)
		if 'contribution' == Chapter_origin then
			Contribution = Chapter;												-- get the name of the contribution
		end
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	
	if utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not utilities.is_set (Contribution) then							-- |contributor= requires |contribution=
				utilities.set_message ('err_contributor_missing_required_param', 'contribution');	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				utilities.set_message ('err_contributor_missing_required_param', 'author');	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if utilities.select_one (args, cfg.aliases['ContributorList-Last'], 'err_redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			utilities.set_message ('err_contributor_ignored');					-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	local Title = A['Title'];
	local TitleLink = A['TitleLink'];

	local auto_select = ''; -- default is auto
	local accept_link;
	TitleLink, accept_link = utilities.has_accept_as_written (TitleLink, true);	-- test for accept-this-as-written markup
	if (not accept_link) and utilities.in_array (TitleLink, {'none', 'pmc', 'doi'}) then -- check for special keywords
		auto_select = TitleLink;												-- remember selection for later
		TitleLink = '';															-- treat as if |title-link= would have been empty
	end

	TitleLink = link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wiki-markup in |title-link= or wiki-markup in |title= when |title-link= is set

	local Section = '';															-- {{cite map}} only; preset to empty string for concatenation if not used
	if 'map' == config.CitationClass and 'section' == Chapter_origin then
		Section = A['Chapter'];													-- get |section= from |chapter= alias list; |chapter= and the other aliases not supported in {{cite map}}
		Chapter = '';															-- unset for now; will be reset later from |map= if present
	end

	local Periodical = A['Periodical'];
	local Periodical_origin = '';
	if utilities.is_set (Periodical) then
		Periodical_origin = A:ORIGIN('Periodical');								-- get the name of the periodical parameter
		local i;
		Periodical, i = utilities.strip_apostrophe_markup (Periodical);			-- strip apostrophe markup so that metadata isn't contaminated 
		if i then																-- non-zero when markup was stripped so emit an error message
			utilities.set_message ('err_apostrophe_markup', {Periodical_origin});
		end
	end

	if 'mailinglist' == config.CitationClass then								-- special case for {{cite mailing list}}
		if utilities.is_set (Periodical) and utilities.is_set (A ['MailingList']) then	-- both set emit an error TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', Periodical_origin) .. ' and ' .. utilities.wrap_style ('parameter', 'mailinglist')});
		end

		Periodical = A ['MailingList'];											-- error or no, set Periodical to |mailinglist= value because this template is {{cite mailing list}}
		Periodical_origin = A:ORIGIN('MailingList');
	end

	local ScriptPeriodical = A['ScriptPeriodical'];

	-- web and news not tested for now because of 
	-- Wikipedia:Administrators%27_noticeboard#Is_there_a_semi-automated_tool_that_could_fix_these_annoying_&quot;Cite_Web&quot;_errors?
	if not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) then	-- 'periodical' templates require periodical parameter
	--	local p = {['journal'] = 'journal', ['magazine'] = 'magazine', ['news'] = 'newspaper', ['web'] = 'website'};	-- for error message
		local p = {['journal'] = 'journal', ['magazine'] = 'magazine'};			-- for error message
		if p[config.CitationClass]  then
			utilities.set_message ('err_missing_periodical', {config.CitationClass, p[config.CitationClass]});
		end
	end
	
	local Volume;
	local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) then
			if not utilities.in_array (Periodical_origin, cfg.citation_no_volume_t) then	-- {{citation}} does not render |volume= when these parameters are used
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		elseif utilities.is_set (ScriptPeriodical) then
			if 'script-website' ~= ScriptPeriodical_origin then					-- {{citation}} does not render volume for |script-website=
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		else
			Volume = A['Volume'];												-- and does for non-'periodical' cites
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_volume) then	-- render |volume= for cs1 according to the configuration settings
		Volume = A['Volume'];
	end	
	extra_text_in_vol_iss_check (Volume, A:ORIGIN ('Volume'), 'v');	

	local Issue;
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) and utilities.in_array (Periodical_origin, cfg.citation_issue_t) then	-- {{citation}} may render |issue= when these parameters are used
			Issue = utilities.hyphen_to_dash (A['Issue']);
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_issue) then	-- conference &amp; map books do not support issue; {{citation}} listed here because included in settings table
		if not (utilities.in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical))) then
			Issue = utilities.hyphen_to_dash (A['Issue']);
		end
	end
	extra_text_in_vol_iss_check (Issue, A:ORIGIN ('Issue'), 'i');	

	local Page;
	local Pages;
	local At;
	if not utilities.in_array (config.CitationClass, cfg.templates_not_using_page) then
		Page = A['Page'];
		Pages = utilities.hyphen_to_dash (A['Pages']);	
		At = A['At'];
	end

	local Edition = A['Edition'];
	local PublicationPlace = place_check (A['PublicationPlace'], A:ORIGIN('PublicationPlace'));
	local Place = place_check (A['Place'], A:ORIGIN('Place'));
	
	local PublisherName = A['PublisherName'];
	local PublisherName_origin = A:ORIGIN('PublisherName');
	if utilities.is_set (PublisherName) then
		local i = 0;
		PublisherName, i = utilities.strip_apostrophe_markup (PublisherName);	-- strip apostrophe markup so that metadata isn't contaminated; publisher is never italicized
		if i then																-- non-zero when markup was stripped so emit an error message
			utilities.set_message ('err_apostrophe_markup', {PublisherName_origin});
		end
	end

	local Newsgroup = A['Newsgroup'];											-- TODO: strip apostrophe markup?
	local Newsgroup_origin = A:ORIGIN('Newsgroup');	

	if 'newsgroup' == config.CitationClass then
		if utilities.is_set (PublisherName) then								-- general use parameter |publisher= not allowed in cite newsgroup
			utilities.set_message ('err_parameter_ignored', {PublisherName_origin});
		end

		PublisherName = nil;													-- ensure that this parameter is unset for the time being; will be used again after COinS
	end

	local URL = A['URL'];														-- TODO: better way to do this for URL, ChapterURL, and MapURL?
	local UrlAccess = is_valid_parameter_value (A['UrlAccess'], A:ORIGIN('UrlAccess'), cfg.keywords_lists['url-access'], nil);
	
	if not utilities.is_set (URL) and utilities.is_set (UrlAccess) then
		UrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', 'url');
	end
	
	local ChapterURL = A['ChapterURL'];
	local ChapterUrlAccess = is_valid_parameter_value (A['ChapterUrlAccess'], A:ORIGIN('ChapterUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (ChapterURL) and utilities.is_set (ChapterUrlAccess) then
		ChapterUrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', {A:ORIGIN('ChapterUrlAccess'):gsub ('%-access', '')});
	end

	local MapUrlAccess = is_valid_parameter_value (A['MapUrlAccess'], A:ORIGIN('MapUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (A['MapURL']) and utilities.is_set (MapUrlAccess) then
		MapUrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', {'map-url'});
	end

	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local no_tracking_cats = is_valid_parameter_value (A['NoTracking'], A:ORIGIN('NoTracking'), cfg.keywords_lists['yes_true_y'], nil);

	-- check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not utilities.is_set (no_tracking_cats) then								-- ignore if we are already not going to categorize this page
		if utilities.in_array (this_page.nsText, cfg.uncategorized_namespaces) then
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _, v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end
																				-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	utilities.select_one (args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'err_redundant_parameters');	-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, A:ORIGIN('Page'), Pages, A:ORIGIN('Pages'), At);

	local NoPP = is_valid_parameter_value (A['NoPP'], A:ORIGIN('NoPP'), cfg.keywords_lists['yes_true_y'], nil);

	if utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- both |publication-place= and |place= (|location=) allowed if different
		utilities.add_prop_cat ('location-test');								-- add property cat to evaluate how often PublicationPlace and Place are used together
		if PublicationPlace == Place then
			Place = '';															-- unset; don't need both if they are the same
		end
	elseif not utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- when only |place= (|location=) is set ...
		PublicationPlace = Place;												-- promote |place= (|location=) to |publication-place
	end

	if PublicationPlace == Place then Place = ''; end							-- don't need both if they are the same
	
	local URL_origin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL_origin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ScriptChapter = A['ScriptChapter'];
	local ScriptChapter_origin = A:ORIGIN ('ScriptChapter');
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local TransChapter = A['TransChapter'];
	local TransChapter_origin = A:ORIGIN ('TransChapter');
	local TransTitle = A['TransTitle'];
	local ScriptTitle = A['ScriptTitle'];
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia= and |title= then map |title= to |article= and |encyclopedia= to |title=
		|encyclopedia= and |article= then map |encyclopedia= to |title=

		|trans-title= maps to |trans-chapter= when |title= is re-mapped
		|url= maps to |chapter-url= when |title= is remapped
	
	All other combinations of |encyclopedia=, |title=, and |article= are not modified
	
	]]

	local Encyclopedia = A['Encyclopedia'];										-- used as a flag by this module and by ~/COinS

	if utilities.is_set (Encyclopedia) then										-- emit error message when Encyclopedia set but template is other than {{cite encyclopedia}} or {{citation}}
		if 'encyclopaedia' ~= config.CitationClass and 'citation' ~= config.CitationClass then
			utilities.set_message ('err_parameter_ignored', {A:ORIGIN ('Encyclopedia')});
			Encyclopedia = nil;													-- unset because not supported by this template
		end
	end

	if ('encyclopaedia' == config.CitationClass) or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Periodical) and utilities.is_set (Encyclopedia) then	-- when both set emit an error TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', A:ORIGIN ('Encyclopedia')) .. ' and ' .. utilities.wrap_style ('parameter', Periodical_origin)});
		end

		if utilities.is_set (Encyclopedia) then
			Periodical = Encyclopedia;											-- error or no, set Periodical to Encyclopedia; allow periodical without encyclopedia
			Periodical_origin = A:ORIGIN ('Encyclopedia');
		end

		if utilities.is_set (Periodical) then									-- Periodical is set when |encyclopedia= is set
			if utilities.is_set (Title) or utilities.is_set (ScriptTitle) then
				if not utilities.is_set (Chapter) then
					Chapter = Title;											-- |encyclopedia= and |title= are set so map |title= to |article= and |encyclopedia= to |title=
					ScriptChapter = ScriptTitle;
					ScriptChapter_origin = A:ORIGIN('ScriptTitle')
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterURL_origin = URL_origin;

					ChapterUrlAccess = UrlAccess;

					if not utilities.is_set (ChapterURL) and utilities.is_set (TitleLink) then
						Chapter = utilities.make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			elseif utilities.is_set (Chapter) or utilities.is_set (ScriptChapter) then								-- |title= not set
				Title = Periodical;												-- |encyclopedia= set and |article= set so map |encyclopedia= to |title=
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- special case for cite techreport.
	local ID = A['ID'];
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if utilities.is_set (A['Number']) then									-- cite techreport uses 'number', which other citations alias to 'issue'
			if not utilities.is_set (ID) then									-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'id') .. ' and ' .. utilities.wrap_style ('parameter', 'number')});
			end
		end	
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	local ChapterLink -- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local Conference = A['Conference'];
	local BookTitle = A['BookTitle'];
	local TransTitle_origin = A:ORIGIN ('TransTitle');
	if 'conference' == config.CitationClass then
		if utilities.is_set (BookTitle) then
			Chapter = Title;
			Chapter_origin = 'title';
	--		ChapterLink = TitleLink;											-- |chapter-link= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			URL_origin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			TransChapter_origin = TransTitle_origin;
			Title = BookTitle;
			Format = '';
	--		TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end
	
	-- CS1/2 mode
	local Mode = is_valid_parameter_value (A['Mode'], A:ORIGIN('Mode'), cfg.keywords_lists['mode'], '');
	-- separator character and postscript
	local sepc, PostScript = set_style (Mode:lower(), A['PostScript'], config.CitationClass);
	-- controls capitalization of certain static text
	local use_lowercase = ( sepc == ',' );
	
	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		if utilities.is_set (Chapter) then										--TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'map') .. ' and ' .. utilities.wrap_style ('parameter', Chapter_origin)});	-- add error message
		end
		Chapter = A['Map'];
		Chapter_origin = A:ORIGIN('Map');
		ChapterURL = A['MapURL'];
		ChapterURL_origin = A:ORIGIN('MapURL');
		TransChapter = A['TransMap'];
		ScriptChapter = A['ScriptMap']
		ScriptChapter_origin = A:ORIGIN('ScriptMap')

		ChapterUrlAccess = MapUrlAccess;
		ChapterFormat = A['MapFormat'];

		Cartography = A['Cartography'];
		if utilities.is_set ( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if utilities.is_set ( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	local Series = A['Series'];
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local SeriesLink = A['SeriesLink'];

		SeriesLink = link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wiki-markup in |series-link= or wiki-markup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if utilities.is_set (Network) then table.insert(n, Network); end
		if utilities.is_set (Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if utilities.is_set (Season) and utilities.is_set (SeriesNumber) then	-- these are mutually exclusive so if both are set TODO: make a function for this and similar?
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'season') .. ' and ' .. utilities.wrap_style ('parameter', 'seriesno')});		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if utilities.is_set (Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if utilities.is_set (SeriesNumber) then table.insert(s, wrap_msg ('seriesnum', SeriesNumber, use_lowercase)); end
			if utilities.is_set (Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ScriptChapter_origin = A:ORIGIN('ScriptTitle');
			ChapterLink = TitleLink;											-- alias |episode-link=
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			ChapterFormat = Format;

			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if utilities.is_set (ChapterLink) and not utilities.is_set (ChapterURL) then	-- link but not URL
				Chapter = utilities.make_wikilink (ChapterLink, Chapter);
			elseif utilities.is_set (ChapterLink) and utilities.is_set (ChapterURL) then	-- if both are set, URL links episode;
				Series = utilities.make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			Format = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if utilities.is_set (Series) and utilities.is_set (SeriesLink) then
				Series = utilities.make_wikilink (SeriesLink, Series);
			end
			Series = utilities.wrap_style ('italic-title', Series);				-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- handle type parameter for those CS1 citations that have default values
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	if utilities.in_array (config.CitationClass, {'AV-media-notes', 'interview', 'mailinglist', 'map', 'podcast', 'pressrelease', 'report', 'speech', 'techreport', 'thesis'}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if utilities.is_set (Degree) and &quot;Thesis&quot; == TitleType then				-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if utilities.is_set (TitleType) then										-- if type parameter is specified
		TitleType = utilities.substitute ( cfg.messages['type'], TitleType);	-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
	local Date = A['Date'];
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging
	local PublicationDate = A['PublicationDate'];
	local Year = A['Year'];

	if not utilities.is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not utilities.is_set (Date) and utilities.is_set (PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]

	local DF = is_valid_parameter_value (A['DF'], A:ORIGIN('DF'), cfg.keywords_lists['df'], '');
	if not utilities.is_set (DF) then
		DF = cfg.global_df;														-- local |df= if present overrides global df set by {{use xxx date}} template
	end

	local ArchiveURL;
	local ArchiveDate;
	local ArchiveFormat = A['ArchiveFormat'];

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	
	ArchiveURL, ArchiveDate = is_unique_archive_url (ArchiveURL, URL, ChapterURL, A:ORIGIN('ArchiveURL'), ArchiveDate);		-- add error message when URL or ChapterURL == ArchiveURL

	
	local AccessDate = A['AccessDate'];
	local LayDate = A['LayDate'];
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification
	local DoiBroken = A['DoiBroken'];
	local Embargo = A['Embargo'];
	local anchor_year;															-- used in the CITEREF identifier
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val = AccessDate, name = A:ORIGIN ('AccessDate')},
			['archive-date'] = {val = ArchiveDate, name = A:ORIGIN ('ArchiveDate')},
			['date'] = {val = Date, name = Date_origin},
			['doi-broken-date'] = {val = DoiBroken, name = A:ORIGIN ('DoiBroken')},
			['pmc-embargo-date'] = {val = Embargo, name = A:ORIGIN ('Embargo')},
			['lay-date'] = {val = LayDate, name = A:ORIGIN ('LayDate')},
			['publication-date'] = {val = PublicationDate, name = A:ORIGIN ('PublicationDate')},
			['year'] = {val = Year, name = A:ORIGIN ('Year')},
			};

		local error_list = {};
		anchor_year, Embargo = validation.dates(date_parameters_list, COinS_date, error_list);

-- start temporary Julian / Gregorian calendar uncertainty categorization
		if COinS_date.inter_cal_cat then
			utilities.add_prop_cat ('jul-greg-uncertainty');
		end
-- end temporary Julian / Gregorian calendar uncertainty categorization

		if utilities.is_set (Year) and utilities.is_set (Date) then				-- both |date= and |year= not normally needed; 
			validation.year_date_check (Year, A:ORIGIN ('Year'), Date, A:ORIGIN ('Date'), error_list);
		end
		
		if 0 == #error_list then												-- error free dates only; 0 when error_list is empty
			local modified = false;												-- flag
			
			if utilities.is_set (DF) then										-- if we need to reformat dates
				modified = validation.reformat_dates (date_parameters_list, DF);	-- reformat to DF format, use long month names if appropriate
			end

			if true == validation.date_hyphen_to_dash (date_parameters_list) then	-- convert hyphens to dashes where appropriate
				modified = true;
				utilities.set_message ('maint_date_format');					-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language; not supported at en.wiki
			if cfg.date_name_auto_xlate_enable and validation.date_name_xlate (date_parameters_list, cfg.date_digit_auto_xlate_enable ) then
				utilities.set_message ('maint_date_auto_xlated');				-- add maint cat
				modified = true;
			end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				LayDate = date_parameters_list['lay-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end
		else
			utilities.set_message ('err_bad_date', {utilities.make_sep_list (#error_list, error_list)});	-- add this error message
		end
	end	-- end of do

	local ID_list = {};															-- sequence table of rendered identifiers
	local ID_list_coins = {};													-- table of identifiers and their values from args; key is same as cfg.id_handlers's key
	local Class = A['Class'];													-- arxiv class identifier
	
	local ID_support = {
		{A['ASINTLD'], 'ASIN', 'err_asintld_missing_asin', A:ORIGIN ('ASINTLD')},				
		{DoiBroken, 'DOI', 'err_doibroken_missing_doi', A:ORIGIN ('DoiBroken')},
		{Embargo, 'PMC', 'err_embargo_missing_pmc', A:ORIGIN ('Embargo')},
		}

	ID_list, ID_list_coins = identifiers.identifier_lists_get (args, {DoiBroken = DoiBroken, ASINTLD = A['ASINTLD'], Embargo = Embargo, Class = Class}, ID_support);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite ssrn}}, before generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then
		if not utilities.is_set (ID_list_coins[config.CitationClass:upper()]) then 	-- |arxiv= or |eprint= required for cite arxiv; |biorxiv= &amp; |citeseerx= required for their templates
			utilities.set_message ('err_' .. config.CitationClass .. '_missing');	-- add error message
		end

		Periodical = ({['arxiv'] = 'arXiv', ['biorxiv'] = 'bioRxiv', ['citeseerx'] = 'CiteSeerX', ['ssrn'] = 'Social Science Research Network'})[config.CitationClass];
	end

	-- Link the title of the work if no |url= was provided, but we have a |pmc= or a |doi= with |doi-access=free

	if config.CitationClass == &quot;journal&quot; and not utilities.is_set (URL) and not utilities.is_set (TitleLink) and not utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) then -- TODO: remove 'none' once existing citations have been switched to 'off', so 'none' can be used as token for &quot;no title&quot; instead
		if 'none' ~= cfg.keywords_xlate[auto_select] then						-- if auto-linking not disabled
 	 		if identifiers.auto_link_urls[auto_select] then						-- manual selection
		 		URL = identifiers.auto_link_urls[auto_select];					-- set URL to be the same as identifier's external link
 				URL_origin = cfg.id_handlers[auto_select:upper()].parameters[1];	-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['pmc'] then						-- auto-select PMC
				URL = identifiers.auto_link_urls['pmc'];						-- set URL to be the same as the PMC external link if not embargoed
				URL_origin = cfg.id_handlers['PMC'].parameters[1];				-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['doi'] then						-- auto-select DOI
				URL = identifiers.auto_link_urls['doi'];
				URL_origin = cfg.id_handlers['DOI'].parameters[1];
			end
 	 	end

		if utilities.is_set (URL) then											-- set when using an identifier-created URL
			if utilities.is_set (AccessDate) then								-- |access-date= requires |url=; identifier-created URL is not |url=
				utilities.set_message ('err_accessdate_missing_url');			-- add an error message
				AccessDate = '';												-- unset
			end

			if utilities.is_set (ArchiveURL) then								-- |archive-url= requires |url=; identifier-created URL is not |url=
				utilities.set_message ('err_archive_missing_url');				-- add an error message
				ArchiveURL = '';												-- unset
			end
		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not utilities.is_set (Title) and not utilities.is_set (TransTitle) and not utilities.is_set (ScriptTitle) then	-- has special case for cite episode
		utilities.set_message ('err_citation_missing_title', {'episode' == config.CitationClass and 'series' or 'title'});
	end

	if utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) and
			utilities.in_array (config.CitationClass, {'journal', 'citation'}) and
			(utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and
			('journal' == Periodical_origin or 'script-journal' == ScriptPeriodical_origin) then	-- special case for journal cites
				Title = '';														-- set title to empty string
				utilities.set_message ('maint_untitled');						-- add maint cat
	end

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Chapter) and utilities.is_set (Title) and utilities.is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end
	
	local QuotePage = A['QuotePage'];
	local QuotePages = utilities.hyphen_to_dash (A['QuotePages']);

	-- this is the function call to COinS()
	local OCinSoutput = metadata.COinS({
		['Periodical'] = utilities.strip_apostrophe_markup (Periodical),		-- no markup in the metadata
		['Encyclopedia'] = Encyclopedia,										-- just a flag; content ignored by ~/COinS
		['Chapter'] = metadata.make_coins_title (coins_chapter, ScriptChapter),	-- Chapter and ScriptChapter stripped of bold / italic / accept-as-written markup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = metadata.make_coins_title (coins_title, ScriptTitle),		-- Title and ScriptTitle stripped of bold / italic / accept-as-written markup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Quarter'] = COinS_date.rftquarter,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['Pages'] = coins_pages or metadata.get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At, QuotePage, QuotePages}, 7)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName or Newsgroup,							-- any apostrophe markup already removed from PublisherName
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list_coins,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, and {{cite ssrn}} AFTER generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, CiteSeerX, or ssrn now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass and utilities.is_set (Newsgroup) then
		PublisherName = utilities.substitute (cfg.messages['newsgroup'], external_link( 'news:' .. Newsgroup, Newsgroup, Newsgroup_origin, nil ));
	end

	local Editors;
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	local Contributors;															-- assembled contributors name list
	local contributor_etal;
	local Translators;															-- assembled translators name list
	local translator_etal;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	local Interviewers;															
	local interviewers_list = {};					
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters
	local interviewer_etal;
	
	-- Now perform various field 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.
	do
		local last_first_list;
		local control = { 
			format = NameListStyle,												-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_names (A['DisplayEditors'], #e, 'editors', editor_etal, A:ORIGIN ('DisplayEditors'));
			Editors, EditorCount = list_people (control, e, editor_etal);

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum, interviewer_etal = get_display_names (A['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal, A:ORIGIN ('DisplayInterviewers'));
			Interviewers = list_people (control, interviewers_list, interviewer_etal);
		end
		do																		-- now do translators
			control.maximum, translator_etal = get_display_names (A['DisplayTranslators'], #t, 'translators', translator_etal, A:ORIGIN ('DisplayTranslators'));
			Translators = list_people (control, t, translator_etal);
		end
		do																		-- now do contributors
			control.maximum, contributor_etal = get_display_names (A['DisplayContributors'], #c, 'contributors', contributor_etal, A:ORIGIN ('DisplayContributors'));
			Contributors = list_people (control, c, contributor_etal);
		end
		do																		-- now do authors
			control.maximum, author_etal = get_display_names (A['DisplayAuthors'], #a, 'authors', author_etal, A:ORIGIN ('DisplayAuthors'));

			last_first_list = list_people (control, a, author_etal);

			if utilities.is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors');	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if utilities.is_set (Authors) and utilities.is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not utilities.is_set (URL) then
		if utilities.in_array (config.CitationClass, {&quot;web&quot;, &quot;podcast&quot;, &quot;mailinglist&quot;}) or		-- |url= required for cite web, cite podcast, and cite mailinglist
			('citation' == config.CitationClass and ('website' == Periodical_origin or 'script-website' == ScriptPeriodical_origin)) then	-- and required for {{citation}} with |website= or |script-website=
				utilities.set_message ('err_cite_web_url');
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if utilities.is_set (AccessDate) and not utilities.is_set (ChapterURL) then		-- ChapterURL may be set when URL is not set;
			utilities.set_message ('err_accessdate_missing_url');
			AccessDate = '';
		end
	end

	local UrlStatus = is_valid_parameter_value (A['UrlStatus'], A:ORIGIN('UrlStatus'), cfg.keywords_lists['url-status'], '');
	local OriginalURL
	local OriginalURL_origin
	local OriginalFormat
	local OriginalAccess;
	UrlStatus = UrlStatus:lower();												-- used later when assembling archived text
	if utilities.is_set ( ArchiveURL ) then
		if utilities.is_set (ChapterURL) then 									-- if chapter-url= is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURL_origin = ChapterURL_origin;								-- name of |chapter-url= parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=

			if 'live' ~= UrlStatus then
				ChapterURL = ArchiveURL											-- swap-in the archive's URL
				ChapterURL_origin = A:ORIGIN('ArchiveURL')						-- name of |archive-url= parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived URLs
			end
		elseif utilities.is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURL_origin = URL_origin;									-- name of URL parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;

			if 'live' ~= UrlStatus then											-- if URL set then |archive-url= applies to it
				URL = ArchiveURL												-- swap-in the archive's URL
				URL_origin = A:ORIGIN('ArchiveURL')								-- name of archive URL parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived URLs
			end
		end
	elseif utilities.is_set (UrlStatus) then									-- if |url-status= is set when |archive-url= is not set
 		utilities.set_message ('maint_url_status');								-- add maint cat
	end

	if utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) then
			local chap_param;
			if utilities.is_set (Chapter) then									-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif utilities.is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif utilities.is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif utilities.is_set (ScriptChapter) then
				chap_param = ScriptChapter_origin;
			else utilities.is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if utilities.is_set (chap_param) then								-- if we found one
				utilities.set_message ('err_chapter_ignored', {chap_param});	-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if utilities.is_set (Contribution) and 0 &lt; #c then						-- if this is a contribution with contributor(s)
			if utilities.in_array (Contribution:lower(), cfg.keywords_lists.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, ScriptChapter_origin, Chapter, Chapter_origin, TransChapter, TransChapter_origin, ChapterURL, ChapterURL_origin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if utilities.is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and utilities.is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter .. sepc .. ' ';
		elseif utilities.is_set (ChapterFormat) then							-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title
	local plain_title = false;
	local accept_title;
	Title, accept_title = utilities.has_accept_as_written (Title, true);		-- remove accept-this-as-written markup when it wraps all of &lt;Title&gt;
	if accept_title and ('' == Title) then										-- only support forced empty for now &quot;(())&quot;
		Title = cfg.messages['notitle'];										-- replace by predefined &quot;No title&quot; message
			-- TODO: utilities.set_message ( 'err_redundant_parameters', ...);	-- issue proper error message instead of muting	 
			ScriptTitle = '';													-- just mute for now	 
			TransTitle = '';													-- just mute for now
 		plain_title = true;														-- suppress text decoration for descriptive title
		utilities.set_message ('maint_untitled');								-- add maint cat
	end

	if not accept_title then													-- &lt;Title&gt; not wrapped in accept-as-written markup
		if '...' == Title:sub (-3) then											-- if ellipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%' .. sepc .. '$', '');			-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end

		if utilities.is_set (ArchiveURL) and is_archived_copy (Title) then
			utilities.set_message ('maint_archived_copy');						-- add maintenance category before we modify the content of Title
		end

		if is_generic ('generic_titles', Title) then
			utilities.set_message ('err_generic_title');						-- set an error message
		end
	end

	if (not plain_title) and (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) or
		('map' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)))) then		-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from module provided quote marks
			Title = utilities.wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle, 'script-title');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
			TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );
	elseif plain_title or ('report' == config.CitationClass) then				-- no styling for cite report and descriptive titles (otherwise same as above)
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );	-- for cite report, use this form for trans-title
	else
		Title = utilities.wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-italic-title', TransTitle);
	end

	if utilities.is_set (TransTitle) then
		if utilities.is_set (Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			utilities.set_message ('err_trans_missing_title', {'title'});
		end
	end

	if utilities.is_set (Title) then											-- TODO: is this the right place to be making Wikisource URLs?
		if utilities.is_set (TitleLink) and utilities.is_set (URL) then
			utilities.set_message ('err_wikilink_in_url');						-- set an error message because we can't have both
			TitleLink = '';														-- unset
		end
	
		if not utilities.is_set (TitleLink) and utilities.is_set (URL) then
			Title = external_link (URL, Title, URL_origin, UrlAccess) .. TransTitle .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif utilities.is_set (TitleLink) and not utilities.is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle;
			else
				Title = utilities.make_wikilink (TitleLink, Title) .. TransTitle;
			end
		else
			local ws_url, ws_label, L;											-- Title has italic or quote markup by the time we get here which causes is_wikilink() to return 0 (not a wikilink)
			ws_url, ws_label, L = wikisource_url_make (Title:gsub('^[\'&quot;]*(.-)[\'&quot;]*$', '%1'));	-- make ws URL from |title= interwiki link (strip italic or quote markup); link portion L becomes tooltip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle;
			else
				Title = Title .. TransTitle;
			end
		end
	else
		Title = TransTitle;
	end

	if utilities.is_set (Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	local ConferenceURL_origin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	if utilities.is_set (Conference) then
		if utilities.is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURL_origin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif utilities.is_set (ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURL_origin, nil );
	end

	local Position = '';
	if not utilities.is_set (Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if utilities.is_set (Minutes) then
			if utilities.is_set (Time) then		--TODO: make a function for this and similar?
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'minutes') .. ' and ' .. utilities.wrap_style ('parameter', 'time')});
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if utilities.is_set (Time) then
				local TimeCaption = A['TimeCaption']
				if not utilities.is_set (TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = utilities.is_set (At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = utilities.is_set (Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Sections = A['Sections'];											-- Section (singular) is an alias of Chapter so set earlier
		local Inset = A['Inset'];
		
		if utilities.is_set ( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if utilities.is_set ( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif utilities.is_set ( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	local Others = A['Others'];
	if utilities.is_set (Others) and 0 == #a and 0 == #e then					-- add maint cat when |others= has value and used without |author=, |editor=
		if config.CitationClass == &quot;AV-media-notes&quot;
		or config.CitationClass == &quot;audio-visual&quot; then							-- special maint for AV/M which has a lot of 'false' positives right now
			utilities.set_message ('maint_others_avm')
		else
			utilities.set_message ('maint_others');
		end
	end
	Others = utilities.is_set (Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if utilities.is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if utilities.is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	local TitleNote = A['TitleNote'];
	TitleNote = utilities.is_set (TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if utilities.is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%n?%.?$') or Edition:match ('%f[%a][Ee]dition$') then -- Ed, ed, Ed., ed., Edn, edn, Edn., edn.
			utilities.set_message ('err_extra_text_edition');					 -- add error message
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = utilities.is_set (Series) and wrap_msg ('series', {sepc, Series}) or &quot;&quot;;	-- not the same as SeriesNum
	local Agency = A['Agency'];
	Agency = utilities.is_set (Agency) and wrap_msg ('agency', {sepc, Agency}) or &quot;&quot;;
	Volume = format_volume_issue (Volume, Issue, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	if utilities.is_set (AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = utilities.substitute (retrv_text, AccessDate);				-- add retrieved text

		AccessDate = utilities.substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if utilities.is_set (ID) then ID = sepc .. &quot; &quot; .. ID; end
	
	local Docket = A['Docket'];
   	if &quot;thesis&quot; == config.CitationClass and utilities.is_set (Docket) then
		ID = sepc .. &quot; Docket &quot; .. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and utilities.is_set (Docket) then		-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	if utilities.is_set (URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URL_origin, UrlAccess );
	end

	local Quote = A['Quote'];
	local TransQuote = A['TransQuote'];
	local ScriptQuote = A['ScriptQuote'];
	if utilities.is_set (Quote) or utilities.is_set (TransQuote) or utilities.is_set (ScriptQuote) then

		if utilities.is_set (Quote) then
			if Quote:sub(1, 1) == '&quot;' and Quote:sub(-1, -1) == '&quot;' then			-- if first and last characters of quote are quote marks
				Quote = Quote:sub(2, -2);										-- strip them off
			end
		end

		Quote = utilities.wrap_style ('quoted-text', Quote );					-- wrap in &lt;q&gt;...&lt;/q&gt; tags
	
		if utilities.is_set (ScriptQuote) then
			Quote = script_concatenate (Quote, ScriptQuote, 'script-quote');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after quote is wrapped
		end

		if utilities.is_set (TransQuote) then
			if TransQuote:sub(1, 1) == '&quot;' and TransQuote:sub(-1, -1) == '&quot;' then -- if first and last characters of |trans-quote are quote marks
				TransQuote = TransQuote:sub(2, -2); -- strip them off
			end
			Quote = Quote .. &quot; &quot; .. utilities.wrap_style ('trans-quoted-title', TransQuote );
		end

		if utilities.is_set (QuotePage) or utilities.is_set (QuotePages) then	-- add page prefix
			local quote_prefix = '';
			if utilities.is_set (QuotePage) then
				extra_text_in_page_check (QuotePage, 'quote-page');				-- add to maint cat if |quote-page= value begins with what looks like p., pp., etc.
				if not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePage}), '', '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePage}), '', '', '';
				end
			elseif utilities.is_set (QuotePages) then
				extra_text_in_page_check (QuotePages, 'quote-pages');			-- add to maint cat if |quote-pages= value begins with what looks like p., pp., etc.
				if tonumber(QuotePages) ~= nil and not NoPP then				-- if only digits, assume single page
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePages}), '', '';
				elseif not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['pp-prefix'], {sepc, QuotePages}), '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePages}), '', '';
				end
			end
                        
			Quote = quote_prefix .. &quot;: &quot; .. Quote;
		else
			Quote = sepc .. &quot; &quot; .. Quote;
		end

		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	-- We check length of PostScript here because it will have been nuked by
	-- the quote parameters. We'd otherwise emit a message even if there wasn't
	-- a displayed postscript.
	-- TODO: Should the max size (1) be configurable?
	-- TODO: Should we check a specific pattern?
	if utilities.is_set(PostScript) and mw.ustring.len(PostScript) &gt; 1 then
		utilities.set_message ('maint_postscript')
	end
	
	local Archived;
	if utilities.is_set (ArchiveURL) then
		local arch_text;
		if not utilities.is_set (ArchiveDate) then
			utilities.set_message ('err_archive_missing_date');
			ArchiveDate = '';													-- empty string for concatenation
		end
		if &quot;live&quot; == UrlStatus then
			arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if utilities.is_set (ArchiveDate) then
				Archived = sepc .. ' ' .. utilities.substitute ( cfg.messages['archived-live'],
					{external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil) .. ArchiveFormat, ArchiveDate } );
			else
				Archived = '';
			end
			if not utilities.is_set (OriginalURL) then
				utilities.set_message ('err_archive_missing_url');
				Archived = '';													-- empty string for concatenation
			end
		elseif utilities.is_set (OriginalURL) then								-- UrlStatus is empty, 'dead', 'unfit', 'usurped', 'bot: unknown'
			if utilities.in_array (UrlStatus, {'unfit', 'usurped', 'bot: unknown'}) then
				arch_text = cfg.messages['archived-unfit'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. ' ' .. arch_text .. ArchiveDate;				-- format already styled
				if 'bot: unknown' == UrlStatus then
					utilities.set_message ('maint_bot_unknown');				-- and add a category if not already added
				else
					utilities.set_message ('maint_unfit');						-- and add a category if not already added
				end
			else																-- UrlStatus is empty, 'dead'
				arch_text = cfg.messages['archived-dead'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				if utilities.is_set (ArchiveDate) then
					Archived = sepc .. &quot; &quot; .. utilities.substitute ( arch_text,
						{ external_link( OriginalURL, cfg.messages['original'], OriginalURL_origin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
				else
					Archived = '';												-- unset for concatenation
				end
			end	
		else																	-- OriginalUrl not set
			arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			utilities.set_message ('err_archive_missing_url');
			Archived = '';														-- empty string for concatenation
		end
	elseif utilities.is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = '';
	end
	
	local Lay = '';
	local LaySource = A['LaySource'];
	local LayURL = A['LayURL'];
	local LayFormat = A['LayFormat'];
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	if utilities.is_set (LayURL) then
		if utilities.is_set (LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if utilities.is_set (LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. utilities.safe_for_italics (LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif utilities.is_set (LayFormat) then									-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	local TranscriptURL = A['TranscriptURL']
	local TranscriptFormat = A['TranscriptFormat'];
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');
	local Transcript = A['Transcript'];
	local TranscriptURL_origin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL
	if utilities.is_set (Transcript) then
		if utilities.is_set (TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURL_origin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif utilities.is_set (TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURL_origin, nil );
	end

	local Publisher;
	if utilities.is_set (PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if utilities.is_set (PublisherName) then
		if utilities.is_set (PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif utilities.is_set (PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	local TransPeriodical =  A['TransPeriodical'];
	local TransPeriodical_origin =  A:ORIGIN ('TransPeriodical');
	-- Several of the above rely upon detecting this as nil, so do it last.
	if (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical)) then
		if utilities.is_set (Title) or utilities.is_set (TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		else 
			Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		end
	end
	
	local Language = A['Language'];
	if utilities.is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc.
	else
		Language='';															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then									-- cite speech only
		TitleNote = TitleType;													-- move TitleType to TitleNote so that it renders ahead of |event=
		TitleType = '';															-- and unset

		if utilities.is_set (Periodical) then									-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if utilities.is_set (Conference) then								-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;							-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
		if utilities.is_set (Others) then Others = safe_join ({Others, sepc .. &quot; &quot;}, sepc) end		-- add terminal punctuation &amp; space; check for dup sepc; TODO why do we need to do this here?
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (Periodical) then		-- special cases for book cites
		if utilities.is_set (Contributors) then									-- when we are citing foreword, preface, introduction, etc.
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if utilities.is_set (Chapter) then										-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif utilities.is_set (Periodical) then								-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local Via = A['Via'];
	Via = utilities.is_set (Via) and  wrap_msg ('via', Via) or '';
	local idcommon;
	if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then	-- special case for cite AV media &amp; cite episode position transcript
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, Lay, Quote }, sepc );
	else
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, Lay, Quote }, sepc );
	end
	
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	local OrigDate = A['OrigDate'];
	OrigDate = utilities.is_set (OrigDate) and wrap_msg ('origdate', OrigDate) or '';
	if utilities.is_set (Date) then
		if utilities.is_set (Authors) or utilities.is_set (Editors) then		-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date .. &quot;)&quot; .. OrigDate .. sepc .. &quot; &quot;;				-- in parentheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon, -1, -1) == sepc) then						-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigDate;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigDate;							-- Date begins with sepc
			end
		end
	end	
	if utilities.is_set (Authors) then
		if (not utilities.is_set (Date)) then									-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if utilities.is_set (Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then
					in_text = in_text:lower()									-- lowercase for cs2
				end
			end
			if EditorCount &lt;= 1 then
				post_text = &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot;;				-- be consistent with no-author, no-date case
			else
				post_text = &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot;;
			end
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Contributors) then									-- book cite and we're citing the intro, preface, etc.
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if utilities.is_set (Editors) and utilities.is_set (Date) then		-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not utilities.is_set (Date)) then								-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif utilities.is_set (Editors) then
		if utilities.is_set (Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editor'];
			else
				Editors = Editors .. &quot;, &quot; .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if utilities.is_set (PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc ); 								-- Deals with italics, spaces, etc.
		text = text:sub(1, -sepc:len() - 1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite&gt; element
	local options_t = {};
	options_t.class = cite_class_attribute_make (config.CitationClass, Mode);

	local Ref = is_valid_parameter_value (A['Ref'], A:ORIGIN('Ref'), cfg.keywords_lists['ref'], nil, true);	-- nil when |ref=harv; A['Ref'] else

	if 'none' ~= cfg.keywords_xlate[(Ref and Ref:lower()) or ''] then
		local namelist_t = {};													-- holds selected contributor, author, editor name list
		local year = first_set ({Year, anchor_year}, 2);						-- Year first for legacy citations and for YMD dates that require disambiguation

		if #c &gt; 0 then															-- if there is a contributor list
			namelist_t = c;														-- select it
		elseif #a &gt; 0 then														-- or an author list
			namelist_t = a;
		elseif #e &gt; 0 then														-- or an editor list
			namelist_t = e;
		end
		local citeref_id;
		if #namelist_t &gt; 0 then													-- if there are names in namelist_t
			citeref_id = make_citeref_id (namelist_t, year);					-- go make the CITEREF anchor
			if mw.uri.anchorEncode (citeref_id) == ((Ref and mw.uri.anchorEncode (Ref)) or '') then	-- Ref may already be encoded (by {{sfnref}}) so citeref_id must be encoded before comparison
				utilities.set_message ('maint_ref_duplicates_default');
			end
		else
			citeref_id = '';													-- unset
		end
		options_t.id = Ref or citeref_id;
	end

	if string.len (text:gsub('%b&lt;&gt;', '')) &lt;= 2 then								-- remove html and html-like tags; then get length of what remains; 
		z.error_cats_t = {};													-- blank the categories list
		z.error_msgs_t = {};													-- blank the error messages list
		OCinSoutput = nil;														-- blank the metadata string
		text = '';																-- blank the the citation
		utilities.set_message ('err_empty_citation');							-- set empty citation message and category
	end
	
	local render_t = {};														-- here we collect the final bits for concatenation into the rendered citation

	if utilities.is_set (options_t.id) then										-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render_t, utilities.substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options_t.id), mw.text.nowiki(options_t.class), text}));	-- when |ref= is set or when there is a namelist
	else
		table.insert (render_t, utilities.substitute (cfg.presentation['cite'], {mw.text.nowiki(options_t.class), text}));	-- when |ref=none or when namelist_t empty and |ref= is missing or is empty
	end		

	if OCinSoutput then															-- blanked when citation is 'empty' so don't bother to add boilerplate metadata span
		table.insert (render_t, utilities.substitute (cfg.presentation['ocins'], OCinSoutput));	-- format and append metadata to the citation
	end

	local template_name = ('citation' == config.CitationClass) and 'citation' or 'cite ' .. (cfg.citation_class_map_t[config.CitationClass] or config.CitationClass);
	local template_link = '[[Template:' .. template_name .. '|' .. template_name .. ']]';
	local msg_prefix = '&lt;code class=&quot;cs1-code&quot;&gt;{{' .. template_link .. '}}&lt;/code&gt;: ';

	if 0 ~= #z.error_msgs_t then
		mw.addWarning (utilities.substitute (cfg.messages.warning_msg_e, template_link));

		table.insert (render_t, ' ');											-- insert a space between citation and its error messages
		table.sort (z.error_msgs_t);											-- sort the error messages list; sorting includes wrapping &lt;span&gt; and &lt;code&gt; tags; hidden-error sorts ahead of visible-error

		local hidden = true;													-- presume that the only error messages emited by this template are hidden
		for _, v in ipairs (z.error_msgs_t) do									-- spin through the list of error messages
			if v:find ('cs1-visible-error', 1, true) then						-- look for the visible error class name
				hidden = false;													-- found one; so don't hide the error message prefix
				break;															-- and done because no need to look further
			end
		end

		z.error_msgs_t[1] = table.concat ({utilities.error_comment (msg_prefix, hidden), z.error_msgs_t[1]});	-- add error message prefix to first error message to prevent extraneous punctuation
		table.insert (render_t, table.concat (z.error_msgs_t, '; '));			-- make a big string of error messages and add it to the rendering
	end

	if 0 ~= #z.maint_cats_t then
		mw.addWarning (utilities.substitute (cfg.messages.warning_msg_m, template_link));

		table.sort (z.maint_cats_t);											-- sort the maintenance messages list

		local maint_msgs_t = {};												-- here we collect all of the maint messages

		if 0 == #z.error_msgs_t then											-- if no error messages
			table.insert (maint_msgs_t, msg_prefix);							-- insert message prefix in maint message livery
		end
		
		for _, v in ipairs( z.maint_cats_t ) do									-- append maintenance categories
			table.insert (maint_msgs_t, 										-- assemble new maint message and add it to the maint_msgs_t table
				table.concat ({v, ' (', utilities.substitute (cfg.messages[':cat wikilink'], v), ')'})
				);
		end
		table.insert (render_t, utilities.substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs_t, ' ')));	-- wrap the group of maint messages with proper presentation and save
	end

	if not no_tracking_cats then
		for _, v in ipairs (z.error_cats_t) do									-- append error categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
		end
		for _, v in ipairs (z.maint_cats_t) do									-- append maintenance categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
		end
		for _, v in ipairs (z.prop_cats_t) do									-- append properties categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
		end
	end

	return table.concat (render_t);												-- make a big string and done
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class, empty)
	local name = tostring (name);
	local enum_name;															-- for enumerated parameters, is name with enumerator replaced with '#'
	local state;
	local function state_test (state, name)										-- local function to do testing of state values
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			if empty then return nil; end										-- empty deprecated parameters are treated as unknowns
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
		if 'tracked' == state then
			local base_name = name:gsub ('%d', '');								-- strip enumerators from parameter names that have them to get the base name
			utilities.add_prop_cat ('tracked-param', {base_name}, base_name);	-- add a properties category; &lt;base_name&gt; modifies &lt;key&gt;
			return true;
		end
		return nil;
	end		

	if name:find ('#') then														-- # is a cs1|2 reserved character so parameters with # not permitted
		return nil;
	end

	if utilities.in_array (cite_class, whitelist.preprint_template_list ) then	-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[name];
		if true == state_test (state, name) then return true; end

		state = whitelist.preprint_arguments[cite_class][name];					-- look in the parameter-list for the template identified by cite_class
		if true == state_test (state, name) then return true; end

																				-- limited enumerated parameters list
		enum_name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );										-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
		state = whitelist.limited_numbered_arguments[enum_name];
		if true == state_test (state, name) then return true; end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates

	if utilities.in_array (cite_class, whitelist.unique_param_template_list) then 	-- experiment for template-specific parameters for templates that accept parameters from the basic argument list
		state = whitelist.unique_arguments[cite_class][name];					-- look in the template-specific parameter-lists for the template identified by cite_class
		if true == state_test (state, name) then return true; end
	end																			-- if here, fall into general validation
		
	state = whitelist.basic_arguments[name];									-- all other templates; all normal parameters allowed
	if true == state_test (state, name) then return true; end

																				-- all enumerated parameters allowed
	enum_name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
	state = whitelist.numbered_arguments[enum_name];
	if true == state_test (state, name) then return true; end

	return false;																-- not supported because not found or name is set to nil
end


--[=[-------------------------&lt; I N T E R _ W I K I _ C H E C K &gt;----------------------------------------------

check &lt;value&gt; for inter-language interwiki-link markup.  &lt;prefix&gt; must be a MediaWiki-recognized language
code.  when these values have the form (without leading colon):
	[[&lt;prefix&gt;:link|label]] return label as plain-text
	[[&lt;prefix&gt;:link]] return &lt;prefix&gt;:link as plain-text

return value as is else

]=]

local function inter_wiki_check (parameter, value)
	local prefix = value:match ('%[%[(%a+):');									-- get an interwiki prefix if one exists
	local _;
	
	if prefix and cfg.inter_wiki_map[prefix:lower()] then						-- if prefix is in the map, needs preceding colon so
		utilities.set_message ('err_bad_paramlink', parameter);					-- emit an error message
		_, value, _ = utilities.is_wikilink (value);							-- extract label portion from wikilink
	end
	return value;
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe.  There are two tests made:
	{{cite ... |title=Title access-date=2016-03-17}}	-- the first parameter has a value and whitespace separates that value from the missing pipe parameter name
	{{cite ... |title=access-date=2016-03-17}}			-- the first parameter has no value (whitespace after the first = is trimmed by MediaWiki)
cs1|2 shares some parameter names with XML/HTML attributes: class=, title=, etc.  To prevent false positives XML/HTML
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (parameter, value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove XML/HTML tags because attributes: class=, title=, etc.

	capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then										-- if the capture is a valid parameter name
		utilities.set_message ('err_missing_pipe', parameter);
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ P U N C T &gt;--------------------------------------

look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_punc (param, value)
	if 'number' == type (param) then
		return;
	end
	
	param = param:gsub ('%d+', '#');											-- enumerated name-list mask params allow terminal punct; normalize 
	if cfg.punct_skip[param] then
		return;																	-- parameter name found in the skip table so done
	end
	
	if value:match ('[,;:]$') then
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
	if value:match ('^=') then													-- sometimes an extraneous '=' character appears ...
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ U R L &gt;------------------------------------------

look for extraneous url parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_url (url_param_t)
	local url_error_t = {};
	
	check_for_url (url_param_t, url_error_t);									-- extraneous url check
	if 0 ~= #url_error_t then													-- non-zero when there are errors
		table.sort (url_error_t);
		utilities.set_message ('err_param_has_ext_link', {utilities.make_sep_list (#url_error_t, url_error_t)});	-- add this error message
	end
end


--[[--------------------------&lt; C I T A T I O N &gt;--------------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

local function citation(frame)
	Frame = frame;																-- save a copy in case we need to display an error message in preview mode
	local sandbox = '/sandbox'													-- i18n: replace this rvalue with the name that your wiki uses to identify sandbox subpages
	is_sandbox = nil ~= string.find (frame:getTitle(), sandbox, 1, true);		-- is this invoke the sandbox module?
	sandbox = is_sandbox and sandbox or '';										-- use i18n sandbox to load sandbox modules when this module is the sandox; live modules else

	local pframe = frame:getParent()
	local styles;
	
	cfg = mw.loadData ('Module:Citation/CS1/Configuration' .. sandbox);			-- load sandbox versions of support modules when {{#invoke:Citation/CS1/sandbox|...}}; live modules else
	whitelist = mw.loadData ('Module:Citation/CS1/Whitelist' .. sandbox);
	utilities = require ('Module:Citation/CS1/Utilities' .. sandbox);
	validation = require ('Module:Citation/CS1/Date_validation' .. sandbox);
	identifiers = require ('Module:Citation/CS1/Identifiers' .. sandbox);
	metadata = require ('Module:Citation/CS1/COinS' .. sandbox);
	styles = 'Module:Citation/CS1' .. sandbox .. '/styles.css';

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the selected cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	is_preview_mode = not utilities.is_set (frame:preprocess ('{{REVISIONID}}'));

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text;															-- used as a flag

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do											-- get parameters from the {{#invoke}} frame
		config[k] = v;
	--	args[k] = v;															-- crude debug support that allows us to render a citation from module {{#invoke:}}; skips parameter validation; TODO: keep?
	end	

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	local empty_unknowns = {};													-- sequence table to hold empty unknown params for error message listing
	for k, v in pairs( pframe.args ) do											-- get parameters from the parent (template) frame
		v = mw.ustring.gsub (v, '^%s*(.-)%s*$', '%1');							-- trim leading/trailing whitespace; when v is only whitespace, becomes empty string
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				if type (k) ~= 'string' then									-- exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text = utilities.set_message ('err_text_ignored', {v});
					end
				elseif validate (k:lower(), config.CitationClass) then 
					error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, k:lower()});	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						if is_sandbox then										-- did the {{#invoke:}} use sandbox version?
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions/sandbox' );	-- use the sandbox version
						else
							suggestions = mw.loadData( 'Module:Citation/CS1/Suggestions' );			-- use the live version
						end
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no capture in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = utilities.substitute (param, capture);		-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, param});	-- set the suggestion error message
							else
								error_text = utilities.set_message ('err_parameter_ignored', {k});	-- suggested param not supported by this template
								v = '';											-- unset
							end
						end
					end
					if not utilities.is_set (error_text) then					-- couldn't match with a pattern, is there an explicit suggestion?						
						if (suggestions.suggestions[ k:lower() ] ~= nil) and validate (suggestions.suggestions[ k:lower() ], config.CitationClass) then
							utilities.set_message ('err_parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]});
						else
							utilities.set_message ('err_parameter_ignored', {k});
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
			end

			args[k] = v;														-- save this parameter and its value

		elseif not utilities.is_set (v) then									-- for empty parameters
			if not validate (k, config.CitationClass, true) then				-- is this empty parameter a valid parameter
				k = ('' == k) and '(empty string)' or k;						-- when k is empty string (or was space(s) trimmed to empty string), replace with descriptive text
				table.insert (empty_unknowns, utilities.wrap_style ('parameter', k));	-- format for error message and add to the list
			end
																				-- crude debug support that allows us to render a citation from module {{#invoke:}} TODO: keep?
	--	elseif args[k] ~= nil or (k == 'postscript') then						-- when args[k] has a value from {{#invoke}} frame (we don't normally do that)
	--		args[k] = v;														-- overwrite args[k] with empty string from pframe.args[k] (template frame); v is empty string here
		end																		-- not sure about the postscript bit; that gets handled in parameter validation; historical artifact?
	end	

	if 0 ~= #empty_unknowns then												-- create empty unknown error message
		utilities.set_message ('err_param_unknown_empty', {
			1 == #empty_unknowns and '' or 's',
			utilities.make_sep_list (#empty_unknowns, empty_unknowns)
			});
	end

	local url_param_t = {};

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);											-- look for invisible characters
		end
		has_extraneous_punc (k, v);												-- look for extraneous terminal punctuation in parameter values
		missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?
		args[k] = inter_wiki_check (k, v);										-- when language interwiki-linked parameter missing leading colon replace with wiki-link label

		if 'string' == type (k) and not cfg.url_skip[k] then					-- when parameter k is not positional and not in url skip table
			url_param_t[k] = v;													-- make a parameter/value list for extraneous url check
		end
	end

	has_extraneous_url (url_param_t);											-- look for url in parameter values where a url does not belong

	return table.concat ({
		frame:extensionTag ('templatestyles', '', {src=styles}),
		citation0( config, args)
	});
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {citation = citation};</text>
      <sha1>5n16iqneaigpy2t8yngx92i9b4sg6ua</sha1>
    </revision>
    <revision>
      <id>4750</id>
      <parentid>4749</parentid>
      <timestamp>2023-01-14T14:43:47Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4750</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="213713" sha1="i7z918lp7p82rgiud4zhl7nejkm3ae9" xml:space="preserve">require('strict');

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------

each of these counts against the Lua upvalue limit

]]

local validation;																-- functions in Module:Citation/CS1/Date_validation

local utilities;																-- functions in Module:Citation/CS1/Utilities
local z = {};																	-- table of tables in Module:Citation/CS1/Utilities

local identifiers;																-- functions and tables in Module:Citation/CS1/Identifiers
local metadata;																	-- functions in Module:Citation/CS1/COinS
local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;---------------

declare variables here that have page-wide scope that are not brought in from
other modules; that are created here and used here

]]

local added_deprecated_cat;														-- Boolean flag so that the category is added only once
local added_vanc_errs;															-- Boolean flag so we only emit one Vancouver error / category
local added_generic_name_errs;													-- Boolean flag so we only emit one generic name error / category and stop testing names once an error is encountered
local Frame;																	-- holds the module's frame table
local is_preview_mode;															-- true when article is in preview mode; false when using 'Preview page with this template' (previewing the module)
local is_sandbox;																-- true when using sandbox modules to render citation


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if utilities.is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a Boolean declared in page scope variables above

]]

local function add_vanc_error (source, position)
	if added_vanc_errs then return end
		
	added_vanc_errs = true;														-- note that we've added this category
	utilities.set_message ('err_vancouver', {source, position});
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a URI scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of TLDs: https://www.iana.org/domains/root/db

RFC 952 (modified by RFC 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the TLD.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a URL with a scheme) will be stripped
here.  Perhaps not necessary but retained in case it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ASCII characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the TLD) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and TLD or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%w]') then											-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at Wikisource
		return false;
	end

	local patterns = {															-- patterns that look like URLs
		'%f[%w][%w][%w%-]+[%w]%.%a%a+$',										-- three or more character hostname.hostname or hostname.tld
		'%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$',									-- internationalized domain name with ACE prefix
		'%f[%a][qxz]%.com$',													-- assigned one character .com hostname (x.com times out 2015-12-10)
		'%f[%a][iq]%.net$',														-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		'%f[%w][%w]%.%a%a$',													-- one character hostname and ccTLD (2 chars)
		'%f[%w][%w][%w]%.%a%a+$',												-- two character hostname and TLD
		'^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?',								-- IPv4 address
		}

	for _, pattern in ipairs (patterns) do										-- loop through the patterns list
		if domain:match (pattern) then
			return true;														-- if a match then we think that this thing that purports to be a URL is a URL
		end
	end

	for _, d in ipairs (cfg.single_letter_2nd_lvl_domains_t) do					-- look for single letter second level domain names for these top level domains
		if domain:match ('%f[%w][%w]%.' .. d) then
			return true
		end
	end
	return false;																-- no matches, we don't know what this thing is
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a URL appear to be a valid URL; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if utilities.is_set (scheme) then											-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when URL is protocol-relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a URL into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following TLD) (if any) and any path(/), query(?) or fragment(#).

If protocol-relative URL, return nil scheme and domain else return nil for both scheme and domain.

When not protocol-relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Any URL that does not have news: scheme must have authority indicator (//).  TODO: are there other common schemes
like news: that don't use authority indicator?

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol-relative URL
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		if utilities.is_set (authority) then
			authority = authority:gsub ('//', '', 1);							-- replace place 1 pair of '/' with nothing;
			if utilities.is_set(authority) then									-- if anything left (1 or 3+ '/' where authority should be) then
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		else
			if not scheme:match ('^news:') then									-- except for news:..., MediaWiki won't link URLs that do not have authority indicator; TODO: a better way to do this test?
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link=, etc. for properly formatted content: no wikilinks, no URLs

Link parameters are to hold the title of a Wikipedia article, so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki URLs and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid URL (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid URL (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from URL; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid URL
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wiki-linked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

check &lt;link&gt; for inter-language interwiki-link prefix.  prefix must be a MediaWiki-recognized language
code and must begin with a colon.

]]

local function link_title_ok (link, lorig, title, torig)
	local orig;
	if utilities.is_set (link) then 											-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		elseif link:match ('^%a+:') then										-- if the link is what looks like an interwiki
			local prefix = link:match ('^(%a+):'):lower();						-- get the interwiki prefix

			if cfg.inter_wiki_map[prefix] then									-- if prefix is in the map, must have preceding colon
				orig = lorig;													-- flag as error
			end
		end
	end

	if utilities.is_set (orig) then
		link = '';																-- unset
		utilities.set_message ('err_bad_paramlink', orig);						-- URL or wikilink in |title= with |title-link=;
	end
	
	return link;																-- link if ok, empty string else
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the URL into scheme and domain
portions, or for protocol-relative (//example.com) URLs, just the domain.  Use is_url() to validate the two
portions of the URL.  If both are valid, or for protocol-relative if domain is valid, return true, else false.

Because it is different from a standard URL, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper URL
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from URL;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a URL.  The test will also find external wikilinks
that use protocol-relative URLs. Also finds bare URLs.

The frontier pattern prevents a match on interwiki-links which are similar to scheme:path URLs.  The tests that
find bracketed URLs are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext. wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol-relative ext. wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare URL with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol-relative bare URL: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a URL
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list, error_list)
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a URL add an error message
			table.insert (error_list, utilities.wrap_style ('parameter', k));
		end
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		utilities.set_message ('err_wikilink_in_url', {});
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link (URL, label, source, access)
	local err_msg = '';
	local domain;
	local path;
	local base_url;

	if not utilities.is_set (label) then
		label = URL;
		if utilities.is_set (source) then
			utilities.set_message ('err_bare_url_missing_title', {utilities.wrap_style ('parameter', source)});
		else
			error (cfg.messages[&quot;bare_url_no_origin&quot;]);							-- programmer error; valid parameter name does not have matching meta-parameter
		end			
	end
	if not check_url (URL) then
		utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)});
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the URL into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['['] = '%5b', [']'] = '%5d'});			-- replace '[' and ']' with their percent-encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat ({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wiki-markup URL

	if utilities.is_set (access) then											-- access level (subscription, registration, limited)
		base_url = utilities.substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end

	return base_url;
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a Boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		utilities.set_message ('err_deprecated_params', {name});				-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wiki-markup) are not kerned.

Replaces Unicode quote marks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc.; not for book titles.

]=]

local function kern_quotes (str)
	local cap = '';
	local wl_type, label, link;

	wl_type, label, link = utilities.is_wikilink (str);							-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-left'], str);
			str = utilities.substitute (cfg.presentation['kern-right'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = utilities.substitute (cfg.presentation['kern-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label = mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label = mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap = mw.ustring.match (label, &quot;^([\&quot;\'][^\'].+)&quot;);						-- match leading double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-left'], cap);
		end
	
		cap = mw.ustring.match (label, &quot;^(.+[^\'][\&quot;\'])$&quot;)						-- match trailing double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-right'], cap);
		end
		
		if 2 == wl_type then
			str = utilities.make_wikilink (link, label);						-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin-based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate RTL languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO 639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO 639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title=, |script-chapter=, |script-&lt;periodical&gt;=

]]

local function format_script_value (script_value, script_param)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%l?%s*:') then									-- if first 3 or 4 non-space characters are script language prefix
		lang = script_value:match('^(%l%l%l?)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not utilities.is_set (lang) then
			utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['missing title part']});		-- prefix without 'title'; add error message
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_code_remap[lang] or mw.language.fetchLanguageName( lang, cfg.this_wiki_code );	-- get language name so that we can use it to categorize
		if utilities.is_set (name) then											-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l+%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if utilities.in_array (lang, cfg.script_lang_codes) then
				utilities.add_prop_cat ('script', {name, lang})
			else
				utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['unknown language code']});	-- unknown script-language; add error message
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['invalid language code']});		-- invalid language code; add error message
			lang = '';															-- invalid so set lang to empty string
		end
	else
		utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['missing prefix']});				-- no language code prefix; add error message
	end
	script_value = utilities.substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is RTL

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script
value has been wrapped in &lt;bdi&gt; tags.

]]

local function script_concatenate (title, script, script_param)
	if utilities.is_set (script) then
		script = format_script_value (script, script_param);					-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; returns empty string on error
		if utilities.is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not utilities.is_set ( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return utilities.substitute ( msg, str );								-- including template text
	else
		return utilities.substitute ( cfg.messages[key], str );
	end		
end


--[[----------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;-------------------

Makes a Wikisource URL from Wikisource interwiki-link.  Returns the URL and appropriate
label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;
	local wikisource_prefix = table.concat ({'https://', cfg.this_wiki_code, '.wikisource.org/wiki/'});

	wl_type, D, L = utilities.is_wikilink (str);								-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 1 == wl_type then													-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end

	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable URL
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent-encoding of fragment marker
	end

	return ws_url, ws_label, L or D;											-- return proper URL or nil and a label or nil
end


--[[----------------&lt; F O R M A T _ P E R I O D I C A L &gt;-----------------------

Format the three periodical parameters: |script-&lt;periodical&gt;=, |&lt;periodical&gt;=,
and |trans-&lt;periodical&gt;= into a single Periodical meta-parameter.

]]

local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)

	if not utilities.is_set (periodical) then
		periodical = '';														-- to be safe for concatenation
	else
		periodical = utilities.wrap_style ('italic-title', periodical);			-- style 
	end

	periodical = script_concatenate (periodical, script_periodical, script_periodical_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (trans_periodical) then
		trans_periodical = utilities.wrap_style ('trans-italic-title', trans_periodical);
		if utilities.is_set (periodical) then
			periodical = periodical .. ' ' .. trans_periodical;
		else																	-- here when trans-periodical without periodical or script-periodical
			periodical = trans_periodical;
			utilities.set_message ('err_trans_missing_title', {'periodical'});
		end
	end

	return periodical;
end


--[[------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;---------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=,
and |chapter-url= into a single chapter meta- parameter (chapter_url_source used
for error messages).

]]

local function format_chapter_title (script_chapter, script_chapter_source, chapter, chapter_source, trans_chapter, trans_chapter_source, chapter_url, chapter_url_source, no_quotes, access)
	local ws_url, ws_label, L = wikisource_url_make (chapter);					-- make a wikisource URL and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', ' ');									-- replace underscore separators with space characters
		chapter = ws_label;
	end

	if not utilities.is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from module provided quote marks
			chapter = utilities.wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, script_chapter, script_chapter_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (chapter_url) then
		chapter = external_link (chapter_url, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');	-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if utilities.is_set (trans_chapter) then
		trans_chapter = utilities.wrap_style ('trans-quoted-title', trans_chapter);
		if utilities.is_set (chapter) then
			chapter = chapter .. ' ' .. trans_chapter;
		else																	-- here when trans_chapter without chapter or script-chapter
			chapter = trans_chapter;
			chapter_source = trans_chapter_source:match ('trans%-?(.+)');		-- when no chapter, get matching name from trans-&lt;param&gt;
			utilities.set_message ('err_trans_missing_title', {chapter_source});
		end
	end

	return chapter;
end


--[[----------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;-------------------

This function searches a parameter's value for non-printable or invisible characters.
The search stops at the first match.

This function will detect the visible replacement character when it is part of the Wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers
(gallery, math, pre, ref) and identifies them with a slightly different error message.
See also coins_cleanup().

Output of this function is an error message that identifies the character or the
Unicode group, or the stripmarker that was detected along with its position (or,
for multi-byte characters, the position of its first byte) in the parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local stripmarker;															-- boolean set true when a stripmarker is found

	capture = string.match (v, '[%w%p ]*');										-- test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no Unicode characters
		return;
	end

	for _, invisible_char in ipairs (cfg.invisible_chars) do
		local char_name = invisible_char[1];									-- the character or group name
		local pattern = invisible_char[2];										-- the pattern used to find it
		position, _, capture = mw.ustring.find (v, pattern);					-- see if the parameter value contains characters that match the pattern
		
		if position and (cfg.invisible_defs.zwj == capture) then				-- if we found a zero-width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- it's ok if one of the Indic scripts
				position = nil;													-- unset position
			elseif cfg.emoji_t[mw.ustring.codepoint (v, position+1)] then			-- is zwj followed by a character listed in emoji{}?
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and utilities.in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and cfg.invisible_defs.del == capture then	-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture and not (cfg.invisible_defs.del == capture or cfg.invisible_defs.zwj == capture) then
					err_msg = capture .. ' ' .. char_name;
				else
					err_msg = char_name .. ' ' .. 'character';
				end

				utilities.set_message ('err_invisible_char', {err_msg, utilities.wrap_style ('parameter', param), position});	-- add error message
				return;															-- and done with this parameter
			end
		end
	end
end


--[[-------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------

Argument wrapper.  This function provides support for argument mapping defined
in the configuration file so that multiple names can be transparently aliased to
single internal variable.

]]

local function argument_wrapper ( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function ( self, k )
			local dummy = self[k];												-- force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = utilities.select_one ( args, list, 'err_redundant_parameters' );
				if origin[k] == nil then
					origin[k] = '';												-- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] .. ': ' .. k);
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;-------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.
When date is DD MMMM YYYY or is MMMM DD, YYYY then wrap in nowrap span:
&lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap = '';
	local cap2 = '';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = utilities.substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = utilities.substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;---------------------

This function sets default title types (equivalent to the citation including
|type=&lt;default value&gt;) for those templates that have defaults. Also handles the
special case where it is desirable to omit the title type from the rendered citation
(|type=none).

]]

local function set_titletype (cite_class, title_type)
	if utilities.is_set (title_type) then
		if 'none' == cfg.keywords_xlate[title_type] then
			title_type = '';													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; S A F E _ J O I N &gt;-----------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'duplicate character'
		if 1 == #duplicate_char then											-- for single byte ASCII characters use the string library functions
			f.gsub = string.gsub
			f.match = string.match
			f.sub = string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub = mw.ustring.gsub
			f.match = mw.ustring.match
			f.sub = mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1, 1) == '&lt;' then										-- special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove HTML markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1, 1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc.?
				trim = false;
				end_chr = f.sub(str, -1, -1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr .. &quot;)&quot;				-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1, -2);									-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;''&quot; then		-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5, -1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;]]&quot; then		-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3, -1) == duplicate_char .. '&quot;]' then	-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2, -1) == duplicate_char .. &quot;]&quot; then	-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2, -1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1, -3);								-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains HTML markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows HTML markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value; 												-- add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;-----------------------------

returns true if suffix is properly formed Jr, Sr, or ordinal in the range 1–9.
Puncutation not allowed.

]]

local function is_suffix (suffix)
	if utilities.in_array (suffix, {'Jr', 'Sr', 'Jnr', 'Snr', '1st', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;-------------------

For Vancouver style, author/editor names are supposed to be rendered in Latin
(read ASCII) characters.  When a name uses characters that contain diacritical
marks, those characters are to be converted to the corresponding Latin
character. When a name is written using a non-Latin alphabet or logogram, that
name is to be transliterated into Latin characters. The module doesn't do this
so editors may/must.

This test allows |first= and |last= names to contain any of the letters defined
in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes.
	(http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;)
	or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written outside of the code editor and pasted here because the code editor
gets confused between character insertion point and cursor position. The test has
been rewritten to use decimal character escape sequence for the individual bytes
of the Unicode characters so that it is not necessary to use an external editor
to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first, suffix, position)
	if not suffix then
		if first:find ('[,%s]') then											-- when there is a space or comma, might be first name/initials + generational suffix
			first = first:match ('(.-)[,%s]+');									-- get name/initials
			suffix = first:match ('[,%s]+(.+)$');								-- get generational suffix
		end
	end
	if utilities.is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error (cfg.err_msg_supl.suffix, position);
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error (cfg.err_msg_supl['non-Latin char'], position);
			return false;														-- not a string of Latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-style=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period.
See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc.) to be rendered
as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format
because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the
Unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first, position)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just initials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error (cfg.err_msg_supl.suffix, position);			-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word

	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i], 1, 1));			-- insert the initial at end of initials table
		end
		i = i + 1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; I N T E R W I K I _ P R E F I X E N _ G E T &gt;----------------------------------

extract interwiki prefixen from &lt;value&gt;.  Returns two one or two values:
	false – no prefixen
	nil – prefix exists but not recognized
	project prefix, language prefix – when value has either of:
		:&lt;project&gt;:&lt;language&gt;:&lt;article&gt;
		:&lt;language&gt;:&lt;project&gt;:&lt;article&gt;
	project prefix, nil – when &lt;value&gt; has only a known single-letter prefix
	nil, language prefix – when &lt;value&gt; has only a known language prefix

accepts single-letter project prefixen: 'd' (wikidata), 's' (wikisource), and 'w' (wikipedia) prefixes; at this
writing, the other single-letter prefixen (b (wikibook), c (commons), m (meta), n (wikinews), q (wikiquote), and
v (wikiversity)) are not supported.

]]

local function interwiki_prefixen_get (value, is_link)
	if not value:find (':%l+:') then											-- if no prefix
		return false;															-- abandon; boolean here to distinguish from nil fail returns later
	end

	local prefix_patterns_linked_t = {											-- sequence of valid interwiki and inter project prefixen
		'^%[%[:([dsw]):(%l%l+):',												-- wikilinked; project and language prefixes
		'^%[%[:(%l%l+):([dsw]):',												-- wikilinked; language and project prefixes
		'^%[%[:([dsw]):',														-- wikilinked; project prefix
		'^%[%[:(%l%l+):',														-- wikilinked; language prefix
		}
		
	local prefix_patterns_unlinked_t = {										-- sequence of valid interwiki and inter project prefixen
		'^:([dsw]):(%l%l+):',													-- project and language prefixes
		'^:(%l%l+):([dsw]):',													-- language and project prefixes
		'^:([dsw]):',															-- project prefix
		'^:(%l%l+):',															-- language prefix
		}
	
	local cap1, cap2;
	for _, pattern in ipairs ((is_link and prefix_patterns_linked_t) or prefix_patterns_unlinked_t) do
		cap1, cap2 = value:match (pattern);
		if cap1 then
			break;																-- found a match so stop looking
		end
	end
	
	if cap1 and cap2 then														-- when both then :project:language: or :language:project: (both forms allowed)
		if 1 == #cap1 then														-- length == 1 then :project:language:
			if cfg.inter_wiki_map[cap2] then									-- is language prefix in the interwiki map?
				return cap1, cap2;												-- return interwiki project and interwiki language
			end
		else																	-- here when :language:project:
			if cfg.inter_wiki_map[cap1] then									-- is language prefix in the interwiki map?
				return cap2, cap1;												-- return interwiki project and interwiki language
			end
		end
		return nil;																-- unknown interwiki language
	elseif not (cap1 or cap2) then												-- both are nil?
		return nil;																-- we got something that looks like a project prefix but isn't; return fail
	elseif 1 == #cap1 then														-- here when one capture
		return cap1, nil;														-- length is 1 so return project, nil language
	else																		-- here when one capture and its length it more than 1
		if cfg.inter_wiki_map[cap1] then										-- is language prefix in the interwiki map?
			return nil, cap1;													-- return nil project, language
		end
	end
end


--[[--------------------------&lt; L I S T _ P E O P L E &gt;--------------------------

Formats a list of people (authors, contributors, editors, interviewers, translators) 

names in the list will be linked when
	|&lt;name&gt;-link= has a value
	|&lt;name&gt;-mask- does NOT have a value; masked names are presumed to have been
		rendered previously so should have been linked there

when |&lt;name&gt;-mask=0, the associated name is not rendered

]]

local function list_people (control, people, etal)
	local sep;
	local namesep;
	local format = control.format;
	local maximum = control.maximum;
	local name_list = {};

	if 'vanc' == format then													-- Vancouver-like name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between names is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between names is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub (-1, -1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if utilities.is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end		-- returned 0 is for EditorCount; not used for other names
	
	for i, person in ipairs (people) do
		if utilities.is_set (person.last) then
			local mask = person.mask;
			local one;
			local sep_one = sep;

			if utilities.is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			end
			
			if mask then
				local n = tonumber (mask);										-- convert to a number if it can be converted; nil else
				if n then
					one = 0 ~= n and string.rep(&quot;&amp;mdash;&quot;, n) or nil;			-- make a string of (n &gt; 0) mdashes, nil else, to replace name
					person.link = nil;											-- don't create link to name if name is replaces with mdash string or has been set nil
				else
					one = mask;													-- replace name with mask text (must include name-list separator)
					sep_one = &quot; &quot;;												-- modify name-list separator
				end
			else
				one = person.last;												-- get surname
				local first = person.first										-- get given name
				if utilities.is_set (first) then
					if (&quot;vanc&quot; == format) then									-- if Vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first, nil, i) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials (first, i);				-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
			end
			if utilities.is_set (person.link) then
				one = utilities.make_wikilink (person.link, one);				-- link author/editor
			end

			if one then															-- if &lt;one&gt; has a value (name, mdash replacement, or mask text replacement)
				local proj, tag = interwiki_prefixen_get (one, true);			-- get the interwiki prefixen if present

				if 'w' == proj and ('Wikipedia' == mw.site.namespaces.Project['name']) then
					proj = nil;													-- for stuff like :w:de:&lt;article&gt;, :w is unnecessary TODO: maint cat?
				end
				if proj then
					proj = ({['d'] = 'Wikidata', ['s'] = 'Wikisource', ['w'] = 'Wikipedia'})[proj];	-- :w (wikipedia) for linking from a non-wikipedia project
					if proj then 
						one = one .. utilities.wrap_style ('interproj', proj);	-- add resized leading space, brackets, static text, language name
						tag = nil;												-- unset; don't do both project and language
					end
				end
				if tag == cfg.this_wiki_code then
					tag = nil;													-- stuff like :en:&lt;article&gt; at en.wiki is pointless TODO: maint cat?
				end
				if tag then
					local lang = cfg.lang_code_remap[tag] or cfg.mw_languages_by_tag_t[tag];
					if lang then												-- error messaging done in extract_names() where we know parameter names
						one = one .. utilities.wrap_style ('interwiki', lang);	-- add resized leading space, brackets, static text, language name
					end
				end

				table.insert (name_list, one);									-- add it to the list of names
				table.insert (name_list, sep_one);								-- add the proper name-list separator
			end
		end
	end

	local count = #name_list / 2;												-- (number of names + number of separators) divided by 2
	if 0 &lt; count then 
		if 1 &lt; count and not etal then
			if 'amp' == format then
				name_list[#name_list-2] = &quot; &amp; &quot;;								-- replace last separator with ampersand text
			elseif 'and' == format then
				if 2 == count then
					name_list[#name_list-2] = cfg.presentation.sep_nl_and;		-- replace last separator with 'and' text
				else
					name_list[#name_list-2] = cfg.presentation.sep_nl_end;		-- replace last separator with '(sep) and' text
				end
			end
		end
		name_list[#name_list] = nil;											-- erase the last separator
	end

	local result = table.concat (name_list);									-- construct list
	if etal and utilities.is_set (result) then									-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. ' ' .. cfg.messages['et al'];					-- we've got a last-first list and etal so add et al.
	end
	
	return result, count;														-- return name-list string and count of number of names (count used for editor names only)
end


--[[--------------------&lt; M A K E _ C I T E R E F _ I D &gt;-----------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise
returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that
order.  year is Year or anchor_year.

]]

local function make_citeref_id (namelist, year)
	local names={};							-- a table for the one to four names and year
	for i,v in ipairs (namelist) do			-- loop through the list and take up to the first four last names
		names[i] = v.last
		if i == 4 then break end			-- if four then done
	end
	table.insert (names, year);				-- add the year at the end
	local id = table.concat(names);			-- concatenate names and year for CITEREF id
	if utilities.is_set (id) then			-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;				-- add the CITEREF portion
	else
		return '';							-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; C I T E _ C L A S S _A T T R I B U T E _M A K E &gt;------------------------------

construct &lt;cite&gt; tag class attribute for this citation.

&lt;cite_class&gt; – config.CitationClass from calling template
&lt;mode&gt; – value from |mode= parameter

]]

local function cite_class_attribute_make (cite_class, mode)
	local class_t = {};
	table.insert (class_t, 'citation');											-- required for blue highlight
	if 'citation' ~= cite_class then
		table.insert (class_t, cite_class);										-- identify this template for user css
		table.insert (class_t, utilities.is_set (mode) and mode or 'cs1');		-- identify the citation style for user css or javascript
	else
		table.insert (class_t, utilities.is_set (mode) and mode or 'cs2');		-- identify the citation style for user css or javascript
	end
	for _, prop_key in ipairs (z.prop_keys_t) do
		table.insert (class_t, prop_key);										-- identify various properties for user css or javascript
	end

	return table.concat (class_t, ' ');											-- make a big string and done
end


--[[---------------------&lt; N A M E _ H A S _ E T A L &gt;--------------------------

Evaluates the content of name parameters (author, editor, etc.) for variations on
the theme of et al.  If found, the et al. is removed, a flag is set to true and
the function returns the modified name and the flag.

This function never sets the flag to false but returns its previous state because
it may have been set by previous passes through this function or by the associated
|display-&lt;names&gt;=etal parameter

]]

local function name_has_etal (name, etal, nocat, param)

	if utilities.is_set (name) then												-- name can be nil in which case just return
		local patterns = cfg.et_al_patterns; 									-- get patterns from configuration
		
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns
			if name:match (pattern) then										-- if this 'et al' pattern is found in name
				name = name:gsub (pattern, '');									-- remove the offending text
				etal = true;													-- set flag (may have been set previously here or by |display-&lt;names&gt;=etal)
				if not nocat then												-- no categorization for |vauthors=
					utilities.set_message ('err_etal', {param});				-- and set an error if not added
				end
			end
		end
	end

	return name, etal;
end


--[[---------------------&lt; N A M E _ I S _ N U M E R I C &gt;----------------------

Add maint cat when name parameter value does not contain letters.  Does not catch
mixed alphanumeric names so |last=A. Green (1922-1987) does not get caught in the
current version of this test but |first=(1888) is caught.

returns nothing

]]

local function name_is_numeric (name, list_name)
	if utilities.is_set (name) then
		if mw.ustring.match (name, '^[%A]+$') then								-- when name does not contain any letters
			utilities.set_message ('maint_numeric_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
		end
	end
end


--[[-----------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;------------------

Evaluates the content of last/surname (authors etc.) parameters for multiple names.
Multiple names are indicated if there is more than one comma or any &quot;unescaped&quot;
semicolons. Escaped semicolons are ones used as part of selected HTML entities.
If the condition is met, the function adds the multiple name maintenance category.

returns nothing

]]

local function name_has_mult_names (name, list_name)
	local _, commas, semicolons, nbsps;
	if utilities.is_set (name) then
		_, commas = name:gsub (',', '');										-- count the number of commas
		_, semicolons = name:gsub (';', '');									-- count the number of semicolons
		-- nbsps probably should be its own separate count rather than merged in
		-- some way with semicolons because Lua patterns do not support the
		-- grouping operator that regex does, which means there is no way to add
		-- more entities to escape except by adding more counts with the new
		-- entities
		_, nbsps = name:gsub ('&amp;nbsp;','');										-- count nbsps
		
		-- There is exactly 1 semicolon per &amp;nbsp; entity, so subtract nbsps
		-- from semicolons to 'escape' them. If additional entities are added,
		-- they also can be subtracted.
		if 1 &lt; commas or 0 &lt; (semicolons - nbsps) then
			utilities.set_message ('maint_mult_names', cfg.special_case_translation [list_name]);	-- add a maint message
		end
	end
end


--[=[-------------------------&lt; I S _ G E N E R I C &gt;----------------------------------------------------------

Compares values assigned to various parameters according to the string provided as &lt;item&gt; in the function call.
&lt;item&gt; can have on of two values:
	'generic_names' – for name-holding parameters: |last=, |first=, |editor-last=, etc
	'generic_titles' – for |title=

There are two types of generic tests.  The 'accept' tests look for a pattern that should not be rejected by the
'reject' test.  For example,
	|author=[[John Smith (author)|Smith, John]]
would be rejected by the 'author' reject test.  But piped wikilinks with 'author' disambiguation should not be
rejected so the 'accept' test prevents that from happening.  Accept tests are always performed before reject
tests.

Each of the 'accept' and 'reject' sequence tables hold tables for en.wiki (['en']) and local.wiki (['local'])
that each can hold a test sequence table  The sequence table holds, at index [1], a test pattern, and, at index
[2], a boolean control value.  The control value tells string.find() or mw.ustring.find() to do plain-text search (true)
or a pattern search (false).  The intent of all this complexity is to make these searches as fast as possible so
that we don't run out of processing time on very large articles.

Returns
	true when a reject test finds the pattern or string
	false when an accept test finds the pattern or string
	nil else

]=]

local function is_generic (item, value, wiki)
	local test_val;
	local str_lower = {															-- use string.lower() for en.wiki (['en']) and use mw.ustring.lower() or local.wiki (['local'])
		['en'] = string.lower,
		['local'] = mw.ustring.lower,
		}
	local str_find = {															-- use string.find() for en.wiki (['en']) and use mw.ustring.find() or local.wiki (['local'])
		['en'] = string.find,
		['local'] = mw.ustring.find,
		}

	local function test (val, test_t, wiki)										-- local function to do the testing; &lt;wiki&gt; selects lower() and find() functions
		val = test_t[2] and str_lower[wiki](value) or val;						-- when &lt;test_t[2]&gt; set to 'true', plaintext search using lowercase value
		return str_find[wiki] (val, test_t[1], 1, test_t[2]);					-- return nil when not found or matched
	end
		
	local test_types_t = {'accept', 'reject'};									-- test accept patterns first, then reject patterns
	local wikis_t = {'en', 'local'};											-- do tests for each of these keys; en.wiki first, local.wiki second

	for _, test_type in ipairs (test_types_t) do								-- for each test type
		for _, generic_value in pairs (cfg.special_case_translation[item][test_type]) do	-- spin through the list of generic value fragments to accept or reject
			for _, wiki in ipairs (wikis_t) do
				if generic_value[wiki] then
					if test (value, generic_value[wiki], wiki) then				-- go do the test
						return ('reject' == test_type);							-- param value rejected, return true; false else
					end
				end
			end
		end
	end
end


--[[--------------------------&lt; N A M E _ I S _ G E N E R I C &gt;------------------------------------------------

calls is_generic() to determine if &lt;name&gt; is a 'generic name' listed in cfg.generic_names; &lt;name_alias&gt; is the
parameter name used in error messaging

]]

local function name_is_generic (name, name_alias)
	if not added_generic_name_errs  and is_generic ('generic_names', name) then
		utilities.set_message ('err_generic_name', name_alias);					-- set an error message
		added_generic_name_errs = true;
	end
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------

This function calls various name checking functions used to validate the content of the various name-holding parameters.

]]

local function name_checks (last, first, list_name, last_alias, first_alias)
	local accept_name;

	if utilities.is_set (last) then
		last, accept_name = utilities.has_accept_as_written (last);				-- remove accept-this-as-written markup when it wraps all of &lt;last&gt;

		if not accept_name then													-- &lt;last&gt; not wrapped in accept-as-written markup
			name_has_mult_names (last, list_name);								-- check for multiple names in the parameter (last only)
			name_is_numeric (last, list_name);									-- check for names that are composed of digits and punctuation
			name_is_generic (last, last_alias);									-- check for names found in the generic names list
		end
	end

	if utilities.is_set (first) then
		first, accept_name = utilities.has_accept_as_written (first);			-- remove accept-this-as-written markup when it wraps all of &lt;first&gt;

		if not accept_name then													-- &lt;first&gt; not wrapped in accept-as-written markup
			name_is_numeric (first, list_name);									-- check for names that are composed of digits and punctuation
			name_is_generic (first, first_alias);								-- check for names found in the generic names list
		end
		local wl_type, D = utilities.is_wikilink (first);
		if 0 ~= wl_type then
			first = D;
			utilities.set_message ('err_bad_paramlink', first_alias);
		end
	end

	return last, first;															-- done
end


--[[----------------------&lt; E X T R A C T _ N A M E S &gt;-------------------------

Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters
(or their aliases), and their matching link and mask parameters. Stops searching
when both |lastn= and |firstn= are not found in args after two sequential attempts:
found |last1=, |last2=, and |last3= but doesn't find |last4= and |last5= then the
search is done.

This function emits an error message when there is a |firstn= without a matching
|lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not
required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.'
is stripped from the parameter and a flag (etal) returned that will cause list_people()
to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps
'et al.' out of the template's metadata.  When this occurs, an error is emitted.

]]

local function extract_names(args, list_name)
	local names = {};															-- table of names
	local last;																	-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;																-- loop counter/indexer
	local n = 1;																-- output table indexer
	local count = 0;															-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal = false;															-- return value set to true when we find some form of et al. in an author parameter

	local last_alias, first_alias, link_alias;									-- selected parameter aliases used in error messaging
	while true do
		last, last_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'err_redundant_parameters', i );		-- search through args for name components beginning at 1
		first, first_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'err_redundant_parameters', i );
		link, link_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i );
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
	
		if last then															-- error check |lastn= alias for unknown interwiki link prefix; done here because this is where we have the parameter name
			local project, language = interwiki_prefixen_get (last, true);		-- true because we expect interwiki links in |lastn= to be wikilinked
			if nil == project and nil == language then							-- when both are nil
				utilities.set_message ('err_bad_paramlink', last_alias);		-- not known, emit an error message	-- TODO: err_bad_interwiki?
				last = utilities.remove_wiki_link (last);						-- remove wikilink markup; show display value only
			end
		end
		
		if link then															-- error check |linkn= alias for unknown interwiki link prefix
			local project, language = interwiki_prefixen_get (link, false);		-- false because wiki links in |author-linkn= is an error
			if nil == project and nil == language then							-- when both are nil
				utilities.set_message ('err_bad_paramlink', link_alias);		-- not known, emit an error message	-- TODO: err_bad_interwiki?
				link = nil;														-- unset so we don't link
				link_alias = nil;
			end
		end
		
		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.
		last, first = name_checks (last, first, list_name, last_alias, first_alias);						-- multiple names, extraneous annotation, etc. checks

		if first and not last then												-- if there is a firstn without a matching lastn
			local alias = first_alias:find ('given', 1, true) and 'given' or 'first';	-- get first or given form of the alias
			utilities.set_message ('err_first_missing_last', {
				first_alias,													-- param name of alias missing its mate
				first_alias:gsub (alias, {['first'] = 'last', ['given'] = 'surname'}),	-- make param name appropriate to the alias form
				});																-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			local result;
			link = link_title_ok (link, link_alias, last, last_alias);			-- check for improper wiki-markup

			if first then
				link = link_title_ok (link, link_alias, first, first_alias);	-- check for improper wiki-markup
			end

			names[n] = {last = last, first = first, link = link, mask = mask, corporate = false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				utilities.set_message ('err_missing_name', {list_name:match (&quot;(%w+)List&quot;):lower(), i - 1});	-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names and the etal flag
end


--[[--------------------------&lt; N A M E _ T A G _ G E T &gt;------------------------------------------------------

attempt to decode |language=&lt;lang_param&gt; and return language name and matching tag; nil else.

This function looks for:
	&lt;lang_param&gt; as a tag in cfg.lang_code_remap{}
	&lt;lang_param&gt; as a name in cfg.lang_name_remap{}
	
	&lt;lang_param&gt; as a name in cfg.mw_languages_by_name_t
	&lt;lang_param&gt; as a tag in cfg.mw_languages_by_tag_t
when those fail, presume that &lt;lang_param&gt; is an IETF-like tag that MediaWiki does not recognize.  Strip all
script, region, variant, whatever subtags from &lt;lang_param&gt; to leave just a two or three character language tag
and look for the new &lt;lang_param&gt; in cfg.mw_languages_by_tag_t{}

on success, returns name (in properly capitalized form) and matching tag (in lowercase); on failure returns nil

]]

local function name_tag_get (lang_param)
	local lang_param_lc = mw.ustring.lower (lang_param);						-- use lowercase as an index into the various tables
	local name;
	local tag;

	name = cfg.lang_code_remap[lang_param_lc];									-- assume &lt;lang_param_lc&gt; is a tag; attempt to get remapped language name 
	if name then																-- when &lt;name&gt;, &lt;lang_param&gt; is a tag for a remapped language name
		return name, lang_param_lc;												-- so return &lt;name&gt; from remap and &lt;lang_param_lc&gt;
	end

	tag = lang_param_lc:match ('^(%a%a%a?)%-.*');								-- still assuming that &lt;lang_param_lc&gt; is a tag; strip script, region, variant subtags
	name = cfg.lang_code_remap[tag];											-- attempt to get remapped language name with language subtag only
	if name then																-- when &lt;name&gt;, &lt;tag&gt; is a tag for a remapped language name
		return name, tag;														-- so return &lt;name&gt; from remap and &lt;tag&gt;
	end

	if cfg.lang_name_remap[lang_param_lc] then									-- not a tag, assume &lt;lang_param_lc&gt; is a name; attempt to get remapped language tag 
		return cfg.lang_name_remap[lang_param_lc][1], cfg.lang_name_remap[lang_param_lc][2];	-- for this &lt;lang_param_lc&gt;, return a (possibly) new name and appropriate tag
	end

	tag = cfg.mw_languages_by_name_t[lang_param_lc];							-- assume that &lt;lang_param_lc&gt; is a language name; attempt to get its matching tag
	
	if tag then
		return cfg.mw_languages_by_tag_t[tag], tag;								-- &lt;lang_param_lc&gt; is a name so return the name from the table and &lt;tag&gt;
	end

	name = cfg.mw_languages_by_tag_t[lang_param_lc];							-- assume that &lt;lang_param_lc&gt; is a tag; attempt to get its matching language name
	
	if name then
		return name, lang_param_lc;												-- &lt;lang_param_lc&gt; is a tag so return it and &lt;name&gt;
	end
	
	tag = lang_param_lc:match ('^(%a%a%a?)%-.*');								-- is &lt;lang_param_lc&gt; an IETF-like tag that MediaWiki doesn't recognize? &lt;tag&gt; gets the language subtag; nil else

	if tag then
		name = cfg.mw_languages_by_tag_t[tag];									-- attempt to get a language name using the shortened &lt;tag&gt;
		if name then
			return name, tag;													-- &lt;lang_param_lc&gt; is an unrecognized IETF-like tag so return &lt;name&gt; and language subtag
		end
	end
end


--[[-------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code
is recognized by MediaWiki, use the returned name; if not, then use the value that
was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is
assigned to the category for that code: Category:Norwegian-language sources (no).
For valid three-character code languages, the page is assigned to the single category
for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does
not recognize three-character equivalents of two-character codes: code 'ar' is
recognized but code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th
where the language names or codes are separated from each other by commas with
optional space characters.

]]

local function language_parameter (lang)
	local tag;																	-- some form of IETF-like language tag; language subtag with optional region, sript, vatiant, etc subtags
	local lang_subtag;															-- ve populates |language= with mostly unecessary region subtags the MediaWiki does not recognize; this is the base language subtag
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_t = {};															-- table made from the value assigned to |language=

	local this_wiki_name = mw.language.fetchLanguageName (cfg.this_wiki_code, cfg.this_wiki_code);	-- get this wiki's language name

	names_t = mw.text.split (lang, '%s*,%s*');									-- names should be a comma separated list

	for _, lang in ipairs (names_t) do											-- reuse lang here because we don't yet know if lang is a language name or a language tag
		name, tag = name_tag_get (lang);										-- attempt to get name/tag pair for &lt;lang&gt;; &lt;name&gt; has proper capitalization; &lt;tag&gt; is lowercase

		if utilities.is_set (tag) then
			lang_subtag = tag:gsub ('^(%a%a%a?)%-.*', '%1');					-- for categorization, strip any IETF-like tags from language tag

			if cfg.this_wiki_code ~= lang_subtag then							-- when the language is not the same as this wiki's language
				if 2 == lang_subtag:len() then									-- and is a two-character tag
					utilities.add_prop_cat ('foreign-lang-source', {name, tag}, lang_subtag);		-- categorize it; tag appended to allow for multiple language categorization
				else															-- or is a recognized language (but has a three-character tag)
					utilities.add_prop_cat ('foreign-lang-source-2', {lang_subtag}, lang_subtag);			-- categorize it differently TODO: support multiple three-character tag categories per cs1|2 template?
				end
			elseif cfg.local_lang_cat_enable then								-- when the language and this wiki's language are the same and categorization is enabled
				utilities.add_prop_cat ('local-lang-source', {name, lang_subtag});		-- categorize it
			end
		else
			name = lang;														-- return whatever &lt;lang&gt; has so that we show something
			utilities.set_message ('maint_unknown_lang');						-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
 
	name = utilities.make_sep_list (#language_list, language_list);
	if (1 == #language_list) and (lang_subtag == cfg.this_wiki_code) then		-- when only one language, find lang name in this wiki lang name; for |language=en-us, 'English' in 'American English'
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[-----------------------&lt; S E T _ C S _ S T Y L E &gt;--------------------------

Gets the default CS style configuration for the given mode.
Returns default separator and either postscript as passed in or the default.
In CS1, the default postscript and separator are '.'.
In CS2, the default postscript is the empty string and the default separator is ','.

]]

local function set_cs_style (postscript, mode)
	if utilities.is_set(postscript) then
		-- emit a maintenance message if user postscript is the default cs1 postscript
		-- we catch the opposite case for cs2 in set_style
		if mode == 'cs1' and postscript == cfg.presentation['ps_' .. mode] then
			utilities.set_message ('maint_postscript');
		end
	else
		postscript = cfg.presentation['ps_' .. mode];
	end
	return cfg.presentation['sep_' .. mode], postscript;
end


--[[--------------------------&lt; S E T _ S T Y L E &gt;-----------------------------

Sets the separator and postscript styles. Checks the |mode= first and the
#invoke CitationClass second. Removes the postscript if postscript == none.

]]

local function set_style (mode, postscript, cite_class)
	local sep;
	if 'cs2' == mode then
		sep, postscript = set_cs_style (postscript, 'cs2');
	elseif 'cs1' == mode then
		sep, postscript = set_cs_style (postscript, 'cs1');
	elseif 'citation' == cite_class	then
		sep, postscript = set_cs_style (postscript, 'cs2');
	else
		sep, postscript = set_cs_style (postscript, 'cs1');
	end

	if cfg.keywords_xlate[postscript:lower()] == 'none' then
		-- emit a maintenance message if user postscript is the default cs2 postscript
		-- we catch the opposite case for cs1 in set_cs_style
		if 'cs2' == mode or 'citation' == cite_class then
			utilities.set_message ('maint_postscript');
		end
		postscript = '';
	end
	
	return sep, postscript
end


--[=[-------------------------&lt; I S _ P D F &gt;-----------------------------------

Determines if a URL has the file extension that is one of the PDF file extensions
used by [[MediaWiki:Common.css]] when applying the PDF icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or
		url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
		url:match ('%.PDF&amp;#035') or url:match ('%.pdf&amp;#035');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;-----------------------

Applies CSS style to |format=, |chapter-format=, etc.  Also emits an error message
if the format parameter does not have a matching URL parameter.  If the format parameter
is not set and the URL contains a file extension that is recognized as a PDF document
by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if utilities.is_set (format) then
		format = utilities.wrap_style ('format', format);						-- add leading space, parentheses, resize
		if not utilities.is_set (url) then
			utilities.set_message ('err_format_missing_url', {fmt_param, url_param});	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if URL is a PDF file then
		format = utilities.wrap_style ('format', 'PDF');						-- set format to PDF
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[---------------------&lt; G E T _ D I S P L A Y _ N A M E S &gt;------------------

Returns a number that defines the number of names displayed for author and editor
name lists and a Boolean flag to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero,
return the number and the previous state of the 'etal' flag (false by default
but may have been set to true if the name list contains some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number
that is one greater than the number of authors in the list and set the 'etal' flag true.
This will cause the list_people() to display all of the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors']; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

]]

local function get_display_names (max, count, list_name, etal, param)
	if utilities.is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if max &gt;= count then												-- if |display-xxxxors= value greater than or equal to number of authors/editors
				utilities.set_message ('err_disp_name', {param, max});			-- add error message
				max = nil;
			end
		else																	-- not a valid keyword or number
			utilities.set_message ('err_disp_name', {param, max});		-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[----------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;---------------

Adds error if |page=, |pages=, |quote-page=, |quote-pages= has what appears to be
some form of p. or pp. abbreviation in the first characters of the parameter content.

check page for extraneous p, p., pp, pp., pg, pg. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when page begins PX or P# but not Px
		      where x and X are letters and # is a digit
	bad pattern:  '^[Pp][PpGg]' matches when page begins pp, pP, Pp, PP, pg, pG, Pg, PG

]]

local function extra_text_in_page_check (val, name)
	if not val:match (cfg.vol_iss_pg_patterns.good_ppattern) then
		for _, pattern in ipairs (cfg.vol_iss_pg_patterns.bad_ppatterns) do		-- spin through the selected sequence table of patterns
			if val:match (pattern) then											-- when a match, error so
				utilities.set_message ('err_extra_text_pages', name);	 		-- add error message
				return;															-- and done
			end
		end
	end		
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ V O L _ I S S _ C H E C K &gt;------------------------

Adds error if |volume= or |issue= has what appears to be some form of redundant 'type' indicator.

For |volume=:
	'V.', or 'Vol.' (with or without the dot) abbreviations or 'Volume' in the first characters of the parameter
	content (all case insensitive). 'V' and 'v' (without the dot) are presumed to be roman numerals so
	are allowed.

For |issue=:
	'No.', 'I.', 'Iss.' (with or without the dot) abbreviations, or 'Issue' in the first characters of the
	parameter content (all case insensitive).
	
Single character values ('v', 'i', 'n') allowed when not followed by separator character ('.', ':', '=', or
whitespace character) – param values are trimmed of whitespace by MediaWiki before delivered to the module.
	
&lt;val&gt; is |volume= or |issue= parameter value
&lt;name&gt; is |volume= or |issue= parameter name for error message
&lt;selector&gt; is 'v' for |volume=, 'i' for |issue=

sets error message on failure; returns nothing

]]

local function extra_text_in_vol_iss_check (val, name, selector)
	if not utilities.is_set (val) then
		return;
	end
	
	local patterns = 'v' == selector and cfg.vol_iss_pg_patterns.vpatterns or cfg.vol_iss_pg_patterns.ipatterns;

	local handler = 'v' == selector and 'err_extra_text_volume' or 'err_extra_text_issue';
	val = val:lower();															-- force parameter value to lower case
	for _, pattern in ipairs (patterns) do										-- spin through the selected sequence table of patterns
		if val:match (pattern) then												-- when a match, error so
			utilities.set_message (handler, name);								-- add error message
			return;																-- and done
		end
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parentheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a placeholder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parentheses
			local name = name_table[i];
			i = i + 1;															-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parentheses
					break;														-- and done reassembling so
				end
				i = i + 1;														-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = utilities.is_wikilink (name_table[i]);		-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i + 1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled parentheses ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the Vancouver error when a required comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		first = '';																-- set to empty string for concatenation and because it may have been set for previous author/editor
		local accept_name;
		v_name, accept_name = utilities.has_accept_as_written (v_name);			-- remove accept-this-as-written markup when it wraps all of &lt;v_name&gt;

		if accept_name then
			last = v_name;
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error (cfg.err_msg_supl.punctuation, i);
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s+&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be initials or generational suffix

			if not mw.ustring.match (first, '^%u+$') then						-- mw.ustring here so that later we will catch non-Latin characters
				suffix = first;													-- not initials so assume that whatever we got is a generational suffix
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end
			last = table.concat(lastfirstTable, ' ')							-- returns a string that is the concatenation of all other names that are not initials and generational suffix
			if not utilities.is_set (last) then
				first = '';														-- unset
				last = v_name;													-- last empty because something wrong with first
				add_vanc_error (cfg.err_msg_supl.name, i);
			end
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error (cfg.err_msg_supl['missing comma'], i);			-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- matches a space between two initials
			end
		else
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
		
		if utilities.is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first, suffix, i);							-- check first and last before restoring the suffix which may have a non-Latin digit
			if utilities.is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '', nil, i);
			end
		end

		link = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i ) or v_link_table[i];
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate = corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest;
|editorn= (and aliases) highest and |veditors= lowest (support for |editors= withdrawn)

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
	local lastfirst = false;
	if utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice in case we have a |first1= without a |last1=; this ...
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or		-- ... also catches the case where |first= is used with |vauthors=
		utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst = true;
	end

	if (utilities.is_set (vxxxxors) and true == lastfirst) or					-- these are the three error conditions
		(utilities.is_set (vxxxxors) and utilities.is_set (xxxxors)) or
		(true == lastfirst and utilities.is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			utilities.set_message ('err_redundant_parameters', err_name .. '-name-list parameters');	-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if utilities.is_set (vxxxxors) then return 2 end;
	if utilities.is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, live, dead, etc.).  When the parameter value has not been assigned a value (missing
or empty in the source template) the function returns the value specified by ret_val.  If the parameter value is one
of the list of allowed values returns the translated value; else, emits an error message and returns the value
specified by ret_val.

TODO: explain &lt;invert&gt;

]]

local function is_valid_parameter_value (value, name, possible, ret_val, invert)
	if not utilities.is_set (value) then
		return ret_val;															-- an empty parameter is ok
	end

	if (not invert and utilities.in_array (value, possible)) then				-- normal; &lt;value&gt; is in &lt;possible&gt; table
		return cfg.keywords_xlate[value];										-- return translation of parameter keyword
	elseif invert and not utilities.in_array (value, possible) then				-- invert; &lt;value&gt; is not in &lt;possible&gt; table
		return value;															-- return &lt;value&gt; as it is
	else
		utilities.set_message ('err_invalid_param_val', {name, value});			-- not an allowed value so add error message
		return ret_val;
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list, -3, -1) == sepc .. '. ') then					-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list, -1, -1) == sepc) or (string.sub (name_list, -3, -1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terminate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;-----------------------------------------

returns the concatenation of the formatted volume and issue (or journal article number) parameters as a single
string; or formatted volume or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, article, cite_class, origin, sepc, lower)
	if not utilities.is_set (volume) and not utilities.is_set (issue) and not utilities.is_set (article) then
		return '';
	end

	-- same condition as in format_pages_sheets()
	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);

	local is_numeric_vol = volume and (volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$'));	-- is only uppercase roman numerals or only digits?
	local is_long_vol = volume and (4 &lt; mw.ustring.len(volume));				-- is |volume= value longer than 4 characters?
	
	if volume and (not is_numeric_vol and is_long_vol) then						-- when not all digits or Roman numerals, is |volume= longer than 4 characters?
		utilities.add_prop_cat ('long-vol');									-- yes, add properties cat
	end

	if is_journal then															-- journal-style formatting
		local vol = '';

		if utilities.is_set (volume) then
			if is_numeric_vol then												-- |volume= value all digits or all uppercase Roman numerals?
				vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, volume});	-- render in bold face
			elseif is_long_vol then												-- not all digits or Roman numerals; longer than 4 characters?
				vol = utilities.substitute (cfg.messages['j-vol'], {sepc, utilities.hyphen_to_dash (volume)});	-- not bold
			else																-- four or fewer characters
				vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, utilities.hyphen_to_dash (volume)});	-- bold
			end
		end
		vol = vol .. (utilities.is_set (issue) and utilities.substitute (cfg.messages['j-issue'], issue) or '')
		vol = vol .. (utilities.is_set (article) and utilities.substitute (cfg.messages['j-article-num'], article) or '')
		return vol;
	end
	
	if 'podcast' == cite_class and utilities.is_set (issue) then
		return wrap_msg ('issue', {sepc, issue}, lower);
	end
	
	if 'conference' == cite_class and utilities.is_set (article) then			-- |article-number= supported only in journal and conference cites
		if utilities.is_set (volume) and utilities.is_set (article) then		-- both volume and article number
			return wrap_msg ('vol-art', {sepc, utilities.hyphen_to_dash (volume), article}, lower);
		elseif utilities.is_set (article) then									-- article number alone; when volume alone, handled below
			return wrap_msg ('art', {sepc, article}, lower);
		end
	end

	-- all other types of citation
	if utilities.is_set (volume) and utilities.is_set (issue) then
		return wrap_msg ('vol-no', {sepc, utilities.hyphen_to_dash (volume), issue}, lower);
	elseif utilities.is_set (volume) then
		return wrap_msg ('vol', {sepc, utilities.hyphen_to_dash (volume)}, lower);
	else
		return wrap_msg ('issue', {sepc, issue}, lower);
	end
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if utilities.is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif utilities.is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if utilities.is_set (page) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return utilities.substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return utilities.substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif utilities.is_set (pages) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then							-- if pages is only digits, assume a single page number
			return '', utilities.substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', utilities.substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', utilities.substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to Wikisource, returns the label portion of the interwiki-link as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki-link to an external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, page_orig, pages, pages_orig, at)
	local ws_url, ws_label, coins_pages, L;										-- for Wikisource interwiki-links; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if utilities.is_set (page) then
		if utilities.is_set (pages) or utilities.is_set (at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page, page_orig);								-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws URL from |page= interwiki link; link portion L becomes tooltip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (pages) then
		if utilities.is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages, pages_orig);							-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws URL from |pages= interwiki link; link portion L becomes tooltip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws URL from |at= interwiki link; link portion L becomes tooltip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end

--[[--------------------------&lt; I S _ U N I Q U E _ A R C H I V E _ U R L &gt;------------------------------------

add error message when |archive-url= value is same as |url= or chapter-url= (or alias...) value

]]

local function is_unique_archive_url (archive, url, c_url, source, date)
	if utilities.is_set (archive) then
		if archive == url or archive == c_url then
			utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)});	-- add error message
			return '', '';														-- unset |archive-url= and |archive-date= because same as |url= or |chapter-url=
		end
	end

	return archive, date;
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org URLs to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot URL or to calendar pages.  When the archive URL is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the URL.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org URL does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command URL
	|archive-url= is an archive.org URL that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org URLs:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this function may return a modified
archive URL:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the URL unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.org URL
	
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine URL
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command URL, we don't want to allow saving of the target page 
		err_msg = cfg.err_msg_supl.save;
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = cfg.err_msg_supl.liveweb;
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');	-- split out some of the URL parts for evaluation
		if not path then														-- malformed in some way; pattern did not match
			err_msg = cfg.err_msg_supl.timestamp;
		elseif 14 ~= timestamp:len() then										-- path and flag optional, must have 14-digit timestamp here
			err_msg = cfg.err_msg_supl.timestamp;
			if '*' ~= flag then
				local replacement = timestamp:match ('^%d%d%d%d%d%d') or timestamp:match ('^%d%d%d%d');	-- get the first 6 (YYYYMM) or first 4 digits (YYYY)
				if replacement then												-- nil if there aren't at least 4 digits (year)
					replacement = replacement .. string.rep ('0', 14 - replacement:len());	-- year or yearmo (4 or 6 digits) zero-fill to make 14-digit timestamp
					url=url:gsub ('(//web%.archive%.org/[^%d]*)%d[^/]*', '%1' .. replacement .. '*', 1)	-- for preview, modify ts to 14 digits plus splat for calendar display
				end
			end
		elseif utilities.is_set (path) and 'web/' ~= path then					-- older archive URLs do not have the extra 'web/' path element
			err_msg = cfg.err_msg_supl.path;
		elseif utilities.is_set (flag) and not utilities.is_set (path) then		-- flag not allowed with the old form URL (without the 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		elseif utilities.is_set (flag) and not flag:match ('%a%a_') then		-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		else
			return url, date;													-- return ArchiveURL and ArchiveDate
		end
	end
																				-- if here, something not right so
	utilities.set_message ('err_archive_url', {err_msg});						-- add error message and

	if is_preview_mode then
		return url, date;														-- preview mode so return ArchiveURL and ArchiveDate
	else
		return '', '';															-- return empty strings for ArchiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; P L A C E _ C H E C K &gt;--------------------------------------------------------

check |place=, |publication-place=, |location= to see if these params include digits.  This function added because
many editors misuse location to specify the in-source location (|page(s)= and |at= are supposed to do that)

returns the original parameter value without modification; added maint cat when parameter value contains digits

]]

local function place_check (param_val)
	if not utilities.is_set (param_val) then									-- parameter empty or omitted
		return param_val;														-- return that empty state
	end
	
	if mw.ustring.find (param_val, '%d') then									-- not empty, are there digits in the parameter value
		utilities.set_message ('maint_location');								-- yep, add maint cat
	end
	
	return param_val;															-- and done
end


--[[--------------------------&lt; I S _ A R C H I V E D _ C O P Y &gt;----------------------------------------------

compares |title= to 'Archived copy' (placeholder added by bots that can't find proper title); if matches, return true; nil else

]]

local function is_archived_copy (title)
	title = mw.ustring.lower(title);											-- switch title to lower case
	if title:find (cfg.special_case_translation.archived_copy.en) then			-- if title is 'Archived copy'
		return true;
	elseif cfg.special_case_translation.archived_copy['local'] then
		if mw.ustring.find (title, cfg.special_case_translation.archived_copy['local']) then	-- mw.ustring() because might not be Latin script
			return true;
		end
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args )
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper ( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListStyle = is_valid_parameter_value (A['NameListStyle'], A:ORIGIN('NameListStyle'), cfg.keywords_lists['name-list-style'], '');
	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			a, author_etal = parse_vauthors_veditors (args, args.vauthors, 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				utilities.set_message ('maint_authors');						-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if utilities.is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], nil, args, 'EditorList');	-- support for |editors= withdrawn
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		end
	end
							
	local Chapter = A['Chapter'];												-- done here so that we have access to |contribution= from |chapter= aliases
	local Chapter_origin = A:ORIGIN ('Chapter');
	local Contribution;															-- because contribution is required for contributor(s)
		if 'contribution' == Chapter_origin then
			Contribution = Chapter;												-- get the name of the contribution
		end
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	
	if utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not utilities.is_set (Contribution) then							-- |contributor= requires |contribution=
				utilities.set_message ('err_contributor_missing_required_param', 'contribution');	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				utilities.set_message ('err_contributor_missing_required_param', 'author');	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if utilities.select_one (args, cfg.aliases['ContributorList-Last'], 'err_redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			utilities.set_message ('err_contributor_ignored');					-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	local Title = A['Title'];
	local TitleLink = A['TitleLink'];

	local auto_select = ''; -- default is auto
	local accept_link;
	TitleLink, accept_link = utilities.has_accept_as_written (TitleLink, true);	-- test for accept-this-as-written markup
	if (not accept_link) and utilities.in_array (TitleLink, {'none', 'pmc', 'doi'}) then -- check for special keywords
		auto_select = TitleLink;												-- remember selection for later
		TitleLink = '';															-- treat as if |title-link= would have been empty
	end

	TitleLink = link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wiki-markup in |title-link= or wiki-markup in |title= when |title-link= is set

	local Section = '';															-- {{cite map}} only; preset to empty string for concatenation if not used
	if 'map' == config.CitationClass and 'section' == Chapter_origin then
		Section = A['Chapter'];													-- get |section= from |chapter= alias list; |chapter= and the other aliases not supported in {{cite map}}
		Chapter = '';															-- unset for now; will be reset later from |map= if present
	end

	local Periodical = A['Periodical'];
	local Periodical_origin = '';
	if utilities.is_set (Periodical) then
		Periodical_origin = A:ORIGIN('Periodical');								-- get the name of the periodical parameter
		local i;
		Periodical, i = utilities.strip_apostrophe_markup (Periodical);			-- strip apostrophe markup so that metadata isn't contaminated 
		if i then																-- non-zero when markup was stripped so emit an error message
			utilities.set_message ('err_apostrophe_markup', {Periodical_origin});
		end
	end

	if 'mailinglist' == config.CitationClass then								-- special case for {{cite mailing list}}
		if utilities.is_set (Periodical) and utilities.is_set (A ['MailingList']) then	-- both set emit an error TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', Periodical_origin) .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'mailinglist')});
		end

		Periodical = A ['MailingList'];											-- error or no, set Periodical to |mailinglist= value because this template is {{cite mailing list}}
		Periodical_origin = A:ORIGIN('MailingList');
	end

	local ScriptPeriodical = A['ScriptPeriodical'];

	-- web and news not tested for now because of 
	-- Wikipedia:Administrators%27_noticeboard#Is_there_a_semi-automated_tool_that_could_fix_these_annoying_&quot;Cite_Web&quot;_errors?
	if not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) then	-- 'periodical' templates require periodical parameter
	--	local p = {['journal'] = 'journal', ['magazine'] = 'magazine', ['news'] = 'newspaper', ['web'] = 'website'};	-- for error message
		local p = {['journal'] = 'journal', ['magazine'] = 'magazine'};			-- for error message
		if p[config.CitationClass]  then
			utilities.set_message ('err_missing_periodical', {config.CitationClass, p[config.CitationClass]});
		end
	end
	
	local Volume;
	local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) then
			if not utilities.in_array (Periodical_origin, cfg.citation_no_volume_t) then	-- {{citation}} does not render |volume= when these parameters are used
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		elseif utilities.is_set (ScriptPeriodical) then
			if 'script-website' ~= ScriptPeriodical_origin then					-- {{citation}} does not render volume for |script-website=
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		else
			Volume = A['Volume'];												-- and does for non-'periodical' cites
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_volume) then	-- render |volume= for cs1 according to the configuration settings
		Volume = A['Volume'];
	end	
	extra_text_in_vol_iss_check (Volume, A:ORIGIN ('Volume'), 'v');	

	local Issue;
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) and utilities.in_array (Periodical_origin, cfg.citation_issue_t) then	-- {{citation}} may render |issue= when these parameters are used
			Issue = utilities.hyphen_to_dash (A['Issue']);
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_issue) then	-- conference &amp; map books do not support issue; {{citation}} listed here because included in settings table
		if not (utilities.in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical))) then
			Issue = utilities.hyphen_to_dash (A['Issue']);
		end
	end
	
	local ArticleNumber;

	if utilities.in_array (config.CitationClass, {'journal', 'conference'}) or ('citation' == config.CitationClass and utilities.is_set (Periodical) and 'journal' == Periodical_origin) then
		ArticleNumber = A['ArticleNumber'];
	end

	extra_text_in_vol_iss_check (Issue, A:ORIGIN ('Issue'), 'i');	

	local Page;
	local Pages;
	local At;
	local QuotePage;
	local QuotePages;
	if not utilities.in_array (config.CitationClass, cfg.templates_not_using_page) then		-- TODO: rewrite to emit ignored parameter error message?
		Page = A['Page'];
		Pages = utilities.hyphen_to_dash (A['Pages']);	
		At = A['At'];
		QuotePage = A['QuotePage'];
		QuotePages = utilities.hyphen_to_dash (A['QuotePages']);
	end

	local Edition = A['Edition'];
	local PublicationPlace = place_check (A['PublicationPlace'], A:ORIGIN('PublicationPlace'));
	local Place = place_check (A['Place'], A:ORIGIN('Place'));
	
	local PublisherName = A['PublisherName'];
	local PublisherName_origin = A:ORIGIN('PublisherName');
	if utilities.is_set (PublisherName) then
		local i = 0;
		PublisherName, i = utilities.strip_apostrophe_markup (PublisherName);	-- strip apostrophe markup so that metadata isn't contaminated; publisher is never italicized
		if i then																-- non-zero when markup was stripped so emit an error message
			utilities.set_message ('err_apostrophe_markup', {PublisherName_origin});
		end
	end

	local Newsgroup = A['Newsgroup'];											-- TODO: strip apostrophe markup?
	local Newsgroup_origin = A:ORIGIN('Newsgroup');	

	if 'newsgroup' == config.CitationClass then
		if utilities.is_set (PublisherName) then								-- general use parameter |publisher= not allowed in cite newsgroup
			utilities.set_message ('err_parameter_ignored', {PublisherName_origin});
		end

		PublisherName = nil;													-- ensure that this parameter is unset for the time being; will be used again after COinS
	end

	local URL = A['URL'];														-- TODO: better way to do this for URL, ChapterURL, and MapURL?
	local UrlAccess = is_valid_parameter_value (A['UrlAccess'], A:ORIGIN('UrlAccess'), cfg.keywords_lists['url-access'], nil);
	
	if not utilities.is_set (URL) and utilities.is_set (UrlAccess) then
		UrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', 'url');
	end
	
	local ChapterURL = A['ChapterURL'];
	local ChapterUrlAccess = is_valid_parameter_value (A['ChapterUrlAccess'], A:ORIGIN('ChapterUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (ChapterURL) and utilities.is_set (ChapterUrlAccess) then
		ChapterUrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', {A:ORIGIN('ChapterUrlAccess'):gsub ('%-access', '')});
	end

	local MapUrlAccess = is_valid_parameter_value (A['MapUrlAccess'], A:ORIGIN('MapUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (A['MapURL']) and utilities.is_set (MapUrlAccess) then
		MapUrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', {'map-url'});
	end

	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local no_tracking_cats = is_valid_parameter_value (A['NoTracking'], A:ORIGIN('NoTracking'), cfg.keywords_lists['yes_true_y'], nil);

	-- check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not utilities.is_set (no_tracking_cats) then								-- ignore if we are already not going to categorize this page
		if cfg.uncategorized_namespaces[this_page.namespace] then				-- is this page's namespace id one of the uncategorized namespace ids?
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _, v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end
																				-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	utilities.select_one (args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'err_redundant_parameters');	-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, A:ORIGIN('Page'), Pages, A:ORIGIN('Pages'), At);

	local NoPP = is_valid_parameter_value (A['NoPP'], A:ORIGIN('NoPP'), cfg.keywords_lists['yes_true_y'], nil);

	if utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- both |publication-place= and |place= (|location=) allowed if different
		utilities.add_prop_cat ('location-test');								-- add property cat to evaluate how often PublicationPlace and Place are used together
		if PublicationPlace == Place then
			Place = '';															-- unset; don't need both if they are the same
		end
	elseif not utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- when only |place= (|location=) is set ...
		PublicationPlace = Place;												-- promote |place= (|location=) to |publication-place
	end

	if PublicationPlace == Place then Place = ''; end							-- don't need both if they are the same
	
	local URL_origin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL_origin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ScriptChapter = A['ScriptChapter'];
	local ScriptChapter_origin = A:ORIGIN ('ScriptChapter');
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local TransChapter = A['TransChapter'];
	local TransChapter_origin = A:ORIGIN ('TransChapter');
	local TransTitle = A['TransTitle'];
	local ScriptTitle = A['ScriptTitle'];
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia= and |title= then map |title= to |article= and |encyclopedia= to |title=
		|encyclopedia= and |article= then map |encyclopedia= to |title=

		|trans-title= maps to |trans-chapter= when |title= is re-mapped
		|url= maps to |chapter-url= when |title= is remapped
	
	All other combinations of |encyclopedia=, |title=, and |article= are not modified
	
	]]

	local Encyclopedia = A['Encyclopedia'];										-- used as a flag by this module and by ~/COinS

	if utilities.is_set (Encyclopedia) then										-- emit error message when Encyclopedia set but template is other than {{cite encyclopedia}} or {{citation}}
		if 'encyclopaedia' ~= config.CitationClass and 'citation' ~= config.CitationClass then
			utilities.set_message ('err_parameter_ignored', {A:ORIGIN ('Encyclopedia')});
			Encyclopedia = nil;													-- unset because not supported by this template
		end
	end

	if ('encyclopaedia' == config.CitationClass) or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Periodical) and utilities.is_set (Encyclopedia) then	-- when both set emit an error TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', A:ORIGIN ('Encyclopedia')) .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', Periodical_origin)});
		end

		if utilities.is_set (Encyclopedia) then
			Periodical = Encyclopedia;											-- error or no, set Periodical to Encyclopedia; allow periodical without encyclopedia
			Periodical_origin = A:ORIGIN ('Encyclopedia');
		end

		if utilities.is_set (Periodical) then									-- Periodical is set when |encyclopedia= is set
			if utilities.is_set (Title) or utilities.is_set (ScriptTitle) then
				if not utilities.is_set (Chapter) then
					Chapter = Title;											-- |encyclopedia= and |title= are set so map |title= to |article= and |encyclopedia= to |title=
					ScriptChapter = ScriptTitle;
					ScriptChapter_origin = A:ORIGIN('ScriptTitle')
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterURL_origin = URL_origin;

					ChapterUrlAccess = UrlAccess;

					if not utilities.is_set (ChapterURL) and utilities.is_set (TitleLink) then
						Chapter = utilities.make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			elseif utilities.is_set (Chapter) or utilities.is_set (ScriptChapter) then								-- |title= not set
				Title = Periodical;												-- |encyclopedia= set and |article= set so map |encyclopedia= to |title=
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- special case for cite techreport.
	local ID = A['ID'];
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if utilities.is_set (A['Number']) then									-- cite techreport uses 'number', which other citations alias to 'issue'
			if not utilities.is_set (ID) then									-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'id') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'number')});
			end
		end	
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	local ChapterLink -- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local Conference = A['Conference'];
	local BookTitle = A['BookTitle'];
	local TransTitle_origin = A:ORIGIN ('TransTitle');
	if 'conference' == config.CitationClass then
		if utilities.is_set (BookTitle) then
			Chapter = Title;
			Chapter_origin = 'title';
	--		ChapterLink = TitleLink;											-- |chapter-link= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			URL_origin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			TransChapter_origin = TransTitle_origin;
			Title = BookTitle;
			Format = '';
	--		TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end
	
	-- CS1/2 mode
	local Mode = is_valid_parameter_value (A['Mode'], A:ORIGIN('Mode'), cfg.keywords_lists['mode'], '');
	-- separator character and postscript
	local sepc, PostScript = set_style (Mode:lower(), A['PostScript'], config.CitationClass);
	-- controls capitalization of certain static text
	local use_lowercase = ( sepc == ',' );
	
	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		if utilities.is_set (Chapter) then										--TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'map') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', Chapter_origin)});	-- add error message
		end
		Chapter = A['Map'];
		Chapter_origin = A:ORIGIN('Map');
		ChapterURL = A['MapURL'];
		ChapterURL_origin = A:ORIGIN('MapURL');
		TransChapter = A['TransMap'];
		ScriptChapter = A['ScriptMap']
		ScriptChapter_origin = A:ORIGIN('ScriptMap')

		ChapterUrlAccess = MapUrlAccess;
		ChapterFormat = A['MapFormat'];

		Cartography = A['Cartography'];
		if utilities.is_set ( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if utilities.is_set ( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	local Series = A['Series'];
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local SeriesLink = A['SeriesLink'];

		SeriesLink = link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wiki-markup in |series-link= or wiki-markup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if utilities.is_set (Network) then table.insert(n, Network); end
		if utilities.is_set (Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if utilities.is_set (Season) and utilities.is_set (SeriesNumber) then	-- these are mutually exclusive so if both are set TODO: make a function for this and similar?
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'season') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'seriesno')});		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if utilities.is_set (Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if utilities.is_set (SeriesNumber) then table.insert(s, wrap_msg ('seriesnum', SeriesNumber, use_lowercase)); end
			if utilities.is_set (Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ScriptChapter_origin = A:ORIGIN('ScriptTitle');
			ChapterLink = TitleLink;											-- alias |episode-link=
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			ChapterFormat = Format;

			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if utilities.is_set (ChapterLink) and not utilities.is_set (ChapterURL) then	-- link but not URL
				Chapter = utilities.make_wikilink (ChapterLink, Chapter);
			elseif utilities.is_set (ChapterLink) and utilities.is_set (ChapterURL) then	-- if both are set, URL links episode;
				Series = utilities.make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			Format = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if utilities.is_set (Series) and utilities.is_set (SeriesLink) then
				Series = utilities.make_wikilink (SeriesLink, Series);
			end
			Series = utilities.wrap_style ('italic-title', Series);				-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- handle type parameter for those CS1 citations that have default values
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	if utilities.in_array (config.CitationClass, {'AV-media-notes', 'interview', 'mailinglist', 'map', 'podcast', 'pressrelease', 'report', 'speech', 'techreport', 'thesis'}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if utilities.is_set (Degree) and &quot;Thesis&quot; == TitleType then				-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if utilities.is_set (TitleType) then										-- if type parameter is specified
		TitleType = utilities.substitute ( cfg.messages['type'], TitleType);	-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
	local Date = A['Date'];
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging
	local PublicationDate = A['PublicationDate'];
	local Year = A['Year'];

	if not utilities.is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not utilities.is_set (Date) and utilities.is_set (PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]

	local DF = is_valid_parameter_value (A['DF'], A:ORIGIN('DF'), cfg.keywords_lists['df'], '');
	if not utilities.is_set (DF) then
		DF = cfg.global_df;														-- local |df= if present overrides global df set by {{use xxx date}} template
	end

	local ArchiveURL;
	local ArchiveDate;
	local ArchiveFormat = A['ArchiveFormat'];

	ArchiveURL, ArchiveDate = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	
	ArchiveURL, ArchiveDate = is_unique_archive_url (ArchiveURL, URL, ChapterURL, A:ORIGIN('ArchiveURL'), ArchiveDate);		-- add error message when URL or ChapterURL == ArchiveURL

	
	local AccessDate = A['AccessDate'];
	local LayDate = A['LayDate'];
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification
	local DoiBroken = A['DoiBroken'];
	local Embargo = A['Embargo'];
	local anchor_year;															-- used in the CITEREF identifier
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val = AccessDate, name = A:ORIGIN ('AccessDate')},
			['archive-date'] = {val = ArchiveDate, name = A:ORIGIN ('ArchiveDate')},
			['date'] = {val = Date, name = Date_origin},
			['doi-broken-date'] = {val = DoiBroken, name = A:ORIGIN ('DoiBroken')},
			['pmc-embargo-date'] = {val = Embargo, name = A:ORIGIN ('Embargo')},
			['lay-date'] = {val = LayDate, name = A:ORIGIN ('LayDate')},
			['publication-date'] = {val = PublicationDate, name = A:ORIGIN ('PublicationDate')},
			['year'] = {val = Year, name = A:ORIGIN ('Year')},
			};

		local error_list = {};
		anchor_year, Embargo = validation.dates(date_parameters_list, COinS_date, error_list);

-- start temporary Julian / Gregorian calendar uncertainty categorization
		if COinS_date.inter_cal_cat then
			utilities.add_prop_cat ('jul-greg-uncertainty');
		end
-- end temporary Julian / Gregorian calendar uncertainty categorization

		if utilities.is_set (Year) and utilities.is_set (Date) then				-- both |date= and |year= not normally needed; 
			validation.year_date_check (Year, A:ORIGIN ('Year'), Date, A:ORIGIN ('Date'), error_list);
		end
		
		if 0 == #error_list then												-- error free dates only; 0 when error_list is empty
			local modified = false;												-- flag
			
			if utilities.is_set (DF) then										-- if we need to reformat dates
				modified = validation.reformat_dates (date_parameters_list, DF);	-- reformat to DF format, use long month names if appropriate
			end

			if true == validation.date_hyphen_to_dash (date_parameters_list) then	-- convert hyphens to dashes where appropriate
				modified = true;
				utilities.set_message ('maint_date_format');					-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language; not supported at en.wiki
			if cfg.date_name_auto_xlate_enable and validation.date_name_xlate (date_parameters_list, cfg.date_digit_auto_xlate_enable ) then
				utilities.set_message ('maint_date_auto_xlated');				-- add maint cat
				modified = true;
			end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				LayDate = date_parameters_list['lay-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end
		else
			utilities.set_message ('err_bad_date', {utilities.make_sep_list (#error_list, error_list)});	-- add this error message
		end
	end	-- end of do

	local ID_list = {};															-- sequence table of rendered identifiers
	local ID_list_coins = {};													-- table of identifiers and their values from args; key is same as cfg.id_handlers's key
	local Class = A['Class'];													-- arxiv class identifier
	
	local ID_support = {
		{A['ASINTLD'], 'ASIN', 'err_asintld_missing_asin', A:ORIGIN ('ASINTLD')},				
		{DoiBroken, 'DOI', 'err_doibroken_missing_doi', A:ORIGIN ('DoiBroken')},
		{Embargo, 'PMC', 'err_embargo_missing_pmc', A:ORIGIN ('Embargo')},
		}

	ID_list, ID_list_coins = identifiers.identifier_lists_get (args, {DoiBroken = DoiBroken, ASINTLD = A['ASINTLD'], Embargo = Embargo, Class = Class}, ID_support);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite ssrn}}, before generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then	-- |arxiv= or |eprint= required for cite arxiv; |biorxiv=, |citeseerx=, |ssrn= required for their templates
		if not (args[cfg.id_handlers[config.CitationClass:upper()].parameters[1]] or 	-- can't use ID_list_coins k/v table here because invalid parameters omitted
			args[cfg.id_handlers[config.CitationClass:upper()].parameters[2]]) then		-- which causes unexpected parameter missing error message
				utilities.set_message ('err_' .. config.CitationClass .. '_missing');	-- add error message
		end

		Periodical = ({['arxiv'] = 'arXiv', ['biorxiv'] = 'bioRxiv', ['citeseerx'] = 'CiteSeerX', ['ssrn'] = 'Social Science Research Network'})[config.CitationClass];
	end

	-- Link the title of the work if no |url= was provided, but we have a |pmc= or a |doi= with |doi-access=free

	if config.CitationClass == &quot;journal&quot; and not utilities.is_set (URL) and not utilities.is_set (TitleLink) and not utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) then -- TODO: remove 'none' once existing citations have been switched to 'off', so 'none' can be used as token for &quot;no title&quot; instead
		if 'none' ~= cfg.keywords_xlate[auto_select] then						-- if auto-linking not disabled
 	 		if identifiers.auto_link_urls[auto_select] then						-- manual selection
		 		URL = identifiers.auto_link_urls[auto_select];					-- set URL to be the same as identifier's external link
 				URL_origin = cfg.id_handlers[auto_select:upper()].parameters[1];	-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['pmc'] then						-- auto-select PMC
				URL = identifiers.auto_link_urls['pmc'];						-- set URL to be the same as the PMC external link if not embargoed
				URL_origin = cfg.id_handlers['PMC'].parameters[1];				-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['doi'] then						-- auto-select DOI
				URL = identifiers.auto_link_urls['doi'];
				URL_origin = cfg.id_handlers['DOI'].parameters[1];
			end
 	 	end

		if utilities.is_set (URL) then											-- set when using an identifier-created URL
			if utilities.is_set (AccessDate) then								-- |access-date= requires |url=; identifier-created URL is not |url=
				utilities.set_message ('err_accessdate_missing_url');			-- add an error message
				AccessDate = '';												-- unset
			end

			if utilities.is_set (ArchiveURL) then								-- |archive-url= requires |url=; identifier-created URL is not |url=
				utilities.set_message ('err_archive_missing_url');				-- add an error message
				ArchiveURL = '';												-- unset
			end
		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not utilities.is_set (Title) and not utilities.is_set (TransTitle) and not utilities.is_set (ScriptTitle) then	-- has special case for cite episode
		utilities.set_message ('err_citation_missing_title', {'episode' == config.CitationClass and 'series' or 'title'});
	end

	if utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) and
			utilities.in_array (config.CitationClass, {'journal', 'citation'}) and
			(utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and
			('journal' == Periodical_origin or 'script-journal' == ScriptPeriodical_origin) then	-- special case for journal cites
				Title = '';														-- set title to empty string
				utilities.set_message ('maint_untitled');						-- add maint cat
	end

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Chapter) and utilities.is_set (Title) and utilities.is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end
	
	-- this is the function call to COinS()
	local OCinSoutput = metadata.COinS({
		['Periodical'] = utilities.strip_apostrophe_markup (Periodical),		-- no markup in the metadata
		['Encyclopedia'] = Encyclopedia,										-- just a flag; content ignored by ~/COinS
		['Chapter'] = metadata.make_coins_title (coins_chapter, ScriptChapter),	-- Chapter and ScriptChapter stripped of bold / italic / accept-as-written markup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = metadata.make_coins_title (coins_title, ScriptTitle),		-- Title and ScriptTitle stripped of bold / italic / accept-as-written markup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date has correctly formatted date if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Quarter'] = COinS_date.rftquarter,
		['Chron'] =  COinS_date.rftchron or (not COinS_date.rftdate and Date) or '',	-- chron but if not set and invalid date format use Date; keep this last bit?
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['ArticleNumber'] = ArticleNumber,
		['Pages'] = coins_pages or metadata.get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At, QuotePage, QuotePages}, 7)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName or Newsgroup,							-- any apostrophe markup already removed from PublisherName
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list_coins,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, and {{cite ssrn}} AFTER generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, CiteSeerX, or ssrn now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass and utilities.is_set (Newsgroup) then
		PublisherName = utilities.substitute (cfg.messages['newsgroup'], external_link( 'news:' .. Newsgroup, Newsgroup, Newsgroup_origin, nil ));
	end

	local Editors;
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	local Contributors;															-- assembled contributors name list
	local contributor_etal;
	local Translators;															-- assembled translators name list
	local translator_etal;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	local Interviewers;															
	local interviewers_list = {};					
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters
	local interviewer_etal;
	
	-- Now perform various field 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.
	do
		local last_first_list;
		local control = { 
			format = NameListStyle,												-- empty string or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			control.maximum , editor_etal = get_display_names (A['DisplayEditors'], #e, 'editors', editor_etal, A:ORIGIN ('DisplayEditors'));
			Editors, EditorCount = list_people (control, e, editor_etal);

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			control.maximum, interviewer_etal = get_display_names (A['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal, A:ORIGIN ('DisplayInterviewers'));
			Interviewers = list_people (control, interviewers_list, interviewer_etal);
		end
		do																		-- now do translators
			control.maximum, translator_etal = get_display_names (A['DisplayTranslators'], #t, 'translators', translator_etal, A:ORIGIN ('DisplayTranslators'));
			Translators = list_people (control, t, translator_etal);
		end
		do																		-- now do contributors
			control.maximum, contributor_etal = get_display_names (A['DisplayContributors'], #c, 'contributors', contributor_etal, A:ORIGIN ('DisplayContributors'));
			Contributors = list_people (control, c, contributor_etal);
		end
		do																		-- now do authors
			control.maximum, author_etal = get_display_names (A['DisplayAuthors'], #a, 'authors', author_etal, A:ORIGIN ('DisplayAuthors'));

			last_first_list = list_people (control, a, author_etal);

			if utilities.is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors');	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if utilities.is_set (Authors) and utilities.is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not utilities.is_set (URL) then
		if utilities.in_array (config.CitationClass, {&quot;web&quot;, &quot;podcast&quot;, &quot;mailinglist&quot;}) or		-- |url= required for cite web, cite podcast, and cite mailinglist
			('citation' == config.CitationClass and ('website' == Periodical_origin or 'script-website' == ScriptPeriodical_origin)) then	-- and required for {{citation}} with |website= or |script-website=
				utilities.set_message ('err_cite_web_url');
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if utilities.is_set (AccessDate) and not utilities.is_set (ChapterURL) then		-- ChapterURL may be set when URL is not set;
			utilities.set_message ('err_accessdate_missing_url');
			AccessDate = '';
		end
	end

	local UrlStatus = is_valid_parameter_value (A['UrlStatus'], A:ORIGIN('UrlStatus'), cfg.keywords_lists['url-status'], '');
	local OriginalURL
	local OriginalURL_origin
	local OriginalFormat
	local OriginalAccess;
	UrlStatus = UrlStatus:lower();												-- used later when assembling archived text
	if utilities.is_set ( ArchiveURL ) then
		if utilities.is_set (ChapterURL) then 									-- if chapter-url= is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURL_origin = ChapterURL_origin;								-- name of |chapter-url= parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=

			if 'live' ~= UrlStatus then
				ChapterURL = ArchiveURL											-- swap-in the archive's URL
				ChapterURL_origin = A:ORIGIN('ArchiveURL')						-- name of |archive-url= parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived URLs
			end
		elseif utilities.is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURL_origin = URL_origin;									-- name of URL parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;

			if 'live' ~= UrlStatus then											-- if URL set then |archive-url= applies to it
				URL = ArchiveURL												-- swap-in the archive's URL
				URL_origin = A:ORIGIN('ArchiveURL')								-- name of archive URL parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived URLs
			end
		end
	elseif utilities.is_set (UrlStatus) then									-- if |url-status= is set when |archive-url= is not set
 		utilities.set_message ('maint_url_status');								-- add maint cat
	end

	if utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) then
			local chap_param;
			if utilities.is_set (Chapter) then									-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif utilities.is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif utilities.is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif utilities.is_set (ScriptChapter) then
				chap_param = ScriptChapter_origin;
			else utilities.is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if utilities.is_set (chap_param) then								-- if we found one
				utilities.set_message ('err_chapter_ignored', {chap_param});	-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if utilities.is_set (Contribution) and 0 &lt; #c then						-- if this is a contribution with contributor(s)
			if utilities.in_array (Contribution:lower(), cfg.keywords_lists.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, ScriptChapter_origin, Chapter, Chapter_origin, TransChapter, TransChapter_origin, ChapterURL, ChapterURL_origin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if utilities.is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and utilities.is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter .. sepc .. ' ';
		elseif utilities.is_set (ChapterFormat) then							-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title
	local plain_title = false;
	local accept_title;
	Title, accept_title = utilities.has_accept_as_written (Title, true);		-- remove accept-this-as-written markup when it wraps all of &lt;Title&gt;
	if accept_title and ('' == Title) then										-- only support forced empty for now &quot;(())&quot;
		Title = cfg.messages['notitle'];										-- replace by predefined &quot;No title&quot; message
			-- TODO: utilities.set_message ( 'err_redundant_parameters', ...);	-- issue proper error message instead of muting	 
			ScriptTitle = '';													-- just mute for now	 
			TransTitle = '';													-- just mute for now
 		plain_title = true;														-- suppress text decoration for descriptive title
		utilities.set_message ('maint_untitled');								-- add maint cat
	end

	if not accept_title then													-- &lt;Title&gt; not wrapped in accept-as-written markup
		if '...' == Title:sub (-3) then											-- if ellipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%' .. sepc .. '$', '');			-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end

		if utilities.is_set (ArchiveURL) and is_archived_copy (Title) then
			utilities.set_message ('maint_archived_copy');						-- add maintenance category before we modify the content of Title
		end

		if is_generic ('generic_titles', Title) then
			utilities.set_message ('err_generic_title');						-- set an error message
		end
	end

	if (not plain_title) and (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) or
		('map' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)))) then		-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from module provided quote marks
			Title = utilities.wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle, 'script-title');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
			TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );
	elseif plain_title or ('report' == config.CitationClass) then				-- no styling for cite report and descriptive titles (otherwise same as above)
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );	-- for cite report, use this form for trans-title
	else
		Title = utilities.wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-italic-title', TransTitle);
	end

	if utilities.is_set (TransTitle) then
		if utilities.is_set (Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			utilities.set_message ('err_trans_missing_title', {'title'});
		end
	end

	if utilities.is_set (Title) then											-- TODO: is this the right place to be making Wikisource URLs?
		if utilities.is_set (TitleLink) and utilities.is_set (URL) then
			utilities.set_message ('err_wikilink_in_url');						-- set an error message because we can't have both
			TitleLink = '';														-- unset
		end
	
		if not utilities.is_set (TitleLink) and utilities.is_set (URL) then
			Title = external_link (URL, Title, URL_origin, UrlAccess) .. TransTitle .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif utilities.is_set (TitleLink) and not utilities.is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle;
			else
				Title = utilities.make_wikilink (TitleLink, Title) .. TransTitle;
			end
		else
			local ws_url, ws_label, L;											-- Title has italic or quote markup by the time we get here which causes is_wikilink() to return 0 (not a wikilink)
			ws_url, ws_label, L = wikisource_url_make (Title:gsub('^[\'&quot;]*(.-)[\'&quot;]*$', '%1'));	-- make ws URL from |title= interwiki link (strip italic or quote markup); link portion L becomes tooltip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle;
			else
				Title = Title .. TransTitle;
			end
		end
	else
		Title = TransTitle;
	end

	if utilities.is_set (Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	local ConferenceURL_origin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	if utilities.is_set (Conference) then
		if utilities.is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURL_origin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif utilities.is_set (ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURL_origin, nil );
	end

	local Position = '';
	if not utilities.is_set (Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if utilities.is_set (Minutes) then
			if utilities.is_set (Time) then		--TODO: make a function for this and similar?
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'minutes') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'time')});
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if utilities.is_set (Time) then
				local TimeCaption = A['TimeCaption']
				if not utilities.is_set (TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = utilities.is_set (At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = utilities.is_set (Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Sections = A['Sections'];											-- Section (singular) is an alias of Chapter so set earlier
		local Inset = A['Inset'];
		
		if utilities.is_set ( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if utilities.is_set ( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif utilities.is_set ( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	local Others = A['Others'];
	if utilities.is_set (Others) and 0 == #a and 0 == #e then					-- add maint cat when |others= has value and used without |author=, |editor=
		if config.CitationClass == &quot;AV-media-notes&quot;
		or config.CitationClass == &quot;audio-visual&quot; then							-- special maint for AV/M which has a lot of 'false' positives right now
			utilities.set_message ('maint_others_avm')
		else
			utilities.set_message ('maint_others');
		end
	end
	Others = utilities.is_set (Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if utilities.is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if utilities.is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	local TitleNote = A['TitleNote'];
	TitleNote = utilities.is_set (TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if utilities.is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%n?%.?$') or Edition:match ('%f[%a][Ee]dition$') then -- Ed, ed, Ed., ed., Edn, edn, Edn., edn.
			utilities.set_message ('err_extra_text_edition');					 -- add error message
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = utilities.is_set (Series) and wrap_msg ('series', {sepc, Series}) or &quot;&quot;;	-- not the same as SeriesNum
	local Agency = A['Agency'];
	Agency = utilities.is_set (Agency) and wrap_msg ('agency', {sepc, Agency}) or &quot;&quot;;
	Volume = format_volume_issue (Volume, Issue, ArticleNumber, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	if utilities.is_set (AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = utilities.substitute (retrv_text, AccessDate);				-- add retrieved text

		AccessDate = utilities.substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if utilities.is_set (ID) then ID = sepc .. &quot; &quot; .. ID; end
	
	local Docket = A['Docket'];
   	if &quot;thesis&quot; == config.CitationClass and utilities.is_set (Docket) then
		ID = sepc .. &quot; Docket &quot; .. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and utilities.is_set (Docket) then		-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	if utilities.is_set (URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URL_origin, UrlAccess );
	end

	local Quote = A['Quote'];
	local TransQuote = A['TransQuote'];
	local ScriptQuote = A['ScriptQuote'];
	if utilities.is_set (Quote) or utilities.is_set (TransQuote) or utilities.is_set (ScriptQuote) then

		if utilities.is_set (Quote) then
			if Quote:sub(1, 1) == '&quot;' and Quote:sub(-1, -1) == '&quot;' then			-- if first and last characters of quote are quote marks
				Quote = Quote:sub(2, -2);										-- strip them off
			end
		end
		
		Quote = kern_quotes (Quote);											-- kern if needed
		Quote = utilities.wrap_style ('quoted-text', Quote );					-- wrap in &lt;q&gt;...&lt;/q&gt; tags
	
		if utilities.is_set (ScriptQuote) then
			Quote = script_concatenate (Quote, ScriptQuote, 'script-quote');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after quote is wrapped
		end

		if utilities.is_set (TransQuote) then
			if TransQuote:sub(1, 1) == '&quot;' and TransQuote:sub(-1, -1) == '&quot;' then -- if first and last characters of |trans-quote are quote marks
				TransQuote = TransQuote:sub(2, -2); -- strip them off
			end
			Quote = Quote .. &quot; &quot; .. utilities.wrap_style ('trans-quoted-title', TransQuote );
		end

		if utilities.is_set (QuotePage) or utilities.is_set (QuotePages) then	-- add page prefix
			local quote_prefix = '';
			if utilities.is_set (QuotePage) then
				extra_text_in_page_check (QuotePage, 'quote-page');				-- add to maint cat if |quote-page= value begins with what looks like p., pp., etc.
				if not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePage}), '', '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePage}), '', '', '';
				end
			elseif utilities.is_set (QuotePages) then
				extra_text_in_page_check (QuotePages, 'quote-pages');			-- add to maint cat if |quote-pages= value begins with what looks like p., pp., etc.
				if tonumber(QuotePages) ~= nil and not NoPP then				-- if only digits, assume single page
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePages}), '', '';
				elseif not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['pp-prefix'], {sepc, QuotePages}), '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePages}), '', '';
				end
			end
                        
			Quote = quote_prefix .. &quot;: &quot; .. Quote;
		else
			Quote = sepc .. &quot; &quot; .. Quote;
		end

		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	-- We check length of PostScript here because it will have been nuked by
	-- the quote parameters. We'd otherwise emit a message even if there wasn't
	-- a displayed postscript.
	-- TODO: Should the max size (1) be configurable?
	-- TODO: Should we check a specific pattern?
	if utilities.is_set(PostScript) and mw.ustring.len(PostScript) &gt; 1 then
		utilities.set_message ('maint_postscript')
	end
	
	local Archived;
	if utilities.is_set (ArchiveURL) then
		local arch_text;
		if not utilities.is_set (ArchiveDate) then
			utilities.set_message ('err_archive_missing_date');
			ArchiveDate = '';													-- empty string for concatenation
		end
		if &quot;live&quot; == UrlStatus then
			arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if utilities.is_set (ArchiveDate) then
				Archived = sepc .. ' ' .. utilities.substitute ( cfg.messages['archived-live'],
					{external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil) .. ArchiveFormat, ArchiveDate } );
			else
				Archived = '';
			end
			if not utilities.is_set (OriginalURL) then
				utilities.set_message ('err_archive_missing_url');
				Archived = '';													-- empty string for concatenation
			end
		elseif utilities.is_set (OriginalURL) then								-- UrlStatus is empty, 'dead', 'unfit', 'usurped', 'bot: unknown'
			if utilities.in_array (UrlStatus, {'unfit', 'usurped', 'bot: unknown'}) then
				arch_text = cfg.messages['archived-unfit'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. ' ' .. arch_text .. ArchiveDate;				-- format already styled
				if 'bot: unknown' == UrlStatus then
					utilities.set_message ('maint_bot_unknown');				-- and add a category if not already added
				else
					utilities.set_message ('maint_unfit');						-- and add a category if not already added
				end
			else																-- UrlStatus is empty, 'dead'
				arch_text = cfg.messages['archived-dead'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				if utilities.is_set (ArchiveDate) then
					Archived = sepc .. &quot; &quot; .. utilities.substitute ( arch_text,
						{ external_link( OriginalURL, cfg.messages['original'], OriginalURL_origin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
				else
					Archived = '';												-- unset for concatenation
				end
			end	
		else																	-- OriginalUrl not set
			arch_text = cfg.messages['archived-missing'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			utilities.set_message ('err_archive_missing_url');
			Archived = '';														-- empty string for concatenation
		end
	elseif utilities.is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = '';
	end
	
	local Lay = '';
	local LaySource = A['LaySource'];
	local LayURL = A['LayURL'];
	local LayFormat = A['LayFormat'];
	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
	if utilities.is_set (LayURL) then
		if utilities.is_set (LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
		if utilities.is_set (LaySource) then 
			LaySource = &quot; &amp;ndash; ''&quot; .. utilities.safe_for_italics (LaySource) .. &quot;''&quot;;
		else
			LaySource = &quot;&quot;;
		end
		if sepc == '.' then
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		else
			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
		end			
	elseif utilities.is_set (LayFormat) then									-- Test if |lay-format= is given without giving a |lay-url=
		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
	end

	local TranscriptURL = A['TranscriptURL']
	local TranscriptFormat = A['TranscriptFormat'];
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');
	local Transcript = A['Transcript'];
	local TranscriptURL_origin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL
	if utilities.is_set (Transcript) then
		if utilities.is_set (TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURL_origin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif utilities.is_set (TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURL_origin, nil );
	end

	local Publisher;
	if utilities.is_set (PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if utilities.is_set (PublisherName) then
		if utilities.is_set (PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif utilities.is_set (PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	local TransPeriodical =  A['TransPeriodical'];
	local TransPeriodical_origin =  A:ORIGIN ('TransPeriodical');
	-- Several of the above rely upon detecting this as nil, so do it last.
	if (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical)) then
		if utilities.is_set (Title) or utilities.is_set (TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		else 
			Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		end
	end
	
	local Language = A['Language'];
	if utilities.is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc.
	else
		Language='';															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then									-- cite speech only
		TitleNote = TitleType;													-- move TitleType to TitleNote so that it renders ahead of |event=
		TitleType = '';															-- and unset

		if utilities.is_set (Periodical) then									-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if utilities.is_set (Conference) then								-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;							-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
		if not (utilities.is_set (Authors) or utilities.is_set (Editors)) then
			Others = Others:gsub ('^' .. sepc .. ' ', '');						-- when no authors and no editors, strip leading sepc and space
		end
		if utilities.is_set (Others) then Others = safe_join ({Others, sepc .. &quot; &quot;}, sepc) end		-- add terminal punctuation &amp; space; check for dup sepc; TODO why do we need to do this here?
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (Periodical) then		-- special cases for book cites
		if utilities.is_set (Contributors) then									-- when we are citing foreword, preface, introduction, etc.
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if utilities.is_set (Chapter) then										-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif utilities.is_set (Periodical) then								-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local Via = A['Via'];
	Via = utilities.is_set (Via) and  wrap_msg ('via', Via) or '';
	local idcommon;
	if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then	-- special case for cite AV media &amp; cite episode position transcript
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, Lay, Quote }, sepc );
	else
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, Lay, Quote }, sepc );
	end
	
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	local OrigDate = A['OrigDate'];
	OrigDate = utilities.is_set (OrigDate) and wrap_msg ('origdate', OrigDate) or '';
	if utilities.is_set (Date) then
		if utilities.is_set (Authors) or utilities.is_set (Editors) then		-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date .. &quot;)&quot; .. OrigDate .. sepc .. &quot; &quot;;				-- in parentheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon, -1, -1) == sepc) then						-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigDate;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigDate;							-- Date begins with sepc
			end
		end
	end	
	if utilities.is_set (Authors) then
		if (not utilities.is_set (Date)) then									-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Editors) then
			local in_text = &quot; &quot;;
			local post_text = &quot;&quot;;
			if utilities.is_set (Chapter) and 0 == #c then
				in_text = in_text .. cfg.messages['in'] .. &quot; &quot;
				if (sepc ~= '.') then
					in_text = in_text:lower()									-- lowercase for cs2
				end
			end
			if EditorCount &lt;= 1 then
				post_text = &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot;;				-- be consistent with no-author, no-date case
			else
				post_text = &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot;;
			end
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Contributors) then									-- book cite and we're citing the intro, preface, etc.
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if utilities.is_set (Editors) and utilities.is_set (Date) then		-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not utilities.is_set (Date)) then								-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif utilities.is_set (Editors) then
		if utilities.is_set (Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. cfg.presentation['sep_name'] .. cfg.messages['editor'];
			else
				Editors = Editors .. cfg.presentation['sep_name'] .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if utilities.is_set (PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc ); 								-- Deals with italics, spaces, etc.
		text = text:sub(1, -sepc:len() - 1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite&gt; element
	local options_t = {};
	options_t.class = cite_class_attribute_make (config.CitationClass, Mode);

	local Ref = is_valid_parameter_value (A['Ref'], A:ORIGIN('Ref'), cfg.keywords_lists['ref'], nil, true);	-- nil when |ref=harv; A['Ref'] else

	if 'none' ~= cfg.keywords_xlate[(Ref and Ref:lower()) or ''] then
		local namelist_t = {};													-- holds selected contributor, author, editor name list
		local year = first_set ({Year, anchor_year}, 2);						-- Year first for legacy citations and for YMD dates that require disambiguation

		if #c &gt; 0 then															-- if there is a contributor list
			namelist_t = c;														-- select it
		elseif #a &gt; 0 then														-- or an author list
			namelist_t = a;
		elseif #e &gt; 0 then														-- or an editor list
			namelist_t = e;
		end
		local citeref_id;
		if #namelist_t &gt; 0 then													-- if there are names in namelist_t
			citeref_id = make_citeref_id (namelist_t, year);					-- go make the CITEREF anchor
			if mw.uri.anchorEncode (citeref_id) == ((Ref and mw.uri.anchorEncode (Ref)) or '') then	-- Ref may already be encoded (by {{sfnref}}) so citeref_id must be encoded before comparison
				utilities.set_message ('maint_ref_duplicates_default');
			end
		else
			citeref_id = '';													-- unset
		end
		options_t.id = Ref or citeref_id;
	end

	if string.len (text:gsub('%b&lt;&gt;', '')) &lt;= 2 then								-- remove html and html-like tags; then get length of what remains; 
		z.error_cats_t = {};													-- blank the categories list
		z.error_msgs_t = {};													-- blank the error messages list
		OCinSoutput = nil;														-- blank the metadata string
		text = '';																-- blank the the citation
		utilities.set_message ('err_empty_citation');							-- set empty citation message and category
	end
	
	local render_t = {};														-- here we collect the final bits for concatenation into the rendered citation

	if utilities.is_set (options_t.id) then										-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render_t, utilities.substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options_t.id), mw.text.nowiki(options_t.class), text}));	-- when |ref= is set or when there is a namelist
	else
		table.insert (render_t, utilities.substitute (cfg.presentation['cite'], {mw.text.nowiki(options_t.class), text}));	-- when |ref=none or when namelist_t empty and |ref= is missing or is empty
	end		

	if OCinSoutput then															-- blanked when citation is 'empty' so don't bother to add boilerplate metadata span
		table.insert (render_t, utilities.substitute (cfg.presentation['ocins'], OCinSoutput));	-- format and append metadata to the citation
	end

	local template_name = ('citation' == config.CitationClass) and 'citation' or 'cite ' .. (cfg.citation_class_map_t[config.CitationClass] or config.CitationClass);
	local template_link = '[[Template:' .. template_name .. '|' .. template_name .. ']]';
	local msg_prefix = '&lt;code class=&quot;cs1-code&quot;&gt;{{' .. template_link .. '}}&lt;/code&gt;: ';

	if 0 ~= #z.error_msgs_t then
		mw.addWarning (utilities.substitute (cfg.messages.warning_msg_e, template_link));

		table.insert (render_t, ' ');											-- insert a space between citation and its error messages
		table.sort (z.error_msgs_t);											-- sort the error messages list; sorting includes wrapping &lt;span&gt; and &lt;code&gt; tags; hidden-error sorts ahead of visible-error

		local hidden = true;													-- presume that the only error messages emited by this template are hidden
		for _, v in ipairs (z.error_msgs_t) do									-- spin through the list of error messages
			if v:find ('cs1-visible-error', 1, true) then						-- look for the visible error class name
				hidden = false;													-- found one; so don't hide the error message prefix
				break;															-- and done because no need to look further
			end
		end

		z.error_msgs_t[1] = table.concat ({utilities.error_comment (msg_prefix, hidden), z.error_msgs_t[1]});	-- add error message prefix to first error message to prevent extraneous punctuation
		table.insert (render_t, table.concat (z.error_msgs_t, '; '));			-- make a big string of error messages and add it to the rendering
	end

	if 0 ~= #z.maint_cats_t then
		mw.addWarning (utilities.substitute (cfg.messages.warning_msg_m, template_link));

		table.sort (z.maint_cats_t);											-- sort the maintenance messages list

		local maint_msgs_t = {};												-- here we collect all of the maint messages

		if 0 == #z.error_msgs_t then											-- if no error messages
			table.insert (maint_msgs_t, msg_prefix);							-- insert message prefix in maint message livery
		end
		
		for _, v in ipairs( z.maint_cats_t ) do									-- append maintenance categories
			table.insert (maint_msgs_t, 										-- assemble new maint message and add it to the maint_msgs_t table
				table.concat ({v, ' (', utilities.substitute (cfg.messages[':cat wikilink'], v), ')'})
				);
		end
		table.insert (render_t, utilities.substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs_t, ' ')));	-- wrap the group of maint messages with proper presentation and save
	end

	if not no_tracking_cats then
		for _, v in ipairs (z.error_cats_t) do									-- append error categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
		end
		for _, v in ipairs (z.maint_cats_t) do									-- append maintenance categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
		end
		for _, v in ipairs (z.prop_cats_t) do									-- append properties categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
		end
	end

	return table.concat (render_t);												-- make a big string and done
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class, empty)
	local name = tostring (name);
	local enum_name;															-- for enumerated parameters, is name with enumerator replaced with '#'
	local state;
	local function state_test (state, name)										-- local function to do testing of state values
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			if empty then return nil; end										-- empty deprecated parameters are treated as unknowns
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
		if 'tracked' == state then
			local base_name = name:gsub ('%d', '');								-- strip enumerators from parameter names that have them to get the base name
			utilities.add_prop_cat ('tracked-param', {base_name}, base_name);	-- add a properties category; &lt;base_name&gt; modifies &lt;key&gt;
			return true;
		end
		return nil;
	end		

	if name:find ('#') then														-- # is a cs1|2 reserved character so parameters with # not permitted
		return nil;
	end

	if utilities.in_array (cite_class, whitelist.preprint_template_list ) then	-- limited parameter sets allowed for these templates
		state = whitelist.limited_basic_arguments[name];
		if true == state_test (state, name) then return true; end

		state = whitelist.preprint_arguments[cite_class][name];					-- look in the parameter-list for the template identified by cite_class
		if true == state_test (state, name) then return true; end

																				-- limited enumerated parameters list
		enum_name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );										-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
		state = whitelist.limited_numbered_arguments[enum_name];
		if true == state_test (state, name) then return true; end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates

	if utilities.in_array (cite_class, whitelist.unique_param_template_list) then 	-- experiment for template-specific parameters for templates that accept parameters from the basic argument list
		state = whitelist.unique_arguments[cite_class][name];					-- look in the template-specific parameter-lists for the template identified by cite_class
		if true == state_test (state, name) then return true; end
	end																			-- if here, fall into general validation
		
	state = whitelist.basic_arguments[name];									-- all other templates; all normal parameters allowed
	if true == state_test (state, name) then return true; end

																				-- all enumerated parameters allowed
	enum_name = name:gsub(&quot;%d+&quot;, &quot;#&quot; );											-- replace digit(s) with # (last25 becomes last#) (mw.ustring because non-Western 'local' digits)
	state = whitelist.numbered_arguments[enum_name];
	if true == state_test (state, name) then return true; end

	return false;																-- not supported because not found or name is set to nil
end


--[=[-------------------------&lt; I N T E R _ W I K I _ C H E C K &gt;----------------------------------------------

check &lt;value&gt; for inter-language interwiki-link markup.  &lt;prefix&gt; must be a MediaWiki-recognized language
code.  when these values have the form (without leading colon):
	[[&lt;prefix&gt;:link|label]] return label as plain-text
	[[&lt;prefix&gt;:link]] return &lt;prefix&gt;:link as plain-text

return value as is else

]=]

local function inter_wiki_check (parameter, value)
	local prefix = value:match ('%[%[(%a+):');									-- get an interwiki prefix if one exists
	local _;
	
	if prefix and cfg.inter_wiki_map[prefix:lower()] then						-- if prefix is in the map, needs preceding colon so
		utilities.set_message ('err_bad_paramlink', parameter);					-- emit an error message
		_, value, _ = utilities.is_wikilink (value);							-- extract label portion from wikilink
	end
	return value;
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe.  There are two tests made:
	{{cite ... |title=Title access-date=2016-03-17}}	-- the first parameter has a value and whitespace separates that value from the missing pipe parameter name
	{{cite ... |title=access-date=2016-03-17}}			-- the first parameter has no value (whitespace after the first = is trimmed by MediaWiki)
cs1|2 shares some parameter names with XML/HTML attributes: class=, title=, etc.  To prevent false positives XML/HTML
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (parameter, value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove XML/HTML tags because attributes: class=, title=, etc.

	capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then										-- if the capture is a valid parameter name
		utilities.set_message ('err_missing_pipe', parameter);
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ P U N C T &gt;--------------------------------------

look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_punc (param, value)
	if 'number' == type (param) then
		return;
	end
	
	param = param:gsub ('%d+', '#');											-- enumerated name-list mask params allow terminal punct; normalize 
	if cfg.punct_skip[param] then
		return;																	-- parameter name found in the skip table so done
	end
	
	if value:match ('[,;:]$') then
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
	if value:match ('^=') then													-- sometimes an extraneous '=' character appears ...
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ U R L &gt;------------------------------------------

look for extraneous url parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_url (url_param_t)
	local url_error_t = {};
	
	check_for_url (url_param_t, url_error_t);									-- extraneous url check
	if 0 ~= #url_error_t then													-- non-zero when there are errors
		table.sort (url_error_t);
		utilities.set_message ('err_param_has_ext_link', {utilities.make_sep_list (#url_error_t, url_error_t)});	-- add this error message
	end
end


--[[--------------------------&lt; C I T A T I O N &gt;--------------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

local function citation(frame)
	Frame = frame;																-- save a copy in case we need to display an error message in preview mode

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do											-- get parameters from the {{#invoke}} frame
		config[k] = v;
	--	args[k] = v;															-- crude debug support that allows us to render a citation from module {{#invoke:}}; skips parameter validation; TODO: keep?
	end	
																				-- i18n: set the name that your wiki uses to identify sandbox subpages from sandbox template invoke (or can be set here)
	local sandbox = ((config.SandboxPath and '' ~= config.SandboxPath) and config.SandboxPath) or '/sandbox';	-- sandbox path from {{#invoke:Citation/CS1/sandbox|citation|SandboxPath=/...}}
	is_sandbox = nil ~= string.find (frame:getTitle(), sandbox, 1, true);		-- is this invoke the sandbox module?
	sandbox = is_sandbox and sandbox or '';										-- use i18n sandbox to load sandbox modules when this module is the sandox; live modules else

	local pframe = frame:getParent()
	local styles;
	
	cfg = mw.loadData ('Module:Citation/CS1/Configuration' .. sandbox);			-- load sandbox versions of support modules when {{#invoke:Citation/CS1/sandbox|...}}; live modules else
	whitelist = mw.loadData ('Module:Citation/CS1/Whitelist' .. sandbox);
	utilities = require ('Module:Citation/CS1/Utilities' .. sandbox);
	validation = require ('Module:Citation/CS1/Date_validation' .. sandbox);
	identifiers = require ('Module:Citation/CS1/Identifiers' .. sandbox);
	metadata = require ('Module:Citation/CS1/COinS' .. sandbox);
	styles = 'Module:Citation/CS1' .. sandbox .. '/styles.css';

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the selected cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	is_preview_mode = not utilities.is_set (frame:preprocess ('{{REVISIONID}}'));

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text;															-- used as a flag

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	local empty_unknowns = {};													-- sequence table to hold empty unknown params for error message listing
	for k, v in pairs( pframe.args ) do											-- get parameters from the parent (template) frame
		v = mw.ustring.gsub (v, '^%s*(.-)%s*$', '%1');							-- trim leading/trailing whitespace; when v is only whitespace, becomes empty string
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				if type (k) ~= 'string' then									-- exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text = utilities.set_message ('err_text_ignored', {v});
					end
				elseif validate (k:lower(), config.CitationClass) then 
					error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, k:lower()});	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						suggestions = mw.loadData ('Module:Citation/CS1/Suggestions' .. sandbox);	--load sandbox version of suggestion module when {{#invoke:Citation/CS1/sandbox|...}}; live module else
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no capture in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = utilities.substitute (param, capture);		-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, param});	-- set the suggestion error message
							else
								error_text = utilities.set_message ('err_parameter_ignored', {k});	-- suggested param not supported by this template
								v = '';											-- unset
							end
						end
					end
					if not utilities.is_set (error_text) then					-- couldn't match with a pattern, is there an explicit suggestion?						
						if (suggestions.suggestions[ k:lower() ] ~= nil) and validate (suggestions.suggestions[ k:lower() ], config.CitationClass) then
							utilities.set_message ('err_parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]});
						else
							utilities.set_message ('err_parameter_ignored', {k});
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
			end

			args[k] = v;														-- save this parameter and its value

		elseif not utilities.is_set (v) then									-- for empty parameters
			if not validate (k, config.CitationClass, true) then				-- is this empty parameter a valid parameter
				k = ('' == k) and '(empty string)' or k;						-- when k is empty string (or was space(s) trimmed to empty string), replace with descriptive text
				table.insert (empty_unknowns, utilities.wrap_style ('parameter', k));	-- format for error message and add to the list
			end
																				-- crude debug support that allows us to render a citation from module {{#invoke:}} TODO: keep?
	--	elseif args[k] ~= nil or (k == 'postscript') then						-- when args[k] has a value from {{#invoke}} frame (we don't normally do that)
	--		args[k] = v;														-- overwrite args[k] with empty string from pframe.args[k] (template frame); v is empty string here
		end																		-- not sure about the postscript bit; that gets handled in parameter validation; historical artifact?
	end	

	if 0 ~= #empty_unknowns then												-- create empty unknown error message
		utilities.set_message ('err_param_unknown_empty', {
			1 == #empty_unknowns and '' or 's',
			utilities.make_sep_list (#empty_unknowns, empty_unknowns)
			});
	end

	local url_param_t = {};

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);											-- look for invisible characters
		end
		has_extraneous_punc (k, v);												-- look for extraneous terminal punctuation in parameter values
		missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?
		args[k] = inter_wiki_check (k, v);										-- when language interwiki-linked parameter missing leading colon replace with wiki-link label

		if 'string' == type (k) and not cfg.url_skip[k] then					-- when parameter k is not positional and not in url skip table
			url_param_t[k] = v;													-- make a parameter/value list for extraneous url check
		end
	end

	has_extraneous_url (url_param_t);											-- look for url in parameter values where a url does not belong

	return table.concat ({
		frame:extensionTag ('templatestyles', '', {src=styles}),
		citation0( config, args)
	});
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {citation = citation};</text>
      <sha1>i7z918lp7p82rgiud4zhl7nejkm3ae9</sha1>
    </revision>
    <revision>
      <id>4751</id>
      <parentid>4750</parentid>
      <timestamp>2023-08-12T19:19:13Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4751</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="223518" sha1="tdu8ggjbxwo5jmdozqbp8w94qat411d" xml:space="preserve">require ('strict');

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------

each of these counts against the Lua upvalue limit

]]

local validation;																-- functions in Module:Citation/CS1/Date_validation

local utilities;																-- functions in Module:Citation/CS1/Utilities
local z = {};																	-- table of tables in Module:Citation/CS1/Utilities

local identifiers;																-- functions and tables in Module:Citation/CS1/Identifiers
local metadata;																	-- functions in Module:Citation/CS1/COinS
local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;---------------

declare variables here that have page-wide scope that are not brought in from
other modules; that are created here and used here

]]

local added_deprecated_cat;														-- Boolean flag so that the category is added only once
local added_vanc_errs;															-- Boolean flag so we only emit one Vancouver error / category
local added_generic_name_errs;													-- Boolean flag so we only emit one generic name error / category and stop testing names once an error is encountered
local Frame;																	-- holds the module's frame table
local is_preview_mode;															-- true when article is in preview mode; false when using 'Preview page with this template' (previewing the module)
local is_sandbox;																-- true when using sandbox modules to render citation


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if utilities.is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a Boolean declared in page scope variables above

]]

local function add_vanc_error (source, position)
	if added_vanc_errs then return end
		
	added_vanc_errs = true;														-- note that we've added this category
	utilities.set_message ('err_vancouver', {source, position});
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a URI scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of TLDs: https://www.iana.org/domains/root/db

RFC 952 (modified by RFC 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the TLD.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a URL with a scheme) will be stripped
here.  Perhaps not necessary but retained in case it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ASCII characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the TLD) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and TLD or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%w]') then											-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at Wikisource
		return false;
	end

	local patterns = {															-- patterns that look like URLs
		'%f[%w][%w][%w%-]+[%w]%.%a%a+$',										-- three or more character hostname.hostname or hostname.tld
		'%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$',									-- internationalized domain name with ACE prefix
		'%f[%a][qxz]%.com$',													-- assigned one character .com hostname (x.com times out 2015-12-10)
		'%f[%a][iq]%.net$',														-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		'%f[%w][%w]%.%a%a$',													-- one character hostname and ccTLD (2 chars)
		'%f[%w][%w][%w]%.%a%a+$',												-- two character hostname and TLD
		'^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?',								-- IPv4 address
		}

	for _, pattern in ipairs (patterns) do										-- loop through the patterns list
		if domain:match (pattern) then
			return true;														-- if a match then we think that this thing that purports to be a URL is a URL
		end
	end

	for _, d in ipairs (cfg.single_letter_2nd_lvl_domains_t) do					-- look for single letter second level domain names for these top level domains
		if domain:match ('%f[%w][%w]%.' .. d) then
			return true
		end
	end
	return false;																-- no matches, we don't know what this thing is
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a URL appear to be a valid URL; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if utilities.is_set (scheme) then											-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when URL is protocol-relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a URL into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following TLD) (if any) and any path(/), query(?) or fragment(#).

If protocol-relative URL, return nil scheme and domain else return nil for both scheme and domain.

When not protocol-relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Any URL that does not have news: scheme must have authority indicator (//).  TODO: are there other common schemes
like news: that don't use authority indicator?

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol-relative URL
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		if utilities.is_set (authority) then
			authority = authority:gsub ('//', '', 1);							-- replace place 1 pair of '/' with nothing;
			if utilities.is_set(authority) then									-- if anything left (1 or 3+ '/' where authority should be) then
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		else
			if not scheme:match ('^news:') then									-- except for news:..., MediaWiki won't link URLs that do not have authority indicator; TODO: a better way to do this test?
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link=, etc. for properly formatted content: no wikilinks, no URLs

Link parameters are to hold the title of a Wikipedia article, so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki URLs and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid URL (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid URL (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from URL; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid URL
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wiki-linked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

check &lt;link&gt; for inter-language interwiki-link prefix.  prefix must be a MediaWiki-recognized language
code and must begin with a colon.

]]

local function link_title_ok (link, lorig, title, torig)
	local orig;
	if utilities.is_set (link) then 											-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		elseif link:match ('^%a+:') then										-- if the link is what looks like an interwiki
			local prefix = link:match ('^(%a+):'):lower();						-- get the interwiki prefix

			if cfg.inter_wiki_map[prefix] then									-- if prefix is in the map, must have preceding colon
				orig = lorig;													-- flag as error
			end
		end
	end

	if utilities.is_set (orig) then
		link = '';																-- unset
		utilities.set_message ('err_bad_paramlink', orig);						-- URL or wikilink in |title= with |title-link=;
	end
	
	return link;																-- link if ok, empty string else
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the URL into scheme and domain
portions, or for protocol-relative (//example.com) URLs, just the domain.  Use is_url() to validate the two
portions of the URL.  If both are valid, or for protocol-relative if domain is valid, return true, else false.

Because it is different from a standard URL, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper URL
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from URL;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a URL.  The test will also find external wikilinks
that use protocol-relative URLs. Also finds bare URLs.

The frontier pattern prevents a match on interwiki-links which are similar to scheme:path URLs.  The tests that
find bracketed URLs are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext. wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol-relative ext. wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare URL with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol-relative bare URL: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a URL
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list, error_list)
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a URL add an error message
			table.insert (error_list, utilities.wrap_style ('parameter', k));
		end
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		utilities.set_message ('err_wikilink_in_url', {});
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link (URL, label, source, access)
	local err_msg = '';
	local domain;
	local path;
	local base_url;

	if not utilities.is_set (label) then
		label = URL;
		if utilities.is_set (source) then
			utilities.set_message ('err_bare_url_missing_title', {utilities.wrap_style ('parameter', source)});
		else
			error (cfg.messages[&quot;bare_url_no_origin&quot;]);							-- programmer error; valid parameter name does not have matching meta-parameter
		end			
	end
	if not check_url (URL) then
		utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)});
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the URL into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['['] = '%5b', [']'] = '%5d'});			-- replace '[' and ']' with their percent-encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat ({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wiki-markup URL

	if utilities.is_set (access) then											-- access level (subscription, registration, limited)
		base_url = utilities.substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end

	return base_url;
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a Boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		utilities.set_message ('err_deprecated_params', {name});				-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wiki-markup) are not kerned.

Replaces Unicode quote marks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc.; not for book titles.

]=]

local function kern_quotes (str)
	local cap = '';
	local wl_type, label, link;

	wl_type, label, link = utilities.is_wikilink (str);							-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-left'], str);
			str = utilities.substitute (cfg.presentation['kern-right'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = utilities.substitute (cfg.presentation['kern-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label = mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label = mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap = mw.ustring.match (label, &quot;^([\&quot;\'][^\'].+)&quot;);						-- match leading double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-left'], cap);
		end
	
		cap = mw.ustring.match (label, &quot;^(.+[^\'][\&quot;\'])$&quot;)						-- match trailing double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-right'], cap);
		end
		
		if 2 == wl_type then
			str = utilities.make_wikilink (link, label);						-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin-based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate RTL languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO 639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO 639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title=, |script-chapter=, |script-&lt;periodical&gt;=

]]

local function format_script_value (script_value, script_param)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%l?%s*:') then									-- if first 3 or 4 non-space characters are script language prefix
		lang = script_value:match('^(%l%l%l?)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not utilities.is_set (lang) then
			utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['missing title part']});		-- prefix without 'title'; add error message
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_tag_remap[lang] or mw.language.fetchLanguageName( lang, cfg.this_wiki_code );	-- get language name so that we can use it to categorize
		if utilities.is_set (name) then											-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l+%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if utilities.in_array (lang, cfg.script_lang_codes) then
				utilities.add_prop_cat ('script', {name, lang})
			else
				utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['unknown language code']});	-- unknown script-language; add error message
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['invalid language code']});		-- invalid language code; add error message
			lang = '';															-- invalid so set lang to empty string
		end
	else
		utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['missing prefix']});				-- no language code prefix; add error message
	end
	script_value = utilities.substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is RTL

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script
value has been wrapped in &lt;bdi&gt; tags.

]]

local function script_concatenate (title, script, script_param)
	if utilities.is_set (script) then
		script = format_script_value (script, script_param);					-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; returns empty string on error
		if utilities.is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not utilities.is_set ( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return utilities.substitute ( msg, str );								-- including template text
	else
		return utilities.substitute ( cfg.messages[key], str );
	end		
end


--[[----------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;-------------------

Makes a Wikisource URL from Wikisource interwiki-link.  Returns the URL and appropriate
label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;
	local wikisource_prefix = table.concat ({'https://', cfg.this_wiki_code, '.wikisource.org/wiki/'});

	wl_type, D, L = utilities.is_wikilink (str);								-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 1 == wl_type then													-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end

	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable URL
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent-encoding of fragment marker
	end

	return ws_url, ws_label, L or D;											-- return proper URL or nil and a label or nil
end


--[[----------------&lt; F O R M A T _ P E R I O D I C A L &gt;-----------------------

Format the three periodical parameters: |script-&lt;periodical&gt;=, |&lt;periodical&gt;=,
and |trans-&lt;periodical&gt;= into a single Periodical meta-parameter.

]]

local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)

	if not utilities.is_set (periodical) then
		periodical = '';														-- to be safe for concatenation
	else
		periodical = utilities.wrap_style ('italic-title', periodical);			-- style 
	end

	periodical = script_concatenate (periodical, script_periodical, script_periodical_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (trans_periodical) then
		trans_periodical = utilities.wrap_style ('trans-italic-title', trans_periodical);
		if utilities.is_set (periodical) then
			periodical = periodical .. ' ' .. trans_periodical;
		else																	-- here when trans-periodical without periodical or script-periodical
			periodical = trans_periodical;
			utilities.set_message ('err_trans_missing_title', {'periodical'});
		end
	end

	return periodical;
end


--[[------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;---------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=,
and |chapter-url= into a single chapter meta- parameter (chapter_url_source used
for error messages).

]]

local function format_chapter_title (script_chapter, script_chapter_source, chapter, chapter_source, trans_chapter, trans_chapter_source, chapter_url, chapter_url_source, no_quotes, access)
	local ws_url, ws_label, L = wikisource_url_make (chapter);					-- make a wikisource URL and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', ' ');									-- replace underscore separators with space characters
		chapter = ws_label;
	end

	if not utilities.is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from module provided quote marks
			chapter = utilities.wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, script_chapter, script_chapter_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (chapter_url) then
		chapter = external_link (chapter_url, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');	-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if utilities.is_set (trans_chapter) then
		trans_chapter = utilities.wrap_style ('trans-quoted-title', trans_chapter);
		if utilities.is_set (chapter) then
			chapter = chapter .. ' ' .. trans_chapter;
		else																	-- here when trans_chapter without chapter or script-chapter
			chapter = trans_chapter;
			chapter_source = trans_chapter_source:match ('trans%-?(.+)');		-- when no chapter, get matching name from trans-&lt;param&gt;
			utilities.set_message ('err_trans_missing_title', {chapter_source});
		end
	end

	return chapter;
end


--[[----------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;-------------------

This function searches a parameter's value for non-printable or invisible characters.
The search stops at the first match.

This function will detect the visible replacement character when it is part of the Wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers
(gallery, math, pre, ref) and identifies them with a slightly different error message.
See also coins_cleanup().

Output of this function is an error message that identifies the character or the
Unicode group, or the stripmarker that was detected along with its position (or,
for multi-byte characters, the position of its first byte) in the parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local stripmarker;															-- boolean set true when a stripmarker is found

	capture = string.match (v, '[%w%p ]*');										-- test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no Unicode characters
		return;
	end

	for _, invisible_char in ipairs (cfg.invisible_chars) do
		local char_name = invisible_char[1];									-- the character or group name
		local pattern = invisible_char[2];										-- the pattern used to find it
		position, _, capture = mw.ustring.find (v, pattern);					-- see if the parameter value contains characters that match the pattern
		
		if position and (cfg.invisible_defs.zwj == capture) then				-- if we found a zero-width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- it's ok if one of the Indic scripts
				position = nil;													-- unset position
			elseif cfg.emoji_t[mw.ustring.codepoint (v, position+1)] then			-- is zwj followed by a character listed in emoji{}?
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and utilities.in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and cfg.invisible_defs.del == capture then	-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture and not (cfg.invisible_defs.del == capture or cfg.invisible_defs.zwj == capture) then
					err_msg = capture .. ' ' .. char_name;
				else
					err_msg = char_name .. ' ' .. 'character';
				end

				utilities.set_message ('err_invisible_char', {err_msg, utilities.wrap_style ('parameter', param), position});	-- add error message
				return;															-- and done with this parameter
			end
		end
	end
end


--[[-------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------

Argument wrapper.  This function provides support for argument mapping defined
in the configuration file so that multiple names can be transparently aliased to
single internal variable.

]]

local function argument_wrapper ( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function ( self, k )
			local dummy = self[k];												-- force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = utilities.select_one ( args, list, 'err_redundant_parameters' );
				if origin[k] == nil then
					origin[k] = '';												-- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] .. ': ' .. k);
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;-------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.
When date is DD MMMM YYYY or is MMMM DD, YYYY then wrap in nowrap span:
&lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap = '';
	local cap2 = '';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = utilities.substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = utilities.substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;---------------------

This function sets default title types (equivalent to the citation including
|type=&lt;default value&gt;) for those templates that have defaults. Also handles the
special case where it is desirable to omit the title type from the rendered citation
(|type=none).

]]

local function set_titletype (cite_class, title_type)
	if utilities.is_set (title_type) then
		if 'none' == cfg.keywords_xlate[title_type] then
			title_type = '';													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; S A F E _ J O I N &gt;-----------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'duplicate character'
		if 1 == #duplicate_char then											-- for single byte ASCII characters use the string library functions
			f.gsub = string.gsub
			f.match = string.match
			f.sub = string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub = mw.ustring.gsub
			f.match = mw.ustring.match
			f.sub = mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1, 1) == '&lt;' then										-- special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove HTML markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1, 1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc.?
				trim = false;
				end_chr = f.sub(str, -1, -1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr .. &quot;)&quot;				-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1, -2);									-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;''&quot; then		-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5, -1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;]]&quot; then		-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3, -1) == duplicate_char .. '&quot;]' then	-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2, -1) == duplicate_char .. &quot;]&quot; then	-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2, -1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1, -3);								-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains HTML markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows HTML markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value; 												-- add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;-----------------------------

returns true if suffix is properly formed Jr, Sr, or ordinal in the range 1–9.
Puncutation not allowed.

]]

local function is_suffix (suffix)
	if utilities.in_array (suffix, {'Jr', 'Sr', 'Jnr', 'Snr', '1st', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;-------------------

For Vancouver style, author/editor names are supposed to be rendered in Latin
(read ASCII) characters.  When a name uses characters that contain diacritical
marks, those characters are to be converted to the corresponding Latin
character. When a name is written using a non-Latin alphabet or logogram, that
name is to be transliterated into Latin characters. The module doesn't do this
so editors may/must.

This test allows |first= and |last= names to contain any of the letters defined
in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes.
	(http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;)
	or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written outside of the code editor and pasted here because the code editor
gets confused between character insertion point and cursor position. The test has
been rewritten to use decimal character escape sequence for the individual bytes
of the Unicode characters so that it is not necessary to use an external editor
to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first, suffix, position)
	if not suffix then
		if first:find ('[,%s]') then											-- when there is a space or comma, might be first name/initials + generational suffix
			first = first:match ('(.-)[,%s]+');									-- get name/initials
			suffix = first:match ('[,%s]+(.+)$');								-- get generational suffix
		end
	end
	if utilities.is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error (cfg.err_msg_supl.suffix, position);
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error (cfg.err_msg_supl['non-Latin char'], position);
			return false;														-- not a string of Latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-style=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period.
See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc.) to be rendered
as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format
because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the
Unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first, position)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just initials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error (cfg.err_msg_supl.suffix, position);			-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word

	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i], 1, 1));			-- insert the initial at end of initials table
		end
		i = i + 1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; I N T E R W I K I _ P R E F I X E N _ G E T &gt;----------------------------------

extract interwiki prefixen from &lt;value&gt;.  Returns two one or two values:
	false – no prefixen
	nil – prefix exists but not recognized
	project prefix, language prefix – when value has either of:
		:&lt;project&gt;:&lt;language&gt;:&lt;article&gt;
		:&lt;language&gt;:&lt;project&gt;:&lt;article&gt;
	project prefix, nil – when &lt;value&gt; has only a known single-letter prefix
	nil, language prefix – when &lt;value&gt; has only a known language prefix

accepts single-letter project prefixen: 'd' (wikidata), 's' (wikisource), and 'w' (wikipedia) prefixes; at this
writing, the other single-letter prefixen (b (wikibook), c (commons), m (meta), n (wikinews), q (wikiquote), and
v (wikiversity)) are not supported.

]]

local function interwiki_prefixen_get (value, is_link)
	if not value:find (':%l+:') then											-- if no prefix
		return false;															-- abandon; boolean here to distinguish from nil fail returns later
	end

	local prefix_patterns_linked_t = {											-- sequence of valid interwiki and inter project prefixen
		'^%[%[:([dsw]):(%l%l+):',												-- wikilinked; project and language prefixes
		'^%[%[:(%l%l+):([dsw]):',												-- wikilinked; language and project prefixes
		'^%[%[:([dsw]):',														-- wikilinked; project prefix
		'^%[%[:(%l%l+):',														-- wikilinked; language prefix
		}
		
	local prefix_patterns_unlinked_t = {										-- sequence of valid interwiki and inter project prefixen
		'^:([dsw]):(%l%l+):',													-- project and language prefixes
		'^:(%l%l+):([dsw]):',													-- language and project prefixes
		'^:([dsw]):',															-- project prefix
		'^:(%l%l+):',															-- language prefix
		}
	
	local cap1, cap2;
	for _, pattern in ipairs ((is_link and prefix_patterns_linked_t) or prefix_patterns_unlinked_t) do
		cap1, cap2 = value:match (pattern);
		if cap1 then
			break;																-- found a match so stop looking
		end
	end
	
	if cap1 and cap2 then														-- when both then :project:language: or :language:project: (both forms allowed)
		if 1 == #cap1 then														-- length == 1 then :project:language:
			if cfg.inter_wiki_map[cap2] then									-- is language prefix in the interwiki map?
				return cap1, cap2;												-- return interwiki project and interwiki language
			end
		else																	-- here when :language:project:
			if cfg.inter_wiki_map[cap1] then									-- is language prefix in the interwiki map?
				return cap2, cap1;												-- return interwiki project and interwiki language
			end
		end
		return nil;																-- unknown interwiki language
	elseif not (cap1 or cap2) then												-- both are nil?
		return nil;																-- we got something that looks like a project prefix but isn't; return fail
	elseif 1 == #cap1 then														-- here when one capture
		return cap1, nil;														-- length is 1 so return project, nil language
	else																		-- here when one capture and its length it more than 1
		if cfg.inter_wiki_map[cap1] then										-- is language prefix in the interwiki map?
			return nil, cap1;													-- return nil project, language
		end
	end
end


--[[--------------------------&lt; L I S T _ P E O P L E &gt;--------------------------

Formats a list of people (authors, contributors, editors, interviewers, translators) 

names in the list will be linked when
	|&lt;name&gt;-link= has a value
	|&lt;name&gt;-mask- does NOT have a value; masked names are presumed to have been
		rendered previously so should have been linked there

when |&lt;name&gt;-mask=0, the associated name is not rendered

]]

local function list_people (control, people, etal)
	local sep;
	local namesep;
	local format = control.format;
	local maximum = control.maximum;
	local name_list = {};

	if 'vanc' == format then													-- Vancouver-like name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between names is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between names is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub (-1, -1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if utilities.is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end		-- returned 0 is for EditorCount; not used for other names
	
	for i, person in ipairs (people) do
		if utilities.is_set (person.last) then
			local mask = person.mask;
			local one;
			local sep_one = sep;

			if utilities.is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			end
			
			if mask then
				local n = tonumber (mask);										-- convert to a number if it can be converted; nil else
				if n then
					one = 0 ~= n and string.rep(&quot;&amp;mdash;&quot;, n) or nil;			-- make a string of (n &gt; 0) mdashes, nil else, to replace name
					person.link = nil;											-- don't create link to name if name is replaces with mdash string or has been set nil
				else
					one = mask;													-- replace name with mask text (must include name-list separator)
					sep_one = &quot; &quot;;												-- modify name-list separator
				end
			else
				one = person.last;												-- get surname
				local first = person.first										-- get given name
				if utilities.is_set (first) then
					if (&quot;vanc&quot; == format) then									-- if Vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first, nil, i) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials (first, i);				-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
			end
			if utilities.is_set (person.link) then
				one = utilities.make_wikilink (person.link, one);				-- link author/editor
			end

			if one then															-- if &lt;one&gt; has a value (name, mdash replacement, or mask text replacement)
				local proj, tag = interwiki_prefixen_get (one, true);			-- get the interwiki prefixen if present

				if 'w' == proj and ('Wikipedia' == mw.site.namespaces.Project['name']) then
					proj = nil;													-- for stuff like :w:de:&lt;article&gt;, :w is unnecessary TODO: maint cat?
				end
				if proj then
					proj = ({['d'] = 'Wikidata', ['s'] = 'Wikisource', ['w'] = 'Wikipedia'})[proj];	-- :w (wikipedia) for linking from a non-wikipedia project
					if proj then 
						one = one .. utilities.wrap_style ('interproj', proj);	-- add resized leading space, brackets, static text, language name
						tag = nil;												-- unset; don't do both project and language
					end
				end
				if tag == cfg.this_wiki_code then
					tag = nil;													-- stuff like :en:&lt;article&gt; at en.wiki is pointless TODO: maint cat?
				end
				if tag then
					local lang = cfg.lang_tag_remap[tag] or cfg.mw_languages_by_tag_t[tag];
					if lang then												-- error messaging done in extract_names() where we know parameter names
						one = one .. utilities.wrap_style ('interwiki', lang);	-- add resized leading space, brackets, static text, language name
					end
				end

				table.insert (name_list, one);									-- add it to the list of names
				table.insert (name_list, sep_one);								-- add the proper name-list separator
			end
		end
	end

	local count = #name_list / 2;												-- (number of names + number of separators) divided by 2
	if 0 &lt; count then 
		if 1 &lt; count and not etal then
			if 'amp' == format then
				name_list[#name_list-2] = &quot; &amp; &quot;;								-- replace last separator with ampersand text
			elseif 'and' == format then
				if 2 == count then
					name_list[#name_list-2] = cfg.presentation.sep_nl_and;		-- replace last separator with 'and' text
				else
					name_list[#name_list-2] = cfg.presentation.sep_nl_end;		-- replace last separator with '(sep) and' text
				end
			end
		end
		name_list[#name_list] = nil;											-- erase the last separator
	end

	local result = table.concat (name_list);									-- construct list
	if etal and utilities.is_set (result) then									-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. cfg.messages['et al'];						-- we've got a last-first list and etal so add et al.
	end
	
	return result, count;														-- return name-list string and count of number of names (count used for editor names only)
end


--[[--------------------&lt; M A K E _ C I T E R E F _ I D &gt;-----------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise
returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that
order.  year is Year or anchor_year.

]]

local function make_citeref_id (namelist, year)
	local names={};							-- a table for the one to four names and year
	for i,v in ipairs (namelist) do			-- loop through the list and take up to the first four last names
		names[i] = v.last
		if i == 4 then break end			-- if four then done
	end
	table.insert (names, year);				-- add the year at the end
	local id = table.concat(names);			-- concatenate names and year for CITEREF id
	if utilities.is_set (id) then			-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;				-- add the CITEREF portion
	else
		return '';							-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; C I T E _ C L A S S _A T T R I B U T E _M A K E &gt;------------------------------

construct &lt;cite&gt; tag class attribute for this citation.

&lt;cite_class&gt; – config.CitationClass from calling template
&lt;mode&gt; – value from |mode= parameter

]]

local function cite_class_attribute_make (cite_class, mode)
	local class_t = {};
	table.insert (class_t, 'citation');											-- required for blue highlight
	if 'citation' ~= cite_class then
		table.insert (class_t, cite_class);										-- identify this template for user css
		table.insert (class_t, utilities.is_set (mode) and mode or 'cs1');		-- identify the citation style for user css or javascript
	else
		table.insert (class_t, utilities.is_set (mode) and mode or 'cs2');		-- identify the citation style for user css or javascript
	end
	for _, prop_key in ipairs (z.prop_keys_t) do
		table.insert (class_t, prop_key);										-- identify various properties for user css or javascript
	end

	return table.concat (class_t, ' ');											-- make a big string and done
end


--[[---------------------&lt; N A M E _ H A S _ E T A L &gt;--------------------------

Evaluates the content of name parameters (author, editor, etc.) for variations on
the theme of et al.  If found, the et al. is removed, a flag is set to true and
the function returns the modified name and the flag.

This function never sets the flag to false but returns its previous state because
it may have been set by previous passes through this function or by the associated
|display-&lt;names&gt;=etal parameter

]]

local function name_has_etal (name, etal, nocat, param)

	if utilities.is_set (name) then												-- name can be nil in which case just return
		local patterns = cfg.et_al_patterns; 									-- get patterns from configuration
		
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns
			if name:match (pattern) then										-- if this 'et al' pattern is found in name
				name = name:gsub (pattern, '');									-- remove the offending text
				etal = true;													-- set flag (may have been set previously here or by |display-&lt;names&gt;=etal)
				if not nocat then												-- no categorization for |vauthors=
					utilities.set_message ('err_etal', {param});				-- and set an error if not added
				end
			end
		end
	end

	return name, etal;
end


--[[---------------------&lt; N A M E _ I S _ N U M E R I C &gt;----------------------

Add maint cat when name parameter value does not contain letters.  Does not catch
mixed alphanumeric names so |last=A. Green (1922-1987) does not get caught in the
current version of this test but |first=(1888) is caught.

returns nothing

]]

local function name_is_numeric (name, list_name)
	if utilities.is_set (name) then
		if mw.ustring.match (name, '^[%A]+$') then								-- when name does not contain any letters
			utilities.set_message ('maint_numeric_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
		end
	end
end


--[[-----------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;------------------

Evaluates the content of last/surname (authors etc.) parameters for multiple names.
Multiple names are indicated if there is more than one comma or any &quot;unescaped&quot;
semicolons. Escaped semicolons are ones used as part of selected HTML entities.
If the condition is met, the function adds the multiple name maintenance category.

Same test for first except that commas should not appear in given names (MOS:JR says
that the generational suffix does not take a separator character).  Titles, degrees,
postnominals, affiliations, all normally comma separated don't belong in a citation.

&lt;name&gt; – name parameter value
&lt;list_name&gt; – AuthorList, EditorList, etc
&lt;limit&gt; – number of allowed commas; 1 (default) for surnames; 0 for given names

returns nothing

]]

local function name_has_mult_names (name, list_name, limit)
	local _, commas, semicolons, nbsps;
	limit = limit and limit or 1;
	if utilities.is_set (name) then
		_, commas = name:gsub (',', '');										-- count the number of commas
		_, semicolons = name:gsub (';', '');									-- count the number of semicolons
		-- nbsps probably should be its own separate count rather than merged in
		-- some way with semicolons because Lua patterns do not support the
		-- grouping operator that regex does, which means there is no way to add
		-- more entities to escape except by adding more counts with the new
		-- entities
		_, nbsps = name:gsub ('&amp;nbsp;','');										-- count nbsps
		
		-- There is exactly 1 semicolon per &amp;nbsp; entity, so subtract nbsps
		-- from semicolons to 'escape' them. If additional entities are added,
		-- they also can be subtracted.
		if limit &lt; commas or 0 &lt; (semicolons - nbsps) then
			utilities.set_message ('maint_mult_names', cfg.special_case_translation [list_name]);	-- add a maint message
		end
	end
end


--[=[-------------------------&lt; I S _ G E N E R I C &gt;----------------------------------------------------------

Compares values assigned to various parameters according to the string provided as &lt;item&gt; in the function call.
&lt;item&gt; can have on of two values:
	'generic_names' – for name-holding parameters: |last=, |first=, |editor-last=, etc
	'generic_titles' – for |title=

There are two types of generic tests.  The 'accept' tests look for a pattern that should not be rejected by the
'reject' test.  For example,
	|author=[[John Smith (author)|Smith, John]]
would be rejected by the 'author' reject test.  But piped wikilinks with 'author' disambiguation should not be
rejected so the 'accept' test prevents that from happening.  Accept tests are always performed before reject
tests.

Each of the 'accept' and 'reject' sequence tables hold tables for en.wiki (['en']) and local.wiki (['local'])
that each can hold a test sequence table  The sequence table holds, at index [1], a test pattern, and, at index
[2], a boolean control value.  The control value tells string.find() or mw.ustring.find() to do plain-text search (true)
or a pattern search (false).  The intent of all this complexity is to make these searches as fast as possible so
that we don't run out of processing time on very large articles.

Returns
	true when a reject test finds the pattern or string
	false when an accept test finds the pattern or string
	nil else

]=]

local function is_generic (item, value, wiki)
	local test_val;
	local str_lower = {															-- use string.lower() for en.wiki (['en']) and use mw.ustring.lower() or local.wiki (['local'])
		['en'] = string.lower,
		['local'] = mw.ustring.lower,
		}
	local str_find = {															-- use string.find() for en.wiki (['en']) and use mw.ustring.find() or local.wiki (['local'])
		['en'] = string.find,
		['local'] = mw.ustring.find,
		}

	local function test (val, test_t, wiki)										-- local function to do the testing; &lt;wiki&gt; selects lower() and find() functions
		val = test_t[2] and str_lower[wiki](value) or val;						-- when &lt;test_t[2]&gt; set to 'true', plaintext search using lowercase value
		return str_find[wiki] (val, test_t[1], 1, test_t[2]);					-- return nil when not found or matched
	end
		
	local test_types_t = {'accept', 'reject'};									-- test accept patterns first, then reject patterns
	local wikis_t = {'en', 'local'};											-- do tests for each of these keys; en.wiki first, local.wiki second

	for _, test_type in ipairs (test_types_t) do								-- for each test type
		for _, generic_value in pairs (cfg.special_case_translation[item][test_type]) do	-- spin through the list of generic value fragments to accept or reject
			for _, wiki in ipairs (wikis_t) do
				if generic_value[wiki] then
					if test (value, generic_value[wiki], wiki) then				-- go do the test
						return ('reject' == test_type);							-- param value rejected, return true; false else
					end
				end
			end
		end
	end
end


--[[--------------------------&lt; N A M E _ I S _ G E N E R I C &gt;------------------------------------------------

calls is_generic() to determine if &lt;name&gt; is a 'generic name' listed in cfg.generic_names; &lt;name_alias&gt; is the
parameter name used in error messaging

]]

local function name_is_generic (name, name_alias)
	if not added_generic_name_errs  and is_generic ('generic_names', name) then
		utilities.set_message ('err_generic_name', name_alias);					-- set an error message
		added_generic_name_errs = true;
	end
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------

This function calls various name checking functions used to validate the content of the various name-holding parameters.

]]

local function name_checks (last, first, list_name, last_alias, first_alias)
	local accept_name;

	if utilities.is_set (last) then
		last, accept_name = utilities.has_accept_as_written (last);				-- remove accept-this-as-written markup when it wraps all of &lt;last&gt;

		if not accept_name then													-- &lt;last&gt; not wrapped in accept-as-written markup
			name_has_mult_names (last, list_name);								-- check for multiple names in the parameter
			name_is_numeric (last, list_name);									-- check for names that are composed of digits and punctuation
			name_is_generic (last, last_alias);									-- check for names found in the generic names list
		end
	end

	if utilities.is_set (first) then
		first, accept_name = utilities.has_accept_as_written (first);			-- remove accept-this-as-written markup when it wraps all of &lt;first&gt;

		if not accept_name then													-- &lt;first&gt; not wrapped in accept-as-written markup
			name_has_mult_names (first, list_name, 0);							-- check for multiple names in the parameter; 0 is number of allowed commas in a given name
			name_is_numeric (first, list_name);									-- check for names that are composed of digits and punctuation
			name_is_generic (first, first_alias);								-- check for names found in the generic names list
		end
		local wl_type, D = utilities.is_wikilink (first);
		if 0 ~= wl_type then
			first = D;
			utilities.set_message ('err_bad_paramlink', first_alias);
		end
	end

	return last, first;															-- done
end


--[[----------------------&lt; E X T R A C T _ N A M E S &gt;-------------------------

Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters
(or their aliases), and their matching link and mask parameters. Stops searching
when both |lastn= and |firstn= are not found in args after two sequential attempts:
found |last1=, |last2=, and |last3= but doesn't find |last4= and |last5= then the
search is done.

This function emits an error message when there is a |firstn= without a matching
|lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not
required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.'
is stripped from the parameter and a flag (etal) returned that will cause list_people()
to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps
'et al.' out of the template's metadata.  When this occurs, an error is emitted.

]]

local function extract_names(args, list_name)
	local names = {};															-- table of names
	local last;																	-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;																-- loop counter/indexer
	local n = 1;																-- output table indexer
	local count = 0;															-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal = false;															-- return value set to true when we find some form of et al. in an author parameter

	local last_alias, first_alias, link_alias;									-- selected parameter aliases used in error messaging
	while true do
		last, last_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'err_redundant_parameters', i );		-- search through args for name components beginning at 1
		first, first_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'err_redundant_parameters', i );
		link, link_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i );
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
	
		if last then															-- error check |lastn= alias for unknown interwiki link prefix; done here because this is where we have the parameter name
			local project, language = interwiki_prefixen_get (last, true);		-- true because we expect interwiki links in |lastn= to be wikilinked
			if nil == project and nil == language then							-- when both are nil
				utilities.set_message ('err_bad_paramlink', last_alias);		-- not known, emit an error message	-- TODO: err_bad_interwiki?
				last = utilities.remove_wiki_link (last);						-- remove wikilink markup; show display value only
			end
		end
		
		if link then															-- error check |linkn= alias for unknown interwiki link prefix
			local project, language = interwiki_prefixen_get (link, false);		-- false because wiki links in |author-linkn= is an error
			if nil == project and nil == language then							-- when both are nil
				utilities.set_message ('err_bad_paramlink', link_alias);		-- not known, emit an error message	-- TODO: err_bad_interwiki?
				link = nil;														-- unset so we don't link
				link_alias = nil;
			end
		end
		
		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.
		last, first = name_checks (last, first, list_name, last_alias, first_alias);						-- multiple names, extraneous annotation, etc. checks

		if first and not last then												-- if there is a firstn without a matching lastn
			local alias = first_alias:find ('given', 1, true) and 'given' or 'first';	-- get first or given form of the alias
			utilities.set_message ('err_first_missing_last', {
				first_alias,													-- param name of alias missing its mate
				first_alias:gsub (alias, {['first'] = 'last', ['given'] = 'surname'}),	-- make param name appropriate to the alias form
				});																-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			local result;
			link = link_title_ok (link, link_alias, last, last_alias);			-- check for improper wiki-markup

			if first then
				link = link_title_ok (link, link_alias, first, first_alias);	-- check for improper wiki-markup
			end

			names[n] = {last = last, first = first, link = link, mask = mask, corporate = false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				utilities.set_message ('err_missing_name', {list_name:match (&quot;(%w+)List&quot;):lower(), i - 1});	-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names and the etal flag
end


--[[--------------------------&lt; N A M E _ T A G _ G E T &gt;------------------------------------------------------

attempt to decode |language=&lt;lang_param&gt; and return language name and matching tag; nil else.

This function looks for:
	&lt;lang_param&gt; as a tag in cfg.lang_tag_remap{}
	&lt;lang_param&gt; as a name in cfg.lang_name_remap{}
	
	&lt;lang_param&gt; as a name in cfg.mw_languages_by_name_t
	&lt;lang_param&gt; as a tag in cfg.mw_languages_by_tag_t
when those fail, presume that &lt;lang_param&gt; is an IETF-like tag that MediaWiki does not recognize.  Strip all
script, region, variant, whatever subtags from &lt;lang_param&gt; to leave just a two or three character language tag
and look for the new &lt;lang_param&gt; in cfg.mw_languages_by_tag_t{}

on success, returns name (in properly capitalized form) and matching tag (in lowercase); on failure returns nil

]]

local function name_tag_get (lang_param)
	local lang_param_lc = mw.ustring.lower (lang_param);						-- use lowercase as an index into the various tables
	local name;
	local tag;

	name = cfg.lang_tag_remap[lang_param_lc];									-- assume &lt;lang_param_lc&gt; is a tag; attempt to get remapped language name 
	if name then																-- when &lt;name&gt;, &lt;lang_param&gt; is a tag for a remapped language name
		return name, lang_param_lc;												-- so return &lt;name&gt; from remap and &lt;lang_param_lc&gt;
	end

	tag = lang_param_lc:match ('^(%a%a%a?)%-.*');								-- still assuming that &lt;lang_param_lc&gt; is a tag; strip script, region, variant subtags
	name = cfg.lang_tag_remap[tag];											-- attempt to get remapped language name with language subtag only
	if name then																-- when &lt;name&gt;, &lt;tag&gt; is a tag for a remapped language name
		return name, tag;														-- so return &lt;name&gt; from remap and &lt;tag&gt;
	end

	if cfg.lang_name_remap[lang_param_lc] then									-- not a tag, assume &lt;lang_param_lc&gt; is a name; attempt to get remapped language tag 
		return cfg.lang_name_remap[lang_param_lc][1], cfg.lang_name_remap[lang_param_lc][2];	-- for this &lt;lang_param_lc&gt;, return a (possibly) new name and appropriate tag
	end

	tag = cfg.mw_languages_by_name_t[lang_param_lc];							-- assume that &lt;lang_param_lc&gt; is a language name; attempt to get its matching tag
	
	if tag then
		return cfg.mw_languages_by_tag_t[tag], tag;								-- &lt;lang_param_lc&gt; is a name so return the name from the table and &lt;tag&gt;
	end

	name = cfg.mw_languages_by_tag_t[lang_param_lc];							-- assume that &lt;lang_param_lc&gt; is a tag; attempt to get its matching language name
	
	if name then
		return name, lang_param_lc;												-- &lt;lang_param_lc&gt; is a tag so return it and &lt;name&gt;
	end
	
	tag = lang_param_lc:match ('^(%a%a%a?)%-.*');								-- is &lt;lang_param_lc&gt; an IETF-like tag that MediaWiki doesn't recognize? &lt;tag&gt; gets the language subtag; nil else

	if tag then
		name = cfg.mw_languages_by_tag_t[tag];									-- attempt to get a language name using the shortened &lt;tag&gt;
		if name then
			return name, tag;													-- &lt;lang_param_lc&gt; is an unrecognized IETF-like tag so return &lt;name&gt; and language subtag
		end
	end
end


--[[-------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code
is recognized by MediaWiki, use the returned name; if not, then use the value that
was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is
assigned to the category for that code: Category:Norwegian-language sources (no).
For valid three-character code languages, the page is assigned to the single category
for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does
not recognize three-character equivalents of two-character codes: code 'ar' is
recognized but code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th
where the language names or codes are separated from each other by commas with
optional space characters.

]]

local function language_parameter (lang)
	local tag;																	-- some form of IETF-like language tag; language subtag with optional region, sript, vatiant, etc subtags
	local lang_subtag;															-- ve populates |language= with mostly unecessary region subtags the MediaWiki does not recognize; this is the base language subtag
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_t = {};															-- table made from the value assigned to |language=

	local this_wiki_name = mw.language.fetchLanguageName (cfg.this_wiki_code, cfg.this_wiki_code);	-- get this wiki's language name

	names_t = mw.text.split (lang, '%s*,%s*');									-- names should be a comma separated list

	for _, lang in ipairs (names_t) do											-- reuse lang here because we don't yet know if lang is a language name or a language tag
		name, tag = name_tag_get (lang);										-- attempt to get name/tag pair for &lt;lang&gt;; &lt;name&gt; has proper capitalization; &lt;tag&gt; is lowercase

		if utilities.is_set (tag) then
			lang_subtag = tag:gsub ('^(%a%a%a?)%-.*', '%1');					-- for categorization, strip any IETF-like tags from language tag

			if cfg.this_wiki_code ~= lang_subtag then							-- when the language is not the same as this wiki's language
				if 2 == lang_subtag:len() then									-- and is a two-character tag
					utilities.add_prop_cat ('foreign-lang-source', {name, tag}, lang_subtag);		-- categorize it; tag appended to allow for multiple language categorization
				else															-- or is a recognized language (but has a three-character tag)
					utilities.add_prop_cat ('foreign-lang-source-2', {lang_subtag}, lang_subtag);			-- categorize it differently TODO: support multiple three-character tag categories per cs1|2 template?
				end
			elseif cfg.local_lang_cat_enable then								-- when the language and this wiki's language are the same and categorization is enabled
				utilities.add_prop_cat ('local-lang-source', {name, lang_subtag});		-- categorize it
			end
		else
			name = lang;														-- return whatever &lt;lang&gt; has so that we show something
			utilities.set_message ('maint_unknown_lang');						-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
 
	name = utilities.make_sep_list (#language_list, language_list);
	if (1 == #language_list) and (lang_subtag == cfg.this_wiki_code) then		-- when only one language, find lang name in this wiki lang name; for |language=en-us, 'English' in 'American English'
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[-----------------------&lt; S E T _ C S _ S T Y L E &gt;--------------------------

Gets the default CS style configuration for the given mode.
Returns default separator and either postscript as passed in or the default.
In CS1, the default postscript and separator are '.'.
In CS2, the default postscript is the empty string and the default separator is ','.

]]

local function set_cs_style (postscript, mode)
	if utilities.is_set(postscript) then
		-- emit a maintenance message if user postscript is the default cs1 postscript
		-- we catch the opposite case for cs2 in set_style
		if mode == 'cs1' and postscript == cfg.presentation['ps_' .. mode] then
			utilities.set_message ('maint_postscript');
		end
	else
		postscript = cfg.presentation['ps_' .. mode];
	end
	return cfg.presentation['sep_' .. mode], postscript;
end


--[[--------------------------&lt; S E T _ S T Y L E &gt;-----------------------------

Sets the separator and postscript styles. Checks the |mode= first and the
#invoke CitationClass second. Removes the postscript if postscript == none.

]]

local function set_style (mode, postscript, cite_class)
	local sep;
	if 'cs2' == mode then
		sep, postscript = set_cs_style (postscript, 'cs2');
	elseif 'cs1' == mode then
		sep, postscript = set_cs_style (postscript, 'cs1');
	elseif 'citation' == cite_class	then
		sep, postscript = set_cs_style (postscript, 'cs2');
	else
		sep, postscript = set_cs_style (postscript, 'cs1');
	end

	if cfg.keywords_xlate[postscript:lower()] == 'none' then
		-- emit a maintenance message if user postscript is the default cs2 postscript
		-- we catch the opposite case for cs1 in set_cs_style
		if 'cs2' == mode or 'citation' == cite_class then
			utilities.set_message ('maint_postscript');
		end
		postscript = '';
	end
	
	return sep, postscript
end


--[=[-------------------------&lt; I S _ P D F &gt;-----------------------------------

Determines if a URL has the file extension that is one of the PDF file extensions
used by [[MediaWiki:Common.css]] when applying the PDF icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or
		url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
		url:match ('%.PDF&amp;#035') or url:match ('%.pdf&amp;#035');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;-----------------------

Applies CSS style to |format=, |chapter-format=, etc.  Also emits an error message
if the format parameter does not have a matching URL parameter.  If the format parameter
is not set and the URL contains a file extension that is recognized as a PDF document
by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if utilities.is_set (format) then
		format = utilities.wrap_style ('format', format);						-- add leading space, parentheses, resize
		if not utilities.is_set (url) then
			utilities.set_message ('err_format_missing_url', {fmt_param, url_param});	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if URL is a PDF file then
		format = utilities.wrap_style ('format', 'PDF');						-- set format to PDF
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[---------------------&lt; G E T _ D I S P L A Y _ N A M E S &gt;------------------

Returns a number that defines the number of names displayed for author and editor
name lists and a Boolean flag to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero,
return the number and the previous state of the 'etal' flag (false by default
but may have been set to true if the name list contains some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number
that is one greater than the number of authors in the list and set the 'etal' flag true.
This will cause the list_people() to display all of the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors'], etc; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

This function sets an error message when |display-xxxxors= value greater than or equal to number of names but
not when &lt;max&gt; comes from {{cs1 config}} global settings.  When using global settings, &lt;param&gt; is set to the
keyword 'cs1 config' which is used to supress the normal error.  Error is suppressed because it is to be expected
that some citations in an article will have the same or fewer names that the limit specified in {{cs1 config}}.

]]

local function get_display_names (max, count, list_name, etal, param)
	if utilities.is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if (max &gt;= count) and ('cs1 config' ~= param) then					-- error when local |display-xxxxors= value greater than or equal to number of names; not an error when using global setting
				utilities.set_message ('err_disp_name', {param, max});			-- add error message
				max = nil;
			end
		else																	-- not a valid keyword or number
			utilities.set_message ('err_disp_name', {param, max});				-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[----------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;---------------

Adds error if |page=, |pages=, |quote-page=, |quote-pages= has what appears to be
some form of p. or pp. abbreviation in the first characters of the parameter content.

check page for extraneous p, p., pp, pp., pg, pg. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when page begins PX or P# but not Px
		      where x and X are letters and # is a digit
	bad pattern:  '^[Pp][PpGg]' matches when page begins pp, pP, Pp, PP, pg, pG, Pg, PG

]]

local function extra_text_in_page_check (val, name)
	if not val:match (cfg.vol_iss_pg_patterns.good_ppattern) then
		for _, pattern in ipairs (cfg.vol_iss_pg_patterns.bad_ppatterns) do		-- spin through the selected sequence table of patterns
			if val:match (pattern) then											-- when a match, error so
				utilities.set_message ('err_extra_text_pages', name);	 		-- add error message
				return;															-- and done
			end
		end
	end		
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ V O L _ I S S _ C H E C K &gt;------------------------

Adds error if |volume= or |issue= has what appears to be some form of redundant 'type' indicator.

For |volume=:
	'V.', or 'Vol.' (with or without the dot) abbreviations or 'Volume' in the first characters of the parameter
	content (all case insensitive). 'V' and 'v' (without the dot) are presumed to be roman numerals so
	are allowed.

For |issue=:
	'No.', 'I.', 'Iss.' (with or without the dot) abbreviations, or 'Issue' in the first characters of the
	parameter content (all case insensitive).
	
Single character values ('v', 'i', 'n') allowed when not followed by separator character ('.', ':', '=', or
whitespace character) – param values are trimmed of whitespace by MediaWiki before delivered to the module.
	
&lt;val&gt; is |volume= or |issue= parameter value
&lt;name&gt; is |volume= or |issue= parameter name for error message
&lt;selector&gt; is 'v' for |volume=, 'i' for |issue=

sets error message on failure; returns nothing

]]

local function extra_text_in_vol_iss_check (val, name, selector)
	if not utilities.is_set (val) then
		return;
	end
	
	local patterns = 'v' == selector and cfg.vol_iss_pg_patterns.vpatterns or cfg.vol_iss_pg_patterns.ipatterns;

	local handler = 'v' == selector and 'err_extra_text_volume' or 'err_extra_text_issue';
	val = val:lower();															-- force parameter value to lower case
	for _, pattern in ipairs (patterns) do										-- spin through the selected sequence table of patterns
		if val:match (pattern) then												-- when a match, error so
			utilities.set_message (handler, name);								-- add error message
			return;																-- and done
		end
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parentheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a placeholder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parentheses
			local name = name_table[i];
			i = i + 1;															-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parentheses
					break;														-- and done reassembling so
				end
				i = i + 1;														-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = utilities.is_wikilink (name_table[i]);		-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i + 1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled parentheses ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the Vancouver error when a required comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		first = '';																-- set to empty string for concatenation and because it may have been set for previous author/editor
		local accept_name;
		v_name, accept_name = utilities.has_accept_as_written (v_name);			-- remove accept-this-as-written markup when it wraps all of &lt;v_name&gt;

		if accept_name then
			last = v_name;
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error (cfg.err_msg_supl.punctuation, i);
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s+&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be initials or generational suffix

			if not mw.ustring.match (first, '^%u+$') then						-- mw.ustring here so that later we will catch non-Latin characters
				suffix = first;													-- not initials so assume that whatever we got is a generational suffix
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end
			last = table.concat(lastfirstTable, ' ')							-- returns a string that is the concatenation of all other names that are not initials and generational suffix
			if not utilities.is_set (last) then
				first = '';														-- unset
				last = v_name;													-- last empty because something wrong with first
				add_vanc_error (cfg.err_msg_supl.name, i);
			end
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error (cfg.err_msg_supl['missing comma'], i);			-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- matches a space between two initials
			end
		else
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
		
		if utilities.is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first, suffix, i);							-- check first and last before restoring the suffix which may have a non-Latin digit
			if utilities.is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '', nil, i);
			end
		end

		link = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i ) or v_link_table[i];
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate = corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest;
|editorn= (and aliases) highest and |veditors= lowest (support for |editors= withdrawn)

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
	local lastfirst = false;
	if utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice in case we have a |first1= without a |last1=; this ...
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or		-- ... also catches the case where |first= is used with |vauthors=
		utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst = true;
	end

	if (utilities.is_set (vxxxxors) and true == lastfirst) or					-- these are the three error conditions
		(utilities.is_set (vxxxxors) and utilities.is_set (xxxxors)) or
		(true == lastfirst and utilities.is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			utilities.set_message ('err_redundant_parameters', err_name .. '-name-list parameters');	-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if utilities.is_set (vxxxxors) then return 2 end;
	if utilities.is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, live, dead, etc.).  When the parameter value has not been assigned a value (missing
or empty in the source template) the function returns the value specified by ret_val.  If the parameter value is one
of the list of allowed values returns the translated value; else, emits an error message and returns the value
specified by ret_val.

TODO: explain &lt;invert&gt;

]]

local function is_valid_parameter_value (value, name, possible, ret_val, invert)
	if not utilities.is_set (value) then
		return ret_val;															-- an empty parameter is ok
	end

	if (not invert and utilities.in_array (value, possible)) then				-- normal; &lt;value&gt; is in &lt;possible&gt; table
		return cfg.keywords_xlate[value];										-- return translation of parameter keyword
	elseif invert and not utilities.in_array (value, possible) then				-- invert; &lt;value&gt; is not in &lt;possible&gt; table
		return value;															-- return &lt;value&gt; as it is
	else
		utilities.set_message ('err_invalid_param_val', {name, value});			-- not an allowed value so add error message
		return ret_val;
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list, -3, -1) == sepc .. '. ') then					-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list, -1, -1) == sepc) or (string.sub (name_list, -3, -1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terminate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;-----------------------------------------

returns the concatenation of the formatted volume and issue (or journal article number) parameters as a single
string; or formatted volume or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, article, cite_class, origin, sepc, lower)
	if not utilities.is_set (volume) and not utilities.is_set (issue) and not utilities.is_set (article) then
		return '';
	end

	-- same condition as in format_pages_sheets()
	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);

	local is_numeric_vol = volume and (volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$'));	-- is only uppercase roman numerals or only digits?
	local is_long_vol = volume and (4 &lt; mw.ustring.len(volume));				-- is |volume= value longer than 4 characters?
	
	if volume and (not is_numeric_vol and is_long_vol) then						-- when not all digits or Roman numerals, is |volume= longer than 4 characters?
		utilities.add_prop_cat ('long-vol');									-- yes, add properties cat
	end

	if is_journal then															-- journal-style formatting
		local vol = '';

		if utilities.is_set (volume) then
			if is_numeric_vol then												-- |volume= value all digits or all uppercase Roman numerals?
				vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, volume});	-- render in bold face
			elseif is_long_vol then												-- not all digits or Roman numerals; longer than 4 characters?
				vol = utilities.substitute (cfg.messages['j-vol'], {sepc, utilities.hyphen_to_dash (volume)});	-- not bold
			else																-- four or fewer characters
				vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, utilities.hyphen_to_dash (volume)});	-- bold
			end
		end
		vol = vol .. (utilities.is_set (issue) and utilities.substitute (cfg.messages['j-issue'], issue) or '')
		vol = vol .. (utilities.is_set (article) and utilities.substitute (cfg.messages['j-article-num'], article) or '')
		return vol;
	end
	
	if 'podcast' == cite_class and utilities.is_set (issue) then
		return wrap_msg ('issue', {sepc, issue}, lower);
	end
	
	if 'conference' == cite_class and utilities.is_set (article) then			-- |article-number= supported only in journal and conference cites
		if utilities.is_set (volume) and utilities.is_set (article) then		-- both volume and article number
			return wrap_msg ('vol-art', {sepc, utilities.hyphen_to_dash (volume), article}, lower);
		elseif utilities.is_set (article) then									-- article number alone; when volume alone, handled below
			return wrap_msg ('art', {sepc, article}, lower);
		end
	end

	-- all other types of citation
	if utilities.is_set (volume) and utilities.is_set (issue) then
		return wrap_msg ('vol-no', {sepc, utilities.hyphen_to_dash (volume), issue}, lower);
	elseif utilities.is_set (volume) then
		return wrap_msg ('vol', {sepc, utilities.hyphen_to_dash (volume)}, lower);
	else
		return wrap_msg ('issue', {sepc, issue}, lower);
	end
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if utilities.is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif utilities.is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if utilities.is_set (page) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return utilities.substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return utilities.substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif utilities.is_set (pages) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then							-- if pages is only digits, assume a single page number
			return '', utilities.substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', utilities.substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', utilities.substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to Wikisource, returns the label portion of the interwiki-link as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki-link to an external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, page_orig, pages, pages_orig, at)
	local ws_url, ws_label, coins_pages, L;										-- for Wikisource interwiki-links; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if utilities.is_set (page) then
		if utilities.is_set (pages) or utilities.is_set (at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page, page_orig);								-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws URL from |page= interwiki link; link portion L becomes tooltip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (pages) then
		if utilities.is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages, pages_orig);							-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws URL from |pages= interwiki link; link portion L becomes tooltip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws URL from |at= interwiki link; link portion L becomes tooltip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end

--[[--------------------------&lt; I S _ U N I Q U E _ A R C H I V E _ U R L &gt;------------------------------------

add error message when |archive-url= value is same as |url= or chapter-url= (or alias...) value

]]

local function is_unique_archive_url (archive, url, c_url, source, date)
	if utilities.is_set (archive) then
		if archive == url or archive == c_url then
			utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)});	-- add error message
			return '', '';														-- unset |archive-url= and |archive-date= because same as |url= or |chapter-url=
		end
	end

	return archive, date;
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org URLs to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot URL or to calendar pages.  When the archive URL is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the URL.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org URL does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command URL
	|archive-url= is an archive.org URL that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org URLs:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this function may return a modified
archive URL:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the URL unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

A secondary function is to return an archive-url timestamp from those urls that have them (archive.org and
archive.today).  The timestamp is used by validation.archive_date_check() to see if the value in |archive-date=
matches the timestamp in the archive url.

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.org URL
	
	timestamp = url:match ('//archive.today/(%d%d%d%d%d%d%d%d%d%d%d%d%d%d)/');	-- get timestamp from archive.today urls
	if timestamp then															-- if this was an archive.today url ...
		return url, date, timestamp;											-- return ArchiveURL, ArchiveDate, and timestamp from |archive-url=, and done
	end
																				-- here for archive.org urls
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine URL
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command URL, we don't want to allow saving of the target page 
		err_msg = cfg.err_msg_supl.save;
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = cfg.err_msg_supl.liveweb;
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');	-- split out some of the URL parts for evaluation
		if not path then														-- malformed in some way; pattern did not match
			err_msg = cfg.err_msg_supl.timestamp;
		elseif 14 ~= timestamp:len() then										-- path and flag optional, must have 14-digit timestamp here
			err_msg = cfg.err_msg_supl.timestamp;
			if '*' ~= flag then
				local replacement = timestamp:match ('^%d%d%d%d%d%d') or timestamp:match ('^%d%d%d%d');	-- get the first 6 (YYYYMM) or first 4 digits (YYYY)
				if replacement then												-- nil if there aren't at least 4 digits (year)
					replacement = replacement .. string.rep ('0', 14 - replacement:len());	-- year or yearmo (4 or 6 digits) zero-fill to make 14-digit timestamp
					url=url:gsub ('(//web%.archive%.org/[^%d]*)%d[^/]*', '%1' .. replacement .. '*', 1)	-- for preview, modify ts to 14 digits plus splat for calendar display
				end
			end
		elseif utilities.is_set (path) and 'web/' ~= path then					-- older archive URLs do not have the extra 'web/' path element
			err_msg = cfg.err_msg_supl.path;
		elseif utilities.is_set (flag) and not utilities.is_set (path) then		-- flag not allowed with the old form URL (without the 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		elseif utilities.is_set (flag) and not flag:match ('%a%a_') then		-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		else
			return url, date, timestamp;										-- return ArchiveURL, ArchiveDate, and timestamp from |archive-url=
		end
	end
																				-- if here, something not right so
	utilities.set_message ('err_archive_url', {err_msg});						-- add error message and

	if is_preview_mode then
		return url, date, timestamp;											-- preview mode so return ArchiveURL, ArchiveDate, and timestamp from |archive-url=
	else
		return '', '';															-- return empty strings for ArchiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; P L A C E _ C H E C K &gt;--------------------------------------------------------

check |place=, |publication-place=, |location= to see if these params include digits.  This function added because
many editors misuse location to specify the in-source location (|page(s)= and |at= are supposed to do that)

returns the original parameter value without modification; added maint cat when parameter value contains digits

]]

local function place_check (param_val)
	if not utilities.is_set (param_val) then									-- parameter empty or omitted
		return param_val;														-- return that empty state
	end
	
	if mw.ustring.find (param_val, '%d') then									-- not empty, are there digits in the parameter value
		utilities.set_message ('maint_location');								-- yep, add maint cat
	end
	
	return param_val;															-- and done
end


--[[--------------------------&lt; I S _ A R C H I V E D _ C O P Y &gt;----------------------------------------------

compares |title= to 'Archived copy' (placeholder added by bots that can't find proper title); if matches, return true; nil else

]]

local function is_archived_copy (title)
	title = mw.ustring.lower(title);											-- switch title to lower case
	if title:find (cfg.special_case_translation.archived_copy.en) then			-- if title is 'Archived copy'
		return true;
	elseif cfg.special_case_translation.archived_copy['local'] then
		if mw.ustring.find (title, cfg.special_case_translation.archived_copy['local']) then	-- mw.ustring() because might not be Latin script
			return true;
		end
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args )
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper ( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListStyle;
		if cfg.global_cs1_config_t['NameListStyle'] then						-- global setting in {{cs1 config}} overrides local |name-list-style= parameter value; nil when empty or assigned value invalid
			NameListStyle = is_valid_parameter_value (cfg.global_cs1_config_t['NameListStyle'], 'cs1 config: name-list-style', cfg.keywords_lists['name-list-style'], '');	-- error messaging 'param' here is a hoax
		else
			NameListStyle = is_valid_parameter_value (A['NameListStyle'], A:ORIGIN('NameListStyle'), cfg.keywords_lists['name-list-style'], '');
		end

		if cfg.global_cs1_config_t['NameListStyle'] and utilities.is_set (A['NameListStyle']) then	-- when template has |name-list-style=&lt;something&gt; which global setting has overridden
			utilities.set_message ('maint_overridden_setting');					-- set a maint message
		end

	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			a, author_etal = parse_vauthors_veditors (args, A['Vauthors'], 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				utilities.set_message ('maint_authors');						-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if utilities.is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], nil, args, 'EditorList');	-- support for |editors= withdrawn
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		end
	end
							
	local Chapter = A['Chapter'];												-- done here so that we have access to |contribution= from |chapter= aliases
	local Chapter_origin = A:ORIGIN ('Chapter');
	local Contribution;															-- because contribution is required for contributor(s)
		if 'contribution' == Chapter_origin then
			Contribution = Chapter;												-- get the name of the contribution
		end
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	
	if utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not utilities.is_set (Contribution) then							-- |contributor= requires |contribution=
				utilities.set_message ('err_contributor_missing_required_param', 'contribution');	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				utilities.set_message ('err_contributor_missing_required_param', 'author');	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if utilities.select_one (args, cfg.aliases['ContributorList-Last'], 'err_redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			utilities.set_message ('err_contributor_ignored');					-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	local Title = A['Title'];
	local TitleLink = A['TitleLink'];

	local auto_select = '';														-- default is auto
	local accept_link;
	TitleLink, accept_link = utilities.has_accept_as_written (TitleLink, true);	-- test for accept-this-as-written markup
	if (not accept_link) and utilities.in_array (TitleLink, {'none', 'pmc', 'doi'}) then -- check for special keywords
		auto_select = TitleLink;												-- remember selection for later
		TitleLink = '';															-- treat as if |title-link= would have been empty
	end

	TitleLink = link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wiki-markup in |title-link= or wiki-markup in |title= when |title-link= is set

	local Section = '';															-- {{cite map}} only; preset to empty string for concatenation if not used
	if 'map' == config.CitationClass and 'section' == Chapter_origin then
		Section = A['Chapter'];													-- get |section= from |chapter= alias list; |chapter= and the other aliases not supported in {{cite map}}
		Chapter = '';															-- unset for now; will be reset later from |map= if present
	end

	local Periodical = A['Periodical'];
	local Periodical_origin = A:ORIGIN('Periodical');
	local ScriptPeriodical = A['ScriptPeriodical'];
	local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');
	local TransPeriodical =  A['TransPeriodical'];
	local TransPeriodical_origin =  A:ORIGIN ('TransPeriodical');
	
	if (utilities.in_array (config.CitationClass, {'book', 'encyclopaedia'}) and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (ScriptPeriodical))) then
		local param;
		if utilities.is_set (Periodical) then									-- get a parameter name from one of these periodical related meta-parameters
			Periodical = nil;													-- unset because not valid {{cite book}} or {{cite encyclopedia}} parameters 
			param = Periodical_origin											-- get parameter name for error messaging
		elseif utilities.is_set (TransPeriodical) then
			TransPeriodical = nil;												-- unset because not valid {{cite book}} or {{cite encyclopedia}} parameters 
			param = TransPeriodical_origin;										-- get parameter name for error messaging
		elseif utilities.is_set (ScriptPeriodical) then
			ScriptPeriodical = nil;												-- unset because not valid {{cite book}} or {{cite encyclopedia}} parameters 
			param = ScriptPeriodical_origin;									-- get parameter name for error messaging
		end

		if utilities.is_set (param) then										-- if we found one
			utilities.set_message ('err_periodical_ignored', {param});			-- emit an error message
		end
	end

	if utilities.is_set (Periodical) then
		local i;
		Periodical, i = utilities.strip_apostrophe_markup (Periodical);			-- strip apostrophe markup so that metadata isn't contaminated 
		if i then																-- non-zero when markup was stripped so emit an error message
			utilities.set_message ('err_apostrophe_markup', {Periodical_origin});
		end
	end

	if 'mailinglist' == config.CitationClass then								-- special case for {{cite mailing list}}
		if utilities.is_set (Periodical) and utilities.is_set (A ['MailingList']) then	-- both set emit an error TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', Periodical_origin) .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'mailinglist')});
		end

		Periodical = A ['MailingList'];											-- error or no, set Periodical to |mailinglist= value because this template is {{cite mailing list}}
		Periodical_origin = A:ORIGIN('MailingList');
	end

	-- web and news not tested for now because of 
	-- Wikipedia:Administrators%27_noticeboard#Is_there_a_semi-automated_tool_that_could_fix_these_annoying_&quot;Cite_Web&quot;_errors?
	if not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) then	-- 'periodical' templates require periodical parameter
	--	local p = {['journal'] = 'journal', ['magazine'] = 'magazine', ['news'] = 'newspaper', ['web'] = 'website'};	-- for error message
		local p = {['journal'] = 'journal', ['magazine'] = 'magazine'};			-- for error message
		if p[config.CitationClass]  then
			utilities.set_message ('err_missing_periodical', {config.CitationClass, p[config.CitationClass]});
		end
	end
	
	local Volume;
--	local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) then
			if not utilities.in_array (Periodical_origin, cfg.citation_no_volume_t) then	-- {{citation}} does not render |volume= when these parameters are used
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		elseif utilities.is_set (ScriptPeriodical) then
			if 'script-website' ~= ScriptPeriodical_origin then					-- {{citation}} does not render volume for |script-website=
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		else
			Volume = A['Volume'];												-- and does for non-'periodical' cites
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_volume) then	-- render |volume= for cs1 according to the configuration settings
		Volume = A['Volume'];
	end	
	extra_text_in_vol_iss_check (Volume, A:ORIGIN ('Volume'), 'v');	

	local Issue;
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) and utilities.in_array (Periodical_origin, cfg.citation_issue_t) then	-- {{citation}} may render |issue= when these parameters are used
			Issue = utilities.hyphen_to_dash (A['Issue']);
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_issue) then	-- conference &amp; map books do not support issue; {{citation}} listed here because included in settings table
		if not (utilities.in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical))) then
			Issue = utilities.hyphen_to_dash (A['Issue']);
		end
	end
	
	local ArticleNumber;

	if utilities.in_array (config.CitationClass, {'journal', 'conference'}) or ('citation' == config.CitationClass and utilities.is_set (Periodical) and 'journal' == Periodical_origin) then
		ArticleNumber = A['ArticleNumber'];
	end

	extra_text_in_vol_iss_check (Issue, A:ORIGIN ('Issue'), 'i');	

	local Page;
	local Pages;
	local At;
	local QuotePage;
	local QuotePages;
	if not utilities.in_array (config.CitationClass, cfg.templates_not_using_page) then		-- TODO: rewrite to emit ignored parameter error message?
		Page = A['Page'];
		Pages = utilities.hyphen_to_dash (A['Pages']);	
		At = A['At'];
		QuotePage = A['QuotePage'];
		QuotePages = utilities.hyphen_to_dash (A['QuotePages']);
	end

	local Edition = A['Edition'];
	local PublicationPlace = place_check (A['PublicationPlace'], A:ORIGIN('PublicationPlace'));
	local Place = place_check (A['Place'], A:ORIGIN('Place'));
	
	local PublisherName = A['PublisherName'];
	local PublisherName_origin = A:ORIGIN('PublisherName');
	if utilities.is_set (PublisherName) and (cfg.keywords_xlate['none'] ~= PublisherName) then
		local i = 0;
		PublisherName, i = utilities.strip_apostrophe_markup (PublisherName);	-- strip apostrophe markup so that metadata isn't contaminated; publisher is never italicized
		if i and (0 &lt; i) then													-- non-zero when markup was stripped so emit an error message
			utilities.set_message ('err_apostrophe_markup', {PublisherName_origin});
		end
	end
	
	if ('document' == config.CitationClass) and not utilities.is_set (PublisherName) then
		utilities.set_message ('err_missing_publisher', {config.CitationClass, 'publisher'});
	end

	local Newsgroup = A['Newsgroup'];											-- TODO: strip apostrophe markup?
	local Newsgroup_origin = A:ORIGIN('Newsgroup');	

	if 'newsgroup' == config.CitationClass then
		if utilities.is_set (PublisherName) and (cfg.keywords_xlate['none'] ~= PublisherName) then	-- general use parameter |publisher= not allowed in cite newsgroup
			utilities.set_message ('err_parameter_ignored', {PublisherName_origin});
		end

		PublisherName = nil;													-- ensure that this parameter is unset for the time being; will be used again after COinS
	end

	local URL = A['URL'];														-- TODO: better way to do this for URL, ChapterURL, and MapURL?
	local UrlAccess = is_valid_parameter_value (A['UrlAccess'], A:ORIGIN('UrlAccess'), cfg.keywords_lists['url-access'], nil);
	
	if not utilities.is_set (URL) and utilities.is_set (UrlAccess) then
		UrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', 'url');
	end
	
	local ChapterURL = A['ChapterURL'];
	local ChapterUrlAccess = is_valid_parameter_value (A['ChapterUrlAccess'], A:ORIGIN('ChapterUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (ChapterURL) and utilities.is_set (ChapterUrlAccess) then
		ChapterUrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', {A:ORIGIN('ChapterUrlAccess'):gsub ('%-access', '')});
	end

	local MapUrlAccess = is_valid_parameter_value (A['MapUrlAccess'], A:ORIGIN('MapUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (A['MapURL']) and utilities.is_set (MapUrlAccess) then
		MapUrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', {'map-url'});
	end

	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local no_tracking_cats = is_valid_parameter_value (A['NoTracking'], A:ORIGIN('NoTracking'), cfg.keywords_lists['yes_true_y'], nil);

	-- check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not utilities.is_set (no_tracking_cats) then								-- ignore if we are already not going to categorize this page
		if cfg.uncategorized_namespaces[this_page.namespace] then				-- is this page's namespace id one of the uncategorized namespace ids?
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _, v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end
																				-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	utilities.select_one (args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'err_redundant_parameters');	-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, A:ORIGIN('Page'), Pages, A:ORIGIN('Pages'), At);

	local NoPP = is_valid_parameter_value (A['NoPP'], A:ORIGIN('NoPP'), cfg.keywords_lists['yes_true_y'], nil);

	if utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- both |publication-place= and |place= (|location=) allowed if different
		utilities.add_prop_cat ('location-test');								-- add property cat to evaluate how often PublicationPlace and Place are used together
		if PublicationPlace == Place then
			Place = '';															-- unset; don't need both if they are the same
		end
	elseif not utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- when only |place= (|location=) is set ...
		PublicationPlace = Place;												-- promote |place= (|location=) to |publication-place
	end

	if PublicationPlace == Place then Place = ''; end							-- don't need both if they are the same

	local URL_origin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL_origin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ScriptChapter = A['ScriptChapter'];
	local ScriptChapter_origin = A:ORIGIN ('ScriptChapter');
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local TransChapter = A['TransChapter'];
	local TransChapter_origin = A:ORIGIN ('TransChapter');
	local TransTitle = A['TransTitle'];
	local ScriptTitle = A['ScriptTitle'];
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia= and |title= then map |title= to |article= and |encyclopedia= to |title= for rendering
		|encyclopedia= and |article= then map |encyclopedia= to |title= for rendering

		|trans-title= maps to |trans-chapter= when |title= is re-mapped
		|url= maps to |chapter-url= when |title= is remapped
	
	All other combinations of |encyclopedia=, |title=, and |article= are not modified
	
	]]

	local Encyclopedia = A['Encyclopedia'];										-- used as a flag by this module and by ~/COinS

	if utilities.is_set (Encyclopedia) then										-- emit error message when Encyclopedia set but template is other than {{cite encyclopedia}} or {{citation}}
		if 'encyclopaedia' ~= config.CitationClass and 'citation' ~= config.CitationClass then
			utilities.set_message ('err_parameter_ignored', {A:ORIGIN ('Encyclopedia')});
			Encyclopedia = nil;													-- unset because not supported by this template
		end
	end

	if ('encyclopaedia' == config.CitationClass) or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Periodical) and utilities.is_set (Encyclopedia) then	-- when both parameters set emit an error message; {{citation}} only; Periodical not allowed in {{cite encyclopedia}}
			utilities.set_message ('err_periodical_ignored', {Periodical_origin});
		end

		if utilities.is_set (Encyclopedia) then
			Periodical = Encyclopedia;											-- error or no, set Periodical to Encyclopedia for rendering; {{citation}} could (not legitimately) have both; use Encyclopedia
			Periodical_origin = A:ORIGIN ('Encyclopedia');

			if utilities.is_set (Title) or utilities.is_set (ScriptTitle) then
				if not utilities.is_set (Chapter) then
					Chapter = Title;											-- |encyclopedia= and |title= are set so map |title= to |article= and |encyclopedia= to |title= for rendering
					ScriptChapter = ScriptTitle;
					ScriptChapter_origin = A:ORIGIN('ScriptTitle')
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterURL_origin = URL_origin;

					ChapterUrlAccess = UrlAccess;

					if not utilities.is_set (ChapterURL) and utilities.is_set (TitleLink) then
						Chapter = utilities.make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			elseif utilities.is_set (Chapter) or utilities.is_set (ScriptChapter) then								-- |title= not set
				Title = Periodical;												-- |encyclopedia= set and |article= set so map |encyclopedia= to |title= for rendering
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- special case for cite techreport.
	local ID = A['ID'];
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if utilities.is_set (A['Number']) then									-- cite techreport uses 'number', which other citations alias to 'issue'
			if not utilities.is_set (ID) then									-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'id') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'number')});
			end
		end	
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	local ChapterLink -- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local Conference = A['Conference'];
	local BookTitle = A['BookTitle'];
	local TransTitle_origin = A:ORIGIN ('TransTitle');
	if 'conference' == config.CitationClass then
		if utilities.is_set (BookTitle) then
			Chapter = Title;
			Chapter_origin = 'title';
	--		ChapterLink = TitleLink;											-- |chapter-link= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			URL_origin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			TransChapter_origin = TransTitle_origin;
			Title = BookTitle;
			Format = '';
	--		TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end
	
	-- CS1/2 mode
	local Mode;
		if cfg.global_cs1_config_t['Mode'] then									-- global setting in {{cs1 config}} overrides local |mode= parameter value; nil when empty or assigned value invalid
			Mode = is_valid_parameter_value (cfg.global_cs1_config_t['Mode'], 'cs1 config: mode', cfg.keywords_lists['mode'], '');	-- error messaging 'param' here is a hoax
		else
			Mode = is_valid_parameter_value (A['Mode'], A:ORIGIN('Mode'), cfg.keywords_lists['mode'], '');
		end

		if cfg.global_cs1_config_t['Mode'] and utilities.is_set (A['Mode']) then	-- when template has |mode=&lt;something&gt; which global setting has overridden
			utilities.set_message ('maint_overridden_setting');					-- set a maint message
		end

	-- separator character and postscript
	local sepc, PostScript = set_style (Mode:lower(), A['PostScript'], config.CitationClass);
	-- controls capitalization of certain static text
	local use_lowercase = ( sepc == ',' );
	
	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		if utilities.is_set (Chapter) then										--TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'map') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', Chapter_origin)});	-- add error message
		end
		Chapter = A['Map'];
		Chapter_origin = A:ORIGIN('Map');
		ChapterURL = A['MapURL'];
		ChapterURL_origin = A:ORIGIN('MapURL');
		TransChapter = A['TransMap'];
		ScriptChapter = A['ScriptMap']
		ScriptChapter_origin = A:ORIGIN('ScriptMap')

		ChapterUrlAccess = MapUrlAccess;
		ChapterFormat = A['MapFormat'];

		Cartography = A['Cartography'];
		if utilities.is_set ( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if utilities.is_set ( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	local Series = A['Series'];
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local SeriesLink = A['SeriesLink'];

		SeriesLink = link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wiki-markup in |series-link= or wiki-markup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if utilities.is_set (Network) then table.insert(n, Network); end
		if utilities.is_set (Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if utilities.is_set (Season) and utilities.is_set (SeriesNumber) then	-- these are mutually exclusive so if both are set TODO: make a function for this and similar?
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'season') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'seriesno')});		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if utilities.is_set (Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if utilities.is_set (SeriesNumber) then table.insert(s, wrap_msg ('seriesnum', SeriesNumber, use_lowercase)); end
			if utilities.is_set (Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ScriptChapter_origin = A:ORIGIN('ScriptTitle');
			ChapterLink = TitleLink;											-- alias |episode-link=
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			ChapterFormat = Format;

			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if utilities.is_set (ChapterLink) and not utilities.is_set (ChapterURL) then	-- link but not URL
				Chapter = utilities.make_wikilink (ChapterLink, Chapter);
			elseif utilities.is_set (ChapterLink) and utilities.is_set (ChapterURL) then	-- if both are set, URL links episode;
				Series = utilities.make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			Format = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if utilities.is_set (Series) and utilities.is_set (SeriesLink) then
				Series = utilities.make_wikilink (SeriesLink, Series);
			end
			Series = utilities.wrap_style ('italic-title', Series);				-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- handle type parameter for those CS1 citations that have default values
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	if utilities.in_array (config.CitationClass, {'AV-media-notes', 'document', 'interview', 'mailinglist', 'map', 'podcast', 'pressrelease', 'report', 'speech', 'techreport', 'thesis'}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if utilities.is_set (Degree) and &quot;Thesis&quot; == TitleType then				-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if utilities.is_set (TitleType) then										-- if type parameter is specified
		TitleType = utilities.substitute ( cfg.messages['type'], TitleType);	-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
	local Date = A['Date'];
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging
	local PublicationDate = A['PublicationDate'];
	local Year = A['Year'];

	if not utilities.is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not utilities.is_set (Date) and utilities.is_set (PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]

	local DF = is_valid_parameter_value (A['DF'], A:ORIGIN('DF'), cfg.keywords_lists['df'], '');
	if not utilities.is_set (DF) then
		DF = cfg.global_df;														-- local |df= if present overrides global df set by {{use xxx date}} template
	end

	local ArchiveURL;
	local ArchiveDate;
	local ArchiveFormat = A['ArchiveFormat'];
	local archive_url_timestamp;												-- timestamp from wayback machine url
	
	ArchiveURL, ArchiveDate, archive_url_timestamp = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	
	ArchiveURL, ArchiveDate = is_unique_archive_url (ArchiveURL, URL, ChapterURL, A:ORIGIN('ArchiveURL'), ArchiveDate);		-- add error message when URL or ChapterURL == ArchiveURL

	local AccessDate = A['AccessDate'];
--	local LayDate = A['LayDate'];
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification
	local DoiBroken = A['DoiBroken'];
	local Embargo = A['Embargo'];
	local anchor_year;															-- used in the CITEREF identifier
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val = AccessDate, name = A:ORIGIN ('AccessDate')},
			['archive-date'] = {val = ArchiveDate, name = A:ORIGIN ('ArchiveDate')},
			['date'] = {val = Date, name = Date_origin},
			['doi-broken-date'] = {val = DoiBroken, name = A:ORIGIN ('DoiBroken')},
			['pmc-embargo-date'] = {val = Embargo, name = A:ORIGIN ('Embargo')},
--			['lay-date'] = {val = LayDate, name = A:ORIGIN ('LayDate')},
			['publication-date'] = {val = PublicationDate, name = A:ORIGIN ('PublicationDate')},
			['year'] = {val = Year, name = A:ORIGIN ('Year')},
			};

		local error_list = {};
		anchor_year, Embargo = validation.dates(date_parameters_list, COinS_date, error_list);

-- start temporary Julian / Gregorian calendar uncertainty categorization
		if COinS_date.inter_cal_cat then
			utilities.add_prop_cat ('jul-greg-uncertainty');
		end
-- end temporary Julian / Gregorian calendar uncertainty categorization

		if utilities.is_set (Year) and utilities.is_set (Date) then				-- both |date= and |year= not normally needed; 
			validation.year_date_check (Year, A:ORIGIN ('Year'), Date, A:ORIGIN ('Date'), error_list);
		end
		
		if 0 == #error_list then												-- error free dates only; 0 when error_list is empty
			local modified = false;												-- flag
			
			if utilities.is_set (DF) then										-- if we need to reformat dates
				modified = validation.reformat_dates (date_parameters_list, DF);	-- reformat to DF format, use long month names if appropriate
			end

			if true == validation.date_hyphen_to_dash (date_parameters_list) then	-- convert hyphens to dashes where appropriate
				modified = true;
				utilities.set_message ('maint_date_format');					-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language; not supported at en.wiki
			if cfg.date_name_auto_xlate_enable and validation.date_name_xlate (date_parameters_list, cfg.date_digit_auto_xlate_enable ) then
				utilities.set_message ('maint_date_auto_xlated');				-- add maint cat
				modified = true;
			end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
--				LayDate = date_parameters_list['lay-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end

			if archive_url_timestamp and utilities.is_set (ArchiveDate) then
				validation.archive_date_check (ArchiveDate, archive_url_timestamp);	-- does YYYYMMDD in archive_url_timestamp match date in ArchiveDate
			end
		else
			utilities.set_message ('err_bad_date', {utilities.make_sep_list (#error_list, error_list)});	-- add this error message
		end
	end	-- end of do

	if utilities.in_array (config.CitationClass, {'book', 'encyclopaedia'}) or	-- {{cite book}}, {{cite encyclopedia}}; TODO: {{cite conference}} and others?
		('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) or			-- {{citation}} as an encylopedia citation
		('citation' == config.CitationClass and not utilities.is_set (Periodical)) then		-- {{citation}} as a book citation
			if utilities.is_set (PublicationPlace) then
				if not utilities.is_set (PublisherName) then
					local date = COinS_date.rftdate and tonumber (COinS_date.rftdate:match ('%d%d%d%d'));	-- get year portion of COinS date (because in Arabic numerals); convert string to number
					if date and (1850 &lt;= date) then								-- location has no publisher; if date is 1850 or later
						utilities.set_message ('maint_location_no_publisher');	-- add maint cat
					end
				else															-- PublisherName has a value
					if cfg.keywords_xlate['none'] == PublisherName then			-- if that value is 'none' (only for book and encyclopedia citations)
						PublisherName = '';										-- unset
					end
				end
			end
	end

	local ID_list = {};															-- sequence table of rendered identifiers
	local ID_list_coins = {};													-- table of identifiers and their values from args; key is same as cfg.id_handlers's key
	local Class = A['Class'];													-- arxiv class identifier
	
	local ID_support = {
		{A['ASINTLD'], 'ASIN', 'err_asintld_missing_asin', A:ORIGIN ('ASINTLD')},				
		{DoiBroken, 'DOI', 'err_doibroken_missing_doi', A:ORIGIN ('DoiBroken')},
		{Embargo, 'PMC', 'err_embargo_missing_pmc', A:ORIGIN ('Embargo')},
		}

	ID_list, ID_list_coins = identifiers.identifier_lists_get (args, {DoiBroken = DoiBroken, ASINTLD = A['ASINTLD'], Embargo = Embargo, Class = Class}, ID_support);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite medrxiv}}, {{cite ssrn}}, before generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list_t) then	-- |arxiv= or |eprint= required for cite arxiv; |biorxiv=, |citeseerx=, |medrxiv=, |ssrn= required for their templates
		if not (args[cfg.id_handlers[config.CitationClass:upper()].parameters[1]] or 		-- can't use ID_list_coins k/v table here because invalid parameters omitted
			args[cfg.id_handlers[config.CitationClass:upper()].parameters[2]]) then			-- which causes unexpected parameter missing error message
				utilities.set_message ('err_' .. config.CitationClass .. '_missing');		-- add error message
		end

		Periodical = ({['arxiv'] = 'arXiv', ['biorxiv'] = 'bioRxiv', ['citeseerx'] = 'CiteSeerX', ['medrxiv'] = 'medRxiv', ['ssrn'] = 'Social Science Research Network'})[config.CitationClass];
	end

	-- Link the title of the work if no |url= was provided, but we have a |pmc= or a |doi= with |doi-access=free

	if config.CitationClass == &quot;journal&quot; and not utilities.is_set (URL) and not utilities.is_set (TitleLink) and not utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) then -- TODO: remove 'none' once existing citations have been switched to 'off', so 'none' can be used as token for &quot;no title&quot; instead
		if 'none' ~= cfg.keywords_xlate[auto_select] then						-- if auto-linking not disabled
 	 		if identifiers.auto_link_urls[auto_select] then						-- manual selection
		 		URL = identifiers.auto_link_urls[auto_select];					-- set URL to be the same as identifier's external link
 				URL_origin = cfg.id_handlers[auto_select:upper()].parameters[1];	-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['pmc'] then						-- auto-select PMC
				URL = identifiers.auto_link_urls['pmc'];						-- set URL to be the same as the PMC external link if not embargoed
				URL_origin = cfg.id_handlers['PMC'].parameters[1];				-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['doi'] then						-- auto-select DOI
				URL = identifiers.auto_link_urls['doi'];
				URL_origin = cfg.id_handlers['DOI'].parameters[1];
			end
 	 	end

		if utilities.is_set (URL) then											-- set when using an identifier-created URL
			if utilities.is_set (AccessDate) then								-- |access-date= requires |url=; identifier-created URL is not |url=
				utilities.set_message ('err_accessdate_missing_url');			-- add an error message
				AccessDate = '';												-- unset
			end

			if utilities.is_set (ArchiveURL) then								-- |archive-url= requires |url=; identifier-created URL is not |url=
				utilities.set_message ('err_archive_missing_url');				-- add an error message
				ArchiveURL = '';												-- unset
			end
		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not utilities.is_set (Title) and not utilities.is_set (TransTitle) and not utilities.is_set (ScriptTitle) then	-- has special case for cite episode
		utilities.set_message ('err_citation_missing_title', {'episode' == config.CitationClass and 'series' or 'title'});
	end

	if utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) and
			utilities.in_array (config.CitationClass, {'journal', 'citation'}) and
			(utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and
			('journal' == Periodical_origin or 'script-journal' == ScriptPeriodical_origin) then	-- special case for journal cites
				Title = '';														-- set title to empty string
				utilities.set_message ('maint_untitled');						-- add maint cat
	end

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Chapter) and utilities.is_set (Title) and utilities.is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end
	
	-- this is the function call to COinS()
	local OCinSoutput = metadata.COinS({
		['Periodical'] = utilities.strip_apostrophe_markup (Periodical),		-- no markup in the metadata
		['Encyclopedia'] = Encyclopedia,										-- just a flag; content ignored by ~/COinS
		['Chapter'] = metadata.make_coins_title (coins_chapter, ScriptChapter),	-- Chapter and ScriptChapter stripped of bold / italic / accept-as-written markup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = metadata.make_coins_title (coins_title, ScriptTitle),		-- Title and ScriptTitle stripped of bold / italic / accept-as-written markup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date.* has correctly formatted date values if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Quarter'] = COinS_date.rftquarter,
		['Chron'] =  COinS_date.rftchron,
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['ArticleNumber'] = ArticleNumber,
		['Pages'] = coins_pages or metadata.get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At, QuotePage, QuotePages}, 7)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName or Newsgroup,							-- any apostrophe markup already removed from PublisherName
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list_coins,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite medrxiv}}, and {{cite ssrn}} AFTER generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list_t) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, CiteSeerX, medRxiv, or ssrn now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass and utilities.is_set (Newsgroup) then
		PublisherName = utilities.substitute (cfg.messages['newsgroup'], external_link( 'news:' .. Newsgroup, Newsgroup, Newsgroup_origin, nil ));
	end

	local Editors;
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	local Contributors;															-- assembled contributors name list
	local contributor_etal;
	local Translators;															-- assembled translators name list
	local translator_etal;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	local Interviewers;															
	local interviewers_list = {};					
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters
	local interviewer_etal;
	
	-- Now perform various field 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.
	do
		local last_first_list;
		local control = { 
			format = NameListStyle,												-- empty string, '&amp;', 'amp', 'and', or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			if cfg.global_cs1_config_t['DisplayEditors'] then					-- global setting from {{cs1 config}} overrides local setting
				control.maximum , editor_etal = get_display_names (cfg.global_cs1_config_t['DisplayEditors'], #e, 'editors', editor_etal, 'cs1 config');
			else
				control.maximum , editor_etal = get_display_names (A['DisplayEditors'], #e, 'editors', editor_etal, A:ORIGIN ('DisplayEditors'));
			end

			if cfg.global_cs1_config_t['DisplayEditors'] and utilities.is_set (A['DisplayEditors']) then	-- when template has |display-editors=&lt;something&gt; which global setting has overridden
				utilities.set_message ('maint_overridden_setting');				-- set a maint message
			end

			Editors, EditorCount = list_people (control, e, editor_etal);

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			if cfg.global_cs1_config_t['DisplayInterviewers'] then				-- global setting from {{cs1 config}} overrides local setting
				control.maximum, interviewer_etal = get_display_names (cfg.global_cs1_config_t['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal, 'cs1 config');
			else
				control.maximum, interviewer_etal = get_display_names (A['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal, A:ORIGIN ('DisplayInterviewers'));
			end

			if cfg.global_cs1_config_t['DisplayInterviewers'] and utilities.is_set (A['DisplayInterviewers']) then	-- when template has |display-interviewers=&lt;something&gt; which global setting has overridden
				utilities.set_message ('maint_overridden_setting');				-- set a maint message
			end

			Interviewers = list_people (control, interviewers_list, interviewer_etal);
		end
		do																		-- now do translators
			if cfg.global_cs1_config_t['DisplayTranslators'] then				-- global setting from {{cs1 config}} overrides local setting
				control.maximum, translator_etal = get_display_names (cfg.global_cs1_config_t['DisplayTranslators'], #t, 'translators', 'cs1 config');
			else
				control.maximum, translator_etal = get_display_names (A['DisplayTranslators'], #t, 'translators', translator_etal, A:ORIGIN ('DisplayTranslators'));
			end

			if cfg.global_cs1_config_t['DisplayTranslators'] and utilities.is_set (A['DisplayTranslators']) then	-- when template has |display-translators=&lt;something&gt; which global setting has overridden
				utilities.set_message ('maint_overridden_setting');				-- set a maint message
			end

			Translators = list_people (control, t, translator_etal);
		end
		do																		-- now do contributors
			if cfg.global_cs1_config_t['DisplayContributors'] then				-- global setting from {{cs1 config}} overrides local setting
				control.maximum, contributor_etal = get_display_names (cfg.global_cs1_config_t['DisplayContributors'], #c, 'contributors', contributor_etal, 'cs1 config');
			else
				control.maximum, contributor_etal = get_display_names (A['DisplayContributors'], #c, 'contributors', contributor_etal, A:ORIGIN ('DisplayContributors'));
			end

			if cfg.global_cs1_config_t['DisplayContributors'] and utilities.is_set (A['DisplayContributors']) then	-- when template has |display-contributors=&lt;something&gt; which global setting has overridden
				utilities.set_message ('maint_overridden_setting');				-- set a maint message
			end

			Contributors = list_people (control, c, contributor_etal);
		end
		do																		-- now do authors
			if cfg.global_cs1_config_t['DisplayAuthors'] then					-- global setting from {{cs1 config}} overrides local setting
				control.maximum, author_etal = get_display_names (cfg.global_cs1_config_t['DisplayAuthors'], #a, 'authors', author_etal, 'cs1 config');
			else
				control.maximum, author_etal = get_display_names (A['DisplayAuthors'], #a, 'authors', author_etal, A:ORIGIN ('DisplayAuthors'));
			end

			if cfg.global_cs1_config_t['DisplayAuthors'] and utilities.is_set (A['DisplayAuthors']) then	-- when template has |display-authors=&lt;something&gt; which global setting has overridden
				utilities.set_message ('maint_overridden_setting');				-- set a maint message
			end

			last_first_list = list_people (control, a, author_etal);

			if utilities.is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors');	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if utilities.is_set (Authors) and utilities.is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'medrxiv', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not utilities.is_set (URL) then
		if utilities.in_array (config.CitationClass, {&quot;web&quot;, &quot;podcast&quot;, &quot;mailinglist&quot;}) or		-- |url= required for cite web, cite podcast, and cite mailinglist
			('citation' == config.CitationClass and ('website' == Periodical_origin or 'script-website' == ScriptPeriodical_origin)) then	-- and required for {{citation}} with |website= or |script-website=
				utilities.set_message ('err_cite_web_url');
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if utilities.is_set (AccessDate) and not utilities.is_set (ChapterURL) then		-- ChapterURL may be set when URL is not set;
			utilities.set_message ('err_accessdate_missing_url');
			AccessDate = '';
		end
	end

	local UrlStatus = is_valid_parameter_value (A['UrlStatus'], A:ORIGIN('UrlStatus'), cfg.keywords_lists['url-status'], '');
	local OriginalURL
	local OriginalURL_origin
	local OriginalFormat
	local OriginalAccess;
	UrlStatus = UrlStatus:lower();												-- used later when assembling archived text
	if utilities.is_set ( ArchiveURL ) then
		if utilities.is_set (ChapterURL) then 									-- if chapter-url= is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURL_origin = ChapterURL_origin;								-- name of |chapter-url= parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=

			if 'live' ~= UrlStatus then
				ChapterURL = ArchiveURL											-- swap-in the archive's URL
				ChapterURL_origin = A:ORIGIN('ArchiveURL')						-- name of |archive-url= parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived URLs
			end
		elseif utilities.is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURL_origin = URL_origin;									-- name of URL parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;

			if 'live' ~= UrlStatus then											-- if URL set then |archive-url= applies to it
				URL = ArchiveURL												-- swap-in the archive's URL
				URL_origin = A:ORIGIN('ArchiveURL')								-- name of archive URL parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived URLs
			end
		end
	elseif utilities.is_set (UrlStatus) then									-- if |url-status= is set when |archive-url= is not set
 		utilities.set_message ('maint_url_status');								-- add maint cat
	end

	if utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'medrxiv', 'ssrn'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) then
			local chap_param;
			if utilities.is_set (Chapter) then									-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif utilities.is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif utilities.is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif utilities.is_set (ScriptChapter) then
				chap_param = ScriptChapter_origin;
			else utilities.is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if utilities.is_set (chap_param) then								-- if we found one
				utilities.set_message ('err_chapter_ignored', {chap_param});	-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if utilities.is_set (Contribution) and 0 &lt; #c then						-- if this is a contribution with contributor(s)
			if utilities.in_array (Contribution:lower(), cfg.keywords_lists.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, ScriptChapter_origin, Chapter, Chapter_origin, TransChapter, TransChapter_origin, ChapterURL, ChapterURL_origin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if utilities.is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and utilities.is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter .. sepc .. ' ';
		elseif utilities.is_set (ChapterFormat) then							-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title
	local plain_title = false;
	local accept_title;
	Title, accept_title = utilities.has_accept_as_written (Title, true);		-- remove accept-this-as-written markup when it wraps all of &lt;Title&gt;
	if accept_title and ('' == Title) then										-- only support forced empty for now &quot;(())&quot;
		Title = cfg.messages['notitle'];										-- replace by predefined &quot;No title&quot; message
			-- TODO: utilities.set_message ( 'err_redundant_parameters', ...);	-- issue proper error message instead of muting	 
			ScriptTitle = '';													-- just mute for now	 
			TransTitle = '';													-- just mute for now
 		plain_title = true;														-- suppress text decoration for descriptive title
		utilities.set_message ('maint_untitled');								-- add maint cat
	end

	if not accept_title then													-- &lt;Title&gt; not wrapped in accept-as-written markup
		if '...' == Title:sub (-3) then											-- if ellipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%' .. sepc .. '$', '');			-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end

		if utilities.is_set (ArchiveURL) and is_archived_copy (Title) then
			utilities.set_message ('maint_archived_copy');						-- add maintenance category before we modify the content of Title
		end

		if is_generic ('generic_titles', Title) then
			utilities.set_message ('err_generic_title');						-- set an error message
		end
	end

	if (not plain_title) and (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'document', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx', 'medrxiv', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) or
		('map' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)))) then		-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from module provided quote marks
			Title = utilities.wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle, 'script-title');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
			TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );
	elseif plain_title or ('report' == config.CitationClass) then				-- no styling for cite report and descriptive titles (otherwise same as above)
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );	-- for cite report, use this form for trans-title
	else
		Title = utilities.wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-italic-title', TransTitle);
	end

	if utilities.is_set (TransTitle) then
		if utilities.is_set (Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			utilities.set_message ('err_trans_missing_title', {'title'});
		end
	end

	if utilities.is_set (Title) then											-- TODO: is this the right place to be making Wikisource URLs?
		if utilities.is_set (TitleLink) and utilities.is_set (URL) then
			utilities.set_message ('err_wikilink_in_url');						-- set an error message because we can't have both
			TitleLink = '';														-- unset
		end
	
		if not utilities.is_set (TitleLink) and utilities.is_set (URL) then
			Title = external_link (URL, Title, URL_origin, UrlAccess) .. TransTitle .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif utilities.is_set (TitleLink) and not utilities.is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle;
			else
				Title = utilities.make_wikilink (TitleLink, Title) .. TransTitle;
			end
		else
			local ws_url, ws_label, L;											-- Title has italic or quote markup by the time we get here which causes is_wikilink() to return 0 (not a wikilink)
			ws_url, ws_label, L = wikisource_url_make (Title:gsub('^[\'&quot;]*(.-)[\'&quot;]*$', '%1'));	-- make ws URL from |title= interwiki link (strip italic or quote markup); link portion L becomes tooltip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle;
			else
				Title = Title .. TransTitle;
			end
		end
	else
		Title = TransTitle;
	end

	if utilities.is_set (Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	local ConferenceURL_origin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	if utilities.is_set (Conference) then
		if utilities.is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURL_origin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif utilities.is_set (ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURL_origin, nil );
	end

	local Position = '';
	if not utilities.is_set (Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if utilities.is_set (Minutes) then
			if utilities.is_set (Time) then		--TODO: make a function for this and similar?
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'minutes') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'time')});
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if utilities.is_set (Time) then
				local TimeCaption = A['TimeCaption']
				if not utilities.is_set (TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = utilities.is_set (At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = utilities.is_set (Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Sections = A['Sections'];											-- Section (singular) is an alias of Chapter so set earlier
		local Inset = A['Inset'];
		
		if utilities.is_set ( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if utilities.is_set ( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif utilities.is_set ( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	local Others = A['Others'];
	if utilities.is_set (Others) and 0 == #a and 0 == #e then					-- add maint cat when |others= has value and used without |author=, |editor=
		if config.CitationClass == &quot;AV-media-notes&quot;
		or config.CitationClass == &quot;audio-visual&quot; then							-- special maint for AV/M which has a lot of 'false' positives right now
			utilities.set_message ('maint_others_avm')
		else
			utilities.set_message ('maint_others');
		end
	end
	Others = utilities.is_set (Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if utilities.is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if utilities.is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	local TitleNote = A['TitleNote'];
	TitleNote = utilities.is_set (TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if utilities.is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%n?%.?$') or Edition:match ('%f[%a][Ee]dition$') then -- Ed, ed, Ed., ed., Edn, edn, Edn., edn.
			utilities.set_message ('err_extra_text_edition');					 -- add error message
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = utilities.is_set (Series) and wrap_msg ('series', {sepc, Series}) or &quot;&quot;;	-- not the same as SeriesNum
	local Agency = A['Agency'];
	Agency = utilities.is_set (Agency) and wrap_msg ('agency', {sepc, Agency}) or &quot;&quot;;
	Volume = format_volume_issue (Volume, Issue, ArticleNumber, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	if utilities.is_set (AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = utilities.substitute (retrv_text, AccessDate);				-- add retrieved text

		AccessDate = utilities.substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if utilities.is_set (ID) then ID = sepc .. &quot; &quot; .. ID; end
	
	local Docket = A['Docket'];
   	if &quot;thesis&quot; == config.CitationClass and utilities.is_set (Docket) then
		ID = sepc .. &quot; Docket &quot; .. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and utilities.is_set (Docket) then		-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	if utilities.is_set (URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URL_origin, UrlAccess );
	end

	local Quote = A['Quote'];
	local TransQuote = A['TransQuote'];
	local ScriptQuote = A['ScriptQuote'];
	if utilities.is_set (Quote) or utilities.is_set (TransQuote) or utilities.is_set (ScriptQuote) then

		if utilities.is_set (Quote) then
			if Quote:sub(1, 1) == '&quot;' and Quote:sub(-1, -1) == '&quot;' then			-- if first and last characters of quote are quote marks
				Quote = Quote:sub(2, -2);										-- strip them off
			end
		end
		
		Quote = kern_quotes (Quote);											-- kern if needed
		Quote = utilities.wrap_style ('quoted-text', Quote );					-- wrap in &lt;q&gt;...&lt;/q&gt; tags
	
		if utilities.is_set (ScriptQuote) then
			Quote = script_concatenate (Quote, ScriptQuote, 'script-quote');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after quote is wrapped
		end

		if utilities.is_set (TransQuote) then
			if TransQuote:sub(1, 1) == '&quot;' and TransQuote:sub(-1, -1) == '&quot;' then -- if first and last characters of |trans-quote are quote marks
				TransQuote = TransQuote:sub(2, -2); -- strip them off
			end
			Quote = Quote .. &quot; &quot; .. utilities.wrap_style ('trans-quoted-title', TransQuote );
		end

		if utilities.is_set (QuotePage) or utilities.is_set (QuotePages) then	-- add page prefix
			local quote_prefix = '';
			if utilities.is_set (QuotePage) then
				extra_text_in_page_check (QuotePage, 'quote-page');				-- add to maint cat if |quote-page= value begins with what looks like p., pp., etc.
				if not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePage}), '', '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePage}), '', '', '';
				end
			elseif utilities.is_set (QuotePages) then
				extra_text_in_page_check (QuotePages, 'quote-pages');			-- add to maint cat if |quote-pages= value begins with what looks like p., pp., etc.
				if tonumber(QuotePages) ~= nil and not NoPP then				-- if only digits, assume single page
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePages}), '', '';
				elseif not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['pp-prefix'], {sepc, QuotePages}), '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePages}), '', '';
				end
			end
                        
			Quote = quote_prefix .. &quot;: &quot; .. Quote;
		else
			Quote = sepc .. &quot; &quot; .. Quote;
		end

		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	-- We check length of PostScript here because it will have been nuked by
	-- the quote parameters. We'd otherwise emit a message even if there wasn't
	-- a displayed postscript.
	-- TODO: Should the max size (1) be configurable?
	-- TODO: Should we check a specific pattern?
	if utilities.is_set(PostScript) and mw.ustring.len(PostScript) &gt; 1 then
		utilities.set_message ('maint_postscript')
	end
	
	local Archived;
	if utilities.is_set (ArchiveURL) then
		if not utilities.is_set (ArchiveDate) then								-- ArchiveURL set but ArchiveDate not set
			utilities.set_message ('err_archive_missing_date');					-- emit an error message
			ArchiveURL = '';													-- empty string for concatenation
			ArchiveDate = '';													-- empty string for concatenation
		end
	else														
		if utilities.is_set (ArchiveDate) then									-- ArchiveURL not set but ArchiveDate is set
			utilities.set_message ('err_archive_date_missing_url');				-- emit an error message
			ArchiveURL = '';													-- empty string for concatenation
			ArchiveDate = '';													-- empty string for concatenation
		end
	end

	if utilities.is_set (ArchiveURL) then
		local arch_text;
--		if not utilities.is_set (ArchiveDate) then
--			utilities.set_message ('err_archive_missing_date');
--			ArchiveDate = '';													-- empty string for concatenation
--		end
		if &quot;live&quot; == UrlStatus then
			arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if utilities.is_set (ArchiveDate) then
				Archived = sepc .. ' ' .. utilities.substitute ( cfg.messages['archived-live'],
					{external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil) .. ArchiveFormat, ArchiveDate } );
			else
				Archived = '';
			end
			if not utilities.is_set (OriginalURL) then
				utilities.set_message ('err_archive_missing_url');
				Archived = '';													-- empty string for concatenation
			end
		elseif utilities.is_set (OriginalURL) then								-- UrlStatus is empty, 'dead', 'unfit', 'usurped', 'bot: unknown'
			if utilities.in_array (UrlStatus, {'unfit', 'usurped', 'bot: unknown'}) then
				arch_text = cfg.messages['archived-unfit'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. ' ' .. arch_text .. ArchiveDate;				-- format already styled
				if 'bot: unknown' == UrlStatus then
					utilities.set_message ('maint_bot_unknown');				-- and add a category if not already added
				else
					utilities.set_message ('maint_unfit');						-- and add a category if not already added
				end
			else																-- UrlStatus is empty, 'dead'
				arch_text = cfg.messages['archived-dead'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				if utilities.is_set (ArchiveDate) then
					Archived = sepc .. &quot; &quot; .. utilities.substitute ( arch_text,
						{ external_link( OriginalURL, cfg.messages['original'], OriginalURL_origin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
				else
					Archived = '';												-- unset for concatenation
				end
			end	
		else																	-- OriginalUrl not set
			utilities.set_message ('err_archive_missing_url');
			Archived = '';														-- empty string for concatenation
		end
	elseif utilities.is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = '';
	end
	
--	local Lay = '';
--	local LaySource = A['LaySource'];
--	local LayURL = A['LayURL'];
--	local LayFormat = A['LayFormat'];
--	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
--	if utilities.is_set (LayURL) then
--		if utilities.is_set (LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
--		if utilities.is_set (LaySource) then 
--			LaySource = &quot; &amp;ndash; ''&quot; .. utilities.safe_for_italics (LaySource) .. &quot;''&quot;;
--		else
--			LaySource = &quot;&quot;;
--		end
--		if sepc == '.' then
--			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
--		else
--			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
--		end			
--	elseif utilities.is_set (LayFormat) then									-- Test if |lay-format= is given without giving a |lay-url=
--		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
--	end

	local TranscriptURL = A['TranscriptURL']
	local TranscriptFormat = A['TranscriptFormat'];
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');
	local Transcript = A['Transcript'];
	local TranscriptURL_origin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL
	if utilities.is_set (Transcript) then
		if utilities.is_set (TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURL_origin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif utilities.is_set (TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURL_origin, nil );
	end

	local Publisher;
	if utilities.is_set (PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if utilities.is_set (PublisherName) then
		if utilities.is_set (PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif utilities.is_set (PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical)) then
		if utilities.is_set (Title) or utilities.is_set (TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		else 
			Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		end
	end
	
	local Language = A['Language'];
	if utilities.is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc.
	else
		Language='';															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then									-- cite speech only
		TitleNote = TitleType;													-- move TitleType to TitleNote so that it renders ahead of |event=
		TitleType = '';															-- and unset

		if utilities.is_set (Periodical) then									-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if utilities.is_set (Conference) then								-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;							-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
		if not (utilities.is_set (Authors) or utilities.is_set (Editors)) then
			Others = Others:gsub ('^' .. sepc .. ' ', '');						-- when no authors and no editors, strip leading sepc and space
		end
		if utilities.is_set (Others) then Others = safe_join ({Others, sepc .. &quot; &quot;}, sepc) end		-- add terminal punctuation &amp; space; check for dup sepc; TODO why do we need to do this here?
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (Periodical) then		-- special cases for book cites
		if utilities.is_set (Contributors) then									-- when we are citing foreword, preface, introduction, etc.
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if utilities.is_set (Chapter) then										-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif utilities.is_set (Periodical) then								-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local Via = A['Via'];
	Via = utilities.is_set (Via) and  wrap_msg ('via', Via) or '';
	local idcommon;
	if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then	-- special case for cite AV media &amp; cite episode position transcript
--		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, Lay, Quote }, sepc );
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, Quote }, sepc );
	else
--		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, Lay, Quote }, sepc );
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, Quote }, sepc );
	end
	
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	local OrigDate = A['OrigDate'];
	OrigDate = utilities.is_set (OrigDate) and wrap_msg ('origdate', OrigDate) or '';
	if utilities.is_set (Date) then
		if utilities.is_set (Authors) or utilities.is_set (Editors) then		-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date .. &quot;)&quot; .. OrigDate .. sepc .. &quot; &quot;;				-- in parentheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon, -1, -1) == sepc) then						-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigDate;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigDate;							-- Date begins with sepc
			end
		end
	end	
	if utilities.is_set (Authors) then
		if (not utilities.is_set (Date)) then									-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Editors) then
			local in_text = '';
			local post_text = '';
			if utilities.is_set (Chapter) and 0 == #c then
				in_text = cfg.messages['in'] .. ' ';
				if (sepc ~= '.') then
					in_text = in_text:lower();									-- lowercase for cs2
				end
			end
			if EditorCount &lt;= 1 then
				post_text = ' (' .. cfg.messages['editor'] .. ')';				-- be consistent with no-author, no-date case
			else
				post_text = ' (' .. cfg.messages['editors'] .. ')';
			end
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Contributors) then									-- book cite and we're citing the intro, preface, etc.
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if utilities.is_set (Editors) and utilities.is_set (Date) then		-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not utilities.is_set (Date)) then								-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif utilities.is_set (Editors) then
		if utilities.is_set (Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. cfg.presentation['sep_name'] .. cfg.messages['editor'];
			else
				Editors = Editors .. cfg.presentation['sep_name'] .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if utilities.is_set (PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc ); 								-- Deals with italics, spaces, etc.
		text = text:sub(1, -sepc:len() - 1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite&gt; element
	local options_t = {};
	options_t.class = cite_class_attribute_make (config.CitationClass, Mode);

	local Ref = is_valid_parameter_value (A['Ref'], A:ORIGIN('Ref'), cfg.keywords_lists['ref'], nil, true);	-- nil when |ref=harv; A['Ref'] else

	if 'none' ~= cfg.keywords_xlate[(Ref and Ref:lower()) or ''] then
		local namelist_t = {};													-- holds selected contributor, author, editor name list
		local year = first_set ({Year, anchor_year}, 2);						-- Year first for legacy citations and for YMD dates that require disambiguation

		if #c &gt; 0 then															-- if there is a contributor list
			namelist_t = c;														-- select it
		elseif #a &gt; 0 then														-- or an author list
			namelist_t = a;
		elseif #e &gt; 0 then														-- or an editor list
			namelist_t = e;
		end
		local citeref_id;
		if #namelist_t &gt; 0 then													-- if there are names in namelist_t
			citeref_id = make_citeref_id (namelist_t, year);					-- go make the CITEREF anchor
			if mw.uri.anchorEncode (citeref_id) == ((Ref and mw.uri.anchorEncode (Ref)) or '') then	-- Ref may already be encoded (by {{sfnref}}) so citeref_id must be encoded before comparison
				utilities.set_message ('maint_ref_duplicates_default');
			end
		else
			citeref_id = '';													-- unset
		end
		options_t.id = Ref or citeref_id;
	end

	if string.len (text:gsub('%b&lt;&gt;', '')) &lt;= 2 then								-- remove html and html-like tags; then get length of what remains; 
		z.error_cats_t = {};													-- blank the categories list
		z.error_msgs_t = {};													-- blank the error messages list
		OCinSoutput = nil;														-- blank the metadata string
		text = '';																-- blank the the citation
		utilities.set_message ('err_empty_citation');							-- set empty citation message and category
	end
	
	local render_t = {};														-- here we collect the final bits for concatenation into the rendered citation

	if utilities.is_set (options_t.id) then										-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render_t, utilities.substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options_t.id), mw.text.nowiki(options_t.class), text}));	-- when |ref= is set or when there is a namelist
	else
		table.insert (render_t, utilities.substitute (cfg.presentation['cite'], {mw.text.nowiki(options_t.class), text}));	-- when |ref=none or when namelist_t empty and |ref= is missing or is empty
	end		

	if OCinSoutput then															-- blanked when citation is 'empty' so don't bother to add boilerplate metadata span
		table.insert (render_t, utilities.substitute (cfg.presentation['ocins'], OCinSoutput));	-- format and append metadata to the citation
	end

	local template_name = ('citation' == config.CitationClass) and 'citation' or 'cite ' .. (cfg.citation_class_map_t[config.CitationClass] or config.CitationClass);
	local template_link = '[[Template:' .. template_name .. '|' .. template_name .. ']]';
	local msg_prefix = '&lt;code class=&quot;cs1-code&quot;&gt;{{' .. template_link .. '}}&lt;/code&gt;: ';

	if 0 ~= #z.error_msgs_t then
		mw.addWarning (utilities.substitute (cfg.messages.warning_msg_e, template_link));

		table.insert (render_t, ' ');											-- insert a space between citation and its error messages
		table.sort (z.error_msgs_t);											-- sort the error messages list; sorting includes wrapping &lt;span&gt; and &lt;code&gt; tags; hidden-error sorts ahead of visible-error

		local hidden = true;													-- presume that the only error messages emited by this template are hidden
		for _, v in ipairs (z.error_msgs_t) do									-- spin through the list of error messages
			if v:find ('cs1-visible-error', 1, true) then						-- look for the visible error class name
				hidden = false;													-- found one; so don't hide the error message prefix
				break;															-- and done because no need to look further
			end
		end

		z.error_msgs_t[1] = table.concat ({utilities.error_comment (msg_prefix, hidden), z.error_msgs_t[1]});	-- add error message prefix to first error message to prevent extraneous punctuation
		table.insert (render_t, table.concat (z.error_msgs_t, '; '));			-- make a big string of error messages and add it to the rendering
	end

	if 0 ~= #z.maint_cats_t then
		mw.addWarning (utilities.substitute (cfg.messages.warning_msg_m, template_link));

		table.sort (z.maint_cats_t);											-- sort the maintenance messages list

		local maint_msgs_t = {};												-- here we collect all of the maint messages

		if 0 == #z.error_msgs_t then											-- if no error messages
			table.insert (maint_msgs_t, msg_prefix);							-- insert message prefix in maint message livery
		end
		
		for _, v in ipairs( z.maint_cats_t ) do									-- append maintenance categories
			table.insert (maint_msgs_t, 										-- assemble new maint message and add it to the maint_msgs_t table
				table.concat ({v, ' (', utilities.substitute (cfg.messages[':cat wikilink'], v), ')'})
				);
		end
		table.insert (render_t, utilities.substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs_t, ' ')));	-- wrap the group of maint messages with proper presentation and save
	end

	if not no_tracking_cats then
		for _, v in ipairs (z.error_cats_t) do									-- append error categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
		end
		for _, v in ipairs (z.maint_cats_t) do									-- append maintenance categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
		end
		for _, v in ipairs (z.prop_cats_t) do									-- append properties categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
		end
	end

	return table.concat (render_t);												-- make a big string and done
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class, empty)
	local name = tostring (name);
	local enum_name;															-- parameter name with enumerator (if any) replaced with '#'
	local state;
	local function state_test (state, name)										-- local function to do testing of state values
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			if empty then return nil; end										-- empty deprecated parameters are treated as unknowns
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
		if 'tracked' == state then
			local base_name = name:gsub ('%d', '');								-- strip enumerators from parameter names that have them to get the base name
			utilities.add_prop_cat ('tracked-param', {base_name}, base_name);	-- add a properties category; &lt;base_name&gt; modifies &lt;key&gt;
			return true;
		end
		return nil;
	end		

	if name:find ('#') then														-- # is a cs1|2 reserved character so parameters with # not permitted
		return nil;
	end
																				-- replace wnumerator digit(s) with # (|last25= becomes |last#=) (mw.ustring because non-Western 'local' digits)
	enum_name = mw.ustring.gsub (name, '%d+$', '#');							-- where enumerator is last charaters in parameter name (these to protect |s2cid=)
	enum_name = mw.ustring.gsub (enum_name, '%d+([%-l])', '#%1');				-- where enumerator is in the middle of the parameter name; |author#link= is the oddity

	if 'document' == cite_class then											-- special case for {{cite document}}
		state = whitelist.document_parameters_t[enum_name];						-- this list holds enumerated and nonenumerated parameters
		if true == state_test (state, name) then return true; end
		
		return false;
	end

	if utilities.in_array (cite_class, whitelist.preprint_template_list_t) then	-- limited parameter sets allowed for these templates
		state = whitelist.limited_parameters_t[enum_name];						-- this list holds enumerated and nonenumerated parameters
		if true == state_test (state, name) then return true; end

		state = whitelist.preprint_arguments_t[cite_class][name];				-- look in the parameter-list for the template identified by cite_class
		if true == state_test (state, name) then return true; end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates

	if utilities.in_array (cite_class, whitelist.unique_param_template_list_t) then 	-- template-specific parameters for templates that accept parameters from the basic argument list
		state = whitelist.unique_arguments_t[cite_class][name];					-- look in the template-specific parameter-lists for the template identified by cite_class
		if true == state_test (state, name) then return true; end
	end																			-- if here, fall into general validation

	state = whitelist.common_parameters_t[enum_name];							-- all other templates; all normal parameters allowed; this list holds enumerated and nonenumerated parameters
	if true == state_test (state, name) then return true; end

	return false;																-- not supported because not found or name is set to nil
end


--[=[-------------------------&lt; I N T E R _ W I K I _ C H E C K &gt;----------------------------------------------

check &lt;value&gt; for inter-language interwiki-link markup.  &lt;prefix&gt; must be a MediaWiki-recognized language
code.  when these values have the form (without leading colon):
	[[&lt;prefix&gt;:link|label]] return label as plain-text
	[[&lt;prefix&gt;:link]] return &lt;prefix&gt;:link as plain-text

return value as is else

]=]

local function inter_wiki_check (parameter, value)
	local prefix = value:match ('%[%[(%a+):');									-- get an interwiki prefix if one exists
	local _;
	
	if prefix and cfg.inter_wiki_map[prefix:lower()] then						-- if prefix is in the map, needs preceding colon so
		utilities.set_message ('err_bad_paramlink', parameter);					-- emit an error message
		_, value, _ = utilities.is_wikilink (value);							-- extract label portion from wikilink
	end
	return value;
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe.  There are two tests made:
	{{cite ... |title=Title access-date=2016-03-17}}	-- the first parameter has a value and whitespace separates that value from the missing pipe parameter name
	{{cite ... |title=access-date=2016-03-17}}			-- the first parameter has no value (whitespace after the first = is trimmed by MediaWiki)
cs1|2 shares some parameter names with XML/HTML attributes: class=, title=, etc.  To prevent false positives XML/HTML
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (parameter, value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove XML/HTML tags because attributes: class=, title=, etc.

	capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then										-- if the capture is a valid parameter name
		utilities.set_message ('err_missing_pipe', parameter);
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ P U N C T &gt;--------------------------------------

look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_punc (param, value)
	if 'number' == type (param) then
		return;
	end
	
	param = param:gsub ('%d+', '#');											-- enumerated name-list mask params allow terminal punct; normalize 
	if cfg.punct_skip[param] then
		return;																	-- parameter name found in the skip table so done
	end
	
	if value:match ('[,;:]$') then
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
	if value:match ('^=') then													-- sometimes an extraneous '=' character appears ...
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ U R L &gt;------------------------------------------

look for extraneous url parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_url (url_param_t)
	local url_error_t = {};
	
	check_for_url (url_param_t, url_error_t);									-- extraneous url check
	if 0 ~= #url_error_t then													-- non-zero when there are errors
		table.sort (url_error_t);
		utilities.set_message ('err_param_has_ext_link', {utilities.make_sep_list (#url_error_t, url_error_t)});	-- add this error message
	end
end


--[[--------------------------&lt; C I T A T I O N &gt;--------------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

local function citation(frame)
	Frame = frame;																-- save a copy in case we need to display an error message in preview mode

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do											-- get parameters from the {{#invoke}} frame
		config[k] = v;
	--	args[k] = v;															-- crude debug support that allows us to render a citation from module {{#invoke:}}; skips parameter validation; TODO: keep?
	end	
																				-- i18n: set the name that your wiki uses to identify sandbox subpages from sandbox template invoke (or can be set here)
	local sandbox = ((config.SandboxPath and '' ~= config.SandboxPath) and config.SandboxPath) or '/sandbox';	-- sandbox path from {{#invoke:Citation/CS1/sandbox|citation|SandboxPath=/...}}
	is_sandbox = nil ~= string.find (frame:getTitle(), sandbox, 1, true);		-- is this invoke the sandbox module?
	sandbox = is_sandbox and sandbox or '';										-- use i18n sandbox to load sandbox modules when this module is the sandox; live modules else

	local pframe = frame:getParent()
	local styles;
	
	cfg = mw.loadData ('Module:Citation/CS1/Configuration' .. sandbox);			-- load sandbox versions of support modules when {{#invoke:Citation/CS1/sandbox|...}}; live modules else
	whitelist = mw.loadData ('Module:Citation/CS1/Whitelist' .. sandbox);
	utilities = require ('Module:Citation/CS1/Utilities' .. sandbox);
	validation = require ('Module:Citation/CS1/Date_validation' .. sandbox);
	identifiers = require ('Module:Citation/CS1/Identifiers' .. sandbox);
	metadata = require ('Module:Citation/CS1/COinS' .. sandbox);
	styles = 'Module:Citation/CS1' .. sandbox .. '/styles.css';

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the selected cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	is_preview_mode = not utilities.is_set (frame:preprocess ('{{REVISIONID}}'));

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text;															-- used as a flag

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	local empty_unknowns = {};													-- sequence table to hold empty unknown params for error message listing
	for k, v in pairs( pframe.args ) do											-- get parameters from the parent (template) frame
		v = mw.ustring.gsub (v, '^%s*(.-)%s*$', '%1');							-- trim leading/trailing whitespace; when v is only whitespace, becomes empty string
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				if type (k) ~= 'string' then									-- exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text = utilities.set_message ('err_text_ignored', {v});
					end
				elseif validate (k:lower(), config.CitationClass) then 
					error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, k:lower()});	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						suggestions = mw.loadData ('Module:Citation/CS1/Suggestions' .. sandbox);	--load sandbox version of suggestion module when {{#invoke:Citation/CS1/sandbox|...}}; live module else
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no capture in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = utilities.substitute (param, capture);		-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, param});	-- set the suggestion error message
							else
								error_text = utilities.set_message ('err_parameter_ignored', {k});	-- suggested param not supported by this template
								v = '';											-- unset
							end
						end
					end
					if not utilities.is_set (error_text) then					-- couldn't match with a pattern, is there an explicit suggestion?						
						if (suggestions.suggestions[ k:lower() ] ~= nil) and validate (suggestions.suggestions[ k:lower() ], config.CitationClass) then
							utilities.set_message ('err_parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]});
						else
							utilities.set_message ('err_parameter_ignored', {k});
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
			end

			args[k] = v;														-- save this parameter and its value

		elseif not utilities.is_set (v) then									-- for empty parameters
			if not validate (k, config.CitationClass, true) then				-- is this empty parameter a valid parameter
				k = ('' == k) and '(empty string)' or k;						-- when k is empty string (or was space(s) trimmed to empty string), replace with descriptive text
				table.insert (empty_unknowns, utilities.wrap_style ('parameter', k));	-- format for error message and add to the list
			end
																				-- crude debug support that allows us to render a citation from module {{#invoke:}} TODO: keep?
	--	elseif args[k] ~= nil or (k == 'postscript') then						-- when args[k] has a value from {{#invoke}} frame (we don't normally do that)
	--		args[k] = v;														-- overwrite args[k] with empty string from pframe.args[k] (template frame); v is empty string here
		end																		-- not sure about the postscript bit; that gets handled in parameter validation; historical artifact?
	end	

	if 0 ~= #empty_unknowns then												-- create empty unknown error message
		utilities.set_message ('err_param_unknown_empty', {
			1 == #empty_unknowns and '' or 's',
			utilities.make_sep_list (#empty_unknowns, empty_unknowns)
			});
	end

	local url_param_t = {};

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);											-- look for invisible characters
		end
		has_extraneous_punc (k, v);												-- look for extraneous terminal punctuation in parameter values
		missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?
		args[k] = inter_wiki_check (k, v);										-- when language interwiki-linked parameter missing leading colon replace with wiki-link label

		if 'string' == type (k) and not cfg.url_skip[k] then					-- when parameter k is not positional and not in url skip table
			url_param_t[k] = v;													-- make a parameter/value list for extraneous url check
		end
	end

	has_extraneous_url (url_param_t);											-- look for url in parameter values where a url does not belong

	return table.concat ({
		frame:extensionTag ('templatestyles', '', {src=styles}),
		citation0( config, args)
	});
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {citation = citation};</text>
      <sha1>tdu8ggjbxwo5jmdozqbp8w94qat411d</sha1>
    </revision>
    <revision>
      <id>4752</id>
      <parentid>4751</parentid>
      <timestamp>2023-08-30T19:56:08Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>fix {{cs1 config}} support for |display-translators=;</comment>
      <origin>4752</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="223535" sha1="0g1meawhunmjmr91m6m0k5lv7p6or5e" xml:space="preserve">require ('strict');

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------

each of these counts against the Lua upvalue limit

]]

local validation;																-- functions in Module:Citation/CS1/Date_validation

local utilities;																-- functions in Module:Citation/CS1/Utilities
local z = {};																	-- table of tables in Module:Citation/CS1/Utilities

local identifiers;																-- functions and tables in Module:Citation/CS1/Identifiers
local metadata;																	-- functions in Module:Citation/CS1/COinS
local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;---------------

declare variables here that have page-wide scope that are not brought in from
other modules; that are created here and used here

]]

local added_deprecated_cat;														-- Boolean flag so that the category is added only once
local added_vanc_errs;															-- Boolean flag so we only emit one Vancouver error / category
local added_generic_name_errs;													-- Boolean flag so we only emit one generic name error / category and stop testing names once an error is encountered
local Frame;																	-- holds the module's frame table
local is_preview_mode;															-- true when article is in preview mode; false when using 'Preview page with this template' (previewing the module)
local is_sandbox;																-- true when using sandbox modules to render citation


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if utilities.is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a Boolean declared in page scope variables above

]]

local function add_vanc_error (source, position)
	if added_vanc_errs then return end
		
	added_vanc_errs = true;														-- note that we've added this category
	utilities.set_message ('err_vancouver', {source, position});
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a URI scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of TLDs: https://www.iana.org/domains/root/db

RFC 952 (modified by RFC 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the TLD.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a URL with a scheme) will be stripped
here.  Perhaps not necessary but retained in case it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ASCII characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the TLD) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and TLD or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%w]') then											-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at Wikisource
		return false;
	end

	local patterns = {															-- patterns that look like URLs
		'%f[%w][%w][%w%-]+[%w]%.%a%a+$',										-- three or more character hostname.hostname or hostname.tld
		'%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$',									-- internationalized domain name with ACE prefix
		'%f[%a][qxz]%.com$',													-- assigned one character .com hostname (x.com times out 2015-12-10)
		'%f[%a][iq]%.net$',														-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		'%f[%w][%w]%.%a%a$',													-- one character hostname and ccTLD (2 chars)
		'%f[%w][%w][%w]%.%a%a+$',												-- two character hostname and TLD
		'^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?',								-- IPv4 address
		}

	for _, pattern in ipairs (patterns) do										-- loop through the patterns list
		if domain:match (pattern) then
			return true;														-- if a match then we think that this thing that purports to be a URL is a URL
		end
	end

	for _, d in ipairs (cfg.single_letter_2nd_lvl_domains_t) do					-- look for single letter second level domain names for these top level domains
		if domain:match ('%f[%w][%w]%.' .. d) then
			return true
		end
	end
	return false;																-- no matches, we don't know what this thing is
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a URL appear to be a valid URL; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if utilities.is_set (scheme) then											-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when URL is protocol-relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a URL into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following TLD) (if any) and any path(/), query(?) or fragment(#).

If protocol-relative URL, return nil scheme and domain else return nil for both scheme and domain.

When not protocol-relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Any URL that does not have news: scheme must have authority indicator (//).  TODO: are there other common schemes
like news: that don't use authority indicator?

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol-relative URL
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		if utilities.is_set (authority) then
			authority = authority:gsub ('//', '', 1);							-- replace place 1 pair of '/' with nothing;
			if utilities.is_set(authority) then									-- if anything left (1 or 3+ '/' where authority should be) then
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		else
			if not scheme:match ('^news:') then									-- except for news:..., MediaWiki won't link URLs that do not have authority indicator; TODO: a better way to do this test?
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link=, etc. for properly formatted content: no wikilinks, no URLs

Link parameters are to hold the title of a Wikipedia article, so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki URLs and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid URL (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid URL (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from URL; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid URL
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wiki-linked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

check &lt;link&gt; for inter-language interwiki-link prefix.  prefix must be a MediaWiki-recognized language
code and must begin with a colon.

]]

local function link_title_ok (link, lorig, title, torig)
	local orig;
	if utilities.is_set (link) then 											-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		elseif link:match ('^%a+:') then										-- if the link is what looks like an interwiki
			local prefix = link:match ('^(%a+):'):lower();						-- get the interwiki prefix

			if cfg.inter_wiki_map[prefix] then									-- if prefix is in the map, must have preceding colon
				orig = lorig;													-- flag as error
			end
		end
	end

	if utilities.is_set (orig) then
		link = '';																-- unset
		utilities.set_message ('err_bad_paramlink', orig);						-- URL or wikilink in |title= with |title-link=;
	end
	
	return link;																-- link if ok, empty string else
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the URL into scheme and domain
portions, or for protocol-relative (//example.com) URLs, just the domain.  Use is_url() to validate the two
portions of the URL.  If both are valid, or for protocol-relative if domain is valid, return true, else false.

Because it is different from a standard URL, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper URL
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from URL;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a URL.  The test will also find external wikilinks
that use protocol-relative URLs. Also finds bare URLs.

The frontier pattern prevents a match on interwiki-links which are similar to scheme:path URLs.  The tests that
find bracketed URLs are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext. wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol-relative ext. wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare URL with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol-relative bare URL: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a URL
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list, error_list)
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a URL add an error message
			table.insert (error_list, utilities.wrap_style ('parameter', k));
		end
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		utilities.set_message ('err_wikilink_in_url', {});
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link (URL, label, source, access)
	local err_msg = '';
	local domain;
	local path;
	local base_url;

	if not utilities.is_set (label) then
		label = URL;
		if utilities.is_set (source) then
			utilities.set_message ('err_bare_url_missing_title', {utilities.wrap_style ('parameter', source)});
		else
			error (cfg.messages[&quot;bare_url_no_origin&quot;]);							-- programmer error; valid parameter name does not have matching meta-parameter
		end			
	end
	if not check_url (URL) then
		utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)});
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the URL into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['['] = '%5b', [']'] = '%5d'});			-- replace '[' and ']' with their percent-encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat ({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wiki-markup URL

	if utilities.is_set (access) then											-- access level (subscription, registration, limited)
		base_url = utilities.substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end

	return base_url;
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a Boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		utilities.set_message ('err_deprecated_params', {name});				-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wiki-markup) are not kerned.

Replaces Unicode quote marks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc.; not for book titles.

]=]

local function kern_quotes (str)
	local cap = '';
	local wl_type, label, link;

	wl_type, label, link = utilities.is_wikilink (str);							-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-left'], str);
			str = utilities.substitute (cfg.presentation['kern-right'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = utilities.substitute (cfg.presentation['kern-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label = mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label = mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap = mw.ustring.match (label, &quot;^([\&quot;\'][^\'].+)&quot;);						-- match leading double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-left'], cap);
		end
	
		cap = mw.ustring.match (label, &quot;^(.+[^\'][\&quot;\'])$&quot;)						-- match trailing double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-right'], cap);
		end
		
		if 2 == wl_type then
			str = utilities.make_wikilink (link, label);						-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin-based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate RTL languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO 639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO 639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title=, |script-chapter=, |script-&lt;periodical&gt;=

]]

local function format_script_value (script_value, script_param)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%l?%s*:') then									-- if first 3 or 4 non-space characters are script language prefix
		lang = script_value:match('^(%l%l%l?)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not utilities.is_set (lang) then
			utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['missing title part']});		-- prefix without 'title'; add error message
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_tag_remap[lang] or mw.language.fetchLanguageName( lang, cfg.this_wiki_code );	-- get language name so that we can use it to categorize
		if utilities.is_set (name) then											-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l+%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if utilities.in_array (lang, cfg.script_lang_codes) then
				utilities.add_prop_cat ('script', {name, lang})
			else
				utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['unknown language code']});	-- unknown script-language; add error message
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['invalid language code']});		-- invalid language code; add error message
			lang = '';															-- invalid so set lang to empty string
		end
	else
		utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['missing prefix']});				-- no language code prefix; add error message
	end
	script_value = utilities.substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is RTL

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script
value has been wrapped in &lt;bdi&gt; tags.

]]

local function script_concatenate (title, script, script_param)
	if utilities.is_set (script) then
		script = format_script_value (script, script_param);					-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; returns empty string on error
		if utilities.is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not utilities.is_set ( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return utilities.substitute ( msg, str );								-- including template text
	else
		return utilities.substitute ( cfg.messages[key], str );
	end		
end


--[[----------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;-------------------

Makes a Wikisource URL from Wikisource interwiki-link.  Returns the URL and appropriate
label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;
	local wikisource_prefix = table.concat ({'https://', cfg.this_wiki_code, '.wikisource.org/wiki/'});

	wl_type, D, L = utilities.is_wikilink (str);								-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 1 == wl_type then													-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end

	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable URL
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent-encoding of fragment marker
	end

	return ws_url, ws_label, L or D;											-- return proper URL or nil and a label or nil
end


--[[----------------&lt; F O R M A T _ P E R I O D I C A L &gt;-----------------------

Format the three periodical parameters: |script-&lt;periodical&gt;=, |&lt;periodical&gt;=,
and |trans-&lt;periodical&gt;= into a single Periodical meta-parameter.

]]

local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)

	if not utilities.is_set (periodical) then
		periodical = '';														-- to be safe for concatenation
	else
		periodical = utilities.wrap_style ('italic-title', periodical);			-- style 
	end

	periodical = script_concatenate (periodical, script_periodical, script_periodical_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (trans_periodical) then
		trans_periodical = utilities.wrap_style ('trans-italic-title', trans_periodical);
		if utilities.is_set (periodical) then
			periodical = periodical .. ' ' .. trans_periodical;
		else																	-- here when trans-periodical without periodical or script-periodical
			periodical = trans_periodical;
			utilities.set_message ('err_trans_missing_title', {'periodical'});
		end
	end

	return periodical;
end


--[[------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;---------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=,
and |chapter-url= into a single chapter meta- parameter (chapter_url_source used
for error messages).

]]

local function format_chapter_title (script_chapter, script_chapter_source, chapter, chapter_source, trans_chapter, trans_chapter_source, chapter_url, chapter_url_source, no_quotes, access)
	local ws_url, ws_label, L = wikisource_url_make (chapter);					-- make a wikisource URL and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', ' ');									-- replace underscore separators with space characters
		chapter = ws_label;
	end

	if not utilities.is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from module provided quote marks
			chapter = utilities.wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, script_chapter, script_chapter_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (chapter_url) then
		chapter = external_link (chapter_url, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');	-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if utilities.is_set (trans_chapter) then
		trans_chapter = utilities.wrap_style ('trans-quoted-title', trans_chapter);
		if utilities.is_set (chapter) then
			chapter = chapter .. ' ' .. trans_chapter;
		else																	-- here when trans_chapter without chapter or script-chapter
			chapter = trans_chapter;
			chapter_source = trans_chapter_source:match ('trans%-?(.+)');		-- when no chapter, get matching name from trans-&lt;param&gt;
			utilities.set_message ('err_trans_missing_title', {chapter_source});
		end
	end

	return chapter;
end


--[[----------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;-------------------

This function searches a parameter's value for non-printable or invisible characters.
The search stops at the first match.

This function will detect the visible replacement character when it is part of the Wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers
(gallery, math, pre, ref) and identifies them with a slightly different error message.
See also coins_cleanup().

Output of this function is an error message that identifies the character or the
Unicode group, or the stripmarker that was detected along with its position (or,
for multi-byte characters, the position of its first byte) in the parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local stripmarker;															-- boolean set true when a stripmarker is found

	capture = string.match (v, '[%w%p ]*');										-- test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no Unicode characters
		return;
	end

	for _, invisible_char in ipairs (cfg.invisible_chars) do
		local char_name = invisible_char[1];									-- the character or group name
		local pattern = invisible_char[2];										-- the pattern used to find it
		position, _, capture = mw.ustring.find (v, pattern);					-- see if the parameter value contains characters that match the pattern
		
		if position and (cfg.invisible_defs.zwj == capture) then				-- if we found a zero-width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- it's ok if one of the Indic scripts
				position = nil;													-- unset position
			elseif cfg.emoji_t[mw.ustring.codepoint (v, position+1)] then			-- is zwj followed by a character listed in emoji{}?
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and utilities.in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and cfg.invisible_defs.del == capture then	-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture and not (cfg.invisible_defs.del == capture or cfg.invisible_defs.zwj == capture) then
					err_msg = capture .. ' ' .. char_name;
				else
					err_msg = char_name .. ' ' .. 'character';
				end

				utilities.set_message ('err_invisible_char', {err_msg, utilities.wrap_style ('parameter', param), position});	-- add error message
				return;															-- and done with this parameter
			end
		end
	end
end


--[[-------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------

Argument wrapper.  This function provides support for argument mapping defined
in the configuration file so that multiple names can be transparently aliased to
single internal variable.

]]

local function argument_wrapper ( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function ( self, k )
			local dummy = self[k];												-- force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = utilities.select_one ( args, list, 'err_redundant_parameters' );
				if origin[k] == nil then
					origin[k] = '';												-- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] .. ': ' .. k);
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;-------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.
When date is DD MMMM YYYY or is MMMM DD, YYYY then wrap in nowrap span:
&lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap = '';
	local cap2 = '';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = utilities.substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = utilities.substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;---------------------

This function sets default title types (equivalent to the citation including
|type=&lt;default value&gt;) for those templates that have defaults. Also handles the
special case where it is desirable to omit the title type from the rendered citation
(|type=none).

]]

local function set_titletype (cite_class, title_type)
	if utilities.is_set (title_type) then
		if 'none' == cfg.keywords_xlate[title_type] then
			title_type = '';													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; S A F E _ J O I N &gt;-----------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'duplicate character'
		if 1 == #duplicate_char then											-- for single byte ASCII characters use the string library functions
			f.gsub = string.gsub
			f.match = string.match
			f.sub = string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub = mw.ustring.gsub
			f.match = mw.ustring.match
			f.sub = mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1, 1) == '&lt;' then										-- special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove HTML markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1, 1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc.?
				trim = false;
				end_chr = f.sub(str, -1, -1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr .. &quot;)&quot;				-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1, -2);									-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;''&quot; then		-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5, -1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;]]&quot; then		-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3, -1) == duplicate_char .. '&quot;]' then	-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2, -1) == duplicate_char .. &quot;]&quot; then	-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2, -1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1, -3);								-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains HTML markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows HTML markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value; 												-- add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;-----------------------------

returns true if suffix is properly formed Jr, Sr, or ordinal in the range 1–9.
Puncutation not allowed.

]]

local function is_suffix (suffix)
	if utilities.in_array (suffix, {'Jr', 'Sr', 'Jnr', 'Snr', '1st', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;-------------------

For Vancouver style, author/editor names are supposed to be rendered in Latin
(read ASCII) characters.  When a name uses characters that contain diacritical
marks, those characters are to be converted to the corresponding Latin
character. When a name is written using a non-Latin alphabet or logogram, that
name is to be transliterated into Latin characters. The module doesn't do this
so editors may/must.

This test allows |first= and |last= names to contain any of the letters defined
in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes.
	(http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;)
	or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written outside of the code editor and pasted here because the code editor
gets confused between character insertion point and cursor position. The test has
been rewritten to use decimal character escape sequence for the individual bytes
of the Unicode characters so that it is not necessary to use an external editor
to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first, suffix, position)
	if not suffix then
		if first:find ('[,%s]') then											-- when there is a space or comma, might be first name/initials + generational suffix
			first = first:match ('(.-)[,%s]+');									-- get name/initials
			suffix = first:match ('[,%s]+(.+)$');								-- get generational suffix
		end
	end
	if utilities.is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error (cfg.err_msg_supl.suffix, position);
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error (cfg.err_msg_supl['non-Latin char'], position);
			return false;														-- not a string of Latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-style=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period.
See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc.) to be rendered
as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format
because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the
Unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first, position)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just initials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error (cfg.err_msg_supl.suffix, position);			-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word

	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i], 1, 1));			-- insert the initial at end of initials table
		end
		i = i + 1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; I N T E R W I K I _ P R E F I X E N _ G E T &gt;----------------------------------

extract interwiki prefixen from &lt;value&gt;.  Returns two one or two values:
	false – no prefixen
	nil – prefix exists but not recognized
	project prefix, language prefix – when value has either of:
		:&lt;project&gt;:&lt;language&gt;:&lt;article&gt;
		:&lt;language&gt;:&lt;project&gt;:&lt;article&gt;
	project prefix, nil – when &lt;value&gt; has only a known single-letter prefix
	nil, language prefix – when &lt;value&gt; has only a known language prefix

accepts single-letter project prefixen: 'd' (wikidata), 's' (wikisource), and 'w' (wikipedia) prefixes; at this
writing, the other single-letter prefixen (b (wikibook), c (commons), m (meta), n (wikinews), q (wikiquote), and
v (wikiversity)) are not supported.

]]

local function interwiki_prefixen_get (value, is_link)
	if not value:find (':%l+:') then											-- if no prefix
		return false;															-- abandon; boolean here to distinguish from nil fail returns later
	end

	local prefix_patterns_linked_t = {											-- sequence of valid interwiki and inter project prefixen
		'^%[%[:([dsw]):(%l%l+):',												-- wikilinked; project and language prefixes
		'^%[%[:(%l%l+):([dsw]):',												-- wikilinked; language and project prefixes
		'^%[%[:([dsw]):',														-- wikilinked; project prefix
		'^%[%[:(%l%l+):',														-- wikilinked; language prefix
		}
		
	local prefix_patterns_unlinked_t = {										-- sequence of valid interwiki and inter project prefixen
		'^:([dsw]):(%l%l+):',													-- project and language prefixes
		'^:(%l%l+):([dsw]):',													-- language and project prefixes
		'^:([dsw]):',															-- project prefix
		'^:(%l%l+):',															-- language prefix
		}
	
	local cap1, cap2;
	for _, pattern in ipairs ((is_link and prefix_patterns_linked_t) or prefix_patterns_unlinked_t) do
		cap1, cap2 = value:match (pattern);
		if cap1 then
			break;																-- found a match so stop looking
		end
	end
	
	if cap1 and cap2 then														-- when both then :project:language: or :language:project: (both forms allowed)
		if 1 == #cap1 then														-- length == 1 then :project:language:
			if cfg.inter_wiki_map[cap2] then									-- is language prefix in the interwiki map?
				return cap1, cap2;												-- return interwiki project and interwiki language
			end
		else																	-- here when :language:project:
			if cfg.inter_wiki_map[cap1] then									-- is language prefix in the interwiki map?
				return cap2, cap1;												-- return interwiki project and interwiki language
			end
		end
		return nil;																-- unknown interwiki language
	elseif not (cap1 or cap2) then												-- both are nil?
		return nil;																-- we got something that looks like a project prefix but isn't; return fail
	elseif 1 == #cap1 then														-- here when one capture
		return cap1, nil;														-- length is 1 so return project, nil language
	else																		-- here when one capture and its length it more than 1
		if cfg.inter_wiki_map[cap1] then										-- is language prefix in the interwiki map?
			return nil, cap1;													-- return nil project, language
		end
	end
end


--[[--------------------------&lt; L I S T _ P E O P L E &gt;--------------------------

Formats a list of people (authors, contributors, editors, interviewers, translators) 

names in the list will be linked when
	|&lt;name&gt;-link= has a value
	|&lt;name&gt;-mask- does NOT have a value; masked names are presumed to have been
		rendered previously so should have been linked there

when |&lt;name&gt;-mask=0, the associated name is not rendered

]]

local function list_people (control, people, etal)
	local sep;
	local namesep;
	local format = control.format;
	local maximum = control.maximum;
	local name_list = {};

	if 'vanc' == format then													-- Vancouver-like name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between names is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between names is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub (-1, -1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if utilities.is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end		-- returned 0 is for EditorCount; not used for other names
	
	for i, person in ipairs (people) do
		if utilities.is_set (person.last) then
			local mask = person.mask;
			local one;
			local sep_one = sep;

			if utilities.is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			end
			
			if mask then
				local n = tonumber (mask);										-- convert to a number if it can be converted; nil else
				if n then
					one = 0 ~= n and string.rep(&quot;&amp;mdash;&quot;, n) or nil;			-- make a string of (n &gt; 0) mdashes, nil else, to replace name
					person.link = nil;											-- don't create link to name if name is replaces with mdash string or has been set nil
				else
					one = mask;													-- replace name with mask text (must include name-list separator)
					sep_one = &quot; &quot;;												-- modify name-list separator
				end
			else
				one = person.last;												-- get surname
				local first = person.first										-- get given name
				if utilities.is_set (first) then
					if (&quot;vanc&quot; == format) then									-- if Vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first, nil, i) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials (first, i);				-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
			end
			if utilities.is_set (person.link) then
				one = utilities.make_wikilink (person.link, one);				-- link author/editor
			end

			if one then															-- if &lt;one&gt; has a value (name, mdash replacement, or mask text replacement)
				local proj, tag = interwiki_prefixen_get (one, true);			-- get the interwiki prefixen if present

				if 'w' == proj and ('Wikipedia' == mw.site.namespaces.Project['name']) then
					proj = nil;													-- for stuff like :w:de:&lt;article&gt;, :w is unnecessary TODO: maint cat?
				end
				if proj then
					proj = ({['d'] = 'Wikidata', ['s'] = 'Wikisource', ['w'] = 'Wikipedia'})[proj];	-- :w (wikipedia) for linking from a non-wikipedia project
					if proj then 
						one = one .. utilities.wrap_style ('interproj', proj);	-- add resized leading space, brackets, static text, language name
						tag = nil;												-- unset; don't do both project and language
					end
				end
				if tag == cfg.this_wiki_code then
					tag = nil;													-- stuff like :en:&lt;article&gt; at en.wiki is pointless TODO: maint cat?
				end
				if tag then
					local lang = cfg.lang_tag_remap[tag] or cfg.mw_languages_by_tag_t[tag];
					if lang then												-- error messaging done in extract_names() where we know parameter names
						one = one .. utilities.wrap_style ('interwiki', lang);	-- add resized leading space, brackets, static text, language name
					end
				end

				table.insert (name_list, one);									-- add it to the list of names
				table.insert (name_list, sep_one);								-- add the proper name-list separator
			end
		end
	end

	local count = #name_list / 2;												-- (number of names + number of separators) divided by 2
	if 0 &lt; count then 
		if 1 &lt; count and not etal then
			if 'amp' == format then
				name_list[#name_list-2] = &quot; &amp; &quot;;								-- replace last separator with ampersand text
			elseif 'and' == format then
				if 2 == count then
					name_list[#name_list-2] = cfg.presentation.sep_nl_and;		-- replace last separator with 'and' text
				else
					name_list[#name_list-2] = cfg.presentation.sep_nl_end;		-- replace last separator with '(sep) and' text
				end
			end
		end
		name_list[#name_list] = nil;											-- erase the last separator
	end

	local result = table.concat (name_list);									-- construct list
	if etal and utilities.is_set (result) then									-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. cfg.messages['et al'];						-- we've got a last-first list and etal so add et al.
	end
	
	return result, count;														-- return name-list string and count of number of names (count used for editor names only)
end


--[[--------------------&lt; M A K E _ C I T E R E F _ I D &gt;-----------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise
returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that
order.  year is Year or anchor_year.

]]

local function make_citeref_id (namelist, year)
	local names={};							-- a table for the one to four names and year
	for i,v in ipairs (namelist) do			-- loop through the list and take up to the first four last names
		names[i] = v.last
		if i == 4 then break end			-- if four then done
	end
	table.insert (names, year);				-- add the year at the end
	local id = table.concat(names);			-- concatenate names and year for CITEREF id
	if utilities.is_set (id) then			-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;				-- add the CITEREF portion
	else
		return '';							-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; C I T E _ C L A S S _A T T R I B U T E _M A K E &gt;------------------------------

construct &lt;cite&gt; tag class attribute for this citation.

&lt;cite_class&gt; – config.CitationClass from calling template
&lt;mode&gt; – value from |mode= parameter

]]

local function cite_class_attribute_make (cite_class, mode)
	local class_t = {};
	table.insert (class_t, 'citation');											-- required for blue highlight
	if 'citation' ~= cite_class then
		table.insert (class_t, cite_class);										-- identify this template for user css
		table.insert (class_t, utilities.is_set (mode) and mode or 'cs1');		-- identify the citation style for user css or javascript
	else
		table.insert (class_t, utilities.is_set (mode) and mode or 'cs2');		-- identify the citation style for user css or javascript
	end
	for _, prop_key in ipairs (z.prop_keys_t) do
		table.insert (class_t, prop_key);										-- identify various properties for user css or javascript
	end

	return table.concat (class_t, ' ');											-- make a big string and done
end


--[[---------------------&lt; N A M E _ H A S _ E T A L &gt;--------------------------

Evaluates the content of name parameters (author, editor, etc.) for variations on
the theme of et al.  If found, the et al. is removed, a flag is set to true and
the function returns the modified name and the flag.

This function never sets the flag to false but returns its previous state because
it may have been set by previous passes through this function or by the associated
|display-&lt;names&gt;=etal parameter

]]

local function name_has_etal (name, etal, nocat, param)

	if utilities.is_set (name) then												-- name can be nil in which case just return
		local patterns = cfg.et_al_patterns; 									-- get patterns from configuration
		
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns
			if name:match (pattern) then										-- if this 'et al' pattern is found in name
				name = name:gsub (pattern, '');									-- remove the offending text
				etal = true;													-- set flag (may have been set previously here or by |display-&lt;names&gt;=etal)
				if not nocat then												-- no categorization for |vauthors=
					utilities.set_message ('err_etal', {param});				-- and set an error if not added
				end
			end
		end
	end

	return name, etal;
end


--[[---------------------&lt; N A M E _ I S _ N U M E R I C &gt;----------------------

Add maint cat when name parameter value does not contain letters.  Does not catch
mixed alphanumeric names so |last=A. Green (1922-1987) does not get caught in the
current version of this test but |first=(1888) is caught.

returns nothing

]]

local function name_is_numeric (name, list_name)
	if utilities.is_set (name) then
		if mw.ustring.match (name, '^[%A]+$') then								-- when name does not contain any letters
			utilities.set_message ('maint_numeric_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
		end
	end
end


--[[-----------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;------------------

Evaluates the content of last/surname (authors etc.) parameters for multiple names.
Multiple names are indicated if there is more than one comma or any &quot;unescaped&quot;
semicolons. Escaped semicolons are ones used as part of selected HTML entities.
If the condition is met, the function adds the multiple name maintenance category.

Same test for first except that commas should not appear in given names (MOS:JR says
that the generational suffix does not take a separator character).  Titles, degrees,
postnominals, affiliations, all normally comma separated don't belong in a citation.

&lt;name&gt; – name parameter value
&lt;list_name&gt; – AuthorList, EditorList, etc
&lt;limit&gt; – number of allowed commas; 1 (default) for surnames; 0 for given names

returns nothing

]]

local function name_has_mult_names (name, list_name, limit)
	local _, commas, semicolons, nbsps;
	limit = limit and limit or 1;
	if utilities.is_set (name) then
		_, commas = name:gsub (',', '');										-- count the number of commas
		_, semicolons = name:gsub (';', '');									-- count the number of semicolons
		-- nbsps probably should be its own separate count rather than merged in
		-- some way with semicolons because Lua patterns do not support the
		-- grouping operator that regex does, which means there is no way to add
		-- more entities to escape except by adding more counts with the new
		-- entities
		_, nbsps = name:gsub ('&amp;nbsp;','');										-- count nbsps
		
		-- There is exactly 1 semicolon per &amp;nbsp; entity, so subtract nbsps
		-- from semicolons to 'escape' them. If additional entities are added,
		-- they also can be subtracted.
		if limit &lt; commas or 0 &lt; (semicolons - nbsps) then
			utilities.set_message ('maint_mult_names', cfg.special_case_translation [list_name]);	-- add a maint message
		end
	end
end


--[=[-------------------------&lt; I S _ G E N E R I C &gt;----------------------------------------------------------

Compares values assigned to various parameters according to the string provided as &lt;item&gt; in the function call.
&lt;item&gt; can have on of two values:
	'generic_names' – for name-holding parameters: |last=, |first=, |editor-last=, etc
	'generic_titles' – for |title=

There are two types of generic tests.  The 'accept' tests look for a pattern that should not be rejected by the
'reject' test.  For example,
	|author=[[John Smith (author)|Smith, John]]
would be rejected by the 'author' reject test.  But piped wikilinks with 'author' disambiguation should not be
rejected so the 'accept' test prevents that from happening.  Accept tests are always performed before reject
tests.

Each of the 'accept' and 'reject' sequence tables hold tables for en.wiki (['en']) and local.wiki (['local'])
that each can hold a test sequence table  The sequence table holds, at index [1], a test pattern, and, at index
[2], a boolean control value.  The control value tells string.find() or mw.ustring.find() to do plain-text search (true)
or a pattern search (false).  The intent of all this complexity is to make these searches as fast as possible so
that we don't run out of processing time on very large articles.

Returns
	true when a reject test finds the pattern or string
	false when an accept test finds the pattern or string
	nil else

]=]

local function is_generic (item, value, wiki)
	local test_val;
	local str_lower = {															-- use string.lower() for en.wiki (['en']) and use mw.ustring.lower() or local.wiki (['local'])
		['en'] = string.lower,
		['local'] = mw.ustring.lower,
		}
	local str_find = {															-- use string.find() for en.wiki (['en']) and use mw.ustring.find() or local.wiki (['local'])
		['en'] = string.find,
		['local'] = mw.ustring.find,
		}

	local function test (val, test_t, wiki)										-- local function to do the testing; &lt;wiki&gt; selects lower() and find() functions
		val = test_t[2] and str_lower[wiki](value) or val;						-- when &lt;test_t[2]&gt; set to 'true', plaintext search using lowercase value
		return str_find[wiki] (val, test_t[1], 1, test_t[2]);					-- return nil when not found or matched
	end
		
	local test_types_t = {'accept', 'reject'};									-- test accept patterns first, then reject patterns
	local wikis_t = {'en', 'local'};											-- do tests for each of these keys; en.wiki first, local.wiki second

	for _, test_type in ipairs (test_types_t) do								-- for each test type
		for _, generic_value in pairs (cfg.special_case_translation[item][test_type]) do	-- spin through the list of generic value fragments to accept or reject
			for _, wiki in ipairs (wikis_t) do
				if generic_value[wiki] then
					if test (value, generic_value[wiki], wiki) then				-- go do the test
						return ('reject' == test_type);							-- param value rejected, return true; false else
					end
				end
			end
		end
	end
end


--[[--------------------------&lt; N A M E _ I S _ G E N E R I C &gt;------------------------------------------------

calls is_generic() to determine if &lt;name&gt; is a 'generic name' listed in cfg.generic_names; &lt;name_alias&gt; is the
parameter name used in error messaging

]]

local function name_is_generic (name, name_alias)
	if not added_generic_name_errs  and is_generic ('generic_names', name) then
		utilities.set_message ('err_generic_name', name_alias);					-- set an error message
		added_generic_name_errs = true;
	end
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------

This function calls various name checking functions used to validate the content of the various name-holding parameters.

]]

local function name_checks (last, first, list_name, last_alias, first_alias)
	local accept_name;

	if utilities.is_set (last) then
		last, accept_name = utilities.has_accept_as_written (last);				-- remove accept-this-as-written markup when it wraps all of &lt;last&gt;

		if not accept_name then													-- &lt;last&gt; not wrapped in accept-as-written markup
			name_has_mult_names (last, list_name);								-- check for multiple names in the parameter
			name_is_numeric (last, list_name);									-- check for names that are composed of digits and punctuation
			name_is_generic (last, last_alias);									-- check for names found in the generic names list
		end
	end

	if utilities.is_set (first) then
		first, accept_name = utilities.has_accept_as_written (first);			-- remove accept-this-as-written markup when it wraps all of &lt;first&gt;

		if not accept_name then													-- &lt;first&gt; not wrapped in accept-as-written markup
			name_has_mult_names (first, list_name, 0);							-- check for multiple names in the parameter; 0 is number of allowed commas in a given name
			name_is_numeric (first, list_name);									-- check for names that are composed of digits and punctuation
			name_is_generic (first, first_alias);								-- check for names found in the generic names list
		end
		local wl_type, D = utilities.is_wikilink (first);
		if 0 ~= wl_type then
			first = D;
			utilities.set_message ('err_bad_paramlink', first_alias);
		end
	end

	return last, first;															-- done
end


--[[----------------------&lt; E X T R A C T _ N A M E S &gt;-------------------------

Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters
(or their aliases), and their matching link and mask parameters. Stops searching
when both |lastn= and |firstn= are not found in args after two sequential attempts:
found |last1=, |last2=, and |last3= but doesn't find |last4= and |last5= then the
search is done.

This function emits an error message when there is a |firstn= without a matching
|lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not
required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.'
is stripped from the parameter and a flag (etal) returned that will cause list_people()
to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps
'et al.' out of the template's metadata.  When this occurs, an error is emitted.

]]

local function extract_names(args, list_name)
	local names = {};															-- table of names
	local last;																	-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;																-- loop counter/indexer
	local n = 1;																-- output table indexer
	local count = 0;															-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal = false;															-- return value set to true when we find some form of et al. in an author parameter

	local last_alias, first_alias, link_alias;									-- selected parameter aliases used in error messaging
	while true do
		last, last_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'err_redundant_parameters', i );		-- search through args for name components beginning at 1
		first, first_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'err_redundant_parameters', i );
		link, link_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i );
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
	
		if last then															-- error check |lastn= alias for unknown interwiki link prefix; done here because this is where we have the parameter name
			local project, language = interwiki_prefixen_get (last, true);		-- true because we expect interwiki links in |lastn= to be wikilinked
			if nil == project and nil == language then							-- when both are nil
				utilities.set_message ('err_bad_paramlink', last_alias);		-- not known, emit an error message	-- TODO: err_bad_interwiki?
				last = utilities.remove_wiki_link (last);						-- remove wikilink markup; show display value only
			end
		end
		
		if link then															-- error check |linkn= alias for unknown interwiki link prefix
			local project, language = interwiki_prefixen_get (link, false);		-- false because wiki links in |author-linkn= is an error
			if nil == project and nil == language then							-- when both are nil
				utilities.set_message ('err_bad_paramlink', link_alias);		-- not known, emit an error message	-- TODO: err_bad_interwiki?
				link = nil;														-- unset so we don't link
				link_alias = nil;
			end
		end
		
		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.
		last, first = name_checks (last, first, list_name, last_alias, first_alias);						-- multiple names, extraneous annotation, etc. checks

		if first and not last then												-- if there is a firstn without a matching lastn
			local alias = first_alias:find ('given', 1, true) and 'given' or 'first';	-- get first or given form of the alias
			utilities.set_message ('err_first_missing_last', {
				first_alias,													-- param name of alias missing its mate
				first_alias:gsub (alias, {['first'] = 'last', ['given'] = 'surname'}),	-- make param name appropriate to the alias form
				});																-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			local result;
			link = link_title_ok (link, link_alias, last, last_alias);			-- check for improper wiki-markup

			if first then
				link = link_title_ok (link, link_alias, first, first_alias);	-- check for improper wiki-markup
			end

			names[n] = {last = last, first = first, link = link, mask = mask, corporate = false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				utilities.set_message ('err_missing_name', {list_name:match (&quot;(%w+)List&quot;):lower(), i - 1});	-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names and the etal flag
end


--[[--------------------------&lt; N A M E _ T A G _ G E T &gt;------------------------------------------------------

attempt to decode |language=&lt;lang_param&gt; and return language name and matching tag; nil else.

This function looks for:
	&lt;lang_param&gt; as a tag in cfg.lang_tag_remap{}
	&lt;lang_param&gt; as a name in cfg.lang_name_remap{}
	
	&lt;lang_param&gt; as a name in cfg.mw_languages_by_name_t
	&lt;lang_param&gt; as a tag in cfg.mw_languages_by_tag_t
when those fail, presume that &lt;lang_param&gt; is an IETF-like tag that MediaWiki does not recognize.  Strip all
script, region, variant, whatever subtags from &lt;lang_param&gt; to leave just a two or three character language tag
and look for the new &lt;lang_param&gt; in cfg.mw_languages_by_tag_t{}

on success, returns name (in properly capitalized form) and matching tag (in lowercase); on failure returns nil

]]

local function name_tag_get (lang_param)
	local lang_param_lc = mw.ustring.lower (lang_param);						-- use lowercase as an index into the various tables
	local name;
	local tag;

	name = cfg.lang_tag_remap[lang_param_lc];									-- assume &lt;lang_param_lc&gt; is a tag; attempt to get remapped language name 
	if name then																-- when &lt;name&gt;, &lt;lang_param&gt; is a tag for a remapped language name
		return name, lang_param_lc;												-- so return &lt;name&gt; from remap and &lt;lang_param_lc&gt;
	end

	tag = lang_param_lc:match ('^(%a%a%a?)%-.*');								-- still assuming that &lt;lang_param_lc&gt; is a tag; strip script, region, variant subtags
	name = cfg.lang_tag_remap[tag];											-- attempt to get remapped language name with language subtag only
	if name then																-- when &lt;name&gt;, &lt;tag&gt; is a tag for a remapped language name
		return name, tag;														-- so return &lt;name&gt; from remap and &lt;tag&gt;
	end

	if cfg.lang_name_remap[lang_param_lc] then									-- not a tag, assume &lt;lang_param_lc&gt; is a name; attempt to get remapped language tag 
		return cfg.lang_name_remap[lang_param_lc][1], cfg.lang_name_remap[lang_param_lc][2];	-- for this &lt;lang_param_lc&gt;, return a (possibly) new name and appropriate tag
	end

	tag = cfg.mw_languages_by_name_t[lang_param_lc];							-- assume that &lt;lang_param_lc&gt; is a language name; attempt to get its matching tag
	
	if tag then
		return cfg.mw_languages_by_tag_t[tag], tag;								-- &lt;lang_param_lc&gt; is a name so return the name from the table and &lt;tag&gt;
	end

	name = cfg.mw_languages_by_tag_t[lang_param_lc];							-- assume that &lt;lang_param_lc&gt; is a tag; attempt to get its matching language name
	
	if name then
		return name, lang_param_lc;												-- &lt;lang_param_lc&gt; is a tag so return it and &lt;name&gt;
	end
	
	tag = lang_param_lc:match ('^(%a%a%a?)%-.*');								-- is &lt;lang_param_lc&gt; an IETF-like tag that MediaWiki doesn't recognize? &lt;tag&gt; gets the language subtag; nil else

	if tag then
		name = cfg.mw_languages_by_tag_t[tag];									-- attempt to get a language name using the shortened &lt;tag&gt;
		if name then
			return name, tag;													-- &lt;lang_param_lc&gt; is an unrecognized IETF-like tag so return &lt;name&gt; and language subtag
		end
	end
end


--[[-------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code
is recognized by MediaWiki, use the returned name; if not, then use the value that
was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is
assigned to the category for that code: Category:Norwegian-language sources (no).
For valid three-character code languages, the page is assigned to the single category
for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does
not recognize three-character equivalents of two-character codes: code 'ar' is
recognized but code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th
where the language names or codes are separated from each other by commas with
optional space characters.

]]

local function language_parameter (lang)
	local tag;																	-- some form of IETF-like language tag; language subtag with optional region, sript, vatiant, etc subtags
	local lang_subtag;															-- ve populates |language= with mostly unecessary region subtags the MediaWiki does not recognize; this is the base language subtag
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_t = {};															-- table made from the value assigned to |language=

	local this_wiki_name = mw.language.fetchLanguageName (cfg.this_wiki_code, cfg.this_wiki_code);	-- get this wiki's language name

	names_t = mw.text.split (lang, '%s*,%s*');									-- names should be a comma separated list

	for _, lang in ipairs (names_t) do											-- reuse lang here because we don't yet know if lang is a language name or a language tag
		name, tag = name_tag_get (lang);										-- attempt to get name/tag pair for &lt;lang&gt;; &lt;name&gt; has proper capitalization; &lt;tag&gt; is lowercase

		if utilities.is_set (tag) then
			lang_subtag = tag:gsub ('^(%a%a%a?)%-.*', '%1');					-- for categorization, strip any IETF-like tags from language tag

			if cfg.this_wiki_code ~= lang_subtag then							-- when the language is not the same as this wiki's language
				if 2 == lang_subtag:len() then									-- and is a two-character tag
					utilities.add_prop_cat ('foreign-lang-source', {name, tag}, lang_subtag);		-- categorize it; tag appended to allow for multiple language categorization
				else															-- or is a recognized language (but has a three-character tag)
					utilities.add_prop_cat ('foreign-lang-source-2', {lang_subtag}, lang_subtag);			-- categorize it differently TODO: support multiple three-character tag categories per cs1|2 template?
				end
			elseif cfg.local_lang_cat_enable then								-- when the language and this wiki's language are the same and categorization is enabled
				utilities.add_prop_cat ('local-lang-source', {name, lang_subtag});		-- categorize it
			end
		else
			name = lang;														-- return whatever &lt;lang&gt; has so that we show something
			utilities.set_message ('maint_unknown_lang');						-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
 
	name = utilities.make_sep_list (#language_list, language_list);
	if (1 == #language_list) and (lang_subtag == cfg.this_wiki_code) then		-- when only one language, find lang name in this wiki lang name; for |language=en-us, 'English' in 'American English'
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[-----------------------&lt; S E T _ C S _ S T Y L E &gt;--------------------------

Gets the default CS style configuration for the given mode.
Returns default separator and either postscript as passed in or the default.
In CS1, the default postscript and separator are '.'.
In CS2, the default postscript is the empty string and the default separator is ','.

]]

local function set_cs_style (postscript, mode)
	if utilities.is_set(postscript) then
		-- emit a maintenance message if user postscript is the default cs1 postscript
		-- we catch the opposite case for cs2 in set_style
		if mode == 'cs1' and postscript == cfg.presentation['ps_' .. mode] then
			utilities.set_message ('maint_postscript');
		end
	else
		postscript = cfg.presentation['ps_' .. mode];
	end
	return cfg.presentation['sep_' .. mode], postscript;
end


--[[--------------------------&lt; S E T _ S T Y L E &gt;-----------------------------

Sets the separator and postscript styles. Checks the |mode= first and the
#invoke CitationClass second. Removes the postscript if postscript == none.

]]

local function set_style (mode, postscript, cite_class)
	local sep;
	if 'cs2' == mode then
		sep, postscript = set_cs_style (postscript, 'cs2');
	elseif 'cs1' == mode then
		sep, postscript = set_cs_style (postscript, 'cs1');
	elseif 'citation' == cite_class	then
		sep, postscript = set_cs_style (postscript, 'cs2');
	else
		sep, postscript = set_cs_style (postscript, 'cs1');
	end

	if cfg.keywords_xlate[postscript:lower()] == 'none' then
		-- emit a maintenance message if user postscript is the default cs2 postscript
		-- we catch the opposite case for cs1 in set_cs_style
		if 'cs2' == mode or 'citation' == cite_class then
			utilities.set_message ('maint_postscript');
		end
		postscript = '';
	end
	
	return sep, postscript
end


--[=[-------------------------&lt; I S _ P D F &gt;-----------------------------------

Determines if a URL has the file extension that is one of the PDF file extensions
used by [[MediaWiki:Common.css]] when applying the PDF icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or
		url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
		url:match ('%.PDF&amp;#035') or url:match ('%.pdf&amp;#035');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;-----------------------

Applies CSS style to |format=, |chapter-format=, etc.  Also emits an error message
if the format parameter does not have a matching URL parameter.  If the format parameter
is not set and the URL contains a file extension that is recognized as a PDF document
by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if utilities.is_set (format) then
		format = utilities.wrap_style ('format', format);						-- add leading space, parentheses, resize
		if not utilities.is_set (url) then
			utilities.set_message ('err_format_missing_url', {fmt_param, url_param});	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if URL is a PDF file then
		format = utilities.wrap_style ('format', 'PDF');						-- set format to PDF
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[---------------------&lt; G E T _ D I S P L A Y _ N A M E S &gt;------------------

Returns a number that defines the number of names displayed for author and editor
name lists and a Boolean flag to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero,
return the number and the previous state of the 'etal' flag (false by default
but may have been set to true if the name list contains some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number
that is one greater than the number of authors in the list and set the 'etal' flag true.
This will cause the list_people() to display all of the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors'], etc; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

This function sets an error message when |display-xxxxors= value greater than or equal to number of names but
not when &lt;max&gt; comes from {{cs1 config}} global settings.  When using global settings, &lt;param&gt; is set to the
keyword 'cs1 config' which is used to supress the normal error.  Error is suppressed because it is to be expected
that some citations in an article will have the same or fewer names that the limit specified in {{cs1 config}}.

]]

local function get_display_names (max, count, list_name, etal, param)
	if utilities.is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if (max &gt;= count) and ('cs1 config' ~= param) then					-- error when local |display-xxxxors= value greater than or equal to number of names; not an error when using global setting
				utilities.set_message ('err_disp_name', {param, max});			-- add error message
				max = nil;
			end
		else																	-- not a valid keyword or number
			utilities.set_message ('err_disp_name', {param, max});				-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[----------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;---------------

Adds error if |page=, |pages=, |quote-page=, |quote-pages= has what appears to be
some form of p. or pp. abbreviation in the first characters of the parameter content.

check page for extraneous p, p., pp, pp., pg, pg. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when page begins PX or P# but not Px
		      where x and X are letters and # is a digit
	bad pattern:  '^[Pp][PpGg]' matches when page begins pp, pP, Pp, PP, pg, pG, Pg, PG

]]

local function extra_text_in_page_check (val, name)
	if not val:match (cfg.vol_iss_pg_patterns.good_ppattern) then
		for _, pattern in ipairs (cfg.vol_iss_pg_patterns.bad_ppatterns) do		-- spin through the selected sequence table of patterns
			if val:match (pattern) then											-- when a match, error so
				utilities.set_message ('err_extra_text_pages', name);	 		-- add error message
				return;															-- and done
			end
		end
	end		
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ V O L _ I S S _ C H E C K &gt;------------------------

Adds error if |volume= or |issue= has what appears to be some form of redundant 'type' indicator.

For |volume=:
	'V.', or 'Vol.' (with or without the dot) abbreviations or 'Volume' in the first characters of the parameter
	content (all case insensitive). 'V' and 'v' (without the dot) are presumed to be roman numerals so
	are allowed.

For |issue=:
	'No.', 'I.', 'Iss.' (with or without the dot) abbreviations, or 'Issue' in the first characters of the
	parameter content (all case insensitive).
	
Single character values ('v', 'i', 'n') allowed when not followed by separator character ('.', ':', '=', or
whitespace character) – param values are trimmed of whitespace by MediaWiki before delivered to the module.
	
&lt;val&gt; is |volume= or |issue= parameter value
&lt;name&gt; is |volume= or |issue= parameter name for error message
&lt;selector&gt; is 'v' for |volume=, 'i' for |issue=

sets error message on failure; returns nothing

]]

local function extra_text_in_vol_iss_check (val, name, selector)
	if not utilities.is_set (val) then
		return;
	end
	
	local patterns = 'v' == selector and cfg.vol_iss_pg_patterns.vpatterns or cfg.vol_iss_pg_patterns.ipatterns;

	local handler = 'v' == selector and 'err_extra_text_volume' or 'err_extra_text_issue';
	val = val:lower();															-- force parameter value to lower case
	for _, pattern in ipairs (patterns) do										-- spin through the selected sequence table of patterns
		if val:match (pattern) then												-- when a match, error so
			utilities.set_message (handler, name);								-- add error message
			return;																-- and done
		end
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parentheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a placeholder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parentheses
			local name = name_table[i];
			i = i + 1;															-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parentheses
					break;														-- and done reassembling so
				end
				i = i + 1;														-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = utilities.is_wikilink (name_table[i]);		-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i + 1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled parentheses ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the Vancouver error when a required comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		first = '';																-- set to empty string for concatenation and because it may have been set for previous author/editor
		local accept_name;
		v_name, accept_name = utilities.has_accept_as_written (v_name);			-- remove accept-this-as-written markup when it wraps all of &lt;v_name&gt;

		if accept_name then
			last = v_name;
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error (cfg.err_msg_supl.punctuation, i);
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s+&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be initials or generational suffix

			if not mw.ustring.match (first, '^%u+$') then						-- mw.ustring here so that later we will catch non-Latin characters
				suffix = first;													-- not initials so assume that whatever we got is a generational suffix
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end
			last = table.concat(lastfirstTable, ' ')							-- returns a string that is the concatenation of all other names that are not initials and generational suffix
			if not utilities.is_set (last) then
				first = '';														-- unset
				last = v_name;													-- last empty because something wrong with first
				add_vanc_error (cfg.err_msg_supl.name, i);
			end
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error (cfg.err_msg_supl['missing comma'], i);			-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- matches a space between two initials
			end
		else
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
		
		if utilities.is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first, suffix, i);							-- check first and last before restoring the suffix which may have a non-Latin digit
			if utilities.is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '', nil, i);
			end
		end

		link = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i ) or v_link_table[i];
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate = corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest;
|editorn= (and aliases) highest and |veditors= lowest (support for |editors= withdrawn)

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
	local lastfirst = false;
	if utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice in case we have a |first1= without a |last1=; this ...
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or		-- ... also catches the case where |first= is used with |vauthors=
		utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst = true;
	end

	if (utilities.is_set (vxxxxors) and true == lastfirst) or					-- these are the three error conditions
		(utilities.is_set (vxxxxors) and utilities.is_set (xxxxors)) or
		(true == lastfirst and utilities.is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			utilities.set_message ('err_redundant_parameters', err_name .. '-name-list parameters');	-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if utilities.is_set (vxxxxors) then return 2 end;
	if utilities.is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, live, dead, etc.).  When the parameter value has not been assigned a value (missing
or empty in the source template) the function returns the value specified by ret_val.  If the parameter value is one
of the list of allowed values returns the translated value; else, emits an error message and returns the value
specified by ret_val.

TODO: explain &lt;invert&gt;

]]

local function is_valid_parameter_value (value, name, possible, ret_val, invert)
	if not utilities.is_set (value) then
		return ret_val;															-- an empty parameter is ok
	end

	if (not invert and utilities.in_array (value, possible)) then				-- normal; &lt;value&gt; is in &lt;possible&gt; table
		return cfg.keywords_xlate[value];										-- return translation of parameter keyword
	elseif invert and not utilities.in_array (value, possible) then				-- invert; &lt;value&gt; is not in &lt;possible&gt; table
		return value;															-- return &lt;value&gt; as it is
	else
		utilities.set_message ('err_invalid_param_val', {name, value});			-- not an allowed value so add error message
		return ret_val;
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list, -3, -1) == sepc .. '. ') then					-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list, -1, -1) == sepc) or (string.sub (name_list, -3, -1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terminate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;-----------------------------------------

returns the concatenation of the formatted volume and issue (or journal article number) parameters as a single
string; or formatted volume or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, article, cite_class, origin, sepc, lower)
	if not utilities.is_set (volume) and not utilities.is_set (issue) and not utilities.is_set (article) then
		return '';
	end

	-- same condition as in format_pages_sheets()
	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);

	local is_numeric_vol = volume and (volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$'));	-- is only uppercase roman numerals or only digits?
	local is_long_vol = volume and (4 &lt; mw.ustring.len(volume));				-- is |volume= value longer than 4 characters?
	
	if volume and (not is_numeric_vol and is_long_vol) then						-- when not all digits or Roman numerals, is |volume= longer than 4 characters?
		utilities.add_prop_cat ('long-vol');									-- yes, add properties cat
	end

	if is_journal then															-- journal-style formatting
		local vol = '';

		if utilities.is_set (volume) then
			if is_numeric_vol then												-- |volume= value all digits or all uppercase Roman numerals?
				vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, volume});	-- render in bold face
			elseif is_long_vol then												-- not all digits or Roman numerals; longer than 4 characters?
				vol = utilities.substitute (cfg.messages['j-vol'], {sepc, utilities.hyphen_to_dash (volume)});	-- not bold
			else																-- four or fewer characters
				vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, utilities.hyphen_to_dash (volume)});	-- bold
			end
		end
		vol = vol .. (utilities.is_set (issue) and utilities.substitute (cfg.messages['j-issue'], issue) or '')
		vol = vol .. (utilities.is_set (article) and utilities.substitute (cfg.messages['j-article-num'], article) or '')
		return vol;
	end
	
	if 'podcast' == cite_class and utilities.is_set (issue) then
		return wrap_msg ('issue', {sepc, issue}, lower);
	end
	
	if 'conference' == cite_class and utilities.is_set (article) then			-- |article-number= supported only in journal and conference cites
		if utilities.is_set (volume) and utilities.is_set (article) then		-- both volume and article number
			return wrap_msg ('vol-art', {sepc, utilities.hyphen_to_dash (volume), article}, lower);
		elseif utilities.is_set (article) then									-- article number alone; when volume alone, handled below
			return wrap_msg ('art', {sepc, article}, lower);
		end
	end

	-- all other types of citation
	if utilities.is_set (volume) and utilities.is_set (issue) then
		return wrap_msg ('vol-no', {sepc, utilities.hyphen_to_dash (volume), issue}, lower);
	elseif utilities.is_set (volume) then
		return wrap_msg ('vol', {sepc, utilities.hyphen_to_dash (volume)}, lower);
	else
		return wrap_msg ('issue', {sepc, issue}, lower);
	end
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if utilities.is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif utilities.is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if utilities.is_set (page) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return utilities.substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return utilities.substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif utilities.is_set (pages) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then							-- if pages is only digits, assume a single page number
			return '', utilities.substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', utilities.substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', utilities.substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to Wikisource, returns the label portion of the interwiki-link as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki-link to an external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, page_orig, pages, pages_orig, at)
	local ws_url, ws_label, coins_pages, L;										-- for Wikisource interwiki-links; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if utilities.is_set (page) then
		if utilities.is_set (pages) or utilities.is_set (at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page, page_orig);								-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws URL from |page= interwiki link; link portion L becomes tooltip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (pages) then
		if utilities.is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages, pages_orig);							-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws URL from |pages= interwiki link; link portion L becomes tooltip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws URL from |at= interwiki link; link portion L becomes tooltip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end

--[[--------------------------&lt; I S _ U N I Q U E _ A R C H I V E _ U R L &gt;------------------------------------

add error message when |archive-url= value is same as |url= or chapter-url= (or alias...) value

]]

local function is_unique_archive_url (archive, url, c_url, source, date)
	if utilities.is_set (archive) then
		if archive == url or archive == c_url then
			utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)});	-- add error message
			return '', '';														-- unset |archive-url= and |archive-date= because same as |url= or |chapter-url=
		end
	end

	return archive, date;
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org URLs to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot URL or to calendar pages.  When the archive URL is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the URL.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org URL does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command URL
	|archive-url= is an archive.org URL that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org URLs:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this function may return a modified
archive URL:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the URL unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

A secondary function is to return an archive-url timestamp from those urls that have them (archive.org and
archive.today).  The timestamp is used by validation.archive_date_check() to see if the value in |archive-date=
matches the timestamp in the archive url.

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.org URL
	
	timestamp = url:match ('//archive.today/(%d%d%d%d%d%d%d%d%d%d%d%d%d%d)/');	-- get timestamp from archive.today urls
	if timestamp then															-- if this was an archive.today url ...
		return url, date, timestamp;											-- return ArchiveURL, ArchiveDate, and timestamp from |archive-url=, and done
	end
																				-- here for archive.org urls
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine URL
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command URL, we don't want to allow saving of the target page 
		err_msg = cfg.err_msg_supl.save;
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = cfg.err_msg_supl.liveweb;
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');	-- split out some of the URL parts for evaluation
		if not path then														-- malformed in some way; pattern did not match
			err_msg = cfg.err_msg_supl.timestamp;
		elseif 14 ~= timestamp:len() then										-- path and flag optional, must have 14-digit timestamp here
			err_msg = cfg.err_msg_supl.timestamp;
			if '*' ~= flag then
				local replacement = timestamp:match ('^%d%d%d%d%d%d') or timestamp:match ('^%d%d%d%d');	-- get the first 6 (YYYYMM) or first 4 digits (YYYY)
				if replacement then												-- nil if there aren't at least 4 digits (year)
					replacement = replacement .. string.rep ('0', 14 - replacement:len());	-- year or yearmo (4 or 6 digits) zero-fill to make 14-digit timestamp
					url=url:gsub ('(//web%.archive%.org/[^%d]*)%d[^/]*', '%1' .. replacement .. '*', 1)	-- for preview, modify ts to 14 digits plus splat for calendar display
				end
			end
		elseif utilities.is_set (path) and 'web/' ~= path then					-- older archive URLs do not have the extra 'web/' path element
			err_msg = cfg.err_msg_supl.path;
		elseif utilities.is_set (flag) and not utilities.is_set (path) then		-- flag not allowed with the old form URL (without the 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		elseif utilities.is_set (flag) and not flag:match ('%a%a_') then		-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		else
			return url, date, timestamp;										-- return ArchiveURL, ArchiveDate, and timestamp from |archive-url=
		end
	end
																				-- if here, something not right so
	utilities.set_message ('err_archive_url', {err_msg});						-- add error message and

	if is_preview_mode then
		return url, date, timestamp;											-- preview mode so return ArchiveURL, ArchiveDate, and timestamp from |archive-url=
	else
		return '', '';															-- return empty strings for ArchiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; P L A C E _ C H E C K &gt;--------------------------------------------------------

check |place=, |publication-place=, |location= to see if these params include digits.  This function added because
many editors misuse location to specify the in-source location (|page(s)= and |at= are supposed to do that)

returns the original parameter value without modification; added maint cat when parameter value contains digits

]]

local function place_check (param_val)
	if not utilities.is_set (param_val) then									-- parameter empty or omitted
		return param_val;														-- return that empty state
	end
	
	if mw.ustring.find (param_val, '%d') then									-- not empty, are there digits in the parameter value
		utilities.set_message ('maint_location');								-- yep, add maint cat
	end
	
	return param_val;															-- and done
end


--[[--------------------------&lt; I S _ A R C H I V E D _ C O P Y &gt;----------------------------------------------

compares |title= to 'Archived copy' (placeholder added by bots that can't find proper title); if matches, return true; nil else

]]

local function is_archived_copy (title)
	title = mw.ustring.lower(title);											-- switch title to lower case
	if title:find (cfg.special_case_translation.archived_copy.en) then			-- if title is 'Archived copy'
		return true;
	elseif cfg.special_case_translation.archived_copy['local'] then
		if mw.ustring.find (title, cfg.special_case_translation.archived_copy['local']) then	-- mw.ustring() because might not be Latin script
			return true;
		end
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args )
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper ( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListStyle;
		if cfg.global_cs1_config_t['NameListStyle'] then						-- global setting in {{cs1 config}} overrides local |name-list-style= parameter value; nil when empty or assigned value invalid
			NameListStyle = is_valid_parameter_value (cfg.global_cs1_config_t['NameListStyle'], 'cs1 config: name-list-style', cfg.keywords_lists['name-list-style'], '');	-- error messaging 'param' here is a hoax
		else
			NameListStyle = is_valid_parameter_value (A['NameListStyle'], A:ORIGIN('NameListStyle'), cfg.keywords_lists['name-list-style'], '');
		end

		if cfg.global_cs1_config_t['NameListStyle'] and utilities.is_set (A['NameListStyle']) then	-- when template has |name-list-style=&lt;something&gt; which global setting has overridden
			utilities.set_message ('maint_overridden_setting');					-- set a maint message
		end

	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			a, author_etal = parse_vauthors_veditors (args, A['Vauthors'], 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |authors=
			if 'authors' == A:ORIGIN('Authors') then							-- but add a maint cat if the parameter is |authors=
				utilities.set_message ('maint_authors');						-- because use of this parameter is discouraged; what to do about the aliases is a TODO:
			end
		end
		if utilities.is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], nil, args, 'EditorList');	-- support for |editors= withdrawn
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		end
	end
							
	local Chapter = A['Chapter'];												-- done here so that we have access to |contribution= from |chapter= aliases
	local Chapter_origin = A:ORIGIN ('Chapter');
	local Contribution;															-- because contribution is required for contributor(s)
		if 'contribution' == Chapter_origin then
			Contribution = Chapter;												-- get the name of the contribution
		end
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	
	if utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not utilities.is_set (Contribution) then							-- |contributor= requires |contribution=
				utilities.set_message ('err_contributor_missing_required_param', 'contribution');	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				utilities.set_message ('err_contributor_missing_required_param', 'author');	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if utilities.select_one (args, cfg.aliases['ContributorList-Last'], 'err_redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			utilities.set_message ('err_contributor_ignored');					-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	local Title = A['Title'];
	local TitleLink = A['TitleLink'];

	local auto_select = '';														-- default is auto
	local accept_link;
	TitleLink, accept_link = utilities.has_accept_as_written (TitleLink, true);	-- test for accept-this-as-written markup
	if (not accept_link) and utilities.in_array (TitleLink, {'none', 'pmc', 'doi'}) then -- check for special keywords
		auto_select = TitleLink;												-- remember selection for later
		TitleLink = '';															-- treat as if |title-link= would have been empty
	end

	TitleLink = link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wiki-markup in |title-link= or wiki-markup in |title= when |title-link= is set

	local Section = '';															-- {{cite map}} only; preset to empty string for concatenation if not used
	if 'map' == config.CitationClass and 'section' == Chapter_origin then
		Section = A['Chapter'];													-- get |section= from |chapter= alias list; |chapter= and the other aliases not supported in {{cite map}}
		Chapter = '';															-- unset for now; will be reset later from |map= if present
	end

	local Periodical = A['Periodical'];
	local Periodical_origin = A:ORIGIN('Periodical');
	local ScriptPeriodical = A['ScriptPeriodical'];
	local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');
	local TransPeriodical =  A['TransPeriodical'];
	local TransPeriodical_origin =  A:ORIGIN ('TransPeriodical');
	
	if (utilities.in_array (config.CitationClass, {'book', 'encyclopaedia'}) and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (ScriptPeriodical))) then
		local param;
		if utilities.is_set (Periodical) then									-- get a parameter name from one of these periodical related meta-parameters
			Periodical = nil;													-- unset because not valid {{cite book}} or {{cite encyclopedia}} parameters 
			param = Periodical_origin											-- get parameter name for error messaging
		elseif utilities.is_set (TransPeriodical) then
			TransPeriodical = nil;												-- unset because not valid {{cite book}} or {{cite encyclopedia}} parameters 
			param = TransPeriodical_origin;										-- get parameter name for error messaging
		elseif utilities.is_set (ScriptPeriodical) then
			ScriptPeriodical = nil;												-- unset because not valid {{cite book}} or {{cite encyclopedia}} parameters 
			param = ScriptPeriodical_origin;									-- get parameter name for error messaging
		end

		if utilities.is_set (param) then										-- if we found one
			utilities.set_message ('err_periodical_ignored', {param});			-- emit an error message
		end
	end

	if utilities.is_set (Periodical) then
		local i;
		Periodical, i = utilities.strip_apostrophe_markup (Periodical);			-- strip apostrophe markup so that metadata isn't contaminated 
		if i then																-- non-zero when markup was stripped so emit an error message
			utilities.set_message ('err_apostrophe_markup', {Periodical_origin});
		end
	end

	if 'mailinglist' == config.CitationClass then								-- special case for {{cite mailing list}}
		if utilities.is_set (Periodical) and utilities.is_set (A ['MailingList']) then	-- both set emit an error TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', Periodical_origin) .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'mailinglist')});
		end

		Periodical = A ['MailingList'];											-- error or no, set Periodical to |mailinglist= value because this template is {{cite mailing list}}
		Periodical_origin = A:ORIGIN('MailingList');
	end

	-- web and news not tested for now because of 
	-- Wikipedia:Administrators%27_noticeboard#Is_there_a_semi-automated_tool_that_could_fix_these_annoying_&quot;Cite_Web&quot;_errors?
	if not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) then	-- 'periodical' templates require periodical parameter
	--	local p = {['journal'] = 'journal', ['magazine'] = 'magazine', ['news'] = 'newspaper', ['web'] = 'website'};	-- for error message
		local p = {['journal'] = 'journal', ['magazine'] = 'magazine'};			-- for error message
		if p[config.CitationClass]  then
			utilities.set_message ('err_missing_periodical', {config.CitationClass, p[config.CitationClass]});
		end
	end
	
	local Volume;
--	local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) then
			if not utilities.in_array (Periodical_origin, cfg.citation_no_volume_t) then	-- {{citation}} does not render |volume= when these parameters are used
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		elseif utilities.is_set (ScriptPeriodical) then
			if 'script-website' ~= ScriptPeriodical_origin then					-- {{citation}} does not render volume for |script-website=
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		else
			Volume = A['Volume'];												-- and does for non-'periodical' cites
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_volume) then	-- render |volume= for cs1 according to the configuration settings
		Volume = A['Volume'];
	end	
	extra_text_in_vol_iss_check (Volume, A:ORIGIN ('Volume'), 'v');	

	local Issue;
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) and utilities.in_array (Periodical_origin, cfg.citation_issue_t) then	-- {{citation}} may render |issue= when these parameters are used
			Issue = utilities.hyphen_to_dash (A['Issue']);
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_issue) then	-- conference &amp; map books do not support issue; {{citation}} listed here because included in settings table
		if not (utilities.in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical))) then
			Issue = utilities.hyphen_to_dash (A['Issue']);
		end
	end
	
	local ArticleNumber;

	if utilities.in_array (config.CitationClass, {'journal', 'conference'}) or ('citation' == config.CitationClass and utilities.is_set (Periodical) and 'journal' == Periodical_origin) then
		ArticleNumber = A['ArticleNumber'];
	end

	extra_text_in_vol_iss_check (Issue, A:ORIGIN ('Issue'), 'i');	

	local Page;
	local Pages;
	local At;
	local QuotePage;
	local QuotePages;
	if not utilities.in_array (config.CitationClass, cfg.templates_not_using_page) then		-- TODO: rewrite to emit ignored parameter error message?
		Page = A['Page'];
		Pages = utilities.hyphen_to_dash (A['Pages']);	
		At = A['At'];
		QuotePage = A['QuotePage'];
		QuotePages = utilities.hyphen_to_dash (A['QuotePages']);
	end

	local Edition = A['Edition'];
	local PublicationPlace = place_check (A['PublicationPlace'], A:ORIGIN('PublicationPlace'));
	local Place = place_check (A['Place'], A:ORIGIN('Place'));
	
	local PublisherName = A['PublisherName'];
	local PublisherName_origin = A:ORIGIN('PublisherName');
	if utilities.is_set (PublisherName) and (cfg.keywords_xlate['none'] ~= PublisherName) then
		local i = 0;
		PublisherName, i = utilities.strip_apostrophe_markup (PublisherName);	-- strip apostrophe markup so that metadata isn't contaminated; publisher is never italicized
		if i and (0 &lt; i) then													-- non-zero when markup was stripped so emit an error message
			utilities.set_message ('err_apostrophe_markup', {PublisherName_origin});
		end
	end
	
	if ('document' == config.CitationClass) and not utilities.is_set (PublisherName) then
		utilities.set_message ('err_missing_publisher', {config.CitationClass, 'publisher'});
	end

	local Newsgroup = A['Newsgroup'];											-- TODO: strip apostrophe markup?
	local Newsgroup_origin = A:ORIGIN('Newsgroup');	

	if 'newsgroup' == config.CitationClass then
		if utilities.is_set (PublisherName) and (cfg.keywords_xlate['none'] ~= PublisherName) then	-- general use parameter |publisher= not allowed in cite newsgroup
			utilities.set_message ('err_parameter_ignored', {PublisherName_origin});
		end

		PublisherName = nil;													-- ensure that this parameter is unset for the time being; will be used again after COinS
	end

	local URL = A['URL'];														-- TODO: better way to do this for URL, ChapterURL, and MapURL?
	local UrlAccess = is_valid_parameter_value (A['UrlAccess'], A:ORIGIN('UrlAccess'), cfg.keywords_lists['url-access'], nil);
	
	if not utilities.is_set (URL) and utilities.is_set (UrlAccess) then
		UrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', 'url');
	end
	
	local ChapterURL = A['ChapterURL'];
	local ChapterUrlAccess = is_valid_parameter_value (A['ChapterUrlAccess'], A:ORIGIN('ChapterUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (ChapterURL) and utilities.is_set (ChapterUrlAccess) then
		ChapterUrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', {A:ORIGIN('ChapterUrlAccess'):gsub ('%-access', '')});
	end

	local MapUrlAccess = is_valid_parameter_value (A['MapUrlAccess'], A:ORIGIN('MapUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (A['MapURL']) and utilities.is_set (MapUrlAccess) then
		MapUrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', {'map-url'});
	end

	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local no_tracking_cats = is_valid_parameter_value (A['NoTracking'], A:ORIGIN('NoTracking'), cfg.keywords_lists['yes_true_y'], nil);

	-- check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not utilities.is_set (no_tracking_cats) then								-- ignore if we are already not going to categorize this page
		if cfg.uncategorized_namespaces[this_page.namespace] then				-- is this page's namespace id one of the uncategorized namespace ids?
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _, v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end
																				-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	utilities.select_one (args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'err_redundant_parameters');	-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, A:ORIGIN('Page'), Pages, A:ORIGIN('Pages'), At);

	local NoPP = is_valid_parameter_value (A['NoPP'], A:ORIGIN('NoPP'), cfg.keywords_lists['yes_true_y'], nil);

	if utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- both |publication-place= and |place= (|location=) allowed if different
		utilities.add_prop_cat ('location-test');								-- add property cat to evaluate how often PublicationPlace and Place are used together
		if PublicationPlace == Place then
			Place = '';															-- unset; don't need both if they are the same
		end
	elseif not utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- when only |place= (|location=) is set ...
		PublicationPlace = Place;												-- promote |place= (|location=) to |publication-place
	end

	if PublicationPlace == Place then Place = ''; end							-- don't need both if they are the same

	local URL_origin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL_origin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ScriptChapter = A['ScriptChapter'];
	local ScriptChapter_origin = A:ORIGIN ('ScriptChapter');
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local TransChapter = A['TransChapter'];
	local TransChapter_origin = A:ORIGIN ('TransChapter');
	local TransTitle = A['TransTitle'];
	local ScriptTitle = A['ScriptTitle'];
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia= and |title= then map |title= to |article= and |encyclopedia= to |title= for rendering
		|encyclopedia= and |article= then map |encyclopedia= to |title= for rendering

		|trans-title= maps to |trans-chapter= when |title= is re-mapped
		|url= maps to |chapter-url= when |title= is remapped
	
	All other combinations of |encyclopedia=, |title=, and |article= are not modified
	
	]]

	local Encyclopedia = A['Encyclopedia'];										-- used as a flag by this module and by ~/COinS

	if utilities.is_set (Encyclopedia) then										-- emit error message when Encyclopedia set but template is other than {{cite encyclopedia}} or {{citation}}
		if 'encyclopaedia' ~= config.CitationClass and 'citation' ~= config.CitationClass then
			utilities.set_message ('err_parameter_ignored', {A:ORIGIN ('Encyclopedia')});
			Encyclopedia = nil;													-- unset because not supported by this template
		end
	end

	if ('encyclopaedia' == config.CitationClass) or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Periodical) and utilities.is_set (Encyclopedia) then	-- when both parameters set emit an error message; {{citation}} only; Periodical not allowed in {{cite encyclopedia}}
			utilities.set_message ('err_periodical_ignored', {Periodical_origin});
		end

		if utilities.is_set (Encyclopedia) then
			Periodical = Encyclopedia;											-- error or no, set Periodical to Encyclopedia for rendering; {{citation}} could (not legitimately) have both; use Encyclopedia
			Periodical_origin = A:ORIGIN ('Encyclopedia');

			if utilities.is_set (Title) or utilities.is_set (ScriptTitle) then
				if not utilities.is_set (Chapter) then
					Chapter = Title;											-- |encyclopedia= and |title= are set so map |title= to |article= and |encyclopedia= to |title= for rendering
					ScriptChapter = ScriptTitle;
					ScriptChapter_origin = A:ORIGIN('ScriptTitle')
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterURL_origin = URL_origin;

					ChapterUrlAccess = UrlAccess;

					if not utilities.is_set (ChapterURL) and utilities.is_set (TitleLink) then
						Chapter = utilities.make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			elseif utilities.is_set (Chapter) or utilities.is_set (ScriptChapter) then								-- |title= not set
				Title = Periodical;												-- |encyclopedia= set and |article= set so map |encyclopedia= to |title= for rendering
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- special case for cite techreport.
	local ID = A['ID'];
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if utilities.is_set (A['Number']) then									-- cite techreport uses 'number', which other citations alias to 'issue'
			if not utilities.is_set (ID) then									-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'id') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'number')});
			end
		end	
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	local ChapterLink -- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local Conference = A['Conference'];
	local BookTitle = A['BookTitle'];
	local TransTitle_origin = A:ORIGIN ('TransTitle');
	if 'conference' == config.CitationClass then
		if utilities.is_set (BookTitle) then
			Chapter = Title;
			Chapter_origin = 'title';
	--		ChapterLink = TitleLink;											-- |chapter-link= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			URL_origin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			TransChapter_origin = TransTitle_origin;
			Title = BookTitle;
			Format = '';
	--		TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end
	
	-- CS1/2 mode
	local Mode;
		if cfg.global_cs1_config_t['Mode'] then									-- global setting in {{cs1 config}} overrides local |mode= parameter value; nil when empty or assigned value invalid
			Mode = is_valid_parameter_value (cfg.global_cs1_config_t['Mode'], 'cs1 config: mode', cfg.keywords_lists['mode'], '');	-- error messaging 'param' here is a hoax
		else
			Mode = is_valid_parameter_value (A['Mode'], A:ORIGIN('Mode'), cfg.keywords_lists['mode'], '');
		end

		if cfg.global_cs1_config_t['Mode'] and utilities.is_set (A['Mode']) then	-- when template has |mode=&lt;something&gt; which global setting has overridden
			utilities.set_message ('maint_overridden_setting');					-- set a maint message
		end

	-- separator character and postscript
	local sepc, PostScript = set_style (Mode:lower(), A['PostScript'], config.CitationClass);
	-- controls capitalization of certain static text
	local use_lowercase = ( sepc == ',' );
	
	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		if utilities.is_set (Chapter) then										--TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'map') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', Chapter_origin)});	-- add error message
		end
		Chapter = A['Map'];
		Chapter_origin = A:ORIGIN('Map');
		ChapterURL = A['MapURL'];
		ChapterURL_origin = A:ORIGIN('MapURL');
		TransChapter = A['TransMap'];
		ScriptChapter = A['ScriptMap']
		ScriptChapter_origin = A:ORIGIN('ScriptMap')

		ChapterUrlAccess = MapUrlAccess;
		ChapterFormat = A['MapFormat'];

		Cartography = A['Cartography'];
		if utilities.is_set ( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if utilities.is_set ( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	local Series = A['Series'];
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local SeriesLink = A['SeriesLink'];

		SeriesLink = link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wiki-markup in |series-link= or wiki-markup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if utilities.is_set (Network) then table.insert(n, Network); end
		if utilities.is_set (Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if utilities.is_set (Season) and utilities.is_set (SeriesNumber) then	-- these are mutually exclusive so if both are set TODO: make a function for this and similar?
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'season') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'seriesno')});		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if utilities.is_set (Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if utilities.is_set (SeriesNumber) then table.insert(s, wrap_msg ('seriesnum', SeriesNumber, use_lowercase)); end
			if utilities.is_set (Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ScriptChapter_origin = A:ORIGIN('ScriptTitle');
			ChapterLink = TitleLink;											-- alias |episode-link=
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			ChapterFormat = Format;

			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if utilities.is_set (ChapterLink) and not utilities.is_set (ChapterURL) then	-- link but not URL
				Chapter = utilities.make_wikilink (ChapterLink, Chapter);
			elseif utilities.is_set (ChapterLink) and utilities.is_set (ChapterURL) then	-- if both are set, URL links episode;
				Series = utilities.make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			Format = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if utilities.is_set (Series) and utilities.is_set (SeriesLink) then
				Series = utilities.make_wikilink (SeriesLink, Series);
			end
			Series = utilities.wrap_style ('italic-title', Series);				-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- handle type parameter for those CS1 citations that have default values
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	if utilities.in_array (config.CitationClass, {'AV-media-notes', 'document', 'interview', 'mailinglist', 'map', 'podcast', 'pressrelease', 'report', 'speech', 'techreport', 'thesis'}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if utilities.is_set (Degree) and &quot;Thesis&quot; == TitleType then				-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if utilities.is_set (TitleType) then										-- if type parameter is specified
		TitleType = utilities.substitute ( cfg.messages['type'], TitleType);	-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
	local Date = A['Date'];
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging
	local PublicationDate = A['PublicationDate'];
	local Year = A['Year'];

	if not utilities.is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not utilities.is_set (Date) and utilities.is_set (PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]

	local DF = is_valid_parameter_value (A['DF'], A:ORIGIN('DF'), cfg.keywords_lists['df'], '');
	if not utilities.is_set (DF) then
		DF = cfg.global_df;														-- local |df= if present overrides global df set by {{use xxx date}} template
	end

	local ArchiveURL;
	local ArchiveDate;
	local ArchiveFormat = A['ArchiveFormat'];
	local archive_url_timestamp;												-- timestamp from wayback machine url
	
	ArchiveURL, ArchiveDate, archive_url_timestamp = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	
	ArchiveURL, ArchiveDate = is_unique_archive_url (ArchiveURL, URL, ChapterURL, A:ORIGIN('ArchiveURL'), ArchiveDate);		-- add error message when URL or ChapterURL == ArchiveURL

	local AccessDate = A['AccessDate'];
--	local LayDate = A['LayDate'];
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification
	local DoiBroken = A['DoiBroken'];
	local Embargo = A['Embargo'];
	local anchor_year;															-- used in the CITEREF identifier
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val = AccessDate, name = A:ORIGIN ('AccessDate')},
			['archive-date'] = {val = ArchiveDate, name = A:ORIGIN ('ArchiveDate')},
			['date'] = {val = Date, name = Date_origin},
			['doi-broken-date'] = {val = DoiBroken, name = A:ORIGIN ('DoiBroken')},
			['pmc-embargo-date'] = {val = Embargo, name = A:ORIGIN ('Embargo')},
--			['lay-date'] = {val = LayDate, name = A:ORIGIN ('LayDate')},
			['publication-date'] = {val = PublicationDate, name = A:ORIGIN ('PublicationDate')},
			['year'] = {val = Year, name = A:ORIGIN ('Year')},
			};

		local error_list = {};
		anchor_year, Embargo = validation.dates(date_parameters_list, COinS_date, error_list);

-- start temporary Julian / Gregorian calendar uncertainty categorization
		if COinS_date.inter_cal_cat then
			utilities.add_prop_cat ('jul-greg-uncertainty');
		end
-- end temporary Julian / Gregorian calendar uncertainty categorization

		if utilities.is_set (Year) and utilities.is_set (Date) then				-- both |date= and |year= not normally needed; 
			validation.year_date_check (Year, A:ORIGIN ('Year'), Date, A:ORIGIN ('Date'), error_list);
		end
		
		if 0 == #error_list then												-- error free dates only; 0 when error_list is empty
			local modified = false;												-- flag
			
			if utilities.is_set (DF) then										-- if we need to reformat dates
				modified = validation.reformat_dates (date_parameters_list, DF);	-- reformat to DF format, use long month names if appropriate
			end

			if true == validation.date_hyphen_to_dash (date_parameters_list) then	-- convert hyphens to dashes where appropriate
				modified = true;
				utilities.set_message ('maint_date_format');					-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language; not supported at en.wiki
			if cfg.date_name_auto_xlate_enable and validation.date_name_xlate (date_parameters_list, cfg.date_digit_auto_xlate_enable ) then
				utilities.set_message ('maint_date_auto_xlated');				-- add maint cat
				modified = true;
			end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
--				LayDate = date_parameters_list['lay-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end

			if archive_url_timestamp and utilities.is_set (ArchiveDate) then
				validation.archive_date_check (ArchiveDate, archive_url_timestamp);	-- does YYYYMMDD in archive_url_timestamp match date in ArchiveDate
			end
		else
			utilities.set_message ('err_bad_date', {utilities.make_sep_list (#error_list, error_list)});	-- add this error message
		end
	end	-- end of do

	if utilities.in_array (config.CitationClass, {'book', 'encyclopaedia'}) or	-- {{cite book}}, {{cite encyclopedia}}; TODO: {{cite conference}} and others?
		('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) or			-- {{citation}} as an encylopedia citation
		('citation' == config.CitationClass and not utilities.is_set (Periodical)) then		-- {{citation}} as a book citation
			if utilities.is_set (PublicationPlace) then
				if not utilities.is_set (PublisherName) then
					local date = COinS_date.rftdate and tonumber (COinS_date.rftdate:match ('%d%d%d%d'));	-- get year portion of COinS date (because in Arabic numerals); convert string to number
					if date and (1850 &lt;= date) then								-- location has no publisher; if date is 1850 or later
						utilities.set_message ('maint_location_no_publisher');	-- add maint cat
					end
				else															-- PublisherName has a value
					if cfg.keywords_xlate['none'] == PublisherName then			-- if that value is 'none' (only for book and encyclopedia citations)
						PublisherName = '';										-- unset
					end
				end
			end
	end

	local ID_list = {};															-- sequence table of rendered identifiers
	local ID_list_coins = {};													-- table of identifiers and their values from args; key is same as cfg.id_handlers's key
	local Class = A['Class'];													-- arxiv class identifier
	
	local ID_support = {
		{A['ASINTLD'], 'ASIN', 'err_asintld_missing_asin', A:ORIGIN ('ASINTLD')},				
		{DoiBroken, 'DOI', 'err_doibroken_missing_doi', A:ORIGIN ('DoiBroken')},
		{Embargo, 'PMC', 'err_embargo_missing_pmc', A:ORIGIN ('Embargo')},
		}

	ID_list, ID_list_coins = identifiers.identifier_lists_get (args, {DoiBroken = DoiBroken, ASINTLD = A['ASINTLD'], Embargo = Embargo, Class = Class}, ID_support);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite medrxiv}}, {{cite ssrn}}, before generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list_t) then	-- |arxiv= or |eprint= required for cite arxiv; |biorxiv=, |citeseerx=, |medrxiv=, |ssrn= required for their templates
		if not (args[cfg.id_handlers[config.CitationClass:upper()].parameters[1]] or 		-- can't use ID_list_coins k/v table here because invalid parameters omitted
			args[cfg.id_handlers[config.CitationClass:upper()].parameters[2]]) then			-- which causes unexpected parameter missing error message
				utilities.set_message ('err_' .. config.CitationClass .. '_missing');		-- add error message
		end

		Periodical = ({['arxiv'] = 'arXiv', ['biorxiv'] = 'bioRxiv', ['citeseerx'] = 'CiteSeerX', ['medrxiv'] = 'medRxiv', ['ssrn'] = 'Social Science Research Network'})[config.CitationClass];
	end

	-- Link the title of the work if no |url= was provided, but we have a |pmc= or a |doi= with |doi-access=free

	if config.CitationClass == &quot;journal&quot; and not utilities.is_set (URL) and not utilities.is_set (TitleLink) and not utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) then -- TODO: remove 'none' once existing citations have been switched to 'off', so 'none' can be used as token for &quot;no title&quot; instead
		if 'none' ~= cfg.keywords_xlate[auto_select] then						-- if auto-linking not disabled
 	 		if identifiers.auto_link_urls[auto_select] then						-- manual selection
		 		URL = identifiers.auto_link_urls[auto_select];					-- set URL to be the same as identifier's external link
 				URL_origin = cfg.id_handlers[auto_select:upper()].parameters[1];	-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['pmc'] then						-- auto-select PMC
				URL = identifiers.auto_link_urls['pmc'];						-- set URL to be the same as the PMC external link if not embargoed
				URL_origin = cfg.id_handlers['PMC'].parameters[1];				-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['doi'] then						-- auto-select DOI
				URL = identifiers.auto_link_urls['doi'];
				URL_origin = cfg.id_handlers['DOI'].parameters[1];
			end
 	 	end

		if utilities.is_set (URL) then											-- set when using an identifier-created URL
			if utilities.is_set (AccessDate) then								-- |access-date= requires |url=; identifier-created URL is not |url=
				utilities.set_message ('err_accessdate_missing_url');			-- add an error message
				AccessDate = '';												-- unset
			end

			if utilities.is_set (ArchiveURL) then								-- |archive-url= requires |url=; identifier-created URL is not |url=
				utilities.set_message ('err_archive_missing_url');				-- add an error message
				ArchiveURL = '';												-- unset
			end
		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not utilities.is_set (Title) and not utilities.is_set (TransTitle) and not utilities.is_set (ScriptTitle) then	-- has special case for cite episode
		utilities.set_message ('err_citation_missing_title', {'episode' == config.CitationClass and 'series' or 'title'});
	end

	if utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) and
			utilities.in_array (config.CitationClass, {'journal', 'citation'}) and
			(utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and
			('journal' == Periodical_origin or 'script-journal' == ScriptPeriodical_origin) then	-- special case for journal cites
				Title = '';														-- set title to empty string
				utilities.set_message ('maint_untitled');						-- add maint cat
	end

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Chapter) and utilities.is_set (Title) and utilities.is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end
	
	-- this is the function call to COinS()
	local OCinSoutput = metadata.COinS({
		['Periodical'] = utilities.strip_apostrophe_markup (Periodical),		-- no markup in the metadata
		['Encyclopedia'] = Encyclopedia,										-- just a flag; content ignored by ~/COinS
		['Chapter'] = metadata.make_coins_title (coins_chapter, ScriptChapter),	-- Chapter and ScriptChapter stripped of bold / italic / accept-as-written markup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = metadata.make_coins_title (coins_title, ScriptTitle),		-- Title and ScriptTitle stripped of bold / italic / accept-as-written markup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date.* has correctly formatted date values if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Quarter'] = COinS_date.rftquarter,
		['Chron'] =  COinS_date.rftchron,
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['ArticleNumber'] = ArticleNumber,
		['Pages'] = coins_pages or metadata.get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At, QuotePage, QuotePages}, 7)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName or Newsgroup,							-- any apostrophe markup already removed from PublisherName
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list_coins,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite medrxiv}}, and {{cite ssrn}} AFTER generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list_t) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, CiteSeerX, medRxiv, or ssrn now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass and utilities.is_set (Newsgroup) then
		PublisherName = utilities.substitute (cfg.messages['newsgroup'], external_link( 'news:' .. Newsgroup, Newsgroup, Newsgroup_origin, nil ));
	end

	local Editors;
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	local Contributors;															-- assembled contributors name list
	local contributor_etal;
	local Translators;															-- assembled translators name list
	local translator_etal;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	local Interviewers;															
	local interviewers_list = {};					
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters
	local interviewer_etal;
	
	-- Now perform various field 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.
	do
		local last_first_list;
		local control = { 
			format = NameListStyle,												-- empty string, '&amp;', 'amp', 'and', or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			if cfg.global_cs1_config_t['DisplayEditors'] then					-- global setting from {{cs1 config}} overrides local setting
				control.maximum , editor_etal = get_display_names (cfg.global_cs1_config_t['DisplayEditors'], #e, 'editors', editor_etal, 'cs1 config');
			else
				control.maximum , editor_etal = get_display_names (A['DisplayEditors'], #e, 'editors', editor_etal, A:ORIGIN ('DisplayEditors'));
			end

			if cfg.global_cs1_config_t['DisplayEditors'] and utilities.is_set (A['DisplayEditors']) then	-- when template has |display-editors=&lt;something&gt; which global setting has overridden
				utilities.set_message ('maint_overridden_setting');				-- set a maint message
			end

			Editors, EditorCount = list_people (control, e, editor_etal);

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			if cfg.global_cs1_config_t['DisplayInterviewers'] then				-- global setting from {{cs1 config}} overrides local setting
				control.maximum, interviewer_etal = get_display_names (cfg.global_cs1_config_t['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal, 'cs1 config');
			else
				control.maximum, interviewer_etal = get_display_names (A['DisplayInterviewers'], #interviewers_list, 'interviewers', interviewer_etal, A:ORIGIN ('DisplayInterviewers'));
			end

			if cfg.global_cs1_config_t['DisplayInterviewers'] and utilities.is_set (A['DisplayInterviewers']) then	-- when template has |display-interviewers=&lt;something&gt; which global setting has overridden
				utilities.set_message ('maint_overridden_setting');				-- set a maint message
			end

			Interviewers = list_people (control, interviewers_list, interviewer_etal);
		end
		do																		-- now do translators
			if cfg.global_cs1_config_t['DisplayTranslators'] then				-- global setting from {{cs1 config}} overrides local setting
				control.maximum, translator_etal = get_display_names (cfg.global_cs1_config_t['DisplayTranslators'], #t, 'translators', translator_etal, 'cs1 config');
			else
				control.maximum, translator_etal = get_display_names (A['DisplayTranslators'], #t, 'translators', translator_etal, A:ORIGIN ('DisplayTranslators'));
			end

			if cfg.global_cs1_config_t['DisplayTranslators'] and utilities.is_set (A['DisplayTranslators']) then	-- when template has |display-translators=&lt;something&gt; which global setting has overridden
				utilities.set_message ('maint_overridden_setting');				-- set a maint message
			end

			Translators = list_people (control, t, translator_etal);
		end
		do																		-- now do contributors
			if cfg.global_cs1_config_t['DisplayContributors'] then				-- global setting from {{cs1 config}} overrides local setting
				control.maximum, contributor_etal = get_display_names (cfg.global_cs1_config_t['DisplayContributors'], #c, 'contributors', contributor_etal, 'cs1 config');
			else
				control.maximum, contributor_etal = get_display_names (A['DisplayContributors'], #c, 'contributors', contributor_etal, A:ORIGIN ('DisplayContributors'));
			end

			if cfg.global_cs1_config_t['DisplayContributors'] and utilities.is_set (A['DisplayContributors']) then	-- when template has |display-contributors=&lt;something&gt; which global setting has overridden
				utilities.set_message ('maint_overridden_setting');				-- set a maint message
			end

			Contributors = list_people (control, c, contributor_etal);
		end
		do																		-- now do authors
			if cfg.global_cs1_config_t['DisplayAuthors'] then					-- global setting from {{cs1 config}} overrides local setting
				control.maximum, author_etal = get_display_names (cfg.global_cs1_config_t['DisplayAuthors'], #a, 'authors', author_etal, 'cs1 config');
			else
				control.maximum, author_etal = get_display_names (A['DisplayAuthors'], #a, 'authors', author_etal, A:ORIGIN ('DisplayAuthors'));
			end

			if cfg.global_cs1_config_t['DisplayAuthors'] and utilities.is_set (A['DisplayAuthors']) then	-- when template has |display-authors=&lt;something&gt; which global setting has overridden
				utilities.set_message ('maint_overridden_setting');				-- set a maint message
			end

			last_first_list = list_people (control, a, author_etal);

			if utilities.is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors');	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if utilities.is_set (Authors) and utilities.is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'medrxiv', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not utilities.is_set (URL) then
		if utilities.in_array (config.CitationClass, {&quot;web&quot;, &quot;podcast&quot;, &quot;mailinglist&quot;}) or		-- |url= required for cite web, cite podcast, and cite mailinglist
			('citation' == config.CitationClass and ('website' == Periodical_origin or 'script-website' == ScriptPeriodical_origin)) then	-- and required for {{citation}} with |website= or |script-website=
				utilities.set_message ('err_cite_web_url');
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if utilities.is_set (AccessDate) and not utilities.is_set (ChapterURL) then		-- ChapterURL may be set when URL is not set;
			utilities.set_message ('err_accessdate_missing_url');
			AccessDate = '';
		end
	end

	local UrlStatus = is_valid_parameter_value (A['UrlStatus'], A:ORIGIN('UrlStatus'), cfg.keywords_lists['url-status'], '');
	local OriginalURL
	local OriginalURL_origin
	local OriginalFormat
	local OriginalAccess;
	UrlStatus = UrlStatus:lower();												-- used later when assembling archived text
	if utilities.is_set ( ArchiveURL ) then
		if utilities.is_set (ChapterURL) then 									-- if chapter-url= is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURL_origin = ChapterURL_origin;								-- name of |chapter-url= parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=

			if 'live' ~= UrlStatus then
				ChapterURL = ArchiveURL											-- swap-in the archive's URL
				ChapterURL_origin = A:ORIGIN('ArchiveURL')						-- name of |archive-url= parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived URLs
			end
		elseif utilities.is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURL_origin = URL_origin;									-- name of URL parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;

			if 'live' ~= UrlStatus then											-- if URL set then |archive-url= applies to it
				URL = ArchiveURL												-- swap-in the archive's URL
				URL_origin = A:ORIGIN('ArchiveURL')								-- name of archive URL parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived URLs
			end
		end
	elseif utilities.is_set (UrlStatus) then									-- if |url-status= is set when |archive-url= is not set
 		utilities.set_message ('maint_url_status');								-- add maint cat
	end

	if utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'medrxiv', 'ssrn'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) then
			local chap_param;
			if utilities.is_set (Chapter) then									-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif utilities.is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif utilities.is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif utilities.is_set (ScriptChapter) then
				chap_param = ScriptChapter_origin;
			else utilities.is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if utilities.is_set (chap_param) then								-- if we found one
				utilities.set_message ('err_chapter_ignored', {chap_param});	-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if utilities.is_set (Contribution) and 0 &lt; #c then						-- if this is a contribution with contributor(s)
			if utilities.in_array (Contribution:lower(), cfg.keywords_lists.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, ScriptChapter_origin, Chapter, Chapter_origin, TransChapter, TransChapter_origin, ChapterURL, ChapterURL_origin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if utilities.is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and utilities.is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter .. sepc .. ' ';
		elseif utilities.is_set (ChapterFormat) then							-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title
	local plain_title = false;
	local accept_title;
	Title, accept_title = utilities.has_accept_as_written (Title, true);		-- remove accept-this-as-written markup when it wraps all of &lt;Title&gt;
	if accept_title and ('' == Title) then										-- only support forced empty for now &quot;(())&quot;
		Title = cfg.messages['notitle'];										-- replace by predefined &quot;No title&quot; message
			-- TODO: utilities.set_message ( 'err_redundant_parameters', ...);	-- issue proper error message instead of muting	 
			ScriptTitle = '';													-- just mute for now	 
			TransTitle = '';													-- just mute for now
 		plain_title = true;														-- suppress text decoration for descriptive title
		utilities.set_message ('maint_untitled');								-- add maint cat
	end

	if not accept_title then													-- &lt;Title&gt; not wrapped in accept-as-written markup
		if '...' == Title:sub (-3) then											-- if ellipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%' .. sepc .. '$', '');			-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end

		if utilities.is_set (ArchiveURL) and is_archived_copy (Title) then
			utilities.set_message ('maint_archived_copy');						-- add maintenance category before we modify the content of Title
		end

		if is_generic ('generic_titles', Title) then
			utilities.set_message ('err_generic_title');						-- set an error message
		end
	end

	if (not plain_title) and (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'document', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx', 'medrxiv', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) or
		('map' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)))) then		-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from module provided quote marks
			Title = utilities.wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle, 'script-title');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
			TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );
	elseif plain_title or ('report' == config.CitationClass) then				-- no styling for cite report and descriptive titles (otherwise same as above)
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );	-- for cite report, use this form for trans-title
	else
		Title = utilities.wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-italic-title', TransTitle);
	end

	if utilities.is_set (TransTitle) then
		if utilities.is_set (Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			utilities.set_message ('err_trans_missing_title', {'title'});
		end
	end

	if utilities.is_set (Title) then											-- TODO: is this the right place to be making Wikisource URLs?
		if utilities.is_set (TitleLink) and utilities.is_set (URL) then
			utilities.set_message ('err_wikilink_in_url');						-- set an error message because we can't have both
			TitleLink = '';														-- unset
		end
	
		if not utilities.is_set (TitleLink) and utilities.is_set (URL) then
			Title = external_link (URL, Title, URL_origin, UrlAccess) .. TransTitle .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif utilities.is_set (TitleLink) and not utilities.is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle;
			else
				Title = utilities.make_wikilink (TitleLink, Title) .. TransTitle;
			end
		else
			local ws_url, ws_label, L;											-- Title has italic or quote markup by the time we get here which causes is_wikilink() to return 0 (not a wikilink)
			ws_url, ws_label, L = wikisource_url_make (Title:gsub('^[\'&quot;]*(.-)[\'&quot;]*$', '%1'));	-- make ws URL from |title= interwiki link (strip italic or quote markup); link portion L becomes tooltip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle;
			else
				Title = Title .. TransTitle;
			end
		end
	else
		Title = TransTitle;
	end

	if utilities.is_set (Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	local ConferenceURL_origin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	if utilities.is_set (Conference) then
		if utilities.is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURL_origin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif utilities.is_set (ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURL_origin, nil );
	end

	local Position = '';
	if not utilities.is_set (Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if utilities.is_set (Minutes) then
			if utilities.is_set (Time) then		--TODO: make a function for this and similar?
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'minutes') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'time')});
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if utilities.is_set (Time) then
				local TimeCaption = A['TimeCaption']
				if not utilities.is_set (TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = utilities.is_set (At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = utilities.is_set (Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Sections = A['Sections'];											-- Section (singular) is an alias of Chapter so set earlier
		local Inset = A['Inset'];
		
		if utilities.is_set ( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if utilities.is_set ( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif utilities.is_set ( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	local Others = A['Others'];
	if utilities.is_set (Others) and 0 == #a and 0 == #e then					-- add maint cat when |others= has value and used without |author=, |editor=
		if config.CitationClass == &quot;AV-media-notes&quot;
		or config.CitationClass == &quot;audio-visual&quot; then							-- special maint for AV/M which has a lot of 'false' positives right now
			utilities.set_message ('maint_others_avm')
		else
			utilities.set_message ('maint_others');
		end
	end
	Others = utilities.is_set (Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if utilities.is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if utilities.is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	local TitleNote = A['TitleNote'];
	TitleNote = utilities.is_set (TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if utilities.is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%n?%.?$') or Edition:match ('%f[%a][Ee]dition$') then -- Ed, ed, Ed., ed., Edn, edn, Edn., edn.
			utilities.set_message ('err_extra_text_edition');					 -- add error message
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = utilities.is_set (Series) and wrap_msg ('series', {sepc, Series}) or &quot;&quot;;	-- not the same as SeriesNum
	local Agency = A['Agency'];
	Agency = utilities.is_set (Agency) and wrap_msg ('agency', {sepc, Agency}) or &quot;&quot;;
	Volume = format_volume_issue (Volume, Issue, ArticleNumber, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	if utilities.is_set (AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = utilities.substitute (retrv_text, AccessDate);				-- add retrieved text

		AccessDate = utilities.substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if utilities.is_set (ID) then ID = sepc .. &quot; &quot; .. ID; end
	
	local Docket = A['Docket'];
   	if &quot;thesis&quot; == config.CitationClass and utilities.is_set (Docket) then
		ID = sepc .. &quot; Docket &quot; .. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and utilities.is_set (Docket) then		-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	if utilities.is_set (URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URL_origin, UrlAccess );
	end

	local Quote = A['Quote'];
	local TransQuote = A['TransQuote'];
	local ScriptQuote = A['ScriptQuote'];
	if utilities.is_set (Quote) or utilities.is_set (TransQuote) or utilities.is_set (ScriptQuote) then

		if utilities.is_set (Quote) then
			if Quote:sub(1, 1) == '&quot;' and Quote:sub(-1, -1) == '&quot;' then			-- if first and last characters of quote are quote marks
				Quote = Quote:sub(2, -2);										-- strip them off
			end
		end
		
		Quote = kern_quotes (Quote);											-- kern if needed
		Quote = utilities.wrap_style ('quoted-text', Quote );					-- wrap in &lt;q&gt;...&lt;/q&gt; tags
	
		if utilities.is_set (ScriptQuote) then
			Quote = script_concatenate (Quote, ScriptQuote, 'script-quote');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after quote is wrapped
		end

		if utilities.is_set (TransQuote) then
			if TransQuote:sub(1, 1) == '&quot;' and TransQuote:sub(-1, -1) == '&quot;' then -- if first and last characters of |trans-quote are quote marks
				TransQuote = TransQuote:sub(2, -2); -- strip them off
			end
			Quote = Quote .. &quot; &quot; .. utilities.wrap_style ('trans-quoted-title', TransQuote );
		end

		if utilities.is_set (QuotePage) or utilities.is_set (QuotePages) then	-- add page prefix
			local quote_prefix = '';
			if utilities.is_set (QuotePage) then
				extra_text_in_page_check (QuotePage, 'quote-page');				-- add to maint cat if |quote-page= value begins with what looks like p., pp., etc.
				if not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePage}), '', '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePage}), '', '', '';
				end
			elseif utilities.is_set (QuotePages) then
				extra_text_in_page_check (QuotePages, 'quote-pages');			-- add to maint cat if |quote-pages= value begins with what looks like p., pp., etc.
				if tonumber(QuotePages) ~= nil and not NoPP then				-- if only digits, assume single page
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePages}), '', '';
				elseif not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['pp-prefix'], {sepc, QuotePages}), '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePages}), '', '';
				end
			end
                        
			Quote = quote_prefix .. &quot;: &quot; .. Quote;
		else
			Quote = sepc .. &quot; &quot; .. Quote;
		end

		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	-- We check length of PostScript here because it will have been nuked by
	-- the quote parameters. We'd otherwise emit a message even if there wasn't
	-- a displayed postscript.
	-- TODO: Should the max size (1) be configurable?
	-- TODO: Should we check a specific pattern?
	if utilities.is_set(PostScript) and mw.ustring.len(PostScript) &gt; 1 then
		utilities.set_message ('maint_postscript')
	end
	
	local Archived;
	if utilities.is_set (ArchiveURL) then
		if not utilities.is_set (ArchiveDate) then								-- ArchiveURL set but ArchiveDate not set
			utilities.set_message ('err_archive_missing_date');					-- emit an error message
			ArchiveURL = '';													-- empty string for concatenation
			ArchiveDate = '';													-- empty string for concatenation
		end
	else														
		if utilities.is_set (ArchiveDate) then									-- ArchiveURL not set but ArchiveDate is set
			utilities.set_message ('err_archive_date_missing_url');				-- emit an error message
			ArchiveURL = '';													-- empty string for concatenation
			ArchiveDate = '';													-- empty string for concatenation
		end
	end

	if utilities.is_set (ArchiveURL) then
		local arch_text;
--		if not utilities.is_set (ArchiveDate) then
--			utilities.set_message ('err_archive_missing_date');
--			ArchiveDate = '';													-- empty string for concatenation
--		end
		if &quot;live&quot; == UrlStatus then
			arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if utilities.is_set (ArchiveDate) then
				Archived = sepc .. ' ' .. utilities.substitute ( cfg.messages['archived-live'],
					{external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil) .. ArchiveFormat, ArchiveDate } );
			else
				Archived = '';
			end
			if not utilities.is_set (OriginalURL) then
				utilities.set_message ('err_archive_missing_url');
				Archived = '';													-- empty string for concatenation
			end
		elseif utilities.is_set (OriginalURL) then								-- UrlStatus is empty, 'dead', 'unfit', 'usurped', 'bot: unknown'
			if utilities.in_array (UrlStatus, {'unfit', 'usurped', 'bot: unknown'}) then
				arch_text = cfg.messages['archived-unfit'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. ' ' .. arch_text .. ArchiveDate;				-- format already styled
				if 'bot: unknown' == UrlStatus then
					utilities.set_message ('maint_bot_unknown');				-- and add a category if not already added
				else
					utilities.set_message ('maint_unfit');						-- and add a category if not already added
				end
			else																-- UrlStatus is empty, 'dead'
				arch_text = cfg.messages['archived-dead'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				if utilities.is_set (ArchiveDate) then
					Archived = sepc .. &quot; &quot; .. utilities.substitute ( arch_text,
						{ external_link( OriginalURL, cfg.messages['original'], OriginalURL_origin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
				else
					Archived = '';												-- unset for concatenation
				end
			end	
		else																	-- OriginalUrl not set
			utilities.set_message ('err_archive_missing_url');
			Archived = '';														-- empty string for concatenation
		end
	elseif utilities.is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = '';
	end
	
--	local Lay = '';
--	local LaySource = A['LaySource'];
--	local LayURL = A['LayURL'];
--	local LayFormat = A['LayFormat'];
--	LayFormat = style_format (LayFormat, LayURL, 'lay-format', 'lay-url');
--	if utilities.is_set (LayURL) then
--		if utilities.is_set (LayDate) then LayDate = &quot; (&quot; .. LayDate .. &quot;)&quot; end
--		if utilities.is_set (LaySource) then 
--			LaySource = &quot; &amp;ndash; ''&quot; .. utilities.safe_for_italics (LaySource) .. &quot;''&quot;;
--		else
--			LaySource = &quot;&quot;;
--		end
--		if sepc == '.' then
--			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary'], A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
--		else
--			Lay = sepc .. &quot; &quot; .. external_link( LayURL, cfg.messages['lay summary']:lower(), A:ORIGIN('LayURL'), nil ) .. LayFormat .. LaySource .. LayDate
--		end			
--	elseif utilities.is_set (LayFormat) then									-- Test if |lay-format= is given without giving a |lay-url=
--		Lay = sepc .. LayFormat;												-- if set and LayURL not set, then LayFormat has error message
--	end

	local TranscriptURL = A['TranscriptURL']
	local TranscriptFormat = A['TranscriptFormat'];
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');
	local Transcript = A['Transcript'];
	local TranscriptURL_origin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL
	if utilities.is_set (Transcript) then
		if utilities.is_set (TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURL_origin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif utilities.is_set (TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURL_origin, nil );
	end

	local Publisher;
	if utilities.is_set (PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if utilities.is_set (PublisherName) then
		if utilities.is_set (PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif utilities.is_set (PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical)) then
		if utilities.is_set (Title) or utilities.is_set (TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		else 
			Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		end
	end
	
	local Language = A['Language'];
	if utilities.is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc.
	else
		Language='';															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then									-- cite speech only
		TitleNote = TitleType;													-- move TitleType to TitleNote so that it renders ahead of |event=
		TitleType = '';															-- and unset

		if utilities.is_set (Periodical) then									-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if utilities.is_set (Conference) then								-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;							-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
		if not (utilities.is_set (Authors) or utilities.is_set (Editors)) then
			Others = Others:gsub ('^' .. sepc .. ' ', '');						-- when no authors and no editors, strip leading sepc and space
		end
		if utilities.is_set (Others) then Others = safe_join ({Others, sepc .. &quot; &quot;}, sepc) end		-- add terminal punctuation &amp; space; check for dup sepc; TODO why do we need to do this here?
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (Periodical) then		-- special cases for book cites
		if utilities.is_set (Contributors) then									-- when we are citing foreword, preface, introduction, etc.
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if utilities.is_set (Chapter) then										-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif utilities.is_set (Periodical) then								-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local Via = A['Via'];
	Via = utilities.is_set (Via) and  wrap_msg ('via', Via) or '';
	local idcommon;
	if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then	-- special case for cite AV media &amp; cite episode position transcript
--		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, Lay, Quote }, sepc );
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, Quote }, sepc );
	else
--		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, Lay, Quote }, sepc );
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, Quote }, sepc );
	end
	
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	local OrigDate = A['OrigDate'];
	OrigDate = utilities.is_set (OrigDate) and wrap_msg ('origdate', OrigDate) or '';
	if utilities.is_set (Date) then
		if utilities.is_set (Authors) or utilities.is_set (Editors) then		-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date .. &quot;)&quot; .. OrigDate .. sepc .. &quot; &quot;;				-- in parentheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon, -1, -1) == sepc) then						-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigDate;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigDate;							-- Date begins with sepc
			end
		end
	end	
	if utilities.is_set (Authors) then
		if (not utilities.is_set (Date)) then									-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Editors) then
			local in_text = '';
			local post_text = '';
			if utilities.is_set (Chapter) and 0 == #c then
				in_text = cfg.messages['in'] .. ' ';
				if (sepc ~= '.') then
					in_text = in_text:lower();									-- lowercase for cs2
				end
			end
			if EditorCount &lt;= 1 then
				post_text = ' (' .. cfg.messages['editor'] .. ')';				-- be consistent with no-author, no-date case
			else
				post_text = ' (' .. cfg.messages['editors'] .. ')';
			end
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Contributors) then									-- book cite and we're citing the intro, preface, etc.
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if utilities.is_set (Editors) and utilities.is_set (Date) then		-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not utilities.is_set (Date)) then								-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif utilities.is_set (Editors) then
		if utilities.is_set (Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. cfg.presentation['sep_name'] .. cfg.messages['editor'];
			else
				Editors = Editors .. cfg.presentation['sep_name'] .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if utilities.is_set (PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc ); 								-- Deals with italics, spaces, etc.
		text = text:sub(1, -sepc:len() - 1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite&gt; element
	local options_t = {};
	options_t.class = cite_class_attribute_make (config.CitationClass, Mode);

	local Ref = is_valid_parameter_value (A['Ref'], A:ORIGIN('Ref'), cfg.keywords_lists['ref'], nil, true);	-- nil when |ref=harv; A['Ref'] else

	if 'none' ~= cfg.keywords_xlate[(Ref and Ref:lower()) or ''] then
		local namelist_t = {};													-- holds selected contributor, author, editor name list
		local year = first_set ({Year, anchor_year}, 2);						-- Year first for legacy citations and for YMD dates that require disambiguation

		if #c &gt; 0 then															-- if there is a contributor list
			namelist_t = c;														-- select it
		elseif #a &gt; 0 then														-- or an author list
			namelist_t = a;
		elseif #e &gt; 0 then														-- or an editor list
			namelist_t = e;
		end
		local citeref_id;
		if #namelist_t &gt; 0 then													-- if there are names in namelist_t
			citeref_id = make_citeref_id (namelist_t, year);					-- go make the CITEREF anchor
			if mw.uri.anchorEncode (citeref_id) == ((Ref and mw.uri.anchorEncode (Ref)) or '') then	-- Ref may already be encoded (by {{sfnref}}) so citeref_id must be encoded before comparison
				utilities.set_message ('maint_ref_duplicates_default');
			end
		else
			citeref_id = '';													-- unset
		end
		options_t.id = Ref or citeref_id;
	end

	if string.len (text:gsub('%b&lt;&gt;', '')) &lt;= 2 then								-- remove html and html-like tags; then get length of what remains; 
		z.error_cats_t = {};													-- blank the categories list
		z.error_msgs_t = {};													-- blank the error messages list
		OCinSoutput = nil;														-- blank the metadata string
		text = '';																-- blank the the citation
		utilities.set_message ('err_empty_citation');							-- set empty citation message and category
	end
	
	local render_t = {};														-- here we collect the final bits for concatenation into the rendered citation

	if utilities.is_set (options_t.id) then										-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render_t, utilities.substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options_t.id), mw.text.nowiki(options_t.class), text}));	-- when |ref= is set or when there is a namelist
	else
		table.insert (render_t, utilities.substitute (cfg.presentation['cite'], {mw.text.nowiki(options_t.class), text}));	-- when |ref=none or when namelist_t empty and |ref= is missing or is empty
	end		

	if OCinSoutput then															-- blanked when citation is 'empty' so don't bother to add boilerplate metadata span
		table.insert (render_t, utilities.substitute (cfg.presentation['ocins'], OCinSoutput));	-- format and append metadata to the citation
	end

	local template_name = ('citation' == config.CitationClass) and 'citation' or 'cite ' .. (cfg.citation_class_map_t[config.CitationClass] or config.CitationClass);
	local template_link = '[[Template:' .. template_name .. '|' .. template_name .. ']]';
	local msg_prefix = '&lt;code class=&quot;cs1-code&quot;&gt;{{' .. template_link .. '}}&lt;/code&gt;: ';

	if 0 ~= #z.error_msgs_t then
		mw.addWarning (utilities.substitute (cfg.messages.warning_msg_e, template_link));

		table.insert (render_t, ' ');											-- insert a space between citation and its error messages
		table.sort (z.error_msgs_t);											-- sort the error messages list; sorting includes wrapping &lt;span&gt; and &lt;code&gt; tags; hidden-error sorts ahead of visible-error

		local hidden = true;													-- presume that the only error messages emited by this template are hidden
		for _, v in ipairs (z.error_msgs_t) do									-- spin through the list of error messages
			if v:find ('cs1-visible-error', 1, true) then						-- look for the visible error class name
				hidden = false;													-- found one; so don't hide the error message prefix
				break;															-- and done because no need to look further
			end
		end

		z.error_msgs_t[1] = table.concat ({utilities.error_comment (msg_prefix, hidden), z.error_msgs_t[1]});	-- add error message prefix to first error message to prevent extraneous punctuation
		table.insert (render_t, table.concat (z.error_msgs_t, '; '));			-- make a big string of error messages and add it to the rendering
	end

	if 0 ~= #z.maint_cats_t then
		mw.addWarning (utilities.substitute (cfg.messages.warning_msg_m, template_link));

		table.sort (z.maint_cats_t);											-- sort the maintenance messages list

		local maint_msgs_t = {};												-- here we collect all of the maint messages

		if 0 == #z.error_msgs_t then											-- if no error messages
			table.insert (maint_msgs_t, msg_prefix);							-- insert message prefix in maint message livery
		end
		
		for _, v in ipairs( z.maint_cats_t ) do									-- append maintenance categories
			table.insert (maint_msgs_t, 										-- assemble new maint message and add it to the maint_msgs_t table
				table.concat ({v, ' (', utilities.substitute (cfg.messages[':cat wikilink'], v), ')'})
				);
		end
		table.insert (render_t, utilities.substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs_t, ' ')));	-- wrap the group of maint messages with proper presentation and save
	end

	if not no_tracking_cats then
		for _, v in ipairs (z.error_cats_t) do									-- append error categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
		end
		for _, v in ipairs (z.maint_cats_t) do									-- append maintenance categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
		end
		for _, v in ipairs (z.prop_cats_t) do									-- append properties categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));
		end
	end

	return table.concat (render_t);												-- make a big string and done
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class, empty)
	local name = tostring (name);
	local enum_name;															-- parameter name with enumerator (if any) replaced with '#'
	local state;
	local function state_test (state, name)										-- local function to do testing of state values
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			if empty then return nil; end										-- empty deprecated parameters are treated as unknowns
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
		if 'tracked' == state then
			local base_name = name:gsub ('%d', '');								-- strip enumerators from parameter names that have them to get the base name
			utilities.add_prop_cat ('tracked-param', {base_name}, base_name);	-- add a properties category; &lt;base_name&gt; modifies &lt;key&gt;
			return true;
		end
		return nil;
	end		

	if name:find ('#') then														-- # is a cs1|2 reserved character so parameters with # not permitted
		return nil;
	end
																				-- replace wnumerator digit(s) with # (|last25= becomes |last#=) (mw.ustring because non-Western 'local' digits)
	enum_name = mw.ustring.gsub (name, '%d+$', '#');							-- where enumerator is last charaters in parameter name (these to protect |s2cid=)
	enum_name = mw.ustring.gsub (enum_name, '%d+([%-l])', '#%1');				-- where enumerator is in the middle of the parameter name; |author#link= is the oddity

	if 'document' == cite_class then											-- special case for {{cite document}}
		state = whitelist.document_parameters_t[enum_name];						-- this list holds enumerated and nonenumerated parameters
		if true == state_test (state, name) then return true; end
		
		return false;
	end

	if utilities.in_array (cite_class, whitelist.preprint_template_list_t) then	-- limited parameter sets allowed for these templates
		state = whitelist.limited_parameters_t[enum_name];						-- this list holds enumerated and nonenumerated parameters
		if true == state_test (state, name) then return true; end

		state = whitelist.preprint_arguments_t[cite_class][name];				-- look in the parameter-list for the template identified by cite_class
		if true == state_test (state, name) then return true; end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates

	if utilities.in_array (cite_class, whitelist.unique_param_template_list_t) then 	-- template-specific parameters for templates that accept parameters from the basic argument list
		state = whitelist.unique_arguments_t[cite_class][name];					-- look in the template-specific parameter-lists for the template identified by cite_class
		if true == state_test (state, name) then return true; end
	end																			-- if here, fall into general validation

	state = whitelist.common_parameters_t[enum_name];							-- all other templates; all normal parameters allowed; this list holds enumerated and nonenumerated parameters
	if true == state_test (state, name) then return true; end

	return false;																-- not supported because not found or name is set to nil
end


--[=[-------------------------&lt; I N T E R _ W I K I _ C H E C K &gt;----------------------------------------------

check &lt;value&gt; for inter-language interwiki-link markup.  &lt;prefix&gt; must be a MediaWiki-recognized language
code.  when these values have the form (without leading colon):
	[[&lt;prefix&gt;:link|label]] return label as plain-text
	[[&lt;prefix&gt;:link]] return &lt;prefix&gt;:link as plain-text

return value as is else

]=]

local function inter_wiki_check (parameter, value)
	local prefix = value:match ('%[%[(%a+):');									-- get an interwiki prefix if one exists
	local _;
	
	if prefix and cfg.inter_wiki_map[prefix:lower()] then						-- if prefix is in the map, needs preceding colon so
		utilities.set_message ('err_bad_paramlink', parameter);					-- emit an error message
		_, value, _ = utilities.is_wikilink (value);							-- extract label portion from wikilink
	end
	return value;
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe.  There are two tests made:
	{{cite ... |title=Title access-date=2016-03-17}}	-- the first parameter has a value and whitespace separates that value from the missing pipe parameter name
	{{cite ... |title=access-date=2016-03-17}}			-- the first parameter has no value (whitespace after the first = is trimmed by MediaWiki)
cs1|2 shares some parameter names with XML/HTML attributes: class=, title=, etc.  To prevent false positives XML/HTML
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (parameter, value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove XML/HTML tags because attributes: class=, title=, etc.

	capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then										-- if the capture is a valid parameter name
		utilities.set_message ('err_missing_pipe', parameter);
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ P U N C T &gt;--------------------------------------

look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_punc (param, value)
	if 'number' == type (param) then
		return;
	end
	
	param = param:gsub ('%d+', '#');											-- enumerated name-list mask params allow terminal punct; normalize 
	if cfg.punct_skip[param] then
		return;																	-- parameter name found in the skip table so done
	end
	
	if value:match ('[,;:]$') then
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
	if value:match ('^=') then													-- sometimes an extraneous '=' character appears ...
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ U R L &gt;------------------------------------------

look for extraneous url parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_url (url_param_t)
	local url_error_t = {};
	
	check_for_url (url_param_t, url_error_t);									-- extraneous url check
	if 0 ~= #url_error_t then													-- non-zero when there are errors
		table.sort (url_error_t);
		utilities.set_message ('err_param_has_ext_link', {utilities.make_sep_list (#url_error_t, url_error_t)});	-- add this error message
	end
end


--[[--------------------------&lt; C I T A T I O N &gt;--------------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

local function citation(frame)
	Frame = frame;																-- save a copy in case we need to display an error message in preview mode

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do											-- get parameters from the {{#invoke}} frame
		config[k] = v;
	--	args[k] = v;															-- crude debug support that allows us to render a citation from module {{#invoke:}}; skips parameter validation; TODO: keep?
	end	
																				-- i18n: set the name that your wiki uses to identify sandbox subpages from sandbox template invoke (or can be set here)
	local sandbox = ((config.SandboxPath and '' ~= config.SandboxPath) and config.SandboxPath) or '/sandbox';	-- sandbox path from {{#invoke:Citation/CS1/sandbox|citation|SandboxPath=/...}}
	is_sandbox = nil ~= string.find (frame:getTitle(), sandbox, 1, true);		-- is this invoke the sandbox module?
	sandbox = is_sandbox and sandbox or '';										-- use i18n sandbox to load sandbox modules when this module is the sandox; live modules else

	local pframe = frame:getParent()
	local styles;
	
	cfg = mw.loadData ('Module:Citation/CS1/Configuration' .. sandbox);			-- load sandbox versions of support modules when {{#invoke:Citation/CS1/sandbox|...}}; live modules else
	whitelist = mw.loadData ('Module:Citation/CS1/Whitelist' .. sandbox);
	utilities = require ('Module:Citation/CS1/Utilities' .. sandbox);
	validation = require ('Module:Citation/CS1/Date_validation' .. sandbox);
	identifiers = require ('Module:Citation/CS1/Identifiers' .. sandbox);
	metadata = require ('Module:Citation/CS1/COinS' .. sandbox);
	styles = 'Module:Citation/CS1' .. sandbox .. '/styles.css';

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the selected cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	is_preview_mode = not utilities.is_set (frame:preprocess ('{{REVISIONID}}'));

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text;															-- used as a flag

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	local empty_unknowns = {};													-- sequence table to hold empty unknown params for error message listing
	for k, v in pairs( pframe.args ) do											-- get parameters from the parent (template) frame
		v = mw.ustring.gsub (v, '^%s*(.-)%s*$', '%1');							-- trim leading/trailing whitespace; when v is only whitespace, becomes empty string
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				if type (k) ~= 'string' then									-- exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text = utilities.set_message ('err_text_ignored', {v});
					end
				elseif validate (k:lower(), config.CitationClass) then 
					error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, k:lower()});	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						suggestions = mw.loadData ('Module:Citation/CS1/Suggestions' .. sandbox);	--load sandbox version of suggestion module when {{#invoke:Citation/CS1/sandbox|...}}; live module else
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no capture in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = utilities.substitute (param, capture);		-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, param});	-- set the suggestion error message
							else
								error_text = utilities.set_message ('err_parameter_ignored', {k});	-- suggested param not supported by this template
								v = '';											-- unset
							end
						end
					end
					if not utilities.is_set (error_text) then					-- couldn't match with a pattern, is there an explicit suggestion?						
						if (suggestions.suggestions[ k:lower() ] ~= nil) and validate (suggestions.suggestions[ k:lower() ], config.CitationClass) then
							utilities.set_message ('err_parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]});
						else
							utilities.set_message ('err_parameter_ignored', {k});
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
			end

			args[k] = v;														-- save this parameter and its value

		elseif not utilities.is_set (v) then									-- for empty parameters
			if not validate (k, config.CitationClass, true) then				-- is this empty parameter a valid parameter
				k = ('' == k) and '(empty string)' or k;						-- when k is empty string (or was space(s) trimmed to empty string), replace with descriptive text
				table.insert (empty_unknowns, utilities.wrap_style ('parameter', k));	-- format for error message and add to the list
			end
																				-- crude debug support that allows us to render a citation from module {{#invoke:}} TODO: keep?
	--	elseif args[k] ~= nil or (k == 'postscript') then						-- when args[k] has a value from {{#invoke}} frame (we don't normally do that)
	--		args[k] = v;														-- overwrite args[k] with empty string from pframe.args[k] (template frame); v is empty string here
		end																		-- not sure about the postscript bit; that gets handled in parameter validation; historical artifact?
	end	

	if 0 ~= #empty_unknowns then												-- create empty unknown error message
		utilities.set_message ('err_param_unknown_empty', {
			1 == #empty_unknowns and '' or 's',
			utilities.make_sep_list (#empty_unknowns, empty_unknowns)
			});
	end

	local url_param_t = {};

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);											-- look for invisible characters
		end
		has_extraneous_punc (k, v);												-- look for extraneous terminal punctuation in parameter values
		missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?
		args[k] = inter_wiki_check (k, v);										-- when language interwiki-linked parameter missing leading colon replace with wiki-link label

		if 'string' == type (k) and not cfg.url_skip[k] then					-- when parameter k is not positional and not in url skip table
			url_param_t[k] = v;													-- make a parameter/value list for extraneous url check
		end
	end

	has_extraneous_url (url_param_t);											-- look for url in parameter values where a url does not belong

	return table.concat ({
		frame:extensionTag ('templatestyles', '', {src=styles}),
		citation0( config, args)
	});
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {citation = citation};</text>
      <sha1>0g1meawhunmjmr91m6m0k5lv7p6or5e</sha1>
    </revision>
    <revision>
      <id>4753</id>
      <parentid>4752</parentid>
      <timestamp>2023-11-25T16:42:17Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4753</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="224915" sha1="1hbbjps2hgnrxlwzaes2de7t1ul73f4" xml:space="preserve">require ('strict');

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------

each of these counts against the Lua upvalue limit

]]

local validation;																-- functions in Module:Citation/CS1/Date_validation

local utilities;																-- functions in Module:Citation/CS1/Utilities
local z = {};																	-- table of tables in Module:Citation/CS1/Utilities

local identifiers;																-- functions and tables in Module:Citation/CS1/Identifiers
local metadata;																	-- functions in Module:Citation/CS1/COinS
local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;---------------

declare variables here that have page-wide scope that are not brought in from
other modules; that are created here and used here

]]

local added_deprecated_cat;														-- Boolean flag so that the category is added only once
local added_vanc_errs;															-- Boolean flag so we only emit one Vancouver error / category
local added_generic_name_errs;													-- Boolean flag so we only emit one generic name error / category and stop testing names once an error is encountered
local added_numeric_name_errs;													-- Boolean flag so we only emit one numeric name error / category and stop testing names once an error is encountered
local added_numeric_name_maint;													-- Boolean flag so we only emit one numeric name maint category and stop testing names once a category has been emitted
local Frame;																	-- holds the module's frame table
local is_preview_mode;															-- true when article is in preview mode; false when using 'Preview page with this template' (previewing the module)
local is_sandbox;																-- true when using sandbox modules to render citation


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if utilities.is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a Boolean declared in page scope variables above

]]

local function add_vanc_error (source, position)
	if added_vanc_errs then return end
		
	added_vanc_errs = true;														-- note that we've added this category
	utilities.set_message ('err_vancouver', {source, position});
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a URI scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of TLDs: https://www.iana.org/domains/root/db

RFC 952 (modified by RFC 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the TLD.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a URL with a scheme) will be stripped
here.  Perhaps not necessary but retained in case it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ASCII characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the TLD) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and TLD or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%w]') then											-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at Wikisource
		return false;
	end

	local patterns = {															-- patterns that look like URLs
		'%f[%w][%w][%w%-]+[%w]%.%a%a+$',										-- three or more character hostname.hostname or hostname.tld
		'%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$',									-- internationalized domain name with ACE prefix
		'%f[%a][qxz]%.com$',													-- assigned one character .com hostname (x.com times out 2015-12-10)
		'%f[%a][iq]%.net$',														-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		'%f[%w][%w]%.%a%a$',													-- one character hostname and ccTLD (2 chars)
		'%f[%w][%w][%w]%.%a%a+$',												-- two character hostname and TLD
		'^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?',								-- IPv4 address
		}

	for _, pattern in ipairs (patterns) do										-- loop through the patterns list
		if domain:match (pattern) then
			return true;														-- if a match then we think that this thing that purports to be a URL is a URL
		end
	end

	for _, d in ipairs (cfg.single_letter_2nd_lvl_domains_t) do					-- look for single letter second level domain names for these top level domains
		if domain:match ('%f[%w][%w]%.' .. d) then
			return true
		end
	end
	return false;																-- no matches, we don't know what this thing is
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a URL appear to be a valid URL; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if utilities.is_set (scheme) then											-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when URL is protocol-relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a URL into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following TLD) (if any) and any path(/), query(?) or fragment(#).

If protocol-relative URL, return nil scheme and domain else return nil for both scheme and domain.

When not protocol-relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Any URL that does not have news: scheme must have authority indicator (//).  TODO: are there other common schemes
like news: that don't use authority indicator?

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol-relative URL
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		if utilities.is_set (authority) then
			authority = authority:gsub ('//', '', 1);							-- replace place 1 pair of '/' with nothing;
			if utilities.is_set(authority) then									-- if anything left (1 or 3+ '/' where authority should be) then
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		else
			if not scheme:match ('^news:') then									-- except for news:..., MediaWiki won't link URLs that do not have authority indicator; TODO: a better way to do this test?
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link=, etc. for properly formatted content: no wikilinks, no URLs

Link parameters are to hold the title of a Wikipedia article, so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki URLs and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid URL (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid URL (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from URL; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid URL
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wiki-linked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

check &lt;link&gt; for inter-language interwiki-link prefix.  prefix must be a MediaWiki-recognized language
code and must begin with a colon.

]]

local function link_title_ok (link, lorig, title, torig)
	local orig;
	if utilities.is_set (link) then 											-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		elseif link:match ('^%a+:') then										-- if the link is what looks like an interwiki
			local prefix = link:match ('^(%a+):'):lower();						-- get the interwiki prefix

			if cfg.inter_wiki_map[prefix] then									-- if prefix is in the map, must have preceding colon
				orig = lorig;													-- flag as error
			end
		end
	end

	if utilities.is_set (orig) then
		link = '';																-- unset
		utilities.set_message ('err_bad_paramlink', orig);						-- URL or wikilink in |title= with |title-link=;
	end
	
	return link;																-- link if ok, empty string else
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the URL into scheme and domain
portions, or for protocol-relative (//example.com) URLs, just the domain.  Use is_url() to validate the two
portions of the URL.  If both are valid, or for protocol-relative if domain is valid, return true, else false.

Because it is different from a standard URL, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper URL
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from URL;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a URL.  The test will also find external wikilinks
that use protocol-relative URLs. Also finds bare URLs.

The frontier pattern prevents a match on interwiki-links which are similar to scheme:path URLs.  The tests that
find bracketed URLs are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext. wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol-relative ext. wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare URL with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol-relative bare URL: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a URL
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list, error_list)
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a URL add an error message
			table.insert (error_list, utilities.wrap_style ('parameter', k));
		end
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		utilities.set_message ('err_wikilink_in_url', {});
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link (URL, label, source, access)
	local err_msg = '';
	local domain;
	local path;
	local base_url;

	if not utilities.is_set (label) then
		label = URL;
		if utilities.is_set (source) then
			utilities.set_message ('err_bare_url_missing_title', {utilities.wrap_style ('parameter', source)});
		else
			error (cfg.messages[&quot;bare_url_no_origin&quot;]);							-- programmer error; valid parameter name does not have matching meta-parameter
		end			
	end
	if not check_url (URL) then
		utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)});
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the URL into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['['] = '%5b', [']'] = '%5d'});			-- replace '[' and ']' with their percent-encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat ({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wiki-markup URL

	if utilities.is_set (access) then											-- access level (subscription, registration, limited)
		base_url = utilities.substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end

	return base_url;
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a Boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		utilities.set_message ('err_deprecated_params', {name});				-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wiki-markup) are not kerned.

Replaces Unicode quote marks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc.; not for book titles.

]=]

local function kern_quotes (str)
	local cap = '';
	local wl_type, label, link;

	wl_type, label, link = utilities.is_wikilink (str);							-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-left'], str);
			str = utilities.substitute (cfg.presentation['kern-right'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = utilities.substitute (cfg.presentation['kern-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label = mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label = mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap = mw.ustring.match (label, &quot;^([\&quot;\'][^\'].+)&quot;);						-- match leading double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-left'], cap);
		end
	
		cap = mw.ustring.match (label, &quot;^(.+[^\'][\&quot;\'])$&quot;)						-- match trailing double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-right'], cap);
		end
		
		if 2 == wl_type then
			str = utilities.make_wikilink (link, label);						-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin-based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate RTL languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO 639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO 639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title=, |script-chapter=, |script-&lt;periodical&gt;=

]]

local function format_script_value (script_value, script_param)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%l?%s*:') then									-- if first 3 or 4 non-space characters are script language prefix
		lang = script_value:match('^(%l%l%l?)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not utilities.is_set (lang) then
			utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['missing title part']});		-- prefix without 'title'; add error message
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_tag_remap[lang] or mw.language.fetchLanguageName( lang, cfg.this_wiki_code );	-- get language name so that we can use it to categorize
		if utilities.is_set (name) then											-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l+%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if utilities.in_array (lang, cfg.script_lang_codes) then
				utilities.add_prop_cat ('script', {name, lang})
			else
				utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['unknown language code']});	-- unknown script-language; add error message
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['invalid language code']});		-- invalid language code; add error message
			lang = '';															-- invalid so set lang to empty string
		end
	else
		utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['missing prefix']});				-- no language code prefix; add error message
	end
	script_value = utilities.substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is RTL

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script
value has been wrapped in &lt;bdi&gt; tags.

]]

local function script_concatenate (title, script, script_param)
	if utilities.is_set (script) then
		script = format_script_value (script, script_param);					-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; returns empty string on error
		if utilities.is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not utilities.is_set ( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return utilities.substitute ( msg, str );								-- including template text
	else
		return utilities.substitute ( cfg.messages[key], str );
	end		
end


--[[----------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;-------------------

Makes a Wikisource URL from Wikisource interwiki-link.  Returns the URL and appropriate
label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;
	local wikisource_prefix = table.concat ({'https://', cfg.this_wiki_code, '.wikisource.org/wiki/'});

	wl_type, D, L = utilities.is_wikilink (str);								-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 1 == wl_type then													-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end

	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable URL
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent-encoding of fragment marker
	end

	return ws_url, ws_label, L or D;											-- return proper URL or nil and a label or nil
end


--[[----------------&lt; F O R M A T _ P E R I O D I C A L &gt;-----------------------

Format the three periodical parameters: |script-&lt;periodical&gt;=, |&lt;periodical&gt;=,
and |trans-&lt;periodical&gt;= into a single Periodical meta-parameter.

]]

local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)

	if not utilities.is_set (periodical) then
		periodical = '';														-- to be safe for concatenation
	else
		periodical = utilities.wrap_style ('italic-title', periodical);			-- style 
	end

	periodical = script_concatenate (periodical, script_periodical, script_periodical_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (trans_periodical) then
		trans_periodical = utilities.wrap_style ('trans-italic-title', trans_periodical);
		if utilities.is_set (periodical) then
			periodical = periodical .. ' ' .. trans_periodical;
		else																	-- here when trans-periodical without periodical or script-periodical
			periodical = trans_periodical;
			utilities.set_message ('err_trans_missing_title', {'periodical'});
		end
	end

	return periodical;
end


--[[------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;---------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=,
and |chapter-url= into a single chapter meta- parameter (chapter_url_source used
for error messages).

]]

local function format_chapter_title (script_chapter, script_chapter_source, chapter, chapter_source, trans_chapter, trans_chapter_source, chapter_url, chapter_url_source, no_quotes, access)
	local ws_url, ws_label, L = wikisource_url_make (chapter);					-- make a wikisource URL and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', ' ');									-- replace underscore separators with space characters
		chapter = ws_label;
	end

	if not utilities.is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from module provided quote marks
			chapter = utilities.wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, script_chapter, script_chapter_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (chapter_url) then
		chapter = external_link (chapter_url, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');	-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if utilities.is_set (trans_chapter) then
		trans_chapter = utilities.wrap_style ('trans-quoted-title', trans_chapter);
		if utilities.is_set (chapter) then
			chapter = chapter .. ' ' .. trans_chapter;
		else																	-- here when trans_chapter without chapter or script-chapter
			chapter = trans_chapter;
			chapter_source = trans_chapter_source:match ('trans%-?(.+)');		-- when no chapter, get matching name from trans-&lt;param&gt;
			utilities.set_message ('err_trans_missing_title', {chapter_source});
		end
	end

	return chapter;
end


--[[----------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;-------------------

This function searches a parameter's value for non-printable or invisible characters.
The search stops at the first match.

This function will detect the visible replacement character when it is part of the Wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers
(gallery, math, pre, ref) and identifies them with a slightly different error message.
See also coins_cleanup().

Output of this function is an error message that identifies the character or the
Unicode group, or the stripmarker that was detected along with its position (or,
for multi-byte characters, the position of its first byte) in the parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local stripmarker;															-- boolean set true when a stripmarker is found

	capture = string.match (v, '[%w%p ]*');										-- test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no Unicode characters
		return;
	end

	for _, invisible_char in ipairs (cfg.invisible_chars) do
		local char_name = invisible_char[1];									-- the character or group name
		local pattern = invisible_char[2];										-- the pattern used to find it
		position, _, capture = mw.ustring.find (v, pattern);					-- see if the parameter value contains characters that match the pattern
		
		if position and (cfg.invisible_defs.zwj == capture) then				-- if we found a zero-width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- it's ok if one of the Indic scripts
				position = nil;													-- unset position
			elseif cfg.emoji_t[mw.ustring.codepoint (v, position+1)] then			-- is zwj followed by a character listed in emoji{}?
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and utilities.in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and cfg.invisible_defs.del == capture then	-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture and not (cfg.invisible_defs.del == capture or cfg.invisible_defs.zwj == capture) then
					err_msg = capture .. ' ' .. char_name;
				else
					err_msg = char_name .. ' ' .. 'character';
				end

				utilities.set_message ('err_invisible_char', {err_msg, utilities.wrap_style ('parameter', param), position});	-- add error message
				return;															-- and done with this parameter
			end
		end
	end
end


--[[-------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------

Argument wrapper.  This function provides support for argument mapping defined
in the configuration file so that multiple names can be transparently aliased to
single internal variable.

]]

local function argument_wrapper ( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function ( self, k )
			local dummy = self[k];												-- force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = utilities.select_one ( args, list, 'err_redundant_parameters' );
				if origin[k] == nil then
					origin[k] = '';												-- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] .. ': ' .. k);
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;-------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.
When date is DD MMMM YYYY or is MMMM DD, YYYY then wrap in nowrap span:
&lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap = '';
	local cap2 = '';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = utilities.substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = utilities.substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;---------------------

This function sets default title types (equivalent to the citation including
|type=&lt;default value&gt;) for those templates that have defaults. Also handles the
special case where it is desirable to omit the title type from the rendered citation
(|type=none).

]]

local function set_titletype (cite_class, title_type)
	if utilities.is_set (title_type) then
		if 'none' == cfg.keywords_xlate[title_type] then
			title_type = '';													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; S A F E _ J O I N &gt;-----------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'duplicate character'
		if 1 == #duplicate_char then											-- for single byte ASCII characters use the string library functions
			f.gsub = string.gsub
			f.match = string.match
			f.sub = string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub = mw.ustring.gsub
			f.match = mw.ustring.match
			f.sub = mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1, 1) == '&lt;' then										-- special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove HTML markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1, 1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc.?
				trim = false;
				end_chr = f.sub(str, -1, -1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr .. &quot;)&quot;				-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1, -2);									-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;''&quot; then		-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5, -1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;]]&quot; then		-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3, -1) == duplicate_char .. '&quot;]' then	-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2, -1) == duplicate_char .. &quot;]&quot; then	-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2, -1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1, -3);								-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains HTML markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows HTML markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value; 												-- add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;-----------------------------

returns true if suffix is properly formed Jr, Sr, or ordinal in the range 1–9.
Puncutation not allowed.

]]

local function is_suffix (suffix)
	if utilities.in_array (suffix, {'Jr', 'Sr', 'Jnr', 'Snr', '1st', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;-------------------

For Vancouver style, author/editor names are supposed to be rendered in Latin
(read ASCII) characters.  When a name uses characters that contain diacritical
marks, those characters are to be converted to the corresponding Latin
character. When a name is written using a non-Latin alphabet or logogram, that
name is to be transliterated into Latin characters. The module doesn't do this
so editors may/must.

This test allows |first= and |last= names to contain any of the letters defined
in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes.
	(http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;)
	or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written outside of the code editor and pasted here because the code editor
gets confused between character insertion point and cursor position. The test has
been rewritten to use decimal character escape sequence for the individual bytes
of the Unicode characters so that it is not necessary to use an external editor
to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first, suffix, position)
	if not suffix then
		if first:find ('[,%s]') then											-- when there is a space or comma, might be first name/initials + generational suffix
			first = first:match ('(.-)[,%s]+');									-- get name/initials
			suffix = first:match ('[,%s]+(.+)$');								-- get generational suffix
		end
	end
	if utilities.is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error (cfg.err_msg_supl.suffix, position);
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143%-%s%'%.]*$&quot;) then
			add_vanc_error (cfg.err_msg_supl['non-Latin char'], position);
			return false;														-- not a string of Latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-style=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period.
See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc.) to be rendered
as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format
because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the
Unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials(first, position)
	local name, suffix = mw.ustring.match(first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match(first, &quot;^(%u+)$&quot;);								-- is it just initials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error (cfg.err_msg_supl.suffix, position);			-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word

	local initials, names = {}, {};												-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names = mw.text.split (first, '[%s,]+');									-- split into a table of names and possible suffix

	while names[i] do															-- loop through the table
		if 1 &lt; i and names[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names[i] = names[i]:gsub ('%.', '');								-- remove terminal dot if present
			if is_suffix (names[i]) then										-- if a legitimate suffix
				table.insert (initials, ' ' .. names[i]);						-- add a separator space, insert at end of initials table
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials, mw.ustring.sub(names[i], 1, 1));			-- insert the initial at end of initials table
		end
		i = i + 1;																-- bump the counter
	end
			
	return table.concat(initials)												-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; I N T E R W I K I _ P R E F I X E N _ G E T &gt;----------------------------------

extract interwiki prefixen from &lt;value&gt;.  Returns two one or two values:
	false – no prefixen
	nil – prefix exists but not recognized
	project prefix, language prefix – when value has either of:
		:&lt;project&gt;:&lt;language&gt;:&lt;article&gt;
		:&lt;language&gt;:&lt;project&gt;:&lt;article&gt;
	project prefix, nil – when &lt;value&gt; has only a known single-letter prefix
	nil, language prefix – when &lt;value&gt; has only a known language prefix

accepts single-letter project prefixen: 'd' (wikidata), 's' (wikisource), and 'w' (wikipedia) prefixes; at this
writing, the other single-letter prefixen (b (wikibook), c (commons), m (meta), n (wikinews), q (wikiquote), and
v (wikiversity)) are not supported.

]]

local function interwiki_prefixen_get (value, is_link)
	if not value:find (':%l+:') then											-- if no prefix
		return false;															-- abandon; boolean here to distinguish from nil fail returns later
	end

	local prefix_patterns_linked_t = {											-- sequence of valid interwiki and inter project prefixen
		'^%[%[:([dsw]):(%l%l+):',												-- wikilinked; project and language prefixes
		'^%[%[:(%l%l+):([dsw]):',												-- wikilinked; language and project prefixes
		'^%[%[:([dsw]):',														-- wikilinked; project prefix
		'^%[%[:(%l%l+):',														-- wikilinked; language prefix
		}
		
	local prefix_patterns_unlinked_t = {										-- sequence of valid interwiki and inter project prefixen
		'^:([dsw]):(%l%l+):',													-- project and language prefixes
		'^:(%l%l+):([dsw]):',													-- language and project prefixes
		'^:([dsw]):',															-- project prefix
		'^:(%l%l+):',															-- language prefix
		}
	
	local cap1, cap2;
	for _, pattern in ipairs ((is_link and prefix_patterns_linked_t) or prefix_patterns_unlinked_t) do
		cap1, cap2 = value:match (pattern);
		if cap1 then
			break;																-- found a match so stop looking
		end
	end
	
	if cap1 and cap2 then														-- when both then :project:language: or :language:project: (both forms allowed)
		if 1 == #cap1 then														-- length == 1 then :project:language:
			if cfg.inter_wiki_map[cap2] then									-- is language prefix in the interwiki map?
				return cap1, cap2;												-- return interwiki project and interwiki language
			end
		else																	-- here when :language:project:
			if cfg.inter_wiki_map[cap1] then									-- is language prefix in the interwiki map?
				return cap2, cap1;												-- return interwiki project and interwiki language
			end
		end
		return nil;																-- unknown interwiki language
	elseif not (cap1 or cap2) then												-- both are nil?
		return nil;																-- we got something that looks like a project prefix but isn't; return fail
	elseif 1 == #cap1 then														-- here when one capture
		return cap1, nil;														-- length is 1 so return project, nil language
	else																		-- here when one capture and its length it more than 1
		if cfg.inter_wiki_map[cap1] then										-- is language prefix in the interwiki map?
			return nil, cap1;													-- return nil project, language
		end
	end
end


--[[--------------------------&lt; L I S T _ P E O P L E &gt;--------------------------

Formats a list of people (authors, contributors, editors, interviewers, translators) 

names in the list will be linked when
	|&lt;name&gt;-link= has a value
	|&lt;name&gt;-mask- does NOT have a value; masked names are presumed to have been
		rendered previously so should have been linked there

when |&lt;name&gt;-mask=0, the associated name is not rendered

]]

local function list_people (control, people, etal)
	local sep;
	local namesep;
	local format = control.format;
	local maximum = control.maximum;
	local name_list = {};

	if 'vanc' == format then													-- Vancouver-like name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between names is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between names is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub (-1, -1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if utilities.is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end		-- returned 0 is for EditorCount; not used for other names
	
	for i, person in ipairs (people) do
		if utilities.is_set (person.last) then
			local mask = person.mask;
			local one;
			local sep_one = sep;

			if utilities.is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			end
			
			if mask then
				local n = tonumber (mask);										-- convert to a number if it can be converted; nil else
				if n then
					one = 0 ~= n and string.rep(&quot;&amp;mdash;&quot;, n) or nil;			-- make a string of (n &gt; 0) mdashes, nil else, to replace name
					person.link = nil;											-- don't create link to name if name is replaces with mdash string or has been set nil
				else
					one = mask;													-- replace name with mask text (must include name-list separator)
					sep_one = &quot; &quot;;												-- modify name-list separator
				end
			else
				one = person.last;												-- get surname
				local first = person.first										-- get given name
				if utilities.is_set (first) then
					if (&quot;vanc&quot; == format) then									-- if Vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first, nil, i) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials (first, i);				-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
			end
			if utilities.is_set (person.link) then
				one = utilities.make_wikilink (person.link, one);				-- link author/editor
			end

			if one then															-- if &lt;one&gt; has a value (name, mdash replacement, or mask text replacement)
				local proj, tag = interwiki_prefixen_get (one, true);			-- get the interwiki prefixen if present

				if 'w' == proj and ('Wikipedia' == mw.site.namespaces.Project['name']) then
					proj = nil;													-- for stuff like :w:de:&lt;article&gt;, :w is unnecessary TODO: maint cat?
				end
				if proj then
					proj = ({['d'] = 'Wikidata', ['s'] = 'Wikisource', ['w'] = 'Wikipedia'})[proj];	-- :w (wikipedia) for linking from a non-wikipedia project
					if proj then 
						one = one .. utilities.wrap_style ('interproj', proj);	-- add resized leading space, brackets, static text, language name
						tag = nil;												-- unset; don't do both project and language
					end
				end
				if tag == cfg.this_wiki_code then
					tag = nil;													-- stuff like :en:&lt;article&gt; at en.wiki is pointless TODO: maint cat?
				end
				if tag then
					local lang = cfg.lang_tag_remap[tag] or cfg.mw_languages_by_tag_t[tag];
					if lang then												-- error messaging done in extract_names() where we know parameter names
						one = one .. utilities.wrap_style ('interwiki', lang);	-- add resized leading space, brackets, static text, language name
					end
				end

				table.insert (name_list, one);									-- add it to the list of names
				table.insert (name_list, sep_one);								-- add the proper name-list separator
			end
		end
	end

	local count = #name_list / 2;												-- (number of names + number of separators) divided by 2
	if 0 &lt; count then 
		if 1 &lt; count and not etal then
			if 'amp' == format then
				name_list[#name_list-2] = &quot; &amp; &quot;;								-- replace last separator with ampersand text
			elseif 'and' == format then
				if 2 == count then
					name_list[#name_list-2] = cfg.presentation.sep_nl_and;		-- replace last separator with 'and' text
				else
					name_list[#name_list-2] = cfg.presentation.sep_nl_end;		-- replace last separator with '(sep) and' text
				end
			end
		end
		name_list[#name_list] = nil;											-- erase the last separator
	end

	local result = table.concat (name_list);									-- construct list
	if etal and utilities.is_set (result) then									-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. cfg.messages['et al'];						-- we've got a last-first list and etal so add et al.
	end
	
	return result, count;														-- return name-list string and count of number of names (count used for editor names only)
end


--[[--------------------&lt; M A K E _ C I T E R E F _ I D &gt;-----------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise
returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that
order.  year is Year or anchor_year.

]]

local function make_citeref_id (namelist, year)
	local names={};							-- a table for the one to four names and year
	for i,v in ipairs (namelist) do			-- loop through the list and take up to the first four last names
		names[i] = v.last
		if i == 4 then break end			-- if four then done
	end
	table.insert (names, year);				-- add the year at the end
	local id = table.concat(names);			-- concatenate names and year for CITEREF id
	if utilities.is_set (id) then			-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;				-- add the CITEREF portion
	else
		return '';							-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; C I T E _ C L A S S _A T T R I B U T E _M A K E &gt;------------------------------

construct &lt;cite&gt; tag class attribute for this citation.

&lt;cite_class&gt; – config.CitationClass from calling template
&lt;mode&gt; – value from |mode= parameter

]]

local function cite_class_attribute_make (cite_class, mode)
	local class_t = {};
	table.insert (class_t, 'citation');											-- required for blue highlight
	if 'citation' ~= cite_class then
		table.insert (class_t, cite_class);										-- identify this template for user css
		table.insert (class_t, utilities.is_set (mode) and mode or 'cs1');		-- identify the citation style for user css or javascript
	else
		table.insert (class_t, utilities.is_set (mode) and mode or 'cs2');		-- identify the citation style for user css or javascript
	end
	for _, prop_key in ipairs (z.prop_keys_t) do
		table.insert (class_t, prop_key);										-- identify various properties for user css or javascript
	end

	return table.concat (class_t, ' ');											-- make a big string and done
end


--[[---------------------&lt; N A M E _ H A S _ E T A L &gt;--------------------------

Evaluates the content of name parameters (author, editor, etc.) for variations on
the theme of et al.  If found, the et al. is removed, a flag is set to true and
the function returns the modified name and the flag.

This function never sets the flag to false but returns its previous state because
it may have been set by previous passes through this function or by the associated
|display-&lt;names&gt;=etal parameter

]]

local function name_has_etal (name, etal, nocat, param)

	if utilities.is_set (name) then												-- name can be nil in which case just return
		local patterns = cfg.et_al_patterns; 									-- get patterns from configuration
		
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns
			if name:match (pattern) then										-- if this 'et al' pattern is found in name
				name = name:gsub (pattern, '');									-- remove the offending text
				etal = true;													-- set flag (may have been set previously here or by |display-&lt;names&gt;=etal)
				if not nocat then												-- no categorization for |vauthors=
					utilities.set_message ('err_etal', {param});				-- and set an error if not added
				end
			end
		end
	end

	return name, etal;
end


--[[---------------------&lt; N A M E _ I S _ N U M E R I C &gt;----------------------

Add an error message and category when &lt;name&gt; parameter value does not contain letters.  

Add a maintenance category when &lt;name&gt; parameter value has numeric characters mixed with characters that are 
not numeric characters; could be letters and/or punctuation characters.

This function will only emit one error and one maint message for the current template.  Does not emit both error
and maint messages/categories for the same parameter value.

returns nothing

]]

local function name_is_numeric (name, name_alias, list_name)
	local patterns = {
		'^%D+%d',																-- &lt;name&gt; must have digits preceded by other characters
		'^%D*%d+%D+',															-- &lt;name&gt; must have digits followed by other characters
		}

	if not added_numeric_name_errs and mw.ustring.match (name, '^[%A]+$') then	-- if we have not already set an error message and &lt;name&gt; does not have any alpha characters
		utilities.set_message ('err_numeric_names', name_alias);				-- add an error message
		added_numeric_name_errs = true;											-- set the flag so we emit only one error message
		return;																	-- when here no point in further testing; abandon
	end

	if not added_numeric_name_maint then										-- if we have already set a maint message
		for _, pattern in ipairs (patterns) do									-- spin through list of patterns
			if mw.ustring.match (name, pattern) then							-- digits preceded or followed by anything but digits; %D+ includes punctuation
				utilities.set_message ('maint_numeric_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
				added_numeric_name_maint = true;								-- set the flag so we emit only one maint message
				return;															-- when here no point in further testing; abandon
			end
		end
	end
end


--[[-----------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;------------------

Evaluates the content of last/surname (authors etc.) parameters for multiple names.
Multiple names are indicated if there is more than one comma or any &quot;unescaped&quot;
semicolons. Escaped semicolons are ones used as part of selected HTML entities.
If the condition is met, the function adds the multiple name maintenance category.

Same test for first except that commas should not appear in given names (MOS:JR says
that the generational suffix does not take a separator character).  Titles, degrees,
postnominals, affiliations, all normally comma separated don't belong in a citation.

&lt;name&gt; – name parameter value
&lt;list_name&gt; – AuthorList, EditorList, etc
&lt;limit&gt; – number of allowed commas; 1 (default) for surnames; 0 for given names

returns nothing

]]

local function name_has_mult_names (name, list_name, limit)
	local _, commas, semicolons, nbsps;
	limit = limit and limit or 1;
	if utilities.is_set (name) then
		_, commas = name:gsub (',', '');										-- count the number of commas
		_, semicolons = name:gsub (';', '');									-- count the number of semicolons
		-- nbsps probably should be its own separate count rather than merged in
		-- some way with semicolons because Lua patterns do not support the
		-- grouping operator that regex does, which means there is no way to add
		-- more entities to escape except by adding more counts with the new
		-- entities
		_, nbsps = name:gsub ('&amp;nbsp;','');										-- count nbsps
		
		-- There is exactly 1 semicolon per &amp;nbsp; entity, so subtract nbsps
		-- from semicolons to 'escape' them. If additional entities are added,
		-- they also can be subtracted.
		if limit &lt; commas or 0 &lt; (semicolons - nbsps) then
			utilities.set_message ('maint_mult_names', cfg.special_case_translation [list_name]);	-- add a maint message
		end
	end
end


--[=[-------------------------&lt; I S _ G E N E R I C &gt;----------------------------------------------------------

Compares values assigned to various parameters according to the string provided as &lt;item&gt; in the function call.
&lt;item&gt; can have on of two values:
	'generic_names' – for name-holding parameters: |last=, |first=, |editor-last=, etc
	'generic_titles' – for |title=

There are two types of generic tests.  The 'accept' tests look for a pattern that should not be rejected by the
'reject' test.  For example,
	|author=[[John Smith (author)|Smith, John]]
would be rejected by the 'author' reject test.  But piped wikilinks with 'author' disambiguation should not be
rejected so the 'accept' test prevents that from happening.  Accept tests are always performed before reject
tests.

Each of the 'accept' and 'reject' sequence tables hold tables for en.wiki (['en']) and local.wiki (['local'])
that each can hold a test sequence table  The sequence table holds, at index [1], a test pattern, and, at index
[2], a boolean control value.  The control value tells string.find() or mw.ustring.find() to do plain-text search (true)
or a pattern search (false).  The intent of all this complexity is to make these searches as fast as possible so
that we don't run out of processing time on very large articles.

Returns
	true when a reject test finds the pattern or string
	false when an accept test finds the pattern or string
	nil else

]=]

local function is_generic (item, value, wiki)
	local test_val;
	local str_lower = {															-- use string.lower() for en.wiki (['en']) and use mw.ustring.lower() or local.wiki (['local'])
		['en'] = string.lower,
		['local'] = mw.ustring.lower,
		}
	local str_find = {															-- use string.find() for en.wiki (['en']) and use mw.ustring.find() or local.wiki (['local'])
		['en'] = string.find,
		['local'] = mw.ustring.find,
		}

	local function test (val, test_t, wiki)										-- local function to do the testing; &lt;wiki&gt; selects lower() and find() functions
		val = test_t[2] and str_lower[wiki](value) or val;						-- when &lt;test_t[2]&gt; set to 'true', plaintext search using lowercase value
		return str_find[wiki] (val, test_t[1], 1, test_t[2]);					-- return nil when not found or matched
	end
		
	local test_types_t = {'accept', 'reject'};									-- test accept patterns first, then reject patterns
	local wikis_t = {'en', 'local'};											-- do tests for each of these keys; en.wiki first, local.wiki second

	for _, test_type in ipairs (test_types_t) do								-- for each test type
		for _, generic_value in pairs (cfg.special_case_translation[item][test_type]) do	-- spin through the list of generic value fragments to accept or reject
			for _, wiki in ipairs (wikis_t) do
				if generic_value[wiki] then
					if test (value, generic_value[wiki], wiki) then				-- go do the test
						return ('reject' == test_type);							-- param value rejected, return true; false else
					end
				end
			end
		end
	end
end


--[[--------------------------&lt; N A M E _ I S _ G E N E R I C &gt;------------------------------------------------

calls is_generic() to determine if &lt;name&gt; is a 'generic name' listed in cfg.generic_names; &lt;name_alias&gt; is the
parameter name used in error messaging

]]

local function name_is_generic (name, name_alias)
	if not added_generic_name_errs  and is_generic ('generic_names', name) then
		utilities.set_message ('err_generic_name', name_alias);					-- set an error message
		added_generic_name_errs = true;
	end
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------

This function calls various name checking functions used to validate the content of the various name-holding parameters.

]]

local function name_checks (last, first, list_name, last_alias, first_alias)
	local accept_name;

	if utilities.is_set (last) then
		last, accept_name = utilities.has_accept_as_written (last);				-- remove accept-this-as-written markup when it wraps all of &lt;last&gt;

		if not accept_name then													-- &lt;last&gt; not wrapped in accept-as-written markup
			name_has_mult_names (last, list_name);								-- check for multiple names in the parameter
			name_is_numeric (last, last_alias, list_name);						-- check for names that have no letters or are a mix of digits and other characters
			name_is_generic (last, last_alias);									-- check for names found in the generic names list
		end
	end

	if utilities.is_set (first) then
		first, accept_name = utilities.has_accept_as_written (first);			-- remove accept-this-as-written markup when it wraps all of &lt;first&gt;

		if not accept_name then													-- &lt;first&gt; not wrapped in accept-as-written markup
			name_has_mult_names (first, list_name, 0);							-- check for multiple names in the parameter; 0 is number of allowed commas in a given name
			name_is_numeric (first, first_alias, list_name);					-- check for names that have no letters or are a mix of digits and other characters
			name_is_generic (first, first_alias);								-- check for names found in the generic names list
		end
		local wl_type, D = utilities.is_wikilink (first);
		if 0 ~= wl_type then
			first = D;
			utilities.set_message ('err_bad_paramlink', first_alias);
		end
	end

	return last, first;															-- done
end


--[[----------------------&lt; E X T R A C T _ N A M E S &gt;-------------------------

Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters
(or their aliases), and their matching link and mask parameters. Stops searching
when both |lastn= and |firstn= are not found in args after two sequential attempts:
found |last1=, |last2=, and |last3= but doesn't find |last4= and |last5= then the
search is done.

This function emits an error message when there is a |firstn= without a matching
|lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not
required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.'
is stripped from the parameter and a flag (etal) returned that will cause list_people()
to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps
'et al.' out of the template's metadata.  When this occurs, an error is emitted.

]]

local function extract_names(args, list_name)
	local names = {};															-- table of names
	local last;																	-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;																-- loop counter/indexer
	local n = 1;																-- output table indexer
	local count = 0;															-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal = false;															-- return value set to true when we find some form of et al. in an author parameter

	local last_alias, first_alias, link_alias;									-- selected parameter aliases used in error messaging
	while true do
		last, last_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'err_redundant_parameters', i );		-- search through args for name components beginning at 1
		first, first_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'err_redundant_parameters', i );
		link, link_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i );
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
	
		if last then															-- error check |lastn= alias for unknown interwiki link prefix; done here because this is where we have the parameter name
			local project, language = interwiki_prefixen_get (last, true);		-- true because we expect interwiki links in |lastn= to be wikilinked
			if nil == project and nil == language then							-- when both are nil
				utilities.set_message ('err_bad_paramlink', last_alias);		-- not known, emit an error message	-- TODO: err_bad_interwiki?
				last = utilities.remove_wiki_link (last);						-- remove wikilink markup; show display value only
			end
		end
		
		if link then															-- error check |linkn= alias for unknown interwiki link prefix
			local project, language = interwiki_prefixen_get (link, false);		-- false because wiki links in |author-linkn= is an error
			if nil == project and nil == language then							-- when both are nil
				utilities.set_message ('err_bad_paramlink', link_alias);		-- not known, emit an error message	-- TODO: err_bad_interwiki?
				link = nil;														-- unset so we don't link
				link_alias = nil;
			end
		end
		
		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.
		last, first = name_checks (last, first, list_name, last_alias, first_alias);						-- multiple names, extraneous annotation, etc. checks

		if first and not last then												-- if there is a firstn without a matching lastn
			local alias = first_alias:find ('given', 1, true) and 'given' or 'first';	-- get first or given form of the alias
			utilities.set_message ('err_first_missing_last', {
				first_alias,													-- param name of alias missing its mate
				first_alias:gsub (alias, {['first'] = 'last', ['given'] = 'surname'}),	-- make param name appropriate to the alias form
				});																-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			local result;
			link = link_title_ok (link, link_alias, last, last_alias);			-- check for improper wiki-markup

			if first then
				link = link_title_ok (link, link_alias, first, first_alias);	-- check for improper wiki-markup
			end

			names[n] = {last = last, first = first, link = link, mask = mask, corporate = false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				utilities.set_message ('err_missing_name', {list_name:match (&quot;(%w+)List&quot;):lower(), i - 1});	-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names and the etal flag
end


--[[--------------------------&lt; N A M E _ T A G _ G E T &gt;------------------------------------------------------

attempt to decode |language=&lt;lang_param&gt; and return language name and matching tag; nil else.

This function looks for:
	&lt;lang_param&gt; as a tag in cfg.lang_tag_remap{}
	&lt;lang_param&gt; as a name in cfg.lang_name_remap{}
	
	&lt;lang_param&gt; as a name in cfg.mw_languages_by_name_t
	&lt;lang_param&gt; as a tag in cfg.mw_languages_by_tag_t
when those fail, presume that &lt;lang_param&gt; is an IETF-like tag that MediaWiki does not recognize.  Strip all
script, region, variant, whatever subtags from &lt;lang_param&gt; to leave just a two or three character language tag
and look for the new &lt;lang_param&gt; in cfg.mw_languages_by_tag_t{}

on success, returns name (in properly capitalized form) and matching tag (in lowercase); on failure returns nil

]]

local function name_tag_get (lang_param)
	local lang_param_lc = mw.ustring.lower (lang_param);						-- use lowercase as an index into the various tables
	local name;
	local tag;

	name = cfg.lang_tag_remap[lang_param_lc];									-- assume &lt;lang_param_lc&gt; is a tag; attempt to get remapped language name 
	if name then																-- when &lt;name&gt;, &lt;lang_param&gt; is a tag for a remapped language name
		if cfg.lang_name_remap[name:lower()][2] ~= lang_param_lc then
			utilities.set_message ('maint_unknown_lang');						-- add maint category if not already added
			return name, cfg.lang_name_remap[name:lower()][2];					-- so return name and tag from lang_name_remap[name]; special case to xlate sr-ec and sr-el to sr-cyrl and sr-latn
		end
		return name, lang_param_lc;												-- so return &lt;name&gt; from remap and &lt;lang_param_lc&gt;
	end

	tag = lang_param_lc:match ('^(%a%a%a?)%-.*');								-- still assuming that &lt;lang_param_lc&gt; is a tag; strip script, region, variant subtags
	name = cfg.lang_tag_remap[tag];												-- attempt to get remapped language name with language subtag only
	if name then																-- when &lt;name&gt;, &lt;tag&gt; is a tag for a remapped language name
		return name, tag;														-- so return &lt;name&gt; from remap and &lt;tag&gt;
	end

	if cfg.lang_name_remap[lang_param_lc] then									-- not a remapped tag, assume &lt;lang_param_lc&gt; is a name; attempt to get remapped language tag 
		return cfg.lang_name_remap[lang_param_lc][1], cfg.lang_name_remap[lang_param_lc][2];	-- for this &lt;lang_param_lc&gt;, return a (possibly) new name and appropriate tag
	end

	name = cfg.mw_languages_by_tag_t[lang_param_lc];							-- assume that &lt;lang_param_lc&gt; is a tag; attempt to get its matching language name
	
	if name then
		return name, lang_param_lc;												-- &lt;lang_param_lc&gt; is a tag so return it and &lt;name&gt;
	end
	
	tag = cfg.mw_languages_by_name_t[lang_param_lc];							-- assume that &lt;lang_param_lc&gt; is a language name; attempt to get its matching tag
	
	if tag then
		return cfg.mw_languages_by_tag_t[tag], tag;								-- &lt;lang_param_lc&gt; is a name so return the name from the table and &lt;tag&gt;
	end

	tag = lang_param_lc:match ('^(%a%a%a?)%-.*');								-- is &lt;lang_param_lc&gt; an IETF-like tag that MediaWiki doesn't recognize? &lt;tag&gt; gets the language subtag; nil else

	if tag then
		name = cfg.mw_languages_by_tag_t[tag];									-- attempt to get a language name using the shortened &lt;tag&gt;
		if name then
			return name, tag;													-- &lt;lang_param_lc&gt; is an unrecognized IETF-like tag so return &lt;name&gt; and language subtag
		end
	end
end


--[[-------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code
is recognized by MediaWiki, use the returned name; if not, then use the value that
was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is
assigned to the category for that code: Category:Norwegian-language sources (no).
For valid three-character code languages, the page is assigned to the single category
for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does
not recognize three-character equivalents of two-character codes: code 'ar' is
recognized but code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th
where the language names or codes are separated from each other by commas with
optional space characters.

]]

local function language_parameter (lang)
	local tag;																	-- some form of IETF-like language tag; language subtag with optional region, sript, vatiant, etc subtags
	local lang_subtag;															-- ve populates |language= with mostly unecessary region subtags the MediaWiki does not recognize; this is the base language subtag
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_t = {};															-- table made from the value assigned to |language=

	local this_wiki_name = mw.language.fetchLanguageName (cfg.this_wiki_code, cfg.this_wiki_code);	-- get this wiki's language name

	names_t = mw.text.split (lang, '%s*,%s*');									-- names should be a comma separated list

	for _, lang in ipairs (names_t) do											-- reuse lang here because we don't yet know if lang is a language name or a language tag
		name, tag = name_tag_get (lang);										-- attempt to get name/tag pair for &lt;lang&gt;; &lt;name&gt; has proper capitalization; &lt;tag&gt; is lowercase

		if utilities.is_set (tag) then
			lang_subtag = tag:gsub ('^(%a%a%a?)%-.*', '%1');					-- for categorization, strip any IETF-like tags from language tag

			if cfg.this_wiki_code ~= lang_subtag then							-- when the language is not the same as this wiki's language
				if 2 == lang_subtag:len() then									-- and is a two-character tag
					utilities.add_prop_cat ('foreign-lang-source', {name, tag}, lang_subtag);		-- categorize it; tag appended to allow for multiple language categorization
				else															-- or is a recognized language (but has a three-character tag)
					utilities.add_prop_cat ('foreign-lang-source-2', {lang_subtag}, lang_subtag);			-- categorize it differently TODO: support multiple three-character tag categories per cs1|2 template?
				end
			elseif cfg.local_lang_cat_enable then								-- when the language and this wiki's language are the same and categorization is enabled
				utilities.add_prop_cat ('local-lang-source', {name, lang_subtag});		-- categorize it
			end
		else
			name = lang;														-- return whatever &lt;lang&gt; has so that we show something
			utilities.set_message ('maint_unknown_lang');						-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
 
	name = utilities.make_sep_list (#language_list, language_list);
	if (1 == #language_list) and (lang_subtag == cfg.this_wiki_code) then		-- when only one language, find lang name in this wiki lang name; for |language=en-us, 'English' in 'American English'
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[-----------------------&lt; S E T _ C S _ S T Y L E &gt;--------------------------

Gets the default CS style configuration for the given mode.
Returns default separator and either postscript as passed in or the default.
In CS1, the default postscript and separator are '.'.
In CS2, the default postscript is the empty string and the default separator is ','.

]]

local function set_cs_style (postscript, mode)
	if utilities.is_set(postscript) then
		-- emit a maintenance message if user postscript is the default cs1 postscript
		-- we catch the opposite case for cs2 in set_style
		if mode == 'cs1' and postscript == cfg.presentation['ps_' .. mode] then
			utilities.set_message ('maint_postscript');
		end
	else
		postscript = cfg.presentation['ps_' .. mode];
	end
	return cfg.presentation['sep_' .. mode], postscript;
end


--[[--------------------------&lt; S E T _ S T Y L E &gt;-----------------------------

Sets the separator and postscript styles. Checks the |mode= first and the
#invoke CitationClass second. Removes the postscript if postscript == none.

]]

local function set_style (mode, postscript, cite_class)
	local sep;
	if 'cs2' == mode then
		sep, postscript = set_cs_style (postscript, 'cs2');
	elseif 'cs1' == mode then
		sep, postscript = set_cs_style (postscript, 'cs1');
	elseif 'citation' == cite_class	then
		sep, postscript = set_cs_style (postscript, 'cs2');
	else
		sep, postscript = set_cs_style (postscript, 'cs1');
	end

	if cfg.keywords_xlate[postscript:lower()] == 'none' then
		-- emit a maintenance message if user postscript is the default cs2 postscript
		-- we catch the opposite case for cs1 in set_cs_style
		if 'cs2' == mode or 'citation' == cite_class then
			utilities.set_message ('maint_postscript');
		end
		postscript = '';
	end
	
	return sep, postscript
end


--[=[-------------------------&lt; I S _ P D F &gt;-----------------------------------

Determines if a URL has the file extension that is one of the PDF file extensions
used by [[MediaWiki:Common.css]] when applying the PDF icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or
		url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
		url:match ('%.PDF&amp;#035') or url:match ('%.pdf&amp;#035');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;-----------------------

Applies CSS style to |format=, |chapter-format=, etc.  Also emits an error message
if the format parameter does not have a matching URL parameter.  If the format parameter
is not set and the URL contains a file extension that is recognized as a PDF document
by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if utilities.is_set (format) then
		format = utilities.wrap_style ('format', format);						-- add leading space, parentheses, resize
		if not utilities.is_set (url) then
			utilities.set_message ('err_format_missing_url', {fmt_param, url_param});	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if URL is a PDF file then
		format = utilities.wrap_style ('format', 'PDF');						-- set format to PDF
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[---------------------&lt; G E T _ D I S P L A Y _ N A M E S &gt;------------------

Returns a number that defines the number of names displayed for author and editor
name lists and a Boolean flag to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero,
return the number and the previous state of the 'etal' flag (false by default
but may have been set to true if the name list contains some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number
that is one greater than the number of authors in the list and set the 'etal' flag true.
This will cause the list_people() to display all of the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors'], etc; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

This function sets an error message when |display-xxxxors= value greater than or equal to number of names but
not when &lt;max&gt; comes from {{cs1 config}} global settings.  When using global settings, &lt;param&gt; is set to the
keyword 'cs1 config' which is used to supress the normal error.  Error is suppressed because it is to be expected
that some citations in an article will have the same or fewer names that the limit specified in {{cs1 config}}.

]]

local function get_display_names (max, count, list_name, etal, param)
	if utilities.is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if (max &gt;= count) and ('cs1 config' ~= param) then					-- error when local |display-xxxxors= value greater than or equal to number of names; not an error when using global setting
				utilities.set_message ('err_disp_name', {param, max});			-- add error message
				max = nil;
			end
		else																	-- not a valid keyword or number
			utilities.set_message ('err_disp_name', {param, max});				-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[----------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;---------------

Adds error if |page=, |pages=, |quote-page=, |quote-pages= has what appears to be
some form of p. or pp. abbreviation in the first characters of the parameter content.

check page for extraneous p, p., pp, pp., pg, pg. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when page begins PX or P# but not Px
		      where x and X are letters and # is a digit
	bad pattern:  '^[Pp][PpGg]' matches when page begins pp, pP, Pp, PP, pg, pG, Pg, PG

]]

local function extra_text_in_page_check (val, name)
	if not val:match (cfg.vol_iss_pg_patterns.good_ppattern) then
		for _, pattern in ipairs (cfg.vol_iss_pg_patterns.bad_ppatterns) do		-- spin through the selected sequence table of patterns
			if val:match (pattern) then											-- when a match, error so
				utilities.set_message ('err_extra_text_pages', name);	 		-- add error message
				return;															-- and done
			end
		end
	end		
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ V O L _ I S S _ C H E C K &gt;------------------------

Adds error if |volume= or |issue= has what appears to be some form of redundant 'type' indicator.

For |volume=:
	'V.', or 'Vol.' (with or without the dot) abbreviations or 'Volume' in the first characters of the parameter
	content (all case insensitive). 'V' and 'v' (without the dot) are presumed to be roman numerals so
	are allowed.

For |issue=:
	'No.', 'I.', 'Iss.' (with or without the dot) abbreviations, or 'Issue' in the first characters of the
	parameter content (all case insensitive).
	
Single character values ('v', 'i', 'n') allowed when not followed by separator character ('.', ':', '=', or
whitespace character) – param values are trimmed of whitespace by MediaWiki before delivered to the module.
	
&lt;val&gt; is |volume= or |issue= parameter value
&lt;name&gt; is |volume= or |issue= parameter name for error message
&lt;selector&gt; is 'v' for |volume=, 'i' for |issue=

sets error message on failure; returns nothing

]]

local function extra_text_in_vol_iss_check (val, name, selector)
	if not utilities.is_set (val) then
		return;
	end
	
	local patterns = 'v' == selector and cfg.vol_iss_pg_patterns.vpatterns or cfg.vol_iss_pg_patterns.ipatterns;

	local handler = 'v' == selector and 'err_extra_text_volume' or 'err_extra_text_issue';
	val = val:lower();															-- force parameter value to lower case
	for _, pattern in ipairs (patterns) do										-- spin through the selected sequence table of patterns
		if val:match (pattern) then												-- when a match, error so
			utilities.set_message (handler, name);								-- add error message
			return;																-- and done
		end
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parentheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a placeholder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parentheses
			local name = name_table[i];
			i = i + 1;															-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parentheses
					break;														-- and done reassembling so
				end
				i = i + 1;														-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = utilities.is_wikilink (name_table[i]);		-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i + 1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled parentheses ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the Vancouver error when a required comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		first = '';																-- set to empty string for concatenation and because it may have been set for previous author/editor
		local accept_name;
		v_name, accept_name = utilities.has_accept_as_written (v_name);			-- remove accept-this-as-written markup when it wraps all of &lt;v_name&gt;

		if accept_name then
			last = v_name;
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error (cfg.err_msg_supl.punctuation, i);
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s+&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be initials or generational suffix

			if not mw.ustring.match (first, '^%u+$') then						-- mw.ustring here so that later we will catch non-Latin characters
				suffix = first;													-- not initials so assume that whatever we got is a generational suffix
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end
			last = table.concat(lastfirstTable, ' ')							-- returns a string that is the concatenation of all other names that are not initials and generational suffix
			if not utilities.is_set (last) then
				first = '';														-- unset
				last = v_name;													-- last empty because something wrong with first
				add_vanc_error (cfg.err_msg_supl.name, i);
			end
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error (cfg.err_msg_supl['missing comma'], i);			-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- matches a space between two initials
			end
		else
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
		
		if utilities.is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first, suffix, i);							-- check first and last before restoring the suffix which may have a non-Latin digit
			if utilities.is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '', nil, i);
			end
		end

		link = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i ) or v_link_table[i];
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate = corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest;
|editorn= (and aliases) highest and |veditors= lowest (support for |editors= withdrawn)

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
	local lastfirst = false;
	if utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice in case we have a |first1= without a |last1=; this ...
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or		-- ... also catches the case where |first= is used with |vauthors=
		utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst = true;
	end

	if (utilities.is_set (vxxxxors) and true == lastfirst) or					-- these are the three error conditions
		(utilities.is_set (vxxxxors) and utilities.is_set (xxxxors)) or
		(true == lastfirst and utilities.is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			utilities.set_message ('err_redundant_parameters', err_name .. '-name-list parameters');	-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if utilities.is_set (vxxxxors) then return 2 end;
	if utilities.is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, live, dead, etc.).  When the parameter value has not been assigned a value (missing
or empty in the source template) the function returns the value specified by ret_val.  If the parameter value is one
of the list of allowed values returns the translated value; else, emits an error message and returns the value
specified by ret_val.

TODO: explain &lt;invert&gt;

]]

local function is_valid_parameter_value (value, name, possible, ret_val, invert)
	if not utilities.is_set (value) then
		return ret_val;															-- an empty parameter is ok
	end

	if (not invert and utilities.in_array (value, possible)) then				-- normal; &lt;value&gt; is in &lt;possible&gt; table
		return cfg.keywords_xlate[value];										-- return translation of parameter keyword
	elseif invert and not utilities.in_array (value, possible) then				-- invert; &lt;value&gt; is not in &lt;possible&gt; table
		return value;															-- return &lt;value&gt; as it is
	else
		utilities.set_message ('err_invalid_param_val', {name, value});			-- not an allowed value so add error message
		return ret_val;
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list, -3, -1) == sepc .. '. ') then					-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list, -1, -1) == sepc) or (string.sub (name_list, -3, -1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terminate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;-----------------------------------------

returns the concatenation of the formatted volume and issue (or journal article number) parameters as a single
string; or formatted volume or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, article, cite_class, origin, sepc, lower)
	if not utilities.is_set (volume) and not utilities.is_set (issue) and not utilities.is_set (article) then
		return '';
	end

	-- same condition as in format_pages_sheets()
	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);

	local is_numeric_vol = volume and (volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$'));	-- is only uppercase roman numerals or only digits?
	local is_long_vol = volume and (4 &lt; mw.ustring.len(volume));				-- is |volume= value longer than 4 characters?
	
	if volume and (not is_numeric_vol and is_long_vol) then						-- when not all digits or Roman numerals, is |volume= longer than 4 characters?
		utilities.add_prop_cat ('long-vol');									-- yes, add properties cat
	end

	if is_journal then															-- journal-style formatting
		local vol = '';

		if utilities.is_set (volume) then
			if is_numeric_vol then												-- |volume= value all digits or all uppercase Roman numerals?
				vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, volume});	-- render in bold face
			elseif is_long_vol then												-- not all digits or Roman numerals; longer than 4 characters?
				vol = utilities.substitute (cfg.messages['j-vol'], {sepc, utilities.hyphen_to_dash (volume)});	-- not bold
			else																-- four or fewer characters
				vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, utilities.hyphen_to_dash (volume)});	-- bold
			end
		end
		vol = vol .. (utilities.is_set (issue) and utilities.substitute (cfg.messages['j-issue'], issue) or '')
		vol = vol .. (utilities.is_set (article) and utilities.substitute (cfg.messages['j-article-num'], article) or '')
		return vol;
	end
	
	if 'podcast' == cite_class and utilities.is_set (issue) then
		return wrap_msg ('issue', {sepc, issue}, lower);
	end
	
	if 'conference' == cite_class and utilities.is_set (article) then			-- |article-number= supported only in journal and conference cites
		if utilities.is_set (volume) and utilities.is_set (article) then		-- both volume and article number
			return wrap_msg ('vol-art', {sepc, utilities.hyphen_to_dash (volume), article}, lower);
		elseif utilities.is_set (article) then									-- article number alone; when volume alone, handled below
			return wrap_msg ('art', {sepc, article}, lower);
		end
	end

	-- all other types of citation
	if utilities.is_set (volume) and utilities.is_set (issue) then
		return wrap_msg ('vol-no', {sepc, utilities.hyphen_to_dash (volume), issue}, lower);
	elseif utilities.is_set (volume) then
		return wrap_msg ('vol', {sepc, utilities.hyphen_to_dash (volume)}, lower);
	else
		return wrap_msg ('issue', {sepc, issue}, lower);
	end
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if utilities.is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif utilities.is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if utilities.is_set (page) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return utilities.substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return utilities.substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif utilities.is_set (pages) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then							-- if pages is only digits, assume a single page number
			return '', utilities.substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', utilities.substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', utilities.substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to Wikisource, returns the label portion of the interwiki-link as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki-link to an external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, page_orig, pages, pages_orig, at)
	local ws_url, ws_label, coins_pages, L;										-- for Wikisource interwiki-links; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if utilities.is_set (page) then
		if utilities.is_set (pages) or utilities.is_set (at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page, page_orig);								-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws URL from |page= interwiki link; link portion L becomes tooltip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (pages) then
		if utilities.is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages, pages_orig);							-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws URL from |pages= interwiki link; link portion L becomes tooltip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws URL from |at= interwiki link; link portion L becomes tooltip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end

--[[--------------------------&lt; I S _ U N I Q U E _ A R C H I V E _ U R L &gt;------------------------------------

add error message when |archive-url= value is same as |url= or chapter-url= (or alias...) value

]]

local function is_unique_archive_url (archive, url, c_url, source, date)
	if utilities.is_set (archive) then
		if archive == url or archive == c_url then
			utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)});	-- add error message
			return '', '';														-- unset |archive-url= and |archive-date= because same as |url= or |chapter-url=
		end
	end

	return archive, date;
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org URLs to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot URL or to calendar pages.  When the archive URL is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the URL.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org URL does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command URL
	|archive-url= is an archive.org URL that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org URLs:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this function may return a modified
archive URL:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the URL unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

A secondary function is to return an archive-url timestamp from those urls that have them (archive.org and
archive.today).  The timestamp is used by validation.archive_date_check() to see if the value in |archive-date=
matches the timestamp in the archive url.

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.org URL
	
	timestamp = url:match ('//archive.today/(%d%d%d%d%d%d%d%d%d%d%d%d%d%d)/');	-- get timestamp from archive.today urls
	if timestamp then															-- if this was an archive.today url ...
		return url, date, timestamp;											-- return ArchiveURL, ArchiveDate, and timestamp from |archive-url=, and done
	end
																				-- here for archive.org urls
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine URL
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command URL, we don't want to allow saving of the target page 
		err_msg = cfg.err_msg_supl.save;
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = cfg.err_msg_supl.liveweb;
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');	-- split out some of the URL parts for evaluation
		if not path then														-- malformed in some way; pattern did not match
			err_msg = cfg.err_msg_supl.timestamp;
		elseif 14 ~= timestamp:len() then										-- path and flag optional, must have 14-digit timestamp here
			err_msg = cfg.err_msg_supl.timestamp;
			if '*' ~= flag then
				local replacement = timestamp:match ('^%d%d%d%d%d%d') or timestamp:match ('^%d%d%d%d');	-- get the first 6 (YYYYMM) or first 4 digits (YYYY)
				if replacement then												-- nil if there aren't at least 4 digits (year)
					replacement = replacement .. string.rep ('0', 14 - replacement:len());	-- year or yearmo (4 or 6 digits) zero-fill to make 14-digit timestamp
					url=url:gsub ('(//web%.archive%.org/[^%d]*)%d[^/]*', '%1' .. replacement .. '*', 1)	-- for preview, modify ts to 14 digits plus splat for calendar display
				end
			end
		elseif utilities.is_set (path) and 'web/' ~= path then					-- older archive URLs do not have the extra 'web/' path element
			err_msg = cfg.err_msg_supl.path;
		elseif utilities.is_set (flag) and not utilities.is_set (path) then		-- flag not allowed with the old form URL (without the 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		elseif utilities.is_set (flag) and not flag:match ('%a%a_') then		-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		else
			return url, date, timestamp;										-- return ArchiveURL, ArchiveDate, and timestamp from |archive-url=
		end
	end
																				-- if here, something not right so
	utilities.set_message ('err_archive_url', {err_msg});						-- add error message and

	if is_preview_mode then
		return url, date, timestamp;											-- preview mode so return ArchiveURL, ArchiveDate, and timestamp from |archive-url=
	else
		return '', '';															-- return empty strings for ArchiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; P L A C E _ C H E C K &gt;--------------------------------------------------------

check |place=, |publication-place=, |location= to see if these params include digits.  This function added because
many editors misuse location to specify the in-source location (|page(s)= and |at= are supposed to do that)

returns the original parameter value without modification; added maint cat when parameter value contains digits

]]

local function place_check (param_val)
	if not utilities.is_set (param_val) then									-- parameter empty or omitted
		return param_val;														-- return that empty state
	end
	
	if mw.ustring.find (param_val, '%d') then									-- not empty, are there digits in the parameter value
		utilities.set_message ('maint_location');								-- yep, add maint cat
	end
	
	return param_val;															-- and done
end


--[[--------------------------&lt; I S _ A R C H I V E D _ C O P Y &gt;----------------------------------------------

compares |title= to 'Archived copy' (placeholder added by bots that can't find proper title); if matches, return true; nil else

]]

local function is_archived_copy (title)
	title = mw.ustring.lower(title);											-- switch title to lower case
	if title:find (cfg.special_case_translation.archived_copy.en) then			-- if title is 'Archived copy'
		return true;
	elseif cfg.special_case_translation.archived_copy['local'] then
		if mw.ustring.find (title, cfg.special_case_translation.archived_copy['local']) then	-- mw.ustring() because might not be Latin script
			return true;
		end
	end
end


--[[--------------------------&lt; D I S P L A Y _ N A M E S _ S E L E C T &gt;--------------------------------------

for any of the |display-authors=, |display-editors=, etc parameters, select either the local or global setting.
When both are present, look at &lt;local_display_names&gt; value.  When the value is some sort of 'et al.'string,
special handling is required.

When {{cs1 config}} has |display-&lt;namelist&gt;= AND this template has |display-&lt;namelist&gt;=etal AND:
	the number of names specified by &lt;number_of_names&gt; is:
		greater than the number specified in the global |display-&lt;namelist&gt;= parameter (&lt;global_display_names&gt;)
			use global |display-&lt;namelist&gt;= parameter value
			set overridden maint category
		less than or equal to the number specified in the global |display-&lt;namelist&gt;=  parameter
			use local |display-&lt;namelist&gt;= parameter value

The purpose of this function is to prevent categorizing a template that has fewer names than the global setting
to keep the etal annotation specified by &lt;local_display_names&gt;.

]]

local function display_names_select (global_display_names, local_display_names, param_name, number_of_names, test)
	if global_display_names and utilities.is_set (local_display_names) then		-- when both
		if 'etal' == local_display_names:lower():gsub(&quot;[ '%.]&quot;, '') then		-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			number_of_names = tonumber (number_of_names);						-- convert these to numbers for comparison
			local global_display_names_num = tonumber (global_display_names);	-- &lt;global_display_names&gt; not set when parameter value is not digits

			if number_of_names &gt; global_display_names_num then					-- template has more names than global config allows to be displayed?
				utilities.set_message ('maint_overridden_setting');				-- set a maint message because global is overriding local |display-&lt;namelist&gt;=etal
				return global_display_names, 'cs1 config';						-- return global with spoof parameter name (for get_display_names())
			else
				return local_display_names, param_name;							-- return local because fewer names so let &lt;local_display_names&gt; control
			end
		end
																				-- here when &lt;global_display_names&gt; and &lt;local_display_names&gt; both numbers; &lt;global_display_names&gt; controls
		utilities.set_message ('maint_overridden_setting');						-- set a maint message
		return global_display_names, 'cs1 config';								-- return global with spoof parameter name (for get_display_names())
	end
																				-- here when only one of &lt;global_display_names&gt; or &lt;local_display_names&gt; set
	if global_display_names then
		return global_display_names, 'cs1 config';								-- return global with spoof parameter name (for get_display_names())
	else
		return local_display_names, param_name;									-- return local
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args )
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper ( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListStyle;
		if cfg.global_cs1_config_t['NameListStyle'] then						-- global setting in {{cs1 config}} overrides local |name-list-style= parameter value; nil when empty or assigned value invalid
			NameListStyle = is_valid_parameter_value (cfg.global_cs1_config_t['NameListStyle'], 'cs1 config: name-list-style', cfg.keywords_lists['name-list-style'], '');	-- error messaging 'param' here is a hoax
		else
			NameListStyle = is_valid_parameter_value (A['NameListStyle'], A:ORIGIN('NameListStyle'), cfg.keywords_lists['name-list-style'], '');
		end

		if cfg.global_cs1_config_t['NameListStyle'] and utilities.is_set (A['NameListStyle']) then	-- when template has |name-list-style=&lt;something&gt; which global setting has overridden
			utilities.set_message ('maint_overridden_setting');					-- set a maint message
		end

	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			a, author_etal = parse_vauthors_veditors (args, A['Vauthors'], 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |people= or |credits=; |authors= is deprecated; TODO: constrain |people= and |credits= to cite av media, episode, serial?
		end
		if utilities.is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], nil, args, 'EditorList');	-- support for |editors= withdrawn
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		end
	end
							
	local Chapter = A['Chapter'];												-- done here so that we have access to |contribution= from |chapter= aliases
	local Chapter_origin = A:ORIGIN ('Chapter');
	local Contribution;															-- because contribution is required for contributor(s)
		if 'contribution' == Chapter_origin then
			Contribution = Chapter;												-- get the name of the contribution
		end
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	
	if utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not utilities.is_set (Contribution) then							-- |contributor= requires |contribution=
				utilities.set_message ('err_contributor_missing_required_param', 'contribution');	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				utilities.set_message ('err_contributor_missing_required_param', 'author');	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if utilities.select_one (args, cfg.aliases['ContributorList-Last'], 'err_redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			utilities.set_message ('err_contributor_ignored');					-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	local Title = A['Title'];
	local TitleLink = A['TitleLink'];

	local auto_select = '';														-- default is auto
	local accept_link;
	TitleLink, accept_link = utilities.has_accept_as_written (TitleLink, true);	-- test for accept-this-as-written markup
	if (not accept_link) and utilities.in_array (TitleLink, {'none', 'pmc', 'doi'}) then -- check for special keywords
		auto_select = TitleLink;												-- remember selection for later
		TitleLink = '';															-- treat as if |title-link= would have been empty
	end

	TitleLink = link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wiki-markup in |title-link= or wiki-markup in |title= when |title-link= is set

	local Section = '';															-- {{cite map}} only; preset to empty string for concatenation if not used
	if 'map' == config.CitationClass and 'section' == Chapter_origin then
		Section = A['Chapter'];													-- get |section= from |chapter= alias list; |chapter= and the other aliases not supported in {{cite map}}
		Chapter = '';															-- unset for now; will be reset later from |map= if present
	end

	local Periodical = A['Periodical'];
	local Periodical_origin = A:ORIGIN('Periodical');
	local ScriptPeriodical = A['ScriptPeriodical'];
	local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');
	local TransPeriodical =  A['TransPeriodical'];
	local TransPeriodical_origin =  A:ORIGIN ('TransPeriodical');
	
	if (utilities.in_array (config.CitationClass, {'book', 'encyclopaedia'}) and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical))) then
		local param;
		if utilities.is_set (Periodical) then									-- get a parameter name from one of these periodical related meta-parameters
			Periodical = '';													-- unset because not valid {{cite book}} or {{cite encyclopedia}} parameters 
			param = Periodical_origin											-- get parameter name for error messaging
		elseif utilities.is_set (TransPeriodical) then
			TransPeriodical = '';												-- unset because not valid {{cite book}} or {{cite encyclopedia}} parameters 
			param = TransPeriodical_origin;										-- get parameter name for error messaging
		elseif utilities.is_set (ScriptPeriodical) then
			ScriptPeriodical = '';												-- unset because not valid {{cite book}} or {{cite encyclopedia}} parameters 
			param = ScriptPeriodical_origin;									-- get parameter name for error messaging
		end

		if utilities.is_set (param) then										-- if we found one
			utilities.set_message ('err_periodical_ignored', {param});			-- emit an error message
		end
	end

	if utilities.is_set (Periodical) then
		local i;
		Periodical, i = utilities.strip_apostrophe_markup (Periodical);			-- strip apostrophe markup so that metadata isn't contaminated 
		if i then																-- non-zero when markup was stripped so emit an error message
			utilities.set_message ('err_apostrophe_markup', {Periodical_origin});
		end
	end

	if 'mailinglist' == config.CitationClass then								-- special case for {{cite mailing list}}
		if utilities.is_set (Periodical) and utilities.is_set (A ['MailingList']) then	-- both set emit an error TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', Periodical_origin) .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'mailinglist')});
		end

		Periodical = A ['MailingList'];											-- error or no, set Periodical to |mailinglist= value because this template is {{cite mailing list}}
		Periodical_origin = A:ORIGIN('MailingList');
	end

	-- web and news not tested for now because of 
	-- Wikipedia:Administrators%27_noticeboard#Is_there_a_semi-automated_tool_that_could_fix_these_annoying_&quot;Cite_Web&quot;_errors?
	if not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) then	-- 'periodical' templates require periodical parameter
	--	local p = {['journal'] = 'journal', ['magazine'] = 'magazine', ['news'] = 'newspaper', ['web'] = 'website'};	-- for error message
		local p = {['journal'] = 'journal', ['magazine'] = 'magazine'};			-- for error message
		if p[config.CitationClass]  then
			utilities.set_message ('err_missing_periodical', {config.CitationClass, p[config.CitationClass]});
		end
	end
	
	local Volume;
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) then
			if not utilities.in_array (Periodical_origin, cfg.citation_no_volume_t) then	-- {{citation}} does not render |volume= when these parameters are used
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		elseif utilities.is_set (ScriptPeriodical) then
			if 'script-website' ~= ScriptPeriodical_origin then					-- {{citation}} does not render volume for |script-website=
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		else
			Volume = A['Volume'];												-- and does for non-'periodical' cites
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_volume) then	-- render |volume= for cs1 according to the configuration settings
		Volume = A['Volume'];
	end	
	extra_text_in_vol_iss_check (Volume, A:ORIGIN ('Volume'), 'v');	

	local Issue;
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) and utilities.in_array (Periodical_origin, cfg.citation_issue_t) then	-- {{citation}} may render |issue= when these parameters are used
			Issue = utilities.hyphen_to_dash (A['Issue']);
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_issue) then	-- conference &amp; map books do not support issue; {{citation}} listed here because included in settings table
		if not (utilities.in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical))) then
			Issue = utilities.hyphen_to_dash (A['Issue']);
		end
	end
	
	local ArticleNumber;

	if utilities.in_array (config.CitationClass, {'journal', 'conference'}) or ('citation' == config.CitationClass and utilities.is_set (Periodical) and 'journal' == Periodical_origin) then
		ArticleNumber = A['ArticleNumber'];
	end

	extra_text_in_vol_iss_check (Issue, A:ORIGIN ('Issue'), 'i');	

	local Page;
	local Pages;
	local At;
	local QuotePage;
	local QuotePages;
	if not utilities.in_array (config.CitationClass, cfg.templates_not_using_page) then		-- TODO: rewrite to emit ignored parameter error message?
		Page = A['Page'];
		Pages = utilities.hyphen_to_dash (A['Pages']);	
		At = A['At'];
		QuotePage = A['QuotePage'];
		QuotePages = utilities.hyphen_to_dash (A['QuotePages']);
	end

	local Edition = A['Edition'];
	local PublicationPlace = place_check (A['PublicationPlace'], A:ORIGIN('PublicationPlace'));
	local Place = place_check (A['Place'], A:ORIGIN('Place'));
	
	local PublisherName = A['PublisherName'];
	local PublisherName_origin = A:ORIGIN('PublisherName');
	if utilities.is_set (PublisherName) and (cfg.keywords_xlate['none'] ~= PublisherName) then
		local i = 0;
		PublisherName, i = utilities.strip_apostrophe_markup (PublisherName);	-- strip apostrophe markup so that metadata isn't contaminated; publisher is never italicized
		if i and (0 &lt; i) then													-- non-zero when markup was stripped so emit an error message
			utilities.set_message ('err_apostrophe_markup', {PublisherName_origin});
		end
	end
	
	if ('document' == config.CitationClass) and not utilities.is_set (PublisherName) then
		utilities.set_message ('err_missing_publisher', {config.CitationClass, 'publisher'});
	end

	local Newsgroup = A['Newsgroup'];											-- TODO: strip apostrophe markup?
	local Newsgroup_origin = A:ORIGIN('Newsgroup');	

	if 'newsgroup' == config.CitationClass then
		if utilities.is_set (PublisherName) and (cfg.keywords_xlate['none'] ~= PublisherName) then	-- general use parameter |publisher= not allowed in cite newsgroup
			utilities.set_message ('err_parameter_ignored', {PublisherName_origin});
		end

		PublisherName = nil;													-- ensure that this parameter is unset for the time being; will be used again after COinS
	end

	local URL = A['URL'];														-- TODO: better way to do this for URL, ChapterURL, and MapURL?
	local UrlAccess = is_valid_parameter_value (A['UrlAccess'], A:ORIGIN('UrlAccess'), cfg.keywords_lists['url-access'], nil);
	
	if not utilities.is_set (URL) and utilities.is_set (UrlAccess) then
		UrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', 'url');
	end
	
	local ChapterURL = A['ChapterURL'];
	local ChapterUrlAccess = is_valid_parameter_value (A['ChapterUrlAccess'], A:ORIGIN('ChapterUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (ChapterURL) and utilities.is_set (ChapterUrlAccess) then
		ChapterUrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', {A:ORIGIN('ChapterUrlAccess'):gsub ('%-access', '')});
	end

	local MapUrlAccess = is_valid_parameter_value (A['MapUrlAccess'], A:ORIGIN('MapUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (A['MapURL']) and utilities.is_set (MapUrlAccess) then
		MapUrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', {'map-url'});
	end

	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local no_tracking_cats = is_valid_parameter_value (A['NoTracking'], A:ORIGIN('NoTracking'), cfg.keywords_lists['yes_true_y'], nil);

	-- check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not utilities.is_set (no_tracking_cats) then								-- ignore if we are already not going to categorize this page
		if cfg.uncategorized_namespaces[this_page.namespace] then				-- is this page's namespace id one of the uncategorized namespace ids?
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _, v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end
																				-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	utilities.select_one (args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'err_redundant_parameters');	-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, A:ORIGIN('Page'), Pages, A:ORIGIN('Pages'), At);

	local NoPP = is_valid_parameter_value (A['NoPP'], A:ORIGIN('NoPP'), cfg.keywords_lists['yes_true_y'], nil);

	if utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- both |publication-place= and |place= (|location=) allowed if different
		utilities.add_prop_cat ('location-test');								-- add property cat to evaluate how often PublicationPlace and Place are used together
		if PublicationPlace == Place then
			Place = '';															-- unset; don't need both if they are the same
		end
	elseif not utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- when only |place= (|location=) is set ...
		PublicationPlace = Place;												-- promote |place= (|location=) to |publication-place
	end

	if PublicationPlace == Place then Place = ''; end							-- don't need both if they are the same

	local URL_origin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL_origin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ScriptChapter = A['ScriptChapter'];
	local ScriptChapter_origin = A:ORIGIN ('ScriptChapter');
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local TransChapter = A['TransChapter'];
	local TransChapter_origin = A:ORIGIN ('TransChapter');
	local TransTitle = A['TransTitle'];
	local ScriptTitle = A['ScriptTitle'];
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia= and |title= then map |title= to |article= and |encyclopedia= to |title= for rendering
		|encyclopedia= and |article= then map |encyclopedia= to |title= for rendering

		|trans-title= maps to |trans-chapter= when |title= is re-mapped
		|url= maps to |chapter-url= when |title= is remapped
	
	All other combinations of |encyclopedia=, |title=, and |article= are not modified
	
	]]

	local Encyclopedia = A['Encyclopedia'];										-- used as a flag by this module and by ~/COinS

	if utilities.is_set (Encyclopedia) then										-- emit error message when Encyclopedia set but template is other than {{cite encyclopedia}} or {{citation}}
		if 'encyclopaedia' ~= config.CitationClass and 'citation' ~= config.CitationClass then
			utilities.set_message ('err_parameter_ignored', {A:ORIGIN ('Encyclopedia')});
			Encyclopedia = nil;													-- unset because not supported by this template
		end
	end

	if ('encyclopaedia' == config.CitationClass) or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Periodical) and utilities.is_set (Encyclopedia) then	-- when both parameters set emit an error message; {{citation}} only; Periodical not allowed in {{cite encyclopedia}}
			utilities.set_message ('err_periodical_ignored', {Periodical_origin});
		end

		if utilities.is_set (Encyclopedia) then
			Periodical = Encyclopedia;											-- error or no, set Periodical to Encyclopedia for rendering; {{citation}} could (not legitimately) have both; use Encyclopedia
			Periodical_origin = A:ORIGIN ('Encyclopedia');

			if utilities.is_set (Title) or utilities.is_set (ScriptTitle) then
				if not utilities.is_set (Chapter) then
					Chapter = Title;											-- |encyclopedia= and |title= are set so map |title= to |article= and |encyclopedia= to |title= for rendering
					ScriptChapter = ScriptTitle;
					ScriptChapter_origin = A:ORIGIN('ScriptTitle')
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterURL_origin = URL_origin;

					ChapterUrlAccess = UrlAccess;

					if not utilities.is_set (ChapterURL) and utilities.is_set (TitleLink) then
						Chapter = utilities.make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;
					ChapterFormat = Format;
					Periodical = '';											-- redundant so unset
					TransTitle = '';
					URL = '';
					Format = '';
					TitleLink = '';
					ScriptTitle = '';
				end
			elseif utilities.is_set (Chapter) or utilities.is_set (ScriptChapter) then								-- |title= not set
				Title = Periodical;												-- |encyclopedia= set and |article= set so map |encyclopedia= to |title= for rendering
				Periodical = '';												-- redundant so unset
			end
		end
	end

	-- special case for cite techreport.
	local ID = A['ID'];
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if utilities.is_set (A['Number']) then									-- cite techreport uses 'number', which other citations alias to 'issue'
			if not utilities.is_set (ID) then									-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'id') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'number')});
			end
		end	
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	local ChapterLink -- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local Conference = A['Conference'];
	local BookTitle = A['BookTitle'];
	local TransTitle_origin = A:ORIGIN ('TransTitle');
	if 'conference' == config.CitationClass then
		if utilities.is_set (BookTitle) then
			Chapter = Title;
			Chapter_origin = 'title';
	--		ChapterLink = TitleLink;											-- |chapter-link= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			URL_origin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			TransChapter_origin = TransTitle_origin;
			Title = BookTitle;
			Format = '';
	--		TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end
	
	-- CS1/2 mode
	local Mode;
		if cfg.global_cs1_config_t['Mode'] then									-- global setting in {{cs1 config}} overrides local |mode= parameter value; nil when empty or assigned value invalid
			Mode = is_valid_parameter_value (cfg.global_cs1_config_t['Mode'], 'cs1 config: mode', cfg.keywords_lists['mode'], '');	-- error messaging 'param' here is a hoax
		else
			Mode = is_valid_parameter_value (A['Mode'], A:ORIGIN('Mode'), cfg.keywords_lists['mode'], '');
		end

		if cfg.global_cs1_config_t['Mode'] and utilities.is_set (A['Mode']) then	-- when template has |mode=&lt;something&gt; which global setting has overridden
			utilities.set_message ('maint_overridden_setting');					-- set a maint message
		end

	-- separator character and postscript
	local sepc, PostScript = set_style (Mode:lower(), A['PostScript'], config.CitationClass);
	-- controls capitalization of certain static text
	local use_lowercase = ( sepc == ',' );
	
	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		if utilities.is_set (Chapter) then										--TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'map') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', Chapter_origin)});	-- add error message
		end
		Chapter = A['Map'];
		Chapter_origin = A:ORIGIN('Map');
		ChapterURL = A['MapURL'];
		ChapterURL_origin = A:ORIGIN('MapURL');
		TransChapter = A['TransMap'];
		ScriptChapter = A['ScriptMap']
		ScriptChapter_origin = A:ORIGIN('ScriptMap')

		ChapterUrlAccess = MapUrlAccess;
		ChapterFormat = A['MapFormat'];

		Cartography = A['Cartography'];
		if utilities.is_set ( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if utilities.is_set ( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	local Series = A['Series'];
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local SeriesLink = A['SeriesLink'];

		SeriesLink = link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wiki-markup in |series-link= or wiki-markup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if utilities.is_set (Network) then table.insert(n, Network); end
		if utilities.is_set (Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if utilities.is_set (Season) and utilities.is_set (SeriesNumber) then	-- these are mutually exclusive so if both are set TODO: make a function for this and similar?
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'season') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'seriesno')});		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if utilities.is_set (Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if utilities.is_set (SeriesNumber) then table.insert(s, wrap_msg ('seriesnum', SeriesNumber, use_lowercase)); end
			if utilities.is_set (Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ScriptChapter_origin = A:ORIGIN('ScriptTitle');
			ChapterLink = TitleLink;											-- alias |episode-link=
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			ChapterFormat = Format;

			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if utilities.is_set (ChapterLink) and not utilities.is_set (ChapterURL) then	-- link but not URL
				Chapter = utilities.make_wikilink (ChapterLink, Chapter);
			elseif utilities.is_set (ChapterLink) and utilities.is_set (ChapterURL) then	-- if both are set, URL links episode;
				Series = utilities.make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			Format = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if utilities.is_set (Series) and utilities.is_set (SeriesLink) then
				Series = utilities.make_wikilink (SeriesLink, Series);
			end
			Series = utilities.wrap_style ('italic-title', Series);				-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- handle type parameter for those CS1 citations that have default values
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	if utilities.in_array (config.CitationClass, {'AV-media-notes', 'document', 'interview', 'mailinglist', 'map', 'podcast', 'pressrelease', 'report', 'speech', 'techreport', 'thesis'}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if utilities.is_set (Degree) and &quot;Thesis&quot; == TitleType then				-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if utilities.is_set (TitleType) then										-- if type parameter is specified
		TitleType = utilities.substitute ( cfg.messages['type'], TitleType);	-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
	local Date = A['Date'];
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging
	local PublicationDate = A['PublicationDate'];
	local Year = A['Year'];

	if not utilities.is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not utilities.is_set (Date) and utilities.is_set (PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]

	local DF = is_valid_parameter_value (A['DF'], A:ORIGIN('DF'), cfg.keywords_lists['df'], '');
	if not utilities.is_set (DF) then
		DF = cfg.global_df;														-- local |df= if present overrides global df set by {{use xxx date}} template
	end

	local ArchiveURL;
	local ArchiveDate;
	local ArchiveFormat = A['ArchiveFormat'];
	local archive_url_timestamp;												-- timestamp from wayback machine url
	
	ArchiveURL, ArchiveDate, archive_url_timestamp = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	
	ArchiveURL, ArchiveDate = is_unique_archive_url (ArchiveURL, URL, ChapterURL, A:ORIGIN('ArchiveURL'), ArchiveDate);		-- add error message when URL or ChapterURL == ArchiveURL

	local AccessDate = A['AccessDate'];
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification
	local DoiBroken = A['DoiBroken'];
	local Embargo = A['Embargo'];
	local anchor_year;															-- used in the CITEREF identifier
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val = AccessDate, name = A:ORIGIN ('AccessDate')},
			['archive-date'] = {val = ArchiveDate, name = A:ORIGIN ('ArchiveDate')},
			['date'] = {val = Date, name = Date_origin},
			['doi-broken-date'] = {val = DoiBroken, name = A:ORIGIN ('DoiBroken')},
			['pmc-embargo-date'] = {val = Embargo, name = A:ORIGIN ('Embargo')},
			['publication-date'] = {val = PublicationDate, name = A:ORIGIN ('PublicationDate')},
			['year'] = {val = Year, name = A:ORIGIN ('Year')},
			};

		local error_list = {};
		anchor_year, Embargo = validation.dates(date_parameters_list, COinS_date, error_list);

-- start temporary Julian / Gregorian calendar uncertainty categorization
		if COinS_date.inter_cal_cat then
			utilities.add_prop_cat ('jul-greg-uncertainty');
		end
-- end temporary Julian / Gregorian calendar uncertainty categorization

		if utilities.is_set (Year) and utilities.is_set (Date) then				-- both |date= and |year= not normally needed; 
			validation.year_date_check (Year, A:ORIGIN ('Year'), Date, A:ORIGIN ('Date'), error_list);
		end
		
		if 0 == #error_list then												-- error free dates only; 0 when error_list is empty
			local modified = false;												-- flag
			
			if utilities.is_set (DF) then										-- if we need to reformat dates
				modified = validation.reformat_dates (date_parameters_list, DF);	-- reformat to DF format, use long month names if appropriate
			end

			if true == validation.date_hyphen_to_dash (date_parameters_list) then	-- convert hyphens to dashes where appropriate
				modified = true;
				utilities.set_message ('maint_date_format');					-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language; not supported at en.wiki
			if cfg.date_name_auto_xlate_enable and validation.date_name_xlate (date_parameters_list, cfg.date_digit_auto_xlate_enable ) then
				utilities.set_message ('maint_date_auto_xlated');				-- add maint cat
				modified = true;
			end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end

			if archive_url_timestamp and utilities.is_set (ArchiveDate) then
				validation.archive_date_check (ArchiveDate, archive_url_timestamp, DF);	-- does YYYYMMDD in archive_url_timestamp match date in ArchiveDate
			end
		else
			utilities.set_message ('err_bad_date', {utilities.make_sep_list (#error_list, error_list)});	-- add this error message
		end
	end	-- end of do

	if utilities.in_array (config.CitationClass, {'book', 'encyclopaedia'}) or	-- {{cite book}}, {{cite encyclopedia}}; TODO: {{cite conference}} and others?
		('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) or			-- {{citation}} as an encylopedia citation
		('citation' == config.CitationClass and not utilities.is_set (Periodical)) then		-- {{citation}} as a book citation
			if utilities.is_set (PublicationPlace) then
				if not utilities.is_set (PublisherName) then
					local date = COinS_date.rftdate and tonumber (COinS_date.rftdate:match ('%d%d%d%d'));	-- get year portion of COinS date (because in Arabic numerals); convert string to number
					if date and (1850 &lt;= date) then								-- location has no publisher; if date is 1850 or later
						utilities.set_message ('maint_location_no_publisher');	-- add maint cat
					end
				else															-- PublisherName has a value
					if cfg.keywords_xlate['none'] == PublisherName then			-- if that value is 'none' (only for book and encyclopedia citations)
						PublisherName = '';										-- unset
					end
				end
			end
	end

	local ID_list = {};															-- sequence table of rendered identifiers
	local ID_list_coins = {};													-- table of identifiers and their values from args; key is same as cfg.id_handlers's key
	local Class = A['Class'];													-- arxiv class identifier
	
	local ID_support = {
		{A['ASINTLD'], 'ASIN', 'err_asintld_missing_asin', A:ORIGIN ('ASINTLD')},				
		{DoiBroken, 'DOI', 'err_doibroken_missing_doi', A:ORIGIN ('DoiBroken')},
		{Embargo, 'PMC', 'err_embargo_missing_pmc', A:ORIGIN ('Embargo')},
		}

	ID_list, ID_list_coins = identifiers.identifier_lists_get (args, {DoiBroken = DoiBroken, ASINTLD = A['ASINTLD'], Embargo = Embargo, Class = Class}, ID_support);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite medrxiv}}, {{cite ssrn}}, before generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list_t) then	-- |arxiv= or |eprint= required for cite arxiv; |biorxiv=, |citeseerx=, |medrxiv=, |ssrn= required for their templates
		if not (args[cfg.id_handlers[config.CitationClass:upper()].parameters[1]] or 		-- can't use ID_list_coins k/v table here because invalid parameters omitted
			args[cfg.id_handlers[config.CitationClass:upper()].parameters[2]]) then			-- which causes unexpected parameter missing error message
				utilities.set_message ('err_' .. config.CitationClass .. '_missing');		-- add error message
		end

		Periodical = ({['arxiv'] = 'arXiv', ['biorxiv'] = 'bioRxiv', ['citeseerx'] = 'CiteSeerX', ['medrxiv'] = 'medRxiv', ['ssrn'] = 'Social Science Research Network'})[config.CitationClass];
	end

	-- Link the title of the work if no |url= was provided, but we have a |pmc= or a |doi= with |doi-access=free

	if config.CitationClass == &quot;journal&quot; and not utilities.is_set (URL) and not utilities.is_set (TitleLink) and not utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) then -- TODO: remove 'none' once existing citations have been switched to 'off', so 'none' can be used as token for &quot;no title&quot; instead
		if 'none' ~= cfg.keywords_xlate[auto_select] then						-- if auto-linking not disabled
 	 		if identifiers.auto_link_urls[auto_select] then						-- manual selection
		 		URL = identifiers.auto_link_urls[auto_select];					-- set URL to be the same as identifier's external link
 				URL_origin = cfg.id_handlers[auto_select:upper()].parameters[1];	-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['pmc'] then						-- auto-select PMC
				URL = identifiers.auto_link_urls['pmc'];						-- set URL to be the same as the PMC external link if not embargoed
				URL_origin = cfg.id_handlers['PMC'].parameters[1];				-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['doi'] then						-- auto-select DOI
				URL = identifiers.auto_link_urls['doi'];
				URL_origin = cfg.id_handlers['DOI'].parameters[1];
			end
 	 	end

		if utilities.is_set (URL) then											-- set when using an identifier-created URL
			if utilities.is_set (AccessDate) then								-- |access-date= requires |url=; identifier-created URL is not |url=
				utilities.set_message ('err_accessdate_missing_url');			-- add an error message
				AccessDate = '';												-- unset
			end

			if utilities.is_set (ArchiveURL) then								-- |archive-url= requires |url=; identifier-created URL is not |url=
				utilities.set_message ('err_archive_missing_url');				-- add an error message
				ArchiveURL = '';												-- unset
			end
		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not utilities.is_set (Title) and not utilities.is_set (TransTitle) and not utilities.is_set (ScriptTitle) then	-- has special case for cite episode
		utilities.set_message ('err_citation_missing_title', {'episode' == config.CitationClass and 'series' or 'title'});
	end

	if utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) and
			utilities.in_array (config.CitationClass, {'journal', 'citation'}) and
			(utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and
			('journal' == Periodical_origin or 'script-journal' == ScriptPeriodical_origin) then	-- special case for journal cites
				Title = '';														-- set title to empty string
				utilities.set_message ('maint_untitled');						-- add maint cat
	end

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Chapter) and utilities.is_set (Title) and utilities.is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end
	
	-- this is the function call to COinS()
	local OCinSoutput = metadata.COinS({
		['Periodical'] = utilities.strip_apostrophe_markup (Periodical),		-- no markup in the metadata
		['Encyclopedia'] = Encyclopedia,										-- just a flag; content ignored by ~/COinS
		['Chapter'] = metadata.make_coins_title (coins_chapter, ScriptChapter),	-- Chapter and ScriptChapter stripped of bold / italic / accept-as-written markup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = metadata.make_coins_title (coins_title, ScriptTitle),		-- Title and ScriptTitle stripped of bold / italic / accept-as-written markup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date.* has correctly formatted date values if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Quarter'] = COinS_date.rftquarter,
		['Chron'] =  COinS_date.rftchron,
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['ArticleNumber'] = ArticleNumber,
		['Pages'] = coins_pages or metadata.get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At, QuotePage, QuotePages}, 7)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName or Newsgroup,							-- any apostrophe markup already removed from PublisherName
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list_coins,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite medrxiv}}, and {{cite ssrn}} AFTER generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list_t) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, CiteSeerX, medRxiv, or ssrn now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass and utilities.is_set (Newsgroup) then
		PublisherName = utilities.substitute (cfg.messages['newsgroup'], external_link( 'news:' .. Newsgroup, Newsgroup, Newsgroup_origin, nil ));
	end

	local Editors;
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	local Contributors;															-- assembled contributors name list
	local contributor_etal;
	local Translators;															-- assembled translators name list
	local translator_etal;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	local Interviewers;															
	local interviewers_list = {};					
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters
	local interviewer_etal;
	
	-- Now perform various field 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.
	do
		local last_first_list;
		local control = { 
			format = NameListStyle,												-- empty string, '&amp;', 'amp', 'and', or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			local display_names, param = display_names_select (cfg.global_cs1_config_t['DisplayEditors'], A['DisplayEditors'], A:ORIGIN ('DisplayEditors'), #e);
			control.maximum, editor_etal = get_display_names (display_names, #e, 'editors', editor_etal, param);

			Editors, EditorCount = list_people (control, e, editor_etal);

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			local display_names, param = display_names_select (cfg.global_cs1_config_t['DisplayInterviewers'], A['DisplayInterviewers'], A:ORIGIN ('DisplayInterviewers'), #interviewers_list);
			control.maximum, interviewer_etal = get_display_names (display_names, #interviewers_list, 'interviewers', interviewer_etal, param);

			Interviewers = list_people (control, interviewers_list, interviewer_etal);
		end
		do																		-- now do translators
			local display_names, param = display_names_select (cfg.global_cs1_config_t['DisplayTranslators'], A['DisplayTranslators'], A:ORIGIN ('DisplayTranslators'), #t);
			control.maximum, translator_etal = get_display_names (display_names, #t, 'translators', translator_etal, param);

			Translators = list_people (control, t, translator_etal);
		end
		do																		-- now do contributors
			local display_names, param = display_names_select (cfg.global_cs1_config_t['DisplayContributors'], A['DisplayContributors'], A:ORIGIN ('DisplayContributors'), #c);
			control.maximum, contributor_etal = get_display_names (display_names, #c, 'contributors', contributor_etal, param);

			Contributors = list_people (control, c, contributor_etal);
		end
		do																		-- now do authors
			local display_names, param = display_names_select (cfg.global_cs1_config_t['DisplayAuthors'], A['DisplayAuthors'], A:ORIGIN ('DisplayAuthors'), #a, author_etal);
			control.maximum, author_etal = get_display_names (display_names, #a, 'authors', author_etal, param);

			last_first_list = list_people (control, a, author_etal);

			if utilities.is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors');	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if utilities.is_set (Authors) and utilities.is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'medrxiv', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not utilities.is_set (URL) then
		if utilities.in_array (config.CitationClass, {&quot;web&quot;, &quot;podcast&quot;, &quot;mailinglist&quot;}) or		-- |url= required for cite web, cite podcast, and cite mailinglist
			('citation' == config.CitationClass and ('website' == Periodical_origin or 'script-website' == ScriptPeriodical_origin)) then	-- and required for {{citation}} with |website= or |script-website=
				utilities.set_message ('err_cite_web_url');
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if utilities.is_set (AccessDate) and not utilities.is_set (ChapterURL) then		-- ChapterURL may be set when URL is not set;
			utilities.set_message ('err_accessdate_missing_url');
			AccessDate = '';
		end
	end

	local UrlStatus = is_valid_parameter_value (A['UrlStatus'], A:ORIGIN('UrlStatus'), cfg.keywords_lists['url-status'], '');
	local OriginalURL
	local OriginalURL_origin
	local OriginalFormat
	local OriginalAccess;
	UrlStatus = UrlStatus:lower();												-- used later when assembling archived text
	if utilities.is_set ( ArchiveURL ) then
		if utilities.is_set (ChapterURL) then 									-- if chapter-url= is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURL_origin = ChapterURL_origin;								-- name of |chapter-url= parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=

			if 'live' ~= UrlStatus then
				ChapterURL = ArchiveURL											-- swap-in the archive's URL
				ChapterURL_origin = A:ORIGIN('ArchiveURL')						-- name of |archive-url= parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived URLs
			end
		elseif utilities.is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURL_origin = URL_origin;									-- name of URL parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;

			if 'live' ~= UrlStatus then											-- if URL set then |archive-url= applies to it
				URL = ArchiveURL												-- swap-in the archive's URL
				URL_origin = A:ORIGIN('ArchiveURL')								-- name of archive URL parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived URLs
			end
		end
	elseif utilities.is_set (UrlStatus) then									-- if |url-status= is set when |archive-url= is not set
 		utilities.set_message ('maint_url_status');								-- add maint cat
	end

	if utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'medrxiv', 'ssrn'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) then
			local chap_param;
			if utilities.is_set (Chapter) then									-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif utilities.is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif utilities.is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif utilities.is_set (ScriptChapter) then
				chap_param = ScriptChapter_origin;
			else utilities.is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if utilities.is_set (chap_param) then								-- if we found one
				utilities.set_message ('err_chapter_ignored', {chap_param});	-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if utilities.is_set (Contribution) and 0 &lt; #c then						-- if this is a contribution with contributor(s)
			if utilities.in_array (Contribution:lower(), cfg.keywords_lists.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, ScriptChapter_origin, Chapter, Chapter_origin, TransChapter, TransChapter_origin, ChapterURL, ChapterURL_origin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if utilities.is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and utilities.is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter .. sepc .. ' ';
		elseif utilities.is_set (ChapterFormat) then							-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title
	local plain_title = false;
	local accept_title;
	Title, accept_title = utilities.has_accept_as_written (Title, true);		-- remove accept-this-as-written markup when it wraps all of &lt;Title&gt;
	if accept_title and ('' == Title) then										-- only support forced empty for now &quot;(())&quot;
		Title = cfg.messages['notitle'];										-- replace by predefined &quot;No title&quot; message
			-- TODO: utilities.set_message ( 'err_redundant_parameters', ...);	-- issue proper error message instead of muting	 
			ScriptTitle = '';													-- just mute for now	 
			TransTitle = '';													-- just mute for now
 		plain_title = true;														-- suppress text decoration for descriptive title
		utilities.set_message ('maint_untitled');								-- add maint cat
	end

	if not accept_title then													-- &lt;Title&gt; not wrapped in accept-as-written markup
		if '...' == Title:sub (-3) then											-- if ellipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%' .. sepc .. '$', '');			-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end

		if utilities.is_set (ArchiveURL) and is_archived_copy (Title) then
			utilities.set_message ('maint_archived_copy');						-- add maintenance category before we modify the content of Title
		end

		if is_generic ('generic_titles', Title) then
			utilities.set_message ('err_generic_title');						-- set an error message
		end
	end

	if (not plain_title) and (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'document', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx', 'medrxiv', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) or
		('map' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)))) then		-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from module provided quote marks
			Title = utilities.wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle, 'script-title');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
			TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );
	elseif plain_title or ('report' == config.CitationClass) then				-- no styling for cite report and descriptive titles (otherwise same as above)
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );	-- for cite report, use this form for trans-title
	else
		Title = utilities.wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-italic-title', TransTitle);
	end

	if utilities.is_set (TransTitle) then
		if utilities.is_set (Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			utilities.set_message ('err_trans_missing_title', {'title'});
		end
	end

	if utilities.is_set (Title) then											-- TODO: is this the right place to be making Wikisource URLs?
		if utilities.is_set (TitleLink) and utilities.is_set (URL) then
			utilities.set_message ('err_wikilink_in_url');						-- set an error message because we can't have both
			TitleLink = '';														-- unset
		end
	
		if not utilities.is_set (TitleLink) and utilities.is_set (URL) then
			Title = external_link (URL, Title, URL_origin, UrlAccess) .. TransTitle .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif utilities.is_set (TitleLink) and not utilities.is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle;
			else
				Title = utilities.make_wikilink (TitleLink, Title) .. TransTitle;
			end
		else
			local ws_url, ws_label, L;											-- Title has italic or quote markup by the time we get here which causes is_wikilink() to return 0 (not a wikilink)
			ws_url, ws_label, L = wikisource_url_make (Title:gsub('^[\'&quot;]*(.-)[\'&quot;]*$', '%1'));	-- make ws URL from |title= interwiki link (strip italic or quote markup); link portion L becomes tooltip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle;
			else
				Title = Title .. TransTitle;
			end
		end
	else
		Title = TransTitle;
	end

	if utilities.is_set (Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	local ConferenceURL_origin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	if utilities.is_set (Conference) then
		if utilities.is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURL_origin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif utilities.is_set (ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURL_origin, nil );
	end

	local Position = '';
	if not utilities.is_set (Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if utilities.is_set (Minutes) then
			if utilities.is_set (Time) then		--TODO: make a function for this and similar?
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'minutes') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'time')});
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if utilities.is_set (Time) then
				local TimeCaption = A['TimeCaption']
				if not utilities.is_set (TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = utilities.is_set (At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = utilities.is_set (Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Sections = A['Sections'];											-- Section (singular) is an alias of Chapter so set earlier
		local Inset = A['Inset'];
		
		if utilities.is_set ( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if utilities.is_set ( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif utilities.is_set ( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	local Others = A['Others'];
	if utilities.is_set (Others) and 0 == #a and 0 == #e then					-- add maint cat when |others= has value and used without |author=, |editor=
		if config.CitationClass == &quot;AV-media-notes&quot;
		or config.CitationClass == &quot;audio-visual&quot; then							-- special maint for AV/M which has a lot of 'false' positives right now
			utilities.set_message ('maint_others_avm')
		else
			utilities.set_message ('maint_others');
		end
	end
	Others = utilities.is_set (Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if utilities.is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if utilities.is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	local TitleNote = A['TitleNote'];
	TitleNote = utilities.is_set (TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if utilities.is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%n?%.?$') or Edition:match ('%f[%a][Ee]dition$') then -- Ed, ed, Ed., ed., Edn, edn, Edn., edn.
			utilities.set_message ('err_extra_text_edition');					 -- add error message
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = utilities.is_set (Series) and wrap_msg ('series', {sepc, Series}) or &quot;&quot;;	-- not the same as SeriesNum
	local Agency = A['Agency'];
	Agency = utilities.is_set (Agency) and wrap_msg ('agency', {sepc, Agency}) or &quot;&quot;;
	Volume = format_volume_issue (Volume, Issue, ArticleNumber, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	if utilities.is_set (AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = utilities.substitute (retrv_text, AccessDate);				-- add retrieved text

		AccessDate = utilities.substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if utilities.is_set (ID) then ID = sepc .. &quot; &quot; .. ID; end
	
	local Docket = A['Docket'];
   	if &quot;thesis&quot; == config.CitationClass and utilities.is_set (Docket) then
		ID = sepc .. &quot; Docket &quot; .. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and utilities.is_set (Docket) then		-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	if utilities.is_set (URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URL_origin, UrlAccess );
	end

	local Quote = A['Quote'];
	local TransQuote = A['TransQuote'];
	local ScriptQuote = A['ScriptQuote'];
	if utilities.is_set (Quote) or utilities.is_set (TransQuote) or utilities.is_set (ScriptQuote) then

		if utilities.is_set (Quote) then
			if Quote:sub(1, 1) == '&quot;' and Quote:sub(-1, -1) == '&quot;' then			-- if first and last characters of quote are quote marks
				Quote = Quote:sub(2, -2);										-- strip them off
			end
		end
		
		Quote = kern_quotes (Quote);											-- kern if needed
		Quote = utilities.wrap_style ('quoted-text', Quote );					-- wrap in &lt;q&gt;...&lt;/q&gt; tags
	
		if utilities.is_set (ScriptQuote) then
			Quote = script_concatenate (Quote, ScriptQuote, 'script-quote');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after quote is wrapped
		end

		if utilities.is_set (TransQuote) then
			if TransQuote:sub(1, 1) == '&quot;' and TransQuote:sub(-1, -1) == '&quot;' then -- if first and last characters of |trans-quote are quote marks
				TransQuote = TransQuote:sub(2, -2); -- strip them off
			end
			Quote = Quote .. &quot; &quot; .. utilities.wrap_style ('trans-quoted-title', TransQuote );
		end

		if utilities.is_set (QuotePage) or utilities.is_set (QuotePages) then	-- add page prefix
			local quote_prefix = '';
			if utilities.is_set (QuotePage) then
				extra_text_in_page_check (QuotePage, 'quote-page');				-- add to maint cat if |quote-page= value begins with what looks like p., pp., etc.
				if not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePage}), '', '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePage}), '', '', '';
				end
			elseif utilities.is_set (QuotePages) then
				extra_text_in_page_check (QuotePages, 'quote-pages');			-- add to maint cat if |quote-pages= value begins with what looks like p., pp., etc.
				if tonumber(QuotePages) ~= nil and not NoPP then				-- if only digits, assume single page
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePages}), '', '';
				elseif not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['pp-prefix'], {sepc, QuotePages}), '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePages}), '', '';
				end
			end
                        
			Quote = quote_prefix .. &quot;: &quot; .. Quote;
		else
			Quote = sepc .. &quot; &quot; .. Quote;
		end

		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	-- We check length of PostScript here because it will have been nuked by
	-- the quote parameters. We'd otherwise emit a message even if there wasn't
	-- a displayed postscript.
	-- TODO: Should the max size (1) be configurable?
	-- TODO: Should we check a specific pattern?
	if utilities.is_set(PostScript) and mw.ustring.len(PostScript) &gt; 1 then
		utilities.set_message ('maint_postscript')
	end
	
	local Archived;
	if utilities.is_set (ArchiveURL) then
		if not utilities.is_set (ArchiveDate) then								-- ArchiveURL set but ArchiveDate not set
			utilities.set_message ('err_archive_missing_date');					-- emit an error message
			ArchiveURL = '';													-- empty string for concatenation
			ArchiveDate = '';													-- empty string for concatenation
		end
	else														
		if utilities.is_set (ArchiveDate) then									-- ArchiveURL not set but ArchiveDate is set
			utilities.set_message ('err_archive_date_missing_url');				-- emit an error message
			ArchiveURL = '';													-- empty string for concatenation
			ArchiveDate = '';													-- empty string for concatenation
		end
	end

	if utilities.is_set (ArchiveURL) then
		local arch_text;
		if &quot;live&quot; == UrlStatus then
			arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if utilities.is_set (ArchiveDate) then
				Archived = sepc .. ' ' .. utilities.substitute ( cfg.messages['archived-live'],
					{external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil) .. ArchiveFormat, ArchiveDate } );
			else
				Archived = '';
			end
			if not utilities.is_set (OriginalURL) then
				utilities.set_message ('err_archive_missing_url');
				Archived = '';													-- empty string for concatenation
			end
		elseif utilities.is_set (OriginalURL) then								-- UrlStatus is empty, 'dead', 'unfit', 'usurped', 'bot: unknown'
			if utilities.in_array (UrlStatus, {'unfit', 'usurped', 'bot: unknown'}) then
				arch_text = cfg.messages['archived-unfit'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. ' ' .. arch_text .. ArchiveDate;				-- format already styled
				if 'bot: unknown' == UrlStatus then
					utilities.set_message ('maint_bot_unknown');				-- and add a category if not already added
				else
					utilities.set_message ('maint_unfit');						-- and add a category if not already added
				end
			else																-- UrlStatus is empty, 'dead'
				arch_text = cfg.messages['archived-dead'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				if utilities.is_set (ArchiveDate) then
					Archived = sepc .. &quot; &quot; .. utilities.substitute ( arch_text,
						{ external_link( OriginalURL, cfg.messages['original'], OriginalURL_origin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
				else
					Archived = '';												-- unset for concatenation
				end
			end	
		else																	-- OriginalUrl not set
			utilities.set_message ('err_archive_missing_url');
			Archived = '';														-- empty string for concatenation
		end
	elseif utilities.is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = '';
	end
	
	local TranscriptURL = A['TranscriptURL']
	local TranscriptFormat = A['TranscriptFormat'];
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');
	local Transcript = A['Transcript'];
	local TranscriptURL_origin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL
	if utilities.is_set (Transcript) then
		if utilities.is_set (TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURL_origin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif utilities.is_set (TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURL_origin, nil );
	end

	local Publisher;
	if utilities.is_set (PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if utilities.is_set (PublisherName) then
		if utilities.is_set (PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif utilities.is_set (PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical)) then
		if utilities.is_set (Title) or utilities.is_set (TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		else 
			Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		end
	end
	
	local Language = A['Language'];
	if utilities.is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc.
	else
		Language='';															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then									-- cite speech only
		TitleNote = TitleType;													-- move TitleType to TitleNote so that it renders ahead of |event=
		TitleType = '';															-- and unset

		if utilities.is_set (Periodical) then									-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if utilities.is_set (Conference) then								-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;							-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
		if not (utilities.is_set (Authors) or utilities.is_set (Editors)) then
			Others = Others:gsub ('^' .. sepc .. ' ', '');						-- when no authors and no editors, strip leading sepc and space
		end
		if utilities.is_set (Others) then Others = safe_join ({Others, sepc .. &quot; &quot;}, sepc) end		-- add terminal punctuation &amp; space; check for dup sepc; TODO why do we need to do this here?
		tcommon = safe_join( {Others, Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Edition, Publisher, Agency, Volume}, sepc );
	elseif utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (Periodical) then		-- special cases for book cites
		if utilities.is_set (Contributors) then									-- when we are citing foreword, preface, introduction, etc.
			tcommon = safe_join( {Title, TitleNote}, sepc );					-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join( {Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		else
			tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc );
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if utilities.is_set (Chapter) then										-- map in a book; TitleType is part of Chapter
			tcommon = safe_join( {Title, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		elseif utilities.is_set (Periodical) then								-- map in a periodical
			tcommon = safe_join( {Title, TitleType, Format, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc );
		else																	-- a sheet or stand-alone map
			tcommon = safe_join( {Title, TitleType, Format, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc );
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join( {Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc );

	else																		-- all other CS1 templates
		tcommon = safe_join( {Title, TitleNote, Conference, Periodical, Format, TitleType, Series, Language, 
			Volume, Others, Edition, Publisher, Agency}, sepc );
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local Via = A['Via'];
	Via = utilities.is_set (Via) and  wrap_msg ('via', Via) or '';
	local idcommon;
	if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then	-- special case for cite AV media &amp; cite episode position transcript
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, Quote }, sepc );
	else
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, Quote }, sepc );
	end
	
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	local OrigDate = A['OrigDate'];
	OrigDate = utilities.is_set (OrigDate) and wrap_msg ('origdate', OrigDate) or '';
	if utilities.is_set (Date) then
		if utilities.is_set (Authors) or utilities.is_set (Editors) then		-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date .. &quot;)&quot; .. OrigDate .. sepc .. &quot; &quot;;				-- in parentheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon, -1, -1) == sepc) then						-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigDate;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigDate;							-- Date begins with sepc
			end
		end
	end	
	if utilities.is_set (Authors) then
		if (not utilities.is_set (Date)) then									-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Editors) then
			local in_text = '';
			local post_text = '';
			if utilities.is_set (Chapter) and 0 == #c then
				in_text = cfg.messages['in'] .. ' ';
				if (sepc ~= '.') then
					in_text = in_text:lower();									-- lowercase for cs2
				end
			end
			if EditorCount &lt;= 1 then
				post_text = ' (' .. cfg.messages['editor'] .. ')';				-- be consistent with no-author, no-date case
			else
				post_text = ' (' .. cfg.messages['editors'] .. ')';
			end
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Contributors) then									-- book cite and we're citing the intro, preface, etc.
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if utilities.is_set (Editors) and utilities.is_set (Date) then		-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not utilities.is_set (Date)) then								-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif utilities.is_set (Editors) then
		if utilities.is_set (Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. cfg.presentation['sep_name'] .. cfg.messages['editor'];
			else
				Editors = Editors .. cfg.presentation['sep_name'] .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end
	
	if utilities.is_set (PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc ); 								-- Deals with italics, spaces, etc.
		text = text:sub(1, -sepc:len() - 1);
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite&gt; element
	local options_t = {};
	options_t.class = cite_class_attribute_make (config.CitationClass, Mode);

	local Ref = is_valid_parameter_value (A['Ref'], A:ORIGIN('Ref'), cfg.keywords_lists['ref'], nil, true);	-- nil when |ref=harv; A['Ref'] else

	if 'none' ~= cfg.keywords_xlate[(Ref and Ref:lower()) or ''] then
		local namelist_t = {};													-- holds selected contributor, author, editor name list
		local year = first_set ({Year, anchor_year}, 2);						-- Year first for legacy citations and for YMD dates that require disambiguation

		if #c &gt; 0 then															-- if there is a contributor list
			namelist_t = c;														-- select it
		elseif #a &gt; 0 then														-- or an author list
			namelist_t = a;
		elseif #e &gt; 0 then														-- or an editor list
			namelist_t = e;
		end
		local citeref_id;
		if #namelist_t &gt; 0 then													-- if there are names in namelist_t
			citeref_id = make_citeref_id (namelist_t, year);					-- go make the CITEREF anchor
			if mw.uri.anchorEncode (citeref_id) == ((Ref and mw.uri.anchorEncode (Ref)) or '') then	-- Ref may already be encoded (by {{sfnref}}) so citeref_id must be encoded before comparison
				utilities.set_message ('maint_ref_duplicates_default');
			end
		else
			citeref_id = '';													-- unset
		end
		options_t.id = Ref or citeref_id;
	end

	if string.len (text:gsub('%b&lt;&gt;', '')) &lt;= 2 then								-- remove html and html-like tags; then get length of what remains; 
		z.error_cats_t = {};													-- blank the categories list
		z.error_msgs_t = {};													-- blank the error messages list
		OCinSoutput = nil;														-- blank the metadata string
		text = '';																-- blank the the citation
		utilities.set_message ('err_empty_citation');							-- set empty citation message and category
	end
	
	local render_t = {};														-- here we collect the final bits for concatenation into the rendered citation

	if utilities.is_set (options_t.id) then										-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render_t, utilities.substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options_t.id), mw.text.nowiki(options_t.class), text}));	-- when |ref= is set or when there is a namelist
	else
		table.insert (render_t, utilities.substitute (cfg.presentation['cite'], {mw.text.nowiki(options_t.class), text}));	-- when |ref=none or when namelist_t empty and |ref= is missing or is empty
	end		

	if OCinSoutput then															-- blanked when citation is 'empty' so don't bother to add boilerplate metadata span
		table.insert (render_t, utilities.substitute (cfg.presentation['ocins'], OCinSoutput));	-- format and append metadata to the citation
	end

	local template_name = ('citation' == config.CitationClass) and 'citation' or 'cite ' .. (cfg.citation_class_map_t[config.CitationClass] or config.CitationClass);
	local template_link = '[[Template:' .. template_name .. '|' .. template_name .. ']]';
	local msg_prefix = '&lt;code class=&quot;cs1-code&quot;&gt;{{' .. template_link .. '}}&lt;/code&gt;: ';

	if 0 ~= #z.error_msgs_t then
		mw.addWarning (utilities.substitute (cfg.messages.warning_msg_e, template_link));

		table.insert (render_t, ' ');											-- insert a space between citation and its error messages
		table.sort (z.error_msgs_t);											-- sort the error messages list; sorting includes wrapping &lt;span&gt; and &lt;code&gt; tags; hidden-error sorts ahead of visible-error

		local hidden = true;													-- presume that the only error messages emited by this template are hidden
		for _, v in ipairs (z.error_msgs_t) do									-- spin through the list of error messages
			if v:find ('cs1-visible-error', 1, true) then						-- look for the visible error class name
				hidden = false;													-- found one; so don't hide the error message prefix
				break;															-- and done because no need to look further
			end
		end

		z.error_msgs_t[1] = table.concat ({utilities.error_comment (msg_prefix, hidden), z.error_msgs_t[1]});	-- add error message prefix to first error message to prevent extraneous punctuation
		table.insert (render_t, table.concat (z.error_msgs_t, '; '));			-- make a big string of error messages and add it to the rendering
	end

	if 0 ~= #z.maint_cats_t then
		mw.addWarning (utilities.substitute (cfg.messages.warning_msg_m, template_link));

		table.sort (z.maint_cats_t);											-- sort the maintenance messages list

		local maint_msgs_t = {};												-- here we collect all of the maint messages

		if 0 == #z.error_msgs_t then											-- if no error messages
			table.insert (maint_msgs_t, msg_prefix);							-- insert message prefix in maint message livery
		end
		
		for _, v in ipairs( z.maint_cats_t ) do									-- append maintenance categories
			table.insert (maint_msgs_t, 										-- assemble new maint message and add it to the maint_msgs_t table
				table.concat ({v, ' (', utilities.substitute (cfg.messages[':cat wikilink'], v), ')'})
				);
		end
		table.insert (render_t, utilities.substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs_t, ' ')));	-- wrap the group of maint messages with proper presentation and save
	end

	if not no_tracking_cats then
		local sort_key;
		local cat_wikilink = 'cat wikilink';
		if cfg.enable_sort_keys then											-- when namespace sort keys enabled
			local namespace_number = mw.title.getCurrentTitle().namespace;		-- get namespace number for this wikitext
			sort_key = (0 ~= namespace_number and (cfg.name_space_sort_keys[namespace_number] or cfg.name_space_sort_keys.other)) or nil;	-- get sort key character; nil for mainspace
			cat_wikilink = (not sort_key and 'cat wikilink') or 'cat wikilink sk';	-- make &lt;cfg.messages&gt; key
		end				

		for _, v in ipairs (z.error_cats_t) do									-- append error categories
			table.insert (render_t, utilities.substitute (cfg.messages[cat_wikilink], {v, sort_key}));
		end
		for _, v in ipairs (z.maint_cats_t) do									-- append maintenance categories
			table.insert (render_t, utilities.substitute (cfg.messages[cat_wikilink], {v, sort_key}));
		end

		for _, v in ipairs (z.prop_cats_t) do									-- append properties categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));	-- no sort keys
		end
	end

	return table.concat (render_t);												-- make a big string and done
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class, empty)
	local name = tostring (name);
	local enum_name;															-- parameter name with enumerator (if any) replaced with '#'
	local state;
	local function state_test (state, name)										-- local function to do testing of state values
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			if empty then return nil; end										-- empty deprecated parameters are treated as unknowns
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
		if 'tracked' == state then
			local base_name = name:gsub ('%d', '');								-- strip enumerators from parameter names that have them to get the base name
			utilities.add_prop_cat ('tracked-param', {base_name}, base_name);	-- add a properties category; &lt;base_name&gt; modifies &lt;key&gt;
			return true;
		end
		return nil;
	end		

	if name:find ('#') then														-- # is a cs1|2 reserved character so parameters with # not permitted
		return nil;
	end
																				-- replace wnumerator digit(s) with # (|last25= becomes |last#=) (mw.ustring because non-Western 'local' digits)
	enum_name = mw.ustring.gsub (name, '%d+$', '#');							-- where enumerator is last charaters in parameter name (these to protect |s2cid=)
	enum_name = mw.ustring.gsub (enum_name, '%d+([%-l])', '#%1');				-- where enumerator is in the middle of the parameter name; |author#link= is the oddity

	if 'document' == cite_class then											-- special case for {{cite document}}
		state = whitelist.document_parameters_t[enum_name];						-- this list holds enumerated and nonenumerated parameters
		if true == state_test (state, name) then return true; end
		
		return false;
	end

	if utilities.in_array (cite_class, whitelist.preprint_template_list_t) then	-- limited parameter sets allowed for these templates
		state = whitelist.limited_parameters_t[enum_name];						-- this list holds enumerated and nonenumerated parameters
		if true == state_test (state, name) then return true; end

		state = whitelist.preprint_arguments_t[cite_class][name];				-- look in the parameter-list for the template identified by cite_class
		if true == state_test (state, name) then return true; end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates

	if utilities.in_array (cite_class, whitelist.unique_param_template_list_t) then 	-- template-specific parameters for templates that accept parameters from the basic argument list
		state = whitelist.unique_arguments_t[cite_class][name];					-- look in the template-specific parameter-lists for the template identified by cite_class
		if true == state_test (state, name) then return true; end
	end																			-- if here, fall into general validation

	state = whitelist.common_parameters_t[enum_name];							-- all other templates; all normal parameters allowed; this list holds enumerated and nonenumerated parameters
	if true == state_test (state, name) then return true; end

	return false;																-- not supported because not found or name is set to nil
end


--[=[-------------------------&lt; I N T E R _ W I K I _ C H E C K &gt;----------------------------------------------

check &lt;value&gt; for inter-language interwiki-link markup.  &lt;prefix&gt; must be a MediaWiki-recognized language
code.  when these values have the form (without leading colon):
	[[&lt;prefix&gt;:link|label]] return label as plain-text
	[[&lt;prefix&gt;:link]] return &lt;prefix&gt;:link as plain-text

return value as is else

]=]

local function inter_wiki_check (parameter, value)
	local prefix = value:match ('%[%[(%a+):');									-- get an interwiki prefix if one exists
	local _;
	
	if prefix and cfg.inter_wiki_map[prefix:lower()] then						-- if prefix is in the map, needs preceding colon so
		utilities.set_message ('err_bad_paramlink', parameter);					-- emit an error message
		_, value, _ = utilities.is_wikilink (value);							-- extract label portion from wikilink
	end
	return value;
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe.  There are two tests made:
	{{cite ... |title=Title access-date=2016-03-17}}	-- the first parameter has a value and whitespace separates that value from the missing pipe parameter name
	{{cite ... |title=access-date=2016-03-17}}			-- the first parameter has no value (whitespace after the first = is trimmed by MediaWiki)
cs1|2 shares some parameter names with XML/HTML attributes: class=, title=, etc.  To prevent false positives XML/HTML
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (parameter, value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove XML/HTML tags because attributes: class=, title=, etc.

	capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then										-- if the capture is a valid parameter name
		utilities.set_message ('err_missing_pipe', parameter);
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ P U N C T &gt;--------------------------------------

look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_punc (param, value)
	if 'number' == type (param) then
		return;
	end
	
	param = param:gsub ('%d+', '#');											-- enumerated name-list mask params allow terminal punct; normalize 
	if cfg.punct_skip[param] then
		return;																	-- parameter name found in the skip table so done
	end
	
	if value:match ('[,;:]$') then
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
	if value:match ('^=') then													-- sometimes an extraneous '=' character appears ...
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ U R L &gt;------------------------------------------

look for extraneous url parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_url (url_param_t)
	local url_error_t = {};
	
	check_for_url (url_param_t, url_error_t);									-- extraneous url check
	if 0 ~= #url_error_t then													-- non-zero when there are errors
		table.sort (url_error_t);
		utilities.set_message ('err_param_has_ext_link', {utilities.make_sep_list (#url_error_t, url_error_t)});	-- add this error message
	end
end


--[[--------------------------&lt; C I T A T I O N &gt;--------------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

local function citation(frame)
	Frame = frame;																-- save a copy in case we need to display an error message in preview mode

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do											-- get parameters from the {{#invoke}} frame
		config[k] = v;
	--	args[k] = v;															-- crude debug support that allows us to render a citation from module {{#invoke:}}; skips parameter validation; TODO: keep?
	end	
																				-- i18n: set the name that your wiki uses to identify sandbox subpages from sandbox template invoke (or can be set here)
	local sandbox = ((config.SandboxPath and '' ~= config.SandboxPath) and config.SandboxPath) or '/sandbox';	-- sandbox path from {{#invoke:Citation/CS1/sandbox|citation|SandboxPath=/...}}
	is_sandbox = nil ~= string.find (frame:getTitle(), sandbox, 1, true);		-- is this invoke the sandbox module?
	sandbox = is_sandbox and sandbox or '';										-- use i18n sandbox to load sandbox modules when this module is the sandox; live modules else

	local pframe = frame:getParent()
	local styles;
	
	cfg = mw.loadData ('Module:Citation/CS1/Configuration' .. sandbox);			-- load sandbox versions of support modules when {{#invoke:Citation/CS1/sandbox|...}}; live modules else
	whitelist = mw.loadData ('Module:Citation/CS1/Whitelist' .. sandbox);
	utilities = require ('Module:Citation/CS1/Utilities' .. sandbox);
	validation = require ('Module:Citation/CS1/Date_validation' .. sandbox);
	identifiers = require ('Module:Citation/CS1/Identifiers' .. sandbox);
	metadata = require ('Module:Citation/CS1/COinS' .. sandbox);
	styles = 'Module:Citation/CS1' .. sandbox .. '/styles.css';

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the selected cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	is_preview_mode = not utilities.is_set (frame:preprocess ('{{REVISIONID}}'));

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text;															-- used as a flag

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	local empty_unknowns = {};													-- sequence table to hold empty unknown params for error message listing
	for k, v in pairs( pframe.args ) do											-- get parameters from the parent (template) frame
		v = mw.ustring.gsub (v, '^%s*(.-)%s*$', '%1');							-- trim leading/trailing whitespace; when v is only whitespace, becomes empty string
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				if type (k) ~= 'string' then									-- exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text = utilities.set_message ('err_text_ignored', {v});
					end
				elseif validate (k:lower(), config.CitationClass) then 
					error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, k:lower()});	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						suggestions = mw.loadData ('Module:Citation/CS1/Suggestions' .. sandbox);	--load sandbox version of suggestion module when {{#invoke:Citation/CS1/sandbox|...}}; live module else
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no capture in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = utilities.substitute (param, capture);		-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, param});	-- set the suggestion error message
							else
								error_text = utilities.set_message ('err_parameter_ignored', {k});	-- suggested param not supported by this template
								v = '';											-- unset
							end
						end
					end
					if not utilities.is_set (error_text) then					-- couldn't match with a pattern, is there an explicit suggestion?						
						if (suggestions.suggestions[ k:lower() ] ~= nil) and validate (suggestions.suggestions[ k:lower() ], config.CitationClass) then
							utilities.set_message ('err_parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]});
						else
							utilities.set_message ('err_parameter_ignored', {k});
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
			end

			args[k] = v;														-- save this parameter and its value

		elseif not utilities.is_set (v) then									-- for empty parameters
			if not validate (k, config.CitationClass, true) then				-- is this empty parameter a valid parameter
				k = ('' == k) and '(empty string)' or k;						-- when k is empty string (or was space(s) trimmed to empty string), replace with descriptive text
				table.insert (empty_unknowns, utilities.wrap_style ('parameter', k));	-- format for error message and add to the list
			end
																				-- crude debug support that allows us to render a citation from module {{#invoke:}} TODO: keep?
	--	elseif args[k] ~= nil or (k == 'postscript') then						-- when args[k] has a value from {{#invoke}} frame (we don't normally do that)
	--		args[k] = v;														-- overwrite args[k] with empty string from pframe.args[k] (template frame); v is empty string here
		end																		-- not sure about the postscript bit; that gets handled in parameter validation; historical artifact?
	end	

	if 0 ~= #empty_unknowns then												-- create empty unknown error message
		utilities.set_message ('err_param_unknown_empty', {
			1 == #empty_unknowns and '' or 's',
			utilities.make_sep_list (#empty_unknowns, empty_unknowns)
			});
	end

	local url_param_t = {};

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);											-- look for invisible characters
		end
		has_extraneous_punc (k, v);												-- look for extraneous terminal punctuation in parameter values
		missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?
		args[k] = inter_wiki_check (k, v);										-- when language interwiki-linked parameter missing leading colon replace with wiki-link label

		if 'string' == type (k) and not cfg.url_skip[k] then					-- when parameter k is not positional and not in url skip table
			url_param_t[k] = v;													-- make a parameter/value list for extraneous url check
		end
	end

	has_extraneous_url (url_param_t);											-- look for url in parameter values where a url does not belong

	return table.concat ({
		frame:extensionTag ('templatestyles', '', {src=styles}),
		citation0( config, args)
	});
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {citation = citation};</text>
      <sha1>1hbbjps2hgnrxlwzaes2de7t1ul73f4</sha1>
    </revision>
    <revision>
      <id>4754</id>
      <parentid>4753</parentid>
      <timestamp>2024-03-23T15:32:48Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4754</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="226159" sha1="7sahwn7umrpjn8voh7tpvtm2yhs02x8" xml:space="preserve">require ('strict');

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------

each of these counts against the Lua upvalue limit

]]

local validation;																-- functions in Module:Citation/CS1/Date_validation

local utilities;																-- functions in Module:Citation/CS1/Utilities
local z = {};																	-- table of tables in Module:Citation/CS1/Utilities

local identifiers;																-- functions and tables in Module:Citation/CS1/Identifiers
local metadata;																	-- functions in Module:Citation/CS1/COinS
local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;---------------

declare variables here that have page-wide scope that are not brought in from
other modules; that are created here and used here

]]

local added_deprecated_cat;														-- Boolean flag so that the category is added only once
local added_vanc_errs;															-- Boolean flag so we only emit one Vancouver error / category
local added_generic_name_errs;													-- Boolean flag so we only emit one generic name error / category and stop testing names once an error is encountered
local added_numeric_name_errs;													-- Boolean flag so we only emit one numeric name error / category and stop testing names once an error is encountered
local added_numeric_name_maint;													-- Boolean flag so we only emit one numeric name maint category and stop testing names once a category has been emitted
local Frame;																	-- holds the module's frame table
local is_preview_mode;															-- true when article is in preview mode; false when using 'Preview page with this template' (previewing the module)
local is_sandbox;																-- true when using sandbox modules to render citation


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if utilities.is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a Boolean declared in page scope variables above

]]

local function add_vanc_error (source, position)
	if added_vanc_errs then return end
		
	added_vanc_errs = true;														-- note that we've added this category
	utilities.set_message ('err_vancouver', {source, position});
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a URI scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of TLDs: https://www.iana.org/domains/root/db

RFC 952 (modified by RFC 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the TLD.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a URL with a scheme) will be stripped
here.  Perhaps not necessary but retained in case it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ASCII characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the TLD) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and TLD or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%w]') then											-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at Wikisource
		return false;
	end

	local patterns = {															-- patterns that look like URLs
		'%f[%w][%w][%w%-]+[%w]%.%a%a+$',										-- three or more character hostname.hostname or hostname.tld
		'%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$',									-- internationalized domain name with ACE prefix
		'%f[%a][qxz]%.com$',													-- assigned one character .com hostname (x.com times out 2015-12-10)
		'%f[%a][iq]%.net$',														-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		'%f[%w][%w]%.%a%a$',													-- one character hostname and ccTLD (2 chars)
		'%f[%w][%w][%w]%.%a%a+$',												-- two character hostname and TLD
		'^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?',								-- IPv4 address
		}

	for _, pattern in ipairs (patterns) do										-- loop through the patterns list
		if domain:match (pattern) then
			return true;														-- if a match then we think that this thing that purports to be a URL is a URL
		end
	end

	for _, d in ipairs (cfg.single_letter_2nd_lvl_domains_t) do					-- look for single letter second level domain names for these top level domains
		if domain:match ('%f[%w][%w]%.' .. d) then
			return true
		end
	end
	return false;																-- no matches, we don't know what this thing is
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a URL appear to be a valid URL; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if utilities.is_set (scheme) then											-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when URL is protocol-relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a URL into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following TLD) (if any) and any path(/), query(?) or fragment(#).

If protocol-relative URL, return nil scheme and domain else return nil for both scheme and domain.

When not protocol-relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Any URL that does not have news: scheme must have authority indicator (//).  TODO: are there other common schemes
like news: that don't use authority indicator?

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol-relative URL
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		if utilities.is_set (authority) then
			authority = authority:gsub ('//', '', 1);							-- replace place 1 pair of '/' with nothing;
			if utilities.is_set(authority) then									-- if anything left (1 or 3+ '/' where authority should be) then
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		else
			if not scheme:match ('^news:') then									-- except for news:..., MediaWiki won't link URLs that do not have authority indicator; TODO: a better way to do this test?
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link=, etc. for properly formatted content: no wikilinks, no URLs

Link parameters are to hold the title of a Wikipedia article, so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki URLs and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid URL (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid URL (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from URL; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid URL
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wiki-linked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

check &lt;link&gt; for inter-language interwiki-link prefix.  prefix must be a MediaWiki-recognized language
code and must begin with a colon.

]]

local function link_title_ok (link, lorig, title, torig)
	local orig;
	if utilities.is_set (link) then 											-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		elseif link:match ('^%a+:') then										-- if the link is what looks like an interwiki
			local prefix = link:match ('^(%a+):'):lower();						-- get the interwiki prefix

			if cfg.inter_wiki_map[prefix] then									-- if prefix is in the map, must have preceding colon
				orig = lorig;													-- flag as error
			end
		end
	end

	if utilities.is_set (orig) then
		link = '';																-- unset
		utilities.set_message ('err_bad_paramlink', orig);						-- URL or wikilink in |title= with |title-link=;
	end
	
	return link;																-- link if ok, empty string else
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the URL into scheme and domain
portions, or for protocol-relative (//example.com) URLs, just the domain.  Use is_url() to validate the two
portions of the URL.  If both are valid, or for protocol-relative if domain is valid, return true, else false.

Because it is different from a standard URL, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper URL
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from URL;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a URL.  The test will also find external wikilinks
that use protocol-relative URLs. Also finds bare URLs.

The frontier pattern prevents a match on interwiki-links which are similar to scheme:path URLs.  The tests that
find bracketed URLs are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext. wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol-relative ext. wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare URL with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol-relative bare URL: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a URL
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list, error_list)
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a URL add an error message
			table.insert (error_list, utilities.wrap_style ('parameter', k));
		end
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		utilities.set_message ('err_wikilink_in_url', {});
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link (URL, label, source, access)
	local err_msg = '';
	local domain;
	local path;
	local base_url;

	if not utilities.is_set (label) then
		label = URL;
		if utilities.is_set (source) then
			utilities.set_message ('err_bare_url_missing_title', {utilities.wrap_style ('parameter', source)});
		else
			error (cfg.messages[&quot;bare_url_no_origin&quot;]);							-- programmer error; valid parameter name does not have matching meta-parameter
		end			
	end
	if not check_url (URL) then
		utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)});
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the URL into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['['] = '%5b', [']'] = '%5d'});			-- replace '[' and ']' with their percent-encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat ({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wiki-markup URL

	if utilities.is_set (access) then											-- access level (subscription, registration, limited)
		base_url = utilities.substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end

	return base_url;
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a Boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		utilities.set_message ('err_deprecated_params', {name});				-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wiki-markup) are not kerned.

Replaces Unicode quote marks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc.; not for book titles.

]=]

local function kern_quotes (str)
	local cap = '';
	local wl_type, label, link;

	wl_type, label, link = utilities.is_wikilink (str);							-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-left'], str);
			str = utilities.substitute (cfg.presentation['kern-right'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = utilities.substitute (cfg.presentation['kern-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label = mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label = mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap = mw.ustring.match (label, &quot;^([\&quot;\'][^\'].+)&quot;);						-- match leading double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-left'], cap);
		end
	
		cap = mw.ustring.match (label, &quot;^(.+[^\'][\&quot;\'])$&quot;)						-- match trailing double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-right'], cap);
		end
		
		if 2 == wl_type then
			str = utilities.make_wikilink (link, label);						-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin-based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate RTL languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO 639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO 639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title=, |script-chapter=, |script-&lt;periodical&gt;=

]]

local function format_script_value (script_value, script_param)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%l?%s*:') then									-- if first 3 or 4 non-space characters are script language prefix
		lang = script_value:match('^(%l%l%l?)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not utilities.is_set (lang) then
			utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['missing title part']});		-- prefix without 'title'; add error message
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_tag_remap[lang] or mw.language.fetchLanguageName( lang, cfg.this_wiki_code );	-- get language name so that we can use it to categorize
		if utilities.is_set (name) then											-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l+%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if utilities.in_array (lang, cfg.script_lang_codes) then
				utilities.add_prop_cat ('script', {name, lang})
			else
				utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['unknown language code']});	-- unknown script-language; add error message
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['invalid language code']});		-- invalid language code; add error message
			lang = '';															-- invalid so set lang to empty string
		end
	else
		utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['missing prefix']});				-- no language code prefix; add error message
	end
	script_value = utilities.substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is RTL

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script
value has been wrapped in &lt;bdi&gt; tags.

]]

local function script_concatenate (title, script, script_param)
	if utilities.is_set (script) then
		script = format_script_value (script, script_param);					-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; returns empty string on error
		if utilities.is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not utilities.is_set ( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return utilities.substitute ( msg, str );								-- including template text
	else
		return utilities.substitute ( cfg.messages[key], str );
	end		
end


--[[----------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;-------------------

Makes a Wikisource URL from Wikisource interwiki-link.  Returns the URL and appropriate
label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;
	local wikisource_prefix = table.concat ({'https://', cfg.this_wiki_code, '.wikisource.org/wiki/'});

	wl_type, D, L = utilities.is_wikilink (str);								-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 1 == wl_type then													-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end

	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable URL
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent-encoding of fragment marker
	end

	return ws_url, ws_label, L or D;											-- return proper URL or nil and a label or nil
end


--[[----------------&lt; F O R M A T _ P E R I O D I C A L &gt;-----------------------

Format the three periodical parameters: |script-&lt;periodical&gt;=, |&lt;periodical&gt;=,
and |trans-&lt;periodical&gt;= into a single Periodical meta-parameter.

]]

local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)

	if not utilities.is_set (periodical) then
		periodical = '';														-- to be safe for concatenation
	else
		periodical = utilities.wrap_style ('italic-title', periodical);			-- style 
	end

	periodical = script_concatenate (periodical, script_periodical, script_periodical_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (trans_periodical) then
		trans_periodical = utilities.wrap_style ('trans-italic-title', trans_periodical);
		if utilities.is_set (periodical) then
			periodical = periodical .. ' ' .. trans_periodical;
		else																	-- here when trans-periodical without periodical or script-periodical
			periodical = trans_periodical;
			utilities.set_message ('err_trans_missing_title', {'periodical'});
		end
	end

	return periodical;
end


--[[------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;---------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=,
and |chapter-url= into a single chapter meta- parameter (chapter_url_source used
for error messages).

]]

local function format_chapter_title (script_chapter, script_chapter_source, chapter, chapter_source, trans_chapter, trans_chapter_source, chapter_url, chapter_url_source, no_quotes, access)
	local ws_url, ws_label, L = wikisource_url_make (chapter);					-- make a wikisource URL and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', ' ');									-- replace underscore separators with space characters
		chapter = ws_label;
	end

	if not utilities.is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from module provided quote marks
			chapter = utilities.wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, script_chapter, script_chapter_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (chapter_url) then
		chapter = external_link (chapter_url, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');	-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if utilities.is_set (trans_chapter) then
		trans_chapter = utilities.wrap_style ('trans-quoted-title', trans_chapter);
		if utilities.is_set (chapter) then
			chapter = chapter .. ' ' .. trans_chapter;
		else																	-- here when trans_chapter without chapter or script-chapter
			chapter = trans_chapter;
			chapter_source = trans_chapter_source:match ('trans%-?(.+)');		-- when no chapter, get matching name from trans-&lt;param&gt;
			utilities.set_message ('err_trans_missing_title', {chapter_source});
		end
	end

	return chapter;
end


--[[----------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;-------------------

This function searches a parameter's value for non-printable or invisible characters.
The search stops at the first match.

This function will detect the visible replacement character when it is part of the Wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers
(gallery, math, pre, ref) and identifies them with a slightly different error message.
See also coins_cleanup().

Output of this function is an error message that identifies the character or the
Unicode group, or the stripmarker that was detected along with its position (or,
for multi-byte characters, the position of its first byte) in the parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local stripmarker;															-- boolean set true when a stripmarker is found

	capture = string.match (v, '[%w%p ]*');										-- test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no Unicode characters
		return;
	end

	for _, invisible_char in ipairs (cfg.invisible_chars) do
		local char_name = invisible_char[1];									-- the character or group name
		local pattern = invisible_char[2];										-- the pattern used to find it
		position, _, capture = mw.ustring.find (v, pattern);					-- see if the parameter value contains characters that match the pattern
		
		if position and (cfg.invisible_defs.zwj == capture) then				-- if we found a zero-width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- it's ok if one of the Indic scripts
				position = nil;													-- unset position
			elseif cfg.emoji_t[mw.ustring.codepoint (v, position+1)] then			-- is zwj followed by a character listed in emoji{}?
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and utilities.in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and cfg.invisible_defs.del == capture then	-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture and not (cfg.invisible_defs.del == capture or cfg.invisible_defs.zwj == capture) then
					err_msg = capture .. ' ' .. char_name;
				else
					err_msg = char_name .. ' ' .. 'character';
				end

				utilities.set_message ('err_invisible_char', {err_msg, utilities.wrap_style ('parameter', param), position});	-- add error message
				return;															-- and done with this parameter
			end
		end
	end
end


--[[-------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------

Argument wrapper.  This function provides support for argument mapping defined
in the configuration file so that multiple names can be transparently aliased to
single internal variable.

]]

local function argument_wrapper ( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function ( self, k )
			local dummy = self[k];												-- force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = utilities.select_one ( args, list, 'err_redundant_parameters' );
				if origin[k] == nil then
					origin[k] = '';												-- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] .. ': ' .. k);
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;-------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.
When date is DD MMMM YYYY or is MMMM DD, YYYY then wrap in nowrap span:
&lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap = '';
	local cap2 = '';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = utilities.substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = utilities.substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;---------------------

This function sets default title types (equivalent to the citation including
|type=&lt;default value&gt;) for those templates that have defaults. Also handles the
special case where it is desirable to omit the title type from the rendered citation
(|type=none).

]]

local function set_titletype (cite_class, title_type)
	if utilities.is_set (title_type) then
		if 'none' == cfg.keywords_xlate[title_type] then
			title_type = '';													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; S A F E _ J O I N &gt;-----------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'duplicate character'
		if 1 == #duplicate_char then											-- for single byte ASCII characters use the string library functions
			f.gsub = string.gsub
			f.match = string.match
			f.sub = string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub = mw.ustring.gsub
			f.match = mw.ustring.match
			f.sub = mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1, 1) == '&lt;' then										-- special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove HTML markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1, 1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc.?
				trim = false;
				end_chr = f.sub(str, -1, -1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr .. &quot;)&quot;				-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1, -2);									-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;''&quot; then		-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5, -1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;]]&quot; then		-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3, -1) == duplicate_char .. '&quot;]' then	-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2, -1) == duplicate_char .. &quot;]&quot; then	-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2, -1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1, -3);								-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains HTML markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows HTML markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value; 												-- add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;-----------------------------

returns true if suffix is properly formed Jr, Sr, or ordinal in the range 1–9.
Puncutation not allowed.

]]

local function is_suffix (suffix)
	if utilities.in_array (suffix, {'Jr', 'Sr', 'Jnr', 'Snr', '1st', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;-------------------

For Vancouver style, author/editor names are supposed to be rendered in Latin
(read ASCII) characters.  When a name uses characters that contain diacritical
marks, those characters are to be converted to the corresponding Latin
character. When a name is written using a non-Latin alphabet or logogram, that
name is to be transliterated into Latin characters. The module doesn't do this
so editors may/must.

This test allows |first= and |last= names to contain any of the letters defined
in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes.
	(http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;)
	or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written outside of the code editor and pasted here because the code editor
gets confused between character insertion point and cursor position. The test has
been rewritten to use decimal character escape sequence for the individual bytes
of the Unicode characters so that it is not necessary to use an external editor
to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first, suffix, position)
	if not suffix then
		if first:find ('[,%s]') then											-- when there is a space or comma, might be first name/initials + generational suffix
			first = first:match ('(.-)[,%s]+');									-- get name/initials
			suffix = first:match ('[,%s]+(.+)$');								-- get generational suffix
		end
	end
	if utilities.is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error (cfg.err_msg_supl.suffix, position);
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143\225\184\128-\225\187\191%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143\225\184\128-\225\187\191%-%s%'%.]*$&quot;) then
			add_vanc_error (cfg.err_msg_supl['non-Latin char'], position);
			return false;														-- not a string of Latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-style=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period.
See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc.) to be rendered
as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format
because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the
Unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials (first, position)
	if first:find (',', 1, true) then
		return first;															-- commas not allowed; abandon
	end

	local name, suffix = mw.ustring.match (first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match (first, &quot;^(%u+)$&quot;);								-- is it just initials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error (cfg.err_msg_supl.suffix, position);			-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word

	local initials_t, names_t = {}, {};											-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names_t = mw.text.split (first, '[%s%-]+');									-- split into a sequence of names and possible suffix

	while names_t[i] do															-- loop through the sequence
		if 1 &lt; i and names_t[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names_t[i] = names_t[i]:gsub ('%.', '');							-- remove terminal dot if present
			if is_suffix (names_t[i]) then										-- if a legitimate suffix
				table.insert (initials_t, ' ' .. names_t[i]);					-- add a separator space, insert at end of initials sequence
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials_t, mw.ustring.sub (names_t[i], 1, 1));		-- insert the initial at end of initials sequence
		end
		i = i + 1;																-- bump the counter
	end
			
	return table.concat (initials_t);											-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; I N T E R W I K I _ P R E F I X E N _ G E T &gt;----------------------------------

extract interwiki prefixen from &lt;value&gt;.  Returns two one or two values:
	false – no prefixen
	nil – prefix exists but not recognized
	project prefix, language prefix – when value has either of:
		:&lt;project&gt;:&lt;language&gt;:&lt;article&gt;
		:&lt;language&gt;:&lt;project&gt;:&lt;article&gt;
	project prefix, nil – when &lt;value&gt; has only a known single-letter prefix
	nil, language prefix – when &lt;value&gt; has only a known language prefix

accepts single-letter project prefixen: 'd' (wikidata), 's' (wikisource), and 'w' (wikipedia) prefixes; at this
writing, the other single-letter prefixen (b (wikibook), c (commons), m (meta), n (wikinews), q (wikiquote), and
v (wikiversity)) are not supported.

]]

local function interwiki_prefixen_get (value, is_link)
	if not value:find (':%l+:') then											-- if no prefix
		return false;															-- abandon; boolean here to distinguish from nil fail returns later
	end

	local prefix_patterns_linked_t = {											-- sequence of valid interwiki and inter project prefixen
		'^%[%[:([dsw]):(%l%l+):',												-- wikilinked; project and language prefixes
		'^%[%[:(%l%l+):([dsw]):',												-- wikilinked; language and project prefixes
		'^%[%[:([dsw]):',														-- wikilinked; project prefix
		'^%[%[:(%l%l+):',														-- wikilinked; language prefix
		}
		
	local prefix_patterns_unlinked_t = {										-- sequence of valid interwiki and inter project prefixen
		'^:([dsw]):(%l%l+):',													-- project and language prefixes
		'^:(%l%l+):([dsw]):',													-- language and project prefixes
		'^:([dsw]):',															-- project prefix
		'^:(%l%l+):',															-- language prefix
		}
	
	local cap1, cap2;
	for _, pattern in ipairs ((is_link and prefix_patterns_linked_t) or prefix_patterns_unlinked_t) do
		cap1, cap2 = value:match (pattern);
		if cap1 then
			break;																-- found a match so stop looking
		end
	end
	
	if cap1 and cap2 then														-- when both then :project:language: or :language:project: (both forms allowed)
		if 1 == #cap1 then														-- length == 1 then :project:language:
			if cfg.inter_wiki_map[cap2] then									-- is language prefix in the interwiki map?
				return cap1, cap2;												-- return interwiki project and interwiki language
			end
		else																	-- here when :language:project:
			if cfg.inter_wiki_map[cap1] then									-- is language prefix in the interwiki map?
				return cap2, cap1;												-- return interwiki project and interwiki language
			end
		end
		return nil;																-- unknown interwiki language
	elseif not (cap1 or cap2) then												-- both are nil?
		return nil;																-- we got something that looks like a project prefix but isn't; return fail
	elseif 1 == #cap1 then														-- here when one capture
		return cap1, nil;														-- length is 1 so return project, nil language
	else																		-- here when one capture and its length it more than 1
		if cfg.inter_wiki_map[cap1] then										-- is language prefix in the interwiki map?
			return nil, cap1;													-- return nil project, language
		end
	end
end


--[[--------------------------&lt; L I S T _ P E O P L E &gt;--------------------------

Formats a list of people (authors, contributors, editors, interviewers, translators) 

names in the list will be linked when
	|&lt;name&gt;-link= has a value
	|&lt;name&gt;-mask- does NOT have a value; masked names are presumed to have been
		rendered previously so should have been linked there

when |&lt;name&gt;-mask=0, the associated name is not rendered

]]

local function list_people (control, people, etal)
	local sep;
	local namesep;
	local format = control.format;
	local maximum = control.maximum;
	local name_list = {};

	if 'vanc' == format then													-- Vancouver-like name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between names is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between names is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub (-1, -1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if utilities.is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end		-- returned 0 is for EditorCount; not used for other names
	
	for i, person in ipairs (people) do
		if utilities.is_set (person.last) then
			local mask = person.mask;
			local one;
			local sep_one = sep;

			if utilities.is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			end
			
			if mask then
				local n = tonumber (mask);										-- convert to a number if it can be converted; nil else
				if n then
					one = 0 ~= n and string.rep(&quot;&amp;mdash;&quot;, n) or nil;			-- make a string of (n &gt; 0) mdashes, nil else, to replace name
					person.link = nil;											-- don't create link to name if name is replaces with mdash string or has been set nil
				else
					one = mask;													-- replace name with mask text (must include name-list separator)
					sep_one = &quot; &quot;;												-- modify name-list separator
				end
			else
				one = person.last;												-- get surname
				local first = person.first										-- get given name
				if utilities.is_set (first) then
					if (&quot;vanc&quot; == format) then									-- if Vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first, nil, i) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials (first, i);				-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
			end
			if utilities.is_set (person.link) then
				one = utilities.make_wikilink (person.link, one);				-- link author/editor
			end

			if one then															-- if &lt;one&gt; has a value (name, mdash replacement, or mask text replacement)
				local proj, tag = interwiki_prefixen_get (one, true);			-- get the interwiki prefixen if present

				if 'w' == proj and ('Wikipedia' == mw.site.namespaces.Project['name']) then
					proj = nil;													-- for stuff like :w:de:&lt;article&gt;, :w is unnecessary TODO: maint cat?
				end
				if proj then
					proj = ({['d'] = 'Wikidata', ['s'] = 'Wikisource', ['w'] = 'Wikipedia'})[proj];	-- :w (wikipedia) for linking from a non-wikipedia project
					if proj then 
						one = one .. utilities.wrap_style ('interproj', proj);	-- add resized leading space, brackets, static text, language name
						tag = nil;												-- unset; don't do both project and language
					end
				end
				if tag == cfg.this_wiki_code then
					tag = nil;													-- stuff like :en:&lt;article&gt; at en.wiki is pointless TODO: maint cat?
				end
				if tag then
					local lang = cfg.lang_tag_remap[tag] or cfg.mw_languages_by_tag_t[tag];
					if lang then												-- error messaging done in extract_names() where we know parameter names
						one = one .. utilities.wrap_style ('interwiki', lang);	-- add resized leading space, brackets, static text, language name
					end
				end

				table.insert (name_list, one);									-- add it to the list of names
				table.insert (name_list, sep_one);								-- add the proper name-list separator
			end
		end
	end

	local count = #name_list / 2;												-- (number of names + number of separators) divided by 2
	if 0 &lt; count then 
		if 1 &lt; count and not etal then
			if 'amp' == format then
				name_list[#name_list-2] = &quot; &amp; &quot;;								-- replace last separator with ampersand text
			elseif 'and' == format then
				if 2 == count then
					name_list[#name_list-2] = cfg.presentation.sep_nl_and;		-- replace last separator with 'and' text
				else
					name_list[#name_list-2] = cfg.presentation.sep_nl_end;		-- replace last separator with '(sep) and' text
				end
			end
		end
		name_list[#name_list] = nil;											-- erase the last separator
	end

	local result = table.concat (name_list);									-- construct list
	if etal and utilities.is_set (result) then									-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. cfg.messages['et al'];						-- we've got a last-first list and etal so add et al.
	end
	
	return result, count;														-- return name-list string and count of number of names (count used for editor names only)
end


--[[--------------------&lt; M A K E _ C I T E R E F _ I D &gt;-----------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise
returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that
order.  year is Year or anchor_year.

]]

local function make_citeref_id (namelist, year)
	local names={};							-- a table for the one to four names and year
	for i,v in ipairs (namelist) do			-- loop through the list and take up to the first four last names
		names[i] = v.last
		if i == 4 then break end			-- if four then done
	end
	table.insert (names, year);				-- add the year at the end
	local id = table.concat(names);			-- concatenate names and year for CITEREF id
	if utilities.is_set (id) then			-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;				-- add the CITEREF portion
	else
		return '';							-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; C I T E _ C L A S S _A T T R I B U T E _M A K E &gt;------------------------------

construct &lt;cite&gt; tag class attribute for this citation.

&lt;cite_class&gt; – config.CitationClass from calling template
&lt;mode&gt; – value from |mode= parameter

]]

local function cite_class_attribute_make (cite_class, mode)
	local class_t = {};
	table.insert (class_t, 'citation');											-- required for blue highlight
	if 'citation' ~= cite_class then
		table.insert (class_t, cite_class);										-- identify this template for user css
		table.insert (class_t, utilities.is_set (mode) and mode or 'cs1');		-- identify the citation style for user css or javascript
	else
		table.insert (class_t, utilities.is_set (mode) and mode or 'cs2');		-- identify the citation style for user css or javascript
	end
	for _, prop_key in ipairs (z.prop_keys_t) do
		table.insert (class_t, prop_key);										-- identify various properties for user css or javascript
	end

	return table.concat (class_t, ' ');											-- make a big string and done
end


--[[---------------------&lt; N A M E _ H A S _ E T A L &gt;--------------------------

Evaluates the content of name parameters (author, editor, etc.) for variations on
the theme of et al.  If found, the et al. is removed, a flag is set to true and
the function returns the modified name and the flag.

This function never sets the flag to false but returns its previous state because
it may have been set by previous passes through this function or by the associated
|display-&lt;names&gt;=etal parameter

]]

local function name_has_etal (name, etal, nocat, param)

	if utilities.is_set (name) then												-- name can be nil in which case just return
		local patterns = cfg.et_al_patterns; 									-- get patterns from configuration
		
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns
			if name:match (pattern) then										-- if this 'et al' pattern is found in name
				name = name:gsub (pattern, '');									-- remove the offending text
				etal = true;													-- set flag (may have been set previously here or by |display-&lt;names&gt;=etal)
				if not nocat then												-- no categorization for |vauthors=
					utilities.set_message ('err_etal', {param});				-- and set an error if not added
				end
			end
		end
	end

	return name, etal;
end


--[[---------------------&lt; N A M E _ I S _ N U M E R I C &gt;----------------------

Add an error message and category when &lt;name&gt; parameter value does not contain letters.  

Add a maintenance category when &lt;name&gt; parameter value has numeric characters mixed with characters that are 
not numeric characters; could be letters and/or punctuation characters.

This function will only emit one error and one maint message for the current template.  Does not emit both error
and maint messages/categories for the same parameter value.

returns nothing

]]

local function name_is_numeric (name, name_alias, list_name)
	local patterns = {
		'^%D+%d',																-- &lt;name&gt; must have digits preceded by other characters
		'^%D*%d+%D+',															-- &lt;name&gt; must have digits followed by other characters
		}

	if not added_numeric_name_errs and mw.ustring.match (name, '^[%A]+$') then	-- if we have not already set an error message and &lt;name&gt; does not have any alpha characters
		utilities.set_message ('err_numeric_names', name_alias);				-- add an error message
		added_numeric_name_errs = true;											-- set the flag so we emit only one error message
		return;																	-- when here no point in further testing; abandon
	end

	if not added_numeric_name_maint then										-- if we have already set a maint message
		for _, pattern in ipairs (patterns) do									-- spin through list of patterns
			if mw.ustring.match (name, pattern) then							-- digits preceded or followed by anything but digits; %D+ includes punctuation
				utilities.set_message ('maint_numeric_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
				added_numeric_name_maint = true;								-- set the flag so we emit only one maint message
				return;															-- when here no point in further testing; abandon
			end
		end
	end
end


--[[-----------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;------------------

Evaluates the content of last/surname (authors etc.) parameters for multiple names.
Multiple names are indicated if there is more than one comma or any &quot;unescaped&quot;
semicolons. Escaped semicolons are ones used as part of selected HTML entities.
If the condition is met, the function adds the multiple name maintenance category.

Same test for first except that commas should not appear in given names (MOS:JR says
that the generational suffix does not take a separator character).  Titles, degrees,
postnominals, affiliations, all normally comma separated don't belong in a citation.

&lt;name&gt; – name parameter value
&lt;list_name&gt; – AuthorList, EditorList, etc
&lt;limit&gt; – number of allowed commas; 1 (default) for surnames; 0 for given names

returns nothing

]]

local function name_has_mult_names (name, list_name, limit)
	local _, commas, semicolons, nbsps;
	limit = limit and limit or 1;
	if utilities.is_set (name) then
		_, commas = name:gsub (',', '');										-- count the number of commas
		_, semicolons = name:gsub (';', '');									-- count the number of semicolons
		-- nbsps probably should be its own separate count rather than merged in
		-- some way with semicolons because Lua patterns do not support the
		-- grouping operator that regex does, which means there is no way to add
		-- more entities to escape except by adding more counts with the new
		-- entities
		_, nbsps = name:gsub ('&amp;nbsp;','');										-- count nbsps
		
		-- There is exactly 1 semicolon per &amp;nbsp; entity, so subtract nbsps
		-- from semicolons to 'escape' them. If additional entities are added,
		-- they also can be subtracted.
		if limit &lt; commas or 0 &lt; (semicolons - nbsps) then
			utilities.set_message ('maint_mult_names', cfg.special_case_translation [list_name]);	-- add a maint message
		end
	end
end


--[=[-------------------------&lt; I S _ G E N E R I C &gt;----------------------------------------------------------

Compares values assigned to various parameters according to the string provided as &lt;item&gt; in the function call.
&lt;item&gt; can have on of two values:
	'generic_names' – for name-holding parameters: |last=, |first=, |editor-last=, etc
	'generic_titles' – for |title=

There are two types of generic tests.  The 'accept' tests look for a pattern that should not be rejected by the
'reject' test.  For example,
	|author=[[John Smith (author)|Smith, John]]
would be rejected by the 'author' reject test.  But piped wikilinks with 'author' disambiguation should not be
rejected so the 'accept' test prevents that from happening.  Accept tests are always performed before reject
tests.

Each of the 'accept' and 'reject' sequence tables hold tables for en.wiki (['en']) and local.wiki (['local'])
that each can hold a test sequence table  The sequence table holds, at index [1], a test pattern, and, at index
[2], a boolean control value.  The control value tells string.find() or mw.ustring.find() to do plain-text search (true)
or a pattern search (false).  The intent of all this complexity is to make these searches as fast as possible so
that we don't run out of processing time on very large articles.

Returns
	true when a reject test finds the pattern or string
	false when an accept test finds the pattern or string
	nil else

]=]

local function is_generic (item, value, wiki)
	local test_val;
	local str_lower = {															-- use string.lower() for en.wiki (['en']) and use mw.ustring.lower() or local.wiki (['local'])
		['en'] = string.lower,
		['local'] = mw.ustring.lower,
		}
	local str_find = {															-- use string.find() for en.wiki (['en']) and use mw.ustring.find() or local.wiki (['local'])
		['en'] = string.find,
		['local'] = mw.ustring.find,
		}

	local function test (val, test_t, wiki)										-- local function to do the testing; &lt;wiki&gt; selects lower() and find() functions
		val = test_t[2] and str_lower[wiki](value) or val;						-- when &lt;test_t[2]&gt; set to 'true', plaintext search using lowercase value
		return str_find[wiki] (val, test_t[1], 1, test_t[2]);					-- return nil when not found or matched
	end
		
	local test_types_t = {'accept', 'reject'};									-- test accept patterns first, then reject patterns
	local wikis_t = {'en', 'local'};											-- do tests for each of these keys; en.wiki first, local.wiki second

	for _, test_type in ipairs (test_types_t) do								-- for each test type
		for _, generic_value in pairs (cfg.special_case_translation[item][test_type]) do	-- spin through the list of generic value fragments to accept or reject
			for _, wiki in ipairs (wikis_t) do
				if generic_value[wiki] then
					if test (value, generic_value[wiki], wiki) then				-- go do the test
						return ('reject' == test_type);							-- param value rejected, return true; false else
					end
				end
			end
		end
	end
end


--[[--------------------------&lt; N A M E _ I S _ G E N E R I C &gt;------------------------------------------------

calls is_generic() to determine if &lt;name&gt; is a 'generic name' listed in cfg.generic_names; &lt;name_alias&gt; is the
parameter name used in error messaging

]]

local function name_is_generic (name, name_alias)
	if not added_generic_name_errs  and is_generic ('generic_names', name) then
		utilities.set_message ('err_generic_name', name_alias);					-- set an error message
		added_generic_name_errs = true;
	end
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------

This function calls various name checking functions used to validate the content of the various name-holding parameters.

]]

local function name_checks (last, first, list_name, last_alias, first_alias)
	local accept_name;

	if utilities.is_set (last) then
		last, accept_name = utilities.has_accept_as_written (last);				-- remove accept-this-as-written markup when it wraps all of &lt;last&gt;

		if not accept_name then													-- &lt;last&gt; not wrapped in accept-as-written markup
			name_has_mult_names (last, list_name);								-- check for multiple names in the parameter
			name_is_numeric (last, last_alias, list_name);						-- check for names that have no letters or are a mix of digits and other characters
			name_is_generic (last, last_alias);									-- check for names found in the generic names list
		end
	end

	if utilities.is_set (first) then
		first, accept_name = utilities.has_accept_as_written (first);			-- remove accept-this-as-written markup when it wraps all of &lt;first&gt;

		if not accept_name then													-- &lt;first&gt; not wrapped in accept-as-written markup
			name_has_mult_names (first, list_name, 0);							-- check for multiple names in the parameter; 0 is number of allowed commas in a given name
			name_is_numeric (first, first_alias, list_name);					-- check for names that have no letters or are a mix of digits and other characters
			name_is_generic (first, first_alias);								-- check for names found in the generic names list
		end
		local wl_type, D = utilities.is_wikilink (first);
		if 0 ~= wl_type then
			first = D;
			utilities.set_message ('err_bad_paramlink', first_alias);
		end
	end

	return last, first;															-- done
end


--[[----------------------&lt; E X T R A C T _ N A M E S &gt;-------------------------

Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters
(or their aliases), and their matching link and mask parameters. Stops searching
when both |lastn= and |firstn= are not found in args after two sequential attempts:
found |last1=, |last2=, and |last3= but doesn't find |last4= and |last5= then the
search is done.

This function emits an error message when there is a |firstn= without a matching
|lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not
required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.'
is stripped from the parameter and a flag (etal) returned that will cause list_people()
to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps
'et al.' out of the template's metadata.  When this occurs, an error is emitted.

]]

local function extract_names(args, list_name)
	local names = {};															-- table of names
	local last;																	-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;																-- loop counter/indexer
	local n = 1;																-- output table indexer
	local count = 0;															-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal = false;															-- return value set to true when we find some form of et al. in an author parameter

	local last_alias, first_alias, link_alias;									-- selected parameter aliases used in error messaging
	while true do
		last, last_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'err_redundant_parameters', i );		-- search through args for name components beginning at 1
		first, first_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'err_redundant_parameters', i );
		link, link_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i );
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
	
		if last then															-- error check |lastn= alias for unknown interwiki link prefix; done here because this is where we have the parameter name
			local project, language = interwiki_prefixen_get (last, true);		-- true because we expect interwiki links in |lastn= to be wikilinked
			if nil == project and nil == language then							-- when both are nil
				utilities.set_message ('err_bad_paramlink', last_alias);		-- not known, emit an error message	-- TODO: err_bad_interwiki?
				last = utilities.remove_wiki_link (last);						-- remove wikilink markup; show display value only
			end
		end
		
		if link then															-- error check |linkn= alias for unknown interwiki link prefix
			local project, language = interwiki_prefixen_get (link, false);		-- false because wiki links in |author-linkn= is an error
			if nil == project and nil == language then							-- when both are nil
				utilities.set_message ('err_bad_paramlink', link_alias);		-- not known, emit an error message	-- TODO: err_bad_interwiki?
				link = nil;														-- unset so we don't link
				link_alias = nil;
			end
		end
		
		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.
		last, first = name_checks (last, first, list_name, last_alias, first_alias);						-- multiple names, extraneous annotation, etc. checks

		if first and not last then												-- if there is a firstn without a matching lastn
			local alias = first_alias:find ('given', 1, true) and 'given' or 'first';	-- get first or given form of the alias
			utilities.set_message ('err_first_missing_last', {
				first_alias,													-- param name of alias missing its mate
				first_alias:gsub (alias, {['first'] = 'last', ['given'] = 'surname'}),	-- make param name appropriate to the alias form
				});																-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			local result;
			link = link_title_ok (link, link_alias, last, last_alias);			-- check for improper wiki-markup

			if first then
				link = link_title_ok (link, link_alias, first, first_alias);	-- check for improper wiki-markup
			end

			names[n] = {last = last, first = first, link = link, mask = mask, corporate = false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				utilities.set_message ('err_missing_name', {list_name:match (&quot;(%w+)List&quot;):lower(), i - 1});	-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names and the etal flag
end


--[[--------------------------&lt; N A M E _ T A G _ G E T &gt;------------------------------------------------------

attempt to decode |language=&lt;lang_param&gt; and return language name and matching tag; nil else.

This function looks for:
	&lt;lang_param&gt; as a tag in cfg.lang_tag_remap{}
	&lt;lang_param&gt; as a name in cfg.lang_name_remap{}
	
	&lt;lang_param&gt; as a name in cfg.mw_languages_by_name_t
	&lt;lang_param&gt; as a tag in cfg.mw_languages_by_tag_t
when those fail, presume that &lt;lang_param&gt; is an IETF-like tag that MediaWiki does not recognize.  Strip all
script, region, variant, whatever subtags from &lt;lang_param&gt; to leave just a two or three character language tag
and look for the new &lt;lang_param&gt; in cfg.mw_languages_by_tag_t{}

on success, returns name (in properly capitalized form) and matching tag (in lowercase); on failure returns nil

]]

local function name_tag_get (lang_param)
	local lang_param_lc = mw.ustring.lower (lang_param);						-- use lowercase as an index into the various tables
	local name;
	local tag;

	name = cfg.lang_tag_remap[lang_param_lc];									-- assume &lt;lang_param_lc&gt; is a tag; attempt to get remapped language name 
	if name then																-- when &lt;name&gt;, &lt;lang_param&gt; is a tag for a remapped language name
		if cfg.lang_name_remap[name:lower()][2] ~= lang_param_lc then
			utilities.set_message ('maint_unknown_lang');						-- add maint category if not already added
			return name, cfg.lang_name_remap[name:lower()][2];					-- so return name and tag from lang_name_remap[name]; special case to xlate sr-ec and sr-el to sr-cyrl and sr-latn
		end
		return name, lang_param_lc;												-- so return &lt;name&gt; from remap and &lt;lang_param_lc&gt;
	end

	tag = lang_param_lc:match ('^(%a%a%a?)%-.*');								-- still assuming that &lt;lang_param_lc&gt; is a tag; strip script, region, variant subtags
	name = cfg.lang_tag_remap[tag];												-- attempt to get remapped language name with language subtag only
	if name then																-- when &lt;name&gt;, &lt;tag&gt; is a tag for a remapped language name
		return name, tag;														-- so return &lt;name&gt; from remap and &lt;tag&gt;
	end

	if cfg.lang_name_remap[lang_param_lc] then									-- not a remapped tag, assume &lt;lang_param_lc&gt; is a name; attempt to get remapped language tag 
		return cfg.lang_name_remap[lang_param_lc][1], cfg.lang_name_remap[lang_param_lc][2];	-- for this &lt;lang_param_lc&gt;, return a (possibly) new name and appropriate tag
	end

	name = cfg.mw_languages_by_tag_t[lang_param_lc];							-- assume that &lt;lang_param_lc&gt; is a tag; attempt to get its matching language name
	
	if name then
		return name, lang_param_lc;												-- &lt;lang_param_lc&gt; is a tag so return it and &lt;name&gt;
	end
	
	tag = cfg.mw_languages_by_name_t[lang_param_lc];							-- assume that &lt;lang_param_lc&gt; is a language name; attempt to get its matching tag
	
	if tag then
		return cfg.mw_languages_by_tag_t[tag], tag;								-- &lt;lang_param_lc&gt; is a name so return the name from the table and &lt;tag&gt;
	end

	tag = lang_param_lc:match ('^(%a%a%a?)%-.*');								-- is &lt;lang_param_lc&gt; an IETF-like tag that MediaWiki doesn't recognize? &lt;tag&gt; gets the language subtag; nil else

	if tag then
		name = cfg.mw_languages_by_tag_t[tag];									-- attempt to get a language name using the shortened &lt;tag&gt;
		if name then
			return name, tag;													-- &lt;lang_param_lc&gt; is an unrecognized IETF-like tag so return &lt;name&gt; and language subtag
		end
	end
end


--[[-------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code
is recognized by MediaWiki, use the returned name; if not, then use the value that
was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is
assigned to the category for that code: Category:Norwegian-language sources (no).
For valid three-character code languages, the page is assigned to the single category
for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does
not recognize three-character equivalents of two-character codes: code 'ar' is
recognized but code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th
where the language names or codes are separated from each other by commas with
optional space characters.

]]

local function language_parameter (lang)
	local tag;																	-- some form of IETF-like language tag; language subtag with optional region, sript, vatiant, etc subtags
	local lang_subtag;															-- ve populates |language= with mostly unecessary region subtags the MediaWiki does not recognize; this is the base language subtag
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_t = {};															-- table made from the value assigned to |language=

	local this_wiki_name = mw.language.fetchLanguageName (cfg.this_wiki_code, cfg.this_wiki_code);	-- get this wiki's language name

	names_t = mw.text.split (lang, '%s*,%s*');									-- names should be a comma separated list

	for _, lang in ipairs (names_t) do											-- reuse lang here because we don't yet know if lang is a language name or a language tag
		name, tag = name_tag_get (lang);										-- attempt to get name/tag pair for &lt;lang&gt;; &lt;name&gt; has proper capitalization; &lt;tag&gt; is lowercase

		if utilities.is_set (tag) then
			lang_subtag = tag:gsub ('^(%a%a%a?)%-.*', '%1');					-- for categorization, strip any IETF-like tags from language tag

			if cfg.this_wiki_code ~= lang_subtag then							-- when the language is not the same as this wiki's language
				if 2 == lang_subtag:len() then									-- and is a two-character tag
					utilities.add_prop_cat ('foreign-lang-source', {name, tag}, lang_subtag);		-- categorize it; tag appended to allow for multiple language categorization
				else															-- or is a recognized language (but has a three-character tag)
					utilities.add_prop_cat ('foreign-lang-source-2', {lang_subtag}, lang_subtag);			-- categorize it differently TODO: support multiple three-character tag categories per cs1|2 template?
				end
			elseif cfg.local_lang_cat_enable then								-- when the language and this wiki's language are the same and categorization is enabled
				utilities.add_prop_cat ('local-lang-source', {name, lang_subtag});		-- categorize it
			end
		else
			name = lang;														-- return whatever &lt;lang&gt; has so that we show something
			utilities.set_message ('maint_unknown_lang');						-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
 
	name = utilities.make_sep_list (#language_list, language_list);
	if (1 == #language_list) and (lang_subtag == cfg.this_wiki_code) then		-- when only one language, find lang name in this wiki lang name; for |language=en-us, 'English' in 'American English'
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[-----------------------&lt; S E T _ C S _ S T Y L E &gt;--------------------------

Gets the default CS style configuration for the given mode.
Returns default separator and either postscript as passed in or the default.
In CS1, the default postscript and separator are '.'.
In CS2, the default postscript is the empty string and the default separator is ','.

]]

local function set_cs_style (postscript, mode)
	if utilities.is_set(postscript) then
		-- emit a maintenance message if user postscript is the default cs1 postscript
		-- we catch the opposite case for cs2 in set_style
		if mode == 'cs1' and postscript == cfg.presentation['ps_' .. mode] then
			utilities.set_message ('maint_postscript');
		end
	else
		postscript = cfg.presentation['ps_' .. mode];
	end
	return cfg.presentation['sep_' .. mode], postscript;
end


--[[--------------------------&lt; S E T _ S T Y L E &gt;-----------------------------

Sets the separator and postscript styles. Checks the |mode= first and the
#invoke CitationClass second. Removes the postscript if postscript == none.

]]

local function set_style (mode, postscript, cite_class)
	local sep;
	if 'cs2' == mode then
		sep, postscript = set_cs_style (postscript, 'cs2');
	elseif 'cs1' == mode then
		sep, postscript = set_cs_style (postscript, 'cs1');
	elseif 'citation' == cite_class	then
		sep, postscript = set_cs_style (postscript, 'cs2');
	else
		sep, postscript = set_cs_style (postscript, 'cs1');
	end

	if cfg.keywords_xlate[postscript:lower()] == 'none' then
		-- emit a maintenance message if user postscript is the default cs2 postscript
		-- we catch the opposite case for cs1 in set_cs_style
		if 'cs2' == mode or ('cs1' ~= mode and 'citation' == cite_class) then	-- {{citation |title=Title |mode=cs1 |postscript=none}} should not emit maint message
			utilities.set_message ('maint_postscript');
		end
		postscript = '';
	end
	
	return sep, postscript
end


--[=[-------------------------&lt; I S _ P D F &gt;-----------------------------------

Determines if a URL has the file extension that is one of the PDF file extensions
used by [[MediaWiki:Common.css]] when applying the PDF icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or
		url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
		url:match ('%.PDF&amp;#035') or url:match ('%.pdf&amp;#035');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;-----------------------

Applies CSS style to |format=, |chapter-format=, etc.  Also emits an error message
if the format parameter does not have a matching URL parameter.  If the format parameter
is not set and the URL contains a file extension that is recognized as a PDF document
by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if utilities.is_set (format) then
		format = utilities.wrap_style ('format', format);						-- add leading space, parentheses, resize
		if not utilities.is_set (url) then
			utilities.set_message ('err_format_missing_url', {fmt_param, url_param});	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if URL is a PDF file then
		format = utilities.wrap_style ('format', 'PDF');						-- set format to PDF
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[---------------------&lt; G E T _ D I S P L A Y _ N A M E S &gt;------------------

Returns a number that defines the number of names displayed for author and editor
name lists and a Boolean flag to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero,
return the number and the previous state of the 'etal' flag (false by default
but may have been set to true if the name list contains some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number
that is one greater than the number of authors in the list and set the 'etal' flag true.
This will cause the list_people() to display all of the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors'], etc; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

This function sets an error message when |display-xxxxors= value greater than or equal to number of names but
not when &lt;max&gt; comes from {{cs1 config}} global settings.  When using global settings, &lt;param&gt; is set to the
keyword 'cs1 config' which is used to supress the normal error.  Error is suppressed because it is to be expected
that some citations in an article will have the same or fewer names that the limit specified in {{cs1 config}}.

]]

local function get_display_names (max, count, list_name, etal, param)
	if utilities.is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if (max &gt;= count) and ('cs1 config' ~= param) then					-- error when local |display-xxxxors= value greater than or equal to number of names; not an error when using global setting
				utilities.set_message ('err_disp_name', {param, max});			-- add error message
				max = nil;
			end
		else																	-- not a valid keyword or number
			utilities.set_message ('err_disp_name', {param, max});				-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[----------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;---------------

Adds error if |page=, |pages=, |quote-page=, |quote-pages= has what appears to be
some form of p. or pp. abbreviation in the first characters of the parameter content.

check page for extraneous p, p., pp, pp., pg, pg. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when page begins PX or P# but not Px
		      where x and X are letters and # is a digit
	bad pattern:  '^[Pp][PpGg]' matches when page begins pp, pP, Pp, PP, pg, pG, Pg, PG

]]

local function extra_text_in_page_check (val, name)
	if not val:match (cfg.vol_iss_pg_patterns.good_ppattern) then
		for _, pattern in ipairs (cfg.vol_iss_pg_patterns.bad_ppatterns) do		-- spin through the selected sequence table of patterns
			if val:match (pattern) then											-- when a match, error so
				utilities.set_message ('err_extra_text_pages', name);	 		-- add error message
				return;															-- and done
			end
		end
	end		
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ V O L _ I S S _ C H E C K &gt;------------------------

Adds error if |volume= or |issue= has what appears to be some form of redundant 'type' indicator.  Applies to
both; this function looks for issue text in both |issue= and |volume= and looks for volume-like text in |voluem=
and |issue=.

For |volume=:
	'V.', or 'Vol.' (with or without the dot) abbreviations or 'Volume' in the first characters of the parameter
	content (all case insensitive). 'V' and 'v' (without the dot) are presumed to be roman numerals so
	are allowed.

For |issue=:
	'No.', 'I.', 'Iss.' (with or without the dot) abbreviations, or 'Issue' in the first characters of the
	parameter content (all case insensitive); numero styling: 'n°' with degree sign U+00B0, and № precomposed
	numero sign U+2116.
	
Single character values ('v', 'i', 'n') allowed when not followed by separator character ('.', ':', '=', or
whitespace character) – param values are trimmed of whitespace by MediaWiki before delivered to the module.
	
&lt;val&gt; is |volume= or |issue= parameter value
&lt;name&gt; is |volume= or |issue= parameter name for error message
&lt;selector&gt; is 'v' for |volume=, 'i' for |issue=

sets error message on failure; returns nothing

]]

local function extra_text_in_vol_iss_check (val, name, selector)
	if not utilities.is_set (val) then
		return;
	end
	
	local handler = 'v' == selector and 'err_extra_text_volume' or 'err_extra_text_issue';
	val = val:lower();															-- force parameter value to lower case

	for _, pattern in ipairs (cfg.vol_iss_pg_patterns.vi_patterns_t) do			-- spin through the sequence table of patterns
		if val:match (pattern) then												-- when a match, error so
			utilities.set_message (handler, name);								-- add error message
			return;																-- and done
		end
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parentheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a placeholder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parentheses
			local name = name_table[i];
			i = i + 1;															-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parentheses
					break;														-- and done reassembling so
				end
				i = i + 1;														-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = utilities.is_wikilink (name_table[i]);		-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i + 1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled parentheses ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the Vancouver error when a required comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		first = '';																-- set to empty string for concatenation and because it may have been set for previous author/editor
		local accept_name;
		v_name, accept_name = utilities.has_accept_as_written (v_name);			-- remove accept-this-as-written markup when it wraps all of &lt;v_name&gt;

		if accept_name then
			last = v_name;
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error (cfg.err_msg_supl.punctuation, i);
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s+&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be initials or generational suffix

			if not mw.ustring.match (first, '^%u+$') then						-- mw.ustring here so that later we will catch non-Latin characters
				suffix = first;													-- not initials so assume that whatever we got is a generational suffix
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end
			last = table.concat(lastfirstTable, ' ')							-- returns a string that is the concatenation of all other names that are not initials and generational suffix
			if not utilities.is_set (last) then
				first = '';														-- unset
				last = v_name;													-- last empty because something wrong with first
				add_vanc_error (cfg.err_msg_supl.name, i);
			end
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error (cfg.err_msg_supl['missing comma'], i);			-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- matches a space between two initials
			end
		else
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
		
		if utilities.is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first, suffix, i);							-- check first and last before restoring the suffix which may have a non-Latin digit
			if utilities.is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '', nil, i);
			end
		end

		link = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i ) or v_link_table[i];
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate = corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest;
|editorn= (and aliases) highest and |veditors= lowest (support for |editors= withdrawn)

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
	local lastfirst = false;
	if utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice in case we have a |first1= without a |last1=; this ...
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or		-- ... also catches the case where |first= is used with |vauthors=
		utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst = true;
	end

	if (utilities.is_set (vxxxxors) and true == lastfirst) or					-- these are the three error conditions
		(utilities.is_set (vxxxxors) and utilities.is_set (xxxxors)) or
		(true == lastfirst and utilities.is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			utilities.set_message ('err_redundant_parameters', err_name .. '-name-list parameters');	-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if utilities.is_set (vxxxxors) then return 2 end;
	if utilities.is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, live, dead, etc.).  When the parameter value has not been assigned a value (missing
or empty in the source template) the function returns the value specified by ret_val.  If the parameter value is one
of the list of allowed values returns the translated value; else, emits an error message and returns the value
specified by ret_val.

TODO: explain &lt;invert&gt;

]]

local function is_valid_parameter_value (value, name, possible, ret_val, invert)
	if not utilities.is_set (value) then
		return ret_val;															-- an empty parameter is ok
	end

	if (not invert and utilities.in_array (value, possible)) then				-- normal; &lt;value&gt; is in &lt;possible&gt; table
		return cfg.keywords_xlate[value];										-- return translation of parameter keyword
	elseif invert and not utilities.in_array (value, possible) then				-- invert; &lt;value&gt; is not in &lt;possible&gt; table
		return value;															-- return &lt;value&gt; as it is
	else
		utilities.set_message ('err_invalid_param_val', {name, value});			-- not an allowed value so add error message
		return ret_val;
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list, -3, -1) == sepc .. '. ') then					-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list, -1, -1) == sepc) or (string.sub (name_list, -3, -1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terminate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;-----------------------------------------

returns the concatenation of the formatted volume and issue (or journal article number) parameters as a single
string; or formatted volume or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, article, cite_class, origin, sepc, lower)
	if not utilities.is_set (volume) and not utilities.is_set (issue) and not utilities.is_set (article) then
		return '';
	end

	-- same condition as in format_pages_sheets()
	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);

	local is_numeric_vol = volume and (volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$'));	-- is only uppercase roman numerals or only digits?
	local is_long_vol = volume and (4 &lt; mw.ustring.len(volume));				-- is |volume= value longer than 4 characters?
	
	if volume and (not is_numeric_vol and is_long_vol) then						-- when not all digits or Roman numerals, is |volume= longer than 4 characters?
		utilities.add_prop_cat ('long-vol');									-- yes, add properties cat
	end

	if is_journal then															-- journal-style formatting
		local vol = '';

		if utilities.is_set (volume) then
			if is_numeric_vol then												-- |volume= value all digits or all uppercase Roman numerals?
				vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, volume});	-- render in bold face
			elseif is_long_vol then												-- not all digits or Roman numerals; longer than 4 characters?
				vol = utilities.substitute (cfg.messages['j-vol'], {sepc, utilities.hyphen_to_dash (volume)});	-- not bold
			else																-- four or fewer characters
				vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, utilities.hyphen_to_dash (volume)});	-- bold
			end
		end
		vol = vol .. (utilities.is_set (issue) and utilities.substitute (cfg.messages['j-issue'], issue) or '')
		vol = vol .. (utilities.is_set (article) and utilities.substitute (cfg.messages['j-article-num'], article) or '')
		return vol;
	end
	
	if 'podcast' == cite_class and utilities.is_set (issue) then
		return wrap_msg ('issue', {sepc, issue}, lower);
	end
	
	if 'conference' == cite_class and utilities.is_set (article) then			-- |article-number= supported only in journal and conference cites
		if utilities.is_set (volume) and utilities.is_set (article) then		-- both volume and article number
			return wrap_msg ('vol-art', {sepc, utilities.hyphen_to_dash (volume), article}, lower);
		elseif utilities.is_set (article) then									-- article number alone; when volume alone, handled below
			return wrap_msg ('art', {sepc, article}, lower);
		end
	end

	-- all other types of citation
	if utilities.is_set (volume) and utilities.is_set (issue) then
		return wrap_msg ('vol-no', {sepc, utilities.hyphen_to_dash (volume), issue}, lower);
	elseif utilities.is_set (volume) then
		return wrap_msg ('vol', {sepc, utilities.hyphen_to_dash (volume)}, lower);
	else
		return wrap_msg ('issue', {sepc, issue}, lower);
	end
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if utilities.is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif utilities.is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if utilities.is_set (page) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return utilities.substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return utilities.substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif utilities.is_set (pages) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then							-- if pages is only digits, assume a single page number
			return '', utilities.substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', utilities.substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', utilities.substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to Wikisource, returns the label portion of the interwiki-link as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki-link to an external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, page_orig, pages, pages_orig, at)
	local ws_url, ws_label, coins_pages, L;										-- for Wikisource interwiki-links; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if utilities.is_set (page) then
		if utilities.is_set (pages) or utilities.is_set (at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page, page_orig);								-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws URL from |page= interwiki link; link portion L becomes tooltip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (pages) then
		if utilities.is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages, pages_orig);							-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws URL from |pages= interwiki link; link portion L becomes tooltip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws URL from |at= interwiki link; link portion L becomes tooltip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end

--[[--------------------------&lt; I S _ U N I Q U E _ A R C H I V E _ U R L &gt;------------------------------------

add error message when |archive-url= value is same as |url= or chapter-url= (or alias...) value

]]

local function is_unique_archive_url (archive, url, c_url, source, date)
	if utilities.is_set (archive) then
		if archive == url or archive == c_url then
			utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)});	-- add error message
			return '', '';														-- unset |archive-url= and |archive-date= because same as |url= or |chapter-url=
		end
	end

	return archive, date;
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org URLs to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot URL or to calendar pages.  When the archive URL is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the URL.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org URL does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command URL
	|archive-url= is an archive.org URL that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org URLs:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this function may return a modified
archive URL:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the URL unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

A secondary function is to return an archive-url timestamp from those urls that have them (archive.org and
archive.today).  The timestamp is used by validation.archive_date_check() to see if the value in |archive-date=
matches the timestamp in the archive url.

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.org URL
	
	timestamp = url:match ('//archive.today/(%d%d%d%d%d%d%d%d%d%d%d%d%d%d)/') or	-- get timestamp from archive.today urls
		url:match ('//archive.today/(%d%d%d%d%.%d%d%.%d%d%-%d%d%d%d%d%d)/');		-- this timestamp needs cleanup
	if timestamp then															-- if this was an archive.today url ...
		return url, date, timestamp:gsub ('[%.%-]', '');						-- return ArchiveURL, ArchiveDate, and timestamp (dots and dashes removed) from |archive-url=, and done
	end
																				-- here for archive.org urls
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine URL
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command URL, we don't want to allow saving of the target page 
		err_msg = cfg.err_msg_supl.save;
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = cfg.err_msg_supl.liveweb;
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');	-- split out some of the URL parts for evaluation
		if not path then														-- malformed in some way; pattern did not match
			err_msg = cfg.err_msg_supl.timestamp;
		elseif 14 ~= timestamp:len() then										-- path and flag optional, must have 14-digit timestamp here
			err_msg = cfg.err_msg_supl.timestamp;
			if '*' ~= flag then
				local replacement = timestamp:match ('^%d%d%d%d%d%d') or timestamp:match ('^%d%d%d%d');	-- get the first 6 (YYYYMM) or first 4 digits (YYYY)
				if replacement then												-- nil if there aren't at least 4 digits (year)
					replacement = replacement .. string.rep ('0', 14 - replacement:len());	-- year or yearmo (4 or 6 digits) zero-fill to make 14-digit timestamp
					url=url:gsub ('(//web%.archive%.org/[^%d]*)%d[^/]*', '%1' .. replacement .. '*', 1)	-- for preview, modify ts to 14 digits plus splat for calendar display
				end
			end
		elseif utilities.is_set (path) and 'web/' ~= path then					-- older archive URLs do not have the extra 'web/' path element
			err_msg = cfg.err_msg_supl.path;
		elseif utilities.is_set (flag) and not utilities.is_set (path) then		-- flag not allowed with the old form URL (without the 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		elseif utilities.is_set (flag) and not flag:match ('%a%a_') then		-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		else
			return url, date, timestamp;										-- return ArchiveURL, ArchiveDate, and timestamp from |archive-url=
		end
	end
																				-- if here, something not right so
	utilities.set_message ('err_archive_url', {err_msg});						-- add error message and

	if is_preview_mode then
		return url, date, timestamp;											-- preview mode so return ArchiveURL, ArchiveDate, and timestamp from |archive-url=
	else
		return '', '';															-- return empty strings for ArchiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; P L A C E _ C H E C K &gt;--------------------------------------------------------

check |place=, |publication-place=, |location= to see if these params include digits.  This function added because
many editors misuse location to specify the in-source location (|page(s)= and |at= are supposed to do that)

returns the original parameter value without modification; added maint cat when parameter value contains digits

]]

local function place_check (param_val)
	if not utilities.is_set (param_val) then									-- parameter empty or omitted
		return param_val;														-- return that empty state
	end
	
	if mw.ustring.find (param_val, '%d') then									-- not empty, are there digits in the parameter value
		utilities.set_message ('maint_location');								-- yep, add maint cat
	end
	
	return param_val;															-- and done
end


--[[--------------------------&lt; I S _ A R C H I V E D _ C O P Y &gt;----------------------------------------------

compares |title= to 'Archived copy' (placeholder added by bots that can't find proper title); if matches, return true; nil else

]]

local function is_archived_copy (title)
	title = mw.ustring.lower(title);											-- switch title to lower case
	if title:find (cfg.special_case_translation.archived_copy.en) then			-- if title is 'Archived copy'
		return true;
	elseif cfg.special_case_translation.archived_copy['local'] then
		if mw.ustring.find (title, cfg.special_case_translation.archived_copy['local']) then	-- mw.ustring() because might not be Latin script
			return true;
		end
	end
end


--[[--------------------------&lt; D I S P L A Y _ N A M E S _ S E L E C T &gt;--------------------------------------

for any of the |display-authors=, |display-editors=, etc parameters, select either the local or global setting.
When both are present, look at &lt;local_display_names&gt; value.  When the value is some sort of 'et al.'string,
special handling is required.

When {{cs1 config}} has |display-&lt;namelist&gt;= AND this template has |display-&lt;namelist&gt;=etal AND:
	the number of names specified by &lt;number_of_names&gt; is:
		greater than the number specified in the global |display-&lt;namelist&gt;= parameter (&lt;global_display_names&gt;)
			use global |display-&lt;namelist&gt;= parameter value
			set overridden maint category
		less than or equal to the number specified in the global |display-&lt;namelist&gt;=  parameter
			use local |display-&lt;namelist&gt;= parameter value

The purpose of this function is to prevent categorizing a template that has fewer names than the global setting
to keep the etal annotation specified by &lt;local_display_names&gt;.

]]

local function display_names_select (global_display_names, local_display_names, param_name, number_of_names, test)
	if global_display_names and utilities.is_set (local_display_names) then		-- when both
		if 'etal' == local_display_names:lower():gsub(&quot;[ '%.]&quot;, '') then		-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			number_of_names = tonumber (number_of_names);						-- convert these to numbers for comparison
			local global_display_names_num = tonumber (global_display_names);	-- &lt;global_display_names&gt; not set when parameter value is not digits

			if number_of_names &gt; global_display_names_num then					-- template has more names than global config allows to be displayed?
				utilities.set_message ('maint_overridden_setting');				-- set a maint message because global is overriding local |display-&lt;namelist&gt;=etal
				return global_display_names, 'cs1 config';						-- return global with spoof parameter name (for get_display_names())
			else
				return local_display_names, param_name;							-- return local because fewer names so let &lt;local_display_names&gt; control
			end
		end
																				-- here when &lt;global_display_names&gt; and &lt;local_display_names&gt; both numbers; &lt;global_display_names&gt; controls
		utilities.set_message ('maint_overridden_setting');						-- set a maint message
		return global_display_names, 'cs1 config';								-- return global with spoof parameter name (for get_display_names())
	end
																				-- here when only one of &lt;global_display_names&gt; or &lt;local_display_names&gt; set
	if global_display_names then
		return global_display_names, 'cs1 config';								-- return global with spoof parameter name (for get_display_names())
	else
		return local_display_names, param_name;									-- return local
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args )
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper ( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListStyle;
		if cfg.global_cs1_config_t['NameListStyle'] then						-- global setting in {{cs1 config}} overrides local |name-list-style= parameter value; nil when empty or assigned value invalid
			NameListStyle = is_valid_parameter_value (cfg.global_cs1_config_t['NameListStyle'], 'cs1 config: name-list-style', cfg.keywords_lists['name-list-style'], '');	-- error messaging 'param' here is a hoax
		else
			NameListStyle = is_valid_parameter_value (A['NameListStyle'], A:ORIGIN('NameListStyle'), cfg.keywords_lists['name-list-style'], '');
		end

		if cfg.global_cs1_config_t['NameListStyle'] and utilities.is_set (A['NameListStyle']) then	-- when template has |name-list-style=&lt;something&gt; which global setting has overridden
			utilities.set_message ('maint_overridden_setting');					-- set a maint message
		end

	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			a, author_etal = parse_vauthors_veditors (args, A['Vauthors'], 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |people= or |credits=; |authors= is deprecated; TODO: constrain |people= and |credits= to cite av media, episode, serial?
		end
		if utilities.is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], nil, args, 'EditorList');	-- support for |editors= withdrawn
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		end
	end
							
	local Chapter = A['Chapter'];												-- done here so that we have access to |contribution= from |chapter= aliases
	local Chapter_origin = A:ORIGIN ('Chapter');
	local Contribution;															-- because contribution is required for contributor(s)
		if 'contribution' == Chapter_origin then
			Contribution = Chapter;												-- get the name of the contribution
		end
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	
	if utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not utilities.is_set (Contribution) then							-- |contributor= requires |contribution=
				utilities.set_message ('err_contributor_missing_required_param', 'contribution');	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				utilities.set_message ('err_contributor_missing_required_param', 'author');	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if utilities.select_one (args, cfg.aliases['ContributorList-Last'], 'err_redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			utilities.set_message ('err_contributor_ignored');					-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	local Title = A['Title'];
	local TitleLink = A['TitleLink'];

	local auto_select = '';														-- default is auto
	local accept_link;
	TitleLink, accept_link = utilities.has_accept_as_written (TitleLink, true);	-- test for accept-this-as-written markup
	if (not accept_link) and utilities.in_array (TitleLink, {'none', 'pmc', 'doi'}) then -- check for special keywords
		auto_select = TitleLink;												-- remember selection for later
		TitleLink = '';															-- treat as if |title-link= would have been empty
	end

	TitleLink = link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wiki-markup in |title-link= or wiki-markup in |title= when |title-link= is set

	local Section = '';															-- {{cite map}} only; preset to empty string for concatenation if not used
	if 'map' == config.CitationClass and 'section' == Chapter_origin then
		Section = A['Chapter'];													-- get |section= from |chapter= alias list; |chapter= and the other aliases not supported in {{cite map}}
		Chapter = '';															-- unset for now; will be reset later from |map= if present
	end

	local Periodical = A['Periodical'];
	local Periodical_origin = A:ORIGIN('Periodical');
	local ScriptPeriodical = A['ScriptPeriodical'];
	local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');
	local TransPeriodical =  A['TransPeriodical'];
	local TransPeriodical_origin =  A:ORIGIN ('TransPeriodical');
	
	if (utilities.in_array (config.CitationClass, {'book', 'encyclopaedia'}) and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical))) then
		local param;
		if utilities.is_set (Periodical) then									-- get a parameter name from one of these periodical related meta-parameters
			Periodical = '';													-- unset because not valid {{cite book}} or {{cite encyclopedia}} parameters 
			param = Periodical_origin											-- get parameter name for error messaging
		elseif utilities.is_set (TransPeriodical) then
			TransPeriodical = '';												-- unset because not valid {{cite book}} or {{cite encyclopedia}} parameters 
			param = TransPeriodical_origin;										-- get parameter name for error messaging
		elseif utilities.is_set (ScriptPeriodical) then
			ScriptPeriodical = '';												-- unset because not valid {{cite book}} or {{cite encyclopedia}} parameters 
			param = ScriptPeriodical_origin;									-- get parameter name for error messaging
		end

		if utilities.is_set (param) then										-- if we found one
			utilities.set_message ('err_periodical_ignored', {param});			-- emit an error message
		end
	end

	if utilities.is_set (Periodical) then
		local i;
		Periodical, i = utilities.strip_apostrophe_markup (Periodical);			-- strip apostrophe markup so that metadata isn't contaminated 
		if i then																-- non-zero when markup was stripped so emit an error message
			utilities.set_message ('err_apostrophe_markup', {Periodical_origin});
		end
	end

	if 'mailinglist' == config.CitationClass then								-- special case for {{cite mailing list}}
		if utilities.is_set (Periodical) and utilities.is_set (A ['MailingList']) then	-- both set emit an error TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', Periodical_origin) .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'mailinglist')});
		end

		Periodical = A ['MailingList'];											-- error or no, set Periodical to |mailinglist= value because this template is {{cite mailing list}}
		Periodical_origin = A:ORIGIN('MailingList');
	end

	-- web and news not tested for now because of 
	-- Wikipedia:Administrators%27_noticeboard#Is_there_a_semi-automated_tool_that_could_fix_these_annoying_&quot;Cite_Web&quot;_errors?
	if not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) then	-- 'periodical' templates require periodical parameter
	--	local p = {['journal'] = 'journal', ['magazine'] = 'magazine', ['news'] = 'newspaper', ['web'] = 'website'};	-- for error message
		local p = {['journal'] = 'journal', ['magazine'] = 'magazine'};			-- for error message
		if p[config.CitationClass]  then
			utilities.set_message ('err_missing_periodical', {config.CitationClass, p[config.CitationClass]});
		end
	end
	
	local Volume;
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) then
			if not utilities.in_array (Periodical_origin, cfg.citation_no_volume_t) then	-- {{citation}} does not render |volume= when these parameters are used
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		elseif utilities.is_set (ScriptPeriodical) then
			if 'script-website' ~= ScriptPeriodical_origin then					-- {{citation}} does not render volume for |script-website=
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		else
			Volume = A['Volume'];												-- and does for non-'periodical' cites
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_volume) then	-- render |volume= for cs1 according to the configuration settings
		Volume = A['Volume'];
	end	
	extra_text_in_vol_iss_check (Volume, A:ORIGIN ('Volume'), 'v');	

	local Issue;
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) and utilities.in_array (Periodical_origin, cfg.citation_issue_t) then	-- {{citation}} may render |issue= when these parameters are used
			Issue = utilities.hyphen_to_dash (A['Issue']);
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_issue) then	-- conference &amp; map books do not support issue; {{citation}} listed here because included in settings table
		if not (utilities.in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical))) then
			Issue = utilities.hyphen_to_dash (A['Issue']);
		end
	end
	
	local ArticleNumber;

	if utilities.in_array (config.CitationClass, {'journal', 'conference'}) or ('citation' == config.CitationClass and utilities.is_set (Periodical) and 'journal' == Periodical_origin) then
		ArticleNumber = A['ArticleNumber'];
	end

	extra_text_in_vol_iss_check (Issue, A:ORIGIN ('Issue'), 'i');	

	local Page;
	local Pages;
	local At;
	local QuotePage;
	local QuotePages;
	if not utilities.in_array (config.CitationClass, cfg.templates_not_using_page) then		-- TODO: rewrite to emit ignored parameter error message?
		Page = A['Page'];
		Pages = utilities.hyphen_to_dash (A['Pages']);	
		At = A['At'];
		QuotePage = A['QuotePage'];
		QuotePages = utilities.hyphen_to_dash (A['QuotePages']);
	end

	local Edition = A['Edition'];
	local PublicationPlace = place_check (A['PublicationPlace'], A:ORIGIN('PublicationPlace'));
	local Place = place_check (A['Place'], A:ORIGIN('Place'));
	
	local PublisherName = A['PublisherName'];
	local PublisherName_origin = A:ORIGIN('PublisherName');
	if utilities.is_set (PublisherName) and (cfg.keywords_xlate['none'] ~= PublisherName) then
		local i = 0;
		PublisherName, i = utilities.strip_apostrophe_markup (PublisherName);	-- strip apostrophe markup so that metadata isn't contaminated; publisher is never italicized
		if i and (0 &lt; i) then													-- non-zero when markup was stripped so emit an error message
			utilities.set_message ('err_apostrophe_markup', {PublisherName_origin});
		end
	end
	
	if ('document' == config.CitationClass) and not utilities.is_set (PublisherName) then
		utilities.set_message ('err_missing_publisher', {config.CitationClass, 'publisher'});
	end

	local Newsgroup = A['Newsgroup'];											-- TODO: strip apostrophe markup?
	local Newsgroup_origin = A:ORIGIN('Newsgroup');	

	if 'newsgroup' == config.CitationClass then
		if utilities.is_set (PublisherName) and (cfg.keywords_xlate['none'] ~= PublisherName) then	-- general use parameter |publisher= not allowed in cite newsgroup
			utilities.set_message ('err_parameter_ignored', {PublisherName_origin});
		end

		PublisherName = nil;													-- ensure that this parameter is unset for the time being; will be used again after COinS
	end

	local URL = A['URL'];														-- TODO: better way to do this for URL, ChapterURL, and MapURL?
	local UrlAccess = is_valid_parameter_value (A['UrlAccess'], A:ORIGIN('UrlAccess'), cfg.keywords_lists['url-access'], nil);
	
	if not utilities.is_set (URL) and utilities.is_set (UrlAccess) then
		UrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', 'url');
	end
	
	local ChapterURL = A['ChapterURL'];
	local ChapterUrlAccess = is_valid_parameter_value (A['ChapterUrlAccess'], A:ORIGIN('ChapterUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (ChapterURL) and utilities.is_set (ChapterUrlAccess) then
		ChapterUrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', {A:ORIGIN('ChapterUrlAccess'):gsub ('%-access', '')});
	end

	local MapUrlAccess = is_valid_parameter_value (A['MapUrlAccess'], A:ORIGIN('MapUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (A['MapURL']) and utilities.is_set (MapUrlAccess) then
		MapUrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', {'map-url'});
	end

	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local no_tracking_cats = is_valid_parameter_value (A['NoTracking'], A:ORIGIN('NoTracking'), cfg.keywords_lists['yes_true_y'], nil);

	-- check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not utilities.is_set (no_tracking_cats) then								-- ignore if we are already not going to categorize this page
		if cfg.uncategorized_namespaces[this_page.namespace] then				-- is this page's namespace id one of the uncategorized namespace ids?
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _, v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end
																				-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	utilities.select_one (args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'err_redundant_parameters');	-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, A:ORIGIN('Page'), Pages, A:ORIGIN('Pages'), At);

	local NoPP = is_valid_parameter_value (A['NoPP'], A:ORIGIN('NoPP'), cfg.keywords_lists['yes_true_y'], nil);

	if utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- both |publication-place= and |place= (|location=) allowed if different
		utilities.add_prop_cat ('location-test');								-- add property cat to evaluate how often PublicationPlace and Place are used together
		if PublicationPlace == Place then
			Place = '';															-- unset; don't need both if they are the same
		end
	elseif not utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- when only |place= (|location=) is set ...
		PublicationPlace = Place;												-- promote |place= (|location=) to |publication-place
	end

	if PublicationPlace == Place then Place = ''; end							-- don't need both if they are the same

	local URL_origin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL_origin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ScriptChapter = A['ScriptChapter'];
	local ScriptChapter_origin = A:ORIGIN ('ScriptChapter');
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local TransChapter = A['TransChapter'];
	local TransChapter_origin = A:ORIGIN ('TransChapter');
	local TransTitle = A['TransTitle'];
	local ScriptTitle = A['ScriptTitle'];
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia= and |title= then map |title= to |article= and |encyclopedia= to |title= for rendering
		|encyclopedia= and |article= then map |encyclopedia= to |title= for rendering

		|trans-title= maps to |trans-chapter= when |title= is re-mapped
		|url= maps to |chapter-url= when |title= is remapped
	
	All other combinations of |encyclopedia=, |title=, and |article= are not modified
	
	]]

	local Encyclopedia = A['Encyclopedia'];										-- used as a flag by this module and by ~/COinS
	local ScriptEncyclopedia = A['ScriptEncyclopedia'];
	local TransEncyclopedia = A['TransEncyclopedia'];

	if utilities.is_set (Encyclopedia) or utilities.is_set (ScriptEncyclopedia) then	-- emit error message when Encyclopedia set but template is other than {{cite encyclopedia}} or {{citation}}
		if 'encyclopaedia' ~= config.CitationClass and 'citation' ~= config.CitationClass then
			if utilities.is_set (Encyclopedia) then
				utilities.set_message ('err_parameter_ignored', {A:ORIGIN ('Encyclopedia')});
			else
				utilities.set_message ('err_parameter_ignored', {A:ORIGIN ('ScriptEncyclopedia')});
			end
			Encyclopedia = nil;													-- unset these because not supported by this template
			ScriptEncyclopedia = nil;
			TransEncyclopedia = nil;
		end
	elseif utilities.is_set (TransEncyclopedia) then
		utilities.set_message ('err_trans_missing_title', {'encyclopedia'});
	end

	if ('encyclopaedia' == config.CitationClass) or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Periodical) and utilities.is_set (Encyclopedia) then	-- when both parameters set emit an error message; {{citation}} only; Periodical not allowed in {{cite encyclopedia}}
			utilities.set_message ('err_periodical_ignored', {Periodical_origin});
		end

		if utilities.is_set (Encyclopedia) or utilities.is_set (ScriptEncyclopedia) then
			Periodical = Encyclopedia;											-- error or no, set Periodical to Encyclopedia for rendering; {{citation}} could (not legitimately) have both; use Encyclopedia
			Periodical_origin = A:ORIGIN ('Encyclopedia');
			ScriptPeriodical = ScriptEncyclopedia;
			ScriptPeriodical_origin = A:ORIGIN ('ScriptEncyclopedia');

			if utilities.is_set (Title) or utilities.is_set (ScriptTitle) then
				if not utilities.is_set (Chapter) then
					Chapter = Title;											-- |encyclopedia= and |title= are set so map |title= params to |article= params for rendering
					ScriptChapter = ScriptTitle;
					ScriptChapter_origin = A:ORIGIN('ScriptTitle')
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterURL_origin = URL_origin;
					ChapterUrlAccess = UrlAccess;
					ChapterFormat = Format;

					if not utilities.is_set (ChapterURL) and utilities.is_set (TitleLink) then
						Chapter = utilities.make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;											-- now map |encyclopedia= params to |title= params for rendering
					ScriptTitle = ScriptPeriodical or '';
					TransTitle = TransEncyclopedia or '';
					Periodical = '';											-- redundant so unset
					ScriptPeriodical = '';
					URL = '';
					Format = '';
					TitleLink = '';
				end
			elseif utilities.is_set (Chapter) or utilities.is_set (ScriptChapter) then	-- |title= not set
				Title = Periodical;												-- |encyclopedia= set and |article= set so map |encyclopedia= to |title= for rendering
				ScriptTitle = ScriptPeriodical or '';
				TransTitle = TransEncyclopedia or '';
				Periodical = '';												-- redundant so unset
				ScriptPeriodical = '';
			end
		end
	end

	-- special case for cite techreport.
	local ID = A['ID'];
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if utilities.is_set (A['Number']) then									-- cite techreport uses 'number', which other citations alias to 'issue'
			if not utilities.is_set (ID) then									-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'id') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'number')});
			end
		end	
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	local ChapterLink -- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local Conference = A['Conference'];
	local BookTitle = A['BookTitle'];
	local TransTitle_origin = A:ORIGIN ('TransTitle');
	if 'conference' == config.CitationClass then
		if utilities.is_set (BookTitle) then
			Chapter = Title;
			Chapter_origin = 'title';
	--		ChapterLink = TitleLink;											-- |chapter-link= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			URL_origin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			TransChapter_origin = TransTitle_origin;
			Title = BookTitle;
			Format = '';
	--		TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end
	
	-- CS1/2 mode
	local Mode;
		if cfg.global_cs1_config_t['Mode'] then									-- global setting in {{cs1 config}} overrides local |mode= parameter value; nil when empty or assigned value invalid
			Mode = is_valid_parameter_value (cfg.global_cs1_config_t['Mode'], 'cs1 config: mode', cfg.keywords_lists['mode'], '');	-- error messaging 'param' here is a hoax
		else
			Mode = is_valid_parameter_value (A['Mode'], A:ORIGIN('Mode'), cfg.keywords_lists['mode'], '');
		end

		if cfg.global_cs1_config_t['Mode'] and utilities.is_set (A['Mode']) then	-- when template has |mode=&lt;something&gt; which global setting has overridden
			utilities.set_message ('maint_overridden_setting');					-- set a maint message
		end

	-- separator character and postscript
	local sepc, PostScript = set_style (Mode:lower(), A['PostScript'], config.CitationClass);
	-- controls capitalization of certain static text
	local use_lowercase = ( sepc == ',' );
	
	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		if utilities.is_set (Chapter) then										--TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'map') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', Chapter_origin)});	-- add error message
		end
		Chapter = A['Map'];
		Chapter_origin = A:ORIGIN('Map');
		ChapterURL = A['MapURL'];
		ChapterURL_origin = A:ORIGIN('MapURL');
		TransChapter = A['TransMap'];
		ScriptChapter = A['ScriptMap']
		ScriptChapter_origin = A:ORIGIN('ScriptMap')

		ChapterUrlAccess = MapUrlAccess;
		ChapterFormat = A['MapFormat'];

		Cartography = A['Cartography'];
		if utilities.is_set ( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if utilities.is_set ( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	local Series = A['Series'];
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local SeriesLink = A['SeriesLink'];

		SeriesLink = link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wiki-markup in |series-link= or wiki-markup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if utilities.is_set (Network) then table.insert(n, Network); end
		if utilities.is_set (Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if utilities.is_set (Season) and utilities.is_set (SeriesNumber) then	-- these are mutually exclusive so if both are set TODO: make a function for this and similar?
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'season') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'seriesno')});		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if utilities.is_set (Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if utilities.is_set (SeriesNumber) then table.insert(s, wrap_msg ('seriesnum', SeriesNumber, use_lowercase)); end
			if utilities.is_set (Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ScriptChapter_origin = A:ORIGIN('ScriptTitle');
			ChapterLink = TitleLink;											-- alias |episode-link=
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			ChapterFormat = Format;

			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if utilities.is_set (ChapterLink) and not utilities.is_set (ChapterURL) then	-- link but not URL
				Chapter = utilities.make_wikilink (ChapterLink, Chapter);
			elseif utilities.is_set (ChapterLink) and utilities.is_set (ChapterURL) then	-- if both are set, URL links episode;
				Series = utilities.make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			Format = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if utilities.is_set (Series) and utilities.is_set (SeriesLink) then
				Series = utilities.make_wikilink (SeriesLink, Series);
			end
			Series = utilities.wrap_style ('italic-title', Series);				-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- handle type parameter for those CS1 citations that have default values
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	if utilities.in_array (config.CitationClass, {'AV-media-notes', 'document', 'interview', 'mailinglist', 'map', 'podcast', 'pressrelease', 'report', 'speech', 'techreport', 'thesis'}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if utilities.is_set (Degree) and &quot;Thesis&quot; == TitleType then				-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if utilities.is_set (TitleType) then										-- if type parameter is specified
		TitleType = utilities.substitute ( cfg.messages['type'], TitleType);	-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
	local Date = A['Date'];
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging
	local PublicationDate = A['PublicationDate'];
	local Year = A['Year'];

	if not utilities.is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not utilities.is_set (Date) and utilities.is_set (PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]

	local DF = is_valid_parameter_value (A['DF'], A:ORIGIN('DF'), cfg.keywords_lists['df'], '');
	if not utilities.is_set (DF) then
		DF = cfg.global_df;														-- local |df= if present overrides global df set by {{use xxx date}} template
	end

	local ArchiveURL;
	local ArchiveDate;
	local ArchiveFormat = A['ArchiveFormat'];
	local archive_url_timestamp;												-- timestamp from wayback machine url
	
	ArchiveURL, ArchiveDate, archive_url_timestamp = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	
	ArchiveURL, ArchiveDate = is_unique_archive_url (ArchiveURL, URL, ChapterURL, A:ORIGIN('ArchiveURL'), ArchiveDate);		-- add error message when URL or ChapterURL == ArchiveURL

	local AccessDate = A['AccessDate'];
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification
	local DoiBroken = A['DoiBroken'];
	local Embargo = A['Embargo'];
	local anchor_year;															-- used in the CITEREF identifier
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val = AccessDate, name = A:ORIGIN ('AccessDate')},
			['archive-date'] = {val = ArchiveDate, name = A:ORIGIN ('ArchiveDate')},
			['date'] = {val = Date, name = Date_origin},
			['doi-broken-date'] = {val = DoiBroken, name = A:ORIGIN ('DoiBroken')},
			['pmc-embargo-date'] = {val = Embargo, name = A:ORIGIN ('Embargo')},
			['publication-date'] = {val = PublicationDate, name = A:ORIGIN ('PublicationDate')},
			['year'] = {val = Year, name = A:ORIGIN ('Year')},
			};

		local error_list = {};
		anchor_year, Embargo = validation.dates(date_parameters_list, COinS_date, error_list);

		if utilities.is_set (Year) and utilities.is_set (Date) then				-- both |date= and |year= not normally needed; 
			validation.year_date_check (Year, A:ORIGIN ('Year'), Date, A:ORIGIN ('Date'), error_list);
		end
		
		if 0 == #error_list then												-- error free dates only; 0 when error_list is empty
			local modified = false;												-- flag
			
			if utilities.is_set (DF) then										-- if we need to reformat dates
				modified = validation.reformat_dates (date_parameters_list, DF);	-- reformat to DF format, use long month names if appropriate
			end

			if true == validation.date_hyphen_to_dash (date_parameters_list) then	-- convert hyphens to dashes where appropriate
				modified = true;
				utilities.set_message ('maint_date_format');					-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language; not supported at en.wiki
			if cfg.date_name_auto_xlate_enable and validation.date_name_xlate (date_parameters_list, cfg.date_digit_auto_xlate_enable ) then
				utilities.set_message ('maint_date_auto_xlated');				-- add maint cat
				modified = true;
			end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end

			if archive_url_timestamp and utilities.is_set (ArchiveDate) then
				validation.archive_date_check (ArchiveDate, archive_url_timestamp, DF);	-- does YYYYMMDD in archive_url_timestamp match date in ArchiveDate
			end
		else
			utilities.set_message ('err_bad_date', {utilities.make_sep_list (#error_list, error_list)});	-- add this error message
		end
	end	-- end of do

	if utilities.in_array (config.CitationClass, {'book', 'encyclopaedia'}) or	-- {{cite book}}, {{cite encyclopedia}}; TODO: {{cite conference}} and others?
		('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) or			-- {{citation}} as an encylopedia citation
		('citation' == config.CitationClass and not utilities.is_set (Periodical)) then		-- {{citation}} as a book citation
			if utilities.is_set (PublicationPlace) then
				if not utilities.is_set (PublisherName) then
					local date = COinS_date.rftdate and tonumber (COinS_date.rftdate:match ('%d%d%d%d'));	-- get year portion of COinS date (because in Arabic numerals); convert string to number
					if date and (1850 &lt;= date) then								-- location has no publisher; if date is 1850 or later
						utilities.set_message ('maint_location_no_publisher');	-- add maint cat
					end
				else															-- PublisherName has a value
					if cfg.keywords_xlate['none'] == PublisherName then			-- if that value is 'none' (only for book and encyclopedia citations)
						PublisherName = '';										-- unset
					end
				end
			end
	end

	local ID_list = {};															-- sequence table of rendered identifiers
	local ID_list_coins = {};													-- table of identifiers and their values from args; key is same as cfg.id_handlers's key
	local Class = A['Class'];													-- arxiv class identifier
	
	local ID_support = {
		{A['ASINTLD'], 'ASIN', 'err_asintld_missing_asin', A:ORIGIN ('ASINTLD')},				
		{DoiBroken, 'DOI', 'err_doibroken_missing_doi', A:ORIGIN ('DoiBroken')},
		{Embargo, 'PMC', 'err_embargo_missing_pmc', A:ORIGIN ('Embargo')},
		}

	ID_list, ID_list_coins = identifiers.identifier_lists_get (args, {DoiBroken = DoiBroken, ASINTLD = A['ASINTLD'], Embargo = Embargo, Class = Class}, ID_support);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite medrxiv}}, {{cite ssrn}}, before generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list_t) then	-- |arxiv= or |eprint= required for cite arxiv; |biorxiv=, |citeseerx=, |medrxiv=, |ssrn= required for their templates
		if not (args[cfg.id_handlers[config.CitationClass:upper()].parameters[1]] or 		-- can't use ID_list_coins k/v table here because invalid parameters omitted
			args[cfg.id_handlers[config.CitationClass:upper()].parameters[2]]) then			-- which causes unexpected parameter missing error message
				utilities.set_message ('err_' .. config.CitationClass .. '_missing');		-- add error message
		end

		Periodical = ({['arxiv'] = 'arXiv', ['biorxiv'] = 'bioRxiv', ['citeseerx'] = 'CiteSeerX', ['medrxiv'] = 'medRxiv', ['ssrn'] = 'Social Science Research Network'})[config.CitationClass];
	end

	-- Link the title of the work if no |url= was provided, but we have a |pmc= or a |doi= with |doi-access=free

	if config.CitationClass == &quot;journal&quot; and not utilities.is_set (URL) and not utilities.is_set (TitleLink) and not utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) then -- TODO: remove 'none' once existing citations have been switched to 'off', so 'none' can be used as token for &quot;no title&quot; instead
		if 'none' ~= cfg.keywords_xlate[auto_select] then						-- if auto-linking not disabled
 	 		if identifiers.auto_link_urls[auto_select] then						-- manual selection
		 		URL = identifiers.auto_link_urls[auto_select];					-- set URL to be the same as identifier's external link
 				URL_origin = cfg.id_handlers[auto_select:upper()].parameters[1];	-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['pmc'] then						-- auto-select PMC
				URL = identifiers.auto_link_urls['pmc'];						-- set URL to be the same as the PMC external link if not embargoed
				URL_origin = cfg.id_handlers['PMC'].parameters[1];				-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['doi'] then						-- auto-select DOI
				URL = identifiers.auto_link_urls['doi'];
				URL_origin = cfg.id_handlers['DOI'].parameters[1];
			end
 	 	end

		if utilities.is_set (URL) then											-- set when using an identifier-created URL
			if utilities.is_set (AccessDate) then								-- |access-date= requires |url=; identifier-created URL is not |url=
				utilities.set_message ('err_accessdate_missing_url');			-- add an error message
				AccessDate = '';												-- unset
			end

			if utilities.is_set (ArchiveURL) then								-- |archive-url= requires |url=; identifier-created URL is not |url=
				utilities.set_message ('err_archive_missing_url');				-- add an error message
				ArchiveURL = '';												-- unset
			end
		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not utilities.is_set (Title) and not utilities.is_set (TransTitle) and not utilities.is_set (ScriptTitle) then	-- has special case for cite episode
		utilities.set_message ('err_citation_missing_title', {'episode' == config.CitationClass and 'series' or 'title'});
	end

	if utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) and
			utilities.in_array (config.CitationClass, {'journal', 'citation'}) and
			(utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and
			('journal' == Periodical_origin or 'script-journal' == ScriptPeriodical_origin) then	-- special case for journal cites
				Title = '';														-- set title to empty string
				utilities.set_message ('maint_untitled');						-- add maint cat
	end

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Chapter) and utilities.is_set (Title) and utilities.is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end
	
	-- this is the function call to COinS()
	local OCinSoutput = metadata.COinS({
		['Periodical'] = utilities.strip_apostrophe_markup (Periodical),		-- no markup in the metadata
		['Encyclopedia'] = Encyclopedia,										-- just a flag; content ignored by ~/COinS
		['Chapter'] = metadata.make_coins_title (coins_chapter, ScriptChapter),	-- Chapter and ScriptChapter stripped of bold / italic / accept-as-written markup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = metadata.make_coins_title (coins_title, ScriptTitle),		-- Title and ScriptTitle stripped of bold / italic / accept-as-written markup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date.* has correctly formatted date values if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Quarter'] = COinS_date.rftquarter,
		['Chron'] =  COinS_date.rftchron,
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['ArticleNumber'] = ArticleNumber,
		['Pages'] = coins_pages or metadata.get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At, QuotePage, QuotePages}, 7)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName or Newsgroup,							-- any apostrophe markup already removed from PublisherName
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list_coins,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite medrxiv}}, and {{cite ssrn}} AFTER generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list_t) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, CiteSeerX, medRxiv, or ssrn now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass and utilities.is_set (Newsgroup) then
		PublisherName = utilities.substitute (cfg.messages['newsgroup'], external_link( 'news:' .. Newsgroup, Newsgroup, Newsgroup_origin, nil ));
	end

	local Editors;
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	local Contributors;															-- assembled contributors name list
	local contributor_etal;
	local Translators;															-- assembled translators name list
	local translator_etal;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	local Interviewers;															
	local interviewers_list = {};					
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters
	local interviewer_etal;
	
	-- Now perform various field 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.
	do
		local last_first_list;
		local control = { 
			format = NameListStyle,												-- empty string, '&amp;', 'amp', 'and', or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			local display_names, param = display_names_select (cfg.global_cs1_config_t['DisplayEditors'], A['DisplayEditors'], A:ORIGIN ('DisplayEditors'), #e);
			control.maximum, editor_etal = get_display_names (display_names, #e, 'editors', editor_etal, param);

			Editors, EditorCount = list_people (control, e, editor_etal);

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			local display_names, param = display_names_select (cfg.global_cs1_config_t['DisplayInterviewers'], A['DisplayInterviewers'], A:ORIGIN ('DisplayInterviewers'), #interviewers_list);
			control.maximum, interviewer_etal = get_display_names (display_names, #interviewers_list, 'interviewers', interviewer_etal, param);

			Interviewers = list_people (control, interviewers_list, interviewer_etal);
		end
		do																		-- now do translators
			local display_names, param = display_names_select (cfg.global_cs1_config_t['DisplayTranslators'], A['DisplayTranslators'], A:ORIGIN ('DisplayTranslators'), #t);
			control.maximum, translator_etal = get_display_names (display_names, #t, 'translators', translator_etal, param);

			Translators = list_people (control, t, translator_etal);
		end
		do																		-- now do contributors
			local display_names, param = display_names_select (cfg.global_cs1_config_t['DisplayContributors'], A['DisplayContributors'], A:ORIGIN ('DisplayContributors'), #c);
			control.maximum, contributor_etal = get_display_names (display_names, #c, 'contributors', contributor_etal, param);

			Contributors = list_people (control, c, contributor_etal);
		end
		do																		-- now do authors
			local display_names, param = display_names_select (cfg.global_cs1_config_t['DisplayAuthors'], A['DisplayAuthors'], A:ORIGIN ('DisplayAuthors'), #a, author_etal);
			control.maximum, author_etal = get_display_names (display_names, #a, 'authors', author_etal, param);

			last_first_list = list_people (control, a, author_etal);

			if utilities.is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors');	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if utilities.is_set (Authors) and utilities.is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'medrxiv', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not utilities.is_set (URL) then
		if utilities.in_array (config.CitationClass, {&quot;web&quot;, &quot;podcast&quot;, &quot;mailinglist&quot;}) or		-- |url= required for cite web, cite podcast, and cite mailinglist
			('citation' == config.CitationClass and ('website' == Periodical_origin or 'script-website' == ScriptPeriodical_origin)) then	-- and required for {{citation}} with |website= or |script-website=
				utilities.set_message ('err_cite_web_url');
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if utilities.is_set (AccessDate) and not utilities.is_set (ChapterURL) then		-- ChapterURL may be set when URL is not set;
			utilities.set_message ('err_accessdate_missing_url');
			AccessDate = '';
		end
	end

	local UrlStatus = is_valid_parameter_value (A['UrlStatus'], A:ORIGIN('UrlStatus'), cfg.keywords_lists['url-status'], '');
	local OriginalURL
	local OriginalURL_origin
	local OriginalFormat
	local OriginalAccess;
	UrlStatus = UrlStatus:lower();												-- used later when assembling archived text
	if utilities.is_set ( ArchiveURL ) then
		if utilities.is_set (ChapterURL) then 									-- if chapter-url= is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURL_origin = ChapterURL_origin;								-- name of |chapter-url= parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=

			if 'live' ~= UrlStatus then
				ChapterURL = ArchiveURL											-- swap-in the archive's URL
				ChapterURL_origin = A:ORIGIN('ArchiveURL')						-- name of |archive-url= parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived URLs
			end
		elseif utilities.is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURL_origin = URL_origin;									-- name of URL parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;

			if 'live' ~= UrlStatus then											-- if URL set then |archive-url= applies to it
				URL = ArchiveURL												-- swap-in the archive's URL
				URL_origin = A:ORIGIN('ArchiveURL')								-- name of archive URL parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived URLs
			end
		end
	elseif utilities.is_set (UrlStatus) then									-- if |url-status= is set when |archive-url= is not set
 		utilities.set_message ('maint_url_status');								-- add maint cat
	end

	if utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'medrxiv', 'ssrn'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) then
			local chap_param;
			if utilities.is_set (Chapter) then									-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif utilities.is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif utilities.is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif utilities.is_set (ScriptChapter) then
				chap_param = ScriptChapter_origin;
			else utilities.is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if utilities.is_set (chap_param) then								-- if we found one
				utilities.set_message ('err_chapter_ignored', {chap_param});	-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if utilities.is_set (Contribution) and 0 &lt; #c then						-- if this is a contribution with contributor(s)
			if utilities.in_array (Contribution:lower(), cfg.keywords_lists.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, ScriptChapter_origin, Chapter, Chapter_origin, TransChapter, TransChapter_origin, ChapterURL, ChapterURL_origin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if utilities.is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and utilities.is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter .. sepc .. ' ';
		elseif utilities.is_set (ChapterFormat) then							-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title
	local plain_title = false;
	local accept_title;
	Title, accept_title = utilities.has_accept_as_written (Title, true);		-- remove accept-this-as-written markup when it wraps all of &lt;Title&gt;
	if accept_title and ('' == Title) then										-- only support forced empty for now &quot;(())&quot;
		Title = cfg.messages['notitle'];										-- replace by predefined &quot;No title&quot; message
			-- TODO: utilities.set_message ( 'err_redundant_parameters', ...);	-- issue proper error message instead of muting	 
			ScriptTitle = '';													-- just mute for now	 
			TransTitle = '';													-- just mute for now
 		plain_title = true;														-- suppress text decoration for descriptive title
		utilities.set_message ('maint_untitled');								-- add maint cat
	end

	if not accept_title then													-- &lt;Title&gt; not wrapped in accept-as-written markup
		if '...' == Title:sub (-3) then											-- if ellipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%' .. sepc .. '$', '');			-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end

		if utilities.is_set (ArchiveURL) and is_archived_copy (Title) then
			utilities.set_message ('maint_archived_copy');						-- add maintenance category before we modify the content of Title
		end

		if is_generic ('generic_titles', Title) then
			utilities.set_message ('err_generic_title');						-- set an error message
		end
	end

	if (not plain_title) and (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'document', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx', 'medrxiv', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) or
		('map' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)))) then		-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from module provided quote marks
			Title = utilities.wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle, 'script-title');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
			TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );
	elseif plain_title or ('report' == config.CitationClass) then				-- no styling for cite report and descriptive titles (otherwise same as above)
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );	-- for cite report, use this form for trans-title
	else
		Title = utilities.wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-italic-title', TransTitle);
	end

	if utilities.is_set (TransTitle) then
		if utilities.is_set (Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			utilities.set_message ('err_trans_missing_title', {'title'});
		end
	end

	if utilities.is_set (Title) then											-- TODO: is this the right place to be making Wikisource URLs?
		if utilities.is_set (TitleLink) and utilities.is_set (URL) then
			utilities.set_message ('err_wikilink_in_url');						-- set an error message because we can't have both
			TitleLink = '';														-- unset
		end
	
		if not utilities.is_set (TitleLink) and utilities.is_set (URL) then
			Title = external_link (URL, Title, URL_origin, UrlAccess) .. TransTitle .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif utilities.is_set (TitleLink) and not utilities.is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle;
			else
				Title = utilities.make_wikilink (TitleLink, Title) .. TransTitle;
			end
		else
			local ws_url, ws_label, L;											-- Title has italic or quote markup by the time we get here which causes is_wikilink() to return 0 (not a wikilink)
			ws_url, ws_label, L = wikisource_url_make (Title:gsub('^[\'&quot;]*(.-)[\'&quot;]*$', '%1'));	-- make ws URL from |title= interwiki link (strip italic or quote markup); link portion L becomes tooltip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle;
			else
				Title = Title .. TransTitle;
			end
		end
	else
		Title = TransTitle;
	end

	if utilities.is_set (Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	local ConferenceURL_origin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	if utilities.is_set (Conference) then
		if utilities.is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURL_origin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif utilities.is_set (ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURL_origin, nil );
	end

	local Position = '';
	if not utilities.is_set (Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if utilities.is_set (Minutes) then
			if utilities.is_set (Time) then		--TODO: make a function for this and similar?
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'minutes') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'time')});
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if utilities.is_set (Time) then
				local TimeCaption = A['TimeCaption']
				if not utilities.is_set (TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = utilities.is_set (At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = utilities.is_set (Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Sections = A['Sections'];											-- Section (singular) is an alias of Chapter so set earlier
		local Inset = A['Inset'];
		
		if utilities.is_set ( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if utilities.is_set ( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif utilities.is_set ( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	local Others = A['Others'];
	if utilities.is_set (Others) and 0 == #a and 0 == #e then					-- add maint cat when |others= has value and used without |author=, |editor=
		if config.CitationClass == &quot;AV-media-notes&quot;
		or config.CitationClass == &quot;audio-visual&quot; then							-- special maint for AV/M which has a lot of 'false' positives right now
			utilities.set_message ('maint_others_avm')
		else
			utilities.set_message ('maint_others');
		end
	end
	Others = utilities.is_set (Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if utilities.is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if utilities.is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	local TitleNote = A['TitleNote'];
	TitleNote = utilities.is_set (TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if utilities.is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%n?%.?$') or Edition:match ('%f[%a][Ee]dition$') then -- Ed, ed, Ed., ed., Edn, edn, Edn., edn.
			utilities.set_message ('err_extra_text_edition');					 -- add error message
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = utilities.is_set (Series) and wrap_msg ('series', {sepc, Series}) or &quot;&quot;;	-- not the same as SeriesNum
	local Agency = A['Agency'] or '';											-- |agency= only supported in {{cite news}}, {{cite press release}}, {{cite web}} and certain {{citation}} templates
	if utilities.is_set (Agency) then											-- this testing done here because {{citation}} supports 'news' citations
		if utilities.in_array (config.CitationClass, {'news', 'pressrelease', 'web'}) or ('citation' == config.CitationClass and utilities.in_array (Periodical_origin, {&quot;newspaper&quot;, &quot;work&quot;})) then
			Agency = wrap_msg ('agency', {sepc, Agency});						-- format for rendering
		else
			Agency = '';														-- unset; not supported
			utilities.set_message ('err_parameter_ignored', {'agency'});		-- add error message
		end
	end
	
	Volume = format_volume_issue (Volume, Issue, ArticleNumber, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	if utilities.is_set (AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = utilities.substitute (retrv_text, AccessDate);				-- add retrieved text

		AccessDate = utilities.substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if utilities.is_set (ID) then ID = sepc .. &quot; &quot; .. ID; end
	
	local Docket = A['Docket'];
   	if &quot;thesis&quot; == config.CitationClass and utilities.is_set (Docket) then
		ID = sepc .. &quot; Docket &quot; .. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and utilities.is_set (Docket) then		-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	if utilities.is_set (URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URL_origin, UrlAccess );
	end

	local Quote = A['Quote'];
	local TransQuote = A['TransQuote'];
	local ScriptQuote = A['ScriptQuote'];
	if utilities.is_set (Quote) or utilities.is_set (TransQuote) or utilities.is_set (ScriptQuote) then

		if utilities.is_set (Quote) then
			if Quote:sub(1, 1) == '&quot;' and Quote:sub(-1, -1) == '&quot;' then			-- if first and last characters of quote are quote marks
				Quote = Quote:sub(2, -2);										-- strip them off
			end
		end
		
		Quote = kern_quotes (Quote);											-- kern if needed
		Quote = utilities.wrap_style ('quoted-text', Quote );					-- wrap in &lt;q&gt;...&lt;/q&gt; tags
	
		if utilities.is_set (ScriptQuote) then
			Quote = script_concatenate (Quote, ScriptQuote, 'script-quote');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after quote is wrapped
		end

		if utilities.is_set (TransQuote) then
			if TransQuote:sub(1, 1) == '&quot;' and TransQuote:sub(-1, -1) == '&quot;' then -- if first and last characters of |trans-quote are quote marks
				TransQuote = TransQuote:sub(2, -2); -- strip them off
			end
			Quote = Quote .. &quot; &quot; .. utilities.wrap_style ('trans-quoted-title', TransQuote );
		end

		if utilities.is_set (QuotePage) or utilities.is_set (QuotePages) then	-- add page prefix
			local quote_prefix = '';
			if utilities.is_set (QuotePage) then
				extra_text_in_page_check (QuotePage, 'quote-page');				-- add to maint cat if |quote-page= value begins with what looks like p., pp., etc.
				if not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePage}), '', '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePage}), '', '', '';
				end
			elseif utilities.is_set (QuotePages) then
				extra_text_in_page_check (QuotePages, 'quote-pages');			-- add to maint cat if |quote-pages= value begins with what looks like p., pp., etc.
				if tonumber(QuotePages) ~= nil and not NoPP then				-- if only digits, assume single page
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePages}), '', '';
				elseif not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['pp-prefix'], {sepc, QuotePages}), '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePages}), '', '';
				end
			end
                        
			Quote = quote_prefix .. &quot;: &quot; .. Quote;
		else
			Quote = sepc .. &quot; &quot; .. Quote;
		end

		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	-- We check length of PostScript here because it will have been nuked by
	-- the quote parameters. We'd otherwise emit a message even if there wasn't
	-- a displayed postscript.
	-- TODO: Should the max size (1) be configurable?
	-- TODO: Should we check a specific pattern?
	if utilities.is_set(PostScript) and mw.ustring.len(PostScript) &gt; 1 then
		utilities.set_message ('maint_postscript')
	end
	
	local Archived;
	if utilities.is_set (ArchiveURL) then
		if not utilities.is_set (ArchiveDate) then								-- ArchiveURL set but ArchiveDate not set
			utilities.set_message ('err_archive_missing_date');					-- emit an error message
			ArchiveURL = '';													-- empty string for concatenation
			ArchiveDate = '';													-- empty string for concatenation
		end
	else														
		if utilities.is_set (ArchiveDate) then									-- ArchiveURL not set but ArchiveDate is set
			utilities.set_message ('err_archive_date_missing_url');				-- emit an error message
			ArchiveURL = '';													-- empty string for concatenation
			ArchiveDate = '';													-- empty string for concatenation
		end
	end

	if utilities.is_set (ArchiveURL) then
		local arch_text;
		if &quot;live&quot; == UrlStatus then
			arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if utilities.is_set (ArchiveDate) then
				Archived = sepc .. ' ' .. utilities.substitute ( cfg.messages['archived-live'],
					{external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil) .. ArchiveFormat, ArchiveDate } );
			else
				Archived = '';
			end
			if not utilities.is_set (OriginalURL) then
				utilities.set_message ('err_archive_missing_url');
				Archived = '';													-- empty string for concatenation
			end
		elseif utilities.is_set (OriginalURL) then								-- UrlStatus is empty, 'dead', 'unfit', 'usurped', 'bot: unknown'
			if utilities.in_array (UrlStatus, {'unfit', 'usurped', 'bot: unknown'}) then
				arch_text = cfg.messages['archived-unfit'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. ' ' .. arch_text .. ArchiveDate;				-- format already styled
				if 'bot: unknown' == UrlStatus then
					utilities.set_message ('maint_bot_unknown');				-- and add a category if not already added
				else
					utilities.set_message ('maint_unfit');						-- and add a category if not already added
				end
			else																-- UrlStatus is empty, 'dead'
				arch_text = cfg.messages['archived-dead'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				if utilities.is_set (ArchiveDate) then
					Archived = sepc .. &quot; &quot; .. utilities.substitute ( arch_text,
						{ external_link( OriginalURL, cfg.messages['original'], OriginalURL_origin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
				else
					Archived = '';												-- unset for concatenation
				end
			end	
		else																	-- OriginalUrl not set
			utilities.set_message ('err_archive_missing_url');
			Archived = '';														-- empty string for concatenation
		end
	elseif utilities.is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = '';
	end
	
	local TranscriptURL = A['TranscriptURL']
	local TranscriptFormat = A['TranscriptFormat'];
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');
	local Transcript = A['Transcript'];
	local TranscriptURL_origin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL
	if utilities.is_set (Transcript) then
		if utilities.is_set (TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURL_origin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif utilities.is_set (TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURL_origin, nil );
	end

	local Publisher;
	if utilities.is_set (PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if utilities.is_set (PublisherName) then
		if utilities.is_set (PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif utilities.is_set (PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical)) then
		if utilities.is_set (Title) or utilities.is_set (TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		else 
			Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		end
	end
	
	local Language = A['Language'];
	if utilities.is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc.
	else
		Language='';															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then									-- cite speech only
		TitleNote = TitleType;													-- move TitleType to TitleNote so that it renders ahead of |event=
		TitleType = '';															-- and unset

		if utilities.is_set (Periodical) then									-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if utilities.is_set (Conference) then								-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;							-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (Periodical) then		-- special cases for book cites
		if utilities.is_set (Contributors) then									-- when we are citing foreword, preface, introduction, etc.
			tcommon = safe_join ({Title, TitleNote}, sepc);						-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join ({TitleType, Series, Language, Volume, Others, Edition, Publisher}, sepc);
		else
			tcommon = safe_join ({Title, TitleNote, TitleType, Series, Language, Volume, Others, Edition, Publisher}, sepc);
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if utilities.is_set (Chapter) then										-- map in a book; TitleType is part of Chapter
			tcommon = safe_join ({Title, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc);
		elseif utilities.is_set (Periodical) then								-- map in a periodical
			tcommon = safe_join ({Title, TitleType, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc);
		else																	-- a sheet or stand-alone map
			tcommon = safe_join ({Title, TitleType, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc);
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join ({Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc);

	else																		-- all other CS1 templates
		tcommon = safe_join ({Title, TitleNote, Conference, Periodical, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc);
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local Via = A['Via'];
	Via = utilities.is_set (Via) and  wrap_msg ('via', Via) or '';
	local idcommon;
	if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then	-- special case for cite AV media &amp; cite episode position transcript
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, Quote }, sepc );
	else
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, Quote }, sepc );
	end
	
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	local OrigDate = A['OrigDate'];
	OrigDate = utilities.is_set (OrigDate) and wrap_msg ('origdate', OrigDate) or '';
	if utilities.is_set (Date) then
		if utilities.is_set (Authors) or utilities.is_set (Editors) then		-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date .. &quot;)&quot; .. OrigDate .. sepc .. &quot; &quot;;				-- in parentheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon, -1, -1) == sepc) then						-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigDate;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigDate;							-- Date begins with sepc
			end
		end
	end	
	if utilities.is_set (Authors) then
		if (not utilities.is_set (Date)) then									-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Editors) then
			local in_text = '';
			local post_text = '';
			if utilities.is_set (Chapter) and 0 == #c then
				in_text = cfg.messages['in'] .. ' ';
				if (sepc ~= '.') then
					in_text = in_text:lower();									-- lowercase for cs2
				end
			end
			if EditorCount &lt;= 1 then
				post_text = ' (' .. cfg.messages['editor'] .. ')';				-- be consistent with no-author, no-date case
			else
				post_text = ' (' .. cfg.messages['editors'] .. ')';
			end
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Contributors) then									-- book cite and we're citing the intro, preface, etc.
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if utilities.is_set (Editors) and utilities.is_set (Date) then		-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not utilities.is_set (Date)) then								-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif utilities.is_set (Editors) then
		if utilities.is_set (Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. cfg.presentation['sep_name'] .. cfg.messages['editor'];
			else
				Editors = Editors .. cfg.presentation['sep_name'] .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end

	if utilities.is_set (PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc ); 								-- Deals with italics, spaces, etc.
		if '.' == sepc then														-- remove final seperator if present
			text = text:gsub ('%' .. sepc .. '$', '');							-- dot must be escaped here
		else
			text = mw.ustring.gsub (text, sepc .. '$', '');						-- using ustring for non-dot sepc (likely a non-Latin character)
		end
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite&gt; element
	local options_t = {};
	options_t.class = cite_class_attribute_make (config.CitationClass, Mode);

	local Ref = is_valid_parameter_value (A['Ref'], A:ORIGIN('Ref'), cfg.keywords_lists['ref'], nil, true);	-- nil when |ref=harv; A['Ref'] else

	if 'none' ~= cfg.keywords_xlate[(Ref and Ref:lower()) or ''] then
		local namelist_t = {};													-- holds selected contributor, author, editor name list
		local year = first_set ({Year, anchor_year}, 2);						-- Year first for legacy citations and for YMD dates that require disambiguation

		if #c &gt; 0 then															-- if there is a contributor list
			namelist_t = c;														-- select it
		elseif #a &gt; 0 then														-- or an author list
			namelist_t = a;
		elseif #e &gt; 0 then														-- or an editor list
			namelist_t = e;
		end
		local citeref_id;
		if #namelist_t &gt; 0 then													-- if there are names in namelist_t
			citeref_id = make_citeref_id (namelist_t, year);					-- go make the CITEREF anchor
			if mw.uri.anchorEncode (citeref_id) == ((Ref and mw.uri.anchorEncode (Ref)) or '') then	-- Ref may already be encoded (by {{sfnref}}) so citeref_id must be encoded before comparison
				utilities.set_message ('maint_ref_duplicates_default');
			end
		else
			citeref_id = '';													-- unset
		end
		options_t.id = Ref or citeref_id;
	end

	if string.len (text:gsub('%b&lt;&gt;', '')) &lt;= 2 then								-- remove html and html-like tags; then get length of what remains; 
		z.error_cats_t = {};													-- blank the categories list
		z.error_msgs_t = {};													-- blank the error messages list
		OCinSoutput = nil;														-- blank the metadata string
		text = '';																-- blank the the citation
		utilities.set_message ('err_empty_citation');							-- set empty citation message and category
	end
	
	local render_t = {};														-- here we collect the final bits for concatenation into the rendered citation

	if utilities.is_set (options_t.id) then										-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render_t, utilities.substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options_t.id), mw.text.nowiki(options_t.class), text}));	-- when |ref= is set or when there is a namelist
	else
		table.insert (render_t, utilities.substitute (cfg.presentation['cite'], {mw.text.nowiki(options_t.class), text}));	-- when |ref=none or when namelist_t empty and |ref= is missing or is empty
	end		

	if OCinSoutput then															-- blanked when citation is 'empty' so don't bother to add boilerplate metadata span
		table.insert (render_t, utilities.substitute (cfg.presentation['ocins'], OCinSoutput));	-- format and append metadata to the citation
	end

	local template_name = ('citation' == config.CitationClass) and 'citation' or 'cite ' .. (cfg.citation_class_map_t[config.CitationClass] or config.CitationClass);
	local template_link = '[[Template:' .. template_name .. '|' .. template_name .. ']]';
	local msg_prefix = '&lt;code class=&quot;cs1-code&quot;&gt;{{' .. template_link .. '}}&lt;/code&gt;: ';

	if 0 ~= #z.error_msgs_t then
		mw.addWarning (utilities.substitute (cfg.messages.warning_msg_e, template_link));

		table.insert (render_t, ' ');											-- insert a space between citation and its error messages
		table.sort (z.error_msgs_t);											-- sort the error messages list; sorting includes wrapping &lt;span&gt; and &lt;code&gt; tags; hidden-error sorts ahead of visible-error

		local hidden = true;													-- presume that the only error messages emited by this template are hidden
		for _, v in ipairs (z.error_msgs_t) do									-- spin through the list of error messages
			if v:find ('cs1-visible-error', 1, true) then						-- look for the visible error class name
				hidden = false;													-- found one; so don't hide the error message prefix
				break;															-- and done because no need to look further
			end
		end

		z.error_msgs_t[1] = table.concat ({utilities.error_comment (msg_prefix, hidden), z.error_msgs_t[1]});	-- add error message prefix to first error message to prevent extraneous punctuation
		table.insert (render_t, table.concat (z.error_msgs_t, '; '));			-- make a big string of error messages and add it to the rendering
	end

	if 0 ~= #z.maint_cats_t then
		mw.addWarning (utilities.substitute (cfg.messages.warning_msg_m, template_link));

		table.sort (z.maint_cats_t);											-- sort the maintenance messages list

		local maint_msgs_t = {};												-- here we collect all of the maint messages

		if 0 == #z.error_msgs_t then											-- if no error messages
			table.insert (maint_msgs_t, msg_prefix);							-- insert message prefix in maint message livery
		end
		
		for _, v in ipairs( z.maint_cats_t ) do									-- append maintenance categories
			table.insert (maint_msgs_t, 										-- assemble new maint message and add it to the maint_msgs_t table
				table.concat ({v, ' (', utilities.substitute (cfg.messages[':cat wikilink'], v), ')'})
				);
		end
		table.insert (render_t, utilities.substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs_t, ' ')));	-- wrap the group of maint messages with proper presentation and save
	end

	if not no_tracking_cats then
		local sort_key;
		local cat_wikilink = 'cat wikilink';
		if cfg.enable_sort_keys then											-- when namespace sort keys enabled
			local namespace_number = mw.title.getCurrentTitle().namespace;		-- get namespace number for this wikitext
			sort_key = (0 ~= namespace_number and (cfg.name_space_sort_keys[namespace_number] or cfg.name_space_sort_keys.other)) or nil;	-- get sort key character; nil for mainspace
			cat_wikilink = (not sort_key and 'cat wikilink') or 'cat wikilink sk';	-- make &lt;cfg.messages&gt; key
		end				

		for _, v in ipairs (z.error_cats_t) do									-- append error categories
			table.insert (render_t, utilities.substitute (cfg.messages[cat_wikilink], {v, sort_key}));
		end
		for _, v in ipairs (z.maint_cats_t) do									-- append maintenance categories
			table.insert (render_t, utilities.substitute (cfg.messages[cat_wikilink], {v, sort_key}));
		end

		for _, v in ipairs (z.prop_cats_t) do									-- append properties categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));	-- no sort keys
		end
	end

	return table.concat (render_t);												-- make a big string and done
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class, empty)
	local name = tostring (name);
	local enum_name;															-- parameter name with enumerator (if any) replaced with '#'
	local state;
	local function state_test (state, name)										-- local function to do testing of state values
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			if empty then return nil; end										-- empty deprecated parameters are treated as unknowns
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
		if 'tracked' == state then
			local base_name = name:gsub ('%d', '');								-- strip enumerators from parameter names that have them to get the base name
			utilities.add_prop_cat ('tracked-param', {base_name}, base_name);	-- add a properties category; &lt;base_name&gt; modifies &lt;key&gt;
			return true;
		end
		return nil;
	end		

	if name:find ('#') then														-- # is a cs1|2 reserved character so parameters with # not permitted
		return nil;
	end
																				-- replace enumerator digit(s) with # (|last25= becomes |last#=) (mw.ustring because non-Western 'local' digits)
	enum_name = mw.ustring.gsub (name, '%d+$', '#');							-- where enumerator is last charaters in parameter name (these to protect |s2cid=)
	enum_name = mw.ustring.gsub (enum_name, '%d+([%-l])', '#%1');				-- where enumerator is in the middle of the parameter name; |author#link= is the oddity

	if 'document' == cite_class then											-- special case for {{cite document}}
		state = whitelist.document_parameters_t[enum_name];						-- this list holds enumerated and nonenumerated parameters
		if true == state_test (state, name) then return true; end
		
		return false;
	end

	if utilities.in_array (cite_class, whitelist.preprint_template_list_t) then	-- limited parameter sets allowed for these templates
		state = whitelist.limited_parameters_t[enum_name];						-- this list holds enumerated and nonenumerated parameters
		if true == state_test (state, name) then return true; end

		state = whitelist.preprint_arguments_t[cite_class][name];				-- look in the parameter-list for the template identified by cite_class
		if true == state_test (state, name) then return true; end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates

	if utilities.in_array (cite_class, whitelist.unique_param_template_list_t) then 	-- template-specific parameters for templates that accept parameters from the basic argument list
		state = whitelist.unique_arguments_t[cite_class][name];					-- look in the template-specific parameter-lists for the template identified by cite_class
		if true == state_test (state, name) then return true; end
	end																			-- if here, fall into general validation

	state = whitelist.common_parameters_t[enum_name];							-- all other templates; all normal parameters allowed; this list holds enumerated and nonenumerated parameters
	if true == state_test (state, name) then return true; end

	return false;																-- not supported because not found or name is set to nil
end


--[=[-------------------------&lt; I N T E R _ W I K I _ C H E C K &gt;----------------------------------------------

check &lt;value&gt; for inter-language interwiki-link markup.  &lt;prefix&gt; must be a MediaWiki-recognized language
code.  when these values have the form (without leading colon):
	[[&lt;prefix&gt;:link|label]] return label as plain-text
	[[&lt;prefix&gt;:link]] return &lt;prefix&gt;:link as plain-text

return value as is else

]=]

local function inter_wiki_check (parameter, value)
	local prefix = value:match ('%[%[(%a+):');									-- get an interwiki prefix if one exists
	local _;
	
	if prefix and cfg.inter_wiki_map[prefix:lower()] then						-- if prefix is in the map, needs preceding colon so
		utilities.set_message ('err_bad_paramlink', parameter);					-- emit an error message
		_, value, _ = utilities.is_wikilink (value);							-- extract label portion from wikilink
	end
	return value;
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe.  There are two tests made:
	{{cite ... |title=Title access-date=2016-03-17}}	-- the first parameter has a value and whitespace separates that value from the missing pipe parameter name
	{{cite ... |title=access-date=2016-03-17}}			-- the first parameter has no value (whitespace after the first = is trimmed by MediaWiki)
cs1|2 shares some parameter names with XML/HTML attributes: class=, title=, etc.  To prevent false positives XML/HTML
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (parameter, value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove XML/HTML tags because attributes: class=, title=, etc.

	capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then										-- if the capture is a valid parameter name
		utilities.set_message ('err_missing_pipe', parameter);
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ P U N C T &gt;--------------------------------------

look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_punc (param, value)
	if 'number' == type (param) then
		return;
	end
	
	param = param:gsub ('%d+', '#');											-- enumerated name-list mask params allow terminal punct; normalize 
	if cfg.punct_skip[param] then
		return;																	-- parameter name found in the skip table so done
	end
	
	if value:match ('[,;:]$') then
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
	if value:match ('^=') then													-- sometimes an extraneous '=' character appears ...
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ U R L &gt;------------------------------------------

look for extraneous url parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_url (url_param_t)
	local url_error_t = {};
	
	check_for_url (url_param_t, url_error_t);									-- extraneous url check
	if 0 ~= #url_error_t then													-- non-zero when there are errors
		table.sort (url_error_t);
		utilities.set_message ('err_param_has_ext_link', {utilities.make_sep_list (#url_error_t, url_error_t)});	-- add this error message
	end
end


--[[--------------------------&lt; C I T A T I O N &gt;--------------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

local function citation(frame)
	Frame = frame;																-- save a copy in case we need to display an error message in preview mode

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do											-- get parameters from the {{#invoke}} frame
		config[k] = v;
	--	args[k] = v;															-- crude debug support that allows us to render a citation from module {{#invoke:}}; skips parameter validation; TODO: keep?
	end	
																				-- i18n: set the name that your wiki uses to identify sandbox subpages from sandbox template invoke (or can be set here)
	local sandbox = ((config.SandboxPath and '' ~= config.SandboxPath) and config.SandboxPath) or '/sandbox';	-- sandbox path from {{#invoke:Citation/CS1/sandbox|citation|SandboxPath=/...}}
	is_sandbox = nil ~= string.find (frame:getTitle(), sandbox, 1, true);		-- is this invoke the sandbox module?
	sandbox = is_sandbox and sandbox or '';										-- use i18n sandbox to load sandbox modules when this module is the sandox; live modules else

	local pframe = frame:getParent()
	local styles;
	
	cfg = mw.loadData ('Module:Citation/CS1/Configuration' .. sandbox);			-- load sandbox versions of support modules when {{#invoke:Citation/CS1/sandbox|...}}; live modules else
	whitelist = mw.loadData ('Module:Citation/CS1/Whitelist' .. sandbox);
	utilities = require ('Module:Citation/CS1/Utilities' .. sandbox);
	validation = require ('Module:Citation/CS1/Date_validation' .. sandbox);
	identifiers = require ('Module:Citation/CS1/Identifiers' .. sandbox);
	metadata = require ('Module:Citation/CS1/COinS' .. sandbox);
	styles = 'Module:Citation/CS1' .. sandbox .. '/styles.css';

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the selected cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	is_preview_mode = not utilities.is_set (frame:preprocess ('{{REVISIONID}}'));

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text;															-- used as a flag

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	local empty_unknowns = {};													-- sequence table to hold empty unknown params for error message listing
	for k, v in pairs( pframe.args ) do											-- get parameters from the parent (template) frame
		v = mw.ustring.gsub (v, '^%s*(.-)%s*$', '%1');							-- trim leading/trailing whitespace; when v is only whitespace, becomes empty string
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				if type (k) ~= 'string' then									-- exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text = utilities.set_message ('err_text_ignored', {v});
					end
				elseif validate (k:lower(), config.CitationClass) then 
					error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, k:lower()});	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						suggestions = mw.loadData ('Module:Citation/CS1/Suggestions' .. sandbox);	--load sandbox version of suggestion module when {{#invoke:Citation/CS1/sandbox|...}}; live module else
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no capture in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = utilities.substitute (param, capture);		-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, param});	-- set the suggestion error message
							else
								error_text = utilities.set_message ('err_parameter_ignored', {k});	-- suggested param not supported by this template
								v = '';											-- unset
							end
						end
					end
					if not utilities.is_set (error_text) then					-- couldn't match with a pattern, is there an explicit suggestion?						
						if (suggestions.suggestions[ k:lower() ] ~= nil) and validate (suggestions.suggestions[ k:lower() ], config.CitationClass) then
							utilities.set_message ('err_parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]});
						else
							utilities.set_message ('err_parameter_ignored', {k});
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
			end

			args[k] = v;														-- save this parameter and its value

		elseif not utilities.is_set (v) then									-- for empty parameters
			if not validate (k, config.CitationClass, true) then				-- is this empty parameter a valid parameter
				k = ('' == k) and '(empty string)' or k;						-- when k is empty string (or was space(s) trimmed to empty string), replace with descriptive text
				table.insert (empty_unknowns, utilities.wrap_style ('parameter', k));	-- format for error message and add to the list
			end
																				-- crude debug support that allows us to render a citation from module {{#invoke:}} TODO: keep?
	--	elseif args[k] ~= nil or (k == 'postscript') then						-- when args[k] has a value from {{#invoke}} frame (we don't normally do that)
	--		args[k] = v;														-- overwrite args[k] with empty string from pframe.args[k] (template frame); v is empty string here
		end																		-- not sure about the postscript bit; that gets handled in parameter validation; historical artifact?
	end	

	if 0 ~= #empty_unknowns then												-- create empty unknown error message
		utilities.set_message ('err_param_unknown_empty', {
			1 == #empty_unknowns and '' or 's',
			utilities.make_sep_list (#empty_unknowns, empty_unknowns)
			});
	end

	local url_param_t = {};

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);											-- look for invisible characters
		end
		has_extraneous_punc (k, v);												-- look for extraneous terminal punctuation in parameter values
		missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?
		args[k] = inter_wiki_check (k, v);										-- when language interwiki-linked parameter missing leading colon replace with wiki-link label

		if 'string' == type (k) and not cfg.url_skip[k] then					-- when parameter k is not positional and not in url skip table
			url_param_t[k] = v;													-- make a parameter/value list for extraneous url check
		end
	end

	has_extraneous_url (url_param_t);											-- look for url in parameter values where a url does not belong

	return table.concat ({
		frame:extensionTag ('templatestyles', '', {src=styles}),
		citation0( config, args)
	});
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {citation = citation};</text>
      <sha1>7sahwn7umrpjn8voh7tpvtm2yhs02x8</sha1>
    </revision>
    <revision>
      <id>4755</id>
      <parentid>4754</parentid>
      <timestamp>2024-08-17T18:39:14Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4755</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="226578" sha1="hg2b1k0ag9k3jgjps3raeavqbua1l4x" xml:space="preserve">require ('strict');

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------

each of these counts against the Lua upvalue limit

]]

local validation;																-- functions in Module:Citation/CS1/Date_validation

local utilities;																-- functions in Module:Citation/CS1/Utilities
local z = {};																	-- table of tables in Module:Citation/CS1/Utilities

local identifiers;																-- functions and tables in Module:Citation/CS1/Identifiers
local metadata;																	-- functions in Module:Citation/CS1/COinS
local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;---------------

declare variables here that have page-wide scope that are not brought in from
other modules; that are created here and used here

]]

local added_deprecated_cat;														-- Boolean flag so that the category is added only once
local added_vanc_errs;															-- Boolean flag so we only emit one Vancouver error / category
local added_generic_name_errs;													-- Boolean flag so we only emit one generic name error / category and stop testing names once an error is encountered
local added_numeric_name_errs;													-- Boolean flag so we only emit one numeric name error / category and stop testing names once an error is encountered
local added_numeric_name_maint;													-- Boolean flag so we only emit one numeric name maint category and stop testing names once a category has been emitted
local Frame;																	-- holds the module's frame table
local is_preview_mode;															-- true when article is in preview mode; false when using 'Preview page with this template' (previewing the module)
local is_sandbox;																-- true when using sandbox modules to render citation


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if utilities.is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a Boolean declared in page scope variables above

]]

local function add_vanc_error (source, position)
	if added_vanc_errs then return end
		
	added_vanc_errs = true;														-- note that we've added this category
	utilities.set_message ('err_vancouver', {source, position});
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a URI scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of TLDs: https://www.iana.org/domains/root/db

RFC 952 (modified by RFC 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the TLD.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a URL with a scheme) will be stripped
here.  Perhaps not necessary but retained in case it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ASCII characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the TLD) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and TLD or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%w]') then											-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at Wikisource
		return false;
	end

	local patterns = {															-- patterns that look like URLs
		'%f[%w][%w][%w%-]+[%w]%.%a%a+$',										-- three or more character hostname.hostname or hostname.tld
		'%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$',									-- internationalized domain name with ACE prefix
		'%f[%a][qxz]%.com$',													-- assigned one character .com hostname (x.com times out 2015-12-10)
		'%f[%a][iq]%.net$',														-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		'%f[%w][%w]%.%a%a$',													-- one character hostname and ccTLD (2 chars)
		'%f[%w][%w][%w]%.%a%a+$',												-- two character hostname and TLD
		'^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?',								-- IPv4 address
		}

	for _, pattern in ipairs (patterns) do										-- loop through the patterns list
		if domain:match (pattern) then
			return true;														-- if a match then we think that this thing that purports to be a URL is a URL
		end
	end

	for _, d in ipairs (cfg.single_letter_2nd_lvl_domains_t) do					-- look for single letter second level domain names for these top level domains
		if domain:match ('%f[%w][%w]%.' .. d) then
			return true
		end
	end
	return false;																-- no matches, we don't know what this thing is
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a URL appear to be a valid URL; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if utilities.is_set (scheme) then											-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when URL is protocol-relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a URL into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following TLD) (if any) and any path(/), query(?) or fragment(#).

If protocol-relative URL, return nil scheme and domain else return nil for both scheme and domain.

When not protocol-relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Any URL that does not have news: scheme must have authority indicator (//).  TODO: are there other common schemes
like news: that don't use authority indicator?

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol-relative URL
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		if utilities.is_set (authority) then
			authority = authority:gsub ('//', '', 1);							-- replace place 1 pair of '/' with nothing;
			if utilities.is_set(authority) then									-- if anything left (1 or 3+ '/' where authority should be) then
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		else
			if not scheme:match ('^news:') then									-- except for news:..., MediaWiki won't link URLs that do not have authority indicator; TODO: a better way to do this test?
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link=, etc. for properly formatted content: no wikilinks, no URLs

Link parameters are to hold the title of a Wikipedia article, so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki URLs and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid URL (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid URL (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then											-- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from URL; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid URL
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wiki-linked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

check &lt;link&gt; for inter-language interwiki-link prefix.  prefix must be a MediaWiki-recognized language
code and must begin with a colon.

]]

local function link_title_ok (link, lorig, title, torig)
	local orig;
	if utilities.is_set (link) then 											-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		elseif link:match ('^%a+:') then										-- if the link is what looks like an interwiki
			local prefix = link:match ('^(%a+):'):lower();						-- get the interwiki prefix

			if cfg.inter_wiki_map[prefix] then									-- if prefix is in the map, must have preceding colon
				orig = lorig;													-- flag as error
			end
		end
	end

	if utilities.is_set (orig) then
		link = '';																-- unset
		utilities.set_message ('err_bad_paramlink', orig);						-- URL or wikilink in |title= with |title-link=;
	end
	
	return link;																-- link if ok, empty string else
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the URL into scheme and domain
portions, or for protocol-relative (//example.com) URLs, just the domain.  Use is_url() to validate the two
portions of the URL.  If both are valid, or for protocol-relative if domain is valid, return true, else false.

Because it is different from a standard URL, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper URL
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from URL;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a URL.  The test will also find external wikilinks
that use protocol-relative URLs. Also finds bare URLs.

The frontier pattern prevents a match on interwiki-links which are similar to scheme:path URLs.  The tests that
find bracketed URLs are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext. wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol-relative ext. wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare URL with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol-relative bare URL: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a URL
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list, error_list)
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a URL add an error message
			table.insert (error_list, utilities.wrap_style ('parameter', k));
		end
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		utilities.set_message ('err_wikilink_in_url', {});
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link (URL, label, source, access)
	local err_msg = '';
	local domain;
	local path;
	local base_url;

	if not utilities.is_set (label) then
		label = URL;
		if utilities.is_set (source) then
			utilities.set_message ('err_bare_url_missing_title', {utilities.wrap_style ('parameter', source)});
		else
			error (cfg.messages[&quot;bare_url_no_origin&quot;]);							-- programmer error; valid parameter name does not have matching meta-parameter
		end			
	end
	if not check_url (URL) then
		utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)});
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the URL into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['['] = '%5b', [']'] = '%5d'});			-- replace '[' and ']' with their percent-encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat ({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wiki-markup URL

	if utilities.is_set (access) then											-- access level (subscription, registration, limited)
		base_url = utilities.substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end

	return base_url;
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a Boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		utilities.set_message ('err_deprecated_params', {name});				-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wiki-markup) are not kerned.

Replaces Unicode quote marks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc.; not for book titles.

]=]

local function kern_quotes (str)
	local cap = '';
	local wl_type, label, link;

	wl_type, label, link = utilities.is_wikilink (str);							-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-left'], str);
			str = utilities.substitute (cfg.presentation['kern-right'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = utilities.substitute (cfg.presentation['kern-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label = mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label = mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap = mw.ustring.match (label, &quot;^([\&quot;\'][^\'].+)&quot;);						-- match leading double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-left'], cap);
		end
	
		cap = mw.ustring.match (label, &quot;^(.+[^\'][\&quot;\'])$&quot;)						-- match trailing double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-right'], cap);
		end
		
		if 2 == wl_type then
			str = utilities.make_wikilink (link, label);						-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin-based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate RTL languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO 639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO 639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title=, |script-chapter=, |script-&lt;periodical&gt;=

]]

local function format_script_value (script_value, script_param)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%l?%s*:') then									-- if first 3 or 4 non-space characters are script language prefix
		lang = script_value:match('^(%l%l%l?)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not utilities.is_set (lang) then
			utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['missing title part']});		-- prefix without 'title'; add error message
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_tag_remap[lang] or mw.language.fetchLanguageName( lang, cfg.this_wiki_code );	-- get language name so that we can use it to categorize
		if utilities.is_set (name) then											-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l+%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if utilities.in_array (lang, cfg.script_lang_codes) then
				utilities.add_prop_cat ('script', {name, lang})
			else
				utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['unknown language code']});	-- unknown script-language; add error message
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['invalid language code']});		-- invalid language code; add error message
			lang = '';															-- invalid so set lang to empty string
		end
	else
		utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['missing prefix']});				-- no language code prefix; add error message
	end
	script_value = utilities.substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is RTL

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script
value has been wrapped in &lt;bdi&gt; tags.

]]

local function script_concatenate (title, script, script_param)
	if utilities.is_set (script) then
		script = format_script_value (script, script_param);					-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; returns empty string on error
		if utilities.is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not utilities.is_set ( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return utilities.substitute ( msg, str );								-- including template text
	else
		return utilities.substitute ( cfg.messages[key], str );
	end		
end


--[[----------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;-------------------

Makes a Wikisource URL from Wikisource interwiki-link.  Returns the URL and appropriate
label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;
	local wikisource_prefix = table.concat ({'https://', cfg.this_wiki_code, '.wikisource.org/wiki/'});

	wl_type, D, L = utilities.is_wikilink (str);								-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 1 == wl_type then													-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end

	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable URL
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent-encoding of fragment marker
	end

	return ws_url, ws_label, L or D;											-- return proper URL or nil and a label or nil
end


--[[----------------&lt; F O R M A T _ P E R I O D I C A L &gt;-----------------------

Format the three periodical parameters: |script-&lt;periodical&gt;=, |&lt;periodical&gt;=,
and |trans-&lt;periodical&gt;= into a single Periodical meta-parameter.

]]

local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)

	if not utilities.is_set (periodical) then
		periodical = '';														-- to be safe for concatenation
	else
		periodical = utilities.wrap_style ('italic-title', periodical);			-- style 
	end

	periodical = script_concatenate (periodical, script_periodical, script_periodical_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (trans_periodical) then
		trans_periodical = utilities.wrap_style ('trans-italic-title', trans_periodical);
		if utilities.is_set (periodical) then
			periodical = periodical .. ' ' .. trans_periodical;
		else																	-- here when trans-periodical without periodical or script-periodical
			periodical = trans_periodical;
			utilities.set_message ('err_trans_missing_title', {'periodical'});
		end
	end

	return periodical;
end


--[[------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;---------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=,
and |chapter-url= into a single chapter meta- parameter (chapter_url_source used
for error messages).

]]

local function format_chapter_title (script_chapter, script_chapter_source, chapter, chapter_source, trans_chapter, trans_chapter_source, chapter_url, chapter_url_source, no_quotes, access)
	local ws_url, ws_label, L = wikisource_url_make (chapter);					-- make a wikisource URL and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', ' ');									-- replace underscore separators with space characters
		chapter = ws_label;
	end

	if not utilities.is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from module provided quote marks
			chapter = utilities.wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, script_chapter, script_chapter_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (chapter_url) then
		chapter = external_link (chapter_url, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');	-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if utilities.is_set (trans_chapter) then
		trans_chapter = utilities.wrap_style ('trans-quoted-title', trans_chapter);
		if utilities.is_set (chapter) then
			chapter = chapter .. ' ' .. trans_chapter;
		else																	-- here when trans_chapter without chapter or script-chapter
			chapter = trans_chapter;
			chapter_source = trans_chapter_source:match ('trans%-?(.+)');		-- when no chapter, get matching name from trans-&lt;param&gt;
			utilities.set_message ('err_trans_missing_title', {chapter_source});
		end
	end

	return chapter;
end


--[[----------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;-------------------

This function searches a parameter's value for non-printable or invisible characters.
The search stops at the first match.

This function will detect the visible replacement character when it is part of the Wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers
(gallery, math, pre, ref) and identifies them with a slightly different error message.
See also coins_cleanup().

Output of this function is an error message that identifies the character or the
Unicode group, or the stripmarker that was detected along with its position (or,
for multi-byte characters, the position of its first byte) in the parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local stripmarker;															-- boolean set true when a stripmarker is found

	capture = string.match (v, '[%w%p ]*');										-- test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no Unicode characters
		return;
	end

	for _, invisible_char in ipairs (cfg.invisible_chars) do
		local char_name = invisible_char[1];									-- the character or group name
		local pattern = invisible_char[2];										-- the pattern used to find it
		position, _, capture = mw.ustring.find (v, pattern);					-- see if the parameter value contains characters that match the pattern
		
		if position and (cfg.invisible_defs.zwj == capture) then				-- if we found a zero-width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- it's ok if one of the Indic scripts
				position = nil;													-- unset position
			elseif cfg.emoji_t[mw.ustring.codepoint (v, position+1)] then			-- is zwj followed by a character listed in emoji{}?
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and utilities.in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and cfg.invisible_defs.del == capture then	-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture and not (cfg.invisible_defs.del == capture or cfg.invisible_defs.zwj == capture) then
					err_msg = capture .. ' ' .. char_name;
				else
					err_msg = char_name .. ' ' .. 'character';
				end

				utilities.set_message ('err_invisible_char', {err_msg, utilities.wrap_style ('parameter', param), position});	-- add error message
				return;															-- and done with this parameter
			end
		end
	end
end


--[[-------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------

Argument wrapper.  This function provides support for argument mapping defined
in the configuration file so that multiple names can be transparently aliased to
single internal variable.

]]

local function argument_wrapper ( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function ( self, k )
			local dummy = self[k];												-- force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = utilities.select_one ( args, list, 'err_redundant_parameters' );
				if origin[k] == nil then
					origin[k] = '';												-- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] .. ': ' .. k);
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;-------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.
When date is DD MMMM YYYY or is MMMM DD, YYYY then wrap in nowrap span:
&lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap = '';
	local cap2 = '';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = utilities.substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = utilities.substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;---------------------

This function sets default title types (equivalent to the citation including
|type=&lt;default value&gt;) for those templates that have defaults. Also handles the
special case where it is desirable to omit the title type from the rendered citation
(|type=none).

]]

local function set_titletype (cite_class, title_type)
	if utilities.is_set (title_type) then
		if 'none' == cfg.keywords_xlate[title_type] then
			title_type = '';													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; S A F E _ J O I N &gt;-----------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'duplicate character'
		if 1 == #duplicate_char then											-- for single byte ASCII characters use the string library functions
			f.gsub = string.gsub
			f.match = string.match
			f.sub = string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub = mw.ustring.gsub
			f.match = mw.ustring.match
			f.sub = mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1, 1) == '&lt;' then										-- special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove HTML markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1, 1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc.?
				trim = false;
				end_chr = f.sub(str, -1, -1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr .. &quot;)&quot;				-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1, -2);									-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;''&quot; then		-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5, -1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;]]&quot; then		-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3, -1) == duplicate_char .. '&quot;]' then	-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2, -1) == duplicate_char .. &quot;]&quot; then	-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2, -1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1, -3);								-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains HTML markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows HTML markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value; 												-- add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;-----------------------------

returns true if suffix is properly formed Jr, Sr, or ordinal in the range 1–9.
Puncutation not allowed.

]]

local function is_suffix (suffix)
	if utilities.in_array (suffix, {'Jr', 'Sr', 'Jnr', 'Snr', '1st', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;-------------------

For Vancouver style, author/editor names are supposed to be rendered in Latin
(read ASCII) characters.  When a name uses characters that contain diacritical
marks, those characters are to be converted to the corresponding Latin
character. When a name is written using a non-Latin alphabet or logogram, that
name is to be transliterated into Latin characters. The module doesn't do this
so editors may/must.

This test allows |first= and |last= names to contain any of the letters defined
in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes.
	(http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;)
	or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written outside of the code editor and pasted here because the code editor
gets confused between character insertion point and cursor position. The test has
been rewritten to use decimal character escape sequence for the individual bytes
of the Unicode characters so that it is not necessary to use an external editor
to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first, suffix, position)
	if not suffix then
		if first:find ('[,%s]') then											-- when there is a space or comma, might be first name/initials + generational suffix
			first = first:match ('(.-)[,%s]+');									-- get name/initials
			suffix = first:match ('[,%s]+(.+)$');								-- get generational suffix
		end
	end
	if utilities.is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error (cfg.err_msg_supl.suffix, position);
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143\225\184\128-\225\187\191%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143\225\184\128-\225\187\191%-%s%'%.]*$&quot;) then
			add_vanc_error (cfg.err_msg_supl['non-Latin char'], position);
			return false;														-- not a string of Latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-style=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period.
See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc.) to be rendered
as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format
because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the
Unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials (first, position)
	if first:find (',', 1, true) then
		return first;															-- commas not allowed; abandon
	end

	local name, suffix = mw.ustring.match (first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match (first, &quot;^(%u+)$&quot;);								-- is it just initials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error (cfg.err_msg_supl.suffix, position);			-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word

	local initials_t, names_t = {}, {};											-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names_t = mw.text.split (first, '[%s%-]+');									-- split into a sequence of names and possible suffix

	while names_t[i] do															-- loop through the sequence
		if 1 &lt; i and names_t[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names_t[i] = names_t[i]:gsub ('%.', '');							-- remove terminal dot if present
			if is_suffix (names_t[i]) then										-- if a legitimate suffix
				table.insert (initials_t, ' ' .. names_t[i]);					-- add a separator space, insert at end of initials sequence
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials_t, mw.ustring.sub (names_t[i], 1, 1));		-- insert the initial at end of initials sequence
		end
		i = i + 1;																-- bump the counter
	end
			
	return table.concat (initials_t);											-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; I N T E R W I K I _ P R E F I X E N _ G E T &gt;----------------------------------

extract interwiki prefixen from &lt;value&gt;.  Returns two one or two values:
	false – no prefixen
	nil – prefix exists but not recognized
	project prefix, language prefix – when value has either of:
		:&lt;project&gt;:&lt;language&gt;:&lt;article&gt;
		:&lt;language&gt;:&lt;project&gt;:&lt;article&gt;
	project prefix, nil – when &lt;value&gt; has only a known single-letter prefix
	nil, language prefix – when &lt;value&gt; has only a known language prefix

accepts single-letter project prefixen: 'd' (wikidata), 's' (wikisource), and 'w' (wikipedia) prefixes; at this
writing, the other single-letter prefixen (b (wikibook), c (commons), m (meta), n (wikinews), q (wikiquote), and
v (wikiversity)) are not supported.

]]

local function interwiki_prefixen_get (value, is_link)
	if not value:find (':%l+:') then											-- if no prefix
		return false;															-- abandon; boolean here to distinguish from nil fail returns later
	end

	local prefix_patterns_linked_t = {											-- sequence of valid interwiki and inter project prefixen
		'^%[%[:([dsw]):(%l%l+):',												-- wikilinked; project and language prefixes
		'^%[%[:(%l%l+):([dsw]):',												-- wikilinked; language and project prefixes
		'^%[%[:([dsw]):',														-- wikilinked; project prefix
		'^%[%[:(%l%l+):',														-- wikilinked; language prefix
		}
		
	local prefix_patterns_unlinked_t = {										-- sequence of valid interwiki and inter project prefixen
		'^:([dsw]):(%l%l+):',													-- project and language prefixes
		'^:(%l%l+):([dsw]):',													-- language and project prefixes
		'^:([dsw]):',															-- project prefix
		'^:(%l%l+):',															-- language prefix
		}
	
	local cap1, cap2;
	for _, pattern in ipairs ((is_link and prefix_patterns_linked_t) or prefix_patterns_unlinked_t) do
		cap1, cap2 = value:match (pattern);
		if cap1 then
			break;																-- found a match so stop looking
		end
	end
	
	if cap1 and cap2 then														-- when both then :project:language: or :language:project: (both forms allowed)
		if 1 == #cap1 then														-- length == 1 then :project:language:
			if cfg.inter_wiki_map[cap2] then									-- is language prefix in the interwiki map?
				return cap1, cap2;												-- return interwiki project and interwiki language
			end
		else																	-- here when :language:project:
			if cfg.inter_wiki_map[cap1] then									-- is language prefix in the interwiki map?
				return cap2, cap1;												-- return interwiki project and interwiki language
			end
		end
		return nil;																-- unknown interwiki language
	elseif not (cap1 or cap2) then												-- both are nil?
		return nil;																-- we got something that looks like a project prefix but isn't; return fail
	elseif 1 == #cap1 then														-- here when one capture
		return cap1, nil;														-- length is 1 so return project, nil language
	else																		-- here when one capture and its length it more than 1
		if cfg.inter_wiki_map[cap1] then										-- is language prefix in the interwiki map?
			return nil, cap1;													-- return nil project, language
		end
	end
end


--[[--------------------------&lt; L I S T _ P E O P L E &gt;--------------------------

Formats a list of people (authors, contributors, editors, interviewers, translators) 

names in the list will be linked when
	|&lt;name&gt;-link= has a value
	|&lt;name&gt;-mask- does NOT have a value; masked names are presumed to have been
		rendered previously so should have been linked there

when |&lt;name&gt;-mask=0, the associated name is not rendered

]]

local function list_people (control, people, etal)
	local sep;
	local namesep;
	local format = control.format;
	local maximum = control.maximum;
	local name_list = {};

	if 'vanc' == format then													-- Vancouver-like name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between names is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between names is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub (-1, -1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if utilities.is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end		-- returned 0 is for EditorCount; not used for other names
	
	for i, person in ipairs (people) do
		if utilities.is_set (person.last) then
			local mask = person.mask;
			local one;
			local sep_one = sep;

			if utilities.is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			end
			
			if mask then
				local n = tonumber (mask);										-- convert to a number if it can be converted; nil else
				if n then
					one = 0 ~= n and string.rep(&quot;&amp;mdash;&quot;, n) or nil;			-- make a string of (n &gt; 0) mdashes, nil else, to replace name
					person.link = nil;											-- don't create link to name if name is replaces with mdash string or has been set nil
				else
					one = mask;													-- replace name with mask text (must include name-list separator)
					sep_one = &quot; &quot;;												-- modify name-list separator
				end
			else
				one = person.last;												-- get surname
				local first = person.first										-- get given name
				if utilities.is_set (first) then
					if (&quot;vanc&quot; == format) then									-- if Vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first, nil, i) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials (first, i);				-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
			end
			if utilities.is_set (person.link) then
				one = utilities.make_wikilink (person.link, one);				-- link author/editor
			end

			if one then															-- if &lt;one&gt; has a value (name, mdash replacement, or mask text replacement)
				local proj, tag = interwiki_prefixen_get (one, true);			-- get the interwiki prefixen if present
				if 'w' == proj and ('Wikipedia' == mw.site.namespaces.Project['name']) then
					proj = nil;													-- for stuff like :w:de:&lt;article&gt;, :w is unnecessary TODO: maint cat?
				end
				if proj then
					local proj_name = ({['d'] = 'Wikidata', ['s'] = 'Wikisource', ['w'] = 'Wikipedia'})[proj];	-- :w (wikipedia) for linking from a non-wikipedia project
					if proj_name then 
						one = one .. utilities.wrap_style ('interproj', proj_name);	-- add resized leading space, brackets, static text, language name
						utilities.add_prop_cat ('interproj-linked-name', proj);	-- categorize it; &lt;proj&gt; is sort key
						tag = nil;												-- unset; don't do both project and language
					end
				end
				if tag == cfg.this_wiki_code then
					tag = nil;													-- stuff like :en:&lt;article&gt; at en.wiki is pointless TODO: maint cat?
				end
				if tag then
					local lang = cfg.lang_tag_remap[tag] or cfg.mw_languages_by_tag_t[tag];
					if lang then												-- error messaging done in extract_names() where we know parameter names
						one = one .. utilities.wrap_style ('interwiki', lang);	-- add resized leading space, brackets, static text, language name
						utilities.add_prop_cat ('interwiki-linked-name', tag);	-- categorize it; &lt;tag&gt; is sort key
					end
				end

				table.insert (name_list, one);									-- add it to the list of names
				table.insert (name_list, sep_one);								-- add the proper name-list separator
			end
		end
	end

	local count = #name_list / 2;												-- (number of names + number of separators) divided by 2
	if 0 &lt; count then 
		if 1 &lt; count and not etal then
			if 'amp' == format then
				name_list[#name_list-2] = &quot; &amp; &quot;;								-- replace last separator with ampersand text
			elseif 'and' == format then
				if 2 == count then
					name_list[#name_list-2] = cfg.presentation.sep_nl_and;		-- replace last separator with 'and' text
				else
					name_list[#name_list-2] = cfg.presentation.sep_nl_end;		-- replace last separator with '(sep) and' text
				end
			end
		end
		name_list[#name_list] = nil;											-- erase the last separator
	end

	local result = table.concat (name_list);									-- construct list
	if etal and utilities.is_set (result) then									-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. cfg.messages['et al'];						-- we've got a last-first list and etal so add et al.
	end
	
	return result, count;														-- return name-list string and count of number of names (count used for editor names only)
end


--[[--------------------&lt; M A K E _ C I T E R E F _ I D &gt;-----------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise
returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that
order.  year is Year or anchor_year.

]]

local function make_citeref_id (namelist, year)
	local names={};							-- a table for the one to four names and year
	for i,v in ipairs (namelist) do			-- loop through the list and take up to the first four last names
		names[i] = v.last
		if i == 4 then break end			-- if four then done
	end
	table.insert (names, year);				-- add the year at the end
	local id = table.concat(names);			-- concatenate names and year for CITEREF id
	if utilities.is_set (id) then			-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;				-- add the CITEREF portion
	else
		return '';							-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; C I T E _ C L A S S _A T T R I B U T E _M A K E &gt;------------------------------

construct &lt;cite&gt; tag class attribute for this citation.

&lt;cite_class&gt; – config.CitationClass from calling template
&lt;mode&gt; – value from |mode= parameter

]]

local function cite_class_attribute_make (cite_class, mode)
	local class_t = {};
	table.insert (class_t, 'citation');											-- required for blue highlight
	if 'citation' ~= cite_class then
		table.insert (class_t, cite_class);										-- identify this template for user css
		table.insert (class_t, utilities.is_set (mode) and mode or 'cs1');		-- identify the citation style for user css or javascript
	else
		table.insert (class_t, utilities.is_set (mode) and mode or 'cs2');		-- identify the citation style for user css or javascript
	end
	for _, prop_key in ipairs (z.prop_keys_t) do
		table.insert (class_t, prop_key);										-- identify various properties for user css or javascript
	end

	return table.concat (class_t, ' ');											-- make a big string and done
end


--[[---------------------&lt; N A M E _ H A S _ E T A L &gt;--------------------------

Evaluates the content of name parameters (author, editor, etc.) for variations on
the theme of et al.  If found, the et al. is removed, a flag is set to true and
the function returns the modified name and the flag.

This function never sets the flag to false but returns its previous state because
it may have been set by previous passes through this function or by the associated
|display-&lt;names&gt;=etal parameter

]]

local function name_has_etal (name, etal, nocat, param)

	if utilities.is_set (name) then												-- name can be nil in which case just return
		local patterns = cfg.et_al_patterns; 									-- get patterns from configuration
		
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns
			if name:match (pattern) then										-- if this 'et al' pattern is found in name
				name = name:gsub (pattern, '');									-- remove the offending text
				etal = true;													-- set flag (may have been set previously here or by |display-&lt;names&gt;=etal)
				if not nocat then												-- no categorization for |vauthors=
					utilities.set_message ('err_etal', {param});				-- and set an error if not added
				end
			end
		end
	end

	return name, etal;
end


--[[---------------------&lt; N A M E _ I S _ N U M E R I C &gt;----------------------

Add an error message and category when &lt;name&gt; parameter value does not contain letters.  

Add a maintenance category when &lt;name&gt; parameter value has numeric characters mixed with characters that are 
not numeric characters; could be letters and/or punctuation characters.

This function will only emit one error and one maint message for the current template.  Does not emit both error
and maint messages/categories for the same parameter value.

returns nothing

]]

local function name_is_numeric (name, name_alias, list_name)
	local patterns = {
		'^%D+%d',																-- &lt;name&gt; must have digits preceded by other characters
		'^%D*%d+%D+',															-- &lt;name&gt; must have digits followed by other characters
		}

	if not added_numeric_name_errs and mw.ustring.match (name, '^[%A]+$') then	-- if we have not already set an error message and &lt;name&gt; does not have any alpha characters
		utilities.set_message ('err_numeric_names', name_alias);				-- add an error message
		added_numeric_name_errs = true;											-- set the flag so we emit only one error message
		return;																	-- when here no point in further testing; abandon
	end

	if not added_numeric_name_maint then										-- if we have already set a maint message
		for _, pattern in ipairs (patterns) do									-- spin through list of patterns
			if mw.ustring.match (name, pattern) then							-- digits preceded or followed by anything but digits; %D+ includes punctuation
				utilities.set_message ('maint_numeric_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
				added_numeric_name_maint = true;								-- set the flag so we emit only one maint message
				return;															-- when here no point in further testing; abandon
			end
		end
	end
end


--[[-----------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;------------------

Evaluates the content of last/surname (authors etc.) parameters for multiple names.
Multiple names are indicated if there is more than one comma or any &quot;unescaped&quot;
semicolons. Escaped semicolons are ones used as part of selected HTML entities.
If the condition is met, the function adds the multiple name maintenance category.

Same test for first except that commas should not appear in given names (MOS:JR says
that the generational suffix does not take a separator character).  Titles, degrees,
postnominals, affiliations, all normally comma separated don't belong in a citation.

&lt;name&gt; – name parameter value
&lt;list_name&gt; – AuthorList, EditorList, etc
&lt;limit&gt; – number of allowed commas; 1 (default) for surnames; 0 for given names

returns nothing

]]

local function name_has_mult_names (name, list_name, limit)
	local _, commas, semicolons, nbsps;
	limit = limit and limit or 1;
	if utilities.is_set (name) then
		_, commas = name:gsub (',', '');										-- count the number of commas
		_, semicolons = name:gsub (';', '');									-- count the number of semicolons
		-- nbsps probably should be its own separate count rather than merged in
		-- some way with semicolons because Lua patterns do not support the
		-- grouping operator that regex does, which means there is no way to add
		-- more entities to escape except by adding more counts with the new
		-- entities
		_, nbsps = name:gsub ('&amp;nbsp;','');										-- count nbsps
		
		-- There is exactly 1 semicolon per &amp;nbsp; entity, so subtract nbsps
		-- from semicolons to 'escape' them. If additional entities are added,
		-- they also can be subtracted.
		if limit &lt; commas or 0 &lt; (semicolons - nbsps) then
			utilities.set_message ('maint_mult_names', cfg.special_case_translation [list_name]);	-- add a maint message
		end
	end
end


--[=[-------------------------&lt; I S _ G E N E R I C &gt;----------------------------------------------------------

Compares values assigned to various parameters according to the string provided as &lt;item&gt; in the function call.
&lt;item&gt; can have on of two values:
	'generic_names' – for name-holding parameters: |last=, |first=, |editor-last=, etc
	'generic_titles' – for |title=

There are two types of generic tests.  The 'accept' tests look for a pattern that should not be rejected by the
'reject' test.  For example,
	|author=[[John Smith (author)|Smith, John]]
would be rejected by the 'author' reject test.  But piped wikilinks with 'author' disambiguation should not be
rejected so the 'accept' test prevents that from happening.  Accept tests are always performed before reject
tests.

Each of the 'accept' and 'reject' sequence tables hold tables for en.wiki (['en']) and local.wiki (['local'])
that each can hold a test sequence table  The sequence table holds, at index [1], a test pattern, and, at index
[2], a boolean control value.  The control value tells string.find() or mw.ustring.find() to do plain-text search (true)
or a pattern search (false).  The intent of all this complexity is to make these searches as fast as possible so
that we don't run out of processing time on very large articles.

Returns
	true when a reject test finds the pattern or string
	false when an accept test finds the pattern or string
	nil else

]=]

local function is_generic (item, value, wiki)
	local test_val;
	local str_lower = {															-- use string.lower() for en.wiki (['en']) and use mw.ustring.lower() or local.wiki (['local'])
		['en'] = string.lower,
		['local'] = mw.ustring.lower,
		}
	local str_find = {															-- use string.find() for en.wiki (['en']) and use mw.ustring.find() or local.wiki (['local'])
		['en'] = string.find,
		['local'] = mw.ustring.find,
		}

	local function test (val, test_t, wiki)										-- local function to do the testing; &lt;wiki&gt; selects lower() and find() functions
		val = test_t[2] and str_lower[wiki](value) or val;						-- when &lt;test_t[2]&gt; set to 'true', plaintext search using lowercase value
		return str_find[wiki] (val, test_t[1], 1, test_t[2]);					-- return nil when not found or matched
	end
		
	local test_types_t = {'accept', 'reject'};									-- test accept patterns first, then reject patterns
	local wikis_t = {'en', 'local'};											-- do tests for each of these keys; en.wiki first, local.wiki second

	for _, test_type in ipairs (test_types_t) do								-- for each test type
		for _, generic_value in pairs (cfg.special_case_translation[item][test_type]) do	-- spin through the list of generic value fragments to accept or reject
			for _, wiki in ipairs (wikis_t) do
				if generic_value[wiki] then
					if test (value, generic_value[wiki], wiki) then				-- go do the test
						return ('reject' == test_type);							-- param value rejected, return true; false else
					end
				end
			end
		end
	end
end


--[[--------------------------&lt; N A M E _ I S _ G E N E R I C &gt;------------------------------------------------

calls is_generic() to determine if &lt;name&gt; is a 'generic name' listed in cfg.generic_names; &lt;name_alias&gt; is the
parameter name used in error messaging

]]

local function name_is_generic (name, name_alias)
	if not added_generic_name_errs  and is_generic ('generic_names', name) then
		utilities.set_message ('err_generic_name', name_alias);					-- set an error message
		added_generic_name_errs = true;
	end
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------

This function calls various name checking functions used to validate the content of the various name-holding parameters.

]]

local function name_checks (last, first, list_name, last_alias, first_alias)
	local accept_name;

	if utilities.is_set (last) then
		last, accept_name = utilities.has_accept_as_written (last);				-- remove accept-this-as-written markup when it wraps all of &lt;last&gt;

		if not accept_name then													-- &lt;last&gt; not wrapped in accept-as-written markup
			name_has_mult_names (last, list_name);								-- check for multiple names in the parameter
			name_is_numeric (last, last_alias, list_name);						-- check for names that have no letters or are a mix of digits and other characters
			name_is_generic (last, last_alias);									-- check for names found in the generic names list
		end
	end

	if utilities.is_set (first) then
		first, accept_name = utilities.has_accept_as_written (first);			-- remove accept-this-as-written markup when it wraps all of &lt;first&gt;

		if not accept_name then													-- &lt;first&gt; not wrapped in accept-as-written markup
			name_has_mult_names (first, list_name, 0);							-- check for multiple names in the parameter; 0 is number of allowed commas in a given name
			name_is_numeric (first, first_alias, list_name);					-- check for names that have no letters or are a mix of digits and other characters
			name_is_generic (first, first_alias);								-- check for names found in the generic names list
		end
		local wl_type, D = utilities.is_wikilink (first);
		if 0 ~= wl_type then
			first = D;
			utilities.set_message ('err_bad_paramlink', first_alias);
		end
	end

	return last, first;															-- done
end


--[[----------------------&lt; E X T R A C T _ N A M E S &gt;-------------------------

Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters
(or their aliases), and their matching link and mask parameters. Stops searching
when both |lastn= and |firstn= are not found in args after two sequential attempts:
found |last1=, |last2=, and |last3= but doesn't find |last4= and |last5= then the
search is done.

This function emits an error message when there is a |firstn= without a matching
|lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not
required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.'
is stripped from the parameter and a flag (etal) returned that will cause list_people()
to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps
'et al.' out of the template's metadata.  When this occurs, an error is emitted.

]]

local function extract_names(args, list_name)
	local names = {};															-- table of names
	local last;																	-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;																-- loop counter/indexer
	local n = 1;																-- output table indexer
	local count = 0;															-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal = false;															-- return value set to true when we find some form of et al. in an author parameter

	local last_alias, first_alias, link_alias;									-- selected parameter aliases used in error messaging
	while true do
		last, last_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'err_redundant_parameters', i );		-- search through args for name components beginning at 1
		first, first_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'err_redundant_parameters', i );
		link, link_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i );
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
	
		if last then															-- error check |lastn= alias for unknown interwiki link prefix; done here because this is where we have the parameter name
			local project, language = interwiki_prefixen_get (last, true);		-- true because we expect interwiki links in |lastn= to be wikilinked
			if nil == project and nil == language then							-- when both are nil
				utilities.set_message ('err_bad_paramlink', last_alias);		-- not known, emit an error message	-- TODO: err_bad_interwiki?
				last = utilities.remove_wiki_link (last);						-- remove wikilink markup; show display value only
			end
		end
		
		if link then															-- error check |linkn= alias for unknown interwiki link prefix
			local project, language = interwiki_prefixen_get (link, false);		-- false because wiki links in |author-linkn= is an error
			if nil == project and nil == language then							-- when both are nil
				utilities.set_message ('err_bad_paramlink', link_alias);		-- not known, emit an error message	-- TODO: err_bad_interwiki?
				link = nil;														-- unset so we don't link
				link_alias = nil;
			end
		end
		
		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.
		last, first = name_checks (last, first, list_name, last_alias, first_alias);						-- multiple names, extraneous annotation, etc. checks

		if first and not last then												-- if there is a firstn without a matching lastn
			local alias = first_alias:find ('given', 1, true) and 'given' or 'first';	-- get first or given form of the alias
			utilities.set_message ('err_first_missing_last', {
				first_alias,													-- param name of alias missing its mate
				first_alias:gsub (alias, {['first'] = 'last', ['given'] = 'surname'}),	-- make param name appropriate to the alias form
				});																-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			local result;
			link = link_title_ok (link, link_alias, last, last_alias);			-- check for improper wiki-markup

			if first then
				link = link_title_ok (link, link_alias, first, first_alias);	-- check for improper wiki-markup
			end

			names[n] = {last = last, first = first, link = link, mask = mask, corporate = false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				utilities.set_message ('err_missing_name', {list_name:match (&quot;(%w+)List&quot;):lower(), i - 1});	-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names and the etal flag
end


--[[--------------------------&lt; N A M E _ T A G _ G E T &gt;------------------------------------------------------

attempt to decode |language=&lt;lang_param&gt; and return language name and matching tag; nil else.

This function looks for:
	&lt;lang_param&gt; as a tag in cfg.lang_tag_remap{}
	&lt;lang_param&gt; as a name in cfg.lang_name_remap{}
	
	&lt;lang_param&gt; as a name in cfg.mw_languages_by_name_t
	&lt;lang_param&gt; as a tag in cfg.mw_languages_by_tag_t
when those fail, presume that &lt;lang_param&gt; is an IETF-like tag that MediaWiki does not recognize.  Strip all
script, region, variant, whatever subtags from &lt;lang_param&gt; to leave just a two or three character language tag
and look for the new &lt;lang_param&gt; in cfg.mw_languages_by_tag_t{}

on success, returns name (in properly capitalized form) and matching tag (in lowercase); on failure returns nil

]]

local function name_tag_get (lang_param)
	local lang_param_lc = mw.ustring.lower (lang_param);						-- use lowercase as an index into the various tables
	local name;
	local tag;

	name = cfg.lang_tag_remap[lang_param_lc];									-- assume &lt;lang_param_lc&gt; is a tag; attempt to get remapped language name 
	if name then																-- when &lt;name&gt;, &lt;lang_param&gt; is a tag for a remapped language name
		if cfg.lang_name_remap[name:lower()][2] ~= lang_param_lc then
			utilities.set_message ('maint_unknown_lang');						-- add maint category if not already added
			return name, cfg.lang_name_remap[name:lower()][2];					-- so return name and tag from lang_name_remap[name]; special case to xlate sr-ec and sr-el to sr-cyrl and sr-latn
		end
		return name, lang_param_lc;												-- so return &lt;name&gt; from remap and &lt;lang_param_lc&gt;
	end

	tag = lang_param_lc:match ('^(%a%a%a?)%-.*');								-- still assuming that &lt;lang_param_lc&gt; is a tag; strip script, region, variant subtags
	name = cfg.lang_tag_remap[tag];												-- attempt to get remapped language name with language subtag only
	if name then																-- when &lt;name&gt;, &lt;tag&gt; is a tag for a remapped language name
		return name, tag;														-- so return &lt;name&gt; from remap and &lt;tag&gt;
	end

	if cfg.lang_name_remap[lang_param_lc] then									-- not a remapped tag, assume &lt;lang_param_lc&gt; is a name; attempt to get remapped language tag 
		return cfg.lang_name_remap[lang_param_lc][1], cfg.lang_name_remap[lang_param_lc][2];	-- for this &lt;lang_param_lc&gt;, return a (possibly) new name and appropriate tag
	end

	name = cfg.mw_languages_by_tag_t[lang_param_lc];							-- assume that &lt;lang_param_lc&gt; is a tag; attempt to get its matching language name
	
	if name then
		return name, lang_param_lc;												-- &lt;lang_param_lc&gt; is a tag so return it and &lt;name&gt;
	end
	
	tag = cfg.mw_languages_by_name_t[lang_param_lc];							-- assume that &lt;lang_param_lc&gt; is a language name; attempt to get its matching tag
	
	if tag then
		return cfg.mw_languages_by_tag_t[tag], tag;								-- &lt;lang_param_lc&gt; is a name so return the name from the table and &lt;tag&gt;
	end

	tag = lang_param_lc:match ('^(%a%a%a?)%-.*');								-- is &lt;lang_param_lc&gt; an IETF-like tag that MediaWiki doesn't recognize? &lt;tag&gt; gets the language subtag; nil else

	if tag then
		name = cfg.mw_languages_by_tag_t[tag];									-- attempt to get a language name using the shortened &lt;tag&gt;
		if name then
			return name, tag;													-- &lt;lang_param_lc&gt; is an unrecognized IETF-like tag so return &lt;name&gt; and language subtag
		end
	end
end


--[[-------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code
is recognized by MediaWiki, use the returned name; if not, then use the value that
was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is
assigned to the category for that code: Category:Norwegian-language sources (no).
For valid three-character code languages, the page is assigned to the single category
for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does
not recognize three-character equivalents of two-character codes: code 'ar' is
recognized but code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th
where the language names or codes are separated from each other by commas with
optional space characters.

]]

local function language_parameter (lang)
	local tag;																	-- some form of IETF-like language tag; language subtag with optional region, sript, vatiant, etc subtags
	local lang_subtag;															-- ve populates |language= with mostly unecessary region subtags the MediaWiki does not recognize; this is the base language subtag
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_t = {};															-- table made from the value assigned to |language=

	local this_wiki_name = mw.language.fetchLanguageName (cfg.this_wiki_code, cfg.this_wiki_code);	-- get this wiki's language name

	names_t = mw.text.split (lang, '%s*,%s*');									-- names should be a comma separated list

	for _, lang in ipairs (names_t) do											-- reuse lang here because we don't yet know if lang is a language name or a language tag
		name, tag = name_tag_get (lang);										-- attempt to get name/tag pair for &lt;lang&gt;; &lt;name&gt; has proper capitalization; &lt;tag&gt; is lowercase

		if utilities.is_set (tag) then
			lang_subtag = tag:gsub ('^(%a%a%a?)%-.*', '%1');					-- for categorization, strip any IETF-like tags from language tag

			if cfg.this_wiki_code ~= lang_subtag then							-- when the language is not the same as this wiki's language
				if 2 == lang_subtag:len() then									-- and is a two-character tag
					utilities.add_prop_cat ('foreign-lang-source', {name, tag}, lang_subtag);		-- categorize it; tag appended to allow for multiple language categorization
				else															-- or is a recognized language (but has a three-character tag)
					utilities.add_prop_cat ('foreign-lang-source-2', {lang_subtag}, lang_subtag);			-- categorize it differently TODO: support multiple three-character tag categories per cs1|2 template?
				end
			elseif cfg.local_lang_cat_enable then								-- when the language and this wiki's language are the same and categorization is enabled
				utilities.add_prop_cat ('local-lang-source', {name, lang_subtag});		-- categorize it
			end
		else
			name = lang;														-- return whatever &lt;lang&gt; has so that we show something
			utilities.set_message ('maint_unknown_lang');						-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
 
	name = utilities.make_sep_list (#language_list, language_list);
	if (1 == #language_list) and (lang_subtag == cfg.this_wiki_code) then		-- when only one language, find lang name in this wiki lang name; for |language=en-us, 'English' in 'American English'
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[-----------------------&lt; S E T _ C S _ S T Y L E &gt;--------------------------

Gets the default CS style configuration for the given mode.
Returns default separator and either postscript as passed in or the default.
In CS1, the default postscript and separator are '.'.
In CS2, the default postscript is the empty string and the default separator is ','.

]]

local function set_cs_style (postscript, mode)
	if utilities.is_set(postscript) then
		-- emit a maintenance message if user postscript is the default cs1 postscript
		-- we catch the opposite case for cs2 in set_style
		if mode == 'cs1' and postscript == cfg.presentation['ps_' .. mode] then
			utilities.set_message ('maint_postscript');
		end
	else
		postscript = cfg.presentation['ps_' .. mode];
	end
	return cfg.presentation['sep_' .. mode], postscript;
end


--[[--------------------------&lt; S E T _ S T Y L E &gt;-----------------------------

Sets the separator and postscript styles. Checks the |mode= first and the
#invoke CitationClass second. Removes the postscript if postscript == none.

]]

local function set_style (mode, postscript, cite_class)
	local sep;
	if 'cs2' == mode then
		sep, postscript = set_cs_style (postscript, 'cs2');
	elseif 'cs1' == mode then
		sep, postscript = set_cs_style (postscript, 'cs1');
	elseif 'citation' == cite_class	then
		sep, postscript = set_cs_style (postscript, 'cs2');
	else
		sep, postscript = set_cs_style (postscript, 'cs1');
	end

	if cfg.keywords_xlate[postscript:lower()] == 'none' then
		-- emit a maintenance message if user postscript is the default cs2 postscript
		-- we catch the opposite case for cs1 in set_cs_style
		if 'cs2' == mode or ('cs1' ~= mode and 'citation' == cite_class) then	-- {{citation |title=Title |mode=cs1 |postscript=none}} should not emit maint message
			utilities.set_message ('maint_postscript');
		end
		postscript = '';
	end
	
	return sep, postscript
end


--[=[-------------------------&lt; I S _ P D F &gt;-----------------------------------

Determines if a URL has the file extension that is one of the PDF file extensions
used by [[MediaWiki:Common.css]] when applying the PDF icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or
		url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
		url:match ('%.PDF&amp;#035') or url:match ('%.pdf&amp;#035');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;-----------------------

Applies CSS style to |format=, |chapter-format=, etc.  Also emits an error message
if the format parameter does not have a matching URL parameter.  If the format parameter
is not set and the URL contains a file extension that is recognized as a PDF document
by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if utilities.is_set (format) then
		format = utilities.wrap_style ('format', format);						-- add leading space, parentheses, resize
		if not utilities.is_set (url) then
			utilities.set_message ('err_format_missing_url', {fmt_param, url_param});	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if URL is a PDF file then
		format = utilities.wrap_style ('format', 'PDF');						-- set format to PDF
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[---------------------&lt; G E T _ D I S P L A Y _ N A M E S &gt;------------------

Returns a number that defines the number of names displayed for author and editor
name lists and a Boolean flag to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero,
return the number and the previous state of the 'etal' flag (false by default
but may have been set to true if the name list contains some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number
that is one greater than the number of authors in the list and set the 'etal' flag true.
This will cause the list_people() to display all of the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors'], etc; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

This function sets an error message when |display-xxxxors= value greater than or equal to number of names but
not when &lt;max&gt; comes from {{cs1 config}} global settings.  When using global settings, &lt;param&gt; is set to the
keyword 'cs1 config' which is used to supress the normal error.  Error is suppressed because it is to be expected
that some citations in an article will have the same or fewer names that the limit specified in {{cs1 config}}.

]]

local function get_display_names (max, count, list_name, etal, param)
	if utilities.is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if (max &gt;= count) and ('cs1 config' ~= param) then					-- error when local |display-xxxxors= value greater than or equal to number of names; not an error when using global setting
				utilities.set_message ('err_disp_name', {param, max});			-- add error message
				max = nil;
			end
		else																	-- not a valid keyword or number
			utilities.set_message ('err_disp_name', {param, max});				-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[----------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;---------------

Adds error if |page=, |pages=, |quote-page=, |quote-pages= has what appears to be
some form of p. or pp. abbreviation in the first characters of the parameter content.

check page for extraneous p, p., pp, pp., pg, pg. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when page begins PX or P# but not Px
		      where x and X are letters and # is a digit
	bad pattern:  '^[Pp][PpGg]' matches when page begins pp, pP, Pp, PP, pg, pG, Pg, PG

]]

local function extra_text_in_page_check (val, name)
	if not val:match (cfg.vol_iss_pg_patterns.good_ppattern) then
		for _, pattern in ipairs (cfg.vol_iss_pg_patterns.bad_ppatterns) do		-- spin through the selected sequence table of patterns
			if val:match (pattern) then											-- when a match, error so
				utilities.set_message ('err_extra_text_pages', name);	 		-- add error message
				return;															-- and done
			end
		end
	end		
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ V O L _ I S S _ C H E C K &gt;------------------------

Adds error if |volume= or |issue= has what appears to be some form of redundant 'type' indicator.  Applies to
both; this function looks for issue text in both |issue= and |volume= and looks for volume-like text in |voluem=
and |issue=.

For |volume=:
	'V.', or 'Vol.' (with or without the dot) abbreviations or 'Volume' in the first characters of the parameter
	content (all case insensitive). 'V' and 'v' (without the dot) are presumed to be roman numerals so
	are allowed.

For |issue=:
	'No.', 'I.', 'Iss.' (with or without the dot) abbreviations, or 'Issue' in the first characters of the
	parameter content (all case insensitive); numero styling: 'n°' with degree sign U+00B0, and № precomposed
	numero sign U+2116.
	
Single character values ('v', 'i', 'n') allowed when not followed by separator character ('.', ':', '=', or
whitespace character) – param values are trimmed of whitespace by MediaWiki before delivered to the module.
	
&lt;val&gt; is |volume= or |issue= parameter value
&lt;name&gt; is |volume= or |issue= parameter name for error message
&lt;selector&gt; is 'v' for |volume=, 'i' for |issue=

sets error message on failure; returns nothing

]]

local function extra_text_in_vol_iss_check (val, name, selector)
	if not utilities.is_set (val) then
		return;
	end
	
	local handler = 'v' == selector and 'err_extra_text_volume' or 'err_extra_text_issue';
	val = val:lower();															-- force parameter value to lower case

	for _, pattern in ipairs (cfg.vol_iss_pg_patterns.vi_patterns_t) do			-- spin through the sequence table of patterns
		if val:match (pattern) then												-- when a match, error so
			utilities.set_message (handler, name);								-- add error message
			return;																-- and done
		end
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parentheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a placeholder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parentheses
			local name = name_table[i];
			i = i + 1;															-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parentheses
					break;														-- and done reassembling so
				end
				i = i + 1;														-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = utilities.is_wikilink (name_table[i]);		-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i + 1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled parentheses ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the Vancouver error when a required comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		first = '';																-- set to empty string for concatenation and because it may have been set for previous author/editor
		local accept_name;
		v_name, accept_name = utilities.has_accept_as_written (v_name);			-- remove accept-this-as-written markup when it wraps all of &lt;v_name&gt;

		if accept_name then
			last = v_name;
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error (cfg.err_msg_supl.punctuation, i);
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s+&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be initials or generational suffix

			if not mw.ustring.match (first, '^%u+$') then						-- mw.ustring here so that later we will catch non-Latin characters
				suffix = first;													-- not initials so assume that whatever we got is a generational suffix
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end
			last = table.concat(lastfirstTable, ' ')							-- returns a string that is the concatenation of all other names that are not initials and generational suffix
			if not utilities.is_set (last) then
				first = '';														-- unset
				last = v_name;													-- last empty because something wrong with first
				add_vanc_error (cfg.err_msg_supl.name, i);
			end
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error (cfg.err_msg_supl['missing comma'], i);			-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- matches a space between two initials
			end
		else
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
		
		if utilities.is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first, suffix, i);							-- check first and last before restoring the suffix which may have a non-Latin digit
			if utilities.is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '', nil, i);
			end
		end

		link = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i ) or v_link_table[i];
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate = corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest;
|editorn= (and aliases) highest and |veditors= lowest (support for |editors= withdrawn)

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
	local lastfirst = false;
	if utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice in case we have a |first1= without a |last1=; this ...
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or		-- ... also catches the case where |first= is used with |vauthors=
		utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst = true;
	end

	if (utilities.is_set (vxxxxors) and true == lastfirst) or					-- these are the three error conditions
		(utilities.is_set (vxxxxors) and utilities.is_set (xxxxors)) or
		(true == lastfirst and utilities.is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			utilities.set_message ('err_redundant_parameters', err_name .. '-name-list parameters');	-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if utilities.is_set (vxxxxors) then return 2 end;
	if utilities.is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, live, dead, etc.).  When the parameter value has not been assigned a value (missing
or empty in the source template) the function returns the value specified by ret_val.  If the parameter value is one
of the list of allowed values returns the translated value; else, emits an error message and returns the value
specified by ret_val.

TODO: explain &lt;invert&gt;

]]

local function is_valid_parameter_value (value, name, possible, ret_val, invert)
	if not utilities.is_set (value) then
		return ret_val;															-- an empty parameter is ok
	end

	if (not invert and utilities.in_array (value, possible)) then				-- normal; &lt;value&gt; is in &lt;possible&gt; table
		return cfg.keywords_xlate[value];										-- return translation of parameter keyword
	elseif invert and not utilities.in_array (value, possible) then				-- invert; &lt;value&gt; is not in &lt;possible&gt; table
		return value;															-- return &lt;value&gt; as it is
	else
		utilities.set_message ('err_invalid_param_val', {name, value});			-- not an allowed value so add error message
		return ret_val;
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list, -3, -1) == sepc .. '. ') then					-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list, -1, -1) == sepc) or (string.sub (name_list, -3, -1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terminate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;-----------------------------------------

returns the concatenation of the formatted volume and issue (or journal article number) parameters as a single
string; or formatted volume or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, article, cite_class, origin, sepc, lower)
	if not utilities.is_set (volume) and not utilities.is_set (issue) and not utilities.is_set (article) then
		return '';
	end

	-- same condition as in format_pages_sheets()
	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);

	local is_numeric_vol = volume and (volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$'));	-- is only uppercase roman numerals or only digits?
	local is_long_vol = volume and (4 &lt; mw.ustring.len(volume));				-- is |volume= value longer than 4 characters?
	
	if volume and (not is_numeric_vol and is_long_vol) then						-- when not all digits or Roman numerals, is |volume= longer than 4 characters?
		utilities.add_prop_cat ('long-vol');									-- yes, add properties cat
	end

	if is_journal then															-- journal-style formatting
		local vol = '';

		if utilities.is_set (volume) then
			if is_numeric_vol then												-- |volume= value all digits or all uppercase Roman numerals?
				vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, volume});	-- render in bold face
			elseif is_long_vol then												-- not all digits or Roman numerals; longer than 4 characters?
				vol = utilities.substitute (cfg.messages['j-vol'], {sepc, utilities.hyphen_to_dash (volume)});	-- not bold
			else																-- four or fewer characters
				vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, utilities.hyphen_to_dash (volume)});	-- bold
			end
		end
		vol = vol .. (utilities.is_set (issue) and utilities.substitute (cfg.messages['j-issue'], issue) or '')
		vol = vol .. (utilities.is_set (article) and utilities.substitute (cfg.messages['j-article-num'], article) or '')
		return vol;
	end
	
	if 'podcast' == cite_class and utilities.is_set (issue) then
		return wrap_msg ('issue', {sepc, issue}, lower);
	end
	
	if 'conference' == cite_class and utilities.is_set (article) then			-- |article-number= supported only in journal and conference cites
		if utilities.is_set (volume) and utilities.is_set (article) then		-- both volume and article number
			return wrap_msg ('vol-art', {sepc, utilities.hyphen_to_dash (volume), article}, lower);
		elseif utilities.is_set (article) then									-- article number alone; when volume alone, handled below
			return wrap_msg ('art', {sepc, article}, lower);
		end
	end

	-- all other types of citation
	if utilities.is_set (volume) and utilities.is_set (issue) then
		return wrap_msg ('vol-no', {sepc, utilities.hyphen_to_dash (volume), issue}, lower);
	elseif utilities.is_set (volume) then
		return wrap_msg ('vol', {sepc, utilities.hyphen_to_dash (volume)}, lower);
	else
		return wrap_msg ('issue', {sepc, issue}, lower);
	end
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if utilities.is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif utilities.is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if utilities.is_set (page) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return utilities.substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return utilities.substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif utilities.is_set (pages) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then							-- if pages is only digits, assume a single page number
			return '', utilities.substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', utilities.substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', utilities.substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to Wikisource, returns the label portion of the interwiki-link as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki-link to an external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, page_orig, pages, pages_orig, at)
	local ws_url, ws_label, coins_pages, L;										-- for Wikisource interwiki-links; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if utilities.is_set (page) then
		if utilities.is_set (pages) or utilities.is_set (at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page, page_orig);								-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws URL from |page= interwiki link; link portion L becomes tooltip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (pages) then
		if utilities.is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages, pages_orig);							-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws URL from |pages= interwiki link; link portion L becomes tooltip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws URL from |at= interwiki link; link portion L becomes tooltip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end

--[[--------------------------&lt; I S _ U N I Q U E _ A R C H I V E _ U R L &gt;------------------------------------

add error message when |archive-url= value is same as |url= or chapter-url= (or alias...) value

]]

local function is_unique_archive_url (archive, url, c_url, source, date)
	if utilities.is_set (archive) then
		if archive == url or archive == c_url then
			utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)});	-- add error message
			return '', '';														-- unset |archive-url= and |archive-date= because same as |url= or |chapter-url=
		end
	end

	return archive, date;
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org URLs to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot URL or to calendar pages.  When the archive URL is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the URL.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org URL does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command URL
	|archive-url= is an archive.org URL that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org URLs:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this function may return a modified
archive URL:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the URL unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

A secondary function is to return an archive-url timestamp from those urls that have them (archive.org and
archive.today).  The timestamp is used by validation.archive_date_check() to see if the value in |archive-date=
matches the timestamp in the archive url.

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.org URL
	
	timestamp = url:match ('//archive.today/(%d%d%d%d%d%d%d%d%d%d%d%d%d%d)/') or	-- get timestamp from archive.today urls
		url:match ('//archive.today/(%d%d%d%d%.%d%d%.%d%d%-%d%d%d%d%d%d)/');		-- this timestamp needs cleanup
	if timestamp then															-- if this was an archive.today url ...
		return url, date, timestamp:gsub ('[%.%-]', '');						-- return ArchiveURL, ArchiveDate, and timestamp (dots and dashes removed) from |archive-url=, and done
	end
																				-- here for archive.org urls
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine URL
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command URL, we don't want to allow saving of the target page 
		err_msg = cfg.err_msg_supl.save;
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = cfg.err_msg_supl.liveweb;
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');	-- split out some of the URL parts for evaluation
		if not path then														-- malformed in some way; pattern did not match
			err_msg = cfg.err_msg_supl.timestamp;
		elseif 14 ~= timestamp:len() then										-- path and flag optional, must have 14-digit timestamp here
			err_msg = cfg.err_msg_supl.timestamp;
			if '*' ~= flag then
				local replacement = timestamp:match ('^%d%d%d%d%d%d') or timestamp:match ('^%d%d%d%d');	-- get the first 6 (YYYYMM) or first 4 digits (YYYY)
				if replacement then												-- nil if there aren't at least 4 digits (year)
					replacement = replacement .. string.rep ('0', 14 - replacement:len());	-- year or yearmo (4 or 6 digits) zero-fill to make 14-digit timestamp
					url=url:gsub ('(//web%.archive%.org/[^%d]*)%d[^/]*', '%1' .. replacement .. '*', 1)	-- for preview, modify ts to 14 digits plus splat for calendar display
				end
			end
		elseif utilities.is_set (path) and 'web/' ~= path then					-- older archive URLs do not have the extra 'web/' path element
			err_msg = cfg.err_msg_supl.path;
		elseif utilities.is_set (flag) and not utilities.is_set (path) then		-- flag not allowed with the old form URL (without the 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		elseif utilities.is_set (flag) and not flag:match ('%a%a_') then		-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		else
			return url, date, timestamp;										-- return ArchiveURL, ArchiveDate, and timestamp from |archive-url=
		end
	end
																				-- if here, something not right so
	utilities.set_message ('err_archive_url', {err_msg});						-- add error message and

	if is_preview_mode then
		return url, date, timestamp;											-- preview mode so return ArchiveURL, ArchiveDate, and timestamp from |archive-url=
	else
		return '', '';															-- return empty strings for ArchiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; P L A C E _ C H E C K &gt;--------------------------------------------------------

check |place=, |publication-place=, |location= to see if these params include digits.  This function added because
many editors misuse location to specify the in-source location (|page(s)= and |at= are supposed to do that)

returns the original parameter value without modification; added maint cat when parameter value contains digits

]]

local function place_check (param_val)
	if not utilities.is_set (param_val) then									-- parameter empty or omitted
		return param_val;														-- return that empty state
	end
	
	if mw.ustring.find (param_val, '%d') then									-- not empty, are there digits in the parameter value
		utilities.set_message ('maint_location');								-- yep, add maint cat
	end
	
	return param_val;															-- and done
end


--[[--------------------------&lt; I S _ A R C H I V E D _ C O P Y &gt;----------------------------------------------

compares |title= to 'Archived copy' (placeholder added by bots that can't find proper title); if matches, return true; nil else

]]

local function is_archived_copy (title)
	title = mw.ustring.lower(title);											-- switch title to lower case
	if title:find (cfg.special_case_translation.archived_copy.en) then			-- if title is 'Archived copy'
		return true;
	elseif cfg.special_case_translation.archived_copy['local'] then
		if mw.ustring.find (title, cfg.special_case_translation.archived_copy['local']) then	-- mw.ustring() because might not be Latin script
			return true;
		end
	end
end


--[[--------------------------&lt; D I S P L A Y _ N A M E S _ S E L E C T &gt;--------------------------------------

for any of the |display-authors=, |display-editors=, etc parameters, select either the local or global setting.
When both are present, look at &lt;local_display_names&gt; value.  When the value is some sort of 'et al.'string,
special handling is required.

When {{cs1 config}} has |display-&lt;namelist&gt;= AND this template has |display-&lt;namelist&gt;=etal AND:
	the number of names specified by &lt;number_of_names&gt; is:
		greater than the number specified in the global |display-&lt;namelist&gt;= parameter (&lt;global_display_names&gt;)
			use global |display-&lt;namelist&gt;= parameter value
			set overridden maint category
		less than or equal to the number specified in the global |display-&lt;namelist&gt;=  parameter
			use local |display-&lt;namelist&gt;= parameter value

The purpose of this function is to prevent categorizing a template that has fewer names than the global setting
to keep the etal annotation specified by &lt;local_display_names&gt;.

]]

local function display_names_select (global_display_names, local_display_names, param_name, number_of_names, test)
	if global_display_names and utilities.is_set (local_display_names) then		-- when both
		if 'etal' == local_display_names:lower():gsub(&quot;[ '%.]&quot;, '') then		-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			number_of_names = tonumber (number_of_names);						-- convert these to numbers for comparison
			local global_display_names_num = tonumber (global_display_names);	-- &lt;global_display_names&gt; not set when parameter value is not digits

			if number_of_names &gt; global_display_names_num then					-- template has more names than global config allows to be displayed?
				utilities.set_message ('maint_overridden_setting');				-- set a maint message because global is overriding local |display-&lt;namelist&gt;=etal
				return global_display_names, 'cs1 config';						-- return global with spoof parameter name (for get_display_names())
			else
				return local_display_names, param_name;							-- return local because fewer names so let &lt;local_display_names&gt; control
			end
		end
																				-- here when &lt;global_display_names&gt; and &lt;local_display_names&gt; both numbers; &lt;global_display_names&gt; controls
		utilities.set_message ('maint_overridden_setting');						-- set a maint message
		return global_display_names, 'cs1 config';								-- return global with spoof parameter name (for get_display_names())
	end
																				-- here when only one of &lt;global_display_names&gt; or &lt;local_display_names&gt; set
	if global_display_names then
		return global_display_names, 'cs1 config';								-- return global with spoof parameter name (for get_display_names())
	else
		return local_display_names, param_name;									-- return local
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args )
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper ( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListStyle;
		if cfg.global_cs1_config_t['NameListStyle'] then						-- global setting in {{cs1 config}} overrides local |name-list-style= parameter value; nil when empty or assigned value invalid
			NameListStyle = is_valid_parameter_value (cfg.global_cs1_config_t['NameListStyle'], 'cs1 config: name-list-style', cfg.keywords_lists['name-list-style'], '');	-- error messaging 'param' here is a hoax
		else
			NameListStyle = is_valid_parameter_value (A['NameListStyle'], A:ORIGIN('NameListStyle'), cfg.keywords_lists['name-list-style'], '');
		end

		if cfg.global_cs1_config_t['NameListStyle'] and utilities.is_set (A['NameListStyle']) then	-- when template has |name-list-style=&lt;something&gt; which global setting has overridden
			utilities.set_message ('maint_overridden_setting');					-- set a maint message
		end

	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			a, author_etal = parse_vauthors_veditors (args, A['Vauthors'], 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |people= or |credits=; |authors= is deprecated; TODO: constrain |people= and |credits= to cite av media, episode, serial?
		end
		if utilities.is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], nil, args, 'EditorList');	-- support for |editors= withdrawn
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		end
	end
							
	local Chapter = A['Chapter'];												-- done here so that we have access to |contribution= from |chapter= aliases
	local Chapter_origin = A:ORIGIN ('Chapter');
	local Contribution;															-- because contribution is required for contributor(s)
		if 'contribution' == Chapter_origin then
			Contribution = Chapter;												-- get the name of the contribution
		end
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	
	if utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not utilities.is_set (Contribution) then							-- |contributor= requires |contribution=
				utilities.set_message ('err_contributor_missing_required_param', 'contribution');	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				utilities.set_message ('err_contributor_missing_required_param', 'author');	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if utilities.select_one (args, cfg.aliases['ContributorList-Last'], 'err_redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			utilities.set_message ('err_contributor_ignored');					-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	local Title = A['Title'];
	local TitleLink = A['TitleLink'];

	local auto_select = '';														-- default is auto
	local accept_link;
	TitleLink, accept_link = utilities.has_accept_as_written (TitleLink, true);	-- test for accept-this-as-written markup
	if (not accept_link) and utilities.in_array (TitleLink, {'none', 'pmc', 'doi'}) then -- check for special keywords
		auto_select = TitleLink;												-- remember selection for later
		TitleLink = '';															-- treat as if |title-link= would have been empty
	end

	TitleLink = link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wiki-markup in |title-link= or wiki-markup in |title= when |title-link= is set

	local Section = '';															-- {{cite map}} only; preset to empty string for concatenation if not used
	if 'map' == config.CitationClass and 'section' == Chapter_origin then
		Section = A['Chapter'];													-- get |section= from |chapter= alias list; |chapter= and the other aliases not supported in {{cite map}}
		Chapter = '';															-- unset for now; will be reset later from |map= if present
	end

	local Periodical = A['Periodical'];
	local Periodical_origin = A:ORIGIN('Periodical');
	local ScriptPeriodical = A['ScriptPeriodical'];
	local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');
	local TransPeriodical =  A['TransPeriodical'];
	local TransPeriodical_origin =  A:ORIGIN ('TransPeriodical');
	
	if (utilities.in_array (config.CitationClass, {'book', 'encyclopaedia'}) and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical))) then
		local param;
		if utilities.is_set (Periodical) then									-- get a parameter name from one of these periodical related meta-parameters
			Periodical = '';													-- unset because not valid {{cite book}} or {{cite encyclopedia}} parameters 
			param = Periodical_origin											-- get parameter name for error messaging
		elseif utilities.is_set (TransPeriodical) then
			TransPeriodical = '';												-- unset because not valid {{cite book}} or {{cite encyclopedia}} parameters 
			param = TransPeriodical_origin;										-- get parameter name for error messaging
		elseif utilities.is_set (ScriptPeriodical) then
			ScriptPeriodical = '';												-- unset because not valid {{cite book}} or {{cite encyclopedia}} parameters 
			param = ScriptPeriodical_origin;									-- get parameter name for error messaging
		end

		if utilities.is_set (param) then										-- if we found one
			utilities.set_message ('err_periodical_ignored', {param});			-- emit an error message
		end
	end

	if utilities.is_set (Periodical) then
		local i;
		Periodical, i = utilities.strip_apostrophe_markup (Periodical);			-- strip apostrophe markup so that metadata isn't contaminated 
		if i then																-- non-zero when markup was stripped so emit an error message
			utilities.set_message ('err_apostrophe_markup', {Periodical_origin});
		end
	end

	if 'mailinglist' == config.CitationClass then								-- special case for {{cite mailing list}}
		if utilities.is_set (Periodical) and utilities.is_set (A ['MailingList']) then	-- both set emit an error TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', Periodical_origin) .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'mailinglist')});
		end

		Periodical = A ['MailingList'];											-- error or no, set Periodical to |mailinglist= value because this template is {{cite mailing list}}
		Periodical_origin = A:ORIGIN('MailingList');
	end

	-- web and news not tested for now because of 
	-- Wikipedia:Administrators%27_noticeboard#Is_there_a_semi-automated_tool_that_could_fix_these_annoying_&quot;Cite_Web&quot;_errors?
	if not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) then	-- 'periodical' templates require periodical parameter
	--	local p = {['journal'] = 'journal', ['magazine'] = 'magazine', ['news'] = 'newspaper', ['web'] = 'website'};	-- for error message
		local p = {['journal'] = 'journal', ['magazine'] = 'magazine'};			-- for error message
		if p[config.CitationClass]  then
			utilities.set_message ('err_missing_periodical', {config.CitationClass, p[config.CitationClass]});
		end
	end
	
	local Volume;
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) then
			if not utilities.in_array (Periodical_origin, cfg.citation_no_volume_t) then	-- {{citation}} does not render |volume= when these parameters are used
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		elseif utilities.is_set (ScriptPeriodical) then
			if 'script-website' ~= ScriptPeriodical_origin then					-- {{citation}} does not render volume for |script-website=
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		else
			Volume = A['Volume'];												-- and does for non-'periodical' cites
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_volume) then	-- render |volume= for cs1 according to the configuration settings
		Volume = A['Volume'];
	end	
	extra_text_in_vol_iss_check (Volume, A:ORIGIN ('Volume'), 'v');	

	local Issue;
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) and utilities.in_array (Periodical_origin, cfg.citation_issue_t) then	-- {{citation}} may render |issue= when these parameters are used
			Issue = utilities.hyphen_to_dash (A['Issue']);
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_issue) then	-- conference &amp; map books do not support issue; {{citation}} listed here because included in settings table
		if not (utilities.in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical))) then
			Issue = utilities.hyphen_to_dash (A['Issue']);
		end
	end
	
	local ArticleNumber;

	if utilities.in_array (config.CitationClass, {'journal', 'conference'}) or ('citation' == config.CitationClass and utilities.is_set (Periodical) and 'journal' == Periodical_origin) then
		ArticleNumber = A['ArticleNumber'];
	end

	extra_text_in_vol_iss_check (Issue, A:ORIGIN ('Issue'), 'i');	

	local Page;
	local Pages;
	local At;
	local QuotePage;
	local QuotePages;
	if not utilities.in_array (config.CitationClass, cfg.templates_not_using_page) then		-- TODO: rewrite to emit ignored parameter error message?
		Page = A['Page'];
		Pages = utilities.hyphen_to_dash (A['Pages']);	
		At = A['At'];
		QuotePage = A['QuotePage'];
		QuotePages = utilities.hyphen_to_dash (A['QuotePages']);
	end

	local Edition = A['Edition'];
	local PublicationPlace = place_check (A['PublicationPlace'], A:ORIGIN('PublicationPlace'));
	local Place = place_check (A['Place'], A:ORIGIN('Place'));
	
	local PublisherName = A['PublisherName'];
	local PublisherName_origin = A:ORIGIN('PublisherName');
	if utilities.is_set (PublisherName) and (cfg.keywords_xlate['none'] ~= PublisherName) then
		local i = 0;
		PublisherName, i = utilities.strip_apostrophe_markup (PublisherName);	-- strip apostrophe markup so that metadata isn't contaminated; publisher is never italicized
		if i and (0 &lt; i) then													-- non-zero when markup was stripped so emit an error message
			utilities.set_message ('err_apostrophe_markup', {PublisherName_origin});
		end
	end
	
	if ('document' == config.CitationClass) and not utilities.is_set (PublisherName) then
		utilities.set_message ('err_missing_publisher', {config.CitationClass, 'publisher'});
	end

	local Newsgroup = A['Newsgroup'];											-- TODO: strip apostrophe markup?
	local Newsgroup_origin = A:ORIGIN('Newsgroup');	

	if 'newsgroup' == config.CitationClass then
		if utilities.is_set (PublisherName) and (cfg.keywords_xlate['none'] ~= PublisherName) then	-- general use parameter |publisher= not allowed in cite newsgroup
			utilities.set_message ('err_parameter_ignored', {PublisherName_origin});
		end

		PublisherName = nil;													-- ensure that this parameter is unset for the time being; will be used again after COinS
	end

	local URL = A['URL'];														-- TODO: better way to do this for URL, ChapterURL, and MapURL?
	local UrlAccess = is_valid_parameter_value (A['UrlAccess'], A:ORIGIN('UrlAccess'), cfg.keywords_lists['url-access'], nil);
	
	if not utilities.is_set (URL) and utilities.is_set (UrlAccess) then
		UrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', 'url');
	end
	
	local ChapterURL = A['ChapterURL'];
	local ChapterUrlAccess = is_valid_parameter_value (A['ChapterUrlAccess'], A:ORIGIN('ChapterUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (ChapterURL) and utilities.is_set (ChapterUrlAccess) then
		ChapterUrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', {A:ORIGIN('ChapterUrlAccess'):gsub ('%-access', '')});
	end

	local MapUrlAccess = is_valid_parameter_value (A['MapUrlAccess'], A:ORIGIN('MapUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (A['MapURL']) and utilities.is_set (MapUrlAccess) then
		MapUrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', {'map-url'});
	end

	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local no_tracking_cats = is_valid_parameter_value (A['NoTracking'], A:ORIGIN('NoTracking'), cfg.keywords_lists['yes_true_y'], nil);

	-- check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not utilities.is_set (no_tracking_cats) then								-- ignore if we are already not going to categorize this page
		if cfg.uncategorized_namespaces[this_page.namespace] then				-- is this page's namespace id one of the uncategorized namespace ids?
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _, v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end
																				-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	utilities.select_one (args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'err_redundant_parameters');	-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, A:ORIGIN('Page'), Pages, A:ORIGIN('Pages'), At);

	local NoPP = is_valid_parameter_value (A['NoPP'], A:ORIGIN('NoPP'), cfg.keywords_lists['yes_true_y'], nil);

	if utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- both |publication-place= and |place= (|location=) allowed if different
		utilities.add_prop_cat ('location-test');								-- add property cat to evaluate how often PublicationPlace and Place are used together
		if PublicationPlace == Place then
			Place = '';															-- unset; don't need both if they are the same
		end
	elseif not utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- when only |place= (|location=) is set ...
		PublicationPlace = Place;												-- promote |place= (|location=) to |publication-place
	end

	if PublicationPlace == Place then Place = ''; end							-- don't need both if they are the same

	local URL_origin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL_origin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ScriptChapter = A['ScriptChapter'];
	local ScriptChapter_origin = A:ORIGIN ('ScriptChapter');
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local TransChapter = A['TransChapter'];
	local TransChapter_origin = A:ORIGIN ('TransChapter');
	local TransTitle = A['TransTitle'];
	local ScriptTitle = A['ScriptTitle'];
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia= and |title= then map |title= to |article= and |encyclopedia= to |title= for rendering
		|encyclopedia= and |article= then map |encyclopedia= to |title= for rendering

		|trans-title= maps to |trans-chapter= when |title= is re-mapped
		|url= maps to |chapter-url= when |title= is remapped
	
	All other combinations of |encyclopedia=, |title=, and |article= are not modified
	
	]]

	local Encyclopedia = A['Encyclopedia'];										-- used as a flag by this module and by ~/COinS
	local ScriptEncyclopedia = A['ScriptEncyclopedia'];
	local TransEncyclopedia = A['TransEncyclopedia'];

	if utilities.is_set (Encyclopedia) or utilities.is_set (ScriptEncyclopedia) then	-- emit error message when Encyclopedia set but template is other than {{cite encyclopedia}} or {{citation}}
		if 'encyclopaedia' ~= config.CitationClass and 'citation' ~= config.CitationClass then
			if utilities.is_set (Encyclopedia) then
				utilities.set_message ('err_parameter_ignored', {A:ORIGIN ('Encyclopedia')});
			else
				utilities.set_message ('err_parameter_ignored', {A:ORIGIN ('ScriptEncyclopedia')});
			end
			Encyclopedia = nil;													-- unset these because not supported by this template
			ScriptEncyclopedia = nil;
			TransEncyclopedia = nil;
		end
	elseif utilities.is_set (TransEncyclopedia) then
		utilities.set_message ('err_trans_missing_title', {'encyclopedia'});
	end

	if ('encyclopaedia' == config.CitationClass) or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Periodical) and utilities.is_set (Encyclopedia) then	-- when both parameters set emit an error message; {{citation}} only; Periodical not allowed in {{cite encyclopedia}}
			utilities.set_message ('err_periodical_ignored', {Periodical_origin});
		end

		if utilities.is_set (Encyclopedia) or utilities.is_set (ScriptEncyclopedia) then
			Periodical = Encyclopedia;											-- error or no, set Periodical to Encyclopedia for rendering; {{citation}} could (not legitimately) have both; use Encyclopedia
			Periodical_origin = A:ORIGIN ('Encyclopedia');
			ScriptPeriodical = ScriptEncyclopedia;
			ScriptPeriodical_origin = A:ORIGIN ('ScriptEncyclopedia');

			if utilities.is_set (Title) or utilities.is_set (ScriptTitle) then
				if not utilities.is_set (Chapter) then
					Chapter = Title;											-- |encyclopedia= and |title= are set so map |title= params to |article= params for rendering
					ScriptChapter = ScriptTitle;
					ScriptChapter_origin = A:ORIGIN('ScriptTitle')
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterURL_origin = URL_origin;
					ChapterUrlAccess = UrlAccess;
					ChapterFormat = Format;

					if not utilities.is_set (ChapterURL) and utilities.is_set (TitleLink) then
						Chapter = utilities.make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;											-- now map |encyclopedia= params to |title= params for rendering
					ScriptTitle = ScriptPeriodical or '';
					TransTitle = TransEncyclopedia or '';
					Periodical = '';											-- redundant so unset
					ScriptPeriodical = '';
					URL = '';
					Format = '';
					TitleLink = '';
				end
			elseif utilities.is_set (Chapter) or utilities.is_set (ScriptChapter) then	-- |title= not set
				Title = Periodical;												-- |encyclopedia= set and |article= set so map |encyclopedia= to |title= for rendering
				ScriptTitle = ScriptPeriodical or '';
				TransTitle = TransEncyclopedia or '';
				Periodical = '';												-- redundant so unset
				ScriptPeriodical = '';
			end
		end
	end

	-- special case for cite techreport.
	local ID = A['ID'];
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if utilities.is_set (A['Number']) then									-- cite techreport uses 'number', which other citations alias to 'issue'
			if not utilities.is_set (ID) then									-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'id') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'number')});
			end
		end	
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	local ChapterLink -- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local Conference = A['Conference'];
	local BookTitle = A['BookTitle'];
	local TransTitle_origin = A:ORIGIN ('TransTitle');
	if 'conference' == config.CitationClass then
		if utilities.is_set (BookTitle) then
			Chapter = Title;
			Chapter_origin = 'title';
	--		ChapterLink = TitleLink;											-- |chapter-link= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			URL_origin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			TransChapter_origin = TransTitle_origin;
			Title = BookTitle;
			Format = '';
	--		TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end
	
	-- CS1/2 mode
	local Mode;
		if cfg.global_cs1_config_t['Mode'] then									-- global setting in {{cs1 config}} overrides local |mode= parameter value; nil when empty or assigned value invalid
			Mode = is_valid_parameter_value (cfg.global_cs1_config_t['Mode'], 'cs1 config: mode', cfg.keywords_lists['mode'], '');	-- error messaging 'param' here is a hoax
		else
			Mode = is_valid_parameter_value (A['Mode'], A:ORIGIN('Mode'), cfg.keywords_lists['mode'], '');
		end

		if cfg.global_cs1_config_t['Mode'] and utilities.is_set (A['Mode']) then	-- when template has |mode=&lt;something&gt; which global setting has overridden
			utilities.set_message ('maint_overridden_setting');					-- set a maint message
		end

	-- separator character and postscript
	local sepc, PostScript = set_style (Mode:lower(), A['PostScript'], config.CitationClass);
	-- controls capitalization of certain static text
	local use_lowercase = ( sepc == ',' );
	
	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		if utilities.is_set (Chapter) then										--TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'map') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', Chapter_origin)});	-- add error message
		end
		Chapter = A['Map'];
		Chapter_origin = A:ORIGIN('Map');
		ChapterURL = A['MapURL'];
		ChapterURL_origin = A:ORIGIN('MapURL');
		TransChapter = A['TransMap'];
		ScriptChapter = A['ScriptMap']
		ScriptChapter_origin = A:ORIGIN('ScriptMap')

		ChapterUrlAccess = MapUrlAccess;
		ChapterFormat = A['MapFormat'];

		Cartography = A['Cartography'];
		if utilities.is_set ( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if utilities.is_set ( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	local Series = A['Series'];
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local SeriesLink = A['SeriesLink'];

		SeriesLink = link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wiki-markup in |series-link= or wiki-markup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if utilities.is_set (Network) then table.insert(n, Network); end
		if utilities.is_set (Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if utilities.is_set (Season) and utilities.is_set (SeriesNumber) then	-- these are mutually exclusive so if both are set TODO: make a function for this and similar?
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'season') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'seriesno')});		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if utilities.is_set (Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if utilities.is_set (SeriesNumber) then table.insert(s, wrap_msg ('seriesnum', SeriesNumber, use_lowercase)); end
			if utilities.is_set (Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ScriptChapter_origin = A:ORIGIN('ScriptTitle');
			ChapterLink = TitleLink;											-- alias |episode-link=
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			ChapterFormat = Format;

			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if utilities.is_set (ChapterLink) and not utilities.is_set (ChapterURL) then	-- link but not URL
				Chapter = utilities.make_wikilink (ChapterLink, Chapter);
			elseif utilities.is_set (ChapterLink) and utilities.is_set (ChapterURL) then	-- if both are set, URL links episode;
				Series = utilities.make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			Format = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if utilities.is_set (Series) and utilities.is_set (SeriesLink) then
				Series = utilities.make_wikilink (SeriesLink, Series);
			end
			Series = utilities.wrap_style ('italic-title', Series);				-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- handle type parameter for those CS1 citations that have default values
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	if utilities.in_array (config.CitationClass, {'AV-media-notes', 'document', 'interview', 'mailinglist', 'map', 'podcast', 'pressrelease', 'report', 'speech', 'techreport', 'thesis'}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if utilities.is_set (Degree) and &quot;Thesis&quot; == TitleType then				-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if utilities.is_set (TitleType) then										-- if type parameter is specified
		TitleType = utilities.substitute ( cfg.messages['type'], TitleType);	-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
	local Date = A['Date'];
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging
	local PublicationDate = A['PublicationDate'];
	local Year = A['Year'];

	if utilities.is_set (Year) then
		validation.year_check (Year);											-- returns nothing; emits maint message when |year= doesn't hold a 'year' value
	end
		
	if not utilities.is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not utilities.is_set (Date) and utilities.is_set (PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]

	local DF = is_valid_parameter_value (A['DF'], A:ORIGIN('DF'), cfg.keywords_lists['df'], '');
	if not utilities.is_set (DF) then
		DF = cfg.global_df;														-- local |df= if present overrides global df set by {{use xxx date}} template
	end

	local ArchiveURL;
	local ArchiveDate;
	local ArchiveFormat = A['ArchiveFormat'];
	local archive_url_timestamp;												-- timestamp from wayback machine url
	
	ArchiveURL, ArchiveDate, archive_url_timestamp = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	
	ArchiveURL, ArchiveDate = is_unique_archive_url (ArchiveURL, URL, ChapterURL, A:ORIGIN('ArchiveURL'), ArchiveDate);		-- add error message when URL or ChapterURL == ArchiveURL

	local AccessDate = A['AccessDate'];
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification
	local DoiBroken = A['DoiBroken'];
	local Embargo = A['Embargo'];
	local anchor_year;															-- used in the CITEREF identifier
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val = AccessDate, name = A:ORIGIN ('AccessDate')},
			['archive-date'] = {val = ArchiveDate, name = A:ORIGIN ('ArchiveDate')},
			['date'] = {val = Date, name = Date_origin},
			['doi-broken-date'] = {val = DoiBroken, name = A:ORIGIN ('DoiBroken')},
			['pmc-embargo-date'] = {val = Embargo, name = A:ORIGIN ('Embargo')},
			['publication-date'] = {val = PublicationDate, name = A:ORIGIN ('PublicationDate')},
			['year'] = {val = Year, name = A:ORIGIN ('Year')},
			};

		local error_list = {};
		anchor_year, Embargo = validation.dates(date_parameters_list, COinS_date, error_list);

		if utilities.is_set (Year) and utilities.is_set (Date) then				-- both |date= and |year= not normally needed; 
			validation.year_date_check (Year, A:ORIGIN ('Year'), Date, A:ORIGIN ('Date'), error_list);
		end

		if 0 == #error_list then												-- error free dates only; 0 when error_list is empty
			local modified = false;												-- flag
			
			if utilities.is_set (DF) then										-- if we need to reformat dates
				modified = validation.reformat_dates (date_parameters_list, DF);	-- reformat to DF format, use long month names if appropriate
			end

			if true == validation.date_hyphen_to_dash (date_parameters_list) then	-- convert hyphens to dashes where appropriate
				modified = true;
				utilities.set_message ('maint_date_format');					-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language; not supported at en.wiki
			if cfg.date_name_auto_xlate_enable and validation.date_name_xlate (date_parameters_list, cfg.date_digit_auto_xlate_enable ) then
				utilities.set_message ('maint_date_auto_xlated');				-- add maint cat
				modified = true;
			end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end

			if archive_url_timestamp and utilities.is_set (ArchiveDate) then
				validation.archive_date_check (ArchiveDate, archive_url_timestamp, DF);	-- does YYYYMMDD in archive_url_timestamp match date in ArchiveDate
			end
		else
			utilities.set_message ('err_bad_date', {utilities.make_sep_list (#error_list, error_list)});	-- add this error message
		end
	end	-- end of do

	if utilities.in_array (config.CitationClass, {'book', 'encyclopaedia'}) or	-- {{cite book}}, {{cite encyclopedia}}; TODO: {{cite conference}} and others?
		('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) or			-- {{citation}} as an encylopedia citation
		('citation' == config.CitationClass and not utilities.is_set (Periodical)) then		-- {{citation}} as a book citation
			if utilities.is_set (PublicationPlace) then
				if not utilities.is_set (PublisherName) then
					local date = COinS_date.rftdate and tonumber (COinS_date.rftdate:match ('%d%d%d%d'));	-- get year portion of COinS date (because in Arabic numerals); convert string to number
					if date and (1850 &lt;= date) then								-- location has no publisher; if date is 1850 or later
						utilities.set_message ('maint_location_no_publisher');	-- add maint cat
					end
				else															-- PublisherName has a value
					if cfg.keywords_xlate['none'] == PublisherName then			-- if that value is 'none' (only for book and encyclopedia citations)
						PublisherName = '';										-- unset
					end
				end
			end
	end

	local ID_list = {};															-- sequence table of rendered identifiers
	local ID_list_coins = {};													-- table of identifiers and their values from args; key is same as cfg.id_handlers's key
	local Class = A['Class'];													-- arxiv class identifier
	
	local ID_support = {
		{A['ASINTLD'], 'ASIN', 'err_asintld_missing_asin', A:ORIGIN ('ASINTLD')},				
		{DoiBroken, 'DOI', 'err_doibroken_missing_doi', A:ORIGIN ('DoiBroken')},
		{Embargo, 'PMC', 'err_embargo_missing_pmc', A:ORIGIN ('Embargo')},
		}

	ID_list, ID_list_coins = identifiers.identifier_lists_get (args, {DoiBroken = DoiBroken, ASINTLD = A['ASINTLD'], Embargo = Embargo, Class = Class}, ID_support);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite medrxiv}}, {{cite ssrn}}, before generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list_t) then	-- |arxiv= or |eprint= required for cite arxiv; |biorxiv=, |citeseerx=, |medrxiv=, |ssrn= required for their templates
		if not (args[cfg.id_handlers[config.CitationClass:upper()].parameters[1]] or 		-- can't use ID_list_coins k/v table here because invalid parameters omitted
			args[cfg.id_handlers[config.CitationClass:upper()].parameters[2]]) then			-- which causes unexpected parameter missing error message
				utilities.set_message ('err_' .. config.CitationClass .. '_missing');		-- add error message
		end

		Periodical = ({['arxiv'] = 'arXiv', ['biorxiv'] = 'bioRxiv', ['citeseerx'] = 'CiteSeerX', ['medrxiv'] = 'medRxiv', ['ssrn'] = 'Social Science Research Network'})[config.CitationClass];
	end

	-- Link the title of the work if no |url= was provided, but we have a |pmc= or a |doi= with |doi-access=free

	if config.CitationClass == &quot;journal&quot; and not utilities.is_set (URL) and not utilities.is_set (TitleLink) and not utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) then -- TODO: remove 'none' once existing citations have been switched to 'off', so 'none' can be used as token for &quot;no title&quot; instead
		if 'none' ~= cfg.keywords_xlate[auto_select] then						-- if auto-linking not disabled
 	 		if identifiers.auto_link_urls[auto_select] then						-- manual selection
		 		URL = identifiers.auto_link_urls[auto_select];					-- set URL to be the same as identifier's external link
 				URL_origin = cfg.id_handlers[auto_select:upper()].parameters[1];	-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['pmc'] then						-- auto-select PMC
				URL = identifiers.auto_link_urls['pmc'];						-- set URL to be the same as the PMC external link if not embargoed
				URL_origin = cfg.id_handlers['PMC'].parameters[1];				-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['doi'] then						-- auto-select DOI
				URL = identifiers.auto_link_urls['doi'];
				URL_origin = cfg.id_handlers['DOI'].parameters[1];
			end
 	 	end

		if utilities.is_set (URL) then											-- set when using an identifier-created URL
			if utilities.is_set (AccessDate) then								-- |access-date= requires |url=; identifier-created URL is not |url=
				utilities.set_message ('err_accessdate_missing_url');			-- add an error message
				AccessDate = '';												-- unset
			end

			if utilities.is_set (ArchiveURL) then								-- |archive-url= requires |url=; identifier-created URL is not |url=
				utilities.set_message ('err_archive_missing_url');				-- add an error message
				ArchiveURL = '';												-- unset
			end
		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not utilities.is_set (Title) and not utilities.is_set (TransTitle) and not utilities.is_set (ScriptTitle) then	-- has special case for cite episode
		utilities.set_message ('err_citation_missing_title', {'episode' == config.CitationClass and 'series' or 'title'});
	end

	if utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) and
			utilities.in_array (config.CitationClass, {'journal', 'citation'}) and
			(utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and
			('journal' == Periodical_origin or 'script-journal' == ScriptPeriodical_origin) then	-- special case for journal cites
				Title = '';														-- set title to empty string
				utilities.set_message ('maint_untitled');						-- add maint cat
	end

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Chapter) and utilities.is_set (Title) and utilities.is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end
	
	-- this is the function call to COinS()
	local OCinSoutput = metadata.COinS({
		['Periodical'] = utilities.strip_apostrophe_markup (Periodical),		-- no markup in the metadata
		['Encyclopedia'] = Encyclopedia,										-- just a flag; content ignored by ~/COinS
		['Chapter'] = metadata.make_coins_title (coins_chapter, ScriptChapter),	-- Chapter and ScriptChapter stripped of bold / italic / accept-as-written markup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = metadata.make_coins_title (coins_title, ScriptTitle),		-- Title and ScriptTitle stripped of bold / italic / accept-as-written markup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date.* has correctly formatted date values if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Quarter'] = COinS_date.rftquarter,
		['Chron'] =  COinS_date.rftchron,
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['ArticleNumber'] = ArticleNumber,
		['Pages'] = coins_pages or metadata.get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At, QuotePage, QuotePages}, 7)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName or Newsgroup,							-- any apostrophe markup already removed from PublisherName
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list_coins,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite medrxiv}}, and {{cite ssrn}} AFTER generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list_t) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, CiteSeerX, medRxiv, or ssrn now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass and utilities.is_set (Newsgroup) then
		PublisherName = utilities.substitute (cfg.messages['newsgroup'], external_link( 'news:' .. Newsgroup, Newsgroup, Newsgroup_origin, nil ));
	end

	local Editors;
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	local Contributors;															-- assembled contributors name list
	local contributor_etal;
	local Translators;															-- assembled translators name list
	local translator_etal;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	local Interviewers;															
	local interviewers_list = {};					
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters
	local interviewer_etal;
	
	-- Now perform various field 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.
	do
		local last_first_list;
		local control = { 
			format = NameListStyle,												-- empty string, '&amp;', 'amp', 'and', or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			local display_names, param = display_names_select (cfg.global_cs1_config_t['DisplayEditors'], A['DisplayEditors'], A:ORIGIN ('DisplayEditors'), #e);
			control.maximum, editor_etal = get_display_names (display_names, #e, 'editors', editor_etal, param);

			Editors, EditorCount = list_people (control, e, editor_etal);

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			local display_names, param = display_names_select (cfg.global_cs1_config_t['DisplayInterviewers'], A['DisplayInterviewers'], A:ORIGIN ('DisplayInterviewers'), #interviewers_list);
			control.maximum, interviewer_etal = get_display_names (display_names, #interviewers_list, 'interviewers', interviewer_etal, param);

			Interviewers = list_people (control, interviewers_list, interviewer_etal);
		end
		do																		-- now do translators
			local display_names, param = display_names_select (cfg.global_cs1_config_t['DisplayTranslators'], A['DisplayTranslators'], A:ORIGIN ('DisplayTranslators'), #t);
			control.maximum, translator_etal = get_display_names (display_names, #t, 'translators', translator_etal, param);

			Translators = list_people (control, t, translator_etal);
		end
		do																		-- now do contributors
			local display_names, param = display_names_select (cfg.global_cs1_config_t['DisplayContributors'], A['DisplayContributors'], A:ORIGIN ('DisplayContributors'), #c);
			control.maximum, contributor_etal = get_display_names (display_names, #c, 'contributors', contributor_etal, param);

			Contributors = list_people (control, c, contributor_etal);
		end
		do																		-- now do authors
			local display_names, param = display_names_select (cfg.global_cs1_config_t['DisplayAuthors'], A['DisplayAuthors'], A:ORIGIN ('DisplayAuthors'), #a, author_etal);
			control.maximum, author_etal = get_display_names (display_names, #a, 'authors', author_etal, param);

			last_first_list = list_people (control, a, author_etal);

			if utilities.is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors');	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if utilities.is_set (Authors) and utilities.is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'medrxiv', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not utilities.is_set (URL) then
		if utilities.in_array (config.CitationClass, {&quot;web&quot;, &quot;podcast&quot;, &quot;mailinglist&quot;}) or		-- |url= required for cite web, cite podcast, and cite mailinglist
			('citation' == config.CitationClass and ('website' == Periodical_origin or 'script-website' == ScriptPeriodical_origin)) then	-- and required for {{citation}} with |website= or |script-website=
				utilities.set_message ('err_cite_web_url');
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if utilities.is_set (AccessDate) and not utilities.is_set (ChapterURL) then		-- ChapterURL may be set when URL is not set;
			utilities.set_message ('err_accessdate_missing_url');
			AccessDate = '';
		end
	end

	local UrlStatus = is_valid_parameter_value (A['UrlStatus'], A:ORIGIN('UrlStatus'), cfg.keywords_lists['url-status'], '');
	local OriginalURL
	local OriginalURL_origin
	local OriginalFormat
	local OriginalAccess;
	UrlStatus = UrlStatus:lower();												-- used later when assembling archived text
	if utilities.is_set ( ArchiveURL ) then
		if utilities.is_set (ChapterURL) then 									-- if chapter-url= is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURL_origin = ChapterURL_origin;								-- name of |chapter-url= parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=

			if 'live' ~= UrlStatus then
				ChapterURL = ArchiveURL											-- swap-in the archive's URL
				ChapterURL_origin = A:ORIGIN('ArchiveURL')						-- name of |archive-url= parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived URLs
			end
		elseif utilities.is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURL_origin = URL_origin;									-- name of URL parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;

			if 'live' ~= UrlStatus then											-- if URL set then |archive-url= applies to it
				URL = ArchiveURL												-- swap-in the archive's URL
				URL_origin = A:ORIGIN('ArchiveURL')								-- name of archive URL parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived URLs
			end
		end
	elseif utilities.is_set (UrlStatus) then									-- if |url-status= is set when |archive-url= is not set
 		utilities.set_message ('maint_url_status');								-- add maint cat
	end

	if utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'medrxiv', 'ssrn'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) then
			local chap_param;
			if utilities.is_set (Chapter) then									-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif utilities.is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif utilities.is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif utilities.is_set (ScriptChapter) then
				chap_param = ScriptChapter_origin;
			else utilities.is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if utilities.is_set (chap_param) then								-- if we found one
				utilities.set_message ('err_chapter_ignored', {chap_param});	-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if utilities.is_set (Contribution) and 0 &lt; #c then						-- if this is a contribution with contributor(s)
			if utilities.in_array (Contribution:lower(), cfg.keywords_lists.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, ScriptChapter_origin, Chapter, Chapter_origin, TransChapter, TransChapter_origin, ChapterURL, ChapterURL_origin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if utilities.is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and utilities.is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter .. sepc .. ' ';
		elseif utilities.is_set (ChapterFormat) then							-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title
	local plain_title = false;
	local accept_title;
	Title, accept_title = utilities.has_accept_as_written (Title, true);		-- remove accept-this-as-written markup when it wraps all of &lt;Title&gt;
	if accept_title and ('' == Title) then										-- only support forced empty for now &quot;(())&quot;
		Title = cfg.messages['notitle'];										-- replace by predefined &quot;No title&quot; message
			-- TODO: utilities.set_message ( 'err_redundant_parameters', ...);	-- issue proper error message instead of muting	 
			ScriptTitle = '';													-- just mute for now	 
			TransTitle = '';													-- just mute for now
 		plain_title = true;														-- suppress text decoration for descriptive title
		utilities.set_message ('maint_untitled');								-- add maint cat
	end

	if not accept_title then													-- &lt;Title&gt; not wrapped in accept-as-written markup
		if '...' == Title:sub (-3) then											-- if ellipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%' .. sepc .. '$', '');			-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end

		if utilities.is_set (ArchiveURL) and is_archived_copy (Title) then
			utilities.set_message ('maint_archived_copy');						-- add maintenance category before we modify the content of Title
		end

		if is_generic ('generic_titles', Title) then
			utilities.set_message ('err_generic_title');						-- set an error message
		end
	end

	if (not plain_title) and (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'document', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx', 'medrxiv', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) or
		('map' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)))) then		-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from module provided quote marks
			Title = utilities.wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle, 'script-title');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
			TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );
	elseif plain_title or ('report' == config.CitationClass) then				-- no styling for cite report and descriptive titles (otherwise same as above)
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );	-- for cite report, use this form for trans-title
	else
		Title = utilities.wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-italic-title', TransTitle);
	end

	if utilities.is_set (TransTitle) then
		if utilities.is_set (Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			utilities.set_message ('err_trans_missing_title', {'title'});
		end
	end

	if utilities.is_set (Title) then											-- TODO: is this the right place to be making Wikisource URLs?
		if utilities.is_set (TitleLink) and utilities.is_set (URL) then
			utilities.set_message ('err_wikilink_in_url');						-- set an error message because we can't have both
			TitleLink = '';														-- unset
		end
	
		if not utilities.is_set (TitleLink) and utilities.is_set (URL) then
			Title = external_link (URL, Title, URL_origin, UrlAccess) .. TransTitle .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif utilities.is_set (TitleLink) and not utilities.is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle;
			else
				Title = utilities.make_wikilink (TitleLink, Title) .. TransTitle;
			end
		else
			local ws_url, ws_label, L;											-- Title has italic or quote markup by the time we get here which causes is_wikilink() to return 0 (not a wikilink)
			ws_url, ws_label, L = wikisource_url_make (Title:gsub('^[\'&quot;]*(.-)[\'&quot;]*$', '%1'));	-- make ws URL from |title= interwiki link (strip italic or quote markup); link portion L becomes tooltip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle;
			else
				Title = Title .. TransTitle;
			end
		end
	else
		Title = TransTitle;
	end

	if utilities.is_set (Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	local ConferenceURL_origin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	if utilities.is_set (Conference) then
		if utilities.is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURL_origin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif utilities.is_set (ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURL_origin, nil );
	end

	local Position = '';
	if not utilities.is_set (Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if utilities.is_set (Minutes) then
			if utilities.is_set (Time) then		--TODO: make a function for this and similar?
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'minutes') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'time')});
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if utilities.is_set (Time) then
				local TimeCaption = A['TimeCaption']
				if not utilities.is_set (TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = utilities.is_set (At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = utilities.is_set (Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Sections = A['Sections'];											-- Section (singular) is an alias of Chapter so set earlier
		local Inset = A['Inset'];
		
		if utilities.is_set ( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if utilities.is_set ( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif utilities.is_set ( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	local Others = A['Others'];
	if utilities.is_set (Others) and 0 == #a and 0 == #e then					-- add maint cat when |others= has value and used without |author=, |editor=
		if config.CitationClass == &quot;AV-media-notes&quot;
		or config.CitationClass == &quot;audio-visual&quot; then							-- special maint for AV/M which has a lot of 'false' positives right now
			utilities.set_message ('maint_others_avm')
		else
			utilities.set_message ('maint_others');
		end
	end
	Others = utilities.is_set (Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if utilities.is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if utilities.is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	local TitleNote = A['TitleNote'];
	TitleNote = utilities.is_set (TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if utilities.is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%n?%.?$') or Edition:match ('%f[%a][Ee]dition$') then -- Ed, ed, Ed., ed., Edn, edn, Edn., edn.
			utilities.set_message ('err_extra_text_edition');					 -- add error message
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = utilities.is_set (Series) and wrap_msg ('series', {sepc, Series}) or &quot;&quot;;	-- not the same as SeriesNum
	local Agency = A['Agency'] or '';											-- |agency= is supported by {{cite magazine}}, {{cite news}}, {{cite press release}}, {{cite web}}, and certain {{citation}} templates
	if utilities.is_set (Agency) then											-- this testing done here because {{citation}} supports 'news' citations
		if utilities.in_array (config.CitationClass, {'magazine', 'news', 'pressrelease', 'web'}) or ('citation' == config.CitationClass and utilities.in_array (Periodical_origin, {&quot;magazine&quot;, &quot;newspaper&quot;, &quot;work&quot;})) then
			Agency = wrap_msg ('agency', {sepc, Agency});						-- format for rendering
		else
			Agency = '';														-- unset; not supported
			utilities.set_message ('err_parameter_ignored', {'agency'});		-- add error message
		end
	end
	
	Volume = format_volume_issue (Volume, Issue, ArticleNumber, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	if utilities.is_set (AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = utilities.substitute (retrv_text, AccessDate);				-- add retrieved text

		AccessDate = utilities.substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if utilities.is_set (ID) then ID = sepc .. &quot; &quot; .. ID; end
	
	local Docket = A['Docket'];
   	if &quot;thesis&quot; == config.CitationClass and utilities.is_set (Docket) then
		ID = sepc .. &quot; Docket &quot; .. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and utilities.is_set (Docket) then		-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	if utilities.is_set (URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URL_origin, UrlAccess );
	end

	local Quote = A['Quote'];
	local TransQuote = A['TransQuote'];
	local ScriptQuote = A['ScriptQuote'];
	if utilities.is_set (Quote) or utilities.is_set (TransQuote) or utilities.is_set (ScriptQuote) then

		if utilities.is_set (Quote) then
			if Quote:sub(1, 1) == '&quot;' and Quote:sub(-1, -1) == '&quot;' then			-- if first and last characters of quote are quote marks
				Quote = Quote:sub(2, -2);										-- strip them off
			end
		end
		
		Quote = kern_quotes (Quote);											-- kern if needed
		Quote = utilities.wrap_style ('quoted-text', Quote );					-- wrap in &lt;q&gt;...&lt;/q&gt; tags
	
		if utilities.is_set (ScriptQuote) then
			Quote = script_concatenate (Quote, ScriptQuote, 'script-quote');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after quote is wrapped
		end

		if utilities.is_set (TransQuote) then
			if TransQuote:sub(1, 1) == '&quot;' and TransQuote:sub(-1, -1) == '&quot;' then -- if first and last characters of |trans-quote are quote marks
				TransQuote = TransQuote:sub(2, -2); -- strip them off
			end
			Quote = Quote .. &quot; &quot; .. utilities.wrap_style ('trans-quoted-title', TransQuote );
		end

		if utilities.is_set (QuotePage) or utilities.is_set (QuotePages) then	-- add page prefix
			local quote_prefix = '';
			if utilities.is_set (QuotePage) then
				extra_text_in_page_check (QuotePage, 'quote-page');				-- add to maint cat if |quote-page= value begins with what looks like p., pp., etc.
				if not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePage}), '', '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePage}), '', '', '';
				end
			elseif utilities.is_set (QuotePages) then
				extra_text_in_page_check (QuotePages, 'quote-pages');			-- add to maint cat if |quote-pages= value begins with what looks like p., pp., etc.
				if tonumber(QuotePages) ~= nil and not NoPP then				-- if only digits, assume single page
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePages}), '', '';
				elseif not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['pp-prefix'], {sepc, QuotePages}), '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePages}), '', '';
				end
			end
                        
			Quote = quote_prefix .. &quot;: &quot; .. Quote;
		else
			Quote = sepc .. &quot; &quot; .. Quote;
		end

		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	-- We check length of PostScript here because it will have been nuked by
	-- the quote parameters. We'd otherwise emit a message even if there wasn't
	-- a displayed postscript.
	-- TODO: Should the max size (1) be configurable?
	-- TODO: Should we check a specific pattern?
	if utilities.is_set(PostScript) and mw.ustring.len(PostScript) &gt; 1 then
		utilities.set_message ('maint_postscript')
	end
	
	local Archived;
	if utilities.is_set (ArchiveURL) then
		if not utilities.is_set (ArchiveDate) then								-- ArchiveURL set but ArchiveDate not set
			utilities.set_message ('err_archive_missing_date');					-- emit an error message
			ArchiveURL = '';													-- empty string for concatenation
			ArchiveDate = '';													-- empty string for concatenation
		end
	else														
		if utilities.is_set (ArchiveDate) then									-- ArchiveURL not set but ArchiveDate is set
			utilities.set_message ('err_archive_date_missing_url');				-- emit an error message
			ArchiveURL = '';													-- empty string for concatenation
			ArchiveDate = '';													-- empty string for concatenation
		end
	end

	if utilities.is_set (ArchiveURL) then
		local arch_text;
		if &quot;live&quot; == UrlStatus then
			arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if utilities.is_set (ArchiveDate) then
				Archived = sepc .. ' ' .. utilities.substitute ( cfg.messages['archived-live'],
					{external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil) .. ArchiveFormat, ArchiveDate } );
			else
				Archived = '';
			end
			if not utilities.is_set (OriginalURL) then
				utilities.set_message ('err_archive_missing_url');
				Archived = '';													-- empty string for concatenation
			end
		elseif utilities.is_set (OriginalURL) then								-- UrlStatus is empty, 'dead', 'unfit', 'usurped', 'bot: unknown'
			if utilities.in_array (UrlStatus, {'unfit', 'usurped', 'bot: unknown'}) then
				arch_text = cfg.messages['archived-unfit'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. ' ' .. arch_text .. ArchiveDate;				-- format already styled
				if 'bot: unknown' == UrlStatus then
					utilities.set_message ('maint_bot_unknown');				-- and add a category if not already added
				else
					utilities.set_message ('maint_unfit');						-- and add a category if not already added
				end
			else																-- UrlStatus is empty, 'dead'
				arch_text = cfg.messages['archived-dead'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				if utilities.is_set (ArchiveDate) then
					Archived = sepc .. &quot; &quot; .. utilities.substitute ( arch_text,
						{ external_link( OriginalURL, cfg.messages['original'], OriginalURL_origin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
				else
					Archived = '';												-- unset for concatenation
				end
			end	
		else																	-- OriginalUrl not set
			utilities.set_message ('err_archive_missing_url');
			Archived = '';														-- empty string for concatenation
		end
	elseif utilities.is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = '';
	end
	
	local TranscriptURL = A['TranscriptURL']
	local TranscriptFormat = A['TranscriptFormat'];
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');
	local Transcript = A['Transcript'];
	local TranscriptURL_origin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL
	if utilities.is_set (Transcript) then
		if utilities.is_set (TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURL_origin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif utilities.is_set (TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURL_origin, nil );
	end

	local Publisher;
	if utilities.is_set (PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if utilities.is_set (PublisherName) then
		if utilities.is_set (PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif utilities.is_set (PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical)) then
		if utilities.is_set (Title) or utilities.is_set (TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		else 
			Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		end
	end
	
	local Language = A['Language'];
	if utilities.is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc.
	else
		Language='';															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then									-- cite speech only
		TitleNote = TitleType;													-- move TitleType to TitleNote so that it renders ahead of |event=
		TitleType = '';															-- and unset

		if utilities.is_set (Periodical) then									-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if utilities.is_set (Conference) then								-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;							-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (Periodical) then		-- special cases for book cites
		if utilities.is_set (Contributors) then									-- when we are citing foreword, preface, introduction, etc.
			tcommon = safe_join ({Title, TitleNote}, sepc);						-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join ({TitleType, Series, Language, Volume, Others, Edition, Publisher}, sepc);
		else
			tcommon = safe_join ({Title, TitleNote, TitleType, Series, Language, Volume, Others, Edition, Publisher}, sepc);
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if utilities.is_set (Chapter) then										-- map in a book; TitleType is part of Chapter
			tcommon = safe_join ({Title, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc);
		elseif utilities.is_set (Periodical) then								-- map in a periodical
			tcommon = safe_join ({Title, TitleType, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc);
		else																	-- a sheet or stand-alone map
			tcommon = safe_join ({Title, TitleType, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc);
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join ({Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc);

	else																		-- all other CS1 templates
		tcommon = safe_join ({Title, TitleNote, Conference, Periodical, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc);
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local Via = A['Via'];
	Via = utilities.is_set (Via) and  wrap_msg ('via', Via) or '';
	local idcommon;
	if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then	-- special case for cite AV media &amp; cite episode position transcript
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, Quote }, sepc );
	else
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, Quote }, sepc );
	end
	
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	local OrigDate = A['OrigDate'];
	OrigDate = utilities.is_set (OrigDate) and wrap_msg ('origdate', OrigDate) or '';
	if utilities.is_set (Date) then
		if utilities.is_set (Authors) or utilities.is_set (Editors) then		-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date .. &quot;)&quot; .. OrigDate .. sepc .. &quot; &quot;;				-- in parentheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon, -1, -1) == sepc) then						-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigDate;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigDate;							-- Date begins with sepc
			end
		end
	end	
	if utilities.is_set (Authors) then
		if (not utilities.is_set (Date)) then									-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Editors) then
			local in_text = '';
			local post_text = '';
			if utilities.is_set (Chapter) and 0 == #c then
				in_text = cfg.messages['in'] .. ' ';
				if (sepc ~= '.') then
					in_text = in_text:lower();									-- lowercase for cs2
				end
			end
			if EditorCount &lt;= 1 then
				post_text = ' (' .. cfg.messages['editor'] .. ')';				-- be consistent with no-author, no-date case
			else
				post_text = ' (' .. cfg.messages['editors'] .. ')';
			end
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Contributors) then									-- book cite and we're citing the intro, preface, etc.
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if utilities.is_set (Editors) and utilities.is_set (Date) then		-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not utilities.is_set (Date)) then								-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif utilities.is_set (Editors) then
		if utilities.is_set (Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. cfg.presentation['sep_name'] .. cfg.messages['editor'];
			else
				Editors = Editors .. cfg.presentation['sep_name'] .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end

	if utilities.is_set (PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc ); 								-- Deals with italics, spaces, etc.
		if '.' == sepc then														-- remove final seperator if present
			text = text:gsub ('%' .. sepc .. '$', '');							-- dot must be escaped here
		else
			text = mw.ustring.gsub (text, sepc .. '$', '');						-- using ustring for non-dot sepc (likely a non-Latin character)
		end
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite&gt; element
	local options_t = {};
	options_t.class = cite_class_attribute_make (config.CitationClass, Mode);

	local Ref = is_valid_parameter_value (A['Ref'], A:ORIGIN('Ref'), cfg.keywords_lists['ref'], nil, true);	-- nil when |ref=harv; A['Ref'] else

	if 'none' ~= cfg.keywords_xlate[(Ref and Ref:lower()) or ''] then
		local namelist_t = {};													-- holds selected contributor, author, editor name list
		local year = first_set ({Year, anchor_year}, 2);						-- Year first for legacy citations and for YMD dates that require disambiguation

		if #c &gt; 0 then															-- if there is a contributor list
			namelist_t = c;														-- select it
		elseif #a &gt; 0 then														-- or an author list
			namelist_t = a;
		elseif #e &gt; 0 then														-- or an editor list
			namelist_t = e;
		end
		local citeref_id;
		if #namelist_t &gt; 0 then													-- if there are names in namelist_t
			citeref_id = make_citeref_id (namelist_t, year);					-- go make the CITEREF anchor
			if mw.uri.anchorEncode (citeref_id) == ((Ref and mw.uri.anchorEncode (Ref)) or '') then	-- Ref may already be encoded (by {{sfnref}}) so citeref_id must be encoded before comparison
				utilities.set_message ('maint_ref_duplicates_default');
			end
		else
			citeref_id = '';													-- unset
		end
		options_t.id = Ref or citeref_id;
	end

	if string.len (text:gsub('%b&lt;&gt;', '')) &lt;= 2 then								-- remove html and html-like tags; then get length of what remains; 
		z.error_cats_t = {};													-- blank the categories list
		z.error_msgs_t = {};													-- blank the error messages list
		OCinSoutput = nil;														-- blank the metadata string
		text = '';																-- blank the the citation
		utilities.set_message ('err_empty_citation');							-- set empty citation message and category
	end
	
	local render_t = {};														-- here we collect the final bits for concatenation into the rendered citation

	if utilities.is_set (options_t.id) then										-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render_t, utilities.substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options_t.id), mw.text.nowiki(options_t.class), text}));	-- when |ref= is set or when there is a namelist
	else
		table.insert (render_t, utilities.substitute (cfg.presentation['cite'], {mw.text.nowiki(options_t.class), text}));	-- when |ref=none or when namelist_t empty and |ref= is missing or is empty
	end		

	if OCinSoutput then															-- blanked when citation is 'empty' so don't bother to add boilerplate metadata span
		table.insert (render_t, utilities.substitute (cfg.presentation['ocins'], OCinSoutput));	-- format and append metadata to the citation
	end

	local template_name = ('citation' == config.CitationClass) and 'citation' or 'cite ' .. (cfg.citation_class_map_t[config.CitationClass] or config.CitationClass);
	local template_link = '[[Template:' .. template_name .. '|' .. template_name .. ']]';
	local msg_prefix = '&lt;code class=&quot;cs1-code&quot;&gt;{{' .. template_link .. '}}&lt;/code&gt;: ';

	if 0 ~= #z.error_msgs_t then
		mw.addWarning (utilities.substitute (cfg.messages.warning_msg_e, template_link));

		table.insert (render_t, ' ');											-- insert a space between citation and its error messages
		table.sort (z.error_msgs_t);											-- sort the error messages list; sorting includes wrapping &lt;span&gt; and &lt;code&gt; tags; hidden-error sorts ahead of visible-error

		local hidden = true;													-- presume that the only error messages emited by this template are hidden
		for _, v in ipairs (z.error_msgs_t) do									-- spin through the list of error messages
			if v:find ('cs1-visible-error', 1, true) then						-- look for the visible error class name
				hidden = false;													-- found one; so don't hide the error message prefix
				break;															-- and done because no need to look further
			end
		end

		z.error_msgs_t[1] = table.concat ({utilities.error_comment (msg_prefix, hidden), z.error_msgs_t[1]});	-- add error message prefix to first error message to prevent extraneous punctuation
		table.insert (render_t, table.concat (z.error_msgs_t, '; '));			-- make a big string of error messages and add it to the rendering
	end

	if 0 ~= #z.maint_cats_t then
		mw.addWarning (utilities.substitute (cfg.messages.warning_msg_m, template_link));

		table.sort (z.maint_cats_t);											-- sort the maintenance messages list

		local maint_msgs_t = {};												-- here we collect all of the maint messages

		if 0 == #z.error_msgs_t then											-- if no error messages
			table.insert (maint_msgs_t, msg_prefix);							-- insert message prefix in maint message livery
		end
		
		for _, v in ipairs( z.maint_cats_t ) do									-- append maintenance categories
			table.insert (maint_msgs_t, 										-- assemble new maint message and add it to the maint_msgs_t table
				table.concat ({v, ' (', utilities.substitute (cfg.messages[':cat wikilink'], v), ')'})
				);
		end
		table.insert (render_t, utilities.substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs_t, ' ')));	-- wrap the group of maint messages with proper presentation and save
	end

	if not no_tracking_cats then
		local sort_key;
		local cat_wikilink = 'cat wikilink';
		if cfg.enable_sort_keys then											-- when namespace sort keys enabled
			local namespace_number = mw.title.getCurrentTitle().namespace;		-- get namespace number for this wikitext
			sort_key = (0 ~= namespace_number and (cfg.name_space_sort_keys[namespace_number] or cfg.name_space_sort_keys.other)) or nil;	-- get sort key character; nil for mainspace
			cat_wikilink = (not sort_key and 'cat wikilink') or 'cat wikilink sk';	-- make &lt;cfg.messages&gt; key
		end				

		for _, v in ipairs (z.error_cats_t) do									-- append error categories
			table.insert (render_t, utilities.substitute (cfg.messages[cat_wikilink], {v, sort_key}));
		end
		for _, v in ipairs (z.maint_cats_t) do									-- append maintenance categories
			table.insert (render_t, utilities.substitute (cfg.messages[cat_wikilink], {v, sort_key}));
		end

		for _, v in ipairs (z.prop_cats_t) do									-- append properties categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));	-- no sort keys
		end
	end

	return table.concat (render_t);												-- make a big string and done
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class, empty)
	local name = tostring (name);
	local enum_name;															-- parameter name with enumerator (if any) replaced with '#'
	local state;
	local function state_test (state, name)										-- local function to do testing of state values
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			if empty then return nil; end										-- empty deprecated parameters are treated as unknowns
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
		if 'tracked' == state then
			local base_name = name:gsub ('%d', '');								-- strip enumerators from parameter names that have them to get the base name
			utilities.add_prop_cat ('tracked-param', {base_name}, base_name);	-- add a properties category; &lt;base_name&gt; modifies &lt;key&gt;
			return true;
		end
		return nil;
	end		

	if name:find ('#') then														-- # is a cs1|2 reserved character so parameters with # not permitted
		return nil;
	end
																				-- replace enumerator digit(s) with # (|last25= becomes |last#=) (mw.ustring because non-Western 'local' digits)
	enum_name = mw.ustring.gsub (name, '%d+$', '#');							-- where enumerator is last charaters in parameter name (these to protect |s2cid=)
	enum_name = mw.ustring.gsub (enum_name, '%d+([%-l])', '#%1');				-- where enumerator is in the middle of the parameter name; |author#link= is the oddity

	if 'document' == cite_class then											-- special case for {{cite document}}
		state = whitelist.document_parameters_t[enum_name];						-- this list holds enumerated and nonenumerated parameters
		if true == state_test (state, name) then return true; end
		
		return false;
	end

	if utilities.in_array (cite_class, whitelist.preprint_template_list_t) then	-- limited parameter sets allowed for these templates
		state = whitelist.limited_parameters_t[enum_name];						-- this list holds enumerated and nonenumerated parameters
		if true == state_test (state, name) then return true; end

		state = whitelist.preprint_arguments_t[cite_class][name];				-- look in the parameter-list for the template identified by cite_class
		if true == state_test (state, name) then return true; end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates

	if utilities.in_array (cite_class, whitelist.unique_param_template_list_t) then 	-- template-specific parameters for templates that accept parameters from the basic argument list
		state = whitelist.unique_arguments_t[cite_class][name];					-- look in the template-specific parameter-lists for the template identified by cite_class
		if true == state_test (state, name) then return true; end
	end																			-- if here, fall into general validation

	state = whitelist.common_parameters_t[enum_name];							-- all other templates; all normal parameters allowed; this list holds enumerated and nonenumerated parameters
	if true == state_test (state, name) then return true; end

	return false;																-- not supported because not found or name is set to nil
end


--[=[-------------------------&lt; I N T E R _ W I K I _ C H E C K &gt;----------------------------------------------

check &lt;value&gt; for inter-language interwiki-link markup.  &lt;prefix&gt; must be a MediaWiki-recognized language
code.  when these values have the form (without leading colon):
	[[&lt;prefix&gt;:link|label]] return label as plain-text
	[[&lt;prefix&gt;:link]] return &lt;prefix&gt;:link as plain-text

return value as is else

]=]

local function inter_wiki_check (parameter, value)
	local prefix = value:match ('%[%[(%a+):');									-- get an interwiki prefix if one exists
	local _;
	
	if prefix and cfg.inter_wiki_map[prefix:lower()] then						-- if prefix is in the map, needs preceding colon so
		utilities.set_message ('err_bad_paramlink', parameter);					-- emit an error message
		_, value, _ = utilities.is_wikilink (value);							-- extract label portion from wikilink
	end
	return value;
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe.  There are two tests made:
	{{cite ... |title=Title access-date=2016-03-17}}	-- the first parameter has a value and whitespace separates that value from the missing pipe parameter name
	{{cite ... |title=access-date=2016-03-17}}			-- the first parameter has no value (whitespace after the first = is trimmed by MediaWiki)
cs1|2 shares some parameter names with XML/HTML attributes: class=, title=, etc.  To prevent false positives XML/HTML
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (parameter, value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove XML/HTML tags because attributes: class=, title=, etc.

	capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then										-- if the capture is a valid parameter name
		utilities.set_message ('err_missing_pipe', parameter);
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ P U N C T &gt;--------------------------------------

look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_punc (param, value)
	if 'number' == type (param) then
		return;
	end
	
	param = param:gsub ('%d+', '#');											-- enumerated name-list mask params allow terminal punct; normalize 
	if cfg.punct_skip[param] then
		return;																	-- parameter name found in the skip table so done
	end
	
	if value:match ('[,;:]$') then
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
	if value:match ('^=') then													-- sometimes an extraneous '=' character appears ...
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ U R L &gt;------------------------------------------

look for extraneous url parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_url (url_param_t)
	local url_error_t = {};
	
	check_for_url (url_param_t, url_error_t);									-- extraneous url check
	if 0 ~= #url_error_t then													-- non-zero when there are errors
		table.sort (url_error_t);
		utilities.set_message ('err_param_has_ext_link', {utilities.make_sep_list (#url_error_t, url_error_t)});	-- add this error message
	end
end


--[[--------------------------&lt; C I T A T I O N &gt;--------------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

local function citation(frame)
	Frame = frame;																-- save a copy in case we need to display an error message in preview mode

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do											-- get parameters from the {{#invoke}} frame
		config[k] = v;
	--	args[k] = v;															-- crude debug support that allows us to render a citation from module {{#invoke:}}; skips parameter validation; TODO: keep?
	end	
																				-- i18n: set the name that your wiki uses to identify sandbox subpages from sandbox template invoke (or can be set here)
	local sandbox = ((config.SandboxPath and '' ~= config.SandboxPath) and config.SandboxPath) or '/sandbox';	-- sandbox path from {{#invoke:Citation/CS1/sandbox|citation|SandboxPath=/...}}
	is_sandbox = nil ~= string.find (frame:getTitle(), sandbox, 1, true);		-- is this invoke the sandbox module?
	sandbox = is_sandbox and sandbox or '';										-- use i18n sandbox to load sandbox modules when this module is the sandox; live modules else

	local pframe = frame:getParent()
	local styles;
	
	cfg = mw.loadData ('Module:Citation/CS1/Configuration' .. sandbox);			-- load sandbox versions of support modules when {{#invoke:Citation/CS1/sandbox|...}}; live modules else
	whitelist = mw.loadData ('Module:Citation/CS1/Whitelist' .. sandbox);
	utilities = require ('Module:Citation/CS1/Utilities' .. sandbox);
	validation = require ('Module:Citation/CS1/Date_validation' .. sandbox);
	identifiers = require ('Module:Citation/CS1/Identifiers' .. sandbox);
	metadata = require ('Module:Citation/CS1/COinS' .. sandbox);
	styles = 'Module:Citation/CS1' .. sandbox .. '/styles.css';

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the selected cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	is_preview_mode = not utilities.is_set (frame:preprocess ('{{REVISIONID}}'));

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text;															-- used as a flag

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	local empty_unknowns = {};													-- sequence table to hold empty unknown params for error message listing
	for k, v in pairs( pframe.args ) do											-- get parameters from the parent (template) frame
		v = mw.ustring.gsub (v, '^%s*(.-)%s*$', '%1');							-- trim leading/trailing whitespace; when v is only whitespace, becomes empty string
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				if type (k) ~= 'string' then									-- exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text = utilities.set_message ('err_text_ignored', {v});
					end
				elseif validate (k:lower(), config.CitationClass) then 
					error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, k:lower()});	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						suggestions = mw.loadData ('Module:Citation/CS1/Suggestions' .. sandbox);	--load sandbox version of suggestion module when {{#invoke:Citation/CS1/sandbox|...}}; live module else
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no capture in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = utilities.substitute (param, capture);		-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, param});	-- set the suggestion error message
							else
								error_text = utilities.set_message ('err_parameter_ignored', {k});	-- suggested param not supported by this template
								v = '';											-- unset
							end
						end
					end
					if not utilities.is_set (error_text) then					-- couldn't match with a pattern, is there an explicit suggestion?						
						if (suggestions.suggestions[ k:lower() ] ~= nil) and validate (suggestions.suggestions[ k:lower() ], config.CitationClass) then
							utilities.set_message ('err_parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]});
						else
							utilities.set_message ('err_parameter_ignored', {k});
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
			end

			args[k] = v;														-- save this parameter and its value

		elseif not utilities.is_set (v) then									-- for empty parameters
			if not validate (k, config.CitationClass, true) then				-- is this empty parameter a valid parameter
				k = ('' == k) and '(empty string)' or k;						-- when k is empty string (or was space(s) trimmed to empty string), replace with descriptive text
				table.insert (empty_unknowns, utilities.wrap_style ('parameter', k));	-- format for error message and add to the list
			end
																				-- crude debug support that allows us to render a citation from module {{#invoke:}} TODO: keep?
	--	elseif args[k] ~= nil or (k == 'postscript') then						-- when args[k] has a value from {{#invoke}} frame (we don't normally do that)
	--		args[k] = v;														-- overwrite args[k] with empty string from pframe.args[k] (template frame); v is empty string here
		end																		-- not sure about the postscript bit; that gets handled in parameter validation; historical artifact?
	end	

	if 0 ~= #empty_unknowns then												-- create empty unknown error message
		utilities.set_message ('err_param_unknown_empty', {
			1 == #empty_unknowns and '' or 's',
			utilities.make_sep_list (#empty_unknowns, empty_unknowns)
			});
	end

	local url_param_t = {};

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);											-- look for invisible characters
		end
		has_extraneous_punc (k, v);												-- look for extraneous terminal punctuation in parameter values
		missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?
		args[k] = inter_wiki_check (k, v);										-- when language interwiki-linked parameter missing leading colon replace with wiki-link label

		if 'string' == type (k) and not cfg.url_skip[k] then					-- when parameter k is not positional and not in url skip table
			url_param_t[k] = v;													-- make a parameter/value list for extraneous url check
		end
	end

	has_extraneous_url (url_param_t);											-- look for url in parameter values where a url does not belong

	return table.concat ({
		frame:extensionTag ('templatestyles', '', {src=styles}),
		citation0( config, args)
	});
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {citation = citation};</text>
      <sha1>hg2b1k0ag9k3jgjps3raeavqbua1l4x</sha1>
    </revision>
    <revision>
      <id>4756</id>
      <parentid>4755</parentid>
      <timestamp>2024-12-28T15:31:52Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4756</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="226986" sha1="38f2p9l79xumyl0w5rmbznp9nbeuvz5" xml:space="preserve">require ('strict');

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------

each of these counts against the Lua upvalue limit

]]

local validation;																-- functions in Module:Citation/CS1/Date_validation

local utilities;																-- functions in Module:Citation/CS1/Utilities
local z = {};																	-- table of tables in Module:Citation/CS1/Utilities

local identifiers;																-- functions and tables in Module:Citation/CS1/Identifiers
local metadata;																	-- functions in Module:Citation/CS1/COinS
local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;---------------

declare variables here that have page-wide scope that are not brought in from
other modules; that are created here and used here

]]

local added_deprecated_cat;														-- Boolean flag so that the category is added only once
local added_vanc_errs;															-- Boolean flag so we only emit one Vancouver error / category
local added_generic_name_errs;													-- Boolean flag so we only emit one generic name error / category and stop testing names once an error is encountered
local added_numeric_name_errs;													-- Boolean flag so we only emit one numeric name error / category and stop testing names once an error is encountered
local added_numeric_name_maint;													-- Boolean flag so we only emit one numeric name maint category and stop testing names once a category has been emitted
local Frame;																	-- holds the module's frame table
local is_preview_mode;															-- true when article is in preview mode; false when using 'Preview page with this template' (previewing the module)
local is_sandbox;																-- true when using sandbox modules to render citation


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if utilities.is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a Boolean declared in page scope variables above

]]

local function add_vanc_error (source, position)
	if added_vanc_errs then return end
		
	added_vanc_errs = true;														-- note that we've added this category
	utilities.set_message ('err_vancouver', {source, position});
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a URI scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of TLDs: https://www.iana.org/domains/root/db

RFC 952 (modified by RFC 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the TLD.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a URL with a scheme) will be stripped
here.  Perhaps not necessary but retained in case it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ASCII characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the TLD) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and TLD or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%w]') then											-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at Wikisource
		return false;
	end

	local patterns = {															-- patterns that look like URLs
		'%f[%w][%w][%w%-]+[%w]%.%a%a+$',										-- three or more character hostname.hostname or hostname.tld
		'%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$',									-- internationalized domain name with ACE prefix
		'%f[%a][qxz]%.com$',													-- assigned one character .com hostname (x.com times out 2015-12-10)
		'%f[%a][iq]%.net$',														-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		'%f[%w][%w]%.%a%a$',													-- one character hostname and ccTLD (2 chars)
		'%f[%w][%w][%w]%.%a%a+$',												-- two character hostname and TLD
		'^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?',								-- IPv4 address
		'[%a%d]+%:?'                                                            -- IPv6 address
		}

	for _, pattern in ipairs (patterns) do										-- loop through the patterns list
		if domain:match (pattern) then
			return true;														-- if a match then we think that this thing that purports to be a URL is a URL
		end
	end

	for _, d in ipairs (cfg.single_letter_2nd_lvl_domains_t) do					-- look for single letter second level domain names for these top level domains
		if domain:match ('%f[%w][%w]%.' .. d) then
			return true
		end
	end
	return false;																-- no matches, we don't know what this thing is
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a URL appear to be a valid URL; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if utilities.is_set (scheme) then											-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when URL is protocol-relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a URL into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following TLD) (if any) and any path(/), query(?) or fragment(#).

If protocol-relative URL, return nil scheme and domain else return nil for both scheme and domain.

When not protocol-relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Any URL that does not have news: scheme must have authority indicator (//).  TODO: are there other common schemes
like news: that don't use authority indicator?

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol-relative URL
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		if utilities.is_set (authority) then
			authority = authority:gsub ('//', '', 1);							-- replace place 1 pair of '/' with nothing;
			if utilities.is_set(authority) then									-- if anything left (1 or 3+ '/' where authority should be) then
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		else
			if not scheme:match ('^news:') then									-- except for news:..., MediaWiki won't link URLs that do not have authority indicator; TODO: a better way to do this test?
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link=, etc. for properly formatted content: no wikilinks, no URLs

Link parameters are to hold the title of a Wikipedia article, so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki URLs and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid URL (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid URL (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then                                          -- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from URL; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid URL
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wiki-linked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

check &lt;link&gt; for inter-language interwiki-link prefix.  prefix must be a MediaWiki-recognized language
code and must begin with a colon.

]]

local function link_title_ok (link, lorig, title, torig)
	local orig;
	if utilities.is_set (link) then 											-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		elseif link:match ('^%a+:') then										-- if the link is what looks like an interwiki
			local prefix = link:match ('^(%a+):'):lower();						-- get the interwiki prefix

			if cfg.inter_wiki_map[prefix] then									-- if prefix is in the map, must have preceding colon
				orig = lorig;													-- flag as error
			end
		end
	end

	if utilities.is_set (orig) then
		link = '';																-- unset
		utilities.set_message ('err_bad_paramlink', orig);						-- URL or wikilink in |title= with |title-link=;
	end
	
	return link;																-- link if ok, empty string else
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the URL into scheme and domain
portions, or for protocol-relative (//example.com) URLs, just the domain.  Use is_url() to validate the two
portions of the URL.  If both are valid, or for protocol-relative if domain is valid, return true, else false.

Because it is different from a standard URL, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper URL
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from URL;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a URL.  The test will also find external wikilinks
that use protocol-relative URLs. Also finds bare URLs.

The frontier pattern prevents a match on interwiki-links which are similar to scheme:path URLs.  The tests that
find bracketed URLs are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext. wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol-relative ext. wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare URL with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('//%S+') then											-- if protocol-relative bare URL: //yyyyy.zzz; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a URL
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list, error_list)
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a URL add an error message
			table.insert (error_list, utilities.wrap_style ('parameter', k));
		end
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		utilities.set_message ('err_wikilink_in_url', {});
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link (URL, label, source, access)
	local err_msg = '';
	local domain;
	local path;
	local base_url;

	if not utilities.is_set (label) then
		label = URL;
		if utilities.is_set (source) then
			utilities.set_message ('err_bare_url_missing_title', {utilities.wrap_style ('parameter', source)});
		else
			error (cfg.messages[&quot;bare_url_no_origin&quot;]);							-- programmer error; valid parameter name does not have matching meta-parameter
		end			
	end
	if not check_url (URL) then
		utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)});
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the URL into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['['] = '%5b', [']'] = '%5d'});			-- replace '[' and ']' with their percent-encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat ({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wiki-markup URL

	if utilities.is_set (access) then											-- access level (subscription, registration, limited)
		base_url = utilities.substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end

	return base_url;
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a Boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		utilities.set_message ('err_deprecated_params', {name});				-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wiki-markup) are not kerned.

Replaces Unicode quote marks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc.; not for book titles.

]=]

local function kern_quotes (str)
	local cap = '';
	local wl_type, label, link;

	wl_type, label, link = utilities.is_wikilink (str);							-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-left'], str);
			str = utilities.substitute (cfg.presentation['kern-right'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = utilities.substitute (cfg.presentation['kern-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label = mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label = mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap = mw.ustring.match (label, &quot;^([\&quot;\'][^\'].+)&quot;);						-- match leading double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-left'], cap);
		end
	
		cap = mw.ustring.match (label, &quot;^(.+[^\'][\&quot;\'])$&quot;)						-- match trailing double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-right'], cap);
		end
		
		if 2 == wl_type then
			str = utilities.make_wikilink (link, label);						-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin-based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate RTL languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO 639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO 639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title=, |script-chapter=, |script-&lt;periodical&gt;=

]]

local function format_script_value (script_value, script_param)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%l?%s*:') then									-- if first 3 or 4 non-space characters are script language prefix
		lang = script_value:match('^(%l%l%l?)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not utilities.is_set (lang) then
			utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['missing title part']});		-- prefix without 'title'; add error message
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_tag_remap[lang] or mw.language.fetchLanguageName( lang, cfg.this_wiki_code );	-- get language name so that we can use it to categorize
		if utilities.is_set (name) then											-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l+%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if utilities.in_array (lang, cfg.script_lang_codes) then
				utilities.add_prop_cat ('script', {name, lang})
			else
				utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['unknown language code']});	-- unknown script-language; add error message
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['invalid language code']});		-- invalid language code; add error message
			lang = '';															-- invalid so set lang to empty string
		end
	else
		utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['missing prefix']});				-- no language code prefix; add error message
	end
	script_value = utilities.substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is RTL

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script
value has been wrapped in &lt;bdi&gt; tags.

]]

local function script_concatenate (title, script, script_param)
	if utilities.is_set (script) then
		script = format_script_value (script, script_param);					-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; returns empty string on error
		if utilities.is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not utilities.is_set ( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return utilities.substitute ( msg, str );								-- including template text
	else
		return utilities.substitute ( cfg.messages[key], str );
	end		
end


--[[----------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;-------------------

Makes a Wikisource URL from Wikisource interwiki-link.  Returns the URL and appropriate
label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;
	local wikisource_prefix = table.concat ({'https://', cfg.this_wiki_code, '.wikisource.org/wiki/'});

	wl_type, D, L = utilities.is_wikilink (str);								-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 1 == wl_type then													-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end

	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable URL
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent-encoding of fragment marker
	end

	return ws_url, ws_label, L or D;											-- return proper URL or nil and a label or nil
end


--[[----------------&lt; F O R M A T _ P E R I O D I C A L &gt;-----------------------

Format the three periodical parameters: |script-&lt;periodical&gt;=, |&lt;periodical&gt;=,
and |trans-&lt;periodical&gt;= into a single Periodical meta-parameter.

]]

local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)

	if not utilities.is_set (periodical) then
		periodical = '';														-- to be safe for concatenation
	else
		periodical = utilities.wrap_style ('italic-title', periodical);			-- style 
	end

	periodical = script_concatenate (periodical, script_periodical, script_periodical_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (trans_periodical) then
		trans_periodical = utilities.wrap_style ('trans-italic-title', trans_periodical);
		if utilities.is_set (periodical) then
			periodical = periodical .. ' ' .. trans_periodical;
		else																	-- here when trans-periodical without periodical or script-periodical
			periodical = trans_periodical;
			utilities.set_message ('err_trans_missing_title', {'periodical'});
		end
	end

	return periodical;
end


--[[------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;---------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=,
and |chapter-url= into a single chapter meta- parameter (chapter_url_source used
for error messages).

]]

local function format_chapter_title (script_chapter, script_chapter_source, chapter, chapter_source, trans_chapter, trans_chapter_source, chapter_url, chapter_url_source, no_quotes, access)
	local ws_url, ws_label, L = wikisource_url_make (chapter);					-- make a wikisource URL and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', ' ');									-- replace underscore separators with space characters
		chapter = ws_label;
	end

	if not utilities.is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from module provided quote marks
			chapter = utilities.wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, script_chapter, script_chapter_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (chapter_url) then
		chapter = external_link (chapter_url, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');	-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if utilities.is_set (trans_chapter) then
		trans_chapter = utilities.wrap_style ('trans-quoted-title', trans_chapter);
		if utilities.is_set (chapter) then
			chapter = chapter .. ' ' .. trans_chapter;
		else																	-- here when trans_chapter without chapter or script-chapter
			chapter = trans_chapter;
			chapter_source = trans_chapter_source:match ('trans%-?(.+)');		-- when no chapter, get matching name from trans-&lt;param&gt;
			utilities.set_message ('err_trans_missing_title', {chapter_source});
		end
	end

	return chapter;
end


--[[----------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;-------------------

This function searches a parameter's value for non-printable or invisible characters.
The search stops at the first match.

This function will detect the visible replacement character when it is part of the Wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers
(gallery, math, pre, ref) and identifies them with a slightly different error message.
See also coins_cleanup().

Output of this function is an error message that identifies the character or the
Unicode group, or the stripmarker that was detected along with its position (or,
for multi-byte characters, the position of its first byte) in the parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local stripmarker;															-- boolean set true when a stripmarker is found

	capture = string.match (v, '[%w%p ]*');										-- test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no Unicode characters
		return;
	end

	for _, invisible_char in ipairs (cfg.invisible_chars) do
		local char_name = invisible_char[1];									-- the character or group name
		local pattern = invisible_char[2];										-- the pattern used to find it
		position, _, capture = mw.ustring.find (v, pattern);					-- see if the parameter value contains characters that match the pattern
		
		if position and (cfg.invisible_defs.zwj == capture) then				-- if we found a zero-width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- it's ok if one of the Indic scripts
				position = nil;													-- unset position
			elseif cfg.emoji_t[mw.ustring.codepoint (v, position+1)] then			-- is zwj followed by a character listed in emoji{}?
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and utilities.in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and cfg.invisible_defs.del == capture then	-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture and not (cfg.invisible_defs.del == capture or cfg.invisible_defs.zwj == capture) then
					err_msg = capture .. ' ' .. char_name;
				else
					err_msg = char_name .. ' ' .. 'character';
				end

				utilities.set_message ('err_invisible_char', {err_msg, utilities.wrap_style ('parameter', param), position});	-- add error message
				return;															-- and done with this parameter
			end
		end
	end
end


--[[-------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------

Argument wrapper.  This function provides support for argument mapping defined
in the configuration file so that multiple names can be transparently aliased to
single internal variable.

]]

local function argument_wrapper ( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function ( self, k )
			local dummy = self[k];												-- force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = utilities.select_one ( args, list, 'err_redundant_parameters' );
				if origin[k] == nil then
					origin[k] = '';												-- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] .. ': ' .. k);
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;-------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.
When date is DD MMMM YYYY or is MMMM DD, YYYY then wrap in nowrap span:
&lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap = '';
	local cap2 = '';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = utilities.substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = utilities.substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;---------------------

This function sets default title types (equivalent to the citation including
|type=&lt;default value&gt;) for those templates that have defaults. Also handles the
special case where it is desirable to omit the title type from the rendered citation
(|type=none).

]]

local function set_titletype (cite_class, title_type)
	if utilities.is_set (title_type) then
		if 'none' == cfg.keywords_xlate[title_type] then
			title_type = '';													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; S A F E _ J O I N &gt;-----------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'duplicate character'
		if 1 == #duplicate_char then											-- for single byte ASCII characters use the string library functions
			f.gsub = string.gsub
			f.match = string.match
			f.sub = string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub = mw.ustring.gsub
			f.match = mw.ustring.match
			f.sub = mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1, 1) == '&lt;' then										-- special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove HTML markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1, 1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc.?
				trim = false;
				end_chr = f.sub(str, -1, -1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr .. &quot;)&quot;				-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1, -2);									-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;''&quot; then		-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5, -1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;]]&quot; then		-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3, -1) == duplicate_char .. '&quot;]' then	-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2, -1) == duplicate_char .. &quot;]&quot; then	-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2, -1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1, -3);								-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains HTML markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows HTML markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value; 												-- add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;-----------------------------

returns true if suffix is properly formed Jr, Sr, or ordinal in the range 1–9.
Puncutation not allowed.

]]

local function is_suffix (suffix)
	if utilities.in_array (suffix, {'Jr', 'Sr', 'Jnr', 'Snr', '1st', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;-------------------

For Vancouver style, author/editor names are supposed to be rendered in Latin
(read ASCII) characters.  When a name uses characters that contain diacritical
marks, those characters are to be converted to the corresponding Latin
character. When a name is written using a non-Latin alphabet or logogram, that
name is to be transliterated into Latin characters. The module doesn't do this
so editors may/must.

This test allows |first= and |last= names to contain any of the letters defined
in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes.
	(http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;)
	or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written outside of the code editor and pasted here because the code editor
gets confused between character insertion point and cursor position. The test has
been rewritten to use decimal character escape sequence for the individual bytes
of the Unicode characters so that it is not necessary to use an external editor
to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first, suffix, position)
	if not suffix then
		if first:find ('[,%s]') then											-- when there is a space or comma, might be first name/initials + generational suffix
			first = first:match ('(.-)[,%s]+');									-- get name/initials
			suffix = first:match ('[,%s]+(.+)$');								-- get generational suffix
		end
	end
	if utilities.is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error (cfg.err_msg_supl.suffix, position);
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143\225\184\128-\225\187\191%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143\225\184\128-\225\187\191%-%s%'%.]*$&quot;) then
			add_vanc_error (cfg.err_msg_supl['non-Latin char'], position);
			return false;														-- not a string of Latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-style=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period.
See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc.) to be rendered
as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format
because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the
Unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials (first, position)
	if first:find (',', 1, true) then
		return first;															-- commas not allowed; abandon
	end

	local name, suffix = mw.ustring.match (first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match (first, &quot;^(%u+)$&quot;);								-- is it just initials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error (cfg.err_msg_supl.suffix, position);			-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word

	local initials_t, names_t = {}, {};											-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names_t = mw.text.split (first, '[%s%-]+');									-- split into a sequence of names and possible suffix

	while names_t[i] do															-- loop through the sequence
		if 1 &lt; i and names_t[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names_t[i] = names_t[i]:gsub ('%.', '');							-- remove terminal dot if present
			if is_suffix (names_t[i]) then										-- if a legitimate suffix
				table.insert (initials_t, ' ' .. names_t[i]);					-- add a separator space, insert at end of initials sequence
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials_t, mw.ustring.sub (names_t[i], 1, 1));		-- insert the initial at end of initials sequence
		end
		i = i + 1;																-- bump the counter
	end
			
	return table.concat (initials_t);											-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; I N T E R W I K I _ P R E F I X E N _ G E T &gt;----------------------------------

extract interwiki prefixen from &lt;value&gt;.  Returns two one or two values:
	false – no prefixen
	nil – prefix exists but not recognized
	project prefix, language prefix – when value has either of:
		:&lt;project&gt;:&lt;language&gt;:&lt;article&gt;
		:&lt;language&gt;:&lt;project&gt;:&lt;article&gt;
	project prefix, nil – when &lt;value&gt; has only a known single-letter prefix
	nil, language prefix – when &lt;value&gt; has only a known language prefix

accepts single-letter project prefixen: 'd' (wikidata), 's' (wikisource), and 'w' (wikipedia) prefixes; at this
writing, the other single-letter prefixen (b (wikibook), c (commons), m (meta), n (wikinews), q (wikiquote), and
v (wikiversity)) are not supported.

]]

local function interwiki_prefixen_get (value, is_link)
	if not value:find (':%l+:') then											-- if no prefix
		return false;															-- abandon; boolean here to distinguish from nil fail returns later
	end

	local prefix_patterns_linked_t = {											-- sequence of valid interwiki and inter project prefixen
		'^%[%[:([dsw]):(%l%l+):',												-- wikilinked; project and language prefixes
		'^%[%[:(%l%l+):([dsw]):',												-- wikilinked; language and project prefixes
		'^%[%[:([dsw]):',														-- wikilinked; project prefix
		'^%[%[:(%l%l+):',														-- wikilinked; language prefix
		}
		
	local prefix_patterns_unlinked_t = {										-- sequence of valid interwiki and inter project prefixen
		'^:([dsw]):(%l%l+):',													-- project and language prefixes
		'^:(%l%l+):([dsw]):',													-- language and project prefixes
		'^:([dsw]):',															-- project prefix
		'^:(%l%l+):',															-- language prefix
		}
	
	local cap1, cap2;
	for _, pattern in ipairs ((is_link and prefix_patterns_linked_t) or prefix_patterns_unlinked_t) do
		cap1, cap2 = value:match (pattern);
		if cap1 then
			break;																-- found a match so stop looking
		end
	end
	
	if cap1 and cap2 then														-- when both then :project:language: or :language:project: (both forms allowed)
		if 1 == #cap1 then														-- length == 1 then :project:language:
			if cfg.inter_wiki_map[cap2] then									-- is language prefix in the interwiki map?
				return cap1, cap2;												-- return interwiki project and interwiki language
			end
		else																	-- here when :language:project:
			if cfg.inter_wiki_map[cap1] then									-- is language prefix in the interwiki map?
				return cap2, cap1;												-- return interwiki project and interwiki language
			end
		end
		return nil;																-- unknown interwiki language
	elseif not (cap1 or cap2) then												-- both are nil?
		return nil;																-- we got something that looks like a project prefix but isn't; return fail
	elseif 1 == #cap1 then														-- here when one capture
		return cap1, nil;														-- length is 1 so return project, nil language
	else																		-- here when one capture and its length it more than 1
		if cfg.inter_wiki_map[cap1] then										-- is language prefix in the interwiki map?
			return nil, cap1;													-- return nil project, language
		end
	end
end


--[[--------------------------&lt; L I S T _ P E O P L E &gt;--------------------------

Formats a list of people (authors, contributors, editors, interviewers, translators) 

names in the list will be linked when
	|&lt;name&gt;-link= has a value
	|&lt;name&gt;-mask- does NOT have a value; masked names are presumed to have been
		rendered previously so should have been linked there

when |&lt;name&gt;-mask=0, the associated name is not rendered

]]

local function list_people (control, people, etal)
	local sep;
	local namesep;
	local format = control.format;
	local maximum = control.maximum;
	local name_list = {};

	if 'vanc' == format then													-- Vancouver-like name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between names is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between names is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub (-1, -1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if utilities.is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end		-- returned 0 is for EditorCount; not used for other names
	
	for i, person in ipairs (people) do
		if utilities.is_set (person.last) then
			local mask = person.mask;
			local one;
			local sep_one = sep;

			if utilities.is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			end
			
			if mask then
				local n = tonumber (mask);										-- convert to a number if it can be converted; nil else
				if n then
					one = 0 ~= n and string.rep(&quot;&amp;mdash;&quot;, n) or nil;			-- make a string of (n &gt; 0) mdashes, nil else, to replace name
					person.link = nil;											-- don't create link to name if name is replaces with mdash string or has been set nil
				else
					one = mask;													-- replace name with mask text (must include name-list separator)
					sep_one = &quot; &quot;;												-- modify name-list separator
				end
			else
				one = person.last;												-- get surname
				local first = person.first										-- get given name
				if utilities.is_set (first) then
					if (&quot;vanc&quot; == format) then									-- if Vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first, nil, i) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials (first, i);				-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
			end
			if utilities.is_set (person.link) then
				one = utilities.make_wikilink (person.link, one);				-- link author/editor
			end

			if one then															-- if &lt;one&gt; has a value (name, mdash replacement, or mask text replacement)
				local proj, tag = interwiki_prefixen_get (one, true);			-- get the interwiki prefixen if present
				if 'w' == proj and ('Wikipedia' == mw.site.namespaces.Project['name']) then
					proj = nil;													-- for stuff like :w:de:&lt;article&gt;, :w is unnecessary TODO: maint cat?
				end
				if proj then
					local proj_name = ({['d'] = 'Wikidata', ['s'] = 'Wikisource', ['w'] = 'Wikipedia'})[proj];	-- :w (wikipedia) for linking from a non-wikipedia project
					if proj_name then 
						one = one .. utilities.wrap_style ('interproj', proj_name);	-- add resized leading space, brackets, static text, language name
						utilities.add_prop_cat ('interproj-linked-name', proj);	-- categorize it; &lt;proj&gt; is sort key
						tag = nil;												-- unset; don't do both project and language
					end
				end
				if tag == cfg.this_wiki_code then
					tag = nil;													-- stuff like :en:&lt;article&gt; at en.wiki is pointless TODO: maint cat?
				end
				if tag then
					local lang = cfg.lang_tag_remap[tag] or cfg.mw_languages_by_tag_t[tag];
					if lang then												-- error messaging done in extract_names() where we know parameter names
						one = one .. utilities.wrap_style ('interwiki', lang);	-- add resized leading space, brackets, static text, language name
						utilities.add_prop_cat ('interwiki-linked-name', tag);	-- categorize it; &lt;tag&gt; is sort key
					end
				end

				table.insert (name_list, one);									-- add it to the list of names
				table.insert (name_list, sep_one);								-- add the proper name-list separator
			end
		end
	end

	local count = #name_list / 2;												-- (number of names + number of separators) divided by 2
	if 0 &lt; count then 
		if 1 &lt; count and not etal then
			if 'amp' == format then
				name_list[#name_list-2] = &quot; &amp; &quot;;								-- replace last separator with ampersand text
			elseif 'and' == format then
				if 2 == count then
					name_list[#name_list-2] = cfg.presentation.sep_nl_and;		-- replace last separator with 'and' text
				else
					name_list[#name_list-2] = cfg.presentation.sep_nl_end;		-- replace last separator with '(sep) and' text
				end
			end
		end
		name_list[#name_list] = nil;											-- erase the last separator
	end

	local result = table.concat (name_list);									-- construct list
	if etal and utilities.is_set (result) then									-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. cfg.messages['et al'];						-- we've got a last-first list and etal so add et al.
	end
	
	return result, count;														-- return name-list string and count of number of names (count used for editor names only)
end


--[[--------------------&lt; M A K E _ C I T E R E F _ I D &gt;-----------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise
returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that
order.  year is Year or anchor_year.

]]

local function make_citeref_id (namelist, year)
	local names={};							-- a table for the one to four names and year
	for i,v in ipairs (namelist) do			-- loop through the list and take up to the first four last names
		names[i] = v.last
		if i == 4 then break end			-- if four then done
	end
	table.insert (names, year);				-- add the year at the end
	local id = table.concat(names);			-- concatenate names and year for CITEREF id
	if utilities.is_set (id) then			-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;				-- add the CITEREF portion
	else
		return '';							-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; C I T E _ C L A S S _A T T R I B U T E _M A K E &gt;------------------------------

construct &lt;cite&gt; tag class attribute for this citation.

&lt;cite_class&gt; – config.CitationClass from calling template
&lt;mode&gt; – value from |mode= parameter

]]

local function cite_class_attribute_make (cite_class, mode)
	local class_t = {};
	table.insert (class_t, 'citation');											-- required for blue highlight
	if 'citation' ~= cite_class then
		table.insert (class_t, cite_class);										-- identify this template for user css
		table.insert (class_t, utilities.is_set (mode) and mode or 'cs1');		-- identify the citation style for user css or javascript
	else
		table.insert (class_t, utilities.is_set (mode) and mode or 'cs2');		-- identify the citation style for user css or javascript
	end
	for _, prop_key in ipairs (z.prop_keys_t) do
		table.insert (class_t, prop_key);										-- identify various properties for user css or javascript
	end

	return table.concat (class_t, ' ');											-- make a big string and done
end


--[[---------------------&lt; N A M E _ H A S _ E T A L &gt;--------------------------

Evaluates the content of name parameters (author, editor, etc.) for variations on
the theme of et al.  If found, the et al. is removed, a flag is set to true and
the function returns the modified name and the flag.

This function never sets the flag to false but returns its previous state because
it may have been set by previous passes through this function or by the associated
|display-&lt;names&gt;=etal parameter

]]

local function name_has_etal (name, etal, nocat, param)

	if utilities.is_set (name) then												-- name can be nil in which case just return
		local patterns = cfg.et_al_patterns; 									-- get patterns from configuration
		
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns
			if name:match (pattern) then										-- if this 'et al' pattern is found in name
				name = name:gsub (pattern, '');									-- remove the offending text
				etal = true;													-- set flag (may have been set previously here or by |display-&lt;names&gt;=etal)
				if not nocat then												-- no categorization for |vauthors=
					utilities.set_message ('err_etal', {param});				-- and set an error if not added
				end
			end
		end
	end

	return name, etal;
end


--[[---------------------&lt; N A M E _ I S _ N U M E R I C &gt;----------------------

Add an error message and category when &lt;name&gt; parameter value does not contain letters.  

Add a maintenance category when &lt;name&gt; parameter value has numeric characters mixed with characters that are 
not numeric characters; could be letters and/or punctuation characters.

This function will only emit one error and one maint message for the current template.  Does not emit both error
and maint messages/categories for the same parameter value.

returns nothing

]]

local function name_is_numeric (name, name_alias, list_name)
	local patterns = {
		'^%D+%d',																-- &lt;name&gt; must have digits preceded by other characters
		'^%D*%d+%D+',															-- &lt;name&gt; must have digits followed by other characters
		}

	if not added_numeric_name_errs and mw.ustring.match (name, '^[%A]+$') then	-- if we have not already set an error message and &lt;name&gt; does not have any alpha characters
		utilities.set_message ('err_numeric_names', name_alias);				-- add an error message
		added_numeric_name_errs = true;											-- set the flag so we emit only one error message
		return;																	-- when here no point in further testing; abandon
	end

	if not added_numeric_name_maint then										-- if we have already set a maint message
		for _, pattern in ipairs (patterns) do									-- spin through list of patterns
			if mw.ustring.match (name, pattern) then							-- digits preceded or followed by anything but digits; %D+ includes punctuation
				utilities.set_message ('maint_numeric_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
				added_numeric_name_maint = true;								-- set the flag so we emit only one maint message
				return;															-- when here no point in further testing; abandon
			end
		end
	end
end


--[[-----------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;------------------

Evaluates the content of last/surname (authors etc.) parameters for multiple names.
Multiple names are indicated if there is more than one comma or any &quot;unescaped&quot;
semicolons. Escaped semicolons are ones used as part of selected HTML entities.
If the condition is met, the function adds the multiple name maintenance category.

Same test for first except that commas should not appear in given names (MOS:JR says
that the generational suffix does not take a separator character).  Titles, degrees,
postnominals, affiliations, all normally comma separated don't belong in a citation.

&lt;name&gt; – name parameter value
&lt;list_name&gt; – AuthorList, EditorList, etc
&lt;limit&gt; – number of allowed commas; 1 (default) for surnames; 0 for given names

returns nothing

]]

local function name_has_mult_names (name, list_name, limit)
	local _, commas, semicolons, nbsps;
	limit = limit and limit or 1;
	if utilities.is_set (name) then
		_, commas = name:gsub (',', '');										-- count the number of commas
		_, semicolons = name:gsub (';', '');									-- count the number of semicolons
		-- nbsps probably should be its own separate count rather than merged in
		-- some way with semicolons because Lua patterns do not support the
		-- grouping operator that regex does, which means there is no way to add
		-- more entities to escape except by adding more counts with the new
		-- entities
		_, nbsps = name:gsub ('&amp;nbsp;','');										-- count nbsps
		
		-- There is exactly 1 semicolon per &amp;nbsp; entity, so subtract nbsps
		-- from semicolons to 'escape' them. If additional entities are added,
		-- they also can be subtracted.
		if limit &lt; commas or 0 &lt; (semicolons - nbsps) then
			utilities.set_message ('maint_mult_names', cfg.special_case_translation [list_name]);	-- add a maint message
		end
	end
end


--[=[-------------------------&lt; I S _ G E N E R I C &gt;----------------------------------------------------------

Compares values assigned to various parameters according to the string provided as &lt;item&gt; in the function call.
&lt;item&gt; can have on of two values:
	'generic_names' – for name-holding parameters: |last=, |first=, |editor-last=, etc
	'generic_titles' – for |title=

There are two types of generic tests.  The 'accept' tests look for a pattern that should not be rejected by the
'reject' test.  For example,
	|author=[[John Smith (author)|Smith, John]]
would be rejected by the 'author' reject test.  But piped wikilinks with 'author' disambiguation should not be
rejected so the 'accept' test prevents that from happening.  Accept tests are always performed before reject
tests.

Each of the 'accept' and 'reject' sequence tables hold tables for en.wiki (['en']) and local.wiki (['local'])
that each can hold a test sequence table  The sequence table holds, at index [1], a test pattern, and, at index
[2], a boolean control value.  The control value tells string.find() or mw.ustring.find() to do plain-text search (true)
or a pattern search (false).  The intent of all this complexity is to make these searches as fast as possible so
that we don't run out of processing time on very large articles.

Returns
	true when a reject test finds the pattern or string
	false when an accept test finds the pattern or string
	nil else

]=]

local function is_generic (item, value, wiki)
	local test_val;
	local str_lower = {															-- use string.lower() for en.wiki (['en']) and use mw.ustring.lower() or local.wiki (['local'])
		['en'] = string.lower,
		['local'] = mw.ustring.lower,
		}
	local str_find = {															-- use string.find() for en.wiki (['en']) and use mw.ustring.find() or local.wiki (['local'])
		['en'] = string.find,
		['local'] = mw.ustring.find,
		}

	local function test (val, test_t, wiki)										-- local function to do the testing; &lt;wiki&gt; selects lower() and find() functions
		val = test_t[2] and str_lower[wiki](value) or val;						-- when &lt;test_t[2]&gt; set to 'true', plaintext search using lowercase value
		return str_find[wiki] (val, test_t[1], 1, test_t[2]);					-- return nil when not found or matched
	end
		
	local test_types_t = {'accept', 'reject'};									-- test accept patterns first, then reject patterns
	local wikis_t = {'en', 'local'};											-- do tests for each of these keys; en.wiki first, local.wiki second

	for _, test_type in ipairs (test_types_t) do								-- for each test type
		for _, generic_value in pairs (cfg.special_case_translation[item][test_type]) do	-- spin through the list of generic value fragments to accept or reject
			for _, wiki in ipairs (wikis_t) do
				if generic_value[wiki] then
					if test (value, generic_value[wiki], wiki) then				-- go do the test
						return ('reject' == test_type);							-- param value rejected, return true; false else
					end
				end
			end
		end
	end
end


--[[--------------------------&lt; N A M E _ I S _ G E N E R I C &gt;------------------------------------------------

calls is_generic() to determine if &lt;name&gt; is a 'generic name' listed in cfg.generic_names; &lt;name_alias&gt; is the
parameter name used in error messaging

]]

local function name_is_generic (name, name_alias)
	if not added_generic_name_errs  and is_generic ('generic_names', name) then
		utilities.set_message ('err_generic_name', name_alias);					-- set an error message
		added_generic_name_errs = true;
	end
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------

This function calls various name checking functions used to validate the content of the various name-holding parameters.

]]

local function name_checks (last, first, list_name, last_alias, first_alias)
	local accept_name;

	if utilities.is_set (last) then
		last, accept_name = utilities.has_accept_as_written (last);				-- remove accept-this-as-written markup when it wraps all of &lt;last&gt;

		if not accept_name then													-- &lt;last&gt; not wrapped in accept-as-written markup
			name_has_mult_names (last, list_name);								-- check for multiple names in the parameter
			name_is_numeric (last, last_alias, list_name);						-- check for names that have no letters or are a mix of digits and other characters
			name_is_generic (last, last_alias);									-- check for names found in the generic names list
		end
	end

	if utilities.is_set (first) then
		first, accept_name = utilities.has_accept_as_written (first);			-- remove accept-this-as-written markup when it wraps all of &lt;first&gt;

		if not accept_name then													-- &lt;first&gt; not wrapped in accept-as-written markup
			name_has_mult_names (first, list_name, 0);							-- check for multiple names in the parameter; 0 is number of allowed commas in a given name
			name_is_numeric (first, first_alias, list_name);					-- check for names that have no letters or are a mix of digits and other characters
			name_is_generic (first, first_alias);								-- check for names found in the generic names list
		end
		local wl_type, D = utilities.is_wikilink (first);
		if 0 ~= wl_type then
			first = D;
			utilities.set_message ('err_bad_paramlink', first_alias);
		end
	end

	return last, first;															-- done
end


--[[----------------------&lt; E X T R A C T _ N A M E S &gt;-------------------------

Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters
(or their aliases), and their matching link and mask parameters. Stops searching
when both |lastn= and |firstn= are not found in args after two sequential attempts:
found |last1=, |last2=, and |last3= but doesn't find |last4= and |last5= then the
search is done.

This function emits an error message when there is a |firstn= without a matching
|lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not
required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.'
is stripped from the parameter and a flag (etal) returned that will cause list_people()
to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps
'et al.' out of the template's metadata.  When this occurs, an error is emitted.

]]

local function extract_names(args, list_name)
	local names = {};															-- table of names
	local last;																	-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;																-- loop counter/indexer
	local n = 1;																-- output table indexer
	local count = 0;															-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal = false;															-- return value set to true when we find some form of et al. in an author parameter

	local last_alias, first_alias, link_alias;									-- selected parameter aliases used in error messaging
	while true do
		last, last_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'err_redundant_parameters', i );		-- search through args for name components beginning at 1
		first, first_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'err_redundant_parameters', i );
		link, link_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i );
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
	
		if last then															-- error check |lastn= alias for unknown interwiki link prefix; done here because this is where we have the parameter name
			local project, language = interwiki_prefixen_get (last, true);		-- true because we expect interwiki links in |lastn= to be wikilinked
			if nil == project and nil == language then							-- when both are nil
				utilities.set_message ('err_bad_paramlink', last_alias);		-- not known, emit an error message	-- TODO: err_bad_interwiki?
				last = utilities.remove_wiki_link (last);						-- remove wikilink markup; show display value only
			end
		end
		
		if link then															-- error check |linkn= alias for unknown interwiki link prefix
			local project, language = interwiki_prefixen_get (link, false);		-- false because wiki links in |author-linkn= is an error
			if nil == project and nil == language then							-- when both are nil
				utilities.set_message ('err_bad_paramlink', link_alias);		-- not known, emit an error message	-- TODO: err_bad_interwiki?
				link = nil;														-- unset so we don't link
				link_alias = nil;
			end
		end
		
		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.
		last, first = name_checks (last, first, list_name, last_alias, first_alias);						-- multiple names, extraneous annotation, etc. checks

		if first and not last then												-- if there is a firstn without a matching lastn
			local alias = first_alias:find ('given', 1, true) and 'given' or 'first';	-- get first or given form of the alias
			utilities.set_message ('err_first_missing_last', {
				first_alias,													-- param name of alias missing its mate
				first_alias:gsub (alias, {['first'] = 'last', ['given'] = 'surname'}),	-- make param name appropriate to the alias form
				});																-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			local result;
			link = link_title_ok (link, link_alias, last, last_alias);			-- check for improper wiki-markup

			if first then
				link = link_title_ok (link, link_alias, first, first_alias);	-- check for improper wiki-markup
			end

			names[n] = {last = last, first = first, link = link, mask = mask, corporate = false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				utilities.set_message ('err_missing_name', {list_name:match (&quot;(%w+)List&quot;):lower(), i - 1});	-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names and the etal flag
end


--[[--------------------------&lt; N A M E _ T A G _ G E T &gt;------------------------------------------------------

attempt to decode |language=&lt;lang_param&gt; and return language name and matching tag; nil else.

This function looks for:
	&lt;lang_param&gt; as a tag in cfg.lang_tag_remap{}
	&lt;lang_param&gt; as a name in cfg.lang_name_remap{}
	
	&lt;lang_param&gt; as a name in cfg.mw_languages_by_name_t
	&lt;lang_param&gt; as a tag in cfg.mw_languages_by_tag_t
when those fail, presume that &lt;lang_param&gt; is an IETF-like tag that MediaWiki does not recognize.  Strip all
script, region, variant, whatever subtags from &lt;lang_param&gt; to leave just a two or three character language tag
and look for the new &lt;lang_param&gt; in cfg.mw_languages_by_tag_t{}

on success, returns name (in properly capitalized form) and matching tag (in lowercase); on failure returns nil

]]

local function name_tag_get (lang_param)
	local lang_param_lc = mw.ustring.lower (lang_param);						-- use lowercase as an index into the various tables
	local name;
	local tag;

	name = cfg.lang_tag_remap[lang_param_lc];									-- assume &lt;lang_param_lc&gt; is a tag; attempt to get remapped language name 
	if name then																-- when &lt;name&gt;, &lt;lang_param&gt; is a tag for a remapped language name
		if cfg.lang_name_remap[name:lower()][2] ~= lang_param_lc then
			utilities.set_message ('maint_unknown_lang');						-- add maint category if not already added
			return name, cfg.lang_name_remap[name:lower()][2];					-- so return name and tag from lang_name_remap[name]; special case to xlate sr-ec and sr-el to sr-cyrl and sr-latn
		end
		return name, lang_param_lc;												-- so return &lt;name&gt; from remap and &lt;lang_param_lc&gt;
	end

	tag = lang_param_lc:match ('^(%a%a%a?)%-.*');								-- still assuming that &lt;lang_param_lc&gt; is a tag; strip script, region, variant subtags
	name = cfg.lang_tag_remap[tag];												-- attempt to get remapped language name with language subtag only
	if name then																-- when &lt;name&gt;, &lt;tag&gt; is a tag for a remapped language name
		return name, tag;														-- so return &lt;name&gt; from remap and &lt;tag&gt;
	end

	if cfg.lang_name_remap[lang_param_lc] then									-- not a remapped tag, assume &lt;lang_param_lc&gt; is a name; attempt to get remapped language tag 
		return cfg.lang_name_remap[lang_param_lc][1], cfg.lang_name_remap[lang_param_lc][2];	-- for this &lt;lang_param_lc&gt;, return a (possibly) new name and appropriate tag
	end

	name = cfg.mw_languages_by_tag_t[lang_param_lc];							-- assume that &lt;lang_param_lc&gt; is a tag; attempt to get its matching language name
	
	if name then
		return name, lang_param_lc;												-- &lt;lang_param_lc&gt; is a tag so return it and &lt;name&gt;
	end
	
	tag = cfg.mw_languages_by_name_t[lang_param_lc];							-- assume that &lt;lang_param_lc&gt; is a language name; attempt to get its matching tag
	
	if tag then
		return cfg.mw_languages_by_tag_t[tag], tag;								-- &lt;lang_param_lc&gt; is a name so return the name from the table and &lt;tag&gt;
	end

	tag = lang_param_lc:match ('^(%a%a%a?)%-.*');								-- is &lt;lang_param_lc&gt; an IETF-like tag that MediaWiki doesn't recognize? &lt;tag&gt; gets the language subtag; nil else

	if tag then
		name = cfg.mw_languages_by_tag_t[tag];									-- attempt to get a language name using the shortened &lt;tag&gt;
		if name then
			return name, tag;													-- &lt;lang_param_lc&gt; is an unrecognized IETF-like tag so return &lt;name&gt; and language subtag
		end
	end
end


--[[-------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code
is recognized by MediaWiki, use the returned name; if not, then use the value that
was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is
assigned to the category for that code: Category:Norwegian-language sources (no).
For valid three-character code languages, the page is assigned to the single category
for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does
not recognize three-character equivalents of two-character codes: code 'ar' is
recognized but code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th
where the language names or codes are separated from each other by commas with
optional space characters.

]]

local function language_parameter (lang)
	local tag;																	-- some form of IETF-like language tag; language subtag with optional region, sript, vatiant, etc subtags
	local lang_subtag;															-- ve populates |language= with mostly unecessary region subtags the MediaWiki does not recognize; this is the base language subtag
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_t = {};															-- table made from the value assigned to |language=

	local this_wiki_name = mw.language.fetchLanguageName (cfg.this_wiki_code, cfg.this_wiki_code);	-- get this wiki's language name

	names_t = mw.text.split (lang, '%s*,%s*');									-- names should be a comma separated list

	for _, lang in ipairs (names_t) do											-- reuse lang here because we don't yet know if lang is a language name or a language tag
		name, tag = name_tag_get (lang);										-- attempt to get name/tag pair for &lt;lang&gt;; &lt;name&gt; has proper capitalization; &lt;tag&gt; is lowercase

		if utilities.is_set (tag) then
			lang_subtag = tag:gsub ('^(%a%a%a?)%-.*', '%1');					-- for categorization, strip any IETF-like tags from language tag

			if cfg.this_wiki_code ~= lang_subtag then							-- when the language is not the same as this wiki's language
				if 2 == lang_subtag:len() then									-- and is a two-character tag
					utilities.add_prop_cat ('foreign-lang-source', {name, tag}, lang_subtag);		-- categorize it; tag appended to allow for multiple language categorization
				else															-- or is a recognized language (but has a three-character tag)
					utilities.add_prop_cat ('foreign-lang-source-2', {lang_subtag}, lang_subtag);			-- categorize it differently TODO: support multiple three-character tag categories per cs1|2 template?
				end
			elseif cfg.local_lang_cat_enable then								-- when the language and this wiki's language are the same and categorization is enabled
				utilities.add_prop_cat ('local-lang-source', {name, lang_subtag});		-- categorize it
			end
		else
			name = lang;														-- return whatever &lt;lang&gt; has so that we show something
			utilities.set_message ('maint_unknown_lang');						-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
 
	name = utilities.make_sep_list (#language_list, language_list);
	if (1 == #language_list) and (lang_subtag == cfg.this_wiki_code) then		-- when only one language, find lang name in this wiki lang name; for |language=en-us, 'English' in 'American English'
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[-----------------------&lt; S E T _ C S _ S T Y L E &gt;--------------------------

Gets the default CS style configuration for the given mode.
Returns default separator and either postscript as passed in or the default.
In CS1, the default postscript and separator are '.'.
In CS2, the default postscript is the empty string and the default separator is ','.

]]

local function set_cs_style (postscript, mode)
	if utilities.is_set(postscript) then
		-- emit a maintenance message if user postscript is the default cs1 postscript
		-- we catch the opposite case for cs2 in set_style
		if mode == 'cs1' and postscript == cfg.presentation['ps_' .. mode] then
			utilities.set_message ('maint_postscript');
		end
	else
		postscript = cfg.presentation['ps_' .. mode];
	end
	return cfg.presentation['sep_' .. mode], postscript;
end


--[[--------------------------&lt; S E T _ S T Y L E &gt;-----------------------------

Sets the separator and postscript styles. Checks the |mode= first and the
#invoke CitationClass second. Removes the postscript if postscript == none.

]]

local function set_style (mode, postscript, cite_class)
	local sep;
	if 'cs2' == mode then
		sep, postscript = set_cs_style (postscript, 'cs2');
	elseif 'cs1' == mode then
		sep, postscript = set_cs_style (postscript, 'cs1');
	elseif 'citation' == cite_class	then
		sep, postscript = set_cs_style (postscript, 'cs2');
	else
		sep, postscript = set_cs_style (postscript, 'cs1');
	end

	if cfg.keywords_xlate[postscript:lower()] == 'none' then
		-- emit a maintenance message if user postscript is the default cs2 postscript
		-- we catch the opposite case for cs1 in set_cs_style
		if 'cs2' == mode or ('cs1' ~= mode and 'citation' == cite_class) then	-- {{citation |title=Title |mode=cs1 |postscript=none}} should not emit maint message
			utilities.set_message ('maint_postscript');
		end
		postscript = '';
	end
	
	return sep, postscript
end


--[=[-------------------------&lt; I S _ P D F &gt;-----------------------------------

Determines if a URL has the file extension that is one of the PDF file extensions
used by [[MediaWiki:Common.css]] when applying the PDF icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or
		url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
		url:match ('%.PDF&amp;#035') or url:match ('%.pdf&amp;#035');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;-----------------------

Applies CSS style to |format=, |chapter-format=, etc.  Also emits an error message
if the format parameter does not have a matching URL parameter.  If the format parameter
is not set and the URL contains a file extension that is recognized as a PDF document
by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if utilities.is_set (format) then
		format = utilities.wrap_style ('format', format);						-- add leading space, parentheses, resize
		if not utilities.is_set (url) then
			utilities.set_message ('err_format_missing_url', {fmt_param, url_param});	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if URL is a PDF file then
		format = utilities.wrap_style ('format', 'PDF');						-- set format to PDF
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[---------------------&lt; G E T _ D I S P L A Y _ N A M E S &gt;------------------

Returns a number that defines the number of names displayed for author and editor
name lists and a Boolean flag to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero,
return the number and the previous state of the 'etal' flag (false by default
but may have been set to true if the name list contains some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number
that is one greater than the number of authors in the list and set the 'etal' flag true.
This will cause the list_people() to display all of the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors'], etc; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

This function sets an error message when |display-xxxxors= value greater than or equal to number of names but
not when &lt;max&gt; comes from {{cs1 config}} global settings.  When using global settings, &lt;param&gt; is set to the
keyword 'cs1 config' which is used to supress the normal error.  Error is suppressed because it is to be expected
that some citations in an article will have the same or fewer names that the limit specified in {{cs1 config}}.

]]

local function get_display_names (max, count, list_name, etal, param)
	if utilities.is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if (max &gt;= count) and ('cs1 config' ~= param) then					-- error when local |display-xxxxors= value greater than or equal to number of names; not an error when using global setting
				utilities.set_message ('err_disp_name', {param, max});			-- add error message
				max = nil;
			end
		else																	-- not a valid keyword or number
			utilities.set_message ('err_disp_name', {param, max});				-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[----------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;---------------

Adds error if |page=, |pages=, |quote-page=, |quote-pages= has what appears to be
some form of p. or pp. abbreviation in the first characters of the parameter content.

check page for extraneous p, p., pp, pp., pg, pg. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when page begins PX or P# but not Px
		      where x and X are letters and # is a digit
	bad pattern:  '^[Pp][PpGg]' matches when page begins pp, pP, Pp, PP, pg, pG, Pg, PG

]]

local function extra_text_in_page_check (val, name)
	if not val:match (cfg.vol_iss_pg_patterns.good_ppattern) then
		for _, pattern in ipairs (cfg.vol_iss_pg_patterns.bad_ppatterns) do		-- spin through the selected sequence table of patterns
			if val:match (pattern) then											-- when a match, error so
				utilities.set_message ('err_extra_text_pages', name);	 		-- add error message
				return;															-- and done
			end
		end
	end		
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ V O L _ I S S _ C H E C K &gt;------------------------

Adds error if |volume= or |issue= has what appears to be some form of redundant 'type' indicator.  Applies to
both; this function looks for issue text in both |issue= and |volume= and looks for volume-like text in |voluem=
and |issue=.

For |volume=:
	'V.', or 'Vol.' (with or without the dot) abbreviations or 'Volume' in the first characters of the parameter
	content (all case insensitive). 'V' and 'v' (without the dot) are presumed to be roman numerals so
	are allowed.

For |issue=:
	'No.', 'I.', 'Iss.' (with or without the dot) abbreviations, or 'Issue' in the first characters of the
	parameter content (all case insensitive); numero styling: 'n°' with degree sign U+00B0, and № precomposed
	numero sign U+2116.
	
Single character values ('v', 'i', 'n') allowed when not followed by separator character ('.', ':', '=', or
whitespace character) – param values are trimmed of whitespace by MediaWiki before delivered to the module.
	
&lt;val&gt; is |volume= or |issue= parameter value
&lt;name&gt; is |volume= or |issue= parameter name for error message
&lt;selector&gt; is 'v' for |volume=, 'i' for |issue=

sets error message on failure; returns nothing

]]

local function extra_text_in_vol_iss_check (val, name, selector)
	if not utilities.is_set (val) then
		return;
	end
	
	local handler = 'v' == selector and 'err_extra_text_volume' or 'err_extra_text_issue';
	val = val:lower();															-- force parameter value to lower case

	for _, pattern in ipairs (cfg.vol_iss_pg_patterns.vi_patterns_t) do			-- spin through the sequence table of patterns
		if val:match (pattern) then												-- when a match, error so
			utilities.set_message (handler, name);								-- add error message
			return;																-- and done
		end
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parentheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a placeholder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parentheses
			local name = name_table[i];
			i = i + 1;															-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parentheses
					break;														-- and done reassembling so
				end
				i = i + 1;														-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = utilities.is_wikilink (name_table[i]);		-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i + 1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled parentheses ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the Vancouver error when a required comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		first = '';																-- set to empty string for concatenation and because it may have been set for previous author/editor
		local accept_name;
		v_name, accept_name = utilities.has_accept_as_written (v_name);			-- remove accept-this-as-written markup when it wraps all of &lt;v_name&gt;

		if accept_name then
			last = v_name;
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error (cfg.err_msg_supl.punctuation, i);
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s+&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be initials or generational suffix

			if not mw.ustring.match (first, '^%u+$') then						-- mw.ustring here so that later we will catch non-Latin characters
				suffix = first;													-- not initials so assume that whatever we got is a generational suffix
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end
			last = table.concat(lastfirstTable, ' ')							-- returns a string that is the concatenation of all other names that are not initials and generational suffix
			if not utilities.is_set (last) then
				first = '';														-- unset
				last = v_name;													-- last empty because something wrong with first
				add_vanc_error (cfg.err_msg_supl.name, i);
			end
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error (cfg.err_msg_supl['missing comma'], i);			-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- matches a space between two initials
			end
		else
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
		
		if utilities.is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first, suffix, i);							-- check first and last before restoring the suffix which may have a non-Latin digit
			if utilities.is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '', nil, i);
			end
		end

		link = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i ) or v_link_table[i];
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate = corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest;
|editorn= (and aliases) highest and |veditors= lowest (support for |editors= withdrawn)

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
	local lastfirst = false;
	if utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice in case we have a |first1= without a |last1=; this ...
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or		-- ... also catches the case where |first= is used with |vauthors=
		utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst = true;
	end

	if (utilities.is_set (vxxxxors) and true == lastfirst) or					-- these are the three error conditions
		(utilities.is_set (vxxxxors) and utilities.is_set (xxxxors)) or
		(true == lastfirst and utilities.is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			utilities.set_message ('err_redundant_parameters', err_name .. '-name-list parameters');	-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if utilities.is_set (vxxxxors) then return 2 end;
	if utilities.is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, live, dead, etc.).  When the parameter value has not been assigned a value (missing
or empty in the source template) the function returns the value specified by ret_val.  If the parameter value is one
of the list of allowed values returns the translated value; else, emits an error message and returns the value
specified by ret_val.

TODO: explain &lt;invert&gt;

]]

local function is_valid_parameter_value (value, name, possible, ret_val, invert)
	if not utilities.is_set (value) then
		return ret_val;															-- an empty parameter is ok
	end

	if (not invert and utilities.in_array (value, possible)) then				-- normal; &lt;value&gt; is in &lt;possible&gt; table
		return cfg.keywords_xlate[value];										-- return translation of parameter keyword
	elseif invert and not utilities.in_array (value, possible) then				-- invert; &lt;value&gt; is not in &lt;possible&gt; table
		return value;															-- return &lt;value&gt; as it is
	else
		utilities.set_message ('err_invalid_param_val', {name, value});			-- not an allowed value so add error message
		return ret_val;
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list, -3, -1) == sepc .. '. ') then					-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list, -1, -1) == sepc) or (string.sub (name_list, -3, -1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terminate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;-----------------------------------------

returns the concatenation of the formatted volume and issue (or journal article number) parameters as a single
string; or formatted volume or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, article, cite_class, origin, sepc, lower)
	if not utilities.is_set (volume) and not utilities.is_set (issue) and not utilities.is_set (article) then
		return '';
	end

	-- same condition as in format_pages_sheets()
	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);

	local is_numeric_vol = volume and (volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$'));	-- is only uppercase roman numerals or only digits?
	local is_long_vol = volume and (4 &lt; mw.ustring.len(volume));				-- is |volume= value longer than 4 characters?
	
	if volume and (not is_numeric_vol and is_long_vol) then						-- when not all digits or Roman numerals, is |volume= longer than 4 characters?
		utilities.add_prop_cat ('long-vol');									-- yes, add properties cat
	end

	if is_journal then															-- journal-style formatting
		local vol = '';

		if utilities.is_set (volume) then
			if is_numeric_vol then												-- |volume= value all digits or all uppercase Roman numerals?
				vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, volume});	-- render in bold face
			elseif is_long_vol then												-- not all digits or Roman numerals; longer than 4 characters?
				vol = utilities.substitute (cfg.messages['j-vol'], {sepc, utilities.hyphen_to_dash (volume)});	-- not bold
			else																-- four or fewer characters
				vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, utilities.hyphen_to_dash (volume)});	-- bold
			end
		end
		vol = vol .. (utilities.is_set (issue) and utilities.substitute (cfg.messages['j-issue'], issue) or '')
		vol = vol .. (utilities.is_set (article) and utilities.substitute (cfg.messages['j-article-num'], article) or '')
		return vol;
	end
	
	if 'podcast' == cite_class and utilities.is_set (issue) then
		return wrap_msg ('issue', {sepc, issue}, lower);
	end
	
	if 'conference' == cite_class and utilities.is_set (article) then			-- |article-number= supported only in journal and conference cites
		if utilities.is_set (volume) and utilities.is_set (article) then		-- both volume and article number
			return wrap_msg ('vol-art', {sepc, utilities.hyphen_to_dash (volume), article}, lower);
		elseif utilities.is_set (article) then									-- article number alone; when volume alone, handled below
			return wrap_msg ('art', {sepc, article}, lower);
		end
	end

	-- all other types of citation
	if utilities.is_set (volume) and utilities.is_set (issue) then
		return wrap_msg ('vol-no', {sepc, utilities.hyphen_to_dash (volume), issue}, lower);
	elseif utilities.is_set (volume) then
		return wrap_msg ('vol', {sepc, utilities.hyphen_to_dash (volume)}, lower);
	else
		return wrap_msg ('issue', {sepc, issue}, lower);
	end
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if utilities.is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif utilities.is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if utilities.is_set (page) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return utilities.substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return utilities.substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif utilities.is_set (pages) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then							-- if pages is only digits, assume a single page number
			return '', utilities.substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', utilities.substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', utilities.substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to Wikisource, returns the label portion of the interwiki-link as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki-link to an external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, page_orig, pages, pages_orig, at)
	local ws_url, ws_label, coins_pages, L;										-- for Wikisource interwiki-links; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if utilities.is_set (page) then
		if utilities.is_set (pages) or utilities.is_set (at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page, page_orig);								-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws URL from |page= interwiki link; link portion L becomes tooltip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (pages) then
		if utilities.is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages, pages_orig);							-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws URL from |pages= interwiki link; link portion L becomes tooltip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws URL from |at= interwiki link; link portion L becomes tooltip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end

--[[--------------------------&lt; I S _ U N I Q U E _ A R C H I V E _ U R L &gt;------------------------------------

add error message when |archive-url= value is same as |url= or chapter-url= (or alias...) value

]]

local function is_unique_archive_url (archive, url, c_url, source, date)
	if utilities.is_set (archive) then
		if archive == url or archive == c_url then
			utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)});	-- add error message
			return '', '';														-- unset |archive-url= and |archive-date= because same as |url= or |chapter-url=
		end
	end

	return archive, date;
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org URLs to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot URL or to calendar pages.  When the archive URL is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the URL.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org URL does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command URL
	|archive-url= is an archive.org URL that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org URLs:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this function may return a modified
archive URL:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the URL unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

A secondary function is to return an archive-url timestamp from those urls that have them (archive.org and
archive.today).  The timestamp is used by validation.archive_date_check() to see if the value in |archive-date=
matches the timestamp in the archive url.

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.org URL
	
	timestamp = url:match ('//archive.today/(%d%d%d%d%d%d%d%d%d%d%d%d%d%d)/') or	-- get timestamp from archive.today urls
		url:match ('//archive.today/(%d%d%d%d%.%d%d%.%d%d%-%d%d%d%d%d%d)/');		-- this timestamp needs cleanup
	if timestamp then															-- if this was an archive.today url ...
		return url, date, timestamp:gsub ('[%.%-]', '');						-- return ArchiveURL, ArchiveDate, and timestamp (dots and dashes removed) from |archive-url=, and done
	end
																				-- here for archive.org urls
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine URL
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command URL, we don't want to allow saving of the target page 
		err_msg = cfg.err_msg_supl.save;
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = cfg.err_msg_supl.liveweb;
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');	-- split out some of the URL parts for evaluation
		if not path then														-- malformed in some way; pattern did not match
			err_msg = cfg.err_msg_supl.timestamp;
		elseif 14 ~= timestamp:len() then										-- path and flag optional, must have 14-digit timestamp here
			err_msg = cfg.err_msg_supl.timestamp;
			if '*' ~= flag then
				local replacement = timestamp:match ('^%d%d%d%d%d%d') or timestamp:match ('^%d%d%d%d');	-- get the first 6 (YYYYMM) or first 4 digits (YYYY)
				if replacement then												-- nil if there aren't at least 4 digits (year)
					replacement = replacement .. string.rep ('0', 14 - replacement:len());	-- year or yearmo (4 or 6 digits) zero-fill to make 14-digit timestamp
					url=url:gsub ('(//web%.archive%.org/[^%d]*)%d[^/]*', '%1' .. replacement .. '*', 1)	-- for preview, modify ts to 14 digits plus splat for calendar display
				end
			end
		elseif utilities.is_set (path) and 'web/' ~= path then					-- older archive URLs do not have the extra 'web/' path element
			err_msg = cfg.err_msg_supl.path;
		elseif utilities.is_set (flag) and not utilities.is_set (path) then		-- flag not allowed with the old form URL (without the 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		elseif utilities.is_set (flag) and not flag:match ('%a%a_') then		-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		else
			return url, date, timestamp;										-- return ArchiveURL, ArchiveDate, and timestamp from |archive-url=
		end
	end
																				-- if here, something not right so
	utilities.set_message ('err_archive_url', {err_msg});						-- add error message and

	if is_preview_mode then
		return url, date, timestamp;											-- preview mode so return ArchiveURL, ArchiveDate, and timestamp from |archive-url=
	else
		return '', '';															-- return empty strings for ArchiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; P L A C E _ C H E C K &gt;--------------------------------------------------------

check |place=, |publication-place=, |location= to see if these params include digits.  This function added because
many editors misuse location to specify the in-source location (|page(s)= and |at= are supposed to do that)

returns the original parameter value without modification; added maint cat when parameter value contains digits

]]

local function place_check (param_val)
	if not utilities.is_set (param_val) then									-- parameter empty or omitted
		return param_val;														-- return that empty state
	end
	
	if mw.ustring.find (param_val, '%d') then									-- not empty, are there digits in the parameter value
		utilities.set_message ('maint_location');								-- yep, add maint cat
	end
	
	return param_val;															-- and done
end


--[[--------------------------&lt; I S _ A R C H I V E D _ C O P Y &gt;----------------------------------------------

compares |title= to 'Archived copy' (placeholder added by bots that can't find proper title); if matches, return true; nil else

]]

local function is_archived_copy (title)
	title = mw.ustring.lower(title);											-- switch title to lower case
	if title:find (cfg.special_case_translation.archived_copy.en) then			-- if title is 'Archived copy'
		return true;
	elseif cfg.special_case_translation.archived_copy['local'] then
		if mw.ustring.find (title, cfg.special_case_translation.archived_copy['local']) then	-- mw.ustring() because might not be Latin script
			return true;
		end
	end
end


--[[--------------------------&lt; D I S P L A Y _ N A M E S _ S E L E C T &gt;--------------------------------------

for any of the |display-authors=, |display-editors=, etc parameters, select either the local or global setting.
When both are present, look at &lt;local_display_names&gt; value.  When the value is some sort of 'et al.'string,
special handling is required.

When {{cs1 config}} has |display-&lt;namelist&gt;= AND this template has |display-&lt;namelist&gt;=etal AND:
	the number of names specified by &lt;number_of_names&gt; is:
		greater than the number specified in the global |display-&lt;namelist&gt;= parameter (&lt;global_display_names&gt;)
			use global |display-&lt;namelist&gt;= parameter value
			set overridden maint category
		less than or equal to the number specified in the global |display-&lt;namelist&gt;=  parameter
			use local |display-&lt;namelist&gt;= parameter value

The purpose of this function is to prevent categorizing a template that has fewer names than the global setting
to keep the etal annotation specified by &lt;local_display_names&gt;.

]]

local function display_names_select (global_display_names, local_display_names, param_name, number_of_names, test)
	if global_display_names and utilities.is_set (local_display_names) then		-- when both
		if 'etal' == local_display_names:lower():gsub(&quot;[ '%.]&quot;, '') then		-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			number_of_names = tonumber (number_of_names);						-- convert these to numbers for comparison
			local global_display_names_num = tonumber (global_display_names);	-- &lt;global_display_names&gt; not set when parameter value is not digits

			if number_of_names &gt; global_display_names_num then					-- template has more names than global config allows to be displayed?
				utilities.set_message ('maint_overridden_setting');				-- set a maint message because global is overriding local |display-&lt;namelist&gt;=etal
				return global_display_names, 'cs1 config';						-- return global with spoof parameter name (for get_display_names())
			else
				return local_display_names, param_name;							-- return local because fewer names so let &lt;local_display_names&gt; control
			end
		end
																				-- here when &lt;global_display_names&gt; and &lt;local_display_names&gt; both numbers; &lt;global_display_names&gt; controls
		utilities.set_message ('maint_overridden_setting');						-- set a maint message
		return global_display_names, 'cs1 config';								-- return global with spoof parameter name (for get_display_names())
	end
																				-- here when only one of &lt;global_display_names&gt; or &lt;local_display_names&gt; set
	if global_display_names then
		return global_display_names, 'cs1 config';								-- return global with spoof parameter name (for get_display_names())
	else
		return local_display_names, param_name;									-- return local
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args )
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper ( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListStyle;
		if cfg.global_cs1_config_t['NameListStyle'] then						-- global setting in {{cs1 config}} overrides local |name-list-style= parameter value; nil when empty or assigned value invalid
			NameListStyle = is_valid_parameter_value (cfg.global_cs1_config_t['NameListStyle'], 'cs1 config: name-list-style', cfg.keywords_lists['name-list-style'], '');	-- error messaging 'param' here is a hoax
		else
			NameListStyle = is_valid_parameter_value (A['NameListStyle'], A:ORIGIN('NameListStyle'), cfg.keywords_lists['name-list-style'], '');
		end

		if cfg.global_cs1_config_t['NameListStyle'] and utilities.is_set (A['NameListStyle']) then	-- when template has |name-list-style=&lt;something&gt; which global setting has overridden
			utilities.set_message ('maint_overridden_setting');					-- set a maint message
		end

	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			a, author_etal = parse_vauthors_veditors (args, A['Vauthors'], 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |people= or |credits=; |authors= is deprecated; TODO: constrain |people= and |credits= to cite av media, episode, serial?
		end
		if utilities.is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], nil, args, 'EditorList');	-- support for |editors= withdrawn
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		end
	end
							
	local Chapter = A['Chapter'];												-- done here so that we have access to |contribution= from |chapter= aliases
	local Chapter_origin = A:ORIGIN ('Chapter');
	local Contribution;															-- because contribution is required for contributor(s)
		if 'contribution' == Chapter_origin then
			Contribution = Chapter;												-- get the name of the contribution
		end
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	
	if utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not utilities.is_set (Contribution) then							-- |contributor= requires |contribution=
				utilities.set_message ('err_contributor_missing_required_param', 'contribution');	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				utilities.set_message ('err_contributor_missing_required_param', 'author');	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if utilities.select_one (args, cfg.aliases['ContributorList-Last'], 'err_redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			utilities.set_message ('err_contributor_ignored');					-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	local Title = A['Title'];
	local TitleLink = A['TitleLink'];

	local auto_select = '';														-- default is auto
	local accept_link;
	TitleLink, accept_link = utilities.has_accept_as_written (TitleLink, true);	-- test for accept-this-as-written markup
	if (not accept_link) and utilities.in_array (TitleLink, {'none', 'pmc', 'doi'}) then -- check for special keywords
		auto_select = TitleLink;												-- remember selection for later
		TitleLink = '';															-- treat as if |title-link= would have been empty
	end

	TitleLink = link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wiki-markup in |title-link= or wiki-markup in |title= when |title-link= is set

	local Section = '';															-- {{cite map}} only; preset to empty string for concatenation if not used
	if 'map' == config.CitationClass and 'section' == Chapter_origin then
		Section = A['Chapter'];													-- get |section= from |chapter= alias list; |chapter= and the other aliases not supported in {{cite map}}
		Chapter = '';															-- unset for now; will be reset later from |map= if present
	end

	local Periodical = A['Periodical'];
	local Periodical_origin = A:ORIGIN('Periodical');
	local ScriptPeriodical = A['ScriptPeriodical'];
	local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');
	local TransPeriodical =  A['TransPeriodical'];
	local TransPeriodical_origin =  A:ORIGIN ('TransPeriodical');
	
	if (utilities.in_array (config.CitationClass, {'book', 'encyclopaedia'}) and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical))) then
		local param;
		if utilities.is_set (Periodical) then									-- get a parameter name from one of these periodical related meta-parameters
			Periodical = '';													-- unset because not valid {{cite book}} or {{cite encyclopedia}} parameters 
			param = Periodical_origin											-- get parameter name for error messaging
		elseif utilities.is_set (TransPeriodical) then
			TransPeriodical = '';												-- unset because not valid {{cite book}} or {{cite encyclopedia}} parameters 
			param = TransPeriodical_origin;										-- get parameter name for error messaging
		elseif utilities.is_set (ScriptPeriodical) then
			ScriptPeriodical = '';												-- unset because not valid {{cite book}} or {{cite encyclopedia}} parameters 
			param = ScriptPeriodical_origin;									-- get parameter name for error messaging
		end

		if utilities.is_set (param) then										-- if we found one
			utilities.set_message ('err_periodical_ignored', {param});			-- emit an error message
		end
	end

	if utilities.is_set (Periodical) then
		local i;
		Periodical, i = utilities.strip_apostrophe_markup (Periodical);			-- strip apostrophe markup so that metadata isn't contaminated 
		if i then																-- non-zero when markup was stripped so emit an error message
			utilities.set_message ('err_apostrophe_markup', {Periodical_origin});
		end
	end

	if 'mailinglist' == config.CitationClass then								-- special case for {{cite mailing list}}
		if utilities.is_set (Periodical) and utilities.is_set (A ['MailingList']) then	-- both set emit an error TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', Periodical_origin) .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'mailinglist')});
		end

		Periodical = A ['MailingList'];											-- error or no, set Periodical to |mailinglist= value because this template is {{cite mailing list}}
		Periodical_origin = A:ORIGIN('MailingList');
	end

	-- web and news not tested for now because of 
	-- Wikipedia:Administrators%27_noticeboard#Is_there_a_semi-automated_tool_that_could_fix_these_annoying_&quot;Cite_Web&quot;_errors?
	if not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) then	-- 'periodical' templates require periodical parameter
	--	local p = {['journal'] = 'journal', ['magazine'] = 'magazine', ['news'] = 'newspaper', ['web'] = 'website'};	-- for error message
		local p = {['journal'] = 'journal', ['magazine'] = 'magazine'};			-- for error message
		if p[config.CitationClass]  then
			utilities.set_message ('err_missing_periodical', {config.CitationClass, p[config.CitationClass]});
		end
	end
	
	local Volume;
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) then
			if not utilities.in_array (Periodical_origin, cfg.citation_no_volume_t) then	-- {{citation}} does not render |volume= when these parameters are used
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		elseif utilities.is_set (ScriptPeriodical) then
			if 'script-website' ~= ScriptPeriodical_origin then					-- {{citation}} does not render volume for |script-website=
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		else
			Volume = A['Volume'];												-- and does for non-'periodical' cites
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_volume) then	-- render |volume= for cs1 according to the configuration settings
		Volume = A['Volume'];
	end	
	extra_text_in_vol_iss_check (Volume, A:ORIGIN ('Volume'), 'v');	

	local Issue;
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) and utilities.in_array (Periodical_origin, cfg.citation_issue_t) then	-- {{citation}} may render |issue= when these parameters are used
			Issue = utilities.hyphen_to_dash (A['Issue']);
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_issue) then	-- conference &amp; map books do not support issue; {{citation}} listed here because included in settings table
		if not (utilities.in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical))) then
			Issue = utilities.hyphen_to_dash (A['Issue']);
		end
	end
	
	local ArticleNumber;

	if utilities.in_array (config.CitationClass, {'journal', 'conference'}) or ('citation' == config.CitationClass and utilities.is_set (Periodical) and 'journal' == Periodical_origin) then
		ArticleNumber = A['ArticleNumber'];
	end

	extra_text_in_vol_iss_check (Issue, A:ORIGIN ('Issue'), 'i');	

	local Page;
	local Pages;
	local At;
	local QuotePage;
	local QuotePages;
	if not utilities.in_array (config.CitationClass, cfg.templates_not_using_page) then		-- TODO: rewrite to emit ignored parameter error message?
		Page = A['Page'];
		Pages = utilities.hyphen_to_dash (A['Pages']);	
		At = A['At'];
		QuotePage = A['QuotePage'];
		QuotePages = utilities.hyphen_to_dash (A['QuotePages']);
	end

	local Edition = A['Edition'];
	local PublicationPlace = place_check (A['PublicationPlace'], A:ORIGIN('PublicationPlace'));
	local Place = place_check (A['Place'], A:ORIGIN('Place'));
	
	local PublisherName = A['PublisherName'];
	local PublisherName_origin = A:ORIGIN('PublisherName');
	if utilities.is_set (PublisherName) and (cfg.keywords_xlate['none'] ~= PublisherName) then
		local i = 0;
		PublisherName, i = utilities.strip_apostrophe_markup (PublisherName);	-- strip apostrophe markup so that metadata isn't contaminated; publisher is never italicized
		if i and (0 &lt; i) then													-- non-zero when markup was stripped so emit an error message
			utilities.set_message ('err_apostrophe_markup', {PublisherName_origin});
		end
	end
	
	if ('document' == config.CitationClass) and not utilities.is_set (PublisherName) then
		utilities.set_message ('err_missing_publisher', {config.CitationClass, 'publisher'});
	end

	local Newsgroup = A['Newsgroup'];											-- TODO: strip apostrophe markup?
	local Newsgroup_origin = A:ORIGIN('Newsgroup');	

	if 'newsgroup' == config.CitationClass then
		if utilities.is_set (PublisherName) and (cfg.keywords_xlate['none'] ~= PublisherName) then	-- general use parameter |publisher= not allowed in cite newsgroup
			utilities.set_message ('err_parameter_ignored', {PublisherName_origin});
		end

		PublisherName = nil;													-- ensure that this parameter is unset for the time being; will be used again after COinS
	end

	local URL = A['URL'];														-- TODO: better way to do this for URL, ChapterURL, and MapURL?
	local UrlAccess = is_valid_parameter_value (A['UrlAccess'], A:ORIGIN('UrlAccess'), cfg.keywords_lists['url-access'], nil);
	
	if not utilities.is_set (URL) and utilities.is_set (UrlAccess) then
		UrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', 'url');
	end
	
	local ChapterURL = A['ChapterURL'];
	local ChapterUrlAccess = is_valid_parameter_value (A['ChapterUrlAccess'], A:ORIGIN('ChapterUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (ChapterURL) and utilities.is_set (ChapterUrlAccess) then
		ChapterUrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', {A:ORIGIN('ChapterUrlAccess'):gsub ('%-access', '')});
	end

	local MapUrlAccess = is_valid_parameter_value (A['MapUrlAccess'], A:ORIGIN('MapUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (A['MapURL']) and utilities.is_set (MapUrlAccess) then
		MapUrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', {'map-url'});
	end

	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local no_tracking_cats = is_valid_parameter_value (A['NoTracking'], A:ORIGIN('NoTracking'), cfg.keywords_lists['yes_true_y'], nil);

	-- check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not utilities.is_set (no_tracking_cats) then								-- ignore if we are already not going to categorize this page
		if cfg.uncategorized_namespaces[this_page.namespace] then				-- is this page's namespace id one of the uncategorized namespace ids?
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _, v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end
																				-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	utilities.select_one (args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'err_redundant_parameters');	-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, A:ORIGIN('Page'), Pages, A:ORIGIN('Pages'), At);

	local NoPP = is_valid_parameter_value (A['NoPP'], A:ORIGIN('NoPP'), cfg.keywords_lists['yes_true_y'], nil);

	if utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- both |publication-place= and |place= (|location=) allowed if different
		utilities.add_prop_cat ('location-test');								-- add property cat to evaluate how often PublicationPlace and Place are used together
		if PublicationPlace == Place then
			Place = '';															-- unset; don't need both if they are the same
		end
	elseif not utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- when only |place= (|location=) is set ...
		PublicationPlace = Place;												-- promote |place= (|location=) to |publication-place
	end

	if PublicationPlace == Place then Place = ''; end							-- don't need both if they are the same

	local URL_origin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL_origin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ScriptChapter = A['ScriptChapter'];
	local ScriptChapter_origin = A:ORIGIN ('ScriptChapter');
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local TransChapter = A['TransChapter'];
	local TransChapter_origin = A:ORIGIN ('TransChapter');
	local TransTitle = A['TransTitle'];
	local ScriptTitle = A['ScriptTitle'];
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia= and |title= then map |title= to |article= and |encyclopedia= to |title= for rendering
		|encyclopedia= and |article= then map |encyclopedia= to |title= for rendering

		|trans-title= maps to |trans-chapter= when |title= is re-mapped
		|url= maps to |chapter-url= when |title= is remapped
	
	All other combinations of |encyclopedia=, |title=, and |article= are not modified
	
	]]

	local Encyclopedia = A['Encyclopedia'];										-- used as a flag by this module and by ~/COinS
	local ScriptEncyclopedia = A['ScriptEncyclopedia'];
	local TransEncyclopedia = A['TransEncyclopedia'];

	if utilities.is_set (Encyclopedia) or utilities.is_set (ScriptEncyclopedia) then	-- emit error message when Encyclopedia set but template is other than {{cite encyclopedia}} or {{citation}}
		if 'encyclopaedia' ~= config.CitationClass and 'citation' ~= config.CitationClass then
			if utilities.is_set (Encyclopedia) then
				utilities.set_message ('err_parameter_ignored', {A:ORIGIN ('Encyclopedia')});
			else
				utilities.set_message ('err_parameter_ignored', {A:ORIGIN ('ScriptEncyclopedia')});
			end
			Encyclopedia = nil;													-- unset these because not supported by this template
			ScriptEncyclopedia = nil;
			TransEncyclopedia = nil;
		end
	elseif utilities.is_set (TransEncyclopedia) then
		utilities.set_message ('err_trans_missing_title', {'encyclopedia'});
	end

	if ('encyclopaedia' == config.CitationClass) or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Periodical) and utilities.is_set (Encyclopedia) then	-- when both parameters set emit an error message; {{citation}} only; Periodical not allowed in {{cite encyclopedia}}
			utilities.set_message ('err_periodical_ignored', {Periodical_origin});
		end

		if utilities.is_set (Encyclopedia) or utilities.is_set (ScriptEncyclopedia) then
			Periodical = Encyclopedia;											-- error or no, set Periodical to Encyclopedia for rendering; {{citation}} could (not legitimately) have both; use Encyclopedia
			Periodical_origin = A:ORIGIN ('Encyclopedia');
			ScriptPeriodical = ScriptEncyclopedia;
			ScriptPeriodical_origin = A:ORIGIN ('ScriptEncyclopedia');

			if utilities.is_set (Title) or utilities.is_set (ScriptTitle) then
				if not utilities.is_set (Chapter) then
					Chapter = Title;											-- |encyclopedia= and |title= are set so map |title= params to |article= params for rendering
					ScriptChapter = ScriptTitle;
					ScriptChapter_origin = A:ORIGIN('ScriptTitle')
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterURL_origin = URL_origin;
					ChapterUrlAccess = UrlAccess;
					ChapterFormat = Format;

					if not utilities.is_set (ChapterURL) and utilities.is_set (TitleLink) then
						Chapter = utilities.make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;											-- now map |encyclopedia= params to |title= params for rendering
					ScriptTitle = ScriptPeriodical or '';
					TransTitle = TransEncyclopedia or '';
					Periodical = '';											-- redundant so unset
					ScriptPeriodical = '';
					URL = '';
					Format = '';
					TitleLink = '';
				end
			elseif utilities.is_set (Chapter) or utilities.is_set (ScriptChapter) then	-- |title= not set
				Title = Periodical;												-- |encyclopedia= set and |article= set so map |encyclopedia= to |title= for rendering
				ScriptTitle = ScriptPeriodical or '';
				TransTitle = TransEncyclopedia or '';
				Periodical = '';												-- redundant so unset
				ScriptPeriodical = '';
			end
		end
	end

	-- special case for cite techreport.
	local ID = A['ID'];
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if utilities.is_set (A['Number']) then									-- cite techreport uses 'number', which other citations alias to 'issue'
			if not utilities.is_set (ID) then									-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'id') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'number')});
			end
		end	
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	local ChapterLink -- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local Conference = A['Conference'];
	local BookTitle = A['BookTitle'];
	local TransTitle_origin = A:ORIGIN ('TransTitle');
	if 'conference' == config.CitationClass then
		if utilities.is_set (BookTitle) then
			Chapter = Title;
			Chapter_origin = 'title';
	--		ChapterLink = TitleLink;											-- |chapter-link= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			URL_origin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			TransChapter_origin = TransTitle_origin;
			Title = BookTitle;
			Format = '';
	--		TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end
	
	-- CS1/2 mode
	local Mode;
		if cfg.global_cs1_config_t['Mode'] then									-- global setting in {{cs1 config}} overrides local |mode= parameter value; nil when empty or assigned value invalid
			Mode = is_valid_parameter_value (cfg.global_cs1_config_t['Mode'], 'cs1 config: mode', cfg.keywords_lists['mode'], '');	-- error messaging 'param' here is a hoax
		else
			Mode = is_valid_parameter_value (A['Mode'], A:ORIGIN('Mode'), cfg.keywords_lists['mode'], '');
		end

		if cfg.global_cs1_config_t['Mode'] and utilities.is_set (A['Mode']) then	-- when template has |mode=&lt;something&gt; which global setting has overridden
			utilities.set_message ('maint_overridden_setting');					-- set a maint message
		end

	-- separator character and postscript
	local sepc, PostScript = set_style (Mode:lower(), A['PostScript'], config.CitationClass);
	-- controls capitalization of certain static text
	local use_lowercase = ( sepc == ',' );
	
	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		if utilities.is_set (Chapter) then										--TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'map') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', Chapter_origin)});	-- add error message
		end
		Chapter = A['Map'];
		Chapter_origin = A:ORIGIN('Map');
		ChapterURL = A['MapURL'];
		ChapterURL_origin = A:ORIGIN('MapURL');
		TransChapter = A['TransMap'];
		ScriptChapter = A['ScriptMap']
		ScriptChapter_origin = A:ORIGIN('ScriptMap')

		ChapterUrlAccess = MapUrlAccess;
		ChapterFormat = A['MapFormat'];

		Cartography = A['Cartography'];
		if utilities.is_set ( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if utilities.is_set ( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	local Series = A['Series'];
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local SeriesLink = A['SeriesLink'];

		SeriesLink = link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wiki-markup in |series-link= or wiki-markup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if utilities.is_set (Network) then table.insert(n, Network); end
		if utilities.is_set (Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if utilities.is_set (Season) and utilities.is_set (SeriesNumber) then	-- these are mutually exclusive so if both are set TODO: make a function for this and similar?
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'season') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'seriesno')});		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if utilities.is_set (Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if utilities.is_set (SeriesNumber) then table.insert(s, wrap_msg ('seriesnum', SeriesNumber, use_lowercase)); end
			if utilities.is_set (Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ScriptChapter_origin = A:ORIGIN('ScriptTitle');
			ChapterLink = TitleLink;											-- alias |episode-link=
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			ChapterFormat = Format;

			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if utilities.is_set (ChapterLink) and not utilities.is_set (ChapterURL) then	-- link but not URL
				Chapter = utilities.make_wikilink (ChapterLink, Chapter);
			elseif utilities.is_set (ChapterLink) and utilities.is_set (ChapterURL) then	-- if both are set, URL links episode;
				Series = utilities.make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			Format = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if utilities.is_set (Series) and utilities.is_set (SeriesLink) then
				Series = utilities.make_wikilink (SeriesLink, Series);
			end
			Series = utilities.wrap_style ('italic-title', Series);				-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- handle type parameter for those CS1 citations that have default values
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	if utilities.in_array (config.CitationClass, {'AV-media-notes', 'document', 'interview', 'mailinglist', 'map', 'podcast', 'pressrelease', 'report', 'speech', 'techreport', 'thesis'}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if utilities.is_set (Degree) and &quot;Thesis&quot; == TitleType then				-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if utilities.is_set (TitleType) then										-- if type parameter is specified
		TitleType = utilities.substitute ( cfg.messages['type'], TitleType);	-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
	local Date = A['Date'];
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging
	local PublicationDate = A['PublicationDate'];
	local Year = A['Year'];

	if utilities.is_set (Year) then
		validation.year_check (Year);											-- returns nothing; emits maint message when |year= doesn't hold a 'year' value
	end
		
	if not utilities.is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not utilities.is_set (Date) and utilities.is_set (PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]

	local DF = is_valid_parameter_value (A['DF'], A:ORIGIN('DF'), cfg.keywords_lists['df'], '');
	if not utilities.is_set (DF) then
		DF = cfg.global_df;														-- local |df= if present overrides global df set by {{use xxx date}} template
	end

	local ArchiveURL;
	local ArchiveDate;
	local ArchiveFormat = A['ArchiveFormat'];
	local archive_url_timestamp;												-- timestamp from wayback machine url
	
	ArchiveURL, ArchiveDate, archive_url_timestamp = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	
	ArchiveURL, ArchiveDate = is_unique_archive_url (ArchiveURL, URL, ChapterURL, A:ORIGIN('ArchiveURL'), ArchiveDate);		-- add error message when URL or ChapterURL == ArchiveURL

	local AccessDate = A['AccessDate'];
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification
	local DoiBroken = A['DoiBroken'];
	local Embargo = A['Embargo'];
	local anchor_year;															-- used in the CITEREF identifier
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val = AccessDate, name = A:ORIGIN ('AccessDate')},
			['archive-date'] = {val = ArchiveDate, name = A:ORIGIN ('ArchiveDate')},
			['date'] = {val = Date, name = Date_origin},
			['doi-broken-date'] = {val = DoiBroken, name = A:ORIGIN ('DoiBroken')},
			['pmc-embargo-date'] = {val = Embargo, name = A:ORIGIN ('Embargo')},
			['publication-date'] = {val = PublicationDate, name = A:ORIGIN ('PublicationDate')},
			['year'] = {val = Year, name = A:ORIGIN ('Year')},
			};

		local error_list = {};
		anchor_year, Embargo = validation.dates(date_parameters_list, COinS_date, error_list);

		if utilities.is_set (Year) and utilities.is_set (Date) then				-- both |date= and |year= not normally needed; 
			validation.year_date_check (Year, A:ORIGIN ('Year'), Date, A:ORIGIN ('Date'), error_list);
		end

		if 0 == #error_list then												-- error free dates only; 0 when error_list is empty
			local modified = false;												-- flag
			
			if utilities.is_set (DF) then										-- if we need to reformat dates
				modified = validation.reformat_dates (date_parameters_list, DF);	-- reformat to DF format, use long month names if appropriate
			end

			if true == validation.date_hyphen_to_dash (date_parameters_list) then	-- convert hyphens to dashes where appropriate
				modified = true;
				utilities.set_message ('maint_date_format');					-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language; not supported at en.wiki
			if cfg.date_name_auto_xlate_enable and validation.date_name_xlate (date_parameters_list, cfg.date_digit_auto_xlate_enable ) then
				utilities.set_message ('maint_date_auto_xlated');				-- add maint cat
				modified = true;
			end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end

			if archive_url_timestamp and utilities.is_set (ArchiveDate) then
				validation.archive_date_check (ArchiveDate, archive_url_timestamp, DF);	-- does YYYYMMDD in archive_url_timestamp match date in ArchiveDate
			end
		else
			utilities.set_message ('err_bad_date', {utilities.make_sep_list (#error_list, error_list)});	-- add this error message
		end
	end	-- end of do

	if utilities.in_array (config.CitationClass, {'book', 'encyclopaedia'}) or	-- {{cite book}}, {{cite encyclopedia}}; TODO: {{cite conference}} and others?
		('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) or			-- {{citation}} as an encylopedia citation
		('citation' == config.CitationClass and not utilities.is_set (Periodical)) then		-- {{citation}} as a book citation
			if utilities.is_set (PublicationPlace) then
				if not utilities.is_set (PublisherName) then
					local date = COinS_date.rftdate and tonumber (COinS_date.rftdate:match ('%d%d%d%d'));	-- get year portion of COinS date (because in Arabic numerals); convert string to number
					if date and (1850 &lt;= date) then								-- location has no publisher; if date is 1850 or later
						utilities.set_message ('maint_location_no_publisher');	-- add maint cat
					end
				else															-- PublisherName has a value
					if cfg.keywords_xlate['none'] == PublisherName then			-- if that value is 'none' (only for book and encyclopedia citations)
						PublisherName = '';										-- unset
					end
				end
			end
	end

	local ID_list = {};															-- sequence table of rendered identifiers
	local ID_list_coins = {};													-- table of identifiers and their values from args; key is same as cfg.id_handlers's key
	local Class = A['Class'];													-- arxiv class identifier
	
	local ID_support = {
		{A['ASINTLD'], 'ASIN', 'err_asintld_missing_asin', A:ORIGIN ('ASINTLD')},				
		{DoiBroken, 'DOI', 'err_doibroken_missing_doi', A:ORIGIN ('DoiBroken')},
		{Embargo, 'PMC', 'err_embargo_missing_pmc', A:ORIGIN ('Embargo')},
		}

	ID_list, ID_list_coins = identifiers.identifier_lists_get (args, {DoiBroken = DoiBroken, ASINTLD = A['ASINTLD'], Embargo = Embargo, Class = Class}, ID_support);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite medrxiv}}, {{cite ssrn}}, before generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list_t) then	-- |arxiv= or |eprint= required for cite arxiv; |biorxiv=, |citeseerx=, |medrxiv=, |ssrn= required for their templates
		if not (args[cfg.id_handlers[config.CitationClass:upper()].parameters[1]] or 		-- can't use ID_list_coins k/v table here because invalid parameters omitted
			args[cfg.id_handlers[config.CitationClass:upper()].parameters[2]]) then			-- which causes unexpected parameter missing error message
				utilities.set_message ('err_' .. config.CitationClass .. '_missing');		-- add error message
		end

		Periodical = ({['arxiv'] = 'arXiv', ['biorxiv'] = 'bioRxiv', ['citeseerx'] = 'CiteSeerX', ['medrxiv'] = 'medRxiv', ['ssrn'] = 'Social Science Research Network'})[config.CitationClass];
	end

	-- Link the title of the work if no |url= was provided, but we have a |pmc= or a |doi= with |doi-access=free

	if config.CitationClass == &quot;journal&quot; and not utilities.is_set (URL) and not utilities.is_set (TitleLink) and not utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) then -- TODO: remove 'none' once existing citations have been switched to 'off', so 'none' can be used as token for &quot;no title&quot; instead
		if 'none' ~= cfg.keywords_xlate[auto_select] then						-- if auto-linking not disabled
 	 		if identifiers.auto_link_urls[auto_select] then						-- manual selection
		 		URL = identifiers.auto_link_urls[auto_select];					-- set URL to be the same as identifier's external link
 				URL_origin = cfg.id_handlers[auto_select:upper()].parameters[1];	-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['pmc'] then						-- auto-select PMC
				URL = identifiers.auto_link_urls['pmc'];						-- set URL to be the same as the PMC external link if not embargoed
				URL_origin = cfg.id_handlers['PMC'].parameters[1];				-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['doi'] then						-- auto-select DOI
				URL = identifiers.auto_link_urls['doi'];
				URL_origin = cfg.id_handlers['DOI'].parameters[1];
			end
 	 	end

		if utilities.is_set (URL) then											-- set when using an identifier-created URL
			if utilities.is_set (AccessDate) then								-- |access-date= requires |url=; identifier-created URL is not |url=
				utilities.set_message ('err_accessdate_missing_url');			-- add an error message
				AccessDate = '';												-- unset
			end

			if utilities.is_set (ArchiveURL) then								-- |archive-url= requires |url=; identifier-created URL is not |url=
				utilities.set_message ('err_archive_missing_url');				-- add an error message
				ArchiveURL = '';												-- unset
			end
		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not utilities.is_set (Title) and not utilities.is_set (TransTitle) and not utilities.is_set (ScriptTitle) then	-- has special case for cite episode
		utilities.set_message ('err_citation_missing_title', {'episode' == config.CitationClass and 'series' or 'title'});
	end

	if utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) and
			utilities.in_array (config.CitationClass, {'journal', 'citation'}) and
			(utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and
			('journal' == Periodical_origin or 'script-journal' == ScriptPeriodical_origin) then	-- special case for journal cites
				Title = '';														-- set title to empty string
				utilities.set_message ('maint_untitled');						-- add maint cat
	end

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Chapter) and utilities.is_set (Title) and utilities.is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end
	
	-- this is the function call to COinS()
	local OCinSoutput = metadata.COinS({
		['Periodical'] = utilities.strip_apostrophe_markup (Periodical),		-- no markup in the metadata
		['Encyclopedia'] = Encyclopedia,										-- just a flag; content ignored by ~/COinS
		['Chapter'] = metadata.make_coins_title (coins_chapter, ScriptChapter),	-- Chapter and ScriptChapter stripped of bold / italic / accept-as-written markup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = metadata.make_coins_title (coins_title, ScriptTitle),		-- Title and ScriptTitle stripped of bold / italic / accept-as-written markup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date.* has correctly formatted date values if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Quarter'] = COinS_date.rftquarter,
		['Chron'] =  COinS_date.rftchron,
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['ArticleNumber'] = ArticleNumber,
		['Pages'] = coins_pages or metadata.get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At, QuotePage, QuotePages}, 7)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName or Newsgroup,							-- any apostrophe markup already removed from PublisherName
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list_coins,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite medrxiv}}, and {{cite ssrn}} AFTER generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list_t) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, CiteSeerX, medRxiv, or ssrn now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass and utilities.is_set (Newsgroup) then
		PublisherName = utilities.substitute (cfg.messages['newsgroup'], external_link( 'news:' .. Newsgroup, Newsgroup, Newsgroup_origin, nil ));
	end

	local Editors;
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	local Contributors;															-- assembled contributors name list
	local contributor_etal;
	local Translators;															-- assembled translators name list
	local translator_etal;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	local Interviewers;															
	local interviewers_list = {};					
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters
	local interviewer_etal;
	
	-- Now perform various field 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.
	do
		local last_first_list;
		local control = { 
			format = NameListStyle,												-- empty string, '&amp;', 'amp', 'and', or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			local display_names, param = display_names_select (cfg.global_cs1_config_t['DisplayEditors'], A['DisplayEditors'], A:ORIGIN ('DisplayEditors'), #e);
			control.maximum, editor_etal = get_display_names (display_names, #e, 'editors', editor_etal, param);

			Editors, EditorCount = list_people (control, e, editor_etal);

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			local display_names, param = display_names_select (cfg.global_cs1_config_t['DisplayInterviewers'], A['DisplayInterviewers'], A:ORIGIN ('DisplayInterviewers'), #interviewers_list);
			control.maximum, interviewer_etal = get_display_names (display_names, #interviewers_list, 'interviewers', interviewer_etal, param);

			Interviewers = list_people (control, interviewers_list, interviewer_etal);
		end
		do																		-- now do translators
			local display_names, param = display_names_select (cfg.global_cs1_config_t['DisplayTranslators'], A['DisplayTranslators'], A:ORIGIN ('DisplayTranslators'), #t);
			control.maximum, translator_etal = get_display_names (display_names, #t, 'translators', translator_etal, param);

			Translators = list_people (control, t, translator_etal);
		end
		do																		-- now do contributors
			local display_names, param = display_names_select (cfg.global_cs1_config_t['DisplayContributors'], A['DisplayContributors'], A:ORIGIN ('DisplayContributors'), #c);
			control.maximum, contributor_etal = get_display_names (display_names, #c, 'contributors', contributor_etal, param);

			Contributors = list_people (control, c, contributor_etal);
		end
		do																		-- now do authors
			local display_names, param = display_names_select (cfg.global_cs1_config_t['DisplayAuthors'], A['DisplayAuthors'], A:ORIGIN ('DisplayAuthors'), #a, author_etal);
			control.maximum, author_etal = get_display_names (display_names, #a, 'authors', author_etal, param);

			last_first_list = list_people (control, a, author_etal);

			if utilities.is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors');	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if utilities.is_set (Authors) and utilities.is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'medrxiv', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not utilities.is_set (URL) then
		if utilities.in_array (config.CitationClass, {&quot;web&quot;, &quot;podcast&quot;, &quot;mailinglist&quot;}) or		-- |url= required for cite web, cite podcast, and cite mailinglist
			('citation' == config.CitationClass and ('website' == Periodical_origin or 'script-website' == ScriptPeriodical_origin)) then	-- and required for {{citation}} with |website= or |script-website=
				utilities.set_message ('err_cite_web_url');
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if utilities.is_set (AccessDate) and not utilities.is_set (ChapterURL) then		-- ChapterURL may be set when URL is not set;
			utilities.set_message ('err_accessdate_missing_url');
			AccessDate = '';
		end
	end

	local UrlStatus = is_valid_parameter_value (A['UrlStatus'], A:ORIGIN('UrlStatus'), cfg.keywords_lists['url-status'], '');
	local OriginalURL
	local OriginalURL_origin
	local OriginalFormat
	local OriginalAccess;
	UrlStatus = UrlStatus:lower();												-- used later when assembling archived text
	if utilities.is_set ( ArchiveURL ) then
		if utilities.is_set (ChapterURL) then 									-- if chapter-url= is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURL_origin = ChapterURL_origin;								-- name of |chapter-url= parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=

			if 'live' ~= UrlStatus then
				ChapterURL = ArchiveURL											-- swap-in the archive's URL
				ChapterURL_origin = A:ORIGIN('ArchiveURL')						-- name of |archive-url= parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived URLs
			end
		elseif utilities.is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURL_origin = URL_origin;									-- name of URL parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;

			if 'live' ~= UrlStatus then											-- if URL set then |archive-url= applies to it
				URL = ArchiveURL												-- swap-in the archive's URL
				URL_origin = A:ORIGIN('ArchiveURL')								-- name of archive URL parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived URLs
			end
		end
	elseif utilities.is_set (UrlStatus) then									-- if |url-status= is set when |archive-url= is not set
 		utilities.set_message ('maint_url_status');								-- add maint cat
	end

	if utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'medrxiv', 'ssrn'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) then
			local chap_param;
			if utilities.is_set (Chapter) then									-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif utilities.is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif utilities.is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif utilities.is_set (ScriptChapter) then
				chap_param = ScriptChapter_origin;
			else utilities.is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if utilities.is_set (chap_param) then								-- if we found one
				utilities.set_message ('err_chapter_ignored', {chap_param});	-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if utilities.is_set (Contribution) and 0 &lt; #c then						-- if this is a contribution with contributor(s)
			if utilities.in_array (Contribution:lower(), cfg.keywords_lists.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, ScriptChapter_origin, Chapter, Chapter_origin, TransChapter, TransChapter_origin, ChapterURL, ChapterURL_origin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if utilities.is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and utilities.is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter .. sepc .. ' ';
		elseif utilities.is_set (ChapterFormat) then							-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title
	local plain_title = false;
	local accept_title;
	Title, accept_title = utilities.has_accept_as_written (Title, true);		-- remove accept-this-as-written markup when it wraps all of &lt;Title&gt;
	if accept_title and ('' == Title) then										-- only support forced empty for now &quot;(())&quot;
		Title = cfg.messages['notitle'];										-- replace by predefined &quot;No title&quot; message
			-- TODO: utilities.set_message ( 'err_redundant_parameters', ...);	-- issue proper error message instead of muting	 
			ScriptTitle = '';													-- just mute for now	 
			TransTitle = '';													-- just mute for now
 		plain_title = true;														-- suppress text decoration for descriptive title
		utilities.set_message ('maint_untitled');								-- add maint cat
	end

	if not accept_title then													-- &lt;Title&gt; not wrapped in accept-as-written markup
		if '...' == Title:sub (-3) then											-- if ellipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%' .. sepc .. '$', '');			-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end

		if utilities.is_set (ArchiveURL) and is_archived_copy (Title) then
			utilities.set_message ('maint_archived_copy');						-- add maintenance category before we modify the content of Title
		end

		if is_generic ('generic_titles', Title) then
			utilities.set_message ('err_generic_title');						-- set an error message
		end
	end

	if (not plain_title) and (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'document', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx', 'medrxiv', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) or
		('map' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)))) then		-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from module provided quote marks
			Title = utilities.wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle, 'script-title');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
			TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );
	elseif plain_title or ('report' == config.CitationClass) then				-- no styling for cite report and descriptive titles (otherwise same as above)
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );	-- for cite report, use this form for trans-title
	else
		Title = utilities.wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-italic-title', TransTitle);
	end

	if utilities.is_set (TransTitle) then
		if utilities.is_set (Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			utilities.set_message ('err_trans_missing_title', {'title'});
		end
	end

	if utilities.is_set (Title) then											-- TODO: is this the right place to be making Wikisource URLs?
		if utilities.is_set (TitleLink) and utilities.is_set (URL) then
			utilities.set_message ('err_wikilink_in_url');						-- set an error message because we can't have both
			TitleLink = '';														-- unset
		end
	
		if not utilities.is_set (TitleLink) and utilities.is_set (URL) then
			Title = external_link (URL, Title, URL_origin, UrlAccess) .. TransTitle .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif utilities.is_set (TitleLink) and not utilities.is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle;
			else
				Title = utilities.make_wikilink (TitleLink, Title) .. TransTitle;
			end
		else
			local ws_url, ws_label, L;											-- Title has italic or quote markup by the time we get here which causes is_wikilink() to return 0 (not a wikilink)
			ws_url, ws_label, L = wikisource_url_make (Title:gsub('^[\'&quot;]*(.-)[\'&quot;]*$', '%1'));	-- make ws URL from |title= interwiki link (strip italic or quote markup); link portion L becomes tooltip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle;
			else
				Title = Title .. TransTitle;
			end
		end
	else
		Title = TransTitle;
	end

	if utilities.is_set (Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	local ConferenceURL_origin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	if utilities.is_set (Conference) then
		if utilities.is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURL_origin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif utilities.is_set (ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURL_origin, nil );
	end

	local Position = '';
	if not utilities.is_set (Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if utilities.is_set (Minutes) then
			if utilities.is_set (Time) then		--TODO: make a function for this and similar?
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'minutes') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'time')});
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if utilities.is_set (Time) then
				local TimeCaption = A['TimeCaption']
				if not utilities.is_set (TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = utilities.is_set (At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = utilities.is_set (Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Sections = A['Sections'];											-- Section (singular) is an alias of Chapter so set earlier
		local Inset = A['Inset'];
		
		if utilities.is_set ( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if utilities.is_set ( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif utilities.is_set ( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	local Others = A['Others'];
	if utilities.is_set (Others) and 0 == #a and 0 == #e then					-- add maint cat when |others= has value and used without |author=, |editor=
		if config.CitationClass == &quot;AV-media-notes&quot;
		or config.CitationClass == &quot;audio-visual&quot; then							-- special maint for AV/M which has a lot of 'false' positives right now
			utilities.set_message ('maint_others_avm')
		else
			utilities.set_message ('maint_others');
		end
	end
	Others = utilities.is_set (Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if utilities.is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if utilities.is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	local TitleNote = A['TitleNote'];
	TitleNote = utilities.is_set (TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if utilities.is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%n?%.?$') or Edition:match ('%f[%a][Ee]dition$') then -- Ed, ed, Ed., ed., Edn, edn, Edn., edn.
			utilities.set_message ('err_extra_text_edition');					 -- add error message
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = utilities.is_set (Series) and wrap_msg ('series', {sepc, Series}) or &quot;&quot;;	-- not the same as SeriesNum
	local Agency = A['Agency'] or '';											-- |agency= is supported by {{cite magazine}}, {{cite news}}, {{cite press release}}, {{cite web}}, and certain {{citation}} templates
	if utilities.is_set (Agency) then											-- this testing done here because {{citation}} supports 'news' citations
		if utilities.in_array (config.CitationClass, {'magazine', 'news', 'pressrelease', 'web'}) or ('citation' == config.CitationClass and utilities.in_array (Periodical_origin, {&quot;magazine&quot;, &quot;newspaper&quot;, &quot;work&quot;})) then
			Agency = wrap_msg ('agency', {sepc, Agency});						-- format for rendering
		else
			Agency = '';														-- unset; not supported
			utilities.set_message ('err_parameter_ignored', {'agency'});		-- add error message
		end
	end
	
	Volume = format_volume_issue (Volume, Issue, ArticleNumber, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	if utilities.is_set (AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = utilities.substitute (retrv_text, AccessDate);				-- add retrieved text

		AccessDate = utilities.substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if utilities.is_set (ID) then ID = sepc .. &quot; &quot; .. ID; end
	
	local Docket = A['Docket'];
   	if &quot;thesis&quot; == config.CitationClass and utilities.is_set (Docket) then
		ID = sepc .. &quot; Docket &quot; .. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and utilities.is_set (Docket) then		-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	if utilities.is_set (URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URL_origin, UrlAccess );
	end

	local Quote = A['Quote'];
	local TransQuote = A['TransQuote'];
	local ScriptQuote = A['ScriptQuote'];
	if utilities.is_set (Quote) or utilities.is_set (TransQuote) or utilities.is_set (ScriptQuote) then

		if utilities.is_set (Quote) then
			if Quote:sub(1, 1) == '&quot;' and Quote:sub(-1, -1) == '&quot;' then			-- if first and last characters of quote are quote marks
				Quote = Quote:sub(2, -2);										-- strip them off
			end
		end
		
		Quote = kern_quotes (Quote);											-- kern if needed
		Quote = utilities.wrap_style ('quoted-text', Quote );					-- wrap in &lt;q&gt;...&lt;/q&gt; tags
	
		if utilities.is_set (ScriptQuote) then
			Quote = script_concatenate (Quote, ScriptQuote, 'script-quote');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after quote is wrapped
		end

		if utilities.is_set (TransQuote) then
			if TransQuote:sub(1, 1) == '&quot;' and TransQuote:sub(-1, -1) == '&quot;' then -- if first and last characters of |trans-quote are quote marks
				TransQuote = TransQuote:sub(2, -2); -- strip them off
			end
			Quote = Quote .. &quot; &quot; .. utilities.wrap_style ('trans-quoted-title', TransQuote );
		end

		if utilities.is_set (QuotePage) or utilities.is_set (QuotePages) then	-- add page prefix
			local quote_prefix = '';
			if utilities.is_set (QuotePage) then
				extra_text_in_page_check (QuotePage, 'quote-page');				-- add to maint cat if |quote-page= value begins with what looks like p., pp., etc.
				if not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePage}), '', '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePage}), '', '', '';
				end
			elseif utilities.is_set (QuotePages) then
				extra_text_in_page_check (QuotePages, 'quote-pages');			-- add to maint cat if |quote-pages= value begins with what looks like p., pp., etc.
				if tonumber(QuotePages) ~= nil and not NoPP then				-- if only digits, assume single page
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, QuotePages}), '', '';
				elseif not NoPP then
					quote_prefix = utilities.substitute (cfg.messages['pp-prefix'], {sepc, QuotePages}), '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, QuotePages}), '', '';
				end
			end
                        
			Quote = quote_prefix .. &quot;: &quot; .. Quote;
		else
			Quote = sepc .. &quot; &quot; .. Quote;
		end

		PostScript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	end
	
	-- We check length of PostScript here because it will have been nuked by
	-- the quote parameters. We'd otherwise emit a message even if there wasn't
	-- a displayed postscript.
	-- TODO: Should the max size (1) be configurable?
	-- TODO: Should we check a specific pattern?
	if utilities.is_set(PostScript) and mw.ustring.len(PostScript) &gt; 1 then
		utilities.set_message ('maint_postscript')
	end
	
	local Archived;
	if utilities.is_set (ArchiveURL) then
		if not utilities.is_set (ArchiveDate) then								-- ArchiveURL set but ArchiveDate not set
			utilities.set_message ('err_archive_missing_date');					-- emit an error message
			ArchiveURL = '';													-- empty string for concatenation
			ArchiveDate = '';													-- empty string for concatenation
		end
	else														
		if utilities.is_set (ArchiveDate) then									-- ArchiveURL not set but ArchiveDate is set
			utilities.set_message ('err_archive_date_missing_url');				-- emit an error message
			ArchiveURL = '';													-- empty string for concatenation
			ArchiveDate = '';													-- empty string for concatenation
		end
	end

	if utilities.is_set (ArchiveURL) then
		local arch_text;
		if &quot;live&quot; == UrlStatus then
			arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if utilities.is_set (ArchiveDate) then
				Archived = sepc .. ' ' .. utilities.substitute ( cfg.messages['archived-live'],
					{external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil) .. ArchiveFormat, ArchiveDate } );
			else
				Archived = '';
			end
			if not utilities.is_set (OriginalURL) then
				utilities.set_message ('err_archive_missing_url');
				Archived = '';													-- empty string for concatenation
			end
		elseif utilities.is_set (OriginalURL) then								-- UrlStatus is empty, 'dead', 'unfit', 'usurped', 'bot: unknown'
			if utilities.in_array (UrlStatus, {'unfit', 'usurped', 'bot: unknown'}) then
				arch_text = cfg.messages['archived-unfit'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. ' ' .. arch_text .. ArchiveDate;				-- format already styled
				if 'bot: unknown' == UrlStatus then
					utilities.set_message ('maint_bot_unknown');				-- and add a category if not already added
				else
--					utilities.set_message ('maint_unfit');						-- and add a category if not already added
					utilities.add_prop_cat ('unfit');							-- and add a category if not already added
				end
			else																-- UrlStatus is empty, 'dead'
				arch_text = cfg.messages['archived-dead'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				if utilities.is_set (ArchiveDate) then
					Archived = sepc .. &quot; &quot; .. utilities.substitute ( arch_text,
						{ external_link( OriginalURL, cfg.messages['original'], OriginalURL_origin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
				else
					Archived = '';												-- unset for concatenation
				end
			end	
		else																	-- OriginalUrl not set
			utilities.set_message ('err_archive_missing_url');
			Archived = '';														-- empty string for concatenation
		end
	elseif utilities.is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = '';
	end
	
	local TranscriptURL = A['TranscriptURL']
	local TranscriptFormat = A['TranscriptFormat'];
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');
	local Transcript = A['Transcript'];
	local TranscriptURL_origin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL
	if utilities.is_set (Transcript) then
		if utilities.is_set (TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURL_origin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif utilities.is_set (TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURL_origin, nil );
	end

	local Publisher;
	if utilities.is_set (PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if utilities.is_set (PublisherName) then
		if utilities.is_set (PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif utilities.is_set (PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical)) then
		if utilities.is_set (Title) or utilities.is_set (TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		else 
			Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		end
	end
	
	local Language = A['Language'];
	if utilities.is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc.
	else
		Language='';															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then									-- cite speech only
		TitleNote = TitleType;													-- move TitleType to TitleNote so that it renders ahead of |event=
		TitleType = '';															-- and unset

		if utilities.is_set (Periodical) then									-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if utilities.is_set (Conference) then								-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;							-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (Periodical) then		-- special cases for book cites
		if utilities.is_set (Contributors) then									-- when we are citing foreword, preface, introduction, etc.
			tcommon = safe_join ({Title, TitleNote}, sepc);						-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join ({TitleType, Series, Language, Volume, Others, Edition, Publisher}, sepc);
		else
			tcommon = safe_join ({Title, TitleNote, TitleType, Series, Language, Volume, Others, Edition, Publisher}, sepc);
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if utilities.is_set (Chapter) then										-- map in a book; TitleType is part of Chapter
			tcommon = safe_join ({Title, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc);
		elseif utilities.is_set (Periodical) then								-- map in a periodical
			tcommon = safe_join ({Title, TitleType, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc);
		else																	-- a sheet or stand-alone map
			tcommon = safe_join ({Title, TitleType, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc);
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join ({Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc);

	else																		-- all other CS1 templates
		tcommon = safe_join ({Title, TitleNote, Conference, Periodical, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc);
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local Via = A['Via'];
	Via = utilities.is_set (Via) and  wrap_msg ('via', Via) or '';
	local idcommon;
	if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then	-- special case for cite AV media &amp; cite episode position transcript
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, Quote }, sepc );
	else
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, Quote }, sepc );
	end
	
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	local OrigDate = A['OrigDate'];
	OrigDate = utilities.is_set (OrigDate) and wrap_msg ('origdate', OrigDate) or '';
	if utilities.is_set (Date) then
		if utilities.is_set (Authors) or utilities.is_set (Editors) then		-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date .. &quot;)&quot; .. OrigDate .. sepc .. &quot; &quot;;				-- in parentheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon, -1, -1) == sepc) then						-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigDate;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigDate;							-- Date begins with sepc
			end
		end
	end	
	if utilities.is_set (Authors) then
		if (not utilities.is_set (Date)) then									-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Editors) then
			local in_text = '';
			local post_text = '';
			if utilities.is_set (Chapter) and 0 == #c then
				in_text = cfg.messages['in'] .. ' ';
				if (sepc ~= '.') then
					in_text = in_text:lower();									-- lowercase for cs2
				end
			end
			if EditorCount &lt;= 1 then
				post_text = ' (' .. cfg.messages['editor'] .. ')';				-- be consistent with no-author, no-date case
			else
				post_text = ' (' .. cfg.messages['editors'] .. ')';
			end
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Contributors) then									-- book cite and we're citing the intro, preface, etc.
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if utilities.is_set (Editors) and utilities.is_set (Date) then		-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not utilities.is_set (Date)) then								-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif utilities.is_set (Editors) then
		if utilities.is_set (Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. cfg.presentation['sep_name'] .. cfg.messages['editor'];
			else
				Editors = Editors .. cfg.presentation['sep_name'] .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end

	if utilities.is_set (PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc ); 								-- Deals with italics, spaces, etc.
		if '.' == sepc then														-- remove final seperator if present
			text = text:gsub ('%' .. sepc .. '$', '');							-- dot must be escaped here
		else
			text = mw.ustring.gsub (text, sepc .. '$', '');						-- using ustring for non-dot sepc (likely a non-Latin character)
		end
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite&gt; element
	local options_t = {};
	options_t.class = cite_class_attribute_make (config.CitationClass, Mode);

	local Ref = is_valid_parameter_value (A['Ref'], A:ORIGIN('Ref'), cfg.keywords_lists['ref'], nil, true);	-- nil when |ref=harv; A['Ref'] else

	if 'none' ~= cfg.keywords_xlate[(Ref and Ref:lower()) or ''] then
		local namelist_t = {};													-- holds selected contributor, author, editor name list
		local year = first_set ({Year, anchor_year}, 2);						-- Year first for legacy citations and for YMD dates that require disambiguation

		if #c &gt; 0 then															-- if there is a contributor list
			namelist_t = c;														-- select it
		elseif #a &gt; 0 then														-- or an author list
			namelist_t = a;
		elseif #e &gt; 0 then														-- or an editor list
			namelist_t = e;
		end
		local citeref_id;
		if #namelist_t &gt; 0 then													-- if there are names in namelist_t
			citeref_id = make_citeref_id (namelist_t, year);					-- go make the CITEREF anchor
			if mw.uri.anchorEncode (citeref_id) == ((Ref and mw.uri.anchorEncode (Ref)) or '') then	-- Ref may already be encoded (by {{sfnref}}) so citeref_id must be encoded before comparison
				utilities.set_message ('maint_ref_duplicates_default');
			end
		else
			citeref_id = '';													-- unset
		end
		options_t.id = Ref or citeref_id;
	end

	if string.len (text:gsub('%b&lt;&gt;', '')) &lt;= 2 then								-- remove html and html-like tags; then get length of what remains; 
		z.error_cats_t = {};													-- blank the categories list
		z.error_msgs_t = {};													-- blank the error messages list
		OCinSoutput = nil;														-- blank the metadata string
		text = '';																-- blank the the citation
		utilities.set_message ('err_empty_citation');							-- set empty citation message and category
	end
	
	local render_t = {};														-- here we collect the final bits for concatenation into the rendered citation

	if utilities.is_set (options_t.id) then										-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render_t, utilities.substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options_t.id), mw.text.nowiki(options_t.class), text}));	-- when |ref= is set or when there is a namelist
	else
		table.insert (render_t, utilities.substitute (cfg.presentation['cite'], {mw.text.nowiki(options_t.class), text}));	-- when |ref=none or when namelist_t empty and |ref= is missing or is empty
	end		

	if OCinSoutput then															-- blanked when citation is 'empty' so don't bother to add boilerplate metadata span
		table.insert (render_t, utilities.substitute (cfg.presentation['ocins'], OCinSoutput));	-- format and append metadata to the citation
	end

	local template_name = ('citation' == config.CitationClass) and 'citation' or 'cite ' .. (cfg.citation_class_map_t[config.CitationClass] or config.CitationClass);
	local template_link = '[[Template:' .. template_name .. '|' .. template_name .. ']]';
	local msg_prefix = '&lt;code class=&quot;cs1-code&quot;&gt;{{' .. template_link .. '}}&lt;/code&gt;: ';

	if 0 ~= #z.error_msgs_t then
		mw.addWarning (utilities.substitute (cfg.messages.warning_msg_e, template_link));

		table.insert (render_t, ' ');											-- insert a space between citation and its error messages
		table.sort (z.error_msgs_t);											-- sort the error messages list; sorting includes wrapping &lt;span&gt; and &lt;code&gt; tags; hidden-error sorts ahead of visible-error

		local hidden = true;													-- presume that the only error messages emited by this template are hidden
		for _, v in ipairs (z.error_msgs_t) do									-- spin through the list of error messages
			if v:find ('cs1-visible-error', 1, true) then						-- look for the visible error class name
				hidden = false;													-- found one; so don't hide the error message prefix
				break;															-- and done because no need to look further
			end
		end

		z.error_msgs_t[1] = table.concat ({utilities.error_comment (msg_prefix, hidden), z.error_msgs_t[1]});	-- add error message prefix to first error message to prevent extraneous punctuation
		table.insert (render_t, table.concat (z.error_msgs_t, '; '));			-- make a big string of error messages and add it to the rendering
	end

	if 0 ~= #z.maint_cats_t then
		mw.addWarning (utilities.substitute (cfg.messages.warning_msg_m, template_link));

		table.sort (z.maint_cats_t);											-- sort the maintenance messages list

		local maint_msgs_t = {};												-- here we collect all of the maint messages

		if 0 == #z.error_msgs_t then											-- if no error messages
			table.insert (maint_msgs_t, msg_prefix);							-- insert message prefix in maint message livery
		end
		
		for _, v in ipairs( z.maint_cats_t ) do									-- append maintenance categories
			table.insert (maint_msgs_t, 										-- assemble new maint message and add it to the maint_msgs_t table
				table.concat ({v, ' (', utilities.substitute (cfg.messages[':cat wikilink'], v), ')'})
				);
		end
		table.insert (render_t, utilities.substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs_t, ' ')));	-- wrap the group of maint messages with proper presentation and save
	end

	if not no_tracking_cats then
		local sort_key;
		local cat_wikilink = 'cat wikilink';
		if cfg.enable_sort_keys then											-- when namespace sort keys enabled
			local namespace_number = mw.title.getCurrentTitle().namespace;		-- get namespace number for this wikitext
			sort_key = (0 ~= namespace_number and (cfg.name_space_sort_keys[namespace_number] or cfg.name_space_sort_keys.other)) or nil;	-- get sort key character; nil for mainspace
			cat_wikilink = (not sort_key and 'cat wikilink') or 'cat wikilink sk';	-- make &lt;cfg.messages&gt; key
		end				

		for _, v in ipairs (z.error_cats_t) do									-- append error categories
			table.insert (render_t, utilities.substitute (cfg.messages[cat_wikilink], {v, sort_key}));
		end
		if cfg.id_limits_data_load_fail then									-- boolean true when load failed
			utilities.set_message ('maint_id_limit_load_fail');					-- done here because this maint cat emits no message
		end
		for _, v in ipairs (z.maint_cats_t) do									-- append maintenance categories
			table.insert (render_t, utilities.substitute (cfg.messages[cat_wikilink], {v, sort_key}));
		end
		for _, v in ipairs (z.prop_cats_t) do									-- append properties categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));	-- no sort keys
		end
	end

	return table.concat (render_t);												-- make a big string and done
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class, empty)
	local name = tostring (name);
	local enum_name;															-- parameter name with enumerator (if any) replaced with '#'
	local state;
	local function state_test (state, name)										-- local function to do testing of state values
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			if empty then return nil; end										-- empty deprecated parameters are treated as unknowns
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
		if 'tracked' == state then
			local base_name = name:gsub ('%d', '');								-- strip enumerators from parameter names that have them to get the base name
			utilities.add_prop_cat ('tracked-param', {base_name}, base_name);	-- add a properties category; &lt;base_name&gt; modifies &lt;key&gt;
			return true;
		end
		return nil;
	end		

	if name:find ('#') then														-- # is a cs1|2 reserved character so parameters with # not permitted
		return nil;
	end
																				-- replace enumerator digit(s) with # (|last25= becomes |last#=) (mw.ustring because non-Western 'local' digits)
	enum_name = mw.ustring.gsub (name, '%d+$', '#');							-- where enumerator is last charaters in parameter name (these to protect |s2cid=)
	enum_name = mw.ustring.gsub (enum_name, '%d+([%-l])', '#%1');				-- where enumerator is in the middle of the parameter name; |author#link= is the oddity

	if 'document' == cite_class then											-- special case for {{cite document}}
		state = whitelist.document_parameters_t[enum_name];						-- this list holds enumerated and nonenumerated parameters
		if true == state_test (state, name) then return true; end
		
		return false;
	end

	if utilities.in_array (cite_class, whitelist.preprint_template_list_t) then	-- limited parameter sets allowed for these templates
		state = whitelist.limited_parameters_t[enum_name];						-- this list holds enumerated and nonenumerated parameters
		if true == state_test (state, name) then return true; end

		state = whitelist.preprint_arguments_t[cite_class][name];				-- look in the parameter-list for the template identified by cite_class
		if true == state_test (state, name) then return true; end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates

	if utilities.in_array (cite_class, whitelist.unique_param_template_list_t) then 	-- template-specific parameters for templates that accept parameters from the basic argument list
		state = whitelist.unique_arguments_t[cite_class][name];					-- look in the template-specific parameter-lists for the template identified by cite_class
		if true == state_test (state, name) then return true; end
	end																			-- if here, fall into general validation

	state = whitelist.common_parameters_t[enum_name];							-- all other templates; all normal parameters allowed; this list holds enumerated and nonenumerated parameters
	if true == state_test (state, name) then return true; end

	return false;																-- not supported because not found or name is set to nil
end


--[=[-------------------------&lt; I N T E R _ W I K I _ C H E C K &gt;----------------------------------------------

check &lt;value&gt; for inter-language interwiki-link markup.  &lt;prefix&gt; must be a MediaWiki-recognized language
code.  when these values have the form (without leading colon):
	[[&lt;prefix&gt;:link|label]] return label as plain-text
	[[&lt;prefix&gt;:link]] return &lt;prefix&gt;:link as plain-text

return value as is else

]=]

local function inter_wiki_check (parameter, value)
	local prefix = value:match ('%[%[(%a+):');									-- get an interwiki prefix if one exists
	local _;
	
	if prefix and cfg.inter_wiki_map[prefix:lower()] then						-- if prefix is in the map, needs preceding colon so
		utilities.set_message ('err_bad_paramlink', parameter);					-- emit an error message
		_, value, _ = utilities.is_wikilink (value);							-- extract label portion from wikilink
	end
	return value;
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe.  There are two tests made:
	{{cite ... |title=Title access-date=2016-03-17}}	-- the first parameter has a value and whitespace separates that value from the missing pipe parameter name
	{{cite ... |title=access-date=2016-03-17}}			-- the first parameter has no value (whitespace after the first = is trimmed by MediaWiki)
cs1|2 shares some parameter names with XML/HTML attributes: class=, title=, etc.  To prevent false positives XML/HTML
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (parameter, value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove XML/HTML tags because attributes: class=, title=, etc.

	capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then										-- if the capture is a valid parameter name
		utilities.set_message ('err_missing_pipe', parameter);
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ P U N C T &gt;--------------------------------------

look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_punc (param, value)
	if 'number' == type (param) then
		return;
	end
	
	param = param:gsub ('%d+', '#');											-- enumerated name-list mask params allow terminal punct; normalize 
	if cfg.punct_skip[param] then
		return;																	-- parameter name found in the skip table so done
	end
	
	if value:match ('[,;:]$') then
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
	if value:match ('^=') then													-- sometimes an extraneous '=' character appears ...
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ U R L &gt;------------------------------------------

look for extraneous url parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_url (url_param_t)
	local url_error_t = {};
	
	check_for_url (url_param_t, url_error_t);									-- extraneous url check
	if 0 ~= #url_error_t then													-- non-zero when there are errors
		table.sort (url_error_t);
		utilities.set_message ('err_param_has_ext_link', {utilities.make_sep_list (#url_error_t, url_error_t)});	-- add this error message
	end
end


--[[--------------------------&lt; C I T A T I O N &gt;--------------------------------------------------------------

This is used by templates such as {{cite book}} to create the actual citation text.

]]

local function citation(frame)
	Frame = frame;																-- save a copy in case we need to display an error message in preview mode

	local config = {};															-- table to store parameters from the module {{#invoke:}}
	for k, v in pairs( frame.args ) do											-- get parameters from the {{#invoke}} frame
		config[k] = v;
	--	args[k] = v;															-- crude debug support that allows us to render a citation from module {{#invoke:}}; skips parameter validation; TODO: keep?
	end	
																				-- i18n: set the name that your wiki uses to identify sandbox subpages from sandbox template invoke (or can be set here)
	local sandbox = ((config.SandboxPath and '' ~= config.SandboxPath) and config.SandboxPath) or '/sandbox';	-- sandbox path from {{#invoke:Citation/CS1/sandbox|citation|SandboxPath=/...}}
	is_sandbox = nil ~= string.find (frame:getTitle(), sandbox, 1, true);		-- is this invoke the sandbox module?
	sandbox = is_sandbox and sandbox or '';										-- use i18n sandbox to load sandbox modules when this module is the sandox; live modules else

	local pframe = frame:getParent()
	local styles;
	
	cfg = mw.loadData ('Module:Citation/CS1/Configuration' .. sandbox);			-- load sandbox versions of support modules when {{#invoke:Citation/CS1/sandbox|...}}; live modules else
	whitelist = mw.loadData ('Module:Citation/CS1/Whitelist' .. sandbox);
	utilities = require ('Module:Citation/CS1/Utilities' .. sandbox);
	validation = require ('Module:Citation/CS1/Date_validation' .. sandbox);
	identifiers = require ('Module:Citation/CS1/Identifiers' .. sandbox);
	metadata = require ('Module:Citation/CS1/COinS' .. sandbox);
	styles = 'Module:Citation/CS1' .. sandbox .. '/styles.css';

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the selected cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	is_preview_mode = not utilities.is_set (frame:preprocess ('{{REVISIONID}}'));

	local args = {};															-- table where we store all of the template's arguments
	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text;															-- used as a flag

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	local empty_unknowns = {};													-- sequence table to hold empty unknown params for error message listing
	for k, v in pairs( pframe.args ) do											-- get parameters from the parent (template) frame
		v = mw.ustring.gsub (v, '^%s*(.-)%s*$', '%1');							-- trim leading/trailing whitespace; when v is only whitespace, becomes empty string
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				if type (k) ~= 'string' then									-- exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text = utilities.set_message ('err_text_ignored', {v});
					end
				elseif validate (k:lower(), config.CitationClass) then 
					error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, k:lower()});	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						suggestions = mw.loadData ('Module:Citation/CS1/Suggestions' .. sandbox);	--load sandbox version of suggestion module when {{#invoke:Citation/CS1/sandbox|...}}; live module else
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no capture in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = utilities.substitute (param, capture);		-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, param});	-- set the suggestion error message
							else
								error_text = utilities.set_message ('err_parameter_ignored', {k});	-- suggested param not supported by this template
								v = '';											-- unset
							end
						end
					end
					if not utilities.is_set (error_text) then					-- couldn't match with a pattern, is there an explicit suggestion?						
						if (suggestions.suggestions[ k:lower() ] ~= nil) and validate (suggestions.suggestions[ k:lower() ], config.CitationClass) then
							utilities.set_message ('err_parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]});
						else
							utilities.set_message ('err_parameter_ignored', {k});
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
			end

			args[k] = v;														-- save this parameter and its value

		elseif not utilities.is_set (v) then									-- for empty parameters
			if not validate (k, config.CitationClass, true) then				-- is this empty parameter a valid parameter
				k = ('' == k) and '(empty string)' or k;						-- when k is empty string (or was space(s) trimmed to empty string), replace with descriptive text
				table.insert (empty_unknowns, utilities.wrap_style ('parameter', k));	-- format for error message and add to the list
			end
																				-- crude debug support that allows us to render a citation from module {{#invoke:}} TODO: keep?
	--	elseif args[k] ~= nil or (k == 'postscript') then						-- when args[k] has a value from {{#invoke}} frame (we don't normally do that)
	--		args[k] = v;														-- overwrite args[k] with empty string from pframe.args[k] (template frame); v is empty string here
		end																		-- not sure about the postscript bit; that gets handled in parameter validation; historical artifact?
	end	

	if 0 ~= #empty_unknowns then												-- create empty unknown error message
		utilities.set_message ('err_param_unknown_empty', {
			1 == #empty_unknowns and '' or 's',
			utilities.make_sep_list (#empty_unknowns, empty_unknowns)
			});
	end

	local url_param_t = {};

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);											-- look for invisible characters
		end
		has_extraneous_punc (k, v);												-- look for extraneous terminal punctuation in parameter values
		missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?
		args[k] = inter_wiki_check (k, v);										-- when language interwiki-linked parameter missing leading colon replace with wiki-link label

		if 'string' == type (k) and not cfg.url_skip[k] then					-- when parameter k is not positional and not in url skip table
			url_param_t[k] = v;													-- make a parameter/value list for extraneous url check
		end
	end

	has_extraneous_url (url_param_t);											-- look for url in parameter values where a url does not belong

	return table.concat ({
		frame:extensionTag ('templatestyles', '', {src=styles}),
		citation0( config, args)
	});
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {citation = citation};</text>
      <sha1>38f2p9l79xumyl0w5rmbznp9nbeuvz5</sha1>
    </revision>
    <revision>
      <id>4757</id>
      <parentid>4756</parentid>
      <timestamp>2025-04-12T13:48:53Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4757</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="232143" sha1="swdh50lofyqq0wmp3o2c259fg8s2nxi" xml:space="preserve">require ('strict');

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------

each of these counts against the Lua upvalue limit

]]

local validation;																-- functions in Module:Citation/CS1/Date_validation

local utilities;																-- functions in Module:Citation/CS1/Utilities
local z = {};																	-- table of tables in Module:Citation/CS1/Utilities

local identifiers;																-- functions and tables in Module:Citation/CS1/Identifiers
local metadata;																	-- functions in Module:Citation/CS1/COinS
local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;---------------

declare variables here that have page-wide scope that are not brought in from
other modules; that are created here and used here

]]

local added_deprecated_cat;														-- Boolean flag so that the category is added only once
local added_vanc_errs;															-- Boolean flag so we only emit one Vancouver error / category
local added_generic_name_errs;													-- Boolean flag so we only emit one generic name error / category and stop testing names once an error is encountered
local added_numeric_name_errs;													-- Boolean flag so we only emit one numeric name error / category and stop testing names once an error is encountered
local added_numeric_name_maint;													-- Boolean flag so we only emit one numeric name maint category and stop testing names once a category has been emitted
local is_preview_mode;															-- true when article is in preview mode; false when using 'Preview page with this template' (previewing the module)
local is_sandbox;																-- true when using sandbox modules to render citation


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if utilities.is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a Boolean declared in page scope variables above

]]

local function add_vanc_error (source, position)
	if added_vanc_errs then return end
		
	added_vanc_errs = true;														-- note that we've added this category
	utilities.set_message ('err_vancouver', {source, position});
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a URI scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of TLDs: https://www.iana.org/domains/root/db

RFC 952 (modified by RFC 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the TLD.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a URL with a scheme) will be stripped
here.  Perhaps not necessary but retained in case it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ASCII characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the TLD) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and TLD or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%w]') then											-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at Wikisource
		return false;
	end

	local patterns = {															-- patterns that look like URLs
		'%f[%w][%w][%w%-]+[%w]%.%a%a+$',										-- three or more character hostname.hostname or hostname.tld
		'%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$',									-- internationalized domain name with ACE prefix
		'%f[%a][qxz]%.com$',													-- assigned one character .com hostname (x.com times out 2015-12-10)
		'%f[%a][iq]%.net$',														-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		'%f[%w][%w]%.%a%a$',													-- one character hostname and ccTLD (2 chars)
		'%f[%w][%w][%w]%.%a%a+$',												-- two character hostname and TLD
		'^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?',								-- IPv4 address
		'[%a%d]+%:?'                                                            -- IPv6 address
		}

	for _, pattern in ipairs (patterns) do										-- loop through the patterns list
		if domain:match (pattern) then
			return true;														-- if a match then we think that this thing that purports to be a URL is a URL
		end
	end

	for _, d in ipairs (cfg.single_letter_2nd_lvl_domains_t) do					-- look for single letter second level domain names for these top level domains
		if domain:match ('%f[%w][%w]%.' .. d) then
			return true
		end
	end
	return false;																-- no matches, we don't know what this thing is
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a URL appear to be a valid URL; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if utilities.is_set (scheme) then											-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when URL is protocol-relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a URL into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following TLD) (if any) and any path(/), query(?) or fragment(#).

If protocol-relative URL, return nil scheme and domain else return nil for both scheme and domain.

When not protocol-relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Any URL that does not have news: scheme must have authority indicator (//).  TODO: are there other common schemes
like news: that don't use authority indicator?

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol-relative URL
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		if utilities.is_set (authority) then
			authority = authority:gsub ('//', '', 1);							-- replace place 1 pair of '/' with nothing;
			if utilities.is_set(authority) then									-- if anything left (1 or 3+ '/' where authority should be) then
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		else
			if not scheme:match ('^news:') then									-- except for news:..., MediaWiki won't link URLs that do not have authority indicator; TODO: a better way to do this test?
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link=, etc. for properly formatted content: no wikilinks, no URLs

Link parameters are to hold the title of a Wikipedia article, so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki URLs and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid URL (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid URL (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then                                          -- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from URL; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid URL
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wiki-linked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

check &lt;link&gt; for inter-language interwiki-link prefix.  prefix must be a MediaWiki-recognized language
code and must begin with a colon.

]]

local function link_title_ok (link, lorig, title, torig)
	local orig;
	if utilities.is_set (link) then 											-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		elseif link:match ('^%a+:') then										-- if the link is what looks like an interwiki
			local prefix = link:match ('^(%a+):'):lower();						-- get the interwiki prefix

			if cfg.inter_wiki_map[prefix] then									-- if prefix is in the map, must have preceding colon
				orig = lorig;													-- flag as error
			end
		end
	end

	if utilities.is_set (orig) then
		link = '';																-- unset
		utilities.set_message ('err_bad_paramlink', orig);						-- URL or wikilink in |title= with |title-link=;
	end
	
	return link;																-- link if ok, empty string else
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the URL into scheme and domain
portions, or for protocol-relative (//example.com) URLs, just the domain.  Use is_url() to validate the two
portions of the URL.  If both are valid, or for protocol-relative if domain is valid, return true, else false.

Because it is different from a standard URL, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper URL
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from URL;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a URL.  The test will also find external wikilinks
that use protocol-relative URLs. Also finds bare URLs.

The frontier pattern prevents a match on interwiki-links which are similar to scheme:path URLs.  The tests that
find bracketed URLs are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext. wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol-relative ext. wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare URL with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('^//%S+') or value:match ('%s//%S+') then				-- if protocol-relative bare URL: //yyyyy.zzz; authority indicator (//) must be be preceded nothing or by whitespace
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a URL
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list, error_list)
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a URL add an error message
			table.insert (error_list, utilities.wrap_style ('parameter', k));
		end
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		utilities.set_message ('err_wikilink_in_url', {});
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link (URL, label, source, access)
	local err_msg = '';
	local domain;
	local path;
	local base_url;

	if not utilities.is_set (label) then
		label = URL;
		if utilities.is_set (source) then
			utilities.set_message ('err_bare_url_missing_title', {utilities.wrap_style ('parameter', source)});
		else
			error (cfg.messages[&quot;bare_url_no_origin&quot;]);							-- programmer error; valid parameter name does not have matching meta-parameter
		end			
	end
	if not check_url (URL) then
		utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)});
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the URL into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['['] = '%5b', [']'] = '%5d'});			-- replace '[' and ']' with their percent-encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat ({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wiki-markup URL

	if utilities.is_set (access) then											-- access level (subscription, registration, limited)
		base_url = utilities.substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end

	return base_url;
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a Boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		utilities.set_message ('err_deprecated_params', {name});				-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wiki-markup) are not kerned.

Replaces Unicode quote marks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc.; not for book titles.

]=]

local function kern_quotes (str)
	local cap = '';
	local wl_type, label, link;

	wl_type, label, link = utilities.is_wikilink (str);							-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-left'], str);
			str = utilities.substitute (cfg.presentation['kern-right'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = utilities.substitute (cfg.presentation['kern-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label = mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label = mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap = mw.ustring.match (label, &quot;^([\&quot;\'][^\'].+)&quot;);						-- match leading double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-left'], cap);
		end
	
		cap = mw.ustring.match (label, &quot;^(.+[^\'][\&quot;\'])$&quot;)						-- match trailing double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-right'], cap);
		end
		
		if 2 == wl_type then
			str = utilities.make_wikilink (link, label);						-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin-based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate RTL languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO 639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO 639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title=, |script-chapter=, |script-&lt;periodical&gt;=

]]

local function format_script_value (script_value, script_param)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%l?%s*:') then									-- if first 3 or 4 non-space characters are script language prefix
		lang = script_value:match('^(%l%l%l?)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not utilities.is_set (lang) then
			utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['missing title part']});		-- prefix without 'title'; add error message
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_tag_remap[lang] or mw.language.fetchLanguageName( lang, cfg.this_wiki_code );	-- get language name so that we can use it to categorize
		if utilities.is_set (name) then											-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l+%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if utilities.in_array (lang, cfg.script_lang_codes) then
				utilities.add_prop_cat ('script', {name, lang})
			else
				utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['unknown language code']});	-- unknown script-language; add error message
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['invalid language code']});		-- invalid language code; add error message
			lang = '';															-- invalid so set lang to empty string
		end
	else
		utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['missing prefix']});				-- no language code prefix; add error message
	end
	script_value = utilities.substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is RTL

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script
value has been wrapped in &lt;bdi&gt; tags.

]]

local function script_concatenate (title, script, script_param)
	if utilities.is_set (script) then
		script = format_script_value (script, script_param);					-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; returns empty string on error
		if utilities.is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not utilities.is_set ( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return utilities.substitute ( msg, str );								-- including template text
	else
		return utilities.substitute ( cfg.messages[key], str );
	end		
end


--[[----------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;-------------------

Makes a Wikisource URL from Wikisource interwiki-link.  Returns the URL and appropriate
label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;
	local wikisource_prefix = table.concat ({'https://', cfg.this_wiki_code, '.wikisource.org/wiki/'});

	wl_type, D, L = utilities.is_wikilink (str);								-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 1 == wl_type then													-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end

	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable URL
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent-encoding of fragment marker
	end

	return ws_url, ws_label, L or D;											-- return proper URL or nil and a label or nil
end


--[[----------------&lt; F O R M A T _ P E R I O D I C A L &gt;-----------------------

Format the three periodical parameters: |script-&lt;periodical&gt;=, |&lt;periodical&gt;=,
and |trans-&lt;periodical&gt;= into a single Periodical meta-parameter.

]]

local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)

	if not utilities.is_set (periodical) then
		periodical = '';														-- to be safe for concatenation
	else
		periodical = utilities.wrap_style ('italic-title', periodical);			-- style 
	end

	periodical = script_concatenate (periodical, script_periodical, script_periodical_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (trans_periodical) then
		trans_periodical = utilities.wrap_style ('trans-italic-title', trans_periodical);
		if utilities.is_set (periodical) then
			periodical = periodical .. ' ' .. trans_periodical;
		else																	-- here when trans-periodical without periodical or script-periodical
			periodical = trans_periodical;
			utilities.set_message ('err_trans_missing_title', {'periodical'});
		end
	end

	return periodical;
end


--[[------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;---------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=,
and |chapter-url= into a single chapter meta- parameter (chapter_url_source used
for error messages).

]]

local function format_chapter_title (script_chapter, script_chapter_source, chapter, chapter_source, trans_chapter, trans_chapter_source, chapter_url, chapter_url_source, no_quotes, access)
	local ws_url, ws_label, L = wikisource_url_make (chapter);					-- make a wikisource URL and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', ' ');									-- replace underscore separators with space characters
		chapter = ws_label;
	end

	if not utilities.is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from module provided quote marks
			chapter = utilities.wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, script_chapter, script_chapter_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (chapter_url) then
		chapter = external_link (chapter_url, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');	-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if utilities.is_set (trans_chapter) then
		trans_chapter = utilities.wrap_style ('trans-quoted-title', trans_chapter);
		if utilities.is_set (chapter) then
			chapter = chapter .. ' ' .. trans_chapter;
		else																	-- here when trans_chapter without chapter or script-chapter
			chapter = trans_chapter;
			chapter_source = trans_chapter_source:match ('trans%-?(.+)');		-- when no chapter, get matching name from trans-&lt;param&gt;
			utilities.set_message ('err_trans_missing_title', {chapter_source});
		end
	end

	return chapter;
end


--[[----------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;-------------------

This function searches a parameter's value for non-printable or invisible characters.
The search stops at the first match.

This function will detect the visible replacement character when it is part of the Wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers
(gallery, math, pre, ref) and identifies them with a slightly different error message.
See also coins_cleanup().

Output of this function is an error message that identifies the character or the
Unicode group, or the stripmarker that was detected along with its position (or,
for multi-byte characters, the position of its first byte) in the parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local stripmarker;															-- boolean set true when a stripmarker is found

	capture = string.match (v, '[%w%p ]*');										-- test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no Unicode characters
		return;
	end

	for _, invisible_char in ipairs (cfg.invisible_chars) do
		local char_name = invisible_char[1];									-- the character or group name
		local pattern = invisible_char[2];										-- the pattern used to find it
		position, _, capture = mw.ustring.find (v, pattern);					-- see if the parameter value contains characters that match the pattern
		
		if position and (cfg.invisible_defs.zwj == capture) then				-- if we found a zero-width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- it's ok if one of the Indic scripts
				position = nil;													-- unset position
			elseif cfg.emoji_t[mw.ustring.codepoint (v, position+1)] then			-- is zwj followed by a character listed in emoji{}?
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and utilities.in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and cfg.invisible_defs.del == capture then	-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture and not (cfg.invisible_defs.del == capture or cfg.invisible_defs.zwj == capture) then
					err_msg = capture .. ' ' .. char_name;
				else
					err_msg = char_name .. ' ' .. 'character';
				end

				utilities.set_message ('err_invisible_char', {err_msg, utilities.wrap_style ('parameter', param), position});	-- add error message
				return;															-- and done with this parameter
			end
		end
	end
end


--[[-------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------

Argument wrapper.  This function provides support for argument mapping defined
in the configuration file so that multiple names can be transparently aliased to
single internal variable.

]]

local function argument_wrapper ( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function ( self, k )
			local dummy = self[k];												-- force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = utilities.select_one ( args, list, 'err_redundant_parameters' );
				if origin[k] == nil then
					origin[k] = '';												-- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] .. ': ' .. k);
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;-------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.
When date is DD MMMM YYYY or is MMMM DD, YYYY then wrap in nowrap span:
&lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap = '';
	local cap2 = '';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = utilities.substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = utilities.substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;---------------------

This function sets default title types (equivalent to the citation including
|type=&lt;default value&gt;) for those templates that have defaults. Also handles the
special case where it is desirable to omit the title type from the rendered citation
(|type=none).

]]

local function set_titletype (cite_class, title_type)
	if utilities.is_set (title_type) then
		if 'none' == cfg.keywords_xlate[title_type] then
			title_type = '';													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; S A F E _ J O I N &gt;-----------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'duplicate character'
		if 1 == #duplicate_char then											-- for single byte ASCII characters use the string library functions
			f.gsub = string.gsub
			f.match = string.match
			f.sub = string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub = mw.ustring.gsub
			f.match = mw.ustring.match
			f.sub = mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1, 1) == '&lt;' then										-- special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove HTML markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1, 1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc.?
				trim = false;
				end_chr = f.sub(str, -1, -1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr .. &quot;)&quot;				-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1, -2);									-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;''&quot; then		-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5, -1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;]]&quot; then		-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3, -1) == duplicate_char .. '&quot;]' then	-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2, -1) == duplicate_char .. &quot;]&quot; then	-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2, -1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1, -3);								-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains HTML markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows HTML markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value; 												-- add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;-----------------------------

returns true if suffix is properly formed Jr, Sr, or ordinal in the range 1–9.
Puncutation not allowed.

]]

local function is_suffix (suffix)
	if utilities.in_array (suffix, {'Jr', 'Sr', 'Jnr', 'Snr', '1st', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;-------------------

For Vancouver style, author/editor names are supposed to be rendered in Latin
(read ASCII) characters.  When a name uses characters that contain diacritical
marks, those characters are to be converted to the corresponding Latin
character. When a name is written using a non-Latin alphabet or logogram, that
name is to be transliterated into Latin characters. The module doesn't do this
so editors may/must.

This test allows |first= and |last= names to contain any of the letters defined
in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes.
	(http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;)
	or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written outside of the code editor and pasted here because the code editor
gets confused between character insertion point and cursor position. The test has
been rewritten to use decimal character escape sequence for the individual bytes
of the Unicode characters so that it is not necessary to use an external editor
to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first, suffix, position)
	if not suffix then
		if first:find ('[,%s]') then											-- when there is a space or comma, might be first name/initials + generational suffix
			first = first:match ('(.-)[,%s]+');									-- get name/initials
			suffix = first:match ('[,%s]+(.+)$');								-- get generational suffix
		end
	end
	if utilities.is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error (cfg.err_msg_supl.suffix, position);
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143\225\184\128-\225\187\191%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143\225\184\128-\225\187\191%-%s%'%.]*$&quot;) then
			add_vanc_error (cfg.err_msg_supl['non-Latin char'], position);
			return false;														-- not a string of Latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-style=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period.
See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc.) to be rendered
as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format
because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the
Unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials (first, position)
	if first:find (',', 1, true) then
		return first;															-- commas not allowed; abandon
	end

	local name, suffix = mw.ustring.match (first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match (first, &quot;^(%u+)$&quot;);								-- is it just initials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error (cfg.err_msg_supl.suffix, position);			-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word

	local initials_t, names_t = {}, {};											-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names_t = mw.text.split (first, '[%s%-]+');									-- split into a sequence of names and possible suffix

	while names_t[i] do															-- loop through the sequence
		if 1 &lt; i and names_t[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names_t[i] = names_t[i]:gsub ('%.', '');							-- remove terminal dot if present
			if is_suffix (names_t[i]) then										-- if a legitimate suffix
				table.insert (initials_t, ' ' .. names_t[i]);					-- add a separator space, insert at end of initials sequence
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials_t, mw.ustring.sub (names_t[i], 1, 1));		-- insert the initial at end of initials sequence
		end
		i = i + 1;																-- bump the counter
	end
			
	return table.concat (initials_t);											-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; I N T E R W I K I _ P R E F I X E N _ G E T &gt;----------------------------------

extract interwiki prefixen from &lt;value&gt;.  Returns two one or two values:
	false – no prefixen
	nil – prefix exists but not recognized
	project prefix, language prefix – when value has either of:
		:&lt;project&gt;:&lt;language&gt;:&lt;article&gt;
		:&lt;language&gt;:&lt;project&gt;:&lt;article&gt;
	project prefix, nil – when &lt;value&gt; has only a known single-letter prefix
	nil, language prefix – when &lt;value&gt; has only a known language prefix

accepts single-letter project prefixen: 'd' (wikidata), 's' (wikisource), and 'w' (wikipedia) prefixes; at this
writing, the other single-letter prefixen (b (wikibook), c (commons), m (meta), n (wikinews), q (wikiquote), and
v (wikiversity)) are not supported.

]]

local function interwiki_prefixen_get (value, is_link)
	if not value:find (':%l+:') then											-- if no prefix
		return false;															-- abandon; boolean here to distinguish from nil fail returns later
	end

	local prefix_patterns_linked_t = {											-- sequence of valid interwiki and inter project prefixen
		'^%[%[:([dsw]):(%l%l+):',												-- wikilinked; project and language prefixes
		'^%[%[:(%l%l+):([dsw]):',												-- wikilinked; language and project prefixes
		'^%[%[:([dsw]):',														-- wikilinked; project prefix
		'^%[%[:(%l%l+):',														-- wikilinked; language prefix
		}
		
	local prefix_patterns_unlinked_t = {										-- sequence of valid interwiki and inter project prefixen
		'^:([dsw]):(%l%l+):',													-- project and language prefixes
		'^:(%l%l+):([dsw]):',													-- language and project prefixes
		'^:([dsw]):',															-- project prefix
		'^:(%l%l+):',															-- language prefix
		}
	
	local cap1, cap2;
	for _, pattern in ipairs ((is_link and prefix_patterns_linked_t) or prefix_patterns_unlinked_t) do
		cap1, cap2 = value:match (pattern);
		if cap1 then
			break;																-- found a match so stop looking
		end
	end
	
	if cap1 and cap2 then														-- when both then :project:language: or :language:project: (both forms allowed)
		if 1 == #cap1 then														-- length == 1 then :project:language:
			if cfg.inter_wiki_map[cap2] then									-- is language prefix in the interwiki map?
				return cap1, cap2;												-- return interwiki project and interwiki language
			end
		else																	-- here when :language:project:
			if cfg.inter_wiki_map[cap1] then									-- is language prefix in the interwiki map?
				return cap2, cap1;												-- return interwiki project and interwiki language
			end
		end
		return nil;																-- unknown interwiki language
	elseif not (cap1 or cap2) then												-- both are nil?
		return nil;																-- we got something that looks like a project prefix but isn't; return fail
	elseif 1 == #cap1 then														-- here when one capture
		return cap1, nil;														-- length is 1 so return project, nil language
	else																		-- here when one capture and its length it more than 1
		if cfg.inter_wiki_map[cap1] then										-- is language prefix in the interwiki map?
			return nil, cap1;													-- return nil project, language
		end
	end
end


--[[--------------------------&lt; L I S T _ P E O P L E &gt;--------------------------

Formats a list of people (authors, contributors, editors, interviewers, translators) 

names in the list will be linked when
	|&lt;name&gt;-link= has a value
	|&lt;name&gt;-mask- does NOT have a value; masked names are presumed to have been
		rendered previously so should have been linked there

when |&lt;name&gt;-mask=0, the associated name is not rendered

]]

local function list_people (control, people, etal)
	local sep;
	local namesep;
	local format = control.format;
	local maximum = control.maximum;
	local name_list = {};

	if 'vanc' == format then													-- Vancouver-like name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between names is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between names is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub (-1, -1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if utilities.is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end		-- returned 0 is for EditorCount; not used for other names
	
	for i, person in ipairs (people) do
		if utilities.is_set (person.last) then
			local mask = person.mask;
			local one;
			local sep_one = sep;

			if utilities.is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			end
			
			if mask then
				local n = tonumber (mask);										-- convert to a number if it can be converted; nil else
				if n then
					one = 0 ~= n and string.rep(&quot;&amp;mdash;&quot;, n) or nil;			-- make a string of (n &gt; 0) mdashes, nil else, to replace name
					person.link = nil;											-- don't create link to name if name is replaces with mdash string or has been set nil
				else
					one = mask;													-- replace name with mask text (must include name-list separator)
					sep_one = &quot; &quot;;												-- modify name-list separator
				end
			else
				one = person.last;												-- get surname
				local first = person.first										-- get given name
				if utilities.is_set (first) then
					if (&quot;vanc&quot; == format) then									-- if Vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first, nil, i) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials (first, i);				-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
			end
			if utilities.is_set (person.link) then
				one = utilities.make_wikilink (person.link, one);				-- link author/editor
			end

			if one then															-- if &lt;one&gt; has a value (name, mdash replacement, or mask text replacement)
				local proj, tag = interwiki_prefixen_get (one, true);			-- get the interwiki prefixen if present
				if 'w' == proj and ('Wikipedia' == mw.site.namespaces.Project['name']) then
					proj = nil;													-- for stuff like :w:de:&lt;article&gt;, :w is unnecessary TODO: maint cat?
				end
				if proj then
					local proj_name = ({['d'] = 'Wikidata', ['s'] = 'Wikisource', ['w'] = 'Wikipedia'})[proj];	-- :w (wikipedia) for linking from a non-wikipedia project
					if proj_name then 
						one = one .. utilities.wrap_style ('interproj', proj_name);	-- add resized leading space, brackets, static text, language name
						utilities.add_prop_cat ('interproj-linked-name', proj);	-- categorize it; &lt;proj&gt; is sort key
						tag = nil;												-- unset; don't do both project and language
					end
				end
				if tag == cfg.this_wiki_code then
					tag = nil;													-- stuff like :en:&lt;article&gt; at en.wiki is pointless TODO: maint cat?
				end
				if tag then
					local lang = cfg.lang_tag_remap[tag] or cfg.mw_languages_by_tag_t[tag];
					if lang then												-- error messaging done in extract_names() where we know parameter names
						one = one .. utilities.wrap_style ('interwiki', lang);	-- add resized leading space, brackets, static text, language name
						utilities.add_prop_cat ('interwiki-linked-name', tag);	-- categorize it; &lt;tag&gt; is sort key
					end
				end

				table.insert (name_list, one);									-- add it to the list of names
				table.insert (name_list, sep_one);								-- add the proper name-list separator
			end
		end
	end

	local count = #name_list / 2;												-- (number of names + number of separators) divided by 2
	if 0 &lt; count then 
		if 1 &lt; count and not etal then
			if 'amp' == format then
				name_list[#name_list-2] = &quot; &amp; &quot;;								-- replace last separator with ampersand text
			elseif 'and' == format then
				if 2 == count then
					name_list[#name_list-2] = cfg.presentation.sep_nl_and;		-- replace last separator with 'and' text
				else
					name_list[#name_list-2] = cfg.presentation.sep_nl_end;		-- replace last separator with '(sep) and' text
				end
			end
		end
		name_list[#name_list] = nil;											-- erase the last separator
	end

	local result = table.concat (name_list);									-- construct list
	if etal and utilities.is_set (result) then									-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. cfg.messages['et al'];						-- we've got a last-first list and etal so add et al.
	end
	
	return result, count;														-- return name-list string and count of number of names (count used for editor names only)
end


--[[--------------------&lt; M A K E _ C I T E R E F _ I D &gt;-----------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise
returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that
order.  year is Year or anchor_year.

]]

local function make_citeref_id (namelist, year)
	local names={};							-- a table for the one to four names and year
	for i,v in ipairs (namelist) do			-- loop through the list and take up to the first four last names
		names[i] = v.last
		if i == 4 then break end			-- if four then done
	end
	table.insert (names, year);				-- add the year at the end
	local id = table.concat(names);			-- concatenate names and year for CITEREF id
	if utilities.is_set (id) then			-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;				-- add the CITEREF portion
	else
		return '';							-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; C I T E _ C L A S S _A T T R I B U T E _M A K E &gt;------------------------------

construct &lt;cite&gt; tag class attribute for this citation.

&lt;cite_class&gt; – config.CitationClass from calling template
&lt;mode&gt; – value from |mode= parameter

]]

local function cite_class_attribute_make (cite_class, mode)
	local class_t = {};
	table.insert (class_t, 'citation');											-- required for blue highlight
	if 'citation' ~= cite_class then
		table.insert (class_t, cite_class);										-- identify this template for user css
		table.insert (class_t, utilities.is_set (mode) and mode or 'cs1');		-- identify the citation style for user css or javascript
	else
		table.insert (class_t, utilities.is_set (mode) and mode or 'cs2');		-- identify the citation style for user css or javascript
	end
	for _, prop_key in ipairs (z.prop_keys_t) do
		table.insert (class_t, prop_key);										-- identify various properties for user css or javascript
	end

	return table.concat (class_t, ' ');											-- make a big string and done
end


--[[---------------------&lt; N A M E _ H A S _ E T A L &gt;--------------------------

Evaluates the content of name parameters (author, editor, etc.) for variations on
the theme of et al.  If found, the et al. is removed, a flag is set to true and
the function returns the modified name and the flag.

This function never sets the flag to false but returns its previous state because
it may have been set by previous passes through this function or by the associated
|display-&lt;names&gt;=etal parameter

]]

local function name_has_etal (name, etal, nocat, param)

	if utilities.is_set (name) then												-- name can be nil in which case just return
		local patterns = cfg.et_al_patterns; 									-- get patterns from configuration
		
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns
			if name:match (pattern) then										-- if this 'et al' pattern is found in name
				name = name:gsub (pattern, '');									-- remove the offending text
				etal = true;													-- set flag (may have been set previously here or by |display-&lt;names&gt;=etal)
				if not nocat then												-- no categorization for |vauthors=
					utilities.set_message ('err_etal', {param});				-- and set an error if not added
				end
			end
		end
	end

	return name, etal;
end


--[[---------------------&lt; N A M E _ I S _ N U M E R I C &gt;----------------------

Add an error message and category when &lt;name&gt; parameter value does not contain letters.  

Add a maintenance category when &lt;name&gt; parameter value has numeric characters mixed with characters that are 
not numeric characters; could be letters and/or punctuation characters.

This function will only emit one error and one maint message for the current template.  Does not emit both error
and maint messages/categories for the same parameter value.

returns nothing

]]

local function name_is_numeric (name, name_alias, list_name)
	local patterns = {
		'^%D+%d',																-- &lt;name&gt; must have digits preceded by other characters
		'^%D*%d+%D+',															-- &lt;name&gt; must have digits followed by other characters
		}

	if not added_numeric_name_errs and mw.ustring.match (name, '^[%A]+$') then	-- if we have not already set an error message and &lt;name&gt; does not have any alpha characters
		utilities.set_message ('err_numeric_names', name_alias);				-- add an error message
		added_numeric_name_errs = true;											-- set the flag so we emit only one error message
		return;																	-- when here no point in further testing; abandon
	end

	if not added_numeric_name_maint then										-- if we have already set a maint message
		for _, pattern in ipairs (patterns) do									-- spin through list of patterns
			if mw.ustring.match (name, pattern) then							-- digits preceded or followed by anything but digits; %D+ includes punctuation
				utilities.set_message ('maint_numeric_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
				added_numeric_name_maint = true;								-- set the flag so we emit only one maint message
				return;															-- when here no point in further testing; abandon
			end
		end
	end
end


--[[-----------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;------------------

Evaluates the content of last/surname (authors etc.) parameters for multiple names.
Multiple names are indicated if there is more than one comma or any &quot;unescaped&quot;
semicolons. Escaped semicolons are ones used as part of selected HTML entities.
If the condition is met, the function adds the multiple name maintenance category.

Same test for first except that commas should not appear in given names (MOS:JR says
that the generational suffix does not take a separator character).  Titles, degrees,
postnominals, affiliations, all normally comma separated don't belong in a citation.

&lt;name&gt; – name parameter value
&lt;list_name&gt; – AuthorList, EditorList, etc
&lt;limit&gt; – number of allowed commas; 1 (default) for surnames; 0 for given names

returns nothing

]]

local function name_has_mult_names (name, list_name, limit)
	local _, commas, semicolons, nbsps;
	limit = limit and limit or 1;
	if utilities.is_set (name) then
		_, commas = name:gsub (',', '');										-- count the number of commas
		_, semicolons = name:gsub (';', '');									-- count the number of semicolons
		-- nbsps probably should be its own separate count rather than merged in
		-- some way with semicolons because Lua patterns do not support the
		-- grouping operator that regex does, which means there is no way to add
		-- more entities to escape except by adding more counts with the new
		-- entities
		_, nbsps = name:gsub ('&amp;nbsp;','');										-- count nbsps
		
		-- There is exactly 1 semicolon per &amp;nbsp; entity, so subtract nbsps
		-- from semicolons to 'escape' them. If additional entities are added,
		-- they also can be subtracted.
		if limit &lt; commas or 0 &lt; (semicolons - nbsps) then
			utilities.set_message ('maint_mult_names', cfg.special_case_translation [list_name]);	-- add a maint message
		end
	end
end


--[=[-------------------------&lt; I S _ G E N E R I C &gt;----------------------------------------------------------

Compares values assigned to various parameters according to the string provided as &lt;item&gt; in the function call.
&lt;item&gt; can have on of two values:
	'generic_names' – for name-holding parameters: |last=, |first=, |editor-last=, etc
	'generic_titles' – for |title=

There are two types of generic tests.  The 'accept' tests look for a pattern that should not be rejected by the
'reject' test.  For example,
	|author=[[John Smith (author)|Smith, John]]
would be rejected by the 'author' reject test.  But piped wikilinks with 'author' disambiguation should not be
rejected so the 'accept' test prevents that from happening.  Accept tests are always performed before reject
tests.

Each of the 'accept' and 'reject' sequence tables hold tables for en.wiki (['en']) and local.wiki (['local'])
that each can hold a test sequence table  The sequence table holds, at index [1], a test pattern, and, at index
[2], a boolean control value.  The control value tells string.find() or mw.ustring.find() to do plain-text search (true)
or a pattern search (false).  The intent of all this complexity is to make these searches as fast as possible so
that we don't run out of processing time on very large articles.

Returns
	true when a reject test finds the pattern or string
	false when an accept test finds the pattern or string
	nil else

]=]

local function is_generic (item, value, wiki)
	local test_val;
	local str_lower = {															-- use string.lower() for en.wiki (['en']) and use mw.ustring.lower() or local.wiki (['local'])
		['en'] = string.lower,
		['local'] = mw.ustring.lower,
		}
	local str_find = {															-- use string.find() for en.wiki (['en']) and use mw.ustring.find() or local.wiki (['local'])
		['en'] = string.find,
		['local'] = mw.ustring.find,
		}

	local function test (val, test_t, wiki)										-- local function to do the testing; &lt;wiki&gt; selects lower() and find() functions
		val = test_t[2] and str_lower[wiki](value) or val;						-- when &lt;test_t[2]&gt; set to 'true', plaintext search using lowercase value
		return str_find[wiki] (val, test_t[1], 1, test_t[2]);					-- return nil when not found or matched
	end
		
	local test_types_t = {'accept', 'reject'};									-- test accept patterns first, then reject patterns
	local wikis_t = {'en', 'local'};											-- do tests for each of these keys; en.wiki first, local.wiki second

	for _, test_type in ipairs (test_types_t) do								-- for each test type
		for _, generic_value in pairs (cfg.special_case_translation[item][test_type]) do	-- spin through the list of generic value fragments to accept or reject
			for _, wiki in ipairs (wikis_t) do
				if generic_value[wiki] then
					if test (value, generic_value[wiki], wiki) then				-- go do the test
						return ('reject' == test_type);							-- param value rejected, return true; false else
					end
				end
			end
		end
	end
end


--[[--------------------------&lt; N A M E _ I S _ G E N E R I C &gt;------------------------------------------------

calls is_generic() to determine if &lt;name&gt; is a 'generic name' listed in cfg.generic_names; &lt;name_alias&gt; is the
parameter name used in error messaging

]]

local function name_is_generic (name, name_alias)
	if not added_generic_name_errs  and is_generic ('generic_names', name) then
		utilities.set_message ('err_generic_name', name_alias);					-- set an error message
		added_generic_name_errs = true;
	end
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------

This function calls various name checking functions used to validate the content of the various name-holding parameters.

]]

local function name_checks (last, first, list_name, last_alias, first_alias)
	local accept_name;

	if utilities.is_set (last) then
		last, accept_name = utilities.has_accept_as_written (last);				-- remove accept-this-as-written markup when it wraps all of &lt;last&gt;

		if not accept_name then													-- &lt;last&gt; not wrapped in accept-as-written markup
			name_has_mult_names (last, list_name);								-- check for multiple names in the parameter
			name_is_numeric (last, last_alias, list_name);						-- check for names that have no letters or are a mix of digits and other characters
			name_is_generic (last, last_alias);									-- check for names found in the generic names list
		end
	end

	if utilities.is_set (first) then
		first, accept_name = utilities.has_accept_as_written (first);			-- remove accept-this-as-written markup when it wraps all of &lt;first&gt;

		if not accept_name then													-- &lt;first&gt; not wrapped in accept-as-written markup
			name_has_mult_names (first, list_name, 0);							-- check for multiple names in the parameter; 0 is number of allowed commas in a given name
			name_is_numeric (first, first_alias, list_name);					-- check for names that have no letters or are a mix of digits and other characters
			name_is_generic (first, first_alias);								-- check for names found in the generic names list
		end
		local wl_type, D = utilities.is_wikilink (first);
		if 0 ~= wl_type then
			first = D;
			utilities.set_message ('err_bad_paramlink', first_alias);
		end
	end

	return last, first;															-- done
end


--[[----------------------&lt; E X T R A C T _ N A M E S &gt;-------------------------

Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters
(or their aliases), and their matching link and mask parameters. Stops searching
when both |lastn= and |firstn= are not found in args after two sequential attempts:
found |last1=, |last2=, and |last3= but doesn't find |last4= and |last5= then the
search is done.

This function emits an error message when there is a |firstn= without a matching
|lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not
required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.'
is stripped from the parameter and a flag (etal) returned that will cause list_people()
to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps
'et al.' out of the template's metadata.  When this occurs, an error is emitted.

]]

local function extract_names(args, list_name)
	local names = {};															-- table of names
	local last;																	-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;																-- loop counter/indexer
	local n = 1;																-- output table indexer
	local count = 0;															-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal = false;															-- return value set to true when we find some form of et al. in an author parameter

	local last_alias, first_alias, link_alias;									-- selected parameter aliases used in error messaging
	while true do
		last, last_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'err_redundant_parameters', i );		-- search through args for name components beginning at 1
		first, first_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'err_redundant_parameters', i );
		link, link_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i );
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
	
		if last then															-- error check |lastn= alias for unknown interwiki link prefix; done here because this is where we have the parameter name
			local project, language = interwiki_prefixen_get (last, true);		-- true because we expect interwiki links in |lastn= to be wikilinked
			if nil == project and nil == language then							-- when both are nil
				utilities.set_message ('err_bad_paramlink', last_alias);		-- not known, emit an error message	-- TODO: err_bad_interwiki?
				last = utilities.remove_wiki_link (last);						-- remove wikilink markup; show display value only
			end
		end
		
		if link then															-- error check |linkn= alias for unknown interwiki link prefix
			local project, language = interwiki_prefixen_get (link, false);		-- false because wiki links in |author-linkn= is an error
			if nil == project and nil == language then							-- when both are nil
				utilities.set_message ('err_bad_paramlink', link_alias);		-- not known, emit an error message	-- TODO: err_bad_interwiki?
				link = nil;														-- unset so we don't link
				link_alias = nil;
			end
		end
		
		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.
		last, first = name_checks (last, first, list_name, last_alias, first_alias);						-- multiple names, extraneous annotation, etc. checks

		if first and not last then												-- if there is a firstn without a matching lastn
			local alias = first_alias:find ('given', 1, true) and 'given' or 'first';	-- get first or given form of the alias
			utilities.set_message ('err_first_missing_last', {
				first_alias,													-- param name of alias missing its mate
				first_alias:gsub (alias, {['first'] = 'last', ['given'] = 'surname'}),	-- make param name appropriate to the alias form
				});																-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			local result;
			link = link_title_ok (link, link_alias, last, last_alias);			-- check for improper wiki-markup

			if first then
				link = link_title_ok (link, link_alias, first, first_alias);	-- check for improper wiki-markup
			end

			names[n] = {last = last, first = first, link = link, mask = mask, corporate = false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				utilities.set_message ('err_missing_name', {list_name:match (&quot;(%w+)List&quot;):lower(), i - 1});	-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names and the etal flag
end


--[[--------------------------&lt; N A M E _ T A G _ G E T &gt;------------------------------------------------------

attempt to decode |language=&lt;lang_param&gt; and return language name and matching tag; nil else.

This function looks for:
	&lt;lang_param&gt; as a tag in cfg.lang_tag_remap{}
	&lt;lang_param&gt; as a name in cfg.lang_name_remap{}
	
	&lt;lang_param&gt; as a name in cfg.mw_languages_by_name_t
	&lt;lang_param&gt; as a tag in cfg.mw_languages_by_tag_t
when those fail, presume that &lt;lang_param&gt; is an IETF-like tag that MediaWiki does not recognize.  Strip all
script, region, variant, whatever subtags from &lt;lang_param&gt; to leave just a two or three character language tag
and look for the new &lt;lang_param&gt; in cfg.mw_languages_by_tag_t{}

on success, returns name (in properly capitalized form) and matching tag (in lowercase); on failure returns nil

]]

local function name_tag_get (lang_param)
	local lang_param_lc = mw.ustring.lower (lang_param);						-- use lowercase as an index into the various tables
	local name;
	local tag;

	name = cfg.lang_tag_remap[lang_param_lc];									-- assume &lt;lang_param_lc&gt; is a tag; attempt to get remapped language name 
	if name then																-- when &lt;name&gt;, &lt;lang_param&gt; is a tag for a remapped language name
		if cfg.lang_name_remap[name:lower()][2] ~= lang_param_lc then
			utilities.set_message ('maint_unknown_lang');						-- add maint category if not already added
			return name, cfg.lang_name_remap[name:lower()][2];					-- so return name and tag from lang_name_remap[name]; special case to xlate sr-ec and sr-el to sr-cyrl and sr-latn
		end
		return name, lang_param_lc;												-- so return &lt;name&gt; from remap and &lt;lang_param_lc&gt;
	end

	tag = lang_param_lc:match ('^(%a%a%a?)%-.*');								-- still assuming that &lt;lang_param_lc&gt; is a tag; strip script, region, variant subtags
	name = cfg.lang_tag_remap[tag];												-- attempt to get remapped language name with language subtag only
	if name then																-- when &lt;name&gt;, &lt;tag&gt; is a tag for a remapped language name
		return name, tag;														-- so return &lt;name&gt; from remap and &lt;tag&gt;
	end

	if cfg.lang_name_remap[lang_param_lc] then									-- not a remapped tag, assume &lt;lang_param_lc&gt; is a name; attempt to get remapped language tag 
		return cfg.lang_name_remap[lang_param_lc][1], cfg.lang_name_remap[lang_param_lc][2];	-- for this &lt;lang_param_lc&gt;, return a (possibly) new name and appropriate tag
	end

	name = cfg.mw_languages_by_tag_t[lang_param_lc];							-- assume that &lt;lang_param_lc&gt; is a tag; attempt to get its matching language name
	
	if name then
		return name, lang_param_lc;												-- &lt;lang_param_lc&gt; is a tag so return it and &lt;name&gt;
	end
	
	tag = cfg.mw_languages_by_name_t[lang_param_lc];							-- assume that &lt;lang_param_lc&gt; is a language name; attempt to get its matching tag
	
	if tag then
		return cfg.mw_languages_by_tag_t[tag], tag;								-- &lt;lang_param_lc&gt; is a name so return the name from the table and &lt;tag&gt;
	end

	tag = lang_param_lc:match ('^(%a%a%a?)%-.*');								-- is &lt;lang_param_lc&gt; an IETF-like tag that MediaWiki doesn't recognize? &lt;tag&gt; gets the language subtag; nil else

	if tag then
		name = cfg.mw_languages_by_tag_t[tag];									-- attempt to get a language name using the shortened &lt;tag&gt;
		if name then
			return name, tag;													-- &lt;lang_param_lc&gt; is an unrecognized IETF-like tag so return &lt;name&gt; and language subtag
		end
	end
end


--[[-------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code
is recognized by MediaWiki, use the returned name; if not, then use the value that
was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is
assigned to the category for that code: Category:Norwegian-language sources (no).
For valid three-character code languages, the page is assigned to the single category
for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does
not recognize three-character equivalents of two-character codes: code 'ar' is
recognized but code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th
where the language names or codes are separated from each other by commas with
optional space characters.

]]

local function language_parameter (lang)
	local tag;																	-- some form of IETF-like language tag; language subtag with optional region, sript, vatiant, etc subtags
	local lang_subtag;															-- ve populates |language= with mostly unecessary region subtags the MediaWiki does not recognize; this is the base language subtag
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_t = {};															-- table made from the value assigned to |language=

	local this_wiki_name = mw.language.fetchLanguageName (cfg.this_wiki_code, cfg.this_wiki_code);	-- get this wiki's language name

	names_t = mw.text.split (lang, '%s*,%s*');									-- names should be a comma separated list

	for _, lang in ipairs (names_t) do											-- reuse lang here because we don't yet know if lang is a language name or a language tag
		name, tag = name_tag_get (lang);										-- attempt to get name/tag pair for &lt;lang&gt;; &lt;name&gt; has proper capitalization; &lt;tag&gt; is lowercase

		if utilities.is_set (tag) then
			lang_subtag = tag:gsub ('^(%a%a%a?)%-.*', '%1');					-- for categorization, strip any IETF-like tags from language tag

			if cfg.this_wiki_code ~= lang_subtag then							-- when the language is not the same as this wiki's language
				if 2 == lang_subtag:len() then									-- and is a two-character tag
					utilities.add_prop_cat ('foreign-lang-source', {name, tag}, lang_subtag);		-- categorize it; tag appended to allow for multiple language categorization
				else															-- or is a recognized language (but has a three-character tag)
					utilities.add_prop_cat ('foreign-lang-source-2', {lang_subtag}, lang_subtag);			-- categorize it differently TODO: support multiple three-character tag categories per cs1|2 template?
				end
			elseif cfg.local_lang_cat_enable then								-- when the language and this wiki's language are the same and categorization is enabled
				utilities.add_prop_cat ('local-lang-source', {name, lang_subtag});		-- categorize it
			end
		else
			name = lang;														-- return whatever &lt;lang&gt; has so that we show something
			utilities.set_message ('maint_unknown_lang');						-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
 
	name = utilities.make_sep_list (#language_list, language_list);
	if (1 == #language_list) and (lang_subtag == cfg.this_wiki_code) then		-- when only one language, find lang name in this wiki lang name; for |language=en-us, 'English' in 'American English'
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[-----------------------&lt; S E T _ C S _ S T Y L E &gt;--------------------------

Gets the default CS style configuration for the given mode.
Returns default separator and either postscript as passed in or the default.
In CS1, the default postscript and separator are '.'.
In CS2, the default postscript is the empty string and the default separator is ','.

]]

local function set_cs_style (postscript, mode)
	if utilities.is_set(postscript) then
		-- emit a maintenance message if user postscript is the default cs1 postscript
		-- we catch the opposite case for cs2 in set_style
		if mode == 'cs1' and postscript == cfg.presentation['ps_' .. mode] then
			utilities.set_message ('maint_postscript');
		end
	else
		postscript = cfg.presentation['ps_' .. mode];
	end
	return cfg.presentation['sep_' .. mode], postscript;
end


--[[--------------------------&lt; S E T _ S T Y L E &gt;-----------------------------

Sets the separator and postscript styles. Checks the |mode= first and the
#invoke CitationClass second. Removes the postscript if postscript == none.

]]

local function set_style (mode, postscript, cite_class)
	local sep;
	if 'cs2' == mode then
		sep, postscript = set_cs_style (postscript, 'cs2');
	elseif 'cs1' == mode then
		sep, postscript = set_cs_style (postscript, 'cs1');
	elseif 'citation' == cite_class	then
		sep, postscript = set_cs_style (postscript, 'cs2');
	else
		sep, postscript = set_cs_style (postscript, 'cs1');
	end

	if cfg.keywords_xlate[postscript:lower()] == 'none' then
		-- emit a maintenance message if user postscript is the default cs2 postscript
		-- we catch the opposite case for cs1 in set_cs_style
		if 'cs2' == mode or ('cs1' ~= mode and 'citation' == cite_class) then	-- {{citation |title=Title |mode=cs1 |postscript=none}} should not emit maint message
			utilities.set_message ('maint_postscript');
		end
		postscript = '';
	end
	
	return sep, postscript
end


--[=[-------------------------&lt; I S _ P D F &gt;-----------------------------------

Determines if a URL has the file extension that is one of the PDF file extensions
used by [[MediaWiki:Common.css]] when applying the PDF icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or
		url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
		url:match ('%.PDF&amp;#035') or url:match ('%.pdf&amp;#035');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;-----------------------

Applies CSS style to |format=, |chapter-format=, etc.  Also emits an error message
if the format parameter does not have a matching URL parameter.  If the format parameter
is not set and the URL contains a file extension that is recognized as a PDF document
by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if utilities.is_set (format) then
		format = utilities.wrap_style ('format', format);						-- add leading space, parentheses, resize
		if not utilities.is_set (url) then
			utilities.set_message ('err_format_missing_url', {fmt_param, url_param});	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if URL is a PDF file then
		format = utilities.wrap_style ('format', 'PDF');						-- set format to PDF
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[---------------------&lt; G E T _ D I S P L A Y _ N A M E S &gt;------------------

Returns a number that defines the number of names displayed for author and editor
name lists and a Boolean flag to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero,
return the number and the previous state of the 'etal' flag (false by default
but may have been set to true if the name list contains some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number
that is one greater than the number of authors in the list and set the 'etal' flag true.
This will cause the list_people() to display all of the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors'], etc; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

This function sets an error message when |display-xxxxors= value greater than or equal to number of names but
not when &lt;max&gt; comes from {{cs1 config}} global settings.  When using global settings, &lt;param&gt; is set to the
keyword 'cs1 config' which is used to supress the normal error.  Error is suppressed because it is to be expected
that some citations in an article will have the same or fewer names that the limit specified in {{cs1 config}}.

]]

local function get_display_names (max, count, list_name, etal, param)
	if utilities.is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if (max &gt;= count) and ('cs1 config' ~= param) then					-- error when local |display-xxxxors= value greater than or equal to number of names; not an error when using global setting
				utilities.set_message ('err_disp_name', {param, max});			-- add error message
				max = nil;
			end
		else																	-- not a valid keyword or number
			utilities.set_message ('err_disp_name', {param, max});				-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[----------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;---------------

Adds error if |page=, |pages=, |quote-page=, |quote-pages= has what appears to be
some form of p. or pp. abbreviation in the first characters of the parameter content.

check page for extraneous p, p., pp, pp., pg, pg. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when page begins PX or P# but not Px
		      where x and X are letters and # is a digit
	bad pattern:  '^[Pp][PpGg]' matches when page begins pp, pP, Pp, PP, pg, pG, Pg, PG

]]

local function extra_text_in_page_check (val, name)
	if not val:match (cfg.vol_iss_pg_patterns.good_ppattern) then
		for _, pattern in ipairs (cfg.vol_iss_pg_patterns.bad_ppatterns) do		-- spin through the selected sequence table of patterns
			if val:match (pattern) then											-- when a match, error so
				utilities.set_message ('err_extra_text_pages', name);	 		-- add error message
				return;															-- and done
			end
		end
	end		
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ V O L _ I S S _ C H E C K &gt;------------------------

Adds error if |volume= or |issue= has what appears to be some form of redundant 'type' indicator.  Applies to
both; this function looks for issue text in both |issue= and |volume= and looks for volume-like text in |voluem=
and |issue=.

For |volume=:
	'V.', or 'Vol.' (with or without the dot) abbreviations or 'Volume' in the first characters of the parameter
	content (all case insensitive). 'V' and 'v' (without the dot) are presumed to be roman numerals so
	are allowed.

For |issue=:
	'No.', 'I.', 'Iss.' (with or without the dot) abbreviations, or 'Issue' in the first characters of the
	parameter content (all case insensitive); numero styling: 'n°' with degree sign U+00B0, and № precomposed
	numero sign U+2116.
	
Single character values ('v', 'i', 'n') allowed when not followed by separator character ('.', ':', '=', or
whitespace character) – param values are trimmed of whitespace by MediaWiki before delivered to the module.
	
&lt;val&gt; is |volume= or |issue= parameter value
&lt;name&gt; is |volume= or |issue= parameter name for error message
&lt;selector&gt; is 'v' for |volume=, 'i' for |issue=

sets error message on failure; returns nothing

]]

local function extra_text_in_vol_iss_check (val, name, selector)
	if not utilities.is_set (val) then
		return;
	end
	
	local handler = 'v' == selector and 'err_extra_text_volume' or 'err_extra_text_issue';
	val = val:lower();															-- force parameter value to lower case

	for _, pattern in ipairs (cfg.vol_iss_pg_patterns.vi_patterns_t) do			-- spin through the sequence table of patterns
		if val:match (pattern) then												-- when a match, error so
			utilities.set_message (handler, name);								-- add error message
			return;																-- and done
		end
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parentheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local _, accept = utilities.has_accept_as_written (vparam);
	if accept then
		utilities.add_prop_cat ('vanc-accept');									-- add properties category
	end
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a placeholder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parentheses
			local name = name_table[i];
			i = i + 1;															-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parentheses
					break;														-- and done reassembling so
				end
				i = i + 1;														-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = utilities.is_wikilink (name_table[i]);		-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i + 1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled parentheses ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the Vancouver error when a required comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		first = '';																-- set to empty string for concatenation and because it may have been set for previous author/editor
		local accept_name;
		v_name, accept_name = utilities.has_accept_as_written (v_name);			-- remove accept-this-as-written markup when it wraps all of &lt;v_name&gt;

		if accept_name then
			last = v_name;
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error (cfg.err_msg_supl.punctuation, i);
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s+&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be initials or generational suffix

			if not mw.ustring.match (first, '^%u+$') then						-- mw.ustring here so that later we will catch non-Latin characters
				suffix = first;													-- not initials so assume that whatever we got is a generational suffix
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end
			last = table.concat(lastfirstTable, ' ')							-- returns a string that is the concatenation of all other names that are not initials and generational suffix
			if not utilities.is_set (last) then
				first = '';														-- unset
				last = v_name;													-- last empty because something wrong with first
				add_vanc_error (cfg.err_msg_supl.name, i);
			end
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error (cfg.err_msg_supl['missing comma'], i);			-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- matches a space between two initials
			end
		else
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
		
		if utilities.is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first, suffix, i);							-- check first and last before restoring the suffix which may have a non-Latin digit
			if utilities.is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '', nil, i);
			end
		end

		link = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i ) or v_link_table[i];
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate = corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest;
|editorn= (and aliases) highest and |veditors= lowest (support for |editors= withdrawn)

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
	local lastfirst = false;
	if utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice in case we have a |first1= without a |last1=; this ...
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or		-- ... also catches the case where |first= is used with |vauthors=
		utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst = true;
	end

	if (utilities.is_set (vxxxxors) and true == lastfirst) or					-- these are the three error conditions
		(utilities.is_set (vxxxxors) and utilities.is_set (xxxxors)) or
		(true == lastfirst and utilities.is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			utilities.set_message ('err_redundant_parameters', err_name .. '-name-list parameters');	-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if utilities.is_set (vxxxxors) then return 2 end;
	if utilities.is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, live, dead, etc.).  When the parameter value has not been assigned a value (missing
or empty in the source template) the function returns the value specified by ret_val.  If the parameter value is one
of the list of allowed values returns the translated value; else, emits an error message and returns the value
specified by ret_val.

TODO: explain &lt;invert&gt;

]]

local function is_valid_parameter_value (value, name, possible, ret_val, invert)
	if not utilities.is_set (value) then
		return ret_val;															-- an empty parameter is ok
	end

	if (not invert and utilities.in_array (value, possible)) then				-- normal; &lt;value&gt; is in &lt;possible&gt; table
		return cfg.keywords_xlate[value];										-- return translation of parameter keyword
	elseif invert and not utilities.in_array (value, possible) then				-- invert; &lt;value&gt; is not in &lt;possible&gt; table
		return value;															-- return &lt;value&gt; as it is
	else
		utilities.set_message ('err_invalid_param_val', {name, value});			-- not an allowed value so add error message
		return ret_val;
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list, -3, -1) == sepc .. '. ') then					-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list, -1, -1) == sepc) or (string.sub (name_list, -3, -1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terminate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;-----------------------------------------

returns the concatenation of the formatted volume and issue (or journal article number) parameters as a single
string; or formatted volume or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, article, cite_class, origin, sepc, lower)
	if not utilities.is_set (volume) and not utilities.is_set (issue) and not utilities.is_set (article) then
		return '';
	end

	-- same condition as in format_pages_sheets()
	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);

	local is_numeric_vol = volume and (volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$'));	-- is only uppercase roman numerals or only digits?
	local is_long_vol = volume and (4 &lt; mw.ustring.len(volume));				-- is |volume= value longer than 4 characters?
	
	if volume and (not is_numeric_vol and is_long_vol) then						-- when not all digits or Roman numerals, is |volume= longer than 4 characters?
		utilities.add_prop_cat ('long-vol');									-- yes, add properties cat
	end

	if is_journal then															-- journal-style formatting
		local vol = '';

		if utilities.is_set (volume) then
			if is_numeric_vol then												-- |volume= value all digits or all uppercase Roman numerals?
				vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, volume});	-- render in bold face
			elseif is_long_vol then												-- not all digits or Roman numerals; longer than 4 characters?
				vol = utilities.substitute (cfg.messages['j-vol'], {sepc, utilities.hyphen_to_dash (volume)});	-- not bold
			else																-- four or fewer characters
				vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, utilities.hyphen_to_dash (volume)});	-- bold
			end
		end
		vol = vol .. (utilities.is_set (issue) and utilities.substitute (cfg.messages['j-issue'], issue) or '')
		vol = vol .. (utilities.is_set (article) and utilities.substitute (cfg.messages['j-article-num'], article) or '')
		return vol;
	end
	
	if 'podcast' == cite_class and utilities.is_set (issue) then
		return wrap_msg ('issue', {sepc, issue}, lower);
	end
	
	if 'conference' == cite_class and utilities.is_set (article) then			-- |article-number= supported only in journal and conference cites
		if utilities.is_set (volume) and utilities.is_set (article) then		-- both volume and article number
			return wrap_msg ('vol-art', {sepc, utilities.hyphen_to_dash (volume), article}, lower);
		elseif utilities.is_set (article) then									-- article number alone; when volume alone, handled below
			return wrap_msg ('art', {sepc, article}, lower);
		end
	end

	-- all other types of citation
	if utilities.is_set (volume) and utilities.is_set (issue) then
		return wrap_msg ('vol-no', {sepc, utilities.hyphen_to_dash (volume), issue}, lower);
	elseif utilities.is_set (volume) then
		return wrap_msg ('vol', {sepc, utilities.hyphen_to_dash (volume)}, lower);
	else
		return wrap_msg ('issue', {sepc, issue}, lower);
	end
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if utilities.is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif utilities.is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if utilities.is_set (page) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return utilities.substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return utilities.substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif utilities.is_set (pages) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then							-- if pages is only digits, assume a single page number
			return '', utilities.substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', utilities.substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', utilities.substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to Wikisource, returns the label portion of the interwiki-link as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki-link to an external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, page_orig, pages, pages_orig, at)
	local ws_url, ws_label, coins_pages, L;										-- for Wikisource interwiki-links; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if utilities.is_set (page) then
		if utilities.is_set (pages) or utilities.is_set (at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page, page_orig);								-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws URL from |page= interwiki link; link portion L becomes tooltip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (pages) then
		if utilities.is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages, pages_orig);							-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws URL from |pages= interwiki link; link portion L becomes tooltip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws URL from |at= interwiki link; link portion L becomes tooltip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end

--[[--------------------------&lt; I S _ U N I Q U E _ A R C H I V E _ U R L &gt;------------------------------------

add error message when |archive-url= value is same as |url= or chapter-url= (or alias...) value

]]

local function is_unique_archive_url (archive, url, c_url, source, date)
	if utilities.is_set (archive) then
		if archive == url or archive == c_url then
			utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)});	-- add error message
			return '', '';														-- unset |archive-url= and |archive-date= because same as |url= or |chapter-url=
		end
	end

	return archive, date;
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org URLs to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot URL or to calendar pages.  When the archive URL is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the URL.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org URL does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command URL
	|archive-url= is an archive.org URL that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org URLs:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this function may return a modified
archive URL:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the URL unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

A secondary function is to return an archive-url timestamp from those urls that have them (archive.org and
archive.today).  The timestamp is used by validation.archive_date_check() to see if the value in |archive-date=
matches the timestamp in the archive url.

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.org URL
	
	timestamp = url:match ('//archive.today/(%d%d%d%d%d%d%d%d%d%d%d%d%d%d)/') or	-- get timestamp from archive.today urls
		url:match ('//archive.today/(%d%d%d%d%.%d%d%.%d%d%-%d%d%d%d%d%d)/');		-- this timestamp needs cleanup
	if timestamp then															-- if this was an archive.today url ...
		return url, date, timestamp:gsub ('[%.%-]', '');						-- return ArchiveURL, ArchiveDate, and timestamp (dots and dashes removed) from |archive-url=, and done
	end
																				-- here for archive.org urls
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine URL
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command URL, we don't want to allow saving of the target page 
		err_msg = cfg.err_msg_supl.save;
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = cfg.err_msg_supl.liveweb;
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');	-- split out some of the URL parts for evaluation
		if not path then														-- malformed in some way; pattern did not match
			err_msg = cfg.err_msg_supl.timestamp;
		elseif 14 ~= timestamp:len() then										-- path and flag optional, must have 14-digit timestamp here
			err_msg = cfg.err_msg_supl.timestamp;
			if '*' ~= flag then
				local replacement = timestamp:match ('^%d%d%d%d%d%d') or timestamp:match ('^%d%d%d%d');	-- get the first 6 (YYYYMM) or first 4 digits (YYYY)
				if replacement then												-- nil if there aren't at least 4 digits (year)
					replacement = replacement .. string.rep ('0', 14 - replacement:len());	-- year or yearmo (4 or 6 digits) zero-fill to make 14-digit timestamp
					url=url:gsub ('(//web%.archive%.org/[^%d]*)%d[^/]*', '%1' .. replacement .. '*', 1)	-- for preview, modify ts to 14 digits plus splat for calendar display
				end
			end
		elseif utilities.is_set (path) and 'web/' ~= path then					-- older archive URLs do not have the extra 'web/' path element
			err_msg = cfg.err_msg_supl.path;
		elseif utilities.is_set (flag) and not utilities.is_set (path) then		-- flag not allowed with the old form URL (without the 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		elseif utilities.is_set (flag) and not flag:match ('%a%a_') then		-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		else
			return url, date, timestamp;										-- return ArchiveURL, ArchiveDate, and timestamp from |archive-url=
		end
	end
																				-- if here, something not right so
	utilities.set_message ('err_archive_url', {err_msg});						-- add error message and

	if is_preview_mode then
		return url, date, timestamp;											-- preview mode so return ArchiveURL, ArchiveDate, and timestamp from |archive-url=
	else
		return '', '';															-- return empty strings for ArchiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; P L A C E _ C H E C K &gt;--------------------------------------------------------

check |place=, |publication-place=, |location= to see if these params include digits.  This function added because
many editors misuse location to specify the in-source location (|page(s)= and |at= are supposed to do that)

returns the original parameter value without modification; added maint cat when parameter value contains digits

]]

local function place_check (param_val)
	if not utilities.is_set (param_val) then									-- parameter empty or omitted
		return param_val;														-- return that empty state
	end
	
	if mw.ustring.find (param_val, '%d') then									-- not empty, are there digits in the parameter value
		utilities.set_message ('maint_location');								-- yep, add maint cat
	end
	
	return param_val;															-- and done
end


--[[--------------------------&lt; I S _ A R C H I V E D _ C O P Y &gt;----------------------------------------------

compares |title= to 'Archived copy' (placeholder added by bots that can't find proper title); if matches, return true; nil else

]]

local function is_archived_copy (title)
	title = mw.ustring.lower(title);											-- switch title to lower case
	if title:find (cfg.special_case_translation.archived_copy.en) then			-- if title is 'Archived copy'
		return true;
	elseif cfg.special_case_translation.archived_copy['local'] then
		if mw.ustring.find (title, cfg.special_case_translation.archived_copy['local']) then	-- mw.ustring() because might not be Latin script
			return true;
		end
	end
end


--[[--------------------------&lt; D I S P L A Y _ N A M E S _ S E L E C T &gt;--------------------------------------

for any of the |display-authors=, |display-editors=, etc parameters, select either the local or global setting.
When both are present, look at &lt;local_display_names&gt; value.  When the value is some sort of 'et al.'string,
special handling is required.

When {{cs1 config}} has |display-&lt;namelist&gt;= AND this template has |display-&lt;namelist&gt;=etal AND:
	the number of names specified by &lt;number_of_names&gt; is:
		greater than the number specified in the global |display-&lt;namelist&gt;= parameter (&lt;global_display_names&gt;)
			use global |display-&lt;namelist&gt;= parameter value
			set overridden maint category
		less than or equal to the number specified in the global |display-&lt;namelist&gt;=  parameter
			use local |display-&lt;namelist&gt;= parameter value

The purpose of this function is to prevent categorizing a template that has fewer names than the global setting
to keep the etal annotation specified by &lt;local_display_names&gt;.

]]

local function display_names_select (global_display_names, local_display_names, param_name, number_of_names, test)
	if global_display_names and utilities.is_set (local_display_names) then		-- when both
		if 'etal' == local_display_names:lower():gsub(&quot;[ '%.]&quot;, '') then		-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			number_of_names = tonumber (number_of_names);						-- convert these to numbers for comparison
			local global_display_names_num = tonumber (global_display_names);	-- &lt;global_display_names&gt; not set when parameter value is not digits

			if number_of_names &gt; global_display_names_num then					-- template has more names than global config allows to be displayed?
				utilities.set_message ('maint_overridden_setting');				-- set a maint message because global is overriding local |display-&lt;namelist&gt;=etal
				return global_display_names, 'cs1 config';						-- return global with spoof parameter name (for get_display_names())
			else
				return local_display_names, param_name;							-- return local because fewer names so let &lt;local_display_names&gt; control
			end
		end
																				-- here when &lt;global_display_names&gt; and &lt;local_display_names&gt; both numbers; &lt;global_display_names&gt; controls
		utilities.set_message ('maint_overridden_setting');						-- set a maint message
		return global_display_names, 'cs1 config';								-- return global with spoof parameter name (for get_display_names())
	end
																				-- here when only one of &lt;global_display_names&gt; or &lt;local_display_names&gt; set
	if global_display_names then
		return global_display_names, 'cs1 config';								-- return global with spoof parameter name (for get_display_names())
	else
		return local_display_names, param_name;									-- return local
	end
end


--[[--------------------------&lt; M O D E _ S E T &gt;--------------------------------------------------------------

fetch global mode setting from {{cs1 config}} (if present) or from |mode= (if present); global setting overrides
local |mode= parameter value.  When both are present, emit maintenance message

]]

local function mode_set (Mode, Mode_origin)
	local mode;
	if cfg.global_cs1_config_t['Mode'] then										-- global setting in {{cs1 config}}; nil when empty or assigned value invalid
		mode = is_valid_parameter_value (cfg.global_cs1_config_t['Mode'], 'cs1 config: mode', cfg.keywords_lists['mode'], '');	-- error messaging 'param' here is a hoax
	else
		mode = is_valid_parameter_value (Mode, Mode_origin, cfg.keywords_lists['mode'], '');
	end

	if cfg.global_cs1_config_t['Mode'] and utilities.is_set (Mode) then			-- when template has |mode=&lt;something&gt; which global setting has overridden
		utilities.set_message ('maint_overridden_setting');						-- set a maint message
	end
	return mode;
end


--[[--------------------------&lt; Q U O T E _ M A K E &gt;----------------------------------------------------------

create quotation from |quote=, |trans-quote=, and/or script-quote= with or without |quote-page= or |quote-pages=

when any of those three quote parameters are set, this function unsets &lt;PostScript&gt;.  When none of those parameters
are set, |quote-page= and |quote-pages= are unset to nil so that they are not included in the template's metadata

]]

local function quote_make (quote, trans_quote, script_quote, quote_page, quote_pages, nopp, sepc, postscript)
	if utilities.is_set (quote) or utilities.is_set (trans_quote) or utilities.is_set (script_quote) then

		if utilities.is_set (quote) then
			if quote:sub(1, 1) == '&quot;' and quote:sub(-1, -1) == '&quot;' then			-- if first and last characters of quote are quote marks
				quote = quote:sub(2, -2);										-- strip them off
			end
		end
		
		quote = kern_quotes (quote);											-- kern if needed
		quote = utilities.wrap_style ('quoted-text', quote );					-- wrap in &lt;q&gt;...&lt;/q&gt; tags
	
		if utilities.is_set (script_quote) then
			quote = script_concatenate (quote, script_quote, 'script-quote');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after quote is wrapped
		end

		if utilities.is_set (trans_quote) then
			if trans_quote:sub(1, 1) == '&quot;' and trans_quote:sub(-1, -1) == '&quot;' then -- if first and last characters of |trans-quote are quote marks
				trans_quote = trans_quote:sub(2, -2); -- strip them off
			end
			quote = quote .. &quot; &quot; .. utilities.wrap_style ('trans-quoted-title', trans_quote );
		end

		if utilities.is_set (quote_page) or utilities.is_set (quote_pages) then	-- add page prefix
			local quote_prefix = '';
			if utilities.is_set (quote_page) then
				extra_text_in_page_check (quote_page, 'quote-page');			-- add to maint cat if |quote-page= value begins with what looks like p., pp., etc.
				if not nopp then
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, quote_page}), '', '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, quote_page}), '', '', '';
				end
			elseif utilities.is_set (quote_pages) then
				extra_text_in_page_check (quote_pages, 'quote-pages');			-- add to maint cat if |quote-pages= value begins with what looks like p., pp., etc.
				if tonumber(quote_pages) ~= nil and not nopp then				-- if only digits, assume single page
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, quote_pages}), '', '';
				elseif not nopp then
					quote_prefix = utilities.substitute (cfg.messages['pp-prefix'], {sepc, quote_pages}), '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, quote_pages}), '', '';
				end
			end
                        
			quote = quote_prefix .. &quot;: &quot; .. quote;
		else
			quote = sepc .. &quot; &quot; .. quote;
		end

		postscript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	
	elseif utilities.is_set (quote_page) or utilities.is_set (quote_pages) then
		quote_page = nil;														-- unset; these require |quote=; TODO: error message?
		quote_pages = nil;
	end

	return quote, quote_page, quote_pages, postscript;
end


--[[--------------------------&lt; C H E C K _ P U B L I S H E R _ N A M E &gt;--------------------------------------

look for variations of '&lt;text&gt;: &lt;text&gt;' that might be '&lt;location&gt;: &lt;publisher&gt;' in |publisher= parameter value.
when found, emit a maintenance message; return nil else

&lt;publisher&gt; is the value assigned to |publisher= or |institution=

]]

local function check_publisher_name (publisher)
	local patterns_t = {
		'^[%w%s]+%s*:%s*[%w%s]+$',												-- plain text &lt;location&gt;: &lt;publisher&gt;
		'^%[+[%w%s:|]+%]+%s*:%s*[%w%s]+$',										-- partially wikilinked [[&lt;location&gt;]]: &lt;publisher&gt;
		'^[%w%s]+%s*:%s*%[+[%w%s:|]+%]+$',										-- partially wikilinked &lt;location&gt;: [[&lt;publisher&gt;]]
		'^%[+[%w%s:|]+%]+%s*:%s*%[+[%w%s:|]+%]+$',								-- wikilinked [[&lt;location&gt;]]: [[&lt;publisher&gt;]]
		}
	
	for _, pattern in ipairs (patterns_t) do									-- spin through the patterns_t sequence
		if mw.ustring.match (publisher, pattern) then							-- does this pattern match?
			utilities.set_message ('maint_publisher_location');					-- set a maint message
			return;																-- and done
		end
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args )
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper ( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListStyle;
		if cfg.global_cs1_config_t['NameListStyle'] then						-- global setting in {{cs1 config}} overrides local |name-list-style= parameter value; nil when empty or assigned value invalid
			NameListStyle = is_valid_parameter_value (cfg.global_cs1_config_t['NameListStyle'], 'cs1 config: name-list-style', cfg.keywords_lists['name-list-style'], '');	-- error messaging 'param' here is a hoax
		else
			NameListStyle = is_valid_parameter_value (A['NameListStyle'], A:ORIGIN('NameListStyle'), cfg.keywords_lists['name-list-style'], '');
		end

		if cfg.global_cs1_config_t['NameListStyle'] and utilities.is_set (A['NameListStyle']) then	-- when template has |name-list-style=&lt;something&gt; which global setting has overridden
			utilities.set_message ('maint_overridden_setting');					-- set a maint message
		end

	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			a, author_etal = parse_vauthors_veditors (args, A['Vauthors'], 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |people= or |credits=; |authors= is deprecated; TODO: constrain |people= and |credits= to cite av media, episode, serial?
		end
		if utilities.is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], nil, args, 'EditorList');	-- support for |editors= withdrawn
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		end
	end
							
	local Chapter = A['Chapter'];												-- done here so that we have access to |contribution= from |chapter= aliases
	local Chapter_origin = A:ORIGIN ('Chapter');
	local Contribution;															-- because contribution is required for contributor(s)
		if 'contribution' == Chapter_origin then
			Contribution = Chapter;												-- get the name of the contribution
		end
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	
	if utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not utilities.is_set (Contribution) then							-- |contributor= requires |contribution=
				utilities.set_message ('err_contributor_missing_required_param', 'contribution');	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				utilities.set_message ('err_contributor_missing_required_param', 'author');	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if utilities.select_one (args, cfg.aliases['ContributorList-Last'], 'err_redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			utilities.set_message ('err_contributor_ignored');					-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	local Title = A['Title'];
	local TitleLink = A['TitleLink'];

	local auto_select = '';														-- default is auto
	local accept_link;
	TitleLink, accept_link = utilities.has_accept_as_written (TitleLink, true);	-- test for accept-this-as-written markup
	if (not accept_link) and utilities.in_array (TitleLink, {'none', 'pmc', 'doi'}) then -- check for special keywords
		auto_select = TitleLink;												-- remember selection for later
		TitleLink = '';															-- treat as if |title-link= would have been empty
	end

	TitleLink = link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wiki-markup in |title-link= or wiki-markup in |title= when |title-link= is set

	local Section = '';															-- {{cite map}} only; preset to empty string for concatenation if not used
	if 'map' == config.CitationClass and 'section' == Chapter_origin then
		Section = A['Chapter'];													-- get |section= from |chapter= alias list; |chapter= and the other aliases not supported in {{cite map}}
		Chapter = '';															-- unset for now; will be reset later from |map= if present
	end

	local Periodical = A['Periodical'];
	local Periodical_origin = A:ORIGIN('Periodical');
	local ScriptPeriodical = A['ScriptPeriodical'];
	local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');
	local TransPeriodical =  A['TransPeriodical'];
	local TransPeriodical_origin =  A:ORIGIN ('TransPeriodical');
	
	if (utilities.in_array (config.CitationClass, {'book', 'encyclopaedia'}) and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical))) then
		local param;
		if utilities.is_set (Periodical) then									-- get a parameter name from one of these periodical related meta-parameters
			Periodical = '';													-- unset because not valid {{cite book}} or {{cite encyclopedia}} parameters 
			param = Periodical_origin											-- get parameter name for error messaging
		elseif utilities.is_set (TransPeriodical) then
			TransPeriodical = '';												-- unset because not valid {{cite book}} or {{cite encyclopedia}} parameters 
			param = TransPeriodical_origin;										-- get parameter name for error messaging
		elseif utilities.is_set (ScriptPeriodical) then
			ScriptPeriodical = '';												-- unset because not valid {{cite book}} or {{cite encyclopedia}} parameters 
			param = ScriptPeriodical_origin;									-- get parameter name for error messaging
		end

		if utilities.is_set (param) then										-- if we found one
			utilities.set_message ('err_periodical_ignored', {param});			-- emit an error message
		end
	end

	if utilities.is_set (Periodical) then
		local i;
		Periodical, i = utilities.strip_apostrophe_markup (Periodical);			-- strip apostrophe markup so that metadata isn't contaminated 
		if i then																-- non-zero when markup was stripped so emit an error message
			utilities.set_message ('err_apostrophe_markup', {Periodical_origin});
		end
	end

	if 'mailinglist' == config.CitationClass then								-- special case for {{cite mailing list}}
		if utilities.is_set (Periodical) and utilities.is_set (A ['MailingList']) then	-- both set emit an error TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', Periodical_origin) .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'mailinglist')});
		end

		Periodical = A ['MailingList'];											-- error or no, set Periodical to |mailinglist= value because this template is {{cite mailing list}}
		Periodical_origin = A:ORIGIN('MailingList');
	end

	-- web and news not tested for now because of 
	-- Wikipedia:Administrators%27_noticeboard#Is_there_a_semi-automated_tool_that_could_fix_these_annoying_&quot;Cite_Web&quot;_errors?
	if not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) then	-- 'periodical' templates require periodical parameter
	--	local p = {['journal'] = 'journal', ['magazine'] = 'magazine', ['news'] = 'newspaper', ['web'] = 'website'};	-- for error message
		local p = {['journal'] = 'journal', ['magazine'] = 'magazine'};			-- for error message
		if p[config.CitationClass]  then
			utilities.set_message ('err_missing_periodical', {config.CitationClass, p[config.CitationClass]});
		end
	end
	
	local Volume;
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) then
			if not utilities.in_array (Periodical_origin, cfg.citation_no_volume_t) then	-- {{citation}} does not render |volume= when these parameters are used
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		elseif utilities.is_set (ScriptPeriodical) then
			if 'script-website' ~= ScriptPeriodical_origin then					-- {{citation}} does not render volume for |script-website=
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		else
			Volume = A['Volume'];												-- and does for non-'periodical' cites
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_volume) then	-- render |volume= for cs1 according to the configuration settings
		Volume = A['Volume'];
	end	
	extra_text_in_vol_iss_check (Volume, A:ORIGIN ('Volume'), 'v');	

	local Issue;
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) and utilities.in_array (Periodical_origin, cfg.citation_issue_t) then	-- {{citation}} may render |issue= when these parameters are used
			Issue = utilities.hyphen_to_dash (A['Issue']);
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_issue) then	-- conference &amp; map books do not support issue; {{citation}} listed here because included in settings table
		if not (utilities.in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical))) then
			Issue = utilities.hyphen_to_dash (A['Issue']);
		end
	end
	
	local ArticleNumber;

	if utilities.in_array (config.CitationClass, {'journal', 'conference'}) or ('citation' == config.CitationClass and utilities.is_set (Periodical) and 'journal' == Periodical_origin) then
		ArticleNumber = A['ArticleNumber'];
	end

	extra_text_in_vol_iss_check (Issue, A:ORIGIN ('Issue'), 'i');	

	local Page;
	local Pages;
	local At;
	local QuotePage;
	local QuotePages;
	if not utilities.in_array (config.CitationClass, cfg.templates_not_using_page) then		-- TODO: rewrite to emit ignored parameter error message?
		Page = A['Page'];
		Pages = utilities.hyphen_to_dash (A['Pages']);	
		At = A['At'];
		QuotePage = A['QuotePage'];
		QuotePages = utilities.hyphen_to_dash (A['QuotePages']);
	end

	local NoPP = is_valid_parameter_value (A['NoPP'], A:ORIGIN('NoPP'), cfg.keywords_lists['yes_true_y'], nil);

	local Mode = mode_set (A['Mode'], A:ORIGIN('Mode'));

	-- separator character and postscript
	local sepc, PostScript = set_style (Mode:lower(), A['PostScript'], config.CitationClass);
	local Quote;
	Quote, QuotePage, QuotePages, PostScript = quote_make (A['Quote'], A['TransQuote'], A['ScriptQuote'], QuotePage, QuotePages, NoPP, sepc, PostScript);

	local Edition = A['Edition'];
	local PublicationPlace = place_check (A['PublicationPlace'], A:ORIGIN('PublicationPlace'));
	local Place = place_check (A['Place'], A:ORIGIN('Place'));
	
	local PublisherName = A['PublisherName'];
	local PublisherName_origin = A:ORIGIN('PublisherName');
	if utilities.is_set (PublisherName) and (cfg.keywords_xlate['none'] ~= PublisherName) then
		local i = 0;
		PublisherName, i = utilities.strip_apostrophe_markup (PublisherName);	-- strip apostrophe markup so that metadata isn't contaminated; publisher is never italicized
		if i and (0 &lt; i) then													-- non-zero when markup was stripped so emit an error message
			utilities.set_message ('err_apostrophe_markup', {PublisherName_origin});
		end
	end
	
	if ('document' == config.CitationClass) and not utilities.is_set (PublisherName) then
		utilities.set_message ('err_missing_publisher', {config.CitationClass, 'publisher'});
	end

	local Newsgroup = A['Newsgroup'];											-- TODO: strip apostrophe markup?
	local Newsgroup_origin = A:ORIGIN('Newsgroup');	

	if 'newsgroup' == config.CitationClass then
		if utilities.is_set (PublisherName) and (cfg.keywords_xlate['none'] ~= PublisherName) then	-- general use parameter |publisher= not allowed in cite newsgroup
			utilities.set_message ('err_parameter_ignored', {PublisherName_origin});
		end

		PublisherName = nil;													-- ensure that this parameter is unset for the time being; will be used again after COinS
	end

	if 'book' == config.CitationClass or 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and not utilities.is_set (Periodical)) then
		local accept;
		PublisherName, accept = utilities.has_accept_as_written (PublisherName);	-- check for and remove accept-as-written markup from |publisher= wrapped
		if not accept then														-- when no accept-as-written markup
			check_publisher_name (PublisherName);								-- emit maint message when |publisher= might be prefixed with publisher's location
		end
	end

	local URL = A['URL'];														-- TODO: better way to do this for URL, ChapterURL, and MapURL?
	local UrlAccess = is_valid_parameter_value (A['UrlAccess'], A:ORIGIN('UrlAccess'), cfg.keywords_lists['url-access'], nil);
	
	if not utilities.is_set (URL) and utilities.is_set (UrlAccess) then
		UrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', 'url');
	end
	
	local ChapterURL = A['ChapterURL'];
	local ChapterUrlAccess = is_valid_parameter_value (A['ChapterUrlAccess'], A:ORIGIN('ChapterUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (ChapterURL) and utilities.is_set (ChapterUrlAccess) then
		ChapterUrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', {A:ORIGIN('ChapterUrlAccess'):gsub ('%-access', '')});
	end

	local MapUrlAccess = is_valid_parameter_value (A['MapUrlAccess'], A:ORIGIN('MapUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (A['MapURL']) and utilities.is_set (MapUrlAccess) then
		MapUrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', {'map-url'});
	end

	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local no_tracking_cats = is_valid_parameter_value (A['NoTracking'], A:ORIGIN('NoTracking'), cfg.keywords_lists['yes_true_y'], nil);

	-- check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not utilities.is_set (no_tracking_cats) then								-- ignore if we are already not going to categorize this page
		if cfg.uncategorized_namespaces[this_page.namespace] then				-- is this page's namespace id one of the uncategorized namespace ids?
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _, v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end
																				-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	utilities.select_one (args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'err_redundant_parameters');	-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, A:ORIGIN('Page'), Pages, A:ORIGIN('Pages'), At);

	if utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- both |publication-place= and |place= (|location=) allowed if different
		utilities.add_prop_cat ('location-test');								-- add property cat to evaluate how often PublicationPlace and Place are used together
		if PublicationPlace == Place then
			Place = '';															-- unset; don't need both if they are the same
		end
	elseif not utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- when only |place= (|location=) is set ...
		PublicationPlace = Place;												-- promote |place= (|location=) to |publication-place
	end

	if PublicationPlace == Place then Place = ''; end							-- don't need both if they are the same

	local URL_origin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL_origin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ScriptChapter = A['ScriptChapter'];
	local ScriptChapter_origin = A:ORIGIN ('ScriptChapter');
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local TransChapter = A['TransChapter'];
	local TransChapter_origin = A:ORIGIN ('TransChapter');
	local TransTitle = A['TransTitle'];
	local ScriptTitle = A['ScriptTitle'];
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia= and |title= then map |title= to |article= and |encyclopedia= to |title= for rendering
		|encyclopedia= and |article= then map |encyclopedia= to |title= for rendering

		|trans-title= maps to |trans-chapter= when |title= is re-mapped
		|url= maps to |chapter-url= when |title= is remapped
	
	All other combinations of |encyclopedia=, |title=, and |article= are not modified
	
	]]

	local Encyclopedia = A['Encyclopedia'];										-- used as a flag by this module and by ~/COinS
	local ScriptEncyclopedia = A['ScriptEncyclopedia'];
	local TransEncyclopedia = A['TransEncyclopedia'];

	if utilities.is_set (Encyclopedia) or utilities.is_set (ScriptEncyclopedia) then	-- emit error message when Encyclopedia set but template is other than {{cite encyclopedia}} or {{citation}}
		if 'encyclopaedia' ~= config.CitationClass and 'citation' ~= config.CitationClass then
			if utilities.is_set (Encyclopedia) then
				utilities.set_message ('err_parameter_ignored', {A:ORIGIN ('Encyclopedia')});
			else
				utilities.set_message ('err_parameter_ignored', {A:ORIGIN ('ScriptEncyclopedia')});
			end
			Encyclopedia = nil;													-- unset these because not supported by this template
			ScriptEncyclopedia = nil;
			TransEncyclopedia = nil;
		end
	elseif utilities.is_set (TransEncyclopedia) then
		utilities.set_message ('err_trans_missing_title', {'encyclopedia'});
	end

	if ('encyclopaedia' == config.CitationClass) or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Periodical) and utilities.is_set (Encyclopedia) then	-- when both parameters set emit an error message; {{citation}} only; Periodical not allowed in {{cite encyclopedia}}
			utilities.set_message ('err_periodical_ignored', {Periodical_origin});
		end

		if utilities.is_set (Encyclopedia) or utilities.is_set (ScriptEncyclopedia) then
			Periodical = Encyclopedia;											-- error or no, set Periodical to Encyclopedia for rendering; {{citation}} could (not legitimately) have both; use Encyclopedia
			Periodical_origin = A:ORIGIN ('Encyclopedia');
			ScriptPeriodical = ScriptEncyclopedia;
			ScriptPeriodical_origin = A:ORIGIN ('ScriptEncyclopedia');

			if utilities.is_set (Title) or utilities.is_set (ScriptTitle) then
				if not utilities.is_set (Chapter) then
					Chapter = Title;											-- |encyclopedia= and |title= are set so map |title= params to |article= params for rendering
					ScriptChapter = ScriptTitle;
					ScriptChapter_origin = A:ORIGIN('ScriptTitle')
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterURL_origin = URL_origin;
					ChapterUrlAccess = UrlAccess;
					ChapterFormat = Format;

					if not utilities.is_set (ChapterURL) and utilities.is_set (TitleLink) then
						Chapter = utilities.make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;											-- now map |encyclopedia= params to |title= params for rendering
					ScriptTitle = ScriptPeriodical or '';
					TransTitle = TransEncyclopedia or '';
					Periodical = '';											-- redundant so unset
					ScriptPeriodical = '';
					URL = '';
					Format = '';
					TitleLink = '';
				end
			elseif utilities.is_set (Chapter) or utilities.is_set (ScriptChapter) then	-- |title= not set
				Title = Periodical;												-- |encyclopedia= set and |article= set so map |encyclopedia= to |title= for rendering
				ScriptTitle = ScriptPeriodical or '';
				TransTitle = TransEncyclopedia or '';
				Periodical = '';												-- redundant so unset
				ScriptPeriodical = '';
			end
		end
	end

	-- special case for cite techreport.
	local ID = A['ID'];
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if utilities.is_set (A['Number']) then									-- cite techreport uses 'number', which other citations alias to 'issue'
			if not utilities.is_set (ID) then									-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'id') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'number')});
			end
		end	
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	local ChapterLink -- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local Conference = A['Conference'];
	local BookTitle = A['BookTitle'];
	local TransTitle_origin = A:ORIGIN ('TransTitle');
	if 'conference' == config.CitationClass then
		if utilities.is_set (BookTitle) then
			Chapter = Title;
			Chapter_origin = 'title';
	--		ChapterLink = TitleLink;											-- |chapter-link= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			URL_origin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			TransChapter_origin = TransTitle_origin;
			Title = BookTitle;
			Format = '';
	--		TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end
	
	local use_lowercase = ( sepc == ',' );										-- controls capitalization of certain static text
	
	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		if utilities.is_set (Chapter) then										--TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'map') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', Chapter_origin)});	-- add error message
		end
		Chapter = A['Map'];
		Chapter_origin = A:ORIGIN('Map');
		ChapterURL = A['MapURL'];
		ChapterURL_origin = A:ORIGIN('MapURL');
		TransChapter = A['TransMap'];
		ScriptChapter = A['ScriptMap']
		ScriptChapter_origin = A:ORIGIN('ScriptMap')

		ChapterUrlAccess = MapUrlAccess;
		ChapterFormat = A['MapFormat'];

		Cartography = A['Cartography'];
		if utilities.is_set ( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if utilities.is_set ( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	local Series = A['Series'];
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local SeriesLink = A['SeriesLink'];

		SeriesLink = link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wiki-markup in |series-link= or wiki-markup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if utilities.is_set (Network) then table.insert(n, Network); end
		if utilities.is_set (Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if utilities.is_set (Season) and utilities.is_set (SeriesNumber) then	-- these are mutually exclusive so if both are set TODO: make a function for this and similar?
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'season') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'seriesno')});		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if utilities.is_set (Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if utilities.is_set (SeriesNumber) then table.insert(s, wrap_msg ('seriesnum', SeriesNumber, use_lowercase)); end
			if utilities.is_set (Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ScriptChapter_origin = A:ORIGIN('ScriptTitle');
			ChapterLink = TitleLink;											-- alias |episode-link=
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			ChapterFormat = Format;

			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if utilities.is_set (ChapterLink) and not utilities.is_set (ChapterURL) then	-- link but not URL
				Chapter = utilities.make_wikilink (ChapterLink, Chapter);
			elseif utilities.is_set (ChapterLink) and utilities.is_set (ChapterURL) then	-- if both are set, URL links episode;
				Series = utilities.make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			Format = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if utilities.is_set (Series) and utilities.is_set (SeriesLink) then
				Series = utilities.make_wikilink (SeriesLink, Series);
			end
			Series = utilities.wrap_style ('italic-title', Series);				-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- handle type parameter for those CS1 citations that have default values
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	if utilities.in_array (config.CitationClass, {'AV-media-notes', 'document', 'interview', 'mailinglist', 'map', 'podcast', 'pressrelease', 'report', 'speech', 'techreport', 'thesis'}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if utilities.is_set (Degree) and &quot;Thesis&quot; == TitleType then				-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if utilities.is_set (TitleType) then										-- if type parameter is specified
		TitleType = utilities.substitute ( cfg.messages['type'], TitleType);	-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
	local Date = A['Date'];
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging
	local PublicationDate = A['PublicationDate'];
	local Year = A['Year'];

	if utilities.is_set (Year) then
		validation.year_check (Year);											-- returns nothing; emits maint message when |year= doesn't hold a 'year' value
	end
		
	if not utilities.is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not utilities.is_set (Date) and utilities.is_set (PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]

	local DF = is_valid_parameter_value (A['DF'], A:ORIGIN('DF'), cfg.keywords_lists['df'], '');
	if not utilities.is_set (DF) then
		DF = cfg.global_df;														-- local |df= if present overrides global df set by {{use xxx date}} template
	end

	local ArchiveURL;
	local ArchiveDate;
	local ArchiveFormat = A['ArchiveFormat'];
	local archive_url_timestamp;												-- timestamp from wayback machine url
	
	ArchiveURL, ArchiveDate, archive_url_timestamp = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	
	ArchiveURL, ArchiveDate = is_unique_archive_url (ArchiveURL, URL, ChapterURL, A:ORIGIN('ArchiveURL'), ArchiveDate);		-- add error message when URL or ChapterURL == ArchiveURL

	local AccessDate = A['AccessDate'];
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification
	local DoiBroken = A['DoiBroken'];
	local Embargo = A['Embargo'];
	local anchor_year;															-- used in the CITEREF identifier
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val = AccessDate, name = A:ORIGIN ('AccessDate')},
			['archive-date'] = {val = ArchiveDate, name = A:ORIGIN ('ArchiveDate')},
			['date'] = {val = Date, name = Date_origin},
			['doi-broken-date'] = {val = DoiBroken, name = A:ORIGIN ('DoiBroken')},
			['pmc-embargo-date'] = {val = Embargo, name = A:ORIGIN ('Embargo')},
			['publication-date'] = {val = PublicationDate, name = A:ORIGIN ('PublicationDate')},
			['year'] = {val = Year, name = A:ORIGIN ('Year')},
			};

		local error_list = {};
		anchor_year, Embargo = validation.dates(date_parameters_list, COinS_date, error_list);

		if utilities.is_set (Year) and utilities.is_set (Date) then				-- both |date= and |year= not normally needed; 
			validation.year_date_check (Year, A:ORIGIN ('Year'), Date, A:ORIGIN ('Date'), error_list);
		end

		if 0 == #error_list then												-- error free dates only; 0 when error_list is empty
			local modified = false;												-- flag
			
			if utilities.is_set (DF) then										-- if we need to reformat dates
				modified = validation.reformat_dates (date_parameters_list, DF);	-- reformat to DF format, use long month names if appropriate
			end

			if true == validation.date_hyphen_to_dash (date_parameters_list) then	-- convert hyphens to dashes where appropriate
				modified = true;
				utilities.set_message ('maint_date_format');					-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language; not supported at en.wiki
			if cfg.date_name_auto_xlate_enable and validation.date_name_xlate (date_parameters_list, cfg.date_digit_auto_xlate_enable ) then
				utilities.set_message ('maint_date_auto_xlated');				-- add maint cat
				modified = true;
			end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end

			if archive_url_timestamp and utilities.is_set (ArchiveDate) then
				validation.archive_date_check (ArchiveDate, archive_url_timestamp, DF);	-- does YYYYMMDD in archive_url_timestamp match date in ArchiveDate
			end
		else
			utilities.set_message ('err_bad_date', {utilities.make_sep_list (#error_list, error_list)});	-- add this error message
		end
	end	-- end of do

	if utilities.in_array (config.CitationClass, {'book', 'encyclopaedia'}) or	-- {{cite book}}, {{cite encyclopedia}}; TODO: {{cite conference}} and others?
		('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) or			-- {{citation}} as an encylopedia citation
		('citation' == config.CitationClass and not utilities.is_set (Periodical)) then		-- {{citation}} as a book citation
			if utilities.is_set (PublicationPlace) then
				if not utilities.is_set (PublisherName) then
					local date = COinS_date.rftdate and tonumber (COinS_date.rftdate:match ('%d%d%d%d'));	-- get year portion of COinS date (because in Arabic numerals); convert string to number
					if date and (1850 &lt;= date) then								-- location has no publisher; if date is 1850 or later
						utilities.set_message ('maint_location_no_publisher');	-- add maint cat
					end
				else															-- PublisherName has a value
					if cfg.keywords_xlate['none'] == PublisherName then			-- if that value is 'none' (only for book and encyclopedia citations)
						PublisherName = '';										-- unset
					end
				end
			end
	end

	local ID_list = {};															-- sequence table of rendered identifiers
	local ID_list_coins = {};													-- table of identifiers and their values from args; key is same as cfg.id_handlers's key
	local Class = A['Class'];													-- arxiv class identifier
	
	local ID_support = {
		{A['ASINTLD'], 'ASIN', 'err_asintld_missing_asin', A:ORIGIN ('ASINTLD')},				
		{DoiBroken, 'DOI', 'err_doibroken_missing_doi', A:ORIGIN ('DoiBroken')},
		{Embargo, 'PMC', 'err_embargo_missing_pmc', A:ORIGIN ('Embargo')},
		}

	ID_list, ID_list_coins = identifiers.identifier_lists_get (args, {DoiBroken = DoiBroken, ASINTLD = A['ASINTLD'], Embargo = Embargo, Class = Class, Year=anchor_year}, ID_support);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite medrxiv}}, {{cite ssrn}}, before generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list_t) then	-- |arxiv= or |eprint= required for cite arxiv; |biorxiv=, |citeseerx=, |medrxiv=, |ssrn= required for their templates
		if not (args[cfg.id_handlers[config.CitationClass:upper()].parameters[1]] or 		-- can't use ID_list_coins k/v table here because invalid parameters omitted
			args[cfg.id_handlers[config.CitationClass:upper()].parameters[2]]) then			-- which causes unexpected parameter missing error message
				utilities.set_message ('err_' .. config.CitationClass .. '_missing');		-- add error message
		end

		Periodical = ({['arxiv'] = 'arXiv', ['biorxiv'] = 'bioRxiv', ['citeseerx'] = 'CiteSeerX', ['medrxiv'] = 'medRxiv', ['ssrn'] = 'Social Science Research Network'})[config.CitationClass];
	end

	-- Link the title of the work if no |url= was provided, but we have a |pmc= or a |doi= with |doi-access=free

	if config.CitationClass == &quot;journal&quot; and not utilities.is_set (URL) and not utilities.is_set (TitleLink) and not utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) then -- TODO: remove 'none' once existing citations have been switched to 'off', so 'none' can be used as token for &quot;no title&quot; instead
		if 'none' ~= cfg.keywords_xlate[auto_select] then						-- if auto-linking not disabled
 	 		if identifiers.auto_link_urls[auto_select] then						-- manual selection
		 		URL = identifiers.auto_link_urls[auto_select];					-- set URL to be the same as identifier's external link
 				URL_origin = cfg.id_handlers[auto_select:upper()].parameters[1];	-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['pmc'] then						-- auto-select PMC
				URL = identifiers.auto_link_urls['pmc'];						-- set URL to be the same as the PMC external link if not embargoed
				URL_origin = cfg.id_handlers['PMC'].parameters[1];				-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['doi'] then						-- auto-select DOI
				URL = identifiers.auto_link_urls['doi'];
				URL_origin = cfg.id_handlers['DOI'].parameters[1];
			end
 	 	end

		if utilities.is_set (URL) then											-- set when using an identifier-created URL
			if utilities.is_set (AccessDate) then								-- |access-date= requires |url=; identifier-created URL is not |url=
				utilities.set_message ('err_accessdate_missing_url');			-- add an error message
				AccessDate = '';												-- unset
			end

			if utilities.is_set (ArchiveURL) then								-- |archive-url= requires |url=; identifier-created URL is not |url=
				utilities.set_message ('err_archive_missing_url');				-- add an error message
				ArchiveURL = '';												-- unset
			end
		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not utilities.is_set (Title) and not utilities.is_set (TransTitle) and not utilities.is_set (ScriptTitle) then	-- has special case for cite episode
		utilities.set_message ('err_citation_missing_title', {'episode' == config.CitationClass and 'series' or 'title'});
	end

	if utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) and
			utilities.in_array (config.CitationClass, {'journal', 'citation'}) and
			(utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and
			('journal' == Periodical_origin or 'script-journal' == ScriptPeriodical_origin) then	-- special case for journal cites
				Title = '';														-- set title to empty string
				utilities.set_message ('maint_untitled');						-- add maint cat
	end

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Chapter) and utilities.is_set (Title) and utilities.is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end
	
	-- this is the function call to COinS()
	local OCinSoutput = metadata.COinS({
		['Periodical'] = utilities.strip_apostrophe_markup (Periodical),		-- no markup in the metadata
		['Encyclopedia'] = Encyclopedia,										-- just a flag; content ignored by ~/COinS
		['Chapter'] = metadata.make_coins_title (coins_chapter, ScriptChapter),	-- Chapter and ScriptChapter stripped of bold / italic / accept-as-written markup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = metadata.make_coins_title (coins_title, ScriptTitle),		-- Title and ScriptTitle stripped of bold / italic / accept-as-written markup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date.* has correctly formatted date values if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Quarter'] = COinS_date.rftquarter,
		['Chron'] =  COinS_date.rftchron,
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['ArticleNumber'] = ArticleNumber,
		['Pages'] = coins_pages or metadata.get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At, QuotePage, QuotePages}, 7)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName or Newsgroup,							-- any apostrophe markup already removed from PublisherName
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list_coins,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite medrxiv}}, and {{cite ssrn}} AFTER generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list_t) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, CiteSeerX, medRxiv, or ssrn now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass and utilities.is_set (Newsgroup) then
		PublisherName = utilities.substitute (cfg.messages['newsgroup'], external_link( 'news:' .. Newsgroup, Newsgroup, Newsgroup_origin, nil ));
	end

	local Editors;
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	local Contributors;															-- assembled contributors name list
	local contributor_etal;
	local Translators;															-- assembled translators name list
	local translator_etal;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	local Interviewers;															
	local interviewers_list = {};					
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters
	local interviewer_etal;
	
	-- Now perform various field 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.
	do
		local last_first_list;
		local control = { 
			format = NameListStyle,												-- empty string, '&amp;', 'amp', 'and', or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			local display_names, param = display_names_select (cfg.global_cs1_config_t['DisplayEditors'], A['DisplayEditors'], A:ORIGIN ('DisplayEditors'), #e);
			control.maximum, editor_etal = get_display_names (display_names, #e, 'editors', editor_etal, param);

			Editors, EditorCount = list_people (control, e, editor_etal);

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			local display_names, param = display_names_select (cfg.global_cs1_config_t['DisplayInterviewers'], A['DisplayInterviewers'], A:ORIGIN ('DisplayInterviewers'), #interviewers_list);
			control.maximum, interviewer_etal = get_display_names (display_names, #interviewers_list, 'interviewers', interviewer_etal, param);

			Interviewers = list_people (control, interviewers_list, interviewer_etal);
		end
		do																		-- now do translators
			local display_names, param = display_names_select (cfg.global_cs1_config_t['DisplayTranslators'], A['DisplayTranslators'], A:ORIGIN ('DisplayTranslators'), #t);
			control.maximum, translator_etal = get_display_names (display_names, #t, 'translators', translator_etal, param);

			Translators = list_people (control, t, translator_etal);
		end
		do																		-- now do contributors
			local display_names, param = display_names_select (cfg.global_cs1_config_t['DisplayContributors'], A['DisplayContributors'], A:ORIGIN ('DisplayContributors'), #c);
			control.maximum, contributor_etal = get_display_names (display_names, #c, 'contributors', contributor_etal, param);

			Contributors = list_people (control, c, contributor_etal);
		end
		do																		-- now do authors
			local display_names, param = display_names_select (cfg.global_cs1_config_t['DisplayAuthors'], A['DisplayAuthors'], A:ORIGIN ('DisplayAuthors'), #a, author_etal);
			control.maximum, author_etal = get_display_names (display_names, #a, 'authors', author_etal, param);

			last_first_list = list_people (control, a, author_etal);

			if utilities.is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors');	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if utilities.is_set (Authors) and utilities.is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'medrxiv', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not utilities.is_set (URL) then
		if utilities.in_array (config.CitationClass, {&quot;web&quot;, &quot;podcast&quot;, &quot;mailinglist&quot;}) or		-- |url= required for cite web, cite podcast, and cite mailinglist
			('citation' == config.CitationClass and ('website' == Periodical_origin or 'script-website' == ScriptPeriodical_origin)) then	-- and required for {{citation}} with |website= or |script-website=
				utilities.set_message ('err_cite_web_url');
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if utilities.is_set (AccessDate) and not utilities.is_set (ChapterURL) then		-- ChapterURL may be set when URL is not set;
			utilities.set_message ('err_accessdate_missing_url');
			AccessDate = '';
		end
	end

	local UrlStatus = is_valid_parameter_value (A['UrlStatus'], A:ORIGIN('UrlStatus'), cfg.keywords_lists['url-status'], '');
	local OriginalURL
	local OriginalURL_origin
	local OriginalFormat
	local OriginalAccess;
	UrlStatus = UrlStatus:lower();												-- used later when assembling archived text
	if utilities.is_set ( ArchiveURL ) then
		if utilities.is_set (ChapterURL) then 									-- if chapter-url= is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURL_origin = ChapterURL_origin;								-- name of |chapter-url= parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=

			if 'live' ~= UrlStatus then
				ChapterURL = ArchiveURL											-- swap-in the archive's URL
				ChapterURL_origin = A:ORIGIN('ArchiveURL')						-- name of |archive-url= parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived URLs
			end
		elseif utilities.is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURL_origin = URL_origin;									-- name of URL parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;

			if 'live' ~= UrlStatus then											-- if URL set then |archive-url= applies to it
				URL = ArchiveURL												-- swap-in the archive's URL
				URL_origin = A:ORIGIN('ArchiveURL')								-- name of archive URL parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived URLs
			end
		end
	elseif utilities.is_set (UrlStatus) then									-- if |url-status= is set when |archive-url= is not set
 		utilities.set_message ('maint_url_status');								-- add maint cat
	end

	if utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'medrxiv', 'ssrn'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) then
			local chap_param;
			if utilities.is_set (Chapter) then									-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif utilities.is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif utilities.is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif utilities.is_set (ScriptChapter) then
				chap_param = ScriptChapter_origin;
			else utilities.is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if utilities.is_set (chap_param) then								-- if we found one
				utilities.set_message ('err_chapter_ignored', {chap_param});	-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if utilities.is_set (Contribution) and 0 &lt; #c then						-- if this is a contribution with contributor(s)
			if utilities.in_array (Contribution:lower(), cfg.keywords_lists.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, ScriptChapter_origin, Chapter, Chapter_origin, TransChapter, TransChapter_origin, ChapterURL, ChapterURL_origin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if utilities.is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and utilities.is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter .. sepc .. ' ';
		elseif utilities.is_set (ChapterFormat) then							-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title
	local plain_title = false;
	local accept_title;
	Title, accept_title = utilities.has_accept_as_written (Title, true);		-- remove accept-this-as-written markup when it wraps all of &lt;Title&gt;
	if accept_title and ('' == Title) then										-- only support forced empty for now &quot;(())&quot;
		Title = cfg.messages['notitle'];										-- replace by predefined &quot;No title&quot; message
			-- TODO: utilities.set_message ( 'err_redundant_parameters', ...);	-- issue proper error message instead of muting	 
			ScriptTitle = '';													-- just mute for now	 
			TransTitle = '';													-- just mute for now
 		plain_title = true;														-- suppress text decoration for descriptive title
		utilities.set_message ('maint_untitled');								-- add maint cat
	end

	if not accept_title then													-- &lt;Title&gt; not wrapped in accept-as-written markup
		if '...' == Title:sub (-3) then											-- if ellipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%' .. sepc .. '$', '');			-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end

		if utilities.is_set (ArchiveURL) and is_archived_copy (Title) then
			utilities.set_message ('maint_archived_copy');						-- add maintenance category before we modify the content of Title
		end

		if is_generic ('generic_titles', Title) then
			utilities.set_message ('err_generic_title');						-- set an error message
		end
	end

	if (not plain_title) and (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'document', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx', 'medrxiv', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) or
		('map' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)))) then		-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from module provided quote marks
			Title = utilities.wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle, 'script-title');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
			TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );
	elseif plain_title or ('report' == config.CitationClass) then				-- no styling for cite report and descriptive titles (otherwise same as above)
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );	-- for cite report, use this form for trans-title
	else
		Title = utilities.wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-italic-title', TransTitle);
	end

	if utilities.is_set (TransTitle) then
		if utilities.is_set (Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			utilities.set_message ('err_trans_missing_title', {'title'});
		end
	end

	if utilities.is_set (Title) then											-- TODO: is this the right place to be making Wikisource URLs?
		if utilities.is_set (TitleLink) and utilities.is_set (URL) then
			utilities.set_message ('err_wikilink_in_url');						-- set an error message because we can't have both
			TitleLink = '';														-- unset
		end
	
		if not utilities.is_set (TitleLink) and utilities.is_set (URL) then
			Title = external_link (URL, Title, URL_origin, UrlAccess) .. TransTitle .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif utilities.is_set (TitleLink) and not utilities.is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle;
			else
				Title = utilities.make_wikilink (TitleLink, Title) .. TransTitle;
			end
		else
			local ws_url, ws_label, L;											-- Title has italic or quote markup by the time we get here which causes is_wikilink() to return 0 (not a wikilink)
			ws_url, ws_label, L = wikisource_url_make (Title:gsub('^[\'&quot;]*(.-)[\'&quot;]*$', '%1'));	-- make ws URL from |title= interwiki link (strip italic or quote markup); link portion L becomes tooltip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle;
			else
				Title = Title .. TransTitle;
			end
		end
	else
		Title = TransTitle;
	end

	if utilities.is_set (Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	local ConferenceURL_origin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	if utilities.is_set (Conference) then
		if utilities.is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURL_origin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif utilities.is_set (ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURL_origin, nil );
	end

	local Position = '';
	if not utilities.is_set (Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if utilities.is_set (Minutes) then
			if utilities.is_set (Time) then		--TODO: make a function for this and similar?
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'minutes') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'time')});
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if utilities.is_set (Time) then
				local TimeCaption = A['TimeCaption']
				if not utilities.is_set (TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = utilities.is_set (At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = utilities.is_set (Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Sections = A['Sections'];											-- Section (singular) is an alias of Chapter so set earlier
		local Inset = A['Inset'];
		
		if utilities.is_set ( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if utilities.is_set ( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif utilities.is_set ( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	local Others = A['Others'];
	if utilities.is_set (Others) and 0 == #a and 0 == #e then					-- add maint cat when |others= has value and used without |author=, |editor=
		if config.CitationClass == &quot;AV-media-notes&quot;
		or config.CitationClass == &quot;audio-visual&quot; then							-- special maint for AV/M which has a lot of 'false' positives right now
			utilities.set_message ('maint_others_avm')
		else
			utilities.set_message ('maint_others');
		end
	end
	Others = utilities.is_set (Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if utilities.is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if utilities.is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	local TitleNote = A['TitleNote'];
	TitleNote = utilities.is_set (TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if utilities.is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%n?%.?$') or Edition:match ('%f[%a][Ee]dition$') then -- Ed, ed, Ed., ed., Edn, edn, Edn., edn.
			utilities.set_message ('err_extra_text_edition');					 -- add error message
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = utilities.is_set (Series) and wrap_msg ('series', {sepc, Series}) or &quot;&quot;;	-- not the same as SeriesNum
	local Agency = A['Agency'] or '';											-- |agency= is supported by {{cite magazine}}, {{cite news}}, {{cite press release}}, {{cite web}}, and certain {{citation}} templates
	if utilities.is_set (Agency) then											-- this testing done here because {{citation}} supports 'news' citations
		if utilities.in_array (config.CitationClass, {'magazine', 'news', 'pressrelease', 'web'}) or ('citation' == config.CitationClass and utilities.in_array (Periodical_origin, {&quot;magazine&quot;, &quot;newspaper&quot;, &quot;work&quot;})) then
			Agency = wrap_msg ('agency', {sepc, Agency});						-- format for rendering
		else
			Agency = '';														-- unset; not supported
			utilities.set_message ('err_parameter_ignored', {'agency'});		-- add error message
		end
	end
	
	Volume = format_volume_issue (Volume, Issue, ArticleNumber, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	if utilities.is_set (AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = utilities.substitute (retrv_text, AccessDate);				-- add retrieved text

		AccessDate = utilities.substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if utilities.is_set (ID) then ID = sepc .. &quot; &quot; .. ID; end
	
	local Docket = A['Docket'];
   	if &quot;thesis&quot; == config.CitationClass and utilities.is_set (Docket) then
		ID = sepc .. &quot; Docket &quot; .. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and utilities.is_set (Docket) then		-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	if utilities.is_set (URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URL_origin, UrlAccess );
	end
	
	-- We check length of PostScript here because it will have been nuked by
	-- the quote parameters. We'd otherwise emit a message even if there wasn't
	-- a displayed postscript.
	-- TODO: Should the max size (1) be configurable?
	-- TODO: Should we check a specific pattern?
	if utilities.is_set(PostScript) and mw.ustring.len(PostScript) &gt; 1 then
		utilities.set_message ('maint_postscript')
	end
	
	local Archived;
	if utilities.is_set (ArchiveURL) then
		if not utilities.is_set (ArchiveDate) then								-- ArchiveURL set but ArchiveDate not set
			utilities.set_message ('err_archive_missing_date');					-- emit an error message
			ArchiveURL = '';													-- empty string for concatenation
			ArchiveDate = '';													-- empty string for concatenation
		end
	else														
		if utilities.is_set (ArchiveDate) then									-- ArchiveURL not set but ArchiveDate is set
			utilities.set_message ('err_archive_date_missing_url');				-- emit an error message
			ArchiveURL = '';													-- empty string for concatenation
			ArchiveDate = '';													-- empty string for concatenation
		end
	end

	if utilities.is_set (ArchiveURL) then
		local arch_text;
		if &quot;live&quot; == UrlStatus then
			arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if utilities.is_set (ArchiveDate) then
				Archived = sepc .. ' ' .. utilities.substitute ( cfg.messages['archived-live'],
					{external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil) .. ArchiveFormat, ArchiveDate } );
			else
				Archived = '';
			end
			if not utilities.is_set (OriginalURL) then
				utilities.set_message ('err_archive_missing_url');
				Archived = '';													-- empty string for concatenation
			end
		elseif utilities.is_set (OriginalURL) then								-- UrlStatus is empty, 'dead', 'unfit', 'usurped', 'bot: unknown'
			if utilities.in_array (UrlStatus, {'unfit', 'usurped', 'bot: unknown'}) then
				arch_text = cfg.messages['archived-unfit'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. ' ' .. arch_text .. ArchiveDate;				-- format already styled
				if 'bot: unknown' == UrlStatus then
					utilities.set_message ('maint_bot_unknown');				-- and add a category if not already added
				else
					utilities.add_prop_cat ('unfit');							-- and add a category if not already added
				end
			else																-- UrlStatus is empty, 'dead'
				arch_text = cfg.messages['archived-dead'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				if utilities.is_set (ArchiveDate) then
					Archived = sepc .. &quot; &quot; .. utilities.substitute ( arch_text,
						{ external_link( OriginalURL, cfg.messages['original'], OriginalURL_origin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
				else
					Archived = '';												-- unset for concatenation
				end
			end	
		else																	-- OriginalUrl not set
			utilities.set_message ('err_archive_missing_url');
			Archived = '';														-- empty string for concatenation
		end
	elseif utilities.is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = '';
	end
	
	local TranscriptURL = A['TranscriptURL']
	local TranscriptFormat = A['TranscriptFormat'];
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');
	local Transcript = A['Transcript'];
	local TranscriptURL_origin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL
	if utilities.is_set (Transcript) then
		if utilities.is_set (TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURL_origin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif utilities.is_set (TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURL_origin, nil );
	end

	local Publisher;
	if utilities.is_set (PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if utilities.is_set (PublisherName) then
		if utilities.is_set (PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif utilities.is_set (PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical)) then
		if utilities.is_set (Title) or utilities.is_set (TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		else 
			Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		end
	end
	
	local Language = A['Language'];
	if utilities.is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc.
	else
		Language='';															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then									-- cite speech only
		TitleNote = TitleType;													-- move TitleType to TitleNote so that it renders ahead of |event=
		TitleType = '';															-- and unset

		if utilities.is_set (Periodical) then									-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if utilities.is_set (Conference) then								-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;							-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (Periodical) then		-- special cases for book cites
		if utilities.is_set (Contributors) then									-- when we are citing foreword, preface, introduction, etc.
			tcommon = safe_join ({Title, TitleNote}, sepc);						-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join ({TitleType, Series, Language, Volume, Others, Edition, Publisher}, sepc);
		else
			tcommon = safe_join ({Title, TitleNote, TitleType, Series, Language, Volume, Others, Edition, Publisher}, sepc);
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if utilities.is_set (Chapter) then										-- map in a book; TitleType is part of Chapter
			tcommon = safe_join ({Title, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc);
		elseif utilities.is_set (Periodical) then								-- map in a periodical
			tcommon = safe_join ({Title, TitleType, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc);
		else																	-- a sheet or stand-alone map
			tcommon = safe_join ({Title, TitleType, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc);
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join ({Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc);

	else																		-- all other CS1 templates
		tcommon = safe_join ({Title, TitleNote, Conference, Periodical, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc);
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local Via = A['Via'];
	Via = utilities.is_set (Via) and  wrap_msg ('via', Via) or '';
	local idcommon;
	if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then	-- special case for cite AV media &amp; cite episode position transcript
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, Quote }, sepc );
	else
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, Quote }, sepc );
	end
	
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	local OrigDate = A['OrigDate'];
	OrigDate = utilities.is_set (OrigDate) and wrap_msg ('origdate', OrigDate) or '';
	if utilities.is_set (Date) then
		if utilities.is_set (Authors) or utilities.is_set (Editors) then		-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date .. &quot;)&quot; .. OrigDate .. sepc .. &quot; &quot;;				-- in parentheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon, -1, -1) == sepc) then						-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigDate;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigDate;							-- Date begins with sepc
			end
		end
	end	
	if utilities.is_set (Authors) then
		if (not utilities.is_set (Date)) then									-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Editors) then
			local in_text = '';
			local post_text = '';
			if utilities.is_set (Chapter) and 0 == #c then
				in_text = cfg.messages['in'] .. ' ';
				if (sepc ~= '.') then
					in_text = in_text:lower();									-- lowercase for cs2
				end
			end
			if EditorCount &lt;= 1 then
				post_text = ' (' .. cfg.messages['editor'] .. ')';				-- be consistent with no-author, no-date case
			else
				post_text = ' (' .. cfg.messages['editors'] .. ')';
			end
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Contributors) then									-- book cite and we're citing the intro, preface, etc.
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if utilities.is_set (Editors) and utilities.is_set (Date) then		-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not utilities.is_set (Date)) then								-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif utilities.is_set (Editors) then
		if utilities.is_set (Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. cfg.presentation['sep_name'] .. cfg.messages['editor'];
			else
				Editors = Editors .. cfg.presentation['sep_name'] .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end

	if utilities.is_set (PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc ); 								-- Deals with italics, spaces, etc.
		if '.' == sepc then														-- remove final seperator if present
			text = text:gsub ('%' .. sepc .. '$', '');							-- dot must be escaped here
		else
			text = mw.ustring.gsub (text, sepc .. '$', '');						-- using ustring for non-dot sepc (likely a non-Latin character)
		end
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite&gt; element
	local options_t = {};
	options_t.class = cite_class_attribute_make (config.CitationClass, Mode);

	local Ref = is_valid_parameter_value (A['Ref'], A:ORIGIN('Ref'), cfg.keywords_lists['ref'], nil, true);	-- nil when |ref=harv; A['Ref'] else

	if 'none' ~= cfg.keywords_xlate[(Ref and Ref:lower()) or ''] then
		local namelist_t = {};													-- holds selected contributor, author, editor name list
		local year = first_set ({Year, anchor_year}, 2);						-- Year first for legacy citations and for YMD dates that require disambiguation

		if #c &gt; 0 then															-- if there is a contributor list
			namelist_t = c;														-- select it
		elseif #a &gt; 0 then														-- or an author list
			namelist_t = a;
		elseif #e &gt; 0 then														-- or an editor list
			namelist_t = e;
		end
		local citeref_id;
		if #namelist_t &gt; 0 then													-- if there are names in namelist_t
			citeref_id = make_citeref_id (namelist_t, year);					-- go make the CITEREF anchor
			if mw.uri.anchorEncode (citeref_id) == ((Ref and mw.uri.anchorEncode (Ref)) or '') then	-- Ref may already be encoded (by {{sfnref}}) so citeref_id must be encoded before comparison
				utilities.set_message ('maint_ref_duplicates_default');
			end
		else
			citeref_id = '';													-- unset
		end
		options_t.id = Ref or citeref_id;
	end

	if string.len (text:gsub('%b&lt;&gt;', '')) &lt;= 2 then								-- remove html and html-like tags; then get length of what remains; 
		z.error_cats_t = {};													-- blank the categories list
		z.error_msgs_t = {};													-- blank the error messages list
		OCinSoutput = nil;														-- blank the metadata string
		text = '';																-- blank the the citation
		utilities.set_message ('err_empty_citation');							-- set empty citation message and category
	end
	
	local render_t = {};														-- here we collect the final bits for concatenation into the rendered citation

	if utilities.is_set (options_t.id) then										-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render_t, utilities.substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options_t.id), mw.text.nowiki(options_t.class), text}));	-- when |ref= is set or when there is a namelist
	else
		table.insert (render_t, utilities.substitute (cfg.presentation['cite'], {mw.text.nowiki(options_t.class), text}));	-- when |ref=none or when namelist_t empty and |ref= is missing or is empty
	end		

	if OCinSoutput then															-- blanked when citation is 'empty' so don't bother to add boilerplate metadata span
		table.insert (render_t, utilities.substitute (cfg.presentation['ocins'], OCinSoutput));	-- format and append metadata to the citation
	end

	local template_name = ('citation' == config.CitationClass) and 'citation' or 'cite ' .. (cfg.citation_class_map_t[config.CitationClass] or config.CitationClass);
	local template_link = '[[Template:' .. template_name .. '|' .. template_name .. ']]';
	local msg_prefix = '&lt;code class=&quot;cs1-code&quot;&gt;{{' .. template_link .. '}}&lt;/code&gt;: ';

	if 0 ~= #z.error_msgs_t then
		mw.addWarning (utilities.substitute (cfg.messages.warning_msg_e, template_link));

		table.insert (render_t, ' ');											-- insert a space between citation and its error messages
		table.sort (z.error_msgs_t);											-- sort the error messages list; sorting includes wrapping &lt;span&gt; and &lt;code&gt; tags; hidden-error sorts ahead of visible-error

		local hidden = true;													-- presume that the only error messages emited by this template are hidden
		for _, v in ipairs (z.error_msgs_t) do									-- spin through the list of error messages
			if v:find ('cs1-visible-error', 1, true) then						-- look for the visible error class name
				hidden = false;													-- found one; so don't hide the error message prefix
				break;															-- and done because no need to look further
			end
		end

		z.error_msgs_t[1] = table.concat ({utilities.error_comment (msg_prefix, hidden), z.error_msgs_t[1]});	-- add error message prefix to first error message to prevent extraneous punctuation
		table.insert (render_t, table.concat (z.error_msgs_t, '; '));			-- make a big string of error messages and add it to the rendering
	end

	if 0 ~= #z.maint_cats_t then
		mw.addWarning (utilities.substitute (cfg.messages.warning_msg_m, template_link));

		table.sort (z.maint_cats_t);											-- sort the maintenance messages list

		local maint_msgs_t = {};												-- here we collect all of the maint messages

		if 0 == #z.error_msgs_t then											-- if no error messages
			table.insert (maint_msgs_t, msg_prefix);							-- insert message prefix in maint message livery
		end
		
		for _, v in ipairs( z.maint_cats_t ) do									-- append maintenance categories
			table.insert (maint_msgs_t, 										-- assemble new maint message and add it to the maint_msgs_t table
				table.concat ({v, ' (', utilities.substitute (cfg.messages[':cat wikilink'], v), ')'})
				);
		end
		table.insert (render_t, utilities.substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs_t, ' ')));	-- wrap the group of maint messages with proper presentation and save
	end

	if not no_tracking_cats then
		local sort_key;
		local cat_wikilink = 'cat wikilink';
		if cfg.enable_sort_keys then											-- when namespace sort keys enabled
			local namespace_number = mw.title.getCurrentTitle().namespace;		-- get namespace number for this wikitext
			sort_key = (0 ~= namespace_number and (cfg.name_space_sort_keys[namespace_number] or cfg.name_space_sort_keys.other)) or nil;	-- get sort key character; nil for mainspace
			cat_wikilink = (not sort_key and 'cat wikilink') or 'cat wikilink sk';	-- make &lt;cfg.messages&gt; key
		end				

		for _, v in ipairs (z.error_cats_t) do									-- append error categories
			table.insert (render_t, utilities.substitute (cfg.messages[cat_wikilink], {v, sort_key}));
		end
		if cfg.id_limits_data_load_fail then									-- boolean true when load failed
			utilities.set_message ('maint_id_limit_load_fail');					-- done here because this maint cat emits no message
		end
		for _, v in ipairs (z.maint_cats_t) do									-- append maintenance categories
			table.insert (render_t, utilities.substitute (cfg.messages[cat_wikilink], {v, sort_key}));
		end
		for _, v in ipairs (z.prop_cats_t) do									-- append properties categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));	-- no sort keys
		end
	end

	return table.concat (render_t);												-- make a big string and done
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class, empty)
	local name = tostring (name);
	local enum_name;															-- parameter name with enumerator (if any) replaced with '#'
	local state;
	local function state_test (state, name)										-- local function to do testing of state values
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			if empty then return nil; end										-- empty deprecated parameters are treated as unknowns
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
		if 'tracked' == state then
			local base_name = name:gsub ('%d', '');								-- strip enumerators from parameter names that have them to get the base name
			utilities.add_prop_cat ('tracked-param', {base_name}, base_name);	-- add a properties category; &lt;base_name&gt; modifies &lt;key&gt;
			return true;
		end
		return nil;
	end		

	if name:find ('#') then														-- # is a cs1|2 reserved character so parameters with # not permitted
		return nil;
	end
																				-- replace enumerator digit(s) with # (|last25= becomes |last#=) (mw.ustring because non-Western 'local' digits)
	enum_name = mw.ustring.gsub (name, '%d+$', '#');							-- where enumerator is last charaters in parameter name (these to protect |s2cid=)
	enum_name = mw.ustring.gsub (enum_name, '%d+([%-l])', '#%1');				-- where enumerator is in the middle of the parameter name; |author#link= is the oddity

	if 'document' == cite_class then											-- special case for {{cite document}}
		state = whitelist.document_parameters_t[enum_name];						-- this list holds enumerated and nonenumerated parameters
		if true == state_test (state, name) then return true; end
		
		return false;
	end

	if utilities.in_array (cite_class, whitelist.preprint_template_list_t) then	-- limited parameter sets allowed for these templates
		state = whitelist.limited_parameters_t[enum_name];						-- this list holds enumerated and nonenumerated parameters
		if true == state_test (state, name) then return true; end

		state = whitelist.preprint_arguments_t[cite_class][name];				-- look in the parameter-list for the template identified by cite_class
		if true == state_test (state, name) then return true; end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates

	if utilities.in_array (cite_class, whitelist.unique_param_template_list_t) then 	-- template-specific parameters for templates that accept parameters from the basic argument list
		state = whitelist.unique_arguments_t[cite_class][name];					-- look in the template-specific parameter-lists for the template identified by cite_class
		if true == state_test (state, name) then return true; end
	end																			-- if here, fall into general validation

	state = whitelist.common_parameters_t[enum_name];							-- all other templates; all normal parameters allowed; this list holds enumerated and nonenumerated parameters
	if true == state_test (state, name) then return true; end

	return false;																-- not supported because not found or name is set to nil
end


--[=[-------------------------&lt; I N T E R _ W I K I _ C H E C K &gt;----------------------------------------------

check &lt;value&gt; for inter-language interwiki-link markup.  &lt;prefix&gt; must be a MediaWiki-recognized language
code.  when these values have the form (without leading colon):
	[[&lt;prefix&gt;:link|label]] return label as plain-text
	[[&lt;prefix&gt;:link]] return &lt;prefix&gt;:link as plain-text

return value as is else

]=]

local function inter_wiki_check (parameter, value)
	local prefix = value:match ('%[%[(%a+):');									-- get an interwiki prefix if one exists
	local _;
	
	if prefix and cfg.inter_wiki_map[prefix:lower()] then						-- if prefix is in the map, needs preceding colon so
		utilities.set_message ('err_bad_paramlink', parameter);					-- emit an error message
		_, value, _ = utilities.is_wikilink (value);							-- extract label portion from wikilink
	end
	return value;
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe.  There are two tests made:
	{{cite ... |title=Title access-date=2016-03-17}}	-- the first parameter has a value and whitespace separates that value from the missing pipe parameter name
	{{cite ... |title=access-date=2016-03-17}}			-- the first parameter has no value (whitespace after the first = is trimmed by MediaWiki)
cs1|2 shares some parameter names with XML/HTML attributes: class=, title=, etc.  To prevent false positives XML/HTML
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (parameter, value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove XML/HTML tags because attributes: class=, title=, etc.

	capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then										-- if the capture is a valid parameter name
		utilities.set_message ('err_missing_pipe', parameter);
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ P U N C T &gt;--------------------------------------

look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_punc (param, value)
	if 'number' == type (param) then
		return;
	end
	
	param = param:gsub ('%d+', '#');											-- enumerated name-list mask params allow terminal punct; normalize 
	if cfg.punct_skip[param] then
		return;																	-- parameter name found in the skip table so done
	end
	
	if value:match ('[,;:]$') then
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
	if value:match ('^=') then													-- sometimes an extraneous '=' character appears ...
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
end


--[[--------------------------&lt; H A S _ T W L _ U R L &gt;--------------------------------------------------------

look for The Wikipedia Library urls in url-holding parameters.  TWL urls are accessible for readers who are not
active extended confirmed Wikipedia editors.  This function emits an error message when such urls are discovered.

looks for: '.wikipedialibrary.idm.oclc.org'

]]

local function has_twl_url (url_params_t)
	local url_error_t = {};														-- sequence of url-holding parameters that have a TWL url
	
	for param, value in pairs (url_params_t) do
		if value:find ('%.wikipedialibrary%.idm%.oclc%.org') then				-- has the TWL base url?
			table.insert (url_error_t, utilities.wrap_style ('parameter', param));	-- add parameter name to the list
		end
	end
	if 0 ~= #url_error_t then													-- non-zero when there are errors
		table.sort (url_error_t);
		utilities.set_message ('err_param_has_twl_url', {utilities.make_sep_list (#url_error_t, url_error_t)});	-- add this error message
		return true;
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ U R L &gt;------------------------------------------

look for extraneous url parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_url (non_url_param_t)
	local url_error_t = {};
	
	check_for_url (non_url_param_t, url_error_t);								-- extraneous url check
	if 0 ~= #url_error_t then													-- non-zero when there are errors
		table.sort (url_error_t);
		utilities.set_message ('err_param_has_ext_link', {utilities.make_sep_list (#url_error_t, url_error_t)});	-- add this error message
	end
end


--[[--------------------------&lt; _ C I T A T I O N &gt;------------------------------------------------------------

Module entry point

	frame – from template call (citation()); may be nil when called from another module
	args – table of all cs1|2 parameters in the template (the template frame)
	config – table of template-supplied parameter (the #invoke frame)

]]

local function _citation (frame, args, config)									-- save a copy in case we need to display an error message in preview mode
	if not frame then
		frame = mw.getCurrentFrame();											-- if called from another module, get a frame for frame-provided functions
	end
																				-- i18n: set the name that your wiki uses to identify sandbox subpages from sandbox template invoke (or can be set here)
	local sandbox = ((config.SandboxPath and '' ~= config.SandboxPath) and config.SandboxPath) or '/sandbox';	-- sandbox path from {{#invoke:Citation/CS1/sandbox|citation|SandboxPath=/...}}
	is_sandbox = nil ~= string.find (frame:getTitle(), sandbox, 1, true);		-- is this invoke the sandbox module?
	sandbox = is_sandbox and sandbox or '';										-- use i18n sandbox to load sandbox modules when this module is the sandox; live modules else

	cfg = mw.loadData ('Module:Citation/CS1/Configuration' .. sandbox);			-- load sandbox versions of support modules when {{#invoke:Citation/CS1/sandbox|...}}; live modules else
	whitelist = mw.loadData ('Module:Citation/CS1/Whitelist' .. sandbox);
	utilities = require ('Module:Citation/CS1/Utilities' .. sandbox);
	validation = require ('Module:Citation/CS1/Date_validation' .. sandbox);
	identifiers = require ('Module:Citation/CS1/Identifiers' .. sandbox);
	metadata = require ('Module:Citation/CS1/COinS' .. sandbox);

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the selected cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	is_preview_mode = not utilities.is_set (frame:preprocess ('{{REVISIONID}}'));

	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text;															-- used as a flag

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	local empty_unknowns = {};													-- sequence table to hold empty unknown params for error message listing
	for k, v in pairs( args ) do												-- get parameters from the parent (template) frame
		v = mw.ustring.gsub (v, '^%s*(.-)%s*$', '%1');							-- trim leading/trailing whitespace; when v is only whitespace, becomes empty string
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				if type (k) ~= 'string' then									-- exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text = utilities.set_message ('err_text_ignored', {v});
					end
				elseif validate (k:lower(), config.CitationClass) then 
					error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, k:lower()});	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						suggestions = mw.loadData ('Module:Citation/CS1/Suggestions' .. sandbox);	--load sandbox version of suggestion module when {{#invoke:Citation/CS1/sandbox|...}}; live module else
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no capture in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = utilities.substitute (param, capture);		-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, param});	-- set the suggestion error message
							else
								error_text = utilities.set_message ('err_parameter_ignored', {k});	-- suggested param not supported by this template
								v = '';											-- unset
							end
						end
					end
					if not utilities.is_set (error_text) then					-- couldn't match with a pattern, is there an explicit suggestion?						
						if (suggestions.suggestions[ k:lower() ] ~= nil) and validate (suggestions.suggestions[ k:lower() ], config.CitationClass) then
							utilities.set_message ('err_parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]});
						else
							utilities.set_message ('err_parameter_ignored', {k});
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
			end

			args[k] = v;														-- save this parameter and its value

		elseif not utilities.is_set (v) then									-- for empty parameters
			if not validate (k, config.CitationClass, true) then				-- is this empty parameter a valid parameter
				k = ('' == k) and '(empty string)' or k;						-- when k is empty string (or was space(s) trimmed to empty string), replace with descriptive text
				table.insert (empty_unknowns, utilities.wrap_style ('parameter', k));	-- format for error message and add to the list
			end
																				-- crude debug support that allows us to render a citation from module {{#invoke:}} TODO: keep?
	--	elseif args[k] ~= nil or (k == 'postscript') then						-- when args[k] has a value from {{#invoke}} frame (we don't normally do that)
	--		args[k] = v;														-- overwrite args[k] with empty string from pframe.args[k] (template frame); v is empty string here
		end																		-- not sure about the postscript bit; that gets handled in parameter validation; historical artifact?
	end	

	if 0 ~= #empty_unknowns then												-- create empty unknown error message
		utilities.set_message ('err_param_unknown_empty', {
			1 == #empty_unknowns and '' or 's',
			utilities.make_sep_list (#empty_unknowns, empty_unknowns)
			});
	end

	local non_url_param_t = {};													-- table of parameters and values that are not url-holding parameters
	local url_param_t = {};														-- table of url-holding paramters and their values

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);											-- look for invisible characters
		end
		has_extraneous_punc (k, v);												-- look for extraneous terminal punctuation in parameter values
		missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?
		args[k] = inter_wiki_check (k, v);										-- when language interwiki-linked parameter missing leading colon replace with wiki-link label

		if 'string' == type (k) then											-- when parameter k is not positional
			if not cfg.url_skip[k] then											-- and not in url skip table
				non_url_param_t[k] = v;											-- make a parameter/value list for extraneous url check
			else																-- and is in url skip table (a url-holding parameter)
				url_param_t[k] = v;												-- make a parameter/value list to check for values that are The Wikipedia Library url
			end
		end
	end

	has_extraneous_url (non_url_param_t);										-- look for url in parameter values where a url does not belong
	if has_twl_url (url_param_t) then												-- look for url-holding parameters that hold a The Wikipedia Library url
		args['url-access'] = 'subscription';
	end
	return table.concat ({
		frame:extensionTag ('templatestyles', '', {src='Module:Citation/CS1' .. sandbox .. '/styles.css'}),
		citation0( config, args)
	});
end


--[[--------------------------&lt; C I T A T I O N &gt;--------------------------------------------------------------

Template entry point

]]

local function citation (frame)
	local config_t = {};														-- table to store parameters from the module {{#invoke:}}
	local args_t = frame:getParent().args;										-- get template's preset parameters

	for k, v in pairs (frame.args) do											-- get parameters from the {{#invoke}} frame
		config_t[k] = v;
	--	args_t[k] = v;															-- crude debug support that allows us to render a citation from module {{#invoke:}}; skips parameter validation; TODO: keep?
	end	
	return _citation (frame, args_t, config_t)
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	citation = citation,														-- template entry point
	
	_citation = _citation,														-- module entry point
	}</text>
      <sha1>swdh50lofyqq0wmp3o2c259fg8s2nxi</sha1>
    </revision>
    <revision>
      <id>4758</id>
      <parentid>4757</parentid>
      <timestamp>2025-08-07T07:37:15Z</timestamp>
      <contributor>
        <username>Martin Urbanec</username>
        <id>803</id>
      </contributor>
      <minor />
      <comment>443 revisions imported from [[:en:Module:Citation/CS1]]: updating from enwiki</comment>
      <origin>4757</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="232143" sha1="swdh50lofyqq0wmp3o2c259fg8s2nxi" xml:space="preserve">require ('strict');

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------

each of these counts against the Lua upvalue limit

]]

local validation;																-- functions in Module:Citation/CS1/Date_validation

local utilities;																-- functions in Module:Citation/CS1/Utilities
local z = {};																	-- table of tables in Module:Citation/CS1/Utilities

local identifiers;																-- functions and tables in Module:Citation/CS1/Identifiers
local metadata;																	-- functions in Module:Citation/CS1/COinS
local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration
local whitelist = {};															-- table of tables listing valid template parameter names; defined in Module:Citation/CS1/Whitelist


--[[------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;---------------

declare variables here that have page-wide scope that are not brought in from
other modules; that are created here and used here

]]

local added_deprecated_cat;														-- Boolean flag so that the category is added only once
local added_vanc_errs;															-- Boolean flag so we only emit one Vancouver error / category
local added_generic_name_errs;													-- Boolean flag so we only emit one generic name error / category and stop testing names once an error is encountered
local added_numeric_name_errs;													-- Boolean flag so we only emit one numeric name error / category and stop testing names once an error is encountered
local added_numeric_name_maint;													-- Boolean flag so we only emit one numeric name maint category and stop testing names once a category has been emitted
local is_preview_mode;															-- true when article is in preview mode; false when using 'Preview page with this template' (previewing the module)
local is_sandbox;																-- true when using sandbox modules to render citation


--[[--------------------------&lt; F I R S T _ S E T &gt;------------------------------------------------------------

Locates and returns the first set value in a table of values where the order established in the table,
left-to-right (or top-to-bottom), is the order in which the values are evaluated.  Returns nil if none are set.

This version replaces the original 'for _, val in pairs do' and a similar version that used ipairs.  With the pairs
version the order of evaluation could not be guaranteed.  With the ipairs version, a nil value would terminate
the for-loop before it reached the actual end of the list.

]]

local function first_set (list, count)
	local i = 1;
	while i &lt;= count do															-- loop through all items in list
		if utilities.is_set( list[i] ) then
			return list[i];														-- return the first set list member
		end
		i = i + 1;																-- point to next
	end
end


--[[--------------------------&lt; A D D _ V A N C _ E R R O R &gt;----------------------------------------------------

Adds a single Vancouver system error message to the template's output regardless of how many error actually exist.
To prevent duplication, added_vanc_errs is nil until an error message is emitted.

added_vanc_errs is a Boolean declared in page scope variables above

]]

local function add_vanc_error (source, position)
	if added_vanc_errs then return end
		
	added_vanc_errs = true;														-- note that we've added this category
	utilities.set_message ('err_vancouver', {source, position});
end


--[[--------------------------&lt; I S _ S C H E M E &gt;------------------------------------------------------------

does this thing that purports to be a URI scheme seem to be a valid scheme?  The scheme is checked to see if it
is in agreement with http://tools.ietf.org/html/std66#section-3.1 which says:
	Scheme names consist of a sequence of characters beginning with a
   letter and followed by any combination of letters, digits, plus
   (&quot;+&quot;), period (&quot;.&quot;), or hyphen (&quot;-&quot;).

returns true if it does, else false

]]

local function is_scheme (scheme)
	return scheme and scheme:match ('^%a[%a%d%+%.%-]*:');						-- true if scheme is set and matches the pattern
end


--[=[-------------------------&lt; I S _ D O M A I N _ N A M E &gt;--------------------------------------------------

Does this thing that purports to be a domain name seem to be a valid domain name?

Syntax defined here: http://tools.ietf.org/html/rfc1034#section-3.5
BNF defined here: https://tools.ietf.org/html/rfc4234
Single character names are generally reserved; see https://tools.ietf.org/html/draft-ietf-dnsind-iana-dns-01#page-15;
	see also [[Single-letter second-level domain]]
list of TLDs: https://www.iana.org/domains/root/db

RFC 952 (modified by RFC 1123) requires the first and last character of a hostname to be a letter or a digit.  Between
the first and last characters the name may use letters, digits, and the hyphen.

Also allowed are IPv4 addresses. IPv6 not supported

domain is expected to be stripped of any path so that the last character in the last character of the TLD.  tld
is two or more alpha characters.  Any preceding '//' (from splitting a URL with a scheme) will be stripped
here.  Perhaps not necessary but retained in case it is necessary for IPv4 dot decimal.

There are several tests:
	the first character of the whole domain name including subdomains must be a letter or a digit
	internationalized domain name (ASCII characters with .xn-- ASCII Compatible Encoding (ACE) prefix xn-- in the TLD) see https://tools.ietf.org/html/rfc3490
	single-letter/digit second-level domains in the .org, .cash, and .today TLDs
	q, x, and z SL domains in the .com TLD
	i and q SL domains in the .net TLD
	single-letter SL domains in the ccTLDs (where the ccTLD is two letters)
	two-character SL domains in gTLDs (where the gTLD is two or more letters)
	three-plus-character SL domains in gTLDs (where the gTLD is two or more letters)
	IPv4 dot-decimal address format; TLD not allowed

returns true if domain appears to be a proper name and TLD or IPv4 address, else false

]=]

local function is_domain_name (domain)
	if not domain then
		return false;															-- if not set, abandon
	end
	
	domain = domain:gsub ('^//', '');											-- strip '//' from domain name if present; done here so we only have to do it once
	
	if not domain:match ('^[%w]') then											-- first character must be letter or digit
		return false;
	end

	if domain:match ('^%a+:') then												-- hack to detect things that look like s:Page:Title where Page: is namespace at Wikisource
		return false;
	end

	local patterns = {															-- patterns that look like URLs
		'%f[%w][%w][%w%-]+[%w]%.%a%a+$',										-- three or more character hostname.hostname or hostname.tld
		'%f[%w][%w][%w%-]+[%w]%.xn%-%-[%w]+$',									-- internationalized domain name with ACE prefix
		'%f[%a][qxz]%.com$',													-- assigned one character .com hostname (x.com times out 2015-12-10)
		'%f[%a][iq]%.net$',														-- assigned one character .net hostname (q.net registered but not active 2015-12-10)
		'%f[%w][%w]%.%a%a$',													-- one character hostname and ccTLD (2 chars)
		'%f[%w][%w][%w]%.%a%a+$',												-- two character hostname and TLD
		'^%d%d?%d?%.%d%d?%d?%.%d%d?%d?%.%d%d?%d?',								-- IPv4 address
		'[%a%d]+%:?'                                                            -- IPv6 address
		}

	for _, pattern in ipairs (patterns) do										-- loop through the patterns list
		if domain:match (pattern) then
			return true;														-- if a match then we think that this thing that purports to be a URL is a URL
		end
	end

	for _, d in ipairs (cfg.single_letter_2nd_lvl_domains_t) do					-- look for single letter second level domain names for these top level domains
		if domain:match ('%f[%w][%w]%.' .. d) then
			return true
		end
	end
	return false;																-- no matches, we don't know what this thing is
end


--[[--------------------------&lt; I S _ U R L &gt;------------------------------------------------------------------

returns true if the scheme and domain parts of a URL appear to be a valid URL; else false.

This function is the last step in the validation process.  This function is separate because there are cases that
are not covered by split_url(), for example is_parameter_ext_wikilink() which is looking for bracketted external
wikilinks.

]]

local function is_url (scheme, domain)
	if utilities.is_set (scheme) then											-- if scheme is set check it and domain
		return is_scheme (scheme) and is_domain_name (domain);
	else
		return is_domain_name (domain);											-- scheme not set when URL is protocol-relative
	end
end


--[[--------------------------&lt; S P L I T _ U R L &gt;------------------------------------------------------------

Split a URL into a scheme, authority indicator, and domain.

First remove Fully Qualified Domain Name terminator (a dot following TLD) (if any) and any path(/), query(?) or fragment(#).

If protocol-relative URL, return nil scheme and domain else return nil for both scheme and domain.

When not protocol-relative, get scheme, authority indicator, and domain.  If there is an authority indicator (one
or more '/' characters immediately following the scheme's colon), make sure that there are only 2.

Any URL that does not have news: scheme must have authority indicator (//).  TODO: are there other common schemes
like news: that don't use authority indicator?

Strip off any port and path;

]]

local function split_url (url_str)
	local scheme, authority, domain;
	
	url_str = url_str:gsub ('([%a%d])%.?[/%?#].*$', '%1');						-- strip FQDN terminator and path(/), query(?), fragment (#) (the capture prevents false replacement of '//')

	if url_str:match ('^//%S*') then											-- if there is what appears to be a protocol-relative URL
		domain = url_str:match ('^//(%S*)')
	elseif url_str:match ('%S-:/*%S+') then										-- if there is what appears to be a scheme, optional authority indicator, and domain name
		scheme, authority, domain = url_str:match ('(%S-:)(/*)(%S+)');			-- extract the scheme, authority indicator, and domain portions
		if utilities.is_set (authority) then
			authority = authority:gsub ('//', '', 1);							-- replace place 1 pair of '/' with nothing;
			if utilities.is_set(authority) then									-- if anything left (1 or 3+ '/' where authority should be) then
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		else
			if not scheme:match ('^news:') then									-- except for news:..., MediaWiki won't link URLs that do not have authority indicator; TODO: a better way to do this test?
				return scheme;													-- return scheme only making domain nil which will cause an error message
			end
		end
		domain = domain:gsub ('(%a):%d+', '%1');								-- strip port number if present
	end
	
	return scheme, domain;
end


--[[--------------------------&lt; L I N K _ P A R A M _ O K &gt;---------------------------------------------------

checks the content of |title-link=, |series-link=, |author-link=, etc. for properly formatted content: no wikilinks, no URLs

Link parameters are to hold the title of a Wikipedia article, so none of the WP:TITLESPECIALCHARACTERS are allowed:
	# &lt; &gt; [ ] | { } _
except the underscore which is used as a space in wiki URLs and # which is used for section links

returns false when the value contains any of these characters.

When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid URL (the
|&lt;param&gt;-link= parameter is ok); else false when value appears to be a valid URL (the |&lt;param&gt;-link= parameter is NOT ok).

]]

local function link_param_ok (value)
	local scheme, domain;
	if value:find ('[&lt;&gt;%[%]|{}]') then                                          -- if any prohibited characters
		return false;
	end

	scheme, domain = split_url (value);											-- get scheme or nil and domain or nil from URL; 
	return not is_url (scheme, domain);											-- return true if value DOES NOT appear to be a valid URL
end


--[[--------------------------&lt; L I N K _ T I T L E _ O K &gt;---------------------------------------------------

Use link_param_ok() to validate |&lt;param&gt;-link= value and its matching |&lt;title&gt;= value.

|&lt;title&gt;= may be wiki-linked but not when |&lt;param&gt;-link= has a value.  This function emits an error message when
that condition exists

check &lt;link&gt; for inter-language interwiki-link prefix.  prefix must be a MediaWiki-recognized language
code and must begin with a colon.

]]

local function link_title_ok (link, lorig, title, torig)
	local orig;
	if utilities.is_set (link) then 											-- don't bother if &lt;param&gt;-link doesn't have a value
		if not link_param_ok (link) then										-- check |&lt;param&gt;-link= markup
			orig = lorig;														-- identify the failing link parameter
		elseif title:find ('%[%[') then											-- check |title= for wikilink markup
			orig = torig;														-- identify the failing |title= parameter
		elseif link:match ('^%a+:') then										-- if the link is what looks like an interwiki
			local prefix = link:match ('^(%a+):'):lower();						-- get the interwiki prefix

			if cfg.inter_wiki_map[prefix] then									-- if prefix is in the map, must have preceding colon
				orig = lorig;													-- flag as error
			end
		end
	end

	if utilities.is_set (orig) then
		link = '';																-- unset
		utilities.set_message ('err_bad_paramlink', orig);						-- URL or wikilink in |title= with |title-link=;
	end
	
	return link;																-- link if ok, empty string else
end


--[[--------------------------&lt; C H E C K _ U R L &gt;------------------------------------------------------------

Determines whether a URL string appears to be valid.

First we test for space characters.  If any are found, return false.  Then split the URL into scheme and domain
portions, or for protocol-relative (//example.com) URLs, just the domain.  Use is_url() to validate the two
portions of the URL.  If both are valid, or for protocol-relative if domain is valid, return true, else false.

Because it is different from a standard URL, and because this module used external_link() to make external links
that work for standard and news: links, we validate newsgroup names here.  The specification for a newsgroup name
is at https://tools.ietf.org/html/rfc5536#section-3.1.4

]]

local function check_url( url_str )
	if nil == url_str:match (&quot;^%S+$&quot;) then										-- if there are any spaces in |url=value it can't be a proper URL
		return false;
	end
	local scheme, domain;

	scheme, domain = split_url (url_str);										-- get scheme or nil and domain or nil from URL;
	
	if 'news:' == scheme then													-- special case for newsgroups
		return domain:match('^[%a%d%+%-_]+%.[%a%d%+%-_%.]*[%a%d%+%-_]$');
	end
	
	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[=[-------------------------&lt; I S _ P A R A M E T E R _ E X T _ W I K I L I N K &gt;----------------------------

Return true if a parameter value has a string that begins and ends with square brackets [ and ] and the first
non-space characters following the opening bracket appear to be a URL.  The test will also find external wikilinks
that use protocol-relative URLs. Also finds bare URLs.

The frontier pattern prevents a match on interwiki-links which are similar to scheme:path URLs.  The tests that
find bracketed URLs are required because the parameters that call this test (currently |title=, |chapter=, |work=,
and |publisher=) may have wikilinks and there are articles or redirects like '//Hus' so, while uncommon, |title=[[//Hus]]
is possible as might be [[en://Hus]].

]=]

local function is_parameter_ext_wikilink (value)
local scheme, domain;

	if value:match ('%f[%[]%[%a%S*:%S+.*%]') then								-- if ext. wikilink with scheme and domain: [xxxx://yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(%a%S*:%S+).*%]'));
	elseif value:match ('%f[%[]%[//%S+.*%]') then								-- if protocol-relative ext. wikilink: [//yyyyy.zzz]
		scheme, domain = split_url (value:match ('%f[%[]%[(//%S+).*%]'));
	elseif value:match ('%a%S*:%S+') then										-- if bare URL with scheme; may have leading or trailing plain text
		scheme, domain = split_url (value:match ('(%a%S*:%S+)'));
	elseif value:match ('^//%S+') or value:match ('%s//%S+') then				-- if protocol-relative bare URL: //yyyyy.zzz; authority indicator (//) must be be preceded nothing or by whitespace
		scheme, domain = split_url (value:match ('(//%S+)'));					-- what is left should be the domain
	else
		return false;															-- didn't find anything that is obviously a URL
	end

	return is_url (scheme, domain);												-- return true if value appears to be a valid URL
end


--[[-------------------------&lt; C H E C K _ F O R _ U R L &gt;-----------------------------------------------------

loop through a list of parameters and their values.  Look at the value and if it has an external link, emit an error message.

]]

local function check_for_url (parameter_list, error_list)
	for k, v in pairs (parameter_list) do										-- for each parameter in the list
		if is_parameter_ext_wikilink (v) then									-- look at the value; if there is a URL add an error message
			table.insert (error_list, utilities.wrap_style ('parameter', k));
		end
	end
end


--[[--------------------------&lt; S A F E _ F O R _ U R L &gt;------------------------------------------------------

Escape sequences for content that will be used for URL descriptions

]]

local function safe_for_url( str )
	if str:match( &quot;%[%[.-%]%]&quot; ) ~= nil then 
		utilities.set_message ('err_wikilink_in_url', {});
	end
	
	return str:gsub( '[%[%]\n]', {	
		['['] = '&amp;#91;',
		[']'] = '&amp;#93;',
		['\n'] = ' ' } );
end


--[[--------------------------&lt; E X T E R N A L _ L I N K &gt;----------------------------------------------------

Format an external link with error checking

]]

local function external_link (URL, label, source, access)
	local err_msg = '';
	local domain;
	local path;
	local base_url;

	if not utilities.is_set (label) then
		label = URL;
		if utilities.is_set (source) then
			utilities.set_message ('err_bare_url_missing_title', {utilities.wrap_style ('parameter', source)});
		else
			error (cfg.messages[&quot;bare_url_no_origin&quot;]);							-- programmer error; valid parameter name does not have matching meta-parameter
		end			
	end
	if not check_url (URL) then
		utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)});
	end
	
	domain, path = URL:match ('^([/%.%-%+:%a%d]+)([/%?#].*)$');					-- split the URL into scheme plus domain and path
	if path then																-- if there is a path portion
		path = path:gsub ('[%[%]]', {['['] = '%5b', [']'] = '%5d'});			-- replace '[' and ']' with their percent-encoded values
		URL = table.concat ({domain, path});									-- and reassemble
	end

	base_url = table.concat ({ &quot;[&quot;, URL, &quot; &quot;, safe_for_url (label), &quot;]&quot; });		-- assemble a wiki-markup URL

	if utilities.is_set (access) then											-- access level (subscription, registration, limited)
		base_url = utilities.substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[access].class, cfg.presentation[access].title, base_url});	-- add the appropriate icon
	end

	return base_url;
end


--[[--------------------------&lt; D E P R E C A T E D _ P A R A M E T E R &gt;--------------------------------------

Categorize and emit an error message when the citation contains one or more deprecated parameters.  The function includes the
offending parameter name to the error message.  Only one error message is emitted regardless of the number of deprecated
parameters in the citation.

added_deprecated_cat is a Boolean declared in page scope variables above

]]

local function deprecated_parameter(name)
	if not added_deprecated_cat then
		added_deprecated_cat = true;											-- note that we've added this category
		utilities.set_message ('err_deprecated_params', {name});				-- add error message
	end
end


--[=[-------------------------&lt; K E R N _ Q U O T E S &gt;--------------------------------------------------------

Apply kerning to open the space between the quote mark provided by the module and a leading or trailing quote
mark contained in a |title= or |chapter= parameter's value.

This function will positive kern either single or double quotes:
	&quot;'Unkerned title with leading and trailing single quote marks'&quot;
	&quot; 'Kerned title with leading and trailing single quote marks' &quot; (in real life the kerning isn't as wide as this example)
Double single quotes (italic or bold wiki-markup) are not kerned.

Replaces Unicode quote marks in plain text or in the label portion of a [[L|D]] style wikilink with typewriter
quote marks regardless of the need for kerning.  Unicode quote marks are not replaced in simple [[D]] wikilinks.

Call this function for chapter titles, for website titles, etc.; not for book titles.

]=]

local function kern_quotes (str)
	local cap = '';
	local wl_type, label, link;

	wl_type, label, link = utilities.is_wikilink (str);							-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
	
	if 1 == wl_type then														-- [[D]] simple wikilink with or without quote marks
		if mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+[\&quot;“”\'‘’]%]%]') then		-- leading and trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-left'], str);
			str = utilities.substitute (cfg.presentation['kern-right'], str);
		elseif mw.ustring.match (str, '%[%[[\&quot;“”\'‘’].+%]%]')	then			-- leading quote marks
			str = utilities.substitute (cfg.presentation['kern-left'], str);
		elseif mw.ustring.match (str, '%[%[.+[\&quot;“”\'‘’]%]%]') then				-- trailing quote marks
			str = utilities.substitute (cfg.presentation['kern-right'], str);
		end

	else																		-- plain text or [[L|D]]; text in label variable
		label = mw.ustring.gsub (label, '[“”]', '\&quot;');							-- replace “” (U+201C &amp; U+201D) with &quot; (typewriter double quote mark)
		label = mw.ustring.gsub (label, '[‘’]', '\'');							-- replace ‘’ (U+2018 &amp; U+2019) with ' (typewriter single quote mark)

		cap = mw.ustring.match (label, &quot;^([\&quot;\'][^\'].+)&quot;);						-- match leading double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-left'], cap);
		end
	
		cap = mw.ustring.match (label, &quot;^(.+[^\'][\&quot;\'])$&quot;)						-- match trailing double or single quote but not doubled single quotes (italic markup)
		if utilities.is_set (cap) then
			label = utilities.substitute (cfg.presentation['kern-right'], cap);
		end
		
		if 2 == wl_type then
			str = utilities.make_wikilink (link, label);						-- reassemble the wikilink
		else
			str = label;
		end
	end
	return str;
end


--[[--------------------------&lt; F O R M A T _ S C R I P T _ V A L U E &gt;----------------------------------------

|script-title= holds title parameters that are not written in Latin-based scripts: Chinese, Japanese, Arabic, Hebrew, etc. These scripts should
not be italicized and may be written right-to-left.  The value supplied by |script-title= is concatenated onto Title after Title has been wrapped
in italic markup.

Regardless of language, all values provided by |script-title= are wrapped in &lt;bdi&gt;...&lt;/bdi&gt; tags to isolate RTL languages from the English left to right.

|script-title= provides a unique feature.  The value in |script-title= may be prefixed with a two-character ISO 639-1 language code and a colon:
	|script-title=ja:*** *** (where * represents a Japanese character)
Spaces between the two-character code and the colon and the colon and the first script character are allowed:
	|script-title=ja : *** ***
	|script-title=ja: *** ***
	|script-title=ja :*** ***
Spaces preceding the prefix are allowed: |script-title = ja:*** ***

The prefix is checked for validity.  If it is a valid ISO 639-1 language code, the lang attribute (lang=&quot;ja&quot;) is added to the &lt;bdi&gt; tag so that browsers can
know the language the tag contains.  This may help the browser render the script more correctly.  If the prefix is invalid, the lang attribute
is not added.  At this time there is no error message for this condition.

Supports |script-title=, |script-chapter=, |script-&lt;periodical&gt;=

]]

local function format_script_value (script_value, script_param)
	local lang='';																-- initialize to empty string
	local name;
	if script_value:match('^%l%l%l?%s*:') then									-- if first 3 or 4 non-space characters are script language prefix
		lang = script_value:match('^(%l%l%l?)%s*:%s*%S.*');						-- get the language prefix or nil if there is no script
		if not utilities.is_set (lang) then
			utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['missing title part']});		-- prefix without 'title'; add error message
			return '';															-- script_value was just the prefix so return empty string
		end
																				-- if we get this far we have prefix and script
		name = cfg.lang_tag_remap[lang] or mw.language.fetchLanguageName( lang, cfg.this_wiki_code );	-- get language name so that we can use it to categorize
		if utilities.is_set (name) then											-- is prefix a proper ISO 639-1 language code?
			script_value = script_value:gsub ('^%l+%s*:%s*', '');				-- strip prefix from script
																				-- is prefix one of these language codes?
			if utilities.in_array (lang, cfg.script_lang_codes) then
				utilities.add_prop_cat ('script', {name, lang})
			else
				utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['unknown language code']});	-- unknown script-language; add error message
			end
			lang = ' lang=&quot;' .. lang .. '&quot; ';									-- convert prefix into a lang attribute
		else
			utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['invalid language code']});		-- invalid language code; add error message
			lang = '';															-- invalid so set lang to empty string
		end
	else
		utilities.set_message ('err_script_parameter', {script_param, cfg.err_msg_supl['missing prefix']});				-- no language code prefix; add error message
	end
	script_value = utilities.substitute (cfg.presentation['bdi'], {lang, script_value});	-- isolate in case script is RTL

	return script_value;
end


--[[--------------------------&lt; S C R I P T _ C O N C A T E N A T E &gt;------------------------------------------

Initially for |title= and |script-title=, this function concatenates those two parameter values after the script
value has been wrapped in &lt;bdi&gt; tags.

]]

local function script_concatenate (title, script, script_param)
	if utilities.is_set (script) then
		script = format_script_value (script, script_param);					-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; returns empty string on error
		if utilities.is_set (script) then
			title = title .. ' ' .. script;										-- concatenate title and script title
		end
	end
	return title;
end


--[[--------------------------&lt; W R A P _ M S G &gt;--------------------------------------------------------------

Applies additional message text to various parameter values. Supplied string is wrapped using a message_list
configuration taking one argument.  Supports lower case text for {{citation}} templates.  Additional text taken
from citation_config.messages - the reason this function is similar to but separate from wrap_style().

]]

local function wrap_msg (key, str, lower)
	if not utilities.is_set ( str ) then
		return &quot;&quot;;
	end
	if true == lower then
		local msg;
		msg = cfg.messages[key]:lower();										-- set the message to lower case before 
		return utilities.substitute ( msg, str );								-- including template text
	else
		return utilities.substitute ( cfg.messages[key], str );
	end		
end


--[[----------------&lt; W I K I S O U R C E _ U R L _ M A K E &gt;-------------------

Makes a Wikisource URL from Wikisource interwiki-link.  Returns the URL and appropriate
label; nil else.

str is the value assigned to |chapter= (or aliases) or |title= or |title-link=

]]

local function wikisource_url_make (str)
	local wl_type, D, L;
	local ws_url, ws_label;
	local wikisource_prefix = table.concat ({'https://', cfg.this_wiki_code, '.wikisource.org/wiki/'});

	wl_type, D, L = utilities.is_wikilink (str);								-- wl_type is 0 (not a wikilink), 1 (simple wikilink), 2 (complex wikilink)

	if 0 == wl_type then														-- not a wikilink; might be from |title-link=
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 1 == wl_type then													-- simple wikilink: [[Wikisource:ws article]]
		str = D:match ('^[Ww]ikisource:(.+)') or D:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title
				});
			ws_label = str;														-- label for the URL
		end
	elseif 2 == wl_type then													-- non-so-simple wikilink: [[Wikisource:ws article|displayed text]] ([[L|D]])
		str = L:match ('^[Ww]ikisource:(.+)') or L:match ('^[Ss]:(.+)');		-- article title from interwiki link with long-form or short-form namespace
		if utilities.is_set (str) then
			ws_label = D;														-- get ws article name from display portion of interwiki link
			ws_url = table.concat ({											-- build a Wikisource URL
				wikisource_prefix,												-- prefix
				str,															-- article title without namespace from link portion of wikilink
				});
		end
	end

	if ws_url then
		ws_url = mw.uri.encode (ws_url, 'WIKI');								-- make a usable URL
		ws_url = ws_url:gsub ('%%23', '#');										-- undo percent-encoding of fragment marker
	end

	return ws_url, ws_label, L or D;											-- return proper URL or nil and a label or nil
end


--[[----------------&lt; F O R M A T _ P E R I O D I C A L &gt;-----------------------

Format the three periodical parameters: |script-&lt;periodical&gt;=, |&lt;periodical&gt;=,
and |trans-&lt;periodical&gt;= into a single Periodical meta-parameter.

]]

local function format_periodical (script_periodical, script_periodical_source, periodical, trans_periodical)

	if not utilities.is_set (periodical) then
		periodical = '';														-- to be safe for concatenation
	else
		periodical = utilities.wrap_style ('italic-title', periodical);			-- style 
	end

	periodical = script_concatenate (periodical, script_periodical, script_periodical_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (trans_periodical) then
		trans_periodical = utilities.wrap_style ('trans-italic-title', trans_periodical);
		if utilities.is_set (periodical) then
			periodical = periodical .. ' ' .. trans_periodical;
		else																	-- here when trans-periodical without periodical or script-periodical
			periodical = trans_periodical;
			utilities.set_message ('err_trans_missing_title', {'periodical'});
		end
	end

	return periodical;
end


--[[------------------&lt; F O R M A T _ C H A P T E R _ T I T L E &gt;---------------

Format the four chapter parameters: |script-chapter=, |chapter=, |trans-chapter=,
and |chapter-url= into a single chapter meta- parameter (chapter_url_source used
for error messages).

]]

local function format_chapter_title (script_chapter, script_chapter_source, chapter, chapter_source, trans_chapter, trans_chapter_source, chapter_url, chapter_url_source, no_quotes, access)
	local ws_url, ws_label, L = wikisource_url_make (chapter);					-- make a wikisource URL and label from a wikisource interwiki link
	if ws_url then
		ws_label = ws_label:gsub ('_', ' ');									-- replace underscore separators with space characters
		chapter = ws_label;
	end

	if not utilities.is_set (chapter) then
		chapter = '';															-- to be safe for concatenation
	else
		if false == no_quotes then
			chapter = kern_quotes (chapter);									-- if necessary, separate chapter title's leading and trailing quote marks from module provided quote marks
			chapter = utilities.wrap_style ('quoted-title', chapter);
		end
	end

	chapter = script_concatenate (chapter, script_chapter, script_chapter_source);	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped

	if utilities.is_set (chapter_url) then
		chapter = external_link (chapter_url, chapter, chapter_url_source, access);	-- adds bare_url_missing_title error if appropriate
	elseif ws_url then
		chapter = external_link (ws_url, chapter .. '&amp;nbsp;', 'ws link in chapter');	-- adds bare_url_missing_title error if appropriate; space char to move icon away from chap text; TODO: better way to do this?
		chapter = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, chapter});				
	end

	if utilities.is_set (trans_chapter) then
		trans_chapter = utilities.wrap_style ('trans-quoted-title', trans_chapter);
		if utilities.is_set (chapter) then
			chapter = chapter .. ' ' .. trans_chapter;
		else																	-- here when trans_chapter without chapter or script-chapter
			chapter = trans_chapter;
			chapter_source = trans_chapter_source:match ('trans%-?(.+)');		-- when no chapter, get matching name from trans-&lt;param&gt;
			utilities.set_message ('err_trans_missing_title', {chapter_source});
		end
	end

	return chapter;
end


--[[----------------&lt; H A S _ I N V I S I B L E _ C H A R S &gt;-------------------

This function searches a parameter's value for non-printable or invisible characters.
The search stops at the first match.

This function will detect the visible replacement character when it is part of the Wikisource.

Detects but ignores nowiki and math stripmarkers.  Also detects other named stripmarkers
(gallery, math, pre, ref) and identifies them with a slightly different error message.
See also coins_cleanup().

Output of this function is an error message that identifies the character or the
Unicode group, or the stripmarker that was detected along with its position (or,
for multi-byte characters, the position of its first byte) in the parameter value.

]]

local function has_invisible_chars (param, v)
	local position = '';														-- position of invisible char or starting position of stripmarker
	local capture;																-- used by stripmarker detection to hold name of the stripmarker
	local stripmarker;															-- boolean set true when a stripmarker is found

	capture = string.match (v, '[%w%p ]*');										-- test for values that are simple ASCII text and bypass other tests if true
	if capture == v then														-- if same there are no Unicode characters
		return;
	end

	for _, invisible_char in ipairs (cfg.invisible_chars) do
		local char_name = invisible_char[1];									-- the character or group name
		local pattern = invisible_char[2];										-- the pattern used to find it
		position, _, capture = mw.ustring.find (v, pattern);					-- see if the parameter value contains characters that match the pattern
		
		if position and (cfg.invisible_defs.zwj == capture) then				-- if we found a zero-width joiner character
			if mw.ustring.find (v, cfg.indic_script) then						-- it's ok if one of the Indic scripts
				position = nil;													-- unset position
			elseif cfg.emoji_t[mw.ustring.codepoint (v, position+1)] then			-- is zwj followed by a character listed in emoji{}?
				position = nil;													-- unset position
			end
		end
		
		if position then
			if 'nowiki' == capture or 'math' == capture or						-- nowiki and math stripmarkers (not an error condition)
				('templatestyles' == capture and utilities.in_array (param, {'id', 'quote'})) then	-- templatestyles stripmarker allowed in these parameters
					stripmarker = true;											-- set a flag
			elseif true == stripmarker and cfg.invisible_defs.del == capture then	-- because stripmakers begin and end with the delete char, assume that we've found one end of a stripmarker
				position = nil;													-- unset
			else
				local err_msg;
				if capture and not (cfg.invisible_defs.del == capture or cfg.invisible_defs.zwj == capture) then
					err_msg = capture .. ' ' .. char_name;
				else
					err_msg = char_name .. ' ' .. 'character';
				end

				utilities.set_message ('err_invisible_char', {err_msg, utilities.wrap_style ('parameter', param), position});	-- add error message
				return;															-- and done with this parameter
			end
		end
	end
end


--[[-------------------&lt; A R G U M E N T _ W R A P P E R &gt;----------------------

Argument wrapper.  This function provides support for argument mapping defined
in the configuration file so that multiple names can be transparently aliased to
single internal variable.

]]

local function argument_wrapper ( args )
	local origin = {};
	
	return setmetatable({
		ORIGIN = function ( self, k )
			local dummy = self[k];												-- force the variable to be loaded.
			return origin[k];
		end
	},
	{
		__index = function ( tbl, k )
			if origin[k] ~= nil then
				return nil;
			end
			
			local args, list, v = args, cfg.aliases[k];
			
			if type( list ) == 'table' then
				v, origin[k] = utilities.select_one ( args, list, 'err_redundant_parameters' );
				if origin[k] == nil then
					origin[k] = '';												-- Empty string, not nil
				end
			elseif list ~= nil then
				v, origin[k] = args[list], list;
			else
				-- maybe let through instead of raising an error?
				-- v, origin[k] = args[k], k;
				error( cfg.messages['unknown_argument_map'] .. ': ' .. k);
			end
			
			-- Empty strings, not nil;
			if v == nil then
				v = '';
				origin[k] = '';
			end
			
			tbl = rawset( tbl, k, v );
			return v;
		end,
	});
end


--[[--------------------------&lt; N O W R A P _ D A T E &gt;-------------------------

When date is YYYY-MM-DD format wrap in nowrap span: &lt;span ...&gt;YYYY-MM-DD&lt;/span&gt;.
When date is DD MMMM YYYY or is MMMM DD, YYYY then wrap in nowrap span:
&lt;span ...&gt;DD MMMM&lt;/span&gt; YYYY or &lt;span ...&gt;MMMM DD,&lt;/span&gt; YYYY

DOES NOT yet support MMMM YYYY or any of the date ranges.

]]

local function nowrap_date (date)
	local cap = '';
	local cap2 = '';

	if date:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then
		date = utilities.substitute (cfg.presentation['nowrap1'], date);
	
	elseif date:match(&quot;^%a+%s*%d%d?,%s+%d%d%d%d$&quot;) or date:match (&quot;^%d%d?%s*%a+%s+%d%d%d%d$&quot;) then
		cap, cap2 = string.match (date, &quot;^(.*)%s+(%d%d%d%d)$&quot;);
		date = utilities.substitute (cfg.presentation['nowrap2'], {cap, cap2});
	end
	
	return date;
end


--[[--------------------------&lt; S E T _ T I T L E T Y P E &gt;---------------------

This function sets default title types (equivalent to the citation including
|type=&lt;default value&gt;) for those templates that have defaults. Also handles the
special case where it is desirable to omit the title type from the rendered citation
(|type=none).

]]

local function set_titletype (cite_class, title_type)
	if utilities.is_set (title_type) then
		if 'none' == cfg.keywords_xlate[title_type] then
			title_type = '';													-- if |type=none then type parameter not displayed
		end
		return title_type;														-- if |type= has been set to any other value use that value
	end

	return cfg.title_types [cite_class] or '';									-- set template's default title type; else empty string for concatenation
end


--[[--------------------------&lt; S A F E _ J O I N &gt;-----------------------------

Joins a sequence of strings together while checking for duplicate separation characters.

]]

local function safe_join( tbl, duplicate_char )
	local f = {};																-- create a function table appropriate to type of 'duplicate character'
		if 1 == #duplicate_char then											-- for single byte ASCII characters use the string library functions
			f.gsub = string.gsub
			f.match = string.match
			f.sub = string.sub
		else																	-- for multi-byte characters use the ustring library functions
			f.gsub = mw.ustring.gsub
			f.match = mw.ustring.match
			f.sub = mw.ustring.sub
		end

	local str = '';																-- the output string
	local comp = '';															-- what does 'comp' mean?
	local end_chr = '';
	local trim;
	for _, value in ipairs( tbl ) do
		if value == nil then value = ''; end
		
		if str == '' then														-- if output string is empty
			str = value;														-- assign value to it (first time through the loop)
		elseif value ~= '' then
			if value:sub(1, 1) == '&lt;' then										-- special case of values enclosed in spans and other markup.
				comp = value:gsub( &quot;%b&lt;&gt;&quot;, &quot;&quot; );								-- remove HTML markup (&lt;span&gt;string&lt;/span&gt; -&gt; string)
			else
				comp = value;
			end
																				-- typically duplicate_char is sepc
			if f.sub(comp, 1, 1) == duplicate_char then							-- is first character same as duplicate_char? why test first character?
																				--   Because individual string segments often (always?) begin with terminal punct for the
																				--   preceding segment: 'First element' .. 'sepc next element' .. etc.?
				trim = false;
				end_chr = f.sub(str, -1, -1);									-- get the last character of the output string
				-- str = str .. &quot;&lt;HERE(enchr=&quot; .. end_chr .. &quot;)&quot;				-- debug stuff?
				if end_chr == duplicate_char then								-- if same as separator
					str = f.sub(str, 1, -2);									-- remove it
				elseif end_chr == &quot;'&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;''&quot; then		-- if last three chars of str are sepc'' 
						str = f.sub(str, 1, -4) .. &quot;''&quot;;						-- remove them and add back ''
					elseif  f.sub(str, -5, -1) == duplicate_char .. &quot;]]''&quot; then	-- if last five chars of str are sepc]]'' 
						trim = true;											-- why? why do this and next differently from previous?
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;]''&quot; then	-- if last four chars of str are sepc]'' 
						trim = true;											-- same question
					end
				elseif end_chr == &quot;]&quot; then										-- if it might be wiki-markup
					if f.sub(str, -3, -1) == duplicate_char .. &quot;]]&quot; then		-- if last three chars of str are sepc]] wikilink 
						trim = true;
					elseif f.sub(str, -3, -1) == duplicate_char .. '&quot;]' then	-- if last three chars of str are sepc&quot;] quoted external link 
						trim = true;
					elseif  f.sub(str, -2, -1) == duplicate_char .. &quot;]&quot; then	-- if last two chars of str are sepc] external link
						trim = true;
					elseif f.sub(str, -4, -1) == duplicate_char .. &quot;'']&quot; then	-- normal case when |url=something &amp; |title=Title.
						trim = true;
					end
				elseif end_chr == &quot; &quot; then										-- if last char of output string is a space
					if f.sub(str, -2, -1) == duplicate_char .. &quot; &quot; then			-- if last two chars of str are &lt;sepc&gt;&lt;space&gt;
						str = f.sub(str, 1, -3);								-- remove them both
					end
				end

				if trim then
					if value ~= comp then 										-- value does not equal comp when value contains HTML markup
						local dup2 = duplicate_char;
						if f.match(dup2, &quot;%A&quot; ) then dup2 = &quot;%&quot; .. dup2; end	-- if duplicate_char not a letter then escape it
						
						value = f.gsub(value, &quot;(%b&lt;&gt;)&quot; .. dup2, &quot;%1&quot;, 1 )		-- remove duplicate_char if it follows HTML markup
					else
						value = f.sub(value, 2, -1 );							-- remove duplicate_char when it is first character
					end
				end
			end
			str = str .. value; 												-- add it to the output string
		end
	end
	return str;
end


--[[--------------------------&lt; I S _ S U F F I X &gt;-----------------------------

returns true if suffix is properly formed Jr, Sr, or ordinal in the range 1–9.
Puncutation not allowed.

]]

local function is_suffix (suffix)
	if utilities.in_array (suffix, {'Jr', 'Sr', 'Jnr', 'Snr', '1st', '2nd', '3rd'}) or suffix:match ('^%dth$') then
		return true;
	end
	return false;
end


--[[--------------------&lt; I S _ G O O D _ V A N C _ N A M E &gt;-------------------

For Vancouver style, author/editor names are supposed to be rendered in Latin
(read ASCII) characters.  When a name uses characters that contain diacritical
marks, those characters are to be converted to the corresponding Latin
character. When a name is written using a non-Latin alphabet or logogram, that
name is to be transliterated into Latin characters. The module doesn't do this
so editors may/must.

This test allows |first= and |last= names to contain any of the letters defined
in the four Unicode Latin character sets
	[http://www.unicode.org/charts/PDF/U0000.pdf C0 Controls and Basic Latin] 0041–005A, 0061–007A
	[http://www.unicode.org/charts/PDF/U0080.pdf C1 Controls and Latin-1 Supplement] 00C0–00D6, 00D8–00F6, 00F8–00FF
	[http://www.unicode.org/charts/PDF/U0100.pdf Latin Extended-A] 0100–017F
	[http://www.unicode.org/charts/PDF/U0180.pdf Latin Extended-B] 0180–01BF, 01C4–024F

|lastn= also allowed to contain hyphens, spaces, and apostrophes.
	(http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
|firstn= also allowed to contain hyphens, spaces, apostrophes, and periods

This original test:
	if nil == mw.ustring.find (last, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%']*$&quot;)
	or nil == mw.ustring.find (first, &quot;^[A-Za-zÀ-ÖØ-öø-ƿǄ-ɏ%-%s%'%.]+[2-6%a]*$&quot;) then
was written outside of the code editor and pasted here because the code editor
gets confused between character insertion point and cursor position. The test has
been rewritten to use decimal character escape sequence for the individual bytes
of the Unicode characters so that it is not necessary to use an external editor
to maintain this code.

	\195\128-\195\150 – À-Ö (U+00C0–U+00D6 – C0 controls)
	\195\152-\195\182 – Ø-ö (U+00D8-U+00F6 – C0 controls)
	\195\184-\198\191 – ø-ƿ (U+00F8-U+01BF – C0 controls, Latin extended A &amp; B)
	\199\132-\201\143 – Ǆ-ɏ (U+01C4-U+024F – Latin extended B)

]]

local function is_good_vanc_name (last, first, suffix, position)
	if not suffix then
		if first:find ('[,%s]') then											-- when there is a space or comma, might be first name/initials + generational suffix
			first = first:match ('(.-)[,%s]+');									-- get name/initials
			suffix = first:match ('[,%s]+(.+)$');								-- get generational suffix
		end
	end
	if utilities.is_set (suffix) then
		if not is_suffix (suffix) then
			add_vanc_error (cfg.err_msg_supl.suffix, position);
			return false;														-- not a name with an appropriate suffix
		end
	end
	if nil == mw.ustring.find (last, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143\225\184\128-\225\187\191%-%s%']*$&quot;) or
		nil == mw.ustring.find (first, &quot;^[A-Za-z\195\128-\195\150\195\152-\195\182\195\184-\198\191\199\132-\201\143\225\184\128-\225\187\191%-%s%'%.]*$&quot;) then
			add_vanc_error (cfg.err_msg_supl['non-Latin char'], position);
			return false;														-- not a string of Latin characters; Vancouver requires Romanization
	end;
	return true;
end


--[[--------------------------&lt; R E D U C E _ T O _ I N I T I A L S &gt;------------------------------------------

Attempts to convert names to initials in support of |name-list-style=vanc.  

Names in |firstn= may be separated by spaces or hyphens, or for initials, a period.
See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35062/.

Vancouver style requires family rank designations (Jr, II, III, etc.) to be rendered
as Jr, 2nd, 3rd, etc.  See http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35085/.
This code only accepts and understands generational suffix in the Vancouver format
because Roman numerals look like, and can be mistaken for, initials.

This function uses ustring functions because firstname initials may be any of the
Unicode Latin characters accepted by is_good_vanc_name ().

]]

local function reduce_to_initials (first, position)
	if first:find (',', 1, true) then
		return first;															-- commas not allowed; abandon
	end

	local name, suffix = mw.ustring.match (first, &quot;^(%u+) ([%dJS][%drndth]+)$&quot;);

	if not name then															-- if not initials and a suffix
		name = mw.ustring.match (first, &quot;^(%u+)$&quot;);								-- is it just initials?
	end

	if name then																-- if first is initials with or without suffix
		if 3 &gt; mw.ustring.len (name) then										-- if one or two initials
			if suffix then														-- if there is a suffix
				if is_suffix (suffix) then										-- is it legitimate?
					return first;												-- one or two initials and a valid suffix so nothing to do
				else
					add_vanc_error (cfg.err_msg_supl.suffix, position);			-- one or two initials with invalid suffix so error message
					return first;												-- and return first unmolested
				end
			else
				return first;													-- one or two initials without suffix; nothing to do
			end
		end
	end																			-- if here then name has 3 or more uppercase letters so treat them as a word

	local initials_t, names_t = {}, {};											-- tables to hold name parts and initials
	local i = 1;																-- counter for number of initials

	names_t = mw.text.split (first, '[%s%-]+');									-- split into a sequence of names and possible suffix

	while names_t[i] do															-- loop through the sequence
		if 1 &lt; i and names_t[i]:match ('[%dJS][%drndth]+%.?$') then				-- if not the first name, and looks like a suffix (may have trailing dot)
			names_t[i] = names_t[i]:gsub ('%.', '');							-- remove terminal dot if present
			if is_suffix (names_t[i]) then										-- if a legitimate suffix
				table.insert (initials_t, ' ' .. names_t[i]);					-- add a separator space, insert at end of initials sequence
				break;															-- and done because suffix must fall at the end of a name
			end																	-- no error message if not a suffix; possibly because of Romanization
		end
		if 3 &gt; i then
			table.insert (initials_t, mw.ustring.sub (names_t[i], 1, 1));		-- insert the initial at end of initials sequence
		end
		i = i + 1;																-- bump the counter
	end
			
	return table.concat (initials_t);											-- Vancouver format does not include spaces.
end


--[[--------------------------&lt; I N T E R W I K I _ P R E F I X E N _ G E T &gt;----------------------------------

extract interwiki prefixen from &lt;value&gt;.  Returns two one or two values:
	false – no prefixen
	nil – prefix exists but not recognized
	project prefix, language prefix – when value has either of:
		:&lt;project&gt;:&lt;language&gt;:&lt;article&gt;
		:&lt;language&gt;:&lt;project&gt;:&lt;article&gt;
	project prefix, nil – when &lt;value&gt; has only a known single-letter prefix
	nil, language prefix – when &lt;value&gt; has only a known language prefix

accepts single-letter project prefixen: 'd' (wikidata), 's' (wikisource), and 'w' (wikipedia) prefixes; at this
writing, the other single-letter prefixen (b (wikibook), c (commons), m (meta), n (wikinews), q (wikiquote), and
v (wikiversity)) are not supported.

]]

local function interwiki_prefixen_get (value, is_link)
	if not value:find (':%l+:') then											-- if no prefix
		return false;															-- abandon; boolean here to distinguish from nil fail returns later
	end

	local prefix_patterns_linked_t = {											-- sequence of valid interwiki and inter project prefixen
		'^%[%[:([dsw]):(%l%l+):',												-- wikilinked; project and language prefixes
		'^%[%[:(%l%l+):([dsw]):',												-- wikilinked; language and project prefixes
		'^%[%[:([dsw]):',														-- wikilinked; project prefix
		'^%[%[:(%l%l+):',														-- wikilinked; language prefix
		}
		
	local prefix_patterns_unlinked_t = {										-- sequence of valid interwiki and inter project prefixen
		'^:([dsw]):(%l%l+):',													-- project and language prefixes
		'^:(%l%l+):([dsw]):',													-- language and project prefixes
		'^:([dsw]):',															-- project prefix
		'^:(%l%l+):',															-- language prefix
		}
	
	local cap1, cap2;
	for _, pattern in ipairs ((is_link and prefix_patterns_linked_t) or prefix_patterns_unlinked_t) do
		cap1, cap2 = value:match (pattern);
		if cap1 then
			break;																-- found a match so stop looking
		end
	end
	
	if cap1 and cap2 then														-- when both then :project:language: or :language:project: (both forms allowed)
		if 1 == #cap1 then														-- length == 1 then :project:language:
			if cfg.inter_wiki_map[cap2] then									-- is language prefix in the interwiki map?
				return cap1, cap2;												-- return interwiki project and interwiki language
			end
		else																	-- here when :language:project:
			if cfg.inter_wiki_map[cap1] then									-- is language prefix in the interwiki map?
				return cap2, cap1;												-- return interwiki project and interwiki language
			end
		end
		return nil;																-- unknown interwiki language
	elseif not (cap1 or cap2) then												-- both are nil?
		return nil;																-- we got something that looks like a project prefix but isn't; return fail
	elseif 1 == #cap1 then														-- here when one capture
		return cap1, nil;														-- length is 1 so return project, nil language
	else																		-- here when one capture and its length it more than 1
		if cfg.inter_wiki_map[cap1] then										-- is language prefix in the interwiki map?
			return nil, cap1;													-- return nil project, language
		end
	end
end


--[[--------------------------&lt; L I S T _ P E O P L E &gt;--------------------------

Formats a list of people (authors, contributors, editors, interviewers, translators) 

names in the list will be linked when
	|&lt;name&gt;-link= has a value
	|&lt;name&gt;-mask- does NOT have a value; masked names are presumed to have been
		rendered previously so should have been linked there

when |&lt;name&gt;-mask=0, the associated name is not rendered

]]

local function list_people (control, people, etal)
	local sep;
	local namesep;
	local format = control.format;
	local maximum = control.maximum;
	local name_list = {};

	if 'vanc' == format then													-- Vancouver-like name styling?
		sep = cfg.presentation['sep_nl_vanc'];									-- name-list separator between names is a comma
		namesep = cfg.presentation['sep_name_vanc'];							-- last/first separator is a space
	else
		sep = cfg.presentation['sep_nl'];										-- name-list separator between names is a semicolon
		namesep = cfg.presentation['sep_name'];									-- last/first separator is &lt;comma&gt;&lt;space&gt;
	end
	
	if sep:sub (-1, -1) ~= &quot; &quot; then sep = sep .. &quot; &quot; end
	if utilities.is_set (maximum) and maximum &lt; 1 then return &quot;&quot;, 0; end		-- returned 0 is for EditorCount; not used for other names
	
	for i, person in ipairs (people) do
		if utilities.is_set (person.last) then
			local mask = person.mask;
			local one;
			local sep_one = sep;

			if utilities.is_set (maximum) and i &gt; maximum then
				etal = true;
				break;
			end
			
			if mask then
				local n = tonumber (mask);										-- convert to a number if it can be converted; nil else
				if n then
					one = 0 ~= n and string.rep(&quot;&amp;mdash;&quot;, n) or nil;			-- make a string of (n &gt; 0) mdashes, nil else, to replace name
					person.link = nil;											-- don't create link to name if name is replaces with mdash string or has been set nil
				else
					one = mask;													-- replace name with mask text (must include name-list separator)
					sep_one = &quot; &quot;;												-- modify name-list separator
				end
			else
				one = person.last;												-- get surname
				local first = person.first										-- get given name
				if utilities.is_set (first) then
					if (&quot;vanc&quot; == format) then									-- if Vancouver format
						one = one:gsub ('%.', '');								-- remove periods from surnames (http://www.ncbi.nlm.nih.gov/books/NBK7271/box/A35029/)
						if not person.corporate and is_good_vanc_name (one, first, nil, i) then		-- and name is all Latin characters; corporate authors not tested
							first = reduce_to_initials (first, i);				-- attempt to convert first name(s) to initials
						end
					end
					one = one .. namesep .. first;
				end
			end
			if utilities.is_set (person.link) then
				one = utilities.make_wikilink (person.link, one);				-- link author/editor
			end

			if one then															-- if &lt;one&gt; has a value (name, mdash replacement, or mask text replacement)
				local proj, tag = interwiki_prefixen_get (one, true);			-- get the interwiki prefixen if present
				if 'w' == proj and ('Wikipedia' == mw.site.namespaces.Project['name']) then
					proj = nil;													-- for stuff like :w:de:&lt;article&gt;, :w is unnecessary TODO: maint cat?
				end
				if proj then
					local proj_name = ({['d'] = 'Wikidata', ['s'] = 'Wikisource', ['w'] = 'Wikipedia'})[proj];	-- :w (wikipedia) for linking from a non-wikipedia project
					if proj_name then 
						one = one .. utilities.wrap_style ('interproj', proj_name);	-- add resized leading space, brackets, static text, language name
						utilities.add_prop_cat ('interproj-linked-name', proj);	-- categorize it; &lt;proj&gt; is sort key
						tag = nil;												-- unset; don't do both project and language
					end
				end
				if tag == cfg.this_wiki_code then
					tag = nil;													-- stuff like :en:&lt;article&gt; at en.wiki is pointless TODO: maint cat?
				end
				if tag then
					local lang = cfg.lang_tag_remap[tag] or cfg.mw_languages_by_tag_t[tag];
					if lang then												-- error messaging done in extract_names() where we know parameter names
						one = one .. utilities.wrap_style ('interwiki', lang);	-- add resized leading space, brackets, static text, language name
						utilities.add_prop_cat ('interwiki-linked-name', tag);	-- categorize it; &lt;tag&gt; is sort key
					end
				end

				table.insert (name_list, one);									-- add it to the list of names
				table.insert (name_list, sep_one);								-- add the proper name-list separator
			end
		end
	end

	local count = #name_list / 2;												-- (number of names + number of separators) divided by 2
	if 0 &lt; count then 
		if 1 &lt; count and not etal then
			if 'amp' == format then
				name_list[#name_list-2] = &quot; &amp; &quot;;								-- replace last separator with ampersand text
			elseif 'and' == format then
				if 2 == count then
					name_list[#name_list-2] = cfg.presentation.sep_nl_and;		-- replace last separator with 'and' text
				else
					name_list[#name_list-2] = cfg.presentation.sep_nl_end;		-- replace last separator with '(sep) and' text
				end
			end
		end
		name_list[#name_list] = nil;											-- erase the last separator
	end

	local result = table.concat (name_list);									-- construct list
	if etal and utilities.is_set (result) then									-- etal may be set by |display-authors=etal but we might not have a last-first list
		result = result .. sep .. cfg.messages['et al'];						-- we've got a last-first list and etal so add et al.
	end
	
	return result, count;														-- return name-list string and count of number of names (count used for editor names only)
end


--[[--------------------&lt; M A K E _ C I T E R E F _ I D &gt;-----------------------

Generates a CITEREF anchor ID if we have at least one name or a date.  Otherwise
returns an empty string.

namelist is one of the contributor-, author-, or editor-name lists chosen in that
order.  year is Year or anchor_year.

]]

local function make_citeref_id (namelist, year)
	local names={};							-- a table for the one to four names and year
	for i,v in ipairs (namelist) do			-- loop through the list and take up to the first four last names
		names[i] = v.last
		if i == 4 then break end			-- if four then done
	end
	table.insert (names, year);				-- add the year at the end
	local id = table.concat(names);			-- concatenate names and year for CITEREF id
	if utilities.is_set (id) then			-- if concatenation is not an empty string
		return &quot;CITEREF&quot; .. id;				-- add the CITEREF portion
	else
		return '';							-- return an empty string; no reason to include CITEREF id in this citation
	end
end


--[[--------------------------&lt; C I T E _ C L A S S _A T T R I B U T E _M A K E &gt;------------------------------

construct &lt;cite&gt; tag class attribute for this citation.

&lt;cite_class&gt; – config.CitationClass from calling template
&lt;mode&gt; – value from |mode= parameter

]]

local function cite_class_attribute_make (cite_class, mode)
	local class_t = {};
	table.insert (class_t, 'citation');											-- required for blue highlight
	if 'citation' ~= cite_class then
		table.insert (class_t, cite_class);										-- identify this template for user css
		table.insert (class_t, utilities.is_set (mode) and mode or 'cs1');		-- identify the citation style for user css or javascript
	else
		table.insert (class_t, utilities.is_set (mode) and mode or 'cs2');		-- identify the citation style for user css or javascript
	end
	for _, prop_key in ipairs (z.prop_keys_t) do
		table.insert (class_t, prop_key);										-- identify various properties for user css or javascript
	end

	return table.concat (class_t, ' ');											-- make a big string and done
end


--[[---------------------&lt; N A M E _ H A S _ E T A L &gt;--------------------------

Evaluates the content of name parameters (author, editor, etc.) for variations on
the theme of et al.  If found, the et al. is removed, a flag is set to true and
the function returns the modified name and the flag.

This function never sets the flag to false but returns its previous state because
it may have been set by previous passes through this function or by the associated
|display-&lt;names&gt;=etal parameter

]]

local function name_has_etal (name, etal, nocat, param)

	if utilities.is_set (name) then												-- name can be nil in which case just return
		local patterns = cfg.et_al_patterns; 									-- get patterns from configuration
		
		for _, pattern in ipairs (patterns) do									-- loop through all of the patterns
			if name:match (pattern) then										-- if this 'et al' pattern is found in name
				name = name:gsub (pattern, '');									-- remove the offending text
				etal = true;													-- set flag (may have been set previously here or by |display-&lt;names&gt;=etal)
				if not nocat then												-- no categorization for |vauthors=
					utilities.set_message ('err_etal', {param});				-- and set an error if not added
				end
			end
		end
	end

	return name, etal;
end


--[[---------------------&lt; N A M E _ I S _ N U M E R I C &gt;----------------------

Add an error message and category when &lt;name&gt; parameter value does not contain letters.  

Add a maintenance category when &lt;name&gt; parameter value has numeric characters mixed with characters that are 
not numeric characters; could be letters and/or punctuation characters.

This function will only emit one error and one maint message for the current template.  Does not emit both error
and maint messages/categories for the same parameter value.

returns nothing

]]

local function name_is_numeric (name, name_alias, list_name)
	local patterns = {
		'^%D+%d',																-- &lt;name&gt; must have digits preceded by other characters
		'^%D*%d+%D+',															-- &lt;name&gt; must have digits followed by other characters
		}

	if not added_numeric_name_errs and mw.ustring.match (name, '^[%A]+$') then	-- if we have not already set an error message and &lt;name&gt; does not have any alpha characters
		utilities.set_message ('err_numeric_names', name_alias);				-- add an error message
		added_numeric_name_errs = true;											-- set the flag so we emit only one error message
		return;																	-- when here no point in further testing; abandon
	end

	if not added_numeric_name_maint then										-- if we have already set a maint message
		for _, pattern in ipairs (patterns) do									-- spin through list of patterns
			if mw.ustring.match (name, pattern) then							-- digits preceded or followed by anything but digits; %D+ includes punctuation
				utilities.set_message ('maint_numeric_names', cfg.special_case_translation [list_name]);	-- add a maint cat for this template
				added_numeric_name_maint = true;								-- set the flag so we emit only one maint message
				return;															-- when here no point in further testing; abandon
			end
		end
	end
end


--[[-----------------&lt; N A M E _ H A S _ M U L T _ N A M E S &gt;------------------

Evaluates the content of last/surname (authors etc.) parameters for multiple names.
Multiple names are indicated if there is more than one comma or any &quot;unescaped&quot;
semicolons. Escaped semicolons are ones used as part of selected HTML entities.
If the condition is met, the function adds the multiple name maintenance category.

Same test for first except that commas should not appear in given names (MOS:JR says
that the generational suffix does not take a separator character).  Titles, degrees,
postnominals, affiliations, all normally comma separated don't belong in a citation.

&lt;name&gt; – name parameter value
&lt;list_name&gt; – AuthorList, EditorList, etc
&lt;limit&gt; – number of allowed commas; 1 (default) for surnames; 0 for given names

returns nothing

]]

local function name_has_mult_names (name, list_name, limit)
	local _, commas, semicolons, nbsps;
	limit = limit and limit or 1;
	if utilities.is_set (name) then
		_, commas = name:gsub (',', '');										-- count the number of commas
		_, semicolons = name:gsub (';', '');									-- count the number of semicolons
		-- nbsps probably should be its own separate count rather than merged in
		-- some way with semicolons because Lua patterns do not support the
		-- grouping operator that regex does, which means there is no way to add
		-- more entities to escape except by adding more counts with the new
		-- entities
		_, nbsps = name:gsub ('&amp;nbsp;','');										-- count nbsps
		
		-- There is exactly 1 semicolon per &amp;nbsp; entity, so subtract nbsps
		-- from semicolons to 'escape' them. If additional entities are added,
		-- they also can be subtracted.
		if limit &lt; commas or 0 &lt; (semicolons - nbsps) then
			utilities.set_message ('maint_mult_names', cfg.special_case_translation [list_name]);	-- add a maint message
		end
	end
end


--[=[-------------------------&lt; I S _ G E N E R I C &gt;----------------------------------------------------------

Compares values assigned to various parameters according to the string provided as &lt;item&gt; in the function call.
&lt;item&gt; can have on of two values:
	'generic_names' – for name-holding parameters: |last=, |first=, |editor-last=, etc
	'generic_titles' – for |title=

There are two types of generic tests.  The 'accept' tests look for a pattern that should not be rejected by the
'reject' test.  For example,
	|author=[[John Smith (author)|Smith, John]]
would be rejected by the 'author' reject test.  But piped wikilinks with 'author' disambiguation should not be
rejected so the 'accept' test prevents that from happening.  Accept tests are always performed before reject
tests.

Each of the 'accept' and 'reject' sequence tables hold tables for en.wiki (['en']) and local.wiki (['local'])
that each can hold a test sequence table  The sequence table holds, at index [1], a test pattern, and, at index
[2], a boolean control value.  The control value tells string.find() or mw.ustring.find() to do plain-text search (true)
or a pattern search (false).  The intent of all this complexity is to make these searches as fast as possible so
that we don't run out of processing time on very large articles.

Returns
	true when a reject test finds the pattern or string
	false when an accept test finds the pattern or string
	nil else

]=]

local function is_generic (item, value, wiki)
	local test_val;
	local str_lower = {															-- use string.lower() for en.wiki (['en']) and use mw.ustring.lower() or local.wiki (['local'])
		['en'] = string.lower,
		['local'] = mw.ustring.lower,
		}
	local str_find = {															-- use string.find() for en.wiki (['en']) and use mw.ustring.find() or local.wiki (['local'])
		['en'] = string.find,
		['local'] = mw.ustring.find,
		}

	local function test (val, test_t, wiki)										-- local function to do the testing; &lt;wiki&gt; selects lower() and find() functions
		val = test_t[2] and str_lower[wiki](value) or val;						-- when &lt;test_t[2]&gt; set to 'true', plaintext search using lowercase value
		return str_find[wiki] (val, test_t[1], 1, test_t[2]);					-- return nil when not found or matched
	end
		
	local test_types_t = {'accept', 'reject'};									-- test accept patterns first, then reject patterns
	local wikis_t = {'en', 'local'};											-- do tests for each of these keys; en.wiki first, local.wiki second

	for _, test_type in ipairs (test_types_t) do								-- for each test type
		for _, generic_value in pairs (cfg.special_case_translation[item][test_type]) do	-- spin through the list of generic value fragments to accept or reject
			for _, wiki in ipairs (wikis_t) do
				if generic_value[wiki] then
					if test (value, generic_value[wiki], wiki) then				-- go do the test
						return ('reject' == test_type);							-- param value rejected, return true; false else
					end
				end
			end
		end
	end
end


--[[--------------------------&lt; N A M E _ I S _ G E N E R I C &gt;------------------------------------------------

calls is_generic() to determine if &lt;name&gt; is a 'generic name' listed in cfg.generic_names; &lt;name_alias&gt; is the
parameter name used in error messaging

]]

local function name_is_generic (name, name_alias)
	if not added_generic_name_errs  and is_generic ('generic_names', name) then
		utilities.set_message ('err_generic_name', name_alias);					-- set an error message
		added_generic_name_errs = true;
	end
end


--[[--------------------------&lt; N A M E _ C H E C K S &gt;--------------------------------------------------------

This function calls various name checking functions used to validate the content of the various name-holding parameters.

]]

local function name_checks (last, first, list_name, last_alias, first_alias)
	local accept_name;

	if utilities.is_set (last) then
		last, accept_name = utilities.has_accept_as_written (last);				-- remove accept-this-as-written markup when it wraps all of &lt;last&gt;

		if not accept_name then													-- &lt;last&gt; not wrapped in accept-as-written markup
			name_has_mult_names (last, list_name);								-- check for multiple names in the parameter
			name_is_numeric (last, last_alias, list_name);						-- check for names that have no letters or are a mix of digits and other characters
			name_is_generic (last, last_alias);									-- check for names found in the generic names list
		end
	end

	if utilities.is_set (first) then
		first, accept_name = utilities.has_accept_as_written (first);			-- remove accept-this-as-written markup when it wraps all of &lt;first&gt;

		if not accept_name then													-- &lt;first&gt; not wrapped in accept-as-written markup
			name_has_mult_names (first, list_name, 0);							-- check for multiple names in the parameter; 0 is number of allowed commas in a given name
			name_is_numeric (first, first_alias, list_name);					-- check for names that have no letters or are a mix of digits and other characters
			name_is_generic (first, first_alias);								-- check for names found in the generic names list
		end
		local wl_type, D = utilities.is_wikilink (first);
		if 0 ~= wl_type then
			first = D;
			utilities.set_message ('err_bad_paramlink', first_alias);
		end
	end

	return last, first;															-- done
end


--[[----------------------&lt; E X T R A C T _ N A M E S &gt;-------------------------

Gets name list from the input arguments

Searches through args in sequential order to find |lastn= and |firstn= parameters
(or their aliases), and their matching link and mask parameters. Stops searching
when both |lastn= and |firstn= are not found in args after two sequential attempts:
found |last1=, |last2=, and |last3= but doesn't find |last4= and |last5= then the
search is done.

This function emits an error message when there is a |firstn= without a matching
|lastn=.  When there are 'holes' in the list of last names, |last1= and |last3=
are present but |last2= is missing, an error message is emitted. |lastn= is not
required to have a matching |firstn=.

When an author or editor parameter contains some form of 'et al.', the 'et al.'
is stripped from the parameter and a flag (etal) returned that will cause list_people()
to add the static 'et al.' text from Module:Citation/CS1/Configuration.  This keeps
'et al.' out of the template's metadata.  When this occurs, an error is emitted.

]]

local function extract_names(args, list_name)
	local names = {};															-- table of names
	local last;																	-- individual name components
	local first;
	local link;
	local mask;
	local i = 1;																-- loop counter/indexer
	local n = 1;																-- output table indexer
	local count = 0;															-- used to count the number of times we haven't found a |last= (or alias for authors, |editor-last or alias for editors)
	local etal = false;															-- return value set to true when we find some form of et al. in an author parameter

	local last_alias, first_alias, link_alias;									-- selected parameter aliases used in error messaging
	while true do
		last, last_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'err_redundant_parameters', i );		-- search through args for name components beginning at 1
		first, first_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'err_redundant_parameters', i );
		link, link_alias = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i );
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
	
		if last then															-- error check |lastn= alias for unknown interwiki link prefix; done here because this is where we have the parameter name
			local project, language = interwiki_prefixen_get (last, true);		-- true because we expect interwiki links in |lastn= to be wikilinked
			if nil == project and nil == language then							-- when both are nil
				utilities.set_message ('err_bad_paramlink', last_alias);		-- not known, emit an error message	-- TODO: err_bad_interwiki?
				last = utilities.remove_wiki_link (last);						-- remove wikilink markup; show display value only
			end
		end
		
		if link then															-- error check |linkn= alias for unknown interwiki link prefix
			local project, language = interwiki_prefixen_get (link, false);		-- false because wiki links in |author-linkn= is an error
			if nil == project and nil == language then							-- when both are nil
				utilities.set_message ('err_bad_paramlink', link_alias);		-- not known, emit an error message	-- TODO: err_bad_interwiki?
				link = nil;														-- unset so we don't link
				link_alias = nil;
			end
		end
		
		last, etal = name_has_etal (last, etal, false, last_alias);				-- find and remove variations on et al.
		first, etal = name_has_etal (first, etal, false, first_alias);			-- find and remove variations on et al.
		last, first = name_checks (last, first, list_name, last_alias, first_alias);						-- multiple names, extraneous annotation, etc. checks

		if first and not last then												-- if there is a firstn without a matching lastn
			local alias = first_alias:find ('given', 1, true) and 'given' or 'first';	-- get first or given form of the alias
			utilities.set_message ('err_first_missing_last', {
				first_alias,													-- param name of alias missing its mate
				first_alias:gsub (alias, {['first'] = 'last', ['given'] = 'surname'}),	-- make param name appropriate to the alias form
				});																-- add this error message
		elseif not first and not last then										-- if both firstn and lastn aren't found, are we done?
			count = count + 1;													-- number of times we haven't found last and first
			if 2 &lt;= count then													-- two missing names and we give up
				break;															-- normal exit or there is a two-name hole in the list; can't tell which
			end
		else																	-- we have last with or without a first
			local result;
			link = link_title_ok (link, link_alias, last, last_alias);			-- check for improper wiki-markup

			if first then
				link = link_title_ok (link, link_alias, first, first_alias);	-- check for improper wiki-markup
			end

			names[n] = {last = last, first = first, link = link, mask = mask, corporate = false};	-- add this name to our names list (corporate for |vauthors= only)
			n = n + 1;															-- point to next location in the names table
			if 1 == count then													-- if the previous name was missing
				utilities.set_message ('err_missing_name', {list_name:match (&quot;(%w+)List&quot;):lower(), i - 1});	-- add this error message
			end
			count = 0;															-- reset the counter, we're looking for two consecutive missing names
		end
		i = i + 1;																-- point to next args location
	end
	
	return names, etal;															-- all done, return our list of names and the etal flag
end


--[[--------------------------&lt; N A M E _ T A G _ G E T &gt;------------------------------------------------------

attempt to decode |language=&lt;lang_param&gt; and return language name and matching tag; nil else.

This function looks for:
	&lt;lang_param&gt; as a tag in cfg.lang_tag_remap{}
	&lt;lang_param&gt; as a name in cfg.lang_name_remap{}
	
	&lt;lang_param&gt; as a name in cfg.mw_languages_by_name_t
	&lt;lang_param&gt; as a tag in cfg.mw_languages_by_tag_t
when those fail, presume that &lt;lang_param&gt; is an IETF-like tag that MediaWiki does not recognize.  Strip all
script, region, variant, whatever subtags from &lt;lang_param&gt; to leave just a two or three character language tag
and look for the new &lt;lang_param&gt; in cfg.mw_languages_by_tag_t{}

on success, returns name (in properly capitalized form) and matching tag (in lowercase); on failure returns nil

]]

local function name_tag_get (lang_param)
	local lang_param_lc = mw.ustring.lower (lang_param);						-- use lowercase as an index into the various tables
	local name;
	local tag;

	name = cfg.lang_tag_remap[lang_param_lc];									-- assume &lt;lang_param_lc&gt; is a tag; attempt to get remapped language name 
	if name then																-- when &lt;name&gt;, &lt;lang_param&gt; is a tag for a remapped language name
		if cfg.lang_name_remap[name:lower()][2] ~= lang_param_lc then
			utilities.set_message ('maint_unknown_lang');						-- add maint category if not already added
			return name, cfg.lang_name_remap[name:lower()][2];					-- so return name and tag from lang_name_remap[name]; special case to xlate sr-ec and sr-el to sr-cyrl and sr-latn
		end
		return name, lang_param_lc;												-- so return &lt;name&gt; from remap and &lt;lang_param_lc&gt;
	end

	tag = lang_param_lc:match ('^(%a%a%a?)%-.*');								-- still assuming that &lt;lang_param_lc&gt; is a tag; strip script, region, variant subtags
	name = cfg.lang_tag_remap[tag];												-- attempt to get remapped language name with language subtag only
	if name then																-- when &lt;name&gt;, &lt;tag&gt; is a tag for a remapped language name
		return name, tag;														-- so return &lt;name&gt; from remap and &lt;tag&gt;
	end

	if cfg.lang_name_remap[lang_param_lc] then									-- not a remapped tag, assume &lt;lang_param_lc&gt; is a name; attempt to get remapped language tag 
		return cfg.lang_name_remap[lang_param_lc][1], cfg.lang_name_remap[lang_param_lc][2];	-- for this &lt;lang_param_lc&gt;, return a (possibly) new name and appropriate tag
	end

	name = cfg.mw_languages_by_tag_t[lang_param_lc];							-- assume that &lt;lang_param_lc&gt; is a tag; attempt to get its matching language name
	
	if name then
		return name, lang_param_lc;												-- &lt;lang_param_lc&gt; is a tag so return it and &lt;name&gt;
	end
	
	tag = cfg.mw_languages_by_name_t[lang_param_lc];							-- assume that &lt;lang_param_lc&gt; is a language name; attempt to get its matching tag
	
	if tag then
		return cfg.mw_languages_by_tag_t[tag], tag;								-- &lt;lang_param_lc&gt; is a name so return the name from the table and &lt;tag&gt;
	end

	tag = lang_param_lc:match ('^(%a%a%a?)%-.*');								-- is &lt;lang_param_lc&gt; an IETF-like tag that MediaWiki doesn't recognize? &lt;tag&gt; gets the language subtag; nil else

	if tag then
		name = cfg.mw_languages_by_tag_t[tag];									-- attempt to get a language name using the shortened &lt;tag&gt;
		if name then
			return name, tag;													-- &lt;lang_param_lc&gt; is an unrecognized IETF-like tag so return &lt;name&gt; and language subtag
		end
	end
end


--[[-------------------&lt; L A N G U A G E _ P A R A M E T E R &gt;------------------

Gets language name from a provided two- or three-character ISO 639 code.  If a code
is recognized by MediaWiki, use the returned name; if not, then use the value that
was provided with the language parameter.

When |language= contains a recognized language (either code or name), the page is
assigned to the category for that code: Category:Norwegian-language sources (no).
For valid three-character code languages, the page is assigned to the single category
for '639-2' codes: Category:CS1 ISO 639-2 language sources.

Languages that are the same as the local wiki are not categorized.  MediaWiki does
not recognize three-character equivalents of two-character codes: code 'ar' is
recognized but code 'ara' is not.

This function supports multiple languages in the form |language=nb, French, th
where the language names or codes are separated from each other by commas with
optional space characters.

]]

local function language_parameter (lang)
	local tag;																	-- some form of IETF-like language tag; language subtag with optional region, sript, vatiant, etc subtags
	local lang_subtag;															-- ve populates |language= with mostly unecessary region subtags the MediaWiki does not recognize; this is the base language subtag
	local name;																	-- the language name
	local language_list = {};													-- table of language names to be rendered
	local names_t = {};															-- table made from the value assigned to |language=

	local this_wiki_name = mw.language.fetchLanguageName (cfg.this_wiki_code, cfg.this_wiki_code);	-- get this wiki's language name

	names_t = mw.text.split (lang, '%s*,%s*');									-- names should be a comma separated list

	for _, lang in ipairs (names_t) do											-- reuse lang here because we don't yet know if lang is a language name or a language tag
		name, tag = name_tag_get (lang);										-- attempt to get name/tag pair for &lt;lang&gt;; &lt;name&gt; has proper capitalization; &lt;tag&gt; is lowercase

		if utilities.is_set (tag) then
			lang_subtag = tag:gsub ('^(%a%a%a?)%-.*', '%1');					-- for categorization, strip any IETF-like tags from language tag

			if cfg.this_wiki_code ~= lang_subtag then							-- when the language is not the same as this wiki's language
				if 2 == lang_subtag:len() then									-- and is a two-character tag
					utilities.add_prop_cat ('foreign-lang-source', {name, tag}, lang_subtag);		-- categorize it; tag appended to allow for multiple language categorization
				else															-- or is a recognized language (but has a three-character tag)
					utilities.add_prop_cat ('foreign-lang-source-2', {lang_subtag}, lang_subtag);			-- categorize it differently TODO: support multiple three-character tag categories per cs1|2 template?
				end
			elseif cfg.local_lang_cat_enable then								-- when the language and this wiki's language are the same and categorization is enabled
				utilities.add_prop_cat ('local-lang-source', {name, lang_subtag});		-- categorize it
			end
		else
			name = lang;														-- return whatever &lt;lang&gt; has so that we show something
			utilities.set_message ('maint_unknown_lang');						-- add maint category if not already added
		end
		
		table.insert (language_list, name);
		name = '';																-- so we can reuse it
	end
 
	name = utilities.make_sep_list (#language_list, language_list);
	if (1 == #language_list) and (lang_subtag == cfg.this_wiki_code) then		-- when only one language, find lang name in this wiki lang name; for |language=en-us, 'English' in 'American English'
		return '';																-- if one language and that language is this wiki's return an empty string (no annotation)
	end
	return (&quot; &quot; .. wrap_msg ('language', name));								-- otherwise wrap with '(in ...)'
	--[[ TODO: should only return blank or name rather than full list
	so we can clean up the bunched parenthetical elements Language, Type, Format
	]]
end


--[[-----------------------&lt; S E T _ C S _ S T Y L E &gt;--------------------------

Gets the default CS style configuration for the given mode.
Returns default separator and either postscript as passed in or the default.
In CS1, the default postscript and separator are '.'.
In CS2, the default postscript is the empty string and the default separator is ','.

]]

local function set_cs_style (postscript, mode)
	if utilities.is_set(postscript) then
		-- emit a maintenance message if user postscript is the default cs1 postscript
		-- we catch the opposite case for cs2 in set_style
		if mode == 'cs1' and postscript == cfg.presentation['ps_' .. mode] then
			utilities.set_message ('maint_postscript');
		end
	else
		postscript = cfg.presentation['ps_' .. mode];
	end
	return cfg.presentation['sep_' .. mode], postscript;
end


--[[--------------------------&lt; S E T _ S T Y L E &gt;-----------------------------

Sets the separator and postscript styles. Checks the |mode= first and the
#invoke CitationClass second. Removes the postscript if postscript == none.

]]

local function set_style (mode, postscript, cite_class)
	local sep;
	if 'cs2' == mode then
		sep, postscript = set_cs_style (postscript, 'cs2');
	elseif 'cs1' == mode then
		sep, postscript = set_cs_style (postscript, 'cs1');
	elseif 'citation' == cite_class	then
		sep, postscript = set_cs_style (postscript, 'cs2');
	else
		sep, postscript = set_cs_style (postscript, 'cs1');
	end

	if cfg.keywords_xlate[postscript:lower()] == 'none' then
		-- emit a maintenance message if user postscript is the default cs2 postscript
		-- we catch the opposite case for cs1 in set_cs_style
		if 'cs2' == mode or ('cs1' ~= mode and 'citation' == cite_class) then	-- {{citation |title=Title |mode=cs1 |postscript=none}} should not emit maint message
			utilities.set_message ('maint_postscript');
		end
		postscript = '';
	end
	
	return sep, postscript
end


--[=[-------------------------&lt; I S _ P D F &gt;-----------------------------------

Determines if a URL has the file extension that is one of the PDF file extensions
used by [[MediaWiki:Common.css]] when applying the PDF icon to external links.

returns true if file extension is one of the recognized extensions, else false

]=]

local function is_pdf (url)
	return url:match ('%.pdf$') or url:match ('%.PDF$') or
		url:match ('%.pdf[%?#]') or url:match ('%.PDF[%?#]') or
		url:match ('%.PDF&amp;#035') or url:match ('%.pdf&amp;#035');
end


--[[--------------------------&lt; S T Y L E _ F O R M A T &gt;-----------------------

Applies CSS style to |format=, |chapter-format=, etc.  Also emits an error message
if the format parameter does not have a matching URL parameter.  If the format parameter
is not set and the URL contains a file extension that is recognized as a PDF document
by MediaWiki's commons.css, this code will set the format parameter to (PDF) with
the appropriate styling.

]]

local function style_format (format, url, fmt_param, url_param)
	if utilities.is_set (format) then
		format = utilities.wrap_style ('format', format);						-- add leading space, parentheses, resize
		if not utilities.is_set (url) then
			utilities.set_message ('err_format_missing_url', {fmt_param, url_param});	-- add an error message
		end
	elseif is_pdf (url) then													-- format is not set so if URL is a PDF file then
		format = utilities.wrap_style ('format', 'PDF');						-- set format to PDF
	else
		format = '';															-- empty string for concatenation
	end
	return format;
end


--[[---------------------&lt; G E T _ D I S P L A Y _ N A M E S &gt;------------------

Returns a number that defines the number of names displayed for author and editor
name lists and a Boolean flag to indicate when et al. should be appended to the name list.

When the value assigned to |display-xxxxors= is a number greater than or equal to zero,
return the number and the previous state of the 'etal' flag (false by default
but may have been set to true if the name list contains some variant of the text 'et al.').

When the value assigned to |display-xxxxors= is the keyword 'etal', return a number
that is one greater than the number of authors in the list and set the 'etal' flag true.
This will cause the list_people() to display all of the names in the name list followed by 'et al.'

In all other cases, returns nil and the previous state of the 'etal' flag.

inputs:
	max: A['DisplayAuthors'] or A['DisplayEditors'], etc; a number or some flavor of etal
	count: #a or #e
	list_name: 'authors' or 'editors'
	etal: author_etal or editor_etal

This function sets an error message when |display-xxxxors= value greater than or equal to number of names but
not when &lt;max&gt; comes from {{cs1 config}} global settings.  When using global settings, &lt;param&gt; is set to the
keyword 'cs1 config' which is used to supress the normal error.  Error is suppressed because it is to be expected
that some citations in an article will have the same or fewer names that the limit specified in {{cs1 config}}.

]]

local function get_display_names (max, count, list_name, etal, param)
	if utilities.is_set (max) then
		if 'etal' == max:lower():gsub(&quot;[ '%.]&quot;, '') then						-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			max = count + 1;													-- number of authors + 1 so display all author name plus et al.
			etal = true;														-- overrides value set by extract_names()
		elseif max:match ('^%d+$') then											-- if is a string of numbers
			max = tonumber (max);												-- make it a number
			if (max &gt;= count) and ('cs1 config' ~= param) then					-- error when local |display-xxxxors= value greater than or equal to number of names; not an error when using global setting
				utilities.set_message ('err_disp_name', {param, max});			-- add error message
				max = nil;
			end
		else																	-- not a valid keyword or number
			utilities.set_message ('err_disp_name', {param, max});				-- add error message
			max = nil;															-- unset; as if |display-xxxxors= had not been set
		end
	end
	
	return max, etal;
end


--[[----------&lt; E X T R A _ T E X T _ I N _ P A G E _ C H E C K &gt;---------------

Adds error if |page=, |pages=, |quote-page=, |quote-pages= has what appears to be
some form of p. or pp. abbreviation in the first characters of the parameter content.

check page for extraneous p, p., pp, pp., pg, pg. at start of parameter value:
	good pattern: '^P[^%.P%l]' matches when page begins PX or P# but not Px
		      where x and X are letters and # is a digit
	bad pattern:  '^[Pp][PpGg]' matches when page begins pp, pP, Pp, PP, pg, pG, Pg, PG

]]

local function extra_text_in_page_check (val, name)
	if not val:match (cfg.vol_iss_pg_patterns.good_ppattern) then
		for _, pattern in ipairs (cfg.vol_iss_pg_patterns.bad_ppatterns) do		-- spin through the selected sequence table of patterns
			if val:match (pattern) then											-- when a match, error so
				utilities.set_message ('err_extra_text_pages', name);	 		-- add error message
				return;															-- and done
			end
		end
	end		
end


--[[--------------------------&lt; E X T R A _ T E X T _ I N _ V O L _ I S S _ C H E C K &gt;------------------------

Adds error if |volume= or |issue= has what appears to be some form of redundant 'type' indicator.  Applies to
both; this function looks for issue text in both |issue= and |volume= and looks for volume-like text in |voluem=
and |issue=.

For |volume=:
	'V.', or 'Vol.' (with or without the dot) abbreviations or 'Volume' in the first characters of the parameter
	content (all case insensitive). 'V' and 'v' (without the dot) are presumed to be roman numerals so
	are allowed.

For |issue=:
	'No.', 'I.', 'Iss.' (with or without the dot) abbreviations, or 'Issue' in the first characters of the
	parameter content (all case insensitive); numero styling: 'n°' with degree sign U+00B0, and № precomposed
	numero sign U+2116.
	
Single character values ('v', 'i', 'n') allowed when not followed by separator character ('.', ':', '=', or
whitespace character) – param values are trimmed of whitespace by MediaWiki before delivered to the module.
	
&lt;val&gt; is |volume= or |issue= parameter value
&lt;name&gt; is |volume= or |issue= parameter name for error message
&lt;selector&gt; is 'v' for |volume=, 'i' for |issue=

sets error message on failure; returns nothing

]]

local function extra_text_in_vol_iss_check (val, name, selector)
	if not utilities.is_set (val) then
		return;
	end
	
	local handler = 'v' == selector and 'err_extra_text_volume' or 'err_extra_text_issue';
	val = val:lower();															-- force parameter value to lower case

	for _, pattern in ipairs (cfg.vol_iss_pg_patterns.vi_patterns_t) do			-- spin through the sequence table of patterns
		if val:match (pattern) then												-- when a match, error so
			utilities.set_message (handler, name);								-- add error message
			return;																-- and done
		end
	end
end


--[=[-------------------------&lt; G E T _ V _ N A M E _ T A B L E &gt;----------------------------------------------

split apart a |vauthors= or |veditors= parameter.  This function allows for corporate names, wrapped in doubled
parentheses to also have commas; in the old version of the code, the doubled parentheses were included in the
rendered citation and in the metadata.  Individual author names may be wikilinked

	|vauthors=Jones AB, [[E. B. White|White EB]], ((Black, Brown, and Co.))

]=]

local function get_v_name_table (vparam, output_table, output_link_table)
	local _, accept = utilities.has_accept_as_written (vparam);
	if accept then
		utilities.add_prop_cat ('vanc-accept');									-- add properties category
	end
	local name_table = mw.text.split(vparam, &quot;%s*,%s*&quot;);						-- names are separated by commas
	local wl_type, label, link;													-- wl_type not used here; just a placeholder
	
	local i = 1;
	
	while name_table[i] do
		if name_table[i]:match ('^%(%(.*[^%)][^%)]$') then						-- first segment of corporate with one or more commas; this segment has the opening doubled parentheses
			local name = name_table[i];
			i = i + 1;															-- bump indexer to next segment
			while name_table[i] do
				name = name .. ', ' .. name_table[i];							-- concatenate with previous segments
				if name_table[i]:match ('^.*%)%)$') then						-- if this table member has the closing doubled parentheses
					break;														-- and done reassembling so
				end
				i = i + 1;														-- bump indexer
			end
			table.insert (output_table, name);									-- and add corporate name to the output table
			table.insert (output_link_table, '');								-- no wikilink
		else
			wl_type, label, link = utilities.is_wikilink (name_table[i]);		-- wl_type is: 0, no wl (text in label variable); 1, [[D]]; 2, [[L|D]]
			table.insert (output_table, label);									-- add this name
			if 1 == wl_type then
				table.insert (output_link_table, label);						-- simple wikilink [[D]]
			else
				table.insert (output_link_table, link);							-- no wikilink or [[L|D]]; add this link if there is one, else empty string
			end
		end
		i = i + 1;
	end	
	return output_table;
end


--[[--------------------------&lt; P A R S E _ V A U T H O R S _ V E D I T O R S &gt;--------------------------------

This function extracts author / editor names from |vauthors= or |veditors= and finds matching |xxxxor-maskn= and
|xxxxor-linkn= in args.  It then returns a table of assembled names just as extract_names() does.

Author / editor names in |vauthors= or |veditors= must be in Vancouver system style. Corporate or institutional names
may sometimes be required and because such names will often fail the is_good_vanc_name() and other format compliance
tests, are wrapped in doubled parentheses ((corporate name)) to suppress the format tests.

Supports generational suffixes Jr, 2nd, 3rd, 4th–6th.

This function sets the Vancouver error when a required comma is missing and when there is a space between an author's initials.

]]

local function parse_vauthors_veditors (args, vparam, list_name)
	local names = {};															-- table of names assembled from |vauthors=, |author-maskn=, |author-linkn=
	local v_name_table = {};
	local v_link_table = {};													-- when name is wikilinked, targets go in this table
	local etal = false;															-- return value set to true when we find some form of et al. vauthors parameter
	local last, first, link, mask, suffix;
	local corporate = false;

	vparam, etal = name_has_etal (vparam, etal, true);							-- find and remove variations on et al. do not categorize (do it here because et al. might have a period)
	v_name_table = get_v_name_table (vparam, v_name_table, v_link_table);		-- names are separated by commas

	for i, v_name in ipairs(v_name_table) do
		first = '';																-- set to empty string for concatenation and because it may have been set for previous author/editor
		local accept_name;
		v_name, accept_name = utilities.has_accept_as_written (v_name);			-- remove accept-this-as-written markup when it wraps all of &lt;v_name&gt;

		if accept_name then
			last = v_name;
			corporate = true;													-- flag used in list_people()
		elseif string.find(v_name, &quot;%s&quot;) then
			if v_name:find('[;%.]') then										-- look for commonly occurring punctuation characters; 
				add_vanc_error (cfg.err_msg_supl.punctuation, i);
			end
			local lastfirstTable = {}
			lastfirstTable = mw.text.split(v_name, &quot;%s+&quot;)
			first = table.remove(lastfirstTable);								-- removes and returns value of last element in table which should be initials or generational suffix

			if not mw.ustring.match (first, '^%u+$') then						-- mw.ustring here so that later we will catch non-Latin characters
				suffix = first;													-- not initials so assume that whatever we got is a generational suffix
				first = table.remove(lastfirstTable);							-- get what should be the initials from the table
			end
			last = table.concat(lastfirstTable, ' ')							-- returns a string that is the concatenation of all other names that are not initials and generational suffix
			if not utilities.is_set (last) then
				first = '';														-- unset
				last = v_name;													-- last empty because something wrong with first
				add_vanc_error (cfg.err_msg_supl.name, i);
			end
			if mw.ustring.match (last, '%a+%s+%u+%s+%a+') then
				add_vanc_error (cfg.err_msg_supl['missing comma'], i);			-- matches last II last; the case when a comma is missing
			end
			if mw.ustring.match (v_name, ' %u %u$') then						-- this test is in the wrong place TODO: move or replace with a more appropriate test
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- matches a space between two initials
			end
		else
			last = v_name;														-- last name or single corporate name?  Doesn't support multiword corporate names? do we need this?
		end
		
		if utilities.is_set (first) then
			if not mw.ustring.match (first, &quot;^%u?%u$&quot;) then						-- first shall contain one or two upper-case letters, nothing else
				add_vanc_error (cfg.err_msg_supl.initials, i);					-- too many initials; mixed case initials (which may be ok Romanization); hyphenated initials
			end
			is_good_vanc_name (last, first, suffix, i);							-- check first and last before restoring the suffix which may have a non-Latin digit
			if utilities.is_set (suffix) then
				first = first .. ' ' .. suffix;									-- if there was a suffix concatenate with the initials
				suffix = '';													-- unset so we don't add this suffix to all subsequent names
			end
		else
			if not corporate then
				is_good_vanc_name (last, '', nil, i);
			end
		end

		link = utilities.select_one ( args, cfg.aliases[list_name .. '-Link'], 'err_redundant_parameters', i ) or v_link_table[i];
		mask = utilities.select_one ( args, cfg.aliases[list_name .. '-Mask'], 'err_redundant_parameters', i );
		names[i] = {last = last, first = first, link = link, mask = mask, corporate = corporate};		-- add this assembled name to our names list
	end
	return names, etal;															-- all done, return our list of names
end


--[[--------------------------&lt; S E L E C T _ A U T H O R _ E D I T O R _ S O U R C E &gt;------------------------

Select one of |authors=, |authorn= / |lastn / firstn=, or |vauthors= as the source of the author name list or
select one of |editorn= / editor-lastn= / |editor-firstn= or |veditors= as the source of the editor name list.

Only one of these appropriate three will be used.  The hierarchy is: |authorn= (and aliases) highest and |authors= lowest;
|editorn= (and aliases) highest and |veditors= lowest (support for |editors= withdrawn)

When looking for |authorn= / |editorn= parameters, test |xxxxor1= and |xxxxor2= (and all of their aliases); stops after the second
test which mimicks the test used in extract_names() when looking for a hole in the author name list.  There may be a better
way to do this, I just haven't discovered what that way is.

Emits an error message when more than one xxxxor name source is provided.

In this function, vxxxxors = vauthors or veditors; xxxxors = authors as appropriate.

]]

local function select_author_editor_source (vxxxxors, xxxxors, args, list_name)
	local lastfirst = false;
	if utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 1 ) or		-- do this twice in case we have a |first1= without a |last1=; this ...
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 1 ) or		-- ... also catches the case where |first= is used with |vauthors=
		utilities.select_one ( args, cfg.aliases[list_name .. '-Last'], 'none', 2 ) or
		utilities.select_one ( args, cfg.aliases[list_name .. '-First'], 'none', 2 ) then
			lastfirst = true;
	end

	if (utilities.is_set (vxxxxors) and true == lastfirst) or					-- these are the three error conditions
		(utilities.is_set (vxxxxors) and utilities.is_set (xxxxors)) or
		(true == lastfirst and utilities.is_set (xxxxors)) then
			local err_name;
			if 'AuthorList' == list_name then									-- figure out which name should be used in error message
				err_name = 'author';
			else
				err_name = 'editor';
			end
			utilities.set_message ('err_redundant_parameters', err_name .. '-name-list parameters');	-- add error message
	end

	if true == lastfirst then return 1 end;										-- return a number indicating which author name source to use
	if utilities.is_set (vxxxxors) then return 2 end;
	if utilities.is_set (xxxxors) then return 3 end;
	return 1;																	-- no authors so return 1; this allows missing author name test to run in case there is a first without last 
end


--[[--------------------------&lt; I S _ V A L I D _ P A R A M E T E R _ V A L U E &gt;------------------------------

This function is used to validate a parameter's assigned value for those parameters that have only a limited number
of allowable values (yes, y, true, live, dead, etc.).  When the parameter value has not been assigned a value (missing
or empty in the source template) the function returns the value specified by ret_val.  If the parameter value is one
of the list of allowed values returns the translated value; else, emits an error message and returns the value
specified by ret_val.

TODO: explain &lt;invert&gt;

]]

local function is_valid_parameter_value (value, name, possible, ret_val, invert)
	if not utilities.is_set (value) then
		return ret_val;															-- an empty parameter is ok
	end

	if (not invert and utilities.in_array (value, possible)) then				-- normal; &lt;value&gt; is in &lt;possible&gt; table
		return cfg.keywords_xlate[value];										-- return translation of parameter keyword
	elseif invert and not utilities.in_array (value, possible) then				-- invert; &lt;value&gt; is not in &lt;possible&gt; table
		return value;															-- return &lt;value&gt; as it is
	else
		utilities.set_message ('err_invalid_param_val', {name, value});			-- not an allowed value so add error message
		return ret_val;
	end
end


--[[--------------------------&lt; T E R M I N A T E _ N A M E _ L I S T &gt;----------------------------------------

This function terminates a name list (author, contributor, editor) with a separator character (sepc) and a space
when the last character is not a sepc character or when the last three characters are not sepc followed by two
closing square brackets (close of a wikilink).  When either of these is true, the name_list is terminated with a
single space character.

]]

local function terminate_name_list (name_list, sepc)
	if (string.sub (name_list, -3, -1) == sepc .. '. ') then					-- if already properly terminated
		return name_list;														-- just return the name list
	elseif (string.sub (name_list, -1, -1) == sepc) or (string.sub (name_list, -3, -1) == sepc .. ']]') then	-- if last name in list ends with sepc char
		return name_list .. &quot; &quot;;												-- don't add another
	else
		return name_list .. sepc .. ' ';										-- otherwise terminate the name list
	end
end


--[[-------------------------&lt; F O R M A T _ V O L U M E _ I S S U E &gt;-----------------------------------------

returns the concatenation of the formatted volume and issue (or journal article number) parameters as a single
string; or formatted volume or formatted issue, or an empty string if neither are set.

]]
	
local function format_volume_issue (volume, issue, article, cite_class, origin, sepc, lower)
	if not utilities.is_set (volume) and not utilities.is_set (issue) and not utilities.is_set (article) then
		return '';
	end

	-- same condition as in format_pages_sheets()
	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);

	local is_numeric_vol = volume and (volume:match ('^[MDCLXVI]+$') or volume:match ('^%d+$'));	-- is only uppercase roman numerals or only digits?
	local is_long_vol = volume and (4 &lt; mw.ustring.len(volume));				-- is |volume= value longer than 4 characters?
	
	if volume and (not is_numeric_vol and is_long_vol) then						-- when not all digits or Roman numerals, is |volume= longer than 4 characters?
		utilities.add_prop_cat ('long-vol');									-- yes, add properties cat
	end

	if is_journal then															-- journal-style formatting
		local vol = '';

		if utilities.is_set (volume) then
			if is_numeric_vol then												-- |volume= value all digits or all uppercase Roman numerals?
				vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, volume});	-- render in bold face
			elseif is_long_vol then												-- not all digits or Roman numerals; longer than 4 characters?
				vol = utilities.substitute (cfg.messages['j-vol'], {sepc, utilities.hyphen_to_dash (volume)});	-- not bold
			else																-- four or fewer characters
				vol = utilities.substitute (cfg.presentation['vol-bold'], {sepc, utilities.hyphen_to_dash (volume)});	-- bold
			end
		end
		vol = vol .. (utilities.is_set (issue) and utilities.substitute (cfg.messages['j-issue'], issue) or '')
		vol = vol .. (utilities.is_set (article) and utilities.substitute (cfg.messages['j-article-num'], article) or '')
		return vol;
	end
	
	if 'podcast' == cite_class and utilities.is_set (issue) then
		return wrap_msg ('issue', {sepc, issue}, lower);
	end
	
	if 'conference' == cite_class and utilities.is_set (article) then			-- |article-number= supported only in journal and conference cites
		if utilities.is_set (volume) and utilities.is_set (article) then		-- both volume and article number
			return wrap_msg ('vol-art', {sepc, utilities.hyphen_to_dash (volume), article}, lower);
		elseif utilities.is_set (article) then									-- article number alone; when volume alone, handled below
			return wrap_msg ('art', {sepc, article}, lower);
		end
	end

	-- all other types of citation
	if utilities.is_set (volume) and utilities.is_set (issue) then
		return wrap_msg ('vol-no', {sepc, utilities.hyphen_to_dash (volume), issue}, lower);
	elseif utilities.is_set (volume) then
		return wrap_msg ('vol', {sepc, utilities.hyphen_to_dash (volume)}, lower);
	else
		return wrap_msg ('issue', {sepc, issue}, lower);
	end
end


--[[-------------------------&lt; F O R M A T _ P A G E S _ S H E E T S &gt;-----------------------------------------

adds static text to one of |page(s)= or |sheet(s)= values and returns it with all of the others set to empty strings.
The return order is:
	page, pages, sheet, sheets

Singular has priority over plural when both are provided.

]]

local function format_pages_sheets (page, pages, sheet, sheets, cite_class, origin, sepc, nopp, lower)
	if 'map' == cite_class then													-- only cite map supports sheet(s) as in-source locators
		if utilities.is_set (sheet) then
			if 'journal' == origin then
				return '', '', wrap_msg ('j-sheet', sheet, lower), '';
			else
				return '', '', wrap_msg ('sheet', {sepc, sheet}, lower), '';
			end
		elseif utilities.is_set (sheets) then
			if 'journal' == origin then
				return '', '', '', wrap_msg ('j-sheets', sheets, lower);
			else
				return '', '', '', wrap_msg ('sheets', {sepc, sheets}, lower);
			end
		end
	end

	local is_journal = 'journal' == cite_class or (utilities.in_array (cite_class, {'citation', 'map', 'interview'}) and 'journal' == origin);
	
	if utilities.is_set (page) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], page), '', '', '';
		elseif not nopp then
			return utilities.substitute (cfg.messages['p-prefix'], {sepc, page}), '', '', '';
		else
			return utilities.substitute (cfg.messages['nopp'], {sepc, page}), '', '', '';
		end
	elseif utilities.is_set (pages) then
		if is_journal then
			return utilities.substitute (cfg.messages['j-page(s)'], pages), '', '', '';
		elseif tonumber(pages) ~= nil and not nopp then							-- if pages is only digits, assume a single page number
			return '', utilities.substitute (cfg.messages['p-prefix'], {sepc, pages}), '', '';
		elseif not nopp then
			return '', utilities.substitute (cfg.messages['pp-prefix'], {sepc, pages}), '', '';
		else
			return '', utilities.substitute (cfg.messages['nopp'], {sepc, pages}), '', '';
		end
	end
	
	return '', '', '', '';														-- return empty strings
end


--[[--------------------------&lt; I N S O U R C E _ L O C _ G E T &gt;----------------------------------------------

returns one of the in-source locators: page, pages, or at. 

If any of these are interwiki links to Wikisource, returns the label portion of the interwiki-link as plain text
for use in COinS.  This COinS thing is done because here we convert an interwiki-link to an external link and
add an icon span around that; get_coins_pages() doesn't know about the span.  TODO: should it?  

TODO: add support for sheet and sheets?; streamline;

TODO: make it so that this function returns only one of the three as the single in-source (the return value assigned
to a new name)?

]]

local function insource_loc_get (page, page_orig, pages, pages_orig, at)
	local ws_url, ws_label, coins_pages, L;										-- for Wikisource interwiki-links; TODO: this corrupts page metadata (span remains in place after cleanup; fix there?)

	if utilities.is_set (page) then
		if utilities.is_set (pages) or utilities.is_set (at) then
			pages = '';															-- unset the others
			at = '';
		end
		extra_text_in_page_check (page, page_orig);								-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (page);						-- make ws URL from |page= interwiki link; link portion L becomes tooltip label
		if ws_url then
			page = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in page');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			page = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, page});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (pages) then
		if utilities.is_set (at) then
			at = '';															-- unset
		end
		extra_text_in_page_check (pages, pages_orig);							-- emit error message when |page= value begins with what looks like p., pp., etc.

		ws_url, ws_label, L = wikisource_url_make (pages);						-- make ws URL from |pages= interwiki link; link portion L becomes tooltip label
		if ws_url then
			pages = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in pages');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			pages = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, pages});
			coins_pages = ws_label;
		end
	elseif utilities.is_set (at) then
		ws_url, ws_label, L = wikisource_url_make (at);							-- make ws URL from |at= interwiki link; link portion L becomes tooltip label
		if ws_url then
			at = external_link (ws_url, ws_label .. '&amp;nbsp;', 'ws link in at');	-- space char after label to move icon away from in-source text; TODO: a better way to do this?
			at = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, at});
			coins_pages = ws_label;
		end
	end
	
	return page, pages, at, coins_pages;
end

--[[--------------------------&lt; I S _ U N I Q U E _ A R C H I V E _ U R L &gt;------------------------------------

add error message when |archive-url= value is same as |url= or chapter-url= (or alias...) value

]]

local function is_unique_archive_url (archive, url, c_url, source, date)
	if utilities.is_set (archive) then
		if archive == url or archive == c_url then
			utilities.set_message ('err_bad_url', {utilities.wrap_style ('parameter', source)});	-- add error message
			return '', '';														-- unset |archive-url= and |archive-date= because same as |url= or |chapter-url=
		end
	end

	return archive, date;
end


--[=[-------------------------&lt; A R C H I V E _ U R L _ C H E C K &gt;--------------------------------------------

Check archive.org URLs to make sure they at least look like they are pointing at valid archives and not to the 
save snapshot URL or to calendar pages.  When the archive URL is 'https://web.archive.org/save/' (or http://...)
archive.org saves a snapshot of the target page in the URL.  That is something that Wikipedia should not allow
unwitting readers to do.

When the archive.org URL does not have a complete timestamp, archive.org chooses a snapshot according to its own
algorithm or provides a calendar 'search' result.  [[WP:ELNO]] discourages links to search results.

This function looks at the value assigned to |archive-url= and returns empty strings for |archive-url= and
|archive-date= and an error message when:
	|archive-url= holds an archive.org save command URL
	|archive-url= is an archive.org URL that does not have a complete timestamp (YYYYMMDDhhmmss 14 digits) in the
		correct place
otherwise returns |archive-url= and |archive-date=

There are two mostly compatible archive.org URLs:
	//web.archive.org/&lt;timestamp&gt;...		-- the old form
	//web.archive.org/web/&lt;timestamp&gt;...	-- the new form

The old form does not support or map to the new form when it contains a display flag.  There are four identified flags
('id_', 'js_', 'cs_', 'im_') but since archive.org ignores others following the same form (two letters and an underscore)
we don't check for these specific flags but we do check the form.

This function supports a preview mode.  When the article is rendered in preview mode, this function may return a modified
archive URL:
	for save command errors, return undated wildcard (/*/)
	for timestamp errors when the timestamp has a wildcard, return the URL unmodified
	for timestamp errors when the timestamp does not have a wildcard, return with timestamp limited to six digits plus wildcard (/yyyymm*/)

A secondary function is to return an archive-url timestamp from those urls that have them (archive.org and
archive.today).  The timestamp is used by validation.archive_date_check() to see if the value in |archive-date=
matches the timestamp in the archive url.

]=]

local function archive_url_check (url, date)
	local err_msg = '';															-- start with the error message empty
	local path, timestamp, flag;												-- portions of the archive.org URL
	
	timestamp = url:match ('//archive.today/(%d%d%d%d%d%d%d%d%d%d%d%d%d%d)/') or	-- get timestamp from archive.today urls
		url:match ('//archive.today/(%d%d%d%d%.%d%d%.%d%d%-%d%d%d%d%d%d)/');		-- this timestamp needs cleanup
	if timestamp then															-- if this was an archive.today url ...
		return url, date, timestamp:gsub ('[%.%-]', '');						-- return ArchiveURL, ArchiveDate, and timestamp (dots and dashes removed) from |archive-url=, and done
	end
																				-- here for archive.org urls
	if (not url:match('//web%.archive%.org/')) and (not url:match('//liveweb%.archive%.org/')) then		-- also deprecated liveweb Wayback machine URL
		return url, date;														-- not an archive.org archive, return ArchiveURL and ArchiveDate
	end

	if url:match('//web%.archive%.org/save/') then								-- if a save command URL, we don't want to allow saving of the target page 
		err_msg = cfg.err_msg_supl.save;
		url = url:gsub ('(//web%.archive%.org)/save/', '%1/*/', 1);				-- for preview mode: modify ArchiveURL
	elseif url:match('//liveweb%.archive%.org/') then
		err_msg = cfg.err_msg_supl.liveweb;
	else
		path, timestamp, flag = url:match('//web%.archive%.org/([^%d]*)(%d+)([^/]*)/');	-- split out some of the URL parts for evaluation
		if not path then														-- malformed in some way; pattern did not match
			err_msg = cfg.err_msg_supl.timestamp;
		elseif 14 ~= timestamp:len() then										-- path and flag optional, must have 14-digit timestamp here
			err_msg = cfg.err_msg_supl.timestamp;
			if '*' ~= flag then
				local replacement = timestamp:match ('^%d%d%d%d%d%d') or timestamp:match ('^%d%d%d%d');	-- get the first 6 (YYYYMM) or first 4 digits (YYYY)
				if replacement then												-- nil if there aren't at least 4 digits (year)
					replacement = replacement .. string.rep ('0', 14 - replacement:len());	-- year or yearmo (4 or 6 digits) zero-fill to make 14-digit timestamp
					url=url:gsub ('(//web%.archive%.org/[^%d]*)%d[^/]*', '%1' .. replacement .. '*', 1)	-- for preview, modify ts to 14 digits plus splat for calendar display
				end
			end
		elseif utilities.is_set (path) and 'web/' ~= path then					-- older archive URLs do not have the extra 'web/' path element
			err_msg = cfg.err_msg_supl.path;
		elseif utilities.is_set (flag) and not utilities.is_set (path) then		-- flag not allowed with the old form URL (without the 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		elseif utilities.is_set (flag) and not flag:match ('%a%a_') then		-- flag if present must be two alpha characters and underscore (requires 'web/' path element)
			err_msg = cfg.err_msg_supl.flag;
		else
			return url, date, timestamp;										-- return ArchiveURL, ArchiveDate, and timestamp from |archive-url=
		end
	end
																				-- if here, something not right so
	utilities.set_message ('err_archive_url', {err_msg});						-- add error message and

	if is_preview_mode then
		return url, date, timestamp;											-- preview mode so return ArchiveURL, ArchiveDate, and timestamp from |archive-url=
	else
		return '', '';															-- return empty strings for ArchiveURL and ArchiveDate
	end
end


--[[--------------------------&lt; P L A C E _ C H E C K &gt;--------------------------------------------------------

check |place=, |publication-place=, |location= to see if these params include digits.  This function added because
many editors misuse location to specify the in-source location (|page(s)= and |at= are supposed to do that)

returns the original parameter value without modification; added maint cat when parameter value contains digits

]]

local function place_check (param_val)
	if not utilities.is_set (param_val) then									-- parameter empty or omitted
		return param_val;														-- return that empty state
	end
	
	if mw.ustring.find (param_val, '%d') then									-- not empty, are there digits in the parameter value
		utilities.set_message ('maint_location');								-- yep, add maint cat
	end
	
	return param_val;															-- and done
end


--[[--------------------------&lt; I S _ A R C H I V E D _ C O P Y &gt;----------------------------------------------

compares |title= to 'Archived copy' (placeholder added by bots that can't find proper title); if matches, return true; nil else

]]

local function is_archived_copy (title)
	title = mw.ustring.lower(title);											-- switch title to lower case
	if title:find (cfg.special_case_translation.archived_copy.en) then			-- if title is 'Archived copy'
		return true;
	elseif cfg.special_case_translation.archived_copy['local'] then
		if mw.ustring.find (title, cfg.special_case_translation.archived_copy['local']) then	-- mw.ustring() because might not be Latin script
			return true;
		end
	end
end


--[[--------------------------&lt; D I S P L A Y _ N A M E S _ S E L E C T &gt;--------------------------------------

for any of the |display-authors=, |display-editors=, etc parameters, select either the local or global setting.
When both are present, look at &lt;local_display_names&gt; value.  When the value is some sort of 'et al.'string,
special handling is required.

When {{cs1 config}} has |display-&lt;namelist&gt;= AND this template has |display-&lt;namelist&gt;=etal AND:
	the number of names specified by &lt;number_of_names&gt; is:
		greater than the number specified in the global |display-&lt;namelist&gt;= parameter (&lt;global_display_names&gt;)
			use global |display-&lt;namelist&gt;= parameter value
			set overridden maint category
		less than or equal to the number specified in the global |display-&lt;namelist&gt;=  parameter
			use local |display-&lt;namelist&gt;= parameter value

The purpose of this function is to prevent categorizing a template that has fewer names than the global setting
to keep the etal annotation specified by &lt;local_display_names&gt;.

]]

local function display_names_select (global_display_names, local_display_names, param_name, number_of_names, test)
	if global_display_names and utilities.is_set (local_display_names) then		-- when both
		if 'etal' == local_display_names:lower():gsub(&quot;[ '%.]&quot;, '') then		-- the :gsub() portion makes 'etal' from a variety of 'et al.' spellings and stylings
			number_of_names = tonumber (number_of_names);						-- convert these to numbers for comparison
			local global_display_names_num = tonumber (global_display_names);	-- &lt;global_display_names&gt; not set when parameter value is not digits

			if number_of_names &gt; global_display_names_num then					-- template has more names than global config allows to be displayed?
				utilities.set_message ('maint_overridden_setting');				-- set a maint message because global is overriding local |display-&lt;namelist&gt;=etal
				return global_display_names, 'cs1 config';						-- return global with spoof parameter name (for get_display_names())
			else
				return local_display_names, param_name;							-- return local because fewer names so let &lt;local_display_names&gt; control
			end
		end
																				-- here when &lt;global_display_names&gt; and &lt;local_display_names&gt; both numbers; &lt;global_display_names&gt; controls
		utilities.set_message ('maint_overridden_setting');						-- set a maint message
		return global_display_names, 'cs1 config';								-- return global with spoof parameter name (for get_display_names())
	end
																				-- here when only one of &lt;global_display_names&gt; or &lt;local_display_names&gt; set
	if global_display_names then
		return global_display_names, 'cs1 config';								-- return global with spoof parameter name (for get_display_names())
	else
		return local_display_names, param_name;									-- return local
	end
end


--[[--------------------------&lt; M O D E _ S E T &gt;--------------------------------------------------------------

fetch global mode setting from {{cs1 config}} (if present) or from |mode= (if present); global setting overrides
local |mode= parameter value.  When both are present, emit maintenance message

]]

local function mode_set (Mode, Mode_origin)
	local mode;
	if cfg.global_cs1_config_t['Mode'] then										-- global setting in {{cs1 config}}; nil when empty or assigned value invalid
		mode = is_valid_parameter_value (cfg.global_cs1_config_t['Mode'], 'cs1 config: mode', cfg.keywords_lists['mode'], '');	-- error messaging 'param' here is a hoax
	else
		mode = is_valid_parameter_value (Mode, Mode_origin, cfg.keywords_lists['mode'], '');
	end

	if cfg.global_cs1_config_t['Mode'] and utilities.is_set (Mode) then			-- when template has |mode=&lt;something&gt; which global setting has overridden
		utilities.set_message ('maint_overridden_setting');						-- set a maint message
	end
	return mode;
end


--[[--------------------------&lt; Q U O T E _ M A K E &gt;----------------------------------------------------------

create quotation from |quote=, |trans-quote=, and/or script-quote= with or without |quote-page= or |quote-pages=

when any of those three quote parameters are set, this function unsets &lt;PostScript&gt;.  When none of those parameters
are set, |quote-page= and |quote-pages= are unset to nil so that they are not included in the template's metadata

]]

local function quote_make (quote, trans_quote, script_quote, quote_page, quote_pages, nopp, sepc, postscript)
	if utilities.is_set (quote) or utilities.is_set (trans_quote) or utilities.is_set (script_quote) then

		if utilities.is_set (quote) then
			if quote:sub(1, 1) == '&quot;' and quote:sub(-1, -1) == '&quot;' then			-- if first and last characters of quote are quote marks
				quote = quote:sub(2, -2);										-- strip them off
			end
		end
		
		quote = kern_quotes (quote);											-- kern if needed
		quote = utilities.wrap_style ('quoted-text', quote );					-- wrap in &lt;q&gt;...&lt;/q&gt; tags
	
		if utilities.is_set (script_quote) then
			quote = script_concatenate (quote, script_quote, 'script-quote');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after quote is wrapped
		end

		if utilities.is_set (trans_quote) then
			if trans_quote:sub(1, 1) == '&quot;' and trans_quote:sub(-1, -1) == '&quot;' then -- if first and last characters of |trans-quote are quote marks
				trans_quote = trans_quote:sub(2, -2); -- strip them off
			end
			quote = quote .. &quot; &quot; .. utilities.wrap_style ('trans-quoted-title', trans_quote );
		end

		if utilities.is_set (quote_page) or utilities.is_set (quote_pages) then	-- add page prefix
			local quote_prefix = '';
			if utilities.is_set (quote_page) then
				extra_text_in_page_check (quote_page, 'quote-page');			-- add to maint cat if |quote-page= value begins with what looks like p., pp., etc.
				if not nopp then
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, quote_page}), '', '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, quote_page}), '', '', '';
				end
			elseif utilities.is_set (quote_pages) then
				extra_text_in_page_check (quote_pages, 'quote-pages');			-- add to maint cat if |quote-pages= value begins with what looks like p., pp., etc.
				if tonumber(quote_pages) ~= nil and not nopp then				-- if only digits, assume single page
					quote_prefix = utilities.substitute (cfg.messages['p-prefix'], {sepc, quote_pages}), '', '';
				elseif not nopp then
					quote_prefix = utilities.substitute (cfg.messages['pp-prefix'], {sepc, quote_pages}), '', '';
				else
					quote_prefix = utilities.substitute (cfg.messages['nopp'], {sepc, quote_pages}), '', '';
				end
			end
                        
			quote = quote_prefix .. &quot;: &quot; .. quote;
		else
			quote = sepc .. &quot; &quot; .. quote;
		end

		postscript = &quot;&quot;;														-- cs1|2 does not supply terminal punctuation when |quote= is set
	
	elseif utilities.is_set (quote_page) or utilities.is_set (quote_pages) then
		quote_page = nil;														-- unset; these require |quote=; TODO: error message?
		quote_pages = nil;
	end

	return quote, quote_page, quote_pages, postscript;
end


--[[--------------------------&lt; C H E C K _ P U B L I S H E R _ N A M E &gt;--------------------------------------

look for variations of '&lt;text&gt;: &lt;text&gt;' that might be '&lt;location&gt;: &lt;publisher&gt;' in |publisher= parameter value.
when found, emit a maintenance message; return nil else

&lt;publisher&gt; is the value assigned to |publisher= or |institution=

]]

local function check_publisher_name (publisher)
	local patterns_t = {
		'^[%w%s]+%s*:%s*[%w%s]+$',												-- plain text &lt;location&gt;: &lt;publisher&gt;
		'^%[+[%w%s:|]+%]+%s*:%s*[%w%s]+$',										-- partially wikilinked [[&lt;location&gt;]]: &lt;publisher&gt;
		'^[%w%s]+%s*:%s*%[+[%w%s:|]+%]+$',										-- partially wikilinked &lt;location&gt;: [[&lt;publisher&gt;]]
		'^%[+[%w%s:|]+%]+%s*:%s*%[+[%w%s:|]+%]+$',								-- wikilinked [[&lt;location&gt;]]: [[&lt;publisher&gt;]]
		}
	
	for _, pattern in ipairs (patterns_t) do									-- spin through the patterns_t sequence
		if mw.ustring.match (publisher, pattern) then							-- does this pattern match?
			utilities.set_message ('maint_publisher_location');					-- set a maint message
			return;																-- and done
		end
	end
end


--[[--------------------------&lt; C I T A T I O N 0 &gt;------------------------------------------------------------

This is the main function doing the majority of the citation formatting.

]]

local function citation0( config, args )
	--[[ 
	Load Input Parameters
	The argument_wrapper facilitates the mapping of multiple aliases to single internal variable.
	]]
	local A = argument_wrapper ( args );
	local i 

	-- Pick out the relevant fields from the arguments.  Different citation templates
	-- define different field names for the same underlying things.	

	local author_etal;
	local a	= {};																-- authors list from |lastn= / |firstn= pairs or |vauthors=
	local Authors;
	local NameListStyle;
		if cfg.global_cs1_config_t['NameListStyle'] then						-- global setting in {{cs1 config}} overrides local |name-list-style= parameter value; nil when empty or assigned value invalid
			NameListStyle = is_valid_parameter_value (cfg.global_cs1_config_t['NameListStyle'], 'cs1 config: name-list-style', cfg.keywords_lists['name-list-style'], '');	-- error messaging 'param' here is a hoax
		else
			NameListStyle = is_valid_parameter_value (A['NameListStyle'], A:ORIGIN('NameListStyle'), cfg.keywords_lists['name-list-style'], '');
		end

		if cfg.global_cs1_config_t['NameListStyle'] and utilities.is_set (A['NameListStyle']) then	-- when template has |name-list-style=&lt;something&gt; which global setting has overridden
			utilities.set_message ('maint_overridden_setting');					-- set a maint message
		end

	local Collaboration = A['Collaboration'];

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Vauthors'], A['Authors'], args, 'AuthorList');
		if 1 == selected then
			a, author_etal = extract_names (args, 'AuthorList');				-- fetch author list from |authorn= / |lastn= / |firstn=, |author-linkn=, and |author-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			a, author_etal = parse_vauthors_veditors (args, A['Vauthors'], 'AuthorList');	-- fetch author list from |vauthors=, |author-linkn=, and |author-maskn=
		elseif 3 == selected then
			Authors = A['Authors'];												-- use content of |people= or |credits=; |authors= is deprecated; TODO: constrain |people= and |credits= to cite av media, episode, serial?
		end
		if utilities.is_set (Collaboration) then
			author_etal = true;													-- so that |display-authors=etal not required
		end
	end

	local editor_etal;
	local e	= {};																-- editors list from |editor-lastn= / |editor-firstn= pairs or |veditors=

	do																			-- to limit scope of selected
		local selected = select_author_editor_source (A['Veditors'], nil, args, 'EditorList');	-- support for |editors= withdrawn
		if 1 == selected then
			e, editor_etal = extract_names (args, 'EditorList');				-- fetch editor list from |editorn= / |editor-lastn= / |editor-firstn=, |editor-linkn=, and |editor-maskn=
		elseif 2 == selected then
			NameListStyle = 'vanc';												-- override whatever |name-list-style= might be
			e, editor_etal = parse_vauthors_veditors (args, args.veditors, 'EditorList');	-- fetch editor list from |veditors=, |editor-linkn=, and |editor-maskn=
		end
	end
							
	local Chapter = A['Chapter'];												-- done here so that we have access to |contribution= from |chapter= aliases
	local Chapter_origin = A:ORIGIN ('Chapter');
	local Contribution;															-- because contribution is required for contributor(s)
		if 'contribution' == Chapter_origin then
			Contribution = Chapter;												-- get the name of the contribution
		end
	local c = {};																-- contributors list from |contributor-lastn= / contributor-firstn= pairs
	
	if utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (A['Periodical']) then	-- |contributor= and |contribution= only supported in book cites
		c = extract_names (args, 'ContributorList');							-- fetch contributor list from |contributorn= / |contributor-lastn=, -firstn=, -linkn=, -maskn=
		
		if 0 &lt; #c then
			if not utilities.is_set (Contribution) then							-- |contributor= requires |contribution=
				utilities.set_message ('err_contributor_missing_required_param', 'contribution');	-- add missing contribution error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
			if 0 == #a then														-- |contributor= requires |author=
				utilities.set_message ('err_contributor_missing_required_param', 'author');	-- add missing author error message
				c = {};															-- blank the contributors' table; it is used as a flag later
			end
		end
	else																		-- if not a book cite
		if utilities.select_one (args, cfg.aliases['ContributorList-Last'], 'err_redundant_parameters', 1 ) then	-- are there contributor name list parameters?
			utilities.set_message ('err_contributor_ignored');					-- add contributor ignored error message
		end
		Contribution = nil;														-- unset
	end

	local Title = A['Title'];
	local TitleLink = A['TitleLink'];

	local auto_select = '';														-- default is auto
	local accept_link;
	TitleLink, accept_link = utilities.has_accept_as_written (TitleLink, true);	-- test for accept-this-as-written markup
	if (not accept_link) and utilities.in_array (TitleLink, {'none', 'pmc', 'doi'}) then -- check for special keywords
		auto_select = TitleLink;												-- remember selection for later
		TitleLink = '';															-- treat as if |title-link= would have been empty
	end

	TitleLink = link_title_ok (TitleLink, A:ORIGIN ('TitleLink'), Title, 'title');	-- check for wiki-markup in |title-link= or wiki-markup in |title= when |title-link= is set

	local Section = '';															-- {{cite map}} only; preset to empty string for concatenation if not used
	if 'map' == config.CitationClass and 'section' == Chapter_origin then
		Section = A['Chapter'];													-- get |section= from |chapter= alias list; |chapter= and the other aliases not supported in {{cite map}}
		Chapter = '';															-- unset for now; will be reset later from |map= if present
	end

	local Periodical = A['Periodical'];
	local Periodical_origin = A:ORIGIN('Periodical');
	local ScriptPeriodical = A['ScriptPeriodical'];
	local ScriptPeriodical_origin = A:ORIGIN('ScriptPeriodical');
	local TransPeriodical =  A['TransPeriodical'];
	local TransPeriodical_origin =  A:ORIGIN ('TransPeriodical');
	
	if (utilities.in_array (config.CitationClass, {'book', 'encyclopaedia'}) and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical))) then
		local param;
		if utilities.is_set (Periodical) then									-- get a parameter name from one of these periodical related meta-parameters
			Periodical = '';													-- unset because not valid {{cite book}} or {{cite encyclopedia}} parameters 
			param = Periodical_origin											-- get parameter name for error messaging
		elseif utilities.is_set (TransPeriodical) then
			TransPeriodical = '';												-- unset because not valid {{cite book}} or {{cite encyclopedia}} parameters 
			param = TransPeriodical_origin;										-- get parameter name for error messaging
		elseif utilities.is_set (ScriptPeriodical) then
			ScriptPeriodical = '';												-- unset because not valid {{cite book}} or {{cite encyclopedia}} parameters 
			param = ScriptPeriodical_origin;									-- get parameter name for error messaging
		end

		if utilities.is_set (param) then										-- if we found one
			utilities.set_message ('err_periodical_ignored', {param});			-- emit an error message
		end
	end

	if utilities.is_set (Periodical) then
		local i;
		Periodical, i = utilities.strip_apostrophe_markup (Periodical);			-- strip apostrophe markup so that metadata isn't contaminated 
		if i then																-- non-zero when markup was stripped so emit an error message
			utilities.set_message ('err_apostrophe_markup', {Periodical_origin});
		end
	end

	if 'mailinglist' == config.CitationClass then								-- special case for {{cite mailing list}}
		if utilities.is_set (Periodical) and utilities.is_set (A ['MailingList']) then	-- both set emit an error TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', Periodical_origin) .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'mailinglist')});
		end

		Periodical = A ['MailingList'];											-- error or no, set Periodical to |mailinglist= value because this template is {{cite mailing list}}
		Periodical_origin = A:ORIGIN('MailingList');
	end

	-- web and news not tested for now because of 
	-- Wikipedia:Administrators%27_noticeboard#Is_there_a_semi-automated_tool_that_could_fix_these_annoying_&quot;Cite_Web&quot;_errors?
	if not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) then	-- 'periodical' templates require periodical parameter
	--	local p = {['journal'] = 'journal', ['magazine'] = 'magazine', ['news'] = 'newspaper', ['web'] = 'website'};	-- for error message
		local p = {['journal'] = 'journal', ['magazine'] = 'magazine'};			-- for error message
		if p[config.CitationClass]  then
			utilities.set_message ('err_missing_periodical', {config.CitationClass, p[config.CitationClass]});
		end
	end
	
	local Volume;
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) then
			if not utilities.in_array (Periodical_origin, cfg.citation_no_volume_t) then	-- {{citation}} does not render |volume= when these parameters are used
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		elseif utilities.is_set (ScriptPeriodical) then
			if 'script-website' ~= ScriptPeriodical_origin then					-- {{citation}} does not render volume for |script-website=
				Volume = A['Volume'];											-- but does for all other 'periodicals'
			end
		else
			Volume = A['Volume'];												-- and does for non-'periodical' cites
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_volume) then	-- render |volume= for cs1 according to the configuration settings
		Volume = A['Volume'];
	end	
	extra_text_in_vol_iss_check (Volume, A:ORIGIN ('Volume'), 'v');	

	local Issue;
	if 'citation' == config.CitationClass then
		if utilities.is_set (Periodical) and utilities.in_array (Periodical_origin, cfg.citation_issue_t) then	-- {{citation}} may render |issue= when these parameters are used
			Issue = utilities.hyphen_to_dash (A['Issue']);
		end
	elseif utilities.in_array (config.CitationClass, cfg.templates_using_issue) then	-- conference &amp; map books do not support issue; {{citation}} listed here because included in settings table
		if not (utilities.in_array (config.CitationClass, {'conference', 'map', 'citation'}) and not (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical))) then
			Issue = utilities.hyphen_to_dash (A['Issue']);
		end
	end
	
	local ArticleNumber;

	if utilities.in_array (config.CitationClass, {'journal', 'conference'}) or ('citation' == config.CitationClass and utilities.is_set (Periodical) and 'journal' == Periodical_origin) then
		ArticleNumber = A['ArticleNumber'];
	end

	extra_text_in_vol_iss_check (Issue, A:ORIGIN ('Issue'), 'i');	

	local Page;
	local Pages;
	local At;
	local QuotePage;
	local QuotePages;
	if not utilities.in_array (config.CitationClass, cfg.templates_not_using_page) then		-- TODO: rewrite to emit ignored parameter error message?
		Page = A['Page'];
		Pages = utilities.hyphen_to_dash (A['Pages']);	
		At = A['At'];
		QuotePage = A['QuotePage'];
		QuotePages = utilities.hyphen_to_dash (A['QuotePages']);
	end

	local NoPP = is_valid_parameter_value (A['NoPP'], A:ORIGIN('NoPP'), cfg.keywords_lists['yes_true_y'], nil);

	local Mode = mode_set (A['Mode'], A:ORIGIN('Mode'));

	-- separator character and postscript
	local sepc, PostScript = set_style (Mode:lower(), A['PostScript'], config.CitationClass);
	local Quote;
	Quote, QuotePage, QuotePages, PostScript = quote_make (A['Quote'], A['TransQuote'], A['ScriptQuote'], QuotePage, QuotePages, NoPP, sepc, PostScript);

	local Edition = A['Edition'];
	local PublicationPlace = place_check (A['PublicationPlace'], A:ORIGIN('PublicationPlace'));
	local Place = place_check (A['Place'], A:ORIGIN('Place'));
	
	local PublisherName = A['PublisherName'];
	local PublisherName_origin = A:ORIGIN('PublisherName');
	if utilities.is_set (PublisherName) and (cfg.keywords_xlate['none'] ~= PublisherName) then
		local i = 0;
		PublisherName, i = utilities.strip_apostrophe_markup (PublisherName);	-- strip apostrophe markup so that metadata isn't contaminated; publisher is never italicized
		if i and (0 &lt; i) then													-- non-zero when markup was stripped so emit an error message
			utilities.set_message ('err_apostrophe_markup', {PublisherName_origin});
		end
	end
	
	if ('document' == config.CitationClass) and not utilities.is_set (PublisherName) then
		utilities.set_message ('err_missing_publisher', {config.CitationClass, 'publisher'});
	end

	local Newsgroup = A['Newsgroup'];											-- TODO: strip apostrophe markup?
	local Newsgroup_origin = A:ORIGIN('Newsgroup');	

	if 'newsgroup' == config.CitationClass then
		if utilities.is_set (PublisherName) and (cfg.keywords_xlate['none'] ~= PublisherName) then	-- general use parameter |publisher= not allowed in cite newsgroup
			utilities.set_message ('err_parameter_ignored', {PublisherName_origin});
		end

		PublisherName = nil;													-- ensure that this parameter is unset for the time being; will be used again after COinS
	end

	if 'book' == config.CitationClass or 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and not utilities.is_set (Periodical)) then
		local accept;
		PublisherName, accept = utilities.has_accept_as_written (PublisherName);	-- check for and remove accept-as-written markup from |publisher= wrapped
		if not accept then														-- when no accept-as-written markup
			check_publisher_name (PublisherName);								-- emit maint message when |publisher= might be prefixed with publisher's location
		end
	end

	local URL = A['URL'];														-- TODO: better way to do this for URL, ChapterURL, and MapURL?
	local UrlAccess = is_valid_parameter_value (A['UrlAccess'], A:ORIGIN('UrlAccess'), cfg.keywords_lists['url-access'], nil);
	
	if not utilities.is_set (URL) and utilities.is_set (UrlAccess) then
		UrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', 'url');
	end
	
	local ChapterURL = A['ChapterURL'];
	local ChapterUrlAccess = is_valid_parameter_value (A['ChapterUrlAccess'], A:ORIGIN('ChapterUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (ChapterURL) and utilities.is_set (ChapterUrlAccess) then
		ChapterUrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', {A:ORIGIN('ChapterUrlAccess'):gsub ('%-access', '')});
	end

	local MapUrlAccess = is_valid_parameter_value (A['MapUrlAccess'], A:ORIGIN('MapUrlAccess'), cfg.keywords_lists['url-access'], nil);
	if not utilities.is_set (A['MapURL']) and utilities.is_set (MapUrlAccess) then
		MapUrlAccess = nil;
		utilities.set_message ('err_param_access_requires_param', {'map-url'});
	end

	local this_page = mw.title.getCurrentTitle();								-- also used for COinS and for language
	local no_tracking_cats = is_valid_parameter_value (A['NoTracking'], A:ORIGIN('NoTracking'), cfg.keywords_lists['yes_true_y'], nil);

	-- check this page to see if it is in one of the namespaces that cs1 is not supposed to add to the error categories
	if not utilities.is_set (no_tracking_cats) then								-- ignore if we are already not going to categorize this page
		if cfg.uncategorized_namespaces[this_page.namespace] then				-- is this page's namespace id one of the uncategorized namespace ids?
			no_tracking_cats = &quot;true&quot;;											-- set no_tracking_cats
		end
		for _, v in ipairs (cfg.uncategorized_subpages) do						-- cycle through page name patterns
			if this_page.text:match (v) then									-- test page name against each pattern
				no_tracking_cats = &quot;true&quot;;										-- set no_tracking_cats
				break;															-- bail out if one is found
			end
		end
	end
																				-- check for extra |page=, |pages= or |at= parameters. (also sheet and sheets while we're at it)
	utilities.select_one (args, {'page', 'p', 'pp', 'pages', 'at', 'sheet', 'sheets'}, 'err_redundant_parameters');	-- this is a dummy call simply to get the error message and category

	local coins_pages;
	
	Page, Pages, At, coins_pages = insource_loc_get (Page, A:ORIGIN('Page'), Pages, A:ORIGIN('Pages'), At);

	if utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- both |publication-place= and |place= (|location=) allowed if different
		utilities.add_prop_cat ('location-test');								-- add property cat to evaluate how often PublicationPlace and Place are used together
		if PublicationPlace == Place then
			Place = '';															-- unset; don't need both if they are the same
		end
	elseif not utilities.is_set (PublicationPlace) and utilities.is_set (Place) then	-- when only |place= (|location=) is set ...
		PublicationPlace = Place;												-- promote |place= (|location=) to |publication-place
	end

	if PublicationPlace == Place then Place = ''; end							-- don't need both if they are the same

	local URL_origin = A:ORIGIN('URL');											-- get name of parameter that holds URL
	local ChapterURL_origin = A:ORIGIN('ChapterURL');							-- get name of parameter that holds ChapterURL
	local ScriptChapter = A['ScriptChapter'];
	local ScriptChapter_origin = A:ORIGIN ('ScriptChapter');
	local Format = A['Format'];
	local ChapterFormat = A['ChapterFormat'];
	local TransChapter = A['TransChapter'];
	local TransChapter_origin = A:ORIGIN ('TransChapter');
	local TransTitle = A['TransTitle'];
	local ScriptTitle = A['ScriptTitle'];
	
	--[[
	Parameter remapping for cite encyclopedia:
	When the citation has these parameters:
		|encyclopedia= and |title= then map |title= to |article= and |encyclopedia= to |title= for rendering
		|encyclopedia= and |article= then map |encyclopedia= to |title= for rendering

		|trans-title= maps to |trans-chapter= when |title= is re-mapped
		|url= maps to |chapter-url= when |title= is remapped
	
	All other combinations of |encyclopedia=, |title=, and |article= are not modified
	
	]]

	local Encyclopedia = A['Encyclopedia'];										-- used as a flag by this module and by ~/COinS
	local ScriptEncyclopedia = A['ScriptEncyclopedia'];
	local TransEncyclopedia = A['TransEncyclopedia'];

	if utilities.is_set (Encyclopedia) or utilities.is_set (ScriptEncyclopedia) then	-- emit error message when Encyclopedia set but template is other than {{cite encyclopedia}} or {{citation}}
		if 'encyclopaedia' ~= config.CitationClass and 'citation' ~= config.CitationClass then
			if utilities.is_set (Encyclopedia) then
				utilities.set_message ('err_parameter_ignored', {A:ORIGIN ('Encyclopedia')});
			else
				utilities.set_message ('err_parameter_ignored', {A:ORIGIN ('ScriptEncyclopedia')});
			end
			Encyclopedia = nil;													-- unset these because not supported by this template
			ScriptEncyclopedia = nil;
			TransEncyclopedia = nil;
		end
	elseif utilities.is_set (TransEncyclopedia) then
		utilities.set_message ('err_trans_missing_title', {'encyclopedia'});
	end

	if ('encyclopaedia' == config.CitationClass) or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Periodical) and utilities.is_set (Encyclopedia) then	-- when both parameters set emit an error message; {{citation}} only; Periodical not allowed in {{cite encyclopedia}}
			utilities.set_message ('err_periodical_ignored', {Periodical_origin});
		end

		if utilities.is_set (Encyclopedia) or utilities.is_set (ScriptEncyclopedia) then
			Periodical = Encyclopedia;											-- error or no, set Periodical to Encyclopedia for rendering; {{citation}} could (not legitimately) have both; use Encyclopedia
			Periodical_origin = A:ORIGIN ('Encyclopedia');
			ScriptPeriodical = ScriptEncyclopedia;
			ScriptPeriodical_origin = A:ORIGIN ('ScriptEncyclopedia');

			if utilities.is_set (Title) or utilities.is_set (ScriptTitle) then
				if not utilities.is_set (Chapter) then
					Chapter = Title;											-- |encyclopedia= and |title= are set so map |title= params to |article= params for rendering
					ScriptChapter = ScriptTitle;
					ScriptChapter_origin = A:ORIGIN('ScriptTitle')
					TransChapter = TransTitle;
					ChapterURL = URL;
					ChapterURL_origin = URL_origin;
					ChapterUrlAccess = UrlAccess;
					ChapterFormat = Format;

					if not utilities.is_set (ChapterURL) and utilities.is_set (TitleLink) then
						Chapter = utilities.make_wikilink (TitleLink, Chapter);
					end
					Title = Periodical;											-- now map |encyclopedia= params to |title= params for rendering
					ScriptTitle = ScriptPeriodical or '';
					TransTitle = TransEncyclopedia or '';
					Periodical = '';											-- redundant so unset
					ScriptPeriodical = '';
					URL = '';
					Format = '';
					TitleLink = '';
				end
			elseif utilities.is_set (Chapter) or utilities.is_set (ScriptChapter) then	-- |title= not set
				Title = Periodical;												-- |encyclopedia= set and |article= set so map |encyclopedia= to |title= for rendering
				ScriptTitle = ScriptPeriodical or '';
				TransTitle = TransEncyclopedia or '';
				Periodical = '';												-- redundant so unset
				ScriptPeriodical = '';
			end
		end
	end

	-- special case for cite techreport.
	local ID = A['ID'];
	if (config.CitationClass == &quot;techreport&quot;) then								-- special case for cite techreport
		if utilities.is_set (A['Number']) then									-- cite techreport uses 'number', which other citations alias to 'issue'
			if not utilities.is_set (ID) then									-- can we use ID for the &quot;number&quot;?
				ID = A['Number'];												-- yes, use it
			else																-- ID has a value so emit error message
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'id') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'number')});
			end
		end	
	end

	-- Account for the oddity that is {{cite conference}}, before generation of COinS data.
	local ChapterLink -- = A['ChapterLink'];									-- deprecated as a parameter but still used internally by cite episode
	local Conference = A['Conference'];
	local BookTitle = A['BookTitle'];
	local TransTitle_origin = A:ORIGIN ('TransTitle');
	if 'conference' == config.CitationClass then
		if utilities.is_set (BookTitle) then
			Chapter = Title;
			Chapter_origin = 'title';
	--		ChapterLink = TitleLink;											-- |chapter-link= is deprecated
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			URL_origin = '';
			ChapterFormat = Format;
			TransChapter = TransTitle;
			TransChapter_origin = TransTitle_origin;
			Title = BookTitle;
			Format = '';
	--		TitleLink = '';
			TransTitle = '';
			URL = '';
		end
	elseif 'speech' ~= config.CitationClass then
		Conference = '';														-- not cite conference or cite speech so make sure this is empty string
	end
	
	local use_lowercase = ( sepc == ',' );										-- controls capitalization of certain static text
	
	-- cite map oddities
	local Cartography = &quot;&quot;;
	local Scale = &quot;&quot;;
	local Sheet = A['Sheet'] or '';
	local Sheets = A['Sheets'] or '';
	if config.CitationClass == &quot;map&quot; then
		if utilities.is_set (Chapter) then										--TODO: make a function for this and similar?
			utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'map') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', Chapter_origin)});	-- add error message
		end
		Chapter = A['Map'];
		Chapter_origin = A:ORIGIN('Map');
		ChapterURL = A['MapURL'];
		ChapterURL_origin = A:ORIGIN('MapURL');
		TransChapter = A['TransMap'];
		ScriptChapter = A['ScriptMap']
		ScriptChapter_origin = A:ORIGIN('ScriptMap')

		ChapterUrlAccess = MapUrlAccess;
		ChapterFormat = A['MapFormat'];

		Cartography = A['Cartography'];
		if utilities.is_set ( Cartography ) then
			Cartography = sepc .. &quot; &quot; .. wrap_msg ('cartography', Cartography, use_lowercase);
		end		
		Scale = A['Scale'];
		if utilities.is_set ( Scale ) then
			Scale = sepc .. &quot; &quot; .. Scale;
		end
	end

	-- Account for the oddities that are {{cite episode}} and {{cite serial}}, before generation of COinS data.
	local Series = A['Series'];
	if 'episode' == config.CitationClass or 'serial' == config.CitationClass then
		local SeriesLink = A['SeriesLink'];

		SeriesLink = link_title_ok (SeriesLink, A:ORIGIN ('SeriesLink'), Series, 'series');	-- check for wiki-markup in |series-link= or wiki-markup in |series= when |series-link= is set

		local Network = A['Network'];
		local Station = A['Station'];
		local s, n = {}, {};
																				-- do common parameters first
		if utilities.is_set (Network) then table.insert(n, Network); end
		if utilities.is_set (Station) then table.insert(n, Station); end
		ID = table.concat(n, sepc .. ' ');
		
		if 'episode' == config.CitationClass then								-- handle the oddities that are strictly {{cite episode}}
			local Season = A['Season'];
			local SeriesNumber = A['SeriesNumber'];

			if utilities.is_set (Season) and utilities.is_set (SeriesNumber) then	-- these are mutually exclusive so if both are set TODO: make a function for this and similar?
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'season') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'seriesno')});		-- add error message
				SeriesNumber = '';												-- unset; prefer |season= over |seriesno=
			end
																				-- assemble a table of parts concatenated later into Series
			if utilities.is_set (Season) then table.insert(s, wrap_msg ('season', Season, use_lowercase)); end
			if utilities.is_set (SeriesNumber) then table.insert(s, wrap_msg ('seriesnum', SeriesNumber, use_lowercase)); end
			if utilities.is_set (Issue) then table.insert(s, wrap_msg ('episode', Issue, use_lowercase)); end
			Issue = '';															-- unset because this is not a unique parameter
	
			Chapter = Title;													-- promote title parameters to chapter
			ScriptChapter = ScriptTitle;
			ScriptChapter_origin = A:ORIGIN('ScriptTitle');
			ChapterLink = TitleLink;											-- alias |episode-link=
			TransChapter = TransTitle;
			ChapterURL = URL;
			ChapterUrlAccess = UrlAccess;
			ChapterURL_origin = URL_origin;
			ChapterFormat = Format;

			Title = Series;														-- promote series to title
			TitleLink = SeriesLink;
			Series = table.concat(s, sepc .. ' ');								-- this is concatenation of season, seriesno, episode number

			if utilities.is_set (ChapterLink) and not utilities.is_set (ChapterURL) then	-- link but not URL
				Chapter = utilities.make_wikilink (ChapterLink, Chapter);
			elseif utilities.is_set (ChapterLink) and utilities.is_set (ChapterURL) then	-- if both are set, URL links episode;
				Series = utilities.make_wikilink (ChapterLink, Series);
			end
			URL = '';															-- unset
			TransTitle = '';
			ScriptTitle = '';
			Format = '';
			
		else																	-- now oddities that are cite serial
			Issue = '';															-- unset because this parameter no longer supported by the citation/core version of cite serial
			Chapter = A['Episode'];												-- TODO: make |episode= available to cite episode someday?
			if utilities.is_set (Series) and utilities.is_set (SeriesLink) then
				Series = utilities.make_wikilink (SeriesLink, Series);
			end
			Series = utilities.wrap_style ('italic-title', Series);				-- series is italicized
		end	
	end
	-- end of {{cite episode}} stuff

	-- handle type parameter for those CS1 citations that have default values
	local TitleType = A['TitleType'];
	local Degree = A['Degree'];
	if utilities.in_array (config.CitationClass, {'AV-media-notes', 'document', 'interview', 'mailinglist', 'map', 'podcast', 'pressrelease', 'report', 'speech', 'techreport', 'thesis'}) then
		TitleType = set_titletype (config.CitationClass, TitleType);
		if utilities.is_set (Degree) and &quot;Thesis&quot; == TitleType then				-- special case for cite thesis
			TitleType = Degree .. ' ' .. cfg.title_types ['thesis']:lower();
		end
	end

	if utilities.is_set (TitleType) then										-- if type parameter is specified
		TitleType = utilities.substitute ( cfg.messages['type'], TitleType);	-- display it in parentheses
	-- TODO: Hack on TitleType to fix bunched parentheses problem
	end

	-- legacy: promote PublicationDate to Date if neither Date nor Year are set.
	local Date = A['Date'];
 	local Date_origin;															-- to hold the name of parameter promoted to Date; required for date error messaging
	local PublicationDate = A['PublicationDate'];
	local Year = A['Year'];

	if utilities.is_set (Year) then
		validation.year_check (Year);											-- returns nothing; emits maint message when |year= doesn't hold a 'year' value
	end
		
	if not utilities.is_set (Date) then
		Date = Year;															-- promote Year to Date
		Year = nil;																-- make nil so Year as empty string isn't used for CITEREF
		if not utilities.is_set (Date) and utilities.is_set (PublicationDate) then	-- use PublicationDate when |date= and |year= are not set
			Date = PublicationDate;												-- promote PublicationDate to Date
			PublicationDate = '';												-- unset, no longer needed
			Date_origin = A:ORIGIN('PublicationDate');							-- save the name of the promoted parameter
		else
			Date_origin = A:ORIGIN('Year');										-- save the name of the promoted parameter
		end
	else
		Date_origin = A:ORIGIN('Date');											-- not a promotion; name required for error messaging
	end

	if PublicationDate == Date then PublicationDate = ''; end					-- if PublicationDate is same as Date, don't display in rendered citation

	--[[
	Go test all of the date-holding parameters for valid MOS:DATE format and make sure that dates are real dates. This must be done before we do COinS because here is where
	we get the date used in the metadata.
	
	Date validation supporting code is in Module:Citation/CS1/Date_validation
	]]

	local DF = is_valid_parameter_value (A['DF'], A:ORIGIN('DF'), cfg.keywords_lists['df'], '');
	if not utilities.is_set (DF) then
		DF = cfg.global_df;														-- local |df= if present overrides global df set by {{use xxx date}} template
	end

	local ArchiveURL;
	local ArchiveDate;
	local ArchiveFormat = A['ArchiveFormat'];
	local archive_url_timestamp;												-- timestamp from wayback machine url
	
	ArchiveURL, ArchiveDate, archive_url_timestamp = archive_url_check (A['ArchiveURL'], A['ArchiveDate'])
	ArchiveFormat = style_format (ArchiveFormat, ArchiveURL, 'archive-format', 'archive-url');
	
	ArchiveURL, ArchiveDate = is_unique_archive_url (ArchiveURL, URL, ChapterURL, A:ORIGIN('ArchiveURL'), ArchiveDate);		-- add error message when URL or ChapterURL == ArchiveURL

	local AccessDate = A['AccessDate'];
	local COinS_date = {};														-- holds date info extracted from |date= for the COinS metadata by Module:Date verification
	local DoiBroken = A['DoiBroken'];
	local Embargo = A['Embargo'];
	local anchor_year;															-- used in the CITEREF identifier
	do	-- create defined block to contain local variables error_message, date_parameters_list, mismatch
		local error_message = '';
																				-- AirDate has been promoted to Date so not necessary to check it
		local date_parameters_list = {
			['access-date'] = {val = AccessDate, name = A:ORIGIN ('AccessDate')},
			['archive-date'] = {val = ArchiveDate, name = A:ORIGIN ('ArchiveDate')},
			['date'] = {val = Date, name = Date_origin},
			['doi-broken-date'] = {val = DoiBroken, name = A:ORIGIN ('DoiBroken')},
			['pmc-embargo-date'] = {val = Embargo, name = A:ORIGIN ('Embargo')},
			['publication-date'] = {val = PublicationDate, name = A:ORIGIN ('PublicationDate')},
			['year'] = {val = Year, name = A:ORIGIN ('Year')},
			};

		local error_list = {};
		anchor_year, Embargo = validation.dates(date_parameters_list, COinS_date, error_list);

		if utilities.is_set (Year) and utilities.is_set (Date) then				-- both |date= and |year= not normally needed; 
			validation.year_date_check (Year, A:ORIGIN ('Year'), Date, A:ORIGIN ('Date'), error_list);
		end

		if 0 == #error_list then												-- error free dates only; 0 when error_list is empty
			local modified = false;												-- flag
			
			if utilities.is_set (DF) then										-- if we need to reformat dates
				modified = validation.reformat_dates (date_parameters_list, DF);	-- reformat to DF format, use long month names if appropriate
			end

			if true == validation.date_hyphen_to_dash (date_parameters_list) then	-- convert hyphens to dashes where appropriate
				modified = true;
				utilities.set_message ('maint_date_format');					-- hyphens were converted so add maint category
			end
			
	-- for those wikis that can and want to have English date names translated to the local language; not supported at en.wiki
			if cfg.date_name_auto_xlate_enable and validation.date_name_xlate (date_parameters_list, cfg.date_digit_auto_xlate_enable ) then
				utilities.set_message ('maint_date_auto_xlated');				-- add maint cat
				modified = true;
			end

			if modified then													-- if the date_parameters_list values were modified
				AccessDate = date_parameters_list['access-date'].val;			-- overwrite date holding parameters with modified values
				ArchiveDate = date_parameters_list['archive-date'].val;
				Date = date_parameters_list['date'].val;
				DoiBroken = date_parameters_list['doi-broken-date'].val;
				PublicationDate = date_parameters_list['publication-date'].val;
			end

			if archive_url_timestamp and utilities.is_set (ArchiveDate) then
				validation.archive_date_check (ArchiveDate, archive_url_timestamp, DF);	-- does YYYYMMDD in archive_url_timestamp match date in ArchiveDate
			end
		else
			utilities.set_message ('err_bad_date', {utilities.make_sep_list (#error_list, error_list)});	-- add this error message
		end
	end	-- end of do

	if utilities.in_array (config.CitationClass, {'book', 'encyclopaedia'}) or	-- {{cite book}}, {{cite encyclopedia}}; TODO: {{cite conference}} and others?
		('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) or			-- {{citation}} as an encylopedia citation
		('citation' == config.CitationClass and not utilities.is_set (Periodical)) then		-- {{citation}} as a book citation
			if utilities.is_set (PublicationPlace) then
				if not utilities.is_set (PublisherName) then
					local date = COinS_date.rftdate and tonumber (COinS_date.rftdate:match ('%d%d%d%d'));	-- get year portion of COinS date (because in Arabic numerals); convert string to number
					if date and (1850 &lt;= date) then								-- location has no publisher; if date is 1850 or later
						utilities.set_message ('maint_location_no_publisher');	-- add maint cat
					end
				else															-- PublisherName has a value
					if cfg.keywords_xlate['none'] == PublisherName then			-- if that value is 'none' (only for book and encyclopedia citations)
						PublisherName = '';										-- unset
					end
				end
			end
	end

	local ID_list = {};															-- sequence table of rendered identifiers
	local ID_list_coins = {};													-- table of identifiers and their values from args; key is same as cfg.id_handlers's key
	local Class = A['Class'];													-- arxiv class identifier
	
	local ID_support = {
		{A['ASINTLD'], 'ASIN', 'err_asintld_missing_asin', A:ORIGIN ('ASINTLD')},				
		{DoiBroken, 'DOI', 'err_doibroken_missing_doi', A:ORIGIN ('DoiBroken')},
		{Embargo, 'PMC', 'err_embargo_missing_pmc', A:ORIGIN ('Embargo')},
		}

	ID_list, ID_list_coins = identifiers.identifier_lists_get (args, {DoiBroken = DoiBroken, ASINTLD = A['ASINTLD'], Embargo = Embargo, Class = Class, Year=anchor_year}, ID_support);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite medrxiv}}, {{cite ssrn}}, before generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list_t) then	-- |arxiv= or |eprint= required for cite arxiv; |biorxiv=, |citeseerx=, |medrxiv=, |ssrn= required for their templates
		if not (args[cfg.id_handlers[config.CitationClass:upper()].parameters[1]] or 		-- can't use ID_list_coins k/v table here because invalid parameters omitted
			args[cfg.id_handlers[config.CitationClass:upper()].parameters[2]]) then			-- which causes unexpected parameter missing error message
				utilities.set_message ('err_' .. config.CitationClass .. '_missing');		-- add error message
		end

		Periodical = ({['arxiv'] = 'arXiv', ['biorxiv'] = 'bioRxiv', ['citeseerx'] = 'CiteSeerX', ['medrxiv'] = 'medRxiv', ['ssrn'] = 'Social Science Research Network'})[config.CitationClass];
	end

	-- Link the title of the work if no |url= was provided, but we have a |pmc= or a |doi= with |doi-access=free

	if config.CitationClass == &quot;journal&quot; and not utilities.is_set (URL) and not utilities.is_set (TitleLink) and not utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) then -- TODO: remove 'none' once existing citations have been switched to 'off', so 'none' can be used as token for &quot;no title&quot; instead
		if 'none' ~= cfg.keywords_xlate[auto_select] then						-- if auto-linking not disabled
 	 		if identifiers.auto_link_urls[auto_select] then						-- manual selection
		 		URL = identifiers.auto_link_urls[auto_select];					-- set URL to be the same as identifier's external link
 				URL_origin = cfg.id_handlers[auto_select:upper()].parameters[1];	-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['pmc'] then						-- auto-select PMC
				URL = identifiers.auto_link_urls['pmc'];						-- set URL to be the same as the PMC external link if not embargoed
				URL_origin = cfg.id_handlers['PMC'].parameters[1];				-- set URL_origin to parameter name for use in error message if citation is missing a |title=
			elseif identifiers.auto_link_urls['doi'] then						-- auto-select DOI
				URL = identifiers.auto_link_urls['doi'];
				URL_origin = cfg.id_handlers['DOI'].parameters[1];
			end
 	 	end

		if utilities.is_set (URL) then											-- set when using an identifier-created URL
			if utilities.is_set (AccessDate) then								-- |access-date= requires |url=; identifier-created URL is not |url=
				utilities.set_message ('err_accessdate_missing_url');			-- add an error message
				AccessDate = '';												-- unset
			end

			if utilities.is_set (ArchiveURL) then								-- |archive-url= requires |url=; identifier-created URL is not |url=
				utilities.set_message ('err_archive_missing_url');				-- add an error message
				ArchiveURL = '';												-- unset
			end
		end
	end

	-- At this point fields may be nil if they weren't specified in the template use.  We can use that fact.
	-- Test if citation has no title
	if	not utilities.is_set (Title) and not utilities.is_set (TransTitle) and not utilities.is_set (ScriptTitle) then	-- has special case for cite episode
		utilities.set_message ('err_citation_missing_title', {'episode' == config.CitationClass and 'series' or 'title'});
	end

	if utilities.in_array (cfg.keywords_xlate[Title], {'off', 'none'}) and
			utilities.in_array (config.CitationClass, {'journal', 'citation'}) and
			(utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and
			('journal' == Periodical_origin or 'script-journal' == ScriptPeriodical_origin) then	-- special case for journal cites
				Title = '';														-- set title to empty string
				utilities.set_message ('maint_untitled');						-- add maint cat
	end

	-- COinS metadata (see &lt;http://ocoins.info/&gt;) for automated parsing of citation information.
	-- handle the oddity that is cite encyclopedia and {{citation |encyclopedia=something}}. Here we presume that
	-- when Periodical, Title, and Chapter are all set, then Periodical is the book (encyclopedia) title, Title
	-- is the article title, and Chapter is a section within the article.  So, we remap 
	
	local coins_chapter = Chapter;												-- default assuming that remapping not required
	local coins_title = Title;													-- et tu
	if 'encyclopaedia' == config.CitationClass or ('citation' == config.CitationClass and utilities.is_set (Encyclopedia)) then
		if utilities.is_set (Chapter) and utilities.is_set (Title) and utilities.is_set (Periodical) then		-- if all are used then
			coins_chapter = Title;												-- remap
			coins_title = Periodical;
		end
	end
	local coins_author = a;														-- default for coins rft.au 
	if 0 &lt; #c then																-- but if contributor list
		coins_author = c;														-- use that instead
	end
	
	-- this is the function call to COinS()
	local OCinSoutput = metadata.COinS({
		['Periodical'] = utilities.strip_apostrophe_markup (Periodical),		-- no markup in the metadata
		['Encyclopedia'] = Encyclopedia,										-- just a flag; content ignored by ~/COinS
		['Chapter'] = metadata.make_coins_title (coins_chapter, ScriptChapter),	-- Chapter and ScriptChapter stripped of bold / italic / accept-as-written markup
		['Degree'] = Degree;													-- cite thesis only
		['Title'] = metadata.make_coins_title (coins_title, ScriptTitle),		-- Title and ScriptTitle stripped of bold / italic / accept-as-written markup
		['PublicationPlace'] = PublicationPlace,
		['Date'] = COinS_date.rftdate,											-- COinS_date.* has correctly formatted date values if Date is valid;
		['Season'] = COinS_date.rftssn,
		['Quarter'] = COinS_date.rftquarter,
		['Chron'] =  COinS_date.rftchron,
		['Series'] = Series,
		['Volume'] = Volume,
		['Issue'] = Issue,
		['ArticleNumber'] = ArticleNumber,
		['Pages'] = coins_pages or metadata.get_coins_pages (first_set ({Sheet, Sheets, Page, Pages, At, QuotePage, QuotePages}, 7)),	-- pages stripped of external links
		['Edition'] = Edition,
		['PublisherName'] = PublisherName or Newsgroup,							-- any apostrophe markup already removed from PublisherName
		['URL'] = first_set ({ChapterURL, URL}, 2),
		['Authors'] = coins_author,
		['ID_list'] = ID_list_coins,
		['RawPage'] = this_page.prefixedText,
	}, config.CitationClass);

	-- Account for the oddities that are {{cite arxiv}}, {{cite biorxiv}}, {{cite citeseerx}}, {{cite medrxiv}}, and {{cite ssrn}} AFTER generation of COinS data.
	if utilities.in_array (config.CitationClass, whitelist.preprint_template_list_t) then	-- we have set rft.jtitle in COinS to arXiv, bioRxiv, CiteSeerX, medRxiv, or ssrn now unset so it isn't displayed
		Periodical = '';														-- periodical not allowed in these templates; if article has been published, use cite journal
	end

	-- special case for cite newsgroup.  Do this after COinS because we are modifying Publishername to include some static text
	if 'newsgroup' == config.CitationClass and utilities.is_set (Newsgroup) then
		PublisherName = utilities.substitute (cfg.messages['newsgroup'], external_link( 'news:' .. Newsgroup, Newsgroup, Newsgroup_origin, nil ));
	end

	local Editors;
	local EditorCount;															-- used only for choosing {ed.) or (eds.) annotation at end of editor name-list
	local Contributors;															-- assembled contributors name list
	local contributor_etal;
	local Translators;															-- assembled translators name list
	local translator_etal;
	local t = {};																-- translators list from |translator-lastn= / translator-firstn= pairs
	t = extract_names (args, 'TranslatorList');									-- fetch translator list from |translatorn= / |translator-lastn=, -firstn=, -linkn=, -maskn=
	local Interviewers;															
	local interviewers_list = {};					
	interviewers_list = extract_names (args, 'InterviewerList');				-- process preferred interviewers parameters
	local interviewer_etal;
	
	-- Now perform various field 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.
	do
		local last_first_list;
		local control = { 
			format = NameListStyle,												-- empty string, '&amp;', 'amp', 'and', or 'vanc'
			maximum = nil,														-- as if display-authors or display-editors not set
			mode = Mode
		};

		do																		-- do editor name list first because the now unsupported coauthors used to modify control table
			local display_names, param = display_names_select (cfg.global_cs1_config_t['DisplayEditors'], A['DisplayEditors'], A:ORIGIN ('DisplayEditors'), #e);
			control.maximum, editor_etal = get_display_names (display_names, #e, 'editors', editor_etal, param);

			Editors, EditorCount = list_people (control, e, editor_etal);

			if 1 == EditorCount and (true == editor_etal or 1 &lt; #e) then		-- only one editor displayed but includes etal then 
				EditorCount = 2;												-- spoof to display (eds.) annotation
			end
		end
		do																		-- now do interviewers
			local display_names, param = display_names_select (cfg.global_cs1_config_t['DisplayInterviewers'], A['DisplayInterviewers'], A:ORIGIN ('DisplayInterviewers'), #interviewers_list);
			control.maximum, interviewer_etal = get_display_names (display_names, #interviewers_list, 'interviewers', interviewer_etal, param);

			Interviewers = list_people (control, interviewers_list, interviewer_etal);
		end
		do																		-- now do translators
			local display_names, param = display_names_select (cfg.global_cs1_config_t['DisplayTranslators'], A['DisplayTranslators'], A:ORIGIN ('DisplayTranslators'), #t);
			control.maximum, translator_etal = get_display_names (display_names, #t, 'translators', translator_etal, param);

			Translators = list_people (control, t, translator_etal);
		end
		do																		-- now do contributors
			local display_names, param = display_names_select (cfg.global_cs1_config_t['DisplayContributors'], A['DisplayContributors'], A:ORIGIN ('DisplayContributors'), #c);
			control.maximum, contributor_etal = get_display_names (display_names, #c, 'contributors', contributor_etal, param);

			Contributors = list_people (control, c, contributor_etal);
		end
		do																		-- now do authors
			local display_names, param = display_names_select (cfg.global_cs1_config_t['DisplayAuthors'], A['DisplayAuthors'], A:ORIGIN ('DisplayAuthors'), #a, author_etal);
			control.maximum, author_etal = get_display_names (display_names, #a, 'authors', author_etal, param);

			last_first_list = list_people (control, a, author_etal);

			if utilities.is_set (Authors) then
				Authors, author_etal = name_has_etal (Authors, author_etal, false, 'authors');	-- find and remove variations on et al.
				if author_etal then
					Authors = Authors .. ' ' .. cfg.messages['et al'];			-- add et al. to authors parameter
				end
			else
				Authors = last_first_list;										-- either an author name list or an empty string
			end
		end																		-- end of do
	
		if utilities.is_set (Authors) and utilities.is_set (Collaboration) then
			Authors = Authors .. ' (' .. Collaboration .. ')';					-- add collaboration after et al.
		end

	end

	local ConferenceFormat = A['ConferenceFormat'];
	local ConferenceURL = A['ConferenceURL'];
	ConferenceFormat = style_format (ConferenceFormat, ConferenceURL, 'conference-format', 'conference-url');
	Format = style_format (Format, URL, 'format', 'url');

	-- special case for chapter format so no error message or cat when chapter not supported
	if not (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'medrxiv', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia))) then
			ChapterFormat = style_format (ChapterFormat, ChapterURL, 'chapter-format', 'chapter-url');
	end

	if not utilities.is_set (URL) then
		if utilities.in_array (config.CitationClass, {&quot;web&quot;, &quot;podcast&quot;, &quot;mailinglist&quot;}) or		-- |url= required for cite web, cite podcast, and cite mailinglist
			('citation' == config.CitationClass and ('website' == Periodical_origin or 'script-website' == ScriptPeriodical_origin)) then	-- and required for {{citation}} with |website= or |script-website=
				utilities.set_message ('err_cite_web_url');
		end
		
		-- do we have |accessdate= without either |url= or |chapter-url=?
		if utilities.is_set (AccessDate) and not utilities.is_set (ChapterURL) then		-- ChapterURL may be set when URL is not set;
			utilities.set_message ('err_accessdate_missing_url');
			AccessDate = '';
		end
	end

	local UrlStatus = is_valid_parameter_value (A['UrlStatus'], A:ORIGIN('UrlStatus'), cfg.keywords_lists['url-status'], '');
	local OriginalURL
	local OriginalURL_origin
	local OriginalFormat
	local OriginalAccess;
	UrlStatus = UrlStatus:lower();												-- used later when assembling archived text
	if utilities.is_set ( ArchiveURL ) then
		if utilities.is_set (ChapterURL) then 									-- if chapter-url= is set apply archive url to it
			OriginalURL = ChapterURL;											-- save copy of source chapter's url for archive text
			OriginalURL_origin = ChapterURL_origin;								-- name of |chapter-url= parameter for error messages
			OriginalFormat = ChapterFormat;										-- and original |chapter-format=

			if 'live' ~= UrlStatus then
				ChapterURL = ArchiveURL											-- swap-in the archive's URL
				ChapterURL_origin = A:ORIGIN('ArchiveURL')						-- name of |archive-url= parameter for error messages
				ChapterFormat = ArchiveFormat or '';							-- swap in archive's format
				ChapterUrlAccess = nil;											-- restricted access levels do not make sense for archived URLs
			end
		elseif utilities.is_set (URL) then
			OriginalURL = URL;													-- save copy of original source URL
			OriginalURL_origin = URL_origin;									-- name of URL parameter for error messages
			OriginalFormat = Format; 											-- and original |format=
			OriginalAccess = UrlAccess;

			if 'live' ~= UrlStatus then											-- if URL set then |archive-url= applies to it
				URL = ArchiveURL												-- swap-in the archive's URL
				URL_origin = A:ORIGIN('ArchiveURL')								-- name of archive URL parameter for error messages
				Format = ArchiveFormat or '';									-- swap in archive's format
				UrlAccess = nil;												-- restricted access levels do not make sense for archived URLs
			end
		end
	elseif utilities.is_set (UrlStatus) then									-- if |url-status= is set when |archive-url= is not set
 		utilities.set_message ('maint_url_status');								-- add maint cat
	end

	if utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'pressrelease', 'podcast', 'newsgroup', 'arxiv', 'biorxiv', 'citeseerx', 'medrxiv', 'ssrn'}) or	-- if any of the 'periodical' cites except encyclopedia
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) then
			local chap_param;
			if utilities.is_set (Chapter) then									-- get a parameter name from one of these chapter related meta-parameters
				chap_param = A:ORIGIN ('Chapter')
			elseif utilities.is_set (TransChapter) then
				chap_param = A:ORIGIN ('TransChapter')
			elseif utilities.is_set (ChapterURL) then
				chap_param = A:ORIGIN ('ChapterURL')
			elseif utilities.is_set (ScriptChapter) then
				chap_param = ScriptChapter_origin;
			else utilities.is_set (ChapterFormat)
				chap_param = A:ORIGIN ('ChapterFormat')
			end

			if utilities.is_set (chap_param) then								-- if we found one
				utilities.set_message ('err_chapter_ignored', {chap_param});	-- add error message
				Chapter = '';													-- and set them to empty string to be safe with concatenation
				TransChapter = '';
				ChapterURL = '';
				ScriptChapter = '';
				ChapterFormat = '';
			end
	else																		-- otherwise, format chapter / article title
		local no_quotes = false;												-- default assume that we will be quoting the chapter parameter value
		if utilities.is_set (Contribution) and 0 &lt; #c then						-- if this is a contribution with contributor(s)
			if utilities.in_array (Contribution:lower(), cfg.keywords_lists.contribution) then	-- and a generic contribution title
				no_quotes = true;												-- then render it unquoted
			end
		end

		Chapter = format_chapter_title (ScriptChapter, ScriptChapter_origin, Chapter, Chapter_origin, TransChapter, TransChapter_origin, ChapterURL, ChapterURL_origin, no_quotes, ChapterUrlAccess);		-- Contribution is also in Chapter
		if utilities.is_set (Chapter) then
			Chapter = Chapter .. ChapterFormat ;
			if 'map' == config.CitationClass and utilities.is_set (TitleType) then
				Chapter = Chapter .. ' ' .. TitleType;							-- map annotation here; not after title
			end
			Chapter = Chapter .. sepc .. ' ';
		elseif utilities.is_set (ChapterFormat) then							-- |chapter= not set but |chapter-format= is so ...
			Chapter = ChapterFormat .. sepc .. ' ';								-- ... ChapterFormat has error message, we want to see it
		end
	end

	-- Format main title
	local plain_title = false;
	local accept_title;
	Title, accept_title = utilities.has_accept_as_written (Title, true);		-- remove accept-this-as-written markup when it wraps all of &lt;Title&gt;
	if accept_title and ('' == Title) then										-- only support forced empty for now &quot;(())&quot;
		Title = cfg.messages['notitle'];										-- replace by predefined &quot;No title&quot; message
			-- TODO: utilities.set_message ( 'err_redundant_parameters', ...);	-- issue proper error message instead of muting	 
			ScriptTitle = '';													-- just mute for now	 
			TransTitle = '';													-- just mute for now
 		plain_title = true;														-- suppress text decoration for descriptive title
		utilities.set_message ('maint_untitled');								-- add maint cat
	end

	if not accept_title then													-- &lt;Title&gt; not wrapped in accept-as-written markup
		if '...' == Title:sub (-3) then											-- if ellipsis is the last three characters of |title=
			Title = Title:gsub ('(%.%.%.)%.+$', '%1');							-- limit the number of dots to three
		elseif not mw.ustring.find (Title, '%.%s*%a%.$') and					-- end of title is not a 'dot-(optional space-)letter-dot' initialism ...
			not mw.ustring.find (Title, '%s+%a%.$') then						-- ...and not a 'space-letter-dot' initial (''Allium canadense'' L.)
				Title = mw.ustring.gsub(Title, '%' .. sepc .. '$', '');			-- remove any trailing separator character; sepc and ms.ustring() here for languages that use multibyte separator characters
		end

		if utilities.is_set (ArchiveURL) and is_archived_copy (Title) then
			utilities.set_message ('maint_archived_copy');						-- add maintenance category before we modify the content of Title
		end

		if is_generic ('generic_titles', Title) then
			utilities.set_message ('err_generic_title');						-- set an error message
		end
	end

	if (not plain_title) and (utilities.in_array (config.CitationClass, {'web', 'news', 'journal', 'magazine', 'document', 'pressrelease', 'podcast', 'newsgroup', 'mailinglist', 'interview', 'arxiv', 'biorxiv', 'citeseerx', 'medrxiv', 'ssrn'}) or
		('citation' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)) and not utilities.is_set (Encyclopedia)) or
		('map' == config.CitationClass and (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical)))) then		-- special case for cite map when the map is in a periodical treat as an article
			Title = kern_quotes (Title);										-- if necessary, separate title's leading and trailing quote marks from module provided quote marks
			Title = utilities.wrap_style ('quoted-title', Title);
			Title = script_concatenate (Title, ScriptTitle, 'script-title');	-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
			TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );
	elseif plain_title or ('report' == config.CitationClass) then				-- no styling for cite report and descriptive titles (otherwise same as above)
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-quoted-title', TransTitle );	-- for cite report, use this form for trans-title
	else
		Title = utilities.wrap_style ('italic-title', Title);
		Title = script_concatenate (Title, ScriptTitle, 'script-title');		-- &lt;bdi&gt; tags, lang attribute, categorization, etc.; must be done after title is wrapped
		TransTitle = utilities.wrap_style ('trans-italic-title', TransTitle);
	end

	if utilities.is_set (TransTitle) then
		if utilities.is_set (Title) then
			TransTitle = &quot; &quot; .. TransTitle;
		else
			utilities.set_message ('err_trans_missing_title', {'title'});
		end
	end

	if utilities.is_set (Title) then											-- TODO: is this the right place to be making Wikisource URLs?
		if utilities.is_set (TitleLink) and utilities.is_set (URL) then
			utilities.set_message ('err_wikilink_in_url');						-- set an error message because we can't have both
			TitleLink = '';														-- unset
		end
	
		if not utilities.is_set (TitleLink) and utilities.is_set (URL) then
			Title = external_link (URL, Title, URL_origin, UrlAccess) .. TransTitle .. Format;
			URL = '';															-- unset these because no longer needed
			Format = &quot;&quot;;
		elseif utilities.is_set (TitleLink) and not utilities.is_set (URL) then
			local ws_url;
			ws_url = wikisource_url_make (TitleLink);							-- ignore ws_label return; not used here
			if ws_url then
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title-link');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], TitleLink, Title});				
				Title = Title .. TransTitle;
			else
				Title = utilities.make_wikilink (TitleLink, Title) .. TransTitle;
			end
		else
			local ws_url, ws_label, L;											-- Title has italic or quote markup by the time we get here which causes is_wikilink() to return 0 (not a wikilink)
			ws_url, ws_label, L = wikisource_url_make (Title:gsub('^[\'&quot;]*(.-)[\'&quot;]*$', '%1'));	-- make ws URL from |title= interwiki link (strip italic or quote markup); link portion L becomes tooltip label
			if ws_url then
				Title = Title:gsub ('%b[]', ws_label);							-- replace interwiki link with ws_label to retain markup
				Title = external_link (ws_url, Title .. '&amp;nbsp;', 'ws link in title');	-- space char after Title to move icon away from italic text; TODO: a better way to do this?
				Title = utilities.substitute (cfg.presentation['interwiki-icon'], {cfg.presentation['class-wikisource'], L, Title});				
				Title = Title .. TransTitle;
			else
				Title = Title .. TransTitle;
			end
		end
	else
		Title = TransTitle;
	end

	if utilities.is_set (Place) then
		Place = &quot; &quot; .. wrap_msg ('written', Place, use_lowercase) .. sepc .. &quot; &quot;;
	end

	local ConferenceURL_origin = A:ORIGIN('ConferenceURL');						-- get name of parameter that holds ConferenceURL
	if utilities.is_set (Conference) then
		if utilities.is_set (ConferenceURL) then
			Conference = external_link( ConferenceURL, Conference, ConferenceURL_origin, nil );
		end
		Conference = sepc .. &quot; &quot; .. Conference .. ConferenceFormat;
	elseif utilities.is_set (ConferenceURL) then
		Conference = sepc .. &quot; &quot; .. external_link( ConferenceURL, nil, ConferenceURL_origin, nil );
	end

	local Position = '';
	if not utilities.is_set (Position) then
		local Minutes = A['Minutes'];
		local Time = A['Time'];

		if utilities.is_set (Minutes) then
			if utilities.is_set (Time) then		--TODO: make a function for this and similar?
				utilities.set_message ('err_redundant_parameters', {utilities.wrap_style ('parameter', 'minutes') .. cfg.presentation['sep_list_pair'] .. utilities.wrap_style ('parameter', 'time')});
			end
			Position = &quot; &quot; .. Minutes .. &quot; &quot; .. cfg.messages['minutes'];
		else
			if utilities.is_set (Time) then
				local TimeCaption = A['TimeCaption']
				if not utilities.is_set (TimeCaption) then
					TimeCaption = cfg.messages['event'];
					if sepc ~= '.' then
						TimeCaption = TimeCaption:lower();
					end
				end
				Position = &quot; &quot; .. TimeCaption .. &quot; &quot; .. Time;
			end
		end
	else
		Position = &quot; &quot; .. Position;
		At = '';
	end

	Page, Pages, Sheet, Sheets = format_pages_sheets (Page, Pages, Sheet, Sheets, config.CitationClass, Periodical_origin, sepc, NoPP, use_lowercase);

	At = utilities.is_set (At) and (sepc .. &quot; &quot; .. At) or &quot;&quot;;
	Position = utilities.is_set (Position) and (sepc .. &quot; &quot; .. Position) or &quot;&quot;;
	if config.CitationClass == 'map' then
		local Sections = A['Sections'];											-- Section (singular) is an alias of Chapter so set earlier
		local Inset = A['Inset'];
		
		if utilities.is_set ( Inset ) then
			Inset = sepc .. &quot; &quot; .. wrap_msg ('inset', Inset, use_lowercase);
		end			

		if utilities.is_set ( Sections ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('sections', Sections, use_lowercase);
		elseif utilities.is_set ( Section ) then
			Section = sepc .. &quot; &quot; .. wrap_msg ('section', Section, use_lowercase);
		end
		At = At .. Inset .. Section;		
	end	

	local Others = A['Others'];
	if utilities.is_set (Others) and 0 == #a and 0 == #e then					-- add maint cat when |others= has value and used without |author=, |editor=
		if config.CitationClass == &quot;AV-media-notes&quot;
		or config.CitationClass == &quot;audio-visual&quot; then							-- special maint for AV/M which has a lot of 'false' positives right now
			utilities.set_message ('maint_others_avm')
		else
			utilities.set_message ('maint_others');
		end
	end
	Others = utilities.is_set (Others) and (sepc .. &quot; &quot; .. Others) or &quot;&quot;;
	
	if utilities.is_set (Translators) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('translated', Translators, use_lowercase), Others}, sepc);
	end
	if utilities.is_set (Interviewers) then
		Others = safe_join ({sepc .. ' ', wrap_msg ('interview', Interviewers, use_lowercase), Others}, sepc);
	end
	
	local TitleNote = A['TitleNote'];
	TitleNote = utilities.is_set (TitleNote) and (sepc .. &quot; &quot; .. TitleNote) or &quot;&quot;;
	if utilities.is_set (Edition) then
		if Edition:match ('%f[%a][Ee]d%n?%.?$') or Edition:match ('%f[%a][Ee]dition$') then -- Ed, ed, Ed., ed., Edn, edn, Edn., edn.
			utilities.set_message ('err_extra_text_edition');					 -- add error message
		end
		Edition = &quot; &quot; .. wrap_msg ('edition', Edition);
	else
		Edition = '';
	end

	Series = utilities.is_set (Series) and wrap_msg ('series', {sepc, Series}) or &quot;&quot;;	-- not the same as SeriesNum
	local Agency = A['Agency'] or '';											-- |agency= is supported by {{cite magazine}}, {{cite news}}, {{cite press release}}, {{cite web}}, and certain {{citation}} templates
	if utilities.is_set (Agency) then											-- this testing done here because {{citation}} supports 'news' citations
		if utilities.in_array (config.CitationClass, {'magazine', 'news', 'pressrelease', 'web'}) or ('citation' == config.CitationClass and utilities.in_array (Periodical_origin, {&quot;magazine&quot;, &quot;newspaper&quot;, &quot;work&quot;})) then
			Agency = wrap_msg ('agency', {sepc, Agency});						-- format for rendering
		else
			Agency = '';														-- unset; not supported
			utilities.set_message ('err_parameter_ignored', {'agency'});		-- add error message
		end
	end
	
	Volume = format_volume_issue (Volume, Issue, ArticleNumber, config.CitationClass, Periodical_origin, sepc, use_lowercase);

	if utilities.is_set (AccessDate) then
		local retrv_text = &quot; &quot; .. cfg.messages['retrieved']

		AccessDate = nowrap_date (AccessDate);									-- wrap in nowrap span if date in appropriate format
		if (sepc ~= &quot;.&quot;) then retrv_text = retrv_text:lower() end				-- if mode is cs2, lower case
		AccessDate = utilities.substitute (retrv_text, AccessDate);				-- add retrieved text

		AccessDate = utilities.substitute (cfg.presentation['accessdate'], {sepc, AccessDate});	-- allow editors to hide accessdates
	end
	
	if utilities.is_set (ID) then ID = sepc .. &quot; &quot; .. ID; end
	
	local Docket = A['Docket'];
   	if &quot;thesis&quot; == config.CitationClass and utilities.is_set (Docket) then
		ID = sepc .. &quot; Docket &quot; .. Docket .. ID;
	end
   	if &quot;report&quot; == config.CitationClass and utilities.is_set (Docket) then		-- for cite report when |docket= is set
		ID = sepc .. ' ' .. Docket;												-- overwrite ID even if |id= is set
	end

	if utilities.is_set (URL) then
		URL = &quot; &quot; .. external_link( URL, nil, URL_origin, UrlAccess );
	end
	
	-- We check length of PostScript here because it will have been nuked by
	-- the quote parameters. We'd otherwise emit a message even if there wasn't
	-- a displayed postscript.
	-- TODO: Should the max size (1) be configurable?
	-- TODO: Should we check a specific pattern?
	if utilities.is_set(PostScript) and mw.ustring.len(PostScript) &gt; 1 then
		utilities.set_message ('maint_postscript')
	end
	
	local Archived;
	if utilities.is_set (ArchiveURL) then
		if not utilities.is_set (ArchiveDate) then								-- ArchiveURL set but ArchiveDate not set
			utilities.set_message ('err_archive_missing_date');					-- emit an error message
			ArchiveURL = '';													-- empty string for concatenation
			ArchiveDate = '';													-- empty string for concatenation
		end
	else														
		if utilities.is_set (ArchiveDate) then									-- ArchiveURL not set but ArchiveDate is set
			utilities.set_message ('err_archive_date_missing_url');				-- emit an error message
			ArchiveURL = '';													-- empty string for concatenation
			ArchiveDate = '';													-- empty string for concatenation
		end
	end

	if utilities.is_set (ArchiveURL) then
		local arch_text;
		if &quot;live&quot; == UrlStatus then
			arch_text = cfg.messages['archived'];
			if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
			if utilities.is_set (ArchiveDate) then
				Archived = sepc .. ' ' .. utilities.substitute ( cfg.messages['archived-live'],
					{external_link( ArchiveURL, arch_text, A:ORIGIN('ArchiveURL'), nil) .. ArchiveFormat, ArchiveDate } );
			else
				Archived = '';
			end
			if not utilities.is_set (OriginalURL) then
				utilities.set_message ('err_archive_missing_url');
				Archived = '';													-- empty string for concatenation
			end
		elseif utilities.is_set (OriginalURL) then								-- UrlStatus is empty, 'dead', 'unfit', 'usurped', 'bot: unknown'
			if utilities.in_array (UrlStatus, {'unfit', 'usurped', 'bot: unknown'}) then
				arch_text = cfg.messages['archived-unfit'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				Archived = sepc .. ' ' .. arch_text .. ArchiveDate;				-- format already styled
				if 'bot: unknown' == UrlStatus then
					utilities.set_message ('maint_bot_unknown');				-- and add a category if not already added
				else
					utilities.add_prop_cat ('unfit');							-- and add a category if not already added
				end
			else																-- UrlStatus is empty, 'dead'
				arch_text = cfg.messages['archived-dead'];
				if sepc ~= &quot;.&quot; then arch_text = arch_text:lower() end
				if utilities.is_set (ArchiveDate) then
					Archived = sepc .. &quot; &quot; .. utilities.substitute ( arch_text,
						{ external_link( OriginalURL, cfg.messages['original'], OriginalURL_origin, OriginalAccess ) .. OriginalFormat, ArchiveDate } );	-- format already styled
				else
					Archived = '';												-- unset for concatenation
				end
			end	
		else																	-- OriginalUrl not set
			utilities.set_message ('err_archive_missing_url');
			Archived = '';														-- empty string for concatenation
		end
	elseif utilities.is_set (ArchiveFormat) then
		Archived = ArchiveFormat;												-- if set and ArchiveURL not set ArchiveFormat has error message
	else
		Archived = '';
	end
	
	local TranscriptURL = A['TranscriptURL']
	local TranscriptFormat = A['TranscriptFormat'];
	TranscriptFormat = style_format (TranscriptFormat, TranscriptURL, 'transcript-format', 'transcripturl');
	local Transcript = A['Transcript'];
	local TranscriptURL_origin = A:ORIGIN('TranscriptURL');						-- get name of parameter that holds TranscriptURL
	if utilities.is_set (Transcript) then
		if utilities.is_set (TranscriptURL) then
			Transcript = external_link( TranscriptURL, Transcript, TranscriptURL_origin, nil );
		end
		Transcript = sepc .. ' ' .. Transcript .. TranscriptFormat;
	elseif utilities.is_set (TranscriptURL) then
		Transcript = external_link( TranscriptURL, nil, TranscriptURL_origin, nil );
	end

	local Publisher;
	if utilities.is_set (PublicationDate) then
		PublicationDate = wrap_msg ('published', PublicationDate);
	end
	if utilities.is_set (PublisherName) then
		if utilities.is_set (PublicationPlace) then
			Publisher = sepc .. &quot; &quot; .. PublicationPlace .. &quot;: &quot; .. PublisherName .. PublicationDate;
		else
			Publisher = sepc .. &quot; &quot; .. PublisherName .. PublicationDate;  
		end			
	elseif utilities.is_set (PublicationPlace) then 
		Publisher= sepc .. &quot; &quot; .. PublicationPlace .. PublicationDate;
	else 
		Publisher = PublicationDate;
	end
	
	-- Several of the above rely upon detecting this as nil, so do it last.
	if (utilities.is_set (Periodical) or utilities.is_set (ScriptPeriodical) or utilities.is_set (TransPeriodical)) then
		if utilities.is_set (Title) or utilities.is_set (TitleNote) then 
			Periodical = sepc .. &quot; &quot; .. format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		else 
			Periodical = format_periodical (ScriptPeriodical, ScriptPeriodical_origin, Periodical, TransPeriodical, TransPeriodical_origin);
		end
	end
	
	local Language = A['Language'];
	if utilities.is_set (Language) then
		Language = language_parameter (Language);								-- format, categories, name from ISO639-1, etc.
	else
		Language='';															-- language not specified so make sure this is an empty string;
	--[[ TODO: need to extract the wrap_msg from language_parameter
	so that we can solve parentheses bunching problem with Format/Language/TitleType
	]]
	end

	--[[
	Handle the oddity that is cite speech.  This code overrides whatever may be the value assigned to TitleNote (through |department=) and forces it to be &quot; (Speech)&quot; so that
	the annotation directly follows the |title= parameter value in the citation rather than the |event= parameter value (if provided).
	]]
	if &quot;speech&quot; == config.CitationClass then									-- cite speech only
		TitleNote = TitleType;													-- move TitleType to TitleNote so that it renders ahead of |event=
		TitleType = '';															-- and unset

		if utilities.is_set (Periodical) then									-- if Periodical, perhaps because of an included |website= or |journal= parameter 
			if utilities.is_set (Conference) then								-- and if |event= is set
				Conference = Conference .. sepc .. &quot; &quot;;							-- then add appropriate punctuation to the end of the Conference variable before rendering
			end
		end
	end

	-- Piece all bits together at last.  Here, all should be 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 tcommon;
	local tcommon2;																-- used for book cite when |contributor= is set
	
	if utilities.in_array (config.CitationClass, {&quot;book&quot;, &quot;citation&quot;}) and not utilities.is_set (Periodical) then		-- special cases for book cites
		if utilities.is_set (Contributors) then									-- when we are citing foreword, preface, introduction, etc.
			tcommon = safe_join ({Title, TitleNote}, sepc);						-- author and other stuff will come after this and before tcommon2
			tcommon2 = safe_join ({TitleType, Series, Language, Volume, Others, Edition, Publisher}, sepc);
		else
			tcommon = safe_join ({Title, TitleNote, TitleType, Series, Language, Volume, Others, Edition, Publisher}, sepc);
		end

	elseif 'map' == config.CitationClass then									-- special cases for cite map
		if utilities.is_set (Chapter) then										-- map in a book; TitleType is part of Chapter
			tcommon = safe_join ({Title, Edition, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc);
		elseif utilities.is_set (Periodical) then								-- map in a periodical
			tcommon = safe_join ({Title, TitleType, Periodical, Scale, Series, Language, Cartography, Others, Publisher, Volume}, sepc);
		else																	-- a sheet or stand-alone map
			tcommon = safe_join ({Title, TitleType, Edition, Scale, Series, Language, Cartography, Others, Publisher}, sepc);
		end
		
	elseif 'episode' == config.CitationClass then								-- special case for cite episode
		tcommon = safe_join ({Title, TitleNote, TitleType, Series, Language, Edition, Publisher}, sepc);

	else																		-- all other CS1 templates
		tcommon = safe_join ({Title, TitleNote, Conference, Periodical, TitleType, Series, Language, Volume, Others, Edition, Publisher, Agency}, sepc);
	end
	
	if #ID_list &gt; 0 then
		ID_list = safe_join( { sepc .. &quot; &quot;,  table.concat( ID_list, sepc .. &quot; &quot; ), ID }, sepc );
	else
		ID_list = ID;
	end
	
	local Via = A['Via'];
	Via = utilities.is_set (Via) and  wrap_msg ('via', Via) or '';
	local idcommon;
	if 'audio-visual' == config.CitationClass or 'episode' == config.CitationClass then	-- special case for cite AV media &amp; cite episode position transcript
		idcommon = safe_join( { ID_list, URL, Archived, Transcript, AccessDate, Via, Quote }, sepc );
	else
		idcommon = safe_join( { ID_list, URL, Archived, AccessDate, Via, Quote }, sepc );
	end
	
	local text;
	local pgtext = Position .. Sheet .. Sheets .. Page .. Pages .. At;

	local OrigDate = A['OrigDate'];
	OrigDate = utilities.is_set (OrigDate) and wrap_msg ('origdate', OrigDate) or '';
	if utilities.is_set (Date) then
		if utilities.is_set (Authors) or utilities.is_set (Editors) then		-- date follows authors or editors when authors not set
			Date = &quot; (&quot; .. Date .. &quot;)&quot; .. OrigDate .. sepc .. &quot; &quot;;				-- in parentheses
		else																	-- neither of authors and editors set
			if (string.sub(tcommon, -1, -1) == sepc) then						-- if the last character of tcommon is sepc
				Date = &quot; &quot; .. Date .. OrigDate;									-- Date does not begin with sepc
			else
				Date = sepc .. &quot; &quot; .. Date .. OrigDate;							-- Date begins with sepc
			end
		end
	end	
	if utilities.is_set (Authors) then
		if (not utilities.is_set (Date)) then									-- when date is set it's in parentheses; no Authors termination
			Authors = terminate_name_list (Authors, sepc);						-- when no date, terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Editors) then
			local in_text = '';
			local post_text = '';
			if utilities.is_set (Chapter) and 0 == #c then
				in_text = cfg.messages['in'] .. ' ';
				if (sepc ~= '.') then
					in_text = in_text:lower();									-- lowercase for cs2
				end
			end
			if EditorCount &lt;= 1 then
				post_text = ' (' .. cfg.messages['editor'] .. ')';				-- be consistent with no-author, no-date case
			else
				post_text = ' (' .. cfg.messages['editors'] .. ')';
			end
			Editors = terminate_name_list (in_text .. Editors .. post_text, sepc);	-- terminate with 0 or 1 sepc and a space
		end
		if utilities.is_set (Contributors) then									-- book cite and we're citing the intro, preface, etc.
			local by_text = sepc .. ' ' .. cfg.messages['by'] .. ' ';
			if (sepc ~= '.') then by_text = by_text:lower() end					-- lowercase for cs2
			Authors = by_text .. Authors;										-- author follows title so tweak it here
			if utilities.is_set (Editors) and utilities.is_set (Date) then		-- when Editors make sure that Authors gets terminated
				Authors = terminate_name_list (Authors, sepc);					-- terminate with 0 or 1 sepc and a space
			end
			if (not utilities.is_set (Date)) then								-- when date is set it's in parentheses; no Contributors termination
				Contributors = terminate_name_list (Contributors, sepc);		-- terminate with 0 or 1 sepc and a space
			end
			text = safe_join( {Contributors, Date, Chapter, tcommon, Authors, Place, Editors, tcommon2, pgtext, idcommon }, sepc );
		else
			text = safe_join( {Authors, Date, Chapter, Place, Editors, tcommon, pgtext, idcommon }, sepc );
		end
	elseif utilities.is_set (Editors) then
		if utilities.is_set (Date) then
			if EditorCount &lt;= 1 then
				Editors = Editors .. cfg.presentation['sep_name'] .. cfg.messages['editor'];
			else
				Editors = Editors .. cfg.presentation['sep_name'] .. cfg.messages['editors'];
			end
		else
			if EditorCount &lt;= 1 then
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editor'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			else
				Editors = Editors .. &quot; (&quot; .. cfg.messages['editors'] .. &quot;)&quot; .. sepc .. &quot; &quot;
			end
		end
		text = safe_join( {Editors, Date, Chapter, Place, tcommon, pgtext, idcommon}, sepc );
	else
		if utilities.in_array (config.CitationClass, {&quot;journal&quot;, &quot;citation&quot;}) and utilities.is_set (Periodical) then
			text = safe_join( {Chapter, Place, tcommon, pgtext, Date, idcommon}, sepc );
		else
			text = safe_join( {Chapter, Place, tcommon, Date, pgtext, idcommon}, sepc );
		end
	end

	if utilities.is_set (PostScript) and PostScript ~= sepc then
		text = safe_join( {text, sepc}, sepc ); 								-- Deals with italics, spaces, etc.
		if '.' == sepc then														-- remove final seperator if present
			text = text:gsub ('%' .. sepc .. '$', '');							-- dot must be escaped here
		else
			text = mw.ustring.gsub (text, sepc .. '$', '');						-- using ustring for non-dot sepc (likely a non-Latin character)
		end
	end	
	
	text = safe_join( {text, PostScript}, sepc );

	-- Now enclose the whole thing in a &lt;cite&gt; element
	local options_t = {};
	options_t.class = cite_class_attribute_make (config.CitationClass, Mode);

	local Ref = is_valid_parameter_value (A['Ref'], A:ORIGIN('Ref'), cfg.keywords_lists['ref'], nil, true);	-- nil when |ref=harv; A['Ref'] else

	if 'none' ~= cfg.keywords_xlate[(Ref and Ref:lower()) or ''] then
		local namelist_t = {};													-- holds selected contributor, author, editor name list
		local year = first_set ({Year, anchor_year}, 2);						-- Year first for legacy citations and for YMD dates that require disambiguation

		if #c &gt; 0 then															-- if there is a contributor list
			namelist_t = c;														-- select it
		elseif #a &gt; 0 then														-- or an author list
			namelist_t = a;
		elseif #e &gt; 0 then														-- or an editor list
			namelist_t = e;
		end
		local citeref_id;
		if #namelist_t &gt; 0 then													-- if there are names in namelist_t
			citeref_id = make_citeref_id (namelist_t, year);					-- go make the CITEREF anchor
			if mw.uri.anchorEncode (citeref_id) == ((Ref and mw.uri.anchorEncode (Ref)) or '') then	-- Ref may already be encoded (by {{sfnref}}) so citeref_id must be encoded before comparison
				utilities.set_message ('maint_ref_duplicates_default');
			end
		else
			citeref_id = '';													-- unset
		end
		options_t.id = Ref or citeref_id;
	end

	if string.len (text:gsub('%b&lt;&gt;', '')) &lt;= 2 then								-- remove html and html-like tags; then get length of what remains; 
		z.error_cats_t = {};													-- blank the categories list
		z.error_msgs_t = {};													-- blank the error messages list
		OCinSoutput = nil;														-- blank the metadata string
		text = '';																-- blank the the citation
		utilities.set_message ('err_empty_citation');							-- set empty citation message and category
	end
	
	local render_t = {};														-- here we collect the final bits for concatenation into the rendered citation

	if utilities.is_set (options_t.id) then										-- here we wrap the rendered citation in &lt;cite ...&gt;...&lt;/cite&gt; tags
		table.insert (render_t, utilities.substitute (cfg.presentation['cite-id'], {mw.uri.anchorEncode(options_t.id), mw.text.nowiki(options_t.class), text}));	-- when |ref= is set or when there is a namelist
	else
		table.insert (render_t, utilities.substitute (cfg.presentation['cite'], {mw.text.nowiki(options_t.class), text}));	-- when |ref=none or when namelist_t empty and |ref= is missing or is empty
	end		

	if OCinSoutput then															-- blanked when citation is 'empty' so don't bother to add boilerplate metadata span
		table.insert (render_t, utilities.substitute (cfg.presentation['ocins'], OCinSoutput));	-- format and append metadata to the citation
	end

	local template_name = ('citation' == config.CitationClass) and 'citation' or 'cite ' .. (cfg.citation_class_map_t[config.CitationClass] or config.CitationClass);
	local template_link = '[[Template:' .. template_name .. '|' .. template_name .. ']]';
	local msg_prefix = '&lt;code class=&quot;cs1-code&quot;&gt;{{' .. template_link .. '}}&lt;/code&gt;: ';

	if 0 ~= #z.error_msgs_t then
		mw.addWarning (utilities.substitute (cfg.messages.warning_msg_e, template_link));

		table.insert (render_t, ' ');											-- insert a space between citation and its error messages
		table.sort (z.error_msgs_t);											-- sort the error messages list; sorting includes wrapping &lt;span&gt; and &lt;code&gt; tags; hidden-error sorts ahead of visible-error

		local hidden = true;													-- presume that the only error messages emited by this template are hidden
		for _, v in ipairs (z.error_msgs_t) do									-- spin through the list of error messages
			if v:find ('cs1-visible-error', 1, true) then						-- look for the visible error class name
				hidden = false;													-- found one; so don't hide the error message prefix
				break;															-- and done because no need to look further
			end
		end

		z.error_msgs_t[1] = table.concat ({utilities.error_comment (msg_prefix, hidden), z.error_msgs_t[1]});	-- add error message prefix to first error message to prevent extraneous punctuation
		table.insert (render_t, table.concat (z.error_msgs_t, '; '));			-- make a big string of error messages and add it to the rendering
	end

	if 0 ~= #z.maint_cats_t then
		mw.addWarning (utilities.substitute (cfg.messages.warning_msg_m, template_link));

		table.sort (z.maint_cats_t);											-- sort the maintenance messages list

		local maint_msgs_t = {};												-- here we collect all of the maint messages

		if 0 == #z.error_msgs_t then											-- if no error messages
			table.insert (maint_msgs_t, msg_prefix);							-- insert message prefix in maint message livery
		end
		
		for _, v in ipairs( z.maint_cats_t ) do									-- append maintenance categories
			table.insert (maint_msgs_t, 										-- assemble new maint message and add it to the maint_msgs_t table
				table.concat ({v, ' (', utilities.substitute (cfg.messages[':cat wikilink'], v), ')'})
				);
		end
		table.insert (render_t, utilities.substitute (cfg.presentation['hidden-maint'], table.concat (maint_msgs_t, ' ')));	-- wrap the group of maint messages with proper presentation and save
	end

	if not no_tracking_cats then
		local sort_key;
		local cat_wikilink = 'cat wikilink';
		if cfg.enable_sort_keys then											-- when namespace sort keys enabled
			local namespace_number = mw.title.getCurrentTitle().namespace;		-- get namespace number for this wikitext
			sort_key = (0 ~= namespace_number and (cfg.name_space_sort_keys[namespace_number] or cfg.name_space_sort_keys.other)) or nil;	-- get sort key character; nil for mainspace
			cat_wikilink = (not sort_key and 'cat wikilink') or 'cat wikilink sk';	-- make &lt;cfg.messages&gt; key
		end				

		for _, v in ipairs (z.error_cats_t) do									-- append error categories
			table.insert (render_t, utilities.substitute (cfg.messages[cat_wikilink], {v, sort_key}));
		end
		if cfg.id_limits_data_load_fail then									-- boolean true when load failed
			utilities.set_message ('maint_id_limit_load_fail');					-- done here because this maint cat emits no message
		end
		for _, v in ipairs (z.maint_cats_t) do									-- append maintenance categories
			table.insert (render_t, utilities.substitute (cfg.messages[cat_wikilink], {v, sort_key}));
		end
		for _, v in ipairs (z.prop_cats_t) do									-- append properties categories
			table.insert (render_t, utilities.substitute (cfg.messages['cat wikilink'], v));	-- no sort keys
		end
	end

	return table.concat (render_t);												-- make a big string and done
end


--[[--------------------------&lt; V A L I D A T E &gt;--------------------------------------------------------------

Looks for a parameter's name in one of several whitelists.

Parameters in the whitelist can have three values:
	true - active, supported parameters
	false - deprecated, supported parameters
	nil - unsupported parameters
	
]]

local function validate (name, cite_class, empty)
	local name = tostring (name);
	local enum_name;															-- parameter name with enumerator (if any) replaced with '#'
	local state;
	local function state_test (state, name)										-- local function to do testing of state values
		if true == state then return true; end									-- valid actively supported parameter
		if false == state then
			if empty then return nil; end										-- empty deprecated parameters are treated as unknowns
			deprecated_parameter (name);										-- parameter is deprecated but still supported
			return true;
		end
		if 'tracked' == state then
			local base_name = name:gsub ('%d', '');								-- strip enumerators from parameter names that have them to get the base name
			utilities.add_prop_cat ('tracked-param', {base_name}, base_name);	-- add a properties category; &lt;base_name&gt; modifies &lt;key&gt;
			return true;
		end
		return nil;
	end		

	if name:find ('#') then														-- # is a cs1|2 reserved character so parameters with # not permitted
		return nil;
	end
																				-- replace enumerator digit(s) with # (|last25= becomes |last#=) (mw.ustring because non-Western 'local' digits)
	enum_name = mw.ustring.gsub (name, '%d+$', '#');							-- where enumerator is last charaters in parameter name (these to protect |s2cid=)
	enum_name = mw.ustring.gsub (enum_name, '%d+([%-l])', '#%1');				-- where enumerator is in the middle of the parameter name; |author#link= is the oddity

	if 'document' == cite_class then											-- special case for {{cite document}}
		state = whitelist.document_parameters_t[enum_name];						-- this list holds enumerated and nonenumerated parameters
		if true == state_test (state, name) then return true; end
		
		return false;
	end

	if utilities.in_array (cite_class, whitelist.preprint_template_list_t) then	-- limited parameter sets allowed for these templates
		state = whitelist.limited_parameters_t[enum_name];						-- this list holds enumerated and nonenumerated parameters
		if true == state_test (state, name) then return true; end

		state = whitelist.preprint_arguments_t[cite_class][name];				-- look in the parameter-list for the template identified by cite_class
		if true == state_test (state, name) then return true; end

		return false;															-- not supported because not found or name is set to nil
	end																			-- end limited parameter-set templates

	if utilities.in_array (cite_class, whitelist.unique_param_template_list_t) then 	-- template-specific parameters for templates that accept parameters from the basic argument list
		state = whitelist.unique_arguments_t[cite_class][name];					-- look in the template-specific parameter-lists for the template identified by cite_class
		if true == state_test (state, name) then return true; end
	end																			-- if here, fall into general validation

	state = whitelist.common_parameters_t[enum_name];							-- all other templates; all normal parameters allowed; this list holds enumerated and nonenumerated parameters
	if true == state_test (state, name) then return true; end

	return false;																-- not supported because not found or name is set to nil
end


--[=[-------------------------&lt; I N T E R _ W I K I _ C H E C K &gt;----------------------------------------------

check &lt;value&gt; for inter-language interwiki-link markup.  &lt;prefix&gt; must be a MediaWiki-recognized language
code.  when these values have the form (without leading colon):
	[[&lt;prefix&gt;:link|label]] return label as plain-text
	[[&lt;prefix&gt;:link]] return &lt;prefix&gt;:link as plain-text

return value as is else

]=]

local function inter_wiki_check (parameter, value)
	local prefix = value:match ('%[%[(%a+):');									-- get an interwiki prefix if one exists
	local _;
	
	if prefix and cfg.inter_wiki_map[prefix:lower()] then						-- if prefix is in the map, needs preceding colon so
		utilities.set_message ('err_bad_paramlink', parameter);					-- emit an error message
		_, value, _ = utilities.is_wikilink (value);							-- extract label portion from wikilink
	end
	return value;
end


--[[--------------------------&lt; M I S S I N G _ P I P E _ C H E C K &gt;------------------------------------------

Look at the contents of a parameter. If the content has a string of characters and digits followed by an equal
sign, compare the alphanumeric string to the list of cs1|2 parameters.  If found, then the string is possibly a
parameter that is missing its pipe.  There are two tests made:
	{{cite ... |title=Title access-date=2016-03-17}}	-- the first parameter has a value and whitespace separates that value from the missing pipe parameter name
	{{cite ... |title=access-date=2016-03-17}}			-- the first parameter has no value (whitespace after the first = is trimmed by MediaWiki)
cs1|2 shares some parameter names with XML/HTML attributes: class=, title=, etc.  To prevent false positives XML/HTML
tags are removed before the search.

If a missing pipe is detected, this function adds the missing pipe maintenance category.

]]

local function missing_pipe_check (parameter, value)
	local capture;
	value = value:gsub ('%b&lt;&gt;', '');											-- remove XML/HTML tags because attributes: class=, title=, etc.

	capture = value:match ('%s+(%a[%w%-]+)%s*=') or value:match ('^(%a[%w%-]+)%s*=');	-- find and categorize parameters with possible missing pipes
	if capture and validate (capture) then										-- if the capture is a valid parameter name
		utilities.set_message ('err_missing_pipe', parameter);
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ P U N C T &gt;--------------------------------------

look for extraneous terminal punctuation in most parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_punc (param, value)
	if 'number' == type (param) then
		return;
	end
	
	param = param:gsub ('%d+', '#');											-- enumerated name-list mask params allow terminal punct; normalize 
	if cfg.punct_skip[param] then
		return;																	-- parameter name found in the skip table so done
	end
	
	if value:match ('[,;:]$') then
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
	if value:match ('^=') then													-- sometimes an extraneous '=' character appears ...
		utilities.set_message ('maint_extra_punct');							-- has extraneous punctuation; add maint cat
	end
end


--[[--------------------------&lt; H A S _ T W L _ U R L &gt;--------------------------------------------------------

look for The Wikipedia Library urls in url-holding parameters.  TWL urls are accessible for readers who are not
active extended confirmed Wikipedia editors.  This function emits an error message when such urls are discovered.

looks for: '.wikipedialibrary.idm.oclc.org'

]]

local function has_twl_url (url_params_t)
	local url_error_t = {};														-- sequence of url-holding parameters that have a TWL url
	
	for param, value in pairs (url_params_t) do
		if value:find ('%.wikipedialibrary%.idm%.oclc%.org') then				-- has the TWL base url?
			table.insert (url_error_t, utilities.wrap_style ('parameter', param));	-- add parameter name to the list
		end
	end
	if 0 ~= #url_error_t then													-- non-zero when there are errors
		table.sort (url_error_t);
		utilities.set_message ('err_param_has_twl_url', {utilities.make_sep_list (#url_error_t, url_error_t)});	-- add this error message
		return true;
	end
end


--[[--------------------------&lt; H A S _ E X T R A N E O U S _ U R L &gt;------------------------------------------

look for extraneous url parameter values; parameters listed in skip table are not checked

]]

local function has_extraneous_url (non_url_param_t)
	local url_error_t = {};
	
	check_for_url (non_url_param_t, url_error_t);								-- extraneous url check
	if 0 ~= #url_error_t then													-- non-zero when there are errors
		table.sort (url_error_t);
		utilities.set_message ('err_param_has_ext_link', {utilities.make_sep_list (#url_error_t, url_error_t)});	-- add this error message
	end
end


--[[--------------------------&lt; _ C I T A T I O N &gt;------------------------------------------------------------

Module entry point

	frame – from template call (citation()); may be nil when called from another module
	args – table of all cs1|2 parameters in the template (the template frame)
	config – table of template-supplied parameter (the #invoke frame)

]]

local function _citation (frame, args, config)									-- save a copy in case we need to display an error message in preview mode
	if not frame then
		frame = mw.getCurrentFrame();											-- if called from another module, get a frame for frame-provided functions
	end
																				-- i18n: set the name that your wiki uses to identify sandbox subpages from sandbox template invoke (or can be set here)
	local sandbox = ((config.SandboxPath and '' ~= config.SandboxPath) and config.SandboxPath) or '/sandbox';	-- sandbox path from {{#invoke:Citation/CS1/sandbox|citation|SandboxPath=/...}}
	is_sandbox = nil ~= string.find (frame:getTitle(), sandbox, 1, true);		-- is this invoke the sandbox module?
	sandbox = is_sandbox and sandbox or '';										-- use i18n sandbox to load sandbox modules when this module is the sandox; live modules else

	cfg = mw.loadData ('Module:Citation/CS1/Configuration' .. sandbox);			-- load sandbox versions of support modules when {{#invoke:Citation/CS1/sandbox|...}}; live modules else
	whitelist = mw.loadData ('Module:Citation/CS1/Whitelist' .. sandbox);
	utilities = require ('Module:Citation/CS1/Utilities' .. sandbox);
	validation = require ('Module:Citation/CS1/Date_validation' .. sandbox);
	identifiers = require ('Module:Citation/CS1/Identifiers' .. sandbox);
	metadata = require ('Module:Citation/CS1/COinS' .. sandbox);

	utilities.set_selected_modules (cfg);										-- so that functions in Utilities can see the selected cfg tables
	identifiers.set_selected_modules (cfg, utilities);							-- so that functions in Identifiers can see the selected cfg tables and selected Utilities module
	validation.set_selected_modules (cfg, utilities);							-- so that functions in Date validataion can see selected cfg tables and the selected Utilities module
	metadata.set_selected_modules (cfg, utilities);								-- so that functions in COinS can see the selected cfg tables and selected Utilities module

	z = utilities.z;															-- table of error and category tables in Module:Citation/CS1/Utilities

	is_preview_mode = not utilities.is_set (frame:preprocess ('{{REVISIONID}}'));

	local suggestions = {};														-- table where we store suggestions if we need to loadData them
	local error_text;															-- used as a flag

	local capture;																-- the single supported capture when matching unknown parameters using patterns
	local empty_unknowns = {};													-- sequence table to hold empty unknown params for error message listing
	for k, v in pairs( args ) do												-- get parameters from the parent (template) frame
		v = mw.ustring.gsub (v, '^%s*(.-)%s*$', '%1');							-- trim leading/trailing whitespace; when v is only whitespace, becomes empty string
		if v ~= '' then
			if ('string' == type (k)) then
				k = mw.ustring.gsub (k, '%d', cfg.date_names.local_digits);		-- for enumerated parameters, translate 'local' digits to Western 0-9
			end
			if not validate( k, config.CitationClass ) then			
				if type (k) ~= 'string' then									-- exclude empty numbered parameters
					if v:match(&quot;%S+&quot;) ~= nil then
						error_text = utilities.set_message ('err_text_ignored', {v});
					end
				elseif validate (k:lower(), config.CitationClass) then 
					error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, k:lower()});	-- suggest the lowercase version of the parameter
				else
					if nil == suggestions.suggestions then						-- if this table is nil then we need to load it
						suggestions = mw.loadData ('Module:Citation/CS1/Suggestions' .. sandbox);	--load sandbox version of suggestion module when {{#invoke:Citation/CS1/sandbox|...}}; live module else
					end
					for pattern, param in pairs (suggestions.patterns) do		-- loop through the patterns to see if we can suggest a proper parameter
						capture = k:match (pattern);							-- the whole match if no capture in pattern else the capture if a match
						if capture then											-- if the pattern matches 
							param = utilities.substitute (param, capture);		-- add the capture to the suggested parameter (typically the enumerator)
							if validate (param, config.CitationClass) then		-- validate the suggestion to make sure that the suggestion is supported by this template (necessary for limited parameter lists)
								error_text = utilities.set_message ('err_parameter_ignored_suggest', {k, param});	-- set the suggestion error message
							else
								error_text = utilities.set_message ('err_parameter_ignored', {k});	-- suggested param not supported by this template
								v = '';											-- unset
							end
						end
					end
					if not utilities.is_set (error_text) then					-- couldn't match with a pattern, is there an explicit suggestion?						
						if (suggestions.suggestions[ k:lower() ] ~= nil) and validate (suggestions.suggestions[ k:lower() ], config.CitationClass) then
							utilities.set_message ('err_parameter_ignored_suggest', {k, suggestions.suggestions[ k:lower() ]});
						else
							utilities.set_message ('err_parameter_ignored', {k});
							v = '';												-- unset value assigned to unrecognized parameters (this for the limited parameter lists)
						end
					end
				end				  
			end

			args[k] = v;														-- save this parameter and its value

		elseif not utilities.is_set (v) then									-- for empty parameters
			if not validate (k, config.CitationClass, true) then				-- is this empty parameter a valid parameter
				k = ('' == k) and '(empty string)' or k;						-- when k is empty string (or was space(s) trimmed to empty string), replace with descriptive text
				table.insert (empty_unknowns, utilities.wrap_style ('parameter', k));	-- format for error message and add to the list
			end
																				-- crude debug support that allows us to render a citation from module {{#invoke:}} TODO: keep?
	--	elseif args[k] ~= nil or (k == 'postscript') then						-- when args[k] has a value from {{#invoke}} frame (we don't normally do that)
	--		args[k] = v;														-- overwrite args[k] with empty string from pframe.args[k] (template frame); v is empty string here
		end																		-- not sure about the postscript bit; that gets handled in parameter validation; historical artifact?
	end	

	if 0 ~= #empty_unknowns then												-- create empty unknown error message
		utilities.set_message ('err_param_unknown_empty', {
			1 == #empty_unknowns and '' or 's',
			utilities.make_sep_list (#empty_unknowns, empty_unknowns)
			});
	end

	local non_url_param_t = {};													-- table of parameters and values that are not url-holding parameters
	local url_param_t = {};														-- table of url-holding paramters and their values

	for k, v in pairs( args ) do
		if 'string' == type (k) then											-- don't evaluate positional parameters
			has_invisible_chars (k, v);											-- look for invisible characters
		end
		has_extraneous_punc (k, v);												-- look for extraneous terminal punctuation in parameter values
		missing_pipe_check (k, v);												-- do we think that there is a parameter that is missing a pipe?
		args[k] = inter_wiki_check (k, v);										-- when language interwiki-linked parameter missing leading colon replace with wiki-link label

		if 'string' == type (k) then											-- when parameter k is not positional
			if not cfg.url_skip[k] then											-- and not in url skip table
				non_url_param_t[k] = v;											-- make a parameter/value list for extraneous url check
			else																-- and is in url skip table (a url-holding parameter)
				url_param_t[k] = v;												-- make a parameter/value list to check for values that are The Wikipedia Library url
			end
		end
	end

	has_extraneous_url (non_url_param_t);										-- look for url in parameter values where a url does not belong
	if has_twl_url (url_param_t) then												-- look for url-holding parameters that hold a The Wikipedia Library url
		args['url-access'] = 'subscription';
	end
	return table.concat ({
		frame:extensionTag ('templatestyles', '', {src='Module:Citation/CS1' .. sandbox .. '/styles.css'}),
		citation0( config, args)
	});
end


--[[--------------------------&lt; C I T A T I O N &gt;--------------------------------------------------------------

Template entry point

]]

local function citation (frame)
	local config_t = {};														-- table to store parameters from the module {{#invoke:}}
	local args_t = frame:getParent().args;										-- get template's preset parameters

	for k, v in pairs (frame.args) do											-- get parameters from the {{#invoke}} frame
		config_t[k] = v;
	--	args_t[k] = v;															-- crude debug support that allows us to render a citation from module {{#invoke:}}; skips parameter validation; TODO: keep?
	end	
	return _citation (frame, args_t, config_t)
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	citation = citation,														-- template entry point
	
	_citation = _citation,														-- module entry point
	}</text>
      <sha1>swdh50lofyqq0wmp3o2c259fg8s2nxi</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Citation/CS1/Whitelist</title>
    <ns>828</ns>
    <id>732</id>
    <revision>
      <id>4761</id>
      <timestamp>2013-04-04T19:20:02Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>[[WP:AES|←]]Created page with 'whitelist = {  basic_arguments = {     ['accessdate'] = true,     ['access-date'] = true,     ['agency'] = true,     ['airdate'] = true,     ['archivedate'] = tr...'</comment>
      <origin>4761</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="5557" sha1="4dz00aqwu1naa7wxv2g28gj24zsd4b7" xml:space="preserve">whitelist = {

basic_arguments = {
    ['accessdate'] = true,
    ['access-date'] = true,
    ['agency'] = true,
    ['airdate'] = true,
    ['archivedate'] = true,
    ['archive-date'] = true,
    ['archiveurl'] = true,
    ['archive-url'] = true,
    ['article'] = true,
    ['arxiv'] = true,
    ['ARXIV'] = true,
    ['asin'] = true,
    ['ASIN'] = true,
    ['asin-tld'] = true,
    ['ASIN-TLD'] = true,
    ['at'] = true,
    ['author'] = true,
    ['author-first'] = true,
    ['authorformat'] = true,
    ['author-format'] = true,
    ['author-last'] = true,
    ['authorlink'] = true,
    ['author-link'] = true,
    ['authormask'] = true,
    ['author-mask'] = true,
    ['author-name-separator'] = true,
    ['authors'] = true,
    ['author-separator'] = true,
    ['began'] = true,
    ['bibcode'] = true,
    ['BIBCODE'] = true,
    ['booktitle'] = true,
    ['chapter'] = true,
    ['chapterlink'] = true,
    ['chapterurl'] = true,
    ['chapter-url'] = true,
    ['coauthor'] = true,
    ['coauthors'] = true,
    ['conference'] = true,
    ['conferenceurl'] = true,
    ['conference-url'] = true,
    ['contribution'] = true,
    ['contributor'] = true,
    ['date'] = true,
    ['day'] = true,
    ['deadurl'] = true,
    ['department'] = true,
    ['dictionary'] = true,
    ['displayauthors'] = true,
    ['display-authors'] = true,
    ['displayeditors'] = true,
    ['display-editors'] = true,
    ['doi'] = true,
    ['DOI'] = true,
    ['DoiBroken'] = true,
    ['doi_brokendate'] = true,
    ['doi_inactivedate'] = true,
    ['edition'] = true,
    ['editor'] = true,
    ['editor-first'] = true,
    ['editorformat'] = true,
    ['editor-format'] = true,
    ['editor-last'] = true,
    ['editorlink'] = true,
    ['editor-link'] = true,
    ['editormask'] = true,
    ['editor-mask'] = true,
    ['editor-name-separator'] = true,
    ['editors'] = true,
    ['editor-separator'] = true,
    ['encode'] = true,
    ['encyclopaedia'] = true,
    ['encyclopedia'] = true,
    ['ended'] = true,
    ['entry'] = true,
    ['episodelink'] = true,
    ['first'] = true,
    ['format'] = true,
    ['given'] = true,
    ['id'] = true,
    ['ID'] = true,
    ['in'] = true,
    ['isbn'] = true,
    ['ISBN'] = true,
    ['isbn13'] = true,
    ['issn'] = true,
    ['ISSN'] = true,
    ['issue'] = true,
    ['jfm'] = true,
    ['JFM'] = true,
    ['journal'] = true,
    ['jstor'] = true,
    ['JSTOR'] = true,
    ['label'] = true,
    ['language'] = true,
    ['last'] = true,
    ['lastauthoramp'] = true,
    ['laydate'] = true,
    ['laysource'] = true,
    ['laysummary'] = true,
    ['lccn'] = true,
    ['LCCN'] = true,
    ['link'] = true,
    ['location'] = true,
    ['magazine'] = true,
    ['minutes'] = true,
    ['month'] = true,
    ['mr'] = true,
    ['MR'] = true,
    ['NameSep'] = true,
    ['name-separator'] = true,
    ['network'] = true,
    ['newspaper'] = true,
    ['nocat'] = true,
    ['nopp'] = true,
    ['notracking'] = true,
    ['no-tracking'] = true,
    ['number'] = true,
    ['oclc'] = true,
    ['OCLC'] = true,
    ['ol'] = true,
    ['OL'] = true,
    ['origyear'] = true,
    ['osti'] = true,
    ['OSTI'] = true,
    ['others'] = true,
    ['p'] = true,
    ['page'] = true,
    ['pages'] = true,
    ['periodical'] = true,
    ['place'] = true,
    ['pmc'] = true,
    ['PMC'] = true,
    ['pmid'] = true,
    ['PMID'] = true,
    ['postscript'] = true,
    ['pp'] = true,
    ['prefix'] = true,
    ['publicationdate'] = true,
    ['publication-date'] = true,
    ['publicationplace'] = true,
    ['publication-place'] = true,
    ['publisher'] = true,
    ['quotation'] = true,
    ['quote'] = true,
    ['ref'] = true,
    ['Ref'] = true,
    ['rfc'] = true,
    ['RFC'] = true,
    ['season'] = true,
    ['separator'] = true,
    ['series'] = true,
    ['serieslink'] = true,
    ['seriesno'] = true,
    ['seriesnumber'] = true,
    ['series-separator'] = true,
    ['ssrn'] = true,
    ['SSRN'] = true,
    ['station'] = true,
    ['subscription'] = true,
    ['suffix'] = true,
    ['template doc demo'] = true,
    ['time'] = true,
    ['timecaption'] = true,
    ['title'] = true,
    ['titlelink'] = true,
    ['trans_chapter'] = true,
    ['trans-chapter'] = true,
    ['transcript'] = true,
    ['transcripturl'] = true,
    ['transcript-url'] = true,
    ['trans_title'] = true,
    ['type'] = true,
    ['url'] = true,
    ['URL'] = true,
    ['version'] = true,
    ['via'] = true,
    ['volume'] = true,
    ['work'] = true,
    ['year'] = true,
    ['zbl'] = true,
    ['ZBL'] = true,
},

numbered_arguments = {
    ['author#'] = true,
    ['Author#'] = true,
    ['author-first#'] = true,
    ['author#-first'] = true,
    ['author-last#'] = true,
    ['author#-last'] = true,
    ['author-link#'] = true,
    ['author#link'] = true,
    ['author#-link'] = true,
    ['authorlink#'] = true,
    ['author-mask#'] = true,
    ['author#mask'] = true,
    ['author#-mask'] = true,
    ['authormask#'] = true,
    ['editor#'] = true,
    ['Editor#'] = true,
    ['editor-first#'] = true,
    ['editor#-first'] = true,
    ['EditorGiven#'] = true,
    ['editor-last#'] = true,
    ['editor#-last'] = true,
    ['editor-link#'] = true,
    ['editor#link'] = true,
    ['editor#-link'] = true,
    ['editorlink#'] = true,
    ['editor-mask#'] = true,
    ['editor#mask'] = true,
    ['editor#-mask'] = true,
    ['editormask#'] = true,
    ['EditorSurname#'] = true,
    ['first#'] = true,
    ['given#'] = true,
    ['last#'] = true,
    ['surname#'] = true,
},

};

return whitelist</text>
      <sha1>4dz00aqwu1naa7wxv2g28gj24zsd4b7</sha1>
    </revision>
    <revision>
      <id>4762</id>
      <parentid>4761</parentid>
      <timestamp>2013-04-04T19:22:36Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <origin>4762</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="5557" sha1="8oavfpl723q7yva9vm4bkxsuj13oyje" xml:space="preserve">whitelist = {

basic_arguments = {
    ['accessdate'] = true,
    ['access-date'] = true,
    ['agency'] = true,
    ['airdate'] = true,
    ['archivedate'] = true,
    ['archive-date'] = true,
    ['archiveurl'] = true,
    ['archive-url'] = true,
    ['article'] = true,
    ['arxiv'] = true,
    ['ARXIV'] = true,
    ['asin'] = true,
    ['ASIN'] = true,
    ['asin-tld'] = true,
    ['ASIN-TLD'] = true,
    ['at'] = true,
    ['author'] = true,
    ['author-first'] = true,
    ['authorformat'] = true,
    ['author-format'] = true,
    ['author-last'] = true,
    ['authorlink'] = true,
    ['author-link'] = true,
    ['authormask'] = true,
    ['author-mask'] = true,
    ['author-name-separator'] = true,
    ['authors'] = true,
    ['author-separator'] = true,
    ['began'] = true,
    ['bibcode'] = true,
    ['BIBCODE'] = true,
    ['booktitle'] = true,
    ['chapter'] = true,
    ['chapterlink'] = true,
    ['chapterurl'] = true,
    ['chapter-url'] = true,
    ['coauthor'] = true,
    ['coauthors'] = true,
    ['conference'] = true,
    ['conferenceurl'] = true,
    ['conference-url'] = true,
    ['contribution'] = true,
    ['contributor'] = true,
    ['date'] = true,
    ['day'] = true,
    ['deadurl'] = true,
    ['department'] = true,
    ['dictionary'] = true,
    ['displayauthors'] = true,
    ['display-authors'] = true,
    ['displayeditors'] = true,
    ['display-editors'] = true,
    ['doi'] = true,
    ['DOI'] = true,
    ['DoiBroken'] = true,
    ['doi_brokendate'] = true,
    ['doi_inactivedate'] = true,
    ['edition'] = true,
    ['editor'] = true,
    ['editor-first'] = true,
    ['editorformat'] = true,
    ['editor-format'] = true,
    ['editor-last'] = true,
    ['editorlink'] = true,
    ['editor-link'] = true,
    ['editormask'] = true,
    ['editor-mask'] = true,
    ['editor-name-separator'] = true,
    ['editors'] = true,
    ['editor-separator'] = true,
    ['encode'] = true,
    ['encyclopaedia'] = true,
    ['encyclopedia'] = true,
    ['ended'] = true,
    ['entry'] = true,
    ['episodelink'] = true,
    ['first'] = true,
    ['format'] = true,
    ['given'] = true,
    ['id'] = true,
    ['ID'] = true,
    ['in'] = true,
    ['isbn'] = true,
    ['ISBN'] = true,
    ['isbn13'] = true,
    ['issn'] = true,
    ['ISSN'] = true,
    ['issue'] = true,
    ['jfm'] = true,
    ['JFM'] = true,
    ['journal'] = true,
    ['jstor'] = true,
    ['JSTOR'] = true,
    ['label'] = true,
    ['language'] = true,
    ['last'] = true,
    ['lastauthoramp'] = true,
    ['laydate'] = true,
    ['laysource'] = true,
    ['laysummary'] = true,
    ['lccn'] = true,
    ['LCCN'] = true,
    ['link'] = true,
    ['location'] = true,
    ['magazine'] = true,
    ['minutes'] = true,
    ['month'] = true,
    ['mr'] = true,
    ['MR'] = true,
    ['NameSep'] = true,
    ['name-separator'] = true,
    ['network'] = true,
    ['newspaper'] = true,
    ['nocat'] = true,
    ['nopp'] = true,
    ['notracking'] = true,
    ['no-tracking'] = true,
    ['number'] = true,
    ['oclc'] = true,
    ['OCLC'] = true,
    ['ol'] = true,
    ['OL'] = true,
    ['origyear'] = true,
    ['osti'] = true,
    ['OSTI'] = true,
    ['others'] = true,
    ['p'] = true,
    ['page'] = true,
    ['pages'] = true,
    ['periodical'] = true,
    ['place'] = true,
    ['pmc'] = true,
    ['PMC'] = true,
    ['pmid'] = true,
    ['PMID'] = true,
    ['postscript'] = true,
    ['pp'] = true,
    ['prefix'] = true,
    ['publicationdate'] = true,
    ['publication-date'] = true,
    ['publicationplace'] = true,
    ['publication-place'] = true,
    ['publisher'] = true,
    ['quotation'] = true,
    ['quote'] = true,
    ['ref'] = true,
    ['Ref'] = true,
    ['rfc'] = true,
    ['RFC'] = true,
    ['season'] = true,
    ['separator'] = true,
    ['series'] = true,
    ['serieslink'] = true,
    ['seriesno'] = true,
    ['seriesnumber'] = true,
    ['series-separator'] = true,
    ['ssrn'] = true,
    ['SSRN'] = true,
    ['station'] = true,
    ['subscription'] = true,
    ['suffix'] = true,
    ['template doc demo'] = true,
    ['time'] = true,
    ['timecaption'] = true,
    ['title'] = true,
    ['titlelink'] = true,
    ['trans_chapter'] = true,
    ['trans-chapter'] = true,
    ['transcript'] = true,
    ['transcripturl'] = true,
    ['transcript-url'] = true,
    ['trans_title'] = true,
    ['type'] = true,
    ['url'] = true,
    ['URL'] = true,
    ['version'] = true,
    ['via'] = true,
    ['volume'] = true,
    ['work'] = true,
    ['year'] = true,
    ['zbl'] = true,
    ['ZBL'] = true,
},

numbered_arguments = {
    ['author#'] = true,
    ['Author#'] = true,
    ['author-first#'] = true,
    ['author#-first'] = true,
    ['author-last#'] = true,
    ['author#-last'] = true,
    ['author-link#'] = true,
    ['author#link'] = true,
    ['author#-link'] = true,
    ['authorlink#'] = true,
    ['author-mask#'] = true,
    ['author#mask'] = true,
    ['author#-mask'] = true,
    ['authormask#'] = true,
    ['editor#'] = true,
    ['Editor#'] = true,
    ['editor-first#'] = true,
    ['editor#-first'] = true,
    ['EditorGiven#'] = true,
    ['editor-last#'] = true,
    ['editor#-last'] = true,
    ['editor-link#'] = true,
    ['editor#link'] = true,
    ['editor#-link'] = true,
    ['editorlink#'] = true,
    ['editor-mask#'] = true,
    ['editor#mask'] = true,
    ['editor#-mask'] = true,
    ['editormask#'] = true,
    ['EditorSurname#'] = true,
    ['first#'] = true,
    ['given#'] = true,
    ['last#'] = true,
    ['surname#'] = true,
},
};

return whitelist;</text>
      <sha1>8oavfpl723q7yva9vm4bkxsuj13oyje</sha1>
    </revision>
    <revision>
      <id>4763</id>
      <parentid>4762</parentid>
      <timestamp>2013-04-04T19:31:24Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>fix</comment>
      <origin>4763</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="5445" sha1="880jer9in8xammqdg7xanuuddzyx3df" xml:space="preserve">whitelist = {

basic_arguments = {
    ['accessdate'] = true,
    ['access-date'] = true,
    ['agency'] = true,
    ['airdate'] = true,
    ['archivedate'] = true,
    ['archive-date'] = true,
    ['archiveurl'] = true,
    ['archive-url'] = true,
    ['article'] = true,
    ['arxiv'] = true,
    ['ARXIV'] = true,
    ['asin'] = true,
    ['ASIN'] = true,
    ['asin-tld'] = true,
    ['ASIN-TLD'] = true,
    ['at'] = true,
    ['author'] = true,
    ['author-first'] = true,
    ['authorformat'] = true,
    ['author-format'] = true,
    ['author-last'] = true,
    ['authorlink'] = true,
    ['author-link'] = true,
    ['authormask'] = true,
    ['author-mask'] = true,
    ['author-name-separator'] = true,
    ['authors'] = true,
    ['author-separator'] = true,
    ['began'] = true,
    ['bibcode'] = true,
    ['BIBCODE'] = true,
    ['booktitle'] = true,
    ['chapter'] = true,
    ['chapterlink'] = true,
    ['chapterurl'] = true,
    ['chapter-url'] = true,
    ['coauthor'] = true,
    ['coauthors'] = true,
    ['conference'] = true,
    ['conferenceurl'] = true,
    ['conference-url'] = true,
    ['contribution'] = true,
    ['contributor'] = true,
    ['date'] = true,
    ['day'] = true,
    ['deadurl'] = true,
    ['department'] = true,
    ['dictionary'] = true,
    ['displayauthors'] = true,
    ['display-authors'] = true,
    ['displayeditors'] = true,
    ['display-editors'] = true,
    ['doi'] = true,
    ['DOI'] = true,
    ['DoiBroken'] = true,
    ['doi_brokendate'] = true,
    ['doi_inactivedate'] = true,
    ['edition'] = true,
    ['editor'] = true,
    ['editor-first'] = true,
    ['editorformat'] = true,
    ['editor-format'] = true,
    ['editor-last'] = true,
    ['editorlink'] = true,
    ['editor-link'] = true,
    ['editormask'] = true,
    ['editor-mask'] = true,
    ['editor-name-separator'] = true,
    ['editors'] = true,
    ['editor-separator'] = true,
    ['encyclopaedia'] = true,
    ['encyclopedia'] = true,
    ['ended'] = true,
    ['entry'] = true,
    ['episodelink'] = true,
    ['first'] = true,
    ['format'] = true,
    ['given'] = true,
    ['id'] = true,
    ['ID'] = true,
    ['in'] = true,
    ['isbn'] = true,
    ['ISBN'] = true,
    ['isbn13'] = true,
    ['issn'] = true,
    ['ISSN'] = true,
    ['issue'] = true,
    ['jfm'] = true,
    ['JFM'] = true,
    ['journal'] = true,
    ['jstor'] = true,
    ['JSTOR'] = true,
    ['language'] = true,
    ['last'] = true,
    ['lastauthoramp'] = true,
    ['laydate'] = true,
    ['laysource'] = true,
    ['laysummary'] = true,
    ['lccn'] = true,
    ['LCCN'] = true,
    ['location'] = true,
    ['magazine'] = true,
    ['minutes'] = true,
    ['month'] = true,
    ['mr'] = true,
    ['MR'] = true,
    ['NameSep'] = true,
    ['name-separator'] = true,
    ['network'] = true,
    ['newspaper'] = true,
    ['nocat'] = true,
    ['nopp'] = true,
    ['notracking'] = true,
    ['no-tracking'] = true,
    ['number'] = true,
    ['oclc'] = true,
    ['OCLC'] = true,
    ['ol'] = true,
    ['OL'] = true,
    ['origyear'] = true,
    ['osti'] = true,
    ['OSTI'] = true,
    ['others'] = true,
    ['p'] = true,
    ['page'] = true,
    ['pages'] = true,
    ['periodical'] = true,
    ['place'] = true,
    ['pmc'] = true,
    ['PMC'] = true,
    ['pmid'] = true,
    ['PMID'] = true,
    ['postscript'] = true,
    ['pp'] = true,
    ['publicationdate'] = true,
    ['publication-date'] = true,
    ['publicationplace'] = true,
    ['publication-place'] = true,
    ['publisher'] = true,
    ['quotation'] = true,
    ['quote'] = true,
    ['ref'] = true,
    ['Ref'] = true,
    ['rfc'] = true,
    ['RFC'] = true,
    ['season'] = true,
    ['separator'] = true,
    ['series'] = true,
    ['serieslink'] = true,
    ['seriesno'] = true,
    ['seriesnumber'] = true,
    ['series-separator'] = true,
    ['ssrn'] = true,
    ['SSRN'] = true,
    ['station'] = true,
    ['subscription'] = true,
    ['template doc demo'] = true,
    ['time'] = true,
    ['timecaption'] = true,
    ['title'] = true,
    ['titlelink'] = true,
    ['trans_chapter'] = true,
    ['trans-chapter'] = true,
    ['transcript'] = true,
    ['transcripturl'] = true,
    ['transcript-url'] = true,
    ['trans_title'] = true,
    ['type'] = true,
    ['url'] = true,
    ['URL'] = true,
    ['version'] = true,
    ['via'] = true,
    ['volume'] = true,
    ['work'] = true,
    ['year'] = true,
    ['zbl'] = true,
    ['ZBL'] = true,
},

numbered_arguments = {
    ['author#'] = true,
    ['Author#'] = true,
    ['author-first#'] = true,
    ['author#-first'] = true,
    ['author-last#'] = true,
    ['author#-last'] = true,
    ['author-link#'] = true,
    ['author#link'] = true,
    ['author#-link'] = true,
    ['authorlink#'] = true,
    ['author-mask#'] = true,
    ['author#mask'] = true,
    ['author#-mask'] = true,
    ['authormask#'] = true,
    ['editor#'] = true,
    ['Editor#'] = true,
    ['editor-first#'] = true,
    ['editor#-first'] = true,
    ['EditorGiven#'] = true,
    ['editor-last#'] = true,
    ['editor#-last'] = true,
    ['editor-link#'] = true,
    ['editor#link'] = true,
    ['editor#-link'] = true,
    ['editorlink#'] = true,
    ['editor-mask#'] = true,
    ['editor#mask'] = true,
    ['editor#-mask'] = true,
    ['editormask#'] = true,
    ['EditorSurname#'] = true,
    ['first#'] = true,
    ['given#'] = true,
    ['last#'] = true,
    ['surname#'] = true,
},
};

return whitelist;</text>
      <sha1>880jer9in8xammqdg7xanuuddzyx3df</sha1>
    </revision>
    <revision>
      <id>4764</id>
      <parentid>4763</parentid>
      <timestamp>2013-04-04T23:30:37Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>update</comment>
      <origin>4764</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="5478" sha1="p9syiykcy0t6d40y9rpss2ghplwzolh" xml:space="preserve">whitelist = {

basic_arguments = {
    ['accessdate'] = true,
    ['access-date'] = true,
    ['agency'] = true,
    ['airdate'] = true,
    ['archivedate'] = true,
    ['archive-date'] = true,
    ['archiveurl'] = true,
    ['archive-url'] = true,
    ['article'] = true,
    ['arxiv'] = true,
    ['ARXIV'] = true,
    ['asin'] = true,
    ['ASIN'] = true,
    ['asin-tld'] = true,
    ['ASIN-TLD'] = true,
    ['at'] = true,
    ['author'] = true,
    ['author-first'] = true,
    ['authorformat'] = true,
    ['author-format'] = true,
    ['author-last'] = true,
    ['authorlink'] = true,
    ['author-link'] = true,
    ['authormask'] = true,
    ['author-mask'] = true,
    ['author-name-separator'] = true,
    ['authors'] = true,
    ['author-separator'] = true,
    ['began'] = true,
    ['bibcode'] = true,
    ['BIBCODE'] = true,
    ['booktitle'] = true,
    ['chapter'] = true,
    ['chapterlink'] = true,
    ['chapterurl'] = true,
    ['chapter-url'] = true,
    ['coauthor'] = true,
    ['coauthors'] = true,
    ['conference'] = true,
    ['conferenceurl'] = true,
    ['conference-url'] = true,
    ['contribution'] = true,
    ['contribution-url'] = true,
    ['contributor'] = true,
    ['date'] = true,
    ['day'] = true,
    ['deadurl'] = true,
    ['department'] = true,
    ['dictionary'] = true,
    ['displayauthors'] = true,
    ['display-authors'] = true,
    ['displayeditors'] = true,
    ['display-editors'] = true,
    ['doi'] = true,
    ['DOI'] = true,
    ['DoiBroken'] = true,
    ['doi_brokendate'] = true,
    ['doi_inactivedate'] = true,
    ['edition'] = true,
    ['editor'] = true,
    ['editor-first'] = true,
    ['editorformat'] = true,
    ['editor-format'] = true,
    ['editor-last'] = true,
    ['editorlink'] = true,
    ['editor-link'] = true,
    ['editormask'] = true,
    ['editor-mask'] = true,
    ['editor-name-separator'] = true,
    ['editors'] = true,
    ['editor-separator'] = true,
    ['encyclopaedia'] = true,
    ['encyclopedia'] = true,
    ['ended'] = true,
    ['entry'] = true,
    ['episodelink'] = true,
    ['first'] = true,
    ['format'] = true,
    ['given'] = true,
    ['id'] = true,
    ['ID'] = true,
    ['in'] = true,
    ['isbn'] = true,
    ['ISBN'] = true,
    ['isbn13'] = true,
    ['issn'] = true,
    ['ISSN'] = true,
    ['issue'] = true,
    ['jfm'] = true,
    ['JFM'] = true,
    ['journal'] = true,
    ['jstor'] = true,
    ['JSTOR'] = true,
    ['language'] = true,
    ['last'] = true,
    ['lastauthoramp'] = true,
    ['laydate'] = true,
    ['laysource'] = true,
    ['laysummary'] = true,
    ['lccn'] = true,
    ['LCCN'] = true,
    ['location'] = true,
    ['magazine'] = true,
    ['minutes'] = true,
    ['month'] = true,
    ['mr'] = true,
    ['MR'] = true,
    ['NameSep'] = true,
    ['name-separator'] = true,
    ['network'] = true,
    ['newspaper'] = true,
    ['nocat'] = true,
    ['nopp'] = true,
    ['notracking'] = true,
    ['no-tracking'] = true,
    ['number'] = true,
    ['oclc'] = true,
    ['OCLC'] = true,
    ['ol'] = true,
    ['OL'] = true,
    ['origyear'] = true,
    ['osti'] = true,
    ['OSTI'] = true,
    ['others'] = true,
    ['p'] = true,
    ['page'] = true,
    ['pages'] = true,
    ['periodical'] = true,
    ['place'] = true,
    ['pmc'] = true,
    ['PMC'] = true,
    ['pmid'] = true,
    ['PMID'] = true,
    ['postscript'] = true,
    ['pp'] = true,
    ['publicationdate'] = true,
    ['publication-date'] = true,
    ['publicationplace'] = true,
    ['publication-place'] = true,
    ['publisher'] = true,
    ['quotation'] = true,
    ['quote'] = true,
    ['ref'] = true,
    ['Ref'] = true,
    ['rfc'] = true,
    ['RFC'] = true,
    ['season'] = true,
    ['separator'] = true,
    ['series'] = true,
    ['serieslink'] = true,
    ['seriesno'] = true,
    ['seriesnumber'] = true,
    ['series-separator'] = true,
    ['ssrn'] = true,
    ['SSRN'] = true,
    ['station'] = true,
    ['subscription'] = true,
    ['template doc demo'] = true,
    ['time'] = true,
    ['timecaption'] = true,
    ['title'] = true,
    ['titlelink'] = true,
    ['trans_chapter'] = true,
    ['trans-chapter'] = true,
    ['transcript'] = true,
    ['transcripturl'] = true,
    ['transcript-url'] = true,
    ['trans_title'] = true,
    ['type'] = true,
    ['url'] = true,
    ['URL'] = true,
    ['version'] = true,
    ['via'] = true,
    ['volume'] = true,
    ['work'] = true,
    ['year'] = true,
    ['zbl'] = true,
    ['ZBL'] = true,
},

numbered_arguments = {
    ['author#'] = true,
    ['Author#'] = true,
    ['author-first#'] = true,
    ['author#-first'] = true,
    ['author-last#'] = true,
    ['author#-last'] = true,
    ['author-link#'] = true,
    ['author#link'] = true,
    ['author#-link'] = true,
    ['authorlink#'] = true,
    ['author-mask#'] = true,
    ['author#mask'] = true,
    ['author#-mask'] = true,
    ['authormask#'] = true,
    ['editor#'] = true,
    ['Editor#'] = true,
    ['editor-first#'] = true,
    ['editor#-first'] = true,
    ['EditorGiven#'] = true,
    ['editor-last#'] = true,
    ['editor#-last'] = true,
    ['editor-link#'] = true,
    ['editor#link'] = true,
    ['editor#-link'] = true,
    ['editorlink#'] = true,
    ['editor-mask#'] = true,
    ['editor#mask'] = true,
    ['editor#-mask'] = true,
    ['editormask#'] = true,
    ['EditorSurname#'] = true,
    ['first#'] = true,
    ['given#'] = true,
    ['last#'] = true,
    ['surname#'] = true,
},
};

return whitelist;</text>
      <sha1>p9syiykcy0t6d40y9rpss2ghplwzolh</sha1>
    </revision>
    <revision>
      <id>4765</id>
      <parentid>4764</parentid>
      <timestamp>2013-04-05T03:09:02Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <minor />
      <comment>Protected Module:Citation/CS1/Whitelist: [[WP:High-risk templates|Highly visible template or Lua module]] ([Edit=Block all non-admin users] (indefinite) [Move=Block all non-admin users] (indefinite))</comment>
      <origin>4764</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="5478" sha1="p9syiykcy0t6d40y9rpss2ghplwzolh" xml:space="preserve">whitelist = {

basic_arguments = {
    ['accessdate'] = true,
    ['access-date'] = true,
    ['agency'] = true,
    ['airdate'] = true,
    ['archivedate'] = true,
    ['archive-date'] = true,
    ['archiveurl'] = true,
    ['archive-url'] = true,
    ['article'] = true,
    ['arxiv'] = true,
    ['ARXIV'] = true,
    ['asin'] = true,
    ['ASIN'] = true,
    ['asin-tld'] = true,
    ['ASIN-TLD'] = true,
    ['at'] = true,
    ['author'] = true,
    ['author-first'] = true,
    ['authorformat'] = true,
    ['author-format'] = true,
    ['author-last'] = true,
    ['authorlink'] = true,
    ['author-link'] = true,
    ['authormask'] = true,
    ['author-mask'] = true,
    ['author-name-separator'] = true,
    ['authors'] = true,
    ['author-separator'] = true,
    ['began'] = true,
    ['bibcode'] = true,
    ['BIBCODE'] = true,
    ['booktitle'] = true,
    ['chapter'] = true,
    ['chapterlink'] = true,
    ['chapterurl'] = true,
    ['chapter-url'] = true,
    ['coauthor'] = true,
    ['coauthors'] = true,
    ['conference'] = true,
    ['conferenceurl'] = true,
    ['conference-url'] = true,
    ['contribution'] = true,
    ['contribution-url'] = true,
    ['contributor'] = true,
    ['date'] = true,
    ['day'] = true,
    ['deadurl'] = true,
    ['department'] = true,
    ['dictionary'] = true,
    ['displayauthors'] = true,
    ['display-authors'] = true,
    ['displayeditors'] = true,
    ['display-editors'] = true,
    ['doi'] = true,
    ['DOI'] = true,
    ['DoiBroken'] = true,
    ['doi_brokendate'] = true,
    ['doi_inactivedate'] = true,
    ['edition'] = true,
    ['editor'] = true,
    ['editor-first'] = true,
    ['editorformat'] = true,
    ['editor-format'] = true,
    ['editor-last'] = true,
    ['editorlink'] = true,
    ['editor-link'] = true,
    ['editormask'] = true,
    ['editor-mask'] = true,
    ['editor-name-separator'] = true,
    ['editors'] = true,
    ['editor-separator'] = true,
    ['encyclopaedia'] = true,
    ['encyclopedia'] = true,
    ['ended'] = true,
    ['entry'] = true,
    ['episodelink'] = true,
    ['first'] = true,
    ['format'] = true,
    ['given'] = true,
    ['id'] = true,
    ['ID'] = true,
    ['in'] = true,
    ['isbn'] = true,
    ['ISBN'] = true,
    ['isbn13'] = true,
    ['issn'] = true,
    ['ISSN'] = true,
    ['issue'] = true,
    ['jfm'] = true,
    ['JFM'] = true,
    ['journal'] = true,
    ['jstor'] = true,
    ['JSTOR'] = true,
    ['language'] = true,
    ['last'] = true,
    ['lastauthoramp'] = true,
    ['laydate'] = true,
    ['laysource'] = true,
    ['laysummary'] = true,
    ['lccn'] = true,
    ['LCCN'] = true,
    ['location'] = true,
    ['magazine'] = true,
    ['minutes'] = true,
    ['month'] = true,
    ['mr'] = true,
    ['MR'] = true,
    ['NameSep'] = true,
    ['name-separator'] = true,
    ['network'] = true,
    ['newspaper'] = true,
    ['nocat'] = true,
    ['nopp'] = true,
    ['notracking'] = true,
    ['no-tracking'] = true,
    ['number'] = true,
    ['oclc'] = true,
    ['OCLC'] = true,
    ['ol'] = true,
    ['OL'] = true,
    ['origyear'] = true,
    ['osti'] = true,
    ['OSTI'] = true,
    ['others'] = true,
    ['p'] = true,
    ['page'] = true,
    ['pages'] = true,
    ['periodical'] = true,
    ['place'] = true,
    ['pmc'] = true,
    ['PMC'] = true,
    ['pmid'] = true,
    ['PMID'] = true,
    ['postscript'] = true,
    ['pp'] = true,
    ['publicationdate'] = true,
    ['publication-date'] = true,
    ['publicationplace'] = true,
    ['publication-place'] = true,
    ['publisher'] = true,
    ['quotation'] = true,
    ['quote'] = true,
    ['ref'] = true,
    ['Ref'] = true,
    ['rfc'] = true,
    ['RFC'] = true,
    ['season'] = true,
    ['separator'] = true,
    ['series'] = true,
    ['serieslink'] = true,
    ['seriesno'] = true,
    ['seriesnumber'] = true,
    ['series-separator'] = true,
    ['ssrn'] = true,
    ['SSRN'] = true,
    ['station'] = true,
    ['subscription'] = true,
    ['template doc demo'] = true,
    ['time'] = true,
    ['timecaption'] = true,
    ['title'] = true,
    ['titlelink'] = true,
    ['trans_chapter'] = true,
    ['trans-chapter'] = true,
    ['transcript'] = true,
    ['transcripturl'] = true,
    ['transcript-url'] = true,
    ['trans_title'] = true,
    ['type'] = true,
    ['url'] = true,
    ['URL'] = true,
    ['version'] = true,
    ['via'] = true,
    ['volume'] = true,
    ['work'] = true,
    ['year'] = true,
    ['zbl'] = true,
    ['ZBL'] = true,
},

numbered_arguments = {
    ['author#'] = true,
    ['Author#'] = true,
    ['author-first#'] = true,
    ['author#-first'] = true,
    ['author-last#'] = true,
    ['author#-last'] = true,
    ['author-link#'] = true,
    ['author#link'] = true,
    ['author#-link'] = true,
    ['authorlink#'] = true,
    ['author-mask#'] = true,
    ['author#mask'] = true,
    ['author#-mask'] = true,
    ['authormask#'] = true,
    ['editor#'] = true,
    ['Editor#'] = true,
    ['editor-first#'] = true,
    ['editor#-first'] = true,
    ['EditorGiven#'] = true,
    ['editor-last#'] = true,
    ['editor#-last'] = true,
    ['editor-link#'] = true,
    ['editor#link'] = true,
    ['editor#-link'] = true,
    ['editorlink#'] = true,
    ['editor-mask#'] = true,
    ['editor#mask'] = true,
    ['editor#-mask'] = true,
    ['editormask#'] = true,
    ['EditorSurname#'] = true,
    ['first#'] = true,
    ['given#'] = true,
    ['last#'] = true,
    ['surname#'] = true,
},
};

return whitelist;</text>
      <sha1>p9syiykcy0t6d40y9rpss2ghplwzolh</sha1>
    </revision>
    <revision>
      <id>4766</id>
      <parentid>4765</parentid>
      <timestamp>2013-04-08T05:28:53Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>update</comment>
      <origin>4766</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="5629" sha1="57s1ou09j72btwoys7zn8w9hhn4ligf" xml:space="preserve">whitelist = {

basic_arguments = {
    ['accessdate'] = true,
    ['access-date'] = true,
    ['agency'] = true,
    ['airdate'] = true,
    ['archivedate'] = true,
    ['archive-date'] = true,
    ['archiveurl'] = true,
    ['archive-url'] = true,
    ['article'] = true,
    ['arxiv'] = true,
    ['ARXIV'] = true,
    ['asin'] = true,
    ['ASIN'] = true,
    ['asin-tld'] = true,
    ['ASIN-TLD'] = true,
    ['at'] = true,
    ['author'] = true,
    ['Author'] = true,
    ['author-first'] = true,
    ['authorformat'] = true,
    ['author-format'] = true,
    ['author-last'] = true,
    ['authorlink'] = true,
    ['author-link'] = true,
    ['authormask'] = true,
    ['author-mask'] = true,
    ['author-name-separator'] = true,
    ['authors'] = true,
    ['author-separator'] = true,
    ['began'] = true,
    ['bibcode'] = true,
    ['BIBCODE'] = true,
    ['booktitle'] = true,
    ['chapter'] = true,
    ['chapterlink'] = true,
    ['chapterurl'] = true,
    ['chapter-url'] = true,
    ['coauthor'] = true,
    ['coauthors'] = true,
    ['conference'] = true,
    ['conferenceurl'] = true,
    ['conference-url'] = true,
    ['contribution'] = true,
    ['contribution-url'] = true,
    ['contributor'] = true,
    ['date'] = true,
    ['day'] = true,
    ['deadurl'] = true,
    ['department'] = true,
    ['dictionary'] = true,
    ['displayauthors'] = true,
    ['display-authors'] = true,
    ['displayeditors'] = true,
    ['display-editors'] = true,
    ['doi'] = true,
    ['DOI'] = true,
    ['DoiBroken'] = true,
    ['doi_brokendate'] = true,
    ['doi_inactivedate'] = true,
    ['edition'] = true,
    ['editor'] = true,
    ['Editor'] = true,
    ['editor-first'] = true,
    ['editorformat'] = true,
    ['editor-format'] = true,
    ['EditorGiven'] = true,
    ['editor-last'] = true,
    ['editorlink'] = true,
    ['editor-link'] = true,
    ['editormask'] = true,
    ['editor-mask'] = true,
    ['editor-name-separator'] = true,
    ['editors'] = true,
    ['editor-separator'] = true,
    ['EditorSurname'] = true,
    ['encyclopaedia'] = true,
    ['encyclopedia'] = true,
    ['ended'] = true,
    ['entry'] = true,
    ['episodelink'] = true,
    ['first'] = true,
    ['format'] = true,
    ['given'] = true,
    ['id'] = true,
    ['ID'] = true,
    ['in'] = true,
    ['isbn'] = true,
    ['ISBN'] = true,
    ['isbn13'] = true,
    ['ISBN13'] = true,
    ['issn'] = true,
    ['ISSN'] = true,
    ['issue'] = true,
    ['jfm'] = true,
    ['JFM'] = true,
    ['journal'] = true,
    ['jstor'] = true,
    ['JSTOR'] = true,
    ['language'] = true,
    ['last'] = true,
    ['lastauthoramp'] = true,
    ['laydate'] = true,
    ['laysource'] = true,
    ['laysummary'] = true,
    ['lccn'] = true,
    ['LCCN'] = true,
    ['location'] = true,
    ['magazine'] = true,
    ['minutes'] = true,
    ['month'] = true,
    ['mr'] = true,
    ['MR'] = true,
    ['NameSep'] = true,
    ['name-separator'] = true,
    ['network'] = true,
    ['newspaper'] = true,
    ['nocat'] = true,
    ['nopp'] = true,
    ['notracking'] = true,
    ['no-tracking'] = true,
    ['number'] = true,
    ['oclc'] = true,
    ['OCLC'] = true,
    ['ol'] = true,
    ['OL'] = true,
    ['origyear'] = true,
    ['osti'] = true,
    ['OSTI'] = true,
    ['others'] = true,
    ['p'] = true,
    ['page'] = true,
    ['pages'] = true,
    ['periodical'] = true,
    ['place'] = true,
    ['pmc'] = true,
    ['PMC'] = true,
    ['pmid'] = true,
    ['PMID'] = true,
    ['postscript'] = true,
    ['pp'] = true,
    ['publicationdate'] = true,
    ['publication-date'] = true,
    ['publicationplace'] = true,
    ['publication-place'] = true,
    ['publisher'] = true,
    ['quotation'] = true,
    ['quote'] = true,
    ['ref'] = true,
    ['Ref'] = true,
    ['rfc'] = true,
    ['RFC'] = true,
    ['season'] = true,
    ['separator'] = true,
    ['series'] = true,
    ['serieslink'] = true,
    ['seriesno'] = true,
    ['seriesnumber'] = true,
    ['series-separator'] = true,
    ['ssrn'] = true,
    ['SSRN'] = true,
    ['station'] = true,
    ['subscription'] = true,
    ['surname'] = true,
    ['template doc demo'] = true,
    ['time'] = true,
    ['timecaption'] = true,
    ['title'] = true,
    ['titlelink'] = true,
    ['trans_chapter'] = true,
    ['trans-chapter'] = true,
    ['transcript'] = true,
    ['transcripturl'] = true,
    ['transcript-url'] = true,
    ['trans_title'] = true,
    ['type'] = true,
    ['url'] = true,
    ['URL'] = true,
    ['version'] = true,
    ['via'] = true,
    ['volume'] = true,
    ['work'] = true,
    ['year'] = true,
    ['zbl'] = true,
    ['ZBL'] = true,
},

numbered_arguments = {
    ['author#'] = true,
    ['Author#'] = true,
    ['author-first#'] = true,
    ['author#-first'] = true,
    ['author-last#'] = true,
    ['author#-last'] = true,
    ['author-link#'] = true,
    ['author#link'] = true,
    ['author#-link'] = true,
    ['authorlink#'] = true,
    ['author-mask#'] = true,
    ['author#mask'] = true,
    ['author#-mask'] = true,
    ['authormask#'] = true,
    ['editor#'] = true,
    ['Editor#'] = true,
    ['editor-first#'] = true,
    ['editor#-first'] = true,
    ['EditorGiven#'] = true,
    ['editor-last#'] = true,
    ['editor#-last'] = true,
    ['editor-link#'] = true,
    ['editor#link'] = true,
    ['editor#-link'] = true,
    ['editorlink#'] = true,
    ['editor-mask#'] = true,
    ['editor#mask'] = true,
    ['editor#-mask'] = true,
    ['editormask#'] = true,
    ['EditorSurname#'] = true,
    ['first#'] = true,
    ['given#'] = true,
    ['last#'] = true,
    ['surname#'] = true,
},
};

return whitelist;</text>
      <sha1>57s1ou09j72btwoys7zn8w9hhn4ligf</sha1>
    </revision>
    <revision>
      <id>4767</id>
      <parentid>4766</parentid>
      <timestamp>2013-04-08T15:33:44Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>add embargo</comment>
      <origin>4767</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="5677" sha1="ophva6cdfm50q4gt1svdpsywvh9zql9" xml:space="preserve">whitelist = {

basic_arguments = {
    ['accessdate'] = true,
    ['access-date'] = true,
    ['agency'] = true,
    ['airdate'] = true,
    ['archivedate'] = true,
    ['archive-date'] = true,
    ['archiveurl'] = true,
    ['archive-url'] = true,
    ['article'] = true,
    ['arxiv'] = true,
    ['ARXIV'] = true,
    ['asin'] = true,
    ['ASIN'] = true,
    ['asin-tld'] = true,
    ['ASIN-TLD'] = true,
    ['at'] = true,
    ['author'] = true,
    ['Author'] = true,
    ['author-first'] = true,
    ['authorformat'] = true,
    ['author-format'] = true,
    ['author-last'] = true,
    ['authorlink'] = true,
    ['author-link'] = true,
    ['authormask'] = true,
    ['author-mask'] = true,
    ['author-name-separator'] = true,
    ['authors'] = true,
    ['author-separator'] = true,
    ['began'] = true,
    ['bibcode'] = true,
    ['BIBCODE'] = true,
    ['booktitle'] = true,
    ['chapter'] = true,
    ['chapterlink'] = true,
    ['chapterurl'] = true,
    ['chapter-url'] = true,
    ['coauthor'] = true,
    ['coauthors'] = true,
    ['conference'] = true,
    ['conferenceurl'] = true,
    ['conference-url'] = true,
    ['contribution'] = true,
    ['contribution-url'] = true,
    ['contributor'] = true,
    ['date'] = true,
    ['day'] = true,
    ['deadurl'] = true,
    ['department'] = true,
    ['dictionary'] = true,
    ['displayauthors'] = true,
    ['display-authors'] = true,
    ['displayeditors'] = true,
    ['display-editors'] = true,
    ['doi'] = true,
    ['DOI'] = true,
    ['DoiBroken'] = true,
    ['doi_brokendate'] = true,
    ['doi_inactivedate'] = true,
    ['edition'] = true,
    ['editor'] = true,
    ['Editor'] = true,
    ['editor-first'] = true,
    ['editorformat'] = true,
    ['editor-format'] = true,
    ['EditorGiven'] = true,
    ['editor-last'] = true,
    ['editorlink'] = true,
    ['editor-link'] = true,
    ['editormask'] = true,
    ['editor-mask'] = true,
    ['editor-name-separator'] = true,
    ['editors'] = true,
    ['editor-separator'] = true,
    ['EditorSurname'] = true,
    ['embargo'] = true,
    ['Embargo'] = true,
    ['encyclopaedia'] = true,
    ['encyclopedia'] = true,
    ['ended'] = true,
    ['entry'] = true,
    ['episodelink'] = true,
    ['first'] = true,
    ['format'] = true,
    ['given'] = true,
    ['id'] = true,
    ['ID'] = true,
    ['in'] = true,
    ['isbn'] = true,
    ['ISBN'] = true,
    ['isbn13'] = true,
    ['ISBN13'] = true,
    ['issn'] = true,
    ['ISSN'] = true,
    ['issue'] = true,
    ['jfm'] = true,
    ['JFM'] = true,
    ['journal'] = true,
    ['jstor'] = true,
    ['JSTOR'] = true,
    ['language'] = true,
    ['last'] = true,
    ['lastauthoramp'] = true,
    ['laydate'] = true,
    ['laysource'] = true,
    ['laysummary'] = true,
    ['lccn'] = true,
    ['LCCN'] = true,
    ['location'] = true,
    ['magazine'] = true,
    ['minutes'] = true,
    ['month'] = true,
    ['mr'] = true,
    ['MR'] = true,
    ['NameSep'] = true,
    ['name-separator'] = true,
    ['network'] = true,
    ['newspaper'] = true,
    ['nocat'] = true,
    ['nopp'] = true,
    ['notracking'] = true,
    ['no-tracking'] = true,
    ['number'] = true,
    ['oclc'] = true,
    ['OCLC'] = true,
    ['ol'] = true,
    ['OL'] = true,
    ['origyear'] = true,
    ['osti'] = true,
    ['OSTI'] = true,
    ['others'] = true,
    ['p'] = true,
    ['page'] = true,
    ['pages'] = true,
    ['periodical'] = true,
    ['place'] = true,
    ['pmc'] = true,
    ['PMC'] = true,
    ['pmid'] = true,
    ['PMID'] = true,
    ['postscript'] = true,
    ['pp'] = true,
    ['publicationdate'] = true,
    ['publication-date'] = true,
    ['publicationplace'] = true,
    ['publication-place'] = true,
    ['publisher'] = true,
    ['quotation'] = true,
    ['quote'] = true,
    ['ref'] = true,
    ['Ref'] = true,
    ['rfc'] = true,
    ['RFC'] = true,
    ['season'] = true,
    ['separator'] = true,
    ['series'] = true,
    ['serieslink'] = true,
    ['seriesno'] = true,
    ['seriesnumber'] = true,
    ['series-separator'] = true,
    ['ssrn'] = true,
    ['SSRN'] = true,
    ['station'] = true,
    ['subscription'] = true,
    ['surname'] = true,
    ['template doc demo'] = true,
    ['time'] = true,
    ['timecaption'] = true,
    ['title'] = true,
    ['titlelink'] = true,
    ['trans_chapter'] = true,
    ['trans-chapter'] = true,
    ['transcript'] = true,
    ['transcripturl'] = true,
    ['transcript-url'] = true,
    ['trans_title'] = true,
    ['type'] = true,
    ['url'] = true,
    ['URL'] = true,
    ['version'] = true,
    ['via'] = true,
    ['volume'] = true,
    ['work'] = true,
    ['year'] = true,
    ['zbl'] = true,
    ['ZBL'] = true,
},

numbered_arguments = {
    ['author#'] = true,
    ['Author#'] = true,
    ['author-first#'] = true,
    ['author#-first'] = true,
    ['author-last#'] = true,
    ['author#-last'] = true,
    ['author-link#'] = true,
    ['author#link'] = true,
    ['author#-link'] = true,
    ['authorlink#'] = true,
    ['author-mask#'] = true,
    ['author#mask'] = true,
    ['author#-mask'] = true,
    ['authormask#'] = true,
    ['editor#'] = true,
    ['Editor#'] = true,
    ['editor-first#'] = true,
    ['editor#-first'] = true,
    ['EditorGiven#'] = true,
    ['editor-last#'] = true,
    ['editor#-last'] = true,
    ['editor-link#'] = true,
    ['editor#link'] = true,
    ['editor#-link'] = true,
    ['editorlink#'] = true,
    ['editor-mask#'] = true,
    ['editor#mask'] = true,
    ['editor#-mask'] = true,
    ['editormask#'] = true,
    ['EditorSurname#'] = true,
    ['first#'] = true,
    ['given#'] = true,
    ['last#'] = true,
    ['surname#'] = true,
},
};

return whitelist;</text>
      <sha1>ophva6cdfm50q4gt1svdpsywvh9zql9</sha1>
    </revision>
    <revision>
      <id>4768</id>
      <parentid>4767</parentid>
      <timestamp>2013-04-09T20:52:33Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>resync whitelist</comment>
      <origin>4768</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="5724" sha1="f13lazq0jypa9g9l2ek0tumbbnnxcax" xml:space="preserve">whitelist = {

basic_arguments = {
    ['accessdate'] = true,
    ['access-date'] = true,
    ['agency'] = true,
    ['airdate'] = true,
    ['archivedate'] = true,
    ['archive-date'] = true,
    ['archiveurl'] = true,
    ['archive-url'] = true,
    ['article'] = true,
    ['arxiv'] = true,
    ['ARXIV'] = true,
    ['asin'] = true,
    ['ASIN'] = true,
    ['asin-tld'] = true,
    ['ASIN-TLD'] = true,
    ['at'] = true,
    ['author'] = true,
    ['Author'] = true,
    ['author-first'] = true,
    ['authorformat'] = true,
    ['author-format'] = true,
    ['author-last'] = true,
    ['authorlink'] = true,
    ['author-link'] = true,
    ['authormask'] = true,
    ['author-mask'] = true,
    ['author-name-separator'] = true,
    ['authors'] = true,
    ['author-separator'] = true,
    ['began'] = true,
    ['bibcode'] = true,
    ['BIBCODE'] = true,
    ['booktitle'] = true,
    ['chapter'] = true,
    ['chapterlink'] = true,
    ['chapterurl'] = true,
    ['chapter-url'] = true,
    ['coauthor'] = true,
    ['coauthors'] = true,
    ['conference'] = true,
    ['conferenceurl'] = true,
    ['conference-url'] = true,
    ['contribution'] = true,
    ['contribution-url'] = true,
    ['contributor'] = true,
    ['date'] = true,
    ['day'] = true,
    ['deadurl'] = true,
    ['department'] = true,
    ['dictionary'] = true,
    ['displayauthors'] = true,
    ['display-authors'] = true,
    ['displayeditors'] = true,
    ['display-editors'] = true,
    ['docket'] = true,
    ['doi'] = true,
    ['DOI'] = true,
    ['DoiBroken'] = true,
    ['doi_brokendate'] = true,
    ['doi_inactivedate'] = true,
    ['edition'] = true,
    ['editor'] = true,
    ['Editor'] = true,
    ['editor-first'] = true,
    ['editorformat'] = true,
    ['editor-format'] = true,
    ['EditorGiven'] = true,
    ['editor-last'] = true,
    ['editorlink'] = true,
    ['editor-link'] = true,
    ['editormask'] = true,
    ['editor-mask'] = true,
    ['editor-name-separator'] = true,
    ['editors'] = true,
    ['editor-separator'] = true,
    ['EditorSurname'] = true,
    ['embargo'] = true,
    ['Embargo'] = true,
    ['encyclopaedia'] = true,
    ['encyclopedia'] = true,
    ['ended'] = true,
    ['entry'] = true,
    ['episodelink'] = true,
    ['first'] = true,
    ['format'] = true,
    ['given'] = true,
    ['id'] = true,
    ['ID'] = true,
    ['in'] = true,
    ['isbn'] = true,
    ['ISBN'] = true,
    ['isbn13'] = true,
    ['ISBN13'] = true,
    ['issn'] = true,
    ['ISSN'] = true,
    ['issue'] = true,
    ['jfm'] = true,
    ['JFM'] = true,
    ['journal'] = true,
    ['jstor'] = true,
    ['JSTOR'] = true,
    ['language'] = true,
    ['last'] = true,
    ['lastauthoramp'] = true,
    ['laydate'] = true,
    ['laysource'] = true,
    ['laysummary'] = true,
    ['lccn'] = true,
    ['LCCN'] = true,
    ['location'] = true,
    ['magazine'] = true,
    ['minutes'] = true,
    ['month'] = true,
    ['mr'] = true,
    ['MR'] = true,
    ['NameSep'] = true,
    ['name-separator'] = true,
    ['network'] = true,
    ['newspaper'] = true,
    ['nocat'] = true,
    ['nopp'] = true,
    ['notracking'] = true,
    ['no-tracking'] = true,
    ['number'] = true,
    ['oclc'] = true,
    ['OCLC'] = true,
    ['ol'] = true,
    ['OL'] = true,
    ['origyear'] = true,
    ['osti'] = true,
    ['OSTI'] = true,
    ['others'] = true,
    ['p'] = true,
    ['page'] = true,
    ['pages'] = true,
    ['periodical'] = true,
    ['place'] = true,
    ['pmc'] = true,
    ['PMC'] = true,
    ['pmid'] = true,
    ['PMID'] = true,
    ['postscript'] = true,
    ['pp'] = true,
    ['publicationdate'] = true,
    ['publication-date'] = true,
    ['publicationplace'] = true,
    ['publication-place'] = true,
    ['publisher'] = true,
    ['quotation'] = true,
    ['quote'] = true,
    ['ref'] = true,
    ['Ref'] = true,
    ['rfc'] = true,
    ['RFC'] = true,
    ['season'] = true,
    ['separator'] = true,
    ['series'] = true,
    ['serieslink'] = true,
    ['seriesno'] = true,
    ['seriesnumber'] = true,
    ['series-separator'] = true,
    ['ssrn'] = true,
    ['SSRN'] = true,
    ['station'] = true,
    ['subscription'] = true,
    ['surname'] = true,
    ['template doc demo'] = true,
    ['time'] = true,
    ['timecaption'] = true,
    ['title'] = true,
    ['titlelink'] = true,
    ['trans_chapter'] = true,
    ['trans-chapter'] = true,
    ['transcript'] = true,
    ['transcripturl'] = true,
    ['transcript-url'] = true,
    ['trans_title'] = true,
    ['type'] = true,
    ['url'] = true,
    ['URL'] = true,
    ['version'] = true,
    ['via'] = true,
    ['volume'] = true,
    ['website'] = true,
    ['work'] = true,
    ['year'] = true,
    ['zbl'] = true,
    ['ZBL'] = true,
},

numbered_arguments = {
    ['author#'] = true,
    ['Author#'] = true,
    ['author-first#'] = true,
    ['author#-first'] = true,
    ['author-last#'] = true,
    ['author#-last'] = true,
    ['author-link#'] = true,
    ['author#link'] = true,
    ['author#-link'] = true,
    ['authorlink#'] = true,
    ['author-mask#'] = true,
    ['author#mask'] = true,
    ['author#-mask'] = true,
    ['authormask#'] = true,
    ['editor#'] = true,
    ['Editor#'] = true,
    ['editor-first#'] = true,
    ['editor#-first'] = true,
    ['EditorGiven#'] = true,
    ['editor-last#'] = true,
    ['editor#-last'] = true,
    ['editor-link#'] = true,
    ['editor#link'] = true,
    ['editor#-link'] = true,
    ['editorlink#'] = true,
    ['editor-mask#'] = true,
    ['editor#mask'] = true,
    ['editor#-mask'] = true,
    ['editormask#'] = true,
    ['EditorSurname#'] = true,
    ['first#'] = true,
    ['given#'] = true,
    ['last#'] = true,
    ['surname#'] = true,
},
};

return whitelist;</text>
      <sha1>f13lazq0jypa9g9l2ek0tumbbnnxcax</sha1>
    </revision>
    <revision>
      <id>4769</id>
      <parentid>4768</parentid>
      <timestamp>2013-04-11T15:11:57Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>update</comment>
      <origin>4769</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="5850" sha1="974xpnxkqbkj5inq4tdgilksbsxswq0" xml:space="preserve">whitelist = {

basic_arguments = {
    ['accessdate'] = true,
    ['access-date'] = true,
    ['agency'] = true,
    ['airdate'] = true,
    ['archivedate'] = true,
    ['archive-date'] = true,
    ['archiveurl'] = true,
    ['archive-url'] = true,
    ['article'] = true,
    ['arxiv'] = true,
    ['ARXIV'] = true,
    ['asin'] = true,
    ['ASIN'] = true,
    ['asin-tld'] = true,
    ['ASIN-TLD'] = true,
    ['at'] = true,
    ['author'] = true,
    ['Author'] = true,
    ['author-first'] = true,
    ['authorformat'] = true,
    ['author-format'] = true,
    ['author-last'] = true,
    ['authorlink'] = true,
    ['author-link'] = true,
    ['authormask'] = true,
    ['author-mask'] = true,
    ['author-name-separator'] = true,
    ['authors'] = true,
    ['author-separator'] = true,
    ['began'] = true,
    ['bibcode'] = true,
    ['BIBCODE'] = true,
    ['booktitle'] = true,
    ['chapter'] = true,
    ['chapterlink'] = true,
    ['chapterurl'] = true,
    ['chapter-url'] = true,
    ['coauthor'] = true,
    ['coauthors'] = true,
    ['conference'] = true,
    ['conferenceurl'] = true,
    ['conference-url'] = true,
    ['contribution'] = true,
    ['contributionurl'] = true,
    ['contribution-url'] = true,
    ['contributor'] = true,
    ['date'] = true,
    ['day'] = true,
    ['deadurl'] = true,
    ['department'] = true,
    ['dictionary'] = true,
    ['displayauthors'] = true,
    ['display-authors'] = true,
    ['displayeditors'] = true,
    ['display-editors'] = true,
    ['docket'] = true,
    ['doi'] = true,
    ['DOI'] = true,
    ['DoiBroken'] = true,
    ['doi_brokendate'] = true,
    ['doi_inactivedate'] = true,
    ['edition'] = true,
    ['editor'] = true,
    ['Editor'] = true,
    ['editor-first'] = true,
    ['editorformat'] = true,
    ['editor-format'] = true,
    ['EditorGiven'] = true,
    ['editor-last'] = true,
    ['editorlink'] = true,
    ['editor-link'] = true,
    ['editormask'] = true,
    ['editor-mask'] = true,
    ['editor-name-separator'] = true,
    ['editors'] = true,
    ['editor-separator'] = true,
    ['EditorSurname'] = true,
    ['embargo'] = true,
    ['Embargo'] = true,
    ['encyclopaedia'] = true,
    ['encyclopedia'] = true,
    ['ended'] = true,
    ['entry'] = true,
    ['episodelink'] = true,
    ['first'] = true,
    ['format'] = true,
    ['given'] = true,
    ['id'] = true,
    ['ID'] = true,
    ['ignoreisbnerror'] = true,
    ['ignore-isbn-error'] = true,
    ['in'] = true,
    ['isbn'] = true,
    ['ISBN'] = true,
    ['isbn13'] = true,
    ['ISBN13'] = true,
    ['issn'] = true,
    ['ISSN'] = true,
    ['issue'] = true,
    ['jfm'] = true,
    ['JFM'] = true,
    ['journal'] = true,
    ['jstor'] = true,
    ['JSTOR'] = true,
    ['language'] = true,
    ['last'] = true,
    ['lastauthoramp'] = true,
    ['laydate'] = true,
    ['laysource'] = true,
    ['laysummary'] = true,
    ['lccn'] = true,
    ['LCCN'] = true,
    ['location'] = true,
    ['magazine'] = true,
    ['minutes'] = true,
    ['month'] = true,
    ['mr'] = true,
    ['MR'] = true,
    ['NameSep'] = true,
    ['name-separator'] = true,
    ['network'] = true,
    ['newspaper'] = true,
    ['nocat'] = true,
    ['nopp'] = true,
    ['notracking'] = true,
    ['no-tracking'] = true,
    ['number'] = true,
    ['oclc'] = true,
    ['OCLC'] = true,
    ['ol'] = true,
    ['OL'] = true,
    ['origyear'] = true,
    ['osti'] = true,
    ['OSTI'] = true,
    ['others'] = true,
    ['p'] = true,
    ['page'] = true,
    ['pages'] = true,
    ['periodical'] = true,
    ['place'] = true,
    ['pmc'] = true,
    ['PMC'] = true,
    ['pmid'] = true,
    ['PMID'] = true,
    ['postscript'] = true,
    ['pp'] = true,
    ['publicationdate'] = true,
    ['publication-date'] = true,
    ['publicationplace'] = true,
    ['publication-place'] = true,
    ['publisher'] = true,
    ['quotation'] = true,
    ['quote'] = true,
    ['ref'] = true,
    ['Ref'] = true,
    ['rfc'] = true,
    ['RFC'] = true,
    ['season'] = true,
    ['separator'] = true,
    ['series'] = true,
    ['serieslink'] = true,
    ['seriesno'] = true,
    ['seriesnumber'] = true,
    ['series-separator'] = true,
    ['ssrn'] = true,
    ['SSRN'] = true,
    ['station'] = true,
    ['subscription'] = true,
    ['surname'] = true,
    ['template doc demo'] = true,
    ['time'] = true,
    ['timecaption'] = true,
    ['title'] = true,
    ['titlelink'] = true,
    ['trans_chapter'] = true,
    ['trans-chapter'] = true,
    ['transcript'] = true,
    ['transcripturl'] = true,
    ['transcript-url'] = true,
    ['trans_title'] = true,
    ['trans-title'] = true,
    ['type'] = true,
    ['url'] = true,
    ['URL'] = true,
    ['version'] = true,
    ['via'] = true,
    ['volume'] = true,
    ['website'] = true,
    ['work'] = true,
    ['year'] = true,
    ['zbl'] = true,
    ['ZBL'] = true,
},

numbered_arguments = {
    ['author#'] = true,
    ['Author#'] = true,
    ['author-first#'] = true,
    ['author#-first'] = true,
    ['author-last#'] = true,
    ['author#-last'] = true,
    ['author-link#'] = true,
    ['author#link'] = true,
    ['author#-link'] = true,
    ['authorlink#'] = true,
    ['author-mask#'] = true,
    ['author#mask'] = true,
    ['author#-mask'] = true,
    ['authormask#'] = true,
    ['editor#'] = true,
    ['Editor#'] = true,
    ['editor-first#'] = true,
    ['editor#-first'] = true,
    ['EditorGiven#'] = true,
    ['editor-last#'] = true,
    ['editor#-last'] = true,
    ['editor-link#'] = true,
    ['editor#link'] = true,
    ['editor#-link'] = true,
    ['editorlink#'] = true,
    ['editor-mask#'] = true,
    ['editor#mask'] = true,
    ['editor#-mask'] = true,
    ['editormask#'] = true,
    ['EditorSurname#'] = true,
    ['first#'] = true,
    ['given#'] = true,
    ['last#'] = true,
    ['surname#'] = true,
},
};

return whitelist;</text>
      <sha1>974xpnxkqbkj5inq4tdgilksbsxswq0</sha1>
    </revision>
    <revision>
      <id>4770</id>
      <parentid>4769</parentid>
      <timestamp>2013-04-17T00:54:28Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>resync whitelist</comment>
      <origin>4770</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="5869" sha1="1oxt1yddhp001cdm01jnr7chz2vilej" xml:space="preserve">whitelist = {

basic_arguments = {
    ['accessdate'] = true,
    ['agency'] = true,
    ['airdate'] = true,
    ['archivedate'] = true,
    ['archive-date'] = true,
    ['archiveurl'] = true,
    ['archive-url'] = true,
    ['article'] = true,
    ['arxiv'] = true,
    ['ARXIV'] = true,
    ['asin'] = true,
    ['ASIN'] = true,
    ['asin-tld'] = true,
    ['ASIN-TLD'] = true,
    ['at'] = true,
    ['author'] = true,
    ['Author'] = true,
    ['author-first'] = true,
    ['authorformat'] = true,
    ['author-format'] = true,
    ['author-last'] = true,
    ['authorlink'] = true,
    ['author-link'] = true,
    ['authormask'] = true,
    ['author-mask'] = true,
    ['author-name-separator'] = true,
    ['authors'] = true,
    ['author-separator'] = true,
    ['began'] = true,
    ['bibcode'] = true,
    ['BIBCODE'] = true,
    ['booktitle'] = true,
    ['chapter'] = true,
    ['chapterlink'] = true,
    ['chapterurl'] = true,
    ['chapter-url'] = true,
    ['coauthor'] = true,
    ['coauthors'] = true,
    ['conference'] = true,
    ['conferenceurl'] = true,
    ['conference-url'] = true,
    ['contribution'] = true,
    ['contributionurl'] = true,
    ['contribution-url'] = true,
    ['date'] = true,
    ['day'] = true,
    ['deadurl'] = true,
    ['department'] = true,
    ['dictionary'] = true,
    ['displayauthors'] = true,
    ['display-authors'] = true,
    ['displayeditors'] = true,
    ['display-editors'] = true,
    ['docket'] = true,
    ['doi'] = true,
    ['DOI'] = true,
    ['DoiBroken'] = true,
    ['doi_brokendate'] = true,
    ['doi_inactivedate'] = true,
    ['edition'] = true,
    ['editor'] = true,
    ['Editor'] = true,
    ['editor-first'] = true,
    ['editorformat'] = true,
    ['editor-format'] = true,
    ['EditorGiven'] = true,
    ['editor-last'] = true,
    ['editorlink'] = true,
    ['editor-link'] = true,
    ['editormask'] = true,
    ['editor-mask'] = true,
    ['editor-name-separator'] = true,
    ['editors'] = true,
    ['editor-separator'] = true,
    ['EditorSurname'] = true,
    ['embargo'] = true,
    ['Embargo'] = true,
    ['encyclopaedia'] = true,
    ['encyclopedia'] = true,
    ['ended'] = true,
    ['entry'] = true,
    ['episodelink'] = true,
    ['first'] = true,
    ['format'] = true,
    ['given'] = true,
    ['id'] = true,
    ['ID'] = true,
    ['ignoreisbnerror'] = true,
    ['ignore-isbn-error'] = true,
    ['in'] = true,
    ['isbn'] = true,
    ['ISBN'] = true,
    ['isbn13'] = true,
    ['ISBN13'] = true,
    ['issn'] = true,
    ['ISSN'] = true,
    ['issue'] = true,
    ['jfm'] = true,
    ['JFM'] = true,
    ['journal'] = true,
    ['jstor'] = true,
    ['JSTOR'] = true,
    ['language'] = true,
    ['last'] = true,
    ['lastauthoramp'] = true,
    ['laydate'] = true,
    ['laysource'] = true,
    ['laysummary'] = true,
    ['lccn'] = true,
    ['LCCN'] = true,
    ['location'] = true,
    ['magazine'] = true,
    ['minutes'] = true,
    ['month'] = true,
    ['mr'] = true,
    ['MR'] = true,
    ['name-separator'] = true,
    ['network'] = true,
    ['newspaper'] = true,
    ['nocat'] = true,
    ['nopp'] = true,
    ['notracking'] = true,
    ['no-tracking'] = true,
    ['number'] = true,
    ['oclc'] = true,
    ['OCLC'] = true,
    ['ol'] = true,
    ['OL'] = true,
    ['origyear'] = true,
    ['osti'] = true,
    ['OSTI'] = true,
    ['others'] = true,
    ['p'] = true,
    ['page'] = true,
    ['pages'] = true,
    ['periodical'] = true,
    ['place'] = true,
    ['pmc'] = true,
    ['PMC'] = true,
    ['pmid'] = true,
    ['PMID'] = true,
    ['postscript'] = true,
    ['pp'] = true,
    ['PPPrefix'] = true,
    ['PPrefix'] = true,
    ['publicationdate'] = true,
    ['publication-date'] = true,
    ['publicationplace'] = true,
    ['publication-place'] = true,
    ['publisher'] = true,
    ['quotation'] = true,
    ['quote'] = true,
    ['ref'] = true,
    ['Ref'] = true,
    ['rfc'] = true,
    ['RFC'] = true,
    ['season'] = true,
    ['separator'] = true,
    ['series'] = true,
    ['serieslink'] = true,
    ['seriesno'] = true,
    ['seriesnumber'] = true,
    ['series-separator'] = true,
    ['ssrn'] = true,
    ['SSRN'] = true,
    ['station'] = true,
    ['subscription'] = true,
    ['surname'] = true,
    ['template doc demo'] = true,
    ['time'] = true,
    ['timecaption'] = true,
    ['title'] = true,
    ['titlelink'] = true,
    ['trans_chapter'] = true,
    ['trans-chapter'] = true,
    ['transcript'] = true,
    ['transcripturl'] = true,
    ['transcript-url'] = true,
    ['trans_title'] = true,
    ['trans-title'] = true,
    ['type'] = true,
    ['url'] = true,
    ['URL'] = true,
    ['version'] = true,
    ['via'] = true,
    ['volume'] = true,
    ['website'] = true,
    ['work'] = true,
    ['year'] = true,
    ['zbl'] = true,
    ['ZBL'] = true,
},

numbered_arguments = {
    ['author#'] = true,
    ['Author#'] = true,
    ['author-first#'] = true,
    ['author#-first'] = true,
    ['author-last#'] = true,
    ['author#-last'] = true,
    ['author-link#'] = true,
    ['author#link'] = true,
    ['author#-link'] = true,
    ['authorlink#'] = true,
    ['author-mask#'] = true,
    ['author#mask'] = true,
    ['author#-mask'] = true,
    ['authormask#'] = true,
    ['authors#'] = true,
    ['editor#'] = true,
    ['Editor#'] = true,
    ['editor-first#'] = true,
    ['editor#-first'] = true,
    ['EditorGiven#'] = true,
    ['editor-last#'] = true,
    ['editor#-last'] = true,
    ['editor-link#'] = true,
    ['editor#link'] = true,
    ['editor#-link'] = true,
    ['editorlink#'] = true,
    ['editor-mask#'] = true,
    ['editor#mask'] = true,
    ['editor#-mask'] = true,
    ['editormask#'] = true,
    ['editors#'] = true,
    ['EditorSurname#'] = true,
    ['first#'] = true,
    ['given#'] = true,
    ['last#'] = true,
    ['surname#'] = true,
},
};

return whitelist;</text>
      <sha1>1oxt1yddhp001cdm01jnr7chz2vilej</sha1>
    </revision>
    <revision>
      <id>4771</id>
      <parentid>4770</parentid>
      <timestamp>2013-04-25T18:42:43Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>adds layurl synonym</comment>
      <origin>4771</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="5848" sha1="1e1v168kayrv7cl5z9o3ycf2rnav1tj" xml:space="preserve">whitelist = {

basic_arguments = {
    ['accessdate'] = true,
    ['agency'] = true,
    ['airdate'] = true,
    ['archivedate'] = true,
    ['archive-date'] = true,
    ['archiveurl'] = true,
    ['archive-url'] = true,
    ['article'] = true,
    ['arxiv'] = true,
    ['ARXIV'] = true,
    ['asin'] = true,
    ['ASIN'] = true,
    ['asin-tld'] = true,
    ['ASIN-TLD'] = true,
    ['at'] = true,
    ['author'] = true,
    ['Author'] = true,
    ['author-first'] = true,
    ['authorformat'] = true,
    ['author-format'] = true,
    ['author-last'] = true,
    ['authorlink'] = true,
    ['author-link'] = true,
    ['authormask'] = true,
    ['author-mask'] = true,
    ['author-name-separator'] = true,
    ['authors'] = true,
    ['author-separator'] = true,
    ['bibcode'] = true,
    ['BIBCODE'] = true,
    ['booktitle'] = true,
    ['chapter'] = true,
    ['chapterlink'] = true,
    ['chapterurl'] = true,
    ['chapter-url'] = true,
    ['coauthor'] = true,
    ['coauthors'] = true,
    ['conference'] = true,
    ['conferenceurl'] = true,
    ['conference-url'] = true,
    ['contribution'] = true,
    ['contributionurl'] = true,
    ['contribution-url'] = true,
    ['date'] = true,
    ['day'] = true,
    ['deadurl'] = true,
    ['department'] = true,
    ['dictionary'] = true,
    ['displayauthors'] = true,
    ['display-authors'] = true,
    ['displayeditors'] = true,
    ['display-editors'] = true,
    ['docket'] = true,
    ['doi'] = true,
    ['DOI'] = true,
    ['DoiBroken'] = true,
    ['doi_brokendate'] = true,
    ['doi_inactivedate'] = true,
    ['edition'] = true,
    ['editor'] = true,
    ['Editor'] = true,
    ['editor-first'] = true,
    ['editorformat'] = true,
    ['editor-format'] = true,
    ['EditorGiven'] = true,
    ['editor-last'] = true,
    ['editorlink'] = true,
    ['editor-link'] = true,
    ['editormask'] = true,
    ['editor-mask'] = true,
    ['editor-name-separator'] = true,
    ['editors'] = true,
    ['editor-separator'] = true,
    ['EditorSurname'] = true,
    ['embargo'] = true,
    ['Embargo'] = true,
    ['encyclopaedia'] = true,
    ['encyclopedia'] = true,
    ['entry'] = true,
    ['episodelink'] = true,
    ['first'] = true,
    ['format'] = true,
    ['given'] = true,
    ['id'] = true,
    ['ID'] = true,
    ['ignoreisbnerror'] = true,
    ['ignore-isbn-error'] = true,
    ['in'] = true,
    ['isbn'] = true,
    ['ISBN'] = true,
    ['isbn13'] = true,
    ['ISBN13'] = true,
    ['issn'] = true,
    ['ISSN'] = true,
    ['issue'] = true,
    ['jfm'] = true,
    ['JFM'] = true,
    ['journal'] = true,
    ['jstor'] = true,
    ['JSTOR'] = true,
    ['language'] = true,
    ['last'] = true,
    ['lastauthoramp'] = true,
    ['laydate'] = true,
    ['laysource'] = true,
    ['laysummary'] = true,
    ['layurl'] = true,
    ['lccn'] = true,
    ['LCCN'] = true,
    ['location'] = true,
    ['magazine'] = true,
    ['minutes'] = true,
    ['month'] = true,
    ['mr'] = true,
    ['MR'] = true,
    ['name-separator'] = true,
    ['network'] = true,
    ['newspaper'] = true,
    ['nocat'] = true,
    ['nopp'] = true,
    ['notracking'] = true,
    ['no-tracking'] = true,
    ['number'] = true,
    ['oclc'] = true,
    ['OCLC'] = true,
    ['ol'] = true,
    ['OL'] = true,
    ['origyear'] = true,
    ['osti'] = true,
    ['OSTI'] = true,
    ['others'] = true,
    ['p'] = true,
    ['page'] = true,
    ['pages'] = true,
    ['periodical'] = true,
    ['place'] = true,
    ['pmc'] = true,
    ['PMC'] = true,
    ['pmid'] = true,
    ['PMID'] = true,
    ['postscript'] = true,
    ['pp'] = true,
    ['PPPrefix'] = true,
    ['PPrefix'] = true,
    ['publicationdate'] = true,
    ['publication-date'] = true,
    ['publicationplace'] = true,
    ['publication-place'] = true,
    ['publisher'] = true,
    ['quotation'] = true,
    ['quote'] = true,
    ['ref'] = true,
    ['Ref'] = true,
    ['rfc'] = true,
    ['RFC'] = true,
    ['season'] = true,
    ['separator'] = true,
    ['series'] = true,
    ['serieslink'] = true,
    ['seriesno'] = true,
    ['seriesnumber'] = true,
    ['series-separator'] = true,
    ['ssrn'] = true,
    ['SSRN'] = true,
    ['station'] = true,
    ['subscription'] = true,
    ['surname'] = true,
    ['template doc demo'] = true,
    ['time'] = true,
    ['timecaption'] = true,
    ['title'] = true,
    ['titlelink'] = true,
    ['trans_chapter'] = true,
    ['trans-chapter'] = true,
    ['transcript'] = true,
    ['transcripturl'] = true,
    ['transcript-url'] = true,
    ['trans_title'] = true,
    ['trans-title'] = true,
    ['type'] = true,
    ['url'] = true,
    ['URL'] = true,
    ['version'] = true,
    ['via'] = true,
    ['volume'] = true,
    ['website'] = true,
    ['work'] = true,
    ['year'] = true,
    ['zbl'] = true,
    ['ZBL'] = true,
},

numbered_arguments = {
    ['author#'] = true,
    ['Author#'] = true,
    ['author-first#'] = true,
    ['author#-first'] = true,
    ['author-last#'] = true,
    ['author#-last'] = true,
    ['author-link#'] = true,
    ['author#link'] = true,
    ['author#-link'] = true,
    ['authorlink#'] = true,
    ['author-mask#'] = true,
    ['author#mask'] = true,
    ['author#-mask'] = true,
    ['authormask#'] = true,
    ['authors#'] = true,
    ['editor#'] = true,
    ['Editor#'] = true,
    ['editor-first#'] = true,
    ['editor#-first'] = true,
    ['EditorGiven#'] = true,
    ['editor-last#'] = true,
    ['editor#-last'] = true,
    ['editor-link#'] = true,
    ['editor#link'] = true,
    ['editor#-link'] = true,
    ['editorlink#'] = true,
    ['editor-mask#'] = true,
    ['editor#mask'] = true,
    ['editor#-mask'] = true,
    ['editormask#'] = true,
    ['editors#'] = true,
    ['EditorSurname#'] = true,
    ['first#'] = true,
    ['given#'] = true,
    ['last#'] = true,
    ['surname#'] = true,
},
};

return whitelist;</text>
      <sha1>1e1v168kayrv7cl5z9o3ycf2rnav1tj</sha1>
    </revision>
    <revision>
      <id>4772</id>
      <parentid>4771</parentid>
      <timestamp>2013-05-20T07:04:33Z</timestamp>
      <contributor>
        <username>Dragons flight</username>
        <id>809</id>
      </contributor>
      <comment>update</comment>
      <origin>4772</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="5990" sha1="o1zrmnmwevkurwoj914ss4rfyf11g9z" xml:space="preserve">whitelist = {

basic_arguments = {
    ['accessdate'] = true,
    ['agency'] = true,
    ['airdate'] = true,
    ['archivedate'] = true,
    ['archive-date'] = true,
    ['archiveurl'] = true,
    ['archive-url'] = true,
    ['article'] = true,
    ['arxiv'] = true,
    ['ARXIV'] = true,
    ['asin'] = true,
    ['ASIN'] = true,
    ['asin-tld'] = true,
    ['ASIN-TLD'] = true,
    ['at'] = true,
    ['author'] = true,
    ['Author'] = true,
    ['author-first'] = true,
    ['authorformat'] = true,
    ['author-format'] = true,
    ['author-last'] = true,
    ['authorlink'] = true,
    ['author-link'] = true,
    ['authormask'] = true,
    ['author-mask'] = true,
    ['author-name-separator'] = true,
    ['authors'] = true,
    ['author-separator'] = true,
    ['bibcode'] = true,
    ['BIBCODE'] = true,
    ['booktitle'] = true,
    ['cartography'] = true,
    ['chapter'] = true,
    ['chapterlink'] = true,
    ['chapterurl'] = true,
    ['chapter-url'] = true,
    ['coauthor'] = true,
    ['coauthors'] = true,
    ['conference'] = true,
    ['conferenceurl'] = true,
    ['conference-url'] = true,
    ['contribution'] = true,
    ['contributionurl'] = true,
    ['contribution-url'] = true,
    ['date'] = true,
    ['day'] = true,
    ['deadurl'] = true,
    ['department'] = true,
    ['dictionary'] = true,
    ['displayauthors'] = true,
    ['display-authors'] = true,
    ['displayeditors'] = true,
    ['display-editors'] = true,
    ['docket'] = true,
    ['doi'] = true,
    ['DOI'] = true,
    ['DoiBroken'] = true,
    ['doi_brokendate'] = true,
    ['doi_inactivedate'] = true,
    ['edition'] = true,
    ['editor'] = true,
    ['Editor'] = true,
    ['editor-first'] = true,
    ['editorformat'] = true,
    ['editor-format'] = true,
    ['EditorGiven'] = true,
    ['editor-last'] = true,
    ['editorlink'] = true,
    ['editor-link'] = true,
    ['editormask'] = true,
    ['editor-mask'] = true,
    ['editor-name-separator'] = true,
    ['editors'] = true,
    ['editor-separator'] = true,
    ['EditorSurname'] = true,
    ['embargo'] = true,
    ['Embargo'] = true,
    ['encyclopaedia'] = true,
    ['encyclopedia'] = true,
    ['entry'] = true,
    ['episodelink'] = true,
    ['first'] = true,
    ['format'] = true,
    ['given'] = true,
    ['id'] = true,
    ['ID'] = true,
    ['ignoreisbnerror'] = true,
    ['ignore-isbn-error'] = true,
    ['in'] = true,
    ['inset'] = true,
    ['isbn'] = true,
    ['ISBN'] = true,
    ['isbn13'] = true,
    ['ISBN13'] = true,
    ['issn'] = true,
    ['ISSN'] = true,
    ['issue'] = true,
    ['jfm'] = true,
    ['JFM'] = true,
    ['journal'] = true,
    ['jstor'] = true,
    ['JSTOR'] = true,
    ['language'] = true,
    ['last'] = true,
    ['lastauthoramp'] = true,
    ['laydate'] = true,
    ['laysource'] = true,
    ['laysummary'] = true,
    ['layurl'] = true,
    ['lccn'] = true,
    ['LCCN'] = true,
    ['location'] = true,
    ['magazine'] = true,
    ['medium'] = true,
    ['minutes'] = true,
    ['month'] = true,
    ['mr'] = true,
    ['MR'] = true,
    ['name-separator'] = true,
    ['network'] = true,
    ['newspaper'] = true,
    ['nocat'] = true,
    ['nopp'] = true,
    ['notracking'] = true,
    ['no-tracking'] = true,
    ['number'] = true,
    ['oclc'] = true,
    ['OCLC'] = true,
    ['ol'] = true,
    ['OL'] = true,
    ['origyear'] = true,
    ['osti'] = true,
    ['OSTI'] = true,
    ['others'] = true,
    ['p'] = true,
    ['page'] = true,
    ['pages'] = true,
    ['people'] = true,
    ['periodical'] = true,
    ['place'] = true,
    ['pmc'] = true,
    ['PMC'] = true,
    ['pmid'] = true,
    ['PMID'] = true,
    ['postscript'] = true,
    ['pp'] = true,
    ['PPPrefix'] = true,
    ['PPrefix'] = true,
    ['publicationdate'] = true,
    ['publication-date'] = true,
    ['publicationplace'] = true,
    ['publication-place'] = true,
    ['publisher'] = true,
    ['quotation'] = true,
    ['quote'] = true,
    ['ref'] = true,
    ['Ref'] = true,
    ['rfc'] = true,
    ['RFC'] = true,
    ['scale'] = true,
    ['season'] = true,
    ['section'] = true,
    ['separator'] = true,
    ['series'] = true,
    ['serieslink'] = true,
    ['seriesno'] = true,
    ['seriesnumber'] = true,
    ['series-separator'] = true,
    ['ssrn'] = true,
    ['SSRN'] = true,
    ['station'] = true,
    ['subscription'] = true,
    ['surname'] = true,
    ['template doc demo'] = true,
    ['time'] = true,
    ['timecaption'] = true,
    ['title'] = true,
    ['titlelink'] = true,
    ['trans_chapter'] = true,
    ['trans-chapter'] = true,
    ['transcript'] = true,
    ['transcripturl'] = true,
    ['transcript-url'] = true,
    ['trans_title'] = true,
    ['trans-title'] = true,
    ['type'] = true,
    ['url'] = true,
    ['URL'] = true,
    ['version'] = true,
    ['via'] = true,
    ['volume'] = true,
    ['website'] = true,
    ['work'] = true,
    ['year'] = true,
    ['zbl'] = true,
    ['ZBL'] = true,
},

numbered_arguments = {
    ['author#'] = true,
    ['Author#'] = true,
    ['author-first#'] = true,
    ['author#-first'] = true,
    ['author-last#'] = true,
    ['author#-last'] = true,
    ['author-link#'] = true,
    ['author#link'] = true,
    ['author#-link'] = true,
    ['authorlink#'] = true,
    ['author-mask#'] = true,
    ['author#mask'] = true,
    ['author#-mask'] = true,
    ['authormask#'] = true,
    ['authors#'] = true,
    ['editor#'] = true,
    ['Editor#'] = true,
    ['editor-first#'] = true,
    ['editor#-first'] = true,
    ['EditorGiven#'] = true,
    ['editor-last#'] = true,
    ['editor#-last'] = true,
    ['editor-link#'] = true,
    ['editor#link'] = true,
    ['editor#-link'] = true,
    ['editorlink#'] = true,
    ['editor-mask#'] = true,
    ['editor#mask'] = true,
    ['editor#-mask'] = true,
    ['editormask#'] = true,
    ['editors#'] = true,
    ['EditorSurname#'] = true,
    ['first#'] = true,
    ['given#'] = true,
    ['last#'] = true,
    ['surname#'] = true,
},
};

return whitelist;</text>
      <sha1>o1zrmnmwevkurwoj914ss4rfyf11g9z</sha1>
    </revision>
    <revision>
      <id>4773</id>
      <parentid>4772</parentid>
      <timestamp>2013-08-17T08:53:05Z</timestamp>
      <contributor>
        <username>Smith609</username>
        <id>819</id>
      </contributor>
      <comment>Add doix</comment>
      <origin>4773</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="6011" sha1="dmryh81yc66zxynyn2asrpc9b00na46" xml:space="preserve">whitelist = {

basic_arguments = {
    ['accessdate'] = true,
    ['agency'] = true,
    ['airdate'] = true,
    ['archivedate'] = true,
    ['archive-date'] = true,
    ['archiveurl'] = true,
    ['archive-url'] = true,
    ['article'] = true,
    ['arxiv'] = true,
    ['ARXIV'] = true,
    ['asin'] = true,
    ['ASIN'] = true,
    ['asin-tld'] = true,
    ['ASIN-TLD'] = true,
    ['at'] = true,
    ['author'] = true,
    ['Author'] = true,
    ['author-first'] = true,
    ['authorformat'] = true,
    ['author-format'] = true,
    ['author-last'] = true,
    ['authorlink'] = true,
    ['author-link'] = true,
    ['authormask'] = true,
    ['author-mask'] = true,
    ['author-name-separator'] = true,
    ['authors'] = true,
    ['author-separator'] = true,
    ['bibcode'] = true,
    ['BIBCODE'] = true,
    ['booktitle'] = true,
    ['cartography'] = true,
    ['chapter'] = true,
    ['chapterlink'] = true,
    ['chapterurl'] = true,
    ['chapter-url'] = true,
    ['coauthor'] = true,
    ['coauthors'] = true,
    ['conference'] = true,
    ['conferenceurl'] = true,
    ['conference-url'] = true,
    ['contribution'] = true,
    ['contributionurl'] = true,
    ['contribution-url'] = true,
    ['date'] = true,
    ['day'] = true,
    ['deadurl'] = true,
    ['department'] = true,
    ['dictionary'] = true,
    ['displayauthors'] = true,
    ['display-authors'] = true,
    ['displayeditors'] = true,
    ['display-editors'] = true,
    ['docket'] = true,
    ['doi'] = true,
    ['doix'] = true,
    ['DOI'] = true,
    ['DoiBroken'] = true,
    ['doi_brokendate'] = true,
    ['doi_inactivedate'] = true,
    ['edition'] = true,
    ['editor'] = true,
    ['Editor'] = true,
    ['editor-first'] = true,
    ['editorformat'] = true,
    ['editor-format'] = true,
    ['EditorGiven'] = true,
    ['editor-last'] = true,
    ['editorlink'] = true,
    ['editor-link'] = true,
    ['editormask'] = true,
    ['editor-mask'] = true,
    ['editor-name-separator'] = true,
    ['editors'] = true,
    ['editor-separator'] = true,
    ['EditorSurname'] = true,
    ['embargo'] = true,
    ['Embargo'] = true,
    ['encyclopaedia'] = true,
    ['encyclopedia'] = true,
    ['entry'] = true,
    ['episodelink'] = true,
    ['first'] = true,
    ['format'] = true,
    ['given'] = true,
    ['id'] = true,
    ['ID'] = true,
    ['ignoreisbnerror'] = true,
    ['ignore-isbn-error'] = true,
    ['in'] = true,
    ['inset'] = true,
    ['isbn'] = true,
    ['ISBN'] = true,
    ['isbn13'] = true,
    ['ISBN13'] = true,
    ['issn'] = true,
    ['ISSN'] = true,
    ['issue'] = true,
    ['jfm'] = true,
    ['JFM'] = true,
    ['journal'] = true,
    ['jstor'] = true,
    ['JSTOR'] = true,
    ['language'] = true,
    ['last'] = true,
    ['lastauthoramp'] = true,
    ['laydate'] = true,
    ['laysource'] = true,
    ['laysummary'] = true,
    ['layurl'] = true,
    ['lccn'] = true,
    ['LCCN'] = true,
    ['location'] = true,
    ['magazine'] = true,
    ['medium'] = true,
    ['minutes'] = true,
    ['month'] = true,
    ['mr'] = true,
    ['MR'] = true,
    ['name-separator'] = true,
    ['network'] = true,
    ['newspaper'] = true,
    ['nocat'] = true,
    ['nopp'] = true,
    ['notracking'] = true,
    ['no-tracking'] = true,
    ['number'] = true,
    ['oclc'] = true,
    ['OCLC'] = true,
    ['ol'] = true,
    ['OL'] = true,
    ['origyear'] = true,
    ['osti'] = true,
    ['OSTI'] = true,
    ['others'] = true,
    ['p'] = true,
    ['page'] = true,
    ['pages'] = true,
    ['people'] = true,
    ['periodical'] = true,
    ['place'] = true,
    ['pmc'] = true,
    ['PMC'] = true,
    ['pmid'] = true,
    ['PMID'] = true,
    ['postscript'] = true,
    ['pp'] = true,
    ['PPPrefix'] = true,
    ['PPrefix'] = true,
    ['publicationdate'] = true,
    ['publication-date'] = true,
    ['publicationplace'] = true,
    ['publication-place'] = true,
    ['publisher'] = true,
    ['quotation'] = true,
    ['quote'] = true,
    ['ref'] = true,
    ['Ref'] = true,
    ['rfc'] = true,
    ['RFC'] = true,
    ['scale'] = true,
    ['season'] = true,
    ['section'] = true,
    ['separator'] = true,
    ['series'] = true,
    ['serieslink'] = true,
    ['seriesno'] = true,
    ['seriesnumber'] = true,
    ['series-separator'] = true,
    ['ssrn'] = true,
    ['SSRN'] = true,
    ['station'] = true,
    ['subscription'] = true,
    ['surname'] = true,
    ['template doc demo'] = true,
    ['time'] = true,
    ['timecaption'] = true,
    ['title'] = true,
    ['titlelink'] = true,
    ['trans_chapter'] = true,
    ['trans-chapter'] = true,
    ['transcript'] = true,
    ['transcripturl'] = true,
    ['transcript-url'] = true,
    ['trans_title'] = true,
    ['trans-title'] = true,
    ['type'] = true,
    ['url'] = true,
    ['URL'] = true,
    ['version'] = true,
    ['via'] = true,
    ['volume'] = true,
    ['website'] = true,
    ['work'] = true,
    ['year'] = true,
    ['zbl'] = true,
    ['ZBL'] = true,
},

numbered_arguments = {
    ['author#'] = true,
    ['Author#'] = true,
    ['author-first#'] = true,
    ['author#-first'] = true,
    ['author-last#'] = true,
    ['author#-last'] = true,
    ['author-link#'] = true,
    ['author#link'] = true,
    ['author#-link'] = true,
    ['authorlink#'] = true,
    ['author-mask#'] = true,
    ['author#mask'] = true,
    ['author#-mask'] = true,
    ['authormask#'] = true,
    ['authors#'] = true,
    ['editor#'] = true,
    ['Editor#'] = true,
    ['editor-first#'] = true,
    ['editor#-first'] = true,
    ['EditorGiven#'] = true,
    ['editor-last#'] = true,
    ['editor#-last'] = true,
    ['editor-link#'] = true,
    ['editor#link'] = true,
    ['editor#-link'] = true,
    ['editorlink#'] = true,
    ['editor-mask#'] = true,
    ['editor#mask'] = true,
    ['editor#-mask'] = true,
    ['editormask#'] = true,
    ['editors#'] = true,
    ['EditorSurname#'] = true,
    ['first#'] = true,
    ['given#'] = true,
    ['last#'] = true,
    ['surname#'] = true,
},
};

return whitelist;</text>
      <sha1>dmryh81yc66zxynyn2asrpc9b00na46</sha1>
    </revision>
    <revision>
      <id>4774</id>
      <parentid>4773</parentid>
      <timestamp>2013-08-26T20:26:07Z</timestamp>
      <contributor>
        <username>Gadget850</username>
        <id>810</id>
      </contributor>
      <comment>update from sandbox</comment>
      <origin>4774</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="6046" sha1="qtp8ccgmbcrchxxunc2mk9s9pju24r2" xml:space="preserve">whitelist = {

basic_arguments = {
    ['accessdate'] = true,
    ['agency'] = true,
    ['airdate'] = true,
    ['archivedate'] = true,
    ['archive-date'] = true,
    ['archiveurl'] = true,
    ['archive-url'] = true,
    ['article'] = true,
    ['arxiv'] = true,
    ['ARXIV'] = true,
    ['asin'] = true,
    ['ASIN'] = true,
    ['asin-tld'] = true,
    ['ASIN-TLD'] = true,
    ['at'] = true,
    ['author'] = true,
    ['Author'] = true,
    ['author-first'] = true,
    ['authorformat'] = true,
    ['author-format'] = true,
    ['author-last'] = true,
    ['authorlink'] = true,
    ['author-link'] = true,
    ['authormask'] = true,
    ['author-mask'] = true,
    ['author-name-separator'] = true,
    ['authors'] = true,
    ['author-separator'] = true,
    ['bibcode'] = true,
    ['BIBCODE'] = true,
    ['booktitle'] = true,
    ['cartography'] = true,
    ['chapter'] = true,
    ['chapterlink'] = true,
    ['chapterurl'] = true,
    ['chapter-url'] = true,
    ['coauthor'] = true,
    ['coauthors'] = true,
    ['conference'] = true,
    ['conferenceurl'] = true,
    ['conference-url'] = true,
    ['contribution'] = true,
    ['contributionurl'] = true,
    ['contribution-url'] = true,
    ['date'] = true,
    ['day'] = true,
    ['deadurl'] = true,
    ['department'] = true,
    ['dictionary'] = true,
    ['displayauthors'] = true,
    ['display-authors'] = true,
    ['displayeditors'] = true,
    ['display-editors'] = true,
    ['docket'] = true,
    ['doi'] = true,
    ['DOI'] = true,
    ['DoiBroken'] = true,
    ['doi_brokendate'] = true,
    ['doi_inactivedate'] = true,
    ['edition'] = true,
    ['editor'] = true,
    ['Editor'] = true,
    ['editor-first'] = true,
    ['editorformat'] = true,
    ['editor-format'] = true,
    ['EditorGiven'] = true,
    ['editor-last'] = true,
    ['editorlink'] = true,
    ['editor-link'] = true,
    ['editormask'] = true,
    ['editor-mask'] = true,
    ['editor-name-separator'] = true,
    ['editors'] = true,
    ['editor-separator'] = true,
    ['EditorSurname'] = true,
    ['embargo'] = true,
    ['Embargo'] = true,
    ['encyclopaedia'] = true,
    ['encyclopedia'] = true,
    ['entry'] = true,
    ['episodelink'] = true,
    ['first'] = true,
    ['format'] = true,
    ['given'] = true,
    ['id'] = true,
    ['ID'] = true,
    ['ignoreisbnerror'] = true,
    ['ignore-isbn-error'] = true,
    ['in'] = true,
    ['inset'] = true,
    ['isbn'] = true,
    ['ISBN'] = true,
    ['isbn13'] = true,
    ['ISBN13'] = true,
    ['issn'] = true,
    ['ISSN'] = true,
    ['issue'] = true,
    ['jfm'] = true,
    ['JFM'] = true,
    ['journal'] = true,
    ['jstor'] = true,
    ['JSTOR'] = true,
    ['language'] = true,
    ['last'] = true,
    ['lastauthoramp'] = true,
    ['laydate'] = true,
    ['laysource'] = true,
    ['laysummary'] = true,
    ['layurl'] = true,
    ['lccn'] = true,
    ['LCCN'] = true,
    ['location'] = true,
    ['magazine'] = true,
    ['medium'] = true,
    ['minutes'] = true,
    ['month'] = true,
    ['mr'] = true,
    ['MR'] = true,
    ['name-separator'] = true,
    ['network'] = true,
    ['newspaper'] = true,
    ['nocat'] = true,
    ['nopp'] = true,
    ['notracking'] = true,
    ['no-tracking'] = true,
    ['number'] = true,
    ['oclc'] = true,
    ['OCLC'] = true,
    ['ol'] = true,
    ['OL'] = true,
    ['origyear'] = true,
    ['osti'] = true,
    ['OSTI'] = true,
    ['others'] = true,
    ['p'] = true,
    ['page'] = true,
    ['pages'] = true,
    ['people'] = true,
    ['periodical'] = true,
    ['place'] = true,
    ['pmc'] = true,
    ['PMC'] = true,
    ['pmid'] = true,
    ['PMID'] = true,
    ['postscript'] = true,
    ['pp'] = true,
    ['PPPrefix'] = true,
    ['PPrefix'] = true,
    ['publicationdate'] = true,
    ['publication-date'] = true,
    ['publicationplace'] = true,
    ['publication-place'] = true,
    ['publisher'] = true,
    ['quotation'] = true,
    ['quote'] = true,
    ['ref'] = true,
    ['Ref'] = true,
    ['registration'] = true,
    ['rfc'] = true,
    ['RFC'] = true,
    ['scale'] = true,
    ['season'] = true,
    ['section'] = true,
    ['sectionurl'] = true,
    ['separator'] = true,
    ['series'] = true,
    ['serieslink'] = true,
    ['seriesno'] = true,
    ['seriesnumber'] = true,
    ['series-separator'] = true,
    ['ssrn'] = true,
    ['SSRN'] = true,
    ['station'] = true,
    ['subscription'] = true,
    ['surname'] = true,
    ['template doc demo'] = true,
    ['time'] = true,
    ['timecaption'] = true,
    ['title'] = true,
    ['titlelink'] = true,
    ['trans_chapter'] = true,
    ['trans-chapter'] = true,
    ['transcript'] = true,
    ['transcripturl'] = true,
    ['transcript-url'] = true,
    ['trans_title'] = true,
    ['trans-title'] = true,
    ['type'] = true,
    ['url'] = true,
    ['URL'] = true,
    ['version'] = true,
    ['via'] = true,
    ['volume'] = true,
    ['website'] = true,
    ['work'] = true,
    ['year'] = true,
    ['zbl'] = true,
    ['ZBL'] = true,
},

numbered_arguments = {
    ['author#'] = true,
    ['Author#'] = true,
    ['author-first#'] = true,
    ['author#-first'] = true,
    ['author-last#'] = true,
    ['author#-last'] = true,
    ['author-link#'] = true,
    ['author#link'] = true,
    ['author#-link'] = true,
    ['authorlink#'] = true,
    ['author-mask#'] = true,
    ['author#mask'] = true,
    ['author#-mask'] = true,
    ['authormask#'] = true,
    ['authors#'] = true,
    ['editor#'] = true,
    ['Editor#'] = true,
    ['editor-first#'] = true,
    ['editor#-first'] = true,
    ['EditorGiven#'] = true,
    ['editor-last#'] = true,
    ['editor#-last'] = true,
    ['editor-link#'] = true,
    ['editor#link'] = true,
    ['editor#-link'] = true,
    ['editorlink#'] = true,
    ['editor-mask#'] = true,
    ['editor#mask'] = true,
    ['editor#-mask'] = true,
    ['editormask#'] = true,
    ['editors#'] = true,
    ['EditorSurname#'] = true,
    ['first#'] = true,
    ['given#'] = true,
    ['last#'] = true,
    ['surname#'] = true,
},
};

return whitelist;</text>
      <sha1>qtp8ccgmbcrchxxunc2mk9s9pju24r2</sha1>
    </revision>
    <revision>
      <id>4775</id>
      <parentid>4774</parentid>
      <timestamp>2013-08-31T11:31:36Z</timestamp>
      <contributor>
        <username>Gadget850</username>
        <id>810</id>
      </contributor>
      <comment>distributor for cite sign</comment>
      <origin>4775</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="6074" sha1="jdw9y179hinwaltgnp0mp5npmnpjjw0" xml:space="preserve">whitelist = {

basic_arguments = {
    ['accessdate'] = true,
    ['agency'] = true,
    ['airdate'] = true,
    ['archivedate'] = true,
    ['archive-date'] = true,
    ['archiveurl'] = true,
    ['archive-url'] = true,
    ['article'] = true,
    ['arxiv'] = true,
    ['ARXIV'] = true,
    ['asin'] = true,
    ['ASIN'] = true,
    ['asin-tld'] = true,
    ['ASIN-TLD'] = true,
    ['at'] = true,
    ['author'] = true,
    ['Author'] = true,
    ['author-first'] = true,
    ['authorformat'] = true,
    ['author-format'] = true,
    ['author-last'] = true,
    ['authorlink'] = true,
    ['author-link'] = true,
    ['authormask'] = true,
    ['author-mask'] = true,
    ['author-name-separator'] = true,
    ['authors'] = true,
    ['author-separator'] = true,
    ['bibcode'] = true,
    ['BIBCODE'] = true,
    ['booktitle'] = true,
    ['cartography'] = true,
    ['chapter'] = true,
    ['chapterlink'] = true,
    ['chapterurl'] = true,
    ['chapter-url'] = true,
    ['coauthor'] = true,
    ['coauthors'] = true,
    ['conference'] = true,
    ['conferenceurl'] = true,
    ['conference-url'] = true,
    ['contribution'] = true,
    ['contributionurl'] = true,
    ['contribution-url'] = true,
    ['date'] = true,
    ['day'] = true,
    ['deadurl'] = true,
    ['department'] = true,
    ['dictionary'] = true,
    ['displayauthors'] = true,
    ['display-authors'] = true,
    ['displayeditors'] = true,
    ['display-editors'] = true,
    ['distributor'] = true,
    ['docket'] = true,
    ['doi'] = true,
    ['DOI'] = true,
    ['DoiBroken'] = true,
    ['doi_brokendate'] = true,
    ['doi_inactivedate'] = true,
    ['edition'] = true,
    ['editor'] = true,
    ['Editor'] = true,
    ['editor-first'] = true,
    ['editorformat'] = true,
    ['editor-format'] = true,
    ['EditorGiven'] = true,
    ['editor-last'] = true,
    ['editorlink'] = true,
    ['editor-link'] = true,
    ['editormask'] = true,
    ['editor-mask'] = true,
    ['editor-name-separator'] = true,
    ['editors'] = true,
    ['editor-separator'] = true,
    ['EditorSurname'] = true,
    ['embargo'] = true,
    ['Embargo'] = true,
    ['encyclopaedia'] = true,
    ['encyclopedia'] = true,
    ['entry'] = true,
    ['episodelink'] = true,
    ['first'] = true,
    ['format'] = true,
    ['given'] = true,
    ['id'] = true,
    ['ID'] = true,
    ['ignoreisbnerror'] = true,
    ['ignore-isbn-error'] = true,
    ['in'] = true,
    ['inset'] = true,
    ['isbn'] = true,
    ['ISBN'] = true,
    ['isbn13'] = true,
    ['ISBN13'] = true,
    ['issn'] = true,
    ['ISSN'] = true,
    ['issue'] = true,
    ['jfm'] = true,
    ['JFM'] = true,
    ['journal'] = true,
    ['jstor'] = true,
    ['JSTOR'] = true,
    ['language'] = true,
    ['last'] = true,
    ['lastauthoramp'] = true,
    ['laydate'] = true,
    ['laysource'] = true,
    ['laysummary'] = true,
    ['layurl'] = true,
    ['lccn'] = true,
    ['LCCN'] = true,
    ['location'] = true,
    ['magazine'] = true,
    ['medium'] = true,
    ['minutes'] = true,
    ['month'] = true,
    ['mr'] = true,
    ['MR'] = true,
    ['name-separator'] = true,
    ['network'] = true,
    ['newspaper'] = true,
    ['nocat'] = true,
    ['nopp'] = true,
    ['notracking'] = true,
    ['no-tracking'] = true,
    ['number'] = true,
    ['oclc'] = true,
    ['OCLC'] = true,
    ['ol'] = true,
    ['OL'] = true,
    ['origyear'] = true,
    ['osti'] = true,
    ['OSTI'] = true,
    ['others'] = true,
    ['p'] = true,
    ['page'] = true,
    ['pages'] = true,
    ['people'] = true,
    ['periodical'] = true,
    ['place'] = true,
    ['pmc'] = true,
    ['PMC'] = true,
    ['pmid'] = true,
    ['PMID'] = true,
    ['postscript'] = true,
    ['pp'] = true,
    ['PPPrefix'] = true,
    ['PPrefix'] = true,
    ['publicationdate'] = true,
    ['publication-date'] = true,
    ['publicationplace'] = true,
    ['publication-place'] = true,
    ['publisher'] = true,
    ['quotation'] = true,
    ['quote'] = true,
    ['ref'] = true,
    ['Ref'] = true,
    ['registration'] = true,
    ['rfc'] = true,
    ['RFC'] = true,
    ['scale'] = true,
    ['season'] = true,
    ['section'] = true,
    ['sectionurl'] = true,
    ['separator'] = true,
    ['series'] = true,
    ['serieslink'] = true,
    ['seriesno'] = true,
    ['seriesnumber'] = true,
    ['series-separator'] = true,
    ['ssrn'] = true,
    ['SSRN'] = true,
    ['station'] = true,
    ['subscription'] = true,
    ['surname'] = true,
    ['template doc demo'] = true,
    ['time'] = true,
    ['timecaption'] = true,
    ['title'] = true,
    ['titlelink'] = true,
    ['trans_chapter'] = true,
    ['trans-chapter'] = true,
    ['transcript'] = true,
    ['transcripturl'] = true,
    ['transcript-url'] = true,
    ['trans_title'] = true,
    ['trans-title'] = true,
    ['type'] = true,
    ['url'] = true,
    ['URL'] = true,
    ['version'] = true,
    ['via'] = true,
    ['volume'] = true,
    ['website'] = true,
    ['work'] = true,
    ['year'] = true,
    ['zbl'] = true,
    ['ZBL'] = true,
},

numbered_arguments = {
    ['author#'] = true,
    ['Author#'] = true,
    ['author-first#'] = true,
    ['author#-first'] = true,
    ['author-last#'] = true,
    ['author#-last'] = true,
    ['author-link#'] = true,
    ['author#link'] = true,
    ['author#-link'] = true,
    ['authorlink#'] = true,
    ['author-mask#'] = true,
    ['author#mask'] = true,
    ['author#-mask'] = true,
    ['authormask#'] = true,
    ['authors#'] = true,
    ['editor#'] = true,
    ['Editor#'] = true,
    ['editor-first#'] = true,
    ['editor#-first'] = true,
    ['EditorGiven#'] = true,
    ['editor-last#'] = true,
    ['editor#-last'] = true,
    ['editor-link#'] = true,
    ['editor#link'] = true,
    ['editor#-link'] = true,
    ['editorlink#'] = true,
    ['editor-mask#'] = true,
    ['editor#mask'] = true,
    ['editor#-mask'] = true,
    ['editormask#'] = true,
    ['editors#'] = true,
    ['EditorSurname#'] = true,
    ['first#'] = true,
    ['given#'] = true,
    ['last#'] = true,
    ['surname#'] = true,
},
};

return whitelist;</text>
      <sha1>jdw9y179hinwaltgnp0mp5npmnpjjw0</sha1>
    </revision>
    <revision>
      <id>4776</id>
      <parentid>4775</parentid>
      <timestamp>2013-11-09T13:35:23Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox; Migrate cite thesis;</comment>
      <origin>4776</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="6097" sha1="spacucvxak3az39timata1wx948qpj8" xml:space="preserve">whitelist = {

basic_arguments = {
    ['accessdate'] = true,
    ['agency'] = true,
    ['airdate'] = true,
    ['archivedate'] = true,
    ['archive-date'] = true,
    ['archiveurl'] = true,
    ['archive-url'] = true,
    ['article'] = true,
    ['arxiv'] = true,
    ['ARXIV'] = true,
    ['asin'] = true,
    ['ASIN'] = true,
    ['asin-tld'] = true,
    ['ASIN-TLD'] = true,
    ['at'] = true,
    ['author'] = true,
    ['Author'] = true,
    ['author-first'] = true,
    ['authorformat'] = true,
    ['author-format'] = true,
    ['author-last'] = true,
    ['authorlink'] = true,
    ['author-link'] = true,
    ['authormask'] = true,
    ['author-mask'] = true,
    ['author-name-separator'] = true,
    ['authors'] = true,
    ['author-separator'] = true,
    ['bibcode'] = true,
    ['BIBCODE'] = true,
    ['booktitle'] = true,
    ['cartography'] = true,
    ['chapter'] = true,
    ['chapterlink'] = true,
    ['chapterurl'] = true,
    ['chapter-url'] = true,
    ['coauthor'] = true,
    ['coauthors'] = true,
    ['conference'] = true,
    ['conferenceurl'] = true,
    ['conference-url'] = true,
    ['contribution'] = true,
    ['contributionurl'] = true,
    ['contribution-url'] = true,
    ['date'] = true,
    ['day'] = true,
    ['deadurl'] = true,
    ['degree'] = true,
    ['department'] = true,
    ['dictionary'] = true,
    ['displayauthors'] = true,
    ['display-authors'] = true,
    ['displayeditors'] = true,
    ['display-editors'] = true,
    ['docket'] = true,
    ['doi'] = true,
    ['DOI'] = true,
    ['DoiBroken'] = true,
    ['doi_brokendate'] = true,
    ['doi_inactivedate'] = true,
    ['edition'] = true,
    ['editor'] = true,
    ['Editor'] = true,
    ['editor-first'] = true,
    ['editorformat'] = true,
    ['editor-format'] = true,
    ['EditorGiven'] = true,
    ['editor-last'] = true,
    ['editorlink'] = true,
    ['editor-link'] = true,
    ['editormask'] = true,
    ['editor-mask'] = true,
    ['editor-name-separator'] = true,
    ['editors'] = true,
    ['editor-separator'] = true,
    ['EditorSurname'] = true,
    ['embargo'] = true,
    ['Embargo'] = true,
    ['encyclopaedia'] = true,
    ['encyclopedia'] = true,
    ['entry'] = true,
    ['episodelink'] = true,
    ['first'] = true,
    ['format'] = true,
    ['given'] = true,
    ['id'] = true,
    ['ID'] = true,
    ['ignoreisbnerror'] = true,
    ['ignore-isbn-error'] = true,
    ['in'] = true,
    ['inset'] = true,
    ['institution'] = true,
    ['isbn'] = true,
    ['ISBN'] = true,
    ['isbn13'] = true,
    ['ISBN13'] = true,
    ['issn'] = true,
    ['ISSN'] = true,
    ['issue'] = true,
    ['jfm'] = true,
    ['JFM'] = true,
    ['journal'] = true,
    ['jstor'] = true,
    ['JSTOR'] = true,
    ['language'] = true,
    ['last'] = true,
    ['lastauthoramp'] = true,
    ['laydate'] = true,
    ['laysource'] = true,
    ['laysummary'] = true,
    ['layurl'] = true,
    ['lccn'] = true,
    ['LCCN'] = true,
    ['location'] = true,
    ['magazine'] = true,
    ['medium'] = true,
    ['minutes'] = true,
    ['month'] = true,
    ['mr'] = true,
    ['MR'] = true,
    ['name-separator'] = true,
    ['network'] = true,
    ['newspaper'] = true,
    ['nocat'] = true,
    ['nopp'] = true,
    ['notracking'] = true,
    ['no-tracking'] = true,
    ['number'] = true,
    ['oclc'] = true,
    ['OCLC'] = true,
    ['ol'] = true,
    ['OL'] = true,
    ['origyear'] = true,
    ['osti'] = true,
    ['OSTI'] = true,
    ['others'] = true,
    ['p'] = true,
    ['page'] = true,
    ['pages'] = true,
    ['people'] = true,
    ['periodical'] = true,
    ['place'] = true,
    ['pmc'] = true,
    ['PMC'] = true,
    ['pmid'] = true,
    ['PMID'] = true,
    ['postscript'] = true,
    ['pp'] = true,
    ['PPPrefix'] = true,
    ['PPrefix'] = true,
    ['publicationdate'] = true,
    ['publication-date'] = true,
    ['publicationplace'] = true,
    ['publication-place'] = true,
    ['publisher'] = true,
    ['quotation'] = true,
    ['quote'] = true,
    ['ref'] = true,
    ['Ref'] = true,
    ['registration'] = true,
    ['rfc'] = true,
    ['RFC'] = true,
    ['scale'] = true,
    ['season'] = true,
    ['section'] = true,
    ['sectionurl'] = true,
    ['separator'] = true,
    ['series'] = true,
    ['serieslink'] = true,
    ['seriesno'] = true,
    ['seriesnumber'] = true,
    ['series-separator'] = true,
    ['ssrn'] = true,
    ['SSRN'] = true,
    ['station'] = true,
    ['subscription'] = true,
    ['surname'] = true,
    ['template doc demo'] = true,
    ['time'] = true,
    ['timecaption'] = true,
    ['title'] = true,
    ['titlelink'] = true,
    ['trans_chapter'] = true,
    ['trans-chapter'] = true,
    ['transcript'] = true,
    ['transcripturl'] = true,
    ['transcript-url'] = true,
    ['trans_title'] = true,
    ['trans-title'] = true,
    ['type'] = true,
    ['url'] = true,
    ['URL'] = true,
    ['version'] = true,
    ['via'] = true,
    ['volume'] = true,
    ['website'] = true,
    ['work'] = true,
    ['year'] = true,
    ['zbl'] = true,
    ['ZBL'] = true,
},

numbered_arguments = {
    ['author#'] = true,
    ['Author#'] = true,
    ['author-first#'] = true,
    ['author#-first'] = true,
    ['author-last#'] = true,
    ['author#-last'] = true,
    ['author-link#'] = true,
    ['author#link'] = true,
    ['author#-link'] = true,
    ['authorlink#'] = true,
    ['author-mask#'] = true,
    ['author#mask'] = true,
    ['author#-mask'] = true,
    ['authormask#'] = true,
    ['authors#'] = true,
    ['editor#'] = true,
    ['Editor#'] = true,
    ['editor-first#'] = true,
    ['editor#-first'] = true,
    ['EditorGiven#'] = true,
    ['editor-last#'] = true,
    ['editor#-last'] = true,
    ['editor-link#'] = true,
    ['editor#link'] = true,
    ['editor#-link'] = true,
    ['editorlink#'] = true,
    ['editor-mask#'] = true,
    ['editor#mask'] = true,
    ['editor#-mask'] = true,
    ['editormask#'] = true,
    ['editors#'] = true,
    ['EditorSurname#'] = true,
    ['first#'] = true,
    ['given#'] = true,
    ['last#'] = true,
    ['surname#'] = true,
},
};

return whitelist;</text>
      <sha1>spacucvxak3az39timata1wx948qpj8</sha1>
    </revision>
    <revision>
      <id>4777</id>
      <parentid>4776</parentid>
      <timestamp>2013-12-14T18:30:34Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Sync from sandbox; streamlined deprecated parameter detection;</comment>
      <origin>4777</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="6507" sha1="9dlstwxoz20qyr3ai1wiq1ljw2hbeou" xml:space="preserve">--[[
Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items now can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
]]
whitelist = {

basic_arguments = {
    ['accessdate'] = true,
    ['agency'] = true,
    ['airdate'] = true,
    ['archivedate'] = true,
    ['archive-date'] = true,
    ['archiveurl'] = true,
    ['archive-url'] = true,
    ['article'] = true,
    ['arxiv'] = true,
    ['ARXIV'] = true,
    ['asin'] = true,
    ['ASIN'] = true,
    ['asin-tld'] = true,
    ['ASIN-TLD'] = true,
    ['at'] = true,
    ['author'] = true,
    ['Author'] = true,
    ['author-first'] = true,
    ['authorformat'] = true,
    ['author-format'] = true,
    ['author-last'] = true,
    ['authorlink'] = true,
    ['author-link'] = true,
    ['authormask'] = true,
    ['author-mask'] = true,
    ['author-name-separator'] = true,
    ['authors'] = true,
    ['author-separator'] = true,
    ['bibcode'] = true,
    ['BIBCODE'] = true,
    ['booktitle'] = true,
    ['cartography'] = true,
    ['chapter'] = true,
    ['chapterlink'] = true,
    ['chapterurl'] = true,
    ['chapter-url'] = true,
    ['coauthor'] = false,
    ['coauthors'] = false,
    ['conference'] = true,
    ['conferenceurl'] = true,
    ['conference-url'] = true,
    ['contribution'] = true,
    ['contributionurl'] = true,
    ['contribution-url'] = true,
    ['date'] = true,
    ['day'] = false,
    ['deadurl'] = true,
    ['degree'] = true,
    ['department'] = true,
    ['dictionary'] = true,
    ['displayauthors'] = true,
    ['display-authors'] = true,
    ['displayeditors'] = true,
    ['display-editors'] = true,
    ['docket'] = true,
    ['doi'] = true,
    ['DOI'] = true,
    ['DoiBroken'] = true,
    ['doi_brokendate'] = true,
    ['doi_inactivedate'] = true,
    ['edition'] = true,
    ['editor'] = true,
    ['Editor'] = true,
    ['editor-first'] = true,
    ['editorformat'] = true,
    ['editor-format'] = true,
    ['EditorGiven'] = true,
    ['editor-last'] = true,
    ['editorlink'] = true,
    ['editor-link'] = true,
    ['editormask'] = true,
    ['editor-mask'] = true,
    ['editor-name-separator'] = true,
    ['editors'] = true,
    ['editor-separator'] = true,
    ['EditorSurname'] = true,
    ['embargo'] = true,
    ['Embargo'] = true,
    ['encyclopaedia'] = true,
    ['encyclopedia'] = true,
    ['entry'] = true,
    ['episodelink'] = true,
    ['first'] = true,
    ['format'] = true,
    ['given'] = true,
    ['id'] = true,
    ['ID'] = true,
    ['ignoreisbnerror'] = true,
    ['ignore-isbn-error'] = true,
    ['in'] = true,
    ['inset'] = true,
    ['institution'] = true,
    ['isbn'] = true,
    ['ISBN'] = true,
    ['isbn13'] = true,
    ['ISBN13'] = true,
    ['issn'] = true,
    ['ISSN'] = true,
    ['issue'] = true,
    ['jfm'] = true,
    ['JFM'] = true,
    ['journal'] = true,
    ['jstor'] = true,
    ['JSTOR'] = true,
    ['language'] = true,
    ['last'] = true,
    ['lastauthoramp'] = true,
    ['laydate'] = true,
    ['laysource'] = true,
    ['laysummary'] = true,
    ['layurl'] = true,
    ['lccn'] = true,
    ['LCCN'] = true,
    ['location'] = true,
    ['magazine'] = true,
    ['medium'] = true,
    ['minutes'] = true,
    ['month'] = false,
    ['mr'] = true,
    ['MR'] = true,
    ['name-separator'] = true,
    ['network'] = true,
    ['newspaper'] = true,
    ['nocat'] = true,
    ['nopp'] = true,
    ['notracking'] = true,
    ['no-tracking'] = true,
    ['number'] = true,
    ['oclc'] = true,
    ['OCLC'] = true,
    ['ol'] = true,
    ['OL'] = true,
    ['origyear'] = true,
    ['osti'] = true,
    ['OSTI'] = true,
    ['others'] = true,
    ['p'] = true,
    ['page'] = true,
    ['pages'] = true,
    ['people'] = true,
    ['periodical'] = true,
    ['place'] = true,
    ['pmc'] = true,
    ['PMC'] = true,
    ['pmid'] = true,
    ['PMID'] = true,
    ['postscript'] = true,
    ['pp'] = true,
    ['PPPrefix'] = true,
    ['PPrefix'] = true,
    ['publicationdate'] = true,
    ['publication-date'] = true,
    ['publicationplace'] = true,
    ['publication-place'] = true,
    ['publisher'] = true,
    ['quotation'] = true,
    ['quote'] = true,
    ['ref'] = true,
    ['Ref'] = true,
    ['registration'] = true,
    ['rfc'] = true,
    ['RFC'] = true,
    ['scale'] = true,
    ['season'] = true,
    ['section'] = true,
    ['sectionurl'] = true,
    ['separator'] = true,
    ['series'] = true,
    ['serieslink'] = true,
    ['seriesno'] = true,
    ['seriesnumber'] = true,
    ['series-separator'] = true,
    ['ssrn'] = true,
    ['SSRN'] = true,
    ['station'] = true,
    ['subscription'] = true,
    ['surname'] = true,
    ['template doc demo'] = true,
    ['time'] = true,
    ['timecaption'] = true,
    ['title'] = true,
    ['titlelink'] = true,
    ['trans_chapter'] = true,
    ['trans-chapter'] = true,
    ['transcript'] = true,
    ['transcripturl'] = true,
    ['transcript-url'] = true,
    ['trans_title'] = true,
    ['trans-title'] = true,
    ['type'] = true,
    ['url'] = true,
    ['URL'] = true,
    ['version'] = true,
    ['via'] = true,
    ['volume'] = true,
    ['website'] = true,
    ['work'] = true,
    ['year'] = true,
    ['zbl'] = true,
    ['ZBL'] = true,
},

numbered_arguments = {
    ['author#'] = true,
    ['Author#'] = true,
    ['author-first#'] = true,
    ['author#-first'] = true,
    ['author-last#'] = true,
    ['author#-last'] = true,
    ['author-link#'] = true,
    ['author#link'] = true,
    ['author#-link'] = true,
    ['authorlink#'] = true,
    ['author-mask#'] = true,
    ['author#mask'] = true,
    ['author#-mask'] = true,
    ['authormask#'] = true,
    ['authors#'] = true,
    ['editor#'] = true,
    ['Editor#'] = true,
    ['editor-first#'] = true,
    ['editor#-first'] = true,
    ['EditorGiven#'] = true,
    ['editor-last#'] = true,
    ['editor#-last'] = true,
    ['editor-link#'] = true,
    ['editor#link'] = true,
    ['editor#-link'] = true,
    ['editorlink#'] = true,
    ['editor-mask#'] = true,
    ['editor#mask'] = true,
    ['editor#-mask'] = true,
    ['editormask#'] = true,
    ['editors#'] = true,
    ['EditorSurname#'] = true,
    ['first#'] = true,
    ['given#'] = true,
    ['last#'] = true,
    ['surname#'] = true,
},
};

return whitelist;</text>
      <sha1>9dlstwxoz20qyr3ai1wiq1ljw2hbeou</sha1>
    </revision>
    <revision>
      <id>4778</id>
      <parentid>4777</parentid>
      <timestamp>2014-02-15T11:07:59Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Sync from sandbox; adds support for cite speech and cite podcast;</comment>
      <origin>4778</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="6575" sha1="kspgrdkfj8mqac0zmbuhkmmc4n4c55j" xml:space="preserve">--[[
Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items now can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
]]
whitelist = {

basic_arguments = {
    ['accessdate'] = true,
    ['agency'] = true,
    ['airdate'] = true,
    ['archivedate'] = true,
    ['archive-date'] = true,
    ['archiveurl'] = true,
    ['archive-url'] = true,
    ['article'] = true,
    ['arxiv'] = true,
    ['ARXIV'] = true,
    ['asin'] = true,
    ['ASIN'] = true,
    ['asin-tld'] = true,
    ['ASIN-TLD'] = true,
    ['at'] = true,
    ['author'] = true,
    ['Author'] = true,
    ['author-first'] = true,
    ['authorformat'] = true,
    ['author-format'] = true,
    ['author-last'] = true,
    ['authorlink'] = true,
    ['author-link'] = true,
    ['authormask'] = true,
    ['author-mask'] = true,
    ['author-name-separator'] = true,
    ['authors'] = true,
    ['author-separator'] = true,
    ['bibcode'] = true,
    ['BIBCODE'] = true,
    ['booktitle'] = true,
    ['cartography'] = true,
    ['chapter'] = true,
    ['chapterlink'] = true,
    ['chapterurl'] = true,
    ['chapter-url'] = true,
    ['coauthor'] = false,
    ['coauthors'] = false,
    ['conference'] = true,
    ['conferenceurl'] = true,
    ['conference-url'] = true,
    ['contribution'] = true,
    ['contributionurl'] = true,
    ['contribution-url'] = true,
    ['date'] = true,
    ['day'] = false,
    ['deadurl'] = true,
    ['degree'] = true,
    ['department'] = true,
    ['dictionary'] = true,
    ['displayauthors'] = true,
    ['display-authors'] = true,
    ['displayeditors'] = true,
    ['display-editors'] = true,
    ['docket'] = true,
    ['doi'] = true,
    ['DOI'] = true,
    ['DoiBroken'] = true,
    ['doi_brokendate'] = true,
    ['doi_inactivedate'] = true,
    ['edition'] = true,
    ['editor'] = true,
    ['Editor'] = true,
    ['editor-first'] = true,
    ['editorformat'] = true,
    ['editor-format'] = true,
    ['EditorGiven'] = true,
    ['editor-last'] = true,
    ['editorlink'] = true,
    ['editor-link'] = true,
    ['editormask'] = true,
    ['editor-mask'] = true,
    ['editor-name-separator'] = true,
    ['editors'] = true,
    ['editor-separator'] = true,
    ['EditorSurname'] = true,
    ['embargo'] = true,
    ['Embargo'] = true,
    ['encyclopaedia'] = true,
    ['encyclopedia'] = true,
    ['entry'] = true,
    ['episodelink'] = true,
    ['event'] = true,
    ['eventurl'] = true,
    ['first'] = true,
    ['format'] = true,
    ['given'] = true,
    ['host'] = true,
    ['id'] = true,
    ['ID'] = true,
    ['ignoreisbnerror'] = true,
    ['ignore-isbn-error'] = true,
    ['in'] = true,
    ['inset'] = true,
    ['institution'] = true,
    ['isbn'] = true,
    ['ISBN'] = true,
    ['isbn13'] = true,
    ['ISBN13'] = true,
    ['issn'] = true,
    ['ISSN'] = true,
    ['issue'] = true,
    ['jfm'] = true,
    ['JFM'] = true,
    ['journal'] = true,
    ['jstor'] = true,
    ['JSTOR'] = true,
    ['language'] = true,
    ['last'] = true,
    ['lastauthoramp'] = true,
    ['laydate'] = true,
    ['laysource'] = true,
    ['laysummary'] = true,
    ['layurl'] = true,
    ['lccn'] = true,
    ['LCCN'] = true,
    ['location'] = true,
    ['magazine'] = true,
    ['medium'] = true,
    ['minutes'] = true,
    ['month'] = false,
    ['mr'] = true,
    ['MR'] = true,
    ['name-separator'] = true,
    ['network'] = true,
    ['newspaper'] = true,
    ['nocat'] = true,
    ['nopp'] = true,
    ['notracking'] = true,
    ['no-tracking'] = true,
    ['number'] = true,
    ['oclc'] = true,
    ['OCLC'] = true,
    ['ol'] = true,
    ['OL'] = true,
    ['origyear'] = true,
    ['osti'] = true,
    ['OSTI'] = true,
    ['others'] = true,
    ['p'] = true,
    ['page'] = true,
    ['pages'] = true,
    ['people'] = true,
    ['periodical'] = true,
    ['place'] = true,
    ['pmc'] = true,
    ['PMC'] = true,
    ['pmid'] = true,
    ['PMID'] = true,
    ['postscript'] = true,
    ['pp'] = true,
    ['PPPrefix'] = true,
    ['PPrefix'] = true,
    ['publicationdate'] = true,
    ['publication-date'] = true,
    ['publicationplace'] = true,
    ['publication-place'] = true,
    ['publisher'] = true,
    ['quotation'] = true,
    ['quote'] = true,
    ['ref'] = true,
    ['Ref'] = true,
    ['registration'] = true,
    ['rfc'] = true,
    ['RFC'] = true,
    ['scale'] = true,
    ['season'] = true,
    ['section'] = true,
    ['sectionurl'] = true,
    ['separator'] = true,
    ['series'] = true,
    ['serieslink'] = true,
    ['seriesno'] = true,
    ['seriesnumber'] = true,
    ['series-separator'] = true,
    ['ssrn'] = true,
    ['SSRN'] = true,
    ['station'] = true,
    ['subscription'] = true,
    ['surname'] = true,
    ['template doc demo'] = true,
    ['time'] = true,
    ['timecaption'] = true,
    ['title'] = true,
    ['titlelink'] = true,
    ['trans_chapter'] = true,
    ['trans-chapter'] = true,
    ['transcript'] = true,
    ['transcripturl'] = true,
    ['transcript-url'] = true,
    ['trans_title'] = true,
    ['trans-title'] = true,
    ['type'] = true,
    ['url'] = true,
    ['URL'] = true,
    ['version'] = true,
    ['via'] = true,
    ['volume'] = true,
    ['website'] = true,
    ['work'] = true,
    ['year'] = true,
    ['zbl'] = true,
    ['ZBL'] = true,
},

numbered_arguments = {
    ['author#'] = true,
    ['Author#'] = true,
    ['author-first#'] = true,
    ['author#-first'] = true,
    ['author-last#'] = true,
    ['author#-last'] = true,
    ['author-link#'] = true,
    ['author#link'] = true,
    ['author#-link'] = true,
    ['authorlink#'] = true,
    ['author-mask#'] = true,
    ['author#mask'] = true,
    ['author#-mask'] = true,
    ['authormask#'] = true,
    ['authors#'] = true,
    ['editor#'] = true,
    ['Editor#'] = true,
    ['editor-first#'] = true,
    ['editor#-first'] = true,
    ['EditorGiven#'] = true,
    ['editor-last#'] = true,
    ['editor#-last'] = true,
    ['editor-link#'] = true,
    ['editor#link'] = true,
    ['editor#-link'] = true,
    ['editorlink#'] = true,
    ['editor-mask#'] = true,
    ['editor#mask'] = true,
    ['editor#-mask'] = true,
    ['editormask#'] = true,
    ['editors#'] = true,
    ['EditorSurname#'] = true,
    ['first#'] = true,
    ['given#'] = true,
    ['last#'] = true,
    ['surname#'] = true,
},
};

return whitelist;</text>
      <sha1>kspgrdkfj8mqac0zmbuhkmmc4n4c55j</sha1>
    </revision>
    <revision>
      <id>4779</id>
      <parentid>4778</parentid>
      <timestamp>2014-03-30T12:23:27Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4779</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="7825" sha1="ldmr4vlsj7vuemb2tn270w979hxwp7o" xml:space="preserve">--[[
Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items now can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
]]
whitelist = {

basic_arguments = {
    ['accessdate'] = true,
    ['agency'] = true,
    ['airdate'] = true,
    ['albumlink'] = false,			-- deprecated; set to nil after 1 October 2014; a unique alias of titlelink used by old cite AV media notes
    ['albumtype'] = nil,			-- controled inappropriate functionality in the old cite AV media notes
    ['archivedate'] = true,
    ['archive-date'] = true,
    ['archiveurl'] = true,
    ['archive-url'] = true,
    ['article'] = true,
    ['artist'] = false,				-- deprecated; set to nil after 1 October 2014; a unique alias of others used by old cite AV media notes
    ['arxiv'] = true,
    ['ARXIV'] = true,
    ['asin'] = true,
    ['ASIN'] = true,
    ['asin-tld'] = true,
    ['ASIN-TLD'] = true,
    ['at'] = true,
    ['author'] = true,
    ['Author'] = true,
    ['author-first'] = true,
    ['authorformat'] = true,
    ['author-format'] = true,
    ['author-last'] = true,
    ['authorlink'] = true,
    ['author-link'] = true,
    ['authormask'] = true,
    ['author-mask'] = true,
    ['author-name-separator'] = true,
    ['authors'] = true,
    ['author-separator'] = true,
    ['bibcode'] = true,
    ['BIBCODE'] = true,
    ['booktitle'] = true,
	['callsign']=true,					-- cite interview
    ['cartography'] = true,
    ['chapter'] = true,
    ['chapterlink'] = true,
    ['chapterurl'] = true,
    ['chapter-url'] = true,
	['city']=true,						-- cite interview
    ['coauthor'] = false,
    ['coauthors'] = false,
    ['cointerviewers'] = false,			-- cite interview
    ['conference'] = true,
    ['conferenceurl'] = true,
    ['conference-url'] = true,
    ['contribution'] = true,
    ['contributionurl'] = true,
    ['contribution-url'] = true,
    ['date'] = true,
    ['day'] = false,
    ['deadurl'] = true,
    ['degree'] = true,
    ['department'] = true,
    ['dictionary'] = true,
    ['director'] = false,				-- deprecated; set to nil after 1 October 2014; a unique alias of author used by old cite DVD-notes
    ['displayauthors'] = true,
    ['display-authors'] = true,
    ['displayeditors'] = true,
    ['display-editors'] = true,
    ['docket'] = true,
    ['doi'] = true,
    ['DOI'] = true,
    ['DoiBroken'] = true,
    ['doi_brokendate'] = true,
    ['doi_inactivedate'] = true,
    ['edition'] = true,
    ['editor'] = true,
    ['Editor'] = true,
    ['editor-first'] = true,
    ['editorformat'] = true,
    ['editor-format'] = true,
    ['EditorGiven'] = true,
    ['editor-last'] = true,
    ['editorlink'] = true,
    ['editor-link'] = true,
    ['editormask'] = true,
    ['editor-mask'] = true,
    ['editor-name-separator'] = true,
    ['editors'] = true,
    ['editor-separator'] = true,
    ['EditorSurname'] = true,
    ['embargo'] = true,
    ['Embargo'] = true,
    ['encyclopaedia'] = true,
    ['encyclopedia'] = true,
    ['entry'] = true,
    ['episodelink'] = true,
    ['event'] = true,
    ['eventurl'] = true,
    ['first'] = true,
    ['format'] = true,
    ['given'] = true,
    ['host'] = true,
    ['id'] = true,
    ['ID'] = true,
    ['ignoreisbnerror'] = true,
    ['ignore-isbn-error'] = true,
    ['in'] = true,
    ['inset'] = true,
    ['institution'] = true,
	['interviewer'] = true,					--cite interview
    ['isbn'] = true,
    ['ISBN'] = true,
    ['isbn13'] = true,
    ['ISBN13'] = true,
    ['issn'] = true,
    ['ISSN'] = true,
    ['issue'] = true,
    ['jfm'] = true,
    ['JFM'] = true,
    ['journal'] = true,
    ['jstor'] = true,
    ['JSTOR'] = true,
    ['language'] = true,
    ['last'] = true,
    ['lastauthoramp'] = true,
    ['laydate'] = true,
    ['laysource'] = true,
    ['laysummary'] = true,
    ['layurl'] = true,
    ['lccn'] = true,
    ['LCCN'] = true,
    ['location'] = true,
    ['magazine'] = true,
    ['medium'] = true,
    ['minutes'] = true,
    ['month'] = false,
    ['mr'] = true,
    ['MR'] = true,
    ['name-separator'] = true,
    ['network'] = true,
    ['newspaper'] = true,
    ['nocat'] = true,
    ['nopp'] = true,
    ['notestitle'] = false,					-- deprecated; set to nil after 1 October 2014; a unique alias of chapter used by old cite AV media notes
    ['notracking'] = true,
    ['no-tracking'] = true,
    ['number'] = true,
    ['oclc'] = true,
    ['OCLC'] = true,
    ['ol'] = true,
    ['OL'] = true,
    ['origyear'] = true,
    ['osti'] = true,
    ['OSTI'] = true,
    ['others'] = true,
    ['p'] = true,
    ['page'] = true,
    ['pages'] = true,
    ['people'] = true,
    ['periodical'] = true,
    ['place'] = true,
    ['pmc'] = true,
    ['PMC'] = true,
    ['pmid'] = true,
    ['PMID'] = true,
    ['postscript'] = true,
    ['pp'] = true,
    ['PPPrefix'] = true,
    ['PPrefix'] = true,
	['program']=true,				-- cite interview
    ['publicationdate'] = true,
    ['publication-date'] = true,
    ['publicationplace'] = true,
    ['publication-place'] = true,
    ['publisher'] = true,
    ['publisherid'] = false,			-- deprecated; set to nil after 1 October 2014; a unique alias of others used by old cite AV media notes and old cite DVD-notes
    ['quotation'] = true,
    ['quote'] = true,
    ['ref'] = true,
    ['Ref'] = true,
    ['registration'] = true,
    ['rfc'] = true,
    ['RFC'] = true,
    ['scale'] = true,
    ['season'] = true,
    ['section'] = true,
    ['sectionurl'] = true,
    ['separator'] = true,
    ['series'] = true,
    ['serieslink'] = true,
    ['seriesno'] = true,
    ['seriesnumber'] = true,
    ['series-separator'] = true,
    ['ssrn'] = true,
    ['SSRN'] = true,
    ['station'] = true,
    ['subject'] = true,
    ['subjectlink'] = true,
    ['subscription'] = true,
    ['surname'] = true,
    ['template doc demo'] = true,
    ['time'] = true,
    ['timecaption'] = true,
    ['title'] = true,
    ['titlelink'] = true,
    ['titleyear'] = false,			-- deprecated; set to nil after 1 October 2014; a unique alias of origyear used by old cite DVD-notes
    ['trans_chapter'] = true,
    ['trans-chapter'] = true,
    ['transcript'] = true,
    ['transcripturl'] = true,
    ['transcript-url'] = true,
    ['trans_title'] = true,
    ['trans-title'] = true,
    ['type'] = true,
    ['url'] = true,
    ['URL'] = true,
    ['version'] = true,
    ['via'] = true,
    ['volume'] = true,
    ['website'] = true,
    ['work'] = true,
    ['year'] = true,
    ['zbl'] = true,
    ['ZBL'] = true,
},

numbered_arguments = {
    ['author#'] = true,
    ['Author#'] = true,
    ['author-first#'] = true,
    ['author#-first'] = true,
    ['author-last#'] = true,
    ['author#-last'] = true,
    ['author-link#'] = true,
    ['author#link'] = true,
    ['author#-link'] = true,
    ['authorlink#'] = true,
    ['author-mask#'] = true,
    ['author#mask'] = true,
    ['author#-mask'] = true,
    ['authormask#'] = true,
    ['authors#'] = true,
    ['editor#'] = true,
    ['Editor#'] = true,
    ['editor-first#'] = true,
    ['editor#-first'] = true,
    ['EditorGiven#'] = true,
    ['editor-last#'] = true,
    ['editor#-last'] = true,
    ['editor-link#'] = true,
    ['editor#link'] = true,
    ['editor#-link'] = true,
    ['editorlink#'] = true,
    ['editor-mask#'] = true,
    ['editor#mask'] = true,
    ['editor#-mask'] = true,
    ['editormask#'] = true,
    ['editors#'] = true,
    ['EditorSurname#'] = true,
    ['first#'] = true,
    ['given#'] = true,
    ['last#'] = true,
    ['subject#'] = true,
    ['subjectlink#'] = true,
    ['surname#'] = true,
},
};

return whitelist;</text>
      <sha1>ldmr4vlsj7vuemb2tn270w979hxwp7o</sha1>
    </revision>
    <revision>
      <id>4780</id>
      <parentid>4779</parentid>
      <timestamp>2014-08-24T10:58:52Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4780</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="8061" sha1="fwukir9kiszdkcd1xiqvcsnheiskk0b" xml:space="preserve">--[[
Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items now can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
]]
whitelist = {

basic_arguments = {
	['accessdate'] = true,
	['access-date'] = true,
	['agency'] = true,
	['airdate'] = true,
	['air-date'] = true,
	['albumlink'] = false,			-- deprecated; set to nil after 1 October 2014; a unique alias of titlelink used by old cite AV media notes
	['albumtype'] = nil,			-- controled inappropriate functionality in the old cite AV media notes
	['archivedate'] = true,
	['archive-date'] = true,
	['archiveurl'] = true,
	['archive-url'] = true,
	['article'] = true,
	['artist'] = false,				-- deprecated; set to nil after 1 October 2014; a unique alias of others used by old cite AV media notes
	['arxiv'] = true,
	['ARXIV'] = true,
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['ASIN-TLD'] = true,
	['at'] = true,
	['author'] = true,
	['Author'] = true,
	['author-first'] = true,
	['authorformat'] = true,
	['author-format'] = true,
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['author-name-separator'] = true,
	['authors'] = true,
	['author-separator'] = true,
	['bibcode'] = true,
	['BIBCODE'] = true,
	['booktitle'] = true,
	['book-title'] = true,
	['callsign']=true,				-- cite interview
	['call-sign']=true,				-- cite interview
	['cartography'] = true,
	['chapter'] = true,
	['chapterlink'] = true,
	['chapter-link'] = true,
	['chapterurl'] = true,
	['chapter-url'] = true,
	['city']=true,					-- cite interview
	['coauthor'] = false,
	['coauthors'] = false,
	['cointerviewers'] = false,		-- cite interview
	['conference'] = true,
	['conferenceurl'] = true,
	['conference-url'] = true,
	['contribution'] = true,
	['contributionurl'] = true,
	['contribution-url'] = true,
	['date'] = true,
	['day'] = false,
	['deadurl'] = true,
	['dead-url'] = true,
	['degree'] = true,
	['department'] = true,
	['dictionary'] = true,
	['director'] = false,			-- deprecated; set to nil after 1 October 2014; a unique alias of author used by old cite DVD-notes
	['displayauthors'] = true,
	['display-authors'] = true,
	['displayeditors'] = true,
	['display-editors'] = true,
	['docket'] = true,
	['doi'] = true,
	['DOI'] = true,
	['DoiBroken'] = true,
	['doi-broken'] = true,
	['doi_brokendate'] = true,
	['doi-broken-date'] = true,
	['doi_inactivedate'] = true,
	['doi-inactive-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['Editor'] = true,
	['editor-first'] = true,
	['editorformat'] = true,
	['editor-format'] = true,
	['EditorGiven'] = true,
	['editor-given'] = true,
	['editor-last'] = true,
	['editorlink'] = true,
	['editor-link'] = true,
	['editormask'] = true,
	['editor-mask'] = true,
	['editor-name-separator'] = true,
	['editors'] = true,
	['editor-separator'] = true,
	['EditorSurname'] = true,
	['editor-surname'] = true,
	['embargo'] = true,
	['Embargo'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['entry'] = true,
	['episodelink'] = true,
	['episode-link'] = true,
	['event'] = true,
	['eventurl'] = true,
	['event-url'] = true,
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['host'] = true,
	['id'] = true,
	['ID'] = true,
	['ignoreisbnerror'] = true,
	['ignore-isbn-error'] = true,
	['in'] = true,
	['inset'] = true,
	['institution'] = true,
	['interviewer'] = true,			--cite interview
	['isbn'] = true,
	['ISBN'] = true,
	['isbn13'] = true,
	['ISBN13'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['laydate'] = true,
	['lay-date'] = true,
	['laysource'] = true,
	['lay-source'] = true,
	['laysummary'] = true,
	['lay-summary'] = true,
	['layurl'] = true,
	['lay-url'] = true,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['magazine'] = true,
	['medium'] = true,
	['minutes'] = true,
	['month'] = false,
	['mr'] = true,
	['MR'] = true,
	['name-separator'] = true,
	['network'] = true,
	['newsgroup'] = true,
	['newspaper'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['nopp'] = true,
	['no-pp'] = true,
	['notestitle'] = false,			-- deprecated; set to nil after 1 October 2014; a unique alias of chapter used by old cite AV media notes
	['notracking'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['people'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['PPPrefix'] = true,
	['pp-prefix'] = true,
	['PPrefix'] = true,
	['p-prefix'] = true,
	['program']=true,				-- cite interview
	['publicationdate'] = true,
	['publication-date'] = true,
	['publicationplace'] = true,
	['publication-place'] = true,
	['publisher'] = true,
	['publisherid'] = false,		-- deprecated; set to nil after 1 October 2014; a unique alias of others used by old cite AV media notes and old cite DVD-notes
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['Ref'] = true,
	['registration'] = true,
	['rfc'] = true,
	['RFC'] = true,
	['scale'] = true,
	['season'] = true,
	['section'] = true,
	['sectionurl'] = true,
	['section-url'] = true,
	['separator'] = true,
	['series'] = true,
	['serieslink'] = true,
	['series-link'] = true,
	['seriesno'] = true,
	['series-no'] = true,
	['seriesnumber'] = true,
	['series-number'] = true,
	['series-separator'] = true,
	['ssrn'] = true,
	['SSRN'] = true,
	['station'] = true,
	['subject'] = true,
	['subjectlink'] = true,
	['subject-link'] = true,
	['subscription'] = true,
	['surname'] = true,
	['template doc demo'] = true,
	['template-doc-demo'] = true,
	['time'] = true,
	['timecaption'] = true,
	['time-caption'] = true,
	['title'] = true,
	['titlelink'] = true,
	['title-link'] = true,
	['titleyear'] = false,			-- deprecated; set to nil after 1 October 2014; a unique alias of origyear used by old cite DVD-notes
	['trans_chapter'] = true,
	['trans-chapter'] = true,
	['transcript'] = true,
	['transcripturl'] = true,
	['transcript-url'] = true,
	['trans_title'] = true,
	['trans-title'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
},

numbered_arguments = {
	['author#'] = true,
	['Author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['authors#'] = true,
	['editor#'] = true,
	['Editor#'] = true,
	['editor-first#'] = true,
	['editor#-first'] = true,
	['EditorGiven#'] = true,
	['editor#-given'] = true,
	['editor-given#'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-link#'] = true,
	['editor#link'] = true,
	['editor#-link'] = true,
	['editorlink#'] = true,
	['editor-mask#'] = true,
	['editor#mask'] = true,
	['editor#-mask'] = true,
	['editormask#'] = true,
	['editors#'] = true,
	['EditorSurname#'] = true,
	['editor#-surname'] = true,
	['editor-surname#'] = true,
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-link#'] = true,
	['subject#link'] = true,
	['subject#-link'] = true,
	['subjectlink#'] = true,
	['surname#'] = true,
},
};

return whitelist;</text>
      <sha1>fwukir9kiszdkcd1xiqvcsnheiskk0b</sha1>
    </revision>
    <revision>
      <id>4781</id>
      <parentid>4780</parentid>
      <timestamp>2014-10-11T12:15:10Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4781</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="8087" sha1="ppx0bckuablixl7ak1xbe2lhm8h49yw" xml:space="preserve">--[[
Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items now can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
]]
whitelist = {

basic_arguments = {
	['accessdate'] = true,
	['access-date'] = true,
	['agency'] = true,
	['airdate'] = true,
	['air-date'] = true,
	['albumlink'] = false,			-- deprecated; set to nil after 1 October 2014; a unique alias of titlelink used by old cite AV media notes
	['albumtype'] = nil,			-- controled inappropriate functionality in the old cite AV media notes
	['archivedate'] = true,
	['archive-date'] = true,
	['archiveurl'] = true,
	['archive-url'] = true,
	['article'] = true,
	['artist'] = false,				-- deprecated; set to nil after 1 October 2014; a unique alias of others used by old cite AV media notes
	['arxiv'] = true,
	['ARXIV'] = true,
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['ASIN-TLD'] = true,
	['at'] = true,
	['author'] = true,
	['Author'] = true,
	['author-first'] = true,
	['authorformat'] = true,
	['author-format'] = true,
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['author-name-separator'] = true,
	['authors'] = true,
	['author-separator'] = true,
	['bibcode'] = true,
	['BIBCODE'] = true,
	['booktitle'] = true,
	['book-title'] = true,
	['callsign']=true,				-- cite interview
	['call-sign']=true,				-- cite interview
	['cartography'] = true,
	['chapter'] = true,
	['chapterlink'] = true,
	['chapter-link'] = true,
	['chapterurl'] = true,
	['chapter-url'] = true,
	['city']=true,					-- cite interview
	['coauthor'] = false,
	['coauthors'] = false,
	['cointerviewers'] = false,		-- cite interview
	['conference'] = true,
	['conferenceurl'] = true,
	['conference-url'] = true,
	['contribution'] = true,
	['contributionurl'] = true,
	['contribution-url'] = true,
	['date'] = true,
	['day'] = false,
	['deadurl'] = true,
	['dead-url'] = true,
	['degree'] = true,
	['department'] = true,
	['dictionary'] = true,
	['director'] = false,			-- deprecated; set to nil after 1 October 2014; a unique alias of author used by old cite DVD-notes
	['displayauthors'] = true,
	['display-authors'] = true,
	['displayeditors'] = true,
	['display-editors'] = true,
	['docket'] = true,
	['doi'] = true,
	['DOI'] = true,
	['DoiBroken'] = true,
	['doi-broken'] = true,
	['doi_brokendate'] = true,
	['doi-broken-date'] = true,
	['doi_inactivedate'] = true,
	['doi-inactive-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['Editor'] = true,
	['editor-first'] = true,
	['editorformat'] = true,
	['editor-format'] = true,
	['EditorGiven'] = true,
	['editor-given'] = true,
	['editor-last'] = true,
	['editorlink'] = true,
	['editor-link'] = true,
	['editormask'] = true,
	['editor-mask'] = true,
	['editor-name-separator'] = true,
	['editors'] = true,
	['editor-separator'] = true,
	['EditorSurname'] = true,
	['editor-surname'] = true,
	['embargo'] = true,
	['Embargo'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['entry'] = true,
	['episodelink'] = true,
	['episode-link'] = true,
	['event'] = true,
	['eventurl'] = true,
	['event-url'] = true,
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['host'] = true,
	['id'] = true,
	['ID'] = true,
	['ignoreisbnerror'] = true,
	['ignore-isbn-error'] = true,
	['in'] = true,
	['inset'] = true,
	['institution'] = true,
	['interviewer'] = true,			--cite interview
	['isbn'] = true,
	['ISBN'] = true,
	['isbn13'] = true,
	['ISBN13'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['laydate'] = true,
	['lay-date'] = true,
	['laysource'] = true,
	['lay-source'] = true,
	['laysummary'] = true,
	['lay-summary'] = true,
	['layurl'] = true,
	['lay-url'] = true,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['script-title'] = true,
	['magazine'] = true,
	['medium'] = true,
	['minutes'] = true,
	['month'] = false,
	['mr'] = true,
	['MR'] = true,
	['name-separator'] = true,
	['network'] = true,
	['newsgroup'] = true,
	['newspaper'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['nopp'] = true,
	['no-pp'] = true,
	['notestitle'] = false,			-- deprecated; set to nil after 1 October 2014; a unique alias of chapter used by old cite AV media notes
	['notracking'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['people'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['PPPrefix'] = true,
	['pp-prefix'] = true,
	['PPrefix'] = true,
	['p-prefix'] = true,
	['program']=true,				-- cite interview
	['publicationdate'] = true,
	['publication-date'] = true,
	['publicationplace'] = true,
	['publication-place'] = true,
	['publisher'] = true,
	['publisherid'] = false,		-- deprecated; set to nil after 1 October 2014; a unique alias of others used by old cite AV media notes and old cite DVD-notes
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['Ref'] = true,
	['registration'] = true,
	['rfc'] = true,
	['RFC'] = true,
	['scale'] = true,
	['season'] = true,
	['section'] = true,
	['sectionurl'] = true,
	['section-url'] = true,
	['separator'] = true,
	['series'] = true,
	['serieslink'] = true,
	['series-link'] = true,
	['seriesno'] = true,
	['series-no'] = true,
	['seriesnumber'] = true,
	['series-number'] = true,
	['series-separator'] = true,
	['ssrn'] = true,
	['SSRN'] = true,
	['station'] = true,
	['subject'] = true,
	['subjectlink'] = true,
	['subject-link'] = true,
	['subscription'] = true,
	['surname'] = true,
	['template doc demo'] = true,
	['template-doc-demo'] = true,
	['time'] = true,
	['timecaption'] = true,
	['time-caption'] = true,
	['title'] = true,
	['titlelink'] = true,
	['title-link'] = true,
	['titleyear'] = false,			-- deprecated; set to nil after 1 October 2014; a unique alias of origyear used by old cite DVD-notes
	['trans_chapter'] = true,
	['trans-chapter'] = true,
	['transcript'] = true,
	['transcripturl'] = true,
	['transcript-url'] = true,
	['trans_title'] = true,
	['trans-title'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
},

numbered_arguments = {
	['author#'] = true,
	['Author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['authors#'] = true,
	['editor#'] = true,
	['Editor#'] = true,
	['editor-first#'] = true,
	['editor#-first'] = true,
	['EditorGiven#'] = true,
	['editor#-given'] = true,
	['editor-given#'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-link#'] = true,
	['editor#link'] = true,
	['editor#-link'] = true,
	['editorlink#'] = true,
	['editor-mask#'] = true,
	['editor#mask'] = true,
	['editor#-mask'] = true,
	['editormask#'] = true,
	['editors#'] = true,
	['EditorSurname#'] = true,
	['editor#-surname'] = true,
	['editor-surname#'] = true,
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-link#'] = true,
	['subject#link'] = true,
	['subject#-link'] = true,
	['subjectlink#'] = true,
	['surname#'] = true,
},
};

return whitelist;</text>
      <sha1>ppx0bckuablixl7ak1xbe2lhm8h49yw</sha1>
    </revision>
    <revision>
      <id>4782</id>
      <parentid>4781</parentid>
      <timestamp>2014-11-29T11:56:57Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4782</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="8435" sha1="gbrusdxcuctkssvmyhrxybpya9h48to" xml:space="preserve">
--[[--------------------------&lt; P A R A M E T E R S   N O T   S U P P O R T E D &gt;------------------------------

This is a list of parameters that once were but now are no longer supported:

	['albumlink'] = nil,			-- unique alias of titlelink used by old cite AV media notes
	['albumtype'] = nil,			-- controled inappropriate functionality in the old cite AV media notes
	['artist'] = nil,				-- unique alias of others used by old cite AV media notes
	['cointerviewers'] = nil,		-- unique alias of others used by old cite interview
	['day'] = nil,					-- deprecated in {{citation/core}} and somehow undeprecated in Module:Citation/CS1 and now finally removed
	['director'] = nil,				-- unique alias of author used by old cite DVD-notes
	['notestitle'] = nil,			-- unique alias of chapter used by old cite AV media notes
	['publisherid'] = nil,			-- unique alias of id used by old cite AV media notes and old cite DVD-notes
	['titleyear'] = nil,			-- unique alias of origyear used by old cite DVD-notes

]]

--[[--------------------------&lt; S U P P O R T E D   P A R A M E T E R S &gt;--------------------------------------

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

whitelist = {
basic_arguments = {
	['accessdate'] = true,
	['access-date'] = true,
	['agency'] = true,
	['airdate'] = true,
	['air-date'] = true,
	['archivedate'] = true,
	['archive-date'] = true,
	['archiveurl'] = true,
	['archive-url'] = true,
	['article'] = true,
	['arxiv'] = true,
	['ARXIV'] = true,
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['ASIN-TLD'] = true,
	['at'] = true,
	['author'] = true,
	['Author'] = true,
	['author-first'] = true,
	['authorformat'] = true,
	['author-format'] = true,
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['author-name-separator'] = true,
	['authors'] = true,
	['author-separator'] = true,
	['bibcode'] = true,
	['BIBCODE'] = true,
	['booktitle'] = true,
	['book-title'] = true,
	['callsign']=true,				-- cite interview
	['call-sign']=true,				-- cite interview
	['cartography'] = true,
	['chapter'] = true,
	['chapter-format'] = true,
	['chapterlink'] = false,		-- deprecated
	['chapter-link'] = false,		-- deprecated
	['chapterurl'] = true,
	['chapter-url'] = true,
	['city']=true,					-- cite interview
	['coauthor'] = false,			-- deprecated
	['coauthors'] = false,			-- deprecated
	['conference'] = true,
	['conferenceurl'] = true,
	['conference-url'] = true,
	['contribution'] = true,
	['contributionurl'] = true,
	['contribution-url'] = true,
	['date'] = true,
	['deadurl'] = true,
	['dead-url'] = true,
	['degree'] = true,
	['department'] = true,
	['dictionary'] = true,
	['displayauthors'] = true,
	['display-authors'] = true,
	['displayeditors'] = true,
	['display-editors'] = true,
	['docket'] = true,
	['doi'] = true,
	['DOI'] = true,
	['DoiBroken'] = true,
	['doi-broken'] = true,
	['doi_brokendate'] = true,
	['doi-broken-date'] = true,
	['doi_inactivedate'] = true,
	['doi-inactive-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['Editor'] = true,
	['editor-first'] = true,
	['editorformat'] = true,
	['editor-format'] = true,
	['EditorGiven'] = true,
	['editor-given'] = true,
	['editor-last'] = true,
	['editorlink'] = true,
	['editor-link'] = true,
	['editormask'] = true,
	['editor-mask'] = true,
	['editor-name-separator'] = true,
	['editors'] = true,
	['editor-separator'] = true,
	['EditorSurname'] = true,
	['editor-surname'] = true,
	['embargo'] = true,
	['Embargo'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['entry'] = true,
	['episodelink'] = true,
	['episode-link'] = true,
	['event'] = true,
	['eventurl'] = true,
	['event-url'] = true,
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['host'] = true,
	['id'] = true,
	['ID'] = true,
	['ignoreisbnerror'] = true,
	['ignore-isbn-error'] = true,
	['in'] = true,
	['inset'] = true,
	['institution'] = true,
	['interviewer'] = true,				--cite interview
	['interviewers'] = true,			--cite interview
	['isbn'] = true,
	['ISBN'] = true,
	['isbn13'] = true,
	['ISBN13'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['laydate'] = true,
	['lay-date'] = true,
	['laysource'] = true,
	['lay-source'] = true,
	['laysummary'] = true,
	['lay-summary'] = true,
	['layurl'] = true,
	['lay-url'] = true,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['script-title'] = true,
	['magazine'] = true,
	['medium'] = true,
	['message-id'] = true,			-- cite newsgroup
	['minutes'] = true,
	['month'] = false,				-- deprecated
	['mr'] = true,
	['MR'] = true,
	['name-separator'] = true,
	['network'] = true,
	['newsgroup'] = true,
	['newspaper'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['nopp'] = true,
	['no-pp'] = true,
	['notracking'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['people'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['PPPrefix'] = true,
	['pp-prefix'] = true,
	['PPrefix'] = true,
	['p-prefix'] = true,
	['program']=true,				-- cite interview
	['publicationdate'] = true,
	['publication-date'] = true,
	['publicationplace'] = true,
	['publication-place'] = true,
	['publisher'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['Ref'] = true,
	['registration'] = true,
	['rfc'] = true,
	['RFC'] = true,
	['scale'] = true,
	['season'] = true,
	['section'] = true,
	['sectionurl'] = true,
	['section-url'] = true,
	['separator'] = true,
	['series'] = true,
	['serieslink'] = true,
	['series-link'] = true,
	['seriesno'] = true,
	['series-no'] = true,
	['seriesnumber'] = true,
	['series-number'] = true,
	['series-separator'] = true,
	['ssrn'] = true,
	['SSRN'] = true,
	['station'] = true,
	['subject'] = true,
	['subjectlink'] = true,
	['subject-link'] = true,
	['subscription'] = true,
	['surname'] = true,
	['template doc demo'] = true,
	['template-doc-demo'] = true,
	['time'] = true,
	['timecaption'] = true,
	['time-caption'] = true,
	['title'] = true,
	['titlelink'] = true,
	['title-link'] = true,
	['trans_chapter'] = true,
	['trans-chapter'] = true,
	['transcript'] = true,
	['transcripturl'] = true,
	['transcript-url'] = true,
	['trans_title'] = true,
	['trans-title'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
},

numbered_arguments = {
	['author#'] = true,
	['Author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['authors#'] = true,
	['editor#'] = true,
	['Editor#'] = true,
	['editor-first#'] = true,
	['editor#-first'] = true,
	['EditorGiven#'] = true,
	['editor#-given'] = true,
	['editor-given#'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-link#'] = true,
	['editor#link'] = true,
	['editor#-link'] = true,
	['editorlink#'] = true,
	['editor-mask#'] = true,
	['editor#mask'] = true,
	['editor#-mask'] = true,
	['editormask#'] = true,
	['editors#'] = true,
	['EditorSurname#'] = true,
	['editor#-surname'] = true,
	['editor-surname#'] = true,
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-link#'] = true,
	['subject#link'] = true,
	['subject#-link'] = true,
	['subjectlink#'] = true,
	['surname#'] = true,
},
};

return whitelist;</text>
      <sha1>gbrusdxcuctkssvmyhrxybpya9h48to</sha1>
    </revision>
    <revision>
      <id>4783</id>
      <parentid>4782</parentid>
      <timestamp>2015-02-14T13:05:12Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4783</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="9643" sha1="2pyy94rqi7ib26cr6kqh292w9pd4fbd" xml:space="preserve">
--[[--------------------------&lt; P A R A M E T E R S   N O T   S U P P O R T E D &gt;------------------------------

This is a list of parameters that once were but now are no longer supported:

	['albumlink'] = nil,			-- unique alias of titlelink used by old cite AV media notes
	['albumtype'] = nil,			-- controled inappropriate functionality in the old cite AV media notes
	['artist'] = nil,				-- unique alias of others used by old cite AV media notes
	['cointerviewers'] = nil,		-- unique alias of others used by old cite interview
	['day'] = nil,					-- deprecated in {{citation/core}} and somehow undeprecated in Module:Citation/CS1 and now finally removed
	['director'] = nil,				-- unique alias of author used by old cite DVD-notes
	['notestitle'] = nil,			-- unique alias of chapter used by old cite AV media notes
	['publisherid'] = nil,			-- unique alias of id used by old cite AV media notes and old cite DVD-notes
	['titleyear'] = nil,			-- unique alias of origyear used by old cite DVD-notes

]]

--[[--------------------------&lt; S U P P O R T E D   P A R A M E T E R S &gt;--------------------------------------

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

whitelist = {
basic_arguments = {
	['accessdate'] = true,
	['access-date'] = true,
	['agency'] = true,
	['airdate'] = true,
	['air-date'] = true,
	['archivedate'] = true,
	['archive-date'] = true,
	['archiveurl'] = true,
	['archive-url'] = true,
	['article'] = true,
	['arxiv'] = true,
	['ARXIV'] = true,
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['ASIN-TLD'] = true,
	['at'] = true,
	['author'] = true,
	['Author'] = true,
	['author-first'] = true,
	['authorformat'] = false,				-- deprecated; primarily used to support Vancouver format which functionality now part of name-list-format
	['author-format'] = false,				-- deprecated; primarily used to support Vancouver format which functionality now part of name-list-format
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['author-name-separator'] = false,		-- deprecated; primarily used to support Vancouver format which functionality now part of name-list-format
	['authors'] = true,
	['author-separator'] = false,			-- deprecated; primarily used to support Vancouver format which functionality now part of name-list-format
	['bibcode'] = true,
	['BIBCODE'] = true,
	['booktitle'] = true,
	['book-title'] = true,
	['callsign']=true,				-- cite interview
	['call-sign']=true,				-- cite interview
	['cartography'] = true,
	['chapter'] = true,
	['chapter-format'] = true,
	['chapterlink'] = false,		-- deprecated
	['chapter-link'] = false,		-- deprecated
	['chapterurl'] = true,
	['chapter-url'] = true,
	['city']=true,					-- cite interview
	['coauthor'] = false,			-- deprecated
	['coauthors'] = false,			-- deprecated
	['conference'] = true,
	['conferenceurl'] = true,
	['conference-url'] = true,
	['contribution'] = true,
	['contributionurl'] = true,
	['contribution-url'] = true,
	['date'] = true,
	['deadurl'] = true,
	['dead-url'] = true,
	['degree'] = true,
	['department'] = true,
	['dictionary'] = true,
	['displayauthors'] = true,
	['display-authors'] = true,
	['displayeditors'] = true,
	['display-editors'] = true,
	['docket'] = true,
	['doi'] = true,
	['DOI'] = true,
	['DoiBroken'] = true,
	['doi-broken'] = true,
	['doi_brokendate'] = true,
	['doi-broken-date'] = true,
	['doi_inactivedate'] = true,
	['doi-inactive-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['Editor'] = true,
	['editor-first'] = true,
	['editorformat'] = false,				-- deprecated; primarily used to support Vancouver format which functionality now part of name-list-format
	['editor-format'] = false,				-- deprecated; primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorGiven'] = true,
	['editor-given'] = true,
	['editor-last'] = true,
	['editorlink'] = true,
	['editor-link'] = true,
	['editormask'] = true,
	['editor-mask'] = true,
	['editor-name-separator'] = false,		-- deprecated; primarily used to support Vancouver format which functionality now part of name-list-format
	['editors'] = true,
	['editor-separator'] = false,			-- deprecated; primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorSurname'] = true,
	['editor-surname'] = true,
	['embargo'] = true,
	['Embargo'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['entry'] = true,
	['episodelink'] = true,
	['episode-link'] = true,
	['event'] = true,
	['eventurl'] = true,
	['event-url'] = true,
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['host'] = true,
	['id'] = true,
	['ID'] = true,
	['ignoreisbnerror'] = true,
	['ignore-isbn-error'] = true,
	['in'] = true,
	['inset'] = true,
	['institution'] = true,
	['interviewer'] = true,				--cite interview
	['interviewers'] = true,			--cite interview
	['isbn'] = true,
	['ISBN'] = true,
	['isbn13'] = true,
	['ISBN13'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['laydate'] = true,
	['lay-date'] = true,
	['laysource'] = true,
	['lay-source'] = true,
	['laysummary'] = true,
	['lay-summary'] = true,
	['layurl'] = true,
	['lay-url'] = true,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['magazine'] = true,
	['mailinglist'] = true,			-- cite mailing list only
	['mailing-list'] = true,			-- cite mailing list only
	['medium'] = true,
	['message-id'] = true,			-- cite newsgroup
	['minutes'] = true,
	['mode'] = true,
	['month'] = false,				-- deprecated
	['mr'] = true,
	['MR'] = true,
	['name-list-format'] = true,
	['name-separator'] = false,		-- deprecated;  primarily used to support Vancouver format which functionality now part of name-list-format
	['network'] = true,
	['newsgroup'] = true,
	['newspaper'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['nopp'] = true,
	['no-pp'] = true,
	['notracking'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['people'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['PPPrefix'] = true,
	['pp-prefix'] = true,
	['PPrefix'] = true,
	['p-prefix'] = true,
	['program']=true,				-- cite interview
	['publicationdate'] = true,
	['publication-date'] = true,
	['publicationplace'] = true,
	['publication-place'] = true,
	['publisher'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['Ref'] = true,
	['registration'] = true,
	['rfc'] = true,
	['RFC'] = true,
	['scale'] = true,
	['script-title'] = true,
	['season'] = true,
	['section'] = true,
	['sectionurl'] = true,
	['section-url'] = true,
	['separator'] = false,				-- deprecated; this functionality now provided by |mode=
	['series'] = true,
	['serieslink'] = true,
	['series-link'] = true,
	['seriesno'] = true,
	['series-no'] = true,
	['seriesnumber'] = true,
	['series-number'] = true,
	['series-separator'] = true,
	['ssrn'] = true,
	['SSRN'] = true,
	['station'] = true,
	['subject'] = true,
	['subjectlink'] = true,
	['subject-link'] = true,
	['subscription'] = true,
	['surname'] = true,
	['template doc demo'] = true,
	['template-doc-demo'] = true,
	['time'] = true,
	['timecaption'] = true,
	['time-caption'] = true,
	['title'] = true,
	['titlelink'] = true,
	['title-link'] = true,
	['trans_chapter'] = true,
	['trans-chapter'] = true,
	['transcript'] = true,
	['transcripturl'] = true,
	['transcript-url'] = true,
	['trans_title'] = true,
	['trans-title'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
},

numbered_arguments = {
	['author#'] = true,
	['Author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['authors#'] = true,
	['editor#'] = true,
	['Editor#'] = true,
	['editor-first#'] = true,
	['editor#-first'] = true,
	['EditorGiven#'] = true,
	['editor#-given'] = true,
	['editor-given#'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-link#'] = true,
	['editor#link'] = true,
	['editor#-link'] = true,
	['editorlink#'] = true,
	['editor-mask#'] = true,
	['editor#mask'] = true,
	['editor#-mask'] = true,
	['editormask#'] = true,
	['editors#'] = true,
	['EditorSurname#'] = true,
	['editor#-surname'] = true,
	['editor-surname#'] = true,
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-link#'] = true,
	['subject#link'] = true,
	['subject#-link'] = true,
	['subjectlink#'] = true,
	['surname#'] = true,
},
};

return whitelist;</text>
      <sha1>2pyy94rqi7ib26cr6kqh292w9pd4fbd</sha1>
    </revision>
    <revision>
      <id>4784</id>
      <parentid>4783</parentid>
      <timestamp>2015-03-21T12:13:33Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4784</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="9853" sha1="s65xdd4nsdowbwc3z816ie09mhdmvp4" xml:space="preserve">
--[[--------------------------&lt; P A R A M E T E R S   N O T   S U P P O R T E D &gt;------------------------------

This is a list of parameters that once were but now are no longer supported:

	['albumlink'] = nil,			-- unique alias of titlelink used by old cite AV media notes
	['albumtype'] = nil,			-- controled inappropriate functionality in the old cite AV media notes
	['artist'] = nil,				-- unique alias of others used by old cite AV media notes
	['cointerviewers'] = nil,		-- unique alias of others used by old cite interview
	['day'] = nil,					-- deprecated in {{citation/core}} and somehow undeprecated in Module:Citation/CS1 and now finally removed
	['director'] = nil,				-- unique alias of author used by old cite DVD-notes
	['notestitle'] = nil,			-- unique alias of chapter used by old cite AV media notes
	['publisherid'] = nil,			-- unique alias of id used by old cite AV media notes and old cite DVD-notes
	['titleyear'] = nil,			-- unique alias of origyear used by old cite DVD-notes

]]

--[[--------------------------&lt; S U P P O R T E D   P A R A M E T E R S &gt;--------------------------------------

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

whitelist = {
basic_arguments = {
	['accessdate'] = true,
	['access-date'] = true,
	['agency'] = true,
	['airdate'] = true,
	['air-date'] = true,
	['archivedate'] = true,
	['archive-date'] = true,
	['archiveurl'] = true,
	['archive-url'] = true,
	['article'] = true,
	['arxiv'] = true,
	['ARXIV'] = true,
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['ASIN-TLD'] = true,
	['at'] = true,
	['author'] = true,
	['Author'] = true,
	['author-first'] = true,
	['authorformat'] = false,				-- deprecated; primarily used to support Vancouver format which functionality now part of name-list-format
	['author-format'] = false,				-- deprecated; primarily used to support Vancouver format which functionality now part of name-list-format
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['author-name-separator'] = false,		-- deprecated; primarily used to support Vancouver format which functionality now part of name-list-format
	['authors'] = true,
	['author-separator'] = false,			-- deprecated; primarily used to support Vancouver format which functionality now part of name-list-format
	['bibcode'] = true,
	['BIBCODE'] = true,
	['booktitle'] = true,
	['book-title'] = true,
	['callsign']=true,				-- cite interview
	['call-sign']=true,				-- cite interview
	['cartography'] = true,
	['chapter'] = true,
	['chapter-format'] = true,
	['chapterlink'] = false,		-- deprecated
	['chapter-link'] = false,		-- deprecated
	['chapterurl'] = true,
	['chapter-url'] = true,
	['city']=true,					-- cite interview
	['coauthor'] = false,			-- deprecated
	['coauthors'] = false,			-- deprecated
	['conference'] = true,
	['conferenceurl'] = true,
	['conference-url'] = true,
	['contribution'] = true,
	['contributionurl'] = true,
	['contribution-url'] = true,
	['date'] = true,
	['deadurl'] = true,
	['dead-url'] = true,
	['degree'] = true,
	['department'] = true,
	['dictionary'] = true,
	['displayauthors'] = true,
	['display-authors'] = true,
	['displayeditors'] = true,
	['display-editors'] = true,
	['docket'] = true,
	['doi'] = true,
	['DOI'] = true,
	['DoiBroken'] = true,
	['doi-broken'] = true,
	['doi_brokendate'] = true,
	['doi-broken-date'] = true,
	['doi_inactivedate'] = true,
	['doi-inactive-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['Editor'] = true,
	['editor-first'] = true,
	['editorformat'] = false,				-- deprecated; primarily used to support Vancouver format which functionality now part of name-list-format
	['editor-format'] = false,				-- deprecated; primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorGiven'] = true,
	['editor-given'] = true,
	['editor-last'] = true,
	['editorlink'] = true,
	['editor-link'] = true,
	['editormask'] = true,
	['editor-mask'] = true,
	['editor-name-separator'] = false,		-- deprecated; primarily used to support Vancouver format which functionality now part of name-list-format
	['editors'] = true,
	['editor-separator'] = false,			-- deprecated; primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorSurname'] = true,
	['editor-surname'] = true,
	['embargo'] = true,
	['Embargo'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['entry'] = true,
	['episodelink'] = true,
	['episode-link'] = true,
	['event'] = true,
	['eventurl'] = true,
	['event-url'] = true,
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['host'] = true,
	['id'] = true,
	['ID'] = true,
	['ignoreisbnerror'] = true,
	['ignore-isbn-error'] = true,
	['in'] = true,
	['inset'] = true,
	['institution'] = true,
	['interviewer'] = true,				--cite interview
	['interviewers'] = true,			--cite interview
	['isbn'] = true,
	['ISBN'] = true,
	['isbn13'] = true,
	['ISBN13'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['laydate'] = true,
	['lay-date'] = true,
	['laysource'] = true,
	['lay-source'] = true,
	['laysummary'] = true,
	['lay-summary'] = true,
	['layurl'] = true,
	['lay-url'] = true,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['magazine'] = true,
	['mailinglist'] = true,				-- cite mailing list only
	['mailing-list'] = true,			-- cite mailing list only
	['map'] = true,						-- cite map only
	['map-format'] = true,				-- cite map only
	['mapurl'] = true,					-- cite map only
	['map-url'] = true,					-- cite map only
	['medium'] = true,
	['message-id'] = true,			-- cite newsgroup
	['minutes'] = true,
	['mode'] = true,
	['month'] = false,				-- deprecated
	['mr'] = true,
	['MR'] = true,
	['name-list-format'] = true,
	['name-separator'] = false,		-- deprecated;  primarily used to support Vancouver format which functionality now part of name-list-format
	['network'] = true,
	['newsgroup'] = true,
	['newspaper'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['nopp'] = true,
	['no-pp'] = true,
	['notracking'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['people'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['PPPrefix'] = true,
	['pp-prefix'] = true,
	['PPrefix'] = true,
	['p-prefix'] = true,
	['program']=true,				-- cite interview
	['publicationdate'] = true,
	['publication-date'] = true,
	['publicationplace'] = true,
	['publication-place'] = true,
	['publisher'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['Ref'] = true,
	['registration'] = true,
	['rfc'] = true,
	['RFC'] = true,
	['scale'] = true,
	['script-title'] = true,
	['season'] = true,
	['section'] = true,
	['sections'] = true,					-- cite map only
	['sectionurl'] = true,
	['section-url'] = true,
	['separator'] = false,				-- deprecated; this functionality now provided by |mode=
	['series'] = true,
	['serieslink'] = true,
	['series-link'] = true,
	['seriesno'] = true,
	['series-no'] = true,
	['seriesnumber'] = true,
	['series-number'] = true,
	['series-separator'] = true,
	['ssrn'] = true,
	['SSRN'] = true,
	['station'] = true,
	['subject'] = true,
	['subjectlink'] = true,
	['subject-link'] = true,
	['subscription'] = true,
	['surname'] = true,
	['template doc demo'] = true,
	['template-doc-demo'] = true,
	['time'] = true,
	['timecaption'] = true,
	['time-caption'] = true,
	['title'] = true,
	['titlelink'] = true,
	['title-link'] = true,
	['trans_chapter'] = true,
	['trans-chapter'] = true,
	['transcript'] = true,
	['transcripturl'] = true,
	['transcript-url'] = true,
	['trans_title'] = true,
	['trans-title'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
},

numbered_arguments = {
	['author#'] = true,
	['Author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['authors#'] = true,
	['editor#'] = true,
	['Editor#'] = true,
	['editor-first#'] = true,
	['editor#-first'] = true,
	['EditorGiven#'] = true,
	['editor#-given'] = true,
	['editor-given#'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-link#'] = true,
	['editor#link'] = true,
	['editor#-link'] = true,
	['editorlink#'] = true,
	['editor-mask#'] = true,
	['editor#mask'] = true,
	['editor#-mask'] = true,
	['editormask#'] = true,
	['editors#'] = true,
	['EditorSurname#'] = true,
	['editor#-surname'] = true,
	['editor-surname#'] = true,
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-link#'] = true,
	['subject#link'] = true,
	['subject#-link'] = true,
	['subjectlink#'] = true,
	['surname#'] = true,
},
};

return whitelist;</text>
      <sha1>s65xdd4nsdowbwc3z816ie09mhdmvp4</sha1>
    </revision>
    <revision>
      <id>4785</id>
      <parentid>4784</parentid>
      <timestamp>2015-04-18T09:53:28Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4785</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="11544" sha1="ra1rrwxpm0zq8f0cqvnpih5ocpdx8vs" xml:space="preserve">
--[[--------------------------&lt; P A R A M E T E R S   N O T   S U P P O R T E D &gt;------------------------------

This is a list of parameters that once were but now are no longer supported:

	['albumlink'] = nil,			-- unique alias of titlelink used by old cite AV media notes
	['albumtype'] = nil,			-- controled inappropriate functionality in the old cite AV media notes
	['artist'] = nil,				-- unique alias of others used by old cite AV media notes
	['authors#'] = nil,				-- no need for multiple lists of author names
	['cointerviewers'] = nil,		-- unique alias of others used by old cite interview
	['day'] = nil,					-- deprecated in {{citation/core}} and somehow undeprecated in Module:Citation/CS1 and now finally removed
	['director'] = nil,				-- unique alias of author used by old cite DVD-notes
	['DoiBroken'] = nil,			-- not used, non-standard captialization
	['editors#'] = nil,				-- no need for multiple lists of editor names
	['Embargo'] = nil,				-- not used, non-standard capitalization
	['notestitle'] = nil,			-- unique alias of chapter used by old cite AV media notes
	['PPPrefix'] = nil,				-- not used, non-standard capitalization
	['publisherid'] = nil,			-- unique alias of id used by old cite AV media notes and old cite DVD-notes
	['titleyear'] = nil,			-- unique alias of origyear used by old cite DVD-notes

]]

--[[--------------------------&lt; S U P P O R T E D   P A R A M E T E R S &gt;--------------------------------------

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local whitelist = {}

local basic_arguments = {
	['accessdate'] = true,
	['access-date'] = true,
	['agency'] = true,
	['airdate'] = true,
	['air-date'] = true,
	['archivedate'] = true,
	['archive-date'] = true,
	['archive-format'] = true,
	['archiveurl'] = true,
	['archive-url'] = true,
	['article'] = true,
	['arxiv'] = true,
	['ARXIV'] = true,
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['ASIN-TLD'] = true,
	['at'] = true,
	['author'] = true,
	['Author'] = false,						-- deprecated; non-standard capitalization
	['author-first'] = true,
	['authorformat'] = false,				-- deprecated; primarily used to support Vancouver format which functionality now part of name-list-format
	['author-format'] = false,				-- deprecated; primarily used to support Vancouver format which functionality now part of name-list-format
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['author-name-separator'] = false,		-- deprecated; primarily used to support Vancouver format which functionality now part of name-list-format
	['authors'] = true,
	['author-separator'] = false,			-- deprecated; primarily used to support Vancouver format which functionality now part of name-list-format
	['began'] = false,															-- deprecated because module handles date ranges; cite episode and cite series
	['bibcode'] = true,
	['BIBCODE'] = true,
	['booktitle'] = true,
	['book-title'] = true,
	['callsign']=true,				-- cite interview
	['call-sign']=true,				-- cite interview
	['cartography'] = true,
	['chapter'] = true,
	['chapter-format'] = true,
	['chapterlink'] = false,		-- deprecated
	['chapter-link'] = false,		-- deprecated
	['chapterurl'] = true,
	['chapter-url'] = true,
	['city'] = true,				-- cite interview, cite episode, cite serial
	['class'] = true,				-- cite arxiv and arxiv identifiers
	['coauthor'] = false,			-- deprecated
	['coauthors'] = false,			-- deprecated
	['conference'] = true,
	['conference-format'] = true,
	['conferenceurl'] = true,
	['conference-url'] = true,
	['contribution'] = true,
	['contribution-format'] = true,
	['contributionurl'] = true,
	['contribution-url'] = true,
	['credits'] = true,				-- cite episode, cite serial
	['date'] = true,
	['deadurl'] = true,
	['dead-url'] = true,
	['degree'] = true,
	['department'] = true,
	['dictionary'] = true,
	['displayauthors'] = true,
	['display-authors'] = true,
	['displayeditors'] = true,
	['display-editors'] = true,
	['docket'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-broken'] = true,
	['doi_brokendate'] = true,
	['doi-broken-date'] = true,
	['doi_inactivedate'] = true,
	['doi-inactive-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['Editor'] = false,						-- deprecated; non-standard capitalization
	['editor-first'] = true,
	['editorformat'] = false,				-- deprecated; primarily used to support Vancouver format which functionality now part of name-list-format
	['editor-format'] = false,				-- deprecated; primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorGiven'] = false,				-- deprecated; non-standard capitalization
	['editor-given'] = true,
	['editor-last'] = true,
	['editorlink'] = true,
	['editor-link'] = true,
	['editormask'] = true,
	['editor-mask'] = true,
	['editor-name-separator'] = false,		-- deprecated; primarily used to support Vancouver format which functionality now part of name-list-format
	['editors'] = true,
	['editor-separator'] = false,			-- deprecated; primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorSurname'] = false,				-- deprecated; non-standard capitalization
	['editor-surname'] = true,
	['embargo'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['ended'] = false,															-- deprecated because module handles date ranges; cite episode and cite series
	['entry'] = true,
	['episode'] = true,															-- cite serial only TODO: make available to cite episode?
	['episodelink'] = true,														-- cite episode and cite serial
	['episode-link'] = true,													-- cite episode and cite serial
	['eprint'] = true,															-- cite arxiv and arxiv identifiers
	['event'] = true,
	['event-format'] = true,
	['eventurl'] = true,
	['event-url'] = true,
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['host'] = true,
	['id'] = true,
	['ID'] = true,
	['ignoreisbnerror'] = true,
	['ignore-isbn-error'] = true,
	['in'] = true,
	['inset'] = true,
	['institution'] = true,
	['interviewer'] = true,				--cite interview
	['interviewers'] = true,			--cite interview
	['isbn'] = true,
	['ISBN'] = true,
	['isbn13'] = true,
	['ISBN13'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['laydate'] = true,
	['lay-date'] = true,
	['laysource'] = true,
	['lay-source'] = true,
	['laysummary'] = true,
	['lay-summary'] = true,
	['lay-format'] = true,
	['layurl'] = true,
	['lay-url'] = true,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['magazine'] = true,
	['mailinglist'] = true,				-- cite mailing list only
	['mailing-list'] = true,			-- cite mailing list only
	['map'] = true,						-- cite map only
	['map-format'] = true,				-- cite map only
	['mapurl'] = true,					-- cite map only
	['map-url'] = true,					-- cite map only
	['medium'] = true,
	['message-id'] = true,			-- cite newsgroup
	['minutes'] = true,
	['mode'] = true,
	['month'] = false,				-- deprecated
	['mr'] = true,
	['MR'] = true,
	['name-list-format'] = true,
	['name-separator'] = false,		-- deprecated;  primarily used to support Vancouver format which functionality now part of name-list-format
	['network'] = true,
	['newsgroup'] = true,
	['newspaper'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['nopp'] = true,
	['no-pp'] = true,
	['notracking'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['people'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['pp-prefix'] = true,
	['PPrefix'] = true,
	['p-prefix'] = true,
	['program']=true,				-- cite interview
	['publicationdate'] = true,
	['publication-date'] = true,
	['publicationplace'] = true,
	['publication-place'] = true,
	['publisher'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['Ref'] = true,
	['registration'] = true,
	['rfc'] = true,
	['RFC'] = true,
	['scale'] = true,
	['script-title'] = true,
	['season'] = true,
	['section'] = true,
	['section-format'] = true,
	['sections'] = true,					-- cite map only
	['sectionurl'] = true,
	['section-url'] = true,
	['separator'] = false,				-- deprecated; this functionality now provided by |mode=
	['series'] = true,
	['serieslink'] = true,
	['series-link'] = true,
	['seriesno'] = true,
	['series-no'] = true,
	['seriesnumber'] = true,
	['series-number'] = true,
	['series-separator'] = true,
	['sheet'] = true,															-- cite map only
	['sheets'] = true,															-- cite map only
	['ssrn'] = true,
	['SSRN'] = true,
	['station'] = true,
	['subject'] = true,
	['subjectlink'] = true,
	['subject-link'] = true,
	['subscription'] = true,
	['surname'] = true,
	['template doc demo'] = true,
	['template-doc-demo'] = true,
	['time'] = true,
	['timecaption'] = true,
	['time-caption'] = true,
	['title'] = true,
	['titlelink'] = true,
	['title-link'] = true,
	['trans_chapter'] = true,
	['trans-chapter'] = true,
	['trans-map'] = true;
	['transcript'] = true,
	['transcript-format'] = true,
	['transcripturl'] = true,
	['transcript-url'] = true,
	['trans_title'] = true,
	['trans-title'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
}

local numbered_arguments = {
	['author#'] = true,
	['Author#'] = false,														-- deprecated; non-standard capitalization
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['editor#'] = true,
	['Editor#'] = false,														-- deprecated; non-standard capitalization
	['editor-first#'] = true,
	['editor#-first'] = true,
	['EditorGiven#'] = false,													-- deprecated; non-standard capitalization
	['editor#-given'] = true,
	['editor-given#'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-link#'] = true,
	['editor#link'] = true,
	['editor#-link'] = true,
	['editorlink#'] = true,
	['editor-mask#'] = true,
	['editor#mask'] = true,
	['editor#-mask'] = true,
	['editormask#'] = true,
	['EditorSurname#'] = false,													-- deprecated; non-standard capitalization
	['editor#-surname'] = true,
	['editor-surname#'] = true,
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-link#'] = true,
	['subject#link'] = true,
	['subject#-link'] = true,
	['subjectlink#'] = true,
	['surname#'] = true,
}
--};

--return whitelist;
return {basic_arguments = basic_arguments, numbered_arguments = numbered_arguments};</text>
      <sha1>ra1rrwxpm0zq8f0cqvnpih5ocpdx8vs</sha1>
    </revision>
    <revision>
      <id>4786</id>
      <parentid>4785</parentid>
      <timestamp>2015-07-25T10:24:18Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4786</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="11624" sha1="egi68rlbldwu0hbgktayui6dgsutta3" xml:space="preserve">
--[[--------------------------&lt; P A R A M E T E R S   N O T   S U P P O R T E D &gt;------------------------------

This is a list of parameters that once were but now are no longer supported:

	['albumlink'] = nil,			-- unique alias of titlelink used by old cite AV media notes
	['albumtype'] = nil,			-- controled inappropriate functionality in the old cite AV media notes
	['artist'] = nil,				-- unique alias of others used by old cite AV media notes
	['authors#'] = nil,				-- no need for multiple lists of author names
	['cointerviewers'] = nil,		-- unique alias of others used by old cite interview
	['day'] = nil,					-- deprecated in {{citation/core}} and somehow undeprecated in Module:Citation/CS1 and now finally removed
	['director'] = nil,				-- unique alias of author used by old cite DVD-notes
	['DoiBroken'] = nil,			-- not used, non-standard captialization
	['editors#'] = nil,				-- no need for multiple lists of editor names
	['Embargo'] = nil,				-- not used, non-standard capitalization
	['notestitle'] = nil,			-- unique alias of chapter used by old cite AV media notes
	['PPPrefix'] = nil,				-- not used, non-standard capitalization
	['publisherid'] = nil,			-- unique alias of id used by old cite AV media notes and old cite DVD-notes
	['titleyear'] = nil,			-- unique alias of origyear used by old cite DVD-notes

]]

--[[--------------------------&lt; S U P P O R T E D   P A R A M E T E R S &gt;--------------------------------------

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local whitelist = {}

local basic_arguments = {
	['accessdate'] = true,
	['access-date'] = true,
	['agency'] = true,
	['airdate'] = true,
	['air-date'] = true,
	['archivedate'] = true,
	['archive-date'] = true,
	['archive-format'] = true,
	['archiveurl'] = true,
	['archive-url'] = true,
	['article'] = true,
	['arxiv'] = true,
	['ARXIV'] = true,
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['ASIN-TLD'] = true,
	['at'] = true,
	['author'] = true,
	['Author'] = false,						-- deprecated; non-standard capitalization
	['author-first'] = true,
	['authorformat'] = false,				-- deprecated; primarily used to support Vancouver format which functionality now part of name-list-format
	['author-format'] = false,				-- deprecated; primarily used to support Vancouver format which functionality now part of name-list-format
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['author-name-separator'] = false,		-- deprecated; primarily used to support Vancouver format which functionality now part of name-list-format
	['authors'] = true,
	['author-separator'] = false,			-- deprecated; primarily used to support Vancouver format which functionality now part of name-list-format
	['began'] = false,															-- deprecated because module handles date ranges; cite episode and cite series
	['bibcode'] = true,
	['BIBCODE'] = true,
	['booktitle'] = true,
	['book-title'] = true,
	['callsign']=true,				-- cite interview
	['call-sign']=true,				-- cite interview
	['cartography'] = true,
	['chapter'] = true,
	['chapter-format'] = true,
	['chapterlink'] = false,		-- deprecated
	['chapter-link'] = false,		-- deprecated
	['chapterurl'] = true,
	['chapter-url'] = true,
	['city'] = true,				-- cite interview, cite episode, cite serial
	['class'] = true,				-- cite arxiv and arxiv identifiers
	['coauthor'] = false,			-- deprecated
	['coauthors'] = false,			-- deprecated
	['conference'] = true,
	['conference-format'] = true,
	['conferenceurl'] = true,
	['conference-url'] = true,
	['contribution'] = true,
	['contribution-format'] = true,
	['contributionurl'] = true,
	['contribution-url'] = true,
	['credits'] = true,				-- cite episode, cite serial
	['date'] = true,
	['deadurl'] = true,
	['dead-url'] = true,
	['degree'] = true,
	['department'] = true,
	['dictionary'] = true,
	['displayauthors'] = true,
	['display-authors'] = true,
	['displayeditors'] = true,
	['display-editors'] = true,
	['docket'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-broken'] = true,
	['doi_brokendate'] = true,
	['doi-broken-date'] = true,
	['doi_inactivedate'] = true,
	['doi-inactive-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['Editor'] = false,						-- deprecated; non-standard capitalization
	['editor-first'] = true,
	['editorformat'] = false,				-- deprecated; primarily used to support Vancouver format which functionality now part of name-list-format
	['editor-format'] = false,				-- deprecated; primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorGiven'] = false,				-- deprecated; non-standard capitalization
	['editor-given'] = true,
	['editor-last'] = true,
	['editorlink'] = true,
	['editor-link'] = true,
	['editormask'] = true,
	['editor-mask'] = true,
	['editor-name-separator'] = false,		-- deprecated; primarily used to support Vancouver format which functionality now part of name-list-format
	['editors'] = true,
	['editor-separator'] = false,			-- deprecated; primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorSurname'] = false,				-- deprecated; non-standard capitalization
	['editor-surname'] = true,
	['embargo'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['ended'] = false,															-- deprecated because module handles date ranges; cite episode and cite series
	['entry'] = true,
	['episode'] = true,															-- cite serial only TODO: make available to cite episode?
	['episodelink'] = true,														-- cite episode and cite serial
	['episode-link'] = true,													-- cite episode and cite serial
	['eprint'] = true,															-- cite arxiv and arxiv identifiers
	['event'] = true,
	['event-format'] = true,
	['eventurl'] = true,
	['event-url'] = true,
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['host'] = true,
	['id'] = true,
	['ID'] = true,
	['ignoreisbnerror'] = true,
	['ignore-isbn-error'] = true,
	['in'] = true,
	['inset'] = true,
	['institution'] = true,
	['interviewer'] = true,				--cite interview
	['interviewers'] = true,			--cite interview
	['isbn'] = true,
	['ISBN'] = true,
	['isbn13'] = true,
	['ISBN13'] = true,
	['ismn'] = true,
	['ISMN'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['laydate'] = true,
	['lay-date'] = true,
	['laysource'] = true,
	['lay-source'] = true,
	['laysummary'] = true,
	['lay-summary'] = true,
	['lay-format'] = true,
	['layurl'] = true,
	['lay-url'] = true,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['magazine'] = true,
	['mailinglist'] = true,				-- cite mailing list only
	['mailing-list'] = true,			-- cite mailing list only
	['map'] = true,						-- cite map only
	['map-format'] = true,				-- cite map only
	['mapurl'] = true,					-- cite map only
	['map-url'] = true,					-- cite map only
	['medium'] = true,
	['message-id'] = true,			-- cite newsgroup
	['minutes'] = true,
	['mode'] = true,
	['month'] = false,				-- deprecated
	['mr'] = true,
	['MR'] = true,
	['name-list-format'] = true,
	['name-separator'] = false,		-- deprecated;  primarily used to support Vancouver format which functionality now part of name-list-format
	['network'] = true,
	['newsgroup'] = true,
	['newspaper'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['nopp'] = true,
	['no-pp'] = true,
	['notracking'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['people'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['pp-prefix'] = true,
	['PPrefix'] = true,
	['p-prefix'] = true,
	['program']=true,				-- cite interview
	['publicationdate'] = true,
	['publication-date'] = true,
	['publicationplace'] = true,
	['publication-place'] = true,
	['publisher'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['Ref'] = true,
	['registration'] = true,
	['rfc'] = true,
	['RFC'] = true,
	['scale'] = true,
	['script-title'] = true,
	['season'] = true,
	['section'] = true,
	['section-format'] = true,
	['sections'] = true,					-- cite map only
	['sectionurl'] = true,
	['section-url'] = true,
	['separator'] = false,				-- deprecated; this functionality now provided by |mode=
	['series'] = true,
	['serieslink'] = true,
	['series-link'] = true,
	['seriesno'] = true,
	['series-no'] = true,
	['seriesnumber'] = true,
	['series-number'] = true,
	['series-separator'] = true,
	['sheet'] = true,															-- cite map only
	['sheets'] = true,															-- cite map only
	['ssrn'] = true,
	['SSRN'] = true,
	['station'] = true,
	['subject'] = true,
	['subjectlink'] = true,
	['subject-link'] = true,
	['subscription'] = true,
	['surname'] = true,
	['template doc demo'] = true,
	['template-doc-demo'] = true,
	['time'] = true,
	['timecaption'] = true,
	['time-caption'] = true,
	['title'] = true,
	['titlelink'] = true,
	['title-link'] = true,
	['trans_chapter'] = true,
	['trans-chapter'] = true,
	['trans-map'] = true;
	['transcript'] = true,
	['transcript-format'] = true,
	['transcripturl'] = true,
	['transcript-url'] = true,
	['trans_title'] = true,
	['trans-title'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['vauthors'] = true,
	['veditors'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
}

local numbered_arguments = {
	['author#'] = true,
	['Author#'] = false,														-- deprecated; non-standard capitalization
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['editor#'] = true,
	['Editor#'] = false,														-- deprecated; non-standard capitalization
	['editor-first#'] = true,
	['editor#-first'] = true,
	['EditorGiven#'] = false,													-- deprecated; non-standard capitalization
	['editor#-given'] = true,
	['editor-given#'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-link#'] = true,
	['editor#link'] = true,
	['editor#-link'] = true,
	['editorlink#'] = true,
	['editor-mask#'] = true,
	['editor#mask'] = true,
	['editor#-mask'] = true,
	['editormask#'] = true,
	['EditorSurname#'] = false,													-- deprecated; non-standard capitalization
	['editor#-surname'] = true,
	['editor-surname#'] = true,
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-link#'] = true,
	['subject#link'] = true,
	['subject#-link'] = true,
	['subjectlink#'] = true,
	['surname#'] = true,
}
--};

--return whitelist;
return {basic_arguments = basic_arguments, numbered_arguments = numbered_arguments};</text>
      <sha1>egi68rlbldwu0hbgktayui6dgsutta3</sha1>
    </revision>
    <revision>
      <id>4787</id>
      <parentid>4786</parentid>
      <timestamp>2015-09-26T16:13:38Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4787</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="11829" sha1="e0pzwmohvj3jwcln0ss0jcfchy1xeqf" xml:space="preserve">
--[[--------------------------&lt; P A R A M E T E R S   N O T   S U P P O R T E D &gt;------------------------------

This is a list of parameters that once were but now are no longer supported:

	['albumlink'] = nil,			-- unique alias of titlelink used by old cite AV media notes
	['albumtype'] = nil,			-- controled inappropriate functionality in the old cite AV media notes
	['artist'] = nil,				-- unique alias of others used by old cite AV media notes
	['Author'] = nil,				-- non-standard capitalization
	['authorformat'] = nil,			-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-format'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-name-separator'] = nil,-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-separator'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['began'] = nil,				-- module handles date ranges; cite episode and cite series
	['chapterlink'] = nil,			-- if ever necessary to link to a chapter article, |chapter= can be wikilinked 
	['chapter-link'] = nil,			-- 
	['cointerviewers'] = nil,		-- unique alias of others used by old cite interview
	['day'] = nil,					-- deprecated in {{citation/core}} and somehow undeprecated in Module:Citation/CS1 and now finally removed
	['director'] = nil,				-- unique alias of author used by old cite DVD-notes
	['DoiBroken'] = nil,			-- not used, non-standard captialization
	['Editor'] = nil,				-- non-standard capitalization
	['editorformat'] = nil,			-- primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorSurname'] = nil,		-- non-standard capitalization
	['editor-format'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorGiven'] = nil,			-- non-standard capitalization
	['editor-name-separator'] = nil,-- primarily used to support Vancouver format which functionality now part of name-list-format
	['editor-separator'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['Embargo'] = nil,				-- not used, non-standard capitalization
	['ended'] = nil,				-- module handles date ranges; cite episode and cite series
	['month'] = nil,				-- functionality supported by |date=
	['name-separator'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['notestitle'] = nil,			-- unique alias of chapter used by old cite AV media notes
	['PPrefix'] = nil,				-- non-standard capitalization
	['PPPrefix'] = nil,				-- not used, non-standard capitalization
	['publisherid'] = nil,			-- unique alias of id used by old cite AV media notes and old cite DVD-notes
	['separator'] = nil,			-- this functionality now provided by |mode=
	['titleyear'] = nil,			-- unique alias of origyear used by old cite DVD-notes

	['Author#'] = nil,				-- non-standard capitalization
	['authors#'] = nil,				-- no need for multiple lists of author names
	['Editor#'] = nil,				-- non-standard capitalization
	['editors#'] = nil,				-- no need for multiple lists of editor names
	['EditorGiven#'] = nil,			-- non-standard capitalization
	['EditorSurname#'] = nil,		-- non-standard capitalization

]]

--[[--------------------------&lt; S U P P O R T E D   P A R A M E T E R S &gt;--------------------------------------

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local whitelist = {}

local basic_arguments = {
	['accessdate'] = true,
	['access-date'] = true,
	['agency'] = true,
	['airdate'] = true,
	['air-date'] = true,
	['archivedate'] = true,
	['archive-date'] = true,
	['archive-format'] = true,
	['archiveurl'] = true,
	['archive-url'] = true,
	['article'] = true,
	['arxiv'] = true,
	['ARXIV'] = true,
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['ASIN-TLD'] = true,
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['bibcode'] = true,
	['BIBCODE'] = true,
	['booktitle'] = true,
	['book-title'] = true,
	['callsign'] = true,			-- cite interview
	['call-sign'] = true,			-- cite interview
	['cartography'] = true,
	['chapter'] = true,
	['chapter-format'] = true,
	['chapterurl'] = true,
	['chapter-url'] = true,
	['city'] = true,				-- cite interview, cite episode, cite serial
	['class'] = true,				-- cite arxiv and arxiv identifiers
	['coauthor'] = false,			-- deprecated
	['coauthors'] = false,			-- deprecated
	['conference'] = true,
	['conference-format'] = true,
	['conferenceurl'] = true,
	['conference-url'] = true,
	['contribution'] = true,
	['contribution-format'] = true,
	['contributionurl'] = true,
	['contribution-url'] = true,
	['credits'] = true,				-- cite episode, cite serial
	['date'] = true,
	['deadurl'] = true,
	['dead-url'] = true,
	['degree'] = true,
	['department'] = true,
	['dictionary'] = true,
	['displayauthors'] = true,
	['display-authors'] = true,
	['displayeditors'] = true,
	['display-editors'] = true,
	['docket'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-broken'] = true,
	['doi_brokendate'] = true,
	['doi-broken-date'] = true,
	['doi_inactivedate'] = true,
	['doi-inactive-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['editor-first'] = true,
	['editor-given'] = true,
	['editor-last'] = true,
	['editorlink'] = true,
	['editor-link'] = true,
	['editormask'] = true,
	['editor-mask'] = true,
	['editors'] = true,
	['editor-surname'] = true,
	['embargo'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['entry'] = true,
	['episode'] = true,															-- cite serial only TODO: make available to cite episode?
	['episodelink'] = true,														-- cite episode and cite serial
	['episode-link'] = true,													-- cite episode and cite serial
	['eprint'] = true,															-- cite arxiv and arxiv identifiers
	['event'] = true,
	['event-format'] = true,
	['eventurl'] = true,
	['event-url'] = true,
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['host'] = true,
	['id'] = true,
	['ID'] = true,
	['ignoreisbnerror'] = true,
	['ignore-isbn-error'] = true,
	['in'] = true,
	['inset'] = true,
	['institution'] = true,
	['interviewer'] = true,				--cite interview
	['interviewers'] = true,			--cite interview
	['isbn'] = true,
	['ISBN'] = true,
	['isbn13'] = true,
	['ISBN13'] = true,
	['ismn'] = true,
	['ISMN'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['laydate'] = true,
	['lay-date'] = true,
	['laysource'] = true,
	['lay-source'] = true,
	['laysummary'] = true,
	['lay-summary'] = true,
	['lay-format'] = true,
	['layurl'] = true,
	['lay-url'] = true,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['magazine'] = true,
	['mailinglist'] = true,				-- cite mailing list only
	['mailing-list'] = true,			-- cite mailing list only
	['map'] = true,						-- cite map only
	['map-format'] = true,				-- cite map only
	['mapurl'] = true,					-- cite map only
	['map-url'] = true,					-- cite map only
	['medium'] = true,
	['message-id'] = true,			-- cite newsgroup
	['minutes'] = true,
	['mode'] = true,
	['mr'] = true,
	['MR'] = true,
	['name-list-format'] = true,
	['network'] = true,
	['newsgroup'] = true,
	['newspaper'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['nopp'] = true,
	['no-pp'] = true,
	['notracking'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['people'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['pp-prefix'] = true,
	['p-prefix'] = true,
	['program'] = true,				-- cite interview
	['publicationdate'] = true,
	['publication-date'] = true,
	['publicationplace'] = true,
	['publication-place'] = true,
	['publisher'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['Ref'] = false,															-- deprecated, non-statndard capitalization
	['registration'] = true,
	['rfc'] = true,
	['RFC'] = true,
	['scale'] = true,
	['script-chapter'] = true,
	['script-title'] = true,
	['season'] = true,
	['section'] = true,
	['section-format'] = true,
	['sections'] = true,					-- cite map only
	['sectionurl'] = true,
	['section-url'] = true,
	['series'] = true,
	['serieslink'] = true,
	['series-link'] = true,
	['seriesno'] = true,
	['series-no'] = true,
	['seriesnumber'] = true,
	['series-number'] = true,
	['series-separator'] = true,
	['sheet'] = true,															-- cite map only
	['sheets'] = true,															-- cite map only
	['ssrn'] = true,
	['SSRN'] = true,
	['station'] = true,
	['subject'] = true,
	['subjectlink'] = true,
	['subject-link'] = true,
	['subscription'] = true,
	['surname'] = true,
	['template doc demo'] = true,
	['template-doc-demo'] = true,
	['time'] = true,
	['timecaption'] = true,
	['time-caption'] = true,
	['title'] = true,
	['titlelink'] = true,
	['title-link'] = true,
	['trans_chapter'] = true,
	['trans-chapter'] = true,
	['trans-map'] = true,
	['transcript'] = true,
	['transcript-format'] = true,
	['transcripturl'] = true,
	['transcript-url'] = true,
	['trans_title'] = true,
	['trans-title'] = true,
	['translator'] = true,
	['translator-first'] = true,
	['translator-last'] = true,
	['translator-link'] = true,
	['translator-mask'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['vauthors'] = true,
	['veditors'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
}

local numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['editor#'] = true,
	['editor-first#'] = true,
	['editor#-first'] = true,
	['editor#-given'] = true,
	['editor-given#'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-link#'] = true,
	['editor#link'] = true,
	['editor#-link'] = true,
	['editorlink#'] = true,
	['editor-mask#'] = true,
	['editor#mask'] = true,
	['editor#-mask'] = true,
	['editormask#'] = true,
	['editor#-surname'] = true,
	['editor-surname#'] = true,
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-link#'] = true,
	['subject#link'] = true,
	['subject#-link'] = true,
	['subjectlink#'] = true,
	['surname#'] = true,
	['translator#'] = true,
	['translator-first#'] = true,
	['translator#-first'] = true,
	['translator-last#'] = true,
	['translator#-last'] = true,
	['translator-link#'] = true,
	['translator#-link'] = true,
	['translator-mask#'] = true,
	['translator#-mask'] = true,
}

return {basic_arguments = basic_arguments, numbered_arguments = numbered_arguments};</text>
      <sha1>e0pzwmohvj3jwcln0ss0jcfchy1xeqf</sha1>
    </revision>
    <revision>
      <id>4788</id>
      <parentid>4787</parentid>
      <timestamp>2015-12-05T12:45:14Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4788</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="12286" sha1="2p2w1ngjc21m1yc7bxm7mb3il4em87h" xml:space="preserve">
--[[--------------------------&lt; P A R A M E T E R S   N O T   S U P P O R T E D &gt;------------------------------

This is a list of parameters that once were but now are no longer supported:

	['albumlink'] = nil,			-- unique alias of titlelink used by old cite AV media notes
	['albumtype'] = nil,			-- controled inappropriate functionality in the old cite AV media notes
	['artist'] = nil,				-- unique alias of others used by old cite AV media notes
	['Author'] = nil,				-- non-standard capitalization
	['authorformat'] = nil,			-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-format'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-name-separator'] = nil,-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-separator'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['began'] = nil,				-- module handles date ranges; cite episode and cite series
	['chapterlink'] = nil,			-- if ever necessary to link to a chapter article, |chapter= can be wikilinked 
	['chapter-link'] = nil,			-- 
	['cointerviewers'] = nil,		-- unique alias of others used by old cite interview
	['day'] = nil,					-- deprecated in {{citation/core}} and somehow undeprecated in Module:Citation/CS1 and now finally removed
	['director'] = nil,				-- unique alias of author used by old cite DVD-notes
	['DoiBroken'] = nil,			-- not used, non-standard captialization
	['Editor'] = nil,				-- non-standard capitalization
	['editorformat'] = nil,			-- primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorSurname'] = nil,		-- non-standard capitalization
	['editor-format'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorGiven'] = nil,			-- non-standard capitalization
	['editor-name-separator'] = nil,-- primarily used to support Vancouver format which functionality now part of name-list-format
	['editor-separator'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['Embargo'] = nil,				-- not used, non-standard capitalization
	['ended'] = nil,				-- module handles date ranges; cite episode and cite series
	['month'] = nil,				-- functionality supported by |date=
	['name-separator'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['notestitle'] = nil,			-- unique alias of chapter used by old cite AV media notes
	['PPrefix'] = nil,				-- non-standard capitalization
	['PPPrefix'] = nil,				-- not used, non-standard capitalization
	['pp-prefix'] = nil,			-- not used, not documented
	['p-prefix'] = nil,				-- not used, not documented
	['publisherid'] = nil,			-- unique alias of id used by old cite AV media notes and old cite DVD-notes
	['Ref'] = nil,					-- non-statndard capitalization
	['separator'] = nil,			-- this functionality now provided by |mode=
	['titleyear'] = nil,			-- unique alias of origyear used by old cite DVD-notes

	['Author#'] = nil,				-- non-standard capitalization
	['authors#'] = nil,				-- no need for multiple lists of author names
	['Editor#'] = nil,				-- non-standard capitalization
	['editors#'] = nil,				-- no need for multiple lists of editor names
	['EditorGiven#'] = nil,			-- non-standard capitalization
	['EditorSurname#'] = nil,		-- non-standard capitalization

]]

--[[--------------------------&lt; S U P P O R T E D   P A R A M E T E R S &gt;--------------------------------------

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local whitelist = {}

local basic_arguments = {
	['accessdate'] = true,
	['access-date'] = true,
	['agency'] = true,
	['airdate'] = true,
	['air-date'] = true,
	['archivedate'] = true,
	['archive-date'] = true,
	['archive-format'] = true,
	['archiveurl'] = true,
	['archive-url'] = true,
	['article'] = true,
	['arxiv'] = true,
	['ARXIV'] = true,
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['ASIN-TLD'] = true,
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['bibcode'] = true,
	['BIBCODE'] = true,
	['booktitle'] = true,
	['book-title'] = true,
	['callsign'] = true,			-- cite interview
	['call-sign'] = true,			-- cite interview
	['cartography'] = true,
	['chapter'] = true,
	['chapter-format'] = true,
	['chapterurl'] = true,
	['chapter-url'] = true,
	['city'] = true,				-- cite interview, cite episode, cite serial
	['class'] = true,				-- cite arxiv and arxiv identifiers
	['coauthor'] = false,			-- deprecated
	['coauthors'] = false,			-- deprecated
	['conference'] = true,
	['conference-format'] = true,
	['conferenceurl'] = true,
	['conference-url'] = true,
	['contribution'] = true,
	['contribution-format'] = true,
	['contributionurl'] = true,
	['contribution-url'] = true,
	['contributor'] = true,
	['contributor-first'] = true,
	['contributor-last'] = true,
	['contributor-link'] = true,
	['contributor-mask'] = true,
	['credits'] = true,				-- cite episode, cite serial
	['date'] = true,
	['deadurl'] = true,
	['dead-url'] = true,
	['degree'] = true,
	['department'] = true,
	['dictionary'] = true,
	['displayauthors'] = true,
	['display-authors'] = true,
	['displayeditors'] = true,
	['display-editors'] = true,
	['docket'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-broken'] = true,
	['doi_brokendate'] = true,
	['doi-broken-date'] = true,
	['doi_inactivedate'] = true,
	['doi-inactive-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['editor-first'] = true,
	['editor-given'] = true,
	['editor-last'] = true,
	['editorlink'] = true,
	['editor-link'] = true,
	['editormask'] = true,
	['editor-mask'] = true,
	['editors'] = true,
	['editor-surname'] = true,
	['embargo'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['entry'] = true,
	['episode'] = true,															-- cite serial only TODO: make available to cite episode?
	['episodelink'] = true,														-- cite episode and cite serial
	['episode-link'] = true,													-- cite episode and cite serial
	['eprint'] = true,															-- cite arxiv and arxiv identifiers
	['event'] = true,
	['event-format'] = true,
	['eventurl'] = true,
	['event-url'] = true,
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['host'] = true,
	['id'] = true,
	['ID'] = true,
	['ignoreisbnerror'] = true,
	['ignore-isbn-error'] = true,
	['in'] = true,
	['inset'] = true,
	['institution'] = true,
	['interviewer'] = true,				--cite interview
	['interviewers'] = true,			--cite interview
	['isbn'] = true,
	['ISBN'] = true,
	['isbn13'] = true,
	['ISBN13'] = true,
	['ismn'] = true,
	['ISMN'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['laydate'] = true,
	['lay-date'] = true,
	['laysource'] = true,
	['lay-source'] = true,
	['laysummary'] = true,
	['lay-summary'] = true,
	['lay-format'] = true,
	['layurl'] = true,
	['lay-url'] = true,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['magazine'] = true,
	['mailinglist'] = true,				-- cite mailing list only
	['mailing-list'] = true,			-- cite mailing list only
	['map'] = true,						-- cite map only
	['map-format'] = true,				-- cite map only
	['mapurl'] = true,					-- cite map only
	['map-url'] = true,					-- cite map only
	['medium'] = true,
	['message-id'] = true,			-- cite newsgroup
	['minutes'] = true,
	['mode'] = true,
	['mr'] = true,
	['MR'] = true,
	['name-list-format'] = true,
	['network'] = true,
	['newsgroup'] = true,
	['newspaper'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['nopp'] = true,
	['no-pp'] = true,
	['notracking'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['people'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['program'] = true,				-- cite interview
	['publicationdate'] = true,
	['publication-date'] = true,
	['publicationplace'] = true,
	['publication-place'] = true,
	['publisher'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['registration'] = true,
	['rfc'] = true,
	['RFC'] = true,
	['scale'] = true,
	['script-chapter'] = true,
	['script-title'] = true,
	['season'] = true,
	['section'] = true,
	['section-format'] = true,
	['sections'] = true,					-- cite map only
	['sectionurl'] = true,
	['section-url'] = true,
	['series'] = true,
	['serieslink'] = true,
	['series-link'] = true,
	['seriesno'] = true,
	['series-no'] = true,
	['seriesnumber'] = true,
	['series-number'] = true,
	['series-separator'] = true,
	['sheet'] = true,															-- cite map only
	['sheets'] = true,															-- cite map only
	['ssrn'] = true,
	['SSRN'] = true,
	['station'] = true,
	['subject'] = true,
	['subjectlink'] = true,
	['subject-link'] = true,
	['subscription'] = true,
	['surname'] = true,
	['template doc demo'] = true,
	['template-doc-demo'] = true,
	['time'] = true,
	['timecaption'] = true,
	['time-caption'] = true,
	['title'] = true,
	['titlelink'] = true,
	['title-link'] = true,
	['trans_chapter'] = true,
	['trans-chapter'] = true,
	['trans-map'] = true,
	['transcript'] = true,
	['transcript-format'] = true,
	['transcripturl'] = true,
	['transcript-url'] = true,
	['trans_title'] = true,
	['trans-title'] = true,
	['translator'] = true,
	['translator-first'] = true,
	['translator-last'] = true,
	['translator-link'] = true,
	['translator-mask'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['vauthors'] = true,
	['veditors'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
}

local numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['contributor#'] = true,
	['contributor-first#'] = true,
	['contributor#-first'] = true,
	['contributor-last#'] = true,
	['contributor#-last'] = true,
	['contributor-link#'] = true,
	['contributor#-link'] = true,
	['contributor-mask#'] = true,
	['contributor#-mask'] = true,
	['editor#'] = true,
	['editor-first#'] = true,
	['editor#-first'] = true,
	['editor#-given'] = true,
	['editor-given#'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-link#'] = true,
	['editor#link'] = true,
	['editor#-link'] = true,
	['editorlink#'] = true,
	['editor-mask#'] = true,
	['editor#mask'] = true,
	['editor#-mask'] = true,
	['editormask#'] = true,
	['editor#-surname'] = true,
	['editor-surname#'] = true,
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-link#'] = true,
	['subject#link'] = true,
	['subject#-link'] = true,
	['subjectlink#'] = true,
	['surname#'] = true,
	['translator#'] = true,
	['translator-first#'] = true,
	['translator#-first'] = true,
	['translator-last#'] = true,
	['translator#-last'] = true,
	['translator-link#'] = true,
	['translator#-link'] = true,
	['translator-mask#'] = true,
	['translator#-mask'] = true,
}

return {basic_arguments = basic_arguments, numbered_arguments = numbered_arguments};</text>
      <sha1>2p2w1ngjc21m1yc7bxm7mb3il4em87h</sha1>
    </revision>
    <revision>
      <id>4789</id>
      <parentid>4788</parentid>
      <timestamp>2016-01-16T13:06:54Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4789</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="12400" sha1="hil32i44qxogi4kjmudrlaz4wz0kg92" xml:space="preserve">
--[[--------------------------&lt; P A R A M E T E R S   N O T   S U P P O R T E D &gt;------------------------------

This is a list of parameters that once were but now are no longer supported:

	['albumlink'] = nil,			-- unique alias of titlelink used by old cite AV media notes
	['albumtype'] = nil,			-- controled inappropriate functionality in the old cite AV media notes
	['artist'] = nil,				-- unique alias of others used by old cite AV media notes
	['Author'] = nil,				-- non-standard capitalization
	['authorformat'] = nil,			-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-format'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-name-separator'] = nil,-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-separator'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['began'] = nil,				-- module handles date ranges; cite episode and cite series
	['chapterlink'] = nil,			-- if ever necessary to link to a chapter article, |chapter= can be wikilinked 
	['chapter-link'] = nil,			-- 
	['cointerviewers'] = nil,		-- unique alias of others used by old cite interview
	['day'] = nil,					-- deprecated in {{citation/core}} and somehow undeprecated in Module:Citation/CS1 and now finally removed
	['director'] = nil,				-- unique alias of author used by old cite DVD-notes
	['DoiBroken'] = nil,			-- not used, non-standard captialization
	['Editor'] = nil,				-- non-standard capitalization
	['editorformat'] = nil,			-- primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorSurname'] = nil,		-- non-standard capitalization
	['editor-format'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorGiven'] = nil,			-- non-standard capitalization
	['editor-name-separator'] = nil,-- primarily used to support Vancouver format which functionality now part of name-list-format
	['editor-separator'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['Embargo'] = nil,				-- not used, non-standard capitalization
	['ended'] = nil,				-- module handles date ranges; cite episode and cite series
	['month'] = nil,				-- functionality supported by |date=
	['name-separator'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['notestitle'] = nil,			-- unique alias of chapter used by old cite AV media notes
	['PPrefix'] = nil,				-- non-standard capitalization
	['PPPrefix'] = nil,				-- not used, non-standard capitalization
	['pp-prefix'] = nil,			-- not used, not documented
	['p-prefix'] = nil,				-- not used, not documented
	['publisherid'] = nil,			-- unique alias of id used by old cite AV media notes and old cite DVD-notes
	['Ref'] = nil,					-- non-standard capitalization
	['separator'] = nil,			-- this functionality now provided by |mode=
	['titleyear'] = nil,			-- unique alias of origyear used by old cite DVD-notes

	['Author#'] = nil,				-- non-standard capitalization
	['authors#'] = nil,				-- no need for multiple lists of author names
	['Editor#'] = nil,				-- non-standard capitalization
	['editors#'] = nil,				-- no need for multiple lists of editor names
	['EditorGiven#'] = nil,			-- non-standard capitalization
	['EditorSurname#'] = nil,		-- non-standard capitalization

]]

--[[--------------------------&lt; S U P P O R T E D   P A R A M E T E R S &gt;--------------------------------------

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local whitelist = {}

local basic_arguments = {
	['accessdate'] = true,
	['access-date'] = true,
	['agency'] = true,
	['airdate'] = true,
	['air-date'] = true,
	['archivedate'] = true,
	['archive-date'] = true,
	['archive-format'] = true,
	['archiveurl'] = true,
	['archive-url'] = true,
	['article'] = true,
	['arxiv'] = true,
	['ARXIV'] = true,
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['ASIN-TLD'] = true,
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['bibcode'] = true,
	['BIBCODE'] = true,
	['booktitle'] = true,
	['book-title'] = true,
	['callsign'] = true,			-- cite interview
	['call-sign'] = true,			-- cite interview
	['cartography'] = true,
	['chapter'] = true,
	['chapter-format'] = true,
	['chapterurl'] = true,
	['chapter-url'] = true,
	['city'] = true,				-- cite interview, cite episode, cite serial
	['class'] = true,				-- cite arxiv and arxiv identifiers
	['coauthor'] = false,			-- deprecated
	['coauthors'] = false,			-- deprecated
	['collaboration'] = true,
	['conference'] = true,
	['conference-format'] = true,
	['conferenceurl'] = true,
	['conference-url'] = true,
	['contribution'] = true,
	['contribution-format'] = true,
	['contributionurl'] = true,
	['contribution-url'] = true,
	['contributor'] = true,
	['contributor-first'] = true,
	['contributor-last'] = true,
	['contributor-link'] = true,
	['contributor-mask'] = true,
	['credits'] = true,				-- cite episode, cite serial
	['date'] = true,
	['deadurl'] = true,
	['dead-url'] = true,
	['degree'] = true,
	['department'] = true,
	['df'] = true,
	['dictionary'] = true,
	['displayauthors'] = true,
	['display-authors'] = true,
	['displayeditors'] = true,
	['display-editors'] = true,
	['docket'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-broken'] = true,
	['doi_brokendate'] = true,
	['doi-broken-date'] = true,
	['doi_inactivedate'] = true,
	['doi-inactive-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['editor-first'] = true,
	['editor-given'] = true,
	['editor-last'] = true,
	['editorlink'] = true,
	['editor-link'] = true,
	['editormask'] = true,
	['editor-mask'] = true,
	['editors'] = true,
	['editor-surname'] = true,
	['eissn'] = true,
	['EISSN'] = true,
	['embargo'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['entry'] = true,
	['episode'] = true,															-- cite serial only TODO: make available to cite episode?
	['episodelink'] = true,														-- cite episode and cite serial
	['episode-link'] = true,													-- cite episode and cite serial
	['eprint'] = true,															-- cite arxiv and arxiv identifiers
	['event'] = true,
	['event-format'] = true,
	['eventurl'] = true,
	['event-url'] = true,
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['hdl'] = true,
	['HDL'] = true,
	['host'] = true,
	['id'] = true,
	['ID'] = true,
	['ignoreisbnerror'] = true,
	['ignore-isbn-error'] = true,
	['in'] = true,
	['inset'] = true,
	['institution'] = true,
	['interviewer'] = true,				--cite interview
	['interviewers'] = true,			--cite interview
	['isbn'] = true,
	['ISBN'] = true,
	['isbn13'] = true,
	['ISBN13'] = true,
	['ismn'] = true,
	['ISMN'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['laydate'] = true,
	['lay-date'] = true,
	['laysource'] = true,
	['lay-source'] = true,
	['laysummary'] = true,
	['lay-summary'] = true,
	['lay-format'] = true,
	['layurl'] = true,
	['lay-url'] = true,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['magazine'] = true,
	['mailinglist'] = true,				-- cite mailing list only
	['mailing-list'] = true,			-- cite mailing list only
	['map'] = true,						-- cite map only
	['map-format'] = true,				-- cite map only
	['mapurl'] = true,					-- cite map only
	['map-url'] = true,					-- cite map only
	['medium'] = true,
	['message-id'] = true,			-- cite newsgroup
	['minutes'] = true,
	['mode'] = true,
	['mr'] = true,
	['MR'] = true,
	['name-list-format'] = true,
	['network'] = true,
	['newsgroup'] = true,
	['newspaper'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['nopp'] = true,
	['no-pp'] = true,
	['notracking'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['people'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['program'] = true,				-- cite interview
	['publicationdate'] = true,
	['publication-date'] = true,
	['publicationplace'] = true,
	['publication-place'] = true,
	['publisher'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['registration'] = true,
	['rfc'] = true,
	['RFC'] = true,
	['scale'] = true,
	['script-chapter'] = true,
	['script-title'] = true,
	['season'] = true,
	['section'] = true,
	['section-format'] = true,
	['sections'] = true,					-- cite map only
	['sectionurl'] = true,
	['section-url'] = true,
	['series'] = true,
	['serieslink'] = true,
	['series-link'] = true,
	['seriesno'] = true,
	['series-no'] = true,
	['seriesnumber'] = true,
	['series-number'] = true,
	['series-separator'] = true,
	['sheet'] = true,															-- cite map only
	['sheets'] = true,															-- cite map only
	['ssrn'] = true,
	['SSRN'] = true,
	['station'] = true,
	['subject'] = true,
	['subjectlink'] = true,
	['subject-link'] = true,
	['subscription'] = true,
	['surname'] = true,
	['template doc demo'] = true,
	['template-doc-demo'] = true,
	['time'] = true,
	['timecaption'] = true,
	['time-caption'] = true,
	['title'] = true,
	['titlelink'] = true,
	['title-link'] = true,
	['trans_chapter'] = true,
	['trans-chapter'] = true,
	['trans-map'] = true,
	['transcript'] = true,
	['transcript-format'] = true,
	['transcripturl'] = true,
	['transcript-url'] = true,
	['trans_title'] = true,
	['trans-title'] = true,
	['translator'] = true,
	['translator-first'] = true,
	['translator-last'] = true,
	['translator-link'] = true,
	['translator-mask'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['vauthors'] = true,
	['veditors'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
}

local numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['contributor#'] = true,
	['contributor-first#'] = true,
	['contributor#-first'] = true,
	['contributor-last#'] = true,
	['contributor#-last'] = true,
	['contributor-link#'] = true,
	['contributor#-link'] = true,
	['contributor-mask#'] = true,
	['contributor#-mask'] = true,
	['editor#'] = true,
	['editor-first#'] = true,
	['editor#-first'] = true,
	['editor#-given'] = true,
	['editor-given#'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-link#'] = true,
	['editor#link'] = true,
	['editor#-link'] = true,
	['editorlink#'] = true,
	['editor-mask#'] = true,
	['editor#mask'] = true,
	['editor#-mask'] = true,
	['editormask#'] = true,
	['editor#-surname'] = true,
	['editor-surname#'] = true,
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-link#'] = true,
	['subject#link'] = true,
	['subject#-link'] = true,
	['subjectlink#'] = true,
	['surname#'] = true,
	['translator#'] = true,
	['translator-first#'] = true,
	['translator#-first'] = true,
	['translator-last#'] = true,
	['translator#-last'] = true,
	['translator-link#'] = true,
	['translator#-link'] = true,
	['translator-mask#'] = true,
	['translator#-mask'] = true,
}

return {basic_arguments = basic_arguments, numbered_arguments = numbered_arguments};</text>
      <sha1>hil32i44qxogi4kjmudrlaz4wz0kg92</sha1>
    </revision>
    <revision>
      <id>4790</id>
      <parentid>4789</parentid>
      <timestamp>2016-04-16T10:34:23Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <minor />
      <comment>Synch from sandbox;</comment>
      <origin>4790</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="12373" sha1="5uh96bltatusih49sarlgsae9tuxbwd" xml:space="preserve">
--[[--------------------------&lt; P A R A M E T E R S   N O T   S U P P O R T E D &gt;------------------------------

This is a list of parameters that once were but now are no longer supported:

	['albumlink'] = nil,			-- unique alias of titlelink used by old cite AV media notes
	['albumtype'] = nil,			-- controled inappropriate functionality in the old cite AV media notes
	['artist'] = nil,				-- unique alias of others used by old cite AV media notes
	['Author'] = nil,				-- non-standard capitalization
	['authorformat'] = nil,			-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-format'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-name-separator'] = nil,-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-separator'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['began'] = nil,				-- module handles date ranges; cite episode and cite series
	['chapterlink'] = nil,			-- if ever necessary to link to a chapter article, |chapter= can be wikilinked 
	['chapter-link'] = nil,			-- 
	['cointerviewers'] = nil,		-- unique alias of others used by old cite interview
	['day'] = nil,					-- deprecated in {{citation/core}} and somehow undeprecated in Module:Citation/CS1 and now finally removed
	['director'] = nil,				-- unique alias of author used by old cite DVD-notes
	['DoiBroken'] = nil,			-- not used, non-standard captialization
	['Editor'] = nil,				-- non-standard capitalization
	['editorformat'] = nil,			-- primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorSurname'] = nil,		-- non-standard capitalization
	['editor-format'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorGiven'] = nil,			-- non-standard capitalization
	['editor-name-separator'] = nil,-- primarily used to support Vancouver format which functionality now part of name-list-format
	['editor-separator'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['Embargo'] = nil,				-- not used, non-standard capitalization
	['ended'] = nil,				-- module handles date ranges; cite episode and cite series
	['month'] = nil,				-- functionality supported by |date=
	['name-separator'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['notestitle'] = nil,			-- unique alias of chapter used by old cite AV media notes
	['PPrefix'] = nil,				-- non-standard capitalization
	['PPPrefix'] = nil,				-- not used, non-standard capitalization
	['pp-prefix'] = nil,			-- not used, not documented
	['p-prefix'] = nil,				-- not used, not documented
	['publisherid'] = nil,			-- unique alias of id used by old cite AV media notes and old cite DVD-notes
	['Ref'] = nil,					-- non-standard capitalization
	['separator'] = nil,			-- this functionality now provided by |mode=
	['titleyear'] = nil,			-- unique alias of origyear used by old cite DVD-notes

	['Author#'] = nil,				-- non-standard capitalization
	['authors#'] = nil,				-- no need for multiple lists of author names
	['Editor#'] = nil,				-- non-standard capitalization
	['editors#'] = nil,				-- no need for multiple lists of editor names
	['EditorGiven#'] = nil,			-- non-standard capitalization
	['EditorSurname#'] = nil,		-- non-standard capitalization

]]

--[[--------------------------&lt; S U P P O R T E D   P A R A M E T E R S &gt;--------------------------------------

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local whitelist = {}

local basic_arguments = {
	['accessdate'] = true,
	['access-date'] = true,
	['agency'] = true,
	['airdate'] = true,
	['air-date'] = true,
	['archivedate'] = true,
	['archive-date'] = true,
	['archive-format'] = true,
	['archiveurl'] = true,
	['archive-url'] = true,
	['article'] = true,
	['arxiv'] = true,
	['ARXIV'] = true,
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['ASIN-TLD'] = true,
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['bibcode'] = true,
	['BIBCODE'] = true,
	['booktitle'] = true,
	['book-title'] = true,
	['callsign'] = true,			-- cite interview
	['call-sign'] = true,			-- cite interview
	['cartography'] = true,
	['chapter'] = true,
	['chapter-format'] = true,
	['chapterurl'] = true,
	['chapter-url'] = true,
	['city'] = true,				-- cite interview
	['class'] = true,				-- cite arxiv and arxiv identifiers
	['coauthor'] = false,			-- deprecated
	['coauthors'] = false,			-- deprecated
	['collaboration'] = true,
	['conference'] = true,
	['conference-format'] = true,
	['conferenceurl'] = true,
	['conference-url'] = true,
	['contribution'] = true,
	['contribution-format'] = true,
	['contributionurl'] = true,
	['contribution-url'] = true,
	['contributor'] = true,
	['contributor-first'] = true,
	['contributor-last'] = true,
	['contributor-link'] = true,
	['contributor-mask'] = true,
	['credits'] = true,				-- cite episode, cite serial
	['date'] = true,
	['deadurl'] = true,
	['dead-url'] = true,
	['degree'] = true,
	['department'] = true,
	['df'] = true,
	['dictionary'] = true,
	['displayauthors'] = true,
	['display-authors'] = true,
	['displayeditors'] = true,
	['display-editors'] = true,
	['docket'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-broken'] = true,
	['doi_brokendate'] = true,
	['doi-broken-date'] = true,
	['doi_inactivedate'] = true,
	['doi-inactive-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['editor-first'] = true,
	['editor-given'] = true,
	['editor-last'] = true,
	['editorlink'] = true,
	['editor-link'] = true,
	['editormask'] = true,
	['editor-mask'] = true,
	['editors'] = true,
	['editor-surname'] = true,
	['eissn'] = true,
	['EISSN'] = true,
	['embargo'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['entry'] = true,
	['episode'] = true,															-- cite serial only TODO: make available to cite episode?
	['episodelink'] = true,														-- cite episode and cite serial
	['episode-link'] = true,													-- cite episode and cite serial
	['eprint'] = true,															-- cite arxiv and arxiv identifiers
	['event'] = true,
	['event-format'] = true,
	['eventurl'] = true,
	['event-url'] = true,
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['hdl'] = true,
	['HDL'] = true,
	['host'] = true,
	['id'] = true,
	['ID'] = true,
	['ignoreisbnerror'] = true,
	['ignore-isbn-error'] = true,
	['in'] = true,
	['inset'] = true,
	['institution'] = true,
	['interviewer'] = true,				--cite interview
	['interviewers'] = true,			--cite interview
	['isbn'] = true,
	['ISBN'] = true,
	['isbn13'] = true,
	['ISBN13'] = true,
	['ismn'] = true,
	['ISMN'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['laydate'] = true,
	['lay-date'] = true,
	['laysource'] = true,
	['lay-source'] = true,
	['laysummary'] = true,
	['lay-summary'] = true,
	['lay-format'] = true,
	['layurl'] = true,
	['lay-url'] = true,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['magazine'] = true,
	['mailinglist'] = true,				-- cite mailing list only
	['mailing-list'] = true,			-- cite mailing list only
	['map'] = true,						-- cite map only
	['map-format'] = true,				-- cite map only
	['mapurl'] = true,					-- cite map only
	['map-url'] = true,					-- cite map only
	['medium'] = true,
	['message-id'] = true,			-- cite newsgroup
	['minutes'] = true,
	['mode'] = true,
	['mr'] = true,
	['MR'] = true,
	['name-list-format'] = true,
	['network'] = true,
	['newsgroup'] = true,
	['newspaper'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['nopp'] = true,
	['no-pp'] = true,
	['notracking'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['people'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['program'] = true,				-- cite interview
	['publicationdate'] = true,
	['publication-date'] = true,
	['publicationplace'] = true,
	['publication-place'] = true,
	['publisher'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['registration'] = true,
	['rfc'] = true,
	['RFC'] = true,
	['scale'] = true,
	['script-chapter'] = true,
	['script-title'] = true,
	['season'] = true,
	['section'] = true,
	['section-format'] = true,
	['sections'] = true,					-- cite map only
	['sectionurl'] = true,
	['section-url'] = true,
	['series'] = true,
	['serieslink'] = true,
	['series-link'] = true,
	['seriesno'] = true,
	['series-no'] = true,
	['seriesnumber'] = true,
	['series-number'] = true,
	['series-separator'] = true,
	['sheet'] = true,															-- cite map only
	['sheets'] = true,															-- cite map only
	['ssrn'] = true,
	['SSRN'] = true,
	['station'] = true,
	['subject'] = true,
	['subjectlink'] = true,
	['subject-link'] = true,
	['subscription'] = true,
	['surname'] = true,
	['template doc demo'] = true,
	['template-doc-demo'] = true,
	['time'] = true,
	['timecaption'] = true,
	['time-caption'] = true,
	['title'] = true,
	['titlelink'] = true,
	['title-link'] = true,
	['trans_chapter'] = true,
	['trans-chapter'] = true,
	['trans-map'] = true,
	['transcript'] = true,
	['transcript-format'] = true,
	['transcripturl'] = true,
	['transcript-url'] = true,
	['trans_title'] = true,
	['trans-title'] = true,
	['translator'] = true,
	['translator-first'] = true,
	['translator-last'] = true,
	['translator-link'] = true,
	['translator-mask'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['vauthors'] = true,
	['veditors'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
}

local numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['contributor#'] = true,
	['contributor-first#'] = true,
	['contributor#-first'] = true,
	['contributor-last#'] = true,
	['contributor#-last'] = true,
	['contributor-link#'] = true,
	['contributor#-link'] = true,
	['contributor-mask#'] = true,
	['contributor#-mask'] = true,
	['editor#'] = true,
	['editor-first#'] = true,
	['editor#-first'] = true,
	['editor#-given'] = true,
	['editor-given#'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-link#'] = true,
	['editor#link'] = true,
	['editor#-link'] = true,
	['editorlink#'] = true,
	['editor-mask#'] = true,
	['editor#mask'] = true,
	['editor#-mask'] = true,
	['editormask#'] = true,
	['editor#-surname'] = true,
	['editor-surname#'] = true,
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-link#'] = true,
	['subject#link'] = true,
	['subject#-link'] = true,
	['subjectlink#'] = true,
	['surname#'] = true,
	['translator#'] = true,
	['translator-first#'] = true,
	['translator#-first'] = true,
	['translator-last#'] = true,
	['translator#-last'] = true,
	['translator-link#'] = true,
	['translator#-link'] = true,
	['translator-mask#'] = true,
	['translator#-mask'] = true,
}

return {basic_arguments = basic_arguments, numbered_arguments = numbered_arguments};</text>
      <sha1>5uh96bltatusih49sarlgsae9tuxbwd</sha1>
    </revision>
    <revision>
      <id>4791</id>
      <parentid>4790</parentid>
      <timestamp>2016-07-30T09:55:12Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4791</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="12759" sha1="3dxkwg54ldou02i30abjjm902uaobfv" xml:space="preserve">
--[[--------------------------&lt; P A R A M E T E R S   N O T   S U P P O R T E D &gt;------------------------------

This is a list of parameters that once were but now are no longer supported:

	['albumlink'] = nil,			-- unique alias of titlelink used by old cite AV media notes
	['albumtype'] = nil,			-- controled inappropriate functionality in the old cite AV media notes
	['artist'] = nil,				-- unique alias of others used by old cite AV media notes
	['Author'] = nil,				-- non-standard capitalization
	['authorformat'] = nil,			-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-format'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-name-separator'] = nil,-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-separator'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['began'] = nil,				-- module handles date ranges; cite episode and cite series
	['chapterlink'] = nil,			-- if ever necessary to link to a chapter article, |chapter= can be wikilinked 
	['chapter-link'] = nil,			-- 
	['cointerviewers'] = nil,		-- unique alias of others used by old cite interview
	['day'] = nil,					-- deprecated in {{citation/core}} and somehow undeprecated in Module:Citation/CS1 and now finally removed
	['director'] = nil,				-- unique alias of author used by old cite DVD-notes
	['DoiBroken'] = nil,			-- not used, non-standard captialization
	['Editor'] = nil,				-- non-standard capitalization
	['editorformat'] = nil,			-- primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorSurname'] = nil,		-- non-standard capitalization
	['editor-format'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorGiven'] = nil,			-- non-standard capitalization
	['editor-name-separator'] = nil,-- primarily used to support Vancouver format which functionality now part of name-list-format
	['editor-separator'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['Embargo'] = nil,				-- not used, non-standard capitalization
	['ended'] = nil,				-- module handles date ranges; cite episode and cite series
	['month'] = nil,				-- functionality supported by |date=
	['name-separator'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['notestitle'] = nil,			-- unique alias of chapter used by old cite AV media notes
	['PPrefix'] = nil,				-- non-standard capitalization
	['PPPrefix'] = nil,				-- not used, non-standard capitalization
	['pp-prefix'] = nil,			-- not used, not documented
	['p-prefix'] = nil,				-- not used, not documented
	['publisherid'] = nil,			-- unique alias of id used by old cite AV media notes and old cite DVD-notes
	['Ref'] = nil,					-- non-standard capitalization
	['separator'] = nil,			-- this functionality now provided by |mode=
	['titleyear'] = nil,			-- unique alias of origyear used by old cite DVD-notes

	['Author#'] = nil,				-- non-standard capitalization
	['authors#'] = nil,				-- no need for multiple lists of author names
	['Editor#'] = nil,				-- non-standard capitalization
	['editors#'] = nil,				-- no need for multiple lists of editor names
	['EditorGiven#'] = nil,			-- non-standard capitalization
	['EditorSurname#'] = nil,		-- non-standard capitalization

]]

--[[--------------------------&lt; S U P P O R T E D   P A R A M E T E R S &gt;--------------------------------------

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local whitelist = {}

local basic_arguments = {
	['accessdate'] = true,
	['access-date'] = true,
	['agency'] = true,
	['airdate'] = true,
	['air-date'] = true,
	['archivedate'] = true,
	['archive-date'] = true,
	['archive-format'] = true,
	['archiveurl'] = true,
	['archive-url'] = true,
	['article'] = true,
	['arxiv'] = true,
	['ARXIV'] = true,
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['ASIN-TLD'] = true,
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['bibcode'] = true,
	['BIBCODE'] = true,
	['booktitle'] = true,
	['book-title'] = true,
	['callsign'] = true,			-- cite interview
	['call-sign'] = true,			-- cite interview
	['cartography'] = true,
	['chapter'] = true,
	['chapter-format'] = true,
	['chapterurl'] = true,
	['chapter-url'] = true,
	['city'] = true,				-- cite interview
	['class'] = true,				-- cite arxiv and arxiv identifiers
	['coauthor'] = false,			-- deprecated
	['coauthors'] = false,			-- deprecated
	['collaboration'] = true,
	['conference'] = true,
	['conference-format'] = true,
	['conferenceurl'] = true,
	['conference-url'] = true,
	['contribution'] = true,
	['contribution-format'] = true,
	['contributionurl'] = true,
	['contribution-url'] = true,
	['contributor'] = true,
	['contributor-first'] = true,
	['contributor-last'] = true,
	['contributor-given'] = true,
	['contributor-surname'] = true,
	['contributor-link'] = true,
	['contributor-mask'] = true,
	['credits'] = true,				-- cite episode, cite serial
	['date'] = true,
	['deadurl'] = true,
	['dead-url'] = true,
	['degree'] = true,
	['department'] = true,
	['df'] = true,
	['dictionary'] = true,
	['displayauthors'] = true,
	['display-authors'] = true,
	['displayeditors'] = true,
	['display-editors'] = true,
	['docket'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-broken'] = true,
	['doi_brokendate'] = true,
	['doi-broken-date'] = true,
	['doi_inactivedate'] = true,
	['doi-inactive-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['editor-first'] = true,
	['editor-given'] = true,
	['editor-last'] = true,
	['editorlink'] = true,
	['editor-link'] = true,
	['editormask'] = true,
	['editor-mask'] = true,
	['editors'] = true,
	['editor-surname'] = true,
	['eissn'] = true,
	['EISSN'] = true,
	['embargo'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['entry'] = true,
	['episode'] = true,															-- cite serial only TODO: make available to cite episode?
	['episodelink'] = true,														-- cite episode and cite serial
	['episode-link'] = true,													-- cite episode and cite serial
	['eprint'] = true,															-- cite arxiv and arxiv identifiers
	['event'] = true,
	['event-format'] = true,
	['eventurl'] = true,
	['event-url'] = true,
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['hdl'] = true,
	['HDL'] = true,
	['host'] = true,
	['id'] = true,
	['ID'] = true,
	['ignoreisbnerror'] = true,
	['ignore-isbn-error'] = true,
	['in'] = true,
	['inset'] = true,
	['institution'] = true,
	['interviewer'] = true,				--cite interview
	['interviewers'] = true,			--cite interview
	['isbn'] = true,
	['ISBN'] = true,
	['isbn13'] = true,
	['ISBN13'] = true,
	['ismn'] = true,
	['ISMN'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['laydate'] = true,
	['lay-date'] = true,
	['laysource'] = true,
	['lay-source'] = true,
	['laysummary'] = true,
	['lay-summary'] = true,
	['lay-format'] = true,
	['layurl'] = true,
	['lay-url'] = true,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['magazine'] = true,
	['mailinglist'] = true,				-- cite mailing list only
	['mailing-list'] = true,			-- cite mailing list only
	['map'] = true,						-- cite map only
	['map-format'] = true,				-- cite map only
	['mapurl'] = true,					-- cite map only
	['map-url'] = true,					-- cite map only
	['medium'] = true,
	['message-id'] = true,			-- cite newsgroup
	['minutes'] = true,
	['mode'] = true,
	['mr'] = true,
	['MR'] = true,
	['name-list-format'] = true,
	['network'] = true,
	['newsgroup'] = true,
	['newspaper'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['nopp'] = true,
	['no-pp'] = true,
	['notracking'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['people'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['program'] = true,				-- cite interview
	['publicationdate'] = true,
	['publication-date'] = true,
	['publicationplace'] = true,
	['publication-place'] = true,
	['publisher'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['registration'] = true,
	['rfc'] = true,
	['RFC'] = true,
	['scale'] = true,
	['script-chapter'] = true,
	['script-title'] = true,
	['season'] = true,
	['section'] = true,
	['section-format'] = true,
	['sections'] = true,					-- cite map only
	['sectionurl'] = true,
	['section-url'] = true,
	['series'] = true,
	['serieslink'] = true,
	['series-link'] = true,
	['seriesno'] = true,
	['series-no'] = true,
	['seriesnumber'] = true,
	['series-number'] = true,
	['series-separator'] = true,
	['sheet'] = true,															-- cite map only
	['sheets'] = true,															-- cite map only
	['ssrn'] = true,
	['SSRN'] = true,
	['station'] = true,
	['subject'] = true,
	['subjectlink'] = true,
	['subject-link'] = true,
	['subscription'] = true,
	['surname'] = true,
	['template doc demo'] = true,
	['template-doc-demo'] = true,
	['time'] = true,
	['timecaption'] = true,
	['time-caption'] = true,
	['title'] = true,
	['titlelink'] = true,
	['title-link'] = true,
	['trans_chapter'] = true,
	['trans-chapter'] = true,
	['trans-map'] = true,
	['transcript'] = true,
	['transcript-format'] = true,
	['transcripturl'] = true,
	['transcript-url'] = true,
	['trans_title'] = true,
	['trans-title'] = true,
	['translator'] = true,
	['translator-first'] = true,
	['translator-last'] = true,
	['translator-given'] = true,
	['translator-surname'] = true,
	['translator-link'] = true,
	['translator-mask'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['vauthors'] = true,
	['veditors'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
}

local numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['contributor#'] = true,
	['contributor-first#'] = true,
	['contributor#-first'] = true,
	['contributor-last#'] = true,
	['contributor#-last'] = true,
	['contributor-given#'] = true,
	['contributor#-given'] = true,
	['contributor-surname#'] = true,
	['contributor#-surname'] = true,
	['contributor-link#'] = true,
	['contributor#-link'] = true,
	['contributor-mask#'] = true,
	['contributor#-mask'] = true,
	['editor#'] = true,
	['editor-first#'] = true,
	['editor#-first'] = true,
	['editor#-given'] = true,
	['editor-given#'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-link#'] = true,
	['editor#link'] = true,
	['editor#-link'] = true,
	['editorlink#'] = true,
	['editor-mask#'] = true,
	['editor#mask'] = true,
	['editor#-mask'] = true,
	['editormask#'] = true,
	['editor#-surname'] = true,
	['editor-surname#'] = true,
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-link#'] = true,
	['subject#link'] = true,
	['subject#-link'] = true,
	['subjectlink#'] = true,
	['surname#'] = true,
	['translator#'] = true,
	['translator-first#'] = true,
	['translator#-first'] = true,
	['translator-last#'] = true,
	['translator#-last'] = true,
	['translator-given#'] = true,
	['translator#-given'] = true,
	['translator-surname#'] = true,
	['translator#-surname'] = true,
	['translator-link#'] = true,
	['translator#-link'] = true,
	['translator-mask#'] = true,
	['translator#-mask'] = true,
}

return {basic_arguments = basic_arguments, numbered_arguments = numbered_arguments};</text>
      <sha1>3dxkwg54ldou02i30abjjm902uaobfv</sha1>
    </revision>
    <revision>
      <id>4792</id>
      <parentid>4791</parentid>
      <timestamp>2016-10-29T08:52:14Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4792</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="13068" sha1="n59xxud2d1brcq5ya8hp0cudlbtw3ex" xml:space="preserve">
--[[--------------------------&lt; P A R A M E T E R S   N O T   S U P P O R T E D &gt;------------------------------

This is a list of parameters that once were but now are no longer supported:

	['albumlink'] = nil,			-- unique alias of titlelink used by old cite AV media notes
	['albumtype'] = nil,			-- controled inappropriate functionality in the old cite AV media notes
	['artist'] = nil,				-- unique alias of others used by old cite AV media notes
	['Author'] = nil,				-- non-standard capitalization
	['authorformat'] = nil,			-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-format'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-name-separator'] = nil,-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-separator'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['began'] = nil,				-- module handles date ranges; cite episode and cite series
	['chapterlink'] = nil,			-- if ever necessary to link to a chapter article, |chapter= can be wikilinked 
	['chapter-link'] = nil,			-- 
	['cointerviewers'] = nil,		-- unique alias of others used by old cite interview
	['day'] = nil,					-- deprecated in {{citation/core}} and somehow undeprecated in Module:Citation/CS1 and now finally removed
	['director'] = nil,				-- unique alias of author used by old cite DVD-notes
	['DoiBroken'] = nil,			-- not used, non-standard captialization
	['Editor'] = nil,				-- non-standard capitalization
	['editorformat'] = nil,			-- primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorSurname'] = nil,		-- non-standard capitalization
	['editor-format'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorGiven'] = nil,			-- non-standard capitalization
	['editor-name-separator'] = nil,-- primarily used to support Vancouver format which functionality now part of name-list-format
	['editor-separator'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['Embargo'] = nil,				-- not used, non-standard capitalization
	['ended'] = nil,				-- module handles date ranges; cite episode and cite series
	['month'] = nil,				-- functionality supported by |date=
	['name-separator'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['notestitle'] = nil,			-- unique alias of chapter used by old cite AV media notes
	['PPrefix'] = nil,				-- non-standard capitalization
	['PPPrefix'] = nil,				-- not used, non-standard capitalization
	['pp-prefix'] = nil,			-- not used, not documented
	['p-prefix'] = nil,				-- not used, not documented
	['publisherid'] = nil,			-- unique alias of id used by old cite AV media notes and old cite DVD-notes
	['Ref'] = nil,					-- non-standard capitalization
	['separator'] = nil,			-- this functionality now provided by |mode=
	['titleyear'] = nil,			-- unique alias of origyear used by old cite DVD-notes

	['Author#'] = nil,				-- non-standard capitalization
	['authors#'] = nil,				-- no need for multiple lists of author names
	['Editor#'] = nil,				-- non-standard capitalization
	['editors#'] = nil,				-- no need for multiple lists of editor names
	['EditorGiven#'] = nil,			-- non-standard capitalization
	['EditorSurname#'] = nil,		-- non-standard capitalization

]]

--[[--------------------------&lt; S U P P O R T E D   P A R A M E T E R S &gt;--------------------------------------

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local whitelist = {}

local basic_arguments = {
	['accessdate'] = true,
	['access-date'] = true,
	['agency'] = true,
	['airdate'] = true,
	['air-date'] = true,
	['archivedate'] = true,
	['archive-date'] = true,
	['archive-format'] = true,
	['archiveurl'] = true,
	['archive-url'] = true,
	['article'] = true,
	['arxiv'] = true,
	['ARXIV'] = false,
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['ASIN-TLD'] = true,
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['bibcode'] = true,
	['BIBCODE'] = false,
	['bibcode-access'] = true,
	['biorxiv'] = true,
	['booktitle'] = true,
	['book-title'] = true,
	['callsign'] = false,			-- cite interview
	['call-sign'] = false,			-- cite interview
	['cartography'] = true,
	['chapter'] = true,
	['chapter-format'] = true,
	['chapterurl'] = true,
	['chapter-url'] = true,
	['citeseerx'] = true,
	['city'] = false,				-- cite interview
	['class'] = true,				-- cite arxiv and arxiv identifiers
	['coauthor'] = false,			-- deprecated
	['coauthors'] = false,			-- deprecated
	['collaboration'] = true,
	['conference'] = true,
	['conference-format'] = true,
	['conferenceurl'] = true,
	['conference-url'] = true,
	['contribution'] = true,
	['contribution-format'] = true,
	['contributionurl'] = true,
	['contribution-url'] = true,
	['contributor'] = true,
	['contributor-first'] = true,
	['contributor-last'] = true,
	['contributor-given'] = true,
	['contributor-surname'] = true,
	['contributor-link'] = true,
	['contributor-mask'] = true,
	['credits'] = true,				-- cite episode, cite serial
	['date'] = true,
	['deadurl'] = true,
	['dead-url'] = true,
	['degree'] = true,
	['department'] = true,
	['df'] = true,
	['dictionary'] = true,
	['displayauthors'] = true,
	['display-authors'] = true,
	['displayeditors'] = true,
	['display-editors'] = true,
	['docket'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-access'] = true,
	['doi-broken'] = true,
	['doi_brokendate'] = true,					-- @TODO deprecate underscore version?
	['doi-broken-date'] = true,
	['doi_inactivedate'] = true,				-- @TODO deprecate underscore version?
	['doi-inactive-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['editor-first'] = true,
	['editor-given'] = true,
	['editor-last'] = true,
	['editorlink'] = true,
	['editor-link'] = true,
	['editormask'] = true,
	['editor-mask'] = true,
	['editors'] = true,
	['editor-surname'] = true,
	['eissn'] = true,
	['EISSN'] = true,
	['embargo'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['entry'] = true,
	['episode'] = true,															-- cite serial only TODO: make available to cite episode?
	['episodelink'] = true,														-- cite episode and cite serial
	['episode-link'] = true,													-- cite episode and cite serial
	['eprint'] = true,															-- cite arxiv and arxiv identifiers
	['event'] = true,
	['event-format'] = true,
	['eventurl'] = true,
	['event-url'] = true,
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['hdl'] = true,
	['HDL'] = true,
	['hdl-access'] = true,
	['host'] = true,
	['id'] = true,
	['ID'] = true,
	['ignoreisbnerror'] = true,
	['ignore-isbn-error'] = true,
	['in'] = true,
	['inset'] = true,
	['institution'] = true,
	['interviewer'] = true,				--cite interview
	['interviewers'] = true,			--cite interview
	['isbn'] = true,
	['ISBN'] = true,
	['isbn13'] = true,
	['ISBN13'] = true,
	['ismn'] = true,
	['ISMN'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['jstor-access'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['laydate'] = true,
	['lay-date'] = true,
	['laysource'] = true,
	['lay-source'] = true,
	['laysummary'] = true,
	['lay-summary'] = true,
	['lay-format'] = true,
	['layurl'] = true,
	['lay-url'] = true,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['magazine'] = true,
	['mailinglist'] = true,				-- cite mailing list only
	['mailing-list'] = true,			-- cite mailing list only
	['map'] = true,						-- cite map only
	['map-format'] = true,				-- cite map only
	['mapurl'] = true,					-- cite map only
	['map-url'] = true,					-- cite map only
	['medium'] = true,
	['message-id'] = true,			-- cite newsgroup
	['minutes'] = true,
	['mode'] = true,
	['mr'] = true,
	['MR'] = true,
	['name-list-format'] = true,
	['network'] = true,
	['newsgroup'] = true,
	['newspaper'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['nopp'] = true,
	['no-pp'] = true,
	['notracking'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['ol-access'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['osti-access'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['people'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['program'] = false,				-- cite interview
	['publicationdate'] = true,
	['publication-date'] = true,
	['publicationplace'] = true,
	['publication-place'] = true,
	['publisher'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['registration'] = true,
	['rfc'] = true,
	['RFC'] = true,
	['scale'] = true,
	['script-chapter'] = true,
	['script-title'] = true,
	['season'] = true,
	['section'] = true,
	['section-format'] = true,
	['sections'] = true,					-- cite map only
	['sectionurl'] = true,
	['section-url'] = true,
	['series'] = true,
	['serieslink'] = true,
	['series-link'] = true,
	['seriesno'] = true,
	['series-no'] = true,
	['seriesnumber'] = true,
	['series-number'] = true,
	['series-separator'] = true,
	['sheet'] = true,															-- cite map only
	['sheets'] = true,															-- cite map only
	['ssrn'] = true,
	['SSRN'] = true,
	['station'] = true,
	['subject'] = true,
	['subjectlink'] = true,
	['subject-link'] = true,
	['subscription'] = true,
	['surname'] = true,
	['template doc demo'] = true,
	['template-doc-demo'] = true,
	['time'] = true,
	['timecaption'] = true,
	['time-caption'] = true,
	['title'] = true,
	['titlelink'] = true,
	['title-link'] = true,
	['trans_chapter'] = true,
	['trans-chapter'] = true,
	['trans-map'] = true,
	['transcript'] = true,
	['transcript-format'] = true,
	['transcripturl'] = true,
	['transcript-url'] = true,
	['trans_title'] = true,
	['trans-title'] = true,
	['translator'] = true,
	['translator-first'] = true,
	['translator-last'] = true,
	['translator-given'] = true,
	['translator-surname'] = true,
	['translator-link'] = true,
	['translator-mask'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['url-access'] = true,
	['vauthors'] = true,
	['veditors'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
}

local numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['contributor#'] = true,
	['contributor-first#'] = true,
	['contributor#-first'] = true,
	['contributor-last#'] = true,
	['contributor#-last'] = true,
	['contributor-given#'] = true,
	['contributor#-given'] = true,
	['contributor-surname#'] = true,
	['contributor#-surname'] = true,
	['contributor-link#'] = true,
	['contributor#-link'] = true,
	['contributor-mask#'] = true,
	['contributor#-mask'] = true,
	['editor#'] = true,
	['editor-first#'] = true,
	['editor#-first'] = true,
	['editor#-given'] = true,
	['editor-given#'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-link#'] = true,
	['editor#link'] = true,
	['editor#-link'] = true,
	['editorlink#'] = true,
	['editor-mask#'] = true,
	['editor#mask'] = true,
	['editor#-mask'] = true,
	['editormask#'] = true,
	['editor#-surname'] = true,
	['editor-surname#'] = true,
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-link#'] = true,
	['subject#link'] = true,
	['subject#-link'] = true,
	['subjectlink#'] = true,
	['surname#'] = true,
	['translator#'] = true,
	['translator-first#'] = true,
	['translator#-first'] = true,
	['translator-last#'] = true,
	['translator#-last'] = true,
	['translator-given#'] = true,
	['translator#-given'] = true,
	['translator-surname#'] = true,
	['translator#-surname'] = true,
	['translator-link#'] = true,
	['translator#-link'] = true,
	['translator-mask#'] = true,
	['translator#-mask'] = true,
}

return {basic_arguments = basic_arguments, numbered_arguments = numbered_arguments};</text>
      <sha1>n59xxud2d1brcq5ya8hp0cudlbtw3ex</sha1>
    </revision>
    <revision>
      <id>4793</id>
      <parentid>4792</parentid>
      <timestamp>2017-04-29T09:52:17Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>synch from sandbox;</comment>
      <origin>4793</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="18566" sha1="gcjlf3p7jfa7qv6jvtvzuhs7fk1qlbr" xml:space="preserve">
--[[--------------------------&lt; P A R A M E T E R S   N O T   S U P P O R T E D &gt;------------------------------

This is a list of parameters that once were but now are no longer supported:

	['albumlink'] = nil,			-- unique alias of titlelink used by old cite AV media notes
	['albumtype'] = nil,			-- controled inappropriate functionality in the old cite AV media notes
	['artist'] = nil,				-- unique alias of others used by old cite AV media notes
	['Author'] = nil,				-- non-standard capitalization
	['authorformat'] = nil,			-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-format'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-name-separator'] = nil,-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-separator'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['began'] = nil,				-- module handles date ranges; cite episode and cite series
	['callsign'] = nil,				-- cite interview removed
	['call-sign'] = nil,			-- cite interview removed
	['chapterlink'] = nil,			-- if ever necessary to link to a chapter article, |chapter= can be wikilinked 
	['chapter-link'] = nil,			-- 
	['city'] = nil,					-- cite interview removed
	['coauthor'] = nil,				-- redundant to |authorn=; not made part of metadata
	['coauthors'] = nil,			-- redundant to |authorn=; not made part of metadata
	['cointerviewers'] = nil,		-- unique alias of others used by old cite interview
	['day'] = nil,					-- deprecated in {{citation/core}} and somehow undeprecated in Module:Citation/CS1 and now finally removed
	['director'] = nil,				-- unique alias of author used by old cite DVD-notes
	['DoiBroken'] = nil,			-- not used, non-standard captialization
	['Editor'] = nil,				-- non-standard capitalization
	['editorformat'] = nil,			-- primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorSurname'] = nil,		-- non-standard capitalization
	['editor-format'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorGiven'] = nil,			-- non-standard capitalization
	['editor-name-separator'] = nil,-- primarily used to support Vancouver format which functionality now part of name-list-format
	['editor-separator'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['Embargo'] = nil,				-- not used, non-standard capitalization
	['ended'] = nil,				-- module handles date ranges; cite episode and cite series
	['month'] = nil,				-- functionality supported by |date=
	['name-separator'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['notestitle'] = nil,			-- unique alias of chapter used by old cite AV media notes
	['PPrefix'] = nil,				-- non-standard capitalization
	['PPPrefix'] = nil,				-- not used, non-standard capitalization
	['pp-prefix'] = nil,			-- not used, not documented
	['p-prefix'] = nil,				-- not used, not documented
	['program'] = nil,				-- cite interview removed
	['publisherid'] = nil,			-- unique alias of id used by old cite AV media notes and old cite DVD-notes
	['Ref'] = nil,					-- non-standard capitalization
	['separator'] = nil,			-- this functionality now provided by |mode=
	['titleyear'] = nil,			-- unique alias of origyear used by old cite DVD-notes

	['Author#'] = nil,				-- non-standard capitalization
	['authors#'] = nil,				-- no need for multiple lists of author names
	['Editor#'] = nil,				-- non-standard capitalization
	['editors#'] = nil,				-- no need for multiple lists of editor names
	['EditorGiven#'] = nil,			-- non-standard capitalization
	['EditorSurname#'] = nil,		-- non-standard capitalization

]]

--[[--------------------------&lt; S U P P O R T E D   P A R A M E T E R S &gt;--------------------------------------

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local whitelist = {}

local basic_arguments = {
	['accessdate'] = true,
	['access-date'] = true,
	['agency'] = true,
	['airdate'] = true,
	['air-date'] = true,
	['archivedate'] = true,
	['archive-date'] = true,
	['archive-format'] = true,
	['archiveurl'] = true,
	['archive-url'] = true,
	['article'] = true,
	['arxiv'] = true,
	['ARXIV'] = false,
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['ASIN-TLD'] = true,
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['bibcode'] = true,
	['BIBCODE'] = false,
	['bibcode-access'] = true,
	['biorxiv'] = true,
	['booktitle'] = true,
	['book-title'] = true,
	['cartography'] = true,
	['chapter'] = true,
	['chapter-format'] = true,
	['chapterurl'] = true,
	['chapter-url'] = true,
	['citeseerx'] = true,
	['class'] = true,				-- cite arxiv and arxiv identifiers
	['collaboration'] = true,
	['conference'] = true,
	['conference-format'] = true,
	['conferenceurl'] = true,
	['conference-url'] = true,
	['contribution'] = true,
	['contribution-format'] = true,
	['contributionurl'] = true,
	['contribution-url'] = true,
	['contributor'] = true,
	['contributor-first'] = true,
	['contributor-last'] = true,
	['contributor-given'] = true,
	['contributor-surname'] = true,
	['contributor-link'] = true,
	['contributor-mask'] = true,
	['credits'] = true,				-- cite episode, cite serial
	['date'] = true,
	['deadurl'] = true,
	['dead-url'] = true,
	['degree'] = true,
	['department'] = true,
	['df'] = true,
	['dictionary'] = true,
	['displayauthors'] = true,
	['display-authors'] = true,
	['displayeditors'] = true,
	['display-editors'] = true,
	['docket'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-access'] = true,
	['doi-broken'] = true,
	['doi_brokendate'] = true,					-- @TODO deprecate underscore version?
	['doi-broken-date'] = true,
	['doi_inactivedate'] = true,				-- @TODO deprecate underscore version?
	['doi-inactive-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['editor-first'] = true,
	['editor-given'] = true,
	['editor-last'] = true,
	['editorlink'] = true,
	['editor-link'] = true,
	['editormask'] = true,
	['editor-mask'] = true,
	['editors'] = true,
	['editor-surname'] = true,
	['eissn'] = true,
	['EISSN'] = true,
	['embargo'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['entry'] = true,
	['episode'] = true,															-- cite serial only TODO: make available to cite episode?
	['episodelink'] = true,														-- cite episode and cite serial
	['episode-link'] = true,													-- cite episode and cite serial
	['eprint'] = true,															-- cite arxiv and arxiv identifiers
	['event'] = true,
	['event-format'] = true,
	['eventurl'] = true,
	['event-url'] = true,
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['hdl'] = true,
	['HDL'] = true,
	['hdl-access'] = true,
	['host'] = true,
	['id'] = true,
	['ID'] = true,
	['ignoreisbnerror'] = true,
	['ignore-isbn-error'] = true,
	['in'] = true,
	['inset'] = true,
	['institution'] = true,
	['interviewer'] = true,
	['interviewer-first'] = true,
	['interviewer-last'] = true,
	['interviewerlink'] = true,
	['interviewer-link'] = true,
	['interviewermask'] = true,
	['interviewer-mask'] = true,
	['interviewers'] = true,
	['isbn'] = true,
	['ISBN'] = true,
	['isbn13'] = true,
	['ISBN13'] = true,
	['ismn'] = true,
	['ISMN'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['jstor-access'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['laydate'] = true,
	['lay-date'] = true,
	['laysource'] = true,
	['lay-source'] = true,
	['laysummary'] = true,
	['lay-summary'] = true,
	['lay-format'] = true,
	['layurl'] = true,
	['lay-url'] = true,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['magazine'] = true,
	['mailinglist'] = true,				-- cite mailing list only
	['mailing-list'] = true,			-- cite mailing list only
	['map'] = true,						-- cite map only
	['map-format'] = true,				-- cite map only
	['mapurl'] = true,					-- cite map only
	['map-url'] = true,					-- cite map only
	['medium'] = true,
	['message-id'] = true,			-- cite newsgroup
	['minutes'] = true,
	['mode'] = true,
	['mr'] = true,
	['MR'] = true,
	['name-list-format'] = true,
	['network'] = true,
	['newsgroup'] = true,
	['newspaper'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['nopp'] = true,
	['no-pp'] = true,
	['notracking'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['ol-access'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['osti-access'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['people'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['publicationdate'] = true,
	['publication-date'] = true,
	['publicationplace'] = true,
	['publication-place'] = true,
	['publisher'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['registration'] = true,
	['rfc'] = true,
	['RFC'] = true,
	['scale'] = true,
	['script-chapter'] = true,
	['script-title'] = true,
	['season'] = true,
	['section'] = true,
	['section-format'] = true,
	['sections'] = true,					-- cite map only
	['sectionurl'] = true,
	['section-url'] = true,
	['series'] = true,
	['serieslink'] = true,
	['series-link'] = true,
	['seriesno'] = true,
	['series-no'] = true,
	['seriesnumber'] = true,
	['series-number'] = true,
	['series-separator'] = true,
	['sheet'] = true,															-- cite map only
	['sheets'] = true,															-- cite map only
	['ssrn'] = true,
	['SSRN'] = true,
	['station'] = true,
	['subject'] = true,
	['subjectlink'] = true,
	['subject-link'] = true,
	['subscription'] = true,
	['surname'] = true,
	['template doc demo'] = true,
	['template-doc-demo'] = true,
	['time'] = true,
	['timecaption'] = true,
	['time-caption'] = true,
	['title'] = true,
	['titlelink'] = true,
	['title-link'] = true,
	['trans_chapter'] = true,
	['trans-chapter'] = true,
	['trans-map'] = true,
	['transcript'] = true,
	['transcript-format'] = true,
	['transcripturl'] = true,
	['transcript-url'] = true,
	['trans_title'] = true,
	['trans-title'] = true,
	['translator'] = true,
	['translator-first'] = true,
	['translator-last'] = true,
	['translator-given'] = true,
	['translator-surname'] = true,
	['translator-link'] = true,
	['translator-mask'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['url-access'] = true,
	['vauthors'] = true,
	['veditors'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
}

local numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['contributor#'] = true,
	['contributor-first#'] = true,
	['contributor#-first'] = true,
	['contributor-last#'] = true,
	['contributor#-last'] = true,
	['contributor-given#'] = true,
	['contributor#-given'] = true,
	['contributor-surname#'] = true,
	['contributor#-surname'] = true,
	['contributor-link#'] = true,
	['contributor#-link'] = true,
	['contributor-mask#'] = true,
	['contributor#-mask'] = true,
	['editor#'] = true,
	['editor-first#'] = true,
	['editor#-first'] = true,
	['editor#-given'] = true,
	['editor-given#'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-link#'] = true,
	['editor#link'] = true,
	['editor#-link'] = true,
	['editorlink#'] = true,
	['editor-mask#'] = true,
	['editor#mask'] = true,
	['editor#-mask'] = true,
	['editormask#'] = true,
	['editor#-surname'] = true,
	['editor-surname#'] = true,
	['first#'] = true,
	['given#'] = true,
	['interviewer#'] = true,
	['interviewer-first#'] = true,
	['interviewer#-first'] = true,
	['interviewer-last#'] = true,
	['interviewer#-last'] = true,
	['interviewer-link#'] = true,
	['interviewer#-link'] = true,
	['interviewer-mask#'] = true,
	['interviewer#-mask'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-link#'] = true,
	['subject#link'] = true,
	['subject#-link'] = true,
	['subjectlink#'] = true,
	['surname#'] = true,
	['translator#'] = true,
	['translator-first#'] = true,
	['translator#-first'] = true,
	['translator-last#'] = true,
	['translator#-last'] = true,
	['translator-given#'] = true,
	['translator#-given'] = true,
	['translator-surname#'] = true,
	['translator#-surname'] = true,
	['translator-link#'] = true,
	['translator#-link'] = true,
	['translator-mask#'] = true,
	['translator#-mask'] = true,
}

--[[--------------------------&lt; C I T E   A R X I V   S U P P O R T E D   P A R A M E T E R S &gt;----------------

This is an experiment that attempts to use validate() and a limited list of valid parameters to validate the
parameters provided in a cite arxiv template.  This method might be expanded to other templates being considered.

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local arxiv_basic_arguments = {
	['arxiv'] = true,
	['ARXIV'] = false,
	['class'] = true,															-- cite arxiv and arxiv identifiers
	['eprint'] = true,															-- cite arxiv and arxiv identifiers
	['version'] = false,
}


--[[--------------------------&lt; C I T E   B I O R X I V   S U P P O R T E D   P A R A M E T E R S &gt;------------

This is an experiment that attempts to use validate() and a limited list of valid parameters to validate the
parameters provided in a cite biorxiv template.  This method might be expanded to other templates being considered.

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local biorxiv_basic_arguments = {
	['biorxiv'] = true,
}


--[[--------------------------&lt; C I T E   C I T E S E E R X   S U P P O R T E D   P A R A M E T E R S &gt;--------

This is an experiment that attempts to use validate() and a limited list of valid parameters to validate the
parameters provided in a cite citeseerx template.  This method might be expanded to other templates being considered.

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local citeseerx_basic_arguments = {
	['citeseerx'] = true,
}


--[[--------------------------&lt; L I M I T E D   S U P P O R T E D   P A R A M E T E R S &gt;----------------------

This is an experiment that attempts to use validate() and a limited list of valid parameters to validate the
parameters provided in a cite arxiv, cite biorxiv, or cite citeseerx templates.  These parameters are common to
all three templates

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local limited_basic_arguments = {
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['collaboration'] = true,
	['date'] = true,
	['df'] = true,
	['display-authors'] = true,
	['first'] = true,
	['given'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['mode'] = true,
	['name-list-format'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['notracking'] = true,
	['no-tracking'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['postscript'] = true,
	['pp'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['surname'] = true,
	['template doc demo'] = true,
	['template-doc-demo'] = true,
	['title'] = true,
	['url'] = true,
	['URL'] = true,
	['vauthors'] = true,
	['year'] = true,
}
local limited_numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['surname#'] = true,
}

return {
	basic_arguments = basic_arguments,
	numbered_arguments = numbered_arguments,
	limited_basic_arguments = limited_basic_arguments,
	limited_numbered_arguments = limited_numbered_arguments,
	arxiv_basic_arguments = arxiv_basic_arguments,
	biorxiv_basic_arguments = biorxiv_basic_arguments,
	citeseerx_basic_arguments = citeseerx_basic_arguments
};</text>
      <sha1>gcjlf3p7jfa7qv6jvtvzuhs7fk1qlbr</sha1>
    </revision>
    <revision>
      <id>4794</id>
      <parentid>4793</parentid>
      <timestamp>2017-04-30T09:19:28Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>unsupport |ARXIV= and |BIBCODE=;</comment>
      <origin>4794</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="18820" sha1="jofaptxmpph8fnllpe14li5b6y100zo" xml:space="preserve">
--[[--------------------------&lt; P A R A M E T E R S   N O T   S U P P O R T E D &gt;------------------------------

This is a list of parameters that once were but now are no longer supported:

	['albumlink'] = nil,			-- unique alias of titlelink used by old cite AV media notes
	['albumtype'] = nil,			-- controled inappropriate functionality in the old cite AV media notes
	['artist'] = nil,				-- unique alias of others used by old cite AV media notes
	['ARXIV'] = nil,				-- not an initialization
	['Author'] = nil,				-- non-standard capitalization
	['authorformat'] = nil,			-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-format'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-name-separator'] = nil,-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-separator'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['began'] = nil,				-- module handles date ranges; cite episode and cite series
	['BIBCODE'] = nil,				-- not an initialization
	['callsign'] = nil,				-- cite interview removed
	['call-sign'] = nil,			-- cite interview removed
	['chapterlink'] = nil,			-- if ever necessary to link to a chapter article, |chapter= can be wikilinked 
	['chapter-link'] = nil,			-- 
	['city'] = nil,					-- cite interview removed
	['coauthor'] = nil,				-- redundant to |authorn=; not made part of metadata
	['coauthors'] = nil,			-- redundant to |authorn=; not made part of metadata
	['cointerviewers'] = nil,		-- unique alias of others used by old cite interview
	['day'] = nil,					-- deprecated in {{citation/core}} and somehow undeprecated in Module:Citation/CS1 and now finally removed
	['director'] = nil,				-- unique alias of author used by old cite DVD-notes
	['DoiBroken'] = nil,			-- not used, non-standard captialization
	['Editor'] = nil,				-- non-standard capitalization
	['editorformat'] = nil,			-- primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorSurname'] = nil,		-- non-standard capitalization
	['editor-format'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorGiven'] = nil,			-- non-standard capitalization
	['editor-name-separator'] = nil,-- primarily used to support Vancouver format which functionality now part of name-list-format
	['editor-separator'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['Embargo'] = nil,				-- not used, non-standard capitalization
	['ended'] = nil,				-- module handles date ranges; cite episode and cite series
	['month'] = nil,				-- functionality supported by |date=
	['name-separator'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['notestitle'] = nil,			-- unique alias of chapter used by old cite AV media notes
	['PPrefix'] = nil,				-- non-standard capitalization
	['PPPrefix'] = nil,				-- not used, non-standard capitalization
	['pp-prefix'] = nil,			-- not used, not documented
	['p-prefix'] = nil,				-- not used, not documented
	['program'] = nil,				-- cite interview removed
	['publisherid'] = nil,			-- unique alias of id used by old cite AV media notes and old cite DVD-notes
	['Ref'] = nil,					-- non-standard capitalization
	['separator'] = nil,			-- this functionality now provided by |mode=
	['titleyear'] = nil,			-- unique alias of origyear used by old cite DVD-notes

	['Author#'] = nil,				-- non-standard capitalization
	['authors#'] = nil,				-- no need for multiple lists of author names
	['Editor#'] = nil,				-- non-standard capitalization
	['editors#'] = nil,				-- no need for multiple lists of editor names
	['EditorGiven#'] = nil,			-- non-standard capitalization
	['EditorSurname#'] = nil,		-- non-standard capitalization

]]

--[[--------------------------&lt; S U P P O R T E D   P A R A M E T E R S &gt;--------------------------------------

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local whitelist = {}

local basic_arguments = {
	['accessdate'] = true,
	['access-date'] = true,
	['agency'] = true,
	['airdate'] = true,
	['air-date'] = true,
	['archivedate'] = true,
	['archive-date'] = true,
	['archive-format'] = true,
	['archiveurl'] = true,
	['archive-url'] = true,
	['article'] = true,
	['arxiv'] = true,
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['ASIN-TLD'] = true,
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['bibcode'] = true,
	['bibcode-access'] = true,
	['biorxiv'] = true,
	['booktitle'] = true,
	['book-title'] = true,
	['cartography'] = true,
	['chapter'] = true,
	['chapter-format'] = true,
	['chapterurl'] = true,
	['chapter-url'] = true,
	['citeseerx'] = true,
	['class'] = true,				-- cite arxiv and arxiv identifiers
	['collaboration'] = true,
	['conference'] = true,
	['conference-format'] = true,
	['conferenceurl'] = true,
	['conference-url'] = true,
	['contribution'] = true,
	['contribution-format'] = true,
	['contributionurl'] = true,
	['contribution-url'] = true,
	['contributor'] = true,
	['contributor-first'] = true,
	['contributor-last'] = true,
	['contributor-given'] = true,
	['contributor-surname'] = true,
	['contributor-link'] = true,
	['contributor-mask'] = true,
	['credits'] = true,				-- cite episode, cite serial
	['date'] = true,
	['deadurl'] = true,
	['dead-url'] = true,
	['degree'] = true,
	['department'] = true,
	['df'] = true,
	['dictionary'] = true,
	['displayauthors'] = true,
	['display-authors'] = true,
	['displayeditors'] = true,
	['display-editors'] = true,
	['docket'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-access'] = true,
	['doi-broken'] = true,
	['doi_brokendate'] = true,					-- @TODO deprecate underscore version?
	['doi-broken-date'] = true,
	['doi_inactivedate'] = true,				-- @TODO deprecate underscore version?
	['doi-inactive-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['editor-first'] = true,
	['editor-given'] = true,
	['editor-last'] = true,
	['editorlink'] = true,
	['editor-link'] = true,
	['editormask'] = true,
	['editor-mask'] = true,
	['editors'] = true,
	['editor-surname'] = true,
	['eissn'] = true,
	['EISSN'] = true,
	['embargo'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['entry'] = true,
	['episode'] = true,															-- cite serial only TODO: make available to cite episode?
	['episodelink'] = true,														-- cite episode and cite serial
	['episode-link'] = true,													-- cite episode and cite serial
	['eprint'] = true,															-- cite arxiv and arxiv identifiers
	['event'] = true,
	['event-format'] = true,
	['eventurl'] = true,
	['event-url'] = true,
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['hdl'] = true,
	['HDL'] = true,
	['hdl-access'] = true,
	['host'] = true,
	['id'] = true,
	['ID'] = true,
	['ignoreisbnerror'] = true,
	['ignore-isbn-error'] = true,
	['in'] = true,
	['inset'] = true,
	['institution'] = true,
	['interviewer'] = true,
	['interviewer-first'] = true,
	['interviewer-last'] = true,
	['interviewerlink'] = true,
	['interviewer-link'] = true,
	['interviewermask'] = true,
	['interviewer-mask'] = true,
	['interviewers'] = true,
	['isbn'] = true,
	['ISBN'] = true,
	['isbn13'] = true,
	['ISBN13'] = true,
	['ismn'] = true,
	['ISMN'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['jstor-access'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['laydate'] = true,
	['lay-date'] = true,
	['laysource'] = true,
	['lay-source'] = true,
	['laysummary'] = true,
	['lay-summary'] = true,
	['lay-format'] = true,
	['layurl'] = true,
	['lay-url'] = true,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['magazine'] = true,
	['mailinglist'] = true,				-- cite mailing list only
	['mailing-list'] = true,			-- cite mailing list only
	['map'] = true,						-- cite map only
	['map-format'] = true,				-- cite map only
	['mapurl'] = true,					-- cite map only
	['map-url'] = true,					-- cite map only
	['medium'] = true,
	['message-id'] = true,			-- cite newsgroup
	['minutes'] = true,
	['mode'] = true,
	['mr'] = true,
	['MR'] = true,
	['name-list-format'] = true,
	['network'] = true,
	['newsgroup'] = true,
	['newspaper'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['nopp'] = true,
	['no-pp'] = true,
	['notracking'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['ol-access'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['osti-access'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['people'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['publicationdate'] = true,
	['publication-date'] = true,
	['publicationplace'] = true,
	['publication-place'] = true,
	['publisher'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['registration'] = true,
	['rfc'] = true,
	['RFC'] = true,
	['scale'] = true,
	['script-chapter'] = true,
	['script-title'] = true,
	['season'] = true,
	['section'] = true,
	['section-format'] = true,
	['sections'] = true,					-- cite map only
	['sectionurl'] = true,
	['section-url'] = true,
	['series'] = true,
	['serieslink'] = true,
	['series-link'] = true,
	['seriesno'] = true,
	['series-no'] = true,
	['seriesnumber'] = true,
	['series-number'] = true,
	['series-separator'] = true,
	['sheet'] = true,															-- cite map only
	['sheets'] = true,															-- cite map only
	['ssrn'] = true,
	['SSRN'] = true,
	['station'] = true,
	['subject'] = true,
	['subjectlink'] = true,
	['subject-link'] = true,
	['subscription'] = true,
	['surname'] = true,
	['template doc demo'] = true,
	['template-doc-demo'] = true,
	['time'] = true,
	['timecaption'] = true,
	['time-caption'] = true,
	['title'] = true,
	['titlelink'] = true,
	['title-link'] = true,
	['trans_chapter'] = true,
	['trans-chapter'] = true,
	['trans-map'] = true,
	['transcript'] = true,
	['transcript-format'] = true,
	['transcripturl'] = true,
	['transcript-url'] = true,
	['trans_title'] = true,
	['trans-title'] = true,
	['translator'] = true,
	['translator-first'] = true,
	['translator-last'] = true,
	['translator-given'] = true,
	['translator-surname'] = true,
	['translator-link'] = true,
	['translator-mask'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['url-access'] = true,
	['vauthors'] = true,
	['veditors'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
}

local numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['contributor#'] = true,
	['contributor-first#'] = true,
	['contributor#-first'] = true,
	['contributor-last#'] = true,
	['contributor#-last'] = true,
	['contributor-given#'] = true,
	['contributor#-given'] = true,
	['contributor-surname#'] = true,
	['contributor#-surname'] = true,
	['contributor-link#'] = true,
	['contributor#-link'] = true,
	['contributor-mask#'] = true,
	['contributor#-mask'] = true,
	['editor#'] = true,
	['editor-first#'] = true,
	['editor#-first'] = true,
	['editor#-given'] = true,
	['editor-given#'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-link#'] = true,
	['editor#link'] = true,
	['editor#-link'] = true,
	['editorlink#'] = true,
	['editor-mask#'] = true,
	['editor#mask'] = true,
	['editor#-mask'] = true,
	['editormask#'] = true,
	['editor#-surname'] = true,
	['editor-surname#'] = true,
	['first#'] = true,
	['given#'] = true,
	['interviewer#'] = true,
	['interviewer-first#'] = true,
	['interviewer#-first'] = true,
	['interviewer-last#'] = true,
	['interviewer#-last'] = true,
	['interviewer-link#'] = true,
	['interviewer#-link'] = true,
	['interviewer-mask#'] = true,
	['interviewer#-mask'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-link#'] = true,
	['subject#link'] = true,
	['subject#-link'] = true,
	['subjectlink#'] = true,
	['surname#'] = true,
	['translator#'] = true,
	['translator-first#'] = true,
	['translator#-first'] = true,
	['translator-last#'] = true,
	['translator#-last'] = true,
	['translator-given#'] = true,
	['translator#-given'] = true,
	['translator-surname#'] = true,
	['translator#-surname'] = true,
	['translator-link#'] = true,
	['translator#-link'] = true,
	['translator-mask#'] = true,
	['translator#-mask'] = true,
}

--[[--------------------------&lt; C I T E   A R X I V   S U P P O R T E D   P A R A M E T E R S &gt;----------------

This is an experiment that attempts to use validate() and a limited list of valid parameters to validate the
parameters provided in a cite arxiv template.  This method might be expanded to other templates being considered.

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

--[[
This is a list of parameters that once were but now are no longer supported:
	['ARXIV'] = nil,				-- not an initialization
	['version'] = nil,				-- this is the cite arxiv parameter; |version= still supported by other cs1|2 templates

]]

local arxiv_basic_arguments = {
	['arxiv'] = true,
	['class'] = true,															-- cite arxiv and arxiv identifiers
	['eprint'] = true,															-- cite arxiv and arxiv identifiers
}


--[[--------------------------&lt; C I T E   B I O R X I V   S U P P O R T E D   P A R A M E T E R S &gt;------------

This is an experiment that attempts to use validate() and a limited list of valid parameters to validate the
parameters provided in a cite biorxiv template.  This method might be expanded to other templates being considered.

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local biorxiv_basic_arguments = {
	['biorxiv'] = true,
}


--[[--------------------------&lt; C I T E   C I T E S E E R X   S U P P O R T E D   P A R A M E T E R S &gt;--------

This is an experiment that attempts to use validate() and a limited list of valid parameters to validate the
parameters provided in a cite citeseerx template.  This method might be expanded to other templates being considered.

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local citeseerx_basic_arguments = {
	['citeseerx'] = true,
}


--[[--------------------------&lt; L I M I T E D   S U P P O R T E D   P A R A M E T E R S &gt;----------------------

This is an experiment that attempts to use validate() and a limited list of valid parameters to validate the
parameters provided in a cite arxiv, cite biorxiv, or cite citeseerx templates.  These parameters are common to
all three templates

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local limited_basic_arguments = {
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['collaboration'] = true,
	['date'] = true,
	['df'] = true,
	['display-authors'] = true,
	['first'] = true,
	['given'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['mode'] = true,
	['name-list-format'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['notracking'] = true,
	['no-tracking'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['postscript'] = true,
	['pp'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['surname'] = true,
	['template doc demo'] = true,
	['template-doc-demo'] = true,
	['title'] = true,
	['url'] = true,
	['URL'] = true,
	['vauthors'] = true,
	['year'] = true,
}
local limited_numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['surname#'] = true,
}

return {
	basic_arguments = basic_arguments,
	numbered_arguments = numbered_arguments,
	limited_basic_arguments = limited_basic_arguments,
	limited_numbered_arguments = limited_numbered_arguments,
	arxiv_basic_arguments = arxiv_basic_arguments,
	biorxiv_basic_arguments = biorxiv_basic_arguments,
	citeseerx_basic_arguments = citeseerx_basic_arguments
};</text>
      <sha1>jofaptxmpph8fnllpe14li5b6y100zo</sha1>
    </revision>
    <revision>
      <id>4795</id>
      <parentid>4794</parentid>
      <timestamp>2017-11-04T10:41:22Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>synch from sandbox;</comment>
      <origin>4795</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="18772" sha1="tab19gewmgi7eq8x1hvmbogile54m43" xml:space="preserve">
--[[--------------------------&lt; P A R A M E T E R S   N O T   S U P P O R T E D &gt;------------------------------

This is a list of parameters that once were but now are no longer supported:

	['albumlink'] = nil,			-- unique alias of titlelink used by old cite AV media notes
	['albumtype'] = nil,			-- controled inappropriate functionality in the old cite AV media notes
	['artist'] = nil,				-- unique alias of others used by old cite AV media notes
	['ARXIV'] = nil,				-- not an initialization
	['Author'] = nil,				-- non-standard capitalization
	['authorformat'] = nil,			-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-format'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-name-separator'] = nil,-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-separator'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['began'] = nil,				-- module handles date ranges; cite episode and cite series
	['BIBCODE'] = nil,				-- not an initialization
	['callsign'] = nil,				-- cite interview removed
	['call-sign'] = nil,			-- cite interview removed
	['chapterlink'] = nil,			-- if ever necessary to link to a chapter article, |chapter= can be wikilinked 
	['chapter-link'] = nil,			-- 
	['city'] = nil,					-- cite interview removed
	['coauthor'] = nil,				-- redundant to |authorn=; not made part of metadata
	['coauthors'] = nil,			-- redundant to |authorn=; not made part of metadata
	['cointerviewers'] = nil,		-- unique alias of others used by old cite interview
	['day'] = nil,					-- deprecated in {{citation/core}} and somehow undeprecated in Module:Citation/CS1 and now finally removed
	['director'] = nil,				-- unique alias of author used by old cite DVD-notes
	['DoiBroken'] = nil,			-- not used, non-standard captialization
	['Editor'] = nil,				-- non-standard capitalization
	['editorformat'] = nil,			-- primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorSurname'] = nil,		-- non-standard capitalization
	['editor-format'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorGiven'] = nil,			-- non-standard capitalization
	['editor-name-separator'] = nil,-- primarily used to support Vancouver format which functionality now part of name-list-format
	['editor-separator'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['Embargo'] = nil,				-- not used, non-standard capitalization
	['ended'] = nil,				-- module handles date ranges; cite episode and cite series
	['month'] = nil,				-- functionality supported by |date=
	['name-separator'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['notestitle'] = nil,			-- unique alias of chapter used by old cite AV media notes
	['PPrefix'] = nil,				-- non-standard capitalization
	['PPPrefix'] = nil,				-- not used, non-standard capitalization
	['pp-prefix'] = nil,			-- not used, not documented
	['p-prefix'] = nil,				-- not used, not documented
	['program'] = nil,				-- cite interview removed
	['publisherid'] = nil,			-- unique alias of id used by old cite AV media notes and old cite DVD-notes
	['Ref'] = nil,					-- non-standard capitalization
	['separator'] = nil,			-- this functionality now provided by |mode=
	['titleyear'] = nil,			-- unique alias of origyear used by old cite DVD-notes

	['Author#'] = nil,				-- non-standard capitalization
	['authors#'] = nil,				-- no need for multiple lists of author names
	['Editor#'] = nil,				-- non-standard capitalization
	['editors#'] = nil,				-- no need for multiple lists of editor names
	['EditorGiven#'] = nil,			-- non-standard capitalization
	['EditorSurname#'] = nil,		-- non-standard capitalization

]]

--[[--------------------------&lt; S U P P O R T E D   P A R A M E T E R S &gt;--------------------------------------

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local whitelist = {}

local basic_arguments = {
	['accessdate'] = true,
	['access-date'] = true,
	['agency'] = true,
	['airdate'] = true,
	['air-date'] = true,
	['archivedate'] = true,
	['archive-date'] = true,
	['archive-format'] = true,
	['archiveurl'] = true,
	['archive-url'] = true,
	['article'] = true,
	['arxiv'] = true,
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['ASIN-TLD'] = true,
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['bibcode'] = true,
	['bibcode-access'] = true,
	['biorxiv'] = true,
	['booktitle'] = true,
	['book-title'] = true,
	['cartography'] = true,
	['chapter'] = true,
	['chapter-format'] = true,
	['chapterurl'] = true,
	['chapter-url'] = true,
	['chapter-url-access'] = true,
	['citeseerx'] = true,
	['class'] = true,				-- cite arxiv and arxiv identifiers
	['collaboration'] = true,
	['conference'] = true,
	['conference-format'] = true,
	['conferenceurl'] = true,
	['conference-url'] = true,
	['contribution'] = true,
	['contribution-format'] = true,
	['contributionurl'] = true,
	['contribution-url'] = true,
	['contributor'] = true,
	['contributor-first'] = true,
	['contributor-last'] = true,
	['contributor-given'] = true,
	['contributor-surname'] = true,
	['contributor-link'] = true,
	['contributor-mask'] = true,
	['credits'] = true,				-- cite episode, cite serial
	['date'] = true,
	['deadurl'] = true,
	['dead-url'] = true,
	['degree'] = true,
	['department'] = true,
	['df'] = true,
	['dictionary'] = true,
	['displayauthors'] = true,
	['display-authors'] = true,
	['displayeditors'] = true,
	['display-editors'] = true,
	['docket'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-access'] = true,
	['doi-broken'] = true,
	['doi_brokendate'] = false,
	['doi-broken-date'] = true,
	['doi_inactivedate'] = false,
	['doi-inactive-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['editor-first'] = true,
	['editor-given'] = true,
	['editor-last'] = true,
	['editorlink'] = true,
	['editor-link'] = true,
	['editormask'] = true,
	['editor-mask'] = true,
	['editors'] = true,
	['editor-surname'] = true,
	['eissn'] = true,
	['EISSN'] = true,
	['embargo'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['entry'] = true,
	['episode'] = true,															-- cite serial only TODO: make available to cite episode?
	['episodelink'] = true,														-- cite episode and cite serial
	['episode-link'] = true,													-- cite episode and cite serial
	['eprint'] = true,															-- cite arxiv and arxiv identifiers
	['event'] = true,
	['event-format'] = true,
	['eventurl'] = true,
	['event-url'] = true,
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['hdl'] = true,
	['HDL'] = true,
	['hdl-access'] = true,
	['host'] = true,
	['id'] = true,
	['ID'] = true,
	['ignoreisbnerror'] = true,
	['ignore-isbn-error'] = true,
	['in'] = true,
	['inset'] = true,
	['institution'] = true,
	['interviewer'] = true,
	['interviewer-first'] = true,
	['interviewer-last'] = true,
	['interviewerlink'] = true,
	['interviewer-link'] = true,
	['interviewermask'] = true,
	['interviewer-mask'] = true,
	['interviewers'] = true,
	['isbn'] = true,
	['ISBN'] = true,
	['isbn13'] = true,
	['ISBN13'] = true,
	['ismn'] = true,
	['ISMN'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['jstor-access'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['laydate'] = true,
	['lay-date'] = true,
	['laysource'] = true,
	['lay-source'] = true,
	['laysummary'] = true,
	['lay-summary'] = true,
	['lay-format'] = true,
	['layurl'] = true,
	['lay-url'] = true,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['magazine'] = true,
	['mailinglist'] = true,				-- cite mailing list only
	['mailing-list'] = true,			-- cite mailing list only
	['map'] = true,						-- cite map only
	['map-format'] = true,				-- cite map only
	['mapurl'] = true,					-- cite map only
	['map-url'] = true,					-- cite map only
	['medium'] = true,
	['message-id'] = true,			-- cite newsgroup
	['minutes'] = true,
	['mode'] = true,
	['mr'] = true,
	['MR'] = true,
	['name-list-format'] = true,
	['network'] = true,
	['newsgroup'] = true,
	['newspaper'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['nopp'] = true,
	['no-pp'] = true,
	['notracking'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['ol-access'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['osti-access'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['people'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['publicationdate'] = true,
	['publication-date'] = true,
	['publicationplace'] = true,
	['publication-place'] = true,
	['publisher'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['registration'] = true,
	['rfc'] = true,
	['RFC'] = true,
	['scale'] = true,
	['script-chapter'] = true,
	['script-title'] = true,
	['season'] = true,
	['section'] = true,
	['section-format'] = true,
	['sections'] = true,					-- cite map only
	['sectionurl'] = true,
	['section-url'] = true,
	['series'] = true,
	['serieslink'] = true,
	['series-link'] = true,
	['seriesno'] = true,
	['series-no'] = true,
	['seriesnumber'] = true,
	['series-number'] = true,
	['series-separator'] = true,
	['sheet'] = true,															-- cite map only
	['sheets'] = true,															-- cite map only
	['ssrn'] = true,
	['SSRN'] = true,
	['station'] = true,
	['subject'] = true,
	['subjectlink'] = true,
	['subject-link'] = true,
	['subscription'] = true,
	['surname'] = true,
	['template doc demo'] = false,
	['template-doc-demo'] = true,
	['time'] = true,
	['timecaption'] = true,
	['time-caption'] = true,
	['title'] = true,
	['titlelink'] = true,
	['title-link'] = true,
	['trans_chapter'] = false,
	['trans-chapter'] = true,
	['trans-map'] = true,
	['transcript'] = true,
	['transcript-format'] = true,
	['transcripturl'] = true,
	['transcript-url'] = true,
	['trans_title'] = false,
	['trans-title'] = true,
	['translator'] = true,
	['translator-first'] = true,
	['translator-last'] = true,
	['translator-given'] = true,
	['translator-surname'] = true,
	['translator-link'] = true,
	['translator-mask'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['url-access'] = true,
	['vauthors'] = true,
	['veditors'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
}

local numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['contributor#'] = true,
	['contributor-first#'] = true,
	['contributor#-first'] = true,
	['contributor-last#'] = true,
	['contributor#-last'] = true,
	['contributor-given#'] = true,
	['contributor#-given'] = true,
	['contributor-surname#'] = true,
	['contributor#-surname'] = true,
	['contributor-link#'] = true,
	['contributor#-link'] = true,
	['contributor-mask#'] = true,
	['contributor#-mask'] = true,
	['editor#'] = true,
	['editor-first#'] = true,
	['editor#-first'] = true,
	['editor#-given'] = true,
	['editor-given#'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-link#'] = true,
	['editor#link'] = true,
	['editor#-link'] = true,
	['editorlink#'] = true,
	['editor-mask#'] = true,
	['editor#mask'] = true,
	['editor#-mask'] = true,
	['editormask#'] = true,
	['editor#-surname'] = true,
	['editor-surname#'] = true,
	['first#'] = true,
	['given#'] = true,
	['interviewer#'] = true,
	['interviewer-first#'] = true,
	['interviewer#-first'] = true,
	['interviewer-last#'] = true,
	['interviewer#-last'] = true,
	['interviewer-link#'] = true,
	['interviewer#-link'] = true,
	['interviewer-mask#'] = true,
	['interviewer#-mask'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-link#'] = true,
	['subject#link'] = true,
	['subject#-link'] = true,
	['subjectlink#'] = true,
	['surname#'] = true,
	['translator#'] = true,
	['translator-first#'] = true,
	['translator#-first'] = true,
	['translator-last#'] = true,
	['translator#-last'] = true,
	['translator-given#'] = true,
	['translator#-given'] = true,
	['translator-surname#'] = true,
	['translator#-surname'] = true,
	['translator-link#'] = true,
	['translator#-link'] = true,
	['translator-mask#'] = true,
	['translator#-mask'] = true,
}

--[[--------------------------&lt; C I T E   A R X I V   S U P P O R T E D   P A R A M E T E R S &gt;----------------

This is an experiment that attempts to use validate() and a limited list of valid parameters to validate the
parameters provided in a cite arxiv template.  This method might be expanded to other templates being considered.

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

--[[
This is a list of parameters that once were but now are no longer supported:
	['ARXIV'] = nil,				-- not an initialization
	['version'] = nil,				-- this is the cite arxiv parameter; |version= still supported by other cs1|2 templates

]]

local arxiv_basic_arguments = {
	['arxiv'] = true,
	['class'] = true,															-- cite arxiv and arxiv identifiers
	['eprint'] = true,															-- cite arxiv and arxiv identifiers
}


--[[--------------------------&lt; C I T E   B I O R X I V   S U P P O R T E D   P A R A M E T E R S &gt;------------

This is an experiment that attempts to use validate() and a limited list of valid parameters to validate the
parameters provided in a cite biorxiv template.  This method might be expanded to other templates being considered.

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local biorxiv_basic_arguments = {
	['biorxiv'] = true,
}


--[[--------------------------&lt; C I T E   C I T E S E E R X   S U P P O R T E D   P A R A M E T E R S &gt;--------

This is an experiment that attempts to use validate() and a limited list of valid parameters to validate the
parameters provided in a cite citeseerx template.  This method might be expanded to other templates being considered.

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local citeseerx_basic_arguments = {
	['citeseerx'] = true,
}


--[[--------------------------&lt; L I M I T E D   S U P P O R T E D   P A R A M E T E R S &gt;----------------------

This is an experiment that attempts to use validate() and a limited list of valid parameters to validate the
parameters provided in a cite arxiv, cite biorxiv, or cite citeseerx templates.  These parameters are common to
all three templates

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local limited_basic_arguments = {
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['collaboration'] = true,
	['date'] = true,
	['df'] = true,
	['display-authors'] = true,
	['first'] = true,
	['given'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['mode'] = true,
	['name-list-format'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['notracking'] = true,
	['no-tracking'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['postscript'] = true,
	['pp'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['surname'] = true,
	['template doc demo'] = true,
	['template-doc-demo'] = true,
	['title'] = true,
	['url'] = true,
	['URL'] = true,
	['vauthors'] = true,
	['year'] = true,
}
local limited_numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['surname#'] = true,
}

return {
	basic_arguments = basic_arguments,
	numbered_arguments = numbered_arguments,
	limited_basic_arguments = limited_basic_arguments,
	limited_numbered_arguments = limited_numbered_arguments,
	arxiv_basic_arguments = arxiv_basic_arguments,
	biorxiv_basic_arguments = biorxiv_basic_arguments,
	citeseerx_basic_arguments = citeseerx_basic_arguments
};</text>
      <sha1>tab19gewmgi7eq8x1hvmbogile54m43</sha1>
    </revision>
    <revision>
      <id>4796</id>
      <parentid>4795</parentid>
      <timestamp>2018-02-17T14:52:17Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4796</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="18946" sha1="9x9mjj45vb802c1t6f99o8wlxbrfzt2" xml:space="preserve">
--[[--------------------------&lt; P A R A M E T E R S   N O T   S U P P O R T E D &gt;------------------------------

This is a list of parameters that once were but now are no longer supported:

	['albumlink'] = nil,			-- unique alias of titlelink used by old cite AV media notes
	['albumtype'] = nil,			-- controled inappropriate functionality in the old cite AV media notes
	['artist'] = nil,				-- unique alias of others used by old cite AV media notes
	['ARXIV'] = nil,				-- not an initialization
	['Author'] = nil,				-- non-standard capitalization
	['authorformat'] = nil,			-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-format'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-name-separator'] = nil,-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-separator'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['began'] = nil,				-- module handles date ranges; cite episode and cite series
	['BIBCODE'] = nil,				-- not an initialization
	['callsign'] = nil,				-- cite interview removed
	['call-sign'] = nil,			-- cite interview removed
	['chapterlink'] = nil,			-- if ever necessary to link to a chapter article, |chapter= can be wikilinked 
	['chapter-link'] = nil,			-- 
	['city'] = nil,					-- cite interview removed
	['coauthor'] = nil,				-- redundant to |authorn=; not made part of metadata
	['coauthors'] = nil,			-- redundant to |authorn=; not made part of metadata
	['cointerviewers'] = nil,		-- unique alias of others used by old cite interview
	['day'] = nil,					-- deprecated in {{citation/core}} and somehow undeprecated in Module:Citation/CS1 and now finally removed
	['director'] = nil,				-- unique alias of author used by old cite DVD-notes
	['doi_brokendate'] = nil,                  -- alias of doi-broken-date
	['doi_inactivedate'] = nil,                  -- alias of doi-inactive-date
	['DoiBroken'] = nil,			-- not used, non-standard captialization
	['Editor'] = nil,				-- non-standard capitalization
	['editorformat'] = nil,			-- primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorSurname'] = nil,		-- non-standard capitalization
	['editor-format'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorGiven'] = nil,			-- non-standard capitalization
	['editor-name-separator'] = nil,-- primarily used to support Vancouver format which functionality now part of name-list-format
	['editor-separator'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['Embargo'] = nil,				-- not used, non-standard capitalization
	['ended'] = nil,				-- module handles date ranges; cite episode and cite series
	['month'] = nil,				-- functionality supported by |date=
	['name-separator'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['notestitle'] = nil,			-- unique alias of chapter used by old cite AV media notes
	['PPrefix'] = nil,				-- non-standard capitalization
	['PPPrefix'] = nil,				-- not used, non-standard capitalization
	['pp-prefix'] = nil,			-- not used, not documented
	['p-prefix'] = nil,				-- not used, not documented
	['program'] = nil,				-- cite interview removed
	['publisherid'] = nil,			-- unique alias of id used by old cite AV media notes and old cite DVD-notes
	['Ref'] = nil,					-- non-standard capitalization
	['separator'] = nil,			-- this functionality now provided by |mode=
	['template doc demo'] = nil,            -- alias of template doc demo
	['titleyear'] = nil,			-- unique alias of origyear used by old cite DVD-notes
	['trans_chapter'] = nil,                -- alias of trans-chapter
	['trans_title'] = nil,                  -- alias of trans-title

	['Author#'] = nil,				-- non-standard capitalization
	['authors#'] = nil,				-- no need for multiple lists of author names
	['Editor#'] = nil,				-- non-standard capitalization
	['editors#'] = nil,				-- no need for multiple lists of editor names
	['EditorGiven#'] = nil,			-- non-standard capitalization
	['EditorSurname#'] = nil,		-- non-standard capitalization

]]

--[[--------------------------&lt; S U P P O R T E D   P A R A M E T E R S &gt;--------------------------------------

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local whitelist = {}

local basic_arguments = {
	['accessdate'] = true,
	['access-date'] = true,
	['agency'] = true,
	['airdate'] = true,
	['air-date'] = true,
	['archivedate'] = true,
	['archive-date'] = true,
	['archive-format'] = true,
	['archiveurl'] = true,
	['archive-url'] = true,
	['article'] = true,
	['arxiv'] = true,
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['ASIN-TLD'] = true,
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['bibcode'] = true,
	['bibcode-access'] = true,
	['biorxiv'] = true,
	['booktitle'] = true,
	['book-title'] = true,
	['cartography'] = true,
	['chapter'] = true,
	['chapter-format'] = true,
	['chapterurl'] = true,
	['chapter-url'] = true,
	['chapter-url-access'] = true,
	['citeseerx'] = true,
	['class'] = true,				-- cite arxiv and arxiv identifiers
	['collaboration'] = true,
	['conference'] = true,
	['conference-format'] = true,
	['conferenceurl'] = true,
	['conference-url'] = true,
	['contribution'] = true,
	['contribution-format'] = true,
	['contributionurl'] = true,
	['contribution-url'] = true,
	['contributor'] = true,
	['contributor-first'] = true,
	['contributor-last'] = true,
	['contributor-given'] = true,
	['contributor-surname'] = true,
	['contributor-link'] = true,
	['contributor-mask'] = true,
	['credits'] = true,				-- cite episode, cite serial
	['date'] = true,
	['deadurl'] = true,
	['dead-url'] = true,
	['degree'] = true,
	['department'] = true,
	['df'] = true,
	['dictionary'] = true,
	['displayauthors'] = true,
	['display-authors'] = true,
	['displayeditors'] = true,
	['display-editors'] = true,
	['docket'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-access'] = true,
	['doi-broken'] = true,
	['doi-broken-date'] = true,
	['doi-inactive-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['editor-first'] = true,
	['editor-given'] = true,
	['editor-last'] = true,
	['editorlink'] = true,
	['editor-link'] = true,
	['editormask'] = true,
	['editor-mask'] = true,
	['editors'] = true,
	['editor-surname'] = true,
	['eissn'] = true,
	['EISSN'] = true,
	['embargo'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['entry'] = true,
	['episode'] = true,															-- cite serial only TODO: make available to cite episode?
	['episodelink'] = true,														-- cite episode and cite serial
	['episode-link'] = true,													-- cite episode and cite serial
	['eprint'] = true,															-- cite arxiv and arxiv identifiers
	['event'] = true,
	['event-format'] = true,
	['eventurl'] = true,
	['event-url'] = true,
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['hdl'] = true,
	['HDL'] = true,
	['hdl-access'] = true,
	['host'] = true,
	['id'] = true,
	['ID'] = true,
	['ignoreisbnerror'] = true,
	['ignore-isbn-error'] = true,
	['in'] = true,
	['inset'] = true,
	['institution'] = true,
	['interviewer'] = true,
	['interviewer-first'] = true,
	['interviewer-last'] = true,
	['interviewerlink'] = true,
	['interviewer-link'] = true,
	['interviewermask'] = true,
	['interviewer-mask'] = true,
	['interviewers'] = true,
	['isbn'] = true,
	['ISBN'] = true,
	['isbn13'] = true,
	['ISBN13'] = true,
	['ismn'] = true,
	['ISMN'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['jstor-access'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['laydate'] = true,
	['lay-date'] = true,
	['laysource'] = true,
	['lay-source'] = true,
	['laysummary'] = true,
	['lay-summary'] = true,
	['lay-format'] = true,
	['layurl'] = true,
	['lay-url'] = true,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['magazine'] = true,
	['mailinglist'] = true,				-- cite mailing list only
	['mailing-list'] = true,			-- cite mailing list only
	['map'] = true,						-- cite map only
	['map-format'] = true,				-- cite map only
	['mapurl'] = true,					-- cite map only
	['map-url'] = true,					-- cite map only
	['medium'] = true,
	['message-id'] = true,			-- cite newsgroup
	['minutes'] = true,
	['mode'] = true,
	['mr'] = true,
	['MR'] = true,
	['name-list-format'] = true,
	['network'] = true,
	['newsgroup'] = true,
	['newspaper'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['nopp'] = true,
	['no-pp'] = true,
	['notracking'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['ol-access'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['osti-access'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['people'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['publicationdate'] = true,
	['publication-date'] = true,
	['publicationplace'] = true,
	['publication-place'] = true,
	['publisher'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['registration'] = true,
	['rfc'] = true,
	['RFC'] = true,
	['scale'] = true,
	['script-chapter'] = true,
	['script-title'] = true,
	['season'] = true,
	['section'] = true,
	['section-format'] = true,
	['sections'] = true,					-- cite map only
	['sectionurl'] = true,
	['section-url'] = true,
	['series'] = true,
	['serieslink'] = true,
	['series-link'] = true,
	['seriesno'] = true,
	['series-no'] = true,
	['seriesnumber'] = true,
	['series-number'] = true,
	['series-separator'] = true,
	['sheet'] = true,															-- cite map only
	['sheets'] = true,															-- cite map only
	['ssrn'] = true,
	['SSRN'] = true,
	['station'] = true,
	['subject'] = true,
	['subjectlink'] = true,
	['subject-link'] = true,
	['subscription'] = true,
	['surname'] = true,
	['template-doc-demo'] = true,
	['time'] = true,
	['timecaption'] = true,
	['time-caption'] = true,
	['title'] = true,
	['titlelink'] = true,
	['title-link'] = true,
	['trans-chapter'] = true,
	['trans-map'] = true,
	['transcript'] = true,
	['transcript-format'] = true,
	['transcripturl'] = true,
	['transcript-url'] = true,
	['trans-title'] = true,
	['translator'] = true,
	['translator-first'] = true,
	['translator-last'] = true,
	['translator-given'] = true,
	['translator-surname'] = true,
	['translator-link'] = true,
	['translator-mask'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['url-access'] = true,
	['vauthors'] = true,
	['veditors'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
}

local numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['contributor#'] = true,
	['contributor-first#'] = true,
	['contributor#-first'] = true,
	['contributor-last#'] = true,
	['contributor#-last'] = true,
	['contributor-given#'] = true,
	['contributor#-given'] = true,
	['contributor-surname#'] = true,
	['contributor#-surname'] = true,
	['contributor-link#'] = true,
	['contributor#-link'] = true,
	['contributor-mask#'] = true,
	['contributor#-mask'] = true,
	['editor#'] = true,
	['editor-first#'] = true,
	['editor#-first'] = true,
	['editor#-given'] = true,
	['editor-given#'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-link#'] = true,
	['editor#link'] = true,
	['editor#-link'] = true,
	['editorlink#'] = true,
	['editor-mask#'] = true,
	['editor#mask'] = true,
	['editor#-mask'] = true,
	['editormask#'] = true,
	['editor#-surname'] = true,
	['editor-surname#'] = true,
	['first#'] = true,
	['given#'] = true,
	['interviewer#'] = true,
	['interviewer-first#'] = true,
	['interviewer#-first'] = true,
	['interviewer-last#'] = true,
	['interviewer#-last'] = true,
	['interviewer-link#'] = true,
	['interviewer#-link'] = true,
	['interviewer-mask#'] = true,
	['interviewer#-mask'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-link#'] = true,
	['subject#link'] = true,
	['subject#-link'] = true,
	['subjectlink#'] = true,
	['surname#'] = true,
	['translator#'] = true,
	['translator-first#'] = true,
	['translator#-first'] = true,
	['translator-last#'] = true,
	['translator#-last'] = true,
	['translator-given#'] = true,
	['translator#-given'] = true,
	['translator-surname#'] = true,
	['translator#-surname'] = true,
	['translator-link#'] = true,
	['translator#-link'] = true,
	['translator-mask#'] = true,
	['translator#-mask'] = true,
}

--[[--------------------------&lt; C I T E   A R X I V   S U P P O R T E D   P A R A M E T E R S &gt;----------------

This is an experiment that attempts to use validate() and a limited list of valid parameters to validate the
parameters provided in a cite arxiv template.  This method might be expanded to other templates being considered.

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

--[[
This is a list of parameters that once were but now are no longer supported:
	['ARXIV'] = nil,				-- not an initialization
	['version'] = nil,				-- this is the cite arxiv parameter; |version= still supported by other cs1|2 templates

]]

local arxiv_basic_arguments = {
	['arxiv'] = true,
	['class'] = true,															-- cite arxiv and arxiv identifiers
	['eprint'] = true,															-- cite arxiv and arxiv identifiers
}


--[[--------------------------&lt; C I T E   B I O R X I V   S U P P O R T E D   P A R A M E T E R S &gt;------------

This is an experiment that attempts to use validate() and a limited list of valid parameters to validate the
parameters provided in a cite biorxiv template.  This method might be expanded to other templates being considered.

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local biorxiv_basic_arguments = {
	['biorxiv'] = true,
}


--[[--------------------------&lt; C I T E   C I T E S E E R X   S U P P O R T E D   P A R A M E T E R S &gt;--------

This is an experiment that attempts to use validate() and a limited list of valid parameters to validate the
parameters provided in a cite citeseerx template.  This method might be expanded to other templates being considered.

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local citeseerx_basic_arguments = {
	['citeseerx'] = true,
}


--[[--------------------------&lt; L I M I T E D   S U P P O R T E D   P A R A M E T E R S &gt;----------------------

This is an experiment that attempts to use validate() and a limited list of valid parameters to validate the
parameters provided in a cite arxiv, cite biorxiv, or cite citeseerx templates.  These parameters are common to
all three templates

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local limited_basic_arguments = {
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['collaboration'] = true,
	['date'] = true,
	['df'] = true,
	['display-authors'] = true,
	['first'] = true,
	['given'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['mode'] = true,
	['name-list-format'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['notracking'] = true,
	['no-tracking'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['postscript'] = true,
	['pp'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['surname'] = true,
	['template-doc-demo'] = true,
	['title'] = true,
	['url'] = true,
	['URL'] = true,
	['vauthors'] = true,
	['year'] = true,
}
local limited_numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['surname#'] = true,
}

return {
	basic_arguments = basic_arguments,
	numbered_arguments = numbered_arguments,
	limited_basic_arguments = limited_basic_arguments,
	limited_numbered_arguments = limited_numbered_arguments,
	arxiv_basic_arguments = arxiv_basic_arguments,
	biorxiv_basic_arguments = biorxiv_basic_arguments,
	citeseerx_basic_arguments = citeseerx_basic_arguments
};</text>
      <sha1>9x9mjj45vb802c1t6f99o8wlxbrfzt2</sha1>
    </revision>
    <revision>
      <id>4797</id>
      <parentid>4796</parentid>
      <timestamp>2018-06-09T21:37:04Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>synch from sandbox;</comment>
      <origin>4797</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="18965" sha1="lp1v9j0dsfcvr8rl07rvlt9icnpqnzw" xml:space="preserve">
--[[--------------------------&lt; P A R A M E T E R S   N O T   S U P P O R T E D &gt;------------------------------

This is a list of parameters that once were but now are no longer supported:

	['albumlink'] = nil,			-- unique alias of titlelink used by old cite AV media notes
	['albumtype'] = nil,			-- controled inappropriate functionality in the old cite AV media notes
	['artist'] = nil,				-- unique alias of others used by old cite AV media notes
	['ARXIV'] = nil,				-- not an initialization
	['Author'] = nil,				-- non-standard capitalization
	['authorformat'] = nil,			-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-format'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-name-separator'] = nil,-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-separator'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['began'] = nil,				-- module handles date ranges; cite episode and cite series
	['BIBCODE'] = nil,				-- not an initialization
	['callsign'] = nil,				-- cite interview removed
	['call-sign'] = nil,			-- cite interview removed
	['chapterlink'] = nil,			-- if ever necessary to link to a chapter article, |chapter= can be wikilinked 
	['chapter-link'] = nil,			-- 
	['city'] = nil,					-- cite interview removed
	['coauthor'] = nil,				-- redundant to |authorn=; not made part of metadata
	['coauthors'] = nil,			-- redundant to |authorn=; not made part of metadata
	['cointerviewers'] = nil,		-- unique alias of others used by old cite interview
	['day'] = nil,					-- deprecated in {{citation/core}} and somehow undeprecated in Module:Citation/CS1 and now finally removed
	['director'] = nil,				-- unique alias of author used by old cite DVD-notes
	['doi_brokendate'] = nil,                  -- alias of doi-broken-date
	['doi_inactivedate'] = nil,                  -- alias of doi-inactive-date
	['DoiBroken'] = nil,			-- not used, non-standard captialization
	['Editor'] = nil,				-- non-standard capitalization
	['editorformat'] = nil,			-- primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorSurname'] = nil,		-- non-standard capitalization
	['editor-format'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorGiven'] = nil,			-- non-standard capitalization
	['editor-name-separator'] = nil,-- primarily used to support Vancouver format which functionality now part of name-list-format
	['editor-separator'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['Embargo'] = nil,				-- not used, non-standard capitalization
	['ended'] = nil,				-- module handles date ranges; cite episode and cite series
	['month'] = nil,				-- functionality supported by |date=
	['name-separator'] = nil,		-- primarily used to support Vancouver format which functionality now part of name-list-format
	['notestitle'] = nil,			-- unique alias of chapter used by old cite AV media notes
	['PPrefix'] = nil,				-- non-standard capitalization
	['PPPrefix'] = nil,				-- not used, non-standard capitalization
	['pp-prefix'] = nil,			-- not used, not documented
	['p-prefix'] = nil,				-- not used, not documented
	['program'] = nil,				-- cite interview removed
	['publisherid'] = nil,			-- unique alias of id used by old cite AV media notes and old cite DVD-notes
	['Ref'] = nil,					-- non-standard capitalization
	['separator'] = nil,			-- this functionality now provided by |mode=
	['template doc demo'] = nil,            -- alias of template doc demo
	['titleyear'] = nil,			-- unique alias of origyear used by old cite DVD-notes
	['trans_chapter'] = nil,                -- alias of trans-chapter
	['trans_title'] = nil,                  -- alias of trans-title

	['Author#'] = nil,				-- non-standard capitalization
	['authors#'] = nil,				-- no need for multiple lists of author names
	['Editor#'] = nil,				-- non-standard capitalization
	['editors#'] = nil,				-- no need for multiple lists of editor names
	['EditorGiven#'] = nil,			-- non-standard capitalization
	['EditorSurname#'] = nil,		-- non-standard capitalization

]]

--[[--------------------------&lt; S U P P O R T E D   P A R A M E T E R S &gt;--------------------------------------

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local whitelist = {}

local basic_arguments = {
	['accessdate'] = true,
	['access-date'] = true,
	['agency'] = true,
	['airdate'] = true,
	['air-date'] = true,
	['archivedate'] = true,
	['archive-date'] = true,
	['archive-format'] = true,
	['archiveurl'] = true,
	['archive-url'] = true,
	['article'] = true,
	['arxiv'] = true,
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['ASIN-TLD'] = true,
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['bibcode'] = true,
	['bibcode-access'] = true,
	['biorxiv'] = true,
	['booktitle'] = true,
	['book-title'] = true,
	['cartography'] = true,
	['chapter'] = true,
	['chapter-format'] = true,
	['chapterurl'] = true,
	['chapter-url'] = true,
	['chapter-url-access'] = true,
	['citeseerx'] = true,
	['class'] = true,				-- cite arxiv and arxiv identifiers
	['collaboration'] = true,
	['conference'] = true,
	['conference-format'] = true,
	['conferenceurl'] = true,
	['conference-url'] = true,
	['contribution'] = true,
	['contribution-format'] = true,
	['contributionurl'] = true,
	['contribution-url'] = true,
	['contributor'] = true,
	['contributor-first'] = true,
	['contributor-last'] = true,
	['contributor-given'] = true,
	['contributor-surname'] = true,
	['contributor-link'] = true,
	['contributor-mask'] = true,
	['credits'] = true,				-- cite episode, cite serial
	['date'] = true,
	['deadurl'] = true,
	['dead-url'] = true,
	['degree'] = true,
	['department'] = true,
	['df'] = true,
	['dictionary'] = true,
	['displayauthors'] = true,
	['display-authors'] = true,
	['displayeditors'] = true,
	['display-editors'] = true,
	['docket'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-access'] = true,
	['doi-broken'] = true,
	['doi-broken-date'] = true,
	['doi-inactive-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['editor-first'] = true,
	['editor-given'] = true,
	['editor-last'] = true,
	['editorlink'] = true,
	['editor-link'] = true,
	['editormask'] = true,
	['editor-mask'] = true,
	['editors'] = true,
	['editor-surname'] = true,
	['eissn'] = true,
	['EISSN'] = true,
	['embargo'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['entry'] = true,
	['episode'] = true,															-- cite serial only TODO: make available to cite episode?
	['episodelink'] = true,														-- cite episode and cite serial
	['episode-link'] = true,													-- cite episode and cite serial
	['eprint'] = true,															-- cite arxiv and arxiv identifiers
	['event'] = true,
	['event-format'] = true,
	['eventurl'] = true,
	['event-url'] = true,
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['hdl'] = true,
	['HDL'] = true,
	['hdl-access'] = true,
	['host'] = true,
	['id'] = true,
	['ID'] = true,
	['ignoreisbnerror'] = true,
	['ignore-isbn-error'] = true,
	['in'] = false,
	['inset'] = true,
	['institution'] = true,
	['interviewer'] = true,
	['interviewer-first'] = true,
	['interviewer-last'] = true,
	['interviewerlink'] = true,
	['interviewer-link'] = true,
	['interviewermask'] = true,
	['interviewer-mask'] = true,
	['interviewers'] = true,
	['isbn'] = true,
	['ISBN'] = true,
	['isbn13'] = true,
	['ISBN13'] = true,
	['ismn'] = true,
	['ISMN'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['jstor-access'] = true,
	['lang'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['laydate'] = true,
	['lay-date'] = true,
	['laysource'] = true,
	['lay-source'] = true,
	['laysummary'] = true,
	['lay-summary'] = true,
	['lay-format'] = true,
	['layurl'] = true,
	['lay-url'] = true,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['magazine'] = true,
	['mailinglist'] = true,				-- cite mailing list only
	['mailing-list'] = true,			-- cite mailing list only
	['map'] = true,						-- cite map only
	['map-format'] = true,				-- cite map only
	['mapurl'] = true,					-- cite map only
	['map-url'] = true,					-- cite map only
	['medium'] = true,
	['message-id'] = true,			-- cite newsgroup
	['minutes'] = true,
	['mode'] = true,
	['mr'] = true,
	['MR'] = true,
	['name-list-format'] = true,
	['network'] = true,
	['newsgroup'] = true,
	['newspaper'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['nopp'] = true,
	['no-pp'] = true,
	['notracking'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['ol-access'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['osti-access'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['people'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['publicationdate'] = true,
	['publication-date'] = true,
	['publicationplace'] = true,
	['publication-place'] = true,
	['publisher'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['registration'] = true,
	['rfc'] = true,
	['RFC'] = true,
	['scale'] = true,
	['script-chapter'] = true,
	['script-title'] = true,
	['season'] = true,
	['section'] = true,
	['section-format'] = true,
	['sections'] = true,					-- cite map only
	['sectionurl'] = true,
	['section-url'] = true,
	['series'] = true,
	['serieslink'] = true,
	['series-link'] = true,
	['seriesno'] = true,
	['series-no'] = true,
	['seriesnumber'] = true,
	['series-number'] = true,
	['series-separator'] = true,
	['sheet'] = true,															-- cite map only
	['sheets'] = true,															-- cite map only
	['ssrn'] = true,
	['SSRN'] = true,
	['station'] = true,
	['subject'] = true,
	['subjectlink'] = true,
	['subject-link'] = true,
	['subscription'] = true,
	['surname'] = true,
	['template-doc-demo'] = true,
	['time'] = true,
	['timecaption'] = true,
	['time-caption'] = true,
	['title'] = true,
	['titlelink'] = true,
	['title-link'] = true,
	['trans-chapter'] = true,
	['trans-map'] = true,
	['transcript'] = true,
	['transcript-format'] = true,
	['transcripturl'] = true,
	['transcript-url'] = true,
	['trans-title'] = true,
	['translator'] = true,
	['translator-first'] = true,
	['translator-last'] = true,
	['translator-given'] = true,
	['translator-surname'] = true,
	['translator-link'] = true,
	['translator-mask'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['url-access'] = true,
	['vauthors'] = true,
	['veditors'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
}

local numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['contributor#'] = true,
	['contributor-first#'] = true,
	['contributor#-first'] = true,
	['contributor-last#'] = true,
	['contributor#-last'] = true,
	['contributor-given#'] = true,
	['contributor#-given'] = true,
	['contributor-surname#'] = true,
	['contributor#-surname'] = true,
	['contributor-link#'] = true,
	['contributor#-link'] = true,
	['contributor-mask#'] = true,
	['contributor#-mask'] = true,
	['editor#'] = true,
	['editor-first#'] = true,
	['editor#-first'] = true,
	['editor#-given'] = true,
	['editor-given#'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-link#'] = true,
	['editor#link'] = true,
	['editor#-link'] = true,
	['editorlink#'] = true,
	['editor-mask#'] = true,
	['editor#mask'] = true,
	['editor#-mask'] = true,
	['editormask#'] = true,
	['editor#-surname'] = true,
	['editor-surname#'] = true,
	['first#'] = true,
	['given#'] = true,
	['interviewer#'] = true,
	['interviewer-first#'] = true,
	['interviewer#-first'] = true,
	['interviewer-last#'] = true,
	['interviewer#-last'] = true,
	['interviewer-link#'] = true,
	['interviewer#-link'] = true,
	['interviewer-mask#'] = true,
	['interviewer#-mask'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-link#'] = true,
	['subject#link'] = true,
	['subject#-link'] = true,
	['subjectlink#'] = true,
	['surname#'] = true,
	['translator#'] = true,
	['translator-first#'] = true,
	['translator#-first'] = true,
	['translator-last#'] = true,
	['translator#-last'] = true,
	['translator-given#'] = true,
	['translator#-given'] = true,
	['translator-surname#'] = true,
	['translator#-surname'] = true,
	['translator-link#'] = true,
	['translator#-link'] = true,
	['translator-mask#'] = true,
	['translator#-mask'] = true,
}

--[[--------------------------&lt; C I T E   A R X I V   S U P P O R T E D   P A R A M E T E R S &gt;----------------

This is an experiment that attempts to use validate() and a limited list of valid parameters to validate the
parameters provided in a cite arxiv template.  This method might be expanded to other templates being considered.

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

--[[
This is a list of parameters that once were but now are no longer supported:
	['ARXIV'] = nil,				-- not an initialization
	['version'] = nil,				-- this is the cite arxiv parameter; |version= still supported by other cs1|2 templates

]]

local arxiv_basic_arguments = {
	['arxiv'] = true,
	['class'] = true,															-- cite arxiv and arxiv identifiers
	['eprint'] = true,															-- cite arxiv and arxiv identifiers
}


--[[--------------------------&lt; C I T E   B I O R X I V   S U P P O R T E D   P A R A M E T E R S &gt;------------

This is an experiment that attempts to use validate() and a limited list of valid parameters to validate the
parameters provided in a cite biorxiv template.  This method might be expanded to other templates being considered.

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local biorxiv_basic_arguments = {
	['biorxiv'] = true,
}


--[[--------------------------&lt; C I T E   C I T E S E E R X   S U P P O R T E D   P A R A M E T E R S &gt;--------

This is an experiment that attempts to use validate() and a limited list of valid parameters to validate the
parameters provided in a cite citeseerx template.  This method might be expanded to other templates being considered.

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local citeseerx_basic_arguments = {
	['citeseerx'] = true,
}


--[[--------------------------&lt; L I M I T E D   S U P P O R T E D   P A R A M E T E R S &gt;----------------------

This is an experiment that attempts to use validate() and a limited list of valid parameters to validate the
parameters provided in a cite arxiv, cite biorxiv, or cite citeseerx templates.  These parameters are common to
all three templates

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local limited_basic_arguments = {
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['collaboration'] = true,
	['date'] = true,
	['df'] = true,
	['display-authors'] = true,
	['first'] = true,
	['given'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['mode'] = true,
	['name-list-format'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['notracking'] = true,
	['no-tracking'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['postscript'] = true,
	['pp'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['surname'] = true,
	['template-doc-demo'] = true,
	['title'] = true,
	['url'] = true,
	['URL'] = true,
	['vauthors'] = true,
	['year'] = true,
}
local limited_numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['surname#'] = true,
}

return {
	basic_arguments = basic_arguments,
	numbered_arguments = numbered_arguments,
	limited_basic_arguments = limited_basic_arguments,
	limited_numbered_arguments = limited_numbered_arguments,
	arxiv_basic_arguments = arxiv_basic_arguments,
	biorxiv_basic_arguments = biorxiv_basic_arguments,
	citeseerx_basic_arguments = citeseerx_basic_arguments
};</text>
      <sha1>lp1v9j0dsfcvr8rl07rvlt9icnpqnzw</sha1>
    </revision>
    <revision>
      <id>4798</id>
      <parentid>4797</parentid>
      <timestamp>2018-09-29T13:26:26Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>synch from sandbox;</comment>
      <origin>4798</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="20227" sha1="fbkgoeol5z8rcmtcar0vscst74y6eta" xml:space="preserve">
--[[--------------------------&lt; P A R A M E T E R S   N O T   S U P P O R T E D &gt;------------------------------

This is a list of parameters that once were but now are no longer supported:

	['albumlink'] = nil,														-- unique alias of titlelink used by old cite AV media notes
	['albumtype'] = nil,														-- controled inappropriate functionality in the old cite AV media notes
	['artist'] = nil,															-- unique alias of others used by old cite AV media notes
	['ARXIV'] = nil,															-- not an initialization
	['Author'] = nil,															-- non-standard capitalization
	['authorformat'] = nil,														-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-format'] = nil,													-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-name-separator'] = nil,											-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-separator'] = nil,													-- primarily used to support Vancouver format which functionality now part of name-list-format
	['began'] = nil,															-- module handles date ranges; cite episode and cite series
	['BIBCODE'] = nil,															-- not an initialization
	['callsign'] = nil,															-- cite interview removed
	['call-sign'] = nil,														-- cite interview removed
	['chapterlink'] = nil,														-- if ever necessary to link to a chapter article, |chapter= can be wikilinked 
	['chapter-link'] = nil,														-- 
	['city'] = nil,																-- cite interview removed
	['coauthor'] = nil,															-- redundant to |authorn=; not made part of metadata
	['coauthors'] = nil,														-- redundant to |authorn=; not made part of metadata
	['cointerviewers'] = nil,													-- unique alias of others used by old cite interview
	['day'] = nil,																-- deprecated in {{citation/core}} and somehow undeprecated in Module:Citation/CS1 and now finally removed
	['director'] = nil,															-- unique alias of author used by old cite DVD-notes
	['doi_brokendate'] = nil,    												-- alias of doi-broken-date
	['doi_inactivedate'] = nil,													-- alias of doi-inactive-date
	['DoiBroken'] = nil,														-- not used, non-standard captialization
	['Editor'] = nil,															-- non-standard capitalization
	['editorformat'] = nil,														-- primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorSurname'] = nil,													-- non-standard capitalization
	['editor-format'] = nil,													-- primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorGiven'] = nil,														-- non-standard capitalization
	['editor-name-separator'] = nil,											-- primarily used to support Vancouver format which functionality now part of name-list-format
	['editor-separator'] = nil,													-- primarily used to support Vancouver format which functionality now part of name-list-format
	['Embargo'] = nil,															-- not used, non-standard capitalization
	['ended'] = nil,															-- module handles date ranges; cite episode and cite series
	['in'] = nil,																-- ambiguous between use for language, appearance of a lesser work in an edited work
	['month'] = nil,															-- functionality supported by |date=
	['name-separator'] = nil,													-- primarily used to support Vancouver format which functionality now part of name-list-format
	['notestitle'] = nil,														-- unique alias of chapter used by old cite AV media notes
	['PPrefix'] = nil,															-- non-standard capitalization
	['PPPrefix'] = nil,															-- not used, non-standard capitalization
	['pp-prefix'] = nil,														-- not used, not documented
	['p-prefix'] = nil,															-- not used, not documented
	['program'] = nil,															-- cite interview removed
	['publisherid'] = nil,														-- unique alias of id used by old cite AV media notes and old cite DVD-notes
	['Ref'] = nil,																-- non-standard capitalization
	['separator'] = nil,														-- this functionality now provided by |mode=
	['template doc demo'] = nil,												-- alias of template doc demo
	['titleyear'] = nil,														-- unique alias of origyear used by old cite DVD-notes
	['trans_chapter'] = nil,													-- alias of trans-chapter
	['trans_title'] = nil,														-- alias of trans-title

	['Author#'] = nil,															-- non-standard capitalization
	['authors#'] = nil,															-- no need for multiple lists of author names
	['Editor#'] = nil,															-- non-standard capitalization
	['editors#'] = nil,															-- no need for multiple lists of editor names
	['EditorGiven#'] = nil,														-- non-standard capitalization
	['EditorSurname#'] = nil,													-- non-standard capitalization

]]

--[[--------------------------&lt; S U P P O R T E D   P A R A M E T E R S &gt;--------------------------------------

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local whitelist = {}

local basic_arguments = {
	['accessdate'] = true,
	['access-date'] = true,
	['agency'] = true,
	['airdate'] = true,
	['air-date'] = true,
	['archivedate'] = true,
	['archive-date'] = true,
	['archive-format'] = true,
	['archiveurl'] = true,
	['archive-url'] = true,
	['article'] = true,
	['article-format'] = true,
	['article-url'] = true,
	['article-url-access'] = true,
	['arxiv'] = true,
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['ASIN-TLD'] = false,														-- not an identifier but an identifier-modifier
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['bibcode'] = true,
	['bibcode-access'] = true,
	['biorxiv'] = true,
	['booktitle'] = true,
	['book-title'] = true,
	['cartography'] = true,
	['chapter'] = true,
	['chapter-format'] = true,
	['chapterurl'] = true,
	['chapter-url'] = true,
	['chapter-url-access'] = true,
	['citeseerx'] = true,
	['class'] = false,															-- cite arxiv only; general use deprecated
	['collaboration'] = true,
	['conference'] = true,
	['conference-format'] = true,
	['conferenceurl'] = true,
	['conference-url'] = true,
	['contribution'] = true,
	['contribution-format'] = true,
	['contributionurl'] = true,
	['contribution-url'] = true,
	['contributor'] = true,
	['contributor-first'] = true,
	['contributor-last'] = true,
	['contributor-given'] = true,
	['contributor-surname'] = true,
	['contributor-link'] = true,
	['contributor-mask'] = true,
	['credits'] = true,															-- cite episode, cite serial
	['date'] = true,
	['deadurl'] = true,
	['dead-url'] = true,
	['degree'] = true,
	['department'] = true,
	['df'] = true,
	['dictionary'] = true,
	['displayauthors'] = true,
	['display-authors'] = true,
	['displayeditors'] = true,
	['display-editors'] = true,
	['docket'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-access'] = true,
	['doi-broken'] = true,
	['doi-broken-date'] = true,
	['doi-inactive-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['editor-first'] = true,
	['editor-given'] = true,
	['editor-last'] = true,
	['editorlink'] = true,
	['editor-link'] = true,
	['editormask'] = true,
	['editor-mask'] = true,
	['editors'] = true,
	['editor-surname'] = true,
	['eissn'] = true,
	['EISSN'] = true,
	['embargo'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['entry'] = true,
	['entry-format'] = true,
	['entry-url'] = true,
	['entry-url-access'] = true,
	['episode'] = true,															-- cite serial only TODO: make available to cite episode?
	['episodelink'] = true,														-- cite episode and cite serial
	['episode-link'] = true,													-- cite episode and cite serial
	['eprint'] = true,															-- cite arxiv and arxiv identifiers
	['event'] = true,
	['event-format'] = true,
	['eventurl'] = true,
	['event-url'] = true,
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['hdl'] = true,
	['HDL'] = true,
	['hdl-access'] = true,
	['host'] = true,
	['id'] = true,
	['ID'] = true,
	['ignoreisbnerror'] = true,
	['ignore-isbn-error'] = true,
	['inset'] = true,
	['institution'] = true,
	['interviewer'] = true,
	['interviewer-first'] = true,
	['interviewer-last'] = true,
	['interviewerlink'] = true,
	['interviewer-link'] = true,
	['interviewermask'] = true,
	['interviewer-mask'] = true,
	['interviewers'] = true,
	['isbn'] = true,
	['ISBN'] = true,
	['isbn13'] = true,
	['ISBN13'] = true,
	['ismn'] = true,
	['ISMN'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['jstor-access'] = true,
	['lang'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['laydate'] = true,
	['lay-date'] = true,
	['laysource'] = true,
	['lay-source'] = true,
	['laysummary'] = true,
	['lay-summary'] = true,
	['lay-format'] = true,
	['layurl'] = true,
	['lay-url'] = true,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['magazine'] = true,
	['mailinglist'] = true,														-- cite mailing list only
	['mailing-list'] = true,													-- cite mailing list only
	['map'] = true,																-- cite map only
	['map-format'] = true,														-- cite map only
	['mapurl'] = true,															-- cite map only
	['map-url'] = true,															-- cite map only
	['medium'] = true,
	['message-id'] = true,														-- cite newsgroup
	['minutes'] = true,
	['mode'] = true,
	['mr'] = true,
	['MR'] = true,
	['name-list-format'] = true,
	['network'] = true,
	['newsgroup'] = true,
	['newspaper'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['nopp'] = true,
	['no-pp'] = true,
	['notracking'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['ol-access'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['osti-access'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['people'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['publicationdate'] = true,
	['publication-date'] = true,
	['publicationplace'] = true,
	['publication-place'] = true,
	['publisher'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['registration'] = true,
	['rfc'] = true,
	['RFC'] = true,
	['scale'] = true,
	['script-chapter'] = true,
	['script-title'] = true,
	['season'] = true,
	['section'] = true,
	['section-format'] = true,
	['sections'] = true,														-- cite map only
	['sectionurl'] = true,
	['section-url'] = true,
	['section-url-access'] = true,
	['series'] = true,
	['serieslink'] = true,
	['series-link'] = true,
	['seriesno'] = true,
	['series-no'] = true,
	['seriesnumber'] = true,
	['series-number'] = true,
	['series-separator'] = true,
	['sheet'] = true,															-- cite map only
	['sheets'] = true,															-- cite map only
	['ssrn'] = true,
	['SSRN'] = true,
	['station'] = true,
	['subject'] = true,
	['subjectlink'] = true,
	['subject-link'] = true,
	['subscription'] = true,
	['surname'] = true,
	['template-doc-demo'] = true,
	['time'] = true,
	['timecaption'] = true,
	['time-caption'] = true,
	['title'] = true,
	['titlelink'] = true,
	['title-link'] = true,
	['trans-chapter'] = true,
	['trans-map'] = true,
	['transcript'] = true,
	['transcript-format'] = true,
	['transcripturl'] = true,
	['transcript-url'] = true,
	['trans-title'] = true,
	['translator'] = true,
	['translator-first'] = true,
	['translator-last'] = true,
	['translator-given'] = true,
	['translator-surname'] = true,
	['translator-link'] = true,
	['translator-mask'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['url-access'] = true,
	['vauthors'] = true,
	['veditors'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
}

local numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['contributor#'] = true,
	['contributor-first#'] = true,
	['contributor#-first'] = true,
	['contributor-last#'] = true,
	['contributor#-last'] = true,
	['contributor-given#'] = true,
	['contributor#-given'] = true,
	['contributor-surname#'] = true,
	['contributor#-surname'] = true,
	['contributor-link#'] = true,
	['contributor#-link'] = true,
	['contributor-mask#'] = true,
	['contributor#-mask'] = true,
	['editor#'] = true,
	['editor-first#'] = true,
	['editor#-first'] = true,
	['editor#-given'] = true,
	['editor-given#'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-link#'] = true,
	['editor#link'] = true,
	['editor#-link'] = true,
	['editorlink#'] = true,
	['editor-mask#'] = true,
	['editor#mask'] = true,
	['editor#-mask'] = true,
	['editormask#'] = true,
	['editor#-surname'] = true,
	['editor-surname#'] = true,
	['first#'] = true,
	['given#'] = true,
	['interviewer#'] = true,
	['interviewer-first#'] = true,
	['interviewer#-first'] = true,
	['interviewer-last#'] = true,
	['interviewer#-last'] = true,
	['interviewer-link#'] = true,
	['interviewer#-link'] = true,
	['interviewer-mask#'] = true,
	['interviewer#-mask'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-link#'] = true,
	['subject#link'] = true,
	['subject#-link'] = true,
	['subjectlink#'] = true,
	['surname#'] = true,
	['translator#'] = true,
	['translator-first#'] = true,
	['translator#-first'] = true,
	['translator-last#'] = true,
	['translator#-last'] = true,
	['translator-given#'] = true,
	['translator#-given'] = true,
	['translator-surname#'] = true,
	['translator#-surname'] = true,
	['translator-link#'] = true,
	['translator#-link'] = true,
	['translator-mask#'] = true,
	['translator#-mask'] = true,
}

--[[--------------------------&lt; C I T E   A R X I V   S U P P O R T E D   P A R A M E T E R S &gt;----------------

Cite arXiv uses the limited set of parameters defined in the limited_basic_arguments and limited_numbered_arguments
tables.  Those lists are supplemented with this list of parameters that are exclusive to cite arXiv but not supported
by other cs1 templates that use the limited parameter set.

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

--[[
This is a list of parameters that once were but now are no longer supported:
	['ARXIV'] = nil,															-- not an initialization
	['version'] = nil,															-- this is the cite arxiv parameter; |version= still supported by other cs1|2 templates

]]

local arxiv_basic_arguments = {
	['arxiv'] = true,															-- cite arxiv and arxiv identifiers
	['class'] = true,															-- cite arxiv only
	['eprint'] = true,															-- cite arxiv and arxiv identifiers
}


--[[--------------------------&lt; C I T E   B I O R X I V   S U P P O R T E D   P A R A M E T E R S &gt;------------

Cite biorxiv uses the limited set of parameters defined in the limited_basic_arguments and limited_numbered_arguments
tables.  Those lists are supplemented with this list of parameters that are exclusive to cite biorxiv but not supported
by other cs1 templates that use the limited parameter set.

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local biorxiv_basic_arguments = {
	['biorxiv'] = true,
}


--[[--------------------------&lt; C I T E   C I T E S E E R X   S U P P O R T E D   P A R A M E T E R S &gt;--------

Cite citeseerx uses the limited set of parameters defined in the limited_basic_arguments and limited_numbered_arguments
tables.  Those lists are supplemented with this list of parameters that are exclusive to cite citeseerx but not supported
by other cs1 templates that use the limited parameter set.

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local citeseerx_basic_arguments = {
	['citeseerx'] = true,
}


--[[--------------------------&lt; L I M I T E D   S U P P O R T E D   P A R A M E T E R S &gt;----------------------

This is an experiment that attempts to use validate() and a limited list of valid parameters to validate the
parameters provided in a cite arxiv, cite biorxiv, or cite citeseerx templates.  These parameters are common to
all three templates

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local limited_basic_arguments = {
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['collaboration'] = true,
	['date'] = true,
	['df'] = true,
	['display-authors'] = true,
	['first'] = true,
	['given'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['mode'] = true,
	['name-list-format'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['notracking'] = true,
	['no-tracking'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['postscript'] = true,
	['pp'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['surname'] = true,
	['template-doc-demo'] = true,
	['title'] = true,
	['url'] = true,
	['URL'] = true,
	['vauthors'] = true,
	['year'] = true,
}
local limited_numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['surname#'] = true,
}

return {
	basic_arguments = basic_arguments,
	numbered_arguments = numbered_arguments,
	limited_basic_arguments = limited_basic_arguments,
	limited_numbered_arguments = limited_numbered_arguments,
	arxiv_basic_arguments = arxiv_basic_arguments,
	biorxiv_basic_arguments = biorxiv_basic_arguments,
	citeseerx_basic_arguments = citeseerx_basic_arguments
};</text>
      <sha1>fbkgoeol5z8rcmtcar0vscst74y6eta</sha1>
    </revision>
    <revision>
      <id>4799</id>
      <parentid>4798</parentid>
      <timestamp>2019-01-19T10:58:29Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>synch from sandbox;</comment>
      <origin>4799</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="20276" sha1="0zognkn41npd7wzljccr8o46nqqx2el" xml:space="preserve">
--[[--------------------------&lt; P A R A M E T E R S   N O T   S U P P O R T E D &gt;------------------------------

This is a list of parameters that once were but now are no longer supported:

	['albumlink'] = nil,														-- unique alias of titlelink used by old cite AV media notes
	['albumtype'] = nil,														-- controled inappropriate functionality in the old cite AV media notes
	['artist'] = nil,															-- unique alias of others used by old cite AV media notes
	['ARXIV'] = nil,															-- not an initialization
	['Author'] = nil,															-- non-standard capitalization
	['authorformat'] = nil,														-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-format'] = nil,													-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-name-separator'] = nil,											-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-separator'] = nil,													-- primarily used to support Vancouver format which functionality now part of name-list-format
	['began'] = nil,															-- module handles date ranges; cite episode and cite series
	['BIBCODE'] = nil,															-- not an initialization
	['callsign'] = nil,															-- cite interview removed
	['call-sign'] = nil,														-- cite interview removed
	['chapterlink'] = nil,														-- if ever necessary to link to a chapter article, |chapter= can be wikilinked 
	['chapter-link'] = nil,														-- 
	['city'] = nil,																-- cite interview removed
	['coauthor'] = nil,															-- redundant to |authorn=; not made part of metadata
	['coauthors'] = nil,														-- redundant to |authorn=; not made part of metadata
	['cointerviewers'] = nil,													-- unique alias of others used by old cite interview
	['day'] = nil,																-- deprecated in {{citation/core}} and somehow undeprecated in Module:Citation/CS1 and now finally removed
	['director'] = nil,															-- unique alias of author used by old cite DVD-notes
	['doi_brokendate'] = nil,    												-- alias of doi-broken-date
	['doi_inactivedate'] = nil,													-- alias of doi-inactive-date
	['DoiBroken'] = nil,														-- not used, non-standard captialization
	['Editor'] = nil,															-- non-standard capitalization
	['editorformat'] = nil,														-- primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorSurname'] = nil,													-- non-standard capitalization
	['editor-format'] = nil,													-- primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorGiven'] = nil,														-- non-standard capitalization
	['editor-name-separator'] = nil,											-- primarily used to support Vancouver format which functionality now part of name-list-format
	['editor-separator'] = nil,													-- primarily used to support Vancouver format which functionality now part of name-list-format
	['Embargo'] = nil,															-- not used, non-standard capitalization
	['ended'] = nil,															-- module handles date ranges; cite episode and cite series
	['in'] = nil,																-- ambiguous between use for language, appearance of a lesser work in an edited work
	['interviewers'] = nil,														-- only need InterviewerList support
	['month'] = nil,															-- functionality supported by |date=
	['name-separator'] = nil,													-- primarily used to support Vancouver format which functionality now part of name-list-format
	['notestitle'] = nil,														-- unique alias of chapter used by old cite AV media notes
	['PPrefix'] = nil,															-- non-standard capitalization
	['PPPrefix'] = nil,															-- not used, non-standard capitalization
	['pp-prefix'] = nil,														-- not used, not documented
	['p-prefix'] = nil,															-- not used, not documented
	['program'] = nil,															-- cite interview removed
	['publisherid'] = nil,														-- unique alias of id used by old cite AV media notes and old cite DVD-notes
	['Ref'] = nil,																-- non-standard capitalization
	['separator'] = nil,														-- this functionality now provided by |mode=
	['template doc demo'] = nil,												-- alias of template doc demo
	['titleyear'] = nil,														-- unique alias of origyear used by old cite DVD-notes
	['trans_chapter'] = nil,													-- alias of trans-chapter
	['trans_title'] = nil,														-- alias of trans-title

	['Author#'] = nil,															-- non-standard capitalization
	['authors#'] = nil,															-- no need for multiple lists of author names
	['Editor#'] = nil,															-- non-standard capitalization
	['editors#'] = nil,															-- no need for multiple lists of editor names
	['EditorGiven#'] = nil,														-- non-standard capitalization
	['EditorSurname#'] = nil,													-- non-standard capitalization

]]

--[[--------------------------&lt; S U P P O R T E D   P A R A M E T E R S &gt;--------------------------------------

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local whitelist = {}

local basic_arguments = {
	['accessdate'] = true,
	['access-date'] = true,
	['agency'] = true,
	['airdate'] = true,
	['air-date'] = true,
	['archivedate'] = true,
	['archive-date'] = true,
	['archive-format'] = true,
	['archiveurl'] = true,
	['archive-url'] = true,
	['article'] = true,
	['article-format'] = true,
	['article-url'] = true,
	['article-url-access'] = true,
	['arxiv'] = true,
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['ASIN-TLD'] = false,														-- not an identifier but an identifier-modifier
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['bibcode'] = true,
	['bibcode-access'] = true,
	['biorxiv'] = true,
	['booktitle'] = true,
	['book-title'] = true,
	['cartography'] = true,
	['chapter'] = true,
	['chapter-format'] = true,
	['chapterurl'] = true,
	['chapter-url'] = true,
	['chapter-url-access'] = true,
	['citeseerx'] = true,
	['class'] = false,															-- cite arxiv only; general use deprecated
	['collaboration'] = true,
	['conference'] = true,
	['conference-format'] = true,
	['conferenceurl'] = true,
	['conference-url'] = true,
	['contribution'] = true,
	['contribution-format'] = true,
	['contributionurl'] = true,
	['contribution-url'] = true,
	['contributor'] = true,
	['contributor-first'] = true,
	['contributor-last'] = true,
	['contributor-given'] = true,
	['contributor-surname'] = true,
	['contributor-link'] = true,
	['contributor-mask'] = true,
	['credits'] = true,															-- cite episode, cite serial
	['date'] = true,
	['deadurl'] = true,
	['dead-url'] = true,
	['degree'] = true,
	['department'] = true,
	['df'] = true,
	['dictionary'] = true,
	['displayauthors'] = true,
	['display-authors'] = true,
	['displayeditors'] = true,
	['display-editors'] = true,
	['docket'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-access'] = true,
	['doi-broken'] = true,
	['doi-broken-date'] = true,
	['doi-inactive-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['editor-first'] = true,
	['editor-given'] = true,
	['editor-last'] = true,
	['editorlink'] = true,
	['editor-link'] = true,
	['editormask'] = true,
	['editor-mask'] = true,
	['editors'] = true,
	['editor-surname'] = true,
	['eissn'] = true,
	['EISSN'] = true,
	['embargo'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['entry'] = true,
	['entry-format'] = true,
	['entry-url'] = true,
	['entry-url-access'] = true,
	['episode'] = true,															-- cite serial only TODO: make available to cite episode?
	['episodelink'] = true,														-- cite episode and cite serial
	['episode-link'] = true,													-- cite episode and cite serial
	['eprint'] = true,															-- cite arxiv and arxiv identifiers
	['event'] = true,
	['event-format'] = true,
	['eventurl'] = true,
	['event-url'] = true,
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['hdl'] = true,
	['HDL'] = true,
	['hdl-access'] = true,
	['host'] = true,
	['id'] = true,
	['ID'] = true,
	['ignoreisbnerror'] = true,
	['ignore-isbn-error'] = true,
	['inset'] = true,
	['institution'] = true,
	['interviewer'] = true,
	['interviewer-first'] = true,
	['interviewer-last'] = true,
	['interviewerlink'] = true,
	['interviewer-link'] = true,
	['interviewermask'] = true,
	['interviewer-mask'] = true,
	['isbn'] = true,
	['ISBN'] = true,
	['isbn13'] = true,
	['ISBN13'] = true,
	['ismn'] = true,
	['ISMN'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['jstor-access'] = true,
	['lang'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['laydate'] = true,
	['lay-date'] = true,
	['laysource'] = true,
	['lay-source'] = true,
	['laysummary'] = true,
	['lay-summary'] = true,
	['lay-format'] = true,
	['layurl'] = true,
	['lay-url'] = true,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['magazine'] = true,
	['mailinglist'] = true,														-- cite mailing list only
	['mailing-list'] = true,													-- cite mailing list only
	['map'] = true,																-- cite map only
	['map-format'] = true,														-- cite map only
	['mapurl'] = true,															-- cite map only
	['map-url'] = true,															-- cite map only
	['medium'] = true,
	['message-id'] = true,														-- cite newsgroup
	['minutes'] = true,
	['mode'] = true,
	['mr'] = true,
	['MR'] = true,
	['name-list-format'] = true,
	['network'] = true,
	['newsgroup'] = true,
	['newspaper'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['nopp'] = true,
	['no-pp'] = true,
	['notracking'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['ol-access'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['osti-access'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['people'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['publicationdate'] = true,
	['publication-date'] = true,
	['publicationplace'] = true,
	['publication-place'] = true,
	['publisher'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['registration'] = true,
	['rfc'] = true,
	['RFC'] = true,
	['scale'] = true,
	['script-chapter'] = true,
	['script-title'] = true,
	['season'] = true,
	['section'] = true,
	['section-format'] = true,
	['sections'] = true,														-- cite map only
	['sectionurl'] = true,
	['section-url'] = true,
	['section-url-access'] = true,
	['series'] = true,
	['serieslink'] = true,
	['series-link'] = true,
	['seriesno'] = true,
	['series-no'] = true,
	['seriesnumber'] = true,
	['series-number'] = true,
	['series-separator'] = true,
	['sheet'] = true,															-- cite map only
	['sheets'] = true,															-- cite map only
	['ssrn'] = true,
	['SSRN'] = true,
	['station'] = true,
	['subject'] = true,
	['subjectlink'] = true,
	['subject-link'] = true,
	['subscription'] = true,
	['surname'] = true,
	['template-doc-demo'] = true,
	['time'] = true,
	['timecaption'] = true,
	['time-caption'] = true,
	['title'] = true,
	['titlelink'] = true,
	['title-link'] = true,
	['trans-chapter'] = true,
	['trans-map'] = true,
	['transcript'] = true,
	['transcript-format'] = true,
	['transcripturl'] = true,
	['transcript-url'] = true,
	['trans-title'] = true,
	['translator'] = true,
	['translator-first'] = true,
	['translator-last'] = true,
	['translator-given'] = true,
	['translator-surname'] = true,
	['translator-link'] = true,
	['translator-mask'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['url-access'] = true,
	['vauthors'] = true,
	['veditors'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
}

local numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['contributor#'] = true,
	['contributor-first#'] = true,
	['contributor#-first'] = true,
	['contributor-last#'] = true,
	['contributor#-last'] = true,
	['contributor-given#'] = true,
	['contributor#-given'] = true,
	['contributor-surname#'] = true,
	['contributor#-surname'] = true,
	['contributor-link#'] = true,
	['contributor#-link'] = true,
	['contributor-mask#'] = true,
	['contributor#-mask'] = true,
	['editor#'] = true,
	['editor-first#'] = true,
	['editor#-first'] = true,
	['editor#-given'] = true,
	['editor-given#'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-link#'] = true,
	['editor#link'] = true,
	['editor#-link'] = true,
	['editorlink#'] = true,
	['editor-mask#'] = true,
	['editor#mask'] = true,
	['editor#-mask'] = true,
	['editormask#'] = true,
	['editor#-surname'] = true,
	['editor-surname#'] = true,
	['first#'] = true,
	['given#'] = true,
	['interviewer#'] = true,
	['interviewer-first#'] = true,
	['interviewer#-first'] = true,
	['interviewer-last#'] = true,
	['interviewer#-last'] = true,
	['interviewer-link#'] = true,
	['interviewer#-link'] = true,
	['interviewer-mask#'] = true,
	['interviewer#-mask'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-link#'] = true,
	['subject#link'] = true,
	['subject#-link'] = true,
	['subjectlink#'] = true,
	['surname#'] = true,
	['translator#'] = true,
	['translator-first#'] = true,
	['translator#-first'] = true,
	['translator-last#'] = true,
	['translator#-last'] = true,
	['translator-given#'] = true,
	['translator#-given'] = true,
	['translator-surname#'] = true,
	['translator#-surname'] = true,
	['translator-link#'] = true,
	['translator#-link'] = true,
	['translator-mask#'] = true,
	['translator#-mask'] = true,
}

--[[--------------------------&lt; C I T E   A R X I V   S U P P O R T E D   P A R A M E T E R S &gt;----------------

Cite arXiv uses the limited set of parameters defined in the limited_basic_arguments and limited_numbered_arguments
tables.  Those lists are supplemented with this list of parameters that are exclusive to cite arXiv but not supported
by other cs1 templates that use the limited parameter set.

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

--[[
This is a list of parameters that once were but now are no longer supported:
	['ARXIV'] = nil,															-- not an initialization
	['version'] = nil,															-- this is the cite arxiv parameter; |version= still supported by other cs1|2 templates

]]

local arxiv_basic_arguments = {
	['arxiv'] = true,															-- cite arxiv and arxiv identifiers
	['class'] = true,															-- cite arxiv only
	['eprint'] = true,															-- cite arxiv and arxiv identifiers
}


--[[--------------------------&lt; C I T E   B I O R X I V   S U P P O R T E D   P A R A M E T E R S &gt;------------

Cite biorxiv uses the limited set of parameters defined in the limited_basic_arguments and limited_numbered_arguments
tables.  Those lists are supplemented with this list of parameters that are exclusive to cite biorxiv but not supported
by other cs1 templates that use the limited parameter set.

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local biorxiv_basic_arguments = {
	['biorxiv'] = true,
}


--[[--------------------------&lt; C I T E   C I T E S E E R X   S U P P O R T E D   P A R A M E T E R S &gt;--------

Cite citeseerx uses the limited set of parameters defined in the limited_basic_arguments and limited_numbered_arguments
tables.  Those lists are supplemented with this list of parameters that are exclusive to cite citeseerx but not supported
by other cs1 templates that use the limited parameter set.

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local citeseerx_basic_arguments = {
	['citeseerx'] = true,
}


--[[--------------------------&lt; L I M I T E D   S U P P O R T E D   P A R A M E T E R S &gt;----------------------

This is an experiment that attempts to use validate() and a limited list of valid parameters to validate the
parameters provided in a cite arxiv, cite biorxiv, or cite citeseerx templates.  These parameters are common to
all three templates

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local limited_basic_arguments = {
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['collaboration'] = true,
	['date'] = true,
	['df'] = true,
	['display-authors'] = true,
	['first'] = true,
	['given'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['mode'] = true,
	['name-list-format'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['notracking'] = true,
	['no-tracking'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['postscript'] = true,
	['pp'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['surname'] = true,
	['template-doc-demo'] = true,
	['title'] = true,
	['url'] = true,
	['URL'] = true,
	['vauthors'] = true,
	['year'] = true,
}
local limited_numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['surname#'] = true,
}

return {
	basic_arguments = basic_arguments,
	numbered_arguments = numbered_arguments,
	limited_basic_arguments = limited_basic_arguments,
	limited_numbered_arguments = limited_numbered_arguments,
	arxiv_basic_arguments = arxiv_basic_arguments,
	biorxiv_basic_arguments = biorxiv_basic_arguments,
	citeseerx_basic_arguments = citeseerx_basic_arguments
};</text>
      <sha1>0zognkn41npd7wzljccr8o46nqqx2el</sha1>
    </revision>
    <revision>
      <id>4800</id>
      <parentid>4799</parentid>
      <timestamp>2019-04-20T13:20:17Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4800</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="20546" sha1="echferh8dk4p5fpgymsbv65whn33w44" xml:space="preserve">
--[[--------------------------&lt; P A R A M E T E R S   N O T   S U P P O R T E D &gt;------------------------------

This is a list of parameters that once were but now are no longer supported:

	['albumlink'] = nil,														-- unique alias of titlelink used by old cite AV media notes
	['albumtype'] = nil,														-- controled inappropriate functionality in the old cite AV media notes
	['artist'] = nil,															-- unique alias of others used by old cite AV media notes
	['ARXIV'] = nil,															-- not an initialization
	['Author'] = nil,															-- non-standard capitalization
	['authorformat'] = nil,														-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-format'] = nil,													-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-name-separator'] = nil,											-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-separator'] = nil,													-- primarily used to support Vancouver format which functionality now part of name-list-format
	['began'] = nil,															-- module handles date ranges; cite episode and cite series
	['BIBCODE'] = nil,															-- not an initialization
	['callsign'] = nil,															-- cite interview removed
	['call-sign'] = nil,														-- cite interview removed
	['chapterlink'] = nil,														-- if ever necessary to link to a chapter article, |chapter= can be wikilinked 
	['chapter-link'] = nil,														-- 
	['city'] = nil,																-- cite interview removed
	['coauthor'] = nil,															-- redundant to |authorn=; not made part of metadata
	['coauthors'] = nil,														-- redundant to |authorn=; not made part of metadata
	['cointerviewers'] = nil,													-- unique alias of others used by old cite interview
	['day'] = nil,																-- deprecated in {{citation/core}} and somehow undeprecated in Module:Citation/CS1 and now finally removed
	['director'] = nil,															-- unique alias of author used by old cite DVD-notes
	['doi_brokendate'] = nil,    												-- alias of doi-broken-date
	['doi_inactivedate'] = nil,													-- alias of doi-inactive-date
	['DoiBroken'] = nil,														-- not used, non-standard captialization
	['Editor'] = nil,															-- non-standard capitalization
	['editorformat'] = nil,														-- primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorSurname'] = nil,													-- non-standard capitalization
	['editor-format'] = nil,													-- primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorGiven'] = nil,														-- non-standard capitalization
	['editor-name-separator'] = nil,											-- primarily used to support Vancouver format which functionality now part of name-list-format
	['editor-separator'] = nil,													-- primarily used to support Vancouver format which functionality now part of name-list-format
	['Embargo'] = nil,															-- not used, non-standard capitalization
	['ended'] = nil,															-- module handles date ranges; cite episode and cite series
	['in'] = nil,																-- ambiguous between use for language, appearance of a lesser work in an edited work
	['interviewers'] = nil,														-- only need InterviewerList support
	['month'] = nil,															-- functionality supported by |date=
	['name-separator'] = nil,													-- primarily used to support Vancouver format which functionality now part of name-list-format
	['notestitle'] = nil,														-- unique alias of chapter used by old cite AV media notes
	['PPrefix'] = nil,															-- non-standard capitalization
	['PPPrefix'] = nil,															-- not used, non-standard capitalization
	['pp-prefix'] = nil,														-- not used, not documented
	['p-prefix'] = nil,															-- not used, not documented
	['program'] = nil,															-- cite interview removed
	['publisherid'] = nil,														-- unique alias of id used by old cite AV media notes and old cite DVD-notes
	['Ref'] = nil,																-- non-standard capitalization
	['separator'] = nil,														-- this functionality now provided by |mode=
	['template doc demo'] = nil,												-- alias of template doc demo
	['titleyear'] = nil,														-- unique alias of origyear used by old cite DVD-notes
	['trans_chapter'] = nil,													-- alias of trans-chapter
	['trans_title'] = nil,														-- alias of trans-title

	['Author#'] = nil,															-- non-standard capitalization
	['authors#'] = nil,															-- no need for multiple lists of author names
	['Editor#'] = nil,															-- non-standard capitalization
	['editors#'] = nil,															-- no need for multiple lists of editor names
	['EditorGiven#'] = nil,														-- non-standard capitalization
	['EditorSurname#'] = nil,													-- non-standard capitalization

]]


--[[--------------------------&lt; S U P P O R T E D   P A R A M E T E R S &gt;--------------------------------------

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local whitelist = {}

local basic_arguments = {
	['accessdate'] = true,
	['access-date'] = true,
	['agency'] = true,
	['airdate'] = true,
	['air-date'] = true,
	['archivedate'] = true,
	['archive-date'] = true,
	['archive-format'] = true,
	['archiveurl'] = true,
	['archive-url'] = true,
	['article'] = true,
	['article-format'] = true,
	['article-url'] = true,
	['article-url-access'] = true,
	['arxiv'] = true,
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['ASIN-TLD'] = false,														-- not an identifier but an identifier-modifier
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['bibcode'] = true,
	['bibcode-access'] = true,
	['biorxiv'] = true,
	['booktitle'] = true,
	['book-title'] = true,
	['cartography'] = true,
	['chapter'] = true,
	['chapter-format'] = true,
	['chapterurl'] = true,
	['chapter-url'] = true,
	['chapter-url-access'] = true,
	['citeseerx'] = true,
	['class'] = false,															-- cite arxiv only; general use deprecated
	['collaboration'] = true,
	['conference'] = true,
	['conference-format'] = true,
	['conferenceurl'] = true,
	['conference-url'] = true,
	['contribution'] = true,
	['contribution-format'] = true,
	['contributionurl'] = true,
	['contribution-url'] = true,
	['contributor'] = true,
	['contributor-first'] = true,
	['contributor-last'] = true,
	['contributor-given'] = true,
	['contributor-surname'] = true,
	['contributor-link'] = true,
	['contributor-mask'] = true,
	['credits'] = true,															-- cite episode, cite serial
	['date'] = true,
	['deadurl'] = true,
	['dead-url'] = true,
	['degree'] = true,
	['department'] = true,
	['df'] = true,
	['dictionary'] = true,
	['displayauthors'] = true,
	['display-authors'] = true,
	['display-contributors'] = true,
	['displayeditors'] = true,
	['display-editors'] = true,
	['display-interviewers'] = true,
	['display-translators'] = true,
	['docket'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-access'] = true,
	['doi-broken'] = true,
	['doi-broken-date'] = true,
	['doi-inactive-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['editor-first'] = true,
	['editor-given'] = true,
	['editor-last'] = true,
	['editorlink'] = true,
	['editor-link'] = true,
	['editormask'] = true,
	['editor-mask'] = true,
	['editors'] = true,
	['editor-surname'] = true,
	['eissn'] = true,
	['EISSN'] = true,
	['embargo'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['entry'] = true,
	['entry-format'] = true,
	['entry-url'] = true,
	['entry-url-access'] = true,
	['episode'] = true,															-- cite serial only TODO: make available to cite episode?
	['episodelink'] = true,														-- cite episode and cite serial
	['episode-link'] = true,													-- cite episode and cite serial
	['eprint'] = true,															-- cite arxiv and arxiv identifiers
	['event'] = true,
	['event-format'] = true,
	['eventurl'] = true,
	['event-url'] = true,
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['hdl'] = true,
	['HDL'] = true,
	['hdl-access'] = true,
	['host'] = true,
	['id'] = true,
	['ID'] = true,
	['ignoreisbnerror'] = true,
	['ignore-isbn-error'] = true,
	['inset'] = true,
	['institution'] = true,
	['interviewer'] = true,
	['interviewer-first'] = true,
	['interviewer-last'] = true,
	['interviewerlink'] = true,
	['interviewer-link'] = true,
	['interviewermask'] = true,
	['interviewer-mask'] = true,
	['isbn'] = true,
	['ISBN'] = true,
	['isbn13'] = true,
	['ISBN13'] = true,
	['ismn'] = true,
	['ISMN'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['jstor-access'] = true,
	['lang'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['laydate'] = true,
	['lay-date'] = true,
	['laysource'] = true,
	['lay-source'] = true,
	['laysummary'] = true,
	['lay-summary'] = true,
	['lay-format'] = true,
	['layurl'] = true,
	['lay-url'] = true,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['magazine'] = true,
	['mailinglist'] = true,														-- cite mailing list only
	['mailing-list'] = true,													-- cite mailing list only
	['map'] = true,																-- cite map only
	['map-format'] = true,														-- cite map only
	['mapurl'] = true,															-- cite map only
	['map-url'] = true,															-- cite map only
	['medium'] = true,
	['message-id'] = true,														-- cite newsgroup
	['minutes'] = true,
	['mode'] = true,
	['mr'] = true,
	['MR'] = true,
	['name-list-format'] = true,
	['network'] = true,
	['newsgroup'] = true,
	['newspaper'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['nopp'] = true,
	['no-pp'] = true,
	['notracking'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['ol-access'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['osti-access'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['people'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['publicationdate'] = true,
	['publication-date'] = true,
	['publicationplace'] = true,
	['publication-place'] = true,
	['publisher'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['registration'] = false,
	['rfc'] = true,
	['RFC'] = true,
	['scale'] = true,
	['script-chapter'] = true,
	['script-title'] = true,
	['season'] = true,
	['section'] = true,
	['section-format'] = true,
	['sections'] = true,														-- cite map only
	['sectionurl'] = true,
	['section-url'] = true,
	['section-url-access'] = true,
	['series'] = true,
	['serieslink'] = true,
	['series-link'] = true,
	['seriesno'] = true,
	['series-no'] = true,
	['seriesnumber'] = true,
	['series-number'] = true,
	['series-separator'] = true,
	['sheet'] = true,															-- cite map only
	['sheets'] = true,															-- cite map only
	['ssrn'] = true,
	['SSRN'] = true,
	['station'] = true,
	['subject'] = true,
	['subjectlink'] = true,
	['subject-link'] = true,
	['subscription'] = false,
	['surname'] = true,
	['template-doc-demo'] = true,
	['time'] = true,
	['timecaption'] = true,
	['time-caption'] = true,
	['title'] = true,
	['titlelink'] = true,
	['title-link'] = true,
	['trans-chapter'] = true,
	['trans-map'] = true,
	['transcript'] = true,
	['transcript-format'] = true,
	['transcripturl'] = true,
	['transcript-url'] = true,
	['trans-title'] = true,
	['translator'] = true,
	['translator-first'] = true,
	['translator-last'] = true,
	['translator-given'] = true,
	['translator-surname'] = true,
	['translator-link'] = true,
	['translator-mask'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['url-access'] = true,
	['vauthors'] = true,
	['veditors'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
}

local numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['contributor#'] = true,
	['contributor-first#'] = true,
	['contributor#-first'] = true,
	['contributor-last#'] = true,
	['contributor#-last'] = true,
	['contributor-given#'] = true,
	['contributor#-given'] = true,
	['contributor-surname#'] = true,
	['contributor#-surname'] = true,
	['contributor-link#'] = true,
	['contributor#-link'] = true,
	['contributor-mask#'] = true,
	['contributor#-mask'] = true,
	['editor#'] = true,
	['editor-first#'] = true,
	['editor#-first'] = true,
	['editor#-given'] = true,
	['editor-given#'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-link#'] = true,
	['editor#link'] = true,
	['editor#-link'] = true,
	['editorlink#'] = true,
	['editor-mask#'] = true,
	['editor#mask'] = true,
	['editor#-mask'] = true,
	['editormask#'] = true,
	['editor#-surname'] = true,
	['editor-surname#'] = true,
	['first#'] = true,
	['given#'] = true,
	['host#'] = true,
	['interviewer#'] = true,
	['interviewer-first#'] = true,
	['interviewer#-first'] = true,
	['interviewer-last#'] = true,
	['interviewer#-last'] = true,
	['interviewer-link#'] = true,
	['interviewer#-link'] = true,
	['interviewer-mask#'] = true,
	['interviewer#-mask'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-link#'] = true,
	['subject#link'] = true,
	['subject#-link'] = true,
	['subjectlink#'] = true,
	['surname#'] = true,
	['translator#'] = true,
	['translator-first#'] = true,
	['translator#-first'] = true,
	['translator-last#'] = true,
	['translator#-last'] = true,
	['translator-given#'] = true,
	['translator#-given'] = true,
	['translator-surname#'] = true,
	['translator#-surname'] = true,
	['translator-link#'] = true,
	['translator#-link'] = true,
	['translator-mask#'] = true,
	['translator#-mask'] = true,
}


--[[--------------------------&lt; C I T E   A R X I V   S U P P O R T E D   P A R A M E T E R S &gt;----------------

Cite arXiv uses the limited set of parameters defined in the limited_basic_arguments and limited_numbered_arguments
tables.  Those lists are supplemented with this list of parameters that are exclusive to cite arXiv but not supported
by other cs1 templates that use the limited parameter set.

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

--[[
This is a list of parameters that once were but now are no longer supported:
	['ARXIV'] = nil,															-- not an initialization
	['version'] = nil,															-- this is the cite arxiv parameter; |version= still supported by other cs1|2 templates

]]

local arxiv_basic_arguments = {
	['arxiv'] = true,															-- cite arxiv and arxiv identifiers
	['class'] = true,															-- cite arxiv only
	['eprint'] = true,															-- cite arxiv and arxiv identifiers
}


--[[--------------------------&lt; C I T E   B I O R X I V   S U P P O R T E D   P A R A M E T E R S &gt;------------

Cite biorxiv uses the limited set of parameters defined in the limited_basic_arguments and limited_numbered_arguments
tables.  Those lists are supplemented with this list of parameters that are exclusive to cite biorxiv but not supported
by other cs1 templates that use the limited parameter set.

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local biorxiv_basic_arguments = {
	['biorxiv'] = true,
}


--[[--------------------------&lt; C I T E   C I T E S E E R X   S U P P O R T E D   P A R A M E T E R S &gt;--------

Cite citeseerx uses the limited set of parameters defined in the limited_basic_arguments and limited_numbered_arguments
tables.  Those lists are supplemented with this list of parameters that are exclusive to cite citeseerx but not supported
by other cs1 templates that use the limited parameter set.

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local citeseerx_basic_arguments = {
	['citeseerx'] = true,
}


--[[--------------------------&lt; L I M I T E D   S U P P O R T E D   P A R A M E T E R S &gt;----------------------

This is an experiment that attempts to use validate() and a limited list of valid parameters to validate the
parameters provided in a cite arxiv, cite biorxiv, or cite citeseerx templates.  These parameters are common to
all three templates

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local limited_basic_arguments = {
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['collaboration'] = true,
	['date'] = true,
	['df'] = true,
	['displayauthors'] = true,
	['display-authors'] = true,
	['first'] = true,
	['given'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['mode'] = true,
	['name-list-format'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['notracking'] = true,
	['no-tracking'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['postscript'] = true,
	['pp'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['surname'] = true,
	['template-doc-demo'] = true,
	['title'] = true,
	['url'] = true,
	['URL'] = true,
	['vauthors'] = true,
	['year'] = true,
}

local limited_numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['surname#'] = true,
}


--[[--------------------------&lt; E X P O R T E D   T A B L E S &gt;------------------------------------------------
]]

return {
	basic_arguments = basic_arguments,
	numbered_arguments = numbered_arguments,
	limited_basic_arguments = limited_basic_arguments,
	limited_numbered_arguments = limited_numbered_arguments,
	arxiv_basic_arguments = arxiv_basic_arguments,
	biorxiv_basic_arguments = biorxiv_basic_arguments,
	citeseerx_basic_arguments = citeseerx_basic_arguments
};</text>
      <sha1>echferh8dk4p5fpgymsbv65whn33w44</sha1>
    </revision>
    <revision>
      <id>4801</id>
      <parentid>4800</parentid>
      <timestamp>2019-09-03T11:05:59Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4801</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="20339" sha1="94febqn4uu908bdzvywj54j5ao93d43" xml:space="preserve">
--[[--------------------------&lt; P A R A M E T E R S   N O T   S U P P O R T E D &gt;------------------------------

This is a list of parameters that once were but now are no longer supported:

	['albumlink'] = nil,														-- unique alias of titlelink used by old cite AV media notes
	['albumtype'] = nil,														-- controled inappropriate functionality in the old cite AV media notes
	['artist'] = nil,															-- unique alias of others used by old cite AV media notes
	['ARXIV'] = nil,															-- not an initialization
	['Author'] = nil,															-- non-standard capitalization
	['authorformat'] = nil,														-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-format'] = nil,													-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-name-separator'] = nil,											-- primarily used to support Vancouver format which functionality now part of name-list-format
	['author-separator'] = nil,													-- primarily used to support Vancouver format which functionality now part of name-list-format
	['began'] = nil,															-- module handles date ranges; cite episode and cite series
	['BIBCODE'] = nil,															-- not an initialization
	['callsign'] = nil,															-- cite interview removed
	['call-sign'] = nil,														-- cite interview removed
	['chapterlink'] = nil,														-- if ever necessary to link to a chapter article, |chapter= can be wikilinked 
	['chapter-link'] = nil,														-- 
	['city'] = nil,																-- cite interview removed
	['coauthor'] = nil,															-- redundant to |authorn=; not made part of metadata
	['coauthors'] = nil,														-- redundant to |authorn=; not made part of metadata
	['cointerviewers'] = nil,													-- unique alias of others used by old cite interview
	['day'] = nil,																-- deprecated in {{citation/core}} and somehow undeprecated in Module:Citation/CS1 and now finally removed
	['director'] = nil,															-- unique alias of author used by old cite DVD-notes
	['doi_brokendate'] = nil,    												-- alias of doi-broken-date
	['doi_inactivedate'] = nil,													-- alias of doi-inactive-date
	['DoiBroken'] = nil,														-- not used, non-standard captialization
	['Editor'] = nil,															-- non-standard capitalization
	['editorformat'] = nil,														-- primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorSurname'] = nil,													-- non-standard capitalization
	['editor-format'] = nil,													-- primarily used to support Vancouver format which functionality now part of name-list-format
	['EditorGiven'] = nil,														-- non-standard capitalization
	['editor-name-separator'] = nil,											-- primarily used to support Vancouver format which functionality now part of name-list-format
	['editor-separator'] = nil,													-- primarily used to support Vancouver format which functionality now part of name-list-format
	['Embargo'] = nil,															-- not used, non-standard capitalization
	['ended'] = nil,															-- module handles date ranges; cite episode and cite series
	['in'] = nil,																-- ambiguous between use for language, appearance of a lesser work in an edited work
	['interviewers'] = nil,														-- only need InterviewerList support
	['month'] = nil,															-- functionality supported by |date=
	['name-separator'] = nil,													-- primarily used to support Vancouver format which functionality now part of name-list-format
	['notestitle'] = nil,														-- unique alias of chapter used by old cite AV media notes
	['PPrefix'] = nil,															-- non-standard capitalization
	['PPPrefix'] = nil,															-- not used, non-standard capitalization
	['pp-prefix'] = nil,														-- not used, not documented
	['p-prefix'] = nil,															-- not used, not documented
	['program'] = nil,															-- cite interview removed
	['publisherid'] = nil,														-- unique alias of id used by old cite AV media notes and old cite DVD-notes
	['Ref'] = nil,																-- non-standard capitalization
	['separator'] = nil,														-- this functionality now provided by |mode=
	['template doc demo'] = nil,												-- alias of template doc demo
	['titleyear'] = nil,														-- unique alias of origyear used by old cite DVD-notes
	['trans_chapter'] = nil,													-- alias of trans-chapter
	['trans_title'] = nil,														-- alias of trans-title

	['Author#'] = nil,															-- non-standard capitalization
	['authors#'] = nil,															-- no need for multiple lists of author names
	['Editor#'] = nil,															-- non-standard capitalization
	['editors#'] = nil,															-- no need for multiple lists of editor names
	['EditorGiven#'] = nil,														-- non-standard capitalization
	['EditorSurname#'] = nil,													-- non-standard capitalization

]]


--[[--------------------------&lt; S U P P O R T E D   P A R A M E T E R S &gt;--------------------------------------

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local whitelist = {}

local basic_arguments = {
	['accessdate'] = true,
	['access-date'] = true,
	['agency'] = true,
	['airdate'] = true,
	['air-date'] = true,
	['archivedate'] = true,
	['archive-date'] = true,
	['archive-format'] = true,
	['archiveurl'] = true,
	['archive-url'] = true,
	['article'] = true,
	['article-format'] = true,
	['article-url'] = true,
	['article-url-access'] = true,
	['arxiv'] = true,
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['ASIN-TLD'] = false,														-- not an identifier but an identifier-modifier
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['bibcode'] = true,
	['bibcode-access'] = true,
	['biorxiv'] = true,
	['booktitle'] = true,
	['book-title'] = true,
	['cartography'] = true,
	['chapter'] = true,
	['chapter-format'] = true,
	['chapterurl'] = true,
	['chapter-url'] = true,
	['chapter-url-access'] = true,
	['citeseerx'] = true,
	['class'] = false,															-- cite arxiv only; general use deprecated
	['collaboration'] = true,
	['conference'] = true,
	['conference-format'] = true,
	['conferenceurl'] = true,
	['conference-url'] = true,
	['contribution'] = true,
	['contribution-format'] = true,
	['contributionurl'] = true,
	['contribution-url'] = true,
	['contribution-url-access'] = true,
	['contributor'] = true,
	['contributor-first'] = true,
	['contributor-last'] = true,
	['contributor-given'] = true,
	['contributor-surname'] = true,
	['contributor-link'] = true,
	['contributor-mask'] = true,
	['credits'] = true,															-- cite episode, cite serial
	['date'] = true,
	['deadurl'] = false,
	['dead-url'] = false,
	['degree'] = true,
	['department'] = true,
	['df'] = true,
	['dictionary'] = true,
	['displayauthors'] = true,
	['display-authors'] = true,
	['display-contributors'] = true,
	['displayeditors'] = true,
	['display-editors'] = true,
	['display-interviewers'] = true,
	['display-translators'] = true,
	['docket'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-access'] = true,
	['doi-broken'] = true,
	['doi-broken-date'] = true,
	['doi-inactive-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['editor-first'] = true,
	['editor-given'] = true,
	['editor-last'] = true,
	['editorlink'] = true,
	['editor-link'] = true,
	['editormask'] = true,
	['editor-mask'] = true,
	['editors'] = true,
	['editor-surname'] = true,
	['eissn'] = true,
	['EISSN'] = true,
	['embargo'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['entry'] = true,
	['entry-format'] = true,
	['entry-url'] = true,
	['entry-url-access'] = true,
	['episode'] = true,															-- cite serial only TODO: make available to cite episode?
	['episodelink'] = true,														-- cite episode and cite serial
	['episode-link'] = true,													-- cite episode and cite serial
	['eprint'] = true,															-- cite arxiv and arxiv identifiers
	['event'] = true,
	['event-format'] = true,
	['eventurl'] = true,
	['event-url'] = true,
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['hdl'] = true,
	['HDL'] = true,
	['hdl-access'] = true,
	['host'] = true,
	['id'] = true,
	['ID'] = true,
	['ignoreisbnerror'] = true,
	['ignore-isbn-error'] = true,
	['inset'] = true,
	['institution'] = true,
	['interviewer'] = true,
	['interviewer-first'] = true,
	['interviewer-last'] = true,
	['interviewerlink'] = true,
	['interviewer-link'] = true,
	['interviewermask'] = true,
	['interviewer-mask'] = true,
	['isbn'] = true,
	['ISBN'] = true,
	['isbn13'] = true,
	['ISBN13'] = true,
	['ismn'] = true,
	['ISMN'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['jstor-access'] = true,
	['lang'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['laydate'] = true,
	['lay-date'] = true,
	['laysource'] = true,
	['lay-source'] = true,
	['laysummary'] = false,
	['lay-summary'] = false,
	['lay-format'] = true,
	['layurl'] = true,
	['lay-url'] = true,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['magazine'] = true,
	['mailinglist'] = true,														-- cite mailing list only
	['mailing-list'] = true,													-- cite mailing list only
	['map'] = true,																-- cite map only
	['map-format'] = true,														-- cite map only
	['mapurl'] = true,															-- cite map only
	['map-url'] = true,															-- cite map only
	['map-url-access'] = true,													-- cite map only
	['medium'] = true,
	['message-id'] = true,														-- cite newsgroup
	['minutes'] = true,
	['mode'] = true,
	['mr'] = true,
	['MR'] = true,
	['name-list-format'] = true,
	['network'] = true,
	['newsgroup'] = true,
	['newspaper'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['nopp'] = true,
	['no-pp'] = true,
	['notracking'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['ol-access'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['osti-access'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['people'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['publicationdate'] = true,
	['publication-date'] = true,
	['publicationplace'] = true,
	['publication-place'] = true,
	['publisher'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['registration'] = false,
	['rfc'] = true,
	['RFC'] = true,
	['scale'] = true,
	['script-article'] = true,
	['script-chapter'] = true,
	['script-contribution'] = true,
	['script-entry'] = true,
	['script-journal'] = true,
	['script-magazine'] = true,
	['script-newspaper'] = true,
	['script-periodical'] = true,
	['script-section'] = true,
	['script-title'] = true,
	['script-website'] = true,
	['script-work'] = true,
	['season'] = true,
	['section'] = true,
	['section-format'] = true,
	['sections'] = true,														-- cite map only
	['sectionurl'] = true,
	['section-url'] = true,
	['section-url-access'] = true,
	['series'] = true,
	['serieslink'] = true,
	['series-link'] = true,
	['seriesno'] = true,
	['series-no'] = true,
	['seriesnumber'] = true,
	['series-number'] = true,
	['series-separator'] = true,
	['sheet'] = true,															-- cite map only
	['sheets'] = true,															-- cite map only
	['ssrn'] = true,
	['SSRN'] = true,
	['station'] = true,
	['subject'] = true,
	['subjectlink'] = true,
	['subject-link'] = true,
	['subscription'] = false,
	['surname'] = true,
	['template-doc-demo'] = true,
	['time'] = true,
	['timecaption'] = true,
	['time-caption'] = true,
	['title'] = true,
	['titlelink'] = true,
	['title-link'] = true,
	['trans-map'] = true,
	['transcript'] = true,
	['transcript-format'] = true,
	['transcripturl'] = true,
	['transcript-url'] = true,
	['translator'] = true,
	['translator-first'] = true,
	['translator-last'] = true,
	['translator-given'] = true,
	['translator-surname'] = true,
	['translator-link'] = true,
	['translator-mask'] = true,
	['trans-article'] = true,
	['trans-chapter'] = true,
	['trans-contribution'] = true,
	['trans-entry'] = true,
	['trans-journal'] = true,
	['trans-magazine'] = true,
	['trans-newspaper'] = true,
	['trans-periodical'] = true,
	['trans-section'] = true,
	['trans-title'] = true,
	['trans-website'] = true,
	['trans-work'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['url-access'] = true,
	['url-status'] = true,
	['vauthors'] = true,
	['veditors'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
}

local numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['contributor#'] = true,
	['contributor-first#'] = true,
	['contributor#-first'] = true,
	['contributor-last#'] = true,
	['contributor#-last'] = true,
	['contributor-given#'] = true,
	['contributor#-given'] = true,
	['contributor-surname#'] = true,
	['contributor#-surname'] = true,
	['contributor-link#'] = true,
	['contributor#-link'] = true,
	['contributor-mask#'] = true,
	['contributor#-mask'] = true,
	['editor#'] = true,
	['editor-first#'] = true,
	['editor#-first'] = true,
	['editor#-given'] = true,
	['editor-given#'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-link#'] = true,
	['editor#link'] = true,
	['editor#-link'] = true,
	['editorlink#'] = true,
	['editor-mask#'] = true,
	['editor#mask'] = true,
	['editor#-mask'] = true,
	['editormask#'] = true,
	['editor#-surname'] = true,
	['editor-surname#'] = true,
	['first#'] = true,
	['given#'] = true,
	['host#'] = true,
	['interviewer#'] = true,
	['interviewer-first#'] = true,
	['interviewer#-first'] = true,
	['interviewer-last#'] = true,
	['interviewer#-last'] = true,
	['interviewer-link#'] = true,
	['interviewer#-link'] = true,
	['interviewer-mask#'] = true,
	['interviewer#-mask'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-link#'] = true,
	['subject#link'] = true,
	['subject#-link'] = true,
	['subjectlink#'] = true,
	['surname#'] = true,
	['translator#'] = true,
	['translator-first#'] = true,
	['translator#-first'] = true,
	['translator-last#'] = true,
	['translator#-last'] = true,
	['translator-given#'] = true,
	['translator#-given'] = true,
	['translator-surname#'] = true,
	['translator#-surname'] = true,
	['translator-link#'] = true,
	['translator#-link'] = true,
	['translator-mask#'] = true,
	['translator#-mask'] = true,
}


--[[--------------------------&lt; P R E P R I N T   S U P P O R T E D   P A R A M E T E R S &gt;--------------------

Cite arXiv, cite biorxiv, cite citeseerx, and cite ssrn are preprint templates that use the limited set of parameters
defined in the limited_basic_arguments and limited_numbered_arguments tables.  Those lists are supplemented with a
template-specific list of parameters that are required by the particular template and may be exclusive to one of the
proeprint templates.  Some of these parameters may also be available to the general cs1|2 templates.

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

--[[--------------------------&lt; C I T E   A R X I V &gt;----------------------------------------------------------

This is a list of parameters that once were but now are no longer supported:
	['ARXIV'] = nil,															-- not an initialization
	['version'] = nil,															-- this is the cite arxiv parameter; |version= still supported by other cs1|2 templates

]]

local arxiv_basic_arguments = {
	['arxiv'] = true,															-- cite arxiv and arxiv identifiers
	['class'] = true,															-- cite arxiv only
	['eprint'] = true,															-- cite arxiv and arxiv identifiers
}


--[[--------------------------&lt; C I T E   B I O R X I V &gt;------------------------------------------------------

]]

local biorxiv_basic_arguments = {
	['biorxiv'] = true,
}


--[[--------------------------&lt; C I T E   C I T E S E E R X &gt;--------------------------------------------------

]]

local citeseerx_basic_arguments = {
	['citeseerx'] = true,
}


--[[--------------------------&lt; C I T E   S S R N &gt;------------------------------------------------------------

]]

local ssrn_basic_arguments = {
	['ssrn'] = true,
	['SSRN'] = true,
}


--[[--------------------------&lt; L I M I T E D   S U P P O R T E D   P A R A M E T E R S &gt;----------------------

This is an experiment that attempts to use validate() and a limited list of valid parameters to validate the
parameters provided in a cite arxiv, cite biorxiv, or cite citeseerx templates.  These parameters are common to
all three templates

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported (when setting a parameter to nil, leave a comment stating the reasons for invalidating the parameter)
	
]]

local limited_basic_arguments = {
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['collaboration'] = true,
	['date'] = true,
	['df'] = true,
	['displayauthors'] = true,
	['display-authors'] = true,
	['first'] = true,
	['given'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['mode'] = true,
	['name-list-format'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['notracking'] = true,
	['no-tracking'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['postscript'] = true,
	['pp'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['surname'] = true,
	['template-doc-demo'] = true,
	['title'] = true,
	['url'] = true,
	['URL'] = true,
	['vauthors'] = true,
	['year'] = true,
}

local limited_numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['surname#'] = true,
}


--[[--------------------------&lt; E X P O R T E D   T A B L E S &gt;------------------------------------------------
]]

return {
	basic_arguments = basic_arguments,
	numbered_arguments = numbered_arguments,
	limited_basic_arguments = limited_basic_arguments,
	limited_numbered_arguments = limited_numbered_arguments,
	arxiv_basic_arguments = arxiv_basic_arguments,
	biorxiv_basic_arguments = biorxiv_basic_arguments,
	citeseerx_basic_arguments = citeseerx_basic_arguments,
	ssrn_basic_arguments = ssrn_basic_arguments
	};</text>
      <sha1>94febqn4uu908bdzvywj54j5ao93d43</sha1>
    </revision>
    <revision>
      <id>4802</id>
      <parentid>4801</parentid>
      <timestamp>2020-01-11T12:32:50Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4802</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="13961" sha1="r0u1d2o5c4d87ppncjwj6wm71bmh2sl" xml:space="preserve">
--[[--------------------------&lt; S U P P O R T E D   P A R A M E T E R S &gt;--------------------------------------

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported. remove entirely
	
]]

local whitelist = {}

local basic_arguments = {
	['accessdate'] = true,
	['access-date'] = true,
	['agency'] = true,
	['airdate'] = true,
	['air-date'] = true,
	['archivedate'] = true,
	['archive-date'] = true,
	['archive-format'] = true,
	['archiveurl'] = true,
	['archive-url'] = true,
	['article'] = true,
	['article-format'] = true,
	['article-url'] = true,
	['article-url-access'] = true,
	['arxiv'] = true,
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['bibcode'] = true,
	['bibcode-access'] = true,
	['biorxiv'] = true,
	['booktitle'] = true,
	['book-title'] = true,
	['cartography'] = true,
	['chapter'] = true,
	['chapter-format'] = true,
	['chapterurl'] = true,
	['chapter-url'] = true,
	['chapter-url-access'] = true,
	['citeseerx'] = true,
	['collaboration'] = true,
	['conference'] = true,
	['conference-format'] = true,
	['conferenceurl'] = true,
	['conference-url'] = true,
	['contribution'] = true,
	['contribution-format'] = true,
	['contributionurl'] = true,
	['contribution-url'] = true,
	['contribution-url-access'] = true,
	['contributor'] = true,
	['contributor-first'] = true,
	['contributor-last'] = true,
	['contributor-given'] = true,
	['contributor-surname'] = true,
	['contributor-link'] = true,
	['contributor-mask'] = true,
	['credits'] = true,															-- cite episode, cite serial
	['date'] = true,
	['degree'] = true,
	['department'] = true,
	['df'] = true,
	['dictionary'] = true,
	['displayauthors'] = true,
	['display-authors'] = true,
	['display-contributors'] = true,
	['displayeditors'] = true,
	['display-editors'] = true,
	['display-interviewers'] = true,
	['display-translators'] = true,
	['docket'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-access'] = true,
	['doi-broken'] = true,
	['doi-broken-date'] = true,
	['doi-inactive-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['editor-first'] = true,
	['editor-given'] = true,
	['editor-last'] = true,
	['editorlink'] = true,
	['editor-link'] = true,
	['editormask'] = true,
	['editor-mask'] = true,
	['editors'] = true,
	['editor-surname'] = true,
	['eissn'] = true,
	['EISSN'] = true,
	['embargo'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['entry'] = true,
	['entry-format'] = true,
	['entry-url'] = true,
	['entry-url-access'] = true,
	['episode'] = true,															-- cite serial only TODO: make available to cite episode?
	['episodelink'] = true,														-- cite episode and cite serial
	['episode-link'] = true,													-- cite episode and cite serial
	['eprint'] = true,															-- cite arxiv and arxiv identifiers
	['event'] = true,
	['event-format'] = true,
	['eventurl'] = true,
	['event-url'] = true,
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['hdl'] = true,
	['HDL'] = true,
	['hdl-access'] = true,
	['host'] = true,
	['id'] = true,
	['ID'] = true,
	['ignoreisbnerror'] = true,
	['ignore-isbn-error'] = true,
	['inset'] = true,
	['institution'] = true,
	['interviewer'] = true,
	['interviewer-first'] = true,
	['interviewer-last'] = true,
	['interviewerlink'] = true,
	['interviewer-link'] = true,
	['interviewermask'] = true,
	['interviewer-mask'] = true,
	['isbn'] = true,
	['ISBN'] = true,
	['isbn13'] = true,
	['ISBN13'] = true,
	['ismn'] = true,
	['ISMN'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['jstor-access'] = true,
	['lang'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['laydate'] = true,
	['lay-date'] = true,
	['laysource'] = true,
	['lay-source'] = true,
	['lay-format'] = true,
	['layurl'] = true,
	['lay-url'] = true,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['magazine'] = true,
	['mailinglist'] = true,														-- cite mailing list only
	['mailing-list'] = true,													-- cite mailing list only
	['map'] = true,																-- cite map only
	['map-format'] = true,														-- cite map only
	['mapurl'] = true,															-- cite map only
	['map-url'] = true,															-- cite map only
	['map-url-access'] = true,													-- cite map only
	['medium'] = true,
	['message-id'] = true,														-- cite newsgroup
	['minutes'] = true,
	['mode'] = true,
	['mr'] = true,
	['MR'] = true,
	['name-list-format'] = true,
	['network'] = true,
	['newsgroup'] = true,
	['newspaper'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['nopp'] = true,
	['no-pp'] = true,
	['notracking'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['ol-access'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['osti-access'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['people'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['publicationdate'] = true,
	['publication-date'] = true,
	['publicationplace'] = true,
	['publication-place'] = true,
	['publisher'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['rfc'] = true,
	['RFC'] = true,
	['scale'] = true,
	['script-article'] = true,
	['script-chapter'] = true,
	['script-contribution'] = true,
	['script-entry'] = true,
	['script-journal'] = true,
	['script-magazine'] = true,
	['script-map'] = true,
	['script-newspaper'] = true,
	['script-periodical'] = true,
	['script-section'] = true,
	['script-title'] = true,
	['script-website'] = true,
	['script-work'] = true,
	['season'] = true,
	['section'] = true,
	['section-format'] = true,
	['sections'] = true,														-- cite map only
	['sectionurl'] = true,
	['section-url'] = true,
	['section-url-access'] = true,
	['series'] = true,
	['serieslink'] = true,
	['series-link'] = true,
	['seriesno'] = true,
	['series-no'] = true,
	['seriesnumber'] = true,
	['series-number'] = true,
	['series-separator'] = true,
	['sheet'] = true,															-- cite map only
	['sheets'] = true,															-- cite map only
	['ssrn'] = true,
	['SSRN'] = true,
	['station'] = true,
	['subject'] = true,
	['subjectlink'] = true,
	['subject-link'] = true,
	['surname'] = true,
	['template-doc-demo'] = true,
	['time'] = true,
	['timecaption'] = true,
	['time-caption'] = true,
	['title'] = true,
	['titlelink'] = true,
	['title-link'] = true,
	['trans-map'] = true,
	['transcript'] = true,
	['transcript-format'] = true,
	['transcripturl'] = true,
	['transcript-url'] = true,
	['translator'] = true,
	['translator-first'] = true,
	['translator-last'] = true,
	['translator-given'] = true,
	['translator-surname'] = true,
	['translator-link'] = true,
	['translator-mask'] = true,
	['trans-article'] = true,
	['trans-chapter'] = true,
	['trans-contribution'] = true,
	['trans-entry'] = true,
	['trans-journal'] = true,
	['trans-magazine'] = true,
	['trans-newspaper'] = true,
	['trans-periodical'] = true,
	['trans-section'] = true,
	['trans-title'] = true,
	['trans-website'] = true,
	['trans-work'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['url-access'] = true,
	['url-status'] = true,
	['vauthors'] = true,
	['veditors'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
}

local numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['contributor#'] = true,
	['contributor-first#'] = true,
	['contributor#-first'] = true,
	['contributor-last#'] = true,
	['contributor#-last'] = true,
	['contributor-given#'] = true,
	['contributor#-given'] = true,
	['contributor-surname#'] = true,
	['contributor#-surname'] = true,
	['contributor-link#'] = true,
	['contributor#-link'] = true,
	['contributor-mask#'] = true,
	['contributor#-mask'] = true,
	['editor#'] = true,
	['editor-first#'] = true,
	['editor#-first'] = true,
	['editor#-given'] = true,
	['editor-given#'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-link#'] = true,
	['editor#link'] = true,
	['editor#-link'] = true,
	['editorlink#'] = true,
	['editor-mask#'] = true,
	['editor#mask'] = true,
	['editor#-mask'] = true,
	['editormask#'] = true,
	['editor#-surname'] = true,
	['editor-surname#'] = true,
	['first#'] = true,
	['given#'] = true,
	['host#'] = true,
	['interviewer#'] = true,
	['interviewer-first#'] = true,
	['interviewer#-first'] = true,
	['interviewer-last#'] = true,
	['interviewer#-last'] = true,
	['interviewer-link#'] = true,
	['interviewer#-link'] = true,
	['interviewer-mask#'] = true,
	['interviewer#-mask'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-link#'] = true,
	['subject#link'] = true,
	['subject#-link'] = true,
	['subjectlink#'] = true,
	['surname#'] = true,
	['translator#'] = true,
	['translator-first#'] = true,
	['translator#-first'] = true,
	['translator-last#'] = true,
	['translator#-last'] = true,
	['translator-given#'] = true,
	['translator#-given'] = true,
	['translator-surname#'] = true,
	['translator#-surname'] = true,
	['translator-link#'] = true,
	['translator#-link'] = true,
	['translator-mask#'] = true,
	['translator#-mask'] = true,
}


--[[--------------------------&lt; P R E P R I N T   S U P P O R T E D   P A R A M E T E R S &gt;--------------------

Cite arXiv, cite biorxiv, cite citeseerx, and cite ssrn are preprint templates that use the limited set of parameters
defined in the limited_basic_arguments and limited_numbered_arguments tables.  Those lists are supplemented with a
template-specific list of parameters that are required by the particular template and may be exclusive to one of the
proeprint templates.  Some of these parameters may also be available to the general cs1|2 templates.

Same conventions for true/false/nil as above.

]]

--[[--------------------------&lt; C I T E   A R X I V &gt;----------------------------------------------------------

]]

local arxiv_basic_arguments = {
	['arxiv'] = true,															-- cite arxiv and arxiv identifiers
	['class'] = true,															-- cite arxiv only
	['eprint'] = true,															-- cite arxiv and arxiv identifiers
}


--[[--------------------------&lt; C I T E   B I O R X I V &gt;------------------------------------------------------

]]

local biorxiv_basic_arguments = {
	['biorxiv'] = true,
}


--[[--------------------------&lt; C I T E   C I T E S E E R X &gt;--------------------------------------------------

]]

local citeseerx_basic_arguments = {
	['citeseerx'] = true,
}


--[[--------------------------&lt; C I T E   S S R N &gt;------------------------------------------------------------

]]

local ssrn_basic_arguments = {
	['ssrn'] = true,
	['SSRN'] = true,
}


--[[--------------------------&lt; L I M I T E D   S U P P O R T E D   P A R A M E T E R S &gt;----------------------

This is an experiment that attempts to use validate() and a limited list of valid parameters to validate the
parameters provided in a cite arxiv, cite biorxiv, or cite citeseerx templates.  These parameters are common to
all three templates

Same conventions for true/false/nil as above.
	
]]

local limited_basic_arguments = {
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['collaboration'] = true,
	['date'] = true,
	['df'] = true,
	['displayauthors'] = true,
	['display-authors'] = true,
	['first'] = true,
	['given'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['mode'] = true,
	['name-list-format'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['notracking'] = true,
	['no-tracking'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['postscript'] = true,
	['pp'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['surname'] = true,
	['template-doc-demo'] = true,
	['title'] = true,
	['url'] = true,
	['URL'] = true,
	['vauthors'] = true,
	['year'] = true,
}

local limited_numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['surname#'] = true,
}


--[[--------------------------&lt; E X P O R T E D   T A B L E S &gt;------------------------------------------------
]]

return {
	basic_arguments = basic_arguments,
	numbered_arguments = numbered_arguments,
	limited_basic_arguments = limited_basic_arguments,
	limited_numbered_arguments = limited_numbered_arguments,
	arxiv_basic_arguments = arxiv_basic_arguments,
	biorxiv_basic_arguments = biorxiv_basic_arguments,
	citeseerx_basic_arguments = citeseerx_basic_arguments,
	ssrn_basic_arguments = ssrn_basic_arguments
	};</text>
      <sha1>r0u1d2o5c4d87ppncjwj6wm71bmh2sl</sha1>
    </revision>
    <revision>
      <id>4803</id>
      <parentid>4802</parentid>
      <timestamp>2020-04-18T12:50:50Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4803</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="15386" sha1="6busmgl196te3keptqmitbtxfaxtdia" xml:space="preserve">
--[[--------------------------&lt; S U P P O R T E D   P A R A M E T E R S &gt;--------------------------------------

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported. remove entirely
	
]]

local whitelist = {}

local basic_arguments = {
	['accessdate'] = true,
	['access-date'] = true,
	['agency'] = true,
--	['airdate'] = true,															-- cite episode and cite serial only
--	['air-date'] = true,														-- cite episode and cite serial only
	['archivedate'] = true,
	['archive-date'] = true,
	['archive-format'] = true,
	['archiveurl'] = true,
	['archive-url'] = true,
	['article'] = true,
	['article-format'] = true,
	['article-url'] = true,
	['article-url-access'] = true,
	['arxiv'] = true,
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['bibcode'] = true,
	['bibcode-access'] = true,
	['biorxiv'] = true,
	['booktitle'] = true,
	['book-title'] = true,
	['cartography'] = true,
	['chapter'] = true,
	['chapter-format'] = true,
	['chapterurl'] = true,
	['chapter-url'] = true,
	['chapter-url-access'] = true,
	['citeseerx'] = true,
	['collaboration'] = true,
	['conference'] = true,
	['conference-format'] = true,
	['conferenceurl'] = true,
	['conference-url'] = true,
	['contribution'] = true,
	['contribution-format'] = true,
	['contributionurl'] = true,
	['contribution-url'] = true,
	['contribution-url-access'] = true,
	['contributor'] = true,
	['contributor-first'] = true,
	['contributor-last'] = true,
	['contributor-given'] = true,
	['contributor-surname'] = true,
	['contributor-link'] = true,
	['contributor-mask'] = true,
--	['credits'] = true,															-- cite episode, cite serial
	['date'] = true,
	['degree'] = true,
	['department'] = true,
	['df'] = true,
	['dictionary'] = true,
	['displayauthors'] = true,
	['display-authors'] = true,
	['display-contributors'] = true,
	['displayeditors'] = true,
	['display-editors'] = true,
	['display-interviewers'] = true,
	['display-translators'] = true,
	['docket'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-access'] = true,
	['doi-broken'] = true,
	['doi-broken-date'] = true,
	['doi-inactive-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['editor-first'] = true,
	['editor-given'] = true,
	['editor-last'] = true,
	['editorlink'] = true,
	['editor-link'] = true,
	['editormask'] = true,
	['editor-mask'] = true,
	['editors'] = true,
	['editor-surname'] = true,
	['eissn'] = true,
	['EISSN'] = true,
	['embargo'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['entry'] = true,
	['entry-format'] = true,
	['entry-url'] = true,
	['entry-url-access'] = true,
--	['episode'] = true,															-- cite serial only TODO: make available to cite episode?
--	['episodelink'] = true,														-- cite episode and cite serial
--	['episode-link'] = true,													-- cite episode and cite serial
	['eprint'] = true,															-- cite arxiv; here because allowed in cite ... as identifier
	['event'] = true,
	['event-format'] = true,
	['eventurl'] = true,
	['event-url'] = true,
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['hdl'] = true,
	['HDL'] = true,
	['hdl-access'] = true,
	['host'] = true,
	['id'] = true,
	['ID'] = true,
	['ignoreisbnerror'] = true,
	['ignore-isbn-error'] = true,
	['inset'] = true,
	['institution'] = true,
	['interviewer'] = true,
	['interviewer-first'] = true,
	['interviewer-last'] = true,
	['interviewerlink'] = true,
	['interviewer-link'] = true,
	['interviewermask'] = true,
	['interviewer-mask'] = true,
	['isbn'] = true,
	['ISBN'] = true,
	['isbn13'] = true,
	['ISBN13'] = true,
	['ismn'] = true,
	['ISMN'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['jstor-access'] = true,
	['lang'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['laydate'] = true,
	['lay-date'] = true,
	['laysource'] = true,
	['lay-source'] = true,
	['lay-format'] = true,
	['layurl'] = true,
	['lay-url'] = true,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['magazine'] = true,
	['mailinglist'] = true,														-- cite mailing list only
	['mailing-list'] = true,													-- cite mailing list only
	['map'] = true,																-- cite map only
	['map-format'] = true,														-- cite map only
	['mapurl'] = true,															-- cite map only
	['map-url'] = true,															-- cite map only
	['map-url-access'] = true,													-- cite map only
	['medium'] = true,
--	['message-id'] = true,														-- cite newsgroup
	['minutes'] = true,
	['mode'] = true,
	['mr'] = true,
	['MR'] = true,
	['name-list-format'] = true,
--	['network'] = true,															-- cite episode and cite serial only
--	['newsgroup'] = true,														-- cite newsgroup
	['newspaper'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['nopp'] = true,
	['no-pp'] = true,
	['notracking'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['ol-access'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['osti-access'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['people'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['publicationdate'] = true,
	['publication-date'] = true,
	['publicationplace'] = true,
	['publication-place'] = true,
	['publisher'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['rfc'] = true,
	['RFC'] = true,
	['sbn'] = true,
	['SBN'] = true,
	['scale'] = true,
	['script-article'] = true,
	['script-chapter'] = true,
	['script-contribution'] = true,
	['script-entry'] = true,
	['script-journal'] = true,
	['script-magazine'] = true,
	['script-map'] = true,
	['script-newspaper'] = true,
	['script-periodical'] = true,
	['script-section'] = true,
	['script-title'] = true,
	['script-website'] = true,
	['script-work'] = true,
	['season'] = true,
	['section'] = true,
	['section-format'] = true,
	['sections'] = true,														-- cite map only
	['sectionurl'] = true,
	['section-url'] = true,
	['section-url-access'] = true,
	['series'] = true,
	['serieslink'] = true,
	['series-link'] = true,
	['seriesno'] = true,
	['series-no'] = true,
	['seriesnumber'] = true,
	['series-number'] = true,
	['series-separator'] = true,
	['sheet'] = true,															-- cite map only
	['sheets'] = true,															-- cite map only
	['ssrn'] = true,
	['SSRN'] = true,
--	['station'] = true,															-- cite episode and cite serial only
	['subject'] = true,
	['subjectlink'] = true,
	['subject-link'] = true,
	['surname'] = true,
	['s2cid'] = true,
	['S2CID'] = true,
	['s2cid-access'] = true,
	['template-doc-demo'] = true,
	['time'] = true,
	['timecaption'] = true,
	['time-caption'] = true,
	['title'] = true,
	['titlelink'] = true,
	['title-link'] = true,
	['trans-map'] = true,
	['transcript'] = true,
	['transcript-format'] = true,
	['transcripturl'] = true,
	['transcript-url'] = true,
	['translator'] = true,
	['translator-first'] = true,
	['translator-last'] = true,
	['translator-given'] = true,
	['translator-surname'] = true,
	['translator-link'] = true,
	['translator-mask'] = true,
	['trans-article'] = true,
	['trans-chapter'] = true,
	['trans-contribution'] = true,
	['trans-entry'] = true,
	['trans-journal'] = true,
	['trans-magazine'] = true,
	['trans-newspaper'] = true,
	['trans-periodical'] = true,
	['trans-section'] = true,
	['trans-title'] = true,
	['trans-website'] = true,
	['trans-work'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['url-access'] = true,
	['url-status'] = true,
	['vauthors'] = true,
	['veditors'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
}

local numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['contributor#'] = true,
	['contributor-first#'] = true,
	['contributor#-first'] = true,
	['contributor-last#'] = true,
	['contributor#-last'] = true,
	['contributor-given#'] = true,
	['contributor#-given'] = true,
	['contributor-surname#'] = true,
	['contributor#-surname'] = true,
	['contributor-link#'] = true,
	['contributor#-link'] = true,
	['contributor-mask#'] = true,
	['contributor#-mask'] = true,
	['editor#'] = true,
	['editor-first#'] = true,
	['editor#-first'] = true,
	['editor#-given'] = true,
	['editor-given#'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-link#'] = true,
	['editor#link'] = true,
	['editor#-link'] = true,
	['editorlink#'] = true,
	['editor-mask#'] = true,
	['editor#mask'] = true,
	['editor#-mask'] = true,
	['editormask#'] = true,
	['editor#-surname'] = true,
	['editor-surname#'] = true,
	['first#'] = true,
	['given#'] = true,
	['host#'] = true,
	['interviewer#'] = true,
	['interviewer-first#'] = true,
	['interviewer#-first'] = true,
	['interviewer-last#'] = true,
	['interviewer#-last'] = true,
	['interviewer-link#'] = true,
	['interviewer#-link'] = true,
	['interviewer-mask#'] = true,
	['interviewer#-mask'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-link#'] = true,
	['subject#link'] = true,
	['subject#-link'] = true,
	['subjectlink#'] = true,
	['surname#'] = true,
	['translator#'] = true,
	['translator-first#'] = true,
	['translator#-first'] = true,
	['translator-last#'] = true,
	['translator#-last'] = true,
	['translator-given#'] = true,
	['translator#-given'] = true,
	['translator-surname#'] = true,
	['translator#-surname'] = true,
	['translator-link#'] = true,
	['translator#-link'] = true,
	['translator-mask#'] = true,
	['translator#-mask'] = true,
}


--[[--------------------------&lt; P R E P R I N T   S U P P O R T E D   P A R A M E T E R S &gt;--------------------

Cite arXiv, cite biorxiv, cite citeseerx, and cite ssrn are preprint templates that use the limited set of parameters
defined in the limited_basic_arguments and limited_numbered_arguments tables.  Those lists are supplemented with a
template-specific list of parameters that are required by the particular template and may be exclusive to one of the
preprint templates.  Some of these parameters may also be available to the general cs1|2 templates.

Same conventions for true/false/nil as above.

]]

local preprint_arguments = {
	arxiv = {
		['arxiv'] = true,														-- cite arxiv and arxiv identifiers
		['class'] = true,														-- cite arxiv only
		['eprint'] = true,														-- cite arxiv and arxiv identifiers
		},
	biorxiv = {
		['biorxiv'] = true,
		},
	citeseerx = {
		['citeseerx'] = true,
		},
	ssrn = {
		['ssrn'] = true,
		['SSRN'] = true,
		},
	}


--[[--------------------------&lt; L I M I T E D   S U P P O R T E D   P A R A M E T E R S &gt;----------------------

This is an experiment that attempts to use validate() and a limited list of valid parameters to validate the
parameters provided in a cite arxiv, cite biorxiv, or cite citeseerx templates.  These parameters are common to
all three templates

Same conventions for true/false/nil as above.
	
]]

local limited_basic_arguments = {
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['collaboration'] = true,
	['date'] = true,
	['df'] = true,
	['displayauthors'] = true,
	['display-authors'] = true,
	['first'] = true,
	['given'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['mode'] = true,
	['name-list-format'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['notracking'] = true,
	['no-tracking'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['postscript'] = true,
	['pp'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['surname'] = true,
	['template-doc-demo'] = true,
	['title'] = true,
	['url'] = true,
	['URL'] = true,
	['vauthors'] = true,
	['year'] = true,
}

local limited_numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['surname#'] = true,
	}


--[[--------------------------&lt; U N I Q U E _ A R G U M E N T S &gt;----------------------------------------------

some templates have unique parameters.  Those templates and their unique parameters are listed here. Keys in this
table are the template's CitationClass parameter value

Same conventions for true/false/nil as above.

]]

local unique_arguments = {
	episode = {
		['airdate'] = true,
		['air-date'] = true,
		['credits'] = true,
		['episodelink'] = true,													-- aliases of |title-link=
		['episode-link'] = true,
		['network'] = true,
		['station'] = true,
		},
	newsgroup = {
		['message-id'] = true,
		['newsgroup'] = true,
		},
	serial = {
		['airdate'] = true,
		['air-date'] = true,
		['credits'] = true,
		['episode'] = true,														-- cite serial only TODO: make available to cite episode?
		['episodelink'] = true,													-- aliases of |title-link=
		['episode-link'] = true,
		['network'] = true,
		['station'] = true,
		},
	}


--[[--------------------------&lt; T E M P L A T E _ L I S T _ G E T &gt;--------------------------------------------

gets a list of the templates from table t

]]

local function template_list_get (t)
	local out = {};																-- a table for output
	for k, _ in pairs (t) do													-- spin through the table and collect the keys
		table.insert (out, k)													-- add each key to the output table
	end
	return out;																	-- and done
end


--[[--------------------------&lt; E X P O R T E D   T A B L E S &gt;------------------------------------------------
]]

return {
	basic_arguments = basic_arguments,
	numbered_arguments = numbered_arguments,
	limited_basic_arguments = limited_basic_arguments,
	limited_numbered_arguments = limited_numbered_arguments,

	preprint_arguments = preprint_arguments,
	preprint_template_list = template_list_get (preprint_arguments),			-- make a template list from preprint_arguments{} table
	unique_arguments = unique_arguments,
	unique_param_template_list = template_list_get (unique_arguments),			-- make a template list from unique_arguments{} table
	};</text>
      <sha1>6busmgl196te3keptqmitbtxfaxtdia</sha1>
    </revision>
    <revision>
      <id>4804</id>
      <parentid>4803</parentid>
      <timestamp>2020-07-11T13:18:12Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4804</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="14552" sha1="byx7p691509ayedjxmbx9ug3yscs89x" xml:space="preserve">
--[[--------------------------&lt; S U P P O R T E D   P A R A M E T E R S &gt;--------------------------------------

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported. remove entirely
	
]]

local whitelist = {}

local basic_arguments = {
	['accessdate'] = true,
	['access-date'] = true,
	['agency'] = true,
	['archivedate'] = true,
	['archive-date'] = true,
	['archive-format'] = true,
	['archiveurl'] = true,
	['archive-url'] = true,
	['article'] = true,
	['article-format'] = true,
	['article-url'] = true,
	['article-url-access'] = true,
	['arxiv'] = true,															-- cite arxiv; here because allowed in cite ... as identifier
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['bibcode'] = true,
	['bibcode-access'] = true,
	['biorxiv'] = true,
	['booktitle'] = true,
	['book-title'] = true,
	['cartography'] = true,
	['chapter'] = true,
	['chapter-format'] = true,
	['chapterurl'] = true,
	['chapter-url'] = true,
	['chapter-url-access'] = true,
	['citeseerx'] = true,
	['collaboration'] = true,
	['conference'] = true,
	['conference-format'] = true,
	['conferenceurl'] = true,
	['conference-url'] = true,
	['contribution'] = true,
	['contribution-format'] = true,
	['contributionurl'] = true,
	['contribution-url'] = true,
	['contribution-url-access'] = true,
	['contributor'] = true,
	['contributor-first'] = true,
	['contributor-last'] = true,
	['contributor-given'] = true,
	['contributor-surname'] = true,
	['contributor-link'] = true,
	['contributor-mask'] = true,
	['date'] = true,
	['degree'] = true,
	['department'] = true,
	['df'] = true,
	['dictionary'] = true,
	['displayauthors'] = true,
	['display-authors'] = true,
	['display-contributors'] = true,
	['displayeditors'] = true,
	['display-editors'] = true,
	['display-interviewers'] = true,
	['display-translators'] = true,
	['docket'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-access'] = true,
	['doi-broken'] = true,
	['doi-broken-date'] = true,
	['doi-inactive-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['editor-first'] = true,
	['editor-given'] = true,
	['editor-last'] = true,
	['editorlink'] = true,
	['editor-link'] = true,
	['editormask'] = true,
	['editor-mask'] = true,
	['editors'] = true,
	['editor-surname'] = true,
	['eissn'] = true,
	['EISSN'] = true,
	['embargo'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['entry'] = true,
	['entry-format'] = true,
	['entry-url'] = true,
	['entry-url-access'] = true,
	['eprint'] = true,															-- cite arxiv; here because allowed in cite ... as identifier
	['event'] = true,
	['event-format'] = true,
	['eventurl'] = true,
	['event-url'] = true,
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['hdl'] = true,
	['HDL'] = true,
	['hdl-access'] = true,
	['host'] = true,
	['id'] = true,
	['ID'] = true,
	['ignoreisbnerror'] = true,
	['ignore-isbn-error'] = true,
	['inset'] = true,
	['institution'] = true,
	['interviewer'] = true,
	['interviewer-first'] = true,
	['interviewer-last'] = true,
	['interviewerlink'] = true,
	['interviewer-link'] = true,
	['interviewermask'] = true,
	['interviewer-mask'] = true,
	['isbn'] = true,
	['ISBN'] = true,
	['isbn13'] = true,
	['ISBN13'] = true,
	['ismn'] = true,
	['ISMN'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['jstor-access'] = true,
	['lang'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['laydate'] = true,
	['lay-date'] = true,
	['laysource'] = true,
	['lay-source'] = true,
	['lay-format'] = true,
	['layurl'] = true,
	['lay-url'] = true,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['magazine'] = true,
	['mailinglist'] = true,														-- cite mailing list only
	['mailing-list'] = true,													-- cite mailing list only
	['medium'] = true,
	['minutes'] = true,
	['mode'] = true,
	['mr'] = true,
	['MR'] = true,
	['name-list-format'] = true,
	['newspaper'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['nopp'] = true,
	['no-pp'] = true,
	['notracking'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['ol-access'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['osti-access'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['people'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['publicationdate'] = true,
	['publication-date'] = true,
	['publicationplace'] = true,
	['publication-place'] = true,
	['publisher'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['rfc'] = true,
	['RFC'] = true,
	['sbn'] = true,
	['SBN'] = true,
	['scale'] = true,
	['script-article'] = true,
	['script-chapter'] = true,
	['script-contribution'] = true,
	['script-entry'] = true,
	['script-journal'] = true,
	['script-magazine'] = true,
	['script-newspaper'] = true,
	['script-periodical'] = true,
	['script-section'] = true,
	['script-title'] = true,
	['script-website'] = true,
	['script-work'] = true,
	['season'] = true,
	['section'] = true,
	['section-format'] = true,
	['sectionurl'] = true,
	['section-url'] = true,
	['section-url-access'] = true,
	['series'] = true,
	['serieslink'] = true,
	['series-link'] = true,
	['seriesno'] = true,
	['series-no'] = true,
	['seriesnumber'] = true,
	['series-number'] = true,
	['series-separator'] = true,
	['ssrn'] = true,
	['SSRN'] = true,
	['subject'] = true,
	['subjectlink'] = true,
	['subject-link'] = true,
	['surname'] = true,
	['s2cid'] = true,
	['S2CID'] = true,
	['s2cid-access'] = true,
	['template-doc-demo'] = true,
	['time'] = true,
	['timecaption'] = true,
	['time-caption'] = true,
	['title'] = true,
	['titlelink'] = true,
	['title-link'] = true,
	['transcript'] = true,
	['transcript-format'] = true,
	['transcripturl'] = true,
	['transcript-url'] = true,
	['translator'] = true,
	['translator-first'] = true,
	['translator-last'] = true,
	['translator-given'] = true,
	['translator-surname'] = true,
	['translator-link'] = true,
	['translator-mask'] = true,
	['trans-article'] = true,
	['trans-chapter'] = true,
	['trans-contribution'] = true,
	['trans-entry'] = true,
	['trans-journal'] = true,
	['trans-magazine'] = true,
	['trans-newspaper'] = true,
	['trans-periodical'] = true,
	['trans-section'] = true,
	['trans-title'] = true,
	['trans-website'] = true,
	['trans-work'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['url-access'] = true,
	['url-status'] = true,
	['vauthors'] = true,
	['veditors'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
}

local numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['contributor#'] = true,
	['contributor-first#'] = true,
	['contributor#-first'] = true,
	['contributor-last#'] = true,
	['contributor#-last'] = true,
	['contributor-given#'] = true,
	['contributor#-given'] = true,
	['contributor-surname#'] = true,
	['contributor#-surname'] = true,
	['contributor-link#'] = true,
	['contributor#-link'] = true,
	['contributor-mask#'] = true,
	['contributor#-mask'] = true,
	['editor#'] = true,
	['editor-first#'] = true,
	['editor#-first'] = true,
	['editor#-given'] = true,
	['editor-given#'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-link#'] = true,
	['editor#link'] = true,
	['editor#-link'] = true,
	['editorlink#'] = true,
	['editor-mask#'] = true,
	['editor#mask'] = true,
	['editor#-mask'] = true,
	['editormask#'] = true,
	['editor#-surname'] = true,
	['editor-surname#'] = true,
	['first#'] = true,
	['given#'] = true,
	['host#'] = true,
	['interviewer#'] = true,
	['interviewer-first#'] = true,
	['interviewer#-first'] = true,
	['interviewer-last#'] = true,
	['interviewer#-last'] = true,
	['interviewer-link#'] = true,
	['interviewer#-link'] = true,
	['interviewer-mask#'] = true,
	['interviewer#-mask'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-link#'] = true,
	['subject#link'] = true,
	['subject#-link'] = true,
	['subjectlink#'] = true,
	['surname#'] = true,
	['translator#'] = true,
	['translator-first#'] = true,
	['translator#-first'] = true,
	['translator-last#'] = true,
	['translator#-last'] = true,
	['translator-given#'] = true,
	['translator#-given'] = true,
	['translator-surname#'] = true,
	['translator#-surname'] = true,
	['translator-link#'] = true,
	['translator#-link'] = true,
	['translator-mask#'] = true,
	['translator#-mask'] = true,
}


--[[--------------------------&lt; P R E P R I N T   S U P P O R T E D   P A R A M E T E R S &gt;--------------------

Cite arXiv, cite biorxiv, cite citeseerx, and cite ssrn are preprint templates that use the limited set of parameters
defined in the limited_basic_arguments and limited_numbered_arguments tables.  Those lists are supplemented with a
template-specific list of parameters that are required by the particular template and may be exclusive to one of the
preprint templates.  Some of these parameters may also be available to the general cs1|2 templates.

Same conventions for true/false/nil as above.

]]

local preprint_arguments = {
	arxiv = {
		['arxiv'] = true,														-- cite arxiv and arxiv identifiers
		['class'] = true,														-- cite arxiv only
		['eprint'] = true,														-- cite arxiv and arxiv identifiers
		},
	biorxiv = {
		['biorxiv'] = true,
		},
	citeseerx = {
		['citeseerx'] = true,
		},
	ssrn = {
		['ssrn'] = true,
		['SSRN'] = true,
		},
	}


--[[--------------------------&lt; L I M I T E D   S U P P O R T E D   P A R A M E T E R S &gt;----------------------

This is an experiment that attempts to use validate() and a limited list of valid parameters to validate the
parameters provided in a cite arxiv, cite biorxiv, or cite citeseerx templates.  These parameters are common to
all three templates

Same conventions for true/false/nil as above.
	
]]

local limited_basic_arguments = {
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-last'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['collaboration'] = true,
	['date'] = true,
	['df'] = true,
	['displayauthors'] = true,
	['display-authors'] = true,
	['first'] = true,
	['given'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = true,
	['last-author-amp'] = true,
	['mode'] = true,
	['name-list-format'] = true,
	['nocat'] = true,
	['no-cat'] = true,
	['notracking'] = true,
	['no-tracking'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['postscript'] = true,
	['pp'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['surname'] = true,
	['template-doc-demo'] = true,
	['title'] = true,
	['trans-title'] = true,
	['url'] = true,
	['URL'] = true,
	['vauthors'] = true,
	['year'] = true,
}

local limited_numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-link#'] = true,
	['author#link'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author-mask#'] = true,
	['author#mask'] = true,
	['author#-mask'] = true,
	['authormask#'] = true,
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['surname#'] = true,
	}


--[[--------------------------&lt; U N I Q U E _ A R G U M E N T S &gt;----------------------------------------------

some templates have unique parameters.  Those templates and their unique parameters are listed here. Keys in this
table are the template's CitationClass parameter value

Same conventions for true/false/nil as above.

]]

local unique_arguments = {
	episode = {
		['airdate'] = true,
		['air-date'] = true,
		['credits'] = true,
		['episodelink'] = true,													-- aliases of |title-link=
		['episode-link'] = true,
		['network'] = true,
		['station'] = true,
		},
	map = {
		['map'] = true,
		['map-format'] = true,
		['mapurl'] = true,
		['map-url'] = true,
		['map-url-access'] = true,
		['script-map'] = true,
		['sections'] = true,
		['sheet'] = true,
		['sheets'] = true,
		['trans-map'] = true,
		},
	newsgroup = {
		['message-id'] = true,
		['newsgroup'] = true,
		},
	serial = {
		['airdate'] = true,
		['air-date'] = true,
		['credits'] = true,
		['episode'] = true,														-- cite serial only TODO: make available to cite episode?
		['episodelink'] = true,													-- aliases of |title-link=
		['episode-link'] = true,
		['network'] = true,
		['station'] = true,
		},
	}


--[[--------------------------&lt; T E M P L A T E _ L I S T _ G E T &gt;--------------------------------------------

gets a list of the templates from table t

]]

local function template_list_get (t)
	local out = {};																-- a table for output
	for k, _ in pairs (t) do													-- spin through the table and collect the keys
		table.insert (out, k)													-- add each key to the output table
	end
	return out;																	-- and done
end


--[[--------------------------&lt; E X P O R T E D   T A B L E S &gt;------------------------------------------------
]]

return {
	basic_arguments = basic_arguments,
	numbered_arguments = numbered_arguments,
	limited_basic_arguments = limited_basic_arguments,
	limited_numbered_arguments = limited_numbered_arguments,

	preprint_arguments = preprint_arguments,
	preprint_template_list = template_list_get (preprint_arguments),			-- make a template list from preprint_arguments{} table
	unique_arguments = unique_arguments,
	unique_param_template_list = template_list_get (unique_arguments),			-- make a template list from unique_arguments{} table
	};</text>
      <sha1>byx7p691509ayedjxmbx9ug3yscs89x</sha1>
    </revision>
    <revision>
      <id>4805</id>
      <parentid>4804</parentid>
      <timestamp>2020-10-10T13:23:00Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4805</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="15875" sha1="4jbcp11pa4k7hsy69nzp2juitha3wp5" xml:space="preserve">
--[[--------------------------&lt; S U P P O R T E D   P A R A M E T E R S &gt;--------------------------------------

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported. remove entirely
	
]]

local basic_arguments = {
	['accessdate'] = true,
	['access-date'] = true,
	['agency'] = true,
	['archivedate'] = true,
	['archive-date'] = true,
	['archive-format'] = true,
	['archiveurl'] = true,
	['archive-url'] = true,
	['article'] = true,
	['article-format'] = true,
	['article-url'] = true,
	['article-url-access'] = true,
	['arxiv'] = true,															-- cite arxiv; here because allowed in cite ... as identifier
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-given'] = true,
	['author-last'] = true,
	['author-surname'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['authormask'] = false,														-- deprecated
	['author-mask'] = true,
	['authors'] = true,
	['bibcode'] = true,
	['bibcode-access'] = true,
	['biorxiv'] = true,															-- cite biorxiv; here because allowed in cite ... as identifier
	['booktitle'] = true,
	['book-title'] = true,
	['cartography'] = true,
	['chapter'] = true,
	['chapter-format'] = true,
	['chapterurl'] = true,
	['chapter-url'] = true,
	['chapter-url-access'] = true,
	['citeseerx'] = true,														-- cite citeseerx; here because allowed in cite ... as identifier
	['collaboration'] = true,
	['conference'] = true,
	['conference-format'] = true,
	['conferenceurl'] = true,
	['conference-url'] = true,
	['contribution'] = true,
	['contribution-format'] = true,
	['contributionurl'] = true,
	['contribution-url'] = true,
	['contribution-url-access'] = true,
	['contributor'] = true,
	['contributor-first'] = true,
	['contributor-given'] = true,
	['contributor-last'] = true,
	['contributor-surname'] = true,
	['contributor-link'] = true,
	['contributor-mask'] = true,
	['date'] = true,
	['degree'] = true,
	['department'] = true,
	['df'] = true,
	['dictionary'] = true,
	['displayauthors'] = false,													-- deprecated
	['display-authors'] = true,
	['display-contributors'] = true,
	['display-editors'] = true,
	['display-interviewers'] = true,
	['display-subjects'] = true,
	['display-translators'] = true,
	['docket'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-access'] = true,
	['doi-broken-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['editor-first'] = true,
	['editor-given'] = true,
	['editor-last'] = true,
	['editor-surname'] = true,
	['editorlink'] = false,														-- deprecated
	['editor-link'] = true,
	['editor-mask'] = true,
	['editors'] = false,														-- deprecated
	['eissn'] = true,
	['EISSN'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['entry'] = true,
	['entry-format'] = true,
	['entry-url'] = true,
	['entry-url-access'] = true,
	['eprint'] = true,															-- cite arxiv; here because allowed in cite ... as identifier
	['event'] = true,
	['event-format'] = true,
	['eventurl'] = true,
	['event-url'] = true,
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['hdl'] = true,
	['HDL'] = true,
	['hdl-access'] = true,
	['host'] = true,
	['id'] = true,
	['ID'] = true,
	['ignore-isbn-error'] = false,												-- deprecated
	['institution'] = true,
	['interviewer'] = true,
	['interviewer-first'] = true,
	['interviewer-given'] = true,
	['interviewer-last'] = true,
	['interviewer-surname'] = true,
	['interviewer-link'] = true,
	['interviewer-mask'] = true,
	['isbn'] = true,
	['ISBN'] = true,
	['isbn13'] = true,
	['ISBN13'] = true,
	['ismn'] = true,
	['ISMN'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['jstor-access'] = true,
	['lang'] = true,
	['language'] = true,
	['last'] = true,
	['lastauthoramp'] = false,													-- deprecated
	['last-author-amp'] = false,												-- deprecated
	['laydate'] = true,
	['lay-date'] = true,
	['laysource'] = true,
	['lay-source'] = true,
	['lay-format'] = true,
	['layurl'] = true,
	['lay-url'] = true,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['magazine'] = true,
	['medium'] = true,
	['minutes'] = true,
	['mode'] = true,
	['mr'] = true,
	['MR'] = true,
	['name-list-format'] = true,
	['name-list-style'] = true,
	['newspaper'] = true,
	['nocat'] = true,
	['nopp'] = true,
	['no-pp'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['ol-access'] = true,
	['orig-date'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['osti-access'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['people'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmc-embargo-date'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['publicationdate'] = true,
	['publication-date'] = true,
	['publicationplace'] = true,
	['publication-place'] = true,
	['publisher'] = true,
	['quotation'] = true,
	['quote'] = true,
	['quote-page'] = true,
	['quote-pages'] = true,
	['ref'] = true,
	['rfc'] = true,
	['RFC'] = true,
	['sbn'] = true,
	['SBN'] = true,
	['scale'] = true,
	['script-article'] = true,
	['script-chapter'] = true,
	['script-contribution'] = true,
	['script-entry'] = true,
	['script-journal'] = true,
	['script-magazine'] = true,
	['script-newspaper'] = true,
	['script-periodical'] = true,
	['script-quote'] = true,
	['script-section'] = true,
	['script-title'] = true,
	['script-website'] = true,
	['script-work'] = true,
	['season'] = true,
	['section'] = true,
	['section-format'] = true,
	['sectionurl'] = true,
	['section-url'] = true,
	['section-url-access'] = true,
	['series'] = true,
	['serieslink'] = true,
	['series-link'] = true,
	['seriesno'] = true,
	['series-no'] = true,
	['seriesnumber'] = true,
	['series-number'] = true,
	['ssrn'] = true,															-- cite ssrn; these two here because allowed in cite ... as identifier
	['SSRN'] = true,
	['subject'] = true,
	['subjectlink'] = false,													-- deprecated
	['subject-link'] = true,
	['subject-mask'] = true,
	['surname'] = true,
	['s2cid'] = true,
	['S2CID'] = true,
	['s2cid-access'] = true,
	['template-doc-demo'] = true,
	['time'] = true,
	['timecaption'] = true,
	['time-caption'] = true,
	['title'] = true,
	['titlelink'] = true,
	['title-link'] = true,
	['translator'] = true,
	['translator-first'] = true,
	['translator-given'] = true,
	['translator-last'] = true,	
	['translator-surname'] = true,
	['translator-link'] = true,
	['translator-mask'] = true,
	['trans-article'] = true,
	['trans-chapter'] = true,
	['trans-contribution'] = true,
	['trans-entry'] = true,
	['trans-journal'] = true,
	['trans-magazine'] = true,
	['trans-newspaper'] = true,
	['trans-periodical'] = true,
	['trans-quote'] = true,
	['trans-section'] = true,
	['trans-title'] = true,
	['trans-website'] = true,
	['trans-work'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['url-access'] = true,
	['url-status'] = true,
	['vauthors'] = true,
	['veditors'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
}

local numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-given#'] = true,
	['author#-given'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-surname#'] = true,
	['author#-surname'] = true,
	['author-link#'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author#link'] = true,
	['author-mask#'] = true,
	['author#-mask'] = true,
	['authormask#'] = false,													-- deprecated
	['author#mask'] = false,													-- deprecated
	['contributor#'] = true,
	['contributor-first#'] = true,
	['contributor#-first'] = true,
	['contributor-given#'] = true,
	['contributor#-given'] = true,
	['contributor-last#'] = true,
	['contributor#-last'] = true,
	['contributor-surname#'] = true,
	['contributor#-surname'] = true,
	['contributor-link#'] = true,
	['contributor#-link'] = true,
	['contributor-mask#'] = true,
	['contributor#-mask'] = true,
	['editor#'] = true,
	['editor-first#'] = true,
	['editor#-first'] = true,
	['editor-given#'] = true,
	['editor#-given'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-surname#'] = true,
	['editor#-surname'] = true,
	['editor-link#'] = true,
	['editor#-link'] = true,
	['editorlink#'] = false,													-- deprecated
	['editor#link'] = false,													-- deprecated
	['editor-mask#'] = true,
	['editor#-mask'] = true,
	['first#'] = true,
	['given#'] = true,
	['host#'] = true,
	['interviewer#'] = true,
	['interviewer-first#'] = true,
	['interviewer#-first'] = true,
	['interviewer-given#'] = true,
	['interviewer#-given'] = true,
	['interviewer-last#'] = true,
	['interviewer#-last'] = true,
	['interviewer-surname#'] = true,
	['interviewer#-surname'] = true,
	['interviewer-link#'] = true,
	['interviewer#-link'] = true,
	['interviewer-mask#'] = true,
	['interviewer#-mask'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-link#'] = true,
	['subject#-link'] = true,
	['subjectlink#'] = false,													-- deprecated
	['subject#link'] = false,													-- deprecated
	['subject-mask#'] = true,
	['subject#-mask'] = true,
	['surname#'] = true,
	['translator#'] = true,
	['translator-first#'] = true,
	['translator#-first'] = true,
	['translator-given#'] = true,
	['translator#-given'] = true,
	['translator-last#'] = true,
	['translator#-last'] = true,
	['translator-surname#'] = true,
	['translator#-surname'] = true,
	['translator-link#'] = true,
	['translator#-link'] = true,
	['translator-mask#'] = true,
	['translator#-mask'] = true,
}


--[[--------------------------&lt; P R E P R I N T   S U P P O R T E D   P A R A M E T E R S &gt;--------------------

Cite arXiv, cite biorxiv, cite citeseerx, and cite ssrn are preprint templates that use the limited set of parameters
defined in the limited_basic_arguments and limited_numbered_arguments tables.  Those lists are supplemented with a
template-specific list of parameters that are required by the particular template and may be exclusive to one of the
preprint templates.  Some of these parameters may also be available to the general cs1|2 templates.

Same conventions for true/false/nil as above.

]]

local preprint_arguments = {
	arxiv = {
		['arxiv'] = true,														-- cite arxiv and arxiv identifiers
		['class'] = true,
		['eprint'] = true,														-- cite arxiv and arxiv identifiers
		},
	biorxiv = {
		['biorxiv'] = true,
		},
	citeseerx = {
		['citeseerx'] = true,
		},
	ssrn = {
		['ssrn'] = true,
		['SSRN'] = true,
		},
	}


--[[--------------------------&lt; L I M I T E D   S U P P O R T E D   P A R A M E T E R S &gt;----------------------

This is an experiment that attempts to use validate() and a limited list of valid parameters to validate the
parameters provided in a cite arxiv, cite biorxiv, or cite citeseerx templates.  These parameters are common to
all three templates

Same conventions for true/false/nil as above.
	
]]

local limited_basic_arguments = {
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-given'] = true,
	['author-last'] = true,
	['author-surname'] = true,
	['author-link'] = true,
	['authorlink'] = true,
	['author-mask'] = true,
	['authormask'] = false,														-- deprecated
	['authors'] = true,
	['collaboration'] = true,
	['date'] = true,
	['df'] = true,
	['display-authors'] = true,
	['displayauthors'] = false,													-- deprecated
	['first'] = true,
	['given'] = true,
	['language'] = true,
	['last'] = true,
	['last-author-amp'] = false,												-- deprecated
	['lastauthoramp'] = false,													-- deprecated
	['mode'] = true,
	['name-list-format'] = true,
	['name-list-style'] = true,
	['nocat'] = true,
	['no-tracking'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['postscript'] = true,
	['pp'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['surname'] = true,
	['template-doc-demo'] = true,
	['title'] = true,
	['trans-title'] = true,
	['url'] = true,
	['URL'] = true,
	['vauthors'] = true,
	['year'] = true,
}

local limited_numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-given#'] = true,
	['author#-given'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-surname#'] = true,
	['author#-surname'] = true,
	['author-link#'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author#link'] = true,
	['author-mask#'] = true,
	['author#-mask'] = true,
	['authormask#'] = false,													-- deprecated
	['author#mask'] = false,													-- deprecated
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['surname#'] = true,
	}


--[[--------------------------&lt; U N I Q U E _ A R G U M E N T S &gt;----------------------------------------------

Some templates have unique parameters.  Those templates and their unique parameters are listed here. Keys in this
table are the template's CitationClass parameter value

Same conventions for true/false/nil as above.

]]

local unique_arguments = {
	['audio-visual'] = {
		['transcript'] = true,
		['transcript-format'] = true,
		['transcripturl'] = true,
		['transcript-url'] = true,
		},
	episode = {
		['airdate'] = true,
		['air-date'] = true,
		['credits'] = true,
		['episodelink'] = true,													-- alias of |title-link=
		['episode-link'] = true,												-- alias of |title-link=
		['network'] = true,
		['station'] = true,
		['transcript'] = true,
		['transcript-format'] = true,
		['transcripturl'] = true,
		['transcript-url'] = true,
		},
	mailinglist = {
		['mailinglist'] = true,
		['mailing-list'] = true,
		},
	map = {
		['inset'] = true,
		['map'] = true,
		['map-format'] = true,
		['mapurl'] = true,
		['map-url'] = true,
		['map-url-access'] = true,
		['script-map'] = true,
		['sections'] = true,
		['sheet'] = true,
		['sheets'] = true,
		['trans-map'] = true,
		},
	newsgroup = {
		['message-id'] = true,
		['newsgroup'] = true,
		},
	serial = {
		['airdate'] = true,
		['air-date'] = true,
		['credits'] = true,
		['episode'] = true,														-- cite serial only TODO: make available to cite episode?
		['episodelink'] = true,													-- aliases of |title-link=
		['episode-link'] = true,
		['network'] = true,
		['station'] = true,
		},
	}


--[[--------------------------&lt; T E M P L A T E _ L I S T _ G E T &gt;--------------------------------------------

gets a list of the templates from table t

]]

local function template_list_get (t)
	local out = {};																-- a table for output
	for k, _ in pairs (t) do													-- spin through the table and collect the keys
		table.insert (out, k)													-- add each key to the output table
	end
	return out;																	-- and done
end


--[[--------------------------&lt; E X P O R T E D   T A B L E S &gt;------------------------------------------------
]]

return {
	basic_arguments = basic_arguments,
	numbered_arguments = numbered_arguments,
	limited_basic_arguments = limited_basic_arguments,
	limited_numbered_arguments = limited_numbered_arguments,

	preprint_arguments = preprint_arguments,
	preprint_template_list = template_list_get (preprint_arguments),			-- make a template list from preprint_arguments{} table
	unique_arguments = unique_arguments,
	unique_param_template_list = template_list_get (unique_arguments),			-- make a template list from unique_arguments{} table
	};</text>
      <sha1>4jbcp11pa4k7hsy69nzp2juitha3wp5</sha1>
    </revision>
    <revision>
      <id>4806</id>
      <parentid>4805</parentid>
      <timestamp>2021-01-09T14:11:15Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4806</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="14751" sha1="me86q0rauh6lh0hgmc4j4or9ab0b0pb" xml:space="preserve">
--[[--------------------------&lt; S U P P O R T E D   P A R A M E T E R S &gt;--------------------------------------

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported. remove entirely
	
]]

local basic_arguments = {
	['accessdate'] = true,
	['access-date'] = true,
	['agency'] = true,
	['archivedate'] = true,
	['archive-date'] = true,
	['archive-format'] = true,
	['archiveurl'] = true,
	['archive-url'] = true,
	['article'] = true,
	['article-format'] = true,
	['article-url'] = true,
	['article-url-access'] = true,
	['arxiv'] = true,															-- cite arxiv; here because allowed in cite ... as identifier
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-given'] = true,
	['author-last'] = true,
	['author-surname'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['bibcode'] = true,
	['bibcode-access'] = true,
	['biorxiv'] = true,															-- cite biorxiv; here because allowed in cite ... as identifier
	['booktitle'] = true,
	['book-title'] = true,
	['cartography'] = true,
	['chapter'] = true,
	['chapter-format'] = true,
	['chapterurl'] = true,
	['chapter-url'] = true,
	['chapter-url-access'] = true,
	['citeseerx'] = true,														-- cite citeseerx; here because allowed in cite ... as identifier
	['collaboration'] = true,
	['conference'] = true,
	['conference-format'] = true,
	['conferenceurl'] = false,
	['conference-url'] = true,
	['contribution'] = true,
	['contribution-format'] = true,
	['contributionurl'] = false,
	['contribution-url'] = true,
	['contribution-url-access'] = true,
	['contributor'] = true,
	['contributor-first'] = true,
	['contributor-given'] = true,
	['contributor-last'] = true,
	['contributor-surname'] = true,
	['contributor-link'] = true,
	['contributor-mask'] = true,
	['date'] = true,
	['degree'] = true,
	['department'] = true,
	['df'] = true,
	['dictionary'] = true,
	['display-authors'] = true,
	['display-contributors'] = true,
	['display-editors'] = true,
	['display-interviewers'] = true,
	['display-subjects'] = true,
	['display-translators'] = true,
	['docket'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-access'] = true,
	['doi-broken-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['editor-first'] = true,
	['editor-given'] = true,
	['editor-last'] = true,
	['editor-surname'] = true,
	['editor-link'] = true,
	['editor-mask'] = true,
	['eissn'] = true,
	['EISSN'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['entry'] = true,
	['entry-format'] = true,
	['entry-url'] = true,
	['entry-url-access'] = true,
	['eprint'] = true,															-- cite arxiv; here because allowed in cite ... as identifier
	['event'] = true, -- synonym of conference in /Config, but used in Cite speech?
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['hdl'] = true,
	['HDL'] = true,
	['hdl-access'] = true,
	['host'] = true,
	['id'] = true,
	['ID'] = true,
	['institution'] = true,
	['interviewer'] = true,
	['interviewer-first'] = true,
	['interviewer-given'] = true,
	['interviewer-last'] = true,
	['interviewer-surname'] = true,
	['interviewer-link'] = true,
	['interviewer-mask'] = true,
	['isbn'] = true,
	['ISBN'] = true,
	['isbn13'] = true,
	['ISBN13'] = true,
	['ismn'] = true,
	['ISMN'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['jstor-access'] = true,
	['lang'] = true,
	['language'] = true,
	['last'] = true,
	['laydate'] = false,
	['lay-date'] = true,
	['laysource'] = false,
	['lay-source'] = true,
	['lay-format'] = true,
	['layurl'] = false,
	['lay-url'] = true,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['magazine'] = true,
	['medium'] = true,
	['minutes'] = true,
	['mode'] = true,
	['mr'] = true,
	['MR'] = true,
	['name-list-format'] = true,
	['name-list-style'] = true,
	['newspaper'] = true,
	['nopp'] = true,
	['no-pp'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['ol-access'] = true,
	['orig-date'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['osti-access'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['people'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmc-embargo-date'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['publicationdate'] = true,
	['publication-date'] = true,
	['publicationplace'] = true,
	['publication-place'] = true,
	['publisher'] = true,
	['quotation'] = true,
	['quote'] = true,
	['quote-page'] = true,
	['quote-pages'] = true,
	['ref'] = true,
	['rfc'] = true,
	['RFC'] = true,
	['sbn'] = true,
	['SBN'] = true,
	['scale'] = true,
	['script-article'] = true,
	['script-chapter'] = true,
	['script-contribution'] = true,
	['script-entry'] = true,
	['script-journal'] = true,
	['script-magazine'] = true,
	['script-newspaper'] = true,
	['script-periodical'] = true,
	['script-quote'] = true,
	['script-section'] = true,
	['script-title'] = true,
	['script-website'] = true,
	['script-work'] = true,
	['season'] = true,
	['section'] = true,
	['section-format'] = true,
	['sectionurl'] = false,
	['section-url'] = true,
	['section-url-access'] = true,
	['series'] = true,
	['serieslink'] = true,
	['series-link'] = true,
	['seriesno'] = false,
	['series-no'] = true,
	['series-number'] = true,
	['ssrn'] = true,															-- cite ssrn; these two here because allowed in cite ... as identifier
	['SSRN'] = true,
	['subject'] = true,
	['subject-link'] = true,
	['subject-mask'] = true,
	['surname'] = true,
	['s2cid'] = true,
	['S2CID'] = true,
	['s2cid-access'] = true,
	['template-doc-demo'] = true,
	['time'] = true,
	['timecaption'] = false,
	['time-caption'] = true,
	['title'] = true,
	['titlelink'] = false,
	['title-link'] = true,
	['translator'] = true,
	['translator-first'] = true,
	['translator-given'] = true,
	['translator-last'] = true,	
	['translator-surname'] = true,
	['translator-link'] = true,
	['translator-mask'] = true,
	['trans-article'] = true,
	['trans-chapter'] = true,
	['trans-contribution'] = true,
	['trans-entry'] = true,
	['trans-journal'] = true,
	['trans-magazine'] = true,
	['trans-newspaper'] = true,
	['trans-periodical'] = true,
	['trans-quote'] = true,
	['trans-section'] = true,
	['trans-title'] = true,
	['trans-website'] = true,
	['trans-work'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['url-access'] = true,
	['url-status'] = true,
	['vauthors'] = true,
	['veditors'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
}

local numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-given#'] = true,
	['author#-given'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-surname#'] = true,
	['author#-surname'] = true,
	['author-link#'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author#link'] = true,
	['author-mask#'] = true,
	['author#-mask'] = true,
	['contributor#'] = true,
	['contributor-first#'] = true,
	['contributor#-first'] = true,
	['contributor-given#'] = true,
	['contributor#-given'] = true,
	['contributor-last#'] = true,
	['contributor#-last'] = true,
	['contributor-surname#'] = true,
	['contributor#-surname'] = true,
	['contributor-link#'] = true,
	['contributor#-link'] = true,
	['contributor-mask#'] = true,
	['contributor#-mask'] = true,
	['editor#'] = true,
	['editor-first#'] = true,
	['editor#-first'] = true,
	['editor-given#'] = true,
	['editor#-given'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-surname#'] = true,
	['editor#-surname'] = true,
	['editor-link#'] = true,
	['editor#-link'] = true,
	['editor-mask#'] = true,
	['editor#-mask'] = true,
	['first#'] = true,
	['given#'] = true,
	['host#'] = true,
	['interviewer#'] = true,
	['interviewer-first#'] = true,
	['interviewer#-first'] = true,
	['interviewer-given#'] = true,
	['interviewer#-given'] = true,
	['interviewer-last#'] = true,
	['interviewer#-last'] = true,
	['interviewer-surname#'] = true,
	['interviewer#-surname'] = true,
	['interviewer-link#'] = true,
	['interviewer#-link'] = true,
	['interviewer-mask#'] = true,
	['interviewer#-mask'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-link#'] = true,
	['subject#-link'] = true,
	['subject-mask#'] = true,
	['subject#-mask'] = true,
	['surname#'] = true,
	['translator#'] = true,
	['translator-first#'] = true,
	['translator#-first'] = true,
	['translator-given#'] = true,
	['translator#-given'] = true,
	['translator-last#'] = true,
	['translator#-last'] = true,
	['translator-surname#'] = true,
	['translator#-surname'] = true,
	['translator-link#'] = true,
	['translator#-link'] = true,
	['translator-mask#'] = true,
	['translator#-mask'] = true,
}


--[[--------------------------&lt; P R E P R I N T   S U P P O R T E D   P A R A M E T E R S &gt;--------------------

Cite arXiv, cite biorxiv, cite citeseerx, and cite ssrn are preprint templates that use the limited set of parameters
defined in the limited_basic_arguments and limited_numbered_arguments tables.  Those lists are supplemented with a
template-specific list of parameters that are required by the particular template and may be exclusive to one of the
preprint templates.  Some of these parameters may also be available to the general cs1|2 templates.

Same conventions for true/false/nil as above.

]]

local preprint_arguments = {
	arxiv = {
		['arxiv'] = true,														-- cite arxiv and arxiv identifiers
		['class'] = true,
		['eprint'] = true,														-- cite arxiv and arxiv identifiers
		},
	biorxiv = {
		['biorxiv'] = true,
		},
	citeseerx = {
		['citeseerx'] = true,
		},
	ssrn = {
		['ssrn'] = true,
		['SSRN'] = true,
		},
	}


--[[--------------------------&lt; L I M I T E D   S U P P O R T E D   P A R A M E T E R S &gt;----------------------

This is an experiment that attempts to use validate() and a limited list of valid parameters to validate the
parameters provided in a cite arxiv, cite biorxiv, or cite citeseerx templates.  These parameters are common to
all three templates

Same conventions for true/false/nil as above.
	
]]

local limited_basic_arguments = {
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-given'] = true,
	['author-last'] = true,
	['author-surname'] = true,
	['author-link'] = true,
	['authorlink'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['collaboration'] = true,
	['date'] = true,
	['df'] = true,
	['display-authors'] = true,
	['first'] = true,
	['given'] = true,
	['language'] = true,
	['last'] = true,
	['mode'] = true,
	['name-list-format'] = true,
	['name-list-style'] = true,
	['no-tracking'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['postscript'] = true,
	['pp'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['surname'] = true,
	['template-doc-demo'] = true,
	['title'] = true,
	['trans-title'] = true,
	['url'] = true,
	['URL'] = true,
	['vauthors'] = true,
	['year'] = true,
}

local limited_numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-given#'] = true,
	['author#-given'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-surname#'] = true,
	['author#-surname'] = true,
	['author-link#'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author#link'] = true,
	['author-mask#'] = true,
	['author#-mask'] = true,
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['surname#'] = true,
	}


--[[--------------------------&lt; U N I Q U E _ A R G U M E N T S &gt;----------------------------------------------

Some templates have unique parameters.  Those templates and their unique parameters are listed here. Keys in this
table are the template's CitationClass parameter value

Same conventions for true/false/nil as above.

]]

local unique_arguments = {
	['audio-visual'] = {
		['transcript'] = true,
		['transcript-format'] = true,
		['transcripturl'] = true,
		['transcript-url'] = true,
		},
	episode = {
		['airdate'] = true,
		['air-date'] = true,
		['credits'] = true,
		['episodelink'] = true,													-- alias of |title-link=
		['episode-link'] = true,												-- alias of |title-link=
		['network'] = true,
		['station'] = true,
		['transcript'] = true,
		['transcript-format'] = true,
		['transcripturl'] = true,
		['transcript-url'] = true,
		},
	mailinglist = {
		['mailinglist'] = true,
		['mailing-list'] = true,
		},
	map = {
		['inset'] = true,
		['map'] = true,
		['map-format'] = true,
		['mapurl'] = true,
		['map-url'] = true,
		['map-url-access'] = true,
		['script-map'] = true,
		['sections'] = true,
		['sheet'] = true,
		['sheets'] = true,
		['trans-map'] = true,
		},
	newsgroup = {
		['message-id'] = true,
		['newsgroup'] = true,
		},
	serial = {
		['airdate'] = true,
		['air-date'] = true,
		['credits'] = true,
		['episode'] = true,														-- cite serial only TODO: make available to cite episode?
		['episodelink'] = true,													-- aliases of |title-link=
		['episode-link'] = true,
		['network'] = true,
		['station'] = true,
		},
	}


--[[--------------------------&lt; T E M P L A T E _ L I S T _ G E T &gt;--------------------------------------------

gets a list of the templates from table t

]]

local function template_list_get (t)
	local out = {};																-- a table for output
	for k, _ in pairs (t) do													-- spin through the table and collect the keys
		table.insert (out, k)													-- add each key to the output table
	end
	return out;																	-- and done
end


--[[--------------------------&lt; E X P O R T E D   T A B L E S &gt;------------------------------------------------
]]

return {
	basic_arguments = basic_arguments,
	numbered_arguments = numbered_arguments,
	limited_basic_arguments = limited_basic_arguments,
	limited_numbered_arguments = limited_numbered_arguments,

	preprint_arguments = preprint_arguments,
	preprint_template_list = template_list_get (preprint_arguments),			-- make a template list from preprint_arguments{} table
	unique_arguments = unique_arguments,
	unique_param_template_list = template_list_get (unique_arguments),			-- make a template list from unique_arguments{} table
	};</text>
      <sha1>me86q0rauh6lh0hgmc4j4or9ab0b0pb</sha1>
    </revision>
    <revision>
      <id>4807</id>
      <parentid>4806</parentid>
      <timestamp>2021-04-10T13:14:51Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4807</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="14682" sha1="sdu6ecv0a6scgu3e4sarhuxpdw86tlw" xml:space="preserve">
--[[--------------------------&lt; S U P P O R T E D   P A R A M E T E R S &gt;--------------------------------------

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	discouraged - pre-deprecation purgatory; may someday be deprecated; or not
	nil - these parameters are no longer supported. remove entirely
	
]]

local basic_arguments = {
	['accessdate'] = 'discouraged',
	['access-date'] = true,
	['agency'] = true,
	['archivedate'] = 'discouraged',
	['archive-date'] = true,
	['archive-format'] = true,
	['archiveurl'] = 'discouraged',
	['archive-url'] = true,
	['article'] = true,
	['article-format'] = true,
	['article-url'] = true,
	['article-url-access'] = true,
	['arxiv'] = true,															-- cite arxiv; here because allowed in cite ... as identifier
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-given'] = true,
	['author-last'] = true,
	['author-surname'] = true,
	['authorlink'] = 'discouraged',
	['author-link'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['bibcode'] = true,
	['bibcode-access'] = true,
	['biorxiv'] = true,															-- cite biorxiv; here because allowed in cite ... as identifier
	['booktitle'] = false,
	['book-title'] = true,
	['cartography'] = true,
	['chapter'] = true,
	['chapter-format'] = true,
	['chapterurl'] = false,
	['chapter-url'] = true,
	['chapter-url-access'] = true,
	['citeseerx'] = true,														-- cite citeseerx; here because allowed in cite ... as identifier
	['collaboration'] = true,
	['conference'] = true,
	['conference-format'] = true,
	['conference-url'] = true,
	['contribution'] = true,
	['contribution-format'] = true,
	['contribution-url'] = true,
	['contribution-url-access'] = true,
	['contributor'] = true,
	['contributor-first'] = true,
	['contributor-given'] = true,
	['contributor-last'] = true,
	['contributor-surname'] = true,
	['contributor-link'] = true,
	['contributor-mask'] = true,
	['date'] = true,
	['degree'] = true,
	['department'] = true,
	['df'] = true,
	['dictionary'] = true,
	['display-authors'] = true,
	['display-contributors'] = true,
	['display-editors'] = true,
	['display-interviewers'] = true,
	['display-subjects'] = true,
	['display-translators'] = true,
	['docket'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-access'] = true,
	['doi-broken-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['editor-first'] = true,
	['editor-given'] = true,
	['editor-last'] = true,
	['editor-surname'] = true,
	['editor-link'] = true,
	['editor-mask'] = true,
	['eissn'] = true,
	['EISSN'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['entry'] = true,
	['entry-format'] = true,
	['entry-url'] = true,
	['entry-url-access'] = true,
	['eprint'] = true,															-- cite arxiv; here because allowed in cite ... as identifier
	['event'] = true,															-- synonym of conference in /Config, but used in Cite speech?
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['hdl'] = true,
	['HDL'] = true,
	['hdl-access'] = true,
	['host'] = true,
	['id'] = true,
	['ID'] = true,
	['institution'] = true,
	['interviewer'] = true,
	['interviewer-first'] = true,
	['interviewer-given'] = true,
	['interviewer-last'] = true,
	['interviewer-surname'] = true,
	['interviewer-link'] = true,
	['interviewer-mask'] = true,
	['isbn'] = true,
	['ISBN'] = true,
	['isbn13'] = true,
	['ISBN13'] = true,
	['ismn'] = true,
	['ISMN'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['jstor-access'] = true,
	['lang'] = true,
	['language'] = true,
	['last'] = true,
	['lay-date'] = true,
	['lay-source'] = true,
	['lay-format'] = true,
	['lay-url'] = true,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['magazine'] = true,
	['medium'] = true,
	['minutes'] = true,
	['mode'] = true,
	['mr'] = true,
	['MR'] = true,
	['name-list-style'] = true,
	['newspaper'] = true,
	['nopp'] = false,
	['no-pp'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['ol-access'] = true,
	['orig-date'] = true,
	['origyear'] = 'discouraged',
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['osti-access'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['people'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmc-embargo-date'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['publicationdate'] = false,
	['publication-date'] = true,
	['publicationplace'] = false,
	['publication-place'] = true,
	['publisher'] = true,
	['quotation'] = true,
	['quote'] = true,
	['quote-page'] = true,
	['quote-pages'] = true,
	['ref'] = true,
	['rfc'] = true,
	['RFC'] = true,
	['sbn'] = true,
	['SBN'] = true,
	['scale'] = true,
	['script-article'] = true,
	['script-chapter'] = true,
	['script-contribution'] = true,
	['script-entry'] = true,
	['script-journal'] = true,
	['script-magazine'] = true,
	['script-newspaper'] = true,
	['script-periodical'] = true,
	['script-quote'] = true,
	['script-section'] = true,
	['script-title'] = true,
	['script-website'] = true,
	['script-work'] = true,
	['season'] = true,
	['section'] = true,
	['section-format'] = true,
	['section-url'] = true,
	['section-url-access'] = true,
	['series'] = true,
	['serieslink'] = false,
	['series-link'] = true,
	['series-no'] = false,
	['series-number'] = true,
	['ssrn'] = true,															-- cite ssrn; these two here because allowed in cite ... as identifier
	['SSRN'] = true,
	['subject'] = true,
	['subject-link'] = true,
	['subject-mask'] = true,
	['surname'] = true,
	['s2cid'] = true,
	['S2CID'] = true,
	['s2cid-access'] = true,
	['template-doc-demo'] = true,
	['time'] = true,
	['time-caption'] = true,
	['title'] = true,
	['title-link'] = true,
	['translator'] = true,
	['translator-first'] = true,
	['translator-given'] = true,
	['translator-last'] = true,	
	['translator-surname'] = true,
	['translator-link'] = true,
	['translator-mask'] = true,
	['trans-article'] = true,
	['trans-chapter'] = true,
	['trans-contribution'] = true,
	['trans-entry'] = true,
	['trans-journal'] = true,
	['trans-magazine'] = true,
	['trans-newspaper'] = true,
	['trans-periodical'] = true,
	['trans-quote'] = true,
	['trans-section'] = true,
	['trans-title'] = true,
	['trans-website'] = true,
	['trans-work'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['url-access'] = true,
	['url-status'] = true,
	['vauthors'] = true,
	['veditors'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
}

local numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-given#'] = true,
	['author#-given'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-surname#'] = true,
	['author#-surname'] = true,
	['author-link#'] = true,
	['author#-link'] = true,
	['authorlink#'] = 'discouraged',
	['author#link'] = 'discouraged',
	['author-mask#'] = true,
	['author#-mask'] = true,
	['contributor#'] = true,
	['contributor-first#'] = true,
	['contributor#-first'] = true,
	['contributor-given#'] = true,
	['contributor#-given'] = true,
	['contributor-last#'] = true,
	['contributor#-last'] = true,
	['contributor-surname#'] = true,
	['contributor#-surname'] = true,
	['contributor-link#'] = true,
	['contributor#-link'] = true,
	['contributor-mask#'] = true,
	['contributor#-mask'] = true,
	['editor#'] = true,
	['editor-first#'] = true,
	['editor#-first'] = true,
	['editor-given#'] = true,
	['editor#-given'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-surname#'] = true,
	['editor#-surname'] = true,
	['editor-link#'] = true,
	['editor#-link'] = true,
	['editor-mask#'] = true,
	['editor#-mask'] = true,
	['first#'] = true,
	['given#'] = true,
	['host#'] = true,
	['interviewer#'] = true,
	['interviewer-first#'] = true,
	['interviewer#-first'] = true,
	['interviewer-given#'] = true,
	['interviewer#-given'] = true,
	['interviewer-last#'] = true,
	['interviewer#-last'] = true,
	['interviewer-surname#'] = true,
	['interviewer#-surname'] = true,
	['interviewer-link#'] = true,
	['interviewer#-link'] = true,
	['interviewer-mask#'] = true,
	['interviewer#-mask'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-link#'] = true,
	['subject#-link'] = true,
	['subject-mask#'] = true,
	['subject#-mask'] = true,
	['surname#'] = true,
	['translator#'] = true,
	['translator-first#'] = true,
	['translator#-first'] = true,
	['translator-given#'] = true,
	['translator#-given'] = true,
	['translator-last#'] = true,
	['translator#-last'] = true,
	['translator-surname#'] = true,
	['translator#-surname'] = true,
	['translator-link#'] = true,
	['translator#-link'] = true,
	['translator-mask#'] = true,
	['translator#-mask'] = true,
}


--[[--------------------------&lt; P R E P R I N T   S U P P O R T E D   P A R A M E T E R S &gt;--------------------

Cite arXiv, cite biorxiv, cite citeseerx, and cite ssrn are preprint templates that use the limited set of parameters
defined in the limited_basic_arguments and limited_numbered_arguments tables.  Those lists are supplemented with a
template-specific list of parameters that are required by the particular template and may be exclusive to one of the
preprint templates.  Some of these parameters may also be available to the general cs1|2 templates.

Same conventions for true/false/dicouraged/nil as above.

]]

local preprint_arguments = {
	arxiv = {
		['arxiv'] = true,														-- cite arxiv and arxiv identifiers
		['class'] = true,
		['eprint'] = true,														-- cite arxiv and arxiv identifiers
		},
	biorxiv = {
		['biorxiv'] = true,
		},
	citeseerx = {
		['citeseerx'] = true,
		},
	ssrn = {
		['ssrn'] = true,
		['SSRN'] = true,
		},
	}


--[[--------------------------&lt; L I M I T E D   S U P P O R T E D   P A R A M E T E R S &gt;----------------------

cite arxiv, cite biorxiv, cite citeseerx, and cite ssrn templates are preprint templates so are allowed only a
limited subset of parameters allowed to all other cs1|2 templates.  The limited subset is defined here.

Same conventions for true/false/dicouraged/nil as above.
	
]]

local limited_basic_arguments = {
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-given'] = true,
	['author-last'] = true,
	['author-surname'] = true,
	['author-link'] = true,
	['authorlink'] = 'discouraged',
	['author-mask'] = true,
	['authors'] = true,
	['collaboration'] = true,
	['date'] = true,
	['df'] = true,
	['display-authors'] = true,
	['first'] = true,
	['given'] = true,
	['language'] = true,
	['last'] = true,
	['mode'] = true,
	['name-list-style'] = true,
	['no-tracking'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['postscript'] = true,
	['pp'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['surname'] = true,
	['template-doc-demo'] = true,
	['title'] = true,
	['trans-title'] = true,
	['url'] = true,
	['URL'] = true,
	['vauthors'] = true,
	['year'] = true,
}

local limited_numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-given#'] = true,
	['author#-given'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-surname#'] = true,
	['author#-surname'] = true,
	['author-link#'] = true,
	['author#-link'] = true,
	['authorlink#'] = 'discouraged',
	['author#link'] = 'discouraged',
	['author-mask#'] = true,
	['author#-mask'] = true,
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['surname#'] = true,
	}


--[[--------------------------&lt; U N I Q U E _ A R G U M E N T S &gt;----------------------------------------------

Some templates have unique parameters.  Those templates and their unique parameters are listed here. Keys in this
table are the template's CitationClass parameter value

Same conventions for true/false/dicouraged/nil as above.

]]

local unique_arguments = {
	['audio-visual'] = {
		['transcript'] = true,
		['transcript-format'] = true,
		['transcripturl'] = false,
		['transcript-url'] = true,
		},
	episode = {
		['airdate'] = 'discouraged',
		['air-date'] = true,
		['credits'] = true,
		['episodelink'] = false,												-- alias of |title-link=
		['episode-link'] = true,												-- alias of |title-link=
		['network'] = true,
		['station'] = true,
		['transcript'] = true,
		['transcript-format'] = true,
		['transcripturl'] = false,
		['transcript-url'] = true,
		},
	mailinglist = {
		['mailinglist'] = false,
		['mailing-list'] = true,
		},
	map = {
		['inset'] = true,
		['map'] = true,
		['map-format'] = true,
		['mapurl'] = false,
		['map-url'] = true,
		['map-url-access'] = true,
		['script-map'] = true,
		['sections'] = true,
		['sheet'] = true,
		['sheets'] = true,
		['trans-map'] = true,
		},
	newsgroup = {
		['message-id'] = true,
		['newsgroup'] = true,
		},
	serial = {
		['airdate'] = 'discouraged',
		['air-date'] = true,
		['credits'] = true,
		['episode'] = true,														-- cite serial only TODO: make available to cite episode?
		['episodelink'] = false,
		['episode-link'] = true,												-- alias of |title-link=
		['network'] = true,
		['station'] = true,
		},
	}


--[[--------------------------&lt; T E M P L A T E _ L I S T _ G E T &gt;--------------------------------------------

gets a list of the templates from table t

]]

local function template_list_get (t)
	local out = {};																-- a table for output
	for k, _ in pairs (t) do													-- spin through the table and collect the keys
		table.insert (out, k)													-- add each key to the output table
	end
	return out;																	-- and done
end


--[[--------------------------&lt; E X P O R T E D   T A B L E S &gt;------------------------------------------------
]]

return {
	basic_arguments = basic_arguments,
	numbered_arguments = numbered_arguments,
	limited_basic_arguments = limited_basic_arguments,
	limited_numbered_arguments = limited_numbered_arguments,

	preprint_arguments = preprint_arguments,
	preprint_template_list = template_list_get (preprint_arguments),			-- make a template list from preprint_arguments{} table
	unique_arguments = unique_arguments,
	unique_param_template_list = template_list_get (unique_arguments),			-- make a template list from unique_arguments{} table
	};</text>
      <sha1>sdu6ecv0a6scgu3e4sarhuxpdw86tlw</sha1>
    </revision>
    <revision>
      <id>4808</id>
      <parentid>4807</parentid>
      <timestamp>2021-04-10T14:25:07Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <minor />
      <comment>restore |series-no=;</comment>
      <origin>4808</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="14681" sha1="htr8gi1skn9htxtyddaxevqaxjp40e3" xml:space="preserve">
--[[--------------------------&lt; S U P P O R T E D   P A R A M E T E R S &gt;--------------------------------------

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	discouraged - pre-deprecation purgatory; may someday be deprecated; or not
	nil - these parameters are no longer supported. remove entirely
	
]]

local basic_arguments = {
	['accessdate'] = 'discouraged',
	['access-date'] = true,
	['agency'] = true,
	['archivedate'] = 'discouraged',
	['archive-date'] = true,
	['archive-format'] = true,
	['archiveurl'] = 'discouraged',
	['archive-url'] = true,
	['article'] = true,
	['article-format'] = true,
	['article-url'] = true,
	['article-url-access'] = true,
	['arxiv'] = true,															-- cite arxiv; here because allowed in cite ... as identifier
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-given'] = true,
	['author-last'] = true,
	['author-surname'] = true,
	['authorlink'] = 'discouraged',
	['author-link'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['bibcode'] = true,
	['bibcode-access'] = true,
	['biorxiv'] = true,															-- cite biorxiv; here because allowed in cite ... as identifier
	['booktitle'] = false,
	['book-title'] = true,
	['cartography'] = true,
	['chapter'] = true,
	['chapter-format'] = true,
	['chapterurl'] = false,
	['chapter-url'] = true,
	['chapter-url-access'] = true,
	['citeseerx'] = true,														-- cite citeseerx; here because allowed in cite ... as identifier
	['collaboration'] = true,
	['conference'] = true,
	['conference-format'] = true,
	['conference-url'] = true,
	['contribution'] = true,
	['contribution-format'] = true,
	['contribution-url'] = true,
	['contribution-url-access'] = true,
	['contributor'] = true,
	['contributor-first'] = true,
	['contributor-given'] = true,
	['contributor-last'] = true,
	['contributor-surname'] = true,
	['contributor-link'] = true,
	['contributor-mask'] = true,
	['date'] = true,
	['degree'] = true,
	['department'] = true,
	['df'] = true,
	['dictionary'] = true,
	['display-authors'] = true,
	['display-contributors'] = true,
	['display-editors'] = true,
	['display-interviewers'] = true,
	['display-subjects'] = true,
	['display-translators'] = true,
	['docket'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-access'] = true,
	['doi-broken-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['editor-first'] = true,
	['editor-given'] = true,
	['editor-last'] = true,
	['editor-surname'] = true,
	['editor-link'] = true,
	['editor-mask'] = true,
	['eissn'] = true,
	['EISSN'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['entry'] = true,
	['entry-format'] = true,
	['entry-url'] = true,
	['entry-url-access'] = true,
	['eprint'] = true,															-- cite arxiv; here because allowed in cite ... as identifier
	['event'] = true,															-- synonym of conference in /Config, but used in Cite speech?
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['hdl'] = true,
	['HDL'] = true,
	['hdl-access'] = true,
	['host'] = true,
	['id'] = true,
	['ID'] = true,
	['institution'] = true,
	['interviewer'] = true,
	['interviewer-first'] = true,
	['interviewer-given'] = true,
	['interviewer-last'] = true,
	['interviewer-surname'] = true,
	['interviewer-link'] = true,
	['interviewer-mask'] = true,
	['isbn'] = true,
	['ISBN'] = true,
	['isbn13'] = true,
	['ISBN13'] = true,
	['ismn'] = true,
	['ISMN'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['jstor-access'] = true,
	['lang'] = true,
	['language'] = true,
	['last'] = true,
	['lay-date'] = true,
	['lay-source'] = true,
	['lay-format'] = true,
	['lay-url'] = true,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['magazine'] = true,
	['medium'] = true,
	['minutes'] = true,
	['mode'] = true,
	['mr'] = true,
	['MR'] = true,
	['name-list-style'] = true,
	['newspaper'] = true,
	['nopp'] = false,
	['no-pp'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['ol-access'] = true,
	['orig-date'] = true,
	['origyear'] = 'discouraged',
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['osti-access'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['people'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmc-embargo-date'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['publicationdate'] = false,
	['publication-date'] = true,
	['publicationplace'] = false,
	['publication-place'] = true,
	['publisher'] = true,
	['quotation'] = true,
	['quote'] = true,
	['quote-page'] = true,
	['quote-pages'] = true,
	['ref'] = true,
	['rfc'] = true,
	['RFC'] = true,
	['sbn'] = true,
	['SBN'] = true,
	['scale'] = true,
	['script-article'] = true,
	['script-chapter'] = true,
	['script-contribution'] = true,
	['script-entry'] = true,
	['script-journal'] = true,
	['script-magazine'] = true,
	['script-newspaper'] = true,
	['script-periodical'] = true,
	['script-quote'] = true,
	['script-section'] = true,
	['script-title'] = true,
	['script-website'] = true,
	['script-work'] = true,
	['season'] = true,
	['section'] = true,
	['section-format'] = true,
	['section-url'] = true,
	['section-url-access'] = true,
	['series'] = true,
	['serieslink'] = false,
	['series-link'] = true,
	['series-no'] = true,
	['series-number'] = true,
	['ssrn'] = true,															-- cite ssrn; these two here because allowed in cite ... as identifier
	['SSRN'] = true,
	['subject'] = true,
	['subject-link'] = true,
	['subject-mask'] = true,
	['surname'] = true,
	['s2cid'] = true,
	['S2CID'] = true,
	['s2cid-access'] = true,
	['template-doc-demo'] = true,
	['time'] = true,
	['time-caption'] = true,
	['title'] = true,
	['title-link'] = true,
	['translator'] = true,
	['translator-first'] = true,
	['translator-given'] = true,
	['translator-last'] = true,	
	['translator-surname'] = true,
	['translator-link'] = true,
	['translator-mask'] = true,
	['trans-article'] = true,
	['trans-chapter'] = true,
	['trans-contribution'] = true,
	['trans-entry'] = true,
	['trans-journal'] = true,
	['trans-magazine'] = true,
	['trans-newspaper'] = true,
	['trans-periodical'] = true,
	['trans-quote'] = true,
	['trans-section'] = true,
	['trans-title'] = true,
	['trans-website'] = true,
	['trans-work'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['url-access'] = true,
	['url-status'] = true,
	['vauthors'] = true,
	['veditors'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
}

local numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-given#'] = true,
	['author#-given'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-surname#'] = true,
	['author#-surname'] = true,
	['author-link#'] = true,
	['author#-link'] = true,
	['authorlink#'] = 'discouraged',
	['author#link'] = 'discouraged',
	['author-mask#'] = true,
	['author#-mask'] = true,
	['contributor#'] = true,
	['contributor-first#'] = true,
	['contributor#-first'] = true,
	['contributor-given#'] = true,
	['contributor#-given'] = true,
	['contributor-last#'] = true,
	['contributor#-last'] = true,
	['contributor-surname#'] = true,
	['contributor#-surname'] = true,
	['contributor-link#'] = true,
	['contributor#-link'] = true,
	['contributor-mask#'] = true,
	['contributor#-mask'] = true,
	['editor#'] = true,
	['editor-first#'] = true,
	['editor#-first'] = true,
	['editor-given#'] = true,
	['editor#-given'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-surname#'] = true,
	['editor#-surname'] = true,
	['editor-link#'] = true,
	['editor#-link'] = true,
	['editor-mask#'] = true,
	['editor#-mask'] = true,
	['first#'] = true,
	['given#'] = true,
	['host#'] = true,
	['interviewer#'] = true,
	['interviewer-first#'] = true,
	['interviewer#-first'] = true,
	['interviewer-given#'] = true,
	['interviewer#-given'] = true,
	['interviewer-last#'] = true,
	['interviewer#-last'] = true,
	['interviewer-surname#'] = true,
	['interviewer#-surname'] = true,
	['interviewer-link#'] = true,
	['interviewer#-link'] = true,
	['interviewer-mask#'] = true,
	['interviewer#-mask'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-link#'] = true,
	['subject#-link'] = true,
	['subject-mask#'] = true,
	['subject#-mask'] = true,
	['surname#'] = true,
	['translator#'] = true,
	['translator-first#'] = true,
	['translator#-first'] = true,
	['translator-given#'] = true,
	['translator#-given'] = true,
	['translator-last#'] = true,
	['translator#-last'] = true,
	['translator-surname#'] = true,
	['translator#-surname'] = true,
	['translator-link#'] = true,
	['translator#-link'] = true,
	['translator-mask#'] = true,
	['translator#-mask'] = true,
}


--[[--------------------------&lt; P R E P R I N T   S U P P O R T E D   P A R A M E T E R S &gt;--------------------

Cite arXiv, cite biorxiv, cite citeseerx, and cite ssrn are preprint templates that use the limited set of parameters
defined in the limited_basic_arguments and limited_numbered_arguments tables.  Those lists are supplemented with a
template-specific list of parameters that are required by the particular template and may be exclusive to one of the
preprint templates.  Some of these parameters may also be available to the general cs1|2 templates.

Same conventions for true/false/dicouraged/nil as above.

]]

local preprint_arguments = {
	arxiv = {
		['arxiv'] = true,														-- cite arxiv and arxiv identifiers
		['class'] = true,
		['eprint'] = true,														-- cite arxiv and arxiv identifiers
		},
	biorxiv = {
		['biorxiv'] = true,
		},
	citeseerx = {
		['citeseerx'] = true,
		},
	ssrn = {
		['ssrn'] = true,
		['SSRN'] = true,
		},
	}


--[[--------------------------&lt; L I M I T E D   S U P P O R T E D   P A R A M E T E R S &gt;----------------------

cite arxiv, cite biorxiv, cite citeseerx, and cite ssrn templates are preprint templates so are allowed only a
limited subset of parameters allowed to all other cs1|2 templates.  The limited subset is defined here.

Same conventions for true/false/dicouraged/nil as above.
	
]]

local limited_basic_arguments = {
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-given'] = true,
	['author-last'] = true,
	['author-surname'] = true,
	['author-link'] = true,
	['authorlink'] = 'discouraged',
	['author-mask'] = true,
	['authors'] = true,
	['collaboration'] = true,
	['date'] = true,
	['df'] = true,
	['display-authors'] = true,
	['first'] = true,
	['given'] = true,
	['language'] = true,
	['last'] = true,
	['mode'] = true,
	['name-list-style'] = true,
	['no-tracking'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['postscript'] = true,
	['pp'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['surname'] = true,
	['template-doc-demo'] = true,
	['title'] = true,
	['trans-title'] = true,
	['url'] = true,
	['URL'] = true,
	['vauthors'] = true,
	['year'] = true,
}

local limited_numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-given#'] = true,
	['author#-given'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-surname#'] = true,
	['author#-surname'] = true,
	['author-link#'] = true,
	['author#-link'] = true,
	['authorlink#'] = 'discouraged',
	['author#link'] = 'discouraged',
	['author-mask#'] = true,
	['author#-mask'] = true,
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['surname#'] = true,
	}


--[[--------------------------&lt; U N I Q U E _ A R G U M E N T S &gt;----------------------------------------------

Some templates have unique parameters.  Those templates and their unique parameters are listed here. Keys in this
table are the template's CitationClass parameter value

Same conventions for true/false/dicouraged/nil as above.

]]

local unique_arguments = {
	['audio-visual'] = {
		['transcript'] = true,
		['transcript-format'] = true,
		['transcripturl'] = false,
		['transcript-url'] = true,
		},
	episode = {
		['airdate'] = 'discouraged',
		['air-date'] = true,
		['credits'] = true,
		['episodelink'] = false,												-- alias of |title-link=
		['episode-link'] = true,												-- alias of |title-link=
		['network'] = true,
		['station'] = true,
		['transcript'] = true,
		['transcript-format'] = true,
		['transcripturl'] = false,
		['transcript-url'] = true,
		},
	mailinglist = {
		['mailinglist'] = false,
		['mailing-list'] = true,
		},
	map = {
		['inset'] = true,
		['map'] = true,
		['map-format'] = true,
		['mapurl'] = false,
		['map-url'] = true,
		['map-url-access'] = true,
		['script-map'] = true,
		['sections'] = true,
		['sheet'] = true,
		['sheets'] = true,
		['trans-map'] = true,
		},
	newsgroup = {
		['message-id'] = true,
		['newsgroup'] = true,
		},
	serial = {
		['airdate'] = 'discouraged',
		['air-date'] = true,
		['credits'] = true,
		['episode'] = true,														-- cite serial only TODO: make available to cite episode?
		['episodelink'] = false,
		['episode-link'] = true,												-- alias of |title-link=
		['network'] = true,
		['station'] = true,
		},
	}


--[[--------------------------&lt; T E M P L A T E _ L I S T _ G E T &gt;--------------------------------------------

gets a list of the templates from table t

]]

local function template_list_get (t)
	local out = {};																-- a table for output
	for k, _ in pairs (t) do													-- spin through the table and collect the keys
		table.insert (out, k)													-- add each key to the output table
	end
	return out;																	-- and done
end


--[[--------------------------&lt; E X P O R T E D   T A B L E S &gt;------------------------------------------------
]]

return {
	basic_arguments = basic_arguments,
	numbered_arguments = numbered_arguments,
	limited_basic_arguments = limited_basic_arguments,
	limited_numbered_arguments = limited_numbered_arguments,

	preprint_arguments = preprint_arguments,
	preprint_template_list = template_list_get (preprint_arguments),			-- make a template list from preprint_arguments{} table
	unique_arguments = unique_arguments,
	unique_param_template_list = template_list_get (unique_arguments),			-- make a template list from unique_arguments{} table
	};</text>
      <sha1>htr8gi1skn9htxtyddaxevqaxjp40e3</sha1>
    </revision>
    <revision>
      <id>4809</id>
      <parentid>4808</parentid>
      <timestamp>2021-05-25T15:05:10Z</timestamp>
      <contributor>
        <username>Amakuru</username>
        <id>820</id>
      </contributor>
      <comment>sync from sandbox</comment>
      <origin>4809</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="14572" sha1="pe5jn7upqetz8mgrs3o3rxvhuwbzk8k" xml:space="preserve">
--[[--------------------------&lt; S U P P O R T E D   P A R A M E T E R S &gt;--------------------------------------

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	nil - these parameters are no longer supported. remove entirely
	
]]

local basic_arguments = {
	['accessdate'] = true,
	['access-date'] = true,
	['agency'] = true,
	['archivedate'] = true,
	['archive-date'] = true,
	['archive-format'] = true,
	['archiveurl'] = true,
	['archive-url'] = true,
	['article'] = true,
	['article-format'] = true,
	['article-url'] = true,
	['article-url-access'] = true,
	['arxiv'] = true,															-- cite arxiv; here because allowed in cite ... as identifier
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-given'] = true,
	['author-last'] = true,
	['author-surname'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['bibcode'] = true,
	['bibcode-access'] = true,
	['biorxiv'] = true,															-- cite biorxiv; here because allowed in cite ... as identifier
	['chapter'] = true,
	['chapter-format'] = true,
	['chapter-url'] = true,
	['chapter-url-access'] = true,
	['citeseerx'] = true,														-- cite citeseerx; here because allowed in cite ... as identifier
	['collaboration'] = true,
	['contribution'] = true,
	['contribution-format'] = true,
	['contribution-url'] = true,
	['contribution-url-access'] = true,
	['contributor'] = true,
	['contributor-first'] = true,
	['contributor-given'] = true,
	['contributor-last'] = true,
	['contributor-surname'] = true,
	['contributor-link'] = true,
	['contributor-mask'] = true,
	['date'] = true,
	['department'] = true,
	['df'] = true,
	['dictionary'] = true,
	['display-authors'] = true,
	['display-contributors'] = true,
	['display-editors'] = true,
	['display-interviewers'] = true,
	['display-subjects'] = true,
	['display-translators'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-access'] = true,
	['doi-broken-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['editor-first'] = true,
	['editor-given'] = true,
	['editor-last'] = true,
	['editor-surname'] = true,
	['editor-link'] = true,
	['editor-mask'] = true,
	['eissn'] = true,
	['EISSN'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['entry'] = true,
	['entry-format'] = true,
	['entry-url'] = true,
	['entry-url-access'] = true,
	['eprint'] = true,															-- cite arxiv; here because allowed in cite ... as identifier
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['hdl'] = true,
	['HDL'] = true,
	['hdl-access'] = true,
	['host'] = true,															-- unique to certain templates?
	['id'] = true,
	['ID'] = true,
	['institution'] = true,														-- constrain to cite thesis?
	['interviewer'] = true,
	['interviewer-first'] = true,
	['interviewer-given'] = true,
	['interviewer-last'] = true,
	['interviewer-surname'] = true,
	['interviewer-link'] = true,
	['interviewer-mask'] = true,
	['isbn'] = true,
	['ISBN'] = true,
	['ismn'] = true,
	['ISMN'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['jstor-access'] = true,
	['lang'] = true,
	['language'] = true,
	['last'] = true,
	['lay-date'] = true,
	['lay-format'] = true,
	['lay-source'] = true,
	['lay-url'] = true,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['magazine'] = true,
	['medium'] = true,
	['minutes'] = true,															-- constrain to cite AV media and podcast?
	['mode'] = true,
	['mr'] = true,
	['MR'] = true,
	['name-list-style'] = true,
	['newspaper'] = true,
	['no-pp'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['ol-access'] = true,
	['orig-date'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['osti-access'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['people'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmc-embargo-date'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['publication-date'] = true,
	['publication-place'] = true,
	['publisher'] = true,
	['quotation'] = true,
	['quote'] = true,
	['quote-page'] = true,
	['quote-pages'] = true,
	['ref'] = true,
	['rfc'] = true,
	['RFC'] = true,
	['sbn'] = true,
	['SBN'] = true,
	['scale'] = true,
	['script-article'] = true,
	['script-chapter'] = true,
	['script-contribution'] = true,
	['script-entry'] = true,
	['script-journal'] = true,
	['script-magazine'] = true,
	['script-newspaper'] = true,
	['script-periodical'] = true,
	['script-quote'] = true,
	['script-section'] = true,
	['script-title'] = true,
	['script-website'] = true,
	['script-work'] = true,
	['section'] = true,
	['section-format'] = true,
	['section-url'] = true,
	['section-url-access'] = true,
	['series'] = true,
	['ssrn'] = true,															-- cite ssrn; these three here because allowed in cite ... as identifier
	['SSRN'] = true,
	['ssrn-access'] = true,
	['subject'] = true,
	['subject-link'] = true,
	['subject-mask'] = true,
	['surname'] = true,
	['s2cid'] = true,
	['S2CID'] = true,
	['s2cid-access'] = true,
	['template-doc-demo'] = true,
	['time'] = true,															-- constrain to cite av media and podcast?
	['time-caption'] = true,													-- constrain to cite av media and podcast?
	['title'] = true,
	['title-link'] = true,
	['translator'] = true,
	['translator-first'] = true,
	['translator-given'] = true,
	['translator-last'] = true,	
	['translator-surname'] = true,
	['translator-link'] = true,
	['translator-mask'] = true,
	['trans-article'] = true,
	['trans-chapter'] = true,
	['trans-contribution'] = true,
	['trans-entry'] = true,
	['trans-journal'] = true,
	['trans-magazine'] = true,
	['trans-newspaper'] = true,
	['trans-periodical'] = true,
	['trans-quote'] = true,
	['trans-section'] = true,
	['trans-title'] = true,
	['trans-website'] = true,
	['trans-work'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['url-access'] = true,
	['url-status'] = true,
	['vauthors'] = true,
	['veditors'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
}

local numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-given#'] = true,
	['author#-given'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-surname#'] = true,
	['author#-surname'] = true,
	['author-link#'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author#link'] = true,
	['author-mask#'] = true,
	['author#-mask'] = true,
	['contributor#'] = true,
	['contributor-first#'] = true,
	['contributor#-first'] = true,
	['contributor-given#'] = true,
	['contributor#-given'] = true,
	['contributor-last#'] = true,
	['contributor#-last'] = true,
	['contributor-surname#'] = true,
	['contributor#-surname'] = true,
	['contributor-link#'] = true,
	['contributor#-link'] = true,
	['contributor-mask#'] = true,
	['contributor#-mask'] = true,
	['editor#'] = true,
	['editor-first#'] = true,
	['editor#-first'] = true,
	['editor-given#'] = true,
	['editor#-given'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-surname#'] = true,
	['editor#-surname'] = true,
	['editor-link#'] = true,
	['editor#-link'] = true,
	['editor-mask#'] = true,
	['editor#-mask'] = true,
	['first#'] = true,
	['given#'] = true,
	['host#'] = true,
	['interviewer#'] = true,
	['interviewer-first#'] = true,
	['interviewer#-first'] = true,
	['interviewer-given#'] = true,
	['interviewer#-given'] = true,
	['interviewer-last#'] = true,
	['interviewer#-last'] = true,
	['interviewer-surname#'] = true,
	['interviewer#-surname'] = true,
	['interviewer-link#'] = true,
	['interviewer#-link'] = true,
	['interviewer-mask#'] = true,
	['interviewer#-mask'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-link#'] = true,
	['subject#-link'] = true,
	['subject-mask#'] = true,
	['subject#-mask'] = true,
	['surname#'] = true,
	['translator#'] = true,
	['translator-first#'] = true,
	['translator#-first'] = true,
	['translator-given#'] = true,
	['translator#-given'] = true,
	['translator-last#'] = true,
	['translator#-last'] = true,
	['translator-surname#'] = true,
	['translator#-surname'] = true,
	['translator-link#'] = true,
	['translator#-link'] = true,
	['translator-mask#'] = true,
	['translator#-mask'] = true,
}


--[[--------------------------&lt; P R E P R I N T   S U P P O R T E D   P A R A M E T E R S &gt;--------------------

Cite arXiv, cite biorxiv, cite citeseerx, and cite ssrn are preprint templates that use the limited set of parameters
defined in the limited_basic_arguments and limited_numbered_arguments tables.  Those lists are supplemented with a
template-specific list of parameters that are required by the particular template and may be exclusive to one of the
preprint templates.  Some of these parameters may also be available to the general cs1|2 templates.

Same conventions for true/false/dicouraged/nil as above.

]]

local preprint_arguments = {
	arxiv = {
		['arxiv'] = true,														-- cite arxiv and arxiv identifiers
		['class'] = true,
		['eprint'] = true,														-- cite arxiv and arxiv identifiers
		},
	biorxiv = {
		['biorxiv'] = true,
		},
	citeseerx = {
		['citeseerx'] = true,
		},
	ssrn = {
		['ssrn'] = true,
		['SSRN'] = true,
		['ssrn-access'] = true,
		},
	}


--[[--------------------------&lt; L I M I T E D   S U P P O R T E D   P A R A M E T E R S &gt;----------------------

cite arxiv, cite biorxiv, cite citeseerx, and cite ssrn templates are preprint templates so are allowed only a
limited subset of parameters allowed to all other cs1|2 templates.  The limited subset is defined here.

Same conventions for true/false/dicouraged/nil as above.
	
]]

local limited_basic_arguments = {
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-given'] = true,
	['author-last'] = true,
	['author-surname'] = true,
	['author-link'] = true,
	['authorlink'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['collaboration'] = true,
	['date'] = true,
	['df'] = true,
	['display-authors'] = true,
	['first'] = true,
	['given'] = true,
	['language'] = true,
	['last'] = true,
	['mode'] = true,
	['name-list-style'] = true,
	['no-tracking'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['postscript'] = true,
	['pp'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['surname'] = true,
	['template-doc-demo'] = true,
	['title'] = true,
	['trans-title'] = true,
	['vauthors'] = true,
	['year'] = true,
}

local limited_numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-given#'] = true,
	['author#-given'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-surname#'] = true,
	['author#-surname'] = true,
	['author-link#'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author#link'] = true,
	['author-mask#'] = true,
	['author#-mask'] = true,
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['surname#'] = true,
	}


--[[--------------------------&lt; U N I Q U E _ A R G U M E N T S &gt;----------------------------------------------

Some templates have unique parameters.  Those templates and their unique parameters are listed here. Keys in this
table are the template's CitationClass parameter value

Same conventions for true/false/dicouraged/nil as above.

]]

local unique_arguments = {
	['audio-visual'] = {
		['transcript'] = true,
		['transcript-format'] = true,
		['transcript-url'] = true,
		},
	conference = {
		['book-title'] = true,
		['conference'] = true,
		['conference-format'] = true,
		['conference-url'] = true,
		['event'] = true,
		},
	episode = {
		['airdate'] = true,
		['air-date'] = true,
		['credits'] = true,
		['episode-link'] = true,												-- alias of |title-link=
		['network'] = true,
		['season'] = true,
		['series-link'] = true,
		['series-no'] = true,
		['series-number'] = true,
		['station'] = true,
		['transcript'] = true,
		['transcript-format'] = true,
		['transcripturl'] = false,
		['transcript-url'] = true,
		},
	mailinglist = {
		['mailing-list'] = true,
		},
	map = {
		['cartography'] = true,
		['inset'] = true,
		['map'] = true,
		['map-format'] = true,
		['map-url'] = true,
		['map-url-access'] = true,
		['script-map'] = true,
		['sections'] = true,
		['sheet'] = true,
		['sheets'] = true,
		['trans-map'] = true,
		},
	newsgroup = {
		['message-id'] = true,
		['newsgroup'] = true,
		},
	report = {
		['docket'] = true,
		},
	serial = {
		['airdate'] = true,
		['air-date'] = true,
		['credits'] = true,
		['episode'] = true,														-- cite serial only TODO: make available to cite episode?
		['episode-link'] = true,												-- alias of |title-link=
		['network'] = true,
		['series-link'] = true,
		['station'] = true,
		},
	speech = {
		['conference'] = true,
		['conference-format'] = true,
		['conference-url'] = true,
		['event'] = true,
		},
	thesis = {
		['degree'] = true,
		['docket'] = true,
		},
	}


--[[--------------------------&lt; T E M P L A T E _ L I S T _ G E T &gt;--------------------------------------------

gets a list of the templates from table t

]]

local function template_list_get (t)
	local out = {};																-- a table for output
	for k, _ in pairs (t) do													-- spin through the table and collect the keys
		table.insert (out, k)													-- add each key to the output table
	end
	return out;																	-- and done
end


--[[--------------------------&lt; E X P O R T E D   T A B L E S &gt;------------------------------------------------
]]

return {
	basic_arguments = basic_arguments,
	numbered_arguments = numbered_arguments,
	limited_basic_arguments = limited_basic_arguments,
	limited_numbered_arguments = limited_numbered_arguments,

	preprint_arguments = preprint_arguments,
	preprint_template_list = template_list_get (preprint_arguments),			-- make a template list from preprint_arguments{} table
	unique_arguments = unique_arguments,
	unique_param_template_list = template_list_get (unique_arguments),			-- make a template list from unique_arguments{} table
	};</text>
      <sha1>pe5jn7upqetz8mgrs3o3rxvhuwbzk8k</sha1>
    </revision>
    <revision>
      <id>4810</id>
      <parentid>4809</parentid>
      <timestamp>2022-01-22T14:11:22Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>update per [[Wikipedia:Village_pump_(proposals)#rfc:_shall_we_update_cs1/2?|RfC]];</comment>
      <origin>4810</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="14676" sha1="c31769ha0b0k636k736zgv3no6leh8l" xml:space="preserve">--[[--------------------------&lt; S U P P O R T E D   P A R A M E T E R S &gt;--------------------------------------

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	tracked - these parameters are valid and supported parameters tracked in an eponymous properties category
	nil - these parameters are no longer supported. remove entirely
	
]]

local basic_arguments = {
	['accessdate'] = true,
	['access-date'] = true,
	['agency'] = true,
	['archivedate'] = true,
	['archive-date'] = true,
	['archive-format'] = true,
	['archiveurl'] = true,
	['archive-url'] = true,
	['article'] = true,
	['article-format'] = true,
	['article-url'] = true,
	['article-url-access'] = true,
	['arxiv'] = true,															-- cite arxiv; here because allowed in cite ... as identifier
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-given'] = true,
	['author-last'] = true,
	['author-surname'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['bibcode'] = true,
	['bibcode-access'] = true,
	['biorxiv'] = true,															-- cite biorxiv; here because allowed in cite ... as identifier
	['chapter'] = true,
	['chapter-format'] = true,
	['chapter-url'] = true,
	['chapter-url-access'] = true,
	['citeseerx'] = true,														-- cite citeseerx; here because allowed in cite ... as identifier
	['collaboration'] = true,
	['contribution'] = true,
	['contribution-format'] = true,
	['contribution-url'] = true,
	['contribution-url-access'] = true,
	['contributor'] = true,
	['contributor-first'] = true,
	['contributor-given'] = true,
	['contributor-last'] = true,
	['contributor-surname'] = true,
	['contributor-link'] = true,
	['contributor-mask'] = true,
	['date'] = true,
	['department'] = true,
	['df'] = true,
	['dictionary'] = true,
	['display-authors'] = true,
	['display-contributors'] = true,
	['display-editors'] = true,
	['display-interviewers'] = true,
	['display-subjects'] = true,
	['display-translators'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-access'] = true,
	['doi-broken-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['editor-first'] = true,
	['editor-given'] = true,
	['editor-last'] = true,
	['editor-surname'] = true,
	['editor-link'] = true,
	['editor-mask'] = true,
	['eissn'] = true,
	['EISSN'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['entry'] = true,
	['entry-format'] = true,
	['entry-url'] = true,
	['entry-url-access'] = true,
	['eprint'] = true,															-- cite arxiv; here because allowed in cite ... as identifier
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['hdl'] = true,
	['HDL'] = true,
	['hdl-access'] = true,
	['host'] = true,															-- unique to certain templates?
	['id'] = true,
	['ID'] = true,
	['institution'] = true,														-- constrain to cite thesis?
	['interviewer'] = true,
	['interviewer-first'] = true,
	['interviewer-given'] = true,
	['interviewer-last'] = true,
	['interviewer-surname'] = true,
	['interviewer-link'] = true,
	['interviewer-mask'] = true,
	['isbn'] = true,
	['ISBN'] = true,
	['ismn'] = true,
	['ISMN'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['jstor-access'] = true,
	['lang'] = true,
	['language'] = true,
	['last'] = true,
	['lay-date'] = false,
	['lay-format'] = false,
	['lay-source'] = false,
	['lay-url'] = false,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['magazine'] = true,
	['medium'] = true,
	['minutes'] = true,															-- constrain to cite AV media and podcast?
	['mode'] = true,
	['mr'] = true,
	['MR'] = true,
	['name-list-style'] = true,
	['newspaper'] = true,
	['no-pp'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['ol-access'] = true,
	['orig-date'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['osti-access'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['people'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmc-embargo-date'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['publication-date'] = true,
	['publication-place'] = true,
	['publisher'] = true,
	['quotation'] = true,
	['quote'] = true,
	['quote-page'] = true,
	['quote-pages'] = true,
	['ref'] = true,
	['rfc'] = true,
	['RFC'] = true,
	['sbn'] = true,
	['SBN'] = true,
	['scale'] = true,
	['script-article'] = true,
	['script-chapter'] = true,
	['script-contribution'] = true,
	['script-entry'] = true,
	['script-journal'] = true,
	['script-magazine'] = true,
	['script-newspaper'] = true,
	['script-periodical'] = true,
	['script-quote'] = true,
	['script-section'] = true,
	['script-title'] = true,
	['script-website'] = true,
	['script-work'] = true,
	['section'] = true,
	['section-format'] = true,
	['section-url'] = true,
	['section-url-access'] = true,
	['series'] = true,
	['ssrn'] = true,															-- cite ssrn; these three here because allowed in cite ... as identifier
	['SSRN'] = true,
	['ssrn-access'] = true,
	['subject'] = true,
	['subject-link'] = true,
	['subject-mask'] = true,
	['surname'] = true,
	['s2cid'] = true,
	['S2CID'] = true,
	['s2cid-access'] = true,
	['template-doc-demo'] = true,
	['time'] = true,															-- constrain to cite av media and podcast?
	['time-caption'] = true,													-- constrain to cite av media and podcast?
	['title'] = true,
	['title-link'] = true,
	['translator'] = true,
	['translator-first'] = true,
	['translator-given'] = true,
	['translator-last'] = true,	
	['translator-surname'] = true,
	['translator-link'] = true,
	['translator-mask'] = true,
	['trans-article'] = true,
	['trans-chapter'] = true,
	['trans-contribution'] = true,
	['trans-entry'] = true,
	['trans-journal'] = true,
	['trans-magazine'] = true,
	['trans-newspaper'] = true,
	['trans-periodical'] = true,
	['trans-quote'] = true,
	['trans-section'] = true,
	['trans-title'] = true,
	['trans-website'] = true,
	['trans-work'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['url-access'] = true,
	['url-status'] = true,
	['vauthors'] = true,
	['veditors'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
	}

local numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-given#'] = true,
	['author#-given'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-surname#'] = true,
	['author#-surname'] = true,
	['author-link#'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author#link'] = true,
	['author-mask#'] = true,
	['author#-mask'] = true,
	['contributor#'] = true,
	['contributor-first#'] = true,
	['contributor#-first'] = true,
	['contributor-given#'] = true,
	['contributor#-given'] = true,
	['contributor-last#'] = true,
	['contributor#-last'] = true,
	['contributor-surname#'] = true,
	['contributor#-surname'] = true,
	['contributor-link#'] = true,
	['contributor#-link'] = true,
	['contributor-mask#'] = true,
	['contributor#-mask'] = true,
	['editor#'] = true,
	['editor-first#'] = true,
	['editor#-first'] = true,
	['editor-given#'] = true,
	['editor#-given'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-surname#'] = true,
	['editor#-surname'] = true,
	['editor-link#'] = true,
	['editor#-link'] = true,
	['editor-mask#'] = true,
	['editor#-mask'] = true,
	['first#'] = true,
	['given#'] = true,
	['host#'] = true,
	['interviewer#'] = true,
	['interviewer-first#'] = true,
	['interviewer#-first'] = true,
	['interviewer-given#'] = true,
	['interviewer#-given'] = true,
	['interviewer-last#'] = true,
	['interviewer#-last'] = true,
	['interviewer-surname#'] = true,
	['interviewer#-surname'] = true,
	['interviewer-link#'] = true,
	['interviewer#-link'] = true,
	['interviewer-mask#'] = true,
	['interviewer#-mask'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-link#'] = true,
	['subject#-link'] = true,
	['subject-mask#'] = true,
	['subject#-mask'] = true,
	['surname#'] = true,
	['translator#'] = true,
	['translator-first#'] = true,
	['translator#-first'] = true,
	['translator-given#'] = true,
	['translator#-given'] = true,
	['translator-last#'] = true,
	['translator#-last'] = true,
	['translator-surname#'] = true,
	['translator#-surname'] = true,
	['translator-link#'] = true,
	['translator#-link'] = true,
	['translator-mask#'] = true,
	['translator#-mask'] = true,
	}


--[[--------------------------&lt; P R E P R I N T   S U P P O R T E D   P A R A M E T E R S &gt;--------------------

Cite arXiv, cite biorxiv, cite citeseerx, and cite ssrn are preprint templates that use the limited set of parameters
defined in the limited_basic_arguments and limited_numbered_arguments tables.  Those lists are supplemented with a
template-specific list of parameters that are required by the particular template and may be exclusive to one of the
preprint templates.  Some of these parameters may also be available to the general cs1|2 templates.

Same conventions for true/false/tracked/nil as above.

]]

local preprint_arguments = {
	arxiv = {
		['arxiv'] = true,														-- cite arxiv and arxiv identifiers
		['class'] = true,
		['eprint'] = true,														-- cite arxiv and arxiv identifiers
		},
	biorxiv = {
		['biorxiv'] = true,
		},
	citeseerx = {
		['citeseerx'] = true,
		},
	ssrn = {
		['ssrn'] = true,
		['SSRN'] = true,
		['ssrn-access'] = true,
		},
	}


--[[--------------------------&lt; L I M I T E D   S U P P O R T E D   P A R A M E T E R S &gt;----------------------

cite arxiv, cite biorxiv, cite citeseerx, and cite ssrn templates are preprint templates so are allowed only a
limited subset of parameters allowed to all other cs1|2 templates.  The limited subset is defined here.

Same conventions for true/false/tracked/nil as above.
	
]]

local limited_basic_arguments = {
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-given'] = true,
	['author-last'] = true,
	['author-surname'] = true,
	['author-link'] = true,
	['authorlink'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['collaboration'] = true,
	['date'] = true,
	['df'] = true,
	['display-authors'] = true,
	['first'] = true,
	['given'] = true,
	['language'] = true,
	['last'] = true,
	['mode'] = true,
	['name-list-style'] = true,
	['no-tracking'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['postscript'] = true,
	['pp'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['surname'] = true,
	['template-doc-demo'] = true,
	['title'] = true,
	['trans-title'] = true,
	['vauthors'] = true,
	['year'] = true,
	}

local limited_numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-given#'] = true,
	['author#-given'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-surname#'] = true,
	['author#-surname'] = true,
	['author-link#'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author#link'] = true,
	['author-mask#'] = true,
	['author#-mask'] = true,
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['surname#'] = true,
	}


--[[--------------------------&lt; U N I Q U E _ A R G U M E N T S &gt;----------------------------------------------

Some templates have unique parameters.  Those templates and their unique parameters are listed here. Keys in this
table are the template's CitationClass parameter value

Same conventions for true/false/tracked/nil as above.

]]

local unique_arguments = {
	['audio-visual'] = {
		['transcript'] = true,
		['transcript-format'] = true,
		['transcript-url'] = true,
		},
	conference = {
		['book-title'] = true,
		['conference'] = true,
		['conference-format'] = true,
		['conference-url'] = true,
		['event'] = true,
		},
	episode = {
		['airdate'] = true,
		['air-date'] = true,
		['credits'] = true,
		['episode-link'] = true,												-- alias of |title-link=
		['network'] = true,
		['season'] = true,
		['series-link'] = true,
		['series-no'] = true,
		['series-number'] = true,
		['station'] = true,
		['transcript'] = true,
		['transcript-format'] = true,
		['transcripturl'] = false,
		['transcript-url'] = true,
		},
	mailinglist = {
		['mailing-list'] = true,
		},
	map = {
		['cartography'] = true,
		['inset'] = true,
		['map'] = true,
		['map-format'] = true,
		['map-url'] = true,
		['map-url-access'] = true,
		['script-map'] = true,
		['sections'] = true,
		['sheet'] = true,
		['sheets'] = true,
		['trans-map'] = true,
		},
	newsgroup = {
		['message-id'] = true,
		['newsgroup'] = true,
		},
	report = {
		['docket'] = true,
		},
	serial = {
		['airdate'] = true,
		['air-date'] = true,
		['credits'] = true,
		['episode'] = true,														-- cite serial only TODO: make available to cite episode?
		['episode-link'] = true,												-- alias of |title-link=
		['network'] = true,
		['series-link'] = true,
		['station'] = true,
		},
	speech = {
		['conference'] = true,
		['conference-format'] = true,
		['conference-url'] = true,
		['event'] = true,
		},
	thesis = {
		['degree'] = true,
		['docket'] = true,
		},
	}


--[[--------------------------&lt; T E M P L A T E _ L I S T _ G E T &gt;--------------------------------------------

gets a list of the templates from table t

]]

local function template_list_get (t)
	local out = {};																-- a table for output
	for k, _ in pairs (t) do													-- spin through the table and collect the keys
		table.insert (out, k)													-- add each key to the output table
	end
	return out;																	-- and done
end


--[[--------------------------&lt; E X P O R T E D   T A B L E S &gt;------------------------------------------------
]]

return {
	basic_arguments = basic_arguments,
	numbered_arguments = numbered_arguments,
	limited_basic_arguments = limited_basic_arguments,
	limited_numbered_arguments = limited_numbered_arguments,

	preprint_arguments = preprint_arguments,
	preprint_template_list = template_list_get (preprint_arguments),			-- make a template list from preprint_arguments{} table
	unique_arguments = unique_arguments,
	unique_param_template_list = template_list_get (unique_arguments),			-- make a template list from unique_arguments{} table
	};</text>
      <sha1>c31769ha0b0k636k736zgv3no6leh8l</sha1>
    </revision>
    <revision>
      <id>4811</id>
      <parentid>4810</parentid>
      <timestamp>2023-01-14T14:43:42Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4811</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="14798" sha1="ejafum0fj56ec1jr28vf2x10nm4d2x0" xml:space="preserve">--[[--------------------------&lt; S U P P O R T E D   P A R A M E T E R S &gt;--------------------------------------

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	tracked - these parameters are valid and supported parameters tracked in an eponymous properties category
	nil - these parameters are no longer supported. remove entirely
	
]]

local basic_arguments = {
	['accessdate'] = true,
	['access-date'] = true,
	['agency'] = true,
	['archivedate'] = true,
	['archive-date'] = true,
	['archive-format'] = true,
	['archiveurl'] = true,
	['archive-url'] = true,
	['article'] = true,
	['article-format'] = true,
	['article-number'] = true,													-- {{cite journal}}, {{cite conference}}; {{citation}} when |journal= has a value
	['article-url'] = true,
	['article-url-access'] = true,
	['arxiv'] = true,															-- cite arxiv; here because allowed in cite ... as identifier
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-given'] = true,
	['author-last'] = true,
	['author-surname'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['bibcode'] = true,
	['bibcode-access'] = true,
	['biorxiv'] = true,															-- cite biorxiv; here because allowed in cite ... as identifier
	['chapter'] = true,
	['chapter-format'] = true,
	['chapter-url'] = true,
	['chapter-url-access'] = true,
	['citeseerx'] = true,														-- cite citeseerx; here because allowed in cite ... as identifier
	['collaboration'] = true,
	['contribution'] = true,
	['contribution-format'] = true,
	['contribution-url'] = true,
	['contribution-url-access'] = true,
	['contributor'] = true,
	['contributor-first'] = true,
	['contributor-given'] = true,
	['contributor-last'] = true,
	['contributor-surname'] = true,
	['contributor-link'] = true,
	['contributor-mask'] = true,
	['date'] = true,
	['department'] = true,
	['df'] = true,
	['dictionary'] = true,
	['display-authors'] = true,
	['display-contributors'] = true,
	['display-editors'] = true,
	['display-interviewers'] = true,
	['display-subjects'] = true,
	['display-translators'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-access'] = true,
	['doi-broken-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['editor-first'] = true,
	['editor-given'] = true,
	['editor-last'] = true,
	['editor-surname'] = true,
	['editor-link'] = true,
	['editor-mask'] = true,
	['eissn'] = true,
	['EISSN'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['entry'] = true,
	['entry-format'] = true,
	['entry-url'] = true,
	['entry-url-access'] = true,
	['eprint'] = true,															-- cite arxiv; here because allowed in cite ... as identifier
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['hdl'] = true,
	['HDL'] = true,
	['hdl-access'] = true,
	['host'] = true,															-- unique to certain templates?
	['id'] = true,
	['ID'] = true,
	['institution'] = true,														-- constrain to cite thesis?
	['interviewer'] = true,
	['interviewer-first'] = true,
	['interviewer-given'] = true,
	['interviewer-last'] = true,
	['interviewer-surname'] = true,
	['interviewer-link'] = true,
	['interviewer-mask'] = true,
	['isbn'] = true,
	['ISBN'] = true,
	['ismn'] = true,
	['ISMN'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['jstor-access'] = true,
	['lang'] = true,
	['language'] = true,
	['last'] = true,
	['lay-date'] = false,
	['lay-format'] = false,
	['lay-source'] = false,
	['lay-url'] = false,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['magazine'] = true,
	['medium'] = true,
	['minutes'] = true,															-- constrain to cite AV media and podcast?
	['mode'] = true,
	['mr'] = true,
	['MR'] = true,
	['name-list-style'] = true,
	['newspaper'] = true,
	['no-pp'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['ol-access'] = true,
	['orig-date'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['osti-access'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['people'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmc-embargo-date'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['publication-date'] = true,
	['publication-place'] = true,
	['publisher'] = true,
	['quotation'] = true,
	['quote'] = true,
	['quote-page'] = true,
	['quote-pages'] = true,
	['ref'] = true,
	['rfc'] = true,
	['RFC'] = true,
	['sbn'] = true,
	['SBN'] = true,
	['scale'] = true,
	['script-article'] = true,
	['script-chapter'] = true,
	['script-contribution'] = true,
	['script-entry'] = true,
	['script-journal'] = true,
	['script-magazine'] = true,
	['script-newspaper'] = true,
	['script-periodical'] = true,
	['script-quote'] = true,
	['script-section'] = true,
	['script-title'] = true,
	['script-website'] = true,
	['script-work'] = true,
	['section'] = true,
	['section-format'] = true,
	['section-url'] = true,
	['section-url-access'] = true,
	['series'] = true,
	['ssrn'] = true,															-- cite ssrn; these three here because allowed in cite ... as identifier
	['SSRN'] = true,
	['ssrn-access'] = true,
	['subject'] = true,
	['subject-link'] = true,
	['subject-mask'] = true,
	['surname'] = true,
	['s2cid'] = true,
	['S2CID'] = true,
	['s2cid-access'] = true,
	['template-doc-demo'] = true,
	['time'] = true,															-- constrain to cite av media and podcast?
	['time-caption'] = true,													-- constrain to cite av media and podcast?
	['title'] = true,
	['title-link'] = true,
	['translator'] = true,
	['translator-first'] = true,
	['translator-given'] = true,
	['translator-last'] = true,	
	['translator-surname'] = true,
	['translator-link'] = true,
	['translator-mask'] = true,
	['trans-article'] = true,
	['trans-chapter'] = true,
	['trans-contribution'] = true,
	['trans-entry'] = true,
	['trans-journal'] = true,
	['trans-magazine'] = true,
	['trans-newspaper'] = true,
	['trans-periodical'] = true,
	['trans-quote'] = true,
	['trans-section'] = true,
	['trans-title'] = true,
	['trans-website'] = true,
	['trans-work'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['url-access'] = true,
	['url-status'] = true,
	['vauthors'] = true,
	['veditors'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
	}

local numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-given#'] = true,
	['author#-given'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-surname#'] = true,
	['author#-surname'] = true,
	['author-link#'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author#link'] = true,
	['author-mask#'] = true,
	['author#-mask'] = true,
	['contributor#'] = true,
	['contributor-first#'] = true,
	['contributor#-first'] = true,
	['contributor-given#'] = true,
	['contributor#-given'] = true,
	['contributor-last#'] = true,
	['contributor#-last'] = true,
	['contributor-surname#'] = true,
	['contributor#-surname'] = true,
	['contributor-link#'] = true,
	['contributor#-link'] = true,
	['contributor-mask#'] = true,
	['contributor#-mask'] = true,
	['editor#'] = true,
	['editor-first#'] = true,
	['editor#-first'] = true,
	['editor-given#'] = true,
	['editor#-given'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-surname#'] = true,
	['editor#-surname'] = true,
	['editor-link#'] = true,
	['editor#-link'] = true,
	['editor-mask#'] = true,
	['editor#-mask'] = true,
	['first#'] = true,
	['given#'] = true,
	['host#'] = true,
	['interviewer#'] = true,
	['interviewer-first#'] = true,
	['interviewer#-first'] = true,
	['interviewer-given#'] = true,
	['interviewer#-given'] = true,
	['interviewer-last#'] = true,
	['interviewer#-last'] = true,
	['interviewer-surname#'] = true,
	['interviewer#-surname'] = true,
	['interviewer-link#'] = true,
	['interviewer#-link'] = true,
	['interviewer-mask#'] = true,
	['interviewer#-mask'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-link#'] = true,
	['subject#-link'] = true,
	['subject-mask#'] = true,
	['subject#-mask'] = true,
	['surname#'] = true,
	['translator#'] = true,
	['translator-first#'] = true,
	['translator#-first'] = true,
	['translator-given#'] = true,
	['translator#-given'] = true,
	['translator-last#'] = true,
	['translator#-last'] = true,
	['translator-surname#'] = true,
	['translator#-surname'] = true,
	['translator-link#'] = true,
	['translator#-link'] = true,
	['translator-mask#'] = true,
	['translator#-mask'] = true,
	}


--[[--------------------------&lt; P R E P R I N T   S U P P O R T E D   P A R A M E T E R S &gt;--------------------

Cite arXiv, cite biorxiv, cite citeseerx, and cite ssrn are preprint templates that use the limited set of parameters
defined in the limited_basic_arguments and limited_numbered_arguments tables.  Those lists are supplemented with a
template-specific list of parameters that are required by the particular template and may be exclusive to one of the
preprint templates.  Some of these parameters may also be available to the general cs1|2 templates.

Same conventions for true/false/tracked/nil as above.

]]

local preprint_arguments = {
	arxiv = {
		['arxiv'] = true,														-- cite arxiv and arxiv identifiers
		['class'] = true,
		['eprint'] = true,														-- cite arxiv and arxiv identifiers
		},
	biorxiv = {
		['biorxiv'] = true,
		},
	citeseerx = {
		['citeseerx'] = true,
		},
	ssrn = {
		['ssrn'] = true,
		['SSRN'] = true,
		['ssrn-access'] = true,
		},
	}


--[[--------------------------&lt; L I M I T E D   S U P P O R T E D   P A R A M E T E R S &gt;----------------------

cite arxiv, cite biorxiv, cite citeseerx, and cite ssrn templates are preprint templates so are allowed only a
limited subset of parameters allowed to all other cs1|2 templates.  The limited subset is defined here.

Same conventions for true/false/tracked/nil as above.
	
]]

local limited_basic_arguments = {
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-given'] = true,
	['author-last'] = true,
	['author-surname'] = true,
	['author-link'] = true,
	['authorlink'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['collaboration'] = true,
	['date'] = true,
	['df'] = true,
	['display-authors'] = true,
	['first'] = true,
	['given'] = true,
	['language'] = true,
	['last'] = true,
	['mode'] = true,
	['name-list-style'] = true,
	['no-tracking'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['postscript'] = true,
	['pp'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['surname'] = true,
	['template-doc-demo'] = true,
	['title'] = true,
	['trans-title'] = true,
	['vauthors'] = true,
	['year'] = true,
	}

local limited_numbered_arguments = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-given#'] = true,
	['author#-given'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-surname#'] = true,
	['author#-surname'] = true,
	['author-link#'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author#link'] = true,
	['author-mask#'] = true,
	['author#-mask'] = true,
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['surname#'] = true,
	}


--[[--------------------------&lt; U N I Q U E _ A R G U M E N T S &gt;----------------------------------------------

Some templates have unique parameters.  Those templates and their unique parameters are listed here. Keys in this
table are the template's CitationClass parameter value

Same conventions for true/false/tracked/nil as above.

]]

local unique_arguments = {
	['audio-visual'] = {
		['transcript'] = true,
		['transcript-format'] = true,
		['transcript-url'] = true,
		},
	conference = {
		['book-title'] = true,
		['conference'] = true,
		['conference-format'] = true,
		['conference-url'] = true,
		['event'] = true,
		},
	episode = {
		['airdate'] = true,
		['air-date'] = true,
		['credits'] = true,
		['episode-link'] = true,												-- alias of |title-link=
		['network'] = true,
		['season'] = true,
		['series-link'] = true,
		['series-no'] = true,
		['series-number'] = true,
		['station'] = true,
		['transcript'] = true,
		['transcript-format'] = true,
		['transcripturl'] = false,
		['transcript-url'] = true,
		},
	mailinglist = {
		['mailing-list'] = true,
		},
	map = {
		['cartography'] = true,
		['inset'] = true,
		['map'] = true,
		['map-format'] = true,
		['map-url'] = true,
		['map-url-access'] = true,
		['script-map'] = true,
		['sections'] = true,
		['sheet'] = true,
		['sheets'] = true,
		['trans-map'] = true,
		},
	newsgroup = {
		['message-id'] = true,
		['newsgroup'] = true,
		},
	report = {
		['docket'] = true,
		},
	serial = {
		['airdate'] = true,
		['air-date'] = true,
		['credits'] = true,
		['episode'] = true,														-- cite serial only TODO: make available to cite episode?
		['episode-link'] = true,												-- alias of |title-link=
		['network'] = true,
		['series-link'] = true,
		['station'] = true,
		},
	speech = {
		['conference'] = true,
		['conference-format'] = true,
		['conference-url'] = true,
		['event'] = true,
		},
	thesis = {
		['degree'] = true,
		['docket'] = true,
		},
	}


--[[--------------------------&lt; T E M P L A T E _ L I S T _ G E T &gt;--------------------------------------------

gets a list of the templates from table t

]]

local function template_list_get (t)
	local out = {};																-- a table for output
	for k, _ in pairs (t) do													-- spin through the table and collect the keys
		table.insert (out, k)													-- add each key to the output table
	end
	return out;																	-- and done
end


--[[--------------------------&lt; E X P O R T E D   T A B L E S &gt;------------------------------------------------
]]

return {
	basic_arguments = basic_arguments,
	numbered_arguments = numbered_arguments,
	limited_basic_arguments = limited_basic_arguments,
	limited_numbered_arguments = limited_numbered_arguments,

	preprint_arguments = preprint_arguments,
	preprint_template_list = template_list_get (preprint_arguments),			-- make a template list from preprint_arguments{} table
	unique_arguments = unique_arguments,
	unique_param_template_list = template_list_get (unique_arguments),			-- make a template list from unique_arguments{} table
	};</text>
      <sha1>ejafum0fj56ec1jr28vf2x10nm4d2x0</sha1>
    </revision>
    <revision>
      <id>4812</id>
      <parentid>4811</parentid>
      <timestamp>2023-08-12T19:19:08Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4812</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="17842" sha1="m3n7fjiqb4k238j0awyuub7fgy4153b" xml:space="preserve">--[[--------------------------&lt; S U P P O R T E D   P A R A M E T E R S &gt;--------------------------------------

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	tracked - these parameters are valid and supported parameters tracked in an eponymous properties category
	nil - these parameters are no longer supported. remove entirely
	
]]

local basic_arguments_t = {
	['accessdate'] = true,
	['access-date'] = true,
	['agency'] = true,
	['archivedate'] = true,
	['archive-date'] = true,
	['archive-format'] = true,
	['archiveurl'] = true,
	['archive-url'] = true,
	['article'] = true,
	['article-format'] = true,
	['article-number'] = true,													-- {{cite journal}}, {{cite conference}}; {{citation}} when |journal= has a value
	['article-url'] = true,
	['article-url-access'] = true,
	['arxiv'] = true,															-- cite arxiv; here because allowed in cite ... as identifier
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-given'] = true,
	['author-last'] = true,
	['author-surname'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['bibcode'] = true,
	['bibcode-access'] = true,
	['biorxiv'] = true,															-- cite biorxiv; here because allowed in cite ... as identifier
	['chapter'] = true,
	['chapter-format'] = true,
	['chapter-url'] = true,
	['chapter-url-access'] = true,
	['citeseerx'] = true,														-- cite citeseerx; here because allowed in cite ... as identifier
	['collaboration'] = true,
	['contribution'] = true,
	['contribution-format'] = true,
	['contribution-url'] = true,
	['contribution-url-access'] = true,
	['contributor'] = true,
	['contributor-first'] = true,
	['contributor-given'] = true,
	['contributor-last'] = true,
	['contributor-surname'] = true,
	['contributor-link'] = true,
	['contributor-mask'] = true,
	['date'] = true,
	['department'] = true,
	['df'] = true,
	['dictionary'] = true,
	['display-authors'] = true,
	['display-contributors'] = true,
	['display-editors'] = true,
	['display-interviewers'] = true,
	['display-subjects'] = true,
	['display-translators'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-access'] = true,
	['doi-broken-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['editor-first'] = true,
	['editor-given'] = true,
	['editor-last'] = true,
	['editor-surname'] = true,
	['editor-link'] = true,
	['editor-mask'] = true,
	['eissn'] = true,
	['EISSN'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['entry'] = true,
	['entry-format'] = true,
	['entry-url'] = true,
	['entry-url-access'] = true,
	['eprint'] = true,															-- cite arxiv; here because allowed in cite ... as identifier
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['hdl'] = true,
	['HDL'] = true,
	['hdl-access'] = true,
	['host'] = true,															-- unique to certain templates?
	['id'] = true,
	['ID'] = true,
	['institution'] = true,														-- constrain to cite thesis?
	['interviewer'] = true,
	['interviewer-first'] = true,
	['interviewer-given'] = true,
	['interviewer-last'] = true,
	['interviewer-surname'] = true,
	['interviewer-link'] = true,
	['interviewer-mask'] = true,
	['isbn'] = true,
	['ISBN'] = true,
	['ismn'] = true,
	['ISMN'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['jstor-access'] = true,
	['lang'] = true,
	['language'] = true,
	['last'] = true,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['magazine'] = true,
	['medium'] = true,
	['medrxiv'] = true,															-- cite medrxiv; here because allowed in cite ... as identifier
	['minutes'] = true,															-- constrain to cite AV media and podcast?
	['mode'] = true,
	['mr'] = true,
	['MR'] = true,
	['name-list-style'] = true,
	['newspaper'] = true,
	['no-pp'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['ol-access'] = true,
	['orig-date'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['osti-access'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['people'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmc-embargo-date'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['publication-date'] = true,
	['publication-place'] = true,
	['publisher'] = true,
	['quotation'] = true,
	['quote'] = true,
	['quote-page'] = true,
	['quote-pages'] = true,
	['ref'] = true,
	['rfc'] = true,
	['RFC'] = true,
	['sbn'] = true,
	['SBN'] = true,
	['scale'] = true,
	['script-article'] = true,
	['script-chapter'] = true,
	['script-contribution'] = true,
	['script-entry'] = true,
	['script-journal'] = true,
	['script-magazine'] = true,
	['script-newspaper'] = true,
	['script-periodical'] = true,
	['script-quote'] = true,
	['script-section'] = true,
	['script-title'] = true,
	['script-website'] = true,
	['script-work'] = true,
	['section'] = true,
	['section-format'] = true,
	['section-url'] = true,
	['section-url-access'] = true,
	['series'] = true,
	['ssrn'] = true,															-- cite ssrn; these three here because allowed in cite ... as identifier
	['SSRN'] = true,
	['ssrn-access'] = true,
	['subject'] = true,
	['subject-first'] = true,
	['subject-given'] = true,
	['subject-last'] = true,
	['subject-link'] = true,
	['subject-mask'] = true,
	['subject-surname'] = true,
	['surname'] = true,
	['s2cid'] = true,
	['S2CID'] = true,
	['s2cid-access'] = true,
	['template-doc-demo'] = true,
	['time'] = true,															-- constrain to cite av media and podcast?
	['time-caption'] = true,													-- constrain to cite av media and podcast?
	['title'] = true,
	['title-link'] = true,
	['title-note'] = true,
	['translator'] = true,
	['translator-first'] = true,
	['translator-given'] = true,
	['translator-last'] = true,	
	['translator-surname'] = true,
	['translator-link'] = true,
	['translator-mask'] = true,
	['trans-article'] = true,
	['trans-chapter'] = true,
	['trans-contribution'] = true,
	['trans-entry'] = true,
	['trans-journal'] = true,
	['trans-magazine'] = true,
	['trans-newspaper'] = true,
	['trans-periodical'] = true,
	['trans-quote'] = true,
	['trans-section'] = true,
	['trans-title'] = true,
	['trans-website'] = true,
	['trans-work'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['url-access'] = true,
	['url-status'] = true,
	['vauthors'] = true,
	['veditors'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
	}

local numbered_arguments_t = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-given#'] = true,
	['author#-given'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-surname#'] = true,
	['author#-surname'] = true,
	['author-link#'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author#link'] = true,
	['author-mask#'] = true,
	['author#-mask'] = true,
	['contributor#'] = true,
	['contributor-first#'] = true,
	['contributor#-first'] = true,
	['contributor-given#'] = true,
	['contributor#-given'] = true,
	['contributor-last#'] = true,
	['contributor#-last'] = true,
	['contributor-surname#'] = true,
	['contributor#-surname'] = true,
	['contributor-link#'] = true,
	['contributor#-link'] = true,
	['contributor-mask#'] = true,
	['contributor#-mask'] = true,
	['editor#'] = true,
	['editor-first#'] = true,
	['editor#-first'] = true,
	['editor-given#'] = true,
	['editor#-given'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-surname#'] = true,
	['editor#-surname'] = true,
	['editor-link#'] = true,
	['editor#-link'] = true,
	['editor-mask#'] = true,
	['editor#-mask'] = true,
	['first#'] = true,
	['given#'] = true,
	['host#'] = true,
	['interviewer#'] = true,
	['interviewer-first#'] = true,
	['interviewer#-first'] = true,
	['interviewer-given#'] = true,
	['interviewer#-given'] = true,
	['interviewer-last#'] = true,
	['interviewer#-last'] = true,
	['interviewer-surname#'] = true,
	['interviewer#-surname'] = true,
	['interviewer-link#'] = true,
	['interviewer#-link'] = true,
	['interviewer-mask#'] = true,
	['interviewer#-mask'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-first#'] = true,
	['subject#-first'] = true,
	['subject-given#'] = true,
	['subject#-given'] = true,
	['subject-last#'] = true,
	['subject#-last'] = true,
	['subject-link#'] = true,
	['subject#-link'] = true,
	['subject-mask#'] = true,
	['subject#-mask'] = true,
	['subject-surname#'] = true,
	['subject#-surname'] = true,
	['surname#'] = true,
	['translator#'] = true,
	['translator-first#'] = true,
	['translator#-first'] = true,
	['translator-given#'] = true,
	['translator#-given'] = true,
	['translator-last#'] = true,
	['translator#-last'] = true,
	['translator-surname#'] = true,
	['translator#-surname'] = true,
	['translator-link#'] = true,
	['translator#-link'] = true,
	['translator-mask#'] = true,
	['translator#-mask'] = true,
	}


--[[--------------------------&lt; P R E P R I N T   S U P P O R T E D   P A R A M E T E R S &gt;--------------------

Cite arXiv, cite biorxiv, cite citeseerx, cite medrxiv, and cite ssrn are preprint templates that use the limited
set of parameters defined in the limited_basic_arguments and limited_numbered_arguments tables.  Those lists are
supplemented with a template-specific list of parameters that are required by the particular template and may be
exclusive to one of the preprint templates.  Some of these parameters may also be available to the general cs1|2
templates.

Same conventions for true/false/tracked/nil as above.

]]

local preprint_arguments_t = {
	arxiv = {
		['arxiv'] = true,														-- cite arxiv and arxiv identifiers
		['class'] = true,
		['eprint'] = true,														-- cite arxiv and arxiv identifiers
		},
	biorxiv = {
		['biorxiv'] = true,
		},
	citeseerx = {
		['citeseerx'] = true,
		},
	medrxiv = {
		['medrxiv'] = true,
		},
	ssrn = {
		['ssrn'] = true,
		['SSRN'] = true,
		['ssrn-access'] = true,
		},
	}


--[[--------------------------&lt; L I M I T E D   S U P P O R T E D   P A R A M E T E R S &gt;----------------------

cite arxiv, cite biorxiv, cite citeseerx, cite medrxiv, and cite ssrn templates are preprint templates so are
allowed only a limited subset of parameters allowed to all other cs1|2 templates.  The limited subset is defined
here.

This list of parameters also used by {{cite document}}

Same conventions for true/false/tracked/nil as above.
	
]]

local limited_basic_arguments_t = {
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-given'] = true,
	['author-last'] = true,
	['author-surname'] = true,
	['author-link'] = true,
	['authorlink'] = true,
	['author-mask'] = true,
	['authors'] = true,
	['collaboration'] = true,
	['date'] = true,
	['df'] = true,
	['display-authors'] = true,
	['first'] = true,
	['given'] = true,
	['language'] = true,
	['last'] = true,
	['mode'] = true,
	['name-list-style'] = true,
	['no-tracking'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['postscript'] = true,
	['pp'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['surname'] = true,
	['template-doc-demo'] = true,
	['title'] = true,
	['trans-title'] = true,
	['vauthors'] = true,
	['year'] = true,
	}

local limited_numbered_arguments_t = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-given#'] = true,
	['author#-given'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-surname#'] = true,
	['author#-surname'] = true,
	['author-link#'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author#link'] = true,
	['author-mask#'] = true,
	['author#-mask'] = true,
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['surname#'] = true,
	}


--[[--------------------------&lt; U N I Q U E _ A R G U M E N T S &gt;----------------------------------------------

Some templates have unique parameters.  Those templates and their unique parameters are listed here. Keys in this
table are the template's CitationClass parameter value

Same conventions for true/false/tracked/nil as above.

]]

local unique_arguments_t = {
	['audio-visual'] = {
		['transcript'] = true,
		['transcript-format'] = true,
		['transcript-url'] = true,
		},
	conference = {
		['book-title'] = true,
		['conference'] = true,
		['conference-format'] = true,
		['conference-url'] = true,
		['event'] = true,
		},
	episode = {
		['airdate'] = true,
		['air-date'] = true,
		['credits'] = true,
		['episode-link'] = true,												-- alias of |title-link=
		['network'] = true,
		['season'] = true,
		['series-link'] = true,
		['series-no'] = true,
		['series-number'] = true,
		['station'] = true,
		['transcript'] = true,
		['transcript-format'] = true,
		['transcript-url'] = true,
		},
	mailinglist = {
		['mailing-list'] = true,
		},
	map = {
		['cartography'] = true,
		['inset'] = true,
		['map'] = true,
		['map-format'] = true,
		['map-url'] = true,
		['map-url-access'] = true,
		['script-map'] = true,
		['sections'] = true,
		['sheet'] = true,
		['sheets'] = true,
		['trans-map'] = true,
		},
	newsgroup = {
		['message-id'] = true,
		['newsgroup'] = true,
		},
	report = {
		['docket'] = true,
		},
	serial = {
		['airdate'] = true,
		['air-date'] = true,
		['credits'] = true,
		['episode'] = true,														-- cite serial only TODO: make available to cite episode?
		['episode-link'] = true,												-- alias of |title-link=
		['network'] = true,
		['series-link'] = true,
		['station'] = true,
		},
	speech = {
		['conference'] = true,
		['conference-format'] = true,
		['conference-url'] = true,
		['event'] = true,
		},
	thesis = {
		['degree'] = true,
		['docket'] = true,
		},
	}


--[[--------------------------&lt; C I T E _ D O C U M E N T &gt;----------------------------------------------------

Special case for cite document.  This template takes the limited basic and limited enumerated parameters plus
others that are apply only to standalone published sources that cannot be cited any other way; no url, book,
periodical, etc parameters; limited support for name lists and named identifiers.

when validating parameters in {{cite document}} templates, the basic and 

]]

local document_arguments_t = {
	['bibcode'] = true,
	['bibcode-access'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-access'] = true,
	['doi-broken-date'] = true,
	['hdl'] = true,
	['HDL'] = true,
	['hdl-access'] = true,
	['id'] = true,
	['ID'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['lang'] = true,
	['location'] = true,
	['mr'] = true,
	['MR'] = true,
	['no-pp'] = true,
	['orig-date'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['osti-access'] = true,
	['place'] = true,
	['publisher'] = true,
	['quote-page'] = true,
	['quote-pages'] = true,
	['script-quote'] = true,
	['script-title'] = true,
	['title-link'] = true,
	['translator'] = true,
	['translator-first'] = true,
	['translator-given'] = true,
	['translator-last'] = true,
	['translator-surname'] = true,
	['translator-link'] = true,
	['translator-mask'] = true,
	['trans-quote'] = true,
	['type'] = true,
	['zbl'] = true,
	['ZBL'] = true,
	}

local document_numbered_arguments_t = {
	['translator#'] = true,
	['translator-first#'] = true,
	['translator#-first'] = true,
	['translator-given#'] = true,
	['translator#-given'] = true,
	['translator-last#'] = true,
	['translator#-last'] = true,
	['translator-surname#'] = true,
	['translator#-surname'] = true,
	['translator-link#'] = true,
	['translator#-link'] = true,
	['translator-mask#'] = true,
	['translator#-mask'] = true,
	}


--[[--------------------------&lt; L I S T _ C O M B I N E &gt;------------------------------------------------------

makes one table from a list of tables.  &lt;lists_t&gt; is a sequence of tables to be combined

]]

local function list_combine (lists_t)
	local out_t = {};

	for _, list_t in ipairs (lists_t) do										-- for each list in &lt;lists_t&gt;
		for k, v in pairs (list_t) do											-- extract each k/v pair
			out_t[k] = v;														-- add to &lt;out_t&gt;
		end
	end
	return out_t;																-- and done
end


--[[--------------------------&lt; T E M P L A T E _ L I S T _ G E T &gt;--------------------------------------------

gets a list of the templates from table t

]]

local function template_list_get (t)
	local out_t = {};															-- a table for output
	for k, _ in pairs (t) do													-- spin through the table and collect the keys
		table.insert (out_t, k)													-- add each key to the output table
	end
	return out_t;																-- and done
end


--[[--------------------------&lt; E X P O R T E D   T A B L E S &gt;------------------------------------------------
]]

return {
	preprint_arguments_t = preprint_arguments_t,
	preprint_template_list_t = template_list_get (preprint_arguments_t),		-- make a template list from preprint_arguments{} table
	unique_arguments_t = unique_arguments_t,
	unique_param_template_list_t = template_list_get (unique_arguments_t),		-- make a template list from unique_arguments{} table
	
	document_parameters_t = list_combine ({limited_basic_arguments_t, limited_numbered_arguments_t, document_arguments_t, document_numbered_arguments_t});
	common_parameters_t = list_combine ({basic_arguments_t, numbered_arguments_t});
	limited_parameters_t = list_combine ({limited_basic_arguments_t, limited_numbered_arguments_t});
	};</text>
      <sha1>m3n7fjiqb4k238j0awyuub7fgy4153b</sha1>
    </revision>
    <revision>
      <id>4813</id>
      <parentid>4812</parentid>
      <timestamp>2023-11-25T16:42:12Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4813</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="17844" sha1="r2xt23jaere01lhs2h9ysq5iacj8pzq" xml:space="preserve">--[[--------------------------&lt; S U P P O R T E D   P A R A M E T E R S &gt;--------------------------------------

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	tracked - these parameters are valid and supported parameters tracked in an eponymous properties category
	nil - these parameters are no longer supported. remove entirely
	
]]

local basic_arguments_t = {
	['accessdate'] = true,
	['access-date'] = true,
	['agency'] = true,
	['archivedate'] = true,
	['archive-date'] = true,
	['archive-format'] = true,
	['archiveurl'] = true,
	['archive-url'] = true,
	['article'] = true,
	['article-format'] = true,
	['article-number'] = true,													-- {{cite journal}}, {{cite conference}}; {{citation}} when |journal= has a value
	['article-url'] = true,
	['article-url-access'] = true,
	['arxiv'] = true,															-- cite arxiv; here because allowed in cite ... as identifier
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-given'] = true,
	['author-last'] = true,
	['author-surname'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['author-mask'] = true,
	['authors'] = false,
	['bibcode'] = true,
	['bibcode-access'] = true,
	['biorxiv'] = true,															-- cite biorxiv; here because allowed in cite ... as identifier
	['chapter'] = true,
	['chapter-format'] = true,
	['chapter-url'] = true,
	['chapter-url-access'] = true,
	['citeseerx'] = true,														-- cite citeseerx; here because allowed in cite ... as identifier
	['collaboration'] = true,
	['contribution'] = true,
	['contribution-format'] = true,
	['contribution-url'] = true,
	['contribution-url-access'] = true,
	['contributor'] = true,
	['contributor-first'] = true,
	['contributor-given'] = true,
	['contributor-last'] = true,
	['contributor-surname'] = true,
	['contributor-link'] = true,
	['contributor-mask'] = true,
	['date'] = true,
	['department'] = true,
	['df'] = true,
	['dictionary'] = true,
	['display-authors'] = true,
	['display-contributors'] = true,
	['display-editors'] = true,
	['display-interviewers'] = true,
	['display-subjects'] = true,
	['display-translators'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-access'] = true,
	['doi-broken-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['editor-first'] = true,
	['editor-given'] = true,
	['editor-last'] = true,
	['editor-surname'] = true,
	['editor-link'] = true,
	['editor-mask'] = true,
	['eissn'] = true,
	['EISSN'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['entry'] = true,
	['entry-format'] = true,
	['entry-url'] = true,
	['entry-url-access'] = true,
	['eprint'] = true,															-- cite arxiv; here because allowed in cite ... as identifier
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['hdl'] = true,
	['HDL'] = true,
	['hdl-access'] = true,
	['host'] = true,															-- unique to certain templates?
	['id'] = true,
	['ID'] = true,
	['institution'] = true,														-- constrain to cite thesis?
	['interviewer'] = true,
	['interviewer-first'] = true,
	['interviewer-given'] = true,
	['interviewer-last'] = true,
	['interviewer-surname'] = true,
	['interviewer-link'] = true,
	['interviewer-mask'] = true,
	['isbn'] = true,
	['ISBN'] = true,
	['ismn'] = true,
	['ISMN'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['jstor-access'] = true,
	['lang'] = true,
	['language'] = true,
	['last'] = true,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['magazine'] = true,
	['medium'] = true,
	['medrxiv'] = true,															-- cite medrxiv; here because allowed in cite ... as identifier
	['minutes'] = true,															-- constrain to cite AV media and podcast?
	['mode'] = true,
	['mr'] = true,
	['MR'] = true,
	['name-list-style'] = true,
	['newspaper'] = true,
	['no-pp'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['ol-access'] = true,
	['orig-date'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['osti-access'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['people'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmc-embargo-date'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['publication-date'] = true,
	['publication-place'] = true,
	['publisher'] = true,
	['quotation'] = true,
	['quote'] = true,
	['quote-page'] = true,
	['quote-pages'] = true,
	['ref'] = true,
	['rfc'] = true,
	['RFC'] = true,
	['sbn'] = true,
	['SBN'] = true,
	['scale'] = true,
	['script-article'] = true,
	['script-chapter'] = true,
	['script-contribution'] = true,
	['script-entry'] = true,
	['script-journal'] = true,
	['script-magazine'] = true,
	['script-newspaper'] = true,
	['script-periodical'] = true,
	['script-quote'] = true,
	['script-section'] = true,
	['script-title'] = true,
	['script-website'] = true,
	['script-work'] = true,
	['section'] = true,
	['section-format'] = true,
	['section-url'] = true,
	['section-url-access'] = true,
	['series'] = true,
	['ssrn'] = true,															-- cite ssrn; these three here because allowed in cite ... as identifier
	['SSRN'] = true,
	['ssrn-access'] = true,
	['subject'] = true,
	['subject-first'] = true,
	['subject-given'] = true,
	['subject-last'] = true,
	['subject-link'] = true,
	['subject-mask'] = true,
	['subject-surname'] = true,
	['surname'] = true,
	['s2cid'] = true,
	['S2CID'] = true,
	['s2cid-access'] = true,
	['template-doc-demo'] = true,
	['time'] = true,															-- constrain to cite av media and podcast?
	['time-caption'] = true,													-- constrain to cite av media and podcast?
	['title'] = true,
	['title-link'] = true,
	['title-note'] = true,
	['translator'] = true,
	['translator-first'] = true,
	['translator-given'] = true,
	['translator-last'] = true,	
	['translator-surname'] = true,
	['translator-link'] = true,
	['translator-mask'] = true,
	['trans-article'] = true,
	['trans-chapter'] = true,
	['trans-contribution'] = true,
	['trans-entry'] = true,
	['trans-journal'] = true,
	['trans-magazine'] = true,
	['trans-newspaper'] = true,
	['trans-periodical'] = true,
	['trans-quote'] = true,
	['trans-section'] = true,
	['trans-title'] = true,
	['trans-website'] = true,
	['trans-work'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['url-access'] = true,
	['url-status'] = true,
	['vauthors'] = true,
	['veditors'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
	}

local numbered_arguments_t = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-given#'] = true,
	['author#-given'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-surname#'] = true,
	['author#-surname'] = true,
	['author-link#'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author#link'] = true,
	['author-mask#'] = true,
	['author#-mask'] = true,
	['contributor#'] = true,
	['contributor-first#'] = true,
	['contributor#-first'] = true,
	['contributor-given#'] = true,
	['contributor#-given'] = true,
	['contributor-last#'] = true,
	['contributor#-last'] = true,
	['contributor-surname#'] = true,
	['contributor#-surname'] = true,
	['contributor-link#'] = true,
	['contributor#-link'] = true,
	['contributor-mask#'] = true,
	['contributor#-mask'] = true,
	['editor#'] = true,
	['editor-first#'] = true,
	['editor#-first'] = true,
	['editor-given#'] = true,
	['editor#-given'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-surname#'] = true,
	['editor#-surname'] = true,
	['editor-link#'] = true,
	['editor#-link'] = true,
	['editor-mask#'] = true,
	['editor#-mask'] = true,
	['first#'] = true,
	['given#'] = true,
	['host#'] = true,
	['interviewer#'] = true,
	['interviewer-first#'] = true,
	['interviewer#-first'] = true,
	['interviewer-given#'] = true,
	['interviewer#-given'] = true,
	['interviewer-last#'] = true,
	['interviewer#-last'] = true,
	['interviewer-surname#'] = true,
	['interviewer#-surname'] = true,
	['interviewer-link#'] = true,
	['interviewer#-link'] = true,
	['interviewer-mask#'] = true,
	['interviewer#-mask'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-first#'] = true,
	['subject#-first'] = true,
	['subject-given#'] = true,
	['subject#-given'] = true,
	['subject-last#'] = true,
	['subject#-last'] = true,
	['subject-link#'] = true,
	['subject#-link'] = true,
	['subject-mask#'] = true,
	['subject#-mask'] = true,
	['subject-surname#'] = true,
	['subject#-surname'] = true,
	['surname#'] = true,
	['translator#'] = true,
	['translator-first#'] = true,
	['translator#-first'] = true,
	['translator-given#'] = true,
	['translator#-given'] = true,
	['translator-last#'] = true,
	['translator#-last'] = true,
	['translator-surname#'] = true,
	['translator#-surname'] = true,
	['translator-link#'] = true,
	['translator#-link'] = true,
	['translator-mask#'] = true,
	['translator#-mask'] = true,
	}


--[[--------------------------&lt; P R E P R I N T   S U P P O R T E D   P A R A M E T E R S &gt;--------------------

Cite arXiv, cite biorxiv, cite citeseerx, cite medrxiv, and cite ssrn are preprint templates that use the limited
set of parameters defined in the limited_basic_arguments and limited_numbered_arguments tables.  Those lists are
supplemented with a template-specific list of parameters that are required by the particular template and may be
exclusive to one of the preprint templates.  Some of these parameters may also be available to the general cs1|2
templates.

Same conventions for true/false/tracked/nil as above.

]]

local preprint_arguments_t = {
	arxiv = {
		['arxiv'] = true,														-- cite arxiv and arxiv identifiers
		['class'] = true,
		['eprint'] = true,														-- cite arxiv and arxiv identifiers
		},
	biorxiv = {
		['biorxiv'] = true,
		},
	citeseerx = {
		['citeseerx'] = true,
		},
	medrxiv = {
		['medrxiv'] = true,
		},
	ssrn = {
		['ssrn'] = true,
		['SSRN'] = true,
		['ssrn-access'] = true,
		},
	}


--[[--------------------------&lt; L I M I T E D   S U P P O R T E D   P A R A M E T E R S &gt;----------------------

cite arxiv, cite biorxiv, cite citeseerx, cite medrxiv, and cite ssrn templates are preprint templates so are
allowed only a limited subset of parameters allowed to all other cs1|2 templates.  The limited subset is defined
here.

This list of parameters also used by {{cite document}}

Same conventions for true/false/tracked/nil as above.
	
]]

local limited_basic_arguments_t = {
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-given'] = true,
	['author-last'] = true,
	['author-surname'] = true,
	['author-link'] = true,
	['authorlink'] = true,
	['author-mask'] = true,
	['authors'] = false,
	['collaboration'] = true,
	['date'] = true,
	['df'] = true,
	['display-authors'] = true,
	['first'] = true,
	['given'] = true,
	['language'] = true,
	['last'] = true,
	['mode'] = true,
	['name-list-style'] = true,
	['no-tracking'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['postscript'] = true,
	['pp'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['surname'] = true,
	['template-doc-demo'] = true,
	['title'] = true,
	['trans-title'] = true,
	['vauthors'] = true,
	['year'] = true,
	}

local limited_numbered_arguments_t = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-given#'] = true,
	['author#-given'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-surname#'] = true,
	['author#-surname'] = true,
	['author-link#'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author#link'] = true,
	['author-mask#'] = true,
	['author#-mask'] = true,
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['surname#'] = true,
	}


--[[--------------------------&lt; U N I Q U E _ A R G U M E N T S &gt;----------------------------------------------

Some templates have unique parameters.  Those templates and their unique parameters are listed here. Keys in this
table are the template's CitationClass parameter value

Same conventions for true/false/tracked/nil as above.

]]

local unique_arguments_t = {
	['audio-visual'] = {
		['transcript'] = true,
		['transcript-format'] = true,
		['transcript-url'] = true,
		},
	conference = {
		['book-title'] = true,
		['conference'] = true,
		['conference-format'] = true,
		['conference-url'] = true,
		['event'] = true,
		},
	episode = {
		['airdate'] = true,
		['air-date'] = true,
		['credits'] = true,
		['episode-link'] = true,												-- alias of |title-link=
		['network'] = true,
		['season'] = true,
		['series-link'] = true,
		['series-no'] = true,
		['series-number'] = true,
		['station'] = true,
		['transcript'] = true,
		['transcript-format'] = true,
		['transcript-url'] = true,
		},
	mailinglist = {
		['mailing-list'] = true,
		},
	map = {
		['cartography'] = true,
		['inset'] = true,
		['map'] = true,
		['map-format'] = true,
		['map-url'] = true,
		['map-url-access'] = true,
		['script-map'] = true,
		['sections'] = true,
		['sheet'] = true,
		['sheets'] = true,
		['trans-map'] = true,
		},
	newsgroup = {
		['message-id'] = true,
		['newsgroup'] = true,
		},
	report = {
		['docket'] = true,
		},
	serial = {
		['airdate'] = true,
		['air-date'] = true,
		['credits'] = true,
		['episode'] = true,														-- cite serial only TODO: make available to cite episode?
		['episode-link'] = true,												-- alias of |title-link=
		['network'] = true,
		['series-link'] = true,
		['station'] = true,
		},
	speech = {
		['conference'] = true,
		['conference-format'] = true,
		['conference-url'] = true,
		['event'] = true,
		},
	thesis = {
		['degree'] = true,
		['docket'] = true,
		},
	}


--[[--------------------------&lt; C I T E _ D O C U M E N T &gt;----------------------------------------------------

Special case for cite document.  This template takes the limited basic and limited enumerated parameters plus
others that are apply only to standalone published sources that cannot be cited any other way; no url, book,
periodical, etc parameters; limited support for name lists and named identifiers.

when validating parameters in {{cite document}} templates, the basic and 

]]

local document_arguments_t = {
	['bibcode'] = true,
	['bibcode-access'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-access'] = true,
	['doi-broken-date'] = true,
	['hdl'] = true,
	['HDL'] = true,
	['hdl-access'] = true,
	['id'] = true,
	['ID'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['lang'] = true,
	['location'] = true,
	['mr'] = true,
	['MR'] = true,
	['no-pp'] = true,
	['orig-date'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['osti-access'] = true,
	['place'] = true,
	['publisher'] = true,
	['quote-page'] = true,
	['quote-pages'] = true,
	['script-quote'] = true,
	['script-title'] = true,
	['title-link'] = true,
	['translator'] = true,
	['translator-first'] = true,
	['translator-given'] = true,
	['translator-last'] = true,
	['translator-surname'] = true,
	['translator-link'] = true,
	['translator-mask'] = true,
	['trans-quote'] = true,
	['type'] = true,
	['zbl'] = true,
	['ZBL'] = true,
	}

local document_numbered_arguments_t = {
	['translator#'] = true,
	['translator-first#'] = true,
	['translator#-first'] = true,
	['translator-given#'] = true,
	['translator#-given'] = true,
	['translator-last#'] = true,
	['translator#-last'] = true,
	['translator-surname#'] = true,
	['translator#-surname'] = true,
	['translator-link#'] = true,
	['translator#-link'] = true,
	['translator-mask#'] = true,
	['translator#-mask'] = true,
	}


--[[--------------------------&lt; L I S T _ C O M B I N E &gt;------------------------------------------------------

makes one table from a list of tables.  &lt;lists_t&gt; is a sequence of tables to be combined

]]

local function list_combine (lists_t)
	local out_t = {};

	for _, list_t in ipairs (lists_t) do										-- for each list in &lt;lists_t&gt;
		for k, v in pairs (list_t) do											-- extract each k/v pair
			out_t[k] = v;														-- add to &lt;out_t&gt;
		end
	end
	return out_t;																-- and done
end


--[[--------------------------&lt; T E M P L A T E _ L I S T _ G E T &gt;--------------------------------------------

gets a list of the templates from table t

]]

local function template_list_get (t)
	local out_t = {};															-- a table for output
	for k, _ in pairs (t) do													-- spin through the table and collect the keys
		table.insert (out_t, k)													-- add each key to the output table
	end
	return out_t;																-- and done
end


--[[--------------------------&lt; E X P O R T E D   T A B L E S &gt;------------------------------------------------
]]

return {
	preprint_arguments_t = preprint_arguments_t,
	preprint_template_list_t = template_list_get (preprint_arguments_t),		-- make a template list from preprint_arguments{} table
	unique_arguments_t = unique_arguments_t,
	unique_param_template_list_t = template_list_get (unique_arguments_t),		-- make a template list from unique_arguments{} table
	
	document_parameters_t = list_combine ({limited_basic_arguments_t, limited_numbered_arguments_t, document_arguments_t, document_numbered_arguments_t});
	common_parameters_t = list_combine ({basic_arguments_t, numbered_arguments_t});
	limited_parameters_t = list_combine ({limited_basic_arguments_t, limited_numbered_arguments_t});
	};</text>
      <sha1>r2xt23jaere01lhs2h9ysq5iacj8pzq</sha1>
    </revision>
    <revision>
      <id>4814</id>
      <parentid>4813</parentid>
      <timestamp>2024-03-23T15:32:43Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4814</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="17976" sha1="1njb5pq14tolfly2zaulxza5sa6eawl" xml:space="preserve">--[[--------------------------&lt; S U P P O R T E D   P A R A M E T E R S &gt;--------------------------------------

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	tracked - these parameters are valid and supported parameters tracked in an eponymous properties category
	nil - these parameters are no longer supported. remove entirely
	
]]

local basic_arguments_t = {
	['accessdate'] = true,
	['access-date'] = true,
	['agency'] = true,
	['archivedate'] = true,
	['archive-date'] = true,
	['archive-format'] = true,
	['archiveurl'] = true,
	['archive-url'] = true,
	['article'] = true,
	['article-format'] = true,
	['article-number'] = true,													-- {{cite journal}}, {{cite conference}}; {{citation}} when |journal= has a value
	['article-url'] = true,
	['article-url-access'] = true,
	['arxiv'] = true,															-- cite arxiv; here because allowed in cite ... as identifier
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-given'] = true,
	['author-last'] = true,
	['author-surname'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['author-mask'] = true,
	['authors'] = false,
	['bibcode'] = true,
	['bibcode-access'] = true,
	['biorxiv'] = true,															-- cite biorxiv; here because allowed in cite ... as identifier
	['chapter'] = true,
	['chapter-format'] = true,
	['chapter-url'] = true,
	['chapter-url-access'] = true,
	['citeseerx'] = true,														-- cite citeseerx; here because allowed in cite ... as identifier
	['collaboration'] = true,
	['contribution'] = true,
	['contribution-format'] = true,
	['contribution-url'] = true,
	['contribution-url-access'] = true,
	['contributor'] = true,
	['contributor-first'] = true,
	['contributor-given'] = true,
	['contributor-last'] = true,
	['contributor-surname'] = true,
	['contributor-link'] = true,
	['contributor-mask'] = true,
	['date'] = true,
	['department'] = true,
	['df'] = true,
	['dictionary'] = true,
	['display-authors'] = true,
	['display-contributors'] = true,
	['display-editors'] = true,
	['display-interviewers'] = true,
	['display-subjects'] = true,
	['display-translators'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-access'] = true,
	['doi-broken-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['editor-first'] = true,
	['editor-given'] = true,
	['editor-last'] = true,
	['editor-surname'] = true,
	['editor-link'] = true,
	['editor-mask'] = true,
	['eissn'] = true,
	['EISSN'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['entry'] = true,
	['entry-format'] = true,
	['entry-url'] = true,
	['entry-url-access'] = true,
	['eprint'] = true,															-- cite arxiv; here because allowed in cite ... as identifier
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['hdl'] = true,
	['HDL'] = true,
	['hdl-access'] = true,
	['host'] = true,															-- unique to certain templates?
	['id'] = true,
	['ID'] = true,
	['institution'] = true,														-- constrain to cite thesis?
	['interviewer'] = true,
	['interviewer-first'] = true,
	['interviewer-given'] = true,
	['interviewer-last'] = true,
	['interviewer-surname'] = true,
	['interviewer-link'] = true,
	['interviewer-mask'] = true,
	['isbn'] = true,
	['ISBN'] = true,
	['ismn'] = true,
	['ISMN'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['jstor-access'] = true,
	['lang'] = true,
	['language'] = true,
	['last'] = true,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['magazine'] = true,
	['medium'] = true,
	['medrxiv'] = true,															-- cite medrxiv; here because allowed in cite ... as identifier
	['minutes'] = true,															-- constrain to cite AV media and podcast?
	['mode'] = true,
	['mr'] = true,
	['MR'] = true,
	['name-list-style'] = true,
	['newspaper'] = true,
	['no-pp'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['ol-access'] = true,
	['orig-date'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['osti-access'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['people'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmc-embargo-date'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['publication-date'] = true,
	['publication-place'] = true,
	['publisher'] = true,
	['quotation'] = true,
	['quote'] = true,
	['quote-page'] = true,
	['quote-pages'] = true,
	['ref'] = true,
	['rfc'] = true,
	['RFC'] = true,
	['sbn'] = true,
	['SBN'] = true,
	['scale'] = true,
	['script-article'] = true,
	['script-chapter'] = true,
	['script-contribution'] = true,
	['script-encyclopaedia'] = true,
	['script-encyclopedia'] = true,
	['script-entry'] = true,
	['script-journal'] = true,
	['script-magazine'] = true,
	['script-newspaper'] = true,
	['script-periodical'] = true,
	['script-quote'] = true,
	['script-section'] = true,
	['script-title'] = true,
	['script-website'] = true,
	['script-work'] = true,
	['section'] = true,
	['section-format'] = true,
	['section-url'] = true,
	['section-url-access'] = true,
	['series'] = true,
	['ssrn'] = true,															-- cite ssrn; these three here because allowed in cite ... as identifier
	['SSRN'] = true,
	['ssrn-access'] = true,
	['subject'] = true,
	['subject-first'] = true,
	['subject-given'] = true,
	['subject-last'] = true,
	['subject-link'] = true,
	['subject-mask'] = true,
	['subject-surname'] = true,
	['surname'] = true,
	['s2cid'] = true,
	['S2CID'] = true,
	['s2cid-access'] = true,
	['template-doc-demo'] = true,
	['time'] = true,															-- constrain to cite av media and podcast?
	['time-caption'] = true,													-- constrain to cite av media and podcast?
	['title'] = true,
	['title-link'] = true,
	['title-note'] = true,
	['translator'] = true,
	['translator-first'] = true,
	['translator-given'] = true,
	['translator-last'] = true,	
	['translator-surname'] = true,
	['translator-link'] = true,
	['translator-mask'] = true,
	['trans-article'] = true,
	['trans-chapter'] = true,
	['trans-contribution'] = true,
	['trans-encyclopaedia'] = true,
	['trans-encyclopedia'] = true,
	['trans-entry'] = true,
	['trans-journal'] = true,
	['trans-magazine'] = true,
	['trans-newspaper'] = true,
	['trans-periodical'] = true,
	['trans-quote'] = true,
	['trans-section'] = true,
	['trans-title'] = true,
	['trans-website'] = true,
	['trans-work'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['url-access'] = true,
	['url-status'] = true,
	['vauthors'] = true,
	['veditors'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
	}

local numbered_arguments_t = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-given#'] = true,
	['author#-given'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-surname#'] = true,
	['author#-surname'] = true,
	['author-link#'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author#link'] = true,
	['author-mask#'] = true,
	['author#-mask'] = true,
	['contributor#'] = true,
	['contributor-first#'] = true,
	['contributor#-first'] = true,
	['contributor-given#'] = true,
	['contributor#-given'] = true,
	['contributor-last#'] = true,
	['contributor#-last'] = true,
	['contributor-surname#'] = true,
	['contributor#-surname'] = true,
	['contributor-link#'] = true,
	['contributor#-link'] = true,
	['contributor-mask#'] = true,
	['contributor#-mask'] = true,
	['editor#'] = true,
	['editor-first#'] = true,
	['editor#-first'] = true,
	['editor-given#'] = true,
	['editor#-given'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-surname#'] = true,
	['editor#-surname'] = true,
	['editor-link#'] = true,
	['editor#-link'] = true,
	['editor-mask#'] = true,
	['editor#-mask'] = true,
	['first#'] = true,
	['given#'] = true,
	['host#'] = true,
	['interviewer#'] = true,
	['interviewer-first#'] = true,
	['interviewer#-first'] = true,
	['interviewer-given#'] = true,
	['interviewer#-given'] = true,
	['interviewer-last#'] = true,
	['interviewer#-last'] = true,
	['interviewer-surname#'] = true,
	['interviewer#-surname'] = true,
	['interviewer-link#'] = true,
	['interviewer#-link'] = true,
	['interviewer-mask#'] = true,
	['interviewer#-mask'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-first#'] = true,
	['subject#-first'] = true,
	['subject-given#'] = true,
	['subject#-given'] = true,
	['subject-last#'] = true,
	['subject#-last'] = true,
	['subject-link#'] = true,
	['subject#-link'] = true,
	['subject-mask#'] = true,
	['subject#-mask'] = true,
	['subject-surname#'] = true,
	['subject#-surname'] = true,
	['surname#'] = true,
	['translator#'] = true,
	['translator-first#'] = true,
	['translator#-first'] = true,
	['translator-given#'] = true,
	['translator#-given'] = true,
	['translator-last#'] = true,
	['translator#-last'] = true,
	['translator-surname#'] = true,
	['translator#-surname'] = true,
	['translator-link#'] = true,
	['translator#-link'] = true,
	['translator-mask#'] = true,
	['translator#-mask'] = true,
	}


--[[--------------------------&lt; P R E P R I N T   S U P P O R T E D   P A R A M E T E R S &gt;--------------------

Cite arXiv, cite biorxiv, cite citeseerx, cite medrxiv, and cite ssrn are preprint templates that use the limited
set of parameters defined in the limited_basic_arguments and limited_numbered_arguments tables.  Those lists are
supplemented with a template-specific list of parameters that are required by the particular template and may be
exclusive to one of the preprint templates.  Some of these parameters may also be available to the general cs1|2
templates.

Same conventions for true/false/tracked/nil as above.

]]

local preprint_arguments_t = {
	arxiv = {
		['arxiv'] = true,														-- cite arxiv and arxiv identifiers
		['class'] = true,
		['eprint'] = true,														-- cite arxiv and arxiv identifiers
		},
	biorxiv = {
		['biorxiv'] = true,
		},
	citeseerx = {
		['citeseerx'] = true,
		},
	medrxiv = {
		['medrxiv'] = true,
		},
	ssrn = {
		['ssrn'] = true,
		['SSRN'] = true,
		['ssrn-access'] = true,
		},
	}


--[[--------------------------&lt; L I M I T E D   S U P P O R T E D   P A R A M E T E R S &gt;----------------------

cite arxiv, cite biorxiv, cite citeseerx, cite medrxiv, and cite ssrn templates are preprint templates so are
allowed only a limited subset of parameters allowed to all other cs1|2 templates.  The limited subset is defined
here.

This list of parameters also used by {{cite document}}

Same conventions for true/false/tracked/nil as above.
	
]]

local limited_basic_arguments_t = {
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-given'] = true,
	['author-last'] = true,
	['author-surname'] = true,
	['author-link'] = true,
	['authorlink'] = true,
	['author-mask'] = true,
	['authors'] = false,
	['collaboration'] = true,
	['date'] = true,
	['df'] = true,
	['display-authors'] = true,
	['first'] = true,
	['given'] = true,
	['language'] = true,
	['last'] = true,
	['mode'] = true,
	['name-list-style'] = true,
	['no-tracking'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['postscript'] = true,
	['pp'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['surname'] = true,
	['template-doc-demo'] = true,
	['title'] = true,
	['trans-title'] = true,
	['vauthors'] = true,
	['year'] = true,
	}

local limited_numbered_arguments_t = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-given#'] = true,
	['author#-given'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-surname#'] = true,
	['author#-surname'] = true,
	['author-link#'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author#link'] = true,
	['author-mask#'] = true,
	['author#-mask'] = true,
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['surname#'] = true,
	}


--[[--------------------------&lt; U N I Q U E _ A R G U M E N T S &gt;----------------------------------------------

Some templates have unique parameters.  Those templates and their unique parameters are listed here. Keys in this
table are the template's CitationClass parameter value

Same conventions for true/false/tracked/nil as above.

]]

local unique_arguments_t = {
	['audio-visual'] = {
		['transcript'] = true,
		['transcript-format'] = true,
		['transcript-url'] = true,
		},
	conference = {
		['book-title'] = true,
		['conference'] = true,
		['conference-format'] = true,
		['conference-url'] = true,
		['event'] = true,
		},
	episode = {
		['airdate'] = true,
		['air-date'] = true,
		['credits'] = true,
		['episode-link'] = true,												-- alias of |title-link=
		['network'] = true,
		['season'] = true,
		['series-link'] = true,
		['series-no'] = true,
		['series-number'] = true,
		['station'] = true,
		['transcript'] = true,
		['transcript-format'] = true,
		['transcript-url'] = true,
		},
	mailinglist = {
		['mailing-list'] = true,
		},
	map = {
		['cartography'] = true,
		['inset'] = true,
		['map'] = true,
		['map-format'] = true,
		['map-url'] = true,
		['map-url-access'] = true,
		['script-map'] = true,
		['sections'] = true,
		['sheet'] = true,
		['sheets'] = true,
		['trans-map'] = true,
		},
	newsgroup = {
		['message-id'] = true,
		['newsgroup'] = true,
		},
	report = {
		['docket'] = true,
		},
	serial = {
		['airdate'] = true,
		['air-date'] = true,
		['credits'] = true,
		['episode'] = true,														-- cite serial only TODO: make available to cite episode?
		['episode-link'] = true,												-- alias of |title-link=
		['network'] = true,
		['series-link'] = true,
		['station'] = true,
		},
	speech = {
		['conference'] = true,
		['conference-format'] = true,
		['conference-url'] = true,
		['event'] = true,
		},
	thesis = {
		['degree'] = true,
		['docket'] = true,
		},
	}


--[[--------------------------&lt; C I T E _ D O C U M E N T &gt;----------------------------------------------------

Special case for cite document.  This template takes the limited basic and limited enumerated parameters plus
others that are apply only to standalone published sources that cannot be cited any other way; no url, book,
periodical, etc parameters; limited support for name lists and named identifiers.

when validating parameters in {{cite document}} templates, the basic and 

]]

local document_arguments_t = {
	['bibcode'] = true,
	['bibcode-access'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-access'] = true,
	['doi-broken-date'] = true,
	['hdl'] = true,
	['HDL'] = true,
	['hdl-access'] = true,
	['id'] = true,
	['ID'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['lang'] = true,
	['location'] = true,
	['mr'] = true,
	['MR'] = true,
	['no-pp'] = true,
	['orig-date'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['osti-access'] = true,
	['place'] = true,
	['publisher'] = true,
	['quote-page'] = true,
	['quote-pages'] = true,
	['script-quote'] = true,
	['script-title'] = true,
	['title-link'] = true,
	['translator'] = true,
	['translator-first'] = true,
	['translator-given'] = true,
	['translator-last'] = true,
	['translator-surname'] = true,
	['translator-link'] = true,
	['translator-mask'] = true,
	['trans-quote'] = true,
	['type'] = true,
	['zbl'] = true,
	['ZBL'] = true,
	}

local document_numbered_arguments_t = {
	['translator#'] = true,
	['translator-first#'] = true,
	['translator#-first'] = true,
	['translator-given#'] = true,
	['translator#-given'] = true,
	['translator-last#'] = true,
	['translator#-last'] = true,
	['translator-surname#'] = true,
	['translator#-surname'] = true,
	['translator-link#'] = true,
	['translator#-link'] = true,
	['translator-mask#'] = true,
	['translator#-mask'] = true,
	}


--[[--------------------------&lt; L I S T _ C O M B I N E &gt;------------------------------------------------------

makes one table from a list of tables.  &lt;lists_t&gt; is a sequence of tables to be combined

]]

local function list_combine (lists_t)
	local out_t = {};

	for _, list_t in ipairs (lists_t) do										-- for each list in &lt;lists_t&gt;
		for k, v in pairs (list_t) do											-- extract each k/v pair
			out_t[k] = v;														-- add to &lt;out_t&gt;
		end
	end
	return out_t;																-- and done
end


--[[--------------------------&lt; T E M P L A T E _ L I S T _ G E T &gt;--------------------------------------------

gets a list of the templates from table t

]]

local function template_list_get (t)
	local out_t = {};															-- a table for output
	for k, _ in pairs (t) do													-- spin through the table and collect the keys
		table.insert (out_t, k)													-- add each key to the output table
	end
	return out_t;																-- and done
end


--[[--------------------------&lt; E X P O R T E D   T A B L E S &gt;------------------------------------------------
]]

return {
	preprint_arguments_t = preprint_arguments_t,
	preprint_template_list_t = template_list_get (preprint_arguments_t),		-- make a template list from preprint_arguments{} table
	unique_arguments_t = unique_arguments_t,
	unique_param_template_list_t = template_list_get (unique_arguments_t),		-- make a template list from unique_arguments{} table
	
	document_parameters_t = list_combine ({limited_basic_arguments_t, limited_numbered_arguments_t, document_arguments_t, document_numbered_arguments_t});
	common_parameters_t = list_combine ({basic_arguments_t, numbered_arguments_t});
	limited_parameters_t = list_combine ({limited_basic_arguments_t, limited_numbered_arguments_t});
	};</text>
      <sha1>1njb5pq14tolfly2zaulxza5sa6eawl</sha1>
    </revision>
    <revision>
      <id>4815</id>
      <parentid>4814</parentid>
      <timestamp>2024-08-17T18:39:09Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4815</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="17975" sha1="baub5v4d976tff8ebf3konhoua4ojgu" xml:space="preserve">--[[--------------------------&lt; S U P P O R T E D   P A R A M E T E R S &gt;--------------------------------------

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	tracked - these parameters are valid and supported parameters tracked in an eponymous properties category
	nil - these parameters are no longer supported. remove entirely
	
]]

local basic_arguments_t = {
	['accessdate'] = true,
	['access-date'] = true,
	['agency'] = true,
	['archivedate'] = true,
	['archive-date'] = true,
	['archive-format'] = true,
	['archiveurl'] = true,
	['archive-url'] = true,
	['article'] = true,
	['article-format'] = true,
	['article-number'] = true,													-- {{cite journal}}, {{cite conference}}; {{citation}} when |journal= has a value
	['article-url'] = true,
	['article-url-access'] = true,
	['arxiv'] = true,															-- cite arxiv; here because allowed in cite ... as identifier
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-given'] = true,
	['author-last'] = true,
	['author-surname'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['author-mask'] = true,
	['bibcode'] = true,
	['bibcode-access'] = true,
	['biorxiv'] = true,															-- cite biorxiv; here because allowed in cite ... as identifier
	['chapter'] = true,
	['chapter-format'] = true,
	['chapter-url'] = true,
	['chapter-url-access'] = true,
	['citeseerx'] = true,														-- cite citeseerx; here because allowed in cite ... as identifier
	['collaboration'] = true,
	['contribution'] = true,
	['contribution-format'] = true,
	['contribution-url'] = true,
	['contribution-url-access'] = true,
	['contributor'] = true,
	['contributor-first'] = true,
	['contributor-given'] = true,
	['contributor-last'] = true,
	['contributor-surname'] = true,
	['contributor-link'] = true,
	['contributor-mask'] = true,
	['date'] = true,
	['department'] = true,
	['df'] = true,
	['dictionary'] = true,
	['display-authors'] = true,
	['display-contributors'] = true,
	['display-editors'] = true,
	['display-interviewers'] = true,
	['display-subjects'] = true,
	['display-translators'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-access'] = true,
	['doi-broken-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['editor-first'] = true,
	['editor-given'] = true,
	['editor-last'] = true,
	['editor-surname'] = true,
	['editor-link'] = true,
	['editor-mask'] = true,
	['eissn'] = true,
	['EISSN'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['entry'] = true,
	['entry-format'] = true,
	['entry-url'] = true,
	['entry-url-access'] = true,
	['eprint'] = true,															-- cite arxiv; here because allowed in cite ... as identifier
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['hdl'] = true,
	['HDL'] = true,
	['hdl-access'] = true,
	['host'] = true,															-- unique to certain templates?
	['id'] = true,
	['ID'] = true,
	['institution'] = true,														-- constrain to cite thesis?
	['interviewer'] = true,
	['interviewer-first'] = true,
	['interviewer-given'] = true,
	['interviewer-last'] = true,
	['interviewer-surname'] = true,
	['interviewer-link'] = true,
	['interviewer-mask'] = true,
	['isbn'] = true,
	['ISBN'] = true,
	['ismn'] = true,
	['ISMN'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['jstor-access'] = true,
	['lang'] = true,
	['language'] = true,
	['last'] = true,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['magazine'] = true,
	['medium'] = true,
	['medrxiv'] = true,															-- cite medrxiv; here because allowed in cite ... as identifier
	['minutes'] = true,															-- constrain to cite AV media and podcast?
	['mode'] = true,
	['mr'] = true,
	['MR'] = true,
	['name-list-style'] = true,
	['newspaper'] = true,
	['no-pp'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['ol-access'] = true,
	['orig-date'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['osti-access'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmc-embargo-date'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['publication-date'] = true,
	['publication-place'] = true,
	['publisher'] = true,
	['quotation'] = true,
	['quote'] = true,
	['quote-page'] = true,
	['quote-pages'] = true,
	['ref'] = true,
	['rfc'] = true,
	['RFC'] = true,
	['sbn'] = true,
	['SBN'] = true,
	['scale'] = true,
	['script-article'] = true,
	['script-chapter'] = true,
	['script-contribution'] = true,
	['script-encyclopaedia'] = true,
	['script-encyclopedia'] = true,
	['script-entry'] = true,
	['script-journal'] = true,
	['script-magazine'] = true,
	['script-newspaper'] = true,
	['script-periodical'] = true,
	['script-quote'] = true,
	['script-section'] = true,
	['script-title'] = true,
	['script-website'] = true,
	['script-work'] = true,
	['section'] = true,
	['section-format'] = true,
	['section-url'] = true,
	['section-url-access'] = true,
	['series'] = true,
	['ssrn'] = true,															-- cite ssrn; these three here because allowed in cite ... as identifier
	['SSRN'] = true,
	['ssrn-access'] = true,
	['subject'] = true,
	['subject-first'] = true,
	['subject-given'] = true,
	['subject-last'] = true,
	['subject-link'] = true,
	['subject-mask'] = true,
	['subject-surname'] = true,
	['surname'] = true,
	['s2cid'] = true,
	['S2CID'] = true,
	['s2cid-access'] = true,
	['template-doc-demo'] = true,
	['time'] = true,															-- constrain to cite av media and podcast?
	['time-caption'] = true,													-- constrain to cite av media and podcast?
	['title'] = true,
	['title-link'] = true,
	['title-note'] = true,
	['translator'] = true,
	['translator-first'] = true,
	['translator-given'] = true,
	['translator-last'] = true,	
	['translator-surname'] = true,
	['translator-link'] = true,
	['translator-mask'] = true,
	['trans-article'] = true,
	['trans-chapter'] = true,
	['trans-contribution'] = true,
	['trans-encyclopaedia'] = true,
	['trans-encyclopedia'] = true,
	['trans-entry'] = true,
	['trans-journal'] = true,
	['trans-magazine'] = true,
	['trans-newspaper'] = true,
	['trans-periodical'] = true,
	['trans-quote'] = true,
	['trans-section'] = true,
	['trans-title'] = true,
	['trans-website'] = true,
	['trans-work'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['url-access'] = true,
	['url-status'] = true,
	['vauthors'] = true,
	['veditors'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
	}

local numbered_arguments_t = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-given#'] = true,
	['author#-given'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-surname#'] = true,
	['author#-surname'] = true,
	['author-link#'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author#link'] = true,
	['author-mask#'] = true,
	['author#-mask'] = true,
	['contributor#'] = true,
	['contributor-first#'] = true,
	['contributor#-first'] = true,
	['contributor-given#'] = true,
	['contributor#-given'] = true,
	['contributor-last#'] = true,
	['contributor#-last'] = true,
	['contributor-surname#'] = true,
	['contributor#-surname'] = true,
	['contributor-link#'] = true,
	['contributor#-link'] = true,
	['contributor-mask#'] = true,
	['contributor#-mask'] = true,
	['editor#'] = true,
	['editor-first#'] = true,
	['editor#-first'] = true,
	['editor-given#'] = true,
	['editor#-given'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-surname#'] = true,
	['editor#-surname'] = true,
	['editor-link#'] = true,
	['editor#-link'] = true,
	['editor-mask#'] = true,
	['editor#-mask'] = true,
	['first#'] = true,
	['given#'] = true,
	['host#'] = true,
	['interviewer#'] = true,
	['interviewer-first#'] = true,
	['interviewer#-first'] = true,
	['interviewer-given#'] = true,
	['interviewer#-given'] = true,
	['interviewer-last#'] = true,
	['interviewer#-last'] = true,
	['interviewer-surname#'] = true,
	['interviewer#-surname'] = true,
	['interviewer-link#'] = true,
	['interviewer#-link'] = true,
	['interviewer-mask#'] = true,
	['interviewer#-mask'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-first#'] = true,
	['subject#-first'] = true,
	['subject-given#'] = true,
	['subject#-given'] = true,
	['subject-last#'] = true,
	['subject#-last'] = true,
	['subject-link#'] = true,
	['subject#-link'] = true,
	['subject-mask#'] = true,
	['subject#-mask'] = true,
	['subject-surname#'] = true,
	['subject#-surname'] = true,
	['surname#'] = true,
	['translator#'] = true,
	['translator-first#'] = true,
	['translator#-first'] = true,
	['translator-given#'] = true,
	['translator#-given'] = true,
	['translator-last#'] = true,
	['translator#-last'] = true,
	['translator-surname#'] = true,
	['translator#-surname'] = true,
	['translator-link#'] = true,
	['translator#-link'] = true,
	['translator-mask#'] = true,
	['translator#-mask'] = true,
	}


--[[--------------------------&lt; P R E P R I N T   S U P P O R T E D   P A R A M E T E R S &gt;--------------------

Cite arXiv, cite biorxiv, cite citeseerx, cite medrxiv, and cite ssrn are preprint templates that use the limited
set of parameters defined in the limited_basic_arguments and limited_numbered_arguments tables.  Those lists are
supplemented with a template-specific list of parameters that are required by the particular template and may be
exclusive to one of the preprint templates.  Some of these parameters may also be available to the general cs1|2
templates.

Same conventions for true/false/tracked/nil as above.

]]

local preprint_arguments_t = {
	arxiv = {
		['arxiv'] = true,														-- cite arxiv and arxiv identifiers
		['class'] = true,
		['eprint'] = true,														-- cite arxiv and arxiv identifiers
		},
	biorxiv = {
		['biorxiv'] = true,
		},
	citeseerx = {
		['citeseerx'] = true,
		},
	medrxiv = {
		['medrxiv'] = true,
		},
	ssrn = {
		['ssrn'] = true,
		['SSRN'] = true,
		['ssrn-access'] = true,
		},
	}


--[[--------------------------&lt; L I M I T E D   S U P P O R T E D   P A R A M E T E R S &gt;----------------------

cite arxiv, cite biorxiv, cite citeseerx, cite medrxiv, and cite ssrn templates are preprint templates so are
allowed only a limited subset of parameters allowed to all other cs1|2 templates.  The limited subset is defined
here.

This list of parameters also used by {{cite document}}

Same conventions for true/false/tracked/nil as above.
	
]]

local limited_basic_arguments_t = {
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-given'] = true,
	['author-last'] = true,
	['author-surname'] = true,
	['author-link'] = true,
	['authorlink'] = true,
	['author-mask'] = true,
	['collaboration'] = true,
	['date'] = true,
	['df'] = true,
	['display-authors'] = true,
	['first'] = true,
	['given'] = true,
	['language'] = true,
	['last'] = true,
	['mode'] = true,
	['name-list-style'] = true,
	['no-tracking'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['postscript'] = true,
	['pp'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['surname'] = true,
	['template-doc-demo'] = true,
	['title'] = true,
	['trans-title'] = true,
	['vauthors'] = true,
	['year'] = true,
	}

local limited_numbered_arguments_t = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-given#'] = true,
	['author#-given'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-surname#'] = true,
	['author#-surname'] = true,
	['author-link#'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author#link'] = true,
	['author-mask#'] = true,
	['author#-mask'] = true,
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['surname#'] = true,
	}


--[[--------------------------&lt; U N I Q U E _ A R G U M E N T S &gt;----------------------------------------------

Some templates have unique parameters.  Those templates and their unique parameters are listed here. Keys in this
table are the template's CitationClass parameter value

Same conventions for true/false/tracked/nil as above.

]]

local unique_arguments_t = {
	['audio-visual'] = {
		['people'] = true,
		['transcript'] = true,
		['transcript-format'] = true,
		['transcript-url'] = true,
		},
	conference = {
		['book-title'] = true,
		['conference'] = true,
		['conference-format'] = true,
		['conference-url'] = true,
		['event'] = true,
		},
	episode = {
		['airdate'] = true,
		['air-date'] = true,
		['credits'] = true,
		['episode-link'] = true,												-- alias of |title-link=
		['network'] = true,
		['people'] = true,
		['season'] = true,
		['series-link'] = true,
		['series-no'] = true,
		['series-number'] = true,
		['station'] = true,
		['transcript'] = true,
		['transcript-format'] = true,
		['transcript-url'] = true,
		},
	mailinglist = {
		['mailing-list'] = true,
		},
	map = {
		['cartography'] = true,
		['inset'] = true,
		['map'] = true,
		['map-format'] = true,
		['map-url'] = true,
		['map-url-access'] = true,
		['script-map'] = true,
		['sections'] = true,
		['sheet'] = true,
		['sheets'] = true,
		['trans-map'] = true,
		},
	newsgroup = {
		['message-id'] = true,
		['newsgroup'] = true,
		},
	report = {
		['docket'] = true,
		},
	serial = {
		['airdate'] = true,
		['air-date'] = true,
		['credits'] = true,
		['episode'] = true,														-- cite serial only TODO: make available to cite episode?
		['episode-link'] = true,												-- alias of |title-link=
		['network'] = true,
		['people'] = true,
		['series-link'] = true,
		['station'] = true,
		},
	speech = {
		['conference'] = true,
		['conference-format'] = true,
		['conference-url'] = true,
		['event'] = true,
		},
	thesis = {
		['degree'] = true,
		['docket'] = true,
		},
	}


--[[--------------------------&lt; C I T E _ D O C U M E N T &gt;----------------------------------------------------

Special case for cite document.  This template takes the limited basic and limited enumerated parameters plus
others that are apply only to standalone published sources that cannot be cited any other way; no url, book,
periodical, etc parameters; limited support for name lists and named identifiers.

when validating parameters in {{cite document}} templates, the basic and 

]]

local document_arguments_t = {
	['bibcode'] = true,
	['bibcode-access'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-access'] = true,
	['doi-broken-date'] = true,
	['hdl'] = true,
	['HDL'] = true,
	['hdl-access'] = true,
	['id'] = true,
	['ID'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['lang'] = true,
	['location'] = true,
	['mr'] = true,
	['MR'] = true,
	['no-pp'] = true,
	['orig-date'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['osti-access'] = true,
	['place'] = true,
	['publisher'] = true,
	['quote-page'] = true,
	['quote-pages'] = true,
	['script-quote'] = true,
	['script-title'] = true,
	['title-link'] = true,
	['translator'] = true,
	['translator-first'] = true,
	['translator-given'] = true,
	['translator-last'] = true,
	['translator-surname'] = true,
	['translator-link'] = true,
	['translator-mask'] = true,
	['trans-quote'] = true,
	['type'] = true,
	['zbl'] = true,
	['ZBL'] = true,
	}

local document_numbered_arguments_t = {
	['translator#'] = true,
	['translator-first#'] = true,
	['translator#-first'] = true,
	['translator-given#'] = true,
	['translator#-given'] = true,
	['translator-last#'] = true,
	['translator#-last'] = true,
	['translator-surname#'] = true,
	['translator#-surname'] = true,
	['translator-link#'] = true,
	['translator#-link'] = true,
	['translator-mask#'] = true,
	['translator#-mask'] = true,
	}


--[[--------------------------&lt; L I S T _ C O M B I N E &gt;------------------------------------------------------

makes one table from a list of tables.  &lt;lists_t&gt; is a sequence of tables to be combined

]]

local function list_combine (lists_t)
	local out_t = {};

	for _, list_t in ipairs (lists_t) do										-- for each list in &lt;lists_t&gt;
		for k, v in pairs (list_t) do											-- extract each k/v pair
			out_t[k] = v;														-- add to &lt;out_t&gt;
		end
	end
	return out_t;																-- and done
end


--[[--------------------------&lt; T E M P L A T E _ L I S T _ G E T &gt;--------------------------------------------

gets a list of the templates from table t

]]

local function template_list_get (t)
	local out_t = {};															-- a table for output
	for k, _ in pairs (t) do													-- spin through the table and collect the keys
		table.insert (out_t, k)													-- add each key to the output table
	end
	return out_t;																-- and done
end


--[[--------------------------&lt; E X P O R T E D   T A B L E S &gt;------------------------------------------------
]]

return {
	preprint_arguments_t = preprint_arguments_t,
	preprint_template_list_t = template_list_get (preprint_arguments_t),		-- make a template list from preprint_arguments{} table
	unique_arguments_t = unique_arguments_t,
	unique_param_template_list_t = template_list_get (unique_arguments_t),		-- make a template list from unique_arguments{} table
	
	document_parameters_t = list_combine ({limited_basic_arguments_t, limited_numbered_arguments_t, document_arguments_t, document_numbered_arguments_t});
	common_parameters_t = list_combine ({basic_arguments_t, numbered_arguments_t});
	limited_parameters_t = list_combine ({limited_basic_arguments_t, limited_numbered_arguments_t});
	};</text>
      <sha1>baub5v4d976tff8ebf3konhoua4ojgu</sha1>
    </revision>
    <revision>
      <id>4816</id>
      <parentid>4815</parentid>
      <timestamp>2025-08-07T07:38:17Z</timestamp>
      <contributor>
        <username>Martin Urbanec</username>
        <id>803</id>
      </contributor>
      <minor />
      <comment>55 revisions imported from [[:en:Module:Citation/CS1/Whitelist]]: updating from enwiki</comment>
      <origin>4815</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="17975" sha1="baub5v4d976tff8ebf3konhoua4ojgu" xml:space="preserve">--[[--------------------------&lt; S U P P O R T E D   P A R A M E T E R S &gt;--------------------------------------

Because a steady-state signal conveys no useful information, whitelist.basic_arguments[] list items can have three values:
	true - these parameters are valid and supported parameters
	false - these parameters are deprecated but still supported
	tracked - these parameters are valid and supported parameters tracked in an eponymous properties category
	nil - these parameters are no longer supported. remove entirely
	
]]

local basic_arguments_t = {
	['accessdate'] = true,
	['access-date'] = true,
	['agency'] = true,
	['archivedate'] = true,
	['archive-date'] = true,
	['archive-format'] = true,
	['archiveurl'] = true,
	['archive-url'] = true,
	['article'] = true,
	['article-format'] = true,
	['article-number'] = true,													-- {{cite journal}}, {{cite conference}}; {{citation}} when |journal= has a value
	['article-url'] = true,
	['article-url-access'] = true,
	['arxiv'] = true,															-- cite arxiv; here because allowed in cite ... as identifier
	['asin'] = true,
	['ASIN'] = true,
	['asin-tld'] = true,
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-given'] = true,
	['author-last'] = true,
	['author-surname'] = true,
	['authorlink'] = true,
	['author-link'] = true,
	['author-mask'] = true,
	['bibcode'] = true,
	['bibcode-access'] = true,
	['biorxiv'] = true,															-- cite biorxiv; here because allowed in cite ... as identifier
	['chapter'] = true,
	['chapter-format'] = true,
	['chapter-url'] = true,
	['chapter-url-access'] = true,
	['citeseerx'] = true,														-- cite citeseerx; here because allowed in cite ... as identifier
	['collaboration'] = true,
	['contribution'] = true,
	['contribution-format'] = true,
	['contribution-url'] = true,
	['contribution-url-access'] = true,
	['contributor'] = true,
	['contributor-first'] = true,
	['contributor-given'] = true,
	['contributor-last'] = true,
	['contributor-surname'] = true,
	['contributor-link'] = true,
	['contributor-mask'] = true,
	['date'] = true,
	['department'] = true,
	['df'] = true,
	['dictionary'] = true,
	['display-authors'] = true,
	['display-contributors'] = true,
	['display-editors'] = true,
	['display-interviewers'] = true,
	['display-subjects'] = true,
	['display-translators'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-access'] = true,
	['doi-broken-date'] = true,
	['edition'] = true,
	['editor'] = true,
	['editor-first'] = true,
	['editor-given'] = true,
	['editor-last'] = true,
	['editor-surname'] = true,
	['editor-link'] = true,
	['editor-mask'] = true,
	['eissn'] = true,
	['EISSN'] = true,
	['encyclopaedia'] = true,
	['encyclopedia'] = true,
	['entry'] = true,
	['entry-format'] = true,
	['entry-url'] = true,
	['entry-url-access'] = true,
	['eprint'] = true,															-- cite arxiv; here because allowed in cite ... as identifier
	['first'] = true,
	['format'] = true,
	['given'] = true,
	['hdl'] = true,
	['HDL'] = true,
	['hdl-access'] = true,
	['host'] = true,															-- unique to certain templates?
	['id'] = true,
	['ID'] = true,
	['institution'] = true,														-- constrain to cite thesis?
	['interviewer'] = true,
	['interviewer-first'] = true,
	['interviewer-given'] = true,
	['interviewer-last'] = true,
	['interviewer-surname'] = true,
	['interviewer-link'] = true,
	['interviewer-mask'] = true,
	['isbn'] = true,
	['ISBN'] = true,
	['ismn'] = true,
	['ISMN'] = true,
	['issn'] = true,
	['ISSN'] = true,
	['issue'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['journal'] = true,
	['jstor'] = true,
	['JSTOR'] = true,
	['jstor-access'] = true,
	['lang'] = true,
	['language'] = true,
	['last'] = true,
	['lccn'] = true,
	['LCCN'] = true,
	['location'] = true,
	['magazine'] = true,
	['medium'] = true,
	['medrxiv'] = true,															-- cite medrxiv; here because allowed in cite ... as identifier
	['minutes'] = true,															-- constrain to cite AV media and podcast?
	['mode'] = true,
	['mr'] = true,
	['MR'] = true,
	['name-list-style'] = true,
	['newspaper'] = true,
	['no-pp'] = true,
	['no-tracking'] = true,
	['number'] = true,
	['oclc'] = true,
	['OCLC'] = true,
	['ol'] = true,
	['OL'] = true,
	['ol-access'] = true,
	['orig-date'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['osti-access'] = true,
	['others'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['periodical'] = true,
	['place'] = true,
	['pmc'] = true,
	['PMC'] = true,
	['pmc-embargo-date'] = true,
	['pmid'] = true,
	['PMID'] = true,
	['postscript'] = true,
	['pp'] = true,
	['publication-date'] = true,
	['publication-place'] = true,
	['publisher'] = true,
	['quotation'] = true,
	['quote'] = true,
	['quote-page'] = true,
	['quote-pages'] = true,
	['ref'] = true,
	['rfc'] = true,
	['RFC'] = true,
	['sbn'] = true,
	['SBN'] = true,
	['scale'] = true,
	['script-article'] = true,
	['script-chapter'] = true,
	['script-contribution'] = true,
	['script-encyclopaedia'] = true,
	['script-encyclopedia'] = true,
	['script-entry'] = true,
	['script-journal'] = true,
	['script-magazine'] = true,
	['script-newspaper'] = true,
	['script-periodical'] = true,
	['script-quote'] = true,
	['script-section'] = true,
	['script-title'] = true,
	['script-website'] = true,
	['script-work'] = true,
	['section'] = true,
	['section-format'] = true,
	['section-url'] = true,
	['section-url-access'] = true,
	['series'] = true,
	['ssrn'] = true,															-- cite ssrn; these three here because allowed in cite ... as identifier
	['SSRN'] = true,
	['ssrn-access'] = true,
	['subject'] = true,
	['subject-first'] = true,
	['subject-given'] = true,
	['subject-last'] = true,
	['subject-link'] = true,
	['subject-mask'] = true,
	['subject-surname'] = true,
	['surname'] = true,
	['s2cid'] = true,
	['S2CID'] = true,
	['s2cid-access'] = true,
	['template-doc-demo'] = true,
	['time'] = true,															-- constrain to cite av media and podcast?
	['time-caption'] = true,													-- constrain to cite av media and podcast?
	['title'] = true,
	['title-link'] = true,
	['title-note'] = true,
	['translator'] = true,
	['translator-first'] = true,
	['translator-given'] = true,
	['translator-last'] = true,	
	['translator-surname'] = true,
	['translator-link'] = true,
	['translator-mask'] = true,
	['trans-article'] = true,
	['trans-chapter'] = true,
	['trans-contribution'] = true,
	['trans-encyclopaedia'] = true,
	['trans-encyclopedia'] = true,
	['trans-entry'] = true,
	['trans-journal'] = true,
	['trans-magazine'] = true,
	['trans-newspaper'] = true,
	['trans-periodical'] = true,
	['trans-quote'] = true,
	['trans-section'] = true,
	['trans-title'] = true,
	['trans-website'] = true,
	['trans-work'] = true,
	['type'] = true,
	['url'] = true,
	['URL'] = true,
	['url-access'] = true,
	['url-status'] = true,
	['vauthors'] = true,
	['veditors'] = true,
	['version'] = true,
	['via'] = true,
	['volume'] = true,
	['website'] = true,
	['work'] = true,
	['year'] = true,
	['zbl'] = true,
	['ZBL'] = true,
	}

local numbered_arguments_t = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-given#'] = true,
	['author#-given'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-surname#'] = true,
	['author#-surname'] = true,
	['author-link#'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author#link'] = true,
	['author-mask#'] = true,
	['author#-mask'] = true,
	['contributor#'] = true,
	['contributor-first#'] = true,
	['contributor#-first'] = true,
	['contributor-given#'] = true,
	['contributor#-given'] = true,
	['contributor-last#'] = true,
	['contributor#-last'] = true,
	['contributor-surname#'] = true,
	['contributor#-surname'] = true,
	['contributor-link#'] = true,
	['contributor#-link'] = true,
	['contributor-mask#'] = true,
	['contributor#-mask'] = true,
	['editor#'] = true,
	['editor-first#'] = true,
	['editor#-first'] = true,
	['editor-given#'] = true,
	['editor#-given'] = true,
	['editor-last#'] = true,
	['editor#-last'] = true,
	['editor-surname#'] = true,
	['editor#-surname'] = true,
	['editor-link#'] = true,
	['editor#-link'] = true,
	['editor-mask#'] = true,
	['editor#-mask'] = true,
	['first#'] = true,
	['given#'] = true,
	['host#'] = true,
	['interviewer#'] = true,
	['interviewer-first#'] = true,
	['interviewer#-first'] = true,
	['interviewer-given#'] = true,
	['interviewer#-given'] = true,
	['interviewer-last#'] = true,
	['interviewer#-last'] = true,
	['interviewer-surname#'] = true,
	['interviewer#-surname'] = true,
	['interviewer-link#'] = true,
	['interviewer#-link'] = true,
	['interviewer-mask#'] = true,
	['interviewer#-mask'] = true,
	['last#'] = true,
	['subject#'] = true,
	['subject-first#'] = true,
	['subject#-first'] = true,
	['subject-given#'] = true,
	['subject#-given'] = true,
	['subject-last#'] = true,
	['subject#-last'] = true,
	['subject-link#'] = true,
	['subject#-link'] = true,
	['subject-mask#'] = true,
	['subject#-mask'] = true,
	['subject-surname#'] = true,
	['subject#-surname'] = true,
	['surname#'] = true,
	['translator#'] = true,
	['translator-first#'] = true,
	['translator#-first'] = true,
	['translator-given#'] = true,
	['translator#-given'] = true,
	['translator-last#'] = true,
	['translator#-last'] = true,
	['translator-surname#'] = true,
	['translator#-surname'] = true,
	['translator-link#'] = true,
	['translator#-link'] = true,
	['translator-mask#'] = true,
	['translator#-mask'] = true,
	}


--[[--------------------------&lt; P R E P R I N T   S U P P O R T E D   P A R A M E T E R S &gt;--------------------

Cite arXiv, cite biorxiv, cite citeseerx, cite medrxiv, and cite ssrn are preprint templates that use the limited
set of parameters defined in the limited_basic_arguments and limited_numbered_arguments tables.  Those lists are
supplemented with a template-specific list of parameters that are required by the particular template and may be
exclusive to one of the preprint templates.  Some of these parameters may also be available to the general cs1|2
templates.

Same conventions for true/false/tracked/nil as above.

]]

local preprint_arguments_t = {
	arxiv = {
		['arxiv'] = true,														-- cite arxiv and arxiv identifiers
		['class'] = true,
		['eprint'] = true,														-- cite arxiv and arxiv identifiers
		},
	biorxiv = {
		['biorxiv'] = true,
		},
	citeseerx = {
		['citeseerx'] = true,
		},
	medrxiv = {
		['medrxiv'] = true,
		},
	ssrn = {
		['ssrn'] = true,
		['SSRN'] = true,
		['ssrn-access'] = true,
		},
	}


--[[--------------------------&lt; L I M I T E D   S U P P O R T E D   P A R A M E T E R S &gt;----------------------

cite arxiv, cite biorxiv, cite citeseerx, cite medrxiv, and cite ssrn templates are preprint templates so are
allowed only a limited subset of parameters allowed to all other cs1|2 templates.  The limited subset is defined
here.

This list of parameters also used by {{cite document}}

Same conventions for true/false/tracked/nil as above.
	
]]

local limited_basic_arguments_t = {
	['at'] = true,
	['author'] = true,
	['author-first'] = true,
	['author-given'] = true,
	['author-last'] = true,
	['author-surname'] = true,
	['author-link'] = true,
	['authorlink'] = true,
	['author-mask'] = true,
	['collaboration'] = true,
	['date'] = true,
	['df'] = true,
	['display-authors'] = true,
	['first'] = true,
	['given'] = true,
	['language'] = true,
	['last'] = true,
	['mode'] = true,
	['name-list-style'] = true,
	['no-tracking'] = true,
	['p'] = true,
	['page'] = true,
	['pages'] = true,
	['postscript'] = true,
	['pp'] = true,
	['quotation'] = true,
	['quote'] = true,
	['ref'] = true,
	['surname'] = true,
	['template-doc-demo'] = true,
	['title'] = true,
	['trans-title'] = true,
	['vauthors'] = true,
	['year'] = true,
	}

local limited_numbered_arguments_t = {
	['author#'] = true,
	['author-first#'] = true,
	['author#-first'] = true,
	['author-given#'] = true,
	['author#-given'] = true,
	['author-last#'] = true,
	['author#-last'] = true,
	['author-surname#'] = true,
	['author#-surname'] = true,
	['author-link#'] = true,
	['author#-link'] = true,
	['authorlink#'] = true,
	['author#link'] = true,
	['author-mask#'] = true,
	['author#-mask'] = true,
	['first#'] = true,
	['given#'] = true,
	['last#'] = true,
	['surname#'] = true,
	}


--[[--------------------------&lt; U N I Q U E _ A R G U M E N T S &gt;----------------------------------------------

Some templates have unique parameters.  Those templates and their unique parameters are listed here. Keys in this
table are the template's CitationClass parameter value

Same conventions for true/false/tracked/nil as above.

]]

local unique_arguments_t = {
	['audio-visual'] = {
		['people'] = true,
		['transcript'] = true,
		['transcript-format'] = true,
		['transcript-url'] = true,
		},
	conference = {
		['book-title'] = true,
		['conference'] = true,
		['conference-format'] = true,
		['conference-url'] = true,
		['event'] = true,
		},
	episode = {
		['airdate'] = true,
		['air-date'] = true,
		['credits'] = true,
		['episode-link'] = true,												-- alias of |title-link=
		['network'] = true,
		['people'] = true,
		['season'] = true,
		['series-link'] = true,
		['series-no'] = true,
		['series-number'] = true,
		['station'] = true,
		['transcript'] = true,
		['transcript-format'] = true,
		['transcript-url'] = true,
		},
	mailinglist = {
		['mailing-list'] = true,
		},
	map = {
		['cartography'] = true,
		['inset'] = true,
		['map'] = true,
		['map-format'] = true,
		['map-url'] = true,
		['map-url-access'] = true,
		['script-map'] = true,
		['sections'] = true,
		['sheet'] = true,
		['sheets'] = true,
		['trans-map'] = true,
		},
	newsgroup = {
		['message-id'] = true,
		['newsgroup'] = true,
		},
	report = {
		['docket'] = true,
		},
	serial = {
		['airdate'] = true,
		['air-date'] = true,
		['credits'] = true,
		['episode'] = true,														-- cite serial only TODO: make available to cite episode?
		['episode-link'] = true,												-- alias of |title-link=
		['network'] = true,
		['people'] = true,
		['series-link'] = true,
		['station'] = true,
		},
	speech = {
		['conference'] = true,
		['conference-format'] = true,
		['conference-url'] = true,
		['event'] = true,
		},
	thesis = {
		['degree'] = true,
		['docket'] = true,
		},
	}


--[[--------------------------&lt; C I T E _ D O C U M E N T &gt;----------------------------------------------------

Special case for cite document.  This template takes the limited basic and limited enumerated parameters plus
others that are apply only to standalone published sources that cannot be cited any other way; no url, book,
periodical, etc parameters; limited support for name lists and named identifiers.

when validating parameters in {{cite document}} templates, the basic and 

]]

local document_arguments_t = {
	['bibcode'] = true,
	['bibcode-access'] = true,
	['doi'] = true,
	['DOI'] = true,
	['doi-access'] = true,
	['doi-broken-date'] = true,
	['hdl'] = true,
	['HDL'] = true,
	['hdl-access'] = true,
	['id'] = true,
	['ID'] = true,
	['jfm'] = true,
	['JFM'] = true,
	['lang'] = true,
	['location'] = true,
	['mr'] = true,
	['MR'] = true,
	['no-pp'] = true,
	['orig-date'] = true,
	['origyear'] = true,
	['orig-year'] = true,
	['osti'] = true,
	['OSTI'] = true,
	['osti-access'] = true,
	['place'] = true,
	['publisher'] = true,
	['quote-page'] = true,
	['quote-pages'] = true,
	['script-quote'] = true,
	['script-title'] = true,
	['title-link'] = true,
	['translator'] = true,
	['translator-first'] = true,
	['translator-given'] = true,
	['translator-last'] = true,
	['translator-surname'] = true,
	['translator-link'] = true,
	['translator-mask'] = true,
	['trans-quote'] = true,
	['type'] = true,
	['zbl'] = true,
	['ZBL'] = true,
	}

local document_numbered_arguments_t = {
	['translator#'] = true,
	['translator-first#'] = true,
	['translator#-first'] = true,
	['translator-given#'] = true,
	['translator#-given'] = true,
	['translator-last#'] = true,
	['translator#-last'] = true,
	['translator-surname#'] = true,
	['translator#-surname'] = true,
	['translator-link#'] = true,
	['translator#-link'] = true,
	['translator-mask#'] = true,
	['translator#-mask'] = true,
	}


--[[--------------------------&lt; L I S T _ C O M B I N E &gt;------------------------------------------------------

makes one table from a list of tables.  &lt;lists_t&gt; is a sequence of tables to be combined

]]

local function list_combine (lists_t)
	local out_t = {};

	for _, list_t in ipairs (lists_t) do										-- for each list in &lt;lists_t&gt;
		for k, v in pairs (list_t) do											-- extract each k/v pair
			out_t[k] = v;														-- add to &lt;out_t&gt;
		end
	end
	return out_t;																-- and done
end


--[[--------------------------&lt; T E M P L A T E _ L I S T _ G E T &gt;--------------------------------------------

gets a list of the templates from table t

]]

local function template_list_get (t)
	local out_t = {};															-- a table for output
	for k, _ in pairs (t) do													-- spin through the table and collect the keys
		table.insert (out_t, k)													-- add each key to the output table
	end
	return out_t;																-- and done
end


--[[--------------------------&lt; E X P O R T E D   T A B L E S &gt;------------------------------------------------
]]

return {
	preprint_arguments_t = preprint_arguments_t,
	preprint_template_list_t = template_list_get (preprint_arguments_t),		-- make a template list from preprint_arguments{} table
	unique_arguments_t = unique_arguments_t,
	unique_param_template_list_t = template_list_get (unique_arguments_t),		-- make a template list from unique_arguments{} table
	
	document_parameters_t = list_combine ({limited_basic_arguments_t, limited_numbered_arguments_t, document_arguments_t, document_numbered_arguments_t});
	common_parameters_t = list_combine ({basic_arguments_t, numbered_arguments_t});
	limited_parameters_t = list_combine ({limited_basic_arguments_t, limited_numbered_arguments_t});
	};</text>
      <sha1>baub5v4d976tff8ebf3konhoua4ojgu</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Citation/CS1/Date validation</title>
    <ns>828</ns>
    <id>733</id>
    <revision>
      <id>4817</id>
      <timestamp>2014-03-10T15:00:02Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Create from sandbox; not yet live;</comment>
      <origin>4817</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="17812" sha1="8nz2wlq23f1xzgen1xj3gh7eu8n9anc" xml:space="preserve">
local p = {}

-- returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct. If not a valid month, returns 0
function get_month_number (month)
local long_months = {['January']=1, ['February']=2, ['March']=3, ['April']=4, ['May']=5, ['June']=6, ['July']=7, ['August']=8, ['September']=9, ['October']=10, ['November']=11, ['December']=12};
local short_months = {['Jan']=1, ['Feb']=2, ['Mar']=3, ['Apr']=4, ['May']=5, ['Jun']=6, ['Jul']=7, ['Aug']=8, ['Sep']=9, ['Oct']=10, ['Nov']=11, ['Dec']=12};
local temp;
	temp=long_months[month];
	if temp then return temp; end				-- if month is the long-form name
	temp=short_months[month];
	if temp then return temp; end				-- if month is the short-form name
	return 0;									-- misspelled, improper case, or not a month name
end

-- returns a number according to the sequence of seasons in a year: 1 for Winter, etc.  Capitalization and spelling must be correct. If not a valid season, returns 0
function get_season_number (season)
local season_list = {['Winter']=1, ['Spring']=2, ['Summer']=3, ['Fall']=4, ['Autumn']=4}
local temp;
	temp=season_list[season];
	if temp then return temp; end				-- if season is a valid name return its number
	return 0;									-- misspelled, improper case, or not a season name
end

--returns true if month or season is valid (properly spelled, capitalized, abbreviated)
function is_valid_month_or_season (month_season)
	if 0 == get_month_number (month_season) then		-- if month text isn't one of the twelve months, might be a season
		if 0 == get_season_number (month_season) then	-- not a month, is it a season?
			return false;								-- return false not a month or one of the five seasons
		end
	end
	return true;
end


-- Function gets current year from the server and compares it to year from a citation parameter.  Years more than one year in the future are not acceptable.
function is_valid_year(year)
	if not is_set(year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;	-- global variable so we only have to fetch it once (os.date(&quot;Y&quot;) no longer works?)
	end
	return tonumber(year) &lt;= year_limit;			-- false if year is in the future more than one year
end

--[[
Returns true if day is less than or equal to the number of days in month and year is no farther into the future than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap years before 1582 and Gregorian leap years after 1582.
Where the two calendars overlap (1582 to approximately 1923) dates are assumed to be Gregorian.
]]
function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year(year) then	-- no farther into the future than next year
		return false;
	end
	
	if (2==month) then							-- if February
		month_length = 28;						-- then 28 days unless
		if 1582 &gt; tonumber(year) then			-- Julian calendar
			if 0==(year%4) then
				month_length = 29;
			end
		else									-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then	-- is a leap year?
				month_length = 29;				-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end

--[[
Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.  Similarly, seasons are also left to right, earliest to latest in time.  There is
an oddity with seasons.  Winter is assigned a value of 1, spring 2, ..., fall and autumn 4.  Because winter can follow fall/autumn at the end of a calender year, a special test
is made to see if |date=Fall-Winter yyyy (4-1) is the date.
]]

function is_valid_month_season_range(range_start, range_end)
	local range_start_number = get_month_number (range_start);
	
	if 0 == range_start_number then								-- is this a month range?
		local range_start_number = get_season_number (range_start);		-- not a month; is it a season? get start season number
		local range_end_number = get_season_number (range_end);			-- get end season number

		if 0 ~= range_start_number then							-- is start of range a season?
			if range_start_number &lt; range_end_number then		-- range_start is a season
				return true;									-- return true when range_end is also a season and follows start season; else false
			end
			if 4 == range_start_number and 1 == range_end_number then	-- special case when range is Fall-Winter or Autumn-Winter
				return true;
			end
		end
		return false;		-- range_start is not a month or a season; or range_start is a season and range_end is not; or improper season sequence
	end

	local range_end_number = get_month_number (range_end);		-- get end month number
	if range_start_number &lt; range_end_number then				-- range_start is a month; does range_start precede range_end?
		return true;											-- if yes, return true
	end
	return false;												-- range_start month number is greater than or equal to range end number; or range end isn't a month
end

--[[
Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only allowed range separator is endash.
Additionally, check the date to see that it is a real date: no 31 in 30-day months; no 29 February when not a leap year.  Months, both long-form and three
character abbreviations, and seasons must be spelled correctly. Future years beyond next year are not allowed.

If the date fails the fomat tests, this function returns false and does not return values for anchor_year and COinS_date.  When this happens, the date parameter is
used in the COinS metadata and the CITEREF identifier gets its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is date_string without anchor_year disambiguator if any
]]
function check_date (date_string)
	local year;			-- assume that year2, months, and days are not used;
	local year2=0;		-- second year in a year range
	local month=0;
	local month2=0;		-- second month in a month range
	local day=0;
	local day2=0;		-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then										-- year-initial numerical year month day format
		year, month, day=string.match(date_string, &quot;(%d%d%d%d)%-(%d%d)%-(%d%d)&quot;);
		month=tonumber(month);
		if 12 &lt; month or 1 &gt; month or 1583 &gt; tonumber(year) then return false; end			-- month number not valid or not Gregorian calendar
		anchor_year = year;

	elseif date_string:match(&quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then						-- month-initial: month day, year
		month, day, anchor_year, year=string.match(date_string, &quot;(%a+)%s*(%d%d?),%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
				
	elseif date_string:match(&quot;^%a+ +[1-9]%d?–[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year=string.match(date_string, &quot;(%a+) +(%d%d?)–(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then						-- day-initial: day month year
		day, month, anchor_year, year=string.match(date_string, &quot;(%d%d*)%s*(%a+)%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d?–[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year=string.match(date_string, &quot;(%d%d?)–(%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d? +%a+ – [1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year=date_string:match(&quot;(%d%d?) +(%a+) – (%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^%a+ +[1-9]%d? – %a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then		-- month initial month-day-range: month day – month day, year;  uses spaced endash
		month, day, month2, day2, anchor_year, year=date_string:match(&quot;(%a+) +(%d%d?) – (%a+) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^Winter +[1-9]%d%d%d–[1-9]%d%d%d%a?$&quot;) then					-- special case Winter year-year; year separated with unspaced endash
		year, anchor_year, year2=date_string:match(&quot;Winter +(%d%d%d%d)–((%d%d%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d% – %a+ +[1-9]%d%d%d%a?$&quot;) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2=date_string:match(&quot;(%a+) +(%d%d%d%d) – (%a+) +((%d%d%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end							-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		if not((0 ~= get_month_number(month) and 0 ~= get_month_number(month2)) or 			-- both must be month year or season year, not mixed
			(0 ~= get_season_number(month) and 0 ~= get_season_number(month2))) then return false; end

	elseif date_string:match (&quot;^%a+–%a+ +[1-9]%d%d%d%a?$&quot;) then								-- month/season range year; months separated by endash 
		month, month2, anchor_year, year=date_string:match (&quot;(%a+)–(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or (not is_valid_year(year)) then
			return false;
		end
		
	elseif date_string:match(&quot;^%a+ +%d%d%d%d%a?$&quot;) then							-- month/season year
		month, anchor_year, year=date_string:match(&quot;(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if not is_valid_year(year) then return false; end
		if not is_valid_month_or_season (month) then return false; end

	elseif date_string:match(&quot;^[1-9]%d%d%d?–[1-9]%d%d%d?%a?$&quot;) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2=date_string:match(&quot;(%d%d%d%d?)–((%d%d%d%d?)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d–%d%d%a?$&quot;) then						-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2=date_string:match(&quot;((%d%d)%d%d)–((%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century..year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then							-- year; here accept either YYY or YYYY
		anchor_year, year=date_string:match(&quot;((%d%d%d%d?)%a?)&quot;);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;											-- date format not one of the MOS:DATE approved formats
	end

	local result=true;											-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result=is_valid_date(year,month,day);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month2,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year2,month2,day2);
	end
	
	if false == result then return false; end
																-- if here, then date_string is valid; get coins_date from date_string (leave CITEREF disambiguator) ...
	coins_date=date_string:match(&quot;^(.+%d)%a?$&quot;);				-- last character of valid disambiguatable date is always a digit
	coins_date= mw.ustring.gsub(coins_date, &quot;–&quot;, &quot;-&quot; );			-- ... and replace any ndash with a hyphen
	
	return true, anchor_year, coins_date;						-- format is good and date string represents a real date
end	

--[[
Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.
]]

function p.dates(date_parameters_list)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local error_message =&quot;&quot;;
	local good_date=false;
	
	for k, v in pairs(date_parameters_list) do										-- for each date-holding parameter in the list
		if is_set(v) then															-- if the parameter has a value
			if v:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then								-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);						-- get the year portion so it can be tested
				if 'date'==k then
					anchor_year, COinS_date = v:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year'==k then
					good_date = is_valid_year(year);
				end
			elseif 'date'==k then													-- if the parameter is |date=
				if v:match(&quot;n%.d%.%a?&quot;) then										-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v:match(&quot;nd%a?$&quot;) then										-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v);			-- go test the date
				end
			else																	-- any other date-holding parameter
				good_date = check_date (v);											-- go test the date
			end
			if false==good_date then												-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then										-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
			end
		end
	end
--	if is_set(error_message) then
--		table.insert( z.message_tail, { seterror( 'bad_date', {error_message}, true ) } );	-- add this error message
--	end

	return anchor_year, COinS_date, error_message;		-- and done
end

return p;</text>
      <sha1>8nz2wlq23f1xzgen1xj3gh7eu8n9anc</sha1>
    </revision>
    <revision>
      <id>4818</id>
      <parentid>4817</parentid>
      <timestamp>2014-03-10T15:04:10Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <minor />
      <comment>Protected Module:Citation/CS1/Date validation: [[WP:High-risk templates|Highly visible template]] ([Edit=Allow only template editors and admins] (indefinite) [Move=Allow only template editors and admins] (indefinite))</comment>
      <origin>4817</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="17812" sha1="8nz2wlq23f1xzgen1xj3gh7eu8n9anc" xml:space="preserve">
local p = {}

-- returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct. If not a valid month, returns 0
function get_month_number (month)
local long_months = {['January']=1, ['February']=2, ['March']=3, ['April']=4, ['May']=5, ['June']=6, ['July']=7, ['August']=8, ['September']=9, ['October']=10, ['November']=11, ['December']=12};
local short_months = {['Jan']=1, ['Feb']=2, ['Mar']=3, ['Apr']=4, ['May']=5, ['Jun']=6, ['Jul']=7, ['Aug']=8, ['Sep']=9, ['Oct']=10, ['Nov']=11, ['Dec']=12};
local temp;
	temp=long_months[month];
	if temp then return temp; end				-- if month is the long-form name
	temp=short_months[month];
	if temp then return temp; end				-- if month is the short-form name
	return 0;									-- misspelled, improper case, or not a month name
end

-- returns a number according to the sequence of seasons in a year: 1 for Winter, etc.  Capitalization and spelling must be correct. If not a valid season, returns 0
function get_season_number (season)
local season_list = {['Winter']=1, ['Spring']=2, ['Summer']=3, ['Fall']=4, ['Autumn']=4}
local temp;
	temp=season_list[season];
	if temp then return temp; end				-- if season is a valid name return its number
	return 0;									-- misspelled, improper case, or not a season name
end

--returns true if month or season is valid (properly spelled, capitalized, abbreviated)
function is_valid_month_or_season (month_season)
	if 0 == get_month_number (month_season) then		-- if month text isn't one of the twelve months, might be a season
		if 0 == get_season_number (month_season) then	-- not a month, is it a season?
			return false;								-- return false not a month or one of the five seasons
		end
	end
	return true;
end


-- Function gets current year from the server and compares it to year from a citation parameter.  Years more than one year in the future are not acceptable.
function is_valid_year(year)
	if not is_set(year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;	-- global variable so we only have to fetch it once (os.date(&quot;Y&quot;) no longer works?)
	end
	return tonumber(year) &lt;= year_limit;			-- false if year is in the future more than one year
end

--[[
Returns true if day is less than or equal to the number of days in month and year is no farther into the future than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap years before 1582 and Gregorian leap years after 1582.
Where the two calendars overlap (1582 to approximately 1923) dates are assumed to be Gregorian.
]]
function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year(year) then	-- no farther into the future than next year
		return false;
	end
	
	if (2==month) then							-- if February
		month_length = 28;						-- then 28 days unless
		if 1582 &gt; tonumber(year) then			-- Julian calendar
			if 0==(year%4) then
				month_length = 29;
			end
		else									-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then	-- is a leap year?
				month_length = 29;				-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end

--[[
Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.  Similarly, seasons are also left to right, earliest to latest in time.  There is
an oddity with seasons.  Winter is assigned a value of 1, spring 2, ..., fall and autumn 4.  Because winter can follow fall/autumn at the end of a calender year, a special test
is made to see if |date=Fall-Winter yyyy (4-1) is the date.
]]

function is_valid_month_season_range(range_start, range_end)
	local range_start_number = get_month_number (range_start);
	
	if 0 == range_start_number then								-- is this a month range?
		local range_start_number = get_season_number (range_start);		-- not a month; is it a season? get start season number
		local range_end_number = get_season_number (range_end);			-- get end season number

		if 0 ~= range_start_number then							-- is start of range a season?
			if range_start_number &lt; range_end_number then		-- range_start is a season
				return true;									-- return true when range_end is also a season and follows start season; else false
			end
			if 4 == range_start_number and 1 == range_end_number then	-- special case when range is Fall-Winter or Autumn-Winter
				return true;
			end
		end
		return false;		-- range_start is not a month or a season; or range_start is a season and range_end is not; or improper season sequence
	end

	local range_end_number = get_month_number (range_end);		-- get end month number
	if range_start_number &lt; range_end_number then				-- range_start is a month; does range_start precede range_end?
		return true;											-- if yes, return true
	end
	return false;												-- range_start month number is greater than or equal to range end number; or range end isn't a month
end

--[[
Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only allowed range separator is endash.
Additionally, check the date to see that it is a real date: no 31 in 30-day months; no 29 February when not a leap year.  Months, both long-form and three
character abbreviations, and seasons must be spelled correctly. Future years beyond next year are not allowed.

If the date fails the fomat tests, this function returns false and does not return values for anchor_year and COinS_date.  When this happens, the date parameter is
used in the COinS metadata and the CITEREF identifier gets its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is date_string without anchor_year disambiguator if any
]]
function check_date (date_string)
	local year;			-- assume that year2, months, and days are not used;
	local year2=0;		-- second year in a year range
	local month=0;
	local month2=0;		-- second month in a month range
	local day=0;
	local day2=0;		-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then										-- year-initial numerical year month day format
		year, month, day=string.match(date_string, &quot;(%d%d%d%d)%-(%d%d)%-(%d%d)&quot;);
		month=tonumber(month);
		if 12 &lt; month or 1 &gt; month or 1583 &gt; tonumber(year) then return false; end			-- month number not valid or not Gregorian calendar
		anchor_year = year;

	elseif date_string:match(&quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then						-- month-initial: month day, year
		month, day, anchor_year, year=string.match(date_string, &quot;(%a+)%s*(%d%d?),%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
				
	elseif date_string:match(&quot;^%a+ +[1-9]%d?–[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year=string.match(date_string, &quot;(%a+) +(%d%d?)–(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then						-- day-initial: day month year
		day, month, anchor_year, year=string.match(date_string, &quot;(%d%d*)%s*(%a+)%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d?–[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year=string.match(date_string, &quot;(%d%d?)–(%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d? +%a+ – [1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year=date_string:match(&quot;(%d%d?) +(%a+) – (%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^%a+ +[1-9]%d? – %a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then		-- month initial month-day-range: month day – month day, year;  uses spaced endash
		month, day, month2, day2, anchor_year, year=date_string:match(&quot;(%a+) +(%d%d?) – (%a+) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^Winter +[1-9]%d%d%d–[1-9]%d%d%d%a?$&quot;) then					-- special case Winter year-year; year separated with unspaced endash
		year, anchor_year, year2=date_string:match(&quot;Winter +(%d%d%d%d)–((%d%d%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d% – %a+ +[1-9]%d%d%d%a?$&quot;) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2=date_string:match(&quot;(%a+) +(%d%d%d%d) – (%a+) +((%d%d%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end							-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		if not((0 ~= get_month_number(month) and 0 ~= get_month_number(month2)) or 			-- both must be month year or season year, not mixed
			(0 ~= get_season_number(month) and 0 ~= get_season_number(month2))) then return false; end

	elseif date_string:match (&quot;^%a+–%a+ +[1-9]%d%d%d%a?$&quot;) then								-- month/season range year; months separated by endash 
		month, month2, anchor_year, year=date_string:match (&quot;(%a+)–(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or (not is_valid_year(year)) then
			return false;
		end
		
	elseif date_string:match(&quot;^%a+ +%d%d%d%d%a?$&quot;) then							-- month/season year
		month, anchor_year, year=date_string:match(&quot;(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if not is_valid_year(year) then return false; end
		if not is_valid_month_or_season (month) then return false; end

	elseif date_string:match(&quot;^[1-9]%d%d%d?–[1-9]%d%d%d?%a?$&quot;) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2=date_string:match(&quot;(%d%d%d%d?)–((%d%d%d%d?)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d–%d%d%a?$&quot;) then						-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2=date_string:match(&quot;((%d%d)%d%d)–((%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century..year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then							-- year; here accept either YYY or YYYY
		anchor_year, year=date_string:match(&quot;((%d%d%d%d?)%a?)&quot;);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;											-- date format not one of the MOS:DATE approved formats
	end

	local result=true;											-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result=is_valid_date(year,month,day);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month2,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year2,month2,day2);
	end
	
	if false == result then return false; end
																-- if here, then date_string is valid; get coins_date from date_string (leave CITEREF disambiguator) ...
	coins_date=date_string:match(&quot;^(.+%d)%a?$&quot;);				-- last character of valid disambiguatable date is always a digit
	coins_date= mw.ustring.gsub(coins_date, &quot;–&quot;, &quot;-&quot; );			-- ... and replace any ndash with a hyphen
	
	return true, anchor_year, coins_date;						-- format is good and date string represents a real date
end	

--[[
Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.
]]

function p.dates(date_parameters_list)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local error_message =&quot;&quot;;
	local good_date=false;
	
	for k, v in pairs(date_parameters_list) do										-- for each date-holding parameter in the list
		if is_set(v) then															-- if the parameter has a value
			if v:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then								-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);						-- get the year portion so it can be tested
				if 'date'==k then
					anchor_year, COinS_date = v:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year'==k then
					good_date = is_valid_year(year);
				end
			elseif 'date'==k then													-- if the parameter is |date=
				if v:match(&quot;n%.d%.%a?&quot;) then										-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v:match(&quot;nd%a?$&quot;) then										-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v);			-- go test the date
				end
			else																	-- any other date-holding parameter
				good_date = check_date (v);											-- go test the date
			end
			if false==good_date then												-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then										-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
			end
		end
	end
--	if is_set(error_message) then
--		table.insert( z.message_tail, { seterror( 'bad_date', {error_message}, true ) } );	-- add this error message
--	end

	return anchor_year, COinS_date, error_message;		-- and done
end

return p;</text>
      <sha1>8nz2wlq23f1xzgen1xj3gh7eu8n9anc</sha1>
    </revision>
    <revision>
      <id>4819</id>
      <parentid>4818</parentid>
      <timestamp>2014-03-30T12:22:02Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4819</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="17659" sha1="jegwhfcwt416y3s3k7d602df7yqkbtr" xml:space="preserve">
local p = {}

-- returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct. If not a valid month, returns 0
function get_month_number (month)
local long_months = {['January']=1, ['February']=2, ['March']=3, ['April']=4, ['May']=5, ['June']=6, ['July']=7, ['August']=8, ['September']=9, ['October']=10, ['November']=11, ['December']=12};
local short_months = {['Jan']=1, ['Feb']=2, ['Mar']=3, ['Apr']=4, ['May']=5, ['Jun']=6, ['Jul']=7, ['Aug']=8, ['Sep']=9, ['Oct']=10, ['Nov']=11, ['Dec']=12};
local temp;
	temp=long_months[month];
	if temp then return temp; end				-- if month is the long-form name
	temp=short_months[month];
	if temp then return temp; end				-- if month is the short-form name
	return 0;									-- misspelled, improper case, or not a month name
end

-- returns a number according to the sequence of seasons in a year: 1 for Winter, etc.  Capitalization and spelling must be correct. If not a valid season, returns 0
function get_season_number (season)
local season_list = {['Winter']=1, ['Spring']=2, ['Summer']=3, ['Fall']=4, ['Autumn']=4}
local temp;
	temp=season_list[season];
	if temp then return temp; end				-- if season is a valid name return its number
	return 0;									-- misspelled, improper case, or not a season name
end

--returns true if month or season is valid (properly spelled, capitalized, abbreviated)
function is_valid_month_or_season (month_season)
	if 0 == get_month_number (month_season) then		-- if month text isn't one of the twelve months, might be a season
		if 0 == get_season_number (month_season) then	-- not a month, is it a season?
			return false;								-- return false not a month or one of the five seasons
		end
	end
	return true;
end


-- Function gets current year from the server and compares it to year from a citation parameter.  Years more than one year in the future are not acceptable.
function is_valid_year(year)
	if not is_set(year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;	-- global variable so we only have to fetch it once (os.date(&quot;Y&quot;) no longer works?)
	end
	return tonumber(year) &lt;= year_limit;			-- false if year is in the future more than one year
end

--[[
Returns true if day is less than or equal to the number of days in month and year is no farther into the future than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap years before 1582 and Gregorian leap years after 1582.
Where the two calendars overlap (1582 to approximately 1923) dates are assumed to be Gregorian.
]]
function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year(year) then	-- no farther into the future than next year
		return false;
	end
	
	if (2==month) then							-- if February
		month_length = 28;						-- then 28 days unless
		if 1582 &gt; tonumber(year) then			-- Julian calendar
			if 0==(year%4) then
				month_length = 29;
			end
		else									-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then	-- is a leap year?
				month_length = 29;				-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end

--[[
Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.  Similarly, seasons are also left to right, earliest to latest in time.  There is
an oddity with seasons.  Winter is assigned a value of 1, spring 2, ..., fall and autumn 4.  Because winter can follow fall/autumn at the end of a calender year, a special test
is made to see if |date=Fall-Winter yyyy (4-1) is the date.
]]

function is_valid_month_season_range(range_start, range_end)
	local range_start_number = get_month_number (range_start);
	
	if 0 == range_start_number then								-- is this a month range?
		local range_start_number = get_season_number (range_start);		-- not a month; is it a season? get start season number
		local range_end_number = get_season_number (range_end);			-- get end season number

		if 0 ~= range_start_number then							-- is start of range a season?
			if range_start_number &lt; range_end_number then		-- range_start is a season
				return true;									-- return true when range_end is also a season and follows start season; else false
			end
			if 4 == range_start_number and 1 == range_end_number then	-- special case when range is Fall-Winter or Autumn-Winter
				return true;
			end
		end
		return false;		-- range_start is not a month or a season; or range_start is a season and range_end is not; or improper season sequence
	end

	local range_end_number = get_month_number (range_end);		-- get end month number
	if range_start_number &lt; range_end_number then				-- range_start is a month; does range_start precede range_end?
		return true;											-- if yes, return true
	end
	return false;												-- range_start month number is greater than or equal to range end number; or range end isn't a month
end

--[[
Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only allowed range separator is endash.
Additionally, check the date to see that it is a real date: no 31 in 30-day months; no 29 February when not a leap year.  Months, both long-form and three
character abbreviations, and seasons must be spelled correctly. Future years beyond next year are not allowed.

If the date fails the fomat tests, this function returns false and does not return values for anchor_year and COinS_date.  When this happens, the date parameter is
used in the COinS metadata and the CITEREF identifier gets its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is date_string without anchor_year disambiguator if any
]]
function check_date (date_string)
	local year;			-- assume that year2, months, and days are not used;
	local year2=0;		-- second year in a year range
	local month=0;
	local month2=0;		-- second month in a month range
	local day=0;
	local day2=0;		-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then										-- year-initial numerical year month day format
		year, month, day=string.match(date_string, &quot;(%d%d%d%d)%-(%d%d)%-(%d%d)&quot;);
		month=tonumber(month);
		if 12 &lt; month or 1 &gt; month or 1583 &gt; tonumber(year) then return false; end			-- month number not valid or not Gregorian calendar
		anchor_year = year;

	elseif date_string:match(&quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then						-- month-initial: month day, year
		month, day, anchor_year, year=string.match(date_string, &quot;(%a+)%s*(%d%d?),%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
				
	elseif date_string:match(&quot;^%a+ +[1-9]%d?–[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year=string.match(date_string, &quot;(%a+) +(%d%d?)–(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then						-- day-initial: day month year
		day, month, anchor_year, year=string.match(date_string, &quot;(%d%d*)%s*(%a+)%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d?–[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year=string.match(date_string, &quot;(%d%d?)–(%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d? +%a+ – [1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year=date_string:match(&quot;(%d%d?) +(%a+) – (%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^%a+ +[1-9]%d? – %a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then		-- month initial month-day-range: month day – month day, year;  uses spaced endash
		month, day, month2, day2, anchor_year, year=date_string:match(&quot;(%a+) +(%d%d?) – (%a+) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^Winter +[1-9]%d%d%d–[1-9]%d%d%d%a?$&quot;) then					-- special case Winter year-year; year separated with unspaced endash
		year, anchor_year, year2=date_string:match(&quot;Winter +(%d%d%d%d)–((%d%d%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d% – %a+ +[1-9]%d%d%d%a?$&quot;) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2=date_string:match(&quot;(%a+) +(%d%d%d%d) – (%a+) +((%d%d%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end							-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		if not((0 ~= get_month_number(month) and 0 ~= get_month_number(month2)) or 			-- both must be month year or season year, not mixed
			(0 ~= get_season_number(month) and 0 ~= get_season_number(month2))) then return false; end

	elseif date_string:match (&quot;^%a+–%a+ +[1-9]%d%d%d%a?$&quot;) then								-- month/season range year; months separated by endash 
		month, month2, anchor_year, year=date_string:match (&quot;(%a+)–(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or (not is_valid_year(year)) then
			return false;
		end
		
	elseif date_string:match(&quot;^%a+ +%d%d%d%d%a?$&quot;) then							-- month/season year
		month, anchor_year, year=date_string:match(&quot;(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if not is_valid_year(year) then return false; end
		if not is_valid_month_or_season (month) then return false; end

	elseif date_string:match(&quot;^[1-9]%d%d%d?–[1-9]%d%d%d?%a?$&quot;) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2=date_string:match(&quot;(%d%d%d%d?)–((%d%d%d%d?)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d–%d%d%a?$&quot;) then						-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2=date_string:match(&quot;((%d%d)%d%d)–((%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century..year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then							-- year; here accept either YYY or YYYY
		anchor_year, year=date_string:match(&quot;((%d%d%d%d?)%a?)&quot;);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;											-- date format not one of the MOS:DATE approved formats
	end

	local result=true;											-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result=is_valid_date(year,month,day);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month2,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year2,month2,day2);
	end
	
	if false == result then return false; end
																-- if here, then date_string is valid; get coins_date from date_string (leave CITEREF disambiguator) ...
	coins_date=date_string:match(&quot;^(.+%d)%a?$&quot;);				-- last character of valid disambiguatable date is always a digit
	coins_date= mw.ustring.gsub(coins_date, &quot;–&quot;, &quot;-&quot; );			-- ... and replace any ndash with a hyphen
	
	return true, anchor_year, coins_date;						-- format is good and date string represents a real date
end	

--[[
Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.
]]

function p.dates(date_parameters_list)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local error_message =&quot;&quot;;
	local good_date=false;
	
	for k, v in pairs(date_parameters_list) do										-- for each date-holding parameter in the list
		if is_set(v) then															-- if the parameter has a value
			if v:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then								-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);						-- get the year portion so it can be tested
				if 'date'==k then
					anchor_year, COinS_date = v:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year'==k then
					good_date = is_valid_year(year);
				end
			elseif 'date'==k then													-- if the parameter is |date=
				if v:match(&quot;n%.d%.%a?&quot;) then										-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v:match(&quot;nd%a?$&quot;) then										-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v);			-- go test the date
				end
			else																	-- any other date-holding parameter
				good_date = check_date (v);											-- go test the date
			end
			if false==good_date then												-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then										-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
			end
		end
	end

	return anchor_year, COinS_date, error_message;		-- and done
end

return p;</text>
      <sha1>jegwhfcwt416y3s3k7d602df7yqkbtr</sha1>
    </revision>
    <revision>
      <id>4820</id>
      <parentid>4819</parentid>
      <timestamp>2014-08-24T10:58:50Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4820</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="19624" sha1="a211cvgxj3ept1dvp5exqptfobllb0v" xml:space="preserve">
local p = {}

-- returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct. If not a valid month, returns 0
function get_month_number (month)
local long_months = {['January']=1, ['February']=2, ['March']=3, ['April']=4, ['May']=5, ['June']=6, ['July']=7, ['August']=8, ['September']=9, ['October']=10, ['November']=11, ['December']=12};
local short_months = {['Jan']=1, ['Feb']=2, ['Mar']=3, ['Apr']=4, ['May']=5, ['Jun']=6, ['Jul']=7, ['Aug']=8, ['Sep']=9, ['Oct']=10, ['Nov']=11, ['Dec']=12};
local temp;
	temp=long_months[month];
	if temp then return temp; end				-- if month is the long-form name
	temp=short_months[month];
	if temp then return temp; end				-- if month is the short-form name
	return 0;									-- misspelled, improper case, or not a month name
end

-- returns a number according to the sequence of seasons in a year: 1 for Winter, etc.  Capitalization and spelling must be correct. If not a valid season, returns 0
function get_season_number (season)
local season_list = {['Winter']=1, ['Spring']=2, ['Summer']=3, ['Fall']=4, ['Autumn']=4}
local temp;
	temp=season_list[season];
	if temp then return temp; end				-- if season is a valid name return its number
	return 0;									-- misspelled, improper case, or not a season name
end

--returns true if month or season is valid (properly spelled, capitalized, abbreviated)
function is_valid_month_or_season (month_season)
	if 0 == get_month_number (month_season) then		-- if month text isn't one of the twelve months, might be a season
		if 0 == get_season_number (month_season) then	-- not a month, is it a season?
			return false;								-- return false not a month or one of the five seasons
		end
	end
	return true;
end


-- Function gets current year from the server and compares it to year from a citation parameter.  Years more than one year in the future are not acceptable.
function is_valid_year(year)
	if not is_set(year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;	-- global variable so we only have to fetch it once (os.date(&quot;Y&quot;) no longer works?)
	end
	return tonumber(year) &lt;= year_limit;			-- false if year is in the future more than one year
end

--[[
Returns true if day is less than or equal to the number of days in month and year is no farther into the future than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap years before 1582 and Gregorian leap years after 1582.
Where the two calendars overlap (1582 to approximately 1923) dates are assumed to be Gregorian.
]]
function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year(year) then	-- no farther into the future than next year
		return false;
	end
	
	if (2==month) then							-- if February
		month_length = 28;						-- then 28 days unless
		if 1582 &gt; tonumber(year) then			-- Julian calendar
			if 0==(year%4) then
				month_length = 29;
			end
		else									-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then	-- is a leap year?
				month_length = 29;				-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end

--[[
Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.  Similarly, seasons are also left to right, earliest to latest in time.  There is
an oddity with seasons.  Winter is assigned a value of 1, spring 2, ..., fall and autumn 4.  Because winter can follow fall/autumn at the end of a calender year, a special test
is made to see if |date=Fall-Winter yyyy (4-1) is the date.
]]

function is_valid_month_season_range(range_start, range_end)
	local range_start_number = get_month_number (range_start);
	
	if 0 == range_start_number then								-- is this a month range?
		local range_start_number = get_season_number (range_start);		-- not a month; is it a season? get start season number
		local range_end_number = get_season_number (range_end);			-- get end season number

		if 0 ~= range_start_number then							-- is start of range a season?
			if range_start_number &lt; range_end_number then		-- range_start is a season
				return true;									-- return true when range_end is also a season and follows start season; else false
			end
			if 4 == range_start_number and 1 == range_end_number then	-- special case when range is Fall-Winter or Autumn-Winter
				return true;
			end
		end
		return false;		-- range_start is not a month or a season; or range_start is a season and range_end is not; or improper season sequence
	end

	local range_end_number = get_month_number (range_end);		-- get end month number
	if range_start_number &lt; range_end_number then				-- range_start is a month; does range_start precede range_end?
		return true;											-- if yes, return true
	end
	return false;												-- range_start month number is greater than or equal to range end number; or range end isn't a month
end

--[[
Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only allowed range separator is endash.
Additionally, check the date to see that it is a real date: no 31 in 30-day months; no 29 February when not a leap year.  Months, both long-form and three
character abbreviations, and seasons must be spelled correctly. Future years beyond next year are not allowed.

If the date fails the fomat tests, this function returns false and does not return values for anchor_year and COinS_date.  When this happens, the date parameter is
used in the COinS metadata and the CITEREF identifier gets its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is date_string without anchor_year disambiguator if any
]]
function check_date (date_string)
	local year;			-- assume that year2, months, and days are not used;
	local year2=0;		-- second year in a year range
	local month=0;
	local month2=0;		-- second month in a month range
	local day=0;
	local day2=0;		-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then										-- year-initial numerical year month day format
		year, month, day=string.match(date_string, &quot;(%d%d%d%d)%-(%d%d)%-(%d%d)&quot;);
		month=tonumber(month);
		if 12 &lt; month or 1 &gt; month or 1583 &gt; tonumber(year) then return false; end			-- month number not valid or not Gregorian calendar
		anchor_year = year;

	elseif date_string:match(&quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then						-- month-initial: month day, year
		month, day, anchor_year, year=string.match(date_string, &quot;(%a+)%s*(%d%d?),%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
				
	elseif date_string:match(&quot;^%a+ +[1-9]%d?–[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year=string.match(date_string, &quot;(%a+) +(%d%d?)–(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then						-- day-initial: day month year
		day, month, anchor_year, year=string.match(date_string, &quot;(%d%d*)%s*(%a+)%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d?–[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year=string.match(date_string, &quot;(%d%d?)–(%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d? +%a+ – [1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year=date_string:match(&quot;(%d%d?) +(%a+) – (%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^%a+ +[1-9]%d? – %a+ +[1-9]%d?, +[1-9]%d%d%d?%a?$&quot;) then		-- month initial month-day-range: month day – month day, year;  uses spaced endash
		month, day, month2, day2, anchor_year, year=date_string:match(&quot;(%a+) +(%d%d?) – (%a+) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^[1-9]%d? +%a+ +[1-9]%d%d%d – [1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2=date_string:match(&quot;(%d%d?) +(%a+) +(%d%d%d%d?) – (%d%d?) +(%a+) +((%d%d%d%d?)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end							-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- year2 no more than one year in the future
		month = get_month_number (month);
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d – %a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then		-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
		month, day, year, month2, day2, anchor_year, year2=date_string:match(&quot;(%a+) +(%d%d?), +(%d%d%d%d) – (%a+) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end							-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- year2 no more than one year in the future
		month = get_month_number (month);
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^Winter +[1-9]%d%d%d–%d%d%a?$&quot;) then							-- special case Winter year-year (YYYY-YY); year separated with unspaced endash
		local century;
		year, century, anchor_year, year2=date_string:match(&quot;Winter +((%d%d)%d%d)–((%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		year2 = century..year2;																-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year

	elseif date_string:match(&quot;^Winter +[1-9]%d%d%d–[1-9]%d%d%d%a?$&quot;) then					-- special case Winter year-year; year separated with unspaced endash
		year, anchor_year, year2=date_string:match(&quot;Winter +(%d%d%d%d)–((%d%d%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d% – %a+ +[1-9]%d%d%d%a?$&quot;) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2=date_string:match(&quot;(%a+) +(%d%d%d%d) – (%a+) +((%d%d%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end							-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		if not((0 ~= get_month_number(month) and 0 ~= get_month_number(month2)) or 			-- both must be month year or season year, not mixed
			(0 ~= get_season_number(month) and 0 ~= get_season_number(month2))) then return false; end

	elseif date_string:match (&quot;^%a+–%a+ +[1-9]%d%d%d%a?$&quot;) then								-- month/season range year; months separated by endash 
		month, month2, anchor_year, year=date_string:match (&quot;(%a+)–(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or (not is_valid_year(year)) then
			return false;
		end
		
	elseif date_string:match(&quot;^%a+ +%d%d%d%d%a?$&quot;) then							-- month/season year
		month, anchor_year, year=date_string:match(&quot;(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if not is_valid_year(year) then return false; end
		if not is_valid_month_or_season (month) then return false; end

	elseif date_string:match(&quot;^[1-9]%d%d%d?–[1-9]%d%d%d?%a?$&quot;) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2=date_string:match(&quot;(%d%d%d%d?)–((%d%d%d%d?)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d–%d%d%a?$&quot;) then						-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2=date_string:match(&quot;((%d%d)%d%d)–((%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century..year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then							-- year; here accept either YYY or YYYY
		anchor_year, year=date_string:match(&quot;((%d%d%d%d?)%a?)&quot;);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;											-- date format not one of the MOS:DATE approved formats
	end

	local result=true;											-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result=is_valid_date(year,month,day);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month2,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year2,month2,day2);
	end
	
	if false == result then return false; end
																-- if here, then date_string is valid; get coins_date from date_string (leave CITEREF disambiguator) ...
	coins_date=date_string:match(&quot;^(.+%d)%a?$&quot;);				-- last character of valid disambiguatable date is always a digit
	coins_date= mw.ustring.gsub(coins_date, &quot;–&quot;, &quot;-&quot; );			-- ... and replace any ndash with a hyphen
	
	return true, anchor_year, coins_date;						-- format is good and date string represents a real date
end	

--[[
Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.
]]

function p.dates(date_parameters_list)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local error_message =&quot;&quot;;
	local good_date=false;
	
	for k, v in pairs(date_parameters_list) do										-- for each date-holding parameter in the list
		if is_set(v) then															-- if the parameter has a value
			if v:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then								-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);						-- get the year portion so it can be tested
				if 'date'==k then
					anchor_year, COinS_date = v:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year'==k then
					good_date = is_valid_year(year);
				end
			elseif 'date'==k then													-- if the parameter is |date=
				if v:match(&quot;n%.d%.%a?&quot;) then										-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v:match(&quot;nd%a?$&quot;) then										-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v);			-- go test the date
				end
			else																	-- any other date-holding parameter
				good_date = check_date (v);											-- go test the date
			end
			if false==good_date then												-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then										-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
			end
		end
	end

	return anchor_year, COinS_date, error_message;		-- and done
end

return p;</text>
      <sha1>a211cvgxj3ept1dvp5exqptfobllb0v</sha1>
    </revision>
    <revision>
      <id>4821</id>
      <parentid>4820</parentid>
      <timestamp>2014-10-11T12:13:12Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4821</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="19916" sha1="ivndrn38r4ruk4mi8y4b639wc6p12w2" xml:space="preserve">
local p = {}

-- returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct. If not a valid month, returns 0
function get_month_number (month)
local long_months = {['January']=1, ['February']=2, ['March']=3, ['April']=4, ['May']=5, ['June']=6, ['July']=7, ['August']=8, ['September']=9, ['October']=10, ['November']=11, ['December']=12};
local short_months = {['Jan']=1, ['Feb']=2, ['Mar']=3, ['Apr']=4, ['May']=5, ['Jun']=6, ['Jul']=7, ['Aug']=8, ['Sep']=9, ['Oct']=10, ['Nov']=11, ['Dec']=12};
local temp;
	temp=long_months[month];
	if temp then return temp; end				-- if month is the long-form name
	temp=short_months[month];
	if temp then return temp; end				-- if month is the short-form name
	return 0;									-- misspelled, improper case, or not a month name
end

-- returns a number according to the sequence of seasons in a year: 1 for Winter, etc.  Capitalization and spelling must be correct. If not a valid season, returns 0
function get_season_number (season)
local season_list = {['Winter']=1, ['Spring']=2, ['Summer']=3, ['Fall']=4, ['Autumn']=4}
local temp;
	temp=season_list[season];
	if temp then return temp; end				-- if season is a valid name return its number
	return 0;									-- misspelled, improper case, or not a season name
end

--returns true if month or season is valid (properly spelled, capitalized, abbreviated)
function is_valid_month_or_season (month_season)
	if 0 == get_month_number (month_season) then		-- if month text isn't one of the twelve months, might be a season
		if 0 == get_season_number (month_season) then	-- not a month, is it a season?
			return false;								-- return false not a month or one of the five seasons
		end
	end
	return true;
end


-- Function gets current year from the server and compares it to year from a citation parameter.  Years more than one year in the future are not acceptable.
function is_valid_year(year)
	if not is_set(year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;	-- global variable so we only have to fetch it once (os.date(&quot;Y&quot;) no longer works?)
	end
	return tonumber(year) &lt;= year_limit;			-- false if year is in the future more than one year
end

--[[
Returns true if day is less than or equal to the number of days in month and year is no farther into the future than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap years before 1582 and Gregorian leap years after 1582.
Where the two calendars overlap (1582 to approximately 1923) dates are assumed to be Gregorian.
]]
function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year(year) then	-- no farther into the future than next year
		return false;
	end
	
	if (2==month) then							-- if February
		month_length = 28;						-- then 28 days unless
		if 1582 &gt; tonumber(year) then			-- Julian calendar
			if 0==(year%4) then
				month_length = 29;
			end
		else									-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then	-- is a leap year?
				month_length = 29;				-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end

--[[
Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.  Similarly, seasons are also left to right, earliest to latest in time.  There is
an oddity with seasons.  Winter is assigned a value of 1, spring 2, ..., fall and autumn 4.  Because winter can follow fall/autumn at the end of a calender year, a special test
is made to see if |date=Fall-Winter yyyy (4-1) is the date.
]]

function is_valid_month_season_range(range_start, range_end)
	local range_start_number = get_month_number (range_start);
	
	if 0 == range_start_number then								-- is this a month range?
		local range_start_number = get_season_number (range_start);		-- not a month; is it a season? get start season number
		local range_end_number = get_season_number (range_end);			-- get end season number

		if 0 ~= range_start_number then							-- is start of range a season?
			if range_start_number &lt; range_end_number then		-- range_start is a season
				return true;									-- return true when range_end is also a season and follows start season; else false
			end
			if 4 == range_start_number and 1 == range_end_number then	-- special case when range is Fall-Winter or Autumn-Winter
				return true;
			end
		end
		return false;		-- range_start is not a month or a season; or range_start is a season and range_end is not; or improper season sequence
	end

	local range_end_number = get_month_number (range_end);		-- get end month number
	if range_start_number &lt; range_end_number then				-- range_start is a month; does range_start precede range_end?
		return true;											-- if yes, return true
	end
	return false;												-- range_start month number is greater than or equal to range end number; or range end isn't a month
end

--[[
Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only allowed range separator is endash.
Additionally, check the date to see that it is a real date: no 31 in 30-day months; no 29 February when not a leap year.  Months, both long-form and three
character abbreviations, and seasons must be spelled correctly. Future years beyond next year are not allowed.

If the date fails the fomat tests, this function returns false and does not return values for anchor_year and COinS_date.  When this happens, the date parameter is
used in the COinS metadata and the CITEREF identifier gets its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is date_string without anchor_year disambiguator if any
]]
function check_date (date_string)
	local year;			-- assume that year2, months, and days are not used;
	local year2=0;		-- second year in a year range
	local month=0;
	local month2=0;		-- second month in a month range
	local day=0;
	local day2=0;		-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then										-- year-initial numerical year month day format
		year, month, day=string.match(date_string, &quot;(%d%d%d%d)%-(%d%d)%-(%d%d)&quot;);
		month=tonumber(month);
		if 12 &lt; month or 1 &gt; month or 1583 &gt; tonumber(year) then return false; end			-- month number not valid or not Gregorian calendar
		anchor_year = year;

	elseif date_string:match(&quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then						-- month-initial: month day, year
		month, day, anchor_year, year=string.match(date_string, &quot;(%a+)%s*(%d%d?),%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
				
	elseif date_string:match(&quot;^%a+ +[1-9]%d?–[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year=string.match(date_string, &quot;(%a+) +(%d%d?)–(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then						-- day-initial: day month year
		day, month, anchor_year, year=string.match(date_string, &quot;(%d%d*)%s*(%a+)%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d?–[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year=string.match(date_string, &quot;(%d%d?)–(%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d? +%a+ – [1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year=date_string:match(&quot;(%d%d?) +(%a+) – (%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^%a+ +[1-9]%d? – %a+ +[1-9]%d?, +[1-9]%d%d%d?%a?$&quot;) then		-- month initial month-day-range: month day – month day, year;  uses spaced endash
		month, day, month2, day2, anchor_year, year=date_string:match(&quot;(%a+) +(%d%d?) – (%a+) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^[1-9]%d? +%a+ +[1-9]%d%d%d – [1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2=date_string:match(&quot;(%d%d?) +(%a+) +(%d%d%d%d?) – (%d%d?) +(%a+) +((%d%d%d%d?)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end							-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- year2 no more than one year in the future
		month = get_month_number (month);
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d – %a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then		-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
		month, day, year, month2, day2, anchor_year, year2=date_string:match(&quot;(%a+) +(%d%d?), +(%d%d%d%d) – (%a+) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end							-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- year2 no more than one year in the future
		month = get_month_number (month);
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d–%d%d%a?$&quot;) then								-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		if nil == date_string:match(&quot;^Winter&quot;) and nil == date_string:match(&quot;^Summer&quot;) then return false end;	-- 'month' can only be Winter or Summer
		local century;
		year, century, anchor_year, year2=date_string:match(&quot;%a+ +((%d%d)%d%d)–((%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		year2 = century..year2;																-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d–[1-9]%d%d%d%a?$&quot;) then						-- special case Winter/Summer year-year; year separated with unspaced endash
		if nil == date_string:match(&quot;^Winter&quot;) and nil == date_string:match(&quot;^Summer&quot;) then return false end;	-- 'month' can only be Winter or Summer
		year, anchor_year, year2=date_string:match(&quot;%a+ +(%d%d%d%d)–((%d%d%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d% – %a+ +[1-9]%d%d%d%a?$&quot;) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2=date_string:match(&quot;(%a+) +(%d%d%d%d) – (%a+) +((%d%d%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end							-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		if not((0 ~= get_month_number(month) and 0 ~= get_month_number(month2)) or 			-- both must be month year or season year, not mixed
			(0 ~= get_season_number(month) and 0 ~= get_season_number(month2))) then return false; end

	elseif date_string:match (&quot;^%a+–%a+ +[1-9]%d%d%d%a?$&quot;) then								-- month/season range year; months separated by endash 
		month, month2, anchor_year, year=date_string:match (&quot;(%a+)–(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or (not is_valid_year(year)) then
			return false;
		end
		
	elseif date_string:match(&quot;^%a+ +%d%d%d%d%a?$&quot;) then							-- month/season year
		month, anchor_year, year=date_string:match(&quot;(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if not is_valid_year(year) then return false; end
		if not is_valid_month_or_season (month) then return false; end

	elseif date_string:match(&quot;^[1-9]%d%d%d?–[1-9]%d%d%d?%a?$&quot;) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2=date_string:match(&quot;(%d%d%d%d?)–((%d%d%d%d?)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d–%d%d%a?$&quot;) then						-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2=date_string:match(&quot;((%d%d)%d%d)–((%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century..year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then							-- year; here accept either YYY or YYYY
		anchor_year, year=date_string:match(&quot;((%d%d%d%d?)%a?)&quot;);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;											-- date format not one of the MOS:DATE approved formats
	end

	local result=true;											-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result=is_valid_date(year,month,day);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month2,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year2,month2,day2);
	end
	
	if false == result then return false; end
																-- if here, then date_string is valid; get coins_date from date_string (leave CITEREF disambiguator) ...
	coins_date=date_string:match(&quot;^(.+%d)%a?$&quot;);				-- last character of valid disambiguatable date is always a digit
	coins_date= mw.ustring.gsub(coins_date, &quot;–&quot;, &quot;-&quot; );			-- ... and replace any ndash with a hyphen
	
	return true, anchor_year, coins_date;						-- format is good and date string represents a real date
end	

--[[
Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.
]]

function p.dates(date_parameters_list)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local error_message =&quot;&quot;;
	local good_date=false;
	
	for k, v in pairs(date_parameters_list) do										-- for each date-holding parameter in the list
		if is_set(v) then															-- if the parameter has a value
			if v:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then								-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);						-- get the year portion so it can be tested
				if 'date'==k then
					anchor_year, COinS_date = v:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year'==k then
					good_date = is_valid_year(year);
				end
			elseif 'date'==k then													-- if the parameter is |date=
				if v:match(&quot;n%.d%.%a?&quot;) then										-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v:match(&quot;nd%a?$&quot;) then										-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v);			-- go test the date
				end
			else																	-- any other date-holding parameter
				good_date = check_date (v);											-- go test the date
			end
			if false==good_date then												-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then										-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
			end
		end
	end

	return anchor_year, COinS_date, error_message;		-- and done
end

return p;</text>
      <sha1>ivndrn38r4ruk4mi8y4b639wc6p12w2</sha1>
    </revision>
    <revision>
      <id>4822</id>
      <parentid>4821</parentid>
      <timestamp>2014-11-29T11:55:27Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <minor />
      <comment>Synch from sandbox;</comment>
      <origin>4822</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="20115" sha1="lrxhn6pkiqdz5trood4sxzhnjw1audr" xml:space="preserve">
local p = {}

-- returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct. If not a valid month, returns 0
function get_month_number (month)
local long_months = {['January']=1, ['February']=2, ['March']=3, ['April']=4, ['May']=5, ['June']=6, ['July']=7, ['August']=8, ['September']=9, ['October']=10, ['November']=11, ['December']=12};
local short_months = {['Jan']=1, ['Feb']=2, ['Mar']=3, ['Apr']=4, ['May']=5, ['Jun']=6, ['Jul']=7, ['Aug']=8, ['Sep']=9, ['Oct']=10, ['Nov']=11, ['Dec']=12};
local temp;
	temp=long_months[month];
	if temp then return temp; end				-- if month is the long-form name
	temp=short_months[month];
	if temp then return temp; end				-- if month is the short-form name
	return 0;									-- misspelled, improper case, or not a month name
end

-- returns a number according to the sequence of seasons in a year: 1 for Winter, etc.  Capitalization and spelling must be correct. If not a valid season, returns 0
function get_season_number (season)
local season_list = {['Winter']=1, ['Spring']=2, ['Summer']=3, ['Fall']=4, ['Autumn']=4}
local temp;
	temp=season_list[season];
	if temp then return temp; end				-- if season is a valid name return its number
	return 0;									-- misspelled, improper case, or not a season name
end

--returns true if month or season is valid (properly spelled, capitalized, abbreviated)
function is_valid_month_or_season (month_season)
	if 0 == get_month_number (month_season) then		-- if month text isn't one of the twelve months, might be a season
		if 0 == get_season_number (month_season) then	-- not a month, is it a season?
			return false;								-- return false not a month or one of the five seasons
		end
	end
	return true;
end


--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one year in the future are not acceptable.

]]

function is_valid_year(year)
	if not is_set(year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;			-- global variable so we only have to fetch it once
	end
	return tonumber(year) &lt;= year_limit;				-- false if year is in the future more than one year
end

--[[
Returns true if day is less than or equal to the number of days in month and year is no farther into the future than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap years before 1582 and Gregorian leap years after 1582.
Where the two calendars overlap (1582 to approximately 1923) dates are assumed to be Gregorian.
]]
function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year(year) then	-- no farther into the future than next year
		return false;
	end
	
	if (2==month) then							-- if February
		month_length = 28;						-- then 28 days unless
		if 1582 &gt; tonumber(year) then			-- Julian calendar
			if 0==(year%4) then
				month_length = 29;
			end
		else									-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then	-- is a leap year?
				month_length = 29;				-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end

--[[
Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.  Similarly, seasons are also left to right, earliest to latest in time.  There is
an oddity with seasons.  Winter is assigned a value of 1, spring 2, ..., fall and autumn 4.  Because winter can follow fall/autumn at the end of a calender year, a special test
is made to see if |date=Fall-Winter yyyy (4-1) is the date.
]]

function is_valid_month_season_range(range_start, range_end)
	local range_start_number = get_month_number (range_start);
	
	if 0 == range_start_number then								-- is this a month range?
		local range_start_number = get_season_number (range_start);		-- not a month; is it a season? get start season number
		local range_end_number = get_season_number (range_end);			-- get end season number

		if 0 ~= range_start_number then							-- is start of range a season?
			if range_start_number &lt; range_end_number then		-- range_start is a season
				return true;									-- return true when range_end is also a season and follows start season; else false
			end
			if 4 == range_start_number and 1 == range_end_number then	-- special case when range is Fall-Winter or Autumn-Winter
				return true;
			end
		end
		return false;		-- range_start is not a month or a season; or range_start is a season and range_end is not; or improper season sequence
	end

	local range_end_number = get_month_number (range_end);		-- get end month number
	if range_start_number &lt; range_end_number then				-- range_start is a month; does range_start precede range_end?
		return true;											-- if yes, return true
	end
	return false;												-- range_start month number is greater than or equal to range end number; or range end isn't a month
end

--[[
Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only allowed range separator is endash.
Additionally, check the date to see that it is a real date: no 31 in 30-day months; no 29 February when not a leap year.  Months, both long-form and three
character abbreviations, and seasons must be spelled correctly. Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and COinS_date.  When this happens, the date parameter is
used in the COinS metadata and the CITEREF identifier gets its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc.)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is date_string without anchor_year disambiguator if any
]]
function check_date (date_string)
	local year;			-- assume that year2, months, and days are not used;
	local year2=0;		-- second year in a year range
	local month=0;
	local month2=0;		-- second month in a month range
	local day=0;
	local day2=0;		-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then										-- year-initial numerical year month day format
		year, month, day=string.match(date_string, &quot;(%d%d%d%d)%-(%d%d)%-(%d%d)&quot;);
		month=tonumber(month);
		if 12 &lt; month or 1 &gt; month or 1583 &gt; tonumber(year) then return false; end			-- month number not valid or not Gregorian calendar
		anchor_year = year;

	elseif date_string:match(&quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then						-- month-initial: month day, year
		month, day, anchor_year, year=string.match(date_string, &quot;(%a+)%s*(%d%d?),%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
				
	elseif date_string:match(&quot;^%a+ +[1-9]%d?–[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year=string.match(date_string, &quot;(%a+) +(%d%d?)–(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then						-- day-initial: day month year
		day, month, anchor_year, year=string.match(date_string, &quot;(%d%d*)%s*(%a+)%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d?–[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year=string.match(date_string, &quot;(%d%d?)–(%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d? +%a+ – [1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year=date_string:match(&quot;(%d%d?) +(%a+) – (%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^%a+ +[1-9]%d? – %a+ +[1-9]%d?, +[1-9]%d%d%d?%a?$&quot;) then		-- month initial month-day-range: month day – month day, year;  uses spaced endash
		month, day, month2, day2, anchor_year, year=date_string:match(&quot;(%a+) +(%d%d?) – (%a+) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^[1-9]%d? +%a+ +[1-9]%d%d%d – [1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2=date_string:match(&quot;(%d%d?) +(%a+) +(%d%d%d%d?) – (%d%d?) +(%a+) +((%d%d%d%d?)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end							-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- year2 no more than one year in the future
		month = get_month_number (month);
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d – %a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then		-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
		month, day, year, month2, day2, anchor_year, year2=date_string:match(&quot;(%a+) +(%d%d?), +(%d%d%d%d) – (%a+) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end							-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- year2 no more than one year in the future
		month = get_month_number (month);
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d–%d%d%a?$&quot;) then								-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		if nil == date_string:match(&quot;^Winter&quot;) and nil == date_string:match(&quot;^Summer&quot;) then return false end;	-- 'month' can only be Winter or Summer
		local century;
		year, century, anchor_year, year2=date_string:match(&quot;%a+ +((%d%d)%d%d)–((%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		year2 = century..year2;																-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d–[1-9]%d%d%d%a?$&quot;) then						-- special case Winter/Summer year-year; year separated with unspaced endash
		if nil == date_string:match(&quot;^Winter&quot;) and nil == date_string:match(&quot;^Summer&quot;) then return false end;	-- 'month' can only be Winter or Summer
		year, anchor_year, year2=date_string:match(&quot;%a+ +(%d%d%d%d)–((%d%d%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d% – %a+ +[1-9]%d%d%d%a?$&quot;) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2=date_string:match(&quot;(%a+) +(%d%d%d%d) – (%a+) +((%d%d%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end							-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		if not((0 ~= get_month_number(month) and 0 ~= get_month_number(month2)) or 			-- both must be month year or season year, not mixed
			(0 ~= get_season_number(month) and 0 ~= get_season_number(month2))) then return false; end

	elseif date_string:match (&quot;^%a+–%a+ +[1-9]%d%d%d%a?$&quot;) then								-- month/season range year; months separated by endash 
		month, month2, anchor_year, year=date_string:match (&quot;(%a+)–(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or (not is_valid_year(year)) then
			return false;
		end
		
	elseif date_string:match(&quot;^%a+ +%d%d%d%d%a?$&quot;) then							-- month/season year
		month, anchor_year, year=date_string:match(&quot;(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if not is_valid_year(year) then return false; end
		if not is_valid_month_or_season (month) then return false; end

	elseif date_string:match(&quot;^[1-9]%d%d%d?–[1-9]%d%d%d?%a?$&quot;) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2=date_string:match(&quot;(%d%d%d%d?)–((%d%d%d%d?)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d–%d%d%a?$&quot;) then						-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2=date_string:match(&quot;((%d%d)%d%d)–((%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century..year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then							-- year; here accept either YYY or YYYY
		anchor_year, year=date_string:match(&quot;((%d%d%d%d?)%a?)&quot;);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;											-- date format not one of the MOS:DATE approved formats
	end

	local result=true;											-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result=is_valid_date(year,month,day);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month2,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year2,month2,day2);
	end
	
	if false == result then return false; end
																-- if here, then date_string is valid; get coins_date from date_string (leave CITEREF disambiguator) ...
	coins_date=date_string:match(&quot;^(.+%d)%a?$&quot;);				-- last character of valid disambiguatable date is always a digit
	coins_date= mw.ustring.gsub(coins_date, &quot;–&quot;, &quot;-&quot; );			-- ... and replace any ndash with a hyphen
	
	return true, anchor_year, coins_date;						-- format is good and date string represents a real date
end	

--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.

]]

function p.dates(date_parameters_list)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local error_message =&quot;&quot;;
	local good_date=false;
	
	for k, v in pairs(date_parameters_list) do										-- for each date-holding parameter in the list
		if is_set(v) then															-- if the parameter has a value
			if v:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then								-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);						-- get the year portion so it can be tested
				if 'date'==k then
					anchor_year, COinS_date = v:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year'==k then
					good_date = is_valid_year(year);
				end
			elseif 'date'==k then													-- if the parameter is |date=
				if v:match(&quot;^n%.d%.%a?&quot;) then										-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v:match(&quot;^nd%a?$&quot;) then										-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v);			-- go test the date
				end
			else																	-- any other date-holding parameter
				good_date = check_date (v);											-- go test the date
			end
			if false==good_date then												-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then										-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
			end
		end
	end

	return anchor_year, COinS_date, error_message;		-- and done
end

return p;</text>
      <sha1>lrxhn6pkiqdz5trood4sxzhnjw1audr</sha1>
    </revision>
    <revision>
      <id>4823</id>
      <parentid>4822</parentid>
      <timestamp>2015-03-21T12:13:36Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4823</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="23615" sha1="qil3ud1tsihuk1g1d688bdzrj7he7jy" xml:space="preserve">
local p = {}

-- returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct. If not a valid month, returns 0
local function get_month_number (month)
local long_months = {['January']=1, ['February']=2, ['March']=3, ['April']=4, ['May']=5, ['June']=6, ['July']=7, ['August']=8, ['September']=9, ['October']=10, ['November']=11, ['December']=12};
local short_months = {['Jan']=1, ['Feb']=2, ['Mar']=3, ['Apr']=4, ['May']=5, ['Jun']=6, ['Jul']=7, ['Aug']=8, ['Sep']=9, ['Oct']=10, ['Nov']=11, ['Dec']=12};
local temp;
	temp=long_months[month];
	if temp then return temp; end				-- if month is the long-form name
	temp=short_months[month];
	if temp then return temp; end				-- if month is the short-form name
	return 0;									-- misspelled, improper case, or not a month name
end

-- returns a number according to the sequence of seasons in a year: 1 for Winter, etc.  Capitalization and spelling must be correct. If not a valid season, returns 0
local function get_season_number (season)
local season_list = {['Winter']=1, ['Spring']=2, ['Summer']=3, ['Fall']=4, ['Autumn']=4}
local temp;
	temp=season_list[season];
	if temp then return temp; end				-- if season is a valid name return its number
	return 0;									-- misspelled, improper case, or not a season name
end

--returns true if month or season is valid (properly spelled, capitalized, abbreviated)
local function is_valid_month_or_season (month_season)
	if 0 == get_month_number (month_season) then		-- if month text isn't one of the twelve months, might be a season
		if 0 == get_season_number (month_season) then	-- not a month, is it a season?
			return false;								-- return false not a month or one of the five seasons
		end
	end
	return true;
end


--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one year in the future are not acceptable.

]]

local function is_valid_year(year)
	if not is_set(year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;			-- global variable so we only have to fetch it once
	end
	return tonumber(year) &lt;= year_limit;				-- false if year is in the future more than one year
end

--[[
Returns true if day is less than or equal to the number of days in month and year is no farther into the future than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap years before 1582 and Gregorian leap years after 1582.
Where the two calendars overlap (1582 to approximately 1923) dates are assumed to be Gregorian.
]]
local function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year(year) then	-- no farther into the future than next year
		return false;
	end
	
	if (2==month) then							-- if February
		month_length = 28;						-- then 28 days unless
		if 1582 &gt; tonumber(year) then			-- Julian calendar
			if 0==(year%4) then
				month_length = 29;
			end
		else									-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then	-- is a leap year?
				month_length = 29;				-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end

--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
There is a special test for May because it can be either short or long form.

Returns true when style for both months is the same

]]

local function is_valid_month_range_style (month1, month2)
local len1 = month1:len();
local len2 = month2:len();
	if len1 == len2 then
		return true;															-- both months are short form so return true
	elseif 'May' == month1 or 'May'== month2 then
		return true;															-- both months are long form so return true
	elseif 3 == len1 or 3 == len2 then
		return false;															-- months are mixed form so return false
	else
		return true;															-- both months are long form so return true
	end
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

Similarly, seasons are also left to right, earliest to latest in time.  There is an oddity with seasons: winter is assigned a value of 1, spring 2, ...,
fall and autumn 4.  Because winter can follow fall/autumn at the end of a calender year, a special test is made to see if |date=Fall-Winter yyyy (4-1) is the date.

]]

local function is_valid_month_season_range(range_start, range_end)
	local range_start_number = get_month_number (range_start);
	
	if 0 == range_start_number then								-- is this a month range?
		local range_start_number = get_season_number (range_start);		-- not a month; is it a season? get start season number
		local range_end_number = get_season_number (range_end);			-- get end season number

		if 0 ~= range_start_number then							-- is start of range a season?
			if range_start_number &lt; range_end_number then		-- range_start is a season
				return true;									-- return true when range_end is also a season and follows start season; else false
			end
			if 4 == range_start_number and 1 == range_end_number then	-- special case when range is Fall-Winter or Autumn-Winter
				return true;
			end
		end
		return false;		-- range_start is not a month or a season; or range_start is a season and range_end is not; or improper season sequence
	end

	local range_end_number = get_month_number (range_end);		-- get end month number
	if range_start_number &lt; range_end_number then				-- range_start is a month; does range_start precede range_end?
		if is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
		end
	end
	return false;												-- range_start month number is greater than or equal to range end number; or range end isn't a month
end

--[[
Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only allowed range separator is endash.
Additionally, check the date to see that it is a real date: no 31 in 30-day months; no 29 February when not a leap year.  Months, both long-form and three
character abbreviations, and seasons must be spelled correctly. Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and COinS_date.  When this happens, the date parameter is
used in the COinS metadata and the CITEREF identifier gets its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc.)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is date_string without anchor_year disambiguator if any
]]
local function check_date (date_string)
	local year;			-- assume that year2, months, and days are not used;
	local year2=0;		-- second year in a year range
	local month=0;
	local month2=0;		-- second month in a month range
	local day=0;
	local day2=0;		-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then										-- year-initial numerical year month day format
		year, month, day=string.match(date_string, &quot;(%d%d%d%d)%-(%d%d)%-(%d%d)&quot;);
		month=tonumber(month);
		if 12 &lt; month or 1 &gt; month or 1583 &gt; tonumber(year) then return false; end			-- month number not valid or not Gregorian calendar
		anchor_year = year;

	elseif date_string:match(&quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then						-- month-initial: month day, year
		month, day, anchor_year, year=string.match(date_string, &quot;(%a+)%s*(%d%d?),%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
				
	elseif date_string:match(&quot;^%a+ +[1-9]%d?–[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year=string.match(date_string, &quot;(%a+) +(%d%d?)–(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then						-- day-initial: day month year
		day, month, anchor_year, year=string.match(date_string, &quot;(%d%d*)%s*(%a+)%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d?–[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year=string.match(date_string, &quot;(%d%d?)–(%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d? +%a+ – [1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year=date_string:match(&quot;(%d%d?) +(%a+) – (%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^%a+ +[1-9]%d? – %a+ +[1-9]%d?, +[1-9]%d%d%d?%a?$&quot;) then		-- month initial month-day-range: month day – month day, year;  uses spaced endash
		month, day, month2, day2, anchor_year, year=date_string:match(&quot;(%a+) +(%d%d?) – (%a+) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^[1-9]%d? +%a+ +[1-9]%d%d%d – [1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2=date_string:match(&quot;(%d%d?) +(%a+) +(%d%d%d%d?) – (%d%d?) +(%a+) +((%d%d%d%d?)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end							-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d – %a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then		-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
		month, day, year, month2, day2, anchor_year, year2=date_string:match(&quot;(%a+) +(%d%d?), +(%d%d%d%d) – (%a+) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end							-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d–%d%d%a?$&quot;) then								-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		if nil == date_string:match(&quot;^Winter&quot;) and nil == date_string:match(&quot;^Summer&quot;) then return false end;	-- 'month' can only be Winter or Summer
		local century;
		year, century, anchor_year, year2=date_string:match(&quot;%a+ +((%d%d)%d%d)–((%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		year2 = century..year2;																-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d–[1-9]%d%d%d%a?$&quot;) then						-- special case Winter/Summer year-year; year separated with unspaced endash
		if nil == date_string:match(&quot;^Winter&quot;) and nil == date_string:match(&quot;^Summer&quot;) then return false end;	-- 'month' can only be Winter or Summer
		year, anchor_year, year2=date_string:match(&quot;%a+ +(%d%d%d%d)–((%d%d%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d% – %a+ +[1-9]%d%d%d%a?$&quot;) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2=date_string:match(&quot;(%a+) +(%d%d%d%d) – (%a+) +((%d%d%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end							-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		if not((0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2)) or 	-- both must be month year, same month style
			(0 ~= get_season_number(month) and 0 ~= get_season_number(month2))) then return false; end								-- or season year, not mixed

	elseif date_string:match (&quot;^%a+–%a+ +[1-9]%d%d%d%a?$&quot;) then								-- month/season range year; months separated by endash 
		month, month2, anchor_year, year=date_string:match (&quot;(%a+)–(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or (not is_valid_year(year)) then
			return false;
		end
		
	elseif date_string:match(&quot;^%a+ +%d%d%d%d%a?$&quot;) then							-- month/season year
		month, anchor_year, year=date_string:match(&quot;(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if not is_valid_year(year) then return false; end
		if not is_valid_month_or_season (month) then return false; end

	elseif date_string:match(&quot;^[1-9]%d%d%d?–[1-9]%d%d%d?%a?$&quot;) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2=date_string:match(&quot;(%d%d%d%d?)–((%d%d%d%d?)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d–%d%d%a?$&quot;) then						-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2=date_string:match(&quot;((%d%d)%d%d)–((%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century..year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then							-- year; here accept either YYY or YYYY
		anchor_year, year=date_string:match(&quot;((%d%d%d%d?)%a?)&quot;);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;											-- date format not one of the MOS:DATE approved formats
	end

	local result=true;											-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result=is_valid_date(year,month,day);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month2,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year2,month2,day2);
	end
	
	if false == result then return false; end
																-- if here, then date_string is valid; get coins_date from date_string (leave CITEREF disambiguator) ...
	coins_date=date_string:match(&quot;^(.+%d)%a?$&quot;);				-- last character of valid disambiguatable date is always a digit
	coins_date= mw.ustring.gsub(coins_date, &quot;–&quot;, &quot;-&quot; );			-- ... and replace any ndash with a hyphen
	
	return true, anchor_year, coins_date;						-- format is good and date string represents a real date
end	

--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.

]]

--function p.dates(date_parameters_list)
local function dates(date_parameters_list)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local error_message = &quot;&quot;;
	local mismatch = 0;
	local good_date = false;
	
	for k, v in pairs(date_parameters_list) do										-- for each date-holding parameter in the list
		if is_set(v) then															-- if the parameter has a value
			if v:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then								-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);						-- get the year portion so it can be tested
				if 'date'==k then
					anchor_year, COinS_date = v:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year'==k then
					good_date = is_valid_year(year);
				end
			elseif 'date'==k then													-- if the parameter is |date=
				if v:match(&quot;^n%.d%.%a?&quot;) then										-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v:match(&quot;^nd%a?$&quot;) then										-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v);			-- go test the date
				end
			else																	-- any other date-holding parameter
				good_date = check_date (v);											-- go test the date
			end
			if false==good_date then												-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then										-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
			end
		end
	end
	return anchor_year, COinS_date, error_message, mismatch;					-- and done
end

--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function returns a numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

]]

local function year_date_check (year_string, date_string)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes
	
	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where date and year required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d[%s%-–]+%d%d&quot;) then						-- YYYY-YY date ranges
		local century;
		date1, century, date2 = date_string:match (&quot;((%d%d)%d%d)[%s%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	end
	return result;
end

return {dates = dates, year_date_check = year_date_check}						-- return exported functions</text>
      <sha1>qil3ud1tsihuk1g1d688bdzrj7he7jy</sha1>
    </revision>
    <revision>
      <id>4824</id>
      <parentid>4823</parentid>
      <timestamp>2015-04-18T09:53:26Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4824</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="26501" sha1="evxcqaduf4fc0hew673fzsesws7jc1s" xml:space="preserve">
local p = {}

--[[--------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |accessdate= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

]]

local function is_valid_accessdate (accessdate)
	local lang = mw.getContentLanguage();
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold unix time stamps representing the dates
		
	good1, access_ts = pcall( lang.formatDate, lang, 'U', accessdate );			-- convert accessdate value to unix timesatmp 
	good2, tomorrow_ts = pcall( lang.formatDate, lang, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then
		access_ts = tonumber (access_ts);										-- convert to numbers for the comparison
		tomorrow_ts = tonumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to unix time stamp
	end
	
	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end

--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct. If not a valid month, returns 0

]]

local function get_month_number (month)
local long_months = {['January']=1, ['February']=2, ['March']=3, ['April']=4, ['May']=5, ['June']=6, ['July']=7, ['August']=8, ['September']=9, ['October']=10, ['November']=11, ['December']=12};
local short_months = {['Jan']=1, ['Feb']=2, ['Mar']=3, ['Apr']=4, ['May']=5, ['Jun']=6, ['Jul']=7, ['Aug']=8, ['Sep']=9, ['Oct']=10, ['Nov']=11, ['Dec']=12};
local temp;
	temp=long_months[month];
	if temp then return temp; end				-- if month is the long-form name
	temp=short_months[month];
	if temp then return temp; end				-- if month is the short-form name
	return 0;									-- misspelled, improper case, or not a month name
end

--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 1 for Winter, etc.  Capitalization and spelling must be correct. If not a valid season, returns 0

]]

local function get_season_number (season)
local season_list = {['Winter']=1, ['Spring']=2, ['Summer']=3, ['Fall']=4, ['Autumn']=4}
local temp;
	temp=season_list[season];
	if temp then return temp; end				-- if season is a valid name return its number
	return 0;									-- misspelled, improper case, or not a season name
end

--[[--------------------------&lt; I S _ P R O P E R _ N A M E &gt;--------------------------------------------------

returns a non-zero number if date contains a recognized proper name.  Capitalization and spelling must be correct.

]]

local function is_proper_name (name)
local name_list = {['Christmas']=1}
local temp;
	temp=name_list[name];
	if temp then return temp; end				-- if name is a valid name return its number
	return 0;									-- misspelled, improper case, or not a proper name
end

--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ O R _ S E A S O N &gt;------------------------------

--returns true if month or season is valid (properly spelled, capitalized, abbreviated)

]]

local function is_valid_month_or_season (month_season)
	if 0 == get_month_number (month_season) then		-- if month text isn't one of the twelve months, might be a season
		if 0 == get_season_number (month_season) then	-- not a month, is it a season?
			return false;								-- return false not a month or one of the five seasons
		end
	end
	return true;
end


--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one year in the future are not acceptable.

]]

local function is_valid_year(year)
	if not is_set(year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;			-- global variable so we only have to fetch it once
	end
	return tonumber(year) &lt;= year_limit;				-- false if year is in the future more than one year
end

--[[
Returns true if day is less than or equal to the number of days in month and year is no farther into the future than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap years before 1582 and Gregorian leap years after 1582.
Where the two calendars overlap (1582 to approximately 1923) dates are assumed to be Gregorian.
]]
local function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year(year) then	-- no farther into the future than next year
		return false;
	end
	
	if (2==month) then							-- if February
		month_length = 28;						-- then 28 days unless
		if 1582 &gt; tonumber(year) then			-- Julian calendar
			if 0==(year%4) then
				month_length = 29;
			end
		else									-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then	-- is a leap year?
				month_length = 29;				-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end

--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
There is a special test for May because it can be either short or long form.

Returns true when style for both months is the same

]]

local function is_valid_month_range_style (month1, month2)
local len1 = month1:len();
local len2 = month2:len();
	if len1 == len2 then
		return true;															-- both months are short form so return true
	elseif 'May' == month1 or 'May'== month2 then
		return true;															-- both months are long form so return true
	elseif 3 == len1 or 3 == len2 then
		return false;															-- months are mixed form so return false
	else
		return true;															-- both months are long form so return true
	end
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

Similarly, seasons are also left to right, earliest to latest in time.  There is an oddity with seasons: winter is assigned a value of 1, spring 2, ...,
fall and autumn 4.  Because winter can follow fall/autumn at the end of a calender year, a special test is made to see if |date=Fall-Winter yyyy (4-1) is the date.

]]

local function is_valid_month_season_range(range_start, range_end)
	local range_start_number = get_month_number (range_start);
	
	if 0 == range_start_number then								-- is this a month range?
		local range_start_number = get_season_number (range_start);		-- not a month; is it a season? get start season number
		local range_end_number = get_season_number (range_end);			-- get end season number

		if 0 ~= range_start_number then							-- is start of range a season?
			if range_start_number &lt; range_end_number then		-- range_start is a season
				return true;									-- return true when range_end is also a season and follows start season; else false
			end
			if 4 == range_start_number and 1 == range_end_number then	-- special case when range is Fall-Winter or Autumn-Winter
				return true;
			end
		end
		return false;		-- range_start is not a month or a season; or range_start is a season and range_end is not; or improper season sequence
	end

	local range_end_number = get_month_number (range_end);		-- get end month number
	if range_start_number &lt; range_end_number then				-- range_start is a month; does range_start precede range_end?
		if is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
		end
	end
	return false;												-- range_start month number is greater than or equal to range end number; or range end isn't a month
end

--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only allowed range separator is endash.
Additionally, check the date to see that it is a real date: no 31 in 30-day months; no 29 February when not a leap year.  Months, both long-form and three
character abbreviations, and seasons must be spelled correctly. Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and COinS_date.  When this happens, the date parameter is
used in the COinS metadata and the CITEREF identifier gets its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc.)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is date_string without anchor_year disambiguator if any
]]
local function check_date (date_string)
	local year;			-- assume that year2, months, and days are not used;
	local year2=0;		-- second year in a year range
	local month=0;
	local month2=0;		-- second month in a month range
	local day=0;
	local day2=0;		-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then										-- year-initial numerical year month day format
		year, month, day=string.match(date_string, &quot;(%d%d%d%d)%-(%d%d)%-(%d%d)&quot;);
		month=tonumber(month);
		if 12 &lt; month or 1 &gt; month or 1583 &gt; tonumber(year) then return false; end			-- month number not valid or not Gregorian calendar
		anchor_year = year;

	elseif date_string:match(&quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then						-- month-initial: month day, year
		month, day, anchor_year, year=string.match(date_string, &quot;(%a+)%s*(%d%d?),%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
				
	elseif date_string:match(&quot;^%a+ +[1-9]%d?–[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year=string.match(date_string, &quot;(%a+) +(%d%d?)–(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then						-- day-initial: day month year
		day, month, anchor_year, year=string.match(date_string, &quot;(%d%d*)%s*(%a+)%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d?–[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year=string.match(date_string, &quot;(%d%d?)–(%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d? +%a+ – [1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year=date_string:match(&quot;(%d%d?) +(%a+) – (%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^%a+ +[1-9]%d? – %a+ +[1-9]%d?, +[1-9]%d%d%d?%a?$&quot;) then		-- month initial month-day-range: month day – month day, year;  uses spaced endash
		month, day, month2, day2, anchor_year, year=date_string:match(&quot;(%a+) +(%d%d?) – (%a+) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^[1-9]%d? +%a+ +[1-9]%d%d%d – [1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2=date_string:match(&quot;(%d%d?) +(%a+) +(%d%d%d%d?) – (%d%d?) +(%a+) +((%d%d%d%d?)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end							-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d – %a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then		-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
		month, day, year, month2, day2, anchor_year, year2=date_string:match(&quot;(%a+) +(%d%d?), +(%d%d%d%d) – (%a+) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end							-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d–%d%d%a?$&quot;) then								-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		if nil == date_string:match(&quot;^Winter&quot;) and nil == date_string:match(&quot;^Summer&quot;) then return false end;	-- 'month' can only be Winter or Summer
		local century;
		year, century, anchor_year, year2=date_string:match(&quot;%a+ +((%d%d)%d%d)–((%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		year2 = century..year2;																-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d–[1-9]%d%d%d%a?$&quot;) then						-- special case Winter/Summer year-year; year separated with unspaced endash
		if nil == date_string:match(&quot;^Winter&quot;) and nil == date_string:match(&quot;^Summer&quot;) then return false end;	-- 'month' can only be Winter or Summer
		year, anchor_year, year2=date_string:match(&quot;%a+ +(%d%d%d%d)–((%d%d%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d% – %a+ +[1-9]%d%d%d%a?$&quot;) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2=date_string:match(&quot;(%a+) +(%d%d%d%d) – (%a+) +((%d%d%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end							-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		if not((0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2)) or 	-- both must be month year, same month style
			(0 ~= get_season_number(month) and 0 ~= get_season_number(month2))) then return false; end								-- or season year, not mixed

	elseif date_string:match (&quot;^%a+–%a+ +[1-9]%d%d%d%a?$&quot;) then								-- month/season range year; months separated by endash 
		month, month2, anchor_year, year=date_string:match (&quot;(%a+)–(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or (not is_valid_year(year)) then
			return false;
		end
		
	elseif date_string:match(&quot;^%a+ +%d%d%d%d%a?$&quot;) then							-- month/season year or proper-name year
		month, anchor_year, year=date_string:match(&quot;(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if not is_valid_year(year) then return false; end
		if not is_valid_month_or_season (month) and 0 == is_proper_name (month) then return false; end

	elseif date_string:match(&quot;^[1-9]%d%d%d?–[1-9]%d%d%d?%a?$&quot;) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2=date_string:match(&quot;(%d%d%d%d?)–((%d%d%d%d?)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d–%d%d%a?$&quot;) then						-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2=date_string:match(&quot;((%d%d)%d%d)–((%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century..year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then							-- year; here accept either YYY or YYYY
		anchor_year, year=date_string:match(&quot;((%d%d%d%d?)%a?)&quot;);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;											-- date format not one of the MOS:DATE approved formats
	end

	local result=true;											-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result=is_valid_date(year,month,day);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month2,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year2,month2,day2);
	end
	
	if false == result then return false; end
																-- if here, then date_string is valid; get coins_date from date_string (leave CITEREF disambiguator) ...
	coins_date=date_string:match(&quot;^(.+%d)%a?$&quot;);				-- last character of valid disambiguatable date is always a digit
	coins_date= mw.ustring.gsub(coins_date, &quot;–&quot;, &quot;-&quot; );			-- ... and replace any ndash with a hyphen
	
	return true, anchor_year, coins_date;						-- format is good and date string represents a real date
end	

--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.

]]

--function p.dates(date_parameters_list)
local function dates(date_parameters_list)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local error_message = &quot;&quot;;
	local mismatch = 0;
	local good_date = false;
	
	for k, v in pairs(date_parameters_list) do										-- for each date-holding parameter in the list
		if is_set(v) then															-- if the parameter has a value
			if v:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then								-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);						-- get the year portion so it can be tested
				if 'date'==k then
					anchor_year, COinS_date = v:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year'==k then
					good_date = is_valid_year(year);
				end
			elseif 'date'==k then													-- if the parameter is |date=
				if v:match(&quot;^n%.d%.%a?&quot;) then										-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v:match(&quot;^nd%a?$&quot;) then										-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v);			-- go test the date
				end
			elseif 'accessdate'==k then												-- if the parameter is |date=
				good_date = check_date (v);											-- go test the date
				if true == good_date then											-- if the date is a valid date
					good_date = is_valid_accessdate (v);							-- is Wikipedia start date &lt; accessdate &lt; tomorrow's date?
				end
			else																	-- any other date-holding parameter
				good_date = check_date (v);											-- go test the date
			end
			if false==good_date then												-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then										-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
			end
		end
	end
	return anchor_year, COinS_date, error_message, mismatch;					-- and done
end

--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function returns a numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

]]

local function year_date_check (year_string, date_string)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes
	
	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where date and year required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d[%s%-–]+%d%d&quot;) then						-- YYYY-YY date ranges
		local century;
		date1, century, date2 = date_string:match (&quot;((%d%d)%d%d)[%s%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	end
	return result;
end

return {dates = dates, year_date_check = year_date_check}						-- return exported functions</text>
      <sha1>evxcqaduf4fc0hew673fzsesws7jc1s</sha1>
    </revision>
    <revision>
      <id>4825</id>
      <parentid>4824</parentid>
      <timestamp>2015-09-26T16:13:35Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4825</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="26502" sha1="mdq4559zou73ecu54lzu2kht8rxy6nl" xml:space="preserve">
local p = {}

--[[--------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |accessdate= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

]]

local function is_valid_accessdate (accessdate)
	local lang = mw.getContentLanguage();
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold unix time stamps representing the dates
		
	good1, access_ts = pcall( lang.formatDate, lang, 'U', accessdate );			-- convert accessdate value to unix timesatmp 
	good2, tomorrow_ts = pcall( lang.formatDate, lang, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then
		access_ts = tonumber (access_ts);										-- convert to numbers for the comparison
		tomorrow_ts = tonumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to unix time stamp
	end
	
	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end

--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct. If not a valid month, returns 0

]]

local function get_month_number (month)
local long_months = {['January']=1, ['February']=2, ['March']=3, ['April']=4, ['May']=5, ['June']=6, ['July']=7, ['August']=8, ['September']=9, ['October']=10, ['November']=11, ['December']=12};
local short_months = {['Jan']=1, ['Feb']=2, ['Mar']=3, ['Apr']=4, ['May']=5, ['Jun']=6, ['Jul']=7, ['Aug']=8, ['Sep']=9, ['Oct']=10, ['Nov']=11, ['Dec']=12};
local temp;
	temp=long_months[month];
	if temp then return temp; end				-- if month is the long-form name
	temp=short_months[month];
	if temp then return temp; end				-- if month is the short-form name
	return 0;									-- misspelled, improper case, or not a month name
end

--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 1 for Winter, etc.  Capitalization and spelling must be correct. If not a valid season, returns 0

]]

local function get_season_number (season)
local season_list = {['Winter']=1, ['Spring']=2, ['Summer']=3, ['Fall']=4, ['Autumn']=4}
local temp;
	temp=season_list[season];
	if temp then return temp; end				-- if season is a valid name return its number
	return 0;									-- misspelled, improper case, or not a season name
end

--[[--------------------------&lt; I S _ P R O P E R _ N A M E &gt;--------------------------------------------------

returns a non-zero number if date contains a recognized proper name.  Capitalization and spelling must be correct.

]]

local function is_proper_name (name)
local name_list = {['Christmas']=1}
local temp;
	temp=name_list[name];
	if temp then return temp; end				-- if name is a valid name return its number
	return 0;									-- misspelled, improper case, or not a proper name
end

--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ O R _ S E A S O N &gt;------------------------------

--returns true if month or season is valid (properly spelled, capitalized, abbreviated)

]]

local function is_valid_month_or_season (month_season)
	if 0 == get_month_number (month_season) then		-- if month text isn't one of the twelve months, might be a season
		if 0 == get_season_number (month_season) then	-- not a month, is it a season?
			return false;								-- return false not a month or one of the five seasons
		end
	end
	return true;
end


--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one year in the future are not acceptable.

]]

local function is_valid_year(year)
	if not is_set(year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;			-- global variable so we only have to fetch it once
	end
	return tonumber(year) &lt;= year_limit;				-- false if year is in the future more than one year
end

--[[
Returns true if day is less than or equal to the number of days in month and year is no farther into the future than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap years before 1582 and Gregorian leap years after 1582.
Where the two calendars overlap (1582 to approximately 1923) dates are assumed to be Gregorian.
]]
local function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year(year) then	-- no farther into the future than next year
		return false;
	end
	
	if (2==month) then							-- if February
		month_length = 28;						-- then 28 days unless
		if 1582 &gt; tonumber(year) then			-- Julian calendar
			if 0==(year%4) then
				month_length = 29;
			end
		else									-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then	-- is a leap year?
				month_length = 29;				-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end

--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
There is a special test for May because it can be either short or long form.

Returns true when style for both months is the same

]]

local function is_valid_month_range_style (month1, month2)
local len1 = month1:len();
local len2 = month2:len();
	if len1 == len2 then
		return true;															-- both months are short form so return true
	elseif 'May' == month1 or 'May'== month2 then
		return true;															-- both months are long form so return true
	elseif 3 == len1 or 3 == len2 then
		return false;															-- months are mixed form so return false
	else
		return true;															-- both months are long form so return true
	end
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

Similarly, seasons are also left to right, earliest to latest in time.  There is an oddity with seasons: winter is assigned a value of 1, spring 2, ...,
fall and autumn 4.  Because winter can follow fall/autumn at the end of a calender year, a special test is made to see if |date=Fall-Winter yyyy (4-1) is the date.

]]

local function is_valid_month_season_range(range_start, range_end)
	local range_start_number = get_month_number (range_start);
	
	if 0 == range_start_number then								-- is this a month range?
		local range_start_number = get_season_number (range_start);		-- not a month; is it a season? get start season number
		local range_end_number = get_season_number (range_end);			-- get end season number

		if 0 ~= range_start_number then							-- is start of range a season?
			if range_start_number &lt; range_end_number then		-- range_start is a season
				return true;									-- return true when range_end is also a season and follows start season; else false
			end
			if 4 == range_start_number and 1 == range_end_number then	-- special case when range is Fall-Winter or Autumn-Winter
				return true;
			end
		end
		return false;		-- range_start is not a month or a season; or range_start is a season and range_end is not; or improper season sequence
	end

	local range_end_number = get_month_number (range_end);		-- get end month number
	if range_start_number &lt; range_end_number then				-- range_start is a month; does range_start precede range_end?
		if is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
		end
	end
	return false;												-- range_start month number is greater than or equal to range end number; or range end isn't a month
end

--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only allowed range separator is endash.
Additionally, check the date to see that it is a real date: no 31 in 30-day months; no 29 February when not a leap year.  Months, both long-form and three
character abbreviations, and seasons must be spelled correctly. Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and COinS_date.  When this happens, the date parameter is
used in the COinS metadata and the CITEREF identifier gets its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc.)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is date_string without anchor_year disambiguator if any
]]
local function check_date (date_string)
	local year;			-- assume that year2, months, and days are not used;
	local year2=0;		-- second year in a year range
	local month=0;
	local month2=0;		-- second month in a month range
	local day=0;
	local day2=0;		-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then										-- year-initial numerical year month day format
		year, month, day=string.match(date_string, &quot;(%d%d%d%d)%-(%d%d)%-(%d%d)&quot;);
		month=tonumber(month);
		if 12 &lt; month or 1 &gt; month or 1583 &gt; tonumber(year) then return false; end			-- month number not valid or not Gregorian calendar
		anchor_year = year;

	elseif date_string:match(&quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then						-- month-initial: month day, year
		month, day, anchor_year, year=string.match(date_string, &quot;(%a+)%s*(%d%d?),%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
				
	elseif date_string:match(&quot;^%a+ +[1-9]%d?–[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year=string.match(date_string, &quot;(%a+) +(%d%d?)–(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then						-- day-initial: day month year
		day, month, anchor_year, year=string.match(date_string, &quot;(%d%d*)%s*(%a+)%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d?–[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year=string.match(date_string, &quot;(%d%d?)–(%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d? +%a+ – [1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year=date_string:match(&quot;(%d%d?) +(%a+) – (%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^%a+ +[1-9]%d? – %a+ +[1-9]%d?, +[1-9]%d%d%d?%a?$&quot;) then		-- month initial month-day-range: month day – month day, year;  uses spaced endash
		month, day, month2, day2, anchor_year, year=date_string:match(&quot;(%a+) +(%d%d?) – (%a+) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^[1-9]%d? +%a+ +[1-9]%d%d%d – [1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2=date_string:match(&quot;(%d%d?) +(%a+) +(%d%d%d%d?) – (%d%d?) +(%a+) +((%d%d%d%d?)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end							-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d – %a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then		-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
		month, day, year, month2, day2, anchor_year, year2=date_string:match(&quot;(%a+) +(%d%d?), +(%d%d%d%d) – (%a+) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end							-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d–%d%d%a?$&quot;) then								-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		if nil == date_string:match(&quot;^Winter&quot;) and nil == date_string:match(&quot;^Summer&quot;) then return false end;	-- 'month' can only be Winter or Summer
		local century;
		year, century, anchor_year, year2=date_string:match(&quot;%a+ +((%d%d)%d%d)–((%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		year2 = century..year2;																-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d–[1-9]%d%d%d%a?$&quot;) then						-- special case Winter/Summer year-year; year separated with unspaced endash
		if nil == date_string:match(&quot;^Winter&quot;) and nil == date_string:match(&quot;^Summer&quot;) then return false end;	-- 'month' can only be Winter or Summer
		year, anchor_year, year2=date_string:match(&quot;%a+ +(%d%d%d%d)–((%d%d%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d% – %a+ +[1-9]%d%d%d%a?$&quot;) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2=date_string:match(&quot;(%a+) +(%d%d%d%d) – (%a+) +((%d%d%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end							-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		if not((0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2)) or 	-- both must be month year, same month style
			(0 ~= get_season_number(month) and 0 ~= get_season_number(month2))) then return false; end								-- or season year, not mixed

	elseif date_string:match (&quot;^%a+–%a+ +[1-9]%d%d%d%a?$&quot;) then								-- month/season range year; months separated by endash 
		month, month2, anchor_year, year=date_string:match (&quot;(%a+)–(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or (not is_valid_year(year)) then
			return false;
		end
		
	elseif date_string:match(&quot;^%a+ +%d%d%d%d%a?$&quot;) then							-- month/season year or proper-name year
		month, anchor_year, year=date_string:match(&quot;(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if not is_valid_year(year) then return false; end
		if not is_valid_month_or_season (month) and 0 == is_proper_name (month) then return false; end

	elseif date_string:match(&quot;^[1-9]%d%d%d?–[1-9]%d%d%d?%a?$&quot;) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2=date_string:match(&quot;(%d%d%d%d?)–((%d%d%d%d?)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d–%d%d%a?$&quot;) then						-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2=date_string:match(&quot;((%d%d)%d%d)–((%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century..year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then							-- year; here accept either YYY or YYYY
		anchor_year, year=date_string:match(&quot;((%d%d%d%d?)%a?)&quot;);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;											-- date format not one of the MOS:DATE approved formats
	end

	local result=true;											-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result=is_valid_date(year,month,day);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month2,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year2,month2,day2);
	end
	
	if false == result then return false; end
																-- if here, then date_string is valid; get coins_date from date_string (leave CITEREF disambiguator) ...
	coins_date=date_string:match(&quot;^(.+%d)%a?$&quot;);				-- last character of valid disambiguatable date is always a digit
	coins_date= mw.ustring.gsub(coins_date, &quot;–&quot;, &quot;-&quot; );			-- ... and replace any ndash with a hyphen
	
	return true, anchor_year, coins_date;						-- format is good and date string represents a real date
end	

--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.

]]

--function p.dates(date_parameters_list)
local function dates(date_parameters_list)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local error_message = &quot;&quot;;
	local mismatch = 0;
	local good_date = false;
	
	for k, v in pairs(date_parameters_list) do										-- for each date-holding parameter in the list
		if is_set(v) then															-- if the parameter has a value
			if v:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then								-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);						-- get the year portion so it can be tested
				if 'date'==k then
					anchor_year, COinS_date = v:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year'==k then
					good_date = is_valid_year(year);
				end
			elseif 'date'==k then													-- if the parameter is |date=
				if v:match(&quot;^n%.d%.%a?&quot;) then										-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v:match(&quot;^nd%a?$&quot;) then										-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v);			-- go test the date
				end
			elseif 'access-date'==k then												-- if the parameter is |date=
				good_date = check_date (v);											-- go test the date
				if true == good_date then											-- if the date is a valid date
					good_date = is_valid_accessdate (v);							-- is Wikipedia start date &lt; accessdate &lt; tomorrow's date?
				end
			else																	-- any other date-holding parameter
				good_date = check_date (v);											-- go test the date
			end
			if false==good_date then												-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then										-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
			end
		end
	end
	return anchor_year, COinS_date, error_message, mismatch;					-- and done
end

--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function returns a numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

]]

local function year_date_check (year_string, date_string)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes
	
	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where date and year required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d[%s%-–]+%d%d&quot;) then						-- YYYY-YY date ranges
		local century;
		date1, century, date2 = date_string:match (&quot;((%d%d)%d%d)[%s%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	end
	return result;
end

return {dates = dates, year_date_check = year_date_check}						-- return exported functions</text>
      <sha1>mdq4559zou73ecu54lzu2kht8rxy6nl</sha1>
    </revision>
    <revision>
      <id>4826</id>
      <parentid>4825</parentid>
      <timestamp>2015-12-05T12:45:18Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4826</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="32334" sha1="j0me7upcxlt961vza107dk4n1lna397" xml:space="preserve">
local p = {}

--[[--------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |accessdate= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

]]

local function is_valid_accessdate (accessdate)
	local lang = mw.getContentLanguage();
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold unix time stamps representing the dates
		
	good1, access_ts = pcall( lang.formatDate, lang, 'U', accessdate );			-- convert accessdate value to unix timesatmp 
	good2, tomorrow_ts = pcall( lang.formatDate, lang, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then
		access_ts = tonumber (access_ts);										-- convert to numbers for the comparison
		tomorrow_ts = tonumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to unix time stamp
	end
	
	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end

--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct. If not a valid month, returns 0

]]

local function get_month_number (month)
local long_months = {['January']=1, ['February']=2, ['March']=3, ['April']=4, ['May']=5, ['June']=6, ['July']=7, ['August']=8, ['September']=9, ['October']=10, ['November']=11, ['December']=12};
local short_months = {['Jan']=1, ['Feb']=2, ['Mar']=3, ['Apr']=4, ['May']=5, ['Jun']=6, ['Jul']=7, ['Aug']=8, ['Sep']=9, ['Oct']=10, ['Nov']=11, ['Dec']=12};
local temp;
	temp=long_months[month];
	if temp then return temp; end				-- if month is the long-form name
	temp=short_months[month];
	if temp then return temp; end				-- if month is the short-form name
	return 0;									-- misspelled, improper case, or not a month name
end

--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 1 for Winter, etc.  Capitalization and spelling must be correct. If not a valid season, returns 0

]]

local function get_season_number (season)
local season_list = {['Winter']=21, ['Spring']=22, ['Summer']=23, ['Fall']=24, ['Autumn']=24};	-- make sure these numbers do not overlap month numbers
local temp;
	temp=season_list[season];
	if temp then return temp; end												-- if season is a valid name return its number
	return 0;																	-- misspelled, improper case, or not a season name
end

--[[--------------------------&lt; I S _ P R O P E R _ N A M E &gt;--------------------------------------------------

returns a non-zero number if date contains a recognized proper name.  Capitalization and spelling must be correct.

]]

local function is_proper_name (name)
local name_list = {['Christmas']=31}
local temp;
	temp=name_list[name];
	if temp then return temp; end				-- if name is a valid name return its number
	return 0;									-- misspelled, improper case, or not a proper name
end

--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ O R _ S E A S O N &gt;------------------------------

--returns true if month or season is valid (properly spelled, capitalized, abbreviated)

]]

local function is_valid_month_or_season (month_season)
	if 0 == get_month_number (month_season) then		-- if month text isn't one of the twelve months, might be a season
		if 0 == get_season_number (month_season) then	-- not a month, is it a season?
			return false;								-- return false not a month or one of the five seasons
		end
	end
	return true;
end


--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one year in the future are not acceptable.

]]

local function is_valid_year(year)
	if not is_set(year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;			-- global variable so we only have to fetch it once
	end
	return tonumber(year) &lt;= year_limit;				-- false if year is in the future more than one year
end

--[[
Returns true if day is less than or equal to the number of days in month and year is no farther into the future than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap years before 1582 and Gregorian leap years after 1582.
Where the two calendars overlap (1582 to approximately 1923) dates are assumed to be Gregorian.
]]
local function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year(year) then	-- no farther into the future than next year
		return false;
	end
	
	if (2==month) then							-- if February
		month_length = 28;						-- then 28 days unless
		if 1582 &gt; tonumber(year) then			-- Julian calendar
			if 0==(year%4) then
				month_length = 29;
			end
		else									-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then	-- is a leap year?
				month_length = 29;				-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[tonumber(month)];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end

--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
There is a special test for May because it can be either short or long form.

Returns true when style for both months is the same

]]

local function is_valid_month_range_style (month1, month2)
local len1 = month1:len();
local len2 = month2:len();
	if len1 == len2 then
		return true;															-- both months are short form so return true
	elseif 'May' == month1 or 'May'== month2 then
		return true;															-- both months are long form so return true
	elseif 3 == len1 or 3 == len2 then
		return false;															-- months are mixed form so return false
	else
		return true;															-- both months are long form so return true
	end
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

Similarly, seasons are also left to right, earliest to latest in time.  There is an oddity with seasons: winter is assigned a value of 1, spring 2, ...,
fall and autumn 4.  Because winter can follow fall/autumn at the end of a calender year, a special test is made to see if |date=Fall-Winter yyyy (4-1) is the date.

]]

local function is_valid_month_season_range(range_start, range_end)
	local range_start_number = get_month_number (range_start);
	
	if 0 == range_start_number then												-- is this a month range?
		local range_start_number = get_season_number (range_start);				-- not a month; is it a season? get start season number
		local range_end_number = get_season_number (range_end);					-- get end season number

		if 0 ~= range_start_number then											-- is start of range a season?
			if range_start_number &lt; range_end_number then						-- range_start is a season
				return true;													-- return true when range_end is also a season and follows start season; else false
			end
			if 24 == range_start_number and 21 == range_end_number then			-- special case when season range is Fall-Winter or Autumn-Winter
				return true;
			end
		end
		return false;		-- range_start is not a month or a season; or range_start is a season and range_end is not; or improper season sequence
	end

	local range_end_number = get_month_number (range_end);						-- get end month number
	if range_start_number &lt; range_end_number then								-- range_start is a month; does range_start precede range_end?
		if is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
		end
	end
	return false;																-- range_start month number is greater than or equal to range end number; or range end isn't a month
end


--[[--------------------------&lt; M A K E _ C O I N S _ D A T E &gt;------------------------------------------------

This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1.  The function is called only for |date= parameters and only if the |date=&lt;value&gt; is 
determined to be a valid date format.  The question of what to do with invlaid date formats is not answered here.

The date parts in the input table are converted to an ISO 8601 conforming date string:
	single whole dates:		yyyy-mm-dd
	month and year dates:	yyyy-mm
	year dates:				yyyy
	ranges:					yyyy-mm-dd/yyyy-mm-dd
							yyyy-mm/yyyy-mm
							yyyy/yyyy

Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.

The input table has:
	year, year2 – always present; if before 1582, ignore months and days if present
	month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 31– proper name dates
	day, day2 –  0 if not provided, 1-31 for days
	
the output table receives:
	rftdate:	an IS8601 formatted date
	rftchron:	a free-form version of the date, usually without year which is in rftdate (season ranges and propername dates)
	rftssn:		one of four season keywords: winter, spring, summer, fall (lowercase)

]]

local function make_COinS_date (input, tCOinS_date)
	local date;																	-- one date or first date in a range
	local date2 = '';															-- end of range date
	
	if 1582 &gt; tonumber(input.year) or 20 &lt; tonumber(input.month) then			-- Julian calendar or season so &amp;rft.date gets year only
		date = input.year;
		if 0 ~= input.year2 and input.year ~= input.year2 then					-- if a range, only the second year portion when not the same as range start year
			date = string.format ('%.4d/%.4d', tonumber(input.year), tonumber(input.year2))		-- assemble the date range
		end
		if 20 &lt; tonumber(input.month) then										-- if season or propername date
			local season = {[21]='winter', [22]='spring', [23]='summer', [24]='fall', [31]='Christmas'};	-- seasons lowercase, no autumn; proper names use title case
			if 0 == input.month2 then											-- single season date
				if 30 &lt;tonumber(input.month) then
					tCOinS_date.rftchron = season[input.month];					-- proper name dates
				else
					tCOinS_date.rftssn = season[input.month];					-- seasons
				end
			else																-- season range with a second season specified
				if input.year ~= input.year2 then								-- season year – season year range or season year–year
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					if 0~= month2 then
						tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);
					end
				else															-- season–season year range
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2];	-- season–season year range
				end
			end
		end
		tCOinS_date.rftdate = date;
		return;																	-- done
	end
	
	if 0 ~= input.day then
		date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day));	-- whole date
	elseif 0 ~= input.month then
		date = string.format ('%s-%.2d', input.year, tonumber(input.month));	-- year and month
	else
		date = string.format ('%s', input.year);								-- just year
	end

	if 0 ~= input.year2 then
		if 0 ~= input.day2 then
			date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2));		-- whole date
		elseif 0 ~= input.month2 then
			date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2));	-- year and month
		else
			date2 = string.format ('/%s', input.year2);							-- just year
		end
	end
	
	tCOinS_date.rftdate = date .. date2;										-- date2 has the '/' separator
	return;
end


--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only allowed range separator is endash.
Additionally, check the date to see that it is a real date: no 31 in 30-day months; no 29 February when not a leap year.  Months, both long-form and three
character abbreviations, and seasons must be spelled correctly. Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and COinS_date.  When this happens, the date parameter is
used in the COinS metadata and the CITEREF identifier gets its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc.)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is date_string without anchor_year disambiguator if any		-- this is being obsoleted.  In future:
		COinS_date is ISO 8601 format date; see make_COInS_date()
]]
local function check_date (date_string, tCOinS_date)
	local year;			-- assume that year2, months, and days are not used;
	local year2=0;		-- second year in a year range
	local month=0;
	local month2=0;		-- second month in a month range
	local day=0;
	local day2=0;		-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then										-- year-initial numerical year month day format
		year, month, day=string.match(date_string, &quot;(%d%d%d%d)%-(%d%d)%-(%d%d)&quot;);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1583 &gt; tonumber(year) then return false; end			-- month number not valid or not Gregorian calendar
		anchor_year = year;

	elseif date_string:match(&quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then						-- month-initial: month day, year
		month, day, anchor_year, year=string.match(date_string, &quot;(%a+)%s*(%d%d?),%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
				
	elseif date_string:match(&quot;^%a+ +[1-9]%d?–[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year=string.match(date_string, &quot;(%a+) +(%d%d?)–(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
		month2=month;																		-- for metadata
		year2=year;

	elseif date_string:match(&quot;^[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then						-- day-initial: day month year
		day, month, anchor_year, year=string.match(date_string, &quot;(%d%d*)%s*(%a+)%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d?–[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year=string.match(date_string, &quot;(%d%d?)–(%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
		month2=month;																		-- for metadata
		year2=year;

	elseif date_string:match(&quot;^[1-9]%d? +%a+ – [1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year=date_string:match(&quot;(%d%d?) +(%a+) – (%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);													-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif date_string:match(&quot;^%a+ +[1-9]%d? – %a+ +[1-9]%d?, +[1-9]%d%d%d?%a?$&quot;) then		-- month initial month-day-range: month day – month day, year;  uses spaced endash
		month, day, month2, day2, anchor_year, year=date_string:match(&quot;(%a+) +(%d%d?) – (%a+) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);													-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif date_string:match(&quot;^[1-9]%d? +%a+ +[1-9]%d%d%d – [1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2=date_string:match(&quot;(%d%d?) +(%a+) +(%d%d%d%d?) – (%d%d?) +(%a+) +((%d%d%d%d?)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end												-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);																		-- for metadata
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d – %a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then		-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
		month, day, year, month2, day2, anchor_year, year2=date_string:match(&quot;(%a+) +(%d%d?), +(%d%d%d%d) – (%a+) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end												-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);																		-- for metadata
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d–%d%d%a?$&quot;) then								-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		local century;
		month, year, century, anchor_year, year2=date_string:match(&quot;(%a+) +((%d%d)%d%d)–((%d%d)%a?)&quot;);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;					-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		year2 = century..year2;																-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		month = get_season_number (month);

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d–[1-9]%d%d%d%a?$&quot;) then						-- special case Winter/Summer year-year; year separated with unspaced endash
		month, year, anchor_year, year2=date_string:match(&quot;(%a+) +(%d%d%d%d)–((%d%d%d%d)%a?)&quot;);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;					-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		month = get_season_number (month);													-- for metadata

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d% – %a+ +[1-9]%d%d%d%a?$&quot;) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2=date_string:match(&quot;(%a+) +(%d%d%d%d) – (%a+) +((%d%d%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end							-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then 	-- both must be month year, same month style
			month = get_month_number(month);
			month2 = get_month_number(month2);
		elseif 0 ~= get_season_number(month) and 0 ~= get_season_number(month2) then		-- both must be or season year, not mixed
			month = get_season_number(month);
			month2 = get_season_number(month2);
		else
			 return false;
		end

	elseif date_string:match (&quot;^%a+–%a+ +[1-9]%d%d%d%a?$&quot;) then								-- month/season range year; months separated by endash 
		month, month2, anchor_year, year=date_string:match (&quot;(%a+)–(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or (not is_valid_year(year)) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
			month2 = get_month_number(month2);
		else
			month = get_season_number(month);
			month2 = get_season_number(month2);
		end
		year2=year;
		
	elseif date_string:match(&quot;^%a+ +%d%d%d%d%a?$&quot;) then							-- month/season year or proper-name year
		month, anchor_year, year=date_string:match(&quot;(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if not is_valid_year(year) then return false; end
		if not is_valid_month_or_season (month) and 0 == is_proper_name (month) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
		elseif 0 ~= get_season_number(month) then
			month = get_season_number(month);
		else
			month = is_proper_name (month);										-- must be proper name; not supported in COinS
		end

	elseif date_string:match(&quot;^[1-9]%d%d%d?–[1-9]%d%d%d?%a?$&quot;) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2=date_string:match(&quot;(%d%d%d%d?)–((%d%d%d%d?)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d–%d%d%a?$&quot;) then						-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2=date_string:match(&quot;((%d%d)%d%d)–((%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century..year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then							-- year; here accept either YYY or YYYY
		anchor_year, year=date_string:match(&quot;((%d%d%d%d?)%a?)&quot;);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;											-- date format not one of the MOS:DATE approved formats
	end

	local result=true;											-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result=is_valid_date(year,month,day);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month2,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year2,month2,day2);
	end
	
	if false == result then return false; end
																-- if here, then date_string is valid; get coins_date from date_string (leave CITEREF disambiguator) ...
--	coins_date=date_string:match(&quot;^(.+%d)%a?$&quot;);				-- last character of valid disambiguatable date is always a digit
--	coins_date= mw.ustring.gsub(coins_date, &quot;–&quot;, &quot;-&quot; );			-- ... and replace any ndash with a hyphen

	if nil ~= tCOinS_date then													-- this table only passed into this function when testing |date= parameter values
		make_COinS_date ({year=year, month=month, day=day, year2=year2, month2=month2, day2=day2}, tCOinS_date);	-- make an ISO 8601 date string for COinS
	end
	
	return true, anchor_year;									-- format is good and date string represents a real date
--	return true, anchor_year, coins_date;						-- format is good and date string represents a real date
end	

--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.

]]

local function dates(date_parameters_list, tCOinS_date)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local error_message = &quot;&quot;;
--	local mismatch = 0;
	local good_date = false;
	
	for k, v in pairs(date_parameters_list) do										-- for each date-holding parameter in the list
		if is_set(v) then															-- if the parameter has a value
			if v:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then								-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);						-- get the year portion so it can be tested
				if 'date'==k then
					anchor_year, COinS_date = v:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year'==k then
					good_date = is_valid_year(year);
				end
			elseif 'date'==k then													-- if the parameter is |date=
				if v:match(&quot;^n%.d%.%a?&quot;) then										-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v:match(&quot;^nd%a?$&quot;) then										-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v, tCOinS_date);			-- go test the date
				end
			elseif 'access-date'==k then												-- if the parameter is |date=
				good_date = check_date (v);											-- go test the date
				if true == good_date then											-- if the date is a valid date
					good_date = is_valid_accessdate (v);							-- is Wikipedia start date &lt; accessdate &lt; tomorrow's date?
				end
			else																	-- any other date-holding parameter
				good_date = check_date (v);											-- go test the date
			end
			if false==good_date then												-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then										-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;							-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;				-- add the failed parameter
			end
		end
	end
--	return anchor_year, COinS_date, error_message, mismatch;					-- and done
	return anchor_year, error_message;											-- and done
end

--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function returns a numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

]]

local function year_date_check (year_string, date_string)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes
	
	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where date and year required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d[%s%-–]+%d%d&quot;) then						-- YYYY-YY date ranges
		local century;
		date1, century, date2 = date_string:match (&quot;((%d%d)%d%d)[%s%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	end
	return result;
end

return {dates = dates, year_date_check = year_date_check}						-- return exported functions</text>
      <sha1>j0me7upcxlt961vza107dk4n1lna397</sha1>
    </revision>
    <revision>
      <id>4827</id>
      <parentid>4826</parentid>
      <timestamp>2015-12-12T10:16:36Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4827</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="31901" sha1="89qtw8wm3cjm3unvxvjxvnewdcbsni3" xml:space="preserve">
local p = {}

--[[--------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |accessdate= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

]]

local function is_valid_accessdate (accessdate)
	local lang = mw.getContentLanguage();
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold unix time stamps representing the dates
		
	good1, access_ts = pcall( lang.formatDate, lang, 'U', accessdate );			-- convert accessdate value to unix timesatmp 
	good2, tomorrow_ts = pcall( lang.formatDate, lang, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then
		access_ts = tonumber (access_ts);										-- convert to numbers for the comparison
		tomorrow_ts = tonumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to unix time stamp
	end
	
	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end

--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct. If not a valid month, returns 0

]]

local function get_month_number (month)
local long_months = {['January']=1, ['February']=2, ['March']=3, ['April']=4, ['May']=5, ['June']=6, ['July']=7, ['August']=8, ['September']=9, ['October']=10, ['November']=11, ['December']=12};
local short_months = {['Jan']=1, ['Feb']=2, ['Mar']=3, ['Apr']=4, ['May']=5, ['Jun']=6, ['Jul']=7, ['Aug']=8, ['Sep']=9, ['Oct']=10, ['Nov']=11, ['Dec']=12};
local temp;
	temp=long_months[month];
	if temp then return temp; end				-- if month is the long-form name
	temp=short_months[month];
	if temp then return temp; end				-- if month is the short-form name
	return 0;									-- misspelled, improper case, or not a month name
end

--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 1 for Winter, etc.  Capitalization and spelling must be correct. If not a valid season, returns 0

]]

local function get_season_number (season)
local season_list = {['Winter']=21, ['Spring']=22, ['Summer']=23, ['Fall']=24, ['Autumn']=24};	-- make sure these numbers do not overlap month numbers
local temp;
	temp=season_list[season];
	if temp then return temp; end												-- if season is a valid name return its number
	return 0;																	-- misspelled, improper case, or not a season name
end

--[[--------------------------&lt; I S _ P R O P E R _ N A M E &gt;--------------------------------------------------

returns a non-zero number if date contains a recognized proper name.  Capitalization and spelling must be correct.

]]

local function is_proper_name (name)
local name_list = {['Christmas']=31}
local temp;
	temp=name_list[name];
	if temp then return temp; end				-- if name is a valid name return its number
	return 0;									-- misspelled, improper case, or not a proper name
end

--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ O R _ S E A S O N &gt;------------------------------

--returns true if month or season is valid (properly spelled, capitalized, abbreviated)

]]

local function is_valid_month_or_season (month_season)
	if 0 == get_month_number (month_season) then		-- if month text isn't one of the twelve months, might be a season
		if 0 == get_season_number (month_season) then	-- not a month, is it a season?
			return false;								-- return false not a month or one of the five seasons
		end
	end
	return true;
end

--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one year in the future are not acceptable.

]]

local function is_valid_year(year)
	if not is_set(year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;			-- global variable so we only have to fetch it once
	end
	return tonumber(year) &lt;= year_limit;				-- false if year is in the future more than one year
end

--[[--------------------------&lt; I S _ V A L I D _ D A T E &gt;----------------------------------------------------
Returns true if day is less than or equal to the number of days in month and year is no farther into the future
than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap
years before 1582 and Gregorian leap years after 1582. Where the two calendars overlap (1582 to approximately
1923) dates are assumed to be Gregorian.

]]

local function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year(year) then												-- no farther into the future than next year
		return false;
	end
	
	month = tonumber(month);													-- required for YYYY-MM-DD dates
	
	if (2==month) then															-- if February
		month_length = 28;														-- then 28 days unless
		if 1582 &gt; tonumber(year) then											-- Julian calendar
			if 0==(year%4) then
				month_length = 29;
			end
		else																	-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then			-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end

--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
There is a special test for May because it can be either short or long form.

Returns true when style for both months is the same

]]

local function is_valid_month_range_style (month1, month2)
local len1 = month1:len();
local len2 = month2:len();
	if len1 == len2 then
		return true;															-- both months are short form so return true
	elseif 'May' == month1 or 'May'== month2 then
		return true;															-- both months are long form so return true
	elseif 3 == len1 or 3 == len2 then
		return false;															-- months are mixed form so return false
	else
		return true;															-- both months are long form so return true
	end
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

Similarly, seasons are also left to right, earliest to latest in time.  There is an oddity with seasons: winter is assigned a value of 1, spring 2, ...,
fall and autumn 4.  Because winter can follow fall/autumn at the end of a calender year, a special test is made to see if |date=Fall-Winter yyyy (4-1) is the date.

]]

local function is_valid_month_season_range(range_start, range_end)
	local range_start_number = get_month_number (range_start);
	
	if 0 == range_start_number then												-- is this a month range?
		local range_start_number = get_season_number (range_start);				-- not a month; is it a season? get start season number
		local range_end_number = get_season_number (range_end);					-- get end season number

		if 0 ~= range_start_number then											-- is start of range a season?
			if range_start_number &lt; range_end_number then						-- range_start is a season
				return true;													-- return true when range_end is also a season and follows start season; else false
			end
			if 24 == range_start_number and 21 == range_end_number then			-- special case when season range is Fall-Winter or Autumn-Winter
				return true;
			end
		end
		return false;		-- range_start is not a month or a season; or range_start is a season and range_end is not; or improper season sequence
	end

	local range_end_number = get_month_number (range_end);						-- get end month number
	if range_start_number &lt; range_end_number then								-- range_start is a month; does range_start precede range_end?
		if is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
		end
	end
	return false;																-- range_start month number is greater than or equal to range end number; or range end isn't a month
end


--[[--------------------------&lt; M A K E _ C O I N S _ D A T E &gt;------------------------------------------------

This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1.  The function is called only for |date= parameters and only if the |date=&lt;value&gt; is 
determined to be a valid date format.  The question of what to do with invalid date formats is not answered here.

The date parts in the input table are converted to an ISO 8601 conforming date string:
	single whole dates:		yyyy-mm-dd
	month and year dates:	yyyy-mm
	year dates:				yyyy
	ranges:					yyyy-mm-dd/yyyy-mm-dd
							yyyy-mm/yyyy-mm
							yyyy/yyyy

Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.

The input table has:
	year, year2 – always present; if before 1582, ignore months and days if present
	month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 31– proper name dates
	day, day2 –  0 if not provided, 1-31 for days
	
the output table receives:
	rftdate:	an IS8601 formatted date
	rftchron:	a free-form version of the date, usually without year which is in rftdate (season ranges and propername dates)
	rftssn:		one of four season keywords: winter, spring, summer, fall (lowercase)

]]

local function make_COinS_date (input, tCOinS_date)
	local date;																	-- one date or first date in a range
	local date2 = '';															-- end of range date
	
	if 1582 &gt; tonumber(input.year) or 20 &lt; tonumber(input.month) then			-- Julian calendar or season so &amp;rft.date gets year only
		date = input.year;
		if 0 ~= input.year2 and input.year ~= input.year2 then					-- if a range, only the second year portion when not the same as range start year
			date = string.format ('%.4d/%.4d', tonumber(input.year), tonumber(input.year2))		-- assemble the date range
		end
		if 20 &lt; tonumber(input.month) then										-- if season or propername date
			local season = {[21]='winter', [22]='spring', [23]='summer', [24]='fall', [31]='Christmas'};	-- seasons lowercase, no autumn; proper names use title case
			if 0 == input.month2 then											-- single season date
				if 30 &lt;tonumber(input.month) then
					tCOinS_date.rftchron = season[input.month];					-- proper name dates
				else
					tCOinS_date.rftssn = season[input.month];					-- seasons
				end
			else																-- season range with a second season specified
				if input.year ~= input.year2 then								-- season year – season year range or season year–year
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					if 0~= month2 then
						tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);
					end
				else															-- season–season year range
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2];	-- season–season year range
				end
			end
		end
		tCOinS_date.rftdate = date;
		return;																	-- done
	end
	
	if 0 ~= input.day then
		date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day));	-- whole date
	elseif 0 ~= input.month then
		date = string.format ('%s-%.2d', input.year, tonumber(input.month));	-- year and month
	else
		date = string.format ('%s', input.year);								-- just year
	end

	if 0 ~= input.year2 then
		if 0 ~= input.day2 then
			date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2));		-- whole date
		elseif 0 ~= input.month2 then
			date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2));	-- year and month
		else
			date2 = string.format ('/%s', input.year2);							-- just year
		end
	end
	
	tCOinS_date.rftdate = date .. date2;										-- date2 has the '/' separator
	return;
end


--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only
allowed range separator is endash.  Additionally, check the date to see that it is a real date: no 31 in 30-day
months; no 29 February when not a leap year.  Months, both long-form and three character abbreviations, and seasons
must be spelled correctly.  Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and
COinS_date.  When this happens, the date parameter is used in the COinS metadata and the CITEREF identifier gets
its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc.)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is ISO 8601 format date; see make_COInS_date()

]]

local function check_date (date_string, tCOinS_date)
	local year;			-- assume that year2, months, and days are not used;
	local year2=0;		-- second year in a year range
	local month=0;
	local month2=0;		-- second month in a month range
	local day=0;
	local day2=0;		-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then										-- year-initial numerical year month day format
		year, month, day=string.match(date_string, &quot;(%d%d%d%d)%-(%d%d)%-(%d%d)&quot;);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1583 &gt; tonumber(year) then return false; end			-- month number not valid or not Gregorian calendar
		anchor_year = year;

	elseif date_string:match(&quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then						-- month-initial: month day, year
		month, day, anchor_year, year=string.match(date_string, &quot;(%a+)%s*(%d%d?),%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
				
	elseif date_string:match(&quot;^%a+ +[1-9]%d?–[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year=string.match(date_string, &quot;(%a+) +(%d%d?)–(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
		month2=month;																		-- for metadata
		year2=year;

	elseif date_string:match(&quot;^[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then						-- day-initial: day month year
		day, month, anchor_year, year=string.match(date_string, &quot;(%d%d*)%s*(%a+)%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d?–[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year=string.match(date_string, &quot;(%d%d?)–(%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
		month2=month;																		-- for metadata
		year2=year;

	elseif date_string:match(&quot;^[1-9]%d? +%a+ – [1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year=date_string:match(&quot;(%d%d?) +(%a+) – (%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);													-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif date_string:match(&quot;^%a+ +[1-9]%d? – %a+ +[1-9]%d?, +[1-9]%d%d%d?%a?$&quot;) then		-- month initial month-day-range: month day – month day, year;  uses spaced endash
		month, day, month2, day2, anchor_year, year=date_string:match(&quot;(%a+) +(%d%d?) – (%a+) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);													-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif date_string:match(&quot;^[1-9]%d? +%a+ +[1-9]%d%d%d – [1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2=date_string:match(&quot;(%d%d?) +(%a+) +(%d%d%d%d?) – (%d%d?) +(%a+) +((%d%d%d%d?)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end												-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);																		-- for metadata
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d – %a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then		-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
		month, day, year, month2, day2, anchor_year, year2=date_string:match(&quot;(%a+) +(%d%d?), +(%d%d%d%d) – (%a+) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end												-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);																		-- for metadata
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d–%d%d%a?$&quot;) then								-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		local century;
		month, year, century, anchor_year, year2=date_string:match(&quot;(%a+) +((%d%d)%d%d)–((%d%d)%a?)&quot;);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;					-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		year2 = century..year2;																-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		month = get_season_number (month);

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d–[1-9]%d%d%d%a?$&quot;) then						-- special case Winter/Summer year-year; year separated with unspaced endash
		month, year, anchor_year, year2=date_string:match(&quot;(%a+) +(%d%d%d%d)–((%d%d%d%d)%a?)&quot;);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;					-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		month = get_season_number (month);													-- for metadata

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d% – %a+ +[1-9]%d%d%d%a?$&quot;) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2=date_string:match(&quot;(%a+) +(%d%d%d%d) – (%a+) +((%d%d%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end							-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then 	-- both must be month year, same month style
			month = get_month_number(month);
			month2 = get_month_number(month2);
		elseif 0 ~= get_season_number(month) and 0 ~= get_season_number(month2) then		-- both must be or season year, not mixed
			month = get_season_number(month);
			month2 = get_season_number(month2);
		else
			 return false;
		end

	elseif date_string:match (&quot;^%a+–%a+ +[1-9]%d%d%d%a?$&quot;) then					-- month/season range year; months separated by endash 
		month, month2, anchor_year, year=date_string:match (&quot;(%a+)–(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or (not is_valid_year(year)) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
			month2 = get_month_number(month2);
		else
			month = get_season_number(month);
			month2 = get_season_number(month2);
		end
		year2=year;
		
	elseif date_string:match(&quot;^%a+ +%d%d%d%d%a?$&quot;) then							-- month/season year or proper-name year
		month, anchor_year, year=date_string:match(&quot;(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if not is_valid_year(year) then return false; end
		if not is_valid_month_or_season (month) and 0 == is_proper_name (month) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
		elseif 0 ~= get_season_number(month) then
			month = get_season_number(month);
		else
			month = is_proper_name (month);										-- must be proper name; not supported in COinS
		end

	elseif date_string:match(&quot;^[1-9]%d%d%d?–[1-9]%d%d%d?%a?$&quot;) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2=date_string:match(&quot;(%d%d%d%d?)–((%d%d%d%d?)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d–%d%d%a?$&quot;) then						-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2=date_string:match(&quot;((%d%d)%d%d)–((%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century..year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then							-- year; here accept either YYY or YYYY
		anchor_year, year=date_string:match(&quot;((%d%d%d%d?)%a?)&quot;);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;															-- date format not one of the MOS:DATE approved formats
	end

	local result=true;															-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result=is_valid_date(year,month,day);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month2,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year2,month2,day2);
	end
	
	if false == result then return false; end

	if nil ~= tCOinS_date then													-- this table only passed into this function when testing |date= parameter values
		make_COinS_date ({year=year, month=month, day=day, year2=year2, month2=month2, day2=day2}, tCOinS_date);	-- make an ISO 8601 date string for COinS
	end
	
	return true, anchor_year;													-- format is good and date string represents a real date
end	


--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.

]]

local function dates(date_parameters_list, tCOinS_date)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local error_message = &quot;&quot;;
	local good_date = false;
	
	for k, v in pairs(date_parameters_list) do									-- for each date-holding parameter in the list
		if is_set(v) then														-- if the parameter has a value
			if v:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then							-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);					-- get the year portion so it can be tested
				if 'date'==k then
					anchor_year, COinS_date = v:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year'==k then
					good_date = is_valid_year(year);
				end
			elseif 'date'==k then												-- if the parameter is |date=
				if v:match(&quot;^n%.d%.%a?&quot;) then									-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v:match(&quot;^nd%a?$&quot;) then									-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v, tCOinS_date);	-- go test the date
				end
			elseif 'access-date'==k then										-- if the parameter is |date=
				good_date = check_date (v);										-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date = is_valid_accessdate (v);						-- is Wikipedia start date &lt; accessdate &lt; tomorrow's date?
				end
			else																-- any other date-holding parameter
				good_date = check_date (v);										-- go test the date
			end
			if false==good_date then											-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then									-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;						-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;			-- add the failed parameter
			end
		end
	end
	return anchor_year, error_message;											-- and done
end


--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function returns a numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

]]

local function year_date_check (year_string, date_string)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes
	
	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where date and year required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d[%s%-–]+%d%d&quot;) then						-- YYYY-YY date ranges
		local century;
		date1, century, date2 = date_string:match (&quot;((%d%d)%d%d)[%s%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	end
	return result;
end

return {dates = dates, year_date_check = year_date_check}						-- return exported functions</text>
      <sha1>89qtw8wm3cjm3unvxvjxvnewdcbsni3</sha1>
    </revision>
    <revision>
      <id>4828</id>
      <parentid>4827</parentid>
      <timestamp>2016-01-16T13:06:59Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4828</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="37267" sha1="omgk8hdpwapjfd9vn559vl4119tww7m" xml:space="preserve">
local p = {}


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array;																	-- imported function from selected Module:Citation/CS1/Utilities


--[[--------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |accessdate= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

]]

local function is_valid_accessdate (accessdate)
	local lang = mw.getContentLanguage();
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold unix time stamps representing the dates
		
	good1, access_ts = pcall( lang.formatDate, lang, 'U', accessdate );			-- convert accessdate value to unix timesatmp 
	good2, tomorrow_ts = pcall( lang.formatDate, lang, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then
		access_ts = tonumber (access_ts);										-- convert to numbers for the comparison
		tomorrow_ts = tonumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to unix time stamp
	end
	
	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end

--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct. If not a valid month, returns 0

]]

local function get_month_number (month)
local long_months = {['January']=1, ['February']=2, ['March']=3, ['April']=4, ['May']=5, ['June']=6, ['July']=7, ['August']=8, ['September']=9, ['October']=10, ['November']=11, ['December']=12};
local short_months = {['Jan']=1, ['Feb']=2, ['Mar']=3, ['Apr']=4, ['May']=5, ['Jun']=6, ['Jul']=7, ['Aug']=8, ['Sep']=9, ['Oct']=10, ['Nov']=11, ['Dec']=12};
local temp;
	temp=long_months[month];
	if temp then return temp; end				-- if month is the long-form name
	temp=short_months[month];
	if temp then return temp; end				-- if month is the short-form name
	return 0;									-- misspelled, improper case, or not a month name
end

--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 1 for Winter, etc.  Capitalization and spelling must be correct. If not a valid season, returns 0

]]

local function get_season_number (season)
local season_list = {['Winter']=21, ['Spring']=22, ['Summer']=23, ['Fall']=24, ['Autumn']=24};	-- make sure these numbers do not overlap month numbers
local temp;
	temp=season_list[season];
	if temp then return temp; end												-- if season is a valid name return its number
	return 0;																	-- misspelled, improper case, or not a season name
end

--[[--------------------------&lt; I S _ P R O P E R _ N A M E &gt;--------------------------------------------------

returns a non-zero number if date contains a recognized proper name.  Capitalization and spelling must be correct.

]]

local function is_proper_name (name)
local name_list = {['Christmas']=31}
local temp;
	temp=name_list[name];
	if temp then return temp; end				-- if name is a valid name return its number
	return 0;									-- misspelled, improper case, or not a proper name
end

--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ O R _ S E A S O N &gt;------------------------------

--returns true if month or season is valid (properly spelled, capitalized, abbreviated)

]]

local function is_valid_month_or_season (month_season)
	if 0 == get_month_number (month_season) then		-- if month text isn't one of the twelve months, might be a season
		if 0 == get_season_number (month_season) then	-- not a month, is it a season?
			return false;								-- return false not a month or one of the five seasons
		end
	end
	return true;
end

--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one year in the future are not acceptable.

]]
local year_limit;
local function is_valid_year(year)
	if not is_set(year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;			-- global variable so we only have to fetch it once
	end
	return tonumber(year) &lt;= year_limit;				-- false if year is in the future more than one year
end

--[[--------------------------&lt; I S _ V A L I D _ D A T E &gt;----------------------------------------------------
Returns true if day is less than or equal to the number of days in month and year is no farther into the future
than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap
years before 1582 and Gregorian leap years after 1582. Where the two calendars overlap (1582 to approximately
1923) dates are assumed to be Gregorian.

]]

local function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year(year) then												-- no farther into the future than next year
		return false;
	end
	
	month = tonumber(month);													-- required for YYYY-MM-DD dates
	
	if (2==month) then															-- if February
		month_length = 28;														-- then 28 days unless
		if 1582 &gt; tonumber(year) then											-- Julian calendar
			if 0==(year%4) then
				month_length = 29;
			end
		else																	-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then			-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end

--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
There is a special test for May because it can be either short or long form.

Returns true when style for both months is the same

]]

local function is_valid_month_range_style (month1, month2)
local len1 = month1:len();
local len2 = month2:len();
	if len1 == len2 then
		return true;															-- both months are short form so return true
	elseif 'May' == month1 or 'May'== month2 then
		return true;															-- both months are long form so return true
	elseif 3 == len1 or 3 == len2 then
		return false;															-- months are mixed form so return false
	else
		return true;															-- both months are long form so return true
	end
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

Similarly, seasons are also left to right, earliest to latest in time.  There is an oddity with seasons: winter is assigned a value of 1, spring 2, ...,
fall and autumn 4.  Because winter can follow fall/autumn at the end of a calender year, a special test is made to see if |date=Fall-Winter yyyy (4-1) is the date.

]]

local function is_valid_month_season_range(range_start, range_end)
	local range_start_number = get_month_number (range_start);
	
	if 0 == range_start_number then												-- is this a month range?
		local range_start_number = get_season_number (range_start);				-- not a month; is it a season? get start season number
		local range_end_number = get_season_number (range_end);					-- get end season number

		if 0 ~= range_start_number then											-- is start of range a season?
			if range_start_number &lt; range_end_number then						-- range_start is a season
				return true;													-- return true when range_end is also a season and follows start season; else false
			end
			if 24 == range_start_number and 21 == range_end_number then			-- special case when season range is Fall-Winter or Autumn-Winter
				return true;
			end
		end
		return false;		-- range_start is not a month or a season; or range_start is a season and range_end is not; or improper season sequence
	end

	local range_end_number = get_month_number (range_end);						-- get end month number
	if range_start_number &lt; range_end_number then								-- range_start is a month; does range_start precede range_end?
		if is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
		end
	end
	return false;																-- range_start month number is greater than or equal to range end number; or range end isn't a month
end


--[[--------------------------&lt; M A K E _ C O I N S _ D A T E &gt;------------------------------------------------

This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1.  The function is called only for |date= parameters and only if the |date=&lt;value&gt; is 
determined to be a valid date format.  The question of what to do with invalid date formats is not answered here.

The date parts in the input table are converted to an ISO 8601 conforming date string:
	single whole dates:		yyyy-mm-dd
	month and year dates:	yyyy-mm
	year dates:				yyyy
	ranges:					yyyy-mm-dd/yyyy-mm-dd
							yyyy-mm/yyyy-mm
							yyyy/yyyy

Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.

The input table has:
	year, year2 – always present; if before 1582, ignore months and days if present
	month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 31– proper name dates
	day, day2 –  0 if not provided, 1-31 for days
	
the output table receives:
	rftdate:	an IS8601 formatted date
	rftchron:	a free-form version of the date, usually without year which is in rftdate (season ranges and propername dates)
	rftssn:		one of four season keywords: winter, spring, summer, fall (lowercase)

]]

local function make_COinS_date (input, tCOinS_date)
	local date;																	-- one date or first date in a range
	local date2 = '';															-- end of range date
	
	if 1582 &gt; tonumber(input.year) or 20 &lt; tonumber(input.month) then			-- Julian calendar or season so &amp;rft.date gets year only
		date = input.year;
		if 0 ~= input.year2 and input.year ~= input.year2 then					-- if a range, only the second year portion when not the same as range start year
			date = string.format ('%.4d/%.4d', tonumber(input.year), tonumber(input.year2))		-- assemble the date range
		end
		if 20 &lt; tonumber(input.month) then										-- if season or propername date
			local season = {[21]='winter', [22]='spring', [23]='summer', [24]='fall', [31]='Christmas'};	-- seasons lowercase, no autumn; proper names use title case
			if 0 == input.month2 then											-- single season date
				if 30 &lt;tonumber(input.month) then
					tCOinS_date.rftchron = season[input.month];					-- proper name dates
				else
					tCOinS_date.rftssn = season[input.month];					-- seasons
				end
			else																-- season range with a second season specified
				if input.year ~= input.year2 then								-- season year – season year range or season year–year
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					if 0~= input.month2 then
						tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);
					end
				else															-- season–season year range
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2];	-- season–season year range
				end
			end
		end
		tCOinS_date.rftdate = date;
		return;																	-- done
	end
	
	if 0 ~= input.day then
		date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day));	-- whole date
	elseif 0 ~= input.month then
		date = string.format ('%s-%.2d', input.year, tonumber(input.month));	-- year and month
	else
		date = string.format ('%s', input.year);								-- just year
	end

	if 0 ~= input.year2 then
		if 0 ~= input.day2 then
			date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2));		-- whole date
		elseif 0 ~= input.month2 then
			date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2));	-- year and month
		else
			date2 = string.format ('/%s', input.year2);							-- just year
		end
	end
	
	tCOinS_date.rftdate = date .. date2;										-- date2 has the '/' separator
	return;
end


--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only
allowed range separator is endash.  Additionally, check the date to see that it is a real date: no 31 in 30-day
months; no 29 February when not a leap year.  Months, both long-form and three character abbreviations, and seasons
must be spelled correctly.  Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and
COinS_date.  When this happens, the date parameter is used in the COinS metadata and the CITEREF identifier gets
its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc.)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is ISO 8601 format date; see make_COInS_date()

]]

local function check_date (date_string, tCOinS_date)
	local year;			-- assume that year2, months, and days are not used;
	local year2=0;		-- second year in a year range
	local month=0;
	local month2=0;		-- second month in a month range
	local day=0;
	local day2=0;		-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then										-- year-initial numerical year month day format
		year, month, day=string.match(date_string, &quot;(%d%d%d%d)%-(%d%d)%-(%d%d)&quot;);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or 0 == tonumber(day) then return false; end	-- month or day number not valid or not Gregorian calendar
		anchor_year = year;

	elseif date_string:match(&quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then						-- month-initial: month day, year
		month, day, anchor_year, year=string.match(date_string, &quot;(%a+)%s*(%d%d?),%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
				
	elseif date_string:match(&quot;^%a+ +[1-9]%d?–[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year=string.match(date_string, &quot;(%a+) +(%d%d?)–(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
		month2=month;																		-- for metadata
		year2=year;

	elseif date_string:match(&quot;^[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then						-- day-initial: day month year
		day, month, anchor_year, year=string.match(date_string, &quot;(%d%d*)%s*(%a+)%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d?–[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year=string.match(date_string, &quot;(%d%d?)–(%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
		month2=month;																		-- for metadata
		year2=year;

	elseif date_string:match(&quot;^[1-9]%d? +%a+ – [1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year=date_string:match(&quot;(%d%d?) +(%a+) – (%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);													-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif date_string:match(&quot;^%a+ +[1-9]%d? – %a+ +[1-9]%d?, +[1-9]%d%d%d?%a?$&quot;) then		-- month initial month-day-range: month day – month day, year;  uses spaced endash
		month, day, month2, day2, anchor_year, year=date_string:match(&quot;(%a+) +(%d%d?) – (%a+) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);													-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif date_string:match(&quot;^[1-9]%d? +%a+ +[1-9]%d%d%d – [1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2=date_string:match(&quot;(%d%d?) +(%a+) +(%d%d%d%d?) – (%d%d?) +(%a+) +((%d%d%d%d?)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end												-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);																		-- for metadata
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d – %a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then		-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
		month, day, year, month2, day2, anchor_year, year2=date_string:match(&quot;(%a+) +(%d%d?), +(%d%d%d%d) – (%a+) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end												-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);																		-- for metadata
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d–%d%d%a?$&quot;) then								-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		local century;
		month, year, century, anchor_year, year2=date_string:match(&quot;(%a+) +((%d%d)%d%d)–((%d%d)%a?)&quot;);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;					-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		year2 = century..year2;																-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		month = get_season_number (month);

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d–[1-9]%d%d%d%a?$&quot;) then						-- special case Winter/Summer year-year; year separated with unspaced endash
		month, year, anchor_year, year2=date_string:match(&quot;(%a+) +(%d%d%d%d)–((%d%d%d%d)%a?)&quot;);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;					-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		month = get_season_number (month);													-- for metadata

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d% – %a+ +[1-9]%d%d%d%a?$&quot;) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2=date_string:match(&quot;(%a+) +(%d%d%d%d) – (%a+) +((%d%d%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end							-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then 	-- both must be month year, same month style
			month = get_month_number(month);
			month2 = get_month_number(month2);
		elseif 0 ~= get_season_number(month) and 0 ~= get_season_number(month2) then		-- both must be or season year, not mixed
			month = get_season_number(month);
			month2 = get_season_number(month2);
		else
			 return false;
		end

	elseif date_string:match (&quot;^%a+–%a+ +[1-9]%d%d%d%a?$&quot;) then					-- month/season range year; months separated by endash 
		month, month2, anchor_year, year=date_string:match (&quot;(%a+)–(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or (not is_valid_year(year)) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
			month2 = get_month_number(month2);
		else
			month = get_season_number(month);
			month2 = get_season_number(month2);
		end
		year2=year;
		
	elseif date_string:match(&quot;^%a+ +%d%d%d%d%a?$&quot;) then							-- month/season year or proper-name year
		month, anchor_year, year=date_string:match(&quot;(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if not is_valid_year(year) then return false; end
		if not is_valid_month_or_season (month) and 0 == is_proper_name (month) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
		elseif 0 ~= get_season_number(month) then
			month = get_season_number(month);
		else
			month = is_proper_name (month);										-- must be proper name; not supported in COinS
		end

	elseif date_string:match(&quot;^[1-9]%d%d%d?–[1-9]%d%d%d?%a?$&quot;) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2=date_string:match(&quot;(%d%d%d%d?)–((%d%d%d%d?)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d–%d%d%a?$&quot;) then						-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2=date_string:match(&quot;((%d%d)%d%d)–((%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century..year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then							-- year; here accept either YYY or YYYY
		anchor_year, year=date_string:match(&quot;((%d%d%d%d?)%a?)&quot;);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;															-- date format not one of the MOS:DATE approved formats
	end

	local result=true;															-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result=is_valid_date(year,month,day);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month2,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year2,month2,day2);
	end
	
	if false == result then return false; end

	if nil ~= tCOinS_date then													-- this table only passed into this function when testing |date= parameter values
		make_COinS_date ({year=year, month=month, day=day, year2=year2, month2=month2, day2=day2}, tCOinS_date);	-- make an ISO 8601 date string for COinS
	end
	
	return true, anchor_year;													-- format is good and date string represents a real date
end	


--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.

]]

local function dates(date_parameters_list, tCOinS_date)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local error_message = &quot;&quot;;
	local good_date = false;
	
	for k, v in pairs(date_parameters_list) do									-- for each date-holding parameter in the list
		if is_set(v) then														-- if the parameter has a value
			if v:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then							-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);					-- get the year portion so it can be tested
				if 'date'==k then
					anchor_year, COinS_date = v:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year'==k then
					good_date = is_valid_year(year);
				end
			elseif 'date'==k then												-- if the parameter is |date=
				if v:match(&quot;^n%.d%.%a?&quot;) then									-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v:match(&quot;^nd%a?$&quot;) then									-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v, tCOinS_date);	-- go test the date
				end
			elseif 'access-date'==k then										-- if the parameter is |date=
				good_date = check_date (v);										-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date = is_valid_accessdate (v);						-- is Wikipedia start date &lt; accessdate &lt; tomorrow's date?
				end
			else																-- any other date-holding parameter
				good_date = check_date (v);										-- go test the date
			end
			if false==good_date then											-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then									-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;						-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;			-- add the failed parameter
			end
		end
	end
	return anchor_year, error_message;											-- and done
end


--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function returns a numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

]]

local function year_date_check (year_string, date_string)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes
	
	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where both date and year are required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard range formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d–%d%d&quot;) then								-- YYYY-YY date ranges
		local century;
		date1, century, date2 = date_string:match (&quot;((%d%d)%d%d)[%s%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	else
		result = 0;																-- no recognizable year in date
	end
	return result;
end


--[[-------------------------&lt; R E F O R M A T   T A B L E S &gt;------------------------------------------------

These table are used exclusively for reformatting dates

]]

local source_patterns = {						-- this table holds patterns that match allowed date formats used to extract date components
	['dmy'] = '(%d%d?)%s+(%a+)%s+(%d%d%d%d)',
	['mdy'] = '(%a+)%s+(%d%d?),%s+(%d%d%d%d)',
	['ymd'] = '(%d%d%d%d)%-(%d%d)-(%d%d)',
	}

local short_formats = {							-- this table holds format strings used by os.date() for short month names
	['dmy'] = '%e %b %Y',
	['mdy'] = '%b %e, %Y',
	['ymd'] = '%F',
	}

local long_formats = {							-- this table holds format strings used by os.date() for long month names
	['dmy'] = '%e %B %Y',
	['mdy'] = '%B %e, %Y',
	['ymd'] = '%F',
	}


--[[-------------------------&lt; G E T _ D M Y _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from DMY formatted date, places them in the source_date table, and returns.

]]

local function get_dmy_date_parts (date, source_date)
	source_date.day, source_date.month, source_date.year = date:match (source_patterns['dmy']);	-- get date components as strings
	source_date.month = get_month_number (source_date.month);					-- get month number
end


--[[-------------------------&lt; G E T _ M D Y _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from MDY formatted date, places them in the source_date table, and returns.

]]

local function get_mdy_date_parts (date, source_date)
	source_date.month, source_date.day, source_date.year = date:match (source_patterns['mdy']);	-- get date components as strings
	source_date.month = get_month_number (source_date.month);					-- get month number
end


--[[-------------------------&lt; G E T _ Y M D _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from YMD formatted date, places them in the source_date table, and returns.

]]

local function get_ymd_date_parts (date, source_date)
	source_date.year, source_date.month, source_date.day = date:match (source_patterns['ymd']);	-- get date components as strings
end


--[[-------------------------&lt; R E F O R M A T _ D A T E S &gt;--------------------------------------------------

Reformats existing dates into the format specified by format and short.

format is one of several keywords: dmy, dmy-all, mdy, mdy-all, ymd, ymd-all.  The all version includes access- and
archive-dates; otherwise these dates are not reformatted

Date ranges, season dates, proper name dates are not currently supported.

]]

local function reformat_dates (date_parameters_list, format, short)
	local all = false;															-- set to false to skip access- and archive-dates
	local format_str;
	local source_date = {};
	
	if format:match('%a+%-all') then
		format = format:match('(%a+)%-all');									-- extract the format
		all = true;																-- set to true to format access- and archive-dates
	end
	
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val) then												-- if the parameter has a value
			if not all and in_array (param_name, {'access-date', 'archive-date'}) then	-- if access- or archive-date and format not xxx-all
				param_val = '';													-- set to empty string so we don't process this date
			end
			for source, pattern in pairs(source_patterns) do
				if param_val:match(pattern) then
					if 'ymd' == source then
						get_ymd_date_parts (param_val, source_date);			-- get the date parts into the source_date table
					elseif 'dmy' == source then
						get_dmy_date_parts (param_val, source_date);			-- get the date parts into the source_date table
					elseif 'mdy' == source then
						get_mdy_date_parts (param_val, source_date);			-- get the date parts into the source_date table
					end

					if 'ymd' == format and 1582 &gt; tonumber(source_date.year) then	-- ymd format dates not allowed before 1582
						return false;											-- abandon reformatting
					end
					
					if short then
						format_str = short_formats[format];
					else
						format_str = long_formats[format];
					end
					
					date_parameters_list[param_name] = os.date (format_str, os.time(source_date));	-- convert date and save
				end
			end
		end
	end
	return true;																-- declare success and done
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (utilities_page_ptr)
	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;											-- import functions from select Module:Citation/CS1/Utilities module
end



return {																		-- return exported functions
	dates = dates,
	year_date_check = year_date_check,
	reformat_dates = reformat_dates,
	set_selected_modules = set_selected_modules
	}</text>
      <sha1>omgk8hdpwapjfd9vn559vl4119tww7m</sha1>
    </revision>
    <revision>
      <id>4829</id>
      <parentid>4828</parentid>
      <timestamp>2016-02-20T11:35:33Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4829</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="37691" sha1="eml3extfcz3aj9ffxcj9uxoeb801a4z" xml:space="preserve">
local p = {}


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array;																	-- imported function from selected Module:Citation/CS1/Utilities


--[=[-------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |accessdate= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work for languages other than English.  Wikimedia #time: parser apparently doesn't understand
non-Engish date month names. This function will always return false when the date contains a non-English month name
because good1 is false after the call to lang.formatDate.

For the time being, to use this function, supply it with YYYY-MM-DD format dates.  See
[[bs:Modul:Citation/CS1/Date validation/igralište]] for one possible solution.

]=]

local function is_valid_accessdate (accessdate)
	local lang = mw.getContentLanguage();
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold unix time stamps representing the dates
		
	good1, access_ts = pcall( lang.formatDate, lang, 'U', accessdate );			-- convert accessdate value to unix timesatmp 
	good2, tomorrow_ts = pcall( lang.formatDate, lang, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then
		access_ts = tonumber (access_ts);										-- convert to numbers for the comparison
		tomorrow_ts = tonumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to unix time stamp
	end
	
	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end

--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct. If not a valid month, returns 0

]]

local function get_month_number (month)
local long_months = {['January']=1, ['February']=2, ['March']=3, ['April']=4, ['May']=5, ['June']=6, ['July']=7, ['August']=8, ['September']=9, ['October']=10, ['November']=11, ['December']=12};
local short_months = {['Jan']=1, ['Feb']=2, ['Mar']=3, ['Apr']=4, ['May']=5, ['Jun']=6, ['Jul']=7, ['Aug']=8, ['Sep']=9, ['Oct']=10, ['Nov']=11, ['Dec']=12};
	return long_months[month] or												-- if month is the long-form name
		short_months[month] or													-- if month is the short-form name
		0;																		-- misspelled, improper case, or not a month name
end

--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 1 for Winter, etc.  Capitalization and spelling must be correct. If not a valid season, returns 0

]]

local function get_season_number (season)
local season_list = {['Winter']=21, ['Spring']=22, ['Summer']=23, ['Fall']=24, ['Autumn']=24};	-- make sure these numbers do not overlap month numbers
local temp;
	temp=season_list[season];
	if temp then return temp; end												-- if season is a valid name return its number
	return 0;																	-- misspelled, improper case, or not a season name
end

--[[--------------------------&lt; I S _ P R O P E R _ N A M E &gt;--------------------------------------------------

returns a non-zero number if date contains a recognized proper name.  Capitalization and spelling must be correct.

]]

local function is_proper_name (name)
local name_list = {['Christmas']=31}
local temp;
	temp=name_list[name];
	if temp then return temp; end				-- if name is a valid name return its number
	return 0;									-- misspelled, improper case, or not a proper name
end

--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ O R _ S E A S O N &gt;------------------------------

--returns true if month or season is valid (properly spelled, capitalized, abbreviated)

]]

local function is_valid_month_or_season (month_season)
	if 0 == get_month_number (month_season) then		-- if month text isn't one of the twelve months, might be a season
		if 0 == get_season_number (month_season) then	-- not a month, is it a season?
			return false;								-- return false not a month or one of the five seasons
		end
	end
	return true;
end

--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one year in the future are not acceptable.

]]
local year_limit;
local function is_valid_year(year)
	if not is_set(year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;			-- global variable so we only have to fetch it once
	end
	return tonumber(year) &lt;= year_limit;				-- false if year is in the future more than one year
end

--[[--------------------------&lt; I S _ V A L I D _ D A T E &gt;----------------------------------------------------
Returns true if day is less than or equal to the number of days in month and year is no farther into the future
than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap
years before 1582 and Gregorian leap years after 1582. Where the two calendars overlap (1582 to approximately
1923) dates are assumed to be Gregorian.

]]

local function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year(year) then												-- no farther into the future than next year
		return false;
	end
	
	month = tonumber(month);													-- required for YYYY-MM-DD dates
	
	if (2==month) then															-- if February
		month_length = 28;														-- then 28 days unless
		if 1582 &gt; tonumber(year) then											-- Julian calendar
			if 0==(year%4) then
				month_length = 29;
			end
		else																	-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then			-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end

--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
There is a special test for May because it can be either short or long form.

Returns true when style for both months is the same

]]

local function is_valid_month_range_style (month1, month2)
local len1 = month1:len();
local len2 = month2:len();
	if len1 == len2 then
		return true;															-- both months are short form so return true
	elseif 'May' == month1 or 'May'== month2 then
		return true;															-- both months are long form so return true
	elseif 3 == len1 or 3 == len2 then
		return false;															-- months are mixed form so return false
	else
		return true;															-- both months are long form so return true
	end
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

Similarly, seasons are also left to right, earliest to latest in time.  There is an oddity with seasons: winter is assigned a value of 1, spring 2, ...,
fall and autumn 4.  Because winter can follow fall/autumn at the end of a calender year, a special test is made to see if |date=Fall-Winter yyyy (4-1) is the date.

]]

local function is_valid_month_season_range(range_start, range_end)
	local range_start_number = get_month_number (range_start);
	local range_end_number;
	
	if 0 == range_start_number then												-- is this a month range?
		local range_start_number = get_season_number (range_start);				-- not a month; is it a season? get start season number
		range_end_number = get_season_number (range_end);						-- get end season number

		if 0 ~= range_start_number then											-- is start of range a season?
			if range_start_number &lt; range_end_number then						-- range_start is a season
				return true;													-- return true when range_end is also a season and follows start season; else false
			end
			if 24 == range_start_number and 21 == range_end_number then			-- special case when season range is Fall-Winter or Autumn-Winter
				return true;
			end
		end
		return false;		-- range_start is not a month or a season; or range_start is a season and range_end is not; or improper season sequence
	end

	range_end_number = get_month_number (range_end);							-- get end month number
	if range_start_number &lt; range_end_number then								-- range_start is a month; does range_start precede range_end?
		if is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
		end
	end
	return false;																-- range_start month number is greater than or equal to range end number; or range end isn't a month
end


--[[--------------------------&lt; M A K E _ C O I N S _ D A T E &gt;------------------------------------------------

This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1.  The function is called only for |date= parameters and only if the |date=&lt;value&gt; is 
determined to be a valid date format.  The question of what to do with invalid date formats is not answered here.

The date parts in the input table are converted to an ISO 8601 conforming date string:
	single whole dates:		yyyy-mm-dd
	month and year dates:	yyyy-mm
	year dates:				yyyy
	ranges:					yyyy-mm-dd/yyyy-mm-dd
							yyyy-mm/yyyy-mm
							yyyy/yyyy

Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.

The input table has:
	year, year2 – always present; if before 1582, ignore months and days if present
	month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 31– proper name dates
	day, day2 –  0 if not provided, 1-31 for days
	
the output table receives:
	rftdate:	an IS8601 formatted date
	rftchron:	a free-form version of the date, usually without year which is in rftdate (season ranges and propername dates)
	rftssn:		one of four season keywords: winter, spring, summer, fall (lowercase)

]]

local function make_COinS_date (input, tCOinS_date)
	local date;																	-- one date or first date in a range
	local date2 = '';															-- end of range date
	
	if 1582 &gt; tonumber(input.year) or 20 &lt; tonumber(input.month) then			-- Julian calendar or season so &amp;rft.date gets year only
		date = input.year;
		if 0 ~= input.year2 and input.year ~= input.year2 then					-- if a range, only the second year portion when not the same as range start year
			date = string.format ('%.4d/%.4d', tonumber(input.year), tonumber(input.year2))		-- assemble the date range
		end
		if 20 &lt; tonumber(input.month) then										-- if season or propername date
			local season = {[21]='winter', [22]='spring', [23]='summer', [24]='fall', [31]='Christmas'};	-- seasons lowercase, no autumn; proper names use title case
			if 0 == input.month2 then											-- single season date
				if 30 &lt;tonumber(input.month) then
					tCOinS_date.rftchron = season[input.month];					-- proper name dates
				else
					tCOinS_date.rftssn = season[input.month];					-- seasons
				end
			else																-- season range with a second season specified
				if input.year ~= input.year2 then								-- season year – season year range or season year–year
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					if 0~= input.month2 then
						tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);
					end
				else															-- season–season year range
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2];	-- season–season year range
				end
			end
		end
		tCOinS_date.rftdate = date;
		return;																	-- done
	end
	
	if 0 ~= input.day then
		date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day));	-- whole date
	elseif 0 ~= input.month then
		date = string.format ('%s-%.2d', input.year, tonumber(input.month));	-- year and month
	else
		date = string.format ('%s', input.year);								-- just year
	end

	if 0 ~= input.year2 then
		if 0 ~= input.day2 then
			date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2));		-- whole date
		elseif 0 ~= input.month2 then
			date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2));	-- year and month
		else
			date2 = string.format ('/%s', input.year2);							-- just year
		end
	end
	
	tCOinS_date.rftdate = date .. date2;										-- date2 has the '/' separator
	return;
end


--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only
allowed range separator is endash.  Additionally, check the date to see that it is a real date: no 31 in 30-day
months; no 29 February when not a leap year.  Months, both long-form and three character abbreviations, and seasons
must be spelled correctly.  Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and
COinS_date.  When this happens, the date parameter is used in the COinS metadata and the CITEREF identifier gets
its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc.)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is ISO 8601 format date; see make_COInS_date()

]]

local function check_date (date_string, tCOinS_date)
	local year;			-- assume that year2, months, and days are not used;
	local year2=0;		-- second year in a year range
	local month=0;
	local month2=0;		-- second month in a month range
	local day=0;
	local day2=0;		-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then										-- year-initial numerical year month day format
		year, month, day=string.match(date_string, &quot;(%d%d%d%d)%-(%d%d)%-(%d%d)&quot;);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or 0 == tonumber(day) then return false; end	-- month or day number not valid or not Gregorian calendar
		anchor_year = year;

	elseif date_string:match(&quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then						-- month-initial: month day, year
		month, day, anchor_year, year=string.match(date_string, &quot;(%a+)%s*(%d%d?),%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
				
	elseif date_string:match(&quot;^%a+ +[1-9]%d?–[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year=string.match(date_string, &quot;(%a+) +(%d%d?)–(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
		month2=month;																		-- for metadata
		year2=year;

	elseif date_string:match(&quot;^[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then						-- day-initial: day month year
		day, month, anchor_year, year=string.match(date_string, &quot;(%d%d*)%s*(%a+)%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d?–[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year=string.match(date_string, &quot;(%d%d?)–(%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
		month2=month;																		-- for metadata
		year2=year;

	elseif date_string:match(&quot;^[1-9]%d? +%a+ – [1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year=date_string:match(&quot;(%d%d?) +(%a+) – (%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);													-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif date_string:match(&quot;^%a+ +[1-9]%d? – %a+ +[1-9]%d?, +[1-9]%d%d%d?%a?$&quot;) then		-- month initial month-day-range: month day – month day, year;  uses spaced endash
		month, day, month2, day2, anchor_year, year=date_string:match(&quot;(%a+) +(%d%d?) – (%a+) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);													-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif date_string:match(&quot;^[1-9]%d? +%a+ +[1-9]%d%d%d – [1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2=date_string:match(&quot;(%d%d?) +(%a+) +(%d%d%d%d?) – (%d%d?) +(%a+) +((%d%d%d%d?)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end												-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);																		-- for metadata
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d – %a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then		-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
		month, day, year, month2, day2, anchor_year, year2=date_string:match(&quot;(%a+) +(%d%d?), +(%d%d%d%d) – (%a+) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end												-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);																		-- for metadata
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d–%d%d%a?$&quot;) then								-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		local century;
		month, year, century, anchor_year, year2=date_string:match(&quot;(%a+) +((%d%d)%d%d)–((%d%d)%a?)&quot;);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;					-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		year2 = century..year2;																-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		month = get_season_number (month);

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d–[1-9]%d%d%d%a?$&quot;) then						-- special case Winter/Summer year-year; year separated with unspaced endash
		month, year, anchor_year, year2=date_string:match(&quot;(%a+) +(%d%d%d%d)–((%d%d%d%d)%a?)&quot;);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;					-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		month = get_season_number (month);													-- for metadata

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d% – %a+ +[1-9]%d%d%d%a?$&quot;) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2=date_string:match(&quot;(%a+) +(%d%d%d%d) – (%a+) +((%d%d%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end							-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then 	-- both must be month year, same month style
			month = get_month_number(month);
			month2 = get_month_number(month2);
		elseif 0 ~= get_season_number(month) and 0 ~= get_season_number(month2) then		-- both must be or season year, not mixed
			month = get_season_number(month);
			month2 = get_season_number(month2);
		else
			 return false;
		end

	elseif date_string:match (&quot;^%a+–%a+ +[1-9]%d%d%d%a?$&quot;) then					-- month/season range year; months separated by endash 
		month, month2, anchor_year, year=date_string:match (&quot;(%a+)–(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or (not is_valid_year(year)) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
			month2 = get_month_number(month2);
		else
			month = get_season_number(month);
			month2 = get_season_number(month2);
		end
		year2=year;
		
	elseif date_string:match(&quot;^%a+ +%d%d%d%d%a?$&quot;) then							-- month/season year or proper-name year
		month, anchor_year, year=date_string:match(&quot;(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if not is_valid_year(year) then return false; end
		if not is_valid_month_or_season (month) and 0 == is_proper_name (month) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
		elseif 0 ~= get_season_number(month) then
			month = get_season_number(month);
		else
			month = is_proper_name (month);										-- must be proper name; not supported in COinS
		end

	elseif date_string:match(&quot;^[1-9]%d%d%d?–[1-9]%d%d%d?%a?$&quot;) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2=date_string:match(&quot;(%d%d%d%d?)–((%d%d%d%d?)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d–%d%d%a?$&quot;) then						-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2=date_string:match(&quot;((%d%d)%d%d)–((%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century..year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then							-- year; here accept either YYY or YYYY
		anchor_year, year=date_string:match(&quot;((%d%d%d%d?)%a?)&quot;);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;															-- date format not one of the MOS:DATE approved formats
	end

	local result=true;															-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result=is_valid_date(year,month,day);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month2,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year2,month2,day2);
	end
	
	if false == result then return false; end

	if nil ~= tCOinS_date then													-- this table only passed into this function when testing |date= parameter values
		make_COinS_date ({year=year, month=month, day=day, year2=year2, month2=month2, day2=day2}, tCOinS_date);	-- make an ISO 8601 date string for COinS
	end
	
	return true, anchor_year;													-- format is good and date string represents a real date
end	


--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.

]]

local function dates(date_parameters_list, tCOinS_date)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local error_message = &quot;&quot;;
	local good_date = false;
	
	for k, v in pairs(date_parameters_list) do									-- for each date-holding parameter in the list
		if is_set(v) then														-- if the parameter has a value
			if v:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then							-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);					-- get the year portion so it can be tested
				if 'date'==k then
					anchor_year, COinS_date = v:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year'==k then
					good_date = is_valid_year(year);
				end
			elseif 'date'==k then												-- if the parameter is |date=
				if v:match(&quot;^n%.d%.%a?&quot;) then									-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v:match(&quot;^nd%a?$&quot;) then									-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v, tCOinS_date);	-- go test the date
				end
			elseif 'access-date'==k then										-- if the parameter is |date=
				good_date = check_date (v);										-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date = is_valid_accessdate (v);						-- is Wikipedia start date &lt; accessdate &lt; tomorrow's date?
				end
			else																-- any other date-holding parameter
				good_date = check_date (v);										-- go test the date
			end
			if false==good_date then											-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then									-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;						-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;			-- add the failed parameter
			end
		end
	end
	return anchor_year, error_message;											-- and done
end


--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function returns a numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

]]

local function year_date_check (year_string, date_string)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes
	
	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where both date and year are required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard range formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d–%d%d&quot;) then								-- YYYY-YY date ranges
		local century;
		date1, century, date2 = date_string:match (&quot;((%d%d)%d%d)[%s%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	else
		result = 0;																-- no recognizable year in date
	end
	return result;
end


--[[-------------------------&lt; R E F O R M A T   T A B L E S &gt;------------------------------------------------

These table are used exclusively for reformatting dates

]]

local source_patterns = {						-- this table holds patterns that match allowed date formats used to extract date components
	['dmy'] = '(%d%d?)%s+(%a+)%s+(%d%d%d%d)',
	['mdy'] = '(%a+)%s+(%d%d?),%s+(%d%d%d%d)',
	['ymd'] = '(%d%d%d%d)%-(%d%d)-(%d%d)',
	}

local short_formats = {							-- this table holds format strings used by os.date() for short month names
	['dmy'] = '%e %b %Y',
	['mdy'] = '%b %e, %Y',
	['ymd'] = '%F',
	}

local long_formats = {							-- this table holds format strings used by os.date() for long month names
	['dmy'] = '%e %B %Y',
	['mdy'] = '%B %e, %Y',
	['ymd'] = '%F',
	}


--[[-------------------------&lt; G E T _ D M Y _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from DMY formatted date, places them in the source_date table, and returns.

]]

local function get_dmy_date_parts (date, source_date)
	source_date.day, source_date.month, source_date.year = date:match (source_patterns['dmy']);	-- get date components as strings
	source_date.month = get_month_number (source_date.month);					-- get month number
end


--[[-------------------------&lt; G E T _ M D Y _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from MDY formatted date, places them in the source_date table, and returns.

]]

local function get_mdy_date_parts (date, source_date)
	source_date.month, source_date.day, source_date.year = date:match (source_patterns['mdy']);	-- get date components as strings
	source_date.month = get_month_number (source_date.month);					-- get month number
end


--[[-------------------------&lt; G E T _ Y M D _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from YMD formatted date, places them in the source_date table, and returns.

]]

local function get_ymd_date_parts (date, source_date)
	source_date.year, source_date.month, source_date.day = date:match (source_patterns['ymd']);	-- get date components as strings
end


--[[-------------------------&lt; R E F O R M A T _ D A T E S &gt;--------------------------------------------------

Reformats existing dates into the format specified by format and short.

format is one of several keywords: dmy, dmy-all, mdy, mdy-all, ymd, ymd-all.  The all version includes access- and
archive-dates; otherwise these dates are not reformatted

Date ranges, season dates, proper name dates are not currently supported.

]]

local function reformat_dates (date_parameters_list, format, short)
	local all = false;															-- set to false to skip access- and archive-dates
	local format_str;
	local source_date = {};
	
	if format:match('%a+%-all') then
		format = format:match('(%a+)%-all');									-- extract the format
		all = true;																-- set to true to format access- and archive-dates
	end
	
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val) then												-- if the parameter has a value
			if not all and in_array (param_name, {'access-date', 'archive-date'}) then	-- if access- or archive-date and format not xxx-all
				param_val = '';													-- set to empty string so we don't process this date
			end
			for source, pattern in pairs(source_patterns) do
				if param_val:match(pattern) then
					if 'ymd' == source then
						get_ymd_date_parts (param_val, source_date);			-- get the date parts into the source_date table
					elseif 'dmy' == source then
						get_dmy_date_parts (param_val, source_date);			-- get the date parts into the source_date table
					elseif 'mdy' == source then
						get_mdy_date_parts (param_val, source_date);			-- get the date parts into the source_date table
					end

					if 'ymd' == format and 1582 &gt; tonumber(source_date.year) then	-- ymd format dates not allowed before 1582
						return false;											-- abandon reformatting
					end
					
					if short then
						format_str = short_formats[format];
					else
						format_str = long_formats[format];
					end
					
					date_parameters_list[param_name] = os.date (format_str, os.time(source_date));	-- convert date and save
				end
			end
		end
	end
	return true;																-- declare success and done
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (utilities_page_ptr)
	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;											-- import functions from select Module:Citation/CS1/Utilities module
end



return {																		-- return exported functions
	dates = dates,
	year_date_check = year_date_check,
	reformat_dates = reformat_dates,
	set_selected_modules = set_selected_modules
	}</text>
      <sha1>eml3extfcz3aj9ffxcj9uxoeb801a4z</sha1>
    </revision>
    <revision>
      <id>4830</id>
      <parentid>4829</parentid>
      <timestamp>2016-04-16T10:51:59Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4830</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="38928" sha1="8rvoa9e567nj697fb82u7ogxqwck7qp" xml:space="preserve">
local p = {}


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array;																	-- imported function from selected Module:Citation/CS1/Utilities


--[=[-------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |accessdate= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work for languages other than English.  Wikimedia #time: parser apparently doesn't understand
non-Engish date month names. This function will always return false when the date contains a non-English month name
because good1 is false after the call to lang.formatDate.

For the time being, to use this function, supply it with YYYY-MM-DD format dates.  See
[[bs:Modul:Citation/CS1/Date validation/igralište]] for one possible solution.

]=]

local function is_valid_accessdate (accessdate)
	local lang = mw.getContentLanguage();
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold unix time stamps representing the dates
		
	good1, access_ts = pcall( lang.formatDate, lang, 'U', accessdate );			-- convert accessdate value to unix timesatmp 
	good2, tomorrow_ts = pcall( lang.formatDate, lang, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then
		access_ts = tonumber (access_ts);										-- convert to numbers for the comparison
		tomorrow_ts = tonumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to unix time stamp
	end
	
	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end


--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct. If not a valid month, returns 0

]]

local function get_month_number (month)
local long_months = {['January']=1, ['February']=2, ['March']=3, ['April']=4, ['May']=5, ['June']=6, ['July']=7, ['August']=8, ['September']=9, ['October']=10, ['November']=11, ['December']=12};
local short_months = {['Jan']=1, ['Feb']=2, ['Mar']=3, ['Apr']=4, ['May']=5, ['Jun']=6, ['Jul']=7, ['Aug']=8, ['Sep']=9, ['Oct']=10, ['Nov']=11, ['Dec']=12};
	return long_months[month] or												-- if month is the long-form name
		short_months[month] or													-- if month is the short-form name
		0;																		-- misspelled, improper case, or not a month name
end


--[[--------------------------&lt; I S _ V A L I D _ E M B A R G O _ D A T E &gt;------------------------------------

returns true and date value if that value has proper dmy, mdy, ymd format.

returns false and 9999 when date value is not proper format; assumes that when |embargo= is set, the editor
intended to embargo a pmc but |embargo does not hold a single date.

]]

local function is_valid_embargo_date (v)
	if v:match ('^%d%d%d%d%-%d%d%-%d%d$') or									-- ymd
		v:match ('^%d%d?%s+%a+%s+%d%d%d%d$') or									-- dmy
		v:match ('^%a+%s+%d%d?%s*,%s*%d%d%d%d$') then							-- mdy
			return true, v;
	end
	return false, '9999';														-- if here not good date so return false and set embargo date to long time in future
end


--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 1 for Winter, etc.  Capitalization and spelling must be correct. If not a valid season, returns 0

]]

local function get_season_number (season)
local season_list = {['Winter']=21, ['Spring']=22, ['Summer']=23, ['Fall']=24, ['Autumn']=24};	-- make sure these numbers do not overlap month numbers
local temp;
	temp=season_list[season];
	if temp then return temp; end												-- if season is a valid name return its number
	return 0;																	-- misspelled, improper case, or not a season name
end

--[[--------------------------&lt; I S _ P R O P E R _ N A M E &gt;--------------------------------------------------

returns a non-zero number if date contains a recognized proper name.  Capitalization and spelling must be correct.

]]

local function is_proper_name (name)
local name_list = {['Christmas']=31}
local temp;
	temp=name_list[name];
	if temp then return temp; end				-- if name is a valid name return its number
	return 0;									-- misspelled, improper case, or not a proper name
end

--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ O R _ S E A S O N &gt;------------------------------

--returns true if month or season is valid (properly spelled, capitalized, abbreviated)

]]

local function is_valid_month_or_season (month_season)
	if 0 == get_month_number (month_season) then		-- if month text isn't one of the twelve months, might be a season
		if 0 == get_season_number (month_season) then	-- not a month, is it a season?
			return false;								-- return false not a month or one of the five seasons
		end
	end
	return true;
end

--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one year in the future are not acceptable.

]]
local year_limit;
local function is_valid_year(year)
	if not is_set(year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;			-- global variable so we only have to fetch it once
	end
	return tonumber(year) &lt;= year_limit;				-- false if year is in the future more than one year
end

--[[--------------------------&lt; I S _ V A L I D _ D A T E &gt;----------------------------------------------------
Returns true if day is less than or equal to the number of days in month and year is no farther into the future
than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap
years before 1582 and Gregorian leap years after 1582. Where the two calendars overlap (1582 to approximately
1923) dates are assumed to be Gregorian.

]]

local function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year(year) then												-- no farther into the future than next year
		return false;
	end
	
	month = tonumber(month);													-- required for YYYY-MM-DD dates
	
	if (2==month) then															-- if February
		month_length = 28;														-- then 28 days unless
		if 1582 &gt; tonumber(year) then											-- Julian calendar
			if 0==(year%4) then
				month_length = 29;
			end
		else																	-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then			-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end

--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
There is a special test for May because it can be either short or long form.

Returns true when style for both months is the same

]]

local function is_valid_month_range_style (month1, month2)
local len1 = month1:len();
local len2 = month2:len();
	if len1 == len2 then
		return true;															-- both months are short form so return true
	elseif 'May' == month1 or 'May'== month2 then
		return true;															-- both months are long form so return true
	elseif 3 == len1 or 3 == len2 then
		return false;															-- months are mixed form so return false
	else
		return true;															-- both months are long form so return true
	end
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

Similarly, seasons are also left to right, earliest to latest in time.  There is an oddity with seasons: winter is assigned a value of 1, spring 2, ...,
fall and autumn 4.  Because winter can follow fall/autumn at the end of a calender year, a special test is made to see if |date=Fall-Winter yyyy (4-1) is the date.

]]

local function is_valid_month_season_range(range_start, range_end)
	local range_start_number = get_month_number (range_start);
	local range_end_number;
	
	if 0 == range_start_number then												-- is this a month range?
		local range_start_number = get_season_number (range_start);				-- not a month; is it a season? get start season number
		range_end_number = get_season_number (range_end);						-- get end season number

		if 0 ~= range_start_number then											-- is start of range a season?
			if range_start_number &lt; range_end_number then						-- range_start is a season
				return true;													-- return true when range_end is also a season and follows start season; else false
			end
			if 24 == range_start_number and 21 == range_end_number then			-- special case when season range is Fall-Winter or Autumn-Winter
				return true;
			end
		end
		return false;		-- range_start is not a month or a season; or range_start is a season and range_end is not; or improper season sequence
	end

	range_end_number = get_month_number (range_end);							-- get end month number
	if range_start_number &lt; range_end_number then								-- range_start is a month; does range_start precede range_end?
		if is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
		end
	end
	return false;																-- range_start month number is greater than or equal to range end number; or range end isn't a month
end


--[[--------------------------&lt; M A K E _ C O I N S _ D A T E &gt;------------------------------------------------

This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1.  The function is called only for |date= parameters and only if the |date=&lt;value&gt; is 
determined to be a valid date format.  The question of what to do with invalid date formats is not answered here.

The date parts in the input table are converted to an ISO 8601 conforming date string:
	single whole dates:		yyyy-mm-dd
	month and year dates:	yyyy-mm
	year dates:				yyyy
	ranges:					yyyy-mm-dd/yyyy-mm-dd
							yyyy-mm/yyyy-mm
							yyyy/yyyy

Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.

The input table has:
	year, year2 – always present; if before 1582, ignore months and days if present
	month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 31– proper name dates
	day, day2 –  0 if not provided, 1-31 for days
	
the output table receives:
	rftdate:	an IS8601 formatted date
	rftchron:	a free-form version of the date, usually without year which is in rftdate (season ranges and propername dates)
	rftssn:		one of four season keywords: winter, spring, summer, fall (lowercase)

]]

local function make_COinS_date (input, tCOinS_date)
	local date;																	-- one date or first date in a range
	local date2 = '';															-- end of range date
	
	if 1582 &gt; tonumber(input.year) or 20 &lt; tonumber(input.month) then			-- Julian calendar or season so &amp;rft.date gets year only
		date = input.year;
		if 0 ~= input.year2 and input.year ~= input.year2 then					-- if a range, only the second year portion when not the same as range start year
			date = string.format ('%.4d/%.4d', tonumber(input.year), tonumber(input.year2))		-- assemble the date range
		end
		if 20 &lt; tonumber(input.month) then										-- if season or propername date
			local season = {[21]='winter', [22]='spring', [23]='summer', [24]='fall', [31]='Christmas'};	-- seasons lowercase, no autumn; proper names use title case
			if 0 == input.month2 then											-- single season date
				if 30 &lt;tonumber(input.month) then
					tCOinS_date.rftchron = season[input.month];					-- proper name dates
				else
					tCOinS_date.rftssn = season[input.month];					-- seasons
				end
			else																-- season range with a second season specified
				if input.year ~= input.year2 then								-- season year – season year range or season year–year
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					if 0~= input.month2 then
						tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);
					end
				else															-- season–season year range
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2];	-- season–season year range
				end
			end
		end
		tCOinS_date.rftdate = date;
		return;																	-- done
	end
	
	if 0 ~= input.day then
		date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day));	-- whole date
	elseif 0 ~= input.month then
		date = string.format ('%s-%.2d', input.year, tonumber(input.month));	-- year and month
	else
		date = string.format ('%s', input.year);								-- just year
	end

	if 0 ~= input.year2 then
		if 0 ~= input.day2 then
			date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2));		-- whole date
		elseif 0 ~= input.month2 then
			date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2));	-- year and month
		else
			date2 = string.format ('/%s', input.year2);							-- just year
		end
	end
	
	tCOinS_date.rftdate = date .. date2;										-- date2 has the '/' separator
	return;
end


--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only
allowed range separator is endash.  Additionally, check the date to see that it is a real date: no 31 in 30-day
months; no 29 February when not a leap year.  Months, both long-form and three character abbreviations, and seasons
must be spelled correctly.  Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and
COinS_date.  When this happens, the date parameter is used in the COinS metadata and the CITEREF identifier gets
its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc.)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is ISO 8601 format date; see make_COInS_date()

]]

local function check_date (date_string, tCOinS_date)
	local year;			-- assume that year2, months, and days are not used;
	local year2=0;		-- second year in a year range
	local month=0;
	local month2=0;		-- second month in a month range
	local day=0;
	local day2=0;		-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then										-- year-initial numerical year month day format
		year, month, day=string.match(date_string, &quot;(%d%d%d%d)%-(%d%d)%-(%d%d)&quot;);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or 0 == tonumber(day) then return false; end	-- month or day number not valid or not Gregorian calendar
		anchor_year = year;

	elseif date_string:match(&quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then						-- month-initial: month day, year
		month, day, anchor_year, year=string.match(date_string, &quot;(%a+)%s*(%d%d?),%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
				
	elseif date_string:match(&quot;^%a+ +[1-9]%d?–[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year=string.match(date_string, &quot;(%a+) +(%d%d?)–(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
		month2=month;																		-- for metadata
		year2=year;

	elseif date_string:match(&quot;^[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then						-- day-initial: day month year
		day, month, anchor_year, year=string.match(date_string, &quot;(%d%d*)%s*(%a+)%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d?–[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year=string.match(date_string, &quot;(%d%d?)–(%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
		month2=month;																		-- for metadata
		year2=year;

	elseif date_string:match(&quot;^[1-9]%d? +%a+ – [1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year=date_string:match(&quot;(%d%d?) +(%a+) – (%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);													-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif date_string:match(&quot;^%a+ +[1-9]%d? – %a+ +[1-9]%d?, +[1-9]%d%d%d?%a?$&quot;) then		-- month initial month-day-range: month day – month day, year;  uses spaced endash
		month, day, month2, day2, anchor_year, year=date_string:match(&quot;(%a+) +(%d%d?) – (%a+) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);													-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif date_string:match(&quot;^[1-9]%d? +%a+ +[1-9]%d%d%d – [1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2=date_string:match(&quot;(%d%d?) +(%a+) +(%d%d%d%d?) – (%d%d?) +(%a+) +((%d%d%d%d?)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end												-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);																		-- for metadata
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d – %a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then		-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
		month, day, year, month2, day2, anchor_year, year2=date_string:match(&quot;(%a+) +(%d%d?), +(%d%d%d%d) – (%a+) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end												-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);																		-- for metadata
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d–%d%d%a?$&quot;) then								-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		local century;
		month, year, century, anchor_year, year2=date_string:match(&quot;(%a+) +((%d%d)%d%d)–((%d%d)%a?)&quot;);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;					-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		year2 = century..year2;																-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		month = get_season_number (month);

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d–[1-9]%d%d%d%a?$&quot;) then						-- special case Winter/Summer year-year; year separated with unspaced endash
		month, year, anchor_year, year2=date_string:match(&quot;(%a+) +(%d%d%d%d)–((%d%d%d%d)%a?)&quot;);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;					-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		month = get_season_number (month);													-- for metadata

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d% – %a+ +[1-9]%d%d%d%a?$&quot;) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2=date_string:match(&quot;(%a+) +(%d%d%d%d) – (%a+) +((%d%d%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end							-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then 	-- both must be month year, same month style
			month = get_month_number(month);
			month2 = get_month_number(month2);
		elseif 0 ~= get_season_number(month) and 0 ~= get_season_number(month2) then		-- both must be or season year, not mixed
			month = get_season_number(month);
			month2 = get_season_number(month2);
		else
			 return false;
		end

	elseif date_string:match (&quot;^%a+–%a+ +[1-9]%d%d%d%a?$&quot;) then					-- month/season range year; months separated by endash 
		month, month2, anchor_year, year=date_string:match (&quot;(%a+)–(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or (not is_valid_year(year)) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
			month2 = get_month_number(month2);
		else
			month = get_season_number(month);
			month2 = get_season_number(month2);
		end
		year2=year;
		
	elseif date_string:match(&quot;^%a+ +%d%d%d%d%a?$&quot;) then							-- month/season year or proper-name year
		month, anchor_year, year=date_string:match(&quot;(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if not is_valid_year(year) then return false; end
		if not is_valid_month_or_season (month) and 0 == is_proper_name (month) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
		elseif 0 ~= get_season_number(month) then
			month = get_season_number(month);
		else
			month = is_proper_name (month);										-- must be proper name; not supported in COinS
		end

	elseif date_string:match(&quot;^[1-9]%d%d%d?–[1-9]%d%d%d?%a?$&quot;) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2=date_string:match(&quot;(%d%d%d%d?)–((%d%d%d%d?)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d–%d%d%a?$&quot;) then						-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2=date_string:match(&quot;((%d%d)%d%d)–((%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century..year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then							-- year; here accept either YYY or YYYY
		anchor_year, year=date_string:match(&quot;((%d%d%d%d?)%a?)&quot;);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;															-- date format not one of the MOS:DATE approved formats
	end

	local result=true;															-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result=is_valid_date(year,month,day);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month2,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year2,month2,day2);
	end
	
	if false == result then return false; end

	if nil ~= tCOinS_date then													-- this table only passed into this function when testing |date= parameter values
		make_COinS_date ({year=year, month=month, day=day, year2=year2, month2=month2, day2=day2}, tCOinS_date);	-- make an ISO 8601 date string for COinS
	end
	
	return true, anchor_year;													-- format is good and date string represents a real date
end	


--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.

]]

local function dates(date_parameters_list, tCOinS_date)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local embargo_date = '9999';												-- if good dmy, mdy, ymd date then holds original value else 9999
	local error_message = &quot;&quot;;
	local good_date = false;
	
	for k, v in pairs(date_parameters_list) do									-- for each date-holding parameter in the list
		if is_set(v) then														-- if the parameter has a value
			if v:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then							-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);					-- get the year portion so it can be tested
				if 'date'==k then
					anchor_year, COinS_date = v:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year'==k then
					good_date = is_valid_year(year);
				end
			elseif 'date'==k then												-- if the parameter is |date=
				if v:match(&quot;^n%.d%.%a?&quot;) then									-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v:match(&quot;^nd%a?$&quot;) then									-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v, tCOinS_date);	-- go test the date
				end
			elseif 'access-date'==k then										-- if the parameter is |access-date=
				good_date = check_date (v);										-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date = is_valid_accessdate (v);						-- is Wikipedia start date &lt; accessdate &lt; tomorrow's date?
				end
			elseif 'embargo'==k then											-- if the parameter is |embargo=
				good_date = check_date (v);										-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date, embargo_date = is_valid_embargo_date (v);		-- is |embargo= date a single dmy, mdy, or ymd formatted date? yes:returns embargo; no: returns 9999
				end
			else																-- any other date-holding parameter
				good_date = check_date (v);										-- go test the date
			end
			if false==good_date then											-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then									-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;						-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;			-- add the failed parameter
			end
		end
	end
	return anchor_year, embargo_date, error_message;											-- and done
end


--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function returns a numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

]]

local function year_date_check (year_string, date_string)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes
	
	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where both date and year are required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard range formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d–%d%d&quot;) then								-- YYYY-YY date ranges
		local century;
		date1, century, date2 = date_string:match (&quot;((%d%d)%d%d)[%s%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	else
		result = 0;																-- no recognizable year in date
	end
	return result;
end


--[[-------------------------&lt; R E F O R M A T   T A B L E S &gt;------------------------------------------------

These table are used exclusively for reformatting dates

]]

local source_patterns = {						-- this table holds patterns that match allowed date formats used to extract date components
	['dmy'] = '(%d%d?)%s+(%a+)%s+(%d%d%d%d)',
	['mdy'] = '(%a+)%s+(%d%d?),%s+(%d%d%d%d)',
	['ymd'] = '(%d%d%d%d)%-(%d%d)-(%d%d)',
	}

local short_formats = {							-- this table holds format strings used by os.date() for short month names
	['dmy'] = '%e %b %Y',
	['mdy'] = '%b %e, %Y',
	['ymd'] = '%F',
	}

local long_formats = {							-- this table holds format strings used by os.date() for long month names
	['dmy'] = '%e %B %Y',
	['mdy'] = '%B %e, %Y',
	['ymd'] = '%F',
	}


--[[-------------------------&lt; G E T _ D M Y _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from DMY formatted date, places them in the source_date table, and returns.

]]

local function get_dmy_date_parts (date, source_date)
	source_date.day, source_date.month, source_date.year = date:match (source_patterns['dmy']);	-- get date components as strings
	source_date.month = get_month_number (source_date.month);					-- get month number
end


--[[-------------------------&lt; G E T _ M D Y _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from MDY formatted date, places them in the source_date table, and returns.

]]

local function get_mdy_date_parts (date, source_date)
	source_date.month, source_date.day, source_date.year = date:match (source_patterns['mdy']);	-- get date components as strings
	source_date.month = get_month_number (source_date.month);					-- get month number
end


--[[-------------------------&lt; G E T _ Y M D _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from YMD formatted date, places them in the source_date table, and returns.

]]

local function get_ymd_date_parts (date, source_date)
	source_date.year, source_date.month, source_date.day = date:match (source_patterns['ymd']);	-- get date components as strings
end


--[[-------------------------&lt; R E F O R M A T _ D A T E S &gt;--------------------------------------------------

Reformats existing dates into the format specified by format and short.

format is one of several keywords: dmy, dmy-all, mdy, mdy-all, ymd, ymd-all.  The all version includes access- and
archive-dates; otherwise these dates are not reformatted

Date ranges, season dates, proper name dates are not currently supported.

]]

local function reformat_dates (date_parameters_list, format, short)
	local all = false;															-- set to false to skip access- and archive-dates
	local format_str;
	local source_date = {};
	
	if format:match('%a+%-all') then
		format = format:match('(%a+)%-all');									-- extract the format
		all = true;																-- set to true to format access- and archive-dates
	end
	
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val) then												-- if the parameter has a value
			if not all and in_array (param_name, {'access-date', 'archive-date'}) then	-- if access- or archive-date and format not xxx-all
				param_val = '';													-- set to empty string so we don't process this date
			end
			for source, pattern in pairs(source_patterns) do
				if param_val:match(pattern) then
					if 'ymd' == source then
						get_ymd_date_parts (param_val, source_date);			-- get the date parts into the source_date table
					elseif 'dmy' == source then
						get_dmy_date_parts (param_val, source_date);			-- get the date parts into the source_date table
					elseif 'mdy' == source then
						get_mdy_date_parts (param_val, source_date);			-- get the date parts into the source_date table
					end

					if 'ymd' == format and 1582 &gt; tonumber(source_date.year) then	-- ymd format dates not allowed before 1582
						return false;											-- abandon reformatting
					end
					
					if short then
						format_str = short_formats[format];
					else
						format_str = long_formats[format];
					end
					
					date_parameters_list[param_name] = os.date (format_str, os.time(source_date));	-- convert date and save
				end
			end
		end
	end
	return true;																-- declare success and done
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (utilities_page_ptr)
	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;											-- import functions from select Module:Citation/CS1/Utilities module
end



return {																		-- return exported functions
	dates = dates,
	year_date_check = year_date_check,
	reformat_dates = reformat_dates,
	set_selected_modules = set_selected_modules
	}</text>
      <sha1>8rvoa9e567nj697fb82u7ogxqwck7qp</sha1>
    </revision>
    <revision>
      <id>4831</id>
      <parentid>4830</parentid>
      <timestamp>2016-04-23T15:27:01Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>embargo date bug fix;</comment>
      <origin>4831</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="38922" sha1="bb6732fnfvr93osgbmanshu9qokvwiz" xml:space="preserve">
local p = {}


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array;																	-- imported function from selected Module:Citation/CS1/Utilities


--[=[-------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |accessdate= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work for languages other than English.  Wikimedia #time: parser apparently doesn't understand
non-Engish date month names. This function will always return false when the date contains a non-English month name
because good1 is false after the call to lang.formatDate.

For the time being, to use this function, supply it with YYYY-MM-DD format dates.  See
[[bs:Modul:Citation/CS1/Date validation/igralište]] for one possible solution.

]=]

local function is_valid_accessdate (accessdate)
	local lang = mw.getContentLanguage();
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold unix time stamps representing the dates
		
	good1, access_ts = pcall( lang.formatDate, lang, 'U', accessdate );			-- convert accessdate value to unix timesatmp 
	good2, tomorrow_ts = pcall( lang.formatDate, lang, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then
		access_ts = tonumber (access_ts);										-- convert to numbers for the comparison
		tomorrow_ts = tonumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to unix time stamp
	end
	
	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end


--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct. If not a valid month, returns 0

]]

local function get_month_number (month)
local long_months = {['January']=1, ['February']=2, ['March']=3, ['April']=4, ['May']=5, ['June']=6, ['July']=7, ['August']=8, ['September']=9, ['October']=10, ['November']=11, ['December']=12};
local short_months = {['Jan']=1, ['Feb']=2, ['Mar']=3, ['Apr']=4, ['May']=5, ['Jun']=6, ['Jul']=7, ['Aug']=8, ['Sep']=9, ['Oct']=10, ['Nov']=11, ['Dec']=12};
	return long_months[month] or												-- if month is the long-form name
		short_months[month] or													-- if month is the short-form name
		0;																		-- misspelled, improper case, or not a month name
end


--[[--------------------------&lt; I S _ V A L I D _ E M B A R G O _ D A T E &gt;------------------------------------

returns true and date value if that value has proper dmy, mdy, ymd format.

returns false and 9999 when date value is not proper format; assumes that when |embargo= is set, the editor
intended to embargo a pmc but |embargo does not hold a single date.

]]

local function is_valid_embargo_date (v)
	if v:match ('^%d%d%d%d%-%d%d%-%d%d$') or									-- ymd
		v:match ('^%d%d?%s+%a+%s+%d%d%d%d$') or									-- dmy
		v:match ('^%a+%s+%d%d?%s*,%s*%d%d%d%d$') then							-- mdy
			return true, v;
	end
	return false, '9999';														-- if here not good date so return false and set embargo date to long time in future
end


--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 1 for Winter, etc.  Capitalization and spelling must be correct. If not a valid season, returns 0

]]

local function get_season_number (season)
local season_list = {['Winter']=21, ['Spring']=22, ['Summer']=23, ['Fall']=24, ['Autumn']=24};	-- make sure these numbers do not overlap month numbers
local temp;
	temp=season_list[season];
	if temp then return temp; end												-- if season is a valid name return its number
	return 0;																	-- misspelled, improper case, or not a season name
end

--[[--------------------------&lt; I S _ P R O P E R _ N A M E &gt;--------------------------------------------------

returns a non-zero number if date contains a recognized proper name.  Capitalization and spelling must be correct.

]]

local function is_proper_name (name)
local name_list = {['Christmas']=31}
local temp;
	temp=name_list[name];
	if temp then return temp; end				-- if name is a valid name return its number
	return 0;									-- misspelled, improper case, or not a proper name
end

--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ O R _ S E A S O N &gt;------------------------------

--returns true if month or season is valid (properly spelled, capitalized, abbreviated)

]]

local function is_valid_month_or_season (month_season)
	if 0 == get_month_number (month_season) then		-- if month text isn't one of the twelve months, might be a season
		if 0 == get_season_number (month_season) then	-- not a month, is it a season?
			return false;								-- return false not a month or one of the five seasons
		end
	end
	return true;
end

--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one year in the future are not acceptable.

]]
local year_limit;
local function is_valid_year(year)
	if not is_set(year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;			-- global variable so we only have to fetch it once
	end
	return tonumber(year) &lt;= year_limit;				-- false if year is in the future more than one year
end

--[[--------------------------&lt; I S _ V A L I D _ D A T E &gt;----------------------------------------------------
Returns true if day is less than or equal to the number of days in month and year is no farther into the future
than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap
years before 1582 and Gregorian leap years after 1582. Where the two calendars overlap (1582 to approximately
1923) dates are assumed to be Gregorian.

]]

local function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year(year) then												-- no farther into the future than next year
		return false;
	end
	
	month = tonumber(month);													-- required for YYYY-MM-DD dates
	
	if (2==month) then															-- if February
		month_length = 28;														-- then 28 days unless
		if 1582 &gt; tonumber(year) then											-- Julian calendar
			if 0==(year%4) then
				month_length = 29;
			end
		else																	-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then			-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end

--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
There is a special test for May because it can be either short or long form.

Returns true when style for both months is the same

]]

local function is_valid_month_range_style (month1, month2)
local len1 = month1:len();
local len2 = month2:len();
	if len1 == len2 then
		return true;															-- both months are short form so return true
	elseif 'May' == month1 or 'May'== month2 then
		return true;															-- both months are long form so return true
	elseif 3 == len1 or 3 == len2 then
		return false;															-- months are mixed form so return false
	else
		return true;															-- both months are long form so return true
	end
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

Similarly, seasons are also left to right, earliest to latest in time.  There is an oddity with seasons: winter is assigned a value of 1, spring 2, ...,
fall and autumn 4.  Because winter can follow fall/autumn at the end of a calender year, a special test is made to see if |date=Fall-Winter yyyy (4-1) is the date.

]]

local function is_valid_month_season_range(range_start, range_end)
	local range_start_number = get_month_number (range_start);
	local range_end_number;
	
	if 0 == range_start_number then												-- is this a month range?
		local range_start_number = get_season_number (range_start);				-- not a month; is it a season? get start season number
		range_end_number = get_season_number (range_end);						-- get end season number

		if 0 ~= range_start_number then											-- is start of range a season?
			if range_start_number &lt; range_end_number then						-- range_start is a season
				return true;													-- return true when range_end is also a season and follows start season; else false
			end
			if 24 == range_start_number and 21 == range_end_number then			-- special case when season range is Fall-Winter or Autumn-Winter
				return true;
			end
		end
		return false;		-- range_start is not a month or a season; or range_start is a season and range_end is not; or improper season sequence
	end

	range_end_number = get_month_number (range_end);							-- get end month number
	if range_start_number &lt; range_end_number then								-- range_start is a month; does range_start precede range_end?
		if is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
		end
	end
	return false;																-- range_start month number is greater than or equal to range end number; or range end isn't a month
end


--[[--------------------------&lt; M A K E _ C O I N S _ D A T E &gt;------------------------------------------------

This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1.  The function is called only for |date= parameters and only if the |date=&lt;value&gt; is 
determined to be a valid date format.  The question of what to do with invalid date formats is not answered here.

The date parts in the input table are converted to an ISO 8601 conforming date string:
	single whole dates:		yyyy-mm-dd
	month and year dates:	yyyy-mm
	year dates:				yyyy
	ranges:					yyyy-mm-dd/yyyy-mm-dd
							yyyy-mm/yyyy-mm
							yyyy/yyyy

Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.

The input table has:
	year, year2 – always present; if before 1582, ignore months and days if present
	month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 31– proper name dates
	day, day2 –  0 if not provided, 1-31 for days
	
the output table receives:
	rftdate:	an IS8601 formatted date
	rftchron:	a free-form version of the date, usually without year which is in rftdate (season ranges and propername dates)
	rftssn:		one of four season keywords: winter, spring, summer, fall (lowercase)

]]

local function make_COinS_date (input, tCOinS_date)
	local date;																	-- one date or first date in a range
	local date2 = '';															-- end of range date
	
	if 1582 &gt; tonumber(input.year) or 20 &lt; tonumber(input.month) then			-- Julian calendar or season so &amp;rft.date gets year only
		date = input.year;
		if 0 ~= input.year2 and input.year ~= input.year2 then					-- if a range, only the second year portion when not the same as range start year
			date = string.format ('%.4d/%.4d', tonumber(input.year), tonumber(input.year2))		-- assemble the date range
		end
		if 20 &lt; tonumber(input.month) then										-- if season or propername date
			local season = {[21]='winter', [22]='spring', [23]='summer', [24]='fall', [31]='Christmas'};	-- seasons lowercase, no autumn; proper names use title case
			if 0 == input.month2 then											-- single season date
				if 30 &lt;tonumber(input.month) then
					tCOinS_date.rftchron = season[input.month];					-- proper name dates
				else
					tCOinS_date.rftssn = season[input.month];					-- seasons
				end
			else																-- season range with a second season specified
				if input.year ~= input.year2 then								-- season year – season year range or season year–year
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					if 0~= input.month2 then
						tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);
					end
				else															-- season–season year range
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2];	-- season–season year range
				end
			end
		end
		tCOinS_date.rftdate = date;
		return;																	-- done
	end
	
	if 0 ~= input.day then
		date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day));	-- whole date
	elseif 0 ~= input.month then
		date = string.format ('%s-%.2d', input.year, tonumber(input.month));	-- year and month
	else
		date = string.format ('%s', input.year);								-- just year
	end

	if 0 ~= input.year2 then
		if 0 ~= input.day2 then
			date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2));		-- whole date
		elseif 0 ~= input.month2 then
			date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2));	-- year and month
		else
			date2 = string.format ('/%s', input.year2);							-- just year
		end
	end
	
	tCOinS_date.rftdate = date .. date2;										-- date2 has the '/' separator
	return;
end


--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only
allowed range separator is endash.  Additionally, check the date to see that it is a real date: no 31 in 30-day
months; no 29 February when not a leap year.  Months, both long-form and three character abbreviations, and seasons
must be spelled correctly.  Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and
COinS_date.  When this happens, the date parameter is used in the COinS metadata and the CITEREF identifier gets
its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc.)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is ISO 8601 format date; see make_COInS_date()

]]

local function check_date (date_string, tCOinS_date)
	local year;			-- assume that year2, months, and days are not used;
	local year2=0;		-- second year in a year range
	local month=0;
	local month2=0;		-- second month in a month range
	local day=0;
	local day2=0;		-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then										-- year-initial numerical year month day format
		year, month, day=string.match(date_string, &quot;(%d%d%d%d)%-(%d%d)%-(%d%d)&quot;);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or 0 == tonumber(day) then return false; end	-- month or day number not valid or not Gregorian calendar
		anchor_year = year;

	elseif date_string:match(&quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then						-- month-initial: month day, year
		month, day, anchor_year, year=string.match(date_string, &quot;(%a+)%s*(%d%d?),%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
				
	elseif date_string:match(&quot;^%a+ +[1-9]%d?–[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year=string.match(date_string, &quot;(%a+) +(%d%d?)–(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
		month2=month;																		-- for metadata
		year2=year;

	elseif date_string:match(&quot;^[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then						-- day-initial: day month year
		day, month, anchor_year, year=string.match(date_string, &quot;(%d%d*)%s*(%a+)%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif date_string:match(&quot;^[1-9]%d?–[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year=string.match(date_string, &quot;(%d%d?)–(%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
		month2=month;																		-- for metadata
		year2=year;

	elseif date_string:match(&quot;^[1-9]%d? +%a+ – [1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year=date_string:match(&quot;(%d%d?) +(%a+) – (%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);													-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif date_string:match(&quot;^%a+ +[1-9]%d? – %a+ +[1-9]%d?, +[1-9]%d%d%d?%a?$&quot;) then		-- month initial month-day-range: month day – month day, year;  uses spaced endash
		month, day, month2, day2, anchor_year, year=date_string:match(&quot;(%a+) +(%d%d?) – (%a+) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);													-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif date_string:match(&quot;^[1-9]%d? +%a+ +[1-9]%d%d%d – [1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2=date_string:match(&quot;(%d%d?) +(%a+) +(%d%d%d%d?) – (%d%d?) +(%a+) +((%d%d%d%d?)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end												-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);																		-- for metadata
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d – %a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then		-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
		month, day, year, month2, day2, anchor_year, year2=date_string:match(&quot;(%a+) +(%d%d?), +(%d%d%d%d) – (%a+) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end												-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);																		-- for metadata
		month2 = get_month_number (month2);

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d–%d%d%a?$&quot;) then								-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		local century;
		month, year, century, anchor_year, year2=date_string:match(&quot;(%a+) +((%d%d)%d%d)–((%d%d)%a?)&quot;);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;					-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		year2 = century..year2;																-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		month = get_season_number (month);

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d–[1-9]%d%d%d%a?$&quot;) then						-- special case Winter/Summer year-year; year separated with unspaced endash
		month, year, anchor_year, year2=date_string:match(&quot;(%a+) +(%d%d%d%d)–((%d%d%d%d)%a?)&quot;);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;					-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		month = get_season_number (month);													-- for metadata

	elseif date_string:match(&quot;^%a+ +[1-9]%d%d%d% – %a+ +[1-9]%d%d%d%a?$&quot;) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2=date_string:match(&quot;(%a+) +(%d%d%d%d) – (%a+) +((%d%d%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end							-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then 	-- both must be month year, same month style
			month = get_month_number(month);
			month2 = get_month_number(month2);
		elseif 0 ~= get_season_number(month) and 0 ~= get_season_number(month2) then		-- both must be or season year, not mixed
			month = get_season_number(month);
			month2 = get_season_number(month2);
		else
			 return false;
		end

	elseif date_string:match (&quot;^%a+–%a+ +[1-9]%d%d%d%a?$&quot;) then					-- month/season range year; months separated by endash 
		month, month2, anchor_year, year=date_string:match (&quot;(%a+)–(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or (not is_valid_year(year)) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
			month2 = get_month_number(month2);
		else
			month = get_season_number(month);
			month2 = get_season_number(month2);
		end
		year2=year;
		
	elseif date_string:match(&quot;^%a+ +%d%d%d%d%a?$&quot;) then							-- month/season year or proper-name year
		month, anchor_year, year=date_string:match(&quot;(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if not is_valid_year(year) then return false; end
		if not is_valid_month_or_season (month) and 0 == is_proper_name (month) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
		elseif 0 ~= get_season_number(month) then
			month = get_season_number(month);
		else
			month = is_proper_name (month);										-- must be proper name; not supported in COinS
		end

	elseif date_string:match(&quot;^[1-9]%d%d%d?–[1-9]%d%d%d?%a?$&quot;) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2=date_string:match(&quot;(%d%d%d%d?)–((%d%d%d%d?)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d–%d%d%a?$&quot;) then						-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2=date_string:match(&quot;((%d%d)%d%d)–((%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century..year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then							-- year; here accept either YYY or YYYY
		anchor_year, year=date_string:match(&quot;((%d%d%d%d?)%a?)&quot;);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;															-- date format not one of the MOS:DATE approved formats
	end

	local result=true;															-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result=is_valid_date(year,month,day);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month2,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year2,month2,day2);
	end
	
	if false == result then return false; end

	if nil ~= tCOinS_date then													-- this table only passed into this function when testing |date= parameter values
		make_COinS_date ({year=year, month=month, day=day, year2=year2, month2=month2, day2=day2}, tCOinS_date);	-- make an ISO 8601 date string for COinS
	end
	
	return true, anchor_year;													-- format is good and date string represents a real date
end	


--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.

]]

local function dates(date_parameters_list, tCOinS_date)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local embargo_date;															-- if good dmy, mdy, ymd date then holds original value else 9999
	local error_message = &quot;&quot;;
	local good_date = false;
	
	for k, v in pairs(date_parameters_list) do									-- for each date-holding parameter in the list
		if is_set(v) then														-- if the parameter has a value
			if v:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then							-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);					-- get the year portion so it can be tested
				if 'date'==k then
					anchor_year, COinS_date = v:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year'==k then
					good_date = is_valid_year(year);
				end
			elseif 'date'==k then												-- if the parameter is |date=
				if v:match(&quot;^n%.d%.%a?&quot;) then									-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v:match(&quot;^nd%a?$&quot;) then									-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v, tCOinS_date);	-- go test the date
				end
			elseif 'access-date'==k then										-- if the parameter is |access-date=
				good_date = check_date (v);										-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date = is_valid_accessdate (v);						-- is Wikipedia start date &lt; accessdate &lt; tomorrow's date?
				end
			elseif 'embargo'==k then											-- if the parameter is |embargo=
				good_date = check_date (v);										-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date, embargo_date = is_valid_embargo_date (v);		-- is |embargo= date a single dmy, mdy, or ymd formatted date? yes:returns embargo; no: returns 9999
				end
			else																-- any other date-holding parameter
				good_date = check_date (v);										-- go test the date
			end
			if false==good_date then											-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then									-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;						-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;			-- add the failed parameter
			end
		end
	end
	return anchor_year, embargo_date, error_message;											-- and done
end


--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function returns a numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

]]

local function year_date_check (year_string, date_string)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes
	
	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where both date and year are required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard range formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d–%d%d&quot;) then								-- YYYY-YY date ranges
		local century;
		date1, century, date2 = date_string:match (&quot;((%d%d)%d%d)[%s%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	else
		result = 0;																-- no recognizable year in date
	end
	return result;
end


--[[-------------------------&lt; R E F O R M A T   T A B L E S &gt;------------------------------------------------

These table are used exclusively for reformatting dates

]]

local source_patterns = {						-- this table holds patterns that match allowed date formats used to extract date components
	['dmy'] = '(%d%d?)%s+(%a+)%s+(%d%d%d%d)',
	['mdy'] = '(%a+)%s+(%d%d?),%s+(%d%d%d%d)',
	['ymd'] = '(%d%d%d%d)%-(%d%d)-(%d%d)',
	}

local short_formats = {							-- this table holds format strings used by os.date() for short month names
	['dmy'] = '%e %b %Y',
	['mdy'] = '%b %e, %Y',
	['ymd'] = '%F',
	}

local long_formats = {							-- this table holds format strings used by os.date() for long month names
	['dmy'] = '%e %B %Y',
	['mdy'] = '%B %e, %Y',
	['ymd'] = '%F',
	}


--[[-------------------------&lt; G E T _ D M Y _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from DMY formatted date, places them in the source_date table, and returns.

]]

local function get_dmy_date_parts (date, source_date)
	source_date.day, source_date.month, source_date.year = date:match (source_patterns['dmy']);	-- get date components as strings
	source_date.month = get_month_number (source_date.month);					-- get month number
end


--[[-------------------------&lt; G E T _ M D Y _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from MDY formatted date, places them in the source_date table, and returns.

]]

local function get_mdy_date_parts (date, source_date)
	source_date.month, source_date.day, source_date.year = date:match (source_patterns['mdy']);	-- get date components as strings
	source_date.month = get_month_number (source_date.month);					-- get month number
end


--[[-------------------------&lt; G E T _ Y M D _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from YMD formatted date, places them in the source_date table, and returns.

]]

local function get_ymd_date_parts (date, source_date)
	source_date.year, source_date.month, source_date.day = date:match (source_patterns['ymd']);	-- get date components as strings
end


--[[-------------------------&lt; R E F O R M A T _ D A T E S &gt;--------------------------------------------------

Reformats existing dates into the format specified by format and short.

format is one of several keywords: dmy, dmy-all, mdy, mdy-all, ymd, ymd-all.  The all version includes access- and
archive-dates; otherwise these dates are not reformatted

Date ranges, season dates, proper name dates are not currently supported.

]]

local function reformat_dates (date_parameters_list, format, short)
	local all = false;															-- set to false to skip access- and archive-dates
	local format_str;
	local source_date = {};
	
	if format:match('%a+%-all') then
		format = format:match('(%a+)%-all');									-- extract the format
		all = true;																-- set to true to format access- and archive-dates
	end
	
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val) then												-- if the parameter has a value
			if not all and in_array (param_name, {'access-date', 'archive-date'}) then	-- if access- or archive-date and format not xxx-all
				param_val = '';													-- set to empty string so we don't process this date
			end
			for source, pattern in pairs(source_patterns) do
				if param_val:match(pattern) then
					if 'ymd' == source then
						get_ymd_date_parts (param_val, source_date);			-- get the date parts into the source_date table
					elseif 'dmy' == source then
						get_dmy_date_parts (param_val, source_date);			-- get the date parts into the source_date table
					elseif 'mdy' == source then
						get_mdy_date_parts (param_val, source_date);			-- get the date parts into the source_date table
					end

					if 'ymd' == format and 1582 &gt; tonumber(source_date.year) then	-- ymd format dates not allowed before 1582
						return false;											-- abandon reformatting
					end
					
					if short then
						format_str = short_formats[format];
					else
						format_str = long_formats[format];
					end
					
					date_parameters_list[param_name] = os.date (format_str, os.time(source_date));	-- convert date and save
				end
			end
		end
	end
	return true;																-- declare success and done
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (utilities_page_ptr)
	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;											-- import functions from select Module:Citation/CS1/Utilities module
end



return {																		-- return exported functions
	dates = dates,
	year_date_check = year_date_check,
	reformat_dates = reformat_dates,
	set_selected_modules = set_selected_modules
	}</text>
      <sha1>bb6732fnfvr93osgbmanshu9qokvwiz</sha1>
    </revision>
    <revision>
      <id>4832</id>
      <parentid>4831</parentid>
      <timestamp>2016-06-04T17:42:21Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4832</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="40329" sha1="q8jb8fckcpszeuv5cspv8bs4l4qqv03" xml:space="preserve">
local p = {}


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array;																	-- imported function from selected Module:Citation/CS1/Utilities


--[=[-------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |accessdate= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work for languages other than English.  Wikimedia #time: parser apparently doesn't understand
non-Engish date month names. This function will always return false when the date contains a non-English month name
because good1 is false after the call to lang.formatDate.

For the time being, to use this function, supply it with YYYY-MM-DD format dates.  See
[[bs:Modul:Citation/CS1/Date validation/igralište]] for one possible solution.

]=]

local function is_valid_accessdate (accessdate)
	local lang = mw.getContentLanguage();
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold unix time stamps representing the dates
		
	good1, access_ts = pcall( lang.formatDate, lang, 'U', accessdate );			-- convert accessdate value to unix timesatmp 
	good2, tomorrow_ts = pcall( lang.formatDate, lang, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then
		access_ts = tonumber (access_ts);										-- convert to numbers for the comparison
		tomorrow_ts = tonumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to unix time stamp
	end
	
	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end


--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct. If not a valid month, returns 0

]]

local function get_month_number (month)
local long_months = {['January']=1, ['February']=2, ['March']=3, ['April']=4, ['May']=5, ['June']=6, ['July']=7, ['August']=8, ['September']=9, ['October']=10, ['November']=11, ['December']=12};
local short_months = {['Jan']=1, ['Feb']=2, ['Mar']=3, ['Apr']=4, ['May']=5, ['Jun']=6, ['Jul']=7, ['Aug']=8, ['Sep']=9, ['Oct']=10, ['Nov']=11, ['Dec']=12};
	return long_months[month] or												-- if month is the long-form name
		short_months[month] or													-- if month is the short-form name
		0;																		-- misspelled, improper case, or not a month name
end


--[[--------------------------&lt; I S _ V A L I D _ E M B A R G O _ D A T E &gt;------------------------------------

returns true and date value if that value has proper dmy, mdy, ymd format.

returns false and 9999 (embargoed forever) when date value is not proper format; assumes that when |embargo= is
set, the editor intended to embargo a pmc but |embargo= does not hold a single date.

]]

local function is_valid_embargo_date (v)
	if v:match ('^%d%d%d%d%-%d%d%-%d%d$') or									-- ymd
		v:match ('^%d%d?%s+%a+%s+%d%d%d%d$') or									-- dmy
		v:match ('^%a+%s+%d%d?%s*,%s*%d%d%d%d$') then							-- mdy
			return true, v;
	end
	return false, '9999';														-- if here not good date so return false and set embargo date to long time in future
end


--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 1 for Winter, etc.  Capitalization and spelling must be correct. If not a valid season, returns 0

]]

local function get_season_number (season)
local season_list = {['Winter']=21, ['Spring']=22, ['Summer']=23, ['Fall']=24, ['Autumn']=24};	-- make sure these numbers do not overlap month numbers
local temp;
	temp=season_list[season];
	if temp then return temp; end												-- if season is a valid name return its number
	return 0;																	-- misspelled, improper case, or not a season name
end

--[[--------------------------&lt; I S _ P R O P E R _ N A M E &gt;--------------------------------------------------

returns a non-zero number if date contains a recognized proper name.  Capitalization and spelling must be correct.

]]

local function is_proper_name (name)
local name_list = {['Christmas']=31}
local temp;
	temp=name_list[name];
	if temp then return temp; end				-- if name is a valid name return its number
	return 0;									-- misspelled, improper case, or not a proper name
end

--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ O R _ S E A S O N &gt;------------------------------

--returns true if month or season is valid (properly spelled, capitalized, abbreviated)

]]

local function is_valid_month_or_season (month_season)
	if 0 == get_month_number (month_season) then		-- if month text isn't one of the twelve months, might be a season
		if 0 == get_season_number (month_season) then	-- not a month, is it a season?
			return false;								-- return false not a month or one of the five seasons
		end
	end
	return true;
end

--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one year in the future are not acceptable.

]]
local year_limit;
local function is_valid_year(year)
	if not is_set(year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;			-- global variable so we only have to fetch it once
	end
	return tonumber(year) &lt;= year_limit;				-- false if year is in the future more than one year
end

--[[--------------------------&lt; I S _ V A L I D _ D A T E &gt;----------------------------------------------------
Returns true if day is less than or equal to the number of days in month and year is no farther into the future
than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap
years before 1582 and Gregorian leap years after 1582. Where the two calendars overlap (1582 to approximately
1923) dates are assumed to be Gregorian.

]]

local function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year(year) then												-- no farther into the future than next year
		return false;
	end
	
	month = tonumber(month);													-- required for YYYY-MM-DD dates
	
	if (2==month) then															-- if February
		month_length = 28;														-- then 28 days unless
		if 1582 &gt; tonumber(year) then											-- Julian calendar
			if 0==(year%4) then
				month_length = 29;
			end
		else																	-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then			-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end

--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
There is a special test for May because it can be either short or long form.

Returns true when style for both months is the same

]]

local function is_valid_month_range_style (month1, month2)
local len1 = month1:len();
local len2 = month2:len();
	if len1 == len2 then
		return true;															-- both months are short form so return true
	elseif 'May' == month1 or 'May'== month2 then
		return true;															-- both months are long form so return true
	elseif 3 == len1 or 3 == len2 then
		return false;															-- months are mixed form so return false
	else
		return true;															-- both months are long form so return true
	end
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

Similarly, seasons are also left to right, earliest to latest in time.  There is an oddity with seasons: winter is assigned a value of 1, spring 2, ...,
fall and autumn 4.  Because winter can follow fall/autumn at the end of a calender year, a special test is made to see if |date=Fall-Winter yyyy (4-1) is the date.

]]

local function is_valid_month_season_range(range_start, range_end)
	local range_start_number = get_month_number (range_start);
	local range_end_number;
	
	if 0 == range_start_number then												-- is this a month range?
		local range_start_number = get_season_number (range_start);				-- not a month; is it a season? get start season number
		range_end_number = get_season_number (range_end);						-- get end season number

		if 0 ~= range_start_number then											-- is start of range a season?
			if range_start_number &lt; range_end_number then						-- range_start is a season
				return true;													-- return true when range_end is also a season and follows start season; else false
			end
			if 24 == range_start_number and 21 == range_end_number then			-- special case when season range is Fall-Winter or Autumn-Winter
				return true;
			end
		end
		return false;		-- range_start is not a month or a season; or range_start is a season and range_end is not; or improper season sequence
	end

	range_end_number = get_month_number (range_end);							-- get end month number
	if range_start_number &lt; range_end_number then								-- range_start is a month; does range_start precede range_end?
		if is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
		end
	end
	return false;																-- range_start month number is greater than or equal to range end number; or range end isn't a month
end


--[[--------------------------&lt; M A K E _ C O I N S _ D A T E &gt;------------------------------------------------

This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1.  The function is called only for |date= parameters and only if the |date=&lt;value&gt; is 
determined to be a valid date format.  The question of what to do with invalid date formats is not answered here.

The date parts in the input table are converted to an ISO 8601 conforming date string:
	single whole dates:		yyyy-mm-dd
	month and year dates:	yyyy-mm
	year dates:				yyyy
	ranges:					yyyy-mm-dd/yyyy-mm-dd
							yyyy-mm/yyyy-mm
							yyyy/yyyy

Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.

The input table has:
	year, year2 – always present; if before 1582, ignore months and days if present
	month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 31– proper name dates
	day, day2 –  0 if not provided, 1-31 for days
	
the output table receives:
	rftdate:	an IS8601 formatted date
	rftchron:	a free-form version of the date, usually without year which is in rftdate (season ranges and propername dates)
	rftssn:		one of four season keywords: winter, spring, summer, fall (lowercase)

]]

local function make_COinS_date (input, tCOinS_date)
	local date;																	-- one date or first date in a range
	local date2 = '';															-- end of range date
	
	if 1582 &gt; tonumber(input.year) or 20 &lt; tonumber(input.month) then			-- Julian calendar or season so &amp;rft.date gets year only
		date = input.year;
		if 0 ~= input.year2 and input.year ~= input.year2 then					-- if a range, only the second year portion when not the same as range start year
			date = string.format ('%.4d/%.4d', tonumber(input.year), tonumber(input.year2))		-- assemble the date range
		end
		if 20 &lt; tonumber(input.month) then										-- if season or propername date
			local season = {[21]='winter', [22]='spring', [23]='summer', [24]='fall', [31]='Christmas'};	-- seasons lowercase, no autumn; proper names use title case
			if 0 == input.month2 then											-- single season date
				if 30 &lt;tonumber(input.month) then
					tCOinS_date.rftchron = season[input.month];					-- proper name dates
				else
					tCOinS_date.rftssn = season[input.month];					-- seasons
				end
			else																-- season range with a second season specified
				if input.year ~= input.year2 then								-- season year – season year range or season year–year
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					if 0~= input.month2 then
						tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);
					end
				else															-- season–season year range
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2];	-- season–season year range
				end
			end
		end
		tCOinS_date.rftdate = date;
		return;																	-- done
	end
	
	if 0 ~= input.day then
		date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day));	-- whole date
	elseif 0 ~= input.month then
		date = string.format ('%s-%.2d', input.year, tonumber(input.month));	-- year and month
	else
		date = string.format ('%s', input.year);								-- just year
	end

	if 0 ~= input.year2 then
		if 0 ~= input.day2 then
			date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2));		-- whole date
		elseif 0 ~= input.month2 then
			date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2));	-- year and month
		else
			date2 = string.format ('/%s', input.year2);							-- just year
		end
	end
	
	tCOinS_date.rftdate = date .. date2;										-- date2 has the '/' separator
	return;
end


--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only
allowed range separator is endash.  Additionally, check the date to see that it is a real date: no 31 in 30-day
months; no 29 February when not a leap year.  Months, both long-form and three character abbreviations, and seasons
must be spelled correctly.  Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and
COinS_date.  When this happens, the date parameter is used in the COinS metadata and the CITEREF identifier gets
its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc.)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is ISO 8601 format date; see make_COInS_date()

]]

local function check_date (date_string, tCOinS_date)
	local year;			-- assume that year2, months, and days are not used;
	local year2=0;		-- second year in a year range
	local month=0;
	local month2=0;		-- second month in a month range
	local day=0;
	local day2=0;		-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then										-- year-initial numerical year month day format
		year, month, day=string.match(date_string, &quot;(%d%d%d%d)%-(%d%d)%-(%d%d)&quot;);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or 0 == tonumber(day) then return false; end	-- month or day number not valid or not Gregorian calendar
		anchor_year = year;

	elseif date_string:match(&quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then						-- month-initial: month day, year
		month, day, anchor_year, year=string.match(date_string, &quot;(%a+)%s*(%d%d?),%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
				
	elseif mw.ustring.match(date_string, &quot;^%a+ +[1-9]%d?[%-–][1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year=mw.ustring.match(date_string, &quot;(%a+) +(%d%d?)[%-–](%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
		month2=month;																		-- for metadata
		year2=year;

	elseif date_string:match(&quot;^[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then						-- day-initial: day month year
		day, month, anchor_year, year=string.match(date_string, &quot;(%d%d*)%s*(%a+)%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d?[%-–][1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year=mw.ustring.match(date_string, &quot;(%d%d?)[%-–](%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
		month2=month;																		-- for metadata
		year2=year;

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d? +%a+ [%-–] [1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year=mw.ustring.match(date_string, &quot;(%d%d?) +(%a+) [%-–] (%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);													-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif mw.ustring.match(date_string, &quot;^%a+ +[1-9]%d? [%-–] %a+ +[1-9]%d?, +[1-9]%d%d%d?%a?$&quot;) then		-- month initial month-day-range: month day – month day, year;  uses spaced endash
		month, day, month2, day2, anchor_year, year=mw.ustring.match(date_string, &quot;(%a+) +(%d%d?) [%-–] (%a+) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);													-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d? +%a+ +[1-9]%d%d%d [%-–] [1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2=mw.ustring.match(date_string, &quot;(%d%d?) +(%a+) +(%d%d%d%d?) [%-–] (%d%d?) +(%a+) +((%d%d%d%d?)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end												-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);																		-- for metadata
		month2 = get_month_number (month2);

	elseif mw.ustring.match(date_string, &quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d [%-–] %a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then		-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
		month, day, year, month2, day2, anchor_year, year2=mw.ustring.match(date_string, &quot;(%a+) +(%d%d?), +(%d%d%d%d) [%-–] (%a+) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end												-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);																		-- for metadata
		month2 = get_month_number (month2);

	elseif mw.ustring.match(date_string, &quot;^%a+ +[1-9]%d%d%d[%-–]%d%d%a?$&quot;) then								-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		local century;
		month, year, century, anchor_year, year2=mw.ustring.match(date_string, &quot;(%a+) +((%d%d)%d%d)[%-–]((%d%d)%a?)&quot;);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;					-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		year2 = century..year2;																-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		month = get_season_number (month);

	elseif mw.ustring.match(date_string, &quot;^%a+ +[1-9]%d%d%d[%-–][1-9]%d%d%d%a?$&quot;) then						-- special case Winter/Summer year-year; year separated with unspaced endash
		month, year, anchor_year, year2=mw.ustring.match(date_string, &quot;(%a+) +(%d%d%d%d)[%-–]((%d%d%d%d)%a?)&quot;);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;					-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		month = get_season_number (month);													-- for metadata

	elseif mw.ustring.match(date_string, &quot;^%a+ +[1-9]%d%d%d% [%-–] %a+ +[1-9]%d%d%d%a?$&quot;) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2=mw.ustring.match(date_string, &quot;(%a+) +(%d%d%d%d) [%-–] (%a+) +((%d%d%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end							-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then 	-- both must be month year, same month style
			month = get_month_number(month);
			month2 = get_month_number(month2);
		elseif 0 ~= get_season_number(month) and 0 ~= get_season_number(month2) then		-- both must be or season year, not mixed
			month = get_season_number(month);
			month2 = get_season_number(month2);
		else
			 return false;
		end

	elseif mw.ustring.match(date_string, &quot;^%a+[%-–]%a+ +[1-9]%d%d%d%a?$&quot;) then					-- month/season range year; months separated by endash 
		month, month2, anchor_year, year=mw.ustring.match(date_string, &quot;(%a+)[%-–](%a+)%s*((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or (not is_valid_year(year)) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
			month2 = get_month_number(month2);
		else
			month = get_season_number(month);
			month2 = get_season_number(month2);
		end
		year2=year;
		
	elseif date_string:match(&quot;^%a+ +%d%d%d%d%a?$&quot;) then							-- month/season year or proper-name year
		month, anchor_year, year=date_string:match(&quot;(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if not is_valid_year(year) then return false; end
		if not is_valid_month_or_season (month) and 0 == is_proper_name (month) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
		elseif 0 ~= get_season_number(month) then
			month = get_season_number(month);
		else
			month = is_proper_name (month);										-- must be proper name; not supported in COinS
		end

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d%d%d?[%-–][1-9]%d%d%d?%a?$&quot;) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2=mw.ustring.match(date_string, &quot;(%d%d%d%d?)[%-–]((%d%d%d%d?)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d%d%d[%-–]%d%d%a?$&quot;) then						-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2=mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]((%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century..year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then							-- year; here accept either YYY or YYYY
		anchor_year, year=date_string:match(&quot;((%d%d%d%d?)%a?)&quot;);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;															-- date format not one of the MOS:DATE approved formats
	end

	local result=true;															-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result=is_valid_date(year,month,day);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month2,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year2,month2,day2);
	end
	
	if false == result then return false; end

	if nil ~= tCOinS_date then													-- this table only passed into this function when testing |date= parameter values
		make_COinS_date ({year=year, month=month, day=day, year2=year2, month2=month2, day2=day2}, tCOinS_date);	-- make an ISO 8601 date string for COinS
	end
	
	return true, anchor_year;													-- format is good and date string represents a real date
end	


--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.

]]

local function dates(date_parameters_list, tCOinS_date)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local embargo_date;															-- if embargo date is a good dmy, mdy, ymd date then holds original value else reset to 9999
	local error_message = &quot;&quot;;
	local good_date = false;
	
	for k, v in pairs(date_parameters_list) do									-- for each date-holding parameter in the list
		if is_set(v) then														-- if the parameter has a value
			if v:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then							-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);					-- get the year portion so it can be tested
				if 'date'==k then
					anchor_year, COinS_date = v:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year'==k then
					good_date = is_valid_year(year);
				end
			elseif 'date'==k then												-- if the parameter is |date=
				if v:match(&quot;^n%.d%.%a?&quot;) then									-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v:match(&quot;^nd%a?$&quot;) then									-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v, tCOinS_date);	-- go test the date
				end
			elseif 'access-date'==k then										-- if the parameter is |access-date=
				good_date = check_date (v);										-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date = is_valid_accessdate (v);						-- is Wikipedia start date &lt; accessdate &lt; tomorrow's date?
				end
			elseif 'embargo'==k then											-- if the parameter is |embargo=
				good_date = check_date (v);										-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date, embargo_date = is_valid_embargo_date (v);		-- is |embargo= date a single dmy, mdy, or ymd formatted date? yes:returns embargo; no: returns 9999
				end
			else																-- any other date-holding parameter
				good_date = check_date (v);										-- go test the date
			end
			if false==good_date then											-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then									-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;						-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;			-- add the failed parameter
			end
		end
	end
	return anchor_year, embargo_date, error_message;											-- and done
end


--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function returns a numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

]]

local function year_date_check (year_string, date_string)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes
	
	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where both date and year are required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard range formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif mw.ustring.match(date_string, &quot;%d%d%d%d[%-–]%d%d&quot;) then								-- YYYY-YY date ranges
		local century;
		date1, century, date2 = mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	else
		result = 0;																-- no recognizable year in date
	end
	return result;
end


--[[-------------------------&lt; R E F O R M A T   T A B L E S &gt;------------------------------------------------

These table are used exclusively for reformatting dates

]]

local source_patterns = {						-- this table holds patterns that match allowed date formats used to extract date components
	['dmy'] = '(%d%d?)%s+(%a+)%s+(%d%d%d%d)',
	['mdy'] = '(%a+)%s+(%d%d?),%s+(%d%d%d%d)',
	['ymd'] = '(%d%d%d%d)%-(%d%d)-(%d%d)',
	}

local short_formats = {							-- this table holds format strings used by os.date() for short month names
	['dmy'] = '%e %b %Y',
	['mdy'] = '%b %e, %Y',
	['ymd'] = '%F',
	}

local long_formats = {							-- this table holds format strings used by os.date() for long month names
	['dmy'] = '%e %B %Y',
	['mdy'] = '%B %e, %Y',
	['ymd'] = '%F',
	}


--[[-------------------------&lt; G E T _ D M Y _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from DMY formatted date, places them in the source_date table, and returns.

]]

local function get_dmy_date_parts (date, source_date)
	source_date.day, source_date.month, source_date.year = date:match (source_patterns['dmy']);	-- get date components as strings
	source_date.month = get_month_number (source_date.month);					-- get month number
end


--[[-------------------------&lt; G E T _ M D Y _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from MDY formatted date, places them in the source_date table, and returns.

]]

local function get_mdy_date_parts (date, source_date)
	source_date.month, source_date.day, source_date.year = date:match (source_patterns['mdy']);	-- get date components as strings
	source_date.month = get_month_number (source_date.month);					-- get month number
end


--[[-------------------------&lt; G E T _ Y M D _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from YMD formatted date, places them in the source_date table, and returns.

]]

local function get_ymd_date_parts (date, source_date)
	source_date.year, source_date.month, source_date.day = date:match (source_patterns['ymd']);	-- get date components as strings
end


--[[-------------------------&lt; R E F O R M A T _ D A T E S &gt;--------------------------------------------------

Reformats existing dates into the format specified by format and short.

format is one of several keywords: dmy, dmy-all, mdy, mdy-all, ymd, ymd-all.  The all version includes access- and
archive-dates; otherwise these dates are not reformatted

Date ranges, season dates, proper name dates are not currently supported.

]]

local function reformat_dates (date_parameters_list, format, short)
	local all = false;															-- set to false to skip access- and archive-dates
	local format_str;
	local source_date = {};
	
	if format:match('%a+%-all') then
		format = format:match('(%a+)%-all');									-- extract the format
		all = true;																-- set to true to format access- and archive-dates
	end
	
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val) then												-- if the parameter has a value
			if not all and in_array (param_name, {'access-date', 'archive-date'}) then	-- if access- or archive-date and format not xxx-all
				param_val = '';													-- set to empty string so we don't process this date
			end
			for source, pattern in pairs(source_patterns) do
				if param_val:match(pattern) then
					if 'ymd' == source then
						get_ymd_date_parts (param_val, source_date);			-- get the date parts into the source_date table
					elseif 'dmy' == source then
						get_dmy_date_parts (param_val, source_date);			-- get the date parts into the source_date table
					elseif 'mdy' == source then
						get_mdy_date_parts (param_val, source_date);			-- get the date parts into the source_date table
					end

					if 'ymd' == format and 1582 &gt; tonumber(source_date.year) then	-- ymd format dates not allowed before 1582
						return false;											-- abandon reformatting
					end
					
					if short then
						format_str = short_formats[format];
					else
						format_str = long_formats[format];
					end
					
					date_parameters_list[param_name] = os.date (format_str, os.time(source_date));	-- convert date and save
				end
			end
		end
	end
	return true;																-- declare success and done
end


--[[--------------------------&lt; D A T E _ H Y P H E N _ T O _ D A S H &gt;----------------------------------------

Loops through the list of date-holding parameters and converts any hyphen to an ndash.  Not called if the cs1|2
template has any date errors.

Modifies the date_parameters_list and returns true if hyphens are replaced, else returns false.

]]

local function date_hyphen_to_dash (date_parameters_list)
	local result = false;
	local n;
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if not param_val:match ('%d%d%d%d%-%d%d%-%d%d') then					-- for those that are not ymd dates
			param_val, n = param_val:gsub ('%-', '–');							-- replace any hyphen with ndash
			if 0 ~= n then
				date_parameters_list[param_name] = param_val;					-- update the list
				result = true;
			end
		end
	end
	return result;																-- so we know if 
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (utilities_page_ptr)
	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;											-- import functions from select Module:Citation/CS1/Utilities module
end



return {																		-- return exported functions
	dates = dates,
	year_date_check = year_date_check,
	reformat_dates = reformat_dates,
	date_hyphen_to_dash = date_hyphen_to_dash,
	set_selected_modules = set_selected_modules
	}</text>
      <sha1>q8jb8fckcpszeuv5cspv8bs4l4qqv03</sha1>
    </revision>
    <revision>
      <id>4833</id>
      <parentid>4832</parentid>
      <timestamp>2016-07-30T09:55:09Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4833</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="41095" sha1="i1fv7pqohu4tjsyxsm6wr9x4cy0aoey" xml:space="preserve">
local p = {}


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array;																	-- imported function from selected Module:Citation/CS1/Utilities


--[=[-------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |accessdate= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-Engish date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate().  To get around that
call this function with YYYY-MM-DD format dates.

]=]

local function is_valid_accessdate (accessdate)
	local lang = mw.getContentLanguage();
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold unix time stamps representing the dates
		
	good1, access_ts = pcall( lang.formatDate, lang, 'U', accessdate );			-- convert accessdate value to unix timesatmp 
	good2, tomorrow_ts = pcall( lang.formatDate, lang, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then
		access_ts = tonumber (access_ts);										-- convert to numbers for the comparison
		tomorrow_ts = tonumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to unix time stamp
	end

	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end


--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct. If not a valid month, returns 0

]]

local function get_month_number (month)
local long_months = {['January']=1, ['February']=2, ['March']=3, ['April']=4, ['May']=5, ['June']=6, ['July']=7, ['August']=8, ['September']=9, ['October']=10, ['November']=11, ['December']=12};
local short_months = {['Jan']=1, ['Feb']=2, ['Mar']=3, ['Apr']=4, ['May']=5, ['Jun']=6, ['Jul']=7, ['Aug']=8, ['Sep']=9, ['Oct']=10, ['Nov']=11, ['Dec']=12};
	return long_months[month] or												-- if month is the long-form name
		short_months[month] or													-- if month is the short-form name
		0;																		-- misspelled, improper case, or not a month name
end


--[[--------------------------&lt; I S _ V A L I D _ E M B A R G O _ D A T E &gt;------------------------------------

returns true and date value if that value has proper dmy, mdy, ymd format.

returns false and 9999 (embargoed forever) when date value is not proper format; assumes that when |embargo= is
set, the editor intended to embargo a pmc but |embargo= does not hold a single date.

]]

local function is_valid_embargo_date (v)
	if v:match ('^%d%d%d%d%-%d%d%-%d%d$') or									-- ymd
		v:match ('^%d%d?%s+%a+%s+%d%d%d%d$') or									-- dmy
		v:match ('^%a+%s+%d%d?%s*,%s*%d%d%d%d$') then							-- mdy
			return true, v;
	end
	return false, '9999';														-- if here not good date so return false and set embargo date to long time in future
end


--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 1 for Winter, etc.  Capitalization and spelling must be correct. If not a valid season, returns 0

]]

local function get_season_number (season)
local season_list = {['Winter']=21, ['Spring']=22, ['Summer']=23, ['Fall']=24, ['Autumn']=24};	-- make sure these numbers do not overlap month numbers
local temp;
	temp=season_list[season];
	if temp then return temp; end												-- if season is a valid name return its number
	return 0;																	-- misspelled, improper case, or not a season name
end

--[[--------------------------&lt; I S _ P R O P E R _ N A M E &gt;--------------------------------------------------

returns a non-zero number if date contains a recognized proper name.  Capitalization and spelling must be correct.

]]

local function is_proper_name (name)
local name_list = {['Christmas']=31}
local temp;
	temp=name_list[name];
	if temp then return temp; end				-- if name is a valid name return its number
	return 0;									-- misspelled, improper case, or not a proper name
end

--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ O R _ S E A S O N &gt;------------------------------

--returns true if month or season is valid (properly spelled, capitalized, abbreviated)

]]

local function is_valid_month_or_season (month_season)
	if 0 == get_month_number (month_season) then		-- if month text isn't one of the twelve months, might be a season
		if 0 == get_season_number (month_season) then	-- not a month, is it a season?
			return false;								-- return false not a month or one of the five seasons
		end
	end
	return true;
end

--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one year in the future are not acceptable.

]]
local year_limit;
local function is_valid_year(year)
	if not is_set(year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;			-- global variable so we only have to fetch it once
	end
	return tonumber(year) &lt;= year_limit;				-- false if year is in the future more than one year
end

--[[--------------------------&lt; I S _ V A L I D _ D A T E &gt;----------------------------------------------------
Returns true if day is less than or equal to the number of days in month and year is no farther into the future
than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap
years before 1582 and Gregorian leap years after 1582. Where the two calendars overlap (1582 to approximately
1923) dates are assumed to be Gregorian.

]]

local function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year(year) then												-- no farther into the future than next year
		return false;
	end
	
	month = tonumber(month);													-- required for YYYY-MM-DD dates
	
	if (2==month) then															-- if February
		month_length = 28;														-- then 28 days unless
		if 1582 &gt; tonumber(year) then											-- Julian calendar
			if 0==(year%4) then
				month_length = 29;
			end
		else																	-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then			-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end

--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
There is a special test for May because it can be either short or long form.

Returns true when style for both months is the same

]]

local function is_valid_month_range_style (month1, month2)
local len1 = month1:len();
local len2 = month2:len();
	if len1 == len2 then
		return true;															-- both months are short form so return true
	elseif 'May' == month1 or 'May'== month2 then
		return true;															-- both months are long form so return true
	elseif 3 == len1 or 3 == len2 then
		return false;															-- months are mixed form so return false
	else
		return true;															-- both months are long form so return true
	end
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

Similarly, seasons are also left to right, earliest to latest in time.  There is an oddity with seasons: winter is assigned a value of 1, spring 2, ...,
fall and autumn 4.  Because winter can follow fall/autumn at the end of a calender year, a special test is made to see if |date=Fall-Winter yyyy (4-1) is the date.

]]

local function is_valid_month_season_range(range_start, range_end)
	local range_start_number = get_month_number (range_start);
	local range_end_number;
	
	if 0 == range_start_number then												-- is this a month range?
		local range_start_number = get_season_number (range_start);				-- not a month; is it a season? get start season number
		range_end_number = get_season_number (range_end);						-- get end season number

		if 0 ~= range_start_number then											-- is start of range a season?
			if range_start_number &lt; range_end_number then						-- range_start is a season
				return true;													-- return true when range_end is also a season and follows start season; else false
			end
			if 24 == range_start_number and 21 == range_end_number then			-- special case when season range is Fall-Winter or Autumn-Winter
				return true;
			end
		end
		return false;		-- range_start is not a month or a season; or range_start is a season and range_end is not; or improper season sequence
	end

	range_end_number = get_month_number (range_end);							-- get end month number
	if range_start_number &lt; range_end_number then								-- range_start is a month; does range_start precede range_end?
		if is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
		end
	end
	return false;																-- range_start month number is greater than or equal to range end number; or range end isn't a month
end


--[[--------------------------&lt; M A K E _ C O I N S _ D A T E &gt;------------------------------------------------

This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1.  The function is called only for |date= parameters and only if the |date=&lt;value&gt; is 
determined to be a valid date format.  The question of what to do with invalid date formats is not answered here.

The date parts in the input table are converted to an ISO 8601 conforming date string:
	single whole dates:		yyyy-mm-dd
	month and year dates:	yyyy-mm
	year dates:				yyyy
	ranges:					yyyy-mm-dd/yyyy-mm-dd
							yyyy-mm/yyyy-mm
							yyyy/yyyy

Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.

The input table has:
	year, year2 – always present; if before 1582, ignore months and days if present
	month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 31– proper name dates
	day, day2 –  0 if not provided, 1-31 for days
	
the output table receives:
	rftdate:	an IS8601 formatted date
	rftchron:	a free-form version of the date, usually without year which is in rftdate (season ranges and propername dates)
	rftssn:		one of four season keywords: winter, spring, summer, fall (lowercase)

]]

local function make_COinS_date (input, tCOinS_date)
	local date;																	-- one date or first date in a range
	local date2 = '';															-- end of range date
	
	if 1582 &gt; tonumber(input.year) or 20 &lt; tonumber(input.month) then			-- Julian calendar or season so &amp;rft.date gets year only
		date = input.year;
		if 0 ~= input.year2 and input.year ~= input.year2 then					-- if a range, only the second year portion when not the same as range start year
			date = string.format ('%.4d/%.4d', tonumber(input.year), tonumber(input.year2))		-- assemble the date range
		end
		if 20 &lt; tonumber(input.month) then										-- if season or propername date
			local season = {[21]='winter', [22]='spring', [23]='summer', [24]='fall', [31]='Christmas'};	-- seasons lowercase, no autumn; proper names use title case
			if 0 == input.month2 then											-- single season date
				if 30 &lt;tonumber(input.month) then
					tCOinS_date.rftchron = season[input.month];					-- proper name dates
				else
					tCOinS_date.rftssn = season[input.month];					-- seasons
				end
			else																-- season range with a second season specified
				if input.year ~= input.year2 then								-- season year – season year range or season year–year
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					if 0~= input.month2 then
						tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);
					end
				else															-- season–season year range
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2];	-- season–season year range
				end
			end
		end
		tCOinS_date.rftdate = date;
		return;																	-- done
	end
	
	if 0 ~= input.day then
		date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day));	-- whole date
	elseif 0 ~= input.month then
		date = string.format ('%s-%.2d', input.year, tonumber(input.month));	-- year and month
	else
		date = string.format ('%s', input.year);								-- just year
	end

	if 0 ~= input.year2 then
		if 0 ~= input.day2 then
			date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2));		-- whole date
		elseif 0 ~= input.month2 then
			date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2));	-- year and month
		else
			date2 = string.format ('/%s', input.year2);							-- just year
		end
	end
	
	tCOinS_date.rftdate = date .. date2;										-- date2 has the '/' separator
	return;
end


--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only
allowed range separator is endash.  Additionally, check the date to see that it is a real date: no 31 in 30-day
months; no 29 February when not a leap year.  Months, both long-form and three character abbreviations, and seasons
must be spelled correctly.  Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and
COinS_date.  When this happens, the date parameter is used in the COinS metadata and the CITEREF identifier gets
its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc.)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is ISO 8601 format date; see make_COInS_date()

]]

local function check_date (date_string, tCOinS_date, test_accessdate)
	local year;			-- assume that year2, months, and days are not used;
	local year2=0;		-- second year in a year range
	local month=0;
	local month2=0;		-- second month in a month range
	local day=0;
	local day2=0;		-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then										-- year-initial numerical year month day format
		year, month, day=string.match(date_string, &quot;(%d%d%d%d)%-(%d%d)%-(%d%d)&quot;);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or 0 == tonumber(day) then return false; end	-- month or day number not valid or not Gregorian calendar
		anchor_year = year;

	elseif date_string:match(&quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then						-- month-initial: month day, year
		month, day, anchor_year, year=string.match(date_string, &quot;(%a+)%s*(%d%d?),%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
				
	elseif mw.ustring.match(date_string, &quot;^%a+ +[1-9]%d?[%-–][1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year=mw.ustring.match(date_string, &quot;(%a+) +(%d%d?)[%-–](%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
		month2=month;																		-- for metadata
		year2=year;

	elseif date_string:match(&quot;^[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then						-- day-initial: day month year
		day, month, anchor_year, year=string.match(date_string, &quot;(%d%d*)%s*(%a+)%s*((%d%d%d%d)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d?[%-–][1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year=mw.ustring.match(date_string, &quot;(%d%d?)[%-–](%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
		month2=month;																		-- for metadata
		year2=year;

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d? +%a+ [%-–] [1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year=mw.ustring.match(date_string, &quot;(%d%d?) +(%a+) [%-–] (%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);													-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif mw.ustring.match(date_string, &quot;^%a+ +[1-9]%d? [%-–] %a+ +[1-9]%d?, +[1-9]%d%d%d?%a?$&quot;) then		-- month initial month-day-range: month day – month day, year;  uses spaced endash
		month, day, month2, day2, anchor_year, year=mw.ustring.match(date_string, &quot;(%a+) +(%d%d?) [%-–] (%a+) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);													-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d? +%a+ +[1-9]%d%d%d [%-–] [1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2=mw.ustring.match(date_string, &quot;(%d%d?) +(%a+) +(%d%d%d%d?) [%-–] (%d%d?) +(%a+) +((%d%d%d%d?)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end												-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);																		-- for metadata
		month2 = get_month_number (month2);

	elseif mw.ustring.match(date_string, &quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d [%-–] %a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then		-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
		month, day, year, month2, day2, anchor_year, year2=mw.ustring.match(date_string, &quot;(%a+) +(%d%d?), +(%d%d%d%d) [%-–] (%a+) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end												-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);																		-- for metadata
		month2 = get_month_number (month2);

	elseif mw.ustring.match(date_string, &quot;^%a+ +[1-9]%d%d%d[%-–]%d%d%a?$&quot;) then								-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		local century;
		month, year, century, anchor_year, year2=mw.ustring.match(date_string, &quot;(%a+) +((%d%d)%d%d)[%-–]((%d%d)%a?)&quot;);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;					-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		year2 = century..year2;																-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		month = get_season_number (month);

	elseif mw.ustring.match(date_string, &quot;^%a+ +[1-9]%d%d%d[%-–][1-9]%d%d%d%a?$&quot;) then						-- special case Winter/Summer year-year; year separated with unspaced endash
		month, year, anchor_year, year2=mw.ustring.match(date_string, &quot;(%a+) +(%d%d%d%d)[%-–]((%d%d%d%d)%a?)&quot;);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;					-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		month = get_season_number (month);													-- for metadata

	elseif mw.ustring.match(date_string, &quot;^%a+ +[1-9]%d%d%d +[%-–] +%a+ +[1-9]%d%d%d%a?$&quot;) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2=mw.ustring.match(date_string, &quot;(%a+) +(%d%d%d%d) +[%-–] +(%a+) +((%d%d%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end							-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then 	-- both must be month year, same month style
			month = get_month_number(month);
			month2 = get_month_number(month2);
		elseif 0 ~= get_season_number(month) and 0 ~= get_season_number(month2) then		-- both must be or season year, not mixed
			month = get_season_number(month);
			month2 = get_season_number(month2);
		else
			 return false;
		end

	elseif mw.ustring.match(date_string, &quot;^%a+[%-–]%a+ +[1-9]%d%d%d%a?$&quot;) then					-- month/season range year; months separated by endash 
		month, month2, anchor_year, year=mw.ustring.match(date_string, &quot;(%a+)[%-–](%a+)%s*((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or (not is_valid_year(year)) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
			month2 = get_month_number(month2);
		else
			month = get_season_number(month);
			month2 = get_season_number(month2);
		end
		year2=year;
		
	elseif date_string:match(&quot;^%a+ +%d%d%d%d%a?$&quot;) then							-- month/season year or proper-name year
		month, anchor_year, year=date_string:match(&quot;(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if not is_valid_year(year) then return false; end
		if not is_valid_month_or_season (month) and 0 == is_proper_name (month) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
		elseif 0 ~= get_season_number(month) then
			month = get_season_number(month);
		else
			month = is_proper_name (month);										-- must be proper name; not supported in COinS
		end

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d%d%d?[%-–][1-9]%d%d%d?%a?$&quot;) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2=mw.ustring.match(date_string, &quot;(%d%d%d%d?)[%-–]((%d%d%d%d?)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d%d%d[%-–]%d%d%a?$&quot;) then						-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2=mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]((%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century..year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then							-- year; here accept either YYY or YYYY
		anchor_year, year=date_string:match(&quot;((%d%d%d%d?)%a?)&quot;);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;															-- date format not one of the MOS:DATE approved formats
	end

	if test_accessdate then														-- test accessdate here because we have numerical date parts
		if 0 ~= year and 0 ~= month and 0 ~= day and 							-- all parts of a single date required
			0 == year2 and 0 == month2 and 0 == day2 then						-- none of these; accessdate must not be a range
				if not is_valid_accessdate (year..'-'..month..'-'..day) then	
					return false;												-- return false when accessdate out of bounds
				end
		else
			return false;														-- return false when accessdate is a range of two dates
		end
	end

	local result=true;															-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result=is_valid_date(year,month,day);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month2,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year2,month2,day2);
	end
	
	if false == result then return false; end

	if nil ~= tCOinS_date then													-- this table only passed into this function when testing |date= parameter values
		make_COinS_date ({year=year, month=month, day=day, year2=year2, month2=month2, day2=day2}, tCOinS_date);	-- make an ISO 8601 date string for COinS
	end
	
	return true, anchor_year;													-- format is good and date string represents a real date
end	


--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.

]]

local function dates(date_parameters_list, tCOinS_date)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local embargo_date;															-- if embargo date is a good dmy, mdy, ymd date then holds original value else reset to 9999
	local error_message = &quot;&quot;;
	local good_date = false;
	
	for k, v in pairs(date_parameters_list) do									-- for each date-holding parameter in the list
		if is_set(v) then														-- if the parameter has a value
			if v:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then							-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);					-- get the year portion so it can be tested
				if 'date'==k then
					anchor_year, COinS_date = v:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year'==k then
					good_date = is_valid_year(year);
				end
			elseif 'date'==k then												-- if the parameter is |date=
				if v:match(&quot;^n%.d%.%a?$&quot;) then									-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v:match(&quot;^nd%a?$&quot;) then									-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v, tCOinS_date);	-- go test the date
				end
			elseif 'year'==k then												-- if the parameter is |year= it should hold only a year value
				if v:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then							-- if |year= 3 or 4 digits only with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((%d+)%a?)&quot;);
				end
			elseif 'access-date'==k then										-- if the parameter is |date=
				good_date = check_date (v, nil, true);							-- go test the date; nil is a placeholder; true is the test_accessdate flag
			elseif 'embargo'==k then											-- if the parameter is |embargo=
				good_date = check_date (v);										-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date, embargo_date = is_valid_embargo_date (v);		-- is |embargo= date a single dmy, mdy, or ymd formatted date? yes:returns embargo; no: returns 9999
				end
			else																-- any other date-holding parameter
				good_date = check_date (v);										-- go test the date
			end
			if false==good_date then											-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then									-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;						-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;			-- add the failed parameter
			end
		end
	end
	return anchor_year, embargo_date, error_message;											-- and done
end


--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function returns a numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

]]

local function year_date_check (year_string, date_string)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes
	
	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where both date and year are required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard range formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif mw.ustring.match(date_string, &quot;%d%d%d%d[%-–]%d%d&quot;) then								-- YYYY-YY date ranges
		local century;
		date1, century, date2 = mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	else
		result = 0;																-- no recognizable year in date
	end
	return result;
end


--[[-------------------------&lt; R E F O R M A T   T A B L E S &gt;------------------------------------------------

These table are used exclusively for reformatting dates

]]

local source_patterns = {						-- this table holds patterns that match allowed date formats used to extract date components
	['dmy'] = '(%d%d?)%s+(%a+)%s+(%d%d%d%d)',
	['mdy'] = '(%a+)%s+(%d%d?),%s+(%d%d%d%d)',
	['ymd'] = '(%d%d%d%d)%-(%d%d)-(%d%d)',
	}

local short_formats = {							-- this table holds format strings used by os.date() for short month names
	['dmy'] = '%e %b %Y',
	['mdy'] = '%b %e, %Y',
	['ymd'] = '%F',
	}

local long_formats = {							-- this table holds format strings used by os.date() for long month names
	['dmy'] = '%e %B %Y',
	['mdy'] = '%B %e, %Y',
	['ymd'] = '%F',
	}


--[[-------------------------&lt; G E T _ D M Y _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from DMY formatted date, places them in the source_date table, and returns.

]]

local function get_dmy_date_parts (date, source_date)
	source_date.day, source_date.month, source_date.year = date:match (source_patterns['dmy']);	-- get date components as strings
	source_date.month = get_month_number (source_date.month);					-- get month number
end


--[[-------------------------&lt; G E T _ M D Y _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from MDY formatted date, places them in the source_date table, and returns.

]]

local function get_mdy_date_parts (date, source_date)
	source_date.month, source_date.day, source_date.year = date:match (source_patterns['mdy']);	-- get date components as strings
	source_date.month = get_month_number (source_date.month);					-- get month number
end


--[[-------------------------&lt; G E T _ Y M D _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from YMD formatted date, places them in the source_date table, and returns.

]]

local function get_ymd_date_parts (date, source_date)
	source_date.year, source_date.month, source_date.day = date:match (source_patterns['ymd']);	-- get date components as strings
end


--[[-------------------------&lt; R E F O R M A T _ D A T E S &gt;--------------------------------------------------

Reformats existing dates into the format specified by format and short.

format is one of several keywords: dmy, dmy-all, mdy, mdy-all, ymd, ymd-all.  The all version includes access- and
archive-dates; otherwise these dates are not reformatted

Date ranges, season dates, proper name dates are not currently supported.

]]

local function reformat_dates (date_parameters_list, format, short)
	local all = false;															-- set to false to skip access- and archive-dates
	local format_str;
	local source_date = {};
	
	if format:match('%a+%-all') then
		format = format:match('(%a+)%-all');									-- extract the format
		all = true;																-- set to true to format access- and archive-dates
	end
	
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val) then												-- if the parameter has a value
			if not all and in_array (param_name, {'access-date', 'archive-date'}) then	-- if access- or archive-date and format not xxx-all
				param_val = '';													-- set to empty string so we don't process this date
			end
			for source, pattern in pairs(source_patterns) do
				if param_val:match(pattern) then
					if 'ymd' == source then
						get_ymd_date_parts (param_val, source_date);			-- get the date parts into the source_date table
					elseif 'dmy' == source then
						get_dmy_date_parts (param_val, source_date);			-- get the date parts into the source_date table
					elseif 'mdy' == source then
						get_mdy_date_parts (param_val, source_date);			-- get the date parts into the source_date table
					end

					if 'ymd' == format and 1582 &gt; tonumber(source_date.year) then	-- ymd format dates not allowed before 1582
						return false;											-- abandon reformatting
					end
					
					if short then
						format_str = short_formats[format];
					else
						format_str = long_formats[format];
					end
																				-- convert date and save;
					date_parameters_list[param_name] = mw.text.trim (os.date (format_str, os.time(source_date)));	-- strip leading space when single digit day and %e is first format
				end
			end
		end
	end
	return true;																-- declare success and done
end


--[[--------------------------&lt; D A T E _ H Y P H E N _ T O _ D A S H &gt;----------------------------------------

Loops through the list of date-holding parameters and converts any hyphen to an ndash.  Not called if the cs1|2
template has any date errors.

Modifies the date_parameters_list and returns true if hyphens are replaced, else returns false.

]]

local function date_hyphen_to_dash (date_parameters_list)
	local result = false;
	local n;
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if not param_val:match ('%d%d%d%d%-%d%d%-%d%d') then					-- for those that are not ymd dates
			param_val, n = param_val:gsub ('%-', '–');							-- replace any hyphen with ndash
			if 0 ~= n then
				date_parameters_list[param_name] = param_val;					-- update the list
				result = true;
			end
		end
	end
	return result;																-- so we know if 
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (utilities_page_ptr)
	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;											-- import functions from select Module:Citation/CS1/Utilities module
end



return {																		-- return exported functions
	dates = dates,
	year_date_check = year_date_check,
	reformat_dates = reformat_dates,
	date_hyphen_to_dash = date_hyphen_to_dash,
	set_selected_modules = set_selected_modules
	}</text>
      <sha1>i1fv7pqohu4tjsyxsm6wr9x4cy0aoey</sha1>
    </revision>
    <revision>
      <id>4834</id>
      <parentid>4833</parentid>
      <timestamp>2017-11-04T10:41:20Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>synch from sandbox;</comment>
      <origin>4834</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="43216" sha1="b8y1188nwelzc8ed2egv39q5uiun27u" xml:space="preserve">
local p = {}


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array;															-- imported functions from selected Module:Citation/CS1/Utilities
local cfg;																		-- table of tables imported from slected Module:Citation/CS1/Configuration

--[=[-------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |accessdate= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-Engish date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate().  To get around that
call this function with YYYY-MM-DD format dates.

]=]

local function is_valid_accessdate (accessdate)
	local lang = mw.getContentLanguage();
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold unix time stamps representing the dates
		
	good1, access_ts = pcall( lang.formatDate, lang, 'U', accessdate );			-- convert accessdate value to unix timesatmp 
	good2, tomorrow_ts = pcall( lang.formatDate, lang, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then
		access_ts = tonumber (access_ts);										-- convert to numbers for the comparison
		tomorrow_ts = tonumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to unix time stamp
	end

	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end


--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct. If not a valid month, returns 0

]]

local function get_month_number (month)
	return cfg.date_names['local'].long[month] or cfg.date_names['local'].short[month] or		-- look for local names first
			cfg.date_names['en'].long[month] or	cfg.date_names['en'].short[month] or			-- failing that, look for English names
			0;																					-- not a recognized month name
end


--[[--------------------------&lt; I S _ V A L I D _ E M B A R G O _ D A T E &gt;------------------------------------

returns true and date value if that value has proper dmy, mdy, ymd format.

returns false and 9999 (embargoed forever) when date value is not proper format; assumes that when |embargo= is
set, the editor intended to embargo a pmc but |embargo= does not hold a single date.

]]

local function is_valid_embargo_date (v)
	if v:match ('^%d%d%d%d%-%d%d%-%d%d$') or									-- ymd
		v:match ('^%d%d?%s+%a+%s+%d%d%d%d$') or									-- dmy
		v:match ('^%a+%s+%d%d?%s*,%s*%d%d%d%d$') then							-- mdy
			return true, v;
	end
	return false, '9999';														-- if here not good date so return false and set embargo date to long time in future
end


--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 1 for Winter, etc.  Capitalization and spelling must be correct. If not a valid season, returns 0

Uses ISO DIS 8601 2016 part 2 §4.7  Divisions of a year for hemishpere-independent seasons:
	21-24 = Spring, Summer, Autumn, Winter, independent of “Hemisphere”

These additional divisions not currently supported:
	25-28 = Spring - Northern Hemisphere, Summer- Northern Hemisphere, Autumn - Northern Hemisphere, Winter - Northern Hemisphere
	29-32 = Spring – Southern Hemisphere, Summer– Southern Hemisphere, Autumn – Southern Hemisphere, Winter - Southern Hemisphere
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)


]]

local function get_season_number (season)
	return cfg.date_names['local'].season[season] or							-- look for local names first
			cfg.date_names['en'].season[season] or								-- failing that, look for English names
			0;																	-- not a recognized season name
end

--[[--------------------------&lt; I S _ P R O P E R _ N A M E &gt;--------------------------------------------------

returns a non-zero number if date contains a recognized proper name.  Capitalization and spelling must be correct.

]]

local function is_proper_name (name)
	return cfg.date_names['local'].named[name] or								-- look for local names dates first
			cfg.date_names['en'].named[name] or									-- failing that, look for English names
			0;																	-- not a recognized named date
end

--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ O R _ S E A S O N &gt;------------------------------

--returns true if month or season is valid (properly spelled, capitalized, abbreviated)

]]

local function is_valid_month_or_season (month_season)
	if 0 == get_month_number (month_season) then		-- if month text isn't one of the twelve months, might be a season
		if 0 == get_season_number (month_season) then	-- not a month, is it a season?
			return false;								-- return false not a month or one of the five seasons
		end
	end
	return true;
end

--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one year in the future are not acceptable.

]]
local year_limit;
local function is_valid_year(year)
	if not is_set(year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;			-- global variable so we only have to fetch it once
	end
	return tonumber(year) &lt;= year_limit;				-- false if year is in the future more than one year
end

--[[--------------------------&lt; I S _ V A L I D _ D A T E &gt;----------------------------------------------------
Returns true if day is less than or equal to the number of days in month and year is no farther into the future
than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap
years before 1582 and Gregorian leap years after 1582. Where the two calendars overlap (1582 to approximately
1923) dates are assumed to be Gregorian.

]]

local function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year(year) then												-- no farther into the future than next year
		return false;
	end
	
	month = tonumber(month);													-- required for YYYY-MM-DD dates
	
	if (2==month) then															-- if February
		month_length = 28;														-- then 28 days unless
		if 1582 &gt; tonumber(year) then											-- Julian calendar
			if 0==(year%4) then
				month_length = 29;
			end
		else																	-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then			-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end

--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
There is a special test for May because it can be either short or long form.

Returns true when style for both months is the same

]]

local function is_valid_month_range_style (month1, month2)
local len1 = month1:len();
local len2 = month2:len();
	if len1 == len2 then
		return true;															-- both months are short form so return true
	elseif 'May' == month1 or 'May'== month2 then
		return true;															-- both months are long form so return true
	elseif 3 == len1 or 3 == len2 then
		return false;															-- months are mixed form so return false
	else
		return true;															-- both months are long form so return true
	end
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

All season ranges are accepted as valid because there are publishers out there who have published a Summer–Spring YYYY issue so ... ok

]]

local function is_valid_month_season_range(range_start, range_end)
	local range_start_number = get_month_number (range_start);
	local range_end_number;
	
	if 0 == range_start_number then												-- is this a month range?
		range_start_number = get_season_number (range_start);					-- not a month; is it a season? get start season number
		range_end_number = get_season_number (range_end);						-- get end season number

		if (0 ~= range_start_number) and (0 ~= range_end_number) then
			return true;														-- any season pairing is accepted
		end
		return false;															-- range_start and/or range_end is not a season
	end
																				-- here when range_start is a month
	range_end_number = get_month_number (range_end);							-- get end month number
	if range_start_number &lt; range_end_number then								-- range_start is a month; does range_start precede range_end?
		if is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
		end
	end
	return false;																-- range_start month number is greater than or equal to range end number; or range end isn't a month
end


--[[--------------------------&lt; M A K E _ C O I N S _ D A T E &gt;------------------------------------------------

This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1.  The function is called only for |date= parameters and only if the |date=&lt;value&gt; is 
determined to be a valid date format.  The question of what to do with invalid date formats is not answered here.

The date parts in the input table are converted to an ISO 8601 conforming date string:
	single whole dates:		yyyy-mm-dd
	month and year dates:	yyyy-mm
	year dates:				yyyy
	ranges:					yyyy-mm-dd/yyyy-mm-dd
							yyyy-mm/yyyy-mm
							yyyy/yyyy

Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.

The input table has:
	year, year2 – always present; if before 1582, ignore months and days if present
	month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 31– proper name dates
	day, day2 –  0 if not provided, 1-31 for days
	
the output table receives:
	rftdate:	an IS8601 formatted date
	rftchron:	a free-form version of the date, usually without year which is in rftdate (season ranges and propername dates)
	rftssn:		one of four season keywords: winter, spring, summer, fall (lowercase)

]]

local function make_COinS_date (input, tCOinS_date)
	local date;																	-- one date or first date in a range
	local date2 = '';															-- end of range date
	
	if 1582 &gt; tonumber(input.year) or 20 &lt; tonumber(input.month) then			-- Julian calendar or season so &amp;rft.date gets year only
		date = input.year;
		if 0 ~= input.year2 and input.year ~= input.year2 then					-- if a range, only the second year portion when not the same as range start year
			date = string.format ('%.4d/%.4d', tonumber(input.year), tonumber(input.year2))		-- assemble the date range
		end
		if 20 &lt; tonumber(input.month) then										-- if season or propername date
			local season = {[21]='winter', [22]='spring', [23]='summer', [24]='fall', [31]='Christmas'};	-- seasons lowercase, no autumn; proper names use title case
			if 0 == input.month2 then											-- single season date
				if 30 &lt;tonumber(input.month) then
					tCOinS_date.rftchron = season[input.month];					-- proper name dates
				else
					tCOinS_date.rftssn = season[input.month];					-- seasons
				end
			else																-- season range with a second season specified
				if input.year ~= input.year2 then								-- season year – season year range or season year–year
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					if 0~= input.month2 then
						tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);
					end
				else															-- season–season year range
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2];	-- season–season year range
				end
			end
		end
		tCOinS_date.rftdate = date;
		return;																	-- done
	end
	
	if 0 ~= input.day then
		date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day));	-- whole date
	elseif 0 ~= input.month then
		date = string.format ('%s-%.2d', input.year, tonumber(input.month));	-- year and month
	else
		date = string.format ('%s', input.year);								-- just year
	end

	if 0 ~= input.year2 then
		if 0 ~= input.day2 then
			date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2));		-- whole date
		elseif 0 ~= input.month2 then
			date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2));	-- year and month
		else
			date2 = string.format ('/%s', input.year2);							-- just year
		end
	end
	
	tCOinS_date.rftdate = date .. date2;										-- date2 has the '/' separator
	return;
end


--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only
allowed range separator is endash.  Additionally, check the date to see that it is a real date: no 31 in 30-day
months; no 29 February when not a leap year.  Months, both long-form and three character abbreviations, and seasons
must be spelled correctly.  Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and
COinS_date.  When this happens, the date parameter is used in the COinS metadata and the CITEREF identifier gets
its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc.)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is ISO 8601 format date; see make_COInS_date()

]]

local function check_date (date_string, tCOinS_date, test_accessdate)
	local year;			-- assume that year2, months, and days are not used;
	local year2=0;		-- second year in a year range
	local month=0;
	local month2=0;		-- second month in a month range
	local day=0;
	local day2=0;		-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then										-- year-initial numerical year month day format
		year, month, day=string.match(date_string, &quot;(%d%d%d%d)%-(%d%d)%-(%d%d)&quot;);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or 0 == tonumber(day) then return false; end	-- month or day number not valid or not Gregorian calendar
		anchor_year = year;
	elseif date_string:match(&quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then						-- month-initial: month day, year
		month, day, anchor_year, year=string.match(date_string, &quot;(%a+)%s*(%d%d?),%s*((%d%d%d%d?)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
				
	elseif mw.ustring.match(date_string, &quot;^%a+ +[1-9]%d?[%-–][1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year=mw.ustring.match(date_string, &quot;(%a+) +(%d%d?)[%-–](%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
		month2=month;																		-- for metadata
		year2=year;

	elseif date_string:match(&quot;^[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then						-- day-initial: day month year
		day, month, anchor_year, year=string.match(date_string, &quot;(%d%d*)%s*(%a+)%s*((%d%d%d%d?)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d?[%-–][1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year=mw.ustring.match(date_string, &quot;(%d%d?)[%-–](%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
		month2=month;																		-- for metadata
		year2=year;

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d? +%a+ [%-–] [1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year=mw.ustring.match(date_string, &quot;(%d%d?) +(%a+) [%-–] (%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);													-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif mw.ustring.match(date_string, &quot;^%a+ +[1-9]%d? [%-–] %a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then		-- month initial month-day-range: month day – month day, year;  uses spaced endash
		month, day, month2, day2, anchor_year, year=mw.ustring.match(date_string, &quot;(%a+) +(%d%d?) [%-–] (%a+) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);													-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d? +%a+ +[1-9]%d%d%d [%-–] [1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2=mw.ustring.match(date_string, &quot;(%d%d?) +(%a+) +(%d%d%d%d) [%-–] (%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end												-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);																		-- for metadata
		month2 = get_month_number (month2);

	elseif mw.ustring.match(date_string, &quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d [%-–] %a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then		-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
		month, day, year, month2, day2, anchor_year, year2=mw.ustring.match(date_string, &quot;(%a+) +(%d%d?), +(%d%d%d%d) [%-–] (%a+) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end												-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);																		-- for metadata
		month2 = get_month_number (month2);

	elseif mw.ustring.match(date_string, &quot;^%a+ +[1-9]%d%d%d[%-–]%d%d%a?$&quot;) then								-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		local century;
		month, year, century, anchor_year, year2=mw.ustring.match(date_string, &quot;(%a+) +((%d%d)%d%d)[%-–]((%d%d)%a?)&quot;);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;					-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		year2 = century..year2;																-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		month = get_season_number (month);

	elseif mw.ustring.match(date_string, &quot;^%a+ +[1-9]%d%d%d[%-–][1-9]%d%d%d%a?$&quot;) then						-- special case Winter/Summer year-year; year separated with unspaced endash
		month, year, anchor_year, year2=mw.ustring.match(date_string, &quot;(%a+) +(%d%d%d%d)[%-–]((%d%d%d%d)%a?)&quot;);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;					-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		month = get_season_number (month);													-- for metadata

	elseif mw.ustring.match(date_string, &quot;^%a+ +[1-9]%d%d%d +[%-–] +%a+ +[1-9]%d%d%d%a?$&quot;) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2=mw.ustring.match(date_string, &quot;(%a+) +(%d%d%d%d) +[%-–] +(%a+) +((%d%d%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end							-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then 	-- both must be month year, same month style
			month = get_month_number(month);
			month2 = get_month_number(month2);
		elseif 0 ~= get_season_number(month) and 0 ~= get_season_number(month2) then		-- both must be or season year, not mixed
			month = get_season_number(month);
			month2 = get_season_number(month2);
		else
			 return false;
		end

	elseif mw.ustring.match(date_string, &quot;^%a+[%-–]%a+ +[1-9]%d%d%d%a?$&quot;) then					-- month/season range year; months separated by endash 
		month, month2, anchor_year, year=mw.ustring.match(date_string, &quot;(%a+)[%-–](%a+)%s*((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or (not is_valid_year(year)) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
			month2 = get_month_number(month2);
		else
			month = get_season_number(month);
			month2 = get_season_number(month2);
		end
		year2=year;
		
	elseif date_string:match(&quot;^%a+ +%d%d%d%d%a?$&quot;) then							-- month/season year or proper-name year
		month, anchor_year, year=date_string:match(&quot;(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if not is_valid_year(year) then return false; end
		if not is_valid_month_or_season (month) and 0 == is_proper_name (month) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
		elseif 0 ~= get_season_number(month) then
			month = get_season_number(month);
		else
			month = is_proper_name (month);										-- must be proper name; not supported in COinS
		end

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d%d%d?[%-–][1-9]%d%d%d?%a?$&quot;) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2=mw.ustring.match(date_string, &quot;(%d%d%d%d?)[%-–]((%d%d%d%d?)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d%d%d[%-–]%d%d%a?$&quot;) then						-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2=mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]((%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century..year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then							-- year; here accept either YYY or YYYY
		anchor_year, year=date_string:match(&quot;((%d%d%d%d?)%a?)&quot;);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;															-- date format not one of the MOS:DATE approved formats
	end

	if test_accessdate then														-- test accessdate here because we have numerical date parts
		if 0 ~= year and 0 ~= month and 0 ~= day and 							-- all parts of a single date required
			0 == year2 and 0 == month2 and 0 == day2 then						-- none of these; accessdate must not be a range
				if not is_valid_accessdate (year..'-'..month..'-'..day) then	
					return false;												-- return false when accessdate out of bounds
				end
		else
			return false;														-- return false when accessdate is a range of two dates
		end
	end

	local result=true;															-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result=is_valid_date(year,month,day);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month2,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year2,month2,day2);
	end
	
	if false == result then return false; end

	if nil ~= tCOinS_date then													-- this table only passed into this function when testing |date= parameter values
		make_COinS_date ({year=year, month=month, day=day, year2=year2, month2=month2, day2=day2}, tCOinS_date);	-- make an ISO 8601 date string for COinS
	end
	
	return true, anchor_year;													-- format is good and date string represents a real date
end	


--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.

]]

local function dates(date_parameters_list, tCOinS_date)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local embargo_date;															-- if embargo date is a good dmy, mdy, ymd date then holds original value else reset to 9999
	local error_message = &quot;&quot;;
	local good_date = false;
	
	for k, v in pairs(date_parameters_list) do									-- for each date-holding parameter in the list
		if is_set(v) then														-- if the parameter has a value
			if v:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then							-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);					-- get the year portion so it can be tested
				if 'date'==k then
					anchor_year, COinS_date = v:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year'==k then
					good_date = is_valid_year(year);
				end
			elseif 'date'==k then												-- if the parameter is |date=
				if v:match(&quot;^n%.d%.%a?$&quot;) then									-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v:match(&quot;^nd%a?$&quot;) then									-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v, tCOinS_date);	-- go test the date
				end
			elseif 'year'==k then												-- if the parameter is |year= it should hold only a year value
				if v:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then							-- if |year= 3 or 4 digits only with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((%d+)%a?)&quot;);
				end
			elseif 'access-date'==k then										-- if the parameter is |date=
				good_date = check_date (v, nil, true);							-- go test the date; nil is a placeholder; true is the test_accessdate flag
			elseif 'embargo'==k then											-- if the parameter is |embargo=
				good_date = check_date (v);										-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date, embargo_date = is_valid_embargo_date (v);		-- is |embargo= date a single dmy, mdy, or ymd formatted date? yes:returns embargo; no: returns 9999
				end
			else																-- any other date-holding parameter
				good_date = check_date (v);										-- go test the date
			end
			if false==good_date then											-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then									-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;						-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;			-- add the failed parameter
			end
		end
	end
	return anchor_year, embargo_date, error_message;											-- and done
end


--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function returns a numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

]]

local function year_date_check (year_string, date_string)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes
	
	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where both date and year are required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard range formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif mw.ustring.match(date_string, &quot;%d%d%d%d[%-–]%d%d&quot;) then								-- YYYY-YY date ranges
		local century;
		date1, century, date2 = mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	else
		result = 0;																-- no recognizable year in date
	end
	return result;
end


--[[-------------------------&lt; R E F O R M A T   T A B L E S &gt;------------------------------------------------

These table are used exclusively for reformatting dates

]]

local source_patterns = {						-- this table holds patterns that match allowed date formats used to extract date components
	['dmy'] = '^(%d%d?)%s+(%a+)%s+(%d%d%d%d)$',
	['mdy'] = '^(%a+)%s+(%d%d?),%s+(%d%d%d%d)$',
	['ymd'] = '^(%d%d%d%d)%-(%d%d)-(%d%d)$',
	}

local short_formats = {							-- this table holds format strings used by os.date() for short month names
	['dmy'] = '%e %b %Y',
	['mdy'] = '%b %e, %Y',
	['ymd'] = '%F',
	}

local long_formats = {							-- this table holds format strings used by os.date() for long month names
	['dmy'] = '%e %B %Y',
	['mdy'] = '%B %e, %Y',
	['ymd'] = '%F',
	}


--[[-------------------------&lt; G E T _ D M Y _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from DMY formatted date, places them in the source_date table, and returns.

]]

local function get_dmy_date_parts (date, source_date)
	source_date.day, source_date.month, source_date.year = date:match (source_patterns['dmy']);	-- get date components as strings
	source_date.month = get_month_number (source_date.month);					-- get month number
end


--[[-------------------------&lt; G E T _ M D Y _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from MDY formatted date, places them in the source_date table, and returns.

]]

local function get_mdy_date_parts (date, source_date)
	source_date.month, source_date.day, source_date.year = date:match (source_patterns['mdy']);	-- get date components as strings
	source_date.month = get_month_number (source_date.month);					-- get month number
end


--[[-------------------------&lt; G E T _ Y M D _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from YMD formatted date, places them in the source_date table, and returns.

]]

local function get_ymd_date_parts (date, source_date)
	source_date.year, source_date.month, source_date.day = date:match (source_patterns['ymd']);	-- get date components as strings
end


--[[-------------------------&lt; R E F O R M A T _ D A T E S &gt;--------------------------------------------------

Reformats existing dates into the format specified by format and short.

format is one of several keywords: dmy, dmy-all, mdy, mdy-all, ymd, ymd-all.  The all version includes access- and
archive-dates; otherwise these dates are not reformatted

Date ranges, season dates, proper name dates are not currently supported.

For i18n:  This code works only at en.wiki because os.date() doesn't support any languages other than English.
mw.getContentLanguage():formatDate() will work at non-English wikis only when the date format is yyyy-mm-dd. This is
the same issue that plagues is_valid_accessdate()

It is possible that a solution like that written for ht:Module:Citation/CS1/Date_validation date_name_xlate() could be applied to this problem

]]

local function reformat_dates (date_parameters_list, format, short)
	local all = false;															-- set to false to skip access- and archive-dates
	local format_str;
	local source_date = {};
	
	if format:match('%a+%-all') then
		format = format:match('(%a+)%-all');									-- extract the format
		all = true;																-- set to true to format access- and archive-dates
	end
	
	for param_name, param_val in pairs (date_parameters_list) do				-- for each date-holding parameter in the list
		if is_set (param_val) then												-- if the parameter has a value
			if not all and in_array (param_name, {'access-date', 'archive-date'}) then	-- if access- or archive-date and format not xxx-all
				param_val = '';													-- set to empty string so we don't process this date
			end
			for source, pattern in pairs (source_patterns) do
				if param_val:match (pattern) then
					if 'ymd' == source then
						get_ymd_date_parts (param_val, source_date);			-- get the date parts into the source_date table
					elseif 'dmy' == source then
						get_dmy_date_parts (param_val, source_date);			-- get the date parts into the source_date table
					elseif 'mdy' == source then
						get_mdy_date_parts (param_val, source_date);			-- get the date parts into the source_date table
					end

					if 'ymd' == format and 1582 &gt; tonumber(source_date.year) then	-- ymd format dates not allowed before 1582
						return false;											-- abandon reformatting
					end
					
					if short then
						format_str = short_formats[format];
					else
						format_str = long_formats[format];
					end
																				-- convert date and save;
					date_parameters_list[param_name] = mw.text.trim (os.date (format_str, os.time(source_date)));	-- strip leading space when single digit day and %e is first format
				end
			end
		end
	end
	return true;																-- declare success and done
end


--[[--------------------------&lt; D A T E _ H Y P H E N _ T O _ D A S H &gt;----------------------------------------

Loops through the list of date-holding parameters and converts any hyphen to an ndash.  Not called if the cs1|2
template has any date errors.

Modifies the date_parameters_list and returns true if hyphens are replaced, else returns false.

]]

local function date_hyphen_to_dash (date_parameters_list)
	local result = false;
	local n;
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if not param_val:match ('%d%d%d%d%-%d%d%-%d%d') then					-- for those that are not ymd dates
			param_val, n = param_val:gsub ('%-', '–');							-- replace any hyphen with ndash
			if 0 ~= n then
				date_parameters_list[param_name] = param_val;					-- update the list
				result = true;
			end
		end
	end
	return result;																-- so we know if any hyphens were replaced
end


--[[-------------------------&lt; D A T E _ N A M E _ X L A T E &gt;------------------------------------------------

Attempts to translate English month names to local-language month names using names supplied by MediaWiki's
date parser function.  This is simple name-for-name replacement and may not work for all languages.

]]

local function	date_name_xlate (date_parameters_list)
	local xlate;
	local mode;																	-- long or short month names
	local modified = false;
	local date;
	
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val) then												-- if the parameter has a value
			date = param_val;
			for month in mw.ustring.gmatch (date, '%a+') do						-- iterate through all dates in the date (single date or date range)
				if cfg.date_names.en.long[month] then
					mode = 'F';													-- English name is long so use long local name
				elseif cfg.date_names.en.short[month] then
					mode = 'M';													-- English name is short so use short local name
				else
					mode = nil;													-- not an English month name; could be local language month name or an English season name
				end
		
				if mode then															-- might be a season
					xlate = mw.getContentLanguage():formatDate(mode, '1' .. month);		-- translate the month name to this local language
					date = mw.ustring.gsub (date, month, xlate);						-- replace the English with the translation
					date_parameters_list[param_name] = date;							-- save the translated date
					modified = true;
				end
			end

		end
	end
	
	return modified;
	end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	is_set = utilities_page_ptr.is_set;											-- import functions from selected Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;										-- import functions from selected Module:Citation/CS1/Utilities module
	cfg = cfg_table_ptr;														-- import tables from selected Module:Citation/CS1/Configuration
end



return {																		-- return exported functions
	dates = dates,
	year_date_check = year_date_check,
	reformat_dates = reformat_dates,
	date_hyphen_to_dash = date_hyphen_to_dash,
	date_name_xlate = date_name_xlate,
	set_selected_modules = set_selected_modules
	}</text>
      <sha1>b8y1188nwelzc8ed2egv39q5uiun27u</sha1>
    </revision>
    <revision>
      <id>4835</id>
      <parentid>4834</parentid>
      <timestamp>2018-02-11T01:01:15Z</timestamp>
      <contributor>
        <username>IceWelder</username>
        <id>821</id>
      </contributor>
      <minor />
      <comment>/* top */clean up using [[Project:AWB|AWB]]</comment>
      <origin>4835</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="43215" sha1="9dvtrzfmtn2hxrrl1lguon5gdjwybb0" xml:space="preserve">local p = {}


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array;															-- imported functions from selected Module:Citation/CS1/Utilities
local cfg;																		-- table of tables imported from slected Module:Citation/CS1/Configuration

--[=[-------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |accessdate= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-Engish date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate().  To get around that
call this function with YYYY-MM-DD format dates.

]=]

local function is_valid_accessdate (accessdate)
	local lang = mw.getContentLanguage();
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold unix time stamps representing the dates
		
	good1, access_ts = pcall( lang.formatDate, lang, 'U', accessdate );			-- convert accessdate value to unix timesatmp 
	good2, tomorrow_ts = pcall( lang.formatDate, lang, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then
		access_ts = tonumber (access_ts);										-- convert to numbers for the comparison
		tomorrow_ts = tonumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to unix time stamp
	end

	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end


--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct. If not a valid month, returns 0

]]

local function get_month_number (month)
	return cfg.date_names['local'].long[month] or cfg.date_names['local'].short[month] or		-- look for local names first
			cfg.date_names['en'].long[month] or	cfg.date_names['en'].short[month] or			-- failing that, look for English names
			0;																					-- not a recognized month name
end


--[[--------------------------&lt; I S _ V A L I D _ E M B A R G O _ D A T E &gt;------------------------------------

returns true and date value if that value has proper dmy, mdy, ymd format.

returns false and 9999 (embargoed forever) when date value is not proper format; assumes that when |embargo= is
set, the editor intended to embargo a pmc but |embargo= does not hold a single date.

]]

local function is_valid_embargo_date (v)
	if v:match ('^%d%d%d%d%-%d%d%-%d%d$') or									-- ymd
		v:match ('^%d%d?%s+%a+%s+%d%d%d%d$') or									-- dmy
		v:match ('^%a+%s+%d%d?%s*,%s*%d%d%d%d$') then							-- mdy
			return true, v;
	end
	return false, '9999';														-- if here not good date so return false and set embargo date to long time in future
end


--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 1 for Winter, etc.  Capitalization and spelling must be correct. If not a valid season, returns 0

Uses ISO DIS 8601 2016 part 2 §4.7  Divisions of a year for hemishpere-independent seasons:
	21-24 = Spring, Summer, Autumn, Winter, independent of “Hemisphere”

These additional divisions not currently supported:
	25-28 = Spring - Northern Hemisphere, Summer- Northern Hemisphere, Autumn - Northern Hemisphere, Winter - Northern Hemisphere
	29-32 = Spring – Southern Hemisphere, Summer– Southern Hemisphere, Autumn – Southern Hemisphere, Winter - Southern Hemisphere
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)


]]

local function get_season_number (season)
	return cfg.date_names['local'].season[season] or							-- look for local names first
			cfg.date_names['en'].season[season] or								-- failing that, look for English names
			0;																	-- not a recognized season name
end

--[[--------------------------&lt; I S _ P R O P E R _ N A M E &gt;--------------------------------------------------

returns a non-zero number if date contains a recognized proper name.  Capitalization and spelling must be correct.

]]

local function is_proper_name (name)
	return cfg.date_names['local'].named[name] or								-- look for local names dates first
			cfg.date_names['en'].named[name] or									-- failing that, look for English names
			0;																	-- not a recognized named date
end

--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ O R _ S E A S O N &gt;------------------------------

--returns true if month or season is valid (properly spelled, capitalized, abbreviated)

]]

local function is_valid_month_or_season (month_season)
	if 0 == get_month_number (month_season) then		-- if month text isn't one of the twelve months, might be a season
		if 0 == get_season_number (month_season) then	-- not a month, is it a season?
			return false;								-- return false not a month or one of the five seasons
		end
	end
	return true;
end

--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one year in the future are not acceptable.

]]
local year_limit;
local function is_valid_year(year)
	if not is_set(year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;			-- global variable so we only have to fetch it once
	end
	return tonumber(year) &lt;= year_limit;				-- false if year is in the future more than one year
end

--[[--------------------------&lt; I S _ V A L I D _ D A T E &gt;----------------------------------------------------
Returns true if day is less than or equal to the number of days in month and year is no farther into the future
than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap
years before 1582 and Gregorian leap years after 1582. Where the two calendars overlap (1582 to approximately
1923) dates are assumed to be Gregorian.

]]

local function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year(year) then												-- no farther into the future than next year
		return false;
	end
	
	month = tonumber(month);													-- required for YYYY-MM-DD dates
	
	if (2==month) then															-- if February
		month_length = 28;														-- then 28 days unless
		if 1582 &gt; tonumber(year) then											-- Julian calendar
			if 0==(year%4) then
				month_length = 29;
			end
		else																	-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then			-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end

--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
There is a special test for May because it can be either short or long form.

Returns true when style for both months is the same

]]

local function is_valid_month_range_style (month1, month2)
local len1 = month1:len();
local len2 = month2:len();
	if len1 == len2 then
		return true;															-- both months are short form so return true
	elseif 'May' == month1 or 'May'== month2 then
		return true;															-- both months are long form so return true
	elseif 3 == len1 or 3 == len2 then
		return false;															-- months are mixed form so return false
	else
		return true;															-- both months are long form so return true
	end
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

All season ranges are accepted as valid because there are publishers out there who have published a Summer–Spring YYYY issue so ... ok

]]

local function is_valid_month_season_range(range_start, range_end)
	local range_start_number = get_month_number (range_start);
	local range_end_number;
	
	if 0 == range_start_number then												-- is this a month range?
		range_start_number = get_season_number (range_start);					-- not a month; is it a season? get start season number
		range_end_number = get_season_number (range_end);						-- get end season number

		if (0 ~= range_start_number) and (0 ~= range_end_number) then
			return true;														-- any season pairing is accepted
		end
		return false;															-- range_start and/or range_end is not a season
	end
																				-- here when range_start is a month
	range_end_number = get_month_number (range_end);							-- get end month number
	if range_start_number &lt; range_end_number then								-- range_start is a month; does range_start precede range_end?
		if is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
		end
	end
	return false;																-- range_start month number is greater than or equal to range end number; or range end isn't a month
end


--[[--------------------------&lt; M A K E _ C O I N S _ D A T E &gt;------------------------------------------------

This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1.  The function is called only for |date= parameters and only if the |date=&lt;value&gt; is 
determined to be a valid date format.  The question of what to do with invalid date formats is not answered here.

The date parts in the input table are converted to an ISO 8601 conforming date string:
	single whole dates:		yyyy-mm-dd
	month and year dates:	yyyy-mm
	year dates:				yyyy
	ranges:					yyyy-mm-dd/yyyy-mm-dd
							yyyy-mm/yyyy-mm
							yyyy/yyyy

Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.

The input table has:
	year, year2 – always present; if before 1582, ignore months and days if present
	month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 31– proper name dates
	day, day2 –  0 if not provided, 1-31 for days
	
the output table receives:
	rftdate:	an IS8601 formatted date
	rftchron:	a free-form version of the date, usually without year which is in rftdate (season ranges and propername dates)
	rftssn:		one of four season keywords: winter, spring, summer, fall (lowercase)

]]

local function make_COinS_date (input, tCOinS_date)
	local date;																	-- one date or first date in a range
	local date2 = '';															-- end of range date
	
	if 1582 &gt; tonumber(input.year) or 20 &lt; tonumber(input.month) then			-- Julian calendar or season so &amp;rft.date gets year only
		date = input.year;
		if 0 ~= input.year2 and input.year ~= input.year2 then					-- if a range, only the second year portion when not the same as range start year
			date = string.format ('%.4d/%.4d', tonumber(input.year), tonumber(input.year2))		-- assemble the date range
		end
		if 20 &lt; tonumber(input.month) then										-- if season or propername date
			local season = {[21]='winter', [22]='spring', [23]='summer', [24]='fall', [31]='Christmas'};	-- seasons lowercase, no autumn; proper names use title case
			if 0 == input.month2 then											-- single season date
				if 30 &lt;tonumber(input.month) then
					tCOinS_date.rftchron = season[input.month];					-- proper name dates
				else
					tCOinS_date.rftssn = season[input.month];					-- seasons
				end
			else																-- season range with a second season specified
				if input.year ~= input.year2 then								-- season year – season year range or season year–year
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					if 0~= input.month2 then
						tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);
					end
				else															-- season–season year range
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2];	-- season–season year range
				end
			end
		end
		tCOinS_date.rftdate = date;
		return;																	-- done
	end
	
	if 0 ~= input.day then
		date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day));	-- whole date
	elseif 0 ~= input.month then
		date = string.format ('%s-%.2d', input.year, tonumber(input.month));	-- year and month
	else
		date = string.format ('%s', input.year);								-- just year
	end

	if 0 ~= input.year2 then
		if 0 ~= input.day2 then
			date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2));		-- whole date
		elseif 0 ~= input.month2 then
			date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2));	-- year and month
		else
			date2 = string.format ('/%s', input.year2);							-- just year
		end
	end
	
	tCOinS_date.rftdate = date .. date2;										-- date2 has the '/' separator
	return;
end


--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only
allowed range separator is endash.  Additionally, check the date to see that it is a real date: no 31 in 30-day
months; no 29 February when not a leap year.  Months, both long-form and three character abbreviations, and seasons
must be spelled correctly.  Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and
COinS_date.  When this happens, the date parameter is used in the COinS metadata and the CITEREF identifier gets
its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc.)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is ISO 8601 format date; see make_COInS_date()

]]

local function check_date (date_string, tCOinS_date, test_accessdate)
	local year;			-- assume that year2, months, and days are not used;
	local year2=0;		-- second year in a year range
	local month=0;
	local month2=0;		-- second month in a month range
	local day=0;
	local day2=0;		-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then										-- year-initial numerical year month day format
		year, month, day=string.match(date_string, &quot;(%d%d%d%d)%-(%d%d)%-(%d%d)&quot;);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or 0 == tonumber(day) then return false; end	-- month or day number not valid or not Gregorian calendar
		anchor_year = year;
	elseif date_string:match(&quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then						-- month-initial: month day, year
		month, day, anchor_year, year=string.match(date_string, &quot;(%a+)%s*(%d%d?),%s*((%d%d%d%d?)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
				
	elseif mw.ustring.match(date_string, &quot;^%a+ +[1-9]%d?[%-–][1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year=mw.ustring.match(date_string, &quot;(%a+) +(%d%d?)[%-–](%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
		month2=month;																		-- for metadata
		year2=year;

	elseif date_string:match(&quot;^[1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then						-- day-initial: day month year
		day, month, anchor_year, year=string.match(date_string, &quot;(%d%d*)%s*(%a+)%s*((%d%d%d%d?)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d?[%-–][1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year=mw.ustring.match(date_string, &quot;(%d%d?)[%-–](%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
		month2=month;																		-- for metadata
		year2=year;

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d? +%a+ [%-–] [1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year=mw.ustring.match(date_string, &quot;(%d%d?) +(%a+) [%-–] (%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);													-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif mw.ustring.match(date_string, &quot;^%a+ +[1-9]%d? [%-–] %a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then		-- month initial month-day-range: month day – month day, year;  uses spaced endash
		month, day, month2, day2, anchor_year, year=mw.ustring.match(date_string, &quot;(%a+) +(%d%d?) [%-–] (%a+) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);													-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d? +%a+ +[1-9]%d%d%d [%-–] [1-9]%d? +%a+ +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2=mw.ustring.match(date_string, &quot;(%d%d?) +(%a+) +(%d%d%d%d) [%-–] (%d%d?) +(%a+) +((%d%d%d%d)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end												-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);																		-- for metadata
		month2 = get_month_number (month2);

	elseif mw.ustring.match(date_string, &quot;^%a+ +[1-9]%d?, +[1-9]%d%d%d [%-–] %a+ +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then		-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
		month, day, year, month2, day2, anchor_year, year2=mw.ustring.match(date_string, &quot;(%a+) +(%d%d?), +(%d%d%d%d) [%-–] (%a+) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end												-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);																		-- for metadata
		month2 = get_month_number (month2);

	elseif mw.ustring.match(date_string, &quot;^%a+ +[1-9]%d%d%d[%-–]%d%d%a?$&quot;) then								-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		local century;
		month, year, century, anchor_year, year2=mw.ustring.match(date_string, &quot;(%a+) +((%d%d)%d%d)[%-–]((%d%d)%a?)&quot;);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;					-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		year2 = century..year2;																-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		month = get_season_number (month);

	elseif mw.ustring.match(date_string, &quot;^%a+ +[1-9]%d%d%d[%-–][1-9]%d%d%d%a?$&quot;) then						-- special case Winter/Summer year-year; year separated with unspaced endash
		month, year, anchor_year, year2=mw.ustring.match(date_string, &quot;(%a+) +(%d%d%d%d)[%-–]((%d%d%d%d)%a?)&quot;);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;					-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		month = get_season_number (month);													-- for metadata

	elseif mw.ustring.match(date_string, &quot;^%a+ +[1-9]%d%d%d +[%-–] +%a+ +[1-9]%d%d%d%a?$&quot;) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2=mw.ustring.match(date_string, &quot;(%a+) +(%d%d%d%d) +[%-–] +(%a+) +((%d%d%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end							-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then 	-- both must be month year, same month style
			month = get_month_number(month);
			month2 = get_month_number(month2);
		elseif 0 ~= get_season_number(month) and 0 ~= get_season_number(month2) then		-- both must be or season year, not mixed
			month = get_season_number(month);
			month2 = get_season_number(month2);
		else
			 return false;
		end

	elseif mw.ustring.match(date_string, &quot;^%a+[%-–]%a+ +[1-9]%d%d%d%a?$&quot;) then					-- month/season range year; months separated by endash 
		month, month2, anchor_year, year=mw.ustring.match(date_string, &quot;(%a+)[%-–](%a+)%s*((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or (not is_valid_year(year)) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
			month2 = get_month_number(month2);
		else
			month = get_season_number(month);
			month2 = get_season_number(month2);
		end
		year2=year;
		
	elseif date_string:match(&quot;^%a+ +%d%d%d%d%a?$&quot;) then							-- month/season year or proper-name year
		month, anchor_year, year=date_string:match(&quot;(%a+)%s*((%d%d%d%d)%a?)&quot;);
		if not is_valid_year(year) then return false; end
		if not is_valid_month_or_season (month) and 0 == is_proper_name (month) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
		elseif 0 ~= get_season_number(month) then
			month = get_season_number(month);
		else
			month = is_proper_name (month);										-- must be proper name; not supported in COinS
		end

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d%d%d?[%-–][1-9]%d%d%d?%a?$&quot;) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2=mw.ustring.match(date_string, &quot;(%d%d%d%d?)[%-–]((%d%d%d%d?)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d%d%d[%-–]%d%d%a?$&quot;) then						-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2=mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]((%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century..year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then							-- year; here accept either YYY or YYYY
		anchor_year, year=date_string:match(&quot;((%d%d%d%d?)%a?)&quot;);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;															-- date format not one of the MOS:DATE approved formats
	end

	if test_accessdate then														-- test accessdate here because we have numerical date parts
		if 0 ~= year and 0 ~= month and 0 ~= day and 							-- all parts of a single date required
			0 == year2 and 0 == month2 and 0 == day2 then						-- none of these; accessdate must not be a range
				if not is_valid_accessdate (year..'-'..month..'-'..day) then	
					return false;												-- return false when accessdate out of bounds
				end
		else
			return false;														-- return false when accessdate is a range of two dates
		end
	end

	local result=true;															-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result=is_valid_date(year,month,day);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month2,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year2,month2,day2);
	end
	
	if false == result then return false; end

	if nil ~= tCOinS_date then													-- this table only passed into this function when testing |date= parameter values
		make_COinS_date ({year=year, month=month, day=day, year2=year2, month2=month2, day2=day2}, tCOinS_date);	-- make an ISO 8601 date string for COinS
	end
	
	return true, anchor_year;													-- format is good and date string represents a real date
end	


--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.

]]

local function dates(date_parameters_list, tCOinS_date)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local embargo_date;															-- if embargo date is a good dmy, mdy, ymd date then holds original value else reset to 9999
	local error_message = &quot;&quot;;
	local good_date = false;
	
	for k, v in pairs(date_parameters_list) do									-- for each date-holding parameter in the list
		if is_set(v) then														-- if the parameter has a value
			if v:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then							-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);					-- get the year portion so it can be tested
				if 'date'==k then
					anchor_year, COinS_date = v:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year'==k then
					good_date = is_valid_year(year);
				end
			elseif 'date'==k then												-- if the parameter is |date=
				if v:match(&quot;^n%.d%.%a?$&quot;) then									-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v:match(&quot;^nd%a?$&quot;) then									-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v, tCOinS_date);	-- go test the date
				end
			elseif 'year'==k then												-- if the parameter is |year= it should hold only a year value
				if v:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then							-- if |year= 3 or 4 digits only with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((%d+)%a?)&quot;);
				end
			elseif 'access-date'==k then										-- if the parameter is |date=
				good_date = check_date (v, nil, true);							-- go test the date; nil is a placeholder; true is the test_accessdate flag
			elseif 'embargo'==k then											-- if the parameter is |embargo=
				good_date = check_date (v);										-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date, embargo_date = is_valid_embargo_date (v);		-- is |embargo= date a single dmy, mdy, or ymd formatted date? yes:returns embargo; no: returns 9999
				end
			else																-- any other date-holding parameter
				good_date = check_date (v);										-- go test the date
			end
			if false==good_date then											-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then									-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;						-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;			-- add the failed parameter
			end
		end
	end
	return anchor_year, embargo_date, error_message;											-- and done
end


--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function returns a numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

]]

local function year_date_check (year_string, date_string)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes
	
	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where both date and year are required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard range formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif mw.ustring.match(date_string, &quot;%d%d%d%d[%-–]%d%d&quot;) then								-- YYYY-YY date ranges
		local century;
		date1, century, date2 = mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	else
		result = 0;																-- no recognizable year in date
	end
	return result;
end


--[[-------------------------&lt; R E F O R M A T   T A B L E S &gt;------------------------------------------------

These table are used exclusively for reformatting dates

]]

local source_patterns = {						-- this table holds patterns that match allowed date formats used to extract date components
	['dmy'] = '^(%d%d?)%s+(%a+)%s+(%d%d%d%d)$',
	['mdy'] = '^(%a+)%s+(%d%d?),%s+(%d%d%d%d)$',
	['ymd'] = '^(%d%d%d%d)%-(%d%d)-(%d%d)$',
	}

local short_formats = {							-- this table holds format strings used by os.date() for short month names
	['dmy'] = '%e %b %Y',
	['mdy'] = '%b %e, %Y',
	['ymd'] = '%F',
	}

local long_formats = {							-- this table holds format strings used by os.date() for long month names
	['dmy'] = '%e %B %Y',
	['mdy'] = '%B %e, %Y',
	['ymd'] = '%F',
	}


--[[-------------------------&lt; G E T _ D M Y _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from DMY formatted date, places them in the source_date table, and returns.

]]

local function get_dmy_date_parts (date, source_date)
	source_date.day, source_date.month, source_date.year = date:match (source_patterns['dmy']);	-- get date components as strings
	source_date.month = get_month_number (source_date.month);					-- get month number
end


--[[-------------------------&lt; G E T _ M D Y _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from MDY formatted date, places them in the source_date table, and returns.

]]

local function get_mdy_date_parts (date, source_date)
	source_date.month, source_date.day, source_date.year = date:match (source_patterns['mdy']);	-- get date components as strings
	source_date.month = get_month_number (source_date.month);					-- get month number
end


--[[-------------------------&lt; G E T _ Y M D _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from YMD formatted date, places them in the source_date table, and returns.

]]

local function get_ymd_date_parts (date, source_date)
	source_date.year, source_date.month, source_date.day = date:match (source_patterns['ymd']);	-- get date components as strings
end


--[[-------------------------&lt; R E F O R M A T _ D A T E S &gt;--------------------------------------------------

Reformats existing dates into the format specified by format and short.

format is one of several keywords: dmy, dmy-all, mdy, mdy-all, ymd, ymd-all.  The all version includes access- and
archive-dates; otherwise these dates are not reformatted

Date ranges, season dates, proper name dates are not currently supported.

For i18n:  This code works only at en.wiki because os.date() doesn't support any languages other than English.
mw.getContentLanguage():formatDate() will work at non-English wikis only when the date format is yyyy-mm-dd. This is
the same issue that plagues is_valid_accessdate()

It is possible that a solution like that written for ht:Module:Citation/CS1/Date_validation date_name_xlate() could be applied to this problem

]]

local function reformat_dates (date_parameters_list, format, short)
	local all = false;															-- set to false to skip access- and archive-dates
	local format_str;
	local source_date = {};
	
	if format:match('%a+%-all') then
		format = format:match('(%a+)%-all');									-- extract the format
		all = true;																-- set to true to format access- and archive-dates
	end
	
	for param_name, param_val in pairs (date_parameters_list) do				-- for each date-holding parameter in the list
		if is_set (param_val) then												-- if the parameter has a value
			if not all and in_array (param_name, {'access-date', 'archive-date'}) then	-- if access- or archive-date and format not xxx-all
				param_val = '';													-- set to empty string so we don't process this date
			end
			for source, pattern in pairs (source_patterns) do
				if param_val:match (pattern) then
					if 'ymd' == source then
						get_ymd_date_parts (param_val, source_date);			-- get the date parts into the source_date table
					elseif 'dmy' == source then
						get_dmy_date_parts (param_val, source_date);			-- get the date parts into the source_date table
					elseif 'mdy' == source then
						get_mdy_date_parts (param_val, source_date);			-- get the date parts into the source_date table
					end

					if 'ymd' == format and 1582 &gt; tonumber(source_date.year) then	-- ymd format dates not allowed before 1582
						return false;											-- abandon reformatting
					end
					
					if short then
						format_str = short_formats[format];
					else
						format_str = long_formats[format];
					end
																				-- convert date and save;
					date_parameters_list[param_name] = mw.text.trim (os.date (format_str, os.time(source_date)));	-- strip leading space when single digit day and %e is first format
				end
			end
		end
	end
	return true;																-- declare success and done
end


--[[--------------------------&lt; D A T E _ H Y P H E N _ T O _ D A S H &gt;----------------------------------------

Loops through the list of date-holding parameters and converts any hyphen to an ndash.  Not called if the cs1|2
template has any date errors.

Modifies the date_parameters_list and returns true if hyphens are replaced, else returns false.

]]

local function date_hyphen_to_dash (date_parameters_list)
	local result = false;
	local n;
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if not param_val:match ('%d%d%d%d%-%d%d%-%d%d') then					-- for those that are not ymd dates
			param_val, n = param_val:gsub ('%-', '–');							-- replace any hyphen with ndash
			if 0 ~= n then
				date_parameters_list[param_name] = param_val;					-- update the list
				result = true;
			end
		end
	end
	return result;																-- so we know if any hyphens were replaced
end


--[[-------------------------&lt; D A T E _ N A M E _ X L A T E &gt;------------------------------------------------

Attempts to translate English month names to local-language month names using names supplied by MediaWiki's
date parser function.  This is simple name-for-name replacement and may not work for all languages.

]]

local function	date_name_xlate (date_parameters_list)
	local xlate;
	local mode;																	-- long or short month names
	local modified = false;
	local date;
	
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val) then												-- if the parameter has a value
			date = param_val;
			for month in mw.ustring.gmatch (date, '%a+') do						-- iterate through all dates in the date (single date or date range)
				if cfg.date_names.en.long[month] then
					mode = 'F';													-- English name is long so use long local name
				elseif cfg.date_names.en.short[month] then
					mode = 'M';													-- English name is short so use short local name
				else
					mode = nil;													-- not an English month name; could be local language month name or an English season name
				end
		
				if mode then															-- might be a season
					xlate = mw.getContentLanguage():formatDate(mode, '1' .. month);		-- translate the month name to this local language
					date = mw.ustring.gsub (date, month, xlate);						-- replace the English with the translation
					date_parameters_list[param_name] = date;							-- save the translated date
					modified = true;
				end
			end

		end
	end
	
	return modified;
	end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	is_set = utilities_page_ptr.is_set;											-- import functions from selected Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;										-- import functions from selected Module:Citation/CS1/Utilities module
	cfg = cfg_table_ptr;														-- import tables from selected Module:Citation/CS1/Configuration
end



return {																		-- return exported functions
	dates = dates,
	year_date_check = year_date_check,
	reformat_dates = reformat_dates,
	date_hyphen_to_dash = date_hyphen_to_dash,
	date_name_xlate = date_name_xlate,
	set_selected_modules = set_selected_modules
	}</text>
      <sha1>9dvtrzfmtn2hxrrl1lguon5gdjwybb0</sha1>
    </revision>
    <revision>
      <id>4836</id>
      <parentid>4835</parentid>
      <timestamp>2018-02-17T14:52:15Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4836</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="44395" sha1="4mkyfuts1otu8fxhn4fytsmvluoycin" xml:space="preserve">
local p = {}


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array;															-- imported functions from selected Module:Citation/CS1/Utilities
local cfg;																		-- table of tables imported from slected Module:Citation/CS1/Configuration

--[=[-------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |accessdate= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-Engish date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate().  To get around that
call this function with YYYY-MM-DD format dates.

]=]

local function is_valid_accessdate (accessdate)
	local lang = mw.getContentLanguage();
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold unix time stamps representing the dates
		
	good1, access_ts = pcall( lang.formatDate, lang, 'U', accessdate );			-- convert accessdate value to unix timesatmp 
	good2, tomorrow_ts = pcall( lang.formatDate, lang, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which which tonumber() may not understand
		access_ts = tonumber (access_ts) or lang:parseFormattedNumber (access_ts);			-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to unix time stamp
	end

	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end


--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct. If not a valid month, returns 0

]]

local function get_month_number (month)
	return cfg.date_names['local'].long[month] or cfg.date_names['local'].short[month] or		-- look for local names first
			cfg.date_names['en'].long[month] or	cfg.date_names['en'].short[month] or			-- failing that, look for English names
			0;																					-- not a recognized month name
end


--[[--------------------------&lt; I S _ V A L I D _ E M B A R G O _ D A T E &gt;------------------------------------

returns true and date value if that value has proper dmy, mdy, ymd format.

returns false and 9999 (embargoed forever) when date value is not proper format; assumes that when |embargo= is
set, the editor intended to embargo a pmc but |embargo= does not hold a single date.

]]

local function is_valid_embargo_date (v)
	if v:match ('^%d%d%d%d%-%d%d%-%d%d$') or									-- ymd
		v:match ('^%d%d?%s+%a+%s+%d%d%d%d$') or									-- dmy
		v:match ('^%a+%s+%d%d?%s*,%s*%d%d%d%d$') then							-- mdy
			return true, v;
	end
	return false, '9999';														-- if here not good date so return false and set embargo date to long time in future
end


--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 1 for Winter, etc.  Capitalization and spelling must be correct. If not a valid season, returns 0

Uses ISO DIS 8601 2016 part 2 §4.7  Divisions of a year for hemishpere-independent seasons:
	21-24 = Spring, Summer, Autumn, Winter, independent of “Hemisphere”

These additional divisions not currently supported:
	25-28 = Spring - Northern Hemisphere, Summer- Northern Hemisphere, Autumn - Northern Hemisphere, Winter - Northern Hemisphere
	29-32 = Spring – Southern Hemisphere, Summer– Southern Hemisphere, Autumn – Southern Hemisphere, Winter - Southern Hemisphere
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)


]]

local function get_season_number (season)
	return cfg.date_names['local'].season[season] or							-- look for local names first
			cfg.date_names['en'].season[season] or								-- failing that, look for English names
			0;																	-- not a recognized season name
end

--[[--------------------------&lt; I S _ P R O P E R _ N A M E &gt;--------------------------------------------------

returns a non-zero number if date contains a recognized proper name.  Capitalization and spelling must be correct.

]]

local function is_proper_name (name)
	return cfg.date_names['local'].named[name] or								-- look for local names dates first
			cfg.date_names['en'].named[name] or									-- failing that, look for English names
			0;																	-- not a recognized named date
end

--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ O R _ S E A S O N &gt;------------------------------

--returns true if month or season is valid (properly spelled, capitalized, abbreviated)

]]

local function is_valid_month_or_season (month_season)
	if 0 == get_month_number (month_season) then		-- if month text isn't one of the twelve months, might be a season
		if 0 == get_season_number (month_season) then	-- not a month, is it a season?
			return false;								-- return false not a month or one of the five seasons
		end
	end
	return true;
end

--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one year in the future are not acceptable.

]]
local year_limit;
local function is_valid_year(year)
	if not is_set(year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;			-- global variable so we only have to fetch it once
	end
	return tonumber(year) &lt;= year_limit;				-- false if year is in the future more than one year
end

--[[--------------------------&lt; I S _ V A L I D _ D A T E &gt;----------------------------------------------------
Returns true if day is less than or equal to the number of days in month and year is no farther into the future
than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap
years before 1582 and Gregorian leap years after 1582. Where the two calendars overlap (1582 to approximately
1923) dates are assumed to be Gregorian.

]]

local function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year(year) then												-- no farther into the future than next year
		return false;
	end
	
	month = tonumber(month);													-- required for YYYY-MM-DD dates
	
	if (2==month) then															-- if February
		month_length = 28;														-- then 28 days unless
		if 1582 &gt; tonumber(year) then											-- Julian calendar
			if 0==(year%4) then
				month_length = 29;
			end
		else																	-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then			-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end

--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
There is a special test for May because it can be either short or long form.

Returns true when style for both months is the same

]]

local function is_valid_month_range_style (month1, month2)
local len1 = month1:len();
local len2 = month2:len();
	if len1 == len2 then
		return true;															-- both months are short form so return true
	elseif 'May' == month1 or 'May'== month2 then
		return true;															-- both months are long form so return true
	elseif 3 == len1 or 3 == len2 then
		return false;															-- months are mixed form so return false
	else
		return true;															-- both months are long form so return true
	end
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

All season ranges are accepted as valid because there are publishers out there who have published a Summer–Spring YYYY issue so ... ok

]]

local function is_valid_month_season_range(range_start, range_end)
	local range_start_number = get_month_number (range_start);
	local range_end_number;
	
	if 0 == range_start_number then												-- is this a month range?
		range_start_number = get_season_number (range_start);					-- not a month; is it a season? get start season number
		range_end_number = get_season_number (range_end);						-- get end season number

		if (0 ~= range_start_number) and (0 ~= range_end_number) then
			return true;														-- any season pairing is accepted
		end
		return false;															-- range_start and/or range_end is not a season
	end
																				-- here when range_start is a month
	range_end_number = get_month_number (range_end);							-- get end month number
	if range_start_number &lt; range_end_number then								-- range_start is a month; does range_start precede range_end?
		if is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
		end
	end
	return false;																-- range_start month number is greater than or equal to range end number; or range end isn't a month
end


--[[--------------------------&lt; M A K E _ C O I N S _ D A T E &gt;------------------------------------------------

This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1.  The function is called only for |date= parameters and only if the |date=&lt;value&gt; is 
determined to be a valid date format.  The question of what to do with invalid date formats is not answered here.

The date parts in the input table are converted to an ISO 8601 conforming date string:
	single whole dates:		yyyy-mm-dd
	month and year dates:	yyyy-mm
	year dates:				yyyy
	ranges:					yyyy-mm-dd/yyyy-mm-dd
							yyyy-mm/yyyy-mm
							yyyy/yyyy

Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.

The input table has:
	year, year2 – always present; if before 1582, ignore months and days if present
	month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 99 Christmas
	day, day2 –  0 if not provided, 1-31 for days
	
the output table receives:
	rftdate:	an IS8601 formatted date
	rftchron:	a free-form version of the date, usually without year which is in rftdate (season ranges and propername dates)
	rftssn:		one of four season keywords: winter, spring, summer, fall (lowercase)

]]

local function make_COinS_date (input, tCOinS_date)
	local date;																	-- one date or first date in a range
	local date2 = '';															-- end of range date
-- start temporary Julian / Gregorian calendar uncertainty detection
	local year = tonumber(input.year);											-- this temporary code to determine the extent of sources dated to the Julian/Gregorian
	local month = tonumber(input.month);										-- interstice 1 October 1582 – 1 January 1926
	local day = tonumber (input.day);
	if (0 ~= day) and															-- day must have a value for this to be a whole date
		(((1582 == year) and (10 &lt;= month) and (12 &gt;= month)) or				-- any whole 1582 date from 1 october to 31 December or
			((1926 == year) and (1 == month) and (1 == input.day)) or			-- 1 January 1926 or
				((1582 &lt; year) and (1925 &gt;= year))) then						-- any date 1 January 1583 – 31 December 1925
					tCOinS_date.inter_cal_cat = true;							-- set category flag true
	end
-- end temporary Julian / Gergorian calendar uncertainty detection
	
	if 1582 &gt; tonumber(input.year) or 20 &lt; tonumber(input.month) then			-- Julian calendar or season so &amp;rft.date gets year only
		date = input.year;
		if 0 ~= input.year2 and input.year ~= input.year2 then					-- if a range, only the second year portion when not the same as range start year
			date = string.format ('%.4d/%.4d', tonumber(input.year), tonumber(input.year2))		-- assemble the date range
		end
		if 20 &lt; tonumber(input.month) then										-- if season or propername date
			local season = {[24]='winter', [21]='spring', [22]='summer', [23]='fall', [99]='Christmas'};	-- seasons lowercase, no autumn; proper names use title case
			if 0 == input.month2 then											-- single season date
				if 30 &lt;tonumber(input.month) then
					tCOinS_date.rftchron = season[input.month];					-- proper name dates
				else
					tCOinS_date.rftssn = season[input.month];					-- seasons
				end
			else																-- season range with a second season specified
				if input.year ~= input.year2 then								-- season year – season year range or season year–year
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					if 0~= input.month2 then
						tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);
					end
				else															-- season–season year range
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2];	-- season–season year range
				end
			end
		end
		tCOinS_date.rftdate = date;
		return;																	-- done
	end
	
	if 0 ~= input.day then
		date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day));	-- whole date
	elseif 0 ~= input.month then
		date = string.format ('%s-%.2d', input.year, tonumber(input.month));	-- year and month
	else
		date = string.format ('%s', input.year);								-- just year
	end

	if 0 ~= input.year2 then
		if 0 ~= input.day2 then
			date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2));		-- whole date
		elseif 0 ~= input.month2 then
			date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2));	-- year and month
		else
			date2 = string.format ('/%s', input.year2);							-- just year
		end
	end
	
	tCOinS_date.rftdate = date .. date2;										-- date2 has the '/' separator
	return;
end


--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only
allowed range separator is endash.  Additionally, check the date to see that it is a real date: no 31 in 30-day
months; no 29 February when not a leap year.  Months, both long-form and three character abbreviations, and seasons
must be spelled correctly.  Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and
COinS_date.  When this happens, the date parameter is used in the COinS metadata and the CITEREF identifier gets
its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc.)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is ISO 8601 format date; see make_COInS_date()

]]

local function check_date (date_string, tCOinS_date, test_accessdate)
	local year;			-- assume that year2, months, and days are not used;
	local year2=0;		-- second year in a year range
	local month=0;
	local month2=0;		-- second month in a month range
	local day=0;
	local day2=0;		-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then										-- year-initial numerical year month day format
		year, month, day=string.match(date_string, &quot;(%d%d%d%d)%-(%d%d)%-(%d%d)&quot;);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or 0 == tonumber(day) then return false; end	-- month or day number not valid or not Gregorian calendar
		anchor_year = year;
	elseif mw.ustring.match(date_string, &quot;^%D- +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then						-- month-initial: month day, year
		month, day, anchor_year, year=mw.ustring.match(date_string, &quot;(%D-) +(%d%d?),%s*((%d%d%d%d?)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
				
	elseif mw.ustring.match(date_string, &quot;^%D- +[1-9]%d?[%-–][1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year=mw.ustring.match(date_string, &quot;(%D-) +(%d%d?)[%-–](%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
		month2=month;																		-- for metadata
		year2=year;

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d? +%D- +[1-9]%d%d%d%a?$&quot;) then						-- day-initial: day month year
		day, month, anchor_year, year=mw.ustring.match(date_string, &quot;(%d%d*)%s*(%D-) +((%d%d%d%d?)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d?[%-–][1-9]%d? +%D- +[1-9]%d%d%d%a?$&quot;) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year=mw.ustring.match(date_string, &quot;(%d%d?)[%-–](%d%d?) +(%D-) +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
		month2=month;																		-- for metadata
		year2=year;

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d? +%D- +[%-–] +[1-9]%d? +%D- +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year=mw.ustring.match(date_string, &quot;(%d%d?) +(%D-) +[%-–] +(%d%d?) +(%D-) +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);													-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif mw.ustring.match(date_string, &quot;^%D- +[1-9]%d? +[%-–] +%D- +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then		-- month initial month-day-range: month day – month day, year;  uses spaced endash
		month, day, month2, day2, anchor_year, year=mw.ustring.match(date_string, &quot;(%D-) +(%d%d?) +[%-–] +(%D-) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);													-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d? +%D- +[1-9]%d%d%d +[%-–] +[1-9]%d? +%D- +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2=mw.ustring.match(date_string, &quot;(%d%d?) +(%D-) +(%d%d%d%d) +[%-–] +(%d%d?) +(%D-) +((%d%d%d%d)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end												-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);																		-- for metadata
		month2 = get_month_number (month2);

	elseif mw.ustring.match(date_string, &quot;^%D- +[1-9]%d?, +[1-9]%d%d%d +[%-–] +%D- +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then		-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
		month, day, year, month2, day2, anchor_year, year2=mw.ustring.match(date_string, &quot;(%D-) +(%d%d?), +(%d%d%d%d) +[%-–] +(%D-) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end												-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);																		-- for metadata
		month2 = get_month_number (month2);

	elseif mw.ustring.match(date_string, &quot;^%D- +[1-9]%d%d%d[%-–]%d%d%a?$&quot;) then								-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		local century;
		month, year, century, anchor_year, year2=mw.ustring.match(date_string, &quot;(%D-) +((%d%d)%d%d)[%-–]((%d%d)%a?)&quot;);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;					-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		year2 = century..year2;																-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		month = get_season_number (month);

	elseif mw.ustring.match(date_string, &quot;^%D- +[1-9]%d%d%d[%-–][1-9]%d%d%d%a?$&quot;) then						-- special case Winter/Summer year-year; year separated with unspaced endash
		month, year, anchor_year, year2=mw.ustring.match(date_string, &quot;(%D-) +(%d%d%d%d)[%-–]((%d%d%d%d)%a?)&quot;);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;					-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		month = get_season_number (month);													-- for metadata

	elseif mw.ustring.match(date_string, &quot;^%D- +[1-9]%d%d%d +[%-–] +%D- +[1-9]%d%d%d%a?$&quot;) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2=mw.ustring.match(date_string, &quot;(%D-) +(%d%d%d%d) +[%-–] +(%D-) +((%d%d%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end							-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then 	-- both must be month year, same month style
			month = get_month_number(month);
			month2 = get_month_number(month2);
		elseif 0 ~= get_season_number(month) and 0 ~= get_season_number(month2) then		-- both must be or season year, not mixed
			month = get_season_number(month);
			month2 = get_season_number(month2);
		else
			 return false;
		end

	elseif mw.ustring.match(date_string, &quot;^%D-[%-–]%D- +[1-9]%d%d%d%a?$&quot;) then					-- month/season range year; months separated by endash 
		month, month2, anchor_year, year=mw.ustring.match(date_string, &quot;(%D-)[%-–](%D-)%s*((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or (not is_valid_year(year)) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
			month2 = get_month_number(month2);
		else
			month = get_season_number(month);
			month2 = get_season_number(month2);
		end
		year2=year;
		
	elseif mw.ustring.match(date_string, &quot;^%D- +%d%d%d%d%a?$&quot;) then							-- month/season year or proper-name year
		month, anchor_year, year=mw.ustring.match(date_string, &quot;(%D-)%s*((%d%d%d%d)%a?)&quot;);
		if not is_valid_year(year) then return false; end
		if not is_valid_month_or_season (month) and 0 == is_proper_name (month) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
		elseif 0 ~= get_season_number(month) then
			month = get_season_number(month);
		else
			month = is_proper_name (month);										-- must be proper name; not supported in COinS
		end

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d%d%d?[%-–][1-9]%d%d%d?%a?$&quot;) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2=mw.ustring.match(date_string, &quot;(%d%d%d%d?)[%-–]((%d%d%d%d?)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d%d%d[%-–]%d%d%a?$&quot;) then						-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2=mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]((%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century..year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then							-- year; here accept either YYY or YYYY
		anchor_year, year=date_string:match(&quot;((%d%d%d%d?)%a?)&quot;);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;															-- date format not one of the MOS:DATE approved formats
	end

	if test_accessdate then														-- test accessdate here because we have numerical date parts
		if 0 ~= year and 0 ~= month and 0 ~= day and 							-- all parts of a single date required
			0 == year2 and 0 == month2 and 0 == day2 then						-- none of these; accessdate must not be a range
				if not is_valid_accessdate (year..'-'..month..'-'..day) then	
					return false;												-- return false when accessdate out of bounds
				end
		else
			return false;														-- return false when accessdate is a range of two dates
		end
	end

	local result=true;															-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result=is_valid_date(year,month,day);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month2,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year2,month2,day2);
	end
	
	if false == result then return false; end

	if nil ~= tCOinS_date then													-- this table only passed into this function when testing |date= parameter values
		make_COinS_date ({year=year, month=month, day=day, year2=year2, month2=month2, day2=day2}, tCOinS_date);	-- make an ISO 8601 date string for COinS
	end
	
	return true, anchor_year;													-- format is good and date string represents a real date
end	


--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.

]]

local function dates(date_parameters_list, tCOinS_date)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local embargo_date;															-- if embargo date is a good dmy, mdy, ymd date then holds original value else reset to 9999
	local error_message = &quot;&quot;;
	local good_date = false;
	
	for k, v in pairs(date_parameters_list) do									-- for each date-holding parameter in the list
		if is_set(v) then														-- if the parameter has a value
			if v:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then							-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				v = mw.ustring.gsub (v, '%d', cfg.date_names.local_digits);
				local year = v:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);					-- get the year portion so it can be tested
				if 'date'==k then
					anchor_year, COinS_date = v:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year'==k then
					good_date = is_valid_year(year);
				end
			elseif 'date'==k then												-- if the parameter is |date=
				if v:match(&quot;^n%.d%.%a?$&quot;) then									-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v:match(&quot;^nd%a?$&quot;) then									-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v, tCOinS_date);	-- go test the date
				end
			elseif 'year'==k then												-- if the parameter is |year= it should hold only a year value
				if v:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then							-- if |year= 3 or 4 digits only with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v:match(&quot;((%d+)%a?)&quot;);
				end
			elseif 'access-date'==k then										-- if the parameter is |date=
				good_date = check_date (v, nil, true);							-- go test the date; nil is a placeholder; true is the test_accessdate flag
			elseif 'embargo'==k then											-- if the parameter is |embargo=
				good_date = check_date (v);										-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date, embargo_date = is_valid_embargo_date (v);		-- is |embargo= date a single dmy, mdy, or ymd formatted date? yes:returns embargo; no: returns 9999
				end
			else																-- any other date-holding parameter
				good_date = check_date (v);										-- go test the date
			end
			if false==good_date then											-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then									-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;						-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. k .. &quot;=&quot;;			-- add the failed parameter
			end
		end
	end
	return anchor_year, embargo_date, error_message;											-- and done
end


--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function returns a numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

]]

local function year_date_check (year_string, date_string)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes
	
	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where both date and year are required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard range formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif mw.ustring.match(date_string, &quot;%d%d%d%d[%-–]%d%d&quot;) then								-- YYYY-YY date ranges
		local century;
		date1, century, date2 = mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	else
		result = 0;																-- no recognizable year in date
	end
	return result;
end


--[[-------------------------&lt; R E F O R M A T   T A B L E S &gt;------------------------------------------------

These table are used exclusively for reformatting dates

]]

local source_patterns = {						-- this table holds patterns that match allowed date formats used to extract date components
	['dmy'] = '^(%d%d?)%s+(%a+)%s+(%d%d%d%d)$',
	['mdy'] = '^(%a+)%s+(%d%d?),%s+(%d%d%d%d)$',
	['ymd'] = '^(%d%d%d%d)%-(%d%d)-(%d%d)$',
	}

local short_formats = {							-- this table holds format strings used by os.date() for short month names
	['dmy'] = '%e %b %Y',
	['mdy'] = '%b %e, %Y',
	['ymd'] = '%F',
	}

local long_formats = {							-- this table holds format strings used by os.date() for long month names
	['dmy'] = '%e %B %Y',
	['mdy'] = '%B %e, %Y',
	['ymd'] = '%F',
	}


--[[-------------------------&lt; G E T _ D M Y _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from DMY formatted date, places them in the source_date table, and returns.

]]

local function get_dmy_date_parts (date, source_date)
	source_date.day, source_date.month, source_date.year = date:match (source_patterns['dmy']);	-- get date components as strings
	source_date.month = get_month_number (source_date.month);					-- get month number
end


--[[-------------------------&lt; G E T _ M D Y _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from MDY formatted date, places them in the source_date table, and returns.

]]

local function get_mdy_date_parts (date, source_date)
	source_date.month, source_date.day, source_date.year = date:match (source_patterns['mdy']);	-- get date components as strings
	source_date.month = get_month_number (source_date.month);					-- get month number
end


--[[-------------------------&lt; G E T _ Y M D _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from YMD formatted date, places them in the source_date table, and returns.

]]

local function get_ymd_date_parts (date, source_date)
	source_date.year, source_date.month, source_date.day = date:match (source_patterns['ymd']);	-- get date components as strings
end


--[[-------------------------&lt; R E F O R M A T _ D A T E S &gt;--------------------------------------------------

Reformats existing dates into the format specified by format and short.

format is one of several keywords: dmy, dmy-all, mdy, mdy-all, ymd, ymd-all.  The all version includes access- and
archive-dates; otherwise these dates are not reformatted

Date ranges, season dates, proper name dates are not currently supported.

For i18n:  This code works only at en.wiki because os.date() doesn't support any languages other than English.
mw.getContentLanguage():formatDate() will work at non-English wikis only when the date format is yyyy-mm-dd. This is
the same issue that plagues is_valid_accessdate()

It is possible that a solution like that written for ht:Module:Citation/CS1/Date_validation date_name_xlate() could be applied to this problem

]]

local function reformat_dates (date_parameters_list, format, short)
	local all = false;															-- set to false to skip access- and archive-dates
	local format_str;
	local source_date = {};
	
	if format:match('%a+%-all') then
		format = format:match('(%a+)%-all');									-- extract the format
		all = true;																-- set to true to format access- and archive-dates
	end
	
	for param_name, param_val in pairs (date_parameters_list) do				-- for each date-holding parameter in the list
		if is_set (param_val) then												-- if the parameter has a value
			if not all and in_array (param_name, {'access-date', 'archive-date'}) then	-- if access- or archive-date and format not xxx-all
				param_val = '';													-- set to empty string so we don't process this date
			end
			for source, pattern in pairs (source_patterns) do
				if param_val:match (pattern) then
					if 'ymd' == source then
						get_ymd_date_parts (param_val, source_date);			-- get the date parts into the source_date table
					elseif 'dmy' == source then
						get_dmy_date_parts (param_val, source_date);			-- get the date parts into the source_date table
					elseif 'mdy' == source then
						get_mdy_date_parts (param_val, source_date);			-- get the date parts into the source_date table
					end

					if 'ymd' == format and 1582 &gt; tonumber(source_date.year) then	-- ymd format dates not allowed before 1582
						return false;											-- abandon reformatting
					end
					
					if short then
						format_str = short_formats[format];
					else
						format_str = long_formats[format];
					end
																				-- convert date and save;
					date_parameters_list[param_name] = mw.text.trim (os.date (format_str, os.time(source_date)));	-- strip leading space when single digit day and %e is first format
				end
			end
		end
	end
	return true;																-- declare success and done
end


--[[--------------------------&lt; D A T E _ H Y P H E N _ T O _ D A S H &gt;----------------------------------------

Loops through the list of date-holding parameters and converts any hyphen to an ndash.  Not called if the cs1|2
template has any date errors.

Modifies the date_parameters_list and returns true if hyphens are replaced, else returns false.

]]

local function date_hyphen_to_dash (date_parameters_list)
	local result = false;
	local n;
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if not param_val:match ('%d%d%d%d%-%d%d%-%d%d') then					-- for those that are not ymd dates
			param_val, n = param_val:gsub ('%-', '–');							-- replace any hyphen with ndash
			if 0 ~= n then
				date_parameters_list[param_name] = param_val;					-- update the list
				result = true;
			end
		end
	end
	return result;																-- so we know if any hyphens were replaced
end


--[[-------------------------&lt; D A T E _ N A M E _ X L A T E &gt;------------------------------------------------

Attempts to translate English month names to local-language month names using names supplied by MediaWiki's
date parser function.  This is simple name-for-name replacement and may not work for all languages.

]]

local function	date_name_xlate (date_parameters_list)
	local xlate;
	local mode;																	-- long or short month names
	local modified = false;
	local date;
	
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val) then												-- if the parameter has a value
			date = param_val;
			for month in mw.ustring.gmatch (date, '%a+') do						-- iterate through all dates in the date (single date or date range)
				if cfg.date_names.en.long[month] then
					mode = 'F';													-- English name is long so use long local name
				elseif cfg.date_names.en.short[month] then
					mode = 'M';													-- English name is short so use short local name
				else
					mode = nil;													-- not an English month name; could be local language month name or an English season name
				end
		
				if mode then															-- might be a season
					xlate = mw.getContentLanguage():formatDate(mode, '1' .. month);		-- translate the month name to this local language
					date = mw.ustring.gsub (date, month, xlate);						-- replace the English with the translation
					date_parameters_list[param_name] = date;							-- save the translated date
					modified = true;
				end
			end

		end
	end
	
	return modified;
	end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	is_set = utilities_page_ptr.is_set;											-- import functions from selected Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;										-- import functions from selected Module:Citation/CS1/Utilities module
	cfg = cfg_table_ptr;														-- import tables from selected Module:Citation/CS1/Configuration
end



return {																		-- return exported functions
	dates = dates,
	year_date_check = year_date_check,
	reformat_dates = reformat_dates,
	date_hyphen_to_dash = date_hyphen_to_dash,
	date_name_xlate = date_name_xlate,
	set_selected_modules = set_selected_modules
	}</text>
      <sha1>4mkyfuts1otu8fxhn4fytsmvluoycin</sha1>
    </revision>
    <revision>
      <id>4837</id>
      <parentid>4836</parentid>
      <timestamp>2018-06-09T21:37:02Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>synch from sandbox;</comment>
      <origin>4837</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="45118" sha1="6su6x3x29l8xt8yuoigkd96847sv6gg" xml:space="preserve">
local p = {}


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array;															-- imported functions from selected Module:Citation/CS1/Utilities
local cfg;																		-- table of tables imported from slected Module:Citation/CS1/Configuration

--[=[-------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |accessdate= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-Engish date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate().  To get around that
call this function with YYYY-MM-DD format dates.

]=]

local function is_valid_accessdate (accessdate)
	local lang = mw.getContentLanguage();
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold unix time stamps representing the dates
		
	good1, access_ts = pcall( lang.formatDate, lang, 'U', accessdate );			-- convert accessdate value to unix timesatmp 
	good2, tomorrow_ts = pcall( lang.formatDate, lang, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which which tonumber() may not understand
		access_ts = tonumber (access_ts) or lang:parseFormattedNumber (access_ts);			-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to unix time stamp
	end

	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end


--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct. If not a valid month, returns 0

]]

local function get_month_number (month)
	return cfg.date_names['local'].long[month] or cfg.date_names['local'].short[month] or		-- look for local names first
			cfg.date_names['en'].long[month] or	cfg.date_names['en'].short[month] or			-- failing that, look for English names
			0;																					-- not a recognized month name
end


--[[--------------------------&lt; I S _ V A L I D _ E M B A R G O _ D A T E &gt;------------------------------------

returns true and date value if that value has proper dmy, mdy, ymd format.

returns false and 9999 (embargoed forever) when date value is not proper format; assumes that when |embargo= is
set, the editor intended to embargo a pmc but |embargo= does not hold a single date.

]]

local function is_valid_embargo_date (v)
	if v:match ('^%d%d%d%d%-%d%d%-%d%d$') or									-- ymd
		v:match ('^%d%d?%s+%a+%s+%d%d%d%d$') or									-- dmy
		v:match ('^%a+%s+%d%d?%s*,%s*%d%d%d%d$') then							-- mdy
			return true, v;
	end
	return false, '9999';														-- if here not good date so return false and set embargo date to long time in future
end


--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 1 for Winter, etc.  Capitalization and spelling must be correct. If not a valid season, returns 0

Uses ISO DIS 8601 2016 part 2 §4.7  Divisions of a year for hemishpere-independent seasons:
	21-24 = Spring, Summer, Autumn, Winter, independent of “Hemisphere”

These additional divisions not currently supported:
	25-28 = Spring - Northern Hemisphere, Summer- Northern Hemisphere, Autumn - Northern Hemisphere, Winter - Northern Hemisphere
	29-32 = Spring – Southern Hemisphere, Summer– Southern Hemisphere, Autumn – Southern Hemisphere, Winter - Southern Hemisphere
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)


]]

local function get_season_number (season)
	return cfg.date_names['local'].season[season] or							-- look for local names first
			cfg.date_names['en'].season[season] or								-- failing that, look for English names
			0;																	-- not a recognized season name
end

--[[--------------------------&lt; I S _ P R O P E R _ N A M E &gt;--------------------------------------------------

returns a non-zero number if date contains a recognized proper name.  Capitalization and spelling must be correct.

]]

local function is_proper_name (name)
	return cfg.date_names['local'].named[name] or								-- look for local names dates first
			cfg.date_names['en'].named[name] or									-- failing that, look for English names
			0;																	-- not a recognized named date
end

--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ O R _ S E A S O N &gt;------------------------------

--returns true if month or season is valid (properly spelled, capitalized, abbreviated)

]]

local function is_valid_month_or_season (month_season)
	if 0 == get_month_number (month_season) then		-- if month text isn't one of the twelve months, might be a season
		if 0 == get_season_number (month_season) then	-- not a month, is it a season?
			return false;								-- return false not a month or one of the five seasons
		end
	end
	return true;
end

--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one year in the future are not acceptable.

]]
local year_limit;
local function is_valid_year(year)
	if not is_set(year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;			-- global variable so we only have to fetch it once
	end
	return tonumber(year) &lt;= year_limit;				-- false if year is in the future more than one year
end

--[[--------------------------&lt; I S _ V A L I D _ D A T E &gt;----------------------------------------------------
Returns true if day is less than or equal to the number of days in month and year is no farther into the future
than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap
years before 1582 and Gregorian leap years after 1582. Where the two calendars overlap (1582 to approximately
1923) dates are assumed to be Gregorian.

]]

local function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year(year) then												-- no farther into the future than next year
		return false;
	end
	
	month = tonumber(month);													-- required for YYYY-MM-DD dates
	
	if (2==month) then															-- if February
		month_length = 28;														-- then 28 days unless
		if 1582 &gt; tonumber(year) then											-- Julian calendar
			if 0==(year%4) then
				month_length = 29;
			end
		else																	-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then			-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end

--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
There is a special test for May because it can be either short or long form.

Returns true when style for both months is the same

]]

local function is_valid_month_range_style (month1, month2)
local len1 = month1:len();
local len2 = month2:len();
	if len1 == len2 then
		return true;															-- both months are short form so return true
	elseif 'May' == month1 or 'May'== month2 then
		return true;															-- both months are long form so return true
	elseif 3 == len1 or 3 == len2 then
		return false;															-- months are mixed form so return false
	else
		return true;															-- both months are long form so return true
	end
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

All season ranges are accepted as valid because there are publishers out there who have published a Summer–Spring YYYY issue so ... ok

]]

local function is_valid_month_season_range(range_start, range_end)
	local range_start_number = get_month_number (range_start);
	local range_end_number;
	
	if 0 == range_start_number then												-- is this a month range?
		range_start_number = get_season_number (range_start);					-- not a month; is it a season? get start season number
		range_end_number = get_season_number (range_end);						-- get end season number

		if (0 ~= range_start_number) and (0 ~= range_end_number) then
			return true;														-- any season pairing is accepted
		end
		return false;															-- range_start and/or range_end is not a season
	end
																				-- here when range_start is a month
	range_end_number = get_month_number (range_end);							-- get end month number
	if range_start_number &lt; range_end_number then								-- range_start is a month; does range_start precede range_end?
		if is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
		end
	end
	return false;																-- range_start month number is greater than or equal to range end number; or range end isn't a month
end


--[[--------------------------&lt; M A K E _ C O I N S _ D A T E &gt;------------------------------------------------

This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1.  The function is called only for |date= parameters and only if the |date=&lt;value&gt; is 
determined to be a valid date format.  The question of what to do with invalid date formats is not answered here.

The date parts in the input table are converted to an ISO 8601 conforming date string:
	single whole dates:		yyyy-mm-dd
	month and year dates:	yyyy-mm
	year dates:				yyyy
	ranges:					yyyy-mm-dd/yyyy-mm-dd
							yyyy-mm/yyyy-mm
							yyyy/yyyy

Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.

The input table has:
	year, year2 – always present; if before 1582, ignore months and days if present
	month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 99 Christmas
	day, day2 –  0 if not provided, 1-31 for days
	
the output table receives:
	rftdate:	an IS8601 formatted date
	rftchron:	a free-form version of the date, usually without year which is in rftdate (season ranges and propername dates)
	rftssn:		one of four season keywords: winter, spring, summer, fall (lowercase)

]]

local function make_COinS_date (input, tCOinS_date)
	local date;																	-- one date or first date in a range
	local date2 = '';															-- end of range date
-- start temporary Julian / Gregorian calendar uncertainty detection
	local year = tonumber(input.year);											-- this temporary code to determine the extent of sources dated to the Julian/Gregorian
	local month = tonumber(input.month);										-- interstice 1 October 1582 – 1 January 1926
	local day = tonumber (input.day);
	if (0 ~= day) and															-- day must have a value for this to be a whole date
		(((1582 == year) and (10 &lt;= month) and (12 &gt;= month)) or				-- any whole 1582 date from 1 october to 31 December or
			((1926 == year) and (1 == month) and (1 == input.day)) or			-- 1 January 1926 or
				((1582 &lt; year) and (1925 &gt;= year))) then						-- any date 1 January 1583 – 31 December 1925
					tCOinS_date.inter_cal_cat = true;							-- set category flag true
	end
-- end temporary Julian / Gergorian calendar uncertainty detection
	
	if 1582 &gt; tonumber(input.year) or 20 &lt; tonumber(input.month) then			-- Julian calendar or season so &amp;rft.date gets year only
		date = input.year;
		if 0 ~= input.year2 and input.year ~= input.year2 then					-- if a range, only the second year portion when not the same as range start year
			date = string.format ('%.4d/%.4d', tonumber(input.year), tonumber(input.year2))		-- assemble the date range
		end
		if 20 &lt; tonumber(input.month) then										-- if season or propername date
			local season = {[24]='winter', [21]='spring', [22]='summer', [23]='fall', [99]='Christmas'};	-- seasons lowercase, no autumn; proper names use title case
			if 0 == input.month2 then											-- single season date
				if 30 &lt;tonumber(input.month) then
					tCOinS_date.rftchron = season[input.month];					-- proper name dates
				else
					tCOinS_date.rftssn = season[input.month];					-- seasons
				end
			else																-- season range with a second season specified
				if input.year ~= input.year2 then								-- season year – season year range or season year–year
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					if 0~= input.month2 then
						tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);
					end
				else															-- season–season year range
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2];	-- season–season year range
				end
			end
		end
		tCOinS_date.rftdate = date;
		return;																	-- done
	end
	
	if 0 ~= input.day then
		date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day));	-- whole date
	elseif 0 ~= input.month then
		date = string.format ('%s-%.2d', input.year, tonumber(input.month));	-- year and month
	else
		date = string.format ('%s', input.year);								-- just year
	end

	if 0 ~= input.year2 then
		if 0 ~= input.day2 then
			date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2));		-- whole date
		elseif 0 ~= input.month2 then
			date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2));	-- year and month
		else
			date2 = string.format ('/%s', input.year2);							-- just year
		end
	end
	
	tCOinS_date.rftdate = date .. date2;										-- date2 has the '/' separator
	return;
end


--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only
allowed range separator is endash.  Additionally, check the date to see that it is a real date: no 31 in 30-day
months; no 29 February when not a leap year.  Months, both long-form and three character abbreviations, and seasons
must be spelled correctly.  Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and
COinS_date.  When this happens, the date parameter is used in the COinS metadata and the CITEREF identifier gets
its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc.)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is ISO 8601 format date; see make_COInS_date()

]]

local function check_date (date_string, tCOinS_date, test_accessdate)
	local year;			-- assume that year2, months, and days are not used;
	local year2=0;		-- second year in a year range
	local month=0;
	local month2=0;		-- second month in a month range
	local day=0;
	local day2=0;		-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then										-- year-initial numerical year month day format
		year, month, day=string.match(date_string, &quot;(%d%d%d%d)%-(%d%d)%-(%d%d)&quot;);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or 0 == tonumber(day) then return false; end	-- month or day number not valid or not Gregorian calendar
		anchor_year = year;
	elseif mw.ustring.match(date_string, &quot;^%D- +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then						-- month-initial: month day, year
		month, day, anchor_year, year=mw.ustring.match(date_string, &quot;(%D-) +(%d%d?),%s*((%d%d%d%d?)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
				
	elseif mw.ustring.match(date_string, &quot;^%D- +[1-9]%d?[%-–][1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year=mw.ustring.match(date_string, &quot;(%D-) +(%d%d?)[%-–](%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
		month2=month;																		-- for metadata
		year2=year;

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d? +%D- +[1-9]%d%d%d%a?$&quot;) then						-- day-initial: day month year
		day, month, anchor_year, year=mw.ustring.match(date_string, &quot;(%d%d*)%s*(%D-) +((%d%d%d%d?)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d?[%-–][1-9]%d? +%D- +[1-9]%d%d%d%a?$&quot;) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year=mw.ustring.match(date_string, &quot;(%d%d?)[%-–](%d%d?) +(%D-) +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
		month2=month;																		-- for metadata
		year2=year;

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d? +%D- +[%-–] +[1-9]%d? +%D- +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year=mw.ustring.match(date_string, &quot;(%d%d?) +(%D-) +[%-–] +(%d%d?) +(%D-) +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);													-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif mw.ustring.match(date_string, &quot;^%D- +[1-9]%d? +[%-–] +%D- +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then		-- month initial month-day-range: month day – month day, year;  uses spaced endash
		month, day, month2, day2, anchor_year, year=mw.ustring.match(date_string, &quot;(%D-) +(%d%d?) +[%-–] +(%D-) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);													-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d? +%D- +[1-9]%d%d%d +[%-–] +[1-9]%d? +%D- +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2=mw.ustring.match(date_string, &quot;(%d%d?) +(%D-) +(%d%d%d%d) +[%-–] +(%d%d?) +(%D-) +((%d%d%d%d)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end												-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);																		-- for metadata
		month2 = get_month_number (month2);

	elseif mw.ustring.match(date_string, &quot;^%D- +[1-9]%d?, +[1-9]%d%d%d +[%-–] +%D- +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then		-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
		month, day, year, month2, day2, anchor_year, year2=mw.ustring.match(date_string, &quot;(%D-) +(%d%d?), +(%d%d%d%d) +[%-–] +(%D-) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end												-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);																		-- for metadata
		month2 = get_month_number (month2);

	elseif mw.ustring.match(date_string, &quot;^%D- +[1-9]%d%d%d[%-–]%d%d%a?$&quot;) then								-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		local century;
		month, year, century, anchor_year, year2=mw.ustring.match(date_string, &quot;(%D-) +((%d%d)%d%d)[%-–]((%d%d)%a?)&quot;);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;					-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		year2 = century..year2;																-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		month = get_season_number (month);

	elseif mw.ustring.match(date_string, &quot;^%D- +[1-9]%d%d%d[%-–][1-9]%d%d%d%a?$&quot;) then						-- special case Winter/Summer year-year; year separated with unspaced endash
		month, year, anchor_year, year2=mw.ustring.match(date_string, &quot;(%D-) +(%d%d%d%d)[%-–]((%d%d%d%d)%a?)&quot;);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;					-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		month = get_season_number (month);													-- for metadata

	elseif mw.ustring.match(date_string, &quot;^%D- +[1-9]%d%d%d +[%-–] +%D- +[1-9]%d%d%d%a?$&quot;) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2=mw.ustring.match(date_string, &quot;(%D-) +(%d%d%d%d) +[%-–] +(%D-) +((%d%d%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end							-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then 	-- both must be month year, same month style
			month = get_month_number(month);
			month2 = get_month_number(month2);
		elseif 0 ~= get_season_number(month) and 0 ~= get_season_number(month2) then		-- both must be or season year, not mixed
			month = get_season_number(month);
			month2 = get_season_number(month2);
		else
			 return false;
		end

	elseif mw.ustring.match(date_string, &quot;^%D-[%-–]%D- +[1-9]%d%d%d%a?$&quot;) then					-- month/season range year; months separated by endash 
		month, month2, anchor_year, year=mw.ustring.match(date_string, &quot;(%D-)[%-–](%D-)%s*((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or (not is_valid_year(year)) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
			month2 = get_month_number(month2);
		else
			month = get_season_number(month);
			month2 = get_season_number(month2);
		end
		year2=year;
		
	elseif mw.ustring.match(date_string, &quot;^%D- +%d%d%d%d%a?$&quot;) then							-- month/season year or proper-name year
		month, anchor_year, year=mw.ustring.match(date_string, &quot;(%D-)%s*((%d%d%d%d)%a?)&quot;);
		if not is_valid_year(year) then return false; end
		if not is_valid_month_or_season (month) and 0 == is_proper_name (month) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
		elseif 0 ~= get_season_number(month) then
			month = get_season_number(month);
		else
			month = is_proper_name (month);										-- must be proper name; not supported in COinS
		end

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d%d%d?[%-–][1-9]%d%d%d?%a?$&quot;) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2=mw.ustring.match(date_string, &quot;(%d%d%d%d?)[%-–]((%d%d%d%d?)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d%d%d[%-–]%d%d%a?$&quot;) then						-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2=mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]((%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century..year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then							-- year; here accept either YYY or YYYY
		anchor_year, year=date_string:match(&quot;((%d%d%d%d?)%a?)&quot;);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;															-- date format not one of the MOS:DATE approved formats
	end

	if test_accessdate then														-- test accessdate here because we have numerical date parts
		if 0 ~= year and 0 ~= month and 0 ~= day and 							-- all parts of a single date required
			0 == year2 and 0 == month2 and 0 == day2 then						-- none of these; accessdate must not be a range
				if not is_valid_accessdate (year..'-'..month..'-'..day) then	
					return false;												-- return false when accessdate out of bounds
				end
		else
			return false;														-- return false when accessdate is a range of two dates
		end
	end

	local result=true;															-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result=is_valid_date(year,month,day);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month2,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year2,month2,day2);
	end
	
	if false == result then return false; end

	if nil ~= tCOinS_date then													-- this table only passed into this function when testing |date= parameter values
		make_COinS_date ({year=year, month=month, day=day, year2=year2, month2=month2, day2=day2}, tCOinS_date);	-- make an ISO 8601 date string for COinS
	end
	
	return true, anchor_year;													-- format is good and date string represents a real date
end	


--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.

]]

local function dates(date_parameters_list, tCOinS_date)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local embargo_date;															-- if embargo date is a good dmy, mdy, ymd date then holds original value else reset to 9999
	local error_message = &quot;&quot;;
	local good_date = false;
	
	for k, v in pairs(date_parameters_list) do									-- for each date-holding parameter in the list
		if is_set(v.val) then														-- if the parameter has a value
			v.val = mw.ustring.gsub (v.val, '%d', cfg.date_names.local_digits);			-- translate 'local' digits to Western 0-9
			if v.val:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then							-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v.val:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);					-- get the year portion so it can be tested
				if 'date'==k then
					anchor_year, COinS_date = v.val:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year'==k then
					good_date = is_valid_year(year);
				end
			elseif 'date'==k then												-- if the parameter is |date=
				if v.val:match(&quot;^n%.d%.%a?$&quot;) then									-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v.val:match(&quot;^nd%a?$&quot;) then									-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v.val, tCOinS_date);	-- go test the date
				end
			elseif 'year'==k then												-- if the parameter is |year= it should hold only a year value
				if v.val:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then							-- if |year= 3 or 4 digits only with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((%d+)%a?)&quot;);
				end
			elseif 'access-date'==k then										-- if the parameter is |date=
				good_date = check_date (v.val, nil, true);							-- go test the date; nil is a placeholder; true is the test_accessdate flag
			elseif 'embargo'==k then											-- if the parameter is |embargo=
				good_date = check_date (v.val);										-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date, embargo_date = is_valid_embargo_date (v.val);		-- is |embargo= date a single dmy, mdy, or ymd formatted date? yes:returns embargo; no: returns 9999
				end
			else																-- any other date-holding parameter
				good_date = check_date (v.val);										-- go test the date
			end
			if false==good_date then											-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then									-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;						-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. v.name .. &quot;=&quot;;		-- add the failed parameter
			end
		end
	end
	return anchor_year, embargo_date, error_message;											-- and done
end


--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function returns a numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

]]

local function year_date_check (year_string, date_string)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes
	
	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where both date and year are required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard range formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif mw.ustring.match(date_string, &quot;%d%d%d%d[%-–]%d%d&quot;) then								-- YYYY-YY date ranges
		local century;
		date1, century, date2 = mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	else
		result = 0;																-- no recognizable year in date
	end
	return result;
end


--[[-------------------------&lt; R E F O R M A T   T A B L E S &gt;------------------------------------------------

These table are used exclusively for reformatting dates

]]

local source_patterns = {						-- this table holds patterns that match allowed date formats used to extract date components
	['dmy'] = '^(%d%d?)%s+(%a+)%s+(%d%d%d%d)$',
	['mdy'] = '^(%a+)%s+(%d%d?),%s+(%d%d%d%d)$',
	['ymd'] = '^(%d%d%d%d)%-(%d%d)-(%d%d)$',
	}

local short_formats = {							-- this table holds format strings used by os.date() for short month names
	['dmy'] = '%e %b %Y',
	['mdy'] = '%b %e, %Y',
	['ymd'] = '%F',
	}

local long_formats = {							-- this table holds format strings used by os.date() for long month names
	['dmy'] = '%e %B %Y',
	['mdy'] = '%B %e, %Y',
	['ymd'] = '%F',
	}


--[[-------------------------&lt; G E T _ D M Y _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from DMY formatted date, places them in the source_date table, and returns.

]]

local function get_dmy_date_parts (date, source_date)
	source_date.day, source_date.month, source_date.year = date:match (source_patterns['dmy']);	-- get date components as strings
	source_date.month = get_month_number (source_date.month);					-- get month number
end


--[[-------------------------&lt; G E T _ M D Y _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from MDY formatted date, places them in the source_date table, and returns.

]]

local function get_mdy_date_parts (date, source_date)
	source_date.month, source_date.day, source_date.year = date:match (source_patterns['mdy']);	-- get date components as strings
	source_date.month = get_month_number (source_date.month);					-- get month number
end


--[[-------------------------&lt; G E T _ Y M D _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from YMD formatted date, places them in the source_date table, and returns.

]]

local function get_ymd_date_parts (date, source_date)
	source_date.year, source_date.month, source_date.day = date:match (source_patterns['ymd']);	-- get date components as strings
end


--[[-------------------------&lt; R E F O R M A T _ D A T E S &gt;--------------------------------------------------

Reformats existing dates into the format specified by format and short.

format is one of several keywords: dmy, dmy-all, mdy, mdy-all, ymd, ymd-all.  The all version includes access- and
archive-dates; otherwise these dates are not reformatted

Date ranges, season dates, proper name dates are not currently supported.

For i18n:  This code works only at en.wiki because os.date() doesn't support any languages other than English.
mw.getContentLanguage():formatDate() will work at non-English wikis only when the date format is yyyy-mm-dd. This is
the same issue that plagues is_valid_accessdate()

It is possible that a solution like that written for ht:Module:Citation/CS1/Date_validation date_name_xlate() could be applied to this problem

]]

local function reformat_dates (date_parameters_list, format, short)
	local all = false;															-- set to false to skip access- and archive-dates
	local format_str;
	local source_date = {};
	
	if format:match('%a+%-all') then
		format = format:match('(%a+)%-all');									-- extract the format
		all = true;																-- set to true to format access- and archive-dates
	end
	
	for param_name, param_val in pairs (date_parameters_list) do				-- for each date-holding parameter in the list
		if is_set (param_val.val) then												-- if the parameter has a value
			if not all and in_array (param_name, {'access-date', 'archive-date'}) then	-- if access- or archive-date and format not xxx-all
				param_val.val = '';													-- set to empty string so we don't process this date
			end
			for source, pattern in pairs (source_patterns) do
				if param_val.val:match (pattern) then
					if 'ymd' == source then
						get_ymd_date_parts (param_val.val, source_date);			-- get the date parts into the source_date table
					elseif 'dmy' == source then
						get_dmy_date_parts (param_val.val, source_date);			-- get the date parts into the source_date table
					elseif 'mdy' == source then
						get_mdy_date_parts (param_val.val, source_date);			-- get the date parts into the source_date table
					end

					if 'ymd' == format and 1582 &gt; tonumber(source_date.year) then	-- ymd format dates not allowed before 1582
						return false;											-- abandon reformatting
					end
					
					if short then
						format_str = short_formats[format];
					else
						format_str = long_formats[format];
					end
																				-- convert date and save;
					date_parameters_list[param_name].val = mw.text.trim (os.date (format_str, os.time(source_date)));	-- strip leading space when single digit day and %e is first format
				end
			end
		end
	end
	return true;																-- declare success and done
end


--[[--------------------------&lt; D A T E _ H Y P H E N _ T O _ D A S H &gt;----------------------------------------

Loops through the list of date-holding parameters and converts any hyphen to an ndash.  Not called if the cs1|2
template has any date errors.

Modifies the date_parameters_list and returns true if hyphens are replaced, else returns false.

]]

local function date_hyphen_to_dash (date_parameters_list)
	local result = false;
	local n;
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set (param_val.val) then
			if not mw.ustring.match (param_val.val, '%d%d%d%d%-%d%d%-%d%d') then		-- for those that are not ymd dates (ustring because here digits may not be western)
				param_val.val, n = param_val.val:gsub ('%-', '–');							-- replace any hyphen with ndash
				if 0 ~= n then
					date_parameters_list[param_name].val = param_val.val;					-- update the list
					result = true;
				end
			end
		end
	end
	return result;																-- so we know if any hyphens were replaced
end


--[[-------------------------&lt; D A T E _ N A M E _ X L A T E &gt;------------------------------------------------

Attempts to translate English month names to local-language month names using names supplied by MediaWiki's
date parser function.  This is simple name-for-name replacement and may not work for all languages.

if xlat_dig is true, this function will also translate western (English) digits to the local language's digits.
This will also translate ymd dates.

]]

local function	date_name_xlate (date_parameters_list, xlt_dig)
	local xlate;
	local mode;																	-- long or short month names
	local modified = false;
	local date;
	
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val.val) then											-- if the parameter has a value
			date = param_val.val;
			for month in mw.ustring.gmatch (date, '%a+') do						-- iterate through all dates in the date (single date or date range)
				if cfg.date_names.en.long[month] then
					mode = 'F';													-- English name is long so use long local name
				elseif cfg.date_names.en.short[month] then
					mode = 'M';													-- English name is short so use short local name
				else
					mode = nil;													-- not an English month name; could be local language month name or an English season name
				end
		
				if mode then															-- might be a season
					xlate = mw.getContentLanguage():formatDate(mode, '1' .. month);		-- translate the month name to this local language
					date = mw.ustring.gsub (date, month, xlate);						-- replace the English with the translation
					date_parameters_list[param_name].val = date;						-- save the translated date
					modified = true;
				end
			end

			if xlt_dig then														-- shall we also translate digits?
				date = date:gsub ('%d', cfg.date_names.xlate_digits);			-- translate digits from western to 'local digits'
				date_parameters_list[param_name].val = date;					-- save the translated date
				modified = true;
			end
		end
	end
	
	return modified;
	end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	is_set = utilities_page_ptr.is_set;											-- import functions from selected Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;										-- import functions from selected Module:Citation/CS1/Utilities module
	cfg = cfg_table_ptr;														-- import tables from selected Module:Citation/CS1/Configuration
end



return {																		-- return exported functions
	dates = dates,
	year_date_check = year_date_check,
	reformat_dates = reformat_dates,
	date_hyphen_to_dash = date_hyphen_to_dash,
	date_name_xlate = date_name_xlate,
	set_selected_modules = set_selected_modules
	}</text>
      <sha1>6su6x3x29l8xt8yuoigkd96847sv6gg</sha1>
    </revision>
    <revision>
      <id>4838</id>
      <parentid>4837</parentid>
      <timestamp>2018-06-10T22:34:32Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>synch from sandbox;</comment>
      <origin>4838</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="45179" sha1="1vsyvap7t0bc9gmgq5zawhizlu9ytx6" xml:space="preserve">
local p = {}


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array;															-- imported functions from selected Module:Citation/CS1/Utilities
local cfg;																		-- table of tables imported from slected Module:Citation/CS1/Configuration

--[=[-------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |accessdate= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-Engish date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate().  To get around that
call this function with YYYY-MM-DD format dates.

]=]

local function is_valid_accessdate (accessdate)
	local lang = mw.getContentLanguage();
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold unix time stamps representing the dates
		
	good1, access_ts = pcall( lang.formatDate, lang, 'U', accessdate );			-- convert accessdate value to unix timesatmp 
	good2, tomorrow_ts = pcall( lang.formatDate, lang, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which which tonumber() may not understand
		access_ts = tonumber (access_ts) or lang:parseFormattedNumber (access_ts);			-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to unix time stamp
	end

	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end


--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct. If not a valid month, returns 0

]]

local function get_month_number (month)
	return cfg.date_names['local'].long[month] or cfg.date_names['local'].short[month] or		-- look for local names first
			cfg.date_names['en'].long[month] or	cfg.date_names['en'].short[month] or			-- failing that, look for English names
			0;																					-- not a recognized month name
end


--[[--------------------------&lt; I S _ V A L I D _ E M B A R G O _ D A T E &gt;------------------------------------

returns true and date value if that value has proper dmy, mdy, ymd format.

returns false and 9999 (embargoed forever) when date value is not proper format; assumes that when |embargo= is
set, the editor intended to embargo a pmc but |embargo= does not hold a single date.

]]

local function is_valid_embargo_date (v)
	if v:match ('^%d%d%d%d%-%d%d%-%d%d$') or									-- ymd
		v:match ('^%d%d?%s+%a+%s+%d%d%d%d$') or									-- dmy
		v:match ('^%a+%s+%d%d?%s*,%s*%d%d%d%d$') then							-- mdy
			return true, v;
	end
	return false, '9999';														-- if here not good date so return false and set embargo date to long time in future
end


--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 1 for Winter, etc.  Capitalization and spelling must be correct. If not a valid season, returns 0

Uses ISO DIS 8601 2016 part 2 §4.7  Divisions of a year for hemishpere-independent seasons:
	21-24 = Spring, Summer, Autumn, Winter, independent of “Hemisphere”

These additional divisions not currently supported:
	25-28 = Spring - Northern Hemisphere, Summer- Northern Hemisphere, Autumn - Northern Hemisphere, Winter - Northern Hemisphere
	29-32 = Spring – Southern Hemisphere, Summer– Southern Hemisphere, Autumn – Southern Hemisphere, Winter - Southern Hemisphere
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)


]]

local function get_season_number (season)
	return cfg.date_names['local'].season[season] or							-- look for local names first
			cfg.date_names['en'].season[season] or								-- failing that, look for English names
			0;																	-- not a recognized season name
end

--[[--------------------------&lt; I S _ P R O P E R _ N A M E &gt;--------------------------------------------------

returns a non-zero number if date contains a recognized proper name.  Capitalization and spelling must be correct.

]]

local function is_proper_name (name)
	return cfg.date_names['local'].named[name] or								-- look for local names dates first
			cfg.date_names['en'].named[name] or									-- failing that, look for English names
			0;																	-- not a recognized named date
end

--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ O R _ S E A S O N &gt;------------------------------

--returns true if month or season is valid (properly spelled, capitalized, abbreviated)

]]

local function is_valid_month_or_season (month_season)
	if 0 == get_month_number (month_season) then		-- if month text isn't one of the twelve months, might be a season
		if 0 == get_season_number (month_season) then	-- not a month, is it a season?
			return false;								-- return false not a month or one of the five seasons
		end
	end
	return true;
end

--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one year in the future are not acceptable.

]]
local year_limit;
local function is_valid_year(year)
	if not is_set(year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;			-- global variable so we only have to fetch it once
	end
	return tonumber(year) &lt;= year_limit;				-- false if year is in the future more than one year
end

--[[--------------------------&lt; I S _ V A L I D _ D A T E &gt;----------------------------------------------------
Returns true if day is less than or equal to the number of days in month and year is no farther into the future
than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap
years before 1582 and Gregorian leap years after 1582. Where the two calendars overlap (1582 to approximately
1923) dates are assumed to be Gregorian.

]]

local function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year(year) then												-- no farther into the future than next year
		return false;
	end
	
	month = tonumber(month);													-- required for YYYY-MM-DD dates
	
	if (2==month) then															-- if February
		month_length = 28;														-- then 28 days unless
		if 1582 &gt; tonumber(year) then											-- Julian calendar
			if 0==(year%4) then
				month_length = 29;
			end
		else																	-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then			-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end

--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
There is a special test for May because it can be either short or long form.

Returns true when style for both months is the same

]]

local function is_valid_month_range_style (month1, month2)
local len1 = month1:len();
local len2 = month2:len();
	if len1 == len2 then
		return true;															-- both months are short form so return true
	elseif 'May' == month1 or 'May'== month2 then
		return true;															-- both months are long form so return true
	elseif 3 == len1 or 3 == len2 then
		return false;															-- months are mixed form so return false
	else
		return true;															-- both months are long form so return true
	end
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

All season ranges are accepted as valid because there are publishers out there who have published a Summer–Spring YYYY issue so ... ok

]]

local function is_valid_month_season_range(range_start, range_end)
	local range_start_number = get_month_number (range_start);
	local range_end_number;
	
	if 0 == range_start_number then												-- is this a month range?
		range_start_number = get_season_number (range_start);					-- not a month; is it a season? get start season number
		range_end_number = get_season_number (range_end);						-- get end season number

		if (0 ~= range_start_number) and (0 ~= range_end_number) then
			return true;														-- any season pairing is accepted
		end
		return false;															-- range_start and/or range_end is not a season
	end
																				-- here when range_start is a month
	range_end_number = get_month_number (range_end);							-- get end month number
	if range_start_number &lt; range_end_number then								-- range_start is a month; does range_start precede range_end?
		if is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
		end
	end
	return false;																-- range_start month number is greater than or equal to range end number; or range end isn't a month
end


--[[--------------------------&lt; M A K E _ C O I N S _ D A T E &gt;------------------------------------------------

This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1.  The function is called only for |date= parameters and only if the |date=&lt;value&gt; is 
determined to be a valid date format.  The question of what to do with invalid date formats is not answered here.

The date parts in the input table are converted to an ISO 8601 conforming date string:
	single whole dates:		yyyy-mm-dd
	month and year dates:	yyyy-mm
	year dates:				yyyy
	ranges:					yyyy-mm-dd/yyyy-mm-dd
							yyyy-mm/yyyy-mm
							yyyy/yyyy

Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.

The input table has:
	year, year2 – always present; if before 1582, ignore months and days if present
	month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 99 Christmas
	day, day2 –  0 if not provided, 1-31 for days
	
the output table receives:
	rftdate:	an IS8601 formatted date
	rftchron:	a free-form version of the date, usually without year which is in rftdate (season ranges and propername dates)
	rftssn:		one of four season keywords: winter, spring, summer, fall (lowercase)

]]

local function make_COinS_date (input, tCOinS_date)
	local date;																	-- one date or first date in a range
	local date2 = '';															-- end of range date
-- start temporary Julian / Gregorian calendar uncertainty detection
	local year = tonumber(input.year);											-- this temporary code to determine the extent of sources dated to the Julian/Gregorian
	local month = tonumber(input.month);										-- interstice 1 October 1582 – 1 January 1926
	local day = tonumber (input.day);
	if (0 ~= day) and															-- day must have a value for this to be a whole date
		(((1582 == year) and (10 &lt;= month) and (12 &gt;= month)) or				-- any whole 1582 date from 1 october to 31 December or
			((1926 == year) and (1 == month) and (1 == input.day)) or			-- 1 January 1926 or
				((1582 &lt; year) and (1925 &gt;= year))) then						-- any date 1 January 1583 – 31 December 1925
					tCOinS_date.inter_cal_cat = true;							-- set category flag true
	end
-- end temporary Julian / Gergorian calendar uncertainty detection
	
	if 1582 &gt; tonumber(input.year) or 20 &lt; tonumber(input.month) then			-- Julian calendar or season so &amp;rft.date gets year only
		date = input.year;
		if 0 ~= input.year2 and input.year ~= input.year2 then					-- if a range, only the second year portion when not the same as range start year
			date = string.format ('%.4d/%.4d', tonumber(input.year), tonumber(input.year2))		-- assemble the date range
		end
		if 20 &lt; tonumber(input.month) then										-- if season or propername date
			local season = {[24]='winter', [21]='spring', [22]='summer', [23]='fall', [99]='Christmas'};	-- seasons lowercase, no autumn; proper names use title case
			if 0 == input.month2 then											-- single season date
				if 30 &lt;tonumber(input.month) then
					tCOinS_date.rftchron = season[input.month];					-- proper name dates
				else
					tCOinS_date.rftssn = season[input.month];					-- seasons
				end
			else																-- season range with a second season specified
				if input.year ~= input.year2 then								-- season year – season year range or season year–year
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					if 0~= input.month2 then
						tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);
					end
				else															-- season–season year range
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2];	-- season–season year range
				end
			end
		end
		tCOinS_date.rftdate = date;
		return;																	-- done
	end
	
	if 0 ~= input.day then
		date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day));	-- whole date
	elseif 0 ~= input.month then
		date = string.format ('%s-%.2d', input.year, tonumber(input.month));	-- year and month
	else
		date = string.format ('%s', input.year);								-- just year
	end

	if 0 ~= input.year2 then
		if 0 ~= input.day2 then
			date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2));		-- whole date
		elseif 0 ~= input.month2 then
			date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2));	-- year and month
		else
			date2 = string.format ('/%s', input.year2);							-- just year
		end
	end
	
	tCOinS_date.rftdate = date .. date2;										-- date2 has the '/' separator
	return;
end


--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only
allowed range separator is endash.  Additionally, check the date to see that it is a real date: no 31 in 30-day
months; no 29 February when not a leap year.  Months, both long-form and three character abbreviations, and seasons
must be spelled correctly.  Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and
COinS_date.  When this happens, the date parameter is used in the COinS metadata and the CITEREF identifier gets
its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc.)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is ISO 8601 format date; see make_COInS_date()

]]

local function check_date (date_string, tCOinS_date, test_accessdate)
	local year;			-- assume that year2, months, and days are not used;
	local year2=0;		-- second year in a year range
	local month=0;
	local month2=0;		-- second month in a month range
	local day=0;
	local day2=0;		-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then										-- year-initial numerical year month day format
		year, month, day=string.match(date_string, &quot;(%d%d%d%d)%-(%d%d)%-(%d%d)&quot;);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or 0 == tonumber(day) then return false; end	-- month or day number not valid or not Gregorian calendar
		anchor_year = year;
	elseif mw.ustring.match(date_string, &quot;^%D- +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then						-- month-initial: month day, year
		month, day, anchor_year, year=mw.ustring.match(date_string, &quot;(%D-) +(%d%d?),%s*((%d%d%d%d?)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
				
	elseif mw.ustring.match(date_string, &quot;^%D- +[1-9]%d?[%-–][1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year=mw.ustring.match(date_string, &quot;(%D-) +(%d%d?)[%-–](%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
		month2=month;																		-- for metadata
		year2=year;

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d? +%D- +[1-9]%d%d%d%a?$&quot;) then						-- day-initial: day month year
		day, month, anchor_year, year=mw.ustring.match(date_string, &quot;(%d%d*)%s*(%D-) +((%d%d%d%d?)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d?[%-–][1-9]%d? +%D- +[1-9]%d%d%d%a?$&quot;) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year=mw.ustring.match(date_string, &quot;(%d%d?)[%-–](%d%d?) +(%D-) +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
		month2=month;																		-- for metadata
		year2=year;

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d? +%D- +[%-–] +[1-9]%d? +%D- +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year=mw.ustring.match(date_string, &quot;(%d%d?) +(%D-) +[%-–] +(%d%d?) +(%D-) +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);													-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif mw.ustring.match(date_string, &quot;^%D- +[1-9]%d? +[%-–] +%D- +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then		-- month initial month-day-range: month day – month day, year;  uses spaced endash
		month, day, month2, day2, anchor_year, year=mw.ustring.match(date_string, &quot;(%D-) +(%d%d?) +[%-–] +(%D-) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);													-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d? +%D- +[1-9]%d%d%d +[%-–] +[1-9]%d? +%D- +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2=mw.ustring.match(date_string, &quot;(%d%d?) +(%D-) +(%d%d%d%d) +[%-–] +(%d%d?) +(%D-) +((%d%d%d%d)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end												-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);																		-- for metadata
		month2 = get_month_number (month2);

	elseif mw.ustring.match(date_string, &quot;^%D- +[1-9]%d?, +[1-9]%d%d%d +[%-–] +%D- +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then		-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
		month, day, year, month2, day2, anchor_year, year2=mw.ustring.match(date_string, &quot;(%D-) +(%d%d?), +(%d%d%d%d) +[%-–] +(%D-) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end												-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);																		-- for metadata
		month2 = get_month_number (month2);

	elseif mw.ustring.match(date_string, &quot;^%D- +[1-9]%d%d%d[%-–]%d%d%a?$&quot;) then								-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		local century;
		month, year, century, anchor_year, year2=mw.ustring.match(date_string, &quot;(%D-) +((%d%d)%d%d)[%-–]((%d%d)%a?)&quot;);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;					-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		year2 = century..year2;																-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		month = get_season_number (month);

	elseif mw.ustring.match(date_string, &quot;^%D- +[1-9]%d%d%d[%-–][1-9]%d%d%d%a?$&quot;) then						-- special case Winter/Summer year-year; year separated with unspaced endash
		month, year, anchor_year, year2=mw.ustring.match(date_string, &quot;(%D-) +(%d%d%d%d)[%-–]((%d%d%d%d)%a?)&quot;);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;					-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		month = get_season_number (month);													-- for metadata

	elseif mw.ustring.match(date_string, &quot;^%D- +[1-9]%d%d%d +[%-–] +%D- +[1-9]%d%d%d%a?$&quot;) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2=mw.ustring.match(date_string, &quot;(%D-) +(%d%d%d%d) +[%-–] +(%D-) +((%d%d%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end							-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then 	-- both must be month year, same month style
			month = get_month_number(month);
			month2 = get_month_number(month2);
		elseif 0 ~= get_season_number(month) and 0 ~= get_season_number(month2) then		-- both must be or season year, not mixed
			month = get_season_number(month);
			month2 = get_season_number(month2);
		else
			 return false;
		end

	elseif mw.ustring.match(date_string, &quot;^%D-[%-–]%D- +[1-9]%d%d%d%a?$&quot;) then					-- month/season range year; months separated by endash 
		month, month2, anchor_year, year=mw.ustring.match(date_string, &quot;(%D-)[%-–](%D-)%s*((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or (not is_valid_year(year)) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
			month2 = get_month_number(month2);
		else
			month = get_season_number(month);
			month2 = get_season_number(month2);
		end
		year2=year;
		
	elseif mw.ustring.match(date_string, &quot;^%D- +%d%d%d%d%a?$&quot;) then							-- month/season year or proper-name year
		month, anchor_year, year=mw.ustring.match(date_string, &quot;(%D-)%s*((%d%d%d%d)%a?)&quot;);
		if not is_valid_year(year) then return false; end
		if not is_valid_month_or_season (month) and 0 == is_proper_name (month) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
		elseif 0 ~= get_season_number(month) then
			month = get_season_number(month);
		else
			month = is_proper_name (month);										-- must be proper name; not supported in COinS
		end

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d%d%d?[%-–][1-9]%d%d%d?%a?$&quot;) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2=mw.ustring.match(date_string, &quot;(%d%d%d%d?)[%-–]((%d%d%d%d?)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d%d%d[%-–]%d%d%a?$&quot;) then						-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2=mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]((%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century..year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then							-- year; here accept either YYY or YYYY
		anchor_year, year=date_string:match(&quot;((%d%d%d%d?)%a?)&quot;);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;															-- date format not one of the MOS:DATE approved formats
	end

	if test_accessdate then														-- test accessdate here because we have numerical date parts
		if 0 ~= year and 0 ~= month and 0 ~= day and 							-- all parts of a single date required
			0 == year2 and 0 == month2 and 0 == day2 then						-- none of these; accessdate must not be a range
				if not is_valid_accessdate (year..'-'..month..'-'..day) then	
					return false;												-- return false when accessdate out of bounds
				end
		else
			return false;														-- return false when accessdate is a range of two dates
		end
	end

	local result=true;															-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result=is_valid_date(year,month,day);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month2,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year2,month2,day2);
	end
	
	if false == result then return false; end

	if nil ~= tCOinS_date then													-- this table only passed into this function when testing |date= parameter values
		make_COinS_date ({year=year, month=month, day=day, year2=year2, month2=month2, day2=day2}, tCOinS_date);	-- make an ISO 8601 date string for COinS
	end
	
	return true, anchor_year;													-- format is good and date string represents a real date
end	


--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.

]]

local function dates(date_parameters_list, tCOinS_date)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local embargo_date;															-- if embargo date is a good dmy, mdy, ymd date then holds original value else reset to 9999
	local error_message = &quot;&quot;;
	local good_date = false;
	
	for k, v in pairs(date_parameters_list) do									-- for each date-holding parameter in the list
		if is_set(v.val) then														-- if the parameter has a value
			v.val = mw.ustring.gsub (v.val, '%d', cfg.date_names.local_digits);			-- translate 'local' digits to Western 0-9
			if v.val:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then							-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v.val:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);					-- get the year portion so it can be tested
				if 'date'==k then
					anchor_year, COinS_date = v.val:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year'==k then
					good_date = is_valid_year(year);
				end
			elseif 'date'==k then												-- if the parameter is |date=
				if v.val:match(&quot;^n%.d%.%a?$&quot;) then									-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v.val:match(&quot;^nd%a?$&quot;) then									-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v.val, tCOinS_date);	-- go test the date
				end
			elseif 'year'==k then												-- if the parameter is |year= it should hold only a year value
				if v.val:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then							-- if |year= 3 or 4 digits only with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((%d+)%a?)&quot;);
				end
			elseif 'access-date'==k then										-- if the parameter is |date=
				good_date = check_date (v.val, nil, true);							-- go test the date; nil is a placeholder; true is the test_accessdate flag
			elseif 'embargo'==k then											-- if the parameter is |embargo=
				good_date = check_date (v.val);										-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date, embargo_date = is_valid_embargo_date (v.val);		-- is |embargo= date a single dmy, mdy, or ymd formatted date? yes:returns embargo; no: returns 9999
				end
			else																-- any other date-holding parameter
				good_date = check_date (v.val);										-- go test the date
			end
			if false==good_date then											-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then									-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;						-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. v.name .. &quot;=&quot;;		-- add the failed parameter
			end
		end
	end
	return anchor_year, embargo_date, error_message;											-- and done
end


--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function returns a numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

]]

local function year_date_check (year_string, date_string)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes
	
	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where both date and year are required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard range formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif mw.ustring.match(date_string, &quot;%d%d%d%d[%-–]%d%d&quot;) then								-- YYYY-YY date ranges
		local century;
		date1, century, date2 = mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	else
		result = 0;																-- no recognizable year in date
	end
	return result;
end


--[[-------------------------&lt; R E F O R M A T   T A B L E S &gt;------------------------------------------------

These table are used exclusively for reformatting dates

]]

local source_patterns = {						-- this table holds patterns that match allowed date formats used to extract date components
	['dmy'] = '^(%d%d?)%s+(%a+)%s+(%d%d%d%d)$',
	['mdy'] = '^(%a+)%s+(%d%d?),%s+(%d%d%d%d)$',
	['ymd'] = '^(%d%d%d%d)%-(%d%d)-(%d%d)$',
	}

local short_formats = {							-- this table holds format strings used by os.date() for short month names
	['dmy'] = '%e %b %Y',
	['mdy'] = '%b %e, %Y',
	['ymd'] = '%F',
	}

local long_formats = {							-- this table holds format strings used by os.date() for long month names
	['dmy'] = '%e %B %Y',
	['mdy'] = '%B %e, %Y',
	['ymd'] = '%F',
	}


--[[-------------------------&lt; G E T _ D M Y _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from DMY formatted date, places them in the source_date table, and returns.

]]

local function get_dmy_date_parts (date, source_date)
	source_date.day, source_date.month, source_date.year = date:match (source_patterns['dmy']);	-- get date components as strings
	source_date.month = get_month_number (source_date.month);					-- get month number
end


--[[-------------------------&lt; G E T _ M D Y _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from MDY formatted date, places them in the source_date table, and returns.

]]

local function get_mdy_date_parts (date, source_date)
	source_date.month, source_date.day, source_date.year = date:match (source_patterns['mdy']);	-- get date components as strings
	source_date.month = get_month_number (source_date.month);					-- get month number
end


--[[-------------------------&lt; G E T _ Y M D _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from YMD formatted date, places them in the source_date table, and returns.

]]

local function get_ymd_date_parts (date, source_date)
	source_date.year, source_date.month, source_date.day = date:match (source_patterns['ymd']);	-- get date components as strings
end


--[[-------------------------&lt; R E F O R M A T _ D A T E S &gt;--------------------------------------------------

Reformats existing dates into the format specified by format and short.

format is one of several keywords: dmy, dmy-all, mdy, mdy-all, ymd, ymd-all.  The all version includes access- and
archive-dates; otherwise these dates are not reformatted

Date ranges, season dates, proper name dates are not currently supported.

For i18n:  This code works only at en.wiki because os.date() doesn't support any languages other than English.
mw.getContentLanguage():formatDate() will work at non-English wikis only when the date format is yyyy-mm-dd. This is
the same issue that plagues is_valid_accessdate()

It is possible that a solution like that written for ht:Module:Citation/CS1/Date_validation date_name_xlate() could be applied to this problem

]]

local function reformat_dates (date_parameters_list, format, short)
	local all = false;															-- set to false to skip access- and archive-dates
	local result = false;
	local format_str;
	local source_date = {};
	
	if format:match('%a+%-all') then
		format = format:match('(%a+)%-all');									-- extract the format
		all = true;																-- set to true to format access- and archive-dates
	end
	
	for param_name, param_val in pairs (date_parameters_list) do				-- for each date-holding parameter in the list
		if is_set (param_val.val) then											-- if the parameter has a value
			if not (not all and in_array (param_name, {'access-date', 'archive-date'})) then	-- skip access- or archive-date unless format is xxx-all; yeah, ugly; TODO: find a better way
				for source, pattern in pairs (source_patterns) do
					if param_val.val:match (pattern) then
						if 'ymd' == source then
							get_ymd_date_parts (param_val.val, source_date);	-- get the date parts into the source_date table
						elseif 'dmy' == source then
							get_dmy_date_parts (param_val.val, source_date);	-- get the date parts into the source_date table
						elseif 'mdy' == source then
							get_mdy_date_parts (param_val.val, source_date);	-- get the date parts into the source_date table
						end
	
						if 'ymd' == format and 1582 &gt; tonumber(source_date.year) then	-- ymd format dates not allowed before 1582
							return false;											-- abandon reformatting
						end
						
						if short then
							format_str = short_formats[format];
						else
							format_str = long_formats[format];
						end
																					-- convert date and save;
						date_parameters_list[param_name].val = mw.text.trim (os.date (format_str, os.time(source_date)));	-- strip leading space when single digit day and %e is first format
						result = true;
					end	-- if
				end		-- for
			end			-- if
		end				-- if
	end					-- for
return result;																	-- declare result and done
end


--[[--------------------------&lt; D A T E _ H Y P H E N _ T O _ D A S H &gt;----------------------------------------

Loops through the list of date-holding parameters and converts any hyphen to an ndash.  Not called if the cs1|2
template has any date errors.

Modifies the date_parameters_list and returns true if hyphens are replaced, else returns false.

]]

local function date_hyphen_to_dash (date_parameters_list)
	local result = false;
	local n;
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set (param_val.val) then
			if not mw.ustring.match (param_val.val, '%d%d%d%d%-%d%d%-%d%d') then		-- for those that are not ymd dates (ustring because here digits may not be western)
				param_val.val, n = param_val.val:gsub ('%-', '–');							-- replace any hyphen with ndash
				if 0 ~= n then
					date_parameters_list[param_name].val = param_val.val;					-- update the list
					result = true;
				end
			end
		end
	end
	return result;																-- so we know if any hyphens were replaced
end


--[[-------------------------&lt; D A T E _ N A M E _ X L A T E &gt;------------------------------------------------

Attempts to translate English month names to local-language month names using names supplied by MediaWiki's
date parser function.  This is simple name-for-name replacement and may not work for all languages.

if xlat_dig is true, this function will also translate western (English) digits to the local language's digits.
This will also translate ymd dates.

]]

local function	date_name_xlate (date_parameters_list, xlt_dig)
	local xlate;
	local mode;																	-- long or short month names
	local modified = false;
	local date;
	
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val.val) then											-- if the parameter has a value
			date = param_val.val;
			for month in mw.ustring.gmatch (date, '%a+') do						-- iterate through all dates in the date (single date or date range)
				if cfg.date_names.en.long[month] then
					mode = 'F';													-- English name is long so use long local name
				elseif cfg.date_names.en.short[month] then
					mode = 'M';													-- English name is short so use short local name
				else
					mode = nil;													-- not an English month name; could be local language month name or an English season name
				end
		
				if mode then															-- might be a season
					xlate = mw.getContentLanguage():formatDate(mode, '1' .. month);		-- translate the month name to this local language
					date = mw.ustring.gsub (date, month, xlate);						-- replace the English with the translation
					date_parameters_list[param_name].val = date;						-- save the translated date
					modified = true;
				end
			end

			if xlt_dig then														-- shall we also translate digits?
				date = date:gsub ('%d', cfg.date_names.xlate_digits);			-- translate digits from western to 'local digits'
				date_parameters_list[param_name].val = date;					-- save the translated date
				modified = true;
			end
		end
	end
	
	return modified;
	end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	is_set = utilities_page_ptr.is_set;											-- import functions from selected Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;										-- import functions from selected Module:Citation/CS1/Utilities module
	cfg = cfg_table_ptr;														-- import tables from selected Module:Citation/CS1/Configuration
end



return {																		-- return exported functions
	dates = dates,
	year_date_check = year_date_check,
	reformat_dates = reformat_dates,
	date_hyphen_to_dash = date_hyphen_to_dash,
	date_name_xlate = date_name_xlate,
	set_selected_modules = set_selected_modules
	}</text>
      <sha1>1vsyvap7t0bc9gmgq5zawhizlu9ytx6</sha1>
    </revision>
    <revision>
      <id>4839</id>
      <parentid>4838</parentid>
      <timestamp>2019-01-19T10:58:27Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>synch from sandbox;</comment>
      <origin>4839</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="45637" sha1="ngd1bggc5lqhfpi21cg38igszbso20w" xml:space="preserve">
local p = {}


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array;															-- imported functions from selected Module:Citation/CS1/Utilities
local cfg;																		-- table of tables imported from slected Module:Citation/CS1/Configuration

--[=[-------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |accessdate= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-Engish date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate().  To get around that
call this function with YYYY-MM-DD format dates.

]=]

local function is_valid_accessdate (accessdate)
	local lang = mw.getContentLanguage();
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold unix time stamps representing the dates
		
	good1, access_ts = pcall( lang.formatDate, lang, 'U', accessdate );			-- convert accessdate value to unix timesatmp 
	good2, tomorrow_ts = pcall( lang.formatDate, lang, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which which tonumber() may not understand
		access_ts = tonumber (access_ts) or lang:parseFormattedNumber (access_ts);			-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to unix time stamp
	end

	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end


--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct. If not a valid month, returns 0

]]

local function get_month_number (month)
	return cfg.date_names['local'].long[month] or cfg.date_names['local'].short[month] or		-- look for local names first
			cfg.date_names['en'].long[month] or	cfg.date_names['en'].short[month] or			-- failing that, look for English names
			0;																					-- not a recognized month name
end


--[[--------------------------&lt; I S _ V A L I D _ E M B A R G O _ D A T E &gt;------------------------------------

returns true and date value if that value has proper dmy, mdy, ymd format.

returns false and 9999 (embargoed forever) when date value is not proper format; assumes that when |embargo= is
set, the editor intended to embargo a pmc but |embargo= does not hold a single date.

]]

local function is_valid_embargo_date (v)
	if v:match ('^%d%d%d%d%-%d%d%-%d%d$') or									-- ymd
		v:match ('^%d%d?%s+%a+%s+%d%d%d%d$') or									-- dmy
		v:match ('^%a+%s+%d%d?%s*,%s*%d%d%d%d$') then							-- mdy
			return true, v;
	end
	return false, '9999';														-- if here not good date so return false and set embargo date to long time in future
end


--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 1 for Winter, etc.  Capitalization and spelling must be correct. If not a valid season, returns 0

Uses ISO DIS 8601 2016 part 2 §4.7  Divisions of a year for hemishpere-independent seasons:
	21-24 = Spring, Summer, Autumn, Winter, independent of “Hemisphere”

These additional divisions not currently supported:
	25-28 = Spring - Northern Hemisphere, Summer- Northern Hemisphere, Autumn - Northern Hemisphere, Winter - Northern Hemisphere
	29-32 = Spring – Southern Hemisphere, Summer– Southern Hemisphere, Autumn – Southern Hemisphere, Winter - Southern Hemisphere
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)


]]

local function get_season_number (season)
	return cfg.date_names['local'].season[season] or							-- look for local names first
			cfg.date_names['en'].season[season] or								-- failing that, look for English names
			0;																	-- not a recognized season name
end

--[[--------------------------&lt; I S _ P R O P E R _ N A M E &gt;--------------------------------------------------

returns a non-zero number if date contains a recognized proper name.  Capitalization and spelling must be correct.

]]

local function is_proper_name (name)
	return cfg.date_names['local'].named[name] or								-- look for local names dates first
			cfg.date_names['en'].named[name] or									-- failing that, look for English names
			0;																	-- not a recognized named date
end

--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ O R _ S E A S O N &gt;------------------------------

--returns true if month or season is valid (properly spelled, capitalized, abbreviated)

]]

local function is_valid_month_or_season (month_season)
	if 0 == get_month_number (month_season) then		-- if month text isn't one of the twelve months, might be a season
		if 0 == get_season_number (month_season) then	-- not a month, is it a season?
			return false;								-- return false not a month or one of the five seasons
		end
	end
	return true;
end

--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one year in the future are not acceptable.

]]
local year_limit;
local function is_valid_year(year)
	if not is_set(year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;			-- global variable so we only have to fetch it once
	end
	return tonumber(year) &lt;= year_limit;				-- false if year is in the future more than one year
end

--[[--------------------------&lt; I S _ V A L I D _ D A T E &gt;----------------------------------------------------
Returns true if day is less than or equal to the number of days in month and year is no farther into the future
than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap
years before 1582 and Gregorian leap years after 1582. Where the two calendars overlap (1582 to approximately
1923) dates are assumed to be Gregorian.

]]

local function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year(year) then												-- no farther into the future than next year
		return false;
	end
	
	month = tonumber(month);													-- required for YYYY-MM-DD dates
	
	if (2==month) then															-- if February
		month_length = 28;														-- then 28 days unless
		if 1582 &gt; tonumber(year) then											-- Julian calendar
			if 0==(year%4) then
				month_length = 29;
			end
		else																	-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then			-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end

--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
There is a special test for May because it can be either short or long form.

Returns true when style for both months is the same

]]

local function is_valid_month_range_style (month1, month2)
local len1 = month1:len();
local len2 = month2:len();
	if len1 == len2 then
		return true;															-- both months are short form so return true
	elseif 'May' == month1 or 'May'== month2 then
		return true;															-- both months are long form so return true
	elseif 3 == len1 or 3 == len2 then
		return false;															-- months are mixed form so return false
	else
		return true;															-- both months are long form so return true
	end
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

All season ranges are accepted as valid because there are publishers out there who have published a Summer–Spring YYYY issue so ... ok

]]

local function is_valid_month_season_range(range_start, range_end)
	local range_start_number = get_month_number (range_start);
	local range_end_number;
	
	if 0 == range_start_number then												-- is this a month range?
		range_start_number = get_season_number (range_start);					-- not a month; is it a season? get start season number
		range_end_number = get_season_number (range_end);						-- get end season number

		if (0 ~= range_start_number) and (0 ~= range_end_number) then
			return true;														-- any season pairing is accepted
		end
		return false;															-- range_start and/or range_end is not a season
	end
																				-- here when range_start is a month
	range_end_number = get_month_number (range_end);							-- get end month number
	if range_start_number &lt; range_end_number then								-- range_start is a month; does range_start precede range_end?
		if is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
		end
	end
	return false;																-- range_start month number is greater than or equal to range end number; or range end isn't a month
end


--[[--------------------------&lt; M A K E _ C O I N S _ D A T E &gt;------------------------------------------------

This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1.  The function is called only for |date= parameters and only if the |date=&lt;value&gt; is 
determined to be a valid date format.  The question of what to do with invalid date formats is not answered here.

The date parts in the input table are converted to an ISO 8601 conforming date string:
	single whole dates:		yyyy-mm-dd
	month and year dates:	yyyy-mm
	year dates:				yyyy
	ranges:					yyyy-mm-dd/yyyy-mm-dd
							yyyy-mm/yyyy-mm
							yyyy/yyyy

Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.

The input table has:
	year, year2 – always present; if before 1582, ignore months and days if present
	month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 99 Christmas
	day, day2 –  0 if not provided, 1-31 for days
	
the output table receives:
	rftdate:	an IS8601 formatted date
	rftchron:	a free-form version of the date, usually without year which is in rftdate (season ranges and propername dates)
	rftssn:		one of four season keywords: winter, spring, summer, fall (lowercase)

]]

local function make_COinS_date (input, tCOinS_date)
	local date;																	-- one date or first date in a range
	local date2 = '';															-- end of range date
-- start temporary Julian / Gregorian calendar uncertainty detection
	local year = tonumber(input.year);											-- this temporary code to determine the extent of sources dated to the Julian/Gregorian
	local month = tonumber(input.month);										-- interstice 1 October 1582 – 1 January 1926
	local day = tonumber (input.day);
	if (0 ~= day) and															-- day must have a value for this to be a whole date
		(((1582 == year) and (10 &lt;= month) and (12 &gt;= month)) or				-- any whole 1582 date from 1 october to 31 December or
			((1926 == year) and (1 == month) and (1 == input.day)) or			-- 1 January 1926 or
				((1582 &lt; year) and (1925 &gt;= year))) then						-- any date 1 January 1583 – 31 December 1925
					tCOinS_date.inter_cal_cat = true;							-- set category flag true
	end
-- end temporary Julian / Gergorian calendar uncertainty detection
	
	if 1582 &gt; tonumber(input.year) or 20 &lt; tonumber(input.month) then			-- Julian calendar or season so &amp;rft.date gets year only
		date = input.year;
		if 0 ~= input.year2 and input.year ~= input.year2 then					-- if a range, only the second year portion when not the same as range start year
			date = string.format ('%.4d/%.4d', tonumber(input.year), tonumber(input.year2))		-- assemble the date range
		end
		if 20 &lt; tonumber(input.month) then										-- if season or propername date
			local season = {[24]='winter', [21]='spring', [22]='summer', [23]='fall', [99]='Christmas'};	-- seasons lowercase, no autumn; proper names use title case
			if 0 == input.month2 then											-- single season date
				if 30 &lt;tonumber(input.month) then
					tCOinS_date.rftchron = season[input.month];					-- proper name dates
				else
					tCOinS_date.rftssn = season[input.month];					-- seasons
				end
			else																-- season range with a second season specified
				if input.year ~= input.year2 then								-- season year – season year range or season year–year
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					if 0~= input.month2 then
						tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);
					end
				else															-- season–season year range
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2];	-- season–season year range
				end
			end
		end
		tCOinS_date.rftdate = date;
		return;																	-- done
	end
	
	if 0 ~= input.day then
		date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day));	-- whole date
	elseif 0 ~= input.month then
		date = string.format ('%s-%.2d', input.year, tonumber(input.month));	-- year and month
	else
		date = string.format ('%s', input.year);								-- just year
	end

	if 0 ~= input.year2 then
		if 0 ~= input.day2 then
			date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2));		-- whole date
		elseif 0 ~= input.month2 then
			date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2));	-- year and month
		else
			date2 = string.format ('/%s', input.year2);							-- just year
		end
	end
	
	tCOinS_date.rftdate = date .. date2;										-- date2 has the '/' separator
	return;
end


--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only
allowed range separator is endash.  Additionally, check the date to see that it is a real date: no 31 in 30-day
months; no 29 February when not a leap year.  Months, both long-form and three character abbreviations, and seasons
must be spelled correctly.  Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and
COinS_date.  When this happens, the date parameter is used in the COinS metadata and the CITEREF identifier gets
its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc.)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is ISO 8601 format date; see make_COInS_date()

]]

local function check_date (date_string, tCOinS_date, test_accessdate)
	local year;			-- assume that year2, months, and days are not used;
	local year2=0;		-- second year in a year range
	local month=0;
	local month2=0;		-- second month in a month range
	local day=0;
	local day2=0;		-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then										-- year-initial numerical year month day format
		year, month, day=string.match(date_string, &quot;(%d%d%d%d)%-(%d%d)%-(%d%d)&quot;);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or 0 == tonumber(day) then return false; end	-- month or day number not valid or not Gregorian calendar
		anchor_year = year;
	elseif mw.ustring.match(date_string, &quot;^%D- +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then			-- month-initial: month day, year
		month, day, anchor_year, year=mw.ustring.match(date_string, &quot;(%D-) +(%d%d?),%s*((%d%d%d%d?)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
				
	elseif mw.ustring.match(date_string, &quot;^%D- +[1-9]%d?[%-–][1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then		-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year=mw.ustring.match(date_string, &quot;(%D-) +(%d%d?)[%-–](%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
		month2=month;																		-- for metadata
		year2=year;

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d? +%D- +[1-9]%d%d%d%a?$&quot;) then			-- day-initial: day month year
		day, month, anchor_year, year=mw.ustring.match(date_string, &quot;(%d%d*)%s*(%D-) +((%d%d%d%d?)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

--[[ NOT supported at en.wiki
	elseif mw.ustring.match(date_string, &quot;^[1-9]%d%d%d%a? +%D- +%d%d?$&quot;) then				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed
		anchor_year, year, month, day=mw.ustring.match(date_string, &quot;((%d%d%d%d?)%a?) +(%D-) +(%d%d?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
-- end NOT supported at en.wiki ]]

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d?[%-–][1-9]%d? +%D- +[1-9]%d%d%d%a?$&quot;) then		-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year=mw.ustring.match(date_string, &quot;(%d%d?)[%-–](%d%d?) +(%D-) +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
		month2=month;																		-- for metadata
		year2=year;

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d? +%D- +[%-–] +[1-9]%d? +%D- +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year=mw.ustring.match(date_string, &quot;(%d%d?) +(%D-) +[%-–] +(%d%d?) +(%D-) +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);													-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif mw.ustring.match(date_string, &quot;^%D- +[1-9]%d? +[%-–] +%D- +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then		-- month initial month-day-range: month day – month day, year;  uses spaced endash
		month, day, month2, day2, anchor_year, year=mw.ustring.match(date_string, &quot;(%D-) +(%d%d?) +[%-–] +(%D-) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);													-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d? +%D- +[1-9]%d%d%d +[%-–] +[1-9]%d? +%D- +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2=mw.ustring.match(date_string, &quot;(%d%d?) +(%D-) +(%d%d%d%d) +[%-–] +(%d%d?) +(%D-) +((%d%d%d%d)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end												-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);																		-- for metadata
		month2 = get_month_number (month2);

	elseif mw.ustring.match(date_string, &quot;^%D- +[1-9]%d?, +[1-9]%d%d%d +[%-–] +%D- +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then		-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
		month, day, year, month2, day2, anchor_year, year2=mw.ustring.match(date_string, &quot;(%D-) +(%d%d?), +(%d%d%d%d) +[%-–] +(%D-) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end												-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);																		-- for metadata
		month2 = get_month_number (month2);

	elseif mw.ustring.match(date_string, &quot;^%D- +[1-9]%d%d%d[%-–]%d%d%a?$&quot;) then								-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		local century;
		month, year, century, anchor_year, year2=mw.ustring.match(date_string, &quot;(%D-) +((%d%d)%d%d)[%-–]((%d%d)%a?)&quot;);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;					-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		year2 = century..year2;																-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		month = get_season_number (month);

	elseif mw.ustring.match(date_string, &quot;^%D- +[1-9]%d%d%d[%-–][1-9]%d%d%d%a?$&quot;) then						-- special case Winter/Summer year-year; year separated with unspaced endash
		month, year, anchor_year, year2=mw.ustring.match(date_string, &quot;(%D-) +(%d%d%d%d)[%-–]((%d%d%d%d)%a?)&quot;);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;					-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		month = get_season_number (month);													-- for metadata

	elseif mw.ustring.match(date_string, &quot;^%D- +[1-9]%d%d%d +[%-–] +%D- +[1-9]%d%d%d%a?$&quot;) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2=mw.ustring.match(date_string, &quot;(%D-) +(%d%d%d%d) +[%-–] +(%D-) +((%d%d%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end							-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then 	-- both must be month year, same month style
			month = get_month_number(month);
			month2 = get_month_number(month2);
		elseif 0 ~= get_season_number(month) and 0 ~= get_season_number(month2) then		-- both must be or season year, not mixed
			month = get_season_number(month);
			month2 = get_season_number(month2);
		else
			 return false;
		end

	elseif mw.ustring.match(date_string, &quot;^%D-[%-–]%D- +[1-9]%d%d%d%a?$&quot;) then					-- month/season range year; months separated by endash 
		month, month2, anchor_year, year=mw.ustring.match(date_string, &quot;(%D-)[%-–](%D-)%s*((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or (not is_valid_year(year)) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
			month2 = get_month_number(month2);
		else
			month = get_season_number(month);
			month2 = get_season_number(month2);
		end
		year2=year;
		
	elseif mw.ustring.match(date_string, &quot;^%D- +%d%d%d%d%a?$&quot;) then							-- month/season year or proper-name year
		month, anchor_year, year=mw.ustring.match(date_string, &quot;(%D-)%s*((%d%d%d%d)%a?)&quot;);
		if not is_valid_year(year) then return false; end
		if not is_valid_month_or_season (month) and 0 == is_proper_name (month) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
		elseif 0 ~= get_season_number(month) then
			month = get_season_number(month);
		else
			month = is_proper_name (month);										-- must be proper name; not supported in COinS
		end

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d%d%d?[%-–][1-9]%d%d%d?%a?$&quot;) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2=mw.ustring.match(date_string, &quot;(%d%d%d%d?)[%-–]((%d%d%d%d?)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d%d%d[%-–]%d%d%a?$&quot;) then						-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2=mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]((%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century..year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then							-- year; here accept either YYY or YYYY
		anchor_year, year=date_string:match(&quot;((%d%d%d%d?)%a?)&quot;);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;															-- date format not one of the MOS:DATE approved formats
	end

	if test_accessdate then														-- test accessdate here because we have numerical date parts
		if 0 ~= year and 0 ~= month and 0 ~= day and 							-- all parts of a single date required
			0 == year2 and 0 == month2 and 0 == day2 then						-- none of these; accessdate must not be a range
				if not is_valid_accessdate (year..'-'..month..'-'..day) then	
					return false;												-- return false when accessdate out of bounds
				end
		else
			return false;														-- return false when accessdate is a range of two dates
		end
	end

	local result=true;															-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result=is_valid_date(year,month,day);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month2,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year2,month2,day2);
	end
	
	if false == result then return false; end

	if nil ~= tCOinS_date then													-- this table only passed into this function when testing |date= parameter values
		make_COinS_date ({year=year, month=month, day=day, year2=year2, month2=month2, day2=day2}, tCOinS_date);	-- make an ISO 8601 date string for COinS
	end
	
	return true, anchor_year;													-- format is good and date string represents a real date
end	


--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.

]]

local function dates(date_parameters_list, tCOinS_date)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local embargo_date;															-- if embargo date is a good dmy, mdy, ymd date then holds original value else reset to 9999
	local error_message = &quot;&quot;;
	local good_date = false;
	
	for k, v in pairs(date_parameters_list) do									-- for each date-holding parameter in the list
		if is_set(v.val) then														-- if the parameter has a value
			v.val = mw.ustring.gsub (v.val, '%d', cfg.date_names.local_digits);			-- translate 'local' digits to Western 0-9
			if v.val:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then							-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v.val:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);					-- get the year portion so it can be tested
				if 'date'==k then
					anchor_year, COinS_date = v.val:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year'==k then
					good_date = is_valid_year(year);
				end
			elseif 'date'==k then												-- if the parameter is |date=
				if v.val:match(&quot;^n%.d%.%a?$&quot;) then									-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v.val:match(&quot;^nd%a?$&quot;) then									-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v.val, tCOinS_date);	-- go test the date
				end
			elseif 'year'==k then												-- if the parameter is |year= it should hold only a year value
				if v.val:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then							-- if |year= 3 or 4 digits only with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((%d+)%a?)&quot;);
				end
			elseif 'access-date'==k then										-- if the parameter is |date=
				good_date = check_date (v.val, nil, true);							-- go test the date; nil is a placeholder; true is the test_accessdate flag
			elseif 'embargo'==k then											-- if the parameter is |embargo=
				good_date = check_date (v.val);										-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date, embargo_date = is_valid_embargo_date (v.val);		-- is |embargo= date a single dmy, mdy, or ymd formatted date? yes:returns embargo; no: returns 9999
				end
			else																-- any other date-holding parameter
				good_date = check_date (v.val);										-- go test the date
			end
			if false==good_date then											-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then									-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;						-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. v.name .. &quot;=&quot;;		-- add the failed parameter
			end
		end
	end
	return anchor_year, embargo_date, error_message;											-- and done
end


--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function returns a numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

]]

local function year_date_check (year_string, date_string)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes
	
	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where both date and year are required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard range formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif mw.ustring.match(date_string, &quot;%d%d%d%d[%-–]%d%d&quot;) then								-- YYYY-YY date ranges
		local century;
		date1, century, date2 = mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	else
		result = 0;																-- no recognizable year in date
	end
	return result;
end


--[[-------------------------&lt; R E F O R M A T   T A B L E S &gt;------------------------------------------------

These table are used exclusively for reformatting dates

]]

local source_patterns = {						-- this table holds patterns that match allowed date formats used to extract date components
	['dmy'] = '^(%d%d?)%s+(%a+)%s+(%d%d%d%d)$',
	['mdy'] = '^(%a+)%s+(%d%d?),%s+(%d%d%d%d)$',
	['ymd'] = '^(%d%d%d%d)%-(%d%d)-(%d%d)$',
	}

local short_formats = {							-- this table holds format strings used by os.date() for short month names
	['dmy'] = '%e %b %Y',
	['mdy'] = '%b %e, %Y',
	['ymd'] = '%F',
	}

local long_formats = {							-- this table holds format strings used by os.date() for long month names
	['dmy'] = '%e %B %Y',
	['mdy'] = '%B %e, %Y',
	['ymd'] = '%F',
	}


--[[-------------------------&lt; G E T _ D M Y _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from DMY formatted date, places them in the source_date table, and returns.

]]

local function get_dmy_date_parts (date, source_date)
	source_date.day, source_date.month, source_date.year = date:match (source_patterns['dmy']);	-- get date components as strings
	source_date.month = get_month_number (source_date.month);					-- get month number
end


--[[-------------------------&lt; G E T _ M D Y _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from MDY formatted date, places them in the source_date table, and returns.

]]

local function get_mdy_date_parts (date, source_date)
	source_date.month, source_date.day, source_date.year = date:match (source_patterns['mdy']);	-- get date components as strings
	source_date.month = get_month_number (source_date.month);					-- get month number
end


--[[-------------------------&lt; G E T _ Y M D _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from YMD formatted date, places them in the source_date table, and returns.

]]

local function get_ymd_date_parts (date, source_date)
	source_date.year, source_date.month, source_date.day = date:match (source_patterns['ymd']);	-- get date components as strings
end


--[[-------------------------&lt; R E F O R M A T _ D A T E S &gt;--------------------------------------------------

Reformats existing dates into the format specified by format and short.

format is one of several keywords: dmy, dmy-all, mdy, mdy-all, ymd, ymd-all.  The all version includes access- and
archive-dates; otherwise these dates are not reformatted

Date ranges, season dates, proper name dates are not currently supported.

For i18n:  This code works only at en.wiki because os.date() doesn't support any languages other than English.
mw.getContentLanguage():formatDate() will work at non-English wikis only when the date format is yyyy-mm-dd. This is
the same issue that plagues is_valid_accessdate()

It is possible that a solution like that written for ht:Module:Citation/CS1/Date_validation date_name_xlate() could be applied to this problem

]]

local function reformat_dates (date_parameters_list, format, short)
	local all = false;															-- set to false to skip access- and archive-dates
	local result = false;
	local format_str;
	local source_date = {};
	
	if format:match('%a+%-all') then
		format = format:match('(%a+)%-all');									-- extract the format
		all = true;																-- set to true to format access- and archive-dates
	end
	
	for param_name, param_val in pairs (date_parameters_list) do				-- for each date-holding parameter in the list
		if is_set (param_val.val) then											-- if the parameter has a value
			if not (not all and in_array (param_name, {'access-date', 'archive-date'})) then	-- skip access- or archive-date unless format is xxx-all; yeah, ugly; TODO: find a better way
				for source, pattern in pairs (source_patterns) do
					if param_val.val:match (pattern) then
						if 'ymd' == source then
							get_ymd_date_parts (param_val.val, source_date);	-- get the date parts into the source_date table
						elseif 'dmy' == source then
							get_dmy_date_parts (param_val.val, source_date);	-- get the date parts into the source_date table
						elseif 'mdy' == source then
							get_mdy_date_parts (param_val.val, source_date);	-- get the date parts into the source_date table
						end
	
						if 'ymd' == format and 1582 &gt; tonumber(source_date.year) then	-- ymd format dates not allowed before 1582
							return false;											-- abandon reformatting
						end
						
						if short then
							format_str = short_formats[format];
						else
							format_str = long_formats[format];
						end
																					-- convert date and save;
						date_parameters_list[param_name].val = mw.text.trim (os.date (format_str, os.time(source_date)));	-- strip leading space when single digit day and %e is first format
						result = true;
					end	-- if
				end		-- for
			end			-- if
		end				-- if
	end					-- for
return result;																	-- declare result and done
end


--[[--------------------------&lt; D A T E _ H Y P H E N _ T O _ D A S H &gt;----------------------------------------

Loops through the list of date-holding parameters and converts any hyphen to an ndash.  Not called if the cs1|2
template has any date errors.

Modifies the date_parameters_list and returns true if hyphens are replaced, else returns false.

]]

local function date_hyphen_to_dash (date_parameters_list)
	local result = false;
	local n;
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set (param_val.val) then
			if not mw.ustring.match (param_val.val, '%d%d%d%d%-%d%d%-%d%d') then		-- for those that are not ymd dates (ustring because here digits may not be western)
				param_val.val, n = param_val.val:gsub ('%-', '–');							-- replace any hyphen with ndash
				if 0 ~= n then
					date_parameters_list[param_name].val = param_val.val;					-- update the list
					result = true;
				end
			end
		end
	end
	return result;																-- so we know if any hyphens were replaced
end


--[[-------------------------&lt; D A T E _ N A M E _ X L A T E &gt;------------------------------------------------

Attempts to translate English month names to local-language month names using names supplied by MediaWiki's
date parser function.  This is simple name-for-name replacement and may not work for all languages.

if xlat_dig is true, this function will also translate western (English) digits to the local language's digits.
This will also translate ymd dates.

]]

local function	date_name_xlate (date_parameters_list, xlt_dig)
	local xlate;
	local mode;																	-- long or short month names
	local modified = false;
	local date;
	
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val.val) then											-- if the parameter has a value
			date = param_val.val;
			for month in mw.ustring.gmatch (date, '%a+') do						-- iterate through all dates in the date (single date or date range)
				if cfg.date_names.en.long[month] then
					mode = 'F';													-- English name is long so use long local name
				elseif cfg.date_names.en.short[month] then
					mode = 'M';													-- English name is short so use short local name
				else
					mode = nil;													-- not an English month name; could be local language month name or an English season name
				end
		
				if mode then															-- might be a season
					xlate = mw.getContentLanguage():formatDate(mode, '1' .. month);		-- translate the month name to this local language
					date = mw.ustring.gsub (date, month, xlate);						-- replace the English with the translation
					date_parameters_list[param_name].val = date;						-- save the translated date
					modified = true;
				end
			end

			if xlt_dig then														-- shall we also translate digits?
				date = date:gsub ('%d', cfg.date_names.xlate_digits);			-- translate digits from western to 'local digits'
				date_parameters_list[param_name].val = date;					-- save the translated date
				modified = true;
			end
		end
	end
	
	return modified;
	end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	is_set = utilities_page_ptr.is_set;											-- import functions from selected Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;										-- import functions from selected Module:Citation/CS1/Utilities module
	cfg = cfg_table_ptr;														-- import tables from selected Module:Citation/CS1/Configuration
end



return {																		-- return exported functions
	dates = dates,
	year_date_check = year_date_check,
	reformat_dates = reformat_dates,
	date_hyphen_to_dash = date_hyphen_to_dash,
	date_name_xlate = date_name_xlate,
	set_selected_modules = set_selected_modules
	}</text>
      <sha1>ngd1bggc5lqhfpi21cg38igszbso20w</sha1>
    </revision>
    <revision>
      <id>4840</id>
      <parentid>4839</parentid>
      <timestamp>2019-02-26T11:35:55Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <minor />
      <comment>Changed protection level for &quot;[[Module:Citation/CS1/Date validation]]&quot;: to match the other modules in the suite ([Edit=Require administrator access] (indefinite) [Move=Require administrator access] (indefinite))</comment>
      <origin>4839</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="45637" sha1="ngd1bggc5lqhfpi21cg38igszbso20w" xml:space="preserve">
local p = {}


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array;															-- imported functions from selected Module:Citation/CS1/Utilities
local cfg;																		-- table of tables imported from slected Module:Citation/CS1/Configuration

--[=[-------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |accessdate= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-Engish date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate().  To get around that
call this function with YYYY-MM-DD format dates.

]=]

local function is_valid_accessdate (accessdate)
	local lang = mw.getContentLanguage();
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold unix time stamps representing the dates
		
	good1, access_ts = pcall( lang.formatDate, lang, 'U', accessdate );			-- convert accessdate value to unix timesatmp 
	good2, tomorrow_ts = pcall( lang.formatDate, lang, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which which tonumber() may not understand
		access_ts = tonumber (access_ts) or lang:parseFormattedNumber (access_ts);			-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to unix time stamp
	end

	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end


--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct. If not a valid month, returns 0

]]

local function get_month_number (month)
	return cfg.date_names['local'].long[month] or cfg.date_names['local'].short[month] or		-- look for local names first
			cfg.date_names['en'].long[month] or	cfg.date_names['en'].short[month] or			-- failing that, look for English names
			0;																					-- not a recognized month name
end


--[[--------------------------&lt; I S _ V A L I D _ E M B A R G O _ D A T E &gt;------------------------------------

returns true and date value if that value has proper dmy, mdy, ymd format.

returns false and 9999 (embargoed forever) when date value is not proper format; assumes that when |embargo= is
set, the editor intended to embargo a pmc but |embargo= does not hold a single date.

]]

local function is_valid_embargo_date (v)
	if v:match ('^%d%d%d%d%-%d%d%-%d%d$') or									-- ymd
		v:match ('^%d%d?%s+%a+%s+%d%d%d%d$') or									-- dmy
		v:match ('^%a+%s+%d%d?%s*,%s*%d%d%d%d$') then							-- mdy
			return true, v;
	end
	return false, '9999';														-- if here not good date so return false and set embargo date to long time in future
end


--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 1 for Winter, etc.  Capitalization and spelling must be correct. If not a valid season, returns 0

Uses ISO DIS 8601 2016 part 2 §4.7  Divisions of a year for hemishpere-independent seasons:
	21-24 = Spring, Summer, Autumn, Winter, independent of “Hemisphere”

These additional divisions not currently supported:
	25-28 = Spring - Northern Hemisphere, Summer- Northern Hemisphere, Autumn - Northern Hemisphere, Winter - Northern Hemisphere
	29-32 = Spring – Southern Hemisphere, Summer– Southern Hemisphere, Autumn – Southern Hemisphere, Winter - Southern Hemisphere
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)


]]

local function get_season_number (season)
	return cfg.date_names['local'].season[season] or							-- look for local names first
			cfg.date_names['en'].season[season] or								-- failing that, look for English names
			0;																	-- not a recognized season name
end

--[[--------------------------&lt; I S _ P R O P E R _ N A M E &gt;--------------------------------------------------

returns a non-zero number if date contains a recognized proper name.  Capitalization and spelling must be correct.

]]

local function is_proper_name (name)
	return cfg.date_names['local'].named[name] or								-- look for local names dates first
			cfg.date_names['en'].named[name] or									-- failing that, look for English names
			0;																	-- not a recognized named date
end

--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ O R _ S E A S O N &gt;------------------------------

--returns true if month or season is valid (properly spelled, capitalized, abbreviated)

]]

local function is_valid_month_or_season (month_season)
	if 0 == get_month_number (month_season) then		-- if month text isn't one of the twelve months, might be a season
		if 0 == get_season_number (month_season) then	-- not a month, is it a season?
			return false;								-- return false not a month or one of the five seasons
		end
	end
	return true;
end

--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one year in the future are not acceptable.

]]
local year_limit;
local function is_valid_year(year)
	if not is_set(year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;			-- global variable so we only have to fetch it once
	end
	return tonumber(year) &lt;= year_limit;				-- false if year is in the future more than one year
end

--[[--------------------------&lt; I S _ V A L I D _ D A T E &gt;----------------------------------------------------
Returns true if day is less than or equal to the number of days in month and year is no farther into the future
than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap
years before 1582 and Gregorian leap years after 1582. Where the two calendars overlap (1582 to approximately
1923) dates are assumed to be Gregorian.

]]

local function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year(year) then												-- no farther into the future than next year
		return false;
	end
	
	month = tonumber(month);													-- required for YYYY-MM-DD dates
	
	if (2==month) then															-- if February
		month_length = 28;														-- then 28 days unless
		if 1582 &gt; tonumber(year) then											-- Julian calendar
			if 0==(year%4) then
				month_length = 29;
			end
		else																	-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then			-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end

--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
There is a special test for May because it can be either short or long form.

Returns true when style for both months is the same

]]

local function is_valid_month_range_style (month1, month2)
local len1 = month1:len();
local len2 = month2:len();
	if len1 == len2 then
		return true;															-- both months are short form so return true
	elseif 'May' == month1 or 'May'== month2 then
		return true;															-- both months are long form so return true
	elseif 3 == len1 or 3 == len2 then
		return false;															-- months are mixed form so return false
	else
		return true;															-- both months are long form so return true
	end
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

All season ranges are accepted as valid because there are publishers out there who have published a Summer–Spring YYYY issue so ... ok

]]

local function is_valid_month_season_range(range_start, range_end)
	local range_start_number = get_month_number (range_start);
	local range_end_number;
	
	if 0 == range_start_number then												-- is this a month range?
		range_start_number = get_season_number (range_start);					-- not a month; is it a season? get start season number
		range_end_number = get_season_number (range_end);						-- get end season number

		if (0 ~= range_start_number) and (0 ~= range_end_number) then
			return true;														-- any season pairing is accepted
		end
		return false;															-- range_start and/or range_end is not a season
	end
																				-- here when range_start is a month
	range_end_number = get_month_number (range_end);							-- get end month number
	if range_start_number &lt; range_end_number then								-- range_start is a month; does range_start precede range_end?
		if is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
		end
	end
	return false;																-- range_start month number is greater than or equal to range end number; or range end isn't a month
end


--[[--------------------------&lt; M A K E _ C O I N S _ D A T E &gt;------------------------------------------------

This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1.  The function is called only for |date= parameters and only if the |date=&lt;value&gt; is 
determined to be a valid date format.  The question of what to do with invalid date formats is not answered here.

The date parts in the input table are converted to an ISO 8601 conforming date string:
	single whole dates:		yyyy-mm-dd
	month and year dates:	yyyy-mm
	year dates:				yyyy
	ranges:					yyyy-mm-dd/yyyy-mm-dd
							yyyy-mm/yyyy-mm
							yyyy/yyyy

Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.

The input table has:
	year, year2 – always present; if before 1582, ignore months and days if present
	month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 99 Christmas
	day, day2 –  0 if not provided, 1-31 for days
	
the output table receives:
	rftdate:	an IS8601 formatted date
	rftchron:	a free-form version of the date, usually without year which is in rftdate (season ranges and propername dates)
	rftssn:		one of four season keywords: winter, spring, summer, fall (lowercase)

]]

local function make_COinS_date (input, tCOinS_date)
	local date;																	-- one date or first date in a range
	local date2 = '';															-- end of range date
-- start temporary Julian / Gregorian calendar uncertainty detection
	local year = tonumber(input.year);											-- this temporary code to determine the extent of sources dated to the Julian/Gregorian
	local month = tonumber(input.month);										-- interstice 1 October 1582 – 1 January 1926
	local day = tonumber (input.day);
	if (0 ~= day) and															-- day must have a value for this to be a whole date
		(((1582 == year) and (10 &lt;= month) and (12 &gt;= month)) or				-- any whole 1582 date from 1 october to 31 December or
			((1926 == year) and (1 == month) and (1 == input.day)) or			-- 1 January 1926 or
				((1582 &lt; year) and (1925 &gt;= year))) then						-- any date 1 January 1583 – 31 December 1925
					tCOinS_date.inter_cal_cat = true;							-- set category flag true
	end
-- end temporary Julian / Gergorian calendar uncertainty detection
	
	if 1582 &gt; tonumber(input.year) or 20 &lt; tonumber(input.month) then			-- Julian calendar or season so &amp;rft.date gets year only
		date = input.year;
		if 0 ~= input.year2 and input.year ~= input.year2 then					-- if a range, only the second year portion when not the same as range start year
			date = string.format ('%.4d/%.4d', tonumber(input.year), tonumber(input.year2))		-- assemble the date range
		end
		if 20 &lt; tonumber(input.month) then										-- if season or propername date
			local season = {[24]='winter', [21]='spring', [22]='summer', [23]='fall', [99]='Christmas'};	-- seasons lowercase, no autumn; proper names use title case
			if 0 == input.month2 then											-- single season date
				if 30 &lt;tonumber(input.month) then
					tCOinS_date.rftchron = season[input.month];					-- proper name dates
				else
					tCOinS_date.rftssn = season[input.month];					-- seasons
				end
			else																-- season range with a second season specified
				if input.year ~= input.year2 then								-- season year – season year range or season year–year
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					if 0~= input.month2 then
						tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);
					end
				else															-- season–season year range
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2];	-- season–season year range
				end
			end
		end
		tCOinS_date.rftdate = date;
		return;																	-- done
	end
	
	if 0 ~= input.day then
		date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day));	-- whole date
	elseif 0 ~= input.month then
		date = string.format ('%s-%.2d', input.year, tonumber(input.month));	-- year and month
	else
		date = string.format ('%s', input.year);								-- just year
	end

	if 0 ~= input.year2 then
		if 0 ~= input.day2 then
			date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2));		-- whole date
		elseif 0 ~= input.month2 then
			date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2));	-- year and month
		else
			date2 = string.format ('/%s', input.year2);							-- just year
		end
	end
	
	tCOinS_date.rftdate = date .. date2;										-- date2 has the '/' separator
	return;
end


--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only
allowed range separator is endash.  Additionally, check the date to see that it is a real date: no 31 in 30-day
months; no 29 February when not a leap year.  Months, both long-form and three character abbreviations, and seasons
must be spelled correctly.  Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and
COinS_date.  When this happens, the date parameter is used in the COinS metadata and the CITEREF identifier gets
its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc.)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is ISO 8601 format date; see make_COInS_date()

]]

local function check_date (date_string, tCOinS_date, test_accessdate)
	local year;			-- assume that year2, months, and days are not used;
	local year2=0;		-- second year in a year range
	local month=0;
	local month2=0;		-- second month in a month range
	local day=0;
	local day2=0;		-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match(&quot;^%d%d%d%d%-%d%d%-%d%d$&quot;) then										-- year-initial numerical year month day format
		year, month, day=string.match(date_string, &quot;(%d%d%d%d)%-(%d%d)%-(%d%d)&quot;);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or 0 == tonumber(day) then return false; end	-- month or day number not valid or not Gregorian calendar
		anchor_year = year;
	elseif mw.ustring.match(date_string, &quot;^%D- +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then			-- month-initial: month day, year
		month, day, anchor_year, year=mw.ustring.match(date_string, &quot;(%D-) +(%d%d?),%s*((%d%d%d%d?)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
				
	elseif mw.ustring.match(date_string, &quot;^%D- +[1-9]%d?[%-–][1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then		-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year=mw.ustring.match(date_string, &quot;(%D-) +(%d%d?)[%-–](%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
		month2=month;																		-- for metadata
		year2=year;

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d? +%D- +[1-9]%d%d%d%a?$&quot;) then			-- day-initial: day month year
		day, month, anchor_year, year=mw.ustring.match(date_string, &quot;(%d%d*)%s*(%D-) +((%d%d%d%d?)%a?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months

--[[ NOT supported at en.wiki
	elseif mw.ustring.match(date_string, &quot;^[1-9]%d%d%d%a? +%D- +%d%d?$&quot;) then				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed
		anchor_year, year, month, day=mw.ustring.match(date_string, &quot;((%d%d%d%d?)%a?) +(%D-) +(%d%d?)&quot;);
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
-- end NOT supported at en.wiki ]]

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d?[%-–][1-9]%d? +%D- +[1-9]%d%d%d%a?$&quot;) then		-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year=mw.ustring.match(date_string, &quot;(%d%d?)[%-–](%d%d?) +(%D-) +((%d%d%d%d)%a?)&quot;);
		if tonumber(day) &gt;= tonumber(day2) then return false; end							-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end												-- return false if month text isn't one of the twelve months
		month2=month;																		-- for metadata
		year2=year;

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d? +%D- +[%-–] +[1-9]%d? +%D- +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year=mw.ustring.match(date_string, &quot;(%d%d?) +(%D-) +[%-–] +(%d%d?) +(%D-) +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);													-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif mw.ustring.match(date_string, &quot;^%D- +[1-9]%d? +[%-–] +%D- +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then		-- month initial month-day-range: month day – month day, year;  uses spaced endash
		month, day, month2, day2, anchor_year, year=mw.ustring.match(date_string, &quot;(%D-) +(%d%d?) +[%-–] +(%D-) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);													-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d? +%D- +[1-9]%d%d%d +[%-–] +[1-9]%d? +%D- +[1-9]%d%d%d%a?$&quot;) then		-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2=mw.ustring.match(date_string, &quot;(%d%d?) +(%D-) +(%d%d%d%d) +[%-–] +(%d%d?) +(%D-) +((%d%d%d%d)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end												-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);																		-- for metadata
		month2 = get_month_number (month2);

	elseif mw.ustring.match(date_string, &quot;^%D- +[1-9]%d?, +[1-9]%d%d%d +[%-–] +%D- +[1-9]%d?, +[1-9]%d%d%d%a?$&quot;) then		-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
		month, day, year, month2, day2, anchor_year, year2=mw.ustring.match(date_string, &quot;(%D-) +(%d%d?), +(%d%d%d%d) +[%-–] +(%D-) +(%d%d?), +((%d%d%d%d)%a?)&quot;);
		if tonumber(year2) &lt;= tonumber(year) then return false; end												-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);																		-- for metadata
		month2 = get_month_number (month2);

	elseif mw.ustring.match(date_string, &quot;^%D- +[1-9]%d%d%d[%-–]%d%d%a?$&quot;) then								-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		local century;
		month, year, century, anchor_year, year2=mw.ustring.match(date_string, &quot;(%D-) +((%d%d)%d%d)[%-–]((%d%d)%a?)&quot;);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;					-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		year2 = century..year2;																-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		month = get_season_number (month);

	elseif mw.ustring.match(date_string, &quot;^%D- +[1-9]%d%d%d[%-–][1-9]%d%d%d%a?$&quot;) then						-- special case Winter/Summer year-year; year separated with unspaced endash
		month, year, anchor_year, year2=mw.ustring.match(date_string, &quot;(%D-) +(%d%d%d%d)[%-–]((%d%d%d%d)%a?)&quot;);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;					-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end						-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		month = get_season_number (month);													-- for metadata

	elseif mw.ustring.match(date_string, &quot;^%D- +[1-9]%d%d%d +[%-–] +%D- +[1-9]%d%d%d%a?$&quot;) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2=mw.ustring.match(date_string, &quot;(%D-) +(%d%d%d%d) +[%-–] +(%D-) +((%d%d%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;													-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end							-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end									-- no year farther in the future than next year
		if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then 	-- both must be month year, same month style
			month = get_month_number(month);
			month2 = get_month_number(month2);
		elseif 0 ~= get_season_number(month) and 0 ~= get_season_number(month2) then		-- both must be or season year, not mixed
			month = get_season_number(month);
			month2 = get_season_number(month2);
		else
			 return false;
		end

	elseif mw.ustring.match(date_string, &quot;^%D-[%-–]%D- +[1-9]%d%d%d%a?$&quot;) then					-- month/season range year; months separated by endash 
		month, month2, anchor_year, year=mw.ustring.match(date_string, &quot;(%D-)[%-–](%D-)%s*((%d%d%d%d)%a?)&quot;);
		if (not is_valid_month_season_range(month, month2)) or (not is_valid_year(year)) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
			month2 = get_month_number(month2);
		else
			month = get_season_number(month);
			month2 = get_season_number(month2);
		end
		year2=year;
		
	elseif mw.ustring.match(date_string, &quot;^%D- +%d%d%d%d%a?$&quot;) then							-- month/season year or proper-name year
		month, anchor_year, year=mw.ustring.match(date_string, &quot;(%D-)%s*((%d%d%d%d)%a?)&quot;);
		if not is_valid_year(year) then return false; end
		if not is_valid_month_or_season (month) and 0 == is_proper_name (month) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
		elseif 0 ~= get_season_number(month) then
			month = get_season_number(month);
		else
			month = is_proper_name (month);										-- must be proper name; not supported in COinS
		end

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d%d%d?[%-–][1-9]%d%d%d?%a?$&quot;) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2=mw.ustring.match(date_string, &quot;(%d%d%d%d?)[%-–]((%d%d%d%d?)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, &quot;^[1-9]%d%d%d[%-–]%d%d%a?$&quot;) then						-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2=mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]((%d%d)%a?)&quot;);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century..year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then							-- year; here accept either YYY or YYYY
		anchor_year, year=date_string:match(&quot;((%d%d%d%d?)%a?)&quot;);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;															-- date format not one of the MOS:DATE approved formats
	end

	if test_accessdate then														-- test accessdate here because we have numerical date parts
		if 0 ~= year and 0 ~= month and 0 ~= day and 							-- all parts of a single date required
			0 == year2 and 0 == month2 and 0 == day2 then						-- none of these; accessdate must not be a range
				if not is_valid_accessdate (year..'-'..month..'-'..day) then	
					return false;												-- return false when accessdate out of bounds
				end
		else
			return false;														-- return false when accessdate is a range of two dates
		end
	end

	local result=true;															-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result=is_valid_date(year,month,day);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month2,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year2,month2,day2);
	end
	
	if false == result then return false; end

	if nil ~= tCOinS_date then													-- this table only passed into this function when testing |date= parameter values
		make_COinS_date ({year=year, month=month, day=day, year2=year2, month2=month2, day2=day2}, tCOinS_date);	-- make an ISO 8601 date string for COinS
	end
	
	return true, anchor_year;													-- format is good and date string represents a real date
end	


--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.

]]

local function dates(date_parameters_list, tCOinS_date)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local embargo_date;															-- if embargo date is a good dmy, mdy, ymd date then holds original value else reset to 9999
	local error_message = &quot;&quot;;
	local good_date = false;
	
	for k, v in pairs(date_parameters_list) do									-- for each date-holding parameter in the list
		if is_set(v.val) then														-- if the parameter has a value
			v.val = mw.ustring.gsub (v.val, '%d', cfg.date_names.local_digits);			-- translate 'local' digits to Western 0-9
			if v.val:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then							-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v.val:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);					-- get the year portion so it can be tested
				if 'date'==k then
					anchor_year, COinS_date = v.val:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year'==k then
					good_date = is_valid_year(year);
				end
			elseif 'date'==k then												-- if the parameter is |date=
				if v.val:match(&quot;^n%.d%.%a?$&quot;) then									-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v.val:match(&quot;^nd%a?$&quot;) then									-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v.val, tCOinS_date);	-- go test the date
				end
			elseif 'year'==k then												-- if the parameter is |year= it should hold only a year value
				if v.val:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then							-- if |year= 3 or 4 digits only with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((%d+)%a?)&quot;);
				end
			elseif 'access-date'==k then										-- if the parameter is |date=
				good_date = check_date (v.val, nil, true);							-- go test the date; nil is a placeholder; true is the test_accessdate flag
			elseif 'embargo'==k then											-- if the parameter is |embargo=
				good_date = check_date (v.val);										-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date, embargo_date = is_valid_embargo_date (v.val);		-- is |embargo= date a single dmy, mdy, or ymd formatted date? yes:returns embargo; no: returns 9999
				end
			else																-- any other date-holding parameter
				good_date = check_date (v.val);										-- go test the date
			end
			if false==good_date then											-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then									-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;						-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. v.name .. &quot;=&quot;;		-- add the failed parameter
			end
		end
	end
	return anchor_year, embargo_date, error_message;											-- and done
end


--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function returns a numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

]]

local function year_date_check (year_string, date_string)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes
	
	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where both date and year are required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard range formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif mw.ustring.match(date_string, &quot;%d%d%d%d[%-–]%d%d&quot;) then								-- YYYY-YY date ranges
		local century;
		date1, century, date2 = mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	else
		result = 0;																-- no recognizable year in date
	end
	return result;
end


--[[-------------------------&lt; R E F O R M A T   T A B L E S &gt;------------------------------------------------

These table are used exclusively for reformatting dates

]]

local source_patterns = {						-- this table holds patterns that match allowed date formats used to extract date components
	['dmy'] = '^(%d%d?)%s+(%a+)%s+(%d%d%d%d)$',
	['mdy'] = '^(%a+)%s+(%d%d?),%s+(%d%d%d%d)$',
	['ymd'] = '^(%d%d%d%d)%-(%d%d)-(%d%d)$',
	}

local short_formats = {							-- this table holds format strings used by os.date() for short month names
	['dmy'] = '%e %b %Y',
	['mdy'] = '%b %e, %Y',
	['ymd'] = '%F',
	}

local long_formats = {							-- this table holds format strings used by os.date() for long month names
	['dmy'] = '%e %B %Y',
	['mdy'] = '%B %e, %Y',
	['ymd'] = '%F',
	}


--[[-------------------------&lt; G E T _ D M Y _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from DMY formatted date, places them in the source_date table, and returns.

]]

local function get_dmy_date_parts (date, source_date)
	source_date.day, source_date.month, source_date.year = date:match (source_patterns['dmy']);	-- get date components as strings
	source_date.month = get_month_number (source_date.month);					-- get month number
end


--[[-------------------------&lt; G E T _ M D Y _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from MDY formatted date, places them in the source_date table, and returns.

]]

local function get_mdy_date_parts (date, source_date)
	source_date.month, source_date.day, source_date.year = date:match (source_patterns['mdy']);	-- get date components as strings
	source_date.month = get_month_number (source_date.month);					-- get month number
end


--[[-------------------------&lt; G E T _ Y M D _ D A T E _ P A R T S &gt;------------------------------------------

extracts year, month and day from YMD formatted date, places them in the source_date table, and returns.

]]

local function get_ymd_date_parts (date, source_date)
	source_date.year, source_date.month, source_date.day = date:match (source_patterns['ymd']);	-- get date components as strings
end


--[[-------------------------&lt; R E F O R M A T _ D A T E S &gt;--------------------------------------------------

Reformats existing dates into the format specified by format and short.

format is one of several keywords: dmy, dmy-all, mdy, mdy-all, ymd, ymd-all.  The all version includes access- and
archive-dates; otherwise these dates are not reformatted

Date ranges, season dates, proper name dates are not currently supported.

For i18n:  This code works only at en.wiki because os.date() doesn't support any languages other than English.
mw.getContentLanguage():formatDate() will work at non-English wikis only when the date format is yyyy-mm-dd. This is
the same issue that plagues is_valid_accessdate()

It is possible that a solution like that written for ht:Module:Citation/CS1/Date_validation date_name_xlate() could be applied to this problem

]]

local function reformat_dates (date_parameters_list, format, short)
	local all = false;															-- set to false to skip access- and archive-dates
	local result = false;
	local format_str;
	local source_date = {};
	
	if format:match('%a+%-all') then
		format = format:match('(%a+)%-all');									-- extract the format
		all = true;																-- set to true to format access- and archive-dates
	end
	
	for param_name, param_val in pairs (date_parameters_list) do				-- for each date-holding parameter in the list
		if is_set (param_val.val) then											-- if the parameter has a value
			if not (not all and in_array (param_name, {'access-date', 'archive-date'})) then	-- skip access- or archive-date unless format is xxx-all; yeah, ugly; TODO: find a better way
				for source, pattern in pairs (source_patterns) do
					if param_val.val:match (pattern) then
						if 'ymd' == source then
							get_ymd_date_parts (param_val.val, source_date);	-- get the date parts into the source_date table
						elseif 'dmy' == source then
							get_dmy_date_parts (param_val.val, source_date);	-- get the date parts into the source_date table
						elseif 'mdy' == source then
							get_mdy_date_parts (param_val.val, source_date);	-- get the date parts into the source_date table
						end
	
						if 'ymd' == format and 1582 &gt; tonumber(source_date.year) then	-- ymd format dates not allowed before 1582
							return false;											-- abandon reformatting
						end
						
						if short then
							format_str = short_formats[format];
						else
							format_str = long_formats[format];
						end
																					-- convert date and save;
						date_parameters_list[param_name].val = mw.text.trim (os.date (format_str, os.time(source_date)));	-- strip leading space when single digit day and %e is first format
						result = true;
					end	-- if
				end		-- for
			end			-- if
		end				-- if
	end					-- for
return result;																	-- declare result and done
end


--[[--------------------------&lt; D A T E _ H Y P H E N _ T O _ D A S H &gt;----------------------------------------

Loops through the list of date-holding parameters and converts any hyphen to an ndash.  Not called if the cs1|2
template has any date errors.

Modifies the date_parameters_list and returns true if hyphens are replaced, else returns false.

]]

local function date_hyphen_to_dash (date_parameters_list)
	local result = false;
	local n;
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set (param_val.val) then
			if not mw.ustring.match (param_val.val, '%d%d%d%d%-%d%d%-%d%d') then		-- for those that are not ymd dates (ustring because here digits may not be western)
				param_val.val, n = param_val.val:gsub ('%-', '–');							-- replace any hyphen with ndash
				if 0 ~= n then
					date_parameters_list[param_name].val = param_val.val;					-- update the list
					result = true;
				end
			end
		end
	end
	return result;																-- so we know if any hyphens were replaced
end


--[[-------------------------&lt; D A T E _ N A M E _ X L A T E &gt;------------------------------------------------

Attempts to translate English month names to local-language month names using names supplied by MediaWiki's
date parser function.  This is simple name-for-name replacement and may not work for all languages.

if xlat_dig is true, this function will also translate western (English) digits to the local language's digits.
This will also translate ymd dates.

]]

local function	date_name_xlate (date_parameters_list, xlt_dig)
	local xlate;
	local mode;																	-- long or short month names
	local modified = false;
	local date;
	
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val.val) then											-- if the parameter has a value
			date = param_val.val;
			for month in mw.ustring.gmatch (date, '%a+') do						-- iterate through all dates in the date (single date or date range)
				if cfg.date_names.en.long[month] then
					mode = 'F';													-- English name is long so use long local name
				elseif cfg.date_names.en.short[month] then
					mode = 'M';													-- English name is short so use short local name
				else
					mode = nil;													-- not an English month name; could be local language month name or an English season name
				end
		
				if mode then															-- might be a season
					xlate = mw.getContentLanguage():formatDate(mode, '1' .. month);		-- translate the month name to this local language
					date = mw.ustring.gsub (date, month, xlate);						-- replace the English with the translation
					date_parameters_list[param_name].val = date;						-- save the translated date
					modified = true;
				end
			end

			if xlt_dig then														-- shall we also translate digits?
				date = date:gsub ('%d', cfg.date_names.xlate_digits);			-- translate digits from western to 'local digits'
				date_parameters_list[param_name].val = date;					-- save the translated date
				modified = true;
			end
		end
	end
	
	return modified;
	end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	is_set = utilities_page_ptr.is_set;											-- import functions from selected Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;										-- import functions from selected Module:Citation/CS1/Utilities module
	cfg = cfg_table_ptr;														-- import tables from selected Module:Citation/CS1/Configuration
end



return {																		-- return exported functions
	dates = dates,
	year_date_check = year_date_check,
	reformat_dates = reformat_dates,
	date_hyphen_to_dash = date_hyphen_to_dash,
	date_name_xlate = date_name_xlate,
	set_selected_modules = set_selected_modules
	}</text>
      <sha1>ngd1bggc5lqhfpi21cg38igszbso20w</sha1>
    </revision>
    <revision>
      <id>4841</id>
      <parentid>4840</parentid>
      <timestamp>2019-04-20T13:20:15Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4841</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="57214" sha1="fj39mnocj5l5fby83xsxd3jbo411pcd" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array;															-- imported functions from selected Module:Citation/CS1/Utilities
local cfg;																		-- table of tables imported from selected Module:Citation/CS1/Configuration


--[=[-------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |accessdate= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-Engish date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate().  To get around that
call this function with YYYY-MM-DD format dates.

]=]

local function is_valid_accessdate (accessdate)
	local lang = mw.getContentLanguage();
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold unix time stamps representing the dates
		
	good1, access_ts = pcall( lang.formatDate, lang, 'U', accessdate );			-- convert accessdate value to unix timesatmp 
	good2, tomorrow_ts = pcall( lang.formatDate, lang, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which which tonumber() may not understand
		access_ts = tonumber (access_ts) or lang:parseFormattedNumber (access_ts);			-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to unix time stamp
	end

	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end


--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct. If not a valid month, returns 0

]]

local function get_month_number (month)
	return cfg.date_names['local'].long[month] or cfg.date_names['local'].short[month] or		-- look for local names first
			cfg.date_names['en'].long[month] or	cfg.date_names['en'].short[month] or			-- failing that, look for English names
			0;																					-- not a recognized month name
end


--[[--------------------------&lt; I S _ V A L I D _ E M B A R G O _ D A T E &gt;------------------------------------

returns true and date value if that value has proper dmy, mdy, ymd format.

returns false and 9999 (embargoed forever) when date value is not proper format; assumes that when |embargo= is
set, the editor intended to embargo a pmc but |embargo= does not hold a single date.

]]

local function is_valid_embargo_date (v)
	if v:match ('^%d%d%d%d%-%d%d%-%d%d$') or									-- ymd
		v:match ('^%d%d?%s+%a+%s+%d%d%d%d$') or									-- dmy
		v:match ('^%a+%s+%d%d?%s*,%s*%d%d%d%d$') then							-- mdy
			return true, v;
	end
	return false, '9999';														-- if here not good date so return false and set embargo date to long time in future
end


--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 1 for Winter, etc.  Capitalization and spelling must be correct. If not a valid season, returns 0

Uses ISO DIS 8601 2016 part 2 §4.7  Divisions of a year for hemishpere-independent seasons:
	21-24 = Spring, Summer, Autumn, Winter, independent of “Hemisphere”

These additional divisions not currently supported:
	25-28 = Spring - Northern Hemisphere, Summer- Northern Hemisphere, Autumn - Northern Hemisphere, Winter - Northern Hemisphere
	29-32 = Spring – Southern Hemisphere, Summer– Southern Hemisphere, Autumn – Southern Hemisphere, Winter - Southern Hemisphere
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)

]]

local function get_season_number (season)
	return cfg.date_names['local'].season[season] or							-- look for local names first
			cfg.date_names['en'].season[season] or								-- failing that, look for English names
			0;																	-- not a recognized season name
end


--[[--------------------------&lt; I S _ P R O P E R _ N A M E &gt;--------------------------------------------------

returns a non-zero number if date contains a recognized proper name.  Capitalization and spelling must be correct.

]]

local function is_proper_name (name)
	return cfg.date_names['local'].named[name] or								-- look for local names dates first
			cfg.date_names['en'].named[name] or									-- failing that, look for English names
			0;																	-- not a recognized named date
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ O R _ S E A S O N &gt;------------------------------

--returns true if month or season is valid (properly spelled, capitalized, abbreviated)

]]

local function is_valid_month_or_season (month_season)
	if 0 == get_month_number (month_season) then								-- if month text isn't one of the twelve months, might be a season
		if 0 == get_season_number (month_season) then							-- not a month, is it a season?
			return false;														-- return false not a month or one of the five seasons
		end
	end
	return true;
end


--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one year in the future are not acceptable.

]]
local year_limit;
local function is_valid_year(year)
	if not is_set(year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;									-- global variable so we only have to fetch it once
	end
	return tonumber(year) &lt;= year_limit;										-- false if year is in the future more than one year
end


--[[--------------------------&lt; I S _ V A L I D _ D A T E &gt;----------------------------------------------------
Returns true if day is less than or equal to the number of days in month and year is no farther into the future
than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap
years before 1582 and Gregorian leap years after 1582. Where the two calendars overlap (1582 to approximately
1923) dates are assumed to be Gregorian.

]]

local function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year(year) then												-- no farther into the future than next year
		return false;
	end
	
	month = tonumber(month);													-- required for YYYY-MM-DD dates
	
	if (2==month) then															-- if February
		month_length = 28;														-- then 28 days unless
		if 1582 &gt; tonumber(year) then											-- Julian calendar
			if 0==(year%4) then													-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		else																	-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then			-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
There is a special test for May because it can be either short or long form.

Returns true when style for both months is the same

]]

local function is_valid_month_range_style (month1, month2)
local len1 = month1:len();
local len2 = month2:len();
	if len1 == len2 then
		return true;															-- both months are short form so return true
	elseif 'May' == month1 or 'May'== month2 then
		return true;															-- both months are long form so return true
	elseif 3 == len1 or 3 == len2 then
		return false;															-- months are mixed form so return false
	else
		return true;															-- both months are long form so return true
	end
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

All season ranges are accepted as valid because there are publishers out there who have published a Summer–Spring YYYY issue so ... ok

]]

local function is_valid_month_season_range(range_start, range_end)
	local range_start_number = get_month_number (range_start);
	local range_end_number;
	
	if 0 == range_start_number then												-- is this a month range?
		range_start_number = get_season_number (range_start);					-- not a month; is it a season? get start season number
		range_end_number = get_season_number (range_end);						-- get end season number

		if (0 ~= range_start_number) and (0 ~= range_end_number) then
			return true;														-- any season pairing is accepted
		end
		return false;															-- range_start and/or range_end is not a season
	end
																				-- here when range_start is a month
	range_end_number = get_month_number (range_end);							-- get end month number
	if range_start_number &lt; range_end_number then								-- range_start is a month; does range_start precede range_end?
		if is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
		end
	end
	return false;																-- range_start month number is greater than or equal to range end number; or range end isn't a month
end


--[[--------------------------&lt; M A K E _ C O I N S _ D A T E &gt;------------------------------------------------

This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1.  The function is called only for |date= parameters and only if the |date=&lt;value&gt; is 
determined to be a valid date format.  The question of what to do with invalid date formats is not answered here.

The date parts in the input table are converted to an ISO 8601 conforming date string:
	single whole dates:		yyyy-mm-dd
	month and year dates:	yyyy-mm
	year dates:				yyyy
	ranges:					yyyy-mm-dd/yyyy-mm-dd
							yyyy-mm/yyyy-mm
							yyyy/yyyy

Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.

The input table has:
	year, year2 – always present; if before 1582, ignore months and days if present
	month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 99 Christmas
	day, day2 –  0 if not provided, 1-31 for days
	
the output table receives:
	rftdate:	an IS8601 formatted date
	rftchron:	a free-form version of the date, usually without year which is in rftdate (season ranges and propername dates)
	rftssn:		one of four season keywords: winter, spring, summer, fall (lowercase)

]]

local function make_COinS_date (input, tCOinS_date)
	local date;																	-- one date or first date in a range
	local date2 = '';															-- end of range date
-- start temporary Julian / Gregorian calendar uncertainty detection
	local year = tonumber(input.year);											-- this temporary code to determine the extent of sources dated to the Julian/Gregorian
	local month = tonumber(input.month);										-- interstice 1 October 1582 – 1 January 1926
	local day = tonumber (input.day);
	if (0 ~= day) and															-- day must have a value for this to be a whole date
		(((1582 == year) and (10 &lt;= month) and (12 &gt;= month)) or				-- any whole 1582 date from 1 october to 31 December or
			((1926 == year) and (1 == month) and (1 == input.day)) or			-- 1 January 1926 or
				((1582 &lt; year) and (1925 &gt;= year))) then						-- any date 1 January 1583 – 31 December 1925
					tCOinS_date.inter_cal_cat = true;							-- set category flag true
	end
-- end temporary Julian / Gergorian calendar uncertainty detection
	
	if 1582 &gt; tonumber(input.year) or 20 &lt; tonumber(input.month) then			-- Julian calendar or season so &amp;rft.date gets year only
		date = input.year;
		if 0 ~= input.year2 and input.year ~= input.year2 then					-- if a range, only the second year portion when not the same as range start year
			date = string.format ('%.4d/%.4d', tonumber(input.year), tonumber(input.year2))		-- assemble the date range
		end
		if 20 &lt; tonumber(input.month) then										-- if season or propername date
			local season = {[24]='winter', [21]='spring', [22]='summer', [23]='fall', [99]='Christmas'};	-- seasons lowercase, no autumn; proper names use title case
			if 0 == input.month2 then											-- single season date
				if 30 &lt;tonumber(input.month) then
					tCOinS_date.rftchron = season[input.month];					-- proper name dates
				else
					tCOinS_date.rftssn = season[input.month];					-- seasons
				end
			else																-- season range with a second season specified
				if input.year ~= input.year2 then								-- season year – season year range or season year–year
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					if 0~= input.month2 then
						tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);
					end
				else															-- season–season year range
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2];	-- season–season year range
				end
			end
		end
		tCOinS_date.rftdate = date;
		return;																	-- done
	end
	
	if 0 ~= input.day then
		date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day));	-- whole date
	elseif 0 ~= input.month then
		date = string.format ('%s-%.2d', input.year, tonumber(input.month));	-- year and month
	else
		date = string.format ('%s', input.year);								-- just year
	end

	if 0 ~= input.year2 then
		if 0 ~= input.day2 then
			date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2));		-- whole date
		elseif 0 ~= input.month2 then
			date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2));	-- year and month
		else
			date2 = string.format ('/%s', input.year2);							-- just year
		end
	end
	
	tCOinS_date.rftdate = date .. date2;										-- date2 has the '/' separator
	return;
end


--[[--------------------------&lt; P A T T E R N S &gt;--------------------------------------------------------------

this is the list of patterns for date formats that this module recognizes.  Approximately the first half of these
patterns represent formats that might be reformatted into another format.  Those that might be reformatted have
'indicator' letters that identify the content of the matching capture: 'd' (day), 'm' (month), 'a' (anchor year),
'y' (year); second day, month, year have a '2' suffix.

These patterns are used for both date validation and for reformatting.  This table should not be moved to ~/Configuration
because changes to this table require changes to check_date() and to reformatter() and reformat_date()

]]

local patterns = {
	 																			-- year-initial numerical year-month-day
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'},					
																				-- month-initial: month day, year
	['Mdy'] = {'^(%D-) +([1-9]%d?), +((%d%d%d%d?)%a?)$', 'm', 'd', 'a', 'y'},
																				-- month-initial day range: month day–day, year; days are separated by endash
	['Md-dy'] = {'^(%D-) +([1-9]%d?)[%-–]([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'd2', 'a', 'y'},
																				-- day-initial: day month year
	['dMy'] = {'^([1-9]%d?) *(%D-) +((%d%d%d%d?)%a?)$', 'd', 'm', 'a', 'y'},
																				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed; not supported at en.wiki
--	['yMd'] = {'^((%d%d%d%d?)%a?) +(%D-) +(%d%d?)$', 'a', 'y', 'm', 'd'},
																				-- day-range-initial: day–day month year; days are separated by endash
	['d-dMy'] = {'^([1-9]%d?)[%-–]([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'd2', 'm', 'a', 'y'},
																				-- day initial month-day-range: day month - day month year; uses spaced endash
	['dM-dMy'] = {'^([1-9]%d?) +(%D-) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'd2', 'm2', 'a', 'y'},
																				-- month initial month-day-range: month day – month day, year;  uses spaced endash
	['Md-Mdy'] = {'^(%D-) +([1-9]%d?) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$','m', 'd', 'm2', 'd2', 'a', 'y'},
																				-- day initial month-day-year-range: day month year - day month year; uses spaced endash
	['dMy-dMy'] = {'^([1-9]%d?) +(%D-) +(%d%d%d%d) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'y', 'd2', 'm2', 'a', 'y2'},
																				-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
	['Mdy-Mdy'] = {'^(%D-) +([1-9]%d?), +(%d%d%d%d) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'y', 'm2', 'd2', 'a', 'y2'},

																				-- these date formats cannot be converted, per se, but month name can be rendered short or long
																				-- month/season year - month/season year; separated by spaced endash
	['My-My'] = {'^(%D-) +(%d%d%d%d) +[%-–] +(%D-) +((%d%d%d%d)%a?)$', 'm', 'y', 'm2', 'a', 'y2'},
																				-- month/season range year; months separated by endash
	['M-My'] = {'^(%D-)[%-–](%D-) +((%d%d%d%d)%a?)$', 'm', 'm2', 'a', 'y'},
																				-- month/season year or proper-name year
	['My'] = {'^([^%d–]-) +((%d%d%d%d)%a?)$', 'm', 'a', 'y'},					-- this way because endash is a member of %D; %D- will match January–March 2019 when it shouldn't
																				-- these date formats cannot be converted
	['Sy4-y2'] = {'^(%D-) +((%d%d)%d%d)[%-–]((%d%d)%a?)$'},						-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
	['Sy-y'] = {'^(%D-) +(%d%d%d%d)[%-–]((%d%d%d%d)%a?)$'},						-- special case Winter/Summer year-year; year separated with unspaced endash
	['y-y'] = {'^(%d%d%d%d?)[%-–]((%d%d%d%d?)%a?)$'},							-- year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
	['y4-y2'] = {'^((%d%d)%d%d)[%-–]((%d%d)%a?)$'},								-- year range: YYYY–YY; separated by unspaced endash
	['y'] = {'^((%d%d%d%d?)%a?)$'},												-- year; here accept either YYY or YYYY
	}


--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only
allowed range separator is endash.  Additionally, check the date to see that it is a real date: no 31 in 30-day
months; no 29 February when not a leap year.  Months, both long-form and three character abbreviations, and seasons
must be spelled correctly.  Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and
COinS_date.  When this happens, the date parameter is used in the COinS metadata and the CITEREF identifier gets
its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc.)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is ISO 8601 format date; see make_COInS_date()

]]

local function check_date (date_string, tCOinS_date, test_accessdate)
	local year;			-- assume that year2, months, and days are not used;
	local year2=0;		-- second year in a year range
	local month=0;
	local month2=0;		-- second month in a month range
	local day=0;
	local day2=0;		-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match (patterns['ymd'][1]) then								-- year-initial numerical year month day format
		year, month, day=date_string:match (patterns['ymd'][1]);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or 0 == tonumber(day) then return false; end	-- month or day number not valid or not Gregorian calendar
		anchor_year = year;
	
	elseif mw.ustring.match(date_string, patterns['Mdy'][1]) then				-- month-initial: month day, year
		month, day, anchor_year, year=mw.ustring.match(date_string, patterns['Mdy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
				
	elseif mw.ustring.match(date_string, patterns['Md-dy'][1]) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year=mw.ustring.match(date_string, patterns['Md-dy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2=month;															-- for metadata
		year2=year;

	elseif mw.ustring.match(date_string, patterns['dMy'][1]) then				-- day-initial: day month year
		day, month, anchor_year, year=mw.ustring.match(date_string, patterns['dMy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months

--[[ NOT supported at en.wiki
	elseif mw.ustring.match(date_string, patterns['yMd'][1]) then				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed
		anchor_year, year, month, day=mw.ustring.match(date_string, patterns['yMd'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
-- end NOT supported at en.wiki ]]

	elseif mw.ustring.match(date_string, patterns['d-dMy'][1]) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year=mw.ustring.match(date_string, patterns['d-dMy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2=month;															-- for metadata
		year2=year;

	elseif mw.ustring.match(date_string, patterns['dM-dMy'][1]) then			-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year=mw.ustring.match(date_string, patterns['dM-dMy'][1]);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif mw.ustring.match(date_string, patterns['Md-Mdy'][1]) then			-- month initial month-day-range: month day – month day, year;  uses spaced endash
		month, day, month2, day2, anchor_year, year=mw.ustring.match(date_string, patterns['Md-Mdy'][1]);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif mw.ustring.match(date_string, patterns['dMy-dMy'][1]) then			-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2=mw.ustring.match(date_string, patterns['dMy-dMy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);

	elseif mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]) then			-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
		month, day, year, month2, day2, anchor_year, year2=mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);

	elseif mw.ustring.match(date_string, patterns['Sy4-y2'][1]) then			-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		local century;
		month, year, century, anchor_year, year2=mw.ustring.match(date_string, patterns['Sy4-y2'][1]);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;		-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;										-- assemble anchor_year from both years
		year2 = century..year2;													-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		month = get_season_number (month);

	elseif mw.ustring.match(date_string, patterns['Sy-y'][1]) then				-- special case Winter/Summer year-year; year separated with unspaced endash
		month, year, anchor_year, year2=mw.ustring.match(date_string, patterns['Sy-y'][1]);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;		-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;										-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		month = get_season_number (month);										-- for metadata

	elseif mw.ustring.match(date_string, patterns['My-My'][1]) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2=mw.ustring.match(date_string, patterns['My-My'][1]);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then 	-- both must be month year, same month style
			month = get_month_number(month);
			month2 = get_month_number(month2);
		elseif 0 ~= get_season_number(month) and 0 ~= get_season_number(month2) then	-- both must be or season year, not mixed
			month = get_season_number(month);
			month2 = get_season_number(month2);
		else
			 return false;
		end

	elseif mw.ustring.match(date_string, patterns['M-My'][1]) then				-- month/season range year; months separated by endash 
		month, month2, anchor_year, year=mw.ustring.match(date_string, patterns['M-My'][1]);
		if (not is_valid_month_season_range(month, month2)) or (not is_valid_year(year)) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
			month2 = get_month_number(month2);
		else
			month = get_season_number(month);
			month2 = get_season_number(month2);
		end
		year2=year;
		
	elseif mw.ustring.match(date_string, patterns['My'][1]) then				-- month/season year or proper-name year
		month, anchor_year, year=mw.ustring.match(date_string, patterns['My'][1]);
		if not is_valid_year(year) then return false; end
		if not is_valid_month_or_season (month) and 0 == is_proper_name (month) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
		elseif 0 ~= get_season_number(month) then
			month = get_season_number(month);
		else
			month = is_proper_name (month);										-- must be proper name; not supported in COinS
		end

	elseif mw.ustring.match(date_string, patterns['y-y'][1]) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2=mw.ustring.match(date_string, patterns['y-y'][1]);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, patterns['y4-y2'][1]) then				-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2=mw.ustring.match(date_string, patterns['y4-y2'][1]);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century..year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match (patterns['y'][1]) then							-- year; here accept either YYY or YYYY
		anchor_year, year=date_string:match (patterns['y'][1]);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;															-- date format not one of the MOS:DATE approved formats
	end

	if test_accessdate then														-- test accessdate here because we have numerical date parts
		if 0 ~= year and 0 ~= month and 0 ~= day and 							-- all parts of a single date required
			0 == year2 and 0 == month2 and 0 == day2 then						-- none of these; accessdate must not be a range
				if not is_valid_accessdate (year..'-'..month..'-'..day) then	
					return false;												-- return false when accessdate out of bounds
				end
		else
			return false;														-- return false when accessdate is a range of two dates
		end
	end

	local result=true;															-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result=is_valid_date(year,month,day);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month2,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year2,month2,day2);
	end
	
	if false == result then return false; end

	if nil ~= tCOinS_date then													-- this table only passed into this function when testing |date= parameter values
		make_COinS_date ({year=year, month=month, day=day, year2=year2, month2=month2, day2=day2}, tCOinS_date);	-- make an ISO 8601 date string for COinS
	end
	
	return true, anchor_year;													-- format is good and date string represents a real date
end	


--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.

]]

local function dates(date_parameters_list, tCOinS_date)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local embargo_date;															-- if embargo date is a good dmy, mdy, ymd date then holds original value else reset to 9999
	local error_message = &quot;&quot;;
	local good_date = false;
	
	for k, v in pairs(date_parameters_list) do									-- for each date-holding parameter in the list
		if is_set(v.val) then													-- if the parameter has a value
			v.val = mw.ustring.gsub (v.val, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9
			if v.val:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then						-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v.val:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);				-- get the year portion so it can be tested
				if 'date'==k then
					anchor_year, COinS_date = v.val:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year'==k then
					good_date = is_valid_year(year);
				end
			elseif 'date'==k then												-- if the parameter is |date=
				if v.val:match(&quot;^n%.d%.%a?$&quot;) then								-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v.val:match(&quot;^nd%a?$&quot;) then								-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v.val, tCOinS_date);	-- go test the date
				end
			elseif 'year'==k then												-- if the parameter is |year= it should hold only a year value
				if v.val:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then						-- if |year= 3 or 4 digits only with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((%d+)%a?)&quot;);
				end
			elseif 'access-date'==k then										-- if the parameter is |date=
				good_date = check_date (v.val, nil, true);						-- go test the date; nil is a placeholder; true is the test_accessdate flag
			elseif 'embargo'==k then											-- if the parameter is |embargo=
				good_date = check_date (v.val);									-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date, embargo_date = is_valid_embargo_date (v.val);	-- is |embargo= date a single dmy, mdy, or ymd formatted date? yes:returns embargo; no: returns 9999
				end
			else																-- any other date-holding parameter
				good_date = check_date (v.val);									-- go test the date
			end
			if false==good_date then											-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then									-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;						-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. v.name .. &quot;=&quot;;		-- add the failed parameter
			end
		end
	end
	return anchor_year, embargo_date, error_message;							-- and done
end


--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function returns a numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

]]

local function year_date_check (year_string, date_string)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes
	
	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where both date and year are required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard range formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif mw.ustring.match(date_string, &quot;%d%d%d%d[%-–]%d%d&quot;) then				-- YYYY-YY date ranges
		local century;
		date1, century, date2 = mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	else
		result = 0;																-- no recognizable year in date
	end
	return result;
end


--[[--------------------------&lt; R E F O R M A T T E R &gt;--------------------------------------------------------

reformat 'date' into new format specified by format_param if pattern_idx (the current format of 'date') can be
reformatted.  Does the grunt work for reformat_dates().

The table re_formats maps patern_idx (current format) and format_param (desired format) to a table that holds:
	format string used by string.format()
	identifier letters ('d', 'm', 'y', 'd2', 'm2', 'y2') that serve as indexes into a table t{} that holds captures
		from mw.ustring.match() for the various date parts specified by  patterns[pattern_idx][1]

Items in patterns{} have the general form:
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'}, where:
		['ymd'] is pattern_idx
		patterns['ymd'][1] is the match pattern with captures for mw.ustring.match()
		patterns['ymd'][2] is an indicator letter identifying the content of the first capture
		patterns['ymd'][3] ... the second capture etc

when a pattern matches a date, the captures are loaded into table t{} in capture order using the idemtifier
characters as indexes into t{}  For the above, a ymd date is in t{} as:
	t.y = first capture (year), t.m = second capture (month), t.d = third capture (day)

To reformat, this function is called with the pattern_idx that matches the current format of the date and with
format_param set to the desired format.  This function loads table t{} as described and then calls string.format()
with the format string specified by re_format[pattern_idx][format_param][1] using values taken from t{} according
to the capture identifier letters specified by patterns[pattern_idx][format_param][n] where n is 2..

]]

local re_formats = {
	['ymd'] = {																	-- date format is ymd; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},									-- |df=yMd; not supported at en.wiki
		},
	['Mdy'] = {																	-- date format is Mdy; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- for long/short reformatting
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},									-- |df=yMd; not supported at en.wiki
		},
	['dMy'] = {																	-- date format is dMy; reformat to:
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- for long/short reformatting
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},									-- |df=yMd; not supported at en.wiki
		},
	['Md-dy'] = {																-- date format is Md-dy; reformat to:
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- for long/short reformatting
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- |df=dmy -&gt; d-dMy 
		},
	['d-dMy'] = {																-- date format is d-d&gt;y; reformat to:
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- for long/short reformatting
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- |df=mdy -&gt; Md-dy 
		},
	['dM-dMy'] = {																-- date format is dM-dMy; reformat to:
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- for long/short reformatting
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd', 'm2', 'd2', 'y'},				-- |df=mdy -&gt; Md-Mdy 
		},
	['Md-Mdy'] = {																-- date format is Md-Mdy; reformat to:
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd',  'm2', 'd2', 'y'},			-- for long/short reformatting
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- |df=dmy -&gt; dM-dMy 
		},
	['dMy-dMy'] = {																-- date format is dMy-dMy; reformat to:
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- for long/short reformatting
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- |df=mdy -&gt; Mdy-Mdy 
		},
	['Mdy-Mdy'] = {																-- date format is Mdy-Mdy; reformat to:
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- for long/short reformatting
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- |df=dmy -&gt; dMy-dMy 
		},
	['My-My'] = {																-- these for long/short reformatting
		['any'] = {'%s %s – %s %s', 'm', 'y', 'm2', 'y2'},						-- dmy/mdy agnostic
		},
	['M-My'] = {																-- these for long/short reformatting
		['any'] = {'%s – %s %s', 'm', 'm2', 'y'},								-- dmy/mdy agnostic
		},
	['My'] = {																	-- these for long/short reformatting
		['any'] = {'%s %s', 'm', 'y'},											-- dmy/mdy agnostic
		},
--	['yMd'] = {																	-- not supported at en.wiki
--		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
--		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
--		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
--		},
	}


local function reformatter (date, pattern_idx, format_param, mon_len)
	if not in_array (pattern_idx, {'ymd', 'Mdy', 'Md-dy', 'dMy', 'yMd', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- not in this set of date format patterns then not a reformattable date
	end
	
	if 'ymd' == format_param and in_array (pattern_idx, {'ymd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- ymd date ranges not supported at en.wiki; no point in reformatting ymd to ymd
	end

	if in_array (pattern_idx, {'My', 'M-My', 'My-My'}) then						-- these are not dmy/mdy so can't be 'reformatted' into either
		format_param = 'any';													-- so format-agnostic 
	end

--	if 'yMd' == format_param and in_array (pattern_idx, {'yMd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy'}) then	-- not supported at en.wiki
	if 'yMd' == format_param then												-- not supported at en.wiki
		return;																	-- not a reformattable date
	end
	
	local c1, c2, c3, c4, c5, c6, c7;											-- these hold the captures specified in patterns[pattern_idx][1]
	c1, c2, c3, c4, c5, c6, c7 = mw.ustring.match (date, patterns[pattern_idx][1]);	-- get the captures

	local t = {																	-- table that holds k/v pairs of date parts from the captures and patterns[pattern_idx][2..]
		[patterns[pattern_idx][2]] = c1;										-- at minimum there is always one capture with a matching indicator letter
		[patterns[pattern_idx][3] or 'x'] = c2;									-- patterns can have a variable number of captures; each capture requires an indicator letter;
		[patterns[pattern_idx][4] or 'x'] = c3;									-- where there is no capture, there is no indicator letter so n in patterns[pattern_idx][n] will be nil;
		[patterns[pattern_idx][5] or 'x'] = c4;									-- the 'x' here spoofs an indicator letter to prevent 'table index is nil' error
		[patterns[pattern_idx][6] or 'x'] = c5;
		[patterns[pattern_idx][7] or 'x'] = c6;
		[patterns[pattern_idx][8] or 'x'] = c7;
		};

	if tonumber(t.m) then														-- if raw month is a number (converting from ymd)
		if 's' == mon_len then													-- if we are to use abbreviated month names
			t.m = cfg.date_names['inv_local_s'][tonumber(t.m)];					-- convert it to a month name
		else
			t.m = cfg.date_names['inv_local_l'][tonumber(t.m)];					-- convert it to a month name
		end
	elseif 'ymd' == format_param then											-- when converting to ymd
		if 1582 &gt; tonumber(t.y) then											-- ymd format dates not allowed before 1582
			return;
		end
		t.m = string.format ('%02d', get_month_number (t.m));					-- make sure that month and day are two digits
		t.d = string.format ('%02d', t.d);
	elseif mon_len then															-- if mon_len is set to either 'short' or 'long'
		for _, mon in ipairs ({'m', 'm2'}) do									-- because there can be two month names, check both 
			if t[mon] then
				t[mon] = get_month_number (t[mon]);								-- get the month number for this month (is length agnostic)
				if 0 == t[mon] then return; end									-- seasons and named dates can't be converted
				t[mon] = (('s' == mon_len) and cfg.date_names['inv_local_s'][t[mon]]) or cfg.date_names['inv_local_l'][t[mon]];	-- fetch month name according to length
			end
		end
	end

	local new_date = string.format (re_formats[pattern_idx][format_param][1],	-- format string
		t[re_formats[pattern_idx][format_param][2]],							-- named captures from t{}
		t[re_formats[pattern_idx][format_param][3]],
		t[re_formats[pattern_idx][format_param][4]],
		t[re_formats[pattern_idx][format_param][5]],
		t[re_formats[pattern_idx][format_param][6]],
		t[re_formats[pattern_idx][format_param][7]],
		t[re_formats[pattern_idx][format_param][8]]
		);

	return new_date;
end


--[[-------------------------&lt; R E F O R M A T _ D A T E S &gt;--------------------------------------------------

Reformats existing dates into the format specified by format.

format is one of several manual keywords: dmy, dmy-all, mdy, mdy-all, ymd, ymd-all.  The -all version includes
access- and archive-dates; otherwise these dates are not reformatted.

This function allows automatic date formatting.  In ~/Configuration, the article source is searched for one of
the {{use xxx dates}} templates.  If found, xxx becomes the global date format as xxx-all.  If |cs1-dates= in
{{use xxx dates}} has legitimate value then that value determines how cs1|2 dates will be rendered.  Legitimate
values for |cs1-dates= are:
	l - all dates are rendered with long month names
	ls - publication dates use long month names; access-/archive-dates use abbreviated month names
	ly - publication dates use long month names; access-/archive-dates rendered in ymd format
	s - all dates are rendered with abbreviated (short) month names
	sy - publication dates use abbreviated month names; access-/archive-dates rendered in ymd format
	y - all dates are rendered in ymd format

the format argument for automatic date formatting will be the format specified by {{use xxx dates}} with the
value supplied by |cs1-dates so one of: xxx-l, xxx-ls, xxx-ly, xxx-s, xxx-sy, xxx-y, or simply xxx (|cs1-dates=
empty, omitted, or invalid) where xxx shall be either of dmy or mdy.

dates are extracted from date_parameters_list, reformatted (if appropriate), and then written back into the
list in the new format.  Dates in date_parameters_list are presumed here to be valid (no errors).  This function
returns true when a date has been reformatted, false else.  Actual reformatting is done by reformatter().

]]

local function reformat_dates (date_parameters_list, format)
	local all = false;															-- set to false to skip access- and archive-dates
	local len_p = 'l';															-- default publication date length shall be long
	local len_a = 'l';															-- default access-/archive-date length shall be long
	local result = false;
	local new_date;																
	
	if format:match('%a+%-all') then											-- manual df keyword; auto df keyword when length not specified in {{use xxx dates}}; 
		format = format:match('(%a+)%-all');									-- extract the format
		all = true;																-- all dates are long format dates because this keyword doesn't specify length
	elseif format:match('%a+%-[lsy][sy]?') then									-- auto df keywords; internal only
		all = true;																-- auto df applies to all dates; use length specified by capture len_p for all dates
		format, len_p, len_a = format:match('(%a+)%-([lsy])([sy]?)');			-- extract the format and length keywords
		if 'y' == len_p then													-- because allowed by MOS:DATEUNIFY (sort of) range dates and My dates not reformatted
			format = 'ymd';														-- override {{use xxx dates}}
		elseif (not is_set(len_a)) or (len_p == len_a) then						-- no access-/archive-date length specified or same length as publication dates then
			len_a = len_p;														-- in case len_a not set
		end
	end																			-- else only publication dates and they are long

	for param_name, param_val in pairs (date_parameters_list) do				-- for each date-holding parameter in the list
		if is_set (param_val.val) then											-- if the parameter has a value
			if not (not all and in_array (param_name, {'access-date', 'archive-date'})) then	-- skip access- or archive-date unless format is xxx-all; yeah, ugly; TODO: find a better way
				for pattern_idx, pattern in pairs (patterns) do
					if mw.ustring.match (param_val.val, pattern[1]) then
						if all and in_array (param_name, {'access-date', 'archive-date'}) then	-- if this date is an access- or archive-date
							new_date = reformatter (param_val.val, pattern_idx, (('y' == len_a) and 'ymd') or format, len_a);	-- choose ymd or dmy/mdy according to len_a setting
						else													-- all other dates
							new_date = reformatter (param_val.val, pattern_idx, format, len_p);
						end
						
						if new_date then										-- set when date was reformatted
							date_parameters_list[param_name].val = new_date;	-- update date in date list
							result = true;										-- and announce that changes have been made
						end
					end	-- if
				end		-- for
			end			-- if
		end				-- if
	end					-- for
return result;																	-- declare boolean result and done
end


--[[--------------------------&lt; D A T E _ H Y P H E N _ T O _ D A S H &gt;----------------------------------------

Loops through the list of date-holding parameters and converts any hyphen to an ndash.  Not called if the cs1|2
template has any date errors.

Modifies the date_parameters_list and returns true if hyphens are replaced, else returns false.

]]

local function date_hyphen_to_dash (date_parameters_list)
	local result = false;
	local n;
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set (param_val.val) then
			if not mw.ustring.match (param_val.val, '%d%d%d%d%-%d%d%-%d%d') then	-- for those that are not ymd dates (ustring because here digits may not be western)
				param_val.val, n = param_val.val:gsub ('%-', '–');				-- replace any hyphen with ndash
				if 0 ~= n then
					date_parameters_list[param_name].val = param_val.val;		-- update the list
					result = true;
				end
			end
		end
	end
	return result;																-- so we know if any hyphens were replaced
end


--[[-------------------------&lt; D A T E _ N A M E _ X L A T E &gt;------------------------------------------------

Attempts to translate English month names to local-language month names using names supplied by MediaWiki's
date parser function.  This is simple name-for-name replacement and may not work for all languages.

if xlat_dig is true, this function will also translate western (English) digits to the local language's digits.
This will also translate ymd dates.

]]

local function	date_name_xlate (date_parameters_list, xlt_dig)
	local xlate;
	local mode;																	-- long or short month names
	local modified = false;
	local date;
	
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val.val) then											-- if the parameter has a value
			date = param_val.val;
			for month in mw.ustring.gmatch (date, '%a+') do						-- iterate through all dates in the date (single date or date range)
				if cfg.date_names.en.long[month] then
					mode = 'F';													-- English name is long so use long local name
				elseif cfg.date_names.en.short[month] then
					mode = 'M';													-- English name is short so use short local name
				else
					mode = nil;													-- not an English month name; could be local language month name or an English season name
				end
		
				if mode then													-- might be a season
					xlate = mw.getContentLanguage():formatDate(mode, '1' .. month);	-- translate the month name to this local language
					date = mw.ustring.gsub (date, month, xlate);				-- replace the English with the translation
					date_parameters_list[param_name].val = date;				-- save the translated date
					modified = true;
				end
			end

			if xlt_dig then														-- shall we also translate digits?
				date = date:gsub ('%d', cfg.date_names.xlate_digits);			-- translate digits from western to 'local digits'
				date_parameters_list[param_name].val = date;					-- save the translated date
				modified = true;
			end
		end
	end
	
	return modified;
	end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	is_set = utilities_page_ptr.is_set;											-- import functions from selected Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;										-- import functions from selected Module:Citation/CS1/Utilities module
	cfg = cfg_table_ptr;														-- import tables from selected Module:Citation/CS1/Configuration
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {																		-- return exported functions
	dates = dates,
	year_date_check = year_date_check,
	reformat_dates = reformat_dates,
	date_hyphen_to_dash = date_hyphen_to_dash,
	date_name_xlate = date_name_xlate,
	set_selected_modules = set_selected_modules
	}</text>
      <sha1>fj39mnocj5l5fby83xsxd3jbo411pcd</sha1>
    </revision>
    <revision>
      <id>4842</id>
      <parentid>4841</parentid>
      <timestamp>2019-04-20T13:47:26Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>bug fix; strip leading '0' from ymd dates when reformatting;</comment>
      <origin>4842</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="57299" sha1="g6ypfjjt1awtu54iodyxpr7lgvh79qk" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array;															-- imported functions from selected Module:Citation/CS1/Utilities
local cfg;																		-- table of tables imported from selected Module:Citation/CS1/Configuration


--[=[-------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |accessdate= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-Engish date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate().  To get around that
call this function with YYYY-MM-DD format dates.

]=]

local function is_valid_accessdate (accessdate)
	local lang = mw.getContentLanguage();
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold unix time stamps representing the dates
		
	good1, access_ts = pcall( lang.formatDate, lang, 'U', accessdate );			-- convert accessdate value to unix timesatmp 
	good2, tomorrow_ts = pcall( lang.formatDate, lang, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which which tonumber() may not understand
		access_ts = tonumber (access_ts) or lang:parseFormattedNumber (access_ts);			-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to unix time stamp
	end

	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end


--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct. If not a valid month, returns 0

]]

local function get_month_number (month)
	return cfg.date_names['local'].long[month] or cfg.date_names['local'].short[month] or		-- look for local names first
			cfg.date_names['en'].long[month] or	cfg.date_names['en'].short[month] or			-- failing that, look for English names
			0;																					-- not a recognized month name
end


--[[--------------------------&lt; I S _ V A L I D _ E M B A R G O _ D A T E &gt;------------------------------------

returns true and date value if that value has proper dmy, mdy, ymd format.

returns false and 9999 (embargoed forever) when date value is not proper format; assumes that when |embargo= is
set, the editor intended to embargo a pmc but |embargo= does not hold a single date.

]]

local function is_valid_embargo_date (v)
	if v:match ('^%d%d%d%d%-%d%d%-%d%d$') or									-- ymd
		v:match ('^%d%d?%s+%a+%s+%d%d%d%d$') or									-- dmy
		v:match ('^%a+%s+%d%d?%s*,%s*%d%d%d%d$') then							-- mdy
			return true, v;
	end
	return false, '9999';														-- if here not good date so return false and set embargo date to long time in future
end


--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 1 for Winter, etc.  Capitalization and spelling must be correct. If not a valid season, returns 0

Uses ISO DIS 8601 2016 part 2 §4.7  Divisions of a year for hemishpere-independent seasons:
	21-24 = Spring, Summer, Autumn, Winter, independent of “Hemisphere”

These additional divisions not currently supported:
	25-28 = Spring - Northern Hemisphere, Summer- Northern Hemisphere, Autumn - Northern Hemisphere, Winter - Northern Hemisphere
	29-32 = Spring – Southern Hemisphere, Summer– Southern Hemisphere, Autumn – Southern Hemisphere, Winter - Southern Hemisphere
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)

]]

local function get_season_number (season)
	return cfg.date_names['local'].season[season] or							-- look for local names first
			cfg.date_names['en'].season[season] or								-- failing that, look for English names
			0;																	-- not a recognized season name
end


--[[--------------------------&lt; I S _ P R O P E R _ N A M E &gt;--------------------------------------------------

returns a non-zero number if date contains a recognized proper name.  Capitalization and spelling must be correct.

]]

local function is_proper_name (name)
	return cfg.date_names['local'].named[name] or								-- look for local names dates first
			cfg.date_names['en'].named[name] or									-- failing that, look for English names
			0;																	-- not a recognized named date
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ O R _ S E A S O N &gt;------------------------------

--returns true if month or season is valid (properly spelled, capitalized, abbreviated)

]]

local function is_valid_month_or_season (month_season)
	if 0 == get_month_number (month_season) then								-- if month text isn't one of the twelve months, might be a season
		if 0 == get_season_number (month_season) then							-- not a month, is it a season?
			return false;														-- return false not a month or one of the five seasons
		end
	end
	return true;
end


--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one year in the future are not acceptable.

]]
local year_limit;
local function is_valid_year(year)
	if not is_set(year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;									-- global variable so we only have to fetch it once
	end
	return tonumber(year) &lt;= year_limit;										-- false if year is in the future more than one year
end


--[[--------------------------&lt; I S _ V A L I D _ D A T E &gt;----------------------------------------------------
Returns true if day is less than or equal to the number of days in month and year is no farther into the future
than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap
years before 1582 and Gregorian leap years after 1582. Where the two calendars overlap (1582 to approximately
1923) dates are assumed to be Gregorian.

]]

local function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year(year) then												-- no farther into the future than next year
		return false;
	end
	
	month = tonumber(month);													-- required for YYYY-MM-DD dates
	
	if (2==month) then															-- if February
		month_length = 28;														-- then 28 days unless
		if 1582 &gt; tonumber(year) then											-- Julian calendar
			if 0==(year%4) then													-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		else																	-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then			-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
There is a special test for May because it can be either short or long form.

Returns true when style for both months is the same

]]

local function is_valid_month_range_style (month1, month2)
local len1 = month1:len();
local len2 = month2:len();
	if len1 == len2 then
		return true;															-- both months are short form so return true
	elseif 'May' == month1 or 'May'== month2 then
		return true;															-- both months are long form so return true
	elseif 3 == len1 or 3 == len2 then
		return false;															-- months are mixed form so return false
	else
		return true;															-- both months are long form so return true
	end
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

All season ranges are accepted as valid because there are publishers out there who have published a Summer–Spring YYYY issue so ... ok

]]

local function is_valid_month_season_range(range_start, range_end)
	local range_start_number = get_month_number (range_start);
	local range_end_number;
	
	if 0 == range_start_number then												-- is this a month range?
		range_start_number = get_season_number (range_start);					-- not a month; is it a season? get start season number
		range_end_number = get_season_number (range_end);						-- get end season number

		if (0 ~= range_start_number) and (0 ~= range_end_number) then
			return true;														-- any season pairing is accepted
		end
		return false;															-- range_start and/or range_end is not a season
	end
																				-- here when range_start is a month
	range_end_number = get_month_number (range_end);							-- get end month number
	if range_start_number &lt; range_end_number then								-- range_start is a month; does range_start precede range_end?
		if is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
		end
	end
	return false;																-- range_start month number is greater than or equal to range end number; or range end isn't a month
end


--[[--------------------------&lt; M A K E _ C O I N S _ D A T E &gt;------------------------------------------------

This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1.  The function is called only for |date= parameters and only if the |date=&lt;value&gt; is 
determined to be a valid date format.  The question of what to do with invalid date formats is not answered here.

The date parts in the input table are converted to an ISO 8601 conforming date string:
	single whole dates:		yyyy-mm-dd
	month and year dates:	yyyy-mm
	year dates:				yyyy
	ranges:					yyyy-mm-dd/yyyy-mm-dd
							yyyy-mm/yyyy-mm
							yyyy/yyyy

Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.

The input table has:
	year, year2 – always present; if before 1582, ignore months and days if present
	month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 99 Christmas
	day, day2 –  0 if not provided, 1-31 for days
	
the output table receives:
	rftdate:	an IS8601 formatted date
	rftchron:	a free-form version of the date, usually without year which is in rftdate (season ranges and propername dates)
	rftssn:		one of four season keywords: winter, spring, summer, fall (lowercase)

]]

local function make_COinS_date (input, tCOinS_date)
	local date;																	-- one date or first date in a range
	local date2 = '';															-- end of range date
-- start temporary Julian / Gregorian calendar uncertainty detection
	local year = tonumber(input.year);											-- this temporary code to determine the extent of sources dated to the Julian/Gregorian
	local month = tonumber(input.month);										-- interstice 1 October 1582 – 1 January 1926
	local day = tonumber (input.day);
	if (0 ~= day) and															-- day must have a value for this to be a whole date
		(((1582 == year) and (10 &lt;= month) and (12 &gt;= month)) or				-- any whole 1582 date from 1 october to 31 December or
			((1926 == year) and (1 == month) and (1 == input.day)) or			-- 1 January 1926 or
				((1582 &lt; year) and (1925 &gt;= year))) then						-- any date 1 January 1583 – 31 December 1925
					tCOinS_date.inter_cal_cat = true;							-- set category flag true
	end
-- end temporary Julian / Gergorian calendar uncertainty detection
	
	if 1582 &gt; tonumber(input.year) or 20 &lt; tonumber(input.month) then			-- Julian calendar or season so &amp;rft.date gets year only
		date = input.year;
		if 0 ~= input.year2 and input.year ~= input.year2 then					-- if a range, only the second year portion when not the same as range start year
			date = string.format ('%.4d/%.4d', tonumber(input.year), tonumber(input.year2))		-- assemble the date range
		end
		if 20 &lt; tonumber(input.month) then										-- if season or propername date
			local season = {[24]='winter', [21]='spring', [22]='summer', [23]='fall', [99]='Christmas'};	-- seasons lowercase, no autumn; proper names use title case
			if 0 == input.month2 then											-- single season date
				if 30 &lt;tonumber(input.month) then
					tCOinS_date.rftchron = season[input.month];					-- proper name dates
				else
					tCOinS_date.rftssn = season[input.month];					-- seasons
				end
			else																-- season range with a second season specified
				if input.year ~= input.year2 then								-- season year – season year range or season year–year
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					if 0~= input.month2 then
						tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);
					end
				else															-- season–season year range
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2];	-- season–season year range
				end
			end
		end
		tCOinS_date.rftdate = date;
		return;																	-- done
	end
	
	if 0 ~= input.day then
		date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day));	-- whole date
	elseif 0 ~= input.month then
		date = string.format ('%s-%.2d', input.year, tonumber(input.month));	-- year and month
	else
		date = string.format ('%s', input.year);								-- just year
	end

	if 0 ~= input.year2 then
		if 0 ~= input.day2 then
			date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2));		-- whole date
		elseif 0 ~= input.month2 then
			date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2));	-- year and month
		else
			date2 = string.format ('/%s', input.year2);							-- just year
		end
	end
	
	tCOinS_date.rftdate = date .. date2;										-- date2 has the '/' separator
	return;
end


--[[--------------------------&lt; P A T T E R N S &gt;--------------------------------------------------------------

this is the list of patterns for date formats that this module recognizes.  Approximately the first half of these
patterns represent formats that might be reformatted into another format.  Those that might be reformatted have
'indicator' letters that identify the content of the matching capture: 'd' (day), 'm' (month), 'a' (anchor year),
'y' (year); second day, month, year have a '2' suffix.

These patterns are used for both date validation and for reformatting.  This table should not be moved to ~/Configuration
because changes to this table require changes to check_date() and to reformatter() and reformat_date()

]]

local patterns = {
	 																			-- year-initial numerical year-month-day
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'},					
																				-- month-initial: month day, year
	['Mdy'] = {'^(%D-) +([1-9]%d?), +((%d%d%d%d?)%a?)$', 'm', 'd', 'a', 'y'},
																				-- month-initial day range: month day–day, year; days are separated by endash
	['Md-dy'] = {'^(%D-) +([1-9]%d?)[%-–]([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'd2', 'a', 'y'},
																				-- day-initial: day month year
	['dMy'] = {'^([1-9]%d?) *(%D-) +((%d%d%d%d?)%a?)$', 'd', 'm', 'a', 'y'},
																				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed; not supported at en.wiki
--	['yMd'] = {'^((%d%d%d%d?)%a?) +(%D-) +(%d%d?)$', 'a', 'y', 'm', 'd'},
																				-- day-range-initial: day–day month year; days are separated by endash
	['d-dMy'] = {'^([1-9]%d?)[%-–]([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'd2', 'm', 'a', 'y'},
																				-- day initial month-day-range: day month - day month year; uses spaced endash
	['dM-dMy'] = {'^([1-9]%d?) +(%D-) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'd2', 'm2', 'a', 'y'},
																				-- month initial month-day-range: month day – month day, year;  uses spaced endash
	['Md-Mdy'] = {'^(%D-) +([1-9]%d?) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$','m', 'd', 'm2', 'd2', 'a', 'y'},
																				-- day initial month-day-year-range: day month year - day month year; uses spaced endash
	['dMy-dMy'] = {'^([1-9]%d?) +(%D-) +(%d%d%d%d) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'y', 'd2', 'm2', 'a', 'y2'},
																				-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
	['Mdy-Mdy'] = {'^(%D-) +([1-9]%d?), +(%d%d%d%d) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'y', 'm2', 'd2', 'a', 'y2'},

																				-- these date formats cannot be converted, per se, but month name can be rendered short or long
																				-- month/season year - month/season year; separated by spaced endash
	['My-My'] = {'^(%D-) +(%d%d%d%d) +[%-–] +(%D-) +((%d%d%d%d)%a?)$', 'm', 'y', 'm2', 'a', 'y2'},
																				-- month/season range year; months separated by endash
	['M-My'] = {'^(%D-)[%-–](%D-) +((%d%d%d%d)%a?)$', 'm', 'm2', 'a', 'y'},
																				-- month/season year or proper-name year
	['My'] = {'^([^%d–]-) +((%d%d%d%d)%a?)$', 'm', 'a', 'y'},					-- this way because endash is a member of %D; %D- will match January–March 2019 when it shouldn't
																				-- these date formats cannot be converted
	['Sy4-y2'] = {'^(%D-) +((%d%d)%d%d)[%-–]((%d%d)%a?)$'},						-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
	['Sy-y'] = {'^(%D-) +(%d%d%d%d)[%-–]((%d%d%d%d)%a?)$'},						-- special case Winter/Summer year-year; year separated with unspaced endash
	['y-y'] = {'^(%d%d%d%d?)[%-–]((%d%d%d%d?)%a?)$'},							-- year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
	['y4-y2'] = {'^((%d%d)%d%d)[%-–]((%d%d)%a?)$'},								-- year range: YYYY–YY; separated by unspaced endash
	['y'] = {'^((%d%d%d%d?)%a?)$'},												-- year; here accept either YYY or YYYY
	}


--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only
allowed range separator is endash.  Additionally, check the date to see that it is a real date: no 31 in 30-day
months; no 29 February when not a leap year.  Months, both long-form and three character abbreviations, and seasons
must be spelled correctly.  Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and
COinS_date.  When this happens, the date parameter is used in the COinS metadata and the CITEREF identifier gets
its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc.)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is ISO 8601 format date; see make_COInS_date()

]]

local function check_date (date_string, tCOinS_date, test_accessdate)
	local year;			-- assume that year2, months, and days are not used;
	local year2=0;		-- second year in a year range
	local month=0;
	local month2=0;		-- second month in a month range
	local day=0;
	local day2=0;		-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match (patterns['ymd'][1]) then								-- year-initial numerical year month day format
		year, month, day=date_string:match (patterns['ymd'][1]);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or 0 == tonumber(day) then return false; end	-- month or day number not valid or not Gregorian calendar
		anchor_year = year;
	
	elseif mw.ustring.match(date_string, patterns['Mdy'][1]) then				-- month-initial: month day, year
		month, day, anchor_year, year=mw.ustring.match(date_string, patterns['Mdy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
				
	elseif mw.ustring.match(date_string, patterns['Md-dy'][1]) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year=mw.ustring.match(date_string, patterns['Md-dy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2=month;															-- for metadata
		year2=year;

	elseif mw.ustring.match(date_string, patterns['dMy'][1]) then				-- day-initial: day month year
		day, month, anchor_year, year=mw.ustring.match(date_string, patterns['dMy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months

--[[ NOT supported at en.wiki
	elseif mw.ustring.match(date_string, patterns['yMd'][1]) then				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed
		anchor_year, year, month, day=mw.ustring.match(date_string, patterns['yMd'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
-- end NOT supported at en.wiki ]]

	elseif mw.ustring.match(date_string, patterns['d-dMy'][1]) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year=mw.ustring.match(date_string, patterns['d-dMy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2=month;															-- for metadata
		year2=year;

	elseif mw.ustring.match(date_string, patterns['dM-dMy'][1]) then			-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year=mw.ustring.match(date_string, patterns['dM-dMy'][1]);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif mw.ustring.match(date_string, patterns['Md-Mdy'][1]) then			-- month initial month-day-range: month day – month day, year;  uses spaced endash
		month, day, month2, day2, anchor_year, year=mw.ustring.match(date_string, patterns['Md-Mdy'][1]);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif mw.ustring.match(date_string, patterns['dMy-dMy'][1]) then			-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2=mw.ustring.match(date_string, patterns['dMy-dMy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);

	elseif mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]) then			-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
		month, day, year, month2, day2, anchor_year, year2=mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);

	elseif mw.ustring.match(date_string, patterns['Sy4-y2'][1]) then			-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		local century;
		month, year, century, anchor_year, year2=mw.ustring.match(date_string, patterns['Sy4-y2'][1]);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;		-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;										-- assemble anchor_year from both years
		year2 = century..year2;													-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		month = get_season_number (month);

	elseif mw.ustring.match(date_string, patterns['Sy-y'][1]) then				-- special case Winter/Summer year-year; year separated with unspaced endash
		month, year, anchor_year, year2=mw.ustring.match(date_string, patterns['Sy-y'][1]);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;		-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;										-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		month = get_season_number (month);										-- for metadata

	elseif mw.ustring.match(date_string, patterns['My-My'][1]) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2=mw.ustring.match(date_string, patterns['My-My'][1]);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then 	-- both must be month year, same month style
			month = get_month_number(month);
			month2 = get_month_number(month2);
		elseif 0 ~= get_season_number(month) and 0 ~= get_season_number(month2) then	-- both must be or season year, not mixed
			month = get_season_number(month);
			month2 = get_season_number(month2);
		else
			 return false;
		end

	elseif mw.ustring.match(date_string, patterns['M-My'][1]) then				-- month/season range year; months separated by endash 
		month, month2, anchor_year, year=mw.ustring.match(date_string, patterns['M-My'][1]);
		if (not is_valid_month_season_range(month, month2)) or (not is_valid_year(year)) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
			month2 = get_month_number(month2);
		else
			month = get_season_number(month);
			month2 = get_season_number(month2);
		end
		year2=year;
		
	elseif mw.ustring.match(date_string, patterns['My'][1]) then				-- month/season year or proper-name year
		month, anchor_year, year=mw.ustring.match(date_string, patterns['My'][1]);
		if not is_valid_year(year) then return false; end
		if not is_valid_month_or_season (month) and 0 == is_proper_name (month) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
		elseif 0 ~= get_season_number(month) then
			month = get_season_number(month);
		else
			month = is_proper_name (month);										-- must be proper name; not supported in COinS
		end

	elseif mw.ustring.match(date_string, patterns['y-y'][1]) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2=mw.ustring.match(date_string, patterns['y-y'][1]);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, patterns['y4-y2'][1]) then				-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2=mw.ustring.match(date_string, patterns['y4-y2'][1]);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century..year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match (patterns['y'][1]) then							-- year; here accept either YYY or YYYY
		anchor_year, year=date_string:match (patterns['y'][1]);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;															-- date format not one of the MOS:DATE approved formats
	end

	if test_accessdate then														-- test accessdate here because we have numerical date parts
		if 0 ~= year and 0 ~= month and 0 ~= day and 							-- all parts of a single date required
			0 == year2 and 0 == month2 and 0 == day2 then						-- none of these; accessdate must not be a range
				if not is_valid_accessdate (year..'-'..month..'-'..day) then	
					return false;												-- return false when accessdate out of bounds
				end
		else
			return false;														-- return false when accessdate is a range of two dates
		end
	end

	local result=true;															-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result=is_valid_date(year,month,day);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month2,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year2,month2,day2);
	end
	
	if false == result then return false; end

	if nil ~= tCOinS_date then													-- this table only passed into this function when testing |date= parameter values
		make_COinS_date ({year=year, month=month, day=day, year2=year2, month2=month2, day2=day2}, tCOinS_date);	-- make an ISO 8601 date string for COinS
	end
	
	return true, anchor_year;													-- format is good and date string represents a real date
end	


--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.

]]

local function dates(date_parameters_list, tCOinS_date)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local embargo_date;															-- if embargo date is a good dmy, mdy, ymd date then holds original value else reset to 9999
	local error_message = &quot;&quot;;
	local good_date = false;
	
	for k, v in pairs(date_parameters_list) do									-- for each date-holding parameter in the list
		if is_set(v.val) then													-- if the parameter has a value
			v.val = mw.ustring.gsub (v.val, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9
			if v.val:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then						-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v.val:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);				-- get the year portion so it can be tested
				if 'date'==k then
					anchor_year, COinS_date = v.val:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year'==k then
					good_date = is_valid_year(year);
				end
			elseif 'date'==k then												-- if the parameter is |date=
				if v.val:match(&quot;^n%.d%.%a?$&quot;) then								-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v.val:match(&quot;^nd%a?$&quot;) then								-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v.val, tCOinS_date);	-- go test the date
				end
			elseif 'year'==k then												-- if the parameter is |year= it should hold only a year value
				if v.val:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then						-- if |year= 3 or 4 digits only with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((%d+)%a?)&quot;);
				end
			elseif 'access-date'==k then										-- if the parameter is |date=
				good_date = check_date (v.val, nil, true);						-- go test the date; nil is a placeholder; true is the test_accessdate flag
			elseif 'embargo'==k then											-- if the parameter is |embargo=
				good_date = check_date (v.val);									-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date, embargo_date = is_valid_embargo_date (v.val);	-- is |embargo= date a single dmy, mdy, or ymd formatted date? yes:returns embargo; no: returns 9999
				end
			else																-- any other date-holding parameter
				good_date = check_date (v.val);									-- go test the date
			end
			if false==good_date then											-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then									-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;						-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. v.name .. &quot;=&quot;;		-- add the failed parameter
			end
		end
	end
	return anchor_year, embargo_date, error_message;							-- and done
end


--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function returns a numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

]]

local function year_date_check (year_string, date_string)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes
	
	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where both date and year are required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard range formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif mw.ustring.match(date_string, &quot;%d%d%d%d[%-–]%d%d&quot;) then				-- YYYY-YY date ranges
		local century;
		date1, century, date2 = mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	else
		result = 0;																-- no recognizable year in date
	end
	return result;
end


--[[--------------------------&lt; R E F O R M A T T E R &gt;--------------------------------------------------------

reformat 'date' into new format specified by format_param if pattern_idx (the current format of 'date') can be
reformatted.  Does the grunt work for reformat_dates().

The table re_formats maps patern_idx (current format) and format_param (desired format) to a table that holds:
	format string used by string.format()
	identifier letters ('d', 'm', 'y', 'd2', 'm2', 'y2') that serve as indexes into a table t{} that holds captures
		from mw.ustring.match() for the various date parts specified by  patterns[pattern_idx][1]

Items in patterns{} have the general form:
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'}, where:
		['ymd'] is pattern_idx
		patterns['ymd'][1] is the match pattern with captures for mw.ustring.match()
		patterns['ymd'][2] is an indicator letter identifying the content of the first capture
		patterns['ymd'][3] ... the second capture etc

when a pattern matches a date, the captures are loaded into table t{} in capture order using the idemtifier
characters as indexes into t{}  For the above, a ymd date is in t{} as:
	t.y = first capture (year), t.m = second capture (month), t.d = third capture (day)

To reformat, this function is called with the pattern_idx that matches the current format of the date and with
format_param set to the desired format.  This function loads table t{} as described and then calls string.format()
with the format string specified by re_format[pattern_idx][format_param][1] using values taken from t{} according
to the capture identifier letters specified by patterns[pattern_idx][format_param][n] where n is 2..

]]

local re_formats = {
	['ymd'] = {																	-- date format is ymd; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},									-- |df=yMd; not supported at en.wiki
		},
	['Mdy'] = {																	-- date format is Mdy; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- for long/short reformatting
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},									-- |df=yMd; not supported at en.wiki
		},
	['dMy'] = {																	-- date format is dMy; reformat to:
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- for long/short reformatting
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},									-- |df=yMd; not supported at en.wiki
		},
	['Md-dy'] = {																-- date format is Md-dy; reformat to:
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- for long/short reformatting
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- |df=dmy -&gt; d-dMy 
		},
	['d-dMy'] = {																-- date format is d-d&gt;y; reformat to:
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- for long/short reformatting
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- |df=mdy -&gt; Md-dy 
		},
	['dM-dMy'] = {																-- date format is dM-dMy; reformat to:
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- for long/short reformatting
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd', 'm2', 'd2', 'y'},				-- |df=mdy -&gt; Md-Mdy 
		},
	['Md-Mdy'] = {																-- date format is Md-Mdy; reformat to:
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd',  'm2', 'd2', 'y'},			-- for long/short reformatting
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- |df=dmy -&gt; dM-dMy 
		},
	['dMy-dMy'] = {																-- date format is dMy-dMy; reformat to:
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- for long/short reformatting
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- |df=mdy -&gt; Mdy-Mdy 
		},
	['Mdy-Mdy'] = {																-- date format is Mdy-Mdy; reformat to:
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- for long/short reformatting
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- |df=dmy -&gt; dMy-dMy 
		},
	['My-My'] = {																-- these for long/short reformatting
		['any'] = {'%s %s – %s %s', 'm', 'y', 'm2', 'y2'},						-- dmy/mdy agnostic
		},
	['M-My'] = {																-- these for long/short reformatting
		['any'] = {'%s – %s %s', 'm', 'm2', 'y'},								-- dmy/mdy agnostic
		},
	['My'] = {																	-- these for long/short reformatting
		['any'] = {'%s %s', 'm', 'y'},											-- dmy/mdy agnostic
		},
--	['yMd'] = {																	-- not supported at en.wiki
--		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
--		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
--		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
--		},
	}


local function reformatter (date, pattern_idx, format_param, mon_len)
	if not in_array (pattern_idx, {'ymd', 'Mdy', 'Md-dy', 'dMy', 'yMd', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- not in this set of date format patterns then not a reformattable date
	end
	
	if 'ymd' == format_param and in_array (pattern_idx, {'ymd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- ymd date ranges not supported at en.wiki; no point in reformatting ymd to ymd
	end

	if in_array (pattern_idx, {'My', 'M-My', 'My-My'}) then						-- these are not dmy/mdy so can't be 'reformatted' into either
		format_param = 'any';													-- so format-agnostic 
	end

--	if 'yMd' == format_param and in_array (pattern_idx, {'yMd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy'}) then	-- not supported at en.wiki
	if 'yMd' == format_param then												-- not supported at en.wiki
		return;																	-- not a reformattable date
	end
	
	local c1, c2, c3, c4, c5, c6, c7;											-- these hold the captures specified in patterns[pattern_idx][1]
	c1, c2, c3, c4, c5, c6, c7 = mw.ustring.match (date, patterns[pattern_idx][1]);	-- get the captures

	local t = {																	-- table that holds k/v pairs of date parts from the captures and patterns[pattern_idx][2..]
		[patterns[pattern_idx][2]] = c1;										-- at minimum there is always one capture with a matching indicator letter
		[patterns[pattern_idx][3] or 'x'] = c2;									-- patterns can have a variable number of captures; each capture requires an indicator letter;
		[patterns[pattern_idx][4] or 'x'] = c3;									-- where there is no capture, there is no indicator letter so n in patterns[pattern_idx][n] will be nil;
		[patterns[pattern_idx][5] or 'x'] = c4;									-- the 'x' here spoofs an indicator letter to prevent 'table index is nil' error
		[patterns[pattern_idx][6] or 'x'] = c5;
		[patterns[pattern_idx][7] or 'x'] = c6;
		[patterns[pattern_idx][8] or 'x'] = c7;
		};

	if tonumber(t.m) then														-- if raw month is a number (converting from ymd)
		if 's' == mon_len then													-- if we are to use abbreviated month names
			t.m = cfg.date_names['inv_local_s'][tonumber(t.m)];					-- convert it to a month name
		else
			t.m = cfg.date_names['inv_local_l'][tonumber(t.m)];					-- convert it to a month name
		end
		t.d = t.d:gsub ('0(%d)', '%1');											-- strip leading '0' from day if present
	elseif 'ymd' == format_param then											-- when converting to ymd
		if 1582 &gt; tonumber(t.y) then											-- ymd format dates not allowed before 1582
			return;
		end
		t.m = string.format ('%02d', get_month_number (t.m));					-- make sure that month and day are two digits
		t.d = string.format ('%02d', t.d);
	elseif mon_len then															-- if mon_len is set to either 'short' or 'long'
		for _, mon in ipairs ({'m', 'm2'}) do									-- because there can be two month names, check both 
			if t[mon] then
				t[mon] = get_month_number (t[mon]);								-- get the month number for this month (is length agnostic)
				if 0 == t[mon] then return; end									-- seasons and named dates can't be converted
				t[mon] = (('s' == mon_len) and cfg.date_names['inv_local_s'][t[mon]]) or cfg.date_names['inv_local_l'][t[mon]];	-- fetch month name according to length
			end
		end
	end

	local new_date = string.format (re_formats[pattern_idx][format_param][1],	-- format string
		t[re_formats[pattern_idx][format_param][2]],							-- named captures from t{}
		t[re_formats[pattern_idx][format_param][3]],
		t[re_formats[pattern_idx][format_param][4]],
		t[re_formats[pattern_idx][format_param][5]],
		t[re_formats[pattern_idx][format_param][6]],
		t[re_formats[pattern_idx][format_param][7]],
		t[re_formats[pattern_idx][format_param][8]]
		);

	return new_date;
end


--[[-------------------------&lt; R E F O R M A T _ D A T E S &gt;--------------------------------------------------

Reformats existing dates into the format specified by format.

format is one of several manual keywords: dmy, dmy-all, mdy, mdy-all, ymd, ymd-all.  The -all version includes
access- and archive-dates; otherwise these dates are not reformatted.

This function allows automatic date formatting.  In ~/Configuration, the article source is searched for one of
the {{use xxx dates}} templates.  If found, xxx becomes the global date format as xxx-all.  If |cs1-dates= in
{{use xxx dates}} has legitimate value then that value determines how cs1|2 dates will be rendered.  Legitimate
values for |cs1-dates= are:
	l - all dates are rendered with long month names
	ls - publication dates use long month names; access-/archive-dates use abbreviated month names
	ly - publication dates use long month names; access-/archive-dates rendered in ymd format
	s - all dates are rendered with abbreviated (short) month names
	sy - publication dates use abbreviated month names; access-/archive-dates rendered in ymd format
	y - all dates are rendered in ymd format

the format argument for automatic date formatting will be the format specified by {{use xxx dates}} with the
value supplied by |cs1-dates so one of: xxx-l, xxx-ls, xxx-ly, xxx-s, xxx-sy, xxx-y, or simply xxx (|cs1-dates=
empty, omitted, or invalid) where xxx shall be either of dmy or mdy.

dates are extracted from date_parameters_list, reformatted (if appropriate), and then written back into the
list in the new format.  Dates in date_parameters_list are presumed here to be valid (no errors).  This function
returns true when a date has been reformatted, false else.  Actual reformatting is done by reformatter().

]]

local function reformat_dates (date_parameters_list, format)
	local all = false;															-- set to false to skip access- and archive-dates
	local len_p = 'l';															-- default publication date length shall be long
	local len_a = 'l';															-- default access-/archive-date length shall be long
	local result = false;
	local new_date;																
	
	if format:match('%a+%-all') then											-- manual df keyword; auto df keyword when length not specified in {{use xxx dates}}; 
		format = format:match('(%a+)%-all');									-- extract the format
		all = true;																-- all dates are long format dates because this keyword doesn't specify length
	elseif format:match('%a+%-[lsy][sy]?') then									-- auto df keywords; internal only
		all = true;																-- auto df applies to all dates; use length specified by capture len_p for all dates
		format, len_p, len_a = format:match('(%a+)%-([lsy])([sy]?)');			-- extract the format and length keywords
		if 'y' == len_p then													-- because allowed by MOS:DATEUNIFY (sort of) range dates and My dates not reformatted
			format = 'ymd';														-- override {{use xxx dates}}
		elseif (not is_set(len_a)) or (len_p == len_a) then						-- no access-/archive-date length specified or same length as publication dates then
			len_a = len_p;														-- in case len_a not set
		end
	end																			-- else only publication dates and they are long

	for param_name, param_val in pairs (date_parameters_list) do				-- for each date-holding parameter in the list
		if is_set (param_val.val) then											-- if the parameter has a value
			if not (not all and in_array (param_name, {'access-date', 'archive-date'})) then	-- skip access- or archive-date unless format is xxx-all; yeah, ugly; TODO: find a better way
				for pattern_idx, pattern in pairs (patterns) do
					if mw.ustring.match (param_val.val, pattern[1]) then
						if all and in_array (param_name, {'access-date', 'archive-date'}) then	-- if this date is an access- or archive-date
							new_date = reformatter (param_val.val, pattern_idx, (('y' == len_a) and 'ymd') or format, len_a);	-- choose ymd or dmy/mdy according to len_a setting
						else													-- all other dates
							new_date = reformatter (param_val.val, pattern_idx, format, len_p);
						end
						
						if new_date then										-- set when date was reformatted
							date_parameters_list[param_name].val = new_date;	-- update date in date list
							result = true;										-- and announce that changes have been made
						end
					end	-- if
				end		-- for
			end			-- if
		end				-- if
	end					-- for
return result;																	-- declare boolean result and done
end


--[[--------------------------&lt; D A T E _ H Y P H E N _ T O _ D A S H &gt;----------------------------------------

Loops through the list of date-holding parameters and converts any hyphen to an ndash.  Not called if the cs1|2
template has any date errors.

Modifies the date_parameters_list and returns true if hyphens are replaced, else returns false.

]]

local function date_hyphen_to_dash (date_parameters_list)
	local result = false;
	local n;
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set (param_val.val) then
			if not mw.ustring.match (param_val.val, '%d%d%d%d%-%d%d%-%d%d') then	-- for those that are not ymd dates (ustring because here digits may not be western)
				param_val.val, n = param_val.val:gsub ('%-', '–');				-- replace any hyphen with ndash
				if 0 ~= n then
					date_parameters_list[param_name].val = param_val.val;		-- update the list
					result = true;
				end
			end
		end
	end
	return result;																-- so we know if any hyphens were replaced
end


--[[-------------------------&lt; D A T E _ N A M E _ X L A T E &gt;------------------------------------------------

Attempts to translate English month names to local-language month names using names supplied by MediaWiki's
date parser function.  This is simple name-for-name replacement and may not work for all languages.

if xlat_dig is true, this function will also translate western (English) digits to the local language's digits.
This will also translate ymd dates.

]]

local function	date_name_xlate (date_parameters_list, xlt_dig)
	local xlate;
	local mode;																	-- long or short month names
	local modified = false;
	local date;
	
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val.val) then											-- if the parameter has a value
			date = param_val.val;
			for month in mw.ustring.gmatch (date, '%a+') do						-- iterate through all dates in the date (single date or date range)
				if cfg.date_names.en.long[month] then
					mode = 'F';													-- English name is long so use long local name
				elseif cfg.date_names.en.short[month] then
					mode = 'M';													-- English name is short so use short local name
				else
					mode = nil;													-- not an English month name; could be local language month name or an English season name
				end
		
				if mode then													-- might be a season
					xlate = mw.getContentLanguage():formatDate(mode, '1' .. month);	-- translate the month name to this local language
					date = mw.ustring.gsub (date, month, xlate);				-- replace the English with the translation
					date_parameters_list[param_name].val = date;				-- save the translated date
					modified = true;
				end
			end

			if xlt_dig then														-- shall we also translate digits?
				date = date:gsub ('%d', cfg.date_names.xlate_digits);			-- translate digits from western to 'local digits'
				date_parameters_list[param_name].val = date;					-- save the translated date
				modified = true;
			end
		end
	end
	
	return modified;
	end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	is_set = utilities_page_ptr.is_set;											-- import functions from selected Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;										-- import functions from selected Module:Citation/CS1/Utilities module
	cfg = cfg_table_ptr;														-- import tables from selected Module:Citation/CS1/Configuration
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {																		-- return exported functions
	dates = dates,
	year_date_check = year_date_check,
	reformat_dates = reformat_dates,
	date_hyphen_to_dash = date_hyphen_to_dash,
	date_name_xlate = date_name_xlate,
	set_selected_modules = set_selected_modules
	}</text>
      <sha1>g6ypfjjt1awtu54iodyxpr7lgvh79qk</sha1>
    </revision>
    <revision>
      <id>4843</id>
      <parentid>4842</parentid>
      <timestamp>2019-09-03T11:05:57Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4843</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="57298" sha1="fs1ivpn6x0ray56v3tidzkgwtdi6v7s" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array;															-- imported functions from selected Module:Citation/CS1/Utilities
local cfg;																		-- table of tables imported from selected Module:Citation/CS1/Configuration


--[=[-------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |accessdate= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-Engish date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate().  To get around that
call this function with YYYY-MM-DD format dates.

]=]

local function is_valid_accessdate (accessdate)
	local lang = mw.getContentLanguage();
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold unix time stamps representing the dates
		
	good1, access_ts = pcall( lang.formatDate, lang, 'U', accessdate );			-- convert accessdate value to unix timesatmp 
	good2, tomorrow_ts = pcall( lang.formatDate, lang, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which which tonumber() may not understand
		access_ts = tonumber (access_ts) or lang:parseFormattedNumber (access_ts);			-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to unix time stamp
	end

	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end


--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct. If not a valid month, returns 0

]]

local function get_month_number (month)
	return cfg.date_names['local'].long[month] or cfg.date_names['local'].short[month] or		-- look for local names first
			cfg.date_names['en'].long[month] or	cfg.date_names['en'].short[month] or			-- failing that, look for English names
			0;																					-- not a recognized month name
end


--[[--------------------------&lt; I S _ V A L I D _ E M B A R G O _ D A T E &gt;------------------------------------

returns true and date value if that value has proper dmy, mdy, ymd format.

returns false and 9999 (embargoed forever) when date value is not proper format; assumes that when |embargo= is
set, the editor intended to embargo a pmc but |embargo= does not hold a single date.

]]

local function is_valid_embargo_date (v)
	if v:match ('^%d%d%d%d%-%d%d%-%d%d$') or									-- ymd
		v:match ('^%d%d?%s+%a+%s+%d%d%d%d$') or									-- dmy
		v:match ('^%a+%s+%d%d?%s*,%s*%d%d%d%d$') then							-- mdy
			return true, v;
	end
	return false, '9999';														-- if here not good date so return false and set embargo date to long time in future
end


--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 1 for Winter, etc.  Capitalization and spelling must be correct. If not a valid season, returns 0

Uses ISO DIS 8601 2016 part 2 §4.7  Divisions of a year for hemishpere-independent seasons:
	21-24 = Spring, Summer, Autumn, Winter, independent of “Hemisphere”

These additional divisions not currently supported:
	25-28 = Spring - Northern Hemisphere, Summer- Northern Hemisphere, Autumn - Northern Hemisphere, Winter - Northern Hemisphere
	29-32 = Spring – Southern Hemisphere, Summer– Southern Hemisphere, Autumn – Southern Hemisphere, Winter - Southern Hemisphere
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)

]]

local function get_season_number (season)
	return cfg.date_names['local'].season[season] or							-- look for local names first
			cfg.date_names['en'].season[season] or								-- failing that, look for English names
			0;																	-- not a recognized season name
end


--[[--------------------------&lt; I S _ P R O P E R _ N A M E &gt;--------------------------------------------------

returns a non-zero number if date contains a recognized proper name.  Capitalization and spelling must be correct.

]]

local function is_proper_name (name)
	return cfg.date_names['local'].named[name] or								-- look for local names dates first
			cfg.date_names['en'].named[name] or									-- failing that, look for English names
			0;																	-- not a recognized named date
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ O R _ S E A S O N &gt;------------------------------

--returns true if month or season is valid (properly spelled, capitalized, abbreviated)

]]

local function is_valid_month_or_season (month_season)
	if 0 == get_month_number (month_season) then								-- if month text isn't one of the twelve months, might be a season
		if 0 == get_season_number (month_season) then							-- not a month, is it a season?
			return false;														-- return false not a month or one of the five seasons
		end
	end
	return true;
end


--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one year in the future are not acceptable.

]]
local year_limit;
local function is_valid_year(year)
	if not is_set(year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;									-- global variable so we only have to fetch it once
	end
	return tonumber(year) &lt;= year_limit;										-- false if year is in the future more than one year
end


--[[--------------------------&lt; I S _ V A L I D _ D A T E &gt;----------------------------------------------------
Returns true if day is less than or equal to the number of days in month and year is no farther into the future
than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap
years before 1582 and Gregorian leap years after 1582. Where the two calendars overlap (1582 to approximately
1923) dates are assumed to be Gregorian.

]]

local function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year(year) then												-- no farther into the future than next year
		return false;
	end
	
	month = tonumber(month);													-- required for YYYY-MM-DD dates
	
	if (2==month) then															-- if February
		month_length = 28;														-- then 28 days unless
		if 1582 &gt; tonumber(year) then											-- Julian calendar
			if 0==(year%4) then													-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		else																	-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then			-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
There is a special test for May because it can be either short or long form.

Returns true when style for both months is the same

]]

local function is_valid_month_range_style (month1, month2)
local len1 = month1:len();
local len2 = month2:len();
	if len1 == len2 then
		return true;															-- both months are short form so return true
	elseif 'May' == month1 or 'May'== month2 then
		return true;															-- both months are long form so return true
	elseif 3 == len1 or 3 == len2 then
		return false;															-- months are mixed form so return false
	else
		return true;															-- both months are long form so return true
	end
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

All season ranges are accepted as valid because there are publishers out there who have published a Summer–Spring YYYY issue so ... ok

]]

local function is_valid_month_season_range(range_start, range_end)
	local range_start_number = get_month_number (range_start);
	local range_end_number;
	
	if 0 == range_start_number then												-- is this a month range?
		range_start_number = get_season_number (range_start);					-- not a month; is it a season? get start season number
		range_end_number = get_season_number (range_end);						-- get end season number

		if (0 ~= range_start_number) and (0 ~= range_end_number) then
			return true;														-- any season pairing is accepted
		end
		return false;															-- range_start and/or range_end is not a season
	end
																				-- here when range_start is a month
	range_end_number = get_month_number (range_end);							-- get end month number
	if range_start_number &lt; range_end_number then								-- range_start is a month; does range_start precede range_end?
		if is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
		end
	end
	return false;																-- range_start month number is greater than or equal to range end number; or range end isn't a month
end


--[[--------------------------&lt; M A K E _ C O I N S _ D A T E &gt;------------------------------------------------

This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1.  The function is called only for |date= parameters and only if the |date=&lt;value&gt; is 
determined to be a valid date format.  The question of what to do with invalid date formats is not answered here.

The date parts in the input table are converted to an ISO 8601 conforming date string:
	single whole dates:		yyyy-mm-dd
	month and year dates:	yyyy-mm
	year dates:				yyyy
	ranges:					yyyy-mm-dd/yyyy-mm-dd
							yyyy-mm/yyyy-mm
							yyyy/yyyy

Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.

The input table has:
	year, year2 – always present; if before 1582, ignore months and days if present
	month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 99 Christmas
	day, day2 –  0 if not provided, 1-31 for days
	
the output table receives:
	rftdate:	an IS8601 formatted date
	rftchron:	a free-form version of the date, usually without year which is in rftdate (season ranges and propername dates)
	rftssn:		one of four season keywords: winter, spring, summer, fall (lowercase)

]]

local function make_COinS_date (input, tCOinS_date)
	local date;																	-- one date or first date in a range
	local date2 = '';															-- end of range date
-- start temporary Julian / Gregorian calendar uncertainty detection
	local year = tonumber(input.year);											-- this temporary code to determine the extent of sources dated to the Julian/Gregorian
	local month = tonumber(input.month);										-- interstice 1 October 1582 – 1 January 1926
	local day = tonumber (input.day);
	if (0 ~= day) and															-- day must have a value for this to be a whole date
		(((1582 == year) and (10 &lt;= month) and (12 &gt;= month)) or				-- any whole 1582 date from 1 october to 31 December or
			((1926 == year) and (1 == month) and (1 == input.day)) or			-- 1 January 1926 or
				((1582 &lt; year) and (1925 &gt;= year))) then						-- any date 1 January 1583 – 31 December 1925
					tCOinS_date.inter_cal_cat = true;							-- set category flag true
	end
-- end temporary Julian / Gergorian calendar uncertainty detection
	
	if 1582 &gt; tonumber(input.year) or 20 &lt; tonumber(input.month) then			-- Julian calendar or season so &amp;rft.date gets year only
		date = input.year;
		if 0 ~= input.year2 and input.year ~= input.year2 then					-- if a range, only the second year portion when not the same as range start year
			date = string.format ('%.4d/%.4d', tonumber(input.year), tonumber(input.year2))		-- assemble the date range
		end
		if 20 &lt; tonumber(input.month) then										-- if season or propername date
			local season = {[24]='winter', [21]='spring', [22]='summer', [23]='fall', [99]='Christmas'};	-- seasons lowercase, no autumn; proper names use title case
			if 0 == input.month2 then											-- single season date
				if 30 &lt;tonumber(input.month) then
					tCOinS_date.rftchron = season[input.month];					-- proper name dates
				else
					tCOinS_date.rftssn = season[input.month];					-- seasons
				end
			else																-- season range with a second season specified
				if input.year ~= input.year2 then								-- season year – season year range or season year–year
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					if 0~= input.month2 then
						tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);
					end
				else															-- season–season year range
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2];	-- season–season year range
				end
			end
		end
		tCOinS_date.rftdate = date;
		return;																	-- done
	end
	
	if 0 ~= input.day then
		date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day));	-- whole date
	elseif 0 ~= input.month then
		date = string.format ('%s-%.2d', input.year, tonumber(input.month));	-- year and month
	else
		date = string.format ('%s', input.year);								-- just year
	end

	if 0 ~= input.year2 then
		if 0 ~= input.day2 then
			date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2));		-- whole date
		elseif 0 ~= input.month2 then
			date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2));	-- year and month
		else
			date2 = string.format ('/%s', input.year2);							-- just year
		end
	end
	
	tCOinS_date.rftdate = date .. date2;										-- date2 has the '/' separator
	return;
end


--[[--------------------------&lt; P A T T E R N S &gt;--------------------------------------------------------------

this is the list of patterns for date formats that this module recognizes.  Approximately the first half of these
patterns represent formats that might be reformatted into another format.  Those that might be reformatted have
'indicator' letters that identify the content of the matching capture: 'd' (day), 'm' (month), 'a' (anchor year),
'y' (year); second day, month, year have a '2' suffix.

These patterns are used for both date validation and for reformatting.  This table should not be moved to ~/Configuration
because changes to this table require changes to check_date() and to reformatter() and reformat_date()

]]

local patterns = {
	 																			-- year-initial numerical year-month-day
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'},					
																				-- month-initial: month day, year
	['Mdy'] = {'^(%D-) +([1-9]%d?), +((%d%d%d%d?)%a?)$', 'm', 'd', 'a', 'y'},
																				-- month-initial day range: month day–day, year; days are separated by endash
	['Md-dy'] = {'^(%D-) +([1-9]%d?)[%-–]([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'd2', 'a', 'y'},
																				-- day-initial: day month year
	['dMy'] = {'^([1-9]%d?) *(%D-) +((%d%d%d%d?)%a?)$', 'd', 'm', 'a', 'y'},
																				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed; not supported at en.wiki
--	['yMd'] = {'^((%d%d%d%d?)%a?) +(%D-) +(%d%d?)$', 'a', 'y', 'm', 'd'},
																				-- day-range-initial: day–day month year; days are separated by endash
	['d-dMy'] = {'^([1-9]%d?)[%-–]([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'd2', 'm', 'a', 'y'},
																				-- day initial month-day-range: day month - day month year; uses spaced endash
	['dM-dMy'] = {'^([1-9]%d?) +(%D-) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'd2', 'm2', 'a', 'y'},
																				-- month initial month-day-range: month day – month day, year;  uses spaced endash
	['Md-Mdy'] = {'^(%D-) +([1-9]%d?) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$','m', 'd', 'm2', 'd2', 'a', 'y'},
																				-- day initial month-day-year-range: day month year - day month year; uses spaced endash
	['dMy-dMy'] = {'^([1-9]%d?) +(%D-) +(%d%d%d%d) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'y', 'd2', 'm2', 'a', 'y2'},
																				-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
	['Mdy-Mdy'] = {'^(%D-) +([1-9]%d?), +(%d%d%d%d) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'y', 'm2', 'd2', 'a', 'y2'},

																				-- these date formats cannot be converted, per se, but month name can be rendered short or long
																				-- month/season year - month/season year; separated by spaced endash
	['My-My'] = {'^(%D-) +(%d%d%d%d) +[%-–] +(%D-) +((%d%d%d%d)%a?)$', 'm', 'y', 'm2', 'a', 'y2'},
																				-- month/season range year; months separated by endash
	['M-My'] = {'^(%D-)[%-–](%D-) +((%d%d%d%d)%a?)$', 'm', 'm2', 'a', 'y'},
																				-- month/season year or proper-name year
	['My'] = {'^([^%d–]-) +((%d%d%d%d)%a?)$', 'm', 'a', 'y'},					-- this way because endash is a member of %D; %D- will match January–March 2019 when it shouldn't
																				-- these date formats cannot be converted
	['Sy4-y2'] = {'^(%D-) +((%d%d)%d%d)[%-–]((%d%d)%a?)$'},						-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
	['Sy-y'] = {'^(%D-) +(%d%d%d%d)[%-–]((%d%d%d%d)%a?)$'},						-- special case Winter/Summer year-year; year separated with unspaced endash
	['y-y'] = {'^(%d%d%d%d?)[%-–]((%d%d%d%d?)%a?)$'},							-- year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
	['y4-y2'] = {'^((%d%d)%d%d)[%-–]((%d%d)%a?)$'},								-- year range: YYYY–YY; separated by unspaced endash
	['y'] = {'^((%d%d%d%d?)%a?)$'},												-- year; here accept either YYY or YYYY
	}


--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only
allowed range separator is endash.  Additionally, check the date to see that it is a real date: no 31 in 30-day
months; no 29 February when not a leap year.  Months, both long-form and three character abbreviations, and seasons
must be spelled correctly.  Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and
COinS_date.  When this happens, the date parameter is used in the COinS metadata and the CITEREF identifier gets
its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc.)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is ISO 8601 format date; see make_COInS_date()

]]

local function check_date (date_string, tCOinS_date, test_accessdate)
	local year;			-- assume that year2, months, and days are not used;
	local year2=0;		-- second year in a year range
	local month=0;
	local month2=0;		-- second month in a month range
	local day=0;
	local day2=0;		-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match (patterns['ymd'][1]) then								-- year-initial numerical year month day format
		year, month, day=date_string:match (patterns['ymd'][1]);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or 0 == tonumber(day) then return false; end	-- month or day number not valid or not Gregorian calendar
		anchor_year = year;
	
	elseif mw.ustring.match(date_string, patterns['Mdy'][1]) then				-- month-initial: month day, year
		month, day, anchor_year, year=mw.ustring.match(date_string, patterns['Mdy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
				
	elseif mw.ustring.match(date_string, patterns['Md-dy'][1]) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year=mw.ustring.match(date_string, patterns['Md-dy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2=month;															-- for metadata
		year2=year;

	elseif mw.ustring.match(date_string, patterns['dMy'][1]) then				-- day-initial: day month year
		day, month, anchor_year, year=mw.ustring.match(date_string, patterns['dMy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months

--[[ NOT supported at en.wiki
	elseif mw.ustring.match(date_string, patterns['yMd'][1]) then				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed
		anchor_year, year, month, day=mw.ustring.match(date_string, patterns['yMd'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
-- end NOT supported at en.wiki ]]

	elseif mw.ustring.match(date_string, patterns['d-dMy'][1]) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year=mw.ustring.match(date_string, patterns['d-dMy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2=month;															-- for metadata
		year2=year;

	elseif mw.ustring.match(date_string, patterns['dM-dMy'][1]) then			-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year=mw.ustring.match(date_string, patterns['dM-dMy'][1]);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif mw.ustring.match(date_string, patterns['Md-Mdy'][1]) then			-- month initial month-day-range: month day – month day, year;  uses spaced endash
		month, day, month2, day2, anchor_year, year=mw.ustring.match(date_string, patterns['Md-Mdy'][1]);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif mw.ustring.match(date_string, patterns['dMy-dMy'][1]) then			-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2=mw.ustring.match(date_string, patterns['dMy-dMy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);

	elseif mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]) then			-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
		month, day, year, month2, day2, anchor_year, year2=mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);

	elseif mw.ustring.match(date_string, patterns['Sy4-y2'][1]) then			-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		local century;
		month, year, century, anchor_year, year2=mw.ustring.match(date_string, patterns['Sy4-y2'][1]);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;		-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;										-- assemble anchor_year from both years
		year2 = century..year2;													-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		month = get_season_number (month);

	elseif mw.ustring.match(date_string, patterns['Sy-y'][1]) then				-- special case Winter/Summer year-year; year separated with unspaced endash
		month, year, anchor_year, year2=mw.ustring.match(date_string, patterns['Sy-y'][1]);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;		-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;										-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		month = get_season_number (month);										-- for metadata

	elseif mw.ustring.match(date_string, patterns['My-My'][1]) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2=mw.ustring.match(date_string, patterns['My-My'][1]);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then 	-- both must be month year, same month style
			month = get_month_number(month);
			month2 = get_month_number(month2);
		elseif 0 ~= get_season_number(month) and 0 ~= get_season_number(month2) then	-- both must be or season year, not mixed
			month = get_season_number(month);
			month2 = get_season_number(month2);
		else
			 return false;
		end

	elseif mw.ustring.match(date_string, patterns['M-My'][1]) then				-- month/season range year; months separated by endash 
		month, month2, anchor_year, year=mw.ustring.match(date_string, patterns['M-My'][1]);
		if (not is_valid_month_season_range(month, month2)) or (not is_valid_year(year)) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
			month2 = get_month_number(month2);
		else
			month = get_season_number(month);
			month2 = get_season_number(month2);
		end
		year2=year;
		
	elseif mw.ustring.match(date_string, patterns['My'][1]) then				-- month/season year or proper-name year
		month, anchor_year, year=mw.ustring.match(date_string, patterns['My'][1]);
		if not is_valid_year(year) then return false; end
		if not is_valid_month_or_season (month) and 0 == is_proper_name (month) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
		elseif 0 ~= get_season_number(month) then
			month = get_season_number(month);
		else
			month = is_proper_name (month);										-- must be proper name; not supported in COinS
		end

	elseif mw.ustring.match(date_string, patterns['y-y'][1]) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2=mw.ustring.match(date_string, patterns['y-y'][1]);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, patterns['y4-y2'][1]) then				-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2=mw.ustring.match(date_string, patterns['y4-y2'][1]);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century..year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif date_string:match (patterns['y'][1]) then							-- year; here accept either YYY or YYYY
		anchor_year, year=date_string:match (patterns['y'][1]);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;															-- date format not one of the MOS:DATE approved formats
	end

	if test_accessdate then														-- test accessdate here because we have numerical date parts
		if 0 ~= year and 0 ~= month and 0 ~= day and 							-- all parts of a single date required
			0 == year2 and 0 == month2 and 0 == day2 then						-- none of these; accessdate must not be a range
				if not is_valid_accessdate (year..'-'..month..'-'..day) then	
					return false;												-- return false when accessdate out of bounds
				end
		else
			return false;														-- return false when accessdate is a range of two dates
		end
	end

	local result=true;															-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result=is_valid_date(year,month,day);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month2,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year2,month2,day2);
	end
	
	if false == result then return false; end

	if nil ~= tCOinS_date then													-- this table only passed into this function when testing |date= parameter values
		make_COinS_date ({year=year, month=month, day=day, year2=year2, month2=month2, day2=day2}, tCOinS_date);	-- make an ISO 8601 date string for COinS
	end
	
	return true, anchor_year;													-- format is good and date string represents a real date
end	


--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.

]]

local function dates(date_parameters_list, tCOinS_date)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local embargo_date;															-- if embargo date is a good dmy, mdy, ymd date then holds original value else reset to 9999
	local error_message = &quot;&quot;;
	local good_date = false;
	
	for k, v in pairs(date_parameters_list) do									-- for each date-holding parameter in the list
		if is_set(v.val) then													-- if the parameter has a value
			v.val = mw.ustring.gsub (v.val, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9
			if v.val:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then						-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v.val:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);				-- get the year portion so it can be tested
				if 'date'==k then
					anchor_year, COinS_date = v.val:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year'==k then
					good_date = is_valid_year(year);
				end
			elseif 'date'==k then												-- if the parameter is |date=
				if v.val:match(&quot;^n%.d%.%a?$&quot;) then								-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v.val:match(&quot;^nd%a?$&quot;) then								-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v.val, tCOinS_date);	-- go test the date
				end
			elseif 'year'==k then												-- if the parameter is |year= it should hold only a year value
				if v.val:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then						-- if |year= 3 or 4 digits only with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((%d+)%a?)&quot;);
				end
			elseif 'access-date'==k then										-- if the parameter is |date=
				good_date = check_date (v.val, nil, true);						-- go test the date; nil is a placeholder; true is the test_accessdate flag
			elseif 'embargo'==k then											-- if the parameter is |embargo=
				good_date = check_date (v.val);									-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date, embargo_date = is_valid_embargo_date (v.val);	-- is |embargo= date a single dmy, mdy, or ymd formatted date? yes:returns embargo; no: returns 9999
				end
			else																-- any other date-holding parameter
				good_date = check_date (v.val);									-- go test the date
			end
			if false==good_date then											-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then									-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;						-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. v.name .. &quot;=&quot;;		-- add the failed parameter
			end
		end
	end
	return anchor_year, embargo_date, error_message;							-- and done
end


--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function returns a numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

]]

local function year_date_check (year_string, date_string)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes
	
	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where both date and year are required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard range formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif mw.ustring.match(date_string, &quot;%d%d%d%d[%-–]%d%d&quot;) then				-- YYYY-YY date ranges
		local century;
		date1, century, date2 = mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	else
		result = 0;																-- no recognizable year in date
	end
	return result;
end


--[[--------------------------&lt; R E F O R M A T T E R &gt;--------------------------------------------------------

reformat 'date' into new format specified by format_param if pattern_idx (the current format of 'date') can be
reformatted.  Does the grunt work for reformat_dates().

The table re_formats maps patern_idx (current format) and format_param (desired format) to a table that holds:
	format string used by string.format()
	identifier letters ('d', 'm', 'y', 'd2', 'm2', 'y2') that serve as indexes into a table t{} that holds captures
		from mw.ustring.match() for the various date parts specified by  patterns[pattern_idx][1]

Items in patterns{} have the general form:
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'}, where:
		['ymd'] is pattern_idx
		patterns['ymd'][1] is the match pattern with captures for mw.ustring.match()
		patterns['ymd'][2] is an indicator letter identifying the content of the first capture
		patterns['ymd'][3] ... the second capture etc

when a pattern matches a date, the captures are loaded into table t{} in capture order using the idemtifier
characters as indexes into t{}  For the above, a ymd date is in t{} as:
	t.y = first capture (year), t.m = second capture (month), t.d = third capture (day)

To reformat, this function is called with the pattern_idx that matches the current format of the date and with
format_param set to the desired format.  This function loads table t{} as described and then calls string.format()
with the format string specified by re_format[pattern_idx][format_param][1] using values taken from t{} according
to the capture identifier letters specified by patterns[pattern_idx][format_param][n] where n is 2..

]]

local re_formats = {
	['ymd'] = {																	-- date format is ymd; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},									-- |df=yMd; not supported at en.wiki
		},
	['Mdy'] = {																	-- date format is Mdy; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- for long/short reformatting
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},									-- |df=yMd; not supported at en.wiki
		},
	['dMy'] = {																	-- date format is dMy; reformat to:
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- for long/short reformatting
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},									-- |df=yMd; not supported at en.wiki
		},
	['Md-dy'] = {																-- date format is Md-dy; reformat to:
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- for long/short reformatting
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- |df=dmy -&gt; d-dMy 
		},
	['d-dMy'] = {																-- date format is d-d&gt;y; reformat to:
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- for long/short reformatting
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- |df=mdy -&gt; Md-dy 
		},
	['dM-dMy'] = {																-- date format is dM-dMy; reformat to:
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- for long/short reformatting
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd', 'm2', 'd2', 'y'},				-- |df=mdy -&gt; Md-Mdy 
		},
	['Md-Mdy'] = {																-- date format is Md-Mdy; reformat to:
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd',  'm2', 'd2', 'y'},			-- for long/short reformatting
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- |df=dmy -&gt; dM-dMy 
		},
	['dMy-dMy'] = {																-- date format is dMy-dMy; reformat to:
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- for long/short reformatting
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- |df=mdy -&gt; Mdy-Mdy 
		},
	['Mdy-Mdy'] = {																-- date format is Mdy-Mdy; reformat to:
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- for long/short reformatting
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- |df=dmy -&gt; dMy-dMy 
		},
	['My-My'] = {																-- these for long/short reformatting
		['any'] = {'%s %s – %s %s', 'm', 'y', 'm2', 'y2'},						-- dmy/mdy agnostic
		},
	['M-My'] = {																-- these for long/short reformatting
		['any'] = {'%s–%s %s', 'm', 'm2', 'y'},									-- dmy/mdy agnostic
		},
	['My'] = {																	-- these for long/short reformatting
		['any'] = {'%s %s', 'm', 'y'},											-- dmy/mdy agnostic
		},
--	['yMd'] = {																	-- not supported at en.wiki
--		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
--		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
--		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
--		},
	}


local function reformatter (date, pattern_idx, format_param, mon_len)
	if not in_array (pattern_idx, {'ymd', 'Mdy', 'Md-dy', 'dMy', 'yMd', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- not in this set of date format patterns then not a reformattable date
	end
	
	if 'ymd' == format_param and in_array (pattern_idx, {'ymd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- ymd date ranges not supported at en.wiki; no point in reformatting ymd to ymd
	end

	if in_array (pattern_idx, {'My', 'M-My', 'My-My'}) then						-- these are not dmy/mdy so can't be 'reformatted' into either
		format_param = 'any';													-- so format-agnostic 
	end

--	if 'yMd' == format_param and in_array (pattern_idx, {'yMd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy'}) then	-- not supported at en.wiki
	if 'yMd' == format_param then												-- not supported at en.wiki
		return;																	-- not a reformattable date
	end
	
	local c1, c2, c3, c4, c5, c6, c7;											-- these hold the captures specified in patterns[pattern_idx][1]
	c1, c2, c3, c4, c5, c6, c7 = mw.ustring.match (date, patterns[pattern_idx][1]);	-- get the captures

	local t = {																	-- table that holds k/v pairs of date parts from the captures and patterns[pattern_idx][2..]
		[patterns[pattern_idx][2]] = c1;										-- at minimum there is always one capture with a matching indicator letter
		[patterns[pattern_idx][3] or 'x'] = c2;									-- patterns can have a variable number of captures; each capture requires an indicator letter;
		[patterns[pattern_idx][4] or 'x'] = c3;									-- where there is no capture, there is no indicator letter so n in patterns[pattern_idx][n] will be nil;
		[patterns[pattern_idx][5] or 'x'] = c4;									-- the 'x' here spoofs an indicator letter to prevent 'table index is nil' error
		[patterns[pattern_idx][6] or 'x'] = c5;
		[patterns[pattern_idx][7] or 'x'] = c6;
		[patterns[pattern_idx][8] or 'x'] = c7;
		};

	if tonumber(t.m) then														-- if raw month is a number (converting from ymd)
		if 's' == mon_len then													-- if we are to use abbreviated month names
			t.m = cfg.date_names['inv_local_s'][tonumber(t.m)];					-- convert it to a month name
		else
			t.m = cfg.date_names['inv_local_l'][tonumber(t.m)];					-- convert it to a month name
		end
		t.d = t.d:gsub ('0(%d)', '%1');											-- strip leading '0' from day if present
	elseif 'ymd' == format_param then											-- when converting to ymd
		if 1582 &gt; tonumber(t.y) then											-- ymd format dates not allowed before 1582
			return;
		end
		t.m = string.format ('%02d', get_month_number (t.m));					-- make sure that month and day are two digits
		t.d = string.format ('%02d', t.d);
	elseif mon_len then															-- if mon_len is set to either 'short' or 'long'
		for _, mon in ipairs ({'m', 'm2'}) do									-- because there can be two month names, check both 
			if t[mon] then
				t[mon] = get_month_number (t[mon]);								-- get the month number for this month (is length agnostic)
				if 0 == t[mon] then return; end									-- seasons and named dates can't be converted
				t[mon] = (('s' == mon_len) and cfg.date_names['inv_local_s'][t[mon]]) or cfg.date_names['inv_local_l'][t[mon]];	-- fetch month name according to length
			end
		end
	end

	local new_date = string.format (re_formats[pattern_idx][format_param][1],	-- format string
		t[re_formats[pattern_idx][format_param][2]],							-- named captures from t{}
		t[re_formats[pattern_idx][format_param][3]],
		t[re_formats[pattern_idx][format_param][4]],
		t[re_formats[pattern_idx][format_param][5]],
		t[re_formats[pattern_idx][format_param][6]],
		t[re_formats[pattern_idx][format_param][7]],
		t[re_formats[pattern_idx][format_param][8]]
		);

	return new_date;
end


--[[-------------------------&lt; R E F O R M A T _ D A T E S &gt;--------------------------------------------------

Reformats existing dates into the format specified by format.

format is one of several manual keywords: dmy, dmy-all, mdy, mdy-all, ymd, ymd-all.  The -all version includes
access- and archive-dates; otherwise these dates are not reformatted.

This function allows automatic date formatting.  In ~/Configuration, the article source is searched for one of
the {{use xxx dates}} templates.  If found, xxx becomes the global date format as xxx-all.  If |cs1-dates= in
{{use xxx dates}} has legitimate value then that value determines how cs1|2 dates will be rendered.  Legitimate
values for |cs1-dates= are:
	l - all dates are rendered with long month names
	ls - publication dates use long month names; access-/archive-dates use abbreviated month names
	ly - publication dates use long month names; access-/archive-dates rendered in ymd format
	s - all dates are rendered with abbreviated (short) month names
	sy - publication dates use abbreviated month names; access-/archive-dates rendered in ymd format
	y - all dates are rendered in ymd format

the format argument for automatic date formatting will be the format specified by {{use xxx dates}} with the
value supplied by |cs1-dates so one of: xxx-l, xxx-ls, xxx-ly, xxx-s, xxx-sy, xxx-y, or simply xxx (|cs1-dates=
empty, omitted, or invalid) where xxx shall be either of dmy or mdy.

dates are extracted from date_parameters_list, reformatted (if appropriate), and then written back into the
list in the new format.  Dates in date_parameters_list are presumed here to be valid (no errors).  This function
returns true when a date has been reformatted, false else.  Actual reformatting is done by reformatter().

]]

local function reformat_dates (date_parameters_list, format)
	local all = false;															-- set to false to skip access- and archive-dates
	local len_p = 'l';															-- default publication date length shall be long
	local len_a = 'l';															-- default access-/archive-date length shall be long
	local result = false;
	local new_date;																
	
	if format:match('%a+%-all') then											-- manual df keyword; auto df keyword when length not specified in {{use xxx dates}}; 
		format = format:match('(%a+)%-all');									-- extract the format
		all = true;																-- all dates are long format dates because this keyword doesn't specify length
	elseif format:match('%a+%-[lsy][sy]?') then									-- auto df keywords; internal only
		all = true;																-- auto df applies to all dates; use length specified by capture len_p for all dates
		format, len_p, len_a = format:match('(%a+)%-([lsy])([sy]?)');			-- extract the format and length keywords
		if 'y' == len_p then													-- because allowed by MOS:DATEUNIFY (sort of) range dates and My dates not reformatted
			format = 'ymd';														-- override {{use xxx dates}}
		elseif (not is_set(len_a)) or (len_p == len_a) then						-- no access-/archive-date length specified or same length as publication dates then
			len_a = len_p;														-- in case len_a not set
		end
	end																			-- else only publication dates and they are long

	for param_name, param_val in pairs (date_parameters_list) do				-- for each date-holding parameter in the list
		if is_set (param_val.val) then											-- if the parameter has a value
			if not (not all and in_array (param_name, {'access-date', 'archive-date'})) then	-- skip access- or archive-date unless format is xxx-all; yeah, ugly; TODO: find a better way
				for pattern_idx, pattern in pairs (patterns) do
					if mw.ustring.match (param_val.val, pattern[1]) then
						if all and in_array (param_name, {'access-date', 'archive-date'}) then	-- if this date is an access- or archive-date
							new_date = reformatter (param_val.val, pattern_idx, (('y' == len_a) and 'ymd') or format, len_a);	-- choose ymd or dmy/mdy according to len_a setting
						else													-- all other dates
							new_date = reformatter (param_val.val, pattern_idx, format, len_p);
						end
						
						if new_date then										-- set when date was reformatted
							date_parameters_list[param_name].val = new_date;	-- update date in date list
							result = true;										-- and announce that changes have been made
						end
					end	-- if
				end		-- for
			end			-- if
		end				-- if
	end					-- for
return result;																	-- declare boolean result and done
end


--[[--------------------------&lt; D A T E _ H Y P H E N _ T O _ D A S H &gt;----------------------------------------

Loops through the list of date-holding parameters and converts any hyphen to an ndash.  Not called if the cs1|2
template has any date errors.

Modifies the date_parameters_list and returns true if hyphens are replaced, else returns false.

]]

local function date_hyphen_to_dash (date_parameters_list)
	local result = false;
	local n;
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set (param_val.val) then
			if not mw.ustring.match (param_val.val, '%d%d%d%d%-%d%d%-%d%d') then	-- for those that are not ymd dates (ustring because here digits may not be western)
				param_val.val, n = param_val.val:gsub ('%-', '–');				-- replace any hyphen with ndash
				if 0 ~= n then
					date_parameters_list[param_name].val = param_val.val;		-- update the list
					result = true;
				end
			end
		end
	end
	return result;																-- so we know if any hyphens were replaced
end


--[[-------------------------&lt; D A T E _ N A M E _ X L A T E &gt;------------------------------------------------

Attempts to translate English month names to local-language month names using names supplied by MediaWiki's
date parser function.  This is simple name-for-name replacement and may not work for all languages.

if xlat_dig is true, this function will also translate western (English) digits to the local language's digits.
This will also translate ymd dates.

]]

local function	date_name_xlate (date_parameters_list, xlt_dig)
	local xlate;
	local mode;																	-- long or short month names
	local modified = false;
	local date;
	
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val.val) then											-- if the parameter has a value
			date = param_val.val;
			for month in mw.ustring.gmatch (date, '%a+') do						-- iterate through all dates in the date (single date or date range)
				if cfg.date_names.en.long[month] then
					mode = 'F';													-- English name is long so use long local name
				elseif cfg.date_names.en.short[month] then
					mode = 'M';													-- English name is short so use short local name
				else
					mode = nil;													-- not an English month name; could be local language month name or an English season name
				end
		
				if mode then													-- might be a season
					xlate = mw.getContentLanguage():formatDate(mode, '1' .. month);	-- translate the month name to this local language
					date = mw.ustring.gsub (date, month, xlate);				-- replace the English with the translation
					date_parameters_list[param_name].val = date;				-- save the translated date
					modified = true;
				end
			end

			if xlt_dig then														-- shall we also translate digits?
				date = date:gsub ('%d', cfg.date_names.xlate_digits);			-- translate digits from western to 'local digits'
				date_parameters_list[param_name].val = date;					-- save the translated date
				modified = true;
			end
		end
	end
	
	return modified;
	end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	is_set = utilities_page_ptr.is_set;											-- import functions from selected Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;										-- import functions from selected Module:Citation/CS1/Utilities module
	cfg = cfg_table_ptr;														-- import tables from selected Module:Citation/CS1/Configuration
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {																		-- return exported functions
	dates = dates,
	year_date_check = year_date_check,
	reformat_dates = reformat_dates,
	date_hyphen_to_dash = date_hyphen_to_dash,
	date_name_xlate = date_name_xlate,
	set_selected_modules = set_selected_modules
	}</text>
      <sha1>fs1ivpn6x0ray56v3tidzkgwtdi6v7s</sha1>
    </revision>
    <revision>
      <id>4844</id>
      <parentid>4843</parentid>
      <timestamp>2020-01-11T12:32:49Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4844</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="57319" sha1="h22yh5m1g3v4luyf3uliuj7bbdei8jw" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array;															-- imported functions from selected Module:Citation/CS1/Utilities
local cfg;																		-- table of tables imported from selected Module:Citation/CS1/Configuration


--[=[-------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |accessdate= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-Engish date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate().  To get around that
call this function with YYYY-MM-DD format dates.

]=]

local function is_valid_accessdate (accessdate)
	local lang = mw.getContentLanguage();
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold unix time stamps representing the dates
		
	good1, access_ts = pcall( lang.formatDate, lang, 'U', accessdate );			-- convert accessdate value to unix timesatmp 
	good2, tomorrow_ts = pcall( lang.formatDate, lang, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which which tonumber() may not understand
		access_ts = tonumber (access_ts) or lang:parseFormattedNumber (access_ts);			-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to unix time stamp
	end

	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end


--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct. If not a valid month, returns 0

]]

local function get_month_number (month)
	return cfg.date_names['local'].long[month] or cfg.date_names['local'].short[month] or		-- look for local names first
			cfg.date_names['en'].long[month] or	cfg.date_names['en'].short[month] or			-- failing that, look for English names
			0;																					-- not a recognized month name
end


--[[--------------------------&lt; I S _ V A L I D _ E M B A R G O _ D A T E &gt;------------------------------------

returns true and date value if that value has proper dmy, mdy, ymd format.

returns false and 9999 (embargoed forever) when date value is not proper format; assumes that when |embargo= is
set, the editor intended to embargo a pmc but |embargo= does not hold a single date.

]]

local function is_valid_embargo_date (v)
	if v:match ('^%d%d%d%d%-%d%d%-%d%d$') or									-- ymd
		v:match ('^%d%d?%s+%a+%s+%d%d%d%d$') or									-- dmy
		v:match ('^%a+%s+%d%d?%s*,%s*%d%d%d%d$') then							-- mdy
			return true, v;
	end
	return false, '9999';														-- if here not good date so return false and set embargo date to long time in future
end


--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 1 for Winter, etc.  Capitalization and spelling must be correct. If not a valid season, returns 0

Uses ISO DIS 8601 2016 part 2 §4.7  Divisions of a year for hemishpere-independent seasons:
	21-24 = Spring, Summer, Autumn, Winter, independent of “Hemisphere”

These additional divisions not currently supported:
	25-28 = Spring - Northern Hemisphere, Summer- Northern Hemisphere, Autumn - Northern Hemisphere, Winter - Northern Hemisphere
	29-32 = Spring – Southern Hemisphere, Summer– Southern Hemisphere, Autumn – Southern Hemisphere, Winter - Southern Hemisphere
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)

]]

local function get_season_number (season)
	return cfg.date_names['local'].season[season] or							-- look for local names first
			cfg.date_names['en'].season[season] or								-- failing that, look for English names
			0;																	-- not a recognized season name
end


--[[--------------------------&lt; I S _ P R O P E R _ N A M E &gt;--------------------------------------------------

returns a non-zero number if date contains a recognized proper name.  Capitalization and spelling must be correct.

]]

local function is_proper_name (name)
	return cfg.date_names['local'].named[name] or								-- look for local names dates first
			cfg.date_names['en'].named[name] or									-- failing that, look for English names
			0;																	-- not a recognized named date
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ O R _ S E A S O N &gt;------------------------------

--returns true if month or season is valid (properly spelled, capitalized, abbreviated)

]]

local function is_valid_month_or_season (month_season)
	if 0 == get_month_number (month_season) then								-- if month text isn't one of the twelve months, might be a season
		if 0 == get_season_number (month_season) then							-- not a month, is it a season?
			return false;														-- return false not a month or one of the five seasons
		end
	end
	return true;
end


--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one year in the future are not acceptable.

]]
local year_limit;
local function is_valid_year(year)
	if not is_set(year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;									-- global variable so we only have to fetch it once
	end
	return tonumber(year) &lt;= year_limit;										-- false if year is in the future more than one year
end


--[[--------------------------&lt; I S _ V A L I D _ D A T E &gt;----------------------------------------------------
Returns true if day is less than or equal to the number of days in month and year is no farther into the future
than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap
years before 1582 and Gregorian leap years after 1582. Where the two calendars overlap (1582 to approximately
1923) dates are assumed to be Gregorian.

]]

local function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year(year) then												-- no farther into the future than next year
		return false;
	end
	
	month = tonumber(month);													-- required for YYYY-MM-DD dates
	
	if (2==month) then															-- if February
		month_length = 28;														-- then 28 days unless
		if 1582 &gt; tonumber(year) then											-- Julian calendar
			if 0==(year%4) then													-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		else																	-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then			-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
There is a special test for May because it can be either short or long form.

Returns true when style for both months is the same

]]

local function is_valid_month_range_style (month1, month2)
local len1 = month1:len();
local len2 = month2:len();
	if len1 == len2 then
		return true;															-- both months are short form so return true
	elseif 'May' == month1 or 'May'== month2 then
		return true;															-- both months are long form so return true
	elseif 3 == len1 or 3 == len2 then
		return false;															-- months are mixed form so return false
	else
		return true;															-- both months are long form so return true
	end
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

All season ranges are accepted as valid because there are publishers out there who have published a Summer–Spring YYYY issue so ... ok

]]

local function is_valid_month_season_range(range_start, range_end)
	local range_start_number = get_month_number (range_start);
	local range_end_number;
	
	if 0 == range_start_number then												-- is this a month range?
		range_start_number = get_season_number (range_start);					-- not a month; is it a season? get start season number
		range_end_number = get_season_number (range_end);						-- get end season number

		if (0 ~= range_start_number) and (0 ~= range_end_number) then
			return true;														-- any season pairing is accepted
		end
		return false;															-- range_start and/or range_end is not a season
	end
																				-- here when range_start is a month
	range_end_number = get_month_number (range_end);							-- get end month number
	if range_start_number &lt; range_end_number then								-- range_start is a month; does range_start precede range_end?
		if is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
		end
	end
	return false;																-- range_start month number is greater than or equal to range end number; or range end isn't a month
end


--[[--------------------------&lt; M A K E _ C O I N S _ D A T E &gt;------------------------------------------------

This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1.  The function is called only for |date= parameters and only if the |date=&lt;value&gt; is 
determined to be a valid date format.  The question of what to do with invalid date formats is not answered here.

The date parts in the input table are converted to an ISO 8601 conforming date string:
	single whole dates:		yyyy-mm-dd
	month and year dates:	yyyy-mm
	year dates:				yyyy
	ranges:					yyyy-mm-dd/yyyy-mm-dd
							yyyy-mm/yyyy-mm
							yyyy/yyyy

Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.

The input table has:
	year, year2 – always present; if before 1582, ignore months and days if present
	month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 99 Christmas
	day, day2 –  0 if not provided, 1-31 for days
	
the output table receives:
	rftdate:	an IS8601 formatted date
	rftchron:	a free-form version of the date, usually without year which is in rftdate (season ranges and propername dates)
	rftssn:		one of four season keywords: winter, spring, summer, fall (lowercase)

]]

local function make_COinS_date (input, tCOinS_date)
	local date;																	-- one date or first date in a range
	local date2 = '';															-- end of range date
-- start temporary Julian / Gregorian calendar uncertainty detection
	local year = tonumber(input.year);											-- this temporary code to determine the extent of sources dated to the Julian/Gregorian
	local month = tonumber(input.month);										-- interstice 1 October 1582 – 1 January 1926
	local day = tonumber (input.day);
	if (0 ~= day) and															-- day must have a value for this to be a whole date
		(((1582 == year) and (10 &lt;= month) and (12 &gt;= month)) or				-- any whole 1582 date from 1 october to 31 December or
			((1926 == year) and (1 == month) and (1 == input.day)) or			-- 1 January 1926 or
				((1582 &lt; year) and (1925 &gt;= year))) then						-- any date 1 January 1583 – 31 December 1925
					tCOinS_date.inter_cal_cat = true;							-- set category flag true
	end
-- end temporary Julian / Gergorian calendar uncertainty detection
	
	if 1582 &gt; tonumber(input.year) or 20 &lt; tonumber(input.month) then			-- Julian calendar or season so &amp;rft.date gets year only
		date = input.year;
		if 0 ~= input.year2 and input.year ~= input.year2 then					-- if a range, only the second year portion when not the same as range start year
			date = string.format ('%.4d/%.4d', tonumber(input.year), tonumber(input.year2))		-- assemble the date range
		end
		if 20 &lt; tonumber(input.month) then										-- if season or propername date
			local season = {[24]='winter', [21]='spring', [22]='summer', [23]='fall', [99]='Christmas'};	-- seasons lowercase, no autumn; proper names use title case
			if 0 == input.month2 then											-- single season date
				if 30 &lt;tonumber(input.month) then
					tCOinS_date.rftchron = season[input.month];					-- proper name dates
				else
					tCOinS_date.rftssn = season[input.month];					-- seasons
				end
			else																-- season range with a second season specified
				if input.year ~= input.year2 then								-- season year – season year range or season year–year
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					if 0~= input.month2 then
						tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);
					end
				else															-- season–season year range
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2];	-- season–season year range
				end
			end
		end
		tCOinS_date.rftdate = date;
		return;																	-- done
	end
	
	if 0 ~= input.day then
		date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day));	-- whole date
	elseif 0 ~= input.month then
		date = string.format ('%s-%.2d', input.year, tonumber(input.month));	-- year and month
	else
		date = string.format ('%s', input.year);								-- just year
	end

	if 0 ~= input.year2 then
		if 0 ~= input.day2 then
			date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2));		-- whole date
		elseif 0 ~= input.month2 then
			date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2));	-- year and month
		else
			date2 = string.format ('/%s', input.year2);							-- just year
		end
	end
	
	tCOinS_date.rftdate = date .. date2;										-- date2 has the '/' separator
	return;
end


--[[--------------------------&lt; P A T T E R N S &gt;--------------------------------------------------------------

this is the list of patterns for date formats that this module recognizes.  Approximately the first half of these
patterns represent formats that might be reformatted into another format.  Those that might be reformatted have
'indicator' letters that identify the content of the matching capture: 'd' (day), 'm' (month), 'a' (anchor year),
'y' (year); second day, month, year have a '2' suffix.

These patterns are used for both date validation and for reformatting.  This table should not be moved to ~/Configuration
because changes to this table require changes to check_date() and to reformatter() and reformat_date()

]]

local patterns = {
	 																			-- year-initial numerical year-month-day
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'},					
																				-- month-initial: month day, year
	['Mdy'] = {'^(%D-) +([1-9]%d?), +((%d%d%d%d?)%a?)$', 'm', 'd', 'a', 'y'},
																				-- month-initial day range: month day–day, year; days are separated by endash
	['Md-dy'] = {'^(%D-) +([1-9]%d?)[%-–]([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'd2', 'a', 'y'},
																				-- day-initial: day month year
	['dMy'] = {'^([1-9]%d?) *(%D-) +((%d%d%d%d?)%a?)$', 'd', 'm', 'a', 'y'},
																				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed; not supported at en.wiki
--	['yMd'] = {'^((%d%d%d%d?)%a?) +(%D-) +(%d%d?)$', 'a', 'y', 'm', 'd'},
																				-- day-range-initial: day–day month year; days are separated by endash
	['d-dMy'] = {'^([1-9]%d?)[%-–]([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'd2', 'm', 'a', 'y'},
																				-- day initial month-day-range: day month - day month year; uses spaced endash
	['dM-dMy'] = {'^([1-9]%d?) +(%D-) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'd2', 'm2', 'a', 'y'},
																				-- month initial month-day-range: month day – month day, year;  uses spaced endash
	['Md-Mdy'] = {'^(%D-) +([1-9]%d?) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$','m', 'd', 'm2', 'd2', 'a', 'y'},
																				-- day initial month-day-year-range: day month year - day month year; uses spaced endash
	['dMy-dMy'] = {'^([1-9]%d?) +(%D-) +(%d%d%d%d) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'y', 'd2', 'm2', 'a', 'y2'},
																				-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
	['Mdy-Mdy'] = {'^(%D-) +([1-9]%d?), +(%d%d%d%d) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'y', 'm2', 'd2', 'a', 'y2'},

																				-- these date formats cannot be converted, per se, but month name can be rendered short or long
																				-- month/season year - month/season year; separated by spaced endash
	['My-My'] = {'^(%D-) +(%d%d%d%d) +[%-–] +(%D-) +((%d%d%d%d)%a?)$', 'm', 'y', 'm2', 'a', 'y2'},
																				-- month/season range year; months separated by endash
	['M-My'] = {'^(%D-)[%-–](%D-) +((%d%d%d%d)%a?)$', 'm', 'm2', 'a', 'y'},
																				-- month/season year or proper-name year
	['My'] = {'^([^%d–]-) +((%d%d%d%d)%a?)$', 'm', 'a', 'y'},					-- this way because endash is a member of %D; %D- will match January–March 2019 when it shouldn't
																				-- these date formats cannot be converted
	['Sy4-y2'] = {'^(%D-) +((%d%d)%d%d)[%-–]((%d%d)%a?)$'},						-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
	['Sy-y'] = {'^(%D-) +(%d%d%d%d)[%-–]((%d%d%d%d)%a?)$'},						-- special case Winter/Summer year-year; year separated with unspaced endash
	['y-y'] = {'^(%d%d%d%d?)[%-–]((%d%d%d%d?)%a?)$'},							-- year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
	['y4-y2'] = {'^((%d%d)%d%d)[%-–]((%d%d)%a?)$'},								-- year range: YYYY–YY; separated by unspaced endash
	['y'] = {'^((%d%d%d%d?)%a?)$'},												-- year; here accept either YYY or YYYY
	}


--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only
allowed range separator is endash.  Additionally, check the date to see that it is a real date: no 31 in 30-day
months; no 29 February when not a leap year.  Months, both long-form and three character abbreviations, and seasons
must be spelled correctly.  Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and
COinS_date.  When this happens, the date parameter is used in the COinS metadata and the CITEREF identifier gets
its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc.)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is ISO 8601 format date; see make_COInS_date()

]]

local function check_date (date_string, tCOinS_date, test_accessdate)
	local year;			-- assume that year2, months, and days are not used;
	local year2=0;		-- second year in a year range
	local month=0;
	local month2=0;		-- second month in a month range
	local day=0;
	local day2=0;		-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match (patterns['ymd'][1]) then								-- year-initial numerical year month day format
		year, month, day=date_string:match (patterns['ymd'][1]);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or 0 == tonumber(day) then return false; end	-- month or day number not valid or not Gregorian calendar
		anchor_year = year;
	
	elseif mw.ustring.match(date_string, patterns['Mdy'][1]) then				-- month-initial: month day, year
		month, day, anchor_year, year=mw.ustring.match(date_string, patterns['Mdy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
				
	elseif mw.ustring.match(date_string, patterns['Md-dy'][1]) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year=mw.ustring.match(date_string, patterns['Md-dy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2=month;															-- for metadata
		year2=year;

	elseif mw.ustring.match(date_string, patterns['dMy'][1]) then				-- day-initial: day month year
		day, month, anchor_year, year=mw.ustring.match(date_string, patterns['dMy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months

--[[ NOT supported at en.wiki
	elseif mw.ustring.match(date_string, patterns['yMd'][1]) then				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed
		anchor_year, year, month, day=mw.ustring.match(date_string, patterns['yMd'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
-- end NOT supported at en.wiki ]]

	elseif mw.ustring.match(date_string, patterns['d-dMy'][1]) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year=mw.ustring.match(date_string, patterns['d-dMy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2=month;															-- for metadata
		year2=year;

	elseif mw.ustring.match(date_string, patterns['dM-dMy'][1]) then			-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year=mw.ustring.match(date_string, patterns['dM-dMy'][1]);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif mw.ustring.match(date_string, patterns['Md-Mdy'][1]) then			-- month initial month-day-range: month day – month day, year;  uses spaced endash
		month, day, month2, day2, anchor_year, year=mw.ustring.match(date_string, patterns['Md-Mdy'][1]);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif mw.ustring.match(date_string, patterns['dMy-dMy'][1]) then			-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2=mw.ustring.match(date_string, patterns['dMy-dMy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);

	elseif mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]) then			-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
		month, day, year, month2, day2, anchor_year, year2=mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);

	elseif mw.ustring.match(date_string, patterns['Sy4-y2'][1]) then			-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		local century;
		month, year, century, anchor_year, year2=mw.ustring.match(date_string, patterns['Sy4-y2'][1]);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;		-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;										-- assemble anchor_year from both years
		year2 = century..year2;													-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		month = get_season_number (month);

	elseif mw.ustring.match(date_string, patterns['Sy-y'][1]) then				-- special case Winter/Summer year-year; year separated with unspaced endash
		month, year, anchor_year, year2=mw.ustring.match(date_string, patterns['Sy-y'][1]);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;		-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;										-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		month = get_season_number (month);										-- for metadata

	elseif mw.ustring.match(date_string, patterns['My-My'][1]) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2=mw.ustring.match(date_string, patterns['My-My'][1]);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then 	-- both must be month year, same month style
			month = get_month_number(month);
			month2 = get_month_number(month2);
		elseif 0 ~= get_season_number(month) and 0 ~= get_season_number(month2) then	-- both must be or season year, not mixed
			month = get_season_number(month);
			month2 = get_season_number(month2);
		else
			 return false;
		end

	elseif mw.ustring.match(date_string, patterns['M-My'][1]) then				-- month/season range year; months separated by endash 
		month, month2, anchor_year, year=mw.ustring.match(date_string, patterns['M-My'][1]);
		if (not is_valid_month_season_range(month, month2)) or (not is_valid_year(year)) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
			month2 = get_month_number(month2);
		else
			month = get_season_number(month);
			month2 = get_season_number(month2);
		end
		year2=year;
		
	elseif mw.ustring.match(date_string, patterns['My'][1]) then				-- month/season year or proper-name year
		month, anchor_year, year=mw.ustring.match(date_string, patterns['My'][1]);
		if not is_valid_year(year) then return false; end
		if not is_valid_month_or_season (month) and 0 == is_proper_name (month) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
		elseif 0 ~= get_season_number(month) then
			month = get_season_number(month);
		else
			month = is_proper_name (month);										-- must be proper name; not supported in COinS
		end

	elseif mw.ustring.match(date_string, patterns['y-y'][1]) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2=mw.ustring.match(date_string, patterns['y-y'][1]);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, patterns['y4-y2'][1]) then				-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2=mw.ustring.match(date_string, patterns['y4-y2'][1]);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century..year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match (date_string, patterns['y'][1]) then				-- year; here accept either YYY or YYYY
		anchor_year, year=mw.ustring.match (date_string, patterns['y'][1]);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;															-- date format not one of the MOS:DATE approved formats
	end

	if test_accessdate then														-- test accessdate here because we have numerical date parts
		if 0 ~= year and 0 ~= month and 0 ~= day and 							-- all parts of a single date required
			0 == year2 and 0 == month2 and 0 == day2 then						-- none of these; accessdate must not be a range
				if not is_valid_accessdate (year..'-'..month..'-'..day) then	
					return false;												-- return false when accessdate out of bounds
				end
		else
			return false;														-- return false when accessdate is a range of two dates
		end
	end

	local result=true;															-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result=is_valid_date(year,month,day);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month2,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year2,month2,day2);
	end
	
	if false == result then return false; end

	if nil ~= tCOinS_date then													-- this table only passed into this function when testing |date= parameter values
		make_COinS_date ({year=year, month=month, day=day, year2=year2, month2=month2, day2=day2}, tCOinS_date);	-- make an ISO 8601 date string for COinS
	end
	
	return true, anchor_year;													-- format is good and date string represents a real date
end	


--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.

]]

local function dates(date_parameters_list, tCOinS_date)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local embargo_date;															-- if embargo date is a good dmy, mdy, ymd date then holds original value else reset to 9999
	local error_message = &quot;&quot;;
	local good_date = false;
	
	for k, v in pairs(date_parameters_list) do									-- for each date-holding parameter in the list
		if is_set(v.val) then													-- if the parameter has a value
			v.val = mw.ustring.gsub (v.val, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9
			if v.val:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then						-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v.val:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);				-- get the year portion so it can be tested
				if 'date'==k then
					anchor_year, COinS_date = v.val:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year'==k then
					good_date = is_valid_year(year);
				end
			elseif 'date'==k then												-- if the parameter is |date=
				if v.val:match(&quot;^n%.d%.%a?$&quot;) then								-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v.val:match(&quot;^nd%a?$&quot;) then								-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v.val, tCOinS_date);	-- go test the date
				end
			elseif 'year'==k then												-- if the parameter is |year= it should hold only a year value
				if v.val:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then						-- if |year= 3 or 4 digits only with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((%d+)%a?)&quot;);
				end
			elseif 'access-date'==k then										-- if the parameter is |date=
				good_date = check_date (v.val, nil, true);						-- go test the date; nil is a placeholder; true is the test_accessdate flag
			elseif 'embargo'==k then											-- if the parameter is |embargo=
				good_date = check_date (v.val);									-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date, embargo_date = is_valid_embargo_date (v.val);	-- is |embargo= date a single dmy, mdy, or ymd formatted date? yes:returns embargo; no: returns 9999
				end
			else																-- any other date-holding parameter
				good_date = check_date (v.val);									-- go test the date
			end
			if false==good_date then											-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then									-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;						-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. v.name .. &quot;=&quot;;		-- add the failed parameter
			end
		end
	end
	return anchor_year, embargo_date, error_message;							-- and done
end


--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function returns a numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

]]

local function year_date_check (year_string, date_string)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes
	
	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where both date and year are required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard range formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif mw.ustring.match(date_string, &quot;%d%d%d%d[%-–]%d%d&quot;) then				-- YYYY-YY date ranges
		local century;
		date1, century, date2 = mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	else
		result = 0;																-- no recognizable year in date
	end
	return result;
end


--[[--------------------------&lt; R E F O R M A T T E R &gt;--------------------------------------------------------

reformat 'date' into new format specified by format_param if pattern_idx (the current format of 'date') can be
reformatted.  Does the grunt work for reformat_dates().

The table re_formats maps patern_idx (current format) and format_param (desired format) to a table that holds:
	format string used by string.format()
	identifier letters ('d', 'm', 'y', 'd2', 'm2', 'y2') that serve as indexes into a table t{} that holds captures
		from mw.ustring.match() for the various date parts specified by  patterns[pattern_idx][1]

Items in patterns{} have the general form:
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'}, where:
		['ymd'] is pattern_idx
		patterns['ymd'][1] is the match pattern with captures for mw.ustring.match()
		patterns['ymd'][2] is an indicator letter identifying the content of the first capture
		patterns['ymd'][3] ... the second capture etc

when a pattern matches a date, the captures are loaded into table t{} in capture order using the idemtifier
characters as indexes into t{}  For the above, a ymd date is in t{} as:
	t.y = first capture (year), t.m = second capture (month), t.d = third capture (day)

To reformat, this function is called with the pattern_idx that matches the current format of the date and with
format_param set to the desired format.  This function loads table t{} as described and then calls string.format()
with the format string specified by re_format[pattern_idx][format_param][1] using values taken from t{} according
to the capture identifier letters specified by patterns[pattern_idx][format_param][n] where n is 2..

]]

local re_formats = {
	['ymd'] = {																	-- date format is ymd; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},									-- |df=yMd; not supported at en.wiki
		},
	['Mdy'] = {																	-- date format is Mdy; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- for long/short reformatting
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},									-- |df=yMd; not supported at en.wiki
		},
	['dMy'] = {																	-- date format is dMy; reformat to:
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- for long/short reformatting
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},									-- |df=yMd; not supported at en.wiki
		},
	['Md-dy'] = {																-- date format is Md-dy; reformat to:
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- for long/short reformatting
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- |df=dmy -&gt; d-dMy 
		},
	['d-dMy'] = {																-- date format is d-d&gt;y; reformat to:
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- for long/short reformatting
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- |df=mdy -&gt; Md-dy 
		},
	['dM-dMy'] = {																-- date format is dM-dMy; reformat to:
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- for long/short reformatting
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd', 'm2', 'd2', 'y'},				-- |df=mdy -&gt; Md-Mdy 
		},
	['Md-Mdy'] = {																-- date format is Md-Mdy; reformat to:
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd',  'm2', 'd2', 'y'},			-- for long/short reformatting
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- |df=dmy -&gt; dM-dMy 
		},
	['dMy-dMy'] = {																-- date format is dMy-dMy; reformat to:
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- for long/short reformatting
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- |df=mdy -&gt; Mdy-Mdy 
		},
	['Mdy-Mdy'] = {																-- date format is Mdy-Mdy; reformat to:
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- for long/short reformatting
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- |df=dmy -&gt; dMy-dMy 
		},
	['My-My'] = {																-- these for long/short reformatting
		['any'] = {'%s %s – %s %s', 'm', 'y', 'm2', 'y2'},						-- dmy/mdy agnostic
		},
	['M-My'] = {																-- these for long/short reformatting
		['any'] = {'%s–%s %s', 'm', 'm2', 'y'},									-- dmy/mdy agnostic
		},
	['My'] = {																	-- these for long/short reformatting
		['any'] = {'%s %s', 'm', 'y'},											-- dmy/mdy agnostic
		},
--	['yMd'] = {																	-- not supported at en.wiki
--		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
--		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
--		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
--		},
	}


local function reformatter (date, pattern_idx, format_param, mon_len)
	if not in_array (pattern_idx, {'ymd', 'Mdy', 'Md-dy', 'dMy', 'yMd', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- not in this set of date format patterns then not a reformattable date
	end
	
	if 'ymd' == format_param and in_array (pattern_idx, {'ymd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- ymd date ranges not supported at en.wiki; no point in reformatting ymd to ymd
	end

	if in_array (pattern_idx, {'My', 'M-My', 'My-My'}) then						-- these are not dmy/mdy so can't be 'reformatted' into either
		format_param = 'any';													-- so format-agnostic 
	end

--	if 'yMd' == format_param and in_array (pattern_idx, {'yMd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy'}) then	-- not supported at en.wiki
	if 'yMd' == format_param then												-- not supported at en.wiki
		return;																	-- not a reformattable date
	end
	
	local c1, c2, c3, c4, c5, c6, c7;											-- these hold the captures specified in patterns[pattern_idx][1]
	c1, c2, c3, c4, c5, c6, c7 = mw.ustring.match (date, patterns[pattern_idx][1]);	-- get the captures

	local t = {																	-- table that holds k/v pairs of date parts from the captures and patterns[pattern_idx][2..]
		[patterns[pattern_idx][2]] = c1;										-- at minimum there is always one capture with a matching indicator letter
		[patterns[pattern_idx][3] or 'x'] = c2;									-- patterns can have a variable number of captures; each capture requires an indicator letter;
		[patterns[pattern_idx][4] or 'x'] = c3;									-- where there is no capture, there is no indicator letter so n in patterns[pattern_idx][n] will be nil;
		[patterns[pattern_idx][5] or 'x'] = c4;									-- the 'x' here spoofs an indicator letter to prevent 'table index is nil' error
		[patterns[pattern_idx][6] or 'x'] = c5;
		[patterns[pattern_idx][7] or 'x'] = c6;
		[patterns[pattern_idx][8] or 'x'] = c7;
		};

	if tonumber(t.m) then														-- if raw month is a number (converting from ymd)
		if 's' == mon_len then													-- if we are to use abbreviated month names
			t.m = cfg.date_names['inv_local_s'][tonumber(t.m)];					-- convert it to a month name
		else
			t.m = cfg.date_names['inv_local_l'][tonumber(t.m)];					-- convert it to a month name
		end
		t.d = t.d:gsub ('0(%d)', '%1');											-- strip leading '0' from day if present
	elseif 'ymd' == format_param then											-- when converting to ymd
		if 1582 &gt; tonumber(t.y) then											-- ymd format dates not allowed before 1582
			return;
		end
		t.m = string.format ('%02d', get_month_number (t.m));					-- make sure that month and day are two digits
		t.d = string.format ('%02d', t.d);
	elseif mon_len then															-- if mon_len is set to either 'short' or 'long'
		for _, mon in ipairs ({'m', 'm2'}) do									-- because there can be two month names, check both 
			if t[mon] then
				t[mon] = get_month_number (t[mon]);								-- get the month number for this month (is length agnostic)
				if 0 == t[mon] then return; end									-- seasons and named dates can't be converted
				t[mon] = (('s' == mon_len) and cfg.date_names['inv_local_s'][t[mon]]) or cfg.date_names['inv_local_l'][t[mon]];	-- fetch month name according to length
			end
		end
	end

	local new_date = string.format (re_formats[pattern_idx][format_param][1],	-- format string
		t[re_formats[pattern_idx][format_param][2]],							-- named captures from t{}
		t[re_formats[pattern_idx][format_param][3]],
		t[re_formats[pattern_idx][format_param][4]],
		t[re_formats[pattern_idx][format_param][5]],
		t[re_formats[pattern_idx][format_param][6]],
		t[re_formats[pattern_idx][format_param][7]],
		t[re_formats[pattern_idx][format_param][8]]
		);

	return new_date;
end


--[[-------------------------&lt; R E F O R M A T _ D A T E S &gt;--------------------------------------------------

Reformats existing dates into the format specified by format.

format is one of several manual keywords: dmy, dmy-all, mdy, mdy-all, ymd, ymd-all.  The -all version includes
access- and archive-dates; otherwise these dates are not reformatted.

This function allows automatic date formatting.  In ~/Configuration, the article source is searched for one of
the {{use xxx dates}} templates.  If found, xxx becomes the global date format as xxx-all.  If |cs1-dates= in
{{use xxx dates}} has legitimate value then that value determines how cs1|2 dates will be rendered.  Legitimate
values for |cs1-dates= are:
	l - all dates are rendered with long month names
	ls - publication dates use long month names; access-/archive-dates use abbreviated month names
	ly - publication dates use long month names; access-/archive-dates rendered in ymd format
	s - all dates are rendered with abbreviated (short) month names
	sy - publication dates use abbreviated month names; access-/archive-dates rendered in ymd format
	y - all dates are rendered in ymd format

the format argument for automatic date formatting will be the format specified by {{use xxx dates}} with the
value supplied by |cs1-dates so one of: xxx-l, xxx-ls, xxx-ly, xxx-s, xxx-sy, xxx-y, or simply xxx (|cs1-dates=
empty, omitted, or invalid) where xxx shall be either of dmy or mdy.

dates are extracted from date_parameters_list, reformatted (if appropriate), and then written back into the
list in the new format.  Dates in date_parameters_list are presumed here to be valid (no errors).  This function
returns true when a date has been reformatted, false else.  Actual reformatting is done by reformatter().

]]

local function reformat_dates (date_parameters_list, format)
	local all = false;															-- set to false to skip access- and archive-dates
	local len_p = 'l';															-- default publication date length shall be long
	local len_a = 'l';															-- default access-/archive-date length shall be long
	local result = false;
	local new_date;																
	
	if format:match('%a+%-all') then											-- manual df keyword; auto df keyword when length not specified in {{use xxx dates}}; 
		format = format:match('(%a+)%-all');									-- extract the format
		all = true;																-- all dates are long format dates because this keyword doesn't specify length
	elseif format:match('%a+%-[lsy][sy]?') then									-- auto df keywords; internal only
		all = true;																-- auto df applies to all dates; use length specified by capture len_p for all dates
		format, len_p, len_a = format:match('(%a+)%-([lsy])([sy]?)');			-- extract the format and length keywords
		if 'y' == len_p then													-- because allowed by MOS:DATEUNIFY (sort of) range dates and My dates not reformatted
			format = 'ymd';														-- override {{use xxx dates}}
		elseif (not is_set(len_a)) or (len_p == len_a) then						-- no access-/archive-date length specified or same length as publication dates then
			len_a = len_p;														-- in case len_a not set
		end
	end																			-- else only publication dates and they are long

	for param_name, param_val in pairs (date_parameters_list) do				-- for each date-holding parameter in the list
		if is_set (param_val.val) then											-- if the parameter has a value
			if not (not all and in_array (param_name, {'access-date', 'archive-date'})) then	-- skip access- or archive-date unless format is xxx-all; yeah, ugly; TODO: find a better way
				for pattern_idx, pattern in pairs (patterns) do
					if mw.ustring.match (param_val.val, pattern[1]) then
						if all and in_array (param_name, {'access-date', 'archive-date'}) then	-- if this date is an access- or archive-date
							new_date = reformatter (param_val.val, pattern_idx, (('y' == len_a) and 'ymd') or format, len_a);	-- choose ymd or dmy/mdy according to len_a setting
						else													-- all other dates
							new_date = reformatter (param_val.val, pattern_idx, format, len_p);
						end
						
						if new_date then										-- set when date was reformatted
							date_parameters_list[param_name].val = new_date;	-- update date in date list
							result = true;										-- and announce that changes have been made
						end
					end	-- if
				end		-- for
			end			-- if
		end				-- if
	end					-- for
return result;																	-- declare boolean result and done
end


--[[--------------------------&lt; D A T E _ H Y P H E N _ T O _ D A S H &gt;----------------------------------------

Loops through the list of date-holding parameters and converts any hyphen to an ndash.  Not called if the cs1|2
template has any date errors.

Modifies the date_parameters_list and returns true if hyphens are replaced, else returns false.

]]

local function date_hyphen_to_dash (date_parameters_list)
	local result = false;
	local n;
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set (param_val.val) then
			if not mw.ustring.match (param_val.val, '%d%d%d%d%-%d%d%-%d%d') then	-- for those that are not ymd dates (ustring because here digits may not be western)
				param_val.val, n = param_val.val:gsub ('%-', '–');				-- replace any hyphen with ndash
				if 0 ~= n then
					date_parameters_list[param_name].val = param_val.val;		-- update the list
					result = true;
				end
			end
		end
	end
	return result;																-- so we know if any hyphens were replaced
end


--[[-------------------------&lt; D A T E _ N A M E _ X L A T E &gt;------------------------------------------------

Attempts to translate English month names to local-language month names using names supplied by MediaWiki's
date parser function.  This is simple name-for-name replacement and may not work for all languages.

if xlat_dig is true, this function will also translate western (English) digits to the local language's digits.
This will also translate ymd dates.

]]

local function	date_name_xlate (date_parameters_list, xlt_dig)
	local xlate;
	local mode;																	-- long or short month names
	local modified = false;
	local date;
	
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val.val) then											-- if the parameter has a value
			date = param_val.val;
			for month in mw.ustring.gmatch (date, '%a+') do						-- iterate through all dates in the date (single date or date range)
				if cfg.date_names.en.long[month] then
					mode = 'F';													-- English name is long so use long local name
				elseif cfg.date_names.en.short[month] then
					mode = 'M';													-- English name is short so use short local name
				else
					mode = nil;													-- not an English month name; could be local language month name or an English season name
				end
		
				if mode then													-- might be a season
					xlate = mw.getContentLanguage():formatDate(mode, '1' .. month);	-- translate the month name to this local language
					date = mw.ustring.gsub (date, month, xlate);				-- replace the English with the translation
					date_parameters_list[param_name].val = date;				-- save the translated date
					modified = true;
				end
			end

			if xlt_dig then														-- shall we also translate digits?
				date = date:gsub ('%d', cfg.date_names.xlate_digits);			-- translate digits from western to 'local digits'
				date_parameters_list[param_name].val = date;					-- save the translated date
				modified = true;
			end
		end
	end
	
	return modified;
	end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	is_set = utilities_page_ptr.is_set;											-- import functions from selected Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;										-- import functions from selected Module:Citation/CS1/Utilities module
	cfg = cfg_table_ptr;														-- import tables from selected Module:Citation/CS1/Configuration
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {																		-- return exported functions
	dates = dates,
	year_date_check = year_date_check,
	reformat_dates = reformat_dates,
	date_hyphen_to_dash = date_hyphen_to_dash,
	date_name_xlate = date_name_xlate,
	set_selected_modules = set_selected_modules
	}</text>
      <sha1>h22yh5m1g3v4luyf3uliuj7bbdei8jw</sha1>
    </revision>
    <revision>
      <id>4845</id>
      <parentid>4844</parentid>
      <timestamp>2020-01-18T14:24:00Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>lua script error fix for non-Latin digits in |year=;</comment>
      <origin>4845</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="57727" sha1="o57erwwu070hhwlma2ud0gony8km56x" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array;															-- imported functions from selected Module:Citation/CS1/Utilities
local cfg;																		-- table of tables imported from selected Module:Citation/CS1/Configuration


--[[--------------------------&lt; F I L E - S C O P E   D E C L A R A T I O N S &gt;--------------------------------

File-scope variables are declared here

]]

local lang_object = mw.getContentLanguage();									-- used by is_valid_accessdate(), is_valid_year(), date_name_xlate(); TODO: move to ~/Configuration?
local year_limit;																-- used by is_valid_year()


--[=[-------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |accessdate= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-Engish date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate().  To get around that
call this function with YYYY-MM-DD format dates.

]=]

local function is_valid_accessdate (accessdate)
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold unix time stamps representing the dates

	good1, access_ts = pcall (lang_object.formatDate, lang_object, 'U', accessdate );			-- convert accessdate value to unix timesatmp 
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which which tonumber() may not understand
		access_ts = tonumber (access_ts) or lang_object:parseFormattedNumber (access_ts);			-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to unix time stamp
	end

	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end


--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct. If not a valid month, returns 0

]]

local function get_month_number (month)
	return cfg.date_names['local'].long[month] or cfg.date_names['local'].short[month] or		-- look for local names first
			cfg.date_names['en'].long[month] or	cfg.date_names['en'].short[month] or			-- failing that, look for English names
			0;																					-- not a recognized month name
end


--[[--------------------------&lt; I S _ V A L I D _ E M B A R G O _ D A T E &gt;------------------------------------

returns true and date value if that value has proper dmy, mdy, ymd format.

returns false and 9999 (embargoed forever) when date value is not proper format; assumes that when |embargo= is
set, the editor intended to embargo a pmc but |embargo= does not hold a single date.

]]

local function is_valid_embargo_date (v)
	if v:match ('^%d%d%d%d%-%d%d%-%d%d$') or									-- ymd
		v:match ('^%d%d?%s+%a+%s+%d%d%d%d$') or									-- dmy
		v:match ('^%a+%s+%d%d?%s*,%s*%d%d%d%d$') then							-- mdy
			return true, v;
	end
	return false, '9999';														-- if here not good date so return false and set embargo date to long time in future
end


--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 1 for Winter, etc.  Capitalization and spelling must be correct. If not a valid season, returns 0

Uses ISO DIS 8601 2016 part 2 §4.7  Divisions of a year for hemishpere-independent seasons:
	21-24 = Spring, Summer, Autumn, Winter, independent of “Hemisphere”

These additional divisions not currently supported:
	25-28 = Spring - Northern Hemisphere, Summer- Northern Hemisphere, Autumn - Northern Hemisphere, Winter - Northern Hemisphere
	29-32 = Spring – Southern Hemisphere, Summer– Southern Hemisphere, Autumn – Southern Hemisphere, Winter - Southern Hemisphere
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)

]]

local function get_season_number (season)
	return cfg.date_names['local'].season[season] or							-- look for local names first
			cfg.date_names['en'].season[season] or								-- failing that, look for English names
			0;																	-- not a recognized season name
end


--[[--------------------------&lt; I S _ P R O P E R _ N A M E &gt;--------------------------------------------------

returns a non-zero number if date contains a recognized proper name.  Capitalization and spelling must be correct.

]]

local function is_proper_name (name)
	return cfg.date_names['local'].named[name] or								-- look for local names dates first
			cfg.date_names['en'].named[name] or									-- failing that, look for English names
			0;																	-- not a recognized named date
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ O R _ S E A S O N &gt;------------------------------

--returns true if month or season is valid (properly spelled, capitalized, abbreviated)

]]

local function is_valid_month_or_season (month_season)
	if 0 == get_month_number (month_season) then								-- if month text isn't one of the twelve months, might be a season
		if 0 == get_season_number (month_season) then							-- not a month, is it a season?
			return false;														-- return false not a month or one of the five seasons
		end
	end
	return true;
end


--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one year in the future are not acceptable.

]]

local function is_valid_year(year)
	if not is_set(year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;									-- global variable so we only have to fetch it once
	end

	year = tonumber (year) or lang_object:parseFormattedNumber (year);			-- convert to numbers for the comparison;
	return year and (year &lt;= year_limit) or false;
end


--[[--------------------------&lt; I S _ V A L I D _ D A T E &gt;----------------------------------------------------
Returns true if day is less than or equal to the number of days in month and year is no farther into the future
than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap
years before 1582 and Gregorian leap years after 1582. Where the two calendars overlap (1582 to approximately
1923) dates are assumed to be Gregorian.

]]

local function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year(year) then												-- no farther into the future than next year
		return false;
	end
	
	month = tonumber(month);													-- required for YYYY-MM-DD dates
	
	if (2==month) then															-- if February
		month_length = 28;														-- then 28 days unless
		if 1582 &gt; tonumber(year) then											-- Julian calendar
			if 0==(year%4) then													-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		else																	-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then			-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
There is a special test for May because it can be either short or long form.

Returns true when style for both months is the same

]]

local function is_valid_month_range_style (month1, month2)
local len1 = month1:len();
local len2 = month2:len();
	if len1 == len2 then
		return true;															-- both months are short form so return true
	elseif 'May' == month1 or 'May'== month2 then
		return true;															-- both months are long form so return true
	elseif 3 == len1 or 3 == len2 then
		return false;															-- months are mixed form so return false
	else
		return true;															-- both months are long form so return true
	end
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

All season ranges are accepted as valid because there are publishers out there who have published a Summer–Spring YYYY issue so ... ok

]]

local function is_valid_month_season_range(range_start, range_end)
	local range_start_number = get_month_number (range_start);
	local range_end_number;
	
	if 0 == range_start_number then												-- is this a month range?
		range_start_number = get_season_number (range_start);					-- not a month; is it a season? get start season number
		range_end_number = get_season_number (range_end);						-- get end season number

		if (0 ~= range_start_number) and (0 ~= range_end_number) then
			return true;														-- any season pairing is accepted
		end
		return false;															-- range_start and/or range_end is not a season
	end
																				-- here when range_start is a month
	range_end_number = get_month_number (range_end);							-- get end month number
	if range_start_number &lt; range_end_number then								-- range_start is a month; does range_start precede range_end?
		if is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
		end
	end
	return false;																-- range_start month number is greater than or equal to range end number; or range end isn't a month
end


--[[--------------------------&lt; M A K E _ C O I N S _ D A T E &gt;------------------------------------------------

This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1.  The function is called only for |date= parameters and only if the |date=&lt;value&gt; is 
determined to be a valid date format.  The question of what to do with invalid date formats is not answered here.

The date parts in the input table are converted to an ISO 8601 conforming date string:
	single whole dates:		yyyy-mm-dd
	month and year dates:	yyyy-mm
	year dates:				yyyy
	ranges:					yyyy-mm-dd/yyyy-mm-dd
							yyyy-mm/yyyy-mm
							yyyy/yyyy

Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.

The input table has:
	year, year2 – always present; if before 1582, ignore months and days if present
	month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 99 Christmas
	day, day2 –  0 if not provided, 1-31 for days
	
the output table receives:
	rftdate:	an IS8601 formatted date
	rftchron:	a free-form version of the date, usually without year which is in rftdate (season ranges and propername dates)
	rftssn:		one of four season keywords: winter, spring, summer, fall (lowercase)

]]

local function make_COinS_date (input, tCOinS_date)
	local date;																	-- one date or first date in a range
	local date2 = '';															-- end of range date
-- start temporary Julian / Gregorian calendar uncertainty detection
	local year = tonumber(input.year);											-- this temporary code to determine the extent of sources dated to the Julian/Gregorian
	local month = tonumber(input.month);										-- interstice 1 October 1582 – 1 January 1926
	local day = tonumber (input.day);
	if (0 ~= day) and															-- day must have a value for this to be a whole date
		(((1582 == year) and (10 &lt;= month) and (12 &gt;= month)) or				-- any whole 1582 date from 1 october to 31 December or
			((1926 == year) and (1 == month) and (1 == input.day)) or			-- 1 January 1926 or
				((1582 &lt; year) and (1925 &gt;= year))) then						-- any date 1 January 1583 – 31 December 1925
					tCOinS_date.inter_cal_cat = true;							-- set category flag true
	end
-- end temporary Julian / Gergorian calendar uncertainty detection
	
	if 1582 &gt; tonumber(input.year) or 20 &lt; tonumber(input.month) then			-- Julian calendar or season so &amp;rft.date gets year only
		date = input.year;
		if 0 ~= input.year2 and input.year ~= input.year2 then					-- if a range, only the second year portion when not the same as range start year
			date = string.format ('%.4d/%.4d', tonumber(input.year), tonumber(input.year2))		-- assemble the date range
		end
		if 20 &lt; tonumber(input.month) then										-- if season or propername date
			local season = {[24]='winter', [21]='spring', [22]='summer', [23]='fall', [99]='Christmas'};	-- seasons lowercase, no autumn; proper names use title case
			if 0 == input.month2 then											-- single season date
				if 30 &lt;tonumber(input.month) then
					tCOinS_date.rftchron = season[input.month];					-- proper name dates
				else
					tCOinS_date.rftssn = season[input.month];					-- seasons
				end
			else																-- season range with a second season specified
				if input.year ~= input.year2 then								-- season year – season year range or season year–year
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					if 0~= input.month2 then
						tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);
					end
				else															-- season–season year range
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2];	-- season–season year range
				end
			end
		end
		tCOinS_date.rftdate = date;
		return;																	-- done
	end
	
	if 0 ~= input.day then
		date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day));	-- whole date
	elseif 0 ~= input.month then
		date = string.format ('%s-%.2d', input.year, tonumber(input.month));	-- year and month
	else
		date = string.format ('%s', input.year);								-- just year
	end

	if 0 ~= input.year2 then
		if 0 ~= input.day2 then
			date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2));		-- whole date
		elseif 0 ~= input.month2 then
			date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2));	-- year and month
		else
			date2 = string.format ('/%s', input.year2);							-- just year
		end
	end
	
	tCOinS_date.rftdate = date .. date2;										-- date2 has the '/' separator
	return;
end


--[[--------------------------&lt; P A T T E R N S &gt;--------------------------------------------------------------

this is the list of patterns for date formats that this module recognizes.  Approximately the first half of these
patterns represent formats that might be reformatted into another format.  Those that might be reformatted have
'indicator' letters that identify the content of the matching capture: 'd' (day), 'm' (month), 'a' (anchor year),
'y' (year); second day, month, year have a '2' suffix.

These patterns are used for both date validation and for reformatting.  This table should not be moved to ~/Configuration
because changes to this table require changes to check_date() and to reformatter() and reformat_date()

]]

local patterns = {
	 																			-- year-initial numerical year-month-day
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'},					
																				-- month-initial: month day, year
	['Mdy'] = {'^(%D-) +([1-9]%d?), +((%d%d%d%d?)%a?)$', 'm', 'd', 'a', 'y'},
																				-- month-initial day range: month day–day, year; days are separated by endash
	['Md-dy'] = {'^(%D-) +([1-9]%d?)[%-–]([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'd2', 'a', 'y'},
																				-- day-initial: day month year
	['dMy'] = {'^([1-9]%d?) *(%D-) +((%d%d%d%d?)%a?)$', 'd', 'm', 'a', 'y'},
																				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed; not supported at en.wiki
--	['yMd'] = {'^((%d%d%d%d?)%a?) +(%D-) +(%d%d?)$', 'a', 'y', 'm', 'd'},
																				-- day-range-initial: day–day month year; days are separated by endash
	['d-dMy'] = {'^([1-9]%d?)[%-–]([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'd2', 'm', 'a', 'y'},
																				-- day initial month-day-range: day month - day month year; uses spaced endash
	['dM-dMy'] = {'^([1-9]%d?) +(%D-) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'd2', 'm2', 'a', 'y'},
																				-- month initial month-day-range: month day – month day, year;  uses spaced endash
	['Md-Mdy'] = {'^(%D-) +([1-9]%d?) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$','m', 'd', 'm2', 'd2', 'a', 'y'},
																				-- day initial month-day-year-range: day month year - day month year; uses spaced endash
	['dMy-dMy'] = {'^([1-9]%d?) +(%D-) +(%d%d%d%d) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'y', 'd2', 'm2', 'a', 'y2'},
																				-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
	['Mdy-Mdy'] = {'^(%D-) +([1-9]%d?), +(%d%d%d%d) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'y', 'm2', 'd2', 'a', 'y2'},

																				-- these date formats cannot be converted, per se, but month name can be rendered short or long
																				-- month/season year - month/season year; separated by spaced endash
	['My-My'] = {'^(%D-) +(%d%d%d%d) +[%-–] +(%D-) +((%d%d%d%d)%a?)$', 'm', 'y', 'm2', 'a', 'y2'},
																				-- month/season range year; months separated by endash
	['M-My'] = {'^(%D-)[%-–](%D-) +((%d%d%d%d)%a?)$', 'm', 'm2', 'a', 'y'},
																				-- month/season year or proper-name year
	['My'] = {'^([^%d–]-) +((%d%d%d%d)%a?)$', 'm', 'a', 'y'},					-- this way because endash is a member of %D; %D- will match January–March 2019 when it shouldn't
																				-- these date formats cannot be converted
	['Sy4-y2'] = {'^(%D-) +((%d%d)%d%d)[%-–]((%d%d)%a?)$'},						-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
	['Sy-y'] = {'^(%D-) +(%d%d%d%d)[%-–]((%d%d%d%d)%a?)$'},						-- special case Winter/Summer year-year; year separated with unspaced endash
	['y-y'] = {'^(%d%d%d%d?)[%-–]((%d%d%d%d?)%a?)$'},							-- year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
	['y4-y2'] = {'^((%d%d)%d%d)[%-–]((%d%d)%a?)$'},								-- year range: YYYY–YY; separated by unspaced endash
	['y'] = {'^((%d%d%d%d?)%a?)$'},												-- year; here accept either YYY or YYYY
	}


--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only
allowed range separator is endash.  Additionally, check the date to see that it is a real date: no 31 in 30-day
months; no 29 February when not a leap year.  Months, both long-form and three character abbreviations, and seasons
must be spelled correctly.  Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and
COinS_date.  When this happens, the date parameter is used in the COinS metadata and the CITEREF identifier gets
its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc.)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is ISO 8601 format date; see make_COInS_date()

]]

local function check_date (date_string, tCOinS_date, test_accessdate)
	local year;			-- assume that year2, months, and days are not used;
	local year2=0;		-- second year in a year range
	local month=0;
	local month2=0;		-- second month in a month range
	local day=0;
	local day2=0;		-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match (patterns['ymd'][1]) then								-- year-initial numerical year month day format
		year, month, day=date_string:match (patterns['ymd'][1]);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or 0 == tonumber(day) then return false; end	-- month or day number not valid or not Gregorian calendar
		anchor_year = year;
	
	elseif mw.ustring.match(date_string, patterns['Mdy'][1]) then				-- month-initial: month day, year
		month, day, anchor_year, year=mw.ustring.match(date_string, patterns['Mdy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
				
	elseif mw.ustring.match(date_string, patterns['Md-dy'][1]) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year=mw.ustring.match(date_string, patterns['Md-dy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2=month;															-- for metadata
		year2=year;

	elseif mw.ustring.match(date_string, patterns['dMy'][1]) then				-- day-initial: day month year
		day, month, anchor_year, year=mw.ustring.match(date_string, patterns['dMy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months

--[[ NOT supported at en.wiki
	elseif mw.ustring.match(date_string, patterns['yMd'][1]) then				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed
		anchor_year, year, month, day=mw.ustring.match(date_string, patterns['yMd'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
-- end NOT supported at en.wiki ]]

	elseif mw.ustring.match(date_string, patterns['d-dMy'][1]) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year=mw.ustring.match(date_string, patterns['d-dMy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2=month;															-- for metadata
		year2=year;

	elseif mw.ustring.match(date_string, patterns['dM-dMy'][1]) then			-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year=mw.ustring.match(date_string, patterns['dM-dMy'][1]);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif mw.ustring.match(date_string, patterns['Md-Mdy'][1]) then			-- month initial month-day-range: month day – month day, year;  uses spaced endash
		month, day, month2, day2, anchor_year, year=mw.ustring.match(date_string, patterns['Md-Mdy'][1]);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif mw.ustring.match(date_string, patterns['dMy-dMy'][1]) then			-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2=mw.ustring.match(date_string, patterns['dMy-dMy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);

	elseif mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]) then			-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
		month, day, year, month2, day2, anchor_year, year2=mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);

	elseif mw.ustring.match(date_string, patterns['Sy4-y2'][1]) then			-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		local century;
		month, year, century, anchor_year, year2=mw.ustring.match(date_string, patterns['Sy4-y2'][1]);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;		-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;										-- assemble anchor_year from both years
		year2 = century..year2;													-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		month = get_season_number (month);

	elseif mw.ustring.match(date_string, patterns['Sy-y'][1]) then				-- special case Winter/Summer year-year; year separated with unspaced endash
		month, year, anchor_year, year2=mw.ustring.match(date_string, patterns['Sy-y'][1]);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;		-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;										-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		month = get_season_number (month);										-- for metadata

	elseif mw.ustring.match(date_string, patterns['My-My'][1]) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2=mw.ustring.match(date_string, patterns['My-My'][1]);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then 	-- both must be month year, same month style
			month = get_month_number(month);
			month2 = get_month_number(month2);
		elseif 0 ~= get_season_number(month) and 0 ~= get_season_number(month2) then	-- both must be or season year, not mixed
			month = get_season_number(month);
			month2 = get_season_number(month2);
		else
			 return false;
		end

	elseif mw.ustring.match(date_string, patterns['M-My'][1]) then				-- month/season range year; months separated by endash 
		month, month2, anchor_year, year=mw.ustring.match(date_string, patterns['M-My'][1]);
		if (not is_valid_month_season_range(month, month2)) or (not is_valid_year(year)) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
			month2 = get_month_number(month2);
		else
			month = get_season_number(month);
			month2 = get_season_number(month2);
		end
		year2=year;
		
	elseif mw.ustring.match(date_string, patterns['My'][1]) then				-- month/season year or proper-name year
		month, anchor_year, year=mw.ustring.match(date_string, patterns['My'][1]);
		if not is_valid_year(year) then return false; end
		if not is_valid_month_or_season (month) and 0 == is_proper_name (month) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
		elseif 0 ~= get_season_number(month) then
			month = get_season_number(month);
		else
			month = is_proper_name (month);										-- must be proper name; not supported in COinS
		end

	elseif mw.ustring.match(date_string, patterns['y-y'][1]) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2=mw.ustring.match(date_string, patterns['y-y'][1]);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, patterns['y4-y2'][1]) then				-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2=mw.ustring.match(date_string, patterns['y4-y2'][1]);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century..year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match (date_string, patterns['y'][1]) then				-- year; here accept either YYY or YYYY
		anchor_year, year=mw.ustring.match (date_string, patterns['y'][1]);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;															-- date format not one of the MOS:DATE approved formats
	end

	if test_accessdate then														-- test accessdate here because we have numerical date parts
		if 0 ~= year and 0 ~= month and 0 ~= day and 							-- all parts of a single date required
			0 == year2 and 0 == month2 and 0 == day2 then						-- none of these; accessdate must not be a range
				if not is_valid_accessdate (year..'-'..month..'-'..day) then	
					return false;												-- return false when accessdate out of bounds
				end
		else
			return false;														-- return false when accessdate is a range of two dates
		end
	end

	local result=true;															-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result=is_valid_date(year,month,day);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month2,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year2,month2,day2);
	end
	
	if false == result then return false; end

	if nil ~= tCOinS_date then													-- this table only passed into this function when testing |date= parameter values
		make_COinS_date ({year=year, month=month, day=day, year2=year2, month2=month2, day2=day2}, tCOinS_date);	-- make an ISO 8601 date string for COinS
	end
	
	return true, anchor_year;													-- format is good and date string represents a real date
end	


--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.

]]

local function dates(date_parameters_list, tCOinS_date)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local embargo_date;															-- if embargo date is a good dmy, mdy, ymd date then holds original value else reset to 9999
	local error_message = &quot;&quot;;
	local good_date = false;
	
	for k, v in pairs(date_parameters_list) do									-- for each date-holding parameter in the list
		if is_set(v.val) then													-- if the parameter has a value
			v.val = mw.ustring.gsub (v.val, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9
			if v.val:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then						-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v.val:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);				-- get the year portion so it can be tested
				if 'date'==k then
					anchor_year, COinS_date = v.val:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year'==k then
					good_date = is_valid_year(year);
				end
			elseif 'date'==k then												-- if the parameter is |date=
				if v.val:match(&quot;^n%.d%.%a?$&quot;) then								-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v.val:match(&quot;^nd%a?$&quot;) then								-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v.val, tCOinS_date);	-- go test the date
				end
			elseif 'year'==k then												-- if the parameter is |year= it should hold only a year value
				if v.val:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then						-- if |year= 3 or 4 digits only with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((%d+)%a?)&quot;);
				end
			elseif 'access-date'==k then										-- if the parameter is |date=
				good_date = check_date (v.val, nil, true);						-- go test the date; nil is a placeholder; true is the test_accessdate flag
			elseif 'embargo'==k then											-- if the parameter is |embargo=
				good_date = check_date (v.val);									-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date, embargo_date = is_valid_embargo_date (v.val);	-- is |embargo= date a single dmy, mdy, or ymd formatted date? yes:returns embargo; no: returns 9999
				end
			else																-- any other date-holding parameter
				good_date = check_date (v.val);									-- go test the date
			end
			if false==good_date then											-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then									-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;						-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. v.name .. &quot;=&quot;;		-- add the failed parameter
			end
		end
	end
	return anchor_year, embargo_date, error_message;							-- and done
end


--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function returns a numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

]]

local function year_date_check (year_string, date_string)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes
	
	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where both date and year are required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard range formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif mw.ustring.match(date_string, &quot;%d%d%d%d[%-–]%d%d&quot;) then				-- YYYY-YY date ranges
		local century;
		date1, century, date2 = mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	else
		result = 0;																-- no recognizable year in date
	end
	return result;
end


--[[--------------------------&lt; R E F O R M A T T E R &gt;--------------------------------------------------------

reformat 'date' into new format specified by format_param if pattern_idx (the current format of 'date') can be
reformatted.  Does the grunt work for reformat_dates().

The table re_formats maps patern_idx (current format) and format_param (desired format) to a table that holds:
	format string used by string.format()
	identifier letters ('d', 'm', 'y', 'd2', 'm2', 'y2') that serve as indexes into a table t{} that holds captures
		from mw.ustring.match() for the various date parts specified by  patterns[pattern_idx][1]

Items in patterns{} have the general form:
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'}, where:
		['ymd'] is pattern_idx
		patterns['ymd'][1] is the match pattern with captures for mw.ustring.match()
		patterns['ymd'][2] is an indicator letter identifying the content of the first capture
		patterns['ymd'][3] ... the second capture etc

when a pattern matches a date, the captures are loaded into table t{} in capture order using the idemtifier
characters as indexes into t{}  For the above, a ymd date is in t{} as:
	t.y = first capture (year), t.m = second capture (month), t.d = third capture (day)

To reformat, this function is called with the pattern_idx that matches the current format of the date and with
format_param set to the desired format.  This function loads table t{} as described and then calls string.format()
with the format string specified by re_format[pattern_idx][format_param][1] using values taken from t{} according
to the capture identifier letters specified by patterns[pattern_idx][format_param][n] where n is 2..

]]

local re_formats = {
	['ymd'] = {																	-- date format is ymd; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},									-- |df=yMd; not supported at en.wiki
		},
	['Mdy'] = {																	-- date format is Mdy; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- for long/short reformatting
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},									-- |df=yMd; not supported at en.wiki
		},
	['dMy'] = {																	-- date format is dMy; reformat to:
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- for long/short reformatting
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},									-- |df=yMd; not supported at en.wiki
		},
	['Md-dy'] = {																-- date format is Md-dy; reformat to:
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- for long/short reformatting
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- |df=dmy -&gt; d-dMy 
		},
	['d-dMy'] = {																-- date format is d-d&gt;y; reformat to:
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- for long/short reformatting
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- |df=mdy -&gt; Md-dy 
		},
	['dM-dMy'] = {																-- date format is dM-dMy; reformat to:
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- for long/short reformatting
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd', 'm2', 'd2', 'y'},				-- |df=mdy -&gt; Md-Mdy 
		},
	['Md-Mdy'] = {																-- date format is Md-Mdy; reformat to:
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd',  'm2', 'd2', 'y'},			-- for long/short reformatting
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- |df=dmy -&gt; dM-dMy 
		},
	['dMy-dMy'] = {																-- date format is dMy-dMy; reformat to:
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- for long/short reformatting
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- |df=mdy -&gt; Mdy-Mdy 
		},
	['Mdy-Mdy'] = {																-- date format is Mdy-Mdy; reformat to:
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- for long/short reformatting
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- |df=dmy -&gt; dMy-dMy 
		},
	['My-My'] = {																-- these for long/short reformatting
		['any'] = {'%s %s – %s %s', 'm', 'y', 'm2', 'y2'},						-- dmy/mdy agnostic
		},
	['M-My'] = {																-- these for long/short reformatting
		['any'] = {'%s–%s %s', 'm', 'm2', 'y'},									-- dmy/mdy agnostic
		},
	['My'] = {																	-- these for long/short reformatting
		['any'] = {'%s %s', 'm', 'y'},											-- dmy/mdy agnostic
		},
--	['yMd'] = {																	-- not supported at en.wiki
--		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
--		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
--		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
--		},
	}


local function reformatter (date, pattern_idx, format_param, mon_len)
	if not in_array (pattern_idx, {'ymd', 'Mdy', 'Md-dy', 'dMy', 'yMd', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- not in this set of date format patterns then not a reformattable date
	end
	
	if 'ymd' == format_param and in_array (pattern_idx, {'ymd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- ymd date ranges not supported at en.wiki; no point in reformatting ymd to ymd
	end

	if in_array (pattern_idx, {'My', 'M-My', 'My-My'}) then						-- these are not dmy/mdy so can't be 'reformatted' into either
		format_param = 'any';													-- so format-agnostic 
	end

--	if 'yMd' == format_param and in_array (pattern_idx, {'yMd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy'}) then	-- not supported at en.wiki
	if 'yMd' == format_param then												-- not supported at en.wiki
		return;																	-- not a reformattable date
	end
	
	local c1, c2, c3, c4, c5, c6, c7;											-- these hold the captures specified in patterns[pattern_idx][1]
	c1, c2, c3, c4, c5, c6, c7 = mw.ustring.match (date, patterns[pattern_idx][1]);	-- get the captures

	local t = {																	-- table that holds k/v pairs of date parts from the captures and patterns[pattern_idx][2..]
		[patterns[pattern_idx][2]] = c1;										-- at minimum there is always one capture with a matching indicator letter
		[patterns[pattern_idx][3] or 'x'] = c2;									-- patterns can have a variable number of captures; each capture requires an indicator letter;
		[patterns[pattern_idx][4] or 'x'] = c3;									-- where there is no capture, there is no indicator letter so n in patterns[pattern_idx][n] will be nil;
		[patterns[pattern_idx][5] or 'x'] = c4;									-- the 'x' here spoofs an indicator letter to prevent 'table index is nil' error
		[patterns[pattern_idx][6] or 'x'] = c5;
		[patterns[pattern_idx][7] or 'x'] = c6;
		[patterns[pattern_idx][8] or 'x'] = c7;
		};

	if tonumber(t.m) then														-- if raw month is a number (converting from ymd)
		if 's' == mon_len then													-- if we are to use abbreviated month names
			t.m = cfg.date_names['inv_local_s'][tonumber(t.m)];					-- convert it to a month name
		else
			t.m = cfg.date_names['inv_local_l'][tonumber(t.m)];					-- convert it to a month name
		end
		t.d = t.d:gsub ('0(%d)', '%1');											-- strip leading '0' from day if present
	elseif 'ymd' == format_param then											-- when converting to ymd
		if 1582 &gt; tonumber(t.y) then											-- ymd format dates not allowed before 1582
			return;
		end
		t.m = string.format ('%02d', get_month_number (t.m));					-- make sure that month and day are two digits
		t.d = string.format ('%02d', t.d);
	elseif mon_len then															-- if mon_len is set to either 'short' or 'long'
		for _, mon in ipairs ({'m', 'm2'}) do									-- because there can be two month names, check both 
			if t[mon] then
				t[mon] = get_month_number (t[mon]);								-- get the month number for this month (is length agnostic)
				if 0 == t[mon] then return; end									-- seasons and named dates can't be converted
				t[mon] = (('s' == mon_len) and cfg.date_names['inv_local_s'][t[mon]]) or cfg.date_names['inv_local_l'][t[mon]];	-- fetch month name according to length
			end
		end
	end

	local new_date = string.format (re_formats[pattern_idx][format_param][1],	-- format string
		t[re_formats[pattern_idx][format_param][2]],							-- named captures from t{}
		t[re_formats[pattern_idx][format_param][3]],
		t[re_formats[pattern_idx][format_param][4]],
		t[re_formats[pattern_idx][format_param][5]],
		t[re_formats[pattern_idx][format_param][6]],
		t[re_formats[pattern_idx][format_param][7]],
		t[re_formats[pattern_idx][format_param][8]]
		);

	return new_date;
end


--[[-------------------------&lt; R E F O R M A T _ D A T E S &gt;--------------------------------------------------

Reformats existing dates into the format specified by format.

format is one of several manual keywords: dmy, dmy-all, mdy, mdy-all, ymd, ymd-all.  The -all version includes
access- and archive-dates; otherwise these dates are not reformatted.

This function allows automatic date formatting.  In ~/Configuration, the article source is searched for one of
the {{use xxx dates}} templates.  If found, xxx becomes the global date format as xxx-all.  If |cs1-dates= in
{{use xxx dates}} has legitimate value then that value determines how cs1|2 dates will be rendered.  Legitimate
values for |cs1-dates= are:
	l - all dates are rendered with long month names
	ls - publication dates use long month names; access-/archive-dates use abbreviated month names
	ly - publication dates use long month names; access-/archive-dates rendered in ymd format
	s - all dates are rendered with abbreviated (short) month names
	sy - publication dates use abbreviated month names; access-/archive-dates rendered in ymd format
	y - all dates are rendered in ymd format

the format argument for automatic date formatting will be the format specified by {{use xxx dates}} with the
value supplied by |cs1-dates so one of: xxx-l, xxx-ls, xxx-ly, xxx-s, xxx-sy, xxx-y, or simply xxx (|cs1-dates=
empty, omitted, or invalid) where xxx shall be either of dmy or mdy.

dates are extracted from date_parameters_list, reformatted (if appropriate), and then written back into the
list in the new format.  Dates in date_parameters_list are presumed here to be valid (no errors).  This function
returns true when a date has been reformatted, false else.  Actual reformatting is done by reformatter().

]]

local function reformat_dates (date_parameters_list, format)
	local all = false;															-- set to false to skip access- and archive-dates
	local len_p = 'l';															-- default publication date length shall be long
	local len_a = 'l';															-- default access-/archive-date length shall be long
	local result = false;
	local new_date;																
	
	if format:match('%a+%-all') then											-- manual df keyword; auto df keyword when length not specified in {{use xxx dates}}; 
		format = format:match('(%a+)%-all');									-- extract the format
		all = true;																-- all dates are long format dates because this keyword doesn't specify length
	elseif format:match('%a+%-[lsy][sy]?') then									-- auto df keywords; internal only
		all = true;																-- auto df applies to all dates; use length specified by capture len_p for all dates
		format, len_p, len_a = format:match('(%a+)%-([lsy])([sy]?)');			-- extract the format and length keywords
		if 'y' == len_p then													-- because allowed by MOS:DATEUNIFY (sort of) range dates and My dates not reformatted
			format = 'ymd';														-- override {{use xxx dates}}
		elseif (not is_set(len_a)) or (len_p == len_a) then						-- no access-/archive-date length specified or same length as publication dates then
			len_a = len_p;														-- in case len_a not set
		end
	end																			-- else only publication dates and they are long

	for param_name, param_val in pairs (date_parameters_list) do				-- for each date-holding parameter in the list
		if is_set (param_val.val) then											-- if the parameter has a value
			if not (not all and in_array (param_name, {'access-date', 'archive-date'})) then	-- skip access- or archive-date unless format is xxx-all; yeah, ugly; TODO: find a better way
				for pattern_idx, pattern in pairs (patterns) do
					if mw.ustring.match (param_val.val, pattern[1]) then
						if all and in_array (param_name, {'access-date', 'archive-date'}) then	-- if this date is an access- or archive-date
							new_date = reformatter (param_val.val, pattern_idx, (('y' == len_a) and 'ymd') or format, len_a);	-- choose ymd or dmy/mdy according to len_a setting
						else													-- all other dates
							new_date = reformatter (param_val.val, pattern_idx, format, len_p);
						end
						
						if new_date then										-- set when date was reformatted
							date_parameters_list[param_name].val = new_date;	-- update date in date list
							result = true;										-- and announce that changes have been made
						end
					end	-- if
				end		-- for
			end			-- if
		end				-- if
	end					-- for
return result;																	-- declare boolean result and done
end


--[[--------------------------&lt; D A T E _ H Y P H E N _ T O _ D A S H &gt;----------------------------------------

Loops through the list of date-holding parameters and converts any hyphen to an ndash.  Not called if the cs1|2
template has any date errors.

Modifies the date_parameters_list and returns true if hyphens are replaced, else returns false.

]]

local function date_hyphen_to_dash (date_parameters_list)
	local result = false;
	local n;
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set (param_val.val) then
			if not mw.ustring.match (param_val.val, '%d%d%d%d%-%d%d%-%d%d') then	-- for those that are not ymd dates (ustring because here digits may not be western)
				param_val.val, n = param_val.val:gsub ('%-', '–');				-- replace any hyphen with ndash
				if 0 ~= n then
					date_parameters_list[param_name].val = param_val.val;		-- update the list
					result = true;
				end
			end
		end
	end
	return result;																-- so we know if any hyphens were replaced
end


--[[-------------------------&lt; D A T E _ N A M E _ X L A T E &gt;------------------------------------------------

Attempts to translate English month names to local-language month names using names supplied by MediaWiki's
date parser function.  This is simple name-for-name replacement and may not work for all languages.

if xlat_dig is true, this function will also translate western (English) digits to the local language's digits.
This will also translate ymd dates.

]]

local function	date_name_xlate (date_parameters_list, xlt_dig)
	local xlate;
	local mode;																	-- long or short month names
	local modified = false;
	local date;
	
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val.val) then											-- if the parameter has a value
			date = param_val.val;
			for month in mw.ustring.gmatch (date, '%a+') do						-- iterate through all dates in the date (single date or date range)
				if cfg.date_names.en.long[month] then
					mode = 'F';													-- English name is long so use long local name
				elseif cfg.date_names.en.short[month] then
					mode = 'M';													-- English name is short so use short local name
				else
					mode = nil;													-- not an English month name; could be local language month name or an English season name
				end
		
				if mode then													-- might be a season
					xlate = lang_object:formatDate(mode, '1' .. month);			-- translate the month name to this local language
					date = mw.ustring.gsub (date, month, xlate);				-- replace the English with the translation
					date_parameters_list[param_name].val = date;				-- save the translated date
					modified = true;
				end
			end

			if xlt_dig then														-- shall we also translate digits?
				date = date:gsub ('%d', cfg.date_names.xlate_digits);			-- translate digits from western to 'local digits'
				date_parameters_list[param_name].val = date;					-- save the translated date
				modified = true;
			end
		end
	end
	
	return modified;
	end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	is_set = utilities_page_ptr.is_set;											-- import functions from selected Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;										-- import functions from selected Module:Citation/CS1/Utilities module
	cfg = cfg_table_ptr;														-- import tables from selected Module:Citation/CS1/Configuration
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {																		-- return exported functions
	dates = dates,
	year_date_check = year_date_check,
	reformat_dates = reformat_dates,
	date_hyphen_to_dash = date_hyphen_to_dash,
	date_name_xlate = date_name_xlate,
	set_selected_modules = set_selected_modules
	}</text>
      <sha1>o57erwwu070hhwlma2ud0gony8km56x</sha1>
    </revision>
    <revision>
      <id>4846</id>
      <parentid>4845</parentid>
      <timestamp>2020-04-18T12:50:48Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4846</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="57727" sha1="2ksocezo4158y8wxm8kabhtrvrzutja" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array;															-- imported functions from selected Module:Citation/CS1/Utilities
local cfg;																		-- table of tables imported from selected Module:Citation/CS1/Configuration


--[[--------------------------&lt; F I L E - S C O P E   D E C L A R A T I O N S &gt;--------------------------------

File-scope variables are declared here

]]

local lang_object = mw.getContentLanguage();									-- used by is_valid_accessdate(), is_valid_year(), date_name_xlate(); TODO: move to ~/Configuration?
local year_limit;																-- used by is_valid_year()


--[=[-------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |accessdate= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-Engish date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate().  To get around that
call this function with YYYY-MM-DD format dates.

]=]

local function is_valid_accessdate (accessdate)
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold unix time stamps representing the dates

	good1, access_ts = pcall (lang_object.formatDate, lang_object, 'U', accessdate );			-- convert accessdate value to unix timesatmp 
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which which tonumber() may not understand
		access_ts = tonumber (access_ts) or lang_object:parseFormattedNumber (access_ts);			-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to unix time stamp
	end

	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end


--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct. If not a valid month, returns 0

]]

local function get_month_number (month)
	return cfg.date_names['local'].long[month] or cfg.date_names['local'].short[month] or		-- look for local names first
			cfg.date_names['en'].long[month] or	cfg.date_names['en'].short[month] or			-- failing that, look for English names
			0;																					-- not a recognized month name
end


--[[--------------------------&lt; I S _ V A L I D _ E M B A R G O _ D A T E &gt;------------------------------------

returns true and date value if that value has proper dmy, mdy, ymd format.

returns false and 9999 (embargoed forever) when date value is not proper format; assumes that when |embargo= is
set, the editor intended to embargo a pmc but |embargo= does not hold a single date.

]]

local function is_valid_embargo_date (v)
	if v:match ('^%d%d%d%d%-%d%d%-%d%d$') or									-- ymd
		v:match ('^%d%d?%s+%a+%s+%d%d%d%d$') or									-- dmy
		v:match ('^%a+%s+%d%d?%s*,%s*%d%d%d%d$') then							-- mdy
			return true, v;
	end
	return false, '9999';														-- if here not good date so return false and set embargo date to long time in future
end


--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 1 for Winter, etc.  Capitalization and spelling must be correct. If not a valid season, returns 0

Uses ISO DIS 8601 2016 part 2 §4.7  Divisions of a year for hemishpere-independent seasons:
	21-24 = Spring, Summer, Autumn, Winter, independent of “Hemisphere”

These additional divisions not currently supported:
	25-28 = Spring - Northern Hemisphere, Summer- Northern Hemisphere, Autumn - Northern Hemisphere, Winter - Northern Hemisphere
	29-32 = Spring – Southern Hemisphere, Summer– Southern Hemisphere, Autumn – Southern Hemisphere, Winter - Southern Hemisphere
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)

]]

local function get_season_number (season)
	return cfg.date_names['local'].season[season] or							-- look for local names first
			cfg.date_names['en'].season[season] or								-- failing that, look for English names
			0;																	-- not a recognized season name
end


--[[--------------------------&lt; I S _ P R O P E R _ N A M E &gt;--------------------------------------------------

returns a non-zero number if date contains a recognized proper name.  Capitalization and spelling must be correct.

]]

local function is_proper_name (name)
	return cfg.date_names['local'].named[name] or								-- look for local names dates first
			cfg.date_names['en'].named[name] or									-- failing that, look for English names
			0;																	-- not a recognized named date
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ O R _ S E A S O N &gt;------------------------------

--returns true if month or season is valid (properly spelled, capitalized, abbreviated)

]]

local function is_valid_month_or_season (month_season)
	if 0 == get_month_number (month_season) then								-- if month text isn't one of the twelve months, might be a season
		if 0 == get_season_number (month_season) then							-- not a month, is it a season?
			return false;														-- return false not a month or one of the five seasons
		end
	end
	return true;
end


--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one year in the future are not acceptable.

]]

local function is_valid_year(year)
	if not is_set(year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;									-- global variable so we only have to fetch it once
	end

	year = tonumber (year) or lang_object:parseFormattedNumber (year);			-- convert to numbers for the comparison;
	return year and (year &lt;= year_limit) or false;
end


--[[--------------------------&lt; I S _ V A L I D _ D A T E &gt;----------------------------------------------------
Returns true if day is less than or equal to the number of days in month and year is no farther into the future
than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap
years before 1582 and Gregorian leap years after 1582. Where the two calendars overlap (1582 to approximately
1923) dates are assumed to be Gregorian.

]]

local function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year(year) then												-- no farther into the future than next year
		return false;
	end
	
	month = tonumber(month);													-- required for YYYY-MM-DD dates
	
	if (2==month) then															-- if February
		month_length = 28;														-- then 28 days unless
		if 1582 &gt; tonumber(year) then											-- Julian calendar
			if 0==(year%4) then													-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		else																	-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then			-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
There is a special test for May because it can be either short or long form.

Returns true when style for both months is the same

]]

local function is_valid_month_range_style (month1, month2)
local len1 = month1:len();
local len2 = month2:len();
	if len1 == len2 then
		return true;															-- both months are short form so return true
	elseif 'May' == month1 or 'May'== month2 then
		return true;															-- both months are long form so return true
	elseif 3 == len1 or 3 == len2 then
		return false;															-- months are mixed form so return false
	else
		return true;															-- both months are long form so return true
	end
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

All season ranges are accepted as valid because there are publishers out there who have published a Summer–Spring YYYY issue so ... ok

]]

local function is_valid_month_season_range(range_start, range_end)
	local range_start_number = get_month_number (range_start);
	local range_end_number;
	
	if 0 == range_start_number then												-- is this a month range?
		range_start_number = get_season_number (range_start);					-- not a month; is it a season? get start season number
		range_end_number = get_season_number (range_end);						-- get end season number

		if (0 ~= range_start_number) and (0 ~= range_end_number) then
			return true;														-- any season pairing is accepted
		end
		return false;															-- range_start and/or range_end is not a season
	end
																				-- here when range_start is a month
	range_end_number = get_month_number (range_end);							-- get end month number
	if range_start_number &lt; range_end_number then								-- range_start is a month; does range_start precede range_end?
		if is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
		end
	end
	return false;																-- range_start month number is greater than or equal to range end number; or range end isn't a month
end


--[[--------------------------&lt; M A K E _ C O I N S _ D A T E &gt;------------------------------------------------

This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1.  The function is called only for |date= parameters and only if the |date=&lt;value&gt; is 
determined to be a valid date format.  The question of what to do with invalid date formats is not answered here.

The date parts in the input table are converted to an ISO 8601 conforming date string:
	single whole dates:		yyyy-mm-dd
	month and year dates:	yyyy-mm
	year dates:				yyyy
	ranges:					yyyy-mm-dd/yyyy-mm-dd
							yyyy-mm/yyyy-mm
							yyyy/yyyy

Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.

The input table has:
	year, year2 – always present; if before 1582, ignore months and days if present
	month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 99 Christmas
	day, day2 –  0 if not provided, 1-31 for days
	
the output table receives:
	rftdate:	an IS8601 formatted date
	rftchron:	a free-form version of the date, usually without year which is in rftdate (season ranges and propername dates)
	rftssn:		one of four season keywords: winter, spring, summer, fall (lowercase)

]]

local function make_COinS_date (input, tCOinS_date)
	local date;																	-- one date or first date in a range
	local date2 = '';															-- end of range date
-- start temporary Julian / Gregorian calendar uncertainty detection
	local year = tonumber(input.year);											-- this temporary code to determine the extent of sources dated to the Julian/Gregorian
	local month = tonumber(input.month);										-- interstice 1 October 1582 – 1 January 1926
	local day = tonumber (input.day);
	if (0 ~= day) and															-- day must have a value for this to be a whole date
		(((1582 == year) and (10 &lt;= month) and (12 &gt;= month)) or				-- any whole 1582 date from 1 october to 31 December or
			((1926 == year) and (1 == month) and (1 == input.day)) or			-- 1 January 1926 or
				((1582 &lt; year) and (1925 &gt;= year))) then						-- any date 1 January 1583 – 31 December 1925
					tCOinS_date.inter_cal_cat = true;							-- set category flag true
	end
-- end temporary Julian / Gergorian calendar uncertainty detection
	
	if 1582 &gt; tonumber(input.year) or 20 &lt; tonumber(input.month) then			-- Julian calendar or season so &amp;rft.date gets year only
		date = input.year;
		if 0 ~= input.year2 and input.year ~= input.year2 then					-- if a range, only the second year portion when not the same as range start year
			date = string.format ('%.4d/%.4d', tonumber(input.year), tonumber(input.year2))		-- assemble the date range
		end
		if 20 &lt; tonumber(input.month) then										-- if season or propername date
			local season = {[24]='winter', [21]='spring', [22]='summer', [23]='fall', [99]='Christmas'};	-- seasons lowercase, no autumn; proper names use title case
			if 0 == input.month2 then											-- single season date
				if 30 &lt;tonumber(input.month) then
					tCOinS_date.rftchron = season[input.month];					-- proper name dates
				else
					tCOinS_date.rftssn = season[input.month];					-- seasons
				end
			else																-- season range with a second season specified
				if input.year ~= input.year2 then								-- season year – season year range or season year–year
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					if 0~= input.month2 then
						tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);
					end
				else															-- season–season year range
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2];	-- season–season year range
				end
			end
		end
		tCOinS_date.rftdate = date;
		return;																	-- done
	end
	
	if 0 ~= input.day then
		date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day));	-- whole date
	elseif 0 ~= input.month then
		date = string.format ('%s-%.2d', input.year, tonumber(input.month));	-- year and month
	else
		date = string.format ('%s', input.year);								-- just year
	end

	if 0 ~= input.year2 then
		if 0 ~= input.day2 then
			date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2));		-- whole date
		elseif 0 ~= input.month2 then
			date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2));	-- year and month
		else
			date2 = string.format ('/%s', input.year2);							-- just year
		end
	end
	
	tCOinS_date.rftdate = date .. date2;										-- date2 has the '/' separator
	return;
end


--[[--------------------------&lt; P A T T E R N S &gt;--------------------------------------------------------------

this is the list of patterns for date formats that this module recognizes.  Approximately the first half of these
patterns represent formats that might be reformatted into another format.  Those that might be reformatted have
'indicator' letters that identify the content of the matching capture: 'd' (day), 'm' (month), 'a' (anchor year),
'y' (year); second day, month, year have a '2' suffix.

These patterns are used for both date validation and for reformatting.  This table should not be moved to ~/Configuration
because changes to this table require changes to check_date() and to reformatter() and reformat_date()

]]

local patterns = {
	 																			-- year-initial numerical year-month-day
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'},					
																				-- month-initial: month day, year
	['Mdy'] = {'^(%D-) +([1-9]%d?), +((%d%d%d%d?)%a?)$', 'm', 'd', 'a', 'y'},
																				-- month-initial day range: month day–day, year; days are separated by endash
	['Md-dy'] = {'^(%D-) +([1-9]%d?)[%-–]([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'd2', 'a', 'y'},
																				-- day-initial: day month year
	['dMy'] = {'^([1-9]%d?) +(%D-) +((%d%d%d%d?)%a?)$', 'd', 'm', 'a', 'y'},
																				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed; not supported at en.wiki
--	['yMd'] = {'^((%d%d%d%d?)%a?) +(%D-) +(%d%d?)$', 'a', 'y', 'm', 'd'},
																				-- day-range-initial: day–day month year; days are separated by endash
	['d-dMy'] = {'^([1-9]%d?)[%-–]([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'd2', 'm', 'a', 'y'},
																				-- day initial month-day-range: day month - day month year; uses spaced endash
	['dM-dMy'] = {'^([1-9]%d?) +(%D-) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'd2', 'm2', 'a', 'y'},
																				-- month initial month-day-range: month day – month day, year;  uses spaced endash
	['Md-Mdy'] = {'^(%D-) +([1-9]%d?) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$','m', 'd', 'm2', 'd2', 'a', 'y'},
																				-- day initial month-day-year-range: day month year - day month year; uses spaced endash
	['dMy-dMy'] = {'^([1-9]%d?) +(%D-) +(%d%d%d%d) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'y', 'd2', 'm2', 'a', 'y2'},
																				-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
	['Mdy-Mdy'] = {'^(%D-) +([1-9]%d?), +(%d%d%d%d) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'y', 'm2', 'd2', 'a', 'y2'},

																				-- these date formats cannot be converted, per se, but month name can be rendered short or long
																				-- month/season year - month/season year; separated by spaced endash
	['My-My'] = {'^(%D-) +(%d%d%d%d) +[%-–] +(%D-) +((%d%d%d%d)%a?)$', 'm', 'y', 'm2', 'a', 'y2'},
																				-- month/season range year; months separated by endash
	['M-My'] = {'^(%D-)[%-–](%D-) +((%d%d%d%d)%a?)$', 'm', 'm2', 'a', 'y'},
																				-- month/season year or proper-name year
	['My'] = {'^([^%d–]-) +((%d%d%d%d)%a?)$', 'm', 'a', 'y'},					-- this way because endash is a member of %D; %D- will match January–March 2019 when it shouldn't
																				-- these date formats cannot be converted
	['Sy4-y2'] = {'^(%D-) +((%d%d)%d%d)[%-–]((%d%d)%a?)$'},						-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
	['Sy-y'] = {'^(%D-) +(%d%d%d%d)[%-–]((%d%d%d%d)%a?)$'},						-- special case Winter/Summer year-year; year separated with unspaced endash
	['y-y'] = {'^(%d%d%d%d?)[%-–]((%d%d%d%d?)%a?)$'},							-- year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
	['y4-y2'] = {'^((%d%d)%d%d)[%-–]((%d%d)%a?)$'},								-- year range: YYYY–YY; separated by unspaced endash
	['y'] = {'^((%d%d%d%d?)%a?)$'},												-- year; here accept either YYY or YYYY
	}


--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only
allowed range separator is endash.  Additionally, check the date to see that it is a real date: no 31 in 30-day
months; no 29 February when not a leap year.  Months, both long-form and three character abbreviations, and seasons
must be spelled correctly.  Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and
COinS_date.  When this happens, the date parameter is used in the COinS metadata and the CITEREF identifier gets
its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc.)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is ISO 8601 format date; see make_COInS_date()

]]

local function check_date (date_string, tCOinS_date, test_accessdate)
	local year;			-- assume that year2, months, and days are not used;
	local year2=0;		-- second year in a year range
	local month=0;
	local month2=0;		-- second month in a month range
	local day=0;
	local day2=0;		-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match (patterns['ymd'][1]) then								-- year-initial numerical year month day format
		year, month, day=date_string:match (patterns['ymd'][1]);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or 0 == tonumber(day) then return false; end	-- month or day number not valid or not Gregorian calendar
		anchor_year = year;
	
	elseif mw.ustring.match(date_string, patterns['Mdy'][1]) then				-- month-initial: month day, year
		month, day, anchor_year, year=mw.ustring.match(date_string, patterns['Mdy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
				
	elseif mw.ustring.match(date_string, patterns['Md-dy'][1]) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year=mw.ustring.match(date_string, patterns['Md-dy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2=month;															-- for metadata
		year2=year;

	elseif mw.ustring.match(date_string, patterns['dMy'][1]) then				-- day-initial: day month year
		day, month, anchor_year, year=mw.ustring.match(date_string, patterns['dMy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months

--[[ NOT supported at en.wiki
	elseif mw.ustring.match(date_string, patterns['yMd'][1]) then				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed
		anchor_year, year, month, day=mw.ustring.match(date_string, patterns['yMd'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
-- end NOT supported at en.wiki ]]

	elseif mw.ustring.match(date_string, patterns['d-dMy'][1]) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year=mw.ustring.match(date_string, patterns['d-dMy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2=month;															-- for metadata
		year2=year;

	elseif mw.ustring.match(date_string, patterns['dM-dMy'][1]) then			-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year=mw.ustring.match(date_string, patterns['dM-dMy'][1]);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif mw.ustring.match(date_string, patterns['Md-Mdy'][1]) then			-- month initial month-day-range: month day – month day, year;  uses spaced endash
		month, day, month2, day2, anchor_year, year=mw.ustring.match(date_string, patterns['Md-Mdy'][1]);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif mw.ustring.match(date_string, patterns['dMy-dMy'][1]) then			-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2=mw.ustring.match(date_string, patterns['dMy-dMy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);

	elseif mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]) then			-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
		month, day, year, month2, day2, anchor_year, year2=mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);

	elseif mw.ustring.match(date_string, patterns['Sy4-y2'][1]) then			-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		local century;
		month, year, century, anchor_year, year2=mw.ustring.match(date_string, patterns['Sy4-y2'][1]);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;		-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;										-- assemble anchor_year from both years
		year2 = century..year2;													-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		month = get_season_number (month);

	elseif mw.ustring.match(date_string, patterns['Sy-y'][1]) then				-- special case Winter/Summer year-year; year separated with unspaced endash
		month, year, anchor_year, year2=mw.ustring.match(date_string, patterns['Sy-y'][1]);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;		-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;										-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		month = get_season_number (month);										-- for metadata

	elseif mw.ustring.match(date_string, patterns['My-My'][1]) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2=mw.ustring.match(date_string, patterns['My-My'][1]);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then 	-- both must be month year, same month style
			month = get_month_number(month);
			month2 = get_month_number(month2);
		elseif 0 ~= get_season_number(month) and 0 ~= get_season_number(month2) then	-- both must be or season year, not mixed
			month = get_season_number(month);
			month2 = get_season_number(month2);
		else
			 return false;
		end

	elseif mw.ustring.match(date_string, patterns['M-My'][1]) then				-- month/season range year; months separated by endash 
		month, month2, anchor_year, year=mw.ustring.match(date_string, patterns['M-My'][1]);
		if (not is_valid_month_season_range(month, month2)) or (not is_valid_year(year)) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
			month2 = get_month_number(month2);
		else
			month = get_season_number(month);
			month2 = get_season_number(month2);
		end
		year2=year;
		
	elseif mw.ustring.match(date_string, patterns['My'][1]) then				-- month/season year or proper-name year
		month, anchor_year, year=mw.ustring.match(date_string, patterns['My'][1]);
		if not is_valid_year(year) then return false; end
		if not is_valid_month_or_season (month) and 0 == is_proper_name (month) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
		elseif 0 ~= get_season_number(month) then
			month = get_season_number(month);
		else
			month = is_proper_name (month);										-- must be proper name; not supported in COinS
		end

	elseif mw.ustring.match(date_string, patterns['y-y'][1]) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2=mw.ustring.match(date_string, patterns['y-y'][1]);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, patterns['y4-y2'][1]) then				-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2=mw.ustring.match(date_string, patterns['y4-y2'][1]);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century..year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match (date_string, patterns['y'][1]) then				-- year; here accept either YYY or YYYY
		anchor_year, year=mw.ustring.match (date_string, patterns['y'][1]);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;															-- date format not one of the MOS:DATE approved formats
	end

	if test_accessdate then														-- test accessdate here because we have numerical date parts
		if 0 ~= year and 0 ~= month and 0 ~= day and 							-- all parts of a single date required
			0 == year2 and 0 == month2 and 0 == day2 then						-- none of these; accessdate must not be a range
				if not is_valid_accessdate (year..'-'..month..'-'..day) then	
					return false;												-- return false when accessdate out of bounds
				end
		else
			return false;														-- return false when accessdate is a range of two dates
		end
	end

	local result=true;															-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result=is_valid_date(year,month,day);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month2,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year2,month2,day2);
	end
	
	if false == result then return false; end

	if nil ~= tCOinS_date then													-- this table only passed into this function when testing |date= parameter values
		make_COinS_date ({year=year, month=month, day=day, year2=year2, month2=month2, day2=day2}, tCOinS_date);	-- make an ISO 8601 date string for COinS
	end
	
	return true, anchor_year;													-- format is good and date string represents a real date
end	


--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.

]]

local function dates(date_parameters_list, tCOinS_date)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local embargo_date;															-- if embargo date is a good dmy, mdy, ymd date then holds original value else reset to 9999
	local error_message = &quot;&quot;;
	local good_date = false;
	
	for k, v in pairs(date_parameters_list) do									-- for each date-holding parameter in the list
		if is_set(v.val) then													-- if the parameter has a value
			v.val = mw.ustring.gsub (v.val, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9
			if v.val:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then						-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v.val:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);				-- get the year portion so it can be tested
				if 'date'==k then
					anchor_year, COinS_date = v.val:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year'==k then
					good_date = is_valid_year(year);
				end
			elseif 'date'==k then												-- if the parameter is |date=
				if v.val:match(&quot;^n%.d%.%a?$&quot;) then								-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v.val:match(&quot;^nd%a?$&quot;) then								-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v.val, tCOinS_date);	-- go test the date
				end
			elseif 'year'==k then												-- if the parameter is |year= it should hold only a year value
				if v.val:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then						-- if |year= 3 or 4 digits only with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((%d+)%a?)&quot;);
				end
			elseif 'access-date'==k then										-- if the parameter is |date=
				good_date = check_date (v.val, nil, true);						-- go test the date; nil is a placeholder; true is the test_accessdate flag
			elseif 'embargo'==k then											-- if the parameter is |embargo=
				good_date = check_date (v.val);									-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date, embargo_date = is_valid_embargo_date (v.val);	-- is |embargo= date a single dmy, mdy, or ymd formatted date? yes:returns embargo; no: returns 9999
				end
			else																-- any other date-holding parameter
				good_date = check_date (v.val);									-- go test the date
			end
			if false==good_date then											-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then									-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;						-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. v.name .. &quot;=&quot;;		-- add the failed parameter
			end
		end
	end
	return anchor_year, embargo_date, error_message;							-- and done
end


--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function returns a numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

]]

local function year_date_check (year_string, date_string)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes
	
	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where both date and year are required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard range formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif mw.ustring.match(date_string, &quot;%d%d%d%d[%-–]%d%d&quot;) then				-- YYYY-YY date ranges
		local century;
		date1, century, date2 = mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	else
		result = 0;																-- no recognizable year in date
	end
	return result;
end


--[[--------------------------&lt; R E F O R M A T T E R &gt;--------------------------------------------------------

reformat 'date' into new format specified by format_param if pattern_idx (the current format of 'date') can be
reformatted.  Does the grunt work for reformat_dates().

The table re_formats maps patern_idx (current format) and format_param (desired format) to a table that holds:
	format string used by string.format()
	identifier letters ('d', 'm', 'y', 'd2', 'm2', 'y2') that serve as indexes into a table t{} that holds captures
		from mw.ustring.match() for the various date parts specified by  patterns[pattern_idx][1]

Items in patterns{} have the general form:
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'}, where:
		['ymd'] is pattern_idx
		patterns['ymd'][1] is the match pattern with captures for mw.ustring.match()
		patterns['ymd'][2] is an indicator letter identifying the content of the first capture
		patterns['ymd'][3] ... the second capture etc

when a pattern matches a date, the captures are loaded into table t{} in capture order using the idemtifier
characters as indexes into t{}  For the above, a ymd date is in t{} as:
	t.y = first capture (year), t.m = second capture (month), t.d = third capture (day)

To reformat, this function is called with the pattern_idx that matches the current format of the date and with
format_param set to the desired format.  This function loads table t{} as described and then calls string.format()
with the format string specified by re_format[pattern_idx][format_param][1] using values taken from t{} according
to the capture identifier letters specified by patterns[pattern_idx][format_param][n] where n is 2..

]]

local re_formats = {
	['ymd'] = {																	-- date format is ymd; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},									-- |df=yMd; not supported at en.wiki
		},
	['Mdy'] = {																	-- date format is Mdy; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- for long/short reformatting
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},									-- |df=yMd; not supported at en.wiki
		},
	['dMy'] = {																	-- date format is dMy; reformat to:
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- for long/short reformatting
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},									-- |df=yMd; not supported at en.wiki
		},
	['Md-dy'] = {																-- date format is Md-dy; reformat to:
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- for long/short reformatting
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- |df=dmy -&gt; d-dMy 
		},
	['d-dMy'] = {																-- date format is d-d&gt;y; reformat to:
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- for long/short reformatting
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- |df=mdy -&gt; Md-dy 
		},
	['dM-dMy'] = {																-- date format is dM-dMy; reformat to:
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- for long/short reformatting
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd', 'm2', 'd2', 'y'},				-- |df=mdy -&gt; Md-Mdy 
		},
	['Md-Mdy'] = {																-- date format is Md-Mdy; reformat to:
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd',  'm2', 'd2', 'y'},			-- for long/short reformatting
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- |df=dmy -&gt; dM-dMy 
		},
	['dMy-dMy'] = {																-- date format is dMy-dMy; reformat to:
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- for long/short reformatting
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- |df=mdy -&gt; Mdy-Mdy 
		},
	['Mdy-Mdy'] = {																-- date format is Mdy-Mdy; reformat to:
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- for long/short reformatting
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- |df=dmy -&gt; dMy-dMy 
		},
	['My-My'] = {																-- these for long/short reformatting
		['any'] = {'%s %s – %s %s', 'm', 'y', 'm2', 'y2'},						-- dmy/mdy agnostic
		},
	['M-My'] = {																-- these for long/short reformatting
		['any'] = {'%s–%s %s', 'm', 'm2', 'y'},									-- dmy/mdy agnostic
		},
	['My'] = {																	-- these for long/short reformatting
		['any'] = {'%s %s', 'm', 'y'},											-- dmy/mdy agnostic
		},
--	['yMd'] = {																	-- not supported at en.wiki
--		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
--		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
--		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
--		},
	}


local function reformatter (date, pattern_idx, format_param, mon_len)
	if not in_array (pattern_idx, {'ymd', 'Mdy', 'Md-dy', 'dMy', 'yMd', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- not in this set of date format patterns then not a reformattable date
	end
	
	if 'ymd' == format_param and in_array (pattern_idx, {'ymd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- ymd date ranges not supported at en.wiki; no point in reformatting ymd to ymd
	end

	if in_array (pattern_idx, {'My', 'M-My', 'My-My'}) then						-- these are not dmy/mdy so can't be 'reformatted' into either
		format_param = 'any';													-- so format-agnostic 
	end

--	if 'yMd' == format_param and in_array (pattern_idx, {'yMd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy'}) then	-- not supported at en.wiki
	if 'yMd' == format_param then												-- not supported at en.wiki
		return;																	-- not a reformattable date
	end
	
	local c1, c2, c3, c4, c5, c6, c7;											-- these hold the captures specified in patterns[pattern_idx][1]
	c1, c2, c3, c4, c5, c6, c7 = mw.ustring.match (date, patterns[pattern_idx][1]);	-- get the captures

	local t = {																	-- table that holds k/v pairs of date parts from the captures and patterns[pattern_idx][2..]
		[patterns[pattern_idx][2]] = c1;										-- at minimum there is always one capture with a matching indicator letter
		[patterns[pattern_idx][3] or 'x'] = c2;									-- patterns can have a variable number of captures; each capture requires an indicator letter;
		[patterns[pattern_idx][4] or 'x'] = c3;									-- where there is no capture, there is no indicator letter so n in patterns[pattern_idx][n] will be nil;
		[patterns[pattern_idx][5] or 'x'] = c4;									-- the 'x' here spoofs an indicator letter to prevent 'table index is nil' error
		[patterns[pattern_idx][6] or 'x'] = c5;
		[patterns[pattern_idx][7] or 'x'] = c6;
		[patterns[pattern_idx][8] or 'x'] = c7;
		};

	if tonumber(t.m) then														-- if raw month is a number (converting from ymd)
		if 's' == mon_len then													-- if we are to use abbreviated month names
			t.m = cfg.date_names['inv_local_s'][tonumber(t.m)];					-- convert it to a month name
		else
			t.m = cfg.date_names['inv_local_l'][tonumber(t.m)];					-- convert it to a month name
		end
		t.d = t.d:gsub ('0(%d)', '%1');											-- strip leading '0' from day if present
	elseif 'ymd' == format_param then											-- when converting to ymd
		if 1582 &gt; tonumber(t.y) then											-- ymd format dates not allowed before 1582
			return;
		end
		t.m = string.format ('%02d', get_month_number (t.m));					-- make sure that month and day are two digits
		t.d = string.format ('%02d', t.d);
	elseif mon_len then															-- if mon_len is set to either 'short' or 'long'
		for _, mon in ipairs ({'m', 'm2'}) do									-- because there can be two month names, check both 
			if t[mon] then
				t[mon] = get_month_number (t[mon]);								-- get the month number for this month (is length agnostic)
				if 0 == t[mon] then return; end									-- seasons and named dates can't be converted
				t[mon] = (('s' == mon_len) and cfg.date_names['inv_local_s'][t[mon]]) or cfg.date_names['inv_local_l'][t[mon]];	-- fetch month name according to length
			end
		end
	end

	local new_date = string.format (re_formats[pattern_idx][format_param][1],	-- format string
		t[re_formats[pattern_idx][format_param][2]],							-- named captures from t{}
		t[re_formats[pattern_idx][format_param][3]],
		t[re_formats[pattern_idx][format_param][4]],
		t[re_formats[pattern_idx][format_param][5]],
		t[re_formats[pattern_idx][format_param][6]],
		t[re_formats[pattern_idx][format_param][7]],
		t[re_formats[pattern_idx][format_param][8]]
		);

	return new_date;
end


--[[-------------------------&lt; R E F O R M A T _ D A T E S &gt;--------------------------------------------------

Reformats existing dates into the format specified by format.

format is one of several manual keywords: dmy, dmy-all, mdy, mdy-all, ymd, ymd-all.  The -all version includes
access- and archive-dates; otherwise these dates are not reformatted.

This function allows automatic date formatting.  In ~/Configuration, the article source is searched for one of
the {{use xxx dates}} templates.  If found, xxx becomes the global date format as xxx-all.  If |cs1-dates= in
{{use xxx dates}} has legitimate value then that value determines how cs1|2 dates will be rendered.  Legitimate
values for |cs1-dates= are:
	l - all dates are rendered with long month names
	ls - publication dates use long month names; access-/archive-dates use abbreviated month names
	ly - publication dates use long month names; access-/archive-dates rendered in ymd format
	s - all dates are rendered with abbreviated (short) month names
	sy - publication dates use abbreviated month names; access-/archive-dates rendered in ymd format
	y - all dates are rendered in ymd format

the format argument for automatic date formatting will be the format specified by {{use xxx dates}} with the
value supplied by |cs1-dates so one of: xxx-l, xxx-ls, xxx-ly, xxx-s, xxx-sy, xxx-y, or simply xxx (|cs1-dates=
empty, omitted, or invalid) where xxx shall be either of dmy or mdy.

dates are extracted from date_parameters_list, reformatted (if appropriate), and then written back into the
list in the new format.  Dates in date_parameters_list are presumed here to be valid (no errors).  This function
returns true when a date has been reformatted, false else.  Actual reformatting is done by reformatter().

]]

local function reformat_dates (date_parameters_list, format)
	local all = false;															-- set to false to skip access- and archive-dates
	local len_p = 'l';															-- default publication date length shall be long
	local len_a = 'l';															-- default access-/archive-date length shall be long
	local result = false;
	local new_date;																
	
	if format:match('%a+%-all') then											-- manual df keyword; auto df keyword when length not specified in {{use xxx dates}}; 
		format = format:match('(%a+)%-all');									-- extract the format
		all = true;																-- all dates are long format dates because this keyword doesn't specify length
	elseif format:match('%a+%-[lsy][sy]?') then									-- auto df keywords; internal only
		all = true;																-- auto df applies to all dates; use length specified by capture len_p for all dates
		format, len_p, len_a = format:match('(%a+)%-([lsy])([sy]?)');			-- extract the format and length keywords
		if 'y' == len_p then													-- because allowed by MOS:DATEUNIFY (sort of) range dates and My dates not reformatted
			format = 'ymd';														-- override {{use xxx dates}}
		elseif (not is_set(len_a)) or (len_p == len_a) then						-- no access-/archive-date length specified or same length as publication dates then
			len_a = len_p;														-- in case len_a not set
		end
	end																			-- else only publication dates and they are long

	for param_name, param_val in pairs (date_parameters_list) do				-- for each date-holding parameter in the list
		if is_set (param_val.val) then											-- if the parameter has a value
			if not (not all and in_array (param_name, {'access-date', 'archive-date'})) then	-- skip access- or archive-date unless format is xxx-all; yeah, ugly; TODO: find a better way
				for pattern_idx, pattern in pairs (patterns) do
					if mw.ustring.match (param_val.val, pattern[1]) then
						if all and in_array (param_name, {'access-date', 'archive-date'}) then	-- if this date is an access- or archive-date
							new_date = reformatter (param_val.val, pattern_idx, (('y' == len_a) and 'ymd') or format, len_a);	-- choose ymd or dmy/mdy according to len_a setting
						else													-- all other dates
							new_date = reformatter (param_val.val, pattern_idx, format, len_p);
						end
						
						if new_date then										-- set when date was reformatted
							date_parameters_list[param_name].val = new_date;	-- update date in date list
							result = true;										-- and announce that changes have been made
						end
					end	-- if
				end		-- for
			end			-- if
		end				-- if
	end					-- for
return result;																	-- declare boolean result and done
end


--[[--------------------------&lt; D A T E _ H Y P H E N _ T O _ D A S H &gt;----------------------------------------

Loops through the list of date-holding parameters and converts any hyphen to an ndash.  Not called if the cs1|2
template has any date errors.

Modifies the date_parameters_list and returns true if hyphens are replaced, else returns false.

]]

local function date_hyphen_to_dash (date_parameters_list)
	local result = false;
	local n;
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set (param_val.val) then
			if not mw.ustring.match (param_val.val, '%d%d%d%d%-%d%d%-%d%d') then	-- for those that are not ymd dates (ustring because here digits may not be western)
				param_val.val, n = param_val.val:gsub ('%-', '–');				-- replace any hyphen with ndash
				if 0 ~= n then
					date_parameters_list[param_name].val = param_val.val;		-- update the list
					result = true;
				end
			end
		end
	end
	return result;																-- so we know if any hyphens were replaced
end


--[[-------------------------&lt; D A T E _ N A M E _ X L A T E &gt;------------------------------------------------

Attempts to translate English month names to local-language month names using names supplied by MediaWiki's
date parser function.  This is simple name-for-name replacement and may not work for all languages.

if xlat_dig is true, this function will also translate western (English) digits to the local language's digits.
This will also translate ymd dates.

]]

local function	date_name_xlate (date_parameters_list, xlt_dig)
	local xlate;
	local mode;																	-- long or short month names
	local modified = false;
	local date;
	
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val.val) then											-- if the parameter has a value
			date = param_val.val;
			for month in mw.ustring.gmatch (date, '%a+') do						-- iterate through all dates in the date (single date or date range)
				if cfg.date_names.en.long[month] then
					mode = 'F';													-- English name is long so use long local name
				elseif cfg.date_names.en.short[month] then
					mode = 'M';													-- English name is short so use short local name
				else
					mode = nil;													-- not an English month name; could be local language month name or an English season name
				end
		
				if mode then													-- might be a season
					xlate = lang_object:formatDate(mode, '1' .. month);			-- translate the month name to this local language
					date = mw.ustring.gsub (date, month, xlate);				-- replace the English with the translation
					date_parameters_list[param_name].val = date;				-- save the translated date
					modified = true;
				end
			end

			if xlt_dig then														-- shall we also translate digits?
				date = date:gsub ('%d', cfg.date_names.xlate_digits);			-- translate digits from western to 'local digits'
				date_parameters_list[param_name].val = date;					-- save the translated date
				modified = true;
			end
		end
	end
	
	return modified;
	end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	is_set = utilities_page_ptr.is_set;											-- import functions from selected Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;										-- import functions from selected Module:Citation/CS1/Utilities module
	cfg = cfg_table_ptr;														-- import tables from selected Module:Citation/CS1/Configuration
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {																		-- return exported functions
	dates = dates,
	year_date_check = year_date_check,
	reformat_dates = reformat_dates,
	date_hyphen_to_dash = date_hyphen_to_dash,
	date_name_xlate = date_name_xlate,
	set_selected_modules = set_selected_modules
	}</text>
      <sha1>2ksocezo4158y8wxm8kabhtrvrzutja</sha1>
    </revision>
    <revision>
      <id>4847</id>
      <parentid>4846</parentid>
      <timestamp>2020-07-11T13:18:10Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4847</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="60462" sha1="fgegkgmzsndz8x1l7i7i1xyosbm8eui" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array;															-- imported functions from selected Module:Citation/CS1/Utilities
local cfg;																		-- table of tables imported from selected Module:Citation/CS1/Configuration


--[[--------------------------&lt; F I L E - S C O P E   D E C L A R A T I O N S &gt;--------------------------------

File-scope variables are declared here

]]

local lang_object = mw.getContentLanguage();									-- used by is_valid_accessdate(), is_valid_year(), date_name_xlate(); TODO: move to ~/Configuration?
local year_limit;																-- used by is_valid_year()


--[=[-------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |accessdate= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-Engish date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate().  To get around that
call this function with YYYY-MM-DD format dates.

]=]

local function is_valid_accessdate (accessdate)
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold unix time stamps representing the dates

	good1, access_ts = pcall (lang_object.formatDate, lang_object, 'U', accessdate );			-- convert accessdate value to unix timesatmp 
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which which tonumber() may not understand
		access_ts = tonumber (access_ts) or lang_object:parseFormattedNumber (access_ts);			-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to unix time stamp
	end

	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end


--[[--------------------------&lt; I S _ V A L I D _ E M B A R G O _ D A T E &gt;------------------------------------

returns true and date value if that value has proper dmy, mdy, ymd format.

returns false and 9999 (embargoed forever) when date value is not proper format; assumes that when |embargo= is
set, the editor intended to embargo a pmc but |embargo= does not hold a single date.

]]

local function is_valid_embargo_date (v)
	if v:match ('^%d%d%d%d%-%d%d%-%d%d$') or									-- ymd
		v:match ('^%d%d?%s+%a+%s+%d%d%d%d$') or									-- dmy
		v:match ('^%a+%s+%d%d?%s*,%s*%d%d%d%d$') then							-- mdy
			return true, v;
	end
	return false, '9999';														-- if here not good date so return false and set embargo date to long time in future
end


--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct.
If not a valid month, returns 0

]]

local function get_month_number (month)
	return cfg.date_names['local'].long[month] or cfg.date_names['local'].short[month] or		-- look for local names first
			cfg.date_names['en'].long[month] or	cfg.date_names['en'].short[month] or			-- failing that, look for English names
			0;																					-- not a recognized month name
end


--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 21 for Spring, etc.  Capitalization and spelling
must be correct. If not a valid season, returns 0.
	21-24 = Spring, Summer, Autumn, Winter, independent of “Hemisphere”

returns 0 when &lt;param&gt; is not |date=

Season numbering is defined by Extended Date/Time Format (EDTF) Specification (https://www.loc.gov/standards/datetime/)
which became part of ISO 8601 in 2019.  See '§Sub-year groupings'.  The standard defines various divisions using
numbers 21-41.  cs1|2 only supports generic seasons.  EDTF does support the distinction between north and south
hemispere seasons but cs1|2 has no way to make that distinction.

These additional divisions not currently supported:
	25-28 = Spring - Northern Hemisphere, Summer- Northern Hemisphere, Autumn - Northern Hemisphere, Winter - Northern Hemisphere
	29-32 = Spring – Southern Hemisphere, Summer– Southern Hemisphere, Autumn – Southern Hemisphere, Winter - Southern Hemisphere
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)

]]

local function get_season_number (season, param)
	if 'date' ~= param then
		return 0;																-- season dates only supported by |date=
	end
	return cfg.date_names['local'].season[season] or							-- look for local names first
			cfg.date_names['en'].season[season] or								-- failing that, look for English names
			0;																	-- not a recognized season name
end


--[[--------------------------&lt; G E T _ Q U A R T E R _ N U M B E R &gt;------------------------------------------

returns a number according to the sequence of quarters in a year: 33 for first quarter, etc.  Capitalization and spelling
must be correct. If not a valid quarter, returns 0.
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)

returns 0 when &lt;param&gt; is not |date=

Quarter numbering is defined by Extended Date/Time Format (EDTF) Specification (https://www.loc.gov/standards/datetime/)
which became part of ISO 8601 in 2019.  See '§Sub-year groupings'.  The standard defines various divisions using
numbers 21-41.  cs1|2 only supports generic seasons and quarters.

These additional divisions not currently supported:
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)

]]

local function get_quarter_number (quarter, param)
	if 'date' ~= param then
		return 0;																-- quarter dates only supported by |date=
	end
	quarter = mw.ustring.gsub (quarter, ' +', ' ');								-- special case replace multiple space chars with a single space char
	return cfg.date_names['local'].quarter[quarter] or							-- look for local names first
			cfg.date_names['en'].quarter[quarter] or							-- failing that, look for English names
			0;																	-- not a recognized quarter name
end


--[[--------------------------&lt; G E T _ P R O P E R _ N A M E _ N U M B E R &gt;----------------------------------

returns a non-zero number if date contains a recognized proper-name.  Capitalization and spelling must be correct.

returns 0 when &lt;param&gt; is not |date=

]]

local function get_proper_name_number (name, param)
	if 'date' ~= param then
		return 0;																-- proper-name dates only supported by |date=
	end
	return cfg.date_names['local'].named[name] or								-- look for local names dates first
			cfg.date_names['en'].named[name] or									-- failing that, look for English names
			0;																	-- not a recognized named date
end


--[[--------------------------&lt; G E T _ E L E M E N T _ N U M B E R &lt;------------------------------------------

returns true if month or season or quarter or proper name is valid (properly spelled, capitalized, abbreviated)

]]

local function get_element_number (element, param)
	local num;
	
	local funcs = {get_month_number, get_season_number, get_quarter_number, get_proper_name_number};	-- list of functions to execute in order
	
	for _, func in ipairs (funcs) do											-- spin through the function list
		num = func (element, param);											-- call the function and get the returned number
		if 0 ~= num then														-- non-zero when valid month season quarter 
			return num;															-- return that number
		end
	end
	return nil;																	-- not valid
end


--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one
year in the future are not acceptable.

]]

local function is_valid_year (year)
	if not is_set(year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;									-- global variable so we only have to fetch it once
	end

	year = tonumber (year) or lang_object:parseFormattedNumber (year);			-- convert to numbers for the comparison;
	return year and (year &lt;= year_limit) or false;
end


--[[--------------------------&lt; I S _ V A L I D _ D A T E &gt;----------------------------------------------------

Returns true if day is less than or equal to the number of days in month and year is no farther into the future
than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap
years before 1582 and Gregorian leap years after 1582. Where the two calendars overlap (1582 to approximately
1923) dates are assumed to be Gregorian.

]]

local function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year(year) then												-- no farther into the future than next year
		return false;
	end
	
	month = tonumber(month);													-- required for YYYY-MM-DD dates
	
	if (2==month) then															-- if February
		month_length = 28;														-- then 28 days unless
		if 1582 &gt; tonumber(year) then											-- Julian calendar
			if 0==(year%4) then													-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		else																	-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then			-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
There is a special test for May because it can be either short or long form.

Returns true when style for both months is the same

]]

local function is_valid_month_range_style (month1, month2)
local len1 = month1:len();
local len2 = month2:len();
	if len1 == len2 then
		return true;															-- both months are short form so return true
	elseif 'May' == month1 or 'May'== month2 then
		return true;															-- both months are long form so return true
	elseif 3 == len1 or 3 == len2 then
		return false;															-- months are mixed form so return false
	else
		return true;															-- both months are long form so return true
	end
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

All season ranges are accepted as valid because there are publishers out there who have published a Summer–Spring YYYY issue so ... ok

]]

local function is_valid_month_season_range(range_start, range_end)
	local range_start_number = get_month_number (range_start);
	local range_end_number;
	
	if 0 == range_start_number then												-- is this a month range?
		range_start_number = get_season_number (range_start);					-- not a month; is it a season? get start season number
		range_end_number = get_season_number (range_end);						-- get end season number

		if (0 ~= range_start_number) and (0 ~= range_end_number) then
			return true;														-- any season pairing is accepted
		end
		return false;															-- range_start and/or range_end is not a season
	end
																				-- here when range_start is a month
	range_end_number = get_month_number (range_end);							-- get end month number
	if range_start_number &lt; range_end_number then								-- range_start is a month; does range_start precede range_end?
		if is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
		end
	end
	return false;																-- range_start month number is greater than or equal to range end number; or range end isn't a month
end


--[[--------------------------&lt; M A K E _ C O I N S _ D A T E &gt;------------------------------------------------

This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1.  The function is called only for |date= parameters and only if the |date=&lt;value&gt; is 
determined to be a valid date format.  The question of what to do with invalid date formats is not answered here.

The date parts in the input table are converted to an ISO 8601 conforming date string:
	single whole dates:		yyyy-mm-dd
	month and year dates:	yyyy-mm
	year dates:				yyyy
	ranges:					yyyy-mm-dd/yyyy-mm-dd
							yyyy-mm/yyyy-mm
							yyyy/yyyy

Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.

The input table has:
	year, year2 – always present; if before 1582, ignore months and days if present
	month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 99 Christmas
	day, day2 –  0 if not provided, 1-31 for days
	
the output table receives:
	rftdate:	an IS8601 formatted date
	rftchron:	a free-form version of the date, usually without year which is in rftdate (season ranges and proper-name dates)
	rftssn:		one of four season keywords: winter, spring, summer, fall (lowercase)
	rftquarter:	one of four values: 1, 2, 3, 4

]]

local function make_COinS_date (input, tCOinS_date)
	local date;																	-- one date or first date in a range
	local date2 = '';															-- end of range date
-- start temporary Julian / Gregorian calendar uncertainty detection
	local year = tonumber(input.year);											-- this temporary code to determine the extent of sources dated to the Julian/Gregorian
	local month = tonumber(input.month);										-- interstice 1 October 1582 – 1 January 1926
	local day = tonumber (input.day);
	if (0 ~= day) and															-- day must have a value for this to be a whole date
		(((1582 == year) and (10 &lt;= month) and (12 &gt;= month)) or				-- any whole 1582 date from 1 october to 31 December or
			((1926 == year) and (1 == month) and (1 == input.day)) or			-- 1 January 1926 or
				((1582 &lt; year) and (1925 &gt;= year))) then						-- any date 1 January 1583 – 31 December 1925
					tCOinS_date.inter_cal_cat = true;							-- set category flag true
	end
-- end temporary Julian / Gergorian calendar uncertainty detection
	
	if 1582 &gt; tonumber(input.year) or 20 &lt; tonumber(input.month) then			-- Julian calendar or season so &amp;rft.date gets year only
		date = input.year;
		if 0 ~= input.year2 and input.year ~= input.year2 then					-- if a range, only the second year portion when not the same as range start year
			date = string.format ('%.4d/%.4d', tonumber(input.year), tonumber(input.year2))		-- assemble the date range
		end
		if 20 &lt; tonumber(input.month) then										-- if season or proper-name date
			local season = {[24]='winter', [21]='spring', [22]='summer', [23]='fall', [33]='1', [34]='2', [35]='3', [36]='4', [98]='Easter', [99]='Christmas'};	-- seasons lowercase, no autumn; proper-names use title case
			if 0 == input.month2 then											-- single season date
				if 40 &lt;tonumber(input.month) then
					tCOinS_date.rftchron = season[input.month];					-- proper-name dates
				elseif 30 &lt;tonumber(input.month) then
					tCOinS_date.rftquarter = season[input.month];				-- quarters
				else
					tCOinS_date.rftssn = season[input.month];					-- seasons
				end
			else																-- season range with a second season specified
				if input.year ~= input.year2 then								-- season year – season year range or season year–year
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					if 0~= input.month2 then
						tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);
					end
				else															-- season–season year range
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2];	-- season–season year range
				end
			end
		end
		tCOinS_date.rftdate = date;
		return;																	-- done
	end
	
	if 0 ~= input.day then
		date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day));	-- whole date
	elseif 0 ~= input.month then
		date = string.format ('%s-%.2d', input.year, tonumber(input.month));	-- year and month
	else
		date = string.format ('%s', input.year);								-- just year
	end

	if 0 ~= input.year2 then
		if 0 ~= input.day2 then
			date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2));		-- whole date
		elseif 0 ~= input.month2 then
			date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2));	-- year and month
		else
			date2 = string.format ('/%s', input.year2);							-- just year
		end
	end
	
	tCOinS_date.rftdate = date .. date2;										-- date2 has the '/' separator
	return;
end


--[[--------------------------&lt; P A T T E R N S &gt;--------------------------------------------------------------

this is the list of patterns for date formats that this module recognizes.  Approximately the first half of these
patterns represent formats that might be reformatted into another format.  Those that might be reformatted have
'indicator' letters that identify the content of the matching capture: 'd' (day), 'm' (month), 'a' (anchor year),
'y' (year); second day, month, year have a '2' suffix.

These patterns are used for both date validation and for reformatting.  This table should not be moved to ~/Configuration
because changes to this table require changes to check_date() and to reformatter() and reformat_date()

]]

local patterns = {
	 																			-- year-initial numerical year-month-day
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'},					
																				-- month-initial: month day, year
	['Mdy'] = {'^(%D-) +([1-9]%d?), +((%d%d%d%d?)%a?)$', 'm', 'd', 'a', 'y'},
																				-- month-initial day range: month day–day, year; days are separated by endash
	['Md-dy'] = {'^(%D-) +([1-9]%d?)[%-–]([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'd2', 'a', 'y'},
																				-- day-initial: day month year
	['dMy'] = {'^([1-9]%d?) +(%D-) +((%d%d%d%d?)%a?)$', 'd', 'm', 'a', 'y'},
																				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed; not supported at en.wiki
--	['yMd'] = {'^((%d%d%d%d?)%a?) +(%D-) +(%d%d?)$', 'a', 'y', 'm', 'd'},
																				-- day-range-initial: day–day month year; days are separated by endash
	['d-dMy'] = {'^([1-9]%d?)[%-–]([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'd2', 'm', 'a', 'y'},
																				-- day initial month-day-range: day month - day month year; uses spaced endash
	['dM-dMy'] = {'^([1-9]%d?) +(%D-) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'd2', 'm2', 'a', 'y'},
																				-- month initial month-day-range: month day – month day, year;  uses spaced endash
	['Md-Mdy'] = {'^(%D-) +([1-9]%d?) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$','m', 'd', 'm2', 'd2', 'a', 'y'},
																				-- day initial month-day-year-range: day month year - day month year; uses spaced endash
	['dMy-dMy'] = {'^([1-9]%d?) +(%D-) +(%d%d%d%d) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'y', 'd2', 'm2', 'a', 'y2'},
																				-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
	['Mdy-Mdy'] = {'^(%D-) +([1-9]%d?), +(%d%d%d%d) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'y', 'm2', 'd2', 'a', 'y2'},

																				-- these date formats cannot be converted, per se, but month name can be rendered short or long
																				-- month/season year - month/season year; separated by spaced endash
	['My-My'] = {'^(%D-) +(%d%d%d%d) +[%-–] +(%D-) +((%d%d%d%d)%a?)$', 'm', 'y', 'm2', 'a', 'y2'},
																				-- month/season range year; months separated by endash
	['M-My'] = {'^(%D-)[%-–](%D-) +((%d%d%d%d)%a?)$', 'm', 'm2', 'a', 'y'},
																				-- month/season year or proper-name year; quarter year when First Quarter YYYY etc
	['My'] = {'^([^%d–]-) +((%d%d%d%d)%a?)$', 'm', 'a', 'y'},					-- this way because endash is a member of %D; %D- will match January–March 2019 when it shouldn't

																				-- these date formats cannot be converted
--	['Q,y'] = {'^(Q%a* +[1-4]), +((%d%d%d%d)%a?)$'},							-- Quarter n, yyyy

	['Sy4-y2'] = {'^(%D-) +((%d%d)%d%d)[%-–]((%d%d)%a?)$'},						-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
	['Sy-y'] = {'^(%D-) +(%d%d%d%d)[%-–]((%d%d%d%d)%a?)$'},						-- special case Winter/Summer year-year; year separated with unspaced endash
	['y-y'] = {'^(%d%d%d%d?)[%-–]((%d%d%d%d?)%a?)$'},							-- year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
	['y4-y2'] = {'^((%d%d)%d%d)[%-–]((%d%d)%a?)$'},								-- year range: YYYY–YY; separated by unspaced endash
	['y'] = {'^((%d%d%d%d?)%a?)$'},												-- year; here accept either YYY or YYYY
	}


--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only
allowed range separator is endash.  Additionally, check the date to see that it is a real date: no 31 in 30-day
months; no 29 February when not a leap year.  Months, both long-form and three character abbreviations, and seasons
must be spelled correctly.  Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and
COinS_date.  When this happens, the date parameter is used in the COinS metadata and the CITEREF identifier gets
its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc.)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is ISO 8601 format date; see make_COInS_date()

]]

--local function check_date (date_string, tCOinS_date, test_accessdate)
local function check_date (date_string, param, tCOinS_date)
	local year;			-- assume that year2, months, and days are not used;
	local year2=0;		-- second year in a year range
	local month=0;
	local month2=0;		-- second month in a month range
	local day=0;
	local day2=0;		-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match (patterns['ymd'][1]) then								-- year-initial numerical year month day format
		year, month, day=date_string:match (patterns['ymd'][1]);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or 0 == tonumber(day) then return false; end	-- month or day number not valid or not Gregorian calendar
		anchor_year = year;
	
--	elseif mw.ustring.match(date_string, patterns['Q,y'][1]) then				-- quarter n, year; here because much the same as Mdy
--		month, anchor_year, year=mw.ustring.match(date_string, patterns['Q,y'][1]);
--		if not is_valid_year(year) then return false; end
--		month = get_quarter_number (month, param);								-- get quarter number or nil
--		if not month then return false; end										-- not valid whatever it is

	elseif mw.ustring.match(date_string, patterns['Mdy'][1]) then				-- month-initial: month day, year
		month, day, anchor_year, year=mw.ustring.match(date_string, patterns['Mdy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
				
	elseif mw.ustring.match(date_string, patterns['Md-dy'][1]) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year=mw.ustring.match(date_string, patterns['Md-dy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2=month;															-- for metadata
		year2=year;

	elseif mw.ustring.match(date_string, patterns['dMy'][1]) then				-- day-initial: day month year
		day, month, anchor_year, year=mw.ustring.match(date_string, patterns['dMy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months

--[[ NOT supported at en.wiki
	elseif mw.ustring.match(date_string, patterns['yMd'][1]) then				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed
		anchor_year, year, month, day=mw.ustring.match(date_string, patterns['yMd'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
-- end NOT supported at en.wiki ]]

	elseif mw.ustring.match(date_string, patterns['d-dMy'][1]) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year=mw.ustring.match(date_string, patterns['d-dMy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2=month;															-- for metadata
		year2=year;

	elseif mw.ustring.match(date_string, patterns['dM-dMy'][1]) then			-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year=mw.ustring.match(date_string, patterns['dM-dMy'][1]);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif mw.ustring.match(date_string, patterns['Md-Mdy'][1]) then			-- month initial month-day-range: month day – month day, year;  uses spaced endash
		month, day, month2, day2, anchor_year, year=mw.ustring.match(date_string, patterns['Md-Mdy'][1]);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif mw.ustring.match(date_string, patterns['dMy-dMy'][1]) then			-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2=mw.ustring.match(date_string, patterns['dMy-dMy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);

	elseif mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]) then			-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
		month, day, year, month2, day2, anchor_year, year2=mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);

	elseif mw.ustring.match(date_string, patterns['Sy4-y2'][1]) then			-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		local century;
		month, year, century, anchor_year, year2=mw.ustring.match(date_string, patterns['Sy4-y2'][1]);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;		-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;										-- assemble anchor_year from both years
		year2 = century..year2;													-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		month = get_season_number (month);

	elseif mw.ustring.match(date_string, patterns['Sy-y'][1]) then				-- special case Winter/Summer year-year; year separated with unspaced endash
		month, year, anchor_year, year2=mw.ustring.match(date_string, patterns['Sy-y'][1]);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;		-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;										-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		month = get_season_number (month);										-- for metadata

	elseif mw.ustring.match(date_string, patterns['My-My'][1]) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2=mw.ustring.match(date_string, patterns['My-My'][1]);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then 	-- both must be month year, same month style
			month = get_month_number(month);
			month2 = get_month_number(month2);
		elseif 0 ~= get_season_number(month) and 0 ~= get_season_number(month2) then	-- both must be or season year, not mixed
			month = get_season_number(month);
			month2 = get_season_number(month2);
		else
			 return false;
		end

	elseif mw.ustring.match(date_string, patterns['M-My'][1]) then				-- month/season range year; months separated by endash 
		month, month2, anchor_year, year=mw.ustring.match(date_string, patterns['M-My'][1]);
		if (not is_valid_month_season_range(month, month2)) or (not is_valid_year(year)) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
			month2 = get_month_number(month2);
		else
			month = get_season_number(month);
			month2 = get_season_number(month2);
		end
		year2=year;
		
	elseif mw.ustring.match(date_string, patterns['My'][1]) then				-- month/season/quarter/proper-name year
		month, anchor_year, year=mw.ustring.match(date_string, patterns['My'][1]);
		if not is_valid_year(year) then return false; end
		month = get_element_number (month, param);								-- get month season quarter proper-name number or nil
		if not month then return false; end										-- not valid whatever it is

	elseif mw.ustring.match(date_string, patterns['y-y'][1]) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2=mw.ustring.match(date_string, patterns['y-y'][1]);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, patterns['y4-y2'][1]) then				-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2=mw.ustring.match(date_string, patterns['y4-y2'][1]);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century..year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match (date_string, patterns['y'][1]) then				-- year; here accept either YYY or YYYY
		anchor_year, year=mw.ustring.match (date_string, patterns['y'][1]);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;															-- date format not one of the MOS:DATE approved formats
	end

	if 'access-date' == param then												-- test accessdate here because we have numerical date parts
		if 0 ~= year and 0 ~= month and 0 ~= day and 							-- all parts of a single date required
			0 == year2 and 0 == month2 and 0 == day2 then						-- none of these; accessdate must not be a range
				if not is_valid_accessdate (year..'-'..month..'-'..day) then	
					return false;												-- return false when accessdate out of bounds
				end
		else
			return false;														-- return false when accessdate is a range of two dates
		end
	end

	local result=true;															-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result=is_valid_date(year,month,day);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month2,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year2,month2,day2);
	end
	
	if false == result then return false; end

	if nil ~= tCOinS_date then													-- this table only passed into this function when testing |date= parameter values
		make_COinS_date ({year=year, month=month, day=day, year2=year2, month2=month2, day2=day2}, tCOinS_date);	-- make an ISO 8601 date string for COinS
	end
	
	return true, anchor_year;													-- format is good and date string represents a real date
end	


--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.

]]

local function dates(date_parameters_list, tCOinS_date)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local embargo_date;															-- if embargo date is a good dmy, mdy, ymd date then holds original value else reset to 9999
	local error_message = &quot;&quot;;
	local good_date = false;
	
	for k, v in pairs(date_parameters_list) do									-- for each date-holding parameter in the list
		if is_set(v.val) then													-- if the parameter has a value
			v.val = mw.ustring.gsub (v.val, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9
			if v.val:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then						-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v.val:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);				-- get the year portion so it can be tested
				if 'date'==k then
					anchor_year, COinS_date = v.val:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year'==k then
					good_date = is_valid_year(year);
				end
			elseif 'date'==k then												-- if the parameter is |date=
				if v.val:match(&quot;^n%.d%.%a?$&quot;) then								-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v.val:match(&quot;^nd%a?$&quot;) then								-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v.val, k, tCOinS_date);	-- go test the date
				end
			elseif 'year'==k then												-- if the parameter is |year= it should hold only a year value
				if v.val:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then						-- if |year= 3 or 4 digits only with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((%d+)%a?)&quot;);
				end
			elseif 'embargo'==k then											-- if the parameter is |embargo=
				good_date = check_date (v.val);									-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date, embargo_date = is_valid_embargo_date (v.val);	-- is |embargo= date a single dmy, mdy, or ymd formatted date? yes:returns embargo; no: returns 9999
				end
			else																-- any other date-holding parameter
				good_date = check_date (v.val, k);								-- go test the date
			end
			if false==good_date then											-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then									-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;						-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. v.name .. &quot;=&quot;;		-- add the failed parameter
			end
		end
	end
	return anchor_year, embargo_date, error_message;							-- and done
end


--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function returns a numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

]]

local function year_date_check (year_string, date_string)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes
	
	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where both date and year are required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard range formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif mw.ustring.match(date_string, &quot;%d%d%d%d[%-–]%d%d&quot;) then				-- YYYY-YY date ranges
		local century;
		date1, century, date2 = mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	else
		result = 0;																-- no recognizable year in date
	end
	return result;
end


--[[--------------------------&lt; R E F O R M A T T E R &gt;--------------------------------------------------------

reformat 'date' into new format specified by format_param if pattern_idx (the current format of 'date') can be
reformatted.  Does the grunt work for reformat_dates().

The table re_formats maps patern_idx (current format) and format_param (desired format) to a table that holds:
	format string used by string.format()
	identifier letters ('d', 'm', 'y', 'd2', 'm2', 'y2') that serve as indexes into a table t{} that holds captures
		from mw.ustring.match() for the various date parts specified by  patterns[pattern_idx][1]

Items in patterns{} have the general form:
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'}, where:
		['ymd'] is pattern_idx
		patterns['ymd'][1] is the match pattern with captures for mw.ustring.match()
		patterns['ymd'][2] is an indicator letter identifying the content of the first capture
		patterns['ymd'][3] ... the second capture etc

when a pattern matches a date, the captures are loaded into table t{} in capture order using the idemtifier
characters as indexes into t{}  For the above, a ymd date is in t{} as:
	t.y = first capture (year), t.m = second capture (month), t.d = third capture (day)

To reformat, this function is called with the pattern_idx that matches the current format of the date and with
format_param set to the desired format.  This function loads table t{} as described and then calls string.format()
with the format string specified by re_format[pattern_idx][format_param][1] using values taken from t{} according
to the capture identifier letters specified by patterns[pattern_idx][format_param][n] where n is 2..

]]

local re_formats = {
	['ymd'] = {																	-- date format is ymd; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},									-- |df=yMd; not supported at en.wiki
		},
	['Mdy'] = {																	-- date format is Mdy; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- for long/short reformatting
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},									-- |df=yMd; not supported at en.wiki
		},
	['dMy'] = {																	-- date format is dMy; reformat to:
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- for long/short reformatting
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},									-- |df=yMd; not supported at en.wiki
		},
	['Md-dy'] = {																-- date format is Md-dy; reformat to:
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- for long/short reformatting
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- |df=dmy -&gt; d-dMy 
		},
	['d-dMy'] = {																-- date format is d-d&gt;y; reformat to:
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- for long/short reformatting
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- |df=mdy -&gt; Md-dy 
		},
	['dM-dMy'] = {																-- date format is dM-dMy; reformat to:
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- for long/short reformatting
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd', 'm2', 'd2', 'y'},				-- |df=mdy -&gt; Md-Mdy 
		},
	['Md-Mdy'] = {																-- date format is Md-Mdy; reformat to:
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd',  'm2', 'd2', 'y'},			-- for long/short reformatting
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- |df=dmy -&gt; dM-dMy 
		},
	['dMy-dMy'] = {																-- date format is dMy-dMy; reformat to:
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- for long/short reformatting
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- |df=mdy -&gt; Mdy-Mdy 
		},
	['Mdy-Mdy'] = {																-- date format is Mdy-Mdy; reformat to:
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- for long/short reformatting
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- |df=dmy -&gt; dMy-dMy 
		},
	['My-My'] = {																-- these for long/short reformatting
		['any'] = {'%s %s – %s %s', 'm', 'y', 'm2', 'y2'},						-- dmy/mdy agnostic
		},
	['M-My'] = {																-- these for long/short reformatting
		['any'] = {'%s–%s %s', 'm', 'm2', 'y'},									-- dmy/mdy agnostic
		},
	['My'] = {																	-- these for long/short reformatting
		['any'] = {'%s %s', 'm', 'y'},											-- dmy/mdy agnostic
		},
--	['yMd'] = {																	-- not supported at en.wiki
--		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
--		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
--		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
--		},
	}


local function reformatter (date, pattern_idx, format_param, mon_len)
	if not in_array (pattern_idx, {'ymd', 'Mdy', 'Md-dy', 'dMy', 'yMd', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- not in this set of date format patterns then not a reformattable date
	end
	
	if 'ymd' == format_param and in_array (pattern_idx, {'ymd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- ymd date ranges not supported at en.wiki; no point in reformatting ymd to ymd
	end

	if in_array (pattern_idx, {'My', 'M-My', 'My-My'}) then						-- these are not dmy/mdy so can't be 'reformatted' into either
		format_param = 'any';													-- so format-agnostic 
	end

--	if 'yMd' == format_param and in_array (pattern_idx, {'yMd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy'}) then	-- not supported at en.wiki
	if 'yMd' == format_param then												-- not supported at en.wiki
		return;																	-- not a reformattable date
	end
	
	local c1, c2, c3, c4, c5, c6, c7;											-- these hold the captures specified in patterns[pattern_idx][1]
	c1, c2, c3, c4, c5, c6, c7 = mw.ustring.match (date, patterns[pattern_idx][1]);	-- get the captures

	local t = {																	-- table that holds k/v pairs of date parts from the captures and patterns[pattern_idx][2..]
		[patterns[pattern_idx][2]] = c1;										-- at minimum there is always one capture with a matching indicator letter
		[patterns[pattern_idx][3] or 'x'] = c2;									-- patterns can have a variable number of captures; each capture requires an indicator letter;
		[patterns[pattern_idx][4] or 'x'] = c3;									-- where there is no capture, there is no indicator letter so n in patterns[pattern_idx][n] will be nil;
		[patterns[pattern_idx][5] or 'x'] = c4;									-- the 'x' here spoofs an indicator letter to prevent 'table index is nil' error
		[patterns[pattern_idx][6] or 'x'] = c5;
		[patterns[pattern_idx][7] or 'x'] = c6;
		[patterns[pattern_idx][8] or 'x'] = c7;
		};

	if t.a then																	-- if this date has an anchor year capture
		t.y = t.a;																-- use the anchor year capture when reassembling the date
	end

	if tonumber(t.m) then														-- if raw month is a number (converting from ymd)
		if 's' == mon_len then													-- if we are to use abbreviated month names
			t.m = cfg.date_names['inv_local_s'][tonumber(t.m)];					-- convert it to a month name
		else
			t.m = cfg.date_names['inv_local_l'][tonumber(t.m)];					-- convert it to a month name
		end
		t.d = t.d:gsub ('0(%d)', '%1');											-- strip leading '0' from day if present
	elseif 'ymd' == format_param then											-- when converting to ymd
		if 1582 &gt; tonumber(t.y) then											-- ymd format dates not allowed before 1582
			return;
		end
		t.m = string.format ('%02d', get_month_number (t.m));					-- make sure that month and day are two digits
		t.d = string.format ('%02d', t.d);
	elseif mon_len then															-- if mon_len is set to either 'short' or 'long'
		for _, mon in ipairs ({'m', 'm2'}) do									-- because there can be two month names, check both 
			if t[mon] then
				t[mon] = get_month_number (t[mon]);								-- get the month number for this month (is length agnostic)
				if 0 == t[mon] then return; end									-- seasons and named dates can't be converted
				t[mon] = (('s' == mon_len) and cfg.date_names['inv_local_s'][t[mon]]) or cfg.date_names['inv_local_l'][t[mon]];	-- fetch month name according to length
			end
		end
	end

	local new_date = string.format (re_formats[pattern_idx][format_param][1],	-- format string
		t[re_formats[pattern_idx][format_param][2]],							-- named captures from t{}
		t[re_formats[pattern_idx][format_param][3]],
		t[re_formats[pattern_idx][format_param][4]],
		t[re_formats[pattern_idx][format_param][5]],
		t[re_formats[pattern_idx][format_param][6]],
		t[re_formats[pattern_idx][format_param][7]],
		t[re_formats[pattern_idx][format_param][8]]
		);

	return new_date;
end


--[[-------------------------&lt; R E F O R M A T _ D A T E S &gt;--------------------------------------------------

Reformats existing dates into the format specified by format.

format is one of several manual keywords: dmy, dmy-all, mdy, mdy-all, ymd, ymd-all.  The -all version includes
access- and archive-dates; otherwise these dates are not reformatted.

This function allows automatic date formatting.  In ~/Configuration, the article source is searched for one of
the {{use xxx dates}} templates.  If found, xxx becomes the global date format as xxx-all.  If |cs1-dates= in
{{use xxx dates}} has legitimate value then that value determines how cs1|2 dates will be rendered.  Legitimate
values for |cs1-dates= are:
	l - all dates are rendered with long month names
	ls - publication dates use long month names; access-/archive-dates use abbreviated month names
	ly - publication dates use long month names; access-/archive-dates rendered in ymd format
	s - all dates are rendered with abbreviated (short) month names
	sy - publication dates use abbreviated month names; access-/archive-dates rendered in ymd format
	y - all dates are rendered in ymd format

the format argument for automatic date formatting will be the format specified by {{use xxx dates}} with the
value supplied by |cs1-dates so one of: xxx-l, xxx-ls, xxx-ly, xxx-s, xxx-sy, xxx-y, or simply xxx (|cs1-dates=
empty, omitted, or invalid) where xxx shall be either of dmy or mdy.

dates are extracted from date_parameters_list, reformatted (if appropriate), and then written back into the
list in the new format.  Dates in date_parameters_list are presumed here to be valid (no errors).  This function
returns true when a date has been reformatted, false else.  Actual reformatting is done by reformatter().

]]

local function reformat_dates (date_parameters_list, format)
	local all = false;															-- set to false to skip access- and archive-dates
	local len_p = 'l';															-- default publication date length shall be long
	local len_a = 'l';															-- default access-/archive-date length shall be long
	local result = false;
	local new_date;																
	
	if format:match('%a+%-all') then											-- manual df keyword; auto df keyword when length not specified in {{use xxx dates}}; 
		format = format:match('(%a+)%-all');									-- extract the format
		all = true;																-- all dates are long format dates because this keyword doesn't specify length
	elseif format:match('%a+%-[lsy][sy]?') then									-- auto df keywords; internal only
		all = true;																-- auto df applies to all dates; use length specified by capture len_p for all dates
		format, len_p, len_a = format:match('(%a+)%-([lsy])([sy]?)');			-- extract the format and length keywords
		if 'y' == len_p then													-- because allowed by MOS:DATEUNIFY (sort of) range dates and My dates not reformatted
			format = 'ymd';														-- override {{use xxx dates}}
		elseif (not is_set(len_a)) or (len_p == len_a) then						-- no access-/archive-date length specified or same length as publication dates then
			len_a = len_p;														-- in case len_a not set
		end
	end																			-- else only publication dates and they are long

	for param_name, param_val in pairs (date_parameters_list) do				-- for each date-holding parameter in the list
		if is_set (param_val.val) then											-- if the parameter has a value
			if not (not all and in_array (param_name, {'access-date', 'archive-date'})) then	-- skip access- or archive-date unless format is xxx-all; yeah, ugly; TODO: find a better way
				for pattern_idx, pattern in pairs (patterns) do
					if mw.ustring.match (param_val.val, pattern[1]) then
						if all and in_array (param_name, {'access-date', 'archive-date'}) then	-- if this date is an access- or archive-date
							new_date = reformatter (param_val.val, pattern_idx, (('y' == len_a) and 'ymd') or format, len_a);	-- choose ymd or dmy/mdy according to len_a setting
						else													-- all other dates
							new_date = reformatter (param_val.val, pattern_idx, format, len_p);
						end
						
						if new_date then										-- set when date was reformatted
							date_parameters_list[param_name].val = new_date;	-- update date in date list
							result = true;										-- and announce that changes have been made
						end
					end	-- if
				end		-- for
			end			-- if
		end				-- if
	end					-- for
return result;																	-- declare boolean result and done
end


--[[--------------------------&lt; D A T E _ H Y P H E N _ T O _ D A S H &gt;----------------------------------------

Loops through the list of date-holding parameters and converts any hyphen to an ndash.  Not called if the cs1|2
template has any date errors.

Modifies the date_parameters_list and returns true if hyphens are replaced, else returns false.

]]

local function date_hyphen_to_dash (date_parameters_list)
	local result = false;
	local n;
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set (param_val.val) then
			if not mw.ustring.match (param_val.val, '%d%d%d%d%-%d%d%-%d%d') then	-- for those that are not ymd dates (ustring because here digits may not be western)
				param_val.val, n = param_val.val:gsub ('%-', '–');				-- replace any hyphen with ndash
				if 0 ~= n then
					date_parameters_list[param_name].val = param_val.val;		-- update the list
					result = true;
				end
			end
		end
	end
	return result;																-- so we know if any hyphens were replaced
end


--[[-------------------------&lt; D A T E _ N A M E _ X L A T E &gt;------------------------------------------------

Attempts to translate English month names to local-language month names using names supplied by MediaWiki's
date parser function.  This is simple name-for-name replacement and may not work for all languages.

if xlat_dig is true, this function will also translate western (English) digits to the local language's digits.
This will also translate ymd dates.

]]

local function	date_name_xlate (date_parameters_list, xlt_dig)
	local xlate;
	local mode;																	-- long or short month names
	local modified = false;
	local date;
	
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val.val) then											-- if the parameter has a value
			date = param_val.val;
			for month in mw.ustring.gmatch (date, '%a+') do						-- iterate through all dates in the date (single date or date range)
				if cfg.date_names.en.long[month] then
					mode = 'F';													-- English name is long so use long local name
				elseif cfg.date_names.en.short[month] then
					mode = 'M';													-- English name is short so use short local name
				else
					mode = nil;													-- not an English month name; could be local language month name or an English season name
				end
		
				if mode then													-- might be a season
					xlate = lang_object:formatDate(mode, '1' .. month);			-- translate the month name to this local language
					date = mw.ustring.gsub (date, month, xlate);				-- replace the English with the translation
					date_parameters_list[param_name].val = date;				-- save the translated date
					modified = true;
				end
			end

			if xlt_dig then														-- shall we also translate digits?
				date = date:gsub ('%d', cfg.date_names.xlate_digits);			-- translate digits from western to 'local digits'
				date_parameters_list[param_name].val = date;					-- save the translated date
				modified = true;
			end
		end
	end
	
	return modified;
	end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	is_set = utilities_page_ptr.is_set;											-- import functions from selected Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;										-- import functions from selected Module:Citation/CS1/Utilities module
	cfg = cfg_table_ptr;														-- import tables from selected Module:Citation/CS1/Configuration
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {																		-- return exported functions
	dates = dates,
	year_date_check = year_date_check,
	reformat_dates = reformat_dates,
	date_hyphen_to_dash = date_hyphen_to_dash,
	date_name_xlate = date_name_xlate,
	set_selected_modules = set_selected_modules
	}</text>
      <sha1>fgegkgmzsndz8x1l7i7i1xyosbm8eui</sha1>
    </revision>
    <revision>
      <id>4848</id>
      <parentid>4847</parentid>
      <timestamp>2020-07-12T11:59:06Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>season range fix;</comment>
      <origin>4848</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="60529" sha1="1377zdgd6gluiiiiyqg8ybdys4wiz0a" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array;															-- imported functions from selected Module:Citation/CS1/Utilities
local cfg;																		-- table of tables imported from selected Module:Citation/CS1/Configuration


--[[--------------------------&lt; F I L E - S C O P E   D E C L A R A T I O N S &gt;--------------------------------

File-scope variables are declared here

]]

local lang_object = mw.getContentLanguage();									-- used by is_valid_accessdate(), is_valid_year(), date_name_xlate(); TODO: move to ~/Configuration?
local year_limit;																-- used by is_valid_year()


--[=[-------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |accessdate= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-Engish date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate().  To get around that
call this function with YYYY-MM-DD format dates.

]=]

local function is_valid_accessdate (accessdate)
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold unix time stamps representing the dates

	good1, access_ts = pcall (lang_object.formatDate, lang_object, 'U', accessdate );			-- convert accessdate value to unix timesatmp 
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which which tonumber() may not understand
		access_ts = tonumber (access_ts) or lang_object:parseFormattedNumber (access_ts);			-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to unix time stamp
	end

	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end


--[[--------------------------&lt; I S _ V A L I D _ E M B A R G O _ D A T E &gt;------------------------------------

returns true and date value if that value has proper dmy, mdy, ymd format.

returns false and 9999 (embargoed forever) when date value is not proper format; assumes that when |embargo= is
set, the editor intended to embargo a pmc but |embargo= does not hold a single date.

]]

local function is_valid_embargo_date (v)
	if v:match ('^%d%d%d%d%-%d%d%-%d%d$') or									-- ymd
		v:match ('^%d%d?%s+%a+%s+%d%d%d%d$') or									-- dmy
		v:match ('^%a+%s+%d%d?%s*,%s*%d%d%d%d$') then							-- mdy
			return true, v;
	end
	return false, '9999';														-- if here not good date so return false and set embargo date to long time in future
end


--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct.
If not a valid month, returns 0

]]

local function get_month_number (month)
	return cfg.date_names['local'].long[month] or cfg.date_names['local'].short[month] or		-- look for local names first
			cfg.date_names['en'].long[month] or	cfg.date_names['en'].short[month] or			-- failing that, look for English names
			0;																					-- not a recognized month name
end


--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 21 for Spring, etc.  Capitalization and spelling
must be correct. If not a valid season, returns 0.
	21-24 = Spring, Summer, Autumn, Winter, independent of “Hemisphere”

returns 0 when &lt;param&gt; is not |date=

Season numbering is defined by Extended Date/Time Format (EDTF) Specification (https://www.loc.gov/standards/datetime/)
which became part of ISO 8601 in 2019.  See '§Sub-year groupings'.  The standard defines various divisions using
numbers 21-41.  cs1|2 only supports generic seasons.  EDTF does support the distinction between north and south
hemispere seasons but cs1|2 has no way to make that distinction.

These additional divisions not currently supported:
	25-28 = Spring - Northern Hemisphere, Summer- Northern Hemisphere, Autumn - Northern Hemisphere, Winter - Northern Hemisphere
	29-32 = Spring – Southern Hemisphere, Summer– Southern Hemisphere, Autumn – Southern Hemisphere, Winter - Southern Hemisphere
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)

]]

local function get_season_number (season, param)
	if 'date' ~= param then
		return 0;																-- season dates only supported by |date=
	end
	return cfg.date_names['local'].season[season] or							-- look for local names first
			cfg.date_names['en'].season[season] or								-- failing that, look for English names
			0;																	-- not a recognized season name
end


--[[--------------------------&lt; G E T _ Q U A R T E R _ N U M B E R &gt;------------------------------------------

returns a number according to the sequence of quarters in a year: 33 for first quarter, etc.  Capitalization and spelling
must be correct. If not a valid quarter, returns 0.
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)

returns 0 when &lt;param&gt; is not |date=

Quarter numbering is defined by Extended Date/Time Format (EDTF) Specification (https://www.loc.gov/standards/datetime/)
which became part of ISO 8601 in 2019.  See '§Sub-year groupings'.  The standard defines various divisions using
numbers 21-41.  cs1|2 only supports generic seasons and quarters.

These additional divisions not currently supported:
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)

]]

local function get_quarter_number (quarter, param)
	if 'date' ~= param then
		return 0;																-- quarter dates only supported by |date=
	end
	quarter = mw.ustring.gsub (quarter, ' +', ' ');								-- special case replace multiple space chars with a single space char
	return cfg.date_names['local'].quarter[quarter] or							-- look for local names first
			cfg.date_names['en'].quarter[quarter] or							-- failing that, look for English names
			0;																	-- not a recognized quarter name
end


--[[--------------------------&lt; G E T _ P R O P E R _ N A M E _ N U M B E R &gt;----------------------------------

returns a non-zero number if date contains a recognized proper-name.  Capitalization and spelling must be correct.

returns 0 when &lt;param&gt; is not |date=

]]

local function get_proper_name_number (name, param)
	if 'date' ~= param then
		return 0;																-- proper-name dates only supported by |date=
	end
	return cfg.date_names['local'].named[name] or								-- look for local names dates first
			cfg.date_names['en'].named[name] or									-- failing that, look for English names
			0;																	-- not a recognized named date
end


--[[--------------------------&lt; G E T _ E L E M E N T _ N U M B E R &lt;------------------------------------------

returns true if month or season or quarter or proper name is valid (properly spelled, capitalized, abbreviated)

]]

local function get_element_number (element, param)
	local num;
	
	local funcs = {get_month_number, get_season_number, get_quarter_number, get_proper_name_number};	-- list of functions to execute in order
	
	for _, func in ipairs (funcs) do											-- spin through the function list
		num = func (element, param);											-- call the function and get the returned number
		if 0 ~= num then														-- non-zero when valid month season quarter 
			return num;															-- return that number
		end
	end
	return nil;																	-- not valid
end


--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one
year in the future are not acceptable.

]]

local function is_valid_year (year)
	if not is_set(year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;									-- global variable so we only have to fetch it once
	end

	year = tonumber (year) or lang_object:parseFormattedNumber (year);			-- convert to numbers for the comparison;
	return year and (year &lt;= year_limit) or false;
end


--[[--------------------------&lt; I S _ V A L I D _ D A T E &gt;----------------------------------------------------

Returns true if day is less than or equal to the number of days in month and year is no farther into the future
than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap
years before 1582 and Gregorian leap years after 1582. Where the two calendars overlap (1582 to approximately
1923) dates are assumed to be Gregorian.

]]

local function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year(year) then												-- no farther into the future than next year
		return false;
	end
	
	month = tonumber(month);													-- required for YYYY-MM-DD dates
	
	if (2==month) then															-- if February
		month_length = 28;														-- then 28 days unless
		if 1582 &gt; tonumber(year) then											-- Julian calendar
			if 0==(year%4) then													-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		else																	-- Gregorian calendar
			if (0==(year%4) and (0~=(year%100) or 0==(year%400))) then			-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		end
	else
		month_length=days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
There is a special test for May because it can be either short or long form.

Returns true when style for both months is the same

]]

local function is_valid_month_range_style (month1, month2)
local len1 = month1:len();
local len2 = month2:len();
	if len1 == len2 then
		return true;															-- both months are short form so return true
	elseif 'May' == month1 or 'May'== month2 then
		return true;															-- both months are long form so return true
	elseif 3 == len1 or 3 == len2 then
		return false;															-- months are mixed form so return false
	else
		return true;															-- both months are long form so return true
	end
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

All season ranges are accepted as valid because there are publishers out there who have published a Summer–Spring YYYY issue so ... ok

]]

local function is_valid_month_season_range(range_start, range_end, param)
	local range_start_number = get_month_number (range_start);
	local range_end_number;

	if 0 == range_start_number then												-- is this a month range?
		range_start_number = get_season_number (range_start, param);			-- not a month; is it a season? get start season number
		range_end_number = get_season_number (range_end, param);				-- get end season number

		if (0 ~= range_start_number) and (0 ~= range_end_number) then
			return true;														-- any season pairing is accepted
		end
		return false;															-- range_start and/or range_end is not a season
	end
																				-- here when range_start is a month
	range_end_number = get_month_number (range_end);							-- get end month number
	if range_start_number &lt; range_end_number then								-- range_start is a month; does range_start precede range_end?
		if is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
		end
	end
	return false;																-- range_start month number is greater than or equal to range end number; or range end isn't a month
end


--[[--------------------------&lt; M A K E _ C O I N S _ D A T E &gt;------------------------------------------------

This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1.  The function is called only for |date= parameters and only if the |date=&lt;value&gt; is 
determined to be a valid date format.  The question of what to do with invalid date formats is not answered here.

The date parts in the input table are converted to an ISO 8601 conforming date string:
	single whole dates:		yyyy-mm-dd
	month and year dates:	yyyy-mm
	year dates:				yyyy
	ranges:					yyyy-mm-dd/yyyy-mm-dd
							yyyy-mm/yyyy-mm
							yyyy/yyyy

Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.

The input table has:
	year, year2 – always present; if before 1582, ignore months and days if present
	month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 99 Christmas
	day, day2 –  0 if not provided, 1-31 for days
	
the output table receives:
	rftdate:	an IS8601 formatted date
	rftchron:	a free-form version of the date, usually without year which is in rftdate (season ranges and proper-name dates)
	rftssn:		one of four season keywords: winter, spring, summer, fall (lowercase)
	rftquarter:	one of four values: 1, 2, 3, 4

]]

local function make_COinS_date (input, tCOinS_date)
	local date;																	-- one date or first date in a range
	local date2 = '';															-- end of range date
-- start temporary Julian / Gregorian calendar uncertainty detection
	local year = tonumber(input.year);											-- this temporary code to determine the extent of sources dated to the Julian/Gregorian
	local month = tonumber(input.month);										-- interstice 1 October 1582 – 1 January 1926
	local day = tonumber (input.day);
	if (0 ~= day) and															-- day must have a value for this to be a whole date
		(((1582 == year) and (10 &lt;= month) and (12 &gt;= month)) or				-- any whole 1582 date from 1 october to 31 December or
			((1926 == year) and (1 == month) and (1 == input.day)) or			-- 1 January 1926 or
				((1582 &lt; year) and (1925 &gt;= year))) then						-- any date 1 January 1583 – 31 December 1925
					tCOinS_date.inter_cal_cat = true;							-- set category flag true
	end
-- end temporary Julian / Gergorian calendar uncertainty detection
	
	if 1582 &gt; tonumber(input.year) or 20 &lt; tonumber(input.month) then			-- Julian calendar or season so &amp;rft.date gets year only
		date = input.year;
		if 0 ~= input.year2 and input.year ~= input.year2 then					-- if a range, only the second year portion when not the same as range start year
			date = string.format ('%.4d/%.4d', tonumber(input.year), tonumber(input.year2))		-- assemble the date range
		end
		if 20 &lt; tonumber(input.month) then										-- if season or proper-name date
			local season = {[24]='winter', [21]='spring', [22]='summer', [23]='fall', [33]='1', [34]='2', [35]='3', [36]='4', [98]='Easter', [99]='Christmas'};	-- seasons lowercase, no autumn; proper-names use title case
			if 0 == input.month2 then											-- single season date
				if 40 &lt;tonumber(input.month) then
					tCOinS_date.rftchron = season[input.month];					-- proper-name dates
				elseif 30 &lt;tonumber(input.month) then
					tCOinS_date.rftquarter = season[input.month];				-- quarters
				else
					tCOinS_date.rftssn = season[input.month];					-- seasons
				end
			else																-- season range with a second season specified
				if input.year ~= input.year2 then								-- season year – season year range or season year–year
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					if 0~= input.month2 then
						tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);
					end
				else															-- season–season year range
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2];	-- season–season year range
				end
			end
		end
		tCOinS_date.rftdate = date;
		return;																	-- done
	end
	
	if 0 ~= input.day then
		date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day));	-- whole date
	elseif 0 ~= input.month then
		date = string.format ('%s-%.2d', input.year, tonumber(input.month));	-- year and month
	else
		date = string.format ('%s', input.year);								-- just year
	end

	if 0 ~= input.year2 then
		if 0 ~= input.day2 then
			date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2));		-- whole date
		elseif 0 ~= input.month2 then
			date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2));	-- year and month
		else
			date2 = string.format ('/%s', input.year2);							-- just year
		end
	end
	
	tCOinS_date.rftdate = date .. date2;										-- date2 has the '/' separator
	return;
end


--[[--------------------------&lt; P A T T E R N S &gt;--------------------------------------------------------------

this is the list of patterns for date formats that this module recognizes.  Approximately the first half of these
patterns represent formats that might be reformatted into another format.  Those that might be reformatted have
'indicator' letters that identify the content of the matching capture: 'd' (day), 'm' (month), 'a' (anchor year),
'y' (year); second day, month, year have a '2' suffix.

These patterns are used for both date validation and for reformatting.  This table should not be moved to ~/Configuration
because changes to this table require changes to check_date() and to reformatter() and reformat_date()

]]

local patterns = {
	 																			-- year-initial numerical year-month-day
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'},					
																				-- month-initial: month day, year
	['Mdy'] = {'^(%D-) +([1-9]%d?), +((%d%d%d%d?)%a?)$', 'm', 'd', 'a', 'y'},
																				-- month-initial day range: month day–day, year; days are separated by endash
	['Md-dy'] = {'^(%D-) +([1-9]%d?)[%-–]([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'd2', 'a', 'y'},
																				-- day-initial: day month year
	['dMy'] = {'^([1-9]%d?) +(%D-) +((%d%d%d%d?)%a?)$', 'd', 'm', 'a', 'y'},
																				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed; not supported at en.wiki
--	['yMd'] = {'^((%d%d%d%d?)%a?) +(%D-) +(%d%d?)$', 'a', 'y', 'm', 'd'},
																				-- day-range-initial: day–day month year; days are separated by endash
	['d-dMy'] = {'^([1-9]%d?)[%-–]([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'd2', 'm', 'a', 'y'},
																				-- day initial month-day-range: day month - day month year; uses spaced endash
	['dM-dMy'] = {'^([1-9]%d?) +(%D-) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'd2', 'm2', 'a', 'y'},
																				-- month initial month-day-range: month day – month day, year;  uses spaced endash
	['Md-Mdy'] = {'^(%D-) +([1-9]%d?) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$','m', 'd', 'm2', 'd2', 'a', 'y'},
																				-- day initial month-day-year-range: day month year - day month year; uses spaced endash
	['dMy-dMy'] = {'^([1-9]%d?) +(%D-) +(%d%d%d%d) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'y', 'd2', 'm2', 'a', 'y2'},
																				-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
	['Mdy-Mdy'] = {'^(%D-) +([1-9]%d?), +(%d%d%d%d) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'y', 'm2', 'd2', 'a', 'y2'},

																				-- these date formats cannot be converted, per se, but month name can be rendered short or long
																				-- month/season year - month/season year; separated by spaced endash
	['My-My'] = {'^(%D-) +(%d%d%d%d) +[%-–] +(%D-) +((%d%d%d%d)%a?)$', 'm', 'y', 'm2', 'a', 'y2'},
																				-- month/season range year; months separated by endash
	['M-My'] = {'^(%D-)[%-–](%D-) +((%d%d%d%d)%a?)$', 'm', 'm2', 'a', 'y'},
																				-- month/season year or proper-name year; quarter year when First Quarter YYYY etc
	['My'] = {'^([^%d–]-) +((%d%d%d%d)%a?)$', 'm', 'a', 'y'},					-- this way because endash is a member of %D; %D- will match January–March 2019 when it shouldn't

																				-- these date formats cannot be converted
--	['Q,y'] = {'^(Q%a* +[1-4]), +((%d%d%d%d)%a?)$'},							-- Quarter n, yyyy

	['Sy4-y2'] = {'^(%D-) +((%d%d)%d%d)[%-–]((%d%d)%a?)$'},						-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
	['Sy-y'] = {'^(%D-) +(%d%d%d%d)[%-–]((%d%d%d%d)%a?)$'},						-- special case Winter/Summer year-year; year separated with unspaced endash
	['y-y'] = {'^(%d%d%d%d?)[%-–]((%d%d%d%d?)%a?)$'},							-- year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
	['y4-y2'] = {'^((%d%d)%d%d)[%-–]((%d%d)%a?)$'},								-- year range: YYYY–YY; separated by unspaced endash
	['y'] = {'^((%d%d%d%d?)%a?)$'},												-- year; here accept either YYY or YYYY
	}


--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only
allowed range separator is endash.  Additionally, check the date to see that it is a real date: no 31 in 30-day
months; no 29 February when not a leap year.  Months, both long-form and three character abbreviations, and seasons
must be spelled correctly.  Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and
COinS_date.  When this happens, the date parameter is used in the COinS metadata and the CITEREF identifier gets
its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, accessdate, embargo, archivedate, etc.)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is ISO 8601 format date; see make_COInS_date()

]]

local function check_date (date_string, param, tCOinS_date)
	local year;																	-- assume that year2, months, and days are not used;
	local year2=0;																-- second year in a year range
	local month=0;
	local month2=0;																-- second month in a month range
	local day=0;
	local day2=0;																-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match (patterns['ymd'][1]) then								-- year-initial numerical year month day format
		year, month, day=date_string:match (patterns['ymd'][1]);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or 0 == tonumber(day) then return false; end	-- month or day number not valid or not Gregorian calendar
		anchor_year = year;
	
--	elseif mw.ustring.match(date_string, patterns['Q,y'][1]) then				-- quarter n, year; here because much the same as Mdy
--		month, anchor_year, year=mw.ustring.match(date_string, patterns['Q,y'][1]);
--		if not is_valid_year(year) then return false; end
--		month = get_quarter_number (month, param);								-- get quarter number or nil
--		if not month then return false; end										-- not valid whatever it is

	elseif mw.ustring.match(date_string, patterns['Mdy'][1]) then				-- month-initial: month day, year
		month, day, anchor_year, year=mw.ustring.match(date_string, patterns['Mdy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
				
	elseif mw.ustring.match(date_string, patterns['Md-dy'][1]) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year=mw.ustring.match(date_string, patterns['Md-dy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2=month;															-- for metadata
		year2=year;

	elseif mw.ustring.match(date_string, patterns['dMy'][1]) then				-- day-initial: day month year
		day, month, anchor_year, year=mw.ustring.match(date_string, patterns['dMy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months

--[[ NOT supported at en.wiki
	elseif mw.ustring.match(date_string, patterns['yMd'][1]) then				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed
		anchor_year, year, month, day=mw.ustring.match(date_string, patterns['yMd'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
-- end NOT supported at en.wiki ]]

	elseif mw.ustring.match(date_string, patterns['d-dMy'][1]) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year=mw.ustring.match(date_string, patterns['d-dMy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2=month;															-- for metadata
		year2=year;

	elseif mw.ustring.match(date_string, patterns['dM-dMy'][1]) then			-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year=mw.ustring.match(date_string, patterns['dM-dMy'][1]);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif mw.ustring.match(date_string, patterns['Md-Mdy'][1]) then			-- month initial month-day-range: month day – month day, year;  uses spaced endash
		month, day, month2, day2, anchor_year, year=mw.ustring.match(date_string, patterns['Md-Mdy'][1]);
		if (not is_valid_month_season_range(month, month2, param)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2=year;

	elseif mw.ustring.match(date_string, patterns['dMy-dMy'][1]) then			-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2=mw.ustring.match(date_string, patterns['dMy-dMy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);

	elseif mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]) then			-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
		month, day, year, month2, day2, anchor_year, year2=mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);

	elseif mw.ustring.match(date_string, patterns['Sy4-y2'][1]) then			-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		local century;
		month, year, century, anchor_year, year2=mw.ustring.match(date_string, patterns['Sy4-y2'][1]);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;		-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;										-- assemble anchor_year from both years
		year2 = century..year2;													-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		month = get_season_number (month, param);

	elseif mw.ustring.match(date_string, patterns['Sy-y'][1]) then				-- special case Winter/Summer year-year; year separated with unspaced endash
		month, year, anchor_year, year2=mw.ustring.match(date_string, patterns['Sy-y'][1]);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;		-- 'month' can only be Winter or Summer
		anchor_year=year..'–'..anchor_year;										-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		month = get_season_number (month, param);								-- for metadata

	elseif mw.ustring.match(date_string, patterns['My-My'][1]) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2=mw.ustring.match(date_string, patterns['My-My'][1]);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then 	-- both must be month year, same month style
			month = get_month_number(month);
			month2 = get_month_number(month2);
		elseif 0 ~= get_season_number(month, param) and 0 ~= get_season_number(month2, param) then	-- both must be season year, not mixed
			month = get_season_number(month, param);
			month2 = get_season_number(month2, param);
		else
			 return false;
		end

	elseif mw.ustring.match(date_string, patterns['M-My'][1]) then				-- month/season range year; months separated by endash 
		month, month2, anchor_year, year=mw.ustring.match(date_string, patterns['M-My'][1]);
		if (not is_valid_month_season_range(month, month2, param)) or (not is_valid_year(year)) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
			month2 = get_month_number(month2);
		else
			month = get_season_number(month, param);
			month2 = get_season_number(month2, param);
		end
		year2=year;
		
	elseif mw.ustring.match(date_string, patterns['My'][1]) then				-- month/season/quarter/proper-name year
		month, anchor_year, year=mw.ustring.match(date_string, patterns['My'][1]);
		if not is_valid_year(year) then return false; end
		month = get_element_number (month, param);								-- get month season quarter proper-name number or nil
		if not month then return false; end										-- not valid whatever it is

	elseif mw.ustring.match(date_string, patterns['y-y'][1]) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2=mw.ustring.match(date_string, patterns['y-y'][1]);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, patterns['y4-y2'][1]) then				-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2=mw.ustring.match(date_string, patterns['y4-y2'][1]);
		anchor_year=year..'–'..anchor_year;										-- assemble anchor year from both years
		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century..year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match (date_string, patterns['y'][1]) then				-- year; here accept either YYY or YYYY
		anchor_year, year=mw.ustring.match (date_string, patterns['y'][1]);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;															-- date format not one of the MOS:DATE approved formats
	end

	if 'access-date' == param then												-- test accessdate here because we have numerical date parts
		if 0 ~= year and 0 ~= month and 0 ~= day and 							-- all parts of a single date required
			0 == year2 and 0 == month2 and 0 == day2 then						-- none of these; accessdate must not be a range
				if not is_valid_accessdate (year..'-'..month..'-'..day) then	
					return false;												-- return false when accessdate out of bounds
				end
		else
			return false;														-- return false when accessdate is a range of two dates
		end
	end

	local result=true;															-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result=is_valid_date(year,month,day);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year,month2,day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result=is_valid_date(year,month,day);
		result=result and is_valid_date(year2,month2,day2);
	end
	
	if false == result then return false; end

	if nil ~= tCOinS_date then													-- this table only passed into this function when testing |date= parameter values
		make_COinS_date ({year=year, month=month, day=day, year2=year2, month2=month2, day2=day2}, tCOinS_date);	-- make an ISO 8601 date string for COinS
	end
	
	return true, anchor_year;													-- format is good and date string represents a real date
end	


--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
a single error message is created as the dates are tested.

]]

local function dates(date_parameters_list, tCOinS_date)
	local anchor_year;		-- will return as nil if the date being tested is not |date=
	local COinS_date;		-- will return as nil if the date being tested is not |date=
	local embargo_date;															-- if embargo date is a good dmy, mdy, ymd date then holds original value else reset to 9999
	local error_message = &quot;&quot;;
	local good_date = false;
	
	for k, v in pairs(date_parameters_list) do									-- for each date-holding parameter in the list
		if is_set(v.val) then													-- if the parameter has a value
			v.val = mw.ustring.gsub (v.val, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9
			if v.val:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then						-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v.val:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);				-- get the year portion so it can be tested
				if 'date'==k then
					anchor_year, COinS_date = v.val:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year'==k then
					good_date = is_valid_year(year);
				end
			elseif 'date'==k then												-- if the parameter is |date=
				if v.val:match(&quot;^n%.d%.%a?$&quot;) then								-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((n%.d%.)%a?)&quot;);	--&quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v.val:match(&quot;^nd%a?$&quot;) then								-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((nd)%a?)&quot;);	--&quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v.val, k, tCOinS_date);	-- go test the date
				end
			elseif 'year'==k then												-- if the parameter is |year= it should hold only a year value
				if v.val:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then						-- if |year= 3 or 4 digits only with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((%d+)%a?)&quot;);
				end
			elseif 'embargo'==k then											-- if the parameter is |embargo=
				good_date = check_date (v.val, k);								-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date, embargo_date = is_valid_embargo_date (v.val);	-- is |embargo= date a single dmy, mdy, or ymd formatted date? yes:returns embargo; no: returns 9999
				end
			else																-- any other date-holding parameter
				good_date = check_date (v.val, k);								-- go test the date
			end
			if false==good_date then											-- assemble one error message so we don't add the tracking category multiple times
				if is_set(error_message) then									-- once we've added the first portion of the error message ...
					error_message=error_message .. &quot;, &quot;;						-- ... add a comma space separator
				end
				error_message=error_message .. &quot;&amp;#124;&quot; .. v.name .. &quot;=&quot;;		-- add the failed parameter
			end
		end
	end
	return anchor_year, embargo_date, error_message;							-- and done
end


--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function returns a numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

]]

local function year_date_check (year_string, date_string)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes
	
	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where both date and year are required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard range formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif mw.ustring.match(date_string, &quot;%d%d%d%d[%-–]%d%d&quot;) then				-- YYYY-YY date ranges
		local century;
		date1, century, date2 = mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	else
		result = 0;																-- no recognizable year in date
	end
	return result;
end


--[[--------------------------&lt; R E F O R M A T T E R &gt;--------------------------------------------------------

reformat 'date' into new format specified by format_param if pattern_idx (the current format of 'date') can be
reformatted.  Does the grunt work for reformat_dates().

The table re_formats maps patern_idx (current format) and format_param (desired format) to a table that holds:
	format string used by string.format()
	identifier letters ('d', 'm', 'y', 'd2', 'm2', 'y2') that serve as indexes into a table t{} that holds captures
		from mw.ustring.match() for the various date parts specified by  patterns[pattern_idx][1]

Items in patterns{} have the general form:
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'}, where:
		['ymd'] is pattern_idx
		patterns['ymd'][1] is the match pattern with captures for mw.ustring.match()
		patterns['ymd'][2] is an indicator letter identifying the content of the first capture
		patterns['ymd'][3] ... the second capture etc

when a pattern matches a date, the captures are loaded into table t{} in capture order using the idemtifier
characters as indexes into t{}  For the above, a ymd date is in t{} as:
	t.y = first capture (year), t.m = second capture (month), t.d = third capture (day)

To reformat, this function is called with the pattern_idx that matches the current format of the date and with
format_param set to the desired format.  This function loads table t{} as described and then calls string.format()
with the format string specified by re_format[pattern_idx][format_param][1] using values taken from t{} according
to the capture identifier letters specified by patterns[pattern_idx][format_param][n] where n is 2..

]]

local re_formats = {
	['ymd'] = {																	-- date format is ymd; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},									-- |df=yMd; not supported at en.wiki
		},
	['Mdy'] = {																	-- date format is Mdy; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- for long/short reformatting
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},									-- |df=yMd; not supported at en.wiki
		},
	['dMy'] = {																	-- date format is dMy; reformat to:
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- for long/short reformatting
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},									-- |df=yMd; not supported at en.wiki
		},
	['Md-dy'] = {																-- date format is Md-dy; reformat to:
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- for long/short reformatting
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- |df=dmy -&gt; d-dMy 
		},
	['d-dMy'] = {																-- date format is d-d&gt;y; reformat to:
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- for long/short reformatting
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- |df=mdy -&gt; Md-dy 
		},
	['dM-dMy'] = {																-- date format is dM-dMy; reformat to:
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- for long/short reformatting
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd', 'm2', 'd2', 'y'},				-- |df=mdy -&gt; Md-Mdy 
		},
	['Md-Mdy'] = {																-- date format is Md-Mdy; reformat to:
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd',  'm2', 'd2', 'y'},			-- for long/short reformatting
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- |df=dmy -&gt; dM-dMy 
		},
	['dMy-dMy'] = {																-- date format is dMy-dMy; reformat to:
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- for long/short reformatting
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- |df=mdy -&gt; Mdy-Mdy 
		},
	['Mdy-Mdy'] = {																-- date format is Mdy-Mdy; reformat to:
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- for long/short reformatting
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- |df=dmy -&gt; dMy-dMy 
		},
	['My-My'] = {																-- these for long/short reformatting
		['any'] = {'%s %s – %s %s', 'm', 'y', 'm2', 'y2'},						-- dmy/mdy agnostic
		},
	['M-My'] = {																-- these for long/short reformatting
		['any'] = {'%s–%s %s', 'm', 'm2', 'y'},									-- dmy/mdy agnostic
		},
	['My'] = {																	-- these for long/short reformatting
		['any'] = {'%s %s', 'm', 'y'},											-- dmy/mdy agnostic
		},
--	['yMd'] = {																	-- not supported at en.wiki
--		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
--		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
--		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
--		},
	}


local function reformatter (date, pattern_idx, format_param, mon_len)
	if not in_array (pattern_idx, {'ymd', 'Mdy', 'Md-dy', 'dMy', 'yMd', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- not in this set of date format patterns then not a reformattable date
	end
	
	if 'ymd' == format_param and in_array (pattern_idx, {'ymd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- ymd date ranges not supported at en.wiki; no point in reformatting ymd to ymd
	end

	if in_array (pattern_idx, {'My', 'M-My', 'My-My'}) then						-- these are not dmy/mdy so can't be 'reformatted' into either
		format_param = 'any';													-- so format-agnostic 
	end

--	if 'yMd' == format_param and in_array (pattern_idx, {'yMd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy'}) then	-- not supported at en.wiki
	if 'yMd' == format_param then												-- not supported at en.wiki
		return;																	-- not a reformattable date
	end
	
	local c1, c2, c3, c4, c5, c6, c7;											-- these hold the captures specified in patterns[pattern_idx][1]
	c1, c2, c3, c4, c5, c6, c7 = mw.ustring.match (date, patterns[pattern_idx][1]);	-- get the captures

	local t = {																	-- table that holds k/v pairs of date parts from the captures and patterns[pattern_idx][2..]
		[patterns[pattern_idx][2]] = c1;										-- at minimum there is always one capture with a matching indicator letter
		[patterns[pattern_idx][3] or 'x'] = c2;									-- patterns can have a variable number of captures; each capture requires an indicator letter;
		[patterns[pattern_idx][4] or 'x'] = c3;									-- where there is no capture, there is no indicator letter so n in patterns[pattern_idx][n] will be nil;
		[patterns[pattern_idx][5] or 'x'] = c4;									-- the 'x' here spoofs an indicator letter to prevent 'table index is nil' error
		[patterns[pattern_idx][6] or 'x'] = c5;
		[patterns[pattern_idx][7] or 'x'] = c6;
		[patterns[pattern_idx][8] or 'x'] = c7;
		};

	if t.a then																	-- if this date has an anchor year capture
		t.y = t.a;																-- use the anchor year capture when reassembling the date
	end

	if tonumber(t.m) then														-- if raw month is a number (converting from ymd)
		if 's' == mon_len then													-- if we are to use abbreviated month names
			t.m = cfg.date_names['inv_local_s'][tonumber(t.m)];					-- convert it to a month name
		else
			t.m = cfg.date_names['inv_local_l'][tonumber(t.m)];					-- convert it to a month name
		end
		t.d = t.d:gsub ('0(%d)', '%1');											-- strip leading '0' from day if present
	elseif 'ymd' == format_param then											-- when converting to ymd
		if 1582 &gt; tonumber(t.y) then											-- ymd format dates not allowed before 1582
			return;
		end
		t.m = string.format ('%02d', get_month_number (t.m));					-- make sure that month and day are two digits
		t.d = string.format ('%02d', t.d);
	elseif mon_len then															-- if mon_len is set to either 'short' or 'long'
		for _, mon in ipairs ({'m', 'm2'}) do									-- because there can be two month names, check both 
			if t[mon] then
				t[mon] = get_month_number (t[mon]);								-- get the month number for this month (is length agnostic)
				if 0 == t[mon] then return; end									-- seasons and named dates can't be converted
				t[mon] = (('s' == mon_len) and cfg.date_names['inv_local_s'][t[mon]]) or cfg.date_names['inv_local_l'][t[mon]];	-- fetch month name according to length
			end
		end
	end

	local new_date = string.format (re_formats[pattern_idx][format_param][1],	-- format string
		t[re_formats[pattern_idx][format_param][2]],							-- named captures from t{}
		t[re_formats[pattern_idx][format_param][3]],
		t[re_formats[pattern_idx][format_param][4]],
		t[re_formats[pattern_idx][format_param][5]],
		t[re_formats[pattern_idx][format_param][6]],
		t[re_formats[pattern_idx][format_param][7]],
		t[re_formats[pattern_idx][format_param][8]]
		);

	return new_date;
end


--[[-------------------------&lt; R E F O R M A T _ D A T E S &gt;--------------------------------------------------

Reformats existing dates into the format specified by format.

format is one of several manual keywords: dmy, dmy-all, mdy, mdy-all, ymd, ymd-all.  The -all version includes
access- and archive-dates; otherwise these dates are not reformatted.

This function allows automatic date formatting.  In ~/Configuration, the article source is searched for one of
the {{use xxx dates}} templates.  If found, xxx becomes the global date format as xxx-all.  If |cs1-dates= in
{{use xxx dates}} has legitimate value then that value determines how cs1|2 dates will be rendered.  Legitimate
values for |cs1-dates= are:
	l - all dates are rendered with long month names
	ls - publication dates use long month names; access-/archive-dates use abbreviated month names
	ly - publication dates use long month names; access-/archive-dates rendered in ymd format
	s - all dates are rendered with abbreviated (short) month names
	sy - publication dates use abbreviated month names; access-/archive-dates rendered in ymd format
	y - all dates are rendered in ymd format

the format argument for automatic date formatting will be the format specified by {{use xxx dates}} with the
value supplied by |cs1-dates so one of: xxx-l, xxx-ls, xxx-ly, xxx-s, xxx-sy, xxx-y, or simply xxx (|cs1-dates=
empty, omitted, or invalid) where xxx shall be either of dmy or mdy.

dates are extracted from date_parameters_list, reformatted (if appropriate), and then written back into the
list in the new format.  Dates in date_parameters_list are presumed here to be valid (no errors).  This function
returns true when a date has been reformatted, false else.  Actual reformatting is done by reformatter().

]]

local function reformat_dates (date_parameters_list, format)
	local all = false;															-- set to false to skip access- and archive-dates
	local len_p = 'l';															-- default publication date length shall be long
	local len_a = 'l';															-- default access-/archive-date length shall be long
	local result = false;
	local new_date;																
	
	if format:match('%a+%-all') then											-- manual df keyword; auto df keyword when length not specified in {{use xxx dates}}; 
		format = format:match('(%a+)%-all');									-- extract the format
		all = true;																-- all dates are long format dates because this keyword doesn't specify length
	elseif format:match('%a+%-[lsy][sy]?') then									-- auto df keywords; internal only
		all = true;																-- auto df applies to all dates; use length specified by capture len_p for all dates
		format, len_p, len_a = format:match('(%a+)%-([lsy])([sy]?)');			-- extract the format and length keywords
		if 'y' == len_p then													-- because allowed by MOS:DATEUNIFY (sort of) range dates and My dates not reformatted
			format = 'ymd';														-- override {{use xxx dates}}
		elseif (not is_set(len_a)) or (len_p == len_a) then						-- no access-/archive-date length specified or same length as publication dates then
			len_a = len_p;														-- in case len_a not set
		end
	end																			-- else only publication dates and they are long

	for param_name, param_val in pairs (date_parameters_list) do				-- for each date-holding parameter in the list
		if is_set (param_val.val) then											-- if the parameter has a value
			if not (not all and in_array (param_name, {'access-date', 'archive-date'})) then	-- skip access- or archive-date unless format is xxx-all; yeah, ugly; TODO: find a better way
				for pattern_idx, pattern in pairs (patterns) do
					if mw.ustring.match (param_val.val, pattern[1]) then
						if all and in_array (param_name, {'access-date', 'archive-date'}) then	-- if this date is an access- or archive-date
							new_date = reformatter (param_val.val, pattern_idx, (('y' == len_a) and 'ymd') or format, len_a);	-- choose ymd or dmy/mdy according to len_a setting
						else													-- all other dates
							new_date = reformatter (param_val.val, pattern_idx, format, len_p);
						end
						
						if new_date then										-- set when date was reformatted
							date_parameters_list[param_name].val = new_date;	-- update date in date list
							result = true;										-- and announce that changes have been made
						end
					end	-- if
				end		-- for
			end			-- if
		end				-- if
	end					-- for
return result;																	-- declare boolean result and done
end


--[[--------------------------&lt; D A T E _ H Y P H E N _ T O _ D A S H &gt;----------------------------------------

Loops through the list of date-holding parameters and converts any hyphen to an ndash.  Not called if the cs1|2
template has any date errors.

Modifies the date_parameters_list and returns true if hyphens are replaced, else returns false.

]]

local function date_hyphen_to_dash (date_parameters_list)
	local result = false;
	local n;
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set (param_val.val) then
			if not mw.ustring.match (param_val.val, '%d%d%d%d%-%d%d%-%d%d') then	-- for those that are not ymd dates (ustring because here digits may not be western)
				param_val.val, n = param_val.val:gsub ('%-', '–');				-- replace any hyphen with ndash
				if 0 ~= n then
					date_parameters_list[param_name].val = param_val.val;		-- update the list
					result = true;
				end
			end
		end
	end
	return result;																-- so we know if any hyphens were replaced
end


--[[-------------------------&lt; D A T E _ N A M E _ X L A T E &gt;------------------------------------------------

Attempts to translate English month names to local-language month names using names supplied by MediaWiki's
date parser function.  This is simple name-for-name replacement and may not work for all languages.

if xlat_dig is true, this function will also translate western (English) digits to the local language's digits.
This will also translate ymd dates.

]]

local function	date_name_xlate (date_parameters_list, xlt_dig)
	local xlate;
	local mode;																	-- long or short month names
	local modified = false;
	local date;
	
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val.val) then											-- if the parameter has a value
			date = param_val.val;
			for month in mw.ustring.gmatch (date, '%a+') do						-- iterate through all dates in the date (single date or date range)
				if cfg.date_names.en.long[month] then
					mode = 'F';													-- English name is long so use long local name
				elseif cfg.date_names.en.short[month] then
					mode = 'M';													-- English name is short so use short local name
				else
					mode = nil;													-- not an English month name; could be local language month name or an English season name
				end
		
				if mode then													-- might be a season
					xlate = lang_object:formatDate(mode, '1' .. month);			-- translate the month name to this local language
					date = mw.ustring.gsub (date, month, xlate);				-- replace the English with the translation
					date_parameters_list[param_name].val = date;				-- save the translated date
					modified = true;
				end
			end

			if xlt_dig then														-- shall we also translate digits?
				date = date:gsub ('%d', cfg.date_names.xlate_digits);			-- translate digits from western to 'local digits'
				date_parameters_list[param_name].val = date;					-- save the translated date
				modified = true;
			end
		end
	end
	
	return modified;
	end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	is_set = utilities_page_ptr.is_set;											-- import functions from selected Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;										-- import functions from selected Module:Citation/CS1/Utilities module
	cfg = cfg_table_ptr;														-- import tables from selected Module:Citation/CS1/Configuration
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {																		-- return exported functions
	dates = dates,
	year_date_check = year_date_check,
	reformat_dates = reformat_dates,
	date_hyphen_to_dash = date_hyphen_to_dash,
	date_name_xlate = date_name_xlate,
	set_selected_modules = set_selected_modules
	}</text>
      <sha1>1377zdgd6gluiiiiyqg8ybdys4wiz0a</sha1>
    </revision>
    <revision>
      <id>4849</id>
      <parentid>4848</parentid>
      <timestamp>2020-10-10T13:22:58Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4849</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="60957" sha1="ds0l4tghd9b1ze47i4ysqzmmocnzkhm" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local add_prop_cat, is_set, in_array, wrap_style;								-- imported functions from selected Module:Citation/CS1/Utilities
local cfg;																		-- table of tables imported from selected Module:Citation/CS1/Configuration


--[[--------------------------&lt; F I L E - S C O P E   D E C L A R A T I O N S &gt;--------------------------------

File-scope variables are declared here

]]

local lang_object = mw.getContentLanguage();									-- used by is_valid_accessdate(), is_valid_year(), date_name_xlate(); TODO: move to ~/Configuration?
local year_limit;																-- used by is_valid_year()


--[=[-------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |access-date= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-English date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate().  To get around that
call this function with YYYY-MM-DD format dates.

]=]

local function is_valid_accessdate (accessdate)
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold Unix time stamps representing the dates

	good1, access_ts = pcall (lang_object.formatDate, lang_object, 'U', accessdate );			-- convert accessdate value to Unix timestamp 
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which which tonumber() may not understand
		access_ts = tonumber (access_ts) or lang_object:parseFormattedNumber (access_ts);			-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to Unix time stamp
	end

	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end


--[[--------------------------&lt; I S _ V A L I D _ E M B A R G O _ D A T E &gt;------------------------------------

returns true and date value if that value has proper dmy, mdy, ymd format.

returns false and 9999 (embargoed forever) when date value is not proper format; assumes that when |pmc-embargo-date= is
set, the editor intended to embargo a PMC but |pmc-embargo-date= does not hold a single date.

]]

local function is_valid_embargo_date (v)
	if v:match ('^%d%d%d%d%-%d%d%-%d%d$') or									-- ymd
		v:match ('^%d%d?%s+%a+%s+%d%d%d%d$') or									-- dmy
		v:match ('^%a+%s+%d%d?%s*,%s*%d%d%d%d$') then							-- mdy
			return true, v;
	end
	return false, '9999';														-- if here not good date so return false and set embargo date to long time in future
end


--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct.
If not a valid month, returns 0

]]

local function get_month_number (month)
	return cfg.date_names['local'].long[month] or cfg.date_names['local'].short[month] or		-- look for local names first
			cfg.date_names['en'].long[month] or	cfg.date_names['en'].short[month] or			-- failing that, look for English names
			0;																					-- not a recognized month name
end


--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 21 for Spring, etc.  Capitalization and spelling
must be correct. If not a valid season, returns 0.
	21-24 = Spring, Summer, Autumn, Winter, independent of “Hemisphere”

returns 0 when &lt;param&gt; is not |date=

Season numbering is defined by Extended Date/Time Format (EDTF) specification (https://www.loc.gov/standards/datetime/)
which became part of ISO 8601 in 2019.  See '§Sub-year groupings'.  The standard defines various divisions using
numbers 21-41.  cs1|2 only supports generic seasons.  EDTF does support the distinction between north and south
hemispere seasons but cs1|2 has no way to make that distinction.

These additional divisions not currently supported:
	25-28 = Spring - Northern Hemisphere, Summer- Northern Hemisphere, Autumn - Northern Hemisphere, Winter - Northern Hemisphere
	29-32 = Spring – Southern Hemisphere, Summer– Southern Hemisphere, Autumn – Southern Hemisphere, Winter - Southern Hemisphere
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)

]]

local function get_season_number (season, param)
	if 'date' ~= param then
		return 0;																-- season dates only supported by |date=
	end
	return cfg.date_names['local'].season[season] or							-- look for local names first
			cfg.date_names['en'].season[season] or								-- failing that, look for English names
			0;																	-- not a recognized season name
end


--[[--------------------------&lt; G E T _ Q U A R T E R _ N U M B E R &gt;------------------------------------------

returns a number according to the sequence of quarters in a year: 33 for first quarter, etc.  Capitalization and spelling
must be correct. If not a valid quarter, returns 0.
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)

returns 0 when &lt;param&gt; is not |date=

Quarter numbering is defined by Extended Date/Time Format (EDTF) specification (https://www.loc.gov/standards/datetime/)
which became part of ISO 8601 in 2019.  See '§Sub-year groupings'.  The standard defines various divisions using
numbers 21-41.  cs1|2 only supports generic seasons and quarters.

These additional divisions not currently supported:
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)

]]

local function get_quarter_number (quarter, param)
	if 'date' ~= param then
		return 0;																-- quarter dates only supported by |date=
	end
	quarter = mw.ustring.gsub (quarter, ' +', ' ');								-- special case replace multiple space chars with a single space char
	return cfg.date_names['local'].quarter[quarter] or							-- look for local names first
			cfg.date_names['en'].quarter[quarter] or							-- failing that, look for English names
			0;																	-- not a recognized quarter name
end


--[[--------------------------&lt; G E T _ P R O P E R _ N A M E _ N U M B E R &gt;----------------------------------

returns a non-zero number if date contains a recognized proper-name.  Capitalization and spelling must be correct.

returns 0 when &lt;param&gt; is not |date=

]]

local function get_proper_name_number (name, param)
	if 'date' ~= param then
		return 0;																-- proper-name dates only supported by |date=
	end
	return cfg.date_names['local'].named[name] or								-- look for local names dates first
			cfg.date_names['en'].named[name] or									-- failing that, look for English names
			0;																	-- not a recognized named date
end


--[[--------------------------&lt; G E T _ E L E M E N T _ N U M B E R &lt;------------------------------------------

returns true if month or season or quarter or proper name is valid (properly spelled, capitalized, abbreviated)

]]

local function get_element_number (element, param)
	local num;
	
	local funcs = {get_month_number, get_season_number, get_quarter_number, get_proper_name_number};	-- list of functions to execute in order
	
	for _, func in ipairs (funcs) do											-- spin through the function list
		num = func (element, param);											-- call the function and get the returned number
		if 0 ~= num then														-- non-zero when valid month season quarter 
			return num;															-- return that number
		end
	end
	return nil;																	-- not valid
end


--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one
year in the future are not acceptable.

]]

local function is_valid_year (year)
	if not is_set(year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;									-- global variable so we only have to fetch it once
	end

	year = tonumber (year) or lang_object:parseFormattedNumber (year);			-- convert to numbers for the comparison;
	return year and (year &lt;= year_limit) or false;
end


--[[--------------------------&lt; I S _ V A L I D _ D A T E &gt;----------------------------------------------------

Returns true if day is less than or equal to the number of days in month and year is no farther into the future
than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap
years before 1582 and Gregorian leap years after 1582. Where the two calendars overlap (1582 to approximately
1923) dates are assumed to be Gregorian.

]]

local function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year(year) then												-- no farther into the future than next year
		return false;
	end
	
	month = tonumber(month);													-- required for YYYY-MM-DD dates
	
	if (2 == month) then															-- if February
		month_length = 28;														-- then 28 days unless
		if 1582 &gt; tonumber(year) then											-- Julian calendar
			if 0 == (year%4) then													-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		else																	-- Gregorian calendar
			if (0 == (year%4) and (0 ~= (year%100) or 0 == (year%400))) then			-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		end
	else
		month_length = days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
There is a special test for May because it can be either short or long form.

Returns true when style for both months is the same

]]

local function is_valid_month_range_style (month1, month2)
local len1 = month1:len();
local len2 = month2:len();
	if len1 == len2 then
		return true;															-- both months are short form so return true
	elseif 'May' == month1 or 'May'== month2 then -- ToDo: I18N
		return true;															-- both months are long form so return true
	elseif 3 == len1 or 3 == len2 then
		return false;															-- months are mixed form so return false
	else
		return true;															-- both months are long form so return true
	end
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

All season ranges are accepted as valid because there are publishers out there who have published a Summer–Spring YYYY issue, hence treat as ok

]]

local function is_valid_month_season_range(range_start, range_end, param)
	local range_start_number = get_month_number (range_start);
	local range_end_number;

	if 0 == range_start_number then												-- is this a month range?
		range_start_number = get_season_number (range_start, param);			-- not a month; is it a season? get start season number
		range_end_number = get_season_number (range_end, param);				-- get end season number

		if (0 ~= range_start_number) and (0 ~= range_end_number) and (range_start_number ~= range_end_number) then
			return true;														-- any season pairing is accepted except when both are the same
		end
		return false;															-- range_start and/or range_end is not a season
	end
																				-- here when range_start is a month
	range_end_number = get_month_number (range_end);							-- get end month number
	if range_start_number &lt; range_end_number then								-- range_start is a month; does range_start precede range_end?
		if is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
		end
	end
	return false;																-- range_start month number is greater than or equal to range end number; or range end isn't a month
end


--[[--------------------------&lt; M A K E _ C O I N S _ D A T E &gt;------------------------------------------------

This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1.  The function is called only for |date= parameters and only if the |date=&lt;value&gt; is 
determined to be a valid date format.  The question of what to do with invalid date formats is not answered here.

The date parts in the input table are converted to an ISO 8601 conforming date string:
	single whole dates:		yyyy-mm-dd
	month and year dates:	yyyy-mm
	year dates:				yyyy
	ranges:					yyyy-mm-dd/yyyy-mm-dd
							yyyy-mm/yyyy-mm
							yyyy/yyyy

Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.

The input table has:
	year, year2 – always present; if before 1582, ignore months and days if present
	month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 99 Christmas
	day, day2 –  0 if not provided, 1-31 for days
	
the output table receives:
	rftdate:	an ISO 8601 formatted date
	rftchron:	a free-form version of the date, usually without year which is in rftdate (season ranges and proper-name dates)
	rftssn:		one of four season keywords: winter, spring, summer, fall (lowercase)
	rftquarter:	one of four values: 1, 2, 3, 4

]]

local function make_COinS_date (input, tCOinS_date)
	local date;																	-- one date or first date in a range
	local date2 = '';															-- end of range date
-- start temporary Julian / Gregorian calendar uncertainty detection
	local year = tonumber(input.year);											-- this temporary code to determine the extent of sources dated to the Julian/Gregorian
	local month = tonumber(input.month);										-- interstice 1 October 1582 – 1 January 1926
	local day = tonumber (input.day);
	if (0 ~= day) and															-- day must have a value for this to be a whole date
		(((1582 == year) and (10 &lt;= month) and (12 &gt;= month)) or				-- any whole 1582 date from 1 October to 31 December or
			((1926 == year) and (1 == month) and (1 == input.day)) or			-- 1 January 1926 or
				((1582 &lt; year) and (1925 &gt;= year))) then						-- any date 1 January 1583 – 31 December 1925
					tCOinS_date.inter_cal_cat = true;							-- set category flag true
	end
-- end temporary Julian / Gregorian calendar uncertainty detection
	
	if 1582 &gt; tonumber(input.year) or 20 &lt; tonumber(input.month) then			-- Julian calendar or season so &amp;rft.date gets year only
		date = input.year;
		if 0 ~= input.year2 and input.year ~= input.year2 then					-- if a range, only the second year portion when not the same as range start year
			date = string.format ('%.4d/%.4d', tonumber(input.year), tonumber(input.year2))		-- assemble the date range
		end
		if 20 &lt; tonumber(input.month) then										-- if season or proper-name date
			local season = {[24] = 'winter', [21] = 'spring', [22] = 'summer', [23] = 'fall', [33] = '1', [34] = '2', [35] = '3', [36] = '4', [98] = 'Easter', [99] = 'Christmas'};	-- seasons lowercase, no autumn; proper-names use title case
			if 0 == input.month2 then											-- single season date
				if 40 &lt; tonumber(input.month) then
					tCOinS_date.rftchron = season[input.month];					-- proper-name dates
				elseif 30 &lt; tonumber(input.month) then
					tCOinS_date.rftquarter = season[input.month];				-- quarters
				else
					tCOinS_date.rftssn = season[input.month];					-- seasons
				end
			else																-- season range with a second season specified
				if input.year ~= input.year2 then								-- season year – season year range or season year–year
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					if 0~= input.month2 then
						tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);
					end
				else															-- season–season year range
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2];	-- season–season year range
				end
			end
		end
		tCOinS_date.rftdate = date;
		return;																	-- done
	end
	
	if 0 ~= input.day then
		date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day));	-- whole date
	elseif 0 ~= input.month then
		date = string.format ('%s-%.2d', input.year, tonumber(input.month));	-- year and month
	else
		date = string.format ('%s', input.year);								-- just year
	end

	if 0 ~= input.year2 then
		if 0 ~= input.day2 then
			date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2));		-- whole date
		elseif 0 ~= input.month2 then
			date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2));	-- year and month
		else
			date2 = string.format ('/%s', input.year2);							-- just year
		end
	end
	
	tCOinS_date.rftdate = date .. date2;										-- date2 has the '/' separator
	return;
end


--[[--------------------------&lt; P A T T E R N S &gt;--------------------------------------------------------------

this is the list of patterns for date formats that this module recognizes.  Approximately the first half of these
patterns represent formats that might be reformatted into another format.  Those that might be reformatted have
'indicator' letters that identify the content of the matching capture: 'd' (day), 'm' (month), 'a' (anchor year),
'y' (year); second day, month, year have a '2' suffix.

These patterns are used for both date validation and for reformatting.  This table should not be moved to ~/Configuration
because changes to this table require changes to check_date() and to reformatter() and reformat_date()

]]

local patterns = {
	 																			-- year-initial numerical year-month-day
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'},					
																				-- month-initial: month day, year
	['Mdy'] = {'^(%D-) +([1-9]%d?), +((%d%d%d%d?)%a?)$', 'm', 'd', 'a', 'y'},
																				-- month-initial day range: month day–day, year; days are separated by endash
	['Md-dy'] = {'^(%D-) +([1-9]%d?)[%-–]([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'd2', 'a', 'y'},
																				-- day-initial: day month year
	['dMy'] = {'^([1-9]%d?) +(%D-) +((%d%d%d%d?)%a?)$', 'd', 'm', 'a', 'y'},
																				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed; not supported at en.wiki
--	['yMd'] = {'^((%d%d%d%d?)%a?) +(%D-) +(%d%d?)$', 'a', 'y', 'm', 'd'},
																				-- day-range-initial: day–day month year; days are separated by endash
	['d-dMy'] = {'^([1-9]%d?)[%-–]([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'd2', 'm', 'a', 'y'},
																				-- day initial month-day-range: day month - day month year; uses spaced endash
	['dM-dMy'] = {'^([1-9]%d?) +(%D-) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'd2', 'm2', 'a', 'y'},
																				-- month initial month-day-range: month day – month day, year;  uses spaced endash
	['Md-Mdy'] = {'^(%D-) +([1-9]%d?) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$','m', 'd', 'm2', 'd2', 'a', 'y'},
																				-- day initial month-day-year-range: day month year - day month year; uses spaced endash
	['dMy-dMy'] = {'^([1-9]%d?) +(%D-) +(%d%d%d%d) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'y', 'd2', 'm2', 'a', 'y2'},
																				-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
	['Mdy-Mdy'] = {'^(%D-) +([1-9]%d?), +(%d%d%d%d) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'y', 'm2', 'd2', 'a', 'y2'},

																				-- these date formats cannot be converted, per se, but month name can be rendered short or long
																				-- month/season year - month/season year; separated by spaced endash
	['My-My'] = {'^(%D-) +(%d%d%d%d) +[%-–] +(%D-) +((%d%d%d%d)%a?)$', 'm', 'y', 'm2', 'a', 'y2'},
																				-- month/season range year; months separated by endash
	['M-My'] = {'^(%D-)[%-–](%D-) +((%d%d%d%d)%a?)$', 'm', 'm2', 'a', 'y'},
																				-- month/season year or proper-name year; quarter year when First Quarter YYYY etc.
	['My'] = {'^([^%d–]-) +((%d%d%d%d)%a?)$', 'm', 'a', 'y'},					-- this way because endash is a member of %D; %D- will match January–March 2019 when it shouldn't

																				-- these date formats cannot be converted
	['Sy4-y2'] = {'^(%D-) +((%d%d)%d%d)[%-–]((%d%d)%a?)$'},						-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
	['Sy-y'] = {'^(%D-) +(%d%d%d%d)[%-–]((%d%d%d%d)%a?)$'},						-- special case Winter/Summer year-year; year separated with unspaced endash
	['y-y'] = {'^(%d%d%d%d?)[%-–]((%d%d%d%d?)%a?)$'},							-- year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
	['y4-y2'] = {'^((%d%d)%d%d)[%-–]((%d%d)%a?)$'},								-- year range: YYYY–YY; separated by unspaced endash
	['y'] = {'^((%d%d%d%d?)%a?)$'},												-- year; here accept either YYY or YYYY
	}


--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only
allowed range separator is endash.  Additionally, check the date to see that it is a real date: no 31 in 30-day
months; no 29 February when not a leap year.  Months, both long-form and three character abbreviations, and seasons
must be spelled correctly.  Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and
COinS_date.  When this happens, the date parameter is (DEBUG: not?) used in the COinS metadata and the CITEREF identifier gets
its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, publication-date, access-date, pmc-embargo-date, archive-date, lay-date)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is ISO 8601 format date; see make_COInS_date()

]]

local function check_date (date_string, param, tCOinS_date)
	local year;																	-- assume that year2, months, and days are not used;
	local year2 = 0;																-- second year in a year range
	local month = 0;
	local month2 = 0;																-- second month in a month range
	local day = 0;
	local day2 = 0;																-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match (patterns['ymd'][1]) then								-- year-initial numerical year month day format
		year, month, day = date_string:match (patterns['ymd'][1]);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or 0 == tonumber(day) then return false; end	-- month or day number not valid or not Gregorian calendar
		anchor_year = year;
	
	elseif mw.ustring.match(date_string, patterns['Mdy'][1]) then				-- month-initial: month day, year
		month, day, anchor_year, year = mw.ustring.match(date_string, patterns['Mdy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
				
	elseif mw.ustring.match(date_string, patterns['Md-dy'][1]) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year = mw.ustring.match(date_string, patterns['Md-dy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2=month;															-- for metadata
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['dMy'][1]) then				-- day-initial: day month year
		day, month, anchor_year, year = mw.ustring.match(date_string, patterns['dMy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months

--[[ NOT supported at en.wiki
	elseif mw.ustring.match(date_string, patterns['yMd'][1]) then				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed
		anchor_year, year, month, day = mw.ustring.match(date_string, patterns['yMd'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
-- end NOT supported at en.wiki ]]

	elseif mw.ustring.match(date_string, patterns['d-dMy'][1]) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year = mw.ustring.match(date_string, patterns['d-dMy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2 = month;															-- for metadata
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['dM-dMy'][1]) then			-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year = mw.ustring.match(date_string, patterns['dM-dMy'][1]);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['Md-Mdy'][1]) then			-- month initial month-day-range: month day – month day, year; uses spaced endash
		month, day, month2, day2, anchor_year, year = mw.ustring.match(date_string, patterns['Md-Mdy'][1]);
		if (not is_valid_month_season_range(month, month2, param)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['dMy-dMy'][1]) then			-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2 = mw.ustring.match(date_string, patterns['dMy-dMy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		if 0 == month or 0 == month2 then return false; end						-- both must be valid

	elseif mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]) then			-- month initial month-day-year-range: month day, year – month day, year; uses spaced endash
		month, day, year, month2, day2, anchor_year, year2 = mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number(month2);
		if 0 == month or 0 == month2 then return false; end						-- both must be valid

	elseif mw.ustring.match(date_string, patterns['Sy4-y2'][1]) then			-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		local century;
		month, year, century, anchor_year, year2 = mw.ustring.match(date_string, patterns['Sy4-y2'][1]);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;		-- 'month' can only be Winter or Summer
		anchor_year = year .. '–' .. anchor_year;										-- assemble anchor_year from both years
		year2 = century..year2;													-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		month = get_season_number(month, param);

	elseif mw.ustring.match(date_string, patterns['Sy-y'][1]) then				-- special case Winter/Summer year-year; year separated with unspaced endash
		month, year, anchor_year, year2 = mw.ustring.match(date_string, patterns['Sy-y'][1]);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;		-- 'month' can only be Winter or Summer
		anchor_year = year .. '–' .. anchor_year;										-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		month = get_season_number (month, param);								-- for metadata

	elseif mw.ustring.match(date_string, patterns['My-My'][1]) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2 = mw.ustring.match(date_string, patterns['My-My'][1]);
		anchor_year = year .. '–' .. anchor_year;										-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then 	-- both must be month year, same month style
			month = get_month_number(month);
			month2 = get_month_number(month2);
		elseif 0 ~= get_season_number(month, param) and 0 ~= get_season_number(month2, param) then	-- both must be season year, not mixed
			month = get_season_number(month, param);
			month2 = get_season_number(month2, param);
		else
			 return false;
		end

	elseif mw.ustring.match(date_string, patterns['M-My'][1]) then				-- month/season range year; months separated by endash 
		month, month2, anchor_year, year = mw.ustring.match(date_string, patterns['M-My'][1]);
		if (not is_valid_month_season_range(month, month2, param)) or (not is_valid_year(year)) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
			month2 = get_month_number(month2);
			if 0 == month or 0 == month2 then return false; end
		else
			month = get_season_number(month, param);
			month2 = get_season_number(month2, param);
		end
		year2 = year;
		
	elseif mw.ustring.match(date_string, patterns['My'][1]) then				-- month/season/quarter/proper-name year
		month, anchor_year, year = mw.ustring.match(date_string, patterns['My'][1]);
		if not is_valid_year(year) then return false; end
		month = get_element_number(month, param);								-- get month season quarter proper-name number or nil
		if not month then return false; end										-- not valid whatever it is

	elseif mw.ustring.match(date_string, patterns['y-y'][1]) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2 = mw.ustring.match(date_string, patterns['y-y'][1]);
		anchor_year = year .. '–' .. anchor_year;										-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, patterns['y4-y2'][1]) then				-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2 = mw.ustring.match(date_string, patterns['y4-y2'][1]);
		anchor_year = year .. '–' .. anchor_year;									-- assemble anchor year from both years

		if in_array (param, {'date', 'publication-date', 'year'}) then
			add_prop_cat ('year_range_abbreviated');
		end

		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century .. year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, patterns['y'][1]) then				-- year; here accept either YYY or YYYY
		anchor_year, year = mw.ustring.match(date_string, patterns['y'][1]);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;															-- date format not one of the MOS:DATE approved formats
	end

	if 'access-date' == param then												-- test accessdate here because we have numerical date parts
		if 0 ~= year and 0 ~= month and 0 ~= day and 							-- all parts of a single date required
			0 == year2 and 0 == month2 and 0 == day2 then						-- none of these; accessdate must not be a range
				if not is_valid_accessdate(year .. '-' .. month .. '-' .. day) then	
					return false;												-- return false when accessdate out of bounds
				end
		else
			return false;														-- return false when accessdate is a range of two dates
		end
	end

	local result=true;															-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result = is_valid_date(year, month, day);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result = is_valid_date(year, month, day);
		result = result and is_valid_date(year, month, day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result = is_valid_date(year, month, day);
		result = result and is_valid_date(year, month2, day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result = is_valid_date(year, month, day);
		result = result and is_valid_date(year2, month2, day2);
	end
	
	if false == result then return false; end

	if nil ~= tCOinS_date then													-- this table only passed into this function when testing |date= parameter values
		make_COinS_date ({year = year, month = month, day = day, year2 = year2, month2 = month2, day2 = day2}, tCOinS_date);	-- make an ISO 8601 date string for COinS
	end
	
	return true, anchor_year;													-- format is good and date string represents a real date
end	


--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
parameters with errors are added to the &lt;error_list&gt; sequence table as the dates are tested.

]]

local function dates(date_parameters_list, tCOinS_date, error_list)
	local anchor_year;															-- will return as nil if the date being tested is not |date=
	local COinS_date;															-- will return as nil if the date being tested is not |date=
	local embargo_date;															-- if embargo date is a good dmy, mdy, ymd date then holds original value else reset to 9999
	local good_date = false;

	for k, v in pairs(date_parameters_list) do									-- for each date-holding parameter in the list
		if is_set(v.val) then													-- if the parameter has a value
			v.val = mw.ustring.gsub(v.val, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9
			if v.val:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then						-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v.val:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);				-- get the year portion so it can be tested
				if 'date' == k then
					anchor_year, COinS_date = v.val:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year' == k then
					good_date = is_valid_year(year);
				end
			elseif 'date' == k then												-- if the parameter is |date=
				if v.val:match(&quot;^n%.d%.%a?$&quot;) then -- ToDo: I18N								-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((n%.d%.)%a?)&quot;); -- ToDo: I18N	-- &quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v.val:match(&quot;^nd%a?$&quot;) then -- ToDo: I18N								-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((nd)%a?)&quot;); -- ToDo: I18N	-- &quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v.val, k, tCOinS_date);	-- go test the date
				end
			elseif 'year' == k then												-- if the parameter is |year= it should hold only a year value
				if v.val:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then						-- if |year = 3 or 4 digits only with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((%d+)%a?)&quot;);
				end
			elseif 'pmc-embargo-date' == k then											-- if the parameter is |pmc-embargo-date=
				good_date = check_date (v.val, k);								-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date, embargo_date = is_valid_embargo_date (v.val);	-- is |pmc-embargo-date= date a single dmy, mdy, or ymd formatted date? yes: returns embargo; no: returns 9999
				end
			else																-- any other date-holding parameter
				good_date = check_date (v.val, k);								-- go test the date
			end
			if false == good_date then											-- assemble one error message so we don't add the tracking category multiple times
				table.insert (error_list, wrap_style ('parameter', v.name));	-- make parameter name suitable for error message list
			end
		end
	end
	return anchor_year, embargo_date;											-- and done
end


--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function returns a numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

]]

local function year_date_check (year_string, date_string)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes
	
	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where both date and year are required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard range formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif mw.ustring.match(date_string, &quot;%d%d%d%d[%-–]%d%d&quot;) then				-- YYYY-YY date ranges
		local century;
		date1, century, date2 = mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	else
		result = 0;																-- no recognizable year in date
	end
	return result;
end


--[[--------------------------&lt; R E F O R M A T T E R &gt;--------------------------------------------------------

reformat 'date' into new format specified by format_param if pattern_idx (the current format of 'date') can be
reformatted.  Does the grunt work for reformat_dates().

The table re_formats maps pattern_idx (current format) and format_param (desired format) to a table that holds:
	format string used by string.format()
	identifier letters ('d', 'm', 'y', 'd2', 'm2', 'y2') that serve as indexes into a table t{} that holds captures
		from mw.ustring.match() for the various date parts specified by  patterns[pattern_idx][1]

Items in patterns{} have the general form:
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'}, where:
		['ymd'] is pattern_idx
		patterns['ymd'][1] is the match pattern with captures for mw.ustring.match()
		patterns['ymd'][2] is an indicator letter identifying the content of the first capture
		patterns['ymd'][3] ... the second capture etc.

when a pattern matches a date, the captures are loaded into table t{} in capture order using the idemtifier
characters as indexes into t{}  For the above, a ymd date is in t{} as:
	t.y = first capture (year), t.m = second capture (month), t.d = third capture (day)

To reformat, this function is called with the pattern_idx that matches the current format of the date and with
format_param set to the desired format.  This function loads table t{} as described and then calls string.format()
with the format string specified by re_format[pattern_idx][format_param][1] using values taken from t{} according
to the capture identifier letters specified by patterns[pattern_idx][format_param][n] where n is 2..

]]

local re_formats = {
	['ymd'] = {																	-- date format is ymd; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},									-- |df=yMd; not supported at en.wiki
		},
	['Mdy'] = {																	-- date format is Mdy; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- for long/short reformatting
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},									-- |df=yMd; not supported at en.wiki
		},
	['dMy'] = {																	-- date format is dMy; reformat to:
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- for long/short reformatting
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},									-- |df=yMd; not supported at en.wiki
		},
	['Md-dy'] = {																-- date format is Md-dy; reformat to:
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- for long/short reformatting
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- |df=dmy -&gt; d-dMy 
		},
	['d-dMy'] = {																-- date format is d-d&gt;y; reformat to:
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- for long/short reformatting
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- |df=mdy -&gt; Md-dy 
		},
	['dM-dMy'] = {																-- date format is dM-dMy; reformat to:
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- for long/short reformatting
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd', 'm2', 'd2', 'y'},				-- |df=mdy -&gt; Md-Mdy 
		},
	['Md-Mdy'] = {																-- date format is Md-Mdy; reformat to:
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd',  'm2', 'd2', 'y'},			-- for long/short reformatting
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- |df=dmy -&gt; dM-dMy 
		},
	['dMy-dMy'] = {																-- date format is dMy-dMy; reformat to:
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- for long/short reformatting
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- |df=mdy -&gt; Mdy-Mdy 
		},
	['Mdy-Mdy'] = {																-- date format is Mdy-Mdy; reformat to:
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- for long/short reformatting
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- |df=dmy -&gt; dMy-dMy 
		},
	['My-My'] = {																-- these for long/short reformatting
		['any'] = {'%s %s – %s %s', 'm', 'y', 'm2', 'y2'},						-- dmy/mdy agnostic
		},
	['M-My'] = {																-- these for long/short reformatting
		['any'] = {'%s–%s %s', 'm', 'm2', 'y'},									-- dmy/mdy agnostic
		},
	['My'] = {																	-- these for long/short reformatting
		['any'] = {'%s %s', 'm', 'y'},											-- dmy/mdy agnostic
		},
--	['yMd'] = {																	-- not supported at en.wiki
--		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
--		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
--		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
--		},
	}


local function reformatter (date, pattern_idx, format_param, mon_len)
	if not in_array (pattern_idx, {'ymd', 'Mdy', 'Md-dy', 'dMy', 'yMd', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- not in this set of date format patterns then not a reformattable date
	end
	
	if 'ymd' == format_param and in_array (pattern_idx, {'ymd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- ymd date ranges not supported at en.wiki; no point in reformatting ymd to ymd
	end

	if in_array (pattern_idx, {'My', 'M-My', 'My-My'}) then						-- these are not dmy/mdy so can't be 'reformatted' into either
		format_param = 'any';													-- so format-agnostic 
	end

	-- yMd is not supported at en.wiki
	-- if yMd is supported at your wiki, uncomment the next line
--	if 'yMd' == format_param and in_array (pattern_idx, {'yMd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy'}) then	-- these formats not convertable; yMd not supported at en.wiki
	-- if yMd is supported at your wiki, remove or comment-out the next line
	if 'yMd' == format_param then												-- yMd not supported at en.wiki
		return;																	-- not a reformattable date
	end
	
	local c1, c2, c3, c4, c5, c6, c7;											-- these hold the captures specified in patterns[pattern_idx][1]
	c1, c2, c3, c4, c5, c6, c7 = mw.ustring.match (date, patterns[pattern_idx][1]);	-- get the captures

	local t = {																	-- table that holds k/v pairs of date parts from the captures and patterns[pattern_idx][2..]
		[patterns[pattern_idx][2]] = c1;										-- at minimum there is always one capture with a matching indicator letter
		[patterns[pattern_idx][3] or 'x'] = c2;									-- patterns can have a variable number of captures; each capture requires an indicator letter;
		[patterns[pattern_idx][4] or 'x'] = c3;									-- where there is no capture, there is no indicator letter so n in patterns[pattern_idx][n] will be nil;
		[patterns[pattern_idx][5] or 'x'] = c4;									-- the 'x' here spoofs an indicator letter to prevent 'table index is nil' error
		[patterns[pattern_idx][6] or 'x'] = c5;
		[patterns[pattern_idx][7] or 'x'] = c6;
		[patterns[pattern_idx][8] or 'x'] = c7;
		};

	if t.a then																	-- if this date has an anchor year capture
		t.y = t.a;																-- use the anchor year capture when reassembling the date
	end

	if tonumber(t.m) then														-- if raw month is a number (converting from ymd)
		if 's' == mon_len then													-- if we are to use abbreviated month names
			t.m = cfg.date_names['inv_local_s'][tonumber(t.m)];					-- convert it to a month name
		else
			t.m = cfg.date_names['inv_local_l'][tonumber(t.m)];					-- convert it to a month name
		end
		t.d = t.d:gsub ('0(%d)', '%1');											-- strip leading '0' from day if present
	elseif 'ymd' == format_param then											-- when converting to ymd
		if 1582 &gt; tonumber(t.y) then											-- ymd format dates not allowed before 1582
			return;
		end
		t.m = string.format ('%02d', get_month_number (t.m));					-- make sure that month and day are two digits
		t.d = string.format ('%02d', t.d);
	elseif mon_len then															-- if mon_len is set to either 'short' or 'long'
		for _, mon in ipairs ({'m', 'm2'}) do									-- because there can be two month names, check both 
			if t[mon] then
				t[mon] = get_month_number (t[mon]);								-- get the month number for this month (is length agnostic)
				if 0 == t[mon] then return; end									-- seasons and named dates can't be converted
				t[mon] = (('s' == mon_len) and cfg.date_names['inv_local_s'][t[mon]]) or cfg.date_names['inv_local_l'][t[mon]];	-- fetch month name according to length
			end
		end
	end

	local new_date = string.format (re_formats[pattern_idx][format_param][1],	-- format string
		t[re_formats[pattern_idx][format_param][2]],							-- named captures from t{}
		t[re_formats[pattern_idx][format_param][3]],
		t[re_formats[pattern_idx][format_param][4]],
		t[re_formats[pattern_idx][format_param][5]],
		t[re_formats[pattern_idx][format_param][6]],
		t[re_formats[pattern_idx][format_param][7]],
		t[re_formats[pattern_idx][format_param][8]]
		);

	return new_date;
end


--[[-------------------------&lt; R E F O R M A T _ D A T E S &gt;--------------------------------------------------

Reformats existing dates into the format specified by format.

format is one of several manual keywords: dmy, dmy-all, mdy, mdy-all, ymd, ymd-all.  The -all version includes
access- and archive-dates; otherwise these dates are not reformatted.

This function allows automatic date formatting.  In ~/Configuration, the article source is searched for one of
the {{use xxx dates}} templates.  If found, xxx becomes the global date format as xxx-all.  If |cs1-dates= in
{{use xxx dates}} has legitimate value then that value determines how cs1|2 dates will be rendered.  Legitimate
values for |cs1-dates= are:
	l - all dates are rendered with long month names
	ls - publication dates use long month names; access-/archive-dates use abbreviated month names
	ly - publication dates use long month names; access-/archive-dates rendered in ymd format
	s - all dates are rendered with abbreviated (short) month names
	sy - publication dates use abbreviated month names; access-/archive-dates rendered in ymd format
	y - all dates are rendered in ymd format

the format argument for automatic date formatting will be the format specified by {{use xxx dates}} with the
value supplied by |cs1-dates so one of: xxx-l, xxx-ls, xxx-ly, xxx-s, xxx-sy, xxx-y, or simply xxx (|cs1-dates=
empty, omitted, or invalid) where xxx shall be either of dmy or mdy.

dates are extracted from date_parameters_list, reformatted (if appropriate), and then written back into the
list in the new format.  Dates in date_parameters_list are presumed here to be valid (no errors).  This function
returns true when a date has been reformatted, false else.  Actual reformatting is done by reformatter().

]]

local function reformat_dates (date_parameters_list, format)
	local all = false;															-- set to false to skip access- and archive-dates
	local len_p = 'l';															-- default publication date length shall be long
	local len_a = 'l';															-- default access-/archive-date length shall be long
	local result = false;
	local new_date;																
	
	if format:match('%a+%-all') then											-- manual df keyword; auto df keyword when length not specified in {{use xxx dates}}; 
		format = format:match('(%a+)%-all');									-- extract the format
		all = true;																-- all dates are long format dates because this keyword doesn't specify length
	elseif format:match('%a+%-[lsy][sy]?') then									-- auto df keywords; internal only
		all = true;																-- auto df applies to all dates; use length specified by capture len_p for all dates
		format, len_p, len_a = format:match('(%a+)%-([lsy])([sy]?)');			-- extract the format and length keywords
		if 'y' == len_p then													-- because allowed by MOS:DATEUNIFY (sort of) range dates and My dates not reformatted
			format = 'ymd';														-- override {{use xxx dates}}
		elseif (not is_set(len_a)) or (len_p == len_a) then						-- no access-/archive-date length specified or same length as publication dates then
			len_a = len_p;														-- in case len_a not set
		end
	end																			-- else only publication dates and they are long

	for param_name, param_val in pairs (date_parameters_list) do				-- for each date-holding parameter in the list
		if is_set (param_val.val) then											-- if the parameter has a value
			if not (not all and in_array (param_name, {'access-date', 'archive-date'})) then	-- skip access- or archive-date unless format is xxx-all; yeah, ugly; TODO: find a better way
				for pattern_idx, pattern in pairs (patterns) do
					if mw.ustring.match (param_val.val, pattern[1]) then
						if all and in_array (param_name, {'access-date', 'archive-date'}) then	-- if this date is an access- or archive-date
							new_date = reformatter (param_val.val, pattern_idx, (('y' == len_a) and 'ymd') or format, len_a);	-- choose ymd or dmy/mdy according to len_a setting
						else													-- all other dates
							new_date = reformatter (param_val.val, pattern_idx, format, len_p);
						end
						
						if new_date then										-- set when date was reformatted
							date_parameters_list[param_name].val = new_date;	-- update date in date list
							result = true;										-- and announce that changes have been made
						end
					end	-- if
				end		-- for
			end			-- if
		end				-- if
	end					-- for
return result;																	-- declare boolean result and done
end


--[[--------------------------&lt; D A T E _ H Y P H E N _ T O _ D A S H &gt;----------------------------------------

Loops through the list of date-holding parameters and converts any hyphen to an ndash.  Not called if the cs1|2
template has any date errors.

Modifies the date_parameters_list and returns true if hyphens are replaced, else returns false.

]]

local function date_hyphen_to_dash (date_parameters_list)
	local result = false;
	local n;
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set (param_val.val) then
			if not mw.ustring.match (param_val.val, '%d%d%d%d%-%d%d%-%d%d') then	-- for those that are not ymd dates (ustring because here digits may not be Western)
				param_val.val, n = param_val.val:gsub ('%-', '–');				-- replace any hyphen with ndash
				if 0 ~= n then
					date_parameters_list[param_name].val = param_val.val;		-- update the list
					result = true;
				end
			end
		end
	end
	return result;																-- so we know if any hyphens were replaced
end


--[[-------------------------&lt; D A T E _ N A M E _ X L A T E &gt;------------------------------------------------

Attempts to translate English month names to local-language month names using names supplied by MediaWiki's
date parser function.  This is simple name-for-name replacement and may not work for all languages.

if xlat_dig is true, this function will also translate Western (English) digits to the local language's digits.
This will also translate ymd dates.

]]

local function date_name_xlate (date_parameters_list, xlt_dig)
	local xlate;
	local mode;																	-- long or short month names
	local modified = false;
	local date;
	
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val.val) then											-- if the parameter has a value
			date = param_val.val;
			for month in mw.ustring.gmatch (date, '%a+') do						-- iterate through all dates in the date (single date or date range)
				if cfg.date_names.en.long[month] then
					mode = 'F';													-- English name is long so use long local name
				elseif cfg.date_names.en.short[month] then
					mode = 'M';													-- English name is short so use short local name
				else
					mode = nil;													-- not an English month name; could be local language month name or an English season name
				end
		
				if mode then													-- might be a season
					xlate = lang_object:formatDate(mode, '1' .. month);			-- translate the month name to this local language
					date = mw.ustring.gsub (date, month, xlate);				-- replace the English with the translation
					date_parameters_list[param_name].val = date;				-- save the translated date
					modified = true;
				end
			end

			if xlt_dig then														-- shall we also translate digits?
				date = date:gsub ('%d', cfg.date_names.xlate_digits);			-- translate digits from Western to 'local digits'
				date_parameters_list[param_name].val = date;					-- save the translated date
				modified = true;
			end
		end
	end
	
	return modified;
	end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	add_prop_cat = utilities_page_ptr.add_prop_cat ;							-- import functions from selected Module:Citation/CS1/Utilities module
	is_set = utilities_page_ptr.is_set;
	in_array = utilities_page_ptr.in_array;
--	set_message = utilities_page_ptr.set_message;
	wrap_style = utilities_page_ptr.wrap_style;

	cfg = cfg_table_ptr;														-- import tables from selected Module:Citation/CS1/Configuration
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {																		-- return exported functions
	dates = dates,
	year_date_check = year_date_check,
	reformat_dates = reformat_dates,
	date_hyphen_to_dash = date_hyphen_to_dash,
	date_name_xlate = date_name_xlate,
	set_selected_modules = set_selected_modules
	}</text>
      <sha1>ds0l4tghd9b1ze47i4ysqzmmocnzkhm</sha1>
    </revision>
    <revision>
      <id>4850</id>
      <parentid>4849</parentid>
      <timestamp>2021-04-10T13:14:49Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4850</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="63347" sha1="b6r7jye2hd1gicunlxd102sepp586yc" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local add_prop_cat, is_set, in_array, set_message, substitute, wrap_style;		-- imported functions from selected Module:Citation/CS1/Utilities
local cfg;																		-- table of tables imported from selected Module:Citation/CS1/Configuration


--[[--------------------------&lt; F I L E - S C O P E   D E C L A R A T I O N S &gt;--------------------------------

File-scope variables are declared here

]]

local lang_object = mw.getContentLanguage();									-- used by is_valid_accessdate(), is_valid_year(), date_name_xlate(); TODO: move to ~/Configuration?
local year_limit;																-- used by is_valid_year()


--[=[-------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |access-date= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-English date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate().  To get around that
call this function with YYYY-MM-DD format dates.

]=]

local function is_valid_accessdate (accessdate)
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold Unix time stamps representing the dates

	good1, access_ts = pcall (lang_object.formatDate, lang_object, 'U', accessdate );			-- convert accessdate value to Unix timestamp 
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which which tonumber() may not understand
		access_ts = tonumber (access_ts) or lang_object:parseFormattedNumber (access_ts);		-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to Unix time stamp
	end

	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end


--[[--------------------------&lt; I S _ V A L I D _ E M B A R G O _ D A T E &gt;------------------------------------

returns true and date value if that value has proper dmy, mdy, ymd format.

returns false and 9999 (embargoed forever) when date value is not proper format; assumes that when |pmc-embargo-date= is
set, the editor intended to embargo a PMC but |pmc-embargo-date= does not hold a single date.

]]

local function is_valid_embargo_date (v)
	if v:match ('^%d%d%d%d%-%d%d%-%d%d$') or									-- ymd
		v:match ('^%d%d?%s+%a+%s+%d%d%d%d$') or									-- dmy
		v:match ('^%a+%s+%d%d?%s*,%s*%d%d%d%d$') then							-- mdy
			return true, v;
	end
	return false, '9999';														-- if here not good date so return false and set embargo date to long time in future
end


--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct.
If not a valid month, returns 0

]]

local function get_month_number (month)
	return cfg.date_names['local'].long[month] or cfg.date_names['local'].short[month] or	-- look for local names first
			cfg.date_names['en'].long[month] or	cfg.date_names['en'].short[month] or		-- failing that, look for English names
			0;																				-- not a recognized month name
end


--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 21 for Spring, etc.  Capitalization and spelling
must be correct. If not a valid season, returns 0.
	21-24 = Spring, Summer, Autumn, Winter, independent of “Hemisphere”

returns 0 when &lt;param&gt; is not |date=

Season numbering is defined by Extended Date/Time Format (EDTF) specification (https://www.loc.gov/standards/datetime/)
which became part of ISO 8601 in 2019.  See '§Sub-year groupings'.  The standard defines various divisions using
numbers 21-41.  cs1|2 only supports generic seasons.  EDTF does support the distinction between north and south
hemisphere seasons but cs1|2 has no way to make that distinction.

These additional divisions not currently supported:
	25-28 = Spring - Northern Hemisphere, Summer- Northern Hemisphere, Autumn - Northern Hemisphere, Winter - Northern Hemisphere
	29-32 = Spring – Southern Hemisphere, Summer– Southern Hemisphere, Autumn – Southern Hemisphere, Winter - Southern Hemisphere
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)

]]

local function get_season_number (season, param)
	if 'date' ~= param then
		return 0;																-- season dates only supported by |date=
	end
	return cfg.date_names['local'].season[season] or							-- look for local names first
			cfg.date_names['en'].season[season] or								-- failing that, look for English names
			0;																	-- not a recognized season name
end


--[[--------------------------&lt; G E T _ Q U A R T E R _ N U M B E R &gt;------------------------------------------

returns a number according to the sequence of quarters in a year: 33 for first quarter, etc.  Capitalization and spelling
must be correct. If not a valid quarter, returns 0.
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)

returns 0 when &lt;param&gt; is not |date=

Quarter numbering is defined by Extended Date/Time Format (EDTF) specification (https://www.loc.gov/standards/datetime/)
which became part of ISO 8601 in 2019.  See '§Sub-year groupings'.  The standard defines various divisions using
numbers 21-41.  cs1|2 only supports generic seasons and quarters.

These additional divisions not currently supported:
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)

]]

local function get_quarter_number (quarter, param)
	if 'date' ~= param then
		return 0;																-- quarter dates only supported by |date=
	end
	quarter = mw.ustring.gsub (quarter, ' +', ' ');								-- special case replace multiple space chars with a single space char
	return cfg.date_names['local'].quarter[quarter] or							-- look for local names first
			cfg.date_names['en'].quarter[quarter] or							-- failing that, look for English names
			0;																	-- not a recognized quarter name
end


--[[--------------------------&lt; G E T _ P R O P E R _ N A M E _ N U M B E R &gt;----------------------------------

returns a non-zero number if date contains a recognized proper-name.  Capitalization and spelling must be correct.

returns 0 when &lt;param&gt; is not |date=

]]

local function get_proper_name_number (name, param)
	if 'date' ~= param then
		return 0;																-- proper-name dates only supported by |date=
	end
	return cfg.date_names['local'].named[name] or								-- look for local names dates first
			cfg.date_names['en'].named[name] or									-- failing that, look for English names
			0;																	-- not a recognized named date
end


--[[--------------------------&lt; G E T _ E L E M E N T _ N U M B E R &lt;------------------------------------------

returns true if month or season or quarter or proper name is valid (properly spelled, capitalized, abbreviated)

]]

local function get_element_number (element, param)
	local num;
	
	local funcs = {get_month_number, get_season_number, get_quarter_number, get_proper_name_number};	-- list of functions to execute in order
	
	for _, func in ipairs (funcs) do											-- spin through the function list
		num = func (element, param);											-- call the function and get the returned number
		if 0 ~= num then														-- non-zero when valid month season quarter 
			return num;															-- return that number
		end
	end
	return nil;																	-- not valid
end


--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one
year in the future are not acceptable.

]]

local function is_valid_year (year)
	if not is_set(year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;									-- global variable so we only have to fetch it once
	end

	year = tonumber (year) or lang_object:parseFormattedNumber (year);			-- convert to numbers for the comparison;
	return year and (year &lt;= year_limit) or false;
end


--[[--------------------------&lt; I S _ V A L I D _ D A T E &gt;----------------------------------------------------

Returns true if day is less than or equal to the number of days in month and year is no farther into the future
than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap
years before 1582 and Gregorian leap years after 1582. Where the two calendars overlap (1582 to approximately
1923) dates are assumed to be Gregorian.

]]

local function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year(year) then												-- no farther into the future than next year
		return false;
	end
	
	month = tonumber(month);													-- required for YYYY-MM-DD dates
	
	if (2 == month) then														-- if February
		month_length = 28;														-- then 28 days unless
		if 1582 &gt; tonumber(year) then											-- Julian calendar
			if 0 == (year%4) then												-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		else																	-- Gregorian calendar
			if (0 == (year%4) and (0 ~= (year%100) or 0 == (year%400))) then	-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		end
	else
		month_length = days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
There is a special test for May because it can be either short or long form.

Returns true when style for both months is the same

]]

local function is_valid_month_range_style (month1, month2)
local len1 = month1:len();
local len2 = month2:len();
	if len1 == len2 then
		return true;															-- both months are short form so return true
	elseif 'May' == month1 or 'May'== month2 then -- ToDo: I18N
		return true;															-- both months are long form so return true
	elseif 3 == len1 or 3 == len2 then
		return false;															-- months are mixed form so return false
	else
		return true;															-- both months are long form so return true
	end
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

All season ranges are accepted as valid because there are publishers out there who have published a Summer–Spring YYYY issue, hence treat as ok

]]

local function is_valid_month_season_range(range_start, range_end, param)
	local range_start_number = get_month_number (range_start);
	local range_end_number;

	if 0 == range_start_number then												-- is this a month range?
		range_start_number = get_season_number (range_start, param);			-- not a month; is it a season? get start season number
		range_end_number = get_season_number (range_end, param);				-- get end season number

		if (0 ~= range_start_number) and (0 ~= range_end_number) and (range_start_number ~= range_end_number) then
			return true;														-- any season pairing is accepted except when both are the same
		end
		return false;															-- range_start and/or range_end is not a season
	end
																				-- here when range_start is a month
	range_end_number = get_month_number (range_end);							-- get end month number
	if range_start_number &lt; range_end_number and								-- range_start is a month; does range_start precede range_end?
		is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
	end
	return false;																-- range_start month number is greater than or equal to range end number; or range end isn't a month
end


--[[--------------------------&lt; M A K E _ C O I N S _ D A T E &gt;------------------------------------------------

This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1.  The function is called only for |date= parameters and only if the |date=&lt;value&gt; is 
determined to be a valid date format.  The question of what to do with invalid date formats is not answered here.

The date parts in the input table are converted to an ISO 8601 conforming date string:
	single whole dates:		yyyy-mm-dd
	month and year dates:	yyyy-mm
	year dates:				yyyy
	ranges:					yyyy-mm-dd/yyyy-mm-dd
							yyyy-mm/yyyy-mm
							yyyy/yyyy

Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.

The input table has:
	year, year2 – always present; if before 1582, ignore months and days if present
	month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 99 Christmas
	day, day2 –  0 if not provided, 1-31 for days
	
the output table receives:
	rftdate:	an ISO 8601 formatted date
	rftchron:	a free-form version of the date, usually without year which is in rftdate (season ranges and proper-name dates)
	rftssn:		one of four season keywords: winter, spring, summer, fall (lowercase)
	rftquarter:	one of four values: 1, 2, 3, 4

]]

local function make_COinS_date (input, tCOinS_date)
	local date;																	-- one date or first date in a range
	local date2 = '';															-- end of range date
-- start temporary Julian / Gregorian calendar uncertainty detection
	local year = tonumber(input.year);											-- this temporary code to determine the extent of sources dated to the Julian/Gregorian
	local month = tonumber(input.month);										-- interstice 1 October 1582 – 1 January 1926
	local day = tonumber (input.day);
	if (0 ~= day) and															-- day must have a value for this to be a whole date
		(((1582 == year) and (10 &lt;= month) and (12 &gt;= month)) or				-- any whole 1582 date from 1 October to 31 December or
			((1926 == year) and (1 == month) and (1 == input.day)) or			-- 1 January 1926 or
				((1582 &lt; year) and (1925 &gt;= year))) then						-- any date 1 January 1583 – 31 December 1925
					tCOinS_date.inter_cal_cat = true;							-- set category flag true
	end
-- end temporary Julian / Gregorian calendar uncertainty detection
	
	if 1582 &gt; tonumber(input.year) or 20 &lt; tonumber(input.month) then			-- Julian calendar or season so &amp;rft.date gets year only
		date = input.year;
		if 0 ~= input.year2 and input.year ~= input.year2 then					-- if a range, only the second year portion when not the same as range start year
			date = string.format ('%.4d/%.4d', tonumber(input.year), tonumber(input.year2))		-- assemble the date range
		end
		if 20 &lt; tonumber(input.month) then										-- if season or proper-name date
			local season = {[24] = 'winter', [21] = 'spring', [22] = 'summer', [23] = 'fall', [33] = '1', [34] = '2', [35] = '3', [36] = '4', [98] = 'Easter', [99] = 'Christmas'};	-- seasons lowercase, no autumn; proper-names use title case
			if 0 == input.month2 then											-- single season date
				if 40 &lt; tonumber(input.month) then
					tCOinS_date.rftchron = season[input.month];					-- proper-name dates
				elseif 30 &lt; tonumber(input.month) then
					tCOinS_date.rftquarter = season[input.month];				-- quarters
				else
					tCOinS_date.rftssn = season[input.month];					-- seasons
				end
			else																-- season range with a second season specified
				if input.year ~= input.year2 then								-- season year – season year range or season year–year
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					if 0~= input.month2 then
						tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);
					end
				else															-- season–season year range
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2];	-- season–season year range
				end
			end
		end
		tCOinS_date.rftdate = date;
		return;																	-- done
	end
	
	if 0 ~= input.day then
		date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day));	-- whole date
	elseif 0 ~= input.month then
		date = string.format ('%s-%.2d', input.year, tonumber(input.month));	-- year and month
	else
		date = string.format ('%s', input.year);								-- just year
	end

	if 0 ~= input.year2 then
		if 0 ~= input.day2 then
			date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2));		-- whole date
		elseif 0 ~= input.month2 then
			date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2));	-- year and month
		else
			date2 = string.format ('/%s', input.year2);							-- just year
		end
	end
	
	tCOinS_date.rftdate = date .. date2;										-- date2 has the '/' separator
	return;
end


--[[--------------------------&lt; P A T T E R N S &gt;--------------------------------------------------------------

this is the list of patterns for date formats that this module recognizes.  Approximately the first half of these
patterns represent formats that might be reformatted into another format.  Those that might be reformatted have
'indicator' letters that identify the content of the matching capture: 'd' (day), 'm' (month), 'a' (anchor year),
'y' (year); second day, month, year have a '2' suffix.

These patterns are used for both date validation and for reformatting.  This table should not be moved to ~/Configuration
because changes to this table require changes to check_date() and to reformatter() and reformat_date()

]]

local patterns = {
	 																			-- year-initial numerical year-month-day
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'},					
																				-- month-initial: month day, year
	['Mdy'] = {'^(%D-) +([1-9]%d?), +((%d%d%d%d?)%a?)$', 'm', 'd', 'a', 'y'},
																				-- month-initial day range: month day–day, year; days are separated by endash
	['Md-dy'] = {'^(%D-) +([1-9]%d?)[%-–]([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'd2', 'a', 'y'},
																				-- day-initial: day month year
	['dMy'] = {'^([1-9]%d?) +(%D-) +((%d%d%d%d?)%a?)$', 'd', 'm', 'a', 'y'},
																				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed; not supported at en.wiki
	--	['yMd'] = {'^((%d%d%d%d?)%a?) +(%D-) +(%d%d?)$', 'a', 'y', 'm', 'd'},
																				-- day-range-initial: day–day month year; days are separated by endash
	['d-dMy'] = {'^([1-9]%d?)[%-–]([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'd2', 'm', 'a', 'y'},
																				-- day initial month-day-range: day month - day month year; uses spaced endash
	['dM-dMy'] = {'^([1-9]%d?) +(%D-) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'd2', 'm2', 'a', 'y'},
																				-- month initial month-day-range: month day – month day, year;  uses spaced endash
	['Md-Mdy'] = {'^(%D-) +([1-9]%d?) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$','m', 'd', 'm2', 'd2', 'a', 'y'},
																				-- day initial month-day-year-range: day month year - day month year; uses spaced endash
	['dMy-dMy'] = {'^([1-9]%d?) +(%D-) +(%d%d%d%d) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'y', 'd2', 'm2', 'a', 'y2'},
																				-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
	['Mdy-Mdy'] = {'^(%D-) +([1-9]%d?), +(%d%d%d%d) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'y', 'm2', 'd2', 'a', 'y2'},

																				-- these date formats cannot be converted, per se, but month name can be rendered short or long
																				-- month/season year - month/season year; separated by spaced endash
	['My-My'] = {'^(%D-) +(%d%d%d%d) +[%-–] +(%D-) +((%d%d%d%d)%a?)$', 'm', 'y', 'm2', 'a', 'y2'},
																				-- month/season range year; months separated by endash
	['M-My'] = {'^(%D-)[%-–](%D-) +((%d%d%d%d)%a?)$', 'm', 'm2', 'a', 'y'},
																				-- month/season year or proper-name year; quarter year when First Quarter YYYY etc.
	['My'] = {'^([^%d–]-) +((%d%d%d%d)%a?)$', 'm', 'a', 'y'},					-- this way because endash is a member of %D; %D- will match January–March 2019 when it shouldn't

																				-- these date formats cannot be converted
	['Sy4-y2'] = {'^(%D-) +((%d%d)%d%d)[%-–]((%d%d)%a?)$'},						-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
	['Sy-y'] = {'^(%D-) +(%d%d%d%d)[%-–]((%d%d%d%d)%a?)$'},						-- special case Winter/Summer year-year; year separated with unspaced endash
	['y-y'] = {'^(%d%d%d%d?)[%-–]((%d%d%d%d?)%a?)$'},							-- year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
	['y4-y2'] = {'^((%d%d)%d%d)[%-–]((%d%d)%a?)$'},								-- year range: YYYY–YY; separated by unspaced endash
	['ymx'] = {'^(%d%d%d%d)%-(%d%d)%-XX$', 'y', 'm'},							-- edtf year-initial numerical year-month-XX
	['y'] = {'^((%d%d%d%d?)%a?)$'},												-- year; here accept either YYY or YYYY
	}


--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only
allowed range separator is endash.  Additionally, check the date to see that it is a real date: no 31 in 30-day
months; no 29 February when not a leap year.  Months, both long-form and three character abbreviations, and seasons
must be spelled correctly.  Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and
COinS_date.  When this happens, the date parameter is (DEBUG: not?) used in the COinS metadata and the CITEREF identifier gets
its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, publication-date, access-date, pmc-embargo-date, archive-date, lay-date)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is ISO 8601 format date; see make_COInS_date()

]]

local function check_date (date_string, param, tCOinS_date)
	local year;																	-- assume that year2, months, and days are not used;
	local year2 = 0;															-- second year in a year range
	local month = 0;
	local month2 = 0;															-- second month in a month range
	local day = 0;
	local day2 = 0;																-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match (patterns['ymd'][1]) then								-- year-initial numerical year month day format
		year, month, day = date_string:match (patterns['ymd'][1]);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or 0 == tonumber(day) then return false; end	-- month or day number not valid or not Gregorian calendar
		anchor_year = year;
	
	elseif date_string:match (patterns['ymx'][1]) then							-- year-initial numerical year month edtf format
		year, month = date_string:match (patterns['ymx'][1]);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or not is_valid_year(year) then return false; end	-- month number not valid or not Gregorian calendar or future year
		anchor_year = year;

	elseif mw.ustring.match(date_string, patterns['Mdy'][1]) then				-- month-initial: month day, year
		month, day, anchor_year, year = mw.ustring.match(date_string, patterns['Mdy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
				
	elseif mw.ustring.match(date_string, patterns['Md-dy'][1]) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year = mw.ustring.match(date_string, patterns['Md-dy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2=month;															-- for metadata
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['dMy'][1]) then				-- day-initial: day month year
		day, month, anchor_year, year = mw.ustring.match(date_string, patterns['dMy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months

--[[ NOT supported at en.wiki
	elseif mw.ustring.match(date_string, patterns['yMd'][1]) then				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed
		anchor_year, year, month, day = mw.ustring.match(date_string, patterns['yMd'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
-- end NOT supported at en.wiki ]]

	elseif mw.ustring.match(date_string, patterns['d-dMy'][1]) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year = mw.ustring.match(date_string, patterns['d-dMy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2 = month;															-- for metadata
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['dM-dMy'][1]) then			-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year = mw.ustring.match(date_string, patterns['dM-dMy'][1]);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['Md-Mdy'][1]) then			-- month initial month-day-range: month day – month day, year; uses spaced endash
		month, day, month2, day2, anchor_year, year = mw.ustring.match(date_string, patterns['Md-Mdy'][1]);
		if (not is_valid_month_season_range(month, month2, param)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['dMy-dMy'][1]) then			-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2 = mw.ustring.match(date_string, patterns['dMy-dMy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		if 0 == month or 0 == month2 then return false; end						-- both must be valid

	elseif mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]) then			-- month initial month-day-year-range: month day, year – month day, year; uses spaced endash
		month, day, year, month2, day2, anchor_year, year2 = mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number(month2);
		if 0 == month or 0 == month2 then return false; end						-- both must be valid

	elseif mw.ustring.match(date_string, patterns['Sy4-y2'][1]) then			-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		local century;
		month, year, century, anchor_year, year2 = mw.ustring.match(date_string, patterns['Sy4-y2'][1]);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;		-- 'month' can only be Winter or Summer
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor_year from both years
		year2 = century..year2;													-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		month = get_season_number(month, param);

	elseif mw.ustring.match(date_string, patterns['Sy-y'][1]) then				-- special case Winter/Summer year-year; year separated with unspaced endash
		month, year, anchor_year, year2 = mw.ustring.match(date_string, patterns['Sy-y'][1]);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;		-- 'month' can only be Winter or Summer
		anchor_year = year .. '–' .. anchor_year;										-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		month = get_season_number (month, param);								-- for metadata

	elseif mw.ustring.match(date_string, patterns['My-My'][1]) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2 = mw.ustring.match(date_string, patterns['My-My'][1]);
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then 	-- both must be month year, same month style
			month = get_month_number(month);
			month2 = get_month_number(month2);
		elseif 0 ~= get_season_number(month, param) and 0 ~= get_season_number(month2, param) then	-- both must be season year, not mixed
			month = get_season_number(month, param);
			month2 = get_season_number(month2, param);
		else
			 return false;
		end

	elseif mw.ustring.match(date_string, patterns['M-My'][1]) then				-- month/season range year; months separated by endash 
		month, month2, anchor_year, year = mw.ustring.match(date_string, patterns['M-My'][1]);
		if (not is_valid_month_season_range(month, month2, param)) or (not is_valid_year(year)) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
			month2 = get_month_number(month2);
			if 0 == month or 0 == month2 then return false; end
		else
			month = get_season_number(month, param);
			month2 = get_season_number(month2, param);
		end
		year2 = year;
		
	elseif mw.ustring.match(date_string, patterns['My'][1]) then				-- month/season/quarter/proper-name year
		month, anchor_year, year = mw.ustring.match(date_string, patterns['My'][1]);
		if not is_valid_year(year) then return false; end
		month = get_element_number(month, param);								-- get month season quarter proper-name number or nil
		if not month then return false; end										-- not valid whatever it is

	elseif mw.ustring.match(date_string, patterns['y-y'][1]) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2 = mw.ustring.match(date_string, patterns['y-y'][1]);
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, patterns['y4-y2'][1]) then				-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2 = mw.ustring.match(date_string, patterns['y4-y2'][1]);
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor year from both years

		if in_array (param, {'date', 'publication-date', 'year'}) then
			add_prop_cat ('year_range_abbreviated');
		end

		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century .. year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, patterns['y'][1]) then					-- year; here accept either YYY or YYYY
		anchor_year, year = mw.ustring.match(date_string, patterns['y'][1]);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;															-- date format not one of the MOS:DATE approved formats
	end

	if 'access-date' == param then												-- test accessdate here because we have numerical date parts
		if 0 ~= year and 0 ~= month and 0 ~= day and 							-- all parts of a single date required
			0 == year2 and 0 == month2 and 0 == day2 then						-- none of these; accessdate must not be a range
				if not is_valid_accessdate(year .. '-' .. month .. '-' .. day) then	
					return false;												-- return false when accessdate out of bounds
				end
		else
			return false;														-- return false when accessdate is a range of two dates
		end
	end

	local result=true;															-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result = is_valid_date(year, month, day);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result = is_valid_date(year, month, day);
		result = result and is_valid_date(year, month, day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result = is_valid_date(year, month, day);
		result = result and is_valid_date(year, month2, day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result = is_valid_date(year, month, day);
		result = result and is_valid_date(year2, month2, day2);
	end
	
	if false == result then return false; end

	if nil ~= tCOinS_date then													-- this table only passed into this function when testing |date= parameter values
		make_COinS_date ({year = year, month = month, day = day, year2 = year2, month2 = month2, day2 = day2}, tCOinS_date);	-- make an ISO 8601 date string for COinS
	end
	
	return true, anchor_year;													-- format is good and date string represents a real date
end	


--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
parameters with errors are added to the &lt;error_list&gt; sequence table as the dates are tested.

]]

local function dates(date_parameters_list, tCOinS_date, error_list)
	local anchor_year;															-- will return as nil if the date being tested is not |date=
	local COinS_date;															-- will return as nil if the date being tested is not |date=
	local embargo_date;															-- if embargo date is a good dmy, mdy, ymd date then holds original value else reset to 9999
	local good_date = false;

	for k, v in pairs(date_parameters_list) do									-- for each date-holding parameter in the list
		if is_set(v.val) then													-- if the parameter has a value
			v.val = mw.ustring.gsub(v.val, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9
			if v.val:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then						-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v.val:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);				-- get the year portion so it can be tested
				if 'date' == k then
					anchor_year, COinS_date = v.val:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year' == k then
					good_date = is_valid_year(year);
				end
			elseif 'date' == k then												-- if the parameter is |date=
				if v.val:match(&quot;^n%.d%.%a?$&quot;) then -- ToDo: I18N								-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((n%.d%.)%a?)&quot;); -- ToDo: I18N	-- &quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v.val:match(&quot;^nd%a?$&quot;) then -- ToDo: I18N								-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((nd)%a?)&quot;); -- ToDo: I18N	-- &quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v.val, k, tCOinS_date);	-- go test the date
				end
			elseif 'year' == k then												-- if the parameter is |year= it should hold only a year value
				if v.val:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then						-- if |year = 3 or 4 digits only with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((%d+)%a?)&quot;);
				end
			elseif 'pmc-embargo-date' == k then											-- if the parameter is |pmc-embargo-date=
				good_date = check_date (v.val, k);								-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date, embargo_date = is_valid_embargo_date (v.val);	-- is |pmc-embargo-date= date a single dmy, mdy, or ymd formatted date? yes: returns embargo; no: returns 9999
				end
			else																-- any other date-holding parameter
				good_date = check_date (v.val, k);								-- go test the date
			end
			if false == good_date then											-- assemble one error message so we don't add the tracking category multiple times
				table.insert (error_list, wrap_style ('parameter', v.name));	-- make parameter name suitable for error message list
			end
		end
	end
	return anchor_year, embargo_date;											-- and done
end


--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function sets a local numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

the numernic value in &lt;result&gt; determines the 'output' if any from this function:
	0 – adds error message to error_list sequence table
	1 – adds maint cat
	2 – does nothing

]]

local function year_date_check (year_string, year_origin, date_string, date_origin, error_list)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes

	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where both date and year are required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard range formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif mw.ustring.match(date_string, &quot;%d%d%d%d[%-–]%d%d&quot;) then				-- YYYY-YY date ranges
		local century;
		date1, century, date2 = mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	else																		-- should never get here; this function called only when no other date errors
		result = 0;																-- no recognizable year in date
	end

	if 0 == result then															-- year / date mismatch
		table.insert (error_list, substitute (cfg.messages['mismatch'], {year_origin, date_origin}));	-- add error message to error_list sequence table
	elseif 1 == result then														-- redundant year / date
		set_message ('maint_date_year');										-- add a maint cat
	end
end


--[[--------------------------&lt; R E F O R M A T T E R &gt;--------------------------------------------------------

reformat 'date' into new format specified by format_param if pattern_idx (the current format of 'date') can be
reformatted.  Does the grunt work for reformat_dates().

The table re_formats maps pattern_idx (current format) and format_param (desired format) to a table that holds:
	format string used by string.format()
	identifier letters ('d', 'm', 'y', 'd2', 'm2', 'y2') that serve as indexes into a table t{} that holds captures
		from mw.ustring.match() for the various date parts specified by  patterns[pattern_idx][1]

Items in patterns{} have the general form:
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'}, where:
		['ymd'] is pattern_idx
		patterns['ymd'][1] is the match pattern with captures for mw.ustring.match()
		patterns['ymd'][2] is an indicator letter identifying the content of the first capture
		patterns['ymd'][3] ... the second capture etc.

when a pattern matches a date, the captures are loaded into table t{} in capture order using the idemtifier
characters as indexes into t{}  For the above, a ymd date is in t{} as:
	t.y = first capture (year), t.m = second capture (month), t.d = third capture (day)

To reformat, this function is called with the pattern_idx that matches the current format of the date and with
format_param set to the desired format.  This function loads table t{} as described and then calls string.format()
with the format string specified by re_format[pattern_idx][format_param][1] using values taken from t{} according
to the capture identifier letters specified by patterns[pattern_idx][format_param][n] where n is 2..

]]

local re_formats = {
	['ymd'] = {																	-- date format is ymd; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
	--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},								-- |df=yMd; not supported at en.wiki
		},
	['Mdy'] = {																	-- date format is Mdy; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- for long/short reformatting
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
	--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},								-- |df=yMd; not supported at en.wiki
		},
	['dMy'] = {																	-- date format is dMy; reformat to:
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- for long/short reformatting
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
	--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},								-- |df=yMd; not supported at en.wiki
		},
	['Md-dy'] = {																-- date format is Md-dy; reformat to:
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- for long/short reformatting
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- |df=dmy -&gt; d-dMy 
		},
	['d-dMy'] = {																-- date format is d-d&gt;y; reformat to:
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- for long/short reformatting
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- |df=mdy -&gt; Md-dy 
		},
	['dM-dMy'] = {																-- date format is dM-dMy; reformat to:
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- for long/short reformatting
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd', 'm2', 'd2', 'y'},				-- |df=mdy -&gt; Md-Mdy 
		},
	['Md-Mdy'] = {																-- date format is Md-Mdy; reformat to:
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd',  'm2', 'd2', 'y'},			-- for long/short reformatting
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- |df=dmy -&gt; dM-dMy 
		},
	['dMy-dMy'] = {																-- date format is dMy-dMy; reformat to:
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- for long/short reformatting
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- |df=mdy -&gt; Mdy-Mdy 
		},
	['Mdy-Mdy'] = {																-- date format is Mdy-Mdy; reformat to:
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- for long/short reformatting
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- |df=dmy -&gt; dMy-dMy 
		},
	['My-My'] = {																-- these for long/short reformatting
		['any'] = {'%s %s – %s %s', 'm', 'y', 'm2', 'y2'},						-- dmy/mdy agnostic
		},
	['M-My'] = {																-- these for long/short reformatting
		['any'] = {'%s–%s %s', 'm', 'm2', 'y'},									-- dmy/mdy agnostic
		},
	['My'] = {																	-- these for long/short reformatting
		['any'] = {'%s %s', 'm', 'y'},											-- dmy/mdy agnostic
		},
	--	['yMd'] = {																-- not supported at en.wiki
	--		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},								-- |df=mdy
	--		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},								-- |df=dmy
	--		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},								-- |df=ymd
	--		},
	}


local function reformatter (date, pattern_idx, format_param, mon_len)
	if not in_array (pattern_idx, {'ymd', 'Mdy', 'Md-dy', 'dMy', 'yMd', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- not in this set of date format patterns then not a reformattable date
	end
	
	if 'ymd' == format_param and in_array (pattern_idx, {'ymd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- ymd date ranges not supported at en.wiki; no point in reformatting ymd to ymd
	end

	if in_array (pattern_idx, {'My', 'M-My', 'My-My'}) then						-- these are not dmy/mdy so can't be 'reformatted' into either
		format_param = 'any';													-- so format-agnostic 
	end

																				-- yMd is not supported at en.wiki; if yMd is supported at your wiki, uncomment the next line
	--	if 'yMd' == format_param and in_array (pattern_idx, {'yMd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy'}) then	-- these formats not convertable; yMd not supported at en.wiki
	-- if yMd is supported at your wiki, remove or comment-out the next line
	if 'yMd' == format_param then												-- yMd not supported at en.wiki
		return;																	-- not a reformattable date
	end
	
	local c1, c2, c3, c4, c5, c6, c7;											-- these hold the captures specified in patterns[pattern_idx][1]
	c1, c2, c3, c4, c5, c6, c7 = mw.ustring.match (date, patterns[pattern_idx][1]);	-- get the captures

	local t = {																	-- table that holds k/v pairs of date parts from the captures and patterns[pattern_idx][2..]
		[patterns[pattern_idx][2]] = c1;										-- at minimum there is always one capture with a matching indicator letter
		[patterns[pattern_idx][3] or 'x'] = c2;									-- patterns can have a variable number of captures; each capture requires an indicator letter;
		[patterns[pattern_idx][4] or 'x'] = c3;									-- where there is no capture, there is no indicator letter so n in patterns[pattern_idx][n] will be nil;
		[patterns[pattern_idx][5] or 'x'] = c4;									-- the 'x' here spoofs an indicator letter to prevent 'table index is nil' error
		[patterns[pattern_idx][6] or 'x'] = c5;
		[patterns[pattern_idx][7] or 'x'] = c6;
		[patterns[pattern_idx][8] or 'x'] = c7;
		};

	if t.a then																	-- if this date has an anchor year capture
		t.y = t.a;																-- use the anchor year capture when reassembling the date
	end

	if tonumber(t.m) then														-- if raw month is a number (converting from ymd)
		if 's' == mon_len then													-- if we are to use abbreviated month names
			t.m = cfg.date_names['inv_local_s'][tonumber(t.m)];					-- convert it to a month name
		else
			t.m = cfg.date_names['inv_local_l'][tonumber(t.m)];					-- convert it to a month name
		end
		t.d = t.d:gsub ('0(%d)', '%1');											-- strip leading '0' from day if present
	elseif 'ymd' == format_param then											-- when converting to ymd
		if 1582 &gt; tonumber(t.y) then											-- ymd format dates not allowed before 1582
			return;
		end
		t.m = string.format ('%02d', get_month_number (t.m));					-- make sure that month and day are two digits
		t.d = string.format ('%02d', t.d);
	elseif mon_len then															-- if mon_len is set to either 'short' or 'long'
		for _, mon in ipairs ({'m', 'm2'}) do									-- because there can be two month names, check both 
			if t[mon] then
				t[mon] = get_month_number (t[mon]);								-- get the month number for this month (is length agnostic)
				if 0 == t[mon] then return; end									-- seasons and named dates can't be converted
				t[mon] = (('s' == mon_len) and cfg.date_names['inv_local_s'][t[mon]]) or cfg.date_names['inv_local_l'][t[mon]];	-- fetch month name according to length
			end
		end
	end

	local new_date = string.format (re_formats[pattern_idx][format_param][1],	-- format string
		t[re_formats[pattern_idx][format_param][2]],							-- named captures from t{}
		t[re_formats[pattern_idx][format_param][3]],
		t[re_formats[pattern_idx][format_param][4]],
		t[re_formats[pattern_idx][format_param][5]],
		t[re_formats[pattern_idx][format_param][6]],
		t[re_formats[pattern_idx][format_param][7]],
		t[re_formats[pattern_idx][format_param][8]]
		);

	return new_date;
end


--[[-------------------------&lt; R E F O R M A T _ D A T E S &gt;--------------------------------------------------

Reformats existing dates into the format specified by format.

format is one of several manual keywords: dmy, dmy-all, mdy, mdy-all, ymd, ymd-all.  The -all version includes
access- and archive-dates; otherwise these dates are not reformatted.

This function allows automatic date formatting.  In ~/Configuration, the article source is searched for one of
the {{use xxx dates}} templates.  If found, xxx becomes the global date format as xxx-all.  If |cs1-dates= in
{{use xxx dates}} has legitimate value then that value determines how cs1|2 dates will be rendered.  Legitimate
values for |cs1-dates= are:
	l - all dates are rendered with long month names
	ls - publication dates use long month names; access-/archive-dates use abbreviated month names
	ly - publication dates use long month names; access-/archive-dates rendered in ymd format
	s - all dates are rendered with abbreviated (short) month names
	sy - publication dates use abbreviated month names; access-/archive-dates rendered in ymd format
	y - all dates are rendered in ymd format

the format argument for automatic date formatting will be the format specified by {{use xxx dates}} with the
value supplied by |cs1-dates so one of: xxx-l, xxx-ls, xxx-ly, xxx-s, xxx-sy, xxx-y, or simply xxx (|cs1-dates=
empty, omitted, or invalid) where xxx shall be either of dmy or mdy.

dates are extracted from date_parameters_list, reformatted (if appropriate), and then written back into the
list in the new format.  Dates in date_parameters_list are presumed here to be valid (no errors).  This function
returns true when a date has been reformatted, false else.  Actual reformatting is done by reformatter().

]]

local function reformat_dates (date_parameters_list, format)
	local all = false;															-- set to false to skip access- and archive-dates
	local len_p = 'l';															-- default publication date length shall be long
	local len_a = 'l';															-- default access-/archive-date length shall be long
	local result = false;
	local new_date;																
	
	if format:match('%a+%-all') then											-- manual df keyword; auto df keyword when length not specified in {{use xxx dates}}; 
		format = format:match('(%a+)%-all');									-- extract the format
		all = true;																-- all dates are long format dates because this keyword doesn't specify length
	elseif format:match('%a+%-[lsy][sy]?') then									-- auto df keywords; internal only
		all = true;																-- auto df applies to all dates; use length specified by capture len_p for all dates
		format, len_p, len_a = format:match('(%a+)%-([lsy])([sy]?)');			-- extract the format and length keywords
		if 'y' == len_p then													-- because allowed by MOS:DATEUNIFY (sort of) range dates and My dates not reformatted
			format = 'ymd';														-- override {{use xxx dates}}
		elseif (not is_set(len_a)) or (len_p == len_a) then						-- no access-/archive-date length specified or same length as publication dates then
			len_a = len_p;														-- in case len_a not set
		end
	end																			-- else only publication dates and they are long

	for param_name, param_val in pairs (date_parameters_list) do				-- for each date-holding parameter in the list
		if is_set (param_val.val) then											-- if the parameter has a value
			if not (not all and in_array (param_name, {'access-date', 'archive-date'})) then	-- skip access- or archive-date unless format is xxx-all; yeah, ugly; TODO: find a better way
				for pattern_idx, pattern in pairs (patterns) do
					if mw.ustring.match (param_val.val, pattern[1]) then
						if all and in_array (param_name, {'access-date', 'archive-date'}) then	-- if this date is an access- or archive-date
							new_date = reformatter (param_val.val, pattern_idx, (('y' == len_a) and 'ymd') or format, len_a);	-- choose ymd or dmy/mdy according to len_a setting
						else													-- all other dates
							new_date = reformatter (param_val.val, pattern_idx, format, len_p);
						end
						
						if new_date then										-- set when date was reformatted
							date_parameters_list[param_name].val = new_date;	-- update date in date list
							result = true;										-- and announce that changes have been made
						end
					end	-- if
				end		-- for
			end			-- if
		end				-- if
	end					-- for
return result;																	-- declare boolean result and done
end


--[[--------------------------&lt; D A T E _ H Y P H E N _ T O _ D A S H &gt;----------------------------------------

Loops through the list of date-holding parameters and converts any hyphen to an ndash.  Not called if the cs1|2
template has any date errors.

Modifies the date_parameters_list and returns true if hyphens are replaced, else returns false.

]]

local function date_hyphen_to_dash (date_parameters_list)
	local result = false;
	local n;
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set (param_val.val) and
			not mw.ustring.match (param_val.val, patterns.ymd[1]) then			-- for those that are not ymd dates (ustring because here digits may not be Western)
				param_val.val, n = param_val.val:gsub ('%-', '–');				-- replace any hyphen with ndash
				if 0 ~= n then
					date_parameters_list[param_name].val = param_val.val;		-- update the list
					result = true;
				end
		end
	end
	return result;																-- so we know if any hyphens were replaced
end


--[[--------------------------&lt; E D T F _ T R A N S F O R M &gt;--------------------------------------------------

Loops through the list of date-holding parameters and converts any EDTF formatted dates to MOS compliant dates.
Only YYY-MM-XX supported at this time. Not called if the cs1|2 template has any date errors.

must be done before reformat_dates() and before date_hyphen_to_dash()

Modifies the date_parameters_list and returns true if transformation is performed, else returns false.

]]

local function edtf_transform (date_parameters_list)
	local result = false;
	local source_date = {};

	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val.val) and param_val.val:match (patterns.ymx[1]) then	-- if parameter is set and is an EDTF dates
			source_date.year, source_date.month = param_val.val:match (patterns.ymx[1]);	-- get year and month number
			source_date.day = 1;												-- required by os.time()
			date_parameters_list[param_name].val = mw.text.trim (os.date ('%B %Y', os.time (source_date)));
			result = true;
		end
	end
	return result;																-- so we know if a transform was done
end


--[[-------------------------&lt; D A T E _ N A M E _ X L A T E &gt;------------------------------------------------

Attempts to translate English month names to local-language month names using names supplied by MediaWiki's
date parser function.  This is simple name-for-name replacement and may not work for all languages.

if xlat_dig is true, this function will also translate Western (English) digits to the local language's digits.
This will also translate ymd dates.

]]

local function date_name_xlate (date_parameters_list, xlt_dig)
	local xlate;
	local mode;																	-- long or short month names
	local modified = false;
	local date;
	
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val.val) then											-- if the parameter has a value
			date = param_val.val;
			for month in mw.ustring.gmatch (date, '%a+') do						-- iterate through all dates in the date (single date or date range)
				if cfg.date_names.en.long[month] then
					mode = 'F';													-- English name is long so use long local name
				elseif cfg.date_names.en.short[month] then
					mode = 'M';													-- English name is short so use short local name
				else
					mode = nil;													-- not an English month name; could be local language month name or an English season name
				end
		
				if mode then													-- might be a season
					xlate = lang_object:formatDate(mode, '1' .. month);			-- translate the month name to this local language
					date = mw.ustring.gsub (date, month, xlate);				-- replace the English with the translation
					date_parameters_list[param_name].val = date;				-- save the translated date
					modified = true;
				end
			end

			if xlt_dig then														-- shall we also translate digits?
				date = date:gsub ('%d', cfg.date_names.xlate_digits);			-- translate digits from Western to 'local digits'
				date_parameters_list[param_name].val = date;					-- save the translated date
				modified = true;
			end
		end
	end
	
	return modified;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	add_prop_cat = utilities_page_ptr.add_prop_cat ;							-- import functions from selected Module:Citation/CS1/Utilities module
	is_set = utilities_page_ptr.is_set;
	in_array = utilities_page_ptr.in_array;
	set_message = utilities_page_ptr.set_message;
	substitute = utilities_page_ptr.substitute;
	wrap_style = utilities_page_ptr.wrap_style;

	cfg = cfg_table_ptr;														-- import tables from selected Module:Citation/CS1/Configuration
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {																		-- return exported functions
	dates = dates,
	year_date_check = year_date_check,
	reformat_dates = reformat_dates,
	date_hyphen_to_dash = date_hyphen_to_dash,
	date_name_xlate = date_name_xlate,
	edtf_transform = edtf_transform,
	set_selected_modules = set_selected_modules
	}</text>
      <sha1>b6r7jye2hd1gicunlxd102sepp586yc</sha1>
    </revision>
    <revision>
      <id>4851</id>
      <parentid>4850</parentid>
      <timestamp>2021-07-28T10:37:57Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>prevent date conversion to ymd when source year has CITEREF disambiguator;</comment>
      <origin>4851</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="63416" sha1="8fmfwsmiqhhlc9hf7o5st1swxmemmse" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local add_prop_cat, is_set, in_array, set_message, substitute, wrap_style;		-- imported functions from selected Module:Citation/CS1/Utilities
local cfg;																		-- table of tables imported from selected Module:Citation/CS1/Configuration


--[[--------------------------&lt; F I L E - S C O P E   D E C L A R A T I O N S &gt;--------------------------------

File-scope variables are declared here

]]

local lang_object = mw.getContentLanguage();									-- used by is_valid_accessdate(), is_valid_year(), date_name_xlate(); TODO: move to ~/Configuration?
local year_limit;																-- used by is_valid_year()


--[=[-------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |access-date= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-English date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate().  To get around that
call this function with YYYY-MM-DD format dates.

]=]

local function is_valid_accessdate (accessdate)
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold Unix time stamps representing the dates

	good1, access_ts = pcall (lang_object.formatDate, lang_object, 'U', accessdate );			-- convert accessdate value to Unix timestamp 
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which which tonumber() may not understand
		access_ts = tonumber (access_ts) or lang_object:parseFormattedNumber (access_ts);		-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to Unix time stamp
	end

	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end


--[[--------------------------&lt; I S _ V A L I D _ E M B A R G O _ D A T E &gt;------------------------------------

returns true and date value if that value has proper dmy, mdy, ymd format.

returns false and 9999 (embargoed forever) when date value is not proper format; assumes that when |pmc-embargo-date= is
set, the editor intended to embargo a PMC but |pmc-embargo-date= does not hold a single date.

]]

local function is_valid_embargo_date (v)
	if v:match ('^%d%d%d%d%-%d%d%-%d%d$') or									-- ymd
		v:match ('^%d%d?%s+%a+%s+%d%d%d%d$') or									-- dmy
		v:match ('^%a+%s+%d%d?%s*,%s*%d%d%d%d$') then							-- mdy
			return true, v;
	end
	return false, '9999';														-- if here not good date so return false and set embargo date to long time in future
end


--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct.
If not a valid month, returns 0

]]

local function get_month_number (month)
	return cfg.date_names['local'].long[month] or cfg.date_names['local'].short[month] or	-- look for local names first
			cfg.date_names['en'].long[month] or	cfg.date_names['en'].short[month] or		-- failing that, look for English names
			0;																				-- not a recognized month name
end


--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 21 for Spring, etc.  Capitalization and spelling
must be correct. If not a valid season, returns 0.
	21-24 = Spring, Summer, Autumn, Winter, independent of “Hemisphere”

returns 0 when &lt;param&gt; is not |date=

Season numbering is defined by Extended Date/Time Format (EDTF) specification (https://www.loc.gov/standards/datetime/)
which became part of ISO 8601 in 2019.  See '§Sub-year groupings'.  The standard defines various divisions using
numbers 21-41.  cs1|2 only supports generic seasons.  EDTF does support the distinction between north and south
hemisphere seasons but cs1|2 has no way to make that distinction.

These additional divisions not currently supported:
	25-28 = Spring - Northern Hemisphere, Summer- Northern Hemisphere, Autumn - Northern Hemisphere, Winter - Northern Hemisphere
	29-32 = Spring – Southern Hemisphere, Summer– Southern Hemisphere, Autumn – Southern Hemisphere, Winter - Southern Hemisphere
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)

]]

local function get_season_number (season, param)
	if 'date' ~= param then
		return 0;																-- season dates only supported by |date=
	end
	return cfg.date_names['local'].season[season] or							-- look for local names first
			cfg.date_names['en'].season[season] or								-- failing that, look for English names
			0;																	-- not a recognized season name
end


--[[--------------------------&lt; G E T _ Q U A R T E R _ N U M B E R &gt;------------------------------------------

returns a number according to the sequence of quarters in a year: 33 for first quarter, etc.  Capitalization and spelling
must be correct. If not a valid quarter, returns 0.
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)

returns 0 when &lt;param&gt; is not |date=

Quarter numbering is defined by Extended Date/Time Format (EDTF) specification (https://www.loc.gov/standards/datetime/)
which became part of ISO 8601 in 2019.  See '§Sub-year groupings'.  The standard defines various divisions using
numbers 21-41.  cs1|2 only supports generic seasons and quarters.

These additional divisions not currently supported:
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)

]]

local function get_quarter_number (quarter, param)
	if 'date' ~= param then
		return 0;																-- quarter dates only supported by |date=
	end
	quarter = mw.ustring.gsub (quarter, ' +', ' ');								-- special case replace multiple space chars with a single space char
	return cfg.date_names['local'].quarter[quarter] or							-- look for local names first
			cfg.date_names['en'].quarter[quarter] or							-- failing that, look for English names
			0;																	-- not a recognized quarter name
end


--[[--------------------------&lt; G E T _ P R O P E R _ N A M E _ N U M B E R &gt;----------------------------------

returns a non-zero number if date contains a recognized proper-name.  Capitalization and spelling must be correct.

returns 0 when &lt;param&gt; is not |date=

]]

local function get_proper_name_number (name, param)
	if 'date' ~= param then
		return 0;																-- proper-name dates only supported by |date=
	end
	return cfg.date_names['local'].named[name] or								-- look for local names dates first
			cfg.date_names['en'].named[name] or									-- failing that, look for English names
			0;																	-- not a recognized named date
end


--[[--------------------------&lt; G E T _ E L E M E N T _ N U M B E R &lt;------------------------------------------

returns true if month or season or quarter or proper name is valid (properly spelled, capitalized, abbreviated)

]]

local function get_element_number (element, param)
	local num;
	
	local funcs = {get_month_number, get_season_number, get_quarter_number, get_proper_name_number};	-- list of functions to execute in order
	
	for _, func in ipairs (funcs) do											-- spin through the function list
		num = func (element, param);											-- call the function and get the returned number
		if 0 ~= num then														-- non-zero when valid month season quarter 
			return num;															-- return that number
		end
	end
	return nil;																	-- not valid
end


--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one
year in the future are not acceptable.

]]

local function is_valid_year (year)
	if not is_set(year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;									-- global variable so we only have to fetch it once
	end

	year = tonumber (year) or lang_object:parseFormattedNumber (year);			-- convert to numbers for the comparison;
	return year and (year &lt;= year_limit) or false;
end


--[[--------------------------&lt; I S _ V A L I D _ D A T E &gt;----------------------------------------------------

Returns true if day is less than or equal to the number of days in month and year is no farther into the future
than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap
years before 1582 and Gregorian leap years after 1582. Where the two calendars overlap (1582 to approximately
1923) dates are assumed to be Gregorian.

]]

local function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year(year) then												-- no farther into the future than next year
		return false;
	end
	
	month = tonumber(month);													-- required for YYYY-MM-DD dates
	
	if (2 == month) then														-- if February
		month_length = 28;														-- then 28 days unless
		if 1582 &gt; tonumber(year) then											-- Julian calendar
			if 0 == (year%4) then												-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		else																	-- Gregorian calendar
			if (0 == (year%4) and (0 ~= (year%100) or 0 == (year%400))) then	-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		end
	else
		month_length = days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
There is a special test for May because it can be either short or long form.

Returns true when style for both months is the same

]]

local function is_valid_month_range_style (month1, month2)
local len1 = month1:len();
local len2 = month2:len();
	if len1 == len2 then
		return true;															-- both months are short form so return true
	elseif 'May' == month1 or 'May'== month2 then -- ToDo: I18N
		return true;															-- both months are long form so return true
	elseif 3 == len1 or 3 == len2 then
		return false;															-- months are mixed form so return false
	else
		return true;															-- both months are long form so return true
	end
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

All season ranges are accepted as valid because there are publishers out there who have published a Summer–Spring YYYY issue, hence treat as ok

]]

local function is_valid_month_season_range(range_start, range_end, param)
	local range_start_number = get_month_number (range_start);
	local range_end_number;

	if 0 == range_start_number then												-- is this a month range?
		range_start_number = get_season_number (range_start, param);			-- not a month; is it a season? get start season number
		range_end_number = get_season_number (range_end, param);				-- get end season number

		if (0 ~= range_start_number) and (0 ~= range_end_number) and (range_start_number ~= range_end_number) then
			return true;														-- any season pairing is accepted except when both are the same
		end
		return false;															-- range_start and/or range_end is not a season
	end
																				-- here when range_start is a month
	range_end_number = get_month_number (range_end);							-- get end month number
	if range_start_number &lt; range_end_number and								-- range_start is a month; does range_start precede range_end?
		is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
	end
	return false;																-- range_start month number is greater than or equal to range end number; or range end isn't a month
end


--[[--------------------------&lt; M A K E _ C O I N S _ D A T E &gt;------------------------------------------------

This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1.  The function is called only for |date= parameters and only if the |date=&lt;value&gt; is 
determined to be a valid date format.  The question of what to do with invalid date formats is not answered here.

The date parts in the input table are converted to an ISO 8601 conforming date string:
	single whole dates:		yyyy-mm-dd
	month and year dates:	yyyy-mm
	year dates:				yyyy
	ranges:					yyyy-mm-dd/yyyy-mm-dd
							yyyy-mm/yyyy-mm
							yyyy/yyyy

Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.

The input table has:
	year, year2 – always present; if before 1582, ignore months and days if present
	month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 99 Christmas
	day, day2 –  0 if not provided, 1-31 for days
	
the output table receives:
	rftdate:	an ISO 8601 formatted date
	rftchron:	a free-form version of the date, usually without year which is in rftdate (season ranges and proper-name dates)
	rftssn:		one of four season keywords: winter, spring, summer, fall (lowercase)
	rftquarter:	one of four values: 1, 2, 3, 4

]]

local function make_COinS_date (input, tCOinS_date)
	local date;																	-- one date or first date in a range
	local date2 = '';															-- end of range date
-- start temporary Julian / Gregorian calendar uncertainty detection
	local year = tonumber(input.year);											-- this temporary code to determine the extent of sources dated to the Julian/Gregorian
	local month = tonumber(input.month);										-- interstice 1 October 1582 – 1 January 1926
	local day = tonumber (input.day);
	if (0 ~= day) and															-- day must have a value for this to be a whole date
		(((1582 == year) and (10 &lt;= month) and (12 &gt;= month)) or				-- any whole 1582 date from 1 October to 31 December or
			((1926 == year) and (1 == month) and (1 == input.day)) or			-- 1 January 1926 or
				((1582 &lt; year) and (1925 &gt;= year))) then						-- any date 1 January 1583 – 31 December 1925
					tCOinS_date.inter_cal_cat = true;							-- set category flag true
	end
-- end temporary Julian / Gregorian calendar uncertainty detection
	
	if 1582 &gt; tonumber(input.year) or 20 &lt; tonumber(input.month) then			-- Julian calendar or season so &amp;rft.date gets year only
		date = input.year;
		if 0 ~= input.year2 and input.year ~= input.year2 then					-- if a range, only the second year portion when not the same as range start year
			date = string.format ('%.4d/%.4d', tonumber(input.year), tonumber(input.year2))		-- assemble the date range
		end
		if 20 &lt; tonumber(input.month) then										-- if season or proper-name date
			local season = {[24] = 'winter', [21] = 'spring', [22] = 'summer', [23] = 'fall', [33] = '1', [34] = '2', [35] = '3', [36] = '4', [98] = 'Easter', [99] = 'Christmas'};	-- seasons lowercase, no autumn; proper-names use title case
			if 0 == input.month2 then											-- single season date
				if 40 &lt; tonumber(input.month) then
					tCOinS_date.rftchron = season[input.month];					-- proper-name dates
				elseif 30 &lt; tonumber(input.month) then
					tCOinS_date.rftquarter = season[input.month];				-- quarters
				else
					tCOinS_date.rftssn = season[input.month];					-- seasons
				end
			else																-- season range with a second season specified
				if input.year ~= input.year2 then								-- season year – season year range or season year–year
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					if 0~= input.month2 then
						tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);
					end
				else															-- season–season year range
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2];	-- season–season year range
				end
			end
		end
		tCOinS_date.rftdate = date;
		return;																	-- done
	end
	
	if 0 ~= input.day then
		date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day));	-- whole date
	elseif 0 ~= input.month then
		date = string.format ('%s-%.2d', input.year, tonumber(input.month));	-- year and month
	else
		date = string.format ('%s', input.year);								-- just year
	end

	if 0 ~= input.year2 then
		if 0 ~= input.day2 then
			date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2));		-- whole date
		elseif 0 ~= input.month2 then
			date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2));	-- year and month
		else
			date2 = string.format ('/%s', input.year2);							-- just year
		end
	end
	
	tCOinS_date.rftdate = date .. date2;										-- date2 has the '/' separator
	return;
end


--[[--------------------------&lt; P A T T E R N S &gt;--------------------------------------------------------------

this is the list of patterns for date formats that this module recognizes.  Approximately the first half of these
patterns represent formats that might be reformatted into another format.  Those that might be reformatted have
'indicator' letters that identify the content of the matching capture: 'd' (day), 'm' (month), 'a' (anchor year),
'y' (year); second day, month, year have a '2' suffix.

These patterns are used for both date validation and for reformatting.  This table should not be moved to ~/Configuration
because changes to this table require changes to check_date() and to reformatter() and reformat_date()

]]

local patterns = {
	 																			-- year-initial numerical year-month-day
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'},					
																				-- month-initial: month day, year
	['Mdy'] = {'^(%D-) +([1-9]%d?), +((%d%d%d%d?)%a?)$', 'm', 'd', 'a', 'y'},
																				-- month-initial day range: month day–day, year; days are separated by endash
	['Md-dy'] = {'^(%D-) +([1-9]%d?)[%-–]([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'd2', 'a', 'y'},
																				-- day-initial: day month year
	['dMy'] = {'^([1-9]%d?) +(%D-) +((%d%d%d%d?)%a?)$', 'd', 'm', 'a', 'y'},
																				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed; not supported at en.wiki
	--	['yMd'] = {'^((%d%d%d%d?)%a?) +(%D-) +(%d%d?)$', 'a', 'y', 'm', 'd'},
																				-- day-range-initial: day–day month year; days are separated by endash
	['d-dMy'] = {'^([1-9]%d?)[%-–]([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'd2', 'm', 'a', 'y'},
																				-- day initial month-day-range: day month - day month year; uses spaced endash
	['dM-dMy'] = {'^([1-9]%d?) +(%D-) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'd2', 'm2', 'a', 'y'},
																				-- month initial month-day-range: month day – month day, year;  uses spaced endash
	['Md-Mdy'] = {'^(%D-) +([1-9]%d?) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$','m', 'd', 'm2', 'd2', 'a', 'y'},
																				-- day initial month-day-year-range: day month year - day month year; uses spaced endash
	['dMy-dMy'] = {'^([1-9]%d?) +(%D-) +(%d%d%d%d) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'y', 'd2', 'm2', 'a', 'y2'},
																				-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
	['Mdy-Mdy'] = {'^(%D-) +([1-9]%d?), +(%d%d%d%d) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'y', 'm2', 'd2', 'a', 'y2'},

																				-- these date formats cannot be converted, per se, but month name can be rendered short or long
																				-- month/season year - month/season year; separated by spaced endash
	['My-My'] = {'^(%D-) +(%d%d%d%d) +[%-–] +(%D-) +((%d%d%d%d)%a?)$', 'm', 'y', 'm2', 'a', 'y2'},
																				-- month/season range year; months separated by endash
	['M-My'] = {'^(%D-)[%-–](%D-) +((%d%d%d%d)%a?)$', 'm', 'm2', 'a', 'y'},
																				-- month/season year or proper-name year; quarter year when First Quarter YYYY etc.
	['My'] = {'^([^%d–]-) +((%d%d%d%d)%a?)$', 'm', 'a', 'y'},					-- this way because endash is a member of %D; %D- will match January–March 2019 when it shouldn't

																				-- these date formats cannot be converted
	['Sy4-y2'] = {'^(%D-) +((%d%d)%d%d)[%-–]((%d%d)%a?)$'},						-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
	['Sy-y'] = {'^(%D-) +(%d%d%d%d)[%-–]((%d%d%d%d)%a?)$'},						-- special case Winter/Summer year-year; year separated with unspaced endash
	['y-y'] = {'^(%d%d%d%d?)[%-–]((%d%d%d%d?)%a?)$'},							-- year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
	['y4-y2'] = {'^((%d%d)%d%d)[%-–]((%d%d)%a?)$'},								-- year range: YYYY–YY; separated by unspaced endash
	['ymx'] = {'^(%d%d%d%d)%-(%d%d)%-XX$', 'y', 'm'},							-- edtf year-initial numerical year-month-XX
	['y'] = {'^((%d%d%d%d?)%a?)$'},												-- year; here accept either YYY or YYYY
	}


--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only
allowed range separator is endash.  Additionally, check the date to see that it is a real date: no 31 in 30-day
months; no 29 February when not a leap year.  Months, both long-form and three character abbreviations, and seasons
must be spelled correctly.  Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and
COinS_date.  When this happens, the date parameter is (DEBUG: not?) used in the COinS metadata and the CITEREF identifier gets
its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, publication-date, access-date, pmc-embargo-date, archive-date, lay-date)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is ISO 8601 format date; see make_COInS_date()

]]

local function check_date (date_string, param, tCOinS_date)
	local year;																	-- assume that year2, months, and days are not used;
	local year2 = 0;															-- second year in a year range
	local month = 0;
	local month2 = 0;															-- second month in a month range
	local day = 0;
	local day2 = 0;																-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match (patterns['ymd'][1]) then								-- year-initial numerical year month day format
		year, month, day = date_string:match (patterns['ymd'][1]);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or 0 == tonumber(day) then return false; end	-- month or day number not valid or not Gregorian calendar
		anchor_year = year;
	
	elseif date_string:match (patterns['ymx'][1]) then							-- year-initial numerical year month edtf format
		year, month = date_string:match (patterns['ymx'][1]);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or not is_valid_year(year) then return false; end	-- month number not valid or not Gregorian calendar or future year
		anchor_year = year;

	elseif mw.ustring.match(date_string, patterns['Mdy'][1]) then				-- month-initial: month day, year
		month, day, anchor_year, year = mw.ustring.match(date_string, patterns['Mdy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
				
	elseif mw.ustring.match(date_string, patterns['Md-dy'][1]) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year = mw.ustring.match(date_string, patterns['Md-dy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2=month;															-- for metadata
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['dMy'][1]) then				-- day-initial: day month year
		day, month, anchor_year, year = mw.ustring.match(date_string, patterns['dMy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months

--[[ NOT supported at en.wiki
	elseif mw.ustring.match(date_string, patterns['yMd'][1]) then				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed
		anchor_year, year, month, day = mw.ustring.match(date_string, patterns['yMd'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
-- end NOT supported at en.wiki ]]

	elseif mw.ustring.match(date_string, patterns['d-dMy'][1]) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year = mw.ustring.match(date_string, patterns['d-dMy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2 = month;															-- for metadata
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['dM-dMy'][1]) then			-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year = mw.ustring.match(date_string, patterns['dM-dMy'][1]);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['Md-Mdy'][1]) then			-- month initial month-day-range: month day – month day, year; uses spaced endash
		month, day, month2, day2, anchor_year, year = mw.ustring.match(date_string, patterns['Md-Mdy'][1]);
		if (not is_valid_month_season_range(month, month2, param)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['dMy-dMy'][1]) then			-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2 = mw.ustring.match(date_string, patterns['dMy-dMy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		if 0 == month or 0 == month2 then return false; end						-- both must be valid

	elseif mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]) then			-- month initial month-day-year-range: month day, year – month day, year; uses spaced endash
		month, day, year, month2, day2, anchor_year, year2 = mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number(month2);
		if 0 == month or 0 == month2 then return false; end						-- both must be valid

	elseif mw.ustring.match(date_string, patterns['Sy4-y2'][1]) then			-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		local century;
		month, year, century, anchor_year, year2 = mw.ustring.match(date_string, patterns['Sy4-y2'][1]);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;		-- 'month' can only be Winter or Summer
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor_year from both years
		year2 = century..year2;													-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		month = get_season_number(month, param);

	elseif mw.ustring.match(date_string, patterns['Sy-y'][1]) then				-- special case Winter/Summer year-year; year separated with unspaced endash
		month, year, anchor_year, year2 = mw.ustring.match(date_string, patterns['Sy-y'][1]);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;		-- 'month' can only be Winter or Summer
		anchor_year = year .. '–' .. anchor_year;										-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		month = get_season_number (month, param);								-- for metadata

	elseif mw.ustring.match(date_string, patterns['My-My'][1]) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2 = mw.ustring.match(date_string, patterns['My-My'][1]);
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then 	-- both must be month year, same month style
			month = get_month_number(month);
			month2 = get_month_number(month2);
		elseif 0 ~= get_season_number(month, param) and 0 ~= get_season_number(month2, param) then	-- both must be season year, not mixed
			month = get_season_number(month, param);
			month2 = get_season_number(month2, param);
		else
			 return false;
		end

	elseif mw.ustring.match(date_string, patterns['M-My'][1]) then				-- month/season range year; months separated by endash 
		month, month2, anchor_year, year = mw.ustring.match(date_string, patterns['M-My'][1]);
		if (not is_valid_month_season_range(month, month2, param)) or (not is_valid_year(year)) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
			month2 = get_month_number(month2);
			if 0 == month or 0 == month2 then return false; end
		else
			month = get_season_number(month, param);
			month2 = get_season_number(month2, param);
		end
		year2 = year;
		
	elseif mw.ustring.match(date_string, patterns['My'][1]) then				-- month/season/quarter/proper-name year
		month, anchor_year, year = mw.ustring.match(date_string, patterns['My'][1]);
		if not is_valid_year(year) then return false; end
		month = get_element_number(month, param);								-- get month season quarter proper-name number or nil
		if not month then return false; end										-- not valid whatever it is

	elseif mw.ustring.match(date_string, patterns['y-y'][1]) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2 = mw.ustring.match(date_string, patterns['y-y'][1]);
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, patterns['y4-y2'][1]) then				-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2 = mw.ustring.match(date_string, patterns['y4-y2'][1]);
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor year from both years

		if in_array (param, {'date', 'publication-date', 'year'}) then
			add_prop_cat ('year_range_abbreviated');
		end

		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century .. year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, patterns['y'][1]) then					-- year; here accept either YYY or YYYY
		anchor_year, year = mw.ustring.match(date_string, patterns['y'][1]);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;															-- date format not one of the MOS:DATE approved formats
	end

	if 'access-date' == param then												-- test accessdate here because we have numerical date parts
		if 0 ~= year and 0 ~= month and 0 ~= day and 							-- all parts of a single date required
			0 == year2 and 0 == month2 and 0 == day2 then						-- none of these; accessdate must not be a range
				if not is_valid_accessdate(year .. '-' .. month .. '-' .. day) then	
					return false;												-- return false when accessdate out of bounds
				end
		else
			return false;														-- return false when accessdate is a range of two dates
		end
	end

	local result=true;															-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result = is_valid_date(year, month, day);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result = is_valid_date(year, month, day);
		result = result and is_valid_date(year, month, day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result = is_valid_date(year, month, day);
		result = result and is_valid_date(year, month2, day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result = is_valid_date(year, month, day);
		result = result and is_valid_date(year2, month2, day2);
	end
	
	if false == result then return false; end

	if nil ~= tCOinS_date then													-- this table only passed into this function when testing |date= parameter values
		make_COinS_date ({year = year, month = month, day = day, year2 = year2, month2 = month2, day2 = day2}, tCOinS_date);	-- make an ISO 8601 date string for COinS
	end
	
	return true, anchor_year;													-- format is good and date string represents a real date
end	


--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
parameters with errors are added to the &lt;error_list&gt; sequence table as the dates are tested.

]]

local function dates(date_parameters_list, tCOinS_date, error_list)
	local anchor_year;															-- will return as nil if the date being tested is not |date=
	local COinS_date;															-- will return as nil if the date being tested is not |date=
	local embargo_date;															-- if embargo date is a good dmy, mdy, ymd date then holds original value else reset to 9999
	local good_date = false;

	for k, v in pairs(date_parameters_list) do									-- for each date-holding parameter in the list
		if is_set(v.val) then													-- if the parameter has a value
			v.val = mw.ustring.gsub(v.val, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9
			if v.val:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then						-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v.val:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);				-- get the year portion so it can be tested
				if 'date' == k then
					anchor_year, COinS_date = v.val:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year' == k then
					good_date = is_valid_year(year);
				end
			elseif 'date' == k then												-- if the parameter is |date=
				if v.val:match(&quot;^n%.d%.%a?$&quot;) then -- ToDo: I18N								-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((n%.d%.)%a?)&quot;); -- ToDo: I18N	-- &quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v.val:match(&quot;^nd%a?$&quot;) then -- ToDo: I18N								-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((nd)%a?)&quot;); -- ToDo: I18N	-- &quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v.val, k, tCOinS_date);	-- go test the date
				end
			elseif 'year' == k then												-- if the parameter is |year= it should hold only a year value
				if v.val:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then						-- if |year = 3 or 4 digits only with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((%d+)%a?)&quot;);
				end
			elseif 'pmc-embargo-date' == k then											-- if the parameter is |pmc-embargo-date=
				good_date = check_date (v.val, k);								-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date, embargo_date = is_valid_embargo_date (v.val);	-- is |pmc-embargo-date= date a single dmy, mdy, or ymd formatted date? yes: returns embargo; no: returns 9999
				end
			else																-- any other date-holding parameter
				good_date = check_date (v.val, k);								-- go test the date
			end
			if false == good_date then											-- assemble one error message so we don't add the tracking category multiple times
				table.insert (error_list, wrap_style ('parameter', v.name));	-- make parameter name suitable for error message list
			end
		end
	end
	return anchor_year, embargo_date;											-- and done
end


--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function sets a local numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

the numernic value in &lt;result&gt; determines the 'output' if any from this function:
	0 – adds error message to error_list sequence table
	1 – adds maint cat
	2 – does nothing

]]

local function year_date_check (year_string, year_origin, date_string, date_origin, error_list)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes

	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where both date and year are required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard range formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif mw.ustring.match(date_string, &quot;%d%d%d%d[%-–]%d%d&quot;) then				-- YYYY-YY date ranges
		local century;
		date1, century, date2 = mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	else																		-- should never get here; this function called only when no other date errors
		result = 0;																-- no recognizable year in date
	end

	if 0 == result then															-- year / date mismatch
		table.insert (error_list, substitute (cfg.messages['mismatch'], {year_origin, date_origin}));	-- add error message to error_list sequence table
	elseif 1 == result then														-- redundant year / date
		set_message ('maint_date_year');										-- add a maint cat
	end
end


--[[--------------------------&lt; R E F O R M A T T E R &gt;--------------------------------------------------------

reformat 'date' into new format specified by format_param if pattern_idx (the current format of 'date') can be
reformatted.  Does the grunt work for reformat_dates().

The table re_formats maps pattern_idx (current format) and format_param (desired format) to a table that holds:
	format string used by string.format()
	identifier letters ('d', 'm', 'y', 'd2', 'm2', 'y2') that serve as indexes into a table t{} that holds captures
		from mw.ustring.match() for the various date parts specified by  patterns[pattern_idx][1]

Items in patterns{} have the general form:
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'}, where:
		['ymd'] is pattern_idx
		patterns['ymd'][1] is the match pattern with captures for mw.ustring.match()
		patterns['ymd'][2] is an indicator letter identifying the content of the first capture
		patterns['ymd'][3] ... the second capture etc.

when a pattern matches a date, the captures are loaded into table t{} in capture order using the idemtifier
characters as indexes into t{}  For the above, a ymd date is in t{} as:
	t.y = first capture (year), t.m = second capture (month), t.d = third capture (day)

To reformat, this function is called with the pattern_idx that matches the current format of the date and with
format_param set to the desired format.  This function loads table t{} as described and then calls string.format()
with the format string specified by re_format[pattern_idx][format_param][1] using values taken from t{} according
to the capture identifier letters specified by patterns[pattern_idx][format_param][n] where n is 2..

]]

local re_formats = {
	['ymd'] = {																	-- date format is ymd; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
	--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},								-- |df=yMd; not supported at en.wiki
		},
	['Mdy'] = {																	-- date format is Mdy; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- for long/short reformatting
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
	--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},								-- |df=yMd; not supported at en.wiki
		},
	['dMy'] = {																	-- date format is dMy; reformat to:
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- for long/short reformatting
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
	--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},								-- |df=yMd; not supported at en.wiki
		},
	['Md-dy'] = {																-- date format is Md-dy; reformat to:
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- for long/short reformatting
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- |df=dmy -&gt; d-dMy 
		},
	['d-dMy'] = {																-- date format is d-d&gt;y; reformat to:
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- for long/short reformatting
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- |df=mdy -&gt; Md-dy 
		},
	['dM-dMy'] = {																-- date format is dM-dMy; reformat to:
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- for long/short reformatting
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd', 'm2', 'd2', 'y'},				-- |df=mdy -&gt; Md-Mdy 
		},
	['Md-Mdy'] = {																-- date format is Md-Mdy; reformat to:
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd',  'm2', 'd2', 'y'},			-- for long/short reformatting
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- |df=dmy -&gt; dM-dMy 
		},
	['dMy-dMy'] = {																-- date format is dMy-dMy; reformat to:
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- for long/short reformatting
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- |df=mdy -&gt; Mdy-Mdy 
		},
	['Mdy-Mdy'] = {																-- date format is Mdy-Mdy; reformat to:
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- for long/short reformatting
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- |df=dmy -&gt; dMy-dMy 
		},
	['My-My'] = {																-- these for long/short reformatting
		['any'] = {'%s %s – %s %s', 'm', 'y', 'm2', 'y2'},						-- dmy/mdy agnostic
		},
	['M-My'] = {																-- these for long/short reformatting
		['any'] = {'%s–%s %s', 'm', 'm2', 'y'},									-- dmy/mdy agnostic
		},
	['My'] = {																	-- these for long/short reformatting
		['any'] = {'%s %s', 'm', 'y'},											-- dmy/mdy agnostic
		},
	--	['yMd'] = {																-- not supported at en.wiki
	--		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},								-- |df=mdy
	--		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},								-- |df=dmy
	--		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},								-- |df=ymd
	--		},
	}


local function reformatter (date, pattern_idx, format_param, mon_len)
	if not in_array (pattern_idx, {'ymd', 'Mdy', 'Md-dy', 'dMy', 'yMd', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- not in this set of date format patterns then not a reformattable date
	end
	
	if 'ymd' == format_param and in_array (pattern_idx, {'ymd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- ymd date ranges not supported at en.wiki; no point in reformatting ymd to ymd
	end

	if in_array (pattern_idx, {'My', 'M-My', 'My-My'}) then						-- these are not dmy/mdy so can't be 'reformatted' into either
		format_param = 'any';													-- so format-agnostic 
	end

																				-- yMd is not supported at en.wiki; if yMd is supported at your wiki, uncomment the next line
	--	if 'yMd' == format_param and in_array (pattern_idx, {'yMd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy'}) then	-- these formats not convertable; yMd not supported at en.wiki
	-- if yMd is supported at your wiki, remove or comment-out the next line
	if 'yMd' == format_param then												-- yMd not supported at en.wiki
		return;																	-- not a reformattable date
	end
	
	local c1, c2, c3, c4, c5, c6, c7;											-- these hold the captures specified in patterns[pattern_idx][1]
	c1, c2, c3, c4, c5, c6, c7 = mw.ustring.match (date, patterns[pattern_idx][1]);	-- get the captures

	local t = {																	-- table that holds k/v pairs of date parts from the captures and patterns[pattern_idx][2..]
		[patterns[pattern_idx][2]] = c1;										-- at minimum there is always one capture with a matching indicator letter
		[patterns[pattern_idx][3] or 'x'] = c2;									-- patterns can have a variable number of captures; each capture requires an indicator letter;
		[patterns[pattern_idx][4] or 'x'] = c3;									-- where there is no capture, there is no indicator letter so n in patterns[pattern_idx][n] will be nil;
		[patterns[pattern_idx][5] or 'x'] = c4;									-- the 'x' here spoofs an indicator letter to prevent 'table index is nil' error
		[patterns[pattern_idx][6] or 'x'] = c5;
		[patterns[pattern_idx][7] or 'x'] = c6;
		[patterns[pattern_idx][8] or 'x'] = c7;
		};

	if t.a then																	-- if this date has an anchor year capture
		t.y = t.a;																-- use the anchor year capture when reassembling the date
	end

	if tonumber(t.m) then														-- if raw month is a number (converting from ymd)
		if 's' == mon_len then													-- if we are to use abbreviated month names
			t.m = cfg.date_names['inv_local_s'][tonumber(t.m)];					-- convert it to a month name
		else
			t.m = cfg.date_names['inv_local_l'][tonumber(t.m)];					-- convert it to a month name
		end
		t.d = t.d:gsub ('0(%d)', '%1');											-- strip leading '0' from day if present
	elseif 'ymd' == format_param then											-- when converting to ymd
		if 1582 &gt; (tonumber(t.y) or 0) then										-- ymd format dates not allowed before 1582; years in source date with CITEREF disambiguator not converted
			return;
		end
		t.m = string.format ('%02d', get_month_number (t.m));					-- make sure that month and day are two digits
		t.d = string.format ('%02d', t.d);
	elseif mon_len then															-- if mon_len is set to either 'short' or 'long'
		for _, mon in ipairs ({'m', 'm2'}) do									-- because there can be two month names, check both 
			if t[mon] then
				t[mon] = get_month_number (t[mon]);								-- get the month number for this month (is length agnostic)
				if 0 == t[mon] then return; end									-- seasons and named dates can't be converted
				t[mon] = (('s' == mon_len) and cfg.date_names['inv_local_s'][t[mon]]) or cfg.date_names['inv_local_l'][t[mon]];	-- fetch month name according to length
			end
		end
	end

	local new_date = string.format (re_formats[pattern_idx][format_param][1],	-- format string
		t[re_formats[pattern_idx][format_param][2]],							-- named captures from t{}
		t[re_formats[pattern_idx][format_param][3]],
		t[re_formats[pattern_idx][format_param][4]],
		t[re_formats[pattern_idx][format_param][5]],
		t[re_formats[pattern_idx][format_param][6]],
		t[re_formats[pattern_idx][format_param][7]],
		t[re_formats[pattern_idx][format_param][8]]
		);

	return new_date;
end


--[[-------------------------&lt; R E F O R M A T _ D A T E S &gt;--------------------------------------------------

Reformats existing dates into the format specified by format.

format is one of several manual keywords: dmy, dmy-all, mdy, mdy-all, ymd, ymd-all.  The -all version includes
access- and archive-dates; otherwise these dates are not reformatted.

This function allows automatic date formatting.  In ~/Configuration, the article source is searched for one of
the {{use xxx dates}} templates.  If found, xxx becomes the global date format as xxx-all.  If |cs1-dates= in
{{use xxx dates}} has legitimate value then that value determines how cs1|2 dates will be rendered.  Legitimate
values for |cs1-dates= are:
	l - all dates are rendered with long month names
	ls - publication dates use long month names; access-/archive-dates use abbreviated month names
	ly - publication dates use long month names; access-/archive-dates rendered in ymd format
	s - all dates are rendered with abbreviated (short) month names
	sy - publication dates use abbreviated month names; access-/archive-dates rendered in ymd format
	y - all dates are rendered in ymd format

the format argument for automatic date formatting will be the format specified by {{use xxx dates}} with the
value supplied by |cs1-dates so one of: xxx-l, xxx-ls, xxx-ly, xxx-s, xxx-sy, xxx-y, or simply xxx (|cs1-dates=
empty, omitted, or invalid) where xxx shall be either of dmy or mdy.

dates are extracted from date_parameters_list, reformatted (if appropriate), and then written back into the
list in the new format.  Dates in date_parameters_list are presumed here to be valid (no errors).  This function
returns true when a date has been reformatted, false else.  Actual reformatting is done by reformatter().

]]

local function reformat_dates (date_parameters_list, format)
	local all = false;															-- set to false to skip access- and archive-dates
	local len_p = 'l';															-- default publication date length shall be long
	local len_a = 'l';															-- default access-/archive-date length shall be long
	local result = false;
	local new_date;																
	
	if format:match('%a+%-all') then											-- manual df keyword; auto df keyword when length not specified in {{use xxx dates}}; 
		format = format:match('(%a+)%-all');									-- extract the format
		all = true;																-- all dates are long format dates because this keyword doesn't specify length
	elseif format:match('%a+%-[lsy][sy]?') then									-- auto df keywords; internal only
		all = true;																-- auto df applies to all dates; use length specified by capture len_p for all dates
		format, len_p, len_a = format:match('(%a+)%-([lsy])([sy]?)');			-- extract the format and length keywords
		if 'y' == len_p then													-- because allowed by MOS:DATEUNIFY (sort of) range dates and My dates not reformatted
			format = 'ymd';														-- override {{use xxx dates}}
		elseif (not is_set(len_a)) or (len_p == len_a) then						-- no access-/archive-date length specified or same length as publication dates then
			len_a = len_p;														-- in case len_a not set
		end
	end																			-- else only publication dates and they are long

	for param_name, param_val in pairs (date_parameters_list) do				-- for each date-holding parameter in the list
		if is_set (param_val.val) then											-- if the parameter has a value
			if not (not all and in_array (param_name, {'access-date', 'archive-date'})) then	-- skip access- or archive-date unless format is xxx-all; yeah, ugly; TODO: find a better way
				for pattern_idx, pattern in pairs (patterns) do
					if mw.ustring.match (param_val.val, pattern[1]) then
						if all and in_array (param_name, {'access-date', 'archive-date'}) then	-- if this date is an access- or archive-date
							new_date = reformatter (param_val.val, pattern_idx, (('y' == len_a) and 'ymd') or format, len_a);	-- choose ymd or dmy/mdy according to len_a setting
						else													-- all other dates
							new_date = reformatter (param_val.val, pattern_idx, format, len_p);
						end
						
						if new_date then										-- set when date was reformatted
							date_parameters_list[param_name].val = new_date;	-- update date in date list
							result = true;										-- and announce that changes have been made
						end
					end	-- if
				end		-- for
			end			-- if
		end				-- if
	end					-- for
return result;																	-- declare boolean result and done
end


--[[--------------------------&lt; D A T E _ H Y P H E N _ T O _ D A S H &gt;----------------------------------------

Loops through the list of date-holding parameters and converts any hyphen to an ndash.  Not called if the cs1|2
template has any date errors.

Modifies the date_parameters_list and returns true if hyphens are replaced, else returns false.

]]

local function date_hyphen_to_dash (date_parameters_list)
	local result = false;
	local n;
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set (param_val.val) and
			not mw.ustring.match (param_val.val, patterns.ymd[1]) then			-- for those that are not ymd dates (ustring because here digits may not be Western)
				param_val.val, n = param_val.val:gsub ('%-', '–');				-- replace any hyphen with ndash
				if 0 ~= n then
					date_parameters_list[param_name].val = param_val.val;		-- update the list
					result = true;
				end
		end
	end
	return result;																-- so we know if any hyphens were replaced
end


--[[--------------------------&lt; E D T F _ T R A N S F O R M &gt;--------------------------------------------------

Loops through the list of date-holding parameters and converts any EDTF formatted dates to MOS compliant dates.
Only YYY-MM-XX supported at this time. Not called if the cs1|2 template has any date errors.

must be done before reformat_dates() and before date_hyphen_to_dash()

Modifies the date_parameters_list and returns true if transformation is performed, else returns false.

]]

local function edtf_transform (date_parameters_list)
	local result = false;
	local source_date = {};

	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val.val) and param_val.val:match (patterns.ymx[1]) then	-- if parameter is set and is an EDTF dates
			source_date.year, source_date.month = param_val.val:match (patterns.ymx[1]);	-- get year and month number
			source_date.day = 1;												-- required by os.time()
			date_parameters_list[param_name].val = mw.text.trim (os.date ('%B %Y', os.time (source_date)));
			result = true;
		end
	end
	return result;																-- so we know if a transform was done
end


--[[-------------------------&lt; D A T E _ N A M E _ X L A T E &gt;------------------------------------------------

Attempts to translate English month names to local-language month names using names supplied by MediaWiki's
date parser function.  This is simple name-for-name replacement and may not work for all languages.

if xlat_dig is true, this function will also translate Western (English) digits to the local language's digits.
This will also translate ymd dates.

]]

local function date_name_xlate (date_parameters_list, xlt_dig)
	local xlate;
	local mode;																	-- long or short month names
	local modified = false;
	local date;
	
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val.val) then											-- if the parameter has a value
			date = param_val.val;
			for month in mw.ustring.gmatch (date, '%a+') do						-- iterate through all dates in the date (single date or date range)
				if cfg.date_names.en.long[month] then
					mode = 'F';													-- English name is long so use long local name
				elseif cfg.date_names.en.short[month] then
					mode = 'M';													-- English name is short so use short local name
				else
					mode = nil;													-- not an English month name; could be local language month name or an English season name
				end
		
				if mode then													-- might be a season
					xlate = lang_object:formatDate(mode, '1' .. month);			-- translate the month name to this local language
					date = mw.ustring.gsub (date, month, xlate);				-- replace the English with the translation
					date_parameters_list[param_name].val = date;				-- save the translated date
					modified = true;
				end
			end

			if xlt_dig then														-- shall we also translate digits?
				date = date:gsub ('%d', cfg.date_names.xlate_digits);			-- translate digits from Western to 'local digits'
				date_parameters_list[param_name].val = date;					-- save the translated date
				modified = true;
			end
		end
	end
	
	return modified;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	add_prop_cat = utilities_page_ptr.add_prop_cat ;							-- import functions from selected Module:Citation/CS1/Utilities module
	is_set = utilities_page_ptr.is_set;
	in_array = utilities_page_ptr.in_array;
	set_message = utilities_page_ptr.set_message;
	substitute = utilities_page_ptr.substitute;
	wrap_style = utilities_page_ptr.wrap_style;

	cfg = cfg_table_ptr;														-- import tables from selected Module:Citation/CS1/Configuration
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {																		-- return exported functions
	dates = dates,
	year_date_check = year_date_check,
	reformat_dates = reformat_dates,
	date_hyphen_to_dash = date_hyphen_to_dash,
	date_name_xlate = date_name_xlate,
	edtf_transform = edtf_transform,
	set_selected_modules = set_selected_modules
	}</text>
      <sha1>8fmfwsmiqhhlc9hf7o5st1swxmemmse</sha1>
    </revision>
    <revision>
      <id>4852</id>
      <parentid>4851</parentid>
      <timestamp>2021-07-28T11:04:25Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>better;</comment>
      <origin>4852</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="63479" sha1="0e3bmc1trazjro3cqbxt2glpi4mw6un" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local add_prop_cat, is_set, in_array, set_message, substitute, wrap_style;		-- imported functions from selected Module:Citation/CS1/Utilities
local cfg;																		-- table of tables imported from selected Module:Citation/CS1/Configuration


--[[--------------------------&lt; F I L E - S C O P E   D E C L A R A T I O N S &gt;--------------------------------

File-scope variables are declared here

]]

local lang_object = mw.getContentLanguage();									-- used by is_valid_accessdate(), is_valid_year(), date_name_xlate(); TODO: move to ~/Configuration?
local year_limit;																-- used by is_valid_year()


--[=[-------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |access-date= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-English date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate().  To get around that
call this function with YYYY-MM-DD format dates.

]=]

local function is_valid_accessdate (accessdate)
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold Unix time stamps representing the dates

	good1, access_ts = pcall (lang_object.formatDate, lang_object, 'U', accessdate );			-- convert accessdate value to Unix timestamp 
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which which tonumber() may not understand
		access_ts = tonumber (access_ts) or lang_object:parseFormattedNumber (access_ts);		-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to Unix time stamp
	end

	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end


--[[--------------------------&lt; I S _ V A L I D _ E M B A R G O _ D A T E &gt;------------------------------------

returns true and date value if that value has proper dmy, mdy, ymd format.

returns false and 9999 (embargoed forever) when date value is not proper format; assumes that when |pmc-embargo-date= is
set, the editor intended to embargo a PMC but |pmc-embargo-date= does not hold a single date.

]]

local function is_valid_embargo_date (v)
	if v:match ('^%d%d%d%d%-%d%d%-%d%d$') or									-- ymd
		v:match ('^%d%d?%s+%a+%s+%d%d%d%d$') or									-- dmy
		v:match ('^%a+%s+%d%d?%s*,%s*%d%d%d%d$') then							-- mdy
			return true, v;
	end
	return false, '9999';														-- if here not good date so return false and set embargo date to long time in future
end


--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct.
If not a valid month, returns 0

]]

local function get_month_number (month)
	return cfg.date_names['local'].long[month] or cfg.date_names['local'].short[month] or	-- look for local names first
			cfg.date_names['en'].long[month] or	cfg.date_names['en'].short[month] or		-- failing that, look for English names
			0;																				-- not a recognized month name
end


--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 21 for Spring, etc.  Capitalization and spelling
must be correct. If not a valid season, returns 0.
	21-24 = Spring, Summer, Autumn, Winter, independent of “Hemisphere”

returns 0 when &lt;param&gt; is not |date=

Season numbering is defined by Extended Date/Time Format (EDTF) specification (https://www.loc.gov/standards/datetime/)
which became part of ISO 8601 in 2019.  See '§Sub-year groupings'.  The standard defines various divisions using
numbers 21-41.  cs1|2 only supports generic seasons.  EDTF does support the distinction between north and south
hemisphere seasons but cs1|2 has no way to make that distinction.

These additional divisions not currently supported:
	25-28 = Spring - Northern Hemisphere, Summer- Northern Hemisphere, Autumn - Northern Hemisphere, Winter - Northern Hemisphere
	29-32 = Spring – Southern Hemisphere, Summer– Southern Hemisphere, Autumn – Southern Hemisphere, Winter - Southern Hemisphere
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)

]]

local function get_season_number (season, param)
	if 'date' ~= param then
		return 0;																-- season dates only supported by |date=
	end
	return cfg.date_names['local'].season[season] or							-- look for local names first
			cfg.date_names['en'].season[season] or								-- failing that, look for English names
			0;																	-- not a recognized season name
end


--[[--------------------------&lt; G E T _ Q U A R T E R _ N U M B E R &gt;------------------------------------------

returns a number according to the sequence of quarters in a year: 33 for first quarter, etc.  Capitalization and spelling
must be correct. If not a valid quarter, returns 0.
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)

returns 0 when &lt;param&gt; is not |date=

Quarter numbering is defined by Extended Date/Time Format (EDTF) specification (https://www.loc.gov/standards/datetime/)
which became part of ISO 8601 in 2019.  See '§Sub-year groupings'.  The standard defines various divisions using
numbers 21-41.  cs1|2 only supports generic seasons and quarters.

These additional divisions not currently supported:
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)

]]

local function get_quarter_number (quarter, param)
	if 'date' ~= param then
		return 0;																-- quarter dates only supported by |date=
	end
	quarter = mw.ustring.gsub (quarter, ' +', ' ');								-- special case replace multiple space chars with a single space char
	return cfg.date_names['local'].quarter[quarter] or							-- look for local names first
			cfg.date_names['en'].quarter[quarter] or							-- failing that, look for English names
			0;																	-- not a recognized quarter name
end


--[[--------------------------&lt; G E T _ P R O P E R _ N A M E _ N U M B E R &gt;----------------------------------

returns a non-zero number if date contains a recognized proper-name.  Capitalization and spelling must be correct.

returns 0 when &lt;param&gt; is not |date=

]]

local function get_proper_name_number (name, param)
	if 'date' ~= param then
		return 0;																-- proper-name dates only supported by |date=
	end
	return cfg.date_names['local'].named[name] or								-- look for local names dates first
			cfg.date_names['en'].named[name] or									-- failing that, look for English names
			0;																	-- not a recognized named date
end


--[[--------------------------&lt; G E T _ E L E M E N T _ N U M B E R &lt;------------------------------------------

returns true if month or season or quarter or proper name is valid (properly spelled, capitalized, abbreviated)

]]

local function get_element_number (element, param)
	local num;
	
	local funcs = {get_month_number, get_season_number, get_quarter_number, get_proper_name_number};	-- list of functions to execute in order
	
	for _, func in ipairs (funcs) do											-- spin through the function list
		num = func (element, param);											-- call the function and get the returned number
		if 0 ~= num then														-- non-zero when valid month season quarter 
			return num;															-- return that number
		end
	end
	return nil;																	-- not valid
end


--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one
year in the future are not acceptable.

]]

local function is_valid_year (year)
	if not is_set(year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;									-- global variable so we only have to fetch it once
	end

	year = tonumber (year) or lang_object:parseFormattedNumber (year);			-- convert to numbers for the comparison;
	return year and (year &lt;= year_limit) or false;
end


--[[--------------------------&lt; I S _ V A L I D _ D A T E &gt;----------------------------------------------------

Returns true if day is less than or equal to the number of days in month and year is no farther into the future
than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap
years before 1582 and Gregorian leap years after 1582. Where the two calendars overlap (1582 to approximately
1923) dates are assumed to be Gregorian.

]]

local function is_valid_date (year, month, day)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year(year) then												-- no farther into the future than next year
		return false;
	end
	
	month = tonumber(month);													-- required for YYYY-MM-DD dates
	
	if (2 == month) then														-- if February
		month_length = 28;														-- then 28 days unless
		if 1582 &gt; tonumber(year) then											-- Julian calendar
			if 0 == (year%4) then												-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		else																	-- Gregorian calendar
			if (0 == (year%4) and (0 ~= (year%100) or 0 == (year%400))) then	-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		end
	else
		month_length = days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
There is a special test for May because it can be either short or long form.

Returns true when style for both months is the same

]]

local function is_valid_month_range_style (month1, month2)
local len1 = month1:len();
local len2 = month2:len();
	if len1 == len2 then
		return true;															-- both months are short form so return true
	elseif 'May' == month1 or 'May'== month2 then -- ToDo: I18N
		return true;															-- both months are long form so return true
	elseif 3 == len1 or 3 == len2 then
		return false;															-- months are mixed form so return false
	else
		return true;															-- both months are long form so return true
	end
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

All season ranges are accepted as valid because there are publishers out there who have published a Summer–Spring YYYY issue, hence treat as ok

]]

local function is_valid_month_season_range(range_start, range_end, param)
	local range_start_number = get_month_number (range_start);
	local range_end_number;

	if 0 == range_start_number then												-- is this a month range?
		range_start_number = get_season_number (range_start, param);			-- not a month; is it a season? get start season number
		range_end_number = get_season_number (range_end, param);				-- get end season number

		if (0 ~= range_start_number) and (0 ~= range_end_number) and (range_start_number ~= range_end_number) then
			return true;														-- any season pairing is accepted except when both are the same
		end
		return false;															-- range_start and/or range_end is not a season
	end
																				-- here when range_start is a month
	range_end_number = get_month_number (range_end);							-- get end month number
	if range_start_number &lt; range_end_number and								-- range_start is a month; does range_start precede range_end?
		is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
	end
	return false;																-- range_start month number is greater than or equal to range end number; or range end isn't a month
end


--[[--------------------------&lt; M A K E _ C O I N S _ D A T E &gt;------------------------------------------------

This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1.  The function is called only for |date= parameters and only if the |date=&lt;value&gt; is 
determined to be a valid date format.  The question of what to do with invalid date formats is not answered here.

The date parts in the input table are converted to an ISO 8601 conforming date string:
	single whole dates:		yyyy-mm-dd
	month and year dates:	yyyy-mm
	year dates:				yyyy
	ranges:					yyyy-mm-dd/yyyy-mm-dd
							yyyy-mm/yyyy-mm
							yyyy/yyyy

Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.

The input table has:
	year, year2 – always present; if before 1582, ignore months and days if present
	month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 99 Christmas
	day, day2 –  0 if not provided, 1-31 for days
	
the output table receives:
	rftdate:	an ISO 8601 formatted date
	rftchron:	a free-form version of the date, usually without year which is in rftdate (season ranges and proper-name dates)
	rftssn:		one of four season keywords: winter, spring, summer, fall (lowercase)
	rftquarter:	one of four values: 1, 2, 3, 4

]]

local function make_COinS_date (input, tCOinS_date)
	local date;																	-- one date or first date in a range
	local date2 = '';															-- end of range date
-- start temporary Julian / Gregorian calendar uncertainty detection
	local year = tonumber(input.year);											-- this temporary code to determine the extent of sources dated to the Julian/Gregorian
	local month = tonumber(input.month);										-- interstice 1 October 1582 – 1 January 1926
	local day = tonumber (input.day);
	if (0 ~= day) and															-- day must have a value for this to be a whole date
		(((1582 == year) and (10 &lt;= month) and (12 &gt;= month)) or				-- any whole 1582 date from 1 October to 31 December or
			((1926 == year) and (1 == month) and (1 == input.day)) or			-- 1 January 1926 or
				((1582 &lt; year) and (1925 &gt;= year))) then						-- any date 1 January 1583 – 31 December 1925
					tCOinS_date.inter_cal_cat = true;							-- set category flag true
	end
-- end temporary Julian / Gregorian calendar uncertainty detection
	
	if 1582 &gt; tonumber(input.year) or 20 &lt; tonumber(input.month) then			-- Julian calendar or season so &amp;rft.date gets year only
		date = input.year;
		if 0 ~= input.year2 and input.year ~= input.year2 then					-- if a range, only the second year portion when not the same as range start year
			date = string.format ('%.4d/%.4d', tonumber(input.year), tonumber(input.year2))		-- assemble the date range
		end
		if 20 &lt; tonumber(input.month) then										-- if season or proper-name date
			local season = {[24] = 'winter', [21] = 'spring', [22] = 'summer', [23] = 'fall', [33] = '1', [34] = '2', [35] = '3', [36] = '4', [98] = 'Easter', [99] = 'Christmas'};	-- seasons lowercase, no autumn; proper-names use title case
			if 0 == input.month2 then											-- single season date
				if 40 &lt; tonumber(input.month) then
					tCOinS_date.rftchron = season[input.month];					-- proper-name dates
				elseif 30 &lt; tonumber(input.month) then
					tCOinS_date.rftquarter = season[input.month];				-- quarters
				else
					tCOinS_date.rftssn = season[input.month];					-- seasons
				end
			else																-- season range with a second season specified
				if input.year ~= input.year2 then								-- season year – season year range or season year–year
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					if 0~= input.month2 then
						tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);
					end
				else															-- season–season year range
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2];	-- season–season year range
				end
			end
		end
		tCOinS_date.rftdate = date;
		return;																	-- done
	end
	
	if 0 ~= input.day then
		date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day));	-- whole date
	elseif 0 ~= input.month then
		date = string.format ('%s-%.2d', input.year, tonumber(input.month));	-- year and month
	else
		date = string.format ('%s', input.year);								-- just year
	end

	if 0 ~= input.year2 then
		if 0 ~= input.day2 then
			date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2));		-- whole date
		elseif 0 ~= input.month2 then
			date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2));	-- year and month
		else
			date2 = string.format ('/%s', input.year2);							-- just year
		end
	end
	
	tCOinS_date.rftdate = date .. date2;										-- date2 has the '/' separator
	return;
end


--[[--------------------------&lt; P A T T E R N S &gt;--------------------------------------------------------------

this is the list of patterns for date formats that this module recognizes.  Approximately the first half of these
patterns represent formats that might be reformatted into another format.  Those that might be reformatted have
'indicator' letters that identify the content of the matching capture: 'd' (day), 'm' (month), 'a' (anchor year),
'y' (year); second day, month, year have a '2' suffix.

These patterns are used for both date validation and for reformatting.  This table should not be moved to ~/Configuration
because changes to this table require changes to check_date() and to reformatter() and reformat_date()

]]

local patterns = {
	 																			-- year-initial numerical year-month-day
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'},					
																				-- month-initial: month day, year
	['Mdy'] = {'^(%D-) +([1-9]%d?), +((%d%d%d%d?)%a?)$', 'm', 'd', 'a', 'y'},
																				-- month-initial day range: month day–day, year; days are separated by endash
	['Md-dy'] = {'^(%D-) +([1-9]%d?)[%-–]([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'd2', 'a', 'y'},
																				-- day-initial: day month year
	['dMy'] = {'^([1-9]%d?) +(%D-) +((%d%d%d%d?)%a?)$', 'd', 'm', 'a', 'y'},
																				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed; not supported at en.wiki
	--	['yMd'] = {'^((%d%d%d%d?)%a?) +(%D-) +(%d%d?)$', 'a', 'y', 'm', 'd'},
																				-- day-range-initial: day–day month year; days are separated by endash
	['d-dMy'] = {'^([1-9]%d?)[%-–]([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'd2', 'm', 'a', 'y'},
																				-- day initial month-day-range: day month - day month year; uses spaced endash
	['dM-dMy'] = {'^([1-9]%d?) +(%D-) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'd2', 'm2', 'a', 'y'},
																				-- month initial month-day-range: month day – month day, year;  uses spaced endash
	['Md-Mdy'] = {'^(%D-) +([1-9]%d?) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$','m', 'd', 'm2', 'd2', 'a', 'y'},
																				-- day initial month-day-year-range: day month year - day month year; uses spaced endash
	['dMy-dMy'] = {'^([1-9]%d?) +(%D-) +(%d%d%d%d) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'y', 'd2', 'm2', 'a', 'y2'},
																				-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
	['Mdy-Mdy'] = {'^(%D-) +([1-9]%d?), +(%d%d%d%d) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'y', 'm2', 'd2', 'a', 'y2'},

																				-- these date formats cannot be converted, per se, but month name can be rendered short or long
																				-- month/season year - month/season year; separated by spaced endash
	['My-My'] = {'^(%D-) +(%d%d%d%d) +[%-–] +(%D-) +((%d%d%d%d)%a?)$', 'm', 'y', 'm2', 'a', 'y2'},
																				-- month/season range year; months separated by endash
	['M-My'] = {'^(%D-)[%-–](%D-) +((%d%d%d%d)%a?)$', 'm', 'm2', 'a', 'y'},
																				-- month/season year or proper-name year; quarter year when First Quarter YYYY etc.
	['My'] = {'^([^%d–]-) +((%d%d%d%d)%a?)$', 'm', 'a', 'y'},					-- this way because endash is a member of %D; %D- will match January–March 2019 when it shouldn't

																				-- these date formats cannot be converted
	['Sy4-y2'] = {'^(%D-) +((%d%d)%d%d)[%-–]((%d%d)%a?)$'},						-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
	['Sy-y'] = {'^(%D-) +(%d%d%d%d)[%-–]((%d%d%d%d)%a?)$'},						-- special case Winter/Summer year-year; year separated with unspaced endash
	['y-y'] = {'^(%d%d%d%d?)[%-–]((%d%d%d%d?)%a?)$'},							-- year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
	['y4-y2'] = {'^((%d%d)%d%d)[%-–]((%d%d)%a?)$'},								-- year range: YYYY–YY; separated by unspaced endash
	['ymx'] = {'^(%d%d%d%d)%-(%d%d)%-XX$', 'y', 'm'},							-- edtf year-initial numerical year-month-XX
	['y'] = {'^((%d%d%d%d?)%a?)$'},												-- year; here accept either YYY or YYYY
	}


--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only
allowed range separator is endash.  Additionally, check the date to see that it is a real date: no 31 in 30-day
months; no 29 February when not a leap year.  Months, both long-form and three character abbreviations, and seasons
must be spelled correctly.  Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and
COinS_date.  When this happens, the date parameter is (DEBUG: not?) used in the COinS metadata and the CITEREF identifier gets
its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, publication-date, access-date, pmc-embargo-date, archive-date, lay-date)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is ISO 8601 format date; see make_COInS_date()

]]

local function check_date (date_string, param, tCOinS_date)
	local year;																	-- assume that year2, months, and days are not used;
	local year2 = 0;															-- second year in a year range
	local month = 0;
	local month2 = 0;															-- second month in a month range
	local day = 0;
	local day2 = 0;																-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match (patterns['ymd'][1]) then								-- year-initial numerical year month day format
		year, month, day = date_string:match (patterns['ymd'][1]);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or 0 == tonumber(day) then return false; end	-- month or day number not valid or not Gregorian calendar
		anchor_year = year;
	
	elseif date_string:match (patterns['ymx'][1]) then							-- year-initial numerical year month edtf format
		year, month = date_string:match (patterns['ymx'][1]);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or not is_valid_year(year) then return false; end	-- month number not valid or not Gregorian calendar or future year
		anchor_year = year;

	elseif mw.ustring.match(date_string, patterns['Mdy'][1]) then				-- month-initial: month day, year
		month, day, anchor_year, year = mw.ustring.match(date_string, patterns['Mdy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
				
	elseif mw.ustring.match(date_string, patterns['Md-dy'][1]) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year = mw.ustring.match(date_string, patterns['Md-dy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2=month;															-- for metadata
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['dMy'][1]) then				-- day-initial: day month year
		day, month, anchor_year, year = mw.ustring.match(date_string, patterns['dMy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months

--[[ NOT supported at en.wiki
	elseif mw.ustring.match(date_string, patterns['yMd'][1]) then				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed
		anchor_year, year, month, day = mw.ustring.match(date_string, patterns['yMd'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
-- end NOT supported at en.wiki ]]

	elseif mw.ustring.match(date_string, patterns['d-dMy'][1]) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year = mw.ustring.match(date_string, patterns['d-dMy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2 = month;															-- for metadata
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['dM-dMy'][1]) then			-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year = mw.ustring.match(date_string, patterns['dM-dMy'][1]);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['Md-Mdy'][1]) then			-- month initial month-day-range: month day – month day, year; uses spaced endash
		month, day, month2, day2, anchor_year, year = mw.ustring.match(date_string, patterns['Md-Mdy'][1]);
		if (not is_valid_month_season_range(month, month2, param)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['dMy-dMy'][1]) then			-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2 = mw.ustring.match(date_string, patterns['dMy-dMy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		if 0 == month or 0 == month2 then return false; end						-- both must be valid

	elseif mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]) then			-- month initial month-day-year-range: month day, year – month day, year; uses spaced endash
		month, day, year, month2, day2, anchor_year, year2 = mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number(month2);
		if 0 == month or 0 == month2 then return false; end						-- both must be valid

	elseif mw.ustring.match(date_string, patterns['Sy4-y2'][1]) then			-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		local century;
		month, year, century, anchor_year, year2 = mw.ustring.match(date_string, patterns['Sy4-y2'][1]);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;		-- 'month' can only be Winter or Summer
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor_year from both years
		year2 = century..year2;													-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		month = get_season_number(month, param);

	elseif mw.ustring.match(date_string, patterns['Sy-y'][1]) then				-- special case Winter/Summer year-year; year separated with unspaced endash
		month, year, anchor_year, year2 = mw.ustring.match(date_string, patterns['Sy-y'][1]);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;		-- 'month' can only be Winter or Summer
		anchor_year = year .. '–' .. anchor_year;										-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		month = get_season_number (month, param);								-- for metadata

	elseif mw.ustring.match(date_string, patterns['My-My'][1]) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2 = mw.ustring.match(date_string, patterns['My-My'][1]);
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then 	-- both must be month year, same month style
			month = get_month_number(month);
			month2 = get_month_number(month2);
		elseif 0 ~= get_season_number(month, param) and 0 ~= get_season_number(month2, param) then	-- both must be season year, not mixed
			month = get_season_number(month, param);
			month2 = get_season_number(month2, param);
		else
			 return false;
		end

	elseif mw.ustring.match(date_string, patterns['M-My'][1]) then				-- month/season range year; months separated by endash 
		month, month2, anchor_year, year = mw.ustring.match(date_string, patterns['M-My'][1]);
		if (not is_valid_month_season_range(month, month2, param)) or (not is_valid_year(year)) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
			month2 = get_month_number(month2);
			if 0 == month or 0 == month2 then return false; end
		else
			month = get_season_number(month, param);
			month2 = get_season_number(month2, param);
		end
		year2 = year;
		
	elseif mw.ustring.match(date_string, patterns['My'][1]) then				-- month/season/quarter/proper-name year
		month, anchor_year, year = mw.ustring.match(date_string, patterns['My'][1]);
		if not is_valid_year(year) then return false; end
		month = get_element_number(month, param);								-- get month season quarter proper-name number or nil
		if not month then return false; end										-- not valid whatever it is

	elseif mw.ustring.match(date_string, patterns['y-y'][1]) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2 = mw.ustring.match(date_string, patterns['y-y'][1]);
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, patterns['y4-y2'][1]) then				-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2 = mw.ustring.match(date_string, patterns['y4-y2'][1]);
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor year from both years

		if in_array (param, {'date', 'publication-date', 'year'}) then
			add_prop_cat ('year_range_abbreviated');
		end

		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century .. year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, patterns['y'][1]) then					-- year; here accept either YYY or YYYY
		anchor_year, year = mw.ustring.match(date_string, patterns['y'][1]);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;															-- date format not one of the MOS:DATE approved formats
	end

	if 'access-date' == param then												-- test accessdate here because we have numerical date parts
		if 0 ~= year and 0 ~= month and 0 ~= day and 							-- all parts of a single date required
			0 == year2 and 0 == month2 and 0 == day2 then						-- none of these; accessdate must not be a range
				if not is_valid_accessdate(year .. '-' .. month .. '-' .. day) then	
					return false;												-- return false when accessdate out of bounds
				end
		else
			return false;														-- return false when accessdate is a range of two dates
		end
	end

	local result=true;															-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result = is_valid_date(year, month, day);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result = is_valid_date(year, month, day);
		result = result and is_valid_date(year, month, day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result = is_valid_date(year, month, day);
		result = result and is_valid_date(year, month2, day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result = is_valid_date(year, month, day);
		result = result and is_valid_date(year2, month2, day2);
	end
	
	if false == result then return false; end

	if nil ~= tCOinS_date then													-- this table only passed into this function when testing |date= parameter values
		make_COinS_date ({year = year, month = month, day = day, year2 = year2, month2 = month2, day2 = day2}, tCOinS_date);	-- make an ISO 8601 date string for COinS
	end
	
	return true, anchor_year;													-- format is good and date string represents a real date
end	


--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
parameters with errors are added to the &lt;error_list&gt; sequence table as the dates are tested.

]]

local function dates(date_parameters_list, tCOinS_date, error_list)
	local anchor_year;															-- will return as nil if the date being tested is not |date=
	local COinS_date;															-- will return as nil if the date being tested is not |date=
	local embargo_date;															-- if embargo date is a good dmy, mdy, ymd date then holds original value else reset to 9999
	local good_date = false;

	for k, v in pairs(date_parameters_list) do									-- for each date-holding parameter in the list
		if is_set(v.val) then													-- if the parameter has a value
			v.val = mw.ustring.gsub(v.val, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9
			if v.val:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then						-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v.val:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);				-- get the year portion so it can be tested
				if 'date' == k then
					anchor_year, COinS_date = v.val:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year' == k then
					good_date = is_valid_year(year);
				end
			elseif 'date' == k then												-- if the parameter is |date=
				if v.val:match(&quot;^n%.d%.%a?$&quot;) then -- ToDo: I18N								-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((n%.d%.)%a?)&quot;); -- ToDo: I18N	-- &quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v.val:match(&quot;^nd%a?$&quot;) then -- ToDo: I18N								-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((nd)%a?)&quot;); -- ToDo: I18N	-- &quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v.val, k, tCOinS_date);	-- go test the date
				end
			elseif 'year' == k then												-- if the parameter is |year= it should hold only a year value
				if v.val:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then						-- if |year = 3 or 4 digits only with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((%d+)%a?)&quot;);
				end
			elseif 'pmc-embargo-date' == k then											-- if the parameter is |pmc-embargo-date=
				good_date = check_date (v.val, k);								-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date, embargo_date = is_valid_embargo_date (v.val);	-- is |pmc-embargo-date= date a single dmy, mdy, or ymd formatted date? yes: returns embargo; no: returns 9999
				end
			else																-- any other date-holding parameter
				good_date = check_date (v.val, k);								-- go test the date
			end
			if false == good_date then											-- assemble one error message so we don't add the tracking category multiple times
				table.insert (error_list, wrap_style ('parameter', v.name));	-- make parameter name suitable for error message list
			end
		end
	end
	return anchor_year, embargo_date;											-- and done
end


--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function sets a local numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

the numernic value in &lt;result&gt; determines the 'output' if any from this function:
	0 – adds error message to error_list sequence table
	1 – adds maint cat
	2 – does nothing

]]

local function year_date_check (year_string, year_origin, date_string, date_origin, error_list)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes

	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where both date and year are required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard range formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif mw.ustring.match(date_string, &quot;%d%d%d%d[%-–]%d%d&quot;) then				-- YYYY-YY date ranges
		local century;
		date1, century, date2 = mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	else																		-- should never get here; this function called only when no other date errors
		result = 0;																-- no recognizable year in date
	end

	if 0 == result then															-- year / date mismatch
		table.insert (error_list, substitute (cfg.messages['mismatch'], {year_origin, date_origin}));	-- add error message to error_list sequence table
	elseif 1 == result then														-- redundant year / date
		set_message ('maint_date_year');										-- add a maint cat
	end
end


--[[--------------------------&lt; R E F O R M A T T E R &gt;--------------------------------------------------------

reformat 'date' into new format specified by format_param if pattern_idx (the current format of 'date') can be
reformatted.  Does the grunt work for reformat_dates().

The table re_formats maps pattern_idx (current format) and format_param (desired format) to a table that holds:
	format string used by string.format()
	identifier letters ('d', 'm', 'y', 'd2', 'm2', 'y2') that serve as indexes into a table t{} that holds captures
		from mw.ustring.match() for the various date parts specified by  patterns[pattern_idx][1]

Items in patterns{} have the general form:
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'}, where:
		['ymd'] is pattern_idx
		patterns['ymd'][1] is the match pattern with captures for mw.ustring.match()
		patterns['ymd'][2] is an indicator letter identifying the content of the first capture
		patterns['ymd'][3] ... the second capture etc.

when a pattern matches a date, the captures are loaded into table t{} in capture order using the idemtifier
characters as indexes into t{}  For the above, a ymd date is in t{} as:
	t.y = first capture (year), t.m = second capture (month), t.d = third capture (day)

To reformat, this function is called with the pattern_idx that matches the current format of the date and with
format_param set to the desired format.  This function loads table t{} as described and then calls string.format()
with the format string specified by re_format[pattern_idx][format_param][1] using values taken from t{} according
to the capture identifier letters specified by patterns[pattern_idx][format_param][n] where n is 2..

]]

local re_formats = {
	['ymd'] = {																	-- date format is ymd; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
	--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},								-- |df=yMd; not supported at en.wiki
		},
	['Mdy'] = {																	-- date format is Mdy; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- for long/short reformatting
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
	--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},								-- |df=yMd; not supported at en.wiki
		},
	['dMy'] = {																	-- date format is dMy; reformat to:
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- for long/short reformatting
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
	--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},								-- |df=yMd; not supported at en.wiki
		},
	['Md-dy'] = {																-- date format is Md-dy; reformat to:
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- for long/short reformatting
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- |df=dmy -&gt; d-dMy 
		},
	['d-dMy'] = {																-- date format is d-d&gt;y; reformat to:
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- for long/short reformatting
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- |df=mdy -&gt; Md-dy 
		},
	['dM-dMy'] = {																-- date format is dM-dMy; reformat to:
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- for long/short reformatting
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd', 'm2', 'd2', 'y'},				-- |df=mdy -&gt; Md-Mdy 
		},
	['Md-Mdy'] = {																-- date format is Md-Mdy; reformat to:
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd',  'm2', 'd2', 'y'},			-- for long/short reformatting
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- |df=dmy -&gt; dM-dMy 
		},
	['dMy-dMy'] = {																-- date format is dMy-dMy; reformat to:
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- for long/short reformatting
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- |df=mdy -&gt; Mdy-Mdy 
		},
	['Mdy-Mdy'] = {																-- date format is Mdy-Mdy; reformat to:
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- for long/short reformatting
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- |df=dmy -&gt; dMy-dMy 
		},
	['My-My'] = {																-- these for long/short reformatting
		['any'] = {'%s %s – %s %s', 'm', 'y', 'm2', 'y2'},						-- dmy/mdy agnostic
		},
	['M-My'] = {																-- these for long/short reformatting
		['any'] = {'%s–%s %s', 'm', 'm2', 'y'},									-- dmy/mdy agnostic
		},
	['My'] = {																	-- these for long/short reformatting
		['any'] = {'%s %s', 'm', 'y'},											-- dmy/mdy agnostic
		},
	--	['yMd'] = {																-- not supported at en.wiki
	--		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},								-- |df=mdy
	--		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},								-- |df=dmy
	--		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},								-- |df=ymd
	--		},
	}


local function reformatter (date, pattern_idx, format_param, mon_len)
	if not in_array (pattern_idx, {'ymd', 'Mdy', 'Md-dy', 'dMy', 'yMd', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- not in this set of date format patterns then not a reformattable date
	end
	
	if 'ymd' == format_param and in_array (pattern_idx, {'ymd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- ymd date ranges not supported at en.wiki; no point in reformatting ymd to ymd
	end

	if in_array (pattern_idx, {'My', 'M-My', 'My-My'}) then						-- these are not dmy/mdy so can't be 'reformatted' into either
		format_param = 'any';													-- so format-agnostic 
	end

																				-- yMd is not supported at en.wiki; if yMd is supported at your wiki, uncomment the next line
	--	if 'yMd' == format_param and in_array (pattern_idx, {'yMd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy'}) then	-- these formats not convertable; yMd not supported at en.wiki
	-- if yMd is supported at your wiki, remove or comment-out the next line
	if 'yMd' == format_param then												-- yMd not supported at en.wiki
		return;																	-- not a reformattable date
	end
	
	local c1, c2, c3, c4, c5, c6, c7;											-- these hold the captures specified in patterns[pattern_idx][1]
	c1, c2, c3, c4, c5, c6, c7 = mw.ustring.match (date, patterns[pattern_idx][1]);	-- get the captures

	local t = {																	-- table that holds k/v pairs of date parts from the captures and patterns[pattern_idx][2..]
		[patterns[pattern_idx][2]] = c1;										-- at minimum there is always one capture with a matching indicator letter
		[patterns[pattern_idx][3] or 'x'] = c2;									-- patterns can have a variable number of captures; each capture requires an indicator letter;
		[patterns[pattern_idx][4] or 'x'] = c3;									-- where there is no capture, there is no indicator letter so n in patterns[pattern_idx][n] will be nil;
		[patterns[pattern_idx][5] or 'x'] = c4;									-- the 'x' here spoofs an indicator letter to prevent 'table index is nil' error
		[patterns[pattern_idx][6] or 'x'] = c5;
		[patterns[pattern_idx][7] or 'x'] = c6;
		[patterns[pattern_idx][8] or 'x'] = c7;
		};

	if t.a then																	-- if this date has an anchor year capture
		t.y = t.a;																-- use the anchor year capture when reassembling the date
	end

	if tonumber(t.m) then														-- if raw month is a number (converting from ymd)
		if 's' == mon_len then													-- if we are to use abbreviated month names
			t.m = cfg.date_names['inv_local_s'][tonumber(t.m)];					-- convert it to a month name
		else
			t.m = cfg.date_names['inv_local_l'][tonumber(t.m)];					-- convert it to a month name
		end
		t.d = t.d:gsub ('0(%d)', '%1');											-- strip leading '0' from day if present
	elseif 'ymd' == format_param then											-- when converting to ymd
		t.y = t.y:gsub ('%a', '');												-- strip CITREF disambiguator if present; anchor year already known so process can proceed
		if 1582 &gt; tonumber (t.y) then											-- ymd format dates not allowed before 1582
			return;
		end
		t.m = string.format ('%02d', get_month_number (t.m));					-- make sure that month and day are two digits
		t.d = string.format ('%02d', t.d);
	elseif mon_len then															-- if mon_len is set to either 'short' or 'long'
		for _, mon in ipairs ({'m', 'm2'}) do									-- because there can be two month names, check both 
			if t[mon] then
				t[mon] = get_month_number (t[mon]);								-- get the month number for this month (is length agnostic)
				if 0 == t[mon] then return; end									-- seasons and named dates can't be converted
				t[mon] = (('s' == mon_len) and cfg.date_names['inv_local_s'][t[mon]]) or cfg.date_names['inv_local_l'][t[mon]];	-- fetch month name according to length
			end
		end
	end

	local new_date = string.format (re_formats[pattern_idx][format_param][1],	-- format string
		t[re_formats[pattern_idx][format_param][2]],							-- named captures from t{}
		t[re_formats[pattern_idx][format_param][3]],
		t[re_formats[pattern_idx][format_param][4]],
		t[re_formats[pattern_idx][format_param][5]],
		t[re_formats[pattern_idx][format_param][6]],
		t[re_formats[pattern_idx][format_param][7]],
		t[re_formats[pattern_idx][format_param][8]]
		);

	return new_date;
end


--[[-------------------------&lt; R E F O R M A T _ D A T E S &gt;--------------------------------------------------

Reformats existing dates into the format specified by format.

format is one of several manual keywords: dmy, dmy-all, mdy, mdy-all, ymd, ymd-all.  The -all version includes
access- and archive-dates; otherwise these dates are not reformatted.

This function allows automatic date formatting.  In ~/Configuration, the article source is searched for one of
the {{use xxx dates}} templates.  If found, xxx becomes the global date format as xxx-all.  If |cs1-dates= in
{{use xxx dates}} has legitimate value then that value determines how cs1|2 dates will be rendered.  Legitimate
values for |cs1-dates= are:
	l - all dates are rendered with long month names
	ls - publication dates use long month names; access-/archive-dates use abbreviated month names
	ly - publication dates use long month names; access-/archive-dates rendered in ymd format
	s - all dates are rendered with abbreviated (short) month names
	sy - publication dates use abbreviated month names; access-/archive-dates rendered in ymd format
	y - all dates are rendered in ymd format

the format argument for automatic date formatting will be the format specified by {{use xxx dates}} with the
value supplied by |cs1-dates so one of: xxx-l, xxx-ls, xxx-ly, xxx-s, xxx-sy, xxx-y, or simply xxx (|cs1-dates=
empty, omitted, or invalid) where xxx shall be either of dmy or mdy.

dates are extracted from date_parameters_list, reformatted (if appropriate), and then written back into the
list in the new format.  Dates in date_parameters_list are presumed here to be valid (no errors).  This function
returns true when a date has been reformatted, false else.  Actual reformatting is done by reformatter().

]]

local function reformat_dates (date_parameters_list, format)
	local all = false;															-- set to false to skip access- and archive-dates
	local len_p = 'l';															-- default publication date length shall be long
	local len_a = 'l';															-- default access-/archive-date length shall be long
	local result = false;
	local new_date;																
	
	if format:match('%a+%-all') then											-- manual df keyword; auto df keyword when length not specified in {{use xxx dates}}; 
		format = format:match('(%a+)%-all');									-- extract the format
		all = true;																-- all dates are long format dates because this keyword doesn't specify length
	elseif format:match('%a+%-[lsy][sy]?') then									-- auto df keywords; internal only
		all = true;																-- auto df applies to all dates; use length specified by capture len_p for all dates
		format, len_p, len_a = format:match('(%a+)%-([lsy])([sy]?)');			-- extract the format and length keywords
		if 'y' == len_p then													-- because allowed by MOS:DATEUNIFY (sort of) range dates and My dates not reformatted
			format = 'ymd';														-- override {{use xxx dates}}
		elseif (not is_set(len_a)) or (len_p == len_a) then						-- no access-/archive-date length specified or same length as publication dates then
			len_a = len_p;														-- in case len_a not set
		end
	end																			-- else only publication dates and they are long

	for param_name, param_val in pairs (date_parameters_list) do				-- for each date-holding parameter in the list
		if is_set (param_val.val) then											-- if the parameter has a value
			if not (not all and in_array (param_name, {'access-date', 'archive-date'})) then	-- skip access- or archive-date unless format is xxx-all; yeah, ugly; TODO: find a better way
				for pattern_idx, pattern in pairs (patterns) do
					if mw.ustring.match (param_val.val, pattern[1]) then
						if all and in_array (param_name, {'access-date', 'archive-date'}) then	-- if this date is an access- or archive-date
							new_date = reformatter (param_val.val, pattern_idx, (('y' == len_a) and 'ymd') or format, len_a);	-- choose ymd or dmy/mdy according to len_a setting
						else													-- all other dates
							new_date = reformatter (param_val.val, pattern_idx, format, len_p);
						end
						
						if new_date then										-- set when date was reformatted
							date_parameters_list[param_name].val = new_date;	-- update date in date list
							result = true;										-- and announce that changes have been made
						end
					end	-- if
				end		-- for
			end			-- if
		end				-- if
	end					-- for
return result;																	-- declare boolean result and done
end


--[[--------------------------&lt; D A T E _ H Y P H E N _ T O _ D A S H &gt;----------------------------------------

Loops through the list of date-holding parameters and converts any hyphen to an ndash.  Not called if the cs1|2
template has any date errors.

Modifies the date_parameters_list and returns true if hyphens are replaced, else returns false.

]]

local function date_hyphen_to_dash (date_parameters_list)
	local result = false;
	local n;
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set (param_val.val) and
			not mw.ustring.match (param_val.val, patterns.ymd[1]) then			-- for those that are not ymd dates (ustring because here digits may not be Western)
				param_val.val, n = param_val.val:gsub ('%-', '–');				-- replace any hyphen with ndash
				if 0 ~= n then
					date_parameters_list[param_name].val = param_val.val;		-- update the list
					result = true;
				end
		end
	end
	return result;																-- so we know if any hyphens were replaced
end


--[[--------------------------&lt; E D T F _ T R A N S F O R M &gt;--------------------------------------------------

Loops through the list of date-holding parameters and converts any EDTF formatted dates to MOS compliant dates.
Only YYY-MM-XX supported at this time. Not called if the cs1|2 template has any date errors.

must be done before reformat_dates() and before date_hyphen_to_dash()

Modifies the date_parameters_list and returns true if transformation is performed, else returns false.

]]

local function edtf_transform (date_parameters_list)
	local result = false;
	local source_date = {};

	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val.val) and param_val.val:match (patterns.ymx[1]) then	-- if parameter is set and is an EDTF dates
			source_date.year, source_date.month = param_val.val:match (patterns.ymx[1]);	-- get year and month number
			source_date.day = 1;												-- required by os.time()
			date_parameters_list[param_name].val = mw.text.trim (os.date ('%B %Y', os.time (source_date)));
			result = true;
		end
	end
	return result;																-- so we know if a transform was done
end


--[[-------------------------&lt; D A T E _ N A M E _ X L A T E &gt;------------------------------------------------

Attempts to translate English month names to local-language month names using names supplied by MediaWiki's
date parser function.  This is simple name-for-name replacement and may not work for all languages.

if xlat_dig is true, this function will also translate Western (English) digits to the local language's digits.
This will also translate ymd dates.

]]

local function date_name_xlate (date_parameters_list, xlt_dig)
	local xlate;
	local mode;																	-- long or short month names
	local modified = false;
	local date;
	
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val.val) then											-- if the parameter has a value
			date = param_val.val;
			for month in mw.ustring.gmatch (date, '%a+') do						-- iterate through all dates in the date (single date or date range)
				if cfg.date_names.en.long[month] then
					mode = 'F';													-- English name is long so use long local name
				elseif cfg.date_names.en.short[month] then
					mode = 'M';													-- English name is short so use short local name
				else
					mode = nil;													-- not an English month name; could be local language month name or an English season name
				end
		
				if mode then													-- might be a season
					xlate = lang_object:formatDate(mode, '1' .. month);			-- translate the month name to this local language
					date = mw.ustring.gsub (date, month, xlate);				-- replace the English with the translation
					date_parameters_list[param_name].val = date;				-- save the translated date
					modified = true;
				end
			end

			if xlt_dig then														-- shall we also translate digits?
				date = date:gsub ('%d', cfg.date_names.xlate_digits);			-- translate digits from Western to 'local digits'
				date_parameters_list[param_name].val = date;					-- save the translated date
				modified = true;
			end
		end
	end
	
	return modified;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	add_prop_cat = utilities_page_ptr.add_prop_cat ;							-- import functions from selected Module:Citation/CS1/Utilities module
	is_set = utilities_page_ptr.is_set;
	in_array = utilities_page_ptr.in_array;
	set_message = utilities_page_ptr.set_message;
	substitute = utilities_page_ptr.substitute;
	wrap_style = utilities_page_ptr.wrap_style;

	cfg = cfg_table_ptr;														-- import tables from selected Module:Citation/CS1/Configuration
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {																		-- return exported functions
	dates = dates,
	year_date_check = year_date_check,
	reformat_dates = reformat_dates,
	date_hyphen_to_dash = date_hyphen_to_dash,
	date_name_xlate = date_name_xlate,
	edtf_transform = edtf_transform,
	set_selected_modules = set_selected_modules
	}</text>
      <sha1>0e3bmc1trazjro3cqbxt2glpi4mw6un</sha1>
    </revision>
    <revision>
      <id>4853</id>
      <parentid>4852</parentid>
      <timestamp>2022-01-22T14:11:21Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>update per [[Wikipedia:Village_pump_(proposals)#rfc:_shall_we_update_cs1/2?|RfC]];</comment>
      <origin>4853</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="62466" sha1="njr3fclpibq75fkfvzi1njmy7dj4693" xml:space="preserve">--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local add_prop_cat, is_set, in_array, set_message, substitute, wrap_style;		-- imported functions from selected Module:Citation/CS1/Utilities
local cfg;																		-- table of tables imported from selected Module:Citation/CS1/Configuration


--[[--------------------------&lt; F I L E - S C O P E   D E C L A R A T I O N S &gt;--------------------------------

File-scope variables are declared here

]]

local lang_object = mw.getContentLanguage();									-- used by is_valid_accessdate(), is_valid_year(), date_name_xlate(); TODO: move to ~/Configuration?
local year_limit;																-- used by is_valid_year()


--[=[-------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |access-date= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-English date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate().  To get around that
call this function with YYYY-MM-DD format dates.

]=]

local function is_valid_accessdate (accessdate)
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold Unix time stamps representing the dates

	good1, access_ts = pcall (lang_object.formatDate, lang_object, 'U', accessdate );			-- convert accessdate value to Unix timestamp 
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which which tonumber() may not understand
		access_ts = tonumber (access_ts) or lang_object:parseFormattedNumber (access_ts);		-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to Unix time stamp
	end

	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end


--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct.
If not a valid month, returns 0

]]

local function get_month_number (month)
	return cfg.date_names['local'].long[month] or cfg.date_names['local'].short[month] or	-- look for local names first
			cfg.date_names['en'].long[month] or	cfg.date_names['en'].short[month] or		-- failing that, look for English names
			0;																				-- not a recognized month name
end


--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 21 for Spring, etc.  Capitalization and spelling
must be correct. If not a valid season, returns 0.
	21-24 = Spring, Summer, Autumn, Winter, independent of “Hemisphere”

returns 0 when &lt;param&gt; is not |date=

Season numbering is defined by Extended Date/Time Format (EDTF) specification (https://www.loc.gov/standards/datetime/)
which became part of ISO 8601 in 2019.  See '§Sub-year groupings'.  The standard defines various divisions using
numbers 21-41.  cs1|2 only supports generic seasons.  EDTF does support the distinction between north and south
hemisphere seasons but cs1|2 has no way to make that distinction.

These additional divisions not currently supported:
	25-28 = Spring - Northern Hemisphere, Summer- Northern Hemisphere, Autumn - Northern Hemisphere, Winter - Northern Hemisphere
	29-32 = Spring – Southern Hemisphere, Summer– Southern Hemisphere, Autumn – Southern Hemisphere, Winter - Southern Hemisphere
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)

]]

local function get_season_number (season, param)
	if 'date' ~= param then
		return 0;																-- season dates only supported by |date=
	end
	return cfg.date_names['local'].season[season] or							-- look for local names first
			cfg.date_names['en'].season[season] or								-- failing that, look for English names
			0;																	-- not a recognized season name
end


--[[--------------------------&lt; G E T _ Q U A R T E R _ N U M B E R &gt;------------------------------------------

returns a number according to the sequence of quarters in a year: 33 for first quarter, etc.  Capitalization and spelling
must be correct. If not a valid quarter, returns 0.
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)

returns 0 when &lt;param&gt; is not |date=

Quarter numbering is defined by Extended Date/Time Format (EDTF) specification (https://www.loc.gov/standards/datetime/)
which became part of ISO 8601 in 2019.  See '§Sub-year groupings'.  The standard defines various divisions using
numbers 21-41.  cs1|2 only supports generic seasons and quarters.

These additional divisions not currently supported:
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)

]]

local function get_quarter_number (quarter, param)
	if 'date' ~= param then
		return 0;																-- quarter dates only supported by |date=
	end
	quarter = mw.ustring.gsub (quarter, ' +', ' ');								-- special case replace multiple space chars with a single space char
	return cfg.date_names['local'].quarter[quarter] or							-- look for local names first
			cfg.date_names['en'].quarter[quarter] or							-- failing that, look for English names
			0;																	-- not a recognized quarter name
end


--[[--------------------------&lt; G E T _ P R O P E R _ N A M E _ N U M B E R &gt;----------------------------------

returns a non-zero number if date contains a recognized proper-name.  Capitalization and spelling must be correct.

returns 0 when &lt;param&gt; is not |date=

]]

local function get_proper_name_number (name, param)
	if 'date' ~= param then
		return 0;																-- proper-name dates only supported by |date=
	end
	return cfg.date_names['local'].named[name] or								-- look for local names dates first
			cfg.date_names['en'].named[name] or									-- failing that, look for English names
			0;																	-- not a recognized named date
end


--[[--------------------------&lt; G E T _ E L E M E N T _ N U M B E R &lt;------------------------------------------

returns true if month or season or quarter or proper name is valid (properly spelled, capitalized, abbreviated)

]]

local function get_element_number (element, param)
	local num;
	
	local funcs = {get_month_number, get_season_number, get_quarter_number, get_proper_name_number};	-- list of functions to execute in order
	
	for _, func in ipairs (funcs) do											-- spin through the function list
		num = func (element, param);											-- call the function and get the returned number
		if 0 ~= num then														-- non-zero when valid month season quarter 
			return num;															-- return that number
		end
	end
	return nil;																	-- not valid
end


--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one
year in the future are not acceptable.

Special case for |pmc-embargo-date=: years more than two years in the future are not acceptable

]]

local function is_valid_year (year, param)
	if not is_set (year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;									-- global variable so we only have to fetch it once
	end

	year = tonumber (year) or lang_object:parseFormattedNumber (year);			-- convert to number for the comparison;
	
	if 'pmc-embargo-date' == param then											-- special case for |pmc-embargo-date=
		return year and (year &lt;= tonumber(os.date(&quot;%Y&quot;))+2) or false;			-- years more than two years in the future are not accepted
	end	
	return year and (year &lt;= year_limit) or false;
end


--[[--------------------------&lt; I S _ V A L I D _ D A T E &gt;----------------------------------------------------

Returns true if day is less than or equal to the number of days in month and year is no farther into the future
than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap
years before 1582 and Gregorian leap years after 1582. Where the two calendars overlap (1582 to approximately
1923) dates are assumed to be Gregorian.

]]

local function is_valid_date (year, month, day, param)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year (year, param) then										-- no farther into the future than next year except |pmc-embargo-date= no more than two years in the future
		return false;
	end
	
	month = tonumber (month);													-- required for YYYY-MM-DD dates
	
	if (2 == month) then														-- if February
		month_length = 28;														-- then 28 days unless
		if 1582 &gt; tonumber(year) then											-- Julian calendar
			if 0 == (year%4) then												-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		else																	-- Gregorian calendar
			if (0 == (year%4) and (0 ~= (year%100) or 0 == (year%400))) then	-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		end
	else
		month_length = days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
This function looks in cfg.date_names{} to see if both month names are listed in the long subtable or both are
listed in the short subtable.  When both have the same style (both are listed in the same table), returns true; false else

]]

local function is_valid_month_range_style (month1, month2)
	if (cfg.date_names.en.long[month1] and cfg.date_names.en.long[month2]) or					-- are both English names listed in the long subtable?
		(cfg.date_names.en.short[month1] and cfg.date_names.en.short[month2]) or				-- are both English names listed in the short subtable?
		(cfg.date_names['local'].long[month1] and cfg.date_names['local'].long[month2]) or		-- are both local names listed in the long subtable?
		(cfg.date_names['local'].short[month1] and cfg.date_names['local'].short[month2]) then	-- are both local names listed in the short subtable?
			return true;
	end
	return false;																-- names are mixed
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

All season ranges are accepted as valid because there are publishers out there who have published a Summer–Spring YYYY issue, hence treat as ok

]]

local function is_valid_month_season_range(range_start, range_end, param)
	local range_start_number = get_month_number (range_start);
	local range_end_number;

	if 0 == range_start_number then												-- is this a month range?
		range_start_number = get_season_number (range_start, param);			-- not a month; is it a season? get start season number
		range_end_number = get_season_number (range_end, param);				-- get end season number

		if (0 ~= range_start_number) and (0 ~= range_end_number) and (range_start_number ~= range_end_number) then
			return true;														-- any season pairing is accepted except when both are the same
		end
		return false;															-- range_start and/or range_end is not a season
	end
																				-- here when range_start is a month
	range_end_number = get_month_number (range_end);							-- get end month number
	if range_start_number &lt; range_end_number and								-- range_start is a month; does range_start precede range_end?
		is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
	end
	return false;																-- range_start month number is greater than or equal to range end number; or range end isn't a month
end


--[[--------------------------&lt; M A K E _ C O I N S _ D A T E &gt;------------------------------------------------

This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1.  The function is called only for |date= parameters and only if the |date=&lt;value&gt; is 
determined to be a valid date format.  The question of what to do with invalid date formats is not answered here.

The date parts in the input table are converted to an ISO 8601 conforming date string:
	single whole dates:		yyyy-mm-dd
	month and year dates:	yyyy-mm
	year dates:				yyyy
	ranges:					yyyy-mm-dd/yyyy-mm-dd
							yyyy-mm/yyyy-mm
							yyyy/yyyy

Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.

The input table has:
	year, year2 – always present; if before 1582, ignore months and days if present
	month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 99 Christmas
	day, day2 –  0 if not provided, 1-31 for days
	
the output table receives:
	rftdate:	an ISO 8601 formatted date
	rftchron:	a free-form version of the date, usually without year which is in rftdate (season ranges and proper-name dates)
	rftssn:		one of four season keywords: winter, spring, summer, fall (lowercase)
	rftquarter:	one of four values: 1, 2, 3, 4

]]

local function make_COinS_date (input, tCOinS_date)
	local date;																	-- one date or first date in a range
	local date2 = '';															-- end of range date
-- start temporary Julian / Gregorian calendar uncertainty detection
	local year = tonumber(input.year);											-- this temporary code to determine the extent of sources dated to the Julian/Gregorian
	local month = tonumber(input.month);										-- interstice 1 October 1582 – 1 January 1926
	local day = tonumber (input.day);
	if (0 ~= day) and															-- day must have a value for this to be a whole date
		(((1582 == year) and (10 &lt;= month) and (12 &gt;= month)) or				-- any whole 1582 date from 1 October to 31 December or
			((1926 == year) and (1 == month) and (1 == input.day)) or			-- 1 January 1926 or
				((1582 &lt; year) and (1925 &gt;= year))) then						-- any date 1 January 1583 – 31 December 1925
					tCOinS_date.inter_cal_cat = true;							-- set category flag true
	end
-- end temporary Julian / Gregorian calendar uncertainty detection
	
	if 1582 &gt; tonumber(input.year) or 20 &lt; tonumber(input.month) then			-- Julian calendar or season so &amp;rft.date gets year only
		date = input.year;
		if 0 ~= input.year2 and input.year ~= input.year2 then					-- if a range, only the second year portion when not the same as range start year
			date = string.format ('%.4d/%.4d', tonumber(input.year), tonumber(input.year2))		-- assemble the date range
		end
		if 20 &lt; tonumber(input.month) then										-- if season or proper-name date
			local season = {[24] = 'winter', [21] = 'spring', [22] = 'summer', [23] = 'fall', [33] = '1', [34] = '2', [35] = '3', [36] = '4', [98] = 'Easter', [99] = 'Christmas'};	-- seasons lowercase, no autumn; proper-names use title case
			if 0 == input.month2 then											-- single season date
				if 40 &lt; tonumber(input.month) then
					tCOinS_date.rftchron = season[input.month];					-- proper-name dates
				elseif 30 &lt; tonumber(input.month) then
					tCOinS_date.rftquarter = season[input.month];				-- quarters
				else
					tCOinS_date.rftssn = season[input.month];					-- seasons
				end
			else																-- season range with a second season specified
				if input.year ~= input.year2 then								-- season year – season year range or season year–year
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					if 0~= input.month2 then
						tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);
					end
				else															-- season–season year range
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2];	-- season–season year range
				end
			end
		end
		tCOinS_date.rftdate = date;
		return;																	-- done
	end
	
	if 0 ~= input.day then
		date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day));	-- whole date
	elseif 0 ~= input.month then
		date = string.format ('%s-%.2d', input.year, tonumber(input.month));	-- year and month
	else
		date = string.format ('%s', input.year);								-- just year
	end

	if 0 ~= input.year2 then
		if 0 ~= input.day2 then
			date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2));		-- whole date
		elseif 0 ~= input.month2 then
			date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2));	-- year and month
		else
			date2 = string.format ('/%s', input.year2);							-- just year
		end
	end
	
	tCOinS_date.rftdate = date .. date2;										-- date2 has the '/' separator
	return;
end


--[[--------------------------&lt; P A T T E R N S &gt;--------------------------------------------------------------

this is the list of patterns for date formats that this module recognizes.  Approximately the first half of these
patterns represent formats that might be reformatted into another format.  Those that might be reformatted have
'indicator' letters that identify the content of the matching capture: 'd' (day), 'm' (month), 'a' (anchor year),
'y' (year); second day, month, year have a '2' suffix.

These patterns are used for both date validation and for reformatting.  This table should not be moved to ~/Configuration
because changes to this table require changes to check_date() and to reformatter() and reformat_date()

]]

local patterns = {
	 																			-- year-initial numerical year-month-day
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'},					
																				-- month-initial: month day, year
	['Mdy'] = {'^(%D-) +([1-9]%d?), +((%d%d%d%d?)%a?)$', 'm', 'd', 'a', 'y'},
																				-- month-initial day range: month day–day, year; days are separated by endash
	['Md-dy'] = {'^(%D-) +([1-9]%d?)[%-–]([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'd2', 'a', 'y'},
																				-- day-initial: day month year
	['dMy'] = {'^([1-9]%d?) +(%D-) +((%d%d%d%d?)%a?)$', 'd', 'm', 'a', 'y'},
																				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed; not supported at en.wiki
	--	['yMd'] = {'^((%d%d%d%d?)%a?) +(%D-) +(%d%d?)$', 'a', 'y', 'm', 'd'},
																				-- day-range-initial: day–day month year; days are separated by endash
	['d-dMy'] = {'^([1-9]%d?)[%-–]([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'd2', 'm', 'a', 'y'},
																				-- day initial month-day-range: day month - day month year; uses spaced endash
	['dM-dMy'] = {'^([1-9]%d?) +(%D-) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'd2', 'm2', 'a', 'y'},
																				-- month initial month-day-range: month day – month day, year;  uses spaced endash
	['Md-Mdy'] = {'^(%D-) +([1-9]%d?) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$','m', 'd', 'm2', 'd2', 'a', 'y'},
																				-- day initial month-day-year-range: day month year - day month year; uses spaced endash
	['dMy-dMy'] = {'^([1-9]%d?) +(%D-) +(%d%d%d%d) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'y', 'd2', 'm2', 'a', 'y2'},
																				-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
	['Mdy-Mdy'] = {'^(%D-) +([1-9]%d?), +(%d%d%d%d) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'y', 'm2', 'd2', 'a', 'y2'},

																				-- these date formats cannot be converted, per se, but month name can be rendered short or long
																				-- month/season year - month/season year; separated by spaced endash
	['My-My'] = {'^(%D-) +(%d%d%d%d) +[%-–] +(%D-) +((%d%d%d%d)%a?)$', 'm', 'y', 'm2', 'a', 'y2'},
																				-- month/season range year; months separated by endash
	['M-My'] = {'^(%D-)[%-–](%D-) +((%d%d%d%d)%a?)$', 'm', 'm2', 'a', 'y'},
																				-- month/season year or proper-name year; quarter year when First Quarter YYYY etc.
	['My'] = {'^([^%d–]-) +((%d%d%d%d)%a?)$', 'm', 'a', 'y'},					-- this way because endash is a member of %D; %D- will match January–March 2019 when it shouldn't

																				-- these date formats cannot be converted
	['Sy4-y2'] = {'^(%D-) +((%d%d)%d%d)[%-–]((%d%d)%a?)$'},						-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
	['Sy-y'] = {'^(%D-) +(%d%d%d%d)[%-–]((%d%d%d%d)%a?)$'},						-- special case Winter/Summer year-year; year separated with unspaced endash
	['y-y'] = {'^(%d%d%d%d?)[%-–]((%d%d%d%d?)%a?)$'},							-- year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
	['y4-y2'] = {'^((%d%d)%d%d)[%-–]((%d%d)%a?)$'},								-- year range: YYYY–YY; separated by unspaced endash
	['y'] = {'^((%d%d%d%d?)%a?)$'},												-- year; here accept either YYY or YYYY
	}


--[[--------------------------&lt; I S _ V A L I D _ E M B A R G O _ D A T E &gt;------------------------------------

returns true and date value if that value has proper dmy, mdy, ymd format.

returns false and 9999 (embargoed forever) when date value is not proper format; assumes that when |pmc-embargo-date= is
set, the editor intended to embargo a PMC but |pmc-embargo-date= does not hold a single date.

]]

local function is_valid_embargo_date (v)
	if v:match (patterns['ymd'][1]) or											-- ymd
		v:match (patterns['Mdy'][1]) or											-- dmy
		v:match (patterns['dMy'][1]) then										-- mdy
			return true, v;
	end
	return false, '9999';														-- if here not good date so return false and set embargo date to long time in future
end


--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only
allowed range separator is endash.  Additionally, check the date to see that it is a real date: no 31 in 30-day
months; no 29 February when not a leap year.  Months, both long-form and three character abbreviations, and seasons
must be spelled correctly.  Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and
COinS_date.  When this happens, the date parameter is (DEBUG: not?) used in the COinS metadata and the CITEREF identifier gets
its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, publication-date, access-date, pmc-embargo-date, archive-date, lay-date)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is ISO 8601 format date; see make_COInS_date()

]]

local function check_date (date_string, param, tCOinS_date)
	local year;																	-- assume that year2, months, and days are not used;
	local year2 = 0;															-- second year in a year range
	local month = 0;
	local month2 = 0;															-- second month in a month range
	local day = 0;
	local day2 = 0;																-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match (patterns['ymd'][1]) then								-- year-initial numerical year month day format
		year, month, day = date_string:match (patterns['ymd'][1]);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or 0 == tonumber(day) then return false; end	-- month or day number not valid or not Gregorian calendar
		anchor_year = year;
	
	elseif mw.ustring.match(date_string, patterns['Mdy'][1]) then				-- month-initial: month day, year
		month, day, anchor_year, year = mw.ustring.match(date_string, patterns['Mdy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
				
	elseif mw.ustring.match(date_string, patterns['Md-dy'][1]) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year = mw.ustring.match(date_string, patterns['Md-dy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2=month;															-- for metadata
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['dMy'][1]) then				-- day-initial: day month year
		day, month, anchor_year, year = mw.ustring.match(date_string, patterns['dMy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months

--[[ NOT supported at en.wiki
	elseif mw.ustring.match(date_string, patterns['yMd'][1]) then				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed
		anchor_year, year, month, day = mw.ustring.match(date_string, patterns['yMd'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
-- end NOT supported at en.wiki ]]

	elseif mw.ustring.match(date_string, patterns['d-dMy'][1]) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year = mw.ustring.match(date_string, patterns['d-dMy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2 = month;															-- for metadata
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['dM-dMy'][1]) then			-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year = mw.ustring.match(date_string, patterns['dM-dMy'][1]);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['Md-Mdy'][1]) then			-- month initial month-day-range: month day – month day, year; uses spaced endash
		month, day, month2, day2, anchor_year, year = mw.ustring.match(date_string, patterns['Md-Mdy'][1]);
		if (not is_valid_month_season_range(month, month2, param)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['dMy-dMy'][1]) then			-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2 = mw.ustring.match(date_string, patterns['dMy-dMy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		if 0 == month or 0 == month2 then return false; end						-- both must be valid

	elseif mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]) then			-- month initial month-day-year-range: month day, year – month day, year; uses spaced endash
		month, day, year, month2, day2, anchor_year, year2 = mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number(month2);
		if 0 == month or 0 == month2 then return false; end						-- both must be valid

	elseif mw.ustring.match(date_string, patterns['Sy4-y2'][1]) then			-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		local century;
		month, year, century, anchor_year, year2 = mw.ustring.match(date_string, patterns['Sy4-y2'][1]);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;		-- 'month' can only be Winter or Summer
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor_year from both years
		year2 = century..year2;													-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		month = get_season_number(month, param);

	elseif mw.ustring.match(date_string, patterns['Sy-y'][1]) then				-- special case Winter/Summer year-year; year separated with unspaced endash
		month, year, anchor_year, year2 = mw.ustring.match(date_string, patterns['Sy-y'][1]);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;		-- 'month' can only be Winter or Summer
		anchor_year = year .. '–' .. anchor_year;										-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		month = get_season_number (month, param);								-- for metadata

	elseif mw.ustring.match(date_string, patterns['My-My'][1]) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2 = mw.ustring.match(date_string, patterns['My-My'][1]);
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then 	-- both must be month year, same month style
			month = get_month_number(month);
			month2 = get_month_number(month2);
		elseif 0 ~= get_season_number(month, param) and 0 ~= get_season_number(month2, param) then	-- both must be season year, not mixed
			month = get_season_number(month, param);
			month2 = get_season_number(month2, param);
		else
			 return false;
		end

	elseif mw.ustring.match(date_string, patterns['M-My'][1]) then				-- month/season range year; months separated by endash 
		month, month2, anchor_year, year = mw.ustring.match(date_string, patterns['M-My'][1]);
		if (not is_valid_month_season_range(month, month2, param)) or (not is_valid_year(year)) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
			month2 = get_month_number(month2);
			if 0 == month or 0 == month2 then return false; end
		else
			month = get_season_number(month, param);
			month2 = get_season_number(month2, param);
		end
		year2 = year;
		
	elseif mw.ustring.match(date_string, patterns['My'][1]) then				-- month/season/quarter/proper-name year
		month, anchor_year, year = mw.ustring.match(date_string, patterns['My'][1]);
		if not is_valid_year(year) then return false; end
		month = get_element_number(month, param);								-- get month season quarter proper-name number or nil
		if not month then return false; end										-- not valid whatever it is

	elseif mw.ustring.match(date_string, patterns['y-y'][1]) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2 = mw.ustring.match(date_string, patterns['y-y'][1]);
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, patterns['y4-y2'][1]) then				-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2 = mw.ustring.match(date_string, patterns['y4-y2'][1]);
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor year from both years

		if in_array (param, {'date', 'publication-date', 'year'}) then
			add_prop_cat ('year-range-abbreviated');
		end

		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century .. year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, patterns['y'][1]) then					-- year; here accept either YYY or YYYY
		anchor_year, year = mw.ustring.match(date_string, patterns['y'][1]);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;															-- date format not one of the MOS:DATE approved formats
	end

	if 'access-date' == param then												-- test accessdate here because we have numerical date parts
		if 0 ~= year and 0 ~= month and 0 ~= day and 							-- all parts of a single date required
			0 == year2 and 0 == month2 and 0 == day2 then						-- none of these; accessdate must not be a range
				if not is_valid_accessdate(year .. '-' .. month .. '-' .. day) then	
					return false;												-- return false when accessdate out of bounds
				end
		else
			return false;														-- return false when accessdate is a range of two dates
		end
	end

	local result=true;															-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result = is_valid_date (year, month, day, param);						-- &lt;param&gt; for |pmc-embargo-date=

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result = is_valid_date (year, month, day);
		result = result and is_valid_date (year, month, day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result = is_valid_date (year, month, day);
		result = result and is_valid_date (year, month2, day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result = is_valid_date(year, month, day);
		result = result and is_valid_date(year2, month2, day2);
	end
	
	if false == result then return false; end

	if nil ~= tCOinS_date then													-- this table only passed into this function when testing |date= parameter values
		make_COinS_date ({year = year, month = month, day = day, year2 = year2, month2 = month2, day2 = day2}, tCOinS_date);	-- make an ISO 8601 date string for COinS
	end
	
	return true, anchor_year;													-- format is good and date string represents a real date
end	


--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
parameters with errors are added to the &lt;error_list&gt; sequence table as the dates are tested.

]]

local function dates(date_parameters_list, tCOinS_date, error_list)
	local anchor_year;															-- will return as nil if the date being tested is not |date=
	local COinS_date;															-- will return as nil if the date being tested is not |date=
	local embargo_date;															-- if embargo date is a good dmy, mdy, ymd date then holds original value else reset to 9999
	local good_date = false;

	for k, v in pairs(date_parameters_list) do									-- for each date-holding parameter in the list
		if is_set(v.val) then													-- if the parameter has a value
			v.val = mw.ustring.gsub(v.val, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9
			if v.val:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then						-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v.val:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);				-- get the year portion so it can be tested
				if 'date' == k then
					anchor_year, COinS_date = v.val:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year' == k then
					good_date = is_valid_year(year);
				end
			elseif 'date' == k then												-- if the parameter is |date=
				if v.val:match(&quot;^n%.d%.%a?$&quot;) then -- ToDo: I18N								-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((n%.d%.)%a?)&quot;); -- ToDo: I18N	-- &quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v.val:match(&quot;^nd%a?$&quot;) then -- ToDo: I18N								-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((nd)%a?)&quot;); -- ToDo: I18N	-- &quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v.val, k, tCOinS_date);	-- go test the date
				end
			elseif 'year' == k then												-- if the parameter is |year= it should hold only a year value
				if v.val:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then						-- if |year = 3 or 4 digits only with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((%d+)%a?)&quot;);
				end
			elseif 'pmc-embargo-date' == k then									-- if the parameter is |pmc-embargo-date=
				good_date = check_date (v.val, k);								-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date, embargo_date = is_valid_embargo_date (v.val);	-- is |pmc-embargo-date= date a single dmy, mdy, or ymd formatted date? yes: returns embargo date; no: returns 9999
				end
			else																-- any other date-holding parameter
				good_date = check_date (v.val, k);								-- go test the date
			end
			if false == good_date then											-- assemble one error message so we don't add the tracking category multiple times
				table.insert (error_list, wrap_style ('parameter', v.name));	-- make parameter name suitable for error message list
			end
		end
	end
	return anchor_year, embargo_date;											-- and done
end


--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function sets a local numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

the numeric value in &lt;result&gt; determines the 'output' if any from this function:
	0 – adds error message to error_list sequence table
	1 – adds maint cat
	2 – does nothing

]]

local function year_date_check (year_string, year_origin, date_string, date_origin, error_list)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes

	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where both date and year are required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard range formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif mw.ustring.match(date_string, &quot;%d%d%d%d[%-–]%d%d&quot;) then				-- YYYY-YY date ranges
		local century;
		date1, century, date2 = mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	else																		-- should never get here; this function called only when no other date errors
		result = 0;																-- no recognizable year in date
	end

	if 0 == result then															-- year / date mismatch
		table.insert (error_list, substitute (cfg.messages['mismatch'], {year_origin, date_origin}));	-- add error message to error_list sequence table
	elseif 1 == result then														-- redundant year / date
		set_message ('maint_date_year');										-- add a maint cat
	end
end


--[[--------------------------&lt; R E F O R M A T T E R &gt;--------------------------------------------------------

reformat 'date' into new format specified by format_param if pattern_idx (the current format of 'date') can be
reformatted.  Does the grunt work for reformat_dates().

The table re_formats maps pattern_idx (current format) and format_param (desired format) to a table that holds:
	format string used by string.format()
	identifier letters ('d', 'm', 'y', 'd2', 'm2', 'y2') that serve as indexes into a table t{} that holds captures
		from mw.ustring.match() for the various date parts specified by  patterns[pattern_idx][1]

Items in patterns{} have the general form:
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'}, where:
		['ymd'] is pattern_idx
		patterns['ymd'][1] is the match pattern with captures for mw.ustring.match()
		patterns['ymd'][2] is an indicator letter identifying the content of the first capture
		patterns['ymd'][3] ... the second capture etc.

when a pattern matches a date, the captures are loaded into table t{} in capture order using the idemtifier
characters as indexes into t{}  For the above, a ymd date is in t{} as:
	t.y = first capture (year), t.m = second capture (month), t.d = third capture (day)

To reformat, this function is called with the pattern_idx that matches the current format of the date and with
format_param set to the desired format.  This function loads table t{} as described and then calls string.format()
with the format string specified by re_format[pattern_idx][format_param][1] using values taken from t{} according
to the capture identifier letters specified by patterns[pattern_idx][format_param][n] where n is 2..

]]

local re_formats = {
	['ymd'] = {																	-- date format is ymd; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
	--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},								-- |df=yMd; not supported at en.wiki
		},
	['Mdy'] = {																	-- date format is Mdy; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- for long/short reformatting
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
	--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},								-- |df=yMd; not supported at en.wiki
		},
	['dMy'] = {																	-- date format is dMy; reformat to:
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- for long/short reformatting
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
	--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},								-- |df=yMd; not supported at en.wiki
		},
	['Md-dy'] = {																-- date format is Md-dy; reformat to:
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- for long/short reformatting
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- |df=dmy -&gt; d-dMy 
		},
	['d-dMy'] = {																-- date format is d-d&gt;y; reformat to:
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- for long/short reformatting
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- |df=mdy -&gt; Md-dy 
		},
	['dM-dMy'] = {																-- date format is dM-dMy; reformat to:
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- for long/short reformatting
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd', 'm2', 'd2', 'y'},				-- |df=mdy -&gt; Md-Mdy 
		},
	['Md-Mdy'] = {																-- date format is Md-Mdy; reformat to:
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd',  'm2', 'd2', 'y'},			-- for long/short reformatting
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- |df=dmy -&gt; dM-dMy 
		},
	['dMy-dMy'] = {																-- date format is dMy-dMy; reformat to:
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- for long/short reformatting
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- |df=mdy -&gt; Mdy-Mdy 
		},
	['Mdy-Mdy'] = {																-- date format is Mdy-Mdy; reformat to:
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- for long/short reformatting
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- |df=dmy -&gt; dMy-dMy 
		},
	['My-My'] = {																-- these for long/short reformatting
		['any'] = {'%s %s – %s %s', 'm', 'y', 'm2', 'y2'},						-- dmy/mdy agnostic
		},
	['M-My'] = {																-- these for long/short reformatting
		['any'] = {'%s–%s %s', 'm', 'm2', 'y'},									-- dmy/mdy agnostic
		},
	['My'] = {																	-- these for long/short reformatting
		['any'] = {'%s %s', 'm', 'y'},											-- dmy/mdy agnostic
		},
	--	['yMd'] = {																-- not supported at en.wiki
	--		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},								-- |df=mdy
	--		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},								-- |df=dmy
	--		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},								-- |df=ymd
	--		},
	}


local function reformatter (date, pattern_idx, format_param, mon_len)
	if not in_array (pattern_idx, {'ymd', 'Mdy', 'Md-dy', 'dMy', 'yMd', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- not in this set of date format patterns then not a reformattable date
	end
	
	if 'ymd' == format_param and in_array (pattern_idx, {'ymd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- ymd date ranges not supported at en.wiki; no point in reformatting ymd to ymd
	end

	if in_array (pattern_idx, {'My', 'M-My', 'My-My'}) then						-- these are not dmy/mdy so can't be 'reformatted' into either
		format_param = 'any';													-- so format-agnostic 
	end

																				-- yMd is not supported at en.wiki; when yMd is supported at your wiki, uncomment the next line
	--	if 'yMd' == format_param and in_array (pattern_idx, {'yMd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy'}) then	-- these formats not convertable; yMd not supported at en.wiki
	if 'yMd' == format_param then												-- yMd not supported at en.wiki; when yMd is supported at your wiki, remove or comment-out this line
		return;																	-- not a reformattable date
	end
	
	local c1, c2, c3, c4, c5, c6, c7;											-- these hold the captures specified in patterns[pattern_idx][1]
	c1, c2, c3, c4, c5, c6, c7 = mw.ustring.match (date, patterns[pattern_idx][1]);	-- get the captures

	local t = {																	-- table that holds k/v pairs of date parts from the captures and patterns[pattern_idx][2..]
		[patterns[pattern_idx][2]] = c1;										-- at minimum there is always one capture with a matching indicator letter
		[patterns[pattern_idx][3] or 'x'] = c2;									-- patterns can have a variable number of captures; each capture requires an indicator letter;
		[patterns[pattern_idx][4] or 'x'] = c3;									-- where there is no capture, there is no indicator letter so n in patterns[pattern_idx][n] will be nil;
		[patterns[pattern_idx][5] or 'x'] = c4;									-- the 'x' here spoofs an indicator letter to prevent 'table index is nil' error
		[patterns[pattern_idx][6] or 'x'] = c5;
		[patterns[pattern_idx][7] or 'x'] = c6;
		[patterns[pattern_idx][8] or 'x'] = c7;
		};

	if t.a then																	-- if this date has an anchor year capture
		t.y = t.a;																-- use the anchor year capture when reassembling the date
	end

	if tonumber(t.m) then														-- if raw month is a number (converting from ymd)
		if 's' == mon_len then													-- if we are to use abbreviated month names
			t.m = cfg.date_names['inv_local_s'][tonumber(t.m)];					-- convert it to a month name
		else
			t.m = cfg.date_names['inv_local_l'][tonumber(t.m)];					-- convert it to a month name
		end
		t.d = t.d:gsub ('0(%d)', '%1');											-- strip leading '0' from day if present
	elseif 'ymd' == format_param then											-- when converting to ymd
		t.y = t.y:gsub ('%a', '');												-- strip CITREF disambiguator if present; anchor year already known so process can proceed; TODO: maint message?
		if 1582 &gt; tonumber (t.y) then											-- ymd format dates not allowed before 1582
			return;
		end
		t.m = string.format ('%02d', get_month_number (t.m));					-- make sure that month and day are two digits
		t.d = string.format ('%02d', t.d);
	elseif mon_len then															-- if mon_len is set to either 'short' or 'long'
		for _, mon in ipairs ({'m', 'm2'}) do									-- because there can be two month names, check both 
			if t[mon] then
				t[mon] = get_month_number (t[mon]);								-- get the month number for this month (is length agnostic)
				if 0 == t[mon] then return; end									-- seasons and named dates can't be converted
				t[mon] = (('s' == mon_len) and cfg.date_names['inv_local_s'][t[mon]]) or cfg.date_names['inv_local_l'][t[mon]];	-- fetch month name according to length
			end
		end
	end

	local new_date = string.format (re_formats[pattern_idx][format_param][1],	-- format string
		t[re_formats[pattern_idx][format_param][2]],							-- named captures from t{}
		t[re_formats[pattern_idx][format_param][3]],
		t[re_formats[pattern_idx][format_param][4]],
		t[re_formats[pattern_idx][format_param][5]],
		t[re_formats[pattern_idx][format_param][6]],
		t[re_formats[pattern_idx][format_param][7]],
		t[re_formats[pattern_idx][format_param][8]]
		);

	return new_date;
end


--[[-------------------------&lt; R E F O R M A T _ D A T E S &gt;--------------------------------------------------

Reformats existing dates into the format specified by format.

format is one of several manual keywords: dmy, dmy-all, mdy, mdy-all, ymd, ymd-all.  The -all version includes
access- and archive-dates; otherwise these dates are not reformatted.

This function allows automatic date formatting.  In ~/Configuration, the article source is searched for one of
the {{use xxx dates}} templates.  If found, xxx becomes the global date format as xxx-all.  If |cs1-dates= in
{{use xxx dates}} has legitimate value then that value determines how cs1|2 dates will be rendered.  Legitimate
values for |cs1-dates= are:
	l - all dates are rendered with long month names
	ls - publication dates use long month names; access-/archive-dates use abbreviated month names
	ly - publication dates use long month names; access-/archive-dates rendered in ymd format
	s - all dates are rendered with abbreviated (short) month names
	sy - publication dates use abbreviated month names; access-/archive-dates rendered in ymd format
	y - all dates are rendered in ymd format

the format argument for automatic date formatting will be the format specified by {{use xxx dates}} with the
value supplied by |cs1-dates so one of: xxx-l, xxx-ls, xxx-ly, xxx-s, xxx-sy, xxx-y, or simply xxx (|cs1-dates=
empty, omitted, or invalid) where xxx shall be either of dmy or mdy.

dates are extracted from date_parameters_list, reformatted (if appropriate), and then written back into the
list in the new format.  Dates in date_parameters_list are presumed here to be valid (no errors).  This function
returns true when a date has been reformatted, false else.  Actual reformatting is done by reformatter().

]]

local function reformat_dates (date_parameters_list, format)
	local all = false;															-- set to false to skip access- and archive-dates
	local len_p = 'l';															-- default publication date length shall be long
	local len_a = 'l';															-- default access-/archive-date length shall be long
	local result = false;
	local new_date;																
	
	if format:match('%a+%-all') then											-- manual df keyword; auto df keyword when length not specified in {{use xxx dates}}; 
		format = format:match('(%a+)%-all');									-- extract the format
		all = true;																-- all dates are long format dates because this keyword doesn't specify length
	elseif format:match('%a+%-[lsy][sy]?') then									-- auto df keywords; internal only
		all = true;																-- auto df applies to all dates; use length specified by capture len_p for all dates
		format, len_p, len_a = format:match('(%a+)%-([lsy])([sy]?)');			-- extract the format and length keywords
		if 'y' == len_p then													-- because allowed by MOS:DATEUNIFY (sort of) range dates and My dates not reformatted
			format = 'ymd';														-- override {{use xxx dates}}
		elseif (not is_set(len_a)) or (len_p == len_a) then						-- no access-/archive-date length specified or same length as publication dates then
			len_a = len_p;														-- in case len_a not set
		end
	end																			-- else only publication dates and they are long

	for param_name, param_val in pairs (date_parameters_list) do				-- for each date-holding parameter in the list
		if is_set (param_val.val) then											-- if the parameter has a value
			if not (not all and in_array (param_name, {'access-date', 'archive-date'})) then	-- skip access- or archive-date unless format is xxx-all; yeah, ugly; TODO: find a better way
				for pattern_idx, pattern in pairs (patterns) do
					if mw.ustring.match (param_val.val, pattern[1]) then
						if all and in_array (param_name, {'access-date', 'archive-date'}) then	-- if this date is an access- or archive-date
							new_date = reformatter (param_val.val, pattern_idx, (('y' == len_a) and 'ymd') or format, len_a);	-- choose ymd or dmy/mdy according to len_a setting
						else													-- all other dates
							new_date = reformatter (param_val.val, pattern_idx, format, len_p);
						end
						
						if new_date then										-- set when date was reformatted
							date_parameters_list[param_name].val = new_date;	-- update date in date list
							result = true;										-- and announce that changes have been made
						end
					end	-- if
				end		-- for
			end			-- if
		end				-- if
	end					-- for
	return result;																-- declare boolean result and done
end


--[[--------------------------&lt; D A T E _ H Y P H E N _ T O _ D A S H &gt;----------------------------------------

Loops through the list of date-holding parameters and converts any hyphen to an ndash.  Not called if the cs1|2
template has any date errors.

Modifies the date_parameters_list and returns true if hyphens are replaced, else returns false.

]]

local function date_hyphen_to_dash (date_parameters_list)
	local result = false;
	local n;
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set (param_val.val) and
			not mw.ustring.match (param_val.val, patterns.ymd[1]) then			-- for those that are not ymd dates (ustring because here digits may not be Western)
				param_val.val, n = param_val.val:gsub ('%-', '–');				-- replace any hyphen with ndash
				if 0 ~= n then
					date_parameters_list[param_name].val = param_val.val;		-- update the list
					result = true;
				end
		end
	end
	return result;																-- so we know if any hyphens were replaced
end


--[[-------------------------&lt; D A T E _ N A M E _ X L A T E &gt;------------------------------------------------

Attempts to translate English month names to local-language month names using names supplied by MediaWiki's
date parser function.  This is simple name-for-name replacement and may not work for all languages.

if xlat_dig is true, this function will also translate Western (English) digits to the local language's digits.
This will also translate ymd dates.

]]

local function date_name_xlate (date_parameters_list, xlt_dig)
	local xlate;
	local mode;																	-- long or short month names
	local modified = false;
	local date;
	
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val.val) then											-- if the parameter has a value
			date = param_val.val;
			for month in mw.ustring.gmatch (date, '%a+') do						-- iterate through all dates in the date (single date or date range)
				if cfg.date_names.en.long[month] then
					mode = 'F';													-- English name is long so use long local name
				elseif cfg.date_names.en.short[month] then
					mode = 'M';													-- English name is short so use short local name
				else
					mode = nil;													-- not an English month name; could be local language month name or an English season name
				end
		
				if mode then													-- might be a season
					xlate = lang_object:formatDate(mode, '1' .. month);			-- translate the month name to this local language
					date = mw.ustring.gsub (date, month, xlate);				-- replace the English with the translation
					date_parameters_list[param_name].val = date;				-- save the translated date
					modified = true;
				end
			end

			if xlt_dig then														-- shall we also translate digits?
				date = date:gsub ('%d', cfg.date_names.xlate_digits);			-- translate digits from Western to 'local digits'
				date_parameters_list[param_name].val = date;					-- save the translated date
				modified = true;
			end
		end
	end
	
	return modified;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	add_prop_cat = utilities_page_ptr.add_prop_cat ;							-- import functions from selected Module:Citation/CS1/Utilities module
	is_set = utilities_page_ptr.is_set;
	in_array = utilities_page_ptr.in_array;
	set_message = utilities_page_ptr.set_message;
	substitute = utilities_page_ptr.substitute;
	wrap_style = utilities_page_ptr.wrap_style;

	cfg = cfg_table_ptr;														-- import tables from selected Module:Citation/CS1/Configuration
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {																		-- return exported functions
	dates = dates,
	year_date_check = year_date_check,
	reformat_dates = reformat_dates,
	date_hyphen_to_dash = date_hyphen_to_dash,
	date_name_xlate = date_name_xlate,
	set_selected_modules = set_selected_modules
	}</text>
      <sha1>njr3fclpibq75fkfvzi1njmy7dj4693</sha1>
    </revision>
    <revision>
      <id>4854</id>
      <parentid>4853</parentid>
      <timestamp>2022-07-01T17:45:21Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4854</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="65384" sha1="obboarlfkmx4zbge5gqjllttddlxljn" xml:space="preserve">--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local add_prop_cat, is_set, in_array, set_message, substitute, wrap_style;		-- imported functions from selected Module:Citation/CS1/Utilities
local cfg;																		-- table of tables imported from selected Module:Citation/CS1/Configuration


--[[--------------------------&lt; F I L E - S C O P E   D E C L A R A T I O N S &gt;--------------------------------

File-scope variables are declared here

]]

local lang_object = mw.getContentLanguage();									-- used by is_valid_accessdate(), is_valid_year(), date_name_xlate(); TODO: move to ~/Configuration?
local year_limit;																-- used by is_valid_year()


--[=[-------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |access-date= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-English date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate().  To get around that
call this function with YYYY-MM-DD format dates.

]=]

local function is_valid_accessdate (accessdate)
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold Unix time stamps representing the dates

	good1, access_ts = pcall (lang_object.formatDate, lang_object, 'U', accessdate );			-- convert accessdate value to Unix timestamp 
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which which tonumber() may not understand
		access_ts = tonumber (access_ts) or lang_object:parseFormattedNumber (access_ts);		-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to Unix time stamp
	end

	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end


--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct.
If not a valid month, returns 0

]]

local function get_month_number (month)
	return cfg.date_names['local'].long[month] or cfg.date_names['local'].short[month] or	-- look for local names first
			cfg.date_names['en'].long[month] or	cfg.date_names['en'].short[month] or		-- failing that, look for English names
			0;																				-- not a recognized month name
end


--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 21 for Spring, etc.  Capitalization and spelling
must be correct. If not a valid season, returns 0.
	21-24 = Spring, Summer, Autumn, Winter, independent of “Hemisphere”

returns 0 when &lt;param&gt; is not |date=

Season numbering is defined by Extended Date/Time Format (EDTF) specification (https://www.loc.gov/standards/datetime/)
which became part of ISO 8601 in 2019.  See '§Sub-year groupings'.  The standard defines various divisions using
numbers 21-41.  cs1|2 only supports generic seasons.  EDTF does support the distinction between north and south
hemisphere seasons but cs1|2 has no way to make that distinction.

These additional divisions not currently supported:
	25-28 = Spring - Northern Hemisphere, Summer- Northern Hemisphere, Autumn - Northern Hemisphere, Winter - Northern Hemisphere
	29-32 = Spring – Southern Hemisphere, Summer– Southern Hemisphere, Autumn – Southern Hemisphere, Winter - Southern Hemisphere
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)

]]

local function get_season_number (season, param)
	if 'date' ~= param then
		return 0;																-- season dates only supported by |date=
	end
	return cfg.date_names['local'].season[season] or							-- look for local names first
			cfg.date_names['en'].season[season] or								-- failing that, look for English names
			0;																	-- not a recognized season name
end


--[[--------------------------&lt; G E T _ Q U A R T E R _ N U M B E R &gt;------------------------------------------

returns a number according to the sequence of quarters in a year: 33 for first quarter, etc.  Capitalization and spelling
must be correct. If not a valid quarter, returns 0.
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)

returns 0 when &lt;param&gt; is not |date=

Quarter numbering is defined by Extended Date/Time Format (EDTF) specification (https://www.loc.gov/standards/datetime/)
which became part of ISO 8601 in 2019.  See '§Sub-year groupings'.  The standard defines various divisions using
numbers 21-41.  cs1|2 only supports generic seasons and quarters.

These additional divisions not currently supported:
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)

]]

local function get_quarter_number (quarter, param)
	if 'date' ~= param then
		return 0;																-- quarter dates only supported by |date=
	end
	quarter = mw.ustring.gsub (quarter, ' +', ' ');								-- special case replace multiple space chars with a single space char
	return cfg.date_names['local'].quarter[quarter] or							-- look for local names first
			cfg.date_names['en'].quarter[quarter] or							-- failing that, look for English names
			0;																	-- not a recognized quarter name
end


--[[--------------------------&lt; G E T _ P R O P E R _ N A M E _ N U M B E R &gt;----------------------------------

returns a non-zero number if date contains a recognized proper-name.  Capitalization and spelling must be correct.

returns 0 when &lt;param&gt; is not |date=

]]

local function get_proper_name_number (name, param)
	if 'date' ~= param then
		return 0;																-- proper-name dates only supported by |date=
	end
	return cfg.date_names['local'].named[name] or								-- look for local names dates first
			cfg.date_names['en'].named[name] or									-- failing that, look for English names
			0;																	-- not a recognized named date
end


--[[--------------------------&lt; G E T _ E L E M E N T _ N U M B E R &lt;------------------------------------------

returns true if month or season or quarter or proper name is valid (properly spelled, capitalized, abbreviated)

]]

local function get_element_number (element, param)
	local num;
	
	local funcs = {get_month_number, get_season_number, get_quarter_number, get_proper_name_number};	-- list of functions to execute in order
	
	for _, func in ipairs (funcs) do											-- spin through the function list
		num = func (element, param);											-- call the function and get the returned number
		if 0 ~= num then														-- non-zero when valid month season quarter 
			return num;															-- return that number
		end
	end
	return nil;																	-- not valid
end


--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one
year in the future are not acceptable.

Special case for |pmc-embargo-date=: years more than two years in the future are not acceptable

]]

local function is_valid_year (year, param)
	if not is_set (year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;									-- global variable so we only have to fetch it once
	end

	year = tonumber (year) or lang_object:parseFormattedNumber (year);			-- convert to number for the comparison;
	
	if 'pmc-embargo-date' == param then											-- special case for |pmc-embargo-date=
		return year and (year &lt;= tonumber(os.date(&quot;%Y&quot;))+2) or false;			-- years more than two years in the future are not accepted
	end	
	return year and (year &lt;= year_limit) or false;
end


--[[--------------------------&lt; I S _ V A L I D _ D A T E &gt;----------------------------------------------------

Returns true if day is less than or equal to the number of days in month and year is no farther into the future
than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap
years before 1582 and Gregorian leap years after 1582. Where the two calendars overlap (1582 to approximately
1923) dates are assumed to be Gregorian.

]]

local function is_valid_date (year, month, day, param)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year (year, param) then										-- no farther into the future than next year except |pmc-embargo-date= no more than two years in the future
		return false;
	end
	
	month = tonumber (month);													-- required for YYYY-MM-DD dates
	
	if (2 == month) then														-- if February
		month_length = 28;														-- then 28 days unless
		if 1582 &gt; tonumber(year) then											-- Julian calendar
			if 0 == (year%4) then												-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		else																	-- Gregorian calendar
			if (0 == (year%4) and (0 ~= (year%100) or 0 == (year%400))) then	-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		end
	else
		month_length = days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
This function looks in cfg.date_names{} to see if both month names are listed in the long subtable or both are
listed in the short subtable.  When both have the same style (both are listed in the same table), returns true; false else

]]

local function is_valid_month_range_style (month1, month2)
	if (cfg.date_names.en.long[month1] and cfg.date_names.en.long[month2]) or					-- are both English names listed in the long subtable?
		(cfg.date_names.en.short[month1] and cfg.date_names.en.short[month2]) or				-- are both English names listed in the short subtable?
		(cfg.date_names['local'].long[month1] and cfg.date_names['local'].long[month2]) or		-- are both local names listed in the long subtable?
		(cfg.date_names['local'].short[month1] and cfg.date_names['local'].short[month2]) then	-- are both local names listed in the short subtable?
			return true;
	end
	return false;																-- names are mixed
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

All season ranges are accepted as valid because there are publishers out there who have published a Summer–Spring YYYY issue, hence treat as ok

]]

local function is_valid_month_season_range(range_start, range_end, param)
	local range_start_number = get_month_number (range_start);
	local range_end_number;

	if 0 == range_start_number then												-- is this a month range?
		range_start_number = get_season_number (range_start, param);			-- not a month; is it a season? get start season number
		range_end_number = get_season_number (range_end, param);				-- get end season number

		if (0 ~= range_start_number) and (0 ~= range_end_number) and (range_start_number ~= range_end_number) then
			return true;														-- any season pairing is accepted except when both are the same
		end
		return false;															-- range_start and/or range_end is not a season
	end
																				-- here when range_start is a month
	range_end_number = get_month_number (range_end);							-- get end month number
	if range_start_number &lt; range_end_number and								-- range_start is a month; does range_start precede range_end?
		is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
	end
	return false;																-- range_start month number is greater than or equal to range end number; or range end isn't a month
end


--[[--------------------------&lt; M A K E _ C O I N S _ D A T E &gt;------------------------------------------------

This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1.  The function is called only for |date= parameters and only if the |date=&lt;value&gt; is 
determined to be a valid date format.  The question of what to do with invalid date formats is not answered here.

The date parts in the input table are converted to an ISO 8601 conforming date string:
	single whole dates:		yyyy-mm-dd
	month and year dates:	yyyy-mm
	year dates:				yyyy
	ranges:					yyyy-mm-dd/yyyy-mm-dd
							yyyy-mm/yyyy-mm
							yyyy/yyyy

Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.

The input table has:
	year, year2 – always present; if before 1582, ignore months and days if present
	month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 99 Christmas
	day, day2 –  0 if not provided, 1-31 for days
	
the output table receives:
	rftdate:	an ISO 8601 formatted date
	rftchron:	a free-form version of the date, usually without year which is in rftdate (season ranges and proper-name dates)
	rftssn:		one of four season keywords: winter, spring, summer, fall (lowercase)
	rftquarter:	one of four values: 1, 2, 3, 4

]]

local function make_COinS_date (input, tCOinS_date)
	local date;																	-- one date or first date in a range
	local date2 = '';															-- end of range date
-- start temporary Julian / Gregorian calendar uncertainty detection
	local year = tonumber(input.year);											-- this temporary code to determine the extent of sources dated to the Julian/Gregorian
	local month = tonumber(input.month);										-- interstice 1 October 1582 – 1 January 1926
	local day = tonumber (input.day);
	if (0 ~= day) and															-- day must have a value for this to be a whole date
		(((1582 == year) and (10 &lt;= month) and (12 &gt;= month)) or				-- any whole 1582 date from 1 October to 31 December or
			((1926 == year) and (1 == month) and (1 == input.day)) or			-- 1 January 1926 or
				((1582 &lt; year) and (1925 &gt;= year))) then						-- any date 1 January 1583 – 31 December 1925
					tCOinS_date.inter_cal_cat = true;							-- set category flag true
	end
-- end temporary Julian / Gregorian calendar uncertainty detection
	
	if 1582 &gt; tonumber(input.year) or 20 &lt; tonumber(input.month) then			-- Julian calendar or season so &amp;rft.date gets year only
		date = input.year;
		if 0 ~= input.year2 and input.year ~= input.year2 then					-- if a range, only the second year portion when not the same as range start year
			date = string.format ('%.4d/%.4d', tonumber(input.year), tonumber(input.year2))		-- assemble the date range
		end
		if 20 &lt; tonumber(input.month) then										-- if season or proper-name date
			local season = {[24] = 'winter', [21] = 'spring', [22] = 'summer', [23] = 'fall', [33] = '1', [34] = '2', [35] = '3', [36] = '4', [98] = 'Easter', [99] = 'Christmas'};	-- seasons lowercase, no autumn; proper-names use title case
			if 0 == input.month2 then											-- single season date
				if 40 &lt; tonumber(input.month) then
					tCOinS_date.rftchron = season[input.month];					-- proper-name dates
				elseif 30 &lt; tonumber(input.month) then
					tCOinS_date.rftquarter = season[input.month];				-- quarters
				else
					tCOinS_date.rftssn = season[input.month];					-- seasons
				end
			else																-- season range with a second season specified
				if input.year ~= input.year2 then								-- season year – season year range or season year–year
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					if 0~= input.month2 then
						tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);
					end
				else															-- season–season year range
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2];	-- season–season year range
				end
			end
		end
		tCOinS_date.rftdate = date;
		return;																	-- done
	end
	
	if 0 ~= input.day then
		date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day));	-- whole date
	elseif 0 ~= input.month then
		date = string.format ('%s-%.2d', input.year, tonumber(input.month));	-- year and month
	else
		date = string.format ('%s', input.year);								-- just year
	end

	if 0 ~= input.year2 then
		if 0 ~= input.day2 then
			date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2));		-- whole date
		elseif 0 ~= input.month2 then
			date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2));	-- year and month
		else
			date2 = string.format ('/%s', input.year2);							-- just year
		end
	end
	
	tCOinS_date.rftdate = date .. date2;										-- date2 has the '/' separator
	return;
end


--[[--------------------------&lt; P A T T E R N S &gt;--------------------------------------------------------------

this is the list of patterns for date formats that this module recognizes.  Approximately the first half of these
patterns represent formats that might be reformatted into another format.  Those that might be reformatted have
'indicator' letters that identify the content of the matching capture: 'd' (day), 'm' (month), 'a' (anchor year),
'y' (year); second day, month, year have a '2' suffix.

These patterns are used for both date validation and for reformatting.  This table should not be moved to ~/Configuration
because changes to this table require changes to check_date() and to reformatter() and reformat_date()

]]

local patterns = {
	 																			-- year-initial numerical year-month-day
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'},					
																				-- month-initial: month day, year
	['Mdy'] = {'^(%D-) +([1-9]%d?), +((%d%d%d%d?)%a?)$', 'm', 'd', 'a', 'y'},
																				-- month-initial day range: month day–day, year; days are separated by endash
	['Md-dy'] = {'^(%D-) +([1-9]%d?)[%-–]([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'd2', 'a', 'y'},
																				-- day-initial: day month year
	['dMy'] = {'^([1-9]%d?) +(%D-) +((%d%d%d%d?)%a?)$', 'd', 'm', 'a', 'y'},
																				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed; not supported at en.wiki
	--	['yMd'] = {'^((%d%d%d%d?)%a?) +(%D-) +(%d%d?)$', 'a', 'y', 'm', 'd'},
																				-- day-range-initial: day–day month year; days are separated by endash
	['d-dMy'] = {'^([1-9]%d?)[%-–]([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'd2', 'm', 'a', 'y'},
																				-- day initial month-day-range: day month - day month year; uses spaced endash
	['dM-dMy'] = {'^([1-9]%d?) +(%D-) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'd2', 'm2', 'a', 'y'},
																				-- month initial month-day-range: month day – month day, year;  uses spaced endash
	['Md-Mdy'] = {'^(%D-) +([1-9]%d?) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$','m', 'd', 'm2', 'd2', 'a', 'y'},
																				-- day initial month-day-year-range: day month year - day month year; uses spaced endash
	['dMy-dMy'] = {'^([1-9]%d?) +(%D-) +(%d%d%d%d) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'y', 'd2', 'm2', 'a', 'y2'},
																				-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
	['Mdy-Mdy'] = {'^(%D-) +([1-9]%d?), +(%d%d%d%d) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'y', 'm2', 'd2', 'a', 'y2'},

																				-- these date formats cannot be converted, per se, but month name can be rendered short or long
																				-- month/season year - month/season year; separated by spaced endash
	['My-My'] = {'^(%D-) +(%d%d%d%d) +[%-–] +(%D-) +((%d%d%d%d)%a?)$', 'm', 'y', 'm2', 'a', 'y2'},
																				-- month/season range year; months separated by endash
	['M-My'] = {'^(%D-)[%-–](%D-) +((%d%d%d%d)%a?)$', 'm', 'm2', 'a', 'y'},
																				-- month/season year or proper-name year; quarter year when First Quarter YYYY etc.
	['My'] = {'^([^%d–]-) +((%d%d%d%d)%a?)$', 'm', 'a', 'y'},					-- this way because endash is a member of %D; %D- will match January–March 2019 when it shouldn't

																				-- these date formats cannot be converted
	['Sy4-y2'] = {'^(%D-) +((%d%d)%d%d)[%-–]((%d%d)%a?)$'},						-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
	['Sy-y'] = {'^(%D-) +(%d%d%d%d)[%-–]((%d%d%d%d)%a?)$'},						-- special case Winter/Summer year-year; year separated with unspaced endash
	['y-y'] = {'^(%d%d%d%d?)[%-–]((%d%d%d%d?)%a?)$'},							-- year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
	['y4-y2'] = {'^((%d%d)%d%d)[%-–]((%d%d)%a?)$'},								-- year range: YYYY–YY; separated by unspaced endash
	['y'] = {'^((%d%d%d%d?)%a?)$'},												-- year; here accept either YYY or YYYY
	}


--[[--------------------------&lt; I S _ V A L I D _ E M B A R G O _ D A T E &gt;------------------------------------

returns true and date value if that value has proper dmy, mdy, ymd format.

returns false and 9999 (embargoed forever) when date value is not proper format; assumes that when |pmc-embargo-date= is
set, the editor intended to embargo a PMC but |pmc-embargo-date= does not hold a single date.

]]

local function is_valid_embargo_date (v)
	if v:match (patterns['ymd'][1]) or											-- ymd
		v:match (patterns['Mdy'][1]) or											-- dmy
		v:match (patterns['dMy'][1]) then										-- mdy
			return true, v;
	end
	return false, '9999';														-- if here not good date so return false and set embargo date to long time in future
end


--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only
allowed range separator is endash.  Additionally, check the date to see that it is a real date: no 31 in 30-day
months; no 29 February when not a leap year.  Months, both long-form and three character abbreviations, and seasons
must be spelled correctly.  Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and
COinS_date.  When this happens, the date parameter is (DEBUG: not?) used in the COinS metadata and the CITEREF identifier gets
its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, publication-date, access-date, pmc-embargo-date, archive-date, lay-date)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is ISO 8601 format date; see make_COInS_date()

]]

local function check_date (date_string, param, tCOinS_date)
	local year;																	-- assume that year2, months, and days are not used;
	local year2 = 0;															-- second year in a year range
	local month = 0;
	local month2 = 0;															-- second month in a month range
	local day = 0;
	local day2 = 0;																-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match (patterns['ymd'][1]) then								-- year-initial numerical year month day format
		year, month, day = date_string:match (patterns['ymd'][1]);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or 0 == tonumber(day) then return false; end	-- month or day number not valid or not Gregorian calendar
		anchor_year = year;
	
	elseif mw.ustring.match(date_string, patterns['Mdy'][1]) then				-- month-initial: month day, year
		month, day, anchor_year, year = mw.ustring.match(date_string, patterns['Mdy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
				
	elseif mw.ustring.match(date_string, patterns['Md-dy'][1]) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year = mw.ustring.match(date_string, patterns['Md-dy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2=month;															-- for metadata
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['dMy'][1]) then				-- day-initial: day month year
		day, month, anchor_year, year = mw.ustring.match(date_string, patterns['dMy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months

--[[ NOT supported at en.wiki
	elseif mw.ustring.match(date_string, patterns['yMd'][1]) then				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed
		anchor_year, year, month, day = mw.ustring.match(date_string, patterns['yMd'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
-- end NOT supported at en.wiki ]]

	elseif mw.ustring.match(date_string, patterns['d-dMy'][1]) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year = mw.ustring.match(date_string, patterns['d-dMy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2 = month;															-- for metadata
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['dM-dMy'][1]) then			-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year = mw.ustring.match(date_string, patterns['dM-dMy'][1]);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['Md-Mdy'][1]) then			-- month initial month-day-range: month day – month day, year; uses spaced endash
		month, day, month2, day2, anchor_year, year = mw.ustring.match(date_string, patterns['Md-Mdy'][1]);
		if (not is_valid_month_season_range(month, month2, param)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['dMy-dMy'][1]) then			-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2 = mw.ustring.match(date_string, patterns['dMy-dMy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		if 0 == month or 0 == month2 then return false; end						-- both must be valid

	elseif mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]) then			-- month initial month-day-year-range: month day, year – month day, year; uses spaced endash
		month, day, year, month2, day2, anchor_year, year2 = mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number(month2);
		if 0 == month or 0 == month2 then return false; end						-- both must be valid

	elseif mw.ustring.match(date_string, patterns['Sy4-y2'][1]) then			-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		local century;
		month, year, century, anchor_year, year2 = mw.ustring.match(date_string, patterns['Sy4-y2'][1]);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;		-- 'month' can only be Winter or Summer
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor_year from both years
		year2 = century..year2;													-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		month = get_season_number(month, param);

	elseif mw.ustring.match(date_string, patterns['Sy-y'][1]) then				-- special case Winter/Summer year-year; year separated with unspaced endash
		month, year, anchor_year, year2 = mw.ustring.match(date_string, patterns['Sy-y'][1]);
		month = get_season_number (month, param);								-- &lt;month&gt; can only be winter or summer; also for metadata
		if (month ~= cfg.date_names['en'].season['Winter']) and (month ~= cfg.date_names['en'].season['Summer']) then
			return false;														-- not Summer or Winter; abandon
		end
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, patterns['My-My'][1]) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2 = mw.ustring.match(date_string, patterns['My-My'][1]);
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then 	-- both must be month year, same month style
			month = get_month_number(month);
			month2 = get_month_number(month2);
		elseif 0 ~= get_season_number(month, param) and 0 ~= get_season_number(month2, param) then	-- both must be season year, not mixed
			month = get_season_number(month, param);
			month2 = get_season_number(month2, param);
		else
			 return false;
		end

	elseif mw.ustring.match(date_string, patterns['M-My'][1]) then				-- month/season range year; months separated by endash 
		month, month2, anchor_year, year = mw.ustring.match(date_string, patterns['M-My'][1]);
		if (not is_valid_month_season_range(month, month2, param)) or (not is_valid_year(year)) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
			month2 = get_month_number(month2);
			if 0 == month or 0 == month2 then return false; end
		else
			month = get_season_number(month, param);
			month2 = get_season_number(month2, param);
		end
		year2 = year;
		
	elseif mw.ustring.match(date_string, patterns['My'][1]) then				-- month/season/quarter/proper-name year
		month, anchor_year, year = mw.ustring.match(date_string, patterns['My'][1]);
		if not is_valid_year(year) then return false; end
		month = get_element_number(month, param);								-- get month season quarter proper-name number or nil
		if not month then return false; end										-- not valid whatever it is

	elseif mw.ustring.match(date_string, patterns['y-y'][1]) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2 = mw.ustring.match(date_string, patterns['y-y'][1]);
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, patterns['y4-y2'][1]) then				-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2 = mw.ustring.match(date_string, patterns['y4-y2'][1]);
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor year from both years

		if in_array (param, {'date', 'publication-date', 'year'}) then
			add_prop_cat ('year-range-abbreviated');
		end

		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century .. year2;													-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, patterns['y'][1]) then					-- year; here accept either YYY or YYYY
		anchor_year, year = mw.ustring.match(date_string, patterns['y'][1]);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;															-- date format not one of the MOS:DATE approved formats
	end

	if 'access-date' == param then												-- test accessdate here because we have numerical date parts
		if 0 ~= year and 0 ~= month and 0 ~= day and 							-- all parts of a single date required
			0 == year2 and 0 == month2 and 0 == day2 then						-- none of these; accessdate must not be a range
				if not is_valid_accessdate(year .. '-' .. month .. '-' .. day) then	
					return false;												-- return false when accessdate out of bounds
				end
		else
			return false;														-- return false when accessdate is a range of two dates
		end
	end

	local result=true;															-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result = is_valid_date (year, month, day, param);						-- &lt;param&gt; for |pmc-embargo-date=

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result = is_valid_date (year, month, day);
		result = result and is_valid_date (year, month, day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result = is_valid_date (year, month, day);
		result = result and is_valid_date (year, month2, day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result = is_valid_date(year, month, day);
		result = result and is_valid_date(year2, month2, day2);
	end
	
	if false == result then return false; end

	if nil ~= tCOinS_date then													-- this table only passed into this function when testing |date= parameter values
		make_COinS_date ({year = year, month = month, day = day, year2 = year2, month2 = month2, day2 = day2}, tCOinS_date);	-- make an ISO 8601 date string for COinS
	end
	
	return true, anchor_year;													-- format is good and date string represents a real date
end	


--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
parameters with errors are added to the &lt;error_list&gt; sequence table as the dates are tested.

]]

local function dates(date_parameters_list, tCOinS_date, error_list)
	local anchor_year;															-- will return as nil if the date being tested is not |date=
	local COinS_date;															-- will return as nil if the date being tested is not |date=
	local embargo_date;															-- if embargo date is a good dmy, mdy, ymd date then holds original value else reset to 9999
	local good_date = false;

	for k, v in pairs(date_parameters_list) do									-- for each date-holding parameter in the list
		if is_set(v.val) then													-- if the parameter has a value
			v.val = mw.ustring.gsub(v.val, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9
			if v.val:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then						-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v.val:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);				-- get the year portion so it can be tested
				if 'date' == k then
					anchor_year, COinS_date = v.val:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year' == k then
					good_date = is_valid_year(year);
				end
			elseif 'date' == k then												-- if the parameter is |date=
				if v.val:match(&quot;^n%.d%.%a?$&quot;) then -- ToDo: I18N								-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((n%.d%.)%a?)&quot;); -- ToDo: I18N	-- &quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v.val:match(&quot;^nd%a?$&quot;) then -- ToDo: I18N								-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((nd)%a?)&quot;); -- ToDo: I18N	-- &quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v.val, k, tCOinS_date);	-- go test the date
				end
			elseif 'year' == k then												-- if the parameter is |year= it should hold only a year value
				if v.val:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then						-- if |year = 3 or 4 digits only with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((%d+)%a?)&quot;);
				end
			elseif 'pmc-embargo-date' == k then									-- if the parameter is |pmc-embargo-date=
				good_date = check_date (v.val, k);								-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date, embargo_date = is_valid_embargo_date (v.val);	-- is |pmc-embargo-date= date a single dmy, mdy, or ymd formatted date? yes: returns embargo date; no: returns 9999
				end
			else																-- any other date-holding parameter
				good_date = check_date (v.val, k);								-- go test the date
			end
			if false == good_date then											-- assemble one error message so we don't add the tracking category multiple times
				table.insert (error_list, wrap_style ('parameter', v.name));	-- make parameter name suitable for error message list
			end
		end
	end
	return anchor_year, embargo_date;											-- and done
end


--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function sets a local numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

the numeric value in &lt;result&gt; determines the 'output' if any from this function:
	0 – adds error message to error_list sequence table
	1 – adds maint cat
	2 – does nothing

]]

local function year_date_check (year_string, year_origin, date_string, date_origin, error_list)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes

	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where both date and year are required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard range formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif mw.ustring.match(date_string, &quot;%d%d%d%d[%-–]%d%d&quot;) then				-- YYYY-YY date ranges
		local century;
		date1, century, date2 = mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	else																		-- should never get here; this function called only when no other date errors
		result = 0;																-- no recognizable year in date
	end

	if 0 == result then															-- year / date mismatch
		table.insert (error_list, substitute (cfg.messages['mismatch'], {year_origin, date_origin}));	-- add error message to error_list sequence table
	elseif 1 == result then														-- redundant year / date
		set_message ('maint_date_year');										-- add a maint cat
	end
end


--[[--------------------------&lt; R E F O R M A T T E R &gt;--------------------------------------------------------

reformat 'date' into new format specified by format_param if pattern_idx (the current format of 'date') can be
reformatted.  Does the grunt work for reformat_dates().

The table re_formats maps pattern_idx (current format) and format_param (desired format) to a table that holds:
	format string used by string.format()
	identifier letters ('d', 'm', 'y', 'd2', 'm2', 'y2') that serve as indexes into a table t{} that holds captures
		from mw.ustring.match() for the various date parts specified by  patterns[pattern_idx][1]

Items in patterns{} have the general form:
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'}, where:
		['ymd'] is pattern_idx
		patterns['ymd'][1] is the match pattern with captures for mw.ustring.match()
		patterns['ymd'][2] is an indicator letter identifying the content of the first capture
		patterns['ymd'][3] ... the second capture etc.

when a pattern matches a date, the captures are loaded into table t{} in capture order using the idemtifier
characters as indexes into t{}  For the above, a ymd date is in t{} as:
	t.y = first capture (year), t.m = second capture (month), t.d = third capture (day)

To reformat, this function is called with the pattern_idx that matches the current format of the date and with
format_param set to the desired format.  This function loads table t{} as described and then calls string.format()
with the format string specified by re_format[pattern_idx][format_param][1] using values taken from t{} according
to the capture identifier letters specified by patterns[pattern_idx][format_param][n] where n is 2..

]]

local re_formats = {
	['ymd'] = {																	-- date format is ymd; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
	--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},								-- |df=yMd; not supported at en.wiki
		},
	['Mdy'] = {																	-- date format is Mdy; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- for long/short reformatting
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
	--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},								-- |df=yMd; not supported at en.wiki
		},
	['dMy'] = {																	-- date format is dMy; reformat to:
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- for long/short reformatting
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
	--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},								-- |df=yMd; not supported at en.wiki
		},
	['Md-dy'] = {																-- date format is Md-dy; reformat to:
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- for long/short reformatting
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- |df=dmy -&gt; d-dMy 
		},
	['d-dMy'] = {																-- date format is d-d&gt;y; reformat to:
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- for long/short reformatting
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- |df=mdy -&gt; Md-dy 
		},
	['dM-dMy'] = {																-- date format is dM-dMy; reformat to:
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- for long/short reformatting
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd', 'm2', 'd2', 'y'},				-- |df=mdy -&gt; Md-Mdy 
		},
	['Md-Mdy'] = {																-- date format is Md-Mdy; reformat to:
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd',  'm2', 'd2', 'y'},			-- for long/short reformatting
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- |df=dmy -&gt; dM-dMy 
		},
	['dMy-dMy'] = {																-- date format is dMy-dMy; reformat to:
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- for long/short reformatting
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- |df=mdy -&gt; Mdy-Mdy 
		},
	['Mdy-Mdy'] = {																-- date format is Mdy-Mdy; reformat to:
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- for long/short reformatting
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- |df=dmy -&gt; dMy-dMy 
		},
	['My-My'] = {																-- these for long/short reformatting
		['any'] = {'%s %s – %s %s', 'm', 'y', 'm2', 'y2'},						-- dmy/mdy agnostic
		},
	['M-My'] = {																-- these for long/short reformatting
		['any'] = {'%s–%s %s', 'm', 'm2', 'y'},									-- dmy/mdy agnostic
		},
	['My'] = {																	-- these for long/short reformatting
		['any'] = {'%s %s', 'm', 'y'},											-- dmy/mdy agnostic
		},
	--	['yMd'] = {																-- not supported at en.wiki
	--		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},								-- |df=mdy
	--		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},								-- |df=dmy
	--		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},								-- |df=ymd
	--		},
	}


local function reformatter (date, pattern_idx, format_param, mon_len)
	if not in_array (pattern_idx, {'ymd', 'Mdy', 'Md-dy', 'dMy', 'yMd', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- not in this set of date format patterns then not a reformattable date
	end
	
	if 'ymd' == format_param and in_array (pattern_idx, {'ymd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- ymd date ranges not supported at en.wiki; no point in reformatting ymd to ymd
	end

	if in_array (pattern_idx, {'My', 'M-My', 'My-My'}) then						-- these are not dmy/mdy so can't be 'reformatted' into either
		format_param = 'any';													-- so format-agnostic 
	end

																				-- yMd is not supported at en.wiki; when yMd is supported at your wiki, uncomment the next line
	--	if 'yMd' == format_param and in_array (pattern_idx, {'yMd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy'}) then	-- these formats not convertable; yMd not supported at en.wiki
	if 'yMd' == format_param then												-- yMd not supported at en.wiki; when yMd is supported at your wiki, remove or comment-out this line
		return;																	-- not a reformattable date
	end
	
	local c1, c2, c3, c4, c5, c6, c7;											-- these hold the captures specified in patterns[pattern_idx][1]
	c1, c2, c3, c4, c5, c6, c7 = mw.ustring.match (date, patterns[pattern_idx][1]);	-- get the captures

	local t = {																	-- table that holds k/v pairs of date parts from the captures and patterns[pattern_idx][2..]
		[patterns[pattern_idx][2]] = c1;										-- at minimum there is always one capture with a matching indicator letter
		[patterns[pattern_idx][3] or 'x'] = c2;									-- patterns can have a variable number of captures; each capture requires an indicator letter;
		[patterns[pattern_idx][4] or 'x'] = c3;									-- where there is no capture, there is no indicator letter so n in patterns[pattern_idx][n] will be nil;
		[patterns[pattern_idx][5] or 'x'] = c4;									-- the 'x' here spoofs an indicator letter to prevent 'table index is nil' error
		[patterns[pattern_idx][6] or 'x'] = c5;
		[patterns[pattern_idx][7] or 'x'] = c6;
		[patterns[pattern_idx][8] or 'x'] = c7;
		};

	if t.a then																	-- if this date has an anchor year capture (all convertable date formats except ymd)
		if t.y2 then															-- for year range date formats														
			t.y2 = t.a;															-- use the anchor year capture when reassembling the date
		else																	-- here for single date formats (except ymd)
			t.y = t.a;															-- use the anchor year capture when reassembling the date
		end
	end

	if tonumber(t.m) then														-- if raw month is a number (converting from ymd)
		if 's' == mon_len then													-- if we are to use abbreviated month names
			t.m = cfg.date_names['inv_local_short'][tonumber(t.m)];					-- convert it to a month name
		else
			t.m = cfg.date_names['inv_local_long'][tonumber(t.m)];					-- convert it to a month name
		end
		t.d = t.d:gsub ('0(%d)', '%1');											-- strip leading '0' from day if present
	elseif 'ymd' == format_param then											-- when converting to ymd
		t.y = t.y:gsub ('%a', '');												-- strip CITREF disambiguator if present; anchor year already known so process can proceed; TODO: maint message?
		if 1582 &gt; tonumber (t.y) then											-- ymd format dates not allowed before 1582
			return;
		end
		t.m = string.format ('%02d', get_month_number (t.m));					-- make sure that month and day are two digits
		t.d = string.format ('%02d', t.d);
	elseif mon_len then															-- if mon_len is set to either 'short' or 'long'
		for _, mon in ipairs ({'m', 'm2'}) do									-- because there can be two month names, check both 
			if t[mon] then
				t[mon] = get_month_number (t[mon]);								-- get the month number for this month (is length agnostic)
				if 0 == t[mon] then return; end									-- seasons and named dates can't be converted
				t[mon] = (('s' == mon_len) and cfg.date_names['inv_local_short'][t[mon]]) or cfg.date_names['inv_local_long'][t[mon]];	-- fetch month name according to length
			end
		end
	end

	local new_date = string.format (re_formats[pattern_idx][format_param][1],	-- format string
		t[re_formats[pattern_idx][format_param][2]],							-- named captures from t{}
		t[re_formats[pattern_idx][format_param][3]],
		t[re_formats[pattern_idx][format_param][4]],
		t[re_formats[pattern_idx][format_param][5]],
		t[re_formats[pattern_idx][format_param][6]],
		t[re_formats[pattern_idx][format_param][7]],
		t[re_formats[pattern_idx][format_param][8]]
		);

	return new_date;
end


--[[-------------------------&lt; R E F O R M A T _ D A T E S &gt;--------------------------------------------------

Reformats existing dates into the format specified by format.

format is one of several manual keywords: dmy, dmy-all, mdy, mdy-all, ymd, ymd-all.  The -all version includes
access- and archive-dates; otherwise these dates are not reformatted.

This function allows automatic date formatting.  In ~/Configuration, the article source is searched for one of
the {{use xxx dates}} templates.  If found, xxx becomes the global date format as xxx-all.  If |cs1-dates= in
{{use xxx dates}} has legitimate value then that value determines how cs1|2 dates will be rendered.  Legitimate
values for |cs1-dates= are:
	l - all dates are rendered with long month names
	ls - publication dates use long month names; access-/archive-dates use abbreviated month names
	ly - publication dates use long month names; access-/archive-dates rendered in ymd format
	s - all dates are rendered with abbreviated (short) month names
	sy - publication dates use abbreviated month names; access-/archive-dates rendered in ymd format
	y - all dates are rendered in ymd format

the format argument for automatic date formatting will be the format specified by {{use xxx dates}} with the
value supplied by |cs1-dates so one of: xxx-l, xxx-ls, xxx-ly, xxx-s, xxx-sy, xxx-y, or simply xxx (|cs1-dates=
empty, omitted, or invalid) where xxx shall be either of dmy or mdy.

dates are extracted from date_parameters_list, reformatted (if appropriate), and then written back into the
list in the new format.  Dates in date_parameters_list are presumed here to be valid (no errors).  This function
returns true when a date has been reformatted, false else.  Actual reformatting is done by reformatter().

]]

local function reformat_dates (date_parameters_list, format)
	local all = false;															-- set to false to skip access- and archive-dates
	local len_p = 'l';															-- default publication date length shall be long
	local len_a = 'l';															-- default access-/archive-date length shall be long
	local result = false;
	local new_date;																
	
	if format:match('%a+%-all') then											-- manual df keyword; auto df keyword when length not specified in {{use xxx dates}}; 
		format = format:match('(%a+)%-all');									-- extract the format
		all = true;																-- all dates are long format dates because this keyword doesn't specify length
	elseif format:match('%a+%-[lsy][sy]?') then									-- auto df keywords; internal only
		all = true;																-- auto df applies to all dates; use length specified by capture len_p for all dates
		format, len_p, len_a = format:match('(%a+)%-([lsy])([sy]?)');			-- extract the format and length keywords
		if 'y' == len_p then													-- because allowed by MOS:DATEUNIFY (sort of) range dates and My dates not reformatted
			format = 'ymd';														-- override {{use xxx dates}}
		elseif (not is_set(len_a)) or (len_p == len_a) then						-- no access-/archive-date length specified or same length as publication dates then
			len_a = len_p;														-- in case len_a not set
		end
	end																			-- else only publication dates and they are long

	for param_name, param_val in pairs (date_parameters_list) do				-- for each date-holding parameter in the list
		if is_set (param_val.val) then											-- if the parameter has a value
			if not (not all and in_array (param_name, {'access-date', 'archive-date'})) then	-- skip access- or archive-date unless format is xxx-all; yeah, ugly; TODO: find a better way
				for pattern_idx, pattern in pairs (patterns) do
					if mw.ustring.match (param_val.val, pattern[1]) then
						if all and in_array (param_name, {'access-date', 'archive-date'}) then	-- if this date is an access- or archive-date
							new_date = reformatter (param_val.val, pattern_idx, (('y' == len_a) and 'ymd') or format, len_a);	-- choose ymd or dmy/mdy according to len_a setting
						else													-- all other dates
							new_date = reformatter (param_val.val, pattern_idx, format, len_p);
						end
						
						if new_date then										-- set when date was reformatted
							date_parameters_list[param_name].val = new_date;	-- update date in date list
							result = true;										-- and announce that changes have been made
						end
					end	-- if
				end		-- for
			end			-- if
		end				-- if
	end					-- for
	return result;																-- declare boolean result and done
end


--[[--------------------------&lt; D A T E _ H Y P H E N _ T O _ D A S H &gt;----------------------------------------

Loops through the list of date-holding parameters and converts any hyphen to an ndash.  Not called if the cs1|2
template has any date errors.

Modifies the date_parameters_list and returns true if hyphens are replaced, else returns false.

]]

local function date_hyphen_to_dash (date_parameters_list)
	local result = false;
	local n;
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set (param_val.val) and
			not mw.ustring.match (param_val.val, patterns.ymd[1]) then			-- for those that are not ymd dates (ustring because here digits may not be Western)
				param_val.val, n = param_val.val:gsub ('%-', '–');				-- replace any hyphen with ndash
				if 0 ~= n then
					date_parameters_list[param_name].val = param_val.val;		-- update the list
					result = true;
				end
		end
	end
	return result;																-- so we know if any hyphens were replaced
end


--[[-------------------------&lt; D A T E _ N A M E _ X L A T E &gt;------------------------------------------------

Attempts to translate English date names to local-language date names using names supplied by MediaWiki's
date parser function.  This is simple name-for-name replacement and may not work for all languages.

if xlat_dig is true, this function will also translate Western (English) digits to the local language's digits.
This will also translate ymd dates.

]]

local function date_name_xlate (date_parameters_list, xlt_dig)
	local xlate;
	local mode;																	-- long or short month names
	local modified = false;
	local date;
	
	local sources_t = {
		{cfg.date_names.en.long, cfg.date_names.inv_local_long},				-- for translating long English month names to long local month names
		{cfg.date_names.en.short, cfg.date_names.inv_local_short},				-- short month names
		{cfg.date_names.en.quarter, cfg.date_names.inv_local_quarter},			-- quarter date names
		{cfg.date_names.en.season, cfg.date_names.inv_local_season},			-- season date nam
		{cfg.date_names.en.named, cfg.date_names.inv_local_named},				-- named dates
		}

	local function is_xlateable (month)											-- local function to get local date name that replaces existing English-language date name
		for _, date_names_t in ipairs (sources_t) do							-- for each sequence table in date_names_t
			if date_names_t[1][month] then										-- if date name is English month (long or short), quarter, season or named and
				if date_names_t[2][date_names_t[1][month]] then					-- if there is a matching local date name
					return date_names_t[2][date_names_t[1][month]];				-- return the local date name
				end
			end
		end
	end

	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val.val) then											-- if the parameter has a value
			date = param_val.val;
			for month in mw.ustring.gmatch (date, '[%a ]+') do					-- iterate through all date names in the date (single date or date range)
				month = mw.text.trim (month);									-- this because quarterly dates contain whitespace
				xlate = is_xlateable (month);									-- get translate &lt;month&gt;; returns translation or nil
				
--				if cfg.date_names.en.long[month] then							-- long month dates
--					if cfg.date_names.inv_local_long[cfg.date_names.en.long[month]] then
--						xlate = cfg.date_names.inv_local_long[cfg.date_names.en.long[month]];
--					end
----					mode = 'F';													-- English name is long so use long local name
--				elseif cfg.date_names.en.short[month] then						-- short month dates
--					if cfg.date_names.inv_local_short[cfg.date_names.en.short[month]] then
--						xlate = cfg.date_names.inv_local_short[cfg.date_names.en.short[month]];
--					end
----					mode = 'M';													-- English name is short so use short local name
--				elseif cfg.date_names.en.quarter[month] then					-- quarter dates
--					if cfg.date_names.inv_local_quarter[cfg.date_names.en.quarter[month]] then
--						xlate = cfg.date_names.inv_local_quarter[cfg.date_names.en.quarter[month]];
--					end
--				elseif cfg.date_names.en.season[month] then						-- season dates
--					if cfg.date_names.inv_local_season[cfg.date_names.en.season[month]] then
--						xlate = cfg.date_names.inv_local_season[cfg.date_names.en.season[month]];
--					end
--				elseif cfg.date_names.en.named[month] then						-- named dates
--					if cfg.date_names.inv_local_named[cfg.date_names.en.named[month]] then
--						xlate = cfg.date_names.inv_local_named[cfg.date_names.en.named[month]];
--					end
--				else
--					xlate=nil;													-- not an English month name; could be local language month name
----					mode = nil;													-- not an English month name; could be local language month name or an English season name
--				end

				if xlate then		
--				if mode then													-- might be a season
--					xlate = lang_object:formatDate(mode, '1' .. month);			-- translate the month name to this local language
					date = mw.ustring.gsub (date, month, xlate);				-- replace the English with the translation
					date_parameters_list[param_name].val = date;				-- save the translated date
					modified = true;
				end
			end

			if xlt_dig then														-- shall we also translate digits?
				date = date:gsub ('%d', cfg.date_names.xlate_digits);			-- translate digits from Western to 'local digits'
				date_parameters_list[param_name].val = date;					-- save the translated date
				modified = true;
			end
		end
	end
	
	return modified;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	add_prop_cat = utilities_page_ptr.add_prop_cat ;							-- import functions from selected Module:Citation/CS1/Utilities module
	is_set = utilities_page_ptr.is_set;
	in_array = utilities_page_ptr.in_array;
	set_message = utilities_page_ptr.set_message;
	substitute = utilities_page_ptr.substitute;
	wrap_style = utilities_page_ptr.wrap_style;

	cfg = cfg_table_ptr;														-- import tables from selected Module:Citation/CS1/Configuration
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {																		-- return exported functions
	dates = dates,
	year_date_check = year_date_check,
	reformat_dates = reformat_dates,
	date_hyphen_to_dash = date_hyphen_to_dash,
	date_name_xlate = date_name_xlate,
	set_selected_modules = set_selected_modules
	}</text>
      <sha1>obboarlfkmx4zbge5gqjllttddlxljn</sha1>
    </revision>
    <revision>
      <id>4855</id>
      <parentid>4854</parentid>
      <timestamp>2023-01-14T14:43:40Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4855</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="63803" sha1="8a90tdzc01kru5rn12zzcqdyok84u39" xml:space="preserve">--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local add_prop_cat, is_set, in_array, set_message, substitute, wrap_style;		-- imported functions from selected Module:Citation/CS1/Utilities
local cfg;																		-- table of tables imported from selected Module:Citation/CS1/Configuration


--[[--------------------------&lt; F I L E - S C O P E   D E C L A R A T I O N S &gt;--------------------------------

File-scope variables are declared here

]]

local lang_object = mw.getContentLanguage();									-- used by is_valid_accessdate(), is_valid_year(), date_name_xlate(); TODO: move to ~/Configuration?
local year_limit;																-- used by is_valid_year()


--[=[-------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |access-date= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-English date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate().  To get around that
call this function with YYYY-MM-DD format dates.

]=]

local function is_valid_accessdate (accessdate)
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold Unix time stamps representing the dates

	good1, access_ts = pcall (lang_object.formatDate, lang_object, 'U', accessdate );			-- convert accessdate value to Unix timestamp 
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which which tonumber() may not understand
		access_ts = tonumber (access_ts) or lang_object:parseFormattedNumber (access_ts);		-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to Unix time stamp
	end

	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end


--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct.
If not a valid month, returns 0

]]

local function get_month_number (month)
	return cfg.date_names['local'].long[month] or cfg.date_names['local'].short[month] or	-- look for local names first
			cfg.date_names['en'].long[month] or	cfg.date_names['en'].short[month] or		-- failing that, look for English names
			0;																				-- not a recognized month name
end


--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 21 for Spring, etc.  Capitalization and spelling
must be correct. If not a valid season, returns 0.
	21-24 = Spring, Summer, Autumn, Winter, independent of “Hemisphere”

returns 0 when &lt;param&gt; is not |date=

Season numbering is defined by Extended Date/Time Format (EDTF) specification (https://www.loc.gov/standards/datetime/)
which became part of ISO 8601 in 2019.  See '§Sub-year groupings'.  The standard defines various divisions using
numbers 21-41.  cs1|2 only supports generic seasons.  EDTF does support the distinction between north and south
hemisphere seasons but cs1|2 has no way to make that distinction.

These additional divisions not currently supported:
	25-28 = Spring - Northern Hemisphere, Summer- Northern Hemisphere, Autumn - Northern Hemisphere, Winter - Northern Hemisphere
	29-32 = Spring – Southern Hemisphere, Summer– Southern Hemisphere, Autumn – Southern Hemisphere, Winter - Southern Hemisphere
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)

]]

local function get_season_number (season, param)
	if 'date' ~= param then
		return 0;																-- season dates only supported by |date=
	end
	return cfg.date_names['local'].season[season] or							-- look for local names first
			cfg.date_names['en'].season[season] or								-- failing that, look for English names
			0;																	-- not a recognized season name
end


--[[--------------------------&lt; G E T _ Q U A R T E R _ N U M B E R &gt;------------------------------------------

returns a number according to the sequence of quarters in a year: 33 for first quarter, etc.  Capitalization and spelling
must be correct. If not a valid quarter, returns 0.
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)

returns 0 when &lt;param&gt; is not |date=

Quarter numbering is defined by Extended Date/Time Format (EDTF) specification (https://www.loc.gov/standards/datetime/)
which became part of ISO 8601 in 2019.  See '§Sub-year groupings'.  The standard defines various divisions using
numbers 21-41.  cs1|2 only supports generic seasons and quarters.

These additional divisions not currently supported:
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)

]]

local function get_quarter_number (quarter, param)
	if 'date' ~= param then
		return 0;																-- quarter dates only supported by |date=
	end
	quarter = mw.ustring.gsub (quarter, ' +', ' ');								-- special case replace multiple space chars with a single space char
	return cfg.date_names['local'].quarter[quarter] or							-- look for local names first
			cfg.date_names['en'].quarter[quarter] or							-- failing that, look for English names
			0;																	-- not a recognized quarter name
end


--[[--------------------------&lt; G E T _ P R O P E R _ N A M E _ N U M B E R &gt;----------------------------------

returns a non-zero number if date contains a recognized proper-name.  Capitalization and spelling must be correct.

returns 0 when &lt;param&gt; is not |date=

]]

local function get_proper_name_number (name, param)
	if 'date' ~= param then
		return 0;																-- proper-name dates only supported by |date=
	end
	return cfg.date_names['local'].named[name] or								-- look for local names dates first
			cfg.date_names['en'].named[name] or									-- failing that, look for English names
			0;																	-- not a recognized named date
end


--[[--------------------------&lt; G E T _ E L E M E N T _ N U M B E R &lt;------------------------------------------

returns true if month or season or quarter or proper name is valid (properly spelled, capitalized, abbreviated)

]]

local function get_element_number (element, param)
	local num;
	
	local funcs = {get_month_number, get_season_number, get_quarter_number, get_proper_name_number};	-- list of functions to execute in order
	
	for _, func in ipairs (funcs) do											-- spin through the function list
		num = func (element, param);											-- call the function and get the returned number
		if 0 ~= num then														-- non-zero when valid month season quarter 
			return num;															-- return that number
		end
	end
	return nil;																	-- not valid
end


--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one
year in the future are not acceptable.

Special case for |pmc-embargo-date=: years more than two years in the future are not acceptable

]]

local function is_valid_year (year, param)
	if not is_set (year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;									-- global variable so we only have to fetch it once
	end

	year = tonumber (year) or lang_object:parseFormattedNumber (year);			-- convert to number for the comparison;
	
	if 'pmc-embargo-date' == param then											-- special case for |pmc-embargo-date=
		return year and (year &lt;= tonumber(os.date(&quot;%Y&quot;))+2) or false;			-- years more than two years in the future are not accepted
	end	
	return year and (year &lt;= year_limit) or false;
end


--[[--------------------------&lt; I S _ V A L I D _ D A T E &gt;----------------------------------------------------

Returns true if day is less than or equal to the number of days in month and year is no farther into the future
than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap
years before 1582 and Gregorian leap years after 1582. Where the two calendars overlap (1582 to approximately
1923) dates are assumed to be Gregorian.

]]

local function is_valid_date (year, month, day, param)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year (year, param) then										-- no farther into the future than next year except |pmc-embargo-date= no more than two years in the future
		return false;
	end
	
	month = tonumber (month);													-- required for YYYY-MM-DD dates
	
	if (2 == month) then														-- if February
		month_length = 28;														-- then 28 days unless
		if 1582 &gt; tonumber(year) then											-- Julian calendar
			if 0 == (year%4) then												-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		else																	-- Gregorian calendar
			if (0 == (year%4) and (0 ~= (year%100) or 0 == (year%400))) then	-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		end
	else
		month_length = days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
This function looks in cfg.date_names{} to see if both month names are listed in the long subtable or both are
listed in the short subtable.  When both have the same style (both are listed in the same table), returns true; false else

]]

local function is_valid_month_range_style (month1, month2)
	if (cfg.date_names.en.long[month1] and cfg.date_names.en.long[month2]) or					-- are both English names listed in the long subtable?
		(cfg.date_names.en.short[month1] and cfg.date_names.en.short[month2]) or				-- are both English names listed in the short subtable?
		(cfg.date_names['local'].long[month1] and cfg.date_names['local'].long[month2]) or		-- are both local names listed in the long subtable?
		(cfg.date_names['local'].short[month1] and cfg.date_names['local'].short[month2]) then	-- are both local names listed in the short subtable?
			return true;
	end
	return false;																-- names are mixed
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

All season ranges are accepted as valid because there are publishers out there who have published a Summer–Spring YYYY issue, hence treat as ok

]]

local function is_valid_month_season_range(range_start, range_end, param)
	local range_start_number = get_month_number (range_start);
	local range_end_number;

	if 0 == range_start_number then												-- is this a month range?
		range_start_number = get_season_number (range_start, param);			-- not a month; is it a season? get start season number
		range_end_number = get_season_number (range_end, param);				-- get end season number

		if (0 ~= range_start_number) and (0 ~= range_end_number) and (range_start_number ~= range_end_number) then
			return true;														-- any season pairing is accepted except when both are the same
		end
		return false;															-- range_start and/or range_end is not a season
	end
																				-- here when range_start is a month
	range_end_number = get_month_number (range_end);							-- get end month number
	if range_start_number &lt; range_end_number and								-- range_start is a month; does range_start precede range_end?
		is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
	end
	return false;																-- range_start month number is greater than or equal to range end number; or range end isn't a month
end


--[[--------------------------&lt; M A K E _ C O I N S _ D A T E &gt;------------------------------------------------

This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1.  The function is called only for |date= parameters and only if the |date=&lt;value&gt; is 
determined to be a valid date format.  The question of what to do with invalid date formats is not answered here.

The date parts in the input table are converted to an ISO 8601 conforming date string:
	single whole dates:		yyyy-mm-dd
	month and year dates:	yyyy-mm
	year dates:				yyyy
	ranges:					yyyy-mm-dd/yyyy-mm-dd
							yyyy-mm/yyyy-mm
							yyyy/yyyy

Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.

The input table has:
	year, year2 – always present; if before 1582, ignore months and days if present
	month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 99 Christmas
	day, day2 –  0 if not provided, 1-31 for days
	
the output table receives:
	rftdate:	an ISO 8601 formatted date
	rftchron:	a free-form version of the date, usually without year which is in rftdate (season ranges and proper-name dates)
	rftssn:		one of four season keywords: winter, spring, summer, fall (lowercase)
	rftquarter:	one of four values: 1, 2, 3, 4

]]

local function make_COinS_date (input, tCOinS_date)
	local date;																	-- one date or first date in a range
	local date2 = '';															-- end of range date
-- start temporary Julian / Gregorian calendar uncertainty detection
	local year = tonumber(input.year);											-- this temporary code to determine the extent of sources dated to the Julian/Gregorian
	local month = tonumber(input.month);										-- interstice 1 October 1582 – 1 January 1926
	local day = tonumber (input.day);
	if (0 ~= day) and															-- day must have a value for this to be a whole date
		(((1582 == year) and (10 &lt;= month) and (12 &gt;= month)) or				-- any whole 1582 date from 1 October to 31 December or
			((1926 == year) and (1 == month) and (1 == input.day)) or			-- 1 January 1926 or
				((1582 &lt; year) and (1925 &gt;= year))) then						-- any date 1 January 1583 – 31 December 1925
					tCOinS_date.inter_cal_cat = true;							-- set category flag true
	end
-- end temporary Julian / Gregorian calendar uncertainty detection
	
	if 1582 &gt; tonumber(input.year) or 20 &lt; tonumber(input.month) then			-- Julian calendar or season so &amp;rft.date gets year only
		date = input.year;
		if 0 ~= input.year2 and input.year ~= input.year2 then					-- if a range, only the second year portion when not the same as range start year
			date = string.format ('%.4d/%.4d', tonumber(input.year), tonumber(input.year2))		-- assemble the date range
		end
		if 20 &lt; tonumber(input.month) then										-- if season or proper-name date
			local season = {[24] = 'winter', [21] = 'spring', [22] = 'summer', [23] = 'fall', [33] = '1', [34] = '2', [35] = '3', [36] = '4', [98] = 'Easter', [99] = 'Christmas'};	-- seasons lowercase, no autumn; proper-names use title case
			if 0 == input.month2 then											-- single season date
				if 40 &lt; tonumber(input.month) then
					tCOinS_date.rftchron = season[input.month];					-- proper-name dates
				elseif 30 &lt; tonumber(input.month) then
					tCOinS_date.rftquarter = season[input.month];				-- quarters
				else
					tCOinS_date.rftssn = season[input.month];					-- seasons
				end
			else																-- season range with a second season specified
				if input.year ~= input.year2 then								-- season year – season year range or season year–year
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					if 0~= input.month2 then
						tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);
					end
				else															-- season–season year range
					tCOinS_date.rftssn = season[input.month];					-- start of range season; keep this?
					tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2];	-- season–season year range
				end
			end
		end
		tCOinS_date.rftdate = date;
		return;																	-- done
	end
	
	if 0 ~= input.day then
		date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day));	-- whole date
	elseif 0 ~= input.month then
		date = string.format ('%s-%.2d', input.year, tonumber(input.month));	-- year and month
	else
		date = string.format ('%s', input.year);								-- just year
	end

	if 0 ~= input.year2 then
		if 0 ~= input.day2 then
			date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2));		-- whole date
		elseif 0 ~= input.month2 then
			date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2));	-- year and month
		else
			date2 = string.format ('/%s', input.year2);							-- just year
		end
	end
	
	tCOinS_date.rftdate = date .. date2;										-- date2 has the '/' separator
	return;
end


--[[--------------------------&lt; P A T T E R N S &gt;--------------------------------------------------------------

this is the list of patterns for date formats that this module recognizes.  Approximately the first half of these
patterns represent formats that might be reformatted into another format.  Those that might be reformatted have
'indicator' letters that identify the content of the matching capture: 'd' (day), 'm' (month), 'a' (anchor year),
'y' (year); second day, month, year have a '2' suffix.

These patterns are used for both date validation and for reformatting.  This table should not be moved to ~/Configuration
because changes to this table require changes to check_date() and to reformatter() and reformat_date()

]]

local patterns = {
	 																			-- year-initial numerical year-month-day
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'},					
																				-- month-initial: month day, year
	['Mdy'] = {'^(%D-) +([1-9]%d?), +((%d%d%d%d?)%a?)$', 'm', 'd', 'a', 'y'},
																				-- month-initial day range: month day–day, year; days are separated by endash
	['Md-dy'] = {'^(%D-) +([1-9]%d?)[%-–]([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'd2', 'a', 'y'},
																				-- day-initial: day month year
	['dMy'] = {'^([1-9]%d?) +(%D-) +((%d%d%d%d?)%a?)$', 'd', 'm', 'a', 'y'},
																				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed; not supported at en.wiki
	--	['yMd'] = {'^((%d%d%d%d?)%a?) +(%D-) +(%d%d?)$', 'a', 'y', 'm', 'd'},
																				-- day-range-initial: day–day month year; days are separated by endash
	['d-dMy'] = {'^([1-9]%d?)[%-–]([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'd2', 'm', 'a', 'y'},
																				-- day initial month-day-range: day month - day month year; uses spaced endash
	['dM-dMy'] = {'^([1-9]%d?) +(%D-) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'd2', 'm2', 'a', 'y'},
																				-- month initial month-day-range: month day – month day, year;  uses spaced endash
	['Md-Mdy'] = {'^(%D-) +([1-9]%d?) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$','m', 'd', 'm2', 'd2', 'a', 'y'},
																				-- day initial month-day-year-range: day month year - day month year; uses spaced endash
	['dMy-dMy'] = {'^([1-9]%d?) +(%D-) +(%d%d%d%d) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'y', 'd2', 'm2', 'a', 'y2'},
																				-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
	['Mdy-Mdy'] = {'^(%D-) +([1-9]%d?), +(%d%d%d%d) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'y', 'm2', 'd2', 'a', 'y2'},

																				-- these date formats cannot be converted, per se, but month name can be rendered short or long
																				-- month/season year - month/season year; separated by spaced endash
	['My-My'] = {'^(%D-) +(%d%d%d%d) +[%-–] +(%D-) +((%d%d%d%d)%a?)$', 'm', 'y', 'm2', 'a', 'y2'},
																				-- month/season range year; months separated by endash
	['M-My'] = {'^(%D-)[%-–](%D-) +((%d%d%d%d)%a?)$', 'm', 'm2', 'a', 'y'},
																				-- month/season year or proper-name year; quarter year when First Quarter YYYY etc.
	['My'] = {'^([^%d–]-) +((%d%d%d%d)%a?)$', 'm', 'a', 'y'},					-- this way because endash is a member of %D; %D- will match January–March 2019 when it shouldn't

																				-- these date formats cannot be converted
	['Sy4-y2'] = {'^(%D-) +((%d%d)%d%d)[%-–]((%d%d)%a?)$'},						-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
	['Sy-y'] = {'^(%D-) +(%d%d%d%d)[%-–]((%d%d%d%d)%a?)$'},						-- special case Winter/Summer year-year; year separated with unspaced endash
	['y-y'] = {'^(%d%d%d%d?)[%-–]((%d%d%d%d?)%a?)$'},							-- year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
	['y4-y2'] = {'^((%d%d)%d%d)[%-–]((%d%d)%a?)$'},								-- year range: YYYY–YY; separated by unspaced endash
	['y'] = {'^((%d%d%d%d?)%a?)$'},												-- year; here accept either YYY or YYYY
	}


--[[--------------------------&lt; I S _ V A L I D _ E M B A R G O _ D A T E &gt;------------------------------------

returns true and date value if that value has proper dmy, mdy, ymd format.

returns false and 9999 (embargoed forever) when date value is not proper format; assumes that when |pmc-embargo-date= is
set, the editor intended to embargo a PMC but |pmc-embargo-date= does not hold a single date.

]]

local function is_valid_embargo_date (v)
	if v:match (patterns['ymd'][1]) or											-- ymd
		v:match (patterns['Mdy'][1]) or											-- dmy
		v:match (patterns['dMy'][1]) then										-- mdy
			return true, v;
	end
	return false, '9999';														-- if here not good date so return false and set embargo date to long time in future
end


--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only
allowed range separator is endash.  Additionally, check the date to see that it is a real date: no 31 in 30-day
months; no 29 February when not a leap year.  Months, both long-form and three character abbreviations, and seasons
must be spelled correctly.  Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and
COinS_date.  When this happens, the date parameter is (DEBUG: not?) used in the COinS metadata and the CITEREF identifier gets
its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, publication-date, access-date, pmc-embargo-date, archive-date, lay-date)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is ISO 8601 format date; see make_COInS_date()

]]

local function check_date (date_string, param, tCOinS_date)
	local year;																	-- assume that year2, months, and days are not used;
	local year2 = 0;															-- second year in a year range
	local month = 0;
	local month2 = 0;															-- second month in a month range
	local day = 0;
	local day2 = 0;																-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match (patterns['ymd'][1]) then								-- year-initial numerical year month day format
		year, month, day = date_string:match (patterns['ymd'][1]);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or 0 == tonumber(day) then return false; end	-- month or day number not valid or not Gregorian calendar
		anchor_year = year;
	
	elseif mw.ustring.match(date_string, patterns['Mdy'][1]) then				-- month-initial: month day, year
		month, day, anchor_year, year = mw.ustring.match(date_string, patterns['Mdy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
				
	elseif mw.ustring.match(date_string, patterns['Md-dy'][1]) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year = mw.ustring.match(date_string, patterns['Md-dy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2=month;															-- for metadata
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['dMy'][1]) then				-- day-initial: day month year
		day, month, anchor_year, year = mw.ustring.match(date_string, patterns['dMy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months

--[[ NOT supported at en.wiki
	elseif mw.ustring.match(date_string, patterns['yMd'][1]) then				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed
		anchor_year, year, month, day = mw.ustring.match(date_string, patterns['yMd'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
-- end NOT supported at en.wiki ]]

	elseif mw.ustring.match(date_string, patterns['d-dMy'][1]) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year = mw.ustring.match(date_string, patterns['d-dMy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2 = month;															-- for metadata
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['dM-dMy'][1]) then			-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year = mw.ustring.match(date_string, patterns['dM-dMy'][1]);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['Md-Mdy'][1]) then			-- month initial month-day-range: month day – month day, year; uses spaced endash
		month, day, month2, day2, anchor_year, year = mw.ustring.match(date_string, patterns['Md-Mdy'][1]);
		if (not is_valid_month_season_range(month, month2, param)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['dMy-dMy'][1]) then			-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2 = mw.ustring.match(date_string, patterns['dMy-dMy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		if 0 == month or 0 == month2 then return false; end						-- both must be valid

	elseif mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]) then			-- month initial month-day-year-range: month day, year – month day, year; uses spaced endash
		month, day, year, month2, day2, anchor_year, year2 = mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number(month2);
		if 0 == month or 0 == month2 then return false; end						-- both must be valid

	elseif mw.ustring.match(date_string, patterns['Sy4-y2'][1]) then			-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		local century;
		month, year, century, anchor_year, year2 = mw.ustring.match(date_string, patterns['Sy4-y2'][1]);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;		-- 'month' can only be Winter or Summer
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor_year from both years
		year2 = century..year2;													-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		month = get_season_number(month, param);

	elseif mw.ustring.match(date_string, patterns['Sy-y'][1]) then				-- special case Winter/Summer year-year; year separated with unspaced endash
		month, year, anchor_year, year2 = mw.ustring.match(date_string, patterns['Sy-y'][1]);
		month = get_season_number (month, param);								-- &lt;month&gt; can only be winter or summer; also for metadata
		if (month ~= cfg.date_names['en'].season['Winter']) and (month ~= cfg.date_names['en'].season['Summer']) then
			return false;														-- not Summer or Winter; abandon
		end
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, patterns['My-My'][1]) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2 = mw.ustring.match(date_string, patterns['My-My'][1]);
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then 	-- both must be month year, same month style
			month = get_month_number(month);
			month2 = get_month_number(month2);
		elseif 0 ~= get_season_number(month, param) and 0 ~= get_season_number(month2, param) then	-- both must be season year, not mixed
			month = get_season_number(month, param);
			month2 = get_season_number(month2, param);
		else
			 return false;
		end

	elseif mw.ustring.match(date_string, patterns['M-My'][1]) then				-- month/season range year; months separated by endash 
		month, month2, anchor_year, year = mw.ustring.match(date_string, patterns['M-My'][1]);
		if (not is_valid_month_season_range(month, month2, param)) or (not is_valid_year(year)) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
			month2 = get_month_number(month2);
			if 0 == month or 0 == month2 then return false; end
		else
			month = get_season_number(month, param);
			month2 = get_season_number(month2, param);
		end
		year2 = year;
		
	elseif mw.ustring.match(date_string, patterns['My'][1]) then				-- month/season/quarter/proper-name year
		month, anchor_year, year = mw.ustring.match(date_string, patterns['My'][1]);
		if not is_valid_year(year) then return false; end
		month = get_element_number(month, param);								-- get month season quarter proper-name number or nil
		if not month then return false; end										-- not valid whatever it is

	elseif mw.ustring.match(date_string, patterns['y-y'][1]) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2 = mw.ustring.match(date_string, patterns['y-y'][1]);
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, patterns['y4-y2'][1]) then				-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2 = mw.ustring.match(date_string, patterns['y4-y2'][1]);
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor year from both years

		if in_array (param, {'date', 'publication-date', 'year'}) then
			add_prop_cat ('year-range-abbreviated');
		end

		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century .. year2;												-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, patterns['y'][1]) then					-- year; here accept either YYY or YYYY
		anchor_year, year = mw.ustring.match(date_string, patterns['y'][1]);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;															-- date format not one of the MOS:DATE approved formats
	end

	if param ~= 'date' then														-- CITEREF disambiguation only allowed in |date=; |year= &amp; |publication-date= promote to date
		if anchor_year:match ('%l$') then
			return false;
		end
	end

	if 'access-date' == param then												-- test accessdate here because we have numerical date parts
		if 0 ~= year and 0 ~= month and 0 ~= day and 							-- all parts of a single date required
			0 == year2 and 0 == month2 and 0 == day2 then						-- none of these; accessdate must not be a range
				if not is_valid_accessdate(year .. '-' .. month .. '-' .. day) then	
					return false;												-- return false when accessdate out of bounds
				end
		else
			return false;														-- return false when accessdate is a range of two dates
		end
	end

	local result=true;															-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result = is_valid_date (year, month, day, param);						-- &lt;param&gt; for |pmc-embargo-date=

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result = is_valid_date (year, month, day);
		result = result and is_valid_date (year, month, day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result = is_valid_date (year, month, day);
		result = result and is_valid_date (year, month2, day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result = is_valid_date(year, month, day);
		result = result and is_valid_date(year2, month2, day2);
	end
	
	if false == result then return false; end

	if nil ~= tCOinS_date then													-- this table only passed into this function when testing |date= parameter values
		make_COinS_date ({year = year, month = month, day = day, year2 = year2, month2 = month2, day2 = day2}, tCOinS_date);	-- make an ISO 8601 date string for COinS
	end
	
	return true, anchor_year;													-- format is good and date string represents a real date
end	


--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
parameters with errors are added to the &lt;error_list&gt; sequence table as the dates are tested.

]]

local function dates(date_parameters_list, tCOinS_date, error_list)
	local anchor_year;															-- will return as nil if the date being tested is not |date=
	local COinS_date;															-- will return as nil if the date being tested is not |date=
	local embargo_date;															-- if embargo date is a good dmy, mdy, ymd date then holds original value else reset to 9999
	local good_date = false;

	for k, v in pairs(date_parameters_list) do									-- for each date-holding parameter in the list
		if is_set(v.val) then													-- if the parameter has a value
			v.val = mw.ustring.gsub(v.val, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9
			if v.val:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then						-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v.val:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);				-- get the year portion so it can be tested
				if 'date' == k then
					anchor_year, COinS_date = v.val:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year' == k then
					good_date = is_valid_year(year);
				end
			elseif 'date' == k then												-- if the parameter is |date=
				if v.val:match(&quot;^n%.d%.%a?$&quot;) then -- ToDo: I18N								-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((n%.d%.)%a?)&quot;); -- ToDo: I18N	-- &quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v.val:match(&quot;^nd%a?$&quot;) then -- ToDo: I18N								-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((nd)%a?)&quot;); -- ToDo: I18N	-- &quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v.val, k, tCOinS_date);	-- go test the date
				end
			elseif 'year' == k then												-- if the parameter is |year= it should hold only a year value
				if v.val:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then						-- if |year = 3 or 4 digits only with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((%d+)%a?)&quot;);
				end
			elseif 'pmc-embargo-date' == k then									-- if the parameter is |pmc-embargo-date=
				good_date = check_date (v.val, k);								-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date, embargo_date = is_valid_embargo_date (v.val);	-- is |pmc-embargo-date= date a single dmy, mdy, or ymd formatted date? yes: returns embargo date; no: returns 9999
				end
			else																-- any other date-holding parameter
				good_date = check_date (v.val, k);								-- go test the date
			end
			if false == good_date then											-- assemble one error message so we don't add the tracking category multiple times
				table.insert (error_list, wrap_style ('parameter', v.name));	-- make parameter name suitable for error message list
			end
		end
	end
	return anchor_year, embargo_date;											-- and done
end


--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function sets a local numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

the numeric value in &lt;result&gt; determines the 'output' if any from this function:
	0 – adds error message to error_list sequence table
	1 – adds maint cat
	2 – does nothing

]]

local function year_date_check (year_string, year_origin, date_string, date_origin, error_list)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes

	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where both date and year are required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard range formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif mw.ustring.match(date_string, &quot;%d%d%d%d[%-–]%d%d&quot;) then				-- YYYY-YY date ranges
		local century;
		date1, century, date2 = mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	else																		-- should never get here; this function called only when no other date errors
		result = 0;																-- no recognizable year in date
	end

	if 0 == result then															-- year / date mismatch
		table.insert (error_list, substitute (cfg.messages['mismatch'], {year_origin, date_origin}));	-- add error message to error_list sequence table
	elseif 1 == result then														-- redundant year / date
		set_message ('maint_date_year');										-- add a maint cat
	end
end


--[[--------------------------&lt; R E F O R M A T T E R &gt;--------------------------------------------------------

reformat 'date' into new format specified by format_param if pattern_idx (the current format of 'date') can be
reformatted.  Does the grunt work for reformat_dates().

The table re_formats maps pattern_idx (current format) and format_param (desired format) to a table that holds:
	format string used by string.format()
	identifier letters ('d', 'm', 'y', 'd2', 'm2', 'y2') that serve as indexes into a table t{} that holds captures
		from mw.ustring.match() for the various date parts specified by  patterns[pattern_idx][1]

Items in patterns{} have the general form:
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'}, where:
		['ymd'] is pattern_idx
		patterns['ymd'][1] is the match pattern with captures for mw.ustring.match()
		patterns['ymd'][2] is an indicator letter identifying the content of the first capture
		patterns['ymd'][3] ... the second capture etc.

when a pattern matches a date, the captures are loaded into table t{} in capture order using the idemtifier
characters as indexes into t{}  For the above, a ymd date is in t{} as:
	t.y = first capture (year), t.m = second capture (month), t.d = third capture (day)

To reformat, this function is called with the pattern_idx that matches the current format of the date and with
format_param set to the desired format.  This function loads table t{} as described and then calls string.format()
with the format string specified by re_format[pattern_idx][format_param][1] using values taken from t{} according
to the capture identifier letters specified by patterns[pattern_idx][format_param][n] where n is 2..

]]

local re_formats = {
	['ymd'] = {																	-- date format is ymd; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
	--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},								-- |df=yMd; not supported at en.wiki
		},
	['Mdy'] = {																	-- date format is Mdy; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- for long/short reformatting
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
	--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},								-- |df=yMd; not supported at en.wiki
		},
	['dMy'] = {																	-- date format is dMy; reformat to:
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- for long/short reformatting
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
	--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},								-- |df=yMd; not supported at en.wiki
		},
	['Md-dy'] = {																-- date format is Md-dy; reformat to:
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- for long/short reformatting
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- |df=dmy -&gt; d-dMy 
		},
	['d-dMy'] = {																-- date format is d-d&gt;y; reformat to:
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- for long/short reformatting
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- |df=mdy -&gt; Md-dy 
		},
	['dM-dMy'] = {																-- date format is dM-dMy; reformat to:
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- for long/short reformatting
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd', 'm2', 'd2', 'y'},				-- |df=mdy -&gt; Md-Mdy 
		},
	['Md-Mdy'] = {																-- date format is Md-Mdy; reformat to:
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd',  'm2', 'd2', 'y'},			-- for long/short reformatting
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- |df=dmy -&gt; dM-dMy 
		},
	['dMy-dMy'] = {																-- date format is dMy-dMy; reformat to:
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- for long/short reformatting
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- |df=mdy -&gt; Mdy-Mdy 
		},
	['Mdy-Mdy'] = {																-- date format is Mdy-Mdy; reformat to:
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- for long/short reformatting
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- |df=dmy -&gt; dMy-dMy 
		},
	['My-My'] = {																-- these for long/short reformatting
		['any'] = {'%s %s – %s %s', 'm', 'y', 'm2', 'y2'},						-- dmy/mdy agnostic
		},
	['M-My'] = {																-- these for long/short reformatting
		['any'] = {'%s–%s %s', 'm', 'm2', 'y'},									-- dmy/mdy agnostic
		},
	['My'] = {																	-- these for long/short reformatting
		['any'] = {'%s %s', 'm', 'y'},											-- dmy/mdy agnostic
		},
	--	['yMd'] = {																-- not supported at en.wiki
	--		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},								-- |df=mdy
	--		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},								-- |df=dmy
	--		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},								-- |df=ymd
	--		},
	}


local function reformatter (date, pattern_idx, format_param, mon_len)
	if not in_array (pattern_idx, {'ymd', 'Mdy', 'Md-dy', 'dMy', 'yMd', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- not in this set of date format patterns then not a reformattable date
	end
	
	if 'ymd' == format_param and in_array (pattern_idx, {'ymd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- ymd date ranges not supported at en.wiki; no point in reformatting ymd to ymd
	end

	if in_array (pattern_idx, {'My', 'M-My', 'My-My'}) then						-- these are not dmy/mdy so can't be 'reformatted' into either
		format_param = 'any';													-- so format-agnostic 
	end

																				-- yMd is not supported at en.wiki; when yMd is supported at your wiki, uncomment the next line
	--	if 'yMd' == format_param and in_array (pattern_idx, {'yMd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy'}) then	-- these formats not convertable; yMd not supported at en.wiki
	if 'yMd' == format_param then												-- yMd not supported at en.wiki; when yMd is supported at your wiki, remove or comment-out this line
		return;																	-- not a reformattable date
	end
	
	local c1, c2, c3, c4, c5, c6, c7;											-- these hold the captures specified in patterns[pattern_idx][1]
	c1, c2, c3, c4, c5, c6, c7 = mw.ustring.match (date, patterns[pattern_idx][1]);	-- get the captures

	local t = {																	-- table that holds k/v pairs of date parts from the captures and patterns[pattern_idx][2..]
		[patterns[pattern_idx][2]] = c1;										-- at minimum there is always one capture with a matching indicator letter
		[patterns[pattern_idx][3] or 'x'] = c2;									-- patterns can have a variable number of captures; each capture requires an indicator letter;
		[patterns[pattern_idx][4] or 'x'] = c3;									-- where there is no capture, there is no indicator letter so n in patterns[pattern_idx][n] will be nil;
		[patterns[pattern_idx][5] or 'x'] = c4;									-- the 'x' here spoofs an indicator letter to prevent 'table index is nil' error
		[patterns[pattern_idx][6] or 'x'] = c5;
		[patterns[pattern_idx][7] or 'x'] = c6;
		[patterns[pattern_idx][8] or 'x'] = c7;
		};

	if t.a then																	-- if this date has an anchor year capture (all convertable date formats except ymd)
		if t.y2 then															-- for year range date formats														
			t.y2 = t.a;															-- use the anchor year capture when reassembling the date
		else																	-- here for single date formats (except ymd)
			t.y = t.a;															-- use the anchor year capture when reassembling the date
		end
	end

	if tonumber(t.m) then														-- if raw month is a number (converting from ymd)
		if 's' == mon_len then													-- if we are to use abbreviated month names
			t.m = cfg.date_names['inv_local_short'][tonumber(t.m)];					-- convert it to a month name
		else
			t.m = cfg.date_names['inv_local_long'][tonumber(t.m)];					-- convert it to a month name
		end
		t.d = t.d:gsub ('0(%d)', '%1');											-- strip leading '0' from day if present
	elseif 'ymd' == format_param then											-- when converting to ymd
		t.y = t.y:gsub ('%a', '');												-- strip CITREF disambiguator if present; anchor year already known so process can proceed; TODO: maint message?
		if 1582 &gt; tonumber (t.y) then											-- ymd format dates not allowed before 1582
			return;
		end
		t.m = string.format ('%02d', get_month_number (t.m));					-- make sure that month and day are two digits
		t.d = string.format ('%02d', t.d);
	elseif mon_len then															-- if mon_len is set to either 'short' or 'long'
		for _, mon in ipairs ({'m', 'm2'}) do									-- because there can be two month names, check both 
			if t[mon] then
				t[mon] = get_month_number (t[mon]);								-- get the month number for this month (is length agnostic)
				if 0 == t[mon] then return; end									-- seasons and named dates can't be converted
				t[mon] = (('s' == mon_len) and cfg.date_names['inv_local_short'][t[mon]]) or cfg.date_names['inv_local_long'][t[mon]];	-- fetch month name according to length
			end
		end
	end

	local new_date = string.format (re_formats[pattern_idx][format_param][1],	-- format string
		t[re_formats[pattern_idx][format_param][2]],							-- named captures from t{}
		t[re_formats[pattern_idx][format_param][3]],
		t[re_formats[pattern_idx][format_param][4]],
		t[re_formats[pattern_idx][format_param][5]],
		t[re_formats[pattern_idx][format_param][6]],
		t[re_formats[pattern_idx][format_param][7]],
		t[re_formats[pattern_idx][format_param][8]]
		);

	return new_date;
end


--[[-------------------------&lt; R E F O R M A T _ D A T E S &gt;--------------------------------------------------

Reformats existing dates into the format specified by format.

format is one of several manual keywords: dmy, dmy-all, mdy, mdy-all, ymd, ymd-all.  The -all version includes
access- and archive-dates; otherwise these dates are not reformatted.

This function allows automatic date formatting.  In ~/Configuration, the article source is searched for one of
the {{use xxx dates}} templates.  If found, xxx becomes the global date format as xxx-all.  If |cs1-dates= in
{{use xxx dates}} has legitimate value then that value determines how cs1|2 dates will be rendered.  Legitimate
values for |cs1-dates= are:
	l - all dates are rendered with long month names
	ls - publication dates use long month names; access-/archive-dates use abbreviated month names
	ly - publication dates use long month names; access-/archive-dates rendered in ymd format
	s - all dates are rendered with abbreviated (short) month names
	sy - publication dates use abbreviated month names; access-/archive-dates rendered in ymd format
	y - all dates are rendered in ymd format

the format argument for automatic date formatting will be the format specified by {{use xxx dates}} with the
value supplied by |cs1-dates so one of: xxx-l, xxx-ls, xxx-ly, xxx-s, xxx-sy, xxx-y, or simply xxx (|cs1-dates=
empty, omitted, or invalid) where xxx shall be either of dmy or mdy.

dates are extracted from date_parameters_list, reformatted (if appropriate), and then written back into the
list in the new format.  Dates in date_parameters_list are presumed here to be valid (no errors).  This function
returns true when a date has been reformatted, false else.  Actual reformatting is done by reformatter().

]]

local function reformat_dates (date_parameters_list, format)
	local all = false;															-- set to false to skip access- and archive-dates
	local len_p = 'l';															-- default publication date length shall be long
	local len_a = 'l';															-- default access-/archive-date length shall be long
	local result = false;
	local new_date;																
	
	if format:match('%a+%-all') then											-- manual df keyword; auto df keyword when length not specified in {{use xxx dates}}; 
		format = format:match('(%a+)%-all');									-- extract the format
		all = true;																-- all dates are long format dates because this keyword doesn't specify length
	elseif format:match('%a+%-[lsy][sy]?') then									-- auto df keywords; internal only
		all = true;																-- auto df applies to all dates; use length specified by capture len_p for all dates
		format, len_p, len_a = format:match('(%a+)%-([lsy])([sy]?)');			-- extract the format and length keywords
		if 'y' == len_p then													-- because allowed by MOS:DATEUNIFY (sort of) range dates and My dates not reformatted
			format = 'ymd';														-- override {{use xxx dates}}
		elseif (not is_set(len_a)) or (len_p == len_a) then						-- no access-/archive-date length specified or same length as publication dates then
			len_a = len_p;														-- in case len_a not set
		end
	end																			-- else only publication dates and they are long

	for param_name, param_val in pairs (date_parameters_list) do				-- for each date-holding parameter in the list
		if is_set (param_val.val) then											-- if the parameter has a value
			if not (not all and in_array (param_name, {'access-date', 'archive-date'})) then	-- skip access- or archive-date unless format is xxx-all; yeah, ugly; TODO: find a better way
				for pattern_idx, pattern in pairs (patterns) do
					if mw.ustring.match (param_val.val, pattern[1]) then
						if all and in_array (param_name, {'access-date', 'archive-date'}) then	-- if this date is an access- or archive-date
							new_date = reformatter (param_val.val, pattern_idx, (('y' == len_a) and 'ymd') or format, len_a);	-- choose ymd or dmy/mdy according to len_a setting
						else													-- all other dates
							new_date = reformatter (param_val.val, pattern_idx, format, len_p);
						end
						
						if new_date then										-- set when date was reformatted
							date_parameters_list[param_name].val = new_date;	-- update date in date list
							result = true;										-- and announce that changes have been made
						end
					end	-- if
				end		-- for
			end			-- if
		end				-- if
	end					-- for
	return result;																-- declare boolean result and done
end


--[[--------------------------&lt; D A T E _ H Y P H E N _ T O _ D A S H &gt;----------------------------------------

Loops through the list of date-holding parameters and converts any hyphen to an ndash.  Not called if the cs1|2
template has any date errors.

Modifies the date_parameters_list and returns true if hyphens are replaced, else returns false.

]]

local function date_hyphen_to_dash (date_parameters_list)
	local result = false;
	local n;
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set (param_val.val) and
			not mw.ustring.match (param_val.val, patterns.ymd[1]) then			-- for those that are not ymd dates (ustring because here digits may not be Western)
				param_val.val, n = param_val.val:gsub ('%-', '–');				-- replace any hyphen with ndash
				if 0 ~= n then
					date_parameters_list[param_name].val = param_val.val;		-- update the list
					result = true;
				end
		end
	end
	return result;																-- so we know if any hyphens were replaced
end


--[[-------------------------&lt; D A T E _ N A M E _ X L A T E &gt;------------------------------------------------

Attempts to translate English date names to local-language date names using names supplied by MediaWiki's
date parser function.  This is simple name-for-name replacement and may not work for all languages.

if xlat_dig is true, this function will also translate Western (English) digits to the local language's digits.
This will also translate ymd dates.

]]

local function date_name_xlate (date_parameters_list, xlt_dig)
	local xlate;
	local mode;																	-- long or short month names
	local modified = false;
	local date;
	
	local sources_t = {
		{cfg.date_names.en.long, cfg.date_names.inv_local_long},				-- for translating long English month names to long local month names
		{cfg.date_names.en.short, cfg.date_names.inv_local_short},				-- short month names
		{cfg.date_names.en.quarter, cfg.date_names.inv_local_quarter},			-- quarter date names
		{cfg.date_names.en.season, cfg.date_names.inv_local_season},			-- season date nam
		{cfg.date_names.en.named, cfg.date_names.inv_local_named},				-- named dates
		}

	local function is_xlateable (month)											-- local function to get local date name that replaces existing English-language date name
		for _, date_names_t in ipairs (sources_t) do							-- for each sequence table in date_names_t
			if date_names_t[1][month] then										-- if date name is English month (long or short), quarter, season or named and
				if date_names_t[2][date_names_t[1][month]] then					-- if there is a matching local date name
					return date_names_t[2][date_names_t[1][month]];				-- return the local date name
				end
			end
		end
	end

	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val.val) then											-- if the parameter has a value
			date = param_val.val;
			for month in mw.ustring.gmatch (date, '[%a ]+') do					-- iterate through all date names in the date (single date or date range)
				month = mw.text.trim (month);									-- this because quarterly dates contain whitespace
				xlate = is_xlateable (month);									-- get translate &lt;month&gt;; returns translation or nil
				
				if xlate then		
					date = mw.ustring.gsub (date, month, xlate);				-- replace the English with the translation
					date_parameters_list[param_name].val = date;				-- save the translated date
					modified = true;
				end
			end

			if xlt_dig then														-- shall we also translate digits?
				date = date:gsub ('%d', cfg.date_names.xlate_digits);			-- translate digits from Western to 'local digits'
				date_parameters_list[param_name].val = date;					-- save the translated date
				modified = true;
			end
		end
	end
	
	return modified;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	add_prop_cat = utilities_page_ptr.add_prop_cat ;							-- import functions from selected Module:Citation/CS1/Utilities module
	is_set = utilities_page_ptr.is_set;
	in_array = utilities_page_ptr.in_array;
	set_message = utilities_page_ptr.set_message;
	substitute = utilities_page_ptr.substitute;
	wrap_style = utilities_page_ptr.wrap_style;

	cfg = cfg_table_ptr;														-- import tables from selected Module:Citation/CS1/Configuration
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {																		-- return exported functions
	dates = dates,
	year_date_check = year_date_check,
	reformat_dates = reformat_dates,
	date_hyphen_to_dash = date_hyphen_to_dash,
	date_name_xlate = date_name_xlate,
	set_selected_modules = set_selected_modules
	}</text>
      <sha1>8a90tdzc01kru5rn12zzcqdyok84u39</sha1>
    </revision>
    <revision>
      <id>4856</id>
      <parentid>4855</parentid>
      <timestamp>2023-08-12T19:19:06Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4856</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="65847" sha1="h1et8hc4yy0nzlgfuigrj5tumodmw1t" xml:space="preserve">--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local add_prop_cat, is_set, in_array, set_message, substitute, wrap_style;		-- imported functions from selected Module:Citation/CS1/Utilities
local cfg;																		-- table of tables imported from selected Module:Citation/CS1/Configuration


--[[--------------------------&lt; F I L E - S C O P E   D E C L A R A T I O N S &gt;--------------------------------

File-scope variables are declared here

]]

local lang_object = mw.getContentLanguage();									-- used by is_valid_accessdate(), is_valid_year(), date_name_xlate(); TODO: move to ~/Configuration?
local year_limit;																-- used by is_valid_year()


--[=[-------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |access-date= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-English date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate().  To get around that
call this function with YYYY-MM-DD format dates.

]=]

local function is_valid_accessdate (accessdate)
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold Unix time stamps representing the dates

	good1, access_ts = pcall (lang_object.formatDate, lang_object, 'U', accessdate );			-- convert accessdate value to Unix timestamp 
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which which tonumber() may not understand
		access_ts = tonumber (access_ts) or lang_object:parseFormattedNumber (access_ts);		-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to Unix time stamp
	end

	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end


--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct.
If not a valid month, returns 0

]]

local function get_month_number (month)
	return cfg.date_names['local'].long[month] or cfg.date_names['local'].short[month] or	-- look for local names first
			cfg.date_names['en'].long[month] or	cfg.date_names['en'].short[month] or		-- failing that, look for English names
			0;																				-- not a recognized month name
end


--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 21 for Spring, etc.  Capitalization and spelling
must be correct. If not a valid season, returns 0.
	21-24 = Spring, Summer, Autumn, Winter, independent of “Hemisphere”

returns 0 when &lt;param&gt; is not |date=

Season numbering is defined by Extended Date/Time Format (EDTF) specification (https://www.loc.gov/standards/datetime/)
which became part of ISO 8601 in 2019.  See '§Sub-year groupings'.  The standard defines various divisions using
numbers 21-41.  cs1|2 only supports generic seasons.  EDTF does support the distinction between north and south
hemisphere seasons but cs1|2 has no way to make that distinction.

These additional divisions not currently supported:
	25-28 = Spring - Northern Hemisphere, Summer- Northern Hemisphere, Autumn - Northern Hemisphere, Winter - Northern Hemisphere
	29-32 = Spring – Southern Hemisphere, Summer– Southern Hemisphere, Autumn – Southern Hemisphere, Winter - Southern Hemisphere
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)

]]

local function get_season_number (season, param)
	if 'date' ~= param then
		return 0;																-- season dates only supported by |date=
	end
	return cfg.date_names['local'].season[season] or							-- look for local names first
			cfg.date_names['en'].season[season] or								-- failing that, look for English names
			0;																	-- not a recognized season name
end


--[[--------------------------&lt; G E T _ Q U A R T E R _ N U M B E R &gt;------------------------------------------

returns a number according to the sequence of quarters in a year: 33 for first quarter, etc.  Capitalization and spelling
must be correct. If not a valid quarter, returns 0.
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)

returns 0 when &lt;param&gt; is not |date=

Quarter numbering is defined by Extended Date/Time Format (EDTF) specification (https://www.loc.gov/standards/datetime/)
which became part of ISO 8601 in 2019.  See '§Sub-year groupings'.  The standard defines various divisions using
numbers 21-41.  cs1|2 only supports generic seasons and quarters.

These additional divisions not currently supported:
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)

]]

local function get_quarter_number (quarter, param)
	if 'date' ~= param then
		return 0;																-- quarter dates only supported by |date=
	end
	quarter = mw.ustring.gsub (quarter, ' +', ' ');								-- special case replace multiple space chars with a single space char
	return cfg.date_names['local'].quarter[quarter] or							-- look for local names first
			cfg.date_names['en'].quarter[quarter] or							-- failing that, look for English names
			0;																	-- not a recognized quarter name
end


--[[--------------------------&lt; G E T _ P R O P E R _ N A M E _ N U M B E R &gt;----------------------------------

returns a non-zero number if date contains a recognized proper-name.  Capitalization and spelling must be correct.

returns 0 when &lt;param&gt; is not |date=

]]

local function get_proper_name_number (name, param)
	if 'date' ~= param then
		return 0;																-- proper-name dates only supported by |date=
	end
	return cfg.date_names['local'].named[name] or								-- look for local names dates first
			cfg.date_names['en'].named[name] or									-- failing that, look for English names
			0;																	-- not a recognized named date
end


--[[--------------------------&lt; G E T _ E L E M E N T _ N U M B E R &lt;------------------------------------------

returns true if month or season or quarter or proper name is valid (properly spelled, capitalized, abbreviated)

]]

local function get_element_number (element, param)
	local num;
	
	local funcs = {get_month_number, get_season_number, get_quarter_number, get_proper_name_number};	-- list of functions to execute in order
	
	for _, func in ipairs (funcs) do											-- spin through the function list
		num = func (element, param);											-- call the function and get the returned number
		if 0 ~= num then														-- non-zero when valid month season quarter 
			return num;															-- return that number
		end
	end
	return nil;																	-- not valid
end


--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one
year in the future are not acceptable.

Special case for |pmc-embargo-date=: years more than two years in the future are not acceptable

]]

local function is_valid_year (year, param)
	if not is_set (year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;									-- global variable so we only have to fetch it once
	end

	year = tonumber (year) or lang_object:parseFormattedNumber (year);			-- convert to number for the comparison
	if year and (100 &gt; year) then												-- years less than 100 not supported
		return false;
	end
	
	if 'pmc-embargo-date' == param then											-- special case for |pmc-embargo-date=
		return year and (year &lt;= tonumber(os.date(&quot;%Y&quot;))+2) or false;			-- years more than two years in the future are not accepted
	end	
	return year and (year &lt;= year_limit) or false;
end


--[[--------------------------&lt; I S _ V A L I D _ D A T E &gt;----------------------------------------------------

Returns true if day is less than or equal to the number of days in month and year is no farther into the future
than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap
years before 1582 and Gregorian leap years after 1582. Where the two calendars overlap (1582 to approximately
1923) dates are assumed to be Gregorian.

]]

local function is_valid_date (year, month, day, param)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year (year, param) then										-- no farther into the future than next year except |pmc-embargo-date= no more than two years in the future
		return false;
	end
	
	month = tonumber (month);													-- required for YYYY-MM-DD dates
	
	if (2 == month) then														-- if February
		month_length = 28;														-- then 28 days unless
		if 1582 &gt; tonumber(year) then											-- Julian calendar
			if 0 == (year%4) then												-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		else																	-- Gregorian calendar
			if (0 == (year%4) and (0 ~= (year%100) or 0 == (year%400))) then	-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		end
	else
		month_length = days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
This function looks in cfg.date_names{} to see if both month names are listed in the long subtable or both are
listed in the short subtable.  When both have the same style (both are listed in the same table), returns true; false else

]]

local function is_valid_month_range_style (month1, month2)
	if (cfg.date_names.en.long[month1] and cfg.date_names.en.long[month2]) or					-- are both English names listed in the long subtable?
		(cfg.date_names.en.short[month1] and cfg.date_names.en.short[month2]) or				-- are both English names listed in the short subtable?
		(cfg.date_names['local'].long[month1] and cfg.date_names['local'].long[month2]) or		-- are both local names listed in the long subtable?
		(cfg.date_names['local'].short[month1] and cfg.date_names['local'].short[month2]) then	-- are both local names listed in the short subtable?
			return true;
	end
	return false;																-- names are mixed
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

All season ranges are accepted as valid because there are publishers out there who have published a Summer–Spring YYYY issue, hence treat as ok

]]

local function is_valid_month_season_range(range_start, range_end, param)
	local range_start_number = get_month_number (range_start);
	local range_end_number;

	if 0 == range_start_number then												-- is this a month range?
		range_start_number = get_season_number (range_start, param);			-- not a month; is it a season? get start season number
		range_end_number = get_season_number (range_end, param);				-- get end season number

		if (0 ~= range_start_number) and (0 ~= range_end_number) and (range_start_number ~= range_end_number) then
			return true;														-- any season pairing is accepted except when both are the same
		end
		return false;															-- range_start and/or range_end is not a season
	end
																				-- here when range_start is a month
	range_end_number = get_month_number (range_end);							-- get end month number
	if range_start_number &lt; range_end_number and								-- range_start is a month; does range_start precede range_end?
		is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
	end
	return false;																-- range_start month number is greater than or equal to range end number; or range end isn't a month
end


--[[--------------------------&lt; M A K E _ C O I N S _ D A T E &gt;------------------------------------------------

This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1.  The function is called only for |date= parameters and only if the |date=&lt;value&gt; is 
determined to be a valid date format.  The question of what to do with invalid date formats is not answered here.

The date parts in the input table are converted to an ISO 8601 conforming date string:
	single whole dates:		yyyy-mm-dd
	month and year dates:	yyyy-mm
	year dates:				yyyy
	ranges:					yyyy-mm-dd/yyyy-mm-dd
							yyyy-mm/yyyy-mm
							yyyy/yyyy

Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.

The input table has:
	year, year2 – always present; if before 1582, ignore months and days if present
	month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 99 Christmas
	day, day2 –  0 if not provided, 1-31 for days
	
the output table receives:
	rftdate:	an ISO 8601 formatted date
	rftchron:	a free-form version of the date, usually without year which is in rftdate (season ranges and proper-name dates)
	rftssn:		one of four season keywords: winter, spring, summer, fall (lowercase)
	rftquarter:	one of four values: 1, 2, 3, 4

]]

local function make_COinS_date (input, tCOinS_date)
	local date;																	-- one date or first date in a range
	local date2 = '';															-- end of range date
	input.year = tonumber (input.year) or lang_object:parseFormattedNumber (input.year);	-- language-aware tonumber()
	input.year2 = tonumber (input.year2) or lang_object:parseFormattedNumber (input.year2);	-- COinS dates are pseudo-ISO 8601 so convert to Arabic numerals

-- start temporary Julian / Gregorian calendar uncertainty detection
	local year = input.year;													-- this temporary code to determine the extent of sources dated to the Julian/Gregorian
	local month = tonumber(input.month);										-- interstice 1 October 1582 – 1 January 1926
	local day = tonumber (input.day);
	if (0 ~= day) and															-- day must have a value for this to be a whole date
		(((1582 == year) and (10 &lt;= month) and (12 &gt;= month)) or				-- any whole 1582 date from 1 October to 31 December or
			((1926 == year) and (1 == month) and (1 == input.day)) or			-- 1 January 1926 or
				((1582 &lt; year) and (1925 &gt;= year))) then						-- any date 1 January 1583 – 31 December 1925
					tCOinS_date.inter_cal_cat = true;							-- set category flag true
	end
-- end temporary Julian / Gregorian calendar uncertainty detection
	if ((1582 == year) and (10 &gt; month)) or (1582 &gt; year) then					-- if a Julian calendar date
		tCOinS_date.rftdate = tostring (input.year);							-- &amp;rft.date gets year only
		return;																	-- done
	end
																				-- here for all forms of Gregorian dates
	if 20 &lt; tonumber (input.month) then											-- if season, quarter, or proper-name date
		date = input.year;														-- &amp;rft.date gets year only
		if 0 ~= input.year2 and input.year ~= input.year2 then					-- if a range, only the second year portion when not the same as range start year
			date = string.format ('%.4d/%.4d', input.year, input.year2)			-- assemble the date range
		end

		local season = {[24] = 'winter', [21] = 'spring', [22] = 'summer', [23] = 'fall', [33] = '1', [34] = '2', [35] = '3', [36] = '4', [98] = 'Easter', [99] = 'Christmas'};	-- seasons lowercase, no autumn; proper-names use title case
		if 0 == input.month2 then												-- single season, quarter, or proper-name date
			if 40 &lt; tonumber(input.month) then
				tCOinS_date.rftchron = season[input.month];						-- proper-name date; used in journal metadata only
			elseif 30 &lt; tonumber(input.month) then
				tCOinS_date.rftquarter = season[input.month];					-- quarter date; used in journal metadata only
			else
				tCOinS_date.rftssn = season[input.month];						-- season date; used in journal metadata only
			end
		else																	-- season ranges are lumped into &amp;rft.chron; &amp;rft.ssn and &amp;rft.quarter are left blank
			if input.year ~= input.year2 then									-- season year – season year range or season year–year
				if 0 ~= input.month2 then
					tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);	-- used in journal metadata only
				end
			else																-- season–season year range
				tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2];	-- season–season year range; used in journal metadata only
			end
		end

		tCOinS_date.rftdate = tostring (date);
		return;																	-- done
	end
																				-- here for gregorian calendar dates
	if 0 ~= input.day then
		date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day));	-- whole date
	elseif 0 ~= input.month then
		date = string.format ('%s-%.2d', input.year, tonumber(input.month));	-- year and month
	else
		date = string.format ('%s', input.year);								-- just year
	end

	if 0 ~= input.year2 then
		if 0 ~= input.day2 then
			date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2));		-- whole date
		elseif 0 ~= input.month2 then
			date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2));	-- year and month
		else
			date2 = string.format ('/%s', input.year2);							-- just year
		end
	end
	
	tCOinS_date.rftdate = date .. date2;										-- date2 has the '/' separator
	return;
end


--[[--------------------------&lt; P A T T E R N S &gt;--------------------------------------------------------------

this is the list of patterns for date formats that this module recognizes.  Approximately the first half of these
patterns represent formats that might be reformatted into another format.  Those that might be reformatted have
'indicator' letters that identify the content of the matching capture: 'd' (day), 'm' (month), 'a' (anchor year),
'y' (year); second day, month, year have a '2' suffix.

These patterns are used for both date validation and for reformatting.  This table should not be moved to ~/Configuration
because changes to this table require changes to check_date() and to reformatter() and reformat_date()

]]

local patterns = {
	 																			-- year-initial numerical year-month-day
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'},					
																				-- month-initial: month day, year
	['Mdy'] = {'^(%D-) +([1-9]%d?), +((%d%d%d%d?)%a?)$', 'm', 'd', 'a', 'y'},
																				-- month-initial day range: month day–day, year; days are separated by endash
	['Md-dy'] = {'^(%D-) +([1-9]%d?)[%-–]([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'd2', 'a', 'y'},
																				-- day-initial: day month year
	['dMy'] = {'^([1-9]%d?) +(%D-) +((%d%d%d%d?)%a?)$', 'd', 'm', 'a', 'y'},
																				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed; not supported at en.wiki
	--	['yMd'] = {'^((%d%d%d%d?)%a?) +(%D-) +(%d%d?)$', 'a', 'y', 'm', 'd'},
																				-- day-range-initial: day–day month year; days are separated by endash
	['d-dMy'] = {'^([1-9]%d?)[%-–]([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'd2', 'm', 'a', 'y'},
																				-- day initial month-day-range: day month - day month year; uses spaced endash
	['dM-dMy'] = {'^([1-9]%d?) +(%D-) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'd2', 'm2', 'a', 'y'},
																				-- month initial month-day-range: month day – month day, year;  uses spaced endash
	['Md-Mdy'] = {'^(%D-) +([1-9]%d?) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$','m', 'd', 'm2', 'd2', 'a', 'y'},
																				-- day initial month-day-year-range: day month year - day month year; uses spaced endash
	['dMy-dMy'] = {'^([1-9]%d?) +(%D-) +(%d%d%d%d) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'y', 'd2', 'm2', 'a', 'y2'},
																				-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
	['Mdy-Mdy'] = {'^(%D-) +([1-9]%d?), +(%d%d%d%d) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'y', 'm2', 'd2', 'a', 'y2'},

																				-- these date formats cannot be converted, per se, but month name can be rendered short or long
																				-- month/season year - month/season year; separated by spaced endash
	['My-My'] = {'^(%D-) +(%d%d%d%d) +[%-–] +(%D-) +((%d%d%d%d)%a?)$', 'm', 'y', 'm2', 'a', 'y2'},
																				-- month/season range year; months separated by endash
	['M-My'] = {'^(%D-)[%-–](%D-) +((%d%d%d%d)%a?)$', 'm', 'm2', 'a', 'y'},
																				-- month/season year or proper-name year; quarter year when First Quarter YYYY etc.
	['My'] = {'^([^%d–]-) +((%d%d%d%d)%a?)$', 'm', 'a', 'y'},					-- this way because endash is a member of %D; %D- will match January–March 2019 when it shouldn't

																				-- these date formats cannot be converted
	['Sy4-y2'] = {'^(%D-) +((%d%d)%d%d)[%-–]((%d%d)%a?)$'},						-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
	['Sy-y'] = {'^(%D-) +(%d%d%d%d)[%-–]((%d%d%d%d)%a?)$'},						-- special case Winter/Summer year-year; year separated with unspaced endash
	['y-y'] = {'^(%d%d%d%d?)[%-–]((%d%d%d%d?)%a?)$'},							-- year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
	['y4-y2'] = {'^((%d%d)%d%d)[%-–]((%d%d)%a?)$'},								-- year range: YYYY–YY; separated by unspaced endash
	['y'] = {'^((%d%d%d%d?)%a?)$'},												-- year; here accept either YYY or YYYY
	}


--[[--------------------------&lt; I S _ V A L I D _ E M B A R G O _ D A T E &gt;------------------------------------

returns true and date value if that value has proper dmy, mdy, ymd format.

returns false and 9999 (embargoed forever) when date value is not proper format; assumes that when |pmc-embargo-date= is
set, the editor intended to embargo a PMC but |pmc-embargo-date= does not hold a single date.

]]

local function is_valid_embargo_date (v)
	if v:match (patterns['ymd'][1]) or											-- ymd
		v:match (patterns['Mdy'][1]) or											-- dmy
		v:match (patterns['dMy'][1]) then										-- mdy
			return true, v;
	end
	return false, '9999';														-- if here not good date so return false and set embargo date to long time in future
end


--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only
allowed range separator is endash.  Additionally, check the date to see that it is a real date: no 31 in 30-day
months; no 29 February when not a leap year.  Months, both long-form and three character abbreviations, and seasons
must be spelled correctly.  Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and
COinS_date.  When this happens, the date parameter is (DEBUG: not?) used in the COinS metadata and the CITEREF identifier gets
its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, publication-date, access-date, pmc-embargo-date, archive-date, lay-date)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is ISO 8601 format date; see make_COInS_date()

]]

local function check_date (date_string, param, tCOinS_date)
	local year;																	-- assume that year2, months, and days are not used;
	local year2 = 0;															-- second year in a year range
	local month = 0;
	local month2 = 0;															-- second month in a month range
	local day = 0;
	local day2 = 0;																-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match (patterns['ymd'][1]) then								-- year-initial numerical year month day format
		year, month, day = date_string:match (patterns['ymd'][1]);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or 0 == tonumber(day) then return false; end	-- month or day number not valid or not Gregorian calendar
		anchor_year = year;
	
	elseif mw.ustring.match(date_string, patterns['Mdy'][1]) then				-- month-initial: month day, year
		month, day, anchor_year, year = mw.ustring.match(date_string, patterns['Mdy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
				
	elseif mw.ustring.match(date_string, patterns['Md-dy'][1]) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year = mw.ustring.match(date_string, patterns['Md-dy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2=month;															-- for metadata
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['dMy'][1]) then				-- day-initial: day month year
		day, month, anchor_year, year = mw.ustring.match(date_string, patterns['dMy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months

--[[ NOT supported at en.wiki
	elseif mw.ustring.match(date_string, patterns['yMd'][1]) then				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed
		anchor_year, year, month, day = mw.ustring.match(date_string, patterns['yMd'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
-- end NOT supported at en.wiki ]]

	elseif mw.ustring.match(date_string, patterns['d-dMy'][1]) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year = mw.ustring.match(date_string, patterns['d-dMy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2 = month;															-- for metadata
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['dM-dMy'][1]) then			-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year = mw.ustring.match(date_string, patterns['dM-dMy'][1]);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['Md-Mdy'][1]) then			-- month initial month-day-range: month day – month day, year; uses spaced endash
		month, day, month2, day2, anchor_year, year = mw.ustring.match(date_string, patterns['Md-Mdy'][1]);
		if (not is_valid_month_season_range(month, month2, param)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['dMy-dMy'][1]) then			-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2 = mw.ustring.match(date_string, patterns['dMy-dMy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		if 0 == month or 0 == month2 then return false; end						-- both must be valid

	elseif mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]) then			-- month initial month-day-year-range: month day, year – month day, year; uses spaced endash
		month, day, year, month2, day2, anchor_year, year2 = mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number(month2);
		if 0 == month or 0 == month2 then return false; end						-- both must be valid

	elseif mw.ustring.match(date_string, patterns['Sy4-y2'][1]) then			-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		local century;
		month, year, century, anchor_year, year2 = mw.ustring.match(date_string, patterns['Sy4-y2'][1]);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;		-- 'month' can only be Winter or Summer
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor_year from both years
		year2 = century..year2;													-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		month = get_season_number(month, param);

	elseif mw.ustring.match(date_string, patterns['Sy-y'][1]) then				-- special case Winter/Summer year-year; year separated with unspaced endash
		month, year, anchor_year, year2 = mw.ustring.match(date_string, patterns['Sy-y'][1]);
		month = get_season_number (month, param);								-- &lt;month&gt; can only be winter or summer; also for metadata
		if (month ~= cfg.date_names['en'].season['Winter']) and (month ~= cfg.date_names['en'].season['Summer']) then
			return false;														-- not Summer or Winter; abandon
		end
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, patterns['My-My'][1]) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2 = mw.ustring.match(date_string, patterns['My-My'][1]);
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then 	-- both must be month year, same month style
			month = get_month_number(month);
			month2 = get_month_number(month2);
		elseif 0 ~= get_season_number(month, param) and 0 ~= get_season_number(month2, param) then	-- both must be season year, not mixed
			month = get_season_number(month, param);
			month2 = get_season_number(month2, param);
		else
			 return false;
		end

	elseif mw.ustring.match(date_string, patterns['M-My'][1]) then				-- month/season range year; months separated by endash 
		month, month2, anchor_year, year = mw.ustring.match(date_string, patterns['M-My'][1]);
		if (not is_valid_month_season_range(month, month2, param)) or (not is_valid_year(year)) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
			month2 = get_month_number(month2);
			if 0 == month or 0 == month2 then return false; end
		else
			month = get_season_number(month, param);
			month2 = get_season_number(month2, param);
		end
		year2 = year;
		
	elseif mw.ustring.match(date_string, patterns['My'][1]) then				-- month/season/quarter/proper-name year
		month, anchor_year, year = mw.ustring.match(date_string, patterns['My'][1]);
		if not is_valid_year(year) then return false; end
		month = get_element_number(month, param);								-- get month season quarter proper-name number or nil
		if not month then return false; end										-- not valid whatever it is

	elseif mw.ustring.match(date_string, patterns['y-y'][1]) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2 = mw.ustring.match(date_string, patterns['y-y'][1]);
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, patterns['y4-y2'][1]) then				-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2 = mw.ustring.match(date_string, patterns['y4-y2'][1]);
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor year from both years

		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century .. year2;												-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

		if in_array (param, {'date', 'publication-date', 'year'}) then			-- here when 'valid' abbreviated year range; if one of these parameters
			add_prop_cat ('year-range-abbreviated');							-- add properties cat
		end

	elseif mw.ustring.match(date_string, patterns['y'][1]) then					-- year; here accept either YYY or YYYY
		anchor_year, year = mw.ustring.match(date_string, patterns['y'][1]);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;															-- date format not one of the MOS:DATE approved formats
	end

	if param ~= 'date' then														-- CITEREF disambiguation only allowed in |date=; |year= &amp; |publication-date= promote to date
		if anchor_year:match ('%l$') then
			return false;
		end
	end

	if 'access-date' == param then												-- test access-date here because we have numerical date parts
		if 0 ~= year and 0 ~= month and 0 ~= day and 							-- all parts of a single date required
			0 == year2 and 0 == month2 and 0 == day2 then						-- none of these; access-date must not be a range
				if not is_valid_accessdate(year .. '-' .. month .. '-' .. day) then	
					return false;												-- return false when access-date out of bounds
				end
		else
			return false;														-- return false when access-date is a range of two dates
		end
	end

	if 'archive-date' == param then												-- test archive-date here because we have numerical date parts
		if not (0 ~= year and 0 ~= month and 0 ~= day and						-- all parts of a single date required
			0 == year2 and 0 == month2 and 0 == day2) then						-- none of these; archive-date must not be a range
				return false;													-- return false when archive-date is a range of two dates
		end
	end

	local result=true;															-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result = is_valid_date (year, month, day, param);						-- &lt;param&gt; for |pmc-embargo-date=

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result = is_valid_date (year, month, day);
		result = result and is_valid_date (year, month, day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result = is_valid_date (year, month, day);
		result = result and is_valid_date (year, month2, day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result = is_valid_date(year, month, day);
		result = result and is_valid_date(year2, month2, day2);
	end
	
	if false == result then return false; end

	if nil ~= tCOinS_date then													-- this table only passed into this function when testing |date= parameter values
		make_COinS_date ({year = year, month = month, day = day, year2 = year2, month2 = month2, day2 = day2}, tCOinS_date);	-- make an ISO 8601 date string for COinS
	end
	
	return true, anchor_year;													-- format is good and date string represents a real date
end	


--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
parameters with errors are added to the &lt;error_list&gt; sequence table as the dates are tested.

]]

local function dates(date_parameters_list, tCOinS_date, error_list)
	local anchor_year;															-- will return as nil if the date being tested is not |date=
	local COinS_date;															-- will return as nil if the date being tested is not |date=
	local embargo_date;															-- if embargo date is a good dmy, mdy, ymd date then holds original value else reset to 9999
	local good_date = false;

	for k, v in pairs(date_parameters_list) do									-- for each date-holding parameter in the list
		if is_set(v.val) then													-- if the parameter has a value
			v.val = mw.ustring.gsub(v.val, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9
			if v.val:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then						-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v.val:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);				-- get the year portion so it can be tested
				if 'date' == k then
					anchor_year, COinS_date = v.val:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year' == k then
					good_date = is_valid_year(year);
				end
			elseif 'date' == k then												-- if the parameter is |date=
				if v.val:match(&quot;^n%.d%.%a?$&quot;) then -- ToDo: I18N								-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((n%.d%.)%a?)&quot;); -- ToDo: I18N	-- &quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v.val:match(&quot;^nd%a?$&quot;) then -- ToDo: I18N								-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((nd)%a?)&quot;); -- ToDo: I18N	-- &quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v.val, k, tCOinS_date);	-- go test the date
				end
			elseif 'year' == k then												-- if the parameter is |year= it should hold only a year value
				if v.val:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then						-- if |year = 3 or 4 digits only with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((%d+)%a?)&quot;);
				end
			elseif 'pmc-embargo-date' == k then									-- if the parameter is |pmc-embargo-date=
				good_date = check_date (v.val, k);								-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date, embargo_date = is_valid_embargo_date (v.val);	-- is |pmc-embargo-date= date a single dmy, mdy, or ymd formatted date? yes: returns embargo date; no: returns 9999
				end
			else																-- any other date-holding parameter
				good_date = check_date (v.val, k);								-- go test the date
			end
			if false == good_date then											-- assemble one error message so we don't add the tracking category multiple times
				table.insert (error_list, wrap_style ('parameter', v.name));	-- make parameter name suitable for error message list
			end
		end
	end
	return anchor_year, embargo_date;											-- and done
end


--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function sets a local numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

the numeric value in &lt;result&gt; determines the 'output' if any from this function:
	0 – adds error message to error_list sequence table
	1 – adds maint cat
	2 – does nothing

]]

local function year_date_check (year_string, year_origin, date_string, date_origin, error_list)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes

	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where both date and year are required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard range formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif mw.ustring.match(date_string, &quot;%d%d%d%d[%-–]%d%d&quot;) then				-- YYYY-YY date ranges
		local century;
		date1, century, date2 = mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	else																		-- should never get here; this function called only when no other date errors
		result = 0;																-- no recognizable year in date
	end

	if 0 == result then															-- year / date mismatch
		table.insert (error_list, substitute (cfg.messages['mismatch'], {year_origin, date_origin}));	-- add error message to error_list sequence table
	elseif 1 == result then														-- redundant year / date
		set_message ('maint_date_year');										-- add a maint cat
	end
end


--[[--------------------------&lt; R E F O R M A T T E R &gt;--------------------------------------------------------

reformat 'date' into new format specified by format_param if pattern_idx (the current format of 'date') can be
reformatted.  Does the grunt work for reformat_dates().

The table re_formats maps pattern_idx (current format) and format_param (desired format) to a table that holds:
	format string used by string.format()
	identifier letters ('d', 'm', 'y', 'd2', 'm2', 'y2') that serve as indexes into a table t{} that holds captures
		from mw.ustring.match() for the various date parts specified by  patterns[pattern_idx][1]

Items in patterns{} have the general form:
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'}, where:
		['ymd'] is pattern_idx
		patterns['ymd'][1] is the match pattern with captures for mw.ustring.match()
		patterns['ymd'][2] is an indicator letter identifying the content of the first capture
		patterns['ymd'][3] ... the second capture etc.

when a pattern matches a date, the captures are loaded into table t{} in capture order using the idemtifier
characters as indexes into t{}  For the above, a ymd date is in t{} as:
	t.y = first capture (year), t.m = second capture (month), t.d = third capture (day)

To reformat, this function is called with the pattern_idx that matches the current format of the date and with
format_param set to the desired format.  This function loads table t{} as described and then calls string.format()
with the format string specified by re_format[pattern_idx][format_param][1] using values taken from t{} according
to the capture identifier letters specified by patterns[pattern_idx][format_param][n] where n is 2..

]]

local re_formats = {
	['ymd'] = {																	-- date format is ymd; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
	--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},								-- |df=yMd; not supported at en.wiki
		},
	['Mdy'] = {																	-- date format is Mdy; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- for long/short reformatting
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
	--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},								-- |df=yMd; not supported at en.wiki
		},
	['dMy'] = {																	-- date format is dMy; reformat to:
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- for long/short reformatting
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
	--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},								-- |df=yMd; not supported at en.wiki
		},
	['Md-dy'] = {																-- date format is Md-dy; reformat to:
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- for long/short reformatting
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- |df=dmy -&gt; d-dMy 
		},
	['d-dMy'] = {																-- date format is d-d&gt;y; reformat to:
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- for long/short reformatting
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- |df=mdy -&gt; Md-dy 
		},
	['dM-dMy'] = {																-- date format is dM-dMy; reformat to:
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- for long/short reformatting
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd', 'm2', 'd2', 'y'},				-- |df=mdy -&gt; Md-Mdy 
		},
	['Md-Mdy'] = {																-- date format is Md-Mdy; reformat to:
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd',  'm2', 'd2', 'y'},			-- for long/short reformatting
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- |df=dmy -&gt; dM-dMy 
		},
	['dMy-dMy'] = {																-- date format is dMy-dMy; reformat to:
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- for long/short reformatting
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- |df=mdy -&gt; Mdy-Mdy 
		},
	['Mdy-Mdy'] = {																-- date format is Mdy-Mdy; reformat to:
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- for long/short reformatting
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- |df=dmy -&gt; dMy-dMy 
		},
	['My-My'] = {																-- these for long/short reformatting
		['any'] = {'%s %s – %s %s', 'm', 'y', 'm2', 'y2'},						-- dmy/mdy agnostic
		},
	['M-My'] = {																-- these for long/short reformatting
		['any'] = {'%s–%s %s', 'm', 'm2', 'y'},									-- dmy/mdy agnostic
		},
	['My'] = {																	-- these for long/short reformatting
		['any'] = {'%s %s', 'm', 'y'},											-- dmy/mdy agnostic
		},
	--	['yMd'] = {																-- not supported at en.wiki
	--		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},								-- |df=mdy
	--		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},								-- |df=dmy
	--		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},								-- |df=ymd
	--		},
	}


local function reformatter (date, pattern_idx, format_param, mon_len)
	if not in_array (pattern_idx, {'ymd', 'Mdy', 'Md-dy', 'dMy', 'yMd', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- not in this set of date format patterns then not a reformattable date
	end
	
	if 'ymd' == format_param and in_array (pattern_idx, {'ymd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- ymd date ranges not supported at en.wiki; no point in reformatting ymd to ymd
	end

	if in_array (pattern_idx, {'My', 'M-My', 'My-My'}) then						-- these are not dmy/mdy so can't be 'reformatted' into either
		format_param = 'any';													-- so format-agnostic 
	end

																				-- yMd is not supported at en.wiki; when yMd is supported at your wiki, uncomment the next line
	--	if 'yMd' == format_param and in_array (pattern_idx, {'yMd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy'}) then	-- these formats not convertable; yMd not supported at en.wiki
	if 'yMd' == format_param then												-- yMd not supported at en.wiki; when yMd is supported at your wiki, remove or comment-out this line
		return;																	-- not a reformattable date
	end
	
	local c1, c2, c3, c4, c5, c6, c7;											-- these hold the captures specified in patterns[pattern_idx][1]
	c1, c2, c3, c4, c5, c6, c7 = mw.ustring.match (date, patterns[pattern_idx][1]);	-- get the captures

	local t = {																	-- table that holds k/v pairs of date parts from the captures and patterns[pattern_idx][2..]
		[patterns[pattern_idx][2]] = c1;										-- at minimum there is always one capture with a matching indicator letter
		[patterns[pattern_idx][3] or 'x'] = c2;									-- patterns can have a variable number of captures; each capture requires an indicator letter;
		[patterns[pattern_idx][4] or 'x'] = c3;									-- where there is no capture, there is no indicator letter so n in patterns[pattern_idx][n] will be nil;
		[patterns[pattern_idx][5] or 'x'] = c4;									-- the 'x' here spoofs an indicator letter to prevent 'table index is nil' error
		[patterns[pattern_idx][6] or 'x'] = c5;
		[patterns[pattern_idx][7] or 'x'] = c6;
		[patterns[pattern_idx][8] or 'x'] = c7;
		};

	if t.a then																	-- if this date has an anchor year capture (all convertable date formats except ymd)
		if t.y2 then															-- for year range date formats														
			t.y2 = t.a;															-- use the anchor year capture when reassembling the date
		else																	-- here for single date formats (except ymd)
			t.y = t.a;															-- use the anchor year capture when reassembling the date
		end
	end

	if tonumber(t.m) then														-- if raw month is a number (converting from ymd)
		if 's' == mon_len then													-- if we are to use abbreviated month names
			t.m = cfg.date_names['inv_local_short'][tonumber(t.m)];					-- convert it to a month name
		else
			t.m = cfg.date_names['inv_local_long'][tonumber(t.m)];					-- convert it to a month name
		end
		t.d = t.d:gsub ('0(%d)', '%1');											-- strip leading '0' from day if present
	elseif 'ymd' == format_param then											-- when converting to ymd
		t.y = t.y:gsub ('%a', '');												-- strip CITREF disambiguator if present; anchor year already known so process can proceed; TODO: maint message?
		if 1582 &gt; tonumber (t.y) then											-- ymd format dates not allowed before 1582
			return;
		end
		t.m = string.format ('%02d', get_month_number (t.m));					-- make sure that month and day are two digits
		t.d = string.format ('%02d', t.d);
	elseif mon_len then															-- if mon_len is set to either 'short' or 'long'
		for _, mon in ipairs ({'m', 'm2'}) do									-- because there can be two month names, check both 
			if t[mon] then
				t[mon] = get_month_number (t[mon]);								-- get the month number for this month (is length agnostic)
				if 0 == t[mon] then return; end									-- seasons and named dates can't be converted
				t[mon] = (('s' == mon_len) and cfg.date_names['inv_local_short'][t[mon]]) or cfg.date_names['inv_local_long'][t[mon]];	-- fetch month name according to length
			end
		end
	end

	local new_date = string.format (re_formats[pattern_idx][format_param][1],	-- format string
		t[re_formats[pattern_idx][format_param][2]],							-- named captures from t{}
		t[re_formats[pattern_idx][format_param][3]],
		t[re_formats[pattern_idx][format_param][4]],
		t[re_formats[pattern_idx][format_param][5]],
		t[re_formats[pattern_idx][format_param][6]],
		t[re_formats[pattern_idx][format_param][7]],
		t[re_formats[pattern_idx][format_param][8]]
		);

	return new_date;
end


--[[-------------------------&lt; R E F O R M A T _ D A T E S &gt;--------------------------------------------------

Reformats existing dates into the format specified by format.

format is one of several manual keywords: dmy, dmy-all, mdy, mdy-all, ymd, ymd-all.  The -all version includes
access- and archive-dates; otherwise these dates are not reformatted.

This function allows automatic date formatting.  In ~/Configuration, the article source is searched for one of
the {{use xxx dates}} templates.  If found, xxx becomes the global date format as xxx-all.  If |cs1-dates= in
{{use xxx dates}} has legitimate value then that value determines how cs1|2 dates will be rendered.  Legitimate
values for |cs1-dates= are:
	l - all dates are rendered with long month names
	ls - publication dates use long month names; access-/archive-dates use abbreviated month names
	ly - publication dates use long month names; access-/archive-dates rendered in ymd format
	s - all dates are rendered with abbreviated (short) month names
	sy - publication dates use abbreviated month names; access-/archive-dates rendered in ymd format
	y - all dates are rendered in ymd format

the format argument for automatic date formatting will be the format specified by {{use xxx dates}} with the
value supplied by |cs1-dates so one of: xxx-l, xxx-ls, xxx-ly, xxx-s, xxx-sy, xxx-y, or simply xxx (|cs1-dates=
empty, omitted, or invalid) where xxx shall be either of dmy or mdy.

dates are extracted from date_parameters_list, reformatted (if appropriate), and then written back into the
list in the new format.  Dates in date_parameters_list are presumed here to be valid (no errors).  This function
returns true when a date has been reformatted, false else.  Actual reformatting is done by reformatter().

]]

local function reformat_dates (date_parameters_list, format)
	local all = false;															-- set to false to skip access- and archive-dates
	local len_p = 'l';															-- default publication date length shall be long
	local len_a = 'l';															-- default access-/archive-date length shall be long
	local result = false;
	local new_date;																
	
	if format:match('%a+%-all') then											-- manual df keyword; auto df keyword when length not specified in {{use xxx dates}}; 
		format = format:match('(%a+)%-all');									-- extract the format
		all = true;																-- all dates are long format dates because this keyword doesn't specify length
	elseif format:match('%a+%-[lsy][sy]?') then									-- auto df keywords; internal only
		all = true;																-- auto df applies to all dates; use length specified by capture len_p for all dates
		format, len_p, len_a = format:match('(%a+)%-([lsy])([sy]?)');			-- extract the format and length keywords
		if 'y' == len_p then													-- because allowed by MOS:DATEUNIFY (sort of) range dates and My dates not reformatted
			format = 'ymd';														-- override {{use xxx dates}}
		elseif (not is_set(len_a)) or (len_p == len_a) then						-- no access-/archive-date length specified or same length as publication dates then
			len_a = len_p;														-- in case len_a not set
		end
	end																			-- else only publication dates and they are long

	for param_name, param_val in pairs (date_parameters_list) do				-- for each date-holding parameter in the list
		if is_set (param_val.val) then											-- if the parameter has a value
			if not (not all and in_array (param_name, {'access-date', 'archive-date'})) then	-- skip access- or archive-date unless format is xxx-all; yeah, ugly; TODO: find a better way
				for pattern_idx, pattern in pairs (patterns) do
					if mw.ustring.match (param_val.val, pattern[1]) then
						if all and in_array (param_name, {'access-date', 'archive-date'}) then	-- if this date is an access- or archive-date
							new_date = reformatter (param_val.val, pattern_idx, (('y' == len_a) and 'ymd') or format, len_a);	-- choose ymd or dmy/mdy according to len_a setting
						else													-- all other dates
							new_date = reformatter (param_val.val, pattern_idx, format, len_p);
						end
						
						if new_date then										-- set when date was reformatted
							date_parameters_list[param_name].val = new_date;	-- update date in date list
							result = true;										-- and announce that changes have been made
							break;
						end
					end	-- if
				end		-- for
			end			-- if
		end				-- if
	end					-- for
	return result;																-- declare boolean result and done
end


--[[--------------------------&lt; D A T E _ H Y P H E N _ T O _ D A S H &gt;----------------------------------------

Loops through the list of date-holding parameters and converts any hyphen to an ndash.  Not called if the cs1|2
template has any date errors.

Modifies the date_parameters_list and returns true if hyphens are replaced, else returns false.

]]

local function date_hyphen_to_dash (date_parameters_list)
	local result = false;
	local n;
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set (param_val.val) and
			not mw.ustring.match (param_val.val, patterns.ymd[1]) then			-- for those that are not ymd dates (ustring because here digits may not be Western)
				param_val.val, n = param_val.val:gsub ('%-', '–');				-- replace any hyphen with ndash
				if 0 ~= n then
					date_parameters_list[param_name].val = param_val.val;		-- update the list
					result = true;
				end
		end
	end
	return result;																-- so we know if any hyphens were replaced
end


--[[-------------------------&lt; D A T E _ N A M E _ X L A T E &gt;------------------------------------------------

Attempts to translate English date names to local-language date names using names supplied by MediaWiki's
date parser function.  This is simple name-for-name replacement and may not work for all languages.

if xlat_dig is true, this function will also translate Western (English) digits to the local language's digits.
This will also translate ymd dates.

]]

local function date_name_xlate (date_parameters_list, xlt_dig)
	local xlate;
	local mode;																	-- long or short month names
	local modified = false;
	local date;
	
	local sources_t = {
		{cfg.date_names.en.long, cfg.date_names.inv_local_long},				-- for translating long English month names to long local month names
		{cfg.date_names.en.short, cfg.date_names.inv_local_short},				-- short month names
		{cfg.date_names.en.quarter, cfg.date_names.inv_local_quarter},			-- quarter date names
		{cfg.date_names.en.season, cfg.date_names.inv_local_season},			-- season date nam
		{cfg.date_names.en.named, cfg.date_names.inv_local_named},				-- named dates
		}

	local function is_xlateable (month)											-- local function to get local date name that replaces existing English-language date name
		for _, date_names_t in ipairs (sources_t) do							-- for each sequence table in date_names_t
			if date_names_t[1][month] then										-- if date name is English month (long or short), quarter, season or named and
				if date_names_t[2][date_names_t[1][month]] then					-- if there is a matching local date name
					return date_names_t[2][date_names_t[1][month]];				-- return the local date name
				end
			end
		end
	end

	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val.val) then											-- if the parameter has a value
			date = param_val.val;
			for month in mw.ustring.gmatch (date, '[%a ]+') do					-- iterate through all date names in the date (single date or date range)
				month = mw.text.trim (month);									-- this because quarterly dates contain whitespace
				xlate = is_xlateable (month);									-- get translate &lt;month&gt;; returns translation or nil
				
				if xlate then		
					date = mw.ustring.gsub (date, month, xlate);				-- replace the English with the translation
					date_parameters_list[param_name].val = date;				-- save the translated date
					modified = true;
				end
			end

			if xlt_dig then														-- shall we also translate digits?
				date = date:gsub ('%d', cfg.date_names.xlate_digits);			-- translate digits from Western to 'local digits'
				date_parameters_list[param_name].val = date;					-- save the translated date
				modified = true;
			end
		end
	end
	
	return modified;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	add_prop_cat = utilities_page_ptr.add_prop_cat ;							-- import functions from selected Module:Citation/CS1/Utilities module
	is_set = utilities_page_ptr.is_set;
	in_array = utilities_page_ptr.in_array;
	set_message = utilities_page_ptr.set_message;
	substitute = utilities_page_ptr.substitute;
	wrap_style = utilities_page_ptr.wrap_style;

	cfg = cfg_table_ptr;														-- import tables from selected Module:Citation/CS1/Configuration
end


--[[--------------------------&lt; A R C H I V E _ D A T E _ C H E C K &gt;------------------------------------------

Compare value in |archive-date= with the timestamp in Wayback machine urls.  Emits an error message when |archive-date=
does not match the timestamp.

]]

local function archive_date_check (archive_date, archive_url_timestamp)
	local good, archive_date_ts = pcall (lang_object.formatDate, lang_object, 'Ymd', archive_date);		-- |archive-date= value to YYYYMMDD format
--	local archive_date_ts = lang_object:formatDate ('Ymd', archive_date);		-- |archive-date= value to YYYYMMDD format

	if good then
		if not archive_url_timestamp:find (archive_date_ts, 1, true) then		-- plain text find; begin search at position 1
			set_message ('err_archive_date_url_ts_mismatch');					-- emit an error message
		end
	end
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {																		-- return exported functions
	archive_date_check = archive_date_check,
	date_hyphen_to_dash = date_hyphen_to_dash,
	date_name_xlate = date_name_xlate,
	dates = dates,
	reformat_dates = reformat_dates,
	set_selected_modules = set_selected_modules,
	year_date_check = year_date_check,
	}</text>
      <sha1>h1et8hc4yy0nzlgfuigrj5tumodmw1t</sha1>
    </revision>
    <revision>
      <id>4857</id>
      <parentid>4856</parentid>
      <timestamp>2023-11-25T16:42:10Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4857</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="67484" sha1="d9i9hsb5bt99p64cyu66e8nnqj6lb6t" xml:space="preserve">--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local add_prop_cat, is_set, in_array, set_message, substitute, wrap_style;		-- imported functions from selected Module:Citation/CS1/Utilities
local cfg;																		-- table of tables imported from selected Module:Citation/CS1/Configuration


--[[--------------------------&lt; F I L E - S C O P E   D E C L A R A T I O N S &gt;--------------------------------

File-scope variables are declared here

]]

local lang_object = mw.getContentLanguage();									-- used by is_valid_accessdate(), is_valid_year(), date_name_xlate(); TODO: move to ~/Configuration?
local year_limit;																-- used by is_valid_year()


--[=[-------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |access-date= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-English date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate().  To get around that
call this function with YYYY-MM-DD format dates.

]=]

local function is_valid_accessdate (accessdate)
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold Unix time stamps representing the dates

	good1, access_ts = pcall (lang_object.formatDate, lang_object, 'U', accessdate );			-- convert accessdate value to Unix timestamp 
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which which tonumber() may not understand
		access_ts = tonumber (access_ts) or lang_object:parseFormattedNumber (access_ts);		-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to Unix time stamp
	end

	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end


--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct.
If not a valid month, returns 0

]]

local function get_month_number (month)
	return cfg.date_names['local'].long[month] or cfg.date_names['local'].short[month] or	-- look for local names first
			cfg.date_names['en'].long[month] or	cfg.date_names['en'].short[month] or		-- failing that, look for English names
			0;																				-- not a recognized month name
end


--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 21 for Spring, etc.  Capitalization and spelling
must be correct. If not a valid season, returns 0.
	21-24 = Spring, Summer, Autumn, Winter, independent of “Hemisphere”

returns 0 when &lt;param&gt; is not |date=

Season numbering is defined by Extended Date/Time Format (EDTF) specification (https://www.loc.gov/standards/datetime/)
which became part of ISO 8601 in 2019.  See '§Sub-year groupings'.  The standard defines various divisions using
numbers 21-41.  cs1|2 only supports generic seasons.  EDTF does support the distinction between north and south
hemisphere seasons but cs1|2 has no way to make that distinction.

These additional divisions not currently supported:
	25-28 = Spring - Northern Hemisphere, Summer- Northern Hemisphere, Autumn - Northern Hemisphere, Winter - Northern Hemisphere
	29-32 = Spring – Southern Hemisphere, Summer– Southern Hemisphere, Autumn – Southern Hemisphere, Winter - Southern Hemisphere
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)

]]

local function get_season_number (season, param)
	if 'date' ~= param then
		return 0;																-- season dates only supported by |date=
	end
	return cfg.date_names['local'].season[season] or							-- look for local names first
			cfg.date_names['en'].season[season] or								-- failing that, look for English names
			0;																	-- not a recognized season name
end


--[[--------------------------&lt; G E T _ Q U A R T E R _ N U M B E R &gt;------------------------------------------

returns a number according to the sequence of quarters in a year: 33 for first quarter, etc.  Capitalization and spelling
must be correct. If not a valid quarter, returns 0.
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)

returns 0 when &lt;param&gt; is not |date=

Quarter numbering is defined by Extended Date/Time Format (EDTF) specification (https://www.loc.gov/standards/datetime/)
which became part of ISO 8601 in 2019.  See '§Sub-year groupings'.  The standard defines various divisions using
numbers 21-41.  cs1|2 only supports generic seasons and quarters.

These additional divisions not currently supported:
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)

]]

local function get_quarter_number (quarter, param)
	if 'date' ~= param then
		return 0;																-- quarter dates only supported by |date=
	end
	quarter = mw.ustring.gsub (quarter, ' +', ' ');								-- special case replace multiple space chars with a single space char
	return cfg.date_names['local'].quarter[quarter] or							-- look for local names first
			cfg.date_names['en'].quarter[quarter] or							-- failing that, look for English names
			0;																	-- not a recognized quarter name
end


--[[--------------------------&lt; G E T _ P R O P E R _ N A M E _ N U M B E R &gt;----------------------------------

returns a non-zero number if date contains a recognized proper-name.  Capitalization and spelling must be correct.

returns 0 when &lt;param&gt; is not |date=

]]

local function get_proper_name_number (name, param)
	if 'date' ~= param then
		return 0;																-- proper-name dates only supported by |date=
	end
	return cfg.date_names['local'].named[name] or								-- look for local names dates first
			cfg.date_names['en'].named[name] or									-- failing that, look for English names
			0;																	-- not a recognized named date
end


--[[--------------------------&lt; G E T _ E L E M E N T _ N U M B E R &lt;------------------------------------------

returns true if month or season or quarter or proper name is valid (properly spelled, capitalized, abbreviated)

]]

local function get_element_number (element, param)
	local num;
	
	local funcs = {get_month_number, get_season_number, get_quarter_number, get_proper_name_number};	-- list of functions to execute in order
	
	for _, func in ipairs (funcs) do											-- spin through the function list
		num = func (element, param);											-- call the function and get the returned number
		if 0 ~= num then														-- non-zero when valid month season quarter 
			return num;															-- return that number
		end
	end
	return nil;																	-- not valid
end


--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one
year in the future are not acceptable.

Special case for |pmc-embargo-date=: years more than two years in the future are not acceptable

]]

local function is_valid_year (year, param)
	if not is_set (year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;									-- global variable so we only have to fetch it once
	end

	year = tonumber (year) or lang_object:parseFormattedNumber (year);			-- convert to number for the comparison
	if year and (100 &gt; year) then												-- years less than 100 not supported
		return false;
	end
	
	if 'pmc-embargo-date' == param then											-- special case for |pmc-embargo-date=
		return year and (year &lt;= tonumber(os.date(&quot;%Y&quot;))+2) or false;			-- years more than two years in the future are not accepted
	end	
	return year and (year &lt;= year_limit) or false;
end


--[[--------------------------&lt; I S _ V A L I D _ D A T E &gt;----------------------------------------------------

Returns true if day is less than or equal to the number of days in month and year is no farther into the future
than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap
years before 1582 and Gregorian leap years after 1582. Where the two calendars overlap (1582 to approximately
1923) dates are assumed to be Gregorian.

]]

local function is_valid_date (year, month, day, param)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year (year, param) then										-- no farther into the future than next year except |pmc-embargo-date= no more than two years in the future
		return false;
	end
	
	month = tonumber (month);													-- required for YYYY-MM-DD dates
	
	if (2 == month) then														-- if February
		month_length = 28;														-- then 28 days unless
		if 1582 &gt; tonumber(year) then											-- Julian calendar
			if 0 == (year%4) then												-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		else																	-- Gregorian calendar
			if (0 == (year%4) and (0 ~= (year%100) or 0 == (year%400))) then	-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		end
	else
		month_length = days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
This function looks in cfg.date_names{} to see if both month names are listed in the long subtable or both are
listed in the short subtable.  When both have the same style (both are listed in the same table), returns true; false else

]]

local function is_valid_month_range_style (month1, month2)
	if (cfg.date_names.en.long[month1] and cfg.date_names.en.long[month2]) or					-- are both English names listed in the long subtable?
		(cfg.date_names.en.short[month1] and cfg.date_names.en.short[month2]) or				-- are both English names listed in the short subtable?
		(cfg.date_names['local'].long[month1] and cfg.date_names['local'].long[month2]) or		-- are both local names listed in the long subtable?
		(cfg.date_names['local'].short[month1] and cfg.date_names['local'].short[month2]) then	-- are both local names listed in the short subtable?
			return true;
	end
	return false;																-- names are mixed
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

All season ranges are accepted as valid because there are publishers out there who have published a Summer–Spring YYYY issue, hence treat as ok

]]

local function is_valid_month_season_range(range_start, range_end, param)
	local range_start_number = get_month_number (range_start);
	local range_end_number;

	if 0 == range_start_number then												-- is this a month range?
		range_start_number = get_season_number (range_start, param);			-- not a month; is it a season? get start season number
		range_end_number = get_season_number (range_end, param);				-- get end season number

		if (0 ~= range_start_number) and (0 ~= range_end_number) and (range_start_number ~= range_end_number) then
			return true;														-- any season pairing is accepted except when both are the same
		end
		return false;															-- range_start and/or range_end is not a season
	end
																				-- here when range_start is a month
	range_end_number = get_month_number (range_end);							-- get end month number
	if range_start_number &lt; range_end_number and								-- range_start is a month; does range_start precede range_end?
		is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
	end
	return false;																-- range_start month number is greater than or equal to range end number; or range end isn't a month
end


--[[--------------------------&lt; M A K E _ C O I N S _ D A T E &gt;------------------------------------------------

This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1.  The function is called only for |date= parameters and only if the |date=&lt;value&gt; is 
determined to be a valid date format.  The question of what to do with invalid date formats is not answered here.

The date parts in the input table are converted to an ISO 8601 conforming date string:
	single whole dates:		yyyy-mm-dd
	month and year dates:	yyyy-mm
	year dates:				yyyy
	ranges:					yyyy-mm-dd/yyyy-mm-dd
							yyyy-mm/yyyy-mm
							yyyy/yyyy

Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.

The input table has:
	year, year2 – always present; if before 1582, ignore months and days if present
	month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 99 Christmas
	day, day2 –  0 if not provided, 1-31 for days
	
the output table receives:
	rftdate:	an ISO 8601 formatted date
	rftchron:	a free-form version of the date, usually without year which is in rftdate (season ranges and proper-name dates)
	rftssn:		one of four season keywords: winter, spring, summer, fall (lowercase)
	rftquarter:	one of four values: 1, 2, 3, 4

]]

local function make_COinS_date (input, tCOinS_date)
	local date;																	-- one date or first date in a range
	local date2 = '';															-- end of range date
	input.year = tonumber (input.year) or lang_object:parseFormattedNumber (input.year);	-- language-aware tonumber()
	input.year2 = tonumber (input.year2) or lang_object:parseFormattedNumber (input.year2);	-- COinS dates are pseudo-ISO 8601 so convert to Arabic numerals

-- start temporary Julian / Gregorian calendar uncertainty detection
	local year = input.year;													-- this temporary code to determine the extent of sources dated to the Julian/Gregorian
	local month = tonumber(input.month);										-- interstice 1 October 1582 – 1 January 1926
	local day = tonumber (input.day);
	if (0 ~= day) and															-- day must have a value for this to be a whole date
		(((1582 == year) and (10 &lt;= month) and (12 &gt;= month)) or				-- any whole 1582 date from 1 October to 31 December or
			((1926 == year) and (1 == month) and (1 == input.day)) or			-- 1 January 1926 or
				((1582 &lt; year) and (1925 &gt;= year))) then						-- any date 1 January 1583 – 31 December 1925
					tCOinS_date.inter_cal_cat = true;							-- set category flag true
	end
-- end temporary Julian / Gregorian calendar uncertainty detection
	if ((1582 == year) and (10 &gt; month)) or (1582 &gt; year) then					-- if a Julian calendar date
		tCOinS_date.rftdate = tostring (input.year);							-- &amp;rft.date gets year only
		return;																	-- done
	end
																				-- here for all forms of Gregorian dates
	if 20 &lt; tonumber (input.month) then											-- if season, quarter, or proper-name date
		date = input.year;														-- &amp;rft.date gets year only
		if 0 ~= input.year2 and input.year ~= input.year2 then					-- if a range, only the second year portion when not the same as range start year
			date = string.format ('%.4d/%.4d', input.year, input.year2)			-- assemble the date range
		end

		local season = {[24] = 'winter', [21] = 'spring', [22] = 'summer', [23] = 'fall', [33] = '1', [34] = '2', [35] = '3', [36] = '4', [98] = 'Easter', [99] = 'Christmas'};	-- seasons lowercase, no autumn; proper-names use title case
		if 0 == input.month2 then												-- single season, quarter, or proper-name date
			if 40 &lt; tonumber(input.month) then
				tCOinS_date.rftchron = season[input.month];						-- proper-name date; used in journal metadata only
			elseif 30 &lt; tonumber(input.month) then
				tCOinS_date.rftquarter = season[input.month];					-- quarter date; used in journal metadata only
			else
				tCOinS_date.rftssn = season[input.month];						-- season date; used in journal metadata only
			end
		else																	-- season ranges are lumped into &amp;rft.chron; &amp;rft.ssn and &amp;rft.quarter are left blank
			if input.year ~= input.year2 then									-- season year – season year range or season year–year
				if 0 ~= input.month2 then
					tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);	-- used in journal metadata only
				end
			else																-- season–season year range
				tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2];	-- season–season year range; used in journal metadata only
			end
		end

		tCOinS_date.rftdate = tostring (date);
		return;																	-- done
	end
																				-- here for gregorian calendar dates
	if 0 ~= input.day then
		date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day));	-- whole date
	elseif 0 ~= input.month then
		date = string.format ('%s-%.2d', input.year, tonumber(input.month));	-- year and month
	else
		date = string.format ('%s', input.year);								-- just year
	end

	if 0 ~= input.year2 then
		if 0 ~= input.day2 then
			date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2));		-- whole date
		elseif 0 ~= input.month2 then
			date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2));	-- year and month
		else
			date2 = string.format ('/%s', input.year2);							-- just year
		end
	end
	
	tCOinS_date.rftdate = date .. date2;										-- date2 has the '/' separator
	return;
end


--[[--------------------------&lt; P A T T E R N S &gt;--------------------------------------------------------------

this is the list of patterns for date formats that this module recognizes.  Approximately the first half of these
patterns represent formats that might be reformatted into another format.  Those that might be reformatted have
'indicator' letters that identify the content of the matching capture: 'd' (day), 'm' (month), 'a' (anchor year),
'y' (year); second day, month, year have a '2' suffix.

These patterns are used for both date validation and for reformatting.  This table should not be moved to ~/Configuration
because changes to this table require changes to check_date() and to reformatter() and reformat_date()

]]

local patterns = {
	 																			-- year-initial numerical year-month-day
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'},					
																				-- month-initial: month day, year
	['Mdy'] = {'^(%D-) +([1-9]%d?), +((%d%d%d%d?)%a?)$', 'm', 'd', 'a', 'y'},
																				-- month-initial day range: month day–day, year; days are separated by endash
	['Md-dy'] = {'^(%D-) +([1-9]%d?)[%-–]([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'd2', 'a', 'y'},
																				-- day-initial: day month year
	['dMy'] = {'^([1-9]%d?) +(%D-) +((%d%d%d%d?)%a?)$', 'd', 'm', 'a', 'y'},
																				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed; not supported at en.wiki
	--	['yMd'] = {'^((%d%d%d%d?)%a?) +(%D-) +(%d%d?)$', 'a', 'y', 'm', 'd'},
																				-- day-range-initial: day–day month year; days are separated by endash
	['d-dMy'] = {'^([1-9]%d?)[%-–]([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'd2', 'm', 'a', 'y'},
																				-- day initial month-day-range: day month - day month year; uses spaced endash
	['dM-dMy'] = {'^([1-9]%d?) +(%D-) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'd2', 'm2', 'a', 'y'},
																				-- month initial month-day-range: month day – month day, year;  uses spaced endash
	['Md-Mdy'] = {'^(%D-) +([1-9]%d?) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$','m', 'd', 'm2', 'd2', 'a', 'y'},
																				-- day initial month-day-year-range: day month year - day month year; uses spaced endash
	['dMy-dMy'] = {'^([1-9]%d?) +(%D-) +(%d%d%d%d) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'y', 'd2', 'm2', 'a', 'y2'},
																				-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
	['Mdy-Mdy'] = {'^(%D-) +([1-9]%d?), +(%d%d%d%d) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'y', 'm2', 'd2', 'a', 'y2'},

																				-- these date formats cannot be converted, per se, but month name can be rendered short or long
																				-- month/season year - month/season year; separated by spaced endash
	['My-My'] = {'^(%D-) +(%d%d%d%d) +[%-–] +(%D-) +((%d%d%d%d)%a?)$', 'm', 'y', 'm2', 'a', 'y2'},
																				-- month/season range year; months separated by endash
	['M-My'] = {'^(%D-)[%-–](%D-) +((%d%d%d%d)%a?)$', 'm', 'm2', 'a', 'y'},
																				-- month/season year or proper-name year; quarter year when First Quarter YYYY etc.
	['My'] = {'^([^%d–]-) +((%d%d%d%d)%a?)$', 'm', 'a', 'y'},					-- this way because endash is a member of %D; %D- will match January–March 2019 when it shouldn't

																				-- these date formats cannot be converted
	['Sy4-y2'] = {'^(%D-) +((%d%d)%d%d)[%-–]((%d%d)%a?)$'},						-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
	['Sy-y'] = {'^(%D-) +(%d%d%d%d)[%-–]((%d%d%d%d)%a?)$'},						-- special case Winter/Summer year-year; year separated with unspaced endash
	['y-y'] = {'^(%d%d%d%d?)[%-–]((%d%d%d%d?)%a?)$'},							-- year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
	['y4-y2'] = {'^((%d%d)%d%d)[%-–]((%d%d)%a?)$'},								-- year range: YYYY–YY; separated by unspaced endash
	['y'] = {'^((%d%d%d%d?)%a?)$'},												-- year; here accept either YYY or YYYY
	}


--[[--------------------------&lt; I S _ V A L I D _ E M B A R G O _ D A T E &gt;------------------------------------

returns true and date value if that value has proper dmy, mdy, ymd format.

returns false and 9999 (embargoed forever) when date value is not proper format; assumes that when |pmc-embargo-date= is
set, the editor intended to embargo a PMC but |pmc-embargo-date= does not hold a single date.

]]

local function is_valid_embargo_date (v)
	if v:match (patterns['ymd'][1]) or											-- ymd
		v:match (patterns['Mdy'][1]) or											-- dmy
		v:match (patterns['dMy'][1]) then										-- mdy
			return true, v;
	end
	return false, '9999';														-- if here not good date so return false and set embargo date to long time in future
end


--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only
allowed range separator is endash.  Additionally, check the date to see that it is a real date: no 31 in 30-day
months; no 29 February when not a leap year.  Months, both long-form and three character abbreviations, and seasons
must be spelled correctly.  Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and
COinS_date.  When this happens, the date parameter is (DEBUG: not?) used in the COinS metadata and the CITEREF identifier gets
its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, publication-date, access-date, pmc-embargo-date, archive-date, lay-date)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is ISO 8601 format date; see make_COInS_date()

]]

local function check_date (date_string, param, tCOinS_date)
	local year;																	-- assume that year2, months, and days are not used;
	local year2 = 0;															-- second year in a year range
	local month = 0;
	local month2 = 0;															-- second month in a month range
	local day = 0;
	local day2 = 0;																-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match (patterns['ymd'][1]) then								-- year-initial numerical year month day format
		year, month, day = date_string:match (patterns['ymd'][1]);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or 0 == tonumber(day) then return false; end	-- month or day number not valid or not Gregorian calendar
		anchor_year = year;
	
	elseif mw.ustring.match(date_string, patterns['Mdy'][1]) then				-- month-initial: month day, year
		month, day, anchor_year, year = mw.ustring.match(date_string, patterns['Mdy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
				
	elseif mw.ustring.match(date_string, patterns['Md-dy'][1]) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year = mw.ustring.match(date_string, patterns['Md-dy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2=month;															-- for metadata
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['dMy'][1]) then				-- day-initial: day month year
		day, month, anchor_year, year = mw.ustring.match(date_string, patterns['dMy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months

--[[ NOT supported at en.wiki
	elseif mw.ustring.match(date_string, patterns['yMd'][1]) then				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed
		anchor_year, year, month, day = mw.ustring.match(date_string, patterns['yMd'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
-- end NOT supported at en.wiki ]]

	elseif mw.ustring.match(date_string, patterns['d-dMy'][1]) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year = mw.ustring.match(date_string, patterns['d-dMy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2 = month;															-- for metadata
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['dM-dMy'][1]) then			-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year = mw.ustring.match(date_string, patterns['dM-dMy'][1]);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['Md-Mdy'][1]) then			-- month initial month-day-range: month day – month day, year; uses spaced endash
		month, day, month2, day2, anchor_year, year = mw.ustring.match(date_string, patterns['Md-Mdy'][1]);
		if (not is_valid_month_season_range(month, month2, param)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['dMy-dMy'][1]) then			-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2 = mw.ustring.match(date_string, patterns['dMy-dMy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		if 0 == month or 0 == month2 then return false; end						-- both must be valid

	elseif mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]) then			-- month initial month-day-year-range: month day, year – month day, year; uses spaced endash
		month, day, year, month2, day2, anchor_year, year2 = mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number(month2);
		if 0 == month or 0 == month2 then return false; end						-- both must be valid

	elseif mw.ustring.match(date_string, patterns['Sy4-y2'][1]) then			-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		local century;
		month, year, century, anchor_year, year2 = mw.ustring.match(date_string, patterns['Sy4-y2'][1]);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;		-- 'month' can only be Winter or Summer
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor_year from both years
		year2 = century..year2;													-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		month = get_season_number(month, param);

	elseif mw.ustring.match(date_string, patterns['Sy-y'][1]) then				-- special case Winter/Summer year-year; year separated with unspaced endash
		month, year, anchor_year, year2 = mw.ustring.match(date_string, patterns['Sy-y'][1]);
		month = get_season_number (month, param);								-- &lt;month&gt; can only be winter or summer; also for metadata
		if (month ~= cfg.date_names['en'].season['Winter']) and (month ~= cfg.date_names['en'].season['Summer']) then
			return false;														-- not Summer or Winter; abandon
		end
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, patterns['My-My'][1]) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2 = mw.ustring.match(date_string, patterns['My-My'][1]);
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then 	-- both must be month year, same month style
			month = get_month_number(month);
			month2 = get_month_number(month2);
		elseif 0 ~= get_season_number(month, param) and 0 ~= get_season_number(month2, param) then	-- both must be season year, not mixed
			month = get_season_number(month, param);
			month2 = get_season_number(month2, param);
		else
			 return false;
		end

	elseif mw.ustring.match(date_string, patterns['M-My'][1]) then				-- month/season range year; months separated by endash 
		month, month2, anchor_year, year = mw.ustring.match(date_string, patterns['M-My'][1]);
		if (not is_valid_month_season_range(month, month2, param)) or (not is_valid_year(year)) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
			month2 = get_month_number(month2);
			if 0 == month or 0 == month2 then return false; end
		else
			month = get_season_number(month, param);
			month2 = get_season_number(month2, param);
		end
		year2 = year;
		
	elseif mw.ustring.match(date_string, patterns['My'][1]) then				-- month/season/quarter/proper-name year
		month, anchor_year, year = mw.ustring.match(date_string, patterns['My'][1]);
		if not is_valid_year(year) then return false; end
		month = get_element_number(month, param);								-- get month season quarter proper-name number or nil
		if not month then return false; end										-- not valid whatever it is

	elseif mw.ustring.match(date_string, patterns['y-y'][1]) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2 = mw.ustring.match(date_string, patterns['y-y'][1]);
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, patterns['y4-y2'][1]) then				-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2 = mw.ustring.match(date_string, patterns['y4-y2'][1]);
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor year from both years

		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century .. year2;												-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

		if in_array (param, {'date', 'publication-date', 'year'}) then			-- here when 'valid' abbreviated year range; if one of these parameters
			add_prop_cat ('year-range-abbreviated');							-- add properties cat
		end

	elseif mw.ustring.match(date_string, patterns['y'][1]) then					-- year; here accept either YYY or YYYY
		anchor_year, year = mw.ustring.match(date_string, patterns['y'][1]);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;															-- date format not one of the MOS:DATE approved formats
	end

	if param ~= 'date' then														-- CITEREF disambiguation only allowed in |date=; |year= &amp; |publication-date= promote to date
		if anchor_year:match ('%l$') then
			return false;
		end
	end

	if 'access-date' == param then												-- test access-date here because we have numerical date parts
		if 0 ~= year and 0 ~= month and 0 ~= day and 							-- all parts of a single date required
			0 == year2 and 0 == month2 and 0 == day2 then						-- none of these; access-date must not be a range
				if not is_valid_accessdate(year .. '-' .. month .. '-' .. day) then	
					return false;												-- return false when access-date out of bounds
				end
		else
			return false;														-- return false when access-date is a range of two dates
		end
	end

	if 'archive-date' == param then												-- test archive-date here because we have numerical date parts
		if not (0 ~= year and 0 ~= month and 0 ~= day and						-- all parts of a single date required
			0 == year2 and 0 == month2 and 0 == day2) then						-- none of these; archive-date must not be a range
				return false;													-- return false when archive-date is a range of two dates
		end
	end

	local result=true;															-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result = is_valid_date (year, month, day, param);						-- &lt;param&gt; for |pmc-embargo-date=

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result = is_valid_date (year, month, day);
		result = result and is_valid_date (year, month, day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result = is_valid_date (year, month, day);
		result = result and is_valid_date (year, month2, day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result = is_valid_date(year, month, day);
		result = result and is_valid_date(year2, month2, day2);
	end
	
	if false == result then return false; end

	if nil ~= tCOinS_date then													-- this table only passed into this function when testing |date= parameter values
		make_COinS_date ({year = year, month = month, day = day, year2 = year2, month2 = month2, day2 = day2}, tCOinS_date);	-- make an ISO 8601 date string for COinS
	end
	
	return true, anchor_year;													-- format is good and date string represents a real date
end	


--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
parameters with errors are added to the &lt;error_list&gt; sequence table as the dates are tested.

]]

local function dates(date_parameters_list, tCOinS_date, error_list)
	local anchor_year;															-- will return as nil if the date being tested is not |date=
	local COinS_date;															-- will return as nil if the date being tested is not |date=
	local embargo_date;															-- if embargo date is a good dmy, mdy, ymd date then holds original value else reset to 9999
	local good_date = false;

	for k, v in pairs(date_parameters_list) do									-- for each date-holding parameter in the list
		if is_set(v.val) then													-- if the parameter has a value
			v.val = mw.ustring.gsub(v.val, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9
			if v.val:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then						-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v.val:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);				-- get the year portion so it can be tested
				if 'date' == k then
					anchor_year, COinS_date = v.val:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year' == k then
					good_date = is_valid_year(year);
				end
			elseif 'date' == k then												-- if the parameter is |date=
				if v.val:match(&quot;^n%.d%.%a?$&quot;) then -- ToDo: I18N								-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((n%.d%.)%a?)&quot;); -- ToDo: I18N	-- &quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v.val:match(&quot;^nd%a?$&quot;) then -- ToDo: I18N								-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((nd)%a?)&quot;); -- ToDo: I18N	-- &quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v.val, k, tCOinS_date);	-- go test the date
				end
			elseif 'year' == k then												-- if the parameter is |year= it should hold only a year value
				if v.val:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then						-- if |year = 3 or 4 digits only with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((%d+)%a?)&quot;);
				end
			elseif 'pmc-embargo-date' == k then									-- if the parameter is |pmc-embargo-date=
				good_date = check_date (v.val, k);								-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date, embargo_date = is_valid_embargo_date (v.val);	-- is |pmc-embargo-date= date a single dmy, mdy, or ymd formatted date? yes: returns embargo date; no: returns 9999
				end
			else																-- any other date-holding parameter
				good_date = check_date (v.val, k);								-- go test the date
			end
			if false == good_date then											-- assemble one error message so we don't add the tracking category multiple times
				table.insert (error_list, wrap_style ('parameter', v.name));	-- make parameter name suitable for error message list
			end
		end
	end
	return anchor_year, embargo_date;											-- and done
end


--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function sets a local numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

the numeric value in &lt;result&gt; determines the 'output' if any from this function:
	0 – adds error message to error_list sequence table
	1 – adds maint cat
	2 – does nothing

]]

local function year_date_check (year_string, year_origin, date_string, date_origin, error_list)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes

	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where both date and year are required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard range formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif mw.ustring.match(date_string, &quot;%d%d%d%d[%-–]%d%d&quot;) then				-- YYYY-YY date ranges
		local century;
		date1, century, date2 = mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	else																		-- should never get here; this function called only when no other date errors
		result = 0;																-- no recognizable year in date
	end

	if 0 == result then															-- year / date mismatch
		table.insert (error_list, substitute (cfg.messages['mismatch'], {year_origin, date_origin}));	-- add error message to error_list sequence table
	elseif 1 == result then														-- redundant year / date
		set_message ('maint_date_year');										-- add a maint cat
	end
end


--[[--------------------------&lt; R E F O R M A T T E R &gt;--------------------------------------------------------

reformat 'date' into new format specified by format_param if pattern_idx (the current format of 'date') can be
reformatted.  Does the grunt work for reformat_dates().

The table re_formats maps pattern_idx (current format) and format_param (desired format) to a table that holds:
	format string used by string.format()
	identifier letters ('d', 'm', 'y', 'd2', 'm2', 'y2') that serve as indexes into a table t{} that holds captures
		from mw.ustring.match() for the various date parts specified by  patterns[pattern_idx][1]

Items in patterns{} have the general form:
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'}, where:
		['ymd'] is pattern_idx
		patterns['ymd'][1] is the match pattern with captures for mw.ustring.match()
		patterns['ymd'][2] is an indicator letter identifying the content of the first capture
		patterns['ymd'][3] ... the second capture etc.

when a pattern matches a date, the captures are loaded into table t{} in capture order using the idemtifier
characters as indexes into t{}  For the above, a ymd date is in t{} as:
	t.y = first capture (year), t.m = second capture (month), t.d = third capture (day)

To reformat, this function is called with the pattern_idx that matches the current format of the date and with
format_param set to the desired format.  This function loads table t{} as described and then calls string.format()
with the format string specified by re_format[pattern_idx][format_param][1] using values taken from t{} according
to the capture identifier letters specified by patterns[pattern_idx][format_param][n] where n is 2..

]]

local re_formats = {
	['ymd'] = {																	-- date format is ymd; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
	--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},								-- |df=yMd; not supported at en.wiki
		},
	['Mdy'] = {																	-- date format is Mdy; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- for long/short reformatting
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
	--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},								-- |df=yMd; not supported at en.wiki
		},
	['dMy'] = {																	-- date format is dMy; reformat to:
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- for long/short reformatting
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
	--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},								-- |df=yMd; not supported at en.wiki
		},
	['Md-dy'] = {																-- date format is Md-dy; reformat to:
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- for long/short reformatting
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- |df=dmy -&gt; d-dMy 
		},
	['d-dMy'] = {																-- date format is d-d&gt;y; reformat to:
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- for long/short reformatting
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- |df=mdy -&gt; Md-dy 
		},
	['dM-dMy'] = {																-- date format is dM-dMy; reformat to:
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- for long/short reformatting
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd', 'm2', 'd2', 'y'},				-- |df=mdy -&gt; Md-Mdy 
		},
	['Md-Mdy'] = {																-- date format is Md-Mdy; reformat to:
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd',  'm2', 'd2', 'y'},			-- for long/short reformatting
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- |df=dmy -&gt; dM-dMy 
		},
	['dMy-dMy'] = {																-- date format is dMy-dMy; reformat to:
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- for long/short reformatting
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- |df=mdy -&gt; Mdy-Mdy 
		},
	['Mdy-Mdy'] = {																-- date format is Mdy-Mdy; reformat to:
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- for long/short reformatting
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- |df=dmy -&gt; dMy-dMy 
		},
	['My-My'] = {																-- these for long/short reformatting
		['any'] = {'%s %s – %s %s', 'm', 'y', 'm2', 'y2'},						-- dmy/mdy agnostic
		},
	['M-My'] = {																-- these for long/short reformatting
		['any'] = {'%s–%s %s', 'm', 'm2', 'y'},									-- dmy/mdy agnostic
		},
	['My'] = {																	-- these for long/short reformatting
		['any'] = {'%s %s', 'm', 'y'},											-- dmy/mdy agnostic
		},
	--	['yMd'] = {																-- not supported at en.wiki
	--		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},								-- |df=mdy
	--		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},								-- |df=dmy
	--		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},								-- |df=ymd
	--		},
	}


local function reformatter (date, pattern_idx, format_param, mon_len)
	if not in_array (pattern_idx, {'ymd', 'Mdy', 'Md-dy', 'dMy', 'yMd', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- not in this set of date format patterns then not a reformattable date
	end
	
	if 'ymd' == format_param and in_array (pattern_idx, {'ymd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- ymd date ranges not supported at en.wiki; no point in reformatting ymd to ymd
	end

	if in_array (pattern_idx, {'My', 'M-My', 'My-My'}) then						-- these are not dmy/mdy so can't be 'reformatted' into either
		format_param = 'any';													-- so format-agnostic 
	end

																				-- yMd is not supported at en.wiki; when yMd is supported at your wiki, uncomment the next line
	--	if 'yMd' == format_param and in_array (pattern_idx, {'yMd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy'}) then	-- these formats not convertable; yMd not supported at en.wiki
	if 'yMd' == format_param then												-- yMd not supported at en.wiki; when yMd is supported at your wiki, remove or comment-out this line
		return;																	-- not a reformattable date
	end
	
	local c1, c2, c3, c4, c5, c6, c7;											-- these hold the captures specified in patterns[pattern_idx][1]
	c1, c2, c3, c4, c5, c6, c7 = mw.ustring.match (date, patterns[pattern_idx][1]);	-- get the captures

	local t = {																	-- table that holds k/v pairs of date parts from the captures and patterns[pattern_idx][2..]
		[patterns[pattern_idx][2]] = c1;										-- at minimum there is always one capture with a matching indicator letter
		[patterns[pattern_idx][3] or 'x'] = c2;									-- patterns can have a variable number of captures; each capture requires an indicator letter;
		[patterns[pattern_idx][4] or 'x'] = c3;									-- where there is no capture, there is no indicator letter so n in patterns[pattern_idx][n] will be nil;
		[patterns[pattern_idx][5] or 'x'] = c4;									-- the 'x' here spoofs an indicator letter to prevent 'table index is nil' error
		[patterns[pattern_idx][6] or 'x'] = c5;
		[patterns[pattern_idx][7] or 'x'] = c6;
		[patterns[pattern_idx][8] or 'x'] = c7;
		};

	if t.a then																	-- if this date has an anchor year capture (all convertable date formats except ymd)
		if t.y2 then															-- for year range date formats														
			t.y2 = t.a;															-- use the anchor year capture when reassembling the date
		else																	-- here for single date formats (except ymd)
			t.y = t.a;															-- use the anchor year capture when reassembling the date
		end
	end

	if tonumber(t.m) then														-- if raw month is a number (converting from ymd)
		if 's' == mon_len then													-- if we are to use abbreviated month names
			t.m = cfg.date_names['inv_local_short'][tonumber(t.m)];					-- convert it to a month name
		else
			t.m = cfg.date_names['inv_local_long'][tonumber(t.m)];					-- convert it to a month name
		end
		t.d = t.d:gsub ('0(%d)', '%1');											-- strip leading '0' from day if present
	elseif 'ymd' == format_param then											-- when converting to ymd
		t.y = t.y:gsub ('%a', '');												-- strip CITREF disambiguator if present; anchor year already known so process can proceed; TODO: maint message?
		if 1582 &gt; tonumber (t.y) then											-- ymd format dates not allowed before 1582
			return;
		end
		t.m = string.format ('%02d', get_month_number (t.m));					-- make sure that month and day are two digits
		t.d = string.format ('%02d', t.d);
	elseif mon_len then															-- if mon_len is set to either 'short' or 'long'
		for _, mon in ipairs ({'m', 'm2'}) do									-- because there can be two month names, check both 
			if t[mon] then
				t[mon] = get_month_number (t[mon]);								-- get the month number for this month (is length agnostic)
				if 0 == t[mon] then return; end									-- seasons and named dates can't be converted
				t[mon] = (('s' == mon_len) and cfg.date_names['inv_local_short'][t[mon]]) or cfg.date_names['inv_local_long'][t[mon]];	-- fetch month name according to length
			end
		end
	end

	local new_date = string.format (re_formats[pattern_idx][format_param][1],	-- format string
		t[re_formats[pattern_idx][format_param][2]],							-- named captures from t{}
		t[re_formats[pattern_idx][format_param][3]],
		t[re_formats[pattern_idx][format_param][4]],
		t[re_formats[pattern_idx][format_param][5]],
		t[re_formats[pattern_idx][format_param][6]],
		t[re_formats[pattern_idx][format_param][7]],
		t[re_formats[pattern_idx][format_param][8]]
		);

	return new_date;
end


--[[-------------------------&lt; R E F O R M A T _ D A T E S &gt;--------------------------------------------------

Reformats existing dates into the format specified by format.

format is one of several manual keywords: dmy, dmy-all, mdy, mdy-all, ymd, ymd-all.  The -all version includes
access- and archive-dates; otherwise these dates are not reformatted.

This function allows automatic date formatting.  In ~/Configuration, the article source is searched for one of
the {{use xxx dates}} templates.  If found, xxx becomes the global date format as xxx-all.  If |cs1-dates= in
{{use xxx dates}} has legitimate value then that value determines how cs1|2 dates will be rendered.  Legitimate
values for |cs1-dates= are:
	l - all dates are rendered with long month names
	ls - publication dates use long month names; access-/archive-dates use abbreviated month names
	ly - publication dates use long month names; access-/archive-dates rendered in ymd format
	s - all dates are rendered with abbreviated (short) month names
	sy - publication dates use abbreviated month names; access-/archive-dates rendered in ymd format
	y - all dates are rendered in ymd format

the format argument for automatic date formatting will be the format specified by {{use xxx dates}} with the
value supplied by |cs1-dates so one of: xxx-l, xxx-ls, xxx-ly, xxx-s, xxx-sy, xxx-y, or simply xxx (|cs1-dates=
empty, omitted, or invalid) where xxx shall be either of dmy or mdy.

dates are extracted from date_parameters_list, reformatted (if appropriate), and then written back into the
list in the new format.  Dates in date_parameters_list are presumed here to be valid (no errors).  This function
returns true when a date has been reformatted, false else.  Actual reformatting is done by reformatter().

]]

local function reformat_dates (date_parameters_list, format)
	local all = false;															-- set to false to skip access- and archive-dates
	local len_p = 'l';															-- default publication date length shall be long
	local len_a = 'l';															-- default access-/archive-date length shall be long
	local result = false;
	local new_date;																
	
	if format:match('%a+%-all') then											-- manual df keyword; auto df keyword when length not specified in {{use xxx dates}}; 
		format = format:match('(%a+)%-all');									-- extract the format
		all = true;																-- all dates are long format dates because this keyword doesn't specify length
	elseif format:match('%a+%-[lsy][sy]?') then									-- auto df keywords; internal only
		all = true;																-- auto df applies to all dates; use length specified by capture len_p for all dates
		format, len_p, len_a = format:match('(%a+)%-([lsy])([sy]?)');			-- extract the format and length keywords
		if 'y' == len_p then													-- because allowed by MOS:DATEUNIFY (sort of) range dates and My dates not reformatted
			format = 'ymd';														-- override {{use xxx dates}}
		elseif (not is_set(len_a)) or (len_p == len_a) then						-- no access-/archive-date length specified or same length as publication dates then
			len_a = len_p;														-- in case len_a not set
		end
	end																			-- else only publication dates and they are long

	for param_name, param_val in pairs (date_parameters_list) do				-- for each date-holding parameter in the list
		if is_set (param_val.val) then											-- if the parameter has a value
			if not (not all and in_array (param_name, {'access-date', 'archive-date'})) then	-- skip access- or archive-date unless format is xxx-all; yeah, ugly; TODO: find a better way
				for pattern_idx, pattern in pairs (patterns) do
					if mw.ustring.match (param_val.val, pattern[1]) then
						if all and in_array (param_name, {'access-date', 'archive-date'}) then	-- if this date is an access- or archive-date
							new_date = reformatter (param_val.val, pattern_idx, (('y' == len_a) and 'ymd') or format, len_a);	-- choose ymd or dmy/mdy according to len_a setting
						else													-- all other dates
							new_date = reformatter (param_val.val, pattern_idx, format, len_p);
						end
						
						if new_date then										-- set when date was reformatted
							date_parameters_list[param_name].val = new_date;	-- update date in date list
							result = true;										-- and announce that changes have been made
							break;
						end
					end	-- if
				end		-- for
			end			-- if
		end				-- if
	end					-- for
	return result;																-- declare boolean result and done
end


--[[--------------------------&lt; D A T E _ H Y P H E N _ T O _ D A S H &gt;----------------------------------------

Loops through the list of date-holding parameters and converts any hyphen to an ndash.  Not called if the cs1|2
template has any date errors.

Modifies the date_parameters_list and returns true if hyphens are replaced, else returns false.

]]

local function date_hyphen_to_dash (date_parameters_list)
	local result = false;
	local n;
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set (param_val.val) and
			not mw.ustring.match (param_val.val, patterns.ymd[1]) then			-- for those that are not ymd dates (ustring because here digits may not be Western)
				param_val.val, n = param_val.val:gsub ('%-', '–');				-- replace any hyphen with ndash
				if 0 ~= n then
					date_parameters_list[param_name].val = param_val.val;		-- update the list
					result = true;
				end
		end
	end
	return result;																-- so we know if any hyphens were replaced
end


--[[-------------------------&lt; D A T E _ N A M E _ X L A T E &gt;------------------------------------------------

Attempts to translate English date names to local-language date names using names supplied by MediaWiki's
date parser function.  This is simple name-for-name replacement and may not work for all languages.

if xlat_dig is true, this function will also translate Western (English) digits to the local language's digits.
This will also translate ymd dates.

]]

local function date_name_xlate (date_parameters_list, xlt_dig)
	local xlate;
	local mode;																	-- long or short month names
	local modified = false;
	local date;
	
	local sources_t = {
		{cfg.date_names.en.long, cfg.date_names.inv_local_long},				-- for translating long English month names to long local month names
		{cfg.date_names.en.short, cfg.date_names.inv_local_short},				-- short month names
		{cfg.date_names.en.quarter, cfg.date_names.inv_local_quarter},			-- quarter date names
		{cfg.date_names.en.season, cfg.date_names.inv_local_season},			-- season date nam
		{cfg.date_names.en.named, cfg.date_names.inv_local_named},				-- named dates
		}

	local function is_xlateable (month)											-- local function to get local date name that replaces existing English-language date name
		for _, date_names_t in ipairs (sources_t) do							-- for each sequence table in date_names_t
			if date_names_t[1][month] then										-- if date name is English month (long or short), quarter, season or named and
				if date_names_t[2][date_names_t[1][month]] then					-- if there is a matching local date name
					return date_names_t[2][date_names_t[1][month]];				-- return the local date name
				end
			end
		end
	end

	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val.val) then											-- if the parameter has a value
			date = param_val.val;
			for month in mw.ustring.gmatch (date, '[%a ]+') do					-- iterate through all date names in the date (single date or date range)
				month = mw.text.trim (month);									-- this because quarterly dates contain whitespace
				xlate = is_xlateable (month);									-- get translate &lt;month&gt;; returns translation or nil
				
				if xlate then		
					date = mw.ustring.gsub (date, month, xlate);				-- replace the English with the translation
					date_parameters_list[param_name].val = date;				-- save the translated date
					modified = true;
				end
			end

			if xlt_dig then														-- shall we also translate digits?
				date = date:gsub ('%d', cfg.date_names.xlate_digits);			-- translate digits from Western to 'local digits'
				date_parameters_list[param_name].val = date;					-- save the translated date
				modified = true;
			end
		end
	end
	
	return modified;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	add_prop_cat = utilities_page_ptr.add_prop_cat ;							-- import functions from selected Module:Citation/CS1/Utilities module
	is_set = utilities_page_ptr.is_set;
	in_array = utilities_page_ptr.in_array;
	set_message = utilities_page_ptr.set_message;
	substitute = utilities_page_ptr.substitute;
	wrap_style = utilities_page_ptr.wrap_style;

	cfg = cfg_table_ptr;														-- import tables from selected Module:Citation/CS1/Configuration
end


--[[--------------------------&lt; A R C H I V E _ D A T E _ C H E C K &gt;------------------------------------------

Compare value in |archive-date= with the timestamp in Wayback machine urls.  Emits an error message with suggested
date from the |archive-url= timestamp in an appropriate format when the value in |archive-date= does not match
the timestamp.

this function never called when any date in a cs1|2 template has errors

error message suggests new |archive-date= value in an appropriate format specified by &lt;df&gt;.  &lt;df&gt; is either 
|df= or cfg.global_df in that order.  If &lt;df&gt; is nil, suggested date has format from |archive-date=.  There is
a caveat: when |df=dmy or |df=mdy, the reformatter leaves |access-date= and |archive-date= formats as they are.
The error message suggested date is passed to the formatter as YYYY-MM-DD so when |df=dmy or |df=mdy, the format
is not changed.

]]

local function archive_date_check (archive_date, archive_url_timestamp, df)
	local archive_date_format = 'dmy-y';										-- holds the date format of date in |archive-date; default to ymd; 'dmy' used here to spoof reformat_dates() 
	
	for _, v_t in ipairs ({{'dMy', 'dmy-all'}, {'Mdy', 'mdy-all'}}) do			-- is |archive-date= format dmy or mdy?
		if archive_date:match (patterns[v_t[1]][1]) then						-- does the pattern match?
			archive_date_format = cfg.keywords_xlate[v_t[2]];					-- get appropriate |df= supported keyword from the i18n translator table
			break;
		end
	end
	
	local dates_t = {};
	dates_t['archive-date'] = {val=archive_date, name=''};						-- setup to call reformat_dates(); never called when errors so &lt;name&gt; unset as not needed
	reformat_dates (dates_t, 'dmy-y');											-- reformat |archive-date= to ymd; 'dmy' used here to spoof reformat_dates()
	local archive_url_date = archive_url_timestamp:gsub ('(%d%d%d%d)(%d%d)(%d%d)%d*', '%1-%2-%3');	-- make ymd format date from timestamp

	if dates_t['archive-date'].val == archive_url_date then						-- are the two dates the same
		return;																	-- yes, done
	else
		dates_t['archive-date'] = {val=archive_url_date, name=''};				-- setup to call reformat_dates() with the timestamp date
		reformat_dates (dates_t, df or archive_date_format);					-- reformat timestamp to format specified by &lt;df&gt; or format used in |archive-date= 
		archive_url_date = dates_t['archive-date'].val;
		set_message ('err_archive_date_url_ts_mismatch', archive_url_date);		-- emit an error message
	end
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {																		-- return exported functions
	archive_date_check = archive_date_check,
	date_hyphen_to_dash = date_hyphen_to_dash,
	date_name_xlate = date_name_xlate,
	dates = dates,
	reformat_dates = reformat_dates,
	set_selected_modules = set_selected_modules,
	year_date_check = year_date_check,
	}</text>
      <sha1>d9i9hsb5bt99p64cyu66e8nnqj6lb6t</sha1>
    </revision>
    <revision>
      <id>4858</id>
      <parentid>4857</parentid>
      <timestamp>2024-03-23T15:32:42Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4858</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="66644" sha1="i9qkckq6672i7afj9xiqmqhw4jkymnu" xml:space="preserve">--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local add_prop_cat, is_set, in_array, set_message, substitute, wrap_style;		-- imported functions from selected Module:Citation/CS1/Utilities
local cfg;																		-- table of tables imported from selected Module:Citation/CS1/Configuration


--[[--------------------------&lt; F I L E - S C O P E   D E C L A R A T I O N S &gt;--------------------------------

File-scope variables are declared here

]]

local lang_object = mw.getContentLanguage();									-- used by is_valid_accessdate(), is_valid_year(), date_name_xlate(); TODO: move to ~/Configuration?
local year_limit;																-- used by is_valid_year()


--[=[-------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |access-date= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-English date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate().  To get around that
call this function with YYYY-MM-DD format dates.

]=]

local function is_valid_accessdate (accessdate)
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold Unix time stamps representing the dates

	good1, access_ts = pcall (lang_object.formatDate, lang_object, 'U', accessdate );			-- convert accessdate value to Unix timestamp 
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which which tonumber() may not understand
		access_ts = tonumber (access_ts) or lang_object:parseFormattedNumber (access_ts);		-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to Unix time stamp
	end

	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end


--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct.
If not a valid month, returns 0

]]

local function get_month_number (month)
	return cfg.date_names['local'].long[month] or cfg.date_names['local'].short[month] or	-- look for local names first
			cfg.date_names['en'].long[month] or	cfg.date_names['en'].short[month] or		-- failing that, look for English names
			0;																				-- not a recognized month name
end


--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 21 for Spring, etc.  Capitalization and spelling
must be correct. If not a valid season, returns 0.
	21-24 = Spring, Summer, Autumn, Winter, independent of “Hemisphere”

returns 0 when &lt;param&gt; is not |date=

Season numbering is defined by Extended Date/Time Format (EDTF) specification (https://www.loc.gov/standards/datetime/)
which became part of ISO 8601 in 2019.  See '§Sub-year groupings'.  The standard defines various divisions using
numbers 21-41.  cs1|2 only supports generic seasons.  EDTF does support the distinction between north and south
hemisphere seasons but cs1|2 has no way to make that distinction.

These additional divisions not currently supported:
	25-28 = Spring - Northern Hemisphere, Summer- Northern Hemisphere, Autumn - Northern Hemisphere, Winter - Northern Hemisphere
	29-32 = Spring – Southern Hemisphere, Summer– Southern Hemisphere, Autumn – Southern Hemisphere, Winter - Southern Hemisphere
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)

]]

local function get_season_number (season, param)
	if 'date' ~= param then
		return 0;																-- season dates only supported by |date=
	end
	return cfg.date_names['local'].season[season] or							-- look for local names first
			cfg.date_names['en'].season[season] or								-- failing that, look for English names
			0;																	-- not a recognized season name
end


--[[--------------------------&lt; G E T _ Q U A R T E R _ N U M B E R &gt;------------------------------------------

returns a number according to the sequence of quarters in a year: 33 for first quarter, etc.  Capitalization and spelling
must be correct. If not a valid quarter, returns 0.
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)

returns 0 when &lt;param&gt; is not |date=

Quarter numbering is defined by Extended Date/Time Format (EDTF) specification (https://www.loc.gov/standards/datetime/)
which became part of ISO 8601 in 2019.  See '§Sub-year groupings'.  The standard defines various divisions using
numbers 21-41.  cs1|2 only supports generic seasons and quarters.

These additional divisions not currently supported:
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)

]]

local function get_quarter_number (quarter, param)
	if 'date' ~= param then
		return 0;																-- quarter dates only supported by |date=
	end
	quarter = mw.ustring.gsub (quarter, ' +', ' ');								-- special case replace multiple space chars with a single space char
	return cfg.date_names['local'].quarter[quarter] or							-- look for local names first
			cfg.date_names['en'].quarter[quarter] or							-- failing that, look for English names
			0;																	-- not a recognized quarter name
end


--[[--------------------------&lt; G E T _ P R O P E R _ N A M E _ N U M B E R &gt;----------------------------------

returns a non-zero number if date contains a recognized proper-name.  Capitalization and spelling must be correct.

returns 0 when &lt;param&gt; is not |date=

]]

local function get_proper_name_number (name, param)
	if 'date' ~= param then
		return 0;																-- proper-name dates only supported by |date=
	end
	return cfg.date_names['local'].named[name] or								-- look for local names dates first
			cfg.date_names['en'].named[name] or									-- failing that, look for English names
			0;																	-- not a recognized named date
end


--[[--------------------------&lt; G E T _ E L E M E N T _ N U M B E R &lt;------------------------------------------

returns true if month or season or quarter or proper name is valid (properly spelled, capitalized, abbreviated)

]]

local function get_element_number (element, param)
	local num;
	
	local funcs = {get_month_number, get_season_number, get_quarter_number, get_proper_name_number};	-- list of functions to execute in order
	
	for _, func in ipairs (funcs) do											-- spin through the function list
		num = func (element, param);											-- call the function and get the returned number
		if 0 ~= num then														-- non-zero when valid month season quarter 
			return num;															-- return that number
		end
	end
	return nil;																	-- not valid
end


--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one
year in the future are not acceptable.

Special case for |pmc-embargo-date=: years more than two years in the future are not acceptable

]]

local function is_valid_year (year, param)
	if not is_set (year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;									-- global variable so we only have to fetch it once
	end

	year = tonumber (year) or lang_object:parseFormattedNumber (year);			-- convert to number for the comparison
	if year and (100 &gt; year) then												-- years less than 100 not supported
		return false;
	end
	
	if 'pmc-embargo-date' == param then											-- special case for |pmc-embargo-date=
		return year and (year &lt;= tonumber(os.date(&quot;%Y&quot;))+2) or false;			-- years more than two years in the future are not accepted
	end	
	return year and (year &lt;= year_limit) or false;
end


--[[--------------------------&lt; I S _ V A L I D _ D A T E &gt;----------------------------------------------------

Returns true if day is less than or equal to the number of days in month and year is no farther into the future
than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap
years before 1582 and Gregorian leap years after 1582. Where the two calendars overlap (1582 to approximately
1923) dates are assumed to be Gregorian.

]]

local function is_valid_date (year, month, day, param)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year (year, param) then										-- no farther into the future than next year except |pmc-embargo-date= no more than two years in the future
		return false;
	end
	
	month = tonumber (month);													-- required for YYYY-MM-DD dates
	
	if (2 == month) then														-- if February
		month_length = 28;														-- then 28 days unless
		if 1582 &gt; tonumber(year) then											-- Julian calendar
			if 0 == (year%4) then												-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		else																	-- Gregorian calendar
			if (0 == (year%4) and (0 ~= (year%100) or 0 == (year%400))) then	-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		end
	else
		month_length = days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
This function looks in cfg.date_names{} to see if both month names are listed in the long subtable or both are
listed in the short subtable.  When both have the same style (both are listed in the same table), returns true; false else

]]

local function is_valid_month_range_style (month1, month2)
	if (cfg.date_names.en.long[month1] and cfg.date_names.en.long[month2]) or					-- are both English names listed in the long subtable?
		(cfg.date_names.en.short[month1] and cfg.date_names.en.short[month2]) or				-- are both English names listed in the short subtable?
		(cfg.date_names['local'].long[month1] and cfg.date_names['local'].long[month2]) or		-- are both local names listed in the long subtable?
		(cfg.date_names['local'].short[month1] and cfg.date_names['local'].short[month2]) then	-- are both local names listed in the short subtable?
			return true;
	end
	return false;																-- names are mixed
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

All season ranges are accepted as valid because there are publishers out there who have published a Summer–Spring YYYY issue, hence treat as ok

]]

local function is_valid_month_season_range(range_start, range_end, param)
	local range_start_number = get_month_number (range_start);
	local range_end_number;

	if 0 == range_start_number then												-- is this a month range?
		range_start_number = get_season_number (range_start, param);			-- not a month; is it a season? get start season number
		range_end_number = get_season_number (range_end, param);				-- get end season number

		if (0 ~= range_start_number) and (0 ~= range_end_number) and (range_start_number ~= range_end_number) then
			return true;														-- any season pairing is accepted except when both are the same
		end
		return false;															-- range_start and/or range_end is not a season
	end
																				-- here when range_start is a month
	range_end_number = get_month_number (range_end);							-- get end month number
	if range_start_number &lt; range_end_number and								-- range_start is a month; does range_start precede range_end?
		is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
	end
	return false;																-- range_start month number is greater than or equal to range end number; or range end isn't a month
end


--[[--------------------------&lt; M A K E _ C O I N S _ D A T E &gt;------------------------------------------------

This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1.  The function is called only for |date= parameters and only if the |date=&lt;value&gt; is 
determined to be a valid date format.  The question of what to do with invalid date formats is not answered here.

The date parts in the input table are converted to an ISO 8601 conforming date string:
	single whole dates:		yyyy-mm-dd
	month and year dates:	yyyy-mm
	year dates:				yyyy
	ranges:					yyyy-mm-dd/yyyy-mm-dd
							yyyy-mm/yyyy-mm
							yyyy/yyyy

Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.

The input table has:
	year, year2 – always present; if before 1582, ignore months and days if present
	month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 99 Christmas
	day, day2 –  0 if not provided, 1-31 for days
	
the output table receives:
	rftdate:	an ISO 8601 formatted date
	rftchron:	a free-form version of the date, usually without year which is in rftdate (season ranges and proper-name dates)
	rftssn:		one of four season keywords: winter, spring, summer, fall (lowercase)
	rftquarter:	one of four values: 1, 2, 3, 4

]]

local function make_COinS_date (input, tCOinS_date)
	local date;																	-- one date or first date in a range
	local date2 = '';															-- end of range date
	input.year = tonumber (input.year) or lang_object:parseFormattedNumber (input.year);	-- language-aware tonumber()
	input.year2 = tonumber (input.year2) or lang_object:parseFormattedNumber (input.year2);	-- COinS dates are pseudo-ISO 8601 so convert to Arabic numerals

	if ((1582 == input.year) and (10 &gt; input.month)) or (1582 &gt; input.year) then	-- if a Julian calendar date
		tCOinS_date.rftdate = tostring (input.year);							-- &amp;rft.date gets year only
		return;																	-- done
	end
																				-- here for all forms of Gregorian dates
	if 20 &lt; tonumber (input.month) then											-- if season, quarter, or proper-name date
		date = input.year;														-- &amp;rft.date gets year only
		if 0 ~= input.year2 and input.year ~= input.year2 then					-- if a range, only the second year portion when not the same as range start year
			date = string.format ('%.4d/%.4d', input.year, input.year2)			-- assemble the date range
		end

		local season = {[24] = 'winter', [21] = 'spring', [22] = 'summer', [23] = 'fall', [33] = '1', [34] = '2', [35] = '3', [36] = '4', [98] = 'Easter', [99] = 'Christmas'};	-- seasons lowercase, no autumn; proper-names use title case
		if 0 == input.month2 then												-- single season, quarter, or proper-name date
			if 40 &lt; tonumber(input.month) then
				tCOinS_date.rftchron = season[input.month];						-- proper-name date; used in journal metadata only
			elseif 30 &lt; tonumber(input.month) then
				tCOinS_date.rftquarter = season[input.month];					-- quarter date; used in journal metadata only
			else
				tCOinS_date.rftssn = season[input.month];						-- season date; used in journal metadata only
			end
		else																	-- season ranges are lumped into &amp;rft.chron; &amp;rft.ssn and &amp;rft.quarter are left blank
			if input.year ~= input.year2 then									-- season year – season year range or season year–year
				if 0 ~= input.month2 then
					tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);	-- used in journal metadata only
				end
			else																-- season–season year range
				tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2];	-- season–season year range; used in journal metadata only
			end
		end

		tCOinS_date.rftdate = tostring (date);
		return;																	-- done
	end
																				-- here for gregorian calendar dates
	if 0 ~= input.day then
		date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day));	-- whole date
	elseif 0 ~= input.month then
		date = string.format ('%s-%.2d', input.year, tonumber(input.month));	-- year and month
	else
		date = string.format ('%s', input.year);								-- just year
	end

	if 0 ~= input.year2 then
		if 0 ~= input.day2 then
			date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2));		-- whole date
		elseif 0 ~= input.month2 then
			date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2));	-- year and month
		else
			date2 = string.format ('/%s', input.year2);							-- just year
		end
	end
	
	tCOinS_date.rftdate = date .. date2;										-- date2 has the '/' separator
	return;
end


--[[--------------------------&lt; P A T T E R N S &gt;--------------------------------------------------------------

this is the list of patterns for date formats that this module recognizes.  Approximately the first half of these
patterns represent formats that might be reformatted into another format.  Those that might be reformatted have
'indicator' letters that identify the content of the matching capture: 'd' (day), 'm' (month), 'a' (anchor year),
'y' (year); second day, month, year have a '2' suffix.

These patterns are used for both date validation and for reformatting.  This table should not be moved to ~/Configuration
because changes to this table require changes to check_date() and to reformatter() and reformat_date()

]]

local patterns = {
	 																			-- year-initial numerical year-month-day
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'},					
																				-- month-initial: month day, year
	['Mdy'] = {'^(%D-) +([1-9]%d?), +((%d%d%d%d?)%a?)$', 'm', 'd', 'a', 'y'},
																				-- month-initial day range: month day–day, year; days are separated by endash
	['Md-dy'] = {'^(%D-) +([1-9]%d?)[%-–]([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'd2', 'a', 'y'},
																				-- day-initial: day month year
	['dMy'] = {'^([1-9]%d?) +(%D-) +((%d%d%d%d?)%a?)$', 'd', 'm', 'a', 'y'},
																				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed; not supported at en.wiki
	--	['yMd'] = {'^((%d%d%d%d?)%a?) +(%D-) +(%d%d?)$', 'a', 'y', 'm', 'd'},
																				-- day-range-initial: day–day month year; days are separated by endash
	['d-dMy'] = {'^([1-9]%d?)[%-–]([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'd2', 'm', 'a', 'y'},
																				-- day initial month-day-range: day month - day month year; uses spaced endash
	['dM-dMy'] = {'^([1-9]%d?) +(%D-) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'd2', 'm2', 'a', 'y'},
																				-- month initial month-day-range: month day – month day, year;  uses spaced endash
	['Md-Mdy'] = {'^(%D-) +([1-9]%d?) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$','m', 'd', 'm2', 'd2', 'a', 'y'},
																				-- day initial month-day-year-range: day month year - day month year; uses spaced endash
	['dMy-dMy'] = {'^([1-9]%d?) +(%D-) +(%d%d%d%d) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'y', 'd2', 'm2', 'a', 'y2'},
																				-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
	['Mdy-Mdy'] = {'^(%D-) +([1-9]%d?), +(%d%d%d%d) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'y', 'm2', 'd2', 'a', 'y2'},

																				-- these date formats cannot be converted, per se, but month name can be rendered short or long
																				-- month/season year - month/season year; separated by spaced endash
	['My-My'] = {'^(%D-) +(%d%d%d%d) +[%-–] +(%D-) +((%d%d%d%d)%a?)$', 'm', 'y', 'm2', 'a', 'y2'},
																				-- month/season range year; months separated by endash
	['M-My'] = {'^(%D-)[%-–](%D-) +((%d%d%d%d)%a?)$', 'm', 'm2', 'a', 'y'},
																				-- month/season year or proper-name year; quarter year when First Quarter YYYY etc.
	['My'] = {'^([^%d–]-) +((%d%d%d%d)%a?)$', 'm', 'a', 'y'},					-- this way because endash is a member of %D; %D- will match January–March 2019 when it shouldn't

																				-- these date formats cannot be converted
	['Sy4-y2'] = {'^(%D-) +((%d%d)%d%d)[%-–]((%d%d)%a?)$'},						-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
	['Sy-y'] = {'^(%D-) +(%d%d%d%d)[%-–]((%d%d%d%d)%a?)$'},						-- special case Winter/Summer year-year; year separated with unspaced endash
	['y-y'] = {'^(%d%d%d%d?)[%-–]((%d%d%d%d?)%a?)$'},							-- year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
	['y4-y2'] = {'^((%d%d)%d%d)[%-–]((%d%d)%a?)$'},								-- year range: YYYY–YY; separated by unspaced endash
	['y'] = {'^((%d%d%d%d?)%a?)$'},												-- year; here accept either YYY or YYYY
	}


--[[--------------------------&lt; I S _ V A L I D _ E M B A R G O _ D A T E &gt;------------------------------------

returns true and date value if that value has proper dmy, mdy, ymd format.

returns false and 9999 (embargoed forever) when date value is not proper format; assumes that when |pmc-embargo-date= is
set, the editor intended to embargo a PMC but |pmc-embargo-date= does not hold a single date.

]]

local function is_valid_embargo_date (v)
	if v:match (patterns['ymd'][1]) or											-- ymd
		v:match (patterns['Mdy'][1]) or											-- dmy
		v:match (patterns['dMy'][1]) then										-- mdy
			return true, v;
	end
	return false, '9999';														-- if here not good date so return false and set embargo date to long time in future
end


--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only
allowed range separator is endash.  Additionally, check the date to see that it is a real date: no 31 in 30-day
months; no 29 February when not a leap year.  Months, both long-form and three character abbreviations, and seasons
must be spelled correctly.  Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and
COinS_date.  When this happens, the date parameter is (DEBUG: not?) used in the COinS metadata and the CITEREF identifier gets
its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, publication-date, access-date, pmc-embargo-date, archive-date, lay-date)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is ISO 8601 format date; see make_COInS_date()

]]

local function check_date (date_string, param, tCOinS_date)
	local year;																	-- assume that year2, months, and days are not used;
	local year2 = 0;															-- second year in a year range
	local month = 0;
	local month2 = 0;															-- second month in a month range
	local day = 0;
	local day2 = 0;																-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match (patterns['ymd'][1]) then								-- year-initial numerical year month day format
		year, month, day = date_string:match (patterns['ymd'][1]);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or 0 == tonumber(day) then return false; end	-- month or day number not valid or not Gregorian calendar
		anchor_year = year;
	
	elseif mw.ustring.match(date_string, patterns['Mdy'][1]) then				-- month-initial: month day, year
		month, day, anchor_year, year = mw.ustring.match(date_string, patterns['Mdy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
				
	elseif mw.ustring.match(date_string, patterns['Md-dy'][1]) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year = mw.ustring.match(date_string, patterns['Md-dy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2=month;															-- for metadata
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['dMy'][1]) then				-- day-initial: day month year
		day, month, anchor_year, year = mw.ustring.match(date_string, patterns['dMy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months

--[[ NOT supported at en.wiki
	elseif mw.ustring.match(date_string, patterns['yMd'][1]) then				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed
		anchor_year, year, month, day = mw.ustring.match(date_string, patterns['yMd'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
-- end NOT supported at en.wiki ]]

	elseif mw.ustring.match(date_string, patterns['d-dMy'][1]) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year = mw.ustring.match(date_string, patterns['d-dMy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2 = month;															-- for metadata
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['dM-dMy'][1]) then			-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year = mw.ustring.match(date_string, patterns['dM-dMy'][1]);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['Md-Mdy'][1]) then			-- month initial month-day-range: month day – month day, year; uses spaced endash
		month, day, month2, day2, anchor_year, year = mw.ustring.match(date_string, patterns['Md-Mdy'][1]);
		if (not is_valid_month_season_range(month, month2, param)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['dMy-dMy'][1]) then			-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2 = mw.ustring.match(date_string, patterns['dMy-dMy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		if 0 == month or 0 == month2 then return false; end						-- both must be valid

	elseif mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]) then			-- month initial month-day-year-range: month day, year – month day, year; uses spaced endash
		month, day, year, month2, day2, anchor_year, year2 = mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number(month2);
		if 0 == month or 0 == month2 then return false; end						-- both must be valid

	elseif mw.ustring.match(date_string, patterns['Sy4-y2'][1]) then			-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		local century;
		month, year, century, anchor_year, year2 = mw.ustring.match(date_string, patterns['Sy4-y2'][1]);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;		-- 'month' can only be Winter or Summer
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor_year from both years
		year2 = century..year2;													-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		month = get_season_number(month, param);

	elseif mw.ustring.match(date_string, patterns['Sy-y'][1]) then				-- special case Winter/Summer year-year; year separated with unspaced endash
		month, year, anchor_year, year2 = mw.ustring.match(date_string, patterns['Sy-y'][1]);
		month = get_season_number (month, param);								-- &lt;month&gt; can only be winter or summer; also for metadata
		if (month ~= cfg.date_names['en'].season['Winter']) and (month ~= cfg.date_names['en'].season['Summer']) then
			return false;														-- not Summer or Winter; abandon
		end
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, patterns['My-My'][1]) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2 = mw.ustring.match(date_string, patterns['My-My'][1]);
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then 	-- both must be month year, same month style
			month = get_month_number(month);
			month2 = get_month_number(month2);
		elseif 0 ~= get_season_number(month, param) and 0 ~= get_season_number(month2, param) then	-- both must be season year, not mixed
			month = get_season_number(month, param);
			month2 = get_season_number(month2, param);
		else
			 return false;
		end

	elseif mw.ustring.match(date_string, patterns['M-My'][1]) then				-- month/season range year; months separated by endash 
		month, month2, anchor_year, year = mw.ustring.match(date_string, patterns['M-My'][1]);
		if (not is_valid_month_season_range(month, month2, param)) or (not is_valid_year(year)) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
			month2 = get_month_number(month2);
			if 0 == month or 0 == month2 then return false; end
		else
			month = get_season_number(month, param);
			month2 = get_season_number(month2, param);
		end
		year2 = year;
		
	elseif mw.ustring.match(date_string, patterns['My'][1]) then				-- month/season/quarter/proper-name year
		month, anchor_year, year = mw.ustring.match(date_string, patterns['My'][1]);
		if not is_valid_year(year) then return false; end
		month = get_element_number(month, param);								-- get month season quarter proper-name number or nil
		if not month then return false; end										-- not valid whatever it is

	elseif mw.ustring.match(date_string, patterns['y-y'][1]) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2 = mw.ustring.match(date_string, patterns['y-y'][1]);
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, patterns['y4-y2'][1]) then				-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2 = mw.ustring.match(date_string, patterns['y4-y2'][1]);
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor year from both years

		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century .. year2;												-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

		if in_array (param, {'date', 'publication-date', 'year'}) then			-- here when 'valid' abbreviated year range; if one of these parameters
			add_prop_cat ('year-range-abbreviated');							-- add properties cat
		end

	elseif mw.ustring.match(date_string, patterns['y'][1]) then					-- year; here accept either YYY or YYYY
		anchor_year, year = mw.ustring.match(date_string, patterns['y'][1]);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;															-- date format not one of the MOS:DATE approved formats
	end

	if param ~= 'date' then														-- CITEREF disambiguation only allowed in |date=; |year= &amp; |publication-date= promote to date
		if anchor_year:match ('%l$') then
			return false;
		end
	end

	if 'access-date' == param then												-- test access-date here because we have numerical date parts
		if 0 ~= year and 0 ~= month and 0 ~= day and 							-- all parts of a single date required
			0 == year2 and 0 == month2 and 0 == day2 then						-- none of these; access-date must not be a range
				if not is_valid_accessdate(year .. '-' .. month .. '-' .. day) then	
					return false;												-- return false when access-date out of bounds
				end
		else
			return false;														-- return false when access-date is a range of two dates
		end
	end

	if 'archive-date' == param then												-- test archive-date here because we have numerical date parts
		if not (0 ~= year and 0 ~= month and 0 ~= day and						-- all parts of a single date required
			0 == year2 and 0 == month2 and 0 == day2) then						-- none of these; archive-date must not be a range
				return false;													-- return false when archive-date is a range of two dates
		end
	end

	local result=true;															-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result = is_valid_date (year, month, day, param);						-- &lt;param&gt; for |pmc-embargo-date=

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result = is_valid_date (year, month, day);
		result = result and is_valid_date (year, month, day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result = is_valid_date (year, month, day);
		result = result and is_valid_date (year, month2, day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result = is_valid_date(year, month, day);
		result = result and is_valid_date(year2, month2, day2);
	end
	
	if false == result then return false; end

	if nil ~= tCOinS_date then													-- this table only passed into this function when testing |date= parameter values
		make_COinS_date ({year = year, month = month, day = day, year2 = year2, month2 = month2, day2 = day2}, tCOinS_date);	-- make an ISO 8601 date string for COinS
	end
	
	return true, anchor_year;													-- format is good and date string represents a real date
end	


--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
parameters with errors are added to the &lt;error_list&gt; sequence table as the dates are tested.

]]

local function dates(date_parameters_list, tCOinS_date, error_list)
	local anchor_year;															-- will return as nil if the date being tested is not |date=
	local COinS_date;															-- will return as nil if the date being tested is not |date=
	local embargo_date;															-- if embargo date is a good dmy, mdy, ymd date then holds original value else reset to 9999
	local good_date = false;

	for k, v in pairs(date_parameters_list) do									-- for each date-holding parameter in the list
		if is_set(v.val) then													-- if the parameter has a value
			v.val = mw.ustring.gsub(v.val, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9
			if v.val:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then						-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v.val:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);				-- get the year portion so it can be tested
				if 'date' == k then
					anchor_year, COinS_date = v.val:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year' == k then
					good_date = is_valid_year(year);
				end
			elseif 'date' == k then												-- if the parameter is |date=
				if v.val:match(&quot;^n%.d%.%a?$&quot;) then -- ToDo: I18N								-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((n%.d%.)%a?)&quot;); -- ToDo: I18N	-- &quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v.val:match(&quot;^nd%a?$&quot;) then -- ToDo: I18N								-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((nd)%a?)&quot;); -- ToDo: I18N	-- &quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v.val, k, tCOinS_date);	-- go test the date
				end
			elseif 'year' == k then												-- if the parameter is |year= it should hold only a year value
				if v.val:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then						-- if |year = 3 or 4 digits only with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((%d+)%a?)&quot;);
				end
			elseif 'pmc-embargo-date' == k then									-- if the parameter is |pmc-embargo-date=
				good_date = check_date (v.val, k);								-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date, embargo_date = is_valid_embargo_date (v.val);	-- is |pmc-embargo-date= date a single dmy, mdy, or ymd formatted date? yes: returns embargo date; no: returns 9999
				end
			else																-- any other date-holding parameter
				good_date = check_date (v.val, k);								-- go test the date
			end
			if false == good_date then											-- assemble one error message so we don't add the tracking category multiple times
				table.insert (error_list, wrap_style ('parameter', v.name));	-- make parameter name suitable for error message list
			end
		end
	end
	return anchor_year, embargo_date;											-- and done
end


--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function sets a local numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

the numeric value in &lt;result&gt; determines the 'output' if any from this function:
	0 – adds error message to error_list sequence table
	1 – adds maint cat
	2 – does nothing

]]

local function year_date_check (year_string, year_origin, date_string, date_origin, error_list)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes

	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where both date and year are required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard range formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif mw.ustring.match(date_string, &quot;%d%d%d%d[%-–]%d%d&quot;) then				-- YYYY-YY date ranges
		local century;
		date1, century, date2 = mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	else																		-- should never get here; this function called only when no other date errors
		result = 0;																-- no recognizable year in date
	end

	if 0 == result then															-- year / date mismatch
		table.insert (error_list, substitute (cfg.messages['mismatch'], {year_origin, date_origin}));	-- add error message to error_list sequence table
	elseif 1 == result then														-- redundant year / date
		set_message ('maint_date_year');										-- add a maint cat
	end
end


--[[--------------------------&lt; R E F O R M A T T E R &gt;--------------------------------------------------------

reformat 'date' into new format specified by format_param if pattern_idx (the current format of 'date') can be
reformatted.  Does the grunt work for reformat_dates().

The table re_formats maps pattern_idx (current format) and format_param (desired format) to a table that holds:
	format string used by string.format()
	identifier letters ('d', 'm', 'y', 'd2', 'm2', 'y2') that serve as indexes into a table t{} that holds captures
		from mw.ustring.match() for the various date parts specified by  patterns[pattern_idx][1]

Items in patterns{} have the general form:
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'}, where:
		['ymd'] is pattern_idx
		patterns['ymd'][1] is the match pattern with captures for mw.ustring.match()
		patterns['ymd'][2] is an indicator letter identifying the content of the first capture
		patterns['ymd'][3] ... the second capture etc.

when a pattern matches a date, the captures are loaded into table t{} in capture order using the idemtifier
characters as indexes into t{}  For the above, a ymd date is in t{} as:
	t.y = first capture (year), t.m = second capture (month), t.d = third capture (day)

To reformat, this function is called with the pattern_idx that matches the current format of the date and with
format_param set to the desired format.  This function loads table t{} as described and then calls string.format()
with the format string specified by re_format[pattern_idx][format_param][1] using values taken from t{} according
to the capture identifier letters specified by patterns[pattern_idx][format_param][n] where n is 2..

]]

local re_formats = {
	['ymd'] = {																	-- date format is ymd; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
	--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},								-- |df=yMd; not supported at en.wiki
		},
	['Mdy'] = {																	-- date format is Mdy; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- for long/short reformatting
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
	--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},								-- |df=yMd; not supported at en.wiki
		},
	['dMy'] = {																	-- date format is dMy; reformat to:
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- for long/short reformatting
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
	--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},								-- |df=yMd; not supported at en.wiki
		},
	['Md-dy'] = {																-- date format is Md-dy; reformat to:
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- for long/short reformatting
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- |df=dmy -&gt; d-dMy 
		},
	['d-dMy'] = {																-- date format is d-d&gt;y; reformat to:
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- for long/short reformatting
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- |df=mdy -&gt; Md-dy 
		},
	['dM-dMy'] = {																-- date format is dM-dMy; reformat to:
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- for long/short reformatting
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd', 'm2', 'd2', 'y'},				-- |df=mdy -&gt; Md-Mdy 
		},
	['Md-Mdy'] = {																-- date format is Md-Mdy; reformat to:
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd',  'm2', 'd2', 'y'},			-- for long/short reformatting
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- |df=dmy -&gt; dM-dMy 
		},
	['dMy-dMy'] = {																-- date format is dMy-dMy; reformat to:
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- for long/short reformatting
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- |df=mdy -&gt; Mdy-Mdy 
		},
	['Mdy-Mdy'] = {																-- date format is Mdy-Mdy; reformat to:
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- for long/short reformatting
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- |df=dmy -&gt; dMy-dMy 
		},
	['My-My'] = {																-- these for long/short reformatting
		['any'] = {'%s %s – %s %s', 'm', 'y', 'm2', 'y2'},						-- dmy/mdy agnostic
		},
	['M-My'] = {																-- these for long/short reformatting
		['any'] = {'%s–%s %s', 'm', 'm2', 'y'},									-- dmy/mdy agnostic
		},
	['My'] = {																	-- these for long/short reformatting
		['any'] = {'%s %s', 'm', 'y'},											-- dmy/mdy agnostic
		},
	--	['yMd'] = {																-- not supported at en.wiki
	--		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},								-- |df=mdy
	--		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},								-- |df=dmy
	--		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},								-- |df=ymd
	--		},
	}


local function reformatter (date, pattern_idx, format_param, mon_len)
	if not in_array (pattern_idx, {'ymd', 'Mdy', 'Md-dy', 'dMy', 'yMd', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- not in this set of date format patterns then not a reformattable date
	end
	
	if 'ymd' == format_param and in_array (pattern_idx, {'ymd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- ymd date ranges not supported at en.wiki; no point in reformatting ymd to ymd
	end

	if in_array (pattern_idx, {'My', 'M-My', 'My-My'}) then						-- these are not dmy/mdy so can't be 'reformatted' into either
		format_param = 'any';													-- so format-agnostic 
	end

																				-- yMd is not supported at en.wiki; when yMd is supported at your wiki, uncomment the next line
	--	if 'yMd' == format_param and in_array (pattern_idx, {'yMd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy'}) then	-- these formats not convertable; yMd not supported at en.wiki
	if 'yMd' == format_param then												-- yMd not supported at en.wiki; when yMd is supported at your wiki, remove or comment-out this line
		return;																	-- not a reformattable date
	end
	
	local c1, c2, c3, c4, c5, c6, c7;											-- these hold the captures specified in patterns[pattern_idx][1]
	c1, c2, c3, c4, c5, c6, c7 = mw.ustring.match (date, patterns[pattern_idx][1]);	-- get the captures

	local t = {																	-- table that holds k/v pairs of date parts from the captures and patterns[pattern_idx][2..]
		[patterns[pattern_idx][2]] = c1;										-- at minimum there is always one capture with a matching indicator letter
		[patterns[pattern_idx][3] or 'x'] = c2;									-- patterns can have a variable number of captures; each capture requires an indicator letter;
		[patterns[pattern_idx][4] or 'x'] = c3;									-- where there is no capture, there is no indicator letter so n in patterns[pattern_idx][n] will be nil;
		[patterns[pattern_idx][5] or 'x'] = c4;									-- the 'x' here spoofs an indicator letter to prevent 'table index is nil' error
		[patterns[pattern_idx][6] or 'x'] = c5;
		[patterns[pattern_idx][7] or 'x'] = c6;
		[patterns[pattern_idx][8] or 'x'] = c7;
		};

	if t.a then																	-- if this date has an anchor year capture (all convertable date formats except ymd)
		if t.y2 then															-- for year range date formats														
			t.y2 = t.a;															-- use the anchor year capture when reassembling the date
		else																	-- here for single date formats (except ymd)
			t.y = t.a;															-- use the anchor year capture when reassembling the date
		end
	end

	if tonumber(t.m) then														-- if raw month is a number (converting from ymd)
		if 's' == mon_len then													-- if we are to use abbreviated month names
			t.m = cfg.date_names['inv_local_short'][tonumber(t.m)];					-- convert it to a month name
		else
			t.m = cfg.date_names['inv_local_long'][tonumber(t.m)];					-- convert it to a month name
		end
		t.d = t.d:gsub ('0(%d)', '%1');											-- strip leading '0' from day if present
	elseif 'ymd' == format_param then											-- when converting to ymd
		t.y = t.y:gsub ('%a', '');												-- strip CITREF disambiguator if present; anchor year already known so process can proceed; TODO: maint message?
		if 1582 &gt; tonumber (t.y) then											-- ymd format dates not allowed before 1582
			return;
		end
		t.m = string.format ('%02d', get_month_number (t.m));					-- make sure that month and day are two digits
		t.d = string.format ('%02d', t.d);
	elseif mon_len then															-- if mon_len is set to either 'short' or 'long'
		for _, mon in ipairs ({'m', 'm2'}) do									-- because there can be two month names, check both 
			if t[mon] then
				t[mon] = get_month_number (t[mon]);								-- get the month number for this month (is length agnostic)
				if 0 == t[mon] then return; end									-- seasons and named dates can't be converted
				t[mon] = (('s' == mon_len) and cfg.date_names['inv_local_short'][t[mon]]) or cfg.date_names['inv_local_long'][t[mon]];	-- fetch month name according to length
			end
		end
	end

	local new_date = string.format (re_formats[pattern_idx][format_param][1],	-- format string
		t[re_formats[pattern_idx][format_param][2]],							-- named captures from t{}
		t[re_formats[pattern_idx][format_param][3]],
		t[re_formats[pattern_idx][format_param][4]],
		t[re_formats[pattern_idx][format_param][5]],
		t[re_formats[pattern_idx][format_param][6]],
		t[re_formats[pattern_idx][format_param][7]],
		t[re_formats[pattern_idx][format_param][8]]
		);

	return new_date;
end


--[[-------------------------&lt; R E F O R M A T _ D A T E S &gt;--------------------------------------------------

Reformats existing dates into the format specified by format.

format is one of several manual keywords: dmy, dmy-all, mdy, mdy-all, ymd, ymd-all.  The -all version includes
access- and archive-dates; otherwise these dates are not reformatted.

This function allows automatic date formatting.  In ~/Configuration, the article source is searched for one of
the {{use xxx dates}} templates.  If found, xxx becomes the global date format as xxx-all.  If |cs1-dates= in
{{use xxx dates}} has legitimate value then that value determines how cs1|2 dates will be rendered.  Legitimate
values for |cs1-dates= are:
	l - all dates are rendered with long month names
	ls - publication dates use long month names; access-/archive-dates use abbreviated month names
	ly - publication dates use long month names; access-/archive-dates rendered in ymd format
	s - all dates are rendered with abbreviated (short) month names
	sy - publication dates use abbreviated month names; access-/archive-dates rendered in ymd format
	y - all dates are rendered in ymd format

the format argument for automatic date formatting will be the format specified by {{use xxx dates}} with the
value supplied by |cs1-dates so one of: xxx-l, xxx-ls, xxx-ly, xxx-s, xxx-sy, xxx-y, or simply xxx (|cs1-dates=
empty, omitted, or invalid) where xxx shall be either of dmy or mdy.

dates are extracted from date_parameters_list, reformatted (if appropriate), and then written back into the
list in the new format.  Dates in date_parameters_list are presumed here to be valid (no errors).  This function
returns true when a date has been reformatted, false else.  Actual reformatting is done by reformatter().

]]

local function reformat_dates (date_parameters_list, format)
	local all = false;															-- set to false to skip access- and archive-dates
	local len_p = 'l';															-- default publication date length shall be long
	local len_a = 'l';															-- default access-/archive-date length shall be long
	local result = false;
	local new_date;																
	
	if format:match('%a+%-all') then											-- manual df keyword; auto df keyword when length not specified in {{use xxx dates}}; 
		format = format:match('(%a+)%-all');									-- extract the format
		all = true;																-- all dates are long format dates because this keyword doesn't specify length
	elseif format:match('%a+%-[lsy][sy]?') then									-- auto df keywords; internal only
		all = true;																-- auto df applies to all dates; use length specified by capture len_p for all dates
		format, len_p, len_a = format:match('(%a+)%-([lsy])([sy]?)');			-- extract the format and length keywords
		if 'y' == len_p then													-- because allowed by MOS:DATEUNIFY (sort of) range dates and My dates not reformatted
			format = 'ymd';														-- override {{use xxx dates}}
		elseif (not is_set(len_a)) or (len_p == len_a) then						-- no access-/archive-date length specified or same length as publication dates then
			len_a = len_p;														-- in case len_a not set
		end
	end																			-- else only publication dates and they are long

	for param_name, param_val in pairs (date_parameters_list) do				-- for each date-holding parameter in the list
		if is_set (param_val.val) then											-- if the parameter has a value
			if not (not all and in_array (param_name, {'access-date', 'archive-date'})) then	-- skip access- or archive-date unless format is xxx-all; yeah, ugly; TODO: find a better way
				for pattern_idx, pattern in pairs (patterns) do
					if mw.ustring.match (param_val.val, pattern[1]) then
						if all and in_array (param_name, {'access-date', 'archive-date'}) then	-- if this date is an access- or archive-date
							new_date = reformatter (param_val.val, pattern_idx, (('y' == len_a) and 'ymd') or format, len_a);	-- choose ymd or dmy/mdy according to len_a setting
						else													-- all other dates
							new_date = reformatter (param_val.val, pattern_idx, format, len_p);
						end
						
						if new_date then										-- set when date was reformatted
							date_parameters_list[param_name].val = new_date;	-- update date in date list
							result = true;										-- and announce that changes have been made
							break;
						end
					end	-- if
				end		-- for
			end			-- if
		end				-- if
	end					-- for
	return result;																-- declare boolean result and done
end


--[[--------------------------&lt; D A T E _ H Y P H E N _ T O _ D A S H &gt;----------------------------------------

Loops through the list of date-holding parameters and converts any hyphen to an ndash.  Not called if the cs1|2
template has any date errors.

Modifies the date_parameters_list and returns true if hyphens are replaced, else returns false.

]]

local function date_hyphen_to_dash (date_parameters_list)
	local result = false;
	local n;
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set (param_val.val) and
			not mw.ustring.match (param_val.val, patterns.ymd[1]) then			-- for those that are not ymd dates (ustring because here digits may not be Western)
				param_val.val, n = param_val.val:gsub ('%-', '–');				-- replace any hyphen with ndash
				if 0 ~= n then
					date_parameters_list[param_name].val = param_val.val;		-- update the list
					result = true;
				end
		end
	end
	return result;																-- so we know if any hyphens were replaced
end


--[[-------------------------&lt; D A T E _ N A M E _ X L A T E &gt;------------------------------------------------

Attempts to translate English date names to local-language date names using names supplied by MediaWiki's
date parser function.  This is simple name-for-name replacement and may not work for all languages.

if xlat_dig is true, this function will also translate Western (English) digits to the local language's digits.
This will also translate ymd dates.

]]

local function date_name_xlate (date_parameters_list, xlt_dig)
	local xlate;
	local mode;																	-- long or short month names
	local modified = false;
	local date;
	
	local sources_t = {
		{cfg.date_names.en.long, cfg.date_names.inv_local_long},				-- for translating long English month names to long local month names
		{cfg.date_names.en.short, cfg.date_names.inv_local_short},				-- short month names
		{cfg.date_names.en.quarter, cfg.date_names.inv_local_quarter},			-- quarter date names
		{cfg.date_names.en.season, cfg.date_names.inv_local_season},			-- season date nam
		{cfg.date_names.en.named, cfg.date_names.inv_local_named},				-- named dates
		}

	local function is_xlateable (month)											-- local function to get local date name that replaces existing English-language date name
		for _, date_names_t in ipairs (sources_t) do							-- for each sequence table in date_names_t
			if date_names_t[1][month] then										-- if date name is English month (long or short), quarter, season or named and
				if date_names_t[2][date_names_t[1][month]] then					-- if there is a matching local date name
					return date_names_t[2][date_names_t[1][month]];				-- return the local date name
				end
			end
		end
	end

	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val.val) then											-- if the parameter has a value
			date = param_val.val;
			for month in mw.ustring.gmatch (date, '[%a ]+') do					-- iterate through all date names in the date (single date or date range)
				month = mw.text.trim (month);									-- this because quarterly dates contain whitespace
				xlate = is_xlateable (month);									-- get translate &lt;month&gt;; returns translation or nil
				
				if xlate then		
					date = mw.ustring.gsub (date, month, xlate);				-- replace the English with the translation
					date_parameters_list[param_name].val = date;				-- save the translated date
					modified = true;
				end
			end

			if xlt_dig then														-- shall we also translate digits?
				date = date:gsub ('%d', cfg.date_names.xlate_digits);			-- translate digits from Western to 'local digits'
				date_parameters_list[param_name].val = date;					-- save the translated date
				modified = true;
			end
		end
	end
	
	return modified;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	add_prop_cat = utilities_page_ptr.add_prop_cat ;							-- import functions from selected Module:Citation/CS1/Utilities module
	is_set = utilities_page_ptr.is_set;
	in_array = utilities_page_ptr.in_array;
	set_message = utilities_page_ptr.set_message;
	substitute = utilities_page_ptr.substitute;
	wrap_style = utilities_page_ptr.wrap_style;

	cfg = cfg_table_ptr;														-- import tables from selected Module:Citation/CS1/Configuration
end


--[[--------------------------&lt; A R C H I V E _ D A T E _ C H E C K &gt;------------------------------------------

Compare value in |archive-date= with the timestamp in Wayback machine urls.  Emits an error message with suggested
date from the |archive-url= timestamp in an appropriate format when the value in |archive-date= does not match
the timestamp.

this function never called when any date in a cs1|2 template has errors

error message suggests new |archive-date= value in an appropriate format specified by &lt;df&gt;.  &lt;df&gt; is either 
|df= or cfg.global_df in that order.  If &lt;df&gt; is nil, suggested date has format from |archive-date=.  There is
a caveat: when |df=dmy or |df=mdy, the reformatter leaves |access-date= and |archive-date= formats as they are.
The error message suggested date is passed to the formatter as YYYY-MM-DD so when |df=dmy or |df=mdy, the format
is not changed.

]]

local function archive_date_check (archive_date, archive_url_timestamp, df)
	local archive_date_format = 'dmy-y';										-- holds the date format of date in |archive-date; default to ymd; 'dmy' used here to spoof reformat_dates() 
	
	for _, v_t in ipairs ({{'dMy', 'dmy-all'}, {'Mdy', 'mdy-all'}}) do			-- is |archive-date= format dmy or mdy?
		if archive_date:match (patterns[v_t[1]][1]) then						-- does the pattern match?
			archive_date_format = cfg.keywords_xlate[v_t[2]];					-- get appropriate |df= supported keyword from the i18n translator table
			break;
		end
	end
	
	local dates_t = {};
	dates_t['archive-date'] = {val=archive_date, name=''};						-- setup to call reformat_dates(); never called when errors so &lt;name&gt; unset as not needed
	reformat_dates (dates_t, 'dmy-y');											-- reformat |archive-date= to ymd; 'dmy' used here to spoof reformat_dates()
	local archive_url_date = archive_url_timestamp:gsub ('(%d%d%d%d)(%d%d)(%d%d)%d*', '%1-%2-%3');	-- make ymd format date from timestamp

	if dates_t['archive-date'].val == archive_url_date then						-- are the two dates the same
		return;																	-- yes, done
	else
		dates_t['archive-date'] = {val=archive_url_date, name=''};				-- setup to call reformat_dates() with the timestamp date
		reformat_dates (dates_t, df or archive_date_format);					-- reformat timestamp to format specified by &lt;df&gt; or format used in |archive-date= 
		archive_url_date = dates_t['archive-date'].val;
		set_message ('err_archive_date_url_ts_mismatch', archive_url_date);		-- emit an error message
	end
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {																		-- return exported functions
	archive_date_check = archive_date_check,
	date_hyphen_to_dash = date_hyphen_to_dash,
	date_name_xlate = date_name_xlate,
	dates = dates,
	reformat_dates = reformat_dates,
	set_selected_modules = set_selected_modules,
	year_date_check = year_date_check,
	}</text>
      <sha1>i9qkckq6672i7afj9xiqmqhw4jkymnu</sha1>
    </revision>
    <revision>
      <id>4859</id>
      <parentid>4858</parentid>
      <timestamp>2024-03-31T15:52:31Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>julian date fix;</comment>
      <origin>4859</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="66654" sha1="eihdxoivcfreufjkz8m1w9dwcssilup" xml:space="preserve">--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local add_prop_cat, is_set, in_array, set_message, substitute, wrap_style;		-- imported functions from selected Module:Citation/CS1/Utilities
local cfg;																		-- table of tables imported from selected Module:Citation/CS1/Configuration


--[[--------------------------&lt; F I L E - S C O P E   D E C L A R A T I O N S &gt;--------------------------------

File-scope variables are declared here

]]

local lang_object = mw.getContentLanguage();									-- used by is_valid_accessdate(), is_valid_year(), date_name_xlate(); TODO: move to ~/Configuration?
local year_limit;																-- used by is_valid_year()


--[=[-------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |access-date= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-English date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate().  To get around that
call this function with YYYY-MM-DD format dates.

]=]

local function is_valid_accessdate (accessdate)
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold Unix time stamps representing the dates

	good1, access_ts = pcall (lang_object.formatDate, lang_object, 'U', accessdate );			-- convert accessdate value to Unix timestamp 
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which which tonumber() may not understand
		access_ts = tonumber (access_ts) or lang_object:parseFormattedNumber (access_ts);		-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to Unix time stamp
	end

	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end


--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct.
If not a valid month, returns 0

]]

local function get_month_number (month)
	return cfg.date_names['local'].long[month] or cfg.date_names['local'].short[month] or	-- look for local names first
			cfg.date_names['en'].long[month] or	cfg.date_names['en'].short[month] or		-- failing that, look for English names
			0;																				-- not a recognized month name
end


--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 21 for Spring, etc.  Capitalization and spelling
must be correct. If not a valid season, returns 0.
	21-24 = Spring, Summer, Autumn, Winter, independent of “Hemisphere”

returns 0 when &lt;param&gt; is not |date=

Season numbering is defined by Extended Date/Time Format (EDTF) specification (https://www.loc.gov/standards/datetime/)
which became part of ISO 8601 in 2019.  See '§Sub-year groupings'.  The standard defines various divisions using
numbers 21-41.  cs1|2 only supports generic seasons.  EDTF does support the distinction between north and south
hemisphere seasons but cs1|2 has no way to make that distinction.

These additional divisions not currently supported:
	25-28 = Spring - Northern Hemisphere, Summer- Northern Hemisphere, Autumn - Northern Hemisphere, Winter - Northern Hemisphere
	29-32 = Spring – Southern Hemisphere, Summer– Southern Hemisphere, Autumn – Southern Hemisphere, Winter - Southern Hemisphere
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)

]]

local function get_season_number (season, param)
	if 'date' ~= param then
		return 0;																-- season dates only supported by |date=
	end
	return cfg.date_names['local'].season[season] or							-- look for local names first
			cfg.date_names['en'].season[season] or								-- failing that, look for English names
			0;																	-- not a recognized season name
end


--[[--------------------------&lt; G E T _ Q U A R T E R _ N U M B E R &gt;------------------------------------------

returns a number according to the sequence of quarters in a year: 33 for first quarter, etc.  Capitalization and spelling
must be correct. If not a valid quarter, returns 0.
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)

returns 0 when &lt;param&gt; is not |date=

Quarter numbering is defined by Extended Date/Time Format (EDTF) specification (https://www.loc.gov/standards/datetime/)
which became part of ISO 8601 in 2019.  See '§Sub-year groupings'.  The standard defines various divisions using
numbers 21-41.  cs1|2 only supports generic seasons and quarters.

These additional divisions not currently supported:
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)

]]

local function get_quarter_number (quarter, param)
	if 'date' ~= param then
		return 0;																-- quarter dates only supported by |date=
	end
	quarter = mw.ustring.gsub (quarter, ' +', ' ');								-- special case replace multiple space chars with a single space char
	return cfg.date_names['local'].quarter[quarter] or							-- look for local names first
			cfg.date_names['en'].quarter[quarter] or							-- failing that, look for English names
			0;																	-- not a recognized quarter name
end


--[[--------------------------&lt; G E T _ P R O P E R _ N A M E _ N U M B E R &gt;----------------------------------

returns a non-zero number if date contains a recognized proper-name.  Capitalization and spelling must be correct.

returns 0 when &lt;param&gt; is not |date=

]]

local function get_proper_name_number (name, param)
	if 'date' ~= param then
		return 0;																-- proper-name dates only supported by |date=
	end
	return cfg.date_names['local'].named[name] or								-- look for local names dates first
			cfg.date_names['en'].named[name] or									-- failing that, look for English names
			0;																	-- not a recognized named date
end


--[[--------------------------&lt; G E T _ E L E M E N T _ N U M B E R &lt;------------------------------------------

returns true if month or season or quarter or proper name is valid (properly spelled, capitalized, abbreviated)

]]

local function get_element_number (element, param)
	local num;
	
	local funcs = {get_month_number, get_season_number, get_quarter_number, get_proper_name_number};	-- list of functions to execute in order
	
	for _, func in ipairs (funcs) do											-- spin through the function list
		num = func (element, param);											-- call the function and get the returned number
		if 0 ~= num then														-- non-zero when valid month season quarter 
			return num;															-- return that number
		end
	end
	return nil;																	-- not valid
end


--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one
year in the future are not acceptable.

Special case for |pmc-embargo-date=: years more than two years in the future are not acceptable

]]

local function is_valid_year (year, param)
	if not is_set (year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;									-- global variable so we only have to fetch it once
	end

	year = tonumber (year) or lang_object:parseFormattedNumber (year);			-- convert to number for the comparison
	if year and (100 &gt; year) then												-- years less than 100 not supported
		return false;
	end
	
	if 'pmc-embargo-date' == param then											-- special case for |pmc-embargo-date=
		return year and (year &lt;= tonumber(os.date(&quot;%Y&quot;))+2) or false;			-- years more than two years in the future are not accepted
	end	
	return year and (year &lt;= year_limit) or false;
end


--[[--------------------------&lt; I S _ V A L I D _ D A T E &gt;----------------------------------------------------

Returns true if day is less than or equal to the number of days in month and year is no farther into the future
than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap
years before 1582 and Gregorian leap years after 1582. Where the two calendars overlap (1582 to approximately
1923) dates are assumed to be Gregorian.

]]

local function is_valid_date (year, month, day, param)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year (year, param) then										-- no farther into the future than next year except |pmc-embargo-date= no more than two years in the future
		return false;
	end
	
	month = tonumber (month);													-- required for YYYY-MM-DD dates
	
	if (2 == month) then														-- if February
		month_length = 28;														-- then 28 days unless
		if 1582 &gt; tonumber(year) then											-- Julian calendar
			if 0 == (year%4) then												-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		else																	-- Gregorian calendar
			if (0 == (year%4) and (0 ~= (year%100) or 0 == (year%400))) then	-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		end
	else
		month_length = days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
This function looks in cfg.date_names{} to see if both month names are listed in the long subtable or both are
listed in the short subtable.  When both have the same style (both are listed in the same table), returns true; false else

]]

local function is_valid_month_range_style (month1, month2)
	if (cfg.date_names.en.long[month1] and cfg.date_names.en.long[month2]) or					-- are both English names listed in the long subtable?
		(cfg.date_names.en.short[month1] and cfg.date_names.en.short[month2]) or				-- are both English names listed in the short subtable?
		(cfg.date_names['local'].long[month1] and cfg.date_names['local'].long[month2]) or		-- are both local names listed in the long subtable?
		(cfg.date_names['local'].short[month1] and cfg.date_names['local'].short[month2]) then	-- are both local names listed in the short subtable?
			return true;
	end
	return false;																-- names are mixed
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

All season ranges are accepted as valid because there are publishers out there who have published a Summer–Spring YYYY issue, hence treat as ok

]]

local function is_valid_month_season_range(range_start, range_end, param)
	local range_start_number = get_month_number (range_start);
	local range_end_number;

	if 0 == range_start_number then												-- is this a month range?
		range_start_number = get_season_number (range_start, param);			-- not a month; is it a season? get start season number
		range_end_number = get_season_number (range_end, param);				-- get end season number

		if (0 ~= range_start_number) and (0 ~= range_end_number) and (range_start_number ~= range_end_number) then
			return true;														-- any season pairing is accepted except when both are the same
		end
		return false;															-- range_start and/or range_end is not a season
	end
																				-- here when range_start is a month
	range_end_number = get_month_number (range_end);							-- get end month number
	if range_start_number &lt; range_end_number and								-- range_start is a month; does range_start precede range_end?
		is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
	end
	return false;																-- range_start month number is greater than or equal to range end number; or range end isn't a month
end


--[[--------------------------&lt; M A K E _ C O I N S _ D A T E &gt;------------------------------------------------

This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1.  The function is called only for |date= parameters and only if the |date=&lt;value&gt; is 
determined to be a valid date format.  The question of what to do with invalid date formats is not answered here.

The date parts in the input table are converted to an ISO 8601 conforming date string:
	single whole dates:		yyyy-mm-dd
	month and year dates:	yyyy-mm
	year dates:				yyyy
	ranges:					yyyy-mm-dd/yyyy-mm-dd
							yyyy-mm/yyyy-mm
							yyyy/yyyy

Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.

The input table has:
	year, year2 – always present; if before 1582, ignore months and days if present
	month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 99 Christmas
	day, day2 –  0 if not provided, 1-31 for days
	
the output table receives:
	rftdate:	an ISO 8601 formatted date
	rftchron:	a free-form version of the date, usually without year which is in rftdate (season ranges and proper-name dates)
	rftssn:		one of four season keywords: winter, spring, summer, fall (lowercase)
	rftquarter:	one of four values: 1, 2, 3, 4

]]

local function make_COinS_date (input, tCOinS_date)
	local date;																	-- one date or first date in a range
	local date2 = '';															-- end of range date
	input.year = tonumber (input.year) or lang_object:parseFormattedNumber (input.year);	-- language-aware tonumber()
	input.year2 = tonumber (input.year2) or lang_object:parseFormattedNumber (input.year2);	-- COinS dates are pseudo-ISO 8601 so convert to Arabic numerals

	if ((1582 == input.year) and (10 &gt; tonumber(input.month))) or (1582 &gt; input.year) then	-- if a Julian calendar date
		tCOinS_date.rftdate = tostring (input.year);							-- &amp;rft.date gets year only
		return;																	-- done
	end
																				-- here for all forms of Gregorian dates
	if 20 &lt; tonumber (input.month) then											-- if season, quarter, or proper-name date
		date = input.year;														-- &amp;rft.date gets year only
		if 0 ~= input.year2 and input.year ~= input.year2 then					-- if a range, only the second year portion when not the same as range start year
			date = string.format ('%.4d/%.4d', input.year, input.year2)			-- assemble the date range
		end

		local season = {[24] = 'winter', [21] = 'spring', [22] = 'summer', [23] = 'fall', [33] = '1', [34] = '2', [35] = '3', [36] = '4', [98] = 'Easter', [99] = 'Christmas'};	-- seasons lowercase, no autumn; proper-names use title case
		if 0 == input.month2 then												-- single season, quarter, or proper-name date
			if 40 &lt; tonumber(input.month) then
				tCOinS_date.rftchron = season[input.month];						-- proper-name date; used in journal metadata only
			elseif 30 &lt; tonumber(input.month) then
				tCOinS_date.rftquarter = season[input.month];					-- quarter date; used in journal metadata only
			else
				tCOinS_date.rftssn = season[input.month];						-- season date; used in journal metadata only
			end
		else																	-- season ranges are lumped into &amp;rft.chron; &amp;rft.ssn and &amp;rft.quarter are left blank
			if input.year ~= input.year2 then									-- season year – season year range or season year–year
				if 0 ~= input.month2 then
					tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);	-- used in journal metadata only
				end
			else																-- season–season year range
				tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2];	-- season–season year range; used in journal metadata only
			end
		end

		tCOinS_date.rftdate = tostring (date);
		return;																	-- done
	end
																				-- here for gregorian calendar dates
	if 0 ~= input.day then
		date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day));	-- whole date
	elseif 0 ~= input.month then
		date = string.format ('%s-%.2d', input.year, tonumber(input.month));	-- year and month
	else
		date = string.format ('%s', input.year);								-- just year
	end

	if 0 ~= input.year2 then
		if 0 ~= input.day2 then
			date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2));		-- whole date
		elseif 0 ~= input.month2 then
			date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2));	-- year and month
		else
			date2 = string.format ('/%s', input.year2);							-- just year
		end
	end
	
	tCOinS_date.rftdate = date .. date2;										-- date2 has the '/' separator
	return;
end


--[[--------------------------&lt; P A T T E R N S &gt;--------------------------------------------------------------

this is the list of patterns for date formats that this module recognizes.  Approximately the first half of these
patterns represent formats that might be reformatted into another format.  Those that might be reformatted have
'indicator' letters that identify the content of the matching capture: 'd' (day), 'm' (month), 'a' (anchor year),
'y' (year); second day, month, year have a '2' suffix.

These patterns are used for both date validation and for reformatting.  This table should not be moved to ~/Configuration
because changes to this table require changes to check_date() and to reformatter() and reformat_date()

]]

local patterns = {
	 																			-- year-initial numerical year-month-day
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'},					
																				-- month-initial: month day, year
	['Mdy'] = {'^(%D-) +([1-9]%d?), +((%d%d%d%d?)%a?)$', 'm', 'd', 'a', 'y'},
																				-- month-initial day range: month day–day, year; days are separated by endash
	['Md-dy'] = {'^(%D-) +([1-9]%d?)[%-–]([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'd2', 'a', 'y'},
																				-- day-initial: day month year
	['dMy'] = {'^([1-9]%d?) +(%D-) +((%d%d%d%d?)%a?)$', 'd', 'm', 'a', 'y'},
																				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed; not supported at en.wiki
	--	['yMd'] = {'^((%d%d%d%d?)%a?) +(%D-) +(%d%d?)$', 'a', 'y', 'm', 'd'},
																				-- day-range-initial: day–day month year; days are separated by endash
	['d-dMy'] = {'^([1-9]%d?)[%-–]([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'd2', 'm', 'a', 'y'},
																				-- day initial month-day-range: day month - day month year; uses spaced endash
	['dM-dMy'] = {'^([1-9]%d?) +(%D-) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'd2', 'm2', 'a', 'y'},
																				-- month initial month-day-range: month day – month day, year;  uses spaced endash
	['Md-Mdy'] = {'^(%D-) +([1-9]%d?) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$','m', 'd', 'm2', 'd2', 'a', 'y'},
																				-- day initial month-day-year-range: day month year - day month year; uses spaced endash
	['dMy-dMy'] = {'^([1-9]%d?) +(%D-) +(%d%d%d%d) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'y', 'd2', 'm2', 'a', 'y2'},
																				-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
	['Mdy-Mdy'] = {'^(%D-) +([1-9]%d?), +(%d%d%d%d) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'y', 'm2', 'd2', 'a', 'y2'},

																				-- these date formats cannot be converted, per se, but month name can be rendered short or long
																				-- month/season year - month/season year; separated by spaced endash
	['My-My'] = {'^(%D-) +(%d%d%d%d) +[%-–] +(%D-) +((%d%d%d%d)%a?)$', 'm', 'y', 'm2', 'a', 'y2'},
																				-- month/season range year; months separated by endash
	['M-My'] = {'^(%D-)[%-–](%D-) +((%d%d%d%d)%a?)$', 'm', 'm2', 'a', 'y'},
																				-- month/season year or proper-name year; quarter year when First Quarter YYYY etc.
	['My'] = {'^([^%d–]-) +((%d%d%d%d)%a?)$', 'm', 'a', 'y'},					-- this way because endash is a member of %D; %D- will match January–March 2019 when it shouldn't

																				-- these date formats cannot be converted
	['Sy4-y2'] = {'^(%D-) +((%d%d)%d%d)[%-–]((%d%d)%a?)$'},						-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
	['Sy-y'] = {'^(%D-) +(%d%d%d%d)[%-–]((%d%d%d%d)%a?)$'},						-- special case Winter/Summer year-year; year separated with unspaced endash
	['y-y'] = {'^(%d%d%d%d?)[%-–]((%d%d%d%d?)%a?)$'},							-- year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
	['y4-y2'] = {'^((%d%d)%d%d)[%-–]((%d%d)%a?)$'},								-- year range: YYYY–YY; separated by unspaced endash
	['y'] = {'^((%d%d%d%d?)%a?)$'},												-- year; here accept either YYY or YYYY
	}


--[[--------------------------&lt; I S _ V A L I D _ E M B A R G O _ D A T E &gt;------------------------------------

returns true and date value if that value has proper dmy, mdy, ymd format.

returns false and 9999 (embargoed forever) when date value is not proper format; assumes that when |pmc-embargo-date= is
set, the editor intended to embargo a PMC but |pmc-embargo-date= does not hold a single date.

]]

local function is_valid_embargo_date (v)
	if v:match (patterns['ymd'][1]) or											-- ymd
		v:match (patterns['Mdy'][1]) or											-- dmy
		v:match (patterns['dMy'][1]) then										-- mdy
			return true, v;
	end
	return false, '9999';														-- if here not good date so return false and set embargo date to long time in future
end


--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only
allowed range separator is endash.  Additionally, check the date to see that it is a real date: no 31 in 30-day
months; no 29 February when not a leap year.  Months, both long-form and three character abbreviations, and seasons
must be spelled correctly.  Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and
COinS_date.  When this happens, the date parameter is (DEBUG: not?) used in the COinS metadata and the CITEREF identifier gets
its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, publication-date, access-date, pmc-embargo-date, archive-date, lay-date)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is ISO 8601 format date; see make_COInS_date()

]]

local function check_date (date_string, param, tCOinS_date)
	local year;																	-- assume that year2, months, and days are not used;
	local year2 = 0;															-- second year in a year range
	local month = 0;
	local month2 = 0;															-- second month in a month range
	local day = 0;
	local day2 = 0;																-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match (patterns['ymd'][1]) then								-- year-initial numerical year month day format
		year, month, day = date_string:match (patterns['ymd'][1]);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or 0 == tonumber(day) then return false; end	-- month or day number not valid or not Gregorian calendar
		anchor_year = year;
	
	elseif mw.ustring.match(date_string, patterns['Mdy'][1]) then				-- month-initial: month day, year
		month, day, anchor_year, year = mw.ustring.match(date_string, patterns['Mdy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
				
	elseif mw.ustring.match(date_string, patterns['Md-dy'][1]) then				-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year = mw.ustring.match(date_string, patterns['Md-dy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2=month;															-- for metadata
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['dMy'][1]) then				-- day-initial: day month year
		day, month, anchor_year, year = mw.ustring.match(date_string, patterns['dMy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months

--[[ NOT supported at en.wiki
	elseif mw.ustring.match(date_string, patterns['yMd'][1]) then				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed
		anchor_year, year, month, day = mw.ustring.match(date_string, patterns['yMd'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
-- end NOT supported at en.wiki ]]

	elseif mw.ustring.match(date_string, patterns['d-dMy'][1]) then				-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year = mw.ustring.match(date_string, patterns['d-dMy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2 = month;															-- for metadata
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['dM-dMy'][1]) then			-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year = mw.ustring.match(date_string, patterns['dM-dMy'][1]);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['Md-Mdy'][1]) then			-- month initial month-day-range: month day – month day, year; uses spaced endash
		month, day, month2, day2, anchor_year, year = mw.ustring.match(date_string, patterns['Md-Mdy'][1]);
		if (not is_valid_month_season_range(month, month2, param)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2 = year;

	elseif mw.ustring.match(date_string, patterns['dMy-dMy'][1]) then			-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2 = mw.ustring.match(date_string, patterns['dMy-dMy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		if 0 == month or 0 == month2 then return false; end						-- both must be valid

	elseif mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]) then			-- month initial month-day-year-range: month day, year – month day, year; uses spaced endash
		month, day, year, month2, day2, anchor_year, year2 = mw.ustring.match(date_string, patterns['Mdy-Mdy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number(month2);
		if 0 == month or 0 == month2 then return false; end						-- both must be valid

	elseif mw.ustring.match(date_string, patterns['Sy4-y2'][1]) then			-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		local century;
		month, year, century, anchor_year, year2 = mw.ustring.match(date_string, patterns['Sy4-y2'][1]);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;		-- 'month' can only be Winter or Summer
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor_year from both years
		year2 = century..year2;													-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		month = get_season_number(month, param);

	elseif mw.ustring.match(date_string, patterns['Sy-y'][1]) then				-- special case Winter/Summer year-year; year separated with unspaced endash
		month, year, anchor_year, year2 = mw.ustring.match(date_string, patterns['Sy-y'][1]);
		month = get_season_number (month, param);								-- &lt;month&gt; can only be winter or summer; also for metadata
		if (month ~= cfg.date_names['en'].season['Winter']) and (month ~= cfg.date_names['en'].season['Summer']) then
			return false;														-- not Summer or Winter; abandon
		end
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, patterns['My-My'][1]) then				-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2 = mw.ustring.match(date_string, patterns['My-My'][1]);
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then 	-- both must be month year, same month style
			month = get_month_number(month);
			month2 = get_month_number(month2);
		elseif 0 ~= get_season_number(month, param) and 0 ~= get_season_number(month2, param) then	-- both must be season year, not mixed
			month = get_season_number(month, param);
			month2 = get_season_number(month2, param);
		else
			 return false;
		end

	elseif mw.ustring.match(date_string, patterns['M-My'][1]) then				-- month/season range year; months separated by endash 
		month, month2, anchor_year, year = mw.ustring.match(date_string, patterns['M-My'][1]);
		if (not is_valid_month_season_range(month, month2, param)) or (not is_valid_year(year)) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
			month2 = get_month_number(month2);
			if 0 == month or 0 == month2 then return false; end
		else
			month = get_season_number(month, param);
			month2 = get_season_number(month2, param);
		end
		year2 = year;
		
	elseif mw.ustring.match(date_string, patterns['My'][1]) then				-- month/season/quarter/proper-name year
		month, anchor_year, year = mw.ustring.match(date_string, patterns['My'][1]);
		if not is_valid_year(year) then return false; end
		month = get_element_number(month, param);								-- get month season quarter proper-name number or nil
		if not month then return false; end										-- not valid whatever it is

	elseif mw.ustring.match(date_string, patterns['y-y'][1]) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2 = mw.ustring.match(date_string, patterns['y-y'][1]);
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, patterns['y4-y2'][1]) then				-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2 = mw.ustring.match(date_string, patterns['y4-y2'][1]);
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor year from both years

		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century .. year2;												-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

		if in_array (param, {'date', 'publication-date', 'year'}) then			-- here when 'valid' abbreviated year range; if one of these parameters
			add_prop_cat ('year-range-abbreviated');							-- add properties cat
		end

	elseif mw.ustring.match(date_string, patterns['y'][1]) then					-- year; here accept either YYY or YYYY
		anchor_year, year = mw.ustring.match(date_string, patterns['y'][1]);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;															-- date format not one of the MOS:DATE approved formats
	end

	if param ~= 'date' then														-- CITEREF disambiguation only allowed in |date=; |year= &amp; |publication-date= promote to date
		if anchor_year:match ('%l$') then
			return false;
		end
	end

	if 'access-date' == param then												-- test access-date here because we have numerical date parts
		if 0 ~= year and 0 ~= month and 0 ~= day and 							-- all parts of a single date required
			0 == year2 and 0 == month2 and 0 == day2 then						-- none of these; access-date must not be a range
				if not is_valid_accessdate(year .. '-' .. month .. '-' .. day) then	
					return false;												-- return false when access-date out of bounds
				end
		else
			return false;														-- return false when access-date is a range of two dates
		end
	end

	if 'archive-date' == param then												-- test archive-date here because we have numerical date parts
		if not (0 ~= year and 0 ~= month and 0 ~= day and						-- all parts of a single date required
			0 == year2 and 0 == month2 and 0 == day2) then						-- none of these; archive-date must not be a range
				return false;													-- return false when archive-date is a range of two dates
		end
	end

	local result=true;															-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result = is_valid_date (year, month, day, param);						-- &lt;param&gt; for |pmc-embargo-date=

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result = is_valid_date (year, month, day);
		result = result and is_valid_date (year, month, day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result = is_valid_date (year, month, day);
		result = result and is_valid_date (year, month2, day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result = is_valid_date(year, month, day);
		result = result and is_valid_date(year2, month2, day2);
	end
	
	if false == result then return false; end

	if nil ~= tCOinS_date then													-- this table only passed into this function when testing |date= parameter values
		make_COinS_date ({year = year, month = month, day = day, year2 = year2, month2 = month2, day2 = day2}, tCOinS_date);	-- make an ISO 8601 date string for COinS
	end
	
	return true, anchor_year;													-- format is good and date string represents a real date
end	


--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
parameters with errors are added to the &lt;error_list&gt; sequence table as the dates are tested.

]]

local function dates(date_parameters_list, tCOinS_date, error_list)
	local anchor_year;															-- will return as nil if the date being tested is not |date=
	local COinS_date;															-- will return as nil if the date being tested is not |date=
	local embargo_date;															-- if embargo date is a good dmy, mdy, ymd date then holds original value else reset to 9999
	local good_date = false;

	for k, v in pairs(date_parameters_list) do									-- for each date-holding parameter in the list
		if is_set(v.val) then													-- if the parameter has a value
			v.val = mw.ustring.gsub(v.val, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9
			if v.val:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then						-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v.val:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);				-- get the year portion so it can be tested
				if 'date' == k then
					anchor_year, COinS_date = v.val:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year' == k then
					good_date = is_valid_year(year);
				end
			elseif 'date' == k then												-- if the parameter is |date=
				if v.val:match(&quot;^n%.d%.%a?$&quot;) then -- ToDo: I18N								-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((n%.d%.)%a?)&quot;); -- ToDo: I18N	-- &quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v.val:match(&quot;^nd%a?$&quot;) then -- ToDo: I18N								-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((nd)%a?)&quot;); -- ToDo: I18N	-- &quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v.val, k, tCOinS_date);	-- go test the date
				end
			elseif 'year' == k then												-- if the parameter is |year= it should hold only a year value
				if v.val:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then						-- if |year = 3 or 4 digits only with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((%d+)%a?)&quot;);
				end
			elseif 'pmc-embargo-date' == k then									-- if the parameter is |pmc-embargo-date=
				good_date = check_date (v.val, k);								-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date, embargo_date = is_valid_embargo_date (v.val);	-- is |pmc-embargo-date= date a single dmy, mdy, or ymd formatted date? yes: returns embargo date; no: returns 9999
				end
			else																-- any other date-holding parameter
				good_date = check_date (v.val, k);								-- go test the date
			end
			if false == good_date then											-- assemble one error message so we don't add the tracking category multiple times
				table.insert (error_list, wrap_style ('parameter', v.name));	-- make parameter name suitable for error message list
			end
		end
	end
	return anchor_year, embargo_date;											-- and done
end


--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function sets a local numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

the numeric value in &lt;result&gt; determines the 'output' if any from this function:
	0 – adds error message to error_list sequence table
	1 – adds maint cat
	2 – does nothing

]]

local function year_date_check (year_string, year_origin, date_string, date_origin, error_list)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes

	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where both date and year are required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard range formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif mw.ustring.match(date_string, &quot;%d%d%d%d[%-–]%d%d&quot;) then				-- YYYY-YY date ranges
		local century;
		date1, century, date2 = mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	else																		-- should never get here; this function called only when no other date errors
		result = 0;																-- no recognizable year in date
	end

	if 0 == result then															-- year / date mismatch
		table.insert (error_list, substitute (cfg.messages['mismatch'], {year_origin, date_origin}));	-- add error message to error_list sequence table
	elseif 1 == result then														-- redundant year / date
		set_message ('maint_date_year');										-- add a maint cat
	end
end


--[[--------------------------&lt; R E F O R M A T T E R &gt;--------------------------------------------------------

reformat 'date' into new format specified by format_param if pattern_idx (the current format of 'date') can be
reformatted.  Does the grunt work for reformat_dates().

The table re_formats maps pattern_idx (current format) and format_param (desired format) to a table that holds:
	format string used by string.format()
	identifier letters ('d', 'm', 'y', 'd2', 'm2', 'y2') that serve as indexes into a table t{} that holds captures
		from mw.ustring.match() for the various date parts specified by  patterns[pattern_idx][1]

Items in patterns{} have the general form:
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'}, where:
		['ymd'] is pattern_idx
		patterns['ymd'][1] is the match pattern with captures for mw.ustring.match()
		patterns['ymd'][2] is an indicator letter identifying the content of the first capture
		patterns['ymd'][3] ... the second capture etc.

when a pattern matches a date, the captures are loaded into table t{} in capture order using the idemtifier
characters as indexes into t{}  For the above, a ymd date is in t{} as:
	t.y = first capture (year), t.m = second capture (month), t.d = third capture (day)

To reformat, this function is called with the pattern_idx that matches the current format of the date and with
format_param set to the desired format.  This function loads table t{} as described and then calls string.format()
with the format string specified by re_format[pattern_idx][format_param][1] using values taken from t{} according
to the capture identifier letters specified by patterns[pattern_idx][format_param][n] where n is 2..

]]

local re_formats = {
	['ymd'] = {																	-- date format is ymd; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
	--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},								-- |df=yMd; not supported at en.wiki
		},
	['Mdy'] = {																	-- date format is Mdy; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- for long/short reformatting
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
	--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},								-- |df=yMd; not supported at en.wiki
		},
	['dMy'] = {																	-- date format is dMy; reformat to:
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- for long/short reformatting
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
	--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},								-- |df=yMd; not supported at en.wiki
		},
	['Md-dy'] = {																-- date format is Md-dy; reformat to:
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- for long/short reformatting
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- |df=dmy -&gt; d-dMy 
		},
	['d-dMy'] = {																-- date format is d-d&gt;y; reformat to:
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- for long/short reformatting
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- |df=mdy -&gt; Md-dy 
		},
	['dM-dMy'] = {																-- date format is dM-dMy; reformat to:
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- for long/short reformatting
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd', 'm2', 'd2', 'y'},				-- |df=mdy -&gt; Md-Mdy 
		},
	['Md-Mdy'] = {																-- date format is Md-Mdy; reformat to:
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd',  'm2', 'd2', 'y'},			-- for long/short reformatting
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- |df=dmy -&gt; dM-dMy 
		},
	['dMy-dMy'] = {																-- date format is dMy-dMy; reformat to:
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- for long/short reformatting
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- |df=mdy -&gt; Mdy-Mdy 
		},
	['Mdy-Mdy'] = {																-- date format is Mdy-Mdy; reformat to:
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- for long/short reformatting
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- |df=dmy -&gt; dMy-dMy 
		},
	['My-My'] = {																-- these for long/short reformatting
		['any'] = {'%s %s – %s %s', 'm', 'y', 'm2', 'y2'},						-- dmy/mdy agnostic
		},
	['M-My'] = {																-- these for long/short reformatting
		['any'] = {'%s–%s %s', 'm', 'm2', 'y'},									-- dmy/mdy agnostic
		},
	['My'] = {																	-- these for long/short reformatting
		['any'] = {'%s %s', 'm', 'y'},											-- dmy/mdy agnostic
		},
	--	['yMd'] = {																-- not supported at en.wiki
	--		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},								-- |df=mdy
	--		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},								-- |df=dmy
	--		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},								-- |df=ymd
	--		},
	}


local function reformatter (date, pattern_idx, format_param, mon_len)
	if not in_array (pattern_idx, {'ymd', 'Mdy', 'Md-dy', 'dMy', 'yMd', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- not in this set of date format patterns then not a reformattable date
	end
	
	if 'ymd' == format_param and in_array (pattern_idx, {'ymd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- ymd date ranges not supported at en.wiki; no point in reformatting ymd to ymd
	end

	if in_array (pattern_idx, {'My', 'M-My', 'My-My'}) then						-- these are not dmy/mdy so can't be 'reformatted' into either
		format_param = 'any';													-- so format-agnostic 
	end

																				-- yMd is not supported at en.wiki; when yMd is supported at your wiki, uncomment the next line
	--	if 'yMd' == format_param and in_array (pattern_idx, {'yMd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy'}) then	-- these formats not convertable; yMd not supported at en.wiki
	if 'yMd' == format_param then												-- yMd not supported at en.wiki; when yMd is supported at your wiki, remove or comment-out this line
		return;																	-- not a reformattable date
	end
	
	local c1, c2, c3, c4, c5, c6, c7;											-- these hold the captures specified in patterns[pattern_idx][1]
	c1, c2, c3, c4, c5, c6, c7 = mw.ustring.match (date, patterns[pattern_idx][1]);	-- get the captures

	local t = {																	-- table that holds k/v pairs of date parts from the captures and patterns[pattern_idx][2..]
		[patterns[pattern_idx][2]] = c1;										-- at minimum there is always one capture with a matching indicator letter
		[patterns[pattern_idx][3] or 'x'] = c2;									-- patterns can have a variable number of captures; each capture requires an indicator letter;
		[patterns[pattern_idx][4] or 'x'] = c3;									-- where there is no capture, there is no indicator letter so n in patterns[pattern_idx][n] will be nil;
		[patterns[pattern_idx][5] or 'x'] = c4;									-- the 'x' here spoofs an indicator letter to prevent 'table index is nil' error
		[patterns[pattern_idx][6] or 'x'] = c5;
		[patterns[pattern_idx][7] or 'x'] = c6;
		[patterns[pattern_idx][8] or 'x'] = c7;
		};

	if t.a then																	-- if this date has an anchor year capture (all convertable date formats except ymd)
		if t.y2 then															-- for year range date formats														
			t.y2 = t.a;															-- use the anchor year capture when reassembling the date
		else																	-- here for single date formats (except ymd)
			t.y = t.a;															-- use the anchor year capture when reassembling the date
		end
	end

	if tonumber(t.m) then														-- if raw month is a number (converting from ymd)
		if 's' == mon_len then													-- if we are to use abbreviated month names
			t.m = cfg.date_names['inv_local_short'][tonumber(t.m)];					-- convert it to a month name
		else
			t.m = cfg.date_names['inv_local_long'][tonumber(t.m)];					-- convert it to a month name
		end
		t.d = t.d:gsub ('0(%d)', '%1');											-- strip leading '0' from day if present
	elseif 'ymd' == format_param then											-- when converting to ymd
		t.y = t.y:gsub ('%a', '');												-- strip CITREF disambiguator if present; anchor year already known so process can proceed; TODO: maint message?
		if 1582 &gt; tonumber (t.y) then											-- ymd format dates not allowed before 1582
			return;
		end
		t.m = string.format ('%02d', get_month_number (t.m));					-- make sure that month and day are two digits
		t.d = string.format ('%02d', t.d);
	elseif mon_len then															-- if mon_len is set to either 'short' or 'long'
		for _, mon in ipairs ({'m', 'm2'}) do									-- because there can be two month names, check both 
			if t[mon] then
				t[mon] = get_month_number (t[mon]);								-- get the month number for this month (is length agnostic)
				if 0 == t[mon] then return; end									-- seasons and named dates can't be converted
				t[mon] = (('s' == mon_len) and cfg.date_names['inv_local_short'][t[mon]]) or cfg.date_names['inv_local_long'][t[mon]];	-- fetch month name according to length
			end
		end
	end

	local new_date = string.format (re_formats[pattern_idx][format_param][1],	-- format string
		t[re_formats[pattern_idx][format_param][2]],							-- named captures from t{}
		t[re_formats[pattern_idx][format_param][3]],
		t[re_formats[pattern_idx][format_param][4]],
		t[re_formats[pattern_idx][format_param][5]],
		t[re_formats[pattern_idx][format_param][6]],
		t[re_formats[pattern_idx][format_param][7]],
		t[re_formats[pattern_idx][format_param][8]]
		);

	return new_date;
end


--[[-------------------------&lt; R E F O R M A T _ D A T E S &gt;--------------------------------------------------

Reformats existing dates into the format specified by format.

format is one of several manual keywords: dmy, dmy-all, mdy, mdy-all, ymd, ymd-all.  The -all version includes
access- and archive-dates; otherwise these dates are not reformatted.

This function allows automatic date formatting.  In ~/Configuration, the article source is searched for one of
the {{use xxx dates}} templates.  If found, xxx becomes the global date format as xxx-all.  If |cs1-dates= in
{{use xxx dates}} has legitimate value then that value determines how cs1|2 dates will be rendered.  Legitimate
values for |cs1-dates= are:
	l - all dates are rendered with long month names
	ls - publication dates use long month names; access-/archive-dates use abbreviated month names
	ly - publication dates use long month names; access-/archive-dates rendered in ymd format
	s - all dates are rendered with abbreviated (short) month names
	sy - publication dates use abbreviated month names; access-/archive-dates rendered in ymd format
	y - all dates are rendered in ymd format

the format argument for automatic date formatting will be the format specified by {{use xxx dates}} with the
value supplied by |cs1-dates so one of: xxx-l, xxx-ls, xxx-ly, xxx-s, xxx-sy, xxx-y, or simply xxx (|cs1-dates=
empty, omitted, or invalid) where xxx shall be either of dmy or mdy.

dates are extracted from date_parameters_list, reformatted (if appropriate), and then written back into the
list in the new format.  Dates in date_parameters_list are presumed here to be valid (no errors).  This function
returns true when a date has been reformatted, false else.  Actual reformatting is done by reformatter().

]]

local function reformat_dates (date_parameters_list, format)
	local all = false;															-- set to false to skip access- and archive-dates
	local len_p = 'l';															-- default publication date length shall be long
	local len_a = 'l';															-- default access-/archive-date length shall be long
	local result = false;
	local new_date;																
	
	if format:match('%a+%-all') then											-- manual df keyword; auto df keyword when length not specified in {{use xxx dates}}; 
		format = format:match('(%a+)%-all');									-- extract the format
		all = true;																-- all dates are long format dates because this keyword doesn't specify length
	elseif format:match('%a+%-[lsy][sy]?') then									-- auto df keywords; internal only
		all = true;																-- auto df applies to all dates; use length specified by capture len_p for all dates
		format, len_p, len_a = format:match('(%a+)%-([lsy])([sy]?)');			-- extract the format and length keywords
		if 'y' == len_p then													-- because allowed by MOS:DATEUNIFY (sort of) range dates and My dates not reformatted
			format = 'ymd';														-- override {{use xxx dates}}
		elseif (not is_set(len_a)) or (len_p == len_a) then						-- no access-/archive-date length specified or same length as publication dates then
			len_a = len_p;														-- in case len_a not set
		end
	end																			-- else only publication dates and they are long

	for param_name, param_val in pairs (date_parameters_list) do				-- for each date-holding parameter in the list
		if is_set (param_val.val) then											-- if the parameter has a value
			if not (not all and in_array (param_name, {'access-date', 'archive-date'})) then	-- skip access- or archive-date unless format is xxx-all; yeah, ugly; TODO: find a better way
				for pattern_idx, pattern in pairs (patterns) do
					if mw.ustring.match (param_val.val, pattern[1]) then
						if all and in_array (param_name, {'access-date', 'archive-date'}) then	-- if this date is an access- or archive-date
							new_date = reformatter (param_val.val, pattern_idx, (('y' == len_a) and 'ymd') or format, len_a);	-- choose ymd or dmy/mdy according to len_a setting
						else													-- all other dates
							new_date = reformatter (param_val.val, pattern_idx, format, len_p);
						end
						
						if new_date then										-- set when date was reformatted
							date_parameters_list[param_name].val = new_date;	-- update date in date list
							result = true;										-- and announce that changes have been made
							break;
						end
					end	-- if
				end		-- for
			end			-- if
		end				-- if
	end					-- for
	return result;																-- declare boolean result and done
end


--[[--------------------------&lt; D A T E _ H Y P H E N _ T O _ D A S H &gt;----------------------------------------

Loops through the list of date-holding parameters and converts any hyphen to an ndash.  Not called if the cs1|2
template has any date errors.

Modifies the date_parameters_list and returns true if hyphens are replaced, else returns false.

]]

local function date_hyphen_to_dash (date_parameters_list)
	local result = false;
	local n;
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set (param_val.val) and
			not mw.ustring.match (param_val.val, patterns.ymd[1]) then			-- for those that are not ymd dates (ustring because here digits may not be Western)
				param_val.val, n = param_val.val:gsub ('%-', '–');				-- replace any hyphen with ndash
				if 0 ~= n then
					date_parameters_list[param_name].val = param_val.val;		-- update the list
					result = true;
				end
		end
	end
	return result;																-- so we know if any hyphens were replaced
end


--[[-------------------------&lt; D A T E _ N A M E _ X L A T E &gt;------------------------------------------------

Attempts to translate English date names to local-language date names using names supplied by MediaWiki's
date parser function.  This is simple name-for-name replacement and may not work for all languages.

if xlat_dig is true, this function will also translate Western (English) digits to the local language's digits.
This will also translate ymd dates.

]]

local function date_name_xlate (date_parameters_list, xlt_dig)
	local xlate;
	local mode;																	-- long or short month names
	local modified = false;
	local date;
	
	local sources_t = {
		{cfg.date_names.en.long, cfg.date_names.inv_local_long},				-- for translating long English month names to long local month names
		{cfg.date_names.en.short, cfg.date_names.inv_local_short},				-- short month names
		{cfg.date_names.en.quarter, cfg.date_names.inv_local_quarter},			-- quarter date names
		{cfg.date_names.en.season, cfg.date_names.inv_local_season},			-- season date nam
		{cfg.date_names.en.named, cfg.date_names.inv_local_named},				-- named dates
		}

	local function is_xlateable (month)											-- local function to get local date name that replaces existing English-language date name
		for _, date_names_t in ipairs (sources_t) do							-- for each sequence table in date_names_t
			if date_names_t[1][month] then										-- if date name is English month (long or short), quarter, season or named and
				if date_names_t[2][date_names_t[1][month]] then					-- if there is a matching local date name
					return date_names_t[2][date_names_t[1][month]];				-- return the local date name
				end
			end
		end
	end

	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val.val) then											-- if the parameter has a value
			date = param_val.val;
			for month in mw.ustring.gmatch (date, '[%a ]+') do					-- iterate through all date names in the date (single date or date range)
				month = mw.text.trim (month);									-- this because quarterly dates contain whitespace
				xlate = is_xlateable (month);									-- get translate &lt;month&gt;; returns translation or nil
				
				if xlate then		
					date = mw.ustring.gsub (date, month, xlate);				-- replace the English with the translation
					date_parameters_list[param_name].val = date;				-- save the translated date
					modified = true;
				end
			end

			if xlt_dig then														-- shall we also translate digits?
				date = date:gsub ('%d', cfg.date_names.xlate_digits);			-- translate digits from Western to 'local digits'
				date_parameters_list[param_name].val = date;					-- save the translated date
				modified = true;
			end
		end
	end
	
	return modified;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	add_prop_cat = utilities_page_ptr.add_prop_cat ;							-- import functions from selected Module:Citation/CS1/Utilities module
	is_set = utilities_page_ptr.is_set;
	in_array = utilities_page_ptr.in_array;
	set_message = utilities_page_ptr.set_message;
	substitute = utilities_page_ptr.substitute;
	wrap_style = utilities_page_ptr.wrap_style;

	cfg = cfg_table_ptr;														-- import tables from selected Module:Citation/CS1/Configuration
end


--[[--------------------------&lt; A R C H I V E _ D A T E _ C H E C K &gt;------------------------------------------

Compare value in |archive-date= with the timestamp in Wayback machine urls.  Emits an error message with suggested
date from the |archive-url= timestamp in an appropriate format when the value in |archive-date= does not match
the timestamp.

this function never called when any date in a cs1|2 template has errors

error message suggests new |archive-date= value in an appropriate format specified by &lt;df&gt;.  &lt;df&gt; is either 
|df= or cfg.global_df in that order.  If &lt;df&gt; is nil, suggested date has format from |archive-date=.  There is
a caveat: when |df=dmy or |df=mdy, the reformatter leaves |access-date= and |archive-date= formats as they are.
The error message suggested date is passed to the formatter as YYYY-MM-DD so when |df=dmy or |df=mdy, the format
is not changed.

]]

local function archive_date_check (archive_date, archive_url_timestamp, df)
	local archive_date_format = 'dmy-y';										-- holds the date format of date in |archive-date; default to ymd; 'dmy' used here to spoof reformat_dates() 
	
	for _, v_t in ipairs ({{'dMy', 'dmy-all'}, {'Mdy', 'mdy-all'}}) do			-- is |archive-date= format dmy or mdy?
		if archive_date:match (patterns[v_t[1]][1]) then						-- does the pattern match?
			archive_date_format = cfg.keywords_xlate[v_t[2]];					-- get appropriate |df= supported keyword from the i18n translator table
			break;
		end
	end
	
	local dates_t = {};
	dates_t['archive-date'] = {val=archive_date, name=''};						-- setup to call reformat_dates(); never called when errors so &lt;name&gt; unset as not needed
	reformat_dates (dates_t, 'dmy-y');											-- reformat |archive-date= to ymd; 'dmy' used here to spoof reformat_dates()
	local archive_url_date = archive_url_timestamp:gsub ('(%d%d%d%d)(%d%d)(%d%d)%d*', '%1-%2-%3');	-- make ymd format date from timestamp

	if dates_t['archive-date'].val == archive_url_date then						-- are the two dates the same
		return;																	-- yes, done
	else
		dates_t['archive-date'] = {val=archive_url_date, name=''};				-- setup to call reformat_dates() with the timestamp date
		reformat_dates (dates_t, df or archive_date_format);					-- reformat timestamp to format specified by &lt;df&gt; or format used in |archive-date= 
		archive_url_date = dates_t['archive-date'].val;
		set_message ('err_archive_date_url_ts_mismatch', archive_url_date);		-- emit an error message
	end
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {																		-- return exported functions
	archive_date_check = archive_date_check,
	date_hyphen_to_dash = date_hyphen_to_dash,
	date_name_xlate = date_name_xlate,
	dates = dates,
	reformat_dates = reformat_dates,
	set_selected_modules = set_selected_modules,
	year_date_check = year_date_check,
	}</text>
      <sha1>eihdxoivcfreufjkz8m1w9dwcssilup</sha1>
    </revision>
    <revision>
      <id>4860</id>
      <parentid>4859</parentid>
      <timestamp>2024-08-17T18:39:07Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4860</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="67787" sha1="h37xf2hxsrjgq13ms7lozl3uiigkklr" xml:space="preserve">--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local add_prop_cat, is_set, in_array, set_message, substitute, wrap_style;		-- imported functions from selected Module:Citation/CS1/Utilities
local cfg;																		-- table of tables imported from selected Module:Citation/CS1/Configuration


--[[--------------------------&lt; F I L E - S C O P E   D E C L A R A T I O N S &gt;--------------------------------

File-scope variables are declared here

]]

local lang_object = mw.getContentLanguage();									-- used by is_valid_accessdate(), is_valid_year(), date_name_xlate(); TODO: move to ~/Configuration?
local year_limit;																-- used by is_valid_year()


--[=[-------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |access-date= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-English date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate().  To get around that
call this function with YYYY-MM-DD format dates.

]=]

local function is_valid_accessdate (accessdate)
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold Unix time stamps representing the dates

	good1, access_ts = pcall (lang_object.formatDate, lang_object, 'U', accessdate );			-- convert accessdate value to Unix timestamp 
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which which tonumber() may not understand
		access_ts = tonumber (access_ts) or lang_object:parseFormattedNumber (access_ts);		-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to Unix time stamp
	end

	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end


--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct.
If not a valid month, returns 0

]]

local function get_month_number (month)
	return cfg.date_names['local'].long[month] or cfg.date_names['local'].short[month] or	-- look for local names first
			cfg.date_names['en'].long[month] or	cfg.date_names['en'].short[month] or		-- failing that, look for English names
			0;																				-- not a recognized month name
end


--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 21 for Spring, etc.  Capitalization and spelling
must be correct. If not a valid season, returns 0.
	21-24 = Spring, Summer, Autumn, Winter, independent of “Hemisphere”

returns 0 when &lt;param&gt; is not |date=

Season numbering is defined by Extended Date/Time Format (EDTF) specification (https://www.loc.gov/standards/datetime/)
which became part of ISO 8601 in 2019.  See '§Sub-year groupings'.  The standard defines various divisions using
numbers 21-41.  cs1|2 only supports generic seasons.  EDTF does support the distinction between north and south
hemisphere seasons but cs1|2 has no way to make that distinction.

These additional divisions not currently supported:
	25-28 = Spring - Northern Hemisphere, Summer- Northern Hemisphere, Autumn - Northern Hemisphere, Winter - Northern Hemisphere
	29-32 = Spring – Southern Hemisphere, Summer– Southern Hemisphere, Autumn – Southern Hemisphere, Winter - Southern Hemisphere
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)

]]

local function get_season_number (season, param)
	if 'date' ~= param then
		return 0;																-- season dates only supported by |date=
	end
	return cfg.date_names['local'].season[season] or							-- look for local names first
			cfg.date_names['en'].season[season] or								-- failing that, look for English names
			0;																	-- not a recognized season name
end


--[[--------------------------&lt; G E T _ Q U A R T E R _ N U M B E R &gt;------------------------------------------

returns a number according to the sequence of quarters in a year: 33 for first quarter, etc.  Capitalization and spelling
must be correct. If not a valid quarter, returns 0.
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)

returns 0 when &lt;param&gt; is not |date=

Quarter numbering is defined by Extended Date/Time Format (EDTF) specification (https://www.loc.gov/standards/datetime/)
which became part of ISO 8601 in 2019.  See '§Sub-year groupings'.  The standard defines various divisions using
numbers 21-41.  cs1|2 only supports generic seasons and quarters.

These additional divisions not currently supported:
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)

]]

local function get_quarter_number (quarter, param)
	if 'date' ~= param then
		return 0;																-- quarter dates only supported by |date=
	end
	quarter = mw.ustring.gsub (quarter, ' +', ' ');								-- special case replace multiple space chars with a single space char
	return cfg.date_names['local'].quarter[quarter] or							-- look for local names first
			cfg.date_names['en'].quarter[quarter] or							-- failing that, look for English names
			0;																	-- not a recognized quarter name
end


--[[--------------------------&lt; G E T _ P R O P E R _ N A M E _ N U M B E R &gt;----------------------------------

returns a non-zero number if date contains a recognized proper-name.  Capitalization and spelling must be correct.

returns 0 when &lt;param&gt; is not |date=

]]

local function get_proper_name_number (name, param)
	if 'date' ~= param then
		return 0;																-- proper-name dates only supported by |date=
	end
	return cfg.date_names['local'].named[name] or								-- look for local names dates first
			cfg.date_names['en'].named[name] or									-- failing that, look for English names
			0;																	-- not a recognized named date
end


--[[--------------------------&lt; G E T _ E L E M E N T _ N U M B E R &lt;------------------------------------------

returns true if month or season or quarter or proper name is valid (properly spelled, capitalized, abbreviated)

]]

local function get_element_number (element, param)
	local num;
	
	local funcs = {get_month_number, get_season_number, get_quarter_number, get_proper_name_number};	-- list of functions to execute in order
	
	for _, func in ipairs (funcs) do											-- spin through the function list
		num = func (element, param);											-- call the function and get the returned number
		if 0 ~= num then														-- non-zero when valid month season quarter 
			return num;															-- return that number
		end
	end
	return nil;																	-- not valid
end


--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one
year in the future are not acceptable.

Special case for |pmc-embargo-date=: years more than two years in the future are not acceptable

]]

local function is_valid_year (year, param)
	if not is_set (year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;									-- global variable so we only have to fetch it once
	end

	year = tonumber (year) or lang_object:parseFormattedNumber (year);			-- convert to number for the comparison
	if year and (100 &gt; year) then												-- years less than 100 not supported
		return false;
	end
	
	if 'pmc-embargo-date' == param then											-- special case for |pmc-embargo-date=
		return year and (year &lt;= tonumber(os.date(&quot;%Y&quot;))+2) or false;			-- years more than two years in the future are not accepted
	end	
	return year and (year &lt;= year_limit) or false;
end


--[[--------------------------&lt; I S _ V A L I D _ D A T E &gt;----------------------------------------------------

Returns true if day is less than or equal to the number of days in month and year is no farther into the future
than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap
years before 1582 and Gregorian leap years after 1582. Where the two calendars overlap (1582 to approximately
1923) dates are assumed to be Gregorian.

]]

local function is_valid_date (year, month, day, param)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year (year, param) then										-- no farther into the future than next year except |pmc-embargo-date= no more than two years in the future
		return false;
	end
	
	month = tonumber (month);													-- required for YYYY-MM-DD dates
	
	if (2 == month) then														-- if February
		month_length = 28;														-- then 28 days unless
		if 1582 &gt; tonumber(year) then											-- Julian calendar
			if 0 == (year%4) then												-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		else																	-- Gregorian calendar
			if (0 == (year%4) and (0 ~= (year%100) or 0 == (year%400))) then	-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		end
	else
		month_length = days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
This function looks in cfg.date_names{} to see if both month names are listed in the long subtable or both are
listed in the short subtable.  When both have the same style (both are listed in the same table), returns true; false else

]]

local function is_valid_month_range_style (month1, month2)
	if (cfg.date_names.en.long[month1] and cfg.date_names.en.long[month2]) or					-- are both English names listed in the long subtable?
		(cfg.date_names.en.short[month1] and cfg.date_names.en.short[month2]) or				-- are both English names listed in the short subtable?
		(cfg.date_names['local'].long[month1] and cfg.date_names['local'].long[month2]) or		-- are both local names listed in the long subtable?
		(cfg.date_names['local'].short[month1] and cfg.date_names['local'].short[month2]) then	-- are both local names listed in the short subtable?
			return true;
	end
	return false;																-- names are mixed
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

All season ranges are accepted as valid because there are publishers out there who have published a Summer–Spring YYYY issue, hence treat as ok

]]

local function is_valid_month_season_range(range_start, range_end, param)
	local range_start_number = get_month_number (range_start);
	local range_end_number;

	if 0 == range_start_number then												-- is this a month range?
		range_start_number = get_season_number (range_start, param);			-- not a month; is it a season? get start season number
		range_end_number = get_season_number (range_end, param);				-- get end season number

		if (0 ~= range_start_number) and (0 ~= range_end_number) and (range_start_number ~= range_end_number) then
			return true;														-- any season pairing is accepted except when both are the same
		end
		return false;															-- range_start and/or range_end is not a season
	end
																				-- here when range_start is a month
	range_end_number = get_month_number (range_end);							-- get end month number
	if range_start_number &lt; range_end_number and								-- range_start is a month; does range_start precede range_end?
		is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
	end
	return false;																-- range_start month number is greater than or equal to range end number; or range end isn't a month
end


--[[--------------------------&lt; M A K E _ C O I N S _ D A T E &gt;------------------------------------------------

This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1.  The function is called only for |date= parameters and only if the |date=&lt;value&gt; is 
determined to be a valid date format.  The question of what to do with invalid date formats is not answered here.

The date parts in the input table are converted to an ISO 8601 conforming date string:
	single whole dates:		yyyy-mm-dd
	month and year dates:	yyyy-mm
	year dates:				yyyy
	ranges:					yyyy-mm-dd/yyyy-mm-dd
							yyyy-mm/yyyy-mm
							yyyy/yyyy

Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.

The input table has:
	year, year2 – always present; if before 1582, ignore months and days if present
	month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 99 Christmas
	day, day2 –  0 if not provided, 1-31 for days
	
the output table receives:
	rftdate:	an ISO 8601 formatted date
	rftchron:	a free-form version of the date, usually without year which is in rftdate (season ranges and proper-name dates)
	rftssn:		one of four season keywords: winter, spring, summer, fall (lowercase)
	rftquarter:	one of four values: 1, 2, 3, 4

]]

local function make_COinS_date (input, tCOinS_date)
	local date;																	-- one date or first date in a range
	local date2 = '';															-- end of range date
	input.year = tonumber (input.year) or lang_object:parseFormattedNumber (input.year);	-- language-aware tonumber()
	input.year2 = tonumber (input.year2) or lang_object:parseFormattedNumber (input.year2);	-- COinS dates are pseudo-ISO 8601 so convert to Arabic numerals

	if ((1582 == input.year) and (10 &gt; tonumber(input.month))) or (1582 &gt; input.year) then	-- if a Julian calendar date
		tCOinS_date.rftdate = tostring (input.year);							-- &amp;rft.date gets year only
		return;																	-- done
	end
																				-- here for all forms of Gregorian dates
	if 20 &lt; tonumber (input.month) then											-- if season, quarter, or proper-name date
		date = input.year;														-- &amp;rft.date gets year only
		if 0 ~= input.year2 and input.year ~= input.year2 then					-- if a range, only the second year portion when not the same as range start year
			date = string.format ('%.4d/%.4d', input.year, input.year2)			-- assemble the date range
		end

		local season = {[24] = 'winter', [21] = 'spring', [22] = 'summer', [23] = 'fall', [33] = '1', [34] = '2', [35] = '3', [36] = '4', [98] = 'Easter', [99] = 'Christmas'};	-- seasons lowercase, no autumn; proper-names use title case
		if 0 == input.month2 then												-- single season, quarter, or proper-name date
			if 40 &lt; tonumber(input.month) then
				tCOinS_date.rftchron = season[input.month];						-- proper-name date; used in journal metadata only
			elseif 30 &lt; tonumber(input.month) then
				tCOinS_date.rftquarter = season[input.month];					-- quarter date; used in journal metadata only
			else
				tCOinS_date.rftssn = season[input.month];						-- season date; used in journal metadata only
			end
		else																	-- season ranges are lumped into &amp;rft.chron; &amp;rft.ssn and &amp;rft.quarter are left blank
			if input.year ~= input.year2 then									-- season year – season year range or season year–year
				if 0 ~= input.month2 then
					tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);	-- used in journal metadata only
				end
			else																-- season–season year range
				tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2];	-- season–season year range; used in journal metadata only
			end
		end

		tCOinS_date.rftdate = tostring (date);
		return;																	-- done
	end
																				-- here for gregorian calendar dates
	if 0 ~= input.day then
		date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day));	-- whole date
	elseif 0 ~= input.month then
		date = string.format ('%s-%.2d', input.year, tonumber(input.month));	-- year and month
	else
		date = string.format ('%s', input.year);								-- just year
	end

	if 0 ~= input.year2 then
		if 0 ~= input.day2 then
			date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2));		-- whole date
		elseif 0 ~= input.month2 then
			date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2));	-- year and month
		else
			date2 = string.format ('/%s', input.year2);							-- just year
		end
	end
	
	tCOinS_date.rftdate = date .. date2;										-- date2 has the '/' separator
	return;
end


--[[--------------------------&lt; P A T T E R N S _ T &gt;----------------------------------------------------------

this is the list of patterns for date formats that this module recognizes.  Approximately the first half of these
patterns represent formats that might be reformatted into another format.  Those that might be reformatted have
'indicator' letters that identify the content of the matching capture: 'd' (day), 'm' (month), 'a' (anchor year),
'y' (year); second day, month, year have a '2' suffix.

These patterns are used for both date validation and for reformatting.  This table should not be moved to ~/Configuration
because changes to this table require changes to check_date() and to reformatter() and reformat_date()

]]

local patterns_t = {
	 																			-- year-initial numerical year-month-day
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'},					
																				-- month-initial: month day, year
	['Mdy'] = {'^(%D-) +([1-9]%d?), +((%d%d%d%d?)%a?)$', 'm', 'd', 'a', 'y'},
																				-- month-initial day range: month day–day, year; days are separated by endash
	['Md-dy'] = {'^(%D-) +([1-9]%d?)[%-–]([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'd2', 'a', 'y'},
																				-- day-initial: day month year
	['dMy'] = {'^([1-9]%d?) +(%D-) +((%d%d%d%d?)%a?)$', 'd', 'm', 'a', 'y'},
																				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed; not supported at en.wiki
	--	['yMd'] = {'^((%d%d%d%d?)%a?) +(%D-) +(%d%d?)$', 'a', 'y', 'm', 'd'},
																				-- day-range-initial: day–day month year; days are separated by endash
	['d-dMy'] = {'^([1-9]%d?)[%-–]([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'd2', 'm', 'a', 'y'},
																				-- day initial month-day-range: day month - day month year; uses spaced endash
	['dM-dMy'] = {'^([1-9]%d?) +(%D-) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'd2', 'm2', 'a', 'y'},
																				-- month initial month-day-range: month day – month day, year;  uses spaced endash
	['Md-Mdy'] = {'^(%D-) +([1-9]%d?) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$','m', 'd', 'm2', 'd2', 'a', 'y'},
																				-- day initial month-day-year-range: day month year - day month year; uses spaced endash
	['dMy-dMy'] = {'^([1-9]%d?) +(%D-) +(%d%d%d%d) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'y', 'd2', 'm2', 'a', 'y2'},
																				-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
	['Mdy-Mdy'] = {'^(%D-) +([1-9]%d?), +(%d%d%d%d) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'y', 'm2', 'd2', 'a', 'y2'},

																				-- these date formats cannot be converted, per se, but month name can be rendered short or long
																				-- month/season year - month/season year; separated by spaced endash
	['My-My'] = {'^(%D-) +(%d%d%d%d) +[%-–] +(%D-) +((%d%d%d%d)%a?)$', 'm', 'y', 'm2', 'a', 'y2'},
																				-- month/season range year; months separated by endash
	['M-My'] = {'^(%D-)[%-–](%D-) +((%d%d%d%d)%a?)$', 'm', 'm2', 'a', 'y'},
																				-- month/season year or proper-name year; quarter year when First Quarter YYYY etc.
	['My'] = {'^([^%d–]-) +((%d%d%d%d)%a?)$', 'm', 'a', 'y'},					-- this way because endash is a member of %D; %D- will match January–March 2019 when it shouldn't

																				-- these date formats cannot be converted
	['Sy4-y2'] = {'^(%D-) +((%d%d)%d%d)[%-–]((%d%d)%a?)$'},						-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
	['Sy-y'] = {'^(%D-) +(%d%d%d%d)[%-–]((%d%d%d%d)%a?)$'},						-- special case Winter/Summer year-year; year separated with unspaced endash
	['y-y'] = {'^(%d%d%d%d?)[%-–]((%d%d%d%d?)%a?)$'},							-- year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
	['y4-y2'] = {'^((%d%d)%d%d)[%-–]((%d%d)%a?)$'},								-- year range: YYYY–YY; separated by unspaced endash
	['y'] = {'^((%d%d%d%d?)%a?)$'},												-- year; here accept either YYY or YYYY
	}


--[[--------------------------&lt; I S _ V A L I D _ E M B A R G O _ D A T E &gt;------------------------------------

returns true and date value if that value has proper dmy, mdy, ymd format.

returns false and 9999 (embargoed forever) when date value is not proper format; assumes that when |pmc-embargo-date= is
set, the editor intended to embargo a PMC but |pmc-embargo-date= does not hold a single date.

]]

local function is_valid_embargo_date (v)
	if v:match (patterns_t['ymd'][1]) or										-- ymd
		v:match (patterns_t['Mdy'][1]) or										-- dmy
		v:match (patterns_t['dMy'][1]) then										-- mdy
			return true, v;
	end
	return false, '9999';														-- if here not good date so return false and set embargo date to long time in future
end


--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only
allowed range separator is endash.  Additionally, check the date to see that it is a real date: no 31 in 30-day
months; no 29 February when not a leap year.  Months, both long-form and three character abbreviations, and seasons
must be spelled correctly.  Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and
COinS_date.  When this happens, the date parameter is (DEBUG: not?) used in the COinS metadata and the CITEREF identifier gets
its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, publication-date, access-date, pmc-embargo-date, archive-date, lay-date)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is ISO 8601 format date; see make_COInS_date()

]]

local function check_date (date_string, param, tCOinS_date)
	local year;																	-- assume that year2, months, and days are not used;
	local year2 = 0;															-- second year in a year range
	local month = 0;
	local month2 = 0;															-- second month in a month range
	local day = 0;
	local day2 = 0;																-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match (patterns_t['ymd'][1]) then							-- year-initial numerical year month day format
		year, month, day = date_string:match (patterns_t['ymd'][1]);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or 0 == tonumber(day) then return false; end	-- month or day number not valid or not Gregorian calendar
		anchor_year = year;
	
	elseif mw.ustring.match(date_string, patterns_t['Mdy'][1]) then				-- month-initial: month day, year
		month, day, anchor_year, year = mw.ustring.match(date_string, patterns_t['Mdy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
				
	elseif mw.ustring.match(date_string, patterns_t['Md-dy'][1]) then			-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year = mw.ustring.match(date_string, patterns_t['Md-dy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2=month;															-- for metadata
		year2 = year;

	elseif mw.ustring.match(date_string, patterns_t['dMy'][1]) then				-- day-initial: day month year
		day, month, anchor_year, year = mw.ustring.match(date_string, patterns_t['dMy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months

--[[ NOT supported at en.wiki
	elseif mw.ustring.match(date_string, patterns_t['yMd'][1]) then				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed
		anchor_year, year, month, day = mw.ustring.match(date_string, patterns_t['yMd'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
-- end NOT supported at en.wiki ]]

	elseif mw.ustring.match(date_string, patterns_t['d-dMy'][1]) then			-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year = mw.ustring.match(date_string, patterns_t['d-dMy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2 = month;															-- for metadata
		year2 = year;

	elseif mw.ustring.match(date_string, patterns_t['dM-dMy'][1]) then			-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year = mw.ustring.match(date_string, patterns_t['dM-dMy'][1]);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2 = year;

	elseif mw.ustring.match(date_string, patterns_t['Md-Mdy'][1]) then			-- month initial month-day-range: month day – month day, year; uses spaced endash
		month, day, month2, day2, anchor_year, year = mw.ustring.match(date_string, patterns_t['Md-Mdy'][1]);
		if (not is_valid_month_season_range(month, month2, param)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2 = year;

	elseif mw.ustring.match(date_string, patterns_t['dMy-dMy'][1]) then			-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2 = mw.ustring.match(date_string, patterns_t['dMy-dMy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		if 0 == month or 0 == month2 then return false; end						-- both must be valid

	elseif mw.ustring.match(date_string, patterns_t['Mdy-Mdy'][1]) then			-- month initial month-day-year-range: month day, year – month day, year; uses spaced endash
		month, day, year, month2, day2, anchor_year, year2 = mw.ustring.match(date_string, patterns_t['Mdy-Mdy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number(month2);
		if 0 == month or 0 == month2 then return false; end						-- both must be valid

	elseif mw.ustring.match(date_string, patterns_t['Sy4-y2'][1]) then			-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		local century;
		month, year, century, anchor_year, year2 = mw.ustring.match(date_string, patterns_t['Sy4-y2'][1]);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;		-- 'month' can only be Winter or Summer
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor_year from both years
		year2 = century..year2;													-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		month = get_season_number(month, param);

	elseif mw.ustring.match(date_string, patterns_t['Sy-y'][1]) then			-- special case Winter/Summer year-year; year separated with unspaced endash
		month, year, anchor_year, year2 = mw.ustring.match(date_string, patterns_t['Sy-y'][1]);
		month = get_season_number (month, param);								-- &lt;month&gt; can only be winter or summer; also for metadata
		if (month ~= cfg.date_names['en'].season['Winter']) and (month ~= cfg.date_names['en'].season['Summer']) then
			return false;														-- not Summer or Winter; abandon
		end
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, patterns_t['My-My'][1]) then			-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2 = mw.ustring.match(date_string, patterns_t['My-My'][1]);
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then 	-- both must be month year, same month style
			month = get_month_number(month);
			month2 = get_month_number(month2);
		elseif 0 ~= get_season_number(month, param) and 0 ~= get_season_number(month2, param) then	-- both must be season year, not mixed
			month = get_season_number(month, param);
			month2 = get_season_number(month2, param);
		else
			 return false;
		end

	elseif mw.ustring.match(date_string, patterns_t['M-My'][1]) then			-- month/season range year; months separated by endash 
		month, month2, anchor_year, year = mw.ustring.match(date_string, patterns_t['M-My'][1]);
		if (not is_valid_month_season_range(month, month2, param)) or (not is_valid_year(year)) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
			month2 = get_month_number(month2);
			if 0 == month or 0 == month2 then return false; end
		else
			month = get_season_number(month, param);
			month2 = get_season_number(month2, param);
		end
		year2 = year;
		
	elseif mw.ustring.match(date_string, patterns_t['My'][1]) then				-- month/season/quarter/proper-name year
		month, anchor_year, year = mw.ustring.match(date_string, patterns_t['My'][1]);
		if not is_valid_year(year) then return false; end
		month = get_element_number(month, param);								-- get month season quarter proper-name number or nil
		if not month then return false; end										-- not valid whatever it is

	elseif mw.ustring.match(date_string, patterns_t['y-y'][1]) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2 = mw.ustring.match(date_string, patterns_t['y-y'][1]);
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, patterns_t['y4-y2'][1]) then			-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2 = mw.ustring.match(date_string, patterns_t['y4-y2'][1]);
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor year from both years

		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century .. year2;												-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

		if in_array (param, {'date', 'publication-date', 'year'}) then			-- here when 'valid' abbreviated year range; if one of these parameters
			add_prop_cat ('year-range-abbreviated');							-- add properties cat
		end

	elseif mw.ustring.match(date_string, patterns_t['y'][1]) then				-- year; here accept either YYY or YYYY
		anchor_year, year = mw.ustring.match(date_string, patterns_t['y'][1]);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;															-- date format not one of the MOS:DATE approved formats
	end

	if param ~= 'date' then														-- CITEREF disambiguation only allowed in |date=; |year= &amp; |publication-date= promote to date
		if anchor_year:match ('%l$') then
			return false;
		end
	end

	if 'access-date' == param then												-- test access-date here because we have numerical date parts
		if 0 ~= year and 0 ~= month and 0 ~= day and 							-- all parts of a single date required
			0 == year2 and 0 == month2 and 0 == day2 then						-- none of these; access-date must not be a range
				if not is_valid_accessdate(year .. '-' .. month .. '-' .. day) then	
					return false;												-- return false when access-date out of bounds
				end
		else
			return false;														-- return false when access-date is a range of two dates
		end
	end

	if 'archive-date' == param then												-- test archive-date here because we have numerical date parts
		if not (0 ~= year and 0 ~= month and 0 ~= day and						-- all parts of a single date required
			0 == year2 and 0 == month2 and 0 == day2) then						-- none of these; archive-date must not be a range
				return false;													-- return false when archive-date is a range of two dates
		end
	end

	local result=true;															-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result = is_valid_date (year, month, day, param);						-- &lt;param&gt; for |pmc-embargo-date=

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result = is_valid_date (year, month, day);
		result = result and is_valid_date (year, month, day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result = is_valid_date (year, month, day);
		result = result and is_valid_date (year, month2, day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result = is_valid_date(year, month, day);
		result = result and is_valid_date(year2, month2, day2);
	end
	
	if false == result then return false; end

	if nil ~= tCOinS_date then													-- this table only passed into this function when testing |date= parameter values
		make_COinS_date ({year = year, month = month, day = day, year2 = year2, month2 = month2, day2 = day2}, tCOinS_date);	-- make an ISO 8601 date string for COinS
	end
	
	return true, anchor_year;													-- format is good and date string represents a real date
end	


--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
parameters with errors are added to the &lt;error_list&gt; sequence table as the dates are tested.

]]

local function dates(date_parameters_list, tCOinS_date, error_list)
	local anchor_year;															-- will return as nil if the date being tested is not |date=
	local COinS_date;															-- will return as nil if the date being tested is not |date=
	local embargo_date;															-- if embargo date is a good dmy, mdy, ymd date then holds original value else reset to 9999
	local good_date = false;

	for k, v in pairs(date_parameters_list) do									-- for each date-holding parameter in the list
		if is_set(v.val) then													-- if the parameter has a value
			v.val = mw.ustring.gsub(v.val, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9
			if v.val:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then						-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v.val:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);				-- get the year portion so it can be tested
				if 'date' == k then
					anchor_year, COinS_date = v.val:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year' == k then
					good_date = is_valid_year(year);
				end
			elseif 'date' == k then												-- if the parameter is |date=
				if v.val:match(&quot;^n%.d%.%a?$&quot;) then -- ToDo: I18N								-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((n%.d%.)%a?)&quot;); -- ToDo: I18N	-- &quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v.val:match(&quot;^nd%a?$&quot;) then -- ToDo: I18N								-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((nd)%a?)&quot;); -- ToDo: I18N	-- &quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v.val, k, tCOinS_date);	-- go test the date
				end
			elseif 'year' == k then												-- if the parameter is |year= it should hold only a year value
				if v.val:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then						-- if |year = 3 or 4 digits only with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((%d+)%a?)&quot;);
				end
			elseif 'pmc-embargo-date' == k then									-- if the parameter is |pmc-embargo-date=
				good_date = check_date (v.val, k);								-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date, embargo_date = is_valid_embargo_date (v.val);	-- is |pmc-embargo-date= date a single dmy, mdy, or ymd formatted date? yes: returns embargo date; no: returns 9999
				end
			else																-- any other date-holding parameter
				good_date = check_date (v.val, k);								-- go test the date
			end
			if false == good_date then											-- assemble one error message so we don't add the tracking category multiple times
				table.insert (error_list, wrap_style ('parameter', v.name));	-- make parameter name suitable for error message list
			end
		end
	end
	return anchor_year, embargo_date;											-- and done
end


--[[--------------------------&lt; Y E A R _ C H E C K &gt;----------------------------------------------------------

Temporary function to test |year= for acceptable values:
	YYY, YYYY, year-only ranges, their circa forms, with or without CITEREF disambiguators.

When |year= holds some form of date that is not one of these year-only dates, emit a maintenance message.

This function necessary because many non-cs1|2 templates have a |year= parameter so cirrus searches are more-or-
less useless

]]

local function year_check (year)
	year = year:gsub ('c%. *', '');												-- remove circa annotation (if present) before testing &lt;year&gt;
	
	for _, index in ipairs ({'y-y', 'y4-y2', 'y'}) do							-- spin through these indexes into patterns_t
		if mw.ustring.match (year, patterns_t[index][1]) then
			return;																-- if a match then |year= holds a valid 'year'
		end
	end

	set_message ('maint_year');													-- if here, |year= value is not an accepted value; add a maint cat
end


--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function sets a local numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

the numeric value in &lt;result&gt; determines the 'output' if any from this function:
	0 – adds error message to error_list sequence table
	1 – adds maint cat
	2 – does nothing

]]

local function year_date_check (year_string, year_origin, date_string, date_origin, error_list)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes

	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where both date and year are required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard range formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif mw.ustring.match(date_string, &quot;%d%d%d%d[%-–]%d%d&quot;) then				-- YYYY-YY date ranges
		local century;
		date1, century, date2 = mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	else																		-- should never get here; this function called only when no other date errors
		result = 0;																-- no recognizable year in date
	end

	if 0 == result then															-- year / date mismatch
		table.insert (error_list, substitute (cfg.messages['mismatch'], {year_origin, date_origin}));	-- add error message to error_list sequence table
	elseif 1 == result then														-- redundant year / date
		set_message ('maint_date_year');										-- add a maint cat
	end
end


--[[--------------------------&lt; R E F O R M A T T E R &gt;--------------------------------------------------------

reformat 'date' into new format specified by format_param if pattern_idx (the current format of 'date') can be
reformatted.  Does the grunt work for reformat_dates().

The table re_formats maps pattern_idx (current format) and format_param (desired format) to a table that holds:
	format string used by string.format()
	identifier letters ('d', 'm', 'y', 'd2', 'm2', 'y2') that serve as indexes into a table t{} that holds captures
		from mw.ustring.match() for the various date parts specified by  patterns_t[pattern_idx][1]

Items in patterns_t{} have the general form:
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'}, where:
		['ymd'] is pattern_idx
		patterns_t['ymd'][1] is the match pattern with captures for mw.ustring.match()
		patterns_t['ymd'][2] is an indicator letter identifying the content of the first capture
		patterns_t['ymd'][3] ... the second capture etc.

when a pattern matches a date, the captures are loaded into table t{} in capture order using the idemtifier
characters as indexes into t{}  For the above, a ymd date is in t{} as:
	t.y = first capture (year), t.m = second capture (month), t.d = third capture (day)

To reformat, this function is called with the pattern_idx that matches the current format of the date and with
format_param set to the desired format.  This function loads table t{} as described and then calls string.format()
with the format string specified by re_format[pattern_idx][format_param][1] using values taken from t{} according
to the capture identifier letters specified by patterns_t[pattern_idx][format_param][n] where n is 2..

]]

local re_formats = {
	['ymd'] = {																	-- date format is ymd; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
	--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},								-- |df=yMd; not supported at en.wiki
		},
	['Mdy'] = {																	-- date format is Mdy; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- for long/short reformatting
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
	--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},								-- |df=yMd; not supported at en.wiki
		},
	['dMy'] = {																	-- date format is dMy; reformat to:
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- for long/short reformatting
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
	--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},								-- |df=yMd; not supported at en.wiki
		},
	['Md-dy'] = {																-- date format is Md-dy; reformat to:
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- for long/short reformatting
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- |df=dmy -&gt; d-dMy 
		},
	['d-dMy'] = {																-- date format is d-d&gt;y; reformat to:
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- for long/short reformatting
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- |df=mdy -&gt; Md-dy 
		},
	['dM-dMy'] = {																-- date format is dM-dMy; reformat to:
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- for long/short reformatting
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd', 'm2', 'd2', 'y'},				-- |df=mdy -&gt; Md-Mdy 
		},
	['Md-Mdy'] = {																-- date format is Md-Mdy; reformat to:
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd',  'm2', 'd2', 'y'},			-- for long/short reformatting
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- |df=dmy -&gt; dM-dMy 
		},
	['dMy-dMy'] = {																-- date format is dMy-dMy; reformat to:
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- for long/short reformatting
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- |df=mdy -&gt; Mdy-Mdy 
		},
	['Mdy-Mdy'] = {																-- date format is Mdy-Mdy; reformat to:
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- for long/short reformatting
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- |df=dmy -&gt; dMy-dMy 
		},
	['My-My'] = {																-- these for long/short reformatting
		['any'] = {'%s %s – %s %s', 'm', 'y', 'm2', 'y2'},						-- dmy/mdy agnostic
		},
	['M-My'] = {																-- these for long/short reformatting
		['any'] = {'%s–%s %s', 'm', 'm2', 'y'},									-- dmy/mdy agnostic
		},
	['My'] = {																	-- these for long/short reformatting
		['any'] = {'%s %s', 'm', 'y'},											-- dmy/mdy agnostic
		},
	--	['yMd'] = {																-- not supported at en.wiki
	--		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},								-- |df=mdy
	--		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},								-- |df=dmy
	--		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},								-- |df=ymd
	--		},
	}


local function reformatter (date, pattern_idx, format_param, mon_len)
	if not in_array (pattern_idx, {'ymd', 'Mdy', 'Md-dy', 'dMy', 'yMd', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- not in this set of date format patterns_t then not a reformattable date
	end
	
	if 'ymd' == format_param and in_array (pattern_idx, {'ymd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- ymd date ranges not supported at en.wiki; no point in reformatting ymd to ymd
	end

	if in_array (pattern_idx, {'My', 'M-My', 'My-My'}) then						-- these are not dmy/mdy so can't be 'reformatted' into either
		format_param = 'any';													-- so format-agnostic 
	end

																				-- yMd is not supported at en.wiki; when yMd is supported at your wiki, uncomment the next line
	--	if 'yMd' == format_param and in_array (pattern_idx, {'yMd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy'}) then	-- these formats not convertable; yMd not supported at en.wiki
	if 'yMd' == format_param then												-- yMd not supported at en.wiki; when yMd is supported at your wiki, remove or comment-out this line
		return;																	-- not a reformattable date
	end
	
	local c1, c2, c3, c4, c5, c6, c7;											-- these hold the captures specified in patterns_t[pattern_idx][1]
	c1, c2, c3, c4, c5, c6, c7 = mw.ustring.match (date, patterns_t[pattern_idx][1]);	-- get the captures

	local t = {																	-- table that holds k/v pairs of date parts from the captures and patterns_t[pattern_idx][2..]
		[patterns_t[pattern_idx][2]] = c1;										-- at minimum there is always one capture with a matching indicator letter
		[patterns_t[pattern_idx][3] or 'x'] = c2;								-- patterns_t can have a variable number of captures; each capture requires an indicator letter;
		[patterns_t[pattern_idx][4] or 'x'] = c3;								-- where there is no capture, there is no indicator letter so n in patterns_t[pattern_idx][n] will be nil;
		[patterns_t[pattern_idx][5] or 'x'] = c4;								-- the 'x' here spoofs an indicator letter to prevent 'table index is nil' error
		[patterns_t[pattern_idx][6] or 'x'] = c5;
		[patterns_t[pattern_idx][7] or 'x'] = c6;
		[patterns_t[pattern_idx][8] or 'x'] = c7;
		};

	if t.a then																	-- if this date has an anchor year capture (all convertable date formats except ymd)
		if t.y2 then															-- for year range date formats														
			t.y2 = t.a;															-- use the anchor year capture when reassembling the date
		else																	-- here for single date formats (except ymd)
			t.y = t.a;															-- use the anchor year capture when reassembling the date
		end
	end

	if tonumber(t.m) then														-- if raw month is a number (converting from ymd)
		if 's' == mon_len then													-- if we are to use abbreviated month names
			t.m = cfg.date_names['inv_local_short'][tonumber(t.m)];					-- convert it to a month name
		else
			t.m = cfg.date_names['inv_local_long'][tonumber(t.m)];					-- convert it to a month name
		end
		t.d = t.d:gsub ('0(%d)', '%1');											-- strip leading '0' from day if present
	elseif 'ymd' == format_param then											-- when converting to ymd
		t.y = t.y:gsub ('%a', '');												-- strip CITREF disambiguator if present; anchor year already known so process can proceed; TODO: maint message?
		if 1582 &gt; tonumber (t.y) then											-- ymd format dates not allowed before 1582
			return;
		end
		t.m = string.format ('%02d', get_month_number (t.m));					-- make sure that month and day are two digits
		t.d = string.format ('%02d', t.d);
	elseif mon_len then															-- if mon_len is set to either 'short' or 'long'
		for _, mon in ipairs ({'m', 'm2'}) do									-- because there can be two month names, check both 
			if t[mon] then
				t[mon] = get_month_number (t[mon]);								-- get the month number for this month (is length agnostic)
				if 0 == t[mon] then return; end									-- seasons and named dates can't be converted
				t[mon] = (('s' == mon_len) and cfg.date_names['inv_local_short'][t[mon]]) or cfg.date_names['inv_local_long'][t[mon]];	-- fetch month name according to length
			end
		end
	end

	local new_date = string.format (re_formats[pattern_idx][format_param][1],	-- format string
		t[re_formats[pattern_idx][format_param][2]],							-- named captures from t{}
		t[re_formats[pattern_idx][format_param][3]],
		t[re_formats[pattern_idx][format_param][4]],
		t[re_formats[pattern_idx][format_param][5]],
		t[re_formats[pattern_idx][format_param][6]],
		t[re_formats[pattern_idx][format_param][7]],
		t[re_formats[pattern_idx][format_param][8]]
		);

	return new_date;
end


--[[-------------------------&lt; R E F O R M A T _ D A T E S &gt;--------------------------------------------------

Reformats existing dates into the format specified by format.

format is one of several manual keywords: dmy, dmy-all, mdy, mdy-all, ymd, ymd-all.  The -all version includes
access- and archive-dates; otherwise these dates are not reformatted.

This function allows automatic date formatting.  In ~/Configuration, the article source is searched for one of
the {{use xxx dates}} templates.  If found, xxx becomes the global date format as xxx-all.  If |cs1-dates= in
{{use xxx dates}} has legitimate value then that value determines how cs1|2 dates will be rendered.  Legitimate
values for |cs1-dates= are:
	l - all dates are rendered with long month names
	ls - publication dates use long month names; access-/archive-dates use abbreviated month names
	ly - publication dates use long month names; access-/archive-dates rendered in ymd format
	s - all dates are rendered with abbreviated (short) month names
	sy - publication dates use abbreviated month names; access-/archive-dates rendered in ymd format
	y - all dates are rendered in ymd format

the format argument for automatic date formatting will be the format specified by {{use xxx dates}} with the
value supplied by |cs1-dates so one of: xxx-l, xxx-ls, xxx-ly, xxx-s, xxx-sy, xxx-y, or simply xxx (|cs1-dates=
empty, omitted, or invalid) where xxx shall be either of dmy or mdy.

dates are extracted from date_parameters_list, reformatted (if appropriate), and then written back into the
list in the new format.  Dates in date_parameters_list are presumed here to be valid (no errors).  This function
returns true when a date has been reformatted, false else.  Actual reformatting is done by reformatter().

]]

local function reformat_dates (date_parameters_list, format)
	local all = false;															-- set to false to skip access- and archive-dates
	local len_p = 'l';															-- default publication date length shall be long
	local len_a = 'l';															-- default access-/archive-date length shall be long
	local result = false;
	local new_date;																
	
	if format:match('%a+%-all') then											-- manual df keyword; auto df keyword when length not specified in {{use xxx dates}}; 
		format = format:match('(%a+)%-all');									-- extract the format
		all = true;																-- all dates are long format dates because this keyword doesn't specify length
	elseif format:match('%a+%-[lsy][sy]?') then									-- auto df keywords; internal only
		all = true;																-- auto df applies to all dates; use length specified by capture len_p for all dates
		format, len_p, len_a = format:match('(%a+)%-([lsy])([sy]?)');			-- extract the format and length keywords
		if 'y' == len_p then													-- because allowed by MOS:DATEUNIFY (sort of) range dates and My dates not reformatted
			format = 'ymd';														-- override {{use xxx dates}}
		elseif (not is_set(len_a)) or (len_p == len_a) then						-- no access-/archive-date length specified or same length as publication dates then
			len_a = len_p;														-- in case len_a not set
		end
	end																			-- else only publication dates and they are long

	for param_name, param_val in pairs (date_parameters_list) do				-- for each date-holding parameter in the list
		if is_set (param_val.val) then											-- if the parameter has a value
			if not (not all and in_array (param_name, {'access-date', 'archive-date'})) then	-- skip access- or archive-date unless format is xxx-all; yeah, ugly; TODO: find a better way
				for pattern_idx, pattern in pairs (patterns_t) do
					if mw.ustring.match (param_val.val, pattern[1]) then
						if all and in_array (param_name, {'access-date', 'archive-date'}) then	-- if this date is an access- or archive-date
							new_date = reformatter (param_val.val, pattern_idx, (('y' == len_a) and 'ymd') or format, len_a);	-- choose ymd or dmy/mdy according to len_a setting
						else													-- all other dates
							new_date = reformatter (param_val.val, pattern_idx, format, len_p);
						end
						
						if new_date then										-- set when date was reformatted
							date_parameters_list[param_name].val = new_date;	-- update date in date list
							result = true;										-- and announce that changes have been made
							break;
						end
					end	-- if
				end		-- for
			end			-- if
		end				-- if
	end					-- for
	return result;																-- declare boolean result and done
end


--[[--------------------------&lt; D A T E _ H Y P H E N _ T O _ D A S H &gt;----------------------------------------

Loops through the list of date-holding parameters and converts any hyphen to an ndash.  Not called if the cs1|2
template has any date errors.

Modifies the date_parameters_list and returns true if hyphens are replaced, else returns false.

]]

local function date_hyphen_to_dash (date_parameters_list)
	local result = false;
	local n;
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set (param_val.val) and
			not mw.ustring.match (param_val.val, patterns_t.ymd[1]) then		-- for those that are not ymd dates (ustring because here digits may not be Western)
				param_val.val, n = param_val.val:gsub ('%-', '–');				-- replace any hyphen with ndash
				if 0 ~= n then
					date_parameters_list[param_name].val = param_val.val;		-- update the list
					result = true;
				end
		end
	end
	return result;																-- so we know if any hyphens were replaced
end


--[[-------------------------&lt; D A T E _ N A M E _ X L A T E &gt;------------------------------------------------

Attempts to translate English date names to local-language date names using names supplied by MediaWiki's
date parser function.  This is simple name-for-name replacement and may not work for all languages.

if xlat_dig is true, this function will also translate Western (English) digits to the local language's digits.
This will also translate ymd dates.

]]

local function date_name_xlate (date_parameters_list, xlt_dig)
	local xlate;
	local mode;																	-- long or short month names
	local modified = false;
	local date;
	
	local sources_t = {
		{cfg.date_names.en.long, cfg.date_names.inv_local_long},				-- for translating long English month names to long local month names
		{cfg.date_names.en.short, cfg.date_names.inv_local_short},				-- short month names
		{cfg.date_names.en.quarter, cfg.date_names.inv_local_quarter},			-- quarter date names
		{cfg.date_names.en.season, cfg.date_names.inv_local_season},			-- season date nam
		{cfg.date_names.en.named, cfg.date_names.inv_local_named},				-- named dates
		}

	local function is_xlateable (month)											-- local function to get local date name that replaces existing English-language date name
		for _, date_names_t in ipairs (sources_t) do							-- for each sequence table in date_names_t
			if date_names_t[1][month] then										-- if date name is English month (long or short), quarter, season or named and
				if date_names_t[2][date_names_t[1][month]] then					-- if there is a matching local date name
					return date_names_t[2][date_names_t[1][month]];				-- return the local date name
				end
			end
		end
	end

	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val.val) then											-- if the parameter has a value
			date = param_val.val;
			for month in mw.ustring.gmatch (date, '[%a ]+') do					-- iterate through all date names in the date (single date or date range)
				month = mw.text.trim (month);									-- this because quarterly dates contain whitespace
				xlate = is_xlateable (month);									-- get translate &lt;month&gt;; returns translation or nil
				
				if xlate then		
					date = mw.ustring.gsub (date, month, xlate);				-- replace the English with the translation
					date_parameters_list[param_name].val = date;				-- save the translated date
					modified = true;
				end
			end

			if xlt_dig then														-- shall we also translate digits?
				date = date:gsub ('%d', cfg.date_names.xlate_digits);			-- translate digits from Western to 'local digits'
				date_parameters_list[param_name].val = date;					-- save the translated date
				modified = true;
			end
		end
	end
	
	return modified;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	add_prop_cat = utilities_page_ptr.add_prop_cat ;							-- import functions from selected Module:Citation/CS1/Utilities module
	is_set = utilities_page_ptr.is_set;
	in_array = utilities_page_ptr.in_array;
	set_message = utilities_page_ptr.set_message;
	substitute = utilities_page_ptr.substitute;
	wrap_style = utilities_page_ptr.wrap_style;

	cfg = cfg_table_ptr;														-- import tables from selected Module:Citation/CS1/Configuration
end


--[[--------------------------&lt; A R C H I V E _ D A T E _ C H E C K &gt;------------------------------------------

Compare value in |archive-date= with the timestamp in Wayback machine urls.  Emits an error message with suggested
date from the |archive-url= timestamp in an appropriate format when the value in |archive-date= does not match
the timestamp.

this function never called when any date in a cs1|2 template has errors

error message suggests new |archive-date= value in an appropriate format specified by &lt;df&gt;.  &lt;df&gt; is either 
|df= or cfg.global_df in that order.  If &lt;df&gt; is nil, suggested date has format from |archive-date=.  There is
a caveat: when |df=dmy or |df=mdy, the reformatter leaves |access-date= and |archive-date= formats as they are.
The error message suggested date is passed to the formatter as YYYY-MM-DD so when |df=dmy or |df=mdy, the format
is not changed.

]]

local function archive_date_check (archive_date, archive_url_timestamp, df)
	local archive_date_format = 'dmy-y';										-- holds the date format of date in |archive-date; default to ymd; 'dmy' used here to spoof reformat_dates() 
	
	for _, v_t in ipairs ({{'dMy', 'dmy-all'}, {'Mdy', 'mdy-all'}}) do			-- is |archive-date= format dmy or mdy?
		if archive_date:match (patterns_t[v_t[1]][1]) then						-- does the pattern match?
			archive_date_format = cfg.keywords_xlate[v_t[2]];					-- get appropriate |df= supported keyword from the i18n translator table
			break;
		end
	end
	
	local dates_t = {};
	dates_t['archive-date'] = {val=archive_date, name=''};						-- setup to call reformat_dates(); never called when errors so &lt;name&gt; unset as not needed
	reformat_dates (dates_t, 'dmy-y');											-- reformat |archive-date= to ymd; 'dmy' used here to spoof reformat_dates()
	local archive_url_date = archive_url_timestamp:gsub ('(%d%d%d%d)(%d%d)(%d%d)%d*', '%1-%2-%3');	-- make ymd format date from timestamp

	if dates_t['archive-date'].val == archive_url_date then						-- are the two dates the same
		return;																	-- yes, done
	else
		dates_t['archive-date'] = {val=archive_url_date, name=''};				-- setup to call reformat_dates() with the timestamp date
		reformat_dates (dates_t, df or archive_date_format);					-- reformat timestamp to format specified by &lt;df&gt; or format used in |archive-date= 
		archive_url_date = dates_t['archive-date'].val;
		set_message ('err_archive_date_url_ts_mismatch', archive_url_date);		-- emit an error message
	end
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {																		-- return exported functions
	archive_date_check = archive_date_check,
	date_hyphen_to_dash = date_hyphen_to_dash,
	date_name_xlate = date_name_xlate,
	dates = dates,
	reformat_dates = reformat_dates,
	set_selected_modules = set_selected_modules,
	year_check = year_check,
	year_date_check = year_date_check,
	}</text>
      <sha1>h37xf2hxsrjgq13ms7lozl3uiigkklr</sha1>
    </revision>
    <revision>
      <id>4861</id>
      <parentid>4860</parentid>
      <timestamp>2025-08-07T07:38:35Z</timestamp>
      <contributor>
        <username>Martin Urbanec</username>
        <id>803</id>
      </contributor>
      <minor />
      <comment>44 revisions imported from [[:en:Module:Citation/CS1/Date_validation]]: updating from enwiki</comment>
      <origin>4860</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="67787" sha1="h37xf2hxsrjgq13ms7lozl3uiigkklr" xml:space="preserve">--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local add_prop_cat, is_set, in_array, set_message, substitute, wrap_style;		-- imported functions from selected Module:Citation/CS1/Utilities
local cfg;																		-- table of tables imported from selected Module:Citation/CS1/Configuration


--[[--------------------------&lt; F I L E - S C O P E   D E C L A R A T I O N S &gt;--------------------------------

File-scope variables are declared here

]]

local lang_object = mw.getContentLanguage();									-- used by is_valid_accessdate(), is_valid_year(), date_name_xlate(); TODO: move to ~/Configuration?
local year_limit;																-- used by is_valid_year()


--[=[-------------------------&lt; I S _ V A L I D _ A C C E S S D A T E &gt;----------------------------------------

returns true if:
	Wikipedia start date &lt;= accessdate &lt; today + 2 days

Wikipedia start date is 2001-01-15T00:00:00 UTC which is 979516800 seconds after 1970-01-01T00:00:00 UTC (the start of Unix time)
accessdate is the date provided in |access-date= at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-English date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate().  To get around that
call this function with YYYY-MM-DD format dates.

]=]

local function is_valid_accessdate (accessdate)
	local good1, good2;
	local access_ts, tomorrow_ts;												-- to hold Unix time stamps representing the dates

	good1, access_ts = pcall (lang_object.formatDate, lang_object, 'U', accessdate );			-- convert accessdate value to Unix timestamp 
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which which tonumber() may not understand
		access_ts = tonumber (access_ts) or lang_object:parseFormattedNumber (access_ts);		-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to Unix time stamp
	end

	if 979516800 &lt;= access_ts and access_ts &lt; tomorrow_ts then					-- Wikipedia start date &lt;= accessdate &lt; tomorrow's date
		return true;
	else
		return false;															-- accessdate out of range
	end
end


--[[--------------------------&lt; G E T _ M O N T H _ N U M B E R &gt;----------------------------------------------

returns a number according to the month in a date: 1 for January, etc.  Capitalization and spelling must be correct.
If not a valid month, returns 0

]]

local function get_month_number (month)
	return cfg.date_names['local'].long[month] or cfg.date_names['local'].short[month] or	-- look for local names first
			cfg.date_names['en'].long[month] or	cfg.date_names['en'].short[month] or		-- failing that, look for English names
			0;																				-- not a recognized month name
end


--[[--------------------------&lt; G E T _ S E A S O N _ N U M B E R &gt;--------------------------------------------

returns a number according to the sequence of seasons in a year: 21 for Spring, etc.  Capitalization and spelling
must be correct. If not a valid season, returns 0.
	21-24 = Spring, Summer, Autumn, Winter, independent of “Hemisphere”

returns 0 when &lt;param&gt; is not |date=

Season numbering is defined by Extended Date/Time Format (EDTF) specification (https://www.loc.gov/standards/datetime/)
which became part of ISO 8601 in 2019.  See '§Sub-year groupings'.  The standard defines various divisions using
numbers 21-41.  cs1|2 only supports generic seasons.  EDTF does support the distinction between north and south
hemisphere seasons but cs1|2 has no way to make that distinction.

These additional divisions not currently supported:
	25-28 = Spring - Northern Hemisphere, Summer- Northern Hemisphere, Autumn - Northern Hemisphere, Winter - Northern Hemisphere
	29-32 = Spring – Southern Hemisphere, Summer– Southern Hemisphere, Autumn – Southern Hemisphere, Winter - Southern Hemisphere
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)

]]

local function get_season_number (season, param)
	if 'date' ~= param then
		return 0;																-- season dates only supported by |date=
	end
	return cfg.date_names['local'].season[season] or							-- look for local names first
			cfg.date_names['en'].season[season] or								-- failing that, look for English names
			0;																	-- not a recognized season name
end


--[[--------------------------&lt; G E T _ Q U A R T E R _ N U M B E R &gt;------------------------------------------

returns a number according to the sequence of quarters in a year: 33 for first quarter, etc.  Capitalization and spelling
must be correct. If not a valid quarter, returns 0.
	33-36 = Quarter 1, Quarter 2, Quarter 3, Quarter 4 (3 months each)

returns 0 when &lt;param&gt; is not |date=

Quarter numbering is defined by Extended Date/Time Format (EDTF) specification (https://www.loc.gov/standards/datetime/)
which became part of ISO 8601 in 2019.  See '§Sub-year groupings'.  The standard defines various divisions using
numbers 21-41.  cs1|2 only supports generic seasons and quarters.

These additional divisions not currently supported:
	37-39 = Quadrimester 1, Quadrimester 2, Quadrimester 3 (4 months each)
	40-41 = Semestral 1, Semestral-2 (6 months each)

]]

local function get_quarter_number (quarter, param)
	if 'date' ~= param then
		return 0;																-- quarter dates only supported by |date=
	end
	quarter = mw.ustring.gsub (quarter, ' +', ' ');								-- special case replace multiple space chars with a single space char
	return cfg.date_names['local'].quarter[quarter] or							-- look for local names first
			cfg.date_names['en'].quarter[quarter] or							-- failing that, look for English names
			0;																	-- not a recognized quarter name
end


--[[--------------------------&lt; G E T _ P R O P E R _ N A M E _ N U M B E R &gt;----------------------------------

returns a non-zero number if date contains a recognized proper-name.  Capitalization and spelling must be correct.

returns 0 when &lt;param&gt; is not |date=

]]

local function get_proper_name_number (name, param)
	if 'date' ~= param then
		return 0;																-- proper-name dates only supported by |date=
	end
	return cfg.date_names['local'].named[name] or								-- look for local names dates first
			cfg.date_names['en'].named[name] or									-- failing that, look for English names
			0;																	-- not a recognized named date
end


--[[--------------------------&lt; G E T _ E L E M E N T _ N U M B E R &lt;------------------------------------------

returns true if month or season or quarter or proper name is valid (properly spelled, capitalized, abbreviated)

]]

local function get_element_number (element, param)
	local num;
	
	local funcs = {get_month_number, get_season_number, get_quarter_number, get_proper_name_number};	-- list of functions to execute in order
	
	for _, func in ipairs (funcs) do											-- spin through the function list
		num = func (element, param);											-- call the function and get the returned number
		if 0 ~= num then														-- non-zero when valid month season quarter 
			return num;															-- return that number
		end
	end
	return nil;																	-- not valid
end


--[[--------------------------&lt; I S _ V A L I D _ Y E A R &gt;----------------------------------------------------

Function gets current year from the server and compares it to year from a citation parameter.  Years more than one
year in the future are not acceptable.

Special case for |pmc-embargo-date=: years more than two years in the future are not acceptable

]]

local function is_valid_year (year, param)
	if not is_set (year_limit) then
		year_limit = tonumber(os.date(&quot;%Y&quot;))+1;									-- global variable so we only have to fetch it once
	end

	year = tonumber (year) or lang_object:parseFormattedNumber (year);			-- convert to number for the comparison
	if year and (100 &gt; year) then												-- years less than 100 not supported
		return false;
	end
	
	if 'pmc-embargo-date' == param then											-- special case for |pmc-embargo-date=
		return year and (year &lt;= tonumber(os.date(&quot;%Y&quot;))+2) or false;			-- years more than two years in the future are not accepted
	end	
	return year and (year &lt;= year_limit) or false;
end


--[[--------------------------&lt; I S _ V A L I D _ D A T E &gt;----------------------------------------------------

Returns true if day is less than or equal to the number of days in month and year is no farther into the future
than next year; else returns false.

Assumes Julian calendar prior to year 1582 and Gregorian calendar thereafter. Accounts for Julian calendar leap
years before 1582 and Gregorian leap years after 1582. Where the two calendars overlap (1582 to approximately
1923) dates are assumed to be Gregorian.

]]

local function is_valid_date (year, month, day, param)
local days_in_month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
local month_length;
	if not is_valid_year (year, param) then										-- no farther into the future than next year except |pmc-embargo-date= no more than two years in the future
		return false;
	end
	
	month = tonumber (month);													-- required for YYYY-MM-DD dates
	
	if (2 == month) then														-- if February
		month_length = 28;														-- then 28 days unless
		if 1582 &gt; tonumber(year) then											-- Julian calendar
			if 0 == (year%4) then												-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		else																	-- Gregorian calendar
			if (0 == (year%4) and (0 ~= (year%100) or 0 == (year%400))) then	-- is a leap year?
				month_length = 29;												-- if leap year then 29 days in February
			end
		end
	else
		month_length = days_in_month[month];
	end

	if tonumber (day) &gt; month_length then
		return false;
	end
	return true;
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ R A N G E _ S T Y L E &gt;--------------------------

Months in a range are expected to have the same style: Jan–Mar or October–December but not February–Mar or Jul–August. 
This function looks in cfg.date_names{} to see if both month names are listed in the long subtable or both are
listed in the short subtable.  When both have the same style (both are listed in the same table), returns true; false else

]]

local function is_valid_month_range_style (month1, month2)
	if (cfg.date_names.en.long[month1] and cfg.date_names.en.long[month2]) or					-- are both English names listed in the long subtable?
		(cfg.date_names.en.short[month1] and cfg.date_names.en.short[month2]) or				-- are both English names listed in the short subtable?
		(cfg.date_names['local'].long[month1] and cfg.date_names['local'].long[month2]) or		-- are both local names listed in the long subtable?
		(cfg.date_names['local'].short[month1] and cfg.date_names['local'].short[month2]) then	-- are both local names listed in the short subtable?
			return true;
	end
	return false;																-- names are mixed
end


--[[--------------------------&lt; I S _ V A L I D _ M O N T H _ S E A S O N _ R A N G E &gt;------------------------

Check a pair of months or seasons to see if both are valid members of a month or season pair.

Month pairs are expected to be left to right, earliest to latest in time.

All season ranges are accepted as valid because there are publishers out there who have published a Summer–Spring YYYY issue, hence treat as ok

]]

local function is_valid_month_season_range(range_start, range_end, param)
	local range_start_number = get_month_number (range_start);
	local range_end_number;

	if 0 == range_start_number then												-- is this a month range?
		range_start_number = get_season_number (range_start, param);			-- not a month; is it a season? get start season number
		range_end_number = get_season_number (range_end, param);				-- get end season number

		if (0 ~= range_start_number) and (0 ~= range_end_number) and (range_start_number ~= range_end_number) then
			return true;														-- any season pairing is accepted except when both are the same
		end
		return false;															-- range_start and/or range_end is not a season
	end
																				-- here when range_start is a month
	range_end_number = get_month_number (range_end);							-- get end month number
	if range_start_number &lt; range_end_number and								-- range_start is a month; does range_start precede range_end?
		is_valid_month_range_style (range_start, range_end) then				-- do months have the same style?
			return true;														-- proper order and same style
	end
	return false;																-- range_start month number is greater than or equal to range end number; or range end isn't a month
end


--[[--------------------------&lt; M A K E _ C O I N S _ D A T E &gt;------------------------------------------------

This function receives a table of date parts for one or two dates and an empty table reference declared in
Module:Citation/CS1.  The function is called only for |date= parameters and only if the |date=&lt;value&gt; is 
determined to be a valid date format.  The question of what to do with invalid date formats is not answered here.

The date parts in the input table are converted to an ISO 8601 conforming date string:
	single whole dates:		yyyy-mm-dd
	month and year dates:	yyyy-mm
	year dates:				yyyy
	ranges:					yyyy-mm-dd/yyyy-mm-dd
							yyyy-mm/yyyy-mm
							yyyy/yyyy

Dates in the Julian calendar are reduced to year or year/year so that we don't have to do calendar conversion from
Julian to Proleptic Gregorian.

The input table has:
	year, year2 – always present; if before 1582, ignore months and days if present
	month, month2 – 0 if not provided, 1-12 for months, 21-24 for seasons; 99 Christmas
	day, day2 –  0 if not provided, 1-31 for days
	
the output table receives:
	rftdate:	an ISO 8601 formatted date
	rftchron:	a free-form version of the date, usually without year which is in rftdate (season ranges and proper-name dates)
	rftssn:		one of four season keywords: winter, spring, summer, fall (lowercase)
	rftquarter:	one of four values: 1, 2, 3, 4

]]

local function make_COinS_date (input, tCOinS_date)
	local date;																	-- one date or first date in a range
	local date2 = '';															-- end of range date
	input.year = tonumber (input.year) or lang_object:parseFormattedNumber (input.year);	-- language-aware tonumber()
	input.year2 = tonumber (input.year2) or lang_object:parseFormattedNumber (input.year2);	-- COinS dates are pseudo-ISO 8601 so convert to Arabic numerals

	if ((1582 == input.year) and (10 &gt; tonumber(input.month))) or (1582 &gt; input.year) then	-- if a Julian calendar date
		tCOinS_date.rftdate = tostring (input.year);							-- &amp;rft.date gets year only
		return;																	-- done
	end
																				-- here for all forms of Gregorian dates
	if 20 &lt; tonumber (input.month) then											-- if season, quarter, or proper-name date
		date = input.year;														-- &amp;rft.date gets year only
		if 0 ~= input.year2 and input.year ~= input.year2 then					-- if a range, only the second year portion when not the same as range start year
			date = string.format ('%.4d/%.4d', input.year, input.year2)			-- assemble the date range
		end

		local season = {[24] = 'winter', [21] = 'spring', [22] = 'summer', [23] = 'fall', [33] = '1', [34] = '2', [35] = '3', [36] = '4', [98] = 'Easter', [99] = 'Christmas'};	-- seasons lowercase, no autumn; proper-names use title case
		if 0 == input.month2 then												-- single season, quarter, or proper-name date
			if 40 &lt; tonumber(input.month) then
				tCOinS_date.rftchron = season[input.month];						-- proper-name date; used in journal metadata only
			elseif 30 &lt; tonumber(input.month) then
				tCOinS_date.rftquarter = season[input.month];					-- quarter date; used in journal metadata only
			else
				tCOinS_date.rftssn = season[input.month];						-- season date; used in journal metadata only
			end
		else																	-- season ranges are lumped into &amp;rft.chron; &amp;rft.ssn and &amp;rft.quarter are left blank
			if input.year ~= input.year2 then									-- season year – season year range or season year–year
				if 0 ~= input.month2 then
					tCOinS_date.rftchron = string.format ('%s %s – %s %s', season[input.month], input.year, season[input.month2], input.year2);	-- used in journal metadata only
				end
			else																-- season–season year range
				tCOinS_date.rftchron = season[input.month] .. '–' .. season[input.month2];	-- season–season year range; used in journal metadata only
			end
		end

		tCOinS_date.rftdate = tostring (date);
		return;																	-- done
	end
																				-- here for gregorian calendar dates
	if 0 ~= input.day then
		date = string.format ('%s-%.2d-%.2d', input.year, tonumber(input.month), tonumber(input.day));	-- whole date
	elseif 0 ~= input.month then
		date = string.format ('%s-%.2d', input.year, tonumber(input.month));	-- year and month
	else
		date = string.format ('%s', input.year);								-- just year
	end

	if 0 ~= input.year2 then
		if 0 ~= input.day2 then
			date2 = string.format ('/%s-%.2d-%.2d', input.year2, tonumber(input.month2), tonumber(input.day2));		-- whole date
		elseif 0 ~= input.month2 then
			date2 = string.format ('/%s-%.2d', input.year2, tonumber(input.month2));	-- year and month
		else
			date2 = string.format ('/%s', input.year2);							-- just year
		end
	end
	
	tCOinS_date.rftdate = date .. date2;										-- date2 has the '/' separator
	return;
end


--[[--------------------------&lt; P A T T E R N S _ T &gt;----------------------------------------------------------

this is the list of patterns for date formats that this module recognizes.  Approximately the first half of these
patterns represent formats that might be reformatted into another format.  Those that might be reformatted have
'indicator' letters that identify the content of the matching capture: 'd' (day), 'm' (month), 'a' (anchor year),
'y' (year); second day, month, year have a '2' suffix.

These patterns are used for both date validation and for reformatting.  This table should not be moved to ~/Configuration
because changes to this table require changes to check_date() and to reformatter() and reformat_date()

]]

local patterns_t = {
	 																			-- year-initial numerical year-month-day
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'},					
																				-- month-initial: month day, year
	['Mdy'] = {'^(%D-) +([1-9]%d?), +((%d%d%d%d?)%a?)$', 'm', 'd', 'a', 'y'},
																				-- month-initial day range: month day–day, year; days are separated by endash
	['Md-dy'] = {'^(%D-) +([1-9]%d?)[%-–]([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'd2', 'a', 'y'},
																				-- day-initial: day month year
	['dMy'] = {'^([1-9]%d?) +(%D-) +((%d%d%d%d?)%a?)$', 'd', 'm', 'a', 'y'},
																				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed; not supported at en.wiki
	--	['yMd'] = {'^((%d%d%d%d?)%a?) +(%D-) +(%d%d?)$', 'a', 'y', 'm', 'd'},
																				-- day-range-initial: day–day month year; days are separated by endash
	['d-dMy'] = {'^([1-9]%d?)[%-–]([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'd2', 'm', 'a', 'y'},
																				-- day initial month-day-range: day month - day month year; uses spaced endash
	['dM-dMy'] = {'^([1-9]%d?) +(%D-) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'd2', 'm2', 'a', 'y'},
																				-- month initial month-day-range: month day – month day, year;  uses spaced endash
	['Md-Mdy'] = {'^(%D-) +([1-9]%d?) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$','m', 'd', 'm2', 'd2', 'a', 'y'},
																				-- day initial month-day-year-range: day month year - day month year; uses spaced endash
	['dMy-dMy'] = {'^([1-9]%d?) +(%D-) +(%d%d%d%d) +[%-–] +([1-9]%d?) +(%D-) +((%d%d%d%d)%a?)$', 'd', 'm', 'y', 'd2', 'm2', 'a', 'y2'},
																				-- month initial month-day-year-range: month day, year – month day, year;  uses spaced endash
	['Mdy-Mdy'] = {'^(%D-) +([1-9]%d?), +(%d%d%d%d) +[%-–] +(%D-) +([1-9]%d?), +((%d%d%d%d)%a?)$', 'm', 'd', 'y', 'm2', 'd2', 'a', 'y2'},

																				-- these date formats cannot be converted, per se, but month name can be rendered short or long
																				-- month/season year - month/season year; separated by spaced endash
	['My-My'] = {'^(%D-) +(%d%d%d%d) +[%-–] +(%D-) +((%d%d%d%d)%a?)$', 'm', 'y', 'm2', 'a', 'y2'},
																				-- month/season range year; months separated by endash
	['M-My'] = {'^(%D-)[%-–](%D-) +((%d%d%d%d)%a?)$', 'm', 'm2', 'a', 'y'},
																				-- month/season year or proper-name year; quarter year when First Quarter YYYY etc.
	['My'] = {'^([^%d–]-) +((%d%d%d%d)%a?)$', 'm', 'a', 'y'},					-- this way because endash is a member of %D; %D- will match January–March 2019 when it shouldn't

																				-- these date formats cannot be converted
	['Sy4-y2'] = {'^(%D-) +((%d%d)%d%d)[%-–]((%d%d)%a?)$'},						-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
	['Sy-y'] = {'^(%D-) +(%d%d%d%d)[%-–]((%d%d%d%d)%a?)$'},						-- special case Winter/Summer year-year; year separated with unspaced endash
	['y-y'] = {'^(%d%d%d%d?)[%-–]((%d%d%d%d?)%a?)$'},							-- year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
	['y4-y2'] = {'^((%d%d)%d%d)[%-–]((%d%d)%a?)$'},								-- year range: YYYY–YY; separated by unspaced endash
	['y'] = {'^((%d%d%d%d?)%a?)$'},												-- year; here accept either YYY or YYYY
	}


--[[--------------------------&lt; I S _ V A L I D _ E M B A R G O _ D A T E &gt;------------------------------------

returns true and date value if that value has proper dmy, mdy, ymd format.

returns false and 9999 (embargoed forever) when date value is not proper format; assumes that when |pmc-embargo-date= is
set, the editor intended to embargo a PMC but |pmc-embargo-date= does not hold a single date.

]]

local function is_valid_embargo_date (v)
	if v:match (patterns_t['ymd'][1]) or										-- ymd
		v:match (patterns_t['Mdy'][1]) or										-- dmy
		v:match (patterns_t['dMy'][1]) then										-- mdy
			return true, v;
	end
	return false, '9999';														-- if here not good date so return false and set embargo date to long time in future
end


--[[--------------------------&lt; C H E C K _ D A T E &gt;----------------------------------------------------------

Check date format to see that it is one of the formats approved by WP:DATESNO or WP:DATERANGE. Exception: only
allowed range separator is endash.  Additionally, check the date to see that it is a real date: no 31 in 30-day
months; no 29 February when not a leap year.  Months, both long-form and three character abbreviations, and seasons
must be spelled correctly.  Future years beyond next year are not allowed.

If the date fails the format tests, this function returns false and does not return values for anchor_year and
COinS_date.  When this happens, the date parameter is (DEBUG: not?) used in the COinS metadata and the CITEREF identifier gets
its year from the year parameter if present otherwise CITEREF does not get a date value.

Inputs:
	date_string - date string from date-holding parameters (date, year, publication-date, access-date, pmc-embargo-date, archive-date, lay-date)

Returns:
	false if date string is not a real date; else
	true, anchor_year, COinS_date
		anchor_year can be used in CITEREF anchors
		COinS_date is ISO 8601 format date; see make_COInS_date()

]]

local function check_date (date_string, param, tCOinS_date)
	local year;																	-- assume that year2, months, and days are not used;
	local year2 = 0;															-- second year in a year range
	local month = 0;
	local month2 = 0;															-- second month in a month range
	local day = 0;
	local day2 = 0;																-- second day in a day range
	local anchor_year;
	local coins_date;

	if date_string:match (patterns_t['ymd'][1]) then							-- year-initial numerical year month day format
		year, month, day = date_string:match (patterns_t['ymd'][1]);
		if 12 &lt; tonumber(month) or 1 &gt; tonumber(month) or 1582 &gt; tonumber(year) or 0 == tonumber(day) then return false; end	-- month or day number not valid or not Gregorian calendar
		anchor_year = year;
	
	elseif mw.ustring.match(date_string, patterns_t['Mdy'][1]) then				-- month-initial: month day, year
		month, day, anchor_year, year = mw.ustring.match(date_string, patterns_t['Mdy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
				
	elseif mw.ustring.match(date_string, patterns_t['Md-dy'][1]) then			-- month-initial day range: month day–day, year; days are separated by endash
		month, day, day2, anchor_year, year = mw.ustring.match(date_string, patterns_t['Md-dy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2=month;															-- for metadata
		year2 = year;

	elseif mw.ustring.match(date_string, patterns_t['dMy'][1]) then				-- day-initial: day month year
		day, month, anchor_year, year = mw.ustring.match(date_string, patterns_t['dMy'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months

--[[ NOT supported at en.wiki
	elseif mw.ustring.match(date_string, patterns_t['yMd'][1]) then				-- year-initial: year month day; day: 1 or 2 two digits, leading zero allowed
		anchor_year, year, month, day = mw.ustring.match(date_string, patterns_t['yMd'][1]);
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
-- end NOT supported at en.wiki ]]

	elseif mw.ustring.match(date_string, patterns_t['d-dMy'][1]) then			-- day-range-initial: day–day month year; days are separated by endash
		day, day2, month, anchor_year, year = mw.ustring.match(date_string, patterns_t['d-dMy'][1]);
		if tonumber(day) &gt;= tonumber(day2) then return false; end				-- date range order is left to right: earlier to later; dates may not be the same;
		month = get_month_number (month);
		if 0 == month then return false; end									-- return false if month text isn't one of the twelve months
		month2 = month;															-- for metadata
		year2 = year;

	elseif mw.ustring.match(date_string, patterns_t['dM-dMy'][1]) then			-- day initial month-day-range: day month - day month year; uses spaced endash
		day, month, day2, month2, anchor_year, year = mw.ustring.match(date_string, patterns_t['dM-dMy'][1]);
		if (not is_valid_month_season_range(month, month2)) or not is_valid_year(year) then return false; end	-- date range order is left to right: earlier to later;
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2 = year;

	elseif mw.ustring.match(date_string, patterns_t['Md-Mdy'][1]) then			-- month initial month-day-range: month day – month day, year; uses spaced endash
		month, day, month2, day2, anchor_year, year = mw.ustring.match(date_string, patterns_t['Md-Mdy'][1]);
		if (not is_valid_month_season_range(month, month2, param)) or not is_valid_year(year) then return false; end
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		year2 = year;

	elseif mw.ustring.match(date_string, patterns_t['dMy-dMy'][1]) then			-- day initial month-day-year-range: day month year - day month year; uses spaced endash
		day, month, year, day2, month2, anchor_year, year2 = mw.ustring.match(date_string, patterns_t['dMy-dMy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number (month2);
		if 0 == month or 0 == month2 then return false; end						-- both must be valid

	elseif mw.ustring.match(date_string, patterns_t['Mdy-Mdy'][1]) then			-- month initial month-day-year-range: month day, year – month day, year; uses spaced endash
		month, day, year, month2, day2, anchor_year, year2 = mw.ustring.match(date_string, patterns_t['Mdy-Mdy'][1]);
		if tonumber(year2) &lt;= tonumber(year) then return false; end				-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) or not is_valid_month_range_style(month, month2) then return false; end		-- year2 no more than one year in the future; months same style
		month = get_month_number (month);										-- for metadata
		month2 = get_month_number(month2);
		if 0 == month or 0 == month2 then return false; end						-- both must be valid

	elseif mw.ustring.match(date_string, patterns_t['Sy4-y2'][1]) then			-- special case Winter/Summer year-year (YYYY-YY); year separated with unspaced endash
		local century;
		month, year, century, anchor_year, year2 = mw.ustring.match(date_string, patterns_t['Sy4-y2'][1]);
		if 'Winter' ~= month and 'Summer' ~= month then return false end;		-- 'month' can only be Winter or Summer
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor_year from both years
		year2 = century..year2;													-- add the century to year2 for comparisons
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		month = get_season_number(month, param);

	elseif mw.ustring.match(date_string, patterns_t['Sy-y'][1]) then			-- special case Winter/Summer year-year; year separated with unspaced endash
		month, year, anchor_year, year2 = mw.ustring.match(date_string, patterns_t['Sy-y'][1]);
		month = get_season_number (month, param);								-- &lt;month&gt; can only be winter or summer; also for metadata
		if (month ~= cfg.date_names['en'].season['Winter']) and (month ~= cfg.date_names['en'].season['Summer']) then
			return false;														-- not Summer or Winter; abandon
		end
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor_year from both years
		if 1 ~= tonumber(year2) - tonumber(year) then return false; end			-- must be sequential years, left to right, earlier to later
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, patterns_t['My-My'][1]) then			-- month/season year - month/season year; separated by spaced endash
		month, year, month2, anchor_year, year2 = mw.ustring.match(date_string, patterns_t['My-My'][1]);
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor_year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year
		if 0 ~= get_month_number(month) and 0 ~= get_month_number(month2) and is_valid_month_range_style(month, month2) then 	-- both must be month year, same month style
			month = get_month_number(month);
			month2 = get_month_number(month2);
		elseif 0 ~= get_season_number(month, param) and 0 ~= get_season_number(month2, param) then	-- both must be season year, not mixed
			month = get_season_number(month, param);
			month2 = get_season_number(month2, param);
		else
			 return false;
		end

	elseif mw.ustring.match(date_string, patterns_t['M-My'][1]) then			-- month/season range year; months separated by endash 
		month, month2, anchor_year, year = mw.ustring.match(date_string, patterns_t['M-My'][1]);
		if (not is_valid_month_season_range(month, month2, param)) or (not is_valid_year(year)) then return false; end
		if 0 ~= get_month_number(month) then									-- determined to be a valid range so just check this one to know if month or season
			month = get_month_number(month);
			month2 = get_month_number(month2);
			if 0 == month or 0 == month2 then return false; end
		else
			month = get_season_number(month, param);
			month2 = get_season_number(month2, param);
		end
		year2 = year;
		
	elseif mw.ustring.match(date_string, patterns_t['My'][1]) then				-- month/season/quarter/proper-name year
		month, anchor_year, year = mw.ustring.match(date_string, patterns_t['My'][1]);
		if not is_valid_year(year) then return false; end
		month = get_element_number(month, param);								-- get month season quarter proper-name number or nil
		if not month then return false; end										-- not valid whatever it is

	elseif mw.ustring.match(date_string, patterns_t['y-y'][1]) then				-- Year range: YYY-YYY or YYY-YYYY or YYYY–YYYY; separated by unspaced endash; 100-9999
		year, anchor_year, year2 = mw.ustring.match(date_string, patterns_t['y-y'][1]);
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor year from both years
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

	elseif mw.ustring.match(date_string, patterns_t['y4-y2'][1]) then			-- Year range: YYYY–YY; separated by unspaced endash
		local century;
		year, century, anchor_year, year2 = mw.ustring.match(date_string, patterns_t['y4-y2'][1]);
		anchor_year = year .. '–' .. anchor_year;								-- assemble anchor year from both years

		if 13 &gt; tonumber(year2) then return false; end							-- don't allow 2003-05 which might be May 2003
		year2 = century .. year2;												-- add the century to year2 for comparisons
		if tonumber(year) &gt;= tonumber(year2) then return false; end				-- left to right, earlier to later, not the same
		if not is_valid_year(year2) then return false; end						-- no year farther in the future than next year

		if in_array (param, {'date', 'publication-date', 'year'}) then			-- here when 'valid' abbreviated year range; if one of these parameters
			add_prop_cat ('year-range-abbreviated');							-- add properties cat
		end

	elseif mw.ustring.match(date_string, patterns_t['y'][1]) then				-- year; here accept either YYY or YYYY
		anchor_year, year = mw.ustring.match(date_string, patterns_t['y'][1]);
		if false == is_valid_year(year) then
			return false;
		end

	else
		return false;															-- date format not one of the MOS:DATE approved formats
	end

	if param ~= 'date' then														-- CITEREF disambiguation only allowed in |date=; |year= &amp; |publication-date= promote to date
		if anchor_year:match ('%l$') then
			return false;
		end
	end

	if 'access-date' == param then												-- test access-date here because we have numerical date parts
		if 0 ~= year and 0 ~= month and 0 ~= day and 							-- all parts of a single date required
			0 == year2 and 0 == month2 and 0 == day2 then						-- none of these; access-date must not be a range
				if not is_valid_accessdate(year .. '-' .. month .. '-' .. day) then	
					return false;												-- return false when access-date out of bounds
				end
		else
			return false;														-- return false when access-date is a range of two dates
		end
	end

	if 'archive-date' == param then												-- test archive-date here because we have numerical date parts
		if not (0 ~= year and 0 ~= month and 0 ~= day and						-- all parts of a single date required
			0 == year2 and 0 == month2 and 0 == day2) then						-- none of these; archive-date must not be a range
				return false;													-- return false when archive-date is a range of two dates
		end
	end

	local result=true;															-- check whole dates for validity; assume true because not all dates will go through this test
	if 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 == day2 then		-- YMD (simple whole date)
		result = is_valid_date (year, month, day, param);						-- &lt;param&gt; for |pmc-embargo-date=

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 == month2 and 0 ~= day2 then	-- YMD-d (day range)
		result = is_valid_date (year, month, day);
		result = result and is_valid_date (year, month, day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 == year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-md (day month range)
		result = is_valid_date (year, month, day);
		result = result and is_valid_date (year, month2, day2);

	elseif 0 ~= year and 0 ~= month and 0 ~= day and 0 ~= year2 and 0 ~= month2 and 0 ~= day2 then	-- YMD-ymd (day month year range)
		result = is_valid_date(year, month, day);
		result = result and is_valid_date(year2, month2, day2);
	end
	
	if false == result then return false; end

	if nil ~= tCOinS_date then													-- this table only passed into this function when testing |date= parameter values
		make_COinS_date ({year = year, month = month, day = day, year2 = year2, month2 = month2, day2 = day2}, tCOinS_date);	-- make an ISO 8601 date string for COinS
	end
	
	return true, anchor_year;													-- format is good and date string represents a real date
end	


--[[--------------------------&lt; D A T E S &gt;--------------------------------------------------------------------

Cycle the date-holding parameters in passed table date_parameters_list through check_date() to check compliance with MOS:DATE. For all valid dates, check_date() returns
true. The |date= parameter test is unique, it is the only date holding parameter from which values for anchor_year (used in CITEREF identifiers) and COinS_date (used in
the COinS metadata) are derived.  The |date= parameter is the only date-holding parameter that is allowed to contain the no-date keywords &quot;n.d.&quot; or &quot;nd&quot; (without quotes).

Unlike most error messages created in this module, only one error message is created by this function. Because all of the date holding parameters are processed serially,
parameters with errors are added to the &lt;error_list&gt; sequence table as the dates are tested.

]]

local function dates(date_parameters_list, tCOinS_date, error_list)
	local anchor_year;															-- will return as nil if the date being tested is not |date=
	local COinS_date;															-- will return as nil if the date being tested is not |date=
	local embargo_date;															-- if embargo date is a good dmy, mdy, ymd date then holds original value else reset to 9999
	local good_date = false;

	for k, v in pairs(date_parameters_list) do									-- for each date-holding parameter in the list
		if is_set(v.val) then													-- if the parameter has a value
			v.val = mw.ustring.gsub(v.val, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9
			if v.val:match(&quot;^c%. [1-9]%d%d%d?%a?$&quot;) then						-- special case for c. year or with or without CITEREF disambiguator - only |date= and |year=
				local year = v.val:match(&quot;c%. ([1-9]%d%d%d?)%a?&quot;);				-- get the year portion so it can be tested
				if 'date' == k then
					anchor_year, COinS_date = v.val:match(&quot;((c%. [1-9]%d%d%d?)%a?)&quot;);	-- anchor year and COinS_date only from |date= parameter
					good_date = is_valid_year(year);
				elseif 'year' == k then
					good_date = is_valid_year(year);
				end
			elseif 'date' == k then												-- if the parameter is |date=
				if v.val:match(&quot;^n%.d%.%a?$&quot;) then -- ToDo: I18N								-- if |date=n.d. with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((n%.d%.)%a?)&quot;); -- ToDo: I18N	-- &quot;n.d.&quot;; no error when date parameter is set to no date
				elseif v.val:match(&quot;^nd%a?$&quot;) then -- ToDo: I18N								-- if |date=nd with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((nd)%a?)&quot;); -- ToDo: I18N	-- &quot;nd&quot;;	no error when date parameter is set to no date
				else
					good_date, anchor_year, COinS_date = check_date (v.val, k, tCOinS_date);	-- go test the date
				end
			elseif 'year' == k then												-- if the parameter is |year= it should hold only a year value
				if v.val:match(&quot;^[1-9]%d%d%d?%a?$&quot;) then						-- if |year = 3 or 4 digits only with or without a CITEREF disambiguator
					good_date, anchor_year, COinS_date = true, v.val:match(&quot;((%d+)%a?)&quot;);
				end
			elseif 'pmc-embargo-date' == k then									-- if the parameter is |pmc-embargo-date=
				good_date = check_date (v.val, k);								-- go test the date
				if true == good_date then										-- if the date is a valid date
					good_date, embargo_date = is_valid_embargo_date (v.val);	-- is |pmc-embargo-date= date a single dmy, mdy, or ymd formatted date? yes: returns embargo date; no: returns 9999
				end
			else																-- any other date-holding parameter
				good_date = check_date (v.val, k);								-- go test the date
			end
			if false == good_date then											-- assemble one error message so we don't add the tracking category multiple times
				table.insert (error_list, wrap_style ('parameter', v.name));	-- make parameter name suitable for error message list
			end
		end
	end
	return anchor_year, embargo_date;											-- and done
end


--[[--------------------------&lt; Y E A R _ C H E C K &gt;----------------------------------------------------------

Temporary function to test |year= for acceptable values:
	YYY, YYYY, year-only ranges, their circa forms, with or without CITEREF disambiguators.

When |year= holds some form of date that is not one of these year-only dates, emit a maintenance message.

This function necessary because many non-cs1|2 templates have a |year= parameter so cirrus searches are more-or-
less useless

]]

local function year_check (year)
	year = year:gsub ('c%. *', '');												-- remove circa annotation (if present) before testing &lt;year&gt;
	
	for _, index in ipairs ({'y-y', 'y4-y2', 'y'}) do							-- spin through these indexes into patterns_t
		if mw.ustring.match (year, patterns_t[index][1]) then
			return;																-- if a match then |year= holds a valid 'year'
		end
	end

	set_message ('maint_year');													-- if here, |year= value is not an accepted value; add a maint cat
end


--[[--------------------------&lt; Y E A R _ D A T E _ C H E C K &gt;------------------------------------------------

Compare the value provided in |year= with the year value(s) provided in |date=.  This function sets a local numeric value:
	0 - year value does not match the year value in date
	1 - (default) year value matches the year value in date or one of the year values when date contains two years
	2 - year value matches the year value in date when date is in the form YYYY-MM-DD and year is disambiguated (|year=YYYYx)

the numeric value in &lt;result&gt; determines the 'output' if any from this function:
	0 – adds error message to error_list sequence table
	1 – adds maint cat
	2 – does nothing

]]

local function year_date_check (year_string, year_origin, date_string, date_origin, error_list)
	local year;
	local date1;
	local date2;
	local result = 1;															-- result of the test; assume that the test passes

	year = year_string:match ('(%d%d%d%d?)');

	if date_string:match ('%d%d%d%d%-%d%d%-%d%d') and year_string:match ('%d%d%d%d%a') then	--special case where both date and year are required YYYY-MM-DD and YYYYx
		date1 = date_string:match ('(%d%d%d%d)');
		year = year_string:match ('(%d%d%d%d)');
		if year ~= date1 then
			result = 0;															-- years don't match
		else
			result = 2;															-- years match; but because disambiguated, don't add to maint cat
		end
		
	elseif date_string:match (&quot;%d%d%d%d?.-%d%d%d%d?&quot;) then						-- any of the standard range formats of date with two three- or four-digit years
		date1, date2 = date_string:match (&quot;(%d%d%d%d?).-(%d%d%d%d?)&quot;);
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif mw.ustring.match(date_string, &quot;%d%d%d%d[%-–]%d%d&quot;) then				-- YYYY-YY date ranges
		local century;
		date1, century, date2 = mw.ustring.match(date_string, &quot;((%d%d)%d%d)[%-–]+(%d%d)&quot;);
		date2 = century..date2;													-- convert YY to YYYY
		if year ~= date1 and year ~= date2 then
			result = 0;
		end

	elseif date_string:match (&quot;%d%d%d%d?&quot;) then									-- any of the standard formats of date with one year
		date1 = date_string:match (&quot;(%d%d%d%d?)&quot;);
		if year ~= date1 then
			result = 0;
		end
	else																		-- should never get here; this function called only when no other date errors
		result = 0;																-- no recognizable year in date
	end

	if 0 == result then															-- year / date mismatch
		table.insert (error_list, substitute (cfg.messages['mismatch'], {year_origin, date_origin}));	-- add error message to error_list sequence table
	elseif 1 == result then														-- redundant year / date
		set_message ('maint_date_year');										-- add a maint cat
	end
end


--[[--------------------------&lt; R E F O R M A T T E R &gt;--------------------------------------------------------

reformat 'date' into new format specified by format_param if pattern_idx (the current format of 'date') can be
reformatted.  Does the grunt work for reformat_dates().

The table re_formats maps pattern_idx (current format) and format_param (desired format) to a table that holds:
	format string used by string.format()
	identifier letters ('d', 'm', 'y', 'd2', 'm2', 'y2') that serve as indexes into a table t{} that holds captures
		from mw.ustring.match() for the various date parts specified by  patterns_t[pattern_idx][1]

Items in patterns_t{} have the general form:
	['ymd'] = {'^(%d%d%d%d)%-(%d%d)%-(%d%d)$', 'y', 'm', 'd'}, where:
		['ymd'] is pattern_idx
		patterns_t['ymd'][1] is the match pattern with captures for mw.ustring.match()
		patterns_t['ymd'][2] is an indicator letter identifying the content of the first capture
		patterns_t['ymd'][3] ... the second capture etc.

when a pattern matches a date, the captures are loaded into table t{} in capture order using the idemtifier
characters as indexes into t{}  For the above, a ymd date is in t{} as:
	t.y = first capture (year), t.m = second capture (month), t.d = third capture (day)

To reformat, this function is called with the pattern_idx that matches the current format of the date and with
format_param set to the desired format.  This function loads table t{} as described and then calls string.format()
with the format string specified by re_format[pattern_idx][format_param][1] using values taken from t{} according
to the capture identifier letters specified by patterns_t[pattern_idx][format_param][n] where n is 2..

]]

local re_formats = {
	['ymd'] = {																	-- date format is ymd; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
	--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},								-- |df=yMd; not supported at en.wiki
		},
	['Mdy'] = {																	-- date format is Mdy; reformat to:
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- for long/short reformatting
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- |df=dmy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
	--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},								-- |df=yMd; not supported at en.wiki
		},
	['dMy'] = {																	-- date format is dMy; reformat to:
		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},									-- for long/short reformatting
		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},									-- |df=mdy
		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},									-- |df=ymd
	--		['yMd'] = {'%s %s %s', 'y', 'm', 'd'},								-- |df=yMd; not supported at en.wiki
		},
	['Md-dy'] = {																-- date format is Md-dy; reformat to:
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- for long/short reformatting
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- |df=dmy -&gt; d-dMy 
		},
	['d-dMy'] = {																-- date format is d-d&gt;y; reformat to:
		['dmy'] = {'%s–%s %s %s', 'd', 'd2', 'm', 'y'},							-- for long/short reformatting
		['mdy'] = {'%s %s–%s, %s', 'm', 'd', 'd2', 'y'},						-- |df=mdy -&gt; Md-dy 
		},
	['dM-dMy'] = {																-- date format is dM-dMy; reformat to:
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- for long/short reformatting
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd', 'm2', 'd2', 'y'},				-- |df=mdy -&gt; Md-Mdy 
		},
	['Md-Mdy'] = {																-- date format is Md-Mdy; reformat to:
		['mdy'] = {'%s %s – %s %s, %s', 'm', 'd',  'm2', 'd2', 'y'},			-- for long/short reformatting
		['dmy'] = {'%s %s – %s %s %s', 'd', 'm', 'd2', 'm2', 'y'},				-- |df=dmy -&gt; dM-dMy 
		},
	['dMy-dMy'] = {																-- date format is dMy-dMy; reformat to:
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- for long/short reformatting
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- |df=mdy -&gt; Mdy-Mdy 
		},
	['Mdy-Mdy'] = {																-- date format is Mdy-Mdy; reformat to:
		['mdy'] = {'%s %s, %s – %s %s, %s', 'm', 'd', 'y', 'm2', 'd2', 'y2'},	-- for long/short reformatting
		['dmy'] = {'%s %s %s – %s %s %s', 'd', 'm', 'y', 'd2', 'm2', 'y2'},		-- |df=dmy -&gt; dMy-dMy 
		},
	['My-My'] = {																-- these for long/short reformatting
		['any'] = {'%s %s – %s %s', 'm', 'y', 'm2', 'y2'},						-- dmy/mdy agnostic
		},
	['M-My'] = {																-- these for long/short reformatting
		['any'] = {'%s–%s %s', 'm', 'm2', 'y'},									-- dmy/mdy agnostic
		},
	['My'] = {																	-- these for long/short reformatting
		['any'] = {'%s %s', 'm', 'y'},											-- dmy/mdy agnostic
		},
	--	['yMd'] = {																-- not supported at en.wiki
	--		['mdy'] = {'%s %s, %s', 'm', 'd', 'y'},								-- |df=mdy
	--		['dmy'] = {'%s %s %s', 'd', 'm', 'y'},								-- |df=dmy
	--		['ymd'] = {'%s-%s-%s', 'y', 'm', 'd'},								-- |df=ymd
	--		},
	}


local function reformatter (date, pattern_idx, format_param, mon_len)
	if not in_array (pattern_idx, {'ymd', 'Mdy', 'Md-dy', 'dMy', 'yMd', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- not in this set of date format patterns_t then not a reformattable date
	end
	
	if 'ymd' == format_param and in_array (pattern_idx, {'ymd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy', 'My-My', 'M-My', 'My'}) then
		return;																	-- ymd date ranges not supported at en.wiki; no point in reformatting ymd to ymd
	end

	if in_array (pattern_idx, {'My', 'M-My', 'My-My'}) then						-- these are not dmy/mdy so can't be 'reformatted' into either
		format_param = 'any';													-- so format-agnostic 
	end

																				-- yMd is not supported at en.wiki; when yMd is supported at your wiki, uncomment the next line
	--	if 'yMd' == format_param and in_array (pattern_idx, {'yMd', 'Md-dy', 'd-dMy', 'dM-dMy', 'Md-Mdy', 'dMy-dMy', 'Mdy-Mdy'}) then	-- these formats not convertable; yMd not supported at en.wiki
	if 'yMd' == format_param then												-- yMd not supported at en.wiki; when yMd is supported at your wiki, remove or comment-out this line
		return;																	-- not a reformattable date
	end
	
	local c1, c2, c3, c4, c5, c6, c7;											-- these hold the captures specified in patterns_t[pattern_idx][1]
	c1, c2, c3, c4, c5, c6, c7 = mw.ustring.match (date, patterns_t[pattern_idx][1]);	-- get the captures

	local t = {																	-- table that holds k/v pairs of date parts from the captures and patterns_t[pattern_idx][2..]
		[patterns_t[pattern_idx][2]] = c1;										-- at minimum there is always one capture with a matching indicator letter
		[patterns_t[pattern_idx][3] or 'x'] = c2;								-- patterns_t can have a variable number of captures; each capture requires an indicator letter;
		[patterns_t[pattern_idx][4] or 'x'] = c3;								-- where there is no capture, there is no indicator letter so n in patterns_t[pattern_idx][n] will be nil;
		[patterns_t[pattern_idx][5] or 'x'] = c4;								-- the 'x' here spoofs an indicator letter to prevent 'table index is nil' error
		[patterns_t[pattern_idx][6] or 'x'] = c5;
		[patterns_t[pattern_idx][7] or 'x'] = c6;
		[patterns_t[pattern_idx][8] or 'x'] = c7;
		};

	if t.a then																	-- if this date has an anchor year capture (all convertable date formats except ymd)
		if t.y2 then															-- for year range date formats														
			t.y2 = t.a;															-- use the anchor year capture when reassembling the date
		else																	-- here for single date formats (except ymd)
			t.y = t.a;															-- use the anchor year capture when reassembling the date
		end
	end

	if tonumber(t.m) then														-- if raw month is a number (converting from ymd)
		if 's' == mon_len then													-- if we are to use abbreviated month names
			t.m = cfg.date_names['inv_local_short'][tonumber(t.m)];					-- convert it to a month name
		else
			t.m = cfg.date_names['inv_local_long'][tonumber(t.m)];					-- convert it to a month name
		end
		t.d = t.d:gsub ('0(%d)', '%1');											-- strip leading '0' from day if present
	elseif 'ymd' == format_param then											-- when converting to ymd
		t.y = t.y:gsub ('%a', '');												-- strip CITREF disambiguator if present; anchor year already known so process can proceed; TODO: maint message?
		if 1582 &gt; tonumber (t.y) then											-- ymd format dates not allowed before 1582
			return;
		end
		t.m = string.format ('%02d', get_month_number (t.m));					-- make sure that month and day are two digits
		t.d = string.format ('%02d', t.d);
	elseif mon_len then															-- if mon_len is set to either 'short' or 'long'
		for _, mon in ipairs ({'m', 'm2'}) do									-- because there can be two month names, check both 
			if t[mon] then
				t[mon] = get_month_number (t[mon]);								-- get the month number for this month (is length agnostic)
				if 0 == t[mon] then return; end									-- seasons and named dates can't be converted
				t[mon] = (('s' == mon_len) and cfg.date_names['inv_local_short'][t[mon]]) or cfg.date_names['inv_local_long'][t[mon]];	-- fetch month name according to length
			end
		end
	end

	local new_date = string.format (re_formats[pattern_idx][format_param][1],	-- format string
		t[re_formats[pattern_idx][format_param][2]],							-- named captures from t{}
		t[re_formats[pattern_idx][format_param][3]],
		t[re_formats[pattern_idx][format_param][4]],
		t[re_formats[pattern_idx][format_param][5]],
		t[re_formats[pattern_idx][format_param][6]],
		t[re_formats[pattern_idx][format_param][7]],
		t[re_formats[pattern_idx][format_param][8]]
		);

	return new_date;
end


--[[-------------------------&lt; R E F O R M A T _ D A T E S &gt;--------------------------------------------------

Reformats existing dates into the format specified by format.

format is one of several manual keywords: dmy, dmy-all, mdy, mdy-all, ymd, ymd-all.  The -all version includes
access- and archive-dates; otherwise these dates are not reformatted.

This function allows automatic date formatting.  In ~/Configuration, the article source is searched for one of
the {{use xxx dates}} templates.  If found, xxx becomes the global date format as xxx-all.  If |cs1-dates= in
{{use xxx dates}} has legitimate value then that value determines how cs1|2 dates will be rendered.  Legitimate
values for |cs1-dates= are:
	l - all dates are rendered with long month names
	ls - publication dates use long month names; access-/archive-dates use abbreviated month names
	ly - publication dates use long month names; access-/archive-dates rendered in ymd format
	s - all dates are rendered with abbreviated (short) month names
	sy - publication dates use abbreviated month names; access-/archive-dates rendered in ymd format
	y - all dates are rendered in ymd format

the format argument for automatic date formatting will be the format specified by {{use xxx dates}} with the
value supplied by |cs1-dates so one of: xxx-l, xxx-ls, xxx-ly, xxx-s, xxx-sy, xxx-y, or simply xxx (|cs1-dates=
empty, omitted, or invalid) where xxx shall be either of dmy or mdy.

dates are extracted from date_parameters_list, reformatted (if appropriate), and then written back into the
list in the new format.  Dates in date_parameters_list are presumed here to be valid (no errors).  This function
returns true when a date has been reformatted, false else.  Actual reformatting is done by reformatter().

]]

local function reformat_dates (date_parameters_list, format)
	local all = false;															-- set to false to skip access- and archive-dates
	local len_p = 'l';															-- default publication date length shall be long
	local len_a = 'l';															-- default access-/archive-date length shall be long
	local result = false;
	local new_date;																
	
	if format:match('%a+%-all') then											-- manual df keyword; auto df keyword when length not specified in {{use xxx dates}}; 
		format = format:match('(%a+)%-all');									-- extract the format
		all = true;																-- all dates are long format dates because this keyword doesn't specify length
	elseif format:match('%a+%-[lsy][sy]?') then									-- auto df keywords; internal only
		all = true;																-- auto df applies to all dates; use length specified by capture len_p for all dates
		format, len_p, len_a = format:match('(%a+)%-([lsy])([sy]?)');			-- extract the format and length keywords
		if 'y' == len_p then													-- because allowed by MOS:DATEUNIFY (sort of) range dates and My dates not reformatted
			format = 'ymd';														-- override {{use xxx dates}}
		elseif (not is_set(len_a)) or (len_p == len_a) then						-- no access-/archive-date length specified or same length as publication dates then
			len_a = len_p;														-- in case len_a not set
		end
	end																			-- else only publication dates and they are long

	for param_name, param_val in pairs (date_parameters_list) do				-- for each date-holding parameter in the list
		if is_set (param_val.val) then											-- if the parameter has a value
			if not (not all and in_array (param_name, {'access-date', 'archive-date'})) then	-- skip access- or archive-date unless format is xxx-all; yeah, ugly; TODO: find a better way
				for pattern_idx, pattern in pairs (patterns_t) do
					if mw.ustring.match (param_val.val, pattern[1]) then
						if all and in_array (param_name, {'access-date', 'archive-date'}) then	-- if this date is an access- or archive-date
							new_date = reformatter (param_val.val, pattern_idx, (('y' == len_a) and 'ymd') or format, len_a);	-- choose ymd or dmy/mdy according to len_a setting
						else													-- all other dates
							new_date = reformatter (param_val.val, pattern_idx, format, len_p);
						end
						
						if new_date then										-- set when date was reformatted
							date_parameters_list[param_name].val = new_date;	-- update date in date list
							result = true;										-- and announce that changes have been made
							break;
						end
					end	-- if
				end		-- for
			end			-- if
		end				-- if
	end					-- for
	return result;																-- declare boolean result and done
end


--[[--------------------------&lt; D A T E _ H Y P H E N _ T O _ D A S H &gt;----------------------------------------

Loops through the list of date-holding parameters and converts any hyphen to an ndash.  Not called if the cs1|2
template has any date errors.

Modifies the date_parameters_list and returns true if hyphens are replaced, else returns false.

]]

local function date_hyphen_to_dash (date_parameters_list)
	local result = false;
	local n;
	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set (param_val.val) and
			not mw.ustring.match (param_val.val, patterns_t.ymd[1]) then		-- for those that are not ymd dates (ustring because here digits may not be Western)
				param_val.val, n = param_val.val:gsub ('%-', '–');				-- replace any hyphen with ndash
				if 0 ~= n then
					date_parameters_list[param_name].val = param_val.val;		-- update the list
					result = true;
				end
		end
	end
	return result;																-- so we know if any hyphens were replaced
end


--[[-------------------------&lt; D A T E _ N A M E _ X L A T E &gt;------------------------------------------------

Attempts to translate English date names to local-language date names using names supplied by MediaWiki's
date parser function.  This is simple name-for-name replacement and may not work for all languages.

if xlat_dig is true, this function will also translate Western (English) digits to the local language's digits.
This will also translate ymd dates.

]]

local function date_name_xlate (date_parameters_list, xlt_dig)
	local xlate;
	local mode;																	-- long or short month names
	local modified = false;
	local date;
	
	local sources_t = {
		{cfg.date_names.en.long, cfg.date_names.inv_local_long},				-- for translating long English month names to long local month names
		{cfg.date_names.en.short, cfg.date_names.inv_local_short},				-- short month names
		{cfg.date_names.en.quarter, cfg.date_names.inv_local_quarter},			-- quarter date names
		{cfg.date_names.en.season, cfg.date_names.inv_local_season},			-- season date nam
		{cfg.date_names.en.named, cfg.date_names.inv_local_named},				-- named dates
		}

	local function is_xlateable (month)											-- local function to get local date name that replaces existing English-language date name
		for _, date_names_t in ipairs (sources_t) do							-- for each sequence table in date_names_t
			if date_names_t[1][month] then										-- if date name is English month (long or short), quarter, season or named and
				if date_names_t[2][date_names_t[1][month]] then					-- if there is a matching local date name
					return date_names_t[2][date_names_t[1][month]];				-- return the local date name
				end
			end
		end
	end

	for param_name, param_val in pairs(date_parameters_list) do					-- for each date-holding parameter in the list
		if is_set(param_val.val) then											-- if the parameter has a value
			date = param_val.val;
			for month in mw.ustring.gmatch (date, '[%a ]+') do					-- iterate through all date names in the date (single date or date range)
				month = mw.text.trim (month);									-- this because quarterly dates contain whitespace
				xlate = is_xlateable (month);									-- get translate &lt;month&gt;; returns translation or nil
				
				if xlate then		
					date = mw.ustring.gsub (date, month, xlate);				-- replace the English with the translation
					date_parameters_list[param_name].val = date;				-- save the translated date
					modified = true;
				end
			end

			if xlt_dig then														-- shall we also translate digits?
				date = date:gsub ('%d', cfg.date_names.xlate_digits);			-- translate digits from Western to 'local digits'
				date_parameters_list[param_name].val = date;					-- save the translated date
				modified = true;
			end
		end
	end
	
	return modified;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	add_prop_cat = utilities_page_ptr.add_prop_cat ;							-- import functions from selected Module:Citation/CS1/Utilities module
	is_set = utilities_page_ptr.is_set;
	in_array = utilities_page_ptr.in_array;
	set_message = utilities_page_ptr.set_message;
	substitute = utilities_page_ptr.substitute;
	wrap_style = utilities_page_ptr.wrap_style;

	cfg = cfg_table_ptr;														-- import tables from selected Module:Citation/CS1/Configuration
end


--[[--------------------------&lt; A R C H I V E _ D A T E _ C H E C K &gt;------------------------------------------

Compare value in |archive-date= with the timestamp in Wayback machine urls.  Emits an error message with suggested
date from the |archive-url= timestamp in an appropriate format when the value in |archive-date= does not match
the timestamp.

this function never called when any date in a cs1|2 template has errors

error message suggests new |archive-date= value in an appropriate format specified by &lt;df&gt;.  &lt;df&gt; is either 
|df= or cfg.global_df in that order.  If &lt;df&gt; is nil, suggested date has format from |archive-date=.  There is
a caveat: when |df=dmy or |df=mdy, the reformatter leaves |access-date= and |archive-date= formats as they are.
The error message suggested date is passed to the formatter as YYYY-MM-DD so when |df=dmy or |df=mdy, the format
is not changed.

]]

local function archive_date_check (archive_date, archive_url_timestamp, df)
	local archive_date_format = 'dmy-y';										-- holds the date format of date in |archive-date; default to ymd; 'dmy' used here to spoof reformat_dates() 
	
	for _, v_t in ipairs ({{'dMy', 'dmy-all'}, {'Mdy', 'mdy-all'}}) do			-- is |archive-date= format dmy or mdy?
		if archive_date:match (patterns_t[v_t[1]][1]) then						-- does the pattern match?
			archive_date_format = cfg.keywords_xlate[v_t[2]];					-- get appropriate |df= supported keyword from the i18n translator table
			break;
		end
	end
	
	local dates_t = {};
	dates_t['archive-date'] = {val=archive_date, name=''};						-- setup to call reformat_dates(); never called when errors so &lt;name&gt; unset as not needed
	reformat_dates (dates_t, 'dmy-y');											-- reformat |archive-date= to ymd; 'dmy' used here to spoof reformat_dates()
	local archive_url_date = archive_url_timestamp:gsub ('(%d%d%d%d)(%d%d)(%d%d)%d*', '%1-%2-%3');	-- make ymd format date from timestamp

	if dates_t['archive-date'].val == archive_url_date then						-- are the two dates the same
		return;																	-- yes, done
	else
		dates_t['archive-date'] = {val=archive_url_date, name=''};				-- setup to call reformat_dates() with the timestamp date
		reformat_dates (dates_t, df or archive_date_format);					-- reformat timestamp to format specified by &lt;df&gt; or format used in |archive-date= 
		archive_url_date = dates_t['archive-date'].val;
		set_message ('err_archive_date_url_ts_mismatch', archive_url_date);		-- emit an error message
	end
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {																		-- return exported functions
	archive_date_check = archive_date_check,
	date_hyphen_to_dash = date_hyphen_to_dash,
	date_name_xlate = date_name_xlate,
	dates = dates,
	reformat_dates = reformat_dates,
	set_selected_modules = set_selected_modules,
	year_check = year_check,
	year_date_check = year_date_check,
	}</text>
      <sha1>h37xf2hxsrjgq13ms7lozl3uiigkklr</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Citation/CS1/Identifiers</title>
    <ns>828</ns>
    <id>734</id>
    <revision>
      <id>4862</id>
      <timestamp>2015-12-13T23:24:22Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>create;</comment>
      <origin>4862</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="29494" sha1="rzorcsjrf1a5xcj9vzlzsykpa241a8u" xml:space="preserve">local identifiers = {};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]
local utilities = require ('Module:Citation/CS1/Utilities')

local is_set = utilities.is_set	;												-- functions in Module:Citation/CS1/Utilities
local in_array = utilities.in_array;
local set_error = utilities.set_error;
local select_one = utilities.select_one;
local add_maint_cat = utilities.add_maint_cat;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local cfg = {};																	-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end


--[[--------------------------&lt; C H E C K _ I S M N &gt;------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the issn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	}</text>
      <sha1>rzorcsjrf1a5xcj9vzlzsykpa241a8u</sha1>
    </revision>
    <revision>
      <id>4863</id>
      <parentid>4862</parentid>
      <timestamp>2015-12-14T15:45:22Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4863</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="29534" sha1="fjk3uferwf6vpzeyc98b4ayeiyk79wi" xml:space="preserve">local identifiers = {};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]
local utilities = require ('Module:Citation/CS1/Utilities')

local is_set = utilities.is_set	;												-- functions in Module:Citation/CS1/Utilities
local in_array = utilities.in_array;
local set_error = utilities.set_error;
local select_one = utilities.select_one;
local add_maint_cat = utilities.add_maint_cat;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');			-- table of configuration tables that are defined in Module:Citation/CS1/Configuration

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end


--[[--------------------------&lt; C H E C K _ I S M N &gt;------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the issn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	}</text>
      <sha1>fjk3uferwf6vpzeyc98b4ayeiyk79wi</sha1>
    </revision>
    <revision>
      <id>4864</id>
      <parentid>4863</parentid>
      <timestamp>2015-12-14T16:19:05Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4864</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="29532" sha1="b6gxf1xx4cxatz43ixxrvqpjc169ior" xml:space="preserve">local identifiers = {};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]
local utilities = require ('Module:Citation/CS1/Utilities')

local is_set = utilities.is_set	;												-- functions in Module:Citation/CS1/Utilities
local in_array = utilities.in_array;
local set_error = utilities.set_error;
local select_one = utilities.select_one;
local add_maint_cat = utilities.add_maint_cat;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');			-- table of configuration tables that are defined in Module:Citation/CS1/Configuration

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the issn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	}</text>
      <sha1>b6gxf1xx4cxatz43ixxrvqpjc169ior</sha1>
    </revision>
    <revision>
      <id>4865</id>
      <parentid>4864</parentid>
      <timestamp>2015-12-14T17:10:19Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4865</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="29910" sha1="7vukvixzsshioztbnnar4oh8wust6lo" xml:space="preserve">local identifiers = {};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]
local utilities = require ('Module:Citation/CS1/Utilities')

local is_set = utilities.is_set	;												-- functions in Module:Citation/CS1/Utilities
local in_array = utilities.in_array;
local set_error = utilities.set_error;
local select_one = utilities.select_one;
local add_maint_cat = utilities.add_maint_cat;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local cfg;			-- table of configuration tables that are defined in Module:Citation/CS1/Configuration

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the issn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; S E T _ C F G &gt;----------------------------------------------------------------

Sets cfg table to use either the live version or the sandbox version of Module:Citation/CS1/Configuration

]]

local function set_cfg (sandbox)
	if sandbox then
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');
	else
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');
	end
end



return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	set_cfg = set_cfg;
	}</text>
      <sha1>7vukvixzsshioztbnnar4oh8wust6lo</sha1>
    </revision>
    <revision>
      <id>4866</id>
      <parentid>4865</parentid>
      <timestamp>2015-12-14T17:14:15Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4866</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="29940" sha1="3fmkbtjwox677nai9htlbx8gvjsmttc" xml:space="preserve">local identifiers = {};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]
local utilities = require ('Module:Citation/CS1/Utilities')

local is_set = utilities.is_set	;												-- functions in Module:Citation/CS1/Utilities
local in_array = utilities.in_array;
local set_error = utilities.set_error;
local select_one = utilities.select_one;
local add_maint_cat = utilities.add_maint_cat;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local cfg;			-- table of configuration tables that are defined in Module:Citation/CS1/Configuration

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the issn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; S E T _ C F G &gt;----------------------------------------------------------------

Sets cfg table to use either the live version or the sandbox version of Module:Citation/CS1/Configuration

]]

local function set_cfg (sandbox)
	if sandbox then
		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');
	else
		cfg = mw.loadData ('Module:Citation/CS1/Configuration');
	end
end



return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	is_embargoed = is_embargoed;
	set_cfg = set_cfg;
	}</text>
      <sha1>3fmkbtjwox677nai9htlbx8gvjsmttc</sha1>
    </revision>
    <revision>
      <id>4867</id>
      <parentid>4866</parentid>
      <timestamp>2015-12-14T17:19:45Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4867</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="30015" sha1="g172eebi5j8z1wlp6h10lbgdkfag7qc" xml:space="preserve">local identifiers = {};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]
local utilities = require ('Module:Citation/CS1/Utilities')

local is_set = utilities.is_set	;												-- functions in Module:Citation/CS1/Utilities
local in_array = utilities.in_array;
local set_error = utilities.set_error;
local select_one = utilities.select_one;
local add_maint_cat = utilities.add_maint_cat;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local cfg;			-- table of configuration tables that are defined in Module:Citation/CS1/Configuration

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the issn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; S E T _ C F G &gt;----------------------------------------------------------------

Sets cfg table to use either the live version or the sandbox version of Module:Citation/CS1/Configuration

]]

local function set_cfg (cfg_table_ptr)
	cfg = cfg_table_ptr;


--local function set_cfg (sandbox)
--	if sandbox then
--		cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');
--	else
--		cfg = mw.loadData ('Module:Citation/CS1/Configuration');
--	end
end



return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	is_embargoed = is_embargoed;
	set_cfg = set_cfg;
	}</text>
      <sha1>g172eebi5j8z1wlp6h10lbgdkfag7qc</sha1>
    </revision>
    <revision>
      <id>4868</id>
      <parentid>4867</parentid>
      <timestamp>2015-12-14T17:26:58Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4868</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="29771" sha1="qzyszasvlcjfvgeg7pc7sist36avumz" xml:space="preserve">local identifiers = {};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]
local utilities = require ('Module:Citation/CS1/Utilities')

local is_set = utilities.is_set	;												-- functions in Module:Citation/CS1/Utilities
local in_array = utilities.in_array;
local set_error = utilities.set_error;
local select_one = utilities.select_one;
local add_maint_cat = utilities.add_maint_cat;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local cfg;			-- table of configuration tables that are defined in Module:Citation/CS1/Configuration

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the issn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; S E T _ C F G &gt;----------------------------------------------------------------

Sets local cfg table to same as that used by the other modules

]]

local function set_cfg (cfg_table_ptr)
	cfg = cfg_table_ptr;
end



return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	is_embargoed = is_embargoed;
	set_cfg = set_cfg;
	}</text>
      <sha1>qzyszasvlcjfvgeg7pc7sist36avumz</sha1>
    </revision>
    <revision>
      <id>4869</id>
      <parentid>4868</parentid>
      <timestamp>2015-12-15T01:13:01Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4869</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="29777" sha1="fim8eo7f28ovs4xxds6tivg7dvs7ool" xml:space="preserve">local identifiers = {};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]
local utilities = require ('Module:Citation/CS1/Utilities')

local is_set = utilities.is_set	;												-- functions in Module:Citation/CS1/Utilities
local in_array = utilities.in_array;
local set_error = utilities.set_error;
local select_one = utilities.select_one;
local add_maint_cat = utilities.add_maint_cat;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local cfg;			-- table of configuration tables that are defined in Module:Citation/CS1/Configuration

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the issn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; S E T _ C F G &gt;----------------------------------------------------------------

Sets local cfg table to same as that used by the other modules

]]

local function set_cfg (cfg_table_ptr)
	cfg = cfg_table_ptr;
end



return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	is_embargoed = is_embargoed;
	set_cfg = set_cfg;
	}</text>
      <sha1>fim8eo7f28ovs4xxds6tivg7dvs7ool</sha1>
    </revision>
    <revision>
      <id>4870</id>
      <parentid>4869</parentid>
      <timestamp>2015-12-15T01:13:35Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4870</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="29783" sha1="9ubmud3w0iuh76f7951jkra3fvij67a" xml:space="preserve">local identifiers = {};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]
local utilities = require ('Module:Citation/CS1/Utilities')

local is_set = utilities.is_set	;												-- functions in Module:Citation/CS1/Utilities
local in_array = utilities.in_array;
local set_error = utilities.set_error;
local select_one = utilities.select_one;
local add_maint_cat = utilities.add_maint_cat;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local cfg;			-- table of configuration tables that are defined in Module:Citation/CS1/Configuration

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the issn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; S E T _ C F G &gt;----------------------------------------------------------------

Sets local cfg table to same as that used by the other modules

]]

local function set_cfg (cfg_table_ptr)
	cfg = cfg_table_ptr;
end



return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	is_embargoed = is_embargoed;
	set_cfg = set_cfg;
	}</text>
      <sha1>9ubmud3w0iuh76f7951jkra3fvij67a</sha1>
    </revision>
    <revision>
      <id>4871</id>
      <parentid>4870</parentid>
      <timestamp>2015-12-15T12:53:35Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4871</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="29789" sha1="sqxfk20e923x04dka507syxt2ac6pf9" xml:space="preserve">local identifiers = {};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]
local utilities = require ('Module:Citation/CS1/Utilities')

local is_set = utilities.is_set	;												-- functions in Module:Citation/CS1/Utilities
local in_array = utilities.in_array;
local set_error = utilities.set_error;
local select_one = utilities.select_one;
local add_maint_cat = utilities.add_maint_cat;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local cfg;			-- table of configuration tables that are defined in Module:Citation/CS1/Configuration

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the issn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; S E T _ C F G &gt;----------------------------------------------------------------

Sets local cfg table to same as that used by the other modules

]]

local function set_cfg (cfg_table_ptr)
	cfg = cfg_table_ptr;
end



return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	is_embargoed = is_embargoed;
	set_cfg = set_cfg;
	}</text>
      <sha1>sqxfk20e923x04dka507syxt2ac6pf9</sha1>
    </revision>
    <revision>
      <id>4872</id>
      <parentid>4871</parentid>
      <timestamp>2015-12-15T15:54:58Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4872</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="29802" sha1="b6er2cnhd8w1v5dr9tthybhtb0nat6x" xml:space="preserve">local identifiers = {};
local utilities;

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set = utilities.is_set	;												-- functions in Module:Citation/CS1/Utilities
local in_array = utilities.in_array;
local set_error = utilities.set_error;
local select_one = utilities.select_one;
local add_maint_cat = utilities.add_maint_cat;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local cfg;			-- table of configuration tables that are defined in Module:Citation/CS1/Configuration

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the issn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; S E T _ C F G &gt;----------------------------------------------------------------

Sets local cfg table to same as that used by the other modules

]]

local function set_cfg (cfg_table_ptr)
	cfg = cfg_table_ptr;
	 utilities = require ('Module:Citation/CS1/Utilities')
end



return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	is_embargoed = is_embargoed;
	set_cfg = set_cfg;
	}</text>
      <sha1>b6er2cnhd8w1v5dr9tthybhtb0nat6x</sha1>
    </revision>
    <revision>
      <id>4873</id>
      <parentid>4872</parentid>
      <timestamp>2015-12-15T16:02:08Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4873</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="29847" sha1="3kyob0fb1h7g5ztut6rznsv5gaeegl3" xml:space="preserve">local utilities = require ('Module:Citation/CS1/Utilities');

local identifiers = {};

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the issn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; S E T _ C F G &gt;----------------------------------------------------------------

Sets local cfg table to same as that used by the other modules

]]

local function set_cfg (cfg_table_ptr)
	cfg = cfg_table_ptr;
	 utilities = require ('Module:Citation/CS1/Utilities')
end

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set = utilities.is_set	;												-- functions in Module:Citation/CS1/Utilities
local in_array = utilities.in_array;
local set_error = utilities.set_error;
local select_one = utilities.select_one;
local add_maint_cat = utilities.add_maint_cat;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local cfg;			-- table of configuration tables that are defined in Module:Citation/CS1/Configuration



return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	is_embargoed = is_embargoed;
	set_cfg = set_cfg;
	}</text>
      <sha1>3kyob0fb1h7g5ztut6rznsv5gaeegl3</sha1>
    </revision>
    <revision>
      <id>4874</id>
      <parentid>4873</parentid>
      <timestamp>2015-12-15T16:03:26Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4874</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="29846" sha1="0md5gptka5dwwtvotkn7md2n70d9i9d" xml:space="preserve">local utilities = require ('Module:Citation/CS1/Utilities');

local identifiers = {};
local z ={};																	-- tables in Module:Citation/CS1/Utilities

local cfg;			-- table of configuration tables that are defined in Module:Citation/CS1/Configuration

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the issn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; S E T _ C F G &gt;----------------------------------------------------------------

Sets local cfg table to same as that used by the other modules

]]

local function set_cfg (cfg_table_ptr)
	cfg = cfg_table_ptr;
	 utilities = require ('Module:Citation/CS1/Utilities')
end

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set = utilities.is_set	;												-- functions in Module:Citation/CS1/Utilities
local in_array = utilities.in_array;
local set_error = utilities.set_error;
local select_one = utilities.select_one;
local add_maint_cat = utilities.add_maint_cat;



return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	is_embargoed = is_embargoed;
	set_cfg = set_cfg;
	}</text>
      <sha1>0md5gptka5dwwtvotkn7md2n70d9i9d</sha1>
    </revision>
    <revision>
      <id>4875</id>
      <parentid>4874</parentid>
      <timestamp>2015-12-15T16:06:24Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4875</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="29791" sha1="my0m6w15mbwepbtrqufvxmxfecrvph4" xml:space="preserve">local utilities = require ('Module:Citation/CS1/Utilities');

local identifiers = {};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set = utilities.is_set	;												-- functions in Module:Citation/CS1/Utilities
local in_array = utilities.in_array;
local set_error = utilities.set_error;
local select_one = utilities.select_one;
local add_maint_cat = utilities.add_maint_cat;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local cfg;			-- table of configuration tables that are defined in Module:Citation/CS1/Configuration

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the issn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; S E T _ C F G &gt;----------------------------------------------------------------

Sets local cfg table to same as that used by the other modules

]]

local function set_cfg (cfg_table_ptr)
	cfg = cfg_table_ptr;
end



return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	is_embargoed = is_embargoed;
	set_cfg = set_cfg;
	}</text>
      <sha1>my0m6w15mbwepbtrqufvxmxfecrvph4</sha1>
    </revision>
    <revision>
      <id>4876</id>
      <parentid>4875</parentid>
      <timestamp>2015-12-15T16:28:21Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4876</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="29808" sha1="hy4len9peu3o2ib5cis0h7m0vci15re" xml:space="preserve">local utilities = '';

local identifiers = {};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set = utilities.is_set	;												-- functions in Module:Citation/CS1/Utilities
local in_array = utilities.in_array;
local set_error = utilities.set_error;
local select_one = utilities.select_one;
local add_maint_cat = utilities.add_maint_cat;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local cfg;			-- table of configuration tables that are defined in Module:Citation/CS1/Configuration

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the issn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; S E T _ C F G &gt;----------------------------------------------------------------

Sets local cfg table to same as that used by the other modules

]]

local function set_cfg (cfg_table_ptr)
	cfg = cfg_table_ptr;
	utilities = require ('Module:Citation/CS1/Utilities');
end



return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	is_embargoed = is_embargoed;
	set_cfg = set_cfg;
	}</text>
      <sha1>hy4len9peu3o2ib5cis0h7m0vci15re</sha1>
    </revision>
    <revision>
      <id>4877</id>
      <parentid>4876</parentid>
      <timestamp>2015-12-15T16:32:42Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4877</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="30111" sha1="pu916cjv3vwg1i1ytnff9kaaig10ap7" xml:space="preserve">local utilities = '';

local identifiers = {};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat;
--local is_set = utilities.is_set	;												-- functions in Module:Citation/CS1/Utilities
--local in_array = utilities.in_array;
--local set_error = utilities.set_error;
--local select_one = utilities.select_one;
--local add_maint_cat = utilities.add_maint_cat;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local cfg;			-- table of configuration tables that are defined in Module:Citation/CS1/Configuration

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the issn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; S E T _ C F G &gt;----------------------------------------------------------------

Sets local cfg table to same as that used by the other modules

]]

local function set_cfg (cfg_table_ptr)
	cfg = cfg_table_ptr;
	utilities = require ('Module:Citation/CS1/Utilities');
	is_set = utilities.is_set	;												-- functions in Module:Citation/CS1/Utilities
	in_array = utilities.in_array;
	set_error = utilities.set_error;
	select_one = utilities.select_one;
	add_maint_cat = utilities.add_maint_cat;

end



return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	is_embargoed = is_embargoed;
	set_cfg = set_cfg;
	}</text>
      <sha1>pu916cjv3vwg1i1ytnff9kaaig10ap7</sha1>
    </revision>
    <revision>
      <id>4878</id>
      <parentid>4877</parentid>
      <timestamp>2015-12-15T16:37:11Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4878</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="30166" sha1="hq6bbt9psjdnwcimkxdd9jlrbslwrhk" xml:space="preserve">local utilities = '';

local identifiers = {};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat;
--local is_set = utilities.is_set	;												-- functions in Module:Citation/CS1/Utilities
--local in_array = utilities.in_array;
--local set_error = utilities.set_error;
--local select_one = utilities.select_one;
--local add_maint_cat = utilities.add_maint_cat;

local z ={};																	-- tables in Module:Citation/CS1/Utilities

local cfg;			-- table of configuration tables that are defined in Module:Citation/CS1/Configuration

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the issn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; S E T _ C F G &gt;----------------------------------------------------------------

Sets local cfg table to same as that used by the other modules

]]

local function set_cfg (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;
--	utilities = require ('Module:Citation/CS1/Utilities');
	utilities = utilities_page_ptr;
	is_set = utilities.is_set	;												-- functions in Module:Citation/CS1/Utilities
	in_array = utilities.in_array;
	set_error = utilities.set_error;
	select_one = utilities.select_one;
	add_maint_cat = utilities.add_maint_cat;

end



return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	is_embargoed = is_embargoed;
	set_cfg = set_cfg;
	}</text>
      <sha1>hq6bbt9psjdnwcimkxdd9jlrbslwrhk</sha1>
    </revision>
    <revision>
      <id>4879</id>
      <parentid>4878</parentid>
      <timestamp>2015-12-15T16:42:53Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4879</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="29978" sha1="e1hra9tpe6llbtzug6x9886sbr6lumc" xml:space="preserve">
local identifiers = {};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat;					-- functions in Module:Citation/CS1/Utilities

local z ={};																	-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the issn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; S E T _ C F G &gt;----------------------------------------------------------------

Sets local cfg table to same as that used by the other modules

]]
local utilities;

local function set_cfg (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;
--	utilities = require ('Module:Citation/CS1/Utilities');
	utilities = utilities_page_ptr;
	is_set = utilities.is_set	;												-- functions in Module:Citation/CS1/Utilities
	in_array = utilities.in_array;
	set_error = utilities.set_error;
	select_one = utilities.select_one;
	add_maint_cat = utilities.add_maint_cat;

end



return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	is_embargoed = is_embargoed;
	set_cfg = set_cfg;
	}</text>
      <sha1>e1hra9tpe6llbtzug6x9886sbr6lumc</sha1>
    </revision>
    <revision>
      <id>4880</id>
      <parentid>4879</parentid>
      <timestamp>2015-12-15T17:02:33Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4880</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="30000" sha1="gcktjxppkvf1gomwsph4bsasq0p0is9" xml:space="preserve">
local identifiers = {};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat;					-- functions in Module:Citation/CS1/Utilities

local z;																	-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the issn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; S E T _ C F G &gt;----------------------------------------------------------------

Sets local cfg table to same as that used by the other modules

]]
local utilities;

local function set_cfg (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;
--	utilities = require ('Module:Citation/CS1/Utilities');
	utilities = utilities_page_ptr;
	is_set = utilities.is_set	;												-- functions in Module:Citation/CS1/Utilities
	in_array = utilities.in_array;
	set_error = utilities.set_error;
	select_one = utilities.select_one;
	add_maint_cat = utilities.add_maint_cat;
	z = utilities_page_ptr.z;
end



return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	is_embargoed = is_embargoed;
	set_cfg = set_cfg;
	}</text>
      <sha1>gcktjxppkvf1gomwsph4bsasq0p0is9</sha1>
    </revision>
    <revision>
      <id>4881</id>
      <parentid>4880</parentid>
      <timestamp>2015-12-15T17:08:19Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4881</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="30085" sha1="aoh4z0rdyhjbxgbz0l6cvaux3oega81" xml:space="preserve">
local identifiers = {};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat;					-- functions in Module:Citation/CS1/Utilities

local z;																	-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the issn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	set_error = utilities_page_ptr.set_error;
	select_one = utilities_page_ptr.select_one;
	add_maint_cat = utilities_page_ptr.add_maint_cat;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end



return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	is_embargoed = is_embargoed;
	set_cfg = set_cfg;
	}</text>
      <sha1>aoh4z0rdyhjbxgbz0l6cvaux3oega81</sha1>
    </revision>
    <revision>
      <id>4882</id>
      <parentid>4881</parentid>
      <timestamp>2015-12-15T17:11:02Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4882</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="30111" sha1="ds9lcxixnmz2gkfn6c8acz59w1kejpd" xml:space="preserve">
local identifiers = {};

--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat;					-- functions in Module:Citation/CS1/Utilities

local z;																	-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the issn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	set_error = utilities_page_ptr.set_error;
	select_one = utilities_page_ptr.select_one;
	add_maint_cat = utilities_page_ptr.add_maint_cat;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end



return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>ds9lcxixnmz2gkfn6c8acz59w1kejpd</sha1>
    </revision>
    <revision>
      <id>4883</id>
      <parentid>4882</parentid>
      <timestamp>2015-12-15T17:34:35Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4883</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="30170" sha1="sqzlzakaempwhr84f5qp3ha15mtj7be" xml:space="preserve">--[[
History of changes since last sync: 2015-12-12

]]

local identifiers = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat;					-- functions in Module:Citation/CS1/Utilities

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the issn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler = cfg.id_handlers['ISSN'];
	local text;
	local valid_issn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	set_error = utilities_page_ptr.set_error;
	select_one = utilities_page_ptr.select_one;
	add_maint_cat = utilities_page_ptr.add_maint_cat;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end



return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>sqzlzakaempwhr84f5qp3ha15mtj7be</sha1>
    </revision>
    <revision>
      <id>4884</id>
      <parentid>4883</parentid>
      <timestamp>2015-12-16T13:51:15Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4884</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="30395" sha1="tkjilg32o7b5lv8g7t4sxqqpx8legu1" xml:space="preserve">--[[
History of changes since last sync: 2015-12-12

]]

local identifiers = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat;					-- functions in Module:Citation/CS1/Utilities

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the ismn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id, e)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler;
	local text;
	local valid_issn = true;
	
	if e then
		 handler = cfg.id_handlers['EISSN'];
	else
		 handler = cfg.id_handlers['ISSN'];
	end

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn', e and 'e' or '' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'EISSN' then
			table.insert( new_list, {handler.label, issn( v, true ) } );		-- true distinguishes eissn from issn
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	set_error = utilities_page_ptr.set_error;
	select_one = utilities_page_ptr.select_one;
	add_maint_cat = utilities_page_ptr.add_maint_cat;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end



return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>tkjilg32o7b5lv8g7t4sxqqpx8legu1</sha1>
    </revision>
    <revision>
      <id>4885</id>
      <parentid>4884</parentid>
      <timestamp>2015-12-16T14:09:39Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4885</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="30431" sha1="gpt9wh8jt2jfy7hqoq9ub3brfjhwrrx" xml:space="preserve">--[[
History of changes since last sync: 2015-12-12

2015-12-16:	add support for eissn;

]]

local identifiers = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat;					-- functions in Module:Citation/CS1/Utilities

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the ismn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id, e)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler;
	local text;
	local valid_issn = true;
	
	if e then
		 handler = cfg.id_handlers['EISSN'];
	else
		 handler = cfg.id_handlers['ISSN'];
	end

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn', e and 'e' or '' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'EISSN' then
			table.insert( new_list, {handler.label, issn( v, true ) } );		-- true distinguishes eissn from issn
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	set_error = utilities_page_ptr.set_error;
	select_one = utilities_page_ptr.select_one;
	add_maint_cat = utilities_page_ptr.add_maint_cat;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end



return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>gpt9wh8jt2jfy7hqoq9ub3brfjhwrrx</sha1>
    </revision>
    <revision>
      <id>4886</id>
      <parentid>4885</parentid>
      <timestamp>2015-12-17T11:36:40Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4886</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="31737" sha1="0fez18y71xmiaichrg8l0tla2wa0aqm" xml:space="preserve">--[[
History of changes since last sync: 2015-12-12

2015-12-16:	add support for eissn;

]]

local identifiers = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat;					-- functions in Module:Citation/CS1/Utilities

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the ismn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id, e)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler;
	local text;
	local valid_issn = true;
	
	if e then
		 handler = cfg.id_handlers['EISSN'];
	else
		 handler = cfg.id_handlers['ISSN'];
	end

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn', e and 'e' or '' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

]]

local function hdl(id)
	local handler = cfg.id_handlers['HDL'];
	
	local text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})

	if nil == id:match(&quot;^%S-/%S-[^%.,]$&quot;) then									-- hdl must contain a fwd slash, must not contain spaces, and must not end with period or comma
		text = text .. ' ' .. set_error( 'bad_hdl' );
	end
	return text;
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'EISSN' then
			table.insert( new_list, {handler.label, issn( v, true ) } );		-- true distinguishes eissn from issn
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	set_error = utilities_page_ptr.set_error;
	select_one = utilities_page_ptr.select_one;
	add_maint_cat = utilities_page_ptr.add_maint_cat;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end



return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>0fez18y71xmiaichrg8l0tla2wa0aqm</sha1>
    </revision>
    <revision>
      <id>4887</id>
      <parentid>4886</parentid>
      <timestamp>2015-12-17T11:43:14Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4887</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="31819" sha1="ab9h49mnzl39xn7j2ibxfgsa6cphlkp" xml:space="preserve">--[[
History of changes since last sync: 2015-12-12

2015-12-16:	add support for eissn;

]]

local identifiers = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat;					-- functions in Module:Citation/CS1/Utilities

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the ismn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id, e)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler;
	local text;
	local valid_issn = true;
	
	if e then
		 handler = cfg.id_handlers['EISSN'];
	else
		 handler = cfg.id_handlers['ISSN'];
	end

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn', e and 'e' or '' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

]]

local function hdl(id)
	local handler = cfg.id_handlers['HDL'];
	
	local text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})

	if nil == id:match(&quot;^%S-/%S-[^%.,]$&quot;) then									-- hdl must contain a fwd slash, must not contain spaces, and must not end with period or comma
		text = text .. ' ' .. set_error( 'bad_hdl' );
	end
	return text;
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'HDL' then
			table.insert( new_list, {handler.label, hdl( v ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'EISSN' then
			table.insert( new_list, {handler.label, issn( v, true ) } );		-- true distinguishes eissn from issn
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	set_error = utilities_page_ptr.set_error;
	select_one = utilities_page_ptr.select_one;
	add_maint_cat = utilities_page_ptr.add_maint_cat;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end



return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>ab9h49mnzl39xn7j2ibxfgsa6cphlkp</sha1>
    </revision>
    <revision>
      <id>4888</id>
      <parentid>4887</parentid>
      <timestamp>2015-12-17T11:51:23Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4888</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="31851" sha1="7fuijtqil0mlryr2bx2d3s21uuz0ozz" xml:space="preserve">--[[
History of changes since last sync: 2015-12-12

2015-12-16:	add support for eissn;

]]

local identifiers = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat;					-- functions in Module:Citation/CS1/Utilities

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the ismn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id, e)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler;
	local text;
	local valid_issn = true;
	
	if e then
		 handler = cfg.id_handlers['EISSN'];
	else
		 handler = cfg.id_handlers['ISSN'];
	end

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn', e and 'e' or '' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

]]

local function hdl(id)
	local handler = cfg.id_handlers['HDL'];
	
	local text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- hdl must contain a fwd slash, must not contain spaces, endashes, and must not end with period or comma
		text = text .. ' ' .. set_error( 'bad_hdl' );
	end
	return text;
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'HDL' then
			table.insert( new_list, {handler.label, hdl( v ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'EISSN' then
			table.insert( new_list, {handler.label, issn( v, true ) } );		-- true distinguishes eissn from issn
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	set_error = utilities_page_ptr.set_error;
	select_one = utilities_page_ptr.select_one;
	add_maint_cat = utilities_page_ptr.add_maint_cat;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end



return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>7fuijtqil0mlryr2bx2d3s21uuz0ozz</sha1>
    </revision>
    <revision>
      <id>4889</id>
      <parentid>4888</parentid>
      <timestamp>2015-12-17T11:57:08Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4889</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="31941" sha1="22lscpgti919in5ub1l2qga6gqgtg9d" xml:space="preserve">--[[
History of changes since last sync: 2015-12-12

2015-12-16:	add support for eissn; see Help_talk:Citation_Style_1#eissn.2C_hdl.2C_citeseerx
2015-12-17: add support for hdl;

]]

local identifiers = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat;					-- functions in Module:Citation/CS1/Utilities

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the ismn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id, e)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler;
	local text;
	local valid_issn = true;
	
	if e then
		 handler = cfg.id_handlers['EISSN'];
	else
		 handler = cfg.id_handlers['ISSN'];
	end

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn', e and 'e' or '' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

]]

local function hdl(id)
	local handler = cfg.id_handlers['HDL'];
	
	local text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- hdl must contain a fwd slash, must not contain spaces, endashes, and must not end with period or comma
		text = text .. ' ' .. set_error( 'bad_hdl' );
	end
	return text;
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'HDL' then
			table.insert( new_list, {handler.label, hdl( v ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'EISSN' then
			table.insert( new_list, {handler.label, issn( v, true ) } );		-- true distinguishes eissn from issn
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	set_error = utilities_page_ptr.set_error;
	select_one = utilities_page_ptr.select_one;
	add_maint_cat = utilities_page_ptr.add_maint_cat;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end



return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>22lscpgti919in5ub1l2qga6gqgtg9d</sha1>
    </revision>
    <revision>
      <id>4890</id>
      <parentid>4889</parentid>
      <timestamp>2016-01-15T14:25:04Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>remove changes history;</comment>
      <origin>4890</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="31758" sha1="1y1zz1grbifwram55l00ffw0jo02rmu" xml:space="preserve">local identifiers = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat;					-- functions in Module:Citation/CS1/Utilities

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the ismn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id, e)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler;
	local text;
	local valid_issn = true;
	
	if e then
		 handler = cfg.id_handlers['EISSN'];
	else
		 handler = cfg.id_handlers['ISSN'];
	end

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn', e and 'e' or '' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

]]

local function hdl(id)
	local handler = cfg.id_handlers['HDL'];
	
	local text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- hdl must contain a fwd slash, must not contain spaces, endashes, and must not end with period or comma
		text = text .. ' ' .. set_error( 'bad_hdl' );
	end
	return text;
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'HDL' then
			table.insert( new_list, {handler.label, hdl( v ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'EISSN' then
			table.insert( new_list, {handler.label, issn( v, true ) } );		-- true distinguishes eissn from issn
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	set_error = utilities_page_ptr.set_error;
	select_one = utilities_page_ptr.select_one;
	add_maint_cat = utilities_page_ptr.add_maint_cat;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end



return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>1y1zz1grbifwram55l00ffw0jo02rmu</sha1>
    </revision>
    <revision>
      <id>4891</id>
      <parentid>4890</parentid>
      <timestamp>2016-01-15T14:30:25Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <minor />
      <comment>Protected &quot;[[Module:Citation/CS1/Identifiers]]&quot;: [[WP:High-risk templates|High-risk Lua module]] ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))</comment>
      <origin>4890</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="31758" sha1="1y1zz1grbifwram55l00ffw0jo02rmu" xml:space="preserve">local identifiers = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat;					-- functions in Module:Citation/CS1/Utilities

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the ismn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id, e)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler;
	local text;
	local valid_issn = true;
	
	if e then
		 handler = cfg.id_handlers['EISSN'];
	else
		 handler = cfg.id_handlers['ISSN'];
	end

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn', e and 'e' or '' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

]]

local function hdl(id)
	local handler = cfg.id_handlers['HDL'];
	
	local text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- hdl must contain a fwd slash, must not contain spaces, endashes, and must not end with period or comma
		text = text .. ' ' .. set_error( 'bad_hdl' );
	end
	return text;
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'HDL' then
			table.insert( new_list, {handler.label, hdl( v ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'EISSN' then
			table.insert( new_list, {handler.label, issn( v, true ) } );		-- true distinguishes eissn from issn
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	set_error = utilities_page_ptr.set_error;
	select_one = utilities_page_ptr.select_one;
	add_maint_cat = utilities_page_ptr.add_maint_cat;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end



return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>1y1zz1grbifwram55l00ffw0jo02rmu</sha1>
    </revision>
    <revision>
      <id>4892</id>
      <parentid>4891</parentid>
      <timestamp>2016-02-20T11:35:36Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sy</comment>
      <origin>4892</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="33735" sha1="nkykcv51rm7w8ypzzy1men6q3549ryx" xml:space="preserve">local identifiers = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat;					-- functions in Module:Citation/CS1/Utilities

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the ismn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id, e)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler;
	local text;
	local valid_issn = true;
	
	if e then
		 handler = cfg.id_handlers['EISSN'];
	else
		 handler = cfg.id_handlers['ISSN'];
	end

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn', e and 'e' or '' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

]]

local function hdl(id)
	local handler = cfg.id_handlers['HDL'];
	
	local text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- hdl must contain a fwd slash, must not contain spaces, endashes, and must not end with period or comma
		text = text .. ' ' .. set_error( 'bad_hdl' );
	end
	return text;
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an oclc id.  https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (id)
	local handler = cfg.id_handlers['OCLC'];
	local number;
	local err_msg = '';															-- empty string for concatenation
	
	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- contrain to 1 to 9 digits; change this when oclc issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- contrain to 1 to 9 digits; change this when oclc issues 10-digit numbers
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		err_msg = ' ' .. set_error( 'bad_oclc' )								-- add an error message if the id is malformed
	end
	
	local text = external_link_id({link=handler.link, label=handler.label,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode}) .. err_msg;

	return text;
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'HDL' then
			table.insert( new_list, {handler.label, hdl( v ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'OCLC' then
			table.insert( new_list, {handler.label, oclc( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'EISSN' then
			table.insert( new_list, {handler.label, issn( v, true ) } );		-- true distinguishes eissn from issn
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	set_error = utilities_page_ptr.set_error;
	select_one = utilities_page_ptr.select_one;
	add_maint_cat = utilities_page_ptr.add_maint_cat;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end



return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>nkykcv51rm7w8ypzzy1men6q3549ryx</sha1>
    </revision>
    <revision>
      <id>4893</id>
      <parentid>4892</parentid>
      <timestamp>2016-02-20T12:23:54Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <minor />
      <comment>oclc to 10 digit max;</comment>
      <origin>4893</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="33737" sha1="5m1q2l9076y7ftwq4xtria7zisirko2" xml:space="preserve">local identifiers = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat;					-- functions in Module:Citation/CS1/Utilities

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then return false; end		-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );	-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false;
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then return false; end
		return is_valid_isxn(isbn_str, 10);
	else
		local temp = 0;
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then return false; end		-- isbn13 begins with 978 or 979; ismn begins with 979
		return is_valid_isxn_13 (isbn_str);
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the ismn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id, e)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler;
	local text;
	local valid_issn = true;
	
	if e then
		 handler = cfg.id_handlers['EISSN'];
	else
		 handler = cfg.id_handlers['ISSN'];
	end

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn', e and 'e' or '' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

]]

local function hdl(id)
	local handler = cfg.id_handlers['HDL'];
	
	local text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- hdl must contain a fwd slash, must not contain spaces, endashes, and must not end with period or comma
		text = text .. ' ' .. set_error( 'bad_hdl' );
	end
	return text;
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an oclc id.  https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (id)
	local handler = cfg.id_handlers['OCLC'];
	local number;
	local err_msg = '';															-- empty string for concatenation
	
	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- contrain to 1 to 9 digits; change this when oclc issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if 10 &lt; number:len() then
			number = nil;														-- contrain to 1 to 10 digits; change this when oclc issues 11-digit numbers
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		err_msg = ' ' .. set_error( 'bad_oclc' )								-- add an error message if the id is malformed
	end
	
	local text = external_link_id({link=handler.link, label=handler.label,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode}) .. err_msg;

	return text;
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'HDL' then
			table.insert( new_list, {handler.label, hdl( v ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'OCLC' then
			table.insert( new_list, {handler.label, oclc( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'EISSN' then
			table.insert( new_list, {handler.label, issn( v, true ) } );		-- true distinguishes eissn from issn
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	set_error = utilities_page_ptr.set_error;
	select_one = utilities_page_ptr.select_one;
	add_maint_cat = utilities_page_ptr.add_maint_cat;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end



return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>5m1q2l9076y7ftwq4xtria7zisirko2</sha1>
    </revision>
    <revision>
      <id>4894</id>
      <parentid>4893</parentid>
      <timestamp>2016-04-16T10:52:04Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4894</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="34658" sha1="kho153i2gfnbdvksqrjjtdtrkhsmaud" xml:space="preserve">
local identifiers = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat;					-- functions in Module:Citation/CS1/Utilities

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then
		return false, 'invalid character';										-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );						-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false, 'length';													-- fail if incorrect length
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then								-- fail if isbn_str has 'X' anywhere but last position
			return false, 'invalid form';									
		end
		return is_valid_isxn(isbn_str, 10), 'checksum';
	else
		if isbn_str:match( &quot;^%d+$&quot; ) == nil then
			return false, 'invalid character';									-- fail if isbn13 is not all digits
		end
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then
			return false, 'invalid prefix';										-- fail when isbn13 does not begin with 978 or 979
		end
		return is_valid_isxn_13 (isbn_str), 'checksum';
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the ismn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id, e)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler;
	local text;
	local valid_issn = true;
	
	if e then
		 handler = cfg.id_handlers['EISSN'];
	else
		 handler = cfg.id_handlers['ISSN'];
	end

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn', e and 'e' or '' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

]]

local function hdl(id)
	local handler = cfg.id_handlers['HDL'];
	
	local text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- hdl must contain a fwd slash, must not contain spaces, endashes, and must not end with period or comma
		text = text .. ' ' .. set_error( 'bad_hdl' );
	end
	return text;
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an oclc id.  https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (id)
	local handler = cfg.id_handlers['OCLC'];
	local number;
	local err_msg = '';															-- empty string for concatenation
	
	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- contrain to 1 to 9 digits; change this when oclc issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if 10 &lt; number:len() then
			number = nil;														-- contrain to 1 to 10 digits; change this when oclc issues 11-digit numbers
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		err_msg = ' ' .. set_error( 'bad_oclc' )								-- add an error message if the id is malformed
	end
	
	local text = external_link_id({link=handler.link, label=handler.label,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode}) .. err_msg;

	return text;
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );
		
		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'HDL' then
			table.insert( new_list, {handler.label, hdl( v ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'OCLC' then
			table.insert( new_list, {handler.label, oclc( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'EISSN' then
			table.insert( new_list, {handler.label, issn( v, true ) } );		-- true distinguishes eissn from issn
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			local check;
			local err_type = '';
--			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
--				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
--			end
			check, err_type = check_isbn( v );
			if not check then
				if is_set(options.IgnoreISBN) then								-- ISBN is invalid; if |ignore-isbn-error= set
					add_maint_cat ('ignore_isbn_err');							-- ad a maint category
				else
					ISBN = ISBN .. set_error( 'bad_isbn', {err_type}, false, &quot; &quot;, &quot;&quot; );	-- else display an error message
				end
			elseif is_set(options.IgnoreISBN) then								-- ISBN is OK; if |ignore-isbn-error= set
					add_maint_cat ('ignore_isbn_err');							-- because |ignore-isbn-error= unnecessary
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	set_error = utilities_page_ptr.set_error;
	select_one = utilities_page_ptr.select_one;
	add_maint_cat = utilities_page_ptr.add_maint_cat;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end



return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>kho153i2gfnbdvksqrjjtdtrkhsmaud</sha1>
    </revision>
    <revision>
      <id>4895</id>
      <parentid>4894</parentid>
      <timestamp>2016-06-04T17:42:18Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4895</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="36715" sha1="p2seu7uluh8iu4af74wmr4njgf3cbcz" xml:space="preserve">
local identifiers = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat;					-- functions in Module:Citation/CS1/Utilities

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, url_string, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then
		return false, 'invalid character';										-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );						-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false, 'length';													-- fail if incorrect length
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then								-- fail if isbn_str has 'X' anywhere but last position
			return false, 'invalid form';									
		end
		return is_valid_isxn(isbn_str, 10), 'checksum';
	else
		if isbn_str:match( &quot;^%d+$&quot; ) == nil then
			return false, 'invalid character';									-- fail if isbn13 is not all digits
		end
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then
			return false, 'invalid prefix';										-- fail when isbn13 does not begin with 978 or 979
		end
		return is_valid_isxn_13 (isbn_str), 'checksum';
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the ismn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id, e)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler;
	local text;
	local valid_issn = true;
	
	if e then
		 handler = cfg.id_handlers['EISSN'];
	else
		 handler = cfg.id_handlers['ISSN'];
	end

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn', e and 'e' or '' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

]]

local function hdl(id)
	local handler = cfg.id_handlers['HDL'];
	
	local text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- hdl must contain a fwd slash, must not contain spaces, endashes, and must not end with period or comma
		text = text .. ' ' .. set_error( 'bad_hdl' );
	end
	return text;
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an oclc id.  https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (id)
	local handler = cfg.id_handlers['OCLC'];
	local number;
	local err_msg = '';															-- empty string for concatenation
	
	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- contrain to 1 to 9 digits; change this when oclc issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if 10 &lt; number:len() then
			number = nil;														-- contrain to 1 to 10 digits; change this when oclc issues 11-digit numbers
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		err_msg = ' ' .. set_error( 'bad_oclc' )								-- add an error message if the id is malformed
	end
	
	local text = external_link_id({link=handler.link, label=handler.label,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode}) .. err_msg;

	return text;
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode id.

Format for bibcodes is specified here: http://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6–8 must be letter, ampersand, or dot (ampersand cannot directly precede a dot; &amp;.
		9 must be letter or dot
		10–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (id)
	local handler = cfg.id_handlers['BIBCODE'];
	local err_type;
	local year;

	local text = external_link_id({link=handler.link, label=handler.label,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode});
	
	if 19 ~= id:len() then
		err_type = 'length';
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%a&amp;%.][%a&amp;%.][%a&amp;%.][%a%.][%a%d%.]+[%a%.]$&quot;)	-- 
		if not year then														-- if nil then no pattern match
			err_type = 'value';													-- so value error
		else
			local next_year = tonumber(os.date ('%Y'))+1;						-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = 'year';												-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = 'journal';											-- journal abbreviation must not have '&amp;.' (if it does its missing a letter)
			end
		end
	end

	if is_set (err_type) then													-- if there was an error detected
		text = text .. ' ' .. set_error( 'bad_bibcode', {err_type});
	end
	return text;
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );

		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'BIBCODE' then
			table.insert( new_list, {handler.label, bibcode( v ) } );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'HDL' then
			table.insert( new_list, {handler.label, hdl( v ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'OCLC' then
			table.insert( new_list, {handler.label, oclc( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'EISSN' then
			table.insert( new_list, {handler.label, issn( v, true ) } );		-- true distinguishes eissn from issn
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			local check;
			local err_type = '';
--			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
--				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
--			end
			check, err_type = check_isbn( v );
			if not check then
				if is_set(options.IgnoreISBN) then								-- ISBN is invalid; if |ignore-isbn-error= set
					add_maint_cat ('ignore_isbn_err');							-- ad a maint category
				else
					ISBN = ISBN .. set_error( 'bad_isbn', {err_type}, false, &quot; &quot;, &quot;&quot; );	-- else display an error message
				end
			elseif is_set(options.IgnoreISBN) then								-- ISBN is OK; if |ignore-isbn-error= set
					add_maint_cat ('ignore_isbn_err');							-- because |ignore-isbn-error= unnecessary
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	set_error = utilities_page_ptr.set_error;
	select_one = utilities_page_ptr.select_one;
	add_maint_cat = utilities_page_ptr.add_maint_cat;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end



return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>p2seu7uluh8iu4af74wmr4njgf3cbcz</sha1>
    </revision>
    <revision>
      <id>4896</id>
      <parentid>4895</parentid>
      <timestamp>2016-07-30T09:55:06Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4896</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="37276" sha1="1mp7wphz5rtbzld4wsltpy0tni9p51t" xml:space="preserve">
local identifiers = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat, substitute;					-- functions in Module:Citation/CS1/Utilities

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	local ext_link;
	
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	
	ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or &quot;&quot;, mw.text.nowiki(options.id));
	if options.free then
		ext_link = substitute (cfg.presentation['free to read'], ext_link);		-- add the free-to-read lock
	end
	
	return mw.ustring.format( '[[%s|%s]]%s%s', options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;, ext_link);

--	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
--		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
--		options.prefix, url_string, options.suffix or &quot;&quot;,
--		mw.text.nowiki(options.id)
--	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then
		return false, 'invalid character';										-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );						-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false, 'length';													-- fail if incorrect length
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then								-- fail if isbn_str has 'X' anywhere but last position
			return false, 'invalid form';									
		end
		return is_valid_isxn(isbn_str, 10), 'checksum';
	else
		if isbn_str:match( &quot;^%d+$&quot; ) == nil then
			return false, 'invalid character';									-- fail if isbn13 is not all digits
		end
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then
			return false, 'invalid prefix';										-- fail when isbn13 does not begin with 978 or 979
		end
		return is_valid_isxn_13 (isbn_str), 'checksum';
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the ismn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id, e)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler;
	local text;
	local valid_issn = true;
	
	if e then
		 handler = cfg.id_handlers['EISSN'];
	else
		 handler = cfg.id_handlers['ISSN'];
	end

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn', e and 'e' or '' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, free=handler.free}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, free=handler.free}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

]]

local function hdl(id)
	local handler = cfg.id_handlers['HDL'];
	
	local text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- hdl must contain a fwd slash, must not contain spaces, endashes, and must not end with period or comma
		text = text .. ' ' .. set_error( 'bad_hdl' );
	end
	return text;
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an oclc id.  https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (id)
	local handler = cfg.id_handlers['OCLC'];
	local number;
	local err_msg = '';															-- empty string for concatenation
	
	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- contrain to 1 to 9 digits; change this when oclc issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if 10 &lt; number:len() then
			number = nil;														-- contrain to 1 to 10 digits; change this when oclc issues 11-digit numbers
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		err_msg = ' ' .. set_error( 'bad_oclc' )								-- add an error message if the id is malformed
	end
	
	local text = external_link_id({link=handler.link, label=handler.label,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode}) .. err_msg;

	return text;
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode id.

Format for bibcodes is specified here: http://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6 must be letter, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		7–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		9–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (id)
	local handler = cfg.id_handlers['BIBCODE'];
	local err_type;
	local year;

	local text = external_link_id({link=handler.link, label=handler.label,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode});
	
	if 19 ~= id:len() then
		err_type = 'length';
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%a&amp;%.][%a&amp;%.%d][%a&amp;%.%d][%a%d%.]+[%a%.]$&quot;)	-- 
		if not year then														-- if nil then no pattern match
			err_type = 'value';													-- so value error
		else
			local next_year = tonumber(os.date ('%Y'))+1;						-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = 'year';												-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = 'journal';											-- journal abbreviation must not have '&amp;.' (if it does its missing a letter)
			end
		end
	end

	if is_set (err_type) then													-- if there was an error detected
		text = text .. ' ' .. set_error( 'bad_bibcode', {err_type});
	end
	return text;
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );

		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'BIBCODE' then
			table.insert( new_list, {handler.label, bibcode( v ) } );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'HDL' then
			table.insert( new_list, {handler.label, hdl( v ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'OCLC' then
			table.insert( new_list, {handler.label, oclc( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'EISSN' then
			table.insert( new_list, {handler.label, issn( v, true ) } );		-- true distinguishes eissn from issn
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			local check;
			local err_type = '';
--			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
--				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
--			end
			check, err_type = check_isbn( v );
			if not check then
				if is_set(options.IgnoreISBN) then								-- ISBN is invalid; if |ignore-isbn-error= set
					add_maint_cat ('ignore_isbn_err');							-- ad a maint category
				else
					ISBN = ISBN .. set_error( 'bad_isbn', {err_type}, false, &quot; &quot;, &quot;&quot; );	-- else display an error message
				end
			elseif is_set(options.IgnoreISBN) then								-- ISBN is OK; if |ignore-isbn-error= set
					add_maint_cat ('ignore_isbn_err');							-- because |ignore-isbn-error= unnecessary
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	set_error = utilities_page_ptr.set_error;
	select_one = utilities_page_ptr.select_one;
	add_maint_cat = utilities_page_ptr.add_maint_cat;
	substitute = utilities_page_ptr.substitute;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end



return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>1mp7wphz5rtbzld4wsltpy0tni9p51t</sha1>
    </revision>
    <revision>
      <id>4897</id>
      <parentid>4896</parentid>
      <timestamp>2016-09-30T14:07:31Z</timestamp>
      <contributor>
        <username>Nihiltres</username>
        <id>822</id>
      </contributor>
      <minor />
      <comment>Bumped PMC limit from 5000000 to 5100000 as some valid PMCs are being flagged currently. Probably worth bumping further, but I don't know enough to judge.</comment>
      <origin>4897</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="37276" sha1="2ymuifqcxs9ah7nl0ps3wxbas0ejgih" xml:space="preserve">
local identifiers = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat, substitute;					-- functions in Module:Citation/CS1/Utilities

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	local ext_link;
	
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	
	ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or &quot;&quot;, mw.text.nowiki(options.id));
	if options.free then
		ext_link = substitute (cfg.presentation['free to read'], ext_link);		-- add the free-to-read lock
	end
	
	return mw.ustring.format( '[[%s|%s]]%s%s', options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;, ext_link);

--	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
--		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
--		options.prefix, url_string, options.suffix or &quot;&quot;,
--		mw.text.nowiki(options.id)
--	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then
		return false, 'invalid character';										-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );						-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false, 'length';													-- fail if incorrect length
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then								-- fail if isbn_str has 'X' anywhere but last position
			return false, 'invalid form';									
		end
		return is_valid_isxn(isbn_str, 10), 'checksum';
	else
		if isbn_str:match( &quot;^%d+$&quot; ) == nil then
			return false, 'invalid character';									-- fail if isbn13 is not all digits
		end
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then
			return false, 'invalid prefix';										-- fail when isbn13 does not begin with 978 or 979
		end
		return is_valid_isxn_13 (isbn_str), 'checksum';
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the ismn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id, e)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler;
	local text;
	local valid_issn = true;
	
	if e then
		 handler = cfg.id_handlers['EISSN'];
	else
		 handler = cfg.id_handlers['ISSN'];
	end

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn', e and 'e' or '' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, free=handler.free}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 5100000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, free=handler.free}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

]]

local function hdl(id)
	local handler = cfg.id_handlers['HDL'];
	
	local text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- hdl must contain a fwd slash, must not contain spaces, endashes, and must not end with period or comma
		text = text .. ' ' .. set_error( 'bad_hdl' );
	end
	return text;
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an oclc id.  https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (id)
	local handler = cfg.id_handlers['OCLC'];
	local number;
	local err_msg = '';															-- empty string for concatenation
	
	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- contrain to 1 to 9 digits; change this when oclc issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if 10 &lt; number:len() then
			number = nil;														-- contrain to 1 to 10 digits; change this when oclc issues 11-digit numbers
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		err_msg = ' ' .. set_error( 'bad_oclc' )								-- add an error message if the id is malformed
	end
	
	local text = external_link_id({link=handler.link, label=handler.label,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode}) .. err_msg;

	return text;
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode id.

Format for bibcodes is specified here: http://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6 must be letter, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		7–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		9–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (id)
	local handler = cfg.id_handlers['BIBCODE'];
	local err_type;
	local year;

	local text = external_link_id({link=handler.link, label=handler.label,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode});
	
	if 19 ~= id:len() then
		err_type = 'length';
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%a&amp;%.][%a&amp;%.%d][%a&amp;%.%d][%a%d%.]+[%a%.]$&quot;)	-- 
		if not year then														-- if nil then no pattern match
			err_type = 'value';													-- so value error
		else
			local next_year = tonumber(os.date ('%Y'))+1;						-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = 'year';												-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = 'journal';											-- journal abbreviation must not have '&amp;.' (if it does its missing a letter)
			end
		end
	end

	if is_set (err_type) then													-- if there was an error detected
		text = text .. ' ' .. set_error( 'bad_bibcode', {err_type});
	end
	return text;
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v }, fallback(k) );

		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'BIBCODE' then
			table.insert( new_list, {handler.label, bibcode( v ) } );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
		elseif k == 'HDL' then
			table.insert( new_list, {handler.label, hdl( v ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'OCLC' then
			table.insert( new_list, {handler.label, oclc( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'EISSN' then
			table.insert( new_list, {handler.label, issn( v, true ) } );		-- true distinguishes eissn from issn
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			local check;
			local err_type = '';
--			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
--				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
--			end
			check, err_type = check_isbn( v );
			if not check then
				if is_set(options.IgnoreISBN) then								-- ISBN is invalid; if |ignore-isbn-error= set
					add_maint_cat ('ignore_isbn_err');							-- ad a maint category
				else
					ISBN = ISBN .. set_error( 'bad_isbn', {err_type}, false, &quot; &quot;, &quot;&quot; );	-- else display an error message
				end
			elseif is_set(options.IgnoreISBN) then								-- ISBN is OK; if |ignore-isbn-error= set
					add_maint_cat ('ignore_isbn_err');							-- because |ignore-isbn-error= unnecessary
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	set_error = utilities_page_ptr.set_error;
	select_one = utilities_page_ptr.select_one;
	add_maint_cat = utilities_page_ptr.add_maint_cat;
	substitute = utilities_page_ptr.substitute;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end



return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>2ymuifqcxs9ah7nl0ps3wxbas0ejgih</sha1>
    </revision>
    <revision>
      <id>4898</id>
      <parentid>4897</parentid>
      <timestamp>2016-10-29T08:52:11Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4898</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="40739" sha1="lmynji1y0vgvsfzhtlccepb9yh4gldk" xml:space="preserve">
local identifiers = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat, substitute;					-- functions in Module:Citation/CS1/Utilities

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	local ext_link;
	
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	
	ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or &quot;&quot;, mw.text.nowiki(options.id));
	if is_set(options.access) then
		ext_link = substitute (cfg.presentation[options.access], ext_link);	-- add the free-to-read / paywall lock
	end
	
	return mw.ustring.format( '[[%s|%s]]%s%s', options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;, ext_link);

--	return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
--		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
--		options.prefix, url_string, options.suffix or &quot;&quot;,
--		mw.text.nowiki(options.id)
--	);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then
		return false, 'invalid character';										-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );						-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false, 'length';													-- fail if incorrect length
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then								-- fail if isbn_str has 'X' anywhere but last position
			return false, 'invalid form';									
		end
		return is_valid_isxn(isbn_str, 10), 'checksum';
	else
		if isbn_str:match( &quot;^%d+$&quot; ) == nil then
			return false, 'invalid character';									-- fail if isbn13 is not all digits
		end
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then
			return false, 'invalid prefix';										-- fail when isbn13 does not begin with 978 or 979
		end
		return is_valid_isxn_13 (isbn_str), 'checksum';
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;
	local id_copy;

	id_copy = id;																-- save a copy because this testing is destructive
	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id_copy;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the ismn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id, e)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler;
	local text;
	local valid_issn = true;
	
	if e then
		 handler = cfg.id_handlers['EISSN'];
	else
		 handler = cfg.id_handlers['ISSN'];
	end

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn', e and 'e' or '' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end

--[[--------------------------&lt; B I O R X I V &gt;-----------------------------------------------------------------

Format bioRxiv id and do simple error checking.  BiorXiv ids are exactly 6 digits.
The bioRxiv id is the number following the last slash in the bioRxiv-issued DOI:
http://dx.doi.org/10.1101/078733 -&gt; 078733

]]

local function biorxiv(id)
	local handler = cfg.id_handlers['BIORXIV'];
	local err_cat =  '';								-- presume that bioRxiv id is valid
	
	if nil == id:match(&quot;^%d%d%d%d%d%d$&quot;) then				-- if bioRxiv id has anything but six digits
		err_cat = ' ' .. set_error( 'bad_biorxiv');	-- set an error message
    end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator,
			encode=handler.encode, access=handler.access}) .. err_cat;
end

--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 6000000;							-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';								-- presume that PMC is valid
	
	local text;

	if id:match(&quot;[^%d]&quot;) then							-- if PMC has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmc' );			-- set an error message
	else												-- PMC is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );		-- set an error message
		end
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,			-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive, access)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

]]

local function hdl(id, access)
	local handler = cfg.id_handlers['HDL'];
	
	local text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- hdl must contain a fwd slash, must not contain spaces, endashes, and must not end with period or comma
		text = text .. ' ' .. set_error( 'bad_hdl' );
	end
	return text;
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id, access)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an oclc id.  https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (id)
	local handler = cfg.id_handlers['OCLC'];
	local number;
	local err_msg = '';															-- empty string for concatenation
	
	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- contrain to 1 to 9 digits; change this when oclc issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if 10 &lt; number:len() then
			number = nil;														-- contrain to 1 to 10 digits; change this when oclc issues 11-digit numbers
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		err_msg = ' ' .. set_error( 'bad_oclc' )								-- add an error message if the id is malformed
	end
	
	local text = external_link_id({link=handler.link, label=handler.label,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode}) .. err_msg;

	return text;
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode id.

Format for bibcodes is specified here: http://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6 must be letter, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		7–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		9–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (id, access)
	local handler = cfg.id_handlers['BIBCODE'];
	local err_type;
	local year;

	local text = external_link_id({link=handler.link, label=handler.label,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
		access=access});
	
	if 19 ~= id:len() then
		err_type = 'length';
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%a&amp;%.][%a&amp;%.%d][%a&amp;%.%d][%a%d%.]+[%a%.]$&quot;)	-- 
		if not year then														-- if nil then no pattern match
			err_type = 'value';													-- so value error
		else
			local next_year = tonumber(os.date ('%Y'))+1;						-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = 'year';												-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = 'journal';											-- journal abbreviation must not have '&amp;.' (if it does its missing a letter)
			end
		end
	end

	if is_set (err_type) then													-- if there was an error detected
		text = text .. ' ' .. set_error( 'bad_bibcode', {err_type});
	end
	return text;
end

--[[--------------------------&lt; C I T E S E E R X &gt;------------------------------------------------------------

CiteSeerX use their own notion of &quot;doi&quot; (not to be confused with the identifiers resolved via doi.org).

The description of the structure of this identifier can be found at Help_talk:Citation_Style_1#CiteSeerX_id_structure
]]

local function citeseerx (id)
	local handler = cfg.id_handlers['CITESEERX'];
	local matched;
	
	local text = external_link_id({link=handler.link, label=handler.label,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
		access=handler.access});
	
	matched = id:match (&quot;^10%.1%.1%.[1-9]%d?%d?%d?%.[1-9]%d?%d?%d?$&quot;);
	if not matched then
		text = text .. ' ' .. set_error( 'bad_citeseerx' );
	end
	return text;
end

--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v, ['access'] = options.IdAccessLevels[k] }, fallback(k) );

		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'BIBCODE' then
			table.insert( new_list, {handler.label, bibcode( v, handler.access ) } );
		elseif k == 'BIORXIV' then
			table.insert( new_list, {handler.label, biorxiv( v ) } );
		elseif k == 'CITESEERX' then
			table.insert( new_list, {handler.label, citeseerx( v ) } );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken, handler.access ) } );
		elseif k == 'HDL' then
			table.insert( new_list, {handler.label, hdl( v, handler.access ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v, handler.access ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'OCLC' then
			table.insert( new_list, {handler.label, oclc( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'EISSN' then
			table.insert( new_list, {handler.label, issn( v, true ) } );		-- true distinguishes eissn from issn
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			local check;
			local err_type = '';
--			if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
--				ISBN = ISBN .. set_error( 'bad_isbn', {}, false, &quot; &quot;, &quot;&quot; );
--			end
			check, err_type = check_isbn( v );
			if not check then
				if is_set(options.IgnoreISBN) then								-- ISBN is invalid; if |ignore-isbn-error= set
					add_maint_cat ('ignore_isbn_err');							-- ad a maint category
				else
					ISBN = ISBN .. set_error( 'bad_isbn', {err_type}, false, &quot; &quot;, &quot;&quot; );	-- else display an error message
				end
			elseif is_set(options.IgnoreISBN) then								-- ISBN is OK; if |ignore-isbn-error= set
					add_maint_cat ('ignore_isbn_err');							-- because |ignore-isbn-error= unnecessary
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end

--[[--------------------------&lt; E X T R A C T _ I D _ A C C E S S _ L E V E L S &gt;--------------------------------------

Fetches custom id access levels from arguments using configuration settings.
Parameters which have a predefined access level (e.g. arxiv) do not use this
function as they are directly rendered as free without using an additional parameter.

]]

local function extract_id_access_levels( args, id_list )
	local id_accesses_list = {};
	for k, v in pairs( cfg.id_handlers ) do
		local access_param = v.custom_access;
		local k_lower = string.lower(k);
		if is_set(access_param) then
			local access_level = args[access_param];
			if is_set(access_level) then
				if not in_array (access_level:lower(), cfg.keywords['id-access']) then
					table.insert( z.message_tail, { set_error( 'invalid_param_val', {access_param, access_level}, true ) } );	
					access_level = nil;
				end
				if not is_set(id_list[k]) then
					table.insert( z.message_tail, { set_error( 'param_access_requires_param', {k_lower}, true ) } );
				end
				if is_set(access_level) then
					access_level = access_level:lower();
				end
				id_accesses_list[k] = access_level;
			end
		end
	end
	return id_accesses_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	set_error = utilities_page_ptr.set_error;
	select_one = utilities_page_ptr.select_one;
	add_maint_cat = utilities_page_ptr.add_maint_cat;
	substitute = utilities_page_ptr.substitute;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end



return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	extract_id_access_levels = extract_id_access_levels,
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>lmynji1y0vgvsfzhtlccepb9yh4gldk</sha1>
    </revision>
    <revision>
      <id>4899</id>
      <parentid>4898</parentid>
      <timestamp>2017-04-29T09:52:15Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>synch from sandbox;</comment>
      <origin>4899</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="42381" sha1="1h2cafos02sco3ydarswxci7v9b7lk1" xml:space="preserve">
local identifiers = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat, substitute;					-- functions in Module:Citation/CS1/Utilities

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	local ext_link;
	
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	
	ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or &quot;&quot;, mw.text.nowiki(options.id));
	if is_set(options.access) then
		ext_link = substitute (cfg.presentation['access-signal'], {ext_link, cfg.presentation[options.access]});	-- add the free-to-read / paywall lock
	end
	
	return mw.ustring.format( '[[%s|%s]]%s%s', options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;, ext_link);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then
		return false, 'invalid character';										-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );						-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false, 'length';													-- fail if incorrect length
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then								-- fail if isbn_str has 'X' anywhere but last position
			return false, 'invalid form';									
		end
		return is_valid_isxn(isbn_str, 10), 'checksum';
	else
		if isbn_str:match( &quot;^%d+$&quot; ) == nil then
			return false, 'invalid character';									-- fail if isbn13 is not all digits
		end
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then
			return false, 'invalid prefix';										-- fail when isbn13 does not begin with 978 or 979
		end
		return is_valid_isxn_13 (isbn_str), 'checksum';
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;
	local id_copy;

	id_copy = id;																-- save a copy because this testing is destructive
	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id_copy;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the ismn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id, e)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler;
	local text;
	local valid_issn = true;
	
	if e then
		 handler = cfg.id_handlers['EISSN'];
	else
		 handler = cfg.id_handlers['ISSN'];
	end

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn', e and 'e' or '' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; B I O R X I V &gt;-----------------------------------------------------------------

Format bioRxiv id and do simple error checking.  BiorXiv ids are exactly 6 digits.
The bioRxiv id is the number following the last slash in the bioRxiv-issued DOI:
https://doi.org/10.1101/078733 -&gt; 078733

]]

local function biorxiv(id)
	local handler = cfg.id_handlers['BIORXIV'];
	local err_cat =  '';								-- presume that bioRxiv id is valid
	
	if nil == id:match(&quot;^%d%d%d%d%d%d$&quot;) then				-- if bioRxiv id has anything but six digits
		err_cat = ' ' .. set_error( 'bad_biorxiv');	-- set an error message
    end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator,
			encode=handler.encode, access=handler.access}) .. err_cat;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 6000000;													-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';														-- presume that PMC is valid
	local id_num;
	local text;
	
	id_num = id:match ('^[Pp][Mm][Cc](%d+)$');                                  -- identifier with pmc prefix

	if is_set (id_num) then
		add_maint_cat ('pmc_format');
	else																        -- plain number without pmc prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then								-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );							-- set an error message
		else
			id = tostring (id_num);												-- make sure id is a string
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_pmc' );								-- set an error message
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,	-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive, access)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

]]

local function hdl(id, access)
	local handler = cfg.id_handlers['HDL'];
	
	local text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- hdl must contain a fwd slash, must not contain spaces, endashes, and must not end with period or comma
		text = text .. ' ' .. set_error( 'bad_hdl' );
	end
	return text;
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id, access)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an oclc id.  https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (id)
	local handler = cfg.id_handlers['OCLC'];
	local number;
	local err_msg = '';															-- empty string for concatenation
	
	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- contrain to 1 to 9 digits; change this when oclc issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if 10 &lt; number:len() then
			number = nil;														-- contrain to 1 to 10 digits; change this when oclc issues 11-digit numbers
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		err_msg = ' ' .. set_error( 'bad_oclc' )								-- add an error message if the id is malformed
	end
	
	local text = external_link_id({link=handler.link, label=handler.label,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode}) .. err_msg;

	return text;
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode id.

Format for bibcodes is specified here: http://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6 must be letter, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		7–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		9–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (id, access)
	local handler = cfg.id_handlers['BIBCODE'];
	local err_type;
	local year;

	local text = external_link_id({link=handler.link, label=handler.label,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
		access=access});
	
	if 19 ~= id:len() then
		err_type = 'length';
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%a&amp;%.][%a&amp;%.%d][%a&amp;%.%d][%a%d%.]+[%a%.]$&quot;)	-- 
		if not year then														-- if nil then no pattern match
			err_type = 'value';													-- so value error
		else
			local next_year = tonumber(os.date ('%Y'))+1;						-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = 'year';												-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = 'journal';											-- journal abbreviation must not have '&amp;.' (if it does its missing a letter)
			end
		end
	end

	if is_set (err_type) then													-- if there was an error detected
		text = text .. ' ' .. set_error( 'bad_bibcode', {err_type});
	end
	return text;
end


--[[--------------------------&lt; C I T E S E E R X &gt;------------------------------------------------------------

CiteSeerX use their own notion of &quot;doi&quot; (not to be confused with the identifiers resolved via doi.org).

The description of the structure of this identifier can be found at Help_talk:Citation_Style_1/Archive_26#CiteSeerX_id_structure
]]

local function citeseerx (id)
	local handler = cfg.id_handlers['CITESEERX'];
	local matched;
	
	local text = external_link_id({link=handler.link, label=handler.label,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
		access=handler.access});
	
	matched = id:match (&quot;^10%.1%.1%.[1-9]%d?%d?%d?%.[1-9]%d?%d?%d?$&quot;);
	if not matched then
		text = text .. ' ' .. set_error( 'bad_citeseerx' );
	end
	return text;
end


--[[--------------------------&lt; S S R N &gt;----------------------------------------------------------------------

Format an ssrn, do simple error checking

SSRNs are sequential numbers beginning at 100? and counting up.  This code checks the ssrn to see that it is
only digits and is greater than 99 and less than test_limit; the value in local variable test_limit will need
to be updated periodically as more SSRNs are issued.

]]

local function ssrn (id)
	local test_limit = 3000000;													-- update this value as SSRNs approach
	local handler = cfg.id_handlers['SSRN'];
	local err_cat =  '';														-- presume that SSRN is valid
	local id_num;
	local text;
	
	id_num = id:match ('^%d+$');												-- id must be all digits

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 100 &gt; id_num or test_limit &lt; id_num then								-- if SSRN is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_ssrn' );							-- set an error message
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_ssrn' );								-- set an error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;

	return text;
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v, ['access'] = options.IdAccessLevels[k] }, fallback(k) );

		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'BIBCODE' then
			table.insert( new_list, {handler.label, bibcode( v, handler.access ) } );
		elseif k == 'BIORXIV' then
			table.insert( new_list, {handler.label, biorxiv( v ) } );
		elseif k == 'CITESEERX' then
			table.insert( new_list, {handler.label, citeseerx( v ) } );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken, handler.access ) } );
		elseif k == 'HDL' then
			table.insert( new_list, {handler.label, hdl( v, handler.access ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v, handler.access ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'OCLC' then
			table.insert( new_list, {handler.label, oclc( v ) } );
		elseif k == 'SSRN' then
			table.insert( new_list, {handler.label, ssrn( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'EISSN' then
			table.insert( new_list, {handler.label, issn( v, true ) } );		-- true distinguishes eissn from issn
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			local check;
			local err_type = '';
			check, err_type = check_isbn( v );
			if not check then
				if is_set(options.IgnoreISBN) then								-- ISBN is invalid; if |ignore-isbn-error= set
					add_maint_cat ('ignore_isbn_err');							-- ad a maint category
				else
					ISBN = ISBN .. set_error( 'bad_isbn', {err_type}, false, &quot; &quot;, &quot;&quot; );	-- else display an error message
				end
			elseif is_set(options.IgnoreISBN) then								-- ISBN is OK; if |ignore-isbn-error= set
					add_maint_cat ('ignore_isbn_err');							-- because |ignore-isbn-error= unnecessary
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; E X T R A C T _ I D _ A C C E S S _ L E V E L S &gt;--------------------------------------

Fetches custom id access levels from arguments using configuration settings.
Parameters which have a predefined access level (e.g. arxiv) do not use this
function as they are directly rendered as free without using an additional parameter.

]]

local function extract_id_access_levels( args, id_list )
	local id_accesses_list = {};
	for k, v in pairs( cfg.id_handlers ) do
		local access_param = v.custom_access;
		local k_lower = string.lower(k);
		if is_set(access_param) then
			local access_level = args[access_param];
			if is_set(access_level) then
				if not in_array (access_level:lower(), cfg.keywords['id-access']) then
					table.insert( z.message_tail, { set_error( 'invalid_param_val', {access_param, access_level}, true ) } );	
					access_level = nil;
				end
				if not is_set(id_list[k]) then
					table.insert( z.message_tail, { set_error( 'param_access_requires_param', {k_lower}, true ) } );
				end
				if is_set(access_level) then
					access_level = access_level:lower();
				end
				id_accesses_list[k] = access_level;
			end
		end
	end
	return id_accesses_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	set_error = utilities_page_ptr.set_error;
	select_one = utilities_page_ptr.select_one;
	add_maint_cat = utilities_page_ptr.add_maint_cat;
	substitute = utilities_page_ptr.substitute;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end


return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	extract_id_access_levels = extract_id_access_levels,
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>1h2cafos02sco3ydarswxci7v9b7lk1</sha1>
    </revision>
    <revision>
      <id>4900</id>
      <parentid>4899</parentid>
      <timestamp>2017-10-04T00:50:45Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <minor />
      <comment>ssrn limit -&gt; 3500000;</comment>
      <origin>4900</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="42381" sha1="bhgirhnotg5ivjt09o7i94bxtg9i1rp" xml:space="preserve">
local identifiers = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat, substitute;					-- functions in Module:Citation/CS1/Utilities

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	local ext_link;
	
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	
	ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or &quot;&quot;, mw.text.nowiki(options.id));
	if is_set(options.access) then
		ext_link = substitute (cfg.presentation['access-signal'], {ext_link, cfg.presentation[options.access]});	-- add the free-to-read / paywall lock
	end
	
	return mw.ustring.format( '[[%s|%s]]%s%s', options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;, ext_link);
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
		options.link, options.label, options.separator or &quot;&amp;nbsp;&quot;,
		options.prefix, options.id, options.suffix or &quot;&quot;,
		mw.text.nowiki(options.id)
	);
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in check_isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9'  → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N  _ 1 3 &gt;----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9'  → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; C H E C K _ I S B N &gt;------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function check_isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then
		return false, 'invalid character';										-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );						-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false, 'length';													-- fail if incorrect length
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then								-- fail if isbn_str has 'X' anywhere but last position
			return false, 'invalid form';									
		end
		return is_valid_isxn(isbn_str, 10), 'checksum';
	else
		if isbn_str:match( &quot;^%d+$&quot; ) == nil then
			return false, 'invalid character';									-- fail if isbn13 is not all digits
		end
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then
			return false, 'invalid prefix';										-- fail when isbn13 does not begin with 978 or 979
		end
		return is_valid_isxn_13 (isbn_str), 'checksum';
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;
	local id_copy;

	id_copy = id;																-- save a copy because this testing is destructive
	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id_copy;		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the ismn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]  -- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id, e)
	local issn_copy = id;		-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler;
	local text;
	local valid_issn = true;
	
	if e then
		 handler = cfg.id_handlers['EISSN'];
	else
		 handler = cfg.id_handlers['ISSN'];
	end

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );									-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then		-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;										-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);						-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );	-- if valid, display correctly formatted version
	else
		id = issn_copy;											-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn', e and 'e' or '' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function amazon(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat =  ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then								-- if 10-digit numeric (or 9 digits with terminal X)
			if check_isbn( id ) then												-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat =  ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat =  ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; B I O R X I V &gt;-----------------------------------------------------------------

Format bioRxiv id and do simple error checking.  BiorXiv ids are exactly 6 digits.
The bioRxiv id is the number following the last slash in the bioRxiv-issued DOI:
https://doi.org/10.1101/078733 -&gt; 078733

]]

local function biorxiv(id)
	local handler = cfg.id_handlers['BIORXIV'];
	local err_cat =  '';								-- presume that bioRxiv id is valid
	
	if nil == id:match(&quot;^%d%d%d%d%d%d$&quot;) then				-- if bioRxiv id has anything but six digits
		err_cat = ' ' .. set_error( 'bad_biorxiv');	-- set an error message
    end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator,
			encode=handler.encode, access=handler.access}) .. err_cat;
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat =  '';								-- presume that LCCN is valid
	local id = lccn;									-- local copy of the lccn

	id = normalize_lccn (id);							-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();								-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then						-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 9 == len then								-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then			-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- set an error message
		end
	elseif 10 == len then								-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then							-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then	-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
			end
		end
	elseif 11 == len then								-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	elseif 12 == len then								-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then	-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );	-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );		-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 30000000;						-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat =  '';								-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then							-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );		-- set an error message
	else												-- PMID is only digits
		local id_num = tonumber(id);					-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then		-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );	-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 6000000;													-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat =  '';														-- presume that PMC is valid
	local id_num;
	local text;
	
	id_num = id:match ('^[Pp][Mm][Cc](%d+)$');                                  -- identifier with pmc prefix

	if is_set (id_num) then
		add_maint_cat ('pmc_format');
	else																        -- plain number without pmc prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then								-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );							-- set an error message
		else
			id = tostring (id_num);												-- make sure id is a string
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_pmc' );								-- set an error message
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text=&quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]&quot; .. handler.separator .. id .. err_cat;	-- still embargoed so no external link
	else
		text = external_link_id({link = handler.link, label = handler.label,	-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive, access)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';		-- try to get the year portion from the inactive date
		text = &quot;[[&quot; .. handler.link .. &quot;|&quot; .. handler.label .. &quot;]]:&quot; .. id;
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );	-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	else 
		text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access})
		inactive = &quot;&quot; 
	end

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then	-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end
	return text .. inactive .. cat 
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

]]

local function hdl(id, access)
	local handler = cfg.id_handlers['HDL'];
	
	local text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- hdl must contain a fwd slash, must not contain spaces, endashes, and must not end with period or comma
		text = text .. ' ' .. set_error( 'bad_hdl' );
	end
	return text;
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id, access)
	local code = id:match(&quot;^%d+([AMW])$&quot;);										-- only digits followed by 'A', 'M', or 'W'
	local handler = cfg.id_handlers['OL'];

	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	elseif ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	elseif ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	else
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access}) .. ' ' .. set_error( 'bad_ol' );
	end
end


--[[--------------------------&lt; M E S S A G E _ I D &gt;----------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function message_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_message_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an oclc id.  https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (id)
	local handler = cfg.id_handlers['OCLC'];
	local number;
	local err_msg = '';															-- empty string for concatenation
	
	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- contrain to 1 to 9 digits; change this when oclc issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if 10 &lt; number:len() then
			number = nil;														-- contrain to 1 to 10 digits; change this when oclc issues 11-digit numbers
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		err_msg = ' ' .. set_error( 'bad_oclc' )								-- add an error message if the id is malformed
	end
	
	local text = external_link_id({link=handler.link, label=handler.label,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode}) .. err_msg;

	return text;
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode id.

Format for bibcodes is specified here: http://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6 must be letter, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		7–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		9–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (id, access)
	local handler = cfg.id_handlers['BIBCODE'];
	local err_type;
	local year;

	local text = external_link_id({link=handler.link, label=handler.label,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
		access=access});
	
	if 19 ~= id:len() then
		err_type = 'length';
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%a&amp;%.][%a&amp;%.%d][%a&amp;%.%d][%a%d%.]+[%a%.]$&quot;)	-- 
		if not year then														-- if nil then no pattern match
			err_type = 'value';													-- so value error
		else
			local next_year = tonumber(os.date ('%Y'))+1;						-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = 'year';												-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = 'journal';											-- journal abbreviation must not have '&amp;.' (if it does its missing a letter)
			end
		end
	end

	if is_set (err_type) then													-- if there was an error detected
		text = text .. ' ' .. set_error( 'bad_bibcode', {err_type});
	end
	return text;
end


--[[--------------------------&lt; C I T E S E E R X &gt;------------------------------------------------------------

CiteSeerX use their own notion of &quot;doi&quot; (not to be confused with the identifiers resolved via doi.org).

The description of the structure of this identifier can be found at Help_talk:Citation_Style_1/Archive_26#CiteSeerX_id_structure
]]

local function citeseerx (id)
	local handler = cfg.id_handlers['CITESEERX'];
	local matched;
	
	local text = external_link_id({link=handler.link, label=handler.label,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
		access=handler.access});
	
	matched = id:match (&quot;^10%.1%.1%.[1-9]%d?%d?%d?%.[1-9]%d?%d?%d?$&quot;);
	if not matched then
		text = text .. ' ' .. set_error( 'bad_citeseerx' );
	end
	return text;
end


--[[--------------------------&lt; S S R N &gt;----------------------------------------------------------------------

Format an ssrn, do simple error checking

SSRNs are sequential numbers beginning at 100? and counting up.  This code checks the ssrn to see that it is
only digits and is greater than 99 and less than test_limit; the value in local variable test_limit will need
to be updated periodically as more SSRNs are issued.

]]

local function ssrn (id)
	local test_limit = 3500000;													-- update this value as SSRNs approach
	local handler = cfg.id_handlers['SSRN'];
	local err_cat =  '';														-- presume that SSRN is valid
	local id_num;
	local text;
	
	id_num = id:match ('^%d+$');												-- id must be all digits

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 100 &gt; id_num or test_limit &lt; id_num then								-- if SSRN is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_ssrn' );							-- set an error message
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_ssrn' );								-- set an error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;

	return text;
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v, ['access'] = options.IdAccessLevels[k] }, fallback(k) );

		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'BIBCODE' then
			table.insert( new_list, {handler.label, bibcode( v, handler.access ) } );
		elseif k == 'BIORXIV' then
			table.insert( new_list, {handler.label, biorxiv( v ) } );
		elseif k == 'CITESEERX' then
			table.insert( new_list, {handler.label, citeseerx( v ) } );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken, handler.access ) } );
		elseif k == 'HDL' then
			table.insert( new_list, {handler.label, hdl( v, handler.access ) } );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } ); 
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v, handler.access ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'OCLC' then
			table.insert( new_list, {handler.label, oclc( v ) } );
		elseif k == 'SSRN' then
			table.insert( new_list, {handler.label, ssrn( v ) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'EISSN' then
			table.insert( new_list, {handler.label, issn( v, true ) } );		-- true distinguishes eissn from issn
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			local check;
			local err_type = '';
			check, err_type = check_isbn( v );
			if not check then
				if is_set(options.IgnoreISBN) then								-- ISBN is invalid; if |ignore-isbn-error= set
					add_maint_cat ('ignore_isbn_err');							-- ad a maint category
				else
					ISBN = ISBN .. set_error( 'bad_isbn', {err_type}, false, &quot; &quot;, &quot;&quot; );	-- else display an error message
				end
			elseif is_set(options.IgnoreISBN) then								-- ISBN is OK; if |ignore-isbn-error= set
					add_maint_cat ('ignore_isbn_err');							-- because |ignore-isbn-error= unnecessary
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, message_id( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1] &lt; b[1];
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; E X T R A C T _ I D _ A C C E S S _ L E V E L S &gt;--------------------------------------

Fetches custom id access levels from arguments using configuration settings.
Parameters which have a predefined access level (e.g. arxiv) do not use this
function as they are directly rendered as free without using an additional parameter.

]]

local function extract_id_access_levels( args, id_list )
	local id_accesses_list = {};
	for k, v in pairs( cfg.id_handlers ) do
		local access_param = v.custom_access;
		local k_lower = string.lower(k);
		if is_set(access_param) then
			local access_level = args[access_param];
			if is_set(access_level) then
				if not in_array (access_level:lower(), cfg.keywords['id-access']) then
					table.insert( z.message_tail, { set_error( 'invalid_param_val', {access_param, access_level}, true ) } );	
					access_level = nil;
				end
				if not is_set(id_list[k]) then
					table.insert( z.message_tail, { set_error( 'param_access_requires_param', {k_lower}, true ) } );
				end
				if is_set(access_level) then
					access_level = access_level:lower();
				end
				id_accesses_list[k] = access_level;
			end
		end
	end
	return id_accesses_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	set_error = utilities_page_ptr.set_error;
	select_one = utilities_page_ptr.select_one;
	add_maint_cat = utilities_page_ptr.add_maint_cat;
	substitute = utilities_page_ptr.substitute;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end


return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	extract_id_access_levels = extract_id_access_levels,
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>bhgirhnotg5ivjt09o7i94bxtg9i1rp</sha1>
    </revision>
    <revision>
      <id>4901</id>
      <parentid>4900</parentid>
      <timestamp>2017-11-04T10:41:18Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>synch from sandbox;</comment>
      <origin>4901</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="46388" sha1="fnb76zqarlm5zeitaqe4nssz9b5w3bk" xml:space="preserve">
local identifiers = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat, substitute, make_wikilink;	-- functions in Module:Citation/CS1/Utilities

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--============================&lt;&lt; H E L P E R   F U N C T I O N S &gt;&gt;============================================

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	local ext_link;
	
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	
	ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or &quot;&quot;, mw.text.nowiki(options.id));
	if is_set(options.access) then
		ext_link = substitute (cfg.presentation['access-signal'], {ext_link, cfg.presentation[options.access]});	-- add the free-to-read / paywall lock
	end
	
	return table.concat	({
		make_wikilink (options.link, options.label),
		options.separator or '&amp;nbsp;',
		ext_link
		});
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)

	return table.concat (
		{
		make_wikilink (options.link, options.label),
		options.separator or '&amp;nbsp;',
		make_wikilink (
			table.concat (
				{
				options.prefix,
				options.id,
				options.suffix or ''
				}),
			mw.text.nowiki (options.id)
			);
		});
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9' → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N _ 1 3 &gt;-----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--============================&lt;&lt; I D E N T I F I E R   F U N C T I O N S &gt;&gt;====================================

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

]]

local function asin(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat = ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then							-- if 10-digit numeric (or 9 digits with terminal X)
			if isbn( id ) then													-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat = ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat = ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode id.

Format for bibcodes is specified here: http://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6 must be letter, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		7–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		9–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (id, access)
	local handler = cfg.id_handlers['BIBCODE'];
	local err_type;
	local year;

	local text = external_link_id({link=handler.link, label=handler.label,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
		access=access});
	
	if 19 ~= id:len() then
		err_type = 'length';
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%a&amp;%.][%a&amp;%.%d][%a&amp;%.%d][%a%d%.]+[%a%.]$&quot;)	-- 
		if not year then														-- if nil then no pattern match
			err_type = 'value';													-- so value error
		else
			local next_year = tonumber(os.date ('%Y'))+1;						-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = 'year';												-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = 'journal';											-- journal abbreviation must not have '&amp;.' (if it does its missing a letter)
			end
		end
	end

	if is_set (err_type) then													-- if there was an error detected
		text = text .. ' ' .. set_error( 'bad_bibcode', {err_type});
	end
	return text;
end


--[[--------------------------&lt; B I O R X I V &gt;-----------------------------------------------------------------

Format bioRxiv id and do simple error checking.  BiorXiv ids are exactly 6 digits.
The bioRxiv id is the number following the last slash in the bioRxiv-issued DOI:
https://doi.org/10.1101/078733 -&gt; 078733

]]

local function biorxiv(id)
	local handler = cfg.id_handlers['BIORXIV'];
	local err_cat = '';															-- presume that bioRxiv id is valid
	
	if nil == id:match(&quot;^%d%d%d%d%d%d$&quot;) then									-- if bioRxiv id has anything but six digits
		err_cat = ' ' .. set_error( 'bad_biorxiv');	-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator,
			encode=handler.encode, access=handler.access}) .. err_cat;
end


--[[--------------------------&lt; C I T E S E E R X &gt;------------------------------------------------------------

CiteSeerX use their own notion of &quot;doi&quot; (not to be confused with the identifiers resolved via doi.org).

The description of the structure of this identifier can be found at Help_talk:Citation_Style_1/Archive_26#CiteSeerX_id_structure
]]

local function citeseerx (id)
	local handler = cfg.id_handlers['CITESEERX'];
	local matched;
	
	local text = external_link_id({link=handler.link, label=handler.label,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
		access=handler.access});
	
	matched = id:match (&quot;^10%.1%.1%.[1-9]%d?%d?%d?%.[1-9]%d?%d?%d?$&quot;);
	if not matched then
		text = text .. ' ' .. set_error( 'bad_citeseerx' );
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive, access)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';					-- try to get the year portion from the inactive date
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );		-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	end
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access}) .. (inactive or '')

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then						-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end

	return text .. cat 
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

]]

local function hdl(id, access)
	local handler = cfg.id_handlers['HDL'];
	
	local text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- hdl must contain a fwd slash, must not contain spaces, endashes, and must not end with period or comma
		text = text .. ' ' .. set_error( 'bad_hdl' );
	end
	return text;
end


--[[--------------------------&lt; I S B N &gt;----------------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then
		return false, 'invalid character';										-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );						-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false, 'length';													-- fail if incorrect length
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then								-- fail if isbn_str has 'X' anywhere but last position
			return false, 'invalid form';									
		end
		return is_valid_isxn(isbn_str, 10), 'checksum';
	else
		if isbn_str:match( &quot;^%d+$&quot; ) == nil then
			return false, 'invalid character';									-- fail if isbn13 is not all digits
		end
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then
			return false, 'invalid prefix';										-- fail when isbn13 does not begin with 978 or 979
		end
		return is_valid_isxn_13 (isbn_str), 'checksum';
	end
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;
	local id_copy;

	id_copy = id;																-- save a copy because this testing is destructive
	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text = table.concat (
		{
		make_wikilink (handler.link, handler.label),
		handler.separator,
		id_copy
		});		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the ismn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]	-- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id, e)
	local issn_copy = id;														-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler;
	local text;
	local valid_issn = true;
	
	if e then
		 handler = cfg.id_handlers['EISSN'];
	else
		 handler = cfg.id_handlers['ISSN'];
	end

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then						-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;														-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);										-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );				-- if valid, display correctly formatted version
	else
		id = issn_copy;															-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn', e and 'e' or '' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; J F M &gt;-----------------------------------------------------------------------

A numerical identifier in the form nn.nnnn.nn

]]

local function jfm (id)
	local handler = cfg.id_handlers['JFM'];
	local id_num;
	local err_cat = '';
	
	id_num = id:match ('^[Jj][Ff][Mm](.*)$');									-- identifier with jfm prefix; extract identifier

	if is_set (id_num) then
		add_maint_cat ('jfm_format');
	else																		-- plain number without mr prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num and id_num:match('^%d%d%.%d%d%d%d%.%d%d$') then
		id = id_num;															-- jfm matches pattern
	else
		err_cat = ' ' .. set_error( 'bad_jfm' );								-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat = '';															-- presume that LCCN is valid
	local id = lccn;															-- local copy of the lccn

	id = normalize_lccn (id);													-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();														-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- set an error message
		end
	elseif 9 == len then														-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then							-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- set an error message
		end
	elseif 10 == len then														-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then					-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );						-- no match, set an error message
			end
		end
	elseif 11 == len then														-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- no match, set an error message
		end
	elseif 12 == len then														-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then						-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );								-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );								-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; M R &gt;--------------------------------------------------------------------------

A seven digit number; if not seven digits, zero-fill leading digits to make seven digits.

]]

local function mr (id)
	local handler = cfg.id_handlers['MR'];
	local id_num;
	local id_len;
	local err_cat = '';
	
	id_num = id:match ('^[Mm][Rr](%d+)$');										-- identifier with mr prefix

	if is_set (id_num) then
		add_maint_cat ('mr_format');
	else																		-- plain number without mr prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	id_len = id_num and id_num:len() or 0;
	if (7 &gt;= id_len) and (0 ~= id_len) then
		id = string.rep ('0', 7-id_len ) .. id_num;								-- zero-fill leading digits
	else
		err_cat = ' ' .. set_error( 'bad_mr' );									-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an oclc id.  https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (id)
	local handler = cfg.id_handlers['OCLC'];
	local number;
	local err_msg = '';															-- empty string for concatenation
	
	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- contrain to 1 to 9 digits; change this when oclc issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if 10 &lt; number:len() then
			number = nil;														-- contrain to 1 to 10 digits; change this when oclc issues 11-digit numbers
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		err_msg = ' ' .. set_error( 'bad_oclc' )								-- add an error message if the id is malformed
	end
	
	local text = external_link_id({link=handler.link, label=handler.label,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode}) .. err_msg;

	return text;
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id, access)
	local code;
	local handler = cfg.id_handlers['OL'];
	local ident;
	
	ident, code = id:gsub('^OL', ''):match(&quot;^(%d+([AMW]))$&quot;);					-- optional OL prefix followed immediately by digits followed by 'A', 'M', or 'W'; remove OL prefix

	if not is_set (ident) then													-- if malformed return an error
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access}) .. ' ' .. set_error( 'bad_ol' );
	end
	
	id = ident;																	-- use ident without the optional OL prefix (it has been removed)
	
	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end
	
	if ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end

	if ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 6000000;													-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat = '';															-- presume that PMC is valid
	local id_num;
	local text;
	
	id_num = id:match ('^[Pp][Mm][Cc](%d+)$');									-- identifier with pmc prefix

	if is_set (id_num) then
		add_maint_cat ('pmc_format');
	else																		-- plain number without pmc prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then								-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );							-- set an error message
		else
			id = tostring (id_num);												-- make sure id is a string
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_pmc' );								-- set an error message
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text = table.concat (													-- still embargoed so no external link
			{
			make_wikilink (handler.link, handler.label),
			handler.separator,
			id,
			err_cat
			});
	else
		text = external_link_id({link = handler.link, label = handler.label,	-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 32000000;												-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat = '';															-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then													-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );								-- set an error message
	else																		-- PMID is only digits
		local id_num = tonumber(id);											-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then								-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );							-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; S S R N &gt;----------------------------------------------------------------------

Format an ssrn, do simple error checking

SSRNs are sequential numbers beginning at 100? and counting up.  This code checks the ssrn to see that it is
only digits and is greater than 99 and less than test_limit; the value in local variable test_limit will need
to be updated periodically as more SSRNs are issued.

]]

local function ssrn (id)
	local test_limit = 3500000;													-- update this value as SSRNs approach
	local handler = cfg.id_handlers['SSRN'];
	local err_cat = '';															-- presume that SSRN is valid
	local id_num;
	local text;
	
	id_num = id:match ('^%d+$');												-- id must be all digits

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 100 &gt; id_num or test_limit &lt; id_num then								-- if SSRN is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_ssrn' );							-- set an error message
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_ssrn' );								-- set an error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;

	return text;
end


--[[--------------------------&lt; U S E N E T _ I D &gt;------------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function usenet_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_usenet_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; Z B L &gt;-----------------------------------------------------------------------

A numerical identifier in the form nnnn.nnnnn - leading zeros in the first quartet optional

]]

local function zbl (id)
	local handler = cfg.id_handlers['ZBL'];
	local id_num;
	local err_cat = '';
	
	id_num = id:match ('^[Zz][Bb][Ll](.*)$');									-- identifier with zbl prefix; extract identifier

	if is_set (id_num) then
		add_maint_cat ('zbl_format');
	else																		-- plain number without zbl prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num:match('^%d?%d?%d?%d%.%d%d%d%d%d$') then
		id = id_num;															-- id matches pattern
	else
		err_cat = ' ' .. set_error( 'bad_zbl' );								-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--============================&lt;&lt; I N T E R F A C E   F U N C T I O N S &gt;&gt;==========================================

--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v, ['access'] = options.IdAccessLevels[k] }, fallback(k) );

		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, asin( v, options.ASINTLD ) } ); 
		elseif k == 'BIBCODE' then
			table.insert( new_list, {handler.label, bibcode( v, handler.access ) } );
		elseif k == 'BIORXIV' then
			table.insert( new_list, {handler.label, biorxiv( v ) } );
		elseif k == 'CITESEERX' then
			table.insert( new_list, {handler.label, citeseerx( v ) } );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken, handler.access ) } );
		elseif k == 'EISSN' then
			table.insert( new_list, {handler.label, issn( v, true ) } );		-- true distinguishes eissn from issn
		elseif k == 'HDL' then
			table.insert( new_list, {handler.label, hdl( v, handler.access ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			local check;
			local err_type = '';
			check, err_type = isbn( v );
			if not check then
				if is_set(options.IgnoreISBN) then								-- ISBN is invalid; if |ignore-isbn-error= set
					add_maint_cat ('ignore_isbn_err');							-- ad a maint category
				else
					ISBN = ISBN .. set_error( 'bad_isbn', {err_type}, false, &quot; &quot;, &quot;&quot; );	-- else display an error message
				end
			elseif is_set(options.IgnoreISBN) then								-- ISBN is OK; if |ignore-isbn-error= set
				add_maint_cat ('ignore_isbn_err');								-- because |ignore-isbn-error= unnecessary
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'JFM' then
			table.insert( new_list, {handler.label, jfm( v ) } );
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'MR' then
			table.insert( new_list, {handler.label, mr( v ) } );
		elseif k == 'OCLC' then
			table.insert( new_list, {handler.label, oclc( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v, handler.access ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'SSRN' then
			table.insert( new_list, {handler.label, ssrn( v ) } );
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, usenet_id( v ) } );
		elseif k == 'ZBL' then
			table.insert( new_list, {handler.label, zbl( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1]:lower() &lt; b[1]:lower();
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; E X T R A C T _ I D _ A C C E S S _ L E V E L S &gt;--------------------------------------

Fetches custom id access levels from arguments using configuration settings.
Parameters which have a predefined access level (e.g. arxiv) do not use this
function as they are directly rendered as free without using an additional parameter.

]]

local function extract_id_access_levels( args, id_list )
	local id_accesses_list = {};
	for k, v in pairs( cfg.id_handlers ) do
		local access_param = v.custom_access;
		local k_lower = string.lower(k);
		if is_set(access_param) then
			local access_level = args[access_param];
			if is_set(access_level) then
				if not in_array (access_level:lower(), cfg.keywords['id-access']) then
					table.insert( z.message_tail, { set_error( 'invalid_param_val', {access_param, access_level}, true ) } );	
					access_level = nil;
				end
				if not is_set(id_list[k]) then
					table.insert( z.message_tail, { set_error( 'param_access_requires_param', {k_lower}, true ) } );
				end
				if is_set(access_level) then
					access_level = access_level:lower();
				end
				id_accesses_list[k] = access_level;
			end
		end
	end
	return id_accesses_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	set_error = utilities_page_ptr.set_error;
	select_one = utilities_page_ptr.select_one;
	add_maint_cat = utilities_page_ptr.add_maint_cat;
	substitute = utilities_page_ptr.substitute;
	make_wikilink = utilities_page_ptr.make_wikilink;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end


return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	extract_id_access_levels = extract_id_access_levels,
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>fnb76zqarlm5zeitaqe4nssz9b5w3bk</sha1>
    </revision>
    <revision>
      <id>4902</id>
      <parentid>4901</parentid>
      <timestamp>2017-11-04T11:07:23Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>asin() calls isbn() so asin() must follow isbn();</comment>
      <origin>4902</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="46446" sha1="kg8ng3yyy7h87bxt8aj5samd9gdseeq" xml:space="preserve">
local identifiers = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat, substitute, make_wikilink;	-- functions in Module:Citation/CS1/Utilities

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--============================&lt;&lt; H E L P E R   F U N C T I O N S &gt;&gt;============================================

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	local ext_link;
	
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	
	ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or &quot;&quot;, mw.text.nowiki(options.id));
	if is_set(options.access) then
		ext_link = substitute (cfg.presentation['access-signal'], {ext_link, cfg.presentation[options.access]});	-- add the free-to-read / paywall lock
	end
	
	return table.concat	({
		make_wikilink (options.link, options.label),
		options.separator or '&amp;nbsp;',
		ext_link
		});
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)

	return table.concat (
		{
		make_wikilink (options.link, options.label),
		options.separator or '&amp;nbsp;',
		make_wikilink (
			table.concat (
				{
				options.prefix,
				options.id,
				options.suffix or ''
				}),
			mw.text.nowiki (options.id)
			);
		});
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9' → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N _ 1 3 &gt;-----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--============================&lt;&lt; I D E N T I F I E R   F U N C T I O N S &gt;&gt;====================================

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode id.

Format for bibcodes is specified here: http://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6 must be letter, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		7–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		9–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (id, access)
	local handler = cfg.id_handlers['BIBCODE'];
	local err_type;
	local year;

	local text = external_link_id({link=handler.link, label=handler.label,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
		access=access});
	
	if 19 ~= id:len() then
		err_type = 'length';
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%a&amp;%.][%a&amp;%.%d][%a&amp;%.%d][%a%d%.]+[%a%.]$&quot;)	-- 
		if not year then														-- if nil then no pattern match
			err_type = 'value';													-- so value error
		else
			local next_year = tonumber(os.date ('%Y'))+1;						-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = 'year';												-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = 'journal';											-- journal abbreviation must not have '&amp;.' (if it does its missing a letter)
			end
		end
	end

	if is_set (err_type) then													-- if there was an error detected
		text = text .. ' ' .. set_error( 'bad_bibcode', {err_type});
	end
	return text;
end


--[[--------------------------&lt; B I O R X I V &gt;-----------------------------------------------------------------

Format bioRxiv id and do simple error checking.  BiorXiv ids are exactly 6 digits.
The bioRxiv id is the number following the last slash in the bioRxiv-issued DOI:
https://doi.org/10.1101/078733 -&gt; 078733

]]

local function biorxiv(id)
	local handler = cfg.id_handlers['BIORXIV'];
	local err_cat = '';															-- presume that bioRxiv id is valid
	
	if nil == id:match(&quot;^%d%d%d%d%d%d$&quot;) then									-- if bioRxiv id has anything but six digits
		err_cat = ' ' .. set_error( 'bad_biorxiv');	-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator,
			encode=handler.encode, access=handler.access}) .. err_cat;
end


--[[--------------------------&lt; C I T E S E E R X &gt;------------------------------------------------------------

CiteSeerX use their own notion of &quot;doi&quot; (not to be confused with the identifiers resolved via doi.org).

The description of the structure of this identifier can be found at Help_talk:Citation_Style_1/Archive_26#CiteSeerX_id_structure
]]

local function citeseerx (id)
	local handler = cfg.id_handlers['CITESEERX'];
	local matched;
	
	local text = external_link_id({link=handler.link, label=handler.label,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
		access=handler.access});
	
	matched = id:match (&quot;^10%.1%.1%.[1-9]%d?%d?%d?%.[1-9]%d?%d?%d?$&quot;);
	if not matched then
		text = text .. ' ' .. set_error( 'bad_citeseerx' );
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive, access)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';					-- try to get the year portion from the inactive date
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );		-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	end
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access}) .. (inactive or '')

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then						-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end

	return text .. cat 
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

]]

local function hdl(id, access)
	local handler = cfg.id_handlers['HDL'];
	
	local text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- hdl must contain a fwd slash, must not contain spaces, endashes, and must not end with period or comma
		text = text .. ' ' .. set_error( 'bad_hdl' );
	end
	return text;
end


--[[--------------------------&lt; I S B N &gt;----------------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then
		return false, 'invalid character';										-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );						-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false, 'length';													-- fail if incorrect length
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then								-- fail if isbn_str has 'X' anywhere but last position
			return false, 'invalid form';									
		end
		return is_valid_isxn(isbn_str, 10), 'checksum';
	else
		if isbn_str:match( &quot;^%d+$&quot; ) == nil then
			return false, 'invalid character';									-- fail if isbn13 is not all digits
		end
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then
			return false, 'invalid prefix';										-- fail when isbn13 does not begin with 978 or 979
		end
		return is_valid_isxn_13 (isbn_str), 'checksum';
	end
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

This function is positioned here because it calls isbn()

]]

local function asin(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat = ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then							-- if 10-digit numeric (or 9 digits with terminal X)
			if isbn( id ) then													-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat = ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat = ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;
	local id_copy;

	id_copy = id;																-- save a copy because this testing is destructive
	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text = table.concat (
		{
		make_wikilink (handler.link, handler.label),
		handler.separator,
		id_copy
		});		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the ismn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]	-- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id, e)
	local issn_copy = id;														-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler;
	local text;
	local valid_issn = true;
	
	if e then
		 handler = cfg.id_handlers['EISSN'];
	else
		 handler = cfg.id_handlers['ISSN'];
	end

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then						-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;														-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);										-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );				-- if valid, display correctly formatted version
	else
		id = issn_copy;															-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn', e and 'e' or '' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; J F M &gt;-----------------------------------------------------------------------

A numerical identifier in the form nn.nnnn.nn

]]

local function jfm (id)
	local handler = cfg.id_handlers['JFM'];
	local id_num;
	local err_cat = '';
	
	id_num = id:match ('^[Jj][Ff][Mm](.*)$');									-- identifier with jfm prefix; extract identifier

	if is_set (id_num) then
		add_maint_cat ('jfm_format');
	else																		-- plain number without mr prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num and id_num:match('^%d%d%.%d%d%d%d%.%d%d$') then
		id = id_num;															-- jfm matches pattern
	else
		err_cat = ' ' .. set_error( 'bad_jfm' );								-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat = '';															-- presume that LCCN is valid
	local id = lccn;															-- local copy of the lccn

	id = normalize_lccn (id);													-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();														-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- set an error message
		end
	elseif 9 == len then														-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then							-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- set an error message
		end
	elseif 10 == len then														-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then					-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );						-- no match, set an error message
			end
		end
	elseif 11 == len then														-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- no match, set an error message
		end
	elseif 12 == len then														-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then						-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );								-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );								-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; M R &gt;--------------------------------------------------------------------------

A seven digit number; if not seven digits, zero-fill leading digits to make seven digits.

]]

local function mr (id)
	local handler = cfg.id_handlers['MR'];
	local id_num;
	local id_len;
	local err_cat = '';
	
	id_num = id:match ('^[Mm][Rr](%d+)$');										-- identifier with mr prefix

	if is_set (id_num) then
		add_maint_cat ('mr_format');
	else																		-- plain number without mr prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	id_len = id_num and id_num:len() or 0;
	if (7 &gt;= id_len) and (0 ~= id_len) then
		id = string.rep ('0', 7-id_len ) .. id_num;								-- zero-fill leading digits
	else
		err_cat = ' ' .. set_error( 'bad_mr' );									-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an oclc id.  https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (id)
	local handler = cfg.id_handlers['OCLC'];
	local number;
	local err_msg = '';															-- empty string for concatenation
	
	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- contrain to 1 to 9 digits; change this when oclc issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if 10 &lt; number:len() then
			number = nil;														-- contrain to 1 to 10 digits; change this when oclc issues 11-digit numbers
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		err_msg = ' ' .. set_error( 'bad_oclc' )								-- add an error message if the id is malformed
	end
	
	local text = external_link_id({link=handler.link, label=handler.label,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode}) .. err_msg;

	return text;
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id, access)
	local code;
	local handler = cfg.id_handlers['OL'];
	local ident;
	
	ident, code = id:gsub('^OL', ''):match(&quot;^(%d+([AMW]))$&quot;);					-- optional OL prefix followed immediately by digits followed by 'A', 'M', or 'W'; remove OL prefix

	if not is_set (ident) then													-- if malformed return an error
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access}) .. ' ' .. set_error( 'bad_ol' );
	end
	
	id = ident;																	-- use ident without the optional OL prefix (it has been removed)
	
	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end
	
	if ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end

	if ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 6000000;													-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat = '';															-- presume that PMC is valid
	local id_num;
	local text;
	
	id_num = id:match ('^[Pp][Mm][Cc](%d+)$');									-- identifier with pmc prefix

	if is_set (id_num) then
		add_maint_cat ('pmc_format');
	else																		-- plain number without pmc prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then								-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );							-- set an error message
		else
			id = tostring (id_num);												-- make sure id is a string
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_pmc' );								-- set an error message
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text = table.concat (													-- still embargoed so no external link
			{
			make_wikilink (handler.link, handler.label),
			handler.separator,
			id,
			err_cat
			});
	else
		text = external_link_id({link = handler.link, label = handler.label,	-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 32000000;												-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat = '';															-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then													-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );								-- set an error message
	else																		-- PMID is only digits
		local id_num = tonumber(id);											-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then								-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );							-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; S S R N &gt;----------------------------------------------------------------------

Format an ssrn, do simple error checking

SSRNs are sequential numbers beginning at 100? and counting up.  This code checks the ssrn to see that it is
only digits and is greater than 99 and less than test_limit; the value in local variable test_limit will need
to be updated periodically as more SSRNs are issued.

]]

local function ssrn (id)
	local test_limit = 3500000;													-- update this value as SSRNs approach
	local handler = cfg.id_handlers['SSRN'];
	local err_cat = '';															-- presume that SSRN is valid
	local id_num;
	local text;
	
	id_num = id:match ('^%d+$');												-- id must be all digits

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 100 &gt; id_num or test_limit &lt; id_num then								-- if SSRN is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_ssrn' );							-- set an error message
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_ssrn' );								-- set an error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;

	return text;
end


--[[--------------------------&lt; U S E N E T _ I D &gt;------------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function usenet_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_usenet_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; Z B L &gt;-----------------------------------------------------------------------

A numerical identifier in the form nnnn.nnnnn - leading zeros in the first quartet optional

]]

local function zbl (id)
	local handler = cfg.id_handlers['ZBL'];
	local id_num;
	local err_cat = '';
	
	id_num = id:match ('^[Zz][Bb][Ll](.*)$');									-- identifier with zbl prefix; extract identifier

	if is_set (id_num) then
		add_maint_cat ('zbl_format');
	else																		-- plain number without zbl prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num:match('^%d?%d?%d?%d%.%d%d%d%d%d$') then
		id = id_num;															-- id matches pattern
	else
		err_cat = ' ' .. set_error( 'bad_zbl' );								-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--============================&lt;&lt; I N T E R F A C E   F U N C T I O N S &gt;&gt;==========================================

--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v, ['access'] = options.IdAccessLevels[k] }, fallback(k) );

		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, asin( v, options.ASINTLD ) } ); 
		elseif k == 'BIBCODE' then
			table.insert( new_list, {handler.label, bibcode( v, handler.access ) } );
		elseif k == 'BIORXIV' then
			table.insert( new_list, {handler.label, biorxiv( v ) } );
		elseif k == 'CITESEERX' then
			table.insert( new_list, {handler.label, citeseerx( v ) } );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken, handler.access ) } );
		elseif k == 'EISSN' then
			table.insert( new_list, {handler.label, issn( v, true ) } );		-- true distinguishes eissn from issn
		elseif k == 'HDL' then
			table.insert( new_list, {handler.label, hdl( v, handler.access ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			local check;
			local err_type = '';
			check, err_type = isbn( v );
			if not check then
				if is_set(options.IgnoreISBN) then								-- ISBN is invalid; if |ignore-isbn-error= set
					add_maint_cat ('ignore_isbn_err');							-- ad a maint category
				else
					ISBN = ISBN .. set_error( 'bad_isbn', {err_type}, false, &quot; &quot;, &quot;&quot; );	-- else display an error message
				end
			elseif is_set(options.IgnoreISBN) then								-- ISBN is OK; if |ignore-isbn-error= set
				add_maint_cat ('ignore_isbn_err');								-- because |ignore-isbn-error= unnecessary
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'JFM' then
			table.insert( new_list, {handler.label, jfm( v ) } );
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'MR' then
			table.insert( new_list, {handler.label, mr( v ) } );
		elseif k == 'OCLC' then
			table.insert( new_list, {handler.label, oclc( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v, handler.access ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'SSRN' then
			table.insert( new_list, {handler.label, ssrn( v ) } );
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, usenet_id( v ) } );
		elseif k == 'ZBL' then
			table.insert( new_list, {handler.label, zbl( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1]:lower() &lt; b[1]:lower();
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; E X T R A C T _ I D _ A C C E S S _ L E V E L S &gt;--------------------------------------

Fetches custom id access levels from arguments using configuration settings.
Parameters which have a predefined access level (e.g. arxiv) do not use this
function as they are directly rendered as free without using an additional parameter.

]]

local function extract_id_access_levels( args, id_list )
	local id_accesses_list = {};
	for k, v in pairs( cfg.id_handlers ) do
		local access_param = v.custom_access;
		local k_lower = string.lower(k);
		if is_set(access_param) then
			local access_level = args[access_param];
			if is_set(access_level) then
				if not in_array (access_level:lower(), cfg.keywords['id-access']) then
					table.insert( z.message_tail, { set_error( 'invalid_param_val', {access_param, access_level}, true ) } );	
					access_level = nil;
				end
				if not is_set(id_list[k]) then
					table.insert( z.message_tail, { set_error( 'param_access_requires_param', {k_lower}, true ) } );
				end
				if is_set(access_level) then
					access_level = access_level:lower();
				end
				id_accesses_list[k] = access_level;
			end
		end
	end
	return id_accesses_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	set_error = utilities_page_ptr.set_error;
	select_one = utilities_page_ptr.select_one;
	add_maint_cat = utilities_page_ptr.add_maint_cat;
	substitute = utilities_page_ptr.substitute;
	make_wikilink = utilities_page_ptr.make_wikilink;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end


return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	extract_id_access_levels = extract_id_access_levels,
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>kg8ng3yyy7h87bxt8aj5samd9gdseeq</sha1>
    </revision>
    <revision>
      <id>4903</id>
      <parentid>4902</parentid>
      <timestamp>2018-06-19T22:35:24Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>pmc limit adjust;</comment>
      <origin>4903</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="46446" sha1="0sr6adsai6gph5uwswossvp9tua1xqf" xml:space="preserve">
local identifiers = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat, substitute, make_wikilink;	-- functions in Module:Citation/CS1/Utilities

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--============================&lt;&lt; H E L P E R   F U N C T I O N S &gt;&gt;============================================

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	local ext_link;
	
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end
	
	ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or &quot;&quot;, mw.text.nowiki(options.id));
	if is_set(options.access) then
		ext_link = substitute (cfg.presentation['access-signal'], {ext_link, cfg.presentation[options.access]});	-- add the free-to-read / paywall lock
	end
	
	return table.concat	({
		make_wikilink (options.link, options.label),
		options.separator or '&amp;nbsp;',
		ext_link
		});
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)

	return table.concat (
		{
		make_wikilink (options.link, options.label),
		options.separator or '&amp;nbsp;',
		make_wikilink (
			table.concat (
				{
				options.prefix,
				options.id,
				options.suffix or ''
				}),
			mw.text.nowiki (options.id)
			);
		});
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9' → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N _ 1 3 &gt;-----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--============================&lt;&lt; I D E N T I F I E R   F U N C T I O N S &gt;&gt;====================================

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode id.

Format for bibcodes is specified here: http://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6 must be letter, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		7–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		9–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (id, access)
	local handler = cfg.id_handlers['BIBCODE'];
	local err_type;
	local year;

	local text = external_link_id({link=handler.link, label=handler.label,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
		access=access});
	
	if 19 ~= id:len() then
		err_type = 'length';
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%a&amp;%.][%a&amp;%.%d][%a&amp;%.%d][%a%d%.]+[%a%.]$&quot;)	-- 
		if not year then														-- if nil then no pattern match
			err_type = 'value';													-- so value error
		else
			local next_year = tonumber(os.date ('%Y'))+1;						-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = 'year';												-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = 'journal';											-- journal abbreviation must not have '&amp;.' (if it does its missing a letter)
			end
		end
	end

	if is_set (err_type) then													-- if there was an error detected
		text = text .. ' ' .. set_error( 'bad_bibcode', {err_type});
	end
	return text;
end


--[[--------------------------&lt; B I O R X I V &gt;-----------------------------------------------------------------

Format bioRxiv id and do simple error checking.  BiorXiv ids are exactly 6 digits.
The bioRxiv id is the number following the last slash in the bioRxiv-issued DOI:
https://doi.org/10.1101/078733 -&gt; 078733

]]

local function biorxiv(id)
	local handler = cfg.id_handlers['BIORXIV'];
	local err_cat = '';															-- presume that bioRxiv id is valid
	
	if nil == id:match(&quot;^%d%d%d%d%d%d$&quot;) then									-- if bioRxiv id has anything but six digits
		err_cat = ' ' .. set_error( 'bad_biorxiv');	-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator,
			encode=handler.encode, access=handler.access}) .. err_cat;
end


--[[--------------------------&lt; C I T E S E E R X &gt;------------------------------------------------------------

CiteSeerX use their own notion of &quot;doi&quot; (not to be confused with the identifiers resolved via doi.org).

The description of the structure of this identifier can be found at Help_talk:Citation_Style_1/Archive_26#CiteSeerX_id_structure
]]

local function citeseerx (id)
	local handler = cfg.id_handlers['CITESEERX'];
	local matched;
	
	local text = external_link_id({link=handler.link, label=handler.label,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
		access=handler.access});
	
	matched = id:match (&quot;^10%.1%.1%.[1-9]%d?%d?%d?%.[1-9]%d?%d?%d?$&quot;);
	if not matched then
		text = text .. ' ' .. set_error( 'bad_citeseerx' );
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive, access)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';					-- try to get the year portion from the inactive date
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );		-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	end
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access}) .. (inactive or '')

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then						-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end

	return text .. cat 
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

]]

local function hdl(id, access)
	local handler = cfg.id_handlers['HDL'];
	
	local text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- hdl must contain a fwd slash, must not contain spaces, endashes, and must not end with period or comma
		text = text .. ' ' .. set_error( 'bad_hdl' );
	end
	return text;
end


--[[--------------------------&lt; I S B N &gt;----------------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then
		return false, 'invalid character';										-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );						-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false, 'length';													-- fail if incorrect length
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then								-- fail if isbn_str has 'X' anywhere but last position
			return false, 'invalid form';									
		end
		return is_valid_isxn(isbn_str, 10), 'checksum';
	else
		if isbn_str:match( &quot;^%d+$&quot; ) == nil then
			return false, 'invalid character';									-- fail if isbn13 is not all digits
		end
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then
			return false, 'invalid prefix';										-- fail when isbn13 does not begin with 978 or 979
		end
		return is_valid_isxn_13 (isbn_str), 'checksum';
	end
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

This function is positioned here because it calls isbn()

]]

local function asin(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat = ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then							-- if 10-digit numeric (or 9 digits with terminal X)
			if isbn( id ) then													-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat = ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat = ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;
	local id_copy;

	id_copy = id;																-- save a copy because this testing is destructive
	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text = table.concat (
		{
		make_wikilink (handler.link, handler.label),
		handler.separator,
		id_copy
		});		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the ismn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]	-- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id, e)
	local issn_copy = id;														-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler;
	local text;
	local valid_issn = true;
	
	if e then
		 handler = cfg.id_handlers['EISSN'];
	else
		 handler = cfg.id_handlers['ISSN'];
	end

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then						-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;														-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);										-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );				-- if valid, display correctly formatted version
	else
		id = issn_copy;															-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn', e and 'e' or '' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; J F M &gt;-----------------------------------------------------------------------

A numerical identifier in the form nn.nnnn.nn

]]

local function jfm (id)
	local handler = cfg.id_handlers['JFM'];
	local id_num;
	local err_cat = '';
	
	id_num = id:match ('^[Jj][Ff][Mm](.*)$');									-- identifier with jfm prefix; extract identifier

	if is_set (id_num) then
		add_maint_cat ('jfm_format');
	else																		-- plain number without mr prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num and id_num:match('^%d%d%.%d%d%d%d%.%d%d$') then
		id = id_num;															-- jfm matches pattern
	else
		err_cat = ' ' .. set_error( 'bad_jfm' );								-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat = '';															-- presume that LCCN is valid
	local id = lccn;															-- local copy of the lccn

	id = normalize_lccn (id);													-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();														-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- set an error message
		end
	elseif 9 == len then														-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then							-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- set an error message
		end
	elseif 10 == len then														-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then					-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );						-- no match, set an error message
			end
		end
	elseif 11 == len then														-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- no match, set an error message
		end
	elseif 12 == len then														-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then						-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );								-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );								-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; M R &gt;--------------------------------------------------------------------------

A seven digit number; if not seven digits, zero-fill leading digits to make seven digits.

]]

local function mr (id)
	local handler = cfg.id_handlers['MR'];
	local id_num;
	local id_len;
	local err_cat = '';
	
	id_num = id:match ('^[Mm][Rr](%d+)$');										-- identifier with mr prefix

	if is_set (id_num) then
		add_maint_cat ('mr_format');
	else																		-- plain number without mr prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	id_len = id_num and id_num:len() or 0;
	if (7 &gt;= id_len) and (0 ~= id_len) then
		id = string.rep ('0', 7-id_len ) .. id_num;								-- zero-fill leading digits
	else
		err_cat = ' ' .. set_error( 'bad_mr' );									-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an oclc id.  https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (id)
	local handler = cfg.id_handlers['OCLC'];
	local number;
	local err_msg = '';															-- empty string for concatenation
	
	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- contrain to 1 to 9 digits; change this when oclc issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if 10 &lt; number:len() then
			number = nil;														-- contrain to 1 to 10 digits; change this when oclc issues 11-digit numbers
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		err_msg = ' ' .. set_error( 'bad_oclc' )								-- add an error message if the id is malformed
	end
	
	local text = external_link_id({link=handler.link, label=handler.label,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode}) .. err_msg;

	return text;
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id, access)
	local code;
	local handler = cfg.id_handlers['OL'];
	local ident;
	
	ident, code = id:gsub('^OL', ''):match(&quot;^(%d+([AMW]))$&quot;);					-- optional OL prefix followed immediately by digits followed by 'A', 'M', or 'W'; remove OL prefix

	if not is_set (ident) then													-- if malformed return an error
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access}) .. ' ' .. set_error( 'bad_ol' );
	end
	
	id = ident;																	-- use ident without the optional OL prefix (it has been removed)
	
	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end
	
	if ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end

	if ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 6500000;													-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat = '';															-- presume that PMC is valid
	local id_num;
	local text;
	
	id_num = id:match ('^[Pp][Mm][Cc](%d+)$');									-- identifier with pmc prefix

	if is_set (id_num) then
		add_maint_cat ('pmc_format');
	else																		-- plain number without pmc prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then								-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );							-- set an error message
		else
			id = tostring (id_num);												-- make sure id is a string
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_pmc' );								-- set an error message
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text = table.concat (													-- still embargoed so no external link
			{
			make_wikilink (handler.link, handler.label),
			handler.separator,
			id,
			err_cat
			});
	else
		text = external_link_id({link = handler.link, label = handler.label,	-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 32000000;												-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat = '';															-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then													-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );								-- set an error message
	else																		-- PMID is only digits
		local id_num = tonumber(id);											-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then								-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );							-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; S S R N &gt;----------------------------------------------------------------------

Format an ssrn, do simple error checking

SSRNs are sequential numbers beginning at 100? and counting up.  This code checks the ssrn to see that it is
only digits and is greater than 99 and less than test_limit; the value in local variable test_limit will need
to be updated periodically as more SSRNs are issued.

]]

local function ssrn (id)
	local test_limit = 3500000;													-- update this value as SSRNs approach
	local handler = cfg.id_handlers['SSRN'];
	local err_cat = '';															-- presume that SSRN is valid
	local id_num;
	local text;
	
	id_num = id:match ('^%d+$');												-- id must be all digits

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 100 &gt; id_num or test_limit &lt; id_num then								-- if SSRN is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_ssrn' );							-- set an error message
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_ssrn' );								-- set an error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;

	return text;
end


--[[--------------------------&lt; U S E N E T _ I D &gt;------------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function usenet_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_usenet_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; Z B L &gt;-----------------------------------------------------------------------

A numerical identifier in the form nnnn.nnnnn - leading zeros in the first quartet optional

]]

local function zbl (id)
	local handler = cfg.id_handlers['ZBL'];
	local id_num;
	local err_cat = '';
	
	id_num = id:match ('^[Zz][Bb][Ll](.*)$');									-- identifier with zbl prefix; extract identifier

	if is_set (id_num) then
		add_maint_cat ('zbl_format');
	else																		-- plain number without zbl prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num:match('^%d?%d?%d?%d%.%d%d%d%d%d$') then
		id = id_num;															-- id matches pattern
	else
		err_cat = ' ' .. set_error( 'bad_zbl' );								-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--============================&lt;&lt; I N T E R F A C E   F U N C T I O N S &gt;&gt;==========================================

--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v, ['access'] = options.IdAccessLevels[k] }, fallback(k) );

		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, asin( v, options.ASINTLD ) } ); 
		elseif k == 'BIBCODE' then
			table.insert( new_list, {handler.label, bibcode( v, handler.access ) } );
		elseif k == 'BIORXIV' then
			table.insert( new_list, {handler.label, biorxiv( v ) } );
		elseif k == 'CITESEERX' then
			table.insert( new_list, {handler.label, citeseerx( v ) } );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken, handler.access ) } );
		elseif k == 'EISSN' then
			table.insert( new_list, {handler.label, issn( v, true ) } );		-- true distinguishes eissn from issn
		elseif k == 'HDL' then
			table.insert( new_list, {handler.label, hdl( v, handler.access ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			local check;
			local err_type = '';
			check, err_type = isbn( v );
			if not check then
				if is_set(options.IgnoreISBN) then								-- ISBN is invalid; if |ignore-isbn-error= set
					add_maint_cat ('ignore_isbn_err');							-- ad a maint category
				else
					ISBN = ISBN .. set_error( 'bad_isbn', {err_type}, false, &quot; &quot;, &quot;&quot; );	-- else display an error message
				end
			elseif is_set(options.IgnoreISBN) then								-- ISBN is OK; if |ignore-isbn-error= set
				add_maint_cat ('ignore_isbn_err');								-- because |ignore-isbn-error= unnecessary
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'JFM' then
			table.insert( new_list, {handler.label, jfm( v ) } );
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'MR' then
			table.insert( new_list, {handler.label, mr( v ) } );
		elseif k == 'OCLC' then
			table.insert( new_list, {handler.label, oclc( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v, handler.access ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'SSRN' then
			table.insert( new_list, {handler.label, ssrn( v ) } );
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, usenet_id( v ) } );
		elseif k == 'ZBL' then
			table.insert( new_list, {handler.label, zbl( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1]:lower() &lt; b[1]:lower();
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; E X T R A C T _ I D _ A C C E S S _ L E V E L S &gt;--------------------------------------

Fetches custom id access levels from arguments using configuration settings.
Parameters which have a predefined access level (e.g. arxiv) do not use this
function as they are directly rendered as free without using an additional parameter.

]]

local function extract_id_access_levels( args, id_list )
	local id_accesses_list = {};
	for k, v in pairs( cfg.id_handlers ) do
		local access_param = v.custom_access;
		local k_lower = string.lower(k);
		if is_set(access_param) then
			local access_level = args[access_param];
			if is_set(access_level) then
				if not in_array (access_level:lower(), cfg.keywords['id-access']) then
					table.insert( z.message_tail, { set_error( 'invalid_param_val', {access_param, access_level}, true ) } );	
					access_level = nil;
				end
				if not is_set(id_list[k]) then
					table.insert( z.message_tail, { set_error( 'param_access_requires_param', {k_lower}, true ) } );
				end
				if is_set(access_level) then
					access_level = access_level:lower();
				end
				id_accesses_list[k] = access_level;
			end
		end
	end
	return id_accesses_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	set_error = utilities_page_ptr.set_error;
	select_one = utilities_page_ptr.select_one;
	add_maint_cat = utilities_page_ptr.add_maint_cat;
	substitute = utilities_page_ptr.substitute;
	make_wikilink = utilities_page_ptr.make_wikilink;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end


return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	extract_id_access_levels = extract_id_access_levels,
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>0sr6adsai6gph5uwswossvp9tua1xqf</sha1>
    </revision>
    <revision>
      <id>4904</id>
      <parentid>4903</parentid>
      <timestamp>2018-07-03T13:47:11Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>doi.org is not accepting fully url encoded urls; '/' character must not be encoded;</comment>
      <origin>4904</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="46670" sha1="by356mih61wyb9ydfuxhkhpgq954vg6" xml:space="preserve">
local identifiers = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat, substitute, make_wikilink;	-- functions in Module:Citation/CS1/Utilities

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--============================&lt;&lt; H E L P E R   F U N C T I O N S &gt;&gt;============================================

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	local ext_link;
	
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
		if 'doi' == options.label then											-- 2018-07-02 doi.org stopped accepting urls with url encoded '/' (%2F)
			url_string = url_string:gsub ('%%2F', '/');							-- special case for doi; undo url-encoded slashes
		end
	end
	
	ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or &quot;&quot;, mw.text.nowiki(options.id));
	if is_set(options.access) then
		ext_link = substitute (cfg.presentation['access-signal'], {ext_link, cfg.presentation[options.access]});	-- add the free-to-read / paywall lock
	end
	
	return table.concat	({
		make_wikilink (options.link, options.label),
		options.separator or '&amp;nbsp;',
		ext_link
		});
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)

	return table.concat (
		{
		make_wikilink (options.link, options.label),
		options.separator or '&amp;nbsp;',
		make_wikilink (
			table.concat (
				{
				options.prefix,
				options.id,
				options.suffix or ''
				}),
			mw.text.nowiki (options.id)
			);
		});
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9' → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N _ 1 3 &gt;-----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--============================&lt;&lt; I D E N T I F I E R   F U N C T I O N S &gt;&gt;====================================

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = '';
	local text;
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = ' ' .. set_error( 'bad_arxiv' );						-- set error message
		end
	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_cat = ' ' .. set_error( 'bad_arxiv' );							-- set error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_arxiv' );								-- arXiv id doesn't match any format
	end

	text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;

	if is_set (class) then
		class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]';	-- external link within square brackets, not wikilink
	else
		class = '';																-- empty string for concatenation
	end
	
	return text .. class;
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode id.

Format for bibcodes is specified here: http://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6 must be letter, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		7–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		9–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (id, access)
	local handler = cfg.id_handlers['BIBCODE'];
	local err_type;
	local year;

	local text = external_link_id({link=handler.link, label=handler.label,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
		access=access});
	
	if 19 ~= id:len() then
		err_type = 'length';
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%a&amp;%.][%a&amp;%.%d][%a&amp;%.%d][%a%d%.]+[%a%.]$&quot;)	-- 
		if not year then														-- if nil then no pattern match
			err_type = 'value';													-- so value error
		else
			local next_year = tonumber(os.date ('%Y'))+1;						-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = 'year';												-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = 'journal';											-- journal abbreviation must not have '&amp;.' (if it does its missing a letter)
			end
		end
	end

	if is_set (err_type) then													-- if there was an error detected
		text = text .. ' ' .. set_error( 'bad_bibcode', {err_type});
	end
	return text;
end


--[[--------------------------&lt; B I O R X I V &gt;-----------------------------------------------------------------

Format bioRxiv id and do simple error checking.  BiorXiv ids are exactly 6 digits.
The bioRxiv id is the number following the last slash in the bioRxiv-issued DOI:
https://doi.org/10.1101/078733 -&gt; 078733

]]

local function biorxiv(id)
	local handler = cfg.id_handlers['BIORXIV'];
	local err_cat = '';															-- presume that bioRxiv id is valid
	
	if nil == id:match(&quot;^%d%d%d%d%d%d$&quot;) then									-- if bioRxiv id has anything but six digits
		err_cat = ' ' .. set_error( 'bad_biorxiv');	-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator,
			encode=handler.encode, access=handler.access}) .. err_cat;
end


--[[--------------------------&lt; C I T E S E E R X &gt;------------------------------------------------------------

CiteSeerX use their own notion of &quot;doi&quot; (not to be confused with the identifiers resolved via doi.org).

The description of the structure of this identifier can be found at Help_talk:Citation_Style_1/Archive_26#CiteSeerX_id_structure
]]

local function citeseerx (id)
	local handler = cfg.id_handlers['CITESEERX'];
	local matched;
	
	local text = external_link_id({link=handler.link, label=handler.label,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
		access=handler.access});
	
	matched = id:match (&quot;^10%.1%.1%.[1-9]%d?%d?%d?%.[1-9]%d?%d?%d?$&quot;);
	if not matched then
		text = text .. ' ' .. set_error( 'bad_citeseerx' );
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive, access)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';					-- try to get the year portion from the inactive date
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );		-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	end
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access}) .. (inactive or '')

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then						-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end

	return text .. cat 
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

]]

local function hdl(id, access)
	local handler = cfg.id_handlers['HDL'];
	
	local text = external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- hdl must contain a fwd slash, must not contain spaces, endashes, and must not end with period or comma
		text = text .. ' ' .. set_error( 'bad_hdl' );
	end
	return text;
end


--[[--------------------------&lt; I S B N &gt;----------------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then
		return false, 'invalid character';										-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );						-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false, 'length';													-- fail if incorrect length
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then								-- fail if isbn_str has 'X' anywhere but last position
			return false, 'invalid form';									
		end
		return is_valid_isxn(isbn_str, 10), 'checksum';
	else
		if isbn_str:match( &quot;^%d+$&quot; ) == nil then
			return false, 'invalid character';									-- fail if isbn13 is not all digits
		end
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then
			return false, 'invalid prefix';										-- fail when isbn13 does not begin with 978 or 979
		end
		return is_valid_isxn_13 (isbn_str), 'checksum';
	end
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

This function is positioned here because it calls isbn()

]]

local function asin(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat = ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then							-- if 10-digit numeric (or 9 digits with terminal X)
			if isbn( id ) then													-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat = ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat = ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;
	local id_copy;

	id_copy = id;																-- save a copy because this testing is destructive
	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text = table.concat (
		{
		make_wikilink (handler.link, handler.label),
		handler.separator,
		id_copy
		});		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the ismn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]	-- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id, e)
	local issn_copy = id;														-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler;
	local text;
	local valid_issn = true;
	
	if e then
		 handler = cfg.id_handlers['EISSN'];
	else
		 handler = cfg.id_handlers['ISSN'];
	end

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then						-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;														-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);										-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );				-- if valid, display correctly formatted version
	else
		id = issn_copy;															-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn', e and 'e' or '' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; J F M &gt;-----------------------------------------------------------------------

A numerical identifier in the form nn.nnnn.nn

]]

local function jfm (id)
	local handler = cfg.id_handlers['JFM'];
	local id_num;
	local err_cat = '';
	
	id_num = id:match ('^[Jj][Ff][Mm](.*)$');									-- identifier with jfm prefix; extract identifier

	if is_set (id_num) then
		add_maint_cat ('jfm_format');
	else																		-- plain number without mr prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num and id_num:match('^%d%d%.%d%d%d%d%.%d%d$') then
		id = id_num;															-- jfm matches pattern
	else
		err_cat = ' ' .. set_error( 'bad_jfm' );								-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat = '';															-- presume that LCCN is valid
	local id = lccn;															-- local copy of the lccn

	id = normalize_lccn (id);													-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();														-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- set an error message
		end
	elseif 9 == len then														-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then							-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- set an error message
		end
	elseif 10 == len then														-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then					-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );						-- no match, set an error message
			end
		end
	elseif 11 == len then														-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- no match, set an error message
		end
	elseif 12 == len then														-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then						-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );								-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );								-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; M R &gt;--------------------------------------------------------------------------

A seven digit number; if not seven digits, zero-fill leading digits to make seven digits.

]]

local function mr (id)
	local handler = cfg.id_handlers['MR'];
	local id_num;
	local id_len;
	local err_cat = '';
	
	id_num = id:match ('^[Mm][Rr](%d+)$');										-- identifier with mr prefix

	if is_set (id_num) then
		add_maint_cat ('mr_format');
	else																		-- plain number without mr prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	id_len = id_num and id_num:len() or 0;
	if (7 &gt;= id_len) and (0 ~= id_len) then
		id = string.rep ('0', 7-id_len ) .. id_num;								-- zero-fill leading digits
	else
		err_cat = ' ' .. set_error( 'bad_mr' );									-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an oclc id.  https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (id)
	local handler = cfg.id_handlers['OCLC'];
	local number;
	local err_msg = '';															-- empty string for concatenation
	
	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- contrain to 1 to 9 digits; change this when oclc issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if 10 &lt; number:len() then
			number = nil;														-- contrain to 1 to 10 digits; change this when oclc issues 11-digit numbers
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		err_msg = ' ' .. set_error( 'bad_oclc' )								-- add an error message if the id is malformed
	end
	
	local text = external_link_id({link=handler.link, label=handler.label,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode}) .. err_msg;

	return text;
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id, access)
	local code;
	local handler = cfg.id_handlers['OL'];
	local ident;
	
	ident, code = id:gsub('^OL', ''):match(&quot;^(%d+([AMW]))$&quot;);					-- optional OL prefix followed immediately by digits followed by 'A', 'M', or 'W'; remove OL prefix

	if not is_set (ident) then													-- if malformed return an error
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access}) .. ' ' .. set_error( 'bad_ol' );
	end
	
	id = ident;																	-- use ident without the optional OL prefix (it has been removed)
	
	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end
	
	if ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end

	if ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 6500000;													-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat = '';															-- presume that PMC is valid
	local id_num;
	local text;
	
	id_num = id:match ('^[Pp][Mm][Cc](%d+)$');									-- identifier with pmc prefix

	if is_set (id_num) then
		add_maint_cat ('pmc_format');
	else																		-- plain number without pmc prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then								-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );							-- set an error message
		else
			id = tostring (id_num);												-- make sure id is a string
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_pmc' );								-- set an error message
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text = table.concat (													-- still embargoed so no external link
			{
			make_wikilink (handler.link, handler.label),
			handler.separator,
			id,
			err_cat
			});
	else
		text = external_link_id({link = handler.link, label = handler.label,	-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 32000000;												-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat = '';															-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then													-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );								-- set an error message
	else																		-- PMID is only digits
		local id_num = tonumber(id);											-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then								-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );							-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; S S R N &gt;----------------------------------------------------------------------

Format an ssrn, do simple error checking

SSRNs are sequential numbers beginning at 100? and counting up.  This code checks the ssrn to see that it is
only digits and is greater than 99 and less than test_limit; the value in local variable test_limit will need
to be updated periodically as more SSRNs are issued.

]]

local function ssrn (id)
	local test_limit = 3500000;													-- update this value as SSRNs approach
	local handler = cfg.id_handlers['SSRN'];
	local err_cat = '';															-- presume that SSRN is valid
	local id_num;
	local text;
	
	id_num = id:match ('^%d+$');												-- id must be all digits

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 100 &gt; id_num or test_limit &lt; id_num then								-- if SSRN is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_ssrn' );							-- set an error message
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_ssrn' );								-- set an error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;

	return text;
end


--[[--------------------------&lt; U S E N E T _ I D &gt;------------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function usenet_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_usenet_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; Z B L &gt;-----------------------------------------------------------------------

A numerical identifier in the form nnnn.nnnnn - leading zeros in the first quartet optional

]]

local function zbl (id)
	local handler = cfg.id_handlers['ZBL'];
	local id_num;
	local err_cat = '';
	
	id_num = id:match ('^[Zz][Bb][Ll](.*)$');									-- identifier with zbl prefix; extract identifier

	if is_set (id_num) then
		add_maint_cat ('zbl_format');
	else																		-- plain number without zbl prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num:match('^%d?%d?%d?%d%.%d%d%d%d%d$') then
		id = id_num;															-- id matches pattern
	else
		err_cat = ' ' .. set_error( 'bad_zbl' );								-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--============================&lt;&lt; I N T E R F A C E   F U N C T I O N S &gt;&gt;==========================================

--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v, ['access'] = options.IdAccessLevels[k] }, fallback(k) );

		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, asin( v, options.ASINTLD ) } ); 
		elseif k == 'BIBCODE' then
			table.insert( new_list, {handler.label, bibcode( v, handler.access ) } );
		elseif k == 'BIORXIV' then
			table.insert( new_list, {handler.label, biorxiv( v ) } );
		elseif k == 'CITESEERX' then
			table.insert( new_list, {handler.label, citeseerx( v ) } );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken, handler.access ) } );
		elseif k == 'EISSN' then
			table.insert( new_list, {handler.label, issn( v, true ) } );		-- true distinguishes eissn from issn
		elseif k == 'HDL' then
			table.insert( new_list, {handler.label, hdl( v, handler.access ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			local check;
			local err_type = '';
			check, err_type = isbn( v );
			if not check then
				if is_set(options.IgnoreISBN) then								-- ISBN is invalid; if |ignore-isbn-error= set
					add_maint_cat ('ignore_isbn_err');							-- ad a maint category
				else
					ISBN = ISBN .. set_error( 'bad_isbn', {err_type}, false, &quot; &quot;, &quot;&quot; );	-- else display an error message
				end
			elseif is_set(options.IgnoreISBN) then								-- ISBN is OK; if |ignore-isbn-error= set
				add_maint_cat ('ignore_isbn_err');								-- because |ignore-isbn-error= unnecessary
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'JFM' then
			table.insert( new_list, {handler.label, jfm( v ) } );
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'MR' then
			table.insert( new_list, {handler.label, mr( v ) } );
		elseif k == 'OCLC' then
			table.insert( new_list, {handler.label, oclc( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v, handler.access ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'SSRN' then
			table.insert( new_list, {handler.label, ssrn( v ) } );
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, usenet_id( v ) } );
		elseif k == 'ZBL' then
			table.insert( new_list, {handler.label, zbl( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1]:lower() &lt; b[1]:lower();
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; E X T R A C T _ I D _ A C C E S S _ L E V E L S &gt;--------------------------------------

Fetches custom id access levels from arguments using configuration settings.
Parameters which have a predefined access level (e.g. arxiv) do not use this
function as they are directly rendered as free without using an additional parameter.

]]

local function extract_id_access_levels( args, id_list )
	local id_accesses_list = {};
	for k, v in pairs( cfg.id_handlers ) do
		local access_param = v.custom_access;
		local k_lower = string.lower(k);
		if is_set(access_param) then
			local access_level = args[access_param];
			if is_set(access_level) then
				if not in_array (access_level:lower(), cfg.keywords['id-access']) then
					table.insert( z.message_tail, { set_error( 'invalid_param_val', {access_param, access_level}, true ) } );	
					access_level = nil;
				end
				if not is_set(id_list[k]) then
					table.insert( z.message_tail, { set_error( 'param_access_requires_param', {k_lower}, true ) } );
				end
				if is_set(access_level) then
					access_level = access_level:lower();
				end
				id_accesses_list[k] = access_level;
			end
		end
	end
	return id_accesses_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	set_error = utilities_page_ptr.set_error;
	select_one = utilities_page_ptr.select_one;
	add_maint_cat = utilities_page_ptr.add_maint_cat;
	substitute = utilities_page_ptr.substitute;
	make_wikilink = utilities_page_ptr.make_wikilink;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end


return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	extract_id_access_levels = extract_id_access_levels,
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>by356mih61wyb9ydfuxhkhpgq954vg6</sha1>
    </revision>
    <revision>
      <id>4905</id>
      <parentid>4904</parentid>
      <timestamp>2018-09-29T13:26:24Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>synch from sandbox;</comment>
      <origin>4905</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="48005" sha1="s6ljsoq7pybsfed84u1np93ua9j4jpz" xml:space="preserve">
local identifiers = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat, substitute, make_wikilink;	-- functions in Module:Citation/CS1/Utilities

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration

local wd_int_lang = (mw.site.server:match ('wikidata') and mw.getCurrentFrame():preprocess('{{int:lang}}')) or '';


--============================&lt;&lt; H E L P E R   F U N C T I O N S &gt;&gt;============================================

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	local ext_link;
	local this_wiki_code;														-- wikipedia subdomain; 'en' for en.wikipedia.org
	local wd_article;															-- article title from wikidata
	
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end

	ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or &quot;&quot;, mw.text.nowiki(options.id));
	if is_set(options.access) then
		ext_link = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[options.access].class, cfg.presentation[options.access].title, ext_link});	-- add the free-to-read / paywall lock
	end

	this_wiki_code = mw.language.getContentLanguage():getCode();				-- get this wikipedia's language code (subdomain)
	
	if string.match (mw.site.server, 'wikidata') then
		this_wiki_code = mw.getCurrentFrame():preprocess('{{int:lang}}');		-- on wikidata so use interface language setting instead
	end
	
	if is_set (options.q) then
		wd_article = mw.wikibase.getEntity (options.q):getSitelink (this_wiki_code .. 'wiki');	-- fetch article title from wd
		if wd_article then
			wd_article = table.concat ({':', this_wiki_code, ':', wd_article});	-- make interwiki link if taken from wd; leading colon required
		end
	end

	return table.concat	({
		make_wikilink (wd_article or options.link, options.label),				-- wikidata link or locally specified
		options.separator or '&amp;nbsp;',
		ext_link
		});
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)

	return table.concat (
		{
		make_wikilink (options.link, options.label),
		options.separator or '&amp;nbsp;',
		make_wikilink (
			table.concat (
				{
				options.prefix,
				options.id,
				options.suffix or ''
				}),
			mw.text.nowiki (options.id)
			);
		});
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9' → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N _ 1 3 &gt;-----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--============================&lt;&lt; I D E N T I F I E R   F U N C T I O N S &gt;&gt;====================================

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation; not the same as |class= parameter which is not supported in this form
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = false;														-- assume no error message
	local text;																	-- output text
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
				err_cat = true;													-- flag for error message
		end

	else
		err_cat = true;															-- not a recognized format; flag for error message
	end

	err_cat = err_cat and table.concat ({' ', set_error ('bad_arxiv')}) or '';	-- set error message if flag is true
	
	text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;

	if is_set (class) then
		if id:match ('^%d+') then
			text = table.concat ({text, ' [[//arxiv.org/archive/', class, ' ', class, ']]'});	-- external link within square brackets, not wikilink
		else
			text = table.concat ({text, ' ', set_error ('class_ignored')});		
		end
	end

	return text;	
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode id.

Format for bibcodes is specified here: http://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6 must be letter, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		7–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		9–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (id, access)
	local handler = cfg.id_handlers['BIBCODE'];
	local err_type;
	local year;

	local text = external_link_id({link=handler.link, label=handler.label, q = handler.q,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
		access=access});
	
	if 19 ~= id:len() then
		err_type = 'length';
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%a&amp;%.][%a&amp;%.%d][%a&amp;%.%d][%a%d%.]+[%a%.]$&quot;)	-- 
		if not year then														-- if nil then no pattern match
			err_type = 'value';													-- so value error
		else
			local next_year = tonumber(os.date ('%Y'))+1;						-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = 'year';												-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = 'journal';											-- journal abbreviation must not have '&amp;.' (if it does its missing a letter)
			end
		end
	end

	if is_set (err_type) then													-- if there was an error detected
		text = text .. ' ' .. set_error( 'bad_bibcode', {err_type});
	end
	return text;
end


--[[--------------------------&lt; B I O R X I V &gt;-----------------------------------------------------------------

Format bioRxiv id and do simple error checking.  BiorXiv ids are exactly 6 digits.
The bioRxiv id is the number following the last slash in the bioRxiv-issued DOI:
https://doi.org/10.1101/078733 -&gt; 078733

]]

local function biorxiv(id)
	local handler = cfg.id_handlers['BIORXIV'];
	local err_cat = '';															-- presume that bioRxiv id is valid
	
	if nil == id:match(&quot;^%d%d%d%d%d%d$&quot;) then									-- if bioRxiv id has anything but six digits
		err_cat = ' ' .. set_error( 'bad_biorxiv');	-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator,
			encode=handler.encode, access=handler.access}) .. err_cat;
end


--[[--------------------------&lt; C I T E S E E R X &gt;------------------------------------------------------------

CiteSeerX use their own notion of &quot;doi&quot; (not to be confused with the identifiers resolved via doi.org).

The description of the structure of this identifier can be found at Help_talk:Citation_Style_1/Archive_26#CiteSeerX_id_structure
]]

local function citeseerx (id)
	local handler = cfg.id_handlers['CITESEERX'];
	local matched;
	
	local text = external_link_id({link=handler.link, label=handler.label, q = handler.q,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
		access=handler.access});
	
	matched = id:match (&quot;^10%.1%.1%.[1-9]%d?%d?%d?%.[1-9]%d?%d?%d?$&quot;);
	if not matched then
		text = text .. ' ' .. set_error( 'bad_citeseerx' );
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive, access)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';					-- try to get the year portion from the inactive date
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive since &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );		-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	end
	text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access}) .. (inactive or '')

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then						-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end

	return text .. cat 
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

]]

local function hdl(id, access)
	local handler = cfg.id_handlers['HDL'];
	
	local text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- hdl must contain a fwd slash, must not contain spaces, endashes, and must not end with period or comma
		text = text .. ' ' .. set_error( 'bad_hdl' );
	end
	return text;
end


--[[--------------------------&lt; I S B N &gt;----------------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then
		return false, 'invalid character';										-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );						-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false, 'length';													-- fail if incorrect length
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then								-- fail if isbn_str has 'X' anywhere but last position
			return false, 'invalid form';									
		end
		return is_valid_isxn(isbn_str, 10), 'checksum';
	else
		if isbn_str:match( &quot;^%d+$&quot; ) == nil then
			return false, 'invalid character';									-- fail if isbn13 is not all digits
		end
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then
			return false, 'invalid prefix';										-- fail when isbn13 does not begin with 978 or 979
		end
		return is_valid_isxn_13 (isbn_str), 'checksum';
	end
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

This function is positioned here because it calls isbn()

]]

local function asin(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat = ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then							-- if 10-digit numeric (or 9 digits with terminal X)
			if isbn( id ) then													-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat = ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat = ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, q = handler.q, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;
	local id_copy;

	id_copy = id;																-- save a copy because this testing is destructive
	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text = table.concat (
		{
		make_wikilink (handler.link, handler.label),
		handler.separator,
		id_copy
		});		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the ismn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]	-- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id, e)
	local issn_copy = id;														-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler;
	local text;
	local valid_issn = true;
	
	if e then
		 handler = cfg.id_handlers['EISSN'];
	else
		 handler = cfg.id_handlers['ISSN'];
	end

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then						-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;														-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);										-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );				-- if valid, display correctly formatted version
	else
		id = issn_copy;															-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn', e and 'e' or '' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; J F M &gt;-----------------------------------------------------------------------

A numerical identifier in the form nn.nnnn.nn

]]

local function jfm (id)
	local handler = cfg.id_handlers['JFM'];
	local id_num;
	local err_cat = '';
	
	id_num = id:match ('^[Jj][Ff][Mm](.*)$');									-- identifier with jfm prefix; extract identifier

	if is_set (id_num) then
		add_maint_cat ('jfm_format');
	else																		-- plain number without mr prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num and id_num:match('^%d%d%.%d%d%d%d%.%d%d$') then
		id = id_num;															-- jfm matches pattern
	else
		err_cat = ' ' .. set_error( 'bad_jfm' );								-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat = '';															-- presume that LCCN is valid
	local id = lccn;															-- local copy of the lccn

	id = normalize_lccn (id);													-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();														-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- set an error message
		end
	elseif 9 == len then														-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then							-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- set an error message
		end
	elseif 10 == len then														-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then					-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );						-- no match, set an error message
			end
		end
	elseif 11 == len then														-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- no match, set an error message
		end
	elseif 12 == len then														-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then						-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );								-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );								-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; M R &gt;--------------------------------------------------------------------------

A seven digit number; if not seven digits, zero-fill leading digits to make seven digits.

]]

local function mr (id)
	local handler = cfg.id_handlers['MR'];
	local id_num;
	local id_len;
	local err_cat = '';
	
	id_num = id:match ('^[Mm][Rr](%d+)$');										-- identifier with mr prefix

	if is_set (id_num) then
		add_maint_cat ('mr_format');
	else																		-- plain number without mr prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	id_len = id_num and id_num:len() or 0;
	if (7 &gt;= id_len) and (0 ~= id_len) then
		id = string.rep ('0', 7-id_len ) .. id_num;								-- zero-fill leading digits
	else
		err_cat = ' ' .. set_error( 'bad_mr' );									-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an oclc id.  https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (id)
	local handler = cfg.id_handlers['OCLC'];
	local number;
	local err_msg = '';															-- empty string for concatenation
	
	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- contrain to 1 to 9 digits; change this when oclc issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if 10 &lt; number:len() then
			number = nil;														-- contrain to 1 to 10 digits; change this when oclc issues 11-digit numbers
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		err_msg = ' ' .. set_error( 'bad_oclc' )								-- add an error message if the id is malformed
	end
	
	local text = external_link_id({link=handler.link, label=handler.label, q = handler.q,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode}) .. err_msg;

	return text;
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id, access)
	local code;
	local handler = cfg.id_handlers['OL'];
	local ident;
	
	ident, code = id:gsub('^OL', ''):match(&quot;^(%d+([AMW]))$&quot;);					-- optional OL prefix followed immediately by digits followed by 'A', 'M', or 'W'; remove OL prefix

	if not is_set (ident) then													-- if malformed return an error
		return external_link_id({link=handler.link, label=handler.label, q = handler.q,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access}) .. ' ' .. set_error( 'bad_ol' );
	end
	
	id = ident;																	-- use ident without the optional OL prefix (it has been removed)
	
	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label, q = handler.q,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end
	
	if ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label, q = handler.q,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end

	if ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label, q = handler.q,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 6500000;													-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat = '';															-- presume that PMC is valid
	local id_num;
	local text;
	
	id_num = id:match ('^[Pp][Mm][Cc](%d+)$');									-- identifier with pmc prefix

	if is_set (id_num) then
		add_maint_cat ('pmc_format');
	else																		-- plain number without pmc prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then								-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );							-- set an error message
		else
			id = tostring (id_num);												-- make sure id is a string
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_pmc' );								-- set an error message
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text = table.concat (													-- still embargoed so no external link
			{
			make_wikilink (handler.link, handler.label),
			handler.separator,
			id,
			err_cat
			});
	else
		text = external_link_id({link = handler.link, label = handler.label, q = handler.q,	-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 32000000;												-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat = '';															-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then													-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );								-- set an error message
	else																		-- PMID is only digits
		local id_num = tonumber(id);											-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then								-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );							-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; S S R N &gt;----------------------------------------------------------------------

Format an ssrn, do simple error checking

SSRNs are sequential numbers beginning at 100? and counting up.  This code checks the ssrn to see that it is
only digits and is greater than 99 and less than test_limit; the value in local variable test_limit will need
to be updated periodically as more SSRNs are issued.

]]

local function ssrn (id)
	local test_limit = 3500000;													-- update this value as SSRNs approach
	local handler = cfg.id_handlers['SSRN'];
	local err_cat = '';															-- presume that SSRN is valid
	local id_num;
	local text;
	
	id_num = id:match ('^%d+$');												-- id must be all digits

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 100 &gt; id_num or test_limit &lt; id_num then								-- if SSRN is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_ssrn' );							-- set an error message
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_ssrn' );								-- set an error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;

	return text;
end


--[[--------------------------&lt; U S E N E T _ I D &gt;------------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function usenet_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_usenet_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; Z B L &gt;-----------------------------------------------------------------------

A numerical identifier in the form nnnn.nnnnn - leading zeros in the first quartet optional

]]

local function zbl (id)
	local handler = cfg.id_handlers['ZBL'];
	local id_num;
	local err_cat = '';
	
	id_num = id:match ('^[Zz][Bb][Ll](.*)$');									-- identifier with zbl prefix; extract identifier

	if is_set (id_num) then
		add_maint_cat ('zbl_format');
	else																		-- plain number without zbl prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num:match('^%d?%d?%d?%d%.%d%d%d%d%d$') then
		id = id_num;															-- id matches pattern
	else
		err_cat = ' ' .. set_error( 'bad_zbl' );								-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--============================&lt;&lt; I N T E R F A C E   F U N C T I O N S &gt;&gt;==========================================

--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v, ['access'] = options.IdAccessLevels[k] }, fallback(k) );

		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, asin( v, options.ASINTLD ) } ); 
		elseif k == 'BIBCODE' then
			table.insert( new_list, {handler.label, bibcode( v, handler.access ) } );
		elseif k == 'BIORXIV' then
			table.insert( new_list, {handler.label, biorxiv( v ) } );
		elseif k == 'CITESEERX' then
			table.insert( new_list, {handler.label, citeseerx( v ) } );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken, handler.access ) } );
		elseif k == 'EISSN' then
			table.insert( new_list, {handler.label, issn( v, true ) } );		-- true distinguishes eissn from issn
		elseif k == 'HDL' then
			table.insert( new_list, {handler.label, hdl( v, handler.access ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			local check;
			local err_type = '';
			check, err_type = isbn( v );
			if not check then
				if is_set(options.IgnoreISBN) then								-- ISBN is invalid; if |ignore-isbn-error= set
					add_maint_cat ('ignore_isbn_err');							-- ad a maint category
				else
					ISBN = ISBN .. set_error( 'bad_isbn', {err_type}, false, &quot; &quot;, &quot;&quot; );	-- else display an error message
				end
			elseif is_set(options.IgnoreISBN) then								-- ISBN is OK; if |ignore-isbn-error= set
				add_maint_cat ('ignore_isbn_err');								-- because |ignore-isbn-error= unnecessary
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'JFM' then
			table.insert( new_list, {handler.label, jfm( v ) } );
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'MR' then
			table.insert( new_list, {handler.label, mr( v ) } );
		elseif k == 'OCLC' then
			table.insert( new_list, {handler.label, oclc( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v, handler.access ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'SSRN' then
			table.insert( new_list, {handler.label, ssrn( v ) } );
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, usenet_id( v ) } );
		elseif k == 'ZBL' then
			table.insert( new_list, {handler.label, zbl( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1]:lower() &lt; b[1]:lower();
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; E X T R A C T _ I D _ A C C E S S _ L E V E L S &gt;--------------------------------------

Fetches custom id access levels from arguments using configuration settings.
Parameters which have a predefined access level (e.g. arxiv) do not use this
function as they are directly rendered as free without using an additional parameter.

]]

local function extract_id_access_levels( args, id_list )
	local id_accesses_list = {};
	for k, v in pairs( cfg.id_handlers ) do
		local access_param = v.custom_access;
		local k_lower = string.lower(k);
		if is_set(access_param) then
			local access_level = args[access_param];
			if is_set(access_level) then
				if not in_array (access_level:lower(), cfg.keywords['id-access']) then
					table.insert( z.message_tail, { set_error( 'invalid_param_val', {access_param, access_level}, true ) } );	
					access_level = nil;
				end
				if not is_set(id_list[k]) then
					table.insert( z.message_tail, { set_error( 'param_access_requires_param', {k_lower}, true ) } );
				end
				if is_set(access_level) then
					access_level = access_level:lower();
				end
				id_accesses_list[k] = access_level;
			end
		end
	end
	return id_accesses_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	set_error = utilities_page_ptr.set_error;
	select_one = utilities_page_ptr.select_one;
	add_maint_cat = utilities_page_ptr.add_maint_cat;
	substitute = utilities_page_ptr.substitute;
	make_wikilink = utilities_page_ptr.make_wikilink;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end


return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	extract_id_access_levels = extract_id_access_levels,
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>s6ljsoq7pybsfed84u1np93ua9j4jpz</sha1>
    </revision>
    <revision>
      <id>4906</id>
      <parentid>4905</parentid>
      <timestamp>2019-04-20T13:20:12Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4906</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="48756" sha1="kz3qvcbhsyebx3ayza344d5o0gpnstg" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat, substitute, make_wikilink;	-- functions in Module:Citation/CS1/Utilities

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration

local wd_int_lang = (mw.site.server:match ('wikidata') and mw.getCurrentFrame():preprocess('{{int:lang}}')) or '';


--============================&lt;&lt; H E L P E R   F U N C T I O N S &gt;&gt;============================================

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	local ext_link;
	local this_wiki_code;														-- wikipedia subdomain; 'en' for en.wikipedia.org
	local wd_article;															-- article title from wikidata
	
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end

	ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or &quot;&quot;, mw.text.nowiki(options.id));
	if is_set(options.access) then
		ext_link = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[options.access].class, cfg.presentation[options.access].title, ext_link});	-- add the free-to-read / paywall lock
	end

	this_wiki_code = mw.language.getContentLanguage():getCode();				-- get this wikipedia's language code (subdomain)
	
	if string.match (mw.site.server, 'wikidata') then
		this_wiki_code = mw.getCurrentFrame():preprocess('{{int:lang}}');		-- on wikidata so use interface language setting instead
	end
	
	if is_set (options.q) and mw.wikibase then									-- wikibase test here avoids script errors in third party wikis that aren't using mw.wikibase extension
		wd_article = mw.wikibase.getEntity (options.q):getSitelink (this_wiki_code .. 'wiki');	-- fetch article title from wd
		if wd_article then
			wd_article = table.concat ({':', this_wiki_code, ':', wd_article});	-- make interwiki link if taken from wd; leading colon required
		end
	end

	return table.concat	({
		make_wikilink (wd_article or options.link, options.label),				-- wikidata link or locally specified
		options.separator or '&amp;nbsp;',
		ext_link
		});
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	local id = mw.ustring.gsub (options.id, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9

	return table.concat (
		{
		make_wikilink (options.link, options.label),
		options.separator or '&amp;nbsp;',
		make_wikilink (
			table.concat (
				{
				options.prefix,
				id,																-- translated to western digits
				options.suffix or ''
				}),
			substitute (cfg.presentation['bdi'], {'', mw.text.nowiki (options.id)})	-- bdi tags to prevent Latn script identifiers from being reversed at rtl language wikis
			);																	-- nowiki because MediaWiki still has magic links for ISBN and the like; TODO: is it really required?
		});
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9' → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N _ 1 3 &gt;-----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--============================&lt;&lt; I D E N T I F I E R   F U N C T I O N S &gt;&gt;====================================

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation; not the same as |class= parameter which is not supported in this form
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = false;														-- assume no error message
	local text;																	-- output text
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
				err_cat = true;													-- flag for error message
		end

	else
		err_cat = true;															-- not a recognized format; flag for error message
	end

	err_cat = err_cat and table.concat ({' ', set_error ('bad_arxiv')}) or '';	-- set error message if flag is true
	
	text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;

	if is_set (class) then
		if id:match ('^%d+') then
			text = table.concat ({text, ' [[//arxiv.org/archive/', class, ' ', class, ']]'});	-- external link within square brackets, not wikilink
		else
			text = table.concat ({text, ' ', set_error ('class_ignored')});		
		end
	end

	return text;	
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode id.

Format for bibcodes is specified here: http://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6 must be letter, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		7–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		9–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (id, access)
	local handler = cfg.id_handlers['BIBCODE'];
	local err_type;
	local year;

	local text = external_link_id({link=handler.link, label=handler.label, q = handler.q,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
		access=access});
	
	if 19 ~= id:len() then
		err_type = 'length';
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%a&amp;%.][%a&amp;%.%d][%a&amp;%.%d][%a%d%.]+[%a%.]$&quot;)	-- 
		if not year then														-- if nil then no pattern match
			err_type = 'value';													-- so value error
		else
			local next_year = tonumber(os.date ('%Y'))+1;						-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = 'year';												-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = 'journal';											-- journal abbreviation must not have '&amp;.' (if it does its missing a letter)
			end
		end
	end

	if is_set (err_type) then													-- if there was an error detected
		text = text .. ' ' .. set_error( 'bad_bibcode', {err_type});
	end
	return text;
end


--[[--------------------------&lt; B I O R X I V &gt;-----------------------------------------------------------------

Format bioRxiv id and do simple error checking.  BiorXiv ids are exactly 6 digits.
The bioRxiv id is the number following the last slash in the bioRxiv-issued DOI:
https://doi.org/10.1101/078733 -&gt; 078733

]]

local function biorxiv(id)
	local handler = cfg.id_handlers['BIORXIV'];
	local err_cat = '';															-- presume that bioRxiv id is valid
	
	if nil == id:match(&quot;^%d%d%d%d%d%d$&quot;) then									-- if bioRxiv id has anything but six digits
		err_cat = ' ' .. set_error( 'bad_biorxiv');	-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator,
			encode=handler.encode, access=handler.access}) .. err_cat;
end


--[[--------------------------&lt; C I T E S E E R X &gt;------------------------------------------------------------

CiteSeerX use their own notion of &quot;doi&quot; (not to be confused with the identifiers resolved via doi.org).

The description of the structure of this identifier can be found at Help_talk:Citation_Style_1/Archive_26#CiteSeerX_id_structure
]]

local function citeseerx (id)
	local handler = cfg.id_handlers['CITESEERX'];
	local matched;
	
	local text = external_link_id({link=handler.link, label=handler.label, q = handler.q,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
		access=handler.access});
	
	matched = id:match (&quot;^10%.1%.1%.[1-9]%d?%d?%d?%.[1-9]%d?%d?%d?$&quot;);
	if not matched then
		text = text .. ' ' .. set_error( 'bad_citeseerx' );
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive, access)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';					-- try to get the year portion from the inactive date
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive as of &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );		-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	end
	text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access}) .. (inactive or '')

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then						-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end

	return text .. cat 
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

]]

local function hdl(id, access)
	local handler = cfg.id_handlers['HDL'];
	
	local text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- hdl must contain a fwd slash, must not contain spaces, endashes, and must not end with period or comma
		text = text .. ' ' .. set_error( 'bad_hdl' );
	end
	return text;
end


--[[--------------------------&lt; I S B N &gt;----------------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then
		return false, 'invalid character';										-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );						-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false, 'length';													-- fail if incorrect length
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then								-- fail if isbn_str has 'X' anywhere but last position
			return false, 'invalid form';									
		end
		return is_valid_isxn(isbn_str, 10), 'checksum';
	else
		if isbn_str:match( &quot;^%d+$&quot; ) == nil then
			return false, 'invalid character';									-- fail if isbn13 is not all digits
		end
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then
			return false, 'invalid prefix';										-- fail when isbn13 does not begin with 978 or 979
		end
		return is_valid_isxn_13 (isbn_str), 'checksum';
	end
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

This function is positioned here because it calls isbn()

]]

local function asin(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat = ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then							-- if 10-digit numeric (or 9 digits with terminal X)
			if isbn( id ) then													-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat = ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat = ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, q = handler.q, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;
	local id_copy;

	id_copy = id;																-- save a copy because this testing is destructive
	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text = table.concat (
		{
		make_wikilink (handler.link, handler.label),
		handler.separator,
		id_copy
		});		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the ismn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]	-- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id, e)
	local issn_copy = id;														-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler;
	local text;
	local valid_issn = true;
	
	if e then
		 handler = cfg.id_handlers['EISSN'];
	else
		 handler = cfg.id_handlers['ISSN'];
	end

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then						-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;														-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);										-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );				-- if valid, display correctly formatted version
	else
		id = issn_copy;															-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn', e and 'e' or '' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; J F M &gt;-----------------------------------------------------------------------

A numerical identifier in the form nn.nnnn.nn

]]

local function jfm (id)
	local handler = cfg.id_handlers['JFM'];
	local id_num;
	local err_cat = '';
	
	id_num = id:match ('^[Jj][Ff][Mm](.*)$');									-- identifier with jfm prefix; extract identifier

	if is_set (id_num) then
		add_maint_cat ('jfm_format');
	else																		-- plain number without mr prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num and id_num:match('^%d%d%.%d%d%d%d%.%d%d$') then
		id = id_num;															-- jfm matches pattern
	else
		err_cat = ' ' .. set_error( 'bad_jfm' );								-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat = '';															-- presume that LCCN is valid
	local id = lccn;															-- local copy of the lccn

	id = normalize_lccn (id);													-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();														-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- set an error message
		end
	elseif 9 == len then														-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then							-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- set an error message
		end
	elseif 10 == len then														-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then					-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );						-- no match, set an error message
			end
		end
	elseif 11 == len then														-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- no match, set an error message
		end
	elseif 12 == len then														-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then						-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );								-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );								-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; M R &gt;--------------------------------------------------------------------------

A seven digit number; if not seven digits, zero-fill leading digits to make seven digits.

]]

local function mr (id)
	local handler = cfg.id_handlers['MR'];
	local id_num;
	local id_len;
	local err_cat = '';
	
	id_num = id:match ('^[Mm][Rr](%d+)$');										-- identifier with mr prefix

	if is_set (id_num) then
		add_maint_cat ('mr_format');
	else																		-- plain number without mr prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	id_len = id_num and id_num:len() or 0;
	if (7 &gt;= id_len) and (0 ~= id_len) then
		id = string.rep ('0', 7-id_len ) .. id_num;								-- zero-fill leading digits
	else
		err_cat = ' ' .. set_error( 'bad_mr' );									-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an oclc id.  https://www.oclc.org/batchload/controlnumber.en.html {{dead link}}
archived at: https://web.archive.org/web/20161228233804/https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (id)
	local handler = cfg.id_handlers['OCLC'];
	local number;
	local err_msg = '';															-- empty string for concatenation
	
	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- contrain to 1 to 9 digits; change this when oclc issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if 10 &lt; number:len() then
			number = nil;														-- contrain to 1 to 10 digits; change this when oclc issues 11-digit numbers
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		err_msg = ' ' .. set_error( 'bad_oclc' )								-- add an error message if the id is malformed
	end
	
	local text = external_link_id({link=handler.link, label=handler.label, q = handler.q,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode}) .. err_msg;

	return text;
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id, access)
	local code;
	local handler = cfg.id_handlers['OL'];
	local ident;
	
	ident, code = id:gsub('^OL', ''):match(&quot;^(%d+([AMW]))$&quot;);					-- optional OL prefix followed immediately by digits followed by 'A', 'M', or 'W'; remove OL prefix

	if not is_set (ident) then													-- if malformed return an error
		return external_link_id({link=handler.link, label=handler.label, q = handler.q,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access}) .. ' ' .. set_error( 'bad_ol' );
	end
	
	id = ident;																	-- use ident without the optional OL prefix (it has been removed)
	
	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label, q = handler.q,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end
	
	if ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label, q = handler.q,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end

	if ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label, q = handler.q,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 6500000;													-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat = '';															-- presume that PMC is valid
	local id_num;
	local text;
	
	id_num = id:match ('^[Pp][Mm][Cc](%d+)$');									-- identifier with pmc prefix

	if is_set (id_num) then
		add_maint_cat ('pmc_format');
	else																		-- plain number without pmc prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then								-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );							-- set an error message
		else
			id = tostring (id_num);												-- make sure id is a string
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_pmc' );								-- set an error message
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text = table.concat (													-- still embargoed so no external link
			{
			make_wikilink (handler.link, handler.label),
			handler.separator,
			id,
			err_cat
			});
	else
		text = external_link_id({link = handler.link, label = handler.label, q = handler.q,	-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 32000000;												-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat = '';															-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then													-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );								-- set an error message
	else																		-- PMID is only digits
		local id_num = tonumber(id);											-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then								-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );							-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; S S R N &gt;----------------------------------------------------------------------

Format an ssrn, do simple error checking

SSRNs are sequential numbers beginning at 100? and counting up.  This code checks the ssrn to see that it is
only digits and is greater than 99 and less than test_limit; the value in local variable test_limit will need
to be updated periodically as more SSRNs are issued.

]]

local function ssrn (id)
	local test_limit = 3500000;													-- update this value as SSRNs approach
	local handler = cfg.id_handlers['SSRN'];
	local err_cat = '';															-- presume that SSRN is valid
	local id_num;
	local text;
	
	id_num = id:match ('^%d+$');												-- id must be all digits

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 100 &gt; id_num or test_limit &lt; id_num then								-- if SSRN is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_ssrn' );							-- set an error message
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_ssrn' );								-- set an error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;

	return text;
end


--[[--------------------------&lt; U S E N E T _ I D &gt;------------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function usenet_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_usenet_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; Z B L &gt;-----------------------------------------------------------------------

A numerical identifier in the form nnnn.nnnnn - leading zeros in the first quartet optional

]]

local function zbl (id)
	local handler = cfg.id_handlers['ZBL'];
	local id_num;
	local err_cat = '';
	
	id_num = id:match ('^[Zz][Bb][Ll](.*)$');									-- identifier with zbl prefix; extract identifier

	if is_set (id_num) then
		add_maint_cat ('zbl_format');
	else																		-- plain number without zbl prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num:match('^%d?%d?%d?%d%.%d%d%d%d%d$') then
		id = id_num;															-- id matches pattern
	else
		err_cat = ' ' .. set_error( 'bad_zbl' );								-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--============================&lt;&lt; I N T E R F A C E   F U N C T I O N S &gt;&gt;==========================================

--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v, ['access'] = options.IdAccessLevels[k] }, fallback(k) );

		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, asin( v, options.ASINTLD ) } ); 
		elseif k == 'BIBCODE' then
			table.insert( new_list, {handler.label, bibcode( v, handler.access ) } );
		elseif k == 'BIORXIV' then
			table.insert( new_list, {handler.label, biorxiv( v ) } );
		elseif k == 'CITESEERX' then
			table.insert( new_list, {handler.label, citeseerx( v ) } );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken, handler.access ) } );
		elseif k == 'EISSN' then
			table.insert( new_list, {handler.label, issn( v, true ) } );		-- true distinguishes eissn from issn
		elseif k == 'HDL' then
			table.insert( new_list, {handler.label, hdl( v, handler.access ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			local check;
			local err_type = '';
			check, err_type = isbn( v );
			if not check then
				if is_set(options.IgnoreISBN) then								-- ISBN is invalid; if |ignore-isbn-error= set
					add_maint_cat ('ignore_isbn_err');							-- ad a maint category
				else
					ISBN = ISBN .. set_error( 'bad_isbn', {err_type}, false, &quot; &quot;, &quot;&quot; );	-- else display an error message
				end
			elseif is_set(options.IgnoreISBN) then								-- ISBN is OK; if |ignore-isbn-error= set
				add_maint_cat ('ignore_isbn_err');								-- because |ignore-isbn-error= unnecessary
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'JFM' then
			table.insert( new_list, {handler.label, jfm( v ) } );
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'MR' then
			table.insert( new_list, {handler.label, mr( v ) } );
		elseif k == 'OCLC' then
			table.insert( new_list, {handler.label, oclc( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v, handler.access ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'SSRN' then
			table.insert( new_list, {handler.label, ssrn( v ) } );
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, usenet_id( v ) } );
		elseif k == 'ZBL' then
			table.insert( new_list, {handler.label, zbl( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1]:lower() &lt; b[1]:lower();
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; E X T R A C T _ I D _ A C C E S S _ L E V E L S &gt;--------------------------------------

Fetches custom id access levels from arguments using configuration settings.
Parameters which have a predefined access level (e.g. arxiv) do not use this
function as they are directly rendered as free without using an additional parameter.

]]

local function extract_id_access_levels( args, id_list )
	local id_accesses_list = {};
	for k, v in pairs( cfg.id_handlers ) do
		local access_param = v.custom_access;
		local k_lower = string.lower(k);
		if is_set(access_param) then
			local access_level = args[access_param];
			if is_set(access_level) then
				if not in_array (access_level:lower(), cfg.keywords['id-access']) then
					table.insert( z.message_tail, { set_error( 'invalid_param_val', {access_param, access_level}, true ) } );	
					access_level = nil;
				end
				if not is_set(id_list[k]) then
					table.insert( z.message_tail, { set_error( 'param_access_requires_param', {k_lower}, true ) } );
				end
				if is_set(access_level) then
					access_level = access_level:lower();
				end
				id_accesses_list[k] = access_level;
			end
		end
	end
	return id_accesses_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	set_error = utilities_page_ptr.set_error;
	select_one = utilities_page_ptr.select_one;
	add_maint_cat = utilities_page_ptr.add_maint_cat;
	substitute = utilities_page_ptr.substitute;
	make_wikilink = utilities_page_ptr.make_wikilink;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	extract_id_access_levels = extract_id_access_levels,
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>kz3qvcbhsyebx3ayza344d5o0gpnstg</sha1>
    </revision>
    <revision>
      <id>4907</id>
      <parentid>4906</parentid>
      <timestamp>2019-06-06T10:10:57Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>pmc limit adjust;</comment>
      <origin>4907</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="48756" sha1="pbkdpd56hhqm0xp814fcu42s34l3qef" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat, substitute, make_wikilink;	-- functions in Module:Citation/CS1/Utilities

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration

local wd_int_lang = (mw.site.server:match ('wikidata') and mw.getCurrentFrame():preprocess('{{int:lang}}')) or '';


--============================&lt;&lt; H E L P E R   F U N C T I O N S &gt;&gt;============================================

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	local ext_link;
	local this_wiki_code;														-- wikipedia subdomain; 'en' for en.wikipedia.org
	local wd_article;															-- article title from wikidata
	
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end

	ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or &quot;&quot;, mw.text.nowiki(options.id));
	if is_set(options.access) then
		ext_link = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[options.access].class, cfg.presentation[options.access].title, ext_link});	-- add the free-to-read / paywall lock
	end

	this_wiki_code = mw.language.getContentLanguage():getCode();				-- get this wikipedia's language code (subdomain)
	
	if string.match (mw.site.server, 'wikidata') then
		this_wiki_code = mw.getCurrentFrame():preprocess('{{int:lang}}');		-- on wikidata so use interface language setting instead
	end
	
	if is_set (options.q) and mw.wikibase then									-- wikibase test here avoids script errors in third party wikis that aren't using mw.wikibase extension
		wd_article = mw.wikibase.getEntity (options.q):getSitelink (this_wiki_code .. 'wiki');	-- fetch article title from wd
		if wd_article then
			wd_article = table.concat ({':', this_wiki_code, ':', wd_article});	-- make interwiki link if taken from wd; leading colon required
		end
	end

	return table.concat	({
		make_wikilink (wd_article or options.link, options.label),				-- wikidata link or locally specified
		options.separator or '&amp;nbsp;',
		ext_link
		});
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	local id = mw.ustring.gsub (options.id, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9

	return table.concat (
		{
		make_wikilink (options.link, options.label),
		options.separator or '&amp;nbsp;',
		make_wikilink (
			table.concat (
				{
				options.prefix,
				id,																-- translated to western digits
				options.suffix or ''
				}),
			substitute (cfg.presentation['bdi'], {'', mw.text.nowiki (options.id)})	-- bdi tags to prevent Latn script identifiers from being reversed at rtl language wikis
			);																	-- nowiki because MediaWiki still has magic links for ISBN and the like; TODO: is it really required?
		});
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9' → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N _ 1 3 &gt;-----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--============================&lt;&lt; I D E N T I F I E R   F U N C T I O N S &gt;&gt;====================================

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation; not the same as |class= parameter which is not supported in this form
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = false;														-- assume no error message
	local text;																	-- output text
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
				err_cat = true;													-- flag for error message
		end

	else
		err_cat = true;															-- not a recognized format; flag for error message
	end

	err_cat = err_cat and table.concat ({' ', set_error ('bad_arxiv')}) or '';	-- set error message if flag is true
	
	text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;

	if is_set (class) then
		if id:match ('^%d+') then
			text = table.concat ({text, ' [[//arxiv.org/archive/', class, ' ', class, ']]'});	-- external link within square brackets, not wikilink
		else
			text = table.concat ({text, ' ', set_error ('class_ignored')});		
		end
	end

	return text;	
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode id.

Format for bibcodes is specified here: http://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6 must be letter, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		7–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		9–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (id, access)
	local handler = cfg.id_handlers['BIBCODE'];
	local err_type;
	local year;

	local text = external_link_id({link=handler.link, label=handler.label, q = handler.q,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
		access=access});
	
	if 19 ~= id:len() then
		err_type = 'length';
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%a&amp;%.][%a&amp;%.%d][%a&amp;%.%d][%a%d%.]+[%a%.]$&quot;)	-- 
		if not year then														-- if nil then no pattern match
			err_type = 'value';													-- so value error
		else
			local next_year = tonumber(os.date ('%Y'))+1;						-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = 'year';												-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = 'journal';											-- journal abbreviation must not have '&amp;.' (if it does its missing a letter)
			end
		end
	end

	if is_set (err_type) then													-- if there was an error detected
		text = text .. ' ' .. set_error( 'bad_bibcode', {err_type});
	end
	return text;
end


--[[--------------------------&lt; B I O R X I V &gt;-----------------------------------------------------------------

Format bioRxiv id and do simple error checking.  BiorXiv ids are exactly 6 digits.
The bioRxiv id is the number following the last slash in the bioRxiv-issued DOI:
https://doi.org/10.1101/078733 -&gt; 078733

]]

local function biorxiv(id)
	local handler = cfg.id_handlers['BIORXIV'];
	local err_cat = '';															-- presume that bioRxiv id is valid
	
	if nil == id:match(&quot;^%d%d%d%d%d%d$&quot;) then									-- if bioRxiv id has anything but six digits
		err_cat = ' ' .. set_error( 'bad_biorxiv');	-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator,
			encode=handler.encode, access=handler.access}) .. err_cat;
end


--[[--------------------------&lt; C I T E S E E R X &gt;------------------------------------------------------------

CiteSeerX use their own notion of &quot;doi&quot; (not to be confused with the identifiers resolved via doi.org).

The description of the structure of this identifier can be found at Help_talk:Citation_Style_1/Archive_26#CiteSeerX_id_structure
]]

local function citeseerx (id)
	local handler = cfg.id_handlers['CITESEERX'];
	local matched;
	
	local text = external_link_id({link=handler.link, label=handler.label, q = handler.q,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
		access=handler.access});
	
	matched = id:match (&quot;^10%.1%.1%.[1-9]%d?%d?%d?%.[1-9]%d?%d?%d?$&quot;);
	if not matched then
		text = text .. ' ' .. set_error( 'bad_citeseerx' );
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive, access)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';					-- try to get the year portion from the inactive date
		if is_set(inactive_year) then
			table.insert( z.error_categories, &quot;Pages with DOIs inactive as of &quot; .. inactive_year );
		else
			table.insert( z.error_categories, &quot;Pages with inactive DOIs&quot; );		-- when inactive doesn't contain a recognizable year
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. &quot; &quot; .. inactive .. &quot;)&quot; 
	end
	text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access}) .. (inactive or '')

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) then						-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		cat = ' ' .. set_error( 'bad_doi' );
	end

	return text .. cat 
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

]]

local function hdl(id, access)
	local handler = cfg.id_handlers['HDL'];
	
	local text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- hdl must contain a fwd slash, must not contain spaces, endashes, and must not end with period or comma
		text = text .. ' ' .. set_error( 'bad_hdl' );
	end
	return text;
end


--[[--------------------------&lt; I S B N &gt;----------------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then
		return false, 'invalid character';										-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );						-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false, 'length';													-- fail if incorrect length
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then								-- fail if isbn_str has 'X' anywhere but last position
			return false, 'invalid form';									
		end
		return is_valid_isxn(isbn_str, 10), 'checksum';
	else
		if isbn_str:match( &quot;^%d+$&quot; ) == nil then
			return false, 'invalid character';									-- fail if isbn13 is not all digits
		end
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then
			return false, 'invalid prefix';										-- fail when isbn13 does not begin with 978 or 979
		end
		return is_valid_isxn_13 (isbn_str), 'checksum';
	end
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

This function is positioned here because it calls isbn()

]]

local function asin(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat = ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then							-- if 10-digit numeric (or 9 digits with terminal X)
			if isbn( id ) then													-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat = ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat = ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, q = handler.q, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;
	local id_copy;

	id_copy = id;																-- save a copy because this testing is destructive
	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text = table.concat (
		{
		make_wikilink (handler.link, handler.label),
		handler.separator,
		id_copy
		});		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the ismn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]	-- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id, e)
	local issn_copy = id;														-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler;
	local text;
	local valid_issn = true;
	
	if e then
		 handler = cfg.id_handlers['EISSN'];
	else
		 handler = cfg.id_handlers['ISSN'];
	end

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then						-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;														-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);										-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );				-- if valid, display correctly formatted version
	else
		id = issn_copy;															-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn', e and 'e' or '' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; J F M &gt;-----------------------------------------------------------------------

A numerical identifier in the form nn.nnnn.nn

]]

local function jfm (id)
	local handler = cfg.id_handlers['JFM'];
	local id_num;
	local err_cat = '';
	
	id_num = id:match ('^[Jj][Ff][Mm](.*)$');									-- identifier with jfm prefix; extract identifier

	if is_set (id_num) then
		add_maint_cat ('jfm_format');
	else																		-- plain number without mr prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num and id_num:match('^%d%d%.%d%d%d%d%.%d%d$') then
		id = id_num;															-- jfm matches pattern
	else
		err_cat = ' ' .. set_error( 'bad_jfm' );								-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat = '';															-- presume that LCCN is valid
	local id = lccn;															-- local copy of the lccn

	id = normalize_lccn (id);													-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();														-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- set an error message
		end
	elseif 9 == len then														-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then							-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- set an error message
		end
	elseif 10 == len then														-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then					-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );						-- no match, set an error message
			end
		end
	elseif 11 == len then														-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- no match, set an error message
		end
	elseif 12 == len then														-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then						-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );								-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );								-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; M R &gt;--------------------------------------------------------------------------

A seven digit number; if not seven digits, zero-fill leading digits to make seven digits.

]]

local function mr (id)
	local handler = cfg.id_handlers['MR'];
	local id_num;
	local id_len;
	local err_cat = '';
	
	id_num = id:match ('^[Mm][Rr](%d+)$');										-- identifier with mr prefix

	if is_set (id_num) then
		add_maint_cat ('mr_format');
	else																		-- plain number without mr prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	id_len = id_num and id_num:len() or 0;
	if (7 &gt;= id_len) and (0 ~= id_len) then
		id = string.rep ('0', 7-id_len ) .. id_num;								-- zero-fill leading digits
	else
		err_cat = ' ' .. set_error( 'bad_mr' );									-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an oclc id.  https://www.oclc.org/batchload/controlnumber.en.html {{dead link}}
archived at: https://web.archive.org/web/20161228233804/https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (id)
	local handler = cfg.id_handlers['OCLC'];
	local number;
	local err_msg = '';															-- empty string for concatenation
	
	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- contrain to 1 to 9 digits; change this when oclc issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if 10 &lt; number:len() then
			number = nil;														-- contrain to 1 to 10 digits; change this when oclc issues 11-digit numbers
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		err_msg = ' ' .. set_error( 'bad_oclc' )								-- add an error message if the id is malformed
	end
	
	local text = external_link_id({link=handler.link, label=handler.label, q = handler.q,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode}) .. err_msg;

	return text;
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id, access)
	local code;
	local handler = cfg.id_handlers['OL'];
	local ident;
	
	ident, code = id:gsub('^OL', ''):match(&quot;^(%d+([AMW]))$&quot;);					-- optional OL prefix followed immediately by digits followed by 'A', 'M', or 'W'; remove OL prefix

	if not is_set (ident) then													-- if malformed return an error
		return external_link_id({link=handler.link, label=handler.label, q = handler.q,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access}) .. ' ' .. set_error( 'bad_ol' );
	end
	
	id = ident;																	-- use ident without the optional OL prefix (it has been removed)
	
	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label, q = handler.q,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end
	
	if ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label, q = handler.q,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end

	if ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label, q = handler.q,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 7000000;													-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat = '';															-- presume that PMC is valid
	local id_num;
	local text;
	
	id_num = id:match ('^[Pp][Mm][Cc](%d+)$');									-- identifier with pmc prefix

	if is_set (id_num) then
		add_maint_cat ('pmc_format');
	else																		-- plain number without pmc prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then								-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );							-- set an error message
		else
			id = tostring (id_num);												-- make sure id is a string
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_pmc' );								-- set an error message
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text = table.concat (													-- still embargoed so no external link
			{
			make_wikilink (handler.link, handler.label),
			handler.separator,
			id,
			err_cat
			});
	else
		text = external_link_id({link = handler.link, label = handler.label, q = handler.q,	-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 32000000;												-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat = '';															-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then													-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );								-- set an error message
	else																		-- PMID is only digits
		local id_num = tonumber(id);											-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then								-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );							-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; S S R N &gt;----------------------------------------------------------------------

Format an ssrn, do simple error checking

SSRNs are sequential numbers beginning at 100? and counting up.  This code checks the ssrn to see that it is
only digits and is greater than 99 and less than test_limit; the value in local variable test_limit will need
to be updated periodically as more SSRNs are issued.

]]

local function ssrn (id)
	local test_limit = 3500000;													-- update this value as SSRNs approach
	local handler = cfg.id_handlers['SSRN'];
	local err_cat = '';															-- presume that SSRN is valid
	local id_num;
	local text;
	
	id_num = id:match ('^%d+$');												-- id must be all digits

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 100 &gt; id_num or test_limit &lt; id_num then								-- if SSRN is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_ssrn' );							-- set an error message
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_ssrn' );								-- set an error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;

	return text;
end


--[[--------------------------&lt; U S E N E T _ I D &gt;------------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function usenet_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_usenet_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; Z B L &gt;-----------------------------------------------------------------------

A numerical identifier in the form nnnn.nnnnn - leading zeros in the first quartet optional

]]

local function zbl (id)
	local handler = cfg.id_handlers['ZBL'];
	local id_num;
	local err_cat = '';
	
	id_num = id:match ('^[Zz][Bb][Ll](.*)$');									-- identifier with zbl prefix; extract identifier

	if is_set (id_num) then
		add_maint_cat ('zbl_format');
	else																		-- plain number without zbl prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num:match('^%d?%d?%d?%d%.%d%d%d%d%d$') then
		id = id_num;															-- id matches pattern
	else
		err_cat = ' ' .. set_error( 'bad_zbl' );								-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--============================&lt;&lt; I N T E R F A C E   F U N C T I O N S &gt;&gt;==========================================

--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v, ['access'] = options.IdAccessLevels[k] }, fallback(k) );

		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, asin( v, options.ASINTLD ) } ); 
		elseif k == 'BIBCODE' then
			table.insert( new_list, {handler.label, bibcode( v, handler.access ) } );
		elseif k == 'BIORXIV' then
			table.insert( new_list, {handler.label, biorxiv( v ) } );
		elseif k == 'CITESEERX' then
			table.insert( new_list, {handler.label, citeseerx( v ) } );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken, handler.access ) } );
		elseif k == 'EISSN' then
			table.insert( new_list, {handler.label, issn( v, true ) } );		-- true distinguishes eissn from issn
		elseif k == 'HDL' then
			table.insert( new_list, {handler.label, hdl( v, handler.access ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			local check;
			local err_type = '';
			check, err_type = isbn( v );
			if not check then
				if is_set(options.IgnoreISBN) then								-- ISBN is invalid; if |ignore-isbn-error= set
					add_maint_cat ('ignore_isbn_err');							-- ad a maint category
				else
					ISBN = ISBN .. set_error( 'bad_isbn', {err_type}, false, &quot; &quot;, &quot;&quot; );	-- else display an error message
				end
			elseif is_set(options.IgnoreISBN) then								-- ISBN is OK; if |ignore-isbn-error= set
				add_maint_cat ('ignore_isbn_err');								-- because |ignore-isbn-error= unnecessary
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'JFM' then
			table.insert( new_list, {handler.label, jfm( v ) } );
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'MR' then
			table.insert( new_list, {handler.label, mr( v ) } );
		elseif k == 'OCLC' then
			table.insert( new_list, {handler.label, oclc( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v, handler.access ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'SSRN' then
			table.insert( new_list, {handler.label, ssrn( v ) } );
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, usenet_id( v ) } );
		elseif k == 'ZBL' then
			table.insert( new_list, {handler.label, zbl( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1]:lower() &lt; b[1]:lower();
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; E X T R A C T _ I D _ A C C E S S _ L E V E L S &gt;--------------------------------------

Fetches custom id access levels from arguments using configuration settings.
Parameters which have a predefined access level (e.g. arxiv) do not use this
function as they are directly rendered as free without using an additional parameter.

]]

local function extract_id_access_levels( args, id_list )
	local id_accesses_list = {};
	for k, v in pairs( cfg.id_handlers ) do
		local access_param = v.custom_access;
		local k_lower = string.lower(k);
		if is_set(access_param) then
			local access_level = args[access_param];
			if is_set(access_level) then
				if not in_array (access_level:lower(), cfg.keywords['id-access']) then
					table.insert( z.message_tail, { set_error( 'invalid_param_val', {access_param, access_level}, true ) } );	
					access_level = nil;
				end
				if not is_set(id_list[k]) then
					table.insert( z.message_tail, { set_error( 'param_access_requires_param', {k_lower}, true ) } );
				end
				if is_set(access_level) then
					access_level = access_level:lower();
				end
				id_accesses_list[k] = access_level;
			end
		end
	end
	return id_accesses_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	set_error = utilities_page_ptr.set_error;
	select_one = utilities_page_ptr.select_one;
	add_maint_cat = utilities_page_ptr.add_maint_cat;
	substitute = utilities_page_ptr.substitute;
	make_wikilink = utilities_page_ptr.make_wikilink;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	extract_id_access_levels = extract_id_access_levels,
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>pbkdpd56hhqm0xp814fcu42s34l3qef</sha1>
    </revision>
    <revision>
      <id>4908</id>
      <parentid>4907</parentid>
      <timestamp>2019-09-03T11:05:55Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4908</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="49768" sha1="2z0ni34e7yfzrvk1bxstpdkhudyssqz" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat, substitute, make_wikilink;	-- functions in Module:Citation/CS1/Utilities

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--============================&lt;&lt; H E L P E R   F U N C T I O N S &gt;&gt;============================================

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	local ext_link;
	local this_wiki_code;														-- wikipedia subdomain; 'en' for en.wikipedia.org
	local wd_article;															-- article title from wikidata
	
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end

	ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or &quot;&quot;, mw.text.nowiki(options.id));
	if is_set(options.access) then
		ext_link = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[options.access].class, cfg.presentation[options.access].title, ext_link});	-- add the free-to-read / paywall lock
	end

	this_wiki_code = mw.language.getContentLanguage():getCode();				-- get this wikipedia's language code (subdomain)
	
	if string.match (mw.site.server, 'wikidata') then
		this_wiki_code = mw.getCurrentFrame():preprocess('{{int:lang}}');		-- on wikidata so use interface language setting instead
	end
	
	if is_set (options.q) and mw.wikibase then									-- wikibase test here avoids script errors in third party wikis that aren't using mw.wikibase extension
		wd_article = mw.wikibase.getEntity (options.q):getSitelink (this_wiki_code .. 'wiki');	-- fetch article title from wd
		if wd_article then
			wd_article = table.concat ({':', this_wiki_code, ':', wd_article});	-- make interwiki link if taken from wd; leading colon required
		end
	end

	return table.concat	({
		make_wikilink (wd_article or options.link, options.label),				-- wikidata link or locally specified
		options.separator or '&amp;nbsp;',
		ext_link
		});
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	local id = mw.ustring.gsub (options.id, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9

	return table.concat (
		{
		make_wikilink (options.link, options.label),
		options.separator or '&amp;nbsp;',
		make_wikilink (
			table.concat (
				{
				options.prefix,
				id,																-- translated to western digits
				options.suffix or ''
				}),
			substitute (cfg.presentation['bdi'], {'', mw.text.nowiki (options.id)})	-- bdi tags to prevent Latn script identifiers from being reversed at rtl language wikis
			);																	-- nowiki because MediaWiki still has magic links for ISBN and the like; TODO: is it really required?
		});
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9' → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N _ 1 3 &gt;-----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--============================&lt;&lt; I D E N T I F I E R   F U N C T I O N S &gt;&gt;====================================

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation; not the same as |class= parameter which is not supported in this form
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = false;														-- assume no error message
	local text;																	-- output text
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
				err_cat = true;													-- flag for error message
		end

	else
		err_cat = true;															-- not a recognized format; flag for error message
	end

	err_cat = err_cat and table.concat ({' ', set_error ('bad_arxiv')}) or '';	-- set error message if flag is true
	
	text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;

	if is_set (class) then
		if id:match ('^%d+') then
			text = table.concat ({text, ' [[//arxiv.org/archive/', class, ' ', class, ']]'});	-- external link within square brackets, not wikilink
		else
			text = table.concat ({text, ' ', set_error ('class_ignored')});		
		end
	end

	return text;	
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode id.

Format for bibcodes is specified here: http://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		9–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (id, access)
	local handler = cfg.id_handlers['BIBCODE'];
	local err_type;
	local year;

	local text = external_link_id({link=handler.link, label=handler.label, q = handler.q,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
		access=access});
	
	if 19 ~= id:len() then
		err_type = 'length';
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%w&amp;%.][%w&amp;%.][%w&amp;%.][%w.]+[%a%.]$&quot;)	-- 
		if not year then														-- if nil then no pattern match
			err_type = 'value';													-- so value error
		else
			local next_year = tonumber(os.date ('%Y'))+1;						-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = 'year';												-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = 'journal';											-- journal abbreviation must not have '&amp;.' (if it does its missing a letter)
			end
		end
	end

	if is_set (err_type) then													-- if there was an error detected
		text = text .. ' ' .. set_error( 'bad_bibcode', {err_type});
	end
	return text;
end


--[[--------------------------&lt; B I O R X I V &gt;-----------------------------------------------------------------

Format bioRxiv id and do simple error checking.  BiorXiv ids are exactly 6 digits.
The bioRxiv id is the number following the last slash in the bioRxiv-issued DOI:
https://doi.org/10.1101/078733 -&gt; 078733

]]

local function biorxiv(id)
	local handler = cfg.id_handlers['BIORXIV'];
	local err_cat = '';															-- presume that bioRxiv id is valid
	
	if nil == id:match(&quot;^%d%d%d%d%d%d$&quot;) then									-- if bioRxiv id has anything but six digits
		err_cat = ' ' .. set_error( 'bad_biorxiv');	-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator,
			encode=handler.encode, access=handler.access}) .. err_cat;
end


--[[--------------------------&lt; C I T E S E E R X &gt;------------------------------------------------------------

CiteSeerX use their own notion of &quot;doi&quot; (not to be confused with the identifiers resolved via doi.org).

The description of the structure of this identifier can be found at Help_talk:Citation_Style_1/Archive_26#CiteSeerX_id_structure
]]

local function citeseerx (id)
	local handler = cfg.id_handlers['CITESEERX'];
	local matched;
	
	local text = external_link_id({link=handler.link, label=handler.label, q = handler.q,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
		access=handler.access});
	
	matched = id:match (&quot;^10%.1%.1%.[1-9]%d?%d?%d?%.[1-9]%d?%d?%d?$&quot;);
	if not matched then
		text = text .. ' ' .. set_error( 'bad_citeseerx' );
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive, access)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';					-- try to get the year portion from the inactive date
		local inactive_month, good;

		if is_set (inactive_year) then
			if 4 &lt; inactive:len() then											-- inactive date has more than just a year (could be anything)
				local lang_obj = mw.getContentLanguage();						-- get a language object for this wiki
				good, inactive_month = pcall (lang_obj.formatDate, lang_obj, 'F', inactive);	-- try to get the month name from the inactive date
				if not good then
					inactive_month = nil;										-- something went wrong so make sure this is unset
				end
			end
		else
			inactive_year = nil;												-- |doi-broken= has something but it isn't a date
		end
		
		if is_set(inactive_year) and is_set (inactive_month) then
			table.insert( z.error_categories, 'Pages with DOIs inactive as of ' .. inactive_year .. ' ' .. inactive_month);	-- use inactive month in category name
		elseif is_set(inactive_year) then
			table.insert( z.error_categories, 'Pages with DOIs inactive as of ' .. inactive_year);
		else
			table.insert( z.error_categories, 'Pages with inactive DOIs');		-- when inactive doesn't contain a recognizable date
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. ' ' .. inactive .. ')';
	end

	text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access}) .. (inactive or '')

	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) or						-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
		id: match ('^10.5555') then												-- test doi will never resolve
			cat = ' ' .. set_error ('bad_doi');
	end

	return text .. cat 
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

]]

local function hdl(id, access)
	local handler = cfg.id_handlers['HDL'];
	
	local text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- hdl must contain a fwd slash, must not contain spaces, endashes, and must not end with period or comma
		text = text .. ' ' .. set_error( 'bad_hdl' );
	end
	return text;
end


--[[--------------------------&lt; I S B N &gt;----------------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then
		return false, 'invalid character';										-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );						-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false, 'length';													-- fail if incorrect length
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then								-- fail if isbn_str has 'X' anywhere but last position
			return false, 'invalid form';									
		end
		return is_valid_isxn(isbn_str, 10), 'checksum';
	else
		if isbn_str:match( &quot;^%d+$&quot; ) == nil then
			return false, 'invalid character';									-- fail if isbn13 is not all digits
		end
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then
			return false, 'invalid prefix';										-- fail when isbn13 does not begin with 978 or 979
		end
		return is_valid_isxn_13 (isbn_str), 'checksum';
	end
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

This function is positioned here because it calls isbn()

]]

local function asin(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat = ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then							-- if 10-digit numeric (or 9 digits with terminal X)
			if isbn( id ) then													-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat = ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat = ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, q = handler.q, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;
	local id_copy;

	id_copy = id;																-- save a copy because this testing is destructive
	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text = table.concat (
		{
		make_wikilink (handler.link, handler.label),
		handler.separator,
		id_copy
		});		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the ismn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]	-- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id, e)
	local issn_copy = id;														-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler;
	local text;
	local valid_issn = true;
	
	if e then
		 handler = cfg.id_handlers['EISSN'];
	else
		 handler = cfg.id_handlers['ISSN'];
	end

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then						-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;														-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);										-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );				-- if valid, display correctly formatted version
	else
		id = issn_copy;															-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn', e and 'e' or '' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; J F M &gt;-----------------------------------------------------------------------

A numerical identifier in the form nn.nnnn.nn

]]

local function jfm (id)
	local handler = cfg.id_handlers['JFM'];
	local id_num;
	local err_cat = '';
	
	id_num = id:match ('^[Jj][Ff][Mm](.*)$');									-- identifier with jfm prefix; extract identifier

	if is_set (id_num) then
		add_maint_cat ('jfm_format');
	else																		-- plain number without mr prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num and id_num:match('^%d%d%.%d%d%d%d%.%d%d$') then
		id = id_num;															-- jfm matches pattern
	else
		err_cat = ' ' .. set_error( 'bad_jfm' );								-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat = '';															-- presume that LCCN is valid
	local id = lccn;															-- local copy of the lccn

	id = normalize_lccn (id);													-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();														-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- set an error message
		end
	elseif 9 == len then														-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then							-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- set an error message
		end
	elseif 10 == len then														-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then					-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );						-- no match, set an error message
			end
		end
	elseif 11 == len then														-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- no match, set an error message
		end
	elseif 12 == len then														-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then						-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );								-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );								-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; M R &gt;--------------------------------------------------------------------------

A seven digit number; if not seven digits, zero-fill leading digits to make seven digits.

]]

local function mr (id)
	local handler = cfg.id_handlers['MR'];
	local id_num;
	local id_len;
	local err_cat = '';
	
	id_num = id:match ('^[Mm][Rr](%d+)$');										-- identifier with mr prefix

	if is_set (id_num) then
		add_maint_cat ('mr_format');
	else																		-- plain number without mr prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	id_len = id_num and id_num:len() or 0;
	if (7 &gt;= id_len) and (0 ~= id_len) then
		id = string.rep ('0', 7-id_len ) .. id_num;								-- zero-fill leading digits
	else
		err_cat = ' ' .. set_error( 'bad_mr' );									-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an oclc id.  https://www.oclc.org/batchload/controlnumber.en.html {{dead link}}
archived at: https://web.archive.org/web/20161228233804/https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (id)
	local handler = cfg.id_handlers['OCLC'];
	local number;
	local err_msg = '';															-- empty string for concatenation
	
	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- contrain to 1 to 9 digits; change this when oclc issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if 10 &lt; number:len() then
			number = nil;														-- contrain to 1 to 10 digits; change this when oclc issues 11-digit numbers
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		err_msg = ' ' .. set_error( 'bad_oclc' )								-- add an error message if the id is malformed
	end
	
	local text = external_link_id({link=handler.link, label=handler.label, q = handler.q,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode}) .. err_msg;

	return text;
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id, access)
	local code;
	local handler = cfg.id_handlers['OL'];
	local ident;
	
	ident, code = id:gsub('^OL', ''):match(&quot;^(%d+([AMW]))$&quot;);					-- optional OL prefix followed immediately by digits followed by 'A', 'M', or 'W'; remove OL prefix

	if not is_set (ident) then													-- if malformed return an error
		return external_link_id({link=handler.link, label=handler.label, q = handler.q,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access}) .. ' ' .. set_error( 'bad_ol' );
	end
	
	id = ident;																	-- use ident without the optional OL prefix (it has been removed)
	
	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label, q = handler.q,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end
	
	if ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label, q = handler.q,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end

	if ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label, q = handler.q,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 7000000;													-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat = '';															-- presume that PMC is valid
	local id_num;
	local text;
	
	id_num = id:match ('^[Pp][Mm][Cc](%d+)$');									-- identifier with pmc prefix

	if is_set (id_num) then
		add_maint_cat ('pmc_format');
	else																		-- plain number without pmc prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then								-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );							-- set an error message
		else
			id = tostring (id_num);												-- make sure id is a string
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_pmc' );								-- set an error message
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text = table.concat (													-- still embargoed so no external link
			{
			make_wikilink (handler.link, handler.label),
			handler.separator,
			id,
			err_cat
			});
	else
		text = external_link_id({link = handler.link, label = handler.label, q = handler.q,	-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 32000000;												-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat = '';															-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then													-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );								-- set an error message
	else																		-- PMID is only digits
		local id_num = tonumber(id);											-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then								-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );							-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; S S R N &gt;----------------------------------------------------------------------

Format an ssrn, do simple error checking

SSRNs are sequential numbers beginning at 100? and counting up.  This code checks the ssrn to see that it is
only digits and is greater than 99 and less than test_limit; the value in local variable test_limit will need
to be updated periodically as more SSRNs are issued.

]]

local function ssrn (id)
	local test_limit = 3500000;													-- update this value as SSRNs approach
	local handler = cfg.id_handlers['SSRN'];
	local err_cat = '';															-- presume that SSRN is valid
	local id_num;
	local text;
	
	id_num = id:match ('^%d+$');												-- id must be all digits

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 100 &gt; id_num or test_limit &lt; id_num then								-- if SSRN is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_ssrn' );							-- set an error message
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_ssrn' );								-- set an error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;

	return text;
end


--[[--------------------------&lt; U S E N E T _ I D &gt;------------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function usenet_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_usenet_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; Z B L &gt;-----------------------------------------------------------------------

A numerical identifier in the form nnnn.nnnnn - leading zeros in the first quartet optional

format described here: http://emis.mi.sanu.ac.rs/ZMATH/zmath/en/help/search/

temporary format is apparently eight digits.  Anything else is an error

]]

local function zbl (id)
	local handler = cfg.id_handlers['ZBL'];
	local err_cat = '';
	
	if id:match('^%d%d%d%d%d%d%d%d$') then										-- is this identifier using temporary format?
		add_maint_cat ('zbl');													-- yes, add maint cat
	elseif not id:match('^%d?%d?%d?%d%.%d%d%d%d%d$') then						-- not temporary, is it normal format?
		err_cat = ' ' .. set_error( 'bad_zbl' );								-- no, set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--============================&lt;&lt; I N T E R F A C E   F U N C T I O N S &gt;&gt;==========================================

--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v, ['access'] = options.IdAccessLevels[k] }, fallback(k) );

		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, asin( v, options.ASINTLD ) } ); 
		elseif k == 'BIBCODE' then
			table.insert( new_list, {handler.label, bibcode( v, handler.access ) } );
		elseif k == 'BIORXIV' then
			table.insert( new_list, {handler.label, biorxiv( v ) } );
		elseif k == 'CITESEERX' then
			table.insert( new_list, {handler.label, citeseerx( v ) } );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken, handler.access ) } );
		elseif k == 'EISSN' then
			table.insert( new_list, {handler.label, issn( v, true ) } );		-- true distinguishes eissn from issn
		elseif k == 'HDL' then
			table.insert( new_list, {handler.label, hdl( v, handler.access ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			local check;
			local err_type = '';
			check, err_type = isbn( v );
			if not check then
				if is_set(options.IgnoreISBN) then								-- ISBN is invalid; if |ignore-isbn-error= set
					add_maint_cat ('ignore_isbn_err');							-- ad a maint category
				else
					ISBN = ISBN .. set_error( 'bad_isbn', {err_type}, false, &quot; &quot;, &quot;&quot; );	-- else display an error message
				end
			elseif is_set(options.IgnoreISBN) then								-- ISBN is OK; if |ignore-isbn-error= set
				add_maint_cat ('ignore_isbn_err');								-- because |ignore-isbn-error= unnecessary
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'JFM' then
			table.insert( new_list, {handler.label, jfm( v ) } );
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'MR' then
			table.insert( new_list, {handler.label, mr( v ) } );
		elseif k == 'OCLC' then
			table.insert( new_list, {handler.label, oclc( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v, handler.access ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'SSRN' then
			table.insert( new_list, {handler.label, ssrn( v ) } );
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, usenet_id( v ) } );
		elseif k == 'ZBL' then
			table.insert( new_list, {handler.label, zbl( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1]:lower() &lt; b[1]:lower();
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; E X T R A C T _ I D _ A C C E S S _ L E V E L S &gt;--------------------------------------

Fetches custom id access levels from arguments using configuration settings.
Parameters which have a predefined access level (e.g. arxiv) do not use this
function as they are directly rendered as free without using an additional parameter.

access-level values must match the case used in cfg.keywords['id-access'] (lowercase unless there is some special reason for something else)

]]

local function extract_id_access_levels( args, id_list )
	local id_accesses_list = {};
	for k, v in pairs( cfg.id_handlers ) do
		local access_param = v.custom_access;									-- name of identifier's access-level parameter
		if is_set(access_param) then
			local access_level = args[access_param];							-- get the assigned value if there is one
			if is_set (access_level) then
				if not in_array (access_level, cfg.keywords['id-access']) then	-- exact match required
					table.insert( z.message_tail, { set_error( 'invalid_param_val', {access_param, access_level}, true ) } );	
					access_level = nil;											-- invalid so unset
				end
				if not is_set(id_list[k]) then									-- identifer access-level must have a matching identifier
					table.insert( z.message_tail, { set_error( 'param_access_requires_param', {k:lower()}, true ) } );	-- param name is uppercase in cfg.id_handlers (k); lowercase for error message
				end
				id_accesses_list[k] = access_level;
			end
		end
	end
	return id_accesses_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	set_error = utilities_page_ptr.set_error;
	select_one = utilities_page_ptr.select_one;
	add_maint_cat = utilities_page_ptr.add_maint_cat;
	substitute = utilities_page_ptr.substitute;
	make_wikilink = utilities_page_ptr.make_wikilink;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	extract_id_access_levels = extract_id_access_levels,
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>2z0ni34e7yfzrvk1bxstpdkhudyssqz</sha1>
    </revision>
    <revision>
      <id>4909</id>
      <parentid>4908</parentid>
      <timestamp>2020-01-11T12:32:47Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4909</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="51323" sha1="kxfzv3mpubt34g5y5wzxzug8hssna7f" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat, substitute, make_wikilink;	-- functions in Module:Citation/CS1/Utilities

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--============================&lt;&lt; H E L P E R   F U N C T I O N S &gt;&gt;============================================

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	local ext_link;
	local this_wiki_code = cfg.this_wiki_code;									-- wikipedia subdomain; 'en' for en.wikipedia.org
	local wd_article;															-- article title from wikidata
	
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end

	ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or &quot;&quot;, mw.text.nowiki(options.id));
	if is_set(options.access) then
		ext_link = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[options.access].class, cfg.presentation[options.access].title, ext_link});	-- add the free-to-read / paywall lock
	end

--	this_wiki_code = mw.language.getContentLanguage():getCode();				-- get this wikipedia's language code (subdomain)
	
	if string.match (mw.site.server, 'wikidata') then
		this_wiki_code = mw.getCurrentFrame():preprocess('{{int:lang}}');		-- on wikidata so use interface language setting instead
	end
	
	if is_set (options.q) and mw.wikibase then									-- wikibase test here avoids script errors in third party wikis that aren't using mw.wikibase extension
		wd_article = mw.wikibase.getEntity (options.q):getSitelink (this_wiki_code .. 'wiki');	-- fetch article title from wd
		if wd_article then
			wd_article = table.concat ({':', this_wiki_code, ':', wd_article});	-- make interwiki link if taken from wd; leading colon required
		end
	end

	return table.concat	({
		make_wikilink (wd_article or options.link, options.label),				-- wikidata link or locally specified
		options.separator or '&amp;nbsp;',
		ext_link
		});
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	local id = mw.ustring.gsub (options.id, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9

	return table.concat (
		{
		make_wikilink (options.link, options.label),
		options.separator or '&amp;nbsp;',
		make_wikilink (
			table.concat (
				{
				options.prefix,
				id,																-- translated to western digits
				options.suffix or ''
				}),
			substitute (cfg.presentation['bdi'], {'', mw.text.nowiki (options.id)})	-- bdi tags to prevent Latn script identifiers from being reversed at rtl language wikis
			);																	-- nowiki because MediaWiki still has magic links for ISBN and the like; TODO: is it really required?
		});
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9' → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N _ 1 3 &gt;-----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--============================&lt;&lt; I D E N T I F I E R   F U N C T I O N S &gt;&gt;====================================

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation; not the same as |class= parameter which is not supported in this form
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = false;														-- assume no error message
	local text;																	-- output text
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
				err_cat = true;													-- flag for error message
		end

	else
		err_cat = true;															-- not a recognized format; flag for error message
	end

	err_cat = err_cat and table.concat ({' ', set_error ('bad_arxiv')}) or '';	-- set error message if flag is true
	
	text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;

	if is_set (class) then
		if id:match ('^%d+') then
			text = table.concat ({text, ' [[//arxiv.org/archive/', class, ' ', class, ']]'});	-- external link within square brackets, not wikilink
		else
			text = table.concat ({text, ' ', set_error ('class_ignored')});		
		end
	end

	return text;	
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode id.

Format for bibcodes is specified here: http://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		9–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (id, access)
	local handler = cfg.id_handlers['BIBCODE'];
	local err_type;
	local year;

	local text = external_link_id({link=handler.link, label=handler.label, q = handler.q,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
		access=access});
	
	if 19 ~= id:len() then
		err_type = 'length';
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%w&amp;%.][%w&amp;%.][%w&amp;%.][%w.]+[%a%.]$&quot;)	-- 
		if not year then														-- if nil then no pattern match
			err_type = 'value';													-- so value error
		else
			local next_year = tonumber(os.date ('%Y'))+1;						-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = 'year';												-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = 'journal';											-- journal abbreviation must not have '&amp;.' (if it does its missing a letter)
			end
		end
	end

	if is_set (err_type) then													-- if there was an error detected
		text = text .. ' ' .. set_error( 'bad_bibcode', {err_type});
	end
	return text;
end


--[[--------------------------&lt; B I O R X I V &gt;-----------------------------------------------------------------

Format bioRxiv id and do simple error checking.  BiorXiv ids are exactly 6 digits.
The bioRxiv id is the number following the last slash in the bioRxiv-issued DOI:
https://doi.org/10.1101/078733 -&gt; 078733

]]

local function biorxiv(id)
	local handler = cfg.id_handlers['BIORXIV'];
	local err_cat = '';															-- presume that bioRxiv id is valid
	
	if nil == id:match(&quot;^%d%d%d%d%d%d$&quot;) then									-- if bioRxiv id has anything but six digits
		err_cat = ' ' .. set_error( 'bad_biorxiv');	-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator,
			encode=handler.encode, access=handler.access}) .. err_cat;
end


--[[--------------------------&lt; C I T E S E E R X &gt;------------------------------------------------------------

CiteSeerX use their own notion of &quot;doi&quot; (not to be confused with the identifiers resolved via doi.org).

The description of the structure of this identifier can be found at Help_talk:Citation_Style_1/Archive_26#CiteSeerX_id_structure
]]

local function citeseerx (id)
	local handler = cfg.id_handlers['CITESEERX'];
	local matched;
	
	local text = external_link_id({link=handler.link, label=handler.label, q = handler.q,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
		access=handler.access});
	
	matched = id:match (&quot;^10%.1%.1%.[1-9]%d?%d?%d?%.[1-9]%d?%d?%d?$&quot;);
	if not matched then
		text = text .. ' ' .. set_error( 'bad_citeseerx' );
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive, access)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';					-- try to get the year portion from the inactive date
		local inactive_month, good;

		if is_set (inactive_year) then
			if 4 &lt; inactive:len() then											-- inactive date has more than just a year (could be anything)
				local lang_obj = mw.getContentLanguage();						-- get a language object for this wiki
				good, inactive_month = pcall (lang_obj.formatDate, lang_obj, 'F', inactive);	-- try to get the month name from the inactive date
				if not good then
					inactive_month = nil;										-- something went wrong so make sure this is unset
				end
			end
		else
			inactive_year = nil;												-- |doi-broken= has something but it isn't a date
		end
		
		if is_set(inactive_year) and is_set (inactive_month) then
			table.insert( z.error_categories, 'Pages with DOIs inactive as of ' .. inactive_year .. ' ' .. inactive_month);	-- use inactive month in category name
		elseif is_set(inactive_year) then
			table.insert( z.error_categories, 'Pages with DOIs inactive as of ' .. inactive_year);
		else
			table.insert( z.error_categories, 'Pages with inactive DOIs');		-- when inactive doesn't contain a recognizable date
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. ' ' .. inactive .. ')';
	end

	text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access}) .. (inactive or '')

--	if nil == id:match(&quot;^10%.[^%s–]-/[^%s–]-[^%.,]$&quot;) or						-- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
--		id: match ('^10.5555') then												-- test doi will never resolve
--			cat = ' ' .. set_error ('bad_doi');
--	end
	
	local registrant = id:match ('^10%.([^/]+)/[^%s–]-[^%.,]$');				-- registrant set when doi has the proper basic form
	
	registrant_err_patterns = {													-- these patterns are for code ranges that are not supported 
		'^[^1-3]%d%d%d%d%.%d%d*$',												-- 5 digits with subcode (0xxxx, 40000+); accecpts: 10000–39999
		'^[^1-3]%d%d%d%d$',														-- 5 digits without subcode (0xxxx, 40000+); accecpts: 10000–39999
		'^[^1-9]%d%d%d%.%d%d*$',												-- 4 digits with subcode (0xxx); accecpts: 1000–9999
		'^[^1-9]%d%d%d$',														-- 4 digits without subcode (0xxx); accecpts: 1000–9999
		'^%d%d%d%d%d%d+',														-- 6 or more digits
		'^%d%d?%d?%.%d%d*$',													-- less than 4 digits with subcode
		'^%d%d?%d?$',															-- less than 4 digits without subcode
		'^5555$',																-- test registrant will never resolve
		}
	
	if registrant then															-- when doi has proper form
		for i, pattern in ipairs (registrant_err_patterns) do					-- spin through error patterns
			if registrant:match (pattern) then									-- to validate registrant codes
				cat = ' ' .. set_error ('bad_doi');								-- when found, mark this doi as bad
				break;															-- and done
			end
		end
	else
		cat = ' ' .. set_error ('bad_doi');										-- invalid directory or malformed
	end

	return text .. cat 
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

]]

local function hdl(id, access)
	local handler = cfg.id_handlers['HDL'];
	
	local text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- hdl must contain a fwd slash, must not contain spaces, endashes, and must not end with period or comma
		text = text .. ' ' .. set_error( 'bad_hdl' );
	end
	return text;
end


--[[--------------------------&lt; I S B N &gt;----------------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then
		return false, 'invalid character';										-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );						-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false, 'length';													-- fail if incorrect length
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then								-- fail if isbn_str has 'X' anywhere but last position
			return false, 'invalid form';									
		end
		return is_valid_isxn(isbn_str, 10), 'checksum';
	else
		if isbn_str:match( &quot;^%d+$&quot; ) == nil then
			return false, 'invalid character';									-- fail if isbn13 is not all digits
		end
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then
			return false, 'invalid prefix';										-- fail when isbn13 does not begin with 978 or 979
		end
		if isbn_str:match ('^9790') then
			return false, 'invalid group id';									-- group identifier '0' is reserved to ismn
		end
		return is_valid_isxn_13 (isbn_str), 'checksum';
	end
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

This function is positioned here because it calls isbn()

]]

local function asin(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat = ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then							-- if 10-digit numeric (or 9 digits with terminal X)
			if isbn( id ) then													-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat = ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat = ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, q = handler.q, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;
	local id_copy;

	id_copy = id;																-- save a copy because this testing is destructive
	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text = table.concat (
		{
		make_wikilink (handler.link, handler.label),
		handler.separator,
		id_copy
		});		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the ismn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]	-- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id, e)
	local issn_copy = id;														-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler;
	local text;
	local valid_issn = true;
	
	if e then
		 handler = cfg.id_handlers['EISSN'];
	else
		 handler = cfg.id_handlers['ISSN'];
	end

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then						-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;														-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);										-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );				-- if valid, display correctly formatted version
	else
		id = issn_copy;															-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn', e and 'e' or '' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; J F M &gt;-----------------------------------------------------------------------

A numerical identifier in the form nn.nnnn.nn

]]

local function jfm (id)
	local handler = cfg.id_handlers['JFM'];
	local id_num;
	local err_cat = '';
	
	id_num = id:match ('^[Jj][Ff][Mm](.*)$');									-- identifier with jfm prefix; extract identifier

	if is_set (id_num) then
		add_maint_cat ('jfm_format');
	else																		-- plain number without mr prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num and id_num:match('^%d%d%.%d%d%d%d%.%d%d$') then
		id = id_num;															-- jfm matches pattern
	else
		err_cat = ' ' .. set_error( 'bad_jfm' );								-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat = '';															-- presume that LCCN is valid
	local id = lccn;															-- local copy of the lccn

	id = normalize_lccn (id);													-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();														-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- set an error message
		end
	elseif 9 == len then														-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then							-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- set an error message
		end
	elseif 10 == len then														-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then					-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );						-- no match, set an error message
			end
		end
	elseif 11 == len then														-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- no match, set an error message
		end
	elseif 12 == len then														-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then						-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );								-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );								-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; M R &gt;--------------------------------------------------------------------------

A seven digit number; if not seven digits, zero-fill leading digits to make seven digits.

]]

local function mr (id)
	local handler = cfg.id_handlers['MR'];
	local id_num;
	local id_len;
	local err_cat = '';
	
	id_num = id:match ('^[Mm][Rr](%d+)$');										-- identifier with mr prefix

	if is_set (id_num) then
		add_maint_cat ('mr_format');
	else																		-- plain number without mr prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	id_len = id_num and id_num:len() or 0;
	if (7 &gt;= id_len) and (0 ~= id_len) then
		id = string.rep ('0', 7-id_len ) .. id_num;								-- zero-fill leading digits
	else
		err_cat = ' ' .. set_error( 'bad_mr' );									-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an oclc id.  https://www.oclc.org/batchload/controlnumber.en.html {{dead link}}
archived at: https://web.archive.org/web/20161228233804/https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (id)
	local handler = cfg.id_handlers['OCLC'];
	local number;
	local err_msg = '';															-- empty string for concatenation
	
	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- contrain to 1 to 9 digits; change this when oclc issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if 10 &lt; number:len() then
			number = nil;														-- contrain to 1 to 10 digits; change this when oclc issues 11-digit numbers
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		err_msg = ' ' .. set_error( 'bad_oclc' )								-- add an error message if the id is malformed
	end
	
	local text = external_link_id({link=handler.link, label=handler.label, q = handler.q,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode}) .. err_msg;

	return text;
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id, access)
	local code;
	local handler = cfg.id_handlers['OL'];
	local ident;
	
	ident, code = id:gsub('^OL', ''):match(&quot;^(%d+([AMW]))$&quot;);					-- optional OL prefix followed immediately by digits followed by 'A', 'M', or 'W'; remove OL prefix

	if not is_set (ident) then													-- if malformed return an error
		return external_link_id({link=handler.link, label=handler.label, q = handler.q,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access}) .. ' ' .. set_error( 'bad_ol' );
	end
	
	id = ident;																	-- use ident without the optional OL prefix (it has been removed)
	
	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label, q = handler.q,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end
	
	if ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label, q = handler.q,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end

	if ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label, q = handler.q,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 7000000;													-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat = '';															-- presume that PMC is valid
	local id_num;
	local text;
	
	id_num = id:match ('^[Pp][Mm][Cc](%d+)$');									-- identifier with pmc prefix

	if is_set (id_num) then
		add_maint_cat ('pmc_format');
	else																		-- plain number without pmc prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then								-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );							-- set an error message
		else
			id = tostring (id_num);												-- make sure id is a string
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_pmc' );								-- set an error message
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text = table.concat (													-- still embargoed so no external link
			{
			make_wikilink (handler.link, handler.label),
			handler.separator,
			id,
			err_cat
			});
	else
		text = external_link_id({link = handler.link, label = handler.label, q = handler.q,	-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 32000000;												-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat = '';															-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then													-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );								-- set an error message
	else																		-- PMID is only digits
		local id_num = tonumber(id);											-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then								-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );							-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; S S R N &gt;----------------------------------------------------------------------

Format an ssrn, do simple error checking

SSRNs are sequential numbers beginning at 100? and counting up.  This code checks the ssrn to see that it is
only digits and is greater than 99 and less than test_limit; the value in local variable test_limit will need
to be updated periodically as more SSRNs are issued.

]]

local function ssrn (id)
	local test_limit = 3500000;													-- update this value as SSRNs approach
	local handler = cfg.id_handlers['SSRN'];
	local err_cat = '';															-- presume that SSRN is valid
	local id_num;
	local text;
	
	id_num = id:match ('^%d+$');												-- id must be all digits

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 100 &gt; id_num or test_limit &lt; id_num then								-- if SSRN is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_ssrn' );							-- set an error message
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_ssrn' );								-- set an error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;

	return text;
end


--[[--------------------------&lt; U S E N E T _ I D &gt;------------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function usenet_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_usenet_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; Z B L &gt;-----------------------------------------------------------------------

A numerical identifier in the form nnnn.nnnnn - leading zeros in the first quartet optional

format described here: http://emis.mi.sanu.ac.rs/ZMATH/zmath/en/help/search/

temporary format is apparently eight digits.  Anything else is an error

]]

local function zbl (id)
	local handler = cfg.id_handlers['ZBL'];
	local err_cat = '';
	
	if id:match('^%d%d%d%d%d%d%d%d$') then										-- is this identifier using temporary format?
		add_maint_cat ('zbl');													-- yes, add maint cat
	elseif not id:match('^%d?%d?%d?%d%.%d%d%d%d%d$') then						-- not temporary, is it normal format?
		err_cat = ' ' .. set_error( 'bad_zbl' );								-- no, set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--============================&lt;&lt; I N T E R F A C E   F U N C T I O N S &gt;&gt;==========================================

--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v, ['access'] = options.IdAccessLevels[k] }, fallback(k) );

		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, asin( v, options.ASINTLD ) } ); 
		elseif k == 'BIBCODE' then
			table.insert( new_list, {handler.label, bibcode( v, handler.access ) } );
		elseif k == 'BIORXIV' then
			table.insert( new_list, {handler.label, biorxiv( v ) } );
		elseif k == 'CITESEERX' then
			table.insert( new_list, {handler.label, citeseerx( v ) } );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken, handler.access ) } );
		elseif k == 'EISSN' then
			table.insert( new_list, {handler.label, issn( v, true ) } );		-- true distinguishes eissn from issn
		elseif k == 'HDL' then
			table.insert( new_list, {handler.label, hdl( v, handler.access ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			local check;
			local err_type = '';
			check, err_type = isbn( v );
			if not check then
				if is_set(options.IgnoreISBN) then								-- ISBN is invalid; if |ignore-isbn-error= set
					add_maint_cat ('ignore_isbn_err');							-- ad a maint category
				else
					ISBN = ISBN .. set_error( 'bad_isbn', {err_type}, false, &quot; &quot;, &quot;&quot; );	-- else display an error message
				end
			elseif is_set(options.IgnoreISBN) then								-- ISBN is OK; if |ignore-isbn-error= set
				add_maint_cat ('ignore_isbn_err');								-- because |ignore-isbn-error= unnecessary
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'JFM' then
			table.insert( new_list, {handler.label, jfm( v ) } );
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'MR' then
			table.insert( new_list, {handler.label, mr( v ) } );
		elseif k == 'OCLC' then
			table.insert( new_list, {handler.label, oclc( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v, handler.access ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'SSRN' then
			table.insert( new_list, {handler.label, ssrn( v ) } );
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, usenet_id( v ) } );
		elseif k == 'ZBL' then
			table.insert( new_list, {handler.label, zbl( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1]:lower() &lt; b[1]:lower();
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; E X T R A C T _ I D _ A C C E S S _ L E V E L S &gt;--------------------------------------

Fetches custom id access levels from arguments using configuration settings.
Parameters which have a predefined access level (e.g. arxiv) do not use this
function as they are directly rendered as free without using an additional parameter.

access-level values must match the case used in cfg.keywords_lists['id-access'] (lowercase unless there is some special reason for something else)

]]

local function extract_id_access_levels( args, id_list )
	local id_accesses_list = {};
	for k, v in pairs( cfg.id_handlers ) do
		local access_param = v.custom_access;									-- name of identifier's access-level parameter
		if is_set(access_param) then
			local access_level = args[access_param];							-- get the assigned value if there is one
			if is_set (access_level) then
				if not in_array (access_level, cfg.keywords_lists['id-access']) then	-- exact match required
					table.insert( z.message_tail, { set_error( 'invalid_param_val', {access_param, access_level}, true ) } );	
					access_level = nil;											-- invalid so unset
				end
				if not is_set(id_list[k]) then									-- identifer access-level must have a matching identifier
					table.insert( z.message_tail, { set_error( 'param_access_requires_param', {k:lower()}, true ) } );	-- param name is uppercase in cfg.id_handlers (k); lowercase for error message
				end
				id_accesses_list[k] = cfg.keywords_xlate[access_level];			-- get translated keyword
			end
		end
	end
	return id_accesses_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	set_error = utilities_page_ptr.set_error;
	select_one = utilities_page_ptr.select_one;
	add_maint_cat = utilities_page_ptr.add_maint_cat;
	substitute = utilities_page_ptr.substitute;
	make_wikilink = utilities_page_ptr.make_wikilink;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	extract_id_access_levels = extract_id_access_levels,
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>kxfzv3mpubt34g5y5wzxzug8hssna7f</sha1>
    </revision>
    <revision>
      <id>4910</id>
      <parentid>4909</parentid>
      <timestamp>2020-01-18T14:28:37Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync doi() from sandbox to fix minor error because same time fixed lua script error in ~/Date validation;</comment>
      <origin>4910</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="50962" sha1="8hl1mgk74e25ils9xklvpyp5ny0qbtx" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat, substitute, make_wikilink;	-- functions in Module:Citation/CS1/Utilities

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--============================&lt;&lt; H E L P E R   F U N C T I O N S &gt;&gt;============================================

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	local ext_link;
	local this_wiki_code = cfg.this_wiki_code;									-- wikipedia subdomain; 'en' for en.wikipedia.org
	local wd_article;															-- article title from wikidata
	
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end

	ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or &quot;&quot;, mw.text.nowiki(options.id));
	if is_set(options.access) then
		ext_link = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[options.access].class, cfg.presentation[options.access].title, ext_link});	-- add the free-to-read / paywall lock
	end

--	this_wiki_code = mw.language.getContentLanguage():getCode();				-- get this wikipedia's language code (subdomain)
	
	if string.match (mw.site.server, 'wikidata') then
		this_wiki_code = mw.getCurrentFrame():preprocess('{{int:lang}}');		-- on wikidata so use interface language setting instead
	end
	
	if is_set (options.q) and mw.wikibase then									-- wikibase test here avoids script errors in third party wikis that aren't using mw.wikibase extension
		wd_article = mw.wikibase.getEntity (options.q):getSitelink (this_wiki_code .. 'wiki');	-- fetch article title from wd
		if wd_article then
			wd_article = table.concat ({':', this_wiki_code, ':', wd_article});	-- make interwiki link if taken from wd; leading colon required
		end
	end

	return table.concat	({
		make_wikilink (wd_article or options.link, options.label),				-- wikidata link or locally specified
		options.separator or '&amp;nbsp;',
		ext_link
		});
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	local id = mw.ustring.gsub (options.id, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9

	return table.concat (
		{
		make_wikilink (options.link, options.label),
		options.separator or '&amp;nbsp;',
		make_wikilink (
			table.concat (
				{
				options.prefix,
				id,																-- translated to western digits
				options.suffix or ''
				}),
			substitute (cfg.presentation['bdi'], {'', mw.text.nowiki (options.id)})	-- bdi tags to prevent Latn script identifiers from being reversed at rtl language wikis
			);																	-- nowiki because MediaWiki still has magic links for ISBN and the like; TODO: is it really required?
		});
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9' → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N _ 1 3 &gt;-----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--============================&lt;&lt; I D E N T I F I E R   F U N C T I O N S &gt;&gt;====================================

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation; not the same as |class= parameter which is not supported in this form
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = false;														-- assume no error message
	local text;																	-- output text
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
				err_cat = true;													-- flag for error message
		end

	else
		err_cat = true;															-- not a recognized format; flag for error message
	end

	err_cat = err_cat and table.concat ({' ', set_error ('bad_arxiv')}) or '';	-- set error message if flag is true
	
	text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;

	if is_set (class) then
		if id:match ('^%d+') then
			text = table.concat ({text, ' [[//arxiv.org/archive/', class, ' ', class, ']]'});	-- external link within square brackets, not wikilink
		else
			text = table.concat ({text, ' ', set_error ('class_ignored')});		
		end
	end

	return text;	
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode id.

Format for bibcodes is specified here: http://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		9–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (id, access)
	local handler = cfg.id_handlers['BIBCODE'];
	local err_type;
	local year;

	local text = external_link_id({link=handler.link, label=handler.label, q = handler.q,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
		access=access});
	
	if 19 ~= id:len() then
		err_type = 'length';
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%w&amp;%.][%w&amp;%.][%w&amp;%.][%w.]+[%a%.]$&quot;)	-- 
		if not year then														-- if nil then no pattern match
			err_type = 'value';													-- so value error
		else
			local next_year = tonumber(os.date ('%Y'))+1;						-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = 'year';												-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = 'journal';											-- journal abbreviation must not have '&amp;.' (if it does its missing a letter)
			end
		end
	end

	if is_set (err_type) then													-- if there was an error detected
		text = text .. ' ' .. set_error( 'bad_bibcode', {err_type});
	end
	return text;
end


--[[--------------------------&lt; B I O R X I V &gt;-----------------------------------------------------------------

Format bioRxiv id and do simple error checking.  BiorXiv ids are exactly 6 digits.
The bioRxiv id is the number following the last slash in the bioRxiv-issued DOI:
https://doi.org/10.1101/078733 -&gt; 078733

]]

local function biorxiv(id)
	local handler = cfg.id_handlers['BIORXIV'];
	local err_cat = '';															-- presume that bioRxiv id is valid
	
	if nil == id:match(&quot;^%d%d%d%d%d%d$&quot;) then									-- if bioRxiv id has anything but six digits
		err_cat = ' ' .. set_error( 'bad_biorxiv');	-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator,
			encode=handler.encode, access=handler.access}) .. err_cat;
end


--[[--------------------------&lt; C I T E S E E R X &gt;------------------------------------------------------------

CiteSeerX use their own notion of &quot;doi&quot; (not to be confused with the identifiers resolved via doi.org).

The description of the structure of this identifier can be found at Help_talk:Citation_Style_1/Archive_26#CiteSeerX_id_structure
]]

local function citeseerx (id)
	local handler = cfg.id_handlers['CITESEERX'];
	local matched;
	
	local text = external_link_id({link=handler.link, label=handler.label, q = handler.q,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
		access=handler.access});
	
	matched = id:match (&quot;^10%.1%.1%.[1-9]%d?%d?%d?%.[1-9]%d?%d?%d?$&quot;);
	if not matched then
		text = text .. ' ' .. set_error( 'bad_citeseerx' );
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive, access)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';					-- try to get the year portion from the inactive date
		local inactive_month, good;

		if is_set (inactive_year) then
			if 4 &lt; inactive:len() then											-- inactive date has more than just a year (could be anything)
				local lang_obj = mw.getContentLanguage();						-- get a language object for this wiki
				good, inactive_month = pcall (lang_obj.formatDate, lang_obj, 'F', inactive);	-- try to get the month name from the inactive date
				if not good then
					inactive_month = nil;										-- something went wrong so make sure this is unset
				end
			end
		else
			inactive_year = nil;												-- |doi-broken= has something but it isn't a date
		end
		
		if is_set(inactive_year) and is_set (inactive_month) then
			table.insert( z.error_categories, 'Pages with DOIs inactive as of ' .. inactive_year .. ' ' .. inactive_month);	-- use inactive month in category name
		elseif is_set(inactive_year) then
			table.insert( z.error_categories, 'Pages with DOIs inactive as of ' .. inactive_year);
		else
			table.insert( z.error_categories, 'Pages with inactive DOIs');		-- when inactive doesn't contain a recognizable date
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. ' ' .. inactive .. ')';
	end

	text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access}) .. (inactive or '')

	local registrant = id:match ('^10%.([^/]+)/[^%s–]-[^%.,]$');				-- registrant set when doi has the proper basic form
	
	registrant_err_patterns = {													-- these patterns are for code ranges that are not supported 
		'^[^1-3]%d%d%d%d%.%d%d*$',												-- 5 digits with subcode (0xxxx, 40000+); accecpts: 10000–39999
		'^[^1-3]%d%d%d%d$',														-- 5 digits without subcode (0xxxx, 40000+); accecpts: 10000–39999
		'^[^1-9]%d%d%d%.%d%d*$',												-- 4 digits with subcode (0xxx); accecpts: 1000–9999
		'^[^1-9]%d%d%d$',														-- 4 digits without subcode (0xxx); accecpts: 1000–9999
		'^%d%d%d%d%d%d+',														-- 6 or more digits
		'^%d%d?%d?$',															-- less than 4 digits without subcode (with subcode is legitimate)
		'^5555$',																-- test registrant will never resolve
		}
	
	if registrant then															-- when doi has proper form
		for i, pattern in ipairs (registrant_err_patterns) do					-- spin through error patterns
			if registrant:match (pattern) then									-- to validate registrant codes
				cat = ' ' .. set_error ('bad_doi');								-- when found, mark this doi as bad
				break;															-- and done
			end
		end
	else
		cat = ' ' .. set_error ('bad_doi');										-- invalid directory or malformed
	end

	return text .. cat 
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

]]

local function hdl(id, access)
	local handler = cfg.id_handlers['HDL'];
	
	local text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- hdl must contain a fwd slash, must not contain spaces, endashes, and must not end with period or comma
		text = text .. ' ' .. set_error( 'bad_hdl' );
	end
	return text;
end


--[[--------------------------&lt; I S B N &gt;----------------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then
		return false, 'invalid character';										-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );						-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false, 'length';													-- fail if incorrect length
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then								-- fail if isbn_str has 'X' anywhere but last position
			return false, 'invalid form';									
		end
		return is_valid_isxn(isbn_str, 10), 'checksum';
	else
		if isbn_str:match( &quot;^%d+$&quot; ) == nil then
			return false, 'invalid character';									-- fail if isbn13 is not all digits
		end
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then
			return false, 'invalid prefix';										-- fail when isbn13 does not begin with 978 or 979
		end
		if isbn_str:match ('^9790') then
			return false, 'invalid group id';									-- group identifier '0' is reserved to ismn
		end
		return is_valid_isxn_13 (isbn_str), 'checksum';
	end
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

This function is positioned here because it calls isbn()

]]

local function asin(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat = ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then							-- if 10-digit numeric (or 9 digits with terminal X)
			if isbn( id ) then													-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat = ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat = ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, q = handler.q, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;
	local id_copy;

	id_copy = id;																-- save a copy because this testing is destructive
	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text = table.concat (
		{
		make_wikilink (handler.link, handler.label),
		handler.separator,
		id_copy
		});		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the ismn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]	-- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id, e)
	local issn_copy = id;														-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler;
	local text;
	local valid_issn = true;
	
	if e then
		 handler = cfg.id_handlers['EISSN'];
	else
		 handler = cfg.id_handlers['ISSN'];
	end

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then						-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;														-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);										-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );				-- if valid, display correctly formatted version
	else
		id = issn_copy;															-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn', e and 'e' or '' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; J F M &gt;-----------------------------------------------------------------------

A numerical identifier in the form nn.nnnn.nn

]]

local function jfm (id)
	local handler = cfg.id_handlers['JFM'];
	local id_num;
	local err_cat = '';
	
	id_num = id:match ('^[Jj][Ff][Mm](.*)$');									-- identifier with jfm prefix; extract identifier

	if is_set (id_num) then
		add_maint_cat ('jfm_format');
	else																		-- plain number without mr prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num and id_num:match('^%d%d%.%d%d%d%d%.%d%d$') then
		id = id_num;															-- jfm matches pattern
	else
		err_cat = ' ' .. set_error( 'bad_jfm' );								-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat = '';															-- presume that LCCN is valid
	local id = lccn;															-- local copy of the lccn

	id = normalize_lccn (id);													-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();														-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- set an error message
		end
	elseif 9 == len then														-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then							-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- set an error message
		end
	elseif 10 == len then														-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then					-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );						-- no match, set an error message
			end
		end
	elseif 11 == len then														-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- no match, set an error message
		end
	elseif 12 == len then														-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then						-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );								-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );								-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; M R &gt;--------------------------------------------------------------------------

A seven digit number; if not seven digits, zero-fill leading digits to make seven digits.

]]

local function mr (id)
	local handler = cfg.id_handlers['MR'];
	local id_num;
	local id_len;
	local err_cat = '';
	
	id_num = id:match ('^[Mm][Rr](%d+)$');										-- identifier with mr prefix

	if is_set (id_num) then
		add_maint_cat ('mr_format');
	else																		-- plain number without mr prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	id_len = id_num and id_num:len() or 0;
	if (7 &gt;= id_len) and (0 ~= id_len) then
		id = string.rep ('0', 7-id_len ) .. id_num;								-- zero-fill leading digits
	else
		err_cat = ' ' .. set_error( 'bad_mr' );									-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an oclc id.  https://www.oclc.org/batchload/controlnumber.en.html {{dead link}}
archived at: https://web.archive.org/web/20161228233804/https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (id)
	local handler = cfg.id_handlers['OCLC'];
	local number;
	local err_msg = '';															-- empty string for concatenation
	
	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- contrain to 1 to 9 digits; change this when oclc issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if 10 &lt; number:len() then
			number = nil;														-- contrain to 1 to 10 digits; change this when oclc issues 11-digit numbers
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		err_msg = ' ' .. set_error( 'bad_oclc' )								-- add an error message if the id is malformed
	end
	
	local text = external_link_id({link=handler.link, label=handler.label, q = handler.q,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode}) .. err_msg;

	return text;
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id, access)
	local code;
	local handler = cfg.id_handlers['OL'];
	local ident;
	
	ident, code = id:gsub('^OL', ''):match(&quot;^(%d+([AMW]))$&quot;);					-- optional OL prefix followed immediately by digits followed by 'A', 'M', or 'W'; remove OL prefix

	if not is_set (ident) then													-- if malformed return an error
		return external_link_id({link=handler.link, label=handler.label, q = handler.q,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access}) .. ' ' .. set_error( 'bad_ol' );
	end
	
	id = ident;																	-- use ident without the optional OL prefix (it has been removed)
	
	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label, q = handler.q,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end
	
	if ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label, q = handler.q,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end

	if ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label, q = handler.q,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 7000000;													-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat = '';															-- presume that PMC is valid
	local id_num;
	local text;
	
	id_num = id:match ('^[Pp][Mm][Cc](%d+)$');									-- identifier with pmc prefix

	if is_set (id_num) then
		add_maint_cat ('pmc_format');
	else																		-- plain number without pmc prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then								-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );							-- set an error message
		else
			id = tostring (id_num);												-- make sure id is a string
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_pmc' );								-- set an error message
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text = table.concat (													-- still embargoed so no external link
			{
			make_wikilink (handler.link, handler.label),
			handler.separator,
			id,
			err_cat
			});
	else
		text = external_link_id({link = handler.link, label = handler.label, q = handler.q,	-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 32000000;												-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat = '';															-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then													-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );								-- set an error message
	else																		-- PMID is only digits
		local id_num = tonumber(id);											-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then								-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );							-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; S S R N &gt;----------------------------------------------------------------------

Format an ssrn, do simple error checking

SSRNs are sequential numbers beginning at 100? and counting up.  This code checks the ssrn to see that it is
only digits and is greater than 99 and less than test_limit; the value in local variable test_limit will need
to be updated periodically as more SSRNs are issued.

]]

local function ssrn (id)
	local test_limit = 3500000;													-- update this value as SSRNs approach
	local handler = cfg.id_handlers['SSRN'];
	local err_cat = '';															-- presume that SSRN is valid
	local id_num;
	local text;
	
	id_num = id:match ('^%d+$');												-- id must be all digits

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 100 &gt; id_num or test_limit &lt; id_num then								-- if SSRN is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_ssrn' );							-- set an error message
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_ssrn' );								-- set an error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;

	return text;
end


--[[--------------------------&lt; U S E N E T _ I D &gt;------------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function usenet_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_usenet_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; Z B L &gt;-----------------------------------------------------------------------

A numerical identifier in the form nnnn.nnnnn - leading zeros in the first quartet optional

format described here: http://emis.mi.sanu.ac.rs/ZMATH/zmath/en/help/search/

temporary format is apparently eight digits.  Anything else is an error

]]

local function zbl (id)
	local handler = cfg.id_handlers['ZBL'];
	local err_cat = '';
	
	if id:match('^%d%d%d%d%d%d%d%d$') then										-- is this identifier using temporary format?
		add_maint_cat ('zbl');													-- yes, add maint cat
	elseif not id:match('^%d?%d?%d?%d%.%d%d%d%d%d$') then						-- not temporary, is it normal format?
		err_cat = ' ' .. set_error( 'bad_zbl' );								-- no, set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--============================&lt;&lt; I N T E R F A C E   F U N C T I O N S &gt;&gt;==========================================

--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v, ['access'] = options.IdAccessLevels[k] }, fallback(k) );

		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, asin( v, options.ASINTLD ) } ); 
		elseif k == 'BIBCODE' then
			table.insert( new_list, {handler.label, bibcode( v, handler.access ) } );
		elseif k == 'BIORXIV' then
			table.insert( new_list, {handler.label, biorxiv( v ) } );
		elseif k == 'CITESEERX' then
			table.insert( new_list, {handler.label, citeseerx( v ) } );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken, handler.access ) } );
		elseif k == 'EISSN' then
			table.insert( new_list, {handler.label, issn( v, true ) } );		-- true distinguishes eissn from issn
		elseif k == 'HDL' then
			table.insert( new_list, {handler.label, hdl( v, handler.access ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			local check;
			local err_type = '';
			check, err_type = isbn( v );
			if not check then
				if is_set(options.IgnoreISBN) then								-- ISBN is invalid; if |ignore-isbn-error= set
					add_maint_cat ('ignore_isbn_err');							-- ad a maint category
				else
					ISBN = ISBN .. set_error( 'bad_isbn', {err_type}, false, &quot; &quot;, &quot;&quot; );	-- else display an error message
				end
			elseif is_set(options.IgnoreISBN) then								-- ISBN is OK; if |ignore-isbn-error= set
				add_maint_cat ('ignore_isbn_err');								-- because |ignore-isbn-error= unnecessary
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'JFM' then
			table.insert( new_list, {handler.label, jfm( v ) } );
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'MR' then
			table.insert( new_list, {handler.label, mr( v ) } );
		elseif k == 'OCLC' then
			table.insert( new_list, {handler.label, oclc( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v, handler.access ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'SSRN' then
			table.insert( new_list, {handler.label, ssrn( v ) } );
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, usenet_id( v ) } );
		elseif k == 'ZBL' then
			table.insert( new_list, {handler.label, zbl( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1]:lower() &lt; b[1]:lower();
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; E X T R A C T _ I D _ A C C E S S _ L E V E L S &gt;--------------------------------------

Fetches custom id access levels from arguments using configuration settings.
Parameters which have a predefined access level (e.g. arxiv) do not use this
function as they are directly rendered as free without using an additional parameter.

access-level values must match the case used in cfg.keywords_lists['id-access'] (lowercase unless there is some special reason for something else)

]]

local function extract_id_access_levels( args, id_list )
	local id_accesses_list = {};
	for k, v in pairs( cfg.id_handlers ) do
		local access_param = v.custom_access;									-- name of identifier's access-level parameter
		if is_set(access_param) then
			local access_level = args[access_param];							-- get the assigned value if there is one
			if is_set (access_level) then
				if not in_array (access_level, cfg.keywords_lists['id-access']) then	-- exact match required
					table.insert( z.message_tail, { set_error( 'invalid_param_val', {access_param, access_level}, true ) } );	
					access_level = nil;											-- invalid so unset
				end
				if not is_set(id_list[k]) then									-- identifer access-level must have a matching identifier
					table.insert( z.message_tail, { set_error( 'param_access_requires_param', {k:lower()}, true ) } );	-- param name is uppercase in cfg.id_handlers (k); lowercase for error message
				end
				id_accesses_list[k] = cfg.keywords_xlate[access_level];			-- get translated keyword
			end
		end
	end
	return id_accesses_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	set_error = utilities_page_ptr.set_error;
	select_one = utilities_page_ptr.select_one;
	add_maint_cat = utilities_page_ptr.add_maint_cat;
	substitute = utilities_page_ptr.substitute;
	make_wikilink = utilities_page_ptr.make_wikilink;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	extract_id_access_levels = extract_id_access_levels,
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>8hl1mgk74e25ils9xklvpyp5ny0qbtx</sha1>
    </revision>
    <revision>
      <id>4911</id>
      <parentid>4910</parentid>
      <timestamp>2020-02-02T03:49:58Z</timestamp>
      <contributor>
        <username>Izno</username>
        <id>817</id>
      </contributor>
      <comment>willing to deploy out of cycle given these were just updated</comment>
      <origin>4911</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="50962" sha1="pghk7ye5bidm921n1ngpehbcmfpwkqt" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat, substitute, make_wikilink;	-- functions in Module:Citation/CS1/Utilities

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--============================&lt;&lt; H E L P E R   F U N C T I O N S &gt;&gt;============================================

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	local ext_link;
	local this_wiki_code = cfg.this_wiki_code;									-- wikipedia subdomain; 'en' for en.wikipedia.org
	local wd_article;															-- article title from wikidata
	
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end

	ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or &quot;&quot;, mw.text.nowiki(options.id));
	if is_set(options.access) then
		ext_link = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[options.access].class, cfg.presentation[options.access].title, ext_link});	-- add the free-to-read / paywall lock
	end

--	this_wiki_code = mw.language.getContentLanguage():getCode();				-- get this wikipedia's language code (subdomain)
	
	if string.match (mw.site.server, 'wikidata') then
		this_wiki_code = mw.getCurrentFrame():preprocess('{{int:lang}}');		-- on wikidata so use interface language setting instead
	end
	
	if is_set (options.q) and mw.wikibase then									-- wikibase test here avoids script errors in third party wikis that aren't using mw.wikibase extension
		wd_article = mw.wikibase.getEntity (options.q):getSitelink (this_wiki_code .. 'wiki');	-- fetch article title from wd
		if wd_article then
			wd_article = table.concat ({':', this_wiki_code, ':', wd_article});	-- make interwiki link if taken from wd; leading colon required
		end
	end

	return table.concat	({
		make_wikilink (wd_article or options.link, options.label),				-- wikidata link or locally specified
		options.separator or '&amp;nbsp;',
		ext_link
		});
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	local id = mw.ustring.gsub (options.id, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9

	return table.concat (
		{
		make_wikilink (options.link, options.label),
		options.separator or '&amp;nbsp;',
		make_wikilink (
			table.concat (
				{
				options.prefix,
				id,																-- translated to western digits
				options.suffix or ''
				}),
			substitute (cfg.presentation['bdi'], {'', mw.text.nowiki (options.id)})	-- bdi tags to prevent Latn script identifiers from being reversed at rtl language wikis
			);																	-- nowiki because MediaWiki still has magic links for ISBN and the like; TODO: is it really required?
		});
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9' → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N _ 1 3 &gt;-----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--============================&lt;&lt; I D E N T I F I E R   F U N C T I O N S &gt;&gt;====================================

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation; not the same as |class= parameter which is not supported in this form
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = false;														-- assume no error message
	local text;																	-- output text
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
				err_cat = true;													-- flag for error message
		end

	else
		err_cat = true;															-- not a recognized format; flag for error message
	end

	err_cat = err_cat and table.concat ({' ', set_error ('bad_arxiv')}) or '';	-- set error message if flag is true
	
	text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;

	if is_set (class) then
		if id:match ('^%d+') then
			text = table.concat ({text, ' [[//arxiv.org/archive/', class, ' ', class, ']]'});	-- external link within square brackets, not wikilink
		else
			text = table.concat ({text, ' ', set_error ('class_ignored')});		
		end
	end

	return text;	
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode id.

Format for bibcodes is specified here: http://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		9–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (id, access)
	local handler = cfg.id_handlers['BIBCODE'];
	local err_type;
	local year;

	local text = external_link_id({link=handler.link, label=handler.label, q = handler.q,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
		access=access});
	
	if 19 ~= id:len() then
		err_type = 'length';
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%w&amp;%.][%w&amp;%.][%w&amp;%.][%w.]+[%a%.]$&quot;)	-- 
		if not year then														-- if nil then no pattern match
			err_type = 'value';													-- so value error
		else
			local next_year = tonumber(os.date ('%Y'))+1;						-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = 'year';												-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = 'journal';											-- journal abbreviation must not have '&amp;.' (if it does its missing a letter)
			end
		end
	end

	if is_set (err_type) then													-- if there was an error detected
		text = text .. ' ' .. set_error( 'bad_bibcode', {err_type});
	end
	return text;
end


--[[--------------------------&lt; B I O R X I V &gt;-----------------------------------------------------------------

Format bioRxiv id and do simple error checking.  BiorXiv ids are exactly 6 digits.
The bioRxiv id is the number following the last slash in the bioRxiv-issued DOI:
https://doi.org/10.1101/078733 -&gt; 078733

]]

local function biorxiv(id)
	local handler = cfg.id_handlers['BIORXIV'];
	local err_cat = '';															-- presume that bioRxiv id is valid
	
	if nil == id:match(&quot;^%d%d%d%d%d%d$&quot;) then									-- if bioRxiv id has anything but six digits
		err_cat = ' ' .. set_error( 'bad_biorxiv');	-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator,
			encode=handler.encode, access=handler.access}) .. err_cat;
end


--[[--------------------------&lt; C I T E S E E R X &gt;------------------------------------------------------------

CiteSeerX use their own notion of &quot;doi&quot; (not to be confused with the identifiers resolved via doi.org).

The description of the structure of this identifier can be found at Help_talk:Citation_Style_1/Archive_26#CiteSeerX_id_structure
]]

local function citeseerx (id)
	local handler = cfg.id_handlers['CITESEERX'];
	local matched;
	
	local text = external_link_id({link=handler.link, label=handler.label, q = handler.q,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
		access=handler.access});
	
	matched = id:match (&quot;^10%.1%.1%.[1-9]%d?%d?%d?%.[1-9]%d?%d?%d?$&quot;);
	if not matched then
		text = text .. ' ' .. set_error( 'bad_citeseerx' );
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive, access)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';					-- try to get the year portion from the inactive date
		local inactive_month, good;

		if is_set (inactive_year) then
			if 4 &lt; inactive:len() then											-- inactive date has more than just a year (could be anything)
				local lang_obj = mw.getContentLanguage();						-- get a language object for this wiki
				good, inactive_month = pcall (lang_obj.formatDate, lang_obj, 'F', inactive);	-- try to get the month name from the inactive date
				if not good then
					inactive_month = nil;										-- something went wrong so make sure this is unset
				end
			end
		else
			inactive_year = nil;												-- |doi-broken= has something but it isn't a date
		end
		
		if is_set(inactive_year) and is_set (inactive_month) then
			table.insert( z.error_categories, 'Pages with DOIs inactive as of ' .. inactive_year .. ' ' .. inactive_month);	-- use inactive month in category name
		elseif is_set(inactive_year) then
			table.insert( z.error_categories, 'Pages with DOIs inactive as of ' .. inactive_year);
		else
			table.insert( z.error_categories, 'Pages with inactive DOIs');		-- when inactive doesn't contain a recognizable date
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. ' ' .. inactive .. ')';
	end

	text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access}) .. (inactive or '')

	local registrant = id:match ('^10%.([^/]+)/[^%s–]-[^%.,]$');				-- registrant set when doi has the proper basic form
	
	registrant_err_patterns = {													-- these patterns are for code ranges that are not supported 
		'^[^1-3]%d%d%d%d%.%d%d*$',												-- 5 digits with subcode (0xxxx, 40000+); accecpts: 10000–39999
		'^[^1-3]%d%d%d%d$',														-- 5 digits without subcode (0xxxx, 40000+); accecpts: 10000–39999
		'^[^1-9]%d%d%d%.%d%d*$',												-- 4 digits with subcode (0xxx); accecpts: 1000–9999
		'^[^1-9]%d%d%d$',														-- 4 digits without subcode (0xxx); accecpts: 1000–9999
		'^%d%d%d%d%d%d+',														-- 6 or more digits
		'^%d%d?%d?$',															-- less than 4 digits without subcode (with subcode is legitimate)
		'^5555$',																-- test registrant will never resolve
		}
	
	if registrant then															-- when doi has proper form
		for i, pattern in ipairs (registrant_err_patterns) do					-- spin through error patterns
			if registrant:match (pattern) then									-- to validate registrant codes
				cat = ' ' .. set_error ('bad_doi');								-- when found, mark this doi as bad
				break;															-- and done
			end
		end
	else
		cat = ' ' .. set_error ('bad_doi');										-- invalid directory or malformed
	end

	return text .. cat 
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

]]

local function hdl(id, access)
	local handler = cfg.id_handlers['HDL'];
	
	local text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- hdl must contain a fwd slash, must not contain spaces, endashes, and must not end with period or comma
		text = text .. ' ' .. set_error( 'bad_hdl' );
	end
	return text;
end


--[[--------------------------&lt; I S B N &gt;----------------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then
		return false, 'invalid character';										-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );						-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false, 'length';													-- fail if incorrect length
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then								-- fail if isbn_str has 'X' anywhere but last position
			return false, 'invalid form';									
		end
		return is_valid_isxn(isbn_str, 10), 'checksum';
	else
		if isbn_str:match( &quot;^%d+$&quot; ) == nil then
			return false, 'invalid character';									-- fail if isbn13 is not all digits
		end
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then
			return false, 'invalid prefix';										-- fail when isbn13 does not begin with 978 or 979
		end
		if isbn_str:match ('^9790') then
			return false, 'invalid group id';									-- group identifier '0' is reserved to ismn
		end
		return is_valid_isxn_13 (isbn_str), 'checksum';
	end
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

This function is positioned here because it calls isbn()

]]

local function asin(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat = ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then							-- if 10-digit numeric (or 9 digits with terminal X)
			if isbn( id ) then													-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat = ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat = ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, q = handler.q, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;
	local id_copy;

	id_copy = id;																-- save a copy because this testing is destructive
	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text = table.concat (
		{
		make_wikilink (handler.link, handler.label),
		handler.separator,
		id_copy
		});		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the ismn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]	-- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id, e)
	local issn_copy = id;														-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler;
	local text;
	local valid_issn = true;
	
	if e then
		 handler = cfg.id_handlers['EISSN'];
	else
		 handler = cfg.id_handlers['ISSN'];
	end

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then						-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;														-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);										-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );				-- if valid, display correctly formatted version
	else
		id = issn_copy;															-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn', e and 'e' or '' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; J F M &gt;-----------------------------------------------------------------------

A numerical identifier in the form nn.nnnn.nn

]]

local function jfm (id)
	local handler = cfg.id_handlers['JFM'];
	local id_num;
	local err_cat = '';
	
	id_num = id:match ('^[Jj][Ff][Mm](.*)$');									-- identifier with jfm prefix; extract identifier

	if is_set (id_num) then
		add_maint_cat ('jfm_format');
	else																		-- plain number without mr prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num and id_num:match('^%d%d%.%d%d%d%d%.%d%d$') then
		id = id_num;															-- jfm matches pattern
	else
		err_cat = ' ' .. set_error( 'bad_jfm' );								-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat = '';															-- presume that LCCN is valid
	local id = lccn;															-- local copy of the lccn

	id = normalize_lccn (id);													-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();														-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- set an error message
		end
	elseif 9 == len then														-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then							-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- set an error message
		end
	elseif 10 == len then														-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then					-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );						-- no match, set an error message
			end
		end
	elseif 11 == len then														-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- no match, set an error message
		end
	elseif 12 == len then														-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then						-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );								-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );								-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; M R &gt;--------------------------------------------------------------------------

A seven digit number; if not seven digits, zero-fill leading digits to make seven digits.

]]

local function mr (id)
	local handler = cfg.id_handlers['MR'];
	local id_num;
	local id_len;
	local err_cat = '';
	
	id_num = id:match ('^[Mm][Rr](%d+)$');										-- identifier with mr prefix

	if is_set (id_num) then
		add_maint_cat ('mr_format');
	else																		-- plain number without mr prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	id_len = id_num and id_num:len() or 0;
	if (7 &gt;= id_len) and (0 ~= id_len) then
		id = string.rep ('0', 7-id_len ) .. id_num;								-- zero-fill leading digits
	else
		err_cat = ' ' .. set_error( 'bad_mr' );									-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an oclc id.  https://www.oclc.org/batchload/controlnumber.en.html {{dead link}}
archived at: https://web.archive.org/web/20161228233804/https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (id)
	local handler = cfg.id_handlers['OCLC'];
	local number;
	local err_msg = '';															-- empty string for concatenation
	
	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- contrain to 1 to 9 digits; change this when oclc issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if 10 &lt; number:len() then
			number = nil;														-- contrain to 1 to 10 digits; change this when oclc issues 11-digit numbers
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		err_msg = ' ' .. set_error( 'bad_oclc' )								-- add an error message if the id is malformed
	end
	
	local text = external_link_id({link=handler.link, label=handler.label, q = handler.q,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode}) .. err_msg;

	return text;
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id, access)
	local code;
	local handler = cfg.id_handlers['OL'];
	local ident;
	
	ident, code = id:gsub('^OL', ''):match(&quot;^(%d+([AMW]))$&quot;);					-- optional OL prefix followed immediately by digits followed by 'A', 'M', or 'W'; remove OL prefix

	if not is_set (ident) then													-- if malformed return an error
		return external_link_id({link=handler.link, label=handler.label, q = handler.q,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access}) .. ' ' .. set_error( 'bad_ol' );
	end
	
	id = ident;																	-- use ident without the optional OL prefix (it has been removed)
	
	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label, q = handler.q,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end
	
	if ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label, q = handler.q,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end

	if ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label, q = handler.q,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 7000000;													-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat = '';															-- presume that PMC is valid
	local id_num;
	local text;
	
	id_num = id:match ('^[Pp][Mm][Cc](%d+)$');									-- identifier with pmc prefix

	if is_set (id_num) then
		add_maint_cat ('pmc_format');
	else																		-- plain number without pmc prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then								-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );							-- set an error message
		else
			id = tostring (id_num);												-- make sure id is a string
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_pmc' );								-- set an error message
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text = table.concat (													-- still embargoed so no external link
			{
			make_wikilink (handler.link, handler.label),
			handler.separator,
			id,
			err_cat
			});
	else
		text = external_link_id({link = handler.link, label = handler.label, q = handler.q,	-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 33000000;												-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat = '';															-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then													-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );								-- set an error message
	else																		-- PMID is only digits
		local id_num = tonumber(id);											-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then								-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );							-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; S S R N &gt;----------------------------------------------------------------------

Format an ssrn, do simple error checking

SSRNs are sequential numbers beginning at 100? and counting up.  This code checks the ssrn to see that it is
only digits and is greater than 99 and less than test_limit; the value in local variable test_limit will need
to be updated periodically as more SSRNs are issued.

]]

local function ssrn (id)
	local test_limit = 3500000;													-- update this value as SSRNs approach
	local handler = cfg.id_handlers['SSRN'];
	local err_cat = '';															-- presume that SSRN is valid
	local id_num;
	local text;
	
	id_num = id:match ('^%d+$');												-- id must be all digits

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 100 &gt; id_num or test_limit &lt; id_num then								-- if SSRN is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_ssrn' );							-- set an error message
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_ssrn' );								-- set an error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;

	return text;
end


--[[--------------------------&lt; U S E N E T _ I D &gt;------------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function usenet_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_usenet_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; Z B L &gt;-----------------------------------------------------------------------

A numerical identifier in the form nnnn.nnnnn - leading zeros in the first quartet optional

format described here: http://emis.mi.sanu.ac.rs/ZMATH/zmath/en/help/search/

temporary format is apparently eight digits.  Anything else is an error

]]

local function zbl (id)
	local handler = cfg.id_handlers['ZBL'];
	local err_cat = '';
	
	if id:match('^%d%d%d%d%d%d%d%d$') then										-- is this identifier using temporary format?
		add_maint_cat ('zbl');													-- yes, add maint cat
	elseif not id:match('^%d?%d?%d?%d%.%d%d%d%d%d$') then						-- not temporary, is it normal format?
		err_cat = ' ' .. set_error( 'bad_zbl' );								-- no, set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--============================&lt;&lt; I N T E R F A C E   F U N C T I O N S &gt;&gt;==========================================

--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v, ['access'] = options.IdAccessLevels[k] }, fallback(k) );

		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, asin( v, options.ASINTLD ) } ); 
		elseif k == 'BIBCODE' then
			table.insert( new_list, {handler.label, bibcode( v, handler.access ) } );
		elseif k == 'BIORXIV' then
			table.insert( new_list, {handler.label, biorxiv( v ) } );
		elseif k == 'CITESEERX' then
			table.insert( new_list, {handler.label, citeseerx( v ) } );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken, handler.access ) } );
		elseif k == 'EISSN' then
			table.insert( new_list, {handler.label, issn( v, true ) } );		-- true distinguishes eissn from issn
		elseif k == 'HDL' then
			table.insert( new_list, {handler.label, hdl( v, handler.access ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			local check;
			local err_type = '';
			check, err_type = isbn( v );
			if not check then
				if is_set(options.IgnoreISBN) then								-- ISBN is invalid; if |ignore-isbn-error= set
					add_maint_cat ('ignore_isbn_err');							-- ad a maint category
				else
					ISBN = ISBN .. set_error( 'bad_isbn', {err_type}, false, &quot; &quot;, &quot;&quot; );	-- else display an error message
				end
			elseif is_set(options.IgnoreISBN) then								-- ISBN is OK; if |ignore-isbn-error= set
				add_maint_cat ('ignore_isbn_err');								-- because |ignore-isbn-error= unnecessary
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'JFM' then
			table.insert( new_list, {handler.label, jfm( v ) } );
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'MR' then
			table.insert( new_list, {handler.label, mr( v ) } );
		elseif k == 'OCLC' then
			table.insert( new_list, {handler.label, oclc( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v, handler.access ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'SSRN' then
			table.insert( new_list, {handler.label, ssrn( v ) } );
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, usenet_id( v ) } );
		elseif k == 'ZBL' then
			table.insert( new_list, {handler.label, zbl( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1]:lower() &lt; b[1]:lower();
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; E X T R A C T _ I D _ A C C E S S _ L E V E L S &gt;--------------------------------------

Fetches custom id access levels from arguments using configuration settings.
Parameters which have a predefined access level (e.g. arxiv) do not use this
function as they are directly rendered as free without using an additional parameter.

access-level values must match the case used in cfg.keywords_lists['id-access'] (lowercase unless there is some special reason for something else)

]]

local function extract_id_access_levels( args, id_list )
	local id_accesses_list = {};
	for k, v in pairs( cfg.id_handlers ) do
		local access_param = v.custom_access;									-- name of identifier's access-level parameter
		if is_set(access_param) then
			local access_level = args[access_param];							-- get the assigned value if there is one
			if is_set (access_level) then
				if not in_array (access_level, cfg.keywords_lists['id-access']) then	-- exact match required
					table.insert( z.message_tail, { set_error( 'invalid_param_val', {access_param, access_level}, true ) } );	
					access_level = nil;											-- invalid so unset
				end
				if not is_set(id_list[k]) then									-- identifer access-level must have a matching identifier
					table.insert( z.message_tail, { set_error( 'param_access_requires_param', {k:lower()}, true ) } );	-- param name is uppercase in cfg.id_handlers (k); lowercase for error message
				end
				id_accesses_list[k] = cfg.keywords_xlate[access_level];			-- get translated keyword
			end
		end
	end
	return id_accesses_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	set_error = utilities_page_ptr.set_error;
	select_one = utilities_page_ptr.select_one;
	add_maint_cat = utilities_page_ptr.add_maint_cat;
	substitute = utilities_page_ptr.substitute;
	make_wikilink = utilities_page_ptr.make_wikilink;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	extract_id_access_levels = extract_id_access_levels,
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>pghk7ye5bidm921n1ngpehbcmfpwkqt</sha1>
    </revision>
    <revision>
      <id>4912</id>
      <parentid>4911</parentid>
      <timestamp>2020-03-06T19:29:30Z</timestamp>
      <contributor>
        <username>The Anome</username>
        <id>823</id>
      </contributor>
      <comment>changed PMC test limit to 8000000, since PMCs greater than 7000000 have now been issued, see https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7003341/</comment>
      <origin>4912</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="50962" sha1="nh1g2ocgz5yq8yqc6mx3746dymufi2o" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat, substitute, make_wikilink;	-- functions in Module:Citation/CS1/Utilities

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--============================&lt;&lt; H E L P E R   F U N C T I O N S &gt;&gt;============================================

--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	local ext_link;
	local this_wiki_code = cfg.this_wiki_code;									-- wikipedia subdomain; 'en' for en.wikipedia.org
	local wd_article;															-- article title from wikidata
	
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end

	ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or &quot;&quot;, mw.text.nowiki(options.id));
	if is_set(options.access) then
		ext_link = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[options.access].class, cfg.presentation[options.access].title, ext_link});	-- add the free-to-read / paywall lock
	end

--	this_wiki_code = mw.language.getContentLanguage():getCode();				-- get this wikipedia's language code (subdomain)
	
	if string.match (mw.site.server, 'wikidata') then
		this_wiki_code = mw.getCurrentFrame():preprocess('{{int:lang}}');		-- on wikidata so use interface language setting instead
	end
	
	if is_set (options.q) and mw.wikibase then									-- wikibase test here avoids script errors in third party wikis that aren't using mw.wikibase extension
		wd_article = mw.wikibase.getEntity (options.q):getSitelink (this_wiki_code .. 'wiki');	-- fetch article title from wd
		if wd_article then
			wd_article = table.concat ({':', this_wiki_code, ':', wd_article});	-- make interwiki link if taken from wd; leading colon required
		end
	end

	return table.concat	({
		make_wikilink (wd_article or options.link, options.label),				-- wikidata link or locally specified
		options.separator or '&amp;nbsp;',
		ext_link
		});
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	local id = mw.ustring.gsub (options.id, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9

	return table.concat (
		{
		make_wikilink (options.link, options.label),
		options.separator or '&amp;nbsp;',
		make_wikilink (
			table.concat (
				{
				options.prefix,
				id,																-- translated to western digits
				options.suffix or ''
				}),
			substitute (cfg.presentation['bdi'], {'', mw.text.nowiki (options.id)})	-- bdi tags to prevent Latn script identifiers from being reversed at rtl language wikis
			);																	-- nowiki because MediaWiki still has magic links for ISBN and the like; TODO: is it really required?
		});
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };	-- make a table of byte values '0' → 0x30 .. '9' → 0x39, 'X' → 0x58
	len = len+1;							-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do		-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then		-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );	-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;					-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N _ 1 3 &gt;-----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--============================&lt;&lt; I D E N T I F I E R   F U N C T I O N S &gt;&gt;====================================

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation; not the same as |class= parameter which is not supported in this form
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = false;														-- assume no error message
	local text;																	-- output text
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
				err_cat = true;													-- flag for error message
		end

	else
		err_cat = true;															-- not a recognized format; flag for error message
	end

	err_cat = err_cat and table.concat ({' ', set_error ('bad_arxiv')}) or '';	-- set error message if flag is true
	
	text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;

	if is_set (class) then
		if id:match ('^%d+') then
			text = table.concat ({text, ' [[//arxiv.org/archive/', class, ' ', class, ']]'});	-- external link within square brackets, not wikilink
		else
			text = table.concat ({text, ' ', set_error ('class_ignored')});		
		end
	end

	return text;	
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode id.

Format for bibcodes is specified here: http://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		9–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (id, access)
	local handler = cfg.id_handlers['BIBCODE'];
	local err_type;
	local year;

	local text = external_link_id({link=handler.link, label=handler.label, q = handler.q,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
		access=access});
	
	if 19 ~= id:len() then
		err_type = 'length';
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%w&amp;%.][%w&amp;%.][%w&amp;%.][%w.]+[%a%.]$&quot;)	-- 
		if not year then														-- if nil then no pattern match
			err_type = 'value';													-- so value error
		else
			local next_year = tonumber(os.date ('%Y'))+1;						-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = 'year';												-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = 'journal';											-- journal abbreviation must not have '&amp;.' (if it does its missing a letter)
			end
		end
	end

	if is_set (err_type) then													-- if there was an error detected
		text = text .. ' ' .. set_error( 'bad_bibcode', {err_type});
	end
	return text;
end


--[[--------------------------&lt; B I O R X I V &gt;-----------------------------------------------------------------

Format bioRxiv id and do simple error checking.  BiorXiv ids are exactly 6 digits.
The bioRxiv id is the number following the last slash in the bioRxiv-issued DOI:
https://doi.org/10.1101/078733 -&gt; 078733

]]

local function biorxiv(id)
	local handler = cfg.id_handlers['BIORXIV'];
	local err_cat = '';															-- presume that bioRxiv id is valid
	
	if nil == id:match(&quot;^%d%d%d%d%d%d$&quot;) then									-- if bioRxiv id has anything but six digits
		err_cat = ' ' .. set_error( 'bad_biorxiv');	-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator,
			encode=handler.encode, access=handler.access}) .. err_cat;
end


--[[--------------------------&lt; C I T E S E E R X &gt;------------------------------------------------------------

CiteSeerX use their own notion of &quot;doi&quot; (not to be confused with the identifiers resolved via doi.org).

The description of the structure of this identifier can be found at Help_talk:Citation_Style_1/Archive_26#CiteSeerX_id_structure
]]

local function citeseerx (id)
	local handler = cfg.id_handlers['CITESEERX'];
	local matched;
	
	local text = external_link_id({link=handler.link, label=handler.label, q = handler.q,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
		access=handler.access});
	
	matched = id:match (&quot;^10%.1%.1%.[1-9]%d?%d?%d?%.[1-9]%d?%d?%d?$&quot;);
	if not matched then
		text = text .. ' ' .. set_error( 'bad_citeseerx' );
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive, access)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';					-- try to get the year portion from the inactive date
		local inactive_month, good;

		if is_set (inactive_year) then
			if 4 &lt; inactive:len() then											-- inactive date has more than just a year (could be anything)
				local lang_obj = mw.getContentLanguage();						-- get a language object for this wiki
				good, inactive_month = pcall (lang_obj.formatDate, lang_obj, 'F', inactive);	-- try to get the month name from the inactive date
				if not good then
					inactive_month = nil;										-- something went wrong so make sure this is unset
				end
			end
		else
			inactive_year = nil;												-- |doi-broken= has something but it isn't a date
		end
		
		if is_set(inactive_year) and is_set (inactive_month) then
			table.insert( z.error_categories, 'Pages with DOIs inactive as of ' .. inactive_year .. ' ' .. inactive_month);	-- use inactive month in category name
		elseif is_set(inactive_year) then
			table.insert( z.error_categories, 'Pages with DOIs inactive as of ' .. inactive_year);
		else
			table.insert( z.error_categories, 'Pages with inactive DOIs');		-- when inactive doesn't contain a recognizable date
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. ' ' .. inactive .. ')';
	end

	text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access}) .. (inactive or '')

	local registrant = id:match ('^10%.([^/]+)/[^%s–]-[^%.,]$');				-- registrant set when doi has the proper basic form
	
	registrant_err_patterns = {													-- these patterns are for code ranges that are not supported 
		'^[^1-3]%d%d%d%d%.%d%d*$',												-- 5 digits with subcode (0xxxx, 40000+); accecpts: 10000–39999
		'^[^1-3]%d%d%d%d$',														-- 5 digits without subcode (0xxxx, 40000+); accecpts: 10000–39999
		'^[^1-9]%d%d%d%.%d%d*$',												-- 4 digits with subcode (0xxx); accecpts: 1000–9999
		'^[^1-9]%d%d%d$',														-- 4 digits without subcode (0xxx); accecpts: 1000–9999
		'^%d%d%d%d%d%d+',														-- 6 or more digits
		'^%d%d?%d?$',															-- less than 4 digits without subcode (with subcode is legitimate)
		'^5555$',																-- test registrant will never resolve
		}
	
	if registrant then															-- when doi has proper form
		for i, pattern in ipairs (registrant_err_patterns) do					-- spin through error patterns
			if registrant:match (pattern) then									-- to validate registrant codes
				cat = ' ' .. set_error ('bad_doi');								-- when found, mark this doi as bad
				break;															-- and done
			end
		end
	else
		cat = ' ' .. set_error ('bad_doi');										-- invalid directory or malformed
	end

	return text .. cat 
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

]]

local function hdl(id, access)
	local handler = cfg.id_handlers['HDL'];
	
	local text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- hdl must contain a fwd slash, must not contain spaces, endashes, and must not end with period or comma
		text = text .. ' ' .. set_error( 'bad_hdl' );
	end
	return text;
end


--[[--------------------------&lt; I S B N &gt;----------------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then
		return false, 'invalid character';										-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );						-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false, 'length';													-- fail if incorrect length
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then								-- fail if isbn_str has 'X' anywhere but last position
			return false, 'invalid form';									
		end
		return is_valid_isxn(isbn_str, 10), 'checksum';
	else
		if isbn_str:match( &quot;^%d+$&quot; ) == nil then
			return false, 'invalid character';									-- fail if isbn13 is not all digits
		end
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then
			return false, 'invalid prefix';										-- fail when isbn13 does not begin with 978 or 979
		end
		if isbn_str:match ('^9790') then
			return false, 'invalid group id';									-- group identifier '0' is reserved to ismn
		end
		return is_valid_isxn_13 (isbn_str), 'checksum';
	end
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

This function is positioned here because it calls isbn()

]]

local function asin(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat = ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then							-- if 10-digit numeric (or 9 digits with terminal X)
			if isbn( id ) then													-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat = ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat = ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id({link=handler.link,
		label=handler.label, q = handler.q, prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;
	local id_copy;

	id_copy = id;																-- save a copy because this testing is destructive
	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id({link = handler.link, label = handler.label,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	text = table.concat (
		{
		make_wikilink (handler.link, handler.label),
		handler.separator,
		id_copy
		});		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the ismn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]	-- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id, e)
	local issn_copy = id;														-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler;
	local text;
	local valid_issn = true;
	
	if e then
		 handler = cfg.id_handlers['EISSN'];
	else
		 handler = cfg.id_handlers['ISSN'];
	end

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then						-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;														-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);										-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );				-- if valid, display correctly formatted version
	else
		id = issn_copy;															-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn', e and 'e' or '' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; J F M &gt;-----------------------------------------------------------------------

A numerical identifier in the form nn.nnnn.nn

]]

local function jfm (id)
	local handler = cfg.id_handlers['JFM'];
	local id_num;
	local err_cat = '';
	
	id_num = id:match ('^[Jj][Ff][Mm](.*)$');									-- identifier with jfm prefix; extract identifier

	if is_set (id_num) then
		add_maint_cat ('jfm_format');
	else																		-- plain number without mr prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num and id_num:match('^%d%d%.%d%d%d%d%.%d%d$') then
		id = id_num;															-- jfm matches pattern
	else
		err_cat = ' ' .. set_error( 'bad_jfm' );								-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat = '';															-- presume that LCCN is valid
	local id = lccn;															-- local copy of the lccn

	id = normalize_lccn (id);													-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();														-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- set an error message
		end
	elseif 9 == len then														-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then							-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- set an error message
		end
	elseif 10 == len then														-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then					-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );						-- no match, set an error message
			end
		end
	elseif 11 == len then														-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- no match, set an error message
		end
	elseif 12 == len then														-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then						-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );								-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );								-- lccn contains a space, set an error message
	end

	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; M R &gt;--------------------------------------------------------------------------

A seven digit number; if not seven digits, zero-fill leading digits to make seven digits.

]]

local function mr (id)
	local handler = cfg.id_handlers['MR'];
	local id_num;
	local id_len;
	local err_cat = '';
	
	id_num = id:match ('^[Mm][Rr](%d+)$');										-- identifier with mr prefix

	if is_set (id_num) then
		add_maint_cat ('mr_format');
	else																		-- plain number without mr prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	id_len = id_num and id_num:len() or 0;
	if (7 &gt;= id_len) and (0 ~= id_len) then
		id = string.rep ('0', 7-id_len ) .. id_num;								-- zero-fill leading digits
	else
		err_cat = ' ' .. set_error( 'bad_mr' );									-- set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an oclc id.  https://www.oclc.org/batchload/controlnumber.en.html {{dead link}}
archived at: https://web.archive.org/web/20161228233804/https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (id)
	local handler = cfg.id_handlers['OCLC'];
	local number;
	local err_msg = '';															-- empty string for concatenation
	
	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- contrain to 1 to 9 digits; change this when oclc issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if 10 &lt; number:len() then
			number = nil;														-- contrain to 1 to 10 digits; change this when oclc issues 11-digit numbers
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		err_msg = ' ' .. set_error( 'bad_oclc' )								-- add an error message if the id is malformed
	end
	
	local text = external_link_id({link=handler.link, label=handler.label, q = handler.q,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode}) .. err_msg;

	return text;
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id, access)
	local code;
	local handler = cfg.id_handlers['OL'];
	local ident;
	
	ident, code = id:gsub('^OL', ''):match(&quot;^(%d+([AMW]))$&quot;);					-- optional OL prefix followed immediately by digits followed by 'A', 'M', or 'W'; remove OL prefix

	if not is_set (ident) then													-- if malformed return an error
		return external_link_id({link=handler.link, label=handler.label, q = handler.q,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access}) .. ' ' .. set_error( 'bad_ol' );
	end
	
	id = ident;																	-- use ident without the optional OL prefix (it has been removed)
	
	if ( code == &quot;A&quot; ) then
		return external_link_id({link=handler.link, label=handler.label, q = handler.q,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end
	
	if ( code == &quot;M&quot; ) then
		return external_link_id({link=handler.link, label=handler.label, q = handler.q,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end

	if ( code == &quot;W&quot; ) then
		return external_link_id({link=handler.link, label=handler.label, q = handler.q,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = 8000000;													-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat = '';															-- presume that PMC is valid
	local id_num;
	local text;
	
	id_num = id:match ('^[Pp][Mm][Cc](%d+)$');									-- identifier with pmc prefix

	if is_set (id_num) then
		add_maint_cat ('pmc_format');
	else																		-- plain number without pmc prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then								-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );							-- set an error message
		else
			id = tostring (id_num);												-- make sure id is a string
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_pmc' );								-- set an error message
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text = table.concat (													-- still embargoed so no external link
			{
			make_wikilink (handler.link, handler.label),
			handler.separator,
			id,
			err_cat
			});
	else
		text = external_link_id({link = handler.link, label = handler.label, q = handler.q,	-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = 33000000;												-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat = '';															-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then													-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );								-- set an error message
	else																		-- PMID is only digits
		local id_num = tonumber(id);											-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then								-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );							-- set an error message
		end
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; S S R N &gt;----------------------------------------------------------------------

Format an ssrn, do simple error checking

SSRNs are sequential numbers beginning at 100? and counting up.  This code checks the ssrn to see that it is
only digits and is greater than 99 and less than test_limit; the value in local variable test_limit will need
to be updated periodically as more SSRNs are issued.

]]

local function ssrn (id)
	local test_limit = 3500000;													-- update this value as SSRNs approach
	local handler = cfg.id_handlers['SSRN'];
	local err_cat = '';															-- presume that SSRN is valid
	local id_num;
	local text;
	
	id_num = id:match ('^%d+$');												-- id must be all digits

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 100 &gt; id_num or test_limit &lt; id_num then								-- if SSRN is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_ssrn' );							-- set an error message
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_ssrn' );								-- set an error message
	end
	
	text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;

	return text;
end


--[[--------------------------&lt; U S E N E T _ I D &gt;------------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function usenet_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id({link = handler.link, label = handler.label, q = handler.q,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_usenet_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; Z B L &gt;-----------------------------------------------------------------------

A numerical identifier in the form nnnn.nnnnn - leading zeros in the first quartet optional

format described here: http://emis.mi.sanu.ac.rs/ZMATH/zmath/en/help/search/

temporary format is apparently eight digits.  Anything else is an error

]]

local function zbl (id)
	local handler = cfg.id_handlers['ZBL'];
	local err_cat = '';
	
	if id:match('^%d%d%d%d%d%d%d%d$') then										-- is this identifier using temporary format?
		add_maint_cat ('zbl');													-- yes, add maint cat
	elseif not id:match('^%d?%d?%d?%d%.%d%d%d%d%d$') then						-- not temporary, is it normal format?
		err_cat = ' ' .. set_error( 'bad_zbl' );								-- no, set an error message
	end
	
	return external_link_id({link = handler.link, label = handler.label, q = handler.q,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--============================&lt;&lt; I N T E R F A C E   F U N C T I O N S &gt;&gt;==========================================

--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v, ['access'] = options.IdAccessLevels[k] }, fallback(k) );

		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, asin( v, options.ASINTLD ) } ); 
		elseif k == 'BIBCODE' then
			table.insert( new_list, {handler.label, bibcode( v, handler.access ) } );
		elseif k == 'BIORXIV' then
			table.insert( new_list, {handler.label, biorxiv( v ) } );
		elseif k == 'CITESEERX' then
			table.insert( new_list, {handler.label, citeseerx( v ) } );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken, handler.access ) } );
		elseif k == 'EISSN' then
			table.insert( new_list, {handler.label, issn( v, true ) } );		-- true distinguishes eissn from issn
		elseif k == 'HDL' then
			table.insert( new_list, {handler.label, hdl( v, handler.access ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			local check;
			local err_type = '';
			check, err_type = isbn( v );
			if not check then
				if is_set(options.IgnoreISBN) then								-- ISBN is invalid; if |ignore-isbn-error= set
					add_maint_cat ('ignore_isbn_err');							-- ad a maint category
				else
					ISBN = ISBN .. set_error( 'bad_isbn', {err_type}, false, &quot; &quot;, &quot;&quot; );	-- else display an error message
				end
			elseif is_set(options.IgnoreISBN) then								-- ISBN is OK; if |ignore-isbn-error= set
				add_maint_cat ('ignore_isbn_err');								-- because |ignore-isbn-error= unnecessary
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'JFM' then
			table.insert( new_list, {handler.label, jfm( v ) } );
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'MR' then
			table.insert( new_list, {handler.label, mr( v ) } );
		elseif k == 'OCLC' then
			table.insert( new_list, {handler.label, oclc( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v, handler.access ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'SSRN' then
			table.insert( new_list, {handler.label, ssrn( v ) } );
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, usenet_id( v ) } );
		elseif k == 'ZBL' then
			table.insert( new_list, {handler.label, zbl( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1]:lower() &lt; b[1]:lower();
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; E X T R A C T _ I D _ A C C E S S _ L E V E L S &gt;--------------------------------------

Fetches custom id access levels from arguments using configuration settings.
Parameters which have a predefined access level (e.g. arxiv) do not use this
function as they are directly rendered as free without using an additional parameter.

access-level values must match the case used in cfg.keywords_lists['id-access'] (lowercase unless there is some special reason for something else)

]]

local function extract_id_access_levels( args, id_list )
	local id_accesses_list = {};
	for k, v in pairs( cfg.id_handlers ) do
		local access_param = v.custom_access;									-- name of identifier's access-level parameter
		if is_set(access_param) then
			local access_level = args[access_param];							-- get the assigned value if there is one
			if is_set (access_level) then
				if not in_array (access_level, cfg.keywords_lists['id-access']) then	-- exact match required
					table.insert( z.message_tail, { set_error( 'invalid_param_val', {access_param, access_level}, true ) } );	
					access_level = nil;											-- invalid so unset
				end
				if not is_set(id_list[k]) then									-- identifer access-level must have a matching identifier
					table.insert( z.message_tail, { set_error( 'param_access_requires_param', {k:lower()}, true ) } );	-- param name is uppercase in cfg.id_handlers (k); lowercase for error message
				end
				id_accesses_list[k] = cfg.keywords_xlate[access_level];			-- get translated keyword
			end
		end
	end
	return id_accesses_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	set_error = utilities_page_ptr.set_error;
	select_one = utilities_page_ptr.select_one;
	add_maint_cat = utilities_page_ptr.add_maint_cat;
	substitute = utilities_page_ptr.substitute;
	make_wikilink = utilities_page_ptr.make_wikilink;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	extract_id_access_levels = extract_id_access_levels,
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>nh1g2ocgz5yq8yqc6mx3746dymufi2o</sha1>
    </revision>
    <revision>
      <id>4913</id>
      <parentid>4912</parentid>
      <timestamp>2020-04-18T12:50:46Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4913</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="61076" sha1="a3loi856p6xhkm72xsgmazjcazbehbi" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat, substitute, make_wikilink;	-- functions in Module:Citation/CS1/Utilities

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--============================&lt;&lt; H E L P E R   F U N C T I O N S &gt;&gt;============================================

--[[--------------------------&lt; W I K I D A T A _ A R T I C L E _ N A M E _ G E T &gt;----------------------------

as an aid to internationalizing identifier-label wikilinks, gets identifier article names from wikidata.

returns :&lt;lang code&gt;:&lt;article title&gt; when &lt;q&gt; has an &lt;article title&gt; for &lt;lang code&gt;; nil else

for identifiers that do not have q, returns nil

for wikis that do not have mw.wikibase installed, returns nil

The call to mw.wikibase.getEntity() bumps the expensive parser function count

]]

local function wikidata_article_name_get (q)
	if not is_set (q) or (q and not mw.wikibase) then							-- when no q number or when a q number but mw.wikibase not installed on this wiki
		return nil;																-- abandon
	end

	local wd_article;
	local this_wiki_code = cfg.this_wiki_code;									-- wikipedia subdomain; 'en' for en.wikipedia.org

	wd_article = mw.wikibase.getEntity (q):getSitelink (this_wiki_code .. 'wiki');	-- fetch article title from wd; nil when no title available at this wiki; bumps expensive parser function count

	if wd_article then
		wd_article = table.concat ({':', this_wiki_code, ':', wd_article});		-- interwiki-style link without brackets if taken from wd; leading colon required
	end

	return wd_article;															-- article title from wd; nil else
end


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	local ext_link;
	local this_wiki_code = cfg.this_wiki_code;									-- wikipedia subdomain; 'en' for en.wikipedia.org
	local wd_article;															-- article title from wikidata
	
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end

	ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or &quot;&quot;, mw.text.nowiki(options.id));
	if is_set(options.access) then
		ext_link = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[options.access].class, cfg.presentation[options.access].title, ext_link});	-- add the free-to-read / paywall lock
	end

	if not (cfg.use_identifier_redirects and is_set (options.redirect)) then	-- redirect has priority so if enabled and available don't fetch from wikidata because expensive
		wd_article = wikidata_article_name_get (options.q);						-- if wikidata has an article title for this wiki, get it;
	end
	
	local label_link = (cfg.use_identifier_redirects and is_set (options.redirect) and options.redirect) or wd_article or options.link;

	return table.concat	({
		make_wikilink (label_link, options.label),								-- redirect, wikidata link, or locally specified link (in that order)
		options.separator or '&amp;nbsp;',
		ext_link
		});
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	local id = mw.ustring.gsub (options.id, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9

	if not (cfg.use_identifier_redirects and is_set (options.redirect)) then	-- redirect has priority so if enabled and available don't fetch from wikidata because expensive
		wd_article = wikidata_article_name_get (options.q);						-- if wikidata has an article title for this wiki, get it;
	end

	local label_link = (cfg.use_identifier_redirects and is_set (options.redirect) and options.redirect) or wd_article or options.link;

	return table.concat (
		{
		make_wikilink (label_link, options.label),								-- wiki link the identifier label
		options.separator or '&amp;nbsp;',											-- add the separator
		make_wikilink (
			table.concat (
				{
				options.prefix,
				id,																-- translated to western digits
				options.suffix or ''
				}),
			substitute (cfg.presentation['bdi'], {'', mw.text.nowiki (options.id)})	-- bdi tags to prevent Latn script identifiers from being reversed at rtl language wikis
			);																	-- nowiki because MediaWiki still has magic links for ISBN and the like; TODO: is it really required?
		});
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[=[-------------------------&lt; I S _ V A L I D _ B I O R X I V _ D A T E &gt;------------------------------------

returns true if:
	2019-12-11T00:00Z &lt;= biorxiv_date &lt; today + 2 days
	
The dated form of biorxiv identifier has a start date of 2019-12-11.  The unix timestamp for that date is {{#time:U|2019-12-11}} = 1576022400

biorxiv_date is the date provided in those |biorxiv= parameter values that are dated at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-Engish date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate().  To get around that
call this function with YYYY-MM-DD format dates.

]=]

local function is_valid_biorxiv_date (biorxiv_date)
	local good1, good2;
	local biorxiv_ts, tomorrow_ts;												-- to hold unix time stamps representing the dates
	local lang_object = mw.getContentLanguage();

	good1, biorxiv_ts = pcall (lang_object.formatDate, lang_object, 'U', biorxiv_date );		-- convert biorxiv_date value to unix timesatmp 
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which which tonumber() may not understand
		biorxiv_ts = tonumber (biorxiv_ts) or lang_object:parseFormattedNumber (biorxiv_ts);	-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to unix time stamp
	end

	return ((1576022400 &lt;= biorxiv_ts) and (biorxiv_ts &lt; tomorrow_ts))			-- 2012-12-11T00:00Z &lt;= biorxiv_date &lt; tomorrow's date
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39, 'X' → 0x58
	len = len+1;																-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do											-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then											-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );										-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;														-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N _ 1 3 &gt;-----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--============================&lt;&lt; I D E N T I F I E R   F U N C T I O N S &gt;&gt;====================================

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation; not the same as |class= parameter which is not supported in this form
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = false;														-- assume no error message
	local text;																	-- output text
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
				err_cat = true;													-- flag for error message
		end

	else
		err_cat = true;															-- not a recognized format; flag for error message
	end

	err_cat = err_cat and table.concat ({' ', set_error ('bad_arxiv')}) or '';	-- set error message if flag is true
	
	text = external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;

	if is_set (class) then
		if id:match ('^%d+') then
			text = table.concat ({text, ' [[//arxiv.org/archive/', class, ' ', class, ']]'});	-- external link within square brackets, not wikilink
		else
			text = table.concat ({text, ' ', set_error ('class_ignored')});		
		end
	end

	return text;	
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode id.

Format for bibcodes is specified here: http://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		9–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (id, access)
	local handler = cfg.id_handlers['BIBCODE'];
	local err_type;
	local year;

	local text = external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
		access=access});
	
	if 19 ~= id:len() then
		err_type = cfg.err_msg_supl.length;
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%w&amp;%.][%w&amp;%.][%w&amp;%.][%w.]+[%a%.]$&quot;)	-- 
		if not year then														-- if nil then no pattern match
			err_type = cfg.err_msg_supl.value;													-- so value error
		else
			local next_year = tonumber(os.date ('%Y'))+1;						-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = cfg.err_msg_supl.year;												-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = cfg.err_msg_supl.journal;											-- journal abbreviation must not have '&amp;.' (if it does its missing a letter)
			end
		end
	end

	if is_set (err_type) then													-- if there was an error detected
		text = text .. ' ' .. set_error( 'bad_bibcode', {err_type});
	end
	return text;
end


--[[--------------------------&lt; B I O R X I V &gt;-----------------------------------------------------------------

Format bioRxiv id and do simple error checking.  Before 2019-12-11, biorXiv ids were 10.1101/ followed by exactly
6 digits.  After 2019-12-11, biorXiv ids retained the six-digit identifier but prefixed that with a yyyy.mm.dd. 
date and suffixed with an optional version identifier.

The bioRxiv id is the string of characters:
	https://doi.org/10.1101/078733 -&gt; 10.1101/078733
or a date followed by a six-digit number followed by an optional version indicator 'v' and one or more digits:
	https://www.biorxiv.org/content/10.1101/2019.12.11.123456v2 -&gt; 10.1101/2019.12.11.123456v2
	
see https://www.biorxiv.org/about-biorxiv

]]

local function biorxiv(id)
	local handler = cfg.id_handlers['BIORXIV'];
	local err_cat =  ' ' .. set_error( 'bad_biorxiv');							-- assume that there will be an error
	
	local patterns = {
		'^10.1101/%d%d%d%d%d%d$',												-- simple 6-digit identifier (before 2019-12-11)
		'^10.1101/(20[1-9]%d)%.([01]%d)%.([0-3]%d)%.%d%d%d%d%d%dv%d+$',			-- y.m.d. date + 6-digit identifier + version (after 2019-12-11)
		'^10.1101/(20[1-9]%d)%.([01]%d)%.([0-3]%d)%.%d%d%d%d%d%d$',				-- y.m.d. date + 6-digit identifier (after 2019-12-11)
	}
	
	for _, pattern in ipairs (patterns) do										-- spin through the patterns looking for a match
		if id:match (pattern) then
			local y, m, d = id:match (pattern);									-- found a match, attempt to get year, month and date from the identifier

			if m then															-- m is nil when id is the six-digit form
				if not is_valid_biorxiv_date (y .. '-' .. m .. '-' .. d) then	-- validate the encoded date; TODO: don't ignore leapyear and actual month lengths ({{#time:}} is a poor date validator)
					break;														-- break out early so we don't unset the error message
				end
			end
			err_cat = '';														-- we found a match so unset the error message
			break;																-- and done
		end
	end																			-- err_cat remains set here when no match

	return external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
			prefix=handler.prefix,id=id,separator=handler.separator,
			encode=handler.encode, access=handler.access}) .. err_cat;
end


--[[--------------------------&lt; C I T E S E E R X &gt;------------------------------------------------------------

CiteSeerX use their own notion of &quot;doi&quot; (not to be confused with the identifiers resolved via doi.org).

The description of the structure of this identifier can be found at Help_talk:Citation_Style_1/Archive_26#CiteSeerX_id_structure
]]

local function citeseerx (id)
	local handler = cfg.id_handlers['CITESEERX'];
	local matched;
	
	local text = external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
		access=handler.access});
	
	matched = id:match (&quot;^10%.1%.1%.[1-9]%d?%d?%d?%.[1-9]%d?%d?%d?$&quot;);
	if not matched then
		text = text .. ' ' .. set_error( 'bad_citeseerx' );
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive, access)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';					-- try to get the year portion from the inactive date
		local inactive_month, good;

		if is_set (inactive_year) then
			if 4 &lt; inactive:len() then											-- inactive date has more than just a year (could be anything)
				local lang_obj = mw.getContentLanguage();						-- get a language object for this wiki
				good, inactive_month = pcall (lang_obj.formatDate, lang_obj, 'F', inactive);	-- try to get the month name from the inactive date
				if not good then
					inactive_month = nil;										-- something went wrong so make sure this is unset
				end
			end
		else
			inactive_year = nil;												-- |doi-broken= has something but it isn't a date
		end
		
		if is_set(inactive_year) and is_set (inactive_month) then
			table.insert( z.error_categories, 'Pages with DOIs inactive as of ' .. inactive_year .. ' ' .. inactive_month);	-- use inactive month in category name
		elseif is_set(inactive_year) then
			table.insert( z.error_categories, 'Pages with DOIs inactive as of ' .. inactive_year);
		else
			table.insert( z.error_categories, 'Pages with inactive DOIs');		-- when inactive doesn't contain a recognizable date
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. ' ' .. inactive .. ')';
	end

	text = external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access}) .. (inactive or '')

	local registrant = id:match ('^10%.([^/]+)/[^%s–]-[^%.,]$');				-- registrant set when doi has the proper basic form
	
	registrant_err_patterns = {													-- these patterns are for code ranges that are not supported 
		'^[^1-3]%d%d%d%d%.%d%d*$',												-- 5 digits with subcode (0xxxx, 40000+); accecpts: 10000–39999
		'^[^1-3]%d%d%d%d$',														-- 5 digits without subcode (0xxxx, 40000+); accecpts: 10000–39999
		'^[^1-9]%d%d%d%.%d%d*$',												-- 4 digits with subcode (0xxx); accecpts: 1000–9999
		'^[^1-9]%d%d%d$',														-- 4 digits without subcode (0xxx); accecpts: 1000–9999
		'^%d%d%d%d%d%d+',														-- 6 or more digits
		'^%d%d?%d?$',															-- less than 4 digits without subcode (with subcode is legitimate)
		'^5555$',																-- test registrant will never resolve
		'%s',																	-- any space character in registrant
		}
	
	if registrant then															-- when doi has proper form
		for i, pattern in ipairs (registrant_err_patterns) do					-- spin through error patterns
			if registrant:match (pattern) then									-- to validate registrant codes
				cat = ' ' .. set_error ('bad_doi');								-- when found, mark this doi as bad
				break;															-- and done
			end
		end
	else
		cat = ' ' .. set_error ('bad_doi');										-- invalid directory or malformed
	end

	return text .. cat 
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

Query string parameters are named here: http://www.handle.net/proxy_servlet.html.  query strings are not displayed
but since '?' is anallowed character in an hdl, '?' followed by one of the query parameters is the only way we
have to detect the query string so that it isn't url encoded with the rest of the identifier.

]]

local function hdl(id, access)
	local handler = cfg.id_handlers['HDL'];
	local query_params = {														-- list of known query parameters from http://www.handle.net/proxy_servlet.html
		'noredirect',
		'ignore_aliases',
		'auth',
		'cert',
		'index',
		'type',
		'urlappend',
		'locatt',
		'action',
		}
	
	local hdl, suffix, param = id:match ('(.-)(%?(%a+).+)$');					-- look for query string
	local found;

	if hdl then																	-- when there are query strings, this is the handle identifier portion
		for _, q in ipairs (query_params) do									-- spin through the list of query parameters
			if param:match ('^' .. q) then										-- if the query string begins with one of the parameters
				found = true;													-- announce a find
				break;															-- and stop looking
			end
		end
	end

	if found then
		id = hdl;																-- found so replace id with the handle portion; this will be url encoded, suffix will not
	else
		suffix = '';															-- make sure suffix is empty string for concatenation else
	end

	local text = external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
			prefix=handler.prefix, id=id, suffix=suffix, separator=handler.separator, encode=handler.encode, access=access})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- hdl must contain a fwd slash, must not contain spaces, endashes, and must not end with period or comma
		text = text .. ' ' .. set_error( 'bad_hdl' );
	end
	return text;
end


--[[--------------------------&lt; I S B N &gt;----------------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then
		return false, cfg.err_msg_supl.char;									-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );						-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false, cfg.err_msg_supl.length;									-- fail if incorrect length
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then								-- fail if isbn_str has 'X' anywhere but last position
			return false, cfg.err_msg_supl.form;									
		end
		return is_valid_isxn(isbn_str, 10), cfg.err_msg_supl.check;
	else
		if isbn_str:match( &quot;^%d+$&quot; ) == nil then
			return false, cfg.err_msg_supl.char;								-- fail if isbn13 is not all digits
		end
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then
			return false, cfg.err_msg_supl.prefix;								-- fail when isbn13 does not begin with 978 or 979
		end
		if isbn_str:match ('^9790') then
			return false, cfg.err_msg_supl.group;								-- group identifier '0' is reserved to ismn
		end
		return is_valid_isxn_13 (isbn_str), cfg.err_msg_supl.check;
	end
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

This function is positioned here because it calls isbn()

]]

local function asin(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat = ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then							-- if 10-digit numeric (or 9 digits with terminal X)
			if isbn( id ) then													-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat = ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat = ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
		prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;
	local id_copy;

	id_copy = id;																-- save a copy because this testing is destructive
	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix, id=id_copy, separator=handler.separator, encode=handler.encode})
 
	text = table.concat (
		{
		make_wikilink (handler.link, handler.label),
		handler.separator,
		id_copy
		});		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the ismn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]	-- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id, e)
	local issn_copy = id;														-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler;
	local text;
	local valid_issn = true;
	
	if e then
		 handler = cfg.id_handlers['EISSN'];
	else
		 handler = cfg.id_handlers['ISSN'];
	end

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then						-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;														-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);										-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );				-- if valid, display correctly formatted version
	else
		id = issn_copy;															-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})

	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn', e and 'e' or '' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; J F M &gt;-----------------------------------------------------------------------

A numerical identifier in the form nn.nnnn.nn

]]

local function jfm (id)
	local handler = cfg.id_handlers['JFM'];
	local id_num;
	local err_cat = '';
	
	id_num = id:match ('^[Jj][Ff][Mm](.*)$');									-- identifier with jfm prefix; extract identifier

	if is_set (id_num) then
		add_maint_cat ('jfm_format');
	else																		-- plain number without mr prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num and id_num:match('^%d%d%.%d%d%d%d%.%d%d$') then
		id = id_num;															-- jfm matches pattern
	else
		err_cat = ' ' .. set_error( 'bad_jfm' );								-- set an error message
	end
	
	return external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat = '';															-- presume that LCCN is valid
	local id = lccn;															-- local copy of the lccn

	id = normalize_lccn (id);													-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();														-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- set an error message
		end
	elseif 9 == len then														-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then							-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- set an error message
		end
	elseif 10 == len then														-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then					-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );						-- no match, set an error message
			end
		end
	elseif 11 == len then														-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- no match, set an error message
		end
	elseif 12 == len then														-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then						-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );								-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );								-- lccn contains a space, set an error message
	end

	return external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; M R &gt;--------------------------------------------------------------------------

A seven digit number; if not seven digits, zero-fill leading digits to make seven digits.

]]

local function mr (id)
	local handler = cfg.id_handlers['MR'];
	local id_num;
	local id_len;
	local err_cat = '';
	
	id_num = id:match ('^[Mm][Rr](%d+)$');										-- identifier with mr prefix

	if is_set (id_num) then
		add_maint_cat ('mr_format');
	else																		-- plain number without mr prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	id_len = id_num and id_num:len() or 0;
	if (7 &gt;= id_len) and (0 ~= id_len) then
		id = string.rep ('0', 7-id_len ) .. id_num;								-- zero-fill leading digits
	else
		err_cat = ' ' .. set_error( 'bad_mr' );									-- set an error message
	end
	
	return external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an oclc id.  https://www.oclc.org/batchload/controlnumber.en.html {{dead link}}
archived at: https://web.archive.org/web/20161228233804/https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (id)
	local handler = cfg.id_handlers['OCLC'];
	local number;
	local err_msg = '';															-- empty string for concatenation
	
	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- contrain to 1 to 9 digits; change this when oclc issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if 10 &lt; number:len() then
			number = nil;														-- contrain to 1 to 10 digits; change this when oclc issues 11-digit numbers
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		err_msg = ' ' .. set_error( 'bad_oclc' )								-- add an error message if the id is malformed
	end
	
	local text = external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode}) .. err_msg;

	return text;
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id, access)
	local code;
	local handler = cfg.id_handlers['OL'];
	local ident;
	
	ident, code = id:gsub('^OL', ''):match(&quot;^(%d+([AMW]))$&quot;);					-- optional OL prefix followed immediately by digits followed by 'A', 'M', or 'W'; remove OL prefix

	if not is_set (ident) then													-- if malformed return an error
		return external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access}) .. ' ' .. set_error( 'bad_ol' );
	end
	
	id = ident;																	-- use ident without the optional OL prefix (it has been removed)
	
	if ( code == &quot;A&quot; ) then
		return external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end
	
	if ( code == &quot;M&quot; ) then
		return external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end

	if ( code == &quot;W&quot; ) then
		return external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = cfg.id_limits.pmc;													-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat = '';															-- presume that PMC is valid
	local id_num;
	local text;
	
	id_num = id:match ('^[Pp][Mm][Cc](%d+)$');									-- identifier with pmc prefix

	if is_set (id_num) then
		add_maint_cat ('pmc_format');
	else																		-- plain number without pmc prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then								-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );							-- set an error message
		else
			id = tostring (id_num);												-- make sure id is a string
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_pmc' );								-- set an error message
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text = table.concat (													-- still embargoed so no external link
			{
			make_wikilink (handler.link, handler.label),
			handler.separator,
			id,
			err_cat
			});
	else
		text = external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,	-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = cfg.id_limits.pmid;											-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat = '';															-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then													-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );								-- set an error message
	else																		-- PMID is only digits
		local id_num = tonumber(id);											-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then								-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );							-- set an error message
		end
	end
	
	return external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; S 2 C I D &gt;--------------------------------------------------------------------

Format an s2cid, do simple error checking

S2CIDs are sequential numbers beginning at 1 and counting up.  This code checks the s2cid to see that it is only
digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically
as more S2CIDs are issued.

]]

local function s2cid (id, access)
	local test_limit = cfg.id_limits.s2cid;										-- update this value as S2CIDs approach
	local handler = cfg.id_handlers['S2CID'];
	local err_cat = '';															-- presume that S2CID is valid
	local id_num;
	local text;
	
	id_num = id:match ('^[1-9]%d+$');											-- id must be all digits; must not begin with 0; no open access flag

 	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if test_limit &lt; id_num then												-- if S2CID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_s2cid' );							-- set an error message
		end

	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_s2cid' );								-- set an error message
	end

	text = external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
		prefix=handler.prefix, id=id:gsub ('%.%a%a', ''), separator=handler.separator, encode=handler.encode, access=access}) .. err_cat;

	return text;
end


--[[--------------------------&lt; S B N &gt;------------------------------------------------------------------------

9-digit form of isbn10; uses same check-digit validation when sbn is prefixed with an additional '0' to make 10 digits

]]

local function sbn (id)
	local check;
	local err_type = '';

	if nil ~= id:match(&quot;[^%s-0-9X]&quot;) then
		return false, cfg.err_msg_supl.char;									-- fail if sbn contains anything but digits, hyphens, or the uppercase X
	end

	id=id:gsub( &quot;[%s-]&quot;, &quot;&quot; );													-- strip spaces and hyphens from the sbn

	if  9 ~= id:len() then
		return false, cfg.err_msg_supl.length;									-- fail if incorrect length
	end

	if id:match( &quot;^%d*X?$&quot; ) == nil then										-- fail if sbn has 'X' anywhere but last position
		return false, cfg.err_msg_supl.form;									
	end

	return is_valid_isxn('0' .. id, 10), cfg.err_msg_supl.check;				-- prefix sbn with '0' and validate as isbn10
end


--[[--------------------------&lt; S S R N &gt;----------------------------------------------------------------------

Format an ssrn, do simple error checking

SSRNs are sequential numbers beginning at 100? and counting up.  This code checks the ssrn to see that it is
only digits and is greater than 99 and less than test_limit; the value in local variable test_limit will need
to be updated periodically as more SSRNs are issued.

]]

local function ssrn (id)
	local test_limit = cfg.id_limits.ssrn;													-- update this value as SSRNs approach
	local handler = cfg.id_handlers['SSRN'];
	local err_cat = '';															-- presume that SSRN is valid
	local id_num;
	local text;
	
	id_num = id:match ('^%d+$');												-- id must be all digits

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 100 &gt; id_num or test_limit &lt; id_num then								-- if SSRN is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_ssrn' );							-- set an error message
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_ssrn' );								-- set an error message
	end
	
	text = external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;

	return text;
end


--[[--------------------------&lt; U S E N E T _ I D &gt;------------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function usenet_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_usenet_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; Z B L &gt;-----------------------------------------------------------------------

A numerical identifier in the form nnnn.nnnnn - leading zeros in the first quartet optional

format described here: http://emis.mi.sanu.ac.rs/ZMATH/zmath/en/help/search/

temporary format is apparently eight digits.  Anything else is an error

]]

local function zbl (id)
	local handler = cfg.id_handlers['ZBL'];
	local err_cat = '';
	
	if id:match('^%d%d%d%d%d%d%d%d$') then										-- is this identifier using temporary format?
		add_maint_cat ('zbl');													-- yes, add maint cat
	elseif not id:match('^%d?%d?%d?%d%.%d%d%d%d%d$') then						-- not temporary, is it normal format?
		err_cat = ' ' .. set_error( 'bad_zbl' );								-- no, set an error message
	end
	
	return external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--============================&lt;&lt; I N T E R F A C E   F U N C T I O N S &gt;&gt;==========================================

--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v, ['access'] = options.IdAccessLevels[k] }, fallback(k) );

		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, asin( v, options.ASINTLD ) } ); 
		elseif k == 'BIBCODE' then
			table.insert( new_list, {handler.label, bibcode( v, handler.access ) } );
		elseif k == 'BIORXIV' then
			table.insert( new_list, {handler.label, biorxiv( v ) } );
		elseif k == 'CITESEERX' then
			table.insert( new_list, {handler.label, citeseerx( v ) } );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken, handler.access ) } );
		elseif k == 'EISSN' then
			table.insert( new_list, {handler.label, issn( v, true ) } );		-- true distinguishes eissn from issn
		elseif k == 'HDL' then
			table.insert( new_list, {handler.label, hdl( v, handler.access ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			local check;
			local err_type = '';
			check, err_type = isbn( v );
			if not check then
				if is_set(options.IgnoreISBN) then								-- ISBN is invalid; if |ignore-isbn-error= set
					add_maint_cat ('ignore_isbn_err');							-- ad a maint category
				else
					ISBN = ISBN .. set_error( 'bad_isbn', {err_type}, false, &quot; &quot;, &quot;&quot; );	-- else display an error message
				end
			elseif is_set(options.IgnoreISBN) then								-- ISBN is OK; if |ignore-isbn-error= set
				add_maint_cat ('ignore_isbn_err');								-- because |ignore-isbn-error= unnecessary
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'JFM' then
			table.insert( new_list, {handler.label, jfm( v ) } );
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'MR' then
			table.insert( new_list, {handler.label, mr( v ) } );
		elseif k == 'OCLC' then
			table.insert( new_list, {handler.label, oclc( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v, handler.access ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'S2CID' then
			table.insert( new_list, {handler.label, s2cid( v, handler.access ) } );
		elseif k == 'SBN' then
			local SBN = internal_link_id (handler);
			local check;														-- boolean validation result
			local err_type = '';
			check, err_type = sbn (v);
			if not check then
				SBN = SBN .. set_error( 'bad_sbn', {err_type}, false, &quot; &quot;, &quot;&quot; );	-- display an error message
			end
			table.insert( new_list, {handler.label, SBN } );				
		elseif k == 'SSRN' then
			table.insert( new_list, {handler.label, ssrn( v ) } );
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, usenet_id( v ) } );
		elseif k == 'ZBL' then
			table.insert( new_list, {handler.label, zbl( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1]:lower() &lt; b[1]:lower();
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; E X T R A C T _ I D _ A C C E S S _ L E V E L S &gt;--------------------------------------

Fetches custom id access levels from arguments using configuration settings.
Parameters which have a predefined access level (e.g. arxiv) do not use this
function as they are directly rendered as free without using an additional parameter.

access-level values must match the case used in cfg.keywords_lists['id-access'] (lowercase unless there is some special reason for something else)

]]

local function extract_id_access_levels( args, id_list )
	local id_accesses_list = {};
	for k, v in pairs( cfg.id_handlers ) do
		local access_param = v.custom_access;									-- name of identifier's access-level parameter
		if is_set(access_param) then
			local access_level = args[access_param];							-- get the assigned value if there is one
			if is_set (access_level) then
				if not in_array (access_level, cfg.keywords_lists['id-access']) then	-- exact match required
					table.insert( z.message_tail, { set_error( 'invalid_param_val', {access_param, access_level}, true ) } );	
					access_level = nil;											-- invalid so unset
				end
				if not is_set(id_list[k]) then									-- identifer access-level must have a matching identifier
					table.insert( z.message_tail, { set_error( 'param_access_requires_param', {k:lower()}, true ) } );	-- param name is uppercase in cfg.id_handlers (k); lowercase for error message
				end
				id_accesses_list[k] = cfg.keywords_xlate[access_level];			-- get translated keyword
			end
		end
	end
	return id_accesses_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	set_error = utilities_page_ptr.set_error;
	select_one = utilities_page_ptr.select_one;
	add_maint_cat = utilities_page_ptr.add_maint_cat;
	substitute = utilities_page_ptr.substitute;
	make_wikilink = utilities_page_ptr.make_wikilink;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	extract_id_access_levels = extract_id_access_levels,
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>a3loi856p6xhkm72xsgmazjcazbehbi</sha1>
    </revision>
    <revision>
      <id>4914</id>
      <parentid>4913</parentid>
      <timestamp>2020-04-18T18:14:50Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>biorxiv cat fix?</comment>
      <origin>4914</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="61119" sha1="3blms0k8weuk0elr5ur90yji32ow8pj" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat, substitute, make_wikilink;	-- functions in Module:Citation/CS1/Utilities

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--============================&lt;&lt; H E L P E R   F U N C T I O N S &gt;&gt;============================================

--[[--------------------------&lt; W I K I D A T A _ A R T I C L E _ N A M E _ G E T &gt;----------------------------

as an aid to internationalizing identifier-label wikilinks, gets identifier article names from wikidata.

returns :&lt;lang code&gt;:&lt;article title&gt; when &lt;q&gt; has an &lt;article title&gt; for &lt;lang code&gt;; nil else

for identifiers that do not have q, returns nil

for wikis that do not have mw.wikibase installed, returns nil

The call to mw.wikibase.getEntity() bumps the expensive parser function count

]]

local function wikidata_article_name_get (q)
	if not is_set (q) or (q and not mw.wikibase) then							-- when no q number or when a q number but mw.wikibase not installed on this wiki
		return nil;																-- abandon
	end

	local wd_article;
	local this_wiki_code = cfg.this_wiki_code;									-- wikipedia subdomain; 'en' for en.wikipedia.org

	wd_article = mw.wikibase.getEntity (q):getSitelink (this_wiki_code .. 'wiki');	-- fetch article title from wd; nil when no title available at this wiki; bumps expensive parser function count

	if wd_article then
		wd_article = table.concat ({':', this_wiki_code, ':', wd_article});		-- interwiki-style link without brackets if taken from wd; leading colon required
	end

	return wd_article;															-- article title from wd; nil else
end


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	local ext_link;
	local this_wiki_code = cfg.this_wiki_code;									-- wikipedia subdomain; 'en' for en.wikipedia.org
	local wd_article;															-- article title from wikidata
	
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end

	ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or &quot;&quot;, mw.text.nowiki(options.id));
	if is_set(options.access) then
		ext_link = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[options.access].class, cfg.presentation[options.access].title, ext_link});	-- add the free-to-read / paywall lock
	end

	if not (cfg.use_identifier_redirects and is_set (options.redirect)) then	-- redirect has priority so if enabled and available don't fetch from wikidata because expensive
		wd_article = wikidata_article_name_get (options.q);						-- if wikidata has an article title for this wiki, get it;
	end
	
	local label_link = (cfg.use_identifier_redirects and is_set (options.redirect) and options.redirect) or wd_article or options.link;

	return table.concat	({
		make_wikilink (label_link, options.label),								-- redirect, wikidata link, or locally specified link (in that order)
		options.separator or '&amp;nbsp;',
		ext_link
		});
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	local id = mw.ustring.gsub (options.id, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9

	if not (cfg.use_identifier_redirects and is_set (options.redirect)) then	-- redirect has priority so if enabled and available don't fetch from wikidata because expensive
		wd_article = wikidata_article_name_get (options.q);						-- if wikidata has an article title for this wiki, get it;
	end

	local label_link = (cfg.use_identifier_redirects and is_set (options.redirect) and options.redirect) or wd_article or options.link;

	return table.concat (
		{
		make_wikilink (label_link, options.label),								-- wiki link the identifier label
		options.separator or '&amp;nbsp;',											-- add the separator
		make_wikilink (
			table.concat (
				{
				options.prefix,
				id,																-- translated to western digits
				options.suffix or ''
				}),
			substitute (cfg.presentation['bdi'], {'', mw.text.nowiki (options.id)})	-- bdi tags to prevent Latn script identifiers from being reversed at rtl language wikis
			);																	-- nowiki because MediaWiki still has magic links for ISBN and the like; TODO: is it really required?
		});
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[=[-------------------------&lt; I S _ V A L I D _ B I O R X I V _ D A T E &gt;------------------------------------

returns true if:
	2019-12-11T00:00Z &lt;= biorxiv_date &lt; today + 2 days
	
The dated form of biorxiv identifier has a start date of 2019-12-11.  The unix timestamp for that date is {{#time:U|2019-12-11}} = 1576022400

biorxiv_date is the date provided in those |biorxiv= parameter values that are dated at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-Engish date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate().  To get around that
call this function with YYYY-MM-DD format dates.

]=]

local function is_valid_biorxiv_date (biorxiv_date)
	local good1, good2;
	local biorxiv_ts, tomorrow_ts;												-- to hold unix time stamps representing the dates
	local lang_object = mw.getContentLanguage();

	good1, biorxiv_ts = pcall (lang_object.formatDate, lang_object, 'U', biorxiv_date );		-- convert biorxiv_date value to unix timesatmp 
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which which tonumber() may not understand
		biorxiv_ts = tonumber (biorxiv_ts) or lang_object:parseFormattedNumber (biorxiv_ts);	-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to unix time stamp
	end

	return ((1576022400 &lt;= biorxiv_ts) and (biorxiv_ts &lt; tomorrow_ts))			-- 2012-12-11T00:00Z &lt;= biorxiv_date &lt; tomorrow's date
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39, 'X' → 0x58
	len = len+1;																-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do											-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then											-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );										-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;														-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N _ 1 3 &gt;-----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--============================&lt;&lt; I D E N T I F I E R   F U N C T I O N S &gt;&gt;====================================

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation; not the same as |class= parameter which is not supported in this form
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = false;														-- assume no error message
	local text;																	-- output text
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
				err_cat = true;													-- flag for error message
		end

	else
		err_cat = true;															-- not a recognized format; flag for error message
	end

	err_cat = err_cat and table.concat ({' ', set_error ('bad_arxiv')}) or '';	-- set error message if flag is true
	
	text = external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;

	if is_set (class) then
		if id:match ('^%d+') then
			text = table.concat ({text, ' [[//arxiv.org/archive/', class, ' ', class, ']]'});	-- external link within square brackets, not wikilink
		else
			text = table.concat ({text, ' ', set_error ('class_ignored')});		
		end
	end

	return text;	
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode id.

Format for bibcodes is specified here: http://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		9–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (id, access)
	local handler = cfg.id_handlers['BIBCODE'];
	local err_type;
	local year;

	local text = external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
		access=access});
	
	if 19 ~= id:len() then
		err_type = cfg.err_msg_supl.length;
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%w&amp;%.][%w&amp;%.][%w&amp;%.][%w.]+[%a%.]$&quot;)	-- 
		if not year then														-- if nil then no pattern match
			err_type = cfg.err_msg_supl.value;													-- so value error
		else
			local next_year = tonumber(os.date ('%Y'))+1;						-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = cfg.err_msg_supl.year;												-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = cfg.err_msg_supl.journal;											-- journal abbreviation must not have '&amp;.' (if it does its missing a letter)
			end
		end
	end

	if is_set (err_type) then													-- if there was an error detected
		text = text .. ' ' .. set_error( 'bad_bibcode', {err_type});
	end
	return text;
end


--[[--------------------------&lt; B I O R X I V &gt;-----------------------------------------------------------------

Format bioRxiv id and do simple error checking.  Before 2019-12-11, biorXiv ids were 10.1101/ followed by exactly
6 digits.  After 2019-12-11, biorXiv ids retained the six-digit identifier but prefixed that with a yyyy.mm.dd. 
date and suffixed with an optional version identifier.

The bioRxiv id is the string of characters:
	https://doi.org/10.1101/078733 -&gt; 10.1101/078733
or a date followed by a six-digit number followed by an optional version indicator 'v' and one or more digits:
	https://www.biorxiv.org/content/10.1101/2019.12.11.123456v2 -&gt; 10.1101/2019.12.11.123456v2
	
see https://www.biorxiv.org/about-biorxiv

]]

local function biorxiv(id)
	local handler = cfg.id_handlers['BIORXIV'];
	local err_cat = true;														-- flag; assume that there will be an error
	
	local patterns = {
		'^10.1101/%d%d%d%d%d%d$',												-- simple 6-digit identifier (before 2019-12-11)
		'^10.1101/(20[1-9]%d)%.([01]%d)%.([0-3]%d)%.%d%d%d%d%d%dv%d+$',			-- y.m.d. date + 6-digit identifier + version (after 2019-12-11)
		'^10.1101/(20[1-9]%d)%.([01]%d)%.([0-3]%d)%.%d%d%d%d%d%d$',				-- y.m.d. date + 6-digit identifier (after 2019-12-11)
	}
	
	for _, pattern in ipairs (patterns) do										-- spin through the patterns looking for a match
		if id:match (pattern) then
			local y, m, d = id:match (pattern);									-- found a match, attempt to get year, month and date from the identifier

			if m then															-- m is nil when id is the six-digit form
				if not is_valid_biorxiv_date (y .. '-' .. m .. '-' .. d) then	-- validate the encoded date; TODO: don't ignore leapyear and actual month lengths ({{#time:}} is a poor date validator)
					break;														-- date fail; break out early so we don't unset the error message
				end
			end
			err_cat = nil;														-- we found a match so unset the error message
			break;																-- and done
		end
	end																			-- err_cat remains set here when no match

	return external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
			prefix=handler.prefix,id=id,separator=handler.separator,
			encode=handler.encode, access=handler.access}) .. (err_cat and (' ' .. set_error( 'bad_biorxiv')) or '');
end


--[[--------------------------&lt; C I T E S E E R X &gt;------------------------------------------------------------

CiteSeerX use their own notion of &quot;doi&quot; (not to be confused with the identifiers resolved via doi.org).

The description of the structure of this identifier can be found at Help_talk:Citation_Style_1/Archive_26#CiteSeerX_id_structure
]]

local function citeseerx (id)
	local handler = cfg.id_handlers['CITESEERX'];
	local matched;
	
	local text = external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
		access=handler.access});
	
	matched = id:match (&quot;^10%.1%.1%.[1-9]%d?%d?%d?%.[1-9]%d?%d?%d?$&quot;);
	if not matched then
		text = text .. ' ' .. set_error( 'bad_citeseerx' );
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive, access)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';					-- try to get the year portion from the inactive date
		local inactive_month, good;

		if is_set (inactive_year) then
			if 4 &lt; inactive:len() then											-- inactive date has more than just a year (could be anything)
				local lang_obj = mw.getContentLanguage();						-- get a language object for this wiki
				good, inactive_month = pcall (lang_obj.formatDate, lang_obj, 'F', inactive);	-- try to get the month name from the inactive date
				if not good then
					inactive_month = nil;										-- something went wrong so make sure this is unset
				end
			end
		else
			inactive_year = nil;												-- |doi-broken= has something but it isn't a date
		end
		
		if is_set(inactive_year) and is_set (inactive_month) then
			table.insert( z.error_categories, 'Pages with DOIs inactive as of ' .. inactive_year .. ' ' .. inactive_month);	-- use inactive month in category name
		elseif is_set(inactive_year) then
			table.insert( z.error_categories, 'Pages with DOIs inactive as of ' .. inactive_year);
		else
			table.insert( z.error_categories, 'Pages with inactive DOIs');		-- when inactive doesn't contain a recognizable date
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. ' ' .. inactive .. ')';
	end

	text = external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access}) .. (inactive or '')

	local registrant = id:match ('^10%.([^/]+)/[^%s–]-[^%.,]$');				-- registrant set when doi has the proper basic form
	
	registrant_err_patterns = {													-- these patterns are for code ranges that are not supported 
		'^[^1-3]%d%d%d%d%.%d%d*$',												-- 5 digits with subcode (0xxxx, 40000+); accecpts: 10000–39999
		'^[^1-3]%d%d%d%d$',														-- 5 digits without subcode (0xxxx, 40000+); accecpts: 10000–39999
		'^[^1-9]%d%d%d%.%d%d*$',												-- 4 digits with subcode (0xxx); accecpts: 1000–9999
		'^[^1-9]%d%d%d$',														-- 4 digits without subcode (0xxx); accecpts: 1000–9999
		'^%d%d%d%d%d%d+',														-- 6 or more digits
		'^%d%d?%d?$',															-- less than 4 digits without subcode (with subcode is legitimate)
		'^5555$',																-- test registrant will never resolve
		'%s',																	-- any space character in registrant
		}
	
	if registrant then															-- when doi has proper form
		for i, pattern in ipairs (registrant_err_patterns) do					-- spin through error patterns
			if registrant:match (pattern) then									-- to validate registrant codes
				cat = ' ' .. set_error ('bad_doi');								-- when found, mark this doi as bad
				break;															-- and done
			end
		end
	else
		cat = ' ' .. set_error ('bad_doi');										-- invalid directory or malformed
	end

	return text .. cat 
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

Query string parameters are named here: http://www.handle.net/proxy_servlet.html.  query strings are not displayed
but since '?' is anallowed character in an hdl, '?' followed by one of the query parameters is the only way we
have to detect the query string so that it isn't url encoded with the rest of the identifier.

]]

local function hdl(id, access)
	local handler = cfg.id_handlers['HDL'];
	local query_params = {														-- list of known query parameters from http://www.handle.net/proxy_servlet.html
		'noredirect',
		'ignore_aliases',
		'auth',
		'cert',
		'index',
		'type',
		'urlappend',
		'locatt',
		'action',
		}
	
	local hdl, suffix, param = id:match ('(.-)(%?(%a+).+)$');					-- look for query string
	local found;

	if hdl then																	-- when there are query strings, this is the handle identifier portion
		for _, q in ipairs (query_params) do									-- spin through the list of query parameters
			if param:match ('^' .. q) then										-- if the query string begins with one of the parameters
				found = true;													-- announce a find
				break;															-- and stop looking
			end
		end
	end

	if found then
		id = hdl;																-- found so replace id with the handle portion; this will be url encoded, suffix will not
	else
		suffix = '';															-- make sure suffix is empty string for concatenation else
	end

	local text = external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
			prefix=handler.prefix, id=id, suffix=suffix, separator=handler.separator, encode=handler.encode, access=access})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- hdl must contain a fwd slash, must not contain spaces, endashes, and must not end with period or comma
		text = text .. ' ' .. set_error( 'bad_hdl' );
	end
	return text;
end


--[[--------------------------&lt; I S B N &gt;----------------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then
		return false, cfg.err_msg_supl.char;									-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );						-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false, cfg.err_msg_supl.length;									-- fail if incorrect length
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then								-- fail if isbn_str has 'X' anywhere but last position
			return false, cfg.err_msg_supl.form;									
		end
		return is_valid_isxn(isbn_str, 10), cfg.err_msg_supl.check;
	else
		if isbn_str:match( &quot;^%d+$&quot; ) == nil then
			return false, cfg.err_msg_supl.char;								-- fail if isbn13 is not all digits
		end
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then
			return false, cfg.err_msg_supl.prefix;								-- fail when isbn13 does not begin with 978 or 979
		end
		if isbn_str:match ('^9790') then
			return false, cfg.err_msg_supl.group;								-- group identifier '0' is reserved to ismn
		end
		return is_valid_isxn_13 (isbn_str), cfg.err_msg_supl.check;
	end
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

This function is positioned here because it calls isbn()

]]

local function asin(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat = ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then							-- if 10-digit numeric (or 9 digits with terminal X)
			if isbn( id ) then													-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat = ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat = ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
		prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;
	local id_copy;

	id_copy = id;																-- save a copy because this testing is destructive
	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix, id=id_copy, separator=handler.separator, encode=handler.encode})
 
	text = table.concat (
		{
		make_wikilink (handler.link, handler.label),
		handler.separator,
		id_copy
		});		-- because no place to link to yet

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the ismn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]	-- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id, e)
	local issn_copy = id;														-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler;
	local text;
	local valid_issn = true;
	
	if e then
		 handler = cfg.id_handlers['EISSN'];
	else
		 handler = cfg.id_handlers['ISSN'];
	end

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then						-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;														-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);										-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );				-- if valid, display correctly formatted version
	else
		id = issn_copy;															-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})

	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn', e and 'e' or '' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; J F M &gt;-----------------------------------------------------------------------

A numerical identifier in the form nn.nnnn.nn

]]

local function jfm (id)
	local handler = cfg.id_handlers['JFM'];
	local id_num;
	local err_cat = '';
	
	id_num = id:match ('^[Jj][Ff][Mm](.*)$');									-- identifier with jfm prefix; extract identifier

	if is_set (id_num) then
		add_maint_cat ('jfm_format');
	else																		-- plain number without mr prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num and id_num:match('^%d%d%.%d%d%d%d%.%d%d$') then
		id = id_num;															-- jfm matches pattern
	else
		err_cat = ' ' .. set_error( 'bad_jfm' );								-- set an error message
	end
	
	return external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat = '';															-- presume that LCCN is valid
	local id = lccn;															-- local copy of the lccn

	id = normalize_lccn (id);													-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();														-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- set an error message
		end
	elseif 9 == len then														-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then							-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- set an error message
		end
	elseif 10 == len then														-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then					-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );						-- no match, set an error message
			end
		end
	elseif 11 == len then														-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- no match, set an error message
		end
	elseif 12 == len then														-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then						-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );								-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );								-- lccn contains a space, set an error message
	end

	return external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; M R &gt;--------------------------------------------------------------------------

A seven digit number; if not seven digits, zero-fill leading digits to make seven digits.

]]

local function mr (id)
	local handler = cfg.id_handlers['MR'];
	local id_num;
	local id_len;
	local err_cat = '';
	
	id_num = id:match ('^[Mm][Rr](%d+)$');										-- identifier with mr prefix

	if is_set (id_num) then
		add_maint_cat ('mr_format');
	else																		-- plain number without mr prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	id_len = id_num and id_num:len() or 0;
	if (7 &gt;= id_len) and (0 ~= id_len) then
		id = string.rep ('0', 7-id_len ) .. id_num;								-- zero-fill leading digits
	else
		err_cat = ' ' .. set_error( 'bad_mr' );									-- set an error message
	end
	
	return external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an oclc id.  https://www.oclc.org/batchload/controlnumber.en.html {{dead link}}
archived at: https://web.archive.org/web/20161228233804/https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (id)
	local handler = cfg.id_handlers['OCLC'];
	local number;
	local err_msg = '';															-- empty string for concatenation
	
	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- contrain to 1 to 9 digits; change this when oclc issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if 10 &lt; number:len() then
			number = nil;														-- contrain to 1 to 10 digits; change this when oclc issues 11-digit numbers
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		err_msg = ' ' .. set_error( 'bad_oclc' )								-- add an error message if the id is malformed
	end
	
	local text = external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode}) .. err_msg;

	return text;
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id, access)
	local code;
	local handler = cfg.id_handlers['OL'];
	local ident;
	
	ident, code = id:gsub('^OL', ''):match(&quot;^(%d+([AMW]))$&quot;);					-- optional OL prefix followed immediately by digits followed by 'A', 'M', or 'W'; remove OL prefix

	if not is_set (ident) then													-- if malformed return an error
		return external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access}) .. ' ' .. set_error( 'bad_ol' );
	end
	
	id = ident;																	-- use ident without the optional OL prefix (it has been removed)
	
	if ( code == &quot;A&quot; ) then
		return external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end
	
	if ( code == &quot;M&quot; ) then
		return external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end

	if ( code == &quot;W&quot; ) then
		return external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local test_limit = cfg.id_limits.pmc;													-- update this value as PMCs approach
	local handler = cfg.id_handlers['PMC'];
	local err_cat = '';															-- presume that PMC is valid
	local id_num;
	local text;
	
	id_num = id:match ('^[Pp][Mm][Cc](%d+)$');									-- identifier with pmc prefix

	if is_set (id_num) then
		add_maint_cat ('pmc_format');
	else																		-- plain number without pmc prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then								-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );							-- set an error message
		else
			id = tostring (id_num);												-- make sure id is a string
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_pmc' );								-- set an error message
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text = table.concat (													-- still embargoed so no external link
			{
			make_wikilink (handler.link, handler.label),
			handler.separator,
			id,
			err_cat
			});
	else
		text = external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,	-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local test_limit = cfg.id_limits.pmid;											-- update this value as PMIDs approach
	local handler = cfg.id_handlers['PMID'];
	local err_cat = '';															-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then													-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );								-- set an error message
	else																		-- PMID is only digits
		local id_num = tonumber(id);											-- convert id to a number for range testing
		if 1 &gt; id_num or test_limit &lt; id_num then								-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );							-- set an error message
		end
	end
	
	return external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; S 2 C I D &gt;--------------------------------------------------------------------

Format an s2cid, do simple error checking

S2CIDs are sequential numbers beginning at 1 and counting up.  This code checks the s2cid to see that it is only
digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically
as more S2CIDs are issued.

]]

local function s2cid (id, access)
	local test_limit = cfg.id_limits.s2cid;										-- update this value as S2CIDs approach
	local handler = cfg.id_handlers['S2CID'];
	local err_cat = '';															-- presume that S2CID is valid
	local id_num;
	local text;
	
	id_num = id:match ('^[1-9]%d+$');											-- id must be all digits; must not begin with 0; no open access flag

 	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if test_limit &lt; id_num then												-- if S2CID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_s2cid' );							-- set an error message
		end

	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_s2cid' );								-- set an error message
	end

	text = external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
		prefix=handler.prefix, id=id:gsub ('%.%a%a', ''), separator=handler.separator, encode=handler.encode, access=access}) .. err_cat;

	return text;
end


--[[--------------------------&lt; S B N &gt;------------------------------------------------------------------------

9-digit form of isbn10; uses same check-digit validation when sbn is prefixed with an additional '0' to make 10 digits

]]

local function sbn (id)
	local check;
	local err_type = '';

	if nil ~= id:match(&quot;[^%s-0-9X]&quot;) then
		return false, cfg.err_msg_supl.char;									-- fail if sbn contains anything but digits, hyphens, or the uppercase X
	end

	id=id:gsub( &quot;[%s-]&quot;, &quot;&quot; );													-- strip spaces and hyphens from the sbn

	if  9 ~= id:len() then
		return false, cfg.err_msg_supl.length;									-- fail if incorrect length
	end

	if id:match( &quot;^%d*X?$&quot; ) == nil then										-- fail if sbn has 'X' anywhere but last position
		return false, cfg.err_msg_supl.form;									
	end

	return is_valid_isxn('0' .. id, 10), cfg.err_msg_supl.check;				-- prefix sbn with '0' and validate as isbn10
end


--[[--------------------------&lt; S S R N &gt;----------------------------------------------------------------------

Format an ssrn, do simple error checking

SSRNs are sequential numbers beginning at 100? and counting up.  This code checks the ssrn to see that it is
only digits and is greater than 99 and less than test_limit; the value in local variable test_limit will need
to be updated periodically as more SSRNs are issued.

]]

local function ssrn (id)
	local test_limit = cfg.id_limits.ssrn;													-- update this value as SSRNs approach
	local handler = cfg.id_handlers['SSRN'];
	local err_cat = '';															-- presume that SSRN is valid
	local id_num;
	local text;
	
	id_num = id:match ('^%d+$');												-- id must be all digits

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 100 &gt; id_num or test_limit &lt; id_num then								-- if SSRN is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_ssrn' );							-- set an error message
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_ssrn' );								-- set an error message
	end
	
	text = external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;

	return text;
end


--[[--------------------------&lt; U S E N E T _ I D &gt;------------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function usenet_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_usenet_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; Z B L &gt;-----------------------------------------------------------------------

A numerical identifier in the form nnnn.nnnnn - leading zeros in the first quartet optional

format described here: http://emis.mi.sanu.ac.rs/ZMATH/zmath/en/help/search/

temporary format is apparently eight digits.  Anything else is an error

]]

local function zbl (id)
	local handler = cfg.id_handlers['ZBL'];
	local err_cat = '';
	
	if id:match('^%d%d%d%d%d%d%d%d$') then										-- is this identifier using temporary format?
		add_maint_cat ('zbl');													-- yes, add maint cat
	elseif not id:match('^%d?%d?%d?%d%.%d%d%d%d%d$') then						-- not temporary, is it normal format?
		err_cat = ' ' .. set_error( 'bad_zbl' );								-- no, set an error message
	end
	
	return external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--============================&lt;&lt; I N T E R F A C E   F U N C T I O N S &gt;&gt;==========================================

--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v, ['access'] = options.IdAccessLevels[k] }, fallback(k) );

		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, asin( v, options.ASINTLD ) } ); 
		elseif k == 'BIBCODE' then
			table.insert( new_list, {handler.label, bibcode( v, handler.access ) } );
		elseif k == 'BIORXIV' then
			table.insert( new_list, {handler.label, biorxiv( v ) } );
		elseif k == 'CITESEERX' then
			table.insert( new_list, {handler.label, citeseerx( v ) } );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken, handler.access ) } );
		elseif k == 'EISSN' then
			table.insert( new_list, {handler.label, issn( v, true ) } );		-- true distinguishes eissn from issn
		elseif k == 'HDL' then
			table.insert( new_list, {handler.label, hdl( v, handler.access ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			local check;
			local err_type = '';
			check, err_type = isbn( v );
			if not check then
				if is_set(options.IgnoreISBN) then								-- ISBN is invalid; if |ignore-isbn-error= set
					add_maint_cat ('ignore_isbn_err');							-- ad a maint category
				else
					ISBN = ISBN .. set_error( 'bad_isbn', {err_type}, false, &quot; &quot;, &quot;&quot; );	-- else display an error message
				end
			elseif is_set(options.IgnoreISBN) then								-- ISBN is OK; if |ignore-isbn-error= set
				add_maint_cat ('ignore_isbn_err');								-- because |ignore-isbn-error= unnecessary
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'JFM' then
			table.insert( new_list, {handler.label, jfm( v ) } );
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'MR' then
			table.insert( new_list, {handler.label, mr( v ) } );
		elseif k == 'OCLC' then
			table.insert( new_list, {handler.label, oclc( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v, handler.access ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'S2CID' then
			table.insert( new_list, {handler.label, s2cid( v, handler.access ) } );
		elseif k == 'SBN' then
			local SBN = internal_link_id (handler);
			local check;														-- boolean validation result
			local err_type = '';
			check, err_type = sbn (v);
			if not check then
				SBN = SBN .. set_error( 'bad_sbn', {err_type}, false, &quot; &quot;, &quot;&quot; );	-- display an error message
			end
			table.insert( new_list, {handler.label, SBN } );				
		elseif k == 'SSRN' then
			table.insert( new_list, {handler.label, ssrn( v ) } );
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, usenet_id( v ) } );
		elseif k == 'ZBL' then
			table.insert( new_list, {handler.label, zbl( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1]:lower() &lt; b[1]:lower();
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; E X T R A C T _ I D _ A C C E S S _ L E V E L S &gt;--------------------------------------

Fetches custom id access levels from arguments using configuration settings.
Parameters which have a predefined access level (e.g. arxiv) do not use this
function as they are directly rendered as free without using an additional parameter.

access-level values must match the case used in cfg.keywords_lists['id-access'] (lowercase unless there is some special reason for something else)

]]

local function extract_id_access_levels( args, id_list )
	local id_accesses_list = {};
	for k, v in pairs( cfg.id_handlers ) do
		local access_param = v.custom_access;									-- name of identifier's access-level parameter
		if is_set(access_param) then
			local access_level = args[access_param];							-- get the assigned value if there is one
			if is_set (access_level) then
				if not in_array (access_level, cfg.keywords_lists['id-access']) then	-- exact match required
					table.insert( z.message_tail, { set_error( 'invalid_param_val', {access_param, access_level}, true ) } );	
					access_level = nil;											-- invalid so unset
				end
				if not is_set(id_list[k]) then									-- identifer access-level must have a matching identifier
					table.insert( z.message_tail, { set_error( 'param_access_requires_param', {k:lower()}, true ) } );	-- param name is uppercase in cfg.id_handlers (k); lowercase for error message
				end
				id_accesses_list[k] = cfg.keywords_xlate[access_level];			-- get translated keyword
			end
		end
	end
	return id_accesses_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	set_error = utilities_page_ptr.set_error;
	select_one = utilities_page_ptr.select_one;
	add_maint_cat = utilities_page_ptr.add_maint_cat;
	substitute = utilities_page_ptr.substitute;
	make_wikilink = utilities_page_ptr.make_wikilink;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	extract_id_access_levels = extract_id_access_levels,
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>3blms0k8weuk0elr5ur90yji32ow8pj</sha1>
    </revision>
    <revision>
      <id>4915</id>
      <parentid>4914</parentid>
      <timestamp>2020-07-11T13:18:08Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4915</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="60831" sha1="pajd30obronm356aaihr3t981f9iy1c" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, set_error, select_one, add_maint_cat, substitute, make_wikilink;	-- functions in Module:Citation/CS1/Utilities

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--============================&lt;&lt; H E L P E R   F U N C T I O N S &gt;&gt;============================================

--[[--------------------------&lt; W I K I D A T A _ A R T I C L E _ N A M E _ G E T &gt;----------------------------

as an aid to internationalizing identifier-label wikilinks, gets identifier article names from wikidata.

returns :&lt;lang code&gt;:&lt;article title&gt; when &lt;q&gt; has an &lt;article title&gt; for &lt;lang code&gt;; nil else

for identifiers that do not have q, returns nil

for wikis that do not have mw.wikibase installed, returns nil

]]

local function wikidata_article_name_get (q)
	if not is_set (q) or (q and not mw.wikibase) then							-- when no q number or when a q number but mw.wikibase not installed on this wiki
		return nil;																-- abandon
	end

	local wd_article;
	local this_wiki_code = cfg.this_wiki_code;									-- wikipedia subdomain; 'en' for en.wikipedia.org

	wd_article = mw.wikibase.getSitelink (q, this_wiki_code .. 'wiki');			-- fetch article title from wd; nil when no title available at this wiki

	if wd_article then
		wd_article = table.concat ({':', this_wiki_code, ':', wd_article});		-- interwiki-style link without brackets if taken from wd; leading colon required
	end

	return wd_article;															-- article title from wd; nil else
end


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style external link

]]

local function external_link_id(options)
	local url_string = options.id;
	local ext_link;
	local this_wiki_code = cfg.this_wiki_code;									-- wikipedia subdomain; 'en' for en.wikipedia.org
	local wd_article;															-- article title from wikidata
	
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end

	ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or &quot;&quot;, mw.text.nowiki(options.id));
	if is_set(options.access) then
		ext_link = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[options.access].class, cfg.presentation[options.access].title, ext_link});	-- add the free-to-read / paywall lock
	end

	if not (cfg.use_identifier_redirects and is_set (options.redirect)) then	-- redirect has priority so if enabled and available don't fetch from wikidata because expensive
		wd_article = wikidata_article_name_get (options.q);						-- if wikidata has an article title for this wiki, get it;
	end
	
	local label_link = (cfg.use_identifier_redirects and is_set (options.redirect) and options.redirect) or wd_article or options.link;

	return table.concat	({
		make_wikilink (label_link, options.label),								-- redirect, wikidata link, or locally specified link (in that order)
		options.separator or '&amp;nbsp;',
		ext_link
		});
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki style internal link

]]

local function internal_link_id(options)
	local id = mw.ustring.gsub (options.id, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9

	if not (cfg.use_identifier_redirects and is_set (options.redirect)) then	-- redirect has priority so if enabled and available don't fetch from wikidata because expensive
		wd_article = wikidata_article_name_get (options.q);						-- if wikidata has an article title for this wiki, get it;
	end

	local label_link = (cfg.use_identifier_redirects and is_set (options.redirect) and options.redirect) or wd_article or options.link;

	return table.concat (
		{
		make_wikilink (label_link, options.label),								-- wiki link the identifier label
		options.separator or '&amp;nbsp;',											-- add the separator
		make_wikilink (
			table.concat (
				{
				options.prefix,
				id,																-- translated to western digits
				options.suffix or ''
				}),
			substitute (cfg.presentation['bdi'], {'', mw.text.nowiki (options.id)})	-- bdi tags to prevent Latn script identifiers from being reversed at rtl language wikis
			);																	-- nowiki because MediaWiki still has magic links for ISBN and the like; TODO: is it really required?
		});
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date.  If embargo date is
in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
|embargo= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, good2, todays_date;
		good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
		good2, todays_date = pcall( lang.formatDate, lang, 'U' );
	
		if good1 and good2 then													-- if embargo date and today's date are good dates
			if tonumber( embargo_date ) &gt;= tonumber( todays_date ) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				add_maint_cat ('embargo')
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |embargo= not set return empty string
end


--[=[-------------------------&lt; I S _ V A L I D _ B I O R X I V _ D A T E &gt;------------------------------------

returns true if:
	2019-12-11T00:00Z &lt;= biorxiv_date &lt; today + 2 days
	
The dated form of biorxiv identifier has a start date of 2019-12-11.  The unix timestamp for that date is {{#time:U|2019-12-11}} = 1576022400

biorxiv_date is the date provided in those |biorxiv= parameter values that are dated at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-Engish date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate().  To get around that
call this function with YYYY-MM-DD format dates.

]=]

local function is_valid_biorxiv_date (biorxiv_date)
	local good1, good2;
	local biorxiv_ts, tomorrow_ts;												-- to hold unix time stamps representing the dates
	local lang_object = mw.getContentLanguage();

	good1, biorxiv_ts = pcall (lang_object.formatDate, lang_object, 'U', biorxiv_date );		-- convert biorxiv_date value to unix timesatmp 
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which which tonumber() may not understand
		biorxiv_ts = tonumber (biorxiv_ts) or lang_object:parseFormattedNumber (biorxiv_ts);	-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to unix time stamp
	end

	return ((1576022400 &lt;= biorxiv_ts) and (biorxiv_ts &lt; tomorrow_ts))			-- 2012-12-11T00:00Z &lt;= biorxiv_date &lt; tomorrow's date
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
ISBN-13 is checked in isbn().

If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
and stripped of dashes, spaces and other non-isxn characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39, 'X' → 0x58
	len = len+1;																-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do											-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then											-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );										-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;														-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N _ 1 3 &gt;-----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
and stripped of dashes, spaces and other non-isxn-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when isbn-13/ismn is correct
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized lccn for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);									-- 1. strip whitespace

	if nil ~= string.find (lccn,'/') then
		lccn = lccn:match (&quot;(.-)/&quot;);								-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);						-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then											-- if there was a hyphen
		suffix=string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;	-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn=prefix..suffix;										-- reassemble the lccn
	end
	
	return lccn;
	end

--============================&lt;&lt; I D E N T I F I E R   F U N C T I O N S &gt;&gt;====================================

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9108 and 0703 is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation; not the same as |class= parameter which is not supported in this form
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = false;														-- assume no error message
	local text;																	-- output text
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9108-0703 format w/ &amp; w/o version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then --or									-- when year is 07, is month invalid (before April)?
				err_cat = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format w/ &amp; w/o version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
				err_cat = true;													-- flag for error message
		end

	else
		err_cat = true;															-- not a recognized format; flag for error message
	end

	err_cat = err_cat and table.concat ({' ', set_error ('bad_arxiv')}) or '';	-- set error message if flag is true
	
	text = external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;

	if is_set (class) then
		if id:match ('^%d+') then
			text = table.concat ({text, ' [[//arxiv.org/archive/', class, ' ', class, ']]'});	-- external link within square brackets, not wikilink
		else
			text = table.concat ({text, ' ', set_error ('class_ignored')});		
		end
	end

	return text;	
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode id.

Format for bibcodes is specified here: http://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		9–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (id, access)
	local handler = cfg.id_handlers['BIBCODE'];
	local err_type;
	local year;

	local text = external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
		access=access});
	
	if 19 ~= id:len() then
		err_type = cfg.err_msg_supl.length;
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%w&amp;%.][%w&amp;%.][%w&amp;%.][%w.]+[%a%.]$&quot;)	-- 
		if not year then														-- if nil then no pattern match
			err_type = cfg.err_msg_supl.value;													-- so value error
		else
			local next_year = tonumber(os.date ('%Y'))+1;						-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = cfg.err_msg_supl.year;												-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = cfg.err_msg_supl.journal;											-- journal abbreviation must not have '&amp;.' (if it does its missing a letter)
			end
		end
	end

	if is_set (err_type) then													-- if there was an error detected
		text = text .. ' ' .. set_error( 'bad_bibcode', {err_type});
	end
	return text;
end


--[[--------------------------&lt; B I O R X I V &gt;-----------------------------------------------------------------

Format bioRxiv id and do simple error checking.  Before 2019-12-11, biorXiv ids were 10.1101/ followed by exactly
6 digits.  After 2019-12-11, biorXiv ids retained the six-digit identifier but prefixed that with a yyyy.mm.dd. 
date and suffixed with an optional version identifier.

The bioRxiv id is the string of characters:
	https://doi.org/10.1101/078733 -&gt; 10.1101/078733
or a date followed by a six-digit number followed by an optional version indicator 'v' and one or more digits:
	https://www.biorxiv.org/content/10.1101/2019.12.11.123456v2 -&gt; 10.1101/2019.12.11.123456v2
	
see https://www.biorxiv.org/about-biorxiv

]]

local function biorxiv(id)
	local handler = cfg.id_handlers['BIORXIV'];
	local err_cat = true;														-- flag; assume that there will be an error
	
	local patterns = {
		'^10.1101/%d%d%d%d%d%d$',												-- simple 6-digit identifier (before 2019-12-11)
		'^10.1101/(20[1-9]%d)%.([01]%d)%.([0-3]%d)%.%d%d%d%d%d%dv%d+$',			-- y.m.d. date + 6-digit identifier + version (after 2019-12-11)
		'^10.1101/(20[1-9]%d)%.([01]%d)%.([0-3]%d)%.%d%d%d%d%d%d$',				-- y.m.d. date + 6-digit identifier (after 2019-12-11)
	}
	
	for _, pattern in ipairs (patterns) do										-- spin through the patterns looking for a match
		if id:match (pattern) then
			local y, m, d = id:match (pattern);									-- found a match, attempt to get year, month and date from the identifier

			if m then															-- m is nil when id is the six-digit form
				if not is_valid_biorxiv_date (y .. '-' .. m .. '-' .. d) then	-- validate the encoded date; TODO: don't ignore leapyear and actual month lengths ({{#time:}} is a poor date validator)
					break;														-- date fail; break out early so we don't unset the error message
				end
			end
			err_cat = nil;														-- we found a match so unset the error message
			break;																-- and done
		end
	end																			-- err_cat remains set here when no match

	return external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
			prefix=handler.prefix,id=id,separator=handler.separator,
			encode=handler.encode, access=handler.access}) .. (err_cat and (' ' .. set_error( 'bad_biorxiv')) or '');
end


--[[--------------------------&lt; C I T E S E E R X &gt;------------------------------------------------------------

CiteSeerX use their own notion of &quot;doi&quot; (not to be confused with the identifiers resolved via doi.org).

The description of the structure of this identifier can be found at Help_talk:Citation_Style_1/Archive_26#CiteSeerX_id_structure
]]

local function citeseerx (id)
	local handler = cfg.id_handlers['CITESEERX'];
	local matched;
	
	local text = external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode,
		access=handler.access});
	
	matched = id:match (&quot;^10%.1%.1%.[1-9]%d?%d?%d?%.[1-9]%d?%d?%d?$&quot;);
	if not matched then
		text = text .. ' ' .. set_error( 'bad_citeseerx' );
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the doi name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in doi names.

]]

local function doi(id, inactive, access)
	local cat = &quot;&quot;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set(inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';					-- try to get the year portion from the inactive date
		local inactive_month, good;

		if is_set (inactive_year) then
			if 4 &lt; inactive:len() then											-- inactive date has more than just a year (could be anything)
				local lang_obj = mw.getContentLanguage();						-- get a language object for this wiki
				good, inactive_month = pcall (lang_obj.formatDate, lang_obj, 'F', inactive);	-- try to get the month name from the inactive date
				if not good then
					inactive_month = nil;										-- something went wrong so make sure this is unset
				end
			end
		else
			inactive_year = nil;												-- |doi-broken= has something but it isn't a date
		end
		
		if is_set(inactive_year) and is_set (inactive_month) then
			table.insert( z.error_categories, 'Pages with DOIs inactive as of ' .. inactive_year .. ' ' .. inactive_month);	-- use inactive month in category name
		elseif is_set(inactive_year) then
			table.insert( z.error_categories, 'Pages with DOIs inactive as of ' .. inactive_year);
		else
			table.insert( z.error_categories, 'Pages with inactive DOIs');		-- when inactive doesn't contain a recognizable date
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. ' ' .. inactive .. ')';
	end

	text = external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=access}) .. (inactive or '')

	local registrant = id:match ('^10%.([^/]+)/[^%s–]-[^%.,]$');				-- registrant set when doi has the proper basic form
	
	registrant_err_patterns = {													-- these patterns are for code ranges that are not supported 
		'^[^1-3]%d%d%d%d%.%d%d*$',												-- 5 digits with subcode (0xxxx, 40000+); accecpts: 10000–39999
		'^[^1-4]%d%d%d%d$',														-- 5 digits without subcode (0xxxx, 40000+); accecpts: 10000–49999
		'^[^1-9]%d%d%d%.%d%d*$',												-- 4 digits with subcode (0xxx); accecpts: 1000–9999
		'^[^1-9]%d%d%d$',														-- 4 digits without subcode (0xxx); accecpts: 1000–9999
		'^%d%d%d%d%d%d+',														-- 6 or more digits
		'^%d%d?%d?$',															-- less than 4 digits without subcode (with subcode is legitimate)
		'^5555$',																-- test registrant will never resolve
		'%s',																	-- any space character in registrant
		}
	
	if registrant then															-- when doi has proper form
		for i, pattern in ipairs (registrant_err_patterns) do					-- spin through error patterns
			if registrant:match (pattern) then									-- to validate registrant codes
				cat = ' ' .. set_error ('bad_doi');								-- when found, mark this doi as bad
				break;															-- and done
			end
		end
	else
		cat = ' ' .. set_error ('bad_doi');										-- invalid directory or malformed
	end

	return text .. cat 
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

Query string parameters are named here: http://www.handle.net/proxy_servlet.html.  query strings are not displayed
but since '?' is anallowed character in an hdl, '?' followed by one of the query parameters is the only way we
have to detect the query string so that it isn't url encoded with the rest of the identifier.

]]

local function hdl(id, access)
	local handler = cfg.id_handlers['HDL'];
	local query_params = {														-- list of known query parameters from http://www.handle.net/proxy_servlet.html
		'noredirect',
		'ignore_aliases',
		'auth',
		'cert',
		'index',
		'type',
		'urlappend',
		'locatt',
		'action',
		}
	
	local hdl, suffix, param = id:match ('(.-)(%?(%a+).+)$');					-- look for query string
	local found;

	if hdl then																	-- when there are query strings, this is the handle identifier portion
		for _, q in ipairs (query_params) do									-- spin through the list of query parameters
			if param:match ('^' .. q) then										-- if the query string begins with one of the parameters
				found = true;													-- announce a find
				break;															-- and stop looking
			end
		end
	end

	if found then
		id = hdl;																-- found so replace id with the handle portion; this will be url encoded, suffix will not
	else
		suffix = '';															-- make sure suffix is empty string for concatenation else
	end

	local text = external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
			prefix=handler.prefix, id=id, suffix=suffix, separator=handler.separator, encode=handler.encode, access=access})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- hdl must contain a fwd slash, must not contain spaces, endashes, and must not end with period or comma
		text = text .. ' ' .. set_error( 'bad_hdl' );
	end
	return text;
end


--[[--------------------------&lt; I S B N &gt;----------------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function isbn( isbn_str )
	if nil ~= isbn_str:match(&quot;[^%s-0-9X]&quot;) then
		return false, cfg.err_msg_supl.char;									-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end
	isbn_str = isbn_str:gsub( &quot;-&quot;, &quot;&quot; ):gsub( &quot; &quot;, &quot;&quot; );						-- remove hyphens and spaces
	local len = isbn_str:len();
 
	if len ~= 10 and len ~= 13 then
		return false, cfg.err_msg_supl.length;									-- fail if incorrect length
	end

	if len == 10 then
		if isbn_str:match( &quot;^%d*X?$&quot; ) == nil then								-- fail if isbn_str has 'X' anywhere but last position
			return false, cfg.err_msg_supl.form;									
		end
		return is_valid_isxn(isbn_str, 10), cfg.err_msg_supl.check;
	else
		if isbn_str:match( &quot;^%d+$&quot; ) == nil then
			return false, cfg.err_msg_supl.char;								-- fail if isbn13 is not all digits
		end
		if isbn_str:match( &quot;^97[89]%d*$&quot; ) == nil then
			return false, cfg.err_msg_supl.prefix;								-- fail when isbn13 does not begin with 978 or 979
		end
		if isbn_str:match ('^9790') then
			return false, cfg.err_msg_supl.group;								-- group identifier '0' is reserved to ismn
		end
		return is_valid_isxn_13 (isbn_str), cfg.err_msg_supl.check;
	end
end


--[[--------------------------&lt; A M A Z O N &gt;------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.

This function is positioned here because it calls isbn()

]]

local function asin(id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat = ' ' .. set_error ('bad_asin');								-- asin is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then							-- if 10-digit numeric (or 9 digits with terminal X)
			if isbn( id ) then													-- see if asin value is isbn10
				add_maint_cat ('ASIN');
			elseif not is_set (err_cat) then
				err_cat = ' ' .. set_error ('bad_asin');						-- asin is not isbn10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat = ' ' .. set_error ('bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then			-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then	-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
		prefix=handler.prefix .. domain .. &quot;/dp/&quot;,
		id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;
	local id_copy;

	id_copy = id;																-- save a copy because this testing is destructive
	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the ismn

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ismn must be 13 digits and begin 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ismn
	end

--	text = internal_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,		-- use this (or external version) when there is some place to link to
--		prefix=handler.prefix, id=id_copy, separator=handler.separator, encode=handler.encode})
 
 	local label_link = (cfg.use_identifier_redirects and is_set (handler.redirect) and handler.redirect) or wd_article or handler.link;	-- because no place to link to yet

	text = table.concat (														-- because no place to link to yet
		{
		make_wikilink (label_link, handler.label),
		handler.separator,
		id_copy
		});

	if false == valid_ismn then
		text = text .. ' ' .. set_error( 'bad_ismn' )							-- add an error message if the ismn is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an issn.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]	-- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the issn midpoint.  It also validates the issn for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message.  The
issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.

]]

local function issn(id, e)
	local issn_copy = id;														-- save a copy of unadulterated issn; use this version for display if issn does not validate
	local handler;
	local text;
	local valid_issn = true;
	
	if e then
		 handler = cfg.id_handlers['EISSN'];
	else
		 handler = cfg.id_handlers['ISSN'];
	end

	id=id:gsub( &quot;[%s-–]&quot;, &quot;&quot; );													-- strip spaces, hyphens, and endashes from the issn

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then						-- validate the issn: 8 digits long, containing only 0-9 or X in the last position
		valid_issn=false;														-- wrong length or improper character
	else
		valid_issn=is_valid_isxn(id, 8);										-- validate issn
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );				-- if valid, display correctly formatted version
	else
		id = issn_copy;															-- if not valid, use the show the invalid issn with error message
	end
	
	text = external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})

	if false == valid_issn then
		text = text .. ' ' .. set_error( 'bad_issn', e and 'e' or '' )			-- add an error message if the issn is invalid
	end 
	
	return text
end


--[[--------------------------&lt; J F M &gt;-----------------------------------------------------------------------

A numerical identifier in the form nn.nnnn.nn

]]

local function jfm (id)
	local handler = cfg.id_handlers['JFM'];
	local id_num;
	local err_cat = '';
	
	id_num = id:match ('^[Jj][Ff][Mm](.*)$');									-- identifier with jfm prefix; extract identifier

	if is_set (id_num) then
		add_maint_cat ('jfm_format');
	else																		-- plain number without mr prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num and id_num:match('^%d%d%.%d%d%d%d%.%d%d$') then
		id = id_num;															-- jfm matches pattern
	else
		err_cat = ' ' .. set_error( 'bad_jfm' );								-- set an error message
	end
	
	return external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lower case alpha
length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lower case alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat = '';															-- presume that LCCN is valid
	local id = lccn;															-- local copy of the lccn

	id = normalize_lccn (id);													-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();														-- get the length of the lccn

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- set an error message
		end
	elseif 9 == len then														-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then							-- does it match our pattern?
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- set an error message
		end
	elseif 10 == len then														-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then					-- ... see if it matches our pattern
				err_cat = ' ' .. set_error( 'bad_lccn' );						-- no match, set an error message
			end
		end
	elseif 11 == len then														-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- no match, set an error message
		end
	elseif 12 == len then														-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then						-- see if it matches our pattern
			err_cat = ' ' .. set_error( 'bad_lccn' );							-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_error( 'bad_lccn' );								-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_error( 'bad_lccn' );								-- lccn contains a space, set an error message
	end

	return external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
			prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; M R &gt;--------------------------------------------------------------------------

A seven digit number; if not seven digits, zero-fill leading digits to make seven digits.

]]

local function mr (id)
	local handler = cfg.id_handlers['MR'];
	local id_num;
	local id_len;
	local err_cat = '';
	
	id_num = id:match ('^[Mm][Rr](%d+)$');										-- identifier with mr prefix

	if is_set (id_num) then
		add_maint_cat ('mr_format');
	else																		-- plain number without mr prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	id_len = id_num and id_num:len() or 0;
	if (7 &gt;= id_len) and (0 ~= id_len) then
		id = string.rep ('0', 7-id_len ) .. id_num;								-- zero-fill leading digits
	else
		err_cat = ' ' .. set_error( 'bad_mr' );									-- set an error message
	end
	
	return external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an oclc id.  https://www.oclc.org/batchload/controlnumber.en.html {{dead link}}
archived at: https://web.archive.org/web/20161228233804/https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (id)
	local handler = cfg.id_handlers['OCLC'];
	local number;
	local err_msg = '';															-- empty string for concatenation
	
	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- contrain to 1 to 9 digits; change this when oclc issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if 10 &lt; number:len() then
			number = nil;														-- contrain to 1 to 10 digits; change this when oclc issues 11-digit numbers
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		err_msg = ' ' .. set_error( 'bad_oclc' )								-- add an error message if the id is malformed
	end
	
	local text = external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
		prefix=handler.prefix, id=id, separator=handler.separator, encode=handler.encode}) .. err_msg;

	return text;
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id, access)
	local code;
	local handler = cfg.id_handlers['OL'];
	local ident;
	
	ident, code = id:gsub('^OL', ''):match(&quot;^(%d+([AMW]))$&quot;);					-- optional OL prefix followed immediately by digits followed by 'A', 'M', or 'W'; remove OL prefix

	if not is_set (ident) then													-- if malformed return an error
		return external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
			prefix=handler.prefix .. 'OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access}) .. ' ' .. set_error( 'bad_ol' );
	end
	
	id = ident;																	-- use ident without the optional OL prefix (it has been removed)
	
	if ( code == &quot;A&quot; ) then
		return external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
			prefix=handler.prefix .. 'authors/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end
	
	if ( code == &quot;M&quot; ) then
		return external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
			prefix=handler.prefix .. 'books/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end

	if ( code == &quot;W&quot; ) then
		return external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
			prefix=handler.prefix .. 'works/OL',
			id=id, separator=handler.separator,	encode = handler.encode,
			access = access})
	end
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc(id, embargo)
	local handler = cfg.id_handlers['PMC'];
	local err_cat = '';															-- presume that PMC is valid
	local id_num;
	local text;
	
	id_num = id:match ('^[Pp][Mm][Cc](%d+)$');									-- identifier with pmc prefix

	if is_set (id_num) then
		add_maint_cat ('pmc_format');
	else																		-- plain number without pmc prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmc' );							-- set an error message
		else
			id = tostring (id_num);												-- make sure id is a string
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_pmc' );								-- set an error message
	end
	
	if is_set (embargo) then													-- is PMC is still embargoed?
		text = table.concat (													-- still embargoed so no external link
			{
			make_wikilink (handler.link, handler.label),
			handler.separator,
			id,
			err_cat
			});
	else
		text = external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,	-- no embargo date or embargo has expired, ok to link to article
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;
	end
	return text;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local handler = cfg.id_handlers['PMID'];
	local err_cat = '';															-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then													-- if PMID has anything but digits
		err_cat = ' ' .. set_error( 'bad_pmid' );								-- set an error message
	else																		-- PMID is only digits
		local id_num = tonumber(id);											-- convert id to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_pmid' );							-- set an error message
		end
	end
	
	return external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--[[--------------------------&lt; S 2 C I D &gt;--------------------------------------------------------------------

Format an s2cid, do simple error checking

S2CIDs are sequential numbers beginning at 1 and counting up.  This code checks the s2cid to see that it is only
digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically
as more S2CIDs are issued.

]]

local function s2cid (id, access)
	local handler = cfg.id_handlers['S2CID'];
	local err_cat = '';															-- presume that S2CID is valid
	local id_num;
	local text;
	
	id_num = id:match ('^[1-9]%d*$');											-- id must be all digits; must not begin with 0; no open access flag

 	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if handler.id_limit &lt; id_num then										-- if S2CID is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_s2cid' );							-- set an error message
		end

	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_s2cid' );								-- set an error message
	end

	text = external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
		prefix=handler.prefix, id=id:gsub ('%.%a%a', ''), separator=handler.separator, encode=handler.encode, access=access}) .. err_cat;

	return text;
end


--[[--------------------------&lt; S B N &gt;------------------------------------------------------------------------

9-digit form of isbn10; uses same check-digit validation when sbn is prefixed with an additional '0' to make 10 digits

]]

local function sbn (id)
	local check;
	local err_type = '';

	if nil ~= id:match(&quot;[^%s-0-9X]&quot;) then
		return false, cfg.err_msg_supl.char;									-- fail if sbn contains anything but digits, hyphens, or the uppercase X
	end

	id=id:gsub( &quot;[%s-]&quot;, &quot;&quot; );													-- strip spaces and hyphens from the sbn

	if  9 ~= id:len() then
		return false, cfg.err_msg_supl.length;									-- fail if incorrect length
	end

	if id:match( &quot;^%d*X?$&quot; ) == nil then										-- fail if sbn has 'X' anywhere but last position
		return false, cfg.err_msg_supl.form;									
	end

	return is_valid_isxn('0' .. id, 10), cfg.err_msg_supl.check;				-- prefix sbn with '0' and validate as isbn10
end


--[[--------------------------&lt; S S R N &gt;----------------------------------------------------------------------

Format an ssrn, do simple error checking

SSRNs are sequential numbers beginning at 100? and counting up.  This code checks the ssrn to see that it is
only digits and is greater than 99 and less than test_limit; the value in local variable test_limit will need
to be updated periodically as more SSRNs are issued.

]]

local function ssrn (id)
	local handler = cfg.id_handlers['SSRN'];
	local err_cat = '';															-- presume that SSRN is valid
	local id_num;
	local text;
	
	id_num = id:match ('^%d+$');												-- id must be all digits

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 100 &gt; id_num or handler.id_limit &lt; id_num then						-- if SSRN is outside test limit boundaries
			err_cat = ' ' .. set_error( 'bad_ssrn' );							-- set an error message
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_error( 'bad_ssrn' );								-- set an error message
	end
	
	text = external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode, access=handler.access}) .. err_cat;

	return text;
end


--[[--------------------------&lt; U S E N E T _ I D &gt;------------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function usenet_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
		prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$')then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_error( 'bad_usenet_id' )						-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; Z B L &gt;-----------------------------------------------------------------------

A numerical identifier in the form nnnn.nnnnn - leading zeros in the first quartet optional

format described here: http://emis.mi.sanu.ac.rs/ZMATH/zmath/en/help/search/

temporary format is apparently eight digits.  Anything else is an error

]]

local function zbl (id)
	local handler = cfg.id_handlers['ZBL'];
	local err_cat = '';
	
	if id:match('^%d%d%d%d%d%d%d%d$') then										-- is this identifier using temporary format?
		add_maint_cat ('zbl');													-- yes, add maint cat
	elseif not id:match('^%d?%d?%d?%d%.%d%d%d%d%d$') then						-- not temporary, is it normal format?
		err_cat = ' ' .. set_error( 'bad_zbl' );								-- no, set an error message
	end
	
	return external_link_id ({link=handler.link, label=handler.label, q=handler.q, redirect=handler.redirect,
			prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
end


--============================&lt;&lt; I N T E R F A C E   F U N C T I O N S &gt;&gt;==========================================

--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do												-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v, ['access'] = options.IdAccessLevels[k] }, fallback(k) );

		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, asin( v, options.ASINTLD ) } ); 
		elseif k == 'BIBCODE' then
			table.insert( new_list, {handler.label, bibcode( v, handler.access ) } );
		elseif k == 'BIORXIV' then
			table.insert( new_list, {handler.label, biorxiv( v ) } );
		elseif k == 'CITESEERX' then
			table.insert( new_list, {handler.label, citeseerx( v ) } );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken, handler.access ) } );
		elseif k == 'EISSN' then
			table.insert( new_list, {handler.label, issn( v, true ) } );		-- true distinguishes eissn from issn
		elseif k == 'HDL' then
			table.insert( new_list, {handler.label, hdl( v, handler.access ) } );
		elseif k == 'ISBN' then
			local ISBN = internal_link_id( handler );
			local check;
			local err_type = '';
			check, err_type = isbn( v );
			if not check then
				if is_set(options.IgnoreISBN) then								-- ISBN is invalid; if |ignore-isbn-error= set
					add_maint_cat ('ignore_isbn_err');							-- ad a maint category
				else
					ISBN = ISBN .. set_error( 'bad_isbn', {err_type}, false, &quot; &quot;, &quot;&quot; );	-- else display an error message
				end
			elseif is_set(options.IgnoreISBN) then								-- ISBN is OK; if |ignore-isbn-error= set
				add_maint_cat ('ignore_isbn_err');								-- because |ignore-isbn-error= unnecessary
			end
			table.insert( new_list, {handler.label, ISBN } );				
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v ) } );
		elseif k == 'JFM' then
			table.insert( new_list, {handler.label, jfm( v ) } );
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'MR' then
			table.insert( new_list, {handler.label, mr( v ) } );
		elseif k == 'OCLC' then
			table.insert( new_list, {handler.label, oclc( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v, handler.access ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'S2CID' then
			table.insert( new_list, {handler.label, s2cid( v, handler.access ) } );
		elseif k == 'SBN' then
			local SBN = internal_link_id (handler);
			local check;														-- boolean validation result
			local err_type = '';
			check, err_type = sbn (v);
			if not check then
				SBN = SBN .. set_error( 'bad_sbn', {err_type}, false, &quot; &quot;, &quot;&quot; );	-- display an error message
			end
			table.insert( new_list, {handler.label, SBN } );				
		elseif k == 'SSRN' then
			table.insert( new_list, {handler.label, ssrn( v ) } );
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, usenet_id( v ) } );
		elseif k == 'ZBL' then
			table.insert( new_list, {handler.label, zbl( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1]:lower() &lt; b[1]:lower();
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message is more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; E X T R A C T _ I D _ A C C E S S _ L E V E L S &gt;--------------------------------------

Fetches custom id access levels from arguments using configuration settings.
Parameters which have a predefined access level (e.g. arxiv) do not use this
function as they are directly rendered as free without using an additional parameter.

access-level values must match the case used in cfg.keywords_lists['id-access'] (lowercase unless there is some special reason for something else)

]]

local function extract_id_access_levels( args, id_list )
	local id_accesses_list = {};
	for k, v in pairs( cfg.id_handlers ) do
		local access_param = v.custom_access;									-- name of identifier's access-level parameter
		if is_set(access_param) then
			local access_level = args[access_param];							-- get the assigned value if there is one
			if is_set (access_level) then
				if not in_array (access_level, cfg.keywords_lists['id-access']) then	-- exact match required
					table.insert( z.message_tail, { set_error( 'invalid_param_val', {access_param, access_level}, true ) } );	
					access_level = nil;											-- invalid so unset
				end
				if not is_set(id_list[k]) then									-- identifer access-level must have a matching identifier
					table.insert( z.message_tail, { set_error( 'param_access_requires_param', {k:lower()}, true ) } );	-- param name is uppercase in cfg.id_handlers (k); lowercase for error message
				end
				id_accesses_list[k] = cfg.keywords_xlate[access_level];			-- get translated keyword
			end
		end
	end
	return id_accesses_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	set_error = utilities_page_ptr.set_error;
	select_one = utilities_page_ptr.select_one;
	add_maint_cat = utilities_page_ptr.add_maint_cat;
	substitute = utilities_page_ptr.substitute;
	make_wikilink = utilities_page_ptr.make_wikilink;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	extract_id_access_levels = extract_id_access_levels,
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>pajd30obronm356aaihr3t981f9iy1c</sha1>
    </revision>
    <revision>
      <id>4916</id>
      <parentid>4915</parentid>
      <timestamp>2020-10-10T13:22:55Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4916</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="63549" sha1="3f3nkfekbg2minwt6n6biny31ech649" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local has_accept_as_written, is_set, in_array, set_message, select_one,			-- functions in Module:Citation/CS1/Utilities
		substitute, make_wikilink;

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

declare variables here that have page-wide scope that are not brought in from other modules; that are created here and used here

]]

local auto_link_urls = {};														-- holds identifier URLs for those identifiers that can auto-link |title=


--============================&lt;&lt; H E L P E R   F U N C T I O N S &gt;&gt;============================================

--[[--------------------------&lt; W I K I D A T A _ A R T I C L E _ N A M E _ G E T &gt;----------------------------

as an aid to internationalizing identifier-label wikilinks, gets identifier article names from Wikidata.

returns :&lt;lang code&gt;:&lt;article title&gt; when &lt;q&gt; has an &lt;article title&gt; for &lt;lang code&gt;; nil else

for identifiers that do not have q, returns nil

for wikis that do not have mw.wikibase installed, returns nil

]]

local function wikidata_article_name_get (q)
	if not is_set (q) or (q and not mw.wikibase) then							-- when no q number or when a q number but mw.wikibase not installed on this wiki
		return nil;																-- abandon
	end

	local wd_article;
	local this_wiki_code = cfg.this_wiki_code;									-- Wikipedia subdomain; 'en' for en.wikipedia.org

	wd_article = mw.wikibase.getSitelink (q, this_wiki_code .. 'wiki');			-- fetch article title from WD; nil when no title available at this wiki

	if wd_article then
		wd_article = table.concat ({':', this_wiki_code, ':', wd_article});		-- interwiki-style link without brackets if taken from WD; leading colon required
	end

	return wd_article;															-- article title from WD; nil else
end


--[[--------------------------&lt; L I N K _ L A B E L _ M A K E &gt;------------------------------------------------

common function to create identifier link label from handler table or from Wikidata

returns the first available of
	1. redirect from local wiki's handler table (if enabled)
	2. Wikidata (if there is a Wikidata entry for this identifier in the local wiki's language)
	3. label specified in the local wiki's handler table
	
]]

local function link_label_make (handler)
	local wd_article;
	
	if not (cfg.use_identifier_redirects and is_set (handler.redirect)) then	-- redirect has priority so if enabled and available don't fetch from Wikidata because expensive
		wd_article = wikidata_article_name_get (handler.q);						-- if Wikidata has an article title for this wiki, get it;
	end
	
	return (cfg.use_identifier_redirects and is_set (handler.redirect) and handler.redirect) or wd_article or handler.link;
end


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki-style external link

NB. Wikidata P1630 has a formatter URL with $1 placeholder for the ID which could be worked into our prefix/id/suffix
string, either overriding local definitions (auto-update) or as fallback for identifiers without local definitions. 
But is expensive and could be risky if WD gets vandalized. 

See Template_talk:Authority_control/Archive_8#Use_Wikidata_as_the_source_for_the_external_link

]]

local function external_link_id (options)
	local url_string = options.id;
	local ext_link;
	local this_wiki_code = cfg.this_wiki_code;									-- Wikipedia subdomain; 'en' for en.wikipedia.org
	local wd_article;															-- article title from Wikidata
	
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end

	if options.auto_link and is_set (options.access) then
		auto_link_urls[options.auto_link] = table.concat ({options.prefix, url_string, options.suffix});
	end

	ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or &quot;&quot;, mw.text.nowiki(options.id));
	if is_set(options.access) then
		ext_link = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[options.access].class, cfg.presentation[options.access].title, ext_link});	-- add the free-to-read / paywall lock
	end

	return table.concat	({
		make_wikilink (link_label_make (options), options.label),				-- redirect, Wikidata link, or locally specified link (in that order)
		options.separator or '&amp;nbsp;',
		ext_link
		});
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki-style internal link

]]

local function internal_link_id(options)
	local id = mw.ustring.gsub (options.id, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9

	return table.concat (
		{
		make_wikilink (link_label_make (options), options.label),				-- wiki-link the identifier label
		options.separator or '&amp;nbsp;',											-- add the separator
		make_wikilink (
			table.concat (
				{
				options.prefix,
				id,																-- translated to Western digits
				options.suffix or ''
				}),
			substitute (cfg.presentation['bdi'], {'', mw.text.nowiki (options.id)})	-- bdi tags to prevent Latin script identifiers from being reversed at RTL language wikis
			);																	-- nowiki because MediaWiki still has magic links for ISBN and the like; TODO: is it really required?
		});
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |pmc-embargo-date= against today's date.  If embargo date is
in the future, returns the content of |pmc-embargo-date=; otherwise, returns an empty string because the embargo has expired or because
|pmc-embargo-date= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, todays_date;
		good1, embargo_date = pcall (lang.formatDate, lang, 'U', embargo);
		todays_date = lang:formatDate ('U');
	
		if good1 then															-- if embargo date is a good date
			if tonumber (embargo_date) &gt;= tonumber (todays_date) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				set_message ('maint_pmc_embargo');								-- embargo has expired; add main cat
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |pmc-embargo-date= not set return empty string
end


--[=[-------------------------&lt; I S _ V A L I D _ B I O R X I V _ D A T E &gt;------------------------------------

returns true if:
	2019-12-11T00:00Z &lt;= biorxiv_date &lt; today + 2 days
	
The dated form of biorxiv identifier has a start date of 2019-12-11.  The Unix timestamp for that date is {{#time:U|2019-12-11}} = 1576022400

biorxiv_date is the date provided in those |biorxiv= parameter values that are dated at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-English date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate().  To get around that
call this function with YYYY-MM-DD format dates.

]=]

local function is_valid_biorxiv_date (biorxiv_date)
	local good1, good2;
	local biorxiv_ts, tomorrow_ts;												-- to hold Unix timestamps representing the dates
	local lang_object = mw.getContentLanguage();

	good1, biorxiv_ts = pcall (lang_object.formatDate, lang_object, 'U', biorxiv_date );		-- convert biorxiv_date value to Unix timestamp 
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which tonumber() may not understand
		biorxiv_ts = tonumber (biorxiv_ts) or lang_object:parseFormattedNumber (biorxiv_ts);	-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to Unix timestamp
	end

	return ((1576022400 &lt;= biorxiv_ts) and (biorxiv_ts &lt; tomorrow_ts))			-- 2012-12-11T00:00Z &lt;= biorxiv_date &lt; tomorrow's date
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all ISBN/ISSN digits including the check digit.
ISBN-13 is checked in isbn().

If the number is valid the result will be 0. Before calling this function, ISBN/ISSN must be checked for length
and stripped of dashes, spaces and other non-ISxN characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39, 'X' → 0x58
	len = len + 1;																-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do											-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then											-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );										-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;														-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N _ 1 3 &gt;-----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 ISBN/ISMN digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, ISBN-13/ISMN must be checked for length
and stripped of dashes, spaces and other non-ISxN-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when ISBN-13/ISMN is correct
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

LCCN normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized LCCN for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);												-- 1. strip whitespace

	if nil ~= string.find (lccn, '/') then
		lccn = lccn:match (&quot;(.-)/&quot;);											-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);									-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then														-- if there was a hyphen
		suffix = string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;				-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn = prefix..suffix;													-- reassemble the LCCN
	end
	
	return lccn;
	end


--============================&lt;&lt; I D E N T I F I E R   F U N C T I O N S &gt;&gt;====================================

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9107 and 0703, is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation; not the same as |class= parameter which is not supported in this form
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = false;														-- assume no error message
	local text;																	-- output text
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9107-0703 format with or without version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 with or without version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then									-- when year is 07, is month invalid (before April)?
				err_cat = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format with or without version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
				err_cat = true;													-- flag for error message
		end

	else
		err_cat = true;															-- not a recognized format; flag for error message
	end

	err_cat = err_cat and table.concat ({' ', set_message ('err_bad_arxiv')}) or '';	-- set error message if flag is true
	
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access}) .. err_cat;

	if is_set (class) then
		if id:match ('^%d+') then
			text = table.concat ({text, ' [[//arxiv.org/archive/', class, ' ', class, ']]'});	-- external link within square brackets, not wikilink
		else
			text = table.concat ({text, ' ', set_message ('err_class_ignored')});		
		end
	end

	return text;	
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode ID.

Format for bibcodes is specified here: http://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		9–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (id, access)
	local handler = cfg.id_handlers['BIBCODE'];
	local err_type;
	local year;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode,
		access = access});
	
	if 19 ~= id:len() then
		err_type = cfg.err_msg_supl.length;
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%w&amp;%.][%w&amp;%.][%w&amp;%.][%w.]+[%a%.]$&quot;);
		if not year then														-- if nil then no pattern match
			err_type = cfg.err_msg_supl.value;									-- so value error
		else
			local next_year = tonumber(os.date ('%Y')) + 1;						-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = cfg.err_msg_supl.year;								-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = cfg.err_msg_supl.journal;							-- journal abbreviation must not have '&amp;.' (if it does it's missing a letter)
			end
		end
	end

	if is_set (err_type) then													-- if there was an error detected
		text = text .. ' ' .. set_message( 'err_bad_bibcode', {err_type});
	end
	return text;
end


--[[--------------------------&lt; B I O R X I V &gt;-----------------------------------------------------------------

Format bioRxiv ID and do simple error checking.  Before 2019-12-11, biorXiv IDs were 10.1101/ followed by exactly
6 digits.  After 2019-12-11, biorXiv IDs retained the six-digit identifier but prefixed that with a yyyy.mm.dd. 
date and suffixed with an optional version identifier.

The bioRxiv ID is the string of characters:
	https://doi.org/10.1101/078733 -&gt; 10.1101/078733
or a date followed by a six-digit number followed by an optional version indicator 'v' and one or more digits:
	https://www.biorxiv.org/content/10.1101/2019.12.11.123456v2 -&gt; 10.1101/2019.12.11.123456v2
	
see https://www.biorxiv.org/about-biorxiv

]]

local function biorxiv(id)
	local handler = cfg.id_handlers['BIORXIV'];
	local err_cat = true;														-- flag; assume that there will be an error
	
	local patterns = {
		'^10.1101/%d%d%d%d%d%d$',												-- simple 6-digit identifier (before 2019-12-11)
		'^10.1101/(20[1-9]%d)%.([01]%d)%.([0-3]%d)%.%d%d%d%d%d%dv%d+$',			-- y.m.d. date + 6-digit identifier + version (after 2019-12-11)
		'^10.1101/(20[1-9]%d)%.([01]%d)%.([0-3]%d)%.%d%d%d%d%d%d$',				-- y.m.d. date + 6-digit identifier (after 2019-12-11)
		}
	
	for _, pattern in ipairs (patterns) do										-- spin through the patterns looking for a match
		if id:match (pattern) then
			local y, m, d = id:match (pattern);									-- found a match, attempt to get year, month and date from the identifier

			if m then															-- m is nil when id is the six-digit form
				if not is_valid_biorxiv_date (y .. '-' .. m .. '-' .. d) then	-- validate the encoded date; TODO: don't ignore leap-year and actual month lengths ({{#time:}} is a poor date validator)
					break;														-- date fail; break out early so we don't unset the error message
				end
			end
			err_cat = nil;														-- we found a match so unset the error message
			break;																-- and done
		end
	end																			-- err_cat remains set here when no match

	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator,
			encode = handler.encode, access = handler.access}) .. (err_cat and (' ' .. set_message( 'err_bad_biorxiv')) or '');
end


--[[--------------------------&lt; C I T E S E E R X &gt;------------------------------------------------------------

CiteSeerX use their own notion of &quot;doi&quot; (not to be confused with the identifiers resolved via doi.org).

The description of the structure of this identifier can be found at Help_talk:Citation_Style_1/Archive_26#CiteSeerX_id_structure
]]

local function citeseerx (id)
	local handler = cfg.id_handlers['CITESEERX'];
	local matched;
	
	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode,
		access = handler.access});
	
	matched = id:match (&quot;^10%.1%.1%.[1-9]%d?%d?%d?%.[1-9]%d?%d?%d?$&quot;);
	if not matched then
		text = text .. ' ' .. set_message( 'err_bad_citeseerx' );
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the DOI name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in DOI names.

]]

local function doi (id, inactive, access, ignore_invalid)
	local err_cat;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set (inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';					-- try to get the year portion from the inactive date
		local inactive_month, good;

		if is_set (inactive_year) then
			if 4 &lt; inactive:len() then											-- inactive date has more than just a year (could be anything)
				local lang_obj = mw.getContentLanguage();						-- get a language object for this wiki
				good, inactive_month = pcall (lang_obj.formatDate, lang_obj, 'F', inactive);	-- try to get the month name from the inactive date
				if not good then
					inactive_month = nil;										-- something went wrong so make sure this is unset
				end
			end
		else
			inactive_year = nil;												-- |doi-broken-date= has something but it isn't a date
		end
		
		if is_set(inactive_year) and is_set (inactive_month) then
			set_message ('maint_doi_inactive_dated', {inactive_year, inactive_month, ' '});
		elseif is_set(inactive_year) then
			set_message ('maint_doi_inactive_dated', {inactive_year, '', ''});
		else
			set_message ('maint_doi_inactive');
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. ' ' .. inactive .. ')';
	end

	local registrant = id:match ('^10%.([^/]+)/[^%s–]-[^%.,]$');				-- registrant set when DOI has the proper basic form
	
	local registrant_err_patterns = {											-- these patterns are for code ranges that are not supported 
		'^[^1-3]%d%d%d%d%.%d%d*$',												-- 5 digits with subcode (0xxxx, 40000+); accepts: 10000–39999
		'^[^1-4]%d%d%d%d$',														-- 5 digits without subcode (0xxxx, 40000+); accepts: 10000–49999
		'^[^1-9]%d%d%d%.%d%d*$',												-- 4 digits with subcode (0xxx); accepts: 1000–9999
		'^[^1-9]%d%d%d$',														-- 4 digits without subcode (0xxx); accepts: 1000–9999
		'^%d%d%d%d%d%d+',														-- 6 or more digits
		'^%d%d?%d?$',															-- less than 4 digits without subcode (with subcode is legitimate)
		'^5555$',																-- test registrant will never resolve
		'%s',																	-- any space character in registrant
		}

	if not ignore_invalid then
		if registrant then -- when DOI has proper form
			for i, pattern in ipairs (registrant_err_patterns) do -- spin through error patterns
				if registrant:match (pattern) then -- to validate registrant codes
					err_cat = ' ' .. set_message ('err_bad_doi'); -- when found, mark this DOI as bad
					break; -- and done
				end
			end
		else
			err_cat = ' ' .. set_message ('err_bad_doi'); -- invalid directory or malformed
		end
	else
		set_message ('maint_doi_ignore');
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access,
		auto_link = not (err_cat or is_set (inactive) or ignore_invalid) and 'doi' or nil -- do not auto-link when |doi-broken-date= has a value or when there is a DOI error or (to play it safe, after all, auto-linking is not essential) when invalid DOIs are ignored
		}) .. (inactive or '');

	return text .. (err_cat and err_cat or ''); -- parentheses required
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

Query string parameters are named here: http://www.handle.net/proxy_servlet.html.  query strings are not displayed
but since '?' is an allowed character in an HDL, '?' followed by one of the query parameters is the only way we
have to detect the query string so that it isn't URL-encoded with the rest of the identifier.

]]

local function hdl(id, access)
	local handler = cfg.id_handlers['HDL'];
	local query_params = {														-- list of known query parameters from http://www.handle.net/proxy_servlet.html
		'noredirect',
		'ignore_aliases',
		'auth',
		'cert',
		'index',
		'type',
		'urlappend',
		'locatt',
		'action',
		}
	
	local hdl, suffix, param = id:match ('(.-)(%?(%a+).+)$');					-- look for query string
	local found;

	if hdl then																	-- when there are query strings, this is the handle identifier portion
		for _, q in ipairs (query_params) do									-- spin through the list of query parameters
			if param:match ('^' .. q) then										-- if the query string begins with one of the parameters
				found = true;													-- announce a find
				break;															-- and stop looking
			end
		end
	end

	if found then
		id = hdl;																-- found so replace id with the handle portion; this will be URL-encoded, suffix will not
	else
		suffix = '';															-- make sure suffix is empty string for concatenation else
	end

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, suffix = suffix, separator = handler.separator, encode = handler.encode, access = access})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- HDL must contain a forward slash, must not contain spaces, endashes, and must not end with period or comma
		text = text .. ' ' .. set_message( 'err_bad_hdl' );
	end
	return text;
end


--[[--------------------------&lt; I S B N &gt;----------------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function isbn (isbn_str, ignore_invalid)
	local handler = cfg.id_handlers['ISBN'];
	local function return_result (check, err_type)								-- local function to handle the various returns
		local ISBN = internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,
						prefix = handler.prefix, id = isbn_str, separator = handler.separator});
		if ignore_invalid then													-- if ignoring ISBN errors
			set_message ('maint_isbn_ignore');									-- add a maint category even when there is no error
		else																	-- here when not ignoring
			if not check then													-- and there is an error
				return ISBN .. set_message ('err_bad_isbn', {err_type}, false, ' ');	-- display an error message
			end
		end
		return ISBN;
	end

	if nil ~= isbn_str:match ('[^%s-0-9X]') then
		return return_result (false, cfg.err_msg_supl.char);					-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end

	local id = isbn_str:gsub ('[%s-]', '');										-- remove hyphens and whitespace

	local len = id:len();
 
	if len ~= 10 and len ~= 13 then
		return return_result (false, cfg.err_msg_supl.length);					-- fail if incorrect length
	end

	if len == 10 then
		if id:match ('^%d*X?$') == nil then										-- fail if isbn_str has 'X' anywhere but last position
			return return_result (false, cfg.err_msg_supl.form);									
		end
		return return_result (is_valid_isxn(id, 10), cfg.err_msg_supl.check);
	else
		if id:match ('^%d+$') == nil then
			return return_result (false, cfg.err_msg_supl.char);				-- fail if ISBN-13 is not all digits
		end
		if id:match ('^97[89]%d*$') == nil then
			return return_result (false, cfg.err_msg_supl.prefix);				-- fail when ISBN-13 does not begin with 978 or 979
		end
		if id:match ('^9790') then
			return return_result (false, cfg.err_msg_supl.group);				-- group identifier '0' is reserved to ISMN
		end
		return return_result (is_valid_isxn_13 (id), cfg.err_msg_supl.check);
	end
end


--[[--------------------------&lt; A S I N &gt;----------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: ASIN must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, ASINs must be 10-digit
ISBN. If 10-digit ISBN, add a maintenance category so a bot or AWB script can replace |asin= with |isbn=.
Error message if not 10 characters, if not ISBN-10, if mixed and first character is a digit.

|asin=630....... is (apparently) not a legitimate ISBN though it checksums as one; these do not cause this
function to emit the maint_asin message

This function is positioned here because it calls isbn()

]]

local function asin (id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat = ' ' .. set_message ('err_bad_asin');							-- ASIN is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then							-- if 10-digit numeric (or 9 digits with terminal X)
			if isbn (id) then													-- see if ASIN value is or validates as ISBN-10
				if not id:find ('^630') then									-- 630xxxxxxx is (apparently) not a valid isbn prefix but is used by amazon as a numeric identifier
					set_message ('maint_asin');									-- begins with something other than 630 so possibly an isbn
				end
			elseif not is_set (err_cat) then
				err_cat = ' ' .. set_message ('err_bad_asin');					-- ASIN is not ISBN-10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat = ' ' .. set_message ('err_bad_asin');						-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then									-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then							-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix .. domain .. &quot;/dp/&quot;,
		id = id, encode = handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to ISBN-13, ISMN is 13 digits beginning 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;
	local id_copy;

	id_copy = id;																-- save a copy because this testing is destructive
	id = id:gsub ('[%s-]', '');													-- remove hyphens and white space

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ISMN must be 13 digits and begin with 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ISMN
	end

	--	text = internal_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,		-- use this (or external version) when there is some place to link to
	--		prefix = handler.prefix, id = id_copy, separator = handler.separator, encode = handler.encode})

	text = table.concat (														-- because no place to link to yet
		{
		make_wikilink (link_label_make (handler), handler.label),
		handler.separator,
		id_copy
		});

	if false == valid_ismn then
		text = text .. ' ' .. set_message( 'err_bad_ismn' )						-- add an error message if the ISMN is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an ISSN.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]	-- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the ISSN midpoint.  It also validates the ISSN for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check ISSN error message.  The
ISSN is always displayed with a hyphen, even if the ISSN was given as a single group of 8 digits.

]]

local function issn (id, e, ignore_invalid)
	local issn_copy = id;														-- save a copy of unadulterated ISSN; use this version for display if ISSN does not validate
	local handler;
	local text;
	local valid_issn = true;
	
	handler = cfg.id_handlers[e and 'EISSN' or 'ISSN'];

	id = id:gsub ('[%s-]', '');													-- remove hyphens and whitespace

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then						-- validate the ISSN: 8 digits long, containing only 0-9 or X in the last position
		valid_issn = false;														-- wrong length or improper character
	else
		valid_issn = is_valid_isxn(id, 8);										-- validate ISSN
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );				-- if valid, display correctly formatted version
	else
		id = issn_copy;															-- if not valid, show the invalid ISSN with error message
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode})

	if ignore_invalid then
		set_message ('maint_issn_ignore');
	else
		if false == valid_issn then
			text = text .. ' ' .. set_message ('err_bad_issn', e and 'e' or '');	-- add an error message if the ISSN is invalid
		end 
	end
	
	return text
end


--[[--------------------------&lt; J F M &gt;-----------------------------------------------------------------------

A numerical identifier in the form nn.nnnn.nn

]]

local function jfm (id)
	local handler = cfg.id_handlers['JFM'];
	local id_num;
	local err_cat = '';
	
	id_num = id:match ('^[Jj][Ff][Mm](.*)$');									-- identifier with jfm prefix; extract identifier

	if is_set (id_num) then
		set_message ('maint_jfm_format');
	else																		-- plain number without mr prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num and id_num:match('^%d%d%.%d%d%d%d%.%d%d$') then
		id = id_num;															-- jfm matches pattern
	else
		err_cat = ' ' .. set_message( 'err_bad_jfm' );							-- set an error message
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode}) .. err_cat;
end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lowercase alpha
length = 10 then lccn[1] and lccn[2] are both lowercase alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lowercase alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lowercase alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat = '';															-- presume that LCCN is valid
	local id = lccn;															-- local copy of the LCCN

	id = normalize_lccn (id);													-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();														-- get the length of the LCCN

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_message ('err_bad_lccn');						-- set an error message
		end
	elseif 9 == len then														-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then							-- does it match our pattern?
			err_cat = ' ' .. set_message ('err_bad_lccn');						-- set an error message
		end
	elseif 10 == len then														-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then					-- ... see if it matches our pattern
				err_cat = ' ' .. set_message ('err_bad_lccn');					-- no match, set an error message
			end
		end
	elseif 11 == len then														-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_message ('err_bad_lccn');						-- no match, set an error message
		end
	elseif 12 == len then														-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then						-- see if it matches our pattern
			err_cat = ' ' .. set_message ('err_bad_lccn');						-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_message ('err_bad_lccn');							-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_message ('err_bad_lccn');							-- lccn contains a space, set an error message
	end

	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = lccn, separator = handler.separator, encode = handler.encode}) .. err_cat;
end


--[[--------------------------&lt; M R &gt;--------------------------------------------------------------------------

A seven digit number; if not seven digits, zero-fill leading digits to make seven digits.

]]

local function mr (id)
	local handler = cfg.id_handlers['MR'];
	local id_num;
	local id_len;
	local err_cat = '';
	
	id_num = id:match ('^[Mm][Rr](%d+)$');										-- identifier with mr prefix

	if is_set (id_num) then
		set_message ('maint_mr_format');										-- add maint cat
	else																		-- plain number without mr prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	id_len = id_num and id_num:len() or 0;
	if (7 &gt;= id_len) and (0 ~= id_len) then
		id = string.rep ('0', 7-id_len ) .. id_num;								-- zero-fill leading digits
	else
		err_cat = ' ' .. set_message ('err_bad_mr');							-- set an error message
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode}) .. err_cat;
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an OCLC ID.  https://www.oclc.org/batchload/controlnumber.en.html {{dead link}}
archived at: https://web.archive.org/web/20161228233804/https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (id)
	local handler = cfg.id_handlers['OCLC'];
	local number;
	local err_msg = '';															-- empty string for concatenation
	
	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- constrain to 1 to 9 digits; change this when OCLC issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if 10 &lt; number:len() then
			number = nil;														-- constrain to 1 to 10 digits; change this when OCLC issues 11-digit numbers
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		err_msg = ' ' .. set_message ('err_bad_oclc')							-- add an error message if the id is malformed
	end
	
	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode}) .. err_msg;

	return text;
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id, access)
	local handler = cfg.id_handlers['OL'];
	local ident, code = id:gsub('^OL', ''):match(&quot;^(%d+([AMW]))$&quot;);				-- strip optional OL prefix followed immediately by digits followed by 'A', 'M', or 'W';
	local error_msg = '';
	local prefix = {															-- these are appended to the handler.prefix according to code
		['A']='authors/OL',
		['M']='books/OL',
		['W']='works/OL',
		['X']='OL'																-- not a code; spoof when 'code' in id is invalid
		};

	if not ident then
		code = 'X';																-- no code or id completely invalid
		ident = id;																-- copy id to ident so that we display the flawed identifier
		error_msg = ' ' .. set_message ('err_bad_ol');
	end

	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix .. prefix[code],
		id = ident, separator = handler.separator, encode = handler.encode,
		access = access}) .. error_msg;
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc (id, embargo)
	local handler = cfg.id_handlers['PMC'];
	local err_cat;
	local id_num;
	local text;

	id_num = id:match ('^[Pp][Mm][Cc](%d+)$');									-- identifier with PMC prefix

	if is_set (id_num) then
		set_message ('maint_pmc_format');
	else																		-- plain number without PMC prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_message ('err_bad_pmc');						-- set an error message
		else
			id = tostring (id_num);												-- make sure id is a string
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_message ('err_bad_pmc');							-- set an error message
	end
	
	if is_set (embargo) and is_set (is_embargoed (embargo)) then				-- is PMC is still embargoed?
		text = table.concat (													-- still embargoed so no external link
			{
			make_wikilink (link_label_make (handler), handler.label),
			handler.separator,
			id,
			(err_cat and err_cat or '')											-- parens required
			});
	else
		text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,	-- no embargo date or embargo has expired, ok to link to article
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access,
			auto_link = not err_cat and 'pmc' or nil								-- do not auto-link when PMC has error
			}) .. (err_cat and err_cat or '');									-- parentheses required
	end
	return text;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local handler = cfg.id_handlers['PMID'];
	local err_cat = '';															-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then													-- if PMID has anything but digits
		err_cat = ' ' .. set_message ('err_bad_pmid');							-- set an error message
	else																		-- PMID is only digits
		local id_num = tonumber(id);											-- convert id to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_message ('err_bad_pmid');						-- set an error message
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode}) .. err_cat;
end


--[[--------------------------&lt; S 2 C I D &gt;--------------------------------------------------------------------

Format an S2CID, do simple error checking

S2CIDs are sequential numbers beginning at 1 and counting up.  This code checks the S2CID to see that it is only
digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically
as more S2CIDs are issued.

]]

local function s2cid (id, access)
	local handler = cfg.id_handlers['S2CID'];
	local err_cat = '';															-- presume that S2CID is valid
	local id_num;
	local text;
	
	id_num = id:match ('^[1-9]%d*$');											-- id must be all digits; must not begin with 0; no open access flag

 	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if handler.id_limit &lt; id_num then										-- if S2CID is outside test limit boundaries
			err_cat = ' ' .. set_message ('bad_s2cid_err');						-- set an error message
		end

	else																		-- when id format incorrect
		err_cat = ' ' .. set_message ('bad_s2cid_err');							-- set an error message
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id:gsub ('%.%a%a', ''), separator = handler.separator, encode = handler.encode, access = access}) .. err_cat;

	return text;
end


--[[--------------------------&lt; S B N &gt;------------------------------------------------------------------------

9-digit form of ISBN-10; uses same check-digit validation when SBN is prefixed with an additional '0' to make 10 digits

]]

local function sbn (id, ignore_invalid)
	local handler = cfg.id_handlers['SBN'];
	local function return_result (check, err_type) -- local function to handle the various returns
		local SBN = internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,
						prefix = handler.prefix, id = id, separator = handler.separator});
		if not ignore_invalid then -- if not ignoring SBN errors
			if not check then
				return SBN .. set_message ('err_bad_sbn', {err_type}, false, ' '); -- display an error message
			end
		else
			set_message ('maint_isbn_ignore');									-- add a maint category even when there is no error (ToDo: Possibly switch to separate message for SBNs only)
		end
		return SBN;
	end

	if id:match ('[^%s-0-9X]') then
		return return_result (false, cfg.err_msg_supl.char);					-- fail if SBN contains anything but digits, hyphens, or the uppercase X
	end

	local ident = id:gsub ('[%s-]', '');											-- remove hyphens and whitespace; they interfere with the rest of the tests

	if  9 ~= ident:len() then
		return return_result (false, cfg.err_msg_supl.length);					-- fail if incorrect length
	end

	if ident:match ('^%d*X?$') == nil then
		return return_result (false, cfg.err_msg_supl.form);					-- fail if SBN has 'X' anywhere but last position
	end

	return return_result (is_valid_isxn ('0' .. ident, 10), cfg.err_msg_supl.check);
end


--[[--------------------------&lt; S S R N &gt;----------------------------------------------------------------------

Format an SSRN, do simple error checking

SSRNs are sequential numbers beginning at 100? and counting up.  This code checks the SSRN to see that it is
only digits and is greater than 99 and less than test_limit; the value in local variable test_limit will need
to be updated periodically as more SSRNs are issued.

]]

local function ssrn (id)
	local handler = cfg.id_handlers['SSRN'];
	local err_cat = '';															-- presume that SSRN is valid
	local id_num;
	local text;
	
	id_num = id:match ('^%d+$');												-- id must be all digits

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 100 &gt; id_num or handler.id_limit &lt; id_num then						-- if SSRN is outside test limit boundaries
			err_cat = ' ' .. set_message ('err_bad_ssrn');						-- set an error message
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_message ('err_bad_ssrn');							-- set an error message
	end
	
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access}) .. err_cat;

	return text;
end


--[[--------------------------&lt; U S E N E T _ I D &gt;------------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function usenet_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$') then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_message ('err_bad_usenet_id')					-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; Z B L &gt;-----------------------------------------------------------------------

A numerical identifier in the form nnnn.nnnnn - leading zeros in the first quartet optional

format described here: http://emis.mi.sanu.ac.rs/ZMATH/zmath/en/help/search/

temporary format is apparently eight digits.  Anything else is an error

]]

local function zbl (id)
	local handler = cfg.id_handlers['ZBL'];
	local err_cat = '';
	
	if id:match('^%d%d%d%d%d%d%d%d$') then										-- is this identifier using temporary format?
		set_message ('maint_zbl');												-- yes, add maint cat
	elseif not id:match('^%d?%d?%d?%d%.%d%d%d%d%d$') then						-- not temporary, is it normal format?
		err_cat = ' ' .. set_message ('err_bad_zbl');							-- no, set an error message
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode}) .. err_cat;
end


--============================&lt;&lt; I N T E R F A C E   F U N C T I O N S &gt;&gt;==========================================

--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};
	local accept;

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do
		v, accept = has_accept_as_written (v);									-- remove and note accept-as-written markup if present

		-- k is uppercase identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v, ['access'] = options.IdAccessLevels[k] }, fallback(k) );

		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, asin( v, options.ASINTLD ) } ); 
		elseif k == 'BIBCODE' then
			table.insert( new_list, {handler.label, bibcode( v, handler.access ) } );
		elseif k == 'BIORXIV' then
			table.insert( new_list, {handler.label, biorxiv( v ) } );
		elseif k == 'CITESEERX' then
			table.insert( new_list, {handler.label, citeseerx( v ) } );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken, handler.access, accept) } );
		elseif k == 'EISSN' then
			table.insert( new_list, {handler.label, issn( v, true, accept) } );	-- true distinguishes EISSN from ISSN
		elseif k == 'HDL' then
			table.insert( new_list, {handler.label, hdl( v, handler.access ) } );
		elseif k == 'ISBN' then
			table.insert( new_list, {handler.label, isbn (v, (accept or options.IgnoreISBN)) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v, false, accept) } );
		elseif k == 'JFM' then
			table.insert( new_list, {handler.label, jfm( v ) } );
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'MR' then
			table.insert( new_list, {handler.label, mr( v ) } );
		elseif k == 'OCLC' then
			table.insert( new_list, {handler.label, oclc( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v, handler.access ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'S2CID' then
			table.insert( new_list, {handler.label, s2cid( v, handler.access ) } );
		elseif k == 'SBN' then
			table.insert( new_list, {handler.label, sbn (v, accept) } );
		elseif k == 'SSRN' then
			table.insert( new_list, {handler.label, ssrn( v ) } );
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, usenet_id( v ) } );
		elseif k == 'ZBL' then
			table.insert( new_list, {handler.label, zbl( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1]:lower() &lt; b[1]:lower();
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message if more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uppercase identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; E X T R A C T _ I D _ A C C E S S _ L E V E L S &gt;--------------------------------------

Fetches custom id access levels from arguments using configuration settings.
Parameters which have a predefined access level (e.g. arxiv) do not use this
function as they are directly rendered as free without using an additional parameter.

access-level values must match the case used in cfg.keywords_lists['id-access'] (lowercase unless there is some special reason for something else)

]]

local function extract_id_access_levels( args, id_list )
	local id_accesses_list = {};
	for k, v in pairs( cfg.id_handlers ) do
		local access_param = v.custom_access;									-- name of identifier's access-level parameter
		if is_set(access_param) then
			local access_level = args[access_param];							-- get the assigned value if there is one
			if is_set (access_level) then
				if not in_array (access_level, cfg.keywords_lists['id-access']) then	-- exact match required
					table.insert( z.message_tail, { set_message( 'invalid_param_val', {access_param, access_level}, true ) } );	
					access_level = nil;											-- invalid so unset
				end
				if not is_set(id_list[k]) then									-- identifier access-level must have a matching identifier
					table.insert( z.message_tail, { set_message( 'err_param_access_requires_param', {k:lower()}, true ) } );	-- parameter name is uppercase in cfg.id_handlers (k); lowercase for error message
				end
				id_accesses_list[k] = cfg.keywords_xlate[access_level];			-- get translated keyword
			end
		end
	end
	return id_accesses_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	has_accept_as_written = utilities_page_ptr.has_accept_as_written;			-- import functions from select Module:Citation/CS1/Utilities module
	is_set = utilities_page_ptr.is_set;								
	in_array = utilities_page_ptr.in_array;
	set_message = utilities_page_ptr.set_message;
	select_one = utilities_page_ptr.select_one;
	substitute = utilities_page_ptr.substitute;
	make_wikilink = utilities_page_ptr.make_wikilink;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	auto_link_urls = auto_link_urls,											-- table of identifier URLs to be used when auto-linking |title=
	
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	extract_id_access_levels = extract_id_access_levels,
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>3f3nkfekbg2minwt6n6biny31ech649</sha1>
    </revision>
    <revision>
      <id>4917</id>
      <parentid>4916</parentid>
      <timestamp>2020-10-13T11:15:27Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4917</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="63553" sha1="eg0zw6ttx0ztqphkrm52zj5q2aqmp0n" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local has_accept_as_written, is_set, in_array, set_message, select_one,			-- functions in Module:Citation/CS1/Utilities
		substitute, make_wikilink;

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

declare variables here that have page-wide scope that are not brought in from other modules; that are created here and used here

]]

local auto_link_urls = {};														-- holds identifier URLs for those identifiers that can auto-link |title=


--============================&lt;&lt; H E L P E R   F U N C T I O N S &gt;&gt;============================================

--[[--------------------------&lt; W I K I D A T A _ A R T I C L E _ N A M E _ G E T &gt;----------------------------

as an aid to internationalizing identifier-label wikilinks, gets identifier article names from Wikidata.

returns :&lt;lang code&gt;:&lt;article title&gt; when &lt;q&gt; has an &lt;article title&gt; for &lt;lang code&gt;; nil else

for identifiers that do not have q, returns nil

for wikis that do not have mw.wikibase installed, returns nil

]]

local function wikidata_article_name_get (q)
	if not is_set (q) or (q and not mw.wikibase) then							-- when no q number or when a q number but mw.wikibase not installed on this wiki
		return nil;																-- abandon
	end

	local wd_article;
	local this_wiki_code = cfg.this_wiki_code;									-- Wikipedia subdomain; 'en' for en.wikipedia.org

	wd_article = mw.wikibase.getSitelink (q, this_wiki_code .. 'wiki');			-- fetch article title from WD; nil when no title available at this wiki

	if wd_article then
		wd_article = table.concat ({':', this_wiki_code, ':', wd_article});		-- interwiki-style link without brackets if taken from WD; leading colon required
	end

	return wd_article;															-- article title from WD; nil else
end


--[[--------------------------&lt; L I N K _ L A B E L _ M A K E &gt;------------------------------------------------

common function to create identifier link label from handler table or from Wikidata

returns the first available of
	1. redirect from local wiki's handler table (if enabled)
	2. Wikidata (if there is a Wikidata entry for this identifier in the local wiki's language)
	3. label specified in the local wiki's handler table
	
]]

local function link_label_make (handler)
	local wd_article;
	
	if not (cfg.use_identifier_redirects and is_set (handler.redirect)) then	-- redirect has priority so if enabled and available don't fetch from Wikidata because expensive
		wd_article = wikidata_article_name_get (handler.q);						-- if Wikidata has an article title for this wiki, get it;
	end
	
	return (cfg.use_identifier_redirects and is_set (handler.redirect) and handler.redirect) or wd_article or handler.link;
end


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki-style external link

NB. Wikidata P1630 has a formatter URL with $1 placeholder for the ID which could be worked into our prefix/id/suffix
string, either overriding local definitions (auto-update) or as fallback for identifiers without local definitions. 
But is expensive and could be risky if WD gets vandalized. 

See Template_talk:Authority_control/Archive_8#Use_Wikidata_as_the_source_for_the_external_link

]]

local function external_link_id (options)
	local url_string = options.id;
	local ext_link;
	local this_wiki_code = cfg.this_wiki_code;									-- Wikipedia subdomain; 'en' for en.wikipedia.org
	local wd_article;															-- article title from Wikidata
	
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode( url_string );
	end

	if options.auto_link and is_set (options.access) then
		auto_link_urls[options.auto_link] = table.concat ({options.prefix, url_string, options.suffix});
	end

	ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or &quot;&quot;, mw.text.nowiki(options.id));
	if is_set(options.access) then
		ext_link = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[options.access].class, cfg.presentation[options.access].title, ext_link});	-- add the free-to-read / paywall lock
	end

	return table.concat	({
		make_wikilink (link_label_make (options), options.label),				-- redirect, Wikidata link, or locally specified link (in that order)
		options.separator or '&amp;nbsp;',
		ext_link
		});
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki-style internal link

]]

local function internal_link_id(options)
	local id = mw.ustring.gsub (options.id, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9

	return table.concat (
		{
		make_wikilink (link_label_make (options), options.label),				-- wiki-link the identifier label
		options.separator or '&amp;nbsp;',											-- add the separator
		make_wikilink (
			table.concat (
				{
				options.prefix,
				id,																-- translated to Western digits
				options.suffix or ''
				}),
			substitute (cfg.presentation['bdi'], {'', mw.text.nowiki (options.id)})	-- bdi tags to prevent Latin script identifiers from being reversed at RTL language wikis
			);																	-- nowiki because MediaWiki still has magic links for ISBN and the like; TODO: is it really required?
		});
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |pmc-embargo-date= against today's date.  If embargo date is
in the future, returns the content of |pmc-embargo-date=; otherwise, returns an empty string because the embargo has expired or because
|pmc-embargo-date= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, todays_date;
		good1, embargo_date = pcall (lang.formatDate, lang, 'U', embargo);
		todays_date = lang:formatDate ('U');
	
		if good1 then															-- if embargo date is a good date
			if tonumber (embargo_date) &gt;= tonumber (todays_date) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				set_message ('maint_pmc_embargo');								-- embargo has expired; add main cat
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |pmc-embargo-date= not set return empty string
end


--[=[-------------------------&lt; I S _ V A L I D _ B I O R X I V _ D A T E &gt;------------------------------------

returns true if:
	2019-12-11T00:00Z &lt;= biorxiv_date &lt; today + 2 days
	
The dated form of biorxiv identifier has a start date of 2019-12-11.  The Unix timestamp for that date is {{#time:U|2019-12-11}} = 1576022400

biorxiv_date is the date provided in those |biorxiv= parameter values that are dated at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-English date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate().  To get around that
call this function with YYYY-MM-DD format dates.

]=]

local function is_valid_biorxiv_date (biorxiv_date)
	local good1, good2;
	local biorxiv_ts, tomorrow_ts;												-- to hold Unix timestamps representing the dates
	local lang_object = mw.getContentLanguage();

	good1, biorxiv_ts = pcall (lang_object.formatDate, lang_object, 'U', biorxiv_date );		-- convert biorxiv_date value to Unix timestamp 
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which tonumber() may not understand
		biorxiv_ts = tonumber (biorxiv_ts) or lang_object:parseFormattedNumber (biorxiv_ts);	-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to Unix timestamp
	end

	return ((1576022400 &lt;= biorxiv_ts) and (biorxiv_ts &lt; tomorrow_ts))			-- 2012-12-11T00:00Z &lt;= biorxiv_date &lt; tomorrow's date
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all ISBN/ISSN digits including the check digit.
ISBN-13 is checked in isbn().

If the number is valid the result will be 0. Before calling this function, ISBN/ISSN must be checked for length
and stripped of dashes, spaces and other non-ISxN characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39, 'X' → 0x58
	len = len + 1;																-- adjust to be a loop counter
	for i, v in ipairs( isxn_str ) do											-- loop through all of the bytes and calculate the checksum
		if v == string.byte( &quot;X&quot; ) then											-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10*( len - i );										-- it represents 10 decimal
		else
			temp = temp + tonumber( string.char(v) )*(len-i);
		end
	end
	return temp % 11 == 0;														-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N _ 1 3 &gt;-----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 ISBN/ISMN digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, ISBN-13/ISMN must be checked for length
and stripped of dashes, spaces and other non-ISxN-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39
	for i, v in ipairs( isxn_str ) do
		temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when ISBN-13/ISMN is correct
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

LCCN normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized LCCN for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);												-- 1. strip whitespace

	if nil ~= string.find (lccn, '/') then
		lccn = lccn:match (&quot;(.-)/&quot;);											-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);									-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then														-- if there was a hyphen
		suffix = string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;				-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn = prefix..suffix;													-- reassemble the LCCN
	end
	
	return lccn;
	end


--============================&lt;&lt; I D E N T I F I E R   F U N C T I O N S &gt;&gt;====================================

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9107 and 0703, is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation; not the same as |class= parameter which is not supported in this form
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (id, class)
	local handler = cfg.id_handlers['ARXIV'];
	local year, month, version;
	local err_cat = false;														-- assume no error message
	local text;																	-- output text
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9107-0703 format with or without version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 with or without version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then									-- when year is 07, is month invalid (before April)?
				err_cat = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format with or without version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber(year);
		month = tonumber(month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
				err_cat = true;													-- flag for error message
		end

	else
		err_cat = true;															-- not a recognized format; flag for error message
	end

	err_cat = err_cat and table.concat ({' ', set_message ('err_bad_arxiv')}) or '';	-- set error message if flag is true
	
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access}) .. err_cat;

	if is_set (class) then
		if id:match ('^%d+') then
			text = table.concat ({text, ' [[//arxiv.org/archive/', class, ' ', class, ']]'});	-- external link within square brackets, not wikilink
		else
			text = table.concat ({text, ' ', set_message ('err_class_ignored')});		
		end
	end

	return text;	
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode ID.

Format for bibcodes is specified here: http://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		9–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (id, access)
	local handler = cfg.id_handlers['BIBCODE'];
	local err_type;
	local year;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode,
		access = access});
	
	if 19 ~= id:len() then
		err_type = cfg.err_msg_supl.length;
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%w&amp;%.][%w&amp;%.][%w&amp;%.][%w.]+[%a%.]$&quot;);
		if not year then														-- if nil then no pattern match
			err_type = cfg.err_msg_supl.value;									-- so value error
		else
			local next_year = tonumber(os.date ('%Y')) + 1;						-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = cfg.err_msg_supl.year;								-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = cfg.err_msg_supl.journal;							-- journal abbreviation must not have '&amp;.' (if it does it's missing a letter)
			end
		end
	end

	if is_set (err_type) then													-- if there was an error detected
		text = text .. ' ' .. set_message( 'err_bad_bibcode', {err_type});
	end
	return text;
end


--[[--------------------------&lt; B I O R X I V &gt;-----------------------------------------------------------------

Format bioRxiv ID and do simple error checking.  Before 2019-12-11, biorXiv IDs were 10.1101/ followed by exactly
6 digits.  After 2019-12-11, biorXiv IDs retained the six-digit identifier but prefixed that with a yyyy.mm.dd. 
date and suffixed with an optional version identifier.

The bioRxiv ID is the string of characters:
	https://doi.org/10.1101/078733 -&gt; 10.1101/078733
or a date followed by a six-digit number followed by an optional version indicator 'v' and one or more digits:
	https://www.biorxiv.org/content/10.1101/2019.12.11.123456v2 -&gt; 10.1101/2019.12.11.123456v2
	
see https://www.biorxiv.org/about-biorxiv

]]

local function biorxiv(id)
	local handler = cfg.id_handlers['BIORXIV'];
	local err_cat = true;														-- flag; assume that there will be an error
	
	local patterns = {
		'^10.1101/%d%d%d%d%d%d$',												-- simple 6-digit identifier (before 2019-12-11)
		'^10.1101/(20[1-9]%d)%.([01]%d)%.([0-3]%d)%.%d%d%d%d%d%dv%d+$',			-- y.m.d. date + 6-digit identifier + version (after 2019-12-11)
		'^10.1101/(20[1-9]%d)%.([01]%d)%.([0-3]%d)%.%d%d%d%d%d%d$',				-- y.m.d. date + 6-digit identifier (after 2019-12-11)
		}
	
	for _, pattern in ipairs (patterns) do										-- spin through the patterns looking for a match
		if id:match (pattern) then
			local y, m, d = id:match (pattern);									-- found a match, attempt to get year, month and date from the identifier

			if m then															-- m is nil when id is the six-digit form
				if not is_valid_biorxiv_date (y .. '-' .. m .. '-' .. d) then	-- validate the encoded date; TODO: don't ignore leap-year and actual month lengths ({{#time:}} is a poor date validator)
					break;														-- date fail; break out early so we don't unset the error message
				end
			end
			err_cat = nil;														-- we found a match so unset the error message
			break;																-- and done
		end
	end																			-- err_cat remains set here when no match

	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator,
			encode = handler.encode, access = handler.access}) .. (err_cat and (' ' .. set_message( 'err_bad_biorxiv')) or '');
end


--[[--------------------------&lt; C I T E S E E R X &gt;------------------------------------------------------------

CiteSeerX use their own notion of &quot;doi&quot; (not to be confused with the identifiers resolved via doi.org).

The description of the structure of this identifier can be found at Help_talk:Citation_Style_1/Archive_26#CiteSeerX_id_structure
]]

local function citeseerx (id)
	local handler = cfg.id_handlers['CITESEERX'];
	local matched;
	
	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode,
		access = handler.access});
	
	matched = id:match (&quot;^10%.1%.1%.[1-9]%d?%d?%d?%.[1-9]%d?%d?%d?$&quot;);
	if not matched then
		text = text .. ' ' .. set_message( 'err_bad_citeseerx' );
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the DOI name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in DOI names.

]]

local function doi (id, inactive, access, ignore_invalid)
	local err_cat;
	local handler = cfg.id_handlers['DOI'];
	
	local text;
	if is_set (inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';					-- try to get the year portion from the inactive date
		local inactive_month, good;

		if is_set (inactive_year) then
			if 4 &lt; inactive:len() then											-- inactive date has more than just a year (could be anything)
				local lang_obj = mw.getContentLanguage();						-- get a language object for this wiki
				good, inactive_month = pcall (lang_obj.formatDate, lang_obj, 'F', inactive);	-- try to get the month name from the inactive date
				if not good then
					inactive_month = nil;										-- something went wrong so make sure this is unset
				end
			end
		else
			inactive_year = nil;												-- |doi-broken-date= has something but it isn't a date
		end
		
		if is_set(inactive_year) and is_set (inactive_month) then
			set_message ('maint_doi_inactive_dated', {inactive_year, inactive_month, ' '});
		elseif is_set(inactive_year) then
			set_message ('maint_doi_inactive_dated', {inactive_year, '', ''});
		else
			set_message ('maint_doi_inactive');
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. ' ' .. inactive .. ')';
	end

	local registrant = id:match ('^10%.([^/]+)/[^%s–]-[^%.,]$');				-- registrant set when DOI has the proper basic form
	
	local registrant_err_patterns = {											-- these patterns are for code ranges that are not supported 
		'^[^1-3]%d%d%d%d%.%d%d*$',												-- 5 digits with subcode (0xxxx, 40000+); accepts: 10000–39999
		'^[^1-4]%d%d%d%d$',														-- 5 digits without subcode (0xxxx, 40000+); accepts: 10000–49999
		'^[^1-9]%d%d%d%.%d%d*$',												-- 4 digits with subcode (0xxx); accepts: 1000–9999
		'^[^1-9]%d%d%d$',														-- 4 digits without subcode (0xxx); accepts: 1000–9999
		'^%d%d%d%d%d%d+',														-- 6 or more digits
		'^%d%d?%d?$',															-- less than 4 digits without subcode (with subcode is legitimate)
		'^5555$',																-- test registrant will never resolve
		'%s',																	-- any space character in registrant
		}

	if not ignore_invalid then
		if registrant then -- when DOI has proper form
			for i, pattern in ipairs (registrant_err_patterns) do -- spin through error patterns
				if registrant:match (pattern) then -- to validate registrant codes
					err_cat = ' ' .. set_message ('err_bad_doi'); -- when found, mark this DOI as bad
					break; -- and done
				end
			end
		else
			err_cat = ' ' .. set_message ('err_bad_doi'); -- invalid directory or malformed
		end
	else
		set_message ('maint_doi_ignore');
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access,
		auto_link = not (err_cat or is_set (inactive) or ignore_invalid) and 'doi' or nil -- do not auto-link when |doi-broken-date= has a value or when there is a DOI error or (to play it safe, after all, auto-linking is not essential) when invalid DOIs are ignored
		}) .. (inactive or '');

	return text .. (err_cat and err_cat or ''); -- parentheses required
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

Query string parameters are named here: http://www.handle.net/proxy_servlet.html.  query strings are not displayed
but since '?' is an allowed character in an HDL, '?' followed by one of the query parameters is the only way we
have to detect the query string so that it isn't URL-encoded with the rest of the identifier.

]]

local function hdl(id, access)
	local handler = cfg.id_handlers['HDL'];
	local query_params = {														-- list of known query parameters from http://www.handle.net/proxy_servlet.html
		'noredirect',
		'ignore_aliases',
		'auth',
		'cert',
		'index',
		'type',
		'urlappend',
		'locatt',
		'action',
		}
	
	local hdl, suffix, param = id:match ('(.-)(%?(%a+).+)$');					-- look for query string
	local found;

	if hdl then																	-- when there are query strings, this is the handle identifier portion
		for _, q in ipairs (query_params) do									-- spin through the list of query parameters
			if param:match ('^' .. q) then										-- if the query string begins with one of the parameters
				found = true;													-- announce a find
				break;															-- and stop looking
			end
		end
	end

	if found then
		id = hdl;																-- found so replace id with the handle portion; this will be URL-encoded, suffix will not
	else
		suffix = '';															-- make sure suffix is empty string for concatenation else
	end

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, suffix = suffix, separator = handler.separator, encode = handler.encode, access = access})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- HDL must contain a forward slash, must not contain spaces, endashes, and must not end with period or comma
		text = text .. ' ' .. set_message( 'err_bad_hdl' );
	end
	return text;
end


--[[--------------------------&lt; I S B N &gt;----------------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function isbn (isbn_str, ignore_invalid)
	local handler = cfg.id_handlers['ISBN'];
	local function return_result (check, err_type)								-- local function to handle the various returns
		local ISBN = internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,
						prefix = handler.prefix, id = isbn_str, separator = handler.separator});
		if ignore_invalid then													-- if ignoring ISBN errors
			set_message ('maint_isbn_ignore');									-- add a maint category even when there is no error
		else																	-- here when not ignoring
			if not check then													-- and there is an error
				return ISBN .. set_message ('err_bad_isbn', {err_type}, false, ' ');	-- display an error message
			end
		end
		return ISBN;
	end

	if nil ~= isbn_str:match ('[^%s-0-9X]') then
		return return_result (false, cfg.err_msg_supl.char);					-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end

	local id = isbn_str:gsub ('[%s-]', '');										-- remove hyphens and whitespace

	local len = id:len();
 
	if len ~= 10 and len ~= 13 then
		return return_result (false, cfg.err_msg_supl.length);					-- fail if incorrect length
	end

	if len == 10 then
		if id:match ('^%d*X?$') == nil then										-- fail if isbn_str has 'X' anywhere but last position
			return return_result (false, cfg.err_msg_supl.form);									
		end
		return return_result (is_valid_isxn(id, 10), cfg.err_msg_supl.check);
	else
		if id:match ('^%d+$') == nil then
			return return_result (false, cfg.err_msg_supl.char);				-- fail if ISBN-13 is not all digits
		end
		if id:match ('^97[89]%d*$') == nil then
			return return_result (false, cfg.err_msg_supl.prefix);				-- fail when ISBN-13 does not begin with 978 or 979
		end
		if id:match ('^9790') then
			return return_result (false, cfg.err_msg_supl.group);				-- group identifier '0' is reserved to ISMN
		end
		return return_result (is_valid_isxn_13 (id), cfg.err_msg_supl.check);
	end
end


--[[--------------------------&lt; A S I N &gt;----------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: ASIN must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, ASINs must be 10-digit
ISBN. If 10-digit ISBN, add a maintenance category so a bot or AWB script can replace |asin= with |isbn=.
Error message if not 10 characters, if not ISBN-10, if mixed and first character is a digit.

|asin=630....... is (apparently) not a legitimate ISBN though it checksums as one; these do not cause this
function to emit the maint_asin message

This function is positioned here because it calls isbn()

]]

local function asin (id, domain)
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat = ' ' .. set_message ('err_bad_asin');							-- ASIN is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then							-- if 10-digit numeric (or 9 digits with terminal X)
			if isbn (id) then													-- see if ASIN value is or validates as ISBN-10
				if not id:find ('^630') then									-- 630xxxxxxx is (apparently) not a valid isbn prefix but is used by amazon as a numeric identifier
					set_message ('maint_asin');									-- begins with something other than 630 so possibly an isbn
				end
			elseif not is_set (err_cat) then
				err_cat = ' ' .. set_message ('err_bad_asin');					-- ASIN is not ISBN-10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat = ' ' .. set_message ('err_bad_asin');						-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set(domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then									-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then							-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end
	local handler = cfg.id_handlers['ASIN'];
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix .. domain .. &quot;/dp/&quot;,
		id = id, encode = handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to ISBN-13, ISMN is 13 digits beginning 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (id)
	local handler = cfg.id_handlers['ISMN'];
	local text;
	local valid_ismn = true;
	local id_copy;

	id_copy = id;																-- save a copy because this testing is destructive
	id = id:gsub ('[%s-]', '');													-- remove hyphens and white space

	if 13 ~= id:len() or id:match( &quot;^9790%d*$&quot; ) == nil then					-- ISMN must be 13 digits and begin with 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ISMN
	end

	--	text = internal_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,		-- use this (or external version) when there is some place to link to
	--		prefix = handler.prefix, id = id_copy, separator = handler.separator, encode = handler.encode})

	text = table.concat (														-- because no place to link to yet
		{
		make_wikilink (link_label_make (handler), handler.label),
		handler.separator,
		id_copy
		});

	if false == valid_ismn then
		text = text .. ' ' .. set_message( 'err_bad_ismn' )						-- add an error message if the ISMN is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an ISSN.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]	-- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the ISSN midpoint.  It also validates the ISSN for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check ISSN error message.  The
ISSN is always displayed with a hyphen, even if the ISSN was given as a single group of 8 digits.

]]

local function issn (id, e, ignore_invalid)
	local issn_copy = id;														-- save a copy of unadulterated ISSN; use this version for display if ISSN does not validate
	local handler;
	local text;
	local valid_issn = true;
	
	handler = cfg.id_handlers[e and 'EISSN' or 'ISSN'];

	id = id:gsub ('[%s-]', '');													-- remove hyphens and whitespace

	if 8 ~= id:len() or nil == id:match( &quot;^%d*X?$&quot; ) then						-- validate the ISSN: 8 digits long, containing only 0-9 or X in the last position
		valid_issn = false;														-- wrong length or improper character
	else
		valid_issn = is_valid_isxn(id, 8);										-- validate ISSN
	end

	if true == valid_issn then
		id = string.sub( id, 1, 4 ) .. &quot;-&quot; .. string.sub( id, 5 );				-- if valid, display correctly formatted version
	else
		id = issn_copy;															-- if not valid, show the invalid ISSN with error message
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode})

	if ignore_invalid then
		set_message ('maint_issn_ignore');
	else
		if false == valid_issn then
			text = text .. ' ' .. set_message ('err_bad_issn', e and 'e' or '');	-- add an error message if the ISSN is invalid
		end 
	end
	
	return text
end


--[[--------------------------&lt; J F M &gt;-----------------------------------------------------------------------

A numerical identifier in the form nn.nnnn.nn

]]

local function jfm (id)
	local handler = cfg.id_handlers['JFM'];
	local id_num;
	local err_cat = '';
	
	id_num = id:match ('^[Jj][Ff][Mm](.*)$');									-- identifier with jfm prefix; extract identifier

	if is_set (id_num) then
		set_message ('maint_jfm_format');
	else																		-- plain number without mr prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num and id_num:match('^%d%d%.%d%d%d%d%.%d%d$') then
		id = id_num;															-- jfm matches pattern
	else
		err_cat = ' ' .. set_message( 'err_bad_jfm' );							-- set an error message
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode}) .. err_cat;
end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lowercase alpha
length = 10 then lccn[1] and lccn[2] are both lowercase alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lowercase alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lowercase alpha

]]

local function lccn(lccn)
	local handler = cfg.id_handlers['LCCN'];
	local err_cat = '';															-- presume that LCCN is valid
	local id = lccn;															-- local copy of the LCCN

	id = normalize_lccn (id);													-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();														-- get the length of the LCCN

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_message ('err_bad_lccn');						-- set an error message
		end
	elseif 9 == len then														-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then							-- does it match our pattern?
			err_cat = ' ' .. set_message ('err_bad_lccn');						-- set an error message
		end
	elseif 10 == len then														-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then					-- ... see if it matches our pattern
				err_cat = ' ' .. set_message ('err_bad_lccn');					-- no match, set an error message
			end
		end
	elseif 11 == len then														-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_message ('err_bad_lccn');						-- no match, set an error message
		end
	elseif 12 == len then														-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then						-- see if it matches our pattern
			err_cat = ' ' .. set_message ('err_bad_lccn');						-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_message ('err_bad_lccn');							-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_message ('err_bad_lccn');							-- lccn contains a space, set an error message
	end

	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = lccn, separator = handler.separator, encode = handler.encode}) .. err_cat;
end


--[[--------------------------&lt; M R &gt;--------------------------------------------------------------------------

A seven digit number; if not seven digits, zero-fill leading digits to make seven digits.

]]

local function mr (id)
	local handler = cfg.id_handlers['MR'];
	local id_num;
	local id_len;
	local err_cat = '';
	
	id_num = id:match ('^[Mm][Rr](%d+)$');										-- identifier with mr prefix

	if is_set (id_num) then
		set_message ('maint_mr_format');										-- add maint cat
	else																		-- plain number without mr prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	id_len = id_num and id_num:len() or 0;
	if (7 &gt;= id_len) and (0 ~= id_len) then
		id = string.rep ('0', 7-id_len ) .. id_num;								-- zero-fill leading digits
	else
		err_cat = ' ' .. set_message ('err_bad_mr');							-- set an error message
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode}) .. err_cat;
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an OCLC ID.  https://www.oclc.org/batchload/controlnumber.en.html {{dead link}}
archived at: https://web.archive.org/web/20161228233804/https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (id)
	local handler = cfg.id_handlers['OCLC'];
	local number;
	local err_msg = '';															-- empty string for concatenation
	
	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- constrain to 1 to 9 digits; change this when OCLC issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if 10 &lt; number:len() then
			number = nil;														-- constrain to 1 to 10 digits; change this when OCLC issues 11-digit numbers
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		err_msg = ' ' .. set_message ('err_bad_oclc')							-- add an error message if the id is malformed
	end
	
	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode}) .. err_msg;

	return text;
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary(id, access)
	local handler = cfg.id_handlers['OL'];
	local ident, code = id:gsub('^OL', ''):match(&quot;^(%d+([AMW]))$&quot;);				-- strip optional OL prefix followed immediately by digits followed by 'A', 'M', or 'W';
	local error_msg = '';
	local prefix = {															-- these are appended to the handler.prefix according to code
		['A']='authors/OL',
		['M']='books/OL',
		['W']='works/OL',
		['X']='OL'																-- not a code; spoof when 'code' in id is invalid
		};

	if not ident then
		code = 'X';																-- no code or id completely invalid
		ident = id;																-- copy id to ident so that we display the flawed identifier
		error_msg = ' ' .. set_message ('err_bad_ol');
	end

	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix .. prefix[code],
		id = ident, separator = handler.separator, encode = handler.encode,
		access = access}) .. error_msg;
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc (id, embargo)
	local handler = cfg.id_handlers['PMC'];
	local err_cat;
	local id_num;
	local text;

	id_num = id:match ('^[Pp][Mm][Cc](%d+)$');									-- identifier with PMC prefix

	if is_set (id_num) then
		set_message ('maint_pmc_format');
	else																		-- plain number without PMC prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_message ('err_bad_pmc');						-- set an error message
		else
			id = tostring (id_num);												-- make sure id is a string
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_message ('err_bad_pmc');							-- set an error message
	end
	
	if is_set (embargo) and is_set (is_embargoed (embargo)) then				-- is PMC is still embargoed?
		text = table.concat (													-- still embargoed so no external link
			{
			make_wikilink (link_label_make (handler), handler.label),
			handler.separator,
			id,
			(err_cat and err_cat or '')											-- parens required
			});
	else
		text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,	-- no embargo date or embargo has expired, ok to link to article
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access,
			auto_link = not err_cat and 'pmc' or nil								-- do not auto-link when PMC has error
			}) .. (err_cat and err_cat or '');									-- parentheses required
	end
	return text;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid(id)
	local handler = cfg.id_handlers['PMID'];
	local err_cat = '';															-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then													-- if PMID has anything but digits
		err_cat = ' ' .. set_message ('err_bad_pmid');							-- set an error message
	else																		-- PMID is only digits
		local id_num = tonumber(id);											-- convert id to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_message ('err_bad_pmid');						-- set an error message
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode}) .. err_cat;
end


--[[--------------------------&lt; S 2 C I D &gt;--------------------------------------------------------------------

Format an S2CID, do simple error checking

S2CIDs are sequential numbers beginning at 1 and counting up.  This code checks the S2CID to see that it is only
digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically
as more S2CIDs are issued.

]]

local function s2cid (id, access)
	local handler = cfg.id_handlers['S2CID'];
	local err_cat = '';															-- presume that S2CID is valid
	local id_num;
	local text;
	
	id_num = id:match ('^[1-9]%d*$');											-- id must be all digits; must not begin with 0; no open access flag

 	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if handler.id_limit &lt; id_num then										-- if S2CID is outside test limit boundaries
			err_cat = ' ' .. set_message ('bad_s2cid_err');						-- set an error message
		end

	else																		-- when id format incorrect
		err_cat = ' ' .. set_message ('bad_s2cid_err');							-- set an error message
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id:gsub ('%.%a%a', ''), separator = handler.separator, encode = handler.encode, access = access}) .. err_cat;

	return text;
end


--[[--------------------------&lt; S B N &gt;------------------------------------------------------------------------

9-digit form of ISBN-10; uses same check-digit validation when SBN is prefixed with an additional '0' to make 10 digits

]]

local function sbn (id, ignore_invalid)
	local handler = cfg.id_handlers['SBN'];
	local function return_result (check, err_type) -- local function to handle the various returns
		local SBN = internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,
						prefix = handler.prefix, id = id, separator = handler.separator});
		if not ignore_invalid then -- if not ignoring SBN errors
			if not check then
				return SBN .. set_message ('err_bad_sbn', {err_type}, false, ' '); -- display an error message
			end
		else
			set_message ('maint_isbn_ignore');									-- add a maint category even when there is no error (ToDo: Possibly switch to separate message for SBNs only)
		end
		return SBN;
	end

	if id:match ('[^%s-0-9X]') then
		return return_result (false, cfg.err_msg_supl.char);					-- fail if SBN contains anything but digits, hyphens, or the uppercase X
	end

	local ident = id:gsub ('[%s-]', '');											-- remove hyphens and whitespace; they interfere with the rest of the tests

	if  9 ~= ident:len() then
		return return_result (false, cfg.err_msg_supl.length);					-- fail if incorrect length
	end

	if ident:match ('^%d*X?$') == nil then
		return return_result (false, cfg.err_msg_supl.form);					-- fail if SBN has 'X' anywhere but last position
	end

	return return_result (is_valid_isxn ('0' .. ident, 10), cfg.err_msg_supl.check);
end


--[[--------------------------&lt; S S R N &gt;----------------------------------------------------------------------

Format an SSRN, do simple error checking

SSRNs are sequential numbers beginning at 100? and counting up.  This code checks the SSRN to see that it is
only digits and is greater than 99 and less than test_limit; the value in local variable test_limit will need
to be updated periodically as more SSRNs are issued.

]]

local function ssrn (id)
	local handler = cfg.id_handlers['SSRN'];
	local err_cat = '';															-- presume that SSRN is valid
	local id_num;
	local text;
	
	id_num = id:match ('^%d+$');												-- id must be all digits

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber(id_num);												-- convert id_num to a number for range testing
		if 100 &gt; id_num or handler.id_limit &lt; id_num then						-- if SSRN is outside test limit boundaries
			err_cat = ' ' .. set_message ('err_bad_ssrn');						-- set an error message
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_message ('err_bad_ssrn');							-- set an error message
	end
	
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access}) .. err_cat;

	return text;
end


--[[--------------------------&lt; U S E N E T _ I D &gt;------------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function usenet_id (id)
	local handler = cfg.id_handlers['USENETID'];

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$') then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_message ('err_bad_usenet_id')					-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; Z B L &gt;-----------------------------------------------------------------------

A numerical identifier in the form nnnn.nnnnn - leading zeros in the first quartet optional

format described here: http://emis.mi.sanu.ac.rs/ZMATH/zmath/en/help/search/

temporary format is apparently eight digits.  Anything else is an error

]]

local function zbl (id)
	local handler = cfg.id_handlers['ZBL'];
	local err_cat = '';
	
	if id:match('^%d%d%d%d%d%d%d%d$') then										-- is this identifier using temporary format?
		set_message ('maint_zbl');												-- yes, add maint cat
	elseif not id:match('^%d?%d?%d?%d%.%d%d%d%d%d$') then						-- not temporary, is it normal format?
		err_cat = ' ' .. set_message ('err_bad_zbl');							-- no, set an error message
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode}) .. err_cat;
end


--============================&lt;&lt; I N T E R F A C E   F U N C T I O N S &gt;&gt;==========================================

--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;--------------------------------------------------------

Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.

inputs:
	id_list – table of identifiers built by extract_ids()
	options – table of various template parameter values used to modify some manually handled identifiers

]]

local function build_id_list( id_list, options )
	local new_list, handler = {};
	local accept;

	local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
	
	for k, v in pairs( id_list ) do
		v, accept = has_accept_as_written (v);									-- remove and note accept-as-written markup if present

		-- k is uppercase identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		-- fallback to read-only cfg
		handler = setmetatable( { ['id'] = v, ['access'] = options.IdAccessLevels[k] }, fallback(k) );

		if handler.mode == 'external' then
			table.insert( new_list, {handler.label, external_link_id( handler ) } );
		elseif handler.mode == 'internal' then
			table.insert( new_list, {handler.label, internal_link_id( handler ) } );
		elseif handler.mode ~= 'manual' then
			error( cfg.messages['unknown_ID_mode'] );
		elseif k == 'ARXIV' then
			table.insert( new_list, {handler.label, arxiv( v, options.Class ) } ); 
		elseif k == 'ASIN' then
			table.insert( new_list, {handler.label, asin( v, options.ASINTLD ) } ); 
		elseif k == 'BIBCODE' then
			table.insert( new_list, {handler.label, bibcode( v, handler.access ) } );
		elseif k == 'BIORXIV' then
			table.insert( new_list, {handler.label, biorxiv( v ) } );
		elseif k == 'CITESEERX' then
			table.insert( new_list, {handler.label, citeseerx( v ) } );
		elseif k == 'DOI' then
			table.insert( new_list, {handler.label, doi( v, options.DoiBroken, handler.access, accept) } );
		elseif k == 'EISSN' then
			table.insert( new_list, {handler.label, issn( v, true, accept) } );	-- true distinguishes EISSN from ISSN
		elseif k == 'HDL' then
			table.insert( new_list, {handler.label, hdl( v, handler.access ) } );
		elseif k == 'ISBN' then
			table.insert( new_list, {handler.label, isbn (v, (accept or options.IgnoreISBN)) } );
		elseif k == 'ISMN' then
			table.insert( new_list, {handler.label, ismn( v ) } );
		elseif k == 'ISSN' then
			table.insert( new_list, {handler.label, issn( v, false, accept) } );
		elseif k == 'JFM' then
			table.insert( new_list, {handler.label, jfm( v ) } );
		elseif k == 'LCCN' then
			table.insert( new_list, {handler.label, lccn( v ) } );
		elseif k == 'MR' then
			table.insert( new_list, {handler.label, mr( v ) } );
		elseif k == 'OCLC' then
			table.insert( new_list, {handler.label, oclc( v ) } );
		elseif k == 'OL' or k == 'OLA' then
			table.insert( new_list, {handler.label, openlibrary( v, handler.access ) } );
		elseif k == 'PMC' then
			table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
		elseif k == 'PMID' then
			table.insert( new_list, {handler.label, pmid( v ) } );
		elseif k == 'S2CID' then
			table.insert( new_list, {handler.label, s2cid( v, handler.access ) } );
		elseif k == 'SBN' then
			table.insert( new_list, {handler.label, sbn (v, accept) } );
		elseif k == 'SSRN' then
			table.insert( new_list, {handler.label, ssrn( v ) } );
		elseif k == 'USENETID' then
			table.insert( new_list, {handler.label, usenet_id( v ) } );
		elseif k == 'ZBL' then
			table.insert( new_list, {handler.label, zbl( v ) } );
		else
			error( cfg.messages['unknown_manual_ID'] );
		end
	end
	
	local function comp( a, b )	-- used in following table.sort()
		return a[1]:lower() &lt; b[1]:lower();
	end
	
	table.sort( new_list, comp );
	for k, v in ipairs( new_list ) do
		new_list[k] = v[2];
	end
	
	return new_list;
end


--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message if more than one alias exists in args

]]

local function extract_ids( args )
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs( cfg.id_handlers ) do										-- k is uppercase identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one( args, v.parameters, 'err_redundant_parameters' );			-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set(v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; E X T R A C T _ I D _ A C C E S S _ L E V E L S &gt;--------------------------------------

Fetches custom id access levels from arguments using configuration settings.
Parameters which have a predefined access level (e.g. arxiv) do not use this
function as they are directly rendered as free without using an additional parameter.

access-level values must match the case used in cfg.keywords_lists['id-access'] (lowercase unless there is some special reason for something else)

]]

local function extract_id_access_levels( args, id_list )
	local id_accesses_list = {};
	for k, v in pairs( cfg.id_handlers ) do
		local access_param = v.custom_access;									-- name of identifier's access-level parameter
		if is_set(access_param) then
			local access_level = args[access_param];							-- get the assigned value if there is one
			if is_set (access_level) then
				if not in_array (access_level, cfg.keywords_lists['id-access']) then	-- exact match required
					table.insert( z.message_tail, { set_message( 'invalid_param_val', {access_param, access_level}, true ) } );	
					access_level = nil;											-- invalid so unset
				end
				if not is_set(id_list[k]) then									-- identifier access-level must have a matching identifier
					table.insert( z.message_tail, { set_message( 'err_param_access_requires_param', {k:lower()}, true ) } );	-- parameter name is uppercase in cfg.id_handlers (k); lowercase for error message
				end
				id_accesses_list[k] = cfg.keywords_xlate[access_level];			-- get translated keyword
			end
		end
	end
	return id_accesses_list;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	has_accept_as_written = utilities_page_ptr.has_accept_as_written;			-- import functions from select Module:Citation/CS1/Utilities module
	is_set = utilities_page_ptr.is_set;								
	in_array = utilities_page_ptr.in_array;
	set_message = utilities_page_ptr.set_message;
	select_one = utilities_page_ptr.select_one;
	substitute = utilities_page_ptr.substitute;
	make_wikilink = utilities_page_ptr.make_wikilink;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	auto_link_urls = auto_link_urls,											-- table of identifier URLs to be used when auto-linking |title=
	
	build_id_list = build_id_list,
	extract_ids = extract_ids,
	extract_id_access_levels = extract_id_access_levels,
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>eg0zw6ttx0ztqphkrm52zj5q2aqmp0n</sha1>
    </revision>
    <revision>
      <id>4918</id>
      <parentid>4917</parentid>
      <timestamp>2021-01-09T14:11:13Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4918</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="68177" sha1="gyud5k236nnv74ta7ljtp8hz15rjf3z" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local has_accept_as_written, is_set, in_array, set_message, select_one,			-- functions in Module:Citation/CS1/Utilities
		substitute, make_wikilink;

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

declare variables here that have page-wide scope that are not brought in from other modules; that are created here and used here

]]

local auto_link_urls = {};														-- holds identifier URLs for those identifiers that can auto-link |title=


--============================&lt;&lt; H E L P E R   F U N C T I O N S &gt;&gt;============================================

--[[--------------------------&lt; W I K I D A T A _ A R T I C L E _ N A M E _ G E T &gt;----------------------------

as an aid to internationalizing identifier-label wikilinks, gets identifier article names from Wikidata.

returns :&lt;lang code&gt;:&lt;article title&gt; when &lt;q&gt; has an &lt;article title&gt; for &lt;lang code&gt;; nil else

for identifiers that do not have q, returns nil

for wikis that do not have mw.wikibase installed, returns nil

]]

local function wikidata_article_name_get (q)
	if not is_set (q) or (q and not mw.wikibase) then							-- when no q number or when a q number but mw.wikibase not installed on this wiki
		return nil;																-- abandon
	end

	local wd_article;
	local this_wiki_code = cfg.this_wiki_code;									-- Wikipedia subdomain; 'en' for en.wikipedia.org

	wd_article = mw.wikibase.getSitelink (q, this_wiki_code .. 'wiki');			-- fetch article title from WD; nil when no title available at this wiki

	if wd_article then
		wd_article = table.concat ({':', this_wiki_code, ':', wd_article});		-- interwiki-style link without brackets if taken from WD; leading colon required
	end

	return wd_article;															-- article title from WD; nil else
end


--[[--------------------------&lt; L I N K _ L A B E L _ M A K E &gt;------------------------------------------------

common function to create identifier link label from handler table or from Wikidata

returns the first available of
	1. redirect from local wiki's handler table (if enabled)
	2. Wikidata (if there is a Wikidata entry for this identifier in the local wiki's language)
	3. label specified in the local wiki's handler table
	
]]

local function link_label_make (handler)
	local wd_article;
	
	if not (cfg.use_identifier_redirects and is_set (handler.redirect)) then	-- redirect has priority so if enabled and available don't fetch from Wikidata because expensive
		wd_article = wikidata_article_name_get (handler.q);						-- if Wikidata has an article title for this wiki, get it;
	end
	
	return (cfg.use_identifier_redirects and is_set (handler.redirect) and handler.redirect) or wd_article or handler.link;
end


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki-style external link

]]

local function external_link_id (options)
	local url_string = options.id;
	local ext_link;
	local this_wiki_code = cfg.this_wiki_code;									-- Wikipedia subdomain; 'en' for en.wikipedia.org
	local wd_article;															-- article title from Wikidata
	
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode (url_string);
	end

	if options.auto_link and is_set (options.access) then
		auto_link_urls[options.auto_link] = table.concat ({options.prefix, url_string, options.suffix});
	end

	ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or &quot;&quot;, mw.text.nowiki (options.id));
	if is_set (options.access) then
		ext_link = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[options.access].class, cfg.presentation[options.access].title, ext_link});	-- add the free-to-read / paywall lock
	end

	return table.concat	({
		make_wikilink (link_label_make (options), options.label),				-- redirect, Wikidata link, or locally specified link (in that order)
		options.separator or '&amp;nbsp;',
		ext_link
		});
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki-style internal link

TODO: Does not currently need to support options.access, options.encode, auto-linking and COinS (as in external_link_id),
but may be needed in the future for :m:Interwiki_map custom-prefixes like :arxiv:, :bibcode:, :DOI:, :hdl:, :ISSN:,
:JSTOR:, :Openlibrary:, :PMID:, :RFC:.

]]

local function internal_link_id (options)
	local id = mw.ustring.gsub (options.id, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9

	return table.concat (
		{
		make_wikilink (link_label_make (options), options.label),				-- wiki-link the identifier label
		options.separator or '&amp;nbsp;',											-- add the separator
		make_wikilink (
			table.concat (
				{
				options.prefix,
				id,																-- translated to Western digits
				options.suffix or ''
				}),
			substitute (cfg.presentation['bdi'], {'', mw.text.nowiki (options.id)})	-- bdi tags to prevent Latin script identifiers from being reversed at RTL language wikis
			);																	-- nowiki because MediaWiki still has magic links for ISBN and the like; TODO: is it really required?
		});
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |pmc-embargo-date= against
today's date.  If embargo date is in the future, returns the content of |pmc-embargo-date=; otherwise, returns
an empty string because the embargo has expired or because |pmc-embargo-date= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, todays_date;
		good1, embargo_date = pcall (lang.formatDate, lang, 'U', embargo);
		todays_date = lang:formatDate ('U');
	
		if good1 then															-- if embargo date is a good date
			if tonumber (embargo_date) &gt;= tonumber (todays_date) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				set_message ('maint_pmc_embargo');								-- embargo has expired; add main cat
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |pmc-embargo-date= not set return empty string
end


--[=[-------------------------&lt; I S _ V A L I D _ B I O R X I V _ D A T E &gt;------------------------------------

returns true if:
	2019-12-11T00:00Z &lt;= biorxiv_date &lt; today + 2 days
	
The dated form of biorxiv identifier has a start date of 2019-12-11.  The Unix timestamp for that date is {{#time:U|2019-12-11}} = 1576022400

biorxiv_date is the date provided in those |biorxiv= parameter values that are dated at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-English date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate().  To get around that
call this function with YYYY-MM-DD format dates.

]=]

local function is_valid_biorxiv_date (biorxiv_date)
	local good1, good2;
	local biorxiv_ts, tomorrow_ts;												-- to hold Unix timestamps representing the dates
	local lang_object = mw.getContentLanguage();

	good1, biorxiv_ts = pcall (lang_object.formatDate, lang_object, 'U', biorxiv_date);		-- convert biorxiv_date value to Unix timestamp 
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which tonumber() may not understand
		biorxiv_ts = tonumber (biorxiv_ts) or lang_object:parseFormattedNumber (biorxiv_ts);	-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to Unix timestamp
	end

	return ((1576022400 &lt;= biorxiv_ts) and (biorxiv_ts &lt; tomorrow_ts))			-- 2012-12-11T00:00Z &lt;= biorxiv_date &lt; tomorrow's date
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all ISBN/ISSN digits including the check digit.
ISBN-13 is checked in isbn().

If the number is valid the result will be 0. Before calling this function, ISBN/ISSN must be checked for length
and stripped of dashes, spaces and other non-ISxN characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39, 'X' → 0x58
	len = len + 1;																-- adjust to be a loop counter
	for i, v in ipairs (isxn_str) do											-- loop through all of the bytes and calculate the checksum
		if v == string.byte (&quot;X&quot; ) then											-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10 * (len - i);										-- it represents 10 decimal
		else
			temp = temp + tonumber (string.char (v) )*(len-i);
		end
	end
	return temp % 11 == 0;														-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N _ 1 3 &gt;-----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 ISBN/ISMN digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, ISBN-13/ISMN must be checked for length
and stripped of dashes, spaces and other non-ISxN-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39
	for i, v in ipairs (isxn_str) do
		temp = temp + (3 - 2*(i % 2)) * tonumber (string.char (v) );				-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when ISBN-13/ISMN is correct
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

LCCN normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized LCCN for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);												-- 1. strip whitespace

	if nil ~= string.find (lccn, '/') then
		lccn = lccn:match (&quot;(.-)/&quot;);											-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);									-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then														-- if there was a hyphen
		suffix = string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;				-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn = prefix..suffix;													-- reassemble the LCCN
	end
	
	return lccn;
	end


--============================&lt;&lt; I D E N T I F I E R   F U N C T I O N S &gt;&gt;====================================

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9107 and 0703, is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation; not the same as |class= parameter which is not supported in this form
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (options)
	local id = options.id;
	local class = options.Class;												-- TODO: lowercase?
	local handler = options.handler;
	local year, month, version;
	local err_cat = false;														-- assume no error message
	local text;																	-- output text
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9107-0703 format with or without version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 with or without version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then									-- when year is 07, is month invalid (before April)?
				err_cat = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format with or without version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
				err_cat = true;													-- flag for error message
		end

	else
		err_cat = true;															-- not a recognized format; flag for error message
	end

	err_cat = err_cat and table.concat ({' ', set_message ('err_bad_arxiv')}) or '';	-- set error message if flag is true
	
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access}) .. err_cat;

	if is_set (class) then
		if id:match ('^%d+') then
			text = table.concat ({text, ' [[//arxiv.org/archive/', class, ' ', class, ']]'});	-- external link within square brackets, not wikilink
		else
			text = table.concat ({text, ' ', set_message ('err_class_ignored')});		
		end
	end

	return text;	
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode ID.

Format for bibcodes is specified here: http://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		9–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local err_type;
	local year;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode,
		access = access});
	
	if 19 ~= id:len() then
		err_type = cfg.err_msg_supl.length;
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%w&amp;%.][%w&amp;%.][%w&amp;%.][%w.]+[%a%.]$&quot;);
		if not year then														-- if nil then no pattern match
			err_type = cfg.err_msg_supl.value;									-- so value error
		else
			local next_year = tonumber (os.date ('%Y')) + 1;						-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = cfg.err_msg_supl.year;								-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = cfg.err_msg_supl.journal;							-- journal abbreviation must not have '&amp;.' (if it does it's missing a letter)
			end
		end
	end

	if is_set (err_type) then													-- if there was an error detected
		text = text .. ' ' .. set_message ('err_bad_bibcode', {err_type});
	end
	return text;
end


--[[--------------------------&lt; B I O R X I V &gt;-----------------------------------------------------------------

Format bioRxiv ID and do simple error checking.  Before 2019-12-11, biorXiv IDs were 10.1101/ followed by exactly
6 digits.  After 2019-12-11, biorXiv IDs retained the six-digit identifier but prefixed that with a yyyy.mm.dd. 
date and suffixed with an optional version identifier.

The bioRxiv ID is the string of characters:
	https://doi.org/10.1101/078733 -&gt; 10.1101/078733
or a date followed by a six-digit number followed by an optional version indicator 'v' and one or more digits:
	https://www.biorxiv.org/content/10.1101/2019.12.11.123456v2 -&gt; 10.1101/2019.12.11.123456v2
	
see https://www.biorxiv.org/about-biorxiv

]]

local function biorxiv (options)
	local id = options.id;
	local handler = options.handler;
	local err_cat = true;														-- flag; assume that there will be an error
	
	local patterns = {
		'^10.1101/%d%d%d%d%d%d$',												-- simple 6-digit identifier (before 2019-12-11)
		'^10.1101/(20[1-9]%d)%.([01]%d)%.([0-3]%d)%.%d%d%d%d%d%dv%d+$',			-- y.m.d. date + 6-digit identifier + version (after 2019-12-11)
		'^10.1101/(20[1-9]%d)%.([01]%d)%.([0-3]%d)%.%d%d%d%d%d%d$',				-- y.m.d. date + 6-digit identifier (after 2019-12-11)
		}
	
	for _, pattern in ipairs (patterns) do										-- spin through the patterns looking for a match
		if id:match (pattern) then
			local y, m, d = id:match (pattern);									-- found a match, attempt to get year, month and date from the identifier

			if m then															-- m is nil when id is the six-digit form
				if not is_valid_biorxiv_date (y .. '-' .. m .. '-' .. d) then	-- validate the encoded date; TODO: don't ignore leap-year and actual month lengths ({{#time:}} is a poor date validator)
					break;														-- date fail; break out early so we don't unset the error message
				end
			end
			err_cat = nil;														-- we found a match so unset the error message
			break;																-- and done
		end
	end																			-- err_cat remains set here when no match

	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator,
			encode = handler.encode, access = handler.access}) .. (err_cat and (' ' .. set_message ('err_bad_biorxiv')) or '');
end


--[[--------------------------&lt; C I T E S E E R X &gt;------------------------------------------------------------

CiteSeerX use their own notion of &quot;doi&quot; (not to be confused with the identifiers resolved via doi.org).

The description of the structure of this identifier can be found at Help_talk:Citation_Style_1/Archive_26#CiteSeerX_id_structure
]]

local function citeseerx (options)
	local id = options.id;
	local handler = options.handler;
	local matched;
	
	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode,
		access = handler.access});
	
	matched = id:match (&quot;^10%.1%.1%.[1-9]%d?%d?%d?%.[1-9]%d?%d?%d?$&quot;);
	if not matched then
		text = text .. ' ' .. set_message ('err_bad_citeseerx' );
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the DOI name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in DOI names.

]]

local function doi (options)
	local id = options.id;
	local inactive = options.DoiBroken
	local access = options.access;
	local ignore_invalid = options.accept;
	local handler = options.handler;
	local err_cat;

	local text;
	if is_set (inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';					-- try to get the year portion from the inactive date
		local inactive_month, good;

		if is_set (inactive_year) then
			if 4 &lt; inactive:len() then											-- inactive date has more than just a year (could be anything)
				local lang_obj = mw.getContentLanguage();						-- get a language object for this wiki
				good, inactive_month = pcall (lang_obj.formatDate, lang_obj, 'F', inactive);	-- try to get the month name from the inactive date
				if not good then
					inactive_month = nil;										-- something went wrong so make sure this is unset
				end
			end
		else
			inactive_year = nil;												-- |doi-broken-date= has something but it isn't a date
		end
		
		if is_set (inactive_year) and is_set (inactive_month) then
			set_message ('maint_doi_inactive_dated', {inactive_year, inactive_month, ' '});
		elseif is_set (inactive_year) then
			set_message ('maint_doi_inactive_dated', {inactive_year, '', ''});
		else
			set_message ('maint_doi_inactive');
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. ' ' .. inactive .. ')';
	end

	local registrant = id:match ('^10%.([^/]+)/[^%s–]-[^%.,]$');				-- registrant set when DOI has the proper basic form
	
	local registrant_err_patterns = {											-- these patterns are for code ranges that are not supported 
		'^[^1-3]%d%d%d%d%.%d%d*$',												-- 5 digits with subcode (0xxxx, 40000+); accepts: 10000–39999
		'^[^1-4]%d%d%d%d$',														-- 5 digits without subcode (0xxxx, 40000+); accepts: 10000–49999
		'^[^1-9]%d%d%d%.%d%d*$',												-- 4 digits with subcode (0xxx); accepts: 1000–9999
		'^[^1-9]%d%d%d$',														-- 4 digits without subcode (0xxx); accepts: 1000–9999
		'^%d%d%d%d%d%d+',														-- 6 or more digits
		'^%d%d?%d?$',															-- less than 4 digits without subcode (with subcode is legitimate)
		'^5555$',																-- test registrant will never resolve
		'[^%d%.]',																-- any character that isn't a digit or a dot
		}

	if not ignore_invalid then
		if registrant then -- when DOI has proper form
			for i, pattern in ipairs (registrant_err_patterns) do -- spin through error patterns
				if registrant:match (pattern) then -- to validate registrant codes
					err_cat = ' ' .. set_message ('err_bad_doi'); -- when found, mark this DOI as bad
					break; -- and done
				end
			end
		else
			err_cat = ' ' .. set_message ('err_bad_doi'); -- invalid directory or malformed
		end
	else
		set_message ('maint_doi_ignore');
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access,
		auto_link = not (err_cat or is_set (inactive) or ignore_invalid) and 'doi' or nil -- do not auto-link when |doi-broken-date= has a value or when there is a DOI error or (to play it safe, after all, auto-linking is not essential) when invalid DOIs are ignored
		}) .. (inactive or '');

	return text .. (err_cat and err_cat or ''); -- parentheses required
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

Query string parameters are named here: http://www.handle.net/proxy_servlet.html.  query strings are not displayed
but since '?' is an allowed character in an HDL, '?' followed by one of the query parameters is the only way we
have to detect the query string so that it isn't URL-encoded with the rest of the identifier.

]]

local function hdl (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local query_params = {														-- list of known query parameters from http://www.handle.net/proxy_servlet.html
		'noredirect',
		'ignore_aliases',
		'auth',
		'cert',
		'index',
		'type',
		'urlappend',
		'locatt',
		'action',
		}
	
	local hdl, suffix, param = id:match ('(.-)(%?(%a+).+)$');					-- look for query string
	local found;

	if hdl then																	-- when there are query strings, this is the handle identifier portion
		for _, q in ipairs (query_params) do									-- spin through the list of query parameters
			if param:match ('^' .. q) then										-- if the query string begins with one of the parameters
				found = true;													-- announce a find
				break;															-- and stop looking
			end
		end
	end

	if found then
		id = hdl;																-- found so replace id with the handle portion; this will be URL-encoded, suffix will not
	else
		suffix = '';															-- make sure suffix is empty string for concatenation else
	end

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, suffix = suffix, separator = handler.separator, encode = handler.encode, access = access})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- HDL must contain a forward slash, must not contain spaces, endashes, and must not end with period or comma
		text = text .. ' ' .. set_message ('err_bad_hdl' );
	end
	return text;
end


--[[--------------------------&lt; I S B N &gt;----------------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function isbn (options)
	local isbn_str = options.id;
	local ignore_invalid = options.accept;
	local handler = options.handler;

	local function return_result (check, err_type)								-- local function to handle the various returns
		local ISBN = internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,
						prefix = handler.prefix, id = isbn_str, separator = handler.separator});
		if ignore_invalid then													-- if ignoring ISBN errors
			set_message ('maint_isbn_ignore');									-- add a maint category even when there is no error
		else																	-- here when not ignoring
			if not check then													-- and there is an error
				return ISBN .. set_message ('err_bad_isbn', {err_type}, false, ' ');	-- display an error message
			end
		end
		return ISBN;
	end

	if nil ~= isbn_str:match ('[^%s-0-9X]') then
		return return_result (false, cfg.err_msg_supl.char);					-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end

	local id = isbn_str:gsub ('[%s-]', '');										-- remove hyphens and whitespace

	local len = id:len();
 
	if len ~= 10 and len ~= 13 then
		return return_result (false, cfg.err_msg_supl.length);					-- fail if incorrect length
	end

	if len == 10 then
		if id:match ('^%d*X?$') == nil then										-- fail if isbn_str has 'X' anywhere but last position
			return return_result (false, cfg.err_msg_supl.form);									
		end
		return return_result (is_valid_isxn (id, 10), cfg.err_msg_supl.check);
	else
		if id:match ('^%d+$') == nil then
			return return_result (false, cfg.err_msg_supl.char);				-- fail if ISBN-13 is not all digits
		end
		if id:match ('^97[89]%d*$') == nil then
			return return_result (false, cfg.err_msg_supl.prefix);				-- fail when ISBN-13 does not begin with 978 or 979
		end
		if id:match ('^9790') then
			return return_result (false, cfg.err_msg_supl.group);				-- group identifier '0' is reserved to ISMN
		end
		return return_result (is_valid_isxn_13 (id), cfg.err_msg_supl.check);
	end
end


--[[--------------------------&lt; A S I N &gt;----------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: ASIN must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, ASINs must be 10-digit
ISBN. If 10-digit ISBN, add a maintenance category so a bot or AWB script can replace |asin= with |isbn=.
Error message if not 10 characters, if not ISBN-10, if mixed and first character is a digit.

|asin=630....... is (apparently) not a legitimate ISBN though it checksums as one; these do not cause this
function to emit the maint_asin message

This function is positioned here because it calls isbn()

]]

local function asin (options)
	local id = options.id;
	local domain = options.ASINTLD;
	
	local err_cat = &quot;&quot;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat = ' ' .. set_message ('err_bad_asin');							-- ASIN is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then							-- if 10-digit numeric (or 9 digits with terminal X)
			if isbn (options) then												-- see if ASIN value is or validates as ISBN-10
				if not id:find ('^630') then									-- 630xxxxxxx is (apparently) not a valid isbn prefix but is used by amazon as a numeric identifier
					set_message ('maint_asin');									-- begins with something other than 630 so possibly an isbn
				end
			elseif not is_set (err_cat) then
				err_cat = ' ' .. set_message ('err_bad_asin');					-- ASIN is not ISBN-10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat = ' ' .. set_message ('err_bad_asin');						-- asin doesn't begin with uppercase alpha
		end
	end
	if not is_set (domain) then 
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then									-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'au', 'br', 'mx'}) then							-- Australia, Brazil, Mexico
		domain = &quot;com.&quot; .. domain;
	end

	local handler = options.handler;
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix .. domain .. &quot;/dp/&quot;,
		id = id, encode = handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to ISBN-13, ISMN is 13 digits beginning 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

]]

local function ismn (options)
	local id = options.id;
	local handler = options.handler;
	local text;
	local valid_ismn = true;
	local id_copy;

	id_copy = id;																-- save a copy because this testing is destructive
	id = id:gsub ('[%s-]', '');													-- remove hyphens and white space

	if 13 ~= id:len() or id:match (&quot;^9790%d*$&quot; ) == nil then					-- ISMN must be 13 digits and begin with 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ISMN
	end

	--	text = internal_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,		-- use this (or external version) when there is some place to link to
	--		prefix = handler.prefix, id = id_copy, separator = handler.separator, encode = handler.encode})

	text = table.concat (														-- because no place to link to yet
		{
		make_wikilink (link_label_make (handler), handler.label),
		handler.separator,
		id_copy
		});

	if false == valid_ismn then
		text = text .. ' ' .. set_message ('err_bad_ismn' )						-- add an error message if the ISMN is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an ISSN.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]	-- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the ISSN midpoint.  It also validates the ISSN for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check ISSN error message.  The
ISSN is always displayed with a hyphen, even if the ISSN was given as a single group of 8 digits.

]]

local function issn (options)
	local id = options.id;
	local handler = options.handler;
	local ignore_invalid = options.accept;

	local issn_copy = id;														-- save a copy of unadulterated ISSN; use this version for display if ISSN does not validate
	local text;
	local valid_issn = true;

	id = id:gsub ('[%s-]', '');													-- remove hyphens and whitespace

	if 8 ~= id:len() or nil == id:match (&quot;^%d*X?$&quot; ) then						-- validate the ISSN: 8 digits long, containing only 0-9 or X in the last position
		valid_issn = false;														-- wrong length or improper character
	else
		valid_issn = is_valid_isxn (id, 8);										-- validate ISSN
	end

	if true == valid_issn then
		id = string.sub (id, 1, 4 ) .. &quot;-&quot; .. string.sub (id, 5 );				-- if valid, display correctly formatted version
	else
		id = issn_copy;															-- if not valid, show the invalid ISSN with error message
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode})

	if ignore_invalid then
		set_message ('maint_issn_ignore');
	else
		if false == valid_issn then
			text = text .. ' ' .. set_message ('err_bad_issn', (options.hkey == 'EISSN') and 'e' or '');	-- add an error message if the ISSN is invalid
		end 
	end
	
	return text
end


--[[--------------------------&lt; J F M &gt;-----------------------------------------------------------------------

A numerical identifier in the form nn.nnnn.nn

]]

local function jfm (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;
	local err_cat = '';
	
	id_num = id:match ('^[Jj][Ff][Mm](.*)$');									-- identifier with jfm prefix; extract identifier

	if is_set (id_num) then
		set_message ('maint_jfm_format');
	else																		-- plain number without JFM prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num and id_num:match('^%d%d%.%d%d%d%d%.%d%d$') then
		id = id_num;															-- jfm matches pattern
	else
		err_cat = ' ' .. set_message ('err_bad_jfm' );							-- set an error message
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode}) .. err_cat;
end


--[[--------------------------&lt; J S T O R &gt;--------------------------------------------------------------------

Format a JSTOR with some error checking

]]

local function jstor (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local err_msg = '';

	if id:find ('[Jj][Ss][Tt][Oo][Rr]') or id:find ('^https?://') or id:find ('%s') then
		err_msg = ' ' .. set_message ('err_bad_jstor');							-- set an error message
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access}) .. err_msg;
end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lowercase alpha
length = 10 then lccn[1] and lccn[2] are both lowercase alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lowercase alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lowercase alpha

]]

local function lccn (options)
	local lccn = options.id;
	local handler = options.handler;
	local err_cat = '';															-- presume that LCCN is valid
	local id = lccn;															-- local copy of the LCCN

	id = normalize_lccn (id);													-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();														-- get the length of the LCCN

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_message ('err_bad_lccn');						-- set an error message
		end
	elseif 9 == len then														-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then							-- does it match our pattern?
			err_cat = ' ' .. set_message ('err_bad_lccn');						-- set an error message
		end
	elseif 10 == len then														-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then					-- ... see if it matches our pattern
				err_cat = ' ' .. set_message ('err_bad_lccn');					-- no match, set an error message
			end
		end
	elseif 11 == len then														-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_message ('err_bad_lccn');						-- no match, set an error message
		end
	elseif 12 == len then														-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then						-- see if it matches our pattern
			err_cat = ' ' .. set_message ('err_bad_lccn');						-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_message ('err_bad_lccn');							-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_message ('err_bad_lccn');							-- lccn contains a space, set an error message
	end

	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = lccn, separator = handler.separator, encode = handler.encode}) .. err_cat;
end


--[[--------------------------&lt; M R &gt;--------------------------------------------------------------------------

A seven digit number; if not seven digits, zero-fill leading digits to make seven digits.

]]

local function mr (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;
	local id_len;
	local err_cat = '';
	
	id_num = id:match ('^[Mm][Rr](%d+)$');										-- identifier with mr prefix

	if is_set (id_num) then
		set_message ('maint_mr_format');										-- add maint cat
	else																		-- plain number without mr prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	id_len = id_num and id_num:len() or 0;
	if (7 &gt;= id_len) and (0 ~= id_len) then
		id = string.rep ('0', 7-id_len) .. id_num;								-- zero-fill leading digits
	else
		err_cat = ' ' .. set_message ('err_bad_mr');							-- set an error message
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode}) .. err_cat;
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an OCLC ID.  https://www.oclc.org/batchload/controlnumber.en.html {{dead link}}
archived at: https://web.archive.org/web/20161228233804/https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (options)
	local id = options.id;
	local handler = options.handler;
	local number;
	local err_msg = '';															-- empty string for concatenation
	
	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- constrain to 1 to 9 digits; change this when OCLC issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if 10 &lt; number:len() then
			number = nil;														-- constrain to 1 to 10 digits; change this when OCLC issues 11-digit numbers
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		err_msg = ' ' .. set_message ('err_bad_oclc')							-- add an error message if the id is malformed
	end
	
	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode}) .. err_msg;

	return text;
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local ident, code = id:gsub('^OL', ''):match(&quot;^(%d+([AMW]))$&quot;);				-- strip optional OL prefix followed immediately by digits followed by 'A', 'M', or 'W';
	local error_msg = '';
	local prefix = {															-- these are appended to the handler.prefix according to code
		['A']='authors/OL',
		['M']='books/OL',
		['W']='works/OL',
		['X']='OL'																-- not a code; spoof when 'code' in id is invalid
		};

	if not ident then
		code = 'X';																-- no code or id completely invalid
		ident = id;																-- copy id to ident so that we display the flawed identifier
		error_msg = ' ' .. set_message ('err_bad_ol');
	end

	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix .. prefix[code],
		id = ident, separator = handler.separator, encode = handler.encode,
		access = access}) .. error_msg;
end


--[[--------------------------&lt; O S T I &gt;----------------------------------------------------------------------

Format OSTI and do simple error checking. OSTIs are sequential numbers beginning at 1 and counting up.  This
code checks the OSTI to see that it contains only digits and is less than test_limit specified in the configuration;
the value in test_limit will need to be updated periodically as more OSTIs are issued.

NB. 1018 is the lowest OSTI number found in the wild (so far) and resolving OK on the OSTI site

]]

local function osti (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local err_cat = '';															-- presume that OSTI is valid
	
	if id:match(&quot;[^%d]&quot;) then													-- if OSTI has anything but digits
		err_cat = ' ' .. set_message ('err_bad_osti');							-- set an error message
	else																		-- OSTI is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1018 &gt; id_num or handler.id_limit &lt; id_num then						-- if OSTI is outside test limit boundaries
			err_cat = ' ' .. set_message ('err_bad_osti');						-- set an error message
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access}) .. err_cat;
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc (options)
	local id = options.id;
	local embargo = options.Embargo;											-- TODO: lowercase?
	local handler = options.handler;
	local err_cat;
	local id_num;
	local text;

	id_num = id:match ('^[Pp][Mm][Cc](%d+)$');									-- identifier with PMC prefix

	if is_set (id_num) then
		set_message ('maint_pmc_format');
	else																		-- plain number without PMC prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_message ('err_bad_pmc');						-- set an error message
		else
			id = tostring (id_num);												-- make sure id is a string
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_message ('err_bad_pmc');							-- set an error message
	end
	
	if is_set (embargo) and is_set (is_embargoed (embargo)) then				-- is PMC is still embargoed?
		text = table.concat (													-- still embargoed so no external link
			{
			make_wikilink (link_label_make (handler), handler.label),
			handler.separator,
			id,
			(err_cat and err_cat or '')											-- parens required
			});
	else
		text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,	-- no embargo date or embargo has expired, ok to link to article
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access,
			auto_link = not err_cat and 'pmc' or nil								-- do not auto-link when PMC has error
			}) .. (err_cat and err_cat or '');									-- parentheses required
	end
	return text;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid (options)
	local id = options.id;
	local handler = options.handler;
	local err_cat = '';															-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then													-- if PMID has anything but digits
		err_cat = ' ' .. set_message ('err_bad_pmid');							-- set an error message
	else																		-- PMID is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_message ('err_bad_pmid');						-- set an error message
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode}) .. err_cat;
end


--[[--------------------------&lt; R F C &gt;------------------------------------------------------------------------

Format RFC and do simple error checking. RFCs are sequential numbers beginning at 1 and counting up.  This
code checks the RFC to see that it contains only digits and is less than test_limit specified in the configuration;
the value in test_limit will need to be updated periodically as more RFCs are issued.

An index of all RFCs is here: https://tools.ietf.org/rfc/

]]

local function rfc (options)
	local id = options.id;
	local handler = options.handler;
	local err_cat = '';															-- presume that RFC is valid
	
	if id:match(&quot;[^%d]&quot;) then													-- if RFC has anything but digits
		err_cat = ' ' .. set_message ('err_bad_rfc');							-- set an error message
	else																		-- RFC is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if RFC is outside test limit boundaries
			err_cat = ' ' .. set_message ('err_bad_rfc');						-- set an error message
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access}) .. err_cat;
end


--[[--------------------------&lt; S 2 C I D &gt;--------------------------------------------------------------------

Format an S2CID, do simple error checking

S2CIDs are sequential numbers beginning at 1 and counting up.  This code checks the S2CID to see that it is only
digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically
as more S2CIDs are issued.

]]

local function s2cid (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local err_cat = '';															-- presume that S2CID is valid
	local id_num;
	local text;
	
	id_num = id:match ('^[1-9]%d*$');											-- id must be all digits; must not begin with 0; no open access flag

 	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if handler.id_limit &lt; id_num then										-- if S2CID is outside test limit boundaries
			err_cat = ' ' .. set_message ('err_bad_s2cid');						-- set an error message
		end

	else																		-- when id format incorrect
		err_cat = ' ' .. set_message ('err_bad_s2cid');							-- set an error message
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access}) .. err_cat;

	return text;
end


--[[--------------------------&lt; S B N &gt;------------------------------------------------------------------------

9-digit form of ISBN-10; uses same check-digit validation when SBN is prefixed with an additional '0' to make 10 digits

]]

local function sbn (options)
	local id = options.id;
	local ignore_invalid = options.accept;
	local handler = options.handler;
	local function return_result (check, err_type) -- local function to handle the various returns
		local SBN = internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,
						prefix = handler.prefix, id = id, separator = handler.separator});
		if not ignore_invalid then -- if not ignoring SBN errors
			if not check then
				return SBN .. set_message ('err_bad_sbn', {err_type}, false, ' '); -- display an error message
			end
		else
			set_message ('maint_isbn_ignore');									-- add a maint category even when there is no error (ToDo: Possibly switch to separate message for SBNs only)
		end
		return SBN;
	end

	if id:match ('[^%s-0-9X]') then
		return return_result (false, cfg.err_msg_supl.char);					-- fail if SBN contains anything but digits, hyphens, or the uppercase X
	end

	local ident = id:gsub ('[%s-]', '');											-- remove hyphens and whitespace; they interfere with the rest of the tests

	if  9 ~= ident:len() then
		return return_result (false, cfg.err_msg_supl.length);					-- fail if incorrect length
	end

	if ident:match ('^%d*X?$') == nil then
		return return_result (false, cfg.err_msg_supl.form);					-- fail if SBN has 'X' anywhere but last position
	end

	return return_result (is_valid_isxn ('0' .. ident, 10), cfg.err_msg_supl.check);
end


--[[--------------------------&lt; S S R N &gt;----------------------------------------------------------------------

Format an SSRN, do simple error checking

SSRNs are sequential numbers beginning at 100? and counting up.  This code checks the SSRN to see that it is
only digits and is greater than 99 and less than test_limit; the value in local variable test_limit will need
to be updated periodically as more SSRNs are issued.

]]

local function ssrn (options)
	local id = options.id;
	local handler = options.handler;
	local err_cat = '';															-- presume that SSRN is valid
	local id_num;
	local text;
	
	id_num = id:match ('^%d+$');												-- id must be all digits

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if 100 &gt; id_num or handler.id_limit &lt; id_num then						-- if SSRN is outside test limit boundaries
			err_cat = ' ' .. set_message ('err_bad_ssrn');						-- set an error message
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_message ('err_bad_ssrn');							-- set an error message
	end
	
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access}) .. err_cat;

	return text;
end


--[[--------------------------&lt; U S E N E T _ I D &gt;------------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function usenet_id (options)
	local id = options.id;
	local handler = options.handler;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$') then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_message ('err_bad_usenet_id')					-- add an error message if the message id is invalid
	end 
	
	return text
end


--[[--------------------------&lt; Z B L &gt;-----------------------------------------------------------------------

A numerical identifier in the form nnnn.nnnnn - leading zeros in the first quartet optional

format described here: http://emis.mi.sanu.ac.rs/ZMATH/zmath/en/help/search/

temporary format is apparently eight digits.  Anything else is an error

]]

local function zbl (options)
	local id = options.id;
	local handler = options.handler;
	local err_cat = '';
	
	if id:match('^%d%d%d%d%d%d%d%d$') then										-- is this identifier using temporary format?
		set_message ('maint_zbl');												-- yes, add maint cat
	elseif not id:match('^%d?%d?%d?%d%.%d%d%d%d%d$') then						-- not temporary, is it normal format?
		err_cat = ' ' .. set_message ('err_bad_zbl');							-- no, set an error message
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode}) .. err_cat;
end


--============================&lt;&lt; I N T E R F A C E   F U N C T I O N S &gt;&gt;==========================================

--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message if more than one alias exists in args

]]

local function extract_ids (args)
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs (cfg.id_handlers) do										-- k is uppercase identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one (args, v.parameters, 'err_redundant_parameters' );		-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set (v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; E X T R A C T _ I D _ A C C E S S _ L E V E L S &gt;--------------------------------------

Fetches custom id access levels from arguments using configuration settings. Parameters which have a predefined access
level (e.g. arxiv) do not use this function as they are directly rendered as free without using an additional parameter.

returns a table of k/v pairs where k is same as the identifier's key in cfg.id_handlers and v is the assigned (valid) keyword

access-level values must match the case used in cfg.keywords_lists['id-access'] (lowercase unless there is some special reason for something else)

]]

local function extract_id_access_levels (args, id_list)
	local id_accesses_list = {};
	for k, v in pairs (cfg.id_handlers) do
		local access_param = v.custom_access;									-- name of identifier's access-level parameter
		if is_set (access_param) then
			local access_level = args[access_param];							-- get the assigned value if there is one
			if is_set (access_level) then
				if not in_array (access_level, cfg.keywords_lists['id-access']) then	-- exact match required
					table.insert (z.message_tail, { set_message ('invalid_param_val', {access_param, access_level}, true) } );	
					access_level = nil;											-- invalid so unset
				end
				if not is_set (id_list[k]) then									-- identifier access-level must have a matching identifier
					table.insert (z.message_tail, { set_message ('err_param_access_requires_param', {k:lower()}, true) } );	-- parameter name is uppercase in cfg.id_handlers (k); lowercase for error message
				end
				id_accesses_list[k] = cfg.keywords_xlate[access_level];			-- get translated keyword
			end
		end
	end
	return id_accesses_list;
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;----------------------------------------------------

render the identifiers into a sorted sequence table

&lt;id_list_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value
&lt;options_t&gt; is a table of is a table of various k/v option pairs provided in the call to new_build_id_list();
	modified by	this function and passed to all identifier rendering functions
&lt;access_levels_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value (if valid)

returns a sequence table of sorted (by hkey) rendered identifier strings

]]

local function build_id_list (id_list_t, options_t, access_levels_t)
	local new_list_t = {};
	local accept;
	local func_map = {															--function map points to functions associated with hkey identifier
		['ARXIV'] = arxiv,
		['ASIN'] = asin,
		['BIBCODE'] = bibcode,
		['BIORXIV'] = biorxiv,
		['CITESEERX'] = citeseerx,
		['DOI'] = doi,
		['EISSN'] = issn,
		['HDL'] = hdl,
		['ISBN'] = isbn,
		['ISMN'] = ismn,
		['ISSN'] = issn,
		['JFM'] = jfm,
		['JSTOR'] = jstor,
		['LCCN'] = lccn,
		['MR'] = mr,
		['OCLC'] = oclc,
		['OL'] = openlibrary,
		['OSTI'] = osti,
		['PMC'] = pmc,
		['PMID'] = pmid,
		['RFC']  = rfc,
		['S2CID'] = s2cid,
		['SBN'] = sbn,
		['SSRN'] = ssrn,
		['USENETID'] = usenet_id,
		['ZBL'] = zbl,
		}

	for hkey, v in pairs (id_list_t) do
		v, accept = has_accept_as_written (v);									-- remove accept-as-written markup if present; accept is boolean true when markup removed; false else
																				-- every function gets the options table with value v and accept boolean
		options_t.hkey = hkey;													-- ~/Configuration handler key
		options_t.id = v;														-- add that identifier value to the options table
		options_t.accept = accept;												-- add the accept boolean flag
		options_t.access = access_levels_t[hkey];								-- add the access level for those that have an |&lt;identifier-access= parameter
		options_t.handler = cfg.id_handlers[hkey];
		if func_map[hkey] then
			table.insert (new_list_t, {hkey, func_map[hkey] (options_t)});		-- call the function and add the results to the output sequence table

			-- TODO: also retrieve identifier validity status, OL A/M/W/X type and ASIN TLD info from the corresponding function call for improved metadata generation in COinS() in ~/COinS

		else
			error (cfg.messages['unknown_ID_key'] .. ' ' .. hkey);				-- here when func_map doesn't have a function for hkey
		end
	end

	local function comp (a, b)													-- used by following table.sort()
		return a[1]:lower() &lt; b[1]:lower();										-- sort by hkey
	end

	table.sort (new_list_t, comp);												-- sequence table of tables sort	
	for k, v in ipairs (new_list_t) do											-- convert sequence table of tables to simple sequence table of strings
		new_list_t[k] = v[2];
	end
	
	return new_list_t;
end


--[[--------------------------&lt; I D E N T I F I E R _ L I S T S _ G E T &gt;--------------------------------------

Creates two identifier lists: a k/v table of identifiers and their values to be used locally and for use in the
COinS metadata, and a sequence table of the rendered identifier strings that will be included in the rendered
citation.

]]

local function identifier_lists_get (args, options_t)
	local ID_list_coins_t = extract_ids (args);											-- get a table of identifiers and their values for use locally and for use in COinS
	local ID_access_levels_t = extract_id_access_levels (args, ID_list_coins_t);		-- get a table of identifier access levels
	local ID_list_t = build_id_list (ID_list_coins_t, options_t, ID_access_levels_t);	-- get a sequence table of rendered identifier strings

	-- TODO: add code to retrieve identifier validity status, OL A/M/W/X type and ASIN TLD info from ID_list_t and add this to ID_list_coins_t for improved metadata generation in COinS() in ~/COinS

	return ID_list_t, ID_list_coins_t;											-- return the tables
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	has_accept_as_written = utilities_page_ptr.has_accept_as_written;			-- import functions from select Module:Citation/CS1/Utilities module
	is_set = utilities_page_ptr.is_set;								
	in_array = utilities_page_ptr.in_array;
	set_message = utilities_page_ptr.set_message;
	select_one = utilities_page_ptr.select_one;
	substitute = utilities_page_ptr.substitute;
	make_wikilink = utilities_page_ptr.make_wikilink;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	auto_link_urls = auto_link_urls,											-- table of identifier URLs to be used when auto-linking |title=
	
	identifier_lists_get = identifier_lists_get,								-- experiment to replace individual calls to build_id_list, extract_ids, extract_id_access_levels
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>gyud5k236nnv74ta7ljtp8hz15rjf3z</sha1>
    </revision>
    <revision>
      <id>4919</id>
      <parentid>4918</parentid>
      <timestamp>2021-04-10T13:14:47Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4919</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="74379" sha1="pyll880p5kq8abjnjrhovoq4uqy2zqb" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local has_accept_as_written, is_set, in_array, set_message, select_one,			-- functions in Module:Citation/CS1/Utilities
		substitute, make_wikilink;

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

declare variables here that have page-wide scope that are not brought in from other modules; that are created here and used here

]]

local auto_link_urls = {};														-- holds identifier URLs for those identifiers that can auto-link |title=


--============================&lt;&lt; H E L P E R   F U N C T I O N S &gt;&gt;============================================

--[[--------------------------&lt; W I K I D A T A _ A R T I C L E _ N A M E _ G E T &gt;----------------------------

as an aid to internationalizing identifier-label wikilinks, gets identifier article names from Wikidata.

returns :&lt;lang code&gt;:&lt;article title&gt; when &lt;q&gt; has an &lt;article title&gt; for &lt;lang code&gt;; nil else

for identifiers that do not have q, returns nil

for wikis that do not have mw.wikibase installed, returns nil

]]

local function wikidata_article_name_get (q)
	if not is_set (q) or (q and not mw.wikibase) then							-- when no q number or when a q number but mw.wikibase not installed on this wiki
		return nil;																-- abandon
	end

	local wd_article;
	local this_wiki_code = cfg.this_wiki_code;									-- Wikipedia subdomain; 'en' for en.wikipedia.org

	wd_article = mw.wikibase.getSitelink (q, this_wiki_code .. 'wiki');			-- fetch article title from WD; nil when no title available at this wiki

	if wd_article then
		wd_article = table.concat ({':', this_wiki_code, ':', wd_article});		-- interwiki-style link without brackets if taken from WD; leading colon required
	end

	return wd_article;															-- article title from WD; nil else
end


--[[--------------------------&lt; L I N K _ L A B E L _ M A K E &gt;------------------------------------------------

common function to create identifier link label from handler table or from Wikidata

returns the first available of
	1. redirect from local wiki's handler table (if enabled)
	2. Wikidata (if there is a Wikidata entry for this identifier in the local wiki's language)
	3. label specified in the local wiki's handler table
	
]]

local function link_label_make (handler)
	local wd_article;
	
	if not (cfg.use_identifier_redirects and is_set (handler.redirect)) then	-- redirect has priority so if enabled and available don't fetch from Wikidata because expensive
		wd_article = wikidata_article_name_get (handler.q);						-- if Wikidata has an article title for this wiki, get it;
	end
	
	return (cfg.use_identifier_redirects and is_set (handler.redirect) and handler.redirect) or wd_article or handler.link;
end


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki-style external link

]]

local function external_link_id (options)
	local url_string = options.id;
	local ext_link;
	local this_wiki_code = cfg.this_wiki_code;									-- Wikipedia subdomain; 'en' for en.wikipedia.org
	local wd_article;															-- article title from Wikidata
	
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode (url_string, 'PATH');
	end

	if options.auto_link and is_set (options.access) then
		auto_link_urls[options.auto_link] = table.concat ({options.prefix, url_string, options.suffix});
	end

	ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or &quot;&quot;, mw.text.nowiki (options.id));
	if is_set (options.access) then
		ext_link = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[options.access].class, cfg.presentation[options.access].title, ext_link});	-- add the free-to-read / paywall lock
	end

	return table.concat	({
		make_wikilink (link_label_make (options), options.label),				-- redirect, Wikidata link, or locally specified link (in that order)
		options.separator or '&amp;nbsp;',
		ext_link
		});
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki-style internal link

TODO: Does not currently need to support options.access, options.encode, auto-linking and COinS (as in external_link_id),
but may be needed in the future for :m:Interwiki_map custom-prefixes like :arxiv:, :bibcode:, :DOI:, :hdl:, :ISSN:,
:JSTOR:, :Openlibrary:, :PMID:, :RFC:.

]]

local function internal_link_id (options)
	local id = mw.ustring.gsub (options.id, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9

	return table.concat (
		{
		make_wikilink (link_label_make (options), options.label),				-- wiki-link the identifier label
		options.separator or '&amp;nbsp;',											-- add the separator
		make_wikilink (
			table.concat (
				{
				options.prefix,
				id,																-- translated to Western digits
				options.suffix or ''
				}),
			substitute (cfg.presentation['bdi'], {'', mw.text.nowiki (options.id)})	-- bdi tags to prevent Latin script identifiers from being reversed at RTL language wikis
			);																	-- nowiki because MediaWiki still has magic links for ISBN and the like; TODO: is it really required?
		});
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |pmc-embargo-date= against
today's date.  If embargo date is in the future, returns the content of |pmc-embargo-date=; otherwise, returns
an empty string because the embargo has expired or because |pmc-embargo-date= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, todays_date;
		good1, embargo_date = pcall (lang.formatDate, lang, 'U', embargo);
		todays_date = lang:formatDate ('U');
	
		if good1 then															-- if embargo date is a good date
			if tonumber (embargo_date) &gt;= tonumber (todays_date) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				set_message ('maint_pmc_embargo');								-- embargo has expired; add main cat
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |pmc-embargo-date= not set return empty string
end


--[=[-------------------------&lt; I S _ V A L I D _ B I O R X I V _ D A T E &gt;------------------------------------

returns true if:
	2019-12-11T00:00Z &lt;= biorxiv_date &lt; today + 2 days
	
The dated form of biorxiv identifier has a start date of 2019-12-11.  The Unix timestamp for that date is {{#time:U|2019-12-11}} = 1576022400

biorxiv_date is the date provided in those |biorxiv= parameter values that are dated at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-English date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang.formatDate().  To get around that
call this function with YYYY-MM-DD format dates.

]=]

local function is_valid_biorxiv_date (biorxiv_date)
	local good1, good2;
	local biorxiv_ts, tomorrow_ts;												-- to hold Unix timestamps representing the dates
	local lang_object = mw.getContentLanguage();

	good1, biorxiv_ts = pcall (lang_object.formatDate, lang_object, 'U', biorxiv_date);		-- convert biorxiv_date value to Unix timestamp 
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which tonumber() may not understand
		biorxiv_ts = tonumber (biorxiv_ts) or lang_object:parseFormattedNumber (biorxiv_ts);	-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to Unix timestamp
	end

	return ((1576022400 &lt;= biorxiv_ts) and (biorxiv_ts &lt; tomorrow_ts))			-- 2012-12-11T00:00Z &lt;= biorxiv_date &lt; tomorrow's date
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all ISBN/ISSN digits including the check digit.
ISBN-13 is checked in isbn().

If the number is valid the result will be 0. Before calling this function, ISBN/ISSN must be checked for length
and stripped of dashes, spaces and other non-ISxN characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39, 'X' → 0x58
	len = len + 1;																-- adjust to be a loop counter
	for i, v in ipairs (isxn_str) do											-- loop through all of the bytes and calculate the checksum
		if v == string.byte (&quot;X&quot; ) then											-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10 * (len - i);										-- it represents 10 decimal
		else
			temp = temp + tonumber (string.char (v) )*(len-i);
		end
	end
	return temp % 11 == 0;														-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N _ 1 3 &gt;-----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 ISBN/ISMN digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, ISBN-13/ISMN must be checked for length
and stripped of dashes, spaces and other non-ISxN-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39
	for i, v in ipairs (isxn_str) do
		temp = temp + (3 - 2*(i % 2)) * tonumber (string.char (v) );			-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when ISBN-13/ISMN is correct
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

LCCN normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized LCCN for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.
]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);												-- 1. strip whitespace

	if nil ~= string.find (lccn, '/') then
		lccn = lccn:match (&quot;(.-)/&quot;);											-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);									-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then														-- if there was a hyphen
		suffix = string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;				-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn = prefix..suffix;													-- reassemble the LCCN
	end
	
	return lccn;
	end


--============================&lt;&lt; I D E N T I F I E R   F U N C T I O N S &gt;&gt;====================================

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9107 and 0703, is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation; not the same as |class= parameter which is not supported in this form
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number
]]

local function arxiv (options)
	local id = options.id;
	local class = options.Class;												-- TODO: lowercase?
	local handler = options.handler;
	local year, month, version;
	local err_cat = false;														-- assume no error message
	local text;																	-- output text
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9107-0703 format with or without version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_cat = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 with or without version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then									-- when year is 07, is month invalid (before April)?
				err_cat = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format with or without version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
				err_cat = true;													-- flag for error message
		end

	else
		err_cat = true;															-- not a recognized format; flag for error message
	end

	if err_cat then
		options.coins_list_t['ARXIV'] = nil;									-- when error, unset so not included in COinS
	end
	
	err_cat = err_cat and table.concat ({' ', set_message ('err_bad_arxiv')}) or '';	-- set error message if flag is true
	
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access}) .. err_cat;

	if is_set (class) then
		if id:match ('^%d+') then
			text = table.concat ({text, ' [[//arxiv.org/archive/', class, ' ', class, ']]'});	-- external link within square brackets, not wikilink
		else
			text = table.concat ({text, ' ', set_message ('err_class_ignored')});		
		end
	end

	return text;	
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode ID.

Format for bibcodes is specified here: http://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		9–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local err_type;
	local year;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode,
		access = access});
	
	if 19 ~= id:len() then
		err_type = cfg.err_msg_supl.length;
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%w&amp;%.][%w&amp;%.][%w&amp;%.][%w.]+[%a%.]$&quot;);
		if not year then														-- if nil then no pattern match
			err_type = cfg.err_msg_supl.value;									-- so value error
		else
			local next_year = tonumber (os.date ('%Y')) + 1;					-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = cfg.err_msg_supl.year;								-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = cfg.err_msg_supl.journal;							-- journal abbreviation must not have '&amp;.' (if it does it's missing a letter)
			end
		end
	end

	if is_set (err_type) then													-- if there was an error detected
		text = text .. ' ' .. set_message ('err_bad_bibcode', {err_type});
		options.coins_list_t['BIBCODE'] = nil;									-- when error, unset so not included in COinS

	end
	return text;
end


--[[--------------------------&lt; B I O R X I V &gt;-----------------------------------------------------------------

Format bioRxiv ID and do simple error checking.  Before 2019-12-11, biorXiv IDs were 10.1101/ followed by exactly
6 digits.  After 2019-12-11, biorXiv IDs retained the six-digit identifier but prefixed that with a yyyy.mm.dd. 
date and suffixed with an optional version identifier.

The bioRxiv ID is the string of characters:
	https://doi.org/10.1101/078733 -&gt; 10.1101/078733
or a date followed by a six-digit number followed by an optional version indicator 'v' and one or more digits:
	https://www.biorxiv.org/content/10.1101/2019.12.11.123456v2 -&gt; 10.1101/2019.12.11.123456v2
	
see https://www.biorxiv.org/about-biorxiv

]]

local function biorxiv (options)
	local id = options.id;
	local handler = options.handler;
	local err_cat = true;														-- flag; assume that there will be an error
	
	local patterns = {
		'^10.1101/%d%d%d%d%d%d$',												-- simple 6-digit identifier (before 2019-12-11)
		'^10.1101/(20[1-9]%d)%.([01]%d)%.([0-3]%d)%.%d%d%d%d%d%dv%d+$',			-- y.m.d. date + 6-digit identifier + version (after 2019-12-11)
		'^10.1101/(20[1-9]%d)%.([01]%d)%.([0-3]%d)%.%d%d%d%d%d%d$',				-- y.m.d. date + 6-digit identifier (after 2019-12-11)
		}
	
	for _, pattern in ipairs (patterns) do										-- spin through the patterns looking for a match
		if id:match (pattern) then
			local y, m, d = id:match (pattern);									-- found a match, attempt to get year, month and date from the identifier

			if m then															-- m is nil when id is the six-digit form
				if not is_valid_biorxiv_date (y .. '-' .. m .. '-' .. d) then	-- validate the encoded date; TODO: don't ignore leap-year and actual month lengths ({{#time:}} is a poor date validator)
					break;														-- date fail; break out early so we don't unset the error message
				end
			end
			err_cat = nil;														-- we found a match so unset the error message
			break;																-- and done
		end
	end																			-- err_cat remains set here when no match

	if err_cat then
		options.coins_list_t['BIORXIV'] = nil;									-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator,
			encode = handler.encode, access = handler.access}) .. (err_cat and (' ' .. set_message ('err_bad_biorxiv')) or '');
end


--[[--------------------------&lt; C I T E S E E R X &gt;------------------------------------------------------------

CiteSeerX use their own notion of &quot;doi&quot; (not to be confused with the identifiers resolved via doi.org).

The description of the structure of this identifier can be found at Help_talk:Citation_Style_1/Archive_26#CiteSeerX_id_structure
]]

local function citeseerx (options)
	local id = options.id;
	local handler = options.handler;
	local matched;
	
	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode,
		access = handler.access});
	
	matched = id:match (&quot;^10%.1%.1%.[1-9]%d?%d?%d?%.[1-9]%d?%d?%d?$&quot;);
	if not matched then
		text = text .. ' ' .. set_message ('err_bad_citeseerx' );
		options.coins_list_t['CITESEERX'] = nil;								-- when error, unset so not included in COinS
	end
	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the DOI name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in DOI names.

]]

local function doi (options)
	local id = options.id;
	local inactive = options.DoiBroken
	local access = options.access;
	local ignore_invalid = options.accept;
	local handler = options.handler;
	local err_cat;

	local text;
	if is_set (inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';					-- try to get the year portion from the inactive date
		local inactive_month, good;

		if is_set (inactive_year) then
			if 4 &lt; inactive:len() then											-- inactive date has more than just a year (could be anything)
				local lang_obj = mw.getContentLanguage();						-- get a language object for this wiki
				good, inactive_month = pcall (lang_obj.formatDate, lang_obj, 'F', inactive);	-- try to get the month name from the inactive date
				if not good then
					inactive_month = nil;										-- something went wrong so make sure this is unset
				end
			end
		else
			inactive_year = nil;												-- |doi-broken-date= has something but it isn't a date
		end
		
		if is_set (inactive_year) and is_set (inactive_month) then
			set_message ('maint_doi_inactive_dated', {inactive_year, inactive_month, ' '});
		elseif is_set (inactive_year) then
			set_message ('maint_doi_inactive_dated', {inactive_year, '', ''});
		else
			set_message ('maint_doi_inactive');
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. ' ' .. inactive .. ')';
	end

	local registrant = id:match ('^10%.([^/]+)/[^%s–]-[^%.,]$');				-- registrant set when DOI has the proper basic form
	
	local registrant_err_patterns = {											-- these patterns are for code ranges that are not supported 
		'^[^1-3]%d%d%d%d%.%d%d*$',												-- 5 digits with subcode (0xxxx, 40000+); accepts: 10000–39999
		'^[^1-5]%d%d%d%d$',														-- 5 digits without subcode (0xxxx, 60000+); accepts: 10000–59999
		'^[^1-9]%d%d%d%.%d%d*$',												-- 4 digits with subcode (0xxx); accepts: 1000–9999
		'^[^1-9]%d%d%d$',														-- 4 digits without subcode (0xxx); accepts: 1000–9999
		'^%d%d%d%d%d%d+',														-- 6 or more digits
		'^%d%d?%d?$',															-- less than 4 digits without subcode (with subcode is legitimate)
		'^5555$',																-- test registrant will never resolve
		'[^%d%.]',																-- any character that isn't a digit or a dot
		}

	if not ignore_invalid then
		if registrant then														-- when DOI has proper form
			for i, pattern in ipairs (registrant_err_patterns) do				-- spin through error patterns
				if registrant:match (pattern) then								-- to validate registrant codes
					err_cat = ' ' .. set_message ('err_bad_doi');				-- when found, mark this DOI as bad
					break;														-- and done
				end
			end
		else
			err_cat = ' ' .. set_message ('err_bad_doi');						-- invalid directory or malformed
		end
	else
		set_message ('maint_doi_ignore');
	end

	if err_cat then
		options.coins_list_t['DOI'] = nil;										-- when error, unset so not included in COinS
	end
	
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access,
		auto_link = not (err_cat or is_set (inactive) or ignore_invalid) and 'doi' or nil -- do not auto-link when |doi-broken-date= has a value or when there is a DOI error or (to play it safe, after all, auto-linking is not essential) when invalid DOIs are ignored
		}) .. (inactive or '');

	return text .. (err_cat and err_cat or ''); -- parentheses required
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

Query string parameters are named here: http://www.handle.net/proxy_servlet.html.  query strings are not displayed
but since '?' is an allowed character in an HDL, '?' followed by one of the query parameters is the only way we
have to detect the query string so that it isn't URL-encoded with the rest of the identifier.

]]

local function hdl (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local query_params = {														-- list of known query parameters from http://www.handle.net/proxy_servlet.html
		'noredirect',
		'ignore_aliases',
		'auth',
		'cert',
		'index',
		'type',
		'urlappend',
		'locatt',
		'action',
		}
	
	local hdl, suffix, param = id:match ('(.-)(%?(%a+).+)$');					-- look for query string
	local found;

	if hdl then																	-- when there are query strings, this is the handle identifier portion
		for _, q in ipairs (query_params) do									-- spin through the list of query parameters
			if param:match ('^' .. q) then										-- if the query string begins with one of the parameters
				found = true;													-- announce a find
				break;															-- and stop looking
			end
		end
	end

	if found then
		id = hdl;																-- found so replace id with the handle portion; this will be URL-encoded, suffix will not
	else
		suffix = '';															-- make sure suffix is empty string for concatenation else
	end

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, suffix = suffix, separator = handler.separator, encode = handler.encode, access = access})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- HDL must contain a forward slash, must not contain spaces, endashes, and must not end with period or comma
		text = text .. ' ' .. set_message ('err_bad_hdl' );
		options.coins_list_t['HDL'] = nil;										-- when error, unset so not included in COinS
	end
	return text;
end


--[[--------------------------&lt; I S B N &gt;----------------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function isbn (options)
	local isbn_str = options.id;
	local ignore_invalid = options.accept;
	local handler = options.handler;

	local function return_result (check, err_type)								-- local function to handle the various returns
		local ISBN = internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,
						prefix = handler.prefix, id = isbn_str, separator = handler.separator});
		if ignore_invalid then													-- if ignoring ISBN errors
			set_message ('maint_isbn_ignore');									-- add a maint category even when there is no error
		else																	-- here when not ignoring
			if not check then													-- and there is an error
				options.coins_list_t['ISBN'] = nil;								-- when error, unset so not included in COinS
				return ISBN .. set_message ('err_bad_isbn', {err_type}, false, ' ');	-- display an error message
			end
		end
		return ISBN;
	end

	if nil ~= isbn_str:match ('[^%s-0-9X]') then
		return return_result (false, cfg.err_msg_supl.char);					-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end

	local id = isbn_str:gsub ('[%s-]', '');										-- remove hyphens and whitespace

	local len = id:len();
 
	if len ~= 10 and len ~= 13 then
		return return_result (false, cfg.err_msg_supl.length);					-- fail if incorrect length
	end

	if len == 10 then
		if id:match ('^%d*X?$') == nil then										-- fail if isbn_str has 'X' anywhere but last position
			return return_result (false, cfg.err_msg_supl.form);									
		end
		if not is_valid_isxn (id, 10) then										-- test isbn-10 for numerical validity
			return return_result (false, cfg.err_msg_supl.check);				-- fail if isbn-10 is not numerically valid
		end
		if id:find ('^63[01]') then												-- 630xxxxxxx and 631xxxxxxx are (apparently) not valid isbn group ids but are used by amazon as numeric identifiers (asin)
			return return_result (false, cfg.err_msg_supl.group);				-- fail if isbn-10 begins with 630/1
		end
		return return_result (true, cfg.err_msg_supl.check);					-- pass if isbn-10 is numerically valid
	else
		if id:match ('^%d+$') == nil then
			return return_result (false, cfg.err_msg_supl.char);				-- fail if ISBN-13 is not all digits
		end
		if id:match ('^97[89]%d*$') == nil then
			return return_result (false, cfg.err_msg_supl.prefix);				-- fail when ISBN-13 does not begin with 978 or 979
		end
		if id:match ('^9790') then
			return return_result (false, cfg.err_msg_supl.group);				-- group identifier '0' is reserved to ISMN
		end
		return return_result (is_valid_isxn_13 (id), cfg.err_msg_supl.check);
	end
end


--[[--------------------------&lt; A S I N &gt;----------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: ASIN must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, ASINs must be 10-digit
ISBN. If 10-digit ISBN, add a maintenance category so a bot or AWB script can replace |asin= with |isbn=.
Error message if not 10 characters, if not ISBN-10, if mixed and first character is a digit.

|asin=630....... and |asin=631....... are (apparently) not a legitimate ISBN though it checksums as one; these
do not cause this function to emit the maint_asin message

This function is positioned here because it calls isbn()

]]

local function asin (options)
	local id = options.id;
	local domain = options.ASINTLD;
	
	local err_cat = ''

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_cat = ' ' .. set_message ('err_bad_asin');							-- ASIN is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then							-- if 10-digit numeric (or 9 digits with terminal X)
			if is_valid_isxn (id, 10) then										-- see if ASIN value is or validates as ISBN-10
				if not id:find ('^63[01]') then									-- 630xxxxxxx and 631xxxxxxx are (apparently) not a valid isbn prefixes but are used by amazon as a numeric identifier
					err_cat = ' ' .. set_message ('err_bad_asin');				-- ASIN has ISBN-10 form but begins with something other than 630/1 so probably an isbn 
				end
			elseif not is_set (err_cat) then
				err_cat = ' ' .. set_message ('err_bad_asin');					-- ASIN is not ISBN-10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_cat = ' ' .. set_message ('err_bad_asin');						-- asin doesn't begin with uppercase alpha
		end
	end
	if (not is_set (domain)) or in_array (domain, {'us'}) then					-- default: United States
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then									-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'z.cn'}) then 									-- China
		domain = &quot;cn&quot;;
	elseif in_array (domain, {'au', 'br', 'mx', 'sg', 'tr'}) then				-- Australia, Brazil, Mexico, Singapore, Turkey
		domain = &quot;com.&quot; .. domain;
	elseif not in_array (domain, {'ae', 'ca', 'cn', 'de', 'es', 'fr', 'in', 'it', 'nl', 'pl', 'sa', 'se', 'co.jp', 'co.uk', 'com', 'com.au', 'com.br', 'com.mx', 'com.sg', 'com.tr'}) then -- Arabic Emirates, Canada, China, Germany, Spain, France, Indonesia, Italy, Netherlands, Poland, Saudi Arabia, Sweden (as of 2021-03 Austria (.at), Liechtenstein (.li) and Switzerland (.ch) still redirect to the German site (.de) with special settings, so don't maintain local ASINs for them)
			err_cat = ' ' .. set_message ('err_bad_asin_tld');					-- unsupported asin-tld value
	end
	local handler = options.handler;

	if not is_set (err_cat) then
		options.coins_list_t['ASIN'] = handler.prefix .. domain .. &quot;/dp/&quot; .. id;	-- experiment for asin coins
	else
		options.coins_list_t['ASIN'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix .. domain .. &quot;/dp/&quot;,
		id = id, encode = handler.encode, separator = handler.separator}) .. err_cat;
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to ISBN-13, ISMN is 13 digits beginning 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

ismn value not made part of COinS metadata because we don't have a url or isn't a COinS-defined identifier (rft.xxx)
or an identifier registered at info-uri.info (info:)

]]

local function ismn (options)
	local id = options.id;
	local handler = options.handler;
	local text;
	local valid_ismn = true;
	local id_copy;

	id_copy = id;																-- save a copy because this testing is destructive
	id = id:gsub ('[%s-]', '');													-- remove hyphens and white space

	if 13 ~= id:len() or id:match (&quot;^9790%d*$&quot; ) == nil then					-- ISMN must be 13 digits and begin with 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ISMN
	end

	--	text = internal_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,		-- use this (or external version) when there is some place to link to
	--		prefix = handler.prefix, id = id_copy, separator = handler.separator, encode = handler.encode})

	text = table.concat (														-- because no place to link to yet
		{
		make_wikilink (link_label_make (handler), handler.label),
		handler.separator,
		id_copy
		});

	if false == valid_ismn then
		options.coins_list_t['ISMN'] = nil;										-- when error, unset so not included in COinS; not really necessary here because ismn not made part of COinS
		text = text .. ' ' .. set_message ('err_bad_ismn' )						-- add an error message if the ISMN is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an ISSN.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]	-- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the ISSN midpoint.  It also validates the ISSN for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check ISSN error message.  The
ISSN is always displayed with a hyphen, even if the ISSN was given as a single group of 8 digits.

]]

local function issn (options)
	local id = options.id;
	local handler = options.handler;
	local ignore_invalid = options.accept;

	local issn_copy = id;														-- save a copy of unadulterated ISSN; use this version for display if ISSN does not validate
	local text;
	local valid_issn = true;

	id = id:gsub ('[%s-]', '');													-- remove hyphens and whitespace

	if 8 ~= id:len() or nil == id:match (&quot;^%d*X?$&quot; ) then						-- validate the ISSN: 8 digits long, containing only 0-9 or X in the last position
		valid_issn = false;														-- wrong length or improper character
	else
		valid_issn = is_valid_isxn (id, 8);										-- validate ISSN
	end

	if true == valid_issn then
		id = string.sub (id, 1, 4 ) .. &quot;-&quot; .. string.sub (id, 5 );				-- if valid, display correctly formatted version
	else
		id = issn_copy;															-- if not valid, show the invalid ISSN with error message
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode})

	if ignore_invalid then
		set_message ('maint_issn_ignore');
	else
		if false == valid_issn then
			options.coins_list_t['ISSN'] = nil;									-- when error, unset so not included in COinS
			text = text .. ' ' .. set_message ('err_bad_issn', (options.hkey == 'EISSN') and 'e' or '');	-- add an error message if the ISSN is invalid
		end 
	end
	
	return text
end


--[[--------------------------&lt; J F M &gt;-----------------------------------------------------------------------

A numerical identifier in the form nn.nnnn.nn

]]

local function jfm (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;
	local err_cat = '';
	
	id_num = id:match ('^[Jj][Ff][Mm](.*)$');									-- identifier with jfm prefix; extract identifier

	if is_set (id_num) then
		set_message ('maint_jfm_format');
	else																		-- plain number without JFM prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num and id_num:match('^%d%d%.%d%d%d%d%.%d%d$') then
		id = id_num;															-- jfm matches pattern
	else
		err_cat = ' ' .. set_message ('err_bad_jfm' );							-- set an error message
		options.coins_list_t['JFM'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode}) .. err_cat;
end


--[[--------------------------&lt; J S T O R &gt;--------------------------------------------------------------------

Format a JSTOR with some error checking

]]

local function jstor (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local err_msg = '';

	if id:find ('[Jj][Ss][Tt][Oo][Rr]') or id:find ('^https?://') or id:find ('%s') then
		err_msg = ' ' .. set_message ('err_bad_jstor');							-- set an error message
		options.coins_list_t['JSTOR'] = nil;									-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access}) .. err_msg;
end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lowercase alpha
length = 10 then lccn[1] and lccn[2] are both lowercase alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lowercase alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lowercase alpha

]]

local function lccn (options)
	local lccn = options.id;
	local handler = options.handler;
	local err_cat = '';															-- presume that LCCN is valid
	local id = lccn;															-- local copy of the LCCN

	id = normalize_lccn (id);													-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();														-- get the length of the LCCN

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits)
			err_cat = ' ' .. set_message ('err_bad_lccn');						-- set an error message
		end
	elseif 9 == len then														-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then							-- does it match our pattern?
			err_cat = ' ' .. set_message ('err_bad_lccn');						-- set an error message
		end
	elseif 10 == len then														-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then					-- ... see if it matches our pattern
				err_cat = ' ' .. set_message ('err_bad_lccn');					-- no match, set an error message
			end
		end
	elseif 11 == len then														-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_cat = ' ' .. set_message ('err_bad_lccn');						-- no match, set an error message
		end
	elseif 12 == len then														-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then						-- see if it matches our pattern
			err_cat = ' ' .. set_message ('err_bad_lccn');						-- no match, set an error message
		end
	else
		err_cat = ' ' .. set_message ('err_bad_lccn');							-- wrong length, set an error message
	end

	if not is_set (err_cat) and nil ~= lccn:find ('%s') then
		err_cat = ' ' .. set_message ('err_bad_lccn');							-- lccn contains a space, set an error message
	end

	if is_set (err_cat) then
		options.coins_list_t['LCCN'] = nil;										-- when error, unset so not included in COinS
	end

	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = lccn, separator = handler.separator, encode = handler.encode}) .. err_cat;
end


--[[--------------------------&lt; M R &gt;--------------------------------------------------------------------------

A seven digit number; if not seven digits, zero-fill leading digits to make seven digits.

]]

local function mr (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;
	local id_len;
	local err_cat = '';
	
	id_num = id:match ('^[Mm][Rr](%d+)$');										-- identifier with mr prefix

	if is_set (id_num) then
		set_message ('maint_mr_format');										-- add maint cat
	else																		-- plain number without mr prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	id_len = id_num and id_num:len() or 0;
	if (7 &gt;= id_len) and (0 ~= id_len) then
		id = string.rep ('0', 7-id_len) .. id_num;								-- zero-fill leading digits
	else
		err_cat = ' ' .. set_message ('err_bad_mr');							-- set an error message
		options.coins_list_t['MR'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode}) .. err_cat;
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an OCLC ID.  https://www.oclc.org/batchload/controlnumber.en.html {{dead link}}
archived at: https://web.archive.org/web/20161228233804/https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (options)
	local id = options.id;
	local handler = options.handler;
	local number;
	local err_msg = '';															-- empty string for concatenation
	
	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- constrain to 1 to 9 digits; change this when OCLC issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if 10 &lt; number:len() then
			number = nil;														-- constrain to 1 to 10 digits; change this when OCLC issues 11-digit numbers
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		err_msg = ' ' .. set_message ('err_bad_oclc')							-- add an error message if the id is malformed
		options.coins_list_t['OCLC'] = nil;										-- when error, unset so not included in COinS
	end
	
	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode}) .. err_msg;

	return text;
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local ident, code = id:gsub('^OL', ''):match(&quot;^(%d+([AMW]))$&quot;);				-- strip optional OL prefix followed immediately by digits followed by 'A', 'M', or 'W';
	local error_msg = '';
	local prefix = {															-- these are appended to the handler.prefix according to code
		['A']='authors/OL',
		['M']='books/OL',
		['W']='works/OL',
		['X']='OL'																-- not a code; spoof when 'code' in id is invalid
		};

	if not ident then
		code = 'X';																-- no code or id completely invalid
		ident = id;																-- copy id to ident so that we display the flawed identifier
		error_msg = ' ' .. set_message ('err_bad_ol');
	end

	if not is_set (error_msg) then
		options.coins_list_t['OL'] = handler.prefix .. prefix[code] .. ident;	-- experiment for ol coins
	else
		options.coins_list_t['OL'] = nil;										-- when error, unset so not included in COinS
	end

	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix .. prefix[code],
		id = ident, separator = handler.separator, encode = handler.encode,
		access = access}) .. error_msg;
end


--[[--------------------------&lt; O S T I &gt;----------------------------------------------------------------------

Format OSTI and do simple error checking. OSTIs are sequential numbers beginning at 1 and counting up.  This
code checks the OSTI to see that it contains only digits and is less than test_limit specified in the configuration;
the value in test_limit will need to be updated periodically as more OSTIs are issued.

NB. 1018 is the lowest OSTI number found in the wild (so far) and resolving OK on the OSTI site

]]

local function osti (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local err_cat = '';															-- presume that OSTI is valid
	
	if id:match(&quot;[^%d]&quot;) then													-- if OSTI has anything but digits
		err_cat = ' ' .. set_message ('err_bad_osti');							-- set an error message
		options.coins_list_t['OSTI'] = nil;										-- when error, unset so not included in COinS
	else																		-- OSTI is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1018 &gt; id_num or handler.id_limit &lt; id_num then						-- if OSTI is outside test limit boundaries
			err_cat = ' ' .. set_message ('err_bad_osti');						-- set an error message
			options.coins_list_t['OSTI'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access}) .. err_cat;
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc (options)
	local id = options.id;
	local embargo = options.Embargo;											-- TODO: lowercase?
	local handler = options.handler;
	local err_cat;
	local id_num;
	local text;

	id_num = id:match ('^[Pp][Mm][Cc](%d+)$');									-- identifier with PMC prefix

	if is_set (id_num) then
		set_message ('maint_pmc_format');
	else																		-- plain number without PMC prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if PMC is outside test limit boundaries
			err_cat = ' ' .. set_message ('err_bad_pmc');						-- set an error message
		else
			id = tostring (id_num);												-- make sure id is a string
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_message ('err_bad_pmc');							-- set an error message
	end
	
	if is_set (embargo) and is_set (is_embargoed (embargo)) then				-- is PMC is still embargoed?
		text = table.concat (													-- still embargoed so no external link
			{
			make_wikilink (link_label_make (handler), handler.label),
			handler.separator,
			id,
			(err_cat and err_cat or '')											-- parens required
			});
	else
		text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,	-- no embargo date or embargo has expired, ok to link to article
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access,
			auto_link = not err_cat and 'pmc' or nil							-- do not auto-link when PMC has error
			}) .. (err_cat and err_cat or '');									-- parentheses required
	end

	if err_cat then
		options.coins_list_t['PMC'] = nil;										-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid (options)
	local id = options.id;
	local handler = options.handler;
	local err_cat = '';															-- presume that PMID is valid
	
	if id:match(&quot;[^%d]&quot;) then													-- if PMID has anything but digits
		err_cat = ' ' .. set_message ('err_bad_pmid');							-- set an error message
		options.coins_list_t['PMID'] = nil;										-- when error, unset so not included in COinS
	else																		-- PMID is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if PMID is outside test limit boundaries
			err_cat = ' ' .. set_message ('err_bad_pmid');						-- set an error message
			options.coins_list_t['PMID'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode}) .. err_cat;
end


--[[--------------------------&lt; R F C &gt;------------------------------------------------------------------------

Format RFC and do simple error checking. RFCs are sequential numbers beginning at 1 and counting up.  This
code checks the RFC to see that it contains only digits and is less than test_limit specified in the configuration;
the value in test_limit will need to be updated periodically as more RFCs are issued.

An index of all RFCs is here: https://tools.ietf.org/rfc/

]]

local function rfc (options)
	local id = options.id;
	local handler = options.handler;
	local err_cat = '';															-- presume that RFC is valid
	
	if id:match(&quot;[^%d]&quot;) then													-- if RFC has anything but digits
		err_cat = ' ' .. set_message ('err_bad_rfc');							-- set an error message
		options.coins_list_t['RFC'] = nil;										-- when error, unset so not included in COinS
	else																		-- RFC is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if RFC is outside test limit boundaries
			err_cat = ' ' .. set_message ('err_bad_rfc');						-- set an error message
			options.coins_list_t['RFC'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access}) .. err_cat;
end


--[[--------------------------&lt; S 2 C I D &gt;--------------------------------------------------------------------

Format an S2CID, do simple error checking

S2CIDs are sequential numbers beginning at 1 and counting up.  This code checks the S2CID to see that it is only
digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically
as more S2CIDs are issued.

]]

local function s2cid (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local err_cat = '';															-- presume that S2CID is valid
	local id_num;
	local text;
	
	id_num = id:match ('^[1-9]%d*$');											-- id must be all digits; must not begin with 0; no open access flag

 	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if handler.id_limit &lt; id_num then										-- if S2CID is outside test limit boundaries
			err_cat = ' ' .. set_message ('err_bad_s2cid');						-- set an error message
			options.coins_list_t['S2CID'] = nil;								-- when error, unset so not included in COinS
		end

	else																		-- when id format incorrect
		err_cat = ' ' .. set_message ('err_bad_s2cid');							-- set an error message
		options.coins_list_t['S2CID'] = nil;									-- when error, unset so not included in COinS
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access}) .. err_cat;

	return text;
end


--[[--------------------------&lt; S B N &gt;------------------------------------------------------------------------

9-digit form of ISBN-10; uses same check-digit validation when SBN is prefixed with an additional '0' to make 10 digits

sbn value not made part of COinS metadata because we don't have a url or isn't a COinS-defined identifier (rft.xxx)
or an identifier registered at info-uri.info (info:)

]]

local function sbn (options)
	local id = options.id;
	local ignore_invalid = options.accept;
	local handler = options.handler;
	local function return_result (check, err_type) -- local function to handle the various returns
		local SBN = internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,
						prefix = handler.prefix, id = id, separator = handler.separator});
		if not ignore_invalid then -- if not ignoring SBN errors
			if not check then
				options.coins_list_t['SBN'] = nil;								-- when error, unset so not included in COinS; not really necessary here because sbn not made part of COinS
				return SBN .. set_message ('err_bad_sbn', {err_type}, false, ' '); -- display an error message
			end
		else
			set_message ('maint_isbn_ignore');									-- add a maint category even when there is no error (ToDo: Possibly switch to separate message for SBNs only)
		end
		return SBN;
	end

	if id:match ('[^%s-0-9X]') then
		return return_result (false, cfg.err_msg_supl.char);					-- fail if SBN contains anything but digits, hyphens, or the uppercase X
	end

	local ident = id:gsub ('[%s-]', '');										-- remove hyphens and whitespace; they interfere with the rest of the tests

	if  9 ~= ident:len() then
		return return_result (false, cfg.err_msg_supl.length);					-- fail if incorrect length
	end

	if ident:match ('^%d*X?$') == nil then
		return return_result (false, cfg.err_msg_supl.form);					-- fail if SBN has 'X' anywhere but last position
	end

	return return_result (is_valid_isxn ('0' .. ident, 10), cfg.err_msg_supl.check);
end


--[[--------------------------&lt; S S R N &gt;----------------------------------------------------------------------

Format an SSRN, do simple error checking

SSRNs are sequential numbers beginning at 100? and counting up.  This code checks the SSRN to see that it is
only digits and is greater than 99 and less than test_limit; the value in local variable test_limit will need
to be updated periodically as more SSRNs are issued.

]]

local function ssrn (options)
	local id = options.id;
	local handler = options.handler;
	local err_cat = '';															-- presume that SSRN is valid
	local id_num;
	local text;
	
	id_num = id:match ('^%d+$');												-- id must be all digits

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if 100 &gt; id_num or handler.id_limit &lt; id_num then						-- if SSRN is outside test limit boundaries
			err_cat = ' ' .. set_message ('err_bad_ssrn');						-- set an error message
			options.coins_list_t['SSRN'] = nil;									-- when error, unset so not included in COinS
		end
	else																		-- when id format incorrect
		err_cat = ' ' .. set_message ('err_bad_ssrn');							-- set an error message
		options.coins_list_t['SSRN'] = nil;										-- when error, unset so not included in COinS
	end
	
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access}) .. err_cat;

	return text;
end


--[[--------------------------&lt; U S E N E T _ I D &gt;------------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function usenet_id (options)
	local id = options.id;
	local handler = options.handler;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$') then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		text = text .. ' ' .. set_message ('err_bad_usenet_id')					-- add an error message if the message id is invalid
		options.coins_list_t['USENETID'] = nil;									-- when error, unset so not included in COinS
	end 
	
	return text
end


--[[--------------------------&lt; Z B L &gt;-----------------------------------------------------------------------

A numerical identifier in the form nnnn.nnnnn - leading zeros in the first quartet optional

format described here: http://emis.mi.sanu.ac.rs/ZMATH/zmath/en/help/search/

temporary format is apparently eight digits.  Anything else is an error

]]

local function zbl (options)
	local id = options.id;
	local handler = options.handler;
	local err_cat = '';
	
	if id:match('^%d%d%d%d%d%d%d%d$') then										-- is this identifier using temporary format?
		set_message ('maint_zbl');												-- yes, add maint cat
	elseif not id:match('^%d?%d?%d?%d%.%d%d%d%d%d$') then						-- not temporary, is it normal format?
		err_cat = ' ' .. set_message ('err_bad_zbl');							-- no, set an error message
		options.coins_list_t['ZBL'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode}) .. err_cat;
end


--============================&lt;&lt; I N T E R F A C E   F U N C T I O N S &gt;&gt;==========================================

--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message if more than one alias exists in args

]]

local function extract_ids (args)
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs (cfg.id_handlers) do										-- k is uppercase identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one (args, v.parameters, 'err_redundant_parameters' );		-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set (v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; E X T R A C T _ I D _ A C C E S S _ L E V E L S &gt;--------------------------------------

Fetches custom id access levels from arguments using configuration settings. Parameters which have a predefined access
level (e.g. arxiv) do not use this function as they are directly rendered as free without using an additional parameter.

returns a table of k/v pairs where k is same as the identifier's key in cfg.id_handlers and v is the assigned (valid) keyword

access-level values must match the case used in cfg.keywords_lists['id-access'] (lowercase unless there is some special reason for something else)

]]

local function extract_id_access_levels (args, id_list)
	local id_accesses_list = {};
	for k, v in pairs (cfg.id_handlers) do
		local access_param = v.custom_access;									-- name of identifier's access-level parameter
		if is_set (access_param) then
			local access_level = args[access_param];							-- get the assigned value if there is one
			if is_set (access_level) then
				if not in_array (access_level, cfg.keywords_lists['id-access']) then	-- exact match required
					table.insert (z.message_tail, { set_message ('err_invalid_param_val', {access_param, access_level}, true) } );	
					access_level = nil;											-- invalid so unset
				end
				if not is_set (id_list[k]) then									-- identifier access-level must have a matching identifier
					table.insert (z.message_tail, { set_message ('err_param_access_requires_param', {k:lower()}, true) } );	-- parameter name is uppercase in cfg.id_handlers (k); lowercase for error message
				end
				id_accesses_list[k] = cfg.keywords_xlate[access_level];			-- get translated keyword
			end
		end
	end
	return id_accesses_list;
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;----------------------------------------------------

render the identifiers into a sorted sequence table

&lt;ID_list_coins_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value
&lt;options_t&gt; is a table of various k/v option pairs provided in the call to new_build_id_list();
	modified by	this function and passed to all identifier rendering functions
&lt;access_levels_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value (if valid)

returns a sequence table of sorted (by hkey - 'handler' key) rendered identifier strings

]]

local function build_id_list (ID_list_coins_t, options_t, access_levels_t)
	local ID_list_t = {};
	local accept;
	local func_map = {															--function map points to functions associated with hkey identifier
		['ARXIV'] = arxiv,
		['ASIN'] = asin,
		['BIBCODE'] = bibcode,
		['BIORXIV'] = biorxiv,
		['CITESEERX'] = citeseerx,
		['DOI'] = doi,
		['EISSN'] = issn,
		['HDL'] = hdl,
		['ISBN'] = isbn,
		['ISMN'] = ismn,
		['ISSN'] = issn,
		['JFM'] = jfm,
		['JSTOR'] = jstor,
		['LCCN'] = lccn,
		['MR'] = mr,
		['OCLC'] = oclc,
		['OL'] = openlibrary,
		['OSTI'] = osti,
		['PMC'] = pmc,
		['PMID'] = pmid,
		['RFC']  = rfc,
		['S2CID'] = s2cid,
		['SBN'] = sbn,
		['SSRN'] = ssrn,
		['USENETID'] = usenet_id,
		['ZBL'] = zbl,
		}

	for hkey, v in pairs (ID_list_coins_t) do
		v, accept = has_accept_as_written (v);									-- remove accept-as-written markup if present; accept is boolean true when markup removed; false else
																				-- every function gets the options table with value v and accept boolean
		options_t.hkey = hkey;													-- ~/Configuration handler key
		options_t.id = v;														-- add that identifier value to the options table
		options_t.accept = accept;												-- add the accept boolean flag
		options_t.access = access_levels_t[hkey];								-- add the access level for those that have an |&lt;identifier-access= parameter
		options_t.handler = cfg.id_handlers[hkey];
		options_t.coins_list_t = ID_list_coins_t;								-- pointer to ID_list_coins_t; for |asin= and |ol=; also to keep erroneous values out of the citation's metadata
		
		if func_map[hkey] then
			table.insert (ID_list_t, {hkey, func_map[hkey] (options_t)});		-- call the function and add the results to the output sequence table
		else
			error (cfg.messages['unknown_ID_key'] .. ' ' .. hkey);				-- here when func_map doesn't have a function for hkey
		end
	end

	local function comp (a, b)													-- used by following table.sort()
		return a[1]:lower() &lt; b[1]:lower();										-- sort by hkey
	end

	table.sort (ID_list_t, comp);												-- sequence table of tables sort	
	for k, v in ipairs (ID_list_t) do											-- convert sequence table of tables to simple sequence table of strings
		ID_list_t[k] = v[2];													-- v[2] is the identifier rendering from the call to the various functions in func_map{}
	end
	
	return ID_list_t;
end


--[[--------------------------&lt; O P T I O N S _ C H E C K &gt;----------------------------------------------------

check that certain option parameters have their associated identifier parameters with values

&lt;ID_list_coins_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value
&lt;ID_support_t&gt; is a sequence table of tables created in citation0() where each subtable has four elements:
	[1] is the support parameter's assigned value; empty string if not set
	[2] is a text string same as key in cfg.id_handlers
	[3] is cfg.error_conditions key used to create error message
	[4] is original ID support parameter name used to create error message
	
returns nothing; on error emits an appropriate error message

]]

local function options_check (ID_list_coins_t, ID_support_t)
	for _, v in ipairs (ID_support_t) do
		if is_set (v[1]) and not ID_list_coins_t[v[2]] then						-- when support parameter has a value but matching identifier parameter is missing or empty
			table.insert (z.message_tail, {set_message (v[3], (v[4]))});		-- emit the appropriate error message
		end
	end
end


--[[--------------------------&lt; I D E N T I F I E R _ L I S T S _ G E T &gt;--------------------------------------

Creates two identifier lists: a k/v table of identifiers and their values to be used locally and for use in the
COinS metadata, and a sequence table of the rendered identifier strings that will be included in the rendered
citation.

]]

local function identifier_lists_get (args, options_t, ID_support_t)
	local ID_list_coins_t = extract_ids (args);											-- get a table of identifiers and their values for use locally and for use in COinS
	options_check (ID_list_coins_t, ID_support_t);										-- ID support parameters must have matching identifier parameters 
	local ID_access_levels_t = extract_id_access_levels (args, ID_list_coins_t);		-- get a table of identifier access levels
	local ID_list_t = build_id_list (ID_list_coins_t, options_t, ID_access_levels_t);	-- get a sequence table of rendered identifier strings

	return ID_list_t, ID_list_coins_t;											-- return the tables
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	has_accept_as_written = utilities_page_ptr.has_accept_as_written;			-- import functions from select Module:Citation/CS1/Utilities module
	is_set = utilities_page_ptr.is_set;								
	in_array = utilities_page_ptr.in_array;
	set_message = utilities_page_ptr.set_message;
	select_one = utilities_page_ptr.select_one;
	substitute = utilities_page_ptr.substitute;
	make_wikilink = utilities_page_ptr.make_wikilink;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	auto_link_urls = auto_link_urls,											-- table of identifier URLs to be used when auto-linking |title=
	
	identifier_lists_get = identifier_lists_get,								-- experiment to replace individual calls to build_id_list, extract_ids, extract_id_access_levels
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>pyll880p5kq8abjnjrhovoq4uqy2zqb</sha1>
    </revision>
    <revision>
      <id>4920</id>
      <parentid>4919</parentid>
      <timestamp>2022-01-22T14:11:18Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>update per [[Wikipedia:Village_pump_(proposals)#rfc:_shall_we_update_cs1/2?|RfC]];</comment>
      <origin>4920</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="73621" sha1="1s53aqur5zcnnjyu0azfrtjq6dyiwg4" xml:space="preserve">--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local has_accept_as_written, is_set, in_array, set_message, select_one,			-- functions in Module:Citation/CS1/Utilities
		substitute, make_wikilink;

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

declare variables here that have page-wide scope that are not brought in from other modules; that are created here and used here

]]

local auto_link_urls = {};														-- holds identifier URLs for those identifiers that can auto-link |title=


--============================&lt;&lt; H E L P E R   F U N C T I O N S &gt;&gt;============================================

--[[--------------------------&lt; W I K I D A T A _ A R T I C L E _ N A M E _ G E T &gt;----------------------------

as an aid to internationalizing identifier-label wikilinks, gets identifier article names from Wikidata.

returns :&lt;lang code&gt;:&lt;article title&gt; when &lt;q&gt; has an &lt;article title&gt; for &lt;lang code&gt;; nil else

for identifiers that do not have q, returns nil

for wikis that do not have mw.wikibase installed, returns nil

]]

local function wikidata_article_name_get (q)
	if not is_set (q) or (q and not mw.wikibase) then							-- when no q number or when a q number but mw.wikibase not installed on this wiki
		return nil;																-- abandon
	end

	local wd_article;
	local this_wiki_code = cfg.this_wiki_code;									-- Wikipedia subdomain; 'en' for en.wikipedia.org

	wd_article = mw.wikibase.getSitelink (q, this_wiki_code .. 'wiki');			-- fetch article title from WD; nil when no title available at this wiki

	if wd_article then
		wd_article = table.concat ({':', this_wiki_code, ':', wd_article});		-- interwiki-style link without brackets if taken from WD; leading colon required
	end

	return wd_article;															-- article title from WD; nil else
end


--[[--------------------------&lt; L I N K _ L A B E L _ M A K E &gt;------------------------------------------------

common function to create identifier link label from handler table or from Wikidata

returns the first available of
	1. redirect from local wiki's handler table (if enabled)
	2. Wikidata (if there is a Wikidata entry for this identifier in the local wiki's language)
	3. label specified in the local wiki's handler table
	
]]

local function link_label_make (handler)
	local wd_article;
	
	if not (cfg.use_identifier_redirects and is_set (handler.redirect)) then	-- redirect has priority so if enabled and available don't fetch from Wikidata because expensive
		wd_article = wikidata_article_name_get (handler.q);						-- if Wikidata has an article title for this wiki, get it;
	end
	
	return (cfg.use_identifier_redirects and is_set (handler.redirect) and handler.redirect) or wd_article or handler.link;
end


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki-style external link

]]

local function external_link_id (options)
	local url_string = options.id;
	local ext_link;
	local this_wiki_code = cfg.this_wiki_code;									-- Wikipedia subdomain; 'en' for en.wikipedia.org
	local wd_article;															-- article title from Wikidata
	
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode (url_string, 'PATH');
	end

	if options.auto_link and is_set (options.access) then
		auto_link_urls[options.auto_link] = table.concat ({options.prefix, url_string, options.suffix});
	end

	ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or &quot;&quot;, mw.text.nowiki (options.id));
	if is_set (options.access) then
		ext_link = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[options.access].class, cfg.presentation[options.access].title, ext_link});	-- add the free-to-read / paywall lock
	end

	return table.concat	({
		make_wikilink (link_label_make (options), options.label),				-- redirect, Wikidata link, or locally specified link (in that order)
		options.separator or '&amp;nbsp;',
		ext_link
		});
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki-style internal link

TODO: Does not currently need to support options.access, options.encode, auto-linking and COinS (as in external_link_id),
but may be needed in the future for :m:Interwiki_map custom-prefixes like :arxiv:, :bibcode:, :DOI:, :hdl:, :ISSN:,
:JSTOR:, :Openlibrary:, :PMID:, :RFC:.

]]

local function internal_link_id (options)
	local id = mw.ustring.gsub (options.id, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9

	return table.concat (
		{
		make_wikilink (link_label_make (options), options.label),				-- wiki-link the identifier label
		options.separator or '&amp;nbsp;',											-- add the separator
		make_wikilink (
			table.concat (
				{
				options.prefix,
				id,																-- translated to Western digits
				options.suffix or ''
				}),
			substitute (cfg.presentation['bdi'], {'', mw.text.nowiki (options.id)})	-- bdi tags to prevent Latin script identifiers from being reversed at RTL language wikis
			);																	-- nowiki because MediaWiki still has magic links for ISBN and the like; TODO: is it really required?
		});
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |pmc-embargo-date= against
today's date.  If embargo date is in the future, returns the content of |pmc-embargo-date=; otherwise, returns
an empty string because the embargo has expired or because |pmc-embargo-date= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, todays_date;
		good1, embargo_date = pcall (lang.formatDate, lang, 'U', embargo);
		todays_date = lang:formatDate ('U');
	
		if good1 then															-- if embargo date is a good date
			if tonumber (embargo_date) &gt;= tonumber (todays_date) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				set_message ('maint_pmc_embargo');								-- embargo has expired; add main cat
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |pmc-embargo-date= not set return empty string
end


--[=[-------------------------&lt; I S _ V A L I D _ B I O R X I V _ D A T E &gt;------------------------------------

returns true if:
	2019-12-11T00:00Z &lt;= biorxiv_date &lt; today + 2 days
	
The dated form of biorxiv identifier has a start date of 2019-12-11.  The Unix timestamp for that date is {{#time:U|2019-12-11}} = 1576022400

biorxiv_date is the date provided in those |biorxiv= parameter values that are dated at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-English date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang_object.formatDate().  To get
around that call this function with date parts and create a YYYY-MM-DD format date.

]=]

local function is_valid_biorxiv_date (y, m, d)
	local biorxiv_date = table.concat ({y, m, d}, '-');							-- make ymd date
	local good1, good2;
	local biorxiv_ts, tomorrow_ts;												-- to hold Unix timestamps representing the dates
	local lang_object = mw.getContentLanguage();

	good1, biorxiv_ts = pcall (lang_object.formatDate, lang_object, 'U', biorxiv_date);		-- convert biorxiv_date value to Unix timestamp 
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which tonumber() may not understand
		biorxiv_ts = tonumber (biorxiv_ts) or lang_object:parseFormattedNumber (biorxiv_ts);	-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to Unix timestamp
	end

	return ((1576022400 &lt;= biorxiv_ts) and (biorxiv_ts &lt; tomorrow_ts))			-- 2012-12-11T00:00Z &lt;= biorxiv_date &lt; tomorrow's date
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all ISBN/ISSN digits including the check digit.
ISBN-13 is checked in isbn().

If the number is valid the result will be 0. Before calling this function, ISBN/ISSN must be checked for length
and stripped of dashes, spaces and other non-ISxN characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39, 'X' → 0x58
	len = len + 1;																-- adjust to be a loop counter
	for i, v in ipairs (isxn_str) do											-- loop through all of the bytes and calculate the checksum
		if v == string.byte (&quot;X&quot; ) then											-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10 * (len - i);										-- it represents 10 decimal
		else
			temp = temp + tonumber (string.char (v) )*(len-i);
		end
	end
	return temp % 11 == 0;														-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N _ 1 3 &gt;-----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 ISBN/ISMN digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, ISBN-13/ISMN must be checked for length
and stripped of dashes, spaces and other non-ISxN-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39
	for i, v in ipairs (isxn_str) do
		temp = temp + (3 - 2*(i % 2)) * tonumber (string.char (v) );			-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when ISBN-13/ISMN is correct
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

LCCN normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized LCCN for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.

]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);												-- 1. strip whitespace

	if nil ~= string.find (lccn, '/') then
		lccn = lccn:match (&quot;(.-)/&quot;);											-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);									-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then														-- if there was a hyphen
		suffix = string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;				-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn = prefix..suffix;													-- reassemble the LCCN
	end
	
	return lccn;
	end


--============================&lt;&lt; I D E N T I F I E R   F U N C T I O N S &gt;&gt;====================================

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: http://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9107 and 0703, is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation; not the same as |class= parameter which is not supported in this form
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number

]]

local function arxiv (options)
	local id = options.id;
	local class = options.Class;												-- TODO: lowercase?
	local handler = options.handler;
	local year, month, version;
	local err_msg = false;														-- assume no error message
	local text;																	-- output text
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9107-0703 format with or without version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_msg = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 with or without version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then									-- when year is 07, is month invalid (before April)?
				err_msg = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format with or without version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_msg = true;														-- flag for error message
		end

	else
		err_msg = true;															-- not a recognized format; flag for error message
	end

	if err_msg then
		options.coins_list_t['ARXIV'] = nil;									-- when error, unset so not included in COinS
	end
	
	local err_msg_t = {};
	if err_msg then
		set_message ('err_bad_arxiv');
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access});

	if is_set (class) then
		if id:match ('^%d+') then
			text = table.concat ({text, ' [[//arxiv.org/archive/', class, ' ', class, ']]'});	-- external link within square brackets, not wikilink
		else
			set_message ('err_class_ignored');
		end
	end

	return text;
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode ID.

Format for bibcodes is specified here: http://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		9–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local err_type;
	local err_msg = '';
	local year;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode,
		access = access});
	
	if 19 ~= id:len() then
		err_type = cfg.err_msg_supl.length;
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%w&amp;%.][%w&amp;%.][%w&amp;%.][%w.]+[%a%.]$&quot;);
		if not year then														-- if nil then no pattern match
			err_type = cfg.err_msg_supl.value;									-- so value error
		else
			local next_year = tonumber (os.date ('%Y')) + 1;					-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = cfg.err_msg_supl.year;								-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = cfg.err_msg_supl.journal;							-- journal abbreviation must not have '&amp;.' (if it does it's missing a letter)
			end
		end
	end

	if is_set (err_type) then													-- if there was an error detected
		set_message ('err_bad_bibcode', {err_type});
		options.coins_list_t['BIBCODE'] = nil;									-- when error, unset so not included in COinS

	end

	return text;
end


--[[--------------------------&lt; B I O R X I V &gt;-----------------------------------------------------------------

Format bioRxiv ID and do simple error checking.  Before 2019-12-11, biorXiv IDs were 10.1101/ followed by exactly
6 digits.  After 2019-12-11, biorXiv IDs retained the six-digit identifier but prefixed that with a yyyy.mm.dd. 
date and suffixed with an optional version identifier.

The bioRxiv ID is the string of characters:
	https://doi.org/10.1101/078733 -&gt; 10.1101/078733
or a date followed by a six-digit number followed by an optional version indicator 'v' and one or more digits:
	https://www.biorxiv.org/content/10.1101/2019.12.11.123456v2 -&gt; 10.1101/2019.12.11.123456v2
	
see https://www.biorxiv.org/about-biorxiv

]]

local function biorxiv (options)
	local id = options.id;
	local handler = options.handler;
	local err_msg = true;														-- flag; assume that there will be an error
	
	local patterns = {
		'^10.1101/%d%d%d%d%d%d$',												-- simple 6-digit identifier (before 2019-12-11)
		'^10.1101/(20[1-9]%d)%.([01]%d)%.([0-3]%d)%.%d%d%d%d%d%dv%d+$',			-- y.m.d. date + 6-digit identifier + version (after 2019-12-11)
		'^10.1101/(20[1-9]%d)%.([01]%d)%.([0-3]%d)%.%d%d%d%d%d%d$',				-- y.m.d. date + 6-digit identifier (after 2019-12-11)
		}
	
	for _, pattern in ipairs (patterns) do										-- spin through the patterns looking for a match
		if id:match (pattern) then
			local y, m, d = id:match (pattern);									-- found a match, attempt to get year, month and date from the identifier

			if m then															-- m is nil when id is the six-digit form
				if not is_valid_biorxiv_date (y, m, d) then						-- validate the encoded date; TODO: don't ignore leap-year and actual month lengths ({{#time:}} is a poor date validator)
					break;														-- date fail; break out early so we don't unset the error message
				end
			end
			err_msg = nil;														-- we found a match so unset the error message
			break;																-- and done
		end
	end																			-- err_cat remains set here when no match

	if err_msg then
		options.coins_list_t['BIORXIV'] = nil;									-- when error, unset so not included in COinS
		set_message ('err_bad_biorxiv');										-- and set the error message
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator,
			encode = handler.encode, access = handler.access});
end


--[[--------------------------&lt; C I T E S E E R X &gt;------------------------------------------------------------

CiteSeerX use their own notion of &quot;doi&quot; (not to be confused with the identifiers resolved via doi.org).

The description of the structure of this identifier can be found at Help_talk:Citation_Style_1/Archive_26#CiteSeerX_id_structure

]]

local function citeseerx (options)
	local id = options.id;
	local handler = options.handler;
	local matched;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode,
		access = handler.access});
	
	matched = id:match (&quot;^10%.1%.1%.[1-9]%d?%d?%d?%.[1-9]%d?%d?%d?$&quot;);
	if not matched then
		set_message ('err_bad_citeseerx' );
		options.coins_list_t['CITESEERX'] = nil;								-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the DOI name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in DOI names.

]]

local function doi (options)
	local id = options.id;
	local inactive = options.DoiBroken
	local access = options.access;
	local ignore_invalid = options.accept;
	local handler = options.handler;
	local err_flag;

	local text;
	if is_set (inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';					-- try to get the year portion from the inactive date
		local inactive_month, good;

		if is_set (inactive_year) then
			if 4 &lt; inactive:len() then											-- inactive date has more than just a year (could be anything)
				local lang_obj = mw.getContentLanguage();						-- get a language object for this wiki
				good, inactive_month = pcall (lang_obj.formatDate, lang_obj, 'F', inactive);	-- try to get the month name from the inactive date
				if not good then
					inactive_month = nil;										-- something went wrong so make sure this is unset
				end
			end
		else
			inactive_year = nil;												-- |doi-broken-date= has something but it isn't a date
		end
		
		if is_set (inactive_year) and is_set (inactive_month) then
			set_message ('maint_doi_inactive_dated', {inactive_year, inactive_month, ' '});
		elseif is_set (inactive_year) then
			set_message ('maint_doi_inactive_dated', {inactive_year, '', ''});
		else
			set_message ('maint_doi_inactive');
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. ' ' .. inactive .. ')';
	end

	local registrant = mw.ustring.match (id, '^10%.([^/]+)/[^%s–]-[^%.,]$');	-- registrant set when DOI has the proper basic form

	local registrant_err_patterns = {											-- these patterns are for code ranges that are not supported 
		'^[^1-3]%d%d%d%d%.%d%d*$',												-- 5 digits with subcode (0xxxx, 40000+); accepts: 10000–39999
		'^[^1-5]%d%d%d%d$',														-- 5 digits without subcode (0xxxx, 60000+); accepts: 10000–59999
		'^[^1-9]%d%d%d%.%d%d*$',												-- 4 digits with subcode (0xxx); accepts: 1000–9999
		'^[^1-9]%d%d%d$',														-- 4 digits without subcode (0xxx); accepts: 1000–9999
		'^%d%d%d%d%d%d+',														-- 6 or more digits
		'^%d%d?%d?$',															-- less than 4 digits without subcode (with subcode is legitimate)
		'^5555$',																-- test registrant will never resolve
		'[^%d%.]',																-- any character that isn't a digit or a dot
		}

	if not ignore_invalid then
		if registrant then														-- when DOI has proper form
			for i, pattern in ipairs (registrant_err_patterns) do				-- spin through error patterns
				if registrant:match (pattern) then								-- to validate registrant codes
					err_flag = set_message ('err_bad_doi');						-- when found, mark this DOI as bad
					break;														-- and done
				end
			end
		else
			err_flag = set_message ('err_bad_doi');								-- invalid directory or malformed
		end
	else
		set_message ('maint_doi_ignore');
	end

	if err_flag then
		options.coins_list_t['DOI'] = nil;										-- when error, unset so not included in COinS
	end
	
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access,
		auto_link = not (err_flag or is_set (inactive) or ignore_invalid) and 'doi' or nil -- do not auto-link when |doi-broken-date= has a value or when there is a DOI error or (to play it safe, after all, auto-linking is not essential) when invalid DOIs are ignored
		}) .. (inactive or '');

	return text;
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

Query string parameters are named here: http://www.handle.net/proxy_servlet.html.  query strings are not displayed
but since '?' is an allowed character in an HDL, '?' followed by one of the query parameters is the only way we
have to detect the query string so that it isn't URL-encoded with the rest of the identifier.

]]

local function hdl (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local query_params = {														-- list of known query parameters from http://www.handle.net/proxy_servlet.html
		'noredirect',
		'ignore_aliases',
		'auth',
		'cert',
		'index',
		'type',
		'urlappend',
		'locatt',
		'action',
		}
	
	local hdl, suffix, param = id:match ('(.-)(%?(%a+).+)$');					-- look for query string
	local found;

	if hdl then																	-- when there are query strings, this is the handle identifier portion
		for _, q in ipairs (query_params) do									-- spin through the list of query parameters
			if param:match ('^' .. q) then										-- if the query string begins with one of the parameters
				found = true;													-- announce a find
				break;															-- and stop looking
			end
		end
	end

	if found then
		id = hdl;																-- found so replace id with the handle portion; this will be URL-encoded, suffix will not
	else
		suffix = '';															-- make sure suffix is empty string for concatenation else
	end

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, suffix = suffix, separator = handler.separator, encode = handler.encode, access = access})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- HDL must contain a forward slash, must not contain spaces, endashes, and must not end with period or comma
		set_message ('err_bad_hdl' );
		options.coins_list_t['HDL'] = nil;										-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; I S B N &gt;----------------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function isbn (options)
	local isbn_str = options.id;
	local ignore_invalid = options.accept;
	local handler = options.handler;

	local function return_result (check, err_type)								-- local function to handle the various returns
		local ISBN = internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,
						prefix = handler.prefix, id = isbn_str, separator = handler.separator});
		if ignore_invalid then													-- if ignoring ISBN errors
			set_message ('maint_isbn_ignore');									-- add a maint category even when there is no error
		else																	-- here when not ignoring
			if not check then													-- and there is an error
				options.coins_list_t['ISBN'] = nil;								-- when error, unset so not included in COinS
				set_message ('err_bad_isbn', err_type);							-- set an error message
				return ISBN;										 			-- return id text
			end
		end
		return ISBN;															-- return id text
	end

	if nil ~= isbn_str:match ('[^%s-0-9X]') then
		return return_result (false, cfg.err_msg_supl.char);					-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end

	local id = isbn_str:gsub ('[%s-]', '');										-- remove hyphens and whitespace

	local len = id:len();
 
	if len ~= 10 and len ~= 13 then
		return return_result (false, cfg.err_msg_supl.length);					-- fail if incorrect length
	end

	if len == 10 then
		if id:match ('^%d*X?$') == nil then										-- fail if isbn_str has 'X' anywhere but last position
			return return_result (false, cfg.err_msg_supl.form);									
		end
		if not is_valid_isxn (id, 10) then										-- test isbn-10 for numerical validity
			return return_result (false, cfg.err_msg_supl.check);				-- fail if isbn-10 is not numerically valid
		end
		if id:find ('^63[01]') then												-- 630xxxxxxx and 631xxxxxxx are (apparently) not valid isbn group ids but are used by amazon as numeric identifiers (asin)
			return return_result (false, cfg.err_msg_supl.group);				-- fail if isbn-10 begins with 630/1
		end
		return return_result (true, cfg.err_msg_supl.check);					-- pass if isbn-10 is numerically valid
	else
		if id:match ('^%d+$') == nil then
			return return_result (false, cfg.err_msg_supl.char);				-- fail if ISBN-13 is not all digits
		end
		if id:match ('^97[89]%d*$') == nil then
			return return_result (false, cfg.err_msg_supl.prefix);				-- fail when ISBN-13 does not begin with 978 or 979
		end
		if id:match ('^9790') then
			return return_result (false, cfg.err_msg_supl.group);				-- group identifier '0' is reserved to ISMN
		end
		return return_result (is_valid_isxn_13 (id), cfg.err_msg_supl.check);
	end
end


--[[--------------------------&lt; A S I N &gt;----------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: ASIN must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, ASINs must be 10-digit
ISBN. If 10-digit ISBN, add a maintenance category so a bot or AWB script can replace |asin= with |isbn=.
Error message if not 10 characters, if not ISBN-10, if mixed and first character is a digit.

|asin=630....... and |asin=631....... are (apparently) not a legitimate ISBN though it checksums as one; these
do not cause this function to emit the maint_asin message

This function is positioned here because it calls isbn()

]]

local function asin (options)
	local id = options.id;
	local domain = options.ASINTLD;
	
	local err_flag;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_flag = set_message ('err_bad_asin');								-- ASIN is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then							-- if 10-digit numeric (or 9 digits with terminal X)
			if is_valid_isxn (id, 10) then										-- see if ASIN value is or validates as ISBN-10
				if not id:find ('^63[01]') then									-- 630xxxxxxx and 631xxxxxxx are (apparently) not a valid isbn prefixes but are used by amazon as a numeric identifier
					err_flag = set_message ('err_bad_asin');					-- ASIN has ISBN-10 form but begins with something other than 630/1 so probably an isbn 
				end
			elseif not is_set (err_flag) then
				err_flag = set_message ('err_bad_asin');						-- ASIN is not ISBN-10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_flag = set_message ('err_bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if (not is_set (domain)) or in_array (domain, {'us'}) then					-- default: United States
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then									-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'z.cn'}) then 									-- China
		domain = &quot;cn&quot;;
	elseif in_array (domain, {'au', 'br', 'mx', 'sg', 'tr'}) then				-- Australia, Brazil, Mexico, Singapore, Turkey
		domain = &quot;com.&quot; .. domain;
	elseif not in_array (domain, {'ae', 'ca', 'cn', 'de', 'es', 'fr', 'in', 'it', 'nl', 'pl', 'sa', 'se', 'co.jp', 'co.uk', 'com', 'com.au', 'com.br', 'com.mx', 'com.sg', 'com.tr'}) then -- Arabic Emirates, Canada, China, Germany, Spain, France, Indonesia, Italy, Netherlands, Poland, Saudi Arabia, Sweden (as of 2021-03 Austria (.at), Liechtenstein (.li) and Switzerland (.ch) still redirect to the German site (.de) with special settings, so don't maintain local ASINs for them)
		err_flag = set_message ('err_bad_asin_tld');							-- unsupported asin-tld value
	end
	local handler = options.handler;

	if not is_set (err_flag) then
		options.coins_list_t['ASIN'] = handler.prefix .. domain .. &quot;/dp/&quot; .. id;	-- asin for coins
	else
		options.coins_list_t['ASIN'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix .. domain .. &quot;/dp/&quot;,
		id = id, encode = handler.encode, separator = handler.separator})
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to ISBN-13, ISMN is 13 digits beginning 979-0-... and uses the
same check digit calculations.  See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

ismn value not made part of COinS metadata because we don't have a url or isn't a COinS-defined identifier (rft.xxx)
or an identifier registered at info-uri.info (info:)

]]

local function ismn (options)
	local id = options.id;
	local handler = options.handler;
	local text;
	local valid_ismn = true;
	local id_copy;

	id_copy = id;																-- save a copy because this testing is destructive
	id = id:gsub ('[%s-]', '');													-- remove hyphens and white space

	if 13 ~= id:len() or id:match (&quot;^9790%d*$&quot; ) == nil then					-- ISMN must be 13 digits and begin with 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ISMN
	end

	--	text = internal_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,		-- use this (or external version) when there is some place to link to
	--		prefix = handler.prefix, id = id_copy, separator = handler.separator, encode = handler.encode})

	text = table.concat (														-- because no place to link to yet
		{
		make_wikilink (link_label_make (handler), handler.label),
		handler.separator,
		id_copy
		});

	if false == valid_ismn then
		options.coins_list_t['ISMN'] = nil;										-- when error, unset so not included in COinS; not really necessary here because ismn not made part of COinS
		set_message ('err_bad_ismn');											-- create an error message if the ISMN is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an ISSN.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327]	-- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the ISSN midpoint.  It also validates the ISSN for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check ISSN error message.  The
ISSN is always displayed with a hyphen, even if the ISSN was given as a single group of 8 digits.

]]

local function issn (options)
	local id = options.id;
	local handler = options.handler;
	local ignore_invalid = options.accept;

	local issn_copy = id;														-- save a copy of unadulterated ISSN; use this version for display if ISSN does not validate
	local text;
	local valid_issn = true;

	id = id:gsub ('[%s-]', '');													-- remove hyphens and whitespace

	if 8 ~= id:len() or nil == id:match (&quot;^%d*X?$&quot; ) then						-- validate the ISSN: 8 digits long, containing only 0-9 or X in the last position
		valid_issn = false;														-- wrong length or improper character
	else
		valid_issn = is_valid_isxn (id, 8);										-- validate ISSN
	end

	if true == valid_issn then
		id = string.sub (id, 1, 4 ) .. &quot;-&quot; .. string.sub (id, 5 );				-- if valid, display correctly formatted version
	else
		id = issn_copy;															-- if not valid, show the invalid ISSN with error message
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode})

	if ignore_invalid then
		set_message ('maint_issn_ignore');
	else
		if false == valid_issn then
			options.coins_list_t['ISSN'] = nil;									-- when error, unset so not included in COinS
			set_message ('err_bad_issn', (options.hkey == 'EISSN') and 'e' or '');	-- create an error message if the ISSN is invalid
		end 
	end
	
	return text;
end


--[[--------------------------&lt; J F M &gt;-----------------------------------------------------------------------

A numerical identifier in the form nn.nnnn.nn

]]

local function jfm (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;

	id_num = id:match ('^[Jj][Ff][Mm](.*)$');									-- identifier with jfm prefix; extract identifier

	if is_set (id_num) then
		set_message ('maint_jfm_format');
	else																		-- plain number without JFM prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num and id_num:match('^%d%d%.%d%d%d%d%.%d%d$') then
		id = id_num;															-- jfm matches pattern
	else
		set_message ('err_bad_jfm' );											-- set an error message
		options.coins_list_t['JFM'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; J S T O R &gt;--------------------------------------------------------------------

Format a JSTOR with some error checking

]]

local function jstor (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;

	if id:find ('[Jj][Ss][Tt][Oo][Rr]') or id:find ('^https?://') or id:find ('%s') then
		set_message ('err_bad_jstor');											-- set an error message
		options.coins_list_t['JSTOR'] = nil;									-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});
end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
http://info-uri.info/registry/OAIHandler?verb=GetRecord&amp;metadataPrefix=reg&amp;identifier=info:lccn/

length = 8 then all digits
length = 9 then lccn[1] is lowercase alpha
length = 10 then lccn[1] and lccn[2] are both lowercase alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lowercase alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lowercase alpha

]]

local function lccn (options)
	local lccn = options.id;
	local handler = options.handler;
	local err_flag;																-- presume that LCCN is valid
	local id = lccn;															-- local copy of the LCCN

	id = normalize_lccn (id);													-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();														-- get the length of the LCCN

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits)
			err_flag = set_message ('err_bad_lccn');							-- set an error message
		end
	elseif 9 == len then														-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then							-- does it match our pattern?
			err_flag = set_message ('err_bad_lccn');							-- set an error message
		end
	elseif 10 == len then														-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then					-- ... see if it matches our pattern
				err_flag = set_message ('err_bad_lccn');						-- no match, set an error message
			end
		end
	elseif 11 == len then														-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_flag = set_message ('err_bad_lccn');							-- no match, set an error message
		end
	elseif 12 == len then														-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then						-- see if it matches our pattern
			err_flag = set_message ('err_bad_lccn');							-- no match, set an error message
		end
	else
		err_flag = set_message ('err_bad_lccn');								-- wrong length, set an error message
	end

	if not is_set (err_flag) and nil ~= lccn:find ('%s') then
		err_flag = set_message ('err_bad_lccn');								-- lccn contains a space, set an error message
	end

	if is_set (err_flag) then
		options.coins_list_t['LCCN'] = nil;										-- when error, unset so not included in COinS
	end

	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = lccn, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; M R &gt;--------------------------------------------------------------------------

A seven digit number; if not seven digits, zero-fill leading digits to make seven digits.

]]

local function mr (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;
	local id_len;

	id_num = id:match ('^[Mm][Rr](%d+)$');										-- identifier with mr prefix

	if is_set (id_num) then
		set_message ('maint_mr_format');										-- add maint cat
	else																		-- plain number without mr prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	id_len = id_num and id_num:len() or 0;
	if (7 &gt;= id_len) and (0 ~= id_len) then
		id = string.rep ('0', 7-id_len) .. id_num;								-- zero-fill leading digits
	else
		set_message ('err_bad_mr');												-- set an error message
		options.coins_list_t['MR'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an OCLC ID.  https://www.oclc.org/batchload/controlnumber.en.html {{dead link}}
archived at: https://web.archive.org/web/20161228233804/https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (options)
	local id = options.id;
	local handler = options.handler;
	local number;

	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- constrain to 1 to 9 digits; change this when OCLC issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if 10 &lt; number:len() then
			number = nil;														-- constrain to 1 to 10 digits; change this when OCLC issues 11-digit numbers
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		set_message ('err_bad_oclc')											-- add an error message if the id is malformed
		options.coins_list_t['OCLC'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local ident, code = id:gsub('^OL', ''):match(&quot;^(%d+([AMW]))$&quot;);				-- strip optional OL prefix followed immediately by digits followed by 'A', 'M', or 'W';
	local err_flag;
	local prefix = {															-- these are appended to the handler.prefix according to code
		['A']='authors/OL',
		['M']='books/OL',
		['W']='works/OL',
		['X']='OL'																-- not a code; spoof when 'code' in id is invalid
		};

	if not ident then
		code = 'X';																-- no code or id completely invalid
		ident = id;																-- copy id to ident so that we display the flawed identifier
		err_flag = set_message ('err_bad_ol');
	end

	if not is_set (err_flag) then
		options.coins_list_t['OL'] = handler.prefix .. prefix[code] .. ident;	-- experiment for ol coins
	else
		options.coins_list_t['OL'] = nil;										-- when error, unset so not included in COinS
	end

	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix .. prefix[code],
		id = ident, separator = handler.separator, encode = handler.encode,
		access = access});
end


--[[--------------------------&lt; O S T I &gt;----------------------------------------------------------------------

Format OSTI and do simple error checking. OSTIs are sequential numbers beginning at 1 and counting up.  This
code checks the OSTI to see that it contains only digits and is less than test_limit specified in the configuration;
the value in test_limit will need to be updated periodically as more OSTIs are issued.

NB. 1018 is the lowest OSTI number found in the wild (so far) and resolving OK on the OSTI site

]]

local function osti (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;

	if id:match(&quot;[^%d]&quot;) then													-- if OSTI has anything but digits
		set_message ('err_bad_osti');											-- set an error message
		options.coins_list_t['OSTI'] = nil;										-- when error, unset so not included in COinS
	else																		-- OSTI is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1018 &gt; id_num or handler.id_limit &lt; id_num then						-- if OSTI is outside test limit boundaries
			set_message ('err_bad_osti');										-- set an error message
			options.coins_list_t['OSTI'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc (options)
	local id = options.id;
	local embargo = options.Embargo;											-- TODO: lowercase?
	local handler = options.handler;
	local err_flag;
	local id_num;
	local text;

	id_num = id:match ('^[Pp][Mm][Cc](%d+)$');									-- identifier with PMC prefix

	if is_set (id_num) then
		set_message ('maint_pmc_format');
	else																		-- plain number without PMC prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if PMC is outside test limit boundaries
			err_flag = set_message ('err_bad_pmc');								-- set an error message
		else
			id = tostring (id_num);												-- make sure id is a string
		end
	else																		-- when id format incorrect
		err_flag = set_message ('err_bad_pmc');									-- set an error message
	end
	
	if is_set (embargo) and is_set (is_embargoed (embargo)) then				-- is PMC is still embargoed?
		text = table.concat (													-- still embargoed so no external link
			{
			make_wikilink (link_label_make (handler), handler.label),
			handler.separator,
			id,
			});
	else
		text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,	-- no embargo date or embargo has expired, ok to link to article
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access,
			auto_link = not err_flag and 'pmc' or nil							-- do not auto-link when PMC has error
			});
	end

	if err_flag then
		options.coins_list_t['PMC'] = nil;										-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid (options)
	local id = options.id;
	local handler = options.handler;

	if id:match(&quot;[^%d]&quot;) then													-- if PMID has anything but digits
		set_message ('err_bad_pmid');											-- set an error message
		options.coins_list_t['PMID'] = nil;										-- when error, unset so not included in COinS
	else																		-- PMID is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if PMID is outside test limit boundaries
			set_message ('err_bad_pmid');										-- set an error message
			options.coins_list_t['PMID'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; R F C &gt;------------------------------------------------------------------------

Format RFC and do simple error checking. RFCs are sequential numbers beginning at 1 and counting up.  This
code checks the RFC to see that it contains only digits and is less than test_limit specified in the configuration;
the value in test_limit will need to be updated periodically as more RFCs are issued.

An index of all RFCs is here: https://tools.ietf.org/rfc/

]]

local function rfc (options)
	local id = options.id;
	local handler = options.handler;

	if id:match(&quot;[^%d]&quot;) then													-- if RFC has anything but digits
		set_message ('err_bad_rfc');											-- set an error message
		options.coins_list_t['RFC'] = nil;										-- when error, unset so not included in COinS
	else																		-- RFC is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if RFC is outside test limit boundaries
			set_message ('err_bad_rfc');										-- set an error message
			options.coins_list_t['RFC'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access});
end


--[[--------------------------&lt; S 2 C I D &gt;--------------------------------------------------------------------

Format an S2CID, do simple error checking

S2CIDs are sequential numbers beginning at 1 and counting up.  This code checks the S2CID to see that it is only
digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically
as more S2CIDs are issued.

]]

local function s2cid (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local id_num;
	local text;
	
	id_num = id:match ('^[1-9]%d*$');											-- id must be all digits; must not begin with 0; no open access flag

 	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if handler.id_limit &lt; id_num then										-- if S2CID is outside test limit boundaries
			set_message ('err_bad_s2cid');										-- set an error message
			options.coins_list_t['S2CID'] = nil;								-- when error, unset so not included in COinS
		end
	else																		-- when id format incorrect
		set_message ('err_bad_s2cid');											-- set an error message
		options.coins_list_t['S2CID'] = nil;									-- when error, unset so not included in COinS
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});

	return text;
end


--[[--------------------------&lt; S B N &gt;------------------------------------------------------------------------

9-digit form of ISBN-10; uses same check-digit validation when SBN is prefixed with an additional '0' to make 10 digits

sbn value not made part of COinS metadata because we don't have a url or isn't a COinS-defined identifier (rft.xxx)
or an identifier registered at info-uri.info (info:)

]]

local function sbn (options)
	local id = options.id;
	local ignore_invalid = options.accept;
	local handler = options.handler;
	local function return_result (check, err_type)								-- local function to handle the various returns
		local SBN = internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,
						prefix = handler.prefix, id = id, separator = handler.separator});
		if not ignore_invalid then												-- if not ignoring SBN errors
			if not check then
				options.coins_list_t['SBN'] = nil;								-- when error, unset so not included in COinS; not really necessary here because sbn not made part of COinS
				set_message ('err_bad_sbn', {err_type});						-- display an error message
				return SBN; 
			end
		else
			set_message ('maint_isbn_ignore');									-- add a maint category even when there is no error (ToDo: Possibly switch to separate message for SBNs only)
		end
		return SBN;
	end

	if id:match ('[^%s-0-9X]') then
		return return_result (false, cfg.err_msg_supl.char);					-- fail if SBN contains anything but digits, hyphens, or the uppercase X
	end

	local ident = id:gsub ('[%s-]', '');										-- remove hyphens and whitespace; they interfere with the rest of the tests

	if  9 ~= ident:len() then
		return return_result (false, cfg.err_msg_supl.length);					-- fail if incorrect length
	end

	if ident:match ('^%d*X?$') == nil then
		return return_result (false, cfg.err_msg_supl.form);					-- fail if SBN has 'X' anywhere but last position
	end

	return return_result (is_valid_isxn ('0' .. ident, 10), cfg.err_msg_supl.check);
end


--[[--------------------------&lt; S S R N &gt;----------------------------------------------------------------------

Format an SSRN, do simple error checking

SSRNs are sequential numbers beginning at 100? and counting up.  This code checks the SSRN to see that it is
only digits and is greater than 99 and less than test_limit; the value in local variable test_limit will need
to be updated periodically as more SSRNs are issued.

]]

local function ssrn (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;
	local text;
	
	id_num = id:match ('^%d+$');												-- id must be all digits

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if 100 &gt; id_num or handler.id_limit &lt; id_num then						-- if SSRN is outside test limit boundaries
			set_message ('err_bad_ssrn');										-- set an error message
			options.coins_list_t['SSRN'] = nil;									-- when error, unset so not included in COinS
		end
	else																		-- when id format incorrect
		set_message ('err_bad_ssrn');											-- set an error message
		options.coins_list_t['SSRN'] = nil;										-- when error, unset so not included in COinS
	end
	
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = options.access});

	return text;
end


--[[--------------------------&lt; U S E N E T _ I D &gt;------------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function usenet_id (options)
	local id = options.id;
	local handler = options.handler;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$') then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		set_message ('err_bad_usenet_id')										-- add an error message if the message id is invalid
		options.coins_list_t['USENETID'] = nil;									-- when error, unset so not included in COinS
	end 
	
	return text;
end


--[[--------------------------&lt; Z B L &gt;-----------------------------------------------------------------------

A numerical identifier in the form nnnn.nnnnn - leading zeros in the first quartet optional

format described here: http://emis.mi.sanu.ac.rs/ZMATH/zmath/en/help/search/

temporary format is apparently eight digits.  Anything else is an error

]]

local function zbl (options)
	local id = options.id;
	local handler = options.handler;

	if id:match('^%d%d%d%d%d%d%d%d$') then										-- is this identifier using temporary format?
		set_message ('maint_zbl');												-- yes, add maint cat
	elseif not id:match('^%d?%d?%d?%d%.%d%d%d%d%d$') then						-- not temporary, is it normal format?
		set_message ('err_bad_zbl');											-- no, set an error message
		options.coins_list_t['ZBL'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--============================&lt;&lt; I N T E R F A C E   F U N C T I O N S &gt;&gt;==========================================

--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message if more than one alias exists in args

]]

local function extract_ids (args)
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs (cfg.id_handlers) do										-- k is uppercase identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one (args, v.parameters, 'err_redundant_parameters' );		-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set (v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; E X T R A C T _ I D _ A C C E S S _ L E V E L S &gt;--------------------------------------

Fetches custom id access levels from arguments using configuration settings. Parameters which have a predefined access
level (e.g. arxiv) do not use this function as they are directly rendered as free without using an additional parameter.

returns a table of k/v pairs where k is same as the identifier's key in cfg.id_handlers and v is the assigned (valid) keyword

access-level values must match the case used in cfg.keywords_lists['id-access'] (lowercase unless there is some special reason for something else)

]]

local function extract_id_access_levels (args, id_list)
	local id_accesses_list = {};
	for k, v in pairs (cfg.id_handlers) do
		local access_param = v.custom_access;									-- name of identifier's access-level parameter
		if is_set (access_param) then
			local access_level = args[access_param];							-- get the assigned value if there is one
			if is_set (access_level) then
				if not in_array (access_level, cfg.keywords_lists['id-access']) then	-- exact match required
					set_message ('err_invalid_param_val', {access_param, access_level});	
					access_level = nil;											-- invalid so unset
				end
				if not is_set (id_list[k]) then									-- identifier access-level must have a matching identifier
					set_message ('err_param_access_requires_param', {k:lower()});	-- parameter name is uppercase in cfg.id_handlers (k); lowercase for error message
				end
				id_accesses_list[k] = cfg.keywords_xlate[access_level];			-- get translated keyword
			end
		end
	end
	return id_accesses_list;
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;----------------------------------------------------

render the identifiers into a sorted sequence table

&lt;ID_list_coins_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value
&lt;options_t&gt; is a table of various k/v option pairs provided in the call to new_build_id_list();
	modified by	this function and passed to all identifier rendering functions
&lt;access_levels_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value (if valid)

returns a sequence table of sorted (by hkey - 'handler' key) rendered identifier strings

]]

local function build_id_list (ID_list_coins_t, options_t, access_levels_t)
	local ID_list_t = {};
	local accept;
	local func_map = {															--function map points to functions associated with hkey identifier
		['ARXIV'] = arxiv,
		['ASIN'] = asin,
		['BIBCODE'] = bibcode,
		['BIORXIV'] = biorxiv,
		['CITESEERX'] = citeseerx,
		['DOI'] = doi,
		['EISSN'] = issn,
		['HDL'] = hdl,
		['ISBN'] = isbn,
		['ISMN'] = ismn,
		['ISSN'] = issn,
		['JFM'] = jfm,
		['JSTOR'] = jstor,
		['LCCN'] = lccn,
		['MR'] = mr,
		['OCLC'] = oclc,
		['OL'] = openlibrary,
		['OSTI'] = osti,
		['PMC'] = pmc,
		['PMID'] = pmid,
		['RFC']  = rfc,
		['S2CID'] = s2cid,
		['SBN'] = sbn,
		['SSRN'] = ssrn,
		['USENETID'] = usenet_id,
		['ZBL'] = zbl,
		}

	for hkey, v in pairs (ID_list_coins_t) do
		v, accept = has_accept_as_written (v);									-- remove accept-as-written markup if present; accept is boolean true when markup removed; false else
																				-- every function gets the options table with value v and accept boolean
		options_t.hkey = hkey;													-- ~/Configuration handler key
		options_t.id = v;														-- add that identifier value to the options table
		options_t.accept = accept;												-- add the accept boolean flag
		options_t.access = access_levels_t[hkey];								-- add the access level for those that have an |&lt;identifier-access= parameter
		options_t.handler = cfg.id_handlers[hkey];
		options_t.coins_list_t = ID_list_coins_t;								-- pointer to ID_list_coins_t; for |asin= and |ol=; also to keep erroneous values out of the citation's metadata
		options_t.coins_list_t[hkey] = v;										-- id value without accept-as-written markup for metadata
		
		if options_t.handler.access and not in_array (options_t.handler.access, cfg.keywords_lists['id-access']) then
			error (cfg.messages['unknown_ID_access'] .. options_t.handler.access);	-- here when handler access key set to a value not listed in list of allowed id access keywords
		end

		if func_map[hkey] then
			local id_text = func_map[hkey] (options_t);							-- call the function to get identifier text and any error message
			table.insert (ID_list_t, {hkey, id_text});							-- add identifier text to the output sequence table
		else
			error (cfg.messages['unknown_ID_key'] .. hkey);						-- here when func_map doesn't have a function for hkey
		end
	end

	local function comp (a, b)													-- used by following table.sort()
		return a[1]:lower() &lt; b[1]:lower();										-- sort by hkey
	end

	table.sort (ID_list_t, comp);												-- sequence table of tables sort	
	for k, v in ipairs (ID_list_t) do											-- convert sequence table of tables to simple sequence table of strings
		ID_list_t[k] = v[2];													-- v[2] is the identifier rendering from the call to the various functions in func_map{}
	end
	
	return ID_list_t;
end


--[[--------------------------&lt; O P T I O N S _ C H E C K &gt;----------------------------------------------------

check that certain option parameters have their associated identifier parameters with values

&lt;ID_list_coins_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value
&lt;ID_support_t&gt; is a sequence table of tables created in citation0() where each subtable has four elements:
	[1] is the support parameter's assigned value; empty string if not set
	[2] is a text string same as key in cfg.id_handlers
	[3] is cfg.error_conditions key used to create error message
	[4] is original ID support parameter name used to create error message
	
returns nothing; on error emits an appropriate error message

]]

local function options_check (ID_list_coins_t, ID_support_t)
	for _, v in ipairs (ID_support_t) do
		if is_set (v[1]) and not ID_list_coins_t[v[2]] then						-- when support parameter has a value but matching identifier parameter is missing or empty
			set_message (v[3], (v[4]));											-- emit the appropriate error message
		end
	end
end


--[[--------------------------&lt; I D E N T I F I E R _ L I S T S _ G E T &gt;--------------------------------------

Creates two identifier lists: a k/v table of identifiers and their values to be used locally and for use in the
COinS metadata, and a sequence table of the rendered identifier strings that will be included in the rendered
citation.

]]

local function identifier_lists_get (args_t, options_t, ID_support_t)
	local ID_list_coins_t = extract_ids (args_t);										-- get a table of identifiers and their values for use locally and for use in COinS
	options_check (ID_list_coins_t, ID_support_t);										-- ID support parameters must have matching identifier parameters 
	local ID_access_levels_t = extract_id_access_levels (args_t, ID_list_coins_t);		-- get a table of identifier access levels
	local ID_list_t = build_id_list (ID_list_coins_t, options_t, ID_access_levels_t);	-- get a sequence table of rendered identifier strings

	return ID_list_t, ID_list_coins_t;											-- return the tables
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	has_accept_as_written = utilities_page_ptr.has_accept_as_written;			-- import functions from select Module:Citation/CS1/Utilities module
	is_set = utilities_page_ptr.is_set;								
	in_array = utilities_page_ptr.in_array;
	set_message = utilities_page_ptr.set_message;
	select_one = utilities_page_ptr.select_one;
	substitute = utilities_page_ptr.substitute;
	make_wikilink = utilities_page_ptr.make_wikilink;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	auto_link_urls = auto_link_urls,											-- table of identifier URLs to be used when auto-linking |title=
	
	identifier_lists_get = identifier_lists_get,								-- experiment to replace individual calls to build_id_list(), extract_ids, extract_id_access_levels
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>1s53aqur5zcnnjyu0azfrtjq6dyiwg4</sha1>
    </revision>
    <revision>
      <id>4921</id>
      <parentid>4920</parentid>
      <timestamp>2023-01-14T14:43:38Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4921</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="73844" sha1="epcxjm1e7vnxg0m69646hxwauvwdfwq" xml:space="preserve">--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local has_accept_as_written, is_set, in_array, set_message, select_one,			-- functions in Module:Citation/CS1/Utilities
		substitute, make_wikilink;

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

declare variables here that have page-wide scope that are not brought in from other modules; that are created here and used here

]]

local auto_link_urls = {};														-- holds identifier URLs for those identifiers that can auto-link |title=


--============================&lt;&lt; H E L P E R   F U N C T I O N S &gt;&gt;============================================

--[[--------------------------&lt; W I K I D A T A _ A R T I C L E _ N A M E _ G E T &gt;----------------------------

as an aid to internationalizing identifier-label wikilinks, gets identifier article names from Wikidata.

returns :&lt;lang code&gt;:&lt;article title&gt; when &lt;q&gt; has an &lt;article title&gt; for &lt;lang code&gt;; nil else

for identifiers that do not have q, returns nil

for wikis that do not have mw.wikibase installed, returns nil

]]

local function wikidata_article_name_get (q)
	if not is_set (q) or (q and not mw.wikibase) then							-- when no q number or when a q number but mw.wikibase not installed on this wiki
		return nil;																-- abandon
	end

	local wd_article;
	local this_wiki_code = cfg.this_wiki_code;									-- Wikipedia subdomain; 'en' for en.wikipedia.org

	wd_article = mw.wikibase.getSitelink (q, this_wiki_code .. 'wiki');			-- fetch article title from WD; nil when no title available at this wiki

	if wd_article then
		wd_article = table.concat ({':', this_wiki_code, ':', wd_article});		-- interwiki-style link without brackets if taken from WD; leading colon required
	end

	return wd_article;															-- article title from WD; nil else
end


--[[--------------------------&lt; L I N K _ L A B E L _ M A K E &gt;------------------------------------------------

common function to create identifier link label from handler table or from Wikidata

returns the first available of
	1. redirect from local wiki's handler table (if enabled)
	2. Wikidata (if there is a Wikidata entry for this identifier in the local wiki's language)
	3. label specified in the local wiki's handler table
	
]]

local function link_label_make (handler)
	local wd_article;
	
	if not (cfg.use_identifier_redirects and is_set (handler.redirect)) then	-- redirect has priority so if enabled and available don't fetch from Wikidata because expensive
		wd_article = wikidata_article_name_get (handler.q);						-- if Wikidata has an article title for this wiki, get it;
	end
	
	return (cfg.use_identifier_redirects and is_set (handler.redirect) and handler.redirect) or wd_article or handler.link;
end


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki-style external link

]]

local function external_link_id (options)
	local url_string = options.id;
	local ext_link;
	local this_wiki_code = cfg.this_wiki_code;									-- Wikipedia subdomain; 'en' for en.wikipedia.org
	local wd_article;															-- article title from Wikidata
	
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode (url_string, 'PATH');
	end

	if options.auto_link and is_set (options.access) then
		auto_link_urls[options.auto_link] = table.concat ({options.prefix, url_string, options.suffix});
	end

	ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or &quot;&quot;, mw.text.nowiki (options.id));
	if is_set (options.access) then
		ext_link = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[options.access].class, cfg.presentation[options.access].title, ext_link});	-- add the free-to-read / paywall lock
	end

	return table.concat	({
		make_wikilink (link_label_make (options), options.label),				-- redirect, Wikidata link, or locally specified link (in that order)
		options.separator or '&amp;nbsp;',
		ext_link
		});
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki-style internal link

TODO: Does not currently need to support options.access, options.encode, auto-linking and COinS (as in external_link_id),
but may be needed in the future for :m:Interwiki_map custom-prefixes like :arxiv:, :bibcode:, :DOI:, :hdl:, :ISSN:,
:JSTOR:, :Openlibrary:, :PMID:, :RFC:.

]]

local function internal_link_id (options)
	local id = mw.ustring.gsub (options.id, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9

	return table.concat (
		{
		make_wikilink (link_label_make (options), options.label),				-- wiki-link the identifier label
		options.separator or '&amp;nbsp;',											-- add the separator
		make_wikilink (
			table.concat (
				{
				options.prefix,
				id,																-- translated to Western digits
				options.suffix or ''
				}),
			substitute (cfg.presentation['bdi'], {'', mw.text.nowiki (options.id)})	-- bdi tags to prevent Latin script identifiers from being reversed at RTL language wikis
			);																	-- nowiki because MediaWiki still has magic links for ISBN and the like; TODO: is it really required?
		});
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |pmc-embargo-date= against
today's date.  If embargo date is in the future, returns the content of |pmc-embargo-date=; otherwise, returns
an empty string because the embargo has expired or because |pmc-embargo-date= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, todays_date;
		good1, embargo_date = pcall (lang.formatDate, lang, 'U', embargo);
		todays_date = lang:formatDate ('U');
	
		if good1 then															-- if embargo date is a good date
			if tonumber (embargo_date) &gt;= tonumber (todays_date) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				set_message ('maint_pmc_embargo');								-- embargo has expired; add main cat
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |pmc-embargo-date= not set return empty string
end


--[=[-------------------------&lt; I S _ V A L I D _ B I O R X I V _ D A T E &gt;------------------------------------

returns true if:
	2019-12-11T00:00Z &lt;= biorxiv_date &lt; today + 2 days
	
The dated form of biorxiv identifier has a start date of 2019-12-11.  The Unix timestamp for that date is {{#time:U|2019-12-11}} = 1576022400

biorxiv_date is the date provided in those |biorxiv= parameter values that are dated at time 00:00:00 UTC
today is the current date at time 00:00:00 UTC plus 48 hours
	if today is 2015-01-01T00:00:00 then
		adding 24 hours gives 2015-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2015-01-03T00:00:00 – one second more than tomorrow

This function does not work if it is fed month names for languages other than English.  Wikimedia #time: parser
apparently doesn't understand non-English date month names. This function will always return false when the date
contains a non-English month name because good1 is false after the call to lang_object.formatDate().  To get
around that call this function with date parts and create a YYYY-MM-DD format date.

]=]

local function is_valid_biorxiv_date (y, m, d)
	local biorxiv_date = table.concat ({y, m, d}, '-');							-- make ymd date
	local good1, good2;
	local biorxiv_ts, tomorrow_ts;												-- to hold Unix timestamps representing the dates
	local lang_object = mw.getContentLanguage();

	good1, biorxiv_ts = pcall (lang_object.formatDate, lang_object, 'U', biorxiv_date);		-- convert biorxiv_date value to Unix timestamp 
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which tonumber() may not understand
		biorxiv_ts = tonumber (biorxiv_ts) or lang_object:parseFormattedNumber (biorxiv_ts);	-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to Unix timestamp
	end

	return ((1576022400 &lt;= biorxiv_ts) and (biorxiv_ts &lt; tomorrow_ts))			-- 2012-12-11T00:00Z &lt;= biorxiv_date &lt; tomorrow's date
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all ISBN/ISSN digits including the check digit.
ISBN-13 is checked in isbn().

If the number is valid the result will be 0. Before calling this function, ISBN/ISSN must be checked for length
and stripped of dashes, spaces and other non-ISxN characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39, 'X' → 0x58
	len = len + 1;																-- adjust to be a loop counter
	for i, v in ipairs (isxn_str) do											-- loop through all of the bytes and calculate the checksum
		if v == string.byte (&quot;X&quot; ) then											-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10 * (len - i);										-- it represents 10 decimal
		else
			temp = temp + tonumber (string.char (v) )*(len-i);
		end
	end
	return temp % 11 == 0;														-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N _ 1 3 &gt;-----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 ISBN/ISMN digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, ISBN-13/ISMN must be checked for length
and stripped of dashes, spaces and other non-ISxN-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39
	for i, v in ipairs (isxn_str) do
		temp = temp + (3 - 2*(i % 2)) * tonumber (string.char (v) );			-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when ISBN-13/ISMN is correct
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

LCCN normalization (https://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized LCCN for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.

]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);												-- 1. strip whitespace

	if nil ~= string.find (lccn, '/') then
		lccn = lccn:match (&quot;(.-)/&quot;);											-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);									-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then														-- if there was a hyphen
		suffix = string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;				-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn = prefix..suffix;													-- reassemble the LCCN
	end
	
	return lccn;
	end


--============================&lt;&lt; I D E N T I F I E R   F U N C T I O N S &gt;&gt;====================================

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: https://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9107 and 0703, is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation; not the same as |class= parameter which is not supported in this form
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number

]]

local function arxiv (options)
	local id = options.id;
	local class = options.Class;												-- TODO: lowercase?
	local handler = options.handler;
	local year, month, version;
	local err_msg = false;														-- assume no error message
	local text;																	-- output text
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9107-0703 format with or without version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_msg = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 with or without version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then									-- when year is 07, is month invalid (before April)?
				err_msg = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format with or without version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_msg = true;														-- flag for error message
		end

	else
		err_msg = true;															-- not a recognized format; flag for error message
	end

	if err_msg then
		options.coins_list_t['ARXIV'] = nil;									-- when error, unset so not included in COinS
	end
	
	local err_msg_t = {};
	if err_msg then
		set_message ('err_bad_arxiv');
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access});

	if is_set (class) then
		if id:match ('^%d+') then
			text = table.concat ({text, ' [[//arxiv.org/archive/', class, ' ', class, ']]'});	-- external link within square brackets, not wikilink
		else
			set_message ('err_class_ignored');
		end
	end

	return text;
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode ID.

Format for bibcodes is specified here: https://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		9–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local err_type;
	local err_msg = '';
	local year;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode,
		access = access});
	
	if 19 ~= id:len() then
		err_type = cfg.err_msg_supl.length;
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%w&amp;%.][%w&amp;%.][%w&amp;%.][%w.]+[%a%.]$&quot;);
		if not year then														-- if nil then no pattern match
			err_type = cfg.err_msg_supl.value;									-- so value error
		else
			local next_year = tonumber (os.date ('%Y')) + 1;					-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = cfg.err_msg_supl.year;								-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = cfg.err_msg_supl.journal;							-- journal abbreviation must not have '&amp;.' (if it does it's missing a letter)
			end
		end
	end

	if is_set (err_type) then													-- if there was an error detected
		set_message ('err_bad_bibcode', {err_type});
		options.coins_list_t['BIBCODE'] = nil;									-- when error, unset so not included in COinS

	end

	return text;
end


--[[--------------------------&lt; B I O R X I V &gt;-----------------------------------------------------------------

Format bioRxiv ID and do simple error checking.  Before 2019-12-11, biorXiv IDs were 10.1101/ followed by exactly
6 digits.  After 2019-12-11, biorXiv IDs retained the six-digit identifier but prefixed that with a yyyy.mm.dd. 
date and suffixed with an optional version identifier.

The bioRxiv ID is the string of characters:
	https://doi.org/10.1101/078733 -&gt; 10.1101/078733
or a date followed by a six-digit number followed by an optional version indicator 'v' and one or more digits:
	https://www.biorxiv.org/content/10.1101/2019.12.11.123456v2 -&gt; 10.1101/2019.12.11.123456v2
	
see https://www.biorxiv.org/about-biorxiv

]]

local function biorxiv (options)
	local id = options.id;
	local handler = options.handler;
	local err_msg = true;														-- flag; assume that there will be an error
	
	local patterns = {
		'^10.1101/%d%d%d%d%d%d$',												-- simple 6-digit identifier (before 2019-12-11)
		'^10.1101/(20[1-9]%d)%.([01]%d)%.([0-3]%d)%.%d%d%d%d%d%dv%d+$',			-- y.m.d. date + 6-digit identifier + version (after 2019-12-11)
		'^10.1101/(20[1-9]%d)%.([01]%d)%.([0-3]%d)%.%d%d%d%d%d%d$',				-- y.m.d. date + 6-digit identifier (after 2019-12-11)
		}
	
	for _, pattern in ipairs (patterns) do										-- spin through the patterns looking for a match
		if id:match (pattern) then
			local y, m, d = id:match (pattern);									-- found a match, attempt to get year, month and date from the identifier

			if m then															-- m is nil when id is the six-digit form
				if not is_valid_biorxiv_date (y, m, d) then						-- validate the encoded date; TODO: don't ignore leap-year and actual month lengths ({{#time:}} is a poor date validator)
					break;														-- date fail; break out early so we don't unset the error message
				end
			end
			err_msg = nil;														-- we found a match so unset the error message
			break;																-- and done
		end
	end																			-- err_cat remains set here when no match

	if err_msg then
		options.coins_list_t['BIORXIV'] = nil;									-- when error, unset so not included in COinS
		set_message ('err_bad_biorxiv');										-- and set the error message
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator,
			encode = handler.encode, access = handler.access});
end


--[[--------------------------&lt; C I T E S E E R X &gt;------------------------------------------------------------

CiteSeerX use their own notion of &quot;doi&quot; (not to be confused with the identifiers resolved via doi.org).

The description of the structure of this identifier can be found at Help_talk:Citation_Style_1/Archive_26#CiteSeerX_id_structure

]]

local function citeseerx (options)
	local id = options.id;
	local handler = options.handler;
	local matched;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode,
		access = handler.access});
	
	matched = id:match (&quot;^10%.1%.1%.[1-9]%d?%d?%d?%.[1-9]%d?%d?%d?$&quot;);
	if not matched then
		set_message ('err_bad_citeseerx' );
		options.coins_list_t['CITESEERX'] = nil;								-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the DOI name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in DOI names.

https://www.doi.org/doi_handbook/2_Numbering.html				-- 2.2 Syntax of a DOI name
https://www.doi.org/doi_handbook/2_Numbering.html#2.2.2			-- 2.2.2 DOI prefix

]]

local function doi (options)
	local id = options.id;
	local inactive = options.DoiBroken
	local access = options.access;
	local ignore_invalid = options.accept;
	local handler = options.handler;
	local err_flag;

	local text;
	if is_set (inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;) or '';					-- try to get the year portion from the inactive date
		local inactive_month, good;

		if is_set (inactive_year) then
			if 4 &lt; inactive:len() then											-- inactive date has more than just a year (could be anything)
				local lang_obj = mw.getContentLanguage();						-- get a language object for this wiki
				good, inactive_month = pcall (lang_obj.formatDate, lang_obj, 'F', inactive);	-- try to get the month name from the inactive date
				if not good then
					inactive_month = nil;										-- something went wrong so make sure this is unset
				end
			end
		else
			inactive_year = nil;												-- |doi-broken-date= has something but it isn't a date
		end
		
		if is_set (inactive_year) and is_set (inactive_month) then
			set_message ('maint_doi_inactive_dated', {inactive_year, inactive_month, ' '});
		elseif is_set (inactive_year) then
			set_message ('maint_doi_inactive_dated', {inactive_year, '', ''});
		else
			set_message ('maint_doi_inactive');
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. ' ' .. inactive .. ')';
	end

	local registrant = mw.ustring.match (id, '^10%.([^/]+)/[^%s–]-[^%.,]$');	-- registrant set when DOI has the proper basic form

	local registrant_err_patterns = {											-- these patterns are for code ranges that are not supported 
		'^[^1-3]%d%d%d%d%.%d%d*$',												-- 5 digits with subcode (0xxxx, 40000+); accepts: 10000–39999
		'^[^1-5]%d%d%d%d$',														-- 5 digits without subcode (0xxxx, 60000+); accepts: 10000–59999
		'^[^1-9]%d%d%d%.%d%d*$',												-- 4 digits with subcode (0xxx); accepts: 1000–9999
		'^[^1-9]%d%d%d$',														-- 4 digits without subcode (0xxx); accepts: 1000–9999
		'^%d%d%d%d%d%d+',														-- 6 or more digits
		'^%d%d?%d?$',															-- less than 4 digits without subcode (3 digits with subcode is legitimate)
		'^%d%d?%.[%d%.]+',														-- 1 or 2 digits with subcode
		'^5555$',																-- test registrant will never resolve
		'[^%d%.]',																-- any character that isn't a digit or a dot
		}

	if not ignore_invalid then
		if registrant then														-- when DOI has proper form
			for i, pattern in ipairs (registrant_err_patterns) do				-- spin through error patterns
				if registrant:match (pattern) then								-- to validate registrant codes
					err_flag = set_message ('err_bad_doi');						-- when found, mark this DOI as bad
					break;														-- and done
				end
			end
		else
			err_flag = set_message ('err_bad_doi');								-- invalid directory or malformed
		end
	else
		set_message ('maint_doi_ignore');
	end

	if err_flag then
		options.coins_list_t['DOI'] = nil;										-- when error, unset so not included in COinS
	end
	
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access,
		auto_link = not (err_flag or is_set (inactive) or ignore_invalid) and 'doi' or nil -- do not auto-link when |doi-broken-date= has a value or when there is a DOI error or (to play it safe, after all, auto-linking is not essential) when invalid DOIs are ignored
		}) .. (inactive or '');

	return text;
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

Query string parameters are named here: https://www.handle.net/proxy_servlet.html.  query strings are not displayed
but since '?' is an allowed character in an HDL, '?' followed by one of the query parameters is the only way we
have to detect the query string so that it isn't URL-encoded with the rest of the identifier.

]]

local function hdl (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local query_params = {														-- list of known query parameters from https://www.handle.net/proxy_servlet.html
		'noredirect',
		'ignore_aliases',
		'auth',
		'cert',
		'index',
		'type',
		'urlappend',
		'locatt',
		'action',
		}
	
	local hdl, suffix, param = id:match ('(.-)(%?(%a+).+)$');					-- look for query string
	local found;

	if hdl then																	-- when there are query strings, this is the handle identifier portion
		for _, q in ipairs (query_params) do									-- spin through the list of query parameters
			if param:match ('^' .. q) then										-- if the query string begins with one of the parameters
				found = true;													-- announce a find
				break;															-- and stop looking
			end
		end
	end

	if found then
		id = hdl;																-- found so replace id with the handle portion; this will be URL-encoded, suffix will not
	else
		suffix = '';															-- make sure suffix is empty string for concatenation else
	end

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, suffix = suffix, separator = handler.separator, encode = handler.encode, access = access})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- HDL must contain a forward slash, must not contain spaces, endashes, and must not end with period or comma
		set_message ('err_bad_hdl' );
		options.coins_list_t['HDL'] = nil;										-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; I S B N &gt;----------------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function isbn (options)
	local isbn_str = options.id;
	local ignore_invalid = options.accept;
	local handler = options.handler;

	local function return_result (check, err_type)								-- local function to handle the various returns
		local ISBN = internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,
						prefix = handler.prefix, id = isbn_str, separator = handler.separator});
		if ignore_invalid then													-- if ignoring ISBN errors
			set_message ('maint_isbn_ignore');									-- add a maint category even when there is no error
		else																	-- here when not ignoring
			if not check then													-- and there is an error
				options.coins_list_t['ISBN'] = nil;								-- when error, unset so not included in COinS
				set_message ('err_bad_isbn', err_type);							-- set an error message
				return ISBN;										 			-- return id text
			end
		end
		return ISBN;															-- return id text
	end

	if nil ~= isbn_str:match ('[^%s-0-9X]') then
		return return_result (false, cfg.err_msg_supl.char);					-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end

	local id = isbn_str:gsub ('[%s-]', '');										-- remove hyphens and whitespace

	local len = id:len();
 
	if len ~= 10 and len ~= 13 then
		return return_result (false, cfg.err_msg_supl.length);					-- fail if incorrect length
	end

	if len == 10 then
		if id:match ('^%d*X?$') == nil then										-- fail if isbn_str has 'X' anywhere but last position
			return return_result (false, cfg.err_msg_supl.form);									
		end
		if not is_valid_isxn (id, 10) then										-- test isbn-10 for numerical validity
			return return_result (false, cfg.err_msg_supl.check);				-- fail if isbn-10 is not numerically valid
		end
		if id:find ('^63[01]') then												-- 630xxxxxxx and 631xxxxxxx are (apparently) not valid isbn group ids but are used by amazon as numeric identifiers (asin)
			return return_result (false, cfg.err_msg_supl.group);				-- fail if isbn-10 begins with 630/1
		end
		return return_result (true, cfg.err_msg_supl.check);					-- pass if isbn-10 is numerically valid
	else
		if id:match ('^%d+$') == nil then
			return return_result (false, cfg.err_msg_supl.char);				-- fail if ISBN-13 is not all digits
		end
		if id:match ('^97[89]%d*$') == nil then
			return return_result (false, cfg.err_msg_supl.prefix);				-- fail when ISBN-13 does not begin with 978 or 979
		end
		if id:match ('^9790') then
			return return_result (false, cfg.err_msg_supl.group);				-- group identifier '0' is reserved to ISMN
		end
		return return_result (is_valid_isxn_13 (id), cfg.err_msg_supl.check);
	end
end


--[[--------------------------&lt; A S I N &gt;----------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: ASIN must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, ASINs must be 10-digit
ISBN. If 10-digit ISBN, add a maintenance category so a bot or AWB script can replace |asin= with |isbn=.
Error message if not 10 characters, if not ISBN-10, if mixed and first character is a digit.

|asin=630....... and |asin=631....... are (apparently) not a legitimate ISBN though it checksums as one; these
do not cause this function to emit the maint_asin message

This function is positioned here because it calls isbn()

]]

local function asin (options)
	local id = options.id;
	local domain = options.ASINTLD;
	
	local err_flag;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_flag = set_message ('err_bad_asin');								-- ASIN is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then							-- if 10-digit numeric (or 9 digits with terminal X)
			if is_valid_isxn (id, 10) then										-- see if ASIN value is or validates as ISBN-10
				if not id:find ('^63[01]') then									-- 630xxxxxxx and 631xxxxxxx are (apparently) not a valid isbn prefixes but are used by amazon as a numeric identifier
					err_flag = set_message ('err_bad_asin');					-- ASIN has ISBN-10 form but begins with something other than 630/1 so probably an isbn 
				end
			elseif not is_set (err_flag) then
				err_flag = set_message ('err_bad_asin');						-- ASIN is not ISBN-10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_flag = set_message ('err_bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if (not is_set (domain)) or in_array (domain, {'us'}) then					-- default: United States
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then									-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'z.cn'}) then 									-- China
		domain = &quot;cn&quot;;
	elseif in_array (domain, {'au', 'br', 'mx', 'sg', 'tr'}) then				-- Australia, Brazil, Mexico, Singapore, Turkey
		domain = &quot;com.&quot; .. domain;
	elseif not in_array (domain, {'ae', 'ca', 'cn', 'de', 'es', 'fr', 'in', 'it', 'nl', 'pl', 'sa', 'se', 'co.jp', 'co.uk', 'com', 'com.au', 'com.br', 'com.mx', 'com.sg', 'com.tr'}) then -- Arabic Emirates, Canada, China, Germany, Spain, France, Indonesia, Italy, Netherlands, Poland, Saudi Arabia, Sweden (as of 2021-03 Austria (.at), Liechtenstein (.li) and Switzerland (.ch) still redirect to the German site (.de) with special settings, so don't maintain local ASINs for them)
		err_flag = set_message ('err_bad_asin_tld');							-- unsupported asin-tld value
	end
	local handler = options.handler;

	if not is_set (err_flag) then
		options.coins_list_t['ASIN'] = handler.prefix .. domain .. &quot;/dp/&quot; .. id;	-- asin for coins
	else
		options.coins_list_t['ASIN'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix .. domain .. &quot;/dp/&quot;,
		id = id, encode = handler.encode, separator = handler.separator})
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to ISBN-13, ISMN is 13 digits beginning 979-0-... and uses the
same check digit calculations.  See https://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

ismn value not made part of COinS metadata because we don't have a url or isn't a COinS-defined identifier (rft.xxx)
or an identifier registered at info-uri.info (info:)

]]

local function ismn (options)
	local id = options.id;
	local handler = options.handler;
	local text;
	local valid_ismn = true;
	local id_copy;

	id_copy = id;																-- save a copy because this testing is destructive
	id = id:gsub ('[%s-]', '');													-- remove hyphens and white space

	if 13 ~= id:len() or id:match (&quot;^9790%d*$&quot; ) == nil then					-- ISMN must be 13 digits and begin with 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ISMN
	end

	--	text = internal_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,		-- use this (or external version) when there is some place to link to
	--		prefix = handler.prefix, id = id_copy, separator = handler.separator, encode = handler.encode})

	text = table.concat (														-- because no place to link to yet
		{
		make_wikilink (link_label_make (handler), handler.label),
		handler.separator,
		id_copy
		});

	if false == valid_ismn then
		options.coins_list_t['ISMN'] = nil;										-- when error, unset so not included in COinS; not really necessary here because ismn not made part of COinS
		set_message ('err_bad_ismn');											-- create an error message if the ISMN is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an ISSN.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [https://www.worldcat.org/issn/0819 4327 0819 4327]	-- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the ISSN midpoint.  It also validates the ISSN for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check ISSN error message.  The
ISSN is always displayed with a hyphen, even if the ISSN was given as a single group of 8 digits.

]]

local function issn (options)
	local id = options.id;
	local handler = options.handler;
	local ignore_invalid = options.accept;

	local issn_copy = id;														-- save a copy of unadulterated ISSN; use this version for display if ISSN does not validate
	local text;
	local valid_issn = true;

	id = id:gsub ('[%s-]', '');													-- remove hyphens and whitespace

	if 8 ~= id:len() or nil == id:match (&quot;^%d*X?$&quot; ) then						-- validate the ISSN: 8 digits long, containing only 0-9 or X in the last position
		valid_issn = false;														-- wrong length or improper character
	else
		valid_issn = is_valid_isxn (id, 8);										-- validate ISSN
	end

	if true == valid_issn then
		id = string.sub (id, 1, 4 ) .. &quot;-&quot; .. string.sub (id, 5 );				-- if valid, display correctly formatted version
	else
		id = issn_copy;															-- if not valid, show the invalid ISSN with error message
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode})

	if ignore_invalid then
		set_message ('maint_issn_ignore');
	else
		if false == valid_issn then
			options.coins_list_t['ISSN'] = nil;									-- when error, unset so not included in COinS
			set_message ('err_bad_issn', (options.hkey == 'EISSN') and 'e' or '');	-- create an error message if the ISSN is invalid
		end 
	end
	
	return text;
end


--[[--------------------------&lt; J F M &gt;-----------------------------------------------------------------------

A numerical identifier in the form nn.nnnn.nn

]]

local function jfm (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;

	id_num = id:match ('^[Jj][Ff][Mm](.*)$');									-- identifier with jfm prefix; extract identifier

	if is_set (id_num) then
		set_message ('maint_jfm_format');
	else																		-- plain number without JFM prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num and id_num:match('^%d%d%.%d%d%d%d%.%d%d$') then
		id = id_num;															-- jfm matches pattern
	else
		set_message ('err_bad_jfm' );											-- set an error message
		options.coins_list_t['JFM'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; J S T O R &gt;--------------------------------------------------------------------

Format a JSTOR with some error checking

]]

local function jstor (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;

	if id:find ('[Jj][Ss][Tt][Oo][Rr]') or id:find ('^https?://') or id:find ('%s') then
		set_message ('err_bad_jstor');											-- set an error message
		options.coins_list_t['JSTOR'] = nil;									-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});
end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
https://oclc-research.github.io/infoURI-Frozen/info-uri.info/info:lccn/reg.html

length = 8 then all digits
length = 9 then lccn[1] is lowercase alpha
length = 10 then lccn[1] and lccn[2] are both lowercase alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lowercase alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lowercase alpha

]]

local function lccn (options)
	local lccn = options.id;
	local handler = options.handler;
	local err_flag;																-- presume that LCCN is valid
	local id = lccn;															-- local copy of the LCCN

	id = normalize_lccn (id);													-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();														-- get the length of the LCCN

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits)
			err_flag = set_message ('err_bad_lccn');							-- set an error message
		end
	elseif 9 == len then														-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then							-- does it match our pattern?
			err_flag = set_message ('err_bad_lccn');							-- set an error message
		end
	elseif 10 == len then														-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then					-- ... see if it matches our pattern
				err_flag = set_message ('err_bad_lccn');						-- no match, set an error message
			end
		end
	elseif 11 == len then														-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_flag = set_message ('err_bad_lccn');							-- no match, set an error message
		end
	elseif 12 == len then														-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then						-- see if it matches our pattern
			err_flag = set_message ('err_bad_lccn');							-- no match, set an error message
		end
	else
		err_flag = set_message ('err_bad_lccn');								-- wrong length, set an error message
	end

	if not is_set (err_flag) and nil ~= lccn:find ('%s') then
		err_flag = set_message ('err_bad_lccn');								-- lccn contains a space, set an error message
	end

	if is_set (err_flag) then
		options.coins_list_t['LCCN'] = nil;										-- when error, unset so not included in COinS
	end

	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = lccn, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; M R &gt;--------------------------------------------------------------------------

A seven digit number; if not seven digits, zero-fill leading digits to make seven digits.

]]

local function mr (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;
	local id_len;

	id_num = id:match ('^[Mm][Rr](%d+)$');										-- identifier with mr prefix

	if is_set (id_num) then
		set_message ('maint_mr_format');										-- add maint cat
	else																		-- plain number without mr prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	id_len = id_num and id_num:len() or 0;
	if (7 &gt;= id_len) and (0 ~= id_len) then
		id = string.rep ('0', 7-id_len) .. id_num;								-- zero-fill leading digits
	else
		set_message ('err_bad_mr');												-- set an error message
		options.coins_list_t['MR'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an OCLC ID.  https://www.oclc.org/batchload/controlnumber.en.html {{dead link}}
archived at: https://web.archive.org/web/20161228233804/https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (options)
	local id = options.id;
	local handler = options.handler;
	local number;

	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- constrain to 1 to 9 digits; change this when OCLC issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if 10 &lt; number:len() then
			number = nil;														-- constrain to 1 to 10 digits; change this when OCLC issues 11-digit numbers
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		set_message ('err_bad_oclc')											-- add an error message if the id is malformed
		options.coins_list_t['OCLC'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local ident, code = id:gsub('^OL', ''):match(&quot;^(%d+([AMW]))$&quot;);				-- strip optional OL prefix followed immediately by digits followed by 'A', 'M', or 'W';
	local err_flag;
	local prefix = {															-- these are appended to the handler.prefix according to code
		['A']='authors/OL',
		['M']='books/OL',
		['W']='works/OL',
		['X']='OL'																-- not a code; spoof when 'code' in id is invalid
		};

	if not ident then
		code = 'X';																-- no code or id completely invalid
		ident = id;																-- copy id to ident so that we display the flawed identifier
		err_flag = set_message ('err_bad_ol');
	end

	if not is_set (err_flag) then
		options.coins_list_t['OL'] = handler.prefix .. prefix[code] .. ident;	-- experiment for ol coins
	else
		options.coins_list_t['OL'] = nil;										-- when error, unset so not included in COinS
	end

	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix .. prefix[code],
		id = ident, separator = handler.separator, encode = handler.encode,
		access = access});
end


--[[--------------------------&lt; O S T I &gt;----------------------------------------------------------------------

Format OSTI and do simple error checking. OSTIs are sequential numbers beginning at 1 and counting up.  This
code checks the OSTI to see that it contains only digits and is less than test_limit specified in the configuration;
the value in test_limit will need to be updated periodically as more OSTIs are issued.

NB. 1018 is the lowest OSTI number found in the wild (so far) and resolving OK on the OSTI site

]]

local function osti (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;

	if id:match(&quot;[^%d]&quot;) then													-- if OSTI has anything but digits
		set_message ('err_bad_osti');											-- set an error message
		options.coins_list_t['OSTI'] = nil;										-- when error, unset so not included in COinS
	else																		-- OSTI is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1018 &gt; id_num or handler.id_limit &lt; id_num then						-- if OSTI is outside test limit boundaries
			set_message ('err_bad_osti');										-- set an error message
			options.coins_list_t['OSTI'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc (options)
	local id = options.id;
	local embargo = options.Embargo;											-- TODO: lowercase?
	local handler = options.handler;
	local err_flag;
	local id_num;
	local text;

	id_num = id:match ('^[Pp][Mm][Cc](%d+)$');									-- identifier with PMC prefix

	if is_set (id_num) then
		set_message ('maint_pmc_format');
	else																		-- plain number without PMC prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if PMC is outside test limit boundaries
			err_flag = set_message ('err_bad_pmc');								-- set an error message
		else
			id = tostring (id_num);												-- make sure id is a string
		end
	else																		-- when id format incorrect
		err_flag = set_message ('err_bad_pmc');									-- set an error message
	end
	
	if is_set (embargo) and is_set (is_embargoed (embargo)) then				-- is PMC is still embargoed?
		text = table.concat (													-- still embargoed so no external link
			{
			make_wikilink (link_label_make (handler), handler.label),
			handler.separator,
			id,
			});
	else
		text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,	-- no embargo date or embargo has expired, ok to link to article
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access,
			auto_link = not err_flag and 'pmc' or nil							-- do not auto-link when PMC has error
			});
	end

	if err_flag then
		options.coins_list_t['PMC'] = nil;										-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid (options)
	local id = options.id;
	local handler = options.handler;

	if id:match(&quot;[^%d]&quot;) then													-- if PMID has anything but digits
		set_message ('err_bad_pmid');											-- set an error message
		options.coins_list_t['PMID'] = nil;										-- when error, unset so not included in COinS
	else																		-- PMID is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if PMID is outside test limit boundaries
			set_message ('err_bad_pmid');										-- set an error message
			options.coins_list_t['PMID'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; R F C &gt;------------------------------------------------------------------------

Format RFC and do simple error checking. RFCs are sequential numbers beginning at 1 and counting up.  This
code checks the RFC to see that it contains only digits and is less than test_limit specified in the configuration;
the value in test_limit will need to be updated periodically as more RFCs are issued.

An index of all RFCs is here: https://tools.ietf.org/rfc/

]]

local function rfc (options)
	local id = options.id;
	local handler = options.handler;

	if id:match(&quot;[^%d]&quot;) then													-- if RFC has anything but digits
		set_message ('err_bad_rfc');											-- set an error message
		options.coins_list_t['RFC'] = nil;										-- when error, unset so not included in COinS
	else																		-- RFC is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if RFC is outside test limit boundaries
			set_message ('err_bad_rfc');										-- set an error message
			options.coins_list_t['RFC'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access});
end


--[[--------------------------&lt; S 2 C I D &gt;--------------------------------------------------------------------

Format an S2CID, do simple error checking

S2CIDs are sequential numbers beginning at 1 and counting up.  This code checks the S2CID to see that it is only
digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically
as more S2CIDs are issued.

]]

local function s2cid (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local id_num;
	local text;
	
	id_num = id:match ('^[1-9]%d*$');											-- id must be all digits; must not begin with 0; no open access flag

 	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if handler.id_limit &lt; id_num then										-- if S2CID is outside test limit boundaries
			set_message ('err_bad_s2cid');										-- set an error message
			options.coins_list_t['S2CID'] = nil;								-- when error, unset so not included in COinS
		end
	else																		-- when id format incorrect
		set_message ('err_bad_s2cid');											-- set an error message
		options.coins_list_t['S2CID'] = nil;									-- when error, unset so not included in COinS
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});

	return text;
end


--[[--------------------------&lt; S B N &gt;------------------------------------------------------------------------

9-digit form of ISBN-10; uses same check-digit validation when SBN is prefixed with an additional '0' to make 10 digits

sbn value not made part of COinS metadata because we don't have a url or isn't a COinS-defined identifier (rft.xxx)
or an identifier registered at info-uri.info (info:)

]]

local function sbn (options)
	local id = options.id;
	local ignore_invalid = options.accept;
	local handler = options.handler;
	local function return_result (check, err_type)								-- local function to handle the various returns
		local SBN = internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,
						prefix = handler.prefix, id = id, separator = handler.separator});
		if not ignore_invalid then												-- if not ignoring SBN errors
			if not check then
				options.coins_list_t['SBN'] = nil;								-- when error, unset so not included in COinS; not really necessary here because sbn not made part of COinS
				set_message ('err_bad_sbn', {err_type});						-- display an error message
				return SBN; 
			end
		else
			set_message ('maint_isbn_ignore');									-- add a maint category even when there is no error (ToDo: Possibly switch to separate message for SBNs only)
		end
		return SBN;
	end

	if id:match ('[^%s-0-9X]') then
		return return_result (false, cfg.err_msg_supl.char);					-- fail if SBN contains anything but digits, hyphens, or the uppercase X
	end

	local ident = id:gsub ('[%s-]', '');										-- remove hyphens and whitespace; they interfere with the rest of the tests

	if  9 ~= ident:len() then
		return return_result (false, cfg.err_msg_supl.length);					-- fail if incorrect length
	end

	if ident:match ('^%d*X?$') == nil then
		return return_result (false, cfg.err_msg_supl.form);					-- fail if SBN has 'X' anywhere but last position
	end

	return return_result (is_valid_isxn ('0' .. ident, 10), cfg.err_msg_supl.check);
end


--[[--------------------------&lt; S S R N &gt;----------------------------------------------------------------------

Format an SSRN, do simple error checking

SSRNs are sequential numbers beginning at 100? and counting up.  This code checks the SSRN to see that it is
only digits and is greater than 99 and less than test_limit; the value in local variable test_limit will need
to be updated periodically as more SSRNs are issued.

]]

local function ssrn (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;
	local text;
	
	id_num = id:match ('^%d+$');												-- id must be all digits

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if 100 &gt; id_num or handler.id_limit &lt; id_num then						-- if SSRN is outside test limit boundaries
			set_message ('err_bad_ssrn');										-- set an error message
			options.coins_list_t['SSRN'] = nil;									-- when error, unset so not included in COinS
		end
	else																		-- when id format incorrect
		set_message ('err_bad_ssrn');											-- set an error message
		options.coins_list_t['SSRN'] = nil;										-- when error, unset so not included in COinS
	end
	
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = options.access});

	return text;
end


--[[--------------------------&lt; U S E N E T _ I D &gt;------------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function usenet_id (options)
	local id = options.id;
	local handler = options.handler;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$') then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		set_message ('err_bad_usenet_id')										-- add an error message if the message id is invalid
		options.coins_list_t['USENETID'] = nil;									-- when error, unset so not included in COinS
	end 
	
	return text;
end


--[[--------------------------&lt; Z B L &gt;-----------------------------------------------------------------------

A numerical identifier in the form nnnn.nnnnn - leading zeros in the first quartet optional

format described here: http://emis.mi.sanu.ac.rs/ZMATH/zmath/en/help/search/

temporary format is apparently eight digits.  Anything else is an error

]]

local function zbl (options)
	local id = options.id;
	local handler = options.handler;

	if id:match('^%d%d%d%d%d%d%d%d$') then										-- is this identifier using temporary format?
		set_message ('maint_zbl');												-- yes, add maint cat
	elseif not id:match('^%d?%d?%d?%d%.%d%d%d%d%d$') then						-- not temporary, is it normal format?
		set_message ('err_bad_zbl');											-- no, set an error message
		options.coins_list_t['ZBL'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--============================&lt;&lt; I N T E R F A C E   F U N C T I O N S &gt;&gt;==========================================

--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message if more than one alias exists in args

]]

local function extract_ids (args)
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs (cfg.id_handlers) do										-- k is uppercase identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one (args, v.parameters, 'err_redundant_parameters' );		-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set (v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; E X T R A C T _ I D _ A C C E S S _ L E V E L S &gt;--------------------------------------

Fetches custom id access levels from arguments using configuration settings. Parameters which have a predefined access
level (e.g. arxiv) do not use this function as they are directly rendered as free without using an additional parameter.

returns a table of k/v pairs where k is same as the identifier's key in cfg.id_handlers and v is the assigned (valid) keyword

access-level values must match the case used in cfg.keywords_lists['id-access'] (lowercase unless there is some special reason for something else)

]]

local function extract_id_access_levels (args, id_list)
	local id_accesses_list = {};
	for k, v in pairs (cfg.id_handlers) do
		local access_param = v.custom_access;									-- name of identifier's access-level parameter
		if is_set (access_param) then
			local access_level = args[access_param];							-- get the assigned value if there is one
			if is_set (access_level) then
				if not in_array (access_level, cfg.keywords_lists['id-access']) then	-- exact match required
					set_message ('err_invalid_param_val', {access_param, access_level});	
					access_level = nil;											-- invalid so unset
				end
				if not is_set (id_list[k]) then									-- identifier access-level must have a matching identifier
					set_message ('err_param_access_requires_param', {k:lower()});	-- parameter name is uppercase in cfg.id_handlers (k); lowercase for error message
				end
				id_accesses_list[k] = cfg.keywords_xlate[access_level];			-- get translated keyword
			end
		end
	end
	return id_accesses_list;
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;----------------------------------------------------

render the identifiers into a sorted sequence table

&lt;ID_list_coins_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value
&lt;options_t&gt; is a table of various k/v option pairs provided in the call to new_build_id_list();
	modified by	this function and passed to all identifier rendering functions
&lt;access_levels_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value (if valid)

returns a sequence table of sorted (by hkey - 'handler' key) rendered identifier strings

]]

local function build_id_list (ID_list_coins_t, options_t, access_levels_t)
	local ID_list_t = {};
	local accept;
	local func_map = {															--function map points to functions associated with hkey identifier
		['ARXIV'] = arxiv,
		['ASIN'] = asin,
		['BIBCODE'] = bibcode,
		['BIORXIV'] = biorxiv,
		['CITESEERX'] = citeseerx,
		['DOI'] = doi,
		['EISSN'] = issn,
		['HDL'] = hdl,
		['ISBN'] = isbn,
		['ISMN'] = ismn,
		['ISSN'] = issn,
		['JFM'] = jfm,
		['JSTOR'] = jstor,
		['LCCN'] = lccn,
		['MR'] = mr,
		['OCLC'] = oclc,
		['OL'] = openlibrary,
		['OSTI'] = osti,
		['PMC'] = pmc,
		['PMID'] = pmid,
		['RFC']  = rfc,
		['S2CID'] = s2cid,
		['SBN'] = sbn,
		['SSRN'] = ssrn,
		['USENETID'] = usenet_id,
		['ZBL'] = zbl,
		}

	for hkey, v in pairs (ID_list_coins_t) do
		v, accept = has_accept_as_written (v);									-- remove accept-as-written markup if present; accept is boolean true when markup removed; false else
																				-- every function gets the options table with value v and accept boolean
		options_t.hkey = hkey;													-- ~/Configuration handler key
		options_t.id = v;														-- add that identifier value to the options table
		options_t.accept = accept;												-- add the accept boolean flag
		options_t.access = access_levels_t[hkey];								-- add the access level for those that have an |&lt;identifier-access= parameter
		options_t.handler = cfg.id_handlers[hkey];
		options_t.coins_list_t = ID_list_coins_t;								-- pointer to ID_list_coins_t; for |asin= and |ol=; also to keep erroneous values out of the citation's metadata
		options_t.coins_list_t[hkey] = v;										-- id value without accept-as-written markup for metadata
		
		if options_t.handler.access and not in_array (options_t.handler.access, cfg.keywords_lists['id-access']) then
			error (cfg.messages['unknown_ID_access'] .. options_t.handler.access);	-- here when handler access key set to a value not listed in list of allowed id access keywords
		end

		if func_map[hkey] then
			local id_text = func_map[hkey] (options_t);							-- call the function to get identifier text and any error message
			table.insert (ID_list_t, {hkey, id_text});							-- add identifier text to the output sequence table
		else
			error (cfg.messages['unknown_ID_key'] .. hkey);						-- here when func_map doesn't have a function for hkey
		end
	end

	local function comp (a, b)													-- used by following table.sort()
		return a[1]:lower() &lt; b[1]:lower();										-- sort by hkey
	end

	table.sort (ID_list_t, comp);												-- sequence table of tables sort	
	for k, v in ipairs (ID_list_t) do											-- convert sequence table of tables to simple sequence table of strings
		ID_list_t[k] = v[2];													-- v[2] is the identifier rendering from the call to the various functions in func_map{}
	end
	
	return ID_list_t;
end


--[[--------------------------&lt; O P T I O N S _ C H E C K &gt;----------------------------------------------------

check that certain option parameters have their associated identifier parameters with values

&lt;ID_list_coins_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value
&lt;ID_support_t&gt; is a sequence table of tables created in citation0() where each subtable has four elements:
	[1] is the support parameter's assigned value; empty string if not set
	[2] is a text string same as key in cfg.id_handlers
	[3] is cfg.error_conditions key used to create error message
	[4] is original ID support parameter name used to create error message
	
returns nothing; on error emits an appropriate error message

]]

local function options_check (ID_list_coins_t, ID_support_t)
	for _, v in ipairs (ID_support_t) do
		if is_set (v[1]) and not ID_list_coins_t[v[2]] then						-- when support parameter has a value but matching identifier parameter is missing or empty
			set_message (v[3], (v[4]));											-- emit the appropriate error message
		end
	end
end


--[[--------------------------&lt; I D E N T I F I E R _ L I S T S _ G E T &gt;--------------------------------------

Creates two identifier lists: a k/v table of identifiers and their values to be used locally and for use in the
COinS metadata, and a sequence table of the rendered identifier strings that will be included in the rendered
citation.

]]

local function identifier_lists_get (args_t, options_t, ID_support_t)
	local ID_list_coins_t = extract_ids (args_t);										-- get a table of identifiers and their values for use locally and for use in COinS
	options_check (ID_list_coins_t, ID_support_t);										-- ID support parameters must have matching identifier parameters 
	local ID_access_levels_t = extract_id_access_levels (args_t, ID_list_coins_t);		-- get a table of identifier access levels
	local ID_list_t = build_id_list (ID_list_coins_t, options_t, ID_access_levels_t);	-- get a sequence table of rendered identifier strings

	return ID_list_t, ID_list_coins_t;											-- return the tables
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	has_accept_as_written = utilities_page_ptr.has_accept_as_written;			-- import functions from select Module:Citation/CS1/Utilities module
	is_set = utilities_page_ptr.is_set;								
	in_array = utilities_page_ptr.in_array;
	set_message = utilities_page_ptr.set_message;
	select_one = utilities_page_ptr.select_one;
	substitute = utilities_page_ptr.substitute;
	make_wikilink = utilities_page_ptr.make_wikilink;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	auto_link_urls = auto_link_urls,											-- table of identifier URLs to be used when auto-linking |title=
	
	identifier_lists_get = identifier_lists_get,								-- experiment to replace individual calls to build_id_list(), extract_ids, extract_id_access_levels
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>epcxjm1e7vnxg0m69646hxwauvwdfwq</sha1>
    </revision>
    <revision>
      <id>4922</id>
      <parentid>4921</parentid>
      <timestamp>2023-08-12T19:19:04Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4922</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="76509" sha1="pkfpwea3v2exbtw6sggib18ty1ubykp" xml:space="preserve">--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local has_accept_as_written, is_set, in_array, set_message, select_one,			-- functions in Module:Citation/CS1/Utilities
		substitute, make_wikilink;

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

declare variables here that have page-wide scope that are not brought in from other modules; that are created here and used here

]]

local auto_link_urls = {};														-- holds identifier URLs for those identifiers that can auto-link |title=


--============================&lt;&lt; H E L P E R   F U N C T I O N S &gt;&gt;============================================

--[[--------------------------&lt; W I K I D A T A _ A R T I C L E _ N A M E _ G E T &gt;----------------------------

as an aid to internationalizing identifier-label wikilinks, gets identifier article names from Wikidata.

returns :&lt;lang code&gt;:&lt;article title&gt; when &lt;q&gt; has an &lt;article title&gt; for &lt;lang code&gt;; nil else

for identifiers that do not have q, returns nil

for wikis that do not have mw.wikibase installed, returns nil

]]

local function wikidata_article_name_get (q)
	if not is_set (q) or (q and not mw.wikibase) then							-- when no q number or when a q number but mw.wikibase not installed on this wiki
		return nil;																-- abandon
	end

	local wd_article;
	local this_wiki_code = cfg.this_wiki_code;									-- Wikipedia subdomain; 'en' for en.wikipedia.org

	wd_article = mw.wikibase.getSitelink (q, this_wiki_code .. 'wiki');			-- fetch article title from WD; nil when no title available at this wiki

	if wd_article then
		wd_article = table.concat ({':', this_wiki_code, ':', wd_article});		-- interwiki-style link without brackets if taken from WD; leading colon required
	end

	return wd_article;															-- article title from WD; nil else
end


--[[--------------------------&lt; L I N K _ L A B E L _ M A K E &gt;------------------------------------------------

common function to create identifier link label from handler table or from Wikidata

returns the first available of
	1. redirect from local wiki's handler table (if enabled)
	2. Wikidata (if there is a Wikidata entry for this identifier in the local wiki's language)
	3. label specified in the local wiki's handler table
	
]]

local function link_label_make (handler)
	local wd_article;
	
	if not (cfg.use_identifier_redirects and is_set (handler.redirect)) then	-- redirect has priority so if enabled and available don't fetch from Wikidata because expensive
		wd_article = wikidata_article_name_get (handler.q);						-- if Wikidata has an article title for this wiki, get it;
	end
	
	return (cfg.use_identifier_redirects and is_set (handler.redirect) and handler.redirect) or wd_article or handler.link;
end


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki-style external link

]]

local function external_link_id (options)
	local url_string = options.id;
	local ext_link;
	local this_wiki_code = cfg.this_wiki_code;									-- Wikipedia subdomain; 'en' for en.wikipedia.org
	local wd_article;															-- article title from Wikidata
	
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode (url_string, 'PATH');
	end

	if options.auto_link and is_set (options.access) then
		auto_link_urls[options.auto_link] = table.concat ({options.prefix, url_string, options.suffix});
	end

	ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or &quot;&quot;, mw.text.nowiki (options.id));
	if is_set (options.access) then
		ext_link = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[options.access].class, cfg.presentation[options.access].title, ext_link});	-- add the free-to-read / paywall lock
	end

	return table.concat	({
		make_wikilink (link_label_make (options), options.label),				-- redirect, Wikidata link, or locally specified link (in that order)
		options.separator or '&amp;nbsp;',
		ext_link
		});
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki-style internal link

TODO: Does not currently need to support options.access, options.encode, auto-linking and COinS (as in external_link_id),
but may be needed in the future for :m:Interwiki_map custom-prefixes like :arxiv:, :bibcode:, :DOI:, :hdl:, :ISSN:,
:JSTOR:, :Openlibrary:, :PMID:, :RFC:.

]]

local function internal_link_id (options)
	local id = mw.ustring.gsub (options.id, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9

	return table.concat (
		{
		make_wikilink (link_label_make (options), options.label),				-- wiki-link the identifier label
		options.separator or '&amp;nbsp;',											-- add the separator
		make_wikilink (
			table.concat (
				{
				options.prefix,
				id,																-- translated to Western digits
				options.suffix or ''
				}),
			substitute (cfg.presentation['bdi'], {'', mw.text.nowiki (options.id)})	-- bdi tags to prevent Latin script identifiers from being reversed at RTL language wikis
			);																	-- nowiki because MediaWiki still has magic links for ISBN and the like; TODO: is it really required?
		});
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |pmc-embargo-date= against
today's date.  If embargo date is in the future, returns the content of |pmc-embargo-date=; otherwise, returns
an empty string because the embargo has expired or because |pmc-embargo-date= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, todays_date;
		good1, embargo_date = pcall (lang.formatDate, lang, 'U', embargo);
		todays_date = lang:formatDate ('U');
	
		if good1 then															-- if embargo date is a good date
			if tonumber (embargo_date) &gt;= tonumber (todays_date) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				set_message ('maint_pmc_embargo');								-- embargo has expired; add main cat
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |pmc-embargo-date= not set return empty string
end


--[=[-------------------------&lt; I S _ V A L I D _ R X I V _ D A T E &gt;------------------------------------------

for biorxiv, returns true if:
	2019-12-11T00:00Z &lt;= biorxiv_date &lt; today + 2 days
for medrxiv, returns true if:
	2020-01-01T00:00Z &lt;= medrxiv_date &lt; today + 2 days
	
The dated form of biorxiv identifier has a start date of 2019-12-11.  The Unix timestamp for that date is {{#time:U|2019-12-11}} = 1576022400
The medrxiv identifier has a start date of 2020-01-01.  The Unix timestamp for that date is {{#time:U|2020-01-01}} = 1577836800

&lt;rxiv_date&gt; is the date provided in those |biorxiv= parameter values that are dated and in |medrxiv= parameter values at time 00:00:00 UTC
&lt;today&gt; is the current date at time 00:00:00 UTC plus 48 hours
	if today's date is 2023-01-01T00:00:00 then
		adding 24 hours gives 2023-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2023-01-03T00:00:00 – one second more than tomorrow

inputs:
	&lt;y&gt;, &lt;m&gt;, &lt;d&gt; – year, month, day parts of the date from the birxiv or medrxiv identifier
	&lt;select&gt; 'b' for biorxiv, 'm' for medrxiv; defaults to 'b'

]=]

local function is_valid_rxiv_date (y, m, d, select)
	if 0 == tonumber (m) and 12 &lt; tonumber (m) then								-- &lt;m&gt; must be a number 1–12
		return false;
	end
	if 0 == tonumber (d) and 31 &lt; tonumber (d) then								-- &lt;d&gt; must be a number 1–31; TODO: account for month length and leap yer?
		return false;
	end
	
	local rxiv_date = table.concat ({y, m, d}, '-');							-- make ymd date string
	local good1, good2;
	local rxiv_ts, tomorrow_ts;													-- to hold Unix timestamps representing the dates
	local lang_object = mw.getContentLanguage();

	good1, rxiv_ts = pcall (lang_object.formatDate, lang_object, 'U', rxiv_date);		-- convert rxiv_date value to Unix timestamp 
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which tonumber() may not understand
		rxiv_ts = tonumber (rxiv_ts) or lang_object:parseFormattedNumber (rxiv_ts);	-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to Unix timestamp
	end

	local limit_ts = ((select and ('m' == select)) and 1577836800) or 1576022400;	-- choose the appropriate limit timesatmp

	return ((limit_ts &lt;= rxiv_ts) and (rxiv_ts &lt; tomorrow_ts))					-- limit_ts &lt;= rxiv_date &lt; tomorrow's date
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all ISBN/ISSN digits including the check digit.
ISBN-13 is checked in isbn().

If the number is valid the result will be 0. Before calling this function, ISBN/ISSN must be checked for length
and stripped of dashes, spaces and other non-ISxN characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39, 'X' → 0x58
	len = len + 1;																-- adjust to be a loop counter
	for i, v in ipairs (isxn_str) do											-- loop through all of the bytes and calculate the checksum
		if v == string.byte (&quot;X&quot; ) then											-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10 * (len - i);										-- it represents 10 decimal
		else
			temp = temp + tonumber (string.char (v) )*(len-i);
		end
	end
	return temp % 11 == 0;														-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N _ 1 3 &gt;-----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 ISBN/ISMN digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, ISBN-13/ISMN must be checked for length
and stripped of dashes, spaces and other non-ISxN-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39
	for i, v in ipairs (isxn_str) do
		temp = temp + (3 - 2*(i % 2)) * tonumber (string.char (v) );			-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when ISBN-13/ISMN is correct
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

LCCN normalization (https://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized LCCN for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.

]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);												-- 1. strip whitespace

	if nil ~= string.find (lccn, '/') then
		lccn = lccn:match (&quot;(.-)/&quot;);											-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);									-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then														-- if there was a hyphen
		suffix = string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;				-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn = prefix..suffix;													-- reassemble the LCCN
	end
	
	return lccn;
	end


--============================&lt;&lt; I D E N T I F I E R   F U N C T I O N S &gt;&gt;====================================

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: https://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9107 and 0703, is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation; not the same as |class= parameter which is not supported in this form
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number

]]

local function arxiv (options)
	local id = options.id;
	local class = options.Class;												-- TODO: lowercase?
	local handler = options.handler;
	local year, month, version;
	local err_msg = false;														-- assume no error message
	local text;																	-- output text
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9107-0703 format with or without version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_msg = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 with or without version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then									-- when year is 07, is month invalid (before April)?
				err_msg = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format with or without version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_msg = true;														-- flag for error message
		end

	else
		err_msg = true;															-- not a recognized format; flag for error message
	end

	if err_msg then
		options.coins_list_t['ARXIV'] = nil;									-- when error, unset so not included in COinS
	end
	
	local err_msg_t = {};
	if err_msg then
		set_message ('err_bad_arxiv');
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access});

	if is_set (class) then
		if id:match ('^%d+') then
			text = table.concat ({text, ' [[https://arxiv.org/archive/', class, ' ', class, ']]'});	-- external link within square brackets, not wikilink
		else
			set_message ('err_class_ignored');
		end
	end

	return text;
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode ID.

Format for bibcodes is specified here: https://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		9–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local ignore_invalid = options.accept;
	local err_type;
	local err_msg = '';
	local year;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode,
		access = access});
	
	if 19 ~= id:len() then
		err_type = cfg.err_msg_supl.length;
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%w&amp;%.][%w&amp;%.][%w&amp;%.][%w.]+[%a%.]$&quot;);
		if not year then														-- if nil then no pattern match
			err_type = cfg.err_msg_supl.value;									-- so value error
		else
			local next_year = tonumber (os.date ('%Y')) + 1;					-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = cfg.err_msg_supl.year;								-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = cfg.err_msg_supl.journal;							-- journal abbreviation must not have '&amp;.' (if it does it's missing a letter)
			end
			if id:match ('.........%.tmp%.') then								-- temporary bibcodes when positions 10–14 are '.tmp.'
				set_message ('maint_bibcode');
			end
		end
	end

	if is_set (err_type) and not ignore_invalid then							-- if there was an error detected and accept-as-written markup not used
		set_message ('err_bad_bibcode', {err_type});
		options.coins_list_t['BIBCODE'] = nil;									-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; B I O R X I V &gt;-----------------------------------------------------------------

Format bioRxiv ID and do simple error checking.  Before 2019-12-11, biorXiv IDs were 10.1101/ followed by exactly
6 digits.  After 2019-12-11, biorXiv IDs retained the six-digit identifier but prefixed that with a yyyy.mm.dd. 
date and suffixed with an optional version identifier.

The bioRxiv ID is the string of characters:
	https://doi.org/10.1101/078733 -&gt; 10.1101/078733
or a date followed by a six-digit number followed by an optional version indicator 'v' and one or more digits:
	https://www.biorxiv.org/content/10.1101/2019.12.11.123456v2 -&gt; 10.1101/2019.12.11.123456v2
	
see https://www.biorxiv.org/about-biorxiv

]]

local function biorxiv (options)
	local id = options.id;
	local handler = options.handler;
	local err_msg = true;														-- flag; assume that there will be an error
	
	local patterns = {
		'^10%.1101/%d%d%d%d%d%d$',												-- simple 6-digit identifier (before 2019-12-11)
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%dv%d+$',				-- y.m.d. date + 6-digit identifier + version (after 2019-12-11)
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%d$',					-- y.m.d. date + 6-digit identifier (after 2019-12-11)
		}
	
	for _, pattern in ipairs (patterns) do										-- spin through the patterns looking for a match
		if id:match (pattern) then
			local y, m, d = id:match (pattern);									-- found a match, attempt to get year, month and date from the identifier

			if m then															-- m is nil when id is the six-digit form
				if not is_valid_rxiv_date (y, m, d, 'b') then					-- validate the encoded date; 'b' for biorxiv limit
					break;														-- date fail; break out early so we don't unset the error message
				end
			end
			err_msg = nil;														-- we found a match so unset the error message
			break;																-- and done
		end
	end																			-- err_cat remains set here when no match

	if err_msg then
		options.coins_list_t['BIORXIV'] = nil;									-- when error, unset so not included in COinS
		set_message ('err_bad_biorxiv');										-- and set the error message
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator,
			encode = handler.encode, access = handler.access});
end


--[[--------------------------&lt; C I T E S E E R X &gt;------------------------------------------------------------

CiteSeerX use their own notion of &quot;doi&quot; (not to be confused with the identifiers resolved via doi.org).

The description of the structure of this identifier can be found at Help_talk:Citation_Style_1/Archive_26#CiteSeerX_id_structure

]]

local function citeseerx (options)
	local id = options.id;
	local handler = options.handler;
	local matched;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode,
		access = handler.access});
	
	matched = id:match (&quot;^10%.1%.1%.[1-9]%d?%d?%d?%.[1-9]%d?%d?%d?$&quot;);
	if not matched then
		set_message ('err_bad_citeseerx' );
		options.coins_list_t['CITESEERX'] = nil;								-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the DOI name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in DOI names.

https://www.doi.org/doi_handbook/2_Numbering.html				-- 2.2 Syntax of a DOI name
https://www.doi.org/doi_handbook/2_Numbering.html#2.2.2			-- 2.2.2 DOI prefix

]]

local function doi (options)
	local id = options.id;
	local inactive = options.DoiBroken
	local access = options.access;
	local ignore_invalid = options.accept;
	local handler = options.handler;
	local err_flag;

	local text;
	if is_set (inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;);						-- try to get the year portion from the inactive date
		local inactive_month, good;

		if is_set (inactive_year) then
			if 4 &lt; inactive:len() then											-- inactive date has more than just a year (could be anything)
				local lang_obj = mw.getContentLanguage();						-- get a language object for this wiki
				good, inactive_month = pcall (lang_obj.formatDate, lang_obj, 'F', inactive);	-- try to get the month name from the inactive date
				if not good then
					inactive_month = nil;										-- something went wrong so make sure this is unset
				end
			end
		end																		-- otherwise, |doi-broken-date= has something but it isn't a date
		
		if is_set (inactive_year) and is_set (inactive_month) then
			set_message ('maint_doi_inactive_dated', {inactive_year, inactive_month, ' '});
		elseif is_set (inactive_year) then
			set_message ('maint_doi_inactive_dated', {inactive_year, '', ''});
		else
			set_message ('maint_doi_inactive');
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. ' ' .. inactive .. ')';
	end

	local registrant = mw.ustring.match (id, '^10%.([^/]+)/[^%s–]-[^%.,]$');	-- registrant set when DOI has the proper basic form

	local registrant_err_patterns = {											-- these patterns are for code ranges that are not supported 
		'^[^1-3]%d%d%d%d%.%d+$',												-- 5 digits with subcode (0xxxx, 40000+); accepts: 10000–39999
		'^[^1-6]%d%d%d%d$',														-- 5 digits without subcode (0xxxx, 60000+); accepts: 10000–69999
		'^[^1-9]%d%d%d%.%d+$',												-- 4 digits with subcode (0xxx); accepts: 1000–9999
		'^[^1-9]%d%d%d$',														-- 4 digits without subcode (0xxx); accepts: 1000–9999
		'^%d%d%d%d%d%d+',														-- 6 or more digits
		'^%d%d?%d?$',															-- less than 4 digits without subcode (3 digits with subcode is legitimate)
		'^%d%d?%.[%d%.]+',														-- 1 or 2 digits with subcode
		'^5555$',																-- test registrant will never resolve
		'[^%d%.]',																-- any character that isn't a digit or a dot
		}

	if not ignore_invalid then
		if registrant then														-- when DOI has proper form
			for i, pattern in ipairs (registrant_err_patterns) do				-- spin through error patterns
				if registrant:match (pattern) then								-- to validate registrant codes
					err_flag = set_message ('err_bad_doi');						-- when found, mark this DOI as bad
					break;														-- and done
				end
			end
		else
			err_flag = set_message ('err_bad_doi');								-- invalid directory or malformed
		end
	else
		set_message ('maint_doi_ignore');
	end

	if err_flag then
		options.coins_list_t['DOI'] = nil;										-- when error, unset so not included in COinS
	end
	
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access,
		auto_link = not (err_flag or is_set (inactive) or ignore_invalid) and 'doi' or nil -- do not auto-link when |doi-broken-date= has a value or when there is a DOI error or (to play it safe, after all, auto-linking is not essential) when invalid DOIs are ignored
		}) .. (inactive or '');

	return text;
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

Query string parameters are named here: https://www.handle.net/proxy_servlet.html.  query strings are not displayed
but since '?' is an allowed character in an HDL, '?' followed by one of the query parameters is the only way we
have to detect the query string so that it isn't URL-encoded with the rest of the identifier.

]]

local function hdl (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local query_params = {														-- list of known query parameters from https://www.handle.net/proxy_servlet.html
		'noredirect',
		'ignore_aliases',
		'auth',
		'cert',
		'index',
		'type',
		'urlappend',
		'locatt',
		'action',
		}
	
	local hdl, suffix, param = id:match ('(.-)(%?(%a+).+)$');					-- look for query string
	local found;

	if hdl then																	-- when there are query strings, this is the handle identifier portion
		for _, q in ipairs (query_params) do									-- spin through the list of query parameters
			if param:match ('^' .. q) then										-- if the query string begins with one of the parameters
				found = true;													-- announce a find
				break;															-- and stop looking
			end
		end
	end

	if found then
		id = hdl;																-- found so replace id with the handle portion; this will be URL-encoded, suffix will not
	else
		suffix = '';															-- make sure suffix is empty string for concatenation else
	end

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, suffix = suffix, separator = handler.separator, encode = handler.encode, access = access})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- HDL must contain a forward slash, must not contain spaces, endashes, and must not end with period or comma
		set_message ('err_bad_hdl' );
		options.coins_list_t['HDL'] = nil;										-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; I S B N &gt;----------------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function isbn (options)
	local isbn_str = options.id;
	local ignore_invalid = options.accept;
	local handler = options.handler;

	local function return_result (check, err_type)								-- local function to handle the various returns
		local ISBN = internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,
						prefix = handler.prefix, id = isbn_str, separator = handler.separator});
		if ignore_invalid then													-- if ignoring ISBN errors
			set_message ('maint_isbn_ignore');									-- add a maint category even when there is no error
		else																	-- here when not ignoring
			if not check then													-- and there is an error
				options.coins_list_t['ISBN'] = nil;								-- when error, unset so not included in COinS
				set_message ('err_bad_isbn', err_type);							-- set an error message
				return ISBN;										 			-- return id text
			end
		end
		return ISBN;															-- return id text
	end

	if nil ~= isbn_str:match ('[^%s-0-9X]') then
		return return_result (false, cfg.err_msg_supl.char);					-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end

	local id = isbn_str:gsub ('[%s-]', '');										-- remove hyphens and whitespace

	local len = id:len();
 
	if len ~= 10 and len ~= 13 then
		return return_result (false, cfg.err_msg_supl.length);					-- fail if incorrect length
	end

	if len == 10 then
		if id:match ('^%d*X?$') == nil then										-- fail if isbn_str has 'X' anywhere but last position
			return return_result (false, cfg.err_msg_supl.form);									
		end
		if not is_valid_isxn (id, 10) then										-- test isbn-10 for numerical validity
			return return_result (false, cfg.err_msg_supl.check);				-- fail if isbn-10 is not numerically valid
		end
		if id:find ('^63[01]') then												-- 630xxxxxxx and 631xxxxxxx are (apparently) not valid isbn group ids but are used by amazon as numeric identifiers (asin)
			return return_result (false, cfg.err_msg_supl.group);				-- fail if isbn-10 begins with 630/1
		end
		return return_result (true, cfg.err_msg_supl.check);					-- pass if isbn-10 is numerically valid
	else
		if id:match ('^%d+$') == nil then
			return return_result (false, cfg.err_msg_supl.char);				-- fail if ISBN-13 is not all digits
		end
		if id:match ('^97[89]%d*$') == nil then
			return return_result (false, cfg.err_msg_supl.prefix);				-- fail when ISBN-13 does not begin with 978 or 979
		end
		if id:match ('^9790') then
			return return_result (false, cfg.err_msg_supl.group);				-- group identifier '0' is reserved to ISMN
		end
		return return_result (is_valid_isxn_13 (id), cfg.err_msg_supl.check);
	end
end


--[[--------------------------&lt; A S I N &gt;----------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: ASIN must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, ASINs must be 10-digit
ISBN. If 10-digit ISBN, add a maintenance category so a bot or AWB script can replace |asin= with |isbn=.
Error message if not 10 characters, if not ISBN-10, if mixed and first character is a digit.

|asin=630....... and |asin=631....... are (apparently) not a legitimate ISBN though it checksums as one; these
do not cause this function to emit the maint_asin message

This function is positioned here because it calls isbn()

]]

local function asin (options)
	local id = options.id;
	local domain = options.ASINTLD;
	
	local err_flag;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_flag = set_message ('err_bad_asin');								-- ASIN is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then							-- if 10-digit numeric (or 9 digits with terminal X)
			if is_valid_isxn (id, 10) then										-- see if ASIN value is or validates as ISBN-10
				if not id:find ('^63[01]') then									-- 630xxxxxxx and 631xxxxxxx are (apparently) not a valid isbn prefixes but are used by amazon as a numeric identifier
					err_flag = set_message ('err_bad_asin');					-- ASIN has ISBN-10 form but begins with something other than 630/1 so probably an isbn 
				end
			elseif not is_set (err_flag) then
				err_flag = set_message ('err_bad_asin');						-- ASIN is not ISBN-10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_flag = set_message ('err_bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if (not is_set (domain)) or in_array (domain, {'us'}) then					-- default: United States
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then									-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'z.cn'}) then 									-- China
		domain = &quot;cn&quot;;
	elseif in_array (domain, {'au', 'br', 'mx', 'sg', 'tr'}) then				-- Australia, Brazil, Mexico, Singapore, Turkey
		domain = &quot;com.&quot; .. domain;
	elseif not in_array (domain, {'ae', 'ca', 'cn', 'de', 'es', 'fr', 'in', 'it', 'nl', 'pl', 'sa', 'se', 'co.jp', 'co.uk', 'com', 'com.au', 'com.br', 'com.mx', 'com.sg', 'com.tr'}) then -- Arabic Emirates, Canada, China, Germany, Spain, France, Indonesia, Italy, Netherlands, Poland, Saudi Arabia, Sweden (as of 2021-03 Austria (.at), Liechtenstein (.li) and Switzerland (.ch) still redirect to the German site (.de) with special settings, so don't maintain local ASINs for them)
		err_flag = set_message ('err_bad_asin_tld');							-- unsupported asin-tld value
	end
	local handler = options.handler;

	if not is_set (err_flag) then
		options.coins_list_t['ASIN'] = handler.prefix .. domain .. &quot;/dp/&quot; .. id;	-- asin for coins
	else
		options.coins_list_t['ASIN'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix .. domain .. &quot;/dp/&quot;,
		id = id, encode = handler.encode, separator = handler.separator})
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to ISBN-13, ISMN is 13 digits beginning 979-0-... and uses the
same check digit calculations.  See https://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

ismn value not made part of COinS metadata because we don't have a url or isn't a COinS-defined identifier (rft.xxx)
or an identifier registered at info-uri.info (info:)

]]

local function ismn (options)
	local id = options.id;
	local handler = options.handler;
	local text;
	local valid_ismn = true;
	local id_copy;

	id_copy = id;																-- save a copy because this testing is destructive
	id = id:gsub ('[%s-]', '');													-- remove hyphens and white space

	if 13 ~= id:len() or id:match (&quot;^9790%d*$&quot; ) == nil then					-- ISMN must be 13 digits and begin with 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ISMN
	end

	--	text = internal_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,		-- use this (or external version) when there is some place to link to
	--		prefix = handler.prefix, id = id_copy, separator = handler.separator, encode = handler.encode})

	text = table.concat (														-- because no place to link to yet
		{
		make_wikilink (link_label_make (handler), handler.label),
		handler.separator,
		id_copy
		});

	if false == valid_ismn then
		options.coins_list_t['ISMN'] = nil;										-- when error, unset so not included in COinS; not really necessary here because ismn not made part of COinS
		set_message ('err_bad_ismn');											-- create an error message if the ISMN is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an ISSN.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [https://www.worldcat.org/issn/0819 4327 0819 4327]	-- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the ISSN midpoint.  It also validates the ISSN for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check ISSN error message.  The
ISSN is always displayed with a hyphen, even if the ISSN was given as a single group of 8 digits.

]]

local function issn (options)
	local id = options.id;
	local handler = options.handler;
	local ignore_invalid = options.accept;

	local issn_copy = id;														-- save a copy of unadulterated ISSN; use this version for display if ISSN does not validate
	local text;
	local valid_issn = true;

	id = id:gsub ('[%s-]', '');													-- remove hyphens and whitespace

	if 8 ~= id:len() or nil == id:match (&quot;^%d*X?$&quot; ) then						-- validate the ISSN: 8 digits long, containing only 0-9 or X in the last position
		valid_issn = false;														-- wrong length or improper character
	else
		valid_issn = is_valid_isxn (id, 8);										-- validate ISSN
	end

	if true == valid_issn then
		id = string.sub (id, 1, 4 ) .. &quot;-&quot; .. string.sub (id, 5 );				-- if valid, display correctly formatted version
	else
		id = issn_copy;															-- if not valid, show the invalid ISSN with error message
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode})

	if ignore_invalid then
		set_message ('maint_issn_ignore');
	else
		if false == valid_issn then
			options.coins_list_t['ISSN'] = nil;									-- when error, unset so not included in COinS
			set_message ('err_bad_issn', (options.hkey == 'EISSN') and 'e' or '');	-- create an error message if the ISSN is invalid
		end 
	end
	
	return text;
end


--[[--------------------------&lt; J F M &gt;-----------------------------------------------------------------------

A numerical identifier in the form nn.nnnn.nn

]]

local function jfm (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;

	id_num = id:match ('^[Jj][Ff][Mm](.*)$');									-- identifier with jfm prefix; extract identifier

	if is_set (id_num) then
		set_message ('maint_jfm_format');
	else																		-- plain number without JFM prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num and id_num:match('^%d%d%.%d%d%d%d%.%d%d$') then
		id = id_num;															-- jfm matches pattern
	else
		set_message ('err_bad_jfm' );											-- set an error message
		options.coins_list_t['JFM'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; J S T O R &gt;--------------------------------------------------------------------

Format a JSTOR with some error checking

]]

local function jstor (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;

	if id:find ('[Jj][Ss][Tt][Oo][Rr]') or id:find ('^https?://') or id:find ('%s') then
		set_message ('err_bad_jstor');											-- set an error message
		options.coins_list_t['JSTOR'] = nil;									-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});
end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
https://oclc-research.github.io/infoURI-Frozen/info-uri.info/info:lccn/reg.html

length = 8 then all digits
length = 9 then lccn[1] is lowercase alpha
length = 10 then lccn[1] and lccn[2] are both lowercase alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lowercase alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lowercase alpha

]]

local function lccn (options)
	local lccn = options.id;
	local handler = options.handler;
	local err_flag;																-- presume that LCCN is valid
	local id = lccn;															-- local copy of the LCCN

	id = normalize_lccn (id);													-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();														-- get the length of the LCCN

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits)
			err_flag = set_message ('err_bad_lccn');							-- set an error message
		end
	elseif 9 == len then														-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then							-- does it match our pattern?
			err_flag = set_message ('err_bad_lccn');							-- set an error message
		end
	elseif 10 == len then														-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then					-- ... see if it matches our pattern
				err_flag = set_message ('err_bad_lccn');						-- no match, set an error message
			end
		end
	elseif 11 == len then														-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_flag = set_message ('err_bad_lccn');							-- no match, set an error message
		end
	elseif 12 == len then														-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then						-- see if it matches our pattern
			err_flag = set_message ('err_bad_lccn');							-- no match, set an error message
		end
	else
		err_flag = set_message ('err_bad_lccn');								-- wrong length, set an error message
	end

	if not is_set (err_flag) and nil ~= lccn:find ('%s') then
		err_flag = set_message ('err_bad_lccn');								-- lccn contains a space, set an error message
	end

	if is_set (err_flag) then
		options.coins_list_t['LCCN'] = nil;										-- when error, unset so not included in COinS
	end

	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = lccn, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; M E D R X I V &gt;-----------------------------------------------------------------

Format medRxiv ID and do simple error checking.  Similar to later bioRxiv IDs, medRxiv IDs are prefixed with a
yyyy.mm.dd. date and suffixed with an optional version identifier.  Ealiest date accepted is 2020.01.01

The medRxiv ID is a date followed by an eight-digit number followed by an optional version indicator 'v' and one or more digits:
	https://www.medrxiv.org/content/10.1101/2020.11.16.20232009v2 -&gt; 10.1101/2020.11.16.20232009v2

]]

local function medrxiv (options)
	local id = options.id;
	local handler = options.handler;
	local err_msg_flag = true;													-- flag; assume that there will be an error

	local patterns = {
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%d%d%dv%d+$',			-- y.m.d. date + 8-digit identifier + version (2020-01-01 and later)
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%d%d%d$',				-- y.m.d. date + 8-digit identifier (2020-01-01 and later)
		}
	
	for _, pattern in ipairs (patterns) do										-- spin through the patterns looking for a match
		local y, m, d = id:match (pattern);										-- attempt to get year, month and date from the identifier

		if m then																-- m is nil when no match
			if not is_valid_rxiv_date (y, m, d, 'm') then						-- validate the encoded date; 'm' for medrxiv limit
				break;															-- date fail; break out early so we don't unset the err_msg_flag
			end
		end
		err_msg_flag = nil;														-- we found a match and date is valid so unset the err_msg_flag
		break;																	-- and done
	end																			-- err_msg flag remains set here when no match

	if err_msg_flag then
		options.coins_list_t['MEDRXIV'] = nil;									-- when error, unset so not included in COinS
		set_message ('err_bad_medrxiv');										-- and set the error message
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator,
			encode = handler.encode, access = handler.access});
end


--[[--------------------------&lt; M R &gt;--------------------------------------------------------------------------

A seven digit number; if not seven digits, zero-fill leading digits to make seven digits.

]]

local function mr (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;
	local id_len;

	id_num = id:match ('^[Mm][Rr](%d+)$');										-- identifier with mr prefix

	if is_set (id_num) then
		set_message ('maint_mr_format');										-- add maint cat
	else																		-- plain number without mr prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	id_len = id_num and id_num:len() or 0;
	if (7 &gt;= id_len) and (0 ~= id_len) then
		id = string.rep ('0', 7-id_len) .. id_num;								-- zero-fill leading digits
	else
		set_message ('err_bad_mr');												-- set an error message
		options.coins_list_t['MR'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an OCLC ID.  https://www.oclc.org/batchload/controlnumber.en.html {{dead link}}
archived at: https://web.archive.org/web/20161228233804/https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (options)
	local id = options.id;
	local handler = options.handler;
	local number;

	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- constrain to 1 to 9 digits; change this when OCLC issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if 10 &lt; number:len() then
			number = nil;														-- constrain to 1 to 10 digits; change this when OCLC issues 11-digit numbers
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		set_message ('err_bad_oclc')											-- add an error message if the id is malformed
		options.coins_list_t['OCLC'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local ident, code = id:gsub('^OL', ''):match(&quot;^(%d+([AMW]))$&quot;);				-- strip optional OL prefix followed immediately by digits followed by 'A', 'M', or 'W';
	local err_flag;
	local prefix = {															-- these are appended to the handler.prefix according to code
		['A']='authors/OL',
		['M']='books/OL',
		['W']='works/OL',
		['X']='OL'																-- not a code; spoof when 'code' in id is invalid
		};

	if not ident then
		code = 'X';																-- no code or id completely invalid
		ident = id;																-- copy id to ident so that we display the flawed identifier
		err_flag = set_message ('err_bad_ol');
	end

	if not is_set (err_flag) then
		options.coins_list_t['OL'] = handler.prefix .. prefix[code] .. ident;	-- experiment for ol coins
	else
		options.coins_list_t['OL'] = nil;										-- when error, unset so not included in COinS
	end

	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix .. prefix[code],
		id = ident, separator = handler.separator, encode = handler.encode,
		access = access});
end


--[[--------------------------&lt; O S T I &gt;----------------------------------------------------------------------

Format OSTI and do simple error checking. OSTIs are sequential numbers beginning at 1 and counting up.  This
code checks the OSTI to see that it contains only digits and is less than test_limit specified in the configuration;
the value in test_limit will need to be updated periodically as more OSTIs are issued.

NB. 1018 is the lowest OSTI number found in the wild (so far) and resolving OK on the OSTI site

]]

local function osti (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;

	if id:match(&quot;[^%d]&quot;) then													-- if OSTI has anything but digits
		set_message ('err_bad_osti');											-- set an error message
		options.coins_list_t['OSTI'] = nil;										-- when error, unset so not included in COinS
	else																		-- OSTI is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1018 &gt; id_num or handler.id_limit &lt; id_num then						-- if OSTI is outside test limit boundaries
			set_message ('err_bad_osti');										-- set an error message
			options.coins_list_t['OSTI'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc (options)
	local id = options.id;
	local embargo = options.Embargo;											-- TODO: lowercase?
	local handler = options.handler;
	local err_flag;
	local id_num;
	local text;

	id_num = id:match ('^[Pp][Mm][Cc](%d+)$');									-- identifier with PMC prefix

	if is_set (id_num) then
		set_message ('maint_pmc_format');
	else																		-- plain number without PMC prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if PMC is outside test limit boundaries
			err_flag = set_message ('err_bad_pmc');								-- set an error message
		else
			id = tostring (id_num);												-- make sure id is a string
		end
	else																		-- when id format incorrect
		err_flag = set_message ('err_bad_pmc');									-- set an error message
	end
	
	if is_set (embargo) and is_set (is_embargoed (embargo)) then				-- is PMC is still embargoed?
		text = table.concat (													-- still embargoed so no external link
			{
			make_wikilink (link_label_make (handler), handler.label),
			handler.separator,
			id,
			});
	else
		text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,	-- no embargo date or embargo has expired, ok to link to article
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access,
			auto_link = not err_flag and 'pmc' or nil							-- do not auto-link when PMC has error
			});
	end

	if err_flag then
		options.coins_list_t['PMC'] = nil;										-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid (options)
	local id = options.id;
	local handler = options.handler;

	if id:match(&quot;[^%d]&quot;) then													-- if PMID has anything but digits
		set_message ('err_bad_pmid');											-- set an error message
		options.coins_list_t['PMID'] = nil;										-- when error, unset so not included in COinS
	else																		-- PMID is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if PMID is outside test limit boundaries
			set_message ('err_bad_pmid');										-- set an error message
			options.coins_list_t['PMID'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; R F C &gt;------------------------------------------------------------------------

Format RFC and do simple error checking. RFCs are sequential numbers beginning at 1 and counting up.  This
code checks the RFC to see that it contains only digits and is less than test_limit specified in the configuration;
the value in test_limit will need to be updated periodically as more RFCs are issued.

An index of all RFCs is here: https://tools.ietf.org/rfc/

]]

local function rfc (options)
	local id = options.id;
	local handler = options.handler;

	if id:match(&quot;[^%d]&quot;) then													-- if RFC has anything but digits
		set_message ('err_bad_rfc');											-- set an error message
		options.coins_list_t['RFC'] = nil;										-- when error, unset so not included in COinS
	else																		-- RFC is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if RFC is outside test limit boundaries
			set_message ('err_bad_rfc');										-- set an error message
			options.coins_list_t['RFC'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access});
end


--[[--------------------------&lt; S 2 C I D &gt;--------------------------------------------------------------------

Format an S2CID, do simple error checking

S2CIDs are sequential numbers beginning at 1 and counting up.  This code checks the S2CID to see that it is only
digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically
as more S2CIDs are issued.

]]

local function s2cid (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local id_num;
	local text;
	
	id_num = id:match ('^[1-9]%d*$');											-- id must be all digits; must not begin with 0; no open access flag

 	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if handler.id_limit &lt; id_num then										-- if S2CID is outside test limit boundaries
			set_message ('err_bad_s2cid');										-- set an error message
			options.coins_list_t['S2CID'] = nil;								-- when error, unset so not included in COinS
		end
	else																		-- when id format incorrect
		set_message ('err_bad_s2cid');											-- set an error message
		options.coins_list_t['S2CID'] = nil;									-- when error, unset so not included in COinS
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});

	return text;
end


--[[--------------------------&lt; S B N &gt;------------------------------------------------------------------------

9-digit form of ISBN-10; uses same check-digit validation when SBN is prefixed with an additional '0' to make 10 digits

sbn value not made part of COinS metadata because we don't have a url or isn't a COinS-defined identifier (rft.xxx)
or an identifier registered at info-uri.info (info:)

]]

local function sbn (options)
	local id = options.id;
	local ignore_invalid = options.accept;
	local handler = options.handler;
	local function return_result (check, err_type)								-- local function to handle the various returns
		local SBN = internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,
						prefix = handler.prefix, id = id, separator = handler.separator});
		if not ignore_invalid then												-- if not ignoring SBN errors
			if not check then
				options.coins_list_t['SBN'] = nil;								-- when error, unset so not included in COinS; not really necessary here because sbn not made part of COinS
				set_message ('err_bad_sbn', {err_type});						-- display an error message
				return SBN; 
			end
		else
			set_message ('maint_isbn_ignore');									-- add a maint category even when there is no error (ToDo: Possibly switch to separate message for SBNs only)
		end
		return SBN;
	end

	if id:match ('[^%s-0-9X]') then
		return return_result (false, cfg.err_msg_supl.char);					-- fail if SBN contains anything but digits, hyphens, or the uppercase X
	end

	local ident = id:gsub ('[%s-]', '');										-- remove hyphens and whitespace; they interfere with the rest of the tests

	if  9 ~= ident:len() then
		return return_result (false, cfg.err_msg_supl.length);					-- fail if incorrect length
	end

	if ident:match ('^%d*X?$') == nil then
		return return_result (false, cfg.err_msg_supl.form);					-- fail if SBN has 'X' anywhere but last position
	end

	return return_result (is_valid_isxn ('0' .. ident, 10), cfg.err_msg_supl.check);
end


--[[--------------------------&lt; S S R N &gt;----------------------------------------------------------------------

Format an SSRN, do simple error checking

SSRNs are sequential numbers beginning at 100? and counting up.  This code checks the SSRN to see that it is
only digits and is greater than 99 and less than test_limit; the value in local variable test_limit will need
to be updated periodically as more SSRNs are issued.

]]

local function ssrn (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;
	local text;
	
	id_num = id:match ('^%d+$');												-- id must be all digits

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if 100 &gt; id_num or handler.id_limit &lt; id_num then						-- if SSRN is outside test limit boundaries
			set_message ('err_bad_ssrn');										-- set an error message
			options.coins_list_t['SSRN'] = nil;									-- when error, unset so not included in COinS
		end
	else																		-- when id format incorrect
		set_message ('err_bad_ssrn');											-- set an error message
		options.coins_list_t['SSRN'] = nil;										-- when error, unset so not included in COinS
	end
	
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = options.access});

	return text;
end


--[[--------------------------&lt; U S E N E T _ I D &gt;------------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function usenet_id (options)
	local id = options.id;
	local handler = options.handler;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$') then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		set_message ('err_bad_usenet_id')										-- add an error message if the message id is invalid
		options.coins_list_t['USENETID'] = nil;									-- when error, unset so not included in COinS
	end 
	
	return text;
end


--[[--------------------------&lt; Z B L &gt;-----------------------------------------------------------------------

A numerical identifier in the form nnnn.nnnnn - leading zeros in the first quartet optional

format described here: http://emis.mi.sanu.ac.rs/ZMATH/zmath/en/help/search/

temporary format is apparently eight digits.  Anything else is an error

]]

local function zbl (options)
	local id = options.id;
	local handler = options.handler;

	if id:match('^%d%d%d%d%d%d%d%d$') then										-- is this identifier using temporary format?
		set_message ('maint_zbl');												-- yes, add maint cat
	elseif not id:match('^%d?%d?%d?%d%.%d%d%d%d%d$') then						-- not temporary, is it normal format?
		set_message ('err_bad_zbl');											-- no, set an error message
		options.coins_list_t['ZBL'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--============================&lt;&lt; I N T E R F A C E   F U N C T I O N S &gt;&gt;==========================================

--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message if more than one alias exists in args

]]

local function extract_ids (args)
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs (cfg.id_handlers) do										-- k is uppercase identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one (args, v.parameters, 'err_redundant_parameters' );		-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set (v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; E X T R A C T _ I D _ A C C E S S _ L E V E L S &gt;--------------------------------------

Fetches custom id access levels from arguments using configuration settings. Parameters which have a predefined access
level (e.g. arxiv) do not use this function as they are directly rendered as free without using an additional parameter.

returns a table of k/v pairs where k is same as the identifier's key in cfg.id_handlers and v is the assigned (valid) keyword

access-level values must match the case used in cfg.keywords_lists['id-access'] (lowercase unless there is some special reason for something else)

]]

local function extract_id_access_levels (args, id_list)
	local id_accesses_list = {};
	for k, v in pairs (cfg.id_handlers) do
		local access_param = v.custom_access;									-- name of identifier's access-level parameter
		if is_set (access_param) then
			local access_level = args[access_param];							-- get the assigned value if there is one
			if is_set (access_level) then
				if not in_array (access_level, cfg.keywords_lists['id-access']) then	-- exact match required
					set_message ('err_invalid_param_val', {access_param, access_level});	
					access_level = nil;											-- invalid so unset
				end
				if not is_set (id_list[k]) then									-- identifier access-level must have a matching identifier
					set_message ('err_param_access_requires_param', {k:lower()});	-- parameter name is uppercase in cfg.id_handlers (k); lowercase for error message
				end
				id_accesses_list[k] = cfg.keywords_xlate[access_level];			-- get translated keyword
			end
		end
	end
	return id_accesses_list;
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;----------------------------------------------------

render the identifiers into a sorted sequence table

&lt;ID_list_coins_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value
&lt;options_t&gt; is a table of various k/v option pairs provided in the call to new_build_id_list();
	modified by	this function and passed to all identifier rendering functions
&lt;access_levels_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value (if valid)

returns a sequence table of sorted (by hkey - 'handler' key) rendered identifier strings

]]

local function build_id_list (ID_list_coins_t, options_t, access_levels_t)
	local ID_list_t = {};
	local accept;
	local func_map = {															--function map points to functions associated with hkey identifier
		['ARXIV'] = arxiv,
		['ASIN'] = asin,
		['BIBCODE'] = bibcode,
		['BIORXIV'] = biorxiv,
		['CITESEERX'] = citeseerx,
		['DOI'] = doi,
		['EISSN'] = issn,
		['HDL'] = hdl,
		['ISBN'] = isbn,
		['ISMN'] = ismn,
		['ISSN'] = issn,
		['JFM'] = jfm,
		['JSTOR'] = jstor,
		['LCCN'] = lccn,
		['MEDRXIV'] = medrxiv,
		['MR'] = mr,
		['OCLC'] = oclc,
		['OL'] = openlibrary,
		['OSTI'] = osti,
		['PMC'] = pmc,
		['PMID'] = pmid,
		['RFC']  = rfc,
		['S2CID'] = s2cid,
		['SBN'] = sbn,
		['SSRN'] = ssrn,
		['USENETID'] = usenet_id,
		['ZBL'] = zbl,
		}

	for hkey, v in pairs (ID_list_coins_t) do
		v, accept = has_accept_as_written (v);									-- remove accept-as-written markup if present; accept is boolean true when markup removed; false else
																				-- every function gets the options table with value v and accept boolean
		options_t.hkey = hkey;													-- ~/Configuration handler key
		options_t.id = v;														-- add that identifier value to the options table
		options_t.accept = accept;												-- add the accept boolean flag
		options_t.access = access_levels_t[hkey];								-- add the access level for those that have an |&lt;identifier-access= parameter
		options_t.handler = cfg.id_handlers[hkey];
		options_t.coins_list_t = ID_list_coins_t;								-- pointer to ID_list_coins_t; for |asin= and |ol=; also to keep erroneous values out of the citation's metadata
		options_t.coins_list_t[hkey] = v;										-- id value without accept-as-written markup for metadata
		
		if options_t.handler.access and not in_array (options_t.handler.access, cfg.keywords_lists['id-access']) then
			error (cfg.messages['unknown_ID_access'] .. options_t.handler.access);	-- here when handler access key set to a value not listed in list of allowed id access keywords
		end

		if func_map[hkey] then
			local id_text = func_map[hkey] (options_t);							-- call the function to get identifier text and any error message
			table.insert (ID_list_t, {hkey, id_text});							-- add identifier text to the output sequence table
		else
			error (cfg.messages['unknown_ID_key'] .. hkey);						-- here when func_map doesn't have a function for hkey
		end
	end

	local function comp (a, b)													-- used by following table.sort()
		return a[1]:lower() &lt; b[1]:lower();										-- sort by hkey
	end

	table.sort (ID_list_t, comp);												-- sequence table of tables sort	
	for k, v in ipairs (ID_list_t) do											-- convert sequence table of tables to simple sequence table of strings
		ID_list_t[k] = v[2];													-- v[2] is the identifier rendering from the call to the various functions in func_map{}
	end
	
	return ID_list_t;
end


--[[--------------------------&lt; O P T I O N S _ C H E C K &gt;----------------------------------------------------

check that certain option parameters have their associated identifier parameters with values

&lt;ID_list_coins_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value
&lt;ID_support_t&gt; is a sequence table of tables created in citation0() where each subtable has four elements:
	[1] is the support parameter's assigned value; empty string if not set
	[2] is a text string same as key in cfg.id_handlers
	[3] is cfg.error_conditions key used to create error message
	[4] is original ID support parameter name used to create error message
	
returns nothing; on error emits an appropriate error message

]]

local function options_check (ID_list_coins_t, ID_support_t)
	for _, v in ipairs (ID_support_t) do
		if is_set (v[1]) and not ID_list_coins_t[v[2]] then						-- when support parameter has a value but matching identifier parameter is missing or empty
			set_message (v[3], (v[4]));											-- emit the appropriate error message
		end
	end
end


--[[--------------------------&lt; I D E N T I F I E R _ L I S T S _ G E T &gt;--------------------------------------

Creates two identifier lists: a k/v table of identifiers and their values to be used locally and for use in the
COinS metadata, and a sequence table of the rendered identifier strings that will be included in the rendered
citation.

]]

local function identifier_lists_get (args_t, options_t, ID_support_t)
	local ID_list_coins_t = extract_ids (args_t);										-- get a table of identifiers and their values for use locally and for use in COinS
	options_check (ID_list_coins_t, ID_support_t);										-- ID support parameters must have matching identifier parameters 
	local ID_access_levels_t = extract_id_access_levels (args_t, ID_list_coins_t);		-- get a table of identifier access levels
	local ID_list_t = build_id_list (ID_list_coins_t, options_t, ID_access_levels_t);	-- get a sequence table of rendered identifier strings

	return ID_list_t, ID_list_coins_t;											-- return the tables
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	has_accept_as_written = utilities_page_ptr.has_accept_as_written;			-- import functions from select Module:Citation/CS1/Utilities module
	is_set = utilities_page_ptr.is_set;								
	in_array = utilities_page_ptr.in_array;
	set_message = utilities_page_ptr.set_message;
	select_one = utilities_page_ptr.select_one;
	substitute = utilities_page_ptr.substitute;
	make_wikilink = utilities_page_ptr.make_wikilink;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	auto_link_urls = auto_link_urls,											-- table of identifier URLs to be used when auto-linking |title=
	
	identifier_lists_get = identifier_lists_get,								-- experiment to replace individual calls to build_id_list(), extract_ids, extract_id_access_levels
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>pkfpwea3v2exbtw6sggib18ty1ubykp</sha1>
    </revision>
    <revision>
      <id>4923</id>
      <parentid>4922</parentid>
      <timestamp>2023-08-12T22:15:16Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>rare 8-digit medrxiv without date;</comment>
      <origin>4923</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="76658" sha1="sh0l2n4ahyihscjfw9ol31xgrbnds2a" xml:space="preserve">--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local has_accept_as_written, is_set, in_array, set_message, select_one,			-- functions in Module:Citation/CS1/Utilities
		substitute, make_wikilink;

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

declare variables here that have page-wide scope that are not brought in from other modules; that are created here and used here

]]

local auto_link_urls = {};														-- holds identifier URLs for those identifiers that can auto-link |title=


--============================&lt;&lt; H E L P E R   F U N C T I O N S &gt;&gt;============================================

--[[--------------------------&lt; W I K I D A T A _ A R T I C L E _ N A M E _ G E T &gt;----------------------------

as an aid to internationalizing identifier-label wikilinks, gets identifier article names from Wikidata.

returns :&lt;lang code&gt;:&lt;article title&gt; when &lt;q&gt; has an &lt;article title&gt; for &lt;lang code&gt;; nil else

for identifiers that do not have q, returns nil

for wikis that do not have mw.wikibase installed, returns nil

]]

local function wikidata_article_name_get (q)
	if not is_set (q) or (q and not mw.wikibase) then							-- when no q number or when a q number but mw.wikibase not installed on this wiki
		return nil;																-- abandon
	end

	local wd_article;
	local this_wiki_code = cfg.this_wiki_code;									-- Wikipedia subdomain; 'en' for en.wikipedia.org

	wd_article = mw.wikibase.getSitelink (q, this_wiki_code .. 'wiki');			-- fetch article title from WD; nil when no title available at this wiki

	if wd_article then
		wd_article = table.concat ({':', this_wiki_code, ':', wd_article});		-- interwiki-style link without brackets if taken from WD; leading colon required
	end

	return wd_article;															-- article title from WD; nil else
end


--[[--------------------------&lt; L I N K _ L A B E L _ M A K E &gt;------------------------------------------------

common function to create identifier link label from handler table or from Wikidata

returns the first available of
	1. redirect from local wiki's handler table (if enabled)
	2. Wikidata (if there is a Wikidata entry for this identifier in the local wiki's language)
	3. label specified in the local wiki's handler table
	
]]

local function link_label_make (handler)
	local wd_article;
	
	if not (cfg.use_identifier_redirects and is_set (handler.redirect)) then	-- redirect has priority so if enabled and available don't fetch from Wikidata because expensive
		wd_article = wikidata_article_name_get (handler.q);						-- if Wikidata has an article title for this wiki, get it;
	end
	
	return (cfg.use_identifier_redirects and is_set (handler.redirect) and handler.redirect) or wd_article or handler.link;
end


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki-style external link

]]

local function external_link_id (options)
	local url_string = options.id;
	local ext_link;
	local this_wiki_code = cfg.this_wiki_code;									-- Wikipedia subdomain; 'en' for en.wikipedia.org
	local wd_article;															-- article title from Wikidata
	
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode (url_string, 'PATH');
	end

	if options.auto_link and is_set (options.access) then
		auto_link_urls[options.auto_link] = table.concat ({options.prefix, url_string, options.suffix});
	end

	ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or &quot;&quot;, mw.text.nowiki (options.id));
	if is_set (options.access) then
		ext_link = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[options.access].class, cfg.presentation[options.access].title, ext_link});	-- add the free-to-read / paywall lock
	end

	return table.concat	({
		make_wikilink (link_label_make (options), options.label),				-- redirect, Wikidata link, or locally specified link (in that order)
		options.separator or '&amp;nbsp;',
		ext_link
		});
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki-style internal link

TODO: Does not currently need to support options.access, options.encode, auto-linking and COinS (as in external_link_id),
but may be needed in the future for :m:Interwiki_map custom-prefixes like :arxiv:, :bibcode:, :DOI:, :hdl:, :ISSN:,
:JSTOR:, :Openlibrary:, :PMID:, :RFC:.

]]

local function internal_link_id (options)
	local id = mw.ustring.gsub (options.id, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9

	return table.concat (
		{
		make_wikilink (link_label_make (options), options.label),				-- wiki-link the identifier label
		options.separator or '&amp;nbsp;',											-- add the separator
		make_wikilink (
			table.concat (
				{
				options.prefix,
				id,																-- translated to Western digits
				options.suffix or ''
				}),
			substitute (cfg.presentation['bdi'], {'', mw.text.nowiki (options.id)})	-- bdi tags to prevent Latin script identifiers from being reversed at RTL language wikis
			);																	-- nowiki because MediaWiki still has magic links for ISBN and the like; TODO: is it really required?
		});
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |pmc-embargo-date= against
today's date.  If embargo date is in the future, returns the content of |pmc-embargo-date=; otherwise, returns
an empty string because the embargo has expired or because |pmc-embargo-date= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, todays_date;
		good1, embargo_date = pcall (lang.formatDate, lang, 'U', embargo);
		todays_date = lang:formatDate ('U');
	
		if good1 then															-- if embargo date is a good date
			if tonumber (embargo_date) &gt;= tonumber (todays_date) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				set_message ('maint_pmc_embargo');								-- embargo has expired; add main cat
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |pmc-embargo-date= not set return empty string
end


--[=[-------------------------&lt; I S _ V A L I D _ R X I V _ D A T E &gt;------------------------------------------

for biorxiv, returns true if:
	2019-12-11T00:00Z &lt;= biorxiv_date &lt; today + 2 days
for medrxiv, returns true if:
	2020-01-01T00:00Z &lt;= medrxiv_date &lt; today + 2 days
	
The dated form of biorxiv identifier has a start date of 2019-12-11.  The Unix timestamp for that date is {{#time:U|2019-12-11}} = 1576022400
The medrxiv identifier has a start date of 2020-01-01.  The Unix timestamp for that date is {{#time:U|2020-01-01}} = 1577836800

&lt;rxiv_date&gt; is the date provided in those |biorxiv= parameter values that are dated and in |medrxiv= parameter values at time 00:00:00 UTC
&lt;today&gt; is the current date at time 00:00:00 UTC plus 48 hours
	if today's date is 2023-01-01T00:00:00 then
		adding 24 hours gives 2023-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2023-01-03T00:00:00 – one second more than tomorrow

inputs:
	&lt;y&gt;, &lt;m&gt;, &lt;d&gt; – year, month, day parts of the date from the birxiv or medrxiv identifier
	&lt;select&gt; 'b' for biorxiv, 'm' for medrxiv; defaults to 'b'

]=]

local function is_valid_rxiv_date (y, m, d, select)
	if 0 == tonumber (m) and 12 &lt; tonumber (m) then								-- &lt;m&gt; must be a number 1–12
		return false;
	end
	if 0 == tonumber (d) and 31 &lt; tonumber (d) then								-- &lt;d&gt; must be a number 1–31; TODO: account for month length and leap yer?
		return false;
	end
	
	local rxiv_date = table.concat ({y, m, d}, '-');							-- make ymd date string
	local good1, good2;
	local rxiv_ts, tomorrow_ts;													-- to hold Unix timestamps representing the dates
	local lang_object = mw.getContentLanguage();

	good1, rxiv_ts = pcall (lang_object.formatDate, lang_object, 'U', rxiv_date);		-- convert rxiv_date value to Unix timestamp 
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which tonumber() may not understand
		rxiv_ts = tonumber (rxiv_ts) or lang_object:parseFormattedNumber (rxiv_ts);	-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to Unix timestamp
	end

	local limit_ts = ((select and ('m' == select)) and 1577836800) or 1576022400;	-- choose the appropriate limit timesatmp

	return ((limit_ts &lt;= rxiv_ts) and (rxiv_ts &lt; tomorrow_ts))					-- limit_ts &lt;= rxiv_date &lt; tomorrow's date
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all ISBN/ISSN digits including the check digit.
ISBN-13 is checked in isbn().

If the number is valid the result will be 0. Before calling this function, ISBN/ISSN must be checked for length
and stripped of dashes, spaces and other non-ISxN characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39, 'X' → 0x58
	len = len + 1;																-- adjust to be a loop counter
	for i, v in ipairs (isxn_str) do											-- loop through all of the bytes and calculate the checksum
		if v == string.byte (&quot;X&quot; ) then											-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10 * (len - i);										-- it represents 10 decimal
		else
			temp = temp + tonumber (string.char (v) )*(len-i);
		end
	end
	return temp % 11 == 0;														-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N _ 1 3 &gt;-----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 ISBN/ISMN digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, ISBN-13/ISMN must be checked for length
and stripped of dashes, spaces and other non-ISxN-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39
	for i, v in ipairs (isxn_str) do
		temp = temp + (3 - 2*(i % 2)) * tonumber (string.char (v) );			-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when ISBN-13/ISMN is correct
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

LCCN normalization (https://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized LCCN for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.

]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);												-- 1. strip whitespace

	if nil ~= string.find (lccn, '/') then
		lccn = lccn:match (&quot;(.-)/&quot;);											-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);									-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then														-- if there was a hyphen
		suffix = string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;				-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn = prefix..suffix;													-- reassemble the LCCN
	end
	
	return lccn;
	end


--============================&lt;&lt; I D E N T I F I E R   F U N C T I O N S &gt;&gt;====================================

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: https://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9107 and 0703, is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation; not the same as |class= parameter which is not supported in this form
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number

]]

local function arxiv (options)
	local id = options.id;
	local class = options.Class;												-- TODO: lowercase?
	local handler = options.handler;
	local year, month, version;
	local err_msg = false;														-- assume no error message
	local text;																	-- output text
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9107-0703 format with or without version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_msg = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 with or without version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then									-- when year is 07, is month invalid (before April)?
				err_msg = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format with or without version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_msg = true;														-- flag for error message
		end

	else
		err_msg = true;															-- not a recognized format; flag for error message
	end

	if err_msg then
		options.coins_list_t['ARXIV'] = nil;									-- when error, unset so not included in COinS
	end
	
	local err_msg_t = {};
	if err_msg then
		set_message ('err_bad_arxiv');
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access});

	if is_set (class) then
		if id:match ('^%d+') then
			text = table.concat ({text, ' [[https://arxiv.org/archive/', class, ' ', class, ']]'});	-- external link within square brackets, not wikilink
		else
			set_message ('err_class_ignored');
		end
	end

	return text;
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode ID.

Format for bibcodes is specified here: https://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		9–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local ignore_invalid = options.accept;
	local err_type;
	local err_msg = '';
	local year;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode,
		access = access});
	
	if 19 ~= id:len() then
		err_type = cfg.err_msg_supl.length;
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%w&amp;%.][%w&amp;%.][%w&amp;%.][%w.]+[%a%.]$&quot;);
		if not year then														-- if nil then no pattern match
			err_type = cfg.err_msg_supl.value;									-- so value error
		else
			local next_year = tonumber (os.date ('%Y')) + 1;					-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = cfg.err_msg_supl.year;								-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = cfg.err_msg_supl.journal;							-- journal abbreviation must not have '&amp;.' (if it does it's missing a letter)
			end
			if id:match ('.........%.tmp%.') then								-- temporary bibcodes when positions 10–14 are '.tmp.'
				set_message ('maint_bibcode');
			end
		end
	end

	if is_set (err_type) and not ignore_invalid then							-- if there was an error detected and accept-as-written markup not used
		set_message ('err_bad_bibcode', {err_type});
		options.coins_list_t['BIBCODE'] = nil;									-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; B I O R X I V &gt;-----------------------------------------------------------------

Format bioRxiv ID and do simple error checking.  Before 2019-12-11, biorXiv IDs were 10.1101/ followed by exactly
6 digits.  After 2019-12-11, biorXiv IDs retained the six-digit identifier but prefixed that with a yyyy.mm.dd. 
date and suffixed with an optional version identifier.

The bioRxiv ID is the string of characters:
	https://doi.org/10.1101/078733 -&gt; 10.1101/078733
or a date followed by a six-digit number followed by an optional version indicator 'v' and one or more digits:
	https://www.biorxiv.org/content/10.1101/2019.12.11.123456v2 -&gt; 10.1101/2019.12.11.123456v2
	
see https://www.biorxiv.org/about-biorxiv

]]

local function biorxiv (options)
	local id = options.id;
	local handler = options.handler;
	local err_msg = true;														-- flag; assume that there will be an error
	
	local patterns = {
		'^10%.1101/%d%d%d%d%d%d$',												-- simple 6-digit identifier (before 2019-12-11)
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%dv%d+$',				-- y.m.d. date + 6-digit identifier + version (after 2019-12-11)
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%d$',					-- y.m.d. date + 6-digit identifier (after 2019-12-11)
		}
	
	for _, pattern in ipairs (patterns) do										-- spin through the patterns looking for a match
		if id:match (pattern) then
			local y, m, d = id:match (pattern);									-- found a match, attempt to get year, month and date from the identifier

			if m then															-- m is nil when id is the six-digit form
				if not is_valid_rxiv_date (y, m, d, 'b') then					-- validate the encoded date; 'b' for biorxiv limit
					break;														-- date fail; break out early so we don't unset the error message
				end
			end
			err_msg = nil;														-- we found a match so unset the error message
			break;																-- and done
		end
	end																			-- err_cat remains set here when no match

	if err_msg then
		options.coins_list_t['BIORXIV'] = nil;									-- when error, unset so not included in COinS
		set_message ('err_bad_biorxiv');										-- and set the error message
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator,
			encode = handler.encode, access = handler.access});
end


--[[--------------------------&lt; C I T E S E E R X &gt;------------------------------------------------------------

CiteSeerX use their own notion of &quot;doi&quot; (not to be confused with the identifiers resolved via doi.org).

The description of the structure of this identifier can be found at Help_talk:Citation_Style_1/Archive_26#CiteSeerX_id_structure

]]

local function citeseerx (options)
	local id = options.id;
	local handler = options.handler;
	local matched;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode,
		access = handler.access});
	
	matched = id:match (&quot;^10%.1%.1%.[1-9]%d?%d?%d?%.[1-9]%d?%d?%d?$&quot;);
	if not matched then
		set_message ('err_bad_citeseerx' );
		options.coins_list_t['CITESEERX'] = nil;								-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the DOI name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in DOI names.

https://www.doi.org/doi_handbook/2_Numbering.html				-- 2.2 Syntax of a DOI name
https://www.doi.org/doi_handbook/2_Numbering.html#2.2.2			-- 2.2.2 DOI prefix

]]

local function doi (options)
	local id = options.id;
	local inactive = options.DoiBroken
	local access = options.access;
	local ignore_invalid = options.accept;
	local handler = options.handler;
	local err_flag;

	local text;
	if is_set (inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;);						-- try to get the year portion from the inactive date
		local inactive_month, good;

		if is_set (inactive_year) then
			if 4 &lt; inactive:len() then											-- inactive date has more than just a year (could be anything)
				local lang_obj = mw.getContentLanguage();						-- get a language object for this wiki
				good, inactive_month = pcall (lang_obj.formatDate, lang_obj, 'F', inactive);	-- try to get the month name from the inactive date
				if not good then
					inactive_month = nil;										-- something went wrong so make sure this is unset
				end
			end
		end																		-- otherwise, |doi-broken-date= has something but it isn't a date
		
		if is_set (inactive_year) and is_set (inactive_month) then
			set_message ('maint_doi_inactive_dated', {inactive_year, inactive_month, ' '});
		elseif is_set (inactive_year) then
			set_message ('maint_doi_inactive_dated', {inactive_year, '', ''});
		else
			set_message ('maint_doi_inactive');
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. ' ' .. inactive .. ')';
	end

	local registrant = mw.ustring.match (id, '^10%.([^/]+)/[^%s–]-[^%.,]$');	-- registrant set when DOI has the proper basic form

	local registrant_err_patterns = {											-- these patterns are for code ranges that are not supported 
		'^[^1-3]%d%d%d%d%.%d+$',												-- 5 digits with subcode (0xxxx, 40000+); accepts: 10000–39999
		'^[^1-6]%d%d%d%d$',														-- 5 digits without subcode (0xxxx, 60000+); accepts: 10000–69999
		'^[^1-9]%d%d%d%.%d+$',												-- 4 digits with subcode (0xxx); accepts: 1000–9999
		'^[^1-9]%d%d%d$',														-- 4 digits without subcode (0xxx); accepts: 1000–9999
		'^%d%d%d%d%d%d+',														-- 6 or more digits
		'^%d%d?%d?$',															-- less than 4 digits without subcode (3 digits with subcode is legitimate)
		'^%d%d?%.[%d%.]+',														-- 1 or 2 digits with subcode
		'^5555$',																-- test registrant will never resolve
		'[^%d%.]',																-- any character that isn't a digit or a dot
		}

	if not ignore_invalid then
		if registrant then														-- when DOI has proper form
			for i, pattern in ipairs (registrant_err_patterns) do				-- spin through error patterns
				if registrant:match (pattern) then								-- to validate registrant codes
					err_flag = set_message ('err_bad_doi');						-- when found, mark this DOI as bad
					break;														-- and done
				end
			end
		else
			err_flag = set_message ('err_bad_doi');								-- invalid directory or malformed
		end
	else
		set_message ('maint_doi_ignore');
	end

	if err_flag then
		options.coins_list_t['DOI'] = nil;										-- when error, unset so not included in COinS
	end
	
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access,
		auto_link = not (err_flag or is_set (inactive) or ignore_invalid) and 'doi' or nil -- do not auto-link when |doi-broken-date= has a value or when there is a DOI error or (to play it safe, after all, auto-linking is not essential) when invalid DOIs are ignored
		}) .. (inactive or '');

	return text;
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

Query string parameters are named here: https://www.handle.net/proxy_servlet.html.  query strings are not displayed
but since '?' is an allowed character in an HDL, '?' followed by one of the query parameters is the only way we
have to detect the query string so that it isn't URL-encoded with the rest of the identifier.

]]

local function hdl (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local query_params = {														-- list of known query parameters from https://www.handle.net/proxy_servlet.html
		'noredirect',
		'ignore_aliases',
		'auth',
		'cert',
		'index',
		'type',
		'urlappend',
		'locatt',
		'action',
		}
	
	local hdl, suffix, param = id:match ('(.-)(%?(%a+).+)$');					-- look for query string
	local found;

	if hdl then																	-- when there are query strings, this is the handle identifier portion
		for _, q in ipairs (query_params) do									-- spin through the list of query parameters
			if param:match ('^' .. q) then										-- if the query string begins with one of the parameters
				found = true;													-- announce a find
				break;															-- and stop looking
			end
		end
	end

	if found then
		id = hdl;																-- found so replace id with the handle portion; this will be URL-encoded, suffix will not
	else
		suffix = '';															-- make sure suffix is empty string for concatenation else
	end

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, suffix = suffix, separator = handler.separator, encode = handler.encode, access = access})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- HDL must contain a forward slash, must not contain spaces, endashes, and must not end with period or comma
		set_message ('err_bad_hdl' );
		options.coins_list_t['HDL'] = nil;										-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; I S B N &gt;----------------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function isbn (options)
	local isbn_str = options.id;
	local ignore_invalid = options.accept;
	local handler = options.handler;

	local function return_result (check, err_type)								-- local function to handle the various returns
		local ISBN = internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,
						prefix = handler.prefix, id = isbn_str, separator = handler.separator});
		if ignore_invalid then													-- if ignoring ISBN errors
			set_message ('maint_isbn_ignore');									-- add a maint category even when there is no error
		else																	-- here when not ignoring
			if not check then													-- and there is an error
				options.coins_list_t['ISBN'] = nil;								-- when error, unset so not included in COinS
				set_message ('err_bad_isbn', err_type);							-- set an error message
				return ISBN;										 			-- return id text
			end
		end
		return ISBN;															-- return id text
	end

	if nil ~= isbn_str:match ('[^%s-0-9X]') then
		return return_result (false, cfg.err_msg_supl.char);					-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end

	local id = isbn_str:gsub ('[%s-]', '');										-- remove hyphens and whitespace

	local len = id:len();
 
	if len ~= 10 and len ~= 13 then
		return return_result (false, cfg.err_msg_supl.length);					-- fail if incorrect length
	end

	if len == 10 then
		if id:match ('^%d*X?$') == nil then										-- fail if isbn_str has 'X' anywhere but last position
			return return_result (false, cfg.err_msg_supl.form);									
		end
		if not is_valid_isxn (id, 10) then										-- test isbn-10 for numerical validity
			return return_result (false, cfg.err_msg_supl.check);				-- fail if isbn-10 is not numerically valid
		end
		if id:find ('^63[01]') then												-- 630xxxxxxx and 631xxxxxxx are (apparently) not valid isbn group ids but are used by amazon as numeric identifiers (asin)
			return return_result (false, cfg.err_msg_supl.group);				-- fail if isbn-10 begins with 630/1
		end
		return return_result (true, cfg.err_msg_supl.check);					-- pass if isbn-10 is numerically valid
	else
		if id:match ('^%d+$') == nil then
			return return_result (false, cfg.err_msg_supl.char);				-- fail if ISBN-13 is not all digits
		end
		if id:match ('^97[89]%d*$') == nil then
			return return_result (false, cfg.err_msg_supl.prefix);				-- fail when ISBN-13 does not begin with 978 or 979
		end
		if id:match ('^9790') then
			return return_result (false, cfg.err_msg_supl.group);				-- group identifier '0' is reserved to ISMN
		end
		return return_result (is_valid_isxn_13 (id), cfg.err_msg_supl.check);
	end
end


--[[--------------------------&lt; A S I N &gt;----------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: ASIN must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, ASINs must be 10-digit
ISBN. If 10-digit ISBN, add a maintenance category so a bot or AWB script can replace |asin= with |isbn=.
Error message if not 10 characters, if not ISBN-10, if mixed and first character is a digit.

|asin=630....... and |asin=631....... are (apparently) not a legitimate ISBN though it checksums as one; these
do not cause this function to emit the maint_asin message

This function is positioned here because it calls isbn()

]]

local function asin (options)
	local id = options.id;
	local domain = options.ASINTLD;
	
	local err_flag;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_flag = set_message ('err_bad_asin');								-- ASIN is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then							-- if 10-digit numeric (or 9 digits with terminal X)
			if is_valid_isxn (id, 10) then										-- see if ASIN value is or validates as ISBN-10
				if not id:find ('^63[01]') then									-- 630xxxxxxx and 631xxxxxxx are (apparently) not a valid isbn prefixes but are used by amazon as a numeric identifier
					err_flag = set_message ('err_bad_asin');					-- ASIN has ISBN-10 form but begins with something other than 630/1 so probably an isbn 
				end
			elseif not is_set (err_flag) then
				err_flag = set_message ('err_bad_asin');						-- ASIN is not ISBN-10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_flag = set_message ('err_bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if (not is_set (domain)) or in_array (domain, {'us'}) then					-- default: United States
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then									-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'z.cn'}) then 									-- China
		domain = &quot;cn&quot;;
	elseif in_array (domain, {'au', 'br', 'mx', 'sg', 'tr'}) then				-- Australia, Brazil, Mexico, Singapore, Turkey
		domain = &quot;com.&quot; .. domain;
	elseif not in_array (domain, {'ae', 'ca', 'cn', 'de', 'es', 'fr', 'in', 'it', 'nl', 'pl', 'sa', 'se', 'co.jp', 'co.uk', 'com', 'com.au', 'com.br', 'com.mx', 'com.sg', 'com.tr'}) then -- Arabic Emirates, Canada, China, Germany, Spain, France, Indonesia, Italy, Netherlands, Poland, Saudi Arabia, Sweden (as of 2021-03 Austria (.at), Liechtenstein (.li) and Switzerland (.ch) still redirect to the German site (.de) with special settings, so don't maintain local ASINs for them)
		err_flag = set_message ('err_bad_asin_tld');							-- unsupported asin-tld value
	end
	local handler = options.handler;

	if not is_set (err_flag) then
		options.coins_list_t['ASIN'] = handler.prefix .. domain .. &quot;/dp/&quot; .. id;	-- asin for coins
	else
		options.coins_list_t['ASIN'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix .. domain .. &quot;/dp/&quot;,
		id = id, encode = handler.encode, separator = handler.separator})
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to ISBN-13, ISMN is 13 digits beginning 979-0-... and uses the
same check digit calculations.  See https://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

ismn value not made part of COinS metadata because we don't have a url or isn't a COinS-defined identifier (rft.xxx)
or an identifier registered at info-uri.info (info:)

]]

local function ismn (options)
	local id = options.id;
	local handler = options.handler;
	local text;
	local valid_ismn = true;
	local id_copy;

	id_copy = id;																-- save a copy because this testing is destructive
	id = id:gsub ('[%s-]', '');													-- remove hyphens and white space

	if 13 ~= id:len() or id:match (&quot;^9790%d*$&quot; ) == nil then					-- ISMN must be 13 digits and begin with 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ISMN
	end

	--	text = internal_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,		-- use this (or external version) when there is some place to link to
	--		prefix = handler.prefix, id = id_copy, separator = handler.separator, encode = handler.encode})

	text = table.concat (														-- because no place to link to yet
		{
		make_wikilink (link_label_make (handler), handler.label),
		handler.separator,
		id_copy
		});

	if false == valid_ismn then
		options.coins_list_t['ISMN'] = nil;										-- when error, unset so not included in COinS; not really necessary here because ismn not made part of COinS
		set_message ('err_bad_ismn');											-- create an error message if the ISMN is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an ISSN.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [https://www.worldcat.org/issn/0819 4327 0819 4327]	-- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the ISSN midpoint.  It also validates the ISSN for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check ISSN error message.  The
ISSN is always displayed with a hyphen, even if the ISSN was given as a single group of 8 digits.

]]

local function issn (options)
	local id = options.id;
	local handler = options.handler;
	local ignore_invalid = options.accept;

	local issn_copy = id;														-- save a copy of unadulterated ISSN; use this version for display if ISSN does not validate
	local text;
	local valid_issn = true;

	id = id:gsub ('[%s-]', '');													-- remove hyphens and whitespace

	if 8 ~= id:len() or nil == id:match (&quot;^%d*X?$&quot; ) then						-- validate the ISSN: 8 digits long, containing only 0-9 or X in the last position
		valid_issn = false;														-- wrong length or improper character
	else
		valid_issn = is_valid_isxn (id, 8);										-- validate ISSN
	end

	if true == valid_issn then
		id = string.sub (id, 1, 4 ) .. &quot;-&quot; .. string.sub (id, 5 );				-- if valid, display correctly formatted version
	else
		id = issn_copy;															-- if not valid, show the invalid ISSN with error message
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode})

	if ignore_invalid then
		set_message ('maint_issn_ignore');
	else
		if false == valid_issn then
			options.coins_list_t['ISSN'] = nil;									-- when error, unset so not included in COinS
			set_message ('err_bad_issn', (options.hkey == 'EISSN') and 'e' or '');	-- create an error message if the ISSN is invalid
		end 
	end
	
	return text;
end


--[[--------------------------&lt; J F M &gt;-----------------------------------------------------------------------

A numerical identifier in the form nn.nnnn.nn

]]

local function jfm (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;

	id_num = id:match ('^[Jj][Ff][Mm](.*)$');									-- identifier with jfm prefix; extract identifier

	if is_set (id_num) then
		set_message ('maint_jfm_format');
	else																		-- plain number without JFM prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num and id_num:match('^%d%d%.%d%d%d%d%.%d%d$') then
		id = id_num;															-- jfm matches pattern
	else
		set_message ('err_bad_jfm' );											-- set an error message
		options.coins_list_t['JFM'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; J S T O R &gt;--------------------------------------------------------------------

Format a JSTOR with some error checking

]]

local function jstor (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;

	if id:find ('[Jj][Ss][Tt][Oo][Rr]') or id:find ('^https?://') or id:find ('%s') then
		set_message ('err_bad_jstor');											-- set an error message
		options.coins_list_t['JSTOR'] = nil;									-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});
end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
https://oclc-research.github.io/infoURI-Frozen/info-uri.info/info:lccn/reg.html

length = 8 then all digits
length = 9 then lccn[1] is lowercase alpha
length = 10 then lccn[1] and lccn[2] are both lowercase alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lowercase alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lowercase alpha

]]

local function lccn (options)
	local lccn = options.id;
	local handler = options.handler;
	local err_flag;																-- presume that LCCN is valid
	local id = lccn;															-- local copy of the LCCN

	id = normalize_lccn (id);													-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();														-- get the length of the LCCN

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits)
			err_flag = set_message ('err_bad_lccn');							-- set an error message
		end
	elseif 9 == len then														-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then							-- does it match our pattern?
			err_flag = set_message ('err_bad_lccn');							-- set an error message
		end
	elseif 10 == len then														-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then					-- ... see if it matches our pattern
				err_flag = set_message ('err_bad_lccn');						-- no match, set an error message
			end
		end
	elseif 11 == len then														-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_flag = set_message ('err_bad_lccn');							-- no match, set an error message
		end
	elseif 12 == len then														-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then						-- see if it matches our pattern
			err_flag = set_message ('err_bad_lccn');							-- no match, set an error message
		end
	else
		err_flag = set_message ('err_bad_lccn');								-- wrong length, set an error message
	end

	if not is_set (err_flag) and nil ~= lccn:find ('%s') then
		err_flag = set_message ('err_bad_lccn');								-- lccn contains a space, set an error message
	end

	if is_set (err_flag) then
		options.coins_list_t['LCCN'] = nil;										-- when error, unset so not included in COinS
	end

	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = lccn, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; M E D R X I V &gt;-----------------------------------------------------------------

Format medRxiv ID and do simple error checking.  Similar to later bioRxiv IDs, medRxiv IDs are prefixed with a
yyyy.mm.dd. date and suffixed with an optional version identifier.  Ealiest date accepted is 2020.01.01

The medRxiv ID is a date followed by an eight-digit number followed by an optional version indicator 'v' and one or more digits:
	https://www.medrxiv.org/content/10.1101/2020.11.16.20232009v2 -&gt; 10.1101/2020.11.16.20232009v2

]]

local function medrxiv (options)
	local id = options.id;
	local handler = options.handler;
	local err_msg_flag = true;													-- flag; assume that there will be an error

	local patterns = {
		'%d%d%d%d%d%d%d%d$',													-- simple 8-digit identifier; these should be relatively rare
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%d%d%dv%d+$',			-- y.m.d. date + 8-digit identifier + version (2020-01-01 and later)
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%d%d%d$',				-- y.m.d. date + 8-digit identifier (2020-01-01 and later)
		}
	
	for _, pattern in ipairs (patterns) do										-- spin through the patterns looking for a match
		if id:match (pattern) then
			local y, m, d = id:match (pattern);									-- found a match, attempt to get year, month and date from the identifier

			if m then															-- m is nil when id is the 8-digit form
				if not is_valid_rxiv_date (y, m, d, 'b') then					-- validate the encoded date; 'b' for medrxiv limit
					break;														-- date fail; break out early so we don't unset the error message
				end
			end
			err_msg_flag = nil;													-- we found a match so unset the error message
			break;																-- and done
		end
	end																			-- &lt;err_msg_flag&gt; remains set here when no match

	if err_msg_flag then
		options.coins_list_t['MEDRXIV'] = nil;									-- when error, unset so not included in COinS
		set_message ('err_bad_medrxiv');										-- and set the error message
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator,
			encode = handler.encode, access = handler.access});
end


--[[--------------------------&lt; M R &gt;--------------------------------------------------------------------------

A seven digit number; if not seven digits, zero-fill leading digits to make seven digits.

]]

local function mr (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;
	local id_len;

	id_num = id:match ('^[Mm][Rr](%d+)$');										-- identifier with mr prefix

	if is_set (id_num) then
		set_message ('maint_mr_format');										-- add maint cat
	else																		-- plain number without mr prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	id_len = id_num and id_num:len() or 0;
	if (7 &gt;= id_len) and (0 ~= id_len) then
		id = string.rep ('0', 7-id_len) .. id_num;								-- zero-fill leading digits
	else
		set_message ('err_bad_mr');												-- set an error message
		options.coins_list_t['MR'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an OCLC ID.  https://www.oclc.org/batchload/controlnumber.en.html {{dead link}}
archived at: https://web.archive.org/web/20161228233804/https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (options)
	local id = options.id;
	local handler = options.handler;
	local number;

	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- constrain to 1 to 9 digits; change this when OCLC issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if 10 &lt; number:len() then
			number = nil;														-- constrain to 1 to 10 digits; change this when OCLC issues 11-digit numbers
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		set_message ('err_bad_oclc')											-- add an error message if the id is malformed
		options.coins_list_t['OCLC'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local ident, code = id:gsub('^OL', ''):match(&quot;^(%d+([AMW]))$&quot;);				-- strip optional OL prefix followed immediately by digits followed by 'A', 'M', or 'W';
	local err_flag;
	local prefix = {															-- these are appended to the handler.prefix according to code
		['A']='authors/OL',
		['M']='books/OL',
		['W']='works/OL',
		['X']='OL'																-- not a code; spoof when 'code' in id is invalid
		};

	if not ident then
		code = 'X';																-- no code or id completely invalid
		ident = id;																-- copy id to ident so that we display the flawed identifier
		err_flag = set_message ('err_bad_ol');
	end

	if not is_set (err_flag) then
		options.coins_list_t['OL'] = handler.prefix .. prefix[code] .. ident;	-- experiment for ol coins
	else
		options.coins_list_t['OL'] = nil;										-- when error, unset so not included in COinS
	end

	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix .. prefix[code],
		id = ident, separator = handler.separator, encode = handler.encode,
		access = access});
end


--[[--------------------------&lt; O S T I &gt;----------------------------------------------------------------------

Format OSTI and do simple error checking. OSTIs are sequential numbers beginning at 1 and counting up.  This
code checks the OSTI to see that it contains only digits and is less than test_limit specified in the configuration;
the value in test_limit will need to be updated periodically as more OSTIs are issued.

NB. 1018 is the lowest OSTI number found in the wild (so far) and resolving OK on the OSTI site

]]

local function osti (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;

	if id:match(&quot;[^%d]&quot;) then													-- if OSTI has anything but digits
		set_message ('err_bad_osti');											-- set an error message
		options.coins_list_t['OSTI'] = nil;										-- when error, unset so not included in COinS
	else																		-- OSTI is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1018 &gt; id_num or handler.id_limit &lt; id_num then						-- if OSTI is outside test limit boundaries
			set_message ('err_bad_osti');										-- set an error message
			options.coins_list_t['OSTI'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc (options)
	local id = options.id;
	local embargo = options.Embargo;											-- TODO: lowercase?
	local handler = options.handler;
	local err_flag;
	local id_num;
	local text;

	id_num = id:match ('^[Pp][Mm][Cc](%d+)$');									-- identifier with PMC prefix

	if is_set (id_num) then
		set_message ('maint_pmc_format');
	else																		-- plain number without PMC prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if PMC is outside test limit boundaries
			err_flag = set_message ('err_bad_pmc');								-- set an error message
		else
			id = tostring (id_num);												-- make sure id is a string
		end
	else																		-- when id format incorrect
		err_flag = set_message ('err_bad_pmc');									-- set an error message
	end
	
	if is_set (embargo) and is_set (is_embargoed (embargo)) then				-- is PMC is still embargoed?
		text = table.concat (													-- still embargoed so no external link
			{
			make_wikilink (link_label_make (handler), handler.label),
			handler.separator,
			id,
			});
	else
		text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,	-- no embargo date or embargo has expired, ok to link to article
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access,
			auto_link = not err_flag and 'pmc' or nil							-- do not auto-link when PMC has error
			});
	end

	if err_flag then
		options.coins_list_t['PMC'] = nil;										-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid (options)
	local id = options.id;
	local handler = options.handler;

	if id:match(&quot;[^%d]&quot;) then													-- if PMID has anything but digits
		set_message ('err_bad_pmid');											-- set an error message
		options.coins_list_t['PMID'] = nil;										-- when error, unset so not included in COinS
	else																		-- PMID is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if PMID is outside test limit boundaries
			set_message ('err_bad_pmid');										-- set an error message
			options.coins_list_t['PMID'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; R F C &gt;------------------------------------------------------------------------

Format RFC and do simple error checking. RFCs are sequential numbers beginning at 1 and counting up.  This
code checks the RFC to see that it contains only digits and is less than test_limit specified in the configuration;
the value in test_limit will need to be updated periodically as more RFCs are issued.

An index of all RFCs is here: https://tools.ietf.org/rfc/

]]

local function rfc (options)
	local id = options.id;
	local handler = options.handler;

	if id:match(&quot;[^%d]&quot;) then													-- if RFC has anything but digits
		set_message ('err_bad_rfc');											-- set an error message
		options.coins_list_t['RFC'] = nil;										-- when error, unset so not included in COinS
	else																		-- RFC is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if RFC is outside test limit boundaries
			set_message ('err_bad_rfc');										-- set an error message
			options.coins_list_t['RFC'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access});
end


--[[--------------------------&lt; S 2 C I D &gt;--------------------------------------------------------------------

Format an S2CID, do simple error checking

S2CIDs are sequential numbers beginning at 1 and counting up.  This code checks the S2CID to see that it is only
digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically
as more S2CIDs are issued.

]]

local function s2cid (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local id_num;
	local text;
	
	id_num = id:match ('^[1-9]%d*$');											-- id must be all digits; must not begin with 0; no open access flag

 	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if handler.id_limit &lt; id_num then										-- if S2CID is outside test limit boundaries
			set_message ('err_bad_s2cid');										-- set an error message
			options.coins_list_t['S2CID'] = nil;								-- when error, unset so not included in COinS
		end
	else																		-- when id format incorrect
		set_message ('err_bad_s2cid');											-- set an error message
		options.coins_list_t['S2CID'] = nil;									-- when error, unset so not included in COinS
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});

	return text;
end


--[[--------------------------&lt; S B N &gt;------------------------------------------------------------------------

9-digit form of ISBN-10; uses same check-digit validation when SBN is prefixed with an additional '0' to make 10 digits

sbn value not made part of COinS metadata because we don't have a url or isn't a COinS-defined identifier (rft.xxx)
or an identifier registered at info-uri.info (info:)

]]

local function sbn (options)
	local id = options.id;
	local ignore_invalid = options.accept;
	local handler = options.handler;
	local function return_result (check, err_type)								-- local function to handle the various returns
		local SBN = internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,
						prefix = handler.prefix, id = id, separator = handler.separator});
		if not ignore_invalid then												-- if not ignoring SBN errors
			if not check then
				options.coins_list_t['SBN'] = nil;								-- when error, unset so not included in COinS; not really necessary here because sbn not made part of COinS
				set_message ('err_bad_sbn', {err_type});						-- display an error message
				return SBN; 
			end
		else
			set_message ('maint_isbn_ignore');									-- add a maint category even when there is no error (ToDo: Possibly switch to separate message for SBNs only)
		end
		return SBN;
	end

	if id:match ('[^%s-0-9X]') then
		return return_result (false, cfg.err_msg_supl.char);					-- fail if SBN contains anything but digits, hyphens, or the uppercase X
	end

	local ident = id:gsub ('[%s-]', '');										-- remove hyphens and whitespace; they interfere with the rest of the tests

	if  9 ~= ident:len() then
		return return_result (false, cfg.err_msg_supl.length);					-- fail if incorrect length
	end

	if ident:match ('^%d*X?$') == nil then
		return return_result (false, cfg.err_msg_supl.form);					-- fail if SBN has 'X' anywhere but last position
	end

	return return_result (is_valid_isxn ('0' .. ident, 10), cfg.err_msg_supl.check);
end


--[[--------------------------&lt; S S R N &gt;----------------------------------------------------------------------

Format an SSRN, do simple error checking

SSRNs are sequential numbers beginning at 100? and counting up.  This code checks the SSRN to see that it is
only digits and is greater than 99 and less than test_limit; the value in local variable test_limit will need
to be updated periodically as more SSRNs are issued.

]]

local function ssrn (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;
	local text;
	
	id_num = id:match ('^%d+$');												-- id must be all digits

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if 100 &gt; id_num or handler.id_limit &lt; id_num then						-- if SSRN is outside test limit boundaries
			set_message ('err_bad_ssrn');										-- set an error message
			options.coins_list_t['SSRN'] = nil;									-- when error, unset so not included in COinS
		end
	else																		-- when id format incorrect
		set_message ('err_bad_ssrn');											-- set an error message
		options.coins_list_t['SSRN'] = nil;										-- when error, unset so not included in COinS
	end
	
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = options.access});

	return text;
end


--[[--------------------------&lt; U S E N E T _ I D &gt;------------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function usenet_id (options)
	local id = options.id;
	local handler = options.handler;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$') then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		set_message ('err_bad_usenet_id')										-- add an error message if the message id is invalid
		options.coins_list_t['USENETID'] = nil;									-- when error, unset so not included in COinS
	end 
	
	return text;
end


--[[--------------------------&lt; Z B L &gt;-----------------------------------------------------------------------

A numerical identifier in the form nnnn.nnnnn - leading zeros in the first quartet optional

format described here: http://emis.mi.sanu.ac.rs/ZMATH/zmath/en/help/search/

temporary format is apparently eight digits.  Anything else is an error

]]

local function zbl (options)
	local id = options.id;
	local handler = options.handler;

	if id:match('^%d%d%d%d%d%d%d%d$') then										-- is this identifier using temporary format?
		set_message ('maint_zbl');												-- yes, add maint cat
	elseif not id:match('^%d?%d?%d?%d%.%d%d%d%d%d$') then						-- not temporary, is it normal format?
		set_message ('err_bad_zbl');											-- no, set an error message
		options.coins_list_t['ZBL'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--============================&lt;&lt; I N T E R F A C E   F U N C T I O N S &gt;&gt;==========================================

--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message if more than one alias exists in args

]]

local function extract_ids (args)
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs (cfg.id_handlers) do										-- k is uppercase identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one (args, v.parameters, 'err_redundant_parameters' );		-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set (v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; E X T R A C T _ I D _ A C C E S S _ L E V E L S &gt;--------------------------------------

Fetches custom id access levels from arguments using configuration settings. Parameters which have a predefined access
level (e.g. arxiv) do not use this function as they are directly rendered as free without using an additional parameter.

returns a table of k/v pairs where k is same as the identifier's key in cfg.id_handlers and v is the assigned (valid) keyword

access-level values must match the case used in cfg.keywords_lists['id-access'] (lowercase unless there is some special reason for something else)

]]

local function extract_id_access_levels (args, id_list)
	local id_accesses_list = {};
	for k, v in pairs (cfg.id_handlers) do
		local access_param = v.custom_access;									-- name of identifier's access-level parameter
		if is_set (access_param) then
			local access_level = args[access_param];							-- get the assigned value if there is one
			if is_set (access_level) then
				if not in_array (access_level, cfg.keywords_lists['id-access']) then	-- exact match required
					set_message ('err_invalid_param_val', {access_param, access_level});	
					access_level = nil;											-- invalid so unset
				end
				if not is_set (id_list[k]) then									-- identifier access-level must have a matching identifier
					set_message ('err_param_access_requires_param', {k:lower()});	-- parameter name is uppercase in cfg.id_handlers (k); lowercase for error message
				end
				id_accesses_list[k] = cfg.keywords_xlate[access_level];			-- get translated keyword
			end
		end
	end
	return id_accesses_list;
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;----------------------------------------------------

render the identifiers into a sorted sequence table

&lt;ID_list_coins_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value
&lt;options_t&gt; is a table of various k/v option pairs provided in the call to new_build_id_list();
	modified by	this function and passed to all identifier rendering functions
&lt;access_levels_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value (if valid)

returns a sequence table of sorted (by hkey - 'handler' key) rendered identifier strings

]]

local function build_id_list (ID_list_coins_t, options_t, access_levels_t)
	local ID_list_t = {};
	local accept;
	local func_map = {															--function map points to functions associated with hkey identifier
		['ARXIV'] = arxiv,
		['ASIN'] = asin,
		['BIBCODE'] = bibcode,
		['BIORXIV'] = biorxiv,
		['CITESEERX'] = citeseerx,
		['DOI'] = doi,
		['EISSN'] = issn,
		['HDL'] = hdl,
		['ISBN'] = isbn,
		['ISMN'] = ismn,
		['ISSN'] = issn,
		['JFM'] = jfm,
		['JSTOR'] = jstor,
		['LCCN'] = lccn,
		['MEDRXIV'] = medrxiv,
		['MR'] = mr,
		['OCLC'] = oclc,
		['OL'] = openlibrary,
		['OSTI'] = osti,
		['PMC'] = pmc,
		['PMID'] = pmid,
		['RFC']  = rfc,
		['S2CID'] = s2cid,
		['SBN'] = sbn,
		['SSRN'] = ssrn,
		['USENETID'] = usenet_id,
		['ZBL'] = zbl,
		}

	for hkey, v in pairs (ID_list_coins_t) do
		v, accept = has_accept_as_written (v);									-- remove accept-as-written markup if present; accept is boolean true when markup removed; false else
																				-- every function gets the options table with value v and accept boolean
		options_t.hkey = hkey;													-- ~/Configuration handler key
		options_t.id = v;														-- add that identifier value to the options table
		options_t.accept = accept;												-- add the accept boolean flag
		options_t.access = access_levels_t[hkey];								-- add the access level for those that have an |&lt;identifier-access= parameter
		options_t.handler = cfg.id_handlers[hkey];
		options_t.coins_list_t = ID_list_coins_t;								-- pointer to ID_list_coins_t; for |asin= and |ol=; also to keep erroneous values out of the citation's metadata
		options_t.coins_list_t[hkey] = v;										-- id value without accept-as-written markup for metadata
		
		if options_t.handler.access and not in_array (options_t.handler.access, cfg.keywords_lists['id-access']) then
			error (cfg.messages['unknown_ID_access'] .. options_t.handler.access);	-- here when handler access key set to a value not listed in list of allowed id access keywords
		end

		if func_map[hkey] then
			local id_text = func_map[hkey] (options_t);							-- call the function to get identifier text and any error message
			table.insert (ID_list_t, {hkey, id_text});							-- add identifier text to the output sequence table
		else
			error (cfg.messages['unknown_ID_key'] .. hkey);						-- here when func_map doesn't have a function for hkey
		end
	end

	local function comp (a, b)													-- used by following table.sort()
		return a[1]:lower() &lt; b[1]:lower();										-- sort by hkey
	end

	table.sort (ID_list_t, comp);												-- sequence table of tables sort	
	for k, v in ipairs (ID_list_t) do											-- convert sequence table of tables to simple sequence table of strings
		ID_list_t[k] = v[2];													-- v[2] is the identifier rendering from the call to the various functions in func_map{}
	end
	
	return ID_list_t;
end


--[[--------------------------&lt; O P T I O N S _ C H E C K &gt;----------------------------------------------------

check that certain option parameters have their associated identifier parameters with values

&lt;ID_list_coins_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value
&lt;ID_support_t&gt; is a sequence table of tables created in citation0() where each subtable has four elements:
	[1] is the support parameter's assigned value; empty string if not set
	[2] is a text string same as key in cfg.id_handlers
	[3] is cfg.error_conditions key used to create error message
	[4] is original ID support parameter name used to create error message
	
returns nothing; on error emits an appropriate error message

]]

local function options_check (ID_list_coins_t, ID_support_t)
	for _, v in ipairs (ID_support_t) do
		if is_set (v[1]) and not ID_list_coins_t[v[2]] then						-- when support parameter has a value but matching identifier parameter is missing or empty
			set_message (v[3], (v[4]));											-- emit the appropriate error message
		end
	end
end


--[[--------------------------&lt; I D E N T I F I E R _ L I S T S _ G E T &gt;--------------------------------------

Creates two identifier lists: a k/v table of identifiers and their values to be used locally and for use in the
COinS metadata, and a sequence table of the rendered identifier strings that will be included in the rendered
citation.

]]

local function identifier_lists_get (args_t, options_t, ID_support_t)
	local ID_list_coins_t = extract_ids (args_t);										-- get a table of identifiers and their values for use locally and for use in COinS
	options_check (ID_list_coins_t, ID_support_t);										-- ID support parameters must have matching identifier parameters 
	local ID_access_levels_t = extract_id_access_levels (args_t, ID_list_coins_t);		-- get a table of identifier access levels
	local ID_list_t = build_id_list (ID_list_coins_t, options_t, ID_access_levels_t);	-- get a sequence table of rendered identifier strings

	return ID_list_t, ID_list_coins_t;											-- return the tables
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	has_accept_as_written = utilities_page_ptr.has_accept_as_written;			-- import functions from select Module:Citation/CS1/Utilities module
	is_set = utilities_page_ptr.is_set;								
	in_array = utilities_page_ptr.in_array;
	set_message = utilities_page_ptr.set_message;
	select_one = utilities_page_ptr.select_one;
	substitute = utilities_page_ptr.substitute;
	make_wikilink = utilities_page_ptr.make_wikilink;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	auto_link_urls = auto_link_urls,											-- table of identifier URLs to be used when auto-linking |title=
	
	identifier_lists_get = identifier_lists_get,								-- experiment to replace individual calls to build_id_list(), extract_ids, extract_id_access_levels
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>sh0l2n4ahyihscjfw9ol31xgrbnds2a</sha1>
    </revision>
    <revision>
      <id>4924</id>
      <parentid>4923</parentid>
      <timestamp>2023-09-20T15:12:36Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>tweak to support new oclc limit;</comment>
      <origin>4924</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="76636" sha1="73vdzq08sflt35x53xns1mv63pkq88c" xml:space="preserve">--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local has_accept_as_written, is_set, in_array, set_message, select_one,			-- functions in Module:Citation/CS1/Utilities
		substitute, make_wikilink;

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

declare variables here that have page-wide scope that are not brought in from other modules; that are created here and used here

]]

local auto_link_urls = {};														-- holds identifier URLs for those identifiers that can auto-link |title=


--============================&lt;&lt; H E L P E R   F U N C T I O N S &gt;&gt;============================================

--[[--------------------------&lt; W I K I D A T A _ A R T I C L E _ N A M E _ G E T &gt;----------------------------

as an aid to internationalizing identifier-label wikilinks, gets identifier article names from Wikidata.

returns :&lt;lang code&gt;:&lt;article title&gt; when &lt;q&gt; has an &lt;article title&gt; for &lt;lang code&gt;; nil else

for identifiers that do not have q, returns nil

for wikis that do not have mw.wikibase installed, returns nil

]]

local function wikidata_article_name_get (q)
	if not is_set (q) or (q and not mw.wikibase) then							-- when no q number or when a q number but mw.wikibase not installed on this wiki
		return nil;																-- abandon
	end

	local wd_article;
	local this_wiki_code = cfg.this_wiki_code;									-- Wikipedia subdomain; 'en' for en.wikipedia.org

	wd_article = mw.wikibase.getSitelink (q, this_wiki_code .. 'wiki');			-- fetch article title from WD; nil when no title available at this wiki

	if wd_article then
		wd_article = table.concat ({':', this_wiki_code, ':', wd_article});		-- interwiki-style link without brackets if taken from WD; leading colon required
	end

	return wd_article;															-- article title from WD; nil else
end


--[[--------------------------&lt; L I N K _ L A B E L _ M A K E &gt;------------------------------------------------

common function to create identifier link label from handler table or from Wikidata

returns the first available of
	1. redirect from local wiki's handler table (if enabled)
	2. Wikidata (if there is a Wikidata entry for this identifier in the local wiki's language)
	3. label specified in the local wiki's handler table
	
]]

local function link_label_make (handler)
	local wd_article;
	
	if not (cfg.use_identifier_redirects and is_set (handler.redirect)) then	-- redirect has priority so if enabled and available don't fetch from Wikidata because expensive
		wd_article = wikidata_article_name_get (handler.q);						-- if Wikidata has an article title for this wiki, get it;
	end
	
	return (cfg.use_identifier_redirects and is_set (handler.redirect) and handler.redirect) or wd_article or handler.link;
end


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki-style external link

]]

local function external_link_id (options)
	local url_string = options.id;
	local ext_link;
	local this_wiki_code = cfg.this_wiki_code;									-- Wikipedia subdomain; 'en' for en.wikipedia.org
	local wd_article;															-- article title from Wikidata
	
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode (url_string, 'PATH');
	end

	if options.auto_link and is_set (options.access) then
		auto_link_urls[options.auto_link] = table.concat ({options.prefix, url_string, options.suffix});
	end

	ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or &quot;&quot;, mw.text.nowiki (options.id));
	if is_set (options.access) then
		ext_link = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[options.access].class, cfg.presentation[options.access].title, ext_link});	-- add the free-to-read / paywall lock
	end

	return table.concat	({
		make_wikilink (link_label_make (options), options.label),				-- redirect, Wikidata link, or locally specified link (in that order)
		options.separator or '&amp;nbsp;',
		ext_link
		});
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki-style internal link

TODO: Does not currently need to support options.access, options.encode, auto-linking and COinS (as in external_link_id),
but may be needed in the future for :m:Interwiki_map custom-prefixes like :arxiv:, :bibcode:, :DOI:, :hdl:, :ISSN:,
:JSTOR:, :Openlibrary:, :PMID:, :RFC:.

]]

local function internal_link_id (options)
	local id = mw.ustring.gsub (options.id, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9

	return table.concat (
		{
		make_wikilink (link_label_make (options), options.label),				-- wiki-link the identifier label
		options.separator or '&amp;nbsp;',											-- add the separator
		make_wikilink (
			table.concat (
				{
				options.prefix,
				id,																-- translated to Western digits
				options.suffix or ''
				}),
			substitute (cfg.presentation['bdi'], {'', mw.text.nowiki (options.id)})	-- bdi tags to prevent Latin script identifiers from being reversed at RTL language wikis
			);																	-- nowiki because MediaWiki still has magic links for ISBN and the like; TODO: is it really required?
		});
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |pmc-embargo-date= against
today's date.  If embargo date is in the future, returns the content of |pmc-embargo-date=; otherwise, returns
an empty string because the embargo has expired or because |pmc-embargo-date= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, todays_date;
		good1, embargo_date = pcall (lang.formatDate, lang, 'U', embargo);
		todays_date = lang:formatDate ('U');
	
		if good1 then															-- if embargo date is a good date
			if tonumber (embargo_date) &gt;= tonumber (todays_date) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				set_message ('maint_pmc_embargo');								-- embargo has expired; add main cat
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |pmc-embargo-date= not set return empty string
end


--[=[-------------------------&lt; I S _ V A L I D _ R X I V _ D A T E &gt;------------------------------------------

for biorxiv, returns true if:
	2019-12-11T00:00Z &lt;= biorxiv_date &lt; today + 2 days
for medrxiv, returns true if:
	2020-01-01T00:00Z &lt;= medrxiv_date &lt; today + 2 days
	
The dated form of biorxiv identifier has a start date of 2019-12-11.  The Unix timestamp for that date is {{#time:U|2019-12-11}} = 1576022400
The medrxiv identifier has a start date of 2020-01-01.  The Unix timestamp for that date is {{#time:U|2020-01-01}} = 1577836800

&lt;rxiv_date&gt; is the date provided in those |biorxiv= parameter values that are dated and in |medrxiv= parameter values at time 00:00:00 UTC
&lt;today&gt; is the current date at time 00:00:00 UTC plus 48 hours
	if today's date is 2023-01-01T00:00:00 then
		adding 24 hours gives 2023-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2023-01-03T00:00:00 – one second more than tomorrow

inputs:
	&lt;y&gt;, &lt;m&gt;, &lt;d&gt; – year, month, day parts of the date from the birxiv or medrxiv identifier
	&lt;select&gt; 'b' for biorxiv, 'm' for medrxiv; defaults to 'b'

]=]

local function is_valid_rxiv_date (y, m, d, select)
	if 0 == tonumber (m) and 12 &lt; tonumber (m) then								-- &lt;m&gt; must be a number 1–12
		return false;
	end
	if 0 == tonumber (d) and 31 &lt; tonumber (d) then								-- &lt;d&gt; must be a number 1–31; TODO: account for month length and leap yer?
		return false;
	end
	
	local rxiv_date = table.concat ({y, m, d}, '-');							-- make ymd date string
	local good1, good2;
	local rxiv_ts, tomorrow_ts;													-- to hold Unix timestamps representing the dates
	local lang_object = mw.getContentLanguage();

	good1, rxiv_ts = pcall (lang_object.formatDate, lang_object, 'U', rxiv_date);		-- convert rxiv_date value to Unix timestamp 
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which tonumber() may not understand
		rxiv_ts = tonumber (rxiv_ts) or lang_object:parseFormattedNumber (rxiv_ts);	-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to Unix timestamp
	end

	local limit_ts = ((select and ('m' == select)) and 1577836800) or 1576022400;	-- choose the appropriate limit timesatmp

	return ((limit_ts &lt;= rxiv_ts) and (rxiv_ts &lt; tomorrow_ts))					-- limit_ts &lt;= rxiv_date &lt; tomorrow's date
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all ISBN/ISSN digits including the check digit.
ISBN-13 is checked in isbn().

If the number is valid the result will be 0. Before calling this function, ISBN/ISSN must be checked for length
and stripped of dashes, spaces and other non-ISxN characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39, 'X' → 0x58
	len = len + 1;																-- adjust to be a loop counter
	for i, v in ipairs (isxn_str) do											-- loop through all of the bytes and calculate the checksum
		if v == string.byte (&quot;X&quot; ) then											-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10 * (len - i);										-- it represents 10 decimal
		else
			temp = temp + tonumber (string.char (v) )*(len-i);
		end
	end
	return temp % 11 == 0;														-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N _ 1 3 &gt;-----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 ISBN/ISMN digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, ISBN-13/ISMN must be checked for length
and stripped of dashes, spaces and other non-ISxN-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39
	for i, v in ipairs (isxn_str) do
		temp = temp + (3 - 2*(i % 2)) * tonumber (string.char (v) );			-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when ISBN-13/ISMN is correct
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

LCCN normalization (https://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized LCCN for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.

]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);												-- 1. strip whitespace

	if nil ~= string.find (lccn, '/') then
		lccn = lccn:match (&quot;(.-)/&quot;);											-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);									-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then														-- if there was a hyphen
		suffix = string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;				-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn = prefix..suffix;													-- reassemble the LCCN
	end
	
	return lccn;
	end


--============================&lt;&lt; I D E N T I F I E R   F U N C T I O N S &gt;&gt;====================================

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: https://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9107 and 0703, is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation; not the same as |class= parameter which is not supported in this form
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number

]]

local function arxiv (options)
	local id = options.id;
	local class = options.Class;												-- TODO: lowercase?
	local handler = options.handler;
	local year, month, version;
	local err_msg = false;														-- assume no error message
	local text;																	-- output text
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9107-0703 format with or without version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_msg = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 with or without version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then									-- when year is 07, is month invalid (before April)?
				err_msg = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format with or without version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_msg = true;														-- flag for error message
		end

	else
		err_msg = true;															-- not a recognized format; flag for error message
	end

	if err_msg then
		options.coins_list_t['ARXIV'] = nil;									-- when error, unset so not included in COinS
	end
	
	local err_msg_t = {};
	if err_msg then
		set_message ('err_bad_arxiv');
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access});

	if is_set (class) then
		if id:match ('^%d+') then
			text = table.concat ({text, ' [[https://arxiv.org/archive/', class, ' ', class, ']]'});	-- external link within square brackets, not wikilink
		else
			set_message ('err_class_ignored');
		end
	end

	return text;
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode ID.

Format for bibcodes is specified here: https://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		9–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local ignore_invalid = options.accept;
	local err_type;
	local err_msg = '';
	local year;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode,
		access = access});
	
	if 19 ~= id:len() then
		err_type = cfg.err_msg_supl.length;
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%w&amp;%.][%w&amp;%.][%w&amp;%.][%w.]+[%a%.]$&quot;);
		if not year then														-- if nil then no pattern match
			err_type = cfg.err_msg_supl.value;									-- so value error
		else
			local next_year = tonumber (os.date ('%Y')) + 1;					-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = cfg.err_msg_supl.year;								-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = cfg.err_msg_supl.journal;							-- journal abbreviation must not have '&amp;.' (if it does it's missing a letter)
			end
			if id:match ('.........%.tmp%.') then								-- temporary bibcodes when positions 10–14 are '.tmp.'
				set_message ('maint_bibcode');
			end
		end
	end

	if is_set (err_type) and not ignore_invalid then							-- if there was an error detected and accept-as-written markup not used
		set_message ('err_bad_bibcode', {err_type});
		options.coins_list_t['BIBCODE'] = nil;									-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; B I O R X I V &gt;-----------------------------------------------------------------

Format bioRxiv ID and do simple error checking.  Before 2019-12-11, biorXiv IDs were 10.1101/ followed by exactly
6 digits.  After 2019-12-11, biorXiv IDs retained the six-digit identifier but prefixed that with a yyyy.mm.dd. 
date and suffixed with an optional version identifier.

The bioRxiv ID is the string of characters:
	https://doi.org/10.1101/078733 -&gt; 10.1101/078733
or a date followed by a six-digit number followed by an optional version indicator 'v' and one or more digits:
	https://www.biorxiv.org/content/10.1101/2019.12.11.123456v2 -&gt; 10.1101/2019.12.11.123456v2
	
see https://www.biorxiv.org/about-biorxiv

]]

local function biorxiv (options)
	local id = options.id;
	local handler = options.handler;
	local err_msg = true;														-- flag; assume that there will be an error
	
	local patterns = {
		'^10%.1101/%d%d%d%d%d%d$',												-- simple 6-digit identifier (before 2019-12-11)
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%dv%d+$',				-- y.m.d. date + 6-digit identifier + version (after 2019-12-11)
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%d$',					-- y.m.d. date + 6-digit identifier (after 2019-12-11)
		}
	
	for _, pattern in ipairs (patterns) do										-- spin through the patterns looking for a match
		if id:match (pattern) then
			local y, m, d = id:match (pattern);									-- found a match, attempt to get year, month and date from the identifier

			if m then															-- m is nil when id is the six-digit form
				if not is_valid_rxiv_date (y, m, d, 'b') then					-- validate the encoded date; 'b' for biorxiv limit
					break;														-- date fail; break out early so we don't unset the error message
				end
			end
			err_msg = nil;														-- we found a match so unset the error message
			break;																-- and done
		end
	end																			-- err_cat remains set here when no match

	if err_msg then
		options.coins_list_t['BIORXIV'] = nil;									-- when error, unset so not included in COinS
		set_message ('err_bad_biorxiv');										-- and set the error message
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator,
			encode = handler.encode, access = handler.access});
end


--[[--------------------------&lt; C I T E S E E R X &gt;------------------------------------------------------------

CiteSeerX use their own notion of &quot;doi&quot; (not to be confused with the identifiers resolved via doi.org).

The description of the structure of this identifier can be found at Help_talk:Citation_Style_1/Archive_26#CiteSeerX_id_structure

]]

local function citeseerx (options)
	local id = options.id;
	local handler = options.handler;
	local matched;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode,
		access = handler.access});
	
	matched = id:match (&quot;^10%.1%.1%.[1-9]%d?%d?%d?%.[1-9]%d?%d?%d?$&quot;);
	if not matched then
		set_message ('err_bad_citeseerx' );
		options.coins_list_t['CITESEERX'] = nil;								-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the DOI name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in DOI names.

https://www.doi.org/doi_handbook/2_Numbering.html				-- 2.2 Syntax of a DOI name
https://www.doi.org/doi_handbook/2_Numbering.html#2.2.2			-- 2.2.2 DOI prefix

]]

local function doi (options)
	local id = options.id;
	local inactive = options.DoiBroken
	local access = options.access;
	local ignore_invalid = options.accept;
	local handler = options.handler;
	local err_flag;

	local text;
	if is_set (inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;);						-- try to get the year portion from the inactive date
		local inactive_month, good;

		if is_set (inactive_year) then
			if 4 &lt; inactive:len() then											-- inactive date has more than just a year (could be anything)
				local lang_obj = mw.getContentLanguage();						-- get a language object for this wiki
				good, inactive_month = pcall (lang_obj.formatDate, lang_obj, 'F', inactive);	-- try to get the month name from the inactive date
				if not good then
					inactive_month = nil;										-- something went wrong so make sure this is unset
				end
			end
		end																		-- otherwise, |doi-broken-date= has something but it isn't a date
		
		if is_set (inactive_year) and is_set (inactive_month) then
			set_message ('maint_doi_inactive_dated', {inactive_year, inactive_month, ' '});
		elseif is_set (inactive_year) then
			set_message ('maint_doi_inactive_dated', {inactive_year, '', ''});
		else
			set_message ('maint_doi_inactive');
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. ' ' .. inactive .. ')';
	end

	local registrant = mw.ustring.match (id, '^10%.([^/]+)/[^%s–]-[^%.,]$');	-- registrant set when DOI has the proper basic form

	local registrant_err_patterns = {											-- these patterns are for code ranges that are not supported 
		'^[^1-3]%d%d%d%d%.%d+$',												-- 5 digits with subcode (0xxxx, 40000+); accepts: 10000–39999
		'^[^1-6]%d%d%d%d$',														-- 5 digits without subcode (0xxxx, 60000+); accepts: 10000–69999
		'^[^1-9]%d%d%d%.%d+$',												-- 4 digits with subcode (0xxx); accepts: 1000–9999
		'^[^1-9]%d%d%d$',														-- 4 digits without subcode (0xxx); accepts: 1000–9999
		'^%d%d%d%d%d%d+',														-- 6 or more digits
		'^%d%d?%d?$',															-- less than 4 digits without subcode (3 digits with subcode is legitimate)
		'^%d%d?%.[%d%.]+',														-- 1 or 2 digits with subcode
		'^5555$',																-- test registrant will never resolve
		'[^%d%.]',																-- any character that isn't a digit or a dot
		}

	if not ignore_invalid then
		if registrant then														-- when DOI has proper form
			for i, pattern in ipairs (registrant_err_patterns) do				-- spin through error patterns
				if registrant:match (pattern) then								-- to validate registrant codes
					err_flag = set_message ('err_bad_doi');						-- when found, mark this DOI as bad
					break;														-- and done
				end
			end
		else
			err_flag = set_message ('err_bad_doi');								-- invalid directory or malformed
		end
	else
		set_message ('maint_doi_ignore');
	end

	if err_flag then
		options.coins_list_t['DOI'] = nil;										-- when error, unset so not included in COinS
	end
	
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access,
		auto_link = not (err_flag or is_set (inactive) or ignore_invalid) and 'doi' or nil -- do not auto-link when |doi-broken-date= has a value or when there is a DOI error or (to play it safe, after all, auto-linking is not essential) when invalid DOIs are ignored
		}) .. (inactive or '');

	return text;
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

Query string parameters are named here: https://www.handle.net/proxy_servlet.html.  query strings are not displayed
but since '?' is an allowed character in an HDL, '?' followed by one of the query parameters is the only way we
have to detect the query string so that it isn't URL-encoded with the rest of the identifier.

]]

local function hdl (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local query_params = {														-- list of known query parameters from https://www.handle.net/proxy_servlet.html
		'noredirect',
		'ignore_aliases',
		'auth',
		'cert',
		'index',
		'type',
		'urlappend',
		'locatt',
		'action',
		}
	
	local hdl, suffix, param = id:match ('(.-)(%?(%a+).+)$');					-- look for query string
	local found;

	if hdl then																	-- when there are query strings, this is the handle identifier portion
		for _, q in ipairs (query_params) do									-- spin through the list of query parameters
			if param:match ('^' .. q) then										-- if the query string begins with one of the parameters
				found = true;													-- announce a find
				break;															-- and stop looking
			end
		end
	end

	if found then
		id = hdl;																-- found so replace id with the handle portion; this will be URL-encoded, suffix will not
	else
		suffix = '';															-- make sure suffix is empty string for concatenation else
	end

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, suffix = suffix, separator = handler.separator, encode = handler.encode, access = access})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- HDL must contain a forward slash, must not contain spaces, endashes, and must not end with period or comma
		set_message ('err_bad_hdl' );
		options.coins_list_t['HDL'] = nil;										-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; I S B N &gt;----------------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function isbn (options)
	local isbn_str = options.id;
	local ignore_invalid = options.accept;
	local handler = options.handler;

	local function return_result (check, err_type)								-- local function to handle the various returns
		local ISBN = internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,
						prefix = handler.prefix, id = isbn_str, separator = handler.separator});
		if ignore_invalid then													-- if ignoring ISBN errors
			set_message ('maint_isbn_ignore');									-- add a maint category even when there is no error
		else																	-- here when not ignoring
			if not check then													-- and there is an error
				options.coins_list_t['ISBN'] = nil;								-- when error, unset so not included in COinS
				set_message ('err_bad_isbn', err_type);							-- set an error message
				return ISBN;										 			-- return id text
			end
		end
		return ISBN;															-- return id text
	end

	if nil ~= isbn_str:match ('[^%s-0-9X]') then
		return return_result (false, cfg.err_msg_supl.char);					-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end

	local id = isbn_str:gsub ('[%s-]', '');										-- remove hyphens and whitespace

	local len = id:len();
 
	if len ~= 10 and len ~= 13 then
		return return_result (false, cfg.err_msg_supl.length);					-- fail if incorrect length
	end

	if len == 10 then
		if id:match ('^%d*X?$') == nil then										-- fail if isbn_str has 'X' anywhere but last position
			return return_result (false, cfg.err_msg_supl.form);									
		end
		if not is_valid_isxn (id, 10) then										-- test isbn-10 for numerical validity
			return return_result (false, cfg.err_msg_supl.check);				-- fail if isbn-10 is not numerically valid
		end
		if id:find ('^63[01]') then												-- 630xxxxxxx and 631xxxxxxx are (apparently) not valid isbn group ids but are used by amazon as numeric identifiers (asin)
			return return_result (false, cfg.err_msg_supl.group);				-- fail if isbn-10 begins with 630/1
		end
		return return_result (true, cfg.err_msg_supl.check);					-- pass if isbn-10 is numerically valid
	else
		if id:match ('^%d+$') == nil then
			return return_result (false, cfg.err_msg_supl.char);				-- fail if ISBN-13 is not all digits
		end
		if id:match ('^97[89]%d*$') == nil then
			return return_result (false, cfg.err_msg_supl.prefix);				-- fail when ISBN-13 does not begin with 978 or 979
		end
		if id:match ('^9790') then
			return return_result (false, cfg.err_msg_supl.group);				-- group identifier '0' is reserved to ISMN
		end
		return return_result (is_valid_isxn_13 (id), cfg.err_msg_supl.check);
	end
end


--[[--------------------------&lt; A S I N &gt;----------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: ASIN must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, ASINs must be 10-digit
ISBN. If 10-digit ISBN, add a maintenance category so a bot or AWB script can replace |asin= with |isbn=.
Error message if not 10 characters, if not ISBN-10, if mixed and first character is a digit.

|asin=630....... and |asin=631....... are (apparently) not a legitimate ISBN though it checksums as one; these
do not cause this function to emit the maint_asin message

This function is positioned here because it calls isbn()

]]

local function asin (options)
	local id = options.id;
	local domain = options.ASINTLD;
	
	local err_flag;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_flag = set_message ('err_bad_asin');								-- ASIN is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then							-- if 10-digit numeric (or 9 digits with terminal X)
			if is_valid_isxn (id, 10) then										-- see if ASIN value is or validates as ISBN-10
				if not id:find ('^63[01]') then									-- 630xxxxxxx and 631xxxxxxx are (apparently) not a valid isbn prefixes but are used by amazon as a numeric identifier
					err_flag = set_message ('err_bad_asin');					-- ASIN has ISBN-10 form but begins with something other than 630/1 so probably an isbn 
				end
			elseif not is_set (err_flag) then
				err_flag = set_message ('err_bad_asin');						-- ASIN is not ISBN-10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_flag = set_message ('err_bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if (not is_set (domain)) or in_array (domain, {'us'}) then					-- default: United States
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then									-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'z.cn'}) then 									-- China
		domain = &quot;cn&quot;;
	elseif in_array (domain, {'au', 'br', 'mx', 'sg', 'tr'}) then				-- Australia, Brazil, Mexico, Singapore, Turkey
		domain = &quot;com.&quot; .. domain;
	elseif not in_array (domain, {'ae', 'ca', 'cn', 'de', 'es', 'fr', 'in', 'it', 'nl', 'pl', 'sa', 'se', 'co.jp', 'co.uk', 'com', 'com.au', 'com.br', 'com.mx', 'com.sg', 'com.tr'}) then -- Arabic Emirates, Canada, China, Germany, Spain, France, Indonesia, Italy, Netherlands, Poland, Saudi Arabia, Sweden (as of 2021-03 Austria (.at), Liechtenstein (.li) and Switzerland (.ch) still redirect to the German site (.de) with special settings, so don't maintain local ASINs for them)
		err_flag = set_message ('err_bad_asin_tld');							-- unsupported asin-tld value
	end
	local handler = options.handler;

	if not is_set (err_flag) then
		options.coins_list_t['ASIN'] = handler.prefix .. domain .. &quot;/dp/&quot; .. id;	-- asin for coins
	else
		options.coins_list_t['ASIN'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix .. domain .. &quot;/dp/&quot;,
		id = id, encode = handler.encode, separator = handler.separator})
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to ISBN-13, ISMN is 13 digits beginning 979-0-... and uses the
same check digit calculations.  See https://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

ismn value not made part of COinS metadata because we don't have a url or isn't a COinS-defined identifier (rft.xxx)
or an identifier registered at info-uri.info (info:)

]]

local function ismn (options)
	local id = options.id;
	local handler = options.handler;
	local text;
	local valid_ismn = true;
	local id_copy;

	id_copy = id;																-- save a copy because this testing is destructive
	id = id:gsub ('[%s-]', '');													-- remove hyphens and white space

	if 13 ~= id:len() or id:match (&quot;^9790%d*$&quot; ) == nil then					-- ISMN must be 13 digits and begin with 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ISMN
	end

	--	text = internal_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,		-- use this (or external version) when there is some place to link to
	--		prefix = handler.prefix, id = id_copy, separator = handler.separator, encode = handler.encode})

	text = table.concat (														-- because no place to link to yet
		{
		make_wikilink (link_label_make (handler), handler.label),
		handler.separator,
		id_copy
		});

	if false == valid_ismn then
		options.coins_list_t['ISMN'] = nil;										-- when error, unset so not included in COinS; not really necessary here because ismn not made part of COinS
		set_message ('err_bad_ismn');											-- create an error message if the ISMN is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an ISSN.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [https://www.worldcat.org/issn/0819 4327 0819 4327]	-- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the ISSN midpoint.  It also validates the ISSN for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check ISSN error message.  The
ISSN is always displayed with a hyphen, even if the ISSN was given as a single group of 8 digits.

]]

local function issn (options)
	local id = options.id;
	local handler = options.handler;
	local ignore_invalid = options.accept;

	local issn_copy = id;														-- save a copy of unadulterated ISSN; use this version for display if ISSN does not validate
	local text;
	local valid_issn = true;

	id = id:gsub ('[%s-]', '');													-- remove hyphens and whitespace

	if 8 ~= id:len() or nil == id:match (&quot;^%d*X?$&quot; ) then						-- validate the ISSN: 8 digits long, containing only 0-9 or X in the last position
		valid_issn = false;														-- wrong length or improper character
	else
		valid_issn = is_valid_isxn (id, 8);										-- validate ISSN
	end

	if true == valid_issn then
		id = string.sub (id, 1, 4 ) .. &quot;-&quot; .. string.sub (id, 5 );				-- if valid, display correctly formatted version
	else
		id = issn_copy;															-- if not valid, show the invalid ISSN with error message
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode})

	if ignore_invalid then
		set_message ('maint_issn_ignore');
	else
		if false == valid_issn then
			options.coins_list_t['ISSN'] = nil;									-- when error, unset so not included in COinS
			set_message ('err_bad_issn', (options.hkey == 'EISSN') and 'e' or '');	-- create an error message if the ISSN is invalid
		end 
	end
	
	return text;
end


--[[--------------------------&lt; J F M &gt;-----------------------------------------------------------------------

A numerical identifier in the form nn.nnnn.nn

]]

local function jfm (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;

	id_num = id:match ('^[Jj][Ff][Mm](.*)$');									-- identifier with jfm prefix; extract identifier

	if is_set (id_num) then
		set_message ('maint_jfm_format');
	else																		-- plain number without JFM prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num and id_num:match('^%d%d%.%d%d%d%d%.%d%d$') then
		id = id_num;															-- jfm matches pattern
	else
		set_message ('err_bad_jfm' );											-- set an error message
		options.coins_list_t['JFM'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; J S T O R &gt;--------------------------------------------------------------------

Format a JSTOR with some error checking

]]

local function jstor (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;

	if id:find ('[Jj][Ss][Tt][Oo][Rr]') or id:find ('^https?://') or id:find ('%s') then
		set_message ('err_bad_jstor');											-- set an error message
		options.coins_list_t['JSTOR'] = nil;									-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});
end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
https://oclc-research.github.io/infoURI-Frozen/info-uri.info/info:lccn/reg.html

length = 8 then all digits
length = 9 then lccn[1] is lowercase alpha
length = 10 then lccn[1] and lccn[2] are both lowercase alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lowercase alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lowercase alpha

]]

local function lccn (options)
	local lccn = options.id;
	local handler = options.handler;
	local err_flag;																-- presume that LCCN is valid
	local id = lccn;															-- local copy of the LCCN

	id = normalize_lccn (id);													-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();														-- get the length of the LCCN

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits)
			err_flag = set_message ('err_bad_lccn');							-- set an error message
		end
	elseif 9 == len then														-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then							-- does it match our pattern?
			err_flag = set_message ('err_bad_lccn');							-- set an error message
		end
	elseif 10 == len then														-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then					-- ... see if it matches our pattern
				err_flag = set_message ('err_bad_lccn');						-- no match, set an error message
			end
		end
	elseif 11 == len then														-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_flag = set_message ('err_bad_lccn');							-- no match, set an error message
		end
	elseif 12 == len then														-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then						-- see if it matches our pattern
			err_flag = set_message ('err_bad_lccn');							-- no match, set an error message
		end
	else
		err_flag = set_message ('err_bad_lccn');								-- wrong length, set an error message
	end

	if not is_set (err_flag) and nil ~= lccn:find ('%s') then
		err_flag = set_message ('err_bad_lccn');								-- lccn contains a space, set an error message
	end

	if is_set (err_flag) then
		options.coins_list_t['LCCN'] = nil;										-- when error, unset so not included in COinS
	end

	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = lccn, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; M E D R X I V &gt;-----------------------------------------------------------------

Format medRxiv ID and do simple error checking.  Similar to later bioRxiv IDs, medRxiv IDs are prefixed with a
yyyy.mm.dd. date and suffixed with an optional version identifier.  Ealiest date accepted is 2020.01.01

The medRxiv ID is a date followed by an eight-digit number followed by an optional version indicator 'v' and one or more digits:
	https://www.medrxiv.org/content/10.1101/2020.11.16.20232009v2 -&gt; 10.1101/2020.11.16.20232009v2

]]

local function medrxiv (options)
	local id = options.id;
	local handler = options.handler;
	local err_msg_flag = true;													-- flag; assume that there will be an error

	local patterns = {
		'%d%d%d%d%d%d%d%d$',													-- simple 8-digit identifier; these should be relatively rare
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%d%d%dv%d+$',			-- y.m.d. date + 8-digit identifier + version (2020-01-01 and later)
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%d%d%d$',				-- y.m.d. date + 8-digit identifier (2020-01-01 and later)
		}
	
	for _, pattern in ipairs (patterns) do										-- spin through the patterns looking for a match
		if id:match (pattern) then
			local y, m, d = id:match (pattern);									-- found a match, attempt to get year, month and date from the identifier

			if m then															-- m is nil when id is the 8-digit form
				if not is_valid_rxiv_date (y, m, d, 'b') then					-- validate the encoded date; 'b' for medrxiv limit
					break;														-- date fail; break out early so we don't unset the error message
				end
			end
			err_msg_flag = nil;													-- we found a match so unset the error message
			break;																-- and done
		end
	end																			-- &lt;err_msg_flag&gt; remains set here when no match

	if err_msg_flag then
		options.coins_list_t['MEDRXIV'] = nil;									-- when error, unset so not included in COinS
		set_message ('err_bad_medrxiv');										-- and set the error message
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator,
			encode = handler.encode, access = handler.access});
end


--[[--------------------------&lt; M R &gt;--------------------------------------------------------------------------

A seven digit number; if not seven digits, zero-fill leading digits to make seven digits.

]]

local function mr (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;
	local id_len;

	id_num = id:match ('^[Mm][Rr](%d+)$');										-- identifier with mr prefix

	if is_set (id_num) then
		set_message ('maint_mr_format');										-- add maint cat
	else																		-- plain number without mr prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	id_len = id_num and id_num:len() or 0;
	if (7 &gt;= id_len) and (0 ~= id_len) then
		id = string.rep ('0', 7-id_len) .. id_num;								-- zero-fill leading digits
	else
		set_message ('err_bad_mr');												-- set an error message
		options.coins_list_t['MR'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an OCLC ID.  https://www.oclc.org/batchload/controlnumber.en.html {{dead link}}
archived at: https://web.archive.org/web/20161228233804/https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (options)
	local id = options.id;
	local handler = options.handler;
	local number;

	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- constrain to 1 to 9 digits; change this when OCLC issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if tonumber (id) &gt; handler.id_limit then
			number = nil;														-- unset when id value exceeds the limit
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		set_message ('err_bad_oclc')											-- add an error message if the id is malformed
		options.coins_list_t['OCLC'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local ident, code = id:gsub('^OL', ''):match(&quot;^(%d+([AMW]))$&quot;);				-- strip optional OL prefix followed immediately by digits followed by 'A', 'M', or 'W';
	local err_flag;
	local prefix = {															-- these are appended to the handler.prefix according to code
		['A']='authors/OL',
		['M']='books/OL',
		['W']='works/OL',
		['X']='OL'																-- not a code; spoof when 'code' in id is invalid
		};

	if not ident then
		code = 'X';																-- no code or id completely invalid
		ident = id;																-- copy id to ident so that we display the flawed identifier
		err_flag = set_message ('err_bad_ol');
	end

	if not is_set (err_flag) then
		options.coins_list_t['OL'] = handler.prefix .. prefix[code] .. ident;	-- experiment for ol coins
	else
		options.coins_list_t['OL'] = nil;										-- when error, unset so not included in COinS
	end

	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix .. prefix[code],
		id = ident, separator = handler.separator, encode = handler.encode,
		access = access});
end


--[[--------------------------&lt; O S T I &gt;----------------------------------------------------------------------

Format OSTI and do simple error checking. OSTIs are sequential numbers beginning at 1 and counting up.  This
code checks the OSTI to see that it contains only digits and is less than test_limit specified in the configuration;
the value in test_limit will need to be updated periodically as more OSTIs are issued.

NB. 1018 is the lowest OSTI number found in the wild (so far) and resolving OK on the OSTI site

]]

local function osti (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;

	if id:match(&quot;[^%d]&quot;) then													-- if OSTI has anything but digits
		set_message ('err_bad_osti');											-- set an error message
		options.coins_list_t['OSTI'] = nil;										-- when error, unset so not included in COinS
	else																		-- OSTI is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1018 &gt; id_num or handler.id_limit &lt; id_num then						-- if OSTI is outside test limit boundaries
			set_message ('err_bad_osti');										-- set an error message
			options.coins_list_t['OSTI'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc (options)
	local id = options.id;
	local embargo = options.Embargo;											-- TODO: lowercase?
	local handler = options.handler;
	local err_flag;
	local id_num;
	local text;

	id_num = id:match ('^[Pp][Mm][Cc](%d+)$');									-- identifier with PMC prefix

	if is_set (id_num) then
		set_message ('maint_pmc_format');
	else																		-- plain number without PMC prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if PMC is outside test limit boundaries
			err_flag = set_message ('err_bad_pmc');								-- set an error message
		else
			id = tostring (id_num);												-- make sure id is a string
		end
	else																		-- when id format incorrect
		err_flag = set_message ('err_bad_pmc');									-- set an error message
	end
	
	if is_set (embargo) and is_set (is_embargoed (embargo)) then				-- is PMC is still embargoed?
		text = table.concat (													-- still embargoed so no external link
			{
			make_wikilink (link_label_make (handler), handler.label),
			handler.separator,
			id,
			});
	else
		text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,	-- no embargo date or embargo has expired, ok to link to article
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access,
			auto_link = not err_flag and 'pmc' or nil							-- do not auto-link when PMC has error
			});
	end

	if err_flag then
		options.coins_list_t['PMC'] = nil;										-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid (options)
	local id = options.id;
	local handler = options.handler;

	if id:match(&quot;[^%d]&quot;) then													-- if PMID has anything but digits
		set_message ('err_bad_pmid');											-- set an error message
		options.coins_list_t['PMID'] = nil;										-- when error, unset so not included in COinS
	else																		-- PMID is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if PMID is outside test limit boundaries
			set_message ('err_bad_pmid');										-- set an error message
			options.coins_list_t['PMID'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; R F C &gt;------------------------------------------------------------------------

Format RFC and do simple error checking. RFCs are sequential numbers beginning at 1 and counting up.  This
code checks the RFC to see that it contains only digits and is less than test_limit specified in the configuration;
the value in test_limit will need to be updated periodically as more RFCs are issued.

An index of all RFCs is here: https://tools.ietf.org/rfc/

]]

local function rfc (options)
	local id = options.id;
	local handler = options.handler;

	if id:match(&quot;[^%d]&quot;) then													-- if RFC has anything but digits
		set_message ('err_bad_rfc');											-- set an error message
		options.coins_list_t['RFC'] = nil;										-- when error, unset so not included in COinS
	else																		-- RFC is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if RFC is outside test limit boundaries
			set_message ('err_bad_rfc');										-- set an error message
			options.coins_list_t['RFC'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access});
end


--[[--------------------------&lt; S 2 C I D &gt;--------------------------------------------------------------------

Format an S2CID, do simple error checking

S2CIDs are sequential numbers beginning at 1 and counting up.  This code checks the S2CID to see that it is only
digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically
as more S2CIDs are issued.

]]

local function s2cid (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local id_num;
	local text;
	
	id_num = id:match ('^[1-9]%d*$');											-- id must be all digits; must not begin with 0; no open access flag

 	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if handler.id_limit &lt; id_num then										-- if S2CID is outside test limit boundaries
			set_message ('err_bad_s2cid');										-- set an error message
			options.coins_list_t['S2CID'] = nil;								-- when error, unset so not included in COinS
		end
	else																		-- when id format incorrect
		set_message ('err_bad_s2cid');											-- set an error message
		options.coins_list_t['S2CID'] = nil;									-- when error, unset so not included in COinS
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});

	return text;
end


--[[--------------------------&lt; S B N &gt;------------------------------------------------------------------------

9-digit form of ISBN-10; uses same check-digit validation when SBN is prefixed with an additional '0' to make 10 digits

sbn value not made part of COinS metadata because we don't have a url or isn't a COinS-defined identifier (rft.xxx)
or an identifier registered at info-uri.info (info:)

]]

local function sbn (options)
	local id = options.id;
	local ignore_invalid = options.accept;
	local handler = options.handler;
	local function return_result (check, err_type)								-- local function to handle the various returns
		local SBN = internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,
						prefix = handler.prefix, id = id, separator = handler.separator});
		if not ignore_invalid then												-- if not ignoring SBN errors
			if not check then
				options.coins_list_t['SBN'] = nil;								-- when error, unset so not included in COinS; not really necessary here because sbn not made part of COinS
				set_message ('err_bad_sbn', {err_type});						-- display an error message
				return SBN; 
			end
		else
			set_message ('maint_isbn_ignore');									-- add a maint category even when there is no error (ToDo: Possibly switch to separate message for SBNs only)
		end
		return SBN;
	end

	if id:match ('[^%s-0-9X]') then
		return return_result (false, cfg.err_msg_supl.char);					-- fail if SBN contains anything but digits, hyphens, or the uppercase X
	end

	local ident = id:gsub ('[%s-]', '');										-- remove hyphens and whitespace; they interfere with the rest of the tests

	if  9 ~= ident:len() then
		return return_result (false, cfg.err_msg_supl.length);					-- fail if incorrect length
	end

	if ident:match ('^%d*X?$') == nil then
		return return_result (false, cfg.err_msg_supl.form);					-- fail if SBN has 'X' anywhere but last position
	end

	return return_result (is_valid_isxn ('0' .. ident, 10), cfg.err_msg_supl.check);
end


--[[--------------------------&lt; S S R N &gt;----------------------------------------------------------------------

Format an SSRN, do simple error checking

SSRNs are sequential numbers beginning at 100? and counting up.  This code checks the SSRN to see that it is
only digits and is greater than 99 and less than test_limit; the value in local variable test_limit will need
to be updated periodically as more SSRNs are issued.

]]

local function ssrn (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;
	local text;
	
	id_num = id:match ('^%d+$');												-- id must be all digits

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if 100 &gt; id_num or handler.id_limit &lt; id_num then						-- if SSRN is outside test limit boundaries
			set_message ('err_bad_ssrn');										-- set an error message
			options.coins_list_t['SSRN'] = nil;									-- when error, unset so not included in COinS
		end
	else																		-- when id format incorrect
		set_message ('err_bad_ssrn');											-- set an error message
		options.coins_list_t['SSRN'] = nil;										-- when error, unset so not included in COinS
	end
	
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = options.access});

	return text;
end


--[[--------------------------&lt; U S E N E T _ I D &gt;------------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function usenet_id (options)
	local id = options.id;
	local handler = options.handler;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$') then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		set_message ('err_bad_usenet_id')										-- add an error message if the message id is invalid
		options.coins_list_t['USENETID'] = nil;									-- when error, unset so not included in COinS
	end 
	
	return text;
end


--[[--------------------------&lt; Z B L &gt;-----------------------------------------------------------------------

A numerical identifier in the form nnnn.nnnnn - leading zeros in the first quartet optional

format described here: http://emis.mi.sanu.ac.rs/ZMATH/zmath/en/help/search/

temporary format is apparently eight digits.  Anything else is an error

]]

local function zbl (options)
	local id = options.id;
	local handler = options.handler;

	if id:match('^%d%d%d%d%d%d%d%d$') then										-- is this identifier using temporary format?
		set_message ('maint_zbl');												-- yes, add maint cat
	elseif not id:match('^%d?%d?%d?%d%.%d%d%d%d%d$') then						-- not temporary, is it normal format?
		set_message ('err_bad_zbl');											-- no, set an error message
		options.coins_list_t['ZBL'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--============================&lt;&lt; I N T E R F A C E   F U N C T I O N S &gt;&gt;==========================================

--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message if more than one alias exists in args

]]

local function extract_ids (args)
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs (cfg.id_handlers) do										-- k is uppercase identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one (args, v.parameters, 'err_redundant_parameters' );		-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set (v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; E X T R A C T _ I D _ A C C E S S _ L E V E L S &gt;--------------------------------------

Fetches custom id access levels from arguments using configuration settings. Parameters which have a predefined access
level (e.g. arxiv) do not use this function as they are directly rendered as free without using an additional parameter.

returns a table of k/v pairs where k is same as the identifier's key in cfg.id_handlers and v is the assigned (valid) keyword

access-level values must match the case used in cfg.keywords_lists['id-access'] (lowercase unless there is some special reason for something else)

]]

local function extract_id_access_levels (args, id_list)
	local id_accesses_list = {};
	for k, v in pairs (cfg.id_handlers) do
		local access_param = v.custom_access;									-- name of identifier's access-level parameter
		if is_set (access_param) then
			local access_level = args[access_param];							-- get the assigned value if there is one
			if is_set (access_level) then
				if not in_array (access_level, cfg.keywords_lists['id-access']) then	-- exact match required
					set_message ('err_invalid_param_val', {access_param, access_level});	
					access_level = nil;											-- invalid so unset
				end
				if not is_set (id_list[k]) then									-- identifier access-level must have a matching identifier
					set_message ('err_param_access_requires_param', {k:lower()});	-- parameter name is uppercase in cfg.id_handlers (k); lowercase for error message
				end
				id_accesses_list[k] = cfg.keywords_xlate[access_level];			-- get translated keyword
			end
		end
	end
	return id_accesses_list;
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;----------------------------------------------------

render the identifiers into a sorted sequence table

&lt;ID_list_coins_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value
&lt;options_t&gt; is a table of various k/v option pairs provided in the call to new_build_id_list();
	modified by	this function and passed to all identifier rendering functions
&lt;access_levels_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value (if valid)

returns a sequence table of sorted (by hkey - 'handler' key) rendered identifier strings

]]

local function build_id_list (ID_list_coins_t, options_t, access_levels_t)
	local ID_list_t = {};
	local accept;
	local func_map = {															--function map points to functions associated with hkey identifier
		['ARXIV'] = arxiv,
		['ASIN'] = asin,
		['BIBCODE'] = bibcode,
		['BIORXIV'] = biorxiv,
		['CITESEERX'] = citeseerx,
		['DOI'] = doi,
		['EISSN'] = issn,
		['HDL'] = hdl,
		['ISBN'] = isbn,
		['ISMN'] = ismn,
		['ISSN'] = issn,
		['JFM'] = jfm,
		['JSTOR'] = jstor,
		['LCCN'] = lccn,
		['MEDRXIV'] = medrxiv,
		['MR'] = mr,
		['OCLC'] = oclc,
		['OL'] = openlibrary,
		['OSTI'] = osti,
		['PMC'] = pmc,
		['PMID'] = pmid,
		['RFC']  = rfc,
		['S2CID'] = s2cid,
		['SBN'] = sbn,
		['SSRN'] = ssrn,
		['USENETID'] = usenet_id,
		['ZBL'] = zbl,
		}

	for hkey, v in pairs (ID_list_coins_t) do
		v, accept = has_accept_as_written (v);									-- remove accept-as-written markup if present; accept is boolean true when markup removed; false else
																				-- every function gets the options table with value v and accept boolean
		options_t.hkey = hkey;													-- ~/Configuration handler key
		options_t.id = v;														-- add that identifier value to the options table
		options_t.accept = accept;												-- add the accept boolean flag
		options_t.access = access_levels_t[hkey];								-- add the access level for those that have an |&lt;identifier-access= parameter
		options_t.handler = cfg.id_handlers[hkey];
		options_t.coins_list_t = ID_list_coins_t;								-- pointer to ID_list_coins_t; for |asin= and |ol=; also to keep erroneous values out of the citation's metadata
		options_t.coins_list_t[hkey] = v;										-- id value without accept-as-written markup for metadata
		
		if options_t.handler.access and not in_array (options_t.handler.access, cfg.keywords_lists['id-access']) then
			error (cfg.messages['unknown_ID_access'] .. options_t.handler.access);	-- here when handler access key set to a value not listed in list of allowed id access keywords
		end

		if func_map[hkey] then
			local id_text = func_map[hkey] (options_t);							-- call the function to get identifier text and any error message
			table.insert (ID_list_t, {hkey, id_text});							-- add identifier text to the output sequence table
		else
			error (cfg.messages['unknown_ID_key'] .. hkey);						-- here when func_map doesn't have a function for hkey
		end
	end

	local function comp (a, b)													-- used by following table.sort()
		return a[1]:lower() &lt; b[1]:lower();										-- sort by hkey
	end

	table.sort (ID_list_t, comp);												-- sequence table of tables sort	
	for k, v in ipairs (ID_list_t) do											-- convert sequence table of tables to simple sequence table of strings
		ID_list_t[k] = v[2];													-- v[2] is the identifier rendering from the call to the various functions in func_map{}
	end
	
	return ID_list_t;
end


--[[--------------------------&lt; O P T I O N S _ C H E C K &gt;----------------------------------------------------

check that certain option parameters have their associated identifier parameters with values

&lt;ID_list_coins_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value
&lt;ID_support_t&gt; is a sequence table of tables created in citation0() where each subtable has four elements:
	[1] is the support parameter's assigned value; empty string if not set
	[2] is a text string same as key in cfg.id_handlers
	[3] is cfg.error_conditions key used to create error message
	[4] is original ID support parameter name used to create error message
	
returns nothing; on error emits an appropriate error message

]]

local function options_check (ID_list_coins_t, ID_support_t)
	for _, v in ipairs (ID_support_t) do
		if is_set (v[1]) and not ID_list_coins_t[v[2]] then						-- when support parameter has a value but matching identifier parameter is missing or empty
			set_message (v[3], (v[4]));											-- emit the appropriate error message
		end
	end
end


--[[--------------------------&lt; I D E N T I F I E R _ L I S T S _ G E T &gt;--------------------------------------

Creates two identifier lists: a k/v table of identifiers and their values to be used locally and for use in the
COinS metadata, and a sequence table of the rendered identifier strings that will be included in the rendered
citation.

]]

local function identifier_lists_get (args_t, options_t, ID_support_t)
	local ID_list_coins_t = extract_ids (args_t);										-- get a table of identifiers and their values for use locally and for use in COinS
	options_check (ID_list_coins_t, ID_support_t);										-- ID support parameters must have matching identifier parameters 
	local ID_access_levels_t = extract_id_access_levels (args_t, ID_list_coins_t);		-- get a table of identifier access levels
	local ID_list_t = build_id_list (ID_list_coins_t, options_t, ID_access_levels_t);	-- get a sequence table of rendered identifier strings

	return ID_list_t, ID_list_coins_t;											-- return the tables
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	has_accept_as_written = utilities_page_ptr.has_accept_as_written;			-- import functions from select Module:Citation/CS1/Utilities module
	is_set = utilities_page_ptr.is_set;								
	in_array = utilities_page_ptr.in_array;
	set_message = utilities_page_ptr.set_message;
	select_one = utilities_page_ptr.select_one;
	substitute = utilities_page_ptr.substitute;
	make_wikilink = utilities_page_ptr.make_wikilink;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	auto_link_urls = auto_link_urls,											-- table of identifier URLs to be used when auto-linking |title=
	
	identifier_lists_get = identifier_lists_get,								-- experiment to replace individual calls to build_id_list(), extract_ids, extract_id_access_levels
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>73vdzq08sflt35x53xns1mv63pkq88c</sha1>
    </revision>
    <revision>
      <id>4925</id>
      <parentid>4924</parentid>
      <timestamp>2023-11-25T16:42:08Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4925</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="76854" sha1="6uzqpmnr4f7kbilmaopc20fiwrqbywt" xml:space="preserve">--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local has_accept_as_written, is_set, in_array, set_message, select_one,			-- functions in Module:Citation/CS1/Utilities
		substitute, make_wikilink;

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

declare variables here that have page-wide scope that are not brought in from other modules; that are created here and used here

]]

local auto_link_urls = {};														-- holds identifier URLs for those identifiers that can auto-link |title=


--============================&lt;&lt; H E L P E R   F U N C T I O N S &gt;&gt;============================================

--[[--------------------------&lt; W I K I D A T A _ A R T I C L E _ N A M E _ G E T &gt;----------------------------

as an aid to internationalizing identifier-label wikilinks, gets identifier article names from Wikidata.

returns :&lt;lang code&gt;:&lt;article title&gt; when &lt;q&gt; has an &lt;article title&gt; for &lt;lang code&gt;; nil else

for identifiers that do not have q, returns nil

for wikis that do not have mw.wikibase installed, returns nil

]]

local function wikidata_article_name_get (q)
	if not is_set (q) or (q and not mw.wikibase) then							-- when no q number or when a q number but mw.wikibase not installed on this wiki
		return nil;																-- abandon
	end

	local wd_article;
	local this_wiki_code = cfg.this_wiki_code;									-- Wikipedia subdomain; 'en' for en.wikipedia.org

	wd_article = mw.wikibase.getSitelink (q, this_wiki_code .. 'wiki');			-- fetch article title from WD; nil when no title available at this wiki

	if wd_article then
		wd_article = table.concat ({':', this_wiki_code, ':', wd_article});		-- interwiki-style link without brackets if taken from WD; leading colon required
	end

	return wd_article;															-- article title from WD; nil else
end


--[[--------------------------&lt; L I N K _ L A B E L _ M A K E &gt;------------------------------------------------

common function to create identifier link label from handler table or from Wikidata

returns the first available of
	1. redirect from local wiki's handler table (if enabled)
	2. Wikidata (if there is a Wikidata entry for this identifier in the local wiki's language)
	3. label specified in the local wiki's handler table
	
]]

local function link_label_make (handler)
	local wd_article;
	
	if not (cfg.use_identifier_redirects and is_set (handler.redirect)) then	-- redirect has priority so if enabled and available don't fetch from Wikidata because expensive
		wd_article = wikidata_article_name_get (handler.q);						-- if Wikidata has an article title for this wiki, get it;
	end
	
	return (cfg.use_identifier_redirects and is_set (handler.redirect) and handler.redirect) or wd_article or handler.link;
end


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki-style external link

]]

local function external_link_id (options)
	local url_string = options.id;
	local ext_link;
	local this_wiki_code = cfg.this_wiki_code;									-- Wikipedia subdomain; 'en' for en.wikipedia.org
	local wd_article;															-- article title from Wikidata
	
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode (url_string, 'PATH');
	end

	if options.auto_link and is_set (options.access) then
		auto_link_urls[options.auto_link] = table.concat ({options.prefix, url_string, options.suffix});
	end

	ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or &quot;&quot;, mw.text.nowiki (options.id));
	if is_set (options.access) then
		ext_link = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[options.access].class, cfg.presentation[options.access].title, ext_link});	-- add the free-to-read / paywall lock
	end

	return table.concat	({
		make_wikilink (link_label_make (options), options.label),				-- redirect, Wikidata link, or locally specified link (in that order)
		options.separator or '&amp;nbsp;',
		ext_link
		});
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki-style internal link

TODO: Does not currently need to support options.access, options.encode, auto-linking and COinS (as in external_link_id),
but may be needed in the future for :m:Interwiki_map custom-prefixes like :arxiv:, :bibcode:, :DOI:, :hdl:, :ISSN:,
:JSTOR:, :Openlibrary:, :PMID:, :RFC:.

]]

local function internal_link_id (options)
	local id = mw.ustring.gsub (options.id, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9

	return table.concat (
		{
		make_wikilink (link_label_make (options), options.label),				-- wiki-link the identifier label
		options.separator or '&amp;nbsp;',											-- add the separator
		make_wikilink (
			table.concat (
				{
				options.prefix,
				id,																-- translated to Western digits
				options.suffix or ''
				}),
			substitute (cfg.presentation['bdi'], {'', mw.text.nowiki (options.id)})	-- bdi tags to prevent Latin script identifiers from being reversed at RTL language wikis
			);																	-- nowiki because MediaWiki still has magic links for ISBN and the like; TODO: is it really required?
		});
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |pmc-embargo-date= against
today's date.  If embargo date is in the future, returns the content of |pmc-embargo-date=; otherwise, returns
an empty string because the embargo has expired or because |pmc-embargo-date= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, todays_date;
		good1, embargo_date = pcall (lang.formatDate, lang, 'U', embargo);
		todays_date = lang:formatDate ('U');
	
		if good1 then															-- if embargo date is a good date
			if tonumber (embargo_date) &gt;= tonumber (todays_date) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				set_message ('maint_pmc_embargo');								-- embargo has expired; add main cat
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |pmc-embargo-date= not set return empty string
end


--[=[-------------------------&lt; I S _ V A L I D _ R X I V _ D A T E &gt;------------------------------------------

for biorxiv, returns true if:
	2019-12-11T00:00Z &lt;= biorxiv_date &lt; today + 2 days
for medrxiv, returns true if:
	2020-01-01T00:00Z &lt;= medrxiv_date &lt; today + 2 days
	
The dated form of biorxiv identifier has a start date of 2019-12-11.  The Unix timestamp for that date is {{#time:U|2019-12-11}} = 1576022400
The medrxiv identifier has a start date of 2020-01-01.  The Unix timestamp for that date is {{#time:U|2020-01-01}} = 1577836800

&lt;rxiv_date&gt; is the date provided in those |biorxiv= parameter values that are dated and in |medrxiv= parameter values at time 00:00:00 UTC
&lt;today&gt; is the current date at time 00:00:00 UTC plus 48 hours
	if today's date is 2023-01-01T00:00:00 then
		adding 24 hours gives 2023-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2023-01-03T00:00:00 – one second more than tomorrow

inputs:
	&lt;y&gt;, &lt;m&gt;, &lt;d&gt; – year, month, day parts of the date from the birxiv or medrxiv identifier
	&lt;select&gt; 'b' for biorxiv, 'm' for medrxiv; defaults to 'b'

]=]

local function is_valid_rxiv_date (y, m, d, select)
	if 0 == tonumber (m) and 12 &lt; tonumber (m) then								-- &lt;m&gt; must be a number 1–12
		return false;
	end
	if 0 == tonumber (d) and 31 &lt; tonumber (d) then								-- &lt;d&gt; must be a number 1–31; TODO: account for month length and leap yer?
		return false;
	end
	
	local rxiv_date = table.concat ({y, m, d}, '-');							-- make ymd date string
	local good1, good2;
	local rxiv_ts, tomorrow_ts;													-- to hold Unix timestamps representing the dates
	local lang_object = mw.getContentLanguage();

	good1, rxiv_ts = pcall (lang_object.formatDate, lang_object, 'U', rxiv_date);		-- convert rxiv_date value to Unix timestamp 
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which tonumber() may not understand
		rxiv_ts = tonumber (rxiv_ts) or lang_object:parseFormattedNumber (rxiv_ts);	-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to Unix timestamp
	end

	local limit_ts = ((select and ('m' == select)) and 1577836800) or 1576022400;	-- choose the appropriate limit timesatmp

	return ((limit_ts &lt;= rxiv_ts) and (rxiv_ts &lt; tomorrow_ts))					-- limit_ts &lt;= rxiv_date &lt; tomorrow's date
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all ISBN/ISSN digits including the check digit.
ISBN-13 is checked in isbn().

If the number is valid the result will be 0. Before calling this function, ISBN/ISSN must be checked for length
and stripped of dashes, spaces and other non-ISxN characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39, 'X' → 0x58
	len = len + 1;																-- adjust to be a loop counter
	for i, v in ipairs (isxn_str) do											-- loop through all of the bytes and calculate the checksum
		if v == string.byte (&quot;X&quot; ) then											-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10 * (len - i);										-- it represents 10 decimal
		else
			temp = temp + tonumber (string.char (v) )*(len-i);
		end
	end
	return temp % 11 == 0;														-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N _ 1 3 &gt;-----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 ISBN/ISMN digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, ISBN-13/ISMN must be checked for length
and stripped of dashes, spaces and other non-ISxN-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39
	for i, v in ipairs (isxn_str) do
		temp = temp + (3 - 2*(i % 2)) * tonumber (string.char (v) );			-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when ISBN-13/ISMN is correct
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

LCCN normalization (https://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized LCCN for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.

]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);												-- 1. strip whitespace

	if nil ~= string.find (lccn, '/') then
		lccn = lccn:match (&quot;(.-)/&quot;);											-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);									-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then														-- if there was a hyphen
		suffix = string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;				-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn = prefix..suffix;													-- reassemble the LCCN
	end
	
	return lccn;
	end


--============================&lt;&lt; I D E N T I F I E R   F U N C T I O N S &gt;&gt;====================================

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: https://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9107 and 0703, is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation; not the same as |class= parameter which is not supported in this form
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number

]]

local function arxiv (options)
	local id = options.id;
	local class = options.Class;												-- TODO: lowercase?
	local handler = options.handler;
	local year, month, version;
	local err_msg = false;														-- assume no error message
	local text;																	-- output text
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9107-0703 format with or without version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_msg = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 with or without version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then									-- when year is 07, is month invalid (before April)?
				err_msg = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format with or without version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_msg = true;														-- flag for error message
		end

	else
		err_msg = true;															-- not a recognized format; flag for error message
	end

	if err_msg then
		options.coins_list_t['ARXIV'] = nil;									-- when error, unset so not included in COinS
	end
	
	local err_msg_t = {};
	if err_msg then
		set_message ('err_bad_arxiv');
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access});

	if is_set (class) then
		if id:match ('^%d+') then
			text = table.concat ({text, ' [[https://arxiv.org/archive/', class, ' ', class, ']]'});	-- external link within square brackets, not wikilink
		else
			set_message ('err_class_ignored');
		end
	end

	return text;
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode ID.

Format for bibcodes is specified here: https://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		9–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local ignore_invalid = options.accept;
	local err_type;
	local err_msg = '';
	local year;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode,
		access = access});
	
	if 19 ~= id:len() then
		err_type = cfg.err_msg_supl.length;
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%w&amp;%.][%w&amp;%.][%w&amp;%.][%w.]+[%a%.]$&quot;);
		if not year then														-- if nil then no pattern match
			err_type = cfg.err_msg_supl.value;									-- so value error
		else
			local next_year = tonumber (os.date ('%Y')) + 1;					-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = cfg.err_msg_supl.year;								-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = cfg.err_msg_supl.journal;							-- journal abbreviation must not have '&amp;.' (if it does it's missing a letter)
			end
			if id:match ('.........%.tmp%.') then								-- temporary bibcodes when positions 10–14 are '.tmp.'
				set_message ('maint_bibcode');
			end
		end
	end

	if is_set (err_type) and not ignore_invalid then							-- if there was an error detected and accept-as-written markup not used
		set_message ('err_bad_bibcode', {err_type});
		options.coins_list_t['BIBCODE'] = nil;									-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; B I O R X I V &gt;-----------------------------------------------------------------

Format bioRxiv ID and do simple error checking.  Before 2019-12-11, biorXiv IDs were 10.1101/ followed by exactly
6 digits.  After 2019-12-11, biorXiv IDs retained the six-digit identifier but prefixed that with a yyyy.mm.dd. 
date and suffixed with an optional version identifier.

The bioRxiv ID is the string of characters:
	https://doi.org/10.1101/078733 -&gt; 10.1101/078733
or a date followed by a six-digit number followed by an optional version indicator 'v' and one or more digits:
	https://www.biorxiv.org/content/10.1101/2019.12.11.123456v2 -&gt; 10.1101/2019.12.11.123456v2
	
see https://www.biorxiv.org/about-biorxiv

]]

local function biorxiv (options)
	local id = options.id;
	local handler = options.handler;
	local err_msg = true;														-- flag; assume that there will be an error
	
	local patterns = {
		'^10%.1101/%d%d%d%d%d%d$',												-- simple 6-digit identifier (before 2019-12-11)
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%dv%d+$',				-- y.m.d. date + 6-digit identifier + version (after 2019-12-11)
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%d$',					-- y.m.d. date + 6-digit identifier (after 2019-12-11)
		}
	
	for _, pattern in ipairs (patterns) do										-- spin through the patterns looking for a match
		if id:match (pattern) then
			local y, m, d = id:match (pattern);									-- found a match, attempt to get year, month and date from the identifier

			if m then															-- m is nil when id is the six-digit form
				if not is_valid_rxiv_date (y, m, d, 'b') then					-- validate the encoded date; 'b' for biorxiv limit
					break;														-- date fail; break out early so we don't unset the error message
				end
			end
			err_msg = nil;														-- we found a match so unset the error message
			break;																-- and done
		end
	end																			-- err_cat remains set here when no match

	if err_msg then
		options.coins_list_t['BIORXIV'] = nil;									-- when error, unset so not included in COinS
		set_message ('err_bad_biorxiv');										-- and set the error message
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator,
			encode = handler.encode, access = handler.access});
end


--[[--------------------------&lt; C I T E S E E R X &gt;------------------------------------------------------------

CiteSeerX use their own notion of &quot;doi&quot; (not to be confused with the identifiers resolved via doi.org).

The description of the structure of this identifier can be found at Help_talk:Citation_Style_1/Archive_26#CiteSeerX_id_structure

]]

local function citeseerx (options)
	local id = options.id;
	local handler = options.handler;
	local matched;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode,
		access = handler.access});
	
	matched = id:match (&quot;^10%.1%.1%.[1-9]%d?%d?%d?%.[1-9]%d?%d?%d?$&quot;);
	if not matched then
		set_message ('err_bad_citeseerx' );
		options.coins_list_t['CITESEERX'] = nil;								-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the DOI name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in DOI names.

https://www.doi.org/doi_handbook/2_Numbering.html				-- 2.2 Syntax of a DOI name
https://www.doi.org/doi_handbook/2_Numbering.html#2.2.2			-- 2.2.2 DOI prefix

]]

local function doi (options)
	local id = options.id;
	local inactive = options.DoiBroken
	local access = options.access;
	local ignore_invalid = options.accept;
	local handler = options.handler;
	local err_flag;

	local text;
	if is_set (inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;);						-- try to get the year portion from the inactive date
		local inactive_month, good;

		if is_set (inactive_year) then
			if 4 &lt; inactive:len() then											-- inactive date has more than just a year (could be anything)
				local lang_obj = mw.getContentLanguage();						-- get a language object for this wiki
				good, inactive_month = pcall (lang_obj.formatDate, lang_obj, 'F', inactive);	-- try to get the month name from the inactive date
				if not good then
					inactive_month = nil;										-- something went wrong so make sure this is unset
				end
			end
		end																		-- otherwise, |doi-broken-date= has something but it isn't a date
		
		if is_set (inactive_year) and is_set (inactive_month) then
			set_message ('maint_doi_inactive_dated', {inactive_year, inactive_month, ' '});
		elseif is_set (inactive_year) then
			set_message ('maint_doi_inactive_dated', {inactive_year, '', ''});
		else
			set_message ('maint_doi_inactive');
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. ' ' .. inactive .. ')';
	end

	local registrant = mw.ustring.match (id, '^10%.([^/]+)/[^%s–]-[^%.,]$');	-- registrant set when DOI has the proper basic form

	local registrant_err_patterns = {											-- these patterns are for code ranges that are not supported 
		'^[^1-3]%d%d%d%d%.%d+$',												-- 5 digits with subcode (0xxxx, 40000+); accepts: 10000–39999
		'^[^1-6]%d%d%d%d$',														-- 5 digits without subcode (0xxxx, 60000+); accepts: 10000–69999
		'^[^1-9]%d%d%d%.%d+$',												-- 4 digits with subcode (0xxx); accepts: 1000–9999
		'^[^1-9]%d%d%d$',														-- 4 digits without subcode (0xxx); accepts: 1000–9999
		'^%d%d%d%d%d%d+',														-- 6 or more digits
		'^%d%d?%d?$',															-- less than 4 digits without subcode (3 digits with subcode is legitimate)
		'^%d%d?%.[%d%.]+',														-- 1 or 2 digits with subcode
		'^5555$',																-- test registrant will never resolve
		'[^%d%.]',																-- any character that isn't a digit or a dot
		}

	if not ignore_invalid then
		if registrant then														-- when DOI has proper form
			for i, pattern in ipairs (registrant_err_patterns) do				-- spin through error patterns
				if registrant:match (pattern) then								-- to validate registrant codes
					err_flag = set_message ('err_bad_doi');						-- when found, mark this DOI as bad
					break;														-- and done
				end
			end
		else
			err_flag = set_message ('err_bad_doi');								-- invalid directory or malformed
		end
	else
		set_message ('maint_doi_ignore');
	end

	if err_flag then
		options.coins_list_t['DOI'] = nil;										-- when error, unset so not included in COinS
	else
		if not access and cfg.known_free_doi_registrants_t[registrant] then		-- |doi-access=free not set and &lt;registrant&gt; is known to be free
			set_message ('maint_doi_unflagged_free');							-- set a maint cat
		end
	end
	
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access,
		auto_link = not (err_flag or is_set (inactive) or ignore_invalid) and 'doi' or nil -- do not auto-link when |doi-broken-date= has a value or when there is a DOI error or (to play it safe, after all, auto-linking is not essential) when invalid DOIs are ignored
		}) .. (inactive or '');

	return text;
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

Query string parameters are named here: https://www.handle.net/proxy_servlet.html.  query strings are not displayed
but since '?' is an allowed character in an HDL, '?' followed by one of the query parameters is the only way we
have to detect the query string so that it isn't URL-encoded with the rest of the identifier.

]]

local function hdl (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local query_params = {														-- list of known query parameters from https://www.handle.net/proxy_servlet.html
		'noredirect',
		'ignore_aliases',
		'auth',
		'cert',
		'index',
		'type',
		'urlappend',
		'locatt',
		'action',
		}
	
	local hdl, suffix, param = id:match ('(.-)(%?(%a+).+)$');					-- look for query string
	local found;

	if hdl then																	-- when there are query strings, this is the handle identifier portion
		for _, q in ipairs (query_params) do									-- spin through the list of query parameters
			if param:match ('^' .. q) then										-- if the query string begins with one of the parameters
				found = true;													-- announce a find
				break;															-- and stop looking
			end
		end
	end

	if found then
		id = hdl;																-- found so replace id with the handle portion; this will be URL-encoded, suffix will not
	else
		suffix = '';															-- make sure suffix is empty string for concatenation else
	end

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, suffix = suffix, separator = handler.separator, encode = handler.encode, access = access})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- HDL must contain a forward slash, must not contain spaces, endashes, and must not end with period or comma
		set_message ('err_bad_hdl' );
		options.coins_list_t['HDL'] = nil;										-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; I S B N &gt;----------------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function isbn (options)
	local isbn_str = options.id;
	local ignore_invalid = options.accept;
	local handler = options.handler;

	local function return_result (check, err_type)								-- local function to handle the various returns
		local ISBN = internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,
						prefix = handler.prefix, id = isbn_str, separator = handler.separator});
		if ignore_invalid then													-- if ignoring ISBN errors
			set_message ('maint_isbn_ignore');									-- add a maint category even when there is no error
		else																	-- here when not ignoring
			if not check then													-- and there is an error
				options.coins_list_t['ISBN'] = nil;								-- when error, unset so not included in COinS
				set_message ('err_bad_isbn', err_type);							-- set an error message
				return ISBN;										 			-- return id text
			end
		end
		return ISBN;															-- return id text
	end

	if nil ~= isbn_str:match ('[^%s-0-9X]') then
		return return_result (false, cfg.err_msg_supl.char);					-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end

	local id = isbn_str:gsub ('[%s-]', '');										-- remove hyphens and whitespace

	local len = id:len();
 
	if len ~= 10 and len ~= 13 then
		return return_result (false, cfg.err_msg_supl.length);					-- fail if incorrect length
	end

	if len == 10 then
		if id:match ('^%d*X?$') == nil then										-- fail if isbn_str has 'X' anywhere but last position
			return return_result (false, cfg.err_msg_supl.form);									
		end
		if not is_valid_isxn (id, 10) then										-- test isbn-10 for numerical validity
			return return_result (false, cfg.err_msg_supl.check);				-- fail if isbn-10 is not numerically valid
		end
		if id:find ('^63[01]') then												-- 630xxxxxxx and 631xxxxxxx are (apparently) not valid isbn group ids but are used by amazon as numeric identifiers (asin)
			return return_result (false, cfg.err_msg_supl.group);				-- fail if isbn-10 begins with 630/1
		end
		return return_result (true, cfg.err_msg_supl.check);					-- pass if isbn-10 is numerically valid
	else
		if id:match ('^%d+$') == nil then
			return return_result (false, cfg.err_msg_supl.char);				-- fail if ISBN-13 is not all digits
		end
		if id:match ('^97[89]%d*$') == nil then
			return return_result (false, cfg.err_msg_supl.prefix);				-- fail when ISBN-13 does not begin with 978 or 979
		end
		if id:match ('^9790') then
			return return_result (false, cfg.err_msg_supl.group);				-- group identifier '0' is reserved to ISMN
		end
		return return_result (is_valid_isxn_13 (id), cfg.err_msg_supl.check);
	end
end


--[[--------------------------&lt; A S I N &gt;----------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: ASIN must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, ASINs must be 10-digit
ISBN. If 10-digit ISBN, add a maintenance category so a bot or AWB script can replace |asin= with |isbn=.
Error message if not 10 characters, if not ISBN-10, if mixed and first character is a digit.

|asin=630....... and |asin=631....... are (apparently) not a legitimate ISBN though it checksums as one; these
do not cause this function to emit the maint_asin message

This function is positioned here because it calls isbn()

]]

local function asin (options)
	local id = options.id;
	local domain = options.ASINTLD;
	
	local err_flag;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_flag = set_message ('err_bad_asin');								-- ASIN is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then							-- if 10-digit numeric (or 9 digits with terminal X)
			if is_valid_isxn (id, 10) then										-- see if ASIN value is or validates as ISBN-10
				if not id:find ('^63[01]') then									-- 630xxxxxxx and 631xxxxxxx are (apparently) not a valid isbn prefixes but are used by amazon as a numeric identifier
					err_flag = set_message ('err_bad_asin');					-- ASIN has ISBN-10 form but begins with something other than 630/1 so probably an isbn 
				end
			elseif not is_set (err_flag) then
				err_flag = set_message ('err_bad_asin');						-- ASIN is not ISBN-10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_flag = set_message ('err_bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if (not is_set (domain)) or in_array (domain, {'us'}) then					-- default: United States
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then									-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'z.cn'}) then 									-- China
		domain = &quot;cn&quot;;
	elseif in_array (domain, {'au', 'br', 'mx', 'sg', 'tr'}) then				-- Australia, Brazil, Mexico, Singapore, Turkey
		domain = &quot;com.&quot; .. domain;
	elseif not in_array (domain, {'ae', 'ca', 'cn', 'de', 'es', 'fr', 'in', 'it', 'nl', 'pl', 'sa', 'se', 'co.jp', 'co.uk', 'com', 'com.au', 'com.br', 'com.mx', 'com.sg', 'com.tr'}) then -- Arabic Emirates, Canada, China, Germany, Spain, France, Indonesia, Italy, Netherlands, Poland, Saudi Arabia, Sweden (as of 2021-03 Austria (.at), Liechtenstein (.li) and Switzerland (.ch) still redirect to the German site (.de) with special settings, so don't maintain local ASINs for them)
		err_flag = set_message ('err_bad_asin_tld');							-- unsupported asin-tld value
	end
	local handler = options.handler;

	if not is_set (err_flag) then
		options.coins_list_t['ASIN'] = handler.prefix .. domain .. &quot;/dp/&quot; .. id;	-- asin for coins
	else
		options.coins_list_t['ASIN'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix .. domain .. &quot;/dp/&quot;,
		id = id, encode = handler.encode, separator = handler.separator})
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to ISBN-13, ISMN is 13 digits beginning 979-0-... and uses the
same check digit calculations.  See https://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

ismn value not made part of COinS metadata because we don't have a url or isn't a COinS-defined identifier (rft.xxx)
or an identifier registered at info-uri.info (info:)

]]

local function ismn (options)
	local id = options.id;
	local handler = options.handler;
	local text;
	local valid_ismn = true;
	local id_copy;

	id_copy = id;																-- save a copy because this testing is destructive
	id = id:gsub ('[%s-]', '');													-- remove hyphens and white space

	if 13 ~= id:len() or id:match (&quot;^9790%d*$&quot; ) == nil then					-- ISMN must be 13 digits and begin with 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ISMN
	end

	--	text = internal_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,		-- use this (or external version) when there is some place to link to
	--		prefix = handler.prefix, id = id_copy, separator = handler.separator, encode = handler.encode})

	text = table.concat (														-- because no place to link to yet
		{
		make_wikilink (link_label_make (handler), handler.label),
		handler.separator,
		id_copy
		});

	if false == valid_ismn then
		options.coins_list_t['ISMN'] = nil;										-- when error, unset so not included in COinS; not really necessary here because ismn not made part of COinS
		set_message ('err_bad_ismn');											-- create an error message if the ISMN is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an ISSN.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [https://www.worldcat.org/issn/0819 4327 0819 4327]	-- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the ISSN midpoint.  It also validates the ISSN for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check ISSN error message.  The
ISSN is always displayed with a hyphen, even if the ISSN was given as a single group of 8 digits.

]]

local function issn (options)
	local id = options.id;
	local handler = options.handler;
	local ignore_invalid = options.accept;

	local issn_copy = id;														-- save a copy of unadulterated ISSN; use this version for display if ISSN does not validate
	local text;
	local valid_issn = true;

	id = id:gsub ('[%s-]', '');													-- remove hyphens and whitespace

	if 8 ~= id:len() or nil == id:match (&quot;^%d*X?$&quot; ) then						-- validate the ISSN: 8 digits long, containing only 0-9 or X in the last position
		valid_issn = false;														-- wrong length or improper character
	else
		valid_issn = is_valid_isxn (id, 8);										-- validate ISSN
	end

	if true == valid_issn then
		id = string.sub (id, 1, 4 ) .. &quot;-&quot; .. string.sub (id, 5 );				-- if valid, display correctly formatted version
	else
		id = issn_copy;															-- if not valid, show the invalid ISSN with error message
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode})

	if ignore_invalid then
		set_message ('maint_issn_ignore');
	else
		if false == valid_issn then
			options.coins_list_t['ISSN'] = nil;									-- when error, unset so not included in COinS
			set_message ('err_bad_issn', (options.hkey == 'EISSN') and 'e' or '');	-- create an error message if the ISSN is invalid
		end 
	end
	
	return text;
end


--[[--------------------------&lt; J F M &gt;-----------------------------------------------------------------------

A numerical identifier in the form nn.nnnn.nn

]]

local function jfm (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;

	id_num = id:match ('^[Jj][Ff][Mm](.*)$');									-- identifier with jfm prefix; extract identifier

	if is_set (id_num) then
		set_message ('maint_jfm_format');
	else																		-- plain number without JFM prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num and id_num:match('^%d%d%.%d%d%d%d%.%d%d$') then
		id = id_num;															-- jfm matches pattern
	else
		set_message ('err_bad_jfm' );											-- set an error message
		options.coins_list_t['JFM'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; J S T O R &gt;--------------------------------------------------------------------

Format a JSTOR with some error checking

]]

local function jstor (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;

	if id:find ('[Jj][Ss][Tt][Oo][Rr]') or id:find ('^https?://') or id:find ('%s') then
		set_message ('err_bad_jstor');											-- set an error message
		options.coins_list_t['JSTOR'] = nil;									-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});
end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
https://oclc-research.github.io/infoURI-Frozen/info-uri.info/info:lccn/reg.html

length = 8 then all digits
length = 9 then lccn[1] is lowercase alpha
length = 10 then lccn[1] and lccn[2] are both lowercase alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lowercase alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lowercase alpha

]]

local function lccn (options)
	local lccn = options.id;
	local handler = options.handler;
	local err_flag;																-- presume that LCCN is valid
	local id = lccn;															-- local copy of the LCCN

	id = normalize_lccn (id);													-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();														-- get the length of the LCCN

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits)
			err_flag = set_message ('err_bad_lccn');							-- set an error message
		end
	elseif 9 == len then														-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then							-- does it match our pattern?
			err_flag = set_message ('err_bad_lccn');							-- set an error message
		end
	elseif 10 == len then														-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then					-- ... see if it matches our pattern
				err_flag = set_message ('err_bad_lccn');						-- no match, set an error message
			end
		end
	elseif 11 == len then														-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_flag = set_message ('err_bad_lccn');							-- no match, set an error message
		end
	elseif 12 == len then														-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then						-- see if it matches our pattern
			err_flag = set_message ('err_bad_lccn');							-- no match, set an error message
		end
	else
		err_flag = set_message ('err_bad_lccn');								-- wrong length, set an error message
	end

	if not is_set (err_flag) and nil ~= lccn:find ('%s') then
		err_flag = set_message ('err_bad_lccn');								-- lccn contains a space, set an error message
	end

	if is_set (err_flag) then
		options.coins_list_t['LCCN'] = nil;										-- when error, unset so not included in COinS
	end

	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = lccn, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; M E D R X I V &gt;-----------------------------------------------------------------

Format medRxiv ID and do simple error checking.  Similar to later bioRxiv IDs, medRxiv IDs are prefixed with a
yyyy.mm.dd. date and suffixed with an optional version identifier.  Ealiest date accepted is 2020.01.01

The medRxiv ID is a date followed by an eight-digit number followed by an optional version indicator 'v' and one or more digits:
	https://www.medrxiv.org/content/10.1101/2020.11.16.20232009v2 -&gt; 10.1101/2020.11.16.20232009v2

]]

local function medrxiv (options)
	local id = options.id;
	local handler = options.handler;
	local err_msg_flag = true;													-- flag; assume that there will be an error

	local patterns = {
		'%d%d%d%d%d%d%d%d$',													-- simple 8-digit identifier; these should be relatively rare
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%d%d%dv%d+$',			-- y.m.d. date + 8-digit identifier + version (2020-01-01 and later)
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%d%d%d$',				-- y.m.d. date + 8-digit identifier (2020-01-01 and later)
		}
	
	for _, pattern in ipairs (patterns) do										-- spin through the patterns looking for a match
		if id:match (pattern) then
			local y, m, d = id:match (pattern);									-- found a match, attempt to get year, month and date from the identifier

			if m then															-- m is nil when id is the 8-digit form
				if not is_valid_rxiv_date (y, m, d, 'b') then					-- validate the encoded date; 'b' for medrxiv limit
					break;														-- date fail; break out early so we don't unset the error message
				end
			end
			err_msg_flag = nil;													-- we found a match so unset the error message
			break;																-- and done
		end
	end																			-- &lt;err_msg_flag&gt; remains set here when no match

	if err_msg_flag then
		options.coins_list_t['MEDRXIV'] = nil;									-- when error, unset so not included in COinS
		set_message ('err_bad_medrxiv');										-- and set the error message
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator,
			encode = handler.encode, access = handler.access});
end


--[[--------------------------&lt; M R &gt;--------------------------------------------------------------------------

A seven digit number; if not seven digits, zero-fill leading digits to make seven digits.

]]

local function mr (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;
	local id_len;

	id_num = id:match ('^[Mm][Rr](%d+)$');										-- identifier with mr prefix

	if is_set (id_num) then
		set_message ('maint_mr_format');										-- add maint cat
	else																		-- plain number without mr prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	id_len = id_num and id_num:len() or 0;
	if (7 &gt;= id_len) and (0 ~= id_len) then
		id = string.rep ('0', 7-id_len) .. id_num;								-- zero-fill leading digits
	else
		set_message ('err_bad_mr');												-- set an error message
		options.coins_list_t['MR'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an OCLC ID.  https://www.oclc.org/batchload/controlnumber.en.html {{dead link}}
archived at: https://web.archive.org/web/20161228233804/https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (options)
	local id = options.id;
	local handler = options.handler;
	local number;

	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- constrain to 1 to 9 digits; change this when OCLC issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if tonumber (id) &gt; handler.id_limit then
			number = nil;														-- unset when id value exceeds the limit
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		set_message ('err_bad_oclc')											-- add an error message if the id is malformed
		options.coins_list_t['OCLC'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local ident, code = id:gsub('^OL', ''):match(&quot;^(%d+([AMW]))$&quot;);				-- strip optional OL prefix followed immediately by digits followed by 'A', 'M', or 'W';
	local err_flag;
	local prefix = {															-- these are appended to the handler.prefix according to code
		['A']='authors/OL',
		['M']='books/OL',
		['W']='works/OL',
		['X']='OL'																-- not a code; spoof when 'code' in id is invalid
		};

	if not ident then
		code = 'X';																-- no code or id completely invalid
		ident = id;																-- copy id to ident so that we display the flawed identifier
		err_flag = set_message ('err_bad_ol');
	end

	if not is_set (err_flag) then
		options.coins_list_t['OL'] = handler.prefix .. prefix[code] .. ident;	-- experiment for ol coins
	else
		options.coins_list_t['OL'] = nil;										-- when error, unset so not included in COinS
	end

	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix .. prefix[code],
		id = ident, separator = handler.separator, encode = handler.encode,
		access = access});
end


--[[--------------------------&lt; O S T I &gt;----------------------------------------------------------------------

Format OSTI and do simple error checking. OSTIs are sequential numbers beginning at 1 and counting up.  This
code checks the OSTI to see that it contains only digits and is less than test_limit specified in the configuration;
the value in test_limit will need to be updated periodically as more OSTIs are issued.

NB. 1018 is the lowest OSTI number found in the wild (so far) and resolving OK on the OSTI site

]]

local function osti (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;

	if id:match(&quot;[^%d]&quot;) then													-- if OSTI has anything but digits
		set_message ('err_bad_osti');											-- set an error message
		options.coins_list_t['OSTI'] = nil;										-- when error, unset so not included in COinS
	else																		-- OSTI is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1018 &gt; id_num or handler.id_limit &lt; id_num then						-- if OSTI is outside test limit boundaries
			set_message ('err_bad_osti');										-- set an error message
			options.coins_list_t['OSTI'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc (options)
	local id = options.id;
	local embargo = options.Embargo;											-- TODO: lowercase?
	local handler = options.handler;
	local err_flag;
	local id_num;
	local text;

	id_num = id:match ('^[Pp][Mm][Cc](%d+)$');									-- identifier with PMC prefix

	if is_set (id_num) then
		set_message ('maint_pmc_format');
	else																		-- plain number without PMC prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if PMC is outside test limit boundaries
			err_flag = set_message ('err_bad_pmc');								-- set an error message
		else
			id = tostring (id_num);												-- make sure id is a string
		end
	else																		-- when id format incorrect
		err_flag = set_message ('err_bad_pmc');									-- set an error message
	end
	
	if is_set (embargo) and is_set (is_embargoed (embargo)) then				-- is PMC is still embargoed?
		text = table.concat (													-- still embargoed so no external link
			{
			make_wikilink (link_label_make (handler), handler.label),
			handler.separator,
			id,
			});
	else
		text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,	-- no embargo date or embargo has expired, ok to link to article
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access,
			auto_link = not err_flag and 'pmc' or nil							-- do not auto-link when PMC has error
			});
	end

	if err_flag then
		options.coins_list_t['PMC'] = nil;										-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid (options)
	local id = options.id;
	local handler = options.handler;

	if id:match(&quot;[^%d]&quot;) then													-- if PMID has anything but digits
		set_message ('err_bad_pmid');											-- set an error message
		options.coins_list_t['PMID'] = nil;										-- when error, unset so not included in COinS
	else																		-- PMID is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if PMID is outside test limit boundaries
			set_message ('err_bad_pmid');										-- set an error message
			options.coins_list_t['PMID'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; R F C &gt;------------------------------------------------------------------------

Format RFC and do simple error checking. RFCs are sequential numbers beginning at 1 and counting up.  This
code checks the RFC to see that it contains only digits and is less than test_limit specified in the configuration;
the value in test_limit will need to be updated periodically as more RFCs are issued.

An index of all RFCs is here: https://tools.ietf.org/rfc/

]]

local function rfc (options)
	local id = options.id;
	local handler = options.handler;

	if id:match(&quot;[^%d]&quot;) then													-- if RFC has anything but digits
		set_message ('err_bad_rfc');											-- set an error message
		options.coins_list_t['RFC'] = nil;										-- when error, unset so not included in COinS
	else																		-- RFC is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if RFC is outside test limit boundaries
			set_message ('err_bad_rfc');										-- set an error message
			options.coins_list_t['RFC'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access});
end


--[[--------------------------&lt; S 2 C I D &gt;--------------------------------------------------------------------

Format an S2CID, do simple error checking

S2CIDs are sequential numbers beginning at 1 and counting up.  This code checks the S2CID to see that it is only
digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically
as more S2CIDs are issued.

]]

local function s2cid (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local id_num;
	local text;
	
	id_num = id:match ('^[1-9]%d*$');											-- id must be all digits; must not begin with 0; no open access flag

 	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if handler.id_limit &lt; id_num then										-- if S2CID is outside test limit boundaries
			set_message ('err_bad_s2cid');										-- set an error message
			options.coins_list_t['S2CID'] = nil;								-- when error, unset so not included in COinS
		end
	else																		-- when id format incorrect
		set_message ('err_bad_s2cid');											-- set an error message
		options.coins_list_t['S2CID'] = nil;									-- when error, unset so not included in COinS
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});

	return text;
end


--[[--------------------------&lt; S B N &gt;------------------------------------------------------------------------

9-digit form of ISBN-10; uses same check-digit validation when SBN is prefixed with an additional '0' to make 10 digits

sbn value not made part of COinS metadata because we don't have a url or isn't a COinS-defined identifier (rft.xxx)
or an identifier registered at info-uri.info (info:)

]]

local function sbn (options)
	local id = options.id;
	local ignore_invalid = options.accept;
	local handler = options.handler;
	local function return_result (check, err_type)								-- local function to handle the various returns
		local SBN = internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,
						prefix = handler.prefix, id = id, separator = handler.separator});
		if not ignore_invalid then												-- if not ignoring SBN errors
			if not check then
				options.coins_list_t['SBN'] = nil;								-- when error, unset so not included in COinS; not really necessary here because sbn not made part of COinS
				set_message ('err_bad_sbn', {err_type});						-- display an error message
				return SBN; 
			end
		else
			set_message ('maint_isbn_ignore');									-- add a maint category even when there is no error (ToDo: Possibly switch to separate message for SBNs only)
		end
		return SBN;
	end

	if id:match ('[^%s-0-9X]') then
		return return_result (false, cfg.err_msg_supl.char);					-- fail if SBN contains anything but digits, hyphens, or the uppercase X
	end

	local ident = id:gsub ('[%s-]', '');										-- remove hyphens and whitespace; they interfere with the rest of the tests

	if  9 ~= ident:len() then
		return return_result (false, cfg.err_msg_supl.length);					-- fail if incorrect length
	end

	if ident:match ('^%d*X?$') == nil then
		return return_result (false, cfg.err_msg_supl.form);					-- fail if SBN has 'X' anywhere but last position
	end

	return return_result (is_valid_isxn ('0' .. ident, 10), cfg.err_msg_supl.check);
end


--[[--------------------------&lt; S S R N &gt;----------------------------------------------------------------------

Format an SSRN, do simple error checking

SSRNs are sequential numbers beginning at 100? and counting up.  This code checks the SSRN to see that it is
only digits and is greater than 99 and less than test_limit; the value in local variable test_limit will need
to be updated periodically as more SSRNs are issued.

]]

local function ssrn (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;
	local text;
	
	id_num = id:match ('^%d+$');												-- id must be all digits

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if 100 &gt; id_num or handler.id_limit &lt; id_num then						-- if SSRN is outside test limit boundaries
			set_message ('err_bad_ssrn');										-- set an error message
			options.coins_list_t['SSRN'] = nil;									-- when error, unset so not included in COinS
		end
	else																		-- when id format incorrect
		set_message ('err_bad_ssrn');											-- set an error message
		options.coins_list_t['SSRN'] = nil;										-- when error, unset so not included in COinS
	end
	
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = options.access});

	return text;
end


--[[--------------------------&lt; U S E N E T _ I D &gt;------------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function usenet_id (options)
	local id = options.id;
	local handler = options.handler;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$') then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		set_message ('err_bad_usenet_id')										-- add an error message if the message id is invalid
		options.coins_list_t['USENETID'] = nil;									-- when error, unset so not included in COinS
	end 
	
	return text;
end


--[[--------------------------&lt; Z B L &gt;-----------------------------------------------------------------------

A numerical identifier in the form nnnn.nnnnn - leading zeros in the first quartet optional

format described here: http://emis.mi.sanu.ac.rs/ZMATH/zmath/en/help/search/

temporary format is apparently eight digits.  Anything else is an error

]]

local function zbl (options)
	local id = options.id;
	local handler = options.handler;

	if id:match('^%d%d%d%d%d%d%d%d$') then										-- is this identifier using temporary format?
		set_message ('maint_zbl');												-- yes, add maint cat
	elseif not id:match('^%d?%d?%d?%d%.%d%d%d%d%d$') then						-- not temporary, is it normal format?
		set_message ('err_bad_zbl');											-- no, set an error message
		options.coins_list_t['ZBL'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--============================&lt;&lt; I N T E R F A C E   F U N C T I O N S &gt;&gt;==========================================

--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message if more than one alias exists in args

]]

local function extract_ids (args)
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs (cfg.id_handlers) do										-- k is uppercase identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one (args, v.parameters, 'err_redundant_parameters' );		-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set (v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; E X T R A C T _ I D _ A C C E S S _ L E V E L S &gt;--------------------------------------

Fetches custom id access levels from arguments using configuration settings. Parameters which have a predefined access
level (e.g. arxiv) do not use this function as they are directly rendered as free without using an additional parameter.

returns a table of k/v pairs where k is same as the identifier's key in cfg.id_handlers and v is the assigned (valid) keyword

access-level values must match the case used in cfg.keywords_lists['id-access'] (lowercase unless there is some special reason for something else)

]]

local function extract_id_access_levels (args, id_list)
	local id_accesses_list = {};
	for k, v in pairs (cfg.id_handlers) do
		local access_param = v.custom_access;									-- name of identifier's access-level parameter
		if is_set (access_param) then
			local access_level = args[access_param];							-- get the assigned value if there is one
			if is_set (access_level) then
				if not in_array (access_level, cfg.keywords_lists['id-access']) then	-- exact match required
					set_message ('err_invalid_param_val', {access_param, access_level});	
					access_level = nil;											-- invalid so unset
				end
				if not is_set (id_list[k]) then									-- identifier access-level must have a matching identifier
					set_message ('err_param_access_requires_param', {k:lower()});	-- parameter name is uppercase in cfg.id_handlers (k); lowercase for error message
				end
				id_accesses_list[k] = cfg.keywords_xlate[access_level];			-- get translated keyword
			end
		end
	end
	return id_accesses_list;
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;----------------------------------------------------

render the identifiers into a sorted sequence table

&lt;ID_list_coins_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value
&lt;options_t&gt; is a table of various k/v option pairs provided in the call to new_build_id_list();
	modified by	this function and passed to all identifier rendering functions
&lt;access_levels_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value (if valid)

returns a sequence table of sorted (by hkey - 'handler' key) rendered identifier strings

]]

local function build_id_list (ID_list_coins_t, options_t, access_levels_t)
	local ID_list_t = {};
	local accept;
	local func_map = {															--function map points to functions associated with hkey identifier
		['ARXIV'] = arxiv,
		['ASIN'] = asin,
		['BIBCODE'] = bibcode,
		['BIORXIV'] = biorxiv,
		['CITESEERX'] = citeseerx,
		['DOI'] = doi,
		['EISSN'] = issn,
		['HDL'] = hdl,
		['ISBN'] = isbn,
		['ISMN'] = ismn,
		['ISSN'] = issn,
		['JFM'] = jfm,
		['JSTOR'] = jstor,
		['LCCN'] = lccn,
		['MEDRXIV'] = medrxiv,
		['MR'] = mr,
		['OCLC'] = oclc,
		['OL'] = openlibrary,
		['OSTI'] = osti,
		['PMC'] = pmc,
		['PMID'] = pmid,
		['RFC']  = rfc,
		['S2CID'] = s2cid,
		['SBN'] = sbn,
		['SSRN'] = ssrn,
		['USENETID'] = usenet_id,
		['ZBL'] = zbl,
		}

	for hkey, v in pairs (ID_list_coins_t) do
		v, accept = has_accept_as_written (v);									-- remove accept-as-written markup if present; accept is boolean true when markup removed; false else
																				-- every function gets the options table with value v and accept boolean
		options_t.hkey = hkey;													-- ~/Configuration handler key
		options_t.id = v;														-- add that identifier value to the options table
		options_t.accept = accept;												-- add the accept boolean flag
		options_t.access = access_levels_t[hkey];								-- add the access level for those that have an |&lt;identifier-access= parameter
		options_t.handler = cfg.id_handlers[hkey];
		options_t.coins_list_t = ID_list_coins_t;								-- pointer to ID_list_coins_t; for |asin= and |ol=; also to keep erroneous values out of the citation's metadata
		options_t.coins_list_t[hkey] = v;										-- id value without accept-as-written markup for metadata
		
		if options_t.handler.access and not in_array (options_t.handler.access, cfg.keywords_lists['id-access']) then
			error (cfg.messages['unknown_ID_access'] .. options_t.handler.access);	-- here when handler access key set to a value not listed in list of allowed id access keywords
		end

		if func_map[hkey] then
			local id_text = func_map[hkey] (options_t);							-- call the function to get identifier text and any error message
			table.insert (ID_list_t, {hkey, id_text});							-- add identifier text to the output sequence table
		else
			error (cfg.messages['unknown_ID_key'] .. hkey);						-- here when func_map doesn't have a function for hkey
		end
	end

	local function comp (a, b)													-- used by following table.sort()
		return a[1]:lower() &lt; b[1]:lower();										-- sort by hkey
	end

	table.sort (ID_list_t, comp);												-- sequence table of tables sort	
	for k, v in ipairs (ID_list_t) do											-- convert sequence table of tables to simple sequence table of strings
		ID_list_t[k] = v[2];													-- v[2] is the identifier rendering from the call to the various functions in func_map{}
	end
	
	return ID_list_t;
end


--[[--------------------------&lt; O P T I O N S _ C H E C K &gt;----------------------------------------------------

check that certain option parameters have their associated identifier parameters with values

&lt;ID_list_coins_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value
&lt;ID_support_t&gt; is a sequence table of tables created in citation0() where each subtable has four elements:
	[1] is the support parameter's assigned value; empty string if not set
	[2] is a text string same as key in cfg.id_handlers
	[3] is cfg.error_conditions key used to create error message
	[4] is original ID support parameter name used to create error message
	
returns nothing; on error emits an appropriate error message

]]

local function options_check (ID_list_coins_t, ID_support_t)
	for _, v in ipairs (ID_support_t) do
		if is_set (v[1]) and not ID_list_coins_t[v[2]] then						-- when support parameter has a value but matching identifier parameter is missing or empty
			set_message (v[3], (v[4]));											-- emit the appropriate error message
		end
	end
end


--[[--------------------------&lt; I D E N T I F I E R _ L I S T S _ G E T &gt;--------------------------------------

Creates two identifier lists: a k/v table of identifiers and their values to be used locally and for use in the
COinS metadata, and a sequence table of the rendered identifier strings that will be included in the rendered
citation.

]]

local function identifier_lists_get (args_t, options_t, ID_support_t)
	local ID_list_coins_t = extract_ids (args_t);										-- get a table of identifiers and their values for use locally and for use in COinS
	options_check (ID_list_coins_t, ID_support_t);										-- ID support parameters must have matching identifier parameters 
	local ID_access_levels_t = extract_id_access_levels (args_t, ID_list_coins_t);		-- get a table of identifier access levels
	local ID_list_t = build_id_list (ID_list_coins_t, options_t, ID_access_levels_t);	-- get a sequence table of rendered identifier strings

	return ID_list_t, ID_list_coins_t;											-- return the tables
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	has_accept_as_written = utilities_page_ptr.has_accept_as_written;			-- import functions from select Module:Citation/CS1/Utilities module
	is_set = utilities_page_ptr.is_set;								
	in_array = utilities_page_ptr.in_array;
	set_message = utilities_page_ptr.set_message;
	select_one = utilities_page_ptr.select_one;
	substitute = utilities_page_ptr.substitute;
	make_wikilink = utilities_page_ptr.make_wikilink;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	auto_link_urls = auto_link_urls,											-- table of identifier URLs to be used when auto-linking |title=
	
	identifier_lists_get = identifier_lists_get,								-- experiment to replace individual calls to build_id_list(), extract_ids, extract_id_access_levels
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>6uzqpmnr4f7kbilmaopc20fiwrqbywt</sha1>
    </revision>
    <revision>
      <id>4926</id>
      <parentid>4925</parentid>
      <timestamp>2024-08-17T18:39:06Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4926</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="77389" sha1="i48i671rh4l6b7va3t85jkbdo8952fk" xml:space="preserve">--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local has_accept_as_written, is_set, in_array, set_message, select_one,			-- functions in Module:Citation/CS1/Utilities
		substitute, make_wikilink;

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

declare variables here that have page-wide scope that are not brought in from other modules; that are created here and used here

]]

local auto_link_urls = {};														-- holds identifier URLs for those identifiers that can auto-link |title=


--============================&lt;&lt; H E L P E R   F U N C T I O N S &gt;&gt;============================================

--[[--------------------------&lt; W I K I D A T A _ A R T I C L E _ N A M E _ G E T &gt;----------------------------

as an aid to internationalizing identifier-label wikilinks, gets identifier article names from Wikidata.

returns :&lt;lang code&gt;:&lt;article title&gt; when &lt;q&gt; has an &lt;article title&gt; for &lt;lang code&gt;; nil else

for identifiers that do not have q, returns nil

for wikis that do not have mw.wikibase installed, returns nil

]]

local function wikidata_article_name_get (q)
	if not is_set (q) or (q and not mw.wikibase) then							-- when no q number or when a q number but mw.wikibase not installed on this wiki
		return nil;																-- abandon
	end

	local wd_article;
	local this_wiki_code = cfg.this_wiki_code;									-- Wikipedia subdomain; 'en' for en.wikipedia.org

	wd_article = mw.wikibase.getSitelink (q, this_wiki_code .. 'wiki');			-- fetch article title from WD; nil when no title available at this wiki

	if wd_article then
		wd_article = table.concat ({':', this_wiki_code, ':', wd_article});		-- interwiki-style link without brackets if taken from WD; leading colon required
	end

	return wd_article;															-- article title from WD; nil else
end


--[[--------------------------&lt; L I N K _ L A B E L _ M A K E &gt;------------------------------------------------

common function to create identifier link label from handler table or from Wikidata

returns the first available of
	1. redirect from local wiki's handler table (if enabled)
	2. Wikidata (if there is a Wikidata entry for this identifier in the local wiki's language)
	3. label specified in the local wiki's handler table
	
]]

local function link_label_make (handler)
	local wd_article;
	
	if not (cfg.use_identifier_redirects and is_set (handler.redirect)) then	-- redirect has priority so if enabled and available don't fetch from Wikidata because expensive
		wd_article = wikidata_article_name_get (handler.q);						-- if Wikidata has an article title for this wiki, get it;
	end
	
	return (cfg.use_identifier_redirects and is_set (handler.redirect) and handler.redirect) or wd_article or handler.link;
end


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki-style external link

]]

local function external_link_id (options)
	local url_string = options.id;
	local ext_link;
	local this_wiki_code = cfg.this_wiki_code;									-- Wikipedia subdomain; 'en' for en.wikipedia.org
	local wd_article;															-- article title from Wikidata
	
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode (url_string, 'PATH');
	end

	if options.auto_link and is_set (options.access) then
		auto_link_urls[options.auto_link] = table.concat ({options.prefix, url_string, options.suffix});
	end

	ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or &quot;&quot;, mw.text.nowiki (options.id));
	if is_set (options.access) then
		ext_link = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[options.access].class, cfg.presentation[options.access].title, ext_link});	-- add the free-to-read / paywall lock
	end

	return table.concat	({
		make_wikilink (link_label_make (options), options.label),				-- redirect, Wikidata link, or locally specified link (in that order)
		options.separator or '&amp;nbsp;',
		ext_link
		});
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki-style internal link

TODO: Does not currently need to support options.access, options.encode, auto-linking and COinS (as in external_link_id),
but may be needed in the future for :m:Interwiki_map custom-prefixes like :arxiv:, :bibcode:, :DOI:, :hdl:, :ISSN:,
:JSTOR:, :Openlibrary:, :PMID:, :RFC:.

]]

local function internal_link_id (options)
	local id = mw.ustring.gsub (options.id, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9

	return table.concat (
		{
		make_wikilink (link_label_make (options), options.label),				-- wiki-link the identifier label
		options.separator or '&amp;nbsp;',											-- add the separator
		make_wikilink (
			table.concat (
				{
				options.prefix,
				id,																-- translated to Western digits
				options.suffix or ''
				}),
			substitute (cfg.presentation['bdi'], {'', mw.text.nowiki (options.id)})	-- bdi tags to prevent Latin script identifiers from being reversed at RTL language wikis
			);																	-- nowiki because MediaWiki still has magic links for ISBN and the like; TODO: is it really required?
		});
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |pmc-embargo-date= against
today's date.  If embargo date is in the future, returns the content of |pmc-embargo-date=; otherwise, returns
an empty string because the embargo has expired or because |pmc-embargo-date= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, todays_date;
		good1, embargo_date = pcall (lang.formatDate, lang, 'U', embargo);
		todays_date = lang:formatDate ('U');
	
		if good1 then															-- if embargo date is a good date
			if tonumber (embargo_date) &gt;= tonumber (todays_date) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				set_message ('maint_pmc_embargo');								-- embargo has expired; add main cat
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |pmc-embargo-date= not set return empty string
end


--[=[-------------------------&lt; I S _ V A L I D _ R X I V _ D A T E &gt;------------------------------------------

for biorxiv, returns true if:
	2019-12-11T00:00Z &lt;= biorxiv_date &lt; today + 2 days
for medrxiv, returns true if:
	2020-01-01T00:00Z &lt;= medrxiv_date &lt; today + 2 days
	
The dated form of biorxiv identifier has a start date of 2019-12-11.  The Unix timestamp for that date is {{#time:U|2019-12-11}} = 1576022400
The medrxiv identifier has a start date of 2020-01-01.  The Unix timestamp for that date is {{#time:U|2020-01-01}} = 1577836800

&lt;rxiv_date&gt; is the date provided in those |biorxiv= parameter values that are dated and in |medrxiv= parameter values at time 00:00:00 UTC
&lt;today&gt; is the current date at time 00:00:00 UTC plus 48 hours
	if today's date is 2023-01-01T00:00:00 then
		adding 24 hours gives 2023-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2023-01-03T00:00:00 – one second more than tomorrow

inputs:
	&lt;y&gt;, &lt;m&gt;, &lt;d&gt; – year, month, day parts of the date from the birxiv or medrxiv identifier
	&lt;select&gt; 'b' for biorxiv, 'm' for medrxiv; defaults to 'b'

]=]

local function is_valid_rxiv_date (y, m, d, select)
	if 0 == tonumber (m) and 12 &lt; tonumber (m) then								-- &lt;m&gt; must be a number 1–12
		return false;
	end
	if 0 == tonumber (d) and 31 &lt; tonumber (d) then								-- &lt;d&gt; must be a number 1–31; TODO: account for month length and leap yer?
		return false;
	end
	
	local rxiv_date = table.concat ({y, m, d}, '-');							-- make ymd date string
	local good1, good2;
	local rxiv_ts, tomorrow_ts;													-- to hold Unix timestamps representing the dates
	local lang_object = mw.getContentLanguage();

	good1, rxiv_ts = pcall (lang_object.formatDate, lang_object, 'U', rxiv_date);		-- convert rxiv_date value to Unix timestamp 
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which tonumber() may not understand
		rxiv_ts = tonumber (rxiv_ts) or lang_object:parseFormattedNumber (rxiv_ts);	-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to Unix timestamp
	end

	local limit_ts = ((select and ('m' == select)) and 1577836800) or 1576022400;	-- choose the appropriate limit timesatmp

	return ((limit_ts &lt;= rxiv_ts) and (rxiv_ts &lt; tomorrow_ts))					-- limit_ts &lt;= rxiv_date &lt; tomorrow's date
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all ISBN/ISSN digits including the check digit.
ISBN-13 is checked in isbn().

If the number is valid the result will be 0. Before calling this function, ISBN/ISSN must be checked for length
and stripped of dashes, spaces and other non-ISxN characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39, 'X' → 0x58
	len = len + 1;																-- adjust to be a loop counter
	for i, v in ipairs (isxn_str) do											-- loop through all of the bytes and calculate the checksum
		if v == string.byte (&quot;X&quot; ) then											-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10 * (len - i);										-- it represents 10 decimal
		else
			temp = temp + tonumber (string.char (v) )*(len-i);
		end
	end
	return temp % 11 == 0;														-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N _ 1 3 &gt;-----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 ISBN/ISMN digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, ISBN-13/ISMN must be checked for length
and stripped of dashes, spaces and other non-ISxN-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39
	for i, v in ipairs (isxn_str) do
		temp = temp + (3 - 2*(i % 2)) * tonumber (string.char (v) );			-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when ISBN-13/ISMN is correct
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

LCCN normalization (https://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized LCCN for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.

]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);												-- 1. strip whitespace

	if nil ~= string.find (lccn, '/') then
		lccn = lccn:match (&quot;(.-)/&quot;);											-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);									-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then														-- if there was a hyphen
		suffix = string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;				-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn = prefix..suffix;													-- reassemble the LCCN
	end
	
	return lccn;
	end


--============================&lt;&lt; I D E N T I F I E R   F U N C T I O N S &gt;&gt;====================================

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: https://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9107 and 0703, is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation; not the same as |class= parameter which is not supported in this form
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number

]]

local function arxiv (options)
	local id = options.id;
	local class = options.Class;												-- TODO: lowercase?
	local handler = options.handler;
	local year, month, version;
	local err_msg = false;														-- assume no error message
	local text;																	-- output text
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9107-0703 format with or without version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_msg = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 with or without version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then									-- when year is 07, is month invalid (before April)?
				err_msg = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format with or without version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_msg = true;														-- flag for error message
		end

	else
		err_msg = true;															-- not a recognized format; flag for error message
	end

	if err_msg then
		options.coins_list_t['ARXIV'] = nil;									-- when error, unset so not included in COinS
	end
	
	local err_msg_t = {};
	if err_msg then
		set_message ('err_bad_arxiv');
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access});

	if is_set (class) then
		if id:match ('^%d+') then
			text = table.concat ({text, ' [[https://arxiv.org/archive/', class, ' ', class, ']]'});	-- external link within square brackets, not wikilink
		else
			set_message ('err_class_ignored');
		end
	end

	return text;
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode ID.

Format for bibcodes is specified here: https://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		9–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local ignore_invalid = options.accept;
	local err_type;
	local err_msg = '';
	local year;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode,
		access = access});
	
	if 19 ~= id:len() then
		err_type = cfg.err_msg_supl.length;
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%w&amp;%.][%w&amp;%.][%w&amp;%.][%w.]+[%a%.]$&quot;);
		if not year then														-- if nil then no pattern match
			err_type = cfg.err_msg_supl.value;									-- so value error
		else
			local next_year = tonumber (os.date ('%Y')) + 1;					-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = cfg.err_msg_supl.year;								-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = cfg.err_msg_supl.journal;							-- journal abbreviation must not have '&amp;.' (if it does it's missing a letter)
			end
			if id:match ('.........%.tmp%.') then								-- temporary bibcodes when positions 10–14 are '.tmp.'
				set_message ('maint_bibcode');
			end
		end
	end

	if is_set (err_type) and not ignore_invalid then							-- if there was an error detected and accept-as-written markup not used
		set_message ('err_bad_bibcode', {err_type});
		options.coins_list_t['BIBCODE'] = nil;									-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; B I O R X I V &gt;-----------------------------------------------------------------

Format bioRxiv ID and do simple error checking.  Before 2019-12-11, biorXiv IDs were 10.1101/ followed by exactly
6 digits.  After 2019-12-11, biorXiv IDs retained the six-digit identifier but prefixed that with a yyyy.mm.dd. 
date and suffixed with an optional version identifier.

The bioRxiv ID is the string of characters:
	https://doi.org/10.1101/078733 -&gt; 10.1101/078733
or a date followed by a six-digit number followed by an optional version indicator 'v' and one or more digits:
	https://www.biorxiv.org/content/10.1101/2019.12.11.123456v2 -&gt; 10.1101/2019.12.11.123456v2
	
see https://www.biorxiv.org/about-biorxiv

]]

local function biorxiv (options)
	local id = options.id;
	local handler = options.handler;
	local err_msg = true;														-- flag; assume that there will be an error
	
	local patterns = {
		'^10%.1101/%d%d%d%d%d%d$',												-- simple 6-digit identifier (before 2019-12-11)
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%dv%d+$',				-- y.m.d. date + 6-digit identifier + version (after 2019-12-11)
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%d$',					-- y.m.d. date + 6-digit identifier (after 2019-12-11)
		}
	
	for _, pattern in ipairs (patterns) do										-- spin through the patterns looking for a match
		if id:match (pattern) then
			local y, m, d = id:match (pattern);									-- found a match, attempt to get year, month and date from the identifier

			if m then															-- m is nil when id is the six-digit form
				if not is_valid_rxiv_date (y, m, d, 'b') then					-- validate the encoded date; 'b' for biorxiv limit
					break;														-- date fail; break out early so we don't unset the error message
				end
			end
			err_msg = nil;														-- we found a match so unset the error message
			break;																-- and done
		end
	end																			-- err_cat remains set here when no match

	if err_msg then
		options.coins_list_t['BIORXIV'] = nil;									-- when error, unset so not included in COinS
		set_message ('err_bad_biorxiv');										-- and set the error message
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator,
			encode = handler.encode, access = handler.access});
end


--[[--------------------------&lt; C I T E S E E R X &gt;------------------------------------------------------------

CiteSeerX use their own notion of &quot;doi&quot; (not to be confused with the identifiers resolved via doi.org).

The description of the structure of this identifier can be found at Help_talk:Citation_Style_1/Archive_26#CiteSeerX_id_structure

]]

local function citeseerx (options)
	local id = options.id;
	local handler = options.handler;
	local matched;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode,
		access = handler.access});
	
	matched = id:match (&quot;^10%.1%.1%.[1-9]%d?%d?%d?%.[1-9]%d?%d?%d?$&quot;);
	if not matched then
		set_message ('err_bad_citeseerx' );
		options.coins_list_t['CITESEERX'] = nil;								-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the DOI name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in DOI names.

https://www.doi.org/doi_handbook/2_Numbering.html				-- 2.2 Syntax of a DOI name
https://www.doi.org/doi_handbook/2_Numbering.html#2.2.2			-- 2.2.2 DOI prefix

]]

local function doi (options)
	local id = options.id;
	local inactive = options.DoiBroken
	local access = options.access;
	local ignore_invalid = options.accept;
	local handler = options.handler;
	local err_flag;

	local function is_extended_free (registrant, id)							-- local function to check those few registrants that are mixed; identifiable by the doi suffix &lt;incipit&gt;
		if cfg.extended_registrants_t[registrant] then							-- if this registrant has known free-to-read extentions
			for _, incipit in ipairs (cfg.extended_registrants_t[registrant]) do	-- loop through the registrant's incipits
				if string.find (id, incipit, 1, true) then						-- if found
					return true;
				end
			end
		end
	end

	local text;
	if is_set (inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;);						-- try to get the year portion from the inactive date
		local inactive_month, good;

		if is_set (inactive_year) then
			if 4 &lt; inactive:len() then											-- inactive date has more than just a year (could be anything)
				local lang_obj = mw.getContentLanguage();						-- get a language object for this wiki
				good, inactive_month = pcall (lang_obj.formatDate, lang_obj, 'F', inactive);	-- try to get the month name from the inactive date
				if not good then
					inactive_month = nil;										-- something went wrong so make sure this is unset
				end
			end
		end																		-- otherwise, |doi-broken-date= has something but it isn't a date
		
		if is_set (inactive_year) and is_set (inactive_month) then
			set_message ('maint_doi_inactive_dated', {inactive_year, inactive_month, ' '});
		elseif is_set (inactive_year) then
			set_message ('maint_doi_inactive_dated', {inactive_year, '', ''});
		else
			set_message ('maint_doi_inactive');
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. ' ' .. inactive .. ')';
	end

	local registrant = mw.ustring.match (id, '^10%.([^/]+)/[^%s–]-[^%.,]$');	-- registrant set when DOI has the proper basic form

	local registrant_err_patterns = {											-- these patterns are for code ranges that are not supported 
		'^[^1-3]%d%d%d%d%.%d+$',												-- 5 digits with subcode (0xxxx, 40000+); accepts: 10000–39999
		'^[^1-6]%d%d%d%d$',														-- 5 digits without subcode (0xxxx, 60000+); accepts: 10000–69999
		'^[^1-9]%d%d%d%.%d+$',												-- 4 digits with subcode (0xxx); accepts: 1000–9999
		'^[^1-9]%d%d%d$',														-- 4 digits without subcode (0xxx); accepts: 1000–9999
		'^%d%d%d%d%d%d+',														-- 6 or more digits
		'^%d%d?%d?$',															-- less than 4 digits without subcode (3 digits with subcode is legitimate)
		'^%d%d?%.[%d%.]+',														-- 1 or 2 digits with subcode
		'^5555$',																-- test registrant will never resolve
		'[^%d%.]',																-- any character that isn't a digit or a dot
		}

	if not ignore_invalid then
		if registrant then														-- when DOI has proper form
			for i, pattern in ipairs (registrant_err_patterns) do				-- spin through error patterns
				if registrant:match (pattern) then								-- to validate registrant codes
					err_flag = set_message ('err_bad_doi');						-- when found, mark this DOI as bad
					break;														-- and done
				end
			end
		else
			err_flag = set_message ('err_bad_doi');								-- invalid directory or malformed
		end
	else
		set_message ('maint_doi_ignore');
	end

	if err_flag then
		options.coins_list_t['DOI'] = nil;										-- when error, unset so not included in COinS
	else
		if not access and (cfg.known_free_doi_registrants_t[registrant] or is_extended_free (registrant, id)) then		-- |doi-access=free not set and &lt;registrant&gt; is known to be free
			set_message ('maint_doi_unflagged_free');							-- set a maint cat
		end
	end
	
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access,
		auto_link = not (err_flag or is_set (inactive) or ignore_invalid) and 'doi' or nil -- do not auto-link when |doi-broken-date= has a value or when there is a DOI error or (to play it safe, after all, auto-linking is not essential) when invalid DOIs are ignored
		}) .. (inactive or '');

	return text;
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

Query string parameters are named here: https://www.handle.net/proxy_servlet.html.  query strings are not displayed
but since '?' is an allowed character in an HDL, '?' followed by one of the query parameters is the only way we
have to detect the query string so that it isn't URL-encoded with the rest of the identifier.

]]

local function hdl (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local query_params = {														-- list of known query parameters from https://www.handle.net/proxy_servlet.html
		'noredirect',
		'ignore_aliases',
		'auth',
		'cert',
		'index',
		'type',
		'urlappend',
		'locatt',
		'action',
		}
	
	local hdl, suffix, param = id:match ('(.-)(%?(%a+).+)$');					-- look for query string
	local found;

	if hdl then																	-- when there are query strings, this is the handle identifier portion
		for _, q in ipairs (query_params) do									-- spin through the list of query parameters
			if param:match ('^' .. q) then										-- if the query string begins with one of the parameters
				found = true;													-- announce a find
				break;															-- and stop looking
			end
		end
	end

	if found then
		id = hdl;																-- found so replace id with the handle portion; this will be URL-encoded, suffix will not
	else
		suffix = '';															-- make sure suffix is empty string for concatenation else
	end

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, suffix = suffix, separator = handler.separator, encode = handler.encode, access = access})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- HDL must contain a forward slash, must not contain spaces, endashes, and must not end with period or comma
		set_message ('err_bad_hdl' );
		options.coins_list_t['HDL'] = nil;										-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; I S B N &gt;----------------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function isbn (options)
	local isbn_str = options.id;
	local ignore_invalid = options.accept;
	local handler = options.handler;

	local function return_result (check, err_type)								-- local function to handle the various returns
		local ISBN = internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,
						prefix = handler.prefix, id = isbn_str, separator = handler.separator});
		if ignore_invalid then													-- if ignoring ISBN errors
			set_message ('maint_isbn_ignore');									-- add a maint category even when there is no error
		else																	-- here when not ignoring
			if not check then													-- and there is an error
				options.coins_list_t['ISBN'] = nil;								-- when error, unset so not included in COinS
				set_message ('err_bad_isbn', err_type);							-- set an error message
				return ISBN;										 			-- return id text
			end
		end
		return ISBN;															-- return id text
	end

	if nil ~= isbn_str:match ('[^%s-0-9X]') then
		return return_result (false, cfg.err_msg_supl.char);					-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end

	local id = isbn_str:gsub ('[%s-]', '');										-- remove hyphens and whitespace

	local len = id:len();
 
	if len ~= 10 and len ~= 13 then
		return return_result (false, cfg.err_msg_supl.length);					-- fail if incorrect length
	end

	if len == 10 then
		if id:match ('^%d*X?$') == nil then										-- fail if isbn_str has 'X' anywhere but last position
			return return_result (false, cfg.err_msg_supl.form);									
		end
		if not is_valid_isxn (id, 10) then										-- test isbn-10 for numerical validity
			return return_result (false, cfg.err_msg_supl.check);				-- fail if isbn-10 is not numerically valid
		end
		if id:find ('^63[01]') then												-- 630xxxxxxx and 631xxxxxxx are (apparently) not valid isbn group ids but are used by amazon as numeric identifiers (asin)
			return return_result (false, cfg.err_msg_supl.group);				-- fail if isbn-10 begins with 630/1
		end
		return return_result (true, cfg.err_msg_supl.check);					-- pass if isbn-10 is numerically valid
	else
		if id:match ('^%d+$') == nil then
			return return_result (false, cfg.err_msg_supl.char);				-- fail if ISBN-13 is not all digits
		end
		if id:match ('^97[89]%d*$') == nil then
			return return_result (false, cfg.err_msg_supl.prefix);				-- fail when ISBN-13 does not begin with 978 or 979
		end
		if id:match ('^9790') then
			return return_result (false, cfg.err_msg_supl.group);				-- group identifier '0' is reserved to ISMN
		end
		return return_result (is_valid_isxn_13 (id), cfg.err_msg_supl.check);
	end
end


--[[--------------------------&lt; A S I N &gt;----------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: ASIN must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, ASINs must be 10-digit
ISBN. If 10-digit ISBN, add a maintenance category so a bot or AWB script can replace |asin= with |isbn=.
Error message if not 10 characters, if not ISBN-10, if mixed and first character is a digit.

|asin=630....... and |asin=631....... are (apparently) not a legitimate ISBN though it checksums as one; these
do not cause this function to emit the maint_asin message

This function is positioned here because it calls isbn()

]]

local function asin (options)
	local id = options.id;
	local domain = options.ASINTLD;
	
	local err_flag;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_flag = set_message ('err_bad_asin');								-- ASIN is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then							-- if 10-digit numeric (or 9 digits with terminal X)
			if is_valid_isxn (id, 10) then										-- see if ASIN value is or validates as ISBN-10
				if not id:find ('^63[01]') then									-- 630xxxxxxx and 631xxxxxxx are (apparently) not a valid isbn prefixes but are used by amazon as a numeric identifier
					err_flag = set_message ('err_bad_asin');					-- ASIN has ISBN-10 form but begins with something other than 630/1 so probably an isbn 
				end
			elseif not is_set (err_flag) then
				err_flag = set_message ('err_bad_asin');						-- ASIN is not ISBN-10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_flag = set_message ('err_bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if (not is_set (domain)) or in_array (domain, {'us'}) then					-- default: United States
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then									-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'z.cn'}) then 									-- China
		domain = &quot;cn&quot;;
	elseif in_array (domain, {'au', 'br', 'mx', 'sg', 'tr'}) then				-- Australia, Brazil, Mexico, Singapore, Turkey
		domain = &quot;com.&quot; .. domain;
	elseif not in_array (domain, {'ae', 'ca', 'cn', 'de', 'es', 'fr', 'in', 'it', 'nl', 'pl', 'sa', 'se', 'co.jp', 'co.uk', 'com', 'com.au', 'com.br', 'com.mx', 'com.sg', 'com.tr'}) then -- Arabic Emirates, Canada, China, Germany, Spain, France, Indonesia, Italy, Netherlands, Poland, Saudi Arabia, Sweden (as of 2021-03 Austria (.at), Liechtenstein (.li) and Switzerland (.ch) still redirect to the German site (.de) with special settings, so don't maintain local ASINs for them)
		err_flag = set_message ('err_bad_asin_tld');							-- unsupported asin-tld value
	end
	local handler = options.handler;

	if not is_set (err_flag) then
		options.coins_list_t['ASIN'] = handler.prefix .. domain .. &quot;/dp/&quot; .. id;	-- asin for coins
	else
		options.coins_list_t['ASIN'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix .. domain .. &quot;/dp/&quot;,
		id = id, encode = handler.encode, separator = handler.separator})
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to ISBN-13, ISMN is 13 digits beginning 979-0-... and uses the
same check digit calculations.  See https://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

ismn value not made part of COinS metadata because we don't have a url or isn't a COinS-defined identifier (rft.xxx)
or an identifier registered at info-uri.info (info:)

]]

local function ismn (options)
	local id = options.id;
	local handler = options.handler;
	local text;
	local valid_ismn = true;
	local id_copy;

	id_copy = id;																-- save a copy because this testing is destructive
	id = id:gsub ('[%s-]', '');													-- remove hyphens and white space

	if 13 ~= id:len() or id:match (&quot;^9790%d*$&quot; ) == nil then					-- ISMN must be 13 digits and begin with 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ISMN
	end

	--	text = internal_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,		-- use this (or external version) when there is some place to link to
	--		prefix = handler.prefix, id = id_copy, separator = handler.separator, encode = handler.encode})

	text = table.concat (														-- because no place to link to yet
		{
		make_wikilink (link_label_make (handler), handler.label),
		handler.separator,
		id_copy
		});

	if false == valid_ismn then
		options.coins_list_t['ISMN'] = nil;										-- when error, unset so not included in COinS; not really necessary here because ismn not made part of COinS
		set_message ('err_bad_ismn');											-- create an error message if the ISMN is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an ISSN.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [https://www.worldcat.org/issn/0819 4327 0819 4327]	-- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the ISSN midpoint.  It also validates the ISSN for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check ISSN error message.  The
ISSN is always displayed with a hyphen, even if the ISSN was given as a single group of 8 digits.

]]

local function issn (options)
	local id = options.id;
	local handler = options.handler;
	local ignore_invalid = options.accept;

	local issn_copy = id;														-- save a copy of unadulterated ISSN; use this version for display if ISSN does not validate
	local text;
	local valid_issn = true;

	id = id:gsub ('[%s-]', '');													-- remove hyphens and whitespace

	if 8 ~= id:len() or nil == id:match (&quot;^%d*X?$&quot; ) then						-- validate the ISSN: 8 digits long, containing only 0-9 or X in the last position
		valid_issn = false;														-- wrong length or improper character
	else
		valid_issn = is_valid_isxn (id, 8);										-- validate ISSN
	end

	if true == valid_issn then
		id = string.sub (id, 1, 4 ) .. &quot;-&quot; .. string.sub (id, 5 );				-- if valid, display correctly formatted version
	else
		id = issn_copy;															-- if not valid, show the invalid ISSN with error message
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode})

	if ignore_invalid then
		set_message ('maint_issn_ignore');
	else
		if false == valid_issn then
			options.coins_list_t['ISSN'] = nil;									-- when error, unset so not included in COinS
			set_message ('err_bad_issn', (options.hkey == 'EISSN') and 'e' or '');	-- create an error message if the ISSN is invalid
		end 
	end
	
	return text;
end


--[[--------------------------&lt; J F M &gt;-----------------------------------------------------------------------

A numerical identifier in the form nn.nnnn.nn

]]

local function jfm (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;

	id_num = id:match ('^[Jj][Ff][Mm](.*)$');									-- identifier with jfm prefix; extract identifier

	if is_set (id_num) then
		set_message ('maint_jfm_format');
	else																		-- plain number without JFM prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num and id_num:match('^%d%d%.%d%d%d%d%.%d%d$') then
		id = id_num;															-- jfm matches pattern
	else
		set_message ('err_bad_jfm' );											-- set an error message
		options.coins_list_t['JFM'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; J S T O R &gt;--------------------------------------------------------------------

Format a JSTOR with some error checking

]]

local function jstor (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;

	if id:find ('[Jj][Ss][Tt][Oo][Rr]') or id:find ('^https?://') or id:find ('%s') then
		set_message ('err_bad_jstor');											-- set an error message
		options.coins_list_t['JSTOR'] = nil;									-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});
end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
https://oclc-research.github.io/infoURI-Frozen/info-uri.info/info:lccn/reg.html

length = 8 then all digits
length = 9 then lccn[1] is lowercase alpha
length = 10 then lccn[1] and lccn[2] are both lowercase alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lowercase alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lowercase alpha

]]

local function lccn (options)
	local lccn = options.id;
	local handler = options.handler;
	local err_flag;																-- presume that LCCN is valid
	local id = lccn;															-- local copy of the LCCN

	id = normalize_lccn (id);													-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();														-- get the length of the LCCN

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits)
			err_flag = set_message ('err_bad_lccn');							-- set an error message
		end
	elseif 9 == len then														-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then							-- does it match our pattern?
			err_flag = set_message ('err_bad_lccn');							-- set an error message
		end
	elseif 10 == len then														-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then					-- ... see if it matches our pattern
				err_flag = set_message ('err_bad_lccn');						-- no match, set an error message
			end
		end
	elseif 11 == len then														-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_flag = set_message ('err_bad_lccn');							-- no match, set an error message
		end
	elseif 12 == len then														-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then						-- see if it matches our pattern
			err_flag = set_message ('err_bad_lccn');							-- no match, set an error message
		end
	else
		err_flag = set_message ('err_bad_lccn');								-- wrong length, set an error message
	end

	if not is_set (err_flag) and nil ~= lccn:find ('%s') then
		err_flag = set_message ('err_bad_lccn');								-- lccn contains a space, set an error message
	end

	if is_set (err_flag) then
		options.coins_list_t['LCCN'] = nil;										-- when error, unset so not included in COinS
	end

	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = lccn, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; M E D R X I V &gt;-----------------------------------------------------------------

Format medRxiv ID and do simple error checking.  Similar to later bioRxiv IDs, medRxiv IDs are prefixed with a
yyyy.mm.dd. date and suffixed with an optional version identifier.  Ealiest date accepted is 2020.01.01

The medRxiv ID is a date followed by an eight-digit number followed by an optional version indicator 'v' and one or more digits:
	https://www.medrxiv.org/content/10.1101/2020.11.16.20232009v2 -&gt; 10.1101/2020.11.16.20232009v2

]]

local function medrxiv (options)
	local id = options.id;
	local handler = options.handler;
	local err_msg_flag = true;													-- flag; assume that there will be an error

	local patterns = {
		'%d%d%d%d%d%d%d%d$',													-- simple 8-digit identifier; these should be relatively rare
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%d%d%dv%d+$',			-- y.m.d. date + 8-digit identifier + version (2020-01-01 and later)
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%d%d%d$',				-- y.m.d. date + 8-digit identifier (2020-01-01 and later)
		}
	
	for _, pattern in ipairs (patterns) do										-- spin through the patterns looking for a match
		if id:match (pattern) then
			local y, m, d = id:match (pattern);									-- found a match, attempt to get year, month and date from the identifier

			if m then															-- m is nil when id is the 8-digit form
				if not is_valid_rxiv_date (y, m, d, 'b') then					-- validate the encoded date; 'b' for medrxiv limit
					break;														-- date fail; break out early so we don't unset the error message
				end
			end
			err_msg_flag = nil;													-- we found a match so unset the error message
			break;																-- and done
		end
	end																			-- &lt;err_msg_flag&gt; remains set here when no match

	if err_msg_flag then
		options.coins_list_t['MEDRXIV'] = nil;									-- when error, unset so not included in COinS
		set_message ('err_bad_medrxiv');										-- and set the error message
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator,
			encode = handler.encode, access = handler.access});
end


--[[--------------------------&lt; M R &gt;--------------------------------------------------------------------------

A seven digit number; if not seven digits, zero-fill leading digits to make seven digits.

]]

local function mr (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;
	local id_len;

	id_num = id:match ('^[Mm][Rr](%d+)$');										-- identifier with mr prefix

	if is_set (id_num) then
		set_message ('maint_mr_format');										-- add maint cat
	else																		-- plain number without mr prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	id_len = id_num and id_num:len() or 0;
	if (7 &gt;= id_len) and (0 ~= id_len) then
		id = string.rep ('0', 7-id_len) .. id_num;								-- zero-fill leading digits
	else
		set_message ('err_bad_mr');												-- set an error message
		options.coins_list_t['MR'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an OCLC ID.  https://www.oclc.org/batchload/controlnumber.en.html {{dead link}}
archived at: https://web.archive.org/web/20161228233804/https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (options)
	local id = options.id;
	local handler = options.handler;
	local number;

	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- constrain to 1 to 9 digits; change this when OCLC issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if tonumber (id) &gt; handler.id_limit then
			number = nil;														-- unset when id value exceeds the limit
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		set_message ('err_bad_oclc')											-- add an error message if the id is malformed
		options.coins_list_t['OCLC'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local ident, code = id:gsub('^OL', ''):match(&quot;^(%d+([AMW]))$&quot;);				-- strip optional OL prefix followed immediately by digits followed by 'A', 'M', or 'W';
	local err_flag;
	local prefix = {															-- these are appended to the handler.prefix according to code
		['A']='authors/OL',
		['M']='books/OL',
		['W']='works/OL',
		['X']='OL'																-- not a code; spoof when 'code' in id is invalid
		};

	if not ident then
		code = 'X';																-- no code or id completely invalid
		ident = id;																-- copy id to ident so that we display the flawed identifier
		err_flag = set_message ('err_bad_ol');
	end

	if not is_set (err_flag) then
		options.coins_list_t['OL'] = handler.prefix .. prefix[code] .. ident;	-- experiment for ol coins
	else
		options.coins_list_t['OL'] = nil;										-- when error, unset so not included in COinS
	end

	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix .. prefix[code],
		id = ident, separator = handler.separator, encode = handler.encode,
		access = access});
end


--[[--------------------------&lt; O S T I &gt;----------------------------------------------------------------------

Format OSTI and do simple error checking. OSTIs are sequential numbers beginning at 1 and counting up.  This
code checks the OSTI to see that it contains only digits and is less than test_limit specified in the configuration;
the value in test_limit will need to be updated periodically as more OSTIs are issued.

NB. 1018 is the lowest OSTI number found in the wild (so far) and resolving OK on the OSTI site

]]

local function osti (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;

	if id:match(&quot;[^%d]&quot;) then													-- if OSTI has anything but digits
		set_message ('err_bad_osti');											-- set an error message
		options.coins_list_t['OSTI'] = nil;										-- when error, unset so not included in COinS
	else																		-- OSTI is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1018 &gt; id_num or handler.id_limit &lt; id_num then						-- if OSTI is outside test limit boundaries
			set_message ('err_bad_osti');										-- set an error message
			options.coins_list_t['OSTI'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc (options)
	local id = options.id;
	local embargo = options.Embargo;											-- TODO: lowercase?
	local handler = options.handler;
	local err_flag;
	local id_num;
	local text;

	id_num = id:match ('^[Pp][Mm][Cc](%d+)$');									-- identifier with PMC prefix

	if is_set (id_num) then
		set_message ('maint_pmc_format');
	else																		-- plain number without PMC prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if PMC is outside test limit boundaries
			err_flag = set_message ('err_bad_pmc');								-- set an error message
		else
			id = tostring (id_num);												-- make sure id is a string
		end
	else																		-- when id format incorrect
		err_flag = set_message ('err_bad_pmc');									-- set an error message
	end
	
	if is_set (embargo) and is_set (is_embargoed (embargo)) then				-- is PMC is still embargoed?
		text = table.concat (													-- still embargoed so no external link
			{
			make_wikilink (link_label_make (handler), handler.label),
			handler.separator,
			id,
			});
	else
		text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,	-- no embargo date or embargo has expired, ok to link to article
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access,
			auto_link = not err_flag and 'pmc' or nil							-- do not auto-link when PMC has error
			});
	end

	if err_flag then
		options.coins_list_t['PMC'] = nil;										-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid (options)
	local id = options.id;
	local handler = options.handler;

	if id:match(&quot;[^%d]&quot;) then													-- if PMID has anything but digits
		set_message ('err_bad_pmid');											-- set an error message
		options.coins_list_t['PMID'] = nil;										-- when error, unset so not included in COinS
	else																		-- PMID is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if PMID is outside test limit boundaries
			set_message ('err_bad_pmid');										-- set an error message
			options.coins_list_t['PMID'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; R F C &gt;------------------------------------------------------------------------

Format RFC and do simple error checking. RFCs are sequential numbers beginning at 1 and counting up.  This
code checks the RFC to see that it contains only digits and is less than test_limit specified in the configuration;
the value in test_limit will need to be updated periodically as more RFCs are issued.

An index of all RFCs is here: https://tools.ietf.org/rfc/

]]

local function rfc (options)
	local id = options.id;
	local handler = options.handler;

	if id:match(&quot;[^%d]&quot;) then													-- if RFC has anything but digits
		set_message ('err_bad_rfc');											-- set an error message
		options.coins_list_t['RFC'] = nil;										-- when error, unset so not included in COinS
	else																		-- RFC is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if RFC is outside test limit boundaries
			set_message ('err_bad_rfc');										-- set an error message
			options.coins_list_t['RFC'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access});
end


--[[--------------------------&lt; S 2 C I D &gt;--------------------------------------------------------------------

Format an S2CID, do simple error checking

S2CIDs are sequential numbers beginning at 1 and counting up.  This code checks the S2CID to see that it is only
digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically
as more S2CIDs are issued.

]]

local function s2cid (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local id_num;
	local text;
	
	id_num = id:match ('^[1-9]%d*$');											-- id must be all digits; must not begin with 0; no open access flag

 	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if handler.id_limit &lt; id_num then										-- if S2CID is outside test limit boundaries
			set_message ('err_bad_s2cid');										-- set an error message
			options.coins_list_t['S2CID'] = nil;								-- when error, unset so not included in COinS
		end
	else																		-- when id format incorrect
		set_message ('err_bad_s2cid');											-- set an error message
		options.coins_list_t['S2CID'] = nil;									-- when error, unset so not included in COinS
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});

	return text;
end


--[[--------------------------&lt; S B N &gt;------------------------------------------------------------------------

9-digit form of ISBN-10; uses same check-digit validation when SBN is prefixed with an additional '0' to make 10 digits

sbn value not made part of COinS metadata because we don't have a url or isn't a COinS-defined identifier (rft.xxx)
or an identifier registered at info-uri.info (info:)

]]

local function sbn (options)
	local id = options.id;
	local ignore_invalid = options.accept;
	local handler = options.handler;
	local function return_result (check, err_type)								-- local function to handle the various returns
		local SBN = internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,
						prefix = handler.prefix, id = id, separator = handler.separator});
		if not ignore_invalid then												-- if not ignoring SBN errors
			if not check then
				options.coins_list_t['SBN'] = nil;								-- when error, unset so not included in COinS; not really necessary here because sbn not made part of COinS
				set_message ('err_bad_sbn', {err_type});						-- display an error message
				return SBN; 
			end
		else
			set_message ('maint_isbn_ignore');									-- add a maint category even when there is no error (ToDo: Possibly switch to separate message for SBNs only)
		end
		return SBN;
	end

	if id:match ('[^%s-0-9X]') then
		return return_result (false, cfg.err_msg_supl.char);					-- fail if SBN contains anything but digits, hyphens, or the uppercase X
	end

	local ident = id:gsub ('[%s-]', '');										-- remove hyphens and whitespace; they interfere with the rest of the tests

	if  9 ~= ident:len() then
		return return_result (false, cfg.err_msg_supl.length);					-- fail if incorrect length
	end

	if ident:match ('^%d*X?$') == nil then
		return return_result (false, cfg.err_msg_supl.form);					-- fail if SBN has 'X' anywhere but last position
	end

	return return_result (is_valid_isxn ('0' .. ident, 10), cfg.err_msg_supl.check);
end


--[[--------------------------&lt; S S R N &gt;----------------------------------------------------------------------

Format an SSRN, do simple error checking

SSRNs are sequential numbers beginning at 100? and counting up.  This code checks the SSRN to see that it is
only digits and is greater than 99 and less than test_limit; the value in local variable test_limit will need
to be updated periodically as more SSRNs are issued.

]]

local function ssrn (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;
	local text;
	
	id_num = id:match ('^%d+$');												-- id must be all digits

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if 100 &gt; id_num or handler.id_limit &lt; id_num then						-- if SSRN is outside test limit boundaries
			set_message ('err_bad_ssrn');										-- set an error message
			options.coins_list_t['SSRN'] = nil;									-- when error, unset so not included in COinS
		end
	else																		-- when id format incorrect
		set_message ('err_bad_ssrn');											-- set an error message
		options.coins_list_t['SSRN'] = nil;										-- when error, unset so not included in COinS
	end
	
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = options.access});

	return text;
end


--[[--------------------------&lt; U S E N E T _ I D &gt;------------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function usenet_id (options)
	local id = options.id;
	local handler = options.handler;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$') then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		set_message ('err_bad_usenet_id')										-- add an error message if the message id is invalid
		options.coins_list_t['USENETID'] = nil;									-- when error, unset so not included in COinS
	end 
	
	return text;
end


--[[--------------------------&lt; Z B L &gt;-----------------------------------------------------------------------

A numerical identifier in the form nnnn.nnnnn - leading zeros in the first quartet optional

format described here: http://emis.mi.sanu.ac.rs/ZMATH/zmath/en/help/search/

temporary format is apparently eight digits.  Anything else is an error

]]

local function zbl (options)
	local id = options.id;
	local handler = options.handler;

	if id:match('^%d%d%d%d%d%d%d%d$') then										-- is this identifier using temporary format?
		set_message ('maint_zbl');												-- yes, add maint cat
	elseif not id:match('^%d?%d?%d?%d%.%d%d%d%d%d$') then						-- not temporary, is it normal format?
		set_message ('err_bad_zbl');											-- no, set an error message
		options.coins_list_t['ZBL'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--============================&lt;&lt; I N T E R F A C E   F U N C T I O N S &gt;&gt;==========================================

--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message if more than one alias exists in args

]]

local function extract_ids (args)
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs (cfg.id_handlers) do										-- k is uppercase identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one (args, v.parameters, 'err_redundant_parameters' );		-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set (v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; E X T R A C T _ I D _ A C C E S S _ L E V E L S &gt;--------------------------------------

Fetches custom id access levels from arguments using configuration settings. Parameters which have a predefined access
level (e.g. arxiv) do not use this function as they are directly rendered as free without using an additional parameter.

returns a table of k/v pairs where k is same as the identifier's key in cfg.id_handlers and v is the assigned (valid) keyword

access-level values must match the case used in cfg.keywords_lists['id-access'] (lowercase unless there is some special reason for something else)

]]

local function extract_id_access_levels (args, id_list)
	local id_accesses_list = {};
	for k, v in pairs (cfg.id_handlers) do
		local access_param = v.custom_access;									-- name of identifier's access-level parameter
		if is_set (access_param) then
			local access_level = args[access_param];							-- get the assigned value if there is one
			if is_set (access_level) then
				if not in_array (access_level, cfg.keywords_lists['id-access']) then	-- exact match required
					set_message ('err_invalid_param_val', {access_param, access_level});	
					access_level = nil;											-- invalid so unset
				end
				if not is_set (id_list[k]) then									-- identifier access-level must have a matching identifier
					set_message ('err_param_access_requires_param', {k:lower()});	-- parameter name is uppercase in cfg.id_handlers (k); lowercase for error message
				end
				id_accesses_list[k] = cfg.keywords_xlate[access_level];			-- get translated keyword
			end
		end
	end
	return id_accesses_list;
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;----------------------------------------------------

render the identifiers into a sorted sequence table

&lt;ID_list_coins_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value
&lt;options_t&gt; is a table of various k/v option pairs provided in the call to new_build_id_list();
	modified by	this function and passed to all identifier rendering functions
&lt;access_levels_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value (if valid)

returns a sequence table of sorted (by hkey - 'handler' key) rendered identifier strings

]]

local function build_id_list (ID_list_coins_t, options_t, access_levels_t)
	local ID_list_t = {};
	local accept;
	local func_map = {															--function map points to functions associated with hkey identifier
		['ARXIV'] = arxiv,
		['ASIN'] = asin,
		['BIBCODE'] = bibcode,
		['BIORXIV'] = biorxiv,
		['CITESEERX'] = citeseerx,
		['DOI'] = doi,
		['EISSN'] = issn,
		['HDL'] = hdl,
		['ISBN'] = isbn,
		['ISMN'] = ismn,
		['ISSN'] = issn,
		['JFM'] = jfm,
		['JSTOR'] = jstor,
		['LCCN'] = lccn,
		['MEDRXIV'] = medrxiv,
		['MR'] = mr,
		['OCLC'] = oclc,
		['OL'] = openlibrary,
		['OSTI'] = osti,
		['PMC'] = pmc,
		['PMID'] = pmid,
		['RFC']  = rfc,
		['S2CID'] = s2cid,
		['SBN'] = sbn,
		['SSRN'] = ssrn,
		['USENETID'] = usenet_id,
		['ZBL'] = zbl,
		}

	for hkey, v in pairs (ID_list_coins_t) do
		v, accept = has_accept_as_written (v);									-- remove accept-as-written markup if present; accept is boolean true when markup removed; false else
																				-- every function gets the options table with value v and accept boolean
		options_t.hkey = hkey;													-- ~/Configuration handler key
		options_t.id = v;														-- add that identifier value to the options table
		options_t.accept = accept;												-- add the accept boolean flag
		options_t.access = access_levels_t[hkey];								-- add the access level for those that have an |&lt;identifier-access= parameter
		options_t.handler = cfg.id_handlers[hkey];
		options_t.coins_list_t = ID_list_coins_t;								-- pointer to ID_list_coins_t; for |asin= and |ol=; also to keep erroneous values out of the citation's metadata
		options_t.coins_list_t[hkey] = v;										-- id value without accept-as-written markup for metadata
		
		if options_t.handler.access and not in_array (options_t.handler.access, cfg.keywords_lists['id-access']) then
			error (cfg.messages['unknown_ID_access'] .. options_t.handler.access);	-- here when handler access key set to a value not listed in list of allowed id access keywords
		end

		if func_map[hkey] then
			local id_text = func_map[hkey] (options_t);							-- call the function to get identifier text and any error message
			table.insert (ID_list_t, {hkey, id_text});							-- add identifier text to the output sequence table
		else
			error (cfg.messages['unknown_ID_key'] .. hkey);						-- here when func_map doesn't have a function for hkey
		end
	end

	local function comp (a, b)													-- used by following table.sort()
		return a[1]:lower() &lt; b[1]:lower();										-- sort by hkey
	end

	table.sort (ID_list_t, comp);												-- sequence table of tables sort	
	for k, v in ipairs (ID_list_t) do											-- convert sequence table of tables to simple sequence table of strings
		ID_list_t[k] = v[2];													-- v[2] is the identifier rendering from the call to the various functions in func_map{}
	end
	
	return ID_list_t;
end


--[[--------------------------&lt; O P T I O N S _ C H E C K &gt;----------------------------------------------------

check that certain option parameters have their associated identifier parameters with values

&lt;ID_list_coins_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value
&lt;ID_support_t&gt; is a sequence table of tables created in citation0() where each subtable has four elements:
	[1] is the support parameter's assigned value; empty string if not set
	[2] is a text string same as key in cfg.id_handlers
	[3] is cfg.error_conditions key used to create error message
	[4] is original ID support parameter name used to create error message
	
returns nothing; on error emits an appropriate error message

]]

local function options_check (ID_list_coins_t, ID_support_t)
	for _, v in ipairs (ID_support_t) do
		if is_set (v[1]) and not ID_list_coins_t[v[2]] then						-- when support parameter has a value but matching identifier parameter is missing or empty
			set_message (v[3], (v[4]));											-- emit the appropriate error message
		end
	end
end


--[[--------------------------&lt; I D E N T I F I E R _ L I S T S _ G E T &gt;--------------------------------------

Creates two identifier lists: a k/v table of identifiers and their values to be used locally and for use in the
COinS metadata, and a sequence table of the rendered identifier strings that will be included in the rendered
citation.

]]

local function identifier_lists_get (args_t, options_t, ID_support_t)
	local ID_list_coins_t = extract_ids (args_t);										-- get a table of identifiers and their values for use locally and for use in COinS
	options_check (ID_list_coins_t, ID_support_t);										-- ID support parameters must have matching identifier parameters 
	local ID_access_levels_t = extract_id_access_levels (args_t, ID_list_coins_t);		-- get a table of identifier access levels
	local ID_list_t = build_id_list (ID_list_coins_t, options_t, ID_access_levels_t);	-- get a sequence table of rendered identifier strings

	return ID_list_t, ID_list_coins_t;											-- return the tables
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	has_accept_as_written = utilities_page_ptr.has_accept_as_written;			-- import functions from select Module:Citation/CS1/Utilities module
	is_set = utilities_page_ptr.is_set;								
	in_array = utilities_page_ptr.in_array;
	set_message = utilities_page_ptr.set_message;
	select_one = utilities_page_ptr.select_one;
	substitute = utilities_page_ptr.substitute;
	make_wikilink = utilities_page_ptr.make_wikilink;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	auto_link_urls = auto_link_urls,											-- table of identifier URLs to be used when auto-linking |title=
	
	identifier_lists_get = identifier_lists_get,								-- experiment to replace individual calls to build_id_list(), extract_ids, extract_id_access_levels
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>i48i671rh4l6b7va3t85jkbdo8952fk</sha1>
    </revision>
    <revision>
      <id>4927</id>
      <parentid>4926</parentid>
      <timestamp>2024-12-28T15:31:47Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4927</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="77436" sha1="hjarco8e2706jgk6fa0c38cbw48m0km" xml:space="preserve">--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local has_accept_as_written, is_set, in_array, set_message, select_one,			-- functions in Module:Citation/CS1/Utilities
		substitute, make_wikilink;

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

declare variables here that have page-wide scope that are not brought in from other modules; that are created here and used here

]]

local auto_link_urls = {};														-- holds identifier URLs for those identifiers that can auto-link |title=


--============================&lt;&lt; H E L P E R   F U N C T I O N S &gt;&gt;============================================

--[[--------------------------&lt; W I K I D A T A _ A R T I C L E _ N A M E _ G E T &gt;----------------------------

as an aid to internationalizing identifier-label wikilinks, gets identifier article names from Wikidata.

returns :&lt;lang code&gt;:&lt;article title&gt; when &lt;q&gt; has an &lt;article title&gt; for &lt;lang code&gt;; nil else

for identifiers that do not have q, returns nil

for wikis that do not have mw.wikibase installed, returns nil

]]

local function wikidata_article_name_get (q)
	if not is_set (q) or (q and not mw.wikibase) then							-- when no q number or when a q number but mw.wikibase not installed on this wiki
		return nil;																-- abandon
	end

	local wd_article;
	local this_wiki_code = cfg.this_wiki_code;									-- Wikipedia subdomain; 'en' for en.wikipedia.org

	wd_article = mw.wikibase.getSitelink (q, this_wiki_code .. 'wiki');			-- fetch article title from WD; nil when no title available at this wiki

	if wd_article then
		wd_article = table.concat ({':', this_wiki_code, ':', wd_article});		-- interwiki-style link without brackets if taken from WD; leading colon required
	end

	return wd_article;															-- article title from WD; nil else
end


--[[--------------------------&lt; L I N K _ L A B E L _ M A K E &gt;------------------------------------------------

common function to create identifier link label from handler table or from Wikidata

returns the first available of
	1. redirect from local wiki's handler table (if enabled)
	2. Wikidata (if there is a Wikidata entry for this identifier in the local wiki's language)
	3. label specified in the local wiki's handler table
	
]]

local function link_label_make (handler)
	local wd_article;
	
	if not (cfg.use_identifier_redirects and is_set (handler.redirect)) then	-- redirect has priority so if enabled and available don't fetch from Wikidata because expensive
		wd_article = wikidata_article_name_get (handler.q);						-- if Wikidata has an article title for this wiki, get it;
	end
	
	return (cfg.use_identifier_redirects and is_set (handler.redirect) and handler.redirect) or wd_article or handler.link;
end


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki-style external link

]]

local function external_link_id (options)
	local url_string = options.id;
	local ext_link;
	local this_wiki_code = cfg.this_wiki_code;									-- Wikipedia subdomain; 'en' for en.wikipedia.org
	local wd_article;															-- article title from Wikidata
	
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode (url_string, 'PATH');
	end

	if options.auto_link and is_set (options.access) then
		auto_link_urls[options.auto_link] = table.concat ({options.prefix, url_string, options.suffix});
	end

	ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or &quot;&quot;, mw.text.nowiki (options.id));
	if is_set (options.access) then
		ext_link = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[options.access].class, cfg.presentation[options.access].title, ext_link});	-- add the free-to-read / paywall lock
	end

	return table.concat	({
		make_wikilink (link_label_make (options), options.label),				-- redirect, Wikidata link, or locally specified link (in that order)
		options.separator or '&amp;nbsp;',
		ext_link
		});
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki-style internal link

TODO: Does not currently need to support options.access, options.encode, auto-linking and COinS (as in external_link_id),
but may be needed in the future for :m:Interwiki_map custom-prefixes like :arxiv:, :bibcode:, :DOI:, :hdl:, :ISSN:,
:JSTOR:, :Openlibrary:, :PMID:, :RFC:.

]]

local function internal_link_id (options)
	local id = mw.ustring.gsub (options.id, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9

	return table.concat (
		{
		make_wikilink (link_label_make (options), options.label),				-- wiki-link the identifier label
		options.separator or '&amp;nbsp;',											-- add the separator
		make_wikilink (
			table.concat (
				{
				options.prefix,
				id,																-- translated to Western digits
				options.suffix or ''
				}),
			substitute (cfg.presentation['bdi'], {'', mw.text.nowiki (options.id)})	-- bdi tags to prevent Latin script identifiers from being reversed at RTL language wikis
			);																	-- nowiki because MediaWiki still has magic links for ISBN and the like; TODO: is it really required?
		});
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |pmc-embargo-date= against
today's date.  If embargo date is in the future, returns the content of |pmc-embargo-date=; otherwise, returns
an empty string because the embargo has expired or because |pmc-embargo-date= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, todays_date;
		good1, embargo_date = pcall (lang.formatDate, lang, 'U', embargo);
		todays_date = lang:formatDate ('U');
	
		if good1 then															-- if embargo date is a good date
			if tonumber (embargo_date) &gt;= tonumber (todays_date) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				set_message ('maint_pmc_embargo');								-- embargo has expired; add main cat
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |pmc-embargo-date= not set return empty string
end


--[=[-------------------------&lt; I S _ V A L I D _ R X I V _ D A T E &gt;------------------------------------------

for biorxiv, returns true if:
	2019-12-11T00:00Z &lt;= biorxiv_date &lt; today + 2 days
for medrxiv, returns true if:
	2020-01-01T00:00Z &lt;= medrxiv_date &lt; today + 2 days
	
The dated form of biorxiv identifier has a start date of 2019-12-11.  The Unix timestamp for that date is {{#time:U|2019-12-11}} = 1576022400
The medrxiv identifier has a start date of 2020-01-01.  The Unix timestamp for that date is {{#time:U|2020-01-01}} = 1577836800

&lt;rxiv_date&gt; is the date provided in those |biorxiv= parameter values that are dated and in |medrxiv= parameter values at time 00:00:00 UTC
&lt;today&gt; is the current date at time 00:00:00 UTC plus 48 hours
	if today's date is 2023-01-01T00:00:00 then
		adding 24 hours gives 2023-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2023-01-03T00:00:00 – one second more than tomorrow

inputs:
	&lt;y&gt;, &lt;m&gt;, &lt;d&gt; – year, month, day parts of the date from the birxiv or medrxiv identifier
	&lt;select&gt; 'b' for biorxiv, 'm' for medrxiv; defaults to 'b'

]=]

local function is_valid_rxiv_date (y, m, d, select)
	if 0 == tonumber (m) and 12 &lt; tonumber (m) then								-- &lt;m&gt; must be a number 1–12
		return false;
	end
	if 0 == tonumber (d) and 31 &lt; tonumber (d) then								-- &lt;d&gt; must be a number 1–31; TODO: account for month length and leap yer?
		return false;
	end
	
	local rxiv_date = table.concat ({y, m, d}, '-');							-- make ymd date string
	local good1, good2;
	local rxiv_ts, tomorrow_ts;													-- to hold Unix timestamps representing the dates
	local lang_object = mw.getContentLanguage();

	good1, rxiv_ts = pcall (lang_object.formatDate, lang_object, 'U', rxiv_date);		-- convert rxiv_date value to Unix timestamp 
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which tonumber() may not understand
		rxiv_ts = tonumber (rxiv_ts) or lang_object:parseFormattedNumber (rxiv_ts);	-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to Unix timestamp
	end

	local limit_ts = ((select and ('m' == select)) and 1577836800) or 1576022400;	-- choose the appropriate limit timesatmp

	return ((limit_ts &lt;= rxiv_ts) and (rxiv_ts &lt; tomorrow_ts))					-- limit_ts &lt;= rxiv_date &lt; tomorrow's date
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all ISBN/ISSN digits including the check digit.
ISBN-13 is checked in isbn().

If the number is valid the result will be 0. Before calling this function, ISBN/ISSN must be checked for length
and stripped of dashes, spaces and other non-ISxN characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39, 'X' → 0x58
	len = len + 1;																-- adjust to be a loop counter
	for i, v in ipairs (isxn_str) do											-- loop through all of the bytes and calculate the checksum
		if v == string.byte (&quot;X&quot; ) then											-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10 * (len - i);										-- it represents 10 decimal
		else
			temp = temp + tonumber (string.char (v) )*(len-i);
		end
	end
	return temp % 11 == 0;														-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N _ 1 3 &gt;-----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 ISBN/ISMN digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, ISBN-13/ISMN must be checked for length
and stripped of dashes, spaces and other non-ISxN-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39
	for i, v in ipairs (isxn_str) do
		temp = temp + (3 - 2*(i % 2)) * tonumber (string.char (v) );			-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when ISBN-13/ISMN is correct
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

LCCN normalization (https://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized LCCN for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.

]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);												-- 1. strip whitespace

	if nil ~= string.find (lccn, '/') then
		lccn = lccn:match (&quot;(.-)/&quot;);											-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);									-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then														-- if there was a hyphen
		suffix = string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;				-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn = prefix..suffix;													-- reassemble the LCCN
	end
	
	return lccn;
	end


--============================&lt;&lt; I D E N T I F I E R   F U N C T I O N S &gt;&gt;====================================

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: https://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9107 and 0703, is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation; not the same as |class= parameter which is not supported in this form
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number

]]

local function arxiv (options)
	local id = options.id;
	local class = options.Class;												-- TODO: lowercase?
	local handler = options.handler;
	local year, month, version;
	local err_msg = false;														-- assume no error message
	local text;																	-- output text
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9107-0703 format with or without version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_msg = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 with or without version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then									-- when year is 07, is month invalid (before April)?
				err_msg = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format with or without version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_msg = true;														-- flag for error message
		end

	else
		err_msg = true;															-- not a recognized format; flag for error message
	end

	if err_msg then
		options.coins_list_t['ARXIV'] = nil;									-- when error, unset so not included in COinS
	end
	
	local err_msg_t = {};
	if err_msg then
		set_message ('err_bad_arxiv');
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access});

	if is_set (class) then
		if id:match ('^%d+') then
			text = table.concat ({text, ' [[https://arxiv.org/archive/', class, ' ', class, ']]'});	-- external link within square brackets, not wikilink
		else
			set_message ('err_class_ignored');
		end
	end

	return text;
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode ID.

Format for bibcodes is specified here: https://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		9–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local ignore_invalid = options.accept;
	local err_type;
	local err_msg = '';
	local year;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode,
		access = access});
	
	if 19 ~= id:len() then
		err_type = cfg.err_msg_supl.length;
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%w&amp;%.][%w&amp;%.][%w&amp;%.][%w.]+[%a%.]$&quot;);
		if not year then														-- if nil then no pattern match
			err_type = cfg.err_msg_supl.value;									-- so value error
		else
			local next_year = tonumber (os.date ('%Y')) + 1;					-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = cfg.err_msg_supl.year;								-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = cfg.err_msg_supl.journal;							-- journal abbreviation must not have '&amp;.' (if it does it's missing a letter)
			end
			if id:match ('.........%.tmp%.') then								-- temporary bibcodes when positions 10–14 are '.tmp.'
				set_message ('maint_bibcode');
			end
		end
	end

	if is_set (err_type) and not ignore_invalid then							-- if there was an error detected and accept-as-written markup not used
		set_message ('err_bad_bibcode', {err_type});
		options.coins_list_t['BIBCODE'] = nil;									-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; B I O R X I V &gt;-----------------------------------------------------------------

Format bioRxiv ID and do simple error checking.  Before 2019-12-11, biorXiv IDs were 10.1101/ followed by exactly
6 digits.  After 2019-12-11, biorXiv IDs retained the six-digit identifier but prefixed that with a yyyy.mm.dd. 
date and suffixed with an optional version identifier.

The bioRxiv ID is the string of characters:
	https://doi.org/10.1101/078733 -&gt; 10.1101/078733
or a date followed by a six-digit number followed by an optional version indicator 'v' and one or more digits:
	https://www.biorxiv.org/content/10.1101/2019.12.11.123456v2 -&gt; 10.1101/2019.12.11.123456v2
	
see https://www.biorxiv.org/about-biorxiv

]]

local function biorxiv (options)
	local id = options.id;
	local handler = options.handler;
	local err_msg = true;														-- flag; assume that there will be an error
	
	local patterns = {
		'^10%.1101/%d%d%d%d%d%d$',												-- simple 6-digit identifier (before 2019-12-11)
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%dv%d+$',				-- y.m.d. date + 6-digit identifier + version (after 2019-12-11)
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%d$',					-- y.m.d. date + 6-digit identifier (after 2019-12-11)
		}
	
	for _, pattern in ipairs (patterns) do										-- spin through the patterns looking for a match
		if id:match (pattern) then
			local y, m, d = id:match (pattern);									-- found a match, attempt to get year, month and date from the identifier

			if m then															-- m is nil when id is the six-digit form
				if not is_valid_rxiv_date (y, m, d, 'b') then					-- validate the encoded date; 'b' for biorxiv limit
					break;														-- date fail; break out early so we don't unset the error message
				end
			end
			err_msg = nil;														-- we found a match so unset the error message
			break;																-- and done
		end
	end																			-- err_cat remains set here when no match

	if err_msg then
		options.coins_list_t['BIORXIV'] = nil;									-- when error, unset so not included in COinS
		set_message ('err_bad_biorxiv');										-- and set the error message
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator,
			encode = handler.encode, access = handler.access});
end


--[[--------------------------&lt; C I T E S E E R X &gt;------------------------------------------------------------

CiteSeerX use their own notion of &quot;doi&quot; (not to be confused with the identifiers resolved via doi.org).

The description of the structure of this identifier can be found at Help_talk:Citation_Style_1/Archive_26#CiteSeerX_id_structure

]]

local function citeseerx (options)
	local id = options.id;
	local handler = options.handler;
	local matched;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode,
		access = handler.access});
	
	matched = id:match (&quot;^10%.1%.1%.[1-9]%d?%d?%d?%.[1-9]%d?%d?%d?$&quot;);
	if not matched then
		set_message ('err_bad_citeseerx' );
		options.coins_list_t['CITESEERX'] = nil;								-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the DOI name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in DOI names.

https://www.doi.org/doi_handbook/2_Numbering.html				-- 2.2 Syntax of a DOI name
https://www.doi.org/doi_handbook/2_Numbering.html#2.2.2			-- 2.2.2 DOI prefix

]]

local function doi (options)
	local id = options.id;
	local inactive = options.DoiBroken
	local access = options.access;
	local ignore_invalid = options.accept;
	local handler = options.handler;
	local err_flag;

	local function is_extended_free (registrant, suffix)						-- local function to check those few registrants that are mixed; identifiable by the doi suffix &lt;incipit&gt;
		if cfg.extended_registrants_t[registrant] then							-- if this registrant has known free-to-read extentions
			for _, incipit in ipairs (cfg.extended_registrants_t[registrant]) do	-- loop through the registrant's incipits
				if mw.ustring.find (suffix, '^' .. incipit) then				-- if found
					return true;
				end
			end
		end
	end

	local text;
	if is_set (inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;);						-- try to get the year portion from the inactive date
		local inactive_month, good;

		if is_set (inactive_year) then
			if 4 &lt; inactive:len() then											-- inactive date has more than just a year (could be anything)
				local lang_obj = mw.getContentLanguage();						-- get a language object for this wiki
				good, inactive_month = pcall (lang_obj.formatDate, lang_obj, 'F', inactive);	-- try to get the month name from the inactive date
				if not good then
					inactive_month = nil;										-- something went wrong so make sure this is unset
				end
			end
		end																		-- otherwise, |doi-broken-date= has something but it isn't a date
		
		if is_set (inactive_year) and is_set (inactive_month) then
			set_message ('maint_doi_inactive_dated', {inactive_year, inactive_month, ' '});
		elseif is_set (inactive_year) then
			set_message ('maint_doi_inactive_dated', {inactive_year, '', ''});
		else
			set_message ('maint_doi_inactive');
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. ' ' .. inactive .. ')';
	end

	local suffix;
	local registrant, suffix = mw.ustring.match (id, '^10%.([^/]+)/([^%s–]-[^%.,])$');	-- registrant and suffix set when DOI has the proper basic form

	local registrant_err_patterns = {											-- these patterns are for code ranges that are not supported 
		'^[^1-3]%d%d%d%d%.%d+$',												-- 5 digits with subcode (0xxxx, 40000+); accepts: 10000–39999
		'^[^1-7]%d%d%d%d$',														-- 5 digits without subcode (0xxxx, 60000+); accepts: 10000–69999
		'^[^1-9]%d%d%d%.%d+$',												-- 4 digits with subcode (0xxx); accepts: 1000–9999
		'^[^1-9]%d%d%d$',														-- 4 digits without subcode (0xxx); accepts: 1000–9999
		'^%d%d%d%d%d%d+',														-- 6 or more digits
		'^%d%d?%d?$',															-- less than 4 digits without subcode (3 digits with subcode is legitimate)
		'^%d%d?%.[%d%.]+',														-- 1 or 2 digits with subcode
		'^5555$',																-- test registrant will never resolve
		'[^%d%.]',																-- any character that isn't a digit or a dot
		}

	if not ignore_invalid then
		if registrant then														-- when DOI has proper form
			for i, pattern in ipairs (registrant_err_patterns) do				-- spin through error patterns
				if registrant:match (pattern) then								-- to validate registrant codes
					err_flag = set_message ('err_bad_doi');						-- when found, mark this DOI as bad
					break;														-- and done
				end
			end
		else
			err_flag = set_message ('err_bad_doi');								-- invalid directory or malformed
		end
	else
		set_message ('maint_doi_ignore');
	end

	if err_flag then
		options.coins_list_t['DOI'] = nil;										-- when error, unset so not included in COinS
	else
		if not access and (cfg.known_free_doi_registrants_t[registrant] or is_extended_free (registrant, suffix)) then		-- |doi-access=free not set and &lt;registrant&gt; is known to be free
			set_message ('maint_doi_unflagged_free');							-- set a maint cat
		end
	end
	
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access,
		auto_link = not (err_flag or is_set (inactive) or ignore_invalid) and 'doi' or nil -- do not auto-link when |doi-broken-date= has a value or when there is a DOI error or (to play it safe, after all, auto-linking is not essential) when invalid DOIs are ignored
		}) .. (inactive or '');

	return text;
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

Query string parameters are named here: https://www.handle.net/proxy_servlet.html.  query strings are not displayed
but since '?' is an allowed character in an HDL, '?' followed by one of the query parameters is the only way we
have to detect the query string so that it isn't URL-encoded with the rest of the identifier.

]]

local function hdl (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local query_params = {														-- list of known query parameters from https://www.handle.net/proxy_servlet.html
		'noredirect',
		'ignore_aliases',
		'auth',
		'cert',
		'index',
		'type',
		'urlappend',
		'locatt',
		'action',
		}
	
	local hdl, suffix, param = id:match ('(.-)(%?(%a+).+)$');					-- look for query string
	local found;

	if hdl then																	-- when there are query strings, this is the handle identifier portion
		for _, q in ipairs (query_params) do									-- spin through the list of query parameters
			if param:match ('^' .. q) then										-- if the query string begins with one of the parameters
				found = true;													-- announce a find
				break;															-- and stop looking
			end
		end
	end

	if found then
		id = hdl;																-- found so replace id with the handle portion; this will be URL-encoded, suffix will not
	else
		suffix = '';															-- make sure suffix is empty string for concatenation else
	end

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, suffix = suffix, separator = handler.separator, encode = handler.encode, access = access})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- HDL must contain a forward slash, must not contain spaces, endashes, and must not end with period or comma
		set_message ('err_bad_hdl' );
		options.coins_list_t['HDL'] = nil;										-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; I S B N &gt;----------------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function isbn (options)
	local isbn_str = options.id;
	local ignore_invalid = options.accept;
	local handler = options.handler;

	local function return_result (check, err_type)								-- local function to handle the various returns
		local ISBN = internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,
						prefix = handler.prefix, id = isbn_str, separator = handler.separator});
		if ignore_invalid then													-- if ignoring ISBN errors
			set_message ('maint_isbn_ignore');									-- add a maint category even when there is no error
		else																	-- here when not ignoring
			if not check then													-- and there is an error
				options.coins_list_t['ISBN'] = nil;								-- when error, unset so not included in COinS
				set_message ('err_bad_isbn', err_type);							-- set an error message
				return ISBN;										 			-- return id text
			end
		end
		return ISBN;															-- return id text
	end

	if nil ~= isbn_str:match ('[^%s-0-9X]') then
		return return_result (false, cfg.err_msg_supl.char);					-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end

	local id = isbn_str:gsub ('[%s-]', '');										-- remove hyphens and whitespace

	local len = id:len();
 
	if len ~= 10 and len ~= 13 then
		return return_result (false, cfg.err_msg_supl.length);					-- fail if incorrect length
	end

	if len == 10 then
		if id:match ('^%d*X?$') == nil then										-- fail if isbn_str has 'X' anywhere but last position
			return return_result (false, cfg.err_msg_supl.form);									
		end
		if not is_valid_isxn (id, 10) then										-- test isbn-10 for numerical validity
			return return_result (false, cfg.err_msg_supl.check);				-- fail if isbn-10 is not numerically valid
		end
		if id:find ('^63[01]') then												-- 630xxxxxxx and 631xxxxxxx are (apparently) not valid isbn group ids but are used by amazon as numeric identifiers (asin)
			return return_result (false, cfg.err_msg_supl.group);				-- fail if isbn-10 begins with 630/1
		end
		return return_result (true, cfg.err_msg_supl.check);					-- pass if isbn-10 is numerically valid
	else
		if id:match ('^%d+$') == nil then
			return return_result (false, cfg.err_msg_supl.char);				-- fail if ISBN-13 is not all digits
		end
		if id:match ('^97[89]%d*$') == nil then
			return return_result (false, cfg.err_msg_supl.prefix);				-- fail when ISBN-13 does not begin with 978 or 979
		end
		if id:match ('^9790') then
			return return_result (false, cfg.err_msg_supl.group);				-- group identifier '0' is reserved to ISMN
		end
		return return_result (is_valid_isxn_13 (id), cfg.err_msg_supl.check);
	end
end


--[[--------------------------&lt; A S I N &gt;----------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: ASIN must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, ASINs must be 10-digit
ISBN. If 10-digit ISBN, add a maintenance category so a bot or AWB script can replace |asin= with |isbn=.
Error message if not 10 characters, if not ISBN-10, if mixed and first character is a digit.

|asin=630....... and |asin=631....... are (apparently) not a legitimate ISBN though it checksums as one; these
do not cause this function to emit the maint_asin message

This function is positioned here because it calls isbn()

]]

local function asin (options)
	local id = options.id;
	local domain = options.ASINTLD;
	
	local err_flag;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_flag = set_message ('err_bad_asin');								-- ASIN is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then							-- if 10-digit numeric (or 9 digits with terminal X)
			if is_valid_isxn (id, 10) then										-- see if ASIN value is or validates as ISBN-10
				if not id:find ('^63[01]') then									-- 630xxxxxxx and 631xxxxxxx are (apparently) not a valid isbn prefixes but are used by amazon as a numeric identifier
					err_flag = set_message ('err_bad_asin');					-- ASIN has ISBN-10 form but begins with something other than 630/1 so probably an isbn 
				end
			elseif not is_set (err_flag) then
				err_flag = set_message ('err_bad_asin');						-- ASIN is not ISBN-10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_flag = set_message ('err_bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if (not is_set (domain)) or in_array (domain, {'us'}) then					-- default: United States
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then									-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'z.cn'}) then 									-- China
		domain = &quot;cn&quot;;
	elseif in_array (domain, {'au', 'br', 'mx', 'sg', 'tr'}) then				-- Australia, Brazil, Mexico, Singapore, Turkey
		domain = &quot;com.&quot; .. domain;
	elseif not in_array (domain, {'ae', 'ca', 'cn', 'de', 'es', 'fr', 'in', 'it', 'nl', 'pl', 'sa', 'se', 'co.jp', 'co.uk', 'com', 'com.au', 'com.br', 'com.mx', 'com.sg', 'com.tr'}) then -- Arabic Emirates, Canada, China, Germany, Spain, France, Indonesia, Italy, Netherlands, Poland, Saudi Arabia, Sweden (as of 2021-03 Austria (.at), Liechtenstein (.li) and Switzerland (.ch) still redirect to the German site (.de) with special settings, so don't maintain local ASINs for them)
		err_flag = set_message ('err_bad_asin_tld');							-- unsupported asin-tld value
	end
	local handler = options.handler;

	if not is_set (err_flag) then
		options.coins_list_t['ASIN'] = handler.prefix .. domain .. &quot;/dp/&quot; .. id;	-- asin for coins
	else
		options.coins_list_t['ASIN'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix .. domain .. &quot;/dp/&quot;,
		id = id, encode = handler.encode, separator = handler.separator})
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to ISBN-13, ISMN is 13 digits beginning 979-0-... and uses the
same check digit calculations.  See https://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

ismn value not made part of COinS metadata because we don't have a url or isn't a COinS-defined identifier (rft.xxx)
or an identifier registered at info-uri.info (info:)

]]

local function ismn (options)
	local id = options.id;
	local handler = options.handler;
	local text;
	local valid_ismn = true;
	local id_copy;

	id_copy = id;																-- save a copy because this testing is destructive
	id = id:gsub ('[%s-]', '');													-- remove hyphens and white space

	if 13 ~= id:len() or id:match (&quot;^9790%d*$&quot; ) == nil then					-- ISMN must be 13 digits and begin with 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ISMN
	end

	--	text = internal_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,		-- use this (or external version) when there is some place to link to
	--		prefix = handler.prefix, id = id_copy, separator = handler.separator, encode = handler.encode})

	text = table.concat (														-- because no place to link to yet
		{
		make_wikilink (link_label_make (handler), handler.label),
		handler.separator,
		id_copy
		});

	if false == valid_ismn then
		options.coins_list_t['ISMN'] = nil;										-- when error, unset so not included in COinS; not really necessary here because ismn not made part of COinS
		set_message ('err_bad_ismn');											-- create an error message if the ISMN is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an ISSN.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [https://www.worldcat.org/issn/0819 4327 0819 4327]	-- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the ISSN midpoint.  It also validates the ISSN for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check ISSN error message.  The
ISSN is always displayed with a hyphen, even if the ISSN was given as a single group of 8 digits.

]]

local function issn (options)
	local id = options.id;
	local handler = options.handler;
	local ignore_invalid = options.accept;

	local issn_copy = id;														-- save a copy of unadulterated ISSN; use this version for display if ISSN does not validate
	local text;
	local valid_issn = true;

	id = id:gsub ('[%s-]', '');													-- remove hyphens and whitespace

	if 8 ~= id:len() or nil == id:match (&quot;^%d*X?$&quot; ) then						-- validate the ISSN: 8 digits long, containing only 0-9 or X in the last position
		valid_issn = false;														-- wrong length or improper character
	else
		valid_issn = is_valid_isxn (id, 8);										-- validate ISSN
	end

	if true == valid_issn then
		id = string.sub (id, 1, 4 ) .. &quot;-&quot; .. string.sub (id, 5 );				-- if valid, display correctly formatted version
	else
		id = issn_copy;															-- if not valid, show the invalid ISSN with error message
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode})

	if ignore_invalid then
		set_message ('maint_issn_ignore');
	else
		if false == valid_issn then
			options.coins_list_t['ISSN'] = nil;									-- when error, unset so not included in COinS
			set_message ('err_bad_issn', (options.hkey == 'EISSN') and 'e' or '');	-- create an error message if the ISSN is invalid
		end 
	end
	
	return text;
end


--[[--------------------------&lt; J F M &gt;-----------------------------------------------------------------------

A numerical identifier in the form nn.nnnn.nn

]]

local function jfm (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;

	id_num = id:match ('^[Jj][Ff][Mm](.*)$');									-- identifier with jfm prefix; extract identifier

	if is_set (id_num) then
		set_message ('maint_jfm_format');
	else																		-- plain number without JFM prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num and id_num:match('^%d%d%.%d%d%d%d%.%d%d$') then
		id = id_num;															-- jfm matches pattern
	else
		set_message ('err_bad_jfm' );											-- set an error message
		options.coins_list_t['JFM'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; J S T O R &gt;--------------------------------------------------------------------

Format a JSTOR with some error checking

]]

local function jstor (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;

	if id:find ('[Jj][Ss][Tt][Oo][Rr]') or id:find ('^https?://') or id:find ('%s') then
		set_message ('err_bad_jstor');											-- set an error message
		options.coins_list_t['JSTOR'] = nil;									-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});
end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
https://oclc-research.github.io/infoURI-Frozen/info-uri.info/info:lccn/reg.html

length = 8 then all digits
length = 9 then lccn[1] is lowercase alpha
length = 10 then lccn[1] and lccn[2] are both lowercase alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lowercase alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lowercase alpha

]]

local function lccn (options)
	local lccn = options.id;
	local handler = options.handler;
	local err_flag;																-- presume that LCCN is valid
	local id = lccn;															-- local copy of the LCCN

	id = normalize_lccn (id);													-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();														-- get the length of the LCCN

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits)
			err_flag = set_message ('err_bad_lccn');							-- set an error message
		end
	elseif 9 == len then														-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then							-- does it match our pattern?
			err_flag = set_message ('err_bad_lccn');							-- set an error message
		end
	elseif 10 == len then														-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then					-- ... see if it matches our pattern
				err_flag = set_message ('err_bad_lccn');						-- no match, set an error message
			end
		end
	elseif 11 == len then														-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_flag = set_message ('err_bad_lccn');							-- no match, set an error message
		end
	elseif 12 == len then														-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then						-- see if it matches our pattern
			err_flag = set_message ('err_bad_lccn');							-- no match, set an error message
		end
	else
		err_flag = set_message ('err_bad_lccn');								-- wrong length, set an error message
	end

	if not is_set (err_flag) and nil ~= lccn:find ('%s') then
		err_flag = set_message ('err_bad_lccn');								-- lccn contains a space, set an error message
	end

	if is_set (err_flag) then
		options.coins_list_t['LCCN'] = nil;										-- when error, unset so not included in COinS
	end

	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = lccn, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; M E D R X I V &gt;-----------------------------------------------------------------

Format medRxiv ID and do simple error checking.  Similar to later bioRxiv IDs, medRxiv IDs are prefixed with a
yyyy.mm.dd. date and suffixed with an optional version identifier.  Ealiest date accepted is 2020.01.01

The medRxiv ID is a date followed by an eight-digit number followed by an optional version indicator 'v' and one or more digits:
	https://www.medrxiv.org/content/10.1101/2020.11.16.20232009v2 -&gt; 10.1101/2020.11.16.20232009v2

]]

local function medrxiv (options)
	local id = options.id;
	local handler = options.handler;
	local err_msg_flag = true;													-- flag; assume that there will be an error

	local patterns = {
		'%d%d%d%d%d%d%d%d$',													-- simple 8-digit identifier; these should be relatively rare
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%d%d%dv%d+$',			-- y.m.d. date + 8-digit identifier + version (2020-01-01 and later)
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%d%d%d$',				-- y.m.d. date + 8-digit identifier (2020-01-01 and later)
		}
	
	for _, pattern in ipairs (patterns) do										-- spin through the patterns looking for a match
		if id:match (pattern) then
			local y, m, d = id:match (pattern);									-- found a match, attempt to get year, month and date from the identifier

			if m then															-- m is nil when id is the 8-digit form
				if not is_valid_rxiv_date (y, m, d, 'b') then					-- validate the encoded date; 'b' for medrxiv limit
					break;														-- date fail; break out early so we don't unset the error message
				end
			end
			err_msg_flag = nil;													-- we found a match so unset the error message
			break;																-- and done
		end
	end																			-- &lt;err_msg_flag&gt; remains set here when no match

	if err_msg_flag then
		options.coins_list_t['MEDRXIV'] = nil;									-- when error, unset so not included in COinS
		set_message ('err_bad_medrxiv');										-- and set the error message
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator,
			encode = handler.encode, access = handler.access});
end


--[[--------------------------&lt; M R &gt;--------------------------------------------------------------------------

A seven digit number; if not seven digits, zero-fill leading digits to make seven digits.

]]

local function mr (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;
	local id_len;

	id_num = id:match ('^[Mm][Rr](%d+)$');										-- identifier with mr prefix

	if is_set (id_num) then
		set_message ('maint_mr_format');										-- add maint cat
	else																		-- plain number without mr prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	id_len = id_num and id_num:len() or 0;
	if (7 &gt;= id_len) and (0 ~= id_len) then
		id = string.rep ('0', 7-id_len) .. id_num;								-- zero-fill leading digits
	else
		set_message ('err_bad_mr');												-- set an error message
		options.coins_list_t['MR'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an OCLC ID.  https://www.oclc.org/batchload/controlnumber.en.html {{dead link}}
archived at: https://web.archive.org/web/20161228233804/https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (options)
	local id = options.id;
	local handler = options.handler;
	local number;

	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- constrain to 1 to 9 digits; change this when OCLC issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if tonumber (id) &gt; handler.id_limit then
			number = nil;														-- unset when id value exceeds the limit
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		set_message ('err_bad_oclc')											-- add an error message if the id is malformed
		options.coins_list_t['OCLC'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local ident, code = id:gsub('^OL', ''):match(&quot;^(%d+([AMW]))$&quot;);				-- strip optional OL prefix followed immediately by digits followed by 'A', 'M', or 'W';
	local err_flag;
	local prefix = {															-- these are appended to the handler.prefix according to code
		['A']='authors/OL',
		['M']='books/OL',
		['W']='works/OL',
		['X']='OL'																-- not a code; spoof when 'code' in id is invalid
		};

	if not ident then
		code = 'X';																-- no code or id completely invalid
		ident = id;																-- copy id to ident so that we display the flawed identifier
		err_flag = set_message ('err_bad_ol');
	end

	if not is_set (err_flag) then
		options.coins_list_t['OL'] = handler.prefix .. prefix[code] .. ident;	-- experiment for ol coins
	else
		options.coins_list_t['OL'] = nil;										-- when error, unset so not included in COinS
	end

	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix .. prefix[code],
		id = ident, separator = handler.separator, encode = handler.encode,
		access = access});
end


--[[--------------------------&lt; O S T I &gt;----------------------------------------------------------------------

Format OSTI and do simple error checking. OSTIs are sequential numbers beginning at 1 and counting up.  This
code checks the OSTI to see that it contains only digits and is less than test_limit specified in the configuration;
the value in test_limit will need to be updated periodically as more OSTIs are issued.

NB. 1018 is the lowest OSTI number found in the wild (so far) and resolving OK on the OSTI site

]]

local function osti (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;

	if id:match(&quot;[^%d]&quot;) then													-- if OSTI has anything but digits
		set_message ('err_bad_osti');											-- set an error message
		options.coins_list_t['OSTI'] = nil;										-- when error, unset so not included in COinS
	else																		-- OSTI is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1018 &gt; id_num or handler.id_limit &lt; id_num then						-- if OSTI is outside test limit boundaries
			set_message ('err_bad_osti');										-- set an error message
			options.coins_list_t['OSTI'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc (options)
	local id = options.id;
	local embargo = options.Embargo;											-- TODO: lowercase?
	local handler = options.handler;
	local err_flag;
	local id_num;
	local text;

	id_num = id:match ('^[Pp][Mm][Cc](%d+)$');									-- identifier with PMC prefix

	if is_set (id_num) then
		set_message ('maint_pmc_format');
	else																		-- plain number without PMC prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if PMC is outside test limit boundaries
			err_flag = set_message ('err_bad_pmc');								-- set an error message
		else
			id = tostring (id_num);												-- make sure id is a string
		end
	else																		-- when id format incorrect
		err_flag = set_message ('err_bad_pmc');									-- set an error message
	end
	
	if is_set (embargo) and is_set (is_embargoed (embargo)) then				-- is PMC is still embargoed?
		text = table.concat (													-- still embargoed so no external link
			{
			make_wikilink (link_label_make (handler), handler.label),
			handler.separator,
			id,
			});
	else
		text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,	-- no embargo date or embargo has expired, ok to link to article
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access,
			auto_link = not err_flag and 'pmc' or nil							-- do not auto-link when PMC has error
			});
	end

	if err_flag then
		options.coins_list_t['PMC'] = nil;										-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid (options)
	local id = options.id;
	local handler = options.handler;

	if id:match(&quot;[^%d]&quot;) then													-- if PMID has anything but digits
		set_message ('err_bad_pmid');											-- set an error message
		options.coins_list_t['PMID'] = nil;										-- when error, unset so not included in COinS
	else																		-- PMID is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if PMID is outside test limit boundaries
			set_message ('err_bad_pmid');										-- set an error message
			options.coins_list_t['PMID'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; R F C &gt;------------------------------------------------------------------------

Format RFC and do simple error checking. RFCs are sequential numbers beginning at 1 and counting up.  This
code checks the RFC to see that it contains only digits and is less than test_limit specified in the configuration;
the value in test_limit will need to be updated periodically as more RFCs are issued.

An index of all RFCs is here: https://tools.ietf.org/rfc/

]]

local function rfc (options)
	local id = options.id;
	local handler = options.handler;

	if id:match(&quot;[^%d]&quot;) then													-- if RFC has anything but digits
		set_message ('err_bad_rfc');											-- set an error message
		options.coins_list_t['RFC'] = nil;										-- when error, unset so not included in COinS
	else																		-- RFC is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if RFC is outside test limit boundaries
			set_message ('err_bad_rfc');										-- set an error message
			options.coins_list_t['RFC'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access});
end


--[[--------------------------&lt; S 2 C I D &gt;--------------------------------------------------------------------

Format an S2CID, do simple error checking

S2CIDs are sequential numbers beginning at 1 and counting up.  This code checks the S2CID to see that it is only
digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically
as more S2CIDs are issued.

]]

local function s2cid (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local id_num;
	local text;
	
	id_num = id:match ('^[1-9]%d*$');											-- id must be all digits; must not begin with 0; no open access flag

 	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if handler.id_limit &lt; id_num then										-- if S2CID is outside test limit boundaries
			set_message ('err_bad_s2cid');										-- set an error message
			options.coins_list_t['S2CID'] = nil;								-- when error, unset so not included in COinS
		end
	else																		-- when id format incorrect
		set_message ('err_bad_s2cid');											-- set an error message
		options.coins_list_t['S2CID'] = nil;									-- when error, unset so not included in COinS
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});

	return text;
end


--[[--------------------------&lt; S B N &gt;------------------------------------------------------------------------

9-digit form of ISBN-10; uses same check-digit validation when SBN is prefixed with an additional '0' to make 10 digits

sbn value not made part of COinS metadata because we don't have a url or isn't a COinS-defined identifier (rft.xxx)
or an identifier registered at info-uri.info (info:)

]]

local function sbn (options)
	local id = options.id;
	local ignore_invalid = options.accept;
	local handler = options.handler;
	local function return_result (check, err_type)								-- local function to handle the various returns
		local SBN = internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,
						prefix = handler.prefix, id = id, separator = handler.separator});
		if not ignore_invalid then												-- if not ignoring SBN errors
			if not check then
				options.coins_list_t['SBN'] = nil;								-- when error, unset so not included in COinS; not really necessary here because sbn not made part of COinS
				set_message ('err_bad_sbn', {err_type});						-- display an error message
				return SBN; 
			end
		else
			set_message ('maint_isbn_ignore');									-- add a maint category even when there is no error (ToDo: Possibly switch to separate message for SBNs only)
		end
		return SBN;
	end

	if id:match ('[^%s-0-9X]') then
		return return_result (false, cfg.err_msg_supl.char);					-- fail if SBN contains anything but digits, hyphens, or the uppercase X
	end

	local ident = id:gsub ('[%s-]', '');										-- remove hyphens and whitespace; they interfere with the rest of the tests

	if  9 ~= ident:len() then
		return return_result (false, cfg.err_msg_supl.length);					-- fail if incorrect length
	end

	if ident:match ('^%d*X?$') == nil then
		return return_result (false, cfg.err_msg_supl.form);					-- fail if SBN has 'X' anywhere but last position
	end

	return return_result (is_valid_isxn ('0' .. ident, 10), cfg.err_msg_supl.check);
end


--[[--------------------------&lt; S S R N &gt;----------------------------------------------------------------------

Format an SSRN, do simple error checking

SSRNs are sequential numbers beginning at 100? and counting up.  This code checks the SSRN to see that it is
only digits and is greater than 99 and less than test_limit; the value in local variable test_limit will need
to be updated periodically as more SSRNs are issued.

]]

local function ssrn (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;
	local text;
	
	id_num = id:match ('^%d+$');												-- id must be all digits

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if 100 &gt; id_num or handler.id_limit &lt; id_num then						-- if SSRN is outside test limit boundaries
			set_message ('err_bad_ssrn');										-- set an error message
			options.coins_list_t['SSRN'] = nil;									-- when error, unset so not included in COinS
		end
	else																		-- when id format incorrect
		set_message ('err_bad_ssrn');											-- set an error message
		options.coins_list_t['SSRN'] = nil;										-- when error, unset so not included in COinS
	end
	
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = options.access});

	return text;
end


--[[--------------------------&lt; U S E N E T _ I D &gt;------------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function usenet_id (options)
	local id = options.id;
	local handler = options.handler;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$') then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		set_message ('err_bad_usenet_id')										-- add an error message if the message id is invalid
		options.coins_list_t['USENETID'] = nil;									-- when error, unset so not included in COinS
	end 
	
	return text;
end


--[[--------------------------&lt; Z B L &gt;-----------------------------------------------------------------------

A numerical identifier in the form nnnn.nnnnn - leading zeros in the first quartet optional

format described here: http://emis.mi.sanu.ac.rs/ZMATH/zmath/en/help/search/

temporary format is apparently eight digits.  Anything else is an error

]]

local function zbl (options)
	local id = options.id;
	local handler = options.handler;

	if id:match('^%d%d%d%d%d%d%d%d$') then										-- is this identifier using temporary format?
		set_message ('maint_zbl');												-- yes, add maint cat
	elseif not id:match('^%d?%d?%d?%d%.%d%d%d%d%d$') then						-- not temporary, is it normal format?
		set_message ('err_bad_zbl');											-- no, set an error message
		options.coins_list_t['ZBL'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--============================&lt;&lt; I N T E R F A C E   F U N C T I O N S &gt;&gt;==========================================

--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message if more than one alias exists in args

]]

local function extract_ids (args)
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs (cfg.id_handlers) do										-- k is uppercase identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one (args, v.parameters, 'err_redundant_parameters' );		-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set (v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; E X T R A C T _ I D _ A C C E S S _ L E V E L S &gt;--------------------------------------

Fetches custom id access levels from arguments using configuration settings. Parameters which have a predefined access
level (e.g. arxiv) do not use this function as they are directly rendered as free without using an additional parameter.

returns a table of k/v pairs where k is same as the identifier's key in cfg.id_handlers and v is the assigned (valid) keyword

access-level values must match the case used in cfg.keywords_lists['id-access'] (lowercase unless there is some special reason for something else)

]]

local function extract_id_access_levels (args, id_list)
	local id_accesses_list = {};
	for k, v in pairs (cfg.id_handlers) do
		local access_param = v.custom_access;									-- name of identifier's access-level parameter
		if is_set (access_param) then
			local access_level = args[access_param];							-- get the assigned value if there is one
			if is_set (access_level) then
				if not in_array (access_level, cfg.keywords_lists['id-access']) then	-- exact match required
					set_message ('err_invalid_param_val', {access_param, access_level});	
					access_level = nil;											-- invalid so unset
				end
				if not is_set (id_list[k]) then									-- identifier access-level must have a matching identifier
					set_message ('err_param_access_requires_param', {k:lower()});	-- parameter name is uppercase in cfg.id_handlers (k); lowercase for error message
				end
				id_accesses_list[k] = cfg.keywords_xlate[access_level];			-- get translated keyword
			end
		end
	end
	return id_accesses_list;
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;----------------------------------------------------

render the identifiers into a sorted sequence table

&lt;ID_list_coins_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value
&lt;options_t&gt; is a table of various k/v option pairs provided in the call to new_build_id_list();
	modified by	this function and passed to all identifier rendering functions
&lt;access_levels_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value (if valid)

returns a sequence table of sorted (by hkey - 'handler' key) rendered identifier strings

]]

local function build_id_list (ID_list_coins_t, options_t, access_levels_t)
	local ID_list_t = {};
	local accept;
	local func_map = {															--function map points to functions associated with hkey identifier
		['ARXIV'] = arxiv,
		['ASIN'] = asin,
		['BIBCODE'] = bibcode,
		['BIORXIV'] = biorxiv,
		['CITESEERX'] = citeseerx,
		['DOI'] = doi,
		['EISSN'] = issn,
		['HDL'] = hdl,
		['ISBN'] = isbn,
		['ISMN'] = ismn,
		['ISSN'] = issn,
		['JFM'] = jfm,
		['JSTOR'] = jstor,
		['LCCN'] = lccn,
		['MEDRXIV'] = medrxiv,
		['MR'] = mr,
		['OCLC'] = oclc,
		['OL'] = openlibrary,
		['OSTI'] = osti,
		['PMC'] = pmc,
		['PMID'] = pmid,
		['RFC']  = rfc,
		['S2CID'] = s2cid,
		['SBN'] = sbn,
		['SSRN'] = ssrn,
		['USENETID'] = usenet_id,
		['ZBL'] = zbl,
		}

	for hkey, v in pairs (ID_list_coins_t) do
		v, accept = has_accept_as_written (v);									-- remove accept-as-written markup if present; accept is boolean true when markup removed; false else
																				-- every function gets the options table with value v and accept boolean
		options_t.hkey = hkey;													-- ~/Configuration handler key
		options_t.id = v;														-- add that identifier value to the options table
		options_t.accept = accept;												-- add the accept boolean flag
		options_t.access = access_levels_t[hkey];								-- add the access level for those that have an |&lt;identifier-access= parameter
		options_t.handler = cfg.id_handlers[hkey];
		options_t.coins_list_t = ID_list_coins_t;								-- pointer to ID_list_coins_t; for |asin= and |ol=; also to keep erroneous values out of the citation's metadata
		options_t.coins_list_t[hkey] = v;										-- id value without accept-as-written markup for metadata
		
		if options_t.handler.access and not in_array (options_t.handler.access, cfg.keywords_lists['id-access']) then
			error (cfg.messages['unknown_ID_access'] .. options_t.handler.access);	-- here when handler access key set to a value not listed in list of allowed id access keywords
		end

		if func_map[hkey] then
			local id_text = func_map[hkey] (options_t);							-- call the function to get identifier text and any error message
			table.insert (ID_list_t, {hkey, id_text});							-- add identifier text to the output sequence table
		else
			error (cfg.messages['unknown_ID_key'] .. hkey);						-- here when func_map doesn't have a function for hkey
		end
	end

	local function comp (a, b)													-- used by following table.sort()
		return a[1]:lower() &lt; b[1]:lower();										-- sort by hkey
	end

	table.sort (ID_list_t, comp);												-- sequence table of tables sort	
	for k, v in ipairs (ID_list_t) do											-- convert sequence table of tables to simple sequence table of strings
		ID_list_t[k] = v[2];													-- v[2] is the identifier rendering from the call to the various functions in func_map{}
	end
	
	return ID_list_t;
end


--[[--------------------------&lt; O P T I O N S _ C H E C K &gt;----------------------------------------------------

check that certain option parameters have their associated identifier parameters with values

&lt;ID_list_coins_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value
&lt;ID_support_t&gt; is a sequence table of tables created in citation0() where each subtable has four elements:
	[1] is the support parameter's assigned value; empty string if not set
	[2] is a text string same as key in cfg.id_handlers
	[3] is cfg.error_conditions key used to create error message
	[4] is original ID support parameter name used to create error message
	
returns nothing; on error emits an appropriate error message

]]

local function options_check (ID_list_coins_t, ID_support_t)
	for _, v in ipairs (ID_support_t) do
		if is_set (v[1]) and not ID_list_coins_t[v[2]] then						-- when support parameter has a value but matching identifier parameter is missing or empty
			set_message (v[3], (v[4]));											-- emit the appropriate error message
		end
	end
end


--[[--------------------------&lt; I D E N T I F I E R _ L I S T S _ G E T &gt;--------------------------------------

Creates two identifier lists: a k/v table of identifiers and their values to be used locally and for use in the
COinS metadata, and a sequence table of the rendered identifier strings that will be included in the rendered
citation.

]]

local function identifier_lists_get (args_t, options_t, ID_support_t)
	local ID_list_coins_t = extract_ids (args_t);										-- get a table of identifiers and their values for use locally and for use in COinS
	options_check (ID_list_coins_t, ID_support_t);										-- ID support parameters must have matching identifier parameters 
	local ID_access_levels_t = extract_id_access_levels (args_t, ID_list_coins_t);		-- get a table of identifier access levels
	local ID_list_t = build_id_list (ID_list_coins_t, options_t, ID_access_levels_t);	-- get a sequence table of rendered identifier strings

	return ID_list_t, ID_list_coins_t;											-- return the tables
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	has_accept_as_written = utilities_page_ptr.has_accept_as_written;			-- import functions from select Module:Citation/CS1/Utilities module
	is_set = utilities_page_ptr.is_set;								
	in_array = utilities_page_ptr.in_array;
	set_message = utilities_page_ptr.set_message;
	select_one = utilities_page_ptr.select_one;
	substitute = utilities_page_ptr.substitute;
	make_wikilink = utilities_page_ptr.make_wikilink;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	auto_link_urls = auto_link_urls,											-- table of identifier URLs to be used when auto-linking |title=
	
	identifier_lists_get = identifier_lists_get,								-- experiment to replace individual calls to build_id_list(), extract_ids, extract_id_access_levels
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>hjarco8e2706jgk6fa0c38cbw48m0km</sha1>
    </revision>
    <revision>
      <id>4928</id>
      <parentid>4927</parentid>
      <timestamp>2025-04-12T13:48:49Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4928</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="77991" sha1="o8oo86ygkuhh5243vjacxy8oq2dgyrl" xml:space="preserve">--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local has_accept_as_written, is_set, in_array, set_message, select_one,			-- functions in Module:Citation/CS1/Utilities
		substitute, make_wikilink;

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

declare variables here that have page-wide scope that are not brought in from other modules; that are created here and used here

]]

local auto_link_urls = {};														-- holds identifier URLs for those identifiers that can auto-link |title=


--============================&lt;&lt; H E L P E R   F U N C T I O N S &gt;&gt;============================================

--[[--------------------------&lt; W I K I D A T A _ A R T I C L E _ N A M E _ G E T &gt;----------------------------

as an aid to internationalizing identifier-label wikilinks, gets identifier article names from Wikidata.

returns :&lt;lang code&gt;:&lt;article title&gt; when &lt;q&gt; has an &lt;article title&gt; for &lt;lang code&gt;; nil else

for identifiers that do not have q, returns nil

for wikis that do not have mw.wikibase installed, returns nil

]]

local function wikidata_article_name_get (q)
	if not is_set (q) or (q and not mw.wikibase) then							-- when no q number or when a q number but mw.wikibase not installed on this wiki
		return nil;																-- abandon
	end

	local wd_article;
	local this_wiki_code = cfg.this_wiki_code;									-- Wikipedia subdomain; 'en' for en.wikipedia.org

	wd_article = mw.wikibase.getSitelink (q, this_wiki_code .. 'wiki');			-- fetch article title from WD; nil when no title available at this wiki

	if wd_article then
		wd_article = table.concat ({':', this_wiki_code, ':', wd_article});		-- interwiki-style link without brackets if taken from WD; leading colon required
	end

	return wd_article;															-- article title from WD; nil else
end


--[[--------------------------&lt; L I N K _ L A B E L _ M A K E &gt;------------------------------------------------

common function to create identifier link label from handler table or from Wikidata

returns the first available of
	1. redirect from local wiki's handler table (if enabled)
	2. Wikidata (if there is a Wikidata entry for this identifier in the local wiki's language)
	3. label specified in the local wiki's handler table
	
]]

local function link_label_make (handler)
	local wd_article;
	
	if not (cfg.use_identifier_redirects and is_set (handler.redirect)) then	-- redirect has priority so if enabled and available don't fetch from Wikidata because expensive
		wd_article = wikidata_article_name_get (handler.q);						-- if Wikidata has an article title for this wiki, get it;
	end
	
	return (cfg.use_identifier_redirects and is_set (handler.redirect) and handler.redirect) or wd_article or handler.link;
end


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki-style external link

]]

local function external_link_id (options)
	local url_string = options.id;
	local ext_link;
	local this_wiki_code = cfg.this_wiki_code;									-- Wikipedia subdomain; 'en' for en.wikipedia.org
	local wd_article;															-- article title from Wikidata
	
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode (url_string, 'PATH');
	end

	if options.auto_link and is_set (options.access) then
		auto_link_urls[options.auto_link] = table.concat ({options.prefix, url_string, options.suffix});
	end

	ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or &quot;&quot;, mw.text.nowiki (options.id));
	if is_set (options.access) then
		ext_link = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[options.access].class, cfg.presentation[options.access].title, ext_link});	-- add the free-to-read / paywall lock
	end

	return table.concat	({
		make_wikilink (link_label_make (options), options.label),				-- redirect, Wikidata link, or locally specified link (in that order)
		options.separator or '&amp;nbsp;',
		ext_link
		});
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki-style internal link

TODO: Does not currently need to support options.access, options.encode, auto-linking and COinS (as in external_link_id),
but may be needed in the future for :m:Interwiki_map custom-prefixes like :arxiv:, :bibcode:, :DOI:, :hdl:, :ISSN:,
:JSTOR:, :Openlibrary:, :PMID:, :RFC:.

]]

local function internal_link_id (options)
	local id = mw.ustring.gsub (options.id, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9

	return table.concat (
		{
		make_wikilink (link_label_make (options), options.label),				-- wiki-link the identifier label
		options.separator or '&amp;nbsp;',											-- add the separator
		make_wikilink (
			table.concat (
				{
				options.prefix,
				id,																-- translated to Western digits
				options.suffix or ''
				}),
			substitute (cfg.presentation['bdi'], {'', mw.text.nowiki (options.id)})	-- bdi tags to prevent Latin script identifiers from being reversed at RTL language wikis
			);																	-- nowiki because MediaWiki still has magic links for ISBN and the like; TODO: is it really required?
		});
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |pmc-embargo-date= against
today's date.  If embargo date is in the future, returns the content of |pmc-embargo-date=; otherwise, returns
an empty string because the embargo has expired or because |pmc-embargo-date= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, todays_date;
		good1, embargo_date = pcall (lang.formatDate, lang, 'U', embargo);
		todays_date = lang:formatDate ('U');
	
		if good1 then															-- if embargo date is a good date
			if tonumber (embargo_date) &gt;= tonumber (todays_date) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				set_message ('maint_pmc_embargo');								-- embargo has expired; add main cat
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |pmc-embargo-date= not set return empty string
end


--[=[-------------------------&lt; I S _ V A L I D _ R X I V _ D A T E &gt;------------------------------------------

for biorxiv, returns true if:
	2019-12-11T00:00Z &lt;= biorxiv_date &lt; today + 2 days
for medrxiv, returns true if:
	2020-01-01T00:00Z &lt;= medrxiv_date &lt; today + 2 days
	
The dated form of biorxiv identifier has a start date of 2019-12-11.  The Unix timestamp for that date is {{#time:U|2019-12-11}} = 1576022400
The medrxiv identifier has a start date of 2020-01-01.  The Unix timestamp for that date is {{#time:U|2020-01-01}} = 1577836800

&lt;rxiv_date&gt; is the date provided in those |biorxiv= parameter values that are dated and in |medrxiv= parameter values at time 00:00:00 UTC
&lt;today&gt; is the current date at time 00:00:00 UTC plus 48 hours
	if today's date is 2023-01-01T00:00:00 then
		adding 24 hours gives 2023-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2023-01-03T00:00:00 – one second more than tomorrow

inputs:
	&lt;y&gt;, &lt;m&gt;, &lt;d&gt; – year, month, day parts of the date from the birxiv or medrxiv identifier
	&lt;select&gt; 'b' for biorxiv, 'm' for medrxiv; defaults to 'b'

]=]

local function is_valid_rxiv_date (y, m, d, select)
	if 0 == tonumber (m) and 12 &lt; tonumber (m) then								-- &lt;m&gt; must be a number 1–12
		return false;
	end
	if 0 == tonumber (d) and 31 &lt; tonumber (d) then								-- &lt;d&gt; must be a number 1–31; TODO: account for month length and leap yer?
		return false;
	end
	
	local rxiv_date = table.concat ({y, m, d}, '-');							-- make ymd date string
	local good1, good2;
	local rxiv_ts, tomorrow_ts;													-- to hold Unix timestamps representing the dates
	local lang_object = mw.getContentLanguage();

	good1, rxiv_ts = pcall (lang_object.formatDate, lang_object, 'U', rxiv_date);		-- convert rxiv_date value to Unix timestamp 
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which tonumber() may not understand
		rxiv_ts = tonumber (rxiv_ts) or lang_object:parseFormattedNumber (rxiv_ts);	-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to Unix timestamp
	end

	local limit_ts = ((select and ('m' == select)) and 1577836800) or 1576022400;	-- choose the appropriate limit timesatmp

	return ((limit_ts &lt;= rxiv_ts) and (rxiv_ts &lt; tomorrow_ts))					-- limit_ts &lt;= rxiv_date &lt; tomorrow's date
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all ISBN/ISSN digits including the check digit.
ISBN-13 is checked in isbn().

If the number is valid the result will be 0. Before calling this function, ISBN/ISSN must be checked for length
and stripped of dashes, spaces and other non-ISxN characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39, 'X' → 0x58
	len = len + 1;																-- adjust to be a loop counter
	for i, v in ipairs (isxn_str) do											-- loop through all of the bytes and calculate the checksum
		if v == string.byte (&quot;X&quot; ) then											-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10 * (len - i);										-- it represents 10 decimal
		else
			temp = temp + tonumber (string.char (v) )*(len-i);
		end
	end
	return temp % 11 == 0;														-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N _ 1 3 &gt;-----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 ISBN/ISMN digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, ISBN-13/ISMN must be checked for length
and stripped of dashes, spaces and other non-ISxN-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39
	for i, v in ipairs (isxn_str) do
		temp = temp + (3 - 2*(i % 2)) * tonumber (string.char (v) );			-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when ISBN-13/ISMN is correct
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

LCCN normalization (https://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized LCCN for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.

]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);												-- 1. strip whitespace

	if nil ~= string.find (lccn, '/') then
		lccn = lccn:match (&quot;(.-)/&quot;);											-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);									-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then														-- if there was a hyphen
		suffix = string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;				-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn = prefix..suffix;													-- reassemble the LCCN
	end
	
	return lccn;
end


--============================&lt;&lt; I D E N T I F I E R   F U N C T I O N S &gt;&gt;====================================

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: https://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9107 and 0703, is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation; not the same as |class= parameter which is not supported in this form
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number

]]

local function arxiv (options)
	local id = options.id;
	local class = options.Class;												-- TODO: lowercase?
	local handler = options.handler;
	local year, month, version;
	local err_msg = false;														-- assume no error message
	local text;																	-- output text
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9107-0703 format with or without version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_msg = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 with or without version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then									-- when year is 07, is month invalid (before April)?
				err_msg = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format with or without version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_msg = true;														-- flag for error message
		end

	else
		err_msg = true;															-- not a recognized format; flag for error message
	end

	if err_msg then
		options.coins_list_t['ARXIV'] = nil;									-- when error, unset so not included in COinS
	end
	
	local err_msg_t = {};
	if err_msg then
		set_message ('err_bad_arxiv');
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access});

	if is_set (class) then
		if id:match ('^%d+') then
			text = table.concat ({text, ' [[https://arxiv.org/archive/', class, ' ', class, ']]'});	-- external link within square brackets, not wikilink
		else
			set_message ('err_class_ignored');
		end
	end

	return text;
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode ID.

Format for bibcodes is specified here: https://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		9–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local ignore_invalid = options.accept;
	local err_type;
	local err_msg = '';
	local year;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode,
		access = access});
	
	if 19 ~= id:len() then
		err_type = cfg.err_msg_supl.length;
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%w&amp;%.][%w&amp;%.][%w&amp;%.][%w.]+[%a%.]$&quot;);
		if not year then														-- if nil then no pattern match
			err_type = cfg.err_msg_supl.value;									-- so value error
		else
			local next_year = tonumber (os.date ('%Y')) + 1;					-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = cfg.err_msg_supl.year;								-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = cfg.err_msg_supl.journal;							-- journal abbreviation must not have '&amp;.' (if it does it's missing a letter)
			end
			if id:match ('.........%.tmp%.') then								-- temporary bibcodes when positions 10–14 are '.tmp.'
				set_message ('maint_bibcode');
			end
		end
	end

	if is_set (err_type) and not ignore_invalid then							-- if there was an error detected and accept-as-written markup not used
		set_message ('err_bad_bibcode', {err_type});
		options.coins_list_t['BIBCODE'] = nil;									-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; B I O R X I V &gt;-----------------------------------------------------------------

Format bioRxiv ID and do simple error checking.  Before 2019-12-11, biorXiv IDs were 10.1101/ followed by exactly
6 digits.  After 2019-12-11, biorXiv IDs retained the six-digit identifier but prefixed that with a yyyy.mm.dd. 
date and suffixed with an optional version identifier.

The bioRxiv ID is the string of characters:
	https://doi.org/10.1101/078733 -&gt; 10.1101/078733
or a date followed by a six-digit number followed by an optional version indicator 'v' and one or more digits:
	https://www.biorxiv.org/content/10.1101/2019.12.11.123456v2 -&gt; 10.1101/2019.12.11.123456v2
	
see https://www.biorxiv.org/about-biorxiv

]]

local function biorxiv (options)
	local id = options.id;
	local handler = options.handler;
	local err_msg = true;														-- flag; assume that there will be an error
	
	local patterns = {
		'^10%.1101/%d%d%d%d%d%d$',												-- simple 6-digit identifier (before 2019-12-11)
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%dv%d+$',				-- y.m.d. date + 6-digit identifier + version (after 2019-12-11)
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%d$',					-- y.m.d. date + 6-digit identifier (after 2019-12-11)
		}
	
	for _, pattern in ipairs (patterns) do										-- spin through the patterns looking for a match
		if id:match (pattern) then
			local y, m, d = id:match (pattern);									-- found a match, attempt to get year, month and date from the identifier

			if m then															-- m is nil when id is the six-digit form
				if not is_valid_rxiv_date (y, m, d, 'b') then					-- validate the encoded date; 'b' for biorxiv limit
					break;														-- date fail; break out early so we don't unset the error message
				end
			end
			err_msg = nil;														-- we found a match so unset the error message
			break;																-- and done
		end
	end																			-- err_cat remains set here when no match

	if err_msg then
		options.coins_list_t['BIORXIV'] = nil;									-- when error, unset so not included in COinS
		set_message ('err_bad_biorxiv');										-- and set the error message
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator,
			encode = handler.encode, access = handler.access});
end


--[[--------------------------&lt; C I T E S E E R X &gt;------------------------------------------------------------

CiteSeerX use their own notion of &quot;doi&quot; (not to be confused with the identifiers resolved via doi.org).

The description of the structure of this identifier can be found at Help_talk:Citation_Style_1/Archive_26#CiteSeerX_id_structure

]]

local function citeseerx (options)
	local id = options.id;
	local handler = options.handler;
	local matched;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode,
		access = handler.access});
	
	matched = id:match (&quot;^10%.1%.1%.[1-9]%d?%d?%d?%.[1-9]%d?%d?%d?$&quot;);
	if not matched then
		set_message ('err_bad_citeseerx' );
		options.coins_list_t['CITESEERX'] = nil;								-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the DOI name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in DOI names.

https://www.doi.org/doi_handbook/2_Numbering.html				-- 2.2 Syntax of a DOI name
https://www.doi.org/doi_handbook/2_Numbering.html#2.2.2			-- 2.2.2 DOI prefix

]]

local function doi (options)
	local id = options.id;
	local inactive = options.DoiBroken
	local access = options.access;
	local ignore_invalid = options.accept;
	local handler = options.handler;
	local err_flag;

	local function is_extended_free (registrant, suffix)						-- local function to check those few registrants that are mixed; identifiable by the doi suffix &lt;incipit&gt;
		if cfg.extended_registrants_t[registrant] then							-- if this registrant has known free-to-read extentions
			for _, incipit in ipairs (cfg.extended_registrants_t[registrant]) do	-- loop through the registrant's incipits
				if mw.ustring.find (suffix, '^' .. incipit) then				-- if found
					return true;
				end
			end
		end
	end

	local text;
	if is_set (inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;);						-- try to get the year portion from the inactive date
		local inactive_month, good;

		if is_set (inactive_year) then
			if 4 &lt; inactive:len() then											-- inactive date has more than just a year (could be anything)
				local lang_obj = mw.getContentLanguage();						-- get a language object for this wiki
				good, inactive_month = pcall (lang_obj.formatDate, lang_obj, 'F', inactive);	-- try to get the month name from the inactive date
				if not good then
					inactive_month = nil;										-- something went wrong so make sure this is unset
				end
			end
		end																		-- otherwise, |doi-broken-date= has something but it isn't a date
		
		if is_set (inactive_year) and is_set (inactive_month) then
			set_message ('maint_doi_inactive_dated', {inactive_year, inactive_month, ' '});
		elseif is_set (inactive_year) then
			set_message ('maint_doi_inactive_dated', {inactive_year, '', ''});
		else
			set_message ('maint_doi_inactive');
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. ' ' .. inactive .. ')';
	end

	local suffix;
	local registrant, suffix = mw.ustring.match (id, '^10%.([^/]+)/([^%s–]-[^%.,])$');	-- registrant and suffix set when DOI has the proper basic form

	local registrant_err_patterns = {											-- these patterns are for code ranges that are not supported 
		'^[^1-3]%d%d%d%d%.%d+$',												-- 5 digits with subcode (0xxxx, 40000+); accepts: 10000–39999
		'^[^1-7]%d%d%d%d$',														-- 5 digits without subcode (0xxxx, 60000+); accepts: 10000–69999
		'^[^1-9]%d%d%d%.%d+$',												-- 4 digits with subcode (0xxx); accepts: 1000–9999
		'^[^1-9]%d%d%d$',														-- 4 digits without subcode (0xxx); accepts: 1000–9999
		'^%d%d%d%d%d%d+',														-- 6 or more digits
		'^%d%d?%d?$',															-- less than 4 digits without subcode (3 digits with subcode is legitimate)
		'^%d%d?%.[%d%.]+',														-- 1 or 2 digits with subcode
		'^5555$',																-- test registrant will never resolve
		'[^%d%.]',																-- any character that isn't a digit or a dot
		}

	if not ignore_invalid then
		if registrant then														-- when DOI has proper form
			for i, pattern in ipairs (registrant_err_patterns) do				-- spin through error patterns
				if registrant:match (pattern) then								-- to validate registrant codes
					err_flag = set_message ('err_bad_doi');						-- when found, mark this DOI as bad
					break;														-- and done
				end
			end
		else
			err_flag = set_message ('err_bad_doi');								-- invalid directory or malformed
		end
	else
		set_message ('maint_doi_ignore');
	end

	if err_flag then
		options.coins_list_t['DOI'] = nil;										-- when error, unset so not included in COinS
	else
		if not access and (cfg.known_free_doi_registrants_t[registrant] or is_extended_free (registrant, suffix)) then		-- |doi-access=free not set and &lt;registrant&gt; is known to be free
			set_message ('maint_doi_unflagged_free');							-- set a maint cat
		end
	end
	
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access,
		auto_link = not (err_flag or is_set (inactive) or ignore_invalid) and 'doi' or nil -- do not auto-link when |doi-broken-date= has a value or when there is a DOI error or (to play it safe, after all, auto-linking is not essential) when invalid DOIs are ignored
		}) .. (inactive or '');

	return text;
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

Query string parameters are named here: https://www.handle.net/proxy_servlet.html.  query strings are not displayed
but since '?' is an allowed character in an HDL, '?' followed by one of the query parameters is the only way we
have to detect the query string so that it isn't URL-encoded with the rest of the identifier.

]]

local function hdl (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local query_params = {														-- list of known query parameters from https://www.handle.net/proxy_servlet.html
		'noredirect',
		'ignore_aliases',
		'auth',
		'cert',
		'index',
		'type',
		'urlappend',
		'locatt',
		'action',
		}
	
	local hdl, suffix, param = id:match ('(.-)(%?(%a+).+)$');					-- look for query string
	local found;

	if hdl then																	-- when there are query strings, this is the handle identifier portion
		for _, q in ipairs (query_params) do									-- spin through the list of query parameters
			if param:match ('^' .. q) then										-- if the query string begins with one of the parameters
				found = true;													-- announce a find
				break;															-- and stop looking
			end
		end
	end

	if found then
		id = hdl;																-- found so replace id with the handle portion; this will be URL-encoded, suffix will not
	else
		suffix = '';															-- make sure suffix is empty string for concatenation else
	end

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, suffix = suffix, separator = handler.separator, encode = handler.encode, access = access})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- HDL must contain a forward slash, must not contain spaces, endashes, and must not end with period or comma
		set_message ('err_bad_hdl' );
		options.coins_list_t['HDL'] = nil;										-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; I S B N &gt;----------------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function isbn (options_t)
	local isbn_str = options_t.id;
	local ignore_invalid = options_t.accept;
	local handler = options_t.handler;
	local year = options_t.Year;												-- when set, valid anchor_year; may have a disambiguator which must be removed

	local function return_result (check, err_type)								-- local function to handle the various returns
		local ISBN = internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,
						prefix = handler.prefix, id = isbn_str, separator = handler.separator});
		if ignore_invalid then													-- if ignoring ISBN errors
			set_message ('maint_isbn_ignore');									-- add a maint category even when there is no error
		else																	-- here when not ignoring
			if not check then													-- and there is an error
				options_t.coins_list_t['ISBN'] = nil;								-- when error, unset so not included in COinS
				set_message ('err_bad_isbn', err_type);							-- set an error message
				return ISBN;										 			-- return id text
			end
		end
		return ISBN;															-- return id text
	end

	if year and not ignore_invalid then											-- 
		year = year:match ('%d%d%d%d');											-- strip disambiguator if present
		if 1965 &gt; tonumber(year) then
			set_message ('err_invalid_isbn_date');								-- set an error message
			return internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,
					prefix = handler.prefix, id = isbn_str, separator = handler.separator});
		end
	end

	if nil ~= isbn_str:match ('[^%s-0-9X]') then
		return return_result (false, cfg.err_msg_supl.char);					-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end

	local id = isbn_str:gsub ('[%s-]', '');										-- remove hyphens and whitespace

	local len = id:len();
 
	if len ~= 10 and len ~= 13 then
		return return_result (false, cfg.err_msg_supl.length);					-- fail if incorrect length
	end

	if len == 10 then
		if id:match ('^%d*X?$') == nil then										-- fail if isbn_str has 'X' anywhere but last position
			return return_result (false, cfg.err_msg_supl.form);									
		end
		if not is_valid_isxn (id, 10) then										-- test isbn-10 for numerical validity
			return return_result (false, cfg.err_msg_supl.check);				-- fail if isbn-10 is not numerically valid
		end
		if id:find ('^63[01]') then												-- 630xxxxxxx and 631xxxxxxx are (apparently) not valid isbn group ids but are used by amazon as numeric identifiers (asin)
			return return_result (false, cfg.err_msg_supl.group);				-- fail if isbn-10 begins with 630/1
		end
		return return_result (true, cfg.err_msg_supl.check);					-- pass if isbn-10 is numerically valid
	else
		if id:match ('^%d+$') == nil then
			return return_result (false, cfg.err_msg_supl.char);				-- fail if ISBN-13 is not all digits
		end
		if id:match ('^97[89]%d*$') == nil then
			return return_result (false, cfg.err_msg_supl.prefix);				-- fail when ISBN-13 does not begin with 978 or 979
		end
		if id:match ('^9790') then
			return return_result (false, cfg.err_msg_supl.group);				-- group identifier '0' is reserved to ISMN
		end
		return return_result (is_valid_isxn_13 (id), cfg.err_msg_supl.check);
	end
end


--[[--------------------------&lt; A S I N &gt;----------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: ASIN must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, ASINs must be 10-digit
ISBN. If 10-digit ISBN, add a maintenance category so a bot or AWB script can replace |asin= with |isbn=.
Error message if not 10 characters, if not ISBN-10, if mixed and first character is a digit.

|asin=630....... and |asin=631....... are (apparently) not a legitimate ISBN though it checksums as one; these
do not cause this function to emit the maint_asin message

This function is positioned here because it calls isbn()

]]

local function asin (options)
	local id = options.id;
	local domain = options.ASINTLD;
	
	local err_flag;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_flag = set_message ('err_bad_asin');								-- ASIN is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then							-- if 10-digit numeric (or 9 digits with terminal X)
			if is_valid_isxn (id, 10) then										-- see if ASIN value is or validates as ISBN-10
				if not id:find ('^63[01]') then									-- 630xxxxxxx and 631xxxxxxx are (apparently) not a valid isbn prefixes but are used by amazon as a numeric identifier
					err_flag = set_message ('err_bad_asin');					-- ASIN has ISBN-10 form but begins with something other than 630/1 so probably an isbn 
				end
			elseif not is_set (err_flag) then
				err_flag = set_message ('err_bad_asin');						-- ASIN is not ISBN-10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_flag = set_message ('err_bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if (not is_set (domain)) or in_array (domain, {'us'}) then					-- default: United States
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then									-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'z.cn'}) then 									-- China
		domain = &quot;cn&quot;;
	elseif in_array (domain, {'au', 'br', 'mx', 'sg', 'tr'}) then				-- Australia, Brazil, Mexico, Singapore, Turkey
		domain = &quot;com.&quot; .. domain;
	elseif not in_array (domain, {'ae', 'ca', 'cn', 'de', 'es', 'fr', 'in', 'it', 'nl', 'pl', 'sa', 'se', 'co.jp', 'co.uk', 'com', 'com.au', 'com.br', 'com.mx', 'com.sg', 'com.tr'}) then -- Arabic Emirates, Canada, China, Germany, Spain, France, Indonesia, Italy, Netherlands, Poland, Saudi Arabia, Sweden (as of 2021-03 Austria (.at), Liechtenstein (.li) and Switzerland (.ch) still redirect to the German site (.de) with special settings, so don't maintain local ASINs for them)
		err_flag = set_message ('err_bad_asin_tld');							-- unsupported asin-tld value
	end
	local handler = options.handler;

	if not is_set (err_flag) then
		options.coins_list_t['ASIN'] = handler.prefix .. domain .. &quot;/dp/&quot; .. id;	-- asin for coins
	else
		options.coins_list_t['ASIN'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix .. domain .. &quot;/dp/&quot;,
		id = id, encode = handler.encode, separator = handler.separator})
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to ISBN-13, ISMN is 13 digits beginning 979-0-... and uses the
same check digit calculations.  See https://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

ismn value not made part of COinS metadata because we don't have a url or isn't a COinS-defined identifier (rft.xxx)
or an identifier registered at info-uri.info (info:)

]]

local function ismn (options)
	local id = options.id;
	local handler = options.handler;
	local text;
	local valid_ismn = true;
	local id_copy;

	id_copy = id;																-- save a copy because this testing is destructive
	id = id:gsub ('[%s-]', '');													-- remove hyphens and white space

	if 13 ~= id:len() or id:match (&quot;^9790%d*$&quot; ) == nil then					-- ISMN must be 13 digits and begin with 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ISMN
	end

	--	text = internal_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,		-- use this (or external version) when there is some place to link to
	--		prefix = handler.prefix, id = id_copy, separator = handler.separator, encode = handler.encode})

	text = table.concat (														-- because no place to link to yet
		{
		make_wikilink (link_label_make (handler), handler.label),
		handler.separator,
		id_copy
		});

	if false == valid_ismn then
		options.coins_list_t['ISMN'] = nil;										-- when error, unset so not included in COinS; not really necessary here because ismn not made part of COinS
		set_message ('err_bad_ismn');											-- create an error message if the ISMN is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an ISSN.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [https://www.worldcat.org/issn/0819 4327 0819 4327]	-- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the ISSN midpoint.  It also validates the ISSN for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check ISSN error message.  The
ISSN is always displayed with a hyphen, even if the ISSN was given as a single group of 8 digits.

]]

local function issn (options)
	local id = options.id;
	local handler = options.handler;
	local ignore_invalid = options.accept;

	local issn_copy = id;														-- save a copy of unadulterated ISSN; use this version for display if ISSN does not validate
	local text;
	local valid_issn = true;

	id = id:gsub ('[%s-]', '');													-- remove hyphens and whitespace

	if 8 ~= id:len() or nil == id:match (&quot;^%d*X?$&quot; ) then						-- validate the ISSN: 8 digits long, containing only 0-9 or X in the last position
		valid_issn = false;														-- wrong length or improper character
	else
		valid_issn = is_valid_isxn (id, 8);										-- validate ISSN
	end

	if true == valid_issn then
		id = string.sub (id, 1, 4 ) .. &quot;-&quot; .. string.sub (id, 5 );				-- if valid, display correctly formatted version
	else
		id = issn_copy;															-- if not valid, show the invalid ISSN with error message
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode})

	if ignore_invalid then
		set_message ('maint_issn_ignore');
	else
		if false == valid_issn then
			options.coins_list_t['ISSN'] = nil;									-- when error, unset so not included in COinS
			set_message ('err_bad_issn', (options.hkey == 'EISSN') and 'e' or '');	-- create an error message if the ISSN is invalid
		end 
	end
	
	return text;
end


--[[--------------------------&lt; J F M &gt;-----------------------------------------------------------------------

A numerical identifier in the form nn.nnnn.nn

]]

local function jfm (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;

	id_num = id:match ('^[Jj][Ff][Mm](.*)$');									-- identifier with jfm prefix; extract identifier

	if is_set (id_num) then
		set_message ('maint_jfm_format');
	else																		-- plain number without JFM prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num and id_num:match('^%d%d%.%d%d%d%d%.%d%d$') then
		id = id_num;															-- jfm matches pattern
	else
		set_message ('err_bad_jfm' );											-- set an error message
		options.coins_list_t['JFM'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; J S T O R &gt;--------------------------------------------------------------------

Format a JSTOR with some error checking

]]

local function jstor (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;

	if id:find ('[Jj][Ss][Tt][Oo][Rr]') or id:find ('^https?://') or id:find ('%s') then
		set_message ('err_bad_jstor');											-- set an error message
		options.coins_list_t['JSTOR'] = nil;									-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});
end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
https://oclc-research.github.io/infoURI-Frozen/info-uri.info/info:lccn/reg.html

length = 8 then all digits
length = 9 then lccn[1] is lowercase alpha
length = 10 then lccn[1] and lccn[2] are both lowercase alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lowercase alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lowercase alpha

]]

local function lccn (options)
	local lccn = options.id;
	local handler = options.handler;
	local err_flag;																-- presume that LCCN is valid
	local id = lccn;															-- local copy of the LCCN

	id = normalize_lccn (id);													-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();														-- get the length of the LCCN

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits)
			err_flag = set_message ('err_bad_lccn');							-- set an error message
		end
	elseif 9 == len then														-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then							-- does it match our pattern?
			err_flag = set_message ('err_bad_lccn');							-- set an error message
		end
	elseif 10 == len then														-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then					-- ... see if it matches our pattern
				err_flag = set_message ('err_bad_lccn');						-- no match, set an error message
			end
		end
	elseif 11 == len then														-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_flag = set_message ('err_bad_lccn');							-- no match, set an error message
		end
	elseif 12 == len then														-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then						-- see if it matches our pattern
			err_flag = set_message ('err_bad_lccn');							-- no match, set an error message
		end
	else
		err_flag = set_message ('err_bad_lccn');								-- wrong length, set an error message
	end

	if not is_set (err_flag) and nil ~= lccn:find ('%s') then
		err_flag = set_message ('err_bad_lccn');								-- lccn contains a space, set an error message
	end

	if is_set (err_flag) then
		options.coins_list_t['LCCN'] = nil;										-- when error, unset so not included in COinS
	end

	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = lccn, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; M E D R X I V &gt;-----------------------------------------------------------------

Format medRxiv ID and do simple error checking.  Similar to later bioRxiv IDs, medRxiv IDs are prefixed with a
yyyy.mm.dd. date and suffixed with an optional version identifier.  Ealiest date accepted is 2020.01.01

The medRxiv ID is a date followed by an eight-digit number followed by an optional version indicator 'v' and one or more digits:
	https://www.medrxiv.org/content/10.1101/2020.11.16.20232009v2 -&gt; 10.1101/2020.11.16.20232009v2

]]

local function medrxiv (options)
	local id = options.id;
	local handler = options.handler;
	local err_msg_flag = true;													-- flag; assume that there will be an error

	local patterns = {
		'%d%d%d%d%d%d%d%d$',													-- simple 8-digit identifier; these should be relatively rare
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%d%d%dv%d+$',			-- y.m.d. date + 8-digit identifier + version (2020-01-01 and later)
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%d%d%d$',				-- y.m.d. date + 8-digit identifier (2020-01-01 and later)
		}
	
	for _, pattern in ipairs (patterns) do										-- spin through the patterns looking for a match
		if id:match (pattern) then
			local y, m, d = id:match (pattern);									-- found a match, attempt to get year, month and date from the identifier

			if m then															-- m is nil when id is the 8-digit form
				if not is_valid_rxiv_date (y, m, d, 'b') then					-- validate the encoded date; 'b' for medrxiv limit
					break;														-- date fail; break out early so we don't unset the error message
				end
			end
			err_msg_flag = nil;													-- we found a match so unset the error message
			break;																-- and done
		end
	end																			-- &lt;err_msg_flag&gt; remains set here when no match

	if err_msg_flag then
		options.coins_list_t['MEDRXIV'] = nil;									-- when error, unset so not included in COinS
		set_message ('err_bad_medrxiv');										-- and set the error message
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator,
			encode = handler.encode, access = handler.access});
end


--[[--------------------------&lt; M R &gt;--------------------------------------------------------------------------

A seven digit number; if not seven digits, zero-fill leading digits to make seven digits.

]]

local function mr (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;
	local id_len;

	id_num = id:match ('^[Mm][Rr](%d+)$');										-- identifier with mr prefix

	if is_set (id_num) then
		set_message ('maint_mr_format');										-- add maint cat
	else																		-- plain number without mr prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	id_len = id_num and id_num:len() or 0;
	if (7 &gt;= id_len) and (0 ~= id_len) then
		id = string.rep ('0', 7-id_len) .. id_num;								-- zero-fill leading digits
	else
		set_message ('err_bad_mr');												-- set an error message
		options.coins_list_t['MR'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an OCLC ID.  https://www.oclc.org/batchload/controlnumber.en.html {{dead link}}
archived at: https://web.archive.org/web/20161228233804/https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (options)
	local id = options.id;
	local handler = options.handler;
	local number;

	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- constrain to 1 to 9 digits; change this when OCLC issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if tonumber (id) &gt; handler.id_limit then
			number = nil;														-- unset when id value exceeds the limit
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		set_message ('err_bad_oclc')											-- add an error message if the id is malformed
		options.coins_list_t['OCLC'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local ident, code = id:gsub('^OL', ''):match(&quot;^(%d+([AMW]))$&quot;);				-- strip optional OL prefix followed immediately by digits followed by 'A', 'M', or 'W';
	local err_flag;
	local prefix = {															-- these are appended to the handler.prefix according to code
		['A']='authors/OL',
		['M']='books/OL',
		['W']='works/OL',
		['X']='OL'																-- not a code; spoof when 'code' in id is invalid
		};

	if not ident then
		code = 'X';																-- no code or id completely invalid
		ident = id;																-- copy id to ident so that we display the flawed identifier
		err_flag = set_message ('err_bad_ol');
	end

	if not is_set (err_flag) then
		options.coins_list_t['OL'] = handler.prefix .. prefix[code] .. ident;	-- experiment for ol coins
	else
		options.coins_list_t['OL'] = nil;										-- when error, unset so not included in COinS
	end

	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix .. prefix[code],
		id = ident, separator = handler.separator, encode = handler.encode,
		access = access});
end


--[[--------------------------&lt; O S T I &gt;----------------------------------------------------------------------

Format OSTI and do simple error checking. OSTIs are sequential numbers beginning at 1 and counting up.  This
code checks the OSTI to see that it contains only digits and is less than test_limit specified in the configuration;
the value in test_limit will need to be updated periodically as more OSTIs are issued.

NB. 1018 is the lowest OSTI number found in the wild (so far) and resolving OK on the OSTI site

]]

local function osti (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;

	if id:match(&quot;[^%d]&quot;) then													-- if OSTI has anything but digits
		set_message ('err_bad_osti');											-- set an error message
		options.coins_list_t['OSTI'] = nil;										-- when error, unset so not included in COinS
	else																		-- OSTI is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1018 &gt; id_num or handler.id_limit &lt; id_num then						-- if OSTI is outside test limit boundaries
			set_message ('err_bad_osti');										-- set an error message
			options.coins_list_t['OSTI'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc (options)
	local id = options.id;
	local embargo = options.Embargo;											-- TODO: lowercase?
	local handler = options.handler;
	local err_flag;
	local id_num;
	local text;

	id_num = id:match ('^[Pp][Mm][Cc](%d+)$');									-- identifier with PMC prefix

	if is_set (id_num) then
		set_message ('maint_pmc_format');
	else																		-- plain number without PMC prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if PMC is outside test limit boundaries
			err_flag = set_message ('err_bad_pmc');								-- set an error message
		else
			id = tostring (id_num);												-- make sure id is a string
		end
	else																		-- when id format incorrect
		err_flag = set_message ('err_bad_pmc');									-- set an error message
	end
	
	if is_set (embargo) and is_set (is_embargoed (embargo)) then				-- is PMC is still embargoed?
		text = table.concat (													-- still embargoed so no external link
			{
			make_wikilink (link_label_make (handler), handler.label),
			handler.separator,
			id,
			});
	else
		text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,	-- no embargo date or embargo has expired, ok to link to article
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access,
			auto_link = not err_flag and 'pmc' or nil							-- do not auto-link when PMC has error
			});
	end

	if err_flag then
		options.coins_list_t['PMC'] = nil;										-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid (options)
	local id = options.id;
	local handler = options.handler;

	if id:match(&quot;[^%d]&quot;) then													-- if PMID has anything but digits
		set_message ('err_bad_pmid');											-- set an error message
		options.coins_list_t['PMID'] = nil;										-- when error, unset so not included in COinS
	else																		-- PMID is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if PMID is outside test limit boundaries
			set_message ('err_bad_pmid');										-- set an error message
			options.coins_list_t['PMID'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; R F C &gt;------------------------------------------------------------------------

Format RFC and do simple error checking. RFCs are sequential numbers beginning at 1 and counting up.  This
code checks the RFC to see that it contains only digits and is less than test_limit specified in the configuration;
the value in test_limit will need to be updated periodically as more RFCs are issued.

An index of all RFCs is here: https://tools.ietf.org/rfc/

]]

local function rfc (options)
	local id = options.id;
	local handler = options.handler;

	if id:match(&quot;[^%d]&quot;) then													-- if RFC has anything but digits
		set_message ('err_bad_rfc');											-- set an error message
		options.coins_list_t['RFC'] = nil;										-- when error, unset so not included in COinS
	else																		-- RFC is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if RFC is outside test limit boundaries
			set_message ('err_bad_rfc');										-- set an error message
			options.coins_list_t['RFC'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access});
end


--[[--------------------------&lt; S 2 C I D &gt;--------------------------------------------------------------------

Format an S2CID, do simple error checking

S2CIDs are sequential numbers beginning at 1 and counting up.  This code checks the S2CID to see that it is only
digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically
as more S2CIDs are issued.

]]

local function s2cid (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local id_num;
	local text;
	
	id_num = id:match ('^[1-9]%d*$');											-- id must be all digits; must not begin with 0; no open access flag

 	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if handler.id_limit &lt; id_num then										-- if S2CID is outside test limit boundaries
			set_message ('err_bad_s2cid');										-- set an error message
			options.coins_list_t['S2CID'] = nil;								-- when error, unset so not included in COinS
		end
	else																		-- when id format incorrect
		set_message ('err_bad_s2cid');											-- set an error message
		options.coins_list_t['S2CID'] = nil;									-- when error, unset so not included in COinS
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});

	return text;
end


--[[--------------------------&lt; S B N &gt;------------------------------------------------------------------------

9-digit form of ISBN-10; uses same check-digit validation when SBN is prefixed with an additional '0' to make 10 digits

sbn value not made part of COinS metadata because we don't have a url or isn't a COinS-defined identifier (rft.xxx)
or an identifier registered at info-uri.info (info:)

]]

local function sbn (options)
	local id = options.id;
	local ignore_invalid = options.accept;
	local handler = options.handler;
	local function return_result (check, err_type)								-- local function to handle the various returns
		local SBN = internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,
						prefix = handler.prefix, id = id, separator = handler.separator});
		if not ignore_invalid then												-- if not ignoring SBN errors
			if not check then
				options.coins_list_t['SBN'] = nil;								-- when error, unset so not included in COinS; not really necessary here because sbn not made part of COinS
				set_message ('err_bad_sbn', {err_type});						-- display an error message
				return SBN; 
			end
		else
			set_message ('maint_isbn_ignore');									-- add a maint category even when there is no error (ToDo: Possibly switch to separate message for SBNs only)
		end
		return SBN;
	end

	if id:match ('[^%s-0-9X]') then
		return return_result (false, cfg.err_msg_supl.char);					-- fail if SBN contains anything but digits, hyphens, or the uppercase X
	end

	local ident = id:gsub ('[%s-]', '');										-- remove hyphens and whitespace; they interfere with the rest of the tests

	if  9 ~= ident:len() then
		return return_result (false, cfg.err_msg_supl.length);					-- fail if incorrect length
	end

	if ident:match ('^%d*X?$') == nil then
		return return_result (false, cfg.err_msg_supl.form);					-- fail if SBN has 'X' anywhere but last position
	end

	return return_result (is_valid_isxn ('0' .. ident, 10), cfg.err_msg_supl.check);
end


--[[--------------------------&lt; S S R N &gt;----------------------------------------------------------------------

Format an SSRN, do simple error checking

SSRNs are sequential numbers beginning at 100? and counting up.  This code checks the SSRN to see that it is
only digits and is greater than 99 and less than test_limit; the value in local variable test_limit will need
to be updated periodically as more SSRNs are issued.

]]

local function ssrn (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;
	local text;
	
	id_num = id:match ('^%d+$');												-- id must be all digits

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if 100 &gt; id_num or handler.id_limit &lt; id_num then						-- if SSRN is outside test limit boundaries
			set_message ('err_bad_ssrn');										-- set an error message
			options.coins_list_t['SSRN'] = nil;									-- when error, unset so not included in COinS
		end
	else																		-- when id format incorrect
		set_message ('err_bad_ssrn');											-- set an error message
		options.coins_list_t['SSRN'] = nil;										-- when error, unset so not included in COinS
	end
	
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = options.access});

	return text;
end


--[[--------------------------&lt; U S E N E T _ I D &gt;------------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function usenet_id (options)
	local id = options.id;
	local handler = options.handler;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$') then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		set_message ('err_bad_usenet_id')										-- add an error message if the message id is invalid
		options.coins_list_t['USENETID'] = nil;									-- when error, unset so not included in COinS
	end 
	
	return text;
end


--[[--------------------------&lt; Z B L &gt;-----------------------------------------------------------------------

A numerical identifier in the form nnnn.nnnnn - leading zeros in the first quartet optional

format described here: http://emis.mi.sanu.ac.rs/ZMATH/zmath/en/help/search/

temporary format is apparently eight digits.  Anything else is an error

]]

local function zbl (options)
	local id = options.id;
	local handler = options.handler;

	if id:match('^%d%d%d%d%d%d%d%d$') then										-- is this identifier using temporary format?
		set_message ('maint_zbl');												-- yes, add maint cat
	elseif not id:match('^%d?%d?%d?%d%.%d%d%d%d%d$') then						-- not temporary, is it normal format?
		set_message ('err_bad_zbl');											-- no, set an error message
		options.coins_list_t['ZBL'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--============================&lt;&lt; I N T E R F A C E   F U N C T I O N S &gt;&gt;==========================================

--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message if more than one alias exists in args

]]

local function extract_ids (args)
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs (cfg.id_handlers) do										-- k is uppercase identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one (args, v.parameters, 'err_redundant_parameters' );		-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set (v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; E X T R A C T _ I D _ A C C E S S _ L E V E L S &gt;--------------------------------------

Fetches custom id access levels from arguments using configuration settings. Parameters which have a predefined access
level (e.g. arxiv) do not use this function as they are directly rendered as free without using an additional parameter.

returns a table of k/v pairs where k is same as the identifier's key in cfg.id_handlers and v is the assigned (valid) keyword

access-level values must match the case used in cfg.keywords_lists['id-access'] (lowercase unless there is some special reason for something else)

]]

local function extract_id_access_levels (args, id_list)
	local id_accesses_list = {};
	for k, v in pairs (cfg.id_handlers) do
		local access_param = v.custom_access;									-- name of identifier's access-level parameter
		if is_set (access_param) then
			local access_level = args[access_param];							-- get the assigned value if there is one
			if is_set (access_level) then
				if not in_array (access_level, cfg.keywords_lists['id-access']) then	-- exact match required
					set_message ('err_invalid_param_val', {access_param, access_level});	
					access_level = nil;											-- invalid so unset
				end
				if not is_set (id_list[k]) then									-- identifier access-level must have a matching identifier
					set_message ('err_param_access_requires_param', {k:lower()});	-- parameter name is uppercase in cfg.id_handlers (k); lowercase for error message
				end
				id_accesses_list[k] = cfg.keywords_xlate[access_level];			-- get translated keyword
			end
		end
	end
	return id_accesses_list;
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;----------------------------------------------------

render the identifiers into a sorted sequence table

&lt;ID_list_coins_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value
&lt;options_t&gt; is a table of various k/v option pairs provided in the call to new_build_id_list();
	modified by	this function and passed to all identifier rendering functions
&lt;access_levels_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value (if valid)

returns a sequence table of sorted (by hkey - 'handler' key) rendered identifier strings

]]

local function build_id_list (ID_list_coins_t, options_t, access_levels_t)
	local ID_list_t = {};
	local accept;
	local func_map = {															--function map points to functions associated with hkey identifier
		['ARXIV'] = arxiv,
		['ASIN'] = asin,
		['BIBCODE'] = bibcode,
		['BIORXIV'] = biorxiv,
		['CITESEERX'] = citeseerx,
		['DOI'] = doi,
		['EISSN'] = issn,
		['HDL'] = hdl,
		['ISBN'] = isbn,
		['ISMN'] = ismn,
		['ISSN'] = issn,
		['JFM'] = jfm,
		['JSTOR'] = jstor,
		['LCCN'] = lccn,
		['MEDRXIV'] = medrxiv,
		['MR'] = mr,
		['OCLC'] = oclc,
		['OL'] = openlibrary,
		['OSTI'] = osti,
		['PMC'] = pmc,
		['PMID'] = pmid,
		['RFC']  = rfc,
		['S2CID'] = s2cid,
		['SBN'] = sbn,
		['SSRN'] = ssrn,
		['USENETID'] = usenet_id,
		['ZBL'] = zbl,
		}

	for hkey, v in pairs (ID_list_coins_t) do
		v, accept = has_accept_as_written (v);									-- remove accept-as-written markup if present; accept is boolean true when markup removed; false else
																				-- every function gets the options table with value v and accept boolean
		options_t.hkey = hkey;													-- ~/Configuration handler key
		options_t.id = v;														-- add that identifier value to the options table
		options_t.accept = accept;												-- add the accept boolean flag
		options_t.access = access_levels_t[hkey];								-- add the access level for those that have an |&lt;identifier-access= parameter
		options_t.handler = cfg.id_handlers[hkey];
		options_t.coins_list_t = ID_list_coins_t;								-- pointer to ID_list_coins_t; for |asin= and |ol=; also to keep erroneous values out of the citation's metadata
		options_t.coins_list_t[hkey] = v;										-- id value without accept-as-written markup for metadata
		
		if options_t.handler.access and not in_array (options_t.handler.access, cfg.keywords_lists['id-access']) then
			error (cfg.messages['unknown_ID_access'] .. options_t.handler.access);	-- here when handler access key set to a value not listed in list of allowed id access keywords
		end

		if func_map[hkey] then
			local id_text = func_map[hkey] (options_t);							-- call the function to get identifier text and any error message
			table.insert (ID_list_t, {hkey, id_text});							-- add identifier text to the output sequence table
		else
			error (cfg.messages['unknown_ID_key'] .. hkey);						-- here when func_map doesn't have a function for hkey
		end
	end

	local function comp (a, b)													-- used by following table.sort()
		return a[1]:lower() &lt; b[1]:lower();										-- sort by hkey
	end

	table.sort (ID_list_t, comp);												-- sequence table of tables sort	
	for k, v in ipairs (ID_list_t) do											-- convert sequence table of tables to simple sequence table of strings
		ID_list_t[k] = v[2];													-- v[2] is the identifier rendering from the call to the various functions in func_map{}
	end
	
	return ID_list_t;
end


--[[--------------------------&lt; O P T I O N S _ C H E C K &gt;----------------------------------------------------

check that certain option parameters have their associated identifier parameters with values

&lt;ID_list_coins_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value
&lt;ID_support_t&gt; is a sequence table of tables created in citation0() where each subtable has four elements:
	[1] is the support parameter's assigned value; empty string if not set
	[2] is a text string same as key in cfg.id_handlers
	[3] is cfg.error_conditions key used to create error message
	[4] is original ID support parameter name used to create error message
	
returns nothing; on error emits an appropriate error message

]]

local function options_check (ID_list_coins_t, ID_support_t)
	for _, v in ipairs (ID_support_t) do
		if is_set (v[1]) and not ID_list_coins_t[v[2]] then						-- when support parameter has a value but matching identifier parameter is missing or empty
			set_message (v[3], (v[4]));											-- emit the appropriate error message
		end
	end
end


--[[--------------------------&lt; I D E N T I F I E R _ L I S T S _ G E T &gt;--------------------------------------

Creates two identifier lists: a k/v table of identifiers and their values to be used locally and for use in the
COinS metadata, and a sequence table of the rendered identifier strings that will be included in the rendered
citation.

]]

local function identifier_lists_get (args_t, options_t, ID_support_t)
	local ID_list_coins_t = extract_ids (args_t);										-- get a table of identifiers and their values for use locally and for use in COinS
	options_check (ID_list_coins_t, ID_support_t);										-- ID support parameters must have matching identifier parameters 
	local ID_access_levels_t = extract_id_access_levels (args_t, ID_list_coins_t);		-- get a table of identifier access levels
	local ID_list_t = build_id_list (ID_list_coins_t, options_t, ID_access_levels_t);	-- get a sequence table of rendered identifier strings

	return ID_list_t, ID_list_coins_t;											-- return the tables
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	has_accept_as_written = utilities_page_ptr.has_accept_as_written;			-- import functions from select Module:Citation/CS1/Utilities module
	is_set = utilities_page_ptr.is_set;								
	in_array = utilities_page_ptr.in_array;
	set_message = utilities_page_ptr.set_message;
	select_one = utilities_page_ptr.select_one;
	substitute = utilities_page_ptr.substitute;
	make_wikilink = utilities_page_ptr.make_wikilink;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	auto_link_urls = auto_link_urls,											-- table of identifier URLs to be used when auto-linking |title=
	
	identifier_lists_get = identifier_lists_get,								-- experiment to replace individual calls to build_id_list(), extract_ids, extract_id_access_levels
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>o8oo86ygkuhh5243vjacxy8oq2dgyrl</sha1>
    </revision>
    <revision>
      <id>4929</id>
      <parentid>4928</parentid>
      <timestamp>2025-04-12T13:55:44Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4929</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="77991" sha1="9qo5fnpaokt9t66c7x4r4x2kojbx6pv" xml:space="preserve">--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local has_accept_as_written, is_set, in_array, set_message, select_one,			-- functions in Module:Citation/CS1/Utilities
		substitute, make_wikilink;

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

declare variables here that have page-wide scope that are not brought in from other modules; that are created here and used here

]]

local auto_link_urls = {};														-- holds identifier URLs for those identifiers that can auto-link |title=


--============================&lt;&lt; H E L P E R   F U N C T I O N S &gt;&gt;============================================

--[[--------------------------&lt; W I K I D A T A _ A R T I C L E _ N A M E _ G E T &gt;----------------------------

as an aid to internationalizing identifier-label wikilinks, gets identifier article names from Wikidata.

returns :&lt;lang code&gt;:&lt;article title&gt; when &lt;q&gt; has an &lt;article title&gt; for &lt;lang code&gt;; nil else

for identifiers that do not have q, returns nil

for wikis that do not have mw.wikibase installed, returns nil

]]

local function wikidata_article_name_get (q)
	if not is_set (q) or (q and not mw.wikibase) then							-- when no q number or when a q number but mw.wikibase not installed on this wiki
		return nil;																-- abandon
	end

	local wd_article;
	local this_wiki_code = cfg.this_wiki_code;									-- Wikipedia subdomain; 'en' for en.wikipedia.org

	wd_article = mw.wikibase.getSitelink (q, this_wiki_code .. 'wiki');			-- fetch article title from WD; nil when no title available at this wiki

	if wd_article then
		wd_article = table.concat ({':', this_wiki_code, ':', wd_article});		-- interwiki-style link without brackets if taken from WD; leading colon required
	end

	return wd_article;															-- article title from WD; nil else
end


--[[--------------------------&lt; L I N K _ L A B E L _ M A K E &gt;------------------------------------------------

common function to create identifier link label from handler table or from Wikidata

returns the first available of
	1. redirect from local wiki's handler table (if enabled)
	2. Wikidata (if there is a Wikidata entry for this identifier in the local wiki's language)
	3. label specified in the local wiki's handler table
	
]]

local function link_label_make (handler)
	local wd_article;
	
	if not (cfg.use_identifier_redirects and is_set (handler.redirect)) then	-- redirect has priority so if enabled and available don't fetch from Wikidata because expensive
		wd_article = wikidata_article_name_get (handler.q);						-- if Wikidata has an article title for this wiki, get it;
	end
	
	return (cfg.use_identifier_redirects and is_set (handler.redirect) and handler.redirect) or wd_article or handler.link;
end


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki-style external link

]]

local function external_link_id (options)
	local url_string = options.id;
	local ext_link;
	local this_wiki_code = cfg.this_wiki_code;									-- Wikipedia subdomain; 'en' for en.wikipedia.org
	local wd_article;															-- article title from Wikidata
	
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode (url_string, 'PATH');
	end

	if options.auto_link and is_set (options.access) then
		auto_link_urls[options.auto_link] = table.concat ({options.prefix, url_string, options.suffix});
	end

	ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or &quot;&quot;, mw.text.nowiki (options.id));
	if is_set (options.access) then
		ext_link = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[options.access].class, cfg.presentation[options.access].title, ext_link});	-- add the free-to-read / paywall lock
	end

	return table.concat	({
		make_wikilink (link_label_make (options), options.label),				-- redirect, Wikidata link, or locally specified link (in that order)
		options.separator or '&amp;nbsp;',
		ext_link
		});
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki-style internal link

TODO: Does not currently need to support options.access, options.encode, auto-linking and COinS (as in external_link_id),
but may be needed in the future for :m:Interwiki_map custom-prefixes like :arxiv:, :bibcode:, :DOI:, :hdl:, :ISSN:,
:JSTOR:, :Openlibrary:, :PMID:, :RFC:.

]]

local function internal_link_id (options)
	local id = mw.ustring.gsub (options.id, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9

	return table.concat (
		{
		make_wikilink (link_label_make (options), options.label),				-- wiki-link the identifier label
		options.separator or '&amp;nbsp;',											-- add the separator
		make_wikilink (
			table.concat (
				{
				options.prefix,
				id,																-- translated to Western digits
				options.suffix or ''
				}),
			substitute (cfg.presentation['bdi'], {'', mw.text.nowiki (options.id)})	-- bdi tags to prevent Latin script identifiers from being reversed at RTL language wikis
			);																	-- nowiki because MediaWiki still has magic links for ISBN and the like; TODO: is it really required?
		});
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |pmc-embargo-date= against
today's date.  If embargo date is in the future, returns the content of |pmc-embargo-date=; otherwise, returns
an empty string because the embargo has expired or because |pmc-embargo-date= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, todays_date;
		good1, embargo_date = pcall (lang.formatDate, lang, 'U', embargo);
		todays_date = lang:formatDate ('U');
	
		if good1 then															-- if embargo date is a good date
			if tonumber (embargo_date) &gt;= tonumber (todays_date) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				set_message ('maint_pmc_embargo');								-- embargo has expired; add main cat
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |pmc-embargo-date= not set return empty string
end


--[=[-------------------------&lt; I S _ V A L I D _ R X I V _ D A T E &gt;------------------------------------------

for biorxiv, returns true if:
	2019-12-11T00:00Z &lt;= biorxiv_date &lt; today + 2 days
for medrxiv, returns true if:
	2020-01-01T00:00Z &lt;= medrxiv_date &lt; today + 2 days
	
The dated form of biorxiv identifier has a start date of 2019-12-11.  The Unix timestamp for that date is {{#time:U|2019-12-11}} = 1576022400
The medrxiv identifier has a start date of 2020-01-01.  The Unix timestamp for that date is {{#time:U|2020-01-01}} = 1577836800

&lt;rxiv_date&gt; is the date provided in those |biorxiv= parameter values that are dated and in |medrxiv= parameter values at time 00:00:00 UTC
&lt;today&gt; is the current date at time 00:00:00 UTC plus 48 hours
	if today's date is 2023-01-01T00:00:00 then
		adding 24 hours gives 2023-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2023-01-03T00:00:00 – one second more than tomorrow

inputs:
	&lt;y&gt;, &lt;m&gt;, &lt;d&gt; – year, month, day parts of the date from the birxiv or medrxiv identifier
	&lt;select&gt; 'b' for biorxiv, 'm' for medrxiv; defaults to 'b'

]=]

local function is_valid_rxiv_date (y, m, d, select)
	if 0 == tonumber (m) and 12 &lt; tonumber (m) then								-- &lt;m&gt; must be a number 1–12
		return false;
	end
	if 0 == tonumber (d) and 31 &lt; tonumber (d) then								-- &lt;d&gt; must be a number 1–31; TODO: account for month length and leap yer?
		return false;
	end
	
	local rxiv_date = table.concat ({y, m, d}, '-');							-- make ymd date string
	local good1, good2;
	local rxiv_ts, tomorrow_ts;													-- to hold Unix timestamps representing the dates
	local lang_object = mw.getContentLanguage();

	good1, rxiv_ts = pcall (lang_object.formatDate, lang_object, 'U', rxiv_date);		-- convert rxiv_date value to Unix timestamp 
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which tonumber() may not understand
		rxiv_ts = tonumber (rxiv_ts) or lang_object:parseFormattedNumber (rxiv_ts);	-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to Unix timestamp
	end

	local limit_ts = ((select and ('m' == select)) and 1577836800) or 1576022400;	-- choose the appropriate limit timesatmp

	return ((limit_ts &lt;= rxiv_ts) and (rxiv_ts &lt; tomorrow_ts))					-- limit_ts &lt;= rxiv_date &lt; tomorrow's date
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all ISBN/ISSN digits including the check digit.
ISBN-13 is checked in isbn().

If the number is valid the result will be 0. Before calling this function, ISBN/ISSN must be checked for length
and stripped of dashes, spaces and other non-ISxN characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39, 'X' → 0x58
	len = len + 1;																-- adjust to be a loop counter
	for i, v in ipairs (isxn_str) do											-- loop through all of the bytes and calculate the checksum
		if v == string.byte (&quot;X&quot; ) then											-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10 * (len - i);										-- it represents 10 decimal
		else
			temp = temp + tonumber (string.char (v) )*(len-i);
		end
	end
	return temp % 11 == 0;														-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N _ 1 3 &gt;-----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 ISBN/ISMN digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, ISBN-13/ISMN must be checked for length
and stripped of dashes, spaces and other non-ISxN-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39
	for i, v in ipairs (isxn_str) do
		temp = temp + (3 - 2*(i % 2)) * tonumber (string.char (v) );			-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when ISBN-13/ISMN is correct
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

LCCN normalization (https://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized LCCN for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.

]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);												-- 1. strip whitespace

	if nil ~= string.find (lccn, '/') then
		lccn = lccn:match (&quot;(.-)/&quot;);											-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);									-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then														-- if there was a hyphen
		suffix = string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;				-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn = prefix..suffix;													-- reassemble the LCCN
	end
	
	return lccn;
end


--============================&lt;&lt; I D E N T I F I E R   F U N C T I O N S &gt;&gt;====================================

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: https://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9107 and 0703, is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation; not the same as |class= parameter which is not supported in this form
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number

]]

local function arxiv (options)
	local id = options.id;
	local class = options.Class;												-- TODO: lowercase?
	local handler = options.handler;
	local year, month, version;
	local err_msg = false;														-- assume no error message
	local text;																	-- output text
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9107-0703 format with or without version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_msg = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 with or without version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then									-- when year is 07, is month invalid (before April)?
				err_msg = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format with or without version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_msg = true;														-- flag for error message
		end

	else
		err_msg = true;															-- not a recognized format; flag for error message
	end

	if err_msg then
		options.coins_list_t['ARXIV'] = nil;									-- when error, unset so not included in COinS
	end
	
	local err_msg_t = {};
	if err_msg then
		set_message ('err_bad_arxiv');
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access});

	if is_set (class) then
		if id:match ('^%d+') then
			text = table.concat ({text, ' [[https://arxiv.org/archive/', class, ' ', class, ']]'});	-- external link within square brackets, not wikilink
		else
			set_message ('err_class_ignored');
		end
	end

	return text;
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode ID.

Format for bibcodes is specified here: https://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		9–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local ignore_invalid = options.accept;
	local err_type;
	local err_msg = '';
	local year;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode,
		access = access});
	
	if 19 ~= id:len() then
		err_type = cfg.err_msg_supl.length;
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%w&amp;%.][%w&amp;%.][%w&amp;%.][%w.]+[%a%.]$&quot;);
		if not year then														-- if nil then no pattern match
			err_type = cfg.err_msg_supl.value;									-- so value error
		else
			local next_year = tonumber (os.date ('%Y')) + 1;					-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = cfg.err_msg_supl.year;								-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = cfg.err_msg_supl.journal;							-- journal abbreviation must not have '&amp;.' (if it does it's missing a letter)
			end
			if id:match ('.........%.tmp%.') then								-- temporary bibcodes when positions 10–14 are '.tmp.'
				set_message ('maint_bibcode');
			end
		end
	end

	if is_set (err_type) and not ignore_invalid then							-- if there was an error detected and accept-as-written markup not used
		set_message ('err_bad_bibcode', {err_type});
		options.coins_list_t['BIBCODE'] = nil;									-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; B I O R X I V &gt;-----------------------------------------------------------------

Format bioRxiv ID and do simple error checking.  Before 2019-12-11, biorXiv IDs were 10.1101/ followed by exactly
6 digits.  After 2019-12-11, biorXiv IDs retained the six-digit identifier but prefixed that with a yyyy.mm.dd. 
date and suffixed with an optional version identifier.

The bioRxiv ID is the string of characters:
	https://doi.org/10.1101/078733 -&gt; 10.1101/078733
or a date followed by a six-digit number followed by an optional version indicator 'v' and one or more digits:
	https://www.biorxiv.org/content/10.1101/2019.12.11.123456v2 -&gt; 10.1101/2019.12.11.123456v2
	
see https://www.biorxiv.org/about-biorxiv

]]

local function biorxiv (options)
	local id = options.id;
	local handler = options.handler;
	local err_msg = true;														-- flag; assume that there will be an error
	
	local patterns = {
		'^10%.1101/%d%d%d%d%d%d$',												-- simple 6-digit identifier (before 2019-12-11)
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%dv%d+$',				-- y.m.d. date + 6-digit identifier + version (after 2019-12-11)
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%d$',					-- y.m.d. date + 6-digit identifier (after 2019-12-11)
		}
	
	for _, pattern in ipairs (patterns) do										-- spin through the patterns looking for a match
		if id:match (pattern) then
			local y, m, d = id:match (pattern);									-- found a match, attempt to get year, month and date from the identifier

			if m then															-- m is nil when id is the six-digit form
				if not is_valid_rxiv_date (y, m, d, 'b') then					-- validate the encoded date; 'b' for biorxiv limit
					break;														-- date fail; break out early so we don't unset the error message
				end
			end
			err_msg = nil;														-- we found a match so unset the error message
			break;																-- and done
		end
	end																			-- err_cat remains set here when no match

	if err_msg then
		options.coins_list_t['BIORXIV'] = nil;									-- when error, unset so not included in COinS
		set_message ('err_bad_biorxiv');										-- and set the error message
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator,
			encode = handler.encode, access = handler.access});
end


--[[--------------------------&lt; C I T E S E E R X &gt;------------------------------------------------------------

CiteSeerX use their own notion of &quot;doi&quot; (not to be confused with the identifiers resolved via doi.org).

The description of the structure of this identifier can be found at Help_talk:Citation_Style_1/Archive_26#CiteSeerX_id_structure

]]

local function citeseerx (options)
	local id = options.id;
	local handler = options.handler;
	local matched;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode,
		access = handler.access});
	
	matched = id:match (&quot;^10%.1%.1%.[1-9]%d?%d?%d?%.[1-9]%d?%d?%d?$&quot;);
	if not matched then
		set_message ('err_bad_citeseerx' );
		options.coins_list_t['CITESEERX'] = nil;								-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the DOI name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in DOI names.

https://www.doi.org/doi_handbook/2_Numbering.html				-- 2.2 Syntax of a DOI name
https://www.doi.org/doi_handbook/2_Numbering.html#2.2.2			-- 2.2.2 DOI prefix

]]

local function doi (options)
	local id = options.id;
	local inactive = options.DoiBroken
	local access = options.access;
	local ignore_invalid = options.accept;
	local handler = options.handler;
	local err_flag;

	local function is_extended_free (registrant, suffix)						-- local function to check those few registrants that are mixed; identifiable by the doi suffix &lt;incipit&gt;
		if cfg.extended_registrants_t[registrant] then							-- if this registrant has known free-to-read extentions
			for _, incipit in ipairs (cfg.extended_registrants_t[registrant]) do	-- loop through the registrant's incipits
				if mw.ustring.find (suffix, '^' .. incipit) then				-- if found
					return true;
				end
			end
		end
	end

	local text;
	if is_set (inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;);						-- try to get the year portion from the inactive date
		local inactive_month, good;

		if is_set (inactive_year) then
			if 4 &lt; inactive:len() then											-- inactive date has more than just a year (could be anything)
				local lang_obj = mw.getContentLanguage();						-- get a language object for this wiki
				good, inactive_month = pcall (lang_obj.formatDate, lang_obj, 'F', inactive);	-- try to get the month name from the inactive date
				if not good then
					inactive_month = nil;										-- something went wrong so make sure this is unset
				end
			end
		end																		-- otherwise, |doi-broken-date= has something but it isn't a date
		
		if is_set (inactive_year) and is_set (inactive_month) then
			set_message ('maint_doi_inactive_dated', {inactive_year, inactive_month, ' '});
		elseif is_set (inactive_year) then
			set_message ('maint_doi_inactive_dated', {inactive_year, '', ''});
		else
			set_message ('maint_doi_inactive');
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. ' ' .. inactive .. ')';
	end

	local suffix;
	local registrant, suffix = mw.ustring.match (id, '^10%.([^/]+)/([^%s–]-[^%.,])$');	-- registrant and suffix set when DOI has the proper basic form

	local registrant_err_patterns = {											-- these patterns are for code ranges that are not supported 
		'^[^1-3]%d%d%d%d%.%d+$',												-- 5 digits with subcode (0xxxx, 40000+); accepts: 10000–39999
		'^[^1-7]%d%d%d%d$',														-- 5 digits without subcode (0xxxx, 60000+); accepts: 10000–69999
		'^[^1-9]%d%d%d%.%d+$',												-- 4 digits with subcode (0xxx); accepts: 1000–9999
		'^[^1-9]%d%d%d$',														-- 4 digits without subcode (0xxx); accepts: 1000–9999
		'^%d%d%d%d%d%d+',														-- 6 or more digits
		'^%d%d?%d?$',															-- less than 4 digits without subcode (3 digits with subcode is legitimate)
		'^%d%d?%.[%d%.]+',														-- 1 or 2 digits with subcode
		'^5555$',																-- test registrant will never resolve
		'[^%d%.]',																-- any character that isn't a digit or a dot
		}

	if not ignore_invalid then
		if registrant then														-- when DOI has proper form
			for i, pattern in ipairs (registrant_err_patterns) do				-- spin through error patterns
				if registrant:match (pattern) then								-- to validate registrant codes
					err_flag = set_message ('err_bad_doi');						-- when found, mark this DOI as bad
					break;														-- and done
				end
			end
		else
			err_flag = set_message ('err_bad_doi');								-- invalid directory or malformed
		end
	else
		set_message ('maint_doi_ignore');
	end

	if err_flag then
		options.coins_list_t['DOI'] = nil;										-- when error, unset so not included in COinS
	else
		if not access and (cfg.known_free_doi_registrants_t[registrant] or is_extended_free (registrant, suffix)) then		-- |doi-access=free not set and &lt;registrant&gt; is known to be free
			set_message ('maint_doi_unflagged_free');							-- set a maint cat
		end
	end
	
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access,
		auto_link = not (err_flag or is_set (inactive) or ignore_invalid) and 'doi' or nil -- do not auto-link when |doi-broken-date= has a value or when there is a DOI error or (to play it safe, after all, auto-linking is not essential) when invalid DOIs are ignored
		}) .. (inactive or '');

	return text;
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

Query string parameters are named here: https://www.handle.net/proxy_servlet.html.  query strings are not displayed
but since '?' is an allowed character in an HDL, '?' followed by one of the query parameters is the only way we
have to detect the query string so that it isn't URL-encoded with the rest of the identifier.

]]

local function hdl (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local query_params = {														-- list of known query parameters from https://www.handle.net/proxy_servlet.html
		'noredirect',
		'ignore_aliases',
		'auth',
		'cert',
		'index',
		'type',
		'urlappend',
		'locatt',
		'action',
		}
	
	local hdl, suffix, param = id:match ('(.-)(%?(%a+).+)$');					-- look for query string
	local found;

	if hdl then																	-- when there are query strings, this is the handle identifier portion
		for _, q in ipairs (query_params) do									-- spin through the list of query parameters
			if param:match ('^' .. q) then										-- if the query string begins with one of the parameters
				found = true;													-- announce a find
				break;															-- and stop looking
			end
		end
	end

	if found then
		id = hdl;																-- found so replace id with the handle portion; this will be URL-encoded, suffix will not
	else
		suffix = '';															-- make sure suffix is empty string for concatenation else
	end

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, suffix = suffix, separator = handler.separator, encode = handler.encode, access = access})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- HDL must contain a forward slash, must not contain spaces, endashes, and must not end with period or comma
		set_message ('err_bad_hdl' );
		options.coins_list_t['HDL'] = nil;										-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; I S B N &gt;----------------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function isbn (options_t)
	local isbn_str = options_t.id;
	local ignore_invalid = options_t.accept;
	local handler = options_t.handler;
	local year = options_t.Year;												-- when set, valid anchor_year; may have a disambiguator which must be removed

	local function return_result (check, err_type)								-- local function to handle the various returns
		local ISBN = internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,
						prefix = handler.prefix, id = isbn_str, separator = handler.separator});
		if ignore_invalid then													-- if ignoring ISBN errors
			set_message ('maint_isbn_ignore');									-- add a maint category even when there is no error
		else																	-- here when not ignoring
			if not check then													-- and there is an error
				options_t.coins_list_t['ISBN'] = nil;								-- when error, unset so not included in COinS
				set_message ('err_bad_isbn', err_type);							-- set an error message
				return ISBN;										 			-- return id text
			end
		end
		return ISBN;															-- return id text
	end

	if year and not ignore_invalid then											-- 
		year = year:match ('%d%d%d%d?');										-- strip disambiguator if present
		if 1965 &gt; tonumber(year) then
			set_message ('err_invalid_isbn_date');								-- set an error message
			return internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,
					prefix = handler.prefix, id = isbn_str, separator = handler.separator});
		end
	end

	if nil ~= isbn_str:match ('[^%s-0-9X]') then
		return return_result (false, cfg.err_msg_supl.char);					-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end

	local id = isbn_str:gsub ('[%s-]', '');										-- remove hyphens and whitespace

	local len = id:len();
 
	if len ~= 10 and len ~= 13 then
		return return_result (false, cfg.err_msg_supl.length);					-- fail if incorrect length
	end

	if len == 10 then
		if id:match ('^%d*X?$') == nil then										-- fail if isbn_str has 'X' anywhere but last position
			return return_result (false, cfg.err_msg_supl.form);									
		end
		if not is_valid_isxn (id, 10) then										-- test isbn-10 for numerical validity
			return return_result (false, cfg.err_msg_supl.check);				-- fail if isbn-10 is not numerically valid
		end
		if id:find ('^63[01]') then												-- 630xxxxxxx and 631xxxxxxx are (apparently) not valid isbn group ids but are used by amazon as numeric identifiers (asin)
			return return_result (false, cfg.err_msg_supl.group);				-- fail if isbn-10 begins with 630/1
		end
		return return_result (true, cfg.err_msg_supl.check);					-- pass if isbn-10 is numerically valid
	else
		if id:match ('^%d+$') == nil then
			return return_result (false, cfg.err_msg_supl.char);				-- fail if ISBN-13 is not all digits
		end
		if id:match ('^97[89]%d*$') == nil then
			return return_result (false, cfg.err_msg_supl.prefix);				-- fail when ISBN-13 does not begin with 978 or 979
		end
		if id:match ('^9790') then
			return return_result (false, cfg.err_msg_supl.group);				-- group identifier '0' is reserved to ISMN
		end
		return return_result (is_valid_isxn_13 (id), cfg.err_msg_supl.check);
	end
end


--[[--------------------------&lt; A S I N &gt;----------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: ASIN must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, ASINs must be 10-digit
ISBN. If 10-digit ISBN, add a maintenance category so a bot or AWB script can replace |asin= with |isbn=.
Error message if not 10 characters, if not ISBN-10, if mixed and first character is a digit.

|asin=630....... and |asin=631....... are (apparently) not a legitimate ISBN though it checksums as one; these
do not cause this function to emit the maint_asin message

This function is positioned here because it calls isbn()

]]

local function asin (options)
	local id = options.id;
	local domain = options.ASINTLD;
	
	local err_flag;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_flag = set_message ('err_bad_asin');								-- ASIN is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then							-- if 10-digit numeric (or 9 digits with terminal X)
			if is_valid_isxn (id, 10) then										-- see if ASIN value is or validates as ISBN-10
				if not id:find ('^63[01]') then									-- 630xxxxxxx and 631xxxxxxx are (apparently) not a valid isbn prefixes but are used by amazon as a numeric identifier
					err_flag = set_message ('err_bad_asin');					-- ASIN has ISBN-10 form but begins with something other than 630/1 so probably an isbn 
				end
			elseif not is_set (err_flag) then
				err_flag = set_message ('err_bad_asin');						-- ASIN is not ISBN-10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_flag = set_message ('err_bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if (not is_set (domain)) or in_array (domain, {'us'}) then					-- default: United States
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then									-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'z.cn'}) then 									-- China
		domain = &quot;cn&quot;;
	elseif in_array (domain, {'au', 'br', 'mx', 'sg', 'tr'}) then				-- Australia, Brazil, Mexico, Singapore, Turkey
		domain = &quot;com.&quot; .. domain;
	elseif not in_array (domain, {'ae', 'ca', 'cn', 'de', 'es', 'fr', 'in', 'it', 'nl', 'pl', 'sa', 'se', 'co.jp', 'co.uk', 'com', 'com.au', 'com.br', 'com.mx', 'com.sg', 'com.tr'}) then -- Arabic Emirates, Canada, China, Germany, Spain, France, Indonesia, Italy, Netherlands, Poland, Saudi Arabia, Sweden (as of 2021-03 Austria (.at), Liechtenstein (.li) and Switzerland (.ch) still redirect to the German site (.de) with special settings, so don't maintain local ASINs for them)
		err_flag = set_message ('err_bad_asin_tld');							-- unsupported asin-tld value
	end
	local handler = options.handler;

	if not is_set (err_flag) then
		options.coins_list_t['ASIN'] = handler.prefix .. domain .. &quot;/dp/&quot; .. id;	-- asin for coins
	else
		options.coins_list_t['ASIN'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix .. domain .. &quot;/dp/&quot;,
		id = id, encode = handler.encode, separator = handler.separator})
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to ISBN-13, ISMN is 13 digits beginning 979-0-... and uses the
same check digit calculations.  See https://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

ismn value not made part of COinS metadata because we don't have a url or isn't a COinS-defined identifier (rft.xxx)
or an identifier registered at info-uri.info (info:)

]]

local function ismn (options)
	local id = options.id;
	local handler = options.handler;
	local text;
	local valid_ismn = true;
	local id_copy;

	id_copy = id;																-- save a copy because this testing is destructive
	id = id:gsub ('[%s-]', '');													-- remove hyphens and white space

	if 13 ~= id:len() or id:match (&quot;^9790%d*$&quot; ) == nil then					-- ISMN must be 13 digits and begin with 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ISMN
	end

	--	text = internal_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,		-- use this (or external version) when there is some place to link to
	--		prefix = handler.prefix, id = id_copy, separator = handler.separator, encode = handler.encode})

	text = table.concat (														-- because no place to link to yet
		{
		make_wikilink (link_label_make (handler), handler.label),
		handler.separator,
		id_copy
		});

	if false == valid_ismn then
		options.coins_list_t['ISMN'] = nil;										-- when error, unset so not included in COinS; not really necessary here because ismn not made part of COinS
		set_message ('err_bad_ismn');											-- create an error message if the ISMN is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an ISSN.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [https://www.worldcat.org/issn/0819 4327 0819 4327]	-- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the ISSN midpoint.  It also validates the ISSN for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check ISSN error message.  The
ISSN is always displayed with a hyphen, even if the ISSN was given as a single group of 8 digits.

]]

local function issn (options)
	local id = options.id;
	local handler = options.handler;
	local ignore_invalid = options.accept;

	local issn_copy = id;														-- save a copy of unadulterated ISSN; use this version for display if ISSN does not validate
	local text;
	local valid_issn = true;

	id = id:gsub ('[%s-]', '');													-- remove hyphens and whitespace

	if 8 ~= id:len() or nil == id:match (&quot;^%d*X?$&quot; ) then						-- validate the ISSN: 8 digits long, containing only 0-9 or X in the last position
		valid_issn = false;														-- wrong length or improper character
	else
		valid_issn = is_valid_isxn (id, 8);										-- validate ISSN
	end

	if true == valid_issn then
		id = string.sub (id, 1, 4 ) .. &quot;-&quot; .. string.sub (id, 5 );				-- if valid, display correctly formatted version
	else
		id = issn_copy;															-- if not valid, show the invalid ISSN with error message
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode})

	if ignore_invalid then
		set_message ('maint_issn_ignore');
	else
		if false == valid_issn then
			options.coins_list_t['ISSN'] = nil;									-- when error, unset so not included in COinS
			set_message ('err_bad_issn', (options.hkey == 'EISSN') and 'e' or '');	-- create an error message if the ISSN is invalid
		end 
	end
	
	return text;
end


--[[--------------------------&lt; J F M &gt;-----------------------------------------------------------------------

A numerical identifier in the form nn.nnnn.nn

]]

local function jfm (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;

	id_num = id:match ('^[Jj][Ff][Mm](.*)$');									-- identifier with jfm prefix; extract identifier

	if is_set (id_num) then
		set_message ('maint_jfm_format');
	else																		-- plain number without JFM prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num and id_num:match('^%d%d%.%d%d%d%d%.%d%d$') then
		id = id_num;															-- jfm matches pattern
	else
		set_message ('err_bad_jfm' );											-- set an error message
		options.coins_list_t['JFM'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; J S T O R &gt;--------------------------------------------------------------------

Format a JSTOR with some error checking

]]

local function jstor (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;

	if id:find ('[Jj][Ss][Tt][Oo][Rr]') or id:find ('^https?://') or id:find ('%s') then
		set_message ('err_bad_jstor');											-- set an error message
		options.coins_list_t['JSTOR'] = nil;									-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});
end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
https://oclc-research.github.io/infoURI-Frozen/info-uri.info/info:lccn/reg.html

length = 8 then all digits
length = 9 then lccn[1] is lowercase alpha
length = 10 then lccn[1] and lccn[2] are both lowercase alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lowercase alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lowercase alpha

]]

local function lccn (options)
	local lccn = options.id;
	local handler = options.handler;
	local err_flag;																-- presume that LCCN is valid
	local id = lccn;															-- local copy of the LCCN

	id = normalize_lccn (id);													-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();														-- get the length of the LCCN

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits)
			err_flag = set_message ('err_bad_lccn');							-- set an error message
		end
	elseif 9 == len then														-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then							-- does it match our pattern?
			err_flag = set_message ('err_bad_lccn');							-- set an error message
		end
	elseif 10 == len then														-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then					-- ... see if it matches our pattern
				err_flag = set_message ('err_bad_lccn');						-- no match, set an error message
			end
		end
	elseif 11 == len then														-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_flag = set_message ('err_bad_lccn');							-- no match, set an error message
		end
	elseif 12 == len then														-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then						-- see if it matches our pattern
			err_flag = set_message ('err_bad_lccn');							-- no match, set an error message
		end
	else
		err_flag = set_message ('err_bad_lccn');								-- wrong length, set an error message
	end

	if not is_set (err_flag) and nil ~= lccn:find ('%s') then
		err_flag = set_message ('err_bad_lccn');								-- lccn contains a space, set an error message
	end

	if is_set (err_flag) then
		options.coins_list_t['LCCN'] = nil;										-- when error, unset so not included in COinS
	end

	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = lccn, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; M E D R X I V &gt;-----------------------------------------------------------------

Format medRxiv ID and do simple error checking.  Similar to later bioRxiv IDs, medRxiv IDs are prefixed with a
yyyy.mm.dd. date and suffixed with an optional version identifier.  Ealiest date accepted is 2020.01.01

The medRxiv ID is a date followed by an eight-digit number followed by an optional version indicator 'v' and one or more digits:
	https://www.medrxiv.org/content/10.1101/2020.11.16.20232009v2 -&gt; 10.1101/2020.11.16.20232009v2

]]

local function medrxiv (options)
	local id = options.id;
	local handler = options.handler;
	local err_msg_flag = true;													-- flag; assume that there will be an error

	local patterns = {
		'%d%d%d%d%d%d%d%d$',													-- simple 8-digit identifier; these should be relatively rare
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%d%d%dv%d+$',			-- y.m.d. date + 8-digit identifier + version (2020-01-01 and later)
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%d%d%d$',				-- y.m.d. date + 8-digit identifier (2020-01-01 and later)
		}
	
	for _, pattern in ipairs (patterns) do										-- spin through the patterns looking for a match
		if id:match (pattern) then
			local y, m, d = id:match (pattern);									-- found a match, attempt to get year, month and date from the identifier

			if m then															-- m is nil when id is the 8-digit form
				if not is_valid_rxiv_date (y, m, d, 'b') then					-- validate the encoded date; 'b' for medrxiv limit
					break;														-- date fail; break out early so we don't unset the error message
				end
			end
			err_msg_flag = nil;													-- we found a match so unset the error message
			break;																-- and done
		end
	end																			-- &lt;err_msg_flag&gt; remains set here when no match

	if err_msg_flag then
		options.coins_list_t['MEDRXIV'] = nil;									-- when error, unset so not included in COinS
		set_message ('err_bad_medrxiv');										-- and set the error message
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator,
			encode = handler.encode, access = handler.access});
end


--[[--------------------------&lt; M R &gt;--------------------------------------------------------------------------

A seven digit number; if not seven digits, zero-fill leading digits to make seven digits.

]]

local function mr (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;
	local id_len;

	id_num = id:match ('^[Mm][Rr](%d+)$');										-- identifier with mr prefix

	if is_set (id_num) then
		set_message ('maint_mr_format');										-- add maint cat
	else																		-- plain number without mr prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	id_len = id_num and id_num:len() or 0;
	if (7 &gt;= id_len) and (0 ~= id_len) then
		id = string.rep ('0', 7-id_len) .. id_num;								-- zero-fill leading digits
	else
		set_message ('err_bad_mr');												-- set an error message
		options.coins_list_t['MR'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an OCLC ID.  https://www.oclc.org/batchload/controlnumber.en.html {{dead link}}
archived at: https://web.archive.org/web/20161228233804/https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (options)
	local id = options.id;
	local handler = options.handler;
	local number;

	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- constrain to 1 to 9 digits; change this when OCLC issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if tonumber (id) &gt; handler.id_limit then
			number = nil;														-- unset when id value exceeds the limit
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		set_message ('err_bad_oclc')											-- add an error message if the id is malformed
		options.coins_list_t['OCLC'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local ident, code = id:gsub('^OL', ''):match(&quot;^(%d+([AMW]))$&quot;);				-- strip optional OL prefix followed immediately by digits followed by 'A', 'M', or 'W';
	local err_flag;
	local prefix = {															-- these are appended to the handler.prefix according to code
		['A']='authors/OL',
		['M']='books/OL',
		['W']='works/OL',
		['X']='OL'																-- not a code; spoof when 'code' in id is invalid
		};

	if not ident then
		code = 'X';																-- no code or id completely invalid
		ident = id;																-- copy id to ident so that we display the flawed identifier
		err_flag = set_message ('err_bad_ol');
	end

	if not is_set (err_flag) then
		options.coins_list_t['OL'] = handler.prefix .. prefix[code] .. ident;	-- experiment for ol coins
	else
		options.coins_list_t['OL'] = nil;										-- when error, unset so not included in COinS
	end

	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix .. prefix[code],
		id = ident, separator = handler.separator, encode = handler.encode,
		access = access});
end


--[[--------------------------&lt; O S T I &gt;----------------------------------------------------------------------

Format OSTI and do simple error checking. OSTIs are sequential numbers beginning at 1 and counting up.  This
code checks the OSTI to see that it contains only digits and is less than test_limit specified in the configuration;
the value in test_limit will need to be updated periodically as more OSTIs are issued.

NB. 1018 is the lowest OSTI number found in the wild (so far) and resolving OK on the OSTI site

]]

local function osti (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;

	if id:match(&quot;[^%d]&quot;) then													-- if OSTI has anything but digits
		set_message ('err_bad_osti');											-- set an error message
		options.coins_list_t['OSTI'] = nil;										-- when error, unset so not included in COinS
	else																		-- OSTI is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1018 &gt; id_num or handler.id_limit &lt; id_num then						-- if OSTI is outside test limit boundaries
			set_message ('err_bad_osti');										-- set an error message
			options.coins_list_t['OSTI'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc (options)
	local id = options.id;
	local embargo = options.Embargo;											-- TODO: lowercase?
	local handler = options.handler;
	local err_flag;
	local id_num;
	local text;

	id_num = id:match ('^[Pp][Mm][Cc](%d+)$');									-- identifier with PMC prefix

	if is_set (id_num) then
		set_message ('maint_pmc_format');
	else																		-- plain number without PMC prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if PMC is outside test limit boundaries
			err_flag = set_message ('err_bad_pmc');								-- set an error message
		else
			id = tostring (id_num);												-- make sure id is a string
		end
	else																		-- when id format incorrect
		err_flag = set_message ('err_bad_pmc');									-- set an error message
	end
	
	if is_set (embargo) and is_set (is_embargoed (embargo)) then				-- is PMC is still embargoed?
		text = table.concat (													-- still embargoed so no external link
			{
			make_wikilink (link_label_make (handler), handler.label),
			handler.separator,
			id,
			});
	else
		text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,	-- no embargo date or embargo has expired, ok to link to article
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access,
			auto_link = not err_flag and 'pmc' or nil							-- do not auto-link when PMC has error
			});
	end

	if err_flag then
		options.coins_list_t['PMC'] = nil;										-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid (options)
	local id = options.id;
	local handler = options.handler;

	if id:match(&quot;[^%d]&quot;) then													-- if PMID has anything but digits
		set_message ('err_bad_pmid');											-- set an error message
		options.coins_list_t['PMID'] = nil;										-- when error, unset so not included in COinS
	else																		-- PMID is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if PMID is outside test limit boundaries
			set_message ('err_bad_pmid');										-- set an error message
			options.coins_list_t['PMID'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; R F C &gt;------------------------------------------------------------------------

Format RFC and do simple error checking. RFCs are sequential numbers beginning at 1 and counting up.  This
code checks the RFC to see that it contains only digits and is less than test_limit specified in the configuration;
the value in test_limit will need to be updated periodically as more RFCs are issued.

An index of all RFCs is here: https://tools.ietf.org/rfc/

]]

local function rfc (options)
	local id = options.id;
	local handler = options.handler;

	if id:match(&quot;[^%d]&quot;) then													-- if RFC has anything but digits
		set_message ('err_bad_rfc');											-- set an error message
		options.coins_list_t['RFC'] = nil;										-- when error, unset so not included in COinS
	else																		-- RFC is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if RFC is outside test limit boundaries
			set_message ('err_bad_rfc');										-- set an error message
			options.coins_list_t['RFC'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access});
end


--[[--------------------------&lt; S 2 C I D &gt;--------------------------------------------------------------------

Format an S2CID, do simple error checking

S2CIDs are sequential numbers beginning at 1 and counting up.  This code checks the S2CID to see that it is only
digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically
as more S2CIDs are issued.

]]

local function s2cid (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local id_num;
	local text;
	
	id_num = id:match ('^[1-9]%d*$');											-- id must be all digits; must not begin with 0; no open access flag

 	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if handler.id_limit &lt; id_num then										-- if S2CID is outside test limit boundaries
			set_message ('err_bad_s2cid');										-- set an error message
			options.coins_list_t['S2CID'] = nil;								-- when error, unset so not included in COinS
		end
	else																		-- when id format incorrect
		set_message ('err_bad_s2cid');											-- set an error message
		options.coins_list_t['S2CID'] = nil;									-- when error, unset so not included in COinS
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});

	return text;
end


--[[--------------------------&lt; S B N &gt;------------------------------------------------------------------------

9-digit form of ISBN-10; uses same check-digit validation when SBN is prefixed with an additional '0' to make 10 digits

sbn value not made part of COinS metadata because we don't have a url or isn't a COinS-defined identifier (rft.xxx)
or an identifier registered at info-uri.info (info:)

]]

local function sbn (options)
	local id = options.id;
	local ignore_invalid = options.accept;
	local handler = options.handler;
	local function return_result (check, err_type)								-- local function to handle the various returns
		local SBN = internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,
						prefix = handler.prefix, id = id, separator = handler.separator});
		if not ignore_invalid then												-- if not ignoring SBN errors
			if not check then
				options.coins_list_t['SBN'] = nil;								-- when error, unset so not included in COinS; not really necessary here because sbn not made part of COinS
				set_message ('err_bad_sbn', {err_type});						-- display an error message
				return SBN; 
			end
		else
			set_message ('maint_isbn_ignore');									-- add a maint category even when there is no error (ToDo: Possibly switch to separate message for SBNs only)
		end
		return SBN;
	end

	if id:match ('[^%s-0-9X]') then
		return return_result (false, cfg.err_msg_supl.char);					-- fail if SBN contains anything but digits, hyphens, or the uppercase X
	end

	local ident = id:gsub ('[%s-]', '');										-- remove hyphens and whitespace; they interfere with the rest of the tests

	if  9 ~= ident:len() then
		return return_result (false, cfg.err_msg_supl.length);					-- fail if incorrect length
	end

	if ident:match ('^%d*X?$') == nil then
		return return_result (false, cfg.err_msg_supl.form);					-- fail if SBN has 'X' anywhere but last position
	end

	return return_result (is_valid_isxn ('0' .. ident, 10), cfg.err_msg_supl.check);
end


--[[--------------------------&lt; S S R N &gt;----------------------------------------------------------------------

Format an SSRN, do simple error checking

SSRNs are sequential numbers beginning at 100? and counting up.  This code checks the SSRN to see that it is
only digits and is greater than 99 and less than test_limit; the value in local variable test_limit will need
to be updated periodically as more SSRNs are issued.

]]

local function ssrn (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;
	local text;
	
	id_num = id:match ('^%d+$');												-- id must be all digits

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if 100 &gt; id_num or handler.id_limit &lt; id_num then						-- if SSRN is outside test limit boundaries
			set_message ('err_bad_ssrn');										-- set an error message
			options.coins_list_t['SSRN'] = nil;									-- when error, unset so not included in COinS
		end
	else																		-- when id format incorrect
		set_message ('err_bad_ssrn');											-- set an error message
		options.coins_list_t['SSRN'] = nil;										-- when error, unset so not included in COinS
	end
	
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = options.access});

	return text;
end


--[[--------------------------&lt; U S E N E T _ I D &gt;------------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function usenet_id (options)
	local id = options.id;
	local handler = options.handler;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$') then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		set_message ('err_bad_usenet_id')										-- add an error message if the message id is invalid
		options.coins_list_t['USENETID'] = nil;									-- when error, unset so not included in COinS
	end 
	
	return text;
end


--[[--------------------------&lt; Z B L &gt;-----------------------------------------------------------------------

A numerical identifier in the form nnnn.nnnnn - leading zeros in the first quartet optional

format described here: http://emis.mi.sanu.ac.rs/ZMATH/zmath/en/help/search/

temporary format is apparently eight digits.  Anything else is an error

]]

local function zbl (options)
	local id = options.id;
	local handler = options.handler;

	if id:match('^%d%d%d%d%d%d%d%d$') then										-- is this identifier using temporary format?
		set_message ('maint_zbl');												-- yes, add maint cat
	elseif not id:match('^%d?%d?%d?%d%.%d%d%d%d%d$') then						-- not temporary, is it normal format?
		set_message ('err_bad_zbl');											-- no, set an error message
		options.coins_list_t['ZBL'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--============================&lt;&lt; I N T E R F A C E   F U N C T I O N S &gt;&gt;==========================================

--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message if more than one alias exists in args

]]

local function extract_ids (args)
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs (cfg.id_handlers) do										-- k is uppercase identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one (args, v.parameters, 'err_redundant_parameters' );		-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set (v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; E X T R A C T _ I D _ A C C E S S _ L E V E L S &gt;--------------------------------------

Fetches custom id access levels from arguments using configuration settings. Parameters which have a predefined access
level (e.g. arxiv) do not use this function as they are directly rendered as free without using an additional parameter.

returns a table of k/v pairs where k is same as the identifier's key in cfg.id_handlers and v is the assigned (valid) keyword

access-level values must match the case used in cfg.keywords_lists['id-access'] (lowercase unless there is some special reason for something else)

]]

local function extract_id_access_levels (args, id_list)
	local id_accesses_list = {};
	for k, v in pairs (cfg.id_handlers) do
		local access_param = v.custom_access;									-- name of identifier's access-level parameter
		if is_set (access_param) then
			local access_level = args[access_param];							-- get the assigned value if there is one
			if is_set (access_level) then
				if not in_array (access_level, cfg.keywords_lists['id-access']) then	-- exact match required
					set_message ('err_invalid_param_val', {access_param, access_level});	
					access_level = nil;											-- invalid so unset
				end
				if not is_set (id_list[k]) then									-- identifier access-level must have a matching identifier
					set_message ('err_param_access_requires_param', {k:lower()});	-- parameter name is uppercase in cfg.id_handlers (k); lowercase for error message
				end
				id_accesses_list[k] = cfg.keywords_xlate[access_level];			-- get translated keyword
			end
		end
	end
	return id_accesses_list;
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;----------------------------------------------------

render the identifiers into a sorted sequence table

&lt;ID_list_coins_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value
&lt;options_t&gt; is a table of various k/v option pairs provided in the call to new_build_id_list();
	modified by	this function and passed to all identifier rendering functions
&lt;access_levels_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value (if valid)

returns a sequence table of sorted (by hkey - 'handler' key) rendered identifier strings

]]

local function build_id_list (ID_list_coins_t, options_t, access_levels_t)
	local ID_list_t = {};
	local accept;
	local func_map = {															--function map points to functions associated with hkey identifier
		['ARXIV'] = arxiv,
		['ASIN'] = asin,
		['BIBCODE'] = bibcode,
		['BIORXIV'] = biorxiv,
		['CITESEERX'] = citeseerx,
		['DOI'] = doi,
		['EISSN'] = issn,
		['HDL'] = hdl,
		['ISBN'] = isbn,
		['ISMN'] = ismn,
		['ISSN'] = issn,
		['JFM'] = jfm,
		['JSTOR'] = jstor,
		['LCCN'] = lccn,
		['MEDRXIV'] = medrxiv,
		['MR'] = mr,
		['OCLC'] = oclc,
		['OL'] = openlibrary,
		['OSTI'] = osti,
		['PMC'] = pmc,
		['PMID'] = pmid,
		['RFC']  = rfc,
		['S2CID'] = s2cid,
		['SBN'] = sbn,
		['SSRN'] = ssrn,
		['USENETID'] = usenet_id,
		['ZBL'] = zbl,
		}

	for hkey, v in pairs (ID_list_coins_t) do
		v, accept = has_accept_as_written (v);									-- remove accept-as-written markup if present; accept is boolean true when markup removed; false else
																				-- every function gets the options table with value v and accept boolean
		options_t.hkey = hkey;													-- ~/Configuration handler key
		options_t.id = v;														-- add that identifier value to the options table
		options_t.accept = accept;												-- add the accept boolean flag
		options_t.access = access_levels_t[hkey];								-- add the access level for those that have an |&lt;identifier-access= parameter
		options_t.handler = cfg.id_handlers[hkey];
		options_t.coins_list_t = ID_list_coins_t;								-- pointer to ID_list_coins_t; for |asin= and |ol=; also to keep erroneous values out of the citation's metadata
		options_t.coins_list_t[hkey] = v;										-- id value without accept-as-written markup for metadata
		
		if options_t.handler.access and not in_array (options_t.handler.access, cfg.keywords_lists['id-access']) then
			error (cfg.messages['unknown_ID_access'] .. options_t.handler.access);	-- here when handler access key set to a value not listed in list of allowed id access keywords
		end

		if func_map[hkey] then
			local id_text = func_map[hkey] (options_t);							-- call the function to get identifier text and any error message
			table.insert (ID_list_t, {hkey, id_text});							-- add identifier text to the output sequence table
		else
			error (cfg.messages['unknown_ID_key'] .. hkey);						-- here when func_map doesn't have a function for hkey
		end
	end

	local function comp (a, b)													-- used by following table.sort()
		return a[1]:lower() &lt; b[1]:lower();										-- sort by hkey
	end

	table.sort (ID_list_t, comp);												-- sequence table of tables sort	
	for k, v in ipairs (ID_list_t) do											-- convert sequence table of tables to simple sequence table of strings
		ID_list_t[k] = v[2];													-- v[2] is the identifier rendering from the call to the various functions in func_map{}
	end
	
	return ID_list_t;
end


--[[--------------------------&lt; O P T I O N S _ C H E C K &gt;----------------------------------------------------

check that certain option parameters have their associated identifier parameters with values

&lt;ID_list_coins_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value
&lt;ID_support_t&gt; is a sequence table of tables created in citation0() where each subtable has four elements:
	[1] is the support parameter's assigned value; empty string if not set
	[2] is a text string same as key in cfg.id_handlers
	[3] is cfg.error_conditions key used to create error message
	[4] is original ID support parameter name used to create error message
	
returns nothing; on error emits an appropriate error message

]]

local function options_check (ID_list_coins_t, ID_support_t)
	for _, v in ipairs (ID_support_t) do
		if is_set (v[1]) and not ID_list_coins_t[v[2]] then						-- when support parameter has a value but matching identifier parameter is missing or empty
			set_message (v[3], (v[4]));											-- emit the appropriate error message
		end
	end
end


--[[--------------------------&lt; I D E N T I F I E R _ L I S T S _ G E T &gt;--------------------------------------

Creates two identifier lists: a k/v table of identifiers and their values to be used locally and for use in the
COinS metadata, and a sequence table of the rendered identifier strings that will be included in the rendered
citation.

]]

local function identifier_lists_get (args_t, options_t, ID_support_t)
	local ID_list_coins_t = extract_ids (args_t);										-- get a table of identifiers and their values for use locally and for use in COinS
	options_check (ID_list_coins_t, ID_support_t);										-- ID support parameters must have matching identifier parameters 
	local ID_access_levels_t = extract_id_access_levels (args_t, ID_list_coins_t);		-- get a table of identifier access levels
	local ID_list_t = build_id_list (ID_list_coins_t, options_t, ID_access_levels_t);	-- get a sequence table of rendered identifier strings

	return ID_list_t, ID_list_coins_t;											-- return the tables
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	has_accept_as_written = utilities_page_ptr.has_accept_as_written;			-- import functions from select Module:Citation/CS1/Utilities module
	is_set = utilities_page_ptr.is_set;								
	in_array = utilities_page_ptr.in_array;
	set_message = utilities_page_ptr.set_message;
	select_one = utilities_page_ptr.select_one;
	substitute = utilities_page_ptr.substitute;
	make_wikilink = utilities_page_ptr.make_wikilink;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	auto_link_urls = auto_link_urls,											-- table of identifier URLs to be used when auto-linking |title=
	
	identifier_lists_get = identifier_lists_get,								-- experiment to replace individual calls to build_id_list(), extract_ids, extract_id_access_levels
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>9qo5fnpaokt9t66c7x4r4x2kojbx6pv</sha1>
    </revision>
    <revision>
      <id>4930</id>
      <parentid>4929</parentid>
      <timestamp>2025-04-12T14:06:45Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4930</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="78002" sha1="k1dr68mpitw4fjf8xuqkl74nhwowac7" xml:space="preserve">--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local has_accept_as_written, is_set, in_array, set_message, select_one,			-- functions in Module:Citation/CS1/Utilities
		substitute, make_wikilink;

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

declare variables here that have page-wide scope that are not brought in from other modules; that are created here and used here

]]

local auto_link_urls = {};														-- holds identifier URLs for those identifiers that can auto-link |title=


--============================&lt;&lt; H E L P E R   F U N C T I O N S &gt;&gt;============================================

--[[--------------------------&lt; W I K I D A T A _ A R T I C L E _ N A M E _ G E T &gt;----------------------------

as an aid to internationalizing identifier-label wikilinks, gets identifier article names from Wikidata.

returns :&lt;lang code&gt;:&lt;article title&gt; when &lt;q&gt; has an &lt;article title&gt; for &lt;lang code&gt;; nil else

for identifiers that do not have q, returns nil

for wikis that do not have mw.wikibase installed, returns nil

]]

local function wikidata_article_name_get (q)
	if not is_set (q) or (q and not mw.wikibase) then							-- when no q number or when a q number but mw.wikibase not installed on this wiki
		return nil;																-- abandon
	end

	local wd_article;
	local this_wiki_code = cfg.this_wiki_code;									-- Wikipedia subdomain; 'en' for en.wikipedia.org

	wd_article = mw.wikibase.getSitelink (q, this_wiki_code .. 'wiki');			-- fetch article title from WD; nil when no title available at this wiki

	if wd_article then
		wd_article = table.concat ({':', this_wiki_code, ':', wd_article});		-- interwiki-style link without brackets if taken from WD; leading colon required
	end

	return wd_article;															-- article title from WD; nil else
end


--[[--------------------------&lt; L I N K _ L A B E L _ M A K E &gt;------------------------------------------------

common function to create identifier link label from handler table or from Wikidata

returns the first available of
	1. redirect from local wiki's handler table (if enabled)
	2. Wikidata (if there is a Wikidata entry for this identifier in the local wiki's language)
	3. label specified in the local wiki's handler table
	
]]

local function link_label_make (handler)
	local wd_article;
	
	if not (cfg.use_identifier_redirects and is_set (handler.redirect)) then	-- redirect has priority so if enabled and available don't fetch from Wikidata because expensive
		wd_article = wikidata_article_name_get (handler.q);						-- if Wikidata has an article title for this wiki, get it;
	end
	
	return (cfg.use_identifier_redirects and is_set (handler.redirect) and handler.redirect) or wd_article or handler.link;
end


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki-style external link

]]

local function external_link_id (options)
	local url_string = options.id;
	local ext_link;
	local this_wiki_code = cfg.this_wiki_code;									-- Wikipedia subdomain; 'en' for en.wikipedia.org
	local wd_article;															-- article title from Wikidata
	
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode (url_string, 'PATH');
	end

	if options.auto_link and is_set (options.access) then
		auto_link_urls[options.auto_link] = table.concat ({options.prefix, url_string, options.suffix});
	end

	ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or &quot;&quot;, mw.text.nowiki (options.id));
	if is_set (options.access) then
		ext_link = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[options.access].class, cfg.presentation[options.access].title, ext_link});	-- add the free-to-read / paywall lock
	end

	return table.concat	({
		make_wikilink (link_label_make (options), options.label),				-- redirect, Wikidata link, or locally specified link (in that order)
		options.separator or '&amp;nbsp;',
		ext_link
		});
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki-style internal link

TODO: Does not currently need to support options.access, options.encode, auto-linking and COinS (as in external_link_id),
but may be needed in the future for :m:Interwiki_map custom-prefixes like :arxiv:, :bibcode:, :DOI:, :hdl:, :ISSN:,
:JSTOR:, :Openlibrary:, :PMID:, :RFC:.

]]

local function internal_link_id (options)
	local id = mw.ustring.gsub (options.id, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9

	return table.concat (
		{
		make_wikilink (link_label_make (options), options.label),				-- wiki-link the identifier label
		options.separator or '&amp;nbsp;',											-- add the separator
		make_wikilink (
			table.concat (
				{
				options.prefix,
				id,																-- translated to Western digits
				options.suffix or ''
				}),
			substitute (cfg.presentation['bdi'], {'', mw.text.nowiki (options.id)})	-- bdi tags to prevent Latin script identifiers from being reversed at RTL language wikis
			);																	-- nowiki because MediaWiki still has magic links for ISBN and the like; TODO: is it really required?
		});
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |pmc-embargo-date= against
today's date.  If embargo date is in the future, returns the content of |pmc-embargo-date=; otherwise, returns
an empty string because the embargo has expired or because |pmc-embargo-date= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, todays_date;
		good1, embargo_date = pcall (lang.formatDate, lang, 'U', embargo);
		todays_date = lang:formatDate ('U');
	
		if good1 then															-- if embargo date is a good date
			if tonumber (embargo_date) &gt;= tonumber (todays_date) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				set_message ('maint_pmc_embargo');								-- embargo has expired; add main cat
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |pmc-embargo-date= not set return empty string
end


--[=[-------------------------&lt; I S _ V A L I D _ R X I V _ D A T E &gt;------------------------------------------

for biorxiv, returns true if:
	2019-12-11T00:00Z &lt;= biorxiv_date &lt; today + 2 days
for medrxiv, returns true if:
	2020-01-01T00:00Z &lt;= medrxiv_date &lt; today + 2 days
	
The dated form of biorxiv identifier has a start date of 2019-12-11.  The Unix timestamp for that date is {{#time:U|2019-12-11}} = 1576022400
The medrxiv identifier has a start date of 2020-01-01.  The Unix timestamp for that date is {{#time:U|2020-01-01}} = 1577836800

&lt;rxiv_date&gt; is the date provided in those |biorxiv= parameter values that are dated and in |medrxiv= parameter values at time 00:00:00 UTC
&lt;today&gt; is the current date at time 00:00:00 UTC plus 48 hours
	if today's date is 2023-01-01T00:00:00 then
		adding 24 hours gives 2023-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2023-01-03T00:00:00 – one second more than tomorrow

inputs:
	&lt;y&gt;, &lt;m&gt;, &lt;d&gt; – year, month, day parts of the date from the birxiv or medrxiv identifier
	&lt;select&gt; 'b' for biorxiv, 'm' for medrxiv; defaults to 'b'

]=]

local function is_valid_rxiv_date (y, m, d, select)
	if 0 == tonumber (m) and 12 &lt; tonumber (m) then								-- &lt;m&gt; must be a number 1–12
		return false;
	end
	if 0 == tonumber (d) and 31 &lt; tonumber (d) then								-- &lt;d&gt; must be a number 1–31; TODO: account for month length and leap yer?
		return false;
	end
	
	local rxiv_date = table.concat ({y, m, d}, '-');							-- make ymd date string
	local good1, good2;
	local rxiv_ts, tomorrow_ts;													-- to hold Unix timestamps representing the dates
	local lang_object = mw.getContentLanguage();

	good1, rxiv_ts = pcall (lang_object.formatDate, lang_object, 'U', rxiv_date);		-- convert rxiv_date value to Unix timestamp 
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which tonumber() may not understand
		rxiv_ts = tonumber (rxiv_ts) or lang_object:parseFormattedNumber (rxiv_ts);	-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to Unix timestamp
	end

	local limit_ts = ((select and ('m' == select)) and 1577836800) or 1576022400;	-- choose the appropriate limit timesatmp

	return ((limit_ts &lt;= rxiv_ts) and (rxiv_ts &lt; tomorrow_ts))					-- limit_ts &lt;= rxiv_date &lt; tomorrow's date
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all ISBN/ISSN digits including the check digit.
ISBN-13 is checked in isbn().

If the number is valid the result will be 0. Before calling this function, ISBN/ISSN must be checked for length
and stripped of dashes, spaces and other non-ISxN characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39, 'X' → 0x58
	len = len + 1;																-- adjust to be a loop counter
	for i, v in ipairs (isxn_str) do											-- loop through all of the bytes and calculate the checksum
		if v == string.byte (&quot;X&quot; ) then											-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10 * (len - i);										-- it represents 10 decimal
		else
			temp = temp + tonumber (string.char (v) )*(len-i);
		end
	end
	return temp % 11 == 0;														-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N _ 1 3 &gt;-----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 ISBN/ISMN digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, ISBN-13/ISMN must be checked for length
and stripped of dashes, spaces and other non-ISxN-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39
	for i, v in ipairs (isxn_str) do
		temp = temp + (3 - 2*(i % 2)) * tonumber (string.char (v) );			-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when ISBN-13/ISMN is correct
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

LCCN normalization (https://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized LCCN for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.

]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);												-- 1. strip whitespace

	if nil ~= string.find (lccn, '/') then
		lccn = lccn:match (&quot;(.-)/&quot;);											-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);									-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then														-- if there was a hyphen
		suffix = string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;				-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn = prefix..suffix;													-- reassemble the LCCN
	end
	
	return lccn;
end


--============================&lt;&lt; I D E N T I F I E R   F U N C T I O N S &gt;&gt;====================================

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: https://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9107 and 0703, is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation; not the same as |class= parameter which is not supported in this form
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number

]]

local function arxiv (options)
	local id = options.id;
	local class = options.Class;												-- TODO: lowercase?
	local handler = options.handler;
	local year, month, version;
	local err_msg = false;														-- assume no error message
	local text;																	-- output text
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9107-0703 format with or without version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_msg = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 with or without version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then									-- when year is 07, is month invalid (before April)?
				err_msg = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format with or without version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_msg = true;														-- flag for error message
		end

	else
		err_msg = true;															-- not a recognized format; flag for error message
	end

	if err_msg then
		options.coins_list_t['ARXIV'] = nil;									-- when error, unset so not included in COinS
	end
	
	local err_msg_t = {};
	if err_msg then
		set_message ('err_bad_arxiv');
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access});

	if is_set (class) then
		if id:match ('^%d+') then
			text = table.concat ({text, ' [[https://arxiv.org/archive/', class, ' ', class, ']]'});	-- external link within square brackets, not wikilink
		else
			set_message ('err_class_ignored');
		end
	end

	return text;
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode ID.

Format for bibcodes is specified here: https://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		9–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local ignore_invalid = options.accept;
	local err_type;
	local err_msg = '';
	local year;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode,
		access = access});
	
	if 19 ~= id:len() then
		err_type = cfg.err_msg_supl.length;
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%w&amp;%.][%w&amp;%.][%w&amp;%.][%w.]+[%a%.]$&quot;);
		if not year then														-- if nil then no pattern match
			err_type = cfg.err_msg_supl.value;									-- so value error
		else
			local next_year = tonumber (os.date ('%Y')) + 1;					-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = cfg.err_msg_supl.year;								-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = cfg.err_msg_supl.journal;							-- journal abbreviation must not have '&amp;.' (if it does it's missing a letter)
			end
			if id:match ('.........%.tmp%.') then								-- temporary bibcodes when positions 10–14 are '.tmp.'
				set_message ('maint_bibcode');
			end
		end
	end

	if is_set (err_type) and not ignore_invalid then							-- if there was an error detected and accept-as-written markup not used
		set_message ('err_bad_bibcode', {err_type});
		options.coins_list_t['BIBCODE'] = nil;									-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; B I O R X I V &gt;-----------------------------------------------------------------

Format bioRxiv ID and do simple error checking.  Before 2019-12-11, biorXiv IDs were 10.1101/ followed by exactly
6 digits.  After 2019-12-11, biorXiv IDs retained the six-digit identifier but prefixed that with a yyyy.mm.dd. 
date and suffixed with an optional version identifier.

The bioRxiv ID is the string of characters:
	https://doi.org/10.1101/078733 -&gt; 10.1101/078733
or a date followed by a six-digit number followed by an optional version indicator 'v' and one or more digits:
	https://www.biorxiv.org/content/10.1101/2019.12.11.123456v2 -&gt; 10.1101/2019.12.11.123456v2
	
see https://www.biorxiv.org/about-biorxiv

]]

local function biorxiv (options)
	local id = options.id;
	local handler = options.handler;
	local err_msg = true;														-- flag; assume that there will be an error
	
	local patterns = {
		'^10%.1101/%d%d%d%d%d%d$',												-- simple 6-digit identifier (before 2019-12-11)
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%dv%d+$',				-- y.m.d. date + 6-digit identifier + version (after 2019-12-11)
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%d$',					-- y.m.d. date + 6-digit identifier (after 2019-12-11)
		}
	
	for _, pattern in ipairs (patterns) do										-- spin through the patterns looking for a match
		if id:match (pattern) then
			local y, m, d = id:match (pattern);									-- found a match, attempt to get year, month and date from the identifier

			if m then															-- m is nil when id is the six-digit form
				if not is_valid_rxiv_date (y, m, d, 'b') then					-- validate the encoded date; 'b' for biorxiv limit
					break;														-- date fail; break out early so we don't unset the error message
				end
			end
			err_msg = nil;														-- we found a match so unset the error message
			break;																-- and done
		end
	end																			-- err_cat remains set here when no match

	if err_msg then
		options.coins_list_t['BIORXIV'] = nil;									-- when error, unset so not included in COinS
		set_message ('err_bad_biorxiv');										-- and set the error message
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator,
			encode = handler.encode, access = handler.access});
end


--[[--------------------------&lt; C I T E S E E R X &gt;------------------------------------------------------------

CiteSeerX use their own notion of &quot;doi&quot; (not to be confused with the identifiers resolved via doi.org).

The description of the structure of this identifier can be found at Help_talk:Citation_Style_1/Archive_26#CiteSeerX_id_structure

]]

local function citeseerx (options)
	local id = options.id;
	local handler = options.handler;
	local matched;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode,
		access = handler.access});
	
	matched = id:match (&quot;^10%.1%.1%.[1-9]%d?%d?%d?%.[1-9]%d?%d?%d?$&quot;);
	if not matched then
		set_message ('err_bad_citeseerx' );
		options.coins_list_t['CITESEERX'] = nil;								-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the DOI name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in DOI names.

https://www.doi.org/doi_handbook/2_Numbering.html				-- 2.2 Syntax of a DOI name
https://www.doi.org/doi_handbook/2_Numbering.html#2.2.2			-- 2.2.2 DOI prefix

]]

local function doi (options)
	local id = options.id;
	local inactive = options.DoiBroken
	local access = options.access;
	local ignore_invalid = options.accept;
	local handler = options.handler;
	local err_flag;

	local function is_extended_free (registrant, suffix)						-- local function to check those few registrants that are mixed; identifiable by the doi suffix &lt;incipit&gt;
		if cfg.extended_registrants_t[registrant] then							-- if this registrant has known free-to-read extentions
			for _, incipit in ipairs (cfg.extended_registrants_t[registrant]) do	-- loop through the registrant's incipits
				if mw.ustring.find (suffix, '^' .. incipit) then				-- if found
					return true;
				end
			end
		end
	end

	local text;
	if is_set (inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;);						-- try to get the year portion from the inactive date
		local inactive_month, good;

		if is_set (inactive_year) then
			if 4 &lt; inactive:len() then											-- inactive date has more than just a year (could be anything)
				local lang_obj = mw.getContentLanguage();						-- get a language object for this wiki
				good, inactive_month = pcall (lang_obj.formatDate, lang_obj, 'F', inactive);	-- try to get the month name from the inactive date
				if not good then
					inactive_month = nil;										-- something went wrong so make sure this is unset
				end
			end
		end																		-- otherwise, |doi-broken-date= has something but it isn't a date
		
		if is_set (inactive_year) and is_set (inactive_month) then
			set_message ('maint_doi_inactive_dated', {inactive_year, inactive_month, ' '});
		elseif is_set (inactive_year) then
			set_message ('maint_doi_inactive_dated', {inactive_year, '', ''});
		else
			set_message ('maint_doi_inactive');
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. ' ' .. inactive .. ')';
	end

	local suffix;
	local registrant, suffix = mw.ustring.match (id, '^10%.([^/]+)/([^%s–]-[^%.,])$');	-- registrant and suffix set when DOI has the proper basic form

	local registrant_err_patterns = {											-- these patterns are for code ranges that are not supported 
		'^[^1-3]%d%d%d%d%.%d+$',												-- 5 digits with subcode (0xxxx, 40000+); accepts: 10000–39999
		'^[^1-7]%d%d%d%d$',														-- 5 digits without subcode (0xxxx, 60000+); accepts: 10000–69999
		'^[^1-9]%d%d%d%.%d+$',												-- 4 digits with subcode (0xxx); accepts: 1000–9999
		'^[^1-9]%d%d%d$',														-- 4 digits without subcode (0xxx); accepts: 1000–9999
		'^%d%d%d%d%d%d+',														-- 6 or more digits
		'^%d%d?%d?$',															-- less than 4 digits without subcode (3 digits with subcode is legitimate)
		'^%d%d?%.[%d%.]+',														-- 1 or 2 digits with subcode
		'^5555$',																-- test registrant will never resolve
		'[^%d%.]',																-- any character that isn't a digit or a dot
		}

	if not ignore_invalid then
		if registrant then														-- when DOI has proper form
			for i, pattern in ipairs (registrant_err_patterns) do				-- spin through error patterns
				if registrant:match (pattern) then								-- to validate registrant codes
					err_flag = set_message ('err_bad_doi');						-- when found, mark this DOI as bad
					break;														-- and done
				end
			end
		else
			err_flag = set_message ('err_bad_doi');								-- invalid directory or malformed
		end
	else
		set_message ('maint_doi_ignore');
	end

	if err_flag then
		options.coins_list_t['DOI'] = nil;										-- when error, unset so not included in COinS
	else
		if not access and (cfg.known_free_doi_registrants_t[registrant] or is_extended_free (registrant, suffix)) then		-- |doi-access=free not set and &lt;registrant&gt; is known to be free
			set_message ('maint_doi_unflagged_free');							-- set a maint cat
		end
	end
	
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access,
		auto_link = not (err_flag or is_set (inactive) or ignore_invalid) and 'doi' or nil -- do not auto-link when |doi-broken-date= has a value or when there is a DOI error or (to play it safe, after all, auto-linking is not essential) when invalid DOIs are ignored
		}) .. (inactive or '');

	return text;
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

Query string parameters are named here: https://www.handle.net/proxy_servlet.html.  query strings are not displayed
but since '?' is an allowed character in an HDL, '?' followed by one of the query parameters is the only way we
have to detect the query string so that it isn't URL-encoded with the rest of the identifier.

]]

local function hdl (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local query_params = {														-- list of known query parameters from https://www.handle.net/proxy_servlet.html
		'noredirect',
		'ignore_aliases',
		'auth',
		'cert',
		'index',
		'type',
		'urlappend',
		'locatt',
		'action',
		}
	
	local hdl, suffix, param = id:match ('(.-)(%?(%a+).+)$');					-- look for query string
	local found;

	if hdl then																	-- when there are query strings, this is the handle identifier portion
		for _, q in ipairs (query_params) do									-- spin through the list of query parameters
			if param:match ('^' .. q) then										-- if the query string begins with one of the parameters
				found = true;													-- announce a find
				break;															-- and stop looking
			end
		end
	end

	if found then
		id = hdl;																-- found so replace id with the handle portion; this will be URL-encoded, suffix will not
	else
		suffix = '';															-- make sure suffix is empty string for concatenation else
	end

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, suffix = suffix, separator = handler.separator, encode = handler.encode, access = access})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- HDL must contain a forward slash, must not contain spaces, endashes, and must not end with period or comma
		set_message ('err_bad_hdl' );
		options.coins_list_t['HDL'] = nil;										-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; I S B N &gt;----------------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function isbn (options_t)
	local isbn_str = options_t.id;
	local ignore_invalid = options_t.accept;
	local handler = options_t.handler;
	local year = options_t.Year;												-- when set, valid anchor_year; may have a disambiguator which must be removed

	local function return_result (check, err_type)								-- local function to handle the various returns
		local ISBN = internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,
						prefix = handler.prefix, id = isbn_str, separator = handler.separator});
		if ignore_invalid then													-- if ignoring ISBN errors
			set_message ('maint_isbn_ignore');									-- add a maint category even when there is no error
		else																	-- here when not ignoring
			if not check then													-- and there is an error
				options_t.coins_list_t['ISBN'] = nil;								-- when error, unset so not included in COinS
				set_message ('err_bad_isbn', err_type);							-- set an error message
				return ISBN;										 			-- return id text
			end
		end
		return ISBN;															-- return id text
	end

	if year and not ignore_invalid then											-- 
		year = year:match ('%d%d%d%d?');										-- strip disambiguator if present
		if year and (1965 &gt; tonumber(year)) then
			set_message ('err_invalid_isbn_date');								-- set an error message
			return internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,
					prefix = handler.prefix, id = isbn_str, separator = handler.separator});
		end
	end

	if nil ~= isbn_str:match ('[^%s-0-9X]') then
		return return_result (false, cfg.err_msg_supl.char);					-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end

	local id = isbn_str:gsub ('[%s-]', '');										-- remove hyphens and whitespace

	local len = id:len();
 
	if len ~= 10 and len ~= 13 then
		return return_result (false, cfg.err_msg_supl.length);					-- fail if incorrect length
	end

	if len == 10 then
		if id:match ('^%d*X?$') == nil then										-- fail if isbn_str has 'X' anywhere but last position
			return return_result (false, cfg.err_msg_supl.form);									
		end
		if not is_valid_isxn (id, 10) then										-- test isbn-10 for numerical validity
			return return_result (false, cfg.err_msg_supl.check);				-- fail if isbn-10 is not numerically valid
		end
		if id:find ('^63[01]') then												-- 630xxxxxxx and 631xxxxxxx are (apparently) not valid isbn group ids but are used by amazon as numeric identifiers (asin)
			return return_result (false, cfg.err_msg_supl.group);				-- fail if isbn-10 begins with 630/1
		end
		return return_result (true, cfg.err_msg_supl.check);					-- pass if isbn-10 is numerically valid
	else
		if id:match ('^%d+$') == nil then
			return return_result (false, cfg.err_msg_supl.char);				-- fail if ISBN-13 is not all digits
		end
		if id:match ('^97[89]%d*$') == nil then
			return return_result (false, cfg.err_msg_supl.prefix);				-- fail when ISBN-13 does not begin with 978 or 979
		end
		if id:match ('^9790') then
			return return_result (false, cfg.err_msg_supl.group);				-- group identifier '0' is reserved to ISMN
		end
		return return_result (is_valid_isxn_13 (id), cfg.err_msg_supl.check);
	end
end


--[[--------------------------&lt; A S I N &gt;----------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: ASIN must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, ASINs must be 10-digit
ISBN. If 10-digit ISBN, add a maintenance category so a bot or AWB script can replace |asin= with |isbn=.
Error message if not 10 characters, if not ISBN-10, if mixed and first character is a digit.

|asin=630....... and |asin=631....... are (apparently) not a legitimate ISBN though it checksums as one; these
do not cause this function to emit the maint_asin message

This function is positioned here because it calls isbn()

]]

local function asin (options)
	local id = options.id;
	local domain = options.ASINTLD;
	
	local err_flag;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_flag = set_message ('err_bad_asin');								-- ASIN is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then							-- if 10-digit numeric (or 9 digits with terminal X)
			if is_valid_isxn (id, 10) then										-- see if ASIN value is or validates as ISBN-10
				if not id:find ('^63[01]') then									-- 630xxxxxxx and 631xxxxxxx are (apparently) not a valid isbn prefixes but are used by amazon as a numeric identifier
					err_flag = set_message ('err_bad_asin');					-- ASIN has ISBN-10 form but begins with something other than 630/1 so probably an isbn 
				end
			elseif not is_set (err_flag) then
				err_flag = set_message ('err_bad_asin');						-- ASIN is not ISBN-10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_flag = set_message ('err_bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if (not is_set (domain)) or in_array (domain, {'us'}) then					-- default: United States
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then									-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'z.cn'}) then 									-- China
		domain = &quot;cn&quot;;
	elseif in_array (domain, {'au', 'br', 'mx', 'sg', 'tr'}) then				-- Australia, Brazil, Mexico, Singapore, Turkey
		domain = &quot;com.&quot; .. domain;
	elseif not in_array (domain, {'ae', 'ca', 'cn', 'de', 'es', 'fr', 'in', 'it', 'nl', 'pl', 'sa', 'se', 'co.jp', 'co.uk', 'com', 'com.au', 'com.br', 'com.mx', 'com.sg', 'com.tr'}) then -- Arabic Emirates, Canada, China, Germany, Spain, France, Indonesia, Italy, Netherlands, Poland, Saudi Arabia, Sweden (as of 2021-03 Austria (.at), Liechtenstein (.li) and Switzerland (.ch) still redirect to the German site (.de) with special settings, so don't maintain local ASINs for them)
		err_flag = set_message ('err_bad_asin_tld');							-- unsupported asin-tld value
	end
	local handler = options.handler;

	if not is_set (err_flag) then
		options.coins_list_t['ASIN'] = handler.prefix .. domain .. &quot;/dp/&quot; .. id;	-- asin for coins
	else
		options.coins_list_t['ASIN'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix .. domain .. &quot;/dp/&quot;,
		id = id, encode = handler.encode, separator = handler.separator})
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to ISBN-13, ISMN is 13 digits beginning 979-0-... and uses the
same check digit calculations.  See https://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

ismn value not made part of COinS metadata because we don't have a url or isn't a COinS-defined identifier (rft.xxx)
or an identifier registered at info-uri.info (info:)

]]

local function ismn (options)
	local id = options.id;
	local handler = options.handler;
	local text;
	local valid_ismn = true;
	local id_copy;

	id_copy = id;																-- save a copy because this testing is destructive
	id = id:gsub ('[%s-]', '');													-- remove hyphens and white space

	if 13 ~= id:len() or id:match (&quot;^9790%d*$&quot; ) == nil then					-- ISMN must be 13 digits and begin with 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ISMN
	end

	--	text = internal_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,		-- use this (or external version) when there is some place to link to
	--		prefix = handler.prefix, id = id_copy, separator = handler.separator, encode = handler.encode})

	text = table.concat (														-- because no place to link to yet
		{
		make_wikilink (link_label_make (handler), handler.label),
		handler.separator,
		id_copy
		});

	if false == valid_ismn then
		options.coins_list_t['ISMN'] = nil;										-- when error, unset so not included in COinS; not really necessary here because ismn not made part of COinS
		set_message ('err_bad_ismn');											-- create an error message if the ISMN is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an ISSN.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [https://www.worldcat.org/issn/0819 4327 0819 4327]	-- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the ISSN midpoint.  It also validates the ISSN for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check ISSN error message.  The
ISSN is always displayed with a hyphen, even if the ISSN was given as a single group of 8 digits.

]]

local function issn (options)
	local id = options.id;
	local handler = options.handler;
	local ignore_invalid = options.accept;

	local issn_copy = id;														-- save a copy of unadulterated ISSN; use this version for display if ISSN does not validate
	local text;
	local valid_issn = true;

	id = id:gsub ('[%s-]', '');													-- remove hyphens and whitespace

	if 8 ~= id:len() or nil == id:match (&quot;^%d*X?$&quot; ) then						-- validate the ISSN: 8 digits long, containing only 0-9 or X in the last position
		valid_issn = false;														-- wrong length or improper character
	else
		valid_issn = is_valid_isxn (id, 8);										-- validate ISSN
	end

	if true == valid_issn then
		id = string.sub (id, 1, 4 ) .. &quot;-&quot; .. string.sub (id, 5 );				-- if valid, display correctly formatted version
	else
		id = issn_copy;															-- if not valid, show the invalid ISSN with error message
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode})

	if ignore_invalid then
		set_message ('maint_issn_ignore');
	else
		if false == valid_issn then
			options.coins_list_t['ISSN'] = nil;									-- when error, unset so not included in COinS
			set_message ('err_bad_issn', (options.hkey == 'EISSN') and 'e' or '');	-- create an error message if the ISSN is invalid
		end 
	end
	
	return text;
end


--[[--------------------------&lt; J F M &gt;-----------------------------------------------------------------------

A numerical identifier in the form nn.nnnn.nn

]]

local function jfm (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;

	id_num = id:match ('^[Jj][Ff][Mm](.*)$');									-- identifier with jfm prefix; extract identifier

	if is_set (id_num) then
		set_message ('maint_jfm_format');
	else																		-- plain number without JFM prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num and id_num:match('^%d%d%.%d%d%d%d%.%d%d$') then
		id = id_num;															-- jfm matches pattern
	else
		set_message ('err_bad_jfm' );											-- set an error message
		options.coins_list_t['JFM'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; J S T O R &gt;--------------------------------------------------------------------

Format a JSTOR with some error checking

]]

local function jstor (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;

	if id:find ('[Jj][Ss][Tt][Oo][Rr]') or id:find ('^https?://') or id:find ('%s') then
		set_message ('err_bad_jstor');											-- set an error message
		options.coins_list_t['JSTOR'] = nil;									-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});
end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
https://oclc-research.github.io/infoURI-Frozen/info-uri.info/info:lccn/reg.html

length = 8 then all digits
length = 9 then lccn[1] is lowercase alpha
length = 10 then lccn[1] and lccn[2] are both lowercase alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lowercase alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lowercase alpha

]]

local function lccn (options)
	local lccn = options.id;
	local handler = options.handler;
	local err_flag;																-- presume that LCCN is valid
	local id = lccn;															-- local copy of the LCCN

	id = normalize_lccn (id);													-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();														-- get the length of the LCCN

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits)
			err_flag = set_message ('err_bad_lccn');							-- set an error message
		end
	elseif 9 == len then														-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then							-- does it match our pattern?
			err_flag = set_message ('err_bad_lccn');							-- set an error message
		end
	elseif 10 == len then														-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then					-- ... see if it matches our pattern
				err_flag = set_message ('err_bad_lccn');						-- no match, set an error message
			end
		end
	elseif 11 == len then														-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_flag = set_message ('err_bad_lccn');							-- no match, set an error message
		end
	elseif 12 == len then														-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then						-- see if it matches our pattern
			err_flag = set_message ('err_bad_lccn');							-- no match, set an error message
		end
	else
		err_flag = set_message ('err_bad_lccn');								-- wrong length, set an error message
	end

	if not is_set (err_flag) and nil ~= lccn:find ('%s') then
		err_flag = set_message ('err_bad_lccn');								-- lccn contains a space, set an error message
	end

	if is_set (err_flag) then
		options.coins_list_t['LCCN'] = nil;										-- when error, unset so not included in COinS
	end

	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = lccn, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; M E D R X I V &gt;-----------------------------------------------------------------

Format medRxiv ID and do simple error checking.  Similar to later bioRxiv IDs, medRxiv IDs are prefixed with a
yyyy.mm.dd. date and suffixed with an optional version identifier.  Ealiest date accepted is 2020.01.01

The medRxiv ID is a date followed by an eight-digit number followed by an optional version indicator 'v' and one or more digits:
	https://www.medrxiv.org/content/10.1101/2020.11.16.20232009v2 -&gt; 10.1101/2020.11.16.20232009v2

]]

local function medrxiv (options)
	local id = options.id;
	local handler = options.handler;
	local err_msg_flag = true;													-- flag; assume that there will be an error

	local patterns = {
		'%d%d%d%d%d%d%d%d$',													-- simple 8-digit identifier; these should be relatively rare
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%d%d%dv%d+$',			-- y.m.d. date + 8-digit identifier + version (2020-01-01 and later)
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%d%d%d$',				-- y.m.d. date + 8-digit identifier (2020-01-01 and later)
		}
	
	for _, pattern in ipairs (patterns) do										-- spin through the patterns looking for a match
		if id:match (pattern) then
			local y, m, d = id:match (pattern);									-- found a match, attempt to get year, month and date from the identifier

			if m then															-- m is nil when id is the 8-digit form
				if not is_valid_rxiv_date (y, m, d, 'b') then					-- validate the encoded date; 'b' for medrxiv limit
					break;														-- date fail; break out early so we don't unset the error message
				end
			end
			err_msg_flag = nil;													-- we found a match so unset the error message
			break;																-- and done
		end
	end																			-- &lt;err_msg_flag&gt; remains set here when no match

	if err_msg_flag then
		options.coins_list_t['MEDRXIV'] = nil;									-- when error, unset so not included in COinS
		set_message ('err_bad_medrxiv');										-- and set the error message
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator,
			encode = handler.encode, access = handler.access});
end


--[[--------------------------&lt; M R &gt;--------------------------------------------------------------------------

A seven digit number; if not seven digits, zero-fill leading digits to make seven digits.

]]

local function mr (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;
	local id_len;

	id_num = id:match ('^[Mm][Rr](%d+)$');										-- identifier with mr prefix

	if is_set (id_num) then
		set_message ('maint_mr_format');										-- add maint cat
	else																		-- plain number without mr prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	id_len = id_num and id_num:len() or 0;
	if (7 &gt;= id_len) and (0 ~= id_len) then
		id = string.rep ('0', 7-id_len) .. id_num;								-- zero-fill leading digits
	else
		set_message ('err_bad_mr');												-- set an error message
		options.coins_list_t['MR'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an OCLC ID.  https://www.oclc.org/batchload/controlnumber.en.html {{dead link}}
archived at: https://web.archive.org/web/20161228233804/https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (options)
	local id = options.id;
	local handler = options.handler;
	local number;

	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- constrain to 1 to 9 digits; change this when OCLC issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if tonumber (id) &gt; handler.id_limit then
			number = nil;														-- unset when id value exceeds the limit
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		set_message ('err_bad_oclc')											-- add an error message if the id is malformed
		options.coins_list_t['OCLC'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local ident, code = id:gsub('^OL', ''):match(&quot;^(%d+([AMW]))$&quot;);				-- strip optional OL prefix followed immediately by digits followed by 'A', 'M', or 'W';
	local err_flag;
	local prefix = {															-- these are appended to the handler.prefix according to code
		['A']='authors/OL',
		['M']='books/OL',
		['W']='works/OL',
		['X']='OL'																-- not a code; spoof when 'code' in id is invalid
		};

	if not ident then
		code = 'X';																-- no code or id completely invalid
		ident = id;																-- copy id to ident so that we display the flawed identifier
		err_flag = set_message ('err_bad_ol');
	end

	if not is_set (err_flag) then
		options.coins_list_t['OL'] = handler.prefix .. prefix[code] .. ident;	-- experiment for ol coins
	else
		options.coins_list_t['OL'] = nil;										-- when error, unset so not included in COinS
	end

	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix .. prefix[code],
		id = ident, separator = handler.separator, encode = handler.encode,
		access = access});
end


--[[--------------------------&lt; O S T I &gt;----------------------------------------------------------------------

Format OSTI and do simple error checking. OSTIs are sequential numbers beginning at 1 and counting up.  This
code checks the OSTI to see that it contains only digits and is less than test_limit specified in the configuration;
the value in test_limit will need to be updated periodically as more OSTIs are issued.

NB. 1018 is the lowest OSTI number found in the wild (so far) and resolving OK on the OSTI site

]]

local function osti (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;

	if id:match(&quot;[^%d]&quot;) then													-- if OSTI has anything but digits
		set_message ('err_bad_osti');											-- set an error message
		options.coins_list_t['OSTI'] = nil;										-- when error, unset so not included in COinS
	else																		-- OSTI is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1018 &gt; id_num or handler.id_limit &lt; id_num then						-- if OSTI is outside test limit boundaries
			set_message ('err_bad_osti');										-- set an error message
			options.coins_list_t['OSTI'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc (options)
	local id = options.id;
	local embargo = options.Embargo;											-- TODO: lowercase?
	local handler = options.handler;
	local err_flag;
	local id_num;
	local text;

	id_num = id:match ('^[Pp][Mm][Cc](%d+)$');									-- identifier with PMC prefix

	if is_set (id_num) then
		set_message ('maint_pmc_format');
	else																		-- plain number without PMC prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if PMC is outside test limit boundaries
			err_flag = set_message ('err_bad_pmc');								-- set an error message
		else
			id = tostring (id_num);												-- make sure id is a string
		end
	else																		-- when id format incorrect
		err_flag = set_message ('err_bad_pmc');									-- set an error message
	end
	
	if is_set (embargo) and is_set (is_embargoed (embargo)) then				-- is PMC is still embargoed?
		text = table.concat (													-- still embargoed so no external link
			{
			make_wikilink (link_label_make (handler), handler.label),
			handler.separator,
			id,
			});
	else
		text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,	-- no embargo date or embargo has expired, ok to link to article
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access,
			auto_link = not err_flag and 'pmc' or nil							-- do not auto-link when PMC has error
			});
	end

	if err_flag then
		options.coins_list_t['PMC'] = nil;										-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid (options)
	local id = options.id;
	local handler = options.handler;

	if id:match(&quot;[^%d]&quot;) then													-- if PMID has anything but digits
		set_message ('err_bad_pmid');											-- set an error message
		options.coins_list_t['PMID'] = nil;										-- when error, unset so not included in COinS
	else																		-- PMID is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if PMID is outside test limit boundaries
			set_message ('err_bad_pmid');										-- set an error message
			options.coins_list_t['PMID'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; R F C &gt;------------------------------------------------------------------------

Format RFC and do simple error checking. RFCs are sequential numbers beginning at 1 and counting up.  This
code checks the RFC to see that it contains only digits and is less than test_limit specified in the configuration;
the value in test_limit will need to be updated periodically as more RFCs are issued.

An index of all RFCs is here: https://tools.ietf.org/rfc/

]]

local function rfc (options)
	local id = options.id;
	local handler = options.handler;

	if id:match(&quot;[^%d]&quot;) then													-- if RFC has anything but digits
		set_message ('err_bad_rfc');											-- set an error message
		options.coins_list_t['RFC'] = nil;										-- when error, unset so not included in COinS
	else																		-- RFC is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if RFC is outside test limit boundaries
			set_message ('err_bad_rfc');										-- set an error message
			options.coins_list_t['RFC'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access});
end


--[[--------------------------&lt; S 2 C I D &gt;--------------------------------------------------------------------

Format an S2CID, do simple error checking

S2CIDs are sequential numbers beginning at 1 and counting up.  This code checks the S2CID to see that it is only
digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically
as more S2CIDs are issued.

]]

local function s2cid (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local id_num;
	local text;
	
	id_num = id:match ('^[1-9]%d*$');											-- id must be all digits; must not begin with 0; no open access flag

 	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if handler.id_limit &lt; id_num then										-- if S2CID is outside test limit boundaries
			set_message ('err_bad_s2cid');										-- set an error message
			options.coins_list_t['S2CID'] = nil;								-- when error, unset so not included in COinS
		end
	else																		-- when id format incorrect
		set_message ('err_bad_s2cid');											-- set an error message
		options.coins_list_t['S2CID'] = nil;									-- when error, unset so not included in COinS
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});

	return text;
end


--[[--------------------------&lt; S B N &gt;------------------------------------------------------------------------

9-digit form of ISBN-10; uses same check-digit validation when SBN is prefixed with an additional '0' to make 10 digits

sbn value not made part of COinS metadata because we don't have a url or isn't a COinS-defined identifier (rft.xxx)
or an identifier registered at info-uri.info (info:)

]]

local function sbn (options)
	local id = options.id;
	local ignore_invalid = options.accept;
	local handler = options.handler;
	local function return_result (check, err_type)								-- local function to handle the various returns
		local SBN = internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,
						prefix = handler.prefix, id = id, separator = handler.separator});
		if not ignore_invalid then												-- if not ignoring SBN errors
			if not check then
				options.coins_list_t['SBN'] = nil;								-- when error, unset so not included in COinS; not really necessary here because sbn not made part of COinS
				set_message ('err_bad_sbn', {err_type});						-- display an error message
				return SBN; 
			end
		else
			set_message ('maint_isbn_ignore');									-- add a maint category even when there is no error (ToDo: Possibly switch to separate message for SBNs only)
		end
		return SBN;
	end

	if id:match ('[^%s-0-9X]') then
		return return_result (false, cfg.err_msg_supl.char);					-- fail if SBN contains anything but digits, hyphens, or the uppercase X
	end

	local ident = id:gsub ('[%s-]', '');										-- remove hyphens and whitespace; they interfere with the rest of the tests

	if  9 ~= ident:len() then
		return return_result (false, cfg.err_msg_supl.length);					-- fail if incorrect length
	end

	if ident:match ('^%d*X?$') == nil then
		return return_result (false, cfg.err_msg_supl.form);					-- fail if SBN has 'X' anywhere but last position
	end

	return return_result (is_valid_isxn ('0' .. ident, 10), cfg.err_msg_supl.check);
end


--[[--------------------------&lt; S S R N &gt;----------------------------------------------------------------------

Format an SSRN, do simple error checking

SSRNs are sequential numbers beginning at 100? and counting up.  This code checks the SSRN to see that it is
only digits and is greater than 99 and less than test_limit; the value in local variable test_limit will need
to be updated periodically as more SSRNs are issued.

]]

local function ssrn (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;
	local text;
	
	id_num = id:match ('^%d+$');												-- id must be all digits

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if 100 &gt; id_num or handler.id_limit &lt; id_num then						-- if SSRN is outside test limit boundaries
			set_message ('err_bad_ssrn');										-- set an error message
			options.coins_list_t['SSRN'] = nil;									-- when error, unset so not included in COinS
		end
	else																		-- when id format incorrect
		set_message ('err_bad_ssrn');											-- set an error message
		options.coins_list_t['SSRN'] = nil;										-- when error, unset so not included in COinS
	end
	
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = options.access});

	return text;
end


--[[--------------------------&lt; U S E N E T _ I D &gt;------------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function usenet_id (options)
	local id = options.id;
	local handler = options.handler;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$') then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		set_message ('err_bad_usenet_id')										-- add an error message if the message id is invalid
		options.coins_list_t['USENETID'] = nil;									-- when error, unset so not included in COinS
	end 
	
	return text;
end


--[[--------------------------&lt; Z B L &gt;-----------------------------------------------------------------------

A numerical identifier in the form nnnn.nnnnn - leading zeros in the first quartet optional

format described here: http://emis.mi.sanu.ac.rs/ZMATH/zmath/en/help/search/

temporary format is apparently eight digits.  Anything else is an error

]]

local function zbl (options)
	local id = options.id;
	local handler = options.handler;

	if id:match('^%d%d%d%d%d%d%d%d$') then										-- is this identifier using temporary format?
		set_message ('maint_zbl');												-- yes, add maint cat
	elseif not id:match('^%d?%d?%d?%d%.%d%d%d%d%d$') then						-- not temporary, is it normal format?
		set_message ('err_bad_zbl');											-- no, set an error message
		options.coins_list_t['ZBL'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--============================&lt;&lt; I N T E R F A C E   F U N C T I O N S &gt;&gt;==========================================

--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message if more than one alias exists in args

]]

local function extract_ids (args)
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs (cfg.id_handlers) do										-- k is uppercase identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one (args, v.parameters, 'err_redundant_parameters' );		-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set (v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; E X T R A C T _ I D _ A C C E S S _ L E V E L S &gt;--------------------------------------

Fetches custom id access levels from arguments using configuration settings. Parameters which have a predefined access
level (e.g. arxiv) do not use this function as they are directly rendered as free without using an additional parameter.

returns a table of k/v pairs where k is same as the identifier's key in cfg.id_handlers and v is the assigned (valid) keyword

access-level values must match the case used in cfg.keywords_lists['id-access'] (lowercase unless there is some special reason for something else)

]]

local function extract_id_access_levels (args, id_list)
	local id_accesses_list = {};
	for k, v in pairs (cfg.id_handlers) do
		local access_param = v.custom_access;									-- name of identifier's access-level parameter
		if is_set (access_param) then
			local access_level = args[access_param];							-- get the assigned value if there is one
			if is_set (access_level) then
				if not in_array (access_level, cfg.keywords_lists['id-access']) then	-- exact match required
					set_message ('err_invalid_param_val', {access_param, access_level});	
					access_level = nil;											-- invalid so unset
				end
				if not is_set (id_list[k]) then									-- identifier access-level must have a matching identifier
					set_message ('err_param_access_requires_param', {k:lower()});	-- parameter name is uppercase in cfg.id_handlers (k); lowercase for error message
				end
				id_accesses_list[k] = cfg.keywords_xlate[access_level];			-- get translated keyword
			end
		end
	end
	return id_accesses_list;
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;----------------------------------------------------

render the identifiers into a sorted sequence table

&lt;ID_list_coins_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value
&lt;options_t&gt; is a table of various k/v option pairs provided in the call to new_build_id_list();
	modified by	this function and passed to all identifier rendering functions
&lt;access_levels_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value (if valid)

returns a sequence table of sorted (by hkey - 'handler' key) rendered identifier strings

]]

local function build_id_list (ID_list_coins_t, options_t, access_levels_t)
	local ID_list_t = {};
	local accept;
	local func_map = {															--function map points to functions associated with hkey identifier
		['ARXIV'] = arxiv,
		['ASIN'] = asin,
		['BIBCODE'] = bibcode,
		['BIORXIV'] = biorxiv,
		['CITESEERX'] = citeseerx,
		['DOI'] = doi,
		['EISSN'] = issn,
		['HDL'] = hdl,
		['ISBN'] = isbn,
		['ISMN'] = ismn,
		['ISSN'] = issn,
		['JFM'] = jfm,
		['JSTOR'] = jstor,
		['LCCN'] = lccn,
		['MEDRXIV'] = medrxiv,
		['MR'] = mr,
		['OCLC'] = oclc,
		['OL'] = openlibrary,
		['OSTI'] = osti,
		['PMC'] = pmc,
		['PMID'] = pmid,
		['RFC']  = rfc,
		['S2CID'] = s2cid,
		['SBN'] = sbn,
		['SSRN'] = ssrn,
		['USENETID'] = usenet_id,
		['ZBL'] = zbl,
		}

	for hkey, v in pairs (ID_list_coins_t) do
		v, accept = has_accept_as_written (v);									-- remove accept-as-written markup if present; accept is boolean true when markup removed; false else
																				-- every function gets the options table with value v and accept boolean
		options_t.hkey = hkey;													-- ~/Configuration handler key
		options_t.id = v;														-- add that identifier value to the options table
		options_t.accept = accept;												-- add the accept boolean flag
		options_t.access = access_levels_t[hkey];								-- add the access level for those that have an |&lt;identifier-access= parameter
		options_t.handler = cfg.id_handlers[hkey];
		options_t.coins_list_t = ID_list_coins_t;								-- pointer to ID_list_coins_t; for |asin= and |ol=; also to keep erroneous values out of the citation's metadata
		options_t.coins_list_t[hkey] = v;										-- id value without accept-as-written markup for metadata
		
		if options_t.handler.access and not in_array (options_t.handler.access, cfg.keywords_lists['id-access']) then
			error (cfg.messages['unknown_ID_access'] .. options_t.handler.access);	-- here when handler access key set to a value not listed in list of allowed id access keywords
		end

		if func_map[hkey] then
			local id_text = func_map[hkey] (options_t);							-- call the function to get identifier text and any error message
			table.insert (ID_list_t, {hkey, id_text});							-- add identifier text to the output sequence table
		else
			error (cfg.messages['unknown_ID_key'] .. hkey);						-- here when func_map doesn't have a function for hkey
		end
	end

	local function comp (a, b)													-- used by following table.sort()
		return a[1]:lower() &lt; b[1]:lower();										-- sort by hkey
	end

	table.sort (ID_list_t, comp);												-- sequence table of tables sort	
	for k, v in ipairs (ID_list_t) do											-- convert sequence table of tables to simple sequence table of strings
		ID_list_t[k] = v[2];													-- v[2] is the identifier rendering from the call to the various functions in func_map{}
	end
	
	return ID_list_t;
end


--[[--------------------------&lt; O P T I O N S _ C H E C K &gt;----------------------------------------------------

check that certain option parameters have their associated identifier parameters with values

&lt;ID_list_coins_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value
&lt;ID_support_t&gt; is a sequence table of tables created in citation0() where each subtable has four elements:
	[1] is the support parameter's assigned value; empty string if not set
	[2] is a text string same as key in cfg.id_handlers
	[3] is cfg.error_conditions key used to create error message
	[4] is original ID support parameter name used to create error message
	
returns nothing; on error emits an appropriate error message

]]

local function options_check (ID_list_coins_t, ID_support_t)
	for _, v in ipairs (ID_support_t) do
		if is_set (v[1]) and not ID_list_coins_t[v[2]] then						-- when support parameter has a value but matching identifier parameter is missing or empty
			set_message (v[3], (v[4]));											-- emit the appropriate error message
		end
	end
end


--[[--------------------------&lt; I D E N T I F I E R _ L I S T S _ G E T &gt;--------------------------------------

Creates two identifier lists: a k/v table of identifiers and their values to be used locally and for use in the
COinS metadata, and a sequence table of the rendered identifier strings that will be included in the rendered
citation.

]]

local function identifier_lists_get (args_t, options_t, ID_support_t)
	local ID_list_coins_t = extract_ids (args_t);										-- get a table of identifiers and their values for use locally and for use in COinS
	options_check (ID_list_coins_t, ID_support_t);										-- ID support parameters must have matching identifier parameters 
	local ID_access_levels_t = extract_id_access_levels (args_t, ID_list_coins_t);		-- get a table of identifier access levels
	local ID_list_t = build_id_list (ID_list_coins_t, options_t, ID_access_levels_t);	-- get a sequence table of rendered identifier strings

	return ID_list_t, ID_list_coins_t;											-- return the tables
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	has_accept_as_written = utilities_page_ptr.has_accept_as_written;			-- import functions from select Module:Citation/CS1/Utilities module
	is_set = utilities_page_ptr.is_set;								
	in_array = utilities_page_ptr.in_array;
	set_message = utilities_page_ptr.set_message;
	select_one = utilities_page_ptr.select_one;
	substitute = utilities_page_ptr.substitute;
	make_wikilink = utilities_page_ptr.make_wikilink;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	auto_link_urls = auto_link_urls,											-- table of identifier URLs to be used when auto-linking |title=
	
	identifier_lists_get = identifier_lists_get,								-- experiment to replace individual calls to build_id_list(), extract_ids, extract_id_access_levels
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>k1dr68mpitw4fjf8xuqkl74nhwowac7</sha1>
    </revision>
    <revision>
      <id>4931</id>
      <parentid>4930</parentid>
      <timestamp>2025-08-07T07:38:57Z</timestamp>
      <contributor>
        <username>Martin Urbanec</username>
        <id>803</id>
      </contributor>
      <minor />
      <comment>69 revisions imported from [[:en:Module:Citation/CS1/Identifiers]]: updating from enwiki</comment>
      <origin>4930</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="78002" sha1="k1dr68mpitw4fjf8xuqkl74nhwowac7" xml:space="preserve">--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local has_accept_as_written, is_set, in_array, set_message, select_one,			-- functions in Module:Citation/CS1/Utilities
		substitute, make_wikilink;

local z;																		-- table of tables defined in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; P A G E   S C O P E   V A R I A B L E S &gt;--------------------------------------

declare variables here that have page-wide scope that are not brought in from other modules; that are created here and used here

]]

local auto_link_urls = {};														-- holds identifier URLs for those identifiers that can auto-link |title=


--============================&lt;&lt; H E L P E R   F U N C T I O N S &gt;&gt;============================================

--[[--------------------------&lt; W I K I D A T A _ A R T I C L E _ N A M E _ G E T &gt;----------------------------

as an aid to internationalizing identifier-label wikilinks, gets identifier article names from Wikidata.

returns :&lt;lang code&gt;:&lt;article title&gt; when &lt;q&gt; has an &lt;article title&gt; for &lt;lang code&gt;; nil else

for identifiers that do not have q, returns nil

for wikis that do not have mw.wikibase installed, returns nil

]]

local function wikidata_article_name_get (q)
	if not is_set (q) or (q and not mw.wikibase) then							-- when no q number or when a q number but mw.wikibase not installed on this wiki
		return nil;																-- abandon
	end

	local wd_article;
	local this_wiki_code = cfg.this_wiki_code;									-- Wikipedia subdomain; 'en' for en.wikipedia.org

	wd_article = mw.wikibase.getSitelink (q, this_wiki_code .. 'wiki');			-- fetch article title from WD; nil when no title available at this wiki

	if wd_article then
		wd_article = table.concat ({':', this_wiki_code, ':', wd_article});		-- interwiki-style link without brackets if taken from WD; leading colon required
	end

	return wd_article;															-- article title from WD; nil else
end


--[[--------------------------&lt; L I N K _ L A B E L _ M A K E &gt;------------------------------------------------

common function to create identifier link label from handler table or from Wikidata

returns the first available of
	1. redirect from local wiki's handler table (if enabled)
	2. Wikidata (if there is a Wikidata entry for this identifier in the local wiki's language)
	3. label specified in the local wiki's handler table
	
]]

local function link_label_make (handler)
	local wd_article;
	
	if not (cfg.use_identifier_redirects and is_set (handler.redirect)) then	-- redirect has priority so if enabled and available don't fetch from Wikidata because expensive
		wd_article = wikidata_article_name_get (handler.q);						-- if Wikidata has an article title for this wiki, get it;
	end
	
	return (cfg.use_identifier_redirects and is_set (handler.redirect) and handler.redirect) or wd_article or handler.link;
end


--[[--------------------------&lt; E X T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki-style external link

]]

local function external_link_id (options)
	local url_string = options.id;
	local ext_link;
	local this_wiki_code = cfg.this_wiki_code;									-- Wikipedia subdomain; 'en' for en.wikipedia.org
	local wd_article;															-- article title from Wikidata
	
	if options.encode == true or options.encode == nil then
		url_string = mw.uri.encode (url_string, 'PATH');
	end

	if options.auto_link and is_set (options.access) then
		auto_link_urls[options.auto_link] = table.concat ({options.prefix, url_string, options.suffix});
	end

	ext_link = mw.ustring.format ('[%s%s%s %s]', options.prefix, url_string, options.suffix or &quot;&quot;, mw.text.nowiki (options.id));
	if is_set (options.access) then
		ext_link = substitute (cfg.presentation['ext-link-access-signal'], {cfg.presentation[options.access].class, cfg.presentation[options.access].title, ext_link});	-- add the free-to-read / paywall lock
	end

	return table.concat	({
		make_wikilink (link_label_make (options), options.label),				-- redirect, Wikidata link, or locally specified link (in that order)
		options.separator or '&amp;nbsp;',
		ext_link
		});
end


--[[--------------------------&lt; I N T E R N A L _ L I N K _ I D &gt;----------------------------------------------

Formats a wiki-style internal link

TODO: Does not currently need to support options.access, options.encode, auto-linking and COinS (as in external_link_id),
but may be needed in the future for :m:Interwiki_map custom-prefixes like :arxiv:, :bibcode:, :DOI:, :hdl:, :ISSN:,
:JSTOR:, :Openlibrary:, :PMID:, :RFC:.

]]

local function internal_link_id (options)
	local id = mw.ustring.gsub (options.id, '%d', cfg.date_names.local_digits);	-- translate 'local' digits to Western 0-9

	return table.concat (
		{
		make_wikilink (link_label_make (options), options.label),				-- wiki-link the identifier label
		options.separator or '&amp;nbsp;',											-- add the separator
		make_wikilink (
			table.concat (
				{
				options.prefix,
				id,																-- translated to Western digits
				options.suffix or ''
				}),
			substitute (cfg.presentation['bdi'], {'', mw.text.nowiki (options.id)})	-- bdi tags to prevent Latin script identifiers from being reversed at RTL language wikis
			);																	-- nowiki because MediaWiki still has magic links for ISBN and the like; TODO: is it really required?
		});
end


--[[--------------------------&lt; I S _ E M B A R G O E D &gt;------------------------------------------------------

Determines if a PMC identifier's online version is embargoed. Compares the date in |pmc-embargo-date= against
today's date.  If embargo date is in the future, returns the content of |pmc-embargo-date=; otherwise, returns
an empty string because the embargo has expired or because |pmc-embargo-date= was not set in this cite.

]]

local function is_embargoed (embargo)
	if is_set (embargo) then
		local lang = mw.getContentLanguage();
		local good1, embargo_date, todays_date;
		good1, embargo_date = pcall (lang.formatDate, lang, 'U', embargo);
		todays_date = lang:formatDate ('U');
	
		if good1 then															-- if embargo date is a good date
			if tonumber (embargo_date) &gt;= tonumber (todays_date) then			-- is embargo date is in the future?
				return embargo;													-- still embargoed
			else
				set_message ('maint_pmc_embargo');								-- embargo has expired; add main cat
				return '';														-- unset because embargo has expired
			end
		end
	end
	return '';																	-- |pmc-embargo-date= not set return empty string
end


--[=[-------------------------&lt; I S _ V A L I D _ R X I V _ D A T E &gt;------------------------------------------

for biorxiv, returns true if:
	2019-12-11T00:00Z &lt;= biorxiv_date &lt; today + 2 days
for medrxiv, returns true if:
	2020-01-01T00:00Z &lt;= medrxiv_date &lt; today + 2 days
	
The dated form of biorxiv identifier has a start date of 2019-12-11.  The Unix timestamp for that date is {{#time:U|2019-12-11}} = 1576022400
The medrxiv identifier has a start date of 2020-01-01.  The Unix timestamp for that date is {{#time:U|2020-01-01}} = 1577836800

&lt;rxiv_date&gt; is the date provided in those |biorxiv= parameter values that are dated and in |medrxiv= parameter values at time 00:00:00 UTC
&lt;today&gt; is the current date at time 00:00:00 UTC plus 48 hours
	if today's date is 2023-01-01T00:00:00 then
		adding 24 hours gives 2023-01-02T00:00:00 – one second more than today
		adding 24 hours gives 2023-01-03T00:00:00 – one second more than tomorrow

inputs:
	&lt;y&gt;, &lt;m&gt;, &lt;d&gt; – year, month, day parts of the date from the birxiv or medrxiv identifier
	&lt;select&gt; 'b' for biorxiv, 'm' for medrxiv; defaults to 'b'

]=]

local function is_valid_rxiv_date (y, m, d, select)
	if 0 == tonumber (m) and 12 &lt; tonumber (m) then								-- &lt;m&gt; must be a number 1–12
		return false;
	end
	if 0 == tonumber (d) and 31 &lt; tonumber (d) then								-- &lt;d&gt; must be a number 1–31; TODO: account for month length and leap yer?
		return false;
	end
	
	local rxiv_date = table.concat ({y, m, d}, '-');							-- make ymd date string
	local good1, good2;
	local rxiv_ts, tomorrow_ts;													-- to hold Unix timestamps representing the dates
	local lang_object = mw.getContentLanguage();

	good1, rxiv_ts = pcall (lang_object.formatDate, lang_object, 'U', rxiv_date);		-- convert rxiv_date value to Unix timestamp 
	good2, tomorrow_ts = pcall (lang_object.formatDate, lang_object, 'U', 'today + 2 days' );	-- today midnight + 2 days is one second more than all day tomorrow
	
	if good1 and good2 then														-- lang.formatDate() returns a timestamp in the local script which tonumber() may not understand
		rxiv_ts = tonumber (rxiv_ts) or lang_object:parseFormattedNumber (rxiv_ts);	-- convert to numbers for the comparison;
		tomorrow_ts = tonumber (tomorrow_ts) or lang_object:parseFormattedNumber (tomorrow_ts);
	else
		return false;															-- one or both failed to convert to Unix timestamp
	end

	local limit_ts = ((select and ('m' == select)) and 1577836800) or 1576022400;	-- choose the appropriate limit timesatmp

	return ((limit_ts &lt;= rxiv_ts) and (rxiv_ts &lt; tomorrow_ts))					-- limit_ts &lt;= rxiv_date &lt; tomorrow's date
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N &gt;-----------------------------------------------------

ISBN-10 and ISSN validator code calculates checksum across all ISBN/ISSN digits including the check digit.
ISBN-13 is checked in isbn().

If the number is valid the result will be 0. Before calling this function, ISBN/ISSN must be checked for length
and stripped of dashes, spaces and other non-ISxN characters.

]]

local function is_valid_isxn (isxn_str, len)
	local temp = 0;
	isxn_str = { isxn_str:byte(1, len) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39, 'X' → 0x58
	len = len + 1;																-- adjust to be a loop counter
	for i, v in ipairs (isxn_str) do											-- loop through all of the bytes and calculate the checksum
		if v == string.byte (&quot;X&quot; ) then											-- if checkdigit is X (compares the byte value of 'X' which is 0x58)
			temp = temp + 10 * (len - i);										-- it represents 10 decimal
		else
			temp = temp + tonumber (string.char (v) )*(len-i);
		end
	end
	return temp % 11 == 0;														-- returns true if calculation result is zero
end


--[[--------------------------&lt; IS _ V A L I D _ I S X N _ 1 3 &gt;-----------------------------------------------

ISBN-13 and ISMN validator code calculates checksum across all 13 ISBN/ISMN digits including the check digit.
If the number is valid, the result will be 0. Before calling this function, ISBN-13/ISMN must be checked for length
and stripped of dashes, spaces and other non-ISxN-13 characters.

]]

local function is_valid_isxn_13 (isxn_str)
	local temp=0;
	
	isxn_str = { isxn_str:byte(1, 13) };										-- make a table of byte values '0' → 0x30 .. '9' → 0x39
	for i, v in ipairs (isxn_str) do
		temp = temp + (3 - 2*(i % 2)) * tonumber (string.char (v) );			-- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
	end
	return temp % 10 == 0;														-- sum modulo 10 is zero when ISBN-13/ISMN is correct
end


--[[--------------------------&lt; N O R M A L I Z E _ L C C N &gt;--------------------------------------------------

LCCN normalization (https://www.loc.gov/marc/lccn-namespace.html#normalization)
1. Remove all blanks.
2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
3. If there is a hyphen in the string:
	a. Remove it.
	b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
		1. All these characters should be digits, and there should be six or less. (not done in this function)
		2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.

Returns a normalized LCCN for lccn() to validate.  There is no error checking (step 3.b.1) performed in this function.

]]

local function normalize_lccn (lccn)
	lccn = lccn:gsub (&quot;%s&quot;, &quot;&quot;);												-- 1. strip whitespace

	if nil ~= string.find (lccn, '/') then
		lccn = lccn:match (&quot;(.-)/&quot;);											-- 2. remove forward slash and all character to the right of it
	end

	local prefix
	local suffix
	prefix, suffix = lccn:match (&quot;(.+)%-(.+)&quot;);									-- 3.a remove hyphen by splitting the string into prefix and suffix

	if nil ~= suffix then														-- if there was a hyphen
		suffix = string.rep(&quot;0&quot;, 6-string.len (suffix)) .. suffix;				-- 3.b.2 left fill the suffix with 0s if suffix length less than 6
		lccn = prefix..suffix;													-- reassemble the LCCN
	end
	
	return lccn;
end


--============================&lt;&lt; I D E N T I F I E R   F U N C T I O N S &gt;&gt;====================================

--[[--------------------------&lt; A R X I V &gt;--------------------------------------------------------------------

See: https://arxiv.org/help/arxiv_identifier

format and error check arXiv identifier.  There are three valid forms of the identifier:
the first form, valid only between date codes 9107 and 0703, is:
	arXiv:&lt;archive&gt;.&lt;class&gt;/&lt;date code&gt;&lt;number&gt;&lt;version&gt;
where:
	&lt;archive&gt; is a string of alpha characters - may be hyphenated; no other punctuation
	&lt;class&gt; is a string of alpha characters - may be hyphenated; no other punctuation; not the same as |class= parameter which is not supported in this form
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
		first digit of YY for this form can only 9 and 0
	&lt;number&gt; is a three-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
	
the second form, valid from April 2007 through December 2014 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
	&lt;number&gt; is a four-digit number
	&lt;version&gt; is a 1 or more digit number preceded with a lowercase v; no spaces

the third form, valid from January 2015 is:
	arXiv:&lt;date code&gt;.&lt;number&gt;&lt;version&gt;
where:
	&lt;date code&gt; and &lt;version&gt; are as defined for 0704-1412
	&lt;number&gt; is a five-digit number

]]

local function arxiv (options)
	local id = options.id;
	local class = options.Class;												-- TODO: lowercase?
	local handler = options.handler;
	local year, month, version;
	local err_msg = false;														-- assume no error message
	local text;																	-- output text
	
	if id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$&quot;) or id:match(&quot;^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$&quot;) then	-- test for the 9107-0703 format with or without version
		year, month = id:match(&quot;^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((not (90 &lt; year or 8 &gt; year)) or (1 &gt; month or 12 &lt; month)) or		-- if invalid year or invalid month
			((91 == year and 7 &gt; month) or (7 == year and 3 &lt; month)) then		-- if years ok, are starting and ending months ok?
				err_msg = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%dv%d+$&quot;) then	-- test for the 0704-1412 with or without version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((7 &gt; year) or (14 &lt; year) or (1 &gt; month or 12 &lt; month)) or			-- is year invalid or is month invalid? (doesn't test for future years)
			((7 == year) and (4 &gt; month)) then									-- when year is 07, is month invalid (before April)?
				err_msg = true;													-- flag for error message
		end

	elseif id:match(&quot;^%d%d[01]%d%.%d%d%d%d%d$&quot;) or id:match(&quot;^%d%d[01]%d%.%d%d%d%d%dv%d+$&quot;) then	-- test for the 1501- format with or without version
		year, month = id:match(&quot;^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$&quot;);
		year = tonumber (year);
		month = tonumber (month);
		if ((15 &gt; year) or (1 &gt; month or 12 &lt; month)) then						-- is year invalid or is month invalid? (doesn't test for future years)
			err_msg = true;														-- flag for error message
		end

	else
		err_msg = true;															-- not a recognized format; flag for error message
	end

	if err_msg then
		options.coins_list_t['ARXIV'] = nil;									-- when error, unset so not included in COinS
	end
	
	local err_msg_t = {};
	if err_msg then
		set_message ('err_bad_arxiv');
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access});

	if is_set (class) then
		if id:match ('^%d+') then
			text = table.concat ({text, ' [[https://arxiv.org/archive/', class, ' ', class, ']]'});	-- external link within square brackets, not wikilink
		else
			set_message ('err_class_ignored');
		end
	end

	return text;
end


--[[--------------------------&lt; B I B C O D E &gt;--------------------------------------------------------------------

Validates (sort of) and formats a bibcode ID.

Format for bibcodes is specified here: https://adsabs.harvard.edu/abs_doc/help_pages/data.html#bibcodes

But, this: 2015arXiv151206696F is apparently valid so apparently, the only things that really matter are length, 19 characters
and first four digits must be a year.  This function makes these tests:
	length must be 19 characters
	characters in position
		1–4 must be digits and must represent a year in the range of 1000 – next year
		5 must be a letter
		6–8 must be letter, digit, ampersand, or dot (ampersand cannot directly precede a dot; &amp;. )
		9–18 must be letter, digit, or dot
		19 must be a letter or dot

]]

local function bibcode (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local ignore_invalid = options.accept;
	local err_type;
	local err_msg = '';
	local year;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode,
		access = access});
	
	if 19 ~= id:len() then
		err_type = cfg.err_msg_supl.length;
	else
		year = id:match (&quot;^(%d%d%d%d)[%a][%w&amp;%.][%w&amp;%.][%w&amp;%.][%w.]+[%a%.]$&quot;);
		if not year then														-- if nil then no pattern match
			err_type = cfg.err_msg_supl.value;									-- so value error
		else
			local next_year = tonumber (os.date ('%Y')) + 1;					-- get the current year as a number and add one for next year
			year = tonumber (year);												-- convert year portion of bibcode to a number
			if (1000 &gt; year) or (year &gt; next_year) then
				err_type = cfg.err_msg_supl.year;								-- year out of bounds
			end
			if id:find('&amp;%.') then
				err_type = cfg.err_msg_supl.journal;							-- journal abbreviation must not have '&amp;.' (if it does it's missing a letter)
			end
			if id:match ('.........%.tmp%.') then								-- temporary bibcodes when positions 10–14 are '.tmp.'
				set_message ('maint_bibcode');
			end
		end
	end

	if is_set (err_type) and not ignore_invalid then							-- if there was an error detected and accept-as-written markup not used
		set_message ('err_bad_bibcode', {err_type});
		options.coins_list_t['BIBCODE'] = nil;									-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; B I O R X I V &gt;-----------------------------------------------------------------

Format bioRxiv ID and do simple error checking.  Before 2019-12-11, biorXiv IDs were 10.1101/ followed by exactly
6 digits.  After 2019-12-11, biorXiv IDs retained the six-digit identifier but prefixed that with a yyyy.mm.dd. 
date and suffixed with an optional version identifier.

The bioRxiv ID is the string of characters:
	https://doi.org/10.1101/078733 -&gt; 10.1101/078733
or a date followed by a six-digit number followed by an optional version indicator 'v' and one or more digits:
	https://www.biorxiv.org/content/10.1101/2019.12.11.123456v2 -&gt; 10.1101/2019.12.11.123456v2
	
see https://www.biorxiv.org/about-biorxiv

]]

local function biorxiv (options)
	local id = options.id;
	local handler = options.handler;
	local err_msg = true;														-- flag; assume that there will be an error
	
	local patterns = {
		'^10%.1101/%d%d%d%d%d%d$',												-- simple 6-digit identifier (before 2019-12-11)
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%dv%d+$',				-- y.m.d. date + 6-digit identifier + version (after 2019-12-11)
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%d$',					-- y.m.d. date + 6-digit identifier (after 2019-12-11)
		}
	
	for _, pattern in ipairs (patterns) do										-- spin through the patterns looking for a match
		if id:match (pattern) then
			local y, m, d = id:match (pattern);									-- found a match, attempt to get year, month and date from the identifier

			if m then															-- m is nil when id is the six-digit form
				if not is_valid_rxiv_date (y, m, d, 'b') then					-- validate the encoded date; 'b' for biorxiv limit
					break;														-- date fail; break out early so we don't unset the error message
				end
			end
			err_msg = nil;														-- we found a match so unset the error message
			break;																-- and done
		end
	end																			-- err_cat remains set here when no match

	if err_msg then
		options.coins_list_t['BIORXIV'] = nil;									-- when error, unset so not included in COinS
		set_message ('err_bad_biorxiv');										-- and set the error message
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator,
			encode = handler.encode, access = handler.access});
end


--[[--------------------------&lt; C I T E S E E R X &gt;------------------------------------------------------------

CiteSeerX use their own notion of &quot;doi&quot; (not to be confused with the identifiers resolved via doi.org).

The description of the structure of this identifier can be found at Help_talk:Citation_Style_1/Archive_26#CiteSeerX_id_structure

]]

local function citeseerx (options)
	local id = options.id;
	local handler = options.handler;
	local matched;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode,
		access = handler.access});
	
	matched = id:match (&quot;^10%.1%.1%.[1-9]%d?%d?%d?%.[1-9]%d?%d?%d?$&quot;);
	if not matched then
		set_message ('err_bad_citeseerx' );
		options.coins_list_t['CITESEERX'] = nil;								-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; D O I &gt;------------------------------------------------------------------------

Formats a DOI and checks for DOI errors.

DOI names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: directory indicator '10.' followed by a registrant code
	Suffix: character string of any length chosen by the registrant

This function checks a DOI name for: prefix/suffix.  If the DOI name contains spaces or endashes, or, if it ends
with a period or a comma, this function will emit a bad_doi error message.

DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in DOI names.

https://www.doi.org/doi_handbook/2_Numbering.html				-- 2.2 Syntax of a DOI name
https://www.doi.org/doi_handbook/2_Numbering.html#2.2.2			-- 2.2.2 DOI prefix

]]

local function doi (options)
	local id = options.id;
	local inactive = options.DoiBroken
	local access = options.access;
	local ignore_invalid = options.accept;
	local handler = options.handler;
	local err_flag;

	local function is_extended_free (registrant, suffix)						-- local function to check those few registrants that are mixed; identifiable by the doi suffix &lt;incipit&gt;
		if cfg.extended_registrants_t[registrant] then							-- if this registrant has known free-to-read extentions
			for _, incipit in ipairs (cfg.extended_registrants_t[registrant]) do	-- loop through the registrant's incipits
				if mw.ustring.find (suffix, '^' .. incipit) then				-- if found
					return true;
				end
			end
		end
	end

	local text;
	if is_set (inactive) then
		local inactive_year = inactive:match(&quot;%d%d%d%d&quot;);						-- try to get the year portion from the inactive date
		local inactive_month, good;

		if is_set (inactive_year) then
			if 4 &lt; inactive:len() then											-- inactive date has more than just a year (could be anything)
				local lang_obj = mw.getContentLanguage();						-- get a language object for this wiki
				good, inactive_month = pcall (lang_obj.formatDate, lang_obj, 'F', inactive);	-- try to get the month name from the inactive date
				if not good then
					inactive_month = nil;										-- something went wrong so make sure this is unset
				end
			end
		end																		-- otherwise, |doi-broken-date= has something but it isn't a date
		
		if is_set (inactive_year) and is_set (inactive_month) then
			set_message ('maint_doi_inactive_dated', {inactive_year, inactive_month, ' '});
		elseif is_set (inactive_year) then
			set_message ('maint_doi_inactive_dated', {inactive_year, '', ''});
		else
			set_message ('maint_doi_inactive');
		end
		inactive = &quot; (&quot; .. cfg.messages['inactive'] .. ' ' .. inactive .. ')';
	end

	local suffix;
	local registrant, suffix = mw.ustring.match (id, '^10%.([^/]+)/([^%s–]-[^%.,])$');	-- registrant and suffix set when DOI has the proper basic form

	local registrant_err_patterns = {											-- these patterns are for code ranges that are not supported 
		'^[^1-3]%d%d%d%d%.%d+$',												-- 5 digits with subcode (0xxxx, 40000+); accepts: 10000–39999
		'^[^1-7]%d%d%d%d$',														-- 5 digits without subcode (0xxxx, 60000+); accepts: 10000–69999
		'^[^1-9]%d%d%d%.%d+$',												-- 4 digits with subcode (0xxx); accepts: 1000–9999
		'^[^1-9]%d%d%d$',														-- 4 digits without subcode (0xxx); accepts: 1000–9999
		'^%d%d%d%d%d%d+',														-- 6 or more digits
		'^%d%d?%d?$',															-- less than 4 digits without subcode (3 digits with subcode is legitimate)
		'^%d%d?%.[%d%.]+',														-- 1 or 2 digits with subcode
		'^5555$',																-- test registrant will never resolve
		'[^%d%.]',																-- any character that isn't a digit or a dot
		}

	if not ignore_invalid then
		if registrant then														-- when DOI has proper form
			for i, pattern in ipairs (registrant_err_patterns) do				-- spin through error patterns
				if registrant:match (pattern) then								-- to validate registrant codes
					err_flag = set_message ('err_bad_doi');						-- when found, mark this DOI as bad
					break;														-- and done
				end
			end
		else
			err_flag = set_message ('err_bad_doi');								-- invalid directory or malformed
		end
	else
		set_message ('maint_doi_ignore');
	end

	if err_flag then
		options.coins_list_t['DOI'] = nil;										-- when error, unset so not included in COinS
	else
		if not access and (cfg.known_free_doi_registrants_t[registrant] or is_extended_free (registrant, suffix)) then		-- |doi-access=free not set and &lt;registrant&gt; is known to be free
			set_message ('maint_doi_unflagged_free');							-- set a maint cat
		end
	end
	
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access,
		auto_link = not (err_flag or is_set (inactive) or ignore_invalid) and 'doi' or nil -- do not auto-link when |doi-broken-date= has a value or when there is a DOI error or (to play it safe, after all, auto-linking is not essential) when invalid DOIs are ignored
		}) .. (inactive or '');

	return text;
end


--[[--------------------------&lt; H D L &gt;------------------------------------------------------------------------

Formats an HDL with minor error checking.

HDL names contain two parts: prefix and suffix separated by a forward slash.
	Prefix: character string using any character in the UCS-2 character set except '/'
	Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant

This function checks a HDL name for: prefix/suffix.  If the HDL name contains spaces, endashes, or, if it ends
with a period or a comma, this function will emit a bad_hdl error message.

HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
if ever used in HDLs.

Query string parameters are named here: https://www.handle.net/proxy_servlet.html.  query strings are not displayed
but since '?' is an allowed character in an HDL, '?' followed by one of the query parameters is the only way we
have to detect the query string so that it isn't URL-encoded with the rest of the identifier.

]]

local function hdl (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local query_params = {														-- list of known query parameters from https://www.handle.net/proxy_servlet.html
		'noredirect',
		'ignore_aliases',
		'auth',
		'cert',
		'index',
		'type',
		'urlappend',
		'locatt',
		'action',
		}
	
	local hdl, suffix, param = id:match ('(.-)(%?(%a+).+)$');					-- look for query string
	local found;

	if hdl then																	-- when there are query strings, this is the handle identifier portion
		for _, q in ipairs (query_params) do									-- spin through the list of query parameters
			if param:match ('^' .. q) then										-- if the query string begins with one of the parameters
				found = true;													-- announce a find
				break;															-- and stop looking
			end
		end
	end

	if found then
		id = hdl;																-- found so replace id with the handle portion; this will be URL-encoded, suffix will not
	else
		suffix = '';															-- make sure suffix is empty string for concatenation else
	end

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, suffix = suffix, separator = handler.separator, encode = handler.encode, access = access})

	if nil == id:match(&quot;^[^%s–]-/[^%s–]-[^%.,]$&quot;) then							-- HDL must contain a forward slash, must not contain spaces, endashes, and must not end with period or comma
		set_message ('err_bad_hdl' );
		options.coins_list_t['HDL'] = nil;										-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; I S B N &gt;----------------------------------------------------------------------

Determines whether an ISBN string is valid

]]

local function isbn (options_t)
	local isbn_str = options_t.id;
	local ignore_invalid = options_t.accept;
	local handler = options_t.handler;
	local year = options_t.Year;												-- when set, valid anchor_year; may have a disambiguator which must be removed

	local function return_result (check, err_type)								-- local function to handle the various returns
		local ISBN = internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,
						prefix = handler.prefix, id = isbn_str, separator = handler.separator});
		if ignore_invalid then													-- if ignoring ISBN errors
			set_message ('maint_isbn_ignore');									-- add a maint category even when there is no error
		else																	-- here when not ignoring
			if not check then													-- and there is an error
				options_t.coins_list_t['ISBN'] = nil;								-- when error, unset so not included in COinS
				set_message ('err_bad_isbn', err_type);							-- set an error message
				return ISBN;										 			-- return id text
			end
		end
		return ISBN;															-- return id text
	end

	if year and not ignore_invalid then											-- 
		year = year:match ('%d%d%d%d?');										-- strip disambiguator if present
		if year and (1965 &gt; tonumber(year)) then
			set_message ('err_invalid_isbn_date');								-- set an error message
			return internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,
					prefix = handler.prefix, id = isbn_str, separator = handler.separator});
		end
	end

	if nil ~= isbn_str:match ('[^%s-0-9X]') then
		return return_result (false, cfg.err_msg_supl.char);					-- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
	end

	local id = isbn_str:gsub ('[%s-]', '');										-- remove hyphens and whitespace

	local len = id:len();
 
	if len ~= 10 and len ~= 13 then
		return return_result (false, cfg.err_msg_supl.length);					-- fail if incorrect length
	end

	if len == 10 then
		if id:match ('^%d*X?$') == nil then										-- fail if isbn_str has 'X' anywhere but last position
			return return_result (false, cfg.err_msg_supl.form);									
		end
		if not is_valid_isxn (id, 10) then										-- test isbn-10 for numerical validity
			return return_result (false, cfg.err_msg_supl.check);				-- fail if isbn-10 is not numerically valid
		end
		if id:find ('^63[01]') then												-- 630xxxxxxx and 631xxxxxxx are (apparently) not valid isbn group ids but are used by amazon as numeric identifiers (asin)
			return return_result (false, cfg.err_msg_supl.group);				-- fail if isbn-10 begins with 630/1
		end
		return return_result (true, cfg.err_msg_supl.check);					-- pass if isbn-10 is numerically valid
	else
		if id:match ('^%d+$') == nil then
			return return_result (false, cfg.err_msg_supl.char);				-- fail if ISBN-13 is not all digits
		end
		if id:match ('^97[89]%d*$') == nil then
			return return_result (false, cfg.err_msg_supl.prefix);				-- fail when ISBN-13 does not begin with 978 or 979
		end
		if id:match ('^9790') then
			return return_result (false, cfg.err_msg_supl.group);				-- group identifier '0' is reserved to ISMN
		end
		return return_result (is_valid_isxn_13 (id), cfg.err_msg_supl.check);
	end
end


--[[--------------------------&lt; A S I N &gt;----------------------------------------------------------------------

Formats a link to Amazon.  Do simple error checking: ASIN must be mix of 10 numeric or uppercase alpha
characters.  If a mix, first character must be uppercase alpha; if all numeric, ASINs must be 10-digit
ISBN. If 10-digit ISBN, add a maintenance category so a bot or AWB script can replace |asin= with |isbn=.
Error message if not 10 characters, if not ISBN-10, if mixed and first character is a digit.

|asin=630....... and |asin=631....... are (apparently) not a legitimate ISBN though it checksums as one; these
do not cause this function to emit the maint_asin message

This function is positioned here because it calls isbn()

]]

local function asin (options)
	local id = options.id;
	local domain = options.ASINTLD;
	
	local err_flag;

	if not id:match(&quot;^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$&quot;) then
		err_flag = set_message ('err_bad_asin');								-- ASIN is not a mix of 10 uppercase alpha and numeric characters
	else
		if id:match(&quot;^%d%d%d%d%d%d%d%d%d[%dX]$&quot;) then							-- if 10-digit numeric (or 9 digits with terminal X)
			if is_valid_isxn (id, 10) then										-- see if ASIN value is or validates as ISBN-10
				if not id:find ('^63[01]') then									-- 630xxxxxxx and 631xxxxxxx are (apparently) not a valid isbn prefixes but are used by amazon as a numeric identifier
					err_flag = set_message ('err_bad_asin');					-- ASIN has ISBN-10 form but begins with something other than 630/1 so probably an isbn 
				end
			elseif not is_set (err_flag) then
				err_flag = set_message ('err_bad_asin');						-- ASIN is not ISBN-10
			end
		elseif not id:match(&quot;^%u[%d%u]+$&quot;) then
			err_flag = set_message ('err_bad_asin');							-- asin doesn't begin with uppercase alpha
		end
	end
	if (not is_set (domain)) or in_array (domain, {'us'}) then					-- default: United States
		domain = &quot;com&quot;;
	elseif in_array (domain, {'jp', 'uk'}) then									-- Japan, United Kingdom
		domain = &quot;co.&quot; .. domain;
	elseif in_array (domain, {'z.cn'}) then 									-- China
		domain = &quot;cn&quot;;
	elseif in_array (domain, {'au', 'br', 'mx', 'sg', 'tr'}) then				-- Australia, Brazil, Mexico, Singapore, Turkey
		domain = &quot;com.&quot; .. domain;
	elseif not in_array (domain, {'ae', 'ca', 'cn', 'de', 'es', 'fr', 'in', 'it', 'nl', 'pl', 'sa', 'se', 'co.jp', 'co.uk', 'com', 'com.au', 'com.br', 'com.mx', 'com.sg', 'com.tr'}) then -- Arabic Emirates, Canada, China, Germany, Spain, France, Indonesia, Italy, Netherlands, Poland, Saudi Arabia, Sweden (as of 2021-03 Austria (.at), Liechtenstein (.li) and Switzerland (.ch) still redirect to the German site (.de) with special settings, so don't maintain local ASINs for them)
		err_flag = set_message ('err_bad_asin_tld');							-- unsupported asin-tld value
	end
	local handler = options.handler;

	if not is_set (err_flag) then
		options.coins_list_t['ASIN'] = handler.prefix .. domain .. &quot;/dp/&quot; .. id;	-- asin for coins
	else
		options.coins_list_t['ASIN'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix .. domain .. &quot;/dp/&quot;,
		id = id, encode = handler.encode, separator = handler.separator})
end


--[[--------------------------&lt; I S M N &gt;----------------------------------------------------------------------

Determines whether an ISMN string is valid.  Similar to ISBN-13, ISMN is 13 digits beginning 979-0-... and uses the
same check digit calculations.  See https://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
section 2, pages 9–12.

ismn value not made part of COinS metadata because we don't have a url or isn't a COinS-defined identifier (rft.xxx)
or an identifier registered at info-uri.info (info:)

]]

local function ismn (options)
	local id = options.id;
	local handler = options.handler;
	local text;
	local valid_ismn = true;
	local id_copy;

	id_copy = id;																-- save a copy because this testing is destructive
	id = id:gsub ('[%s-]', '');													-- remove hyphens and white space

	if 13 ~= id:len() or id:match (&quot;^9790%d*$&quot; ) == nil then					-- ISMN must be 13 digits and begin with 9790
		valid_ismn = false;
	else
		valid_ismn=is_valid_isxn_13 (id);										-- validate ISMN
	end

	--	text = internal_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,		-- use this (or external version) when there is some place to link to
	--		prefix = handler.prefix, id = id_copy, separator = handler.separator, encode = handler.encode})

	text = table.concat (														-- because no place to link to yet
		{
		make_wikilink (link_label_make (handler), handler.label),
		handler.separator,
		id_copy
		});

	if false == valid_ismn then
		options.coins_list_t['ISMN'] = nil;										-- when error, unset so not included in COinS; not really necessary here because ismn not made part of COinS
		set_message ('err_bad_ismn');											-- create an error message if the ISMN is invalid
	end 
	
	return text;
end


--[[--------------------------&lt; I S S N &gt;----------------------------------------------------------------------

Validate and format an ISSN.  This code fixes the case where an editor has included an ISSN in the citation but
has separated the two groups of four digits with a space.  When that condition occurred, the resulting link looked
like this:

	|issn=0819 4327 gives: [https://www.worldcat.org/issn/0819 4327 0819 4327]	-- can't have spaces in an external link
	
This code now prevents that by inserting a hyphen at the ISSN midpoint.  It also validates the ISSN for length
and makes sure that the checkdigit agrees with the calculated value.  Incorrect length (8 digits), characters
other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check ISSN error message.  The
ISSN is always displayed with a hyphen, even if the ISSN was given as a single group of 8 digits.

]]

local function issn (options)
	local id = options.id;
	local handler = options.handler;
	local ignore_invalid = options.accept;

	local issn_copy = id;														-- save a copy of unadulterated ISSN; use this version for display if ISSN does not validate
	local text;
	local valid_issn = true;

	id = id:gsub ('[%s-]', '');													-- remove hyphens and whitespace

	if 8 ~= id:len() or nil == id:match (&quot;^%d*X?$&quot; ) then						-- validate the ISSN: 8 digits long, containing only 0-9 or X in the last position
		valid_issn = false;														-- wrong length or improper character
	else
		valid_issn = is_valid_isxn (id, 8);										-- validate ISSN
	end

	if true == valid_issn then
		id = string.sub (id, 1, 4 ) .. &quot;-&quot; .. string.sub (id, 5 );				-- if valid, display correctly formatted version
	else
		id = issn_copy;															-- if not valid, show the invalid ISSN with error message
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode})

	if ignore_invalid then
		set_message ('maint_issn_ignore');
	else
		if false == valid_issn then
			options.coins_list_t['ISSN'] = nil;									-- when error, unset so not included in COinS
			set_message ('err_bad_issn', (options.hkey == 'EISSN') and 'e' or '');	-- create an error message if the ISSN is invalid
		end 
	end
	
	return text;
end


--[[--------------------------&lt; J F M &gt;-----------------------------------------------------------------------

A numerical identifier in the form nn.nnnn.nn

]]

local function jfm (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;

	id_num = id:match ('^[Jj][Ff][Mm](.*)$');									-- identifier with jfm prefix; extract identifier

	if is_set (id_num) then
		set_message ('maint_jfm_format');
	else																		-- plain number without JFM prefix
		id_num = id;															-- if here id does not have prefix
	end

	if id_num and id_num:match('^%d%d%.%d%d%d%d%.%d%d$') then
		id = id_num;															-- jfm matches pattern
	else
		set_message ('err_bad_jfm' );											-- set an error message
		options.coins_list_t['JFM'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; J S T O R &gt;--------------------------------------------------------------------

Format a JSTOR with some error checking

]]

local function jstor (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;

	if id:find ('[Jj][Ss][Tt][Oo][Rr]') or id:find ('^https?://') or id:find ('%s') then
		set_message ('err_bad_jstor');											-- set an error message
		options.coins_list_t['JSTOR'] = nil;									-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});
end


--[[--------------------------&lt; L C C N &gt;----------------------------------------------------------------------

Format LCCN link and do simple error checking.  LCCN is a character string 8-12 characters long. The length of
the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
https://oclc-research.github.io/infoURI-Frozen/info-uri.info/info:lccn/reg.html

length = 8 then all digits
length = 9 then lccn[1] is lowercase alpha
length = 10 then lccn[1] and lccn[2] are both lowercase alpha or both digits
length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lowercase alpha or both digits
length = 12 then lccn[1] and lccn[2] are both lowercase alpha

]]

local function lccn (options)
	local lccn = options.id;
	local handler = options.handler;
	local err_flag;																-- presume that LCCN is valid
	local id = lccn;															-- local copy of the LCCN

	id = normalize_lccn (id);													-- get canonical form (no whitespace, hyphens, forward slashes)
	local len = id:len();														-- get the length of the LCCN

	if 8 == len then
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits)
			err_flag = set_message ('err_bad_lccn');							-- set an error message
		end
	elseif 9 == len then														-- LCCN should be adddddddd
		if nil == id:match(&quot;%l%d%d%d%d%d%d%d%d&quot;) then							-- does it match our pattern?
			err_flag = set_message ('err_bad_lccn');							-- set an error message
		end
	elseif 10 == len then														-- LCCN should be aadddddddd or dddddddddd
		if id:match(&quot;[^%d]&quot;) then												-- if LCCN has anything but digits (nil if only digits) ...
			if nil == id:match(&quot;^%l%l%d%d%d%d%d%d%d%d&quot;) then					-- ... see if it matches our pattern
				err_flag = set_message ('err_bad_lccn');						-- no match, set an error message
			end
		end
	elseif 11 == len then														-- LCCN should be aaadddddddd or adddddddddd
		if not (id:match(&quot;^%l%l%l%d%d%d%d%d%d%d%d&quot;) or id:match(&quot;^%l%d%d%d%d%d%d%d%d%d%d&quot;)) then	-- see if it matches one of our patterns
			err_flag = set_message ('err_bad_lccn');							-- no match, set an error message
		end
	elseif 12 == len then														-- LCCN should be aadddddddddd
		if not id:match(&quot;^%l%l%d%d%d%d%d%d%d%d%d%d&quot;) then						-- see if it matches our pattern
			err_flag = set_message ('err_bad_lccn');							-- no match, set an error message
		end
	else
		err_flag = set_message ('err_bad_lccn');								-- wrong length, set an error message
	end

	if not is_set (err_flag) and nil ~= lccn:find ('%s') then
		err_flag = set_message ('err_bad_lccn');								-- lccn contains a space, set an error message
	end

	if is_set (err_flag) then
		options.coins_list_t['LCCN'] = nil;										-- when error, unset so not included in COinS
	end

	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = lccn, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; M E D R X I V &gt;-----------------------------------------------------------------

Format medRxiv ID and do simple error checking.  Similar to later bioRxiv IDs, medRxiv IDs are prefixed with a
yyyy.mm.dd. date and suffixed with an optional version identifier.  Ealiest date accepted is 2020.01.01

The medRxiv ID is a date followed by an eight-digit number followed by an optional version indicator 'v' and one or more digits:
	https://www.medrxiv.org/content/10.1101/2020.11.16.20232009v2 -&gt; 10.1101/2020.11.16.20232009v2

]]

local function medrxiv (options)
	local id = options.id;
	local handler = options.handler;
	local err_msg_flag = true;													-- flag; assume that there will be an error

	local patterns = {
		'%d%d%d%d%d%d%d%d$',													-- simple 8-digit identifier; these should be relatively rare
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%d%d%dv%d+$',			-- y.m.d. date + 8-digit identifier + version (2020-01-01 and later)
		'^10%.1101/(20%d%d)%.(%d%d)%.(%d%d)%.%d%d%d%d%d%d%d%d$',				-- y.m.d. date + 8-digit identifier (2020-01-01 and later)
		}
	
	for _, pattern in ipairs (patterns) do										-- spin through the patterns looking for a match
		if id:match (pattern) then
			local y, m, d = id:match (pattern);									-- found a match, attempt to get year, month and date from the identifier

			if m then															-- m is nil when id is the 8-digit form
				if not is_valid_rxiv_date (y, m, d, 'b') then					-- validate the encoded date; 'b' for medrxiv limit
					break;														-- date fail; break out early so we don't unset the error message
				end
			end
			err_msg_flag = nil;													-- we found a match so unset the error message
			break;																-- and done
		end
	end																			-- &lt;err_msg_flag&gt; remains set here when no match

	if err_msg_flag then
		options.coins_list_t['MEDRXIV'] = nil;									-- when error, unset so not included in COinS
		set_message ('err_bad_medrxiv');										-- and set the error message
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator,
			encode = handler.encode, access = handler.access});
end


--[[--------------------------&lt; M R &gt;--------------------------------------------------------------------------

A seven digit number; if not seven digits, zero-fill leading digits to make seven digits.

]]

local function mr (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;
	local id_len;

	id_num = id:match ('^[Mm][Rr](%d+)$');										-- identifier with mr prefix

	if is_set (id_num) then
		set_message ('maint_mr_format');										-- add maint cat
	else																		-- plain number without mr prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	id_len = id_num and id_num:len() or 0;
	if (7 &gt;= id_len) and (0 ~= id_len) then
		id = string.rep ('0', 7-id_len) .. id_num;								-- zero-fill leading digits
	else
		set_message ('err_bad_mr');												-- set an error message
		options.coins_list_t['MR'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; O C L C &gt;----------------------------------------------------------------------

Validate and format an OCLC ID.  https://www.oclc.org/batchload/controlnumber.en.html {{dead link}}
archived at: https://web.archive.org/web/20161228233804/https://www.oclc.org/batchload/controlnumber.en.html

]]

local function oclc (options)
	local id = options.id;
	local handler = options.handler;
	local number;

	if id:match('^ocm%d%d%d%d%d%d%d%d$') then									-- ocm prefix and 8 digits; 001 field (12 characters)
		number = id:match('ocm(%d+)');											-- get the number
	elseif id:match('^ocn%d%d%d%d%d%d%d%d%d$') then								-- ocn prefix and 9 digits; 001 field (12 characters)
		number = id:match('ocn(%d+)');											-- get the number
	elseif id:match('^on%d%d%d%d%d%d%d%d%d%d+$') then							-- on prefix and 10 or more digits; 001 field (12 characters)
		number = id:match('^on(%d%d%d%d%d%d%d%d%d%d+)$');						-- get the number
	elseif id:match('^%(OCoLC%)[1-9]%d*$') then									-- (OCoLC) prefix and variable number digits; no leading zeros; 035 field
		number = id:match('%(OCoLC%)([1-9]%d*)');								-- get the number
		if 9 &lt; number:len() then
			number = nil;														-- constrain to 1 to 9 digits; change this when OCLC issues 10-digit numbers
		end
	elseif id:match('^%d+$') then												-- no prefix
		number = id;															-- get the number
		if tonumber (id) &gt; handler.id_limit then
			number = nil;														-- unset when id value exceeds the limit
		end
	end

	if number then																-- proper format
		id = number;															-- exclude prefix, if any, from external link
	else
		set_message ('err_bad_oclc')											-- add an error message if the id is malformed
		options.coins_list_t['OCLC'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; O P E N L I B R A R Y &gt;--------------------------------------------------------

Formats an OpenLibrary link, and checks for associated errors.

]]

local function openlibrary (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local ident, code = id:gsub('^OL', ''):match(&quot;^(%d+([AMW]))$&quot;);				-- strip optional OL prefix followed immediately by digits followed by 'A', 'M', or 'W';
	local err_flag;
	local prefix = {															-- these are appended to the handler.prefix according to code
		['A']='authors/OL',
		['M']='books/OL',
		['W']='works/OL',
		['X']='OL'																-- not a code; spoof when 'code' in id is invalid
		};

	if not ident then
		code = 'X';																-- no code or id completely invalid
		ident = id;																-- copy id to ident so that we display the flawed identifier
		err_flag = set_message ('err_bad_ol');
	end

	if not is_set (err_flag) then
		options.coins_list_t['OL'] = handler.prefix .. prefix[code] .. ident;	-- experiment for ol coins
	else
		options.coins_list_t['OL'] = nil;										-- when error, unset so not included in COinS
	end

	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix .. prefix[code],
		id = ident, separator = handler.separator, encode = handler.encode,
		access = access});
end


--[[--------------------------&lt; O S T I &gt;----------------------------------------------------------------------

Format OSTI and do simple error checking. OSTIs are sequential numbers beginning at 1 and counting up.  This
code checks the OSTI to see that it contains only digits and is less than test_limit specified in the configuration;
the value in test_limit will need to be updated periodically as more OSTIs are issued.

NB. 1018 is the lowest OSTI number found in the wild (so far) and resolving OK on the OSTI site

]]

local function osti (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;

	if id:match(&quot;[^%d]&quot;) then													-- if OSTI has anything but digits
		set_message ('err_bad_osti');											-- set an error message
		options.coins_list_t['OSTI'] = nil;										-- when error, unset so not included in COinS
	else																		-- OSTI is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1018 &gt; id_num or handler.id_limit &lt; id_num then						-- if OSTI is outside test limit boundaries
			set_message ('err_bad_osti');										-- set an error message
			options.coins_list_t['OSTI'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});
end


--[[--------------------------&lt; P M C &gt;------------------------------------------------------------------------

Format a PMC, do simple error checking, and check for embargoed articles.

The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
be linked to the article.  If the embargo date is today or in the past, or if it is empty or omitted, then the
PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.

PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
has |pmc=&lt;value&gt; but does not have a |url= then |title= is linked with the PMC link.  Function is_embargoed ()
returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.

PMCs are sequential numbers beginning at 1 and counting up.  This code checks the PMC to see that it contains only digits and is less
than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.

]]

local function pmc (options)
	local id = options.id;
	local embargo = options.Embargo;											-- TODO: lowercase?
	local handler = options.handler;
	local err_flag;
	local id_num;
	local text;

	id_num = id:match ('^[Pp][Mm][Cc](%d+)$');									-- identifier with PMC prefix

	if is_set (id_num) then
		set_message ('maint_pmc_format');
	else																		-- plain number without PMC prefix
		id_num = id:match ('^%d+$');											-- if here id is all digits
	end

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if PMC is outside test limit boundaries
			err_flag = set_message ('err_bad_pmc');								-- set an error message
		else
			id = tostring (id_num);												-- make sure id is a string
		end
	else																		-- when id format incorrect
		err_flag = set_message ('err_bad_pmc');									-- set an error message
	end
	
	if is_set (embargo) and is_set (is_embargoed (embargo)) then				-- is PMC is still embargoed?
		text = table.concat (													-- still embargoed so no external link
			{
			make_wikilink (link_label_make (handler), handler.label),
			handler.separator,
			id,
			});
	else
		text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,	-- no embargo date or embargo has expired, ok to link to article
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access,
			auto_link = not err_flag and 'pmc' or nil							-- do not auto-link when PMC has error
			});
	end

	if err_flag then
		options.coins_list_t['PMC'] = nil;										-- when error, unset so not included in COinS
	end

	return text;
end


--[[--------------------------&lt; P M I D &gt;----------------------------------------------------------------------

Format PMID and do simple error checking.  PMIDs are sequential numbers beginning at 1 and counting up.  This
code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
test_limit will need to be updated periodically as more PMIDs are issued.

]]

local function pmid (options)
	local id = options.id;
	local handler = options.handler;

	if id:match(&quot;[^%d]&quot;) then													-- if PMID has anything but digits
		set_message ('err_bad_pmid');											-- set an error message
		options.coins_list_t['PMID'] = nil;										-- when error, unset so not included in COinS
	else																		-- PMID is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if PMID is outside test limit boundaries
			set_message ('err_bad_pmid');										-- set an error message
			options.coins_list_t['PMID'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--[[--------------------------&lt; R F C &gt;------------------------------------------------------------------------

Format RFC and do simple error checking. RFCs are sequential numbers beginning at 1 and counting up.  This
code checks the RFC to see that it contains only digits and is less than test_limit specified in the configuration;
the value in test_limit will need to be updated periodically as more RFCs are issued.

An index of all RFCs is here: https://tools.ietf.org/rfc/

]]

local function rfc (options)
	local id = options.id;
	local handler = options.handler;

	if id:match(&quot;[^%d]&quot;) then													-- if RFC has anything but digits
		set_message ('err_bad_rfc');											-- set an error message
		options.coins_list_t['RFC'] = nil;										-- when error, unset so not included in COinS
	else																		-- RFC is only digits
		local id_num = tonumber (id);											-- convert id to a number for range testing
		if 1 &gt; id_num or handler.id_limit &lt; id_num then							-- if RFC is outside test limit boundaries
			set_message ('err_bad_rfc');										-- set an error message
			options.coins_list_t['RFC'] = nil;									-- when error, unset so not included in COinS
		end
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = handler.access});
end


--[[--------------------------&lt; S 2 C I D &gt;--------------------------------------------------------------------

Format an S2CID, do simple error checking

S2CIDs are sequential numbers beginning at 1 and counting up.  This code checks the S2CID to see that it is only
digits and is less than test_limit; the value in local variable test_limit will need to be updated periodically
as more S2CIDs are issued.

]]

local function s2cid (options)
	local id = options.id;
	local access = options.access;
	local handler = options.handler;
	local id_num;
	local text;
	
	id_num = id:match ('^[1-9]%d*$');											-- id must be all digits; must not begin with 0; no open access flag

 	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if handler.id_limit &lt; id_num then										-- if S2CID is outside test limit boundaries
			set_message ('err_bad_s2cid');										-- set an error message
			options.coins_list_t['S2CID'] = nil;								-- when error, unset so not included in COinS
		end
	else																		-- when id format incorrect
		set_message ('err_bad_s2cid');											-- set an error message
		options.coins_list_t['S2CID'] = nil;									-- when error, unset so not included in COinS
	end

	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = access});

	return text;
end


--[[--------------------------&lt; S B N &gt;------------------------------------------------------------------------

9-digit form of ISBN-10; uses same check-digit validation when SBN is prefixed with an additional '0' to make 10 digits

sbn value not made part of COinS metadata because we don't have a url or isn't a COinS-defined identifier (rft.xxx)
or an identifier registered at info-uri.info (info:)

]]

local function sbn (options)
	local id = options.id;
	local ignore_invalid = options.accept;
	local handler = options.handler;
	local function return_result (check, err_type)								-- local function to handle the various returns
		local SBN = internal_link_id ({link = handler.link, label = handler.label, redirect = handler.redirect,
						prefix = handler.prefix, id = id, separator = handler.separator});
		if not ignore_invalid then												-- if not ignoring SBN errors
			if not check then
				options.coins_list_t['SBN'] = nil;								-- when error, unset so not included in COinS; not really necessary here because sbn not made part of COinS
				set_message ('err_bad_sbn', {err_type});						-- display an error message
				return SBN; 
			end
		else
			set_message ('maint_isbn_ignore');									-- add a maint category even when there is no error (ToDo: Possibly switch to separate message for SBNs only)
		end
		return SBN;
	end

	if id:match ('[^%s-0-9X]') then
		return return_result (false, cfg.err_msg_supl.char);					-- fail if SBN contains anything but digits, hyphens, or the uppercase X
	end

	local ident = id:gsub ('[%s-]', '');										-- remove hyphens and whitespace; they interfere with the rest of the tests

	if  9 ~= ident:len() then
		return return_result (false, cfg.err_msg_supl.length);					-- fail if incorrect length
	end

	if ident:match ('^%d*X?$') == nil then
		return return_result (false, cfg.err_msg_supl.form);					-- fail if SBN has 'X' anywhere but last position
	end

	return return_result (is_valid_isxn ('0' .. ident, 10), cfg.err_msg_supl.check);
end


--[[--------------------------&lt; S S R N &gt;----------------------------------------------------------------------

Format an SSRN, do simple error checking

SSRNs are sequential numbers beginning at 100? and counting up.  This code checks the SSRN to see that it is
only digits and is greater than 99 and less than test_limit; the value in local variable test_limit will need
to be updated periodically as more SSRNs are issued.

]]

local function ssrn (options)
	local id = options.id;
	local handler = options.handler;
	local id_num;
	local text;
	
	id_num = id:match ('^%d+$');												-- id must be all digits

	if is_set (id_num) then														-- id_num has a value so test it
		id_num = tonumber (id_num);												-- convert id_num to a number for range testing
		if 100 &gt; id_num or handler.id_limit &lt; id_num then						-- if SSRN is outside test limit boundaries
			set_message ('err_bad_ssrn');										-- set an error message
			options.coins_list_t['SSRN'] = nil;									-- when error, unset so not included in COinS
		end
	else																		-- when id format incorrect
		set_message ('err_bad_ssrn');											-- set an error message
		options.coins_list_t['SSRN'] = nil;										-- when error, unset so not included in COinS
	end
	
	text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode, access = options.access});

	return text;
end


--[[--------------------------&lt; U S E N E T _ I D &gt;------------------------------------------------------------

Validate and format a usenet message id.  Simple error checking, looks for 'id-left@id-right' not enclosed in
'&lt;' and/or '&gt;' angle brackets.

]]

local function usenet_id (options)
	local id = options.id;
	local handler = options.handler;

	local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
		prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode})
 
	if not id:match('^.+@.+$') or not id:match('^[^&lt;].*[^&gt;]$') then				-- doesn't have '@' or has one or first or last character is '&lt; or '&gt;'
		set_message ('err_bad_usenet_id')										-- add an error message if the message id is invalid
		options.coins_list_t['USENETID'] = nil;									-- when error, unset so not included in COinS
	end 
	
	return text;
end


--[[--------------------------&lt; Z B L &gt;-----------------------------------------------------------------------

A numerical identifier in the form nnnn.nnnnn - leading zeros in the first quartet optional

format described here: http://emis.mi.sanu.ac.rs/ZMATH/zmath/en/help/search/

temporary format is apparently eight digits.  Anything else is an error

]]

local function zbl (options)
	local id = options.id;
	local handler = options.handler;

	if id:match('^%d%d%d%d%d%d%d%d$') then										-- is this identifier using temporary format?
		set_message ('maint_zbl');												-- yes, add maint cat
	elseif not id:match('^%d?%d?%d?%d%.%d%d%d%d%d$') then						-- not temporary, is it normal format?
		set_message ('err_bad_zbl');											-- no, set an error message
		options.coins_list_t['ZBL'] = nil;										-- when error, unset so not included in COinS
	end
	
	return external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect,
			prefix = handler.prefix, id = id, separator = handler.separator, encode = handler.encode});
end


--============================&lt;&lt; I N T E R F A C E   F U N C T I O N S &gt;&gt;==========================================

--[[--------------------------&lt; E X T R A C T _ I D S &gt;------------------------------------------------------------

Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
any of the parameters listed in each cfg.id_handlers['...'].parameters.  If found, adds the parameter and value to
the identifier list.  Emits redundant error message if more than one alias exists in args

]]

local function extract_ids (args)
	local id_list = {};															-- list of identifiers found in args
	for k, v in pairs (cfg.id_handlers) do										-- k is uppercase identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
		v = select_one (args, v.parameters, 'err_redundant_parameters' );		-- v.parameters is a table of aliases for k; here we pick one from args if present
		if is_set (v) then id_list[k] = v; end									-- if found in args, add identifier to our list
	end
	return id_list;
end


--[[--------------------------&lt; E X T R A C T _ I D _ A C C E S S _ L E V E L S &gt;--------------------------------------

Fetches custom id access levels from arguments using configuration settings. Parameters which have a predefined access
level (e.g. arxiv) do not use this function as they are directly rendered as free without using an additional parameter.

returns a table of k/v pairs where k is same as the identifier's key in cfg.id_handlers and v is the assigned (valid) keyword

access-level values must match the case used in cfg.keywords_lists['id-access'] (lowercase unless there is some special reason for something else)

]]

local function extract_id_access_levels (args, id_list)
	local id_accesses_list = {};
	for k, v in pairs (cfg.id_handlers) do
		local access_param = v.custom_access;									-- name of identifier's access-level parameter
		if is_set (access_param) then
			local access_level = args[access_param];							-- get the assigned value if there is one
			if is_set (access_level) then
				if not in_array (access_level, cfg.keywords_lists['id-access']) then	-- exact match required
					set_message ('err_invalid_param_val', {access_param, access_level});	
					access_level = nil;											-- invalid so unset
				end
				if not is_set (id_list[k]) then									-- identifier access-level must have a matching identifier
					set_message ('err_param_access_requires_param', {k:lower()});	-- parameter name is uppercase in cfg.id_handlers (k); lowercase for error message
				end
				id_accesses_list[k] = cfg.keywords_xlate[access_level];			-- get translated keyword
			end
		end
	end
	return id_accesses_list;
end


--[[--------------------------&lt; B U I L D _ I D _ L I S T &gt;----------------------------------------------------

render the identifiers into a sorted sequence table

&lt;ID_list_coins_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value
&lt;options_t&gt; is a table of various k/v option pairs provided in the call to new_build_id_list();
	modified by	this function and passed to all identifier rendering functions
&lt;access_levels_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value (if valid)

returns a sequence table of sorted (by hkey - 'handler' key) rendered identifier strings

]]

local function build_id_list (ID_list_coins_t, options_t, access_levels_t)
	local ID_list_t = {};
	local accept;
	local func_map = {															--function map points to functions associated with hkey identifier
		['ARXIV'] = arxiv,
		['ASIN'] = asin,
		['BIBCODE'] = bibcode,
		['BIORXIV'] = biorxiv,
		['CITESEERX'] = citeseerx,
		['DOI'] = doi,
		['EISSN'] = issn,
		['HDL'] = hdl,
		['ISBN'] = isbn,
		['ISMN'] = ismn,
		['ISSN'] = issn,
		['JFM'] = jfm,
		['JSTOR'] = jstor,
		['LCCN'] = lccn,
		['MEDRXIV'] = medrxiv,
		['MR'] = mr,
		['OCLC'] = oclc,
		['OL'] = openlibrary,
		['OSTI'] = osti,
		['PMC'] = pmc,
		['PMID'] = pmid,
		['RFC']  = rfc,
		['S2CID'] = s2cid,
		['SBN'] = sbn,
		['SSRN'] = ssrn,
		['USENETID'] = usenet_id,
		['ZBL'] = zbl,
		}

	for hkey, v in pairs (ID_list_coins_t) do
		v, accept = has_accept_as_written (v);									-- remove accept-as-written markup if present; accept is boolean true when markup removed; false else
																				-- every function gets the options table with value v and accept boolean
		options_t.hkey = hkey;													-- ~/Configuration handler key
		options_t.id = v;														-- add that identifier value to the options table
		options_t.accept = accept;												-- add the accept boolean flag
		options_t.access = access_levels_t[hkey];								-- add the access level for those that have an |&lt;identifier-access= parameter
		options_t.handler = cfg.id_handlers[hkey];
		options_t.coins_list_t = ID_list_coins_t;								-- pointer to ID_list_coins_t; for |asin= and |ol=; also to keep erroneous values out of the citation's metadata
		options_t.coins_list_t[hkey] = v;										-- id value without accept-as-written markup for metadata
		
		if options_t.handler.access and not in_array (options_t.handler.access, cfg.keywords_lists['id-access']) then
			error (cfg.messages['unknown_ID_access'] .. options_t.handler.access);	-- here when handler access key set to a value not listed in list of allowed id access keywords
		end

		if func_map[hkey] then
			local id_text = func_map[hkey] (options_t);							-- call the function to get identifier text and any error message
			table.insert (ID_list_t, {hkey, id_text});							-- add identifier text to the output sequence table
		else
			error (cfg.messages['unknown_ID_key'] .. hkey);						-- here when func_map doesn't have a function for hkey
		end
	end

	local function comp (a, b)													-- used by following table.sort()
		return a[1]:lower() &lt; b[1]:lower();										-- sort by hkey
	end

	table.sort (ID_list_t, comp);												-- sequence table of tables sort	
	for k, v in ipairs (ID_list_t) do											-- convert sequence table of tables to simple sequence table of strings
		ID_list_t[k] = v[2];													-- v[2] is the identifier rendering from the call to the various functions in func_map{}
	end
	
	return ID_list_t;
end


--[[--------------------------&lt; O P T I O N S _ C H E C K &gt;----------------------------------------------------

check that certain option parameters have their associated identifier parameters with values

&lt;ID_list_coins_t&gt; is a table of k/v pairs where k is same as key in cfg.id_handlers and v is the assigned value
&lt;ID_support_t&gt; is a sequence table of tables created in citation0() where each subtable has four elements:
	[1] is the support parameter's assigned value; empty string if not set
	[2] is a text string same as key in cfg.id_handlers
	[3] is cfg.error_conditions key used to create error message
	[4] is original ID support parameter name used to create error message
	
returns nothing; on error emits an appropriate error message

]]

local function options_check (ID_list_coins_t, ID_support_t)
	for _, v in ipairs (ID_support_t) do
		if is_set (v[1]) and not ID_list_coins_t[v[2]] then						-- when support parameter has a value but matching identifier parameter is missing or empty
			set_message (v[3], (v[4]));											-- emit the appropriate error message
		end
	end
end


--[[--------------------------&lt; I D E N T I F I E R _ L I S T S _ G E T &gt;--------------------------------------

Creates two identifier lists: a k/v table of identifiers and their values to be used locally and for use in the
COinS metadata, and a sequence table of the rendered identifier strings that will be included in the rendered
citation.

]]

local function identifier_lists_get (args_t, options_t, ID_support_t)
	local ID_list_coins_t = extract_ids (args_t);										-- get a table of identifiers and their values for use locally and for use in COinS
	options_check (ID_list_coins_t, ID_support_t);										-- ID support parameters must have matching identifier parameters 
	local ID_access_levels_t = extract_id_access_levels (args_t, ID_list_coins_t);		-- get a table of identifier access levels
	local ID_list_t = build_id_list (ID_list_coins_t, options_t, ID_access_levels_t);	-- get a sequence table of rendered identifier strings

	return ID_list_t, ID_list_coins_t;											-- return the tables
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	has_accept_as_written = utilities_page_ptr.has_accept_as_written;			-- import functions from select Module:Citation/CS1/Utilities module
	is_set = utilities_page_ptr.is_set;								
	in_array = utilities_page_ptr.in_array;
	set_message = utilities_page_ptr.set_message;
	select_one = utilities_page_ptr.select_one;
	substitute = utilities_page_ptr.substitute;
	make_wikilink = utilities_page_ptr.make_wikilink;

	z = utilities_page_ptr.z;													-- table of tables in Module:Citation/CS1/Utilities
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	auto_link_urls = auto_link_urls,											-- table of identifier URLs to be used when auto-linking |title=
	
	identifier_lists_get = identifier_lists_get,								-- experiment to replace individual calls to build_id_list(), extract_ids, extract_id_access_levels
	is_embargoed = is_embargoed;
	set_selected_modules = set_selected_modules;
	}</text>
      <sha1>k1dr68mpitw4fjf8xuqkl74nhwowac7</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Citation/CS1/Utilities</title>
    <ns>828</ns>
    <id>735</id>
    <revision>
      <id>4932</id>
      <timestamp>2015-12-13T15:46:24Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>create as an experiment;</comment>
      <origin>4932</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="485" sha1="rd35su6mgqa6aogkwvad14hcantddox" xml:space="preserve">local u = {}


--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.
This function is global because it is called from both this module and from Date validation

]]
function is_set( var )
	return not (var == nil or var == '');
end

return {is_set = is_set}														-- return exported functions</text>
      <sha1>rd35su6mgqa6aogkwvad14hcantddox</sha1>
    </revision>
    <revision>
      <id>4933</id>
      <parentid>4932</parentid>
      <timestamp>2015-12-13T17:18:10Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4933</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="855" sha1="4d3o6hm1ogfx1q6jwxppjkbaf9lfqne" xml:space="preserve">local u = {}

local z = {
	error_categories = {};		-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};		-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};		-- for categorizing citations based on certain properties, language of source for instance
};

--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.
This function is global because it is called from both this module and from Date validation

]]
function is_set( var )
	return not (var == nil or var == '');
end

return {is_set = is_set, z=z}													-- return exported functions and tables</text>
      <sha1>4d3o6hm1ogfx1q6jwxppjkbaf9lfqne</sha1>
    </revision>
    <revision>
      <id>4934</id>
      <parentid>4933</parentid>
      <timestamp>2015-12-13T18:09:51Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4934</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="925" sha1="p3xn92x1gzux3h9xtkd9dbojsmrw5iv" xml:space="preserve">local u = {}

local z = {
	error_categories = {};		-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};		-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};		-- for categorizing citations based on certain properties, language of source for instance
};

local cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');

--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.
This function is global because it is called from both this module and from Date validation

]]
function is_set( var )
	return not (var == nil or var == '');
end

return {is_set = is_set, z=z}											-- return exported functions and tables</text>
      <sha1>p3xn92x1gzux3h9xtkd9dbojsmrw5iv</sha1>
    </revision>
    <revision>
      <id>4935</id>
      <parentid>4934</parentid>
      <timestamp>2015-12-13T18:21:21Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4935</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="1983" sha1="afso42zch4oe9ecu3uc937fpnmjf9dg" xml:space="preserve">local u = {}

local z = {
	error_categories = {};		-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};		-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};		-- for categorizing citations based on certain properties, language of source for instance
};

local cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');

--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.
This function is global because it is called from both this module and from Date validation

]]
function is_set( var )
	return not (var == nil or var == '');
end

--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end

--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]
local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end

return {is_set=is_set, in_array=in_array, substitute=substitute, error_comment=error_comment, z=z}			-- return exported functions and tables</text>
      <sha1>afso42zch4oe9ecu3uc937fpnmjf9dg</sha1>
    </revision>
    <revision>
      <id>4936</id>
      <parentid>4935</parentid>
      <timestamp>2015-12-13T20:43:11Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4936</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="3278" sha1="fwixxqazf0xcxljw503hg7wrzulktjb" xml:space="preserve">local u = {}

local z = {
	error_categories = {};		-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};		-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};		-- for categorizing citations based on certain properties, language of source for instance
};

local cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');

--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.
This function is global because it is called from both this module and from Date validation

]]
function is_set( var )
	return not (var == nil or var == '');
end

--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end

--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]
local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end

--[[--------------------------&lt; S E T _ E R R O R &gt;--------------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

]]
local function set_error( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if in_array( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return error_comment( message, error_state.hidden );
end

return {																		-- return exported functions and tables
	is_set = is_set,
	in_array = in_array,
	substitute = substitute,
	error_comment = error_comment,
	set_error = set_error,
	z = z,
	}</text>
      <sha1>fwixxqazf0xcxljw503hg7wrzulktjb</sha1>
    </revision>
    <revision>
      <id>4937</id>
      <parentid>4936</parentid>
      <timestamp>2015-12-13T22:20:03Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4937</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="7821" sha1="qy5b15f9z5il22t20bqq908jnfiz2sg" xml:space="preserve">local u = {}

local z = {
	error_categories = {};		-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};		-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};		-- for categorizing citations based on certain properties, language of source for instance
};

local cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');

--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.
This function is global because it is called from both this module and from Date validation

]]
function is_set( var )
	return not (var == nil or var == '');
end

--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end

--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end

--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]
local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end

--[[--------------------------&lt; S E T _ E R R O R &gt;--------------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

]]
local function set_error( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if in_array( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return error_comment( message, error_state.hidden );
end

--[[-------------------------&lt; I S _ A L I A S _ U S E D &gt;-----------------------------------------------------

This function is used by select_one() to determine if one of a list of alias parameters is in the argument list
provided by the template.

Input:
	args – pointer to the arguments table from calling template
	alias – one of the list of possible aliases in the aliases lists from Module:Citation/CS1/Configuration
	index – for enumerated parameters, identifies which one
	enumerated – true/false flag used choose how enumerated aliases are examined
	value – value associated with an alias that has previously been selected; nil if not yet selected
	selected – the alias that has previously been selected; nil if not yet selected
	error_list – list of aliases that are duplicates of the alias already selected

Returns:
	value – value associated with alias we selected or that was previously selected or nil if an alias not yet selected
	selected – the alias we selected or the alias that was previously selected or nil if an alias not yet selected

]]

local function is_alias_used (args, alias, index, enumerated, value, selected, error_list)
	if enumerated then															-- is this a test for an enumerated parameters?
		alias = alias:gsub ('#', index);										-- replace '#' with the value in index
	else
		alias = alias:gsub ('#', '');											-- remove '#' if it exists
	end

	if is_set(args[alias]) then													-- alias is in the template's argument list
		if value ~= nil and selected ~= alias then								-- if we have already selected one of the aliases
			local skip;
			for _, v in ipairs(error_list) do									-- spin through the error list to see if we've added this alias
				if v == alias then
					skip = true;
					break;														-- has been added so stop looking 
				end
			end
			if not skip then													-- has not been added so
				table.insert( error_list, alias );								-- add error alias to the error list
			end
		else
			value = args[alias];												-- not yet selected an alias, so select this one
			selected = alias;
		end
	end
	return value, selected;														-- return newly selected alias, or previously selected alias
end


--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider.  The list of parameters to consider is just
names.  For parameters that may be enumerated, the position of the numerator in the parameter name is identified
by the '#' so |author-last1= and |author1-last= are represented as 'author-last#' and 'author#-last'.

Because enumerated parameter |&lt;param&gt;1= is an alias of |&lt;param&gt;= we must test for both possibilities.


Generates an error if more than one match is present.

]]

local function select_one( args, aliases_list, error_condition, index )
	local value = nil;															-- the value assigned to the selected parameter
	local selected = '';														-- the name of the parameter we have chosen
	local error_list = {};

	if index ~= nil then index = tostring(index); end

	for _, alias in ipairs( aliases_list ) do									-- for each alias in the aliases list
		if alias:match ('#') then												-- if this alias can be enumerated
			if '1' == index then												-- when index is 1 test for enumerated and non-enumerated aliases
				value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);	-- first test for non-enumerated alias
			end
			value, selected = is_alias_used (args, alias, index, true, value, selected, error_list);		-- test for enumerated alias
		else
			value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);		--test for non-enumerated alias
		end
	end

	if #error_list &gt; 0 and 'none' ~= error_condition then						-- for cases where this code is used outside of extract_names()
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap_style ('parameter', k);
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap_style ('parameter', selected);
		table.insert( z.message_tail, { set_error( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end


return {																		-- return exported functions and tables
	is_set = is_set,
	in_array = in_array,
	substitute = substitute,
	error_comment = error_comment,
	set_error = set_error,
	select_one = select_one,
	z = z,
	}</text>
      <sha1>qy5b15f9z5il22t20bqq908jnfiz2sg</sha1>
    </revision>
    <revision>
      <id>4938</id>
      <parentid>4937</parentid>
      <timestamp>2015-12-13T22:49:30Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4938</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="8615" sha1="eao7bgwyem5y8fd50jw5yy3a3qi3626" xml:space="preserve">local u = {}

local z = {
	error_categories = {};		-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};		-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};		-- for categorizing citations based on certain properties, language of source for instance
};

local cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');

--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maintenance_cats using names from the configuration file with additional text if any.
To prevent duplication, the added_maint_cats table lists the categories by key that have been added to z.maintenance_cats.

]]

local added_maint_cats = {}														-- list of maintenance categories that have been added to z.maintenance_cats
local function add_maint_cat (key, arguments)
	if not added_maint_cats [key] then
		added_maint_cats [key] = true;											-- note that we've added this category
		table.insert( z.maintenance_cats, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
	end
end


--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.
This function is global because it is called from both this module and from Date validation

]]
function is_set( var )
	return not (var == nil or var == '');
end


--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end


--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end


--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]
local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end


--[[--------------------------&lt; S E T _ E R R O R &gt;--------------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

]]
local function set_error( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if in_array( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return error_comment( message, error_state.hidden );
end


--[[-------------------------&lt; I S _ A L I A S _ U S E D &gt;-----------------------------------------------------

This function is used by select_one() to determine if one of a list of alias parameters is in the argument list
provided by the template.

Input:
	args – pointer to the arguments table from calling template
	alias – one of the list of possible aliases in the aliases lists from Module:Citation/CS1/Configuration
	index – for enumerated parameters, identifies which one
	enumerated – true/false flag used choose how enumerated aliases are examined
	value – value associated with an alias that has previously been selected; nil if not yet selected
	selected – the alias that has previously been selected; nil if not yet selected
	error_list – list of aliases that are duplicates of the alias already selected

Returns:
	value – value associated with alias we selected or that was previously selected or nil if an alias not yet selected
	selected – the alias we selected or the alias that was previously selected or nil if an alias not yet selected

]]

local function is_alias_used (args, alias, index, enumerated, value, selected, error_list)
	if enumerated then															-- is this a test for an enumerated parameters?
		alias = alias:gsub ('#', index);										-- replace '#' with the value in index
	else
		alias = alias:gsub ('#', '');											-- remove '#' if it exists
	end

	if is_set(args[alias]) then													-- alias is in the template's argument list
		if value ~= nil and selected ~= alias then								-- if we have already selected one of the aliases
			local skip;
			for _, v in ipairs(error_list) do									-- spin through the error list to see if we've added this alias
				if v == alias then
					skip = true;
					break;														-- has been added so stop looking 
				end
			end
			if not skip then													-- has not been added so
				table.insert( error_list, alias );								-- add error alias to the error list
			end
		else
			value = args[alias];												-- not yet selected an alias, so select this one
			selected = alias;
		end
	end
	return value, selected;														-- return newly selected alias, or previously selected alias
end


--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider.  The list of parameters to consider is just
names.  For parameters that may be enumerated, the position of the numerator in the parameter name is identified
by the '#' so |author-last1= and |author1-last= are represented as 'author-last#' and 'author#-last'.

Because enumerated parameter |&lt;param&gt;1= is an alias of |&lt;param&gt;= we must test for both possibilities.


Generates an error if more than one match is present.

]]

local function select_one( args, aliases_list, error_condition, index )
	local value = nil;															-- the value assigned to the selected parameter
	local selected = '';														-- the name of the parameter we have chosen
	local error_list = {};

	if index ~= nil then index = tostring(index); end

	for _, alias in ipairs( aliases_list ) do									-- for each alias in the aliases list
		if alias:match ('#') then												-- if this alias can be enumerated
			if '1' == index then												-- when index is 1 test for enumerated and non-enumerated aliases
				value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);	-- first test for non-enumerated alias
			end
			value, selected = is_alias_used (args, alias, index, true, value, selected, error_list);		-- test for enumerated alias
		else
			value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);		--test for non-enumerated alias
		end
	end

	if #error_list &gt; 0 and 'none' ~= error_condition then						-- for cases where this code is used outside of extract_names()
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap_style ('parameter', k);
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap_style ('parameter', selected);
		table.insert( z.message_tail, { set_error( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end


return {																		-- return exported functions and tables
	is_set = is_set,
	in_array = in_array,
	substitute = substitute,
	error_comment = error_comment,
	set_error = set_error,
	select_one = select_one,
	add_maint_cat = add_maint_cat,
	z = z,
	}</text>
      <sha1>eao7bgwyem5y8fd50jw5yy3a3qi3626</sha1>
    </revision>
    <revision>
      <id>4939</id>
      <parentid>4938</parentid>
      <timestamp>2015-12-13T22:54:18Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4939</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="8615" sha1="g9xbr0c0ypkuzhkum1x81uu2wejvykk" xml:space="preserve">local u = {}

local z = {
	error_categories = {};		-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};		-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};		-- for categorizing citations based on certain properties, language of source for instance
};

local cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');

--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.
This function is global because it is called from both this module and from Date validation

]]
function is_set( var )
	return not (var == nil or var == '');
end


--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end


--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end


--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]
local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end


--[[--------------------------&lt; S E T _ E R R O R &gt;--------------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

]]
local function set_error( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if in_array( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return error_comment( message, error_state.hidden );
end


--[[-------------------------&lt; I S _ A L I A S _ U S E D &gt;-----------------------------------------------------

This function is used by select_one() to determine if one of a list of alias parameters is in the argument list
provided by the template.

Input:
	args – pointer to the arguments table from calling template
	alias – one of the list of possible aliases in the aliases lists from Module:Citation/CS1/Configuration
	index – for enumerated parameters, identifies which one
	enumerated – true/false flag used choose how enumerated aliases are examined
	value – value associated with an alias that has previously been selected; nil if not yet selected
	selected – the alias that has previously been selected; nil if not yet selected
	error_list – list of aliases that are duplicates of the alias already selected

Returns:
	value – value associated with alias we selected or that was previously selected or nil if an alias not yet selected
	selected – the alias we selected or the alias that was previously selected or nil if an alias not yet selected

]]

local function is_alias_used (args, alias, index, enumerated, value, selected, error_list)
	if enumerated then															-- is this a test for an enumerated parameters?
		alias = alias:gsub ('#', index);										-- replace '#' with the value in index
	else
		alias = alias:gsub ('#', '');											-- remove '#' if it exists
	end

	if is_set(args[alias]) then													-- alias is in the template's argument list
		if value ~= nil and selected ~= alias then								-- if we have already selected one of the aliases
			local skip;
			for _, v in ipairs(error_list) do									-- spin through the error list to see if we've added this alias
				if v == alias then
					skip = true;
					break;														-- has been added so stop looking 
				end
			end
			if not skip then													-- has not been added so
				table.insert( error_list, alias );								-- add error alias to the error list
			end
		else
			value = args[alias];												-- not yet selected an alias, so select this one
			selected = alias;
		end
	end
	return value, selected;														-- return newly selected alias, or previously selected alias
end


--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider.  The list of parameters to consider is just
names.  For parameters that may be enumerated, the position of the numerator in the parameter name is identified
by the '#' so |author-last1= and |author1-last= are represented as 'author-last#' and 'author#-last'.

Because enumerated parameter |&lt;param&gt;1= is an alias of |&lt;param&gt;= we must test for both possibilities.


Generates an error if more than one match is present.

]]

local function select_one( args, aliases_list, error_condition, index )
	local value = nil;															-- the value assigned to the selected parameter
	local selected = '';														-- the name of the parameter we have chosen
	local error_list = {};

	if index ~= nil then index = tostring(index); end

	for _, alias in ipairs( aliases_list ) do									-- for each alias in the aliases list
		if alias:match ('#') then												-- if this alias can be enumerated
			if '1' == index then												-- when index is 1 test for enumerated and non-enumerated aliases
				value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);	-- first test for non-enumerated alias
			end
			value, selected = is_alias_used (args, alias, index, true, value, selected, error_list);		-- test for enumerated alias
		else
			value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);		--test for non-enumerated alias
		end
	end

	if #error_list &gt; 0 and 'none' ~= error_condition then						-- for cases where this code is used outside of extract_names()
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap_style ('parameter', k);
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap_style ('parameter', selected);
		table.insert( z.message_tail, { set_error( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end


--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maintenance_cats using names from the configuration file with additional text if any.
To prevent duplication, the added_maint_cats table lists the categories by key that have been added to z.maintenance_cats.

]]

local added_maint_cats = {}														-- list of maintenance categories that have been added to z.maintenance_cats
local function add_maint_cat (key, arguments)
	if not added_maint_cats [key] then
		added_maint_cats [key] = true;											-- note that we've added this category
		table.insert( z.maintenance_cats, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
	end
end


return {																		-- return exported functions and tables
	is_set = is_set,
	in_array = in_array,
	substitute = substitute,
	error_comment = error_comment,
	set_error = set_error,
	select_one = select_one,
	add_maint_cat = add_maint_cat,
	z = z,
	}</text>
      <sha1>g9xbr0c0ypkuzhkum1x81uu2wejvykk</sha1>
    </revision>
    <revision>
      <id>4940</id>
      <parentid>4939</parentid>
      <timestamp>2015-12-14T15:53:26Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4940</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="10077" sha1="4blryh6085f93wbnky4csa0jlfplbfz" xml:space="preserve">local u = {}

local z = {
	error_categories = {};		-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};		-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};		-- for categorizing citations based on certain properties, language of source for instance
};

local cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');

--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.
This function is global because it is called from both this module and from Date validation

]]
function is_set( var )
	return not (var == nil or var == '');
end


--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end


--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end


--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]
local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end


--[[--------------------------&lt; S E T _ E R R O R &gt;--------------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

]]
local function set_error( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if in_array( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return error_comment( message, error_state.hidden );
end


--[[-------------------------&lt; I S _ A L I A S _ U S E D &gt;-----------------------------------------------------

This function is used by select_one() to determine if one of a list of alias parameters is in the argument list
provided by the template.

Input:
	args – pointer to the arguments table from calling template
	alias – one of the list of possible aliases in the aliases lists from Module:Citation/CS1/Configuration
	index – for enumerated parameters, identifies which one
	enumerated – true/false flag used choose how enumerated aliases are examined
	value – value associated with an alias that has previously been selected; nil if not yet selected
	selected – the alias that has previously been selected; nil if not yet selected
	error_list – list of aliases that are duplicates of the alias already selected

Returns:
	value – value associated with alias we selected or that was previously selected or nil if an alias not yet selected
	selected – the alias we selected or the alias that was previously selected or nil if an alias not yet selected

]]

local function is_alias_used (args, alias, index, enumerated, value, selected, error_list)
	if enumerated then															-- is this a test for an enumerated parameters?
		alias = alias:gsub ('#', index);										-- replace '#' with the value in index
	else
		alias = alias:gsub ('#', '');											-- remove '#' if it exists
	end

	if is_set(args[alias]) then													-- alias is in the template's argument list
		if value ~= nil and selected ~= alias then								-- if we have already selected one of the aliases
			local skip;
			for _, v in ipairs(error_list) do									-- spin through the error list to see if we've added this alias
				if v == alias then
					skip = true;
					break;														-- has been added so stop looking 
				end
			end
			if not skip then													-- has not been added so
				table.insert( error_list, alias );								-- add error alias to the error list
			end
		else
			value = args[alias];												-- not yet selected an alias, so select this one
			selected = alias;
		end
	end
	return value, selected;														-- return newly selected alias, or previously selected alias
end


--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider.  The list of parameters to consider is just
names.  For parameters that may be enumerated, the position of the numerator in the parameter name is identified
by the '#' so |author-last1= and |author1-last= are represented as 'author-last#' and 'author#-last'.

Because enumerated parameter |&lt;param&gt;1= is an alias of |&lt;param&gt;= we must test for both possibilities.


Generates an error if more than one match is present.

]]

local function select_one( args, aliases_list, error_condition, index )
	local value = nil;															-- the value assigned to the selected parameter
	local selected = '';														-- the name of the parameter we have chosen
	local error_list = {};

	if index ~= nil then index = tostring(index); end

	for _, alias in ipairs( aliases_list ) do									-- for each alias in the aliases list
		if alias:match ('#') then												-- if this alias can be enumerated
			if '1' == index then												-- when index is 1 test for enumerated and non-enumerated aliases
				value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);	-- first test for non-enumerated alias
			end
			value, selected = is_alias_used (args, alias, index, true, value, selected, error_list);		-- test for enumerated alias
		else
			value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);		--test for non-enumerated alias
		end
	end

	if #error_list &gt; 0 and 'none' ~= error_condition then						-- for cases where this code is used outside of extract_names()
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap_style ('parameter', k);
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap_style ('parameter', selected);
		table.insert( z.message_tail, { set_error( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end


--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maintenance_cats using names from the configuration file with additional text if any.
To prevent duplication, the added_maint_cats table lists the categories by key that have been added to z.maintenance_cats.

]]

local added_maint_cats = {}														-- list of maintenance categories that have been added to z.maintenance_cats
local function add_maint_cat (key, arguments)
	if not added_maint_cats [key] then
		added_maint_cats [key] = true;											-- note that we've added this category
		table.insert( z.maintenance_cats, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
	end
end


--[[--------------------------&lt; S A F E _ F O R _ I T A L I C S &gt;----------------------------------------------

Protects a string that will be wrapped in wiki italic markup '' ... ''

Note: We cannot use &lt;i&gt; for italics, as the expected behavior for italics specified by ''...'' in the title is that
they will be inverted (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and '' tend to interact
poorly under Mediawiki's HTML tidy.

]]

local function safe_for_italics( str )
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end


--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

local function wrap_style (key, str)
	if not is_set( str ) then
		return &quot;&quot;;
	elseif in_array( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safe_for_italics( str );
	end

	return substitute( cfg.presentation[key], {str} );
end


return {																		-- return exported functions and tables
	is_set = is_set,
	in_array = in_array,
	substitute = substitute,
	error_comment = error_comment,
	set_error = set_error,
	select_one = select_one,
	add_maint_cat = add_maint_cat,
	wrap_style = wrap_style;
	safe_for_italics = safe_for_italics;
	z = z,
	}</text>
      <sha1>4blryh6085f93wbnky4csa0jlfplbfz</sha1>
    </revision>
    <revision>
      <id>4941</id>
      <parentid>4940</parentid>
      <timestamp>2015-12-14T15:54:59Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4941</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="10078" sha1="4b7i6u3knqr37ri73cwehgfwcraekti" xml:space="preserve">local u = {}

local z = {
	error_categories = {};		-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};		-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};		-- for categorizing citations based on certain properties, language of source for instance
};

local cfg = mw.loadData ('Module:Citation/CS1/Configuration/sandbox');

--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.
This function is global because it is called from both this module and from Date validation

]]
function is_set( var )
	return not (var == nil or var == '');
end


--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end


--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end


--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]
local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end


--[[--------------------------&lt; S E T _ E R R O R &gt;--------------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

]]
local function set_error( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if in_array( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return error_comment( message, error_state.hidden );
end


--[[-------------------------&lt; I S _ A L I A S _ U S E D &gt;-----------------------------------------------------

This function is used by select_one() to determine if one of a list of alias parameters is in the argument list
provided by the template.

Input:
	args – pointer to the arguments table from calling template
	alias – one of the list of possible aliases in the aliases lists from Module:Citation/CS1/Configuration
	index – for enumerated parameters, identifies which one
	enumerated – true/false flag used choose how enumerated aliases are examined
	value – value associated with an alias that has previously been selected; nil if not yet selected
	selected – the alias that has previously been selected; nil if not yet selected
	error_list – list of aliases that are duplicates of the alias already selected

Returns:
	value – value associated with alias we selected or that was previously selected or nil if an alias not yet selected
	selected – the alias we selected or the alias that was previously selected or nil if an alias not yet selected

]]

local function is_alias_used (args, alias, index, enumerated, value, selected, error_list)
	if enumerated then															-- is this a test for an enumerated parameters?
		alias = alias:gsub ('#', index);										-- replace '#' with the value in index
	else
		alias = alias:gsub ('#', '');											-- remove '#' if it exists
	end

	if is_set(args[alias]) then													-- alias is in the template's argument list
		if value ~= nil and selected ~= alias then								-- if we have already selected one of the aliases
			local skip;
			for _, v in ipairs(error_list) do									-- spin through the error list to see if we've added this alias
				if v == alias then
					skip = true;
					break;														-- has been added so stop looking 
				end
			end
			if not skip then													-- has not been added so
				table.insert( error_list, alias );								-- add error alias to the error list
			end
		else
			value = args[alias];												-- not yet selected an alias, so select this one
			selected = alias;
		end
	end
	return value, selected;														-- return newly selected alias, or previously selected alias
end


--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maintenance_cats using names from the configuration file with additional text if any.
To prevent duplication, the added_maint_cats table lists the categories by key that have been added to z.maintenance_cats.

]]

local added_maint_cats = {}														-- list of maintenance categories that have been added to z.maintenance_cats
local function add_maint_cat (key, arguments)
	if not added_maint_cats [key] then
		added_maint_cats [key] = true;											-- note that we've added this category
		table.insert( z.maintenance_cats, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
	end
end


--[[--------------------------&lt; S A F E _ F O R _ I T A L I C S &gt;----------------------------------------------

Protects a string that will be wrapped in wiki italic markup '' ... ''

Note: We cannot use &lt;i&gt; for italics, as the expected behavior for italics specified by ''...'' in the title is that
they will be inverted (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and '' tend to interact
poorly under Mediawiki's HTML tidy.

]]

local function safe_for_italics( str )
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end


--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

local function wrap_style (key, str)
	if not is_set( str ) then
		return &quot;&quot;;
	elseif in_array( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safe_for_italics( str );
	end

	return substitute( cfg.presentation[key], {str} );
end


--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider.  The list of parameters to consider is just
names.  For parameters that may be enumerated, the position of the numerator in the parameter name is identified
by the '#' so |author-last1= and |author1-last= are represented as 'author-last#' and 'author#-last'.

Because enumerated parameter |&lt;param&gt;1= is an alias of |&lt;param&gt;= we must test for both possibilities.


Generates an error if more than one match is present.

]]

local function select_one( args, aliases_list, error_condition, index )
	local value = nil;															-- the value assigned to the selected parameter
	local selected = '';														-- the name of the parameter we have chosen
	local error_list = {};

	if index ~= nil then index = tostring(index); end

	for _, alias in ipairs( aliases_list ) do									-- for each alias in the aliases list
		if alias:match ('#') then												-- if this alias can be enumerated
			if '1' == index then												-- when index is 1 test for enumerated and non-enumerated aliases
				value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);	-- first test for non-enumerated alias
			end
			value, selected = is_alias_used (args, alias, index, true, value, selected, error_list);		-- test for enumerated alias
		else
			value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);		--test for non-enumerated alias
		end
	end

	if #error_list &gt; 0 and 'none' ~= error_condition then						-- for cases where this code is used outside of extract_names()
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap_style ('parameter', k);
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap_style ('parameter', selected);
		table.insert( z.message_tail, { set_error( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end



return {																		-- return exported functions and tables
	is_set = is_set,
	in_array = in_array,
	substitute = substitute,
	error_comment = error_comment,
	set_error = set_error,
	select_one = select_one,
	add_maint_cat = add_maint_cat,
	wrap_style = wrap_style;
	safe_for_italics = safe_for_italics;
	z = z,
	}</text>
      <sha1>4b7i6u3knqr37ri73cwehgfwcraekti</sha1>
    </revision>
    <revision>
      <id>4942</id>
      <parentid>4941</parentid>
      <timestamp>2015-12-14T17:28:00Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4942</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="10286" sha1="58fex2n7fl2uqvwjsatrnb5dxrjfcjx" xml:space="preserve">local u = {}

local z = {
	error_categories = {};		-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};		-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};		-- for categorizing citations based on certain properties, language of source for instance
};

local cfg;

--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.
This function is global because it is called from both this module and from Date validation

]]
function is_set( var )
	return not (var == nil or var == '');
end


--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end


--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end


--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]
local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end


--[[--------------------------&lt; S E T _ E R R O R &gt;--------------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

]]
local function set_error( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if in_array( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return error_comment( message, error_state.hidden );
end


--[[-------------------------&lt; I S _ A L I A S _ U S E D &gt;-----------------------------------------------------

This function is used by select_one() to determine if one of a list of alias parameters is in the argument list
provided by the template.

Input:
	args – pointer to the arguments table from calling template
	alias – one of the list of possible aliases in the aliases lists from Module:Citation/CS1/Configuration
	index – for enumerated parameters, identifies which one
	enumerated – true/false flag used choose how enumerated aliases are examined
	value – value associated with an alias that has previously been selected; nil if not yet selected
	selected – the alias that has previously been selected; nil if not yet selected
	error_list – list of aliases that are duplicates of the alias already selected

Returns:
	value – value associated with alias we selected or that was previously selected or nil if an alias not yet selected
	selected – the alias we selected or the alias that was previously selected or nil if an alias not yet selected

]]

local function is_alias_used (args, alias, index, enumerated, value, selected, error_list)
	if enumerated then															-- is this a test for an enumerated parameters?
		alias = alias:gsub ('#', index);										-- replace '#' with the value in index
	else
		alias = alias:gsub ('#', '');											-- remove '#' if it exists
	end

	if is_set(args[alias]) then													-- alias is in the template's argument list
		if value ~= nil and selected ~= alias then								-- if we have already selected one of the aliases
			local skip;
			for _, v in ipairs(error_list) do									-- spin through the error list to see if we've added this alias
				if v == alias then
					skip = true;
					break;														-- has been added so stop looking 
				end
			end
			if not skip then													-- has not been added so
				table.insert( error_list, alias );								-- add error alias to the error list
			end
		else
			value = args[alias];												-- not yet selected an alias, so select this one
			selected = alias;
		end
	end
	return value, selected;														-- return newly selected alias, or previously selected alias
end


--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maintenance_cats using names from the configuration file with additional text if any.
To prevent duplication, the added_maint_cats table lists the categories by key that have been added to z.maintenance_cats.

]]

local added_maint_cats = {}														-- list of maintenance categories that have been added to z.maintenance_cats
local function add_maint_cat (key, arguments)
	if not added_maint_cats [key] then
		added_maint_cats [key] = true;											-- note that we've added this category
		table.insert( z.maintenance_cats, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
	end
end


--[[--------------------------&lt; S A F E _ F O R _ I T A L I C S &gt;----------------------------------------------

Protects a string that will be wrapped in wiki italic markup '' ... ''

Note: We cannot use &lt;i&gt; for italics, as the expected behavior for italics specified by ''...'' in the title is that
they will be inverted (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and '' tend to interact
poorly under Mediawiki's HTML tidy.

]]

local function safe_for_italics( str )
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end


--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

local function wrap_style (key, str)
	if not is_set( str ) then
		return &quot;&quot;;
	elseif in_array( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safe_for_italics( str );
	end

	return substitute( cfg.presentation[key], {str} );
end


--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider.  The list of parameters to consider is just
names.  For parameters that may be enumerated, the position of the numerator in the parameter name is identified
by the '#' so |author-last1= and |author1-last= are represented as 'author-last#' and 'author#-last'.

Because enumerated parameter |&lt;param&gt;1= is an alias of |&lt;param&gt;= we must test for both possibilities.


Generates an error if more than one match is present.

]]

local function select_one( args, aliases_list, error_condition, index )
	local value = nil;															-- the value assigned to the selected parameter
	local selected = '';														-- the name of the parameter we have chosen
	local error_list = {};

	if index ~= nil then index = tostring(index); end

	for _, alias in ipairs( aliases_list ) do									-- for each alias in the aliases list
		if alias:match ('#') then												-- if this alias can be enumerated
			if '1' == index then												-- when index is 1 test for enumerated and non-enumerated aliases
				value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);	-- first test for non-enumerated alias
			end
			value, selected = is_alias_used (args, alias, index, true, value, selected, error_list);		-- test for enumerated alias
		else
			value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);		--test for non-enumerated alias
		end
	end

	if #error_list &gt; 0 and 'none' ~= error_condition then						-- for cases where this code is used outside of extract_names()
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap_style ('parameter', k);
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap_style ('parameter', selected);
		table.insert( z.message_tail, { set_error( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end


--[[--------------------------&lt; S E T _ C F G &gt;----------------------------------------------------------------

Sets local cfg table to same as that used by the other modules

]]

local function set_cfg (cfg_table_ptr)
	cfg = cfg_table_ptr;
end



return {																		-- return exported functions and tables
	is_set = is_set,
	in_array = in_array,
	substitute = substitute,
	error_comment = error_comment,
	set_error = set_error,
	select_one = select_one,
	add_maint_cat = add_maint_cat,
	wrap_style = wrap_style;
	safe_for_italics = safe_for_italics;
	set_cfg = set_cfg;
	z = z,
	}</text>
      <sha1>58fex2n7fl2uqvwjsatrnb5dxrjfcjx</sha1>
    </revision>
    <revision>
      <id>4943</id>
      <parentid>4942</parentid>
      <timestamp>2015-12-15T01:01:32Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4943</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="10414" sha1="3v6kuzqjuilsbgm753d80h2xo386c5s" xml:space="preserve">require('Module:No globals');
--[[
History of changes since last sync: 2015-12-12

]]

local u = {}

local z = {
	error_categories = {};														-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};														-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};														-- for categorizing citations based on certain properties, language of source for instance
};

local cfg = {};

--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.
This function is global because it is called from both this module and from Date validation

]]
function is_set( var )
	return not (var == nil or var == '');
end


--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end


--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end


--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]
local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end


--[[--------------------------&lt; S E T _ E R R O R &gt;--------------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

]]
local function set_error( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if in_array( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return error_comment( message, error_state.hidden );
end


--[[-------------------------&lt; I S _ A L I A S _ U S E D &gt;-----------------------------------------------------

This function is used by select_one() to determine if one of a list of alias parameters is in the argument list
provided by the template.

Input:
	args – pointer to the arguments table from calling template
	alias – one of the list of possible aliases in the aliases lists from Module:Citation/CS1/Configuration
	index – for enumerated parameters, identifies which one
	enumerated – true/false flag used choose how enumerated aliases are examined
	value – value associated with an alias that has previously been selected; nil if not yet selected
	selected – the alias that has previously been selected; nil if not yet selected
	error_list – list of aliases that are duplicates of the alias already selected

Returns:
	value – value associated with alias we selected or that was previously selected or nil if an alias not yet selected
	selected – the alias we selected or the alias that was previously selected or nil if an alias not yet selected

]]

local function is_alias_used (args, alias, index, enumerated, value, selected, error_list)
	if enumerated then															-- is this a test for an enumerated parameters?
		alias = alias:gsub ('#', index);										-- replace '#' with the value in index
	else
		alias = alias:gsub ('#', '');											-- remove '#' if it exists
	end

	if is_set(args[alias]) then													-- alias is in the template's argument list
		if value ~= nil and selected ~= alias then								-- if we have already selected one of the aliases
			local skip;
			for _, v in ipairs(error_list) do									-- spin through the error list to see if we've added this alias
				if v == alias then
					skip = true;
					break;														-- has been added so stop looking 
				end
			end
			if not skip then													-- has not been added so
				table.insert( error_list, alias );								-- add error alias to the error list
			end
		else
			value = args[alias];												-- not yet selected an alias, so select this one
			selected = alias;
		end
	end
	return value, selected;														-- return newly selected alias, or previously selected alias
end


--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maintenance_cats using names from the configuration file with additional text if any.
To prevent duplication, the added_maint_cats table lists the categories by key that have been added to z.maintenance_cats.

]]

local added_maint_cats = {}														-- list of maintenance categories that have been added to z.maintenance_cats
local function add_maint_cat (key, arguments)
	if not added_maint_cats [key] then
		added_maint_cats [key] = true;											-- note that we've added this category
		table.insert( z.maintenance_cats, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
	end
end


--[[--------------------------&lt; S A F E _ F O R _ I T A L I C S &gt;----------------------------------------------

Protects a string that will be wrapped in wiki italic markup '' ... ''

Note: We cannot use &lt;i&gt; for italics, as the expected behavior for italics specified by ''...'' in the title is that
they will be inverted (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and '' tend to interact
poorly under Mediawiki's HTML tidy.

]]

local function safe_for_italics( str )
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end


--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

local function wrap_style (key, str)
	if not is_set( str ) then
		return &quot;&quot;;
	elseif in_array( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safe_for_italics( str );
	end

	return substitute( cfg.presentation[key], {str} );
end


--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider.  The list of parameters to consider is just
names.  For parameters that may be enumerated, the position of the numerator in the parameter name is identified
by the '#' so |author-last1= and |author1-last= are represented as 'author-last#' and 'author#-last'.

Because enumerated parameter |&lt;param&gt;1= is an alias of |&lt;param&gt;= we must test for both possibilities.


Generates an error if more than one match is present.

]]

local function select_one( args, aliases_list, error_condition, index )
	local value = nil;															-- the value assigned to the selected parameter
	local selected = '';														-- the name of the parameter we have chosen
	local error_list = {};

	if index ~= nil then index = tostring(index); end

	for _, alias in ipairs( aliases_list ) do									-- for each alias in the aliases list
		if alias:match ('#') then												-- if this alias can be enumerated
			if '1' == index then												-- when index is 1 test for enumerated and non-enumerated aliases
				value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);	-- first test for non-enumerated alias
			end
			value, selected = is_alias_used (args, alias, index, true, value, selected, error_list);		-- test for enumerated alias
		else
			value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);		--test for non-enumerated alias
		end
	end

	if #error_list &gt; 0 and 'none' ~= error_condition then						-- for cases where this code is used outside of extract_names()
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap_style ('parameter', k);
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap_style ('parameter', selected);
		table.insert( z.message_tail, { set_error( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end


--[[--------------------------&lt; S E T _ C F G &gt;----------------------------------------------------------------

Sets local cfg table to same as that used by the other modules

]]

local function set_cfg (cfg_table_ptr)
	cfg = cfg_table_ptr;
end



return {																		-- return exported functions and tables
	is_set = is_set,
	in_array = in_array,
	substitute = substitute,
	error_comment = error_comment,
	set_error = set_error,
	select_one = select_one,
	add_maint_cat = add_maint_cat,
	wrap_style = wrap_style;
	safe_for_italics = safe_for_italics;
	set_cfg = set_cfg;
	z = z,
	}</text>
      <sha1>3v6kuzqjuilsbgm753d80h2xo386c5s</sha1>
    </revision>
    <revision>
      <id>4944</id>
      <parentid>4943</parentid>
      <timestamp>2015-12-15T01:02:26Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4944</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="10420" sha1="4g4afbmqm2r40tpjcvvckcxa3wwnti7" xml:space="preserve">require('Module:No globals');
--[[
History of changes since last sync: 2015-12-12

]]

local u = {}

local z = {
	error_categories = {};														-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};														-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};														-- for categorizing citations based on certain properties, language of source for instance
};

local cfg = {};

--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.
This function is global because it is called from both this module and from Date validation

]]
local function is_set( var )
	return not (var == nil or var == '');
end


--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end


--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end


--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]
local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end


--[[--------------------------&lt; S E T _ E R R O R &gt;--------------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

]]
local function set_error( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if in_array( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return error_comment( message, error_state.hidden );
end


--[[-------------------------&lt; I S _ A L I A S _ U S E D &gt;-----------------------------------------------------

This function is used by select_one() to determine if one of a list of alias parameters is in the argument list
provided by the template.

Input:
	args – pointer to the arguments table from calling template
	alias – one of the list of possible aliases in the aliases lists from Module:Citation/CS1/Configuration
	index – for enumerated parameters, identifies which one
	enumerated – true/false flag used choose how enumerated aliases are examined
	value – value associated with an alias that has previously been selected; nil if not yet selected
	selected – the alias that has previously been selected; nil if not yet selected
	error_list – list of aliases that are duplicates of the alias already selected

Returns:
	value – value associated with alias we selected or that was previously selected or nil if an alias not yet selected
	selected – the alias we selected or the alias that was previously selected or nil if an alias not yet selected

]]

local function is_alias_used (args, alias, index, enumerated, value, selected, error_list)
	if enumerated then															-- is this a test for an enumerated parameters?
		alias = alias:gsub ('#', index);										-- replace '#' with the value in index
	else
		alias = alias:gsub ('#', '');											-- remove '#' if it exists
	end

	if is_set(args[alias]) then													-- alias is in the template's argument list
		if value ~= nil and selected ~= alias then								-- if we have already selected one of the aliases
			local skip;
			for _, v in ipairs(error_list) do									-- spin through the error list to see if we've added this alias
				if v == alias then
					skip = true;
					break;														-- has been added so stop looking 
				end
			end
			if not skip then													-- has not been added so
				table.insert( error_list, alias );								-- add error alias to the error list
			end
		else
			value = args[alias];												-- not yet selected an alias, so select this one
			selected = alias;
		end
	end
	return value, selected;														-- return newly selected alias, or previously selected alias
end


--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maintenance_cats using names from the configuration file with additional text if any.
To prevent duplication, the added_maint_cats table lists the categories by key that have been added to z.maintenance_cats.

]]

local added_maint_cats = {}														-- list of maintenance categories that have been added to z.maintenance_cats
local function add_maint_cat (key, arguments)
	if not added_maint_cats [key] then
		added_maint_cats [key] = true;											-- note that we've added this category
		table.insert( z.maintenance_cats, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
	end
end


--[[--------------------------&lt; S A F E _ F O R _ I T A L I C S &gt;----------------------------------------------

Protects a string that will be wrapped in wiki italic markup '' ... ''

Note: We cannot use &lt;i&gt; for italics, as the expected behavior for italics specified by ''...'' in the title is that
they will be inverted (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and '' tend to interact
poorly under Mediawiki's HTML tidy.

]]

local function safe_for_italics( str )
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end


--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

local function wrap_style (key, str)
	if not is_set( str ) then
		return &quot;&quot;;
	elseif in_array( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safe_for_italics( str );
	end

	return substitute( cfg.presentation[key], {str} );
end


--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider.  The list of parameters to consider is just
names.  For parameters that may be enumerated, the position of the numerator in the parameter name is identified
by the '#' so |author-last1= and |author1-last= are represented as 'author-last#' and 'author#-last'.

Because enumerated parameter |&lt;param&gt;1= is an alias of |&lt;param&gt;= we must test for both possibilities.


Generates an error if more than one match is present.

]]

local function select_one( args, aliases_list, error_condition, index )
	local value = nil;															-- the value assigned to the selected parameter
	local selected = '';														-- the name of the parameter we have chosen
	local error_list = {};

	if index ~= nil then index = tostring(index); end

	for _, alias in ipairs( aliases_list ) do									-- for each alias in the aliases list
		if alias:match ('#') then												-- if this alias can be enumerated
			if '1' == index then												-- when index is 1 test for enumerated and non-enumerated aliases
				value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);	-- first test for non-enumerated alias
			end
			value, selected = is_alias_used (args, alias, index, true, value, selected, error_list);		-- test for enumerated alias
		else
			value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);		--test for non-enumerated alias
		end
	end

	if #error_list &gt; 0 and 'none' ~= error_condition then						-- for cases where this code is used outside of extract_names()
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap_style ('parameter', k);
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap_style ('parameter', selected);
		table.insert( z.message_tail, { set_error( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end


--[[--------------------------&lt; S E T _ C F G &gt;----------------------------------------------------------------

Sets local cfg table to same as that used by the other modules

]]

local function set_cfg (cfg_table_ptr)
	cfg = cfg_table_ptr;
end



return {																		-- return exported functions and tables
	is_set = is_set,
	in_array = in_array,
	substitute = substitute,
	error_comment = error_comment,
	set_error = set_error,
	select_one = select_one,
	add_maint_cat = add_maint_cat,
	wrap_style = wrap_style;
	safe_for_italics = safe_for_italics;
	set_cfg = set_cfg;
	z = z,
	}</text>
      <sha1>4g4afbmqm2r40tpjcvvckcxa3wwnti7</sha1>
    </revision>
    <revision>
      <id>4945</id>
      <parentid>4944</parentid>
      <timestamp>2015-12-15T17:14:24Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4945</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="10473" sha1="kyqjxvsedc6qephjlzvgvt7udd1oqly" xml:space="preserve">require('Module:No globals');
--[[
History of changes since last sync: 2015-12-12

]]

local u = {}

local z = {
	error_categories = {};														-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};														-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};														-- for categorizing citations based on certain properties, language of source for instance
};

local cfg;

--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.
This function is global because it is called from both this module and from Date validation

]]
local function is_set( var )
	return not (var == nil or var == '');
end


--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end


--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end


--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]
local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end


--[[--------------------------&lt; S E T _ E R R O R &gt;--------------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

]]
local function set_error( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if in_array( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return error_comment( message, error_state.hidden );
end


--[[-------------------------&lt; I S _ A L I A S _ U S E D &gt;-----------------------------------------------------

This function is used by select_one() to determine if one of a list of alias parameters is in the argument list
provided by the template.

Input:
	args – pointer to the arguments table from calling template
	alias – one of the list of possible aliases in the aliases lists from Module:Citation/CS1/Configuration
	index – for enumerated parameters, identifies which one
	enumerated – true/false flag used choose how enumerated aliases are examined
	value – value associated with an alias that has previously been selected; nil if not yet selected
	selected – the alias that has previously been selected; nil if not yet selected
	error_list – list of aliases that are duplicates of the alias already selected

Returns:
	value – value associated with alias we selected or that was previously selected or nil if an alias not yet selected
	selected – the alias we selected or the alias that was previously selected or nil if an alias not yet selected

]]

local function is_alias_used (args, alias, index, enumerated, value, selected, error_list)
	if enumerated then															-- is this a test for an enumerated parameters?
		alias = alias:gsub ('#', index);										-- replace '#' with the value in index
	else
		alias = alias:gsub ('#', '');											-- remove '#' if it exists
	end

	if is_set(args[alias]) then													-- alias is in the template's argument list
		if value ~= nil and selected ~= alias then								-- if we have already selected one of the aliases
			local skip;
			for _, v in ipairs(error_list) do									-- spin through the error list to see if we've added this alias
				if v == alias then
					skip = true;
					break;														-- has been added so stop looking 
				end
			end
			if not skip then													-- has not been added so
				table.insert( error_list, alias );								-- add error alias to the error list
			end
		else
			value = args[alias];												-- not yet selected an alias, so select this one
			selected = alias;
		end
	end
	return value, selected;														-- return newly selected alias, or previously selected alias
end


--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maintenance_cats using names from the configuration file with additional text if any.
To prevent duplication, the added_maint_cats table lists the categories by key that have been added to z.maintenance_cats.

]]

local added_maint_cats = {}														-- list of maintenance categories that have been added to z.maintenance_cats
local function add_maint_cat (key, arguments)
	if not added_maint_cats [key] then
		added_maint_cats [key] = true;											-- note that we've added this category
		table.insert( z.maintenance_cats, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
	end
end


--[[--------------------------&lt; S A F E _ F O R _ I T A L I C S &gt;----------------------------------------------

Protects a string that will be wrapped in wiki italic markup '' ... ''

Note: We cannot use &lt;i&gt; for italics, as the expected behavior for italics specified by ''...'' in the title is that
they will be inverted (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and '' tend to interact
poorly under Mediawiki's HTML tidy.

]]

local function safe_for_italics( str )
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end


--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

local function wrap_style (key, str)
	if not is_set( str ) then
		return &quot;&quot;;
	elseif in_array( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safe_for_italics( str );
	end

	return substitute( cfg.presentation[key], {str} );
end


--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider.  The list of parameters to consider is just
names.  For parameters that may be enumerated, the position of the numerator in the parameter name is identified
by the '#' so |author-last1= and |author1-last= are represented as 'author-last#' and 'author#-last'.

Because enumerated parameter |&lt;param&gt;1= is an alias of |&lt;param&gt;= we must test for both possibilities.


Generates an error if more than one match is present.

]]

local function select_one( args, aliases_list, error_condition, index )
	local value = nil;															-- the value assigned to the selected parameter
	local selected = '';														-- the name of the parameter we have chosen
	local error_list = {};

	if index ~= nil then index = tostring(index); end

	for _, alias in ipairs( aliases_list ) do									-- for each alias in the aliases list
		if alias:match ('#') then												-- if this alias can be enumerated
			if '1' == index then												-- when index is 1 test for enumerated and non-enumerated aliases
				value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);	-- first test for non-enumerated alias
			end
			value, selected = is_alias_used (args, alias, index, true, value, selected, error_list);		-- test for enumerated alias
		else
			value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);		--test for non-enumerated alias
		end
	end

	if #error_list &gt; 0 and 'none' ~= error_condition then						-- for cases where this code is used outside of extract_names()
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap_style ('parameter', k);
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap_style ('parameter', selected);
		table.insert( z.message_tail, { set_error( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr)
	cfg = cfg_table_ptr;
end



return {																		-- return exported functions and tables
	is_set = is_set,
	in_array = in_array,
	substitute = substitute,
	error_comment = error_comment,
	set_error = set_error,
	select_one = select_one,
	add_maint_cat = add_maint_cat,
	wrap_style = wrap_style;
	safe_for_italics = safe_for_italics;
	set_selected_modules = set_selected_modules;
	z = z,
	}</text>
      <sha1>kyqjxvsedc6qephjlzvgvt7udd1oqly</sha1>
    </revision>
    <revision>
      <id>4946</id>
      <parentid>4945</parentid>
      <timestamp>2015-12-15T17:33:22Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4946</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="10683" sha1="r5c4h75pasy9rmm3io1g3zq3op7x5s6" xml:space="preserve">require('Module:No globals');
--[[
History of changes since last sync: 2015-12-12

]]

local u = {}

local z = {
	error_categories = {};														-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};														-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};														-- for categorizing citations based on certain properties, language of source for instance
};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local cfg;																		-- table of tables imported from slected Module:Citation/CS1/Configuration


--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.
This function is global because it is called from both this module and from Date validation

]]
local function is_set( var )
	return not (var == nil or var == '');
end


--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end


--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end


--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]
local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end


--[[--------------------------&lt; S E T _ E R R O R &gt;--------------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

]]
local function set_error( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if in_array( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return error_comment( message, error_state.hidden );
end


--[[-------------------------&lt; I S _ A L I A S _ U S E D &gt;-----------------------------------------------------

This function is used by select_one() to determine if one of a list of alias parameters is in the argument list
provided by the template.

Input:
	args – pointer to the arguments table from calling template
	alias – one of the list of possible aliases in the aliases lists from Module:Citation/CS1/Configuration
	index – for enumerated parameters, identifies which one
	enumerated – true/false flag used choose how enumerated aliases are examined
	value – value associated with an alias that has previously been selected; nil if not yet selected
	selected – the alias that has previously been selected; nil if not yet selected
	error_list – list of aliases that are duplicates of the alias already selected

Returns:
	value – value associated with alias we selected or that was previously selected or nil if an alias not yet selected
	selected – the alias we selected or the alias that was previously selected or nil if an alias not yet selected

]]

local function is_alias_used (args, alias, index, enumerated, value, selected, error_list)
	if enumerated then															-- is this a test for an enumerated parameters?
		alias = alias:gsub ('#', index);										-- replace '#' with the value in index
	else
		alias = alias:gsub ('#', '');											-- remove '#' if it exists
	end

	if is_set(args[alias]) then													-- alias is in the template's argument list
		if value ~= nil and selected ~= alias then								-- if we have already selected one of the aliases
			local skip;
			for _, v in ipairs(error_list) do									-- spin through the error list to see if we've added this alias
				if v == alias then
					skip = true;
					break;														-- has been added so stop looking 
				end
			end
			if not skip then													-- has not been added so
				table.insert( error_list, alias );								-- add error alias to the error list
			end
		else
			value = args[alias];												-- not yet selected an alias, so select this one
			selected = alias;
		end
	end
	return value, selected;														-- return newly selected alias, or previously selected alias
end


--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maintenance_cats using names from the configuration file with additional text if any.
To prevent duplication, the added_maint_cats table lists the categories by key that have been added to z.maintenance_cats.

]]

local added_maint_cats = {}														-- list of maintenance categories that have been added to z.maintenance_cats
local function add_maint_cat (key, arguments)
	if not added_maint_cats [key] then
		added_maint_cats [key] = true;											-- note that we've added this category
		table.insert( z.maintenance_cats, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
	end
end


--[[--------------------------&lt; S A F E _ F O R _ I T A L I C S &gt;----------------------------------------------

Protects a string that will be wrapped in wiki italic markup '' ... ''

Note: We cannot use &lt;i&gt; for italics, as the expected behavior for italics specified by ''...'' in the title is that
they will be inverted (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and '' tend to interact
poorly under Mediawiki's HTML tidy.

]]

local function safe_for_italics( str )
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end


--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

local function wrap_style (key, str)
	if not is_set( str ) then
		return &quot;&quot;;
	elseif in_array( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safe_for_italics( str );
	end

	return substitute( cfg.presentation[key], {str} );
end


--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider.  The list of parameters to consider is just
names.  For parameters that may be enumerated, the position of the numerator in the parameter name is identified
by the '#' so |author-last1= and |author1-last= are represented as 'author-last#' and 'author#-last'.

Because enumerated parameter |&lt;param&gt;1= is an alias of |&lt;param&gt;= we must test for both possibilities.


Generates an error if more than one match is present.

]]

local function select_one( args, aliases_list, error_condition, index )
	local value = nil;															-- the value assigned to the selected parameter
	local selected = '';														-- the name of the parameter we have chosen
	local error_list = {};

	if index ~= nil then index = tostring(index); end

	for _, alias in ipairs( aliases_list ) do									-- for each alias in the aliases list
		if alias:match ('#') then												-- if this alias can be enumerated
			if '1' == index then												-- when index is 1 test for enumerated and non-enumerated aliases
				value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);	-- first test for non-enumerated alias
			end
			value, selected = is_alias_used (args, alias, index, true, value, selected, error_list);		-- test for enumerated alias
		else
			value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);		--test for non-enumerated alias
		end
	end

	if #error_list &gt; 0 and 'none' ~= error_condition then						-- for cases where this code is used outside of extract_names()
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap_style ('parameter', k);
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap_style ('parameter', selected);
		table.insert( z.message_tail, { set_error( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr)
	cfg = cfg_table_ptr;
end



return {																		-- return exported functions and tables
	is_set = is_set,
	in_array = in_array,
	substitute = substitute,
	error_comment = error_comment,
	set_error = set_error,
	select_one = select_one,
	add_maint_cat = add_maint_cat,
	wrap_style = wrap_style;
	safe_for_italics = safe_for_italics;
	set_selected_modules = set_selected_modules;
	z = z,
	}</text>
      <sha1>r5c4h75pasy9rmm3io1g3zq3op7x5s6</sha1>
    </revision>
    <revision>
      <id>4947</id>
      <parentid>4946</parentid>
      <timestamp>2015-12-15T19:18:33Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4947</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="11081" sha1="6a09wf8ga8j491mwjm95igp0wu7c8lx" xml:space="preserve">require('Module:No globals');
--[[
History of changes since last sync: 2015-12-12

]]

local u = {}

local z = {
	error_categories = {};														-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};														-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};														-- for categorizing citations based on certain properties, language of source for instance
};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local cfg;																		-- table of tables imported from slected Module:Citation/CS1/Configuration


--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.
This function is global because it is called from both this module and from Date validation

]]
local function is_set( var )
	return not (var == nil or var == '');
end


--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end


--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end


--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]
local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end


--[[--------------------------&lt; S E T _ E R R O R &gt;--------------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

]]
local function set_error( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if in_array( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return error_comment( message, error_state.hidden );
end


--[[-------------------------&lt; I S _ A L I A S _ U S E D &gt;-----------------------------------------------------

This function is used by select_one() to determine if one of a list of alias parameters is in the argument list
provided by the template.

Input:
	args – pointer to the arguments table from calling template
	alias – one of the list of possible aliases in the aliases lists from Module:Citation/CS1/Configuration
	index – for enumerated parameters, identifies which one
	enumerated – true/false flag used choose how enumerated aliases are examined
	value – value associated with an alias that has previously been selected; nil if not yet selected
	selected – the alias that has previously been selected; nil if not yet selected
	error_list – list of aliases that are duplicates of the alias already selected

Returns:
	value – value associated with alias we selected or that was previously selected or nil if an alias not yet selected
	selected – the alias we selected or the alias that was previously selected or nil if an alias not yet selected

]]

local function is_alias_used (args, alias, index, enumerated, value, selected, error_list)
	if enumerated then															-- is this a test for an enumerated parameters?
		alias = alias:gsub ('#', index);										-- replace '#' with the value in index
	else
		alias = alias:gsub ('#', '');											-- remove '#' if it exists
	end

	if is_set(args[alias]) then													-- alias is in the template's argument list
		if value ~= nil and selected ~= alias then								-- if we have already selected one of the aliases
			local skip;
			for _, v in ipairs(error_list) do									-- spin through the error list to see if we've added this alias
				if v == alias then
					skip = true;
					break;														-- has been added so stop looking 
				end
			end
			if not skip then													-- has not been added so
				table.insert( error_list, alias );								-- add error alias to the error list
			end
		else
			value = args[alias];												-- not yet selected an alias, so select this one
			selected = alias;
		end
	end
	return value, selected;														-- return newly selected alias, or previously selected alias
end


--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maintenance_cats using names from the configuration file with additional text if any.
To prevent duplication, the added_maint_cats table lists the categories by key that have been added to z.maintenance_cats.

]]

local added_maint_cats = {}														-- list of maintenance categories that have been added to z.maintenance_cats
local function add_maint_cat (key, arguments)
	if not added_maint_cats [key] then
		added_maint_cats [key] = true;											-- note that we've added this category
		table.insert( z.maintenance_cats, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
	end
end


--[[--------------------------&lt; S A F E _ F O R _ I T A L I C S &gt;----------------------------------------------

Protects a string that will be wrapped in wiki italic markup '' ... ''

Note: We cannot use &lt;i&gt; for italics, as the expected behavior for italics specified by ''...'' in the title is that
they will be inverted (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and '' tend to interact
poorly under Mediawiki's HTML tidy.

]]

local function safe_for_italics( str )
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end


--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

local function wrap_style (key, str)
	if not is_set( str ) then
		return &quot;&quot;;
	elseif in_array( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safe_for_italics( str );
	end

	return substitute( cfg.presentation[key], {str} );
end


--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider.  The list of parameters to consider is just
names.  For parameters that may be enumerated, the position of the numerator in the parameter name is identified
by the '#' so |author-last1= and |author1-last= are represented as 'author-last#' and 'author#-last'.

Because enumerated parameter |&lt;param&gt;1= is an alias of |&lt;param&gt;= we must test for both possibilities.


Generates an error if more than one match is present.

]]

local function select_one( args, aliases_list, error_condition, index )
	local value = nil;															-- the value assigned to the selected parameter
	local selected = '';														-- the name of the parameter we have chosen
	local error_list = {};

	if index ~= nil then index = tostring(index); end

	for _, alias in ipairs( aliases_list ) do									-- for each alias in the aliases list
		if alias:match ('#') then												-- if this alias can be enumerated
			if '1' == index then												-- when index is 1 test for enumerated and non-enumerated aliases
				value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);	-- first test for non-enumerated alias
			end
			value, selected = is_alias_used (args, alias, index, true, value, selected, error_list);		-- test for enumerated alias
		else
			value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);		--test for non-enumerated alias
		end
	end

	if #error_list &gt; 0 and 'none' ~= error_condition then						-- for cases where this code is used outside of extract_names()
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap_style ('parameter', k);
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap_style ('parameter', selected);
		table.insert( z.message_tail, { set_error( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end


--[=[-------------------------&lt; R E M O V E _ W I K I _ L I N K &gt;----------------------------------------------

Gets the display text from a wikilink like [[A|B]] or [[B]] gives B

]=]

local function remove_wiki_link (str)
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr)
	cfg = cfg_table_ptr;
end



return {																		-- return exported functions and tables
	is_set = is_set,
	in_array = in_array,
	substitute = substitute,
	error_comment = error_comment,
	set_error = set_error,
	select_one = select_one,
	add_maint_cat = add_maint_cat,
	wrap_style = wrap_style;
	safe_for_italics = safe_for_italics;
	remove_wiki_link = remove_wiki_link;
	set_selected_modules = set_selected_modules;
	z = z,
	}</text>
      <sha1>6a09wf8ga8j491mwjm95igp0wu7c8lx</sha1>
    </revision>
    <revision>
      <id>4948</id>
      <parentid>4947</parentid>
      <timestamp>2016-01-15T14:25:38Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>remove ch</comment>
      <origin>4948</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="10994" sha1="m8ojanpl403qdkc0wvbyskl5ce5hpxl" xml:space="preserve">local u = {}

local z = {
	error_categories = {};														-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};														-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};														-- for categorizing citations based on certain properties, language of source for instance
};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local cfg;																		-- table of tables imported from slected Module:Citation/CS1/Configuration


--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.
This function is global because it is called from both this module and from Date validation

]]
local function is_set( var )
	return not (var == nil or var == '');
end


--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end


--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end


--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]
local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end


--[[--------------------------&lt; S E T _ E R R O R &gt;--------------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

]]
local function set_error( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if in_array( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return error_comment( message, error_state.hidden );
end


--[[-------------------------&lt; I S _ A L I A S _ U S E D &gt;-----------------------------------------------------

This function is used by select_one() to determine if one of a list of alias parameters is in the argument list
provided by the template.

Input:
	args – pointer to the arguments table from calling template
	alias – one of the list of possible aliases in the aliases lists from Module:Citation/CS1/Configuration
	index – for enumerated parameters, identifies which one
	enumerated – true/false flag used choose how enumerated aliases are examined
	value – value associated with an alias that has previously been selected; nil if not yet selected
	selected – the alias that has previously been selected; nil if not yet selected
	error_list – list of aliases that are duplicates of the alias already selected

Returns:
	value – value associated with alias we selected or that was previously selected or nil if an alias not yet selected
	selected – the alias we selected or the alias that was previously selected or nil if an alias not yet selected

]]

local function is_alias_used (args, alias, index, enumerated, value, selected, error_list)
	if enumerated then															-- is this a test for an enumerated parameters?
		alias = alias:gsub ('#', index);										-- replace '#' with the value in index
	else
		alias = alias:gsub ('#', '');											-- remove '#' if it exists
	end

	if is_set(args[alias]) then													-- alias is in the template's argument list
		if value ~= nil and selected ~= alias then								-- if we have already selected one of the aliases
			local skip;
			for _, v in ipairs(error_list) do									-- spin through the error list to see if we've added this alias
				if v == alias then
					skip = true;
					break;														-- has been added so stop looking 
				end
			end
			if not skip then													-- has not been added so
				table.insert( error_list, alias );								-- add error alias to the error list
			end
		else
			value = args[alias];												-- not yet selected an alias, so select this one
			selected = alias;
		end
	end
	return value, selected;														-- return newly selected alias, or previously selected alias
end


--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maintenance_cats using names from the configuration file with additional text if any.
To prevent duplication, the added_maint_cats table lists the categories by key that have been added to z.maintenance_cats.

]]

local added_maint_cats = {}														-- list of maintenance categories that have been added to z.maintenance_cats
local function add_maint_cat (key, arguments)
	if not added_maint_cats [key] then
		added_maint_cats [key] = true;											-- note that we've added this category
		table.insert( z.maintenance_cats, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
	end
end


--[[--------------------------&lt; S A F E _ F O R _ I T A L I C S &gt;----------------------------------------------

Protects a string that will be wrapped in wiki italic markup '' ... ''

Note: We cannot use &lt;i&gt; for italics, as the expected behavior for italics specified by ''...'' in the title is that
they will be inverted (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and '' tend to interact
poorly under Mediawiki's HTML tidy.

]]

local function safe_for_italics( str )
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end


--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

local function wrap_style (key, str)
	if not is_set( str ) then
		return &quot;&quot;;
	elseif in_array( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safe_for_italics( str );
	end

	return substitute( cfg.presentation[key], {str} );
end


--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider.  The list of parameters to consider is just
names.  For parameters that may be enumerated, the position of the numerator in the parameter name is identified
by the '#' so |author-last1= and |author1-last= are represented as 'author-last#' and 'author#-last'.

Because enumerated parameter |&lt;param&gt;1= is an alias of |&lt;param&gt;= we must test for both possibilities.


Generates an error if more than one match is present.

]]

local function select_one( args, aliases_list, error_condition, index )
	local value = nil;															-- the value assigned to the selected parameter
	local selected = '';														-- the name of the parameter we have chosen
	local error_list = {};

	if index ~= nil then index = tostring(index); end

	for _, alias in ipairs( aliases_list ) do									-- for each alias in the aliases list
		if alias:match ('#') then												-- if this alias can be enumerated
			if '1' == index then												-- when index is 1 test for enumerated and non-enumerated aliases
				value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);	-- first test for non-enumerated alias
			end
			value, selected = is_alias_used (args, alias, index, true, value, selected, error_list);		-- test for enumerated alias
		else
			value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);		--test for non-enumerated alias
		end
	end

	if #error_list &gt; 0 and 'none' ~= error_condition then						-- for cases where this code is used outside of extract_names()
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap_style ('parameter', k);
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap_style ('parameter', selected);
		table.insert( z.message_tail, { set_error( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end


--[=[-------------------------&lt; R E M O V E _ W I K I _ L I N K &gt;----------------------------------------------

Gets the display text from a wikilink like [[A|B]] or [[B]] gives B

]=]

local function remove_wiki_link (str)
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr)
	cfg = cfg_table_ptr;
end



return {																		-- return exported functions and tables
	is_set = is_set,
	in_array = in_array,
	substitute = substitute,
	error_comment = error_comment,
	set_error = set_error,
	select_one = select_one,
	add_maint_cat = add_maint_cat,
	wrap_style = wrap_style;
	safe_for_italics = safe_for_italics;
	remove_wiki_link = remove_wiki_link;
	set_selected_modules = set_selected_modules;
	z = z,
	}</text>
      <sha1>m8ojanpl403qdkc0wvbyskl5ce5hpxl</sha1>
    </revision>
    <revision>
      <id>4949</id>
      <parentid>4948</parentid>
      <timestamp>2016-01-15T14:31:09Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <minor />
      <comment>Protected &quot;[[Module:Citation/CS1/Utilities]]&quot;: [[WP:High-risk templates|High-risk Lua module]] ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))</comment>
      <origin>4948</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="10994" sha1="m8ojanpl403qdkc0wvbyskl5ce5hpxl" xml:space="preserve">local u = {}

local z = {
	error_categories = {};														-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};														-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};														-- for categorizing citations based on certain properties, language of source for instance
};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local cfg;																		-- table of tables imported from slected Module:Citation/CS1/Configuration


--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.
This function is global because it is called from both this module and from Date validation

]]
local function is_set( var )
	return not (var == nil or var == '');
end


--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end


--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end


--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]
local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end


--[[--------------------------&lt; S E T _ E R R O R &gt;--------------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

]]
local function set_error( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if in_array( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return error_comment( message, error_state.hidden );
end


--[[-------------------------&lt; I S _ A L I A S _ U S E D &gt;-----------------------------------------------------

This function is used by select_one() to determine if one of a list of alias parameters is in the argument list
provided by the template.

Input:
	args – pointer to the arguments table from calling template
	alias – one of the list of possible aliases in the aliases lists from Module:Citation/CS1/Configuration
	index – for enumerated parameters, identifies which one
	enumerated – true/false flag used choose how enumerated aliases are examined
	value – value associated with an alias that has previously been selected; nil if not yet selected
	selected – the alias that has previously been selected; nil if not yet selected
	error_list – list of aliases that are duplicates of the alias already selected

Returns:
	value – value associated with alias we selected or that was previously selected or nil if an alias not yet selected
	selected – the alias we selected or the alias that was previously selected or nil if an alias not yet selected

]]

local function is_alias_used (args, alias, index, enumerated, value, selected, error_list)
	if enumerated then															-- is this a test for an enumerated parameters?
		alias = alias:gsub ('#', index);										-- replace '#' with the value in index
	else
		alias = alias:gsub ('#', '');											-- remove '#' if it exists
	end

	if is_set(args[alias]) then													-- alias is in the template's argument list
		if value ~= nil and selected ~= alias then								-- if we have already selected one of the aliases
			local skip;
			for _, v in ipairs(error_list) do									-- spin through the error list to see if we've added this alias
				if v == alias then
					skip = true;
					break;														-- has been added so stop looking 
				end
			end
			if not skip then													-- has not been added so
				table.insert( error_list, alias );								-- add error alias to the error list
			end
		else
			value = args[alias];												-- not yet selected an alias, so select this one
			selected = alias;
		end
	end
	return value, selected;														-- return newly selected alias, or previously selected alias
end


--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maintenance_cats using names from the configuration file with additional text if any.
To prevent duplication, the added_maint_cats table lists the categories by key that have been added to z.maintenance_cats.

]]

local added_maint_cats = {}														-- list of maintenance categories that have been added to z.maintenance_cats
local function add_maint_cat (key, arguments)
	if not added_maint_cats [key] then
		added_maint_cats [key] = true;											-- note that we've added this category
		table.insert( z.maintenance_cats, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
	end
end


--[[--------------------------&lt; S A F E _ F O R _ I T A L I C S &gt;----------------------------------------------

Protects a string that will be wrapped in wiki italic markup '' ... ''

Note: We cannot use &lt;i&gt; for italics, as the expected behavior for italics specified by ''...'' in the title is that
they will be inverted (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and '' tend to interact
poorly under Mediawiki's HTML tidy.

]]

local function safe_for_italics( str )
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span /&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span /&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end


--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

local function wrap_style (key, str)
	if not is_set( str ) then
		return &quot;&quot;;
	elseif in_array( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safe_for_italics( str );
	end

	return substitute( cfg.presentation[key], {str} );
end


--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider.  The list of parameters to consider is just
names.  For parameters that may be enumerated, the position of the numerator in the parameter name is identified
by the '#' so |author-last1= and |author1-last= are represented as 'author-last#' and 'author#-last'.

Because enumerated parameter |&lt;param&gt;1= is an alias of |&lt;param&gt;= we must test for both possibilities.


Generates an error if more than one match is present.

]]

local function select_one( args, aliases_list, error_condition, index )
	local value = nil;															-- the value assigned to the selected parameter
	local selected = '';														-- the name of the parameter we have chosen
	local error_list = {};

	if index ~= nil then index = tostring(index); end

	for _, alias in ipairs( aliases_list ) do									-- for each alias in the aliases list
		if alias:match ('#') then												-- if this alias can be enumerated
			if '1' == index then												-- when index is 1 test for enumerated and non-enumerated aliases
				value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);	-- first test for non-enumerated alias
			end
			value, selected = is_alias_used (args, alias, index, true, value, selected, error_list);		-- test for enumerated alias
		else
			value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);		--test for non-enumerated alias
		end
	end

	if #error_list &gt; 0 and 'none' ~= error_condition then						-- for cases where this code is used outside of extract_names()
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap_style ('parameter', k);
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap_style ('parameter', selected);
		table.insert( z.message_tail, { set_error( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end


--[=[-------------------------&lt; R E M O V E _ W I K I _ L I N K &gt;----------------------------------------------

Gets the display text from a wikilink like [[A|B]] or [[B]] gives B

]=]

local function remove_wiki_link (str)
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr)
	cfg = cfg_table_ptr;
end



return {																		-- return exported functions and tables
	is_set = is_set,
	in_array = in_array,
	substitute = substitute,
	error_comment = error_comment,
	set_error = set_error,
	select_one = select_one,
	add_maint_cat = add_maint_cat,
	wrap_style = wrap_style;
	safe_for_italics = safe_for_italics;
	remove_wiki_link = remove_wiki_link;
	set_selected_modules = set_selected_modules;
	z = z,
	}</text>
      <sha1>m8ojanpl403qdkc0wvbyskl5ce5hpxl</sha1>
    </revision>
    <revision>
      <id>4950</id>
      <parentid>4949</parentid>
      <timestamp>2016-07-14T22:01:43Z</timestamp>
      <contributor>
        <username>Redrose64</username>
        <id>813</id>
      </contributor>
      <comment>this kind of markup is no longer allowed, and puts pages in [[Category:Pages using invalid self-closed HTML tags]]</comment>
      <origin>4950</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="11004" sha1="pvch8640xcg83okjfikzjpcsn9567i3" xml:space="preserve">local u = {}

local z = {
	error_categories = {};														-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};														-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};														-- for categorizing citations based on certain properties, language of source for instance
};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local cfg;																		-- table of tables imported from slected Module:Citation/CS1/Configuration


--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.
This function is global because it is called from both this module and from Date validation

]]
local function is_set( var )
	return not (var == nil or var == '');
end


--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end


--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end


--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]
local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end


--[[--------------------------&lt; S E T _ E R R O R &gt;--------------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

]]
local function set_error( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );
	
	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if in_array( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return error_comment( message, error_state.hidden );
end


--[[-------------------------&lt; I S _ A L I A S _ U S E D &gt;-----------------------------------------------------

This function is used by select_one() to determine if one of a list of alias parameters is in the argument list
provided by the template.

Input:
	args – pointer to the arguments table from calling template
	alias – one of the list of possible aliases in the aliases lists from Module:Citation/CS1/Configuration
	index – for enumerated parameters, identifies which one
	enumerated – true/false flag used choose how enumerated aliases are examined
	value – value associated with an alias that has previously been selected; nil if not yet selected
	selected – the alias that has previously been selected; nil if not yet selected
	error_list – list of aliases that are duplicates of the alias already selected

Returns:
	value – value associated with alias we selected or that was previously selected or nil if an alias not yet selected
	selected – the alias we selected or the alias that was previously selected or nil if an alias not yet selected

]]

local function is_alias_used (args, alias, index, enumerated, value, selected, error_list)
	if enumerated then															-- is this a test for an enumerated parameters?
		alias = alias:gsub ('#', index);										-- replace '#' with the value in index
	else
		alias = alias:gsub ('#', '');											-- remove '#' if it exists
	end

	if is_set(args[alias]) then													-- alias is in the template's argument list
		if value ~= nil and selected ~= alias then								-- if we have already selected one of the aliases
			local skip;
			for _, v in ipairs(error_list) do									-- spin through the error list to see if we've added this alias
				if v == alias then
					skip = true;
					break;														-- has been added so stop looking 
				end
			end
			if not skip then													-- has not been added so
				table.insert( error_list, alias );								-- add error alias to the error list
			end
		else
			value = args[alias];												-- not yet selected an alias, so select this one
			selected = alias;
		end
	end
	return value, selected;														-- return newly selected alias, or previously selected alias
end


--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maintenance_cats using names from the configuration file with additional text if any.
To prevent duplication, the added_maint_cats table lists the categories by key that have been added to z.maintenance_cats.

]]

local added_maint_cats = {}														-- list of maintenance categories that have been added to z.maintenance_cats
local function add_maint_cat (key, arguments)
	if not added_maint_cats [key] then
		added_maint_cats [key] = true;											-- note that we've added this category
		table.insert( z.maintenance_cats, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
	end
end


--[[--------------------------&lt; S A F E _ F O R _ I T A L I C S &gt;----------------------------------------------

Protects a string that will be wrapped in wiki italic markup '' ... ''

Note: We cannot use &lt;i&gt; for italics, as the expected behavior for italics specified by ''...'' in the title is that
they will be inverted (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and '' tend to interact
poorly under Mediawiki's HTML tidy.

]]

local function safe_for_italics( str )
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span&gt;&lt;/span&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span&gt;&lt;/span&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end


--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

local function wrap_style (key, str)
	if not is_set( str ) then
		return &quot;&quot;;
	elseif in_array( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safe_for_italics( str );
	end

	return substitute( cfg.presentation[key], {str} );
end


--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider.  The list of parameters to consider is just
names.  For parameters that may be enumerated, the position of the numerator in the parameter name is identified
by the '#' so |author-last1= and |author1-last= are represented as 'author-last#' and 'author#-last'.

Because enumerated parameter |&lt;param&gt;1= is an alias of |&lt;param&gt;= we must test for both possibilities.


Generates an error if more than one match is present.

]]

local function select_one( args, aliases_list, error_condition, index )
	local value = nil;															-- the value assigned to the selected parameter
	local selected = '';														-- the name of the parameter we have chosen
	local error_list = {};

	if index ~= nil then index = tostring(index); end

	for _, alias in ipairs( aliases_list ) do									-- for each alias in the aliases list
		if alias:match ('#') then												-- if this alias can be enumerated
			if '1' == index then												-- when index is 1 test for enumerated and non-enumerated aliases
				value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);	-- first test for non-enumerated alias
			end
			value, selected = is_alias_used (args, alias, index, true, value, selected, error_list);		-- test for enumerated alias
		else
			value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);		--test for non-enumerated alias
		end
	end

	if #error_list &gt; 0 and 'none' ~= error_condition then						-- for cases where this code is used outside of extract_names()
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap_style ('parameter', k);
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap_style ('parameter', selected);
		table.insert( z.message_tail, { set_error( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end


--[=[-------------------------&lt; R E M O V E _ W I K I _ L I N K &gt;----------------------------------------------

Gets the display text from a wikilink like [[A|B]] or [[B]] gives B

]=]

local function remove_wiki_link (str)
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr)
	cfg = cfg_table_ptr;
end



return {																		-- return exported functions and tables
	is_set = is_set,
	in_array = in_array,
	substitute = substitute,
	error_comment = error_comment,
	set_error = set_error,
	select_one = select_one,
	add_maint_cat = add_maint_cat,
	wrap_style = wrap_style;
	safe_for_italics = safe_for_italics;
	remove_wiki_link = remove_wiki_link;
	set_selected_modules = set_selected_modules;
	z = z,
	}</text>
      <sha1>pvch8640xcg83okjfikzjpcsn9567i3</sha1>
    </revision>
    <revision>
      <id>4951</id>
      <parentid>4950</parentid>
      <timestamp>2017-11-04T10:41:15Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>synch from sandbox;</comment>
      <origin>4951</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="13878" sha1="paqzmjiy0g42xcm0br82k5z9jczlnm6" xml:space="preserve">local u = {}

local z = {
	error_categories = {};														-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};														-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};														-- for categorizing citations based on certain properties, language of source for instance
};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local cfg;																		-- table of tables imported from selected Module:Citation/CS1/Configuration


--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.

]]

local function is_set( var )
	return not (var == nil or var == '');
end


--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end


--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end


--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]

local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end


--[=[-------------------------&lt; M A K E _ W I K I L I N K &gt;----------------------------------------------------

Makes a wikilink; when bot link and display text is provided, returns a wikilink in the form [[L|D]]; if only
link is provided, returns a wikilink in the form [[L]]; if neither are provided or link is omitted, returns an
empty string.

]=]

local function make_wikilink (link, display)
	if is_set (link) then
		if is_set (display) then
			return table.concat ({'[[', link, '|', display, ']]'});
		else
			return table.concat ({'[[', link, ']]'});
		end
	else
		return '';
	end
end


--[[--------------------------&lt; S E T _ E R R O R &gt;--------------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

]]

local function set_error( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );								-- because missing error handler in Module:Citation/CS1/Configuration
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );

	message = table.concat (
		{
		message,
		' (',
		make_wikilink (
			table.concat (
				{
				cfg.messages['help page link'],
				'#',
				error_state.anchor
				}),
			cfg.messages['help page label']),
		')'
		});

--	message = table.concat ({message, ' (', substitute (cfg.presentation['wikilink'], 
--		{cfg.messages['help page link'] .. '#' .. error_state.anchor, cfg.messages['help page label']}), ')'});
--	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
--		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
--		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if in_array( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return error_comment( message, error_state.hidden );
end


--[[-------------------------&lt; I S _ A L I A S _ U S E D &gt;-----------------------------------------------------

This function is used by select_one() to determine if one of a list of alias parameters is in the argument list
provided by the template.

Input:
	args – pointer to the arguments table from calling template
	alias – one of the list of possible aliases in the aliases lists from Module:Citation/CS1/Configuration
	index – for enumerated parameters, identifies which one
	enumerated – true/false flag used choose how enumerated aliases are examined
	value – value associated with an alias that has previously been selected; nil if not yet selected
	selected – the alias that has previously been selected; nil if not yet selected
	error_list – list of aliases that are duplicates of the alias already selected

Returns:
	value – value associated with alias we selected or that was previously selected or nil if an alias not yet selected
	selected – the alias we selected or the alias that was previously selected or nil if an alias not yet selected

]]

local function is_alias_used (args, alias, index, enumerated, value, selected, error_list)
	if enumerated then															-- is this a test for an enumerated parameters?
		alias = alias:gsub ('#', index);										-- replace '#' with the value in index
	else
		alias = alias:gsub ('#', '');											-- remove '#' if it exists
	end

	if is_set(args[alias]) then													-- alias is in the template's argument list
		if value ~= nil and selected ~= alias then								-- if we have already selected one of the aliases
			local skip;
			for _, v in ipairs(error_list) do									-- spin through the error list to see if we've added this alias
				if v == alias then
					skip = true;
					break;														-- has been added so stop looking 
				end
			end
			if not skip then													-- has not been added so
				table.insert( error_list, alias );								-- add error alias to the error list
			end
		else
			value = args[alias];												-- not yet selected an alias, so select this one
			selected = alias;
		end
	end
	return value, selected;														-- return newly selected alias, or previously selected alias
end


--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maintenance_cats using names from the configuration file with additional text if any.
To prevent duplication, the added_maint_cats table lists the categories by key that have been added to z.maintenance_cats.

]]

local added_maint_cats = {}														-- list of maintenance categories that have been added to z.maintenance_cats
local function add_maint_cat (key, arguments)
	if not added_maint_cats [key] then
		added_maint_cats [key] = true;											-- note that we've added this category
		table.insert( z.maintenance_cats, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
	end
end


--[[--------------------------&lt; S A F E _ F O R _ I T A L I C S &gt;----------------------------------------------

Protects a string that will be wrapped in wiki italic markup '' ... ''

Note: We cannot use &lt;i&gt; for italics, as the expected behavior for italics specified by ''...'' in the title is that
they will be inverted (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and '' tend to interact
poorly under Mediawiki's HTML tidy.

]]

local function safe_for_italics( str )
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span&gt;&lt;/span&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span&gt;&lt;/span&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end


--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

local function wrap_style (key, str)
	if not is_set( str ) then
		return &quot;&quot;;
	elseif in_array( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safe_for_italics( str );
	end

	return substitute( cfg.presentation[key], {str} );
end


--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider.  The list of parameters to consider is just
names.  For parameters that may be enumerated, the position of the numerator in the parameter name is identified
by the '#' so |author-last1= and |author1-last= are represented as 'author-last#' and 'author#-last'.

Because enumerated parameter |&lt;param&gt;1= is an alias of |&lt;param&gt;= we must test for both possibilities.


Generates an error if more than one match is present.

]]

local function select_one( args, aliases_list, error_condition, index )
	local value = nil;															-- the value assigned to the selected parameter
	local selected = '';														-- the name of the parameter we have chosen
	local error_list = {};

	if index ~= nil then index = tostring(index); end

	for _, alias in ipairs( aliases_list ) do									-- for each alias in the aliases list
		if alias:match ('#') then												-- if this alias can be enumerated
			if '1' == index then												-- when index is 1 test for enumerated and non-enumerated aliases
				value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);	-- first test for non-enumerated alias
			end
			value, selected = is_alias_used (args, alias, index, true, value, selected, error_list);		-- test for enumerated alias
		else
			value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);		--test for non-enumerated alias
		end
	end

	if #error_list &gt; 0 and 'none' ~= error_condition then						-- for cases where this code is used outside of extract_names()
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap_style ('parameter', k);
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap_style ('parameter', selected);
		table.insert( z.message_tail, { set_error( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end


--[=[-------------------------&lt; R E M O V E _ W I K I _ L I N K &gt;----------------------------------------------

Gets the display text from a wikilink like [[A|B]] or [[B]] gives B

The str:gsub() returns either A|B froma [[A|B]] or B from [[B]] or B from B (no wikilink markup).

In l(), l:gsub() removes the link and pipe (if they exist); the second :gsub() trims white space from the label
if str was wrapped in wikilink markup.  Presumably, this is because without wikimarkup in str, there is no match
in the initial gsub, the replacement function l() doesn't get called.

]=]

local function remove_wiki_link (str)
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end


--[=[-------------------------&lt; I S _ W I K I L I N K &gt;--------------------------------------------------------

Determines if str is a wikilink, extracts, and returns the the wikilink type, link text, and display text parts.
If str is a complex wikilink ([[L|D]]):
	returns wl_type 2 and D and L from [[L|D]];
if str is a simple wikilink ([[D]])
	returns wl_type 1 and D from [[D]] and L as empty string;
if not a wikilink:
	returns wl_type 0, str as D, and L as empty string.

trims leading and trailing white space and pipes from L and D ([[L|]] and [[|D]] are accepted by MediaWiki and
treated like [[D]]; while [[|D|]] is not accepted by MediaWiki, here, we accept it and return D without the pipes).

]=]

local function is_wikilink (str)
	local D, L
	local wl_type = 2;															-- assume that str is a complex wikilink [[L|D]]

	L, D = str:match ('%[%[([^|]+)|([^%]]+)%]%]');								-- get L and D from [[L|D]] 

	if not is_set (D) then														-- if no separate link
		D = str:match ('%[%[([^%]]*)|*%]%]');									-- get D from [[D]]
		wl_type = 1; 
	end
	
	if not is_set (D) then														-- no wikilink markup
		D = str;																-- return the string as D
		wl_type = 0;															-- but say that it is not a wikilink
	end
	
	D = mw.text.trim (D, '%s|');												-- trim white space and pipe characters 
	L = L and mw.text.trim (L, '%s|');
	
	return wl_type, D, L or '';
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr)
	cfg = cfg_table_ptr;
	
end



return {																		-- return exported functions and tables
	is_set = is_set,
	in_array = in_array,
	substitute = substitute,
	error_comment = error_comment,
	set_error = set_error,
	select_one = select_one,
	add_maint_cat = add_maint_cat,
	wrap_style = wrap_style,
	safe_for_italics = safe_for_italics,
	remove_wiki_link = remove_wiki_link,
	is_wikilink = is_wikilink,
	make_wikilink = make_wikilink,
	set_selected_modules = set_selected_modules,
	z = z,
	}</text>
      <sha1>paqzmjiy0g42xcm0br82k5z9jczlnm6</sha1>
    </revision>
    <revision>
      <id>4952</id>
      <parentid>4951</parentid>
      <timestamp>2019-04-20T13:20:10Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4952</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="13994" sha1="5mdp5hoi03nwh7wo1em9uavtniuxlo8" xml:space="preserve">
local z = {
	error_categories = {};														-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};														-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};														-- for categorizing citations based on certain properties, language of source for instance
};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local cfg;																		-- table of tables imported from selected Module:Citation/CS1/Configuration


--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.

]]

local function is_set( var )
	return not (var == nil or var == '');
end


--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end


--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end


--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]

local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end


--[=[-------------------------&lt; M A K E _ W I K I L I N K &gt;----------------------------------------------------

Makes a wikilink; when bot link and display text is provided, returns a wikilink in the form [[L|D]]; if only
link is provided, returns a wikilink in the form [[L]]; if neither are provided or link is omitted, returns an
empty string.

]=]

local function make_wikilink (link, display)
	if is_set (link) then
		if is_set (display) then
			return table.concat ({'[[', link, '|', display, ']]'});
		else
			return table.concat ({'[[', link, ']]'});
		end
	else
		return '';
	end
end


--[[--------------------------&lt; S E T _ E R R O R &gt;--------------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

]]

local function set_error( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );								-- because missing error handler in Module:Citation/CS1/Configuration
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );

	message = table.concat (
		{
		message,
		' (',
		make_wikilink (
			table.concat (
				{
				cfg.messages['help page link'],
				'#',
				error_state.anchor
				}),
			cfg.messages['help page label']),
		')'
		});

--	message = table.concat ({message, ' (', substitute (cfg.presentation['wikilink'], 
--		{cfg.messages['help page link'] .. '#' .. error_state.anchor, cfg.messages['help page label']}), ')'});
--	message = message .. &quot; ([[&quot; .. cfg.messages['help page link'] .. 
--		&quot;#&quot; .. error_state.anchor .. &quot;|&quot; ..
--		cfg.messages['help page label'] .. &quot;]])&quot;;
	
	z.error_ids[ error_id ] = true;
	if in_array( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return error_comment( message, error_state.hidden );
end


--[[-------------------------&lt; I S _ A L I A S _ U S E D &gt;-----------------------------------------------------

This function is used by select_one() to determine if one of a list of alias parameters is in the argument list
provided by the template.

Input:
	args – pointer to the arguments table from calling template
	alias – one of the list of possible aliases in the aliases lists from Module:Citation/CS1/Configuration
	index – for enumerated parameters, identifies which one
	enumerated – true/false flag used choose how enumerated aliases are examined
	value – value associated with an alias that has previously been selected; nil if not yet selected
	selected – the alias that has previously been selected; nil if not yet selected
	error_list – list of aliases that are duplicates of the alias already selected

Returns:
	value – value associated with alias we selected or that was previously selected or nil if an alias not yet selected
	selected – the alias we selected or the alias that was previously selected or nil if an alias not yet selected

]]

local function is_alias_used (args, alias, index, enumerated, value, selected, error_list)
	if enumerated then															-- is this a test for an enumerated parameters?
		alias = alias:gsub ('#', index);										-- replace '#' with the value in index
	else
		alias = alias:gsub ('#', '');											-- remove '#' if it exists
	end

	if is_set(args[alias]) then													-- alias is in the template's argument list
		if value ~= nil and selected ~= alias then								-- if we have already selected one of the aliases
			local skip;
			for _, v in ipairs(error_list) do									-- spin through the error list to see if we've added this alias
				if v == alias then
					skip = true;
					break;														-- has been added so stop looking 
				end
			end
			if not skip then													-- has not been added so
				table.insert( error_list, alias );								-- add error alias to the error list
			end
		else
			value = args[alias];												-- not yet selected an alias, so select this one
			selected = alias;
		end
	end
	return value, selected;														-- return newly selected alias, or previously selected alias
end


--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maintenance_cats using names from the configuration file with additional text if any.
To prevent duplication, the added_maint_cats table lists the categories by key that have been added to z.maintenance_cats.

]]

local added_maint_cats = {}														-- list of maintenance categories that have been added to z.maintenance_cats
local function add_maint_cat (key, arguments)
	if not added_maint_cats [key] then
		added_maint_cats [key] = true;											-- note that we've added this category
		table.insert( z.maintenance_cats, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
	end
end


--[[--------------------------&lt; S A F E _ F O R _ I T A L I C S &gt;----------------------------------------------

Protects a string that will be wrapped in wiki italic markup '' ... ''

Note: We cannot use &lt;i&gt; for italics, as the expected behavior for italics specified by ''...'' in the title is that
they will be inverted (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and '' tend to interact
poorly under Mediawiki's HTML tidy.

]]

local function safe_for_italics( str )
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span&gt;&lt;/span&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span&gt;&lt;/span&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end


--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

local function wrap_style (key, str)
	if not is_set( str ) then
		return &quot;&quot;;
	elseif in_array( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safe_for_italics( str );
	end

	return substitute( cfg.presentation[key], {str} );
end


--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider.  The list of parameters to consider is just
names.  For parameters that may be enumerated, the position of the numerator in the parameter name is identified
by the '#' so |author-last1= and |author1-last= are represented as 'author-last#' and 'author#-last'.

Because enumerated parameter |&lt;param&gt;1= is an alias of |&lt;param&gt;= we must test for both possibilities.


Generates an error if more than one match is present.

]]

local function select_one( args, aliases_list, error_condition, index )
	local value = nil;															-- the value assigned to the selected parameter
	local selected = '';														-- the name of the parameter we have chosen
	local error_list = {};

	if index ~= nil then index = tostring(index); end

	for _, alias in ipairs( aliases_list ) do									-- for each alias in the aliases list
		if alias:match ('#') then												-- if this alias can be enumerated
			if '1' == index then												-- when index is 1 test for enumerated and non-enumerated aliases
				value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);	-- first test for non-enumerated alias
			end
			value, selected = is_alias_used (args, alias, index, true, value, selected, error_list);		-- test for enumerated alias
		else
			value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);		--test for non-enumerated alias
		end
	end

	if #error_list &gt; 0 and 'none' ~= error_condition then						-- for cases where this code is used outside of extract_names()
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap_style ('parameter', k);
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap_style ('parameter', selected);
		table.insert( z.message_tail, { set_error( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end


--[=[-------------------------&lt; R E M O V E _ W I K I _ L I N K &gt;----------------------------------------------

Gets the display text from a wikilink like [[A|B]] or [[B]] gives B

The str:gsub() returns either A|B froma [[A|B]] or B from [[B]] or B from B (no wikilink markup).

In l(), l:gsub() removes the link and pipe (if they exist); the second :gsub() trims white space from the label
if str was wrapped in wikilink markup.  Presumably, this is because without wikimarkup in str, there is no match
in the initial gsub, the replacement function l() doesn't get called.

]=]

local function remove_wiki_link (str)
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end


--[=[-------------------------&lt; I S _ W I K I L I N K &gt;--------------------------------------------------------

Determines if str is a wikilink, extracts, and returns the the wikilink type, link text, and display text parts.
If str is a complex wikilink ([[L|D]]):
	returns wl_type 2 and D and L from [[L|D]];
if str is a simple wikilink ([[D]])
	returns wl_type 1 and D from [[D]] and L as empty string;
if not a wikilink:
	returns wl_type 0, str as D, and L as empty string.

trims leading and trailing white space and pipes from L and D ([[L|]] and [[|D]] are accepted by MediaWiki and
treated like [[D]]; while [[|D|]] is not accepted by MediaWiki, here, we accept it and return D without the pipes).

]=]

local function is_wikilink (str)
	local D, L
	local wl_type = 2;															-- assume that str is a complex wikilink [[L|D]]

	L, D = str:match ('%[%[([^|]+)|([^%]]+)%]%]');								-- get L and D from [[L|D]] 

	if not is_set (D) then														-- if no separate link
		D = str:match ('%[%[([^%]]*)|*%]%]');									-- get D from [[D]]
		wl_type = 1; 
	end
	
	if not is_set (D) then														-- no wikilink markup
		D = str;																-- return the string as D
		wl_type = 0;															-- but say that it is not a wikilink
	end
	
	D = mw.text.trim (D, '%s|');												-- trim white space and pipe characters 
	L = L and mw.text.trim (L, '%s|');
	
	return wl_type, D, L or '';
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr)
	cfg = cfg_table_ptr;
	
end


--[[--------------------------&lt; E X P O R T S &gt;----------------------------------------------------------------
]]

return {
	is_set = is_set,															-- exported functions
	in_array = in_array,
	substitute = substitute,
	error_comment = error_comment,
	set_error = set_error,
	select_one = select_one,
	add_maint_cat = add_maint_cat,
	wrap_style = wrap_style,
	safe_for_italics = safe_for_italics,
	remove_wiki_link = remove_wiki_link,
	is_wikilink = is_wikilink,
	make_wikilink = make_wikilink,
	set_selected_modules = set_selected_modules,
	z = z,																		-- exported table
	}</text>
      <sha1>5mdp5hoi03nwh7wo1em9uavtniuxlo8</sha1>
    </revision>
    <revision>
      <id>4953</id>
      <parentid>4952</parentid>
      <timestamp>2019-09-03T11:05:52Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4953</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="15353" sha1="3ip0nyncv5q3w1ip0l9y5jzifvqvcf6" xml:space="preserve">
local z = {
	error_categories = {};														-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};														-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};														-- for categorizing citations based on certain properties, language of source for instance
};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local cfg;																		-- table of tables imported from selected Module:Citation/CS1/Configuration


--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.

]]

local function is_set( var )
	return not (var == nil or var == '');
end


--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end


--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end


--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]

local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end


--[=[-------------------------&lt; M A K E _ W I K I L I N K &gt;----------------------------------------------------

Makes a wikilink; when bot link and display text is provided, returns a wikilink in the form [[L|D]]; if only
link is provided, returns a wikilink in the form [[L]]; if neither are provided or link is omitted, returns an
empty string.

]=]

local function make_wikilink (link, display)
	if is_set (link) then
		if is_set (display) then
			return table.concat ({'[[', link, '|', display, ']]'});
		else
			return table.concat ({'[[', link, ']]'});
		end
	else
		return '';
	end
end


--[[--------------------------&lt; S E T _ E R R O R &gt;--------------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

]]

local function set_error( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );								-- because missing error handler in Module:Citation/CS1/Configuration
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );

	message = table.concat (
		{
		message,
		' (',
		make_wikilink (
			table.concat (
				{
				cfg.messages['help page link'],
				'#',
				error_state.anchor
				}),
			cfg.messages['help page label']),
		')'
		});

	z.error_ids[ error_id ] = true;
	if in_array( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return error_comment( message, error_state.hidden );
end


--[[-------------------------&lt; I S _ A L I A S _ U S E D &gt;-----------------------------------------------------

This function is used by select_one() to determine if one of a list of alias parameters is in the argument list
provided by the template.

Input:
	args – pointer to the arguments table from calling template
	alias – one of the list of possible aliases in the aliases lists from Module:Citation/CS1/Configuration
	index – for enumerated parameters, identifies which one
	enumerated – true/false flag used choose how enumerated aliases are examined
	value – value associated with an alias that has previously been selected; nil if not yet selected
	selected – the alias that has previously been selected; nil if not yet selected
	error_list – list of aliases that are duplicates of the alias already selected

Returns:
	value – value associated with alias we selected or that was previously selected or nil if an alias not yet selected
	selected – the alias we selected or the alias that was previously selected or nil if an alias not yet selected

]]

local function is_alias_used (args, alias, index, enumerated, value, selected, error_list)
	if enumerated then															-- is this a test for an enumerated parameters?
		alias = alias:gsub ('#', index);										-- replace '#' with the value in index
	else
		alias = alias:gsub ('#', '');											-- remove '#' if it exists
	end

	if is_set(args[alias]) then													-- alias is in the template's argument list
		if value ~= nil and selected ~= alias then								-- if we have already selected one of the aliases
			local skip;
			for _, v in ipairs(error_list) do									-- spin through the error list to see if we've added this alias
				if v == alias then
					skip = true;
					break;														-- has been added so stop looking 
				end
			end
			if not skip then													-- has not been added so
				table.insert( error_list, alias );								-- add error alias to the error list
			end
		else
			value = args[alias];												-- not yet selected an alias, so select this one
			selected = alias;
		end
	end
	return value, selected;														-- return newly selected alias, or previously selected alias
end


--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maintenance_cats using names from the configuration file with additional text if any.
To prevent duplication, the added_maint_cats table lists the categories by key that have been added to z.maintenance_cats.

]]

local added_maint_cats = {}														-- list of maintenance categories that have been added to z.maintenance_cats
local function add_maint_cat (key, arguments)
	if not added_maint_cats [key] then
		added_maint_cats [key] = true;											-- note that we've added this category
		table.insert( z.maintenance_cats, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
	end
end


--[[--------------------------&lt; S A F E _ F O R _ I T A L I C S &gt;----------------------------------------------

Protects a string that will be wrapped in wiki italic markup '' ... ''

Note: We cannot use &lt;i&gt; for italics, as the expected behavior for italics specified by ''...'' in the title is that
they will be inverted (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and '' tend to interact
poorly under Mediawiki's HTML tidy.

]]

local function safe_for_italics( str )
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span&gt;&lt;/span&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span&gt;&lt;/span&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end


--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

local function wrap_style (key, str)
	if not is_set( str ) then
		return &quot;&quot;;
	elseif in_array( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safe_for_italics( str );
	end

	return substitute( cfg.presentation[key], {str} );
end


--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider.  The list of parameters to consider is just
names.  For parameters that may be enumerated, the position of the numerator in the parameter name is identified
by the '#' so |author-last1= and |author1-last= are represented as 'author-last#' and 'author#-last'.

Because enumerated parameter |&lt;param&gt;1= is an alias of |&lt;param&gt;= we must test for both possibilities.


Generates an error if more than one match is present.

]]

local function select_one( args, aliases_list, error_condition, index )
	local value = nil;															-- the value assigned to the selected parameter
	local selected = '';														-- the name of the parameter we have chosen
	local error_list = {};

	if index ~= nil then index = tostring(index); end

	for _, alias in ipairs( aliases_list ) do									-- for each alias in the aliases list
		if alias:match ('#') then												-- if this alias can be enumerated
			if '1' == index then												-- when index is 1 test for enumerated and non-enumerated aliases
				value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);	-- first test for non-enumerated alias
			end
			value, selected = is_alias_used (args, alias, index, true, value, selected, error_list);		-- test for enumerated alias
		else
			value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);		--test for non-enumerated alias
		end
	end

	if #error_list &gt; 0 and 'none' ~= error_condition then						-- for cases where this code is used outside of extract_names()
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap_style ('parameter', k);
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap_style ('parameter', selected);
		table.insert( z.message_tail, { set_error( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end


--[=[-------------------------&lt; R E M O V E _ W I K I _ L I N K &gt;----------------------------------------------

Gets the display text from a wikilink like [[A|B]] or [[B]] gives B

The str:gsub() returns either A|B froma [[A|B]] or B from [[B]] or B from B (no wikilink markup).

In l(), l:gsub() removes the link and pipe (if they exist); the second :gsub() trims white space from the label
if str was wrapped in wikilink markup.  Presumably, this is because without wikimarkup in str, there is no match
in the initial gsub, the replacement function l() doesn't get called.

]=]

local function remove_wiki_link (str)
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end


--[=[-------------------------&lt; I S _ W I K I L I N K &gt;--------------------------------------------------------

Determines if str is a wikilink, extracts, and returns the the wikilink type, link text, and display text parts.
If str is a complex wikilink ([[L|D]]):
	returns wl_type 2 and D and L from [[L|D]];
if str is a simple wikilink ([[D]])
	returns wl_type 1 and D from [[D]] and L as empty string;
if not a wikilink:
	returns wl_type 0, str as D, and L as empty string.

trims leading and trailing white space and pipes from L and D ([[L|]] and [[|D]] are accepted by MediaWiki and
treated like [[D]]; while [[|D|]] is not accepted by MediaWiki, here, we accept it and return D without the pipes).

]=]

local function is_wikilink (str)
	local D, L
	local wl_type = 2;															-- assume that str is a complex wikilink [[L|D]]

	L, D = str:match ('^%[%[([^|]+)|([^%]]+)%]%]$');							-- get L and D from [[L|D]] 

	if not is_set (D) then														-- if no separate link
		D = str:match ('^%[%[([^%]]*)|*%]%]$');									-- get D from [[D]]
		wl_type = 1; 
	end
	
	if not is_set (D) then														-- no wikilink markup
		D = str;																-- return the string as D
		wl_type = 0;															-- but say that it is not a wikilink
	end
	
	D = mw.text.trim (D, '%s|');												-- trim white space and pipe characters 
	L = L and mw.text.trim (L, '%s|');
	
	return wl_type, D, L or '';
end


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

Returns the argument without wiki markup and a number; the number is more-or-less meaningless except as a flag
to indicate that markup was replaced; do not rely on it as an indicator of how many of any kind of markup was
removed; returns the argument and nil when no markup removed

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then
		return argument, nil;													-- no argument, nothing to do
	end

	if nil == argument:find ( &quot;''&quot;, 1, true ) then								-- Is there at least one double apostrophe?  If not, exit.
		return argument, nil;
	end

	local flag;
	while true do
		if argument:find ( &quot;'''''&quot;, 1, true ) then								-- bold italic (5)
			argument, flag=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);						-- remove all instances of it
		elseif argument:find ( &quot;''''&quot;, 1, true ) then							-- italic start and end without content (4)
			argument, flag=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;'''&quot;, 1, true ) then							-- bold (3)
			argument, flag=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;''&quot;, 1, true ) then								-- italic (2)
			argument, flag=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end

	return argument, flag;														-- done
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr)
	cfg = cfg_table_ptr;
	
end


--[[--------------------------&lt; E X P O R T S &gt;----------------------------------------------------------------
]]

return {
	is_set = is_set,															-- exported functions
	in_array = in_array,
	substitute = substitute,
	error_comment = error_comment,
	set_error = set_error,
	select_one = select_one,
	add_maint_cat = add_maint_cat,
	wrap_style = wrap_style,
	safe_for_italics = safe_for_italics,
	remove_wiki_link = remove_wiki_link,
	is_wikilink = is_wikilink,
	make_wikilink = make_wikilink,
	set_selected_modules = set_selected_modules,
	strip_apostrophe_markup = strip_apostrophe_markup,
	z = z,																		-- exported table
	}</text>
      <sha1>3ip0nyncv5q3w1ip0l9y5jzifvqvcf6</sha1>
    </revision>
    <revision>
      <id>4954</id>
      <parentid>4953</parentid>
      <timestamp>2019-09-03T22:05:11Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>hide deprecated parameters error messages and hide missing periodical error messages;</comment>
      <origin>4954</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="15539" sha1="8xsukzg63wje3rgaqoqryknps275h4r" xml:space="preserve">
local z = {
	error_categories = {};														-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};														-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};														-- for categorizing citations based on certain properties, language of source for instance
};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local cfg;																		-- table of tables imported from selected Module:Citation/CS1/Configuration


--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.

]]

local function is_set( var )
	return not (var == nil or var == '');
end


--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end


--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end


--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]

local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end


--[=[-------------------------&lt; M A K E _ W I K I L I N K &gt;----------------------------------------------------

Makes a wikilink; when bot link and display text is provided, returns a wikilink in the form [[L|D]]; if only
link is provided, returns a wikilink in the form [[L]]; if neither are provided or link is omitted, returns an
empty string.

]=]

local function make_wikilink (link, display)
	if is_set (link) then
		if is_set (display) then
			return table.concat ({'[[', link, '|', display, ']]'});
		else
			return table.concat ({'[[', link, ']]'});
		end
	else
		return '';
	end
end


--[[--------------------------&lt; S E T _ E R R O R &gt;--------------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

]]

local function set_error( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );								-- because missing error handler in Module:Citation/CS1/Configuration
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );

if error_state.hidden then														-- hack to hide error message that are being problematic
	return;																		-- without this hidden=true isn't working; don't know why
end

	message = table.concat (
		{
		message,
		' (',
		make_wikilink (
			table.concat (
				{
				cfg.messages['help page link'],
				'#',
				error_state.anchor
				}),
			cfg.messages['help page label']),
		')'
		});

	z.error_ids[ error_id ] = true;
	if in_array( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return error_comment( message, error_state.hidden );
end


--[[-------------------------&lt; I S _ A L I A S _ U S E D &gt;-----------------------------------------------------

This function is used by select_one() to determine if one of a list of alias parameters is in the argument list
provided by the template.

Input:
	args – pointer to the arguments table from calling template
	alias – one of the list of possible aliases in the aliases lists from Module:Citation/CS1/Configuration
	index – for enumerated parameters, identifies which one
	enumerated – true/false flag used choose how enumerated aliases are examined
	value – value associated with an alias that has previously been selected; nil if not yet selected
	selected – the alias that has previously been selected; nil if not yet selected
	error_list – list of aliases that are duplicates of the alias already selected

Returns:
	value – value associated with alias we selected or that was previously selected or nil if an alias not yet selected
	selected – the alias we selected or the alias that was previously selected or nil if an alias not yet selected

]]

local function is_alias_used (args, alias, index, enumerated, value, selected, error_list)
	if enumerated then															-- is this a test for an enumerated parameters?
		alias = alias:gsub ('#', index);										-- replace '#' with the value in index
	else
		alias = alias:gsub ('#', '');											-- remove '#' if it exists
	end

	if is_set(args[alias]) then													-- alias is in the template's argument list
		if value ~= nil and selected ~= alias then								-- if we have already selected one of the aliases
			local skip;
			for _, v in ipairs(error_list) do									-- spin through the error list to see if we've added this alias
				if v == alias then
					skip = true;
					break;														-- has been added so stop looking 
				end
			end
			if not skip then													-- has not been added so
				table.insert( error_list, alias );								-- add error alias to the error list
			end
		else
			value = args[alias];												-- not yet selected an alias, so select this one
			selected = alias;
		end
	end
	return value, selected;														-- return newly selected alias, or previously selected alias
end


--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maintenance_cats using names from the configuration file with additional text if any.
To prevent duplication, the added_maint_cats table lists the categories by key that have been added to z.maintenance_cats.

]]

local added_maint_cats = {}														-- list of maintenance categories that have been added to z.maintenance_cats
local function add_maint_cat (key, arguments)
	if not added_maint_cats [key] then
		added_maint_cats [key] = true;											-- note that we've added this category
		table.insert( z.maintenance_cats, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
	end
end


--[[--------------------------&lt; S A F E _ F O R _ I T A L I C S &gt;----------------------------------------------

Protects a string that will be wrapped in wiki italic markup '' ... ''

Note: We cannot use &lt;i&gt; for italics, as the expected behavior for italics specified by ''...'' in the title is that
they will be inverted (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and '' tend to interact
poorly under Mediawiki's HTML tidy.

]]

local function safe_for_italics( str )
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span&gt;&lt;/span&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span&gt;&lt;/span&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end


--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

local function wrap_style (key, str)
	if not is_set( str ) then
		return &quot;&quot;;
	elseif in_array( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safe_for_italics( str );
	end

	return substitute( cfg.presentation[key], {str} );
end


--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider.  The list of parameters to consider is just
names.  For parameters that may be enumerated, the position of the numerator in the parameter name is identified
by the '#' so |author-last1= and |author1-last= are represented as 'author-last#' and 'author#-last'.

Because enumerated parameter |&lt;param&gt;1= is an alias of |&lt;param&gt;= we must test for both possibilities.


Generates an error if more than one match is present.

]]

local function select_one( args, aliases_list, error_condition, index )
	local value = nil;															-- the value assigned to the selected parameter
	local selected = '';														-- the name of the parameter we have chosen
	local error_list = {};

	if index ~= nil then index = tostring(index); end

	for _, alias in ipairs( aliases_list ) do									-- for each alias in the aliases list
		if alias:match ('#') then												-- if this alias can be enumerated
			if '1' == index then												-- when index is 1 test for enumerated and non-enumerated aliases
				value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);	-- first test for non-enumerated alias
			end
			value, selected = is_alias_used (args, alias, index, true, value, selected, error_list);		-- test for enumerated alias
		else
			value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);		--test for non-enumerated alias
		end
	end

	if #error_list &gt; 0 and 'none' ~= error_condition then						-- for cases where this code is used outside of extract_names()
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap_style ('parameter', k);
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap_style ('parameter', selected);
		table.insert( z.message_tail, { set_error( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end


--[=[-------------------------&lt; R E M O V E _ W I K I _ L I N K &gt;----------------------------------------------

Gets the display text from a wikilink like [[A|B]] or [[B]] gives B

The str:gsub() returns either A|B froma [[A|B]] or B from [[B]] or B from B (no wikilink markup).

In l(), l:gsub() removes the link and pipe (if they exist); the second :gsub() trims white space from the label
if str was wrapped in wikilink markup.  Presumably, this is because without wikimarkup in str, there is no match
in the initial gsub, the replacement function l() doesn't get called.

]=]

local function remove_wiki_link (str)
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end


--[=[-------------------------&lt; I S _ W I K I L I N K &gt;--------------------------------------------------------

Determines if str is a wikilink, extracts, and returns the the wikilink type, link text, and display text parts.
If str is a complex wikilink ([[L|D]]):
	returns wl_type 2 and D and L from [[L|D]];
if str is a simple wikilink ([[D]])
	returns wl_type 1 and D from [[D]] and L as empty string;
if not a wikilink:
	returns wl_type 0, str as D, and L as empty string.

trims leading and trailing white space and pipes from L and D ([[L|]] and [[|D]] are accepted by MediaWiki and
treated like [[D]]; while [[|D|]] is not accepted by MediaWiki, here, we accept it and return D without the pipes).

]=]

local function is_wikilink (str)
	local D, L
	local wl_type = 2;															-- assume that str is a complex wikilink [[L|D]]

	L, D = str:match ('^%[%[([^|]+)|([^%]]+)%]%]$');							-- get L and D from [[L|D]] 

	if not is_set (D) then														-- if no separate link
		D = str:match ('^%[%[([^%]]*)|*%]%]$');									-- get D from [[D]]
		wl_type = 1; 
	end
	
	if not is_set (D) then														-- no wikilink markup
		D = str;																-- return the string as D
		wl_type = 0;															-- but say that it is not a wikilink
	end
	
	D = mw.text.trim (D, '%s|');												-- trim white space and pipe characters 
	L = L and mw.text.trim (L, '%s|');
	
	return wl_type, D, L or '';
end


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

Returns the argument without wiki markup and a number; the number is more-or-less meaningless except as a flag
to indicate that markup was replaced; do not rely on it as an indicator of how many of any kind of markup was
removed; returns the argument and nil when no markup removed

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then
		return argument, nil;													-- no argument, nothing to do
	end

	if nil == argument:find ( &quot;''&quot;, 1, true ) then								-- Is there at least one double apostrophe?  If not, exit.
		return argument, nil;
	end

	local flag;
	while true do
		if argument:find ( &quot;'''''&quot;, 1, true ) then								-- bold italic (5)
			argument, flag=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);						-- remove all instances of it
		elseif argument:find ( &quot;''''&quot;, 1, true ) then							-- italic start and end without content (4)
			argument, flag=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;'''&quot;, 1, true ) then							-- bold (3)
			argument, flag=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;''&quot;, 1, true ) then								-- italic (2)
			argument, flag=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end

	return argument, flag;														-- done
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr)
	cfg = cfg_table_ptr;
	
end


--[[--------------------------&lt; E X P O R T S &gt;----------------------------------------------------------------
]]

return {
	is_set = is_set,															-- exported functions
	in_array = in_array,
	substitute = substitute,
	error_comment = error_comment,
	set_error = set_error,
	select_one = select_one,
	add_maint_cat = add_maint_cat,
	wrap_style = wrap_style,
	safe_for_italics = safe_for_italics,
	remove_wiki_link = remove_wiki_link,
	is_wikilink = is_wikilink,
	make_wikilink = make_wikilink,
	set_selected_modules = set_selected_modules,
	strip_apostrophe_markup = strip_apostrophe_markup,
	z = z,																		-- exported table
	}</text>
      <sha1>8xsukzg63wje3rgaqoqryknps275h4r</sha1>
    </revision>
    <revision>
      <id>4955</id>
      <parentid>4954</parentid>
      <timestamp>2019-09-04T14:45:24Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>undo brute force hiding of deprecated parameter and missing periodical error messages;</comment>
      <origin>4955</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="15353" sha1="3ip0nyncv5q3w1ip0l9y5jzifvqvcf6" xml:space="preserve">
local z = {
	error_categories = {};														-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};														-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};														-- for categorizing citations based on certain properties, language of source for instance
};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local cfg;																		-- table of tables imported from selected Module:Citation/CS1/Configuration


--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.

]]

local function is_set( var )
	return not (var == nil or var == '');
end


--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end


--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end


--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]

local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end


--[=[-------------------------&lt; M A K E _ W I K I L I N K &gt;----------------------------------------------------

Makes a wikilink; when bot link and display text is provided, returns a wikilink in the form [[L|D]]; if only
link is provided, returns a wikilink in the form [[L]]; if neither are provided or link is omitted, returns an
empty string.

]=]

local function make_wikilink (link, display)
	if is_set (link) then
		if is_set (display) then
			return table.concat ({'[[', link, '|', display, ']]'});
		else
			return table.concat ({'[[', link, ']]'});
		end
	else
		return '';
	end
end


--[[--------------------------&lt; S E T _ E R R O R &gt;--------------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

]]

local function set_error( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );								-- because missing error handler in Module:Citation/CS1/Configuration
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );

	message = table.concat (
		{
		message,
		' (',
		make_wikilink (
			table.concat (
				{
				cfg.messages['help page link'],
				'#',
				error_state.anchor
				}),
			cfg.messages['help page label']),
		')'
		});

	z.error_ids[ error_id ] = true;
	if in_array( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return error_comment( message, error_state.hidden );
end


--[[-------------------------&lt; I S _ A L I A S _ U S E D &gt;-----------------------------------------------------

This function is used by select_one() to determine if one of a list of alias parameters is in the argument list
provided by the template.

Input:
	args – pointer to the arguments table from calling template
	alias – one of the list of possible aliases in the aliases lists from Module:Citation/CS1/Configuration
	index – for enumerated parameters, identifies which one
	enumerated – true/false flag used choose how enumerated aliases are examined
	value – value associated with an alias that has previously been selected; nil if not yet selected
	selected – the alias that has previously been selected; nil if not yet selected
	error_list – list of aliases that are duplicates of the alias already selected

Returns:
	value – value associated with alias we selected or that was previously selected or nil if an alias not yet selected
	selected – the alias we selected or the alias that was previously selected or nil if an alias not yet selected

]]

local function is_alias_used (args, alias, index, enumerated, value, selected, error_list)
	if enumerated then															-- is this a test for an enumerated parameters?
		alias = alias:gsub ('#', index);										-- replace '#' with the value in index
	else
		alias = alias:gsub ('#', '');											-- remove '#' if it exists
	end

	if is_set(args[alias]) then													-- alias is in the template's argument list
		if value ~= nil and selected ~= alias then								-- if we have already selected one of the aliases
			local skip;
			for _, v in ipairs(error_list) do									-- spin through the error list to see if we've added this alias
				if v == alias then
					skip = true;
					break;														-- has been added so stop looking 
				end
			end
			if not skip then													-- has not been added so
				table.insert( error_list, alias );								-- add error alias to the error list
			end
		else
			value = args[alias];												-- not yet selected an alias, so select this one
			selected = alias;
		end
	end
	return value, selected;														-- return newly selected alias, or previously selected alias
end


--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maintenance_cats using names from the configuration file with additional text if any.
To prevent duplication, the added_maint_cats table lists the categories by key that have been added to z.maintenance_cats.

]]

local added_maint_cats = {}														-- list of maintenance categories that have been added to z.maintenance_cats
local function add_maint_cat (key, arguments)
	if not added_maint_cats [key] then
		added_maint_cats [key] = true;											-- note that we've added this category
		table.insert( z.maintenance_cats, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
	end
end


--[[--------------------------&lt; S A F E _ F O R _ I T A L I C S &gt;----------------------------------------------

Protects a string that will be wrapped in wiki italic markup '' ... ''

Note: We cannot use &lt;i&gt; for italics, as the expected behavior for italics specified by ''...'' in the title is that
they will be inverted (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and '' tend to interact
poorly under Mediawiki's HTML tidy.

]]

local function safe_for_italics( str )
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span&gt;&lt;/span&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span&gt;&lt;/span&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end


--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

local function wrap_style (key, str)
	if not is_set( str ) then
		return &quot;&quot;;
	elseif in_array( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safe_for_italics( str );
	end

	return substitute( cfg.presentation[key], {str} );
end


--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider.  The list of parameters to consider is just
names.  For parameters that may be enumerated, the position of the numerator in the parameter name is identified
by the '#' so |author-last1= and |author1-last= are represented as 'author-last#' and 'author#-last'.

Because enumerated parameter |&lt;param&gt;1= is an alias of |&lt;param&gt;= we must test for both possibilities.


Generates an error if more than one match is present.

]]

local function select_one( args, aliases_list, error_condition, index )
	local value = nil;															-- the value assigned to the selected parameter
	local selected = '';														-- the name of the parameter we have chosen
	local error_list = {};

	if index ~= nil then index = tostring(index); end

	for _, alias in ipairs( aliases_list ) do									-- for each alias in the aliases list
		if alias:match ('#') then												-- if this alias can be enumerated
			if '1' == index then												-- when index is 1 test for enumerated and non-enumerated aliases
				value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);	-- first test for non-enumerated alias
			end
			value, selected = is_alias_used (args, alias, index, true, value, selected, error_list);		-- test for enumerated alias
		else
			value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);		--test for non-enumerated alias
		end
	end

	if #error_list &gt; 0 and 'none' ~= error_condition then						-- for cases where this code is used outside of extract_names()
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap_style ('parameter', k);
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap_style ('parameter', selected);
		table.insert( z.message_tail, { set_error( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end


--[=[-------------------------&lt; R E M O V E _ W I K I _ L I N K &gt;----------------------------------------------

Gets the display text from a wikilink like [[A|B]] or [[B]] gives B

The str:gsub() returns either A|B froma [[A|B]] or B from [[B]] or B from B (no wikilink markup).

In l(), l:gsub() removes the link and pipe (if they exist); the second :gsub() trims white space from the label
if str was wrapped in wikilink markup.  Presumably, this is because without wikimarkup in str, there is no match
in the initial gsub, the replacement function l() doesn't get called.

]=]

local function remove_wiki_link (str)
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end


--[=[-------------------------&lt; I S _ W I K I L I N K &gt;--------------------------------------------------------

Determines if str is a wikilink, extracts, and returns the the wikilink type, link text, and display text parts.
If str is a complex wikilink ([[L|D]]):
	returns wl_type 2 and D and L from [[L|D]];
if str is a simple wikilink ([[D]])
	returns wl_type 1 and D from [[D]] and L as empty string;
if not a wikilink:
	returns wl_type 0, str as D, and L as empty string.

trims leading and trailing white space and pipes from L and D ([[L|]] and [[|D]] are accepted by MediaWiki and
treated like [[D]]; while [[|D|]] is not accepted by MediaWiki, here, we accept it and return D without the pipes).

]=]

local function is_wikilink (str)
	local D, L
	local wl_type = 2;															-- assume that str is a complex wikilink [[L|D]]

	L, D = str:match ('^%[%[([^|]+)|([^%]]+)%]%]$');							-- get L and D from [[L|D]] 

	if not is_set (D) then														-- if no separate link
		D = str:match ('^%[%[([^%]]*)|*%]%]$');									-- get D from [[D]]
		wl_type = 1; 
	end
	
	if not is_set (D) then														-- no wikilink markup
		D = str;																-- return the string as D
		wl_type = 0;															-- but say that it is not a wikilink
	end
	
	D = mw.text.trim (D, '%s|');												-- trim white space and pipe characters 
	L = L and mw.text.trim (L, '%s|');
	
	return wl_type, D, L or '';
end


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

Returns the argument without wiki markup and a number; the number is more-or-less meaningless except as a flag
to indicate that markup was replaced; do not rely on it as an indicator of how many of any kind of markup was
removed; returns the argument and nil when no markup removed

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then
		return argument, nil;													-- no argument, nothing to do
	end

	if nil == argument:find ( &quot;''&quot;, 1, true ) then								-- Is there at least one double apostrophe?  If not, exit.
		return argument, nil;
	end

	local flag;
	while true do
		if argument:find ( &quot;'''''&quot;, 1, true ) then								-- bold italic (5)
			argument, flag=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);						-- remove all instances of it
		elseif argument:find ( &quot;''''&quot;, 1, true ) then							-- italic start and end without content (4)
			argument, flag=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;'''&quot;, 1, true ) then							-- bold (3)
			argument, flag=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;''&quot;, 1, true ) then								-- italic (2)
			argument, flag=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end

	return argument, flag;														-- done
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr)
	cfg = cfg_table_ptr;
	
end


--[[--------------------------&lt; E X P O R T S &gt;----------------------------------------------------------------
]]

return {
	is_set = is_set,															-- exported functions
	in_array = in_array,
	substitute = substitute,
	error_comment = error_comment,
	set_error = set_error,
	select_one = select_one,
	add_maint_cat = add_maint_cat,
	wrap_style = wrap_style,
	safe_for_italics = safe_for_italics,
	remove_wiki_link = remove_wiki_link,
	is_wikilink = is_wikilink,
	make_wikilink = make_wikilink,
	set_selected_modules = set_selected_modules,
	strip_apostrophe_markup = strip_apostrophe_markup,
	z = z,																		-- exported table
	}</text>
      <sha1>3ip0nyncv5q3w1ip0l9y5jzifvqvcf6</sha1>
    </revision>
    <revision>
      <id>4956</id>
      <parentid>4955</parentid>
      <timestamp>2020-01-11T12:32:44Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4956</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="15414" sha1="5rfrtuc4s7uvjwnzsho5aib4ou956cd" xml:space="preserve">
local z = {
	error_categories = {};														-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};														-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};														-- for categorizing citations based on certain properties, language of source for instance
};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local cfg;																		-- table of tables imported from selected Module:Citation/CS1/Configuration


--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.

]]

local function is_set( var )
	return not (var == nil or var == '');
end


--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end


--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end


--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with css markup according to the state of hidden.

]]

local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end


--[=[-------------------------&lt; M A K E _ W I K I L I N K &gt;----------------------------------------------------

Makes a wikilink; when bot link and display text is provided, returns a wikilink in the form [[L|D]]; if only
link is provided, returns a wikilink in the form [[L]]; if neither are provided or link is omitted, returns an
empty string.

]=]

local function make_wikilink (link, display)
	if is_set (link) then
		if is_set (display) then
			return table.concat ({'[[', link, '|', display, ']]'});
		else
			return table.concat ({'[[', link, ']]'});
		end
	else
		return '';
	end
end


--[[--------------------------&lt; S E T _ E R R O R &gt;--------------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

]]

local function set_error( error_id, arguments, raw, prefix, suffix )
	local error_state = cfg.error_conditions[ error_id ];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] );								-- because missing error handler in Module:Citation/CS1/Configuration
	elseif is_set( error_state.category ) then
		table.insert( z.error_categories, error_state.category );
	end
	
	local message = substitute( error_state.message, arguments );

	message = table.concat (
		{
		message,
		' (',
		make_wikilink (
			table.concat (
				{
				cfg.messages['help page link'],
				'#',
				error_state.anchor
				}),
			cfg.messages['help page label']),
		')'
		});

	z.error_ids[ error_id ] = true;
	if in_array( error_id, { 'bare_url_missing_title', 'trans_missing_title' } )
			and z.error_ids['citation_missing_title'] then
		return '', false;
	end
	
	message = table.concat({ prefix, message, suffix });
	
	if raw == true then
		return message, error_state.hidden;
	end		
		
	return error_comment( message, error_state.hidden );
end


--[[-------------------------&lt; I S _ A L I A S _ U S E D &gt;-----------------------------------------------------

This function is used by select_one() to determine if one of a list of alias parameters is in the argument list
provided by the template.

Input:
	args – pointer to the arguments table from calling template
	alias – one of the list of possible aliases in the aliases lists from Module:Citation/CS1/Configuration
	index – for enumerated parameters, identifies which one
	enumerated – true/false flag used choose how enumerated aliases are examined
	value – value associated with an alias that has previously been selected; nil if not yet selected
	selected – the alias that has previously been selected; nil if not yet selected
	error_list – list of aliases that are duplicates of the alias already selected

Returns:
	value – value associated with alias we selected or that was previously selected or nil if an alias not yet selected
	selected – the alias we selected or the alias that was previously selected or nil if an alias not yet selected

]]

local function is_alias_used (args, alias, index, enumerated, value, selected, error_list)
	if enumerated then															-- is this a test for an enumerated parameters?
		alias = alias:gsub ('#', index);										-- replace '#' with the value in index
	else
		alias = alias:gsub ('#', '');											-- remove '#' if it exists
	end

	if is_set(args[alias]) then													-- alias is in the template's argument list
		if value ~= nil and selected ~= alias then								-- if we have already selected one of the aliases
			local skip;
			for _, v in ipairs(error_list) do									-- spin through the error list to see if we've added this alias
				if v == alias then
					skip = true;
					break;														-- has been added so stop looking 
				end
			end
			if not skip then													-- has not been added so
				table.insert( error_list, alias );								-- add error alias to the error list
			end
		else
			value = args[alias];												-- not yet selected an alias, so select this one
			selected = alias;
		end
	end
	return value, selected;														-- return newly selected alias, or previously selected alias
end


--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maintenance_cats using names from the configuration file with additional text if any.
To prevent duplication, the added_maint_cats table lists the categories by key that have been added to z.maintenance_cats.

]]

local added_maint_cats = {}														-- list of maintenance categories that have been added to z.maintenance_cats
local function add_maint_cat (key, arguments)
	if not added_maint_cats [key] then
		added_maint_cats [key] = true;											-- note that we've added this category
		table.insert( z.maintenance_cats, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
	end
end


--[[--------------------------&lt; S A F E _ F O R _ I T A L I C S &gt;----------------------------------------------

Protects a string that will be wrapped in wiki italic markup '' ... ''

Note: We cannot use &lt;i&gt; for italics, as the expected behavior for italics specified by ''...'' in the title is that
they will be inverted (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and '' tend to interact
poorly under Mediawiki's HTML tidy.

]]

local function safe_for_italics( str )
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span&gt;&lt;/span&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span&gt;&lt;/span&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end


--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

local function wrap_style (key, str)
	if not is_set( str ) then
		return &quot;&quot;;
	elseif in_array( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safe_for_italics( str );
	end

	return substitute( cfg.presentation[key], {str} );
end


--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider.  The list of parameters to consider is just
names.  For parameters that may be enumerated, the position of the numerator in the parameter name is identified
by the '#' so |author-last1= and |author1-last= are represented as 'author-last#' and 'author#-last'.

Because enumerated parameter |&lt;param&gt;1= is an alias of |&lt;param&gt;= we must test for both possibilities.


Generates an error if more than one match is present.

]]

local function select_one( args, aliases_list, error_condition, index )
	local value = nil;															-- the value assigned to the selected parameter
	local selected = '';														-- the name of the parameter we have chosen
	local error_list = {};

	if index ~= nil then index = tostring(index); end

	for _, alias in ipairs( aliases_list ) do									-- for each alias in the aliases list
		if alias:match ('#') then												-- if this alias can be enumerated
			if '1' == index then												-- when index is 1 test for enumerated and non-enumerated aliases
				value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);	-- first test for non-enumerated alias
			end
			value, selected = is_alias_used (args, alias, index, true, value, selected, error_list);		-- test for enumerated alias
		else
			value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);		--test for non-enumerated alias
		end
	end

	if #error_list &gt; 0 and 'none' ~= error_condition then						-- for cases where this code is used outside of extract_names()
		local error_str = &quot;&quot;;
		for _, k in ipairs( error_list ) do
			if error_str ~= &quot;&quot; then error_str = error_str .. cfg.messages['parameter-separator'] end
			error_str = error_str .. wrap_style ('parameter', k);
		end
		if #error_list &gt; 1 then
			error_str = error_str .. cfg.messages['parameter-final-separator'];
		else
			error_str = error_str .. cfg.messages['parameter-pair-separator'];
		end
		error_str = error_str .. wrap_style ('parameter', selected);
		table.insert( z.message_tail, { set_error( error_condition, {error_str}, true ) } );
	end
	
	return value, selected;
end


--[=[-------------------------&lt; R E M O V E _ W I K I _ L I N K &gt;----------------------------------------------

Gets the display text from a wikilink like [[A|B]] or [[B]] gives B

The str:gsub() returns either A|B froma [[A|B]] or B from [[B]] or B from B (no wikilink markup).

In l(), l:gsub() removes the link and pipe (if they exist); the second :gsub() trims white space from the label
if str was wrapped in wikilink markup.  Presumably, this is because without wikimarkup in str, there is no match
in the initial gsub, the replacement function l() doesn't get called.

]=]

local function remove_wiki_link (str)
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end


--[=[-------------------------&lt; I S _ W I K I L I N K &gt;--------------------------------------------------------

Determines if str is a wikilink, extracts, and returns the the wikilink type, link text, and display text parts.
If str is a complex wikilink ([[L|D]]):
	returns wl_type 2 and D and L from [[L|D]];
if str is a simple wikilink ([[D]])
	returns wl_type 1 and D from [[D]] and L as empty string;
if not a wikilink:
	returns wl_type 0, str as D, and L as empty string.

trims leading and trailing white space and pipes from L and D ([[L|]] and [[|D]] are accepted by MediaWiki and
treated like [[D]]; while [[|D|]] is not accepted by MediaWiki, here, we accept it and return D without the pipes).

]=]

local function is_wikilink (str)
	local D, L
	local wl_type = 2;															-- assume that str is a complex wikilink [[L|D]]

	if not str:match ('^%[%[[^%]]+%]%]$') then									-- is str some sort of a wikilink (must have some sort of content)
		return 0, str, '';														-- not a wililink; return wl_type as 0, str as D, and empty string as L
	end
	
	L, D = str:match ('^%[%[([^|]+)|([^%]]+)%]%]$');							-- get L and D from [[L|D]] 

	if not is_set (D) then														-- if no separate display
		D = str:match ('^%[%[([^%]]*)|*%]%]$');									-- get D from [[D]] or [[D|]]
		wl_type = 1; 
	end
	
	D = mw.text.trim (D, '%s|');												-- trim white space and pipe characters 
--	L = L and mw.text.trim (L, '%s|');
	return wl_type, D, L or '';
end


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

Returns the argument without wiki markup and a number; the number is more-or-less meaningless except as a flag
to indicate that markup was replaced; do not rely on it as an indicator of how many of any kind of markup was
removed; returns the argument and nil when no markup removed

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then
		return argument, nil;													-- no argument, nothing to do
	end

	if nil == argument:find ( &quot;''&quot;, 1, true ) then								-- Is there at least one double apostrophe?  If not, exit.
		return argument, nil;
	end

	local flag;
	while true do
		if argument:find ( &quot;'''''&quot;, 1, true ) then								-- bold italic (5)
			argument, flag=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);						-- remove all instances of it
		elseif argument:find ( &quot;''''&quot;, 1, true ) then							-- italic start and end without content (4)
			argument, flag=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;'''&quot;, 1, true ) then							-- bold (3)
			argument, flag=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;''&quot;, 1, true ) then								-- italic (2)
			argument, flag=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end

	return argument, flag;														-- done
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr)
	cfg = cfg_table_ptr;
	
end


--[[--------------------------&lt; E X P O R T S &gt;----------------------------------------------------------------
]]

return {
	is_set = is_set,															-- exported functions
	in_array = in_array,
	substitute = substitute,
	error_comment = error_comment,
	set_error = set_error,
	select_one = select_one,
	add_maint_cat = add_maint_cat,
	wrap_style = wrap_style,
	safe_for_italics = safe_for_italics,
	remove_wiki_link = remove_wiki_link,
	is_wikilink = is_wikilink,
	make_wikilink = make_wikilink,
	set_selected_modules = set_selected_modules,
	strip_apostrophe_markup = strip_apostrophe_markup,
	z = z,																		-- exported table
	}</text>
      <sha1>5rfrtuc4s7uvjwnzsho5aib4ou956cd</sha1>
    </revision>
    <revision>
      <id>4957</id>
      <parentid>4956</parentid>
      <timestamp>2020-10-10T13:22:53Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4957</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="19220" sha1="rnxgdpjx6jrhyzx5bolqb5kyqlzkqoq" xml:space="preserve">
local z = {
	error_categories = {};														-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};														-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};														-- for categorizing citations based on certain properties, language of source for instance
};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local cfg;																		-- table of tables imported from selected Module:Citation/CS1/Configuration


--[[--------------------------&lt; H A S _ A C C E P T _ A S _ W R I T T E N &gt;------------------------------------

when &lt;str&gt; is wholly wrapped in accept-as-written markup, return &lt;str&gt; without markup and true; return &lt;str&gt; and false else

with allow_empty = false, &lt;str&gt; must have at least one character inside the markup
with allow_empty = true, &lt;str&gt; the markup frame can be empty like (()) to distinguish an empty template parameter from the specific condition &quot;has no applicable value&quot; in citation-context.

After futher evaluation the two cases might be merged at a later stage, but should be kept separated for now.

]]

local function has_accept_as_written (str, allow_empty)
	local count;
	if true == allow_empty then
		str, count = str:gsub ('^%(%((.*)%)%)$', '%1'); 						-- allows (()) to be an empty set
	else
		str, count = str:gsub ('^%(%((.+)%)%)$', '%1');
	end
	return str, 0 ~= count;
end


--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.

]]

local function is_set( var )
	return not (var == nil or var == '');
end


--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array( needle, haystack )
	if needle == nil then
		return false;
	end
	for n,v in ipairs( haystack ) do
		if v == needle then
			return n;
		end
	end
	return false;
end


--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute( msg, args )
	return args and mw.message.newRawMessage( msg, args ):plain() or msg;
end


--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with CSS markup according to the state of hidden.

]]

local function error_comment( content, hidden )
	return substitute( hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content );
end


--[=[-------------------------&lt; M A K E _ W I K I L I N K &gt;----------------------------------------------------

Makes a wikilink; when both link and display text is provided, returns a wikilink in the form [[L|D]]; if only
link is provided, returns a wikilink in the form [[L]]; if neither are provided or link is omitted, returns an
empty string.

]=]

local function make_wikilink (link, display)
	if is_set (link) then
		if is_set (display) then
			return table.concat ({'[[', link, '|', display, ']]'});
		else
			return table.concat ({'[[', link, ']]'});
		end
	else
		return '';
	end
end


--[[--------------------------&lt; S E T _ M E S S A G E &gt;----------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

TODO: change z.error_categories and z.maintenance_cats to have the form cat_name = true; to avoid dups without having to have an extra cat

]]
local added_maint_cats = {}														-- list of maintenance categories that have been added to z.maintenance_cats; TODO: figure out how to delete this table

local function set_message (error_id, arguments, raw, prefix, suffix)
	local error_state = cfg.error_conditions[error_id];
	
	prefix = prefix or &quot;&quot;;
	suffix = suffix or &quot;&quot;;
	
	if error_state == nil then
		error( cfg.messages['undefined_error'] .. ': ' .. error_id );			-- because missing error handler in Module:Citation/CS1/Configuration

	elseif is_set (error_state.category) then
		if error_state.message then												-- when error_state.message defined, this is an error message
			table.insert( z.error_categories, error_state.category );
		else
			if not added_maint_cats[error_id] then
				added_maint_cats[error_id] = true;								-- note that we've added this category
				table.insert (z.maintenance_cats, substitute (error_state.category, arguments));	-- make cat name then add to table
			end
			return;																-- because no message, nothing more to do
		end
	end

	local message = substitute( error_state.message, arguments );

	message = table.concat (
		{
		message,
		' (',
		make_wikilink (
			table.concat (
				{
				cfg.messages['help page link'],
				'#',
				error_state.anchor
				}),
			cfg.messages['help page label']),
		')'
		});

	z.error_ids[error_id] = true;
	if z.error_ids['err_citation_missing_title'] and							-- if missing-title error already noted
		in_array (error_id, {'err_bare_url_missing_title', 'err_trans_missing_title'}) then		-- and this error is one of these
			return '', false;													-- don't bother because one flavor of missing title is sufficient
	end
	
	message = table.concat ({ prefix, message, suffix });

	if raw == true then
		return message, error_state.hidden;
	end		

	return error_comment (message, error_state.hidden);
end


--[[-------------------------&lt; I S _ A L I A S _ U S E D &gt;-----------------------------------------------------

This function is used by select_one() to determine if one of a list of alias parameters is in the argument list
provided by the template.

Input:
	args – pointer to the arguments table from calling template
	alias – one of the list of possible aliases in the aliases lists from Module:Citation/CS1/Configuration
	index – for enumerated parameters, identifies which one
	enumerated – true/false flag used to choose how enumerated aliases are examined
	value – value associated with an alias that has previously been selected; nil if not yet selected
	selected – the alias that has previously been selected; nil if not yet selected
	error_list – list of aliases that are duplicates of the alias already selected

Returns:
	value – value associated with alias we selected or that was previously selected or nil if an alias not yet selected
	selected – the alias we selected or the alias that was previously selected or nil if an alias not yet selected

]]

local function is_alias_used (args, alias, index, enumerated, value, selected, error_list)
	if enumerated then															-- is this a test for an enumerated parameters?
		alias = alias:gsub ('#', index);										-- replace '#' with the value in index
	else
		alias = alias:gsub ('#', '');											-- remove '#' if it exists
	end

	if is_set(args[alias]) then													-- alias is in the template's argument list
		if value ~= nil and selected ~= alias then								-- if we have already selected one of the aliases
			local skip;
			for _, v in ipairs(error_list) do									-- spin through the error list to see if we've added this alias
				if v == alias then
					skip = true;
					break;														-- has been added so stop looking 
				end
			end
			if not skip then													-- has not been added so
				table.insert( error_list, alias );								-- add error alias to the error list
			end
		else
			value = args[alias];												-- not yet selected an alias, so select this one
			selected = alias;
		end
	end
	return value, selected;														-- return newly selected alias, or previously selected alias
end


--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maintenance_cats using names from the configuration file with additional text if any.
To prevent duplication, the added_maint_cats table lists the categories by key that have been added to z.maintenance_cats.

]]

local function add_maint_cat (key, arguments)
	if not added_maint_cats [key] then
		added_maint_cats [key] = true;											-- note that we've added this category
		table.insert( z.maintenance_cats, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
	end
end


--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

foreign_lang_source and foreign_lang_source_2 keys have a language code appended to them so that multiple languages
may be categorized but multiples of the same language are not categorized.

added_prop_cats is a table declared in page scope variables above

]]

local added_prop_cats = {};														-- list of property categories that have been added to z.properties_cats

local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		key = key:gsub ('(foreign_lang_source_?2?)%a%a%a?[%a%-]*', '%1');		-- strip lang code from keyname
		table.insert( z.properties_cats, substitute (cfg.prop_cats [key], arguments));	-- make name then add to table
	end
end


--[[--------------------------&lt; S A F E _ F O R _ I T A L I C S &gt;----------------------------------------------

Protects a string that will be wrapped in wiki italic markup '' ... ''

Note: We cannot use &lt;i&gt; for italics, as the expected behavior for italics specified by ''...'' in the title is that
they will be inverted (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and '' tend to interact
poorly under Mediawiki's HTML tidy.

]]

local function safe_for_italics( str )
	if not is_set(str) then
		return str;
	else
		if str:sub(1,1) == &quot;'&quot; then str = &quot;&lt;span&gt;&lt;/span&gt;&quot; .. str; end
		if str:sub(-1,-1) == &quot;'&quot; then str = str .. &quot;&lt;span&gt;&lt;/span&gt;&quot;; end
		
		-- Remove newlines as they break italics.
		return str:gsub( '\n', ' ' );
	end
end


--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

local function wrap_style (key, str)
	if not is_set( str ) then
		return &quot;&quot;;
	elseif in_array( key, { 'italic-title', 'trans-italic-title' } ) then
		str = safe_for_italics( str );
	end

	return substitute( cfg.presentation[key], {str} );
end


--[[--------------------------&lt; M A K E _ S E P _ L I S T &gt;------------------------------------------------------------

make a separated list of items using provided separators.
	&lt;sep_list&gt; - typically '&lt;comma&gt;&lt;space&gt;'
	&lt;sep_list_pair&gt; - typically '&lt;space&gt;and&lt;space&gt;'
	&lt;sep_list_end&gt; - typically '&lt;comma&gt;&lt;space&gt;and&lt;space&gt;' or '&lt;comma&gt;&lt;space&gt;&amp;&lt;space&gt;'

defaults to cfg.presentation['sep_list'], cfg.presentation['sep_list_pair'], and cfg.presentation['sep_list_end']
if &lt;sep_list_end&gt; is specified, &lt;sep_list&gt; and &lt;sep_list_pair&gt; must also be supplied

]]

local function make_sep_list (count, list_seq, sep_list, sep_list_pair, sep_list_end)
	local list = '';

	if not sep_list then														-- set the defaults
		sep_list = cfg.presentation['sep_list'];
		sep_list_pair = cfg.presentation['sep_list_pair'];
		sep_list_end = cfg.presentation['sep_list_end'];
	end
	
	if 2 &gt;= count then
		list = table.concat (list_seq, sep_list_pair);							-- insert separator between two items; returns list_seq[1] then only one item
	elseif 2 &lt; count then
		list = table.concat (list_seq, sep_list, 1, count-1);					-- concatenate all but last item with plain list separator
		list = table.concat ({list, list_seq[count]}, sep_list_end);			-- concatenate last item onto end of &lt;list&gt; with final separator
	end
	
	return list;
end


--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider.  The list of parameters to consider is just
names.  For parameters that may be enumerated, the position of the numerator in the parameter name is identified
by the '#' so |author-last1= and |author1-last= are represented as 'author-last#' and 'author#-last'.

Because enumerated parameter |&lt;param&gt;1= is an alias of |&lt;param&gt;= we must test for both possibilities.


Generates an error if more than one match is present.

]]

local function select_one (args, aliases_list, error_condition, index)
	local value = nil;															-- the value assigned to the selected parameter
	local selected = '';														-- the name of the parameter we have chosen
	local error_list = {};

	if index ~= nil then index = tostring(index); end

	for _, alias in ipairs( aliases_list ) do									-- for each alias in the aliases list
		if alias:match ('#') then												-- if this alias can be enumerated
			if '1' == index then												-- when index is 1 test for enumerated and non-enumerated aliases
				value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);	-- first test for non-enumerated alias
			end
			value, selected = is_alias_used (args, alias, index, true, value, selected, error_list);	-- test for enumerated alias
		else
			value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);	--test for non-enumerated alias
		end
	end

	if #error_list &gt; 0 and 'none' ~= error_condition then						-- for cases where this code is used outside of extract_names()
		for i, v in ipairs (error_list) do
			error_list[i] = wrap_style ('parameter', v);
		end
		table.insert (error_list, wrap_style ('parameter', selected));
		table.insert (z.message_tail, {set_message (error_condition, {make_sep_list (#error_list, error_list)}, true)});
	end
	
	return value, selected;
end


--[=[-------------------------&lt; R E M O V E _ W I K I _ L I N K &gt;----------------------------------------------

Gets the display text from a wikilink like [[A|B]] or [[B]] gives B

The str:gsub() returns either A|B froma [[A|B]] or B from [[B]] or B from B (no wikilink markup).

In l(), l:gsub() removes the link and pipe (if they exist); the second :gsub() trims whitespace from the label
if str was wrapped in wikilink markup.  Presumably, this is because without wikimarkup in str, there is no match
in the initial gsub, the replacement function l() doesn't get called.

]=]

local function remove_wiki_link (str)
	return (str:gsub( &quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub( &quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub(&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end


--[=[-------------------------&lt; I S _ W I K I L I N K &gt;--------------------------------------------------------

Determines if str is a wikilink, extracts, and returns the wikilink type, link text, and display text parts.
If str is a complex wikilink ([[L|D]]):
	returns wl_type 2 and D and L from [[L|D]];
if str is a simple wikilink ([[D]])
	returns wl_type 1 and D from [[D]] and L as empty string;
if not a wikilink:
	returns wl_type 0, str as D, and L as empty string.

trims leading and trailing whitespace and pipes from L and D ([[L|]] and [[|D]] are accepted by MediaWiki and
treated like [[D]]; while [[|D|]] is not accepted by MediaWiki, here, we accept it and return D without the pipes).

]=]

local function is_wikilink (str)
	local D, L
	local wl_type = 2;															-- assume that str is a complex wikilink [[L|D]]

	if not str:match ('^%[%[[^%]]+%]%]$') then									-- is str some sort of a wikilink (must have some sort of content)
		return 0, str, '';														-- not a wikilink; return wl_type as 0, str as D, and empty string as L
	end
	
	L, D = str:match ('^%[%[([^|]+)|([^%]]+)%]%]$');							-- get L and D from [[L|D]] 

	if not is_set (D) then														-- if no separate display
		D = str:match ('^%[%[([^%]]*)|*%]%]$');									-- get D from [[D]] or [[D|]]
		wl_type = 1; 
	end
	
	D = mw.text.trim (D, '%s|');												-- trim white space and pipe characters 
	return wl_type, D, L or '';
end


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

Returns the argument without wiki markup and a number; the number is more-or-less meaningless except as a flag
to indicate that markup was replaced; do not rely on it as an indicator of how many of any kind of markup was
removed; returns the argument and nil when no markup removed

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then
		return argument, nil;													-- no argument, nothing to do
	end

	if nil == argument:find ( &quot;''&quot;, 1, true ) then								-- Is there at least one double apostrophe?  If not, exit.
		return argument, nil;
	end

	local flag;
	while true do
		if argument:find ( &quot;'''''&quot;, 1, true ) then								-- bold italic (5)
			argument, flag=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);						-- remove all instances of it
		elseif argument:find ( &quot;''''&quot;, 1, true ) then							-- italic start and end without content (4)
			argument, flag=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;'''&quot;, 1, true ) then							-- bold (3)
			argument, flag=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;''&quot;, 1, true ) then								-- italic (2)
			argument, flag=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end

	return argument, flag;														-- done
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr)
	cfg = cfg_table_ptr;
	
end


--[[--------------------------&lt; E X P O R T S &gt;----------------------------------------------------------------
]]

return {
	add_maint_cat = add_maint_cat,												-- exported functions
	add_prop_cat = add_prop_cat,
	error_comment = error_comment,
	has_accept_as_written = has_accept_as_written,
	in_array = in_array,
	is_set = is_set,
	is_wikilink = is_wikilink,
	make_sep_list = make_sep_list,
	make_wikilink = make_wikilink,
	remove_wiki_link = remove_wiki_link,
	safe_for_italics = safe_for_italics,
	select_one = select_one,
	set_message = set_message,
	set_selected_modules = set_selected_modules,
	strip_apostrophe_markup = strip_apostrophe_markup,
	substitute = substitute,
	wrap_style = wrap_style,

	z = z,																		-- exported table
	}</text>
      <sha1>rnxgdpjx6jrhyzx5bolqb5kyqlzkqoq</sha1>
    </revision>
    <revision>
      <id>4958</id>
      <parentid>4957</parentid>
      <timestamp>2021-01-09T14:11:11Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4958</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="19249" sha1="12dopckfk6g95hjrotef4mkj3hq5uiw" xml:space="preserve">
local z = {
	error_categories = {};														-- for categorizing citations that contain errors
	error_ids = {};
	message_tail = {};
	maintenance_cats = {};														-- for categorizing citations that aren't erroneous per se, but could use a little work
	properties_cats = {};														-- for categorizing citations based on certain properties, language of source for instance
};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local cfg;																		-- table of tables imported from selected Module:Citation/CS1/Configuration


--[[--------------------------&lt; H A S _ A C C E P T _ A S _ W R I T T E N &gt;------------------------------------

When &lt;str&gt; is wholly wrapped in accept-as-written markup, return &lt;str&gt; without markup and true; return &lt;str&gt; and false else

with allow_empty = false, &lt;str&gt; must have at least one character inside the markup
with allow_empty = true, &lt;str&gt; the markup frame can be empty like (()) to distinguish an empty template parameter from the specific condition &quot;has no applicable value&quot; in citation-context.

After further evaluation the two cases might be merged at a later stage, but should be kept separated for now.

]]

local function has_accept_as_written (str, allow_empty)
	local count;
	if true == allow_empty then
		str, count = str:gsub ('^%(%((.*)%)%)$', '%1'); 						-- allows (()) to be an empty set
	else
		str, count = str:gsub ('^%(%((.+)%)%)$', '%1');
	end
	return str, 0 ~= count;
end


--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.

]]

local function is_set (var)
	return not (var == nil or var == '');
end


--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array (needle, haystack)
	if needle == nil then
		return false;
	end
	for n, v in ipairs (haystack) do
		if v == needle then
			return n;
		end
	end
	return false;
end


--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table.

]]

local function substitute (msg, args)
	return args and mw.message.newRawMessage (msg, args):plain() or msg;
end


--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with CSS markup according to the state of hidden.

]]

local function error_comment (content, hidden)
	return substitute (hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content);
end


--[=[-------------------------&lt; M A K E _ W I K I L I N K &gt;----------------------------------------------------

Makes a wikilink; when both link and display text is provided, returns a wikilink in the form [[L|D]]; if only
link is provided (or link and display are the same), returns a wikilink in the form [[L]]; if neither are
provided or link is omitted, returns an empty string.

]=]

local function make_wikilink (link, display)
	if not is_set (link) then return '' end

	if is_set (display) and link ~= display then			
		return table.concat ({'[[', link, '|', display, ']]'});			
	else
		return table.concat ({'[[', link, ']]'});
	end
end


--[[--------------------------&lt; S E T _ M E S S A G E &gt;----------------------------------------------------------

Sets an error condition and returns the appropriate error message.  The actual placement of the error message in the output is
the responsibility of the calling function.

TODO: change z.error_categories and z.maintenance_cats to have the form cat_name = true; to avoid dups without having to have an extra cat

]]
local added_maint_cats = {}														-- list of maintenance categories that have been added to z.maintenance_cats; TODO: figure out how to delete this table

local function set_message (error_id, arguments, raw, prefix, suffix)
	local error_state = cfg.error_conditions[error_id];
	
	prefix = prefix or '';
	suffix = suffix or '';
	
	if error_state == nil then
		error (cfg.messages['undefined_error'] .. ': ' .. error_id);			-- because missing error handler in Module:Citation/CS1/Configuration

	elseif is_set (error_state.category) then
		if error_state.message then												-- when error_state.message defined, this is an error message
			table.insert (z.error_categories, error_state.category);
		else
			if not added_maint_cats[error_id] then
				added_maint_cats[error_id] = true;								-- note that we've added this category
				table.insert (z.maintenance_cats, substitute (error_state.category, arguments));	-- make cat name then add to table
			end
			return;																-- because no message, nothing more to do
		end
	end

	local message = substitute (error_state.message, arguments);

	message = table.concat (
		{
		message,
		' (',
		make_wikilink (
			table.concat (
				{
				cfg.messages['help page link'],
				'#',
				error_state.anchor
				}),
			cfg.messages['help page label']),
		')'
		});

	z.error_ids[error_id] = true;
	if z.error_ids['err_citation_missing_title'] and							-- if missing-title error already noted
		in_array (error_id, {'err_bare_url_missing_title', 'err_trans_missing_title'}) then		-- and this error is one of these
			return '', false;													-- don't bother because one flavor of missing title is sufficient
	end
	
	message = table.concat ({prefix, message, suffix});

	if raw == true then
		return message, error_state.hidden;
	end		

	return error_comment (message, error_state.hidden);
end


--[[-------------------------&lt; I S _ A L I A S _ U S E D &gt;-----------------------------------------------------

This function is used by select_one() to determine if one of a list of alias parameters is in the argument list
provided by the template.

Input:
	args – pointer to the arguments table from calling template
	alias – one of the list of possible aliases in the aliases lists from Module:Citation/CS1/Configuration
	index – for enumerated parameters, identifies which one
	enumerated – true/false flag used to choose how enumerated aliases are examined
	value – value associated with an alias that has previously been selected; nil if not yet selected
	selected – the alias that has previously been selected; nil if not yet selected
	error_list – list of aliases that are duplicates of the alias already selected

Returns:
	value – value associated with alias we selected or that was previously selected or nil if an alias not yet selected
	selected – the alias we selected or the alias that was previously selected or nil if an alias not yet selected

]]

local function is_alias_used (args, alias, index, enumerated, value, selected, error_list)
	if enumerated then															-- is this a test for an enumerated parameters?
		alias = alias:gsub ('#', index);										-- replace '#' with the value in index
	else
		alias = alias:gsub ('#', '');											-- remove '#' if it exists
	end

	if is_set (args[alias]) then													-- alias is in the template's argument list
		if value ~= nil and selected ~= alias then								-- if we have already selected one of the aliases
			local skip;
			for _, v in ipairs (error_list) do									-- spin through the error list to see if we've added this alias
				if v == alias then
					skip = true;
					break;														-- has been added so stop looking 
				end
			end
			if not skip then													-- has not been added so
				table.insert (error_list, alias);								-- add error alias to the error list
			end
		else
			value = args[alias];												-- not yet selected an alias, so select this one
			selected = alias;
		end
	end
	return value, selected;														-- return newly selected alias, or previously selected alias
end


--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maintenance_cats using names from the configuration file with additional text if any.
To prevent duplication, the added_maint_cats table lists the categories by key that have been added to z.maintenance_cats.

]]

local function add_maint_cat (key, arguments)
	if not added_maint_cats [key] then
		added_maint_cats [key] = true;											-- note that we've added this category
		table.insert (z.maintenance_cats, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
	end
end


--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.properties_cats using names from the configuration file with additional text if any.

foreign_lang_source and foreign_lang_source_2 keys have a language code appended to them so that multiple languages
may be categorized but multiples of the same language are not categorized.

added_prop_cats is a table declared in page scope variables above

]]

local added_prop_cats = {};														-- list of property categories that have been added to z.properties_cats

local function add_prop_cat (key, arguments)
	if not added_prop_cats [key] then
		added_prop_cats [key] = true;											-- note that we've added this category
		key = key:gsub ('(foreign_lang_source_?2?)%a%a%a?[%a%-]*', '%1');		-- strip lang code from keyname
		table.insert (z.properties_cats, substitute (cfg.prop_cats [key], arguments));	-- make name then add to table
	end
end


--[[--------------------------&lt; S A F E _ F O R _ I T A L I C S &gt;----------------------------------------------

Protects a string that will be wrapped in wiki italic markup '' ... ''

Note: We cannot use &lt;i&gt; for italics, as the expected behavior for italics specified by ''...'' in the title is that
they will be inverted (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and '' tend to interact
poorly under Mediawiki's HTML tidy.

]]

local function safe_for_italics (str)
	if not is_set (str) then return str end

	if str:sub (1, 1) == &quot;'&quot; then str = &quot;&lt;span&gt;&lt;/span&gt;&quot; .. str; end
	if str:sub (-1, -1) == &quot;'&quot; then str = str .. &quot;&lt;span&gt;&lt;/span&gt;&quot;; end
	
	-- Remove newlines as they break italics.
	return str:gsub ('\n', ' ');

end


--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

local function wrap_style (key, str)
	if not is_set (str) then
		return &quot;&quot;;
	elseif in_array (key, {'italic-title', 'trans-italic-title'}) then
		str = safe_for_italics (str);
	end

	return substitute (cfg.presentation[key], {str});
end


--[[--------------------------&lt; M A K E _ S E P _ L I S T &gt;------------------------------------------------------------

make a separated list of items using provided separators.
	&lt;sep_list&gt; - typically '&lt;comma&gt;&lt;space&gt;'
	&lt;sep_list_pair&gt; - typically '&lt;space&gt;and&lt;space&gt;'
	&lt;sep_list_end&gt; - typically '&lt;comma&gt;&lt;space&gt;and&lt;space&gt;' or '&lt;comma&gt;&lt;space&gt;&amp;&lt;space&gt;'

defaults to cfg.presentation['sep_list'], cfg.presentation['sep_list_pair'], and cfg.presentation['sep_list_end']
if &lt;sep_list_end&gt; is specified, &lt;sep_list&gt; and &lt;sep_list_pair&gt; must also be supplied

]]

local function make_sep_list (count, list_seq, sep_list, sep_list_pair, sep_list_end)
	local list = '';

	if not sep_list then														-- set the defaults
		sep_list = cfg.presentation['sep_list'];
		sep_list_pair = cfg.presentation['sep_list_pair'];
		sep_list_end = cfg.presentation['sep_list_end'];
	end
	
	if 2 &gt;= count then
		list = table.concat (list_seq, sep_list_pair);							-- insert separator between two items; returns list_seq[1] then only one item
	elseif 2 &lt; count then
		list = table.concat (list_seq, sep_list, 1, count - 1);					-- concatenate all but last item with plain list separator
		list = table.concat ({list, list_seq[count]}, sep_list_end);			-- concatenate last item onto end of &lt;list&gt; with final separator
	end
	
	return list;
end


--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider.  The list of parameters to consider is just
names.  For parameters that may be enumerated, the position of the numerator in the parameter name is identified
by the '#' so |author-last1= and |author1-last= are represented as 'author-last#' and 'author#-last'.

Because enumerated parameter |&lt;param&gt;1= is an alias of |&lt;param&gt;= we must test for both possibilities.


Generates an error if more than one match is present.

]]

local function select_one (args, aliases_list, error_condition, index)
	local value = nil;															-- the value assigned to the selected parameter
	local selected = '';														-- the name of the parameter we have chosen
	local error_list = {};

	if index ~= nil then index = tostring(index); end

	for _, alias in ipairs (aliases_list) do									-- for each alias in the aliases list
		if alias:match ('#') then												-- if this alias can be enumerated
			if '1' == index then												-- when index is 1 test for enumerated and non-enumerated aliases
				value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);	-- first test for non-enumerated alias
			end
			value, selected = is_alias_used (args, alias, index, true, value, selected, error_list);	-- test for enumerated alias
		else
			value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);	-- test for non-enumerated alias
		end
	end

	if #error_list &gt; 0 and 'none' ~= error_condition then						-- for cases where this code is used outside of extract_names()
		for i, v in ipairs (error_list) do
			error_list[i] = wrap_style ('parameter', v);
		end
		table.insert (error_list, wrap_style ('parameter', selected));
		table.insert (z.message_tail, {set_message (error_condition, {make_sep_list (#error_list, error_list)}, true)});
	end
	
	return value, selected;
end


--[=[-------------------------&lt; R E M O V E _ W I K I _ L I N K &gt;----------------------------------------------

Gets the display text from a wikilink like [[A|B]] or [[B]] gives B

The str:gsub() returns either A|B froma [[A|B]] or B from [[B]] or B from B (no wikilink markup).

In l(), l:gsub() removes the link and pipe (if they exist); the second :gsub() trims whitespace from the label
if str was wrapped in wikilink markup.  Presumably, this is because without wikimarkup in str, there is no match
in the initial gsub, the replacement function l() doesn't get called.

]=]

local function remove_wiki_link (str)
	return (str:gsub (&quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub (&quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub (&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end


--[=[-------------------------&lt; I S _ W I K I L I N K &gt;--------------------------------------------------------

Determines if str is a wikilink, extracts, and returns the wikilink type, link text, and display text parts.
If str is a complex wikilink ([[L|D]]):
	returns wl_type 2 and D and L from [[L|D]];
if str is a simple wikilink ([[D]])
	returns wl_type 1 and D from [[D]] and L as empty string;
if not a wikilink:
	returns wl_type 0, str as D, and L as empty string.

trims leading and trailing whitespace and pipes from L and D ([[L|]] and [[|D]] are accepted by MediaWiki and
treated like [[D]]; while [[|D|]] is not accepted by MediaWiki, here, we accept it and return D without the pipes).

]=]

local function is_wikilink (str)
	local D, L
	local wl_type = 2;															-- assume that str is a complex wikilink [[L|D]]

	if not str:match ('^%[%[[^%]]+%]%]$') then									-- is str some sort of a wikilink (must have some sort of content)
		return 0, str, '';														-- not a wikilink; return wl_type as 0, str as D, and empty string as L
	end
	
	L, D = str:match ('^%[%[([^|]+)|([^%]]+)%]%]$');							-- get L and D from [[L|D]] 

	if not is_set (D) then														-- if no separate display
		D = str:match ('^%[%[([^%]]*)|*%]%]$');									-- get D from [[D]] or [[D|]]
		wl_type = 1; 
	end
	
	D = mw.text.trim (D, '%s|');												-- trim white space and pipe characters 
	return wl_type, D, L or '';
end


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

Returns the argument without wiki markup and a number; the number is more-or-less meaningless except as a flag
to indicate that markup was replaced; do not rely on it as an indicator of how many of any kind of markup was
removed; returns the argument and nil when no markup removed

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then
		return argument, nil;													-- no argument, nothing to do
	end

	if nil == argument:find ( &quot;''&quot;, 1, true ) then								-- Is there at least one double apostrophe?  If not, exit.
		return argument, nil;
	end

	local flag;
	while true do
		if argument:find (&quot;'''''&quot;, 1, true) then								-- bold italic (5)
			argument, flag = argument:gsub (&quot;%'%'%'%'%'&quot;, &quot;&quot;);						-- remove all instances of it
		elseif argument:find (&quot;''''&quot;, 1, true) then							-- italic start and end without content (4)
			argument, flag=argument:gsub (&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find (&quot;'''&quot;, 1, true) then							-- bold (3)
			argument, flag=argument:gsub (&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find (&quot;''&quot;, 1, true) then								-- italic (2)
			argument, flag = argument:gsub (&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end

	return argument, flag;														-- done
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr)
	cfg = cfg_table_ptr;
	
end


--[[--------------------------&lt; E X P O R T S &gt;----------------------------------------------------------------
]]

return {
	add_maint_cat = add_maint_cat,												-- exported functions
	add_prop_cat = add_prop_cat,
	error_comment = error_comment,
	has_accept_as_written = has_accept_as_written,
	in_array = in_array,
	is_set = is_set,
	is_wikilink = is_wikilink,
	make_sep_list = make_sep_list,
	make_wikilink = make_wikilink,
	remove_wiki_link = remove_wiki_link,
	safe_for_italics = safe_for_italics,
	select_one = select_one,
	set_message = set_message,
	set_selected_modules = set_selected_modules,
	strip_apostrophe_markup = strip_apostrophe_markup,
	substitute = substitute,
	wrap_style = wrap_style,

	z = z,																		-- exported table
	}</text>
      <sha1>12dopckfk6g95hjrotef4mkj3hq5uiw</sha1>
    </revision>
    <revision>
      <id>4959</id>
      <parentid>4958</parentid>
      <timestamp>2022-01-22T14:11:16Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>update per [[Wikipedia:Village_pump_(proposals)#rfc:_shall_we_update_cs1/2?|RfC]];</comment>
      <origin>4959</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="24564" sha1="kk801mqzkv4xrvmuck62gy23fyu6dl0" xml:space="preserve">local z = {
	error_cats_t = {};															-- for categorizing citations that contain errors
	error_ids_t = {};															-- list of error identifiers; used to prevent duplication of certain errors; local to this module
	error_msgs_t = {};															-- sequence table of error messages
	maint_cats_t = {};															-- for categorizing citations that aren't erroneous per se, but could use a little work
	prop_cats_t = {};															-- for categorizing citations based on certain properties, language of source for instance
	prop_keys_t = {};															-- for adding classes to the citation's &lt;cite&gt; tag
};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local cfg;																		-- table of tables imported from selected Module:Citation/CS1/Configuration


--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.

]]

local function is_set (var)
	return not (var == nil or var == '');
end


--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array (needle, haystack)
	if needle == nil then
		return false;
	end
	for n, v in ipairs (haystack) do
		if v == needle then
			return n;
		end
	end
	return false;
end


--[[--------------------------&lt; H A S _ A C C E P T _ A S _ W R I T T E N &gt;------------------------------------

When &lt;str&gt; is wholly wrapped in accept-as-written markup, return &lt;str&gt; without markup and true; return &lt;str&gt; and false else

with allow_empty = false, &lt;str&gt; must have at least one character inside the markup
with allow_empty = true, &lt;str&gt; the markup frame can be empty like (()) to distinguish an empty template parameter from the specific condition &quot;has no applicable value&quot; in citation-context.

After further evaluation the two cases might be merged at a later stage, but should be kept separated for now.

]]

local function has_accept_as_written (str, allow_empty)
	if not is_set (str) then
		return str, false;
	end

	local count;

	if true == allow_empty then
		str, count = str:gsub ('^%(%((.*)%)%)$', '%1'); 						-- allows (()) to be an empty set
	else
		str, count = str:gsub ('^%(%((.+)%)%)$', '%1');
	end
	return str, 0 ~= count;
end


--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table. &lt;args&gt; may be a single string or a
sequence table of multiple strings.

]]

local function substitute (msg, args)
	return args and mw.message.newRawMessage (msg, args):plain() or msg;
end


--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with CSS markup according to the state of hidden. &lt;content&gt; may be a single string or a
sequence table of multiple strings.

]]

local function error_comment (content, hidden)
	return substitute (hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content);
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen to a dash under certain conditions.  The hyphen must separate
like items; unlike items are returned unmodified.  These forms are modified:
	letter - letter (A - B)
	digit - digit (4-5)
	digit separator digit - digit separator digit (4.1-4.5 or 4-1-4-5)
	letterdigit - letterdigit (A1-A5) (an optional separator between letter and
		digit is supported – a.1-a.5 or a-1-a-5)
	digitletter - digitletter (5a - 5d) (an optional separator between letter and
		digit is supported – 5.a-5.d or 5-a-5-d)

any other forms are returned unmodified.

str may be a comma- or semicolon-separated list

]]

local function hyphen_to_dash (str)
	if not is_set (str) then
		return str;
	end

	local accept;																-- boolean

	str = str:gsub (&quot;(%(%(.-%)%))&quot;, function(m) return m:gsub(&quot;,&quot;, &quot;，&quot;):gsub(&quot;;&quot;, &quot;；&quot;) end) -- replace commas and semicolons in accept-as-written markup with similar unicode characters so they'll be ignored during the split	
	str = str:gsub ('&amp;[nm]dash;', {['&amp;ndash;'] = '–', ['&amp;mdash;'] = '—'});		-- replace &amp;mdash; and &amp;ndash; entities with their characters; semicolon mucks up the text.split
	str = str:gsub ('&amp;#45;', '-'); -- replace HTML numeric entity with hyphen character
	str = str:gsub ('&amp;nbsp;', ' '); -- replace &amp;nbsp; entity with generic keyboard space character
	
	local out = {};
	local list = mw.text.split (str, '%s*[,;]%s*');								-- split str at comma or semicolon separators if there are any

	for _, item in ipairs (list) do												-- for each item in the list
		item, accept = has_accept_as_written (item);							-- remove accept-this-as-written markup when it wraps all of item
		if not accept and mw.ustring.match (item, '^%w*[%.%-]?%w+%s*[%-–—]%s*%w*[%.%-]?%w+$') then	-- if a hyphenated range or has endash or emdash separators
			if item:match ('^%a+[%.%-]?%d+%s*%-%s*%a+[%.%-]?%d+$') or			-- letterdigit hyphen letterdigit (optional separator between letter and digit)
				item:match ('^%d+[%.%-]?%a+%s*%-%s*%d+[%.%-]?%a+$') or			-- digitletter hyphen digitletter (optional separator between digit and letter)
				item:match ('^%d+[%.%-]%d+%s*%-%s*%d+[%.%-]%d+$') or			-- digit separator digit hyphen digit separator digit
				item:match ('^%d+%s*%-%s*%d+$') or								-- digit hyphen digit
				item:match ('^%a+%s*%-%s*%a+$') then							-- letter hyphen letter
					item = item:gsub ('(%w*[%.%-]?%w+)%s*%-%s*(%w*[%.%-]?%w+)', '%1–%2');	-- replace hyphen, remove extraneous space characters
			else
				item = mw.ustring.gsub (item, '%s*[–—]%s*', '–');				-- for endash or emdash separated ranges, replace em with en, remove extraneous whitespace
			end
		end
		table.insert (out, item);												-- add the (possibly modified) item to the output table
	end

	local temp_str = '';														-- concatenate the output table into a comma separated string
	temp_str, accept = has_accept_as_written (table.concat (out, ', '));		-- remove accept-this-as-written markup when it wraps all of concatenated out
	if accept then
		temp_str = has_accept_as_written (str);									-- when global markup removed, return original str; do it this way to suppress boolean second return value
		return temp_str:gsub(&quot;，&quot;, &quot;,&quot;):gsub(&quot;；&quot;, &quot;;&quot;);
	else
		return temp_str:gsub(&quot;，&quot;, &quot;,&quot;):gsub(&quot;；&quot;, &quot;;&quot;);						-- else, return assembled temp_str
	end
end


--[=[-------------------------&lt; M A K E _ W I K I L I N K &gt;----------------------------------------------------

Makes a wikilink; when both link and display text is provided, returns a wikilink in the form [[L|D]]; if only
link is provided (or link and display are the same), returns a wikilink in the form [[L]]; if neither are
provided or link is omitted, returns an empty string.

]=]

local function make_wikilink (link, display)
	if not is_set (link) then return '' end

	if is_set (display) and link ~= display then			
		return table.concat ({'[[', link, '|', display, ']]'});			
	else
		return table.concat ({'[[', link, ']]'});
	end
end


--[[--------------------------&lt; S E T _ M E S S A G E &gt;----------------------------------------------------------

Sets an error message using the ~/Configuration error_conditions{} table along with arguments supplied in the function
call, inserts the resulting message in z.error_msgs_t{} sequence table, and returns the error message.

&lt;error_id&gt; – key value for appropriate error handler in ~/Configuration error_conditions{} table 
&lt;arguments&gt; – may be a single string or a sequence table of multiple strings to be subsititued into error_conditions[error_id].message
&lt;raw&gt; – boolean
	true –	causes this function to return the error message not wrapped in visible-error, hidden-error span tag;
			returns error_conditions[error_id].hidden as a second return value
			does not add message to z.error_msgs_t sequence table
	false, nil – adds message wrapped in visible-error, hidden-error span tag to z.error_msgs_t
			returns the error message wrapped in visible-error, hidden-error span tag; there is no second return value
&lt;prefix&gt; – string to be prepended to &lt;message&gt;									-- TODO: remove support for these unused(?) arguments?
&lt;suffix&gt; – string to be appended to &lt;message&gt;

TODO: change z.error_cats_t and z.maint_cats_t to have the form cat_name = true?  this to avoid dups without having to have an extra table

]]

local added_maint_cats = {}														-- list of maintenance categories that have been added to z.maint_cats_t; TODO: figure out how to delete this table

local function set_message (error_id, arguments, raw, prefix, suffix)
	local error_state = cfg.error_conditions[error_id];
	
	prefix = prefix or '';
	suffix = suffix or '';
	
	if error_state == nil then
		error (cfg.messages['undefined_error'] .. ': ' .. error_id);			-- because missing error handler in Module:Citation/CS1/Configuration

	elseif is_set (error_state.category) then
		if error_state.message then												-- when error_state.message defined, this is an error message
			table.insert (z.error_cats_t, error_state.category);
		else
			if not added_maint_cats[error_id] then
				added_maint_cats[error_id] = true;								-- note that we've added this category
				table.insert (z.maint_cats_t, substitute (error_state.category, arguments));	-- make cat name then add to table
			end
			return;																-- because no message, nothing more to do
		end
	end

	local message = substitute (error_state.message, arguments);

	message = table.concat (
		{
		message,
		' (',
		make_wikilink (
			table.concat (
				{
				cfg.messages['help page link'],
				'#',
				error_state.anchor
				}),
			cfg.messages['help page label']),
		')'
		});

	z.error_ids_t[error_id] = true;
	if z.error_ids_t['err_citation_missing_title'] and							-- if missing-title error already noted
		in_array (error_id, {'err_bare_url_missing_title', 'err_trans_missing_title'}) then		-- and this error is one of these
			return '', false;													-- don't bother because one flavor of missing title is sufficient
	end
	
	message = table.concat ({prefix, message, suffix});

	if true == raw then
		return message, error_state.hidden;										-- return message not wrapped in visible-error, hidden-error span tag
	end		

	message = error_comment (message, error_state.hidden);						-- wrap message in visible-error, hidden-error span tag
	table.insert (z.error_msgs_t, message);										-- add it to the messages sequence table
	return message;																-- and done; return value generally not used but is used as a flag in various functions of ~/Identifiers
end


--[[-------------------------&lt; I S _ A L I A S _ U S E D &gt;-----------------------------------------------------

This function is used by select_one() to determine if one of a list of alias parameters is in the argument list
provided by the template.

Input:
	args – pointer to the arguments table from calling template
	alias – one of the list of possible aliases in the aliases lists from Module:Citation/CS1/Configuration
	index – for enumerated parameters, identifies which one
	enumerated – true/false flag used to choose how enumerated aliases are examined
	value – value associated with an alias that has previously been selected; nil if not yet selected
	selected – the alias that has previously been selected; nil if not yet selected
	error_list – list of aliases that are duplicates of the alias already selected

Returns:
	value – value associated with alias we selected or that was previously selected or nil if an alias not yet selected
	selected – the alias we selected or the alias that was previously selected or nil if an alias not yet selected

]]

local function is_alias_used (args, alias, index, enumerated, value, selected, error_list)
	if enumerated then															-- is this a test for an enumerated parameters?
		alias = alias:gsub ('#', index);										-- replace '#' with the value in index
	else
		alias = alias:gsub ('#', '');											-- remove '#' if it exists
	end

	if is_set (args[alias]) then												-- alias is in the template's argument list
		if value ~= nil and selected ~= alias then								-- if we have already selected one of the aliases
			local skip;
			for _, v in ipairs (error_list) do									-- spin through the error list to see if we've added this alias
				if v == alias then
					skip = true;
					break;														-- has been added so stop looking 
				end
			end
			if not skip then													-- has not been added so
				table.insert (error_list, alias);								-- add error alias to the error list
			end
		else
			value = args[alias];												-- not yet selected an alias, so select this one
			selected = alias;
		end
	end
	return value, selected;														-- return newly selected alias, or previously selected alias
end


--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maint_cats_t using names from the configuration file with additional text if any.
To prevent duplication, the added_maint_cats table lists the categories by key that have been added to z.maint_cats_t.

]]

local function add_maint_cat (key, arguments)
	if not added_maint_cats [key] then
		added_maint_cats [key] = true;											-- note that we've added this category
		table.insert (z.maint_cats_t, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
	end
end


--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.prop_cats_t using names from the configuration file with additional text if any.

foreign_lang_source and foreign_lang_source_2 keys have a language code appended to them so that multiple languages
may be categorized but multiples of the same language are not categorized.

added_prop_cats is a table declared in page scope variables above

]]

local added_prop_cats = {};														-- list of property categories that have been added to z.prop_cats_t

local function add_prop_cat (key, arguments, key_modifier)
	local key_modified = key .. ((key_modifier and key_modifier) or '');		-- modify &lt;key&gt; with &lt;key_modifier&gt; if present and not nil
	
	if not added_prop_cats [key_modified] then
		added_prop_cats [key_modified] = true;									-- note that we've added this category
		table.insert (z.prop_cats_t, substitute (cfg.prop_cats [key], arguments));	-- make name then add to table
		table.insert (z.prop_keys_t, 'cs1-prop-' .. key);						-- convert key to class for use in the citation's &lt;cite&gt; tag
	end
end


--[[--------------------------&lt; S A F E _ F O R _ I T A L I C S &gt;----------------------------------------------

Protects a string that will be wrapped in wiki italic markup '' ... ''

Note: We cannot use &lt;i&gt; for italics, as the expected behavior for italics specified by ''...'' in the title is that
they will be inverted (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and '' tend to interact
poorly under Mediawiki's HTML tidy.

]]

local function safe_for_italics (str)
	if not is_set (str) then return str end

	if str:sub (1, 1) == &quot;'&quot; then str = &quot;&lt;span&gt;&lt;/span&gt;&quot; .. str; end
	if str:sub (-1, -1) == &quot;'&quot; then str = str .. &quot;&lt;span&gt;&lt;/span&gt;&quot;; end
	
	return str:gsub ('\n', ' ');												-- Remove newlines as they break italics.
end


--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

local function wrap_style (key, str)
	if not is_set (str) then
		return &quot;&quot;;
	elseif in_array (key, {'italic-title', 'trans-italic-title'}) then
		str = safe_for_italics (str);
	end

	return substitute (cfg.presentation[key], {str});
end


--[[--------------------------&lt; M A K E _ S E P _ L I S T &gt;------------------------------------------------------------

make a separated list of items using provided separators.
	&lt;sep_list&gt; - typically '&lt;comma&gt;&lt;space&gt;'
	&lt;sep_list_pair&gt; - typically '&lt;space&gt;and&lt;space&gt;'
	&lt;sep_list_end&gt; - typically '&lt;comma&gt;&lt;space&gt;and&lt;space&gt;' or '&lt;comma&gt;&lt;space&gt;&amp;&lt;space&gt;'

defaults to cfg.presentation['sep_list'], cfg.presentation['sep_list_pair'], and cfg.presentation['sep_list_end']
if &lt;sep_list_end&gt; is specified, &lt;sep_list&gt; and &lt;sep_list_pair&gt; must also be supplied

]]

local function make_sep_list (count, list_seq, sep_list, sep_list_pair, sep_list_end)
	local list = '';

	if not sep_list then														-- set the defaults
		sep_list = cfg.presentation['sep_list'];
		sep_list_pair = cfg.presentation['sep_list_pair'];
		sep_list_end = cfg.presentation['sep_list_end'];
	end
	
	if 2 &gt;= count then
		list = table.concat (list_seq, sep_list_pair);							-- insert separator between two items; returns list_seq[1] then only one item
	elseif 2 &lt; count then
		list = table.concat (list_seq, sep_list, 1, count - 1);					-- concatenate all but last item with plain list separator
		list = table.concat ({list, list_seq[count]}, sep_list_end);			-- concatenate last item onto end of &lt;list&gt; with final separator
	end
	
	return list;
end


--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider.  The list of parameters to consider is just
names.  For parameters that may be enumerated, the position of the numerator in the parameter name is identified
by the '#' so |author-last1= and |author1-last= are represented as 'author-last#' and 'author#-last'.

Because enumerated parameter |&lt;param&gt;1= is an alias of |&lt;param&gt;= we must test for both possibilities.


Generates an error if more than one match is present.

]]

local function select_one (args, aliases_list, error_condition, index)
	local value = nil;															-- the value assigned to the selected parameter
	local selected = '';														-- the name of the parameter we have chosen
	local error_list = {};

	if index ~= nil then index = tostring(index); end

	for _, alias in ipairs (aliases_list) do									-- for each alias in the aliases list
		if alias:match ('#') then												-- if this alias can be enumerated
			if '1' == index then												-- when index is 1 test for enumerated and non-enumerated aliases
				value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);	-- first test for non-enumerated alias
			end
			value, selected = is_alias_used (args, alias, index, true, value, selected, error_list);	-- test for enumerated alias
		else
			value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);	-- test for non-enumerated alias
		end
	end

	if #error_list &gt; 0 and 'none' ~= error_condition then						-- for cases where this code is used outside of extract_names()
		for i, v in ipairs (error_list) do
			error_list[i] = wrap_style ('parameter', v);
		end
		table.insert (error_list, wrap_style ('parameter', selected));
		set_message (error_condition, {make_sep_list (#error_list, error_list)});
	end
	
	return value, selected;
end


--[=[-------------------------&lt; R E M O V E _ W I K I _ L I N K &gt;----------------------------------------------

Gets the display text from a wikilink like [[A|B]] or [[B]] gives B

The str:gsub() returns either A|B froma [[A|B]] or B from [[B]] or B from B (no wikilink markup).

In l(), l:gsub() removes the link and pipe (if they exist); the second :gsub() trims whitespace from the label
if str was wrapped in wikilink markup.  Presumably, this is because without wikimarkup in str, there is no match
in the initial gsub, the replacement function l() doesn't get called.

]=]

local function remove_wiki_link (str)
	return (str:gsub (&quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub (&quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub (&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end


--[=[-------------------------&lt; I S _ W I K I L I N K &gt;--------------------------------------------------------

Determines if str is a wikilink, extracts, and returns the wikilink type, link text, and display text parts.
If str is a complex wikilink ([[L|D]]):
	returns wl_type 2 and D and L from [[L|D]];
if str is a simple wikilink ([[D]])
	returns wl_type 1 and D from [[D]] and L as empty string;
if not a wikilink:
	returns wl_type 0, str as D, and L as empty string.

trims leading and trailing whitespace and pipes from L and D ([[L|]] and [[|D]] are accepted by MediaWiki and
treated like [[D]]; while [[|D|]] is not accepted by MediaWiki, here, we accept it and return D without the pipes).

]=]

local function is_wikilink (str)
	local D, L
	local wl_type = 2;															-- assume that str is a complex wikilink [[L|D]]

	if not str:match ('^%[%[[^%]]+%]%]$') then									-- is str some sort of a wikilink (must have some sort of content)
		return 0, str, '';														-- not a wikilink; return wl_type as 0, str as D, and empty string as L
	end
	
	L, D = str:match ('^%[%[([^|]+)|([^%]]+)%]%]$');							-- get L and D from [[L|D]] 

	if not is_set (D) then														-- if no separate display
		D = str:match ('^%[%[([^%]]*)|*%]%]$');									-- get D from [[D]] or [[D|]]
		wl_type = 1; 
	end
	
	D = mw.text.trim (D, '%s|');												-- trim white space and pipe characters 
	return wl_type, D, L or '';
end


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

Returns the argument without wiki markup and a number; the number is more-or-less meaningless except as a flag
to indicate that markup was replaced; do not rely on it as an indicator of how many of any kind of markup was
removed; returns the argument and nil when no markup removed

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then
		return argument, nil;													-- no argument, nothing to do
	end

	if nil == argument:find ( &quot;''&quot;, 1, true ) then								-- Is there at least one double apostrophe?  If not, exit.
		return argument, nil;
	end

	local flag;
	while true do
		if argument:find (&quot;'''''&quot;, 1, true) then								-- bold italic (5)
			argument, flag = argument:gsub (&quot;%'%'%'%'%'&quot;, &quot;&quot;);					-- remove all instances of it
		elseif argument:find (&quot;''''&quot;, 1, true) then								-- italic start and end without content (4)
			argument, flag=argument:gsub (&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find (&quot;'''&quot;, 1, true) then								-- bold (3)
			argument, flag=argument:gsub (&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find (&quot;''&quot;, 1, true) then								-- italic (2)
			argument, flag = argument:gsub (&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end

	return argument, flag;														-- done
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr)
	cfg = cfg_table_ptr;
	
end


--[[--------------------------&lt; E X P O R T S &gt;----------------------------------------------------------------
]]

return {
	add_maint_cat = add_maint_cat,												-- exported functions
	add_prop_cat = add_prop_cat,
	error_comment = error_comment,
	has_accept_as_written = has_accept_as_written,
	hyphen_to_dash = hyphen_to_dash,
	in_array = in_array,
	is_set = is_set,
	is_wikilink = is_wikilink,
	make_sep_list = make_sep_list,
	make_wikilink = make_wikilink,
	remove_wiki_link = remove_wiki_link,
	safe_for_italics = safe_for_italics,
	select_one = select_one,
	set_message = set_message,
	set_selected_modules = set_selected_modules,
	strip_apostrophe_markup = strip_apostrophe_markup,
	substitute = substitute,
	wrap_style = wrap_style,

	z = z,																		-- exported table
	}</text>
      <sha1>kk801mqzkv4xrvmuck62gy23fyu6dl0</sha1>
    </revision>
    <revision>
      <id>4960</id>
      <parentid>4959</parentid>
      <timestamp>2024-12-28T15:31:46Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4960</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="24954" sha1="1rgyhapxi1dzuxmh3cqix2zrvvro8l2" xml:space="preserve">local z = {
	error_cats_t = {};															-- for categorizing citations that contain errors
	error_ids_t = {};															-- list of error identifiers; used to prevent duplication of certain errors; local to this module
	error_msgs_t = {};															-- sequence table of error messages
	maint_cats_t = {};															-- for categorizing citations that aren't erroneous per se, but could use a little work
	prop_cats_t = {};															-- for categorizing citations based on certain properties, language of source for instance
	prop_keys_t = {};															-- for adding classes to the citation's &lt;cite&gt; tag
};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local cfg;																		-- table of tables imported from selected Module:Citation/CS1/Configuration


--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.

]]

local function is_set (var)
	return not (var == nil or var == '');
end


--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array (needle, haystack)
	if needle == nil then
		return false;
	end
	for n, v in ipairs (haystack) do
		if v == needle then
			return n;
		end
	end
	return false;
end


--[[--------------------------&lt; H A S _ A C C E P T _ A S _ W R I T T E N &gt;------------------------------------

When &lt;str&gt; is wholly wrapped in accept-as-written markup, return &lt;str&gt; without markup and true; return &lt;str&gt; and false else

with allow_empty = false, &lt;str&gt; must have at least one character inside the markup
with allow_empty = true, &lt;str&gt; the markup frame can be empty like (()) to distinguish an empty template parameter from the specific condition &quot;has no applicable value&quot; in citation-context.

After further evaluation the two cases might be merged at a later stage, but should be kept separated for now.

]]

local function has_accept_as_written (str, allow_empty)
	if not is_set (str) then
		return str, false;
	end

	local count;

	if true == allow_empty then
		str, count = str:gsub ('^%(%((.*)%)%)$', '%1'); 						-- allows (()) to be an empty set
	else
		str, count = str:gsub ('^%(%((.+)%)%)$', '%1');
	end
	return str, 0 ~= count;
end


--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table. &lt;args&gt; may be a single string or a
sequence table of multiple strings.

]]

local function substitute (msg, args)
	return args and mw.message.newRawMessage (msg, args):plain() or msg;
end


--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with CSS markup according to the state of hidden. &lt;content&gt; may be a single string or a
sequence table of multiple strings.

]]

local function error_comment (content, hidden)
	return substitute (hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content);
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen, endash, emdash to endash under certain conditions.  The hyphen/en/em must separate
like items; unlike items are returned unmodified.  These forms are modified:
	letter - letter (A-B)
	digit - digit (4-5)
	digit separator digit - digit separator digit (4.1-4.5 or 4-1-4-5)
	letterdigit - letterdigit (A1-A5) (an optional separator between letter and
		digit is supported – a.1-a.5 or a-1-a-5)
	digitletter - digitletter (5a-5d) (an optional separator between letter and
		digit is supported – 5.a-5.d or 5-a-5-d)

any other forms are returned unmodified.

str may be a comma- or semicolon-separated list of page ranges with/without single pages

]]

local function hyphen_to_dash (str)
	if not is_set (str) then
		return str;
	end

	str = str:gsub (&quot;(%(%(.-%)%))&quot;, function(m) return m:gsub(&quot;,&quot;, &quot;，&quot;):gsub(&quot;;&quot;, &quot;；&quot;) end) -- replace commas and semicolons in accept-as-written markup with similar unicode characters so they'll be ignored during the split	
	str = str:gsub ('&amp;[nm]dash;', {['&amp;ndash;'] = '–', ['&amp;mdash;'] = '—'});		-- replace &amp;mdash; and &amp;ndash; entities with their characters; semicolon mucks up the text.split
	str = str:gsub ('&amp;#45;', '-');												-- replace HTML numeric entity with hyphen character
	str = str:gsub ('&amp;nbsp;', ' ');												-- replace &amp;nbsp; entity with generic keyboard space character
	
	local out = {};
	local list = mw.text.split (str, '%s*[,;]%s*');								-- split str at comma or semicolon separators if there are any

	local accept;																-- boolean

	for _, item in ipairs (list) do												-- for each item in the list
		item, accept = has_accept_as_written (item);							-- remove accept-this-as-written markup when it wraps all of item
		if not accept and mw.ustring.match (item, '^%w*[%.%-]?%w+%s*[—–-]%s*%w*[%.%-]?%w+$') then	-- if a hyphenated range or has endash or emdash separators
			if mw.ustring.match (item, '^%a+[%.%-]?%d+%s*[—–-]%s*%a+[%.%-]?%d+$') or		-- letterdigit hyphen letterdigit (optional separator between letter and digit)
				mw.ustring.match (item, '^%d+[%.%-]?%a+%s*[—–-]%s*%d+[%.%-]?%a+$') or		-- digitletter hyphen digitletter (optional separator between digit and letter)
				mw.ustring.match (item, '^%d+[%.%-]%d+%s*[—–-]%s*%d+[%.%-]%d+$') then		-- digit separator digit hyphen digit separator digit
					item = mw.ustring.gsub (item, '(%w*[%.%-]?%w+)%s*[—–-]%s*(%w*[%.%-]?%w+)', '&lt;span class=&quot;nowrap&quot;&gt;%1 –&lt;/span&gt; &lt;span class=&quot;nowrap&quot;&gt;%2&lt;/span&gt;');	-- replace hyphen/dash, with spaced endash

			elseif mw.ustring.match (item, '^%d+%s*[—–-]%s*%d+$') or			-- digit hyphen digit
				mw.ustring.match (item, '^%a+%s*[—–-]%s*%a+$') then				-- letter hyphen letter
					item = mw.ustring.gsub (item, '(%w+)%s*[—–-]%s*(%w+)', '&lt;span class=&quot;nowrap&quot;&gt;%1–&lt;/span&gt;%2');	-- replace hyphen/emdash with endash, remove extraneous space characters

			else
--				item = mw.ustring.gsub (item, '%s*[—–-]%s*', '–');				-- disabled; here when 'unlike' items so return &lt;item&gt; as is
			end
		end
		table.insert (out, item);												-- add the (possibly modified) item to the output table
	end

	local temp_str = '';														-- concatenate the output table into a comma separated string
	temp_str, accept = has_accept_as_written (table.concat (out, ', '));		-- remove accept-this-as-written markup when it wraps all of concatenated out
	if accept then
		temp_str = has_accept_as_written (str);									-- when global markup removed, return original str; do it this way to suppress boolean second return value
		return temp_str:gsub(&quot;，&quot;, &quot;,&quot;):gsub(&quot;；&quot;, &quot;;&quot;);
	else
		return temp_str:gsub(&quot;，&quot;, &quot;,&quot;):gsub(&quot;；&quot;, &quot;;&quot;);						-- else, return assembled temp_str
	end
end


--[=[-------------------------&lt; M A K E _ W I K I L I N K &gt;----------------------------------------------------

Makes a wikilink; when both link and display text is provided, returns a wikilink in the form [[L|D]]; if only
link is provided (or link and display are the same), returns a wikilink in the form [[L]]; if neither are
provided or link is omitted, returns an empty string.

]=]

local function make_wikilink (link, display)
	if not is_set (link) then return '' end

	if is_set (display) and link ~= display then			
		return table.concat ({'[[', link, '|', display, ']]'});			
	else
		return table.concat ({'[[', link, ']]'});
	end
end


--[[--------------------------&lt; S E T _ M E S S A G E &gt;----------------------------------------------------------

Sets an error message using the ~/Configuration error_conditions{} table along with arguments supplied in the function
call, inserts the resulting message in z.error_msgs_t{} sequence table, and returns the error message.

&lt;error_id&gt; – key value for appropriate error handler in ~/Configuration error_conditions{} table 
&lt;arguments&gt; – may be a single string or a sequence table of multiple strings to be subsititued into error_conditions[error_id].message
&lt;raw&gt; – boolean
	true –	causes this function to return the error message not wrapped in visible-error, hidden-error span tag;
			returns error_conditions[error_id].hidden as a second return value
			does not add message to z.error_msgs_t sequence table
	false, nil – adds message wrapped in visible-error, hidden-error span tag to z.error_msgs_t
			returns the error message wrapped in visible-error, hidden-error span tag; there is no second return value
&lt;prefix&gt; – string to be prepended to &lt;message&gt;									-- TODO: remove support for these unused(?) arguments?
&lt;suffix&gt; – string to be appended to &lt;message&gt;

TODO: change z.error_cats_t and z.maint_cats_t to have the form cat_name = true?  this to avoid dups without having to have an extra table

]]

local added_maint_cats = {}														-- list of maintenance categories that have been added to z.maint_cats_t; TODO: figure out how to delete this table

local function set_message (error_id, arguments, raw, prefix, suffix)
	local error_state = cfg.error_conditions[error_id];
	
	prefix = prefix or '';
	suffix = suffix or '';
	
	if error_state == nil then
		error (cfg.messages['undefined_error'] .. ': ' .. error_id);			-- because missing error handler in Module:Citation/CS1/Configuration

	elseif is_set (error_state.category) then
		if error_state.message then												-- when error_state.message defined, this is an error message
			table.insert (z.error_cats_t, error_state.category);
		else
			if not added_maint_cats[error_id] then
				added_maint_cats[error_id] = true;								-- note that we've added this category
				table.insert (z.maint_cats_t, substitute (error_state.category, arguments));	-- make cat name then add to table
			end
			return;																-- because no message, nothing more to do
		end
	end

	local message = substitute (error_state.message, arguments);

	message = table.concat (
		{
		message,
		' (',
		make_wikilink (
			table.concat (
				{
				cfg.messages['help page link'],
				'#',
				error_state.anchor
				}),
			cfg.messages['help page label']),
		')'
		});

	z.error_ids_t[error_id] = true;
	if z.error_ids_t['err_citation_missing_title'] and							-- if missing-title error already noted
		in_array (error_id, {'err_bare_url_missing_title', 'err_trans_missing_title'}) then		-- and this error is one of these
			return '', false;													-- don't bother because one flavor of missing title is sufficient
	end
	
	message = table.concat ({prefix, message, suffix});

	if true == raw then
		return message, error_state.hidden;										-- return message not wrapped in visible-error, hidden-error span tag
	end		

	message = error_comment (message, error_state.hidden);						-- wrap message in visible-error, hidden-error span tag
	table.insert (z.error_msgs_t, message);										-- add it to the messages sequence table
	return message;																-- and done; return value generally not used but is used as a flag in various functions of ~/Identifiers
end


--[[-------------------------&lt; I S _ A L I A S _ U S E D &gt;-----------------------------------------------------

This function is used by select_one() to determine if one of a list of alias parameters is in the argument list
provided by the template.

Input:
	args – pointer to the arguments table from calling template
	alias – one of the list of possible aliases in the aliases lists from Module:Citation/CS1/Configuration
	index – for enumerated parameters, identifies which one
	enumerated – true/false flag used to choose how enumerated aliases are examined
	value – value associated with an alias that has previously been selected; nil if not yet selected
	selected – the alias that has previously been selected; nil if not yet selected
	error_list – list of aliases that are duplicates of the alias already selected

Returns:
	value – value associated with alias we selected or that was previously selected or nil if an alias not yet selected
	selected – the alias we selected or the alias that was previously selected or nil if an alias not yet selected

]]

local function is_alias_used (args, alias, index, enumerated, value, selected, error_list)
	if enumerated then															-- is this a test for an enumerated parameters?
		alias = alias:gsub ('#', index);										-- replace '#' with the value in index
	else
		alias = alias:gsub ('#', '');											-- remove '#' if it exists
	end

	if is_set (args[alias]) then												-- alias is in the template's argument list
		if value ~= nil and selected ~= alias then								-- if we have already selected one of the aliases
			local skip;
			for _, v in ipairs (error_list) do									-- spin through the error list to see if we've added this alias
				if v == alias then
					skip = true;
					break;														-- has been added so stop looking 
				end
			end
			if not skip then													-- has not been added so
				table.insert (error_list, alias);								-- add error alias to the error list
			end
		else
			value = args[alias];												-- not yet selected an alias, so select this one
			selected = alias;
		end
	end
	return value, selected;														-- return newly selected alias, or previously selected alias
end


--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maint_cats_t using names from the configuration file with additional text if any.
To prevent duplication, the added_maint_cats table lists the categories by key that have been added to z.maint_cats_t.

]]

local function add_maint_cat (key, arguments)
	if not added_maint_cats [key] then
		added_maint_cats [key] = true;											-- note that we've added this category
		table.insert (z.maint_cats_t, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
	end
end


--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.prop_cats_t using names from the configuration file with additional text if any.

foreign_lang_source and foreign_lang_source_2 keys have a language code appended to them so that multiple languages
may be categorized but multiples of the same language are not categorized.

added_prop_cats is a table declared in page scope variables above

]]

local added_prop_cats = {};														-- list of property categories that have been added to z.prop_cats_t

local function add_prop_cat (key, arguments, key_modifier)
	local key_modified = key .. ((key_modifier and key_modifier) or '');		-- modify &lt;key&gt; with &lt;key_modifier&gt; if present and not nil
	
	if not added_prop_cats [key_modified] then
		added_prop_cats [key_modified] = true;									-- note that we've added this category
		table.insert (z.prop_cats_t, substitute (cfg.prop_cats [key], arguments));	-- make name then add to table
		table.insert (z.prop_keys_t, 'cs1-prop-' .. key);						-- convert key to class for use in the citation's &lt;cite&gt; tag
	end
end


--[[--------------------------&lt; S A F E _ F O R _ I T A L I C S &gt;----------------------------------------------

Protects a string that will be wrapped in wiki italic markup '' ... ''

Note: We cannot use &lt;i&gt; for italics, as the expected behavior for italics specified by ''...'' in the title is that
they will be inverted (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and '' tend to interact
poorly under Mediawiki's HTML tidy.

]]

local function safe_for_italics (str)
	if not is_set (str) then return str end

	if str:sub (1, 1) == &quot;'&quot; then str = &quot;&lt;span&gt;&lt;/span&gt;&quot; .. str; end
	if str:sub (-1, -1) == &quot;'&quot; then str = str .. &quot;&lt;span&gt;&lt;/span&gt;&quot;; end
	
	return str:gsub ('\n', ' ');												-- Remove newlines as they break italics.
end


--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

local function wrap_style (key, str)
	if not is_set (str) then
		return &quot;&quot;;
	elseif in_array (key, {'italic-title', 'trans-italic-title'}) then
		str = safe_for_italics (str);
	end

	return substitute (cfg.presentation[key], {str});
end


--[[--------------------------&lt; M A K E _ S E P _ L I S T &gt;------------------------------------------------------------

make a separated list of items using provided separators.
	&lt;sep_list&gt; - typically '&lt;comma&gt;&lt;space&gt;'
	&lt;sep_list_pair&gt; - typically '&lt;space&gt;and&lt;space&gt;'
	&lt;sep_list_end&gt; - typically '&lt;comma&gt;&lt;space&gt;and&lt;space&gt;' or '&lt;comma&gt;&lt;space&gt;&amp;&lt;space&gt;'

defaults to cfg.presentation['sep_list'], cfg.presentation['sep_list_pair'], and cfg.presentation['sep_list_end']
if &lt;sep_list_end&gt; is specified, &lt;sep_list&gt; and &lt;sep_list_pair&gt; must also be supplied

]]

local function make_sep_list (count, list_seq, sep_list, sep_list_pair, sep_list_end)
	local list = '';

	if not sep_list then														-- set the defaults
		sep_list = cfg.presentation['sep_list'];
		sep_list_pair = cfg.presentation['sep_list_pair'];
		sep_list_end = cfg.presentation['sep_list_end'];
	end
	
	if 2 &gt;= count then
		list = table.concat (list_seq, sep_list_pair);							-- insert separator between two items; returns list_seq[1] then only one item
	elseif 2 &lt; count then
		list = table.concat (list_seq, sep_list, 1, count - 1);					-- concatenate all but last item with plain list separator
		list = table.concat ({list, list_seq[count]}, sep_list_end);			-- concatenate last item onto end of &lt;list&gt; with final separator
	end
	
	return list;
end


--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider.  The list of parameters to consider is just
names.  For parameters that may be enumerated, the position of the numerator in the parameter name is identified
by the '#' so |author-last1= and |author1-last= are represented as 'author-last#' and 'author#-last'.

Because enumerated parameter |&lt;param&gt;1= is an alias of |&lt;param&gt;= we must test for both possibilities.


Generates an error if more than one match is present.

]]

local function select_one (args, aliases_list, error_condition, index)
	local value = nil;															-- the value assigned to the selected parameter
	local selected = '';														-- the name of the parameter we have chosen
	local error_list = {};

	if index ~= nil then index = tostring(index); end

	for _, alias in ipairs (aliases_list) do									-- for each alias in the aliases list
		if alias:match ('#') then												-- if this alias can be enumerated
			if '1' == index then												-- when index is 1 test for enumerated and non-enumerated aliases
				value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);	-- first test for non-enumerated alias
			end
			value, selected = is_alias_used (args, alias, index, true, value, selected, error_list);	-- test for enumerated alias
		else
			value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);	-- test for non-enumerated alias
		end
	end

	if #error_list &gt; 0 and 'none' ~= error_condition then						-- for cases where this code is used outside of extract_names()
		for i, v in ipairs (error_list) do
			error_list[i] = wrap_style ('parameter', v);
		end
		table.insert (error_list, wrap_style ('parameter', selected));
		set_message (error_condition, {make_sep_list (#error_list, error_list)});
	end
	
	return value, selected;
end


--[=[-------------------------&lt; R E M O V E _ W I K I _ L I N K &gt;----------------------------------------------

Gets the display text from a wikilink like [[A|B]] or [[B]] gives B

The str:gsub() returns either A|B froma [[A|B]] or B from [[B]] or B from B (no wikilink markup).

In l(), l:gsub() removes the link and pipe (if they exist); the second :gsub() trims whitespace from the label
if str was wrapped in wikilink markup.  Presumably, this is because without wikimarkup in str, there is no match
in the initial gsub, the replacement function l() doesn't get called.

]=]

local function remove_wiki_link (str)
	return (str:gsub (&quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub (&quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub (&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end


--[=[-------------------------&lt; I S _ W I K I L I N K &gt;--------------------------------------------------------

Determines if str is a wikilink, extracts, and returns the wikilink type, link text, and display text parts.
If str is a complex wikilink ([[L|D]]):
	returns wl_type 2 and D and L from [[L|D]];
if str is a simple wikilink ([[D]])
	returns wl_type 1 and D from [[D]] and L as empty string;
if not a wikilink:
	returns wl_type 0, str as D, and L as empty string.

trims leading and trailing whitespace and pipes from L and D ([[L|]] and [[|D]] are accepted by MediaWiki and
treated like [[D]]; while [[|D|]] is not accepted by MediaWiki, here, we accept it and return D without the pipes).

]=]

local function is_wikilink (str)
	local D, L
	local wl_type = 2;															-- assume that str is a complex wikilink [[L|D]]

	if not str:match ('^%[%[[^%]]+%]%]$') then									-- is str some sort of a wikilink (must have some sort of content)
		return 0, str, '';														-- not a wikilink; return wl_type as 0, str as D, and empty string as L
	end
	
	L, D = str:match ('^%[%[([^|]+)|([^%]]+)%]%]$');							-- get L and D from [[L|D]] 

	if not is_set (D) then														-- if no separate display
		D = str:match ('^%[%[([^%]]*)|*%]%]$');									-- get D from [[D]] or [[D|]]
		wl_type = 1; 
	end
	
	D = mw.text.trim (D, '%s|');												-- trim white space and pipe characters 
	return wl_type, D, L or '';
end


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

Returns the argument without wiki markup and a number; the number is more-or-less meaningless except as a flag
to indicate that markup was replaced; do not rely on it as an indicator of how many of any kind of markup was
removed; returns the argument and nil when no markup removed

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then
		return argument, nil;													-- no argument, nothing to do
	end

	if nil == argument:find ( &quot;''&quot;, 1, true ) then								-- Is there at least one double apostrophe?  If not, exit.
		return argument, nil;
	end

	local flag;
	while true do
		if argument:find (&quot;'''''&quot;, 1, true) then								-- bold italic (5)
			argument, flag = argument:gsub (&quot;%'%'%'%'%'&quot;, &quot;&quot;);					-- remove all instances of it
		elseif argument:find (&quot;''''&quot;, 1, true) then								-- italic start and end without content (4)
			argument, flag=argument:gsub (&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find (&quot;'''&quot;, 1, true) then								-- bold (3)
			argument, flag=argument:gsub (&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find (&quot;''&quot;, 1, true) then								-- italic (2)
			argument, flag = argument:gsub (&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end

	return argument, flag;														-- done
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr)
	cfg = cfg_table_ptr;
	
end


--[[--------------------------&lt; E X P O R T S &gt;----------------------------------------------------------------
]]

return {
	add_maint_cat = add_maint_cat,												-- exported functions
	add_prop_cat = add_prop_cat,
	error_comment = error_comment,
	has_accept_as_written = has_accept_as_written,
	hyphen_to_dash = hyphen_to_dash,
	in_array = in_array,
	is_set = is_set,
	is_wikilink = is_wikilink,
	make_sep_list = make_sep_list,
	make_wikilink = make_wikilink,
	remove_wiki_link = remove_wiki_link,
	safe_for_italics = safe_for_italics,
	select_one = select_one,
	set_message = set_message,
	set_selected_modules = set_selected_modules,
	strip_apostrophe_markup = strip_apostrophe_markup,
	substitute = substitute,
	wrap_style = wrap_style,

	z = z,																		-- exported table
	}</text>
      <sha1>1rgyhapxi1dzuxmh3cqix2zrvvro8l2</sha1>
    </revision>
    <revision>
      <id>4961</id>
      <parentid>4960</parentid>
      <timestamp>2025-08-07T07:39:16Z</timestamp>
      <contributor>
        <username>Martin Urbanec</username>
        <id>803</id>
      </contributor>
      <minor />
      <comment>29 revisions imported from [[:en:Module:Citation/CS1/Utilities]]: updating from enwiki</comment>
      <origin>4960</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="24954" sha1="1rgyhapxi1dzuxmh3cqix2zrvvro8l2" xml:space="preserve">local z = {
	error_cats_t = {};															-- for categorizing citations that contain errors
	error_ids_t = {};															-- list of error identifiers; used to prevent duplication of certain errors; local to this module
	error_msgs_t = {};															-- sequence table of error messages
	maint_cats_t = {};															-- for categorizing citations that aren't erroneous per se, but could use a little work
	prop_cats_t = {};															-- for categorizing citations based on certain properties, language of source for instance
	prop_keys_t = {};															-- for adding classes to the citation's &lt;cite&gt; tag
};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local cfg;																		-- table of tables imported from selected Module:Citation/CS1/Configuration


--[[--------------------------&lt; I S _ S E T &gt;------------------------------------------------------------------

Returns true if argument is set; false otherwise. Argument is 'set' when it exists (not nil) or when it is not an empty string.

]]

local function is_set (var)
	return not (var == nil or var == '');
end


--[[--------------------------&lt; I N _ A R R A Y &gt;--------------------------------------------------------------

Whether needle is in haystack

]]

local function in_array (needle, haystack)
	if needle == nil then
		return false;
	end
	for n, v in ipairs (haystack) do
		if v == needle then
			return n;
		end
	end
	return false;
end


--[[--------------------------&lt; H A S _ A C C E P T _ A S _ W R I T T E N &gt;------------------------------------

When &lt;str&gt; is wholly wrapped in accept-as-written markup, return &lt;str&gt; without markup and true; return &lt;str&gt; and false else

with allow_empty = false, &lt;str&gt; must have at least one character inside the markup
with allow_empty = true, &lt;str&gt; the markup frame can be empty like (()) to distinguish an empty template parameter from the specific condition &quot;has no applicable value&quot; in citation-context.

After further evaluation the two cases might be merged at a later stage, but should be kept separated for now.

]]

local function has_accept_as_written (str, allow_empty)
	if not is_set (str) then
		return str, false;
	end

	local count;

	if true == allow_empty then
		str, count = str:gsub ('^%(%((.*)%)%)$', '%1'); 						-- allows (()) to be an empty set
	else
		str, count = str:gsub ('^%(%((.+)%)%)$', '%1');
	end
	return str, 0 ~= count;
end


--[[--------------------------&lt; S U B S T I T U T E &gt;----------------------------------------------------------

Populates numbered arguments in a message string using an argument table. &lt;args&gt; may be a single string or a
sequence table of multiple strings.

]]

local function substitute (msg, args)
	return args and mw.message.newRawMessage (msg, args):plain() or msg;
end


--[[--------------------------&lt; E R R O R _ C O M M E N T &gt;----------------------------------------------------

Wraps error messages with CSS markup according to the state of hidden. &lt;content&gt; may be a single string or a
sequence table of multiple strings.

]]

local function error_comment (content, hidden)
	return substitute (hidden and cfg.presentation['hidden-error'] or cfg.presentation['visible-error'], content);
end


--[[--------------------------&lt; H Y P H E N _ T O _ D A S H &gt;--------------------------------------------------

Converts a hyphen, endash, emdash to endash under certain conditions.  The hyphen/en/em must separate
like items; unlike items are returned unmodified.  These forms are modified:
	letter - letter (A-B)
	digit - digit (4-5)
	digit separator digit - digit separator digit (4.1-4.5 or 4-1-4-5)
	letterdigit - letterdigit (A1-A5) (an optional separator between letter and
		digit is supported – a.1-a.5 or a-1-a-5)
	digitletter - digitletter (5a-5d) (an optional separator between letter and
		digit is supported – 5.a-5.d or 5-a-5-d)

any other forms are returned unmodified.

str may be a comma- or semicolon-separated list of page ranges with/without single pages

]]

local function hyphen_to_dash (str)
	if not is_set (str) then
		return str;
	end

	str = str:gsub (&quot;(%(%(.-%)%))&quot;, function(m) return m:gsub(&quot;,&quot;, &quot;，&quot;):gsub(&quot;;&quot;, &quot;；&quot;) end) -- replace commas and semicolons in accept-as-written markup with similar unicode characters so they'll be ignored during the split	
	str = str:gsub ('&amp;[nm]dash;', {['&amp;ndash;'] = '–', ['&amp;mdash;'] = '—'});		-- replace &amp;mdash; and &amp;ndash; entities with their characters; semicolon mucks up the text.split
	str = str:gsub ('&amp;#45;', '-');												-- replace HTML numeric entity with hyphen character
	str = str:gsub ('&amp;nbsp;', ' ');												-- replace &amp;nbsp; entity with generic keyboard space character
	
	local out = {};
	local list = mw.text.split (str, '%s*[,;]%s*');								-- split str at comma or semicolon separators if there are any

	local accept;																-- boolean

	for _, item in ipairs (list) do												-- for each item in the list
		item, accept = has_accept_as_written (item);							-- remove accept-this-as-written markup when it wraps all of item
		if not accept and mw.ustring.match (item, '^%w*[%.%-]?%w+%s*[—–-]%s*%w*[%.%-]?%w+$') then	-- if a hyphenated range or has endash or emdash separators
			if mw.ustring.match (item, '^%a+[%.%-]?%d+%s*[—–-]%s*%a+[%.%-]?%d+$') or		-- letterdigit hyphen letterdigit (optional separator between letter and digit)
				mw.ustring.match (item, '^%d+[%.%-]?%a+%s*[—–-]%s*%d+[%.%-]?%a+$') or		-- digitletter hyphen digitletter (optional separator between digit and letter)
				mw.ustring.match (item, '^%d+[%.%-]%d+%s*[—–-]%s*%d+[%.%-]%d+$') then		-- digit separator digit hyphen digit separator digit
					item = mw.ustring.gsub (item, '(%w*[%.%-]?%w+)%s*[—–-]%s*(%w*[%.%-]?%w+)', '&lt;span class=&quot;nowrap&quot;&gt;%1 –&lt;/span&gt; &lt;span class=&quot;nowrap&quot;&gt;%2&lt;/span&gt;');	-- replace hyphen/dash, with spaced endash

			elseif mw.ustring.match (item, '^%d+%s*[—–-]%s*%d+$') or			-- digit hyphen digit
				mw.ustring.match (item, '^%a+%s*[—–-]%s*%a+$') then				-- letter hyphen letter
					item = mw.ustring.gsub (item, '(%w+)%s*[—–-]%s*(%w+)', '&lt;span class=&quot;nowrap&quot;&gt;%1–&lt;/span&gt;%2');	-- replace hyphen/emdash with endash, remove extraneous space characters

			else
--				item = mw.ustring.gsub (item, '%s*[—–-]%s*', '–');				-- disabled; here when 'unlike' items so return &lt;item&gt; as is
			end
		end
		table.insert (out, item);												-- add the (possibly modified) item to the output table
	end

	local temp_str = '';														-- concatenate the output table into a comma separated string
	temp_str, accept = has_accept_as_written (table.concat (out, ', '));		-- remove accept-this-as-written markup when it wraps all of concatenated out
	if accept then
		temp_str = has_accept_as_written (str);									-- when global markup removed, return original str; do it this way to suppress boolean second return value
		return temp_str:gsub(&quot;，&quot;, &quot;,&quot;):gsub(&quot;；&quot;, &quot;;&quot;);
	else
		return temp_str:gsub(&quot;，&quot;, &quot;,&quot;):gsub(&quot;；&quot;, &quot;;&quot;);						-- else, return assembled temp_str
	end
end


--[=[-------------------------&lt; M A K E _ W I K I L I N K &gt;----------------------------------------------------

Makes a wikilink; when both link and display text is provided, returns a wikilink in the form [[L|D]]; if only
link is provided (or link and display are the same), returns a wikilink in the form [[L]]; if neither are
provided or link is omitted, returns an empty string.

]=]

local function make_wikilink (link, display)
	if not is_set (link) then return '' end

	if is_set (display) and link ~= display then			
		return table.concat ({'[[', link, '|', display, ']]'});			
	else
		return table.concat ({'[[', link, ']]'});
	end
end


--[[--------------------------&lt; S E T _ M E S S A G E &gt;----------------------------------------------------------

Sets an error message using the ~/Configuration error_conditions{} table along with arguments supplied in the function
call, inserts the resulting message in z.error_msgs_t{} sequence table, and returns the error message.

&lt;error_id&gt; – key value for appropriate error handler in ~/Configuration error_conditions{} table 
&lt;arguments&gt; – may be a single string or a sequence table of multiple strings to be subsititued into error_conditions[error_id].message
&lt;raw&gt; – boolean
	true –	causes this function to return the error message not wrapped in visible-error, hidden-error span tag;
			returns error_conditions[error_id].hidden as a second return value
			does not add message to z.error_msgs_t sequence table
	false, nil – adds message wrapped in visible-error, hidden-error span tag to z.error_msgs_t
			returns the error message wrapped in visible-error, hidden-error span tag; there is no second return value
&lt;prefix&gt; – string to be prepended to &lt;message&gt;									-- TODO: remove support for these unused(?) arguments?
&lt;suffix&gt; – string to be appended to &lt;message&gt;

TODO: change z.error_cats_t and z.maint_cats_t to have the form cat_name = true?  this to avoid dups without having to have an extra table

]]

local added_maint_cats = {}														-- list of maintenance categories that have been added to z.maint_cats_t; TODO: figure out how to delete this table

local function set_message (error_id, arguments, raw, prefix, suffix)
	local error_state = cfg.error_conditions[error_id];
	
	prefix = prefix or '';
	suffix = suffix or '';
	
	if error_state == nil then
		error (cfg.messages['undefined_error'] .. ': ' .. error_id);			-- because missing error handler in Module:Citation/CS1/Configuration

	elseif is_set (error_state.category) then
		if error_state.message then												-- when error_state.message defined, this is an error message
			table.insert (z.error_cats_t, error_state.category);
		else
			if not added_maint_cats[error_id] then
				added_maint_cats[error_id] = true;								-- note that we've added this category
				table.insert (z.maint_cats_t, substitute (error_state.category, arguments));	-- make cat name then add to table
			end
			return;																-- because no message, nothing more to do
		end
	end

	local message = substitute (error_state.message, arguments);

	message = table.concat (
		{
		message,
		' (',
		make_wikilink (
			table.concat (
				{
				cfg.messages['help page link'],
				'#',
				error_state.anchor
				}),
			cfg.messages['help page label']),
		')'
		});

	z.error_ids_t[error_id] = true;
	if z.error_ids_t['err_citation_missing_title'] and							-- if missing-title error already noted
		in_array (error_id, {'err_bare_url_missing_title', 'err_trans_missing_title'}) then		-- and this error is one of these
			return '', false;													-- don't bother because one flavor of missing title is sufficient
	end
	
	message = table.concat ({prefix, message, suffix});

	if true == raw then
		return message, error_state.hidden;										-- return message not wrapped in visible-error, hidden-error span tag
	end		

	message = error_comment (message, error_state.hidden);						-- wrap message in visible-error, hidden-error span tag
	table.insert (z.error_msgs_t, message);										-- add it to the messages sequence table
	return message;																-- and done; return value generally not used but is used as a flag in various functions of ~/Identifiers
end


--[[-------------------------&lt; I S _ A L I A S _ U S E D &gt;-----------------------------------------------------

This function is used by select_one() to determine if one of a list of alias parameters is in the argument list
provided by the template.

Input:
	args – pointer to the arguments table from calling template
	alias – one of the list of possible aliases in the aliases lists from Module:Citation/CS1/Configuration
	index – for enumerated parameters, identifies which one
	enumerated – true/false flag used to choose how enumerated aliases are examined
	value – value associated with an alias that has previously been selected; nil if not yet selected
	selected – the alias that has previously been selected; nil if not yet selected
	error_list – list of aliases that are duplicates of the alias already selected

Returns:
	value – value associated with alias we selected or that was previously selected or nil if an alias not yet selected
	selected – the alias we selected or the alias that was previously selected or nil if an alias not yet selected

]]

local function is_alias_used (args, alias, index, enumerated, value, selected, error_list)
	if enumerated then															-- is this a test for an enumerated parameters?
		alias = alias:gsub ('#', index);										-- replace '#' with the value in index
	else
		alias = alias:gsub ('#', '');											-- remove '#' if it exists
	end

	if is_set (args[alias]) then												-- alias is in the template's argument list
		if value ~= nil and selected ~= alias then								-- if we have already selected one of the aliases
			local skip;
			for _, v in ipairs (error_list) do									-- spin through the error list to see if we've added this alias
				if v == alias then
					skip = true;
					break;														-- has been added so stop looking 
				end
			end
			if not skip then													-- has not been added so
				table.insert (error_list, alias);								-- add error alias to the error list
			end
		else
			value = args[alias];												-- not yet selected an alias, so select this one
			selected = alias;
		end
	end
	return value, selected;														-- return newly selected alias, or previously selected alias
end


--[[--------------------------&lt; A D D _ M A I N T _ C A T &gt;------------------------------------------------------

Adds a category to z.maint_cats_t using names from the configuration file with additional text if any.
To prevent duplication, the added_maint_cats table lists the categories by key that have been added to z.maint_cats_t.

]]

local function add_maint_cat (key, arguments)
	if not added_maint_cats [key] then
		added_maint_cats [key] = true;											-- note that we've added this category
		table.insert (z.maint_cats_t, substitute (cfg.maint_cats [key], arguments));	-- make name then add to table
	end
end


--[[--------------------------&lt; A D D _ P R O P _ C A T &gt;--------------------------------------------------------

Adds a category to z.prop_cats_t using names from the configuration file with additional text if any.

foreign_lang_source and foreign_lang_source_2 keys have a language code appended to them so that multiple languages
may be categorized but multiples of the same language are not categorized.

added_prop_cats is a table declared in page scope variables above

]]

local added_prop_cats = {};														-- list of property categories that have been added to z.prop_cats_t

local function add_prop_cat (key, arguments, key_modifier)
	local key_modified = key .. ((key_modifier and key_modifier) or '');		-- modify &lt;key&gt; with &lt;key_modifier&gt; if present and not nil
	
	if not added_prop_cats [key_modified] then
		added_prop_cats [key_modified] = true;									-- note that we've added this category
		table.insert (z.prop_cats_t, substitute (cfg.prop_cats [key], arguments));	-- make name then add to table
		table.insert (z.prop_keys_t, 'cs1-prop-' .. key);						-- convert key to class for use in the citation's &lt;cite&gt; tag
	end
end


--[[--------------------------&lt; S A F E _ F O R _ I T A L I C S &gt;----------------------------------------------

Protects a string that will be wrapped in wiki italic markup '' ... ''

Note: We cannot use &lt;i&gt; for italics, as the expected behavior for italics specified by ''...'' in the title is that
they will be inverted (i.e. unitalicized) in the resulting references.  In addition, &lt;i&gt; and '' tend to interact
poorly under Mediawiki's HTML tidy.

]]

local function safe_for_italics (str)
	if not is_set (str) then return str end

	if str:sub (1, 1) == &quot;'&quot; then str = &quot;&lt;span&gt;&lt;/span&gt;&quot; .. str; end
	if str:sub (-1, -1) == &quot;'&quot; then str = str .. &quot;&lt;span&gt;&lt;/span&gt;&quot;; end
	
	return str:gsub ('\n', ' ');												-- Remove newlines as they break italics.
end


--[[--------------------------&lt; W R A P _ S T Y L E &gt;----------------------------------------------------------

Applies styling to various parameters.  Supplied string is wrapped using a message_list configuration taking one
argument; protects italic styled parameters.  Additional text taken from citation_config.presentation - the reason
this function is similar to but separate from wrap_msg().

]]

local function wrap_style (key, str)
	if not is_set (str) then
		return &quot;&quot;;
	elseif in_array (key, {'italic-title', 'trans-italic-title'}) then
		str = safe_for_italics (str);
	end

	return substitute (cfg.presentation[key], {str});
end


--[[--------------------------&lt; M A K E _ S E P _ L I S T &gt;------------------------------------------------------------

make a separated list of items using provided separators.
	&lt;sep_list&gt; - typically '&lt;comma&gt;&lt;space&gt;'
	&lt;sep_list_pair&gt; - typically '&lt;space&gt;and&lt;space&gt;'
	&lt;sep_list_end&gt; - typically '&lt;comma&gt;&lt;space&gt;and&lt;space&gt;' or '&lt;comma&gt;&lt;space&gt;&amp;&lt;space&gt;'

defaults to cfg.presentation['sep_list'], cfg.presentation['sep_list_pair'], and cfg.presentation['sep_list_end']
if &lt;sep_list_end&gt; is specified, &lt;sep_list&gt; and &lt;sep_list_pair&gt; must also be supplied

]]

local function make_sep_list (count, list_seq, sep_list, sep_list_pair, sep_list_end)
	local list = '';

	if not sep_list then														-- set the defaults
		sep_list = cfg.presentation['sep_list'];
		sep_list_pair = cfg.presentation['sep_list_pair'];
		sep_list_end = cfg.presentation['sep_list_end'];
	end
	
	if 2 &gt;= count then
		list = table.concat (list_seq, sep_list_pair);							-- insert separator between two items; returns list_seq[1] then only one item
	elseif 2 &lt; count then
		list = table.concat (list_seq, sep_list, 1, count - 1);					-- concatenate all but last item with plain list separator
		list = table.concat ({list, list_seq[count]}, sep_list_end);			-- concatenate last item onto end of &lt;list&gt; with final separator
	end
	
	return list;
end


--[[--------------------------&lt; S E L E C T _ O N E &gt;----------------------------------------------------------

Chooses one matching parameter from a list of parameters to consider.  The list of parameters to consider is just
names.  For parameters that may be enumerated, the position of the numerator in the parameter name is identified
by the '#' so |author-last1= and |author1-last= are represented as 'author-last#' and 'author#-last'.

Because enumerated parameter |&lt;param&gt;1= is an alias of |&lt;param&gt;= we must test for both possibilities.


Generates an error if more than one match is present.

]]

local function select_one (args, aliases_list, error_condition, index)
	local value = nil;															-- the value assigned to the selected parameter
	local selected = '';														-- the name of the parameter we have chosen
	local error_list = {};

	if index ~= nil then index = tostring(index); end

	for _, alias in ipairs (aliases_list) do									-- for each alias in the aliases list
		if alias:match ('#') then												-- if this alias can be enumerated
			if '1' == index then												-- when index is 1 test for enumerated and non-enumerated aliases
				value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);	-- first test for non-enumerated alias
			end
			value, selected = is_alias_used (args, alias, index, true, value, selected, error_list);	-- test for enumerated alias
		else
			value, selected = is_alias_used (args, alias, index, false, value, selected, error_list);	-- test for non-enumerated alias
		end
	end

	if #error_list &gt; 0 and 'none' ~= error_condition then						-- for cases where this code is used outside of extract_names()
		for i, v in ipairs (error_list) do
			error_list[i] = wrap_style ('parameter', v);
		end
		table.insert (error_list, wrap_style ('parameter', selected));
		set_message (error_condition, {make_sep_list (#error_list, error_list)});
	end
	
	return value, selected;
end


--[=[-------------------------&lt; R E M O V E _ W I K I _ L I N K &gt;----------------------------------------------

Gets the display text from a wikilink like [[A|B]] or [[B]] gives B

The str:gsub() returns either A|B froma [[A|B]] or B from [[B]] or B from B (no wikilink markup).

In l(), l:gsub() removes the link and pipe (if they exist); the second :gsub() trims whitespace from the label
if str was wrapped in wikilink markup.  Presumably, this is because without wikimarkup in str, there is no match
in the initial gsub, the replacement function l() doesn't get called.

]=]

local function remove_wiki_link (str)
	return (str:gsub (&quot;%[%[([^%[%]]*)%]%]&quot;, function(l)
		return l:gsub (&quot;^[^|]*|(.*)$&quot;, &quot;%1&quot; ):gsub (&quot;^%s*(.-)%s*$&quot;, &quot;%1&quot;);
	end));
end


--[=[-------------------------&lt; I S _ W I K I L I N K &gt;--------------------------------------------------------

Determines if str is a wikilink, extracts, and returns the wikilink type, link text, and display text parts.
If str is a complex wikilink ([[L|D]]):
	returns wl_type 2 and D and L from [[L|D]];
if str is a simple wikilink ([[D]])
	returns wl_type 1 and D from [[D]] and L as empty string;
if not a wikilink:
	returns wl_type 0, str as D, and L as empty string.

trims leading and trailing whitespace and pipes from L and D ([[L|]] and [[|D]] are accepted by MediaWiki and
treated like [[D]]; while [[|D|]] is not accepted by MediaWiki, here, we accept it and return D without the pipes).

]=]

local function is_wikilink (str)
	local D, L
	local wl_type = 2;															-- assume that str is a complex wikilink [[L|D]]

	if not str:match ('^%[%[[^%]]+%]%]$') then									-- is str some sort of a wikilink (must have some sort of content)
		return 0, str, '';														-- not a wikilink; return wl_type as 0, str as D, and empty string as L
	end
	
	L, D = str:match ('^%[%[([^|]+)|([^%]]+)%]%]$');							-- get L and D from [[L|D]] 

	if not is_set (D) then														-- if no separate display
		D = str:match ('^%[%[([^%]]*)|*%]%]$');									-- get D from [[D]] or [[D|]]
		wl_type = 1; 
	end
	
	D = mw.text.trim (D, '%s|');												-- trim white space and pipe characters 
	return wl_type, D, L or '';
end


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

Returns the argument without wiki markup and a number; the number is more-or-less meaningless except as a flag
to indicate that markup was replaced; do not rely on it as an indicator of how many of any kind of markup was
removed; returns the argument and nil when no markup removed

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then
		return argument, nil;													-- no argument, nothing to do
	end

	if nil == argument:find ( &quot;''&quot;, 1, true ) then								-- Is there at least one double apostrophe?  If not, exit.
		return argument, nil;
	end

	local flag;
	while true do
		if argument:find (&quot;'''''&quot;, 1, true) then								-- bold italic (5)
			argument, flag = argument:gsub (&quot;%'%'%'%'%'&quot;, &quot;&quot;);					-- remove all instances of it
		elseif argument:find (&quot;''''&quot;, 1, true) then								-- italic start and end without content (4)
			argument, flag=argument:gsub (&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find (&quot;'''&quot;, 1, true) then								-- bold (3)
			argument, flag=argument:gsub (&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find (&quot;''&quot;, 1, true) then								-- italic (2)
			argument, flag = argument:gsub (&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end

	return argument, flag;														-- done
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr)
	cfg = cfg_table_ptr;
	
end


--[[--------------------------&lt; E X P O R T S &gt;----------------------------------------------------------------
]]

return {
	add_maint_cat = add_maint_cat,												-- exported functions
	add_prop_cat = add_prop_cat,
	error_comment = error_comment,
	has_accept_as_written = has_accept_as_written,
	hyphen_to_dash = hyphen_to_dash,
	in_array = in_array,
	is_set = is_set,
	is_wikilink = is_wikilink,
	make_sep_list = make_sep_list,
	make_wikilink = make_wikilink,
	remove_wiki_link = remove_wiki_link,
	safe_for_italics = safe_for_italics,
	select_one = select_one,
	set_message = set_message,
	set_selected_modules = set_selected_modules,
	strip_apostrophe_markup = strip_apostrophe_markup,
	substitute = substitute,
	wrap_style = wrap_style,

	z = z,																		-- exported table
	}</text>
      <sha1>1rgyhapxi1dzuxmh3cqix2zrvvro8l2</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Citation/CS1/COinS</title>
    <ns>828</ns>
    <id>736</id>
    <revision>
      <id>4962</id>
      <timestamp>2015-12-15T19:02:26Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>create;</comment>
      <origin>4962</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="13215" sha1="7spos2whbz5818g2gxty3xsz6arccjh" xml:space="preserve">--[[
History of changes since last sync: 2015-12-12

]]

local coins = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array;															-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	if argument:find ( &quot;''&quot;, 1, true ) == nil then								-- Is there at least one double apostrophe?  If not, exit.
		return argument;
	end

	while true do
		if argument:find ( &quot;'''''&quot;, 1, true ) then								-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:find ( &quot;''''&quot;, 1, true ) then							-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;'''&quot;, 1, true ) then							-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;''&quot;, 1, true ) then								-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end


--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain html entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaced math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?
]]

local function coins_cleanup (value)
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;s&lt;/span&gt;', &quot;'s&quot;);	-- replace {{'s}} template with simple apostrophe-s
	value = value:gsub ('&amp;zwj;\226\128\138\039\226\128\139', &quot;'&quot;);				-- replace {{'}} with simple apostrophe
	value = value:gsub ('\226\128\138\039\226\128\139', &quot;'&quot;);					-- replace {{'}} with simple apostrophe (as of 2015-12-11)
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	value = value:gsub ('&amp;zwj;', '');											-- remove &amp;zwj; entities
	value = value:gsub ('[\226\128\141\226\128\139]', '')						-- remove zero-width joiner, zero-width space
	value = value:gsub ('[\194\173\009\010\013]', ' ');							-- replace soft hyphen, horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'journal', 'news'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if 'arxiv' == class then											-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	--{'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation
	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		if k == 'ISBN' then v = clean_isbn( v ) end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v };	-- others; provide a url
		end
	end

--[[	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
]]
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki strip markers, non-printing or invisible characers
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
end



return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	}</text>
      <sha1>7spos2whbz5818g2gxty3xsz6arccjh</sha1>
    </revision>
    <revision>
      <id>4963</id>
      <parentid>4962</parentid>
      <timestamp>2015-12-15T19:08:03Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4963</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="13261" sha1="930hx1bbv1kf3sg08hx4ev80l9orfjw" xml:space="preserve">--[[
History of changes since last sync: 2015-12-12

]]

local coins = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array;															-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	if argument:find ( &quot;''&quot;, 1, true ) == nil then								-- Is there at least one double apostrophe?  If not, exit.
		return argument;
	end

	while true do
		if argument:find ( &quot;'''''&quot;, 1, true ) then								-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:find ( &quot;''''&quot;, 1, true ) then							-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;'''&quot;, 1, true ) then							-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;''&quot;, 1, true ) then								-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end


--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain html entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaced math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?
]]

local function coins_cleanup (value)
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;s&lt;/span&gt;', &quot;'s&quot;);	-- replace {{'s}} template with simple apostrophe-s
	value = value:gsub ('&amp;zwj;\226\128\138\039\226\128\139', &quot;'&quot;);				-- replace {{'}} with simple apostrophe
	value = value:gsub ('\226\128\138\039\226\128\139', &quot;'&quot;);					-- replace {{'}} with simple apostrophe (as of 2015-12-11)
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	value = value:gsub ('&amp;zwj;', '');											-- remove &amp;zwj; entities
	value = value:gsub ('[\226\128\141\226\128\139]', '')						-- remove zero-width joiner, zero-width space
	value = value:gsub ('[\194\173\009\010\013]', ' ');							-- replace soft hyphen, horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'journal', 'news'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if 'arxiv' == class then											-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	--{'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation
	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		if k == 'ISBN' then v = clean_isbn( v ) end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v };	-- others; provide a url
		end
	end

--[[	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
]]
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki strip markers, non-printing or invisible characers
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
end



return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>930hx1bbv1kf3sg08hx4ev80l9orfjw</sha1>
    </revision>
    <revision>
      <id>4964</id>
      <parentid>4963</parentid>
      <timestamp>2015-12-15T19:19:52Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4964</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="13331" sha1="1negym8kiz50k1br1sgzbrg5ov60sb5" xml:space="preserve">--[[
History of changes since last sync: 2015-12-12

]]

local coins = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, remove_wiki_link;										-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	if argument:find ( &quot;''&quot;, 1, true ) == nil then								-- Is there at least one double apostrophe?  If not, exit.
		return argument;
	end

	while true do
		if argument:find ( &quot;'''''&quot;, 1, true ) then								-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:find ( &quot;''''&quot;, 1, true ) then							-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;'''&quot;, 1, true ) then							-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;''&quot;, 1, true ) then								-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end


--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain html entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaced math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?
]]

local function coins_cleanup (value)
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;s&lt;/span&gt;', &quot;'s&quot;);	-- replace {{'s}} template with simple apostrophe-s
	value = value:gsub ('&amp;zwj;\226\128\138\039\226\128\139', &quot;'&quot;);				-- replace {{'}} with simple apostrophe
	value = value:gsub ('\226\128\138\039\226\128\139', &quot;'&quot;);					-- replace {{'}} with simple apostrophe (as of 2015-12-11)
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	value = value:gsub ('&amp;zwj;', '');											-- remove &amp;zwj; entities
	value = value:gsub ('[\226\128\141\226\128\139]', '')						-- remove zero-width joiner, zero-width space
	value = value:gsub ('[\194\173\009\010\013]', ' ');							-- replace soft hyphen, horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'journal', 'news'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if 'arxiv' == class then											-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	--{'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation
	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		if k == 'ISBN' then v = clean_isbn( v ) end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v };	-- others; provide a url
		end
	end

--[[	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
]]
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki strip markers, non-printing or invisible characers
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	remove_wiki_link = utilities_page_ptr.remove_wiki_link;
end



return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>1negym8kiz50k1br1sgzbrg5ov60sb5</sha1>
    </revision>
    <revision>
      <id>4965</id>
      <parentid>4964</parentid>
      <timestamp>2015-12-15T19:24:31Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4965</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="13389" sha1="n6c9hqq12ok4ssm0b0xco2ti04ov8xc" xml:space="preserve">--[[
History of changes since last sync: 2015-12-12

]]

local coins = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, remove_wiki_link;										-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	if argument:find ( &quot;''&quot;, 1, true ) == nil then								-- Is there at least one double apostrophe?  If not, exit.
		return argument;
	end

	while true do
		if argument:find ( &quot;'''''&quot;, 1, true ) then								-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:find ( &quot;''''&quot;, 1, true ) then							-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;'''&quot;, 1, true ) then							-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;''&quot;, 1, true ) then								-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end


--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain html entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaced math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?
]]

local function coins_cleanup (value)
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;s&lt;/span&gt;', &quot;'s&quot;);	-- replace {{'s}} template with simple apostrophe-s
	value = value:gsub ('&amp;zwj;\226\128\138\039\226\128\139', &quot;'&quot;);				-- replace {{'}} with simple apostrophe
	value = value:gsub ('\226\128\138\039\226\128\139', &quot;'&quot;);					-- replace {{'}} with simple apostrophe (as of 2015-12-11)
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	value = value:gsub ('&amp;zwj;', '');											-- remove &amp;zwj; entities
	value = value:gsub ('[\226\128\141\226\128\139]', '')						-- remove zero-width joiner, zero-width space
	value = value:gsub ('[\194\173\009\010\013]', ' ');							-- replace soft hyphen, horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'journal', 'news'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if 'arxiv' == class then											-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	--{'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation
	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
--		if k == 'ISBN' then v = clean_isbn( v ) end
		if k == 'ISBN' then v = v:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; ); end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v };	-- others; provide a url
		end
	end

--[[	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
]]
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki strip markers, non-printing or invisible characers
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	remove_wiki_link = utilities_page_ptr.remove_wiki_link;
end



return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>n6c9hqq12ok4ssm0b0xco2ti04ov8xc</sha1>
    </revision>
    <revision>
      <id>4966</id>
      <parentid>4965</parentid>
      <timestamp>2015-12-17T18:38:08Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4966</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="15325" sha1="5ic1u8j5eo5q59f3hwmg8yq0ok7l53x" xml:space="preserve">--[[
History of changes since last sync: 2015-12-12

]]

local coins = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, remove_wiki_link;										-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	if argument:find ( &quot;''&quot;, 1, true ) == nil then								-- Is there at least one double apostrophe?  If not, exit.
		return argument;
	end

	while true do
		if argument:find ( &quot;'''''&quot;, 1, true ) then								-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:find ( &quot;''''&quot;, 1, true ) then							-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;'''&quot;, 1, true ) then							-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;''&quot;, 1, true ) then								-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end


--[=[-------------------------&lt; C O I N S _ R E P L A C E _ M A T H _ S T R I P M A R K E R &gt;------------------

There are three options for math markup that depends on the editor's math preference settings.  These settings
are at [[Special:Preferences#mw-prefsection-rendering]] and are
	PNG images
	TeX source
	MathML with SVG or PNG fallback

All three are heavy with html and css which don't belong in the metadata.

This function gets the rendered form of an equation according to the editor's preference.  It then searches the
rendering for the text equivalent of the rendered equation and replaces the rendering with that.

]=]

local function coins_replace_math_stripmarker (value)
	local stripmarker = '\127UNIQ%-%-math%-[%a%d]+%-QINU\127';					-- math stripmarker pattern
	local rendering = value:match (value);										-- is there a math stripmarker

	if not rendering then														-- when value doesn't have a math stripmarker, abandon this test
		return value;
	end
	
	rendering = mw.text.unstripNoWiki (stripmarker);							-- get the rendered value (or nil? ''? when math render error)
	
	if rendering:match ('alt=&quot;[^&quot;]+&quot;') then										-- if PNG math option
		rendering = rendering:match ('alt=&quot;([^&quot;]+)&quot;');							-- extract just the math text
	elseif rendering:match ('$%s+.+%s+%$') then									-- if TeX math option; $ is legit character that is escapes as \$
		rendering = rendering:match ('$%s+(.+)%s+%$')							-- extract just the math text
	elseif rendering:match ('&lt;annotation[^&gt;]+&gt;.+&lt;/annotation&gt;') then			-- if MathML math option
		rendering:match ('&lt;annotation[^&gt;]+&gt;(.+)&lt;/annotation&gt;')					-- extract just the math text
	else
		return value;															-- had math stripmarker but not one of the three defined forms
	end
	
	return value:gsub (stripmarker, rendering, 1);
end

--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain html entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaced math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?
]]

local function coins_cleanup (value)
	value = coins_replace_math_stripmarker (value);								-- replace math stripmarker with text representation of the equation
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;s&lt;/span&gt;', &quot;'s&quot;);	-- replace {{'s}} template with simple apostrophe-s
	value = value:gsub ('&amp;zwj;\226\128\138\039\226\128\139', &quot;'&quot;);				-- replace {{'}} with simple apostrophe
	value = value:gsub ('\226\128\138\039\226\128\139', &quot;'&quot;);					-- replace {{'}} with simple apostrophe (as of 2015-12-11)
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	value = value:gsub ('&amp;zwj;', '');											-- remove &amp;zwj; entities
	value = value:gsub ('[\226\128\141\226\128\139]', '')						-- remove zero-width joiner, zero-width space
	value = value:gsub ('[\194\173\009\010\013]', ' ');							-- replace soft hyphen, horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'journal', 'news'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if 'arxiv' == class then											-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	--{'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation
	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
--		if k == 'ISBN' then v = clean_isbn( v ) end
		if k == 'ISBN' then v = v:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; ); end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v };	-- others; provide a url
		end
	end

--[[	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
]]
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki strip markers, non-printing or invisible characers
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	remove_wiki_link = utilities_page_ptr.remove_wiki_link;
end



return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>5ic1u8j5eo5q59f3hwmg8yq0ok7l53x</sha1>
    </revision>
    <revision>
      <id>4967</id>
      <parentid>4966</parentid>
      <timestamp>2015-12-17T18:42:10Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4967</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="15378" sha1="fvcvv4nsjo9ew6fqovnrtlepqpjywnb" xml:space="preserve">--[[
History of changes since last sync: 2015-12-12

]]

local coins = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, remove_wiki_link;										-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	if argument:find ( &quot;''&quot;, 1, true ) == nil then								-- Is there at least one double apostrophe?  If not, exit.
		return argument;
	end

	while true do
		if argument:find ( &quot;'''''&quot;, 1, true ) then								-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:find ( &quot;''''&quot;, 1, true ) then							-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;'''&quot;, 1, true ) then							-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;''&quot;, 1, true ) then								-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end


--[=[-------------------------&lt; C O I N S _ R E P L A C E _ M A T H _ S T R I P M A R K E R &gt;------------------

There are three options for math markup that depends on the editor's math preference settings.  These settings
are at [[Special:Preferences#mw-prefsection-rendering]] and are
	PNG images
	TeX source
	MathML with SVG or PNG fallback

All three are heavy with html and css which don't belong in the metadata.

This function gets the rendered form of an equation according to the editor's preference.  It then searches the
rendering for the text equivalent of the rendered equation and replaces the rendering with that.

]=]

local function coins_replace_math_stripmarker (value)
	local stripmarker = '\127UNIQ%-%-math%-[%a%d]+%-QINU\127';					-- math stripmarker pattern
	local rendering = value:match (value);										-- is there a math stripmarker

	if not rendering then														-- when value doesn't have a math stripmarker, abandon this test
		return value;
	end
	
	rendering = mw.text.unstripNoWiki (stripmarker);							-- get the rendered value (or nil? ''? when math render error)
	
	if rendering:match ('alt=&quot;[^&quot;]+&quot;') then										-- if PNG math option
		rendering = rendering:match ('alt=&quot;([^&quot;]+)&quot;');							-- extract just the math text
	elseif rendering:match ('$%s+.+%s+%$') then									-- if TeX math option; $ is legit character that is escapes as \$
		rendering = rendering:match ('$%s+(.+)%s+%$')							-- extract just the math text
	elseif rendering:match ('&lt;annotation[^&gt;]+&gt;.+&lt;/annotation&gt;') then			-- if MathML math option
		rendering:match ('&lt;annotation[^&gt;]+&gt;(.+)&lt;/annotation&gt;')					-- extract just the math text
	else
--		return value;															-- had math stripmarker but not one of the three defined forms
		return value:gsub (stripmarker, 'rendering', 1);
	end
	
	return value:gsub (stripmarker, rendering, 1);
end

--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain html entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaced math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?
]]

local function coins_cleanup (value)
	value = coins_replace_math_stripmarker (value);								-- replace math stripmarker with text representation of the equation
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;s&lt;/span&gt;', &quot;'s&quot;);	-- replace {{'s}} template with simple apostrophe-s
	value = value:gsub ('&amp;zwj;\226\128\138\039\226\128\139', &quot;'&quot;);				-- replace {{'}} with simple apostrophe
	value = value:gsub ('\226\128\138\039\226\128\139', &quot;'&quot;);					-- replace {{'}} with simple apostrophe (as of 2015-12-11)
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	value = value:gsub ('&amp;zwj;', '');											-- remove &amp;zwj; entities
	value = value:gsub ('[\226\128\141\226\128\139]', '')						-- remove zero-width joiner, zero-width space
	value = value:gsub ('[\194\173\009\010\013]', ' ');							-- replace soft hyphen, horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'journal', 'news'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if 'arxiv' == class then											-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	--{'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation
	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
--		if k == 'ISBN' then v = clean_isbn( v ) end
		if k == 'ISBN' then v = v:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; ); end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v };	-- others; provide a url
		end
	end

--[[	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
]]
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki strip markers, non-printing or invisible characers
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	remove_wiki_link = utilities_page_ptr.remove_wiki_link;
end



return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>fvcvv4nsjo9ew6fqovnrtlepqpjywnb</sha1>
    </revision>
    <revision>
      <id>4968</id>
      <parentid>4967</parentid>
      <timestamp>2015-12-17T18:43:58Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4968</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="15353" sha1="fpy021wkjrgiuecn5wgm1be030b2mlt" xml:space="preserve">--[[
History of changes since last sync: 2015-12-12

]]

local coins = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, remove_wiki_link;										-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	if argument:find ( &quot;''&quot;, 1, true ) == nil then								-- Is there at least one double apostrophe?  If not, exit.
		return argument;
	end

	while true do
		if argument:find ( &quot;'''''&quot;, 1, true ) then								-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:find ( &quot;''''&quot;, 1, true ) then							-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;'''&quot;, 1, true ) then							-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;''&quot;, 1, true ) then								-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end


--[=[-------------------------&lt; C O I N S _ R E P L A C E _ M A T H _ S T R I P M A R K E R &gt;------------------

There are three options for math markup that depends on the editor's math preference settings.  These settings
are at [[Special:Preferences#mw-prefsection-rendering]] and are
	PNG images
	TeX source
	MathML with SVG or PNG fallback

All three are heavy with html and css which don't belong in the metadata.

This function gets the rendered form of an equation according to the editor's preference.  It then searches the
rendering for the text equivalent of the rendered equation and replaces the rendering with that.

]=]

local function coins_replace_math_stripmarker (value)
	local stripmarker = '\127UNIQ%-%-math%-[%a%d]+%-QINU\127';					-- math stripmarker pattern
	local rendering = value:match (value);										-- is there a math stripmarker

	if not rendering then														-- when value doesn't have a math stripmarker, abandon this test
		return 'not rendering';
--		return value;
	end
	
	rendering = mw.text.unstripNoWiki (stripmarker);							-- get the rendered value (or nil? ''? when math render error)
	
	if rendering:match ('alt=&quot;[^&quot;]+&quot;') then										-- if PNG math option
		rendering = rendering:match ('alt=&quot;([^&quot;]+)&quot;');							-- extract just the math text
	elseif rendering:match ('$%s+.+%s+%$') then									-- if TeX math option; $ is legit character that is escapes as \$
		rendering = rendering:match ('$%s+(.+)%s+%$')							-- extract just the math text
	elseif rendering:match ('&lt;annotation[^&gt;]+&gt;.+&lt;/annotation&gt;') then			-- if MathML math option
		rendering:match ('&lt;annotation[^&gt;]+&gt;(.+)&lt;/annotation&gt;')					-- extract just the math text
	else
		return value;															-- had math stripmarker but not one of the three defined forms
	end
	
	return value:gsub (stripmarker, rendering, 1);
end

--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain html entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaced math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?
]]

local function coins_cleanup (value)
	value = coins_replace_math_stripmarker (value);								-- replace math stripmarker with text representation of the equation
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;s&lt;/span&gt;', &quot;'s&quot;);	-- replace {{'s}} template with simple apostrophe-s
	value = value:gsub ('&amp;zwj;\226\128\138\039\226\128\139', &quot;'&quot;);				-- replace {{'}} with simple apostrophe
	value = value:gsub ('\226\128\138\039\226\128\139', &quot;'&quot;);					-- replace {{'}} with simple apostrophe (as of 2015-12-11)
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	value = value:gsub ('&amp;zwj;', '');											-- remove &amp;zwj; entities
	value = value:gsub ('[\226\128\141\226\128\139]', '')						-- remove zero-width joiner, zero-width space
	value = value:gsub ('[\194\173\009\010\013]', ' ');							-- replace soft hyphen, horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'journal', 'news'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if 'arxiv' == class then											-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	--{'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation
	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
--		if k == 'ISBN' then v = clean_isbn( v ) end
		if k == 'ISBN' then v = v:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; ); end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v };	-- others; provide a url
		end
	end

--[[	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
]]
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki strip markers, non-printing or invisible characers
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	remove_wiki_link = utilities_page_ptr.remove_wiki_link;
end



return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>fpy021wkjrgiuecn5wgm1be030b2mlt</sha1>
    </revision>
    <revision>
      <id>4969</id>
      <parentid>4968</parentid>
      <timestamp>2015-12-17T18:44:55Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4969</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="15329" sha1="jtn5yq9fh4164t2wjmy0hypa6pyetbe" xml:space="preserve">--[[
History of changes since last sync: 2015-12-12

]]

local coins = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, remove_wiki_link;										-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	if argument:find ( &quot;''&quot;, 1, true ) == nil then								-- Is there at least one double apostrophe?  If not, exit.
		return argument;
	end

	while true do
		if argument:find ( &quot;'''''&quot;, 1, true ) then								-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:find ( &quot;''''&quot;, 1, true ) then							-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;'''&quot;, 1, true ) then							-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;''&quot;, 1, true ) then								-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end


--[=[-------------------------&lt; C O I N S _ R E P L A C E _ M A T H _ S T R I P M A R K E R &gt;------------------

There are three options for math markup that depends on the editor's math preference settings.  These settings
are at [[Special:Preferences#mw-prefsection-rendering]] and are
	PNG images
	TeX source
	MathML with SVG or PNG fallback

All three are heavy with html and css which don't belong in the metadata.

This function gets the rendered form of an equation according to the editor's preference.  It then searches the
rendering for the text equivalent of the rendered equation and replaces the rendering with that.

]=]

local function coins_replace_math_stripmarker (value)
	local stripmarker = '\127UNIQ%-%-math%-[%a%d]+%-QINU\127';					-- math stripmarker pattern
	local rendering = value:match (stripmarker);								-- is there a math stripmarker

	if not rendering then														-- when value doesn't have a math stripmarker, abandon this test
		return value;
	end
	
	rendering = mw.text.unstripNoWiki (stripmarker);							-- get the rendered value (or nil? ''? when math render error)
	
	if rendering:match ('alt=&quot;[^&quot;]+&quot;') then										-- if PNG math option
		rendering = rendering:match ('alt=&quot;([^&quot;]+)&quot;');							-- extract just the math text
	elseif rendering:match ('$%s+.+%s+%$') then									-- if TeX math option; $ is legit character that is escapes as \$
		rendering = rendering:match ('$%s+(.+)%s+%$')							-- extract just the math text
	elseif rendering:match ('&lt;annotation[^&gt;]+&gt;.+&lt;/annotation&gt;') then			-- if MathML math option
		rendering:match ('&lt;annotation[^&gt;]+&gt;(.+)&lt;/annotation&gt;')					-- extract just the math text
	else
		return value;															-- had math stripmarker but not one of the three defined forms
	end
	
	return value:gsub (stripmarker, rendering, 1);
end

--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain html entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaced math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?
]]

local function coins_cleanup (value)
	value = coins_replace_math_stripmarker (value);								-- replace math stripmarker with text representation of the equation
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;s&lt;/span&gt;', &quot;'s&quot;);	-- replace {{'s}} template with simple apostrophe-s
	value = value:gsub ('&amp;zwj;\226\128\138\039\226\128\139', &quot;'&quot;);				-- replace {{'}} with simple apostrophe
	value = value:gsub ('\226\128\138\039\226\128\139', &quot;'&quot;);					-- replace {{'}} with simple apostrophe (as of 2015-12-11)
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	value = value:gsub ('&amp;zwj;', '');											-- remove &amp;zwj; entities
	value = value:gsub ('[\226\128\141\226\128\139]', '')						-- remove zero-width joiner, zero-width space
	value = value:gsub ('[\194\173\009\010\013]', ' ');							-- replace soft hyphen, horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'journal', 'news'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if 'arxiv' == class then											-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	--{'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation
	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
--		if k == 'ISBN' then v = clean_isbn( v ) end
		if k == 'ISBN' then v = v:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; ); end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v };	-- others; provide a url
		end
	end

--[[	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
]]
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki strip markers, non-printing or invisible characers
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	remove_wiki_link = utilities_page_ptr.remove_wiki_link;
end



return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>jtn5yq9fh4164t2wjmy0hypa6pyetbe</sha1>
    </revision>
    <revision>
      <id>4970</id>
      <parentid>4969</parentid>
      <timestamp>2015-12-17T18:47:04Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4970</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="15345" sha1="odol8y2simylsizj636x4mhypqw5q93" xml:space="preserve">--[[
History of changes since last sync: 2015-12-12

]]

local coins = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, remove_wiki_link;										-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	if argument:find ( &quot;''&quot;, 1, true ) == nil then								-- Is there at least one double apostrophe?  If not, exit.
		return argument;
	end

	while true do
		if argument:find ( &quot;'''''&quot;, 1, true ) then								-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:find ( &quot;''''&quot;, 1, true ) then							-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;'''&quot;, 1, true ) then							-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;''&quot;, 1, true ) then								-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end


--[=[-------------------------&lt; C O I N S _ R E P L A C E _ M A T H _ S T R I P M A R K E R &gt;------------------

There are three options for math markup that depends on the editor's math preference settings.  These settings
are at [[Special:Preferences#mw-prefsection-rendering]] and are
	PNG images
	TeX source
	MathML with SVG or PNG fallback

All three are heavy with html and css which don't belong in the metadata.

This function gets the rendered form of an equation according to the editor's preference.  It then searches the
rendering for the text equivalent of the rendered equation and replaces the rendering with that.

]=]

local function coins_replace_math_stripmarker (value)
	local stripmarker = '\127UNIQ%-%-math%-[%a%d]+%-QINU\127';					-- math stripmarker pattern
	local rendering = value:match (stripmarker);								-- is there a math stripmarker

	if not rendering then														-- when value doesn't have a math stripmarker, abandon this test
		return value;
	end
	
	rendering = mw.text.unstripNoWiki (rendering);								-- convert stripmarker into rendered value (or nil? ''? when math render error)
	
	if rendering:match ('alt=&quot;[^&quot;]+&quot;') then										-- if PNG math option
		rendering = rendering:match ('alt=&quot;([^&quot;]+)&quot;');							-- extract just the math text
	elseif rendering:match ('$%s+.+%s+%$') then									-- if TeX math option; $ is legit character that is escapes as \$
		rendering = rendering:match ('$%s+(.+)%s+%$')							-- extract just the math text
	elseif rendering:match ('&lt;annotation[^&gt;]+&gt;.+&lt;/annotation&gt;') then			-- if MathML math option
		rendering:match ('&lt;annotation[^&gt;]+&gt;(.+)&lt;/annotation&gt;')					-- extract just the math text
	else
		return value;															-- had math stripmarker but not one of the three defined forms
	end
	
	return value:gsub (stripmarker, rendering, 1);
end

--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain html entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaced math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?
]]

local function coins_cleanup (value)
	value = coins_replace_math_stripmarker (value);								-- replace math stripmarker with text representation of the equation
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;s&lt;/span&gt;', &quot;'s&quot;);	-- replace {{'s}} template with simple apostrophe-s
	value = value:gsub ('&amp;zwj;\226\128\138\039\226\128\139', &quot;'&quot;);				-- replace {{'}} with simple apostrophe
	value = value:gsub ('\226\128\138\039\226\128\139', &quot;'&quot;);					-- replace {{'}} with simple apostrophe (as of 2015-12-11)
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	value = value:gsub ('&amp;zwj;', '');											-- remove &amp;zwj; entities
	value = value:gsub ('[\226\128\141\226\128\139]', '')						-- remove zero-width joiner, zero-width space
	value = value:gsub ('[\194\173\009\010\013]', ' ');							-- replace soft hyphen, horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'journal', 'news'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if 'arxiv' == class then											-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	--{'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation
	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
--		if k == 'ISBN' then v = clean_isbn( v ) end
		if k == 'ISBN' then v = v:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; ); end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v };	-- others; provide a url
		end
	end

--[[	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
]]
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki strip markers, non-printing or invisible characers
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	remove_wiki_link = utilities_page_ptr.remove_wiki_link;
end



return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>odol8y2simylsizj636x4mhypqw5q93</sha1>
    </revision>
    <revision>
      <id>4971</id>
      <parentid>4970</parentid>
      <timestamp>2015-12-17T18:57:56Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4971</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="15373" sha1="pn0j0yp05datltlq2vrwbqs9tkxjegh" xml:space="preserve">--[[
History of changes since last sync: 2015-12-12

]]

local coins = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, remove_wiki_link;										-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	if argument:find ( &quot;''&quot;, 1, true ) == nil then								-- Is there at least one double apostrophe?  If not, exit.
		return argument;
	end

	while true do
		if argument:find ( &quot;'''''&quot;, 1, true ) then								-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:find ( &quot;''''&quot;, 1, true ) then							-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;'''&quot;, 1, true ) then							-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;''&quot;, 1, true ) then								-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end


--[=[-------------------------&lt; C O I N S _ R E P L A C E _ M A T H _ S T R I P M A R K E R &gt;------------------

There are three options for math markup that depends on the editor's math preference settings.  These settings
are at [[Special:Preferences#mw-prefsection-rendering]] and are
	PNG images
	TeX source
	MathML with SVG or PNG fallback

All three are heavy with html and css which don't belong in the metadata.

This function gets the rendered form of an equation according to the editor's preference.  It then searches the
rendering for the text equivalent of the rendered equation and replaces the rendering with that.

]=]

local function coins_replace_math_stripmarker (value)
	local stripmarker = '\127UNIQ%-%-math%-[%a%d]+%-QINU\127';					-- math stripmarker pattern
	local rendering = value:match (stripmarker);								-- is there a math stripmarker

	if not rendering then														-- when value doesn't have a math stripmarker, abandon this test
		return 'not rendering';
--		return value;
	end
	
	rendering = mw.text.unstripNoWiki (rendering);								-- convert stripmarker into rendered value (or nil? ''? when math render error)
	
	if rendering:match ('alt=&quot;[^&quot;]+&quot;') then										-- if PNG math option
		rendering = rendering:match ('alt=&quot;([^&quot;]+)&quot;');							-- extract just the math text
	elseif rendering:match ('$%s+.+%s+%$') then									-- if TeX math option; $ is legit character that is escapes as \$
		rendering = rendering:match ('$%s+(.+)%s+%$')							-- extract just the math text
	elseif rendering:match ('&lt;annotation[^&gt;]+&gt;.+&lt;/annotation&gt;') then			-- if MathML math option
		rendering:match ('&lt;annotation[^&gt;]+&gt;(.+)&lt;/annotation&gt;')					-- extract just the math text
	else
		return value;															-- had math stripmarker but not one of the three defined forms
	end
	
	return value:gsub (stripmarker, rendering, 1);
end

--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain html entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaced math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?
]]

local function coins_cleanup (value)
	value = coins_replace_math_stripmarker (value);								-- replace math stripmarker with text representation of the equation
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;s&lt;/span&gt;', &quot;'s&quot;);	-- replace {{'s}} template with simple apostrophe-s
	value = value:gsub ('&amp;zwj;\226\128\138\039\226\128\139', &quot;'&quot;);				-- replace {{'}} with simple apostrophe
	value = value:gsub ('\226\128\138\039\226\128\139', &quot;'&quot;);					-- replace {{'}} with simple apostrophe (as of 2015-12-11)
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	value = value:gsub ('&amp;zwj;', '');											-- remove &amp;zwj; entities
	value = value:gsub ('[\226\128\141\226\128\139]', '')						-- remove zero-width joiner, zero-width space
	value = value:gsub ('[\194\173\009\010\013]', ' ');							-- replace soft hyphen, horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'journal', 'news'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if 'arxiv' == class then											-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	--{'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation
	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
--		if k == 'ISBN' then v = clean_isbn( v ) end
		if k == 'ISBN' then v = v:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; ); end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v };	-- others; provide a url
		end
	end

--[[	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
]]
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki strip markers, non-printing or invisible characers
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	remove_wiki_link = utilities_page_ptr.remove_wiki_link;
end



return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>pn0j0yp05datltlq2vrwbqs9tkxjegh</sha1>
    </revision>
    <revision>
      <id>4972</id>
      <parentid>4971</parentid>
      <timestamp>2015-12-17T18:59:08Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4972</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="15382" sha1="4e43atrm4nh9c89ix8tti03j2m4ssgp" xml:space="preserve">--[[
History of changes since last sync: 2015-12-12

]]

local coins = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, remove_wiki_link;										-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	if argument:find ( &quot;''&quot;, 1, true ) == nil then								-- Is there at least one double apostrophe?  If not, exit.
		return argument;
	end

	while true do
		if argument:find ( &quot;'''''&quot;, 1, true ) then								-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:find ( &quot;''''&quot;, 1, true ) then							-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;'''&quot;, 1, true ) then							-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;''&quot;, 1, true ) then								-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end


--[=[-------------------------&lt; C O I N S _ R E P L A C E _ M A T H _ S T R I P M A R K E R &gt;------------------

There are three options for math markup that depends on the editor's math preference settings.  These settings
are at [[Special:Preferences#mw-prefsection-rendering]] and are
	PNG images
	TeX source
	MathML with SVG or PNG fallback

All three are heavy with html and css which don't belong in the metadata.

This function gets the rendered form of an equation according to the editor's preference.  It then searches the
rendering for the text equivalent of the rendered equation and replaces the rendering with that.

]=]

local function coins_replace_math_stripmarker (value)
	local stripmarker = '\127UNIQ%-%-math%-[%a%d]+%-QINU\127';					-- math stripmarker pattern
	local rendering = value:match (stripmarker);								-- is there a math stripmarker

	if not rendering then														-- when value doesn't have a math stripmarker, abandon this test
--		return 'not rendering';
		return value;
	end
	
	rendering = mw.text.unstripNoWiki (rendering);								-- convert stripmarker into rendered value (or nil? ''? when math render error)
	
	if rendering:match ('alt=&quot;[^&quot;]+&quot;') then										-- if PNG math option
		rendering = rendering:match ('alt=&quot;([^&quot;]+)&quot;');							-- extract just the math text
	elseif rendering:match ('$%s+.+%s+%$') then									-- if TeX math option; $ is legit character that is escapes as \$
		rendering = rendering:match ('$%s+(.+)%s+%$')							-- extract just the math text
	elseif rendering:match ('&lt;annotation[^&gt;]+&gt;.+&lt;/annotation&gt;') then			-- if MathML math option
		rendering = rendering:match ('&lt;annotation[^&gt;]+&gt;(.+)&lt;/annotation&gt;')		-- extract just the math text
	else
		return value;															-- had math stripmarker but not one of the three defined forms
	end
	
	return value:gsub (stripmarker, rendering, 1);
end

--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain html entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaced math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?
]]

local function coins_cleanup (value)
	value = coins_replace_math_stripmarker (value);								-- replace math stripmarker with text representation of the equation
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;s&lt;/span&gt;', &quot;'s&quot;);	-- replace {{'s}} template with simple apostrophe-s
	value = value:gsub ('&amp;zwj;\226\128\138\039\226\128\139', &quot;'&quot;);				-- replace {{'}} with simple apostrophe
	value = value:gsub ('\226\128\138\039\226\128\139', &quot;'&quot;);					-- replace {{'}} with simple apostrophe (as of 2015-12-11)
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	value = value:gsub ('&amp;zwj;', '');											-- remove &amp;zwj; entities
	value = value:gsub ('[\226\128\141\226\128\139]', '')						-- remove zero-width joiner, zero-width space
	value = value:gsub ('[\194\173\009\010\013]', ' ');							-- replace soft hyphen, horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'journal', 'news'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if 'arxiv' == class then											-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	--{'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation
	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
--		if k == 'ISBN' then v = clean_isbn( v ) end
		if k == 'ISBN' then v = v:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; ); end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v };	-- others; provide a url
		end
	end

--[[	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
]]
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki strip markers, non-printing or invisible characers
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	remove_wiki_link = utilities_page_ptr.remove_wiki_link;
end



return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>4e43atrm4nh9c89ix8tti03j2m4ssgp</sha1>
    </revision>
    <revision>
      <id>4973</id>
      <parentid>4972</parentid>
      <timestamp>2015-12-17T19:16:53Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4973</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="15382" sha1="9d4zlu1ds6m7funazlgjk2d93j8zgyy" xml:space="preserve">--[[
History of changes since last sync: 2015-12-12

]]

local coins = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, remove_wiki_link;										-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	if argument:find ( &quot;''&quot;, 1, true ) == nil then								-- Is there at least one double apostrophe?  If not, exit.
		return argument;
	end

	while true do
		if argument:find ( &quot;'''''&quot;, 1, true ) then								-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:find ( &quot;''''&quot;, 1, true ) then							-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;'''&quot;, 1, true ) then							-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;''&quot;, 1, true ) then								-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end


--[=[-------------------------&lt; C O I N S _ R E P L A C E _ M A T H _ S T R I P M A R K E R &gt;------------------

There are three options for math markup that depends on the editor's math preference settings.  These settings
are at [[Special:Preferences#mw-prefsection-rendering]] and are
	PNG images
	TeX source
	MathML with SVG or PNG fallback

All three are heavy with html and css which don't belong in the metadata.

This function gets the rendered form of an equation according to the editor's preference.  It then searches the
rendering for the text equivalent of the rendered equation and replaces the rendering with that.

]=]

local function coins_replace_math_stripmarker (value)
	local stripmarker = '\127UNIQ%-%-math%-[%a%d]+%-QINU\127';					-- math stripmarker pattern
	local rendering = value:match (stripmarker);								-- is there a math stripmarker

	if not rendering then														-- when value doesn't have a math stripmarker, abandon this test
		return 'not rendering';
--		return value;
	end
	
	rendering = mw.text.unstripNoWiki (rendering);								-- convert stripmarker into rendered value (or nil? ''? when math render error)
	
	if rendering:match ('alt=&quot;[^&quot;]+&quot;') then										-- if PNG math option
		rendering = rendering:match ('alt=&quot;([^&quot;]+)&quot;');							-- extract just the math text
	elseif rendering:match ('$%s+.+%s+%$') then									-- if TeX math option; $ is legit character that is escapes as \$
		rendering = rendering:match ('$%s+(.+)%s+%$')							-- extract just the math text
	elseif rendering:match ('&lt;annotation[^&gt;]+&gt;.+&lt;/annotation&gt;') then			-- if MathML math option
		rendering = rendering:match ('&lt;annotation[^&gt;]+&gt;(.+)&lt;/annotation&gt;')		-- extract just the math text
	else
		return value;															-- had math stripmarker but not one of the three defined forms
	end
	
	return value:gsub (stripmarker, rendering, 1);
end

--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain html entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaced math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?
]]

local function coins_cleanup (value)
	value = coins_replace_math_stripmarker (value);								-- replace math stripmarker with text representation of the equation
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;s&lt;/span&gt;', &quot;'s&quot;);	-- replace {{'s}} template with simple apostrophe-s
	value = value:gsub ('&amp;zwj;\226\128\138\039\226\128\139', &quot;'&quot;);				-- replace {{'}} with simple apostrophe
	value = value:gsub ('\226\128\138\039\226\128\139', &quot;'&quot;);					-- replace {{'}} with simple apostrophe (as of 2015-12-11)
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	value = value:gsub ('&amp;zwj;', '');											-- remove &amp;zwj; entities
	value = value:gsub ('[\226\128\141\226\128\139]', '')						-- remove zero-width joiner, zero-width space
	value = value:gsub ('[\194\173\009\010\013]', ' ');							-- replace soft hyphen, horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'journal', 'news'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if 'arxiv' == class then											-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	--{'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation
	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
--		if k == 'ISBN' then v = clean_isbn( v ) end
		if k == 'ISBN' then v = v:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; ); end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v };	-- others; provide a url
		end
	end

--[[	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
]]
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki strip markers, non-printing or invisible characers
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	remove_wiki_link = utilities_page_ptr.remove_wiki_link;
end



return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>9d4zlu1ds6m7funazlgjk2d93j8zgyy</sha1>
    </revision>
    <revision>
      <id>4974</id>
      <parentid>4973</parentid>
      <timestamp>2015-12-17T19:20:53Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4974</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="15469" sha1="65xhrqo4mysv34c2tlasxluxsulhp9x" xml:space="preserve">--[[
History of changes since last sync: 2015-12-12

]]

local coins = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, remove_wiki_link;										-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	if argument:find ( &quot;''&quot;, 1, true ) == nil then								-- Is there at least one double apostrophe?  If not, exit.
		return argument;
	end

	while true do
		if argument:find ( &quot;'''''&quot;, 1, true ) then								-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:find ( &quot;''''&quot;, 1, true ) then							-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;'''&quot;, 1, true ) then							-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;''&quot;, 1, true ) then								-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end


--[=[-------------------------&lt; C O I N S _ R E P L A C E _ M A T H _ S T R I P M A R K E R &gt;------------------

There are three options for math markup that depends on the editor's math preference settings.  These settings
are at [[Special:Preferences#mw-prefsection-rendering]] and are
	PNG images
	TeX source
	MathML with SVG or PNG fallback

All three are heavy with html and css which don't belong in the metadata.

This function gets the rendered form of an equation according to the editor's preference.  It then searches the
rendering for the text equivalent of the rendered equation and replaces the rendering with that.

]=]

local function coins_replace_math_stripmarker (value)
	local stripmarker = '\127UNIQ%-%-math%-[%a%d]+%-QINU\127';					-- math stripmarker pattern
	local rendering = value:match (stripmarker);								-- is there a math stripmarker

	if not rendering then														-- when value doesn't have a math stripmarker, abandon this test
--		return 'not rendering';
		return value;
	end
	
	rendering = mw.text.unstripNoWiki (rendering);								-- convert stripmarker into rendered value (or nil? ''? when math render error)
	
	if rendering:match ('alt=&quot;[^&quot;]+&quot;') then										-- if PNG math option
		rendering = rendering:match ('alt=&quot;([^&quot;]+)&quot;');							-- extract just the math text
	elseif rendering:match ('$%s+.+%s+%$') then									-- if TeX math option; $ is legit character that is escapes as \$
		rendering = rendering:match ('$%s+(.+)%s+%$')							-- extract just the math text
	elseif rendering:match ('&lt;annotation[^&gt;]+&gt;.+&lt;/annotation&gt;') then			-- if MathML math option
		rendering = rendering:match ('&lt;annotation[^&gt;]+&gt;(.+)&lt;/annotation&gt;')		-- extract just the math text
	else
		return value;															-- had math stripmarker but not one of the three defined forms
	end
	
	return value:gsub (stripmarker, rendering, 1);
end

--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain html entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaced math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?
]]

local function coins_cleanup (value)
	value = coins_replace_math_stripmarker (value);								-- replace math stripmarker with text representation of the equation
	value = value:gsub ('\127UNIQ%-%-math%-[%a%d]+%-QINU\127', &quot;MATH RENDER ERROR&quot;);	-- 

	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;s&lt;/span&gt;', &quot;'s&quot;);	-- replace {{'s}} template with simple apostrophe-s
	value = value:gsub ('&amp;zwj;\226\128\138\039\226\128\139', &quot;'&quot;);				-- replace {{'}} with simple apostrophe
	value = value:gsub ('\226\128\138\039\226\128\139', &quot;'&quot;);					-- replace {{'}} with simple apostrophe (as of 2015-12-11)
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	value = value:gsub ('&amp;zwj;', '');											-- remove &amp;zwj; entities
	value = value:gsub ('[\226\128\141\226\128\139]', '')						-- remove zero-width joiner, zero-width space
	value = value:gsub ('[\194\173\009\010\013]', ' ');							-- replace soft hyphen, horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'journal', 'news'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if 'arxiv' == class then											-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	--{'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation
	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
--		if k == 'ISBN' then v = clean_isbn( v ) end
		if k == 'ISBN' then v = v:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; ); end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v };	-- others; provide a url
		end
	end

--[[	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
]]
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki strip markers, non-printing or invisible characers
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	remove_wiki_link = utilities_page_ptr.remove_wiki_link;
end



return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>65xhrqo4mysv34c2tlasxluxsulhp9x</sha1>
    </revision>
    <revision>
      <id>4975</id>
      <parentid>4974</parentid>
      <timestamp>2015-12-17T19:28:55Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4975</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="15690" sha1="eskxb181toenxv7agpv6rom02az7owo" xml:space="preserve">--[[
History of changes since last sync: 2015-12-12

]]

local coins = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, remove_wiki_link;										-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	if argument:find ( &quot;''&quot;, 1, true ) == nil then								-- Is there at least one double apostrophe?  If not, exit.
		return argument;
	end

	while true do
		if argument:find ( &quot;'''''&quot;, 1, true ) then								-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:find ( &quot;''''&quot;, 1, true ) then							-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;'''&quot;, 1, true ) then							-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;''&quot;, 1, true ) then								-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end


--[=[-------------------------&lt; C O I N S _ R E P L A C E _ M A T H _ S T R I P M A R K E R &gt;------------------

There are three options for math markup that depends on the editor's math preference settings.  These settings
are at [[Special:Preferences#mw-prefsection-rendering]] and are
	PNG images
	TeX source
	MathML with SVG or PNG fallback

All three are heavy with html and css which don't belong in the metadata.

This function gets the rendered form of an equation according to the editor's preference.  It then searches the
rendering for the text equivalent of the rendered equation and replaces the rendering with that.

When a replacement is made, this function returns true and the value with replacement

]=]

local function coins_replace_math_stripmarker (value)
	local stripmarker = '\127UNIQ%-%-math%-[%a%d]+%-QINU\127';					-- math stripmarker pattern
	local rendering = value:match (stripmarker);								-- is there a math stripmarker

	if not rendering then														-- when value doesn't have a math stripmarker, abandon this test
--		return 'not rendering';
		return false, value;
	end
	
	rendering = mw.text.unstripNoWiki (rendering);								-- convert stripmarker into rendered value (or nil? ''? when math render error)
	
	if rendering:match ('alt=&quot;[^&quot;]+&quot;') then										-- if PNG math option
		rendering = rendering:match ('alt=&quot;([^&quot;]+)&quot;');							-- extract just the math text
	elseif rendering:match ('$%s+.+%s+%$') then									-- if TeX math option; $ is legit character that is escapes as \$
		rendering = rendering:match ('$%s+(.+)%s+%$')							-- extract just the math text
	elseif rendering:match ('&lt;annotation[^&gt;]+&gt;.+&lt;/annotation&gt;') then			-- if MathML math option
		rendering = rendering:match ('&lt;annotation[^&gt;]+&gt;(.+)&lt;/annotation&gt;')		-- extract just the math text
	else
		return false, value;													-- had math stripmarker but not one of the three defined forms
	end
	
	return true, value:gsub (stripmarker, rendering, 1);
end

--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain html entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaced math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?
]]

local function coins_cleanup (value)
	local replaced = true;														-- default state to get the do loop running
	
	while replaced do
		replaced, value = coins_replace_math_stripmarker (value);				-- replace math stripmarker with text representation of the equation
	end

	value = value:gsub ('\127UNIQ%-%-math%-[%a%d]+%-QINU\127', &quot;MATH RENDER ERROR&quot;);	-- 
	
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;s&lt;/span&gt;', &quot;'s&quot;);	-- replace {{'s}} template with simple apostrophe-s
	value = value:gsub ('&amp;zwj;\226\128\138\039\226\128\139', &quot;'&quot;);				-- replace {{'}} with simple apostrophe
	value = value:gsub ('\226\128\138\039\226\128\139', &quot;'&quot;);					-- replace {{'}} with simple apostrophe (as of 2015-12-11)
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	value = value:gsub ('&amp;zwj;', '');											-- remove &amp;zwj; entities
	value = value:gsub ('[\226\128\141\226\128\139]', '')						-- remove zero-width joiner, zero-width space
	value = value:gsub ('[\194\173\009\010\013]', ' ');							-- replace soft hyphen, horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'journal', 'news'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if 'arxiv' == class then											-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	--{'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation
	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
--		if k == 'ISBN' then v = clean_isbn( v ) end
		if k == 'ISBN' then v = v:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; ); end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v };	-- others; provide a url
		end
	end

--[[	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
]]
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki strip markers, non-printing or invisible characers
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	remove_wiki_link = utilities_page_ptr.remove_wiki_link;
end



return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>eskxb181toenxv7agpv6rom02az7owo</sha1>
    </revision>
    <revision>
      <id>4976</id>
      <parentid>4975</parentid>
      <timestamp>2015-12-17T19:37:23Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4976</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="15809" sha1="nx88dyu6c5qsz0o2hmafa6zr2nivuhr" xml:space="preserve">--[[
History of changes since last sync: 2015-12-12

]]

local coins = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, remove_wiki_link;										-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	if argument:find ( &quot;''&quot;, 1, true ) == nil then								-- Is there at least one double apostrophe?  If not, exit.
		return argument;
	end

	while true do
		if argument:find ( &quot;'''''&quot;, 1, true ) then								-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:find ( &quot;''''&quot;, 1, true ) then							-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;'''&quot;, 1, true ) then							-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;''&quot;, 1, true ) then								-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end


--[=[-------------------------&lt; C O I N S _ R E P L A C E _ M A T H _ S T R I P M A R K E R &gt;------------------

There are three options for math markup that depends on the editor's math preference settings.  These settings
are at [[Special:Preferences#mw-prefsection-rendering]] and are
	PNG images
	TeX source
	MathML with SVG or PNG fallback

All three are heavy with html and css which don't belong in the metadata.

This function gets the rendered form of an equation according to the editor's preference.  It then searches the
rendering for the text equivalent of the rendered equation and replaces the rendering with that.

When a replacement is made, this function returns true and the value with replacement

]=]

local function coins_replace_math_stripmarker (value)
	local stripmarker = '\127UNIQ%-%-math%-[%a%d]+%-QINU\127';					-- math stripmarker pattern
	local rendering = value:match (stripmarker);								-- is there a math stripmarker

	if not rendering then														-- when value doesn't have a math stripmarker, abandon this test
--		return 'not rendering';
		return false, value;
	end
	
	rendering = mw.text.unstripNoWiki (rendering);								-- convert stripmarker into rendered value (or nil? ''? when math render error)
	
	if rendering:match ('alt=&quot;[^&quot;]+&quot;') then										-- if PNG math option
		rendering = rendering:match ('alt=&quot;([^&quot;]+)&quot;');							-- extract just the math text
	elseif rendering:match ('$%s+.+%s+%$') then									-- if TeX math option; $ is legit character that is escapes as \$
		rendering = rendering:match ('$%s+(.+)%s+%$')							-- extract just the math text
	elseif rendering:match ('&lt;annotation[^&gt;]+&gt;.+&lt;/annotation&gt;') then			-- if MathML math option
		rendering = rendering:match ('&lt;annotation[^&gt;]+&gt;(.+)&lt;/annotation&gt;')		-- extract just the math text
	else
		return false, value;													-- had math stripmarker but not one of the three defined forms
	end
	
	return true, value:gsub (stripmarker, rendering, 1);
end

--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain html entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaced math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?
]]

local function coins_cleanup (value)
	local replaced = true;														-- default state to get the do loop running
	
	while replaced do															-- loop until all math stripmarkers replaced
		replaced, value = coins_replace_math_stripmarker (value);				-- replace math stripmarker with text representation of the equation
	end

	value = value:gsub ('\127UNIQ%-%-math%-[%a%d]+%-QINU\127', &quot;MATH RENDER ERROR&quot;);	-- one or more couldn't be replaced; insert vague error message
	
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;s&lt;/span&gt;', &quot;'s&quot;);	-- replace {{'s}} template with simple apostrophe-s
	value = value:gsub ('&amp;zwj;\226\128\138\039\226\128\139', &quot;'&quot;);				-- replace {{'}} with simple apostrophe
	value = value:gsub ('\226\128\138\039\226\128\139', &quot;'&quot;);					-- replace {{'}} with simple apostrophe (as of 2015-12-11)
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	value = value:gsub ('&amp;zwj;', '');											-- remove &amp;zwj; entities
	value = value:gsub ('[\226\128\141\226\128\139]', '')						-- remove zero-width joiner, zero-width space
	value = value:gsub ('[\194\173\009\010\013]', ' ');							-- replace soft hyphen, horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'journal', 'news'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if 'arxiv' == class then											-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	--{'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation
	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
--		if k == 'ISBN' then v = clean_isbn( v ) end
		if k == 'ISBN' then v = v:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; ); end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v };	-- others; provide a url
		end
	end

--[[	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
]]
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki strip markers, non-printing or invisible characers
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	remove_wiki_link = utilities_page_ptr.remove_wiki_link;
end



return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>nx88dyu6c5qsz0o2hmafa6zr2nivuhr</sha1>
    </revision>
    <revision>
      <id>4977</id>
      <parentid>4976</parentid>
      <timestamp>2015-12-18T12:11:27Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4977</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="15792" sha1="mwrawm19nczc2pfe6kzc8z9drdgzzyn" xml:space="preserve">--[[
History of changes since last sync: 2015-12-12

]]

local coins = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, remove_wiki_link;										-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	if argument:find ( &quot;''&quot;, 1, true ) == nil then								-- Is there at least one double apostrophe?  If not, exit.
		return argument;
	end

	while true do
		if argument:find ( &quot;'''''&quot;, 1, true ) then								-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:find ( &quot;''''&quot;, 1, true ) then							-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;'''&quot;, 1, true ) then							-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;''&quot;, 1, true ) then								-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end


--[=[-------------------------&lt; C O I N S _ R E P L A C E _ M A T H _ S T R I P M A R K E R &gt;------------------

There are three options for math markup rendering that depend on the editor's math preference settings.  These
settings are at [[Special:Preferences#mw-prefsection-rendering]] and are
	PNG images
	TeX source
	MathML with SVG or PNG fallback

All three are heavy with html and css which don't belong in the metadata.

This function gets the rendered form of an equation according to the editor's preference.  It then searches the
rendering for the text equivalent of the rendered equation and replaces the rendering with that.

When a replacement is made, this function returns true and the value with replacement

]=]

local function coins_replace_math_stripmarker (value)
	local stripmarker = '\127UNIQ%-%-math%-[%a%d]+%-QINU\127';					-- math stripmarker pattern
	local rendering = value:match (stripmarker);								-- is there a math stripmarker

	if not rendering then														-- when value doesn't have a math stripmarker, abandon this test
		return false, value;
	end
	
	rendering = mw.text.unstripNoWiki (rendering);								-- convert stripmarker into rendered value (or nil? ''? when math render error)
	
	if rendering:match ('alt=&quot;[^&quot;]+&quot;') then										-- if PNG math option
		rendering = rendering:match ('alt=&quot;([^&quot;]+)&quot;');							-- extract just the math text
	elseif rendering:match ('$%s+.+%s+%$') then									-- if TeX math option; $ is legit character that is escapes as \$
		rendering = rendering:match ('$%s+(.+)%s+%$')							-- extract just the math text
	elseif rendering:match ('&lt;annotation[^&gt;]+&gt;.+&lt;/annotation&gt;') then			-- if MathML math option
		rendering = rendering:match ('&lt;annotation[^&gt;]+&gt;(.+)&lt;/annotation&gt;')		-- extract just the math text
	else
		return false, value;													-- had math stripmarker but not one of the three defined forms
	end
	
	return true, value:gsub (stripmarker, rendering, 1);
end


--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain html entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaced math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?

]]

local function coins_cleanup (value)
	local replaced = true;														-- default state to get the do loop running
	
	while replaced do															-- loop until all math stripmarkers replaced
		replaced, value = coins_replace_math_stripmarker (value);				-- replace math stripmarker with text representation of the equation
	end

	value = value:gsub ('\127UNIQ%-%-math%-[%a%d]+%-QINU\127', &quot;MATH RENDER ERROR&quot;);	-- one or more couldn't be replaced; insert vague error message
	
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;s&lt;/span&gt;', &quot;'s&quot;);	-- replace {{'s}} template with simple apostrophe-s
	value = value:gsub ('&amp;zwj;\226\128\138\039\226\128\139', &quot;'&quot;);				-- replace {{'}} with simple apostrophe
	value = value:gsub ('\226\128\138\039\226\128\139', &quot;'&quot;);					-- replace {{'}} with simple apostrophe (as of 2015-12-11)
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	value = value:gsub ('&amp;zwj;', '');											-- remove &amp;zwj; entities
	value = value:gsub ('[\226\128\141\226\128\139]', '')						-- remove zero-width joiner, zero-width space
	value = value:gsub ('[\194\173\009\010\013]', ' ');							-- replace soft hyphen, horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'journal', 'news'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if 'arxiv' == class then											-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	--{'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation
	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
--		if k == 'ISBN' then v = clean_isbn( v ) end
		if k == 'ISBN' then v = v:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; ); end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v };	-- others; provide a url
		end
	end

--[[	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
]]
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki strip markers, non-printing or invisible characers
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	remove_wiki_link = utilities_page_ptr.remove_wiki_link;
end



return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>mwrawm19nczc2pfe6kzc8z9drdgzzyn</sha1>
    </revision>
    <revision>
      <id>4978</id>
      <parentid>4977</parentid>
      <timestamp>2015-12-18T12:33:39Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4978</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="16215" sha1="02zmn2mp33niye8y01v70ogzmxps9u5" xml:space="preserve">--[[
History of changes since last sync: 2015-12-12

]]

local coins = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, remove_wiki_link;										-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	if argument:find ( &quot;''&quot;, 1, true ) == nil then								-- Is there at least one double apostrophe?  If not, exit.
		return argument;
	end

	while true do
		if argument:find ( &quot;'''''&quot;, 1, true ) then								-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:find ( &quot;''''&quot;, 1, true ) then							-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;'''&quot;, 1, true ) then							-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;''&quot;, 1, true ) then								-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end


--[=[-------------------------&lt; C O I N S _ R E P L A C E _ M A T H _ S T R I P M A R K E R &gt;------------------

There are three options for math markup rendering that depend on the editor's math preference settings.  These
settings are at [[Special:Preferences#mw-prefsection-rendering]] and are
	PNG images
	TeX source
	MathML with SVG or PNG fallback

All three are heavy with html and css which doesn't belong in the metadata.

Without this function, the metadata saved in the raw wikitext contained the rendering determined by the settings
of the last editor to save the page.

This function gets the rendered form of an equation according to the editor's preference before the page is saved.  It
then searches the rendering for the text equivalent of the rendered equation and replaces the rendering with that so
that the page is saved without extraneous html/css markup and with a reasonably readable text form of the equation.

When a replacement is made, this function returns true and the value with replacement; otherwise false and the intital
value.  To replace multipe equations it is necesary to call this function from within a loop.

]=]

local function coins_replace_math_stripmarker (value)
	local stripmarker = '\127UNIQ%-%-math%-[%a%d]+%-QINU\127';					-- math stripmarker pattern
	local rendering = value:match (stripmarker);								-- is there a math stripmarker

	if not rendering then														-- when value doesn't have a math stripmarker, abandon this test
		return false, value;
	end
	
	rendering = mw.text.unstripNoWiki (rendering);								-- convert stripmarker into rendered value (or nil? ''? when math render error)
	
	if rendering:match ('alt=&quot;[^&quot;]+&quot;') then										-- if PNG math option
		rendering = rendering:match ('alt=&quot;([^&quot;]+)&quot;');							-- extract just the math text
	elseif rendering:match ('$%s+.+%s+%$') then									-- if TeX math option; $ is legit character that is escapes as \$
		rendering = rendering:match ('$%s+(.+)%s+%$')							-- extract just the math text
	elseif rendering:match ('&lt;annotation[^&gt;]+&gt;.+&lt;/annotation&gt;') then			-- if MathML math option
		rendering = rendering:match ('&lt;annotation[^&gt;]+&gt;(.+)&lt;/annotation&gt;')		-- extract just the math text
	else
		return false, value;													-- had math stripmarker but not one of the three defined forms
	end
	
	return true, value:gsub (stripmarker, rendering, 1);
end


--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain html entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaced math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?

]]

local function coins_cleanup (value)
	local replaced = true;														-- default state to get the do loop running
	
	while replaced do															-- loop until all math stripmarkers replaced
		replaced, value = coins_replace_math_stripmarker (value);				-- replace math stripmarker with text representation of the equation
	end

	value = value:gsub ('\127UNIQ%-%-math%-[%a%d]+%-QINU\127', &quot;MATH RENDER ERROR&quot;);	-- one or more couldn't be replaced; insert vague error message
	
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;s&lt;/span&gt;', &quot;'s&quot;);	-- replace {{'s}} template with simple apostrophe-s
	value = value:gsub ('&amp;zwj;\226\128\138\039\226\128\139', &quot;'&quot;);				-- replace {{'}} with simple apostrophe
	value = value:gsub ('\226\128\138\039\226\128\139', &quot;'&quot;);					-- replace {{'}} with simple apostrophe (as of 2015-12-11)
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	value = value:gsub ('&amp;zwj;', '');											-- remove &amp;zwj; entities
	value = value:gsub ('[\226\128\141\226\128\139]', '')						-- remove zero-width joiner, zero-width space
	value = value:gsub ('[\194\173\009\010\013]', ' ');							-- replace soft hyphen, horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'journal', 'news'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if 'arxiv' == class then											-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	--{'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation
	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
--		if k == 'ISBN' then v = clean_isbn( v ) end
		if k == 'ISBN' then v = v:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; ); end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v };	-- others; provide a url
		end
	end

--[[	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
]]
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki strip markers, non-printing or invisible characers
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	remove_wiki_link = utilities_page_ptr.remove_wiki_link;
end



return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>02zmn2mp33niye8y01v70ogzmxps9u5</sha1>
    </revision>
    <revision>
      <id>4979</id>
      <parentid>4978</parentid>
      <timestamp>2015-12-26T16:02:39Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4979</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="16796" sha1="nm48erzwof6z95r0iezzw1n413pe13g" xml:space="preserve">--[[
History of changes since last sync: 2015-12-12

]]

local coins = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, remove_wiki_link;										-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	if argument:find ( &quot;''&quot;, 1, true ) == nil then								-- Is there at least one double apostrophe?  If not, exit.
		return argument;
	end

	while true do
		if argument:find ( &quot;'''''&quot;, 1, true ) then								-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:find ( &quot;''''&quot;, 1, true ) then							-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;'''&quot;, 1, true ) then							-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;''&quot;, 1, true ) then								-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't correupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]

local function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other lua magic pattern characters
	return argument;
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end


--[=[-------------------------&lt; C O I N S _ R E P L A C E _ M A T H _ S T R I P M A R K E R &gt;------------------

There are three options for math markup rendering that depend on the editor's math preference settings.  These
settings are at [[Special:Preferences#mw-prefsection-rendering]] and are
	PNG images
	TeX source
	MathML with SVG or PNG fallback

All three are heavy with html and css which doesn't belong in the metadata.

Without this function, the metadata saved in the raw wikitext contained the rendering determined by the settings
of the last editor to save the page.

This function gets the rendered form of an equation according to the editor's preference before the page is saved.  It
then searches the rendering for the text equivalent of the rendered equation and replaces the rendering with that so
that the page is saved without extraneous html/css markup and with a reasonably readable text form of the equation.

When a replacement is made, this function returns true and the value with replacement; otherwise false and the intital
value.  To replace multipe equations it is necesary to call this function from within a loop.

]=]

local function coins_replace_math_stripmarker (value)
	local stripmarker = '\127UNIQ%-%-math%-[%a%d]+%-QINU\127';					-- math stripmarker pattern
	local rendering = value:match (stripmarker);								-- is there a math stripmarker

	if not rendering then														-- when value doesn't have a math stripmarker, abandon this test
		return false, value;
	end
	
	rendering = mw.text.unstripNoWiki (rendering);								-- convert stripmarker into rendered value (or nil? ''? when math render error)
	
	if rendering:match ('alt=&quot;[^&quot;]+&quot;') then										-- if PNG math option
		rendering = rendering:match ('alt=&quot;([^&quot;]+)&quot;');							-- extract just the math text
	elseif rendering:match ('$%s+.+%s+%$') then									-- if TeX math option; $ is legit character that is escapes as \$
		rendering = rendering:match ('$%s+(.+)%s+%$')							-- extract just the math text
	elseif rendering:match ('&lt;annotation[^&gt;]+&gt;.+&lt;/annotation&gt;') then			-- if MathML math option
		rendering = rendering:match ('&lt;annotation[^&gt;]+&gt;(.+)&lt;/annotation&gt;')		-- extract just the math text
	else
		return false, value;													-- had math stripmarker but not one of the three defined forms
	end
	
	return true, value:gsub (stripmarker, rendering, 1);
end


--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain html entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaced math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?

]]

local function coins_cleanup (value)
	local replaced = true;														-- default state to get the do loop running
	
	while replaced do															-- loop until all math stripmarkers replaced
		replaced, value = coins_replace_math_stripmarker (value);				-- replace math stripmarker with text representation of the equation
	end

	value = value:gsub ('\127UNIQ%-%-math%-[%a%d]+%-QINU\127', &quot;MATH RENDER ERROR&quot;);	-- one or more couldn't be replaced; insert vague error message
	
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;s&lt;/span&gt;', &quot;'s&quot;);	-- replace {{'s}} template with simple apostrophe-s
	value = value:gsub ('&amp;zwj;\226\128\138\039\226\128\139', &quot;'&quot;);				-- replace {{'}} with simple apostrophe
	value = value:gsub ('\226\128\138\039\226\128\139', &quot;'&quot;);					-- replace {{'}} with simple apostrophe (as of 2015-12-11)
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	value = value:gsub ('&amp;zwj;', '');											-- remove &amp;zwj; entities
	value = value:gsub ('[\226\128\141\226\128\139]', '')						-- remove zero-width joiner, zero-width space
	value = value:gsub ('[\194\173\009\010\013]', ' ');							-- replace soft hyphen, horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'journal', 'news'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if 'arxiv' == class then											-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	--{'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation
	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
--		if k == 'ISBN' then v = clean_isbn( v ) end
		if k == 'ISBN' then v = v:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; ); end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v };	-- others; provide a url
		end
	end

--[[	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
]]
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki strip markers, non-printing or invisible characers
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	remove_wiki_link = utilities_page_ptr.remove_wiki_link;
end



return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>nm48erzwof6z95r0iezzw1n413pe13g</sha1>
    </revision>
    <revision>
      <id>4980</id>
      <parentid>4979</parentid>
      <timestamp>2016-01-05T03:59:59Z</timestamp>
      <contributor>
        <username>Obsuser</username>
        <id>824</id>
      </contributor>
      <minor />
      <comment>correupted → corrupted</comment>
      <origin>4980</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="16795" sha1="rkqt9fkb4b886qmaut0333160xcm1o3" xml:space="preserve">--[[
History of changes since last sync: 2015-12-12

]]

local coins = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, remove_wiki_link;										-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	if argument:find ( &quot;''&quot;, 1, true ) == nil then								-- Is there at least one double apostrophe?  If not, exit.
		return argument;
	end

	while true do
		if argument:find ( &quot;'''''&quot;, 1, true ) then								-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:find ( &quot;''''&quot;, 1, true ) then							-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;'''&quot;, 1, true ) then							-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;''&quot;, 1, true ) then								-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't corrupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]

local function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other lua magic pattern characters
	return argument;
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end


--[=[-------------------------&lt; C O I N S _ R E P L A C E _ M A T H _ S T R I P M A R K E R &gt;------------------

There are three options for math markup rendering that depend on the editor's math preference settings.  These
settings are at [[Special:Preferences#mw-prefsection-rendering]] and are
	PNG images
	TeX source
	MathML with SVG or PNG fallback

All three are heavy with html and css which doesn't belong in the metadata.

Without this function, the metadata saved in the raw wikitext contained the rendering determined by the settings
of the last editor to save the page.

This function gets the rendered form of an equation according to the editor's preference before the page is saved.  It
then searches the rendering for the text equivalent of the rendered equation and replaces the rendering with that so
that the page is saved without extraneous html/css markup and with a reasonably readable text form of the equation.

When a replacement is made, this function returns true and the value with replacement; otherwise false and the intital
value.  To replace multipe equations it is necesary to call this function from within a loop.

]=]

local function coins_replace_math_stripmarker (value)
	local stripmarker = '\127UNIQ%-%-math%-[%a%d]+%-QINU\127';					-- math stripmarker pattern
	local rendering = value:match (stripmarker);								-- is there a math stripmarker

	if not rendering then														-- when value doesn't have a math stripmarker, abandon this test
		return false, value;
	end
	
	rendering = mw.text.unstripNoWiki (rendering);								-- convert stripmarker into rendered value (or nil? ''? when math render error)
	
	if rendering:match ('alt=&quot;[^&quot;]+&quot;') then										-- if PNG math option
		rendering = rendering:match ('alt=&quot;([^&quot;]+)&quot;');							-- extract just the math text
	elseif rendering:match ('$%s+.+%s+%$') then									-- if TeX math option; $ is legit character that is escapes as \$
		rendering = rendering:match ('$%s+(.+)%s+%$')							-- extract just the math text
	elseif rendering:match ('&lt;annotation[^&gt;]+&gt;.+&lt;/annotation&gt;') then			-- if MathML math option
		rendering = rendering:match ('&lt;annotation[^&gt;]+&gt;(.+)&lt;/annotation&gt;')		-- extract just the math text
	else
		return false, value;													-- had math stripmarker but not one of the three defined forms
	end
	
	return true, value:gsub (stripmarker, rendering, 1);
end


--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain html entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaced math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?

]]

local function coins_cleanup (value)
	local replaced = true;														-- default state to get the do loop running
	
	while replaced do															-- loop until all math stripmarkers replaced
		replaced, value = coins_replace_math_stripmarker (value);				-- replace math stripmarker with text representation of the equation
	end

	value = value:gsub ('\127UNIQ%-%-math%-[%a%d]+%-QINU\127', &quot;MATH RENDER ERROR&quot;);	-- one or more couldn't be replaced; insert vague error message
	
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;s&lt;/span&gt;', &quot;'s&quot;);	-- replace {{'s}} template with simple apostrophe-s
	value = value:gsub ('&amp;zwj;\226\128\138\039\226\128\139', &quot;'&quot;);				-- replace {{'}} with simple apostrophe
	value = value:gsub ('\226\128\138\039\226\128\139', &quot;'&quot;);					-- replace {{'}} with simple apostrophe (as of 2015-12-11)
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	value = value:gsub ('&amp;zwj;', '');											-- remove &amp;zwj; entities
	value = value:gsub ('[\226\128\141\226\128\139]', '')						-- remove zero-width joiner, zero-width space
	value = value:gsub ('[\194\173\009\010\013]', ' ');							-- replace soft hyphen, horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'journal', 'news'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if 'arxiv' == class then											-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	--{'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation
	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
--		if k == 'ISBN' then v = clean_isbn( v ) end
		if k == 'ISBN' then v = v:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; ); end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v };	-- others; provide a url
		end
	end

--[[	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
]]
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki strip markers, non-printing or invisible characers
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	remove_wiki_link = utilities_page_ptr.remove_wiki_link;
end



return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>rkqt9fkb4b886qmaut0333160xcm1o3</sha1>
    </revision>
    <revision>
      <id>4981</id>
      <parentid>4980</parentid>
      <timestamp>2016-01-10T17:36:34Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4981</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="16903" sha1="d84njv9i4eo4vpcvwtlaz66xl2ck1zh" xml:space="preserve">--[[
History of changes since last sync: 2015-12-12

2016-01-10:	bug fix; article title (aka chapter) missing from cite conference book metadata;

]]

local coins = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, remove_wiki_link;										-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	if argument:find ( &quot;''&quot;, 1, true ) == nil then								-- Is there at least one double apostrophe?  If not, exit.
		return argument;
	end

	while true do
		if argument:find ( &quot;'''''&quot;, 1, true ) then								-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:find ( &quot;''''&quot;, 1, true ) then							-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;'''&quot;, 1, true ) then							-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;''&quot;, 1, true ) then								-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't corrupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]

local function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other lua magic pattern characters
	return argument;
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end


--[=[-------------------------&lt; C O I N S _ R E P L A C E _ M A T H _ S T R I P M A R K E R &gt;------------------

There are three options for math markup rendering that depend on the editor's math preference settings.  These
settings are at [[Special:Preferences#mw-prefsection-rendering]] and are
	PNG images
	TeX source
	MathML with SVG or PNG fallback

All three are heavy with html and css which doesn't belong in the metadata.

Without this function, the metadata saved in the raw wikitext contained the rendering determined by the settings
of the last editor to save the page.

This function gets the rendered form of an equation according to the editor's preference before the page is saved.  It
then searches the rendering for the text equivalent of the rendered equation and replaces the rendering with that so
that the page is saved without extraneous html/css markup and with a reasonably readable text form of the equation.

When a replacement is made, this function returns true and the value with replacement; otherwise false and the intital
value.  To replace multipe equations it is necesary to call this function from within a loop.

]=]

local function coins_replace_math_stripmarker (value)
	local stripmarker = '\127UNIQ%-%-math%-[%a%d]+%-QINU\127';					-- math stripmarker pattern
	local rendering = value:match (stripmarker);								-- is there a math stripmarker

	if not rendering then														-- when value doesn't have a math stripmarker, abandon this test
		return false, value;
	end
	
	rendering = mw.text.unstripNoWiki (rendering);								-- convert stripmarker into rendered value (or nil? ''? when math render error)
	
	if rendering:match ('alt=&quot;[^&quot;]+&quot;') then										-- if PNG math option
		rendering = rendering:match ('alt=&quot;([^&quot;]+)&quot;');							-- extract just the math text
	elseif rendering:match ('$%s+.+%s+%$') then									-- if TeX math option; $ is legit character that is escapes as \$
		rendering = rendering:match ('$%s+(.+)%s+%$')							-- extract just the math text
	elseif rendering:match ('&lt;annotation[^&gt;]+&gt;.+&lt;/annotation&gt;') then			-- if MathML math option
		rendering = rendering:match ('&lt;annotation[^&gt;]+&gt;(.+)&lt;/annotation&gt;')		-- extract just the math text
	else
		return false, value;													-- had math stripmarker but not one of the three defined forms
	end
	
	return true, value:gsub (stripmarker, rendering, 1);
end


--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain html entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaced math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?

]]

local function coins_cleanup (value)
	local replaced = true;														-- default state to get the do loop running
	
	while replaced do															-- loop until all math stripmarkers replaced
		replaced, value = coins_replace_math_stripmarker (value);				-- replace math stripmarker with text representation of the equation
	end

	value = value:gsub ('\127UNIQ%-%-math%-[%a%d]+%-QINU\127', &quot;MATH RENDER ERROR&quot;);	-- one or more couldn't be replaced; insert vague error message
	
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;s&lt;/span&gt;', &quot;'s&quot;);	-- replace {{'s}} template with simple apostrophe-s
	value = value:gsub ('&amp;zwj;\226\128\138\039\226\128\139', &quot;'&quot;);				-- replace {{'}} with simple apostrophe
	value = value:gsub ('\226\128\138\039\226\128\139', &quot;'&quot;);					-- replace {{'}} with simple apostrophe (as of 2015-12-11)
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	value = value:gsub ('&amp;zwj;', '');											-- remove &amp;zwj; entities
	value = value:gsub ('[\226\128\141\226\128\139]', '')						-- remove zero-width joiner, zero-width space
	value = value:gsub ('[\194\173\009\010\013]', ' ');							-- replace soft hyphen, horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'journal', 'news'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if 'arxiv' == class then											-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
		elseif in_array (class, {'book', 'citation', 'conference', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	--{'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation
	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
--		if k == 'ISBN' then v = clean_isbn( v ) end
		if k == 'ISBN' then v = v:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; ); end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v };	-- others; provide a url
		end
	end

--[[	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
]]
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki strip markers, non-printing or invisible characers
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	remove_wiki_link = utilities_page_ptr.remove_wiki_link;
end



return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>d84njv9i4eo4vpcvwtlaz66xl2ck1zh</sha1>
    </revision>
    <revision>
      <id>4982</id>
      <parentid>4981</parentid>
      <timestamp>2016-01-10T17:40:31Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4982</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="16993" sha1="5dpk1yff5hf1bf764stzppl19oxtgaj" xml:space="preserve">--[[
History of changes since last sync: 2015-12-12

2016-01-10:	bug fix; article title (aka chapter) missing from cite conference book metadata;

]]

local coins = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, remove_wiki_link;										-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	if argument:find ( &quot;''&quot;, 1, true ) == nil then								-- Is there at least one double apostrophe?  If not, exit.
		return argument;
	end

	while true do
		if argument:find ( &quot;'''''&quot;, 1, true ) then								-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:find ( &quot;''''&quot;, 1, true ) then							-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;'''&quot;, 1, true ) then							-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;''&quot;, 1, true ) then								-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't corrupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]

local function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other lua magic pattern characters
	return argument;
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end


--[=[-------------------------&lt; C O I N S _ R E P L A C E _ M A T H _ S T R I P M A R K E R &gt;------------------

There are three options for math markup rendering that depend on the editor's math preference settings.  These
settings are at [[Special:Preferences#mw-prefsection-rendering]] and are
	PNG images
	TeX source
	MathML with SVG or PNG fallback

All three are heavy with html and css which doesn't belong in the metadata.

Without this function, the metadata saved in the raw wikitext contained the rendering determined by the settings
of the last editor to save the page.

This function gets the rendered form of an equation according to the editor's preference before the page is saved.  It
then searches the rendering for the text equivalent of the rendered equation and replaces the rendering with that so
that the page is saved without extraneous html/css markup and with a reasonably readable text form of the equation.

When a replacement is made, this function returns true and the value with replacement; otherwise false and the intital
value.  To replace multipe equations it is necesary to call this function from within a loop.

]=]

local function coins_replace_math_stripmarker (value)
	local stripmarker = '\127UNIQ%-%-math%-[%a%d]+%-QINU\127';					-- math stripmarker pattern
	local rendering = value:match (stripmarker);								-- is there a math stripmarker

	if not rendering then														-- when value doesn't have a math stripmarker, abandon this test
		return false, value;
	end
	
	rendering = mw.text.unstripNoWiki (rendering);								-- convert stripmarker into rendered value (or nil? ''? when math render error)
	
	if rendering:match ('alt=&quot;[^&quot;]+&quot;') then										-- if PNG math option
		rendering = rendering:match ('alt=&quot;([^&quot;]+)&quot;');							-- extract just the math text
	elseif rendering:match ('$%s+.+%s+%$') then									-- if TeX math option; $ is legit character that is escapes as \$
		rendering = rendering:match ('$%s+(.+)%s+%$')							-- extract just the math text
	elseif rendering:match ('&lt;annotation[^&gt;]+&gt;.+&lt;/annotation&gt;') then			-- if MathML math option
		rendering = rendering:match ('&lt;annotation[^&gt;]+&gt;(.+)&lt;/annotation&gt;')		-- extract just the math text
	else
		return false, value;													-- had math stripmarker but not one of the three defined forms
	end
	
	return true, value:gsub (stripmarker, rendering, 1);
end


--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain html entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaced math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?

]]

local function coins_cleanup (value)
	local replaced = true;														-- default state to get the do loop running
	
	while replaced do															-- loop until all math stripmarkers replaced
		replaced, value = coins_replace_math_stripmarker (value);				-- replace math stripmarker with text representation of the equation
	end

	value = value:gsub ('\127UNIQ%-%-math%-[%a%d]+%-QINU\127', &quot;MATH RENDER ERROR&quot;);	-- one or more couldn't be replaced; insert vague error message
	
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;s&lt;/span&gt;', &quot;'s&quot;);	-- replace {{'s}} template with simple apostrophe-s
	value = value:gsub ('&amp;zwj;\226\128\138\039\226\128\139', &quot;'&quot;);				-- replace {{'}} with simple apostrophe
	value = value:gsub ('\226\128\138\039\226\128\139', &quot;'&quot;);					-- replace {{'}} with simple apostrophe (as of 2015-12-11)
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	value = value:gsub ('&amp;zwj;', '');											-- remove &amp;zwj; entities
	value = value:gsub ('[\226\128\141\226\128\139]', '')						-- remove zero-width joiner, zero-width space
	value = value:gsub ('[\194\173\009\010\013]', ' ');							-- replace soft hyphen, horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'journal', 'news'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if 'arxiv' == class then											-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
			OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;							-- conference paper as chapter in proceedings (book)
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	--{'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation
	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
--		if k == 'ISBN' then v = clean_isbn( v ) end
		if k == 'ISBN' then v = v:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; ); end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v };	-- others; provide a url
		end
	end

--[[	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
]]
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki strip markers, non-printing or invisible characers
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	remove_wiki_link = utilities_page_ptr.remove_wiki_link;
end



return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>5dpk1yff5hf1bf764stzppl19oxtgaj</sha1>
    </revision>
    <revision>
      <id>4983</id>
      <parentid>4982</parentid>
      <timestamp>2016-01-10T17:58:33Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>4983</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="17084" sha1="jhmu86urarjvo5jmcasnubhepog0zfy" xml:space="preserve">--[[
History of changes since last sync: 2015-12-12

2016-01-10:	bug fix; article title (aka chapter) missing from cite conference book metadata; see Help_talk:Citation_Style_1#cite_conference_title.3D_parameter_is_incorrectly_formatted

]]

local coins = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, remove_wiki_link;										-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	if argument:find ( &quot;''&quot;, 1, true ) == nil then								-- Is there at least one double apostrophe?  If not, exit.
		return argument;
	end

	while true do
		if argument:find ( &quot;'''''&quot;, 1, true ) then								-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:find ( &quot;''''&quot;, 1, true ) then							-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;'''&quot;, 1, true ) then							-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;''&quot;, 1, true ) then								-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't corrupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]

local function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other lua magic pattern characters
	return argument;
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end


--[=[-------------------------&lt; C O I N S _ R E P L A C E _ M A T H _ S T R I P M A R K E R &gt;------------------

There are three options for math markup rendering that depend on the editor's math preference settings.  These
settings are at [[Special:Preferences#mw-prefsection-rendering]] and are
	PNG images
	TeX source
	MathML with SVG or PNG fallback

All three are heavy with html and css which doesn't belong in the metadata.

Without this function, the metadata saved in the raw wikitext contained the rendering determined by the settings
of the last editor to save the page.

This function gets the rendered form of an equation according to the editor's preference before the page is saved.  It
then searches the rendering for the text equivalent of the rendered equation and replaces the rendering with that so
that the page is saved without extraneous html/css markup and with a reasonably readable text form of the equation.

When a replacement is made, this function returns true and the value with replacement; otherwise false and the intital
value.  To replace multipe equations it is necesary to call this function from within a loop.

]=]

local function coins_replace_math_stripmarker (value)
	local stripmarker = '\127UNIQ%-%-math%-[%a%d]+%-QINU\127';					-- math stripmarker pattern
	local rendering = value:match (stripmarker);								-- is there a math stripmarker

	if not rendering then														-- when value doesn't have a math stripmarker, abandon this test
		return false, value;
	end
	
	rendering = mw.text.unstripNoWiki (rendering);								-- convert stripmarker into rendered value (or nil? ''? when math render error)
	
	if rendering:match ('alt=&quot;[^&quot;]+&quot;') then										-- if PNG math option
		rendering = rendering:match ('alt=&quot;([^&quot;]+)&quot;');							-- extract just the math text
	elseif rendering:match ('$%s+.+%s+%$') then									-- if TeX math option; $ is legit character that is escapes as \$
		rendering = rendering:match ('$%s+(.+)%s+%$')							-- extract just the math text
	elseif rendering:match ('&lt;annotation[^&gt;]+&gt;.+&lt;/annotation&gt;') then			-- if MathML math option
		rendering = rendering:match ('&lt;annotation[^&gt;]+&gt;(.+)&lt;/annotation&gt;')		-- extract just the math text
	else
		return false, value;													-- had math stripmarker but not one of the three defined forms
	end
	
	return true, value:gsub (stripmarker, rendering, 1);
end


--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain html entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaced math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?

]]

local function coins_cleanup (value)
	local replaced = true;														-- default state to get the do loop running
	
	while replaced do															-- loop until all math stripmarkers replaced
		replaced, value = coins_replace_math_stripmarker (value);				-- replace math stripmarker with text representation of the equation
	end

	value = value:gsub ('\127UNIQ%-%-math%-[%a%d]+%-QINU\127', &quot;MATH RENDER ERROR&quot;);	-- one or more couldn't be replaced; insert vague error message
	
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;s&lt;/span&gt;', &quot;'s&quot;);	-- replace {{'s}} template with simple apostrophe-s
	value = value:gsub ('&amp;zwj;\226\128\138\039\226\128\139', &quot;'&quot;);				-- replace {{'}} with simple apostrophe
	value = value:gsub ('\226\128\138\039\226\128\139', &quot;'&quot;);					-- replace {{'}} with simple apostrophe (as of 2015-12-11)
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	value = value:gsub ('&amp;zwj;', '');											-- remove &amp;zwj; entities
	value = value:gsub ('[\226\128\141\226\128\139]', '')						-- remove zero-width joiner, zero-width space
	value = value:gsub ('[\194\173\009\010\013]', ' ');							-- replace soft hyphen, horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'journal', 'news'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if 'arxiv' == class then											-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
			OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;							-- conference paper as chapter in proceedings (book)
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	--{'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation
	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
--		if k == 'ISBN' then v = clean_isbn( v ) end
		if k == 'ISBN' then v = v:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; ); end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v };	-- others; provide a url
		end
	end

--[[	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
]]
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki strip markers, non-printing or invisible characers
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	remove_wiki_link = utilities_page_ptr.remove_wiki_link;
end



return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>jhmu86urarjvo5jmcasnubhepog0zfy</sha1>
    </revision>
    <revision>
      <id>4984</id>
      <parentid>4983</parentid>
      <timestamp>2016-01-15T14:26:21Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <minor />
      <comment>remove changes history;</comment>
      <origin>4984</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="16842" sha1="j2mup8ws593h8jyhxa56arw8uoj8pmi" xml:space="preserve">local coins = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, remove_wiki_link;										-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	if argument:find ( &quot;''&quot;, 1, true ) == nil then								-- Is there at least one double apostrophe?  If not, exit.
		return argument;
	end

	while true do
		if argument:find ( &quot;'''''&quot;, 1, true ) then								-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:find ( &quot;''''&quot;, 1, true ) then							-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;'''&quot;, 1, true ) then							-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;''&quot;, 1, true ) then								-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't corrupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]

local function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other lua magic pattern characters
	return argument;
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end


--[=[-------------------------&lt; C O I N S _ R E P L A C E _ M A T H _ S T R I P M A R K E R &gt;------------------

There are three options for math markup rendering that depend on the editor's math preference settings.  These
settings are at [[Special:Preferences#mw-prefsection-rendering]] and are
	PNG images
	TeX source
	MathML with SVG or PNG fallback

All three are heavy with html and css which doesn't belong in the metadata.

Without this function, the metadata saved in the raw wikitext contained the rendering determined by the settings
of the last editor to save the page.

This function gets the rendered form of an equation according to the editor's preference before the page is saved.  It
then searches the rendering for the text equivalent of the rendered equation and replaces the rendering with that so
that the page is saved without extraneous html/css markup and with a reasonably readable text form of the equation.

When a replacement is made, this function returns true and the value with replacement; otherwise false and the intital
value.  To replace multipe equations it is necesary to call this function from within a loop.

]=]

local function coins_replace_math_stripmarker (value)
	local stripmarker = '\127UNIQ%-%-math%-[%a%d]+%-QINU\127';					-- math stripmarker pattern
	local rendering = value:match (stripmarker);								-- is there a math stripmarker

	if not rendering then														-- when value doesn't have a math stripmarker, abandon this test
		return false, value;
	end
	
	rendering = mw.text.unstripNoWiki (rendering);								-- convert stripmarker into rendered value (or nil? ''? when math render error)
	
	if rendering:match ('alt=&quot;[^&quot;]+&quot;') then										-- if PNG math option
		rendering = rendering:match ('alt=&quot;([^&quot;]+)&quot;');							-- extract just the math text
	elseif rendering:match ('$%s+.+%s+%$') then									-- if TeX math option; $ is legit character that is escapes as \$
		rendering = rendering:match ('$%s+(.+)%s+%$')							-- extract just the math text
	elseif rendering:match ('&lt;annotation[^&gt;]+&gt;.+&lt;/annotation&gt;') then			-- if MathML math option
		rendering = rendering:match ('&lt;annotation[^&gt;]+&gt;(.+)&lt;/annotation&gt;')		-- extract just the math text
	else
		return false, value;													-- had math stripmarker but not one of the three defined forms
	end
	
	return true, value:gsub (stripmarker, rendering, 1);
end


--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain html entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaced math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?

]]

local function coins_cleanup (value)
	local replaced = true;														-- default state to get the do loop running
	
	while replaced do															-- loop until all math stripmarkers replaced
		replaced, value = coins_replace_math_stripmarker (value);				-- replace math stripmarker with text representation of the equation
	end

	value = value:gsub ('\127UNIQ%-%-math%-[%a%d]+%-QINU\127', &quot;MATH RENDER ERROR&quot;);	-- one or more couldn't be replaced; insert vague error message
	
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;s&lt;/span&gt;', &quot;'s&quot;);	-- replace {{'s}} template with simple apostrophe-s
	value = value:gsub ('&amp;zwj;\226\128\138\039\226\128\139', &quot;'&quot;);				-- replace {{'}} with simple apostrophe
	value = value:gsub ('\226\128\138\039\226\128\139', &quot;'&quot;);					-- replace {{'}} with simple apostrophe (as of 2015-12-11)
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	value = value:gsub ('&amp;zwj;', '');											-- remove &amp;zwj; entities
	value = value:gsub ('[\226\128\141\226\128\139]', '')						-- remove zero-width joiner, zero-width space
	value = value:gsub ('[\194\173\009\010\013]', ' ');							-- replace soft hyphen, horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'journal', 'news'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if 'arxiv' == class then											-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
			OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;							-- conference paper as chapter in proceedings (book)
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	--{'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation
	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
--		if k == 'ISBN' then v = clean_isbn( v ) end
		if k == 'ISBN' then v = v:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; ); end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v };	-- others; provide a url
		end
	end

--[[	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
]]
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki strip markers, non-printing or invisible characers
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	remove_wiki_link = utilities_page_ptr.remove_wiki_link;
end



return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>j2mup8ws593h8jyhxa56arw8uoj8pmi</sha1>
    </revision>
    <revision>
      <id>4985</id>
      <parentid>4984</parentid>
      <timestamp>2016-01-15T14:31:31Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <minor />
      <comment>Protected &quot;[[Module:Citation/CS1/COinS]]&quot;: [[WP:High-risk templates|High-risk Lua module]] ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))</comment>
      <origin>4984</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="16842" sha1="j2mup8ws593h8jyhxa56arw8uoj8pmi" xml:space="preserve">local coins = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, remove_wiki_link;										-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	if argument:find ( &quot;''&quot;, 1, true ) == nil then								-- Is there at least one double apostrophe?  If not, exit.
		return argument;
	end

	while true do
		if argument:find ( &quot;'''''&quot;, 1, true ) then								-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:find ( &quot;''''&quot;, 1, true ) then							-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;'''&quot;, 1, true ) then							-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;''&quot;, 1, true ) then								-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't corrupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]

local function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other lua magic pattern characters
	return argument;
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end


--[=[-------------------------&lt; C O I N S _ R E P L A C E _ M A T H _ S T R I P M A R K E R &gt;------------------

There are three options for math markup rendering that depend on the editor's math preference settings.  These
settings are at [[Special:Preferences#mw-prefsection-rendering]] and are
	PNG images
	TeX source
	MathML with SVG or PNG fallback

All three are heavy with html and css which doesn't belong in the metadata.

Without this function, the metadata saved in the raw wikitext contained the rendering determined by the settings
of the last editor to save the page.

This function gets the rendered form of an equation according to the editor's preference before the page is saved.  It
then searches the rendering for the text equivalent of the rendered equation and replaces the rendering with that so
that the page is saved without extraneous html/css markup and with a reasonably readable text form of the equation.

When a replacement is made, this function returns true and the value with replacement; otherwise false and the intital
value.  To replace multipe equations it is necesary to call this function from within a loop.

]=]

local function coins_replace_math_stripmarker (value)
	local stripmarker = '\127UNIQ%-%-math%-[%a%d]+%-QINU\127';					-- math stripmarker pattern
	local rendering = value:match (stripmarker);								-- is there a math stripmarker

	if not rendering then														-- when value doesn't have a math stripmarker, abandon this test
		return false, value;
	end
	
	rendering = mw.text.unstripNoWiki (rendering);								-- convert stripmarker into rendered value (or nil? ''? when math render error)
	
	if rendering:match ('alt=&quot;[^&quot;]+&quot;') then										-- if PNG math option
		rendering = rendering:match ('alt=&quot;([^&quot;]+)&quot;');							-- extract just the math text
	elseif rendering:match ('$%s+.+%s+%$') then									-- if TeX math option; $ is legit character that is escapes as \$
		rendering = rendering:match ('$%s+(.+)%s+%$')							-- extract just the math text
	elseif rendering:match ('&lt;annotation[^&gt;]+&gt;.+&lt;/annotation&gt;') then			-- if MathML math option
		rendering = rendering:match ('&lt;annotation[^&gt;]+&gt;(.+)&lt;/annotation&gt;')		-- extract just the math text
	else
		return false, value;													-- had math stripmarker but not one of the three defined forms
	end
	
	return true, value:gsub (stripmarker, rendering, 1);
end


--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain html entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaced math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?

]]

local function coins_cleanup (value)
	local replaced = true;														-- default state to get the do loop running
	
	while replaced do															-- loop until all math stripmarkers replaced
		replaced, value = coins_replace_math_stripmarker (value);				-- replace math stripmarker with text representation of the equation
	end

	value = value:gsub ('\127UNIQ%-%-math%-[%a%d]+%-QINU\127', &quot;MATH RENDER ERROR&quot;);	-- one or more couldn't be replaced; insert vague error message
	
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;s&lt;/span&gt;', &quot;'s&quot;);	-- replace {{'s}} template with simple apostrophe-s
	value = value:gsub ('&amp;zwj;\226\128\138\039\226\128\139', &quot;'&quot;);				-- replace {{'}} with simple apostrophe
	value = value:gsub ('\226\128\138\039\226\128\139', &quot;'&quot;);					-- replace {{'}} with simple apostrophe (as of 2015-12-11)
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	value = value:gsub ('&amp;zwj;', '');											-- remove &amp;zwj; entities
	value = value:gsub ('[\226\128\141\226\128\139]', '')						-- remove zero-width joiner, zero-width space
	value = value:gsub ('[\194\173\009\010\013]', ' ');							-- replace soft hyphen, horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'journal', 'news'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if 'arxiv' == class then											-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
			OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;							-- conference paper as chapter in proceedings (book)
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	--{'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation
	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
--		if k == 'ISBN' then v = clean_isbn( v ) end
		if k == 'ISBN' then v = v:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; ); end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v };	-- others; provide a url
		end
	end

--[[	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
]]
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki strip markers, non-printing or invisible characers
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	remove_wiki_link = utilities_page_ptr.remove_wiki_link;
end



return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>j2mup8ws593h8jyhxa56arw8uoj8pmi</sha1>
    </revision>
    <revision>
      <id>4986</id>
      <parentid>4985</parentid>
      <timestamp>2016-04-16T10:52:07Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Synch from sandbox;</comment>
      <origin>4986</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="16578" sha1="05g552e3m2ptwtlpscizxxzeayu7l76" xml:space="preserve">
local coins = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, remove_wiki_link;										-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	if argument:find ( &quot;''&quot;, 1, true ) == nil then								-- Is there at least one double apostrophe?  If not, exit.
		return argument;
	end

	while true do
		if argument:find ( &quot;'''''&quot;, 1, true ) then								-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:find ( &quot;''''&quot;, 1, true ) then							-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;'''&quot;, 1, true ) then							-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;''&quot;, 1, true ) then								-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't corrupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]

local function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other lua magic pattern characters
	return argument;
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end


--[=[-------------------------&lt; C O I N S _ R E P L A C E _ M A T H _ S T R I P M A R K E R &gt;------------------

There are three options for math markup rendering that depend on the editor's math preference settings.  These
settings are at [[Special:Preferences#mw-prefsection-rendering]] and are
	PNG images
	TeX source
	MathML with SVG or PNG fallback

All three are heavy with html and css which doesn't belong in the metadata.

Without this function, the metadata saved in the raw wikitext contained the rendering determined by the settings
of the last editor to save the page.

This function gets the rendered form of an equation according to the editor's preference before the page is saved.  It
then searches the rendering for the text equivalent of the rendered equation and replaces the rendering with that so
that the page is saved without extraneous html/css markup and with a reasonably readable text form of the equation.

When a replacement is made, this function returns true and the value with replacement; otherwise false and the intital
value.  To replace multipe equations it is necesary to call this function from within a loop.

]=]

local function coins_replace_math_stripmarker (value)
	local stripmarker = cfg.stripmarkers['math'];
	local rendering = value:match (stripmarker);								-- is there a math stripmarker

	if not rendering then														-- when value doesn't have a math stripmarker, abandon this test
		return false, value;
	end
	
	rendering = mw.text.unstripNoWiki (rendering);								-- convert stripmarker into rendered value (or nil? ''? when math render error)
	
	if rendering:match ('alt=&quot;[^&quot;]+&quot;') then										-- if PNG math option
		rendering = rendering:match ('alt=&quot;([^&quot;]+)&quot;');							-- extract just the math text
	elseif rendering:match ('$%s+.+%s+%$') then									-- if TeX math option; $ is legit character that is escapes as \$
		rendering = rendering:match ('$%s+(.+)%s+%$')							-- extract just the math text
	elseif rendering:match ('&lt;annotation[^&gt;]+&gt;.+&lt;/annotation&gt;') then			-- if MathML math option
		rendering = rendering:match ('&lt;annotation[^&gt;]+&gt;(.+)&lt;/annotation&gt;')		-- extract just the math text
	else
		return false, value;													-- had math stripmarker but not one of the three defined forms
	end
	
	return true, value:gsub (stripmarker, rendering, 1);
end


--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain html entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaces math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?

]]

local function coins_cleanup (value)
	local replaced = true;														-- default state to get the do loop running

	while replaced do															-- loop until all math stripmarkers replaced
		replaced, value = coins_replace_math_stripmarker (value);				-- replace math stripmarker with text representation of the equation
	end

	value = value:gsub (cfg.stripmarkers['math'], &quot;MATH RENDER ERROR&quot;);						-- one or more couldn't be replaced; insert vague error message
	
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;(s?)&lt;/span&gt;', &quot;'%1&quot;);	-- replace {{'}} or {{'s}} with simple apostrophe or apostrophe-s
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	value = value:gsub ('&amp;zwj;', '');											-- remove &amp;zwj; entities
	value = value:gsub ('[\226\128\141\226\128\139\194\173]', '')				-- remove zero-width joiner, zero-width space, soft hyphen
	value = value:gsub ('[\009\010\013]', ' ');									-- replace horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'journal', 'news'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if 'arxiv' == class then											-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
			OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;							-- conference paper as chapter in proceedings (book)
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	--{'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation
	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
--		if k == 'ISBN' then v = clean_isbn( v ) end
		if k == 'ISBN' then v = v:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; ); end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v };	-- others; provide a url
		end
	end

--[[	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
]]
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki strip markers, non-printing or invisible characers
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	remove_wiki_link = utilities_page_ptr.remove_wiki_link;
end



return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>05g552e3m2ptwtlpscizxxzeayu7l76</sha1>
    </revision>
    <revision>
      <id>4987</id>
      <parentid>4986</parentid>
      <timestamp>2017-04-29T09:52:12Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>synch from sandbox;</comment>
      <origin>4987</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="16659" sha1="pm4hgl6tjnsc7o9byydo5xhp9r2sj9s" xml:space="preserve">
local coins = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, remove_wiki_link;										-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	if argument:find ( &quot;''&quot;, 1, true ) == nil then								-- Is there at least one double apostrophe?  If not, exit.
		return argument;
	end

	while true do
		if argument:find ( &quot;'''''&quot;, 1, true ) then								-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:find ( &quot;''''&quot;, 1, true ) then							-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;'''&quot;, 1, true ) then							-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;''&quot;, 1, true ) then								-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't corrupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]

local function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other lua magic pattern characters
	return argument;
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end


--[=[-------------------------&lt; C O I N S _ R E P L A C E _ M A T H _ S T R I P M A R K E R &gt;------------------

There are three options for math markup rendering that depend on the editor's math preference settings.  These
settings are at [[Special:Preferences#mw-prefsection-rendering]] and are
	PNG images
	TeX source
	MathML with SVG or PNG fallback

All three are heavy with html and css which doesn't belong in the metadata.

Without this function, the metadata saved in the raw wikitext contained the rendering determined by the settings
of the last editor to save the page.

This function gets the rendered form of an equation according to the editor's preference before the page is saved.  It
then searches the rendering for the text equivalent of the rendered equation and replaces the rendering with that so
that the page is saved without extraneous html/css markup and with a reasonably readable text form of the equation.

When a replacement is made, this function returns true and the value with replacement; otherwise false and the intital
value.  To replace multipe equations it is necesary to call this function from within a loop.

]=]

local function coins_replace_math_stripmarker (value)
	local stripmarker = cfg.stripmarkers['math'];
	local rendering = value:match (stripmarker);								-- is there a math stripmarker

	if not rendering then														-- when value doesn't have a math stripmarker, abandon this test
		return false, value;
	end
	
	rendering = mw.text.unstripNoWiki (rendering);								-- convert stripmarker into rendered value (or nil? ''? when math render error)
	
	if rendering:match ('alt=&quot;[^&quot;]+&quot;') then										-- if PNG math option
		rendering = rendering:match ('alt=&quot;([^&quot;]+)&quot;');							-- extract just the math text
	elseif rendering:match ('$%s+.+%s+%$') then									-- if TeX math option; $ is legit character that is escapes as \$
		rendering = rendering:match ('$%s+(.+)%s+%$')							-- extract just the math text
	elseif rendering:match ('&lt;annotation[^&gt;]+&gt;.+&lt;/annotation&gt;') then			-- if MathML math option
		rendering = rendering:match ('&lt;annotation[^&gt;]+&gt;(.+)&lt;/annotation&gt;')		-- extract just the math text
	else
		return false, value;													-- had math stripmarker but not one of the three defined forms
	end
	
	return true, value:gsub (stripmarker, rendering, 1);
end


--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain html entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaces math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?

]]

local function coins_cleanup (value)
	local replaced = true;														-- default state to get the do loop running

	while replaced do															-- loop until all math stripmarkers replaced
		replaced, value = coins_replace_math_stripmarker (value);				-- replace math stripmarker with text representation of the equation
	end

	value = value:gsub (cfg.stripmarkers['math'], &quot;MATH RENDER ERROR&quot;);						-- one or more couldn't be replaced; insert vague error message
	
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;(s?)&lt;/span&gt;', &quot;'%1&quot;);	-- replace {{'}} or {{'s}} with simple apostrophe or apostrophe-s
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	value = value:gsub ('&amp;zwj;', '');											-- remove &amp;zwj; entities
	value = value:gsub ('[\226\128\141\226\128\139\194\173]', '')				-- remove zero-width joiner, zero-width space, soft hyphen
	value = value:gsub ('[\009\010\013]', ' ');									-- replace horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'biorxiv', 'citeseerx', 'journal', 'news'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if in_array (class, {'arxiv', 'biorxiv', 'citeseerx'}) then			-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv, cite biorxiv, cite citeseerx
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
			OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;							-- conference paper as chapter in proceedings (book)
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	--{'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation
	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
--		if k == 'ISBN' then v = clean_isbn( v ) end
		if k == 'ISBN' then v = v:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; ); end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v };	-- others; provide a url
		end
	end

--[[	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
]]
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki strip markers, non-printing or invisible characers
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	remove_wiki_link = utilities_page_ptr.remove_wiki_link;
end



return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>pm4hgl6tjnsc7o9byydo5xhp9r2sj9s</sha1>
    </revision>
    <revision>
      <id>4988</id>
      <parentid>4987</parentid>
      <timestamp>2017-05-02T16:22:11Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>long-time corrupted-metadata bug fixed;</comment>
      <origin>4988</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="16669" sha1="4995qhrt3cjizstwz85s4vt36gml0uj" xml:space="preserve">
local coins = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, remove_wiki_link;										-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	if argument:find ( &quot;''&quot;, 1, true ) == nil then								-- Is there at least one double apostrophe?  If not, exit.
		return argument;
	end

	while true do
		if argument:find ( &quot;'''''&quot;, 1, true ) then								-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:find ( &quot;''''&quot;, 1, true ) then							-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;'''&quot;, 1, true ) then							-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;''&quot;, 1, true ) then								-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't corrupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]

local function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other lua magic pattern characters
	return argument;
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end


--[=[-------------------------&lt; C O I N S _ R E P L A C E _ M A T H _ S T R I P M A R K E R &gt;------------------

There are three options for math markup rendering that depend on the editor's math preference settings.  These
settings are at [[Special:Preferences#mw-prefsection-rendering]] and are
	PNG images
	TeX source
	MathML with SVG or PNG fallback

All three are heavy with html and css which doesn't belong in the metadata.

Without this function, the metadata saved in the raw wikitext contained the rendering determined by the settings
of the last editor to save the page.

This function gets the rendered form of an equation according to the editor's preference before the page is saved.  It
then searches the rendering for the text equivalent of the rendered equation and replaces the rendering with that so
that the page is saved without extraneous html/css markup and with a reasonably readable text form of the equation.

When a replacement is made, this function returns true and the value with replacement; otherwise false and the intital
value.  To replace multipe equations it is necesary to call this function from within a loop.

]=]

local function coins_replace_math_stripmarker (value)
	local stripmarker = cfg.stripmarkers['math'];
	local rendering = value:match (stripmarker);								-- is there a math stripmarker

	if not rendering then														-- when value doesn't have a math stripmarker, abandon this test
		return false, value;
	end
	
	rendering = mw.text.unstripNoWiki (rendering);								-- convert stripmarker into rendered value (or nil? ''? when math render error)
	
	if rendering:match ('alt=&quot;[^&quot;]+&quot;') then										-- if PNG math option
		rendering = rendering:match ('alt=&quot;([^&quot;]+)&quot;');							-- extract just the math text
	elseif rendering:match ('$%s+.+%s+%$') then									-- if TeX math option; $ is legit character that is escapes as \$
		rendering = rendering:match ('$%s+(.+)%s+%$')							-- extract just the math text
	elseif rendering:match ('&lt;annotation[^&gt;]+&gt;.+&lt;/annotation&gt;') then			-- if MathML math option
		rendering = rendering:match ('&lt;annotation[^&gt;]+&gt;(.+)&lt;/annotation&gt;')		-- extract just the math text
	else
		return false, value;													-- had math stripmarker but not one of the three defined forms
	end
	
	return true, value:gsub (stripmarker, rendering, 1);
end


--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain html entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaces math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?

]]

local function coins_cleanup (value)
	local replaced = true;														-- default state to get the do loop running

	while replaced do															-- loop until all math stripmarkers replaced
		replaced, value = coins_replace_math_stripmarker (value);				-- replace math stripmarker with text representation of the equation
	end

	value = value:gsub (cfg.stripmarkers['math'], &quot;MATH RENDER ERROR&quot;);						-- one or more couldn't be replaced; insert vague error message
	
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;(s?)&lt;/span&gt;', &quot;'%1&quot;);	-- replace {{'}} or {{'s}} with simple apostrophe or apostrophe-s
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	value = value:gsub ('&amp;zwj;', '');											-- remove &amp;zwj; entities
	value = mw.ustring.gsub (value, '[\226\128\141\226\128\139\194\173]', '');	-- remove zero-width joiner, zero-width space, soft hyphen
	value = value:gsub ('[\009\010\013]', ' ');									-- replace horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'biorxiv', 'citeseerx', 'journal', 'news'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if in_array (class, {'arxiv', 'biorxiv', 'citeseerx'}) then			-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv, cite biorxiv, cite citeseerx
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
			OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;							-- conference paper as chapter in proceedings (book)
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	--{'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation
	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
--		if k == 'ISBN' then v = clean_isbn( v ) end
		if k == 'ISBN' then v = v:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; ); end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v };	-- others; provide a url
		end
	end

--[[	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
]]
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki strip markers, non-printing or invisible characers
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	remove_wiki_link = utilities_page_ptr.remove_wiki_link;
end



return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>4995qhrt3cjizstwz85s4vt36gml0uj</sha1>
    </revision>
    <revision>
      <id>4989</id>
      <parentid>4988</parentid>
      <timestamp>2017-11-04T10:41:13Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>synch from sandbox;</comment>
      <origin>4989</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="16800" sha1="coep8us87urtrppcmr74si4z4ldv4gs" xml:space="preserve">
local coins = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]
local is_set, in_array, remove_wiki_link;										-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	if argument:find ( &quot;''&quot;, 1, true ) == nil then								-- Is there at least one double apostrophe?  If not, exit.
		return argument;
	end

	while true do
		if argument:find ( &quot;'''''&quot;, 1, true ) then								-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:find ( &quot;''''&quot;, 1, true ) then							-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;'''&quot;, 1, true ) then							-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;''&quot;, 1, true ) then								-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't corrupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]

local function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other lua magic pattern characters
	return argument;
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end


--[=[-------------------------&lt; C O I N S _ R E P L A C E _ M A T H _ S T R I P M A R K E R &gt;------------------

There are three options for math markup rendering that depend on the editor's math preference settings.  These
settings are at [[Special:Preferences#mw-prefsection-rendering]] and are
	PNG images
	TeX source
	MathML with SVG or PNG fallback

All three are heavy with html and css which doesn't belong in the metadata.

Without this function, the metadata saved in the raw wikitext contained the rendering determined by the settings
of the last editor to save the page.

This function gets the rendered form of an equation according to the editor's preference before the page is saved.  It
then searches the rendering for the text equivalent of the rendered equation and replaces the rendering with that so
that the page is saved without extraneous html/css markup and with a reasonably readable text form of the equation.

When a replacement is made, this function returns true and the value with replacement; otherwise false and the intital
value.  To replace multipe equations it is necesary to call this function from within a loop.

]=]

local function coins_replace_math_stripmarker (value)
	local stripmarker = cfg.stripmarkers['math'];
	local rendering = value:match (stripmarker);								-- is there a math stripmarker

	if not rendering then														-- when value doesn't have a math stripmarker, abandon this test
		return false, value;
	end
	
	rendering = mw.text.unstripNoWiki (rendering);								-- convert stripmarker into rendered value (or nil? ''? when math render error)
	
	if rendering:match ('alt=&quot;[^&quot;]+&quot;') then										-- if PNG math option
		rendering = rendering:match ('alt=&quot;([^&quot;]+)&quot;');							-- extract just the math text
	elseif rendering:match ('$%s+.+%s+%$') then									-- if TeX math option; $ is legit character that is escapes as \$
		rendering = rendering:match ('$%s+(.+)%s+%$')							-- extract just the math text
	elseif rendering:match ('&lt;annotation[^&gt;]+&gt;.+&lt;/annotation&gt;') then			-- if MathML math option
		rendering = rendering:match ('&lt;annotation[^&gt;]+&gt;(.+)&lt;/annotation&gt;')		-- extract just the math text
	else
		return false, value;													-- had math stripmarker but not one of the three defined forms
	end
	
	return true, value:gsub (stripmarker, rendering, 1);
end


--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain html entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaces math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?

]]

local function coins_cleanup (value)
	local replaced = true;														-- default state to get the do loop running

	while replaced do															-- loop until all math stripmarkers replaced
		replaced, value = coins_replace_math_stripmarker (value);				-- replace math stripmarker with text representation of the equation
	end

	value = value:gsub (cfg.stripmarkers['math'], &quot;MATH RENDER ERROR&quot;);						-- one or more couldn't be replaced; insert vague error message
	
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;(s?)&lt;/span&gt;', &quot;'%1&quot;);	-- replace {{'}} or {{'s}} with simple apostrophe or apostrophe-s
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	if not mw.ustring.find (value, cfg.indic_script) then						-- don't remove zero width joiner characters from indic script
		value = value:gsub ('&amp;zwj;', '');											-- remove &amp;zwj; entities
		value = mw.ustring.gsub (value, '[\226\128\141\226\128\139\194\173]', '');	-- remove zero-width joiner, zero-width space, soft hyphen
	end
	value = value:gsub ('[\009\010\013]', ' ');									-- replace horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'biorxiv', 'citeseerx', 'journal', 'news'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if in_array (class, {'arxiv', 'biorxiv', 'citeseerx'}) then			-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv, cite biorxiv, cite citeseerx
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
			OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;							-- conference paper as chapter in proceedings (book)
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	--{'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation
	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
--		if k == 'ISBN' then v = clean_isbn( v ) end
		if k == 'ISBN' then v = v:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; ); end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v };	-- others; provide a url
		end
	end

--[[	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
]]
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki strip markers, non-printing or invisible characers
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	--table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	remove_wiki_link = utilities_page_ptr.remove_wiki_link;
end



return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>coep8us87urtrppcmr74si4z4ldv4gs</sha1>
    </revision>
    <revision>
      <id>4990</id>
      <parentid>4989</parentid>
      <timestamp>2018-09-29T13:26:22Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>synch from sandbox;</comment>
      <origin>4990</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="16812" sha1="1uz7v2hiqbm2wga5qnigax1d7ujy26k" xml:space="preserve">
local coins = {};


--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]
local is_set, in_array, remove_wiki_link;										-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	if argument:find ( &quot;''&quot;, 1, true ) == nil then								-- Is there at least one double apostrophe?  If not, exit.
		return argument;
	end

	while true do
		if argument:find ( &quot;'''''&quot;, 1, true ) then								-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:find ( &quot;''''&quot;, 1, true ) then							-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;'''&quot;, 1, true ) then							-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;''&quot;, 1, true ) then								-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't corrupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]

local function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other lua magic pattern characters
	return argument;
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end


--[=[-------------------------&lt; C O I N S _ R E P L A C E _ M A T H _ S T R I P M A R K E R &gt;------------------

There are three options for math markup rendering that depend on the editor's math preference settings.  These
settings are at [[Special:Preferences#mw-prefsection-rendering]] and are
	PNG images
	TeX source
	MathML with SVG or PNG fallback

All three are heavy with html and css which doesn't belong in the metadata.

Without this function, the metadata saved in the raw wikitext contained the rendering determined by the settings
of the last editor to save the page.

This function gets the rendered form of an equation according to the editor's preference before the page is saved.  It
then searches the rendering for the text equivalent of the rendered equation and replaces the rendering with that so
that the page is saved without extraneous html/css markup and with a reasonably readable text form of the equation.

When a replacement is made, this function returns true and the value with replacement; otherwise false and the intital
value.  To replace multipe equations it is necesary to call this function from within a loop.

]=]

local function coins_replace_math_stripmarker (value)
	local stripmarker = cfg.stripmarkers['math'];
	local rendering = value:match (stripmarker);								-- is there a math stripmarker

	if not rendering then														-- when value doesn't have a math stripmarker, abandon this test
		return false, value;
	end
	
	rendering = mw.text.unstripNoWiki (rendering);								-- convert stripmarker into rendered value (or nil? ''? when math render error)
	
	if rendering:match ('alt=&quot;[^&quot;]+&quot;') then										-- if PNG math option
		rendering = rendering:match ('alt=&quot;([^&quot;]+)&quot;');							-- extract just the math text
	elseif rendering:match ('$%s+.+%s+%$') then									-- if TeX math option; $ is legit character that is escapes as \$
		rendering = rendering:match ('$%s+(.+)%s+%$')							-- extract just the math text
	elseif rendering:match ('&lt;annotation[^&gt;]+&gt;.+&lt;/annotation&gt;') then			-- if MathML math option
		rendering = rendering:match ('&lt;annotation[^&gt;]+&gt;(.+)&lt;/annotation&gt;')		-- extract just the math text
	else
		return false, value;													-- had math stripmarker but not one of the three defined forms
	end
	
	return true, value:gsub (stripmarker, rendering, 1);
end


--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain html entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaces math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?

]]

local function coins_cleanup (value)
	local replaced = true;														-- default state to get the do loop running

	while replaced do															-- loop until all math stripmarkers replaced
		replaced, value = coins_replace_math_stripmarker (value);				-- replace math stripmarker with text representation of the equation
	end

	value = value:gsub (cfg.stripmarkers['math'], &quot;MATH RENDER ERROR&quot;);						-- one or more couldn't be replaced; insert vague error message
	
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;(s?)&lt;/span&gt;', &quot;'%1&quot;);	-- replace {{'}} or {{'s}} with simple apostrophe or apostrophe-s
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	if not mw.ustring.find (value, cfg.indic_script) then						-- don't remove zero width joiner characters from indic script
		value = value:gsub ('&amp;zwj;', '');											-- remove &amp;zwj; entities
		value = mw.ustring.gsub (value, '[\226\128\141\226\128\139\194\173]', '');	-- remove zero-width joiner, zero-width space, soft hyphen
	end
	value = value:gsub ('[\009\010\013]', ' ');									-- replace horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'biorxiv', 'citeseerx', 'journal', 'news', 'magazine'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if in_array (class, {'arxiv', 'biorxiv', 'citeseerx'}) then			-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv, cite biorxiv, cite citeseerx
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
			OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;							-- conference paper as chapter in proceedings (book)
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	--{'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation
	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
--		if k == 'ISBN' then v = clean_isbn( v ) end
		if k == 'ISBN' then v = v:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; ); end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v };	-- others; provide a url
		end
	end

--[[	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
]]
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki strip markers, non-printing or invisible characers
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	--table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	remove_wiki_link = utilities_page_ptr.remove_wiki_link;
end



return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>1uz7v2hiqbm2wga5qnigax1d7ujy26k</sha1>
    </revision>
    <revision>
      <id>4991</id>
      <parentid>4990</parentid>
      <timestamp>2019-04-20T13:20:08Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4991</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="16860" sha1="75clr9wbrojzv11qjlc7bn6dxvql5mg" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, remove_wiki_link;										-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; S T R I P _ A P O S T R O P H E _ M A R K U P &gt;--------------------------------

Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata.
This function strips common patterns of apostrophe markup.  We presume that editors who have taken the time to
markup a title have, as a result, provided valid markup. When they don't, some single apostrophes are left behind.

]]

local function strip_apostrophe_markup (argument)
	if not is_set (argument) then return argument; end

	if argument:find ( &quot;''&quot;, 1, true ) == nil then								-- Is there at least one double apostrophe?  If not, exit.
		return argument;
	end

	while true do
		if argument:find ( &quot;'''''&quot;, 1, true ) then								-- bold italic (5)
			argument=argument:gsub(&quot;%'%'%'%'%'&quot;, &quot;&quot;);							-- remove all instances of it
		elseif argument:find ( &quot;''''&quot;, 1, true ) then							-- italic start and end without content (4)
			argument=argument:gsub(&quot;%'%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;'''&quot;, 1, true ) then							-- bold (3)
			argument=argument:gsub(&quot;%'%'%'&quot;, &quot;&quot;);
		elseif argument:find ( &quot;''&quot;, 1, true ) then								-- italic (2)
			argument=argument:gsub(&quot;%'%'&quot;, &quot;&quot;);
		else
			break;
		end
	end
	return argument;															-- done
end


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't corrupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]

local function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other lua magic pattern characters
	return argument;
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end


--[=[-------------------------&lt; C O I N S _ R E P L A C E _ M A T H _ S T R I P M A R K E R &gt;------------------

There are three options for math markup rendering that depend on the editor's math preference settings.  These
settings are at [[Special:Preferences#mw-prefsection-rendering]] and are
	PNG images
	TeX source
	MathML with SVG or PNG fallback

All three are heavy with html and css which doesn't belong in the metadata.

Without this function, the metadata saved in the raw wikitext contained the rendering determined by the settings
of the last editor to save the page.

This function gets the rendered form of an equation according to the editor's preference before the page is saved.  It
then searches the rendering for the text equivalent of the rendered equation and replaces the rendering with that so
that the page is saved without extraneous html/css markup and with a reasonably readable text form of the equation.

When a replacement is made, this function returns true and the value with replacement; otherwise false and the intital
value.  To replace multipe equations it is necesary to call this function from within a loop.

]=]

local function coins_replace_math_stripmarker (value)
	local stripmarker = cfg.stripmarkers['math'];
	local rendering = value:match (stripmarker);								-- is there a math stripmarker

	if not rendering then														-- when value doesn't have a math stripmarker, abandon this test
		return false, value;
	end
	
	rendering = mw.text.unstripNoWiki (rendering);								-- convert stripmarker into rendered value (or nil? ''? when math render error)
	
	if rendering:match ('alt=&quot;[^&quot;]+&quot;') then										-- if PNG math option
		rendering = rendering:match ('alt=&quot;([^&quot;]+)&quot;');							-- extract just the math text
	elseif rendering:match ('$%s+.+%s+%$') then									-- if TeX math option; $ is legit character that is escapes as \$
		rendering = rendering:match ('$%s+(.+)%s+%$')							-- extract just the math text
	elseif rendering:match ('&lt;annotation[^&gt;]+&gt;.+&lt;/annotation&gt;') then			-- if MathML math option
		rendering = rendering:match ('&lt;annotation[^&gt;]+&gt;(.+)&lt;/annotation&gt;')		-- extract just the math text
	else
		return false, value;													-- had math stripmarker but not one of the three defined forms
	end
	
	return true, value:gsub (stripmarker, rendering, 1);
end


--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain html entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaces math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?

]]

local function coins_cleanup (value)
	local replaced = true;														-- default state to get the do loop running

	while replaced do															-- loop until all math stripmarkers replaced
		replaced, value = coins_replace_math_stripmarker (value);				-- replace math stripmarker with text representation of the equation
	end

	value = value:gsub (cfg.stripmarkers['math'], &quot;MATH RENDER ERROR&quot;);						-- one or more couldn't be replaced; insert vague error message
	
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;(s?)&lt;/span&gt;', &quot;'%1&quot;);	-- replace {{'}} or {{'s}} with simple apostrophe or apostrophe-s
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	if not mw.ustring.find (value, cfg.indic_script) then						-- don't remove zero width joiner characters from indic script
		value = value:gsub ('&amp;zwj;', '');											-- remove &amp;zwj; entities
		value = mw.ustring.gsub (value, '[\226\128\141\226\128\139\194\173]', '');	-- remove zero-width joiner, zero-width space, soft hyphen
	end
	value = value:gsub ('[\009\010\013]', ' ');									-- replace horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'biorxiv', 'citeseerx', 'journal', 'news', 'magazine'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if in_array (class, {'arxiv', 'biorxiv', 'citeseerx'}) then			-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv, cite biorxiv, cite citeseerx
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
			OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;							-- conference paper as chapter in proceedings (book)
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	--{'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation
	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		if k == 'ISBN' then v = v:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; ); end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v };	-- others; provide a url
		end
	end

--[[	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		local id, value = cfg.id_handlers[k].COinS;
		if k == 'ISBN' then value = clean_isbn( v ); else value = v; end
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		else
			OCinSoutput[ id ] = value;
		end
	end
]]
	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki strip markers, non-printing or invisible characers
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	--table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from select Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	remove_wiki_link = utilities_page_ptr.remove_wiki_link;
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>75clr9wbrojzv11qjlc7bn6dxvql5mg</sha1>
    </revision>
    <revision>
      <id>4992</id>
      <parentid>4991</parentid>
      <timestamp>2019-09-03T11:05:48Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4992</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="15310" sha1="l8s94fpb0lbhviey5aqaamradc5q20u" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, remove_wiki_link, strip_apostrophe_markup;				-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't corrupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title='';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script='';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]

local function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other lua magic pattern characters
	return argument;
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the url and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more urls
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace html entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end


--[=[-------------------------&lt; C O I N S _ R E P L A C E _ M A T H _ S T R I P M A R K E R &gt;------------------

There are three options for math markup rendering that depend on the editor's math preference settings.  These
settings are at [[Special:Preferences#mw-prefsection-rendering]] and are
	PNG images
	TeX source
	MathML with SVG or PNG fallback

All three are heavy with html and css which doesn't belong in the metadata.

Without this function, the metadata saved in the raw wikitext contained the rendering determined by the settings
of the last editor to save the page.

This function gets the rendered form of an equation according to the editor's preference before the page is saved.  It
then searches the rendering for the text equivalent of the rendered equation and replaces the rendering with that so
that the page is saved without extraneous html/css markup and with a reasonably readable text form of the equation.

When a replacement is made, this function returns true and the value with replacement; otherwise false and the intital
value.  To replace multipe equations it is necesary to call this function from within a loop.

]=]

local function coins_replace_math_stripmarker (value)
	local stripmarker = cfg.stripmarkers['math'];
	local rendering = value:match (stripmarker);								-- is there a math stripmarker

	if not rendering then														-- when value doesn't have a math stripmarker, abandon this test
		return false, value;
	end
	
	rendering = mw.text.unstripNoWiki (rendering);								-- convert stripmarker into rendered value (or nil? ''? when math render error)
	
	if rendering:match ('alt=&quot;[^&quot;]+&quot;') then										-- if PNG math option
		rendering = rendering:match ('alt=&quot;([^&quot;]+)&quot;');							-- extract just the math text
	elseif rendering:match ('$%s+.+%s+%$') then									-- if TeX math option; $ is legit character that is escapes as \$
		rendering = rendering:match ('$%s+(.+)%s+%$')							-- extract just the math text
	elseif rendering:match ('&lt;annotation[^&gt;]+&gt;.+&lt;/annotation&gt;') then			-- if MathML math option
		rendering = rendering:match ('&lt;annotation[^&gt;]+&gt;(.+)&lt;/annotation&gt;')		-- extract just the math text
	else
		return false, value;													-- had math stripmarker but not one of the three defined forms
	end
	
	return true, value:gsub (stripmarker, rendering, 1);
end


--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain html entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaces math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?

]]

local function coins_cleanup (value)
	local replaced = true;														-- default state to get the do loop running

	while replaced do															-- loop until all math stripmarkers replaced
		replaced, value = coins_replace_math_stripmarker (value);				-- replace math stripmarker with text representation of the equation
	end

	value = value:gsub (cfg.stripmarkers['math'], &quot;MATH RENDER ERROR&quot;);						-- one or more couldn't be replaced; insert vague error message
	
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;(s?)&lt;/span&gt;', &quot;'%1&quot;);	-- replace {{'}} or {{'s}} with simple apostrophe or apostrophe-s
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	if not mw.ustring.find (value, cfg.indic_script) then						-- don't remove zero width joiner characters from indic script
		value = value:gsub ('&amp;zwj;', '');											-- remove &amp;zwj; entities
		value = mw.ustring.gsub (value, '[\226\128\141\226\128\139\194\173]', '');	-- remove zero-width joiner, zero-width space, soft hyphen
	end
	value = value:gsub ('[\009\010\013]', ' ');									-- replace horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'biorxiv', 'citeseerx', 'ssrn', 'journal', 'news', 'magazine'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if in_array (class, {'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) then	-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv, cite biorxiv, cite citeseerx, cite ssrn
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
			OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;							-- conference paper as chapter in proceedings (book)
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	--{'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation
	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		if k == 'ISBN' then v = v:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; ); end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v };	-- others; provide a url
		end
	end

	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki strip markers, non-printing or invisible characers
		if k == 1 then															-- for the first author name only
			if is_set(last)  and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };
	OCinSoutput = setmetatable( OCinSoutput, nil );
	
	-- sort with version string always first, and combine.
	--table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver );  -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from selected Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	remove_wiki_link = utilities_page_ptr.remove_wiki_link;
	strip_apostrophe_markup = utilities_page_ptr.strip_apostrophe_markup;
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>l8s94fpb0lbhviey5aqaamradc5q20u</sha1>
    </revision>
    <revision>
      <id>4993</id>
      <parentid>4992</parentid>
      <timestamp>2021-01-09T14:11:09Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4993</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="16313" sha1="e95njrdgmzt3kt3wm971pnfodhvzwms" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, remove_wiki_link, strip_apostrophe_markup;				-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't corrupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title = '';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script = '';																-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of Lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]

local function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other Lua magic pattern characters
	return argument;
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the URL and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more URLs
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape Lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );							-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );						-- and replace HTML entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end


--[=[-------------------------&lt; C O I N S _ R E P L A C E _ M A T H _ S T R I P M A R K E R &gt;------------------

There are three options for math markup rendering that depend on the editor's math preference settings.  These
settings are at [[Special:Preferences#mw-prefsection-rendering]] and are
	PNG images
	TeX source
	MathML with SVG or PNG fallback

All three are heavy with HTML and CSS which doesn't belong in the metadata.

Without this function, the metadata saved in the raw wikitext contained the rendering determined by the settings
of the last editor to save the page.

This function gets the rendered form of an equation according to the editor's preference before the page is saved.  It
then searches the rendering for the text equivalent of the rendered equation and replaces the rendering with that so
that the page is saved without extraneous HTML/CSS markup and with a reasonably readable text form of the equation.

When a replacement is made, this function returns true and the value with replacement; otherwise false and the initial
value.  To replace multipe equations it is necessary to call this function from within a loop.

]=]

local function coins_replace_math_stripmarker (value)
	local stripmarker = cfg.stripmarkers['math'];
	local rendering = value:match (stripmarker);								-- is there a math stripmarker

	if not rendering then														-- when value doesn't have a math stripmarker, abandon this test
		return false, value;
	end
	
	rendering = mw.text.unstripNoWiki (rendering);								-- convert stripmarker into rendered value (or nil? ''? when math render error)
	
	if rendering:match ('alt=&quot;[^&quot;]+&quot;') then										-- if PNG math option
		rendering = rendering:match ('alt=&quot;([^&quot;]+)&quot;');							-- extract just the math text
	elseif rendering:match ('$%s+.+%s+%$') then									-- if TeX math option; $ is legit character that is escapes as \$
		rendering = rendering:match ('$%s+(.+)%s+%$')							-- extract just the math text
	elseif rendering:match ('&lt;annotation[^&gt;]+&gt;.+&lt;/annotation&gt;') then			-- if MathML math option
		rendering = rendering:match ('&lt;annotation[^&gt;]+&gt;(.+)&lt;/annotation&gt;')		-- extract just the math text
	else
		return false, value;													-- had math stripmarker but not one of the three defined forms
	end
	
	return true, value:gsub (stripmarker, rendering, 1);
end


--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain HTML entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaces math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?

]]

local function coins_cleanup (value)
	local replaced = true;														-- default state to get the do loop running

	while replaced do															-- loop until all math stripmarkers replaced
		replaced, value = coins_replace_math_stripmarker (value);				-- replace math stripmarker with text representation of the equation
	end

	value = value:gsub (cfg.stripmarkers['math'], &quot;MATH RENDER ERROR&quot;);						-- one or more couldn't be replaced; insert vague error message
	
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;(s?)&lt;/span&gt;', &quot;'%1&quot;);	-- replace {{'}} or {{'s}} with simple apostrophe or apostrophe-s
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	if not mw.ustring.find (value, cfg.indic_script) then						-- don't remove zero-width joiner characters from indic script
		value = value:gsub ('&amp;zwj;', '');											-- remove &amp;zwj; entities
		value = mw.ustring.gsub (value, '[\226\128\141\226\128\139\194\173]', '');	-- remove zero-width joiner, zero-width space, soft hyphen
	end
	value = value:gsub ('[\009\010\013 ]+', ' ');									-- replace horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'biorxiv', 'citeseerx', 'ssrn', 'journal', 'news', 'magazine'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if in_array (class, {'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) then	-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv, cite biorxiv, cite citeseerx, cite ssrn
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.quarter&quot;] = data.Quarter;							-- single digits 1-&gt;first quarter, etc.
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
			OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;							-- conference paper as chapter in proceedings (book)
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	-- {'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
	-- NB. Not currently supported are &quot;info:ofi/fmt:kev:mtx:patent&quot;, &quot;info:ofi/fmt:kev:mtx:dc&quot;, &quot;info:ofi/fmt:kev:mtx:sch_svc&quot;, &quot;info:ofi/fmt:kev:mtx:ctx&quot;
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation

	-- TODO: data.ID_list should also contain identifier validity status (to suppress output of invalid identifier metadata) as well as OL A/M/W/X type and ASIN TLD info (to special-case prefix generation)
	
	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		if k == 'ISBN' then v = v:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; ); end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc. that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v, cfg.id_handlers[k].suffix or '', &quot;#id-name=&quot;, cfg.id_handlers[k].label };	-- others; provide a URL and indicate identifier name as #fragment (human-readable, but transparent to browsers)
		end
	end

	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki stripmarkers, non-printing or invisible characters
		if k == 1 then															-- for the first author name only
			if is_set(last) and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
			-- TODO: At present we do not report &quot;et al.&quot;. Add anything special if this condition applies?
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };

	-- TODO: Add optional extra info:
	-- rfr_dat=#REVISION&lt;version&gt; (referrer private data)
	-- ctx_id=&lt;data.RawPage&gt;#&lt;ref&gt; (identifier for the context object)
	-- ctx_tim=&lt;ts&gt; (timestamp in format yyyy-mm-ddThh:mm:ssTZD or yyyy-mm-dd)
	-- ctx_enc=info:ofi/enc:UTF-8 (character encoding)
	
	OCinSoutput = setmetatable( OCinSoutput, nil );

	-- sort with version string always first, and combine.
	-- table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver ); -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from selected Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	remove_wiki_link = utilities_page_ptr.remove_wiki_link;
	strip_apostrophe_markup = utilities_page_ptr.strip_apostrophe_markup;
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>e95njrdgmzt3kt3wm971pnfodhvzwms</sha1>
    </revision>
    <revision>
      <id>4994</id>
      <parentid>4993</parentid>
      <timestamp>2021-04-10T13:14:45Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4994</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="16336" sha1="lqjm8eawzfik98gj25kc03pr48t7x6z" xml:space="preserve">
--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local is_set, in_array, remove_wiki_link, strip_apostrophe_markup;				-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't corrupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title = '';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script = '';															-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of Lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]

local function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other Lua magic pattern characters
	return argument;
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the URL and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more URLs
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape Lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );												-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );											-- and replace HTML entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end


--[=[-------------------------&lt; C O I N S _ R E P L A C E _ M A T H _ S T R I P M A R K E R &gt;------------------

There are three options for math markup rendering that depend on the editor's math preference settings.  These
settings are at [[Special:Preferences#mw-prefsection-rendering]] and are
	PNG images
	TeX source
	MathML with SVG or PNG fallback

All three are heavy with HTML and CSS which doesn't belong in the metadata.

Without this function, the metadata saved in the raw wikitext contained the rendering determined by the settings
of the last editor to save the page.

This function gets the rendered form of an equation according to the editor's preference before the page is saved.  It
then searches the rendering for the text equivalent of the rendered equation and replaces the rendering with that so
that the page is saved without extraneous HTML/CSS markup and with a reasonably readable text form of the equation.

When a replacement is made, this function returns true and the value with replacement; otherwise false and the initial
value.  To replace multipe equations it is necessary to call this function from within a loop.

]=]

local function coins_replace_math_stripmarker (value)
	local stripmarker = cfg.stripmarkers['math'];
	local rendering = value:match (stripmarker);								-- is there a math stripmarker

	if not rendering then														-- when value doesn't have a math stripmarker, abandon this test
		return false, value;
	end
	
	rendering = mw.text.unstripNoWiki (rendering);								-- convert stripmarker into rendered value (or nil? ''? when math render error)
	
	if rendering:match ('alt=&quot;[^&quot;]+&quot;') then										-- if PNG math option
		rendering = rendering:match ('alt=&quot;([^&quot;]+)&quot;');							-- extract just the math text
	elseif rendering:match ('$%s+.+%s+%$') then									-- if TeX math option; $ is legit character that is escapes as \$
		rendering = rendering:match ('$%s+(.+)%s+%$')							-- extract just the math text
	elseif rendering:match ('&lt;annotation[^&gt;]+&gt;.+&lt;/annotation&gt;') then			-- if MathML math option
		rendering = rendering:match ('&lt;annotation[^&gt;]+&gt;(.+)&lt;/annotation&gt;')		-- extract just the math text
	else
		return false, value;													-- had math stripmarker but not one of the three defined forms
	end
	
	return true, value:gsub (stripmarker, rendering, 1);
end


--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain HTML entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaces math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?

]]

local function coins_cleanup (value)
	local replaced = true;														-- default state to get the do loop running

	while replaced do															-- loop until all math stripmarkers replaced
		replaced, value = coins_replace_math_stripmarker (value);				-- replace math stripmarker with text representation of the equation
	end

	value = value:gsub (cfg.stripmarkers['math'], &quot;MATH RENDER ERROR&quot;);			-- one or more couldn't be replaced; insert vague error message
	
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;(s?)&lt;/span&gt;', &quot;'%1&quot;);	-- replace {{'}} or {{'s}} with simple apostrophe or apostrophe-s
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	if not mw.ustring.find (value, cfg.indic_script) then						-- don't remove zero-width joiner characters from indic script
		value = value:gsub ('&amp;zwj;', '');										-- remove &amp;zwj; entities
		value = mw.ustring.gsub (value, '[\226\128\141\226\128\139\194\173]', '');	-- remove zero-width joiner, zero-width space, soft hyphen
	end
	value = value:gsub ('[\009\010\013 ]+', ' ');								-- replace horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'biorxiv', 'citeseerx', 'ssrn', 'journal', 'news', 'magazine'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if in_array (class, {'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) then	-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv, cite biorxiv, cite citeseerx, cite ssrn
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.quarter&quot;] = data.Quarter;							-- single digits 1-&gt;first quarter, etc.
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
			OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;							-- conference paper as chapter in proceedings (book)
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	-- {'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
	-- NB. Not currently supported are &quot;info:ofi/fmt:kev:mtx:patent&quot;, &quot;info:ofi/fmt:kev:mtx:dc&quot;, &quot;info:ofi/fmt:kev:mtx:sch_svc&quot;, &quot;info:ofi/fmt:kev:mtx:ctx&quot;
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation

	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		if k == 'ISBN' then v = v:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; ); end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc. that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif 'url' == id then													-- for urls that are assembled in ~/Identifiers; |asin= and |ol=
			OCinSoutput[&quot;rft_id&quot;] = table.concat ({data.ID_list[k], &quot;#id-name=&quot;, cfg.id_handlers[k].label});
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil so urls created here
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v, cfg.id_handlers[k].suffix or '', &quot;#id-name=&quot;, cfg.id_handlers[k].label };	-- others; provide a URL and indicate identifier name as #fragment (human-readable, but transparent to browsers)
		end
	end

	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki stripmarkers, non-printing or invisible characters
		if k == 1 then															-- for the first author name only
			if is_set(last) and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
			-- TODO: At present we do not report &quot;et al.&quot;. Add anything special if this condition applies?
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };

	-- TODO: Add optional extra info:
	-- rfr_dat=#REVISION&lt;version&gt; (referrer private data)
	-- ctx_id=&lt;data.RawPage&gt;#&lt;ref&gt; (identifier for the context object)
	-- ctx_tim=&lt;ts&gt; (timestamp in format yyyy-mm-ddThh:mm:ssTZD or yyyy-mm-dd)
	-- ctx_enc=info:ofi/enc:UTF-8 (character encoding)
	
	OCinSoutput = setmetatable( OCinSoutput, nil );

	-- sort with version string always first, and combine.
	-- table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver ); -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	is_set = utilities_page_ptr.is_set;											-- import functions from selected Module:Citation/CS1/Utilities module
	in_array = utilities_page_ptr.in_array;
	remove_wiki_link = utilities_page_ptr.remove_wiki_link;
	strip_apostrophe_markup = utilities_page_ptr.strip_apostrophe_markup;
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>lqjm8eawzfik98gj25kc03pr48t7x6z</sha1>
    </revision>
    <revision>
      <id>4995</id>
      <parentid>4994</parentid>
      <timestamp>2022-01-22T14:11:14Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>update per [[Wikipedia:Village_pump_(proposals)#rfc:_shall_we_update_cs1/2?|RfC]];</comment>
      <origin>4995</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="16454" sha1="9vyk9pk52t1pp4siilcbluanw9m1ekz" xml:space="preserve">--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local has_accept_as_written, is_set, in_array, remove_wiki_link, strip_apostrophe_markup;	-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't corrupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	title = has_accept_as_written (title);
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title = '';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script = '';															-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of Lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]

local function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other Lua magic pattern characters
	return argument;
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the URL and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more URLs
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape Lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );												-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );											-- and replace HTML entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end


--[=[-------------------------&lt; C O I N S _ R E P L A C E _ M A T H _ S T R I P M A R K E R &gt;------------------

There are three options for math markup rendering that depend on the editor's math preference settings.  These
settings are at [[Special:Preferences#mw-prefsection-rendering]] and are
	PNG images
	TeX source
	MathML with SVG or PNG fallback

All three are heavy with HTML and CSS which doesn't belong in the metadata.

Without this function, the metadata saved in the raw wikitext contained the rendering determined by the settings
of the last editor to save the page.

This function gets the rendered form of an equation according to the editor's preference before the page is saved.  It
then searches the rendering for the text equivalent of the rendered equation and replaces the rendering with that so
that the page is saved without extraneous HTML/CSS markup and with a reasonably readable text form of the equation.

When a replacement is made, this function returns true and the value with replacement; otherwise false and the initial
value.  To replace multipe equations it is necessary to call this function from within a loop.

]=]

local function coins_replace_math_stripmarker (value)
	local stripmarker = cfg.stripmarkers['math'];
	local rendering = value:match (stripmarker);								-- is there a math stripmarker

	if not rendering then														-- when value doesn't have a math stripmarker, abandon this test
		return false, value;
	end
	
	rendering = mw.text.unstripNoWiki (rendering);								-- convert stripmarker into rendered value (or nil? ''? when math render error)
	
	if rendering:match ('alt=&quot;[^&quot;]+&quot;') then										-- if PNG math option
		rendering = rendering:match ('alt=&quot;([^&quot;]+)&quot;');							-- extract just the math text
	elseif rendering:match ('$%s+.+%s+%$') then									-- if TeX math option; $ is legit character that is escapes as \$
		rendering = rendering:match ('$%s+(.+)%s+%$')							-- extract just the math text
	elseif rendering:match ('&lt;annotation[^&gt;]+&gt;.+&lt;/annotation&gt;') then			-- if MathML math option
		rendering = rendering:match ('&lt;annotation[^&gt;]+&gt;(.+)&lt;/annotation&gt;')		-- extract just the math text
	else
		return false, value;													-- had math stripmarker but not one of the three defined forms
	end
	
	return true, value:gsub (stripmarker, rendering, 1);
end


--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain HTML entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaces math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?

]]

local function coins_cleanup (value)
	local replaced = true;														-- default state to get the do loop running

	while replaced do															-- loop until all math stripmarkers replaced
		replaced, value = coins_replace_math_stripmarker (value);				-- replace math stripmarker with text representation of the equation
	end

	value = value:gsub (cfg.stripmarkers['math'], &quot;MATH RENDER ERROR&quot;);			-- one or more couldn't be replaced; insert vague error message
	
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;(s?)&lt;/span&gt;', &quot;'%1&quot;);	-- replace {{'}} or {{'s}} with simple apostrophe or apostrophe-s
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	if not mw.ustring.find (value, cfg.indic_script) then						-- don't remove zero-width joiner characters from indic script
		value = value:gsub ('&amp;zwj;', '');										-- remove &amp;zwj; entities
		value = mw.ustring.gsub (value, '[\226\128\141\226\128\139\194\173]', '');	-- remove zero-width joiner, zero-width space, soft hyphen
	end
	value = value:gsub ('[\009\010\013 ]+', ' ');								-- replace horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'biorxiv', 'citeseerx', 'ssrn', 'journal', 'news', 'magazine'}) or (in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or 
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if in_array (class, {'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) then	-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv, cite biorxiv, cite citeseerx, cite ssrn
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.quarter&quot;] = data.Quarter;							-- single digits 1-&gt;first quarter, etc.
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
			OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;							-- conference paper as chapter in proceedings (book)
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	-- {'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
	-- NB. Not currently supported are &quot;info:ofi/fmt:kev:mtx:patent&quot;, &quot;info:ofi/fmt:kev:mtx:dc&quot;, &quot;info:ofi/fmt:kev:mtx:sch_svc&quot;, &quot;info:ofi/fmt:kev:mtx:ctx&quot;
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation

	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		if k == 'ISBN' then v = v:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; ); end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc. that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif 'url' == id then													-- for urls that are assembled in ~/Identifiers; |asin= and |ol=
			OCinSoutput[&quot;rft_id&quot;] = table.concat ({data.ID_list[k], &quot;#id-name=&quot;, cfg.id_handlers[k].label});
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil so urls created here
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v, cfg.id_handlers[k].suffix or '', &quot;#id-name=&quot;, cfg.id_handlers[k].label };	-- others; provide a URL and indicate identifier name as #fragment (human-readable, but transparent to browsers)
		end
	end

	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki stripmarkers, non-printing or invisible characters
		if k == 1 then															-- for the first author name only
			if is_set(last) and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
			-- TODO: At present we do not report &quot;et al.&quot;. Add anything special if this condition applies?
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };

	-- TODO: Add optional extra info:
	-- rfr_dat=#REVISION&lt;version&gt; (referrer private data)
	-- ctx_id=&lt;data.RawPage&gt;#&lt;ref&gt; (identifier for the context object)
	-- ctx_tim=&lt;ts&gt; (timestamp in format yyyy-mm-ddThh:mm:ssTZD or yyyy-mm-dd)
	-- ctx_enc=info:ofi/enc:UTF-8 (character encoding)
	
	OCinSoutput = setmetatable( OCinSoutput, nil );

	-- sort with version string always first, and combine.
	-- table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver ); -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	has_accept_as_written = utilities_page_ptr.has_accept_as_written;			-- import functions from selected Module:Citation/CS1/Utilities module
	is_set = utilities_page_ptr.is_set;
	in_array = utilities_page_ptr.in_array;
	remove_wiki_link = utilities_page_ptr.remove_wiki_link;
	strip_apostrophe_markup = utilities_page_ptr.strip_apostrophe_markup;
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>9vyk9pk52t1pp4siilcbluanw9m1ekz</sha1>
    </revision>
    <revision>
      <id>4996</id>
      <parentid>4995</parentid>
      <timestamp>2023-01-14T14:43:36Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4996</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="16536" sha1="a0gmpnpcb8ubdmyykxu2uq3uavog7ta" xml:space="preserve">--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local has_accept_as_written, is_set, in_array, remove_wiki_link, strip_apostrophe_markup;	-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't corrupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	title = has_accept_as_written (title);
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title = '';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script = '';															-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of Lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]

local function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other Lua magic pattern characters
	return argument;
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the URL and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more URLs
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape Lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );												-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );											-- and replace HTML entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end


--[=[-------------------------&lt; C O I N S _ R E P L A C E _ M A T H _ S T R I P M A R K E R &gt;------------------

There are three options for math markup rendering that depend on the editor's math preference settings.  These
settings are at [[Special:Preferences#mw-prefsection-rendering]] and are
	PNG images
	TeX source
	MathML with SVG or PNG fallback

All three are heavy with HTML and CSS which doesn't belong in the metadata.

Without this function, the metadata saved in the raw wikitext contained the rendering determined by the settings
of the last editor to save the page.

This function gets the rendered form of an equation according to the editor's preference before the page is saved.  It
then searches the rendering for the text equivalent of the rendered equation and replaces the rendering with that so
that the page is saved without extraneous HTML/CSS markup and with a reasonably readable text form of the equation.

When a replacement is made, this function returns true and the value with replacement; otherwise false and the initial
value.  To replace multipe equations it is necessary to call this function from within a loop.

]=]

local function coins_replace_math_stripmarker (value)
	local stripmarker = cfg.stripmarkers['math'];
	local rendering = value:match (stripmarker);								-- is there a math stripmarker

	if not rendering then														-- when value doesn't have a math stripmarker, abandon this test
		return false, value;
	end
	
	rendering = mw.text.unstripNoWiki (rendering);								-- convert stripmarker into rendered value (or nil? ''? when math render error)
	
	if rendering:match ('alt=&quot;[^&quot;]+&quot;') then										-- if PNG math option
		rendering = rendering:match ('alt=&quot;([^&quot;]+)&quot;');							-- extract just the math text
	elseif rendering:match ('$%s+.+%s+%$') then									-- if TeX math option; $ is legit character that is escapes as \$
		rendering = rendering:match ('$%s+(.+)%s+%$')							-- extract just the math text
	elseif rendering:match ('&lt;annotation[^&gt;]+&gt;.+&lt;/annotation&gt;') then			-- if MathML math option
		rendering = rendering:match ('&lt;annotation[^&gt;]+&gt;(.+)&lt;/annotation&gt;')		-- extract just the math text
	else
		return false, value;													-- had math stripmarker but not one of the three defined forms
	end
	
	return true, value:gsub (stripmarker, rendering, 1);
end


--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain HTML entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaces math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?

]]

local function coins_cleanup (value)
	local replaced = true;														-- default state to get the do loop running

	while replaced do															-- loop until all math stripmarkers replaced
		replaced, value = coins_replace_math_stripmarker (value);				-- replace math stripmarker with text representation of the equation
	end

	value = value:gsub (cfg.stripmarkers['math'], &quot;MATH RENDER ERROR&quot;);			-- one or more couldn't be replaced; insert vague error message
	
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;(s?)&lt;/span&gt;', &quot;'%1&quot;);	-- replace {{'}} or {{'s}} with simple apostrophe or apostrophe-s
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	if not mw.ustring.find (value, cfg.indic_script) then						-- don't remove zero-width joiner characters from indic script
		value = value:gsub ('&amp;zwj;', '');										-- remove &amp;zwj; entities
		value = mw.ustring.gsub (value, '[\226\128\141\226\128\139\194\173]', '');	-- remove zero-width joiner, zero-width space, soft hyphen
	end
	value = value:gsub ('[\009\010\013 ]+', ' ');								-- replace horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'biorxiv', 'citeseerx', 'ssrn', 'journal', 'news', 'magazine'}) or
		(in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if in_array (class, {'arxiv', 'biorxiv', 'citeseerx', 'ssrn'}) then	-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv, cite biorxiv, cite citeseerx, cite ssrn
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.quarter&quot;] = data.Quarter;							-- single digits 1-&gt;first quarter, etc.
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput['rft.artnum'] = data.ArticleNumber;						-- {{cite journal}} only
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
			OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;							-- conference paper as chapter in proceedings (book)
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	-- {'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
	-- NB. Not currently supported are &quot;info:ofi/fmt:kev:mtx:patent&quot;, &quot;info:ofi/fmt:kev:mtx:dc&quot;, &quot;info:ofi/fmt:kev:mtx:sch_svc&quot;, &quot;info:ofi/fmt:kev:mtx:ctx&quot;
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation

	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		if k == 'ISBN' then v = v:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; ); end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc. that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif 'url' == id then													-- for urls that are assembled in ~/Identifiers; |asin= and |ol=
			OCinSoutput[&quot;rft_id&quot;] = table.concat ({data.ID_list[k], &quot;#id-name=&quot;, cfg.id_handlers[k].label});
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil so urls created here
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v, cfg.id_handlers[k].suffix or '', &quot;#id-name=&quot;, cfg.id_handlers[k].label };	-- others; provide a URL and indicate identifier name as #fragment (human-readable, but transparent to browsers)
		end
	end

	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki stripmarkers, non-printing or invisible characters
		if k == 1 then															-- for the first author name only
			if is_set(last) and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
			-- TODO: At present we do not report &quot;et al.&quot;. Add anything special if this condition applies?
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };

	-- TODO: Add optional extra info:
	-- rfr_dat=#REVISION&lt;version&gt; (referrer private data)
	-- ctx_id=&lt;data.RawPage&gt;#&lt;ref&gt; (identifier for the context object)
	-- ctx_tim=&lt;ts&gt; (timestamp in format yyyy-mm-ddThh:mm:ssTZD or yyyy-mm-dd)
	-- ctx_enc=info:ofi/enc:UTF-8 (character encoding)
	
	OCinSoutput = setmetatable( OCinSoutput, nil );

	-- sort with version string always first, and combine.
	-- table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver ); -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	has_accept_as_written = utilities_page_ptr.has_accept_as_written;			-- import functions from selected Module:Citation/CS1/Utilities module
	is_set = utilities_page_ptr.is_set;
	in_array = utilities_page_ptr.in_array;
	remove_wiki_link = utilities_page_ptr.remove_wiki_link;
	strip_apostrophe_markup = utilities_page_ptr.strip_apostrophe_markup;
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>a0gmpnpcb8ubdmyykxu2uq3uavog7ta</sha1>
    </revision>
    <revision>
      <id>4997</id>
      <parentid>4996</parentid>
      <timestamp>2023-08-12T19:19:02Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4997</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="16572" sha1="9bz6mvz0mzk8yv0c75eqy8rm41au7y9" xml:space="preserve">--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local has_accept_as_written, is_set, in_array, remove_wiki_link, strip_apostrophe_markup;	-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't corrupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	title = has_accept_as_written (title);
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title = '';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script = '';															-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of Lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]

local function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other Lua magic pattern characters
	return argument;
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the URL and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more URLs
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape Lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );												-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );											-- and replace HTML entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	return pages;
end


--[=[-------------------------&lt; C O I N S _ R E P L A C E _ M A T H _ S T R I P M A R K E R &gt;------------------

There are three options for math markup rendering that depend on the editor's math preference settings.  These
settings are at [[Special:Preferences#mw-prefsection-rendering]] and are
	PNG images
	TeX source
	MathML with SVG or PNG fallback

All three are heavy with HTML and CSS which doesn't belong in the metadata.

Without this function, the metadata saved in the raw wikitext contained the rendering determined by the settings
of the last editor to save the page.

This function gets the rendered form of an equation according to the editor's preference before the page is saved.  It
then searches the rendering for the text equivalent of the rendered equation and replaces the rendering with that so
that the page is saved without extraneous HTML/CSS markup and with a reasonably readable text form of the equation.

When a replacement is made, this function returns true and the value with replacement; otherwise false and the initial
value.  To replace multipe equations it is necessary to call this function from within a loop.

]=]

local function coins_replace_math_stripmarker (value)
	local stripmarker = cfg.stripmarkers['math'];
	local rendering = value:match (stripmarker);								-- is there a math stripmarker

	if not rendering then														-- when value doesn't have a math stripmarker, abandon this test
		return false, value;
	end
	
	rendering = mw.text.unstripNoWiki (rendering);								-- convert stripmarker into rendered value (or nil? ''? when math render error)
	
	if rendering:match ('alt=&quot;[^&quot;]+&quot;') then										-- if PNG math option
		rendering = rendering:match ('alt=&quot;([^&quot;]+)&quot;');							-- extract just the math text
	elseif rendering:match ('$%s+.+%s+%$') then									-- if TeX math option; $ is legit character that is escapes as \$
		rendering = rendering:match ('$%s+(.+)%s+%$')							-- extract just the math text
	elseif rendering:match ('&lt;annotation[^&gt;]+&gt;.+&lt;/annotation&gt;') then			-- if MathML math option
		rendering = rendering:match ('&lt;annotation[^&gt;]+&gt;(.+)&lt;/annotation&gt;')		-- extract just the math text
	else
		return false, value;													-- had math stripmarker but not one of the three defined forms
	end
	
	return true, value:gsub (stripmarker, rendering, 1);
end


--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain HTML entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaces math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?

]]

local function coins_cleanup (value)
	local replaced = true;														-- default state to get the do loop running

	while replaced do															-- loop until all math stripmarkers replaced
		replaced, value = coins_replace_math_stripmarker (value);				-- replace math stripmarker with text representation of the equation
	end

	value = value:gsub (cfg.stripmarkers['math'], &quot;MATH RENDER ERROR&quot;);			-- one or more couldn't be replaced; insert vague error message
	
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;(s?)&lt;/span&gt;', &quot;'%1&quot;);	-- replace {{'}} or {{'s}} with simple apostrophe or apostrophe-s
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	if not mw.ustring.find (value, cfg.indic_script) then						-- don't remove zero-width joiner characters from indic script
		value = value:gsub ('&amp;zwj;', '');										-- remove &amp;zwj; entities
		value = mw.ustring.gsub (value, '[\226\128\141\226\128\139\194\173]', '');	-- remove zero-width joiner, zero-width space, soft hyphen
	end
	value = value:gsub ('[\009\010\013 ]+', ' ');								-- replace horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'biorxiv', 'citeseerx', 'medrxiv', 'ssrn', 'journal', 'news', 'magazine'}) or
		(in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if in_array (class, {'arxiv', 'biorxiv', 'citeseerx', 'medrxiv', 'ssrn'}) then	-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv, cite biorxiv, cite citeseerx, cite medrxiv, cite ssrn
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.quarter&quot;] = data.Quarter;							-- single digits 1-&gt;first quarter, etc.
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput['rft.artnum'] = data.ArticleNumber;						-- {{cite journal}} only
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
			OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;							-- conference paper as chapter in proceedings (book)
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	-- {'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
	-- NB. Not currently supported are &quot;info:ofi/fmt:kev:mtx:patent&quot;, &quot;info:ofi/fmt:kev:mtx:dc&quot;, &quot;info:ofi/fmt:kev:mtx:sch_svc&quot;, &quot;info:ofi/fmt:kev:mtx:ctx&quot;
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation

	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		if k == 'ISBN' then v = v:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; ); end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc. that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif 'url' == id then													-- for urls that are assembled in ~/Identifiers; |asin= and |ol=
			OCinSoutput[&quot;rft_id&quot;] = table.concat ({data.ID_list[k], &quot;#id-name=&quot;, cfg.id_handlers[k].label});
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil so urls created here
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v, cfg.id_handlers[k].suffix or '', &quot;#id-name=&quot;, cfg.id_handlers[k].label };	-- others; provide a URL and indicate identifier name as #fragment (human-readable, but transparent to browsers)
		end
	end

	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki stripmarkers, non-printing or invisible characters
		if k == 1 then															-- for the first author name only
			if is_set(last) and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
			-- TODO: At present we do not report &quot;et al.&quot;. Add anything special if this condition applies?
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };

	-- TODO: Add optional extra info:
	-- rfr_dat=#REVISION&lt;version&gt; (referrer private data)
	-- ctx_id=&lt;data.RawPage&gt;#&lt;ref&gt; (identifier for the context object)
	-- ctx_tim=&lt;ts&gt; (timestamp in format yyyy-mm-ddThh:mm:ssTZD or yyyy-mm-dd)
	-- ctx_enc=info:ofi/enc:UTF-8 (character encoding)
	
	OCinSoutput = setmetatable( OCinSoutput, nil );

	-- sort with version string always first, and combine.
	-- table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver ); -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	has_accept_as_written = utilities_page_ptr.has_accept_as_written;			-- import functions from selected Module:Citation/CS1/Utilities module
	is_set = utilities_page_ptr.is_set;
	in_array = utilities_page_ptr.in_array;
	remove_wiki_link = utilities_page_ptr.remove_wiki_link;
	strip_apostrophe_markup = utilities_page_ptr.strip_apostrophe_markup;
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>9bz6mvz0mzk8yv0c75eqy8rm41au7y9</sha1>
    </revision>
    <revision>
      <id>4998</id>
      <parentid>4997</parentid>
      <timestamp>2025-04-12T13:48:47Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>4998</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="16743" sha1="2eba9cn0u4yseyeujt1vmrglxrgcllo" xml:space="preserve">--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local has_accept_as_written, is_set, in_array, remove_wiki_link, strip_apostrophe_markup;	-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't corrupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	title = has_accept_as_written (title);
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title = '';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script = '';															-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of Lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]

local function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other Lua magic pattern characters
	return argument;
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the URL and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more URLs
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape Lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );												-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );											-- and replace HTML entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	pages = pages:gsub ('%b&lt;&gt;', '');											-- remove html-like tags; spans are added to &lt;Pages&gt; by utilities.hyphen_to_dash() which should not appear in COinS metadata
	return pages;
end


--[=[-------------------------&lt; C O I N S _ R E P L A C E _ M A T H _ S T R I P M A R K E R &gt;------------------

There are three options for math markup rendering that depend on the editor's math preference settings.  These
settings are at [[Special:Preferences#mw-prefsection-rendering]] and are
	PNG images
	TeX source
	MathML with SVG or PNG fallback

All three are heavy with HTML and CSS which doesn't belong in the metadata.

Without this function, the metadata saved in the raw wikitext contained the rendering determined by the settings
of the last editor to save the page.

This function gets the rendered form of an equation according to the editor's preference before the page is saved.  It
then searches the rendering for the text equivalent of the rendered equation and replaces the rendering with that so
that the page is saved without extraneous HTML/CSS markup and with a reasonably readable text form of the equation.

When a replacement is made, this function returns true and the value with replacement; otherwise false and the initial
value.  To replace multipe equations it is necessary to call this function from within a loop.

]=]

local function coins_replace_math_stripmarker (value)
	local stripmarker = cfg.stripmarkers['math'];
	local rendering = value:match (stripmarker);								-- is there a math stripmarker

	if not rendering then														-- when value doesn't have a math stripmarker, abandon this test
		return false, value;
	end
	
	rendering = mw.text.unstripNoWiki (rendering);								-- convert stripmarker into rendered value (or nil? ''? when math render error)
	
	if rendering:match ('alt=&quot;[^&quot;]+&quot;') then										-- if PNG math option
		rendering = rendering:match ('alt=&quot;([^&quot;]+)&quot;');							-- extract just the math text
	elseif rendering:match ('$%s+.+%s+%$') then									-- if TeX math option; $ is legit character that is escapes as \$
		rendering = rendering:match ('$%s+(.+)%s+%$')							-- extract just the math text
	elseif rendering:match ('&lt;annotation[^&gt;]+&gt;.+&lt;/annotation&gt;') then			-- if MathML math option
		rendering = rendering:match ('&lt;annotation[^&gt;]+&gt;(.+)&lt;/annotation&gt;')		-- extract just the math text
	else
		return false, value;													-- had math stripmarker but not one of the three defined forms
	end
	
	return true, value:gsub (stripmarker, rendering, 1);
end


--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain HTML entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaces math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?

]]

local function coins_cleanup (value)
	local replaced = true;														-- default state to get the do loop running

	while replaced do															-- loop until all math stripmarkers replaced
		replaced, value = coins_replace_math_stripmarker (value);				-- replace math stripmarker with text representation of the equation
	end

	value = value:gsub (cfg.stripmarkers['math'], &quot;MATH RENDER ERROR&quot;);			-- one or more couldn't be replaced; insert vague error message
	
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;(s?)&lt;/span&gt;', &quot;'%1&quot;);	-- replace {{'}} or {{'s}} with simple apostrophe or apostrophe-s
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	if not mw.ustring.find (value, cfg.indic_script) then						-- don't remove zero-width joiner characters from indic script
		value = value:gsub ('&amp;zwj;', '');										-- remove &amp;zwj; entities
		value = mw.ustring.gsub (value, '[\226\128\141\226\128\139\194\173]', '');	-- remove zero-width joiner, zero-width space, soft hyphen
	end
	value = value:gsub ('[\009\010\013 ]+', ' ');								-- replace horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'biorxiv', 'citeseerx', 'medrxiv', 'ssrn', 'journal', 'news', 'magazine'}) or
		(in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if in_array (class, {'arxiv', 'biorxiv', 'citeseerx', 'medrxiv', 'ssrn'}) then	-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv, cite biorxiv, cite citeseerx, cite medrxiv, cite ssrn
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.quarter&quot;] = data.Quarter;							-- single digits 1-&gt;first quarter, etc.
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput['rft.artnum'] = data.ArticleNumber;						-- {{cite journal}} only
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
			OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;							-- conference paper as chapter in proceedings (book)
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	-- {'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
	-- NB. Not currently supported are &quot;info:ofi/fmt:kev:mtx:patent&quot;, &quot;info:ofi/fmt:kev:mtx:dc&quot;, &quot;info:ofi/fmt:kev:mtx:sch_svc&quot;, &quot;info:ofi/fmt:kev:mtx:ctx&quot;
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation

	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		if k == 'ISBN' then v = v:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; ); end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc. that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif 'url' == id then													-- for urls that are assembled in ~/Identifiers; |asin= and |ol=
			OCinSoutput[&quot;rft_id&quot;] = table.concat ({data.ID_list[k], &quot;#id-name=&quot;, cfg.id_handlers[k].label});
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil so urls created here
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v, cfg.id_handlers[k].suffix or '', &quot;#id-name=&quot;, cfg.id_handlers[k].label };	-- others; provide a URL and indicate identifier name as #fragment (human-readable, but transparent to browsers)
		end
	end

	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki stripmarkers, non-printing or invisible characters
		if k == 1 then															-- for the first author name only
			if is_set(last) and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
			-- TODO: At present we do not report &quot;et al.&quot;. Add anything special if this condition applies?
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };

	-- TODO: Add optional extra info:
	-- rfr_dat=#REVISION&lt;version&gt; (referrer private data)
	-- ctx_id=&lt;data.RawPage&gt;#&lt;ref&gt; (identifier for the context object)
	-- ctx_tim=&lt;ts&gt; (timestamp in format yyyy-mm-ddThh:mm:ssTZD or yyyy-mm-dd)
	-- ctx_enc=info:ofi/enc:UTF-8 (character encoding)
	
	OCinSoutput = setmetatable( OCinSoutput, nil );

	-- sort with version string always first, and combine.
	-- table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver ); -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	has_accept_as_written = utilities_page_ptr.has_accept_as_written;			-- import functions from selected Module:Citation/CS1/Utilities module
	is_set = utilities_page_ptr.is_set;
	in_array = utilities_page_ptr.in_array;
	remove_wiki_link = utilities_page_ptr.remove_wiki_link;
	strip_apostrophe_markup = utilities_page_ptr.strip_apostrophe_markup;
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>2eba9cn0u4yseyeujt1vmrglxrgcllo</sha1>
    </revision>
    <revision>
      <id>4999</id>
      <parentid>4998</parentid>
      <timestamp>2025-08-07T07:39:35Z</timestamp>
      <contributor>
        <username>Martin Urbanec</username>
        <id>803</id>
      </contributor>
      <minor />
      <comment>37 revisions imported from [[:en:Module:Citation/CS1/COinS]]: updating from enwiki</comment>
      <origin>4998</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="16743" sha1="2eba9cn0u4yseyeujt1vmrglxrgcllo" xml:space="preserve">--[[--------------------------&lt; F O R W A R D   D E C L A R A T I O N S &gt;--------------------------------------
]]

local has_accept_as_written, is_set, in_array, remove_wiki_link, strip_apostrophe_markup;	-- functions in Module:Citation/CS1/Utilities

local cfg;																		-- table of configuration tables that are defined in Module:Citation/CS1/Configuration


--[[--------------------------&lt; M A K E _ C O I N S _ T I T L E &gt;----------------------------------------------

Makes a title for COinS from Title and / or ScriptTitle (or any other name-script pairs)

Apostrophe markup (bold, italics) is stripped from each value so that the COinS metadata isn't corrupted with strings
of %27%27...

]]

local function make_coins_title (title, script)
	title = has_accept_as_written (title);
	if is_set (title) then
		title = strip_apostrophe_markup (title);								-- strip any apostrophe markup
	else
		title = '';																-- if not set, make sure title is an empty string
	end
	if is_set (script) then
		script = script:gsub ('^%l%l%s*:%s*', '');								-- remove language prefix if present (script value may now be empty string)
		script = strip_apostrophe_markup (script);								-- strip any apostrophe markup
	else
		script = '';															-- if not set, make sure script is an empty string
	end
	if is_set (title) and is_set (script) then
		script = ' ' .. script;													-- add a space before we concatenate
	end
	return title .. script;														-- return the concatenation
end


--[[--------------------------&lt; E S C A P E _ L U A _ M A G I C _ C H A R S &gt;----------------------------------

Returns a string where all of Lua's magic characters have been escaped.  This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]

local function escape_lua_magic_chars (argument)
	argument = argument:gsub(&quot;%%&quot;, &quot;%%%%&quot;);										-- replace % with %%
	argument = argument:gsub(&quot;([%^%$%(%)%.%[%]%*%+%-%?])&quot;, &quot;%%%1&quot;);				-- replace all other Lua magic pattern characters
	return argument;
end


--[[--------------------------&lt; G E T _ C O I N S _ P A G E S &gt;------------------------------------------------

Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.

]]

local function get_coins_pages (pages)
	local pattern;
	if not is_set (pages) then return pages; end								-- if no page numbers then we're done
	
	while true do
		pattern = pages:match(&quot;%[(%w*:?//[^ ]+%s+)[%w%d].*%]&quot;);					-- pattern is the opening bracket, the URL and following space(s): &quot;[url &quot;
		if nil == pattern then break; end										-- no more URLs
		pattern = escape_lua_magic_chars (pattern);								-- pattern is not a literal string; escape Lua's magic pattern characters
		pages = pages:gsub(pattern, &quot;&quot;);										-- remove as many instances of pattern as possible
	end
	
	pages = pages:gsub(&quot;[%[%]]&quot;, &quot;&quot;);											-- remove the brackets
	pages = pages:gsub(&quot;–&quot;, &quot;-&quot; );												-- replace endashes with hyphens
	pages = pages:gsub(&quot;&amp;%w+;&quot;, &quot;-&quot; );											-- and replace HTML entities (&amp;ndash; etc.) with hyphens; do we need to replace numerical entities like &amp;#32; and the like?
	pages = pages:gsub ('%b&lt;&gt;', '');											-- remove html-like tags; spans are added to &lt;Pages&gt; by utilities.hyphen_to_dash() which should not appear in COinS metadata
	return pages;
end


--[=[-------------------------&lt; C O I N S _ R E P L A C E _ M A T H _ S T R I P M A R K E R &gt;------------------

There are three options for math markup rendering that depend on the editor's math preference settings.  These
settings are at [[Special:Preferences#mw-prefsection-rendering]] and are
	PNG images
	TeX source
	MathML with SVG or PNG fallback

All three are heavy with HTML and CSS which doesn't belong in the metadata.

Without this function, the metadata saved in the raw wikitext contained the rendering determined by the settings
of the last editor to save the page.

This function gets the rendered form of an equation according to the editor's preference before the page is saved.  It
then searches the rendering for the text equivalent of the rendered equation and replaces the rendering with that so
that the page is saved without extraneous HTML/CSS markup and with a reasonably readable text form of the equation.

When a replacement is made, this function returns true and the value with replacement; otherwise false and the initial
value.  To replace multipe equations it is necessary to call this function from within a loop.

]=]

local function coins_replace_math_stripmarker (value)
	local stripmarker = cfg.stripmarkers['math'];
	local rendering = value:match (stripmarker);								-- is there a math stripmarker

	if not rendering then														-- when value doesn't have a math stripmarker, abandon this test
		return false, value;
	end
	
	rendering = mw.text.unstripNoWiki (rendering);								-- convert stripmarker into rendered value (or nil? ''? when math render error)
	
	if rendering:match ('alt=&quot;[^&quot;]+&quot;') then										-- if PNG math option
		rendering = rendering:match ('alt=&quot;([^&quot;]+)&quot;');							-- extract just the math text
	elseif rendering:match ('$%s+.+%s+%$') then									-- if TeX math option; $ is legit character that is escapes as \$
		rendering = rendering:match ('$%s+(.+)%s+%$')							-- extract just the math text
	elseif rendering:match ('&lt;annotation[^&gt;]+&gt;.+&lt;/annotation&gt;') then			-- if MathML math option
		rendering = rendering:match ('&lt;annotation[^&gt;]+&gt;(.+)&lt;/annotation&gt;')		-- extract just the math text
	else
		return false, value;													-- had math stripmarker but not one of the three defined forms
	end
	
	return true, value:gsub (stripmarker, rendering, 1);
end


--[[--------------------------&lt; C O I N S _ C L E A N U P &gt;----------------------------------------------------

Cleanup parameter values for the metadata by removing or replacing invisible characters and certain HTML entities.

2015-12-10: there is a bug in mw.text.unstripNoWiki ().  It replaces math stripmarkers with the appropriate content
when it shouldn't.  See https://phabricator.wikimedia.org/T121085 and Wikipedia_talk:Lua#stripmarkers_and_mw.text.unstripNoWiki.28.29

TODO: move the replacement patterns and replacement values into a table in /Configuration similar to the invisible
characters table?

]]

local function coins_cleanup (value)
	local replaced = true;														-- default state to get the do loop running

	while replaced do															-- loop until all math stripmarkers replaced
		replaced, value = coins_replace_math_stripmarker (value);				-- replace math stripmarker with text representation of the equation
	end

	value = value:gsub (cfg.stripmarkers['math'], &quot;MATH RENDER ERROR&quot;);			-- one or more couldn't be replaced; insert vague error message
	
	value = mw.text.unstripNoWiki (value);										-- replace nowiki stripmarkers with their content
	value = value:gsub ('&lt;span class=&quot;nowrap&quot; style=&quot;padding%-left:0%.1em;&quot;&gt;&amp;#39;(s?)&lt;/span&gt;', &quot;'%1&quot;);	-- replace {{'}} or {{'s}} with simple apostrophe or apostrophe-s
	value = value:gsub ('&amp;nbsp;', ' ');											-- replace &amp;nbsp; entity with plain space
	value = value:gsub ('\226\128\138', ' ');									-- replace hair space with plain space
	if not mw.ustring.find (value, cfg.indic_script) then						-- don't remove zero-width joiner characters from indic script
		value = value:gsub ('&amp;zwj;', '');										-- remove &amp;zwj; entities
		value = mw.ustring.gsub (value, '[\226\128\141\226\128\139\194\173]', '');	-- remove zero-width joiner, zero-width space, soft hyphen
	end
	value = value:gsub ('[\009\010\013 ]+', ' ');								-- replace horizontal tab, line feed, carriage return with plain space
	return value;
end


--[[--------------------------&lt; C O I N S &gt;--------------------------------------------------------------------

COinS metadata (see &lt;http://ocoins.info/&gt;) allows automated tools to parse the citation information.

]]

local function COinS(data, class)
	if 'table' ~= type(data) or nil == next(data) then
		return '';
	end

	for k, v in pairs (data) do													-- spin through all of the metadata parameter values
		if 'ID_list' ~= k and 'Authors' ~= k then								-- except the ID_list and Author tables (author nowiki stripmarker done when Author table processed)
			data[k] = coins_cleanup (v);
		end
	end

	local ctx_ver = &quot;Z39.88-2004&quot;;
	
	-- treat table strictly as an array with only set values.
	local OCinSoutput = setmetatable( {}, {
		__newindex = function(self, key, value)
			if is_set(value) then
				rawset( self, #self+1, table.concat{ key, '=', mw.uri.encode( remove_wiki_link( value ) ) } );
			end
		end
	});
	
	if in_array (class, {'arxiv', 'biorxiv', 'citeseerx', 'medrxiv', 'ssrn', 'journal', 'news', 'magazine'}) or
		(in_array (class, {'conference', 'interview', 'map', 'press release', 'web'}) and is_set(data.Periodical)) or
		('citation' == class and is_set(data.Periodical) and not is_set (data.Encyclopedia)) then
			OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:journal&quot;;			-- journal metadata identifier
			if in_array (class, {'arxiv', 'biorxiv', 'citeseerx', 'medrxiv', 'ssrn'}) then	-- set genre according to the type of citation template we are rendering
				OCinSoutput[&quot;rft.genre&quot;] = &quot;preprint&quot;;							-- cite arxiv, cite biorxiv, cite citeseerx, cite medrxiv, cite ssrn
			elseif 'conference' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;						-- cite conference (when Periodical set)
			elseif 'web' == class then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;							-- cite web (when Periodical set)
			else
				OCinSoutput[&quot;rft.genre&quot;] = &quot;article&quot;;							-- journal and other 'periodical' articles
			end
			OCinSoutput[&quot;rft.jtitle&quot;] = data.Periodical;						-- journal only
			OCinSoutput[&quot;rft.atitle&quot;] = data.Title;								-- 'periodical' article titles

																				-- these used only for periodicals
			OCinSoutput[&quot;rft.ssn&quot;] = data.Season;								-- keywords: winter, spring, summer, fall
			OCinSoutput[&quot;rft.quarter&quot;] = data.Quarter;							-- single digits 1-&gt;first quarter, etc.
			OCinSoutput[&quot;rft.chron&quot;] = data.Chron;								-- free-form date components
			OCinSoutput[&quot;rft.volume&quot;] = data.Volume;							-- does not apply to books
			OCinSoutput[&quot;rft.issue&quot;] = data.Issue;
			OCinSoutput['rft.artnum'] = data.ArticleNumber;						-- {{cite journal}} only
			OCinSoutput[&quot;rft.pages&quot;] = data.Pages;								-- also used in book metadata

	elseif 'thesis' ~= class then												-- all others except cite thesis are treated as 'book' metadata; genre distinguishes
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:book&quot;;					-- book metadata identifier
		if 'report' == class or 'techreport' == class then						-- cite report and cite techreport
			OCinSoutput[&quot;rft.genre&quot;] = &quot;report&quot;;
		elseif 'conference' == class then										-- cite conference when Periodical not set
			OCinSoutput[&quot;rft.genre&quot;] = &quot;conference&quot;;
			OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;							-- conference paper as chapter in proceedings (book)
		elseif in_array (class, {'book', 'citation', 'encyclopaedia', 'interview', 'map'}) then
			if is_set (data.Chapter) then
				OCinSoutput[&quot;rft.genre&quot;] = &quot;bookitem&quot;;
				OCinSoutput[&quot;rft.atitle&quot;] = data.Chapter;						-- book chapter, encyclopedia article, interview in a book, or map title
			else
				if 'map' == class or 'interview' == class then
					OCinSoutput[&quot;rft.genre&quot;] = 'unknown';						-- standalone map or interview
				else
					OCinSoutput[&quot;rft.genre&quot;] = 'book';							-- book and encyclopedia
				end
			end
		else	-- {'audio-visual', 'AV-media-notes', 'DVD-notes', 'episode', 'interview', 'mailinglist', 'map', 'newsgroup', 'podcast', 'press release', 'serial', 'sign', 'speech', 'web'}
			OCinSoutput[&quot;rft.genre&quot;] = &quot;unknown&quot;;
		end
		OCinSoutput[&quot;rft.btitle&quot;] = data.Title;									-- book only
		OCinSoutput[&quot;rft.place&quot;] = data.PublicationPlace;						-- book only
		OCinSoutput[&quot;rft.series&quot;] = data.Series;								-- book only
		OCinSoutput[&quot;rft.pages&quot;] = data.Pages;									-- book, journal
		OCinSoutput[&quot;rft.edition&quot;] = data.Edition;								-- book only
		OCinSoutput[&quot;rft.pub&quot;] = data.PublisherName;							-- book and dissertation
		
	else																		-- cite thesis
		OCinSoutput.rft_val_fmt = &quot;info:ofi/fmt:kev:mtx:dissertation&quot;;			-- dissertation metadata identifier
		OCinSoutput[&quot;rft.title&quot;] = data.Title;									-- dissertation (also patent but that is not yet supported)
		OCinSoutput[&quot;rft.degree&quot;] = data.Degree;								-- dissertation only
		OCinSoutput['rft.inst'] = data.PublisherName;							-- book and dissertation
	end
	-- NB. Not currently supported are &quot;info:ofi/fmt:kev:mtx:patent&quot;, &quot;info:ofi/fmt:kev:mtx:dc&quot;, &quot;info:ofi/fmt:kev:mtx:sch_svc&quot;, &quot;info:ofi/fmt:kev:mtx:ctx&quot;
																				-- and now common parameters (as much as possible)
	OCinSoutput[&quot;rft.date&quot;] = data.Date;										-- book, journal, dissertation

	for k, v in pairs( data.ID_list ) do										-- what to do about these? For now assume that they are common to all?
		if k == 'ISBN' then v = v:gsub( &quot;[^-0-9X]&quot;, &quot;&quot; ); end
		local id = cfg.id_handlers[k].COinS;
		if string.sub( id or &quot;&quot;, 1, 4 ) == 'info' then							-- for ids that are in the info:registry
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ id, &quot;/&quot;, v };
		elseif string.sub (id or &quot;&quot;, 1, 3 ) == 'rft' then						-- for isbn, issn, eissn, etc. that have defined COinS keywords
			OCinSoutput[ id ] = v;
		elseif 'url' == id then													-- for urls that are assembled in ~/Identifiers; |asin= and |ol=
			OCinSoutput[&quot;rft_id&quot;] = table.concat ({data.ID_list[k], &quot;#id-name=&quot;, cfg.id_handlers[k].label});
		elseif id then															-- when cfg.id_handlers[k].COinS is not nil so urls created here
			OCinSoutput[&quot;rft_id&quot;] = table.concat{ cfg.id_handlers[k].prefix, v, cfg.id_handlers[k].suffix or '', &quot;#id-name=&quot;, cfg.id_handlers[k].label };	-- others; provide a URL and indicate identifier name as #fragment (human-readable, but transparent to browsers)
		end
	end

	local last, first;
	for k, v in ipairs( data.Authors ) do
		last, first = coins_cleanup (v.last), coins_cleanup (v.first or '');	-- replace any nowiki stripmarkers, non-printing or invisible characters
		if k == 1 then															-- for the first author name only
			if is_set(last) and is_set(first) then								-- set these COinS values if |first= and |last= specify the first author name
				OCinSoutput[&quot;rft.aulast&quot;] = last;								-- book, journal, dissertation
				OCinSoutput[&quot;rft.aufirst&quot;] = first;								-- book, journal, dissertation
			elseif is_set(last) then 
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation -- otherwise use this form for the first name
			end
		else																	-- for all other authors
			if is_set(last) and is_set(first) then
				OCinSoutput[&quot;rft.au&quot;] = table.concat{ last, &quot;, &quot;, first };		-- book, journal, dissertation
			elseif is_set(last) then
				OCinSoutput[&quot;rft.au&quot;] = last;									-- book, journal, dissertation
			end
			-- TODO: At present we do not report &quot;et al.&quot;. Add anything special if this condition applies?
		end
	end

	OCinSoutput.rft_id = data.URL;
	OCinSoutput.rfr_id = table.concat{ &quot;info:sid/&quot;, mw.site.server:match( &quot;[^/]*$&quot; ), &quot;:&quot;, data.RawPage };

	-- TODO: Add optional extra info:
	-- rfr_dat=#REVISION&lt;version&gt; (referrer private data)
	-- ctx_id=&lt;data.RawPage&gt;#&lt;ref&gt; (identifier for the context object)
	-- ctx_tim=&lt;ts&gt; (timestamp in format yyyy-mm-ddThh:mm:ssTZD or yyyy-mm-dd)
	-- ctx_enc=info:ofi/enc:UTF-8 (character encoding)
	
	OCinSoutput = setmetatable( OCinSoutput, nil );

	-- sort with version string always first, and combine.
	-- table.sort( OCinSoutput );
	table.insert( OCinSoutput, 1, &quot;ctx_ver=&quot; .. ctx_ver ); -- such as &quot;Z39.88-2004&quot;
	return table.concat(OCinSoutput, &quot;&amp;&quot;);
end


--[[--------------------------&lt; S E T _ S E L E C T E D _ M O D U L E S &gt;--------------------------------------

Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.

]]

local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
	cfg = cfg_table_ptr;

	has_accept_as_written = utilities_page_ptr.has_accept_as_written;			-- import functions from selected Module:Citation/CS1/Utilities module
	is_set = utilities_page_ptr.is_set;
	in_array = utilities_page_ptr.in_array;
	remove_wiki_link = utilities_page_ptr.remove_wiki_link;
	strip_apostrophe_markup = utilities_page_ptr.strip_apostrophe_markup;
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	make_coins_title = make_coins_title,
	get_coins_pages = get_coins_pages,
	COinS = COinS,
	set_selected_modules = set_selected_modules,
	}</text>
      <sha1>2eba9cn0u4yseyeujt1vmrglxrgcllo</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Citation/CS1/styles.css</title>
    <ns>828</ns>
    <id>737</id>
    <revision>
      <id>5000</id>
      <timestamp>2018-07-19T14:59:46Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Trappist the monk created the page [[Module:Citation/CS1/style.css]] using a non-default content model &quot;Sanitized CSS&quot;: experimenting with template styles</comment>
      <origin>5000</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
    <revision>
      <id>5001</id>
      <parentid>5000</parentid>
      <timestamp>2018-07-19T15:01:28Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>copy/paste from [[Template:Catalog lookup link/style.css]] because mediawiki wouldn't let me move that page here;</comment>
      <origin>5001</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="456" sha1="o3be9fa23y4sb3lol3z5mdq0ym2gpa1" xml:space="preserve">.cs1_lock_green a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Lock-green.svg/9px-Lock-green.svg.png) no-repeat right;
	}

.cs1_lock_blue a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/b/b4/Lock-blue-alt-2.svg/9px-Lock-blue-alt-2.svg.png) no-repeat right;
	}

.cs1_lock_red a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/c/c8/Lock-red-alt.svg/9px-Lock-red-alt.svg.png) no-repeat right;
	}</text>
      <sha1>o3be9fa23y4sb3lol3z5mdq0ym2gpa1</sha1>
    </revision>
    <revision>
      <id>5002</id>
      <parentid>5001</parentid>
      <timestamp>2018-07-19T16:47:33Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>5002</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="561" sha1="k5tn6spez4i4u9nt1vecx3a81gkkqtv" xml:space="preserve">.cs1_lock_green a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Lock-green.svg/9px-Lock-green.svg.png) no-repeat;
	background-position: right .2em center;
	}

.cs1_lock_blue a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/b/b4/Lock-blue-alt-2.svg/9px-Lock-blue-alt-2.svg.png) no-repeat;
	background-position: right .2em center;
	}

.cs1_lock_red a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/c/c8/Lock-red-alt.svg/9px-Lock-red-alt.svg.png) no-repeat;
	background-position: right .2em center;
	}</text>
      <sha1>k5tn6spez4i4u9nt1vecx3a81gkkqtv</sha1>
    </revision>
    <revision>
      <id>5003</id>
      <parentid>5002</parentid>
      <timestamp>2018-07-19T21:17:46Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>5003</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="598" sha1="a4vk7si3siu8iw0d44ejmya767osdqn" xml:space="preserve">.cs1_lock_free a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Lock-green.svg/9px-Lock-green.svg.png) no-repeat;
	background-position: right .2em center;
	}

.cs1_lock_limited a,
.cs1_lock_registration a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/b/b4/Lock-blue-alt-2.svg/9px-Lock-blue-alt-2.svg.png) no-repeat;
	background-position: right .2em center;
	}

.cs1_lock_subscription a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/c/c8/Lock-red-alt.svg/9px-Lock-red-alt.svg.png) no-repeat;
	background-position: right .2em center;
	}</text>
      <sha1>a4vk7si3siu8iw0d44ejmya767osdqn</sha1>
    </revision>
    <revision>
      <id>5004</id>
      <parentid>5003</parentid>
      <timestamp>2018-07-19T22:13:59Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>5004</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="598" sha1="c14we5hldkbuuegnff5chnrct2kvdmm" xml:space="preserve">.cs1_lock_free a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Lock-green.svg/9px-Lock-green.svg.png) no-repeat;
	background-position: right .1em center;
	}

.cs1_lock_limited a,
.cs1_lock_registration a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/b/b4/Lock-blue-alt-2.svg/9px-Lock-blue-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
	}

.cs1_lock_subscription a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/c/c8/Lock-red-alt.svg/9px-Lock-red-alt.svg.png) no-repeat;
	background-position: right .1em center;
	}</text>
      <sha1>c14we5hldkbuuegnff5chnrct2kvdmm</sha1>
    </revision>
    <revision>
      <id>5005</id>
      <parentid>5004</parentid>
      <timestamp>2018-07-20T00:28:21Z</timestamp>
      <contributor>
        <username>Headbomb</username>
        <id>825</id>
      </contributor>
      <comment>grey-alt-2/red-alt-2 per RFC</comment>
      <origin>5005</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="602" sha1="oxwsk1fhx6il0j9vzo9f9sm1c5kug2w" xml:space="preserve">.cs1_lock_free a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Lock-green.svg/9px-Lock-green.svg.png) no-repeat;
	background-position: right .1em center;
	}

.cs1_lock_limited a,
.cs1_lock_registration a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/b/b4/Lock-grey-alt-2.svg/9px-Lock-grey-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
	}

.cs1_lock_subscription a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/c/c8/Lock-red-alt-2.svg/9px-Lock-red-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
	}</text>
      <sha1>oxwsk1fhx6il0j9vzo9f9sm1c5kug2w</sha1>
    </revision>
    <revision>
      <id>5006</id>
      <parentid>5005</parentid>
      <timestamp>2018-07-20T00:29:31Z</timestamp>
      <contributor>
        <username>Headbomb</username>
        <id>825</id>
      </contributor>
      <minor />
      <comment>gray</comment>
      <origin>5006</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="602" sha1="62hikcc3ctbxktjgeo6ujkzr6g3o9y3" xml:space="preserve">.cs1_lock_free a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Lock-green.svg/9px-Lock-green.svg.png) no-repeat;
	background-position: right .1em center;
	}

.cs1_lock_limited a,
.cs1_lock_registration a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/b/b4/Lock-gray-alt-2.svg/9px-Lock-gray-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
	}

.cs1_lock_subscription a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/c/c8/Lock-red-alt-2.svg/9px-Lock-red-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
	}</text>
      <sha1>62hikcc3ctbxktjgeo6ujkzr6g3o9y3</sha1>
    </revision>
    <revision>
      <id>5007</id>
      <parentid>5006</parentid>
      <timestamp>2018-07-20T00:30:44Z</timestamp>
      <contributor>
        <username>Headbomb</username>
        <id>825</id>
      </contributor>
      <comment>tweak</comment>
      <origin>5007</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="602" sha1="e7qzrerttnpke2icka2lgjsz7qgu55v" xml:space="preserve">.cs1_lock_free a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Lock-green.svg/9px-Lock-green.svg.png) no-repeat;
	background-position: right .1em center;
	}

.cs1_lock_limited a,
.cs1_lock_registration a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Lock-gray-alt-2.svg/9px-Lock-gray-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
	}

.cs1_lock_subscription a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Lock-red-alt-2.svg/9px-Lock-red-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
	}</text>
      <sha1>e7qzrerttnpke2icka2lgjsz7qgu55v</sha1>
    </revision>
    <revision>
      <id>5008</id>
      <parentid>5007</parentid>
      <timestamp>2018-07-21T14:09:23Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>+error message code style;</comment>
      <origin>5008</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="1018" sha1="q3rlx1m9key6mffb3vhv8bq56kxa52v" xml:space="preserve">.cs1_style_code {																/* preserve font but remove other &lt;code&gt; styling; used in error messages */
	color:inherit;
	border: inherit;															/* code editor doesn't like inherit with boder? https://www.w3.org/wiki/CSS/Properties/border suggest that inherit is ok */
	padding:inherit;
	}

/*----------------------------&lt; A C C E S S   I C O N   S T Y L E &gt;------------------------------------------*/

.cs1_lock_free a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Lock-green.svg/9px-Lock-green.svg.png) no-repeat;
	background-position: right .1em center;
	}

.cs1_lock_limited a,
.cs1_lock_registration a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Lock-gray-alt-2.svg/9px-Lock-gray-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
	}

.cs1_lock_subscription a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Lock-red-alt-2.svg/9px-Lock-red-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
	}</text>
      <sha1>q3rlx1m9key6mffb3vhv8bq56kxa52v</sha1>
    </revision>
    <revision>
      <id>5009</id>
      <parentid>5008</parentid>
      <timestamp>2018-07-21T14:58:01Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>5009</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="1041" sha1="ladtyny703wfxfzhtx1gau7ppj8mjw0" xml:space="preserve">.cs1_style_code {																/* preserve font but remove other &lt;code&gt; styling; used in error messages */
	color:inherit;
	background: inherit;
	border: inherit;															/* code editor doesn't like inherit with boder? https://www.w3.org/wiki/CSS/Properties/border suggest that inherit is ok */
	padding:inherit;
	}


/*----------------------------&lt; A C C E S S   I C O N   S T Y L E &gt;------------------------------------------*/

.cs1_lock_free a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Lock-green.svg/9px-Lock-green.svg.png) no-repeat;
	background-position: right .1em center;
	}

.cs1_lock_limited a,
.cs1_lock_registration a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Lock-gray-alt-2.svg/9px-Lock-gray-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
	}

.cs1_lock_subscription a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Lock-red-alt-2.svg/9px-Lock-red-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
	}</text>
      <sha1>ladtyny703wfxfzhtx1gau7ppj8mjw0</sha1>
    </revision>
    <revision>
      <id>5010</id>
      <parentid>5009</parentid>
      <timestamp>2018-07-21T15:38:03Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>overrides;</comment>
      <origin>5010</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="2106" sha1="3h7wrz4guut27hp9yf8gbq3k93yki7d" xml:space="preserve">/*----------------------------&lt; O V E R R I D E S &gt;------------------------------------------------------------

cs1|2 references are wrapped in &lt;cite&gt;...&lt;/cite&gt; tags.  Some wiki's have not chosen to override the generic user
agent italic styling as en.wiki has.  This (untested) styling should override the user agent default when cs1|2
templates are rendered.

Similarly, some languages use different quotation punctuation so that setting is also made available here.

*/

cite.citation {																	/* Reset italic styling set by user agent (only for cs1|2 templates; the reason for the .citation qualifier) */
	font-style: inherit;
	}

q	{																			/* Straight quote marks for &lt;q&gt; */
	quotes: '&quot;' '&quot;' &quot;'&quot; &quot;'&quot;;
	}


/*----------------------------&lt; C O M M O N   P R E S E N T A T I O N &gt;----------------------------------------

&lt;code&gt;...&lt;/code&gt; style override: mediawiki's css definition is specified here:
	https://git.wikimedia.org/blob/mediawiki%2Fcore.git/69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199

*/

.cs1_style_code {																/* preserve font but remove other &lt;code&gt; styling; used in error messages */
	color:inherit;
	background: inherit;
	border: inherit;															/* code editor doesn't like inherit with boder? https://www.w3.org/wiki/CSS/Properties/border suggest that inherit is ok */
	padding:inherit;
	}


/*----------------------------&lt; A C C E S S   I C O N   S T Y L E &gt;------------------------------------------*/

.cs1_lock_free a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Lock-green.svg/9px-Lock-green.svg.png) no-repeat;
	background-position: right .1em center;
	}

.cs1_lock_limited a,
.cs1_lock_registration a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Lock-gray-alt-2.svg/9px-Lock-gray-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
	}

.cs1_lock_subscription a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Lock-red-alt-2.svg/9px-Lock-red-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
	}</text>
      <sha1>3h7wrz4guut27hp9yf8gbq3k93yki7d</sha1>
    </revision>
    <revision>
      <id>5011</id>
      <parentid>5010</parentid>
      <timestamp>2018-07-21T15:38:28Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <origin>5011</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="2105" sha1="ag1znxd7oyb3rpyhkoc55hl4ly9xsvh" xml:space="preserve">/*----------------------------&lt; O V E R R I D E S &gt;------------------------------------------------------------

cs1|2 references are wrapped in &lt;cite&gt;...&lt;/cite&gt; tags.  Some wikis have not chosen to override the generic user
agent italic styling as en.wiki has.  This (untested) styling should override the user agent default when cs1|2
templates are rendered.

Similarly, some languages use different quotation punctuation so that setting is also made available here.

*/

cite.citation {																	/* Reset italic styling set by user agent (only for cs1|2 templates; the reason for the .citation qualifier) */
	font-style: inherit;
	}

q	{																			/* Straight quote marks for &lt;q&gt; */
	quotes: '&quot;' '&quot;' &quot;'&quot; &quot;'&quot;;
	}


/*----------------------------&lt; C O M M O N   P R E S E N T A T I O N &gt;----------------------------------------

&lt;code&gt;...&lt;/code&gt; style override: mediawiki's css definition is specified here:
	https://git.wikimedia.org/blob/mediawiki%2Fcore.git/69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199

*/

.cs1_style_code {																/* preserve font but remove other &lt;code&gt; styling; used in error messages */
	color:inherit;
	background: inherit;
	border: inherit;															/* code editor doesn't like inherit with boder? https://www.w3.org/wiki/CSS/Properties/border suggest that inherit is ok */
	padding:inherit;
	}


/*----------------------------&lt; A C C E S S   I C O N   S T Y L E &gt;------------------------------------------*/

.cs1_lock_free a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Lock-green.svg/9px-Lock-green.svg.png) no-repeat;
	background-position: right .1em center;
	}

.cs1_lock_limited a,
.cs1_lock_registration a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Lock-gray-alt-2.svg/9px-Lock-gray-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
	}

.cs1_lock_subscription a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Lock-red-alt-2.svg/9px-Lock-red-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
	}</text>
      <sha1>ag1znxd7oyb3rpyhkoc55hl4ly9xsvh</sha1>
    </revision>
    <revision>
      <id>5012</id>
      <parentid>5011</parentid>
      <timestamp>2018-08-03T12:00:00Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <minor />
      <comment>Trappist the monk moved page [[Module:Citation/CS1/style.css]] to [[Module:Citation/CS1/styles.css]] without leaving a redirect: per naming convention at [[WP:TemplateStyles]];</comment>
      <origin>5011</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="2105" sha1="ag1znxd7oyb3rpyhkoc55hl4ly9xsvh" xml:space="preserve">/*----------------------------&lt; O V E R R I D E S &gt;------------------------------------------------------------

cs1|2 references are wrapped in &lt;cite&gt;...&lt;/cite&gt; tags.  Some wikis have not chosen to override the generic user
agent italic styling as en.wiki has.  This (untested) styling should override the user agent default when cs1|2
templates are rendered.

Similarly, some languages use different quotation punctuation so that setting is also made available here.

*/

cite.citation {																	/* Reset italic styling set by user agent (only for cs1|2 templates; the reason for the .citation qualifier) */
	font-style: inherit;
	}

q	{																			/* Straight quote marks for &lt;q&gt; */
	quotes: '&quot;' '&quot;' &quot;'&quot; &quot;'&quot;;
	}


/*----------------------------&lt; C O M M O N   P R E S E N T A T I O N &gt;----------------------------------------

&lt;code&gt;...&lt;/code&gt; style override: mediawiki's css definition is specified here:
	https://git.wikimedia.org/blob/mediawiki%2Fcore.git/69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199

*/

.cs1_style_code {																/* preserve font but remove other &lt;code&gt; styling; used in error messages */
	color:inherit;
	background: inherit;
	border: inherit;															/* code editor doesn't like inherit with boder? https://www.w3.org/wiki/CSS/Properties/border suggest that inherit is ok */
	padding:inherit;
	}


/*----------------------------&lt; A C C E S S   I C O N   S T Y L E &gt;------------------------------------------*/

.cs1_lock_free a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Lock-green.svg/9px-Lock-green.svg.png) no-repeat;
	background-position: right .1em center;
	}

.cs1_lock_limited a,
.cs1_lock_registration a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Lock-gray-alt-2.svg/9px-Lock-gray-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
	}

.cs1_lock_subscription a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Lock-red-alt-2.svg/9px-Lock-red-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
	}</text>
      <sha1>ag1znxd7oyb3rpyhkoc55hl4ly9xsvh</sha1>
    </revision>
    <revision>
      <id>5013</id>
      <parentid>5012</parentid>
      <timestamp>2018-08-05T20:17:55Z</timestamp>
      <contributor>
        <username>Izno</username>
        <id>817</id>
      </contributor>
      <comment>add some</comment>
      <origin>5013</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="2975" sha1="kg721366gqi1jfz87sswfujljgtj2jm" xml:space="preserve">/*----------------------------&lt; O V E R R I D E S &gt;------------------------------------------------------------

cs1|2 references are wrapped in &lt;cite&gt;...&lt;/cite&gt; tags.  Some wikis have not chosen to override the generic user
agent italic styling as en.wiki has.  This (untested) styling should override the user agent default when cs1|2
templates are rendered.

Similarly, some languages use different quotation punctuation so that setting is also made available here.

*/

cite.citation {																	/* Reset italic styling set by user agent (only for cs1|2 templates; the reason for the .citation qualifier) */
	font-style: inherit;
	}

q	{																			/* Straight quote marks for &lt;q&gt; */
	quotes: '&quot;' '&quot;' &quot;'&quot; &quot;'&quot;;
	}


/*----------------------------&lt; C O M M O N   P R E S E N T A T I O N &gt;----------------------------------------

&lt;code&gt;...&lt;/code&gt; style override: mediawiki's css definition is specified here:
	https://git.wikimedia.org/blob/mediawiki%2Fcore.git/69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199

*/

.cs1_style_code {																/* preserve font but remove other &lt;code&gt; styling; used in error messages */
	color:inherit;
	background: inherit;
	border: inherit;															/* code editor doesn't like inherit with boder? https://www.w3.org/wiki/CSS/Properties/border suggest that inherit is ok */
	padding:inherit;
	}


/*----------------------------&lt; A C C E S S   I C O N   S T Y L E &gt;------------------------------------------*/

.cs1_lock_free a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Lock-green.svg/9px-Lock-green.svg.png) no-repeat;
	background-position: right .1em center;
	}

.cs1_lock_limited a,
.cs1_lock_registration a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Lock-gray-alt-2.svg/9px-Lock-gray-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
	}

.cs1_lock_subscription a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Lock-red-alt-2.svg/9px-Lock-red-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
	}

/*----------------------------&lt; C S 1/C O N F I G U R A T I O N &gt;------------------------------------------*/
.cs1_subscription,
.cs1_registration {
	color:#555;
}
.cs1_subscription span,
.cs1_registration span {
	border-bottom:1px dotted;
	cursor:help;
}
.cs1_hidden-error {
	display:none;
	font-size:100%; 
}
.cs1_visible-error {
	font-size:100%;
}
/* set small text size in one place
.95 * .9 (from references list) is ~0.85
which is the lower bound for size for accessibility
old styling for this was just .85
We could write the rule so that when this template is inside references
only then does it multiply by 0.95;
else multiply by 0.85 */
.cs1_subscription,
.cs1_registration,
.cs1_format {
	font-size:95%; 
}
.cs1_kern-left,
.cs1_kern-wl-left {
	padding-left:0.2em
}
.cs1_kern-right,
.cs1_kern-wl-right {
	padding-right:0.2em
}
.Z3988 span {
	display: none;
}</text>
      <sha1>kg721366gqi1jfz87sswfujljgtj2jm</sha1>
    </revision>
    <revision>
      <id>5014</id>
      <parentid>5013</parentid>
      <timestamp>2018-08-05T20:20:12Z</timestamp>
      <contributor>
        <username>Izno</username>
        <id>817</id>
      </contributor>
      <comment>shorten name</comment>
      <origin>5014</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="2973" sha1="lq7h5e0fngpw10w1oiyc6wfh2ectbq9" xml:space="preserve">/*----------------------------&lt; O V E R R I D E S &gt;------------------------------------------------------------

cs1|2 references are wrapped in &lt;cite&gt;...&lt;/cite&gt; tags.  Some wikis have not chosen to override the generic user
agent italic styling as en.wiki has.  This (untested) styling should override the user agent default when cs1|2
templates are rendered.

Similarly, some languages use different quotation punctuation so that setting is also made available here.

*/

cite.citation {																	/* Reset italic styling set by user agent (only for cs1|2 templates; the reason for the .citation qualifier) */
	font-style: inherit;
	}

q	{																			/* Straight quote marks for &lt;q&gt; */
	quotes: '&quot;' '&quot;' &quot;'&quot; &quot;'&quot;;
	}


/*----------------------------&lt; C O M M O N   P R E S E N T A T I O N &gt;----------------------------------------

&lt;code&gt;...&lt;/code&gt; style override: mediawiki's css definition is specified here:
	https://git.wikimedia.org/blob/mediawiki%2Fcore.git/69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199

*/

code.cs1_code {																/* preserve font but remove other &lt;code&gt; styling; used in error messages */
	color:inherit;
	background: inherit;
	border: inherit;															/* code editor doesn't like inherit with boder? https://www.w3.org/wiki/CSS/Properties/border suggest that inherit is ok */
	padding:inherit;
	}


/*----------------------------&lt; A C C E S S   I C O N   S T Y L E &gt;------------------------------------------*/

.cs1_lock_free a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Lock-green.svg/9px-Lock-green.svg.png) no-repeat;
	background-position: right .1em center;
	}

.cs1_lock_limited a,
.cs1_lock_registration a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Lock-gray-alt-2.svg/9px-Lock-gray-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
	}

.cs1_lock_subscription a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Lock-red-alt-2.svg/9px-Lock-red-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
	}

/*----------------------------&lt; C S 1/C O N F I G U R A T I O N &gt;------------------------------------------*/
.cs1_subscription,
.cs1_registration {
	color:#555;
}
.cs1_subscription span,
.cs1_registration span {
	border-bottom:1px dotted;
	cursor:help;
}
.cs1_hidden-error {
	display:none;
	font-size:100%; 
}
.cs1_visible-error {
	font-size:100%;
}
/* set small text size in one place
.95 * .9 (from references list) is ~0.85
which is the lower bound for size for accessibility
old styling for this was just .85
We could write the rule so that when this template is inside references
only then does it multiply by 0.95;
else multiply by 0.85 */
.cs1_subscription,
.cs1_registration,
.cs1_format {
	font-size:95%; 
}
.cs1_kern-left,
.cs1_kern-wl-left {
	padding-left:0.2em
}
.cs1_kern-right,
.cs1_kern-wl-right {
	padding-right:0.2em
}
.Z3988 span {
	display: none;
}</text>
      <sha1>lq7h5e0fngpw10w1oiyc6wfh2ectbq9</sha1>
    </revision>
    <revision>
      <id>5015</id>
      <parentid>5014</parentid>
      <timestamp>2018-08-13T12:54:37Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>templatestyles class names;</comment>
      <origin>5015</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="2994" sha1="azcy6lo7x7p7vkhry0nh0gnrrny8tzf" xml:space="preserve">/*----------------------------&lt; O V E R R I D E S &gt;------------------------------------------------------------

cs1|2 references are wrapped in &lt;cite&gt;...&lt;/cite&gt; tags.  Some wikis have not chosen to override the generic user
agent italic styling as en.wiki has.  This (untested) styling should override the user agent default when cs1|2
templates are rendered.

Similarly, some languages use different quotation punctuation so that setting is also made available here.

*/

cite.citation {																	/* Reset italic styling set by user agent (only for cs1|2 templates; the reason for the .citation qualifier) */
	font-style: inherit;
	}

q	{																			/* Straight quote marks for &lt;q&gt; */
	quotes: '&quot;' '&quot;' &quot;'&quot; &quot;'&quot;;
	}


/*----------------------------&lt; C O M M O N   P R E S E N T A T I O N &gt;----------------------------------------

&lt;code&gt;...&lt;/code&gt; style override: mediawiki's css definition is specified here:
	https://git.wikimedia.org/blob/mediawiki%2Fcore.git/69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199

*/

code.cs1-code {																	/* preserve font but remove other &lt;code&gt; styling; used in error messages */
	color:inherit;
	background: inherit;
	border: inherit;															/* code editor doesn't like inherit with boder? https://www.w3.org/wiki/CSS/Properties/border suggest that inherit is ok */
	padding:inherit;
	}


/*----------------------------&lt; A C C E S S   I C O N   S T Y L E &gt;------------------------------------------*/

.cs1-lock_free a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Lock-green.svg/9px-Lock-green.svg.png) no-repeat;
	background-position: right .1em center;
	}

.cs1-lock_limited a,
.cs1-lock_registration a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Lock-gray-alt-2.svg/9px-Lock-gray-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
	}

.cs1-lock_subscription a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Lock-red-alt-2.svg/9px-Lock-red-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
	}

/*----------------------------&lt; C S 1 / C O N F I G U R A T I O N &gt;------------------------------------------*/
.cs1-subscription,
.cs1-registration {
	color:#555;
	}

.cs1-subscription span,
.cs1-registration span {
	border-bottom:1px dotted;
	cursor:help;
	}

.cs1-hidden-error {
	display:none;
	font-size:100%; 
	}

.cs1-visible-error {
	font-size:100%;
	}

/* set small text size in one place .95 * .9 (from references list) is ~0.85 which is the lower bound for size for accessibility
old styling for this was just .85.  We could write the rule so that when this template is inside references only then does it
multiply by 0.95; else multiply by 0.85 */

.cs1-subscription,
.cs1-registration,
.cs1-format {
	font-size:95%; 
	}

.cs1-kern-left,
.cs1-kern-wl-left {
	padding-left:0.2em
	}

.cs1-kern-right,
.cs1-kern-wl-right {
	padding-right:0.2em
	}

.Z3988 span {
	display: none;
	}</text>
      <sha1>azcy6lo7x7p7vkhry0nh0gnrrny8tzf</sha1>
    </revision>
    <revision>
      <id>5016</id>
      <parentid>5015</parentid>
      <timestamp>2018-08-13T15:19:01Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>fix lock selectors;</comment>
      <origin>5016</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="2995" sha1="k7gmbeafll3bveka2fzg6qof3py6qrz" xml:space="preserve">/*----------------------------&lt; O V E R R I D E S &gt;------------------------------------------------------------

cs1|2 references are wrapped in &lt;cite&gt;...&lt;/cite&gt; tags.  Some wikis have not chosen to override the generic user
agent italic styling as en.wiki has.  This (untested) styling should override the user agent default when cs1|2
templates are rendered.

Similarly, some languages use different quotation punctuation so that setting is also made available here.

*/

cite.citation {																	/* Reset italic styling set by user agent (only for cs1|2 templates; the reason for the .citation qualifier) */
	font-style: inherit;
	}

q	{																			/* Straight quote marks for &lt;q&gt; */
	quotes: '&quot;' '&quot;' &quot;'&quot; &quot;'&quot;;
	}


/*----------------------------&lt; C O M M O N   P R E S E N T A T I O N &gt;----------------------------------------

&lt;code&gt;...&lt;/code&gt; style override: mediawiki's css definition is specified here:
	https://git.wikimedia.org/blob/mediawiki%2Fcore.git/69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199

*/

code.cs1-code {																	/* preserve font but remove other &lt;code&gt; styling; used in error messages */
	color:inherit;
	background: inherit;
	border: inherit;															/* code editor doesn't like inherit with boder? https://www.w3.org/wiki/CSS/Properties/border suggest that inherit is ok */
	padding:inherit;
	}


/*----------------------------&lt; A C C E S S   I C O N   S T Y L E &gt;------------------------------------------*/

.cs1-lock-free a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Lock-green.svg/9px-Lock-green.svg.png) no-repeat;
	background-position: right .1em center;
	}

.cs1-lock-limited a,
.cs1-lock-registration a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Lock-gray-alt-2.svg/9px-Lock-gray-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
	}

.cs1-lock-subscription a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Lock-red-alt-2.svg/9px-Lock-red-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
	}


/*----------------------------&lt; C S 1 / C O N F I G U R A T I O N &gt;------------------------------------------*/
.cs1-subscription,
.cs1-registration {
	color:#555;
	}

.cs1-subscription span,
.cs1-registration span {
	border-bottom:1px dotted;
	cursor:help;
	}

.cs1-hidden-error {
	display:none;
	font-size:100%; 
	}

.cs1-visible-error {
	font-size:100%;
	}

/* set small text size in one place .95 * .9 (from references list) is ~0.85 which is the lower bound for size for accessibility
old styling for this was just .85.  We could write the rule so that when this template is inside references only then does it
multiply by 0.95; else multiply by 0.85 */

.cs1-subscription,
.cs1-registration,
.cs1-format {
	font-size:95%; 
	}

.cs1-kern-left,
.cs1-kern-wl-left {
	padding-left:0.2em
	}

.cs1-kern-right,
.cs1-kern-wl-right {
	padding-right:0.2em
	}

.Z3988 span {
	display: none;
	}</text>
      <sha1>k7gmbeafll3bveka2fzg6qof3py6qrz</sha1>
    </revision>
    <revision>
      <id>5017</id>
      <parentid>5016</parentid>
      <timestamp>2018-08-13T23:27:57Z</timestamp>
      <contributor>
        <username>Izno</username>
        <id>817</id>
      </contributor>
      <comment>coding conventions</comment>
      <origin>5017</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="2981" sha1="3031jl8unc8q67vcvrt71isbdph24x4" xml:space="preserve">/*----------------------------&lt; O V E R R I D E S &gt;------------------------------------------------------------

cs1|2 references are wrapped in &lt;cite&gt;...&lt;/cite&gt; tags.  Some wikis have not chosen to override the generic user
agent italic styling as en.wiki has.  This (untested) styling should override the user agent default when cs1|2
templates are rendered.

Similarly, some languages use different quotation punctuation so that setting is also made available here.

*/

cite.citation {																	/* Reset italic styling set by user agent (only for cs1|2 templates; the reason for the .citation qualifier) */
	font-style: inherit;
}

q	{																			/* Straight quote marks for &lt;q&gt; */
	quotes: '&quot;' '&quot;' &quot;'&quot; &quot;'&quot;;
}


/*----------------------------&lt; C O M M O N   P R E S E N T A T I O N &gt;----------------------------------------

&lt;code&gt;...&lt;/code&gt; style override: mediawiki's css definition is specified here:
	https://git.wikimedia.org/blob/mediawiki%2Fcore.git/69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199

*/

code.cs1-code {																	/* preserve font but remove other &lt;code&gt; styling; used in error messages */
	color:inherit;
	background: inherit;
	border: inherit;															/* code editor doesn't like inherit with boder? https://www.w3.org/wiki/CSS/Properties/border suggest that inherit is ok */
	padding:inherit;
}


/*----------------------------&lt; A C C E S S   I C O N   S T Y L E &gt;------------------------------------------*/

.cs1-lock-free a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Lock-green.svg/9px-Lock-green.svg.png) no-repeat;
	background-position: right .1em center;
}

.cs1-lock-limited a,
.cs1-lock-registration a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Lock-gray-alt-2.svg/9px-Lock-gray-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
}

.cs1-lock-subscription a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Lock-red-alt-2.svg/9px-Lock-red-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
}


/*----------------------------&lt; C S 1 / C O N F I G U R A T I O N &gt;------------------------------------------*/
.cs1-subscription,
.cs1-registration {
	color:#555;
}

.cs1-subscription span,
.cs1-registration span {
	border-bottom:1px dotted;
	cursor:help;
}

.cs1-hidden-error {
	display:none;
	font-size:100%; 
}

.cs1-visible-error {
	font-size:100%;
}

/* set small text size in one place .95 * .9 (from references list) is ~0.85 which is the lower bound for size for accessibility
old styling for this was just .85.  We could write the rule so that when this template is inside references only then does it
multiply by 0.95; else multiply by 0.85 */

.cs1-subscription,
.cs1-registration,
.cs1-format {
	font-size:95%; 
}

.cs1-kern-left,
.cs1-kern-wl-left {
	padding-left:0.2em
}

.cs1-kern-right,
.cs1-kern-wl-right {
	padding-right:0.2em
}

.Z3988 span {
	display: none;
}</text>
      <sha1>3031jl8unc8q67vcvrt71isbdph24x4</sha1>
    </revision>
    <revision>
      <id>5018</id>
      <parentid>5017</parentid>
      <timestamp>2018-08-13T23:38:40Z</timestamp>
      <contributor>
        <username>Izno</username>
        <id>817</id>
      </contributor>
      <comment>make most text 80 characters or shorter (general best practice)</comment>
      <origin>5018</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="2856" sha1="99t5ae1vgu2p54pjup6jg6a6vaxyw6f" xml:space="preserve">/*----------------------------&lt; O V E R R I D E S &gt;------------------------------------------------------------

cs1|2 references are wrapped in &lt;cite&gt;...&lt;/cite&gt; tags.  Some wikis have not
chosen to override the generic user agent italic styling as en.wiki has.  This
(untested) styling should override the user agent default when cs1|2 templates
are rendered.

Similarly, some languages use different quotation punctuation so that setting
is also made available here.
*/

cite.citation {
	/* Reset italic styling set by user agent (only for cs1|2 templates; the
	reason for the .citation qualifier) */
	font-style: inherit;
}

q	{ /* Straight quote marks for &lt;q&gt; */
	quotes: '&quot;' '&quot;' &quot;'&quot; &quot;'&quot;;
}


/*-------====--&lt; C O M M O N   P R E S E N T A T I O N &gt;----------------------

&lt;code&gt;...&lt;/code&gt; style override: mediawiki's css definition is specified here:
	https://git.wikimedia.org/blob/mediawiki%2Fcore.git/69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199

*/

code.cs1-code {
	/* preserve font but remove other &lt;code&gt; styling; used in error messages */
	color:inherit;
	background: inherit;
	border: inherit;
	/* code editor doesn't like inherit with boder?
	https://www.w3.org/wiki/CSS/Properties/border suggest that inherit is ok */
	padding:inherit;
}


/*----------------------------&lt; A C C E S S   I C O N   S T Y L E &gt;------------------------------------------*/

.cs1-lock-free a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Lock-green.svg/9px-Lock-green.svg.png) no-repeat;
	background-position: right .1em center;
}

.cs1-lock-limited a,
.cs1-lock-registration a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Lock-gray-alt-2.svg/9px-Lock-gray-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
}

.cs1-lock-subscription a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Lock-red-alt-2.svg/9px-Lock-red-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
}


/*-------------------&lt; C S 1 / C O N F I G U R A T I O N &gt;-------------------*/
.cs1-subscription,
.cs1-registration {
	color:#555;
}

.cs1-subscription span,
.cs1-registration span {
	border-bottom:1px dotted;
	cursor:help;
}

.cs1-hidden-error {
	display:none;
	font-size:100%; 
}

.cs1-visible-error {
	font-size:100%;
}

/* set small text size in one place .95 * .9 (from references list) is ~0.85
which is the lower bound for size for accessibility old styling for this was
just .85.  We could write the rule so that when this template is inside
references only then does it multiply by 0.95; else multiply by 0.85 */

.cs1-subscription,
.cs1-registration,
.cs1-format {
	font-size:95%; 
}

.cs1-kern-left,
.cs1-kern-wl-left {
	padding-left:0.2em
}

.cs1-kern-right,
.cs1-kern-wl-right {
	padding-right:0.2em
}

.Z3988 span {
	display: none;
}</text>
      <sha1>99t5ae1vgu2p54pjup6jg6a6vaxyw6f</sha1>
    </revision>
    <revision>
      <id>5019</id>
      <parentid>5018</parentid>
      <timestamp>2018-08-13T23:45:17Z</timestamp>
      <contributor>
        <username>Izno</username>
        <id>817</id>
      </contributor>
      <comment>and that one for consistency</comment>
      <origin>5019</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="2825" sha1="tfq9wsivnuj6b083sw7g9fv8cy6wmk9" xml:space="preserve">/*----------------------------&lt; O V E R R I D E S &gt;------------------------------------------------------------

cs1|2 references are wrapped in &lt;cite&gt;...&lt;/cite&gt; tags.  Some wikis have not
chosen to override the generic user agent italic styling as en.wiki has.  This
(untested) styling should override the user agent default when cs1|2 templates
are rendered.

Similarly, some languages use different quotation punctuation so that setting
is also made available here.
*/

cite.citation {
	/* Reset italic styling set by user agent (only for cs1|2 templates; the
	reason for the .citation qualifier) */
	font-style: inherit;
}

q	{ /* Straight quote marks for &lt;q&gt; */
	quotes: '&quot;' '&quot;' &quot;'&quot; &quot;'&quot;;
}


/*-------====--&lt; C O M M O N   P R E S E N T A T I O N &gt;----------------------

&lt;code&gt;...&lt;/code&gt; style override: mediawiki's css definition is specified here:
	https://git.wikimedia.org/blob/mediawiki%2Fcore.git/69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199

*/

code.cs1-code {
	/* preserve font but remove other &lt;code&gt; styling; used in error messages */
	color:inherit;
	background: inherit;
	border: inherit;
	/* code editor doesn't like inherit with boder?
	https://www.w3.org/wiki/CSS/Properties/border suggest that inherit is ok */
	padding:inherit;
}


/*-----------------&lt; A C C E S S   I C O N   S T Y L E &gt;----------------------*/

.cs1-lock-free a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Lock-green.svg/9px-Lock-green.svg.png) no-repeat;
	background-position: right .1em center;
}

.cs1-lock-limited a,
.cs1-lock-registration a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Lock-gray-alt-2.svg/9px-Lock-gray-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
}

.cs1-lock-subscription a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Lock-red-alt-2.svg/9px-Lock-red-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
}


/*-------------------&lt; C S 1 / C O N F I G U R A T I O N &gt;-------------------*/
.cs1-subscription,
.cs1-registration {
	color:#555;
}

.cs1-subscription span,
.cs1-registration span {
	border-bottom:1px dotted;
	cursor:help;
}

.cs1-hidden-error {
	display:none;
	font-size:100%; 
}

.cs1-visible-error {
	font-size:100%;
}

/* set small text size in one place .95 * .9 (from references list) is ~0.85
which is the lower bound for size for accessibility old styling for this was
just .85.  We could write the rule so that when this template is inside
references only then does it multiply by 0.95; else multiply by 0.85 */

.cs1-subscription,
.cs1-registration,
.cs1-format {
	font-size:95%; 
}

.cs1-kern-left,
.cs1-kern-wl-left {
	padding-left:0.2em
}

.cs1-kern-right,
.cs1-kern-wl-right {
	padding-right:0.2em
}

.Z3988 span {
	display: none;
}</text>
      <sha1>tfq9wsivnuj6b083sw7g9fv8cy6wmk9</sha1>
    </revision>
    <revision>
      <id>5020</id>
      <parentid>5019</parentid>
      <timestamp>2018-08-13T23:45:42Z</timestamp>
      <contributor>
        <username>Izno</username>
        <id>817</id>
      </contributor>
      <comment>last one</comment>
      <origin>5020</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="2793" sha1="ovaxlam0xqczoxk1ssw7s8qhokzxt6t" xml:space="preserve">/*-------------------------&lt; O V E R R I D E S &gt;-------------------------------

cs1|2 references are wrapped in &lt;cite&gt;...&lt;/cite&gt; tags.  Some wikis have not
chosen to override the generic user agent italic styling as en.wiki has.  This
(untested) styling should override the user agent default when cs1|2 templates
are rendered.

Similarly, some languages use different quotation punctuation so that setting
is also made available here.
*/

cite.citation {
	/* Reset italic styling set by user agent (only for cs1|2 templates; the
	reason for the .citation qualifier) */
	font-style: inherit;
}

q	{ /* Straight quote marks for &lt;q&gt; */
	quotes: '&quot;' '&quot;' &quot;'&quot; &quot;'&quot;;
}


/*-------====--&lt; C O M M O N   P R E S E N T A T I O N &gt;----------------------

&lt;code&gt;...&lt;/code&gt; style override: mediawiki's css definition is specified here:
	https://git.wikimedia.org/blob/mediawiki%2Fcore.git/69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199

*/

code.cs1-code {
	/* preserve font but remove other &lt;code&gt; styling; used in error messages */
	color:inherit;
	background: inherit;
	border: inherit;
	/* code editor doesn't like inherit with boder?
	https://www.w3.org/wiki/CSS/Properties/border suggest that inherit is ok */
	padding:inherit;
}


/*-----------------&lt; A C C E S S   I C O N   S T Y L E &gt;----------------------*/

.cs1-lock-free a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Lock-green.svg/9px-Lock-green.svg.png) no-repeat;
	background-position: right .1em center;
}

.cs1-lock-limited a,
.cs1-lock-registration a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Lock-gray-alt-2.svg/9px-Lock-gray-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
}

.cs1-lock-subscription a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Lock-red-alt-2.svg/9px-Lock-red-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
}


/*-------------------&lt; C S 1 / C O N F I G U R A T I O N &gt;-------------------*/
.cs1-subscription,
.cs1-registration {
	color:#555;
}

.cs1-subscription span,
.cs1-registration span {
	border-bottom:1px dotted;
	cursor:help;
}

.cs1-hidden-error {
	display:none;
	font-size:100%; 
}

.cs1-visible-error {
	font-size:100%;
}

/* set small text size in one place .95 * .9 (from references list) is ~0.85
which is the lower bound for size for accessibility old styling for this was
just .85.  We could write the rule so that when this template is inside
references only then does it multiply by 0.95; else multiply by 0.85 */

.cs1-subscription,
.cs1-registration,
.cs1-format {
	font-size:95%; 
}

.cs1-kern-left,
.cs1-kern-wl-left {
	padding-left:0.2em
}

.cs1-kern-right,
.cs1-kern-wl-right {
	padding-right:0.2em
}

.Z3988 span {
	display: none;
}</text>
      <sha1>ovaxlam0xqczoxk1ssw7s8qhokzxt6t</sha1>
    </revision>
    <revision>
      <id>5021</id>
      <parentid>5020</parentid>
      <timestamp>2018-08-13T23:46:35Z</timestamp>
      <contributor>
        <username>Izno</username>
        <id>817</id>
      </contributor>
      <comment>boder is a border</comment>
      <origin>5021</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="2789" sha1="an3u318s40lsb0sdauus7bcxz685h35" xml:space="preserve">/*-------------------------&lt; O V E R R I D E S &gt;-------------------------------

cs1|2 references are wrapped in &lt;cite&gt;...&lt;/cite&gt; tags.  Some wikis have not
chosen to override the generic user agent italic styling as en.wiki has.  This
(untested) styling should override the user agent default when cs1|2 templates
are rendered.

Similarly, some languages use different quotation punctuation so that setting
is also made available here.
*/

cite.citation {
	/* Reset italic styling set by user agent (only for cs1|2 templates; the
	reason for the .citation qualifier) */
	font-style: inherit;
}

q	{ /* Straight quote marks for &lt;q&gt; */
	quotes: '&quot;' '&quot;' &quot;'&quot; &quot;'&quot;;
}


/*-------====--&lt; C O M M O N   P R E S E N T A T I O N &gt;----------------------

&lt;code&gt;...&lt;/code&gt; style override: mediawiki's css definition is specified here:
	https://git.wikimedia.org/blob/mediawiki%2Fcore.git/69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199

*/
code.cs1-code {
	/* preserve font but remove other &lt;code&gt; styling; used in error messages */
	color:inherit;
	background: inherit;
	border: inherit;
	/* code editor doesn't like inherit with border?
	https://www.w3.org/wiki/CSS/Properties/border suggest that inherit is ok */
	padding:inherit;
}

/*-----------------&lt; A C C E S S   I C O N   S T Y L E &gt;----------------------*/
.cs1-lock-free a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Lock-green.svg/9px-Lock-green.svg.png) no-repeat;
	background-position: right .1em center;
}

.cs1-lock-limited a,
.cs1-lock-registration a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Lock-gray-alt-2.svg/9px-Lock-gray-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
}

.cs1-lock-subscription a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Lock-red-alt-2.svg/9px-Lock-red-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
}

/*-------------------&lt; C S 1 / C O N F I G U R A T I O N &gt;-------------------*/
.cs1-subscription,
.cs1-registration {
	color:#555;
}

.cs1-subscription span,
.cs1-registration span {
	border-bottom:1px dotted;
	cursor:help;
}

.cs1-hidden-error {
	display:none;
	font-size:100%; 
}

.cs1-visible-error {
	font-size:100%;
}

/* set small text size in one place .95 * .9 (from references list) is ~0.85
which is the lower bound for size for accessibility old styling for this was
just .85.  We could write the rule so that when this template is inside
references only then does it multiply by 0.95; else multiply by 0.85 */
.cs1-subscription,
.cs1-registration,
.cs1-format {
	font-size:95%; 
}

.cs1-kern-left,
.cs1-kern-wl-left {
	padding-left:0.2em
}

.cs1-kern-right,
.cs1-kern-wl-right {
	padding-right:0.2em
}

.Z3988 span {
	display: none;
}</text>
      <sha1>an3u318s40lsb0sdauus7bcxz685h35</sha1>
    </revision>
    <revision>
      <id>5022</id>
      <parentid>5021</parentid>
      <timestamp>2018-08-13T23:51:22Z</timestamp>
      <contributor>
        <username>Izno</username>
        <id>817</id>
      </contributor>
      <comment>some more whitespace consistency</comment>
      <origin>5022</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="2819" sha1="80krt83gzmz4cr32g00ubo2p1q96p2y" xml:space="preserve">/*-------------------------&lt; O V E R R I D E S &gt;-------------------------------

cs1|2 references are wrapped in &lt;cite&gt;...&lt;/cite&gt; tags.  Some wikis have not
chosen to override the generic user agent italic styling as en.wiki has.  This
(untested) styling should override the user agent default when cs1|2 templates
are rendered.

Similarly, some languages use different quotation punctuation so that setting
is also made available here.
*/
cite.citation {
	/* Reset italic styling set by user agent (only for cs1|2 templates; the
	reason for the .citation qualifier) */
	font-style: inherit;
}

q	{ /* Straight quote marks for &lt;q&gt; */
	quotes: '&quot;' '&quot;' &quot;'&quot; &quot;'&quot;;
}

/*-------====--&lt; C O M M O N   P R E S E N T A T I O N &gt;----------------------

&lt;code&gt;...&lt;/code&gt; style override: mediawiki's css definition is specified here:
	https://git.wikimedia.org/blob/mediawiki%2Fcore.git/69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199
*/
code.cs1-code {
	/* preserve font but remove other &lt;code&gt; styling; used in error messages */
	color: inherit;
	background: inherit;
	border: inherit;	/* code editor doesn't like inherit with border?
						https://www.w3.org/wiki/CSS/Properties/border
						suggest that inherit is ok */
	padding: inherit;
}

/*-----------------&lt; A C C E S S   I C O N   S T Y L E &gt;----------------------*/
.cs1-lock-free a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Lock-green.svg/9px-Lock-green.svg.png) no-repeat;
	background-position: right .1em center;
}

.cs1-lock-limited a,
.cs1-lock-registration a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Lock-gray-alt-2.svg/9px-Lock-gray-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
}

.cs1-lock-subscription a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Lock-red-alt-2.svg/9px-Lock-red-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
}

/*-------------------&lt; C S 1 / C O N F I G U R A T I O N &gt;--------------------*/
.cs1-subscription,
.cs1-registration {
	color: #555;
}

.cs1-subscription span,
.cs1-registration span {
	border-bottom: 1px dotted;
	cursor: help;
}

.cs1-hidden-error {
	display: none;
	font-size: 100%; 
}

.cs1-visible-error {
	font-size: 100%;
}

/* set small text size in one place .95 * .9 (from references list) is ~0.85
which is the lower bound for size for accessibility. Old styling for this was
just .85.  We could write the rule so that when this template is inside
references/reflist only then does it multiply by 0.95; else multiply by 0.85 */
.cs1-subscription,
.cs1-registration,
.cs1-format {
	font-size: 95%; 
}

.cs1-kern-left,
.cs1-kern-wl-left {
	padding-left: 0.2em;
}

.cs1-kern-right,
.cs1-kern-wl-right {
	padding-right: 0.2em;
}

.Z3988 span {
	display: none;
}</text>
      <sha1>80krt83gzmz4cr32g00ubo2p1q96p2y</sha1>
    </revision>
    <revision>
      <id>5023</id>
      <parentid>5022</parentid>
      <timestamp>2018-08-16T16:34:48Z</timestamp>
      <contributor>
        <username>Izno</username>
        <id>817</id>
      </contributor>
      <comment>remove hack for tidy</comment>
      <origin>5023</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="2786" sha1="eidgt9sw8xepme0l65xeb0hl6ozv8nj" xml:space="preserve">/*-------------------------&lt; O V E R R I D E S &gt;-------------------------------

cs1|2 references are wrapped in &lt;cite&gt;...&lt;/cite&gt; tags.  Some wikis have not
chosen to override the generic user agent italic styling as en.wiki has.  This
(untested) styling should override the user agent default when cs1|2 templates
are rendered.

Similarly, some languages use different quotation punctuation so that setting
is also made available here.
*/
cite.citation {
	/* Reset italic styling set by user agent (only for cs1|2 templates; the
	reason for the .citation qualifier) */
	font-style: inherit;
}

q	{ /* Straight quote marks for &lt;q&gt; */
	quotes: '&quot;' '&quot;' &quot;'&quot; &quot;'&quot;;
}

/*-------====--&lt; C O M M O N   P R E S E N T A T I O N &gt;----------------------

&lt;code&gt;...&lt;/code&gt; style override: mediawiki's css definition is specified here:
	https://git.wikimedia.org/blob/mediawiki%2Fcore.git/69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199
*/
code.cs1-code {
	/* preserve font but remove other &lt;code&gt; styling; used in error messages */
	color: inherit;
	background: inherit;
	border: inherit;	/* code editor doesn't like inherit with border?
						https://www.w3.org/wiki/CSS/Properties/border
						suggest that inherit is ok */
	padding: inherit;
}

/*-----------------&lt; A C C E S S   I C O N   S T Y L E &gt;----------------------*/
.cs1-lock-free a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Lock-green.svg/9px-Lock-green.svg.png) no-repeat;
	background-position: right .1em center;
}

.cs1-lock-limited a,
.cs1-lock-registration a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Lock-gray-alt-2.svg/9px-Lock-gray-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
}

.cs1-lock-subscription a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Lock-red-alt-2.svg/9px-Lock-red-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
}

/*-------------------&lt; C S 1 / C O N F I G U R A T I O N &gt;--------------------*/
.cs1-subscription,
.cs1-registration {
	color: #555;
}

.cs1-subscription span,
.cs1-registration span {
	border-bottom: 1px dotted;
	cursor: help;
}

.cs1-hidden-error {
	display: none;
	font-size: 100%; 
}

.cs1-visible-error {
	font-size: 100%;
}

/* set small text size in one place .95 * .9 (from references list) is ~0.85
which is the lower bound for size for accessibility. Old styling for this was
just .85.  We could write the rule so that when this template is inside
references/reflist only then does it multiply by 0.95; else multiply by 0.85 */
.cs1-subscription,
.cs1-registration,
.cs1-format {
	font-size: 95%; 
}

.cs1-kern-left,
.cs1-kern-wl-left {
	padding-left: 0.2em;
}

.cs1-kern-right,
.cs1-kern-wl-right {
	padding-right: 0.2em;
}</text>
      <sha1>eidgt9sw8xepme0l65xeb0hl6ozv8nj</sha1>
    </revision>
    <revision>
      <id>5024</id>
      <parentid>5023</parentid>
      <timestamp>2018-08-17T02:12:01Z</timestamp>
      <contributor>
        <username>Izno</username>
        <id>817</id>
      </contributor>
      <comment>we like English in our notes, and English has punctuation</comment>
      <origin>5024</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="2798" sha1="429s1wpxjsgd5ujrcy0airojhem2rr4" xml:space="preserve">/*-------------------------&lt; O V E R R I D E S &gt;-------------------------------

cs1|2 references are wrapped in &lt;cite&gt;...&lt;/cite&gt; tags.  Some wikis have not
chosen to override the generic user agent italic styling as en.wiki has.  This
(untested) styling should override the user agent default when cs1|2 templates
are rendered.

Similarly, some languages use different quotation punctuation so that setting
is also made available here.
*/
cite.citation {
	/* Reset italic styling set by user agent (only for cs1|2 templates; the
	reason for the .citation qualifier) */
	font-style: inherit;
}

q	{ /* Straight quote marks for &lt;q&gt; */
	quotes: '&quot;' '&quot;' &quot;'&quot; &quot;'&quot;;
}

/*-------====--&lt; C O M M O N   P R E S E N T A T I O N &gt;----------------------

&lt;code&gt;...&lt;/code&gt; style override: mediawiki's css definition is specified here:
	https://git.wikimedia.org/blob/mediawiki%2Fcore.git/69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199
*/
code.cs1-code {
	/* preserve font but remove other &lt;code&gt; styling; used in error messages */
	color: inherit;
	background: inherit;
	border: inherit;	/* code editor doesn't like inherit with border?
						https://www.w3.org/wiki/CSS/Properties/border
						suggest that inherit is ok */
	padding: inherit;
}

/*-----------------&lt; A C C E S S   I C O N   S T Y L E &gt;----------------------*/
.cs1-lock-free a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Lock-green.svg/9px-Lock-green.svg.png) no-repeat;
	background-position: right .1em center;
}

.cs1-lock-limited a,
.cs1-lock-registration a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Lock-gray-alt-2.svg/9px-Lock-gray-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
}

.cs1-lock-subscription a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Lock-red-alt-2.svg/9px-Lock-red-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
}

/*-------------------&lt; C S 1 / C O N F I G U R A T I O N &gt;--------------------*/
.cs1-subscription,
.cs1-registration {
	color: #555;
}

.cs1-subscription span,
.cs1-registration span {
	border-bottom: 1px dotted;
	cursor: help;
}

.cs1-hidden-error {
	display: none;
	font-size: 100%; 
}

.cs1-visible-error {
	font-size: 100%;
}

/* Set small text size in one place. 0.95 (here) * 0.9 (from references list) is
~0.85, which is the lower bound for size for accessibility. Old styling for this
was just 0.85. We could write the rule so that when this template is inside
references/reflist, only then does it multiply by 0.95; else multiply by 0.85 */
.cs1-subscription,
.cs1-registration,
.cs1-format {
	font-size: 95%; 
}

.cs1-kern-left,
.cs1-kern-wl-left {
	padding-left: 0.2em;
}

.cs1-kern-right,
.cs1-kern-wl-right {
	padding-right: 0.2em;
}</text>
      <sha1>429s1wpxjsgd5ujrcy0airojhem2rr4</sha1>
    </revision>
    <revision>
      <id>5025</id>
      <parentid>5024</parentid>
      <timestamp>2018-08-17T02:12:25Z</timestamp>
      <contributor>
        <username>Izno</username>
        <id>817</id>
      </contributor>
      <comment>ditch a tab</comment>
      <origin>5025</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="2798" sha1="ezlge3dn4vk1ojodwlb6whzyh4ggoyw" xml:space="preserve">/*-------------------------&lt; O V E R R I D E S &gt;-------------------------------

cs1|2 references are wrapped in &lt;cite&gt;...&lt;/cite&gt; tags.  Some wikis have not
chosen to override the generic user agent italic styling as en.wiki has.  This
(untested) styling should override the user agent default when cs1|2 templates
are rendered.

Similarly, some languages use different quotation punctuation so that setting
is also made available here.
*/
cite.citation {
	/* Reset italic styling set by user agent (only for cs1|2 templates; the
	reason for the .citation qualifier) */
	font-style: inherit;
}

q { /* Straight quote marks for &lt;q&gt; */
	quotes: '&quot;' '&quot;' &quot;'&quot; &quot;'&quot;;
}

/*-------====--&lt; C O M M O N   P R E S E N T A T I O N &gt;----------------------

&lt;code&gt;...&lt;/code&gt; style override: mediawiki's css definition is specified here:
	https://git.wikimedia.org/blob/mediawiki%2Fcore.git/69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199
*/
code.cs1-code {
	/* preserve font but remove other &lt;code&gt; styling; used in error messages */
	color: inherit;
	background: inherit;
	border: inherit;	/* code editor doesn't like inherit with border?
						https://www.w3.org/wiki/CSS/Properties/border
						suggest that inherit is ok */
	padding: inherit;
}

/*-----------------&lt; A C C E S S   I C O N   S T Y L E &gt;----------------------*/
.cs1-lock-free a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Lock-green.svg/9px-Lock-green.svg.png) no-repeat;
	background-position: right .1em center;
}

.cs1-lock-limited a,
.cs1-lock-registration a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Lock-gray-alt-2.svg/9px-Lock-gray-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
}

.cs1-lock-subscription a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Lock-red-alt-2.svg/9px-Lock-red-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
}

/*-------------------&lt; C S 1 / C O N F I G U R A T I O N &gt;--------------------*/
.cs1-subscription,
.cs1-registration {
	color: #555;
}

.cs1-subscription span,
.cs1-registration span {
	border-bottom: 1px dotted;
	cursor: help;
}

.cs1-hidden-error {
	display: none;
	font-size: 100%; 
}

.cs1-visible-error {
	font-size: 100%;
}

/* Set small text size in one place. 0.95 (here) * 0.9 (from references list) is
~0.85, which is the lower bound for size for accessibility. Old styling for this
was just 0.85. We could write the rule so that when this template is inside
references/reflist, only then does it multiply by 0.95; else multiply by 0.85 */
.cs1-subscription,
.cs1-registration,
.cs1-format {
	font-size: 95%; 
}

.cs1-kern-left,
.cs1-kern-wl-left {
	padding-left: 0.2em;
}

.cs1-kern-right,
.cs1-kern-wl-right {
	padding-right: 0.2em;
}</text>
      <sha1>ezlge3dn4vk1ojodwlb6whzyh4ggoyw</sha1>
    </revision>
    <revision>
      <id>5026</id>
      <parentid>5025</parentid>
      <timestamp>2018-08-17T16:12:49Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <minor />
      <comment>Protected &quot;[[Module:Citation/CS1/styles.css]]&quot;: match protection level of root module; ([Edit=Require administrator access] (indefinite) [Move=Require administrator access] (indefinite))</comment>
      <origin>5025</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="2798" sha1="ezlge3dn4vk1ojodwlb6whzyh4ggoyw" xml:space="preserve">/*-------------------------&lt; O V E R R I D E S &gt;-------------------------------

cs1|2 references are wrapped in &lt;cite&gt;...&lt;/cite&gt; tags.  Some wikis have not
chosen to override the generic user agent italic styling as en.wiki has.  This
(untested) styling should override the user agent default when cs1|2 templates
are rendered.

Similarly, some languages use different quotation punctuation so that setting
is also made available here.
*/
cite.citation {
	/* Reset italic styling set by user agent (only for cs1|2 templates; the
	reason for the .citation qualifier) */
	font-style: inherit;
}

q { /* Straight quote marks for &lt;q&gt; */
	quotes: '&quot;' '&quot;' &quot;'&quot; &quot;'&quot;;
}

/*-------====--&lt; C O M M O N   P R E S E N T A T I O N &gt;----------------------

&lt;code&gt;...&lt;/code&gt; style override: mediawiki's css definition is specified here:
	https://git.wikimedia.org/blob/mediawiki%2Fcore.git/69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199
*/
code.cs1-code {
	/* preserve font but remove other &lt;code&gt; styling; used in error messages */
	color: inherit;
	background: inherit;
	border: inherit;	/* code editor doesn't like inherit with border?
						https://www.w3.org/wiki/CSS/Properties/border
						suggest that inherit is ok */
	padding: inherit;
}

/*-----------------&lt; A C C E S S   I C O N   S T Y L E &gt;----------------------*/
.cs1-lock-free a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Lock-green.svg/9px-Lock-green.svg.png) no-repeat;
	background-position: right .1em center;
}

.cs1-lock-limited a,
.cs1-lock-registration a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Lock-gray-alt-2.svg/9px-Lock-gray-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
}

.cs1-lock-subscription a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Lock-red-alt-2.svg/9px-Lock-red-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
}

/*-------------------&lt; C S 1 / C O N F I G U R A T I O N &gt;--------------------*/
.cs1-subscription,
.cs1-registration {
	color: #555;
}

.cs1-subscription span,
.cs1-registration span {
	border-bottom: 1px dotted;
	cursor: help;
}

.cs1-hidden-error {
	display: none;
	font-size: 100%; 
}

.cs1-visible-error {
	font-size: 100%;
}

/* Set small text size in one place. 0.95 (here) * 0.9 (from references list) is
~0.85, which is the lower bound for size for accessibility. Old styling for this
was just 0.85. We could write the rule so that when this template is inside
references/reflist, only then does it multiply by 0.95; else multiply by 0.85 */
.cs1-subscription,
.cs1-registration,
.cs1-format {
	font-size: 95%; 
}

.cs1-kern-left,
.cs1-kern-wl-left {
	padding-left: 0.2em;
}

.cs1-kern-right,
.cs1-kern-wl-right {
	padding-right: 0.2em;
}</text>
      <sha1>ezlge3dn4vk1ojodwlb6whzyh4ggoyw</sha1>
    </revision>
    <revision>
      <id>5027</id>
      <parentid>5026</parentid>
      <timestamp>2018-09-29T13:26:20Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>synch from sandbox;</comment>
      <origin>5027</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="2792" sha1="mj3y80gld3yka1q60v6qgjxvbitso6w" xml:space="preserve">/*-------------------------&lt; O V E R R I D E S &gt;-----------------------------

cs1|2 references are wrapped in &lt;cite&gt;...&lt;/cite&gt; tags.  Some wikis have not
chosen to override the generic user agent italic styling as en.wiki has.  This
(untested) styling should override the user agent default when cs1|2 templates
are rendered.

Similarly, some languages use different quotation punctuation so that setting
is also made available here.
*/
cite.citation {
	/* Reset italic styling set by user agent (only for cs1|2 templates; the
	reason for the .citation qualifier) */
	font-style: inherit;
}

q { /* Straight quote marks for &lt;q&gt; */
	quotes: '&quot;' '&quot;' &quot;'&quot; &quot;'&quot;;
}

/*------------&lt; C O M M O N   P R E S E N T A T I O N &gt;----------------------

&lt;code&gt;...&lt;/code&gt; style override: mediawiki's css definition is specified here:
	https://git.wikimedia.org/blob/mediawiki%2Fcore.git/69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199
*/
code.cs1-code {
	/* preserve font but remove other &lt;code&gt; styling; used in error messages */
	color: inherit;
	background: inherit;
	border: inherit;	/* code editor doesn't like inherit with border?
						https://www.w3.org/wiki/CSS/Properties/border
						suggests that inherit is ok */
	padding: inherit;
}

/*-----------------&lt; A C C E S S   I C O N   S T Y L E &gt;--------------------*/
.cs1-lock-free a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Lock-green.svg/9px-Lock-green.svg.png) no-repeat;
	background-position: right .1em center;
}

.cs1-lock-limited a,
.cs1-lock-registration a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Lock-gray-alt-2.svg/9px-Lock-gray-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
}

.cs1-lock-subscription a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Lock-red-alt-2.svg/9px-Lock-red-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
}

/*------------------&lt; C S 1 / C O N F I G U R A T I O N &gt;-------------------*/
.cs1-subscription,
.cs1-registration {
	color: #555;
}

.cs1-subscription span,
.cs1-registration span {
	border-bottom: 1px dotted;
	cursor: help;
}

.cs1-hidden-error {
	display: none;
	font-size: 100%; 
}

.cs1-visible-error {
	font-size: 100%;
}

/* Set small text size in one place. 0.95 (here) * 0.9 (from references list) is
~0.85, which is the lower bound for size for accessibility. Old styling for this
was just 0.85. We could write the rule so that when this template is inside
references/reflist, only then does it multiply by 0.95; else multiply by 0.85 */
.cs1-subscription,
.cs1-registration,
.cs1-format {
	font-size: 95%; 
}

.cs1-kern-left,
.cs1-kern-wl-left {
	padding-left: 0.2em;
}

.cs1-kern-right,
.cs1-kern-wl-right {
	padding-right: 0.2em;
}</text>
      <sha1>mj3y80gld3yka1q60v6qgjxvbitso6w</sha1>
    </revision>
    <revision>
      <id>5028</id>
      <parentid>5027</parentid>
      <timestamp>2019-01-19T10:58:25Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>synch from sandbox;</comment>
      <origin>5028</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="3472" sha1="04u3t93fbagwd42ay3tdzlwzvseugt8" xml:space="preserve">/*-------------------------&lt; O V E R R I D E S &gt;-----------------------------

cs1|2 references are wrapped in &lt;cite&gt;...&lt;/cite&gt; tags.  Some wikis have not
chosen to override the generic user agent italic styling as en.wiki has.  This
(untested) styling should override the user agent default when cs1|2 templates
are rendered.

Similarly, some languages use different quotation punctuation so that setting
is also made available here.
*/
cite.citation {
	/* Reset italic styling set by user agent (only for cs1|2 templates; the
	reason for the .citation qualifier) */
	font-style: inherit;
}

.citation q {
	/* Straight quote marks for &lt;q&gt;; keep same as [[MediaWiki:Common.css]] */
	quotes: '&quot;' '&quot;' &quot;'&quot; &quot;'&quot;;
}

/* ID and URL access
Both core and Common.css have selector .mw-parser-output a[href$=&quot;.pdf&quot;].external
for PDF pages. All TemplateStyles pages are hoisted to .mw-parser-output. We need
to have specificity equal to a[href$=&quot;.pdf&quot;].external for locks to override PDF icon.
*/
.citation .cs1-lock-free a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Lock-green.svg/9px-Lock-green.svg.png) no-repeat;
	background-position: right .1em center;
}

.citation .cs1-lock-limited a,
.citation .cs1-lock-registration a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Lock-gray-alt-2.svg/9px-Lock-gray-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
}

.citation .cs1-lock-subscription a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Lock-red-alt-2.svg/9px-Lock-red-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
}

.cs1-subscription,
.cs1-registration {
	color: #555;
}

.cs1-subscription span,
.cs1-registration span {
	border-bottom: 1px dotted;
	cursor: help;
}

/* Wikisource icon
Experiment to see if it is possible/practical to add support for a wikisource
icon when |chapter= or |title= is wikilinked to a source in wikisource ala cite wikisource
*/
.cs1-ws-icon a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/4/4c/Wikisource-logo.svg/12px-Wikisource-logo.svg.png) no-repeat;
	background-position: right .1em center;
}

/* Errors and maintenance */
code.cs1-code {
	/* &lt;code&gt;...&lt;/code&gt; style override: mediawiki's css definition is specified here:
	https://git.wikimedia.org/blob/mediawiki%2Fcore.git/69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199
	*/
	color: inherit;
	background: inherit;
	border: inherit;	/* code editor doesn't like inherit with border?
						https://www.w3.org/wiki/CSS/Properties/border
						suggests that inherit is ok
						the actual spec says the code editor is correct:
						https://www.w3.org/TR/css-backgrounds-3/#borders
						*/
	padding: inherit;
}

.cs1-hidden-error {
	display: none;
	font-size: 100%;
}

.cs1-visible-error {
	font-size: 100%;
}

.cs1-maint {
	display: none;
	color: #33aa33;
	margin-left: 0.3em;
}

/* Small text size
Set small text size in one place. 0.95 (here) * 0.9 (from references list) is
~0.85, which is the lower bound for size for accessibility. Old styling for this
was just 0.85. We could write the rule so that when this template is inside
references/reflist, only then does it multiply by 0.95; else multiply by 0.85 */
.cs1-subscription,
.cs1-registration,
.cs1-format {
	font-size: 95%;
}

/* kerning */
.cs1-kern-left,
.cs1-kern-wl-left {
	padding-left: 0.2em;
}

.cs1-kern-right,
.cs1-kern-wl-right {
	padding-right: 0.2em;
}</text>
      <sha1>04u3t93fbagwd42ay3tdzlwzvseugt8</sha1>
    </revision>
    <revision>
      <id>5029</id>
      <parentid>5028</parentid>
      <timestamp>2019-03-04T01:04:42Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>per [[Help talk:Citation Style 1#Protected edit request on 4 March_2019|edit request]];</comment>
      <origin>5029</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="3713" sha1="7fv38nbtpuch4lec0zbgz4par9lwh5e" xml:space="preserve">/*-------------------------&lt; P R O T E C T I O N   I C O N &gt;--------------------

the following line controls the page-protection icon in the upper right corner
it must remain within this comment
	{{sandbox other||{{pp-template}}}}

*/


/*-------------------------&lt; O V E R R I D E S &gt;--------------------------------

cs1|2 references are wrapped in &lt;cite&gt;...&lt;/cite&gt; tags.  Some wikis have not
chosen to override the generic user agent italic styling as en.wiki has.  This
(untested) styling should override the user agent default when cs1|2 templates
are rendered.

Similarly, some languages use different quotation punctuation so that setting
is also made available here.
*/
cite.citation {
	/* Reset italic styling set by user agent (only for cs1|2 templates; the
	reason for the .citation qualifier) */
	font-style: inherit;
}

.citation q {
	/* Straight quote marks for &lt;q&gt;; keep same as [[MediaWiki:Common.css]] */
	quotes: '&quot;' '&quot;' &quot;'&quot; &quot;'&quot;;
}

/* ID and URL access
Both core and Common.css have selector .mw-parser-output a[href$=&quot;.pdf&quot;].external
for PDF pages. All TemplateStyles pages are hoisted to .mw-parser-output. We need
to have specificity equal to a[href$=&quot;.pdf&quot;].external for locks to override PDF icon.
*/
.citation .cs1-lock-free a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Lock-green.svg/9px-Lock-green.svg.png) no-repeat;
	background-position: right .1em center;
}

.citation .cs1-lock-limited a,
.citation .cs1-lock-registration a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Lock-gray-alt-2.svg/9px-Lock-gray-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
}

.citation .cs1-lock-subscription a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Lock-red-alt-2.svg/9px-Lock-red-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
}

.cs1-subscription,
.cs1-registration {
	color: #555;
}

.cs1-subscription span,
.cs1-registration span {
	border-bottom: 1px dotted;
	cursor: help;
}

/* Wikisource icon
Experiment to see if it is possible/practical to add support for a wikisource
icon when |chapter= or |title= is wikilinked to a source in wikisource ala cite wikisource
*/
.cs1-ws-icon a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/4/4c/Wikisource-logo.svg/12px-Wikisource-logo.svg.png) no-repeat;
	background-position: right .1em center;
}

/* Errors and maintenance */
code.cs1-code {
	/* &lt;code&gt;...&lt;/code&gt; style override: mediawiki's css definition is specified here:
	https://git.wikimedia.org/blob/mediawiki%2Fcore.git/69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199
	*/
	color: inherit;
	background: inherit;
	border: inherit;	/* code editor doesn't like inherit with border?
						https://www.w3.org/wiki/CSS/Properties/border
						suggests that inherit is ok
						the actual spec says the code editor is correct:
						https://www.w3.org/TR/css-backgrounds-3/#borders
						*/
	padding: inherit;
}

.cs1-hidden-error {
	display: none;
	font-size: 100%;
}

.cs1-visible-error {
	font-size: 100%;
}

.cs1-maint {
	display: none;
	color: #33aa33;
	margin-left: 0.3em;
}

/* Small text size
Set small text size in one place. 0.95 (here) * 0.9 (from references list) is
~0.85, which is the lower bound for size for accessibility. Old styling for this
was just 0.85. We could write the rule so that when this template is inside
references/reflist, only then does it multiply by 0.95; else multiply by 0.85 */
.cs1-subscription,
.cs1-registration,
.cs1-format {
	font-size: 95%;
}

/* kerning */
.cs1-kern-left,
.cs1-kern-wl-left {
	padding-left: 0.2em;
}

.cs1-kern-right,
.cs1-kern-wl-right {
	padding-right: 0.2em;
}</text>
      <sha1>7fv38nbtpuch4lec0zbgz4par9lwh5e</sha1>
    </revision>
    <revision>
      <id>5030</id>
      <parentid>5029</parentid>
      <timestamp>2020-01-11T12:32:42Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>5030</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="3896" sha1="4b0rbgfwypupw286w6ycml5ovdk6dkc" xml:space="preserve">/*-------------------------&lt; P R O T E C T I O N   I C O N &gt;--------------------

the following line controls the page-protection icon in the upper right corner
it must remain within this comment
	{{sandbox other||{{pp-template}}}}

*/


/*-------------------------&lt; O V E R R I D E S &gt;--------------------------------

cs1|2 references are wrapped in &lt;cite&gt;...&lt;/cite&gt; tags.  Some wikis have not
chosen to override the generic user agent italic styling as en.wiki has.  This
(untested) styling should override the user agent default when cs1|2 templates
are rendered.

Similarly, some languages use different quotation punctuation so that setting
is also made available here.
*/
cite.citation {
	/* Reset italic styling set by user agent (only for cs1|2 templates; the
	reason for the .citation qualifier) */
	font-style: inherit;
}

.citation q {
	/* Straight quote marks for &lt;q&gt;; keep same as [[MediaWiki:Common.css]] */
	quotes: '&quot;' '&quot;' &quot;'&quot; &quot;'&quot;;
}

/* ID and URL access
Both core and Common.css have selector .mw-parser-output a[href$=&quot;.pdf&quot;].external
for PDF pages. All TemplateStyles pages are hoisted to .mw-parser-output. We need
to have specificity equal to a[href$=&quot;.pdf&quot;].external for locks to override PDF icon.

the .id-lock-... selectors are for use by non-citation templates like {{Catalog lookup link}}
*/

.id-lock-free a,
.citation .cs1-lock-free a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Lock-green.svg/9px-Lock-green.svg.png) no-repeat;
	background-position: right .1em center;
}

.id-lock-limited a,
.id-lock-registration a,
.citation .cs1-lock-limited a,
.citation .cs1-lock-registration a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Lock-gray-alt-2.svg/9px-Lock-gray-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
}

.id-lock-subscription a,
.citation .cs1-lock-subscription a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Lock-red-alt-2.svg/9px-Lock-red-alt-2.svg.png) no-repeat;
	background-position: right .1em center;
}

.cs1-subscription,
.cs1-registration {
	color: #555;
}

.cs1-subscription span,
.cs1-registration span {
	border-bottom: 1px dotted;
	cursor: help;
}

/* Wikisource icon
Experiment to see if it is possible/practical to add support for a wikisource
icon when |chapter= or |title= is wikilinked to a source in wikisource ala cite wikisource
*/
.cs1-ws-icon a {
	background: url(//upload.wikimedia.org/wikipedia/commons/thumb/4/4c/Wikisource-logo.svg/12px-Wikisource-logo.svg.png) no-repeat;
	background-position: right .1em center;
}

/* Errors and maintenance */
code.cs1-code {
	/* &lt;code&gt;...&lt;/code&gt; style override: mediawiki's css definition is specified here:
	https://git.wikimedia.org/blob/mediawiki%2Fcore.git/69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199
	*/
	color: inherit;
	background: inherit;
	border: inherit;	/* code editor doesn't like inherit with border?
						https://www.w3.org/wiki/CSS/Properties/border
						suggests that inherit is ok
						the actual spec says the code editor is correct:
						https://www.w3.org/TR/css-backgrounds-3/#borders
						*/
	padding: inherit;
}

.cs1-hidden-error {
	display: none;
	font-size: 100%;
}

.cs1-visible-error {
	font-size: 100%;
}

.cs1-maint {
	display: none;
	color: #33aa33;
	margin-left: 0.3em;
}

/* Small text size
Set small text size in one place. 0.95 (here) * 0.9 (from references list) is
~0.85, which is the lower bound for size for accessibility. Old styling for this
was just 0.85. We could write the rule so that when this template is inside
references/reflist, only then does it multiply by 0.95; else multiply by 0.85 */
.cs1-subscription,
.cs1-registration,
.cs1-format {
	font-size: 95%;
}

/* kerning */
.cs1-kern-left,
.cs1-kern-wl-left {
	padding-left: 0.2em;
}

.cs1-kern-right,
.cs1-kern-wl-right {
	padding-right: 0.2em;
}</text>
      <sha1>4b0rbgfwypupw286w6ycml5ovdk6dkc</sha1>
    </revision>
    <revision>
      <id>5031</id>
      <parentid>5030</parentid>
      <timestamp>2020-04-18T12:50:43Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>5031</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="4767" sha1="8ryajwyk0nayscee4lq07orx1ekke4v" xml:space="preserve">/*-------------------------&lt; P R O T E C T I O N   I C O N &gt;--------------------

the following line controls the page-protection icon in the upper right corner
it must remain within this comment
	{{sandbox other||{{pp-template}}}}

*/


/*-------------------------&lt; O V E R R I D E S &gt;--------------------------------

cs1|2 references are wrapped in &lt;cite&gt;...&lt;/cite&gt; tags.  Some wikis have not
chosen to override the generic user agent italic styling as en.wiki has.  This
(untested) styling should override the user agent default when cs1|2 templates
are rendered.

Similarly, some languages use different quotation punctuation so that setting
is also made available here.
*/
cite.citation {
	/* Reset italic styling set by user agent (only for cs1|2 templates; the
	reason for the .citation qualifier) */
	font-style: inherit;
}

.citation q {
	/* Straight quote marks for &lt;q&gt;; keep same as [[MediaWiki:Common.css]] */
	quotes: '&quot;' '&quot;' &quot;'&quot; &quot;'&quot;;
}

/* ID and URL access
Both core and Common.css have selector .mw-parser-output a[href$=&quot;.pdf&quot;].external
for PDF pages. All TemplateStyles pages are hoisted to .mw-parser-output. We need
to have specificity equal to a[href$=&quot;.pdf&quot;].external for locks to override PDF icon.

the .id-lock-... selectors are for use by non-citation templates like {{Catalog lookup link}}
*/

.id-lock-free a,
.citation .cs1-lock-free a {
	background-image: url(//upload.wikimedia.org/wikipedia/commons/thumb/6/65/Lock-green.svg/9px-Lock-green.svg.png);
	background-image: linear-gradient(transparent, transparent), url(//upload.wikimedia.org/wikipedia/commons/6/65/Lock-green.svg);
	background-repeat: no-repeat;
	background-size: 9px;
	background-position: right .1em center;
}

.id-lock-limited a,
.id-lock-registration a,
.citation .cs1-lock-limited a,
.citation .cs1-lock-registration a {
	background-image: url(//upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Lock-gray-alt-2.svg/9px-Lock-gray-alt-2.svg.png);
	background-image: linear-gradient(transparent, transparent), url(//upload.wikimedia.org/wikipedia/commons/d/d6/Lock-gray-alt-2.svg);
	background-repeat: no-repeat;
	background-size: 9px;
	background-position: right .1em center;
}

.id-lock-subscription a,
.citation .cs1-lock-subscription a {
	background-image: url(//upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Lock-red-alt-2.svg/9px-Lock-red-alt-2.svg.png);
	background-image: linear-gradient(transparent, transparent), url(//upload.wikimedia.org/wikipedia/commons/a/aa/Lock-red-alt-2.svg);
	background-repeat: no-repeat;
	background-size: 9px;
	background-position: right .1em center; 
}

.cs1-subscription,
.cs1-registration {
	color: #555;
}

.cs1-subscription span,
.cs1-registration span {
	border-bottom: 1px dotted;
	cursor: help;
}

/* Wikisource icon
Experiment to see if it is possible/practical to add support for a wikisource
icon when |chapter= or |title= is wikilinked to a source in wikisource ala cite wikisource
*/
.cs1-ws-icon a {
	background-image: url(//upload.wikimedia.org/wikipedia/commons/thumb/4/4c/Wikisource-logo.svg/12px-Wikisource-logo.svg.png);
	background-image: linear-gradient(transparent, transparent), url(//upload.wikimedia.org/wikipedia/commons/4/4c/Wikisource-logo.svg);
	background-repeat: no-repeat;
	background-size: 12px;
	background-position: right .1em center;
}

/* Errors and maintenance */
code.cs1-code {
	/* &lt;code&gt;...&lt;/code&gt; style override: mediawiki's css definition is specified here:
	https://git.wikimedia.org/blob/mediawiki%2Fcore.git/69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199
	*/
	color: inherit;
	background: inherit;
	border: inherit;	/* code editor doesn't like inherit with border?
						https://www.w3.org/wiki/CSS/Properties/border
						suggests that inherit is ok
						the actual spec says the code editor is correct:
						https://www.w3.org/TR/css-backgrounds-3/#borders
						*/
	padding: inherit;
}

.cs1-hidden-error {
	display: none;
	font-size: 100%;
}

.cs1-visible-error {
	font-size: 100%;
}

.cs1-maint {
	display: none;
	color: #33aa33;
	margin-left: 0.3em;
}

/* Small text size
Set small text size in one place. 0.95 (here) * 0.9 (from references list) is
~0.85, which is the lower bound for size for accessibility. Old styling for this
was just 0.85. We could write the rule so that when this template is inside
references/reflist, only then does it multiply by 0.95; else multiply by 0.85 */
.cs1-subscription,
.cs1-registration,
.cs1-format {
	font-size: 95%;
}

/* kerning */
.cs1-kern-left,
.cs1-kern-wl-left {
	padding-left: 0.2em;
}

.cs1-kern-right,
.cs1-kern-wl-right {
	padding-right: 0.2em;
}

/* selflinks – avoid bold font style when cs1|2 template links to the current page */
.citation .mw-selflink {
	font-weight: inherit;
}</text>
      <sha1>8ryajwyk0nayscee4lq07orx1ekke4v</sha1>
    </revision>
    <revision>
      <id>5032</id>
      <parentid>5031</parentid>
      <timestamp>2020-10-10T13:22:51Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>5032</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="3290" sha1="1m7rwqy4j4owuxl77ctkjt24he3uj8v" xml:space="preserve">/* Protection icon
the following line controls the page-protection icon in the upper right corner
it must remain within this comment
	{{sandbox other||{{pp-template}}}}

*/

/* Overrides
Some wikis do not override user agent default styles for HTML &lt;cite&gt; and &lt;q&gt;,
unlike en.wp. On en.wp, keep these the same as [[MediaWiki:Common.css]]
*/
cite.citation {
	font-style: inherit; /* Remove italics for &lt;cite&gt; */
}

.citation q {
	quotes: '&quot;' '&quot;' &quot;'&quot; &quot;'&quot;; /* Straight quote marks for &lt;q&gt; */
}

/* ID and URL access
Both core and Common.css have selector .mw-parser-output a[href$=&quot;.pdf&quot;].external
for PDF pages. All TemplateStyles pages are hoisted to .mw-parser-output. We need
to have specificity equal to a[href$=&quot;.pdf&quot;].external for locks to override PDF icon.

the .id-lock-... selectors are for use by non-citation templates like {{Catalog lookup link}}
*/
.id-lock-free a,
.citation .cs1-lock-free a {
	background: linear-gradient(transparent, transparent),
		url(//upload.wikimedia.org/wikipedia/commons/6/65/Lock-green.svg)
		right 0.1em center/9px no-repeat;
}

.id-lock-limited a,
.id-lock-registration a,
.citation .cs1-lock-limited a,
.citation .cs1-lock-registration a {
	background: linear-gradient(transparent, transparent),
		url(//upload.wikimedia.org/wikipedia/commons/d/d6/Lock-gray-alt-2.svg)
		right 0.1em center/9px no-repeat;
}

.id-lock-subscription a,
.citation .cs1-lock-subscription a {
	background: linear-gradient(transparent, transparent),
		url(//upload.wikimedia.org/wikipedia/commons/a/aa/Lock-red-alt-2.svg)
		right 0.1em center/9px no-repeat;
}

.cs1-subscription,
.cs1-registration {
	color: #555;
}

.cs1-subscription span,
.cs1-registration span {
	border-bottom: 1px dotted;
	cursor: help;
}

/* Wikisource
Wikisource icon when |chapter= or |title= is wikilinked to Wikisource
as in cite wikisource
*/
.cs1-ws-icon a {
	background: linear-gradient(transparent, transparent),
		url(//upload.wikimedia.org/wikipedia/commons/4/4c/Wikisource-logo.svg)
		right 0.1em center/12px no-repeat;
}

/* Errors and maintenance */
code.cs1-code {
	/* &lt;code&gt;...&lt;/code&gt; style override: mediawiki's css definition is specified here:
	https://git.wikimedia.org/blob/mediawiki%2Fcore.git/
		69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199
	*/
	color: inherit;
	background: inherit;
	border: none; /* this maybe can be inherit. MDN says yes, code editor says no */
	padding: inherit;
}

.cs1-hidden-error {
	display: none;
	font-size: 100%;
}

.cs1-visible-error {
	font-size: 100%;
}

.cs1-maint {
	display: none;
	color: #33aa33;
	margin-left: 0.3em;
}

/* Small text size
Set small text size in one place. 0.95 (here) * 0.9 (from references list) is
~0.85, which is the lower bound for size for accessibility. Old styling for this
was just 0.85. We could write the rule so that when this template is inside
references/reflist, only then does it multiply by 0.95; else multiply by 0.85 */
.cs1-subscription,
.cs1-registration,
.cs1-format {
	font-size: 95%;
}

/* kerning */
.cs1-kern-left,
.cs1-kern-wl-left {
	padding-left: 0.2em;
}

.cs1-kern-right,
.cs1-kern-wl-right {
	padding-right: 0.2em;
}

/* selflinks – avoid bold font style when cs1|2 template links to the current page */
.citation .mw-selflink {
	font-weight: inherit;
}</text>
      <sha1>1m7rwqy4j4owuxl77ctkjt24he3uj8v</sha1>
    </revision>
    <revision>
      <id>5033</id>
      <parentid>5032</parentid>
      <timestamp>2021-01-09T14:11:04Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>5033</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="3252" sha1="oaoi1bld4zu2dgneb2yaj11tyyqa6vc" xml:space="preserve">/* Protection icon
the following line controls the page-protection icon in the upper right corner
it must remain within this comment
	{{sandbox other||{{pp-template}}}}

*/

/* Overrides
Some wikis do not override user agent default styles for HTML &lt;cite&gt; and &lt;q&gt;,
unlike en.wp. On en.wp, keep these the same as [[MediaWiki:Common.css]]
*/
cite.citation {
	font-style: inherit; /* Remove italics for &lt;cite&gt; */
}

.citation q {
	quotes: '&quot;' '&quot;' &quot;'&quot; &quot;'&quot;; /* Straight quote marks for &lt;q&gt; */
}

/* ID and URL access
Both core and Common.css have selector .mw-parser-output a[href$=&quot;.pdf&quot;].external
for PDF pages. All TemplateStyles pages are hoisted to .mw-parser-output. We need
to have specificity equal to a[href$=&quot;.pdf&quot;].external for locks to override PDF icon.

the .id-lock-... selectors are for use by non-citation templates like {{Catalog lookup link}}
*/
.id-lock-free a,
.citation .cs1-lock-free a {
	background: linear-gradient(transparent, transparent),
		url(//upload.wikimedia.org/wikipedia/commons/6/65/Lock-green.svg)
		right 0.1em center/9px no-repeat;
}

.id-lock-limited a,
.id-lock-registration a,
.citation .cs1-lock-limited a,
.citation .cs1-lock-registration a {
	background: linear-gradient(transparent, transparent),
		url(//upload.wikimedia.org/wikipedia/commons/d/d6/Lock-gray-alt-2.svg)
		right 0.1em center/9px no-repeat;
}

.id-lock-subscription a,
.citation .cs1-lock-subscription a {
	background: linear-gradient(transparent, transparent),
		url(//upload.wikimedia.org/wikipedia/commons/a/aa/Lock-red-alt-2.svg)
		right 0.1em center/9px no-repeat;
}

.cs1-subscription,
.cs1-registration {
	color: #555;
}

.cs1-subscription span,
.cs1-registration span {
	border-bottom: 1px dotted;
	cursor: help;
}

/* Wikisource
Wikisource icon when |chapter= or |title= is wikilinked to Wikisource
as in cite wikisource
*/
.cs1-ws-icon a {
	background: linear-gradient(transparent, transparent),
		url(//upload.wikimedia.org/wikipedia/commons/4/4c/Wikisource-logo.svg)
		right 0.1em center/12px no-repeat;
}

/* Errors and maintenance */
code.cs1-code {
	/* &lt;code&gt;...&lt;/code&gt; style override: mediawiki's css definition is specified here:
	https://git.wikimedia.org/blob/mediawiki%2Fcore.git/
		69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199
	*/
	color: inherit;
	background: inherit;
	border: none; /* this maybe can be inherit. MDN says yes, code editor says no */
	padding: inherit;
}

.cs1-hidden-error {
	display: none;
	font-size: 100%;
}

.cs1-visible-error {
	font-size: 100%;
}

.cs1-maint {
	display: none;
	color: #33aa33;
	margin-left: 0.3em;
}

/* Small text size
Set small text size in one place. 0.95 (here) * 0.9 (from references list) is
~0.85, which is the lower bound for size for accessibility. Old styling for this
was just 0.85. We could write the rule so that when this template is inside
references/reflist, only then does it multiply by 0.95; else multiply by 0.85 */
.cs1-format {
	font-size: 95%;
}

/* kerning */
.cs1-kern-left,
.cs1-kern-wl-left {
	padding-left: 0.2em;
}

.cs1-kern-right,
.cs1-kern-wl-right {
	padding-right: 0.2em;
}

/* selflinks – avoid bold font style when cs1|2 template links to the current page */
.citation .mw-selflink {
	font-weight: inherit;
}</text>
      <sha1>oaoi1bld4zu2dgneb2yaj11tyyqa6vc</sha1>
    </revision>
    <revision>
      <id>5034</id>
      <parentid>5033</parentid>
      <timestamp>2022-01-22T14:11:09Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>update per [[Wikipedia:Village_pump_(proposals)#rfc:_shall_we_update_cs1/2?|RfC]];</comment>
      <origin>5034</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="3482" sha1="05swlrxxaulwkgtbbdmtf5atrgfwmuz" xml:space="preserve">/* Protection icon
the following line controls the page-protection icon in the upper right corner
it must remain within this comment
	{{sandbox other||{{pp-template}}}}

*/

/* Overrides
Some wikis do not override user agent default styles for HTML &lt;cite&gt; and &lt;q&gt;,
unlike en.wp. On en.wp, keep these the same as [[MediaWiki:Common.css]].

The word-wrap and :target styles were moved here from Common.css.
On en.wp, keep these the same as [[Template:Citation/styles.css]].
*/
cite.citation {
	font-style: inherit; /* Remove italics for &lt;cite&gt; */
	/* Break long urls, etc., rather than overflowing box */
	word-wrap: break-word;
}

.citation q {
	quotes: '&quot;' '&quot;' &quot;'&quot; &quot;'&quot;; /* Straight quote marks for &lt;q&gt; */
}

/* Highlight linked elements (such as clicked references) in blue */
.citation:target {
	/* ignore the linter - all browsers of interest implement this */
	background-color: rgba(0, 127, 255, 0.133);
}

/* ID and URL access
Both core and Common.css have selector .mw-parser-output a[href$=&quot;.pdf&quot;].external
for PDF pages. All TemplateStyles pages are hoisted to .mw-parser-output. We need
to have specificity equal to a[href$=&quot;.pdf&quot;].external for locks to override PDF icon.
That's essentially 2 classes and 1 element.

the .id-lock-... selectors are for use by non-citation templates like
{{Catalog lookup link}} which do not have to handle PDF links
*/
.id-lock-free a,
.citation .cs1-lock-free a {
	background: linear-gradient(transparent, transparent),
		url(//upload.wikimedia.org/wikipedia/commons/6/65/Lock-green.svg)
		right 0.1em center/9px no-repeat;
}

.id-lock-limited a,
.id-lock-registration a,
.citation .cs1-lock-limited a,
.citation .cs1-lock-registration a {
	background: linear-gradient(transparent, transparent),
		url(//upload.wikimedia.org/wikipedia/commons/d/d6/Lock-gray-alt-2.svg)
		right 0.1em center/9px no-repeat;
}

.id-lock-subscription a,
.citation .cs1-lock-subscription a {
	background: linear-gradient(transparent, transparent),
		url(//upload.wikimedia.org/wikipedia/commons/a/aa/Lock-red-alt-2.svg)
		right 0.1em center/9px no-repeat;
}

/* Wikisource
Wikisource icon when |chapter= or |title= is wikilinked to Wikisource
as in cite wikisource
*/
.cs1-ws-icon a {
	background: linear-gradient(transparent, transparent),
		url(//upload.wikimedia.org/wikipedia/commons/4/4c/Wikisource-logo.svg)
		right 0.1em center/12px no-repeat;
}

/* Errors and maintenance */
.cs1-code {
	/* &lt;code&gt;...&lt;/code&gt; style override: mediawiki's css definition is specified here:
	https://git.wikimedia.org/blob/mediawiki%2Fcore.git/
		69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199
	*/
	color: inherit;
	background: inherit;
	border: none;
	padding: inherit;
}

.cs1-hidden-error {
	display: none;
	color: #d33;
}

.cs1-visible-error {
	color: #d33;
}

.cs1-maint {
	display: none;
	color: #3a3;
	margin-left: 0.3em;
}

/* Small text size
Set small text size in one place. 0.95 (here) * 0.9 (from references list) is
~0.85, which is the lower bound for size for accessibility. Old styling for this
was just 0.85. We could write the rule so that when this template is inside
references/reflist, only then does it multiply by 0.95; else multiply by 0.85 */
.cs1-format {
	font-size: 95%;
}

/* kerning */
.cs1-kern-left {
	padding-left: 0.2em;
}

.cs1-kern-right {
	padding-right: 0.2em;
}

/* selflinks – avoid bold font style when cs1|2 template links to the current page */
.citation .mw-selflink {
	font-weight: inherit;
}</text>
      <sha1>05swlrxxaulwkgtbbdmtf5atrgfwmuz</sha1>
    </revision>
    <revision>
      <id>5035</id>
      <parentid>5034</parentid>
      <timestamp>2023-01-14T14:43:34Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>5035</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="3302" sha1="ejxb7w00q7ab6z612s0f3eb5n73ikia" xml:space="preserve">/* Protection icon
the following line controls the page-protection icon in the upper right corner
it must remain within this comment
	{{sandbox other||{{pp-template}}}}

*/

/* Overrides
Some wikis do not override user agent default styles for HTML &lt;cite&gt; and &lt;q&gt;,
unlike en.wp. On en.wp, keep these the same as [[MediaWiki:Common.css]].

The word-wrap and :target styles were moved here from Common.css.
On en.wp, keep these the same as [[Template:Citation/styles.css]].
*/
cite.citation {
	font-style: inherit; /* Remove italics for &lt;cite&gt; */
	/* Break long urls, etc., rather than overflowing box */
	word-wrap: break-word;
}

.citation q {
	quotes: '&quot;' '&quot;' &quot;'&quot; &quot;'&quot;; /* Straight quote marks for &lt;q&gt; */
}

/* Highlight linked elements (such as clicked references) in blue */
.citation:target {
	/* ignore the linter - all browsers of interest implement this */
	background-color: rgba(0, 127, 255, 0.133);
}

/* ID and URL access
Both core and Common.css have selector .mw-parser-output a[href$=&quot;.pdf&quot;].external
for PDF pages. All TemplateStyles pages are hoisted to .mw-parser-output. We need
to have specificity equal to a[href$=&quot;.pdf&quot;].external for locks to override PDF icon.
That's essentially 2 classes and 1 element.

the .id-lock-... selectors are for use by non-citation templates like
{{Catalog lookup link}} which do not have to handle PDF links
*/
.id-lock-free a,
.citation .cs1-lock-free a {
	background: url(//upload.wikimedia.org/wikipedia/commons/6/65/Lock-green.svg)
		right 0.1em center/9px no-repeat;
}

.id-lock-limited a,
.id-lock-registration a,
.citation .cs1-lock-limited a,
.citation .cs1-lock-registration a {
	background: url(//upload.wikimedia.org/wikipedia/commons/d/d6/Lock-gray-alt-2.svg)
		right 0.1em center/9px no-repeat;
}

.id-lock-subscription a,
.citation .cs1-lock-subscription a {
	background: url(//upload.wikimedia.org/wikipedia/commons/a/aa/Lock-red-alt-2.svg)
		right 0.1em center/9px no-repeat;
}

/* Wikisource
Wikisource icon when |chapter= or |title= is wikilinked to Wikisource
as in cite wikisource
*/
.cs1-ws-icon a {
	background: url(//upload.wikimedia.org/wikipedia/commons/4/4c/Wikisource-logo.svg)
		right 0.1em center/12px no-repeat;
}

/* Errors and maintenance */
.cs1-code {
	/* &lt;code&gt;...&lt;/code&gt; style override: mediawiki's css definition is specified here:
	https://git.wikimedia.org/blob/mediawiki%2Fcore.git/
		69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199
	*/
	color: inherit;
	background: inherit;
	border: none;
	padding: inherit;
}

.cs1-hidden-error {
	display: none;
	color: #d33;
}

.cs1-visible-error {
	color: #d33;
}

.cs1-maint {
	display: none;
	color: #3a3;
	margin-left: 0.3em;
}

/* Small text size
Set small text size in one place. 0.95 (here) * 0.9 (from references list) is
~0.85, which is the lower bound for size for accessibility. Old styling for this
was just 0.85. We could write the rule so that when this template is inside
references/reflist, only then does it multiply by 0.95; else multiply by 0.85 */
.cs1-format {
	font-size: 95%;
}

/* kerning */
.cs1-kern-left {
	padding-left: 0.2em;
}

.cs1-kern-right {
	padding-right: 0.2em;
}

/* selflinks – avoid bold font style when cs1|2 template links to the current page */
.citation .mw-selflink {
	font-weight: inherit;
}</text>
      <sha1>ejxb7w00q7ab6z612s0f3eb5n73ikia</sha1>
    </revision>
    <revision>
      <id>5036</id>
      <parentid>5035</parentid>
      <timestamp>2024-03-23T15:32:39Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>sync from sandbox;</comment>
      <origin>5036</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="4370" sha1="k2swanwe3pivjhe0tpkmp82iio2fwuc" xml:space="preserve">/* Protection icon
the following line controls the page-protection icon in the upper right corner
it must remain within this comment
	{{sandbox other||{{pp-template}}}}

*/

/* Overrides
Some wikis do not override user agent default styles for HTML &lt;cite&gt; and &lt;q&gt;,
unlike en.wp. On en.wp, keep these the same as [[MediaWiki:Common.css]].

The word-wrap and :target styles were moved here from Common.css.
On en.wp, keep these the same as [[Template:Citation/styles.css]].
*/
cite.citation {
	font-style: inherit; /* Remove italics for &lt;cite&gt; */
	/* Break long urls, etc., rather than overflowing box */
	word-wrap: break-word;
}

.citation q {
	quotes: '&quot;' '&quot;' &quot;'&quot; &quot;'&quot;; /* Straight quote marks for &lt;q&gt; */
}

/* Highlight linked elements (such as clicked references) in blue */
.citation:target {
	/* ignore the linter - all browsers of interest implement this */
	background-color: rgba(0, 127, 255, 0.133);
}

/* ID and URL access
Both core and Common.css have selector .mw-parser-output a[href$=&quot;.pdf&quot;].external
for PDF pages. All TemplateStyles pages are hoisted to .mw-parser-output. We need
to have specificity equal to a[href$=&quot;.pdf&quot;].external for locks to override PDF icon.
That's essentially 2 classes and 1 element.

the .id-lock-... selectors are for use by non-citation templates like
{{Catalog lookup link}}

bg-size `contain` in Minerva and Timeless is too large, so we set a size for them
and then exclude them later
*/
.id-lock-free.id-lock-free a {
	background: url(//upload.wikimedia.org/wikipedia/commons/6/65/Lock-green.svg)
		right 0.1em center/9px no-repeat;
}

body:not(.skin-timeless):not(.skin-minerva) .id-lock-free a {
	background-size: contain;													
}

.id-lock-limited.id-lock-limited a,
.id-lock-registration.id-lock-registration a {
	background: url(//upload.wikimedia.org/wikipedia/commons/d/d6/Lock-gray-alt-2.svg)
		right 0.1em center/9px no-repeat;
}

body:not(.skin-timeless):not(.skin-minerva) .id-lock-limited a,
body:not(.skin-timeless):not(.skin-minerva) .id-lock-registration a {
	background-size: contain;
}

.id-lock-subscription.id-lock-subscription a {
	background: url(//upload.wikimedia.org/wikipedia/commons/a/aa/Lock-red-alt-2.svg)
		right 0.1em center/9px no-repeat;
}

body:not(.skin-timeless):not(.skin-minerva) .id-lock-subscription a {
	background-size: contain;
}

/* Wikisource
Wikisource icon when |chapter= or |title= is wikilinked to Wikisource
as in cite wikisource
*/
.cs1-ws-icon a {
	background: url(//upload.wikimedia.org/wikipedia/commons/4/4c/Wikisource-logo.svg)
		right 0.1em center/12px no-repeat;
}

body:not(.skin-timeless):not(.skin-minerva) .cs1-ws-icon a {
	background-size: contain;
}

/* Errors and maintenance */
.cs1-code {
	/* &lt;code&gt;...&lt;/code&gt; style override: mediawiki's css definition is specified here:
	https://git.wikimedia.org/blob/mediawiki%2Fcore.git/
		69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199
	*/
	color: inherit;
	background: inherit;
	border: none;
	padding: inherit;
}

.cs1-hidden-error {
	display: none;
	color: #d33;
}

.cs1-visible-error {
	color: #d33;
}

.cs1-maint {
	display: none;
	color: #2C882D;
	margin-left: 0.3em;
}

/* Small text size
Set small text size in one place. 0.95 (here) * 0.9 (from references list) is
~0.85, which is the lower bound for size for accessibility. Old styling for this
was just 0.85. We could write the rule so that when this template is inside
references/reflist, only then does it multiply by 0.95; else multiply by 0.85 */
.cs1-format {
	font-size: 95%;
}

/* kerning */
.cs1-kern-left {
	padding-left: 0.2em;
}

.cs1-kern-right {
	padding-right: 0.2em;
}

/* selflinks – avoid bold font style when cs1|2 template links to the current page */
.citation .mw-selflink {
	font-weight: inherit;
}

html.skin-theme-clientpref-night .cs1-maint {
	color: #18911F;
}

/* Remove next rule when [[phab:T360562]] is fixed and adjust above usual colors */
html.skin-theme-clientpref-night .cs1-visible-error,
html.skin-theme-clientpref-night .cs1-hidden-error {
	color: #f8a397;
}

@media (prefers-color-scheme: dark) {
	/* Remove next rule when [[phab:T360562]] is fixed and adjust above usual colors */
	html.skin-theme-clientpref-os .cs1-visible-error,
	html.skin-theme-clientpref-os .cs1-hidden-error {
		color: #f8a397;
	}
	
	html.skin-theme-clientpref-os .cs1-maint {
		color: #18911F;
	}
}</text>
      <sha1>k2swanwe3pivjhe0tpkmp82iio2fwuc</sha1>
    </revision>
    <revision>
      <id>5037</id>
      <parentid>5036</parentid>
      <timestamp>2024-07-31T22:52:55Z</timestamp>
      <contributor>
        <username>Jon (WMF)</username>
        <id>826</id>
      </contributor>
      <comment>Fixes [[phab:T369874]] via automated script</comment>
      <origin>5037</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="4414" sha1="cfi06ctzw90t9o0xx77fakj2k7f6896" xml:space="preserve">/* Protection icon
the following line controls the page-protection icon in the upper right corner
it must remain within this comment
	{{sandbox other||{{pp-template}}}}

*/

/* Overrides
Some wikis do not override user agent default styles for HTML &lt;cite&gt; and &lt;q&gt;,
unlike en.wp. On en.wp, keep these the same as [[MediaWiki:Common.css]].

The word-wrap and :target styles were moved here from Common.css.
On en.wp, keep these the same as [[Template:Citation/styles.css]].
*/
cite.citation {
	font-style: inherit; /* Remove italics for &lt;cite&gt; */
	/* Break long urls, etc., rather than overflowing box */
	word-wrap: break-word;
}

.citation q {
	quotes: '&quot;' '&quot;' &quot;'&quot; &quot;'&quot;; /* Straight quote marks for &lt;q&gt; */
}

/* Highlight linked elements (such as clicked references) in blue */
.citation:target {
	/* ignore the linter - all browsers of interest implement this */
	background-color: rgba(0, 127, 255, 0.133);
}

/* ID and URL access
Both core and Common.css have selector .mw-parser-output a[href$=&quot;.pdf&quot;].external
for PDF pages. All TemplateStyles pages are hoisted to .mw-parser-output. We need
to have specificity equal to a[href$=&quot;.pdf&quot;].external for locks to override PDF icon.
That's essentially 2 classes and 1 element.

the .id-lock-... selectors are for use by non-citation templates like
{{Catalog lookup link}}

bg-size `contain` in Minerva and Timeless is too large, so we set a size for them
and then exclude them later
*/
.id-lock-free.id-lock-free a {
	background: url(//upload.wikimedia.org/wikipedia/commons/6/65/Lock-green.svg)
		right 0.1em center/9px no-repeat;
}

body:not(.skin-timeless):not(.skin-minerva) .id-lock-free a {
	background-size: contain;													
}

.id-lock-limited.id-lock-limited a,
.id-lock-registration.id-lock-registration a {
	background: url(//upload.wikimedia.org/wikipedia/commons/d/d6/Lock-gray-alt-2.svg)
		right 0.1em center/9px no-repeat;
}

body:not(.skin-timeless):not(.skin-minerva) .id-lock-limited a,
body:not(.skin-timeless):not(.skin-minerva) .id-lock-registration a {
	background-size: contain;
}

.id-lock-subscription.id-lock-subscription a {
	background: url(//upload.wikimedia.org/wikipedia/commons/a/aa/Lock-red-alt-2.svg)
		right 0.1em center/9px no-repeat;
}

body:not(.skin-timeless):not(.skin-minerva) .id-lock-subscription a {
	background-size: contain;
}

/* Wikisource
Wikisource icon when |chapter= or |title= is wikilinked to Wikisource
as in cite wikisource
*/
.cs1-ws-icon a {
	background: url(//upload.wikimedia.org/wikipedia/commons/4/4c/Wikisource-logo.svg)
		right 0.1em center/12px no-repeat;
}

body:not(.skin-timeless):not(.skin-minerva) .cs1-ws-icon a {
	background-size: contain;
}

/* Errors and maintenance */
.cs1-code {
	/* &lt;code&gt;...&lt;/code&gt; style override: mediawiki's css definition is specified here:
	https://git.wikimedia.org/blob/mediawiki%2Fcore.git/
		69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199
	*/
	color: inherit;
	background: inherit;
	border: none;
	padding: inherit;
}

.cs1-hidden-error {
	display: none;
	color: #d33;
}

.cs1-visible-error {
	color: #d33;
}

.cs1-maint {
	display: none;
	color: #2C882D;
	margin-left: 0.3em;
}

/* Small text size
Set small text size in one place. 0.95 (here) * 0.9 (from references list) is
~0.85, which is the lower bound for size for accessibility. Old styling for this
was just 0.85. We could write the rule so that when this template is inside
references/reflist, only then does it multiply by 0.95; else multiply by 0.85 */
.cs1-format {
	font-size: 95%;
}

/* kerning */
.cs1-kern-left {
	padding-left: 0.2em;
}

.cs1-kern-right {
	padding-right: 0.2em;
}

/* selflinks – avoid bold font style when cs1|2 template links to the current page */
.citation .mw-selflink {
	font-weight: inherit;
}


@media screen {
    html.skin-theme-clientpref-night .cs1-maint {
		color: #18911F;
	}
	
	/* Remove next rule when [[phab:T360562]] is fixed and adjust above usual colors */
	html.skin-theme-clientpref-night .cs1-visible-error,
	html.skin-theme-clientpref-night .cs1-hidden-error {
		color: #f8a397;
	}
}


@media screen and ( prefers-color-scheme: dark) {
	/* Remove next rule when [[phab:T360562]] is fixed and adjust above usual colors */
	html.skin-theme-clientpref-os .cs1-visible-error,
	html.skin-theme-clientpref-os .cs1-hidden-error {
		color: #f8a397;
	}
	
	html.skin-theme-clientpref-os .cs1-maint {
		color: #18911F;
	}
}</text>
      <sha1>cfi06ctzw90t9o0xx77fakj2k7f6896</sha1>
    </revision>
    <revision>
      <id>5038</id>
      <parentid>5037</parentid>
      <timestamp>2024-07-31T23:41:08Z</timestamp>
      <contributor>
        <username>Trappist the monk</username>
        <id>811</id>
      </contributor>
      <comment>Undid revision [[Special:Diff/1237875763|1237875763]] by [[Special:Contributions/Jon (WMF)|Jon (WMF)]] ([[User talk:Jon (WMF)|talk]]) drive-by edits to the live module without evidence of testing and discussion at [[Help talk:Citation Style 1]] strongly discouraged; make your edits to the sandbox, test and discuss;</comment>
      <origin>5038</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="4370" sha1="k2swanwe3pivjhe0tpkmp82iio2fwuc" xml:space="preserve">/* Protection icon
the following line controls the page-protection icon in the upper right corner
it must remain within this comment
	{{sandbox other||{{pp-template}}}}

*/

/* Overrides
Some wikis do not override user agent default styles for HTML &lt;cite&gt; and &lt;q&gt;,
unlike en.wp. On en.wp, keep these the same as [[MediaWiki:Common.css]].

The word-wrap and :target styles were moved here from Common.css.
On en.wp, keep these the same as [[Template:Citation/styles.css]].
*/
cite.citation {
	font-style: inherit; /* Remove italics for &lt;cite&gt; */
	/* Break long urls, etc., rather than overflowing box */
	word-wrap: break-word;
}

.citation q {
	quotes: '&quot;' '&quot;' &quot;'&quot; &quot;'&quot;; /* Straight quote marks for &lt;q&gt; */
}

/* Highlight linked elements (such as clicked references) in blue */
.citation:target {
	/* ignore the linter - all browsers of interest implement this */
	background-color: rgba(0, 127, 255, 0.133);
}

/* ID and URL access
Both core and Common.css have selector .mw-parser-output a[href$=&quot;.pdf&quot;].external
for PDF pages. All TemplateStyles pages are hoisted to .mw-parser-output. We need
to have specificity equal to a[href$=&quot;.pdf&quot;].external for locks to override PDF icon.
That's essentially 2 classes and 1 element.

the .id-lock-... selectors are for use by non-citation templates like
{{Catalog lookup link}}

bg-size `contain` in Minerva and Timeless is too large, so we set a size for them
and then exclude them later
*/
.id-lock-free.id-lock-free a {
	background: url(//upload.wikimedia.org/wikipedia/commons/6/65/Lock-green.svg)
		right 0.1em center/9px no-repeat;
}

body:not(.skin-timeless):not(.skin-minerva) .id-lock-free a {
	background-size: contain;													
}

.id-lock-limited.id-lock-limited a,
.id-lock-registration.id-lock-registration a {
	background: url(//upload.wikimedia.org/wikipedia/commons/d/d6/Lock-gray-alt-2.svg)
		right 0.1em center/9px no-repeat;
}

body:not(.skin-timeless):not(.skin-minerva) .id-lock-limited a,
body:not(.skin-timeless):not(.skin-minerva) .id-lock-registration a {
	background-size: contain;
}

.id-lock-subscription.id-lock-subscription a {
	background: url(//upload.wikimedia.org/wikipedia/commons/a/aa/Lock-red-alt-2.svg)
		right 0.1em center/9px no-repeat;
}

body:not(.skin-timeless):not(.skin-minerva) .id-lock-subscription a {
	background-size: contain;
}

/* Wikisource
Wikisource icon when |chapter= or |title= is wikilinked to Wikisource
as in cite wikisource
*/
.cs1-ws-icon a {
	background: url(//upload.wikimedia.org/wikipedia/commons/4/4c/Wikisource-logo.svg)
		right 0.1em center/12px no-repeat;
}

body:not(.skin-timeless):not(.skin-minerva) .cs1-ws-icon a {
	background-size: contain;
}

/* Errors and maintenance */
.cs1-code {
	/* &lt;code&gt;...&lt;/code&gt; style override: mediawiki's css definition is specified here:
	https://git.wikimedia.org/blob/mediawiki%2Fcore.git/
		69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199
	*/
	color: inherit;
	background: inherit;
	border: none;
	padding: inherit;
}

.cs1-hidden-error {
	display: none;
	color: #d33;
}

.cs1-visible-error {
	color: #d33;
}

.cs1-maint {
	display: none;
	color: #2C882D;
	margin-left: 0.3em;
}

/* Small text size
Set small text size in one place. 0.95 (here) * 0.9 (from references list) is
~0.85, which is the lower bound for size for accessibility. Old styling for this
was just 0.85. We could write the rule so that when this template is inside
references/reflist, only then does it multiply by 0.95; else multiply by 0.85 */
.cs1-format {
	font-size: 95%;
}

/* kerning */
.cs1-kern-left {
	padding-left: 0.2em;
}

.cs1-kern-right {
	padding-right: 0.2em;
}

/* selflinks – avoid bold font style when cs1|2 template links to the current page */
.citation .mw-selflink {
	font-weight: inherit;
}

html.skin-theme-clientpref-night .cs1-maint {
	color: #18911F;
}

/* Remove next rule when [[phab:T360562]] is fixed and adjust above usual colors */
html.skin-theme-clientpref-night .cs1-visible-error,
html.skin-theme-clientpref-night .cs1-hidden-error {
	color: #f8a397;
}

@media (prefers-color-scheme: dark) {
	/* Remove next rule when [[phab:T360562]] is fixed and adjust above usual colors */
	html.skin-theme-clientpref-os .cs1-visible-error,
	html.skin-theme-clientpref-os .cs1-hidden-error {
		color: #f8a397;
	}
	
	html.skin-theme-clientpref-os .cs1-maint {
		color: #18911F;
	}
}</text>
      <sha1>k2swanwe3pivjhe0tpkmp82iio2fwuc</sha1>
    </revision>
    <revision>
      <id>5039</id>
      <parentid>5038</parentid>
      <timestamp>2024-08-02T18:47:39Z</timestamp>
      <contributor>
        <username>Izno</username>
        <id>817</id>
      </contributor>
      <comment>Well, since we're editing this today, I'll pull from sandbox, which *does* have the same change and has had the same change for a month (which you would have seen if you checked). If you don't understand CSS, consider asking a question instead of blindly reverting an otherwise correct edit.</comment>
      <origin>5039</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="4452" sha1="g94vqevafs45o1jd3o1f3ba6shczucf" xml:space="preserve">/*
History of changes since last sync: 2024-03-23
2024-04-16: fix bg-contain for PDF URLs; Help_talk:Citation_Style_1#The_url-access_lock_icon_becomes_huge_if_the_linked_source_is_a_PDF_file
2024-05-21: implement error design tokens per [[phab:T360562]]
*/

/* Protection icon
the following line controls the page-protection icon in the upper right corner
it must remain within this comment
	{{sandbox other||{{pp-template}}}}

*/

/* Overrides
Some wikis do not override user agent default styles for HTML &lt;cite&gt; and &lt;q&gt;,
unlike en.wp. On en.wp, keep these the same as [[MediaWiki:Common.css]].

The word-wrap and :target styles were moved here from Common.css.
On en.wp, keep these the same as [[Template:Citation/styles.css]].
*/
cite.citation {
	font-style: inherit; /* Remove italics for &lt;cite&gt; */
	/* Break long urls, etc., rather than overflowing box */
	word-wrap: break-word;
}

.citation q {
	quotes: '&quot;' '&quot;' &quot;'&quot; &quot;'&quot;; /* Straight quote marks for &lt;q&gt; */
}

/* Highlight linked elements (such as clicked references) in blue */
.citation:target {
	/* ignore the linter - all browsers of interest implement this */
	background-color: rgba(0, 127, 255, 0.133);
}

/* ID and URL access
Both core and Common.css have selector .mw-parser-output a[href$=&quot;.pdf&quot;].external
for PDF pages. All TemplateStyles pages are hoisted to .mw-parser-output. We need
to have specificity equal to a[href$=&quot;.pdf&quot;].external for locks to override PDF icon.
That's essentially 2 classes and 1 element.

the .id-lock-... selectors are for use by non-citation templates like
{{Catalog lookup link}}

bg-size `contain` in Minerva and Timeless is too large, so we set a size for them
and then exclude them later
*/
.id-lock-free.id-lock-free a {
	background: url(//upload.wikimedia.org/wikipedia/commons/6/65/Lock-green.svg)
		right 0.1em center/9px no-repeat;
}

.id-lock-limited.id-lock-limited a,
.id-lock-registration.id-lock-registration a {
	background: url(//upload.wikimedia.org/wikipedia/commons/d/d6/Lock-gray-alt-2.svg)
		right 0.1em center/9px no-repeat;
}

.id-lock-subscription.id-lock-subscription a {
	background: url(//upload.wikimedia.org/wikipedia/commons/a/aa/Lock-red-alt-2.svg)
		right 0.1em center/9px no-repeat;
}

/* Wikisource
Wikisource icon when |chapter= or |title= is wikilinked to Wikisource
as in cite wikisource
*/
.cs1-ws-icon a {
	background: url(//upload.wikimedia.org/wikipedia/commons/4/4c/Wikisource-logo.svg)
		right 0.1em center/12px no-repeat;
}

body:not(.skin-timeless):not(.skin-minerva) .id-lock-free a,
body:not(.skin-timeless):not(.skin-minerva) .id-lock-limited a,
body:not(.skin-timeless):not(.skin-minerva) .id-lock-registration a,
body:not(.skin-timeless):not(.skin-minerva) .id-lock-subscription a,
body:not(.skin-timeless):not(.skin-minerva) .cs1-ws-icon a {
	background-size: contain;
	/* Common.css has a padding set for PDF URLs. bg-contain expands to the
	 * size of the padding which makes the icons very large. we &quot;reset&quot; the
	 * padding here. 1em picked out of a hat based on console having a similar
	 * rule from elsewhere
	 */
	padding: 0 1em 0 0;
}

/* Errors and maintenance */
.cs1-code {
	/* &lt;code&gt;...&lt;/code&gt; style override: mediawiki's css definition is specified here:
	https://git.wikimedia.org/blob/mediawiki%2Fcore.git/
		69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199
	*/
	color: inherit;
	background: inherit;
	border: none;
	padding: inherit;
}

.cs1-hidden-error {
	display: none;
	color: var(--color-error, #d33);
}

.cs1-visible-error {
	color: var(--color-error, #d33);
}

.cs1-maint {
	display: none;
	color: #085;
	margin-left: 0.3em;
}

/* kerning */
.cs1-kern-left {
	padding-left: 0.2em;
}

.cs1-kern-right {
	padding-right: 0.2em;
}

/* selflinks – avoid bold font style when cs1|2 template links to the current page */
.citation .mw-selflink {
	font-weight: inherit;
}

@media screen {
	/* Small text size
	Set small text size in one place. 0.95 (here) * 0.9 (from references list) is
	~0.85, which is the lower bound for size for accessibility. Old styling for this
	was just 0.85. We could write the rule so that when this template is inside
	references/reflist, only then does it multiply by 0.95; else multiply by 0.85 */
	.cs1-format {
		font-size: 95%;
	}
	
	html.skin-theme-clientpref-night .cs1-maint {
		color: #18911f;
	}
}

@media screen and (prefers-color-scheme: dark) {
	html.skin-theme-clientpref-os .cs1-maint {
		color: #18911f;
	}
}</text>
      <sha1>g94vqevafs45o1jd3o1f3ba6shczucf</sha1>
    </revision>
    <revision>
      <id>5040</id>
      <parentid>5039</parentid>
      <timestamp>2024-08-02T18:48:11Z</timestamp>
      <contributor>
        <username>Izno</username>
        <id>817</id>
      </contributor>
      <comment>nix notes</comment>
      <origin>5040</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="4194" sha1="4vx8grkh20viq5i9qf98wumgw6uva7x" xml:space="preserve">/* Protection icon
the following line controls the page-protection icon in the upper right corner
it must remain within this comment
	{{sandbox other||{{pp-template}}}}

*/

/* Overrides
Some wikis do not override user agent default styles for HTML &lt;cite&gt; and &lt;q&gt;,
unlike en.wp. On en.wp, keep these the same as [[MediaWiki:Common.css]].

The word-wrap and :target styles were moved here from Common.css.
On en.wp, keep these the same as [[Template:Citation/styles.css]].
*/
cite.citation {
	font-style: inherit; /* Remove italics for &lt;cite&gt; */
	/* Break long urls, etc., rather than overflowing box */
	word-wrap: break-word;
}

.citation q {
	quotes: '&quot;' '&quot;' &quot;'&quot; &quot;'&quot;; /* Straight quote marks for &lt;q&gt; */
}

/* Highlight linked elements (such as clicked references) in blue */
.citation:target {
	/* ignore the linter - all browsers of interest implement this */
	background-color: rgba(0, 127, 255, 0.133);
}

/* ID and URL access
Both core and Common.css have selector .mw-parser-output a[href$=&quot;.pdf&quot;].external
for PDF pages. All TemplateStyles pages are hoisted to .mw-parser-output. We need
to have specificity equal to a[href$=&quot;.pdf&quot;].external for locks to override PDF icon.
That's essentially 2 classes and 1 element.

the .id-lock-... selectors are for use by non-citation templates like
{{Catalog lookup link}}

bg-size `contain` in Minerva and Timeless is too large, so we set a size for them
and then exclude them later
*/
.id-lock-free.id-lock-free a {
	background: url(//upload.wikimedia.org/wikipedia/commons/6/65/Lock-green.svg)
		right 0.1em center/9px no-repeat;
}

.id-lock-limited.id-lock-limited a,
.id-lock-registration.id-lock-registration a {
	background: url(//upload.wikimedia.org/wikipedia/commons/d/d6/Lock-gray-alt-2.svg)
		right 0.1em center/9px no-repeat;
}

.id-lock-subscription.id-lock-subscription a {
	background: url(//upload.wikimedia.org/wikipedia/commons/a/aa/Lock-red-alt-2.svg)
		right 0.1em center/9px no-repeat;
}

/* Wikisource
Wikisource icon when |chapter= or |title= is wikilinked to Wikisource
as in cite wikisource
*/
.cs1-ws-icon a {
	background: url(//upload.wikimedia.org/wikipedia/commons/4/4c/Wikisource-logo.svg)
		right 0.1em center/12px no-repeat;
}

body:not(.skin-timeless):not(.skin-minerva) .id-lock-free a,
body:not(.skin-timeless):not(.skin-minerva) .id-lock-limited a,
body:not(.skin-timeless):not(.skin-minerva) .id-lock-registration a,
body:not(.skin-timeless):not(.skin-minerva) .id-lock-subscription a,
body:not(.skin-timeless):not(.skin-minerva) .cs1-ws-icon a {
	background-size: contain;
	/* Common.css has a padding set for PDF URLs. bg-contain expands to the
	 * size of the padding which makes the icons very large. we &quot;reset&quot; the
	 * padding here. 1em picked out of a hat based on console having a similar
	 * rule from elsewhere
	 */
	padding: 0 1em 0 0;
}

/* Errors and maintenance */
.cs1-code {
	/* &lt;code&gt;...&lt;/code&gt; style override: mediawiki's css definition is specified here:
	https://git.wikimedia.org/blob/mediawiki%2Fcore.git/
		69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199
	*/
	color: inherit;
	background: inherit;
	border: none;
	padding: inherit;
}

.cs1-hidden-error {
	display: none;
	color: var(--color-error, #d33);
}

.cs1-visible-error {
	color: var(--color-error, #d33);
}

.cs1-maint {
	display: none;
	color: #085;
	margin-left: 0.3em;
}

/* kerning */
.cs1-kern-left {
	padding-left: 0.2em;
}

.cs1-kern-right {
	padding-right: 0.2em;
}

/* selflinks – avoid bold font style when cs1|2 template links to the current page */
.citation .mw-selflink {
	font-weight: inherit;
}

@media screen {
	/* Small text size
	Set small text size in one place. 0.95 (here) * 0.9 (from references list) is
	~0.85, which is the lower bound for size for accessibility. Old styling for this
	was just 0.85. We could write the rule so that when this template is inside
	references/reflist, only then does it multiply by 0.95; else multiply by 0.85 */
	.cs1-format {
		font-size: 95%;
	}
	
	html.skin-theme-clientpref-night .cs1-maint {
		color: #18911f;
	}
}

@media screen and (prefers-color-scheme: dark) {
	html.skin-theme-clientpref-os .cs1-maint {
		color: #18911f;
	}
}</text>
      <sha1>4vx8grkh20viq5i9qf98wumgw6uva7x</sha1>
    </revision>
    <revision>
      <id>5041</id>
      <parentid>5040</parentid>
      <timestamp>2025-08-07T07:39:53Z</timestamp>
      <contributor>
        <username>Martin Urbanec</username>
        <id>803</id>
      </contributor>
      <minor />
      <comment>41 revisions imported from [[:en:Module:Citation/CS1/styles.css]]: updating from enwiki</comment>
      <origin>5040</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="4194" sha1="4vx8grkh20viq5i9qf98wumgw6uva7x" xml:space="preserve">/* Protection icon
the following line controls the page-protection icon in the upper right corner
it must remain within this comment
	{{sandbox other||{{pp-template}}}}

*/

/* Overrides
Some wikis do not override user agent default styles for HTML &lt;cite&gt; and &lt;q&gt;,
unlike en.wp. On en.wp, keep these the same as [[MediaWiki:Common.css]].

The word-wrap and :target styles were moved here from Common.css.
On en.wp, keep these the same as [[Template:Citation/styles.css]].
*/
cite.citation {
	font-style: inherit; /* Remove italics for &lt;cite&gt; */
	/* Break long urls, etc., rather than overflowing box */
	word-wrap: break-word;
}

.citation q {
	quotes: '&quot;' '&quot;' &quot;'&quot; &quot;'&quot;; /* Straight quote marks for &lt;q&gt; */
}

/* Highlight linked elements (such as clicked references) in blue */
.citation:target {
	/* ignore the linter - all browsers of interest implement this */
	background-color: rgba(0, 127, 255, 0.133);
}

/* ID and URL access
Both core and Common.css have selector .mw-parser-output a[href$=&quot;.pdf&quot;].external
for PDF pages. All TemplateStyles pages are hoisted to .mw-parser-output. We need
to have specificity equal to a[href$=&quot;.pdf&quot;].external for locks to override PDF icon.
That's essentially 2 classes and 1 element.

the .id-lock-... selectors are for use by non-citation templates like
{{Catalog lookup link}}

bg-size `contain` in Minerva and Timeless is too large, so we set a size for them
and then exclude them later
*/
.id-lock-free.id-lock-free a {
	background: url(//upload.wikimedia.org/wikipedia/commons/6/65/Lock-green.svg)
		right 0.1em center/9px no-repeat;
}

.id-lock-limited.id-lock-limited a,
.id-lock-registration.id-lock-registration a {
	background: url(//upload.wikimedia.org/wikipedia/commons/d/d6/Lock-gray-alt-2.svg)
		right 0.1em center/9px no-repeat;
}

.id-lock-subscription.id-lock-subscription a {
	background: url(//upload.wikimedia.org/wikipedia/commons/a/aa/Lock-red-alt-2.svg)
		right 0.1em center/9px no-repeat;
}

/* Wikisource
Wikisource icon when |chapter= or |title= is wikilinked to Wikisource
as in cite wikisource
*/
.cs1-ws-icon a {
	background: url(//upload.wikimedia.org/wikipedia/commons/4/4c/Wikisource-logo.svg)
		right 0.1em center/12px no-repeat;
}

body:not(.skin-timeless):not(.skin-minerva) .id-lock-free a,
body:not(.skin-timeless):not(.skin-minerva) .id-lock-limited a,
body:not(.skin-timeless):not(.skin-minerva) .id-lock-registration a,
body:not(.skin-timeless):not(.skin-minerva) .id-lock-subscription a,
body:not(.skin-timeless):not(.skin-minerva) .cs1-ws-icon a {
	background-size: contain;
	/* Common.css has a padding set for PDF URLs. bg-contain expands to the
	 * size of the padding which makes the icons very large. we &quot;reset&quot; the
	 * padding here. 1em picked out of a hat based on console having a similar
	 * rule from elsewhere
	 */
	padding: 0 1em 0 0;
}

/* Errors and maintenance */
.cs1-code {
	/* &lt;code&gt;...&lt;/code&gt; style override: mediawiki's css definition is specified here:
	https://git.wikimedia.org/blob/mediawiki%2Fcore.git/
		69cd73811f7aadd093050dbf20ed70ef0b42a713/skins%2Fcommon%2FcommonElements.css#L199
	*/
	color: inherit;
	background: inherit;
	border: none;
	padding: inherit;
}

.cs1-hidden-error {
	display: none;
	color: var(--color-error, #d33);
}

.cs1-visible-error {
	color: var(--color-error, #d33);
}

.cs1-maint {
	display: none;
	color: #085;
	margin-left: 0.3em;
}

/* kerning */
.cs1-kern-left {
	padding-left: 0.2em;
}

.cs1-kern-right {
	padding-right: 0.2em;
}

/* selflinks – avoid bold font style when cs1|2 template links to the current page */
.citation .mw-selflink {
	font-weight: inherit;
}

@media screen {
	/* Small text size
	Set small text size in one place. 0.95 (here) * 0.9 (from references list) is
	~0.85, which is the lower bound for size for accessibility. Old styling for this
	was just 0.85. We could write the rule so that when this template is inside
	references/reflist, only then does it multiply by 0.95; else multiply by 0.85 */
	.cs1-format {
		font-size: 95%;
	}
	
	html.skin-theme-clientpref-night .cs1-maint {
		color: #18911f;
	}
}

@media screen and (prefers-color-scheme: dark) {
	html.skin-theme-clientpref-os .cs1-maint {
		color: #18911f;
	}
}</text>
      <sha1>4vx8grkh20viq5i9qf98wumgw6uva7x</sha1>
    </revision>
  </page>
  <page>
    <title>MediaWiki:Gadget-HotCat</title>
    <ns>8</ns>
    <id>738</id>
    <revision>
      <id>5045</id>
      <timestamp>2025-08-07T08:04:58Z</timestamp>
      <contributor>
        <username>Martin Urbanec</username>
        <id>803</id>
      </contributor>
      <comment>enabling HotCat {translation by [[User:Nomsa Skosana]])</comment>
      <origin>5045</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="123" sha1="o4ac6hniq18nkjpat4v4un90050laq0" xml:space="preserve">HotCat: faka ngobulula, susa, begodu faka amakhathegori ekhasineli, namagama owasikiselako ([[:File:HotCat.png|isibonelo]])</text>
      <sha1>o4ac6hniq18nkjpat4v4un90050laq0</sha1>
    </revision>
  </page>
  <page>
    <title>MediaWiki:Gadgets-definition</title>
    <ns>8</ns>
    <id>739</id>
    <revision>
      <id>5046</id>
      <timestamp>2025-08-07T08:05:50Z</timestamp>
      <contributor>
        <username>Martin Urbanec</username>
        <id>803</id>
      </contributor>
      <comment>enable HotCat</comment>
      <origin>5046</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="65" sha1="p1jdcu1btgecdz9t4h7wo13c4mexuna" xml:space="preserve">== edit-gadgets ==
* HotCat[ResourceLoader|rights=edit]|HotCat.js</text>
      <sha1>p1jdcu1btgecdz9t4h7wo13c4mexuna</sha1>
    </revision>
    <revision>
      <id>5047</id>
      <parentid>5046</parentid>
      <timestamp>2025-08-07T08:06:13Z</timestamp>
      <contributor>
        <username>Martin Urbanec</username>
        <id>803</id>
      </contributor>
      <minor />
      <comment>remove the section</comment>
      <origin>5047</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="46" sha1="qr300h780fjt5y3oy73caz7q8etmfx1" xml:space="preserve">* HotCat[ResourceLoader|rights=edit]|HotCat.js</text>
      <sha1>qr300h780fjt5y3oy73caz7q8etmfx1</sha1>
    </revision>
  </page>
  <page>
    <title>Isiko-pilo</title>
    <ns>0</ns>
    <id>740</id>
    <revision>
      <id>5055</id>
      <timestamp>2025-08-07T13:50:11Z</timestamp>
      <contributor>
        <username>Zukesto</username>
        <id>829</id>
      </contributor>
      <comment>Created page with &quot;isiko pilo yabantu&quot;</comment>
      <origin>5055</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="18" sha1="9iytv2qmtqrqpck63s0ywjwozxq9qb1" xml:space="preserve">isiko pilo yabantu</text>
      <sha1>9iytv2qmtqrqpck63s0ywjwozxq9qb1</sha1>
    </revision>
  </page>
  <page>
    <title>Ukuzithwala</title>
    <ns>0</ns>
    <id>741</id>
    <revision>
      <id>5073</id>
      <timestamp>2025-08-08T08:12:24Z</timestamp>
      <contributor>
        <username>Zukesto</username>
        <id>829</id>
      </contributor>
      <comment>pregnancy</comment>
      <origin>5073</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="34" sha1="h8ygs2vac8bmaujgck0y0m1cur209d4" xml:space="preserve">ukuzithwala kulokha umuntu wengubo</text>
      <sha1>h8ygs2vac8bmaujgck0y0m1cur209d4</sha1>
    </revision>
    <revision>
      <id>5075</id>
      <parentid>5073</parentid>
      <timestamp>2025-08-08T08:14:51Z</timestamp>
      <contributor>
        <username>Mpho F Mahlangu</username>
        <id>838</id>
      </contributor>
      <origin>5075</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="43" sha1="d1sbxyefsuc6tal21gdmsogendwz1g2" xml:space="preserve">Ukuzithwala kulokha umuntu wengubo asidisi.</text>
      <sha1>d1sbxyefsuc6tal21gdmsogendwz1g2</sha1>
    </revision>
    <revision>
      <id>5076</id>
      <parentid>5075</parentid>
      <timestamp>2025-08-08T08:19:11Z</timestamp>
      <contributor>
        <username>Ayanda TS Mahlangu</username>
        <id>834</id>
      </contributor>
      <origin>5076</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="118" sha1="mgbm3k8gh2v7gr5kmxjr3khxnkmtt2y" xml:space="preserve">Ukuzithwala kulokha umuntu wengubo asidisi. Lokhu kwenzeka lokha umuntu wengubo ahlangene nomuntu wesilisa ngokomseme.</text>
      <sha1>mgbm3k8gh2v7gr5kmxjr3khxnkmtt2y</sha1>
    </revision>
    <revision>
      <id>5077</id>
      <parentid>5076</parentid>
      <timestamp>2025-08-08T08:27:49Z</timestamp>
      <contributor>
        <username>2003.Maureen</username>
        <id>839</id>
      </contributor>
      <origin>5077</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="310" sha1="njwnfyhzzeke8crittudxce8sisf6ft" xml:space="preserve">Ukuzithwala kulokha umuntu wengubo asidisi. Lokhu kwenzeka lokha umuntu wengubo ahlangene nomuntu wesilisa ngokomseme.ukuzthwala yiskhathi lapho umntwana akhula khona ngemathunjini womuntu wengubo.Kuthatha iimveke ezingaba -40,nofana iinyanga ezilithoba.Zihlukaniswe ngeengaba ezintathu ezibizwa nge-trimester.</text>
      <sha1>njwnfyhzzeke8crittudxce8sisf6ft</sha1>
    </revision>
    <revision>
      <id>5098</id>
      <parentid>5077</parentid>
      <timestamp>2025-08-08T09:40:03Z</timestamp>
      <contributor>
        <username>Mtsweni S</username>
        <id>835</id>
      </contributor>
      <origin>5098</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="449" sha1="h5lr53hp7danglg8rj89s34hv10u1gr" xml:space="preserve">Ukuzithwala kulokha umuntu wengubo asidisi. Lokhu kwenzeka lokha umuntu wengubo ahlangene nomuntu wembaji ngokomseme begodu singatjho bona ukuzithwala yisikhathi lapho umntwana akhula khona ngemathunjini womuntu wengubo.Kuthatha iimveke ezingaba -40,nofana iinyanga ezilithoba.Zihlukaniswe ngeengaba ezintathu ezibizwa nge-trimester. Umuntu wengubo nakazithweleko ubonakala ngamatshwayo athileko, isibonelo: ukuthulula, abanye batjhuguluka imizimba.</text>
      <sha1>h5lr53hp7danglg8rj89s34hv10u1gr</sha1>
    </revision>
  </page>
  <page>
    <title>Ukutlhoriswa kwabantu bengubo eSewula Africa</title>
    <ns>0</ns>
    <id>742</id>
    <revision>
      <id>5078</id>
      <timestamp>2025-08-08T08:31:34Z</timestamp>
      <contributor>
        <username>Ayanda TS Mahlangu</username>
        <id>834</id>
      </contributor>
      <comment>Created page with &quot;Ukutlhorisa ukuhlukumeza umuntu ngokwenyama, ngokomkhumbulo, kanye nangokommoya.&quot;</comment>
      <origin>5078</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="80" sha1="apci7wr0t76qnr8a0kp18y5zu8ke1zc" xml:space="preserve">Ukutlhorisa ukuhlukumeza umuntu ngokwenyama, ngokomkhumbulo, kanye nangokommoya.</text>
      <sha1>apci7wr0t76qnr8a0kp18y5zu8ke1zc</sha1>
    </revision>
  </page>
  <page>
    <title>Ukutlhoriswa kwabantu bengubo eSewula Afrika</title>
    <ns>0</ns>
    <id>743</id>
    <revision>
      <id>5081</id>
      <timestamp>2025-08-08T08:44:29Z</timestamp>
      <contributor>
        <username>Mpho F Mahlangu</username>
        <id>838</id>
      </contributor>
      <comment>Created page with &quot;Ukutlhorisa kuhlukumeza omunye umuntu, ukumenza aphatheke kumbi nofana kabahlungu. Kunemihlobo ehlukahlukeneko yokuhlukumezeka, ukuhlukumezeka ngokwenyama, ngokomkhumbulo, nangokommoya.&quot;</comment>
      <origin>5081</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="185" sha1="kyw9249ia4q2jfvcnn53s0k82x9cjfp" xml:space="preserve">Ukutlhorisa kuhlukumeza omunye umuntu, ukumenza aphatheke kumbi nofana kabahlungu. Kunemihlobo ehlukahlukeneko yokuhlukumezeka, ukuhlukumezeka ngokwenyama, ngokomkhumbulo, nangokommoya.</text>
      <sha1>kyw9249ia4q2jfvcnn53s0k82x9cjfp</sha1>
    </revision>
    <revision>
      <id>5083</id>
      <parentid>5081</parentid>
      <timestamp>2025-08-08T08:56:33Z</timestamp>
      <contributor>
        <username>Mpho F Mahlangu</username>
        <id>838</id>
      </contributor>
      <origin>5083</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="348" sha1="6hm0xfyaup7jk8h7mjf3t1hobniiwsj" xml:space="preserve">Ukutlhorisa kuhlukumeza omunye umuntu, ukumenza aphatheke kumbi nofana kabahlungu. Kunemihlobo ehlukahlukeneko yokuhlukumezeka, ukuhlukumezeka ngokwenyama, ngokomkhumbulo, nangokommoya. Ukuhlukumezeka ngokwenyama kufaka hlangana ukuzwisa umuntu ubuhlungu ngokumubetha. Ukuhlukumeza ngokumkhumbulo kufaka hlangana ukugandelela umuntu ngokomkhumbulo.</text>
      <sha1>6hm0xfyaup7jk8h7mjf3t1hobniiwsj</sha1>
    </revision>
    <revision>
      <id>5085</id>
      <parentid>5083</parentid>
      <timestamp>2025-08-08T09:02:03Z</timestamp>
      <contributor>
        <username>Ayanda TS Mahlangu</username>
        <id>834</id>
      </contributor>
      <origin>5085</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="503" sha1="qkk58mh75go1rhqcyu3ofe9bba1w0l8" xml:space="preserve">Ukutlhorisa kuhlukumeza omunye umuntu, ukumenza aphatheke kumbi nofana kabahlungu. Kunemihlobo ehlukahlukeneko yokuhlukumezeka, ukuhlukumezeka ngokwenyama, ngokomkhumbulo, nangokommoya. Ukuhlukumezeka ngokwenyama kufaka hlangana ukuzwisa umuntu ubuhlungu ngokumubetha. Ukuhlukumeza ngokumkhumbulo kufaka hlangana ukugandelela umuntu ngokomkhumbulo. Lokhu kwenzeka lokha umuntu angakavumeleki ukuba neemibono ngokuthile okwenza bona umuntu agcine sele angasazithimbi azizwe agadendelekile ngokomkhumbulo.</text>
      <sha1>qkk58mh75go1rhqcyu3ofe9bba1w0l8</sha1>
    </revision>
    <revision>
      <id>5087</id>
      <parentid>5085</parentid>
      <timestamp>2025-08-08T09:10:52Z</timestamp>
      <contributor>
        <username>Mpho F Mahlangu</username>
        <id>838</id>
      </contributor>
      <origin>5087</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="587" sha1="ndclsd4nsuazoejm0sz5bhjnrmufwak" xml:space="preserve">Ukutlhorisa kuhlukumeza omunye umuntu, ukumenza aphatheke kumbi nofana kabahlungu. Kunemihlobo ehlukahlukeneko yokuhlukumezeka, ukuhlukumezeka ngokwenyama, ngokomkhumbulo, ngokumseme, nangokommoya. Ukuhlukumezeka ngokwenyama kufaka hlangana ukuzwisa umuntu ubuhlungu ngokumubetha. Ukuhlukumeza ngokumkhumbulo kufaka hlangana ukugandelela umuntu ngokomkhumbulo. Lokhu kwenzeka lokha umuntu angakavumeleki ukuba neemibono ngokuthile okwenza bona umuntu agcine sele angasazithembi azizwe agadendelekile ngokomkhumbulo. Ukunyukubeza ngokomseme

Ukuhlukumezeka kwabantu bengubo eSewula Afrika</text>
      <sha1>ndclsd4nsuazoejm0sz5bhjnrmufwak</sha1>
    </revision>
    <revision>
      <id>5089</id>
      <parentid>5087</parentid>
      <timestamp>2025-08-08T09:22:40Z</timestamp>
      <contributor>
        <username>Mpho F Mahlangu</username>
        <id>838</id>
      </contributor>
      <origin>5089</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="636" sha1="hmqcc8lt0rajdteos3c5ege9bpm5p51" xml:space="preserve">Ukutlhorisa kuhlukumeza omunye umuntu, ukumenza aphatheke kumbi nofana kabahlungu. Kunemihlobo ehlukahlukeneko yokuhlukumezeka, ukuhlukumezeka ngokwenyama, ngokomkhumbulo, ngokumseme, nangokommoya. Ukuhlukumezeka ngokwenyama kufaka hlangana ukuzwisa umuntu ubuhlungu ngokumubetha. Ukuhlukumeza ngokumkhumbulo kufaka hlangana ukugandelela umuntu ngokomkhumbulo. Lokhu kwenzeka lokha umuntu angakavumeleki ukuba neemibono ngokuthile okwenza bona umuntu agcine sele angasazithembi azizwe agadendelekile ngokomkhumbulo. Ukunyukubeza ngokomseme

ISewula Afrika yinarha esesenamazinga aphezulu wokutlhoriswa kwabantu bengubo ephasini mazombe.</text>
      <sha1>hmqcc8lt0rajdteos3c5ege9bpm5p51</sha1>
    </revision>
    <revision>
      <id>5091</id>
      <parentid>5089</parentid>
      <timestamp>2025-08-08T09:26:55Z</timestamp>
      <contributor>
        <username>Ayanda TS Mahlangu</username>
        <id>834</id>
      </contributor>
      <origin>5091</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="540" sha1="lty50gf0zkyyzb4m8ft24pxunintqkt" xml:space="preserve">Ukutlhorisa kuhlukumeza omunye umuntu, ukumenza aphatheke kumbi nofana kabahlungu. Kunemihlobo ehlukahlukeneko yokuhlukumezeka, ukuhlukumezeka ngokwenyama, ngokomkhumbulo, ngokumseme, ngokommoya kunye nangokomseme. Ukutlhoriswa kwabantu bengubo eSewula Afriki kusezingeni eliphezulu begodu kubonakala likhuphuka nyaka nonyaka. Lokhu kungebanga lokobana ubunengi babantu bengubo abatkhoriswako, batlhoriswa ezandleni zabantu abatjhidelene nabo.

ISewula Afrika yinarha esesenamazinga aphezulu wokutlhoriswa kwabantu bengubo ephasini mazombe.</text>
      <sha1>lty50gf0zkyyzb4m8ft24pxunintqkt</sha1>
    </revision>
    <revision>
      <id>5095</id>
      <parentid>5091</parentid>
      <timestamp>2025-08-08T09:32:13Z</timestamp>
      <contributor>
        <username>Mpho F Mahlangu</username>
        <id>838</id>
      </contributor>
      <origin>5095</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="540" sha1="1zd61kpmm5cna5bgxg2ceadym9ec5ax" xml:space="preserve">Ukutlhorisa kuhlukumeza omunye umuntu, ukumenza aphatheke kumbi nofana kabahlungu. Kunemihlobo ehlukahlukeneko yokuhlukumezeka, ukuhlukumezeka ngokwenyama, ngokomkhumbulo, ngokumseme, ngokommoya kunye nangokomseme. Ukutlhoriswa kwabantu bengubo eSewula Afriki kusezingeni eliphezulu begodu kubonakala likhuphuka nyaka nonyaka. Lokhu kungebanga lokobana ubunengi babantu bengubo abatlhoriswako, batlhoriswa ezandleni zabantu abatjhidelene nabo.

ISewula Afrika yinarha esesenamazinga aphezulu wokutlhoriswa kwabantu bengubo ephasini mazombe.</text>
      <sha1>1zd61kpmm5cna5bgxg2ceadym9ec5ax</sha1>
    </revision>
    <revision>
      <id>5100</id>
      <parentid>5095</parentid>
      <timestamp>2025-08-08T09:40:09Z</timestamp>
      <contributor>
        <username>Ayanda TS Mahlangu</username>
        <id>834</id>
      </contributor>
      <origin>5100</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="763" sha1="nvq8lyo3gtmzg5y97y03d20gqg8x9en" xml:space="preserve">Ukutlhorisa kuhlukumeza omunye umuntu, ukumenza aphatheke kumbi nofana kabahlungu. Kunemihlobo ehlukahlukeneko yokuhlukumezeka, ukuhlukumezeka ngokwenyama, ngokomkhumbulo, ngokumseme, ngokommoya kunye nangokomseme. Ukutlhoriswa kwabantu bengubo eSewula Afriki kusezingeni eliphezulu begodu kubonakala likhuphuka nyaka nonyaka. Lokhu kungebanga lokobana ubunengi babantu bengubo abatlhoriswako, batlhoriswa ezandleni zabantu abatjhidelene nabo.

Abantu bengubo bahlukumezeka ngeendlela ezinengi enarhe yeSewula Africa, njengokutlhoriswa ngokwenyama. Lokhu kutlhoriswa okujayelekile kileli, ekwenzeka khulu khulu hlangana nabantu abaziinthandani. Namhlanje sikhamba phezu kwabantu abanengi bengubo abakhambe emhlabeni babulawa babantu ababathandako ngokubatlhorisa.</text>
      <sha1>nvq8lyo3gtmzg5y97y03d20gqg8x9en</sha1>
    </revision>
  </page>
  <page>
    <title>Ukuthunjwa nokubulawa kwabentazana eSewula Afrika</title>
    <ns>0</ns>
    <id>744</id>
    <revision>
      <id>5092</id>
      <timestamp>2025-08-08T09:27:07Z</timestamp>
      <contributor>
        <username>2003.Maureen</username>
        <id>839</id>
      </contributor>
      <comment>ukubhala amaqala wokbulala nge Sindebele</comment>
      <origin>5092</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1087" sha1="cq5vleyhuthe4zt6w9r4cuqf2f5x8b3" xml:space="preserve">Ukubulawa kwabantu besifazane kuyinto esele Ibhebhetheka ngokweqileko enarheni le.Enyakeni lo uwodwa sele kubulewe abantu abanengi kwamambala iikakhulukazi abezwana nabo.Umntazinyana u Olerato Mongale egade aneminyaka ematjhumi amathathu obekafunda eRHODES UNIVERSITY,watholakala abulewe ngemva kokobana ahlangane nomuntu eenkundleni zokuthintana.Kuthiwa umuntu lo wazenza ngathi ufuna ukumkhipha ayomdlisa isidlo sebsuku kanti uze ngokumbi ngokobana ambululale.Nontobeko Cele ebekaneminyaka ematjhumi amabili nahlanu yena ubulawe ngeshlungu mumuntu obekahlekisana naye uSibusiso Lawrence.Okubhlungu kukobana wathi nakambulalako wenza umgadangiso.Kuthiwa amapholisa amthola alenge emthini eduze nalapho enze khona isenzo lezi .Lokhu kwenzeka e Kwazulu Natal.Ku Rhoboyi woyaka lo ePitori kusolwa bonyana kunombulali okhamba athumba bekabulale abafazi.Kuthiwa bahlanu abentazana abatholakele babulawe ngendlela efanako batholakele baphuthelwe nge tjhegasi ,batjhisiwe begodu abanye babo bagujelwe eduze ne Tshwane,basukela eminyakeni ematjhumi amabili ukuya kewamatjhumi amathathu nahlanu.</text>
      <sha1>cq5vleyhuthe4zt6w9r4cuqf2f5x8b3</sha1>
    </revision>
    <revision>
      <id>5099</id>
      <parentid>5092</parentid>
      <timestamp>2025-08-08T09:40:04Z</timestamp>
      <contributor>
        <username>2003.Maureen</username>
        <id>839</id>
      </contributor>
      <origin>5099</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1116" sha1="ggrcbd2kuve5439kptdxs7pm97yc6xa" xml:space="preserve">Ukubulawa kwabantu besifazane kuyinto esele Ibhebhetheka ngokweqileko enarheni le.Enyakeni lo uwodwa sele kubulewe abantu abanengi kwamambala iikakhulukazi abezwana nabo 


Umntazinyana u Olerato Mongale egade aneminyaka ematjhumi amathathu obekafunda eRHODES UNIVERSITY,watholakala abulewe ngemva kokobana ahlangane nomuntu eenkundleni zokuthintana.Kuthiwa umuntu lo wazenza ngathi ufuna ukumkhipha ayomdlisa isidlo sebsuku kanti uze ngokumbi ngokobana ambululale.Nontobeko Cele ebekaneminyaka ematjhumi amabili nahlanu yena ubulawe ngeshlungu mumuntu obekahlekisana naye uSibusiso Lawrence.Okubhlungu kukobana wathi nakambulalako wenza umgadangiso.Kuthiwa amapholisa amthola alenge emthini eduze nalapho enze khona isenzo lezi .Lokhu kwenzeka e Kwazulu Natal.Ku Rhoboyi woyaka lo ePitori kusolwa bonyana kunombulali okhamba athumba bekabulale abafazi.Kuthiwa bahlanu abentazana abatholakele babulawe ngendlela efanako batholakele baphuthelwe nge tjhegasi ,batjhisiwe begodu abanye babo bagujelwe eduze ne Tshwane,basukela eminyakeni ematjhumi amabili ukuya kewamatjhumi amathathu nahlanu.

Ekhotho ye Pitor bagwebe</text>
      <sha1>ggrcbd2kuve5439kptdxs7pm97yc6xa</sha1>
    </revision>
  </page>
  <page>
    <title>Ubuntazana</title>
    <ns>0</ns>
    <id>745</id>
    <revision>
      <id>5103</id>
      <timestamp>2025-08-08T10:01:56Z</timestamp>
      <contributor>
        <username>Nqobile P Mahlangu</username>
        <id>840</id>
      </contributor>
      <comment>Created page with &quot;Ubuntazana ngokwesiko butjho ubujamo bokungakaze uhlanganyele ngokomseme. Ukuqakatheka kwako kuyahluka ngokuya kwam asiko, iinkolo kanye neenkathi. ngokomlando, ubuntazana nofana ubuntombi khulukhulu besifazana bukhambelana nokuzihlonipha nokukuhlanzeka. ngokuya ngo (Gottlieb,2004), eemphakathini eminengi yakade, bekuyimfuneko yomtjhado nokuba semthethweni komndeni.   Ngokomoya, ubuntazana buvame ukubonwa njengetshwayo lokuhlanzeka nokuzinikela ku Krestu. Ukuhlonipha oku...&quot;</comment>
      <origin>5103</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="893" sha1="fs3gcsj2g61f8p756adqef5nzmezkkp" xml:space="preserve">Ubuntazana ngokwesiko butjho ubujamo bokungakaze uhlanganyele ngokomseme. Ukuqakatheka kwako kuyahluka ngokuya kwam asiko, iinkolo kanye neenkathi. ngokomlando, ubuntazana nofana ubuntombi khulukhulu besifazana bukhambelana nokuzihlonipha nokukuhlanzeka. ngokuya ngo (Gottlieb,2004), eemphakathini eminengi yakade, bekuyimfuneko yomtjhado nokuba semthethweni komndeni. 

Ngokomoya, ubuntazana buvame ukubonwa njengetshwayo lokuhlanzeka nokuzinikela ku Krestu. Ukuhlonipha okufanako kutholakala ekoweni yamaHindu yama bhuda, lapho ukungatjhadi kuthathwa njengendlela eya ekukhanyeni.

Ukuzigcina kungakusiza ngendlela ezinengi njengokuzivimbela ukuthola ama STI, ukukhulelwa ngokungakahleleki, kakhulukazi ebantwaneni. Ubuntazana kungahlotjaniswa nokulungela ngokomkhumbulo ngokomkhumbulo nokuphila luhle ngokwngqondo. 

Esikhathini esizako, umnqondo wobuntazana ungaba womuntu yedwa,(mathupha)</text>
      <sha1>fs3gcsj2g61f8p756adqef5nzmezkkp</sha1>
    </revision>
  </page>
  <page>
    <title>Sfiso Ncwane</title>
    <ns>0</ns>
    <id>746</id>
    <revision>
      <id>5105</id>
      <timestamp>2025-08-08T10:40:06Z</timestamp>
      <contributor>
        <username>Nqobile P Mahlangu</username>
        <id>840</id>
      </contributor>
      <comment>Created page with &quot;             USfiso Ncwane wabelethwa ngomhlaka 1979-ku Sihlabantdangana ngelanga ama-21 wabhubha ngo Nobayeni mhlana amalanga ama-5 ngo- 2016. Ubegade acula nge Sewula afrika.  wahlanganyela ne Mlazi based band ebizwa nge new edition, Ngokuhlanganyela u Ntombifuthi no skhumbuzo Gumee lo ebegade abetha iingubhu. U Ncwane waphandinda enye iband ebizwa ngokobana yi &quot; one touch&quot; no Mr Joe  gcabashe , sikhona Gumede no Senzao sabela.&quot;</comment>
      <origin>5105</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="433" sha1="i8mq7zcwhnmszrum8xq6jch4qf41i7q" xml:space="preserve">            
USfiso Ncwane wabelethwa ngomhlaka 1979-ku Sihlabantdangana ngelanga ama-21 wabhubha ngo Nobayeni mhlana amalanga ama-5 ngo- 2016. Ubegade acula nge Sewula afrika.  wahlanganyela ne Mlazi based band ebizwa nge new edition, Ngokuhlanganyela u Ntombifuthi no skhumbuzo Gumee lo ebegade abetha iingubhu. U Ncwane waphandinda enye iband ebizwa ngokobana yi &quot; one touch&quot; no Mr Joe  gcabashe , sikhona Gumede no Senzao sabela.</text>
      <sha1>i8mq7zcwhnmszrum8xq6jch4qf41i7q</sha1>
    </revision>
  </page>
  <page>
    <title>Wp/nr/Winnie Mandela</title>
    <ns>0</ns>
    <id>747</id>
    <revision>
      <id>5106</id>
      <timestamp>2025-08-08T11:06:30Z</timestamp>
      <contributor>
        <username>Ayanda TS Mahlangu</username>
        <id>834</id>
      </contributor>
      <comment>Created page with &quot;Nomzamo  Winifred Zanyiwe Madikizela-Mandela OLS MP ( wabelethwa mahlana amalanga ama26 kuSeptember 1936- 2 April 2018),  owaziwa ngo Winnie Mandela, waye ngusopolitiki weSewula Afrika, anti-apartheid activist begodu angukosikazi wesibili ka Nelson Mandela.Ngesikhathi sakhe sepolotiki wayesebenza njengelungu lePalamende ukusukela ngomyaka we-1994 ukuyokyfika enyakeni ka-2003, wasebenza godu  ukusuka ngomnyaka we-2009 ukufikela bewahlongakala, wayelisekala likaNqonqoshe w...&quot;</comment>
      <origin>5106</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1360" sha1="nedvrlpjw2150bld9n6tjjw96jlqpf3" xml:space="preserve">Nomzamo  Winifred Zanyiwe Madikizela-Mandela OLS MP ( wabelethwa mahlana amalanga ama26 kuSeptember 1936- 2 April 2018),  owaziwa ngo Winnie Mandela, waye ngusopolitiki weSewula Afrika, anti-apartheid activist begodu angukosikazi wesibili ka Nelson Mandela.Ngesikhathi sakhe sepolotiki wayesebenza njengelungu lePalamende ukusukela ngomyaka we-1994 ukuyokyfika enyakeni ka-2003, wasebenza godu  ukusuka ngomnyaka we-2009 ukufikela bewahlongakala, wayelisekala likaNqonqoshe we Arts and Culture ukusukela ngomnyaka we-1994 ukufikela enyakeni we-1996. Ubegade alilungu le African National Congress (ANC) lapho ebekasebenza ku National Executive Committee ye-ANC bewahola ne-Women's League. Abalandeli baka Madikizela-Mandela babemazi njengo &quot;Mma wesitjhaba&quot;.

Wabelethelwa ebukhosini bamaXhosa eBizana, amthlogomeli, atjhade noNelson Mandela eJohennesburg ngomnyaka wee-1958; baqeda iminyaka ema-38 emtjhadweni wabo, baba nabentwana ababili. Ngo-1983, ngemva kokubotjhwa kwakaMandela ngokulandela i-Rivonia Trail, waba bubuso bakhe emphathini eminyakeni ema-27 ayiqeda ejele.Ngaleso sikhathi, waduma khulu emphakathini womzabalazo. UMadikizela Mandele wavinjezelwa yi-aphartheid state security services eentweni ezinengi, wahlukunyezwa, wagandelelwa ngemithetho evimbako, bewaqotjhwa emadorobhedini wamaplasi bewahlala iinyanga eziimbalwa e-Solitary Confinement.</text>
      <sha1>nedvrlpjw2150bld9n6tjjw96jlqpf3</sha1>
    </revision>
  </page>
  <page>
    <title>Wp/nr/Nelson Mandela</title>
    <ns>0</ns>
    <id>748</id>
    <revision>
      <id>5107</id>
      <timestamp>2025-08-08T11:10:30Z</timestamp>
      <contributor>
        <username>Umenathi</username>
        <id>837</id>
      </contributor>
      <comment>Created page with &quot;Mandela wabelethwa ngomhlaka 18 kuVelabahlinze 1918, esgodini seMvezo ngendaweni ebizwa ngokuthi yiMtata, eEastern Cape. Wanikelwa igama likaRolihlahla, igama lesiXhosa elitjho ukuthi &quot;troublemaker&quot; kwathi emnyakeni elandelawo wathoma ukwaziwa ngesithakazelo sakhe, uMadiba. Ukhokhomkhulu wakhe wehlangothini lika yise, uNgubengcuka wayemdosiphambili wesizwe siThembu eTranskeian kwiphrovinsi yeEastern Cape. Omunye wamadodana kaNgubengcuka, ibizo lakhe ekungu Mandela, umkhu...&quot;</comment>
      <origin>5107</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1279" sha1="0dp1ts6mk17vtueejczllesz67uqpca" xml:space="preserve">Mandela wabelethwa ngomhlaka 18 kuVelabahlinze 1918, esgodini seMvezo ngendaweni ebizwa ngokuthi yiMtata, eEastern Cape. Wanikelwa igama likaRolihlahla, igama lesiXhosa elitjho ukuthi &quot;troublemaker&quot; kwathi emnyakeni elandelawo wathoma ukwaziwa ngesithakazelo sakhe, uMadiba. Ukhokhomkhulu wakhe wehlangothini lika yise, uNgubengcuka wayemdosiphambili wesizwe siThembu eTranskeian kwiphrovinsi yeEastern Cape. Omunye wamadodana kaNgubengcuka, ibizo lakhe ekungu Mandela, umkhulu kaNelson, ekunguye ebamthiyelela ngaye. Ngebanga lokobana uMandela wayebelethwa ngendlini yomfazi obuya esitjhabeni seIxhiba, kwenza bona angarhoni ukuba yikosana elandelako.

Ubaba kanelson Mandela, uGadla Henry Mphakanyiswa Mandela, wayeyikosana, wabekwaesihlalweni ngomyaka ka1915, ngemva kokuthi umkhandlo wakhe wakhe uthweswe ngomlandu wokukhwabanisa, uthweswa mkhandlu wabantu abamhlophe. Ngo1926, uGadla waqotjhwa emsebenzini ngonobangela wokukhwabanisa, kodwana uNelson bamtjela ukuthi uyise bamqothele ukujamela amalungelo nobulungiswa emkhandlwini. UGadla wayenesithembu, abafazi abane, amadodana amane kanye namadodakazi alithoba, ebebahlala endaweni ezihlukileko. Unina kaNelson wayemfazi wesithathu, uNosekeni Fanny, indodakazi kaNkedama wendlu yangesidleni, ilunga lesitjhaba samaMpemvu.</text>
      <sha1>0dp1ts6mk17vtueejczllesz67uqpca</sha1>
    </revision>
    <revision>
      <id>5414</id>
      <parentid>5107</parentid>
      <timestamp>2025-09-03T20:56:55Z</timestamp>
      <contributor>
        <username>F.K MAHLANGU</username>
        <id>891</id>
      </contributor>
      <minor />
      <comment>added references and a picture of Nelson Mandela.</comment>
      <origin>5414</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1913" sha1="6chdq6gcko39eaxip19b8t49ks8gl0t" xml:space="preserve">[[Isimumathi:Nelson Mandela 1994.jpg|thumb|345x345px|&lt;ref&gt;[https://upload.wikimedia.org/wikipedia/commons/0/02/Nelson_Mandela_1994.jpg Nelson_Mandela_1994.jpg (1500×1940)]&lt;/ref&gt;Nelson Mandela]]
Mandela wabelethwa ngomhlaka 18 kuVelabahlinze 1918, esgodini seMvezo ngendaweni ebizwa ngokuthi yiMtata, eEastern Cape

&lt;ref&gt;Mandela, N. (1994). ''Long Walk to Freedom: The Autobiography of Nelson Mandela''. Boston: Little, Brown and Company.&lt;/ref&gt;. Wanikelwa igama likaRolihlahla, igama lesiXhosa elitjho ukuthi &quot;troublemaker&quot;&lt;ref&gt;Lodge, T. (2006). ''Mandela: A Critical Life''. Oxford: Oxford University Press.&lt;/ref&gt; kwathi emnyakeni elandelako wathoma ukwaziwa ngesithakazelo sakhe, uMadiba. Ukhokhomkhulu wakhe wehlangothini lika yise, uNgubengcuka wayemdosiphambili wesizwe siThembu eTranskeian kwiphrovinsi yeEastern Cape&lt;ref&gt;Meredith, M. (2010). ''Mandela: A Biography''. New York: PublicAffairs.&lt;/ref&gt;. Omunye wamadodana kaNgubengcuka, ibizo lakhe ekungu Mandela, umkhulu kaNelson, ekunguye ebamthiyelela ngaye. Ngebanga lokobana uMandela wayebelethwa ngendlini yomfazi obuya esitjhabeni seIxhiba, kwenza bona angarhoni ukuba yikosana elandelako.

Ubaba kanelson Mandela, uGadla Henry Mphakanyiswa Mandela, wayeyikosana, wabekwaesihlalweni ngomyaka ka1915, ngemva kokuthi umkhandlo wakhe wakhe uthweswe ngomlandu wokukhwabanisa, uthweswa mkhandlu wabantu abamhlophe&lt;ref&gt;Sampson, A. (1999). ''Mandela: The Authorized Biography''. London: HarperCollins.&lt;/ref&gt;. Ngo1926, uGadla waqotjhwa emsebenzini ngonobangela wokukhwabanisa, kodwana uNelson bamtjela ukuthi uyise bamqothele ukujamela amalungelo nobulungiswa emkhandlwini. UGadla wayenesithembu, abafazi abane, amadodana amane kanye namadodakazi alithoba, ebebahlala endaweni ezihlukileko. Unina kaNelson wayemfazi wesithathu, uNosekeni Fanny, indodakazi kaNkedama wendlu yangesidleni, ilunga lesitjhaba samaMpemvu.

=== Irherho lemithombo. ===
&lt;references /&gt;</text>
      <sha1>6chdq6gcko39eaxip19b8t49ks8gl0t</sha1>
    </revision>
  </page>
  <page>
    <title>Miriam Makeba</title>
    <ns>0</ns>
    <id>749</id>
    <revision>
      <id>5108</id>
      <timestamp>2025-08-08T11:12:25Z</timestamp>
      <contributor>
        <username>Mpho F Mahlangu</username>
        <id>838</id>
      </contributor>
      <comment>Created page with &quot; UZenzile Miriam Makeba (4 Ntaka 1932- 9 Sinyikhaba 2008), ogade aziwa ngelaka Mama Afrika, bekamvumi weSewula Afrika, umbhali weengoma, umlingisi nomlweli wezamalungela wabantu. Kwezomvumo bekazibandakanye imihlobeni ye-Afropop, jazz, and world music, bekamjameli ujamele ukugandeleleka kwabantu abanzima nombuso wabantu abanzima eSewula Afrika.  Wabelethelwa eJohanesburg, umbelethi wakhe omunye bekamSwati omunye amuXhosa, uMakeba wakateleleka borna ayokufuna umsebenzi as...&quot;</comment>
      <origin>5108</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="963" sha1="ssp66f13lztynvok07qy5cu5e3u4624" xml:space="preserve">
UZenzile Miriam Makeba (4 Ntaka 1932- 9 Sinyikhaba 2008), ogade aziwa ngelaka Mama Afrika, bekamvumi weSewula Afrika, umbhali weengoma, umlingisi nomlweli wezamalungela wabantu. Kwezomvumo bekazibandakanye imihlobeni ye-Afropop, jazz, and world music, bekamjameli ujamele ukugandeleleka kwabantu abanzima nombuso wabantu abanzima eSewula Afrika.

Wabelethelwa eJohanesburg, umbelethi wakhe omunye bekamSwati omunye amuXhosa, uMakeba wakateleleka borna ayokufuna umsebenzi asesemcani ngemuva kokuhlongakala kukayise. Waba nemshoda weskhatjhana nobegade ahlukumezeka kiwo aneminyaka eli-17, wathola umntwanakhe wokuthoma ngomnyaka we-1950, wahlula nesifo sekankere yamabele. Ikghono lakhe kwezomvumo lavela asesemntwana, waba ngusaziwayo ngo-1950, wahlanganyela nesiqhema se-The Cuban brothers, Manhattan brothers, an all women group, the skylarks,bebadlala imihlobohlobo ye-jazz, traditionala African melodies, neminye imihlobo yezomvumo edumileko yangaphetjheya.</text>
      <sha1>ssp66f13lztynvok07qy5cu5e3u4624</sha1>
    </revision>
  </page>
  <page>
    <title>Mr JazziQ</title>
    <ns>0</ns>
    <id>750</id>
    <revision>
      <id>5109</id>
      <timestamp>2025-08-08T11:12:46Z</timestamp>
      <contributor>
        <username>Willson2001</username>
        <id>841</id>
      </contributor>
      <comment>Bhuda TW(2025)</comment>
      <origin>5109</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1309" sha1="hj2wocfyv0lnba89rf3al57r0x0lwwr" xml:space="preserve">'''UTumelo Manyoni''' owaziwa ngokuthi ngu-Mr Jazziq, ungusonkunupe wama-Piano enarheni yeSewula Afrika, begodu nomkhiqizi wamarekhodi. Waziwa khulu ngebanga lokobana ulilunga lr iJazzi disciplines.&lt;ref name=&quot;:0&quot;&gt;Bhuda, TW(2025)&lt;/ref&gt;

== Early life and education ==
UTumelo Manyoni wabelethwa mhlana amalanga amathathu kuNtaka ngomnyaka we-1995, wabelethwa begodu wakhuliswa endaweni eyaziwa ngokobana yiAlexandra, ukhuliswe ngugogo wakhe ngesikhathi ababelethi bakhe bahlala etlhagwini yeJwanasbhege. Wafunda eHighlands North Boy's High School. Ukuvezwa kwakhe njengomvumi ekuthomeni ngokusebenzisa ukuduma komndeni, okufaka hlangana ukubamamathe nelimi kwakayise, umalume wakhe kanye nabavumi abafana njengo Oskido, Black Coffe, kwavusa ikareko yakhe ekorweni yezomvumi.&lt;ref name=&quot;:0&quot; /&gt;

Ikhambo lakhe lomvumo lathoma ngokuthi uyise kanye nomalume wakhe bazibandakanye emkhakheni womvumo, koke lokhu kwamenza bona akhiphe amehlo enyameni begodu ahlangane nabanye abavumi abadumileko enarheni mazombe, koke lokhu kwamkhuthaza bona abenekareko ekuvumeni. Wathi nakahlanganisa iminyaka elitjhumi nane besele angusonkunupe, kwathi lokha nakaneminyaka elitjhumi nesithandathu wathoma ukukhiqiza umvumo wasebenzisana noJosiah De Discipline ukwakha ubudlelwano JazziDisciples ngomnyaka wee-2017.&lt;ref name=&quot;:0&quot; /&gt;</text>
      <sha1>hj2wocfyv0lnba89rf3al57r0x0lwwr</sha1>
    </revision>
  </page>
  <page>
    <title>Charles II of England</title>
    <ns>0</ns>
    <id>751</id>
    <revision>
      <id>5110</id>
      <timestamp>2025-08-08T11:12:46Z</timestamp>
      <contributor>
        <username>2003.Maureen</username>
        <id>839</id>
      </contributor>
      <comment>Created page with &quot;Challie wesibili mntwana omdala wekosi u Charlse wokuthoma okunguye yedwa oseleko enarheni ye Scotland,Ireland ne Henrietta Maria of France. AfNgemva kukuphumala kuka charles wokuthoma ngonyaka ka-30 January 1649,Ngesikhathi sepi wabantu abamhlophe ekuyi British civil war,ipalamende ye Scotsland ibeke u Charles ikosi yesibili ngomhlaka 5 February 1649,kodwana, England yangena e skathini esiyi interregnum.yabuya yaphathwa ngu  Cromwell owahlula u Charles II epini Worceste...&quot;</comment>
      <origin>5110</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="497" sha1="1o3aa1h4jdq62lfvlpkho1rd1u3he4a" xml:space="preserve">Challie wesibili mntwana omdala wekosi u Charlse wokuthoma okunguye yedwa oseleko enarheni ye Scotland,Ireland ne Henrietta Maria of France. AfNgemva kukuphumala kuka charles wokuthoma ngonyaka ka-30 January 1649,Ngesikhathi sepi wabantu abamhlophe ekuyi British civil war,ipalamende ye Scotsland ibeke u Charles ikosi yesibili ngomhlaka 5 February 1649,kodwana, England yangena e skathini esiyi interregnum.yabuya yaphathwa ngu  Cromwell owahlula u Charles II epini Worcester on 3 September 1651,</text>
      <sha1>1o3aa1h4jdq62lfvlpkho1rd1u3he4a</sha1>
    </revision>
    <revision>
      <id>6622</id>
      <parentid>5110</parentid>
      <timestamp>2026-05-19T07:47:40Z</timestamp>
      <contributor>
        <username>Kwamikagami</username>
        <id>1412</id>
      </contributor>
      <minor />
      <origin>6622</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="500" sha1="du2c2mjceg96qwp5y9ii6f1hh5oov7z" xml:space="preserve">Challie wesibili mntwana omdala wekosi u Charlse wokuthoma okunguye yedwa oseleko enarheni ye Scotland, Ireland ne Henrietta Maria of France. AfNgemva kukuphumala kuka charles wokuthoma ngonyaka ka-30 January 1649, Ngesikhathi sepi wabantu abamhlophe ekuyi British civil war, ipalamende ye Scotsland ibeke u Charles ikosi yesibili ngomhlaka 5 February 1649,kodwana, England yangena e skathini esiyi interregnum. Yabuya yaphathwa ngu Cromwell owahlula u Charles II epini Worcester on 3 September 1651.</text>
      <sha1>du2c2mjceg96qwp5y9ii6f1hh5oov7z</sha1>
    </revision>
    <revision>
      <id>6623</id>
      <parentid>6622</parentid>
      <timestamp>2026-05-19T07:48:42Z</timestamp>
      <contributor>
        <username>Kwamikagami</username>
        <id>1412</id>
      </contributor>
      <minor />
      <comment>Kwamikagami moved page [[Charles I of England]] to [[Charles II of England]]: wrong topic</comment>
      <origin>6622</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="500" sha1="du2c2mjceg96qwp5y9ii6f1hh5oov7z" xml:space="preserve">Challie wesibili mntwana omdala wekosi u Charlse wokuthoma okunguye yedwa oseleko enarheni ye Scotland, Ireland ne Henrietta Maria of France. AfNgemva kukuphumala kuka charles wokuthoma ngonyaka ka-30 January 1649, Ngesikhathi sepi wabantu abamhlophe ekuyi British civil war, ipalamende ye Scotsland ibeke u Charles ikosi yesibili ngomhlaka 5 February 1649,kodwana, England yangena e skathini esiyi interregnum. Yabuya yaphathwa ngu Cromwell owahlula u Charles II epini Worcester on 3 September 1651.</text>
      <sha1>du2c2mjceg96qwp5y9ii6f1hh5oov7z</sha1>
    </revision>
  </page>
  <page>
    <title>Cassper Nyovest</title>
    <ns>0</ns>
    <id>752</id>
    <revision>
      <id>5111</id>
      <timestamp>2025-08-08T11:13:20Z</timestamp>
      <contributor>
        <username>Tjhudu Khanyi</username>
        <id>836</id>
      </contributor>
      <comment>Created page with &quot;  URefiloe Maela Phoolo (wabelethwa mhla amalanga ali-16 kuNobayeni 1990), owaziwa ngoCasper Nyovest, mvumi weSewula Afrika, mtloli womvumo, usomabhizinisi, umkhiqizi womvumo kanye nosomaguduva. Wabelethelwa begodu bewakhulela eMahikeng, eTjingalanga Kapa, uthathwa njengomunye wabavumi abaphumeleleko eSewula Afrika. Ngomnyaka ka-2014 wasungula umgadangiso womvumo iFamily Tree Records. uNyovest waduma ngokukhutjhwa kwe- albhamu i- Tsholofelo (2014) eyakhiqiza iimvumo edum...&quot;</comment>
      <origin>5111</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1363" sha1="pcychxcid8owsbdsl2si8i94n7jihhi" xml:space="preserve">

URefiloe Maela Phoolo (wabelethwa mhla amalanga ali-16 kuNobayeni 1990), owaziwa ngoCasper Nyovest, mvumi weSewula Afrika, mtloli womvumo, usomabhizinisi, umkhiqizi womvumo kanye nosomaguduva. Wabelethelwa begodu bewakhulela eMahikeng, eTjingalanga Kapa, uthathwa njengomunye wabavumi abaphumeleleko eSewula Afrika. Ngomnyaka ka-2014 wasungula umgadangiso womvumo iFamily Tree Records. uNyovest waduma ngokukhutjhwa kwe- albhamu i- Tsholofelo (2014) eyakhiqiza iimvumo edumileko ezithi &quot;Gusheshe&quot; kanye ne &quot;Doc Shebeleza&quot;

Ngepumelelo yakhe yokuthengisa amathikithi wekhonsethi yakhe, iFill Up the Dome (2015) ebeyibanjwe eTicketpro Dome eJohannesburg. Ipumelelo yomnyanya lo yalandelela uNyovest nge &quot;Fill Up&quot; ukukhuthaza amakhonsethi eenkundleni ezihlukahlukeneko qobe mnyaka, kufaka hlangana iOrlando Stadium (2016) kanye neFNB Stadium (2017), kanye eJohannesburg, Moses Mabhida Stadium (2018) eDurban, kanye neRoyal Bafokeng Stadium eNorth West. 

UNyovest wakhupha i-albhamu enebizo elifana nelakhe, iRefiloe, eyakhitjhwa mhlazi 31 kuSewula 2025, kukhonsethi yakhe eFill Up The Dome. I-albhamu le isebenzisana nabavumu abanengi abafakanga hlangana no The Game, DJ Drama, Stonebwoy kanye noCasey Veggies. Walandela ipumelelo le nge-albhamu yakhe yesithathu eyadunyiswa khulu i-Thuto (2018), kanye ne-albhamu yakhe yesine ye-Kwaito, i-Sweet and Short (2019).</text>
      <sha1>pcychxcid8owsbdsl2si8i94n7jihhi</sha1>
    </revision>
  </page>
  <page>
    <title>Wp/nr/Thuso Mbedu</title>
    <ns>0</ns>
    <id>753</id>
    <revision>
      <id>5112</id>
      <timestamp>2025-08-08T11:16:04Z</timestamp>
      <contributor>
        <username>Mtsweni S</username>
        <id>835</id>
      </contributor>
      <comment>Created page with &quot;U-Thuso Nokwanda Mbedu (owabelethwa mhla amalanga abunane ku-Velabahlinze ngonyaka we-1991) ungomunye wabadlali bakumabonwakude be-Sewula Afrika. Waduma khulu ngendima ayidlalako emdlalweni we-Sewula Afrika wabantu abatjha obizwa ngokobana yi-Sthunzi, lapho akhethwa khona ngokulandelana ukuthi athathe unongorwana wangaphetjheya obizwa nge- International Emmy ngonyaka wee-2017 kanye no-2018. U-Mbedu ekukhambeni kwesikhathi wavela ehlanganweni ebizwa ngokuthi yi- Forbes Af...&quot;</comment>
      <origin>5112</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2157" sha1="h3dhic88l69sl3a69sh114hgdarxrlt" xml:space="preserve">U-Thuso Nokwanda Mbedu (owabelethwa mhla amalanga abunane ku-Velabahlinze ngonyaka we-1991) ungomunye wabadlali bakumabonwakude be-Sewula Afrika. Waduma khulu ngendima ayidlalako emdlalweni we-Sewula Afrika wabantu abatjha obizwa ngokobana yi-Sthunzi, lapho akhethwa khona ngokulandelana ukuthi athathe unongorwana wangaphetjheya obizwa nge- International Emmy ngonyaka wee-2017 kanye no-2018. U-Mbedu ekukhambeni kwesikhathi wavela ehlanganweni ebizwa ngokuthi yi- Forbes Africa 30 ngaphasi kwabantu abangaphasi kweminyaka ematjhumi amathathu ubudala ngonyaka wee-2018.&lt;ref name=&quot;:0&quot;&gt;Mtsweni S&lt;/ref&gt;

Ngonyaka wee-2021, wadlala ehlelweni elibizwa nge-Underground Railroad elitholakala kuAmazon Video, lapho kunamahlelo amanengi nekungilo elamenza bona abemdlali wokuthoma we-Sewula Afrika okhamba phambili kwezamahlelo adlala kumabonwakude we-America. Lokhu kwamenza bona athumbe unongorwana obizwa bona yi-Independent Spirit Award etholwa mumuntu wengubo okhamba phambili ngokuba mdlali wakumabonwakude ehlelweni elitjha. Waragela phambili waba ngomunye wabalingisi ehlelweni elimlando wangaphetjheya e-America obizwa ngokobana yi- The Woman King( 2022) lapho adlala khona iskhundla saka Nawi.&lt;ref name=&quot;:0&quot; /&gt;

== Early life and education ==
Ipilo yakhe nefundo

U-Mbedu wabelethelwa eMidlands Medical Centre endaweni ye-Pietermaritzburg, KwaZulu-Natal. Ubelethwa ngumma okhuluma isiZulu kanye noyise okhuluma isiSotho nesiXhosa. Wakhuliswa e-Pelham ngugogo wakhe , owabamumuntu omtlhogomelako ngemva kokuhlongakalelwa babelethi bakhe bobabili asesemncani.&lt;ref name=&quot;:0&quot; /&gt;

Mbedu attended Pelham Primary School and then Pietermaritzburg Girls' High School. She went on to study Physical Theatre and Performing Arts Management at the University of the Witwatersrand (Wits), graduating in 2013 with honours, after also having taken a course at the Stella Adler Studio of Acting in New York City in 2012.&lt;ref name=&quot;:0&quot; /&gt;

U-Mbedu wafunda esikolweni esibizwa nge-Pelham Primary School, waragela phambili emabangeni aphezulu e-Pietermaritzburg Girls' High School. Waragela phambili emazingeni aphezulu e-University ye Witwatersrand( Wits), &lt;ref name=&quot;:0&quot; /&gt;</text>
      <sha1>h3dhic88l69sl3a69sh114hgdarxrlt</sha1>
    </revision>
    <revision>
      <id>5117</id>
      <parentid>5112</parentid>
      <timestamp>2025-08-08T11:25:27Z</timestamp>
      <contributor>
        <username>Mtsweni S</username>
        <id>835</id>
      </contributor>
      <origin>5117</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1784" sha1="90zcltgcak21a6ih49hg55z99ss68bf" xml:space="preserve">U-Thuso Nokwanda Mbedu (owabelethwa mhla amalanga abunane ku-Velabahlinze ngonyaka we-1991) ungomunye wabadlali bakumabonwakude be-Sewula Afrika. Waduma khulu ngendima ayidlalako emdlalweni we-Sewula Afrika wabantu abatjha obizwa ngokobana yi-Sthunzi, lapho akhethwa khona ngokulandelana ukuthi athathe unongorwana wangaphetjheya obizwa nge- International Emmy ngonyaka wee-2017 kanye no-2018. U-Mbedu ekukhambeni kwesikhathi wavela ehlanganweni ebizwa ngokuthi yi- Forbes Africa 30 ngaphasi kwabantu abangaphasi kweminyaka ematjhumi amathathu ubudala ngonyaka wee-2018.&lt;ref name=&quot;:0&quot;&gt;Mtsweni S&lt;/ref&gt;

Ngonyaka wee-2021, wadlala ehlelweni elibizwa nge-Underground Railroad elitholakala kuAmazon Video, lapho kunamahlelo amanengi nekungilo elamenza bona abemdlali wokuthoma we-Sewula Afrika okhamba phambili kwezamahlelo adlala kumabonwakude we-America. Lokhu kwamenza bona athumbe unongorwana obizwa bona yi-Independent Spirit Award etholwa mumuntu wengubo okhamba phambili ngokuba mdlali wakumabonwakude ehlelweni elitjha. Waragela phambili waba ngomunye wabalingisi ehlelweni elimlando wangaphetjheya e-America obizwa ngokobana yi- The Woman King( 2022) lapho adlala khona iskhundla saka Nawi.&lt;ref name=&quot;:0&quot; /&gt;

== Ipilo yakhe nefundo ==
U-Mbedu wabelethelwa eMidlands Medical Centre endaweni ye-Pietermaritzburg, KwaZulu-Natal. Ubelethwa ngumma okhuluma isiZulu kanye noyise okhuluma isiSotho nesiXhosa. Wakhuliswa e-Pelham ngugogo wakhe , owabamumuntu omtlhogomelako ngemva kokuhlongakalelwa babelethi bakhe bobabili asesemncani.&lt;ref name=&quot;:0&quot; /&gt; U-Mbedu wafunda esikolweni esibizwa nge-Pelham Primary School, waragela phambili emabangeni aphezulu e-Pietermaritzburg Girls' High School. Waragela phambili emazingeni aphezulu e-University ye Witwatersrand( Wits), &lt;ref name=&quot;:0&quot; /&gt;</text>
      <sha1>90zcltgcak21a6ih49hg55z99ss68bf</sha1>
    </revision>
  </page>
  <page>
    <title>Mlindo the Vocalist</title>
    <ns>0</ns>
    <id>754</id>
    <revision>
      <id>5113</id>
      <timestamp>2025-08-08T11:17:24Z</timestamp>
      <contributor>
        <username>Lerato Ruffy</username>
        <id>846</id>
      </contributor>
      <comment>Created page with &quot;'''ULindokuhle Mgedezi''' wabelethwa mhla amalanga alikhomba enyangeni kaSewula ngomnyaka we-1995, waziwa ngegama lika '''Mlindo the Vocalist''', ungumvumi we Sewula Africa begodu ungumbhali weengoma. Wathoma ukubonakala kanye nokuduma nofana ukwaziwa ngemva kobana akhiphe ingoma yakhe eyaduma khulu eyayibizwa bonyana yi &quot; Amablesser&quot; ayikhipha e albhamini yakhe ekubizwa bonyana yi ''Emakhaya (2018).''&lt;ref name=&quot;:0&quot;&gt;Lerato Ruffy&lt;/ref&gt;  '''IPILO NOMSEBENZI'''  1995-2016:...&quot;</comment>
      <origin>5113</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="974" sha1="af39pbgth9y94s7dzf05cfakj2kcatp" xml:space="preserve">'''ULindokuhle Mgedezi''' wabelethwa mhla amalanga alikhomba enyangeni kaSewula ngomnyaka we-1995, waziwa ngegama lika '''Mlindo the Vocalist''', ungumvumi we Sewula Africa begodu ungumbhali weengoma. Wathoma ukubonakala kanye nokuduma nofana ukwaziwa ngemva kobana akhiphe ingoma yakhe eyaduma khulu eyayibizwa bonyana yi &quot; Amablesser&quot; ayikhipha e albhamini yakhe ekubizwa bonyana yi ''Emakhaya (2018).''&lt;ref name=&quot;:0&quot;&gt;Lerato Ruffy&lt;/ref&gt;

'''IPILO NOMSEBENZI'''

1995-2016: Ipilo yokuthoma

ULindokuhle Mgedezi wabelethwa emnyakeni we-1995 e-Port Shepstone, KwaZulu Natal. Wathi nakaneminyaka emine, waba ngomunye welunga lesondo langekhabo lapha athola khona bonyana uyakwazi ukuvuma. UMlindo wafunda ePhathwa High School eGcilima, edorobheni le Margate. Nengoba athatha ikhambo lakhe lokuvuma, ngemva kwesikhathi uMlindo waya eTjhingalanga Kapa lapha azibandakanya khona nesiqhema somvumo wehlobo leHip Hop ekubizwa bona yi Flow Riders ngomyaka we-2010. &lt;ref name=&quot;:0&quot; /&gt;</text>
      <sha1>af39pbgth9y94s7dzf05cfakj2kcatp</sha1>
    </revision>
    <revision>
      <id>5118</id>
      <parentid>5113</parentid>
      <timestamp>2025-08-08T11:49:56Z</timestamp>
      <contributor>
        <username>Lerato Ruffy</username>
        <id>846</id>
      </contributor>
      <origin>5118</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1521" sha1="6op23rpcbud8pv2z480xqbi692tlmt6" xml:space="preserve">'''ULindokuhle Mgedezi''' wabelethwa mhla amalanga alikhomba enyangeni kaSewula ngomnyaka we-1995, waziwa ngegama lika '''Mlindo the Vocalist''', ungumvumi we Sewula Africa begodu ungumbhali weengoma. Wathoma ukubonakala kanye nokuduma nofana ukwaziwa ngemva kobana akhiphe ingoma yakhe eyaduma khulu eyayibizwa bonyana yi &quot; Amablesser&quot; ayikhipha e albhamini yakhe ekubizwa bonyana yi ''Emakhaya (2018).''&lt;ref name=&quot;:0&quot;&gt;Lerato Ruffy&lt;/ref&gt;

'''IPILO NOMSEBENZI'''

1995-2016: Ipilo yokuthoma

ULindokuhle Mgedezi wabelethwa emnyakeni we-1995 e-Port Shepstone, KwaZulu Natal. Wathi nakaneminyaka emine, waba ngomunye welunga lesondo langekhabo lapha athola khona bonyana uyakwazi ukuvuma. UMlindo wafunda ePhathwa High School eGcilima, edorobheni le Margate. 

Njengoba athatha ikhambo lakhe lokuvuma, ngemva kwesikhathi uMlindo waya eTjhingalanga Kapa lapha azibandakanya khona nesiqhema somvumo wehlobo leHip Hop ekubizwa bonyana yi Flow Riders ngomyaka we-2010. Wathatha ingcenye ekuquleni. Ngomyaka ka-2014, wasungula esiqhema se-Capella esibizwa bona yiWhite Bread, ngemva kokukhamba kwakhe esiqhemeni se Flow Riders. Esiqhema se White Bread saba yipumelelo enye ekulu njengoma bathumba imitlomela eminengi ekufaka hlangana kjwe ''Search for Stars,'' eyabanjelwa eUShaka Marine World eThekwini. Ngomyaka ka-2017, wathumba umncintiswano wamathalente i''Golden Search'' endaweni ye Richards Bay, ekungiyo eyamupha ithuba lokusebenza lapha ekugadangiswa khona umvumo ekubizwa bonyana yi Afrotainment ephethwe ngu DJ Tira.</text>
      <sha1>6op23rpcbud8pv2z480xqbi692tlmt6</sha1>
    </revision>
  </page>
  <page>
    <title>Wp/nr/Esther Mahlangu</title>
    <ns>0</ns>
    <id>755</id>
    <revision>
      <id>5114</id>
      <timestamp>2025-08-08T11:17:52Z</timestamp>
      <contributor>
        <username>N Mabhena</username>
        <id>843</id>
      </contributor>
      <comment>Created page with &quot;U-Esther Nikwambi Mahlangu wabelethwa mhla amalanga ali-11 kuSinyikhaba 1935. Wabelethelwa eplasini ngaphandle kwe-Middelburg, e-Mpumalanga, eSewula Afrika. Ulilunga labantu besiNdebele eSewula. UMahlangu mdala ebantwaneni abalithoba, unabafowabo abasithandathu nabodadwabo ababili. Wathoma ukupenda aneminyaka eli-10, afundiswe ngunina nogogo wakhe ngokuya kwesiko lamaNdebele, lapho abentazana abasesebatjha bafunda ukudweba ukulungiselela ukuhlobisa ngaphandle kwemizi yab...&quot;</comment>
      <origin>5114</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4852" sha1="n3at33b8boc4urdmrehf54whsq3v6ig" xml:space="preserve">U-Esther Nikwambi Mahlangu wabelethwa mhla amalanga ali-11 kuSinyikhaba 1935. Wabelethelwa eplasini ngaphandle kwe-Middelburg, e-Mpumalanga, eSewula Afrika. Ulilunga labantu besiNdebele eSewula. UMahlangu mdala ebantwaneni abalithoba, unabafowabo abasithandathu nabodadwabo ababili. Wathoma ukupenda aneminyaka eli-10, afundiswe ngunina nogogo wakhe ngokuya kwesiko lamaNdebele, lapho abentazana abasesebatjha bafunda ukudweba ukulungiselela ukuhlobisa ngaphandle kwemizi yabo ngemva komtjhado.

UMahlangu waziwa ngokutjhugulula ubucikwa be-Ndebele, obudwetjwa ngokwesiko emabodeni we-adobe, ukuya kezinye iindawo ezifana ne-canvas kanye nama-alloy wensimbi. Imitlamo yakhe etlikitliweko ivamise ukuba nemida emhlophe ehlelelwe ngokulandelana nofana ngamaphetheni we-chevron. Iingoma zakhe ziqhazwe ngokuthi &quot;zithakazelisa khulu begodu zikhulu ukudlula lezo zabantu besikhathi sakhe,&quot; ngemitlamo yemingcele emikhulu khulu.

Ubukghwari bakaMahlangu buthatha amaphetheni atholakala ezembathweni zesintu kanye nejuwelari yabantu bamaNdebele. Imitlamo yakhe ivamise ukuba nemibalabala nejometri, begodu imidwebo yakhe ivamise ukuba mikhulu, yenziwa ngokusebenzisa ibhrashi yokupenda eyenziwe ngamasiba wekukhu. Utlikitla umncamo wakhe ngokusebenzisa umncamo ukwenza amagama wakhe wokuthoma.

Phakathi kuka-1980 no-1991, u-Mahlangu bekahlala e-Botshabelo Historical Village, imnyuziyamu evulekileko enikelwe ukufundisa iimvakatjhi ngamasiko wamaNdebele.

UMahlangu wathoma ukuhlonitjhwa ngamazwe ngamazwe ngo-1989 embukisweni we-Magiciens de la terre (Ama-Magicians of the World) e-Center Pompidou e-Paris. Wamenywa bona ahlanganyele ngemva kobana abarhubhululi be-Embassy ye-France bavakatjhele iSewula Afrika ngo-1986 begodu babona imidwebo emzini wakhe. Ngesikhathi sokuhlala kwakhe e-France iinyanga ezimbili, wapenda umfanekiso wendlu yakhe phambi kweenkulungwana zabantu begodu waqeda ukudweba ngaphakathi kwe-Angoulême Museum of Fine Arts.

Ngo-1991, wathunyelwa yi-BMW bona enze ikoloyi egwaliweko, wajoyina abafaki-galelo bangaphambilini abafana no-Andy Warhol, u-David Hockney, no-Frank Stella. Idizayini yakhe, ependiwe ku-BMW 525i, beyinemifanekiso yesiko lamaNdebele begodu bekuyi-BMW Art Car yokuthoma eyakhiwe mdwebi ongasi ngeweTjingalanga begodu mumuntu wengubo. Ikoloyi le yavezwa e-National Museum of Women in the Arts e-Washington, D.C., ngo-1994, begodu yavezwa godu embukisweni i-South Africa: The Art of a Nation e-British Museum e-London kusukela ngoNobayeni 2016 ukuya kuMhlolanja 2017. Ngomnyaka ka-2016, u-Mahlangu wapenda ingaphakathi le-BMW 7 Series sedan eyavezwa e-Frizeze Art Fair e-Regent's Park, e-London, njengengcenye elihlelwe hlangana ne-BMW ne-34FineArt. 

Ngo-1992, uMahlangu wathunyelwa bona agwale umfanekiso we-Johannesburg Civic Theatre. Ngo-1994, wenza umfanekiso ebodeni e-National Museum of Women in the Arts e-Washington, D.C., ukutshwaya ukuvulwa komqaliso wakhe wedwa emnyuziyamu.

Ngo-1997, uMahlangu wathunyelwa bona apende amaphiko womsila weemphaphamtjhini ezinengi ze-British Airways. Ngo-2007, wapenda i-Fiat 500 ye-Why Africa? umqaliso e-Turin, e-Italy. Ngomnyaka ka-2014, uMahlangu waqeda ukuhlala kwenyanga eyodwa e-Virginia Museum of Fine Arts e-Richmond, Virginia, lapho akha khona imifanekiso emibili ye-museum ye-African art gallery. Ngomnyaka ka-2016, watlama ibhodlelo le-Product Red le-Belvedere Vodka, ngamaphesente amatjhumi amahlanu wemali etholakalako anikelwa ku-Global Fund ukulwisana ne-HIV/AIDS, imalariya, nesifo sofuba.[23][5] Ngalowo mnyaka, wasebenzisana nomhlobo wefetjheni we-Sweden i-Eytys ukuklama ama-sneaker anemitlamo yesiko lama-Ndebele, okutjho ukusetjenziswa kokuthoma kokufekethisiwe emsebenzini wakhe begodu wasebenzisana nomhlobo wamanyathelo we-Brazil u-Melissa kanye neleyibula yefetjheni ye-Japan i-Comme des Garçons.

Ngo-2020, uMahlangu wapenda ingaphakathi le-Rolls-Royce Phantom, elifaka hlangana 'igalari' kudetjhibhodi eyenzelwe ukutjengisa imisebenzi yomgwalo. Waba mdwebi wokuthoma weSewula Afrika owathunyelwa bona enze umsebenzi wekoloyi. Umsebenzi lo bewutjengiswa ngesikhathi seveke yezemigwalo ye-Cape Town 2020 e-The Melrose Gallery. Ngo-2024, uMahlangu wasebenzisana ne-BMW ukwakha i-i5 Flow Nostokana, ikoloyi ehlukileko enombala otjhuguluka ngaphandle ehlotjiswe ngemitlamo yama-Ndebele eyenziwe ngokusebenzisa ithekhnoloji ye-E Ink.[4][28][29] Umsebenzi wakhe utjengiswe emazweni ngamazwe, begodu imisebenzi yakhe ifakwe emkhakheni emikhulu yangasese nekwezikhungo, kufaka hlangana iqoqo le-Contemporary African Art Collection ka-Jean Pigozzi.

Ngomnyaka ka-2024, isitudiyo sobuciko esinikelwe emsebenzini ka-Mahlangu savulwa ekhaya lakhe e-Mpumalanga, eSewula Afrika. Ngaphambilini wasungula isikolo sokugwala esizisekela ngemali ngemva kwekhaya lakhe ukufundisa isiNdebele ukudweba namaqhinga wokutlama esizukulwaneni esilandelako sokugwala.</text>
      <sha1>n3at33b8boc4urdmrehf54whsq3v6ig</sha1>
    </revision>
  </page>
  <page>
    <title>David Mabuza</title>
    <ns>0</ns>
    <id>756</id>
    <revision>
      <id>5115</id>
      <timestamp>2025-08-08T11:20:51Z</timestamp>
      <contributor>
        <username>T Ntuli</username>
        <id>844</id>
      </contributor>
      <comment>Created page with &quot;U-David Dabede Mabuza wabelethwa mhlazana amalanga ali 25 kuRhoboyi 1960 e Phola eduze ne Hazyview endaweni eyaba sifundazwe se-Mpumalanga. Ababelethi bakhe bebabalimi. Beka ngowesithandathu ebantwaneni abalitjhumi nambili,abentazana  ababunane nabesana  abane.Wafunda e-Khumbula High School nayo ise Mpumalanga. Wathola  idiploma yokufundisa, ekhethekileko yesifundo  seembalo, e Mgwenya College of Education ngo-1985.ubenguNobhala we-Black Consciousness-aligned Azania Stud...&quot;</comment>
      <origin>5115</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2835" sha1="p137kmjinwohm7k85pr3orkh2ydzd3v" xml:space="preserve">U-David Dabede Mabuza wabelethwa mhlazana amalanga ali 25 kuRhoboyi 1960 e Phola eduze ne Hazyview endaweni eyaba sifundazwe se-Mpumalanga. Ababelethi bakhe bebabalimi. Beka ngowesithandathu ebantwaneni abalitjhumi nambili,abentazana  ababunane nabesana  abane.Wafunda e-Khumbula High School nayo ise Mpumalanga. Wathola  idiploma yokufundisa, ekhethekileko yesifundo  seembalo, e Mgwenya College of Education ngo-1985.ubenguNobhala we-Black Consciousness-aligned Azania Student Organization (AZASO) kusukela ngo-1984 ukuya ku-1985. Lokha nakafunda eYunivesithi yeSewula Afrika ukuze athole  i-Bachelor of Arts ku-psychology ayifumana ngo-1989, wathoma ukusebenza njengotitjhere wesikolo. Wafundisa eMnyangweni wezeFundo we-KaNgwane kusukela ngo-1986 ukuya ku-1988 begodu waba nguHlokokulu  we-Lungisani Secondary School, nayo Ese Mpumalanga kusukela ngo-1989 ukuya ku-1993.

U-David Dabede Mabuza bekangu sopolotiki weSewula Afrika owasebenza njengesekela likaMongameli weSewula Afrika kusukela ngoMhlolanja 2018 ukuya kuMhlolanja  2023. Bekayisekela likaMongameli we-African National Congress (ANC) kusukela ngoNobayeni 2017 ukuya kuNobayeni 2020 kanti ke ngaphambilini ubenguNdunakulu  we-Mpumalanga ukusukela ngo-2009 ukuya ku-2018, kikho ukuphathwa  bomlingani wakhe wezepolotiki u-Jacob Zuma. U-Mabuza wasebenza njengeLunga lePalamende ukusukela ngo-2018 bekwaba kulapho atjhiya khona umsebenzi ngo-2023.

 wabelethelwa e Mpumalanga begodu ungutitjhere ngokubandulwa. ukuzibandakanya kwakaMabuza kwezepolotiki kokuthoma kwaba ngomnyakazo we-Black Consciousness ngesikhathi asesemfundi. Bese kuthi nge yuniyoni zabotitjhere bekangumgcinisihlalo we-South African Democratic Teachers Union, ehlangene ne-Congress of South African Trade Unions ukusuka ngo-1988 ukuya ku-1991. Ngemva kokuphela kwebandlululo ngo-1994 wangenela isiBethamthetho sesiFunda se-Mpumalanga njengommeleli we-ANC begodu wathatha iinkhundla ezinengi zobuNgqongqotjhe eKhanseleni le-Executive le-Mpumalanga. Wakhethwa eKomidini ye-ANC National Executive Committee kokuthoma ngo-2007 begodu waba ngusihlalo we-ANC wesifundazwe e-Mpumalanga kusukela ngo-2008 ukuya ku-2017, ngesikhathi sakhe sokuba nguNdunakulu.

Ipolotiki ka-Mabuza ngesikhathi somsebenzi wakhe beyihlathululwa njengeyabantu abathanda abantu. wakhuphula ubukhulu nomthelela wesiqhema  se-ANC e -Mpumalanga no-Ace Magashule no-Supra Mahumapelo. waba yingcenye ye-Premier League eyasiza ukwakha umphumela we-ANC's 54th National Conference. Emhlanganweni lo  owabanjwa ngoNobayeni ku-2017, u-Mabuza wakhethwa njengoSekela likaMongameli we-ANC asebenza ngaphasi kuka-Cyril Ramaphosa. Lokha u-Ramaphosa nakakhuphukela esikhundleni sikamongameli weentjhabatjhaba ngemva kokutjhiya kwaka-Zuma ngoMhlolanja 2018, wabeka u-Mabuza bona athathe isikhundla sakhe njengeSekela likaMongameli weentjhabatjhaba.</text>
      <sha1>p137kmjinwohm7k85pr3orkh2ydzd3v</sha1>
    </revision>
    <revision>
      <id>5116</id>
      <parentid>5115</parentid>
      <timestamp>2025-08-08T11:22:56Z</timestamp>
      <contributor>
        <username>T Ntuli</username>
        <id>844</id>
      </contributor>
      <origin>5116</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2773" sha1="59pcybuw1ycgmbeefp1ae79qdjkidn8" xml:space="preserve">U-David Dabede Mabuza wabelethwa mhlazana amalanga ali 25 kuRhoboyi 1960 e Phola eduze ne Hazyview endaweni eyaba sifundazwe se-Mpumalanga. Ababelethi bakhe bebabalimi. Beka ngowesithandathu ebantwaneni abalitjhumi nambili,abentazana  ababunane nabesana  abane.Wafunda e-Khumbula High School nayo ise Mpumalanga. Wathola  idiploma yokufundisa, ekhethekileko yesifundo  seembalo, e Mgwenya College of Education ngo-1985.ubenguNobhala we-Black Consciousness-aligned Azania Student Organization (AZASO) kusukela ngo-1984 ukuya ku-1985. Lokha nakafunda eYunivesithi yeSewula Afrika ukuze athole  i-Bachelor of Arts ku-psychology ayifumana ngo-1989, wathoma ukusebenza njengotitjhere wesikolo. Wafundisa eMnyangweni wezeFundo we-KaNgwane kusukela ngo-1986 ukuya ku-1988 begodu waba nguHlokokulu  we-Lungisani Secondary School, nayo Ese Mpumalanga kusukela ngo-1989 ukuya ku-1993.

U-David Dabede Mabuza bekangu sopolotiki weSewula Afrika owasebenza njengesekela likaMongameli weSewula Afrika kusukela ngoMhlolanja 2018 ukuya kuMhlolanja  2023. Bekayisekela likaMongameli we-African National Congress (ANC) kusukela ngoNobayeni 2017 ukuya kuNobayeni 2020 kanti ke ngaphambilini ubenguNdunakulu  we-Mpumalanga ukusukela ngo-2009 ukuya ku-2018, kikho ukuphathwa  bomlingani wakhe wezepolotiki u-Jacob Zuma. U-Mabuza wasebenza njengeLunga lePalamende ukusukela ngo-2018 bekwaba kulapho atjhiya khona umsebenzi ngo-2023.

ukuzibandakanya kwakaMabuza kwezepolotiki kokuthoma kwaba ngomnyakazo we-Black Consciousness ngesikhathi asesemfundi. Bese kuthi nge yuniyoni zabotitjhere bekangumgcinisihlalo we-South African Democratic Teachers Union, ehlangene ne-Congress of South African Trade Unions ukusuka ngo-1988 ukuya ku-1991. Ngemva kokuphela kwebandlululo ngo-1994 wangenela isiBethamthetho sesiFunda se-Mpumalanga njengommeleli we-ANC begodu wathatha iinkhundla ezinengi zobuNgqongqotjhe eKhanseleni le-Executive le-Mpumalanga. Wakhethwa eKomidini ye-ANC National Executive Committee kokuthoma ngo-2007 begodu waba ngusihlalo we-ANC wesifundazwe e-Mpumalanga kusukela ngo-2008 ukuya ku-2017, ngesikhathi sakhe sokuba nguNdunakulu.

Ipolotiki ka-Mabuza ngesikhathi somsebenzi wakhe beyihlathululwa njengeyabantu abathanda abantu. wakhuphula ubukhulu nomthelela wesiqhema  se-ANC e -Mpumalanga no-Ace Magashule no-Supra Mahumapelo. waba yingcenye ye-Premier League eyasiza ukwakha umphumela we-ANC's 54th National Conference. Emhlanganweni lo  owabanjwa ngoNobayeni ku-2017, u-Mabuza wakhethwa njengoSekela likaMongameli we-ANC asebenza ngaphasi kuka-Cyril Ramaphosa. Lokha u-Ramaphosa nakakhuphukela esikhundleni sikamongameli weentjhabatjhaba ngemva kokutjhiya kwaka-Zuma ngoMhlolanja 2018, wabeka u-Mabuza bona athathe isikhundla sakhe njengeSekela likaMongameli weentjhabatjhaba.</text>
      <sha1>59pcybuw1ycgmbeefp1ae79qdjkidn8</sha1>
    </revision>
  </page>
  <page>
    <title>Helen Zille</title>
    <ns>0</ns>
    <id>757</id>
    <revision>
      <id>5127</id>
      <timestamp>2025-08-10T15:42:04Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;UHellen Zille umumuntu wengubo ongusopolitiki enarheni yeSewula afrika. Wabelethwa mhlana amalanga ali-9 kuNtaka ngonyama we-1951, wabelethelwa endaweni ye-Johanesburg. Wabe ambikindaba begodu amumuntu olwisana nebandlululo. Ukhule iplo yakhe ibunjwa magugu wabaJuda nokusinda kwababelethi bakhe  lokha iNazi nayizingela i-Germany. Wafunda e st-Mary isikolo endaweni ye-Waverly begodu ngemva kwalokho wayokufunda efundweni yamaziko aphezulu eyunivesithi ye-Witwatersrand ekuk...&quot;</comment>
      <origin>5127</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="837" sha1="tb6582o9q078jkkseiz2u4q4r23wwkz" xml:space="preserve">UHellen Zille umumuntu wengubo ongusopolitiki enarheni yeSewula afrika. Wabelethwa mhlana amalanga ali-9 kuNtaka ngonyama we-1951, wabelethelwa endaweni ye-Johanesburg. Wabe ambikindaba begodu amumuntu olwisana nebandlululo. Ukhule iplo yakhe ibunjwa magugu wabaJuda nokusinda kwababelethi bakhe  lokha iNazi nayizingela i-Germany. Wafunda e st-Mary isikolo endaweni ye-Waverly begodu ngemva kwalokho wayokufunda efundweni yamaziko aphezulu eyunivesithi ye-Witwatersrand ekukulapho athola khona iziqu zakhe ze-Bachelor of arts. Wathoma umsebenzi wokuba nguSopolitiki nakasebenzela i-Rand daily Mail ekukulapho aveza khona iqiniso ngokukhlongaka kwaka Steve Biko.ukungasabi kwakhe kuveza iqiniso leli kwenza nokuthi abe ngomunye olwisana negandelelo kwamsiza bonyana akghone  ukubayikutani yokukhululeka ukukhuluma neyama lungelo wobuntu.</text>
      <sha1>tb6582o9q078jkkseiz2u4q4r23wwkz</sha1>
    </revision>
    <revision>
      <id>5128</id>
      <parentid>5127</parentid>
      <timestamp>2025-08-10T15:50:28Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5128</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1308" sha1="m4uzbtlwjlvyiz0owk0mqhv3lp8wrnj" xml:space="preserve">[[Isimumathi:Democratic Alliance supporters leaving an election rally in Worcester, WC, May 2019.jpg|thumb|Abantu abambethe iinkipha ze-DA ekuyihlangano ebeyidoswa phambili ngu-Hellen Zille]]
'''UHellen Zille''' umumuntu wengubo ongusopolitiki enarheni yeSewula afrika. Wabelethwa mhlana amalanga ali-9 kuNtaka ngonyama we-1951, wabelethelwa endaweni ye-Johanesburg. Wabe ambikindaba begodu amumuntu olwisana nebandlululo.&lt;ref&gt;[https://www.britannica.com/biography/Helen-Zille Helen Zille | Biography &amp; Facts | Britannica]&lt;/ref&gt; Ukhule iplo yakhe ibunjwa magugu wabaJuda nokusinda kwababelethi bakhe  lokha iNazi nayizingela i-Germany. Wafunda e st-Mary isikolo endaweni ye-Waverly begodu ngemva kwalokho wayokufunda efundweni yamaziko aphezulu eyunivesithi ye-Witwatersrand ekukulapho athola khona iziqu zakhe ze-Bachelor of arts. Wathoma umsebenzi wokuba nguSopolitiki nakasebenzela i-Rand daily Mail ekukulapho aveza khona iqiniso ngokukhlongaka kwaka Steve Biko.&lt;ref&gt;Sauter, E.S., 2011. ''Shout Amandla! A rhetorical analysis of Helen Zille'' (Master's thesis, Colorado State University).&lt;/ref&gt;ukungasabi kwakhe kuveza iqiniso leli kwenza nokuthi abe ngomunye olwisana negandelelo kwamsiza bonyana akghone  ukubayikutani yokukhululeka ukukhuluma neyama lungelo wobuntu.

=== Imisebenzi kaHellen Zille ===</text>
      <sha1>m4uzbtlwjlvyiz0owk0mqhv3lp8wrnj</sha1>
    </revision>
    <revision>
      <id>5129</id>
      <parentid>5128</parentid>
      <timestamp>2025-08-10T15:50:56Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5129</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1324" sha1="2bjg3tdytyhmflxnnae1q8c2bcttwck" xml:space="preserve">[[Isimumathi:Democratic Alliance supporters leaving an election rally in Worcester, WC, May 2019.jpg|thumb|Abantu abambethe iinkipha ze-DA ekuyihlangano ebeyidoswa phambili ngu-Hellen Zille]]
'''UHellen Zille''' umumuntu wengubo ongusopolitiki enarheni yeSewula afrika. Wabelethwa mhlana amalanga ali-9 kuNtaka ngonyama we-1951, wabelethelwa endaweni ye-Johanesburg. Wabe ambikindaba begodu amumuntu olwisana nebandlululo.&lt;ref&gt;[https://www.britannica.com/biography/Helen-Zille Helen Zille | Biography &amp; Facts | Britannica]&lt;/ref&gt; Ukhule iplo yakhe ibunjwa magugu wabaJuda nokusinda kwababelethi bakhe  lokha iNazi nayizingela i-Germany. Wafunda e st-Mary isikolo endaweni ye-Waverly begodu ngemva kwalokho wayokufunda efundweni yamaziko aphezulu eyunivesithi ye-Witwatersrand ekukulapho athola khona iziqu zakhe ze-Bachelor of arts. Wathoma umsebenzi wokuba nguSopolitiki nakasebenzela i-Rand daily Mail ekukulapho aveza khona iqiniso ngokukhlongaka kwaka Steve Biko.&lt;ref&gt;Sauter, E.S., 2011. ''Shout Amandla! A rhetorical analysis of Helen Zille'' (Master's thesis, Colorado State University).&lt;/ref&gt;ukungasabi kwakhe kuveza iqiniso leli kwenza nokuthi abe ngomunye olwisana negandelelo kwamsiza bonyana akghone  ukubayikutani yokukhululeka ukukhuluma neyama lungelo wobuntu.

=== Imisebenzi kaHellen Zille ===

== Iinkomba ==</text>
      <sha1>2bjg3tdytyhmflxnnae1q8c2bcttwck</sha1>
    </revision>
    <revision>
      <id>5130</id>
      <parentid>5129</parentid>
      <timestamp>2025-08-10T15:52:07Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>5130</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1373" sha1="cekbewl1gdp7n72pdq4ckn2jesbhgj5" xml:space="preserve">[[Isimumathi:Democratic Alliance supporters leaving an election rally in Worcester, WC, May 2019.jpg|thumb|Abantu abambethe iinkipha ze-DA ekuyihlangano ebeyidoswa phambili ngu-Hellen Zille]]
'''UHellen Zille''' umumuntu wengubo ongusopolitiki enarheni yeSewula afrika. Wabelethwa mhlana amalanga ali-9 kuNtaka ngonyama we-1951, wabelethelwa endaweni ye-Johanesburg. Wabe ambikindaba begodu amumuntu olwisana nebandlululo.&lt;ref&gt;[https://www.britannica.com/biography/Helen-Zille Helen Zille | Biography &amp; Facts | Britannica]&lt;/ref&gt; Ukhule iplo yakhe ibunjwa magugu wabaJuda nokusinda kwababelethi bakhe  lokha iNazi nayizingela i-Germany. Wafunda e st-Mary isikolo endaweni ye-Waverly begodu ngemva kwalokho wayokufunda efundweni yamaziko aphezulu eyunivesithi ye-Witwatersrand ekukulapho athola khona iziqu zakhe ze-Bachelor of arts. Wathoma umsebenzi wokuba nguSopolitiki nakasebenzela i-Rand daily Mail ekukulapho aveza khona iqiniso ngokukhlongaka kwaka Steve Biko.&lt;ref&gt;Sauter, E.S., 2011. ''Shout Amandla! A rhetorical analysis of Helen Zille'' (Master's thesis, Colorado State University).&lt;/ref&gt;ukungasabi kwakhe kuveza iqiniso leli kwenza nokuthi abe ngomunye olwisana negandelelo kwamsiza bonyana akghone  ukubayikutani yokukhululeka ukukhuluma neyama lungelo wobuntu.

=== Imisebenzi kaHellen Zille ===

== Iinkomba ==
[[category:Hellen zille]]
[[Category:Ipolotiki]]</text>
      <sha1>cekbewl1gdp7n72pdq4ckn2jesbhgj5</sha1>
    </revision>
    <revision>
      <id>5131</id>
      <parentid>5130</parentid>
      <timestamp>2025-08-10T15:52:29Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>5131</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1373" sha1="r4icvbmwseej78vza6os6cmgq35bo2k" xml:space="preserve">[[Isimumathi:Democratic Alliance supporters leaving an election rally in Worcester, WC, May 2019.jpg|thumb|Abantu abambethe iinkipha ze-DA ekuyihlangano ebeyidoswa phambili ngu-Hellen Zille]]
'''UHellen Zille''' umumuntu wengubo ongusopolitiki enarheni yeSewula afrika. Wabelethwa mhlana amalanga ali-9 kuNtaka ngonyama we-1951, wabelethelwa endaweni ye-Johanesburg. Wabe ambikindaba begodu amumuntu olwisana nebandlululo.&lt;ref&gt;[https://www.britannica.com/biography/Helen-Zille Helen Zille | Biography &amp; Facts | Britannica]&lt;/ref&gt; Ukhule iplo yakhe ibunjwa magugu wabaJuda nokusinda kwababelethi bakhe  lokha iNazi nayizingela i-Germany. Wafunda e st-Mary isikolo endaweni ye-Waverly begodu ngemva kwalokho wayokufunda efundweni yamaziko aphezulu eyunivesithi ye-Witwatersrand ekukulapho athola khona iziqu zakhe ze-Bachelor of arts. Wathoma umsebenzi wokuba nguSopolitiki nakasebenzela i-Rand daily Mail ekukulapho aveza khona iqiniso ngokukhlongaka kwaka Steve Biko.&lt;ref&gt;Sauter, E.S., 2011. ''Shout Amandla! A rhetorical analysis of Helen Zille'' (Master's thesis, Colorado State University).&lt;/ref&gt;ukungasabi kwakhe kuveza iqiniso leli kwenza nokuthi abe ngomunye olwisana negandelelo kwamsiza bonyana akghone  ukubayikutani yokukhululeka ukukhuluma neyama lungelo wobuntu.

=== Imisebenzi kaHellen Zille ===

== Iinkomba ==
[[category:Hellen Zille]]
[[Category:Ipolotiki]]</text>
      <sha1>r4icvbmwseej78vza6os6cmgq35bo2k</sha1>
    </revision>
    <revision>
      <id>5132</id>
      <parentid>5131</parentid>
      <timestamp>2025-08-10T16:01:11Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5132</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2043" sha1="1ehsv6j1qsrd5ya1vc1w1xs04r2jiyq" xml:space="preserve">[[Isimumathi:Democratic Alliance supporters leaving an election rally in Worcester, WC, May 2019.jpg|thumb|Abantu abambethe iinkipha ze-DA ekuyihlangano ebeyidoswa phambili ngu-Hellen Zille]]
'''UHellen Zille''' umumuntu wengubo ongusopolitiki enarheni yeSewula afrika. Wabelethwa mhlana amalanga ali-9 kuNtaka ngonyama we-1951, wabelethelwa endaweni ye-Johanesburg. Wabe ambikindaba begodu amumuntu olwisana nebandlululo.&lt;ref&gt;[https://www.britannica.com/biography/Helen-Zille Helen Zille | Biography &amp; Facts | Britannica]&lt;/ref&gt; Ukhule iplo yakhe ibunjwa magugu wabaJuda nokusinda kwababelethi bakhe  lokha iNazi nayizingela i-Germany. Wafunda e st-Mary isikolo endaweni ye-Waverly begodu ngemva kwalokho wayokufunda efundweni yamaziko aphezulu eyunivesithi ye-Witwatersrand ekukulapho athola khona iziqu zakhe ze-Bachelor of arts. Wathoma umsebenzi wokuba nguSopolitiki nakasebenzela i-Rand daily Mail ekukulapho aveza khona iqiniso ngokukhlongaka kwaka Steve Biko.&lt;ref&gt;Sauter, E.S., 2011. ''Shout Amandla! A rhetorical analysis of Helen Zille'' (Master's thesis, Colorado State University).&lt;/ref&gt;ukungasabi kwakhe kuveza iqiniso leli kwenza nokuthi abe ngomunye olwisana negandelelo kwamsiza bonyana akghone  ukubayikutani yokukhululeka ukukhuluma neyama lungelo wobuntu.

=== Imisebenzi kaHellen Zille ===
Wabalilunga lepalamemde eSewula Afrika ngehlangano ye-Democratic alliance ngonyaka we-2004, wasebenza njengomkhulumeli wehlangan yenarha.Umsebenzi wakhe epalamdenwabe unzinze khulu kwezfundo, zepilo nakweminye imiraro yokuphatha. Waraga waba ngumeyara weCapetown ngonyaka we-2006ekukulapho wasebenzisa khona imigomo ukuthuthukisa izinga abantu abathola ngalo iinsetjenziswa zakamaspala, begodu walwisana nobugebengu. Ngesikhathi sakhe wenza amatjhuguluko emakhiweni wendawo leya begodu lokho kwamdosela ukwaziwa ngaphetjheya kwezinye iinarha ezingaphandle kweSewula Afrika.&lt;ref&gt;Rivas, G., 2018. The Role of National and State Actors in the Cape Town Water Crisis.&lt;/ref&gt;

== Iinkomba ==
[[category:Hellen Zille]]
[[Category:Ipolotiki]]</text>
      <sha1>1ehsv6j1qsrd5ya1vc1w1xs04r2jiyq</sha1>
    </revision>
    <revision>
      <id>5133</id>
      <parentid>5132</parentid>
      <timestamp>2025-08-10T17:43:16Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5133</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3304" sha1="sf5ez1jl0bdmduxq4ds7bfm0lrtsmpw" xml:space="preserve">[[Isimumathi:Democratic Alliance supporters leaving an election rally in Worcester, WC, May 2019.jpg|thumb|Abantu abambethe iinkipha ze-DA ekuyihlangano ebeyidoswa phambili ngu-Hellen Zille]]
'''UHellen Zille''' umumuntu wengubo ongusopolitiki enarheni yeSewula afrika. Wabelethwa mhlana amalanga ali-9 kuNtaka ngonyama we-1951, wabelethelwa endaweni ye-Johanesburg. Wabe ambikindaba begodu amumuntu olwisana nebandlululo.&lt;ref&gt;[https://www.britannica.com/biography/Helen-Zille Helen Zille | Biography &amp; Facts | Britannica]&lt;/ref&gt; Ukhule iplo yakhe ibunjwa magugu wabaJuda nokusinda kwababelethi bakhe  lokha iNazi nayizingela i-Germany. Wafunda e st-Mary isikolo endaweni ye-Waverly begodu ngemva kwalokho wayokufunda efundweni yamaziko aphezulu eyunivesithi ye-Witwatersrand ekukulapho athola khona iziqu zakhe ze-Bachelor of arts. Wathoma umsebenzi wokuba nguSopolitiki nakasebenzela i-Rand daily Mail ekukulapho aveza khona iqiniso ngokukhlongaka kwaka Steve Biko.&lt;ref&gt;Sauter, E.S., 2011. ''Shout Amandla! A rhetorical analysis of Helen Zille'' (Master's thesis, Colorado State University).&lt;/ref&gt;ukungasabi kwakhe kuveza iqiniso leli kwenza nokuthi abe ngomunye olwisana negandelelo kwamsiza bonyana akghone  ukubayikutani yokukhululeka ukukhuluma neyama lungelo wobuntu.

=== Imisebenzi kaHellen Zille ===
Wabalilunga lepalamemde eSewula Afrika ngehlangano ye-Democratic alliance ngonyaka we-2004, wasebenza njengomkhulumeli wehlangan yenarha.Umsebenzi wakhe epalamdenwabe unzinze khulu kwezfundo, zepilo nakweminye imiraro yokuphatha. Waraga waba ngumeyara weCapetown ngonyaka we-2006ekukulapho wasebenzisa khona imigomo ukuthuthukisa izinga abantu abathola ngalo iinsetjenziswa zakamaspala, begodu walwisana nobugebengu. Ngesikhathi sakhe wenza amatjhuguluko emakhiweni wendawo leya begodu lokho kwamdosela ukwaziwa ngaphetjheya kwezinye iinarha ezingaphandle kweSewula Afrika.&lt;ref&gt;Rivas, G., 2018. The Role of National and State Actors in the Cape Town Water Crisis.&lt;/ref&gt;

=== Ukubobaka kwakhe nokuthumba abonongorwana ===
Ngonyaka we-2008 u-Hellen Zille wanikelwa unongorwana wokuba ngumeyara wephasi ngombana wazama ukuthi alwisane  nokusetjenziswa kweendakamizwa wenza nokuthi wenza nokuthi abantu bathole iisetjenziswa zakarhulumende ngesikhathi.Unongorwana lo bekungewokuthi iindlela azisebenzisako ukuphatha edorobheni ziyasebenza begodu ubonakele azimisele ukuzibandakaya njengesakhamuzi. Godu wathumba  wabamumenzi weendaba wonyaka ngonyaka we-2006 lapo wabe athunjiswa yi-National press club ngesibanga sokuzibandakanya kwakhe kwezepolitiki inarha.

=== Umehluko owenziwe ngu-Hellen Zille ===
UHellen Zille ukghonile ukuthi  enze umehluko kweze politiki enarheni yeSewula Afrika, ngombana ukhombisile ukuukuzinikela kwakhe ngokuthiekuthuthukiseni amaphilo wezakhamuzi ezivamileko. Indlela yakhe yokudosa phambili ehlanganisa iphrinsipuli yokuzinikela nokurarulula imiraro usebenzisa i-pragmatic approach, ifundwe babantu beyathandwa nabanbanye abosopolitiki banantu abenza imigomo ephasini zombelele. Ukghonile ukwenzela iinzukulwana ezizako zabantu bengubo indlela kwezepolitiki.Ukuzimisela, ukubekezela, kwakhe  ukusebenzela kwakhe abantu kukhuthaze  ilutjha elinengi ukuthi lenze imsebenzi ekwezepolitiki nakarhulumende.

== Iinkomba ==
[[category:Hellen Zille]]
[[Category:Ipolotiki]]</text>
      <sha1>sf5ez1jl0bdmduxq4ds7bfm0lrtsmpw</sha1>
    </revision>
    <revision>
      <id>5134</id>
      <parentid>5133</parentid>
      <timestamp>2025-08-10T17:46:10Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5134</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3470" sha1="6d53mn5twzxlag3kegoqyifokl5hd05" xml:space="preserve">[[Isimumathi:Democratic Alliance supporters leaving an election rally in Worcester, WC, May 2019.jpg|thumb|Abantu abambethe iinkipha ze-DA ekuyihlangano ebeyidoswa phambili ngu-Hellen Zille]]
'''UHellen Zille''' umumuntu wengubo ongusopolitiki enarheni yeSewula afrika. Wabelethwa mhlana amalanga ali-9 kuNtaka ngonyama we-1951, wabelethelwa endaweni ye-Johanesburg. Wabe ambikindaba begodu amumuntu olwisana nebandlululo.&lt;ref&gt;[https://www.britannica.com/biography/Helen-Zille Helen Zille | Biography &amp; Facts | Britannica]&lt;/ref&gt; Ukhule iplo yakhe ibunjwa magugu wabaJuda nokusinda kwababelethi bakhe  lokha iNazi nayizingela i-Germany. Wafunda e st-Mary isikolo endaweni ye-Waverly begodu ngemva kwalokho wayokufunda efundweni yamaziko aphezulu eyunivesithi ye-Witwatersrand ekukulapho athola khona iziqu zakhe ze-Bachelor of arts. Wathoma umsebenzi wokuba nguSopolitiki nakasebenzela i-Rand daily Mail ekukulapho aveza khona iqiniso ngokukhlongaka kwaka Steve Biko.&lt;ref&gt;Sauter, E.S., 2011. ''Shout Amandla! A rhetorical analysis of Helen Zille'' (Master's thesis, Colorado State University).&lt;/ref&gt;ukungasabi kwakhe kuveza iqiniso leli kwenza nokuthi abe ngomunye olwisana negandelelo kwamsiza bonyana akghone  ukubayikutani yokukhululeka ukukhuluma neyama lungelo wobuntu.

=== Imisebenzi kaHellen Zille ===
Wabalilunga lepalamemde eSewula Afrika ngehlangano ye-Democratic alliance ngonyaka we-2004, wasebenza njengomkhulumeli wehlangano yenarha.Umsebenzi wakhe epalamdenwabe unzinze khulu kwezfundo, zepilo nakweminye imiraro yokuphatha. Waraga waba ngumeyara weCapetown ngonyaka we-2006ekukulapho wasebenzisa khona imigomo ukuthuthukisa izinga abantu abathola ngalo iinsetjenziswa zakamaspala, begodu walwisana nobugebengu. Ngesikhathi sakhe wenza amatjhuguluko emakhiweni wendawo leya begodu lokho kwamdosela ukwaziwa ngaphetjheya kwezinye iinarha ezingaphandle kweSewula Afrika.&lt;ref&gt;Rivas, G., 2018. The Role of National and State Actors in the Cape Town Water Crisis.&lt;/ref&gt;

=== Ukubobaka kwakhe nokuthumba abonongorwana ===
Ngonyaka we-2008 u-Hellen Zille wanikelwa unongorwana wokuba ngumeyara wephasi ngombana wazama ukuthi alwisane  nokusetjenziswa kweendakamizwa wenza nokuthi wenza nokuthi abantu bathole iisetjenziswa zakarhulumende ngesikhathi.&lt;ref&gt;[https://www.capetownmagazine.com/city-news/helen-zille-selected-as-the-worlds-best-mayor/172_22_9497 Helen Zille | Mayor of Cape Town | World Mayor 2008]&lt;/ref&gt;Unongorwana lo bekungewokuthi iindlela azisebenzisako ukuphatha edorobheni ziyasebenza begodu ubonakele azimisele ukuzibandakaya njengesakhamuzi. Godu wathumba  wabamumenzi weendaba wonyaka ngonyaka we-2006 lapo wabe athunjiswa yi-National press club ngesibanga sokuzibandakanya kwakhe kwezepolitiki inarha.

=== Umehluko owenziwe ngu-Hellen Zille ===
UHellen Zille ukghonile ukuthi  enze umehluko kweze politiki enarheni yeSewula Afrika, ngombana ukhombisile ukuukuzinikela kwakhe ngokuthiekuthuthukiseni amaphilo wezakhamuzi ezivamileko. Indlela yakhe yokudosa phambili ehlanganisa iphrinsipuli yokuzinikela nokurarulula imiraro usebenzisa i-pragmatic approach, ifundwe babantu beyathandwa nabanbanye abosopolitiki banantu abenza imigomo ephasini zombelele. Ukghonile ukwenzela iinzukulwana ezizako zabantu bengubo indlela kwezepolitiki.Ukuzimisela, ukubekezela, kwakhe  ukusebenzela kwakhe abantu kukhuthaze  ilutjha elinengi ukuthi lenze imsebenzi ekwezepolitiki nakarhulumende.

== Iinkomba ==
[[category:Hellen Zille]]
[[Category:Ipolotiki]]</text>
      <sha1>6d53mn5twzxlag3kegoqyifokl5hd05</sha1>
    </revision>
    <revision>
      <id>5135</id>
      <parentid>5134</parentid>
      <timestamp>2025-08-10T17:47:04Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5135</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3474" sha1="2mowqzry0nirxkc7ptqpsxu0qsbl1yx" xml:space="preserve">[[Isimumathi:Democratic Alliance supporters leaving an election rally in Worcester, WC, May 2019.jpg|thumb|Abantu abambethe iinkipha ze-DA ekuyihlangano ebeyidoswa phambili ngu-Hellen Zille]]
'''UHellen Zille''' umumuntu wengubo ongusopolitiki enarheni yeSewula afrika. Wabelethwa mhlana amalanga ali-9 kuNtaka ngonyama we-1951, wabelethelwa endaweni ye-Johanesburg. Wabe ambikindaba begodu amumuntu olwisana nebandlululo.&lt;ref&gt;[https://www.britannica.com/biography/Helen-Zille Helen Zille | Biography &amp; Facts | Britannica]&lt;/ref&gt; Ukhule iplo yakhe ibunjwa magugu wabaJuda nokusinda kwababelethi bakhe  lokha iNazi nayizingela i-Germany. Wafunda e st-Mary isikolo endaweni ye-Waverly begodu ngemva kwalokho wayokufunda efundweni yamaziko aphezulu eyunivesithi ye-Witwatersrand ekukulapho athola khona iziqu zakhe ze-Bachelor of arts. Wathoma umsebenzi wokuba nguSopolitiki nakasebenzela i-Rand daily Mail ekukulapho aveza khona iqiniso ngokukhlongaka kwaka Steve Biko.&lt;ref&gt;Sauter, E.S., 2011. ''Shout Amandla! A rhetorical analysis of Helen Zille'' (Master's thesis, Colorado State University).&lt;/ref&gt;ukungasabi kwakhe kuveza iqiniso leli kwenza nokuthi abe ngomunye olwisana negandelelo kwamsiza bonyana akghone  ukubayikutani yokukhululeka ukukhuluma neyama lungelo wobuntu.

=== Imisebenzi kaHellen Zille ===
Wabalilunga lepalamemde eSewula Afrika ngehlangano ye-[[Democratic alliance]] ngonyaka we-2004, wasebenza njengomkhulumeli wehlangano yenarha.Umsebenzi wakhe epalamdenwabe unzinze khulu kwezfundo, zepilo nakweminye imiraro yokuphatha. Waraga waba ngumeyara weCapetown ngonyaka we-2006ekukulapho wasebenzisa khona imigomo ukuthuthukisa izinga abantu abathola ngalo iinsetjenziswa zakamaspala, begodu walwisana nobugebengu. Ngesikhathi sakhe wenza amatjhuguluko emakhiweni wendawo leya begodu lokho kwamdosela ukwaziwa ngaphetjheya kwezinye iinarha ezingaphandle kweSewula Afrika.&lt;ref&gt;Rivas, G., 2018. The Role of National and State Actors in the Cape Town Water Crisis.&lt;/ref&gt;

=== Ukubobaka kwakhe nokuthumba abonongorwana ===
Ngonyaka we-2008 u-Hellen Zille wanikelwa unongorwana wokuba ngumeyara wephasi ngombana wazama ukuthi alwisane  nokusetjenziswa kweendakamizwa wenza nokuthi wenza nokuthi abantu bathole iisetjenziswa zakarhulumende ngesikhathi.&lt;ref&gt;[https://www.capetownmagazine.com/city-news/helen-zille-selected-as-the-worlds-best-mayor/172_22_9497 Helen Zille | Mayor of Cape Town | World Mayor 2008]&lt;/ref&gt;Unongorwana lo bekungewokuthi iindlela azisebenzisako ukuphatha edorobheni ziyasebenza begodu ubonakele azimisele ukuzibandakaya njengesakhamuzi. Godu wathumba  wabamumenzi weendaba wonyaka ngonyaka we-2006 lapo wabe athunjiswa yi-National press club ngesibanga sokuzibandakanya kwakhe kwezepolitiki inarha.

=== Umehluko owenziwe ngu-Hellen Zille ===
UHellen Zille ukghonile ukuthi  enze umehluko kweze politiki enarheni yeSewula Afrika, ngombana ukhombisile ukuukuzinikela kwakhe ngokuthiekuthuthukiseni amaphilo wezakhamuzi ezivamileko. Indlela yakhe yokudosa phambili ehlanganisa iphrinsipuli yokuzinikela nokurarulula imiraro usebenzisa i-pragmatic approach, ifundwe babantu beyathandwa nabanbanye abosopolitiki banantu abenza imigomo ephasini zombelele. Ukghonile ukwenzela iinzukulwana ezizako zabantu bengubo indlela kwezepolitiki.Ukuzimisela, ukubekezela, kwakhe  ukusebenzela kwakhe abantu kukhuthaze  ilutjha elinengi ukuthi lenze imsebenzi ekwezepolitiki nakarhulumende.

== Iinkomba ==
[[category:Hellen Zille]]
[[Category:Ipolotiki]]</text>
      <sha1>2mowqzry0nirxkc7ptqpsxu0qsbl1yx</sha1>
    </revision>
    <revision>
      <id>5136</id>
      <parentid>5135</parentid>
      <timestamp>2025-08-10T17:48:42Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5136</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3548" sha1="mtiimmgzs7rc6qh6gd8ocz78cq1txf2" xml:space="preserve">[[Isimumathi:Democratic Alliance supporters leaving an election rally in Worcester, WC, May 2019.jpg|thumb|Abantu abambethe iinkipha ze-DA ekuyihlangano ebeyidoswa phambili ngu-Hellen Zille]]
[[Isimumathi:Helen Zille in Mpumalanga (cropped).jpg|thumb|Hellen Zille]]
'''UHellen Zille''' umumuntu wengubo ongusopolitiki enarheni yeSewula afrika. Wabelethwa mhlana amalanga ali-9 kuNtaka ngonyama we-1951, wabelethelwa endaweni ye-Johanesburg. Wabe ambikindaba begodu amumuntu olwisana nebandlululo.&lt;ref&gt;[https://www.britannica.com/biography/Helen-Zille Helen Zille | Biography &amp; Facts | Britannica]&lt;/ref&gt; Ukhule iplo yakhe ibunjwa magugu wabaJuda nokusinda kwababelethi bakhe  lokha iNazi nayizingela i-Germany. Wafunda e st-Mary isikolo endaweni ye-Waverly begodu ngemva kwalokho wayokufunda efundweni yamaziko aphezulu eyunivesithi ye-Witwatersrand ekukulapho athola khona iziqu zakhe ze-Bachelor of arts. Wathoma umsebenzi wokuba nguSopolitiki nakasebenzela i-Rand daily Mail ekukulapho aveza khona iqiniso ngokukhlongaka kwaka Steve Biko.&lt;ref&gt;Sauter, E.S., 2011. ''Shout Amandla! A rhetorical analysis of Helen Zille'' (Master's thesis, Colorado State University).&lt;/ref&gt;ukungasabi kwakhe kuveza iqiniso leli kwenza nokuthi abe ngomunye olwisana negandelelo kwamsiza bonyana akghone  ukubayikutani yokukhululeka ukukhuluma neyama lungelo wobuntu.

=== Imisebenzi kaHellen Zille ===
Wabalilunga lepalamemde eSewula Afrika ngehlangano ye-[[Democratic alliance]] ngonyaka we-2004, wasebenza njengomkhulumeli wehlangano yenarha.Umsebenzi wakhe epalamdenwabe unzinze khulu kwezfundo, zepilo nakweminye imiraro yokuphatha. Waraga waba ngumeyara weCapetown ngonyaka we-2006ekukulapho wasebenzisa khona imigomo ukuthuthukisa izinga abantu abathola ngalo iinsetjenziswa zakamaspala, begodu walwisana nobugebengu. Ngesikhathi sakhe wenza amatjhuguluko emakhiweni wendawo leya begodu lokho kwamdosela ukwaziwa ngaphetjheya kwezinye iinarha ezingaphandle kweSewula Afrika.&lt;ref&gt;Rivas, G., 2018. The Role of National and State Actors in the Cape Town Water Crisis.&lt;/ref&gt;

=== Ukubobaka kwakhe nokuthumba abonongorwana ===
Ngonyaka we-2008 u-Hellen Zille wanikelwa unongorwana wokuba ngumeyara wephasi ngombana wazama ukuthi alwisane  nokusetjenziswa kweendakamizwa wenza nokuthi wenza nokuthi abantu bathole iisetjenziswa zakarhulumende ngesikhathi.&lt;ref&gt;[https://www.capetownmagazine.com/city-news/helen-zille-selected-as-the-worlds-best-mayor/172_22_9497 Helen Zille | Mayor of Cape Town | World Mayor 2008]&lt;/ref&gt;Unongorwana lo bekungewokuthi iindlela azisebenzisako ukuphatha edorobheni ziyasebenza begodu ubonakele azimisele ukuzibandakaya njengesakhamuzi. Godu wathumba  wabamumenzi weendaba wonyaka ngonyaka we-2006 lapo wabe athunjiswa yi-National press club ngesibanga sokuzibandakanya kwakhe kwezepolitiki inarha.

=== Umehluko owenziwe ngu-Hellen Zille ===
UHellen Zille ukghonile ukuthi  enze umehluko kweze politiki enarheni yeSewula Afrika, ngombana ukhombisile ukuukuzinikela kwakhe ngokuthiekuthuthukiseni amaphilo wezakhamuzi ezivamileko. Indlela yakhe yokudosa phambili ehlanganisa iphrinsipuli yokuzinikela nokurarulula imiraro usebenzisa i-pragmatic approach, ifundwe babantu beyathandwa nabanbanye abosopolitiki banantu abenza imigomo ephasini zombelele. Ukghonile ukwenzela iinzukulwana ezizako zabantu bengubo indlela kwezepolitiki.Ukuzimisela, ukubekezela, kwakhe  ukusebenzela kwakhe abantu kukhuthaze  ilutjha elinengi ukuthi lenze imsebenzi ekwezepolitiki nakarhulumende.

== Iinkomba ==
[[category:Hellen Zille]]
[[Category:Ipolotiki]]</text>
      <sha1>mtiimmgzs7rc6qh6gd8ocz78cq1txf2</sha1>
    </revision>
    <revision>
      <id>5137</id>
      <parentid>5136</parentid>
      <timestamp>2025-08-10T17:50:06Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5137</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3550" sha1="chma59v4a75qgqg68vljksigiopde9b" xml:space="preserve">[[Isimumathi:Democratic Alliance supporters leaving an election rally in Worcester, WC, May 2019.jpg|thumb|Abantu abambethe iinkipha ze-DA ekuyihlangano ebeyidoswa phambili ngu-Hellen Zille]]
[[Isimumathi:Helen Zille in Mpumalanga (cropped).jpg|thumb|Hellen Zille]]
'''UHellen Zille''' umumuntu wengubo ongusopolitiki enarheni yeSewula afrika. Wabelethwa mhlana amalanga ali-9 kuNtaka ngonyama we-1951, wabelethelwa endaweni ye-Johanesburg. Wabe ambikindaba begodu amumuntu olwisana nebandlululo.&lt;ref&gt;[https://www.britannica.com/biography/Helen-Zille Helen Zille | Biography &amp; Facts | Britannica]&lt;/ref&gt; Ukhule iplo yakhe ibunjwa magugu wabaJuda nokusinda kwababelethi bakhe  lokha iNazi nayizingela i-Germany. Wafunda e st-Mary isikolo endaweni ye-Waverly begodu ngemva kwalokho wayokufunda efundweni yamaziko aphezulu eyunivesithi ye-Witwatersrand ekukulapho athola khona iziqu zakhe ze-Bachelor of arts. Wathoma umsebenzi wokuba nguSopolitiki nakasebenzela i-Rand daily Mail ekukulapho aveza khona iqiniso ngokukhlongaka kwaka Steve Biko.&lt;ref&gt;Sauter, E.S., 2011. ''Shout Amandla! A rhetorical analysis of Helen Zille'' (Master's thesis, Colorado State University).&lt;/ref&gt;ukungasabi kwakhe kuveza iqiniso leli kwenza nokuthi abe ngomunye olwisana negandelelo kwamsiza bonyana akghone  ukubayikutani yokukhululeka ukukhuluma neyama lungelo wobuntu.

=== Imisebenzi kaHellen Zille ===
Wabalilunga lepalamemde eSewula Afrika ngehlangano ye-[[Democratic alliance]] ngonyaka we-2004, wasebenza njengomkhulumeli wehlangano yenarha.Umsebenzi wakhe epalamdenwabe unzinze khulu kwezfundo, zepilo nakweminye imiraro yokuphatha. Waraga waba ngumeyara weCapetown ngonyaka we-2006ekukulapho wasebenzisa khona imigomo ukuthuthukisa izinga abantu abathola ngalo iinsetjenziswa zakamaspala, begodu walwisana nobugebengu. Ngesikhathi sakhe wenza amatjhuguluko emakhiweni wendawo leya begodu lokho kwamdosela ukwaziwa ngaphetjheya kwezinye iinarha ezingaphandle kweSewula Afrika.&lt;ref&gt;Rivas, G., 2018. The Role of National and State Actors in the Cape Town Water Crisis.&lt;/ref&gt;

=== Ukubonakala kwakhe nokuthumba abonongorwana ===
Ngonyaka we-2008 u-Hellen Zille wanikelwa unongorwana wokuba ngumeyara wephasi ngombana wazama ukuthi alwisane  nokusetjenziswa kweendakamizwa wenza nokuthi wenza nokuthi abantu bathole iisetjenziswa zakarhulumende ngesikhathi.&lt;ref&gt;[https://www.capetownmagazine.com/city-news/helen-zille-selected-as-the-worlds-best-mayor/172_22_9497 Helen Zille | Mayor of Cape Town | World Mayor 2008]&lt;/ref&gt;Unongorwana lo bekungewokuthi iindlela azisebenzisako ukuphatha edorobheni ziyasebenza begodu ubonakele azimisele ukuzibandakaya njengesakhamuzi. Godu wathumba  wabamumenzi weendaba wonyaka ngonyaka we-2006 lapo wabe athunjiswa yi-National press club ngesibanga sokuzibandakanya kwakhe kwezepolitiki inarha.

=== Umehluko owenziwe ngu-Hellen Zille ===
UHellen Zille ukghonile ukuthi  enze umehluko kweze politiki enarheni yeSewula Afrika, ngombana ukhombisile ukuukuzinikela kwakhe ngokuthiekuthuthukiseni amaphilo wezakhamuzi ezivamileko. Indlela yakhe yokudosa phambili ehlanganisa iphrinsipuli yokuzinikela nokurarulula imiraro usebenzisa i-pragmatic approach, ifundwe babantu beyathandwa nabanbanye abosopolitiki banantu abenza imigomo ephasini zombelele. Ukghonile ukwenzela iinzukulwana ezizako zabantu bengubo indlela kwezepolitiki.Ukuzimisela, ukubekezela, kwakhe  ukusebenzela kwakhe abantu kukhuthaze  ilutjha elinengi ukuthi lenze imsebenzi ekwezepolitiki nakarhulumende.

== Iinkomba ==
[[category:Hellen Zille]]
[[Category:Ipolotiki]]</text>
      <sha1>chma59v4a75qgqg68vljksigiopde9b</sha1>
    </revision>
    <revision>
      <id>5138</id>
      <parentid>5137</parentid>
      <timestamp>2025-08-10T17:53:42Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5138</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3551" sha1="9vpxkhezmrvrxqktqg198vwc2clfyno" xml:space="preserve">[[Isimumathi:Democratic Alliance supporters leaving an election rally in Worcester, WC, May 2019.jpg|thumb|Abantu abambethe iinkipha ze-DA ekuyihlangano ebeyidoswa phambili ngu-Hellen Zille]]
[[Isimumathi:Helen Zille in Mpumalanga (cropped).jpg|thumb|Hellen Zille]]
'''UHellen Zille''' umumuntu wengubo ongusopolitiki enarheni yeSewula afrika. Wabelethwa mhlana amalanga ali-9 kuNtaka ngonyama we-1951, wabelethelwa endaweni ye-Johannesburg. Wabe ambikindaba begodu amumuntu olwisana nebandlululo.&lt;ref&gt;[https://www.britannica.com/biography/Helen-Zille Helen Zille | Biography &amp; Facts | Britannica]&lt;/ref&gt; Ukhule iplo yakhe ibunjwa magugu wabaJuda nokusinda kwababelethi bakhe  lokha iNazi nayizingela i-Germany. Wafunda e st-Mary isikolo endaweni ye-Waverly begodu ngemva kwalokho wayokufunda efundweni yamaziko aphezulu eyunivesithi ye-Witwatersrand ekukulapho athola khona iziqu zakhe ze-Bachelor of arts. Wathoma umsebenzi wokuba nguSopolitiki nakasebenzela i-Rand daily Mail ekukulapho aveza khona iqiniso ngokukhlongaka kwaka Steve Biko.&lt;ref&gt;Sauter, E.S., 2011. ''Shout Amandla! A rhetorical analysis of Helen Zille'' (Master's thesis, Colorado State University).&lt;/ref&gt;ukungasabi kwakhe kuveza iqiniso leli kwenza nokuthi abe ngomunye olwisana negandelelo kwamsiza bonyana akghone  ukubayikutani yokukhululeka ukukhuluma neyama lungelo wobuntu.

=== Imisebenzi kaHellen Zille ===
Wabalilunga lepalamemde eSewula Afrika ngehlangano ye-[[Democratic alliance]] ngonyaka we-2004, wasebenza njengomkhulumeli wehlangano yenarha.Umsebenzi wakhe epalamdenwabe unzinze khulu kwezfundo, zepilo nakweminye imiraro yokuphatha. Waraga waba ngumeyara weCapetown ngonyaka we-2006ekukulapho wasebenzisa khona imigomo ukuthuthukisa izinga abantu abathola ngalo iinsetjenziswa zakamaspala, begodu walwisana nobugebengu. Ngesikhathi sakhe wenza amatjhuguluko emakhiweni wendawo leya begodu lokho kwamdosela ukwaziwa ngaphetjheya kwezinye iinarha ezingaphandle kweSewula Afrika.&lt;ref&gt;Rivas, G., 2018. The Role of National and State Actors in the Cape Town Water Crisis.&lt;/ref&gt;

=== Ukubonakala kwakhe nokuthumba abonongorwana ===
Ngonyaka we-2008 u-Hellen Zille wanikelwa unongorwana wokuba ngumeyara wephasi ngombana wazama ukuthi alwisane  nokusetjenziswa kweendakamizwa wenza nokuthi wenza nokuthi abantu bathole iisetjenziswa zakarhulumende ngesikhathi.&lt;ref&gt;[https://www.capetownmagazine.com/city-news/helen-zille-selected-as-the-worlds-best-mayor/172_22_9497 Helen Zille | Mayor of Cape Town | World Mayor 2008]&lt;/ref&gt;Unongorwana lo bekungewokuthi iindlela azisebenzisako ukuphatha edorobheni ziyasebenza begodu ubonakele azimisele ukuzibandakaya njengesakhamuzi. Godu wathumba  wabamumenzi weendaba wonyaka ngonyaka we-2006 lapo wabe athunjiswa yi-National press club ngesibanga sokuzibandakanya kwakhe kwezepolitiki inarha.

=== Umehluko owenziwe ngu-Hellen Zille ===
UHellen Zille ukghonile ukuthi  enze umehluko kweze politiki enarheni yeSewula Afrika, ngombana ukhombisile ukuukuzinikela kwakhe ngokuthiekuthuthukiseni amaphilo wezakhamuzi ezivamileko. Indlela yakhe yokudosa phambili ehlanganisa iphrinsipuli yokuzinikela nokurarulula imiraro usebenzisa i-pragmatic approach, ifundwe babantu beyathandwa nabanbanye abosopolitiki banantu abenza imigomo ephasini zombelele. Ukghonile ukwenzela iinzukulwana ezizako zabantu bengubo indlela kwezepolitiki.Ukuzimisela, ukubekezela, kwakhe  ukusebenzela kwakhe abantu kukhuthaze  ilutjha elinengi ukuthi lenze imsebenzi ekwezepolitiki nakarhulumende.

== Iinkomba ==
[[category:Hellen Zille]]
[[Category:Ipolotiki]]</text>
      <sha1>9vpxkhezmrvrxqktqg198vwc2clfyno</sha1>
    </revision>
    <revision>
      <id>5139</id>
      <parentid>5138</parentid>
      <timestamp>2025-08-10T17:54:38Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5139</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3550" sha1="nris1okpjxoqm3aqr36cbkw6h643vt1" xml:space="preserve">[[Isimumathi:Democratic Alliance supporters leaving an election rally in Worcester, WC, May 2019.jpg|thumb|Abantu abambethe iinkipha ze-DA ekuyihlangano ebeyidoswa phambili ngu-Hellen Zille]]
[[Isimumathi:Helen Zille in Mpumalanga (cropped).jpg|thumb|Hellen Zille]]
'''UHellen Zille''' umumuntu wengubo ongusopolitiki enarheni yeSewula afrika. Wabelethwa mhlana amalanga ali-9 kuNtaka ngonyama we-1951, wabelethelwa endaweni ye-Johannesburg. Wabe ambikindaba begodu amumuntu olwisana nebandlululo.&lt;ref&gt;[https://www.britannica.com/biography/Helen-Zille Helen Zille | Biography &amp; Facts | Britannica]&lt;/ref&gt; Ukhule iplo yakhe ibunjwa magugu wabaJuda nokusinda kwababelethi bakhe  lokha iNazi nayizingela i-Germany. Wafunda e st-Mary isikolo endaweni ye-Waverly begodu ngemva kwalokho wayokufunda efundweni yamaziko aphezulu eyunivesithi ye-Witwatersrand ekukulapho athola khona iziqu zakhe ze-Bachelor of arts. Wathoma umsebenzi wokuba nguSopolitiki nakasebenzela i-Rand daily Mail ekukulapho aveza khona iqiniso ngokuhlongaka kwaka Steve Biko.&lt;ref&gt;Sauter, E.S., 2011. ''Shout Amandla! A rhetorical analysis of Helen Zille'' (Master's thesis, Colorado State University).&lt;/ref&gt;ukungasabi kwakhe kuveza iqiniso leli kwenza nokuthi abe ngomunye olwisana negandelelo kwamsiza bonyana akghone  ukubayikutani yokukhululeka ukukhuluma neyama lungelo wobuntu.

=== Imisebenzi kaHellen Zille ===
Wabalilunga lepalamemde eSewula Afrika ngehlangano ye-[[Democratic alliance]] ngonyaka we-2004, wasebenza njengomkhulumeli wehlangano yenarha.Umsebenzi wakhe epalamdenwabe unzinze khulu kwezfundo, zepilo nakweminye imiraro yokuphatha. Waraga waba ngumeyara weCapetown ngonyaka we-2006ekukulapho wasebenzisa khona imigomo ukuthuthukisa izinga abantu abathola ngalo iinsetjenziswa zakamaspala, begodu walwisana nobugebengu. Ngesikhathi sakhe wenza amatjhuguluko emakhiweni wendawo leya begodu lokho kwamdosela ukwaziwa ngaphetjheya kwezinye iinarha ezingaphandle kweSewula Afrika.&lt;ref&gt;Rivas, G., 2018. The Role of National and State Actors in the Cape Town Water Crisis.&lt;/ref&gt;

=== Ukubonakala kwakhe nokuthumba abonongorwana ===
Ngonyaka we-2008 u-Hellen Zille wanikelwa unongorwana wokuba ngumeyara wephasi ngombana wazama ukuthi alwisane  nokusetjenziswa kweendakamizwa wenza nokuthi wenza nokuthi abantu bathole iisetjenziswa zakarhulumende ngesikhathi.&lt;ref&gt;[https://www.capetownmagazine.com/city-news/helen-zille-selected-as-the-worlds-best-mayor/172_22_9497 Helen Zille | Mayor of Cape Town | World Mayor 2008]&lt;/ref&gt;Unongorwana lo bekungewokuthi iindlela azisebenzisako ukuphatha edorobheni ziyasebenza begodu ubonakele azimisele ukuzibandakaya njengesakhamuzi. Godu wathumba  wabamumenzi weendaba wonyaka ngonyaka we-2006 lapo wabe athunjiswa yi-National press club ngesibanga sokuzibandakanya kwakhe kwezepolitiki inarha.

=== Umehluko owenziwe ngu-Hellen Zille ===
UHellen Zille ukghonile ukuthi  enze umehluko kweze politiki enarheni yeSewula Afrika, ngombana ukhombisile ukuukuzinikela kwakhe ngokuthiekuthuthukiseni amaphilo wezakhamuzi ezivamileko. Indlela yakhe yokudosa phambili ehlanganisa iphrinsipuli yokuzinikela nokurarulula imiraro usebenzisa i-pragmatic approach, ifundwe babantu beyathandwa nabanbanye abosopolitiki banantu abenza imigomo ephasini zombelele. Ukghonile ukwenzela iinzukulwana ezizako zabantu bengubo indlela kwezepolitiki.Ukuzimisela, ukubekezela, kwakhe  ukusebenzela kwakhe abantu kukhuthaze  ilutjha elinengi ukuthi lenze imsebenzi ekwezepolitiki nakarhulumende.

== Iinkomba ==
[[category:Hellen Zille]]
[[Category:Ipolotiki]]</text>
      <sha1>nris1okpjxoqm3aqr36cbkw6h643vt1</sha1>
    </revision>
    <revision>
      <id>5146</id>
      <parentid>5139</parentid>
      <timestamp>2025-08-11T08:06:03Z</timestamp>
      <contributor>
        <username>Wolverène</username>
        <id>97</id>
      </contributor>
      <minor />
      <comment>Wolverène moved page [[Hellen Zille]] to [[Helen Zille]]: single L !</comment>
      <origin>5139</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3550" sha1="nris1okpjxoqm3aqr36cbkw6h643vt1" xml:space="preserve">[[Isimumathi:Democratic Alliance supporters leaving an election rally in Worcester, WC, May 2019.jpg|thumb|Abantu abambethe iinkipha ze-DA ekuyihlangano ebeyidoswa phambili ngu-Hellen Zille]]
[[Isimumathi:Helen Zille in Mpumalanga (cropped).jpg|thumb|Hellen Zille]]
'''UHellen Zille''' umumuntu wengubo ongusopolitiki enarheni yeSewula afrika. Wabelethwa mhlana amalanga ali-9 kuNtaka ngonyama we-1951, wabelethelwa endaweni ye-Johannesburg. Wabe ambikindaba begodu amumuntu olwisana nebandlululo.&lt;ref&gt;[https://www.britannica.com/biography/Helen-Zille Helen Zille | Biography &amp; Facts | Britannica]&lt;/ref&gt; Ukhule iplo yakhe ibunjwa magugu wabaJuda nokusinda kwababelethi bakhe  lokha iNazi nayizingela i-Germany. Wafunda e st-Mary isikolo endaweni ye-Waverly begodu ngemva kwalokho wayokufunda efundweni yamaziko aphezulu eyunivesithi ye-Witwatersrand ekukulapho athola khona iziqu zakhe ze-Bachelor of arts. Wathoma umsebenzi wokuba nguSopolitiki nakasebenzela i-Rand daily Mail ekukulapho aveza khona iqiniso ngokuhlongaka kwaka Steve Biko.&lt;ref&gt;Sauter, E.S., 2011. ''Shout Amandla! A rhetorical analysis of Helen Zille'' (Master's thesis, Colorado State University).&lt;/ref&gt;ukungasabi kwakhe kuveza iqiniso leli kwenza nokuthi abe ngomunye olwisana negandelelo kwamsiza bonyana akghone  ukubayikutani yokukhululeka ukukhuluma neyama lungelo wobuntu.

=== Imisebenzi kaHellen Zille ===
Wabalilunga lepalamemde eSewula Afrika ngehlangano ye-[[Democratic alliance]] ngonyaka we-2004, wasebenza njengomkhulumeli wehlangano yenarha.Umsebenzi wakhe epalamdenwabe unzinze khulu kwezfundo, zepilo nakweminye imiraro yokuphatha. Waraga waba ngumeyara weCapetown ngonyaka we-2006ekukulapho wasebenzisa khona imigomo ukuthuthukisa izinga abantu abathola ngalo iinsetjenziswa zakamaspala, begodu walwisana nobugebengu. Ngesikhathi sakhe wenza amatjhuguluko emakhiweni wendawo leya begodu lokho kwamdosela ukwaziwa ngaphetjheya kwezinye iinarha ezingaphandle kweSewula Afrika.&lt;ref&gt;Rivas, G., 2018. The Role of National and State Actors in the Cape Town Water Crisis.&lt;/ref&gt;

=== Ukubonakala kwakhe nokuthumba abonongorwana ===
Ngonyaka we-2008 u-Hellen Zille wanikelwa unongorwana wokuba ngumeyara wephasi ngombana wazama ukuthi alwisane  nokusetjenziswa kweendakamizwa wenza nokuthi wenza nokuthi abantu bathole iisetjenziswa zakarhulumende ngesikhathi.&lt;ref&gt;[https://www.capetownmagazine.com/city-news/helen-zille-selected-as-the-worlds-best-mayor/172_22_9497 Helen Zille | Mayor of Cape Town | World Mayor 2008]&lt;/ref&gt;Unongorwana lo bekungewokuthi iindlela azisebenzisako ukuphatha edorobheni ziyasebenza begodu ubonakele azimisele ukuzibandakaya njengesakhamuzi. Godu wathumba  wabamumenzi weendaba wonyaka ngonyaka we-2006 lapo wabe athunjiswa yi-National press club ngesibanga sokuzibandakanya kwakhe kwezepolitiki inarha.

=== Umehluko owenziwe ngu-Hellen Zille ===
UHellen Zille ukghonile ukuthi  enze umehluko kweze politiki enarheni yeSewula Afrika, ngombana ukhombisile ukuukuzinikela kwakhe ngokuthiekuthuthukiseni amaphilo wezakhamuzi ezivamileko. Indlela yakhe yokudosa phambili ehlanganisa iphrinsipuli yokuzinikela nokurarulula imiraro usebenzisa i-pragmatic approach, ifundwe babantu beyathandwa nabanbanye abosopolitiki banantu abenza imigomo ephasini zombelele. Ukghonile ukwenzela iinzukulwana ezizako zabantu bengubo indlela kwezepolitiki.Ukuzimisela, ukubekezela, kwakhe  ukusebenzela kwakhe abantu kukhuthaze  ilutjha elinengi ukuthi lenze imsebenzi ekwezepolitiki nakarhulumende.

== Iinkomba ==
[[category:Hellen Zille]]
[[Category:Ipolotiki]]</text>
      <sha1>nris1okpjxoqm3aqr36cbkw6h643vt1</sha1>
    </revision>
    <revision>
      <id>5148</id>
      <parentid>5146</parentid>
      <timestamp>2025-08-11T08:06:34Z</timestamp>
      <contributor>
        <username>Wolverène</username>
        <id>97</id>
      </contributor>
      <minor />
      <comment>m.</comment>
      <origin>5148</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3542" sha1="skm92s0x4mrnkbd6lhlerf3ak2qws78" xml:space="preserve">[[Isimumathi:Democratic Alliance supporters leaving an election rally in Worcester, WC, May 2019.jpg|thumb|Abantu abambethe iinkipha ze-DA ekuyihlangano ebeyidoswa phambili ngu-Helen Zille]]
[[Isimumathi:Helen Zille in Mpumalanga (cropped).jpg|thumb|Helen Zille]]
'''UHelen Zille''' umumuntu wengubo ongusopolitiki enarheni yeSewula afrika. Wabelethwa mhlana amalanga ali-9 kuNtaka ngonyama we-1951, wabelethelwa endaweni ye-Johannesburg. Wabe ambikindaba begodu amumuntu olwisana nebandlululo.&lt;ref&gt;[https://www.britannica.com/biography/Helen-Zille Helen Zille | Biography &amp; Facts | Britannica]&lt;/ref&gt; Ukhule iplo yakhe ibunjwa magugu wabaJuda nokusinda kwababelethi bakhe  lokha iNazi nayizingela i-Germany. Wafunda e st-Mary isikolo endaweni ye-Waverly begodu ngemva kwalokho wayokufunda efundweni yamaziko aphezulu eyunivesithi ye-Witwatersrand ekukulapho athola khona iziqu zakhe ze-Bachelor of arts. Wathoma umsebenzi wokuba nguSopolitiki nakasebenzela i-Rand daily Mail ekukulapho aveza khona iqiniso ngokuhlongaka kwaka Steve Biko.&lt;ref&gt;Sauter, E.S., 2011. ''Shout Amandla! A rhetorical analysis of Helen Zille'' (Master's thesis, Colorado State University).&lt;/ref&gt;ukungasabi kwakhe kuveza iqiniso leli kwenza nokuthi abe ngomunye olwisana negandelelo kwamsiza bonyana akghone  ukubayikutani yokukhululeka ukukhuluma neyama lungelo wobuntu.

=== Imisebenzi kaHelen Zille ===
Wabalilunga lepalamemde eSewula Afrika ngehlangano ye-[[Democratic alliance]] ngonyaka we-2004, wasebenza njengomkhulumeli wehlangano yenarha.Umsebenzi wakhe epalamdenwabe unzinze khulu kwezfundo, zepilo nakweminye imiraro yokuphatha. Waraga waba ngumeyara weCapetown ngonyaka we-2006ekukulapho wasebenzisa khona imigomo ukuthuthukisa izinga abantu abathola ngalo iinsetjenziswa zakamaspala, begodu walwisana nobugebengu. Ngesikhathi sakhe wenza amatjhuguluko emakhiweni wendawo leya begodu lokho kwamdosela ukwaziwa ngaphetjheya kwezinye iinarha ezingaphandle kweSewula Afrika.&lt;ref&gt;Rivas, G., 2018. The Role of National and State Actors in the Cape Town Water Crisis.&lt;/ref&gt;

=== Ukubonakala kwakhe nokuthumba abonongorwana ===
Ngonyaka we-2008 u-Helen Zille wanikelwa unongorwana wokuba ngumeyara wephasi ngombana wazama ukuthi alwisane  nokusetjenziswa kweendakamizwa wenza nokuthi wenza nokuthi abantu bathole iisetjenziswa zakarhulumende ngesikhathi.&lt;ref&gt;[https://www.capetownmagazine.com/city-news/helen-zille-selected-as-the-worlds-best-mayor/172_22_9497 Helen Zille | Mayor of Cape Town | World Mayor 2008]&lt;/ref&gt;Unongorwana lo bekungewokuthi iindlela azisebenzisako ukuphatha edorobheni ziyasebenza begodu ubonakele azimisele ukuzibandakaya njengesakhamuzi. Godu wathumba  wabamumenzi weendaba wonyaka ngonyaka we-2006 lapo wabe athunjiswa yi-National press club ngesibanga sokuzibandakanya kwakhe kwezepolitiki inarha.

=== Umehluko owenziwe ngu-Helen Zille ===
UHelen Zille ukghonile ukuthi  enze umehluko kweze politiki enarheni yeSewula Afrika, ngombana ukhombisile ukuukuzinikela kwakhe ngokuthiekuthuthukiseni amaphilo wezakhamuzi ezivamileko. Indlela yakhe yokudosa phambili ehlanganisa iphrinsipuli yokuzinikela nokurarulula imiraro usebenzisa i-pragmatic approach, ifundwe babantu beyathandwa nabanbanye abosopolitiki banantu abenza imigomo ephasini zombelele. Ukghonile ukwenzela iinzukulwana ezizako zabantu bengubo indlela kwezepolitiki.Ukuzimisela, ukubekezela, kwakhe  ukusebenzela kwakhe abantu kukhuthaze  ilutjha elinengi ukuthi lenze imsebenzi ekwezepolitiki nakarhulumende.

== Iinkomba ==
[[category:Helen Zille]]
[[Category:Ipolotiki]]</text>
      <sha1>skm92s0x4mrnkbd6lhlerf3ak2qws78</sha1>
    </revision>
  </page>
  <page>
    <title>IVUNULO</title>
    <ns>0</ns>
    <id>758</id>
    <redirect title="Ivunulo" />
    <revision>
      <id>5145</id>
      <timestamp>2025-08-11T07:50:37Z</timestamp>
      <contributor>
        <username>Wolverène</username>
        <id>97</id>
      </contributor>
      <comment>Wolverène moved page [[IVUNULO]] to [[Ivunulo]]</comment>
      <origin>5145</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="21" sha1="69bmmhw1gidgempnv6fays7259izipg" xml:space="preserve">#REDIRECT [[Ivunulo]]</text>
      <sha1>69bmmhw1gidgempnv6fays7259izipg</sha1>
    </revision>
  </page>
  <page>
    <title>Hellen Zille</title>
    <ns>0</ns>
    <id>759</id>
    <redirect title="Helen Zille" />
    <revision>
      <id>5147</id>
      <timestamp>2025-08-11T08:06:03Z</timestamp>
      <contributor>
        <username>Wolverène</username>
        <id>97</id>
      </contributor>
      <comment>Wolverène moved page [[Hellen Zille]] to [[Helen Zille]]: single L !</comment>
      <origin>5147</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="25" sha1="dsmuc5c66yikak0gu2xowa1u3zh3wj8" xml:space="preserve">#REDIRECT [[Helen Zille]]</text>
      <sha1>dsmuc5c66yikak0gu2xowa1u3zh3wj8</sha1>
    </revision>
  </page>
  <page>
    <title>I-Jonathan Ball Publishers</title>
    <ns>0</ns>
    <id>760</id>
    <revision>
      <id>5158</id>
      <timestamp>2025-08-14T13:23:37Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1305819088|Jonathan Ball Publishers]]&quot;</comment>
      <origin>5158</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1284" sha1="sif2giaf6gd6awet5nbbr8nspx7lrwm" xml:space="preserve">
'''I-Jonathan Ball Publishers''' yindlu yokugadangisa [[Isewula Afrika|yeSewula Afrika]] eyasungulwa nguJonathan Ball ngomnyaka wa 1976. &lt;ref&gt;https://www.news24.com/opinions/obituaries/obituary-publisher-jonathan-ball-69-challenged-the-establishment-and-oppressive-politics-20210403&lt;/ref&gt; Yaziwa ngokugadangisa nokusabalalisa iincwadi ezingezizo zezinganekwane ezisezingeni eliphezulu, okufakahlangana imisebenzi yezepolotiki yeSewula Afrika, umlando, amabiography, kanye neendaba zamanje, kanye neenhloko ezikhethiweko zezinganekwane. Ikhamphani le godu isebenza njengomsabalalisi wendawo wemibhalo eminengi emikhulu yamazwe ngamazwe, iletha iincwadi ezithengiswa khulu ephasini loke emakethe yeSewula Afrika. I-Jonathan Ball Publishers isebenze nabanye babatloli nabahlaziyi abadumileko enarheni, begodu ikhathalogu yayo ifaka hlangana kokubili imisebenzi yokuphenya eqakathekileko nokufundwa okuthandwako. Ihhovisi elikhulu lise [[Johannesburg|-Goli]], neminye imisebenzi e -Cape Town. &lt;ref&gt;https://www.dailymaverick.co.za/article/2021-04-06-jonathan-ball-1951-2021-a-disruptor-who-transformed-south-africas-publishing-industry/&lt;/ref&gt; &lt;ref&gt;https://www.thebookseller.com/news/jonathan-ball-publishers-acquires-icon-books-ltd-1198338&lt;/ref&gt;

== Iinkomba ==

[[Mkhakha:Sewula Afrika]]</text>
      <sha1>sif2giaf6gd6awet5nbbr8nspx7lrwm</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Sewula Afrika</title>
    <ns>14</ns>
    <id>761</id>
    <revision>
      <id>5159</id>
      <timestamp>2025-08-14T13:24:07Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created blank page</comment>
      <origin>5159</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
  </page>
  <page>
    <title>Hlengiwe Mhlaba</title>
    <ns>0</ns>
    <id>762</id>
    <revision>
      <id>5169</id>
      <timestamp>2025-08-14T15:04:39Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''U-Hlengiwe Mhlaba''' wabelethwa mhlana amalanga ali-7  kuVelabahlinze ngonyaka we-1973.&lt;ref&gt;[https://thenation.co.za/biography/hlengiwe-mhlaba-biography/ Hlengiwe Mhlaba Biography: Age, Net Worth, Spouse, Songs, Suicide Attempt, Accident - TheNation]&lt;/ref&gt;Wabelethelwa KwaMashu esiphandeni KwaZulu Natal. Umvumi nomtloli womvumo enarheni yeSewula Afrika,yena uvuma umvumo wesonto.Ikhambo lakhe kwezomvumo lathoma asesemncaninakanikela ipilo yakhe kuKhreste. Wathoma ukut...&quot;</comment>
      <origin>5169</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3030" sha1="m8j814frmmbul7ka0aktv2jwj9c51ig" xml:space="preserve">'''U-Hlengiwe Mhlaba''' wabelethwa mhlana amalanga ali-7  kuVelabahlinze ngonyaka we-1973.&lt;ref&gt;[https://thenation.co.za/biography/hlengiwe-mhlaba-biography/ Hlengiwe Mhlaba Biography: Age, Net Worth, Spouse, Songs, Suicide Attempt, Accident - TheNation]&lt;/ref&gt;Wabelethelwa KwaMashu esiphandeni KwaZulu Natal. Umvumi nomtloli womvumo enarheni yeSewula Afrika,yena uvuma umvumo wesonto.Ikhambo lakhe kwezomvumo lathoma asesemncaninakanikela ipilo yakhe kuKhreste. Wathoma ukuthanda ukuvuma asakhula, ithando lakhe lovuma lakhuliswa  makhredte bewagcina alandela ibizelomvumi. Ngaphambi kobana abemvumi obandululiweko u-Hlengiwe Mhlaba wabe angutitjhere afundisa isifundo seembalo nesayensi esikolweni esisemakhaya.

Ngemva kwalokho nasele isiskhathi sikhambile wathola iziqu zokumhlonipha zokuba ngudorhodere ku-theology azithola ku-Immanuel University of Theology, lokho bakwenza babobna ikghono lakhe lokuvuma umvumo wesento.Isitayela sakhe sokuvuma sihlukile simenze bonyana abe nabalandeli abangaphezulu kwe-22 000 ku Instagram ngombana wabela abantu ngokukhuthala umvumo wakhe begodu utlola imilayezo ekhuthazako nokubalandeli bakhe.Akanabo abantwana ukungebakhe U-Hlengiwe begodu umumuntu wengubo ongakhange atjhade epilweni.Uyakhuluma ngesiqunto sakhe sokuthi agcoke indandatho emunweni, Uyigcokela bonyana abantu bembsaji bangamsomi, kodwana baphazamiseke babone ngathi utjhadile. Wenza lokho ngombana begade bangamfuni lokha nakasese ngutitjhere kodwana nakathoma ukuba mvumi sele bamfuna uthi lokho kutjengisa bona bafuna imali yakhe ingasi yena.

Umsebenzi wakhe kwezokuvuma

Ikghono lakhe lokuvuma latholwa ngomunye wabavumi bomvumo wesonto u-Sipho Makhabane ekunguye owamfaka ku-Manxusa productions ekukulapho athoma khona ibizelo lakhe lokuvuma.&lt;ref&gt;[https://audiosure.co.za/hlengiwe-mhlaba/ Hlengiwe Mhlaba | Audiosure]&lt;/ref&gt;Ibizelo lakaHlengiwe Mhlaba lathoma ngonyaka we-2005 nakakhipha i-lbhamu yakhe yesihloko esithi “dwala lami”ekungiyo eyamenzelabona aziwe njengomvumi womvumo wesonto.”UJesu uyalalela” yi-albhamu yakhe alandelal ngayo eyabe ikatelela bona umthandazo ngiwo oyipendulo. Wakhupha enye godu i-albhamu ngo-2007 yona eyabe imumethe ifihlo yokobana umvumo wesonto kufanele uzwakale bunjani, uphethe ukulotjha uzimu, ukudansa Kanye nokubonga.Sele akhiphe ama-albhamu aphezulu kwalikhomba.

Ipilo yakhe neentjhijilo

Uhlengiwe Mhlaba akhange afihle okwenzeke epilweni yakhe waveza kopbana ukhe walinga ukuzikhunga ngesibanga sokugandelelwa mndeni begodu nangesinga sokuba nobudisi kwezemali. Nanyana kunjalo wasebenzisa izinto akhe aqalana nazo ukuthi abasele umvumo wakhe akwazi ukuthi alekelele abanye abanobududisi abacalene nabo  epilweni ngomvumo wakhe.Umumuntu ofundisa ngokuthi abantu kufanele bazigcine baphilile emkhumbulweni wabo babalekele ukugandeleleka ngombana ukugandeleleka kungenza umuntu binyana abe nomcabango wokuzikhunga.Ngalokho wagcina azibandakanya  ku-“Ungazibulali depression  and Suicide Campaign”.Uthanda ukhuluma nesitjhaba anikele abantu ithemba epilweni.</text>
      <sha1>m8j814frmmbul7ka0aktv2jwj9c51ig</sha1>
    </revision>
    <revision>
      <id>5170</id>
      <parentid>5169</parentid>
      <timestamp>2025-08-14T15:08:40Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5170</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3064" sha1="sbqk38v4gw1m58d3xfratbtv0vchxrf" xml:space="preserve">'''U-Hlengiwe Mhlaba''' wabelethwa mhlana amalanga ali-7  kuVelabahlinze ngonyaka we-1973.&lt;ref&gt;[https://thenation.co.za/biography/hlengiwe-mhlaba-biography/ Hlengiwe Mhlaba Biography: Age, Net Worth, Spouse, Songs, Suicide Attempt, Accident - TheNation]&lt;/ref&gt;Wabelethelwa KwaMashu esiphandeni KwaZulu Natal. Umvumi nomtloli womvumo enarheni yeSewula Afrika,yena uvuma [[umvumo wesonto]].Ikhambo lakhe kwezomvumo lathoma asesemncaninakanikela ipilo yakhe kuKhreste. Wathoma ukuthanda ukuvuma asakhula, ithando lakhe lovuma lakhuliswa  makhredte bewagcina alandela ibizelomvumi. Ngaphambi kobana abemvumi obandululiweko u-Hlengiwe Mhlaba wabe angutitjhere afundisa isifundo seembalo nesayensi esikolweni esisemakhaya.

Ngemva kwalokho nasele isiskhathi sikhambile wathola iziqu zokumhlonipha zokuba ngudorhodere ku-theology azithola ku-Immanuel University of Theology, lokho bakwenza babobna ikghono lakhe lokuvuma umvumo wesento.Isitayela sakhe sokuvuma sihlukile simenze bonyana abe nabalandeli abangaphezulu kwe-22 000 ku Instagram ngombana wabela abantu ngokukhuthala umvumo wakhe begodu utlola imilayezo ekhuthazako nokubalandeli bakhe.Akanabo abantwana ukungebakhe U-Hlengiwe begodu umumuntu wengubo ongakhange atjhade epilweni.Uyakhuluma ngesiqunto sakhe sokuthi agcoke indandatho emunweni, Uyigcokela bonyana abantu bembsaji bangamsomi, kodwana baphazamiseke babone ngathi utjhadile. Wenza lokho ngombana begade bangamfuni lokha nakasese ngutitjhere kodwana nakathoma ukuba mvumi sele bamfuna uthi lokho kutjengisa bona bafuna imali yakhe ingasi yena.

=== Umsebenzi wakhe kwezokuvuma ===
Ikghono lakhe lokuvuma latholwa ngomunye wabavumi bomvumo wesonto u-Sipho Makhabane ekunguye owamfaka ku-Manxusa productions ekukulapho athoma khona ibizelo lakhe lokuvuma.&lt;ref&gt;[https://audiosure.co.za/hlengiwe-mhlaba/ Hlengiwe Mhlaba | Audiosure]&lt;/ref&gt;Ibizelo lakaHlengiwe Mhlaba lathoma ngonyaka we-2005 nakakhipha i-lbhamu yakhe yesihloko esithi “dwala lami”ekungiyo eyamenzelabona aziwe njengomvumi womvumo wesonto.”UJesu uyalalela” yi-albhamu yakhe alandelal ngayo eyabe ikatelela bona umthandazo ngiwo oyipendulo. Wakhupha enye godu i-albhamu ngo-2007 yona eyabe imumethe ifihlo yokobana umvumo wesonto kufanele uzwakale bunjani, uphethe ukulotjha uzimu, ukudansa Kanye nokubonga.Sele akhiphe ama-albhamu aphezulu kwalikhomba.

=== Ipilo yakhe neentjhijilo ===
Uhlengiwe Mhlaba akhange afihle okwenzeke epilweni yakhe waveza kopbana ukhe walinga ukuzikhunga ngesibanga sokugandelelwa mndeni begodu nangesinga sokuba nobudisi kwezemali. Nanyana kunjalo wasebenzisa izinto akhe aqalana nazo ukuthi abasele umvumo wakhe akwazi ukuthi alekelele abanye abanobududisi abacalene nabo  epilweni ngomvumo wakhe.Umumuntu ofundisa ngokuthi abantu kufanele bazigcine baphilile emkhumbulweni wabo babalekele ukugandeleleka ngombana ukugandeleleka kungenza umuntu binyana abe nomcabango wokuzikhunga.Ngalokho wagcina azibandakanya  ku-“Ungazibulali depression  and Suicide Campaign”.Uthanda ukhuluma nesitjhaba anikele abantu ithemba epilweni.

== Iinkomba ==</text>
      <sha1>sbqk38v4gw1m58d3xfratbtv0vchxrf</sha1>
    </revision>
    <revision>
      <id>5171</id>
      <parentid>5170</parentid>
      <timestamp>2025-08-14T16:08:11Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>5171</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3112" sha1="an0inirvayf08i9k3npku78o81vhc7k" xml:space="preserve">'''U-Hlengiwe Mhlaba''' wabelethwa mhlana amalanga ali-7  kuVelabahlinze ngonyaka we-1973.&lt;ref&gt;[https://thenation.co.za/biography/hlengiwe-mhlaba-biography/ Hlengiwe Mhlaba Biography: Age, Net Worth, Spouse, Songs, Suicide Attempt, Accident - TheNation]&lt;/ref&gt;Wabelethelwa KwaMashu esiphandeni KwaZulu Natal. Umvumi nomtloli womvumo enarheni yeSewula Afrika,yena uvuma [[umvumo wesonto]].Ikhambo lakhe kwezomvumo lathoma asesemncaninakanikela ipilo yakhe kuKhreste. Wathoma ukuthanda ukuvuma asakhula, ithando lakhe lovuma lakhuliswa  makhredte bewagcina alandela ibizelomvumi. Ngaphambi kobana abemvumi obandululiweko u-Hlengiwe Mhlaba wabe angutitjhere afundisa isifundo seembalo nesayensi esikolweni esisemakhaya.

Ngemva kwalokho nasele isiskhathi sikhambile wathola iziqu zokumhlonipha zokuba ngudorhodere ku-theology azithola ku-Immanuel University of Theology, lokho bakwenza babobna ikghono lakhe lokuvuma umvumo wesento.Isitayela sakhe sokuvuma sihlukile simenze bonyana abe nabalandeli abangaphezulu kwe-22 000 ku Instagram ngombana wabela abantu ngokukhuthala umvumo wakhe begodu utlola imilayezo ekhuthazako nokubalandeli bakhe.Akanabo abantwana ukungebakhe U-Hlengiwe begodu umumuntu wengubo ongakhange atjhade epilweni.Uyakhuluma ngesiqunto sakhe sokuthi agcoke indandatho emunweni, Uyigcokela bonyana abantu bembsaji bangamsomi, kodwana baphazamiseke babone ngathi utjhadile. Wenza lokho ngombana begade bangamfuni lokha nakasese ngutitjhere kodwana nakathoma ukuba mvumi sele bamfuna uthi lokho kutjengisa bona bafuna imali yakhe ingasi yena.

=== Umsebenzi wakhe kwezokuvuma ===
Ikghono lakhe lokuvuma latholwa ngomunye wabavumi bomvumo wesonto u-Sipho Makhabane ekunguye owamfaka ku-Manxusa productions ekukulapho athoma khona ibizelo lakhe lokuvuma.&lt;ref&gt;[https://audiosure.co.za/hlengiwe-mhlaba/ Hlengiwe Mhlaba | Audiosure]&lt;/ref&gt;Ibizelo lakaHlengiwe Mhlaba lathoma ngonyaka we-2005 nakakhipha i-lbhamu yakhe yesihloko esithi “dwala lami”ekungiyo eyamenzelabona aziwe njengomvumi womvumo wesonto.”UJesu uyalalela” yi-albhamu yakhe alandelal ngayo eyabe ikatelela bona umthandazo ngiwo oyipendulo. Wakhupha enye godu i-albhamu ngo-2007 yona eyabe imumethe ifihlo yokobana umvumo wesonto kufanele uzwakale bunjani, uphethe ukulotjha uzimu, ukudansa Kanye nokubonga.Sele akhiphe ama-albhamu aphezulu kwalikhomba.

=== Ipilo yakhe neentjhijilo ===
Uhlengiwe Mhlaba akhange afihle okwenzeke epilweni yakhe waveza kopbana ukhe walinga ukuzikhunga ngesibanga sokugandelelwa mndeni begodu nangesinga sokuba nobudisi kwezemali. Nanyana kunjalo wasebenzisa izinto akhe aqalana nazo ukuthi abasele umvumo wakhe akwazi ukuthi alekelele abanye abanobududisi abacalene nabo  epilweni ngomvumo wakhe.Umumuntu ofundisa ngokuthi abantu kufanele bazigcine baphilile emkhumbulweni wabo babalekele ukugandeleleka ngombana ukugandeleleka kungenza umuntu binyana abe nomcabango wokuzikhunga.Ngalokho wagcina azibandakanya  ku-“Ungazibulali depression  and Suicide Campaign”.Uthanda ukhuluma nesitjhaba anikele abantu ithemba epilweni.

== Iinkomba ==
[[Category:Abavumi]]
[[category:Umvumo wekolo]]</text>
      <sha1>an0inirvayf08i9k3npku78o81vhc7k</sha1>
    </revision>
    <revision>
      <id>5172</id>
      <parentid>5171</parentid>
      <timestamp>2025-08-14T16:12:20Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5172</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3402" sha1="hje0mnfi6d9lldcwfigpnzbyt6ed4jx" xml:space="preserve">'''U-Hlengiwe Mhlaba''' wabelethwa mhlana amalanga ali-7  kuVelabahlinze ngonyaka we-1973.&lt;ref&gt;[https://thenation.co.za/biography/hlengiwe-mhlaba-biography/ Hlengiwe Mhlaba Biography: Age, Net Worth, Spouse, Songs, Suicide Attempt, Accident - TheNation]&lt;/ref&gt;Wabelethelwa KwaMashu esiphandeni KwaZulu Natal. Umvumi nomtloli womvumo enarheni yeSewula Afrika,yena uvuma [[umvumo wesonto]].Ikhambo lakhe kwezomvumo lathoma asesemncaninakanikela ipilo yakhe kuKhreste. Wathoma ukuthanda ukuvuma asakhula, ithando lakhe lovuma lakhuliswa  makhredte bewagcina alandela ibizelomvumi. Ngaphambi kobana abemvumi obandululiweko u-Hlengiwe Mhlaba wabe angutitjhere afundisa isifundo seembalo nesayensi esikolweni esisemakhaya.

Ngemva kwalokho nasele isiskhathi sikhambile wathola iziqu zokumhlonipha zokuba ngudorhodere ku-theology azithola ku-Immanuel University of Theology, lokho bakwenza babobna ikghono lakhe lokuvuma umvumo wesento.Isitayela sakhe sokuvuma sihlukile simenze bonyana abe nabalandeli abangaphezulu kwe-22 000 ku Instagram ngombana wabela abantu ngokukhuthala umvumo wakhe begodu utlola imilayezo ekhuthazako nokubalandeli bakhe.Akanabo abantwana ukungebakhe U-Hlengiwe begodu umumuntu wengubo ongakhange atjhade epilweni.Uyakhuluma ngesiqunto sakhe sokuthi agcoke indandatho emunweni, Uyigcokela bonyana abantu bembsaji bangamsomi, kodwana baphazamiseke babone ngathi utjhadile.&lt;ref&gt;https://tidingsinfo.com/hlengiwe-mhlaba/&lt;/ref&gt; Wenza lokho ngombana begade bangamfuni lokha nakasese ngutitjhere kodwana nakathoma ukuba mvumi sele bamfuna uthi lokho kutjengisa bona bafuna imali yakhe ingasi yena.

=== Umsebenzi wakhe kwezokuvuma ===
Ikghono lakhe lokuvuma latholwa ngomunye wabavumi bomvumo wesonto u-Sipho Makhabane ekunguye owamfaka ku-Manxusa productions ekukulapho athoma khona ibizelo lakhe lokuvuma.&lt;ref&gt;[https://audiosure.co.za/hlengiwe-mhlaba/ Hlengiwe Mhlaba | Audiosure]&lt;/ref&gt;Ibizelo lakaHlengiwe Mhlaba lathoma ngonyaka we-2005 nakakhipha i-lbhamu yakhe yesihloko esithi “dwala lami”ekungiyo eyamenzelabona aziwe njengomvumi womvumo wesonto.”UJesu uyalalela” yi-albhamu yakhe alandelal ngayo eyabe ikatelela bona umthandazo ngiwo oyipendulo. Wakhupha enye godu i-albhamu ngo-2007 yona eyabe imumethe ifihlo yokobana umvumo wesonto kufanele uzwakale bunjani, uphethe ukulotjha uzimu, ukudansa Kanye nokubonga.Sele akhiphe ama-albhamu aphezulu kwalikhomba.

=== Ipilo yakhe neentjhijilo ===
Uhlengiwe Mhlaba akhange afihle okwenzeke epilweni yakhe waveza kopbana ukhe walinga ukuzikhunga ngesibanga sokugandelelwa mndeni begodu nangesinga sokuba nobudisi kwezemali. Nanyana kunjalo wasebenzisa izinto akhe aqalana nazo ukuthi abasele umvumo wakhe akwazi ukuthi alekelele abanye abanobududisi abacalene nabo  epilweni ngomvumo wakhe.Umumuntu ofundisa ngokuthi abantu kufanele bazigcine baphilile emkhumbulweni wabo babalekele ukugandeleleka ngombana ukugandeleleka kungenza umuntu binyana abe nomcabango wokuzikhunga.Ngalokho wagcina azibandakanya  ku-“Ungazibulali depression  and Suicide Campaign”.&lt;ref&gt;[https://www.news24.com/drum/celebs/news/hlengiwe-mhlaba-marks-20-years-in-music-after-conquering-depression-a-car-crash-20250306 ICYMI: Hlengiwe Mhlaba marks 20 years in music after conquering depression &amp; a car crash | News24]&lt;/ref&gt;Uthanda ukhuluma nesitjhaba anikele abantu ithemba epilweni.

== Iinkomba ==
[[Category:Abavumi]]
[[category:Umvumo wekolo]]</text>
      <sha1>hje0mnfi6d9lldcwfigpnzbyt6ed4jx</sha1>
    </revision>
    <revision>
      <id>5173</id>
      <parentid>5172</parentid>
      <timestamp>2025-08-14T16:13:43Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5173</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3410" sha1="3zctz2j5m0vxr4bn2gnlmfm40hignml" xml:space="preserve">'''U-Hlengiwe Mhlaba''' wabelethwa mhlana amalanga ali-7  kuMgwengweni ngonyaka we-1973.&lt;ref&gt;[https://thenation.co.za/biography/hlengiwe-mhlaba-biography/ Hlengiwe Mhlaba Biography: Age, Net Worth, Spouse, Songs, Suicide Attempt, Accident - TheNation]&lt;/ref&gt;Wabelethelwa KwaMashu esiphandeni KwaZulu Natal. Umvumi nomtloli womvumo enarheni yeSewula Afrika,yena uvuma [[umvumo wesonto]].Ikhambo lakhe kwezomvumo lathoma asese mncani nakanikela ipilo yakhe kuKhreste. Wathoma ukuthanda ukuvuma asakhula, ithando lakhe lovuma lakhuliswa  makhreste bewagcina alandela ibizelo lokuba mvumi. Ngaphambi kobana abemvumi obandululiweko u-Hlengiwe Mhlaba wabe angutitjhere afundisa isifundo seembalo nesayensi esikolweni esisemakhaya.

Ngemva kwalokho nasele isiskhathi sikhambile wathola iziqu zokumhlonipha zokuba ngudorhodere ku-theology azithola ku-Immanuel University of Theology, lokho bakwenza babobna ikghono lakhe lokuvuma umvumo wesento.Isitayela sakhe sokuvuma sihlukile simenze bonyana abe nabalandeli abangaphezulu kwe-22 000 ku Instagram ngombana wabela abantu ngokukhuthala umvumo wakhe begodu utlola imilayezo ekhuthazako nokubalandeli bakhe.Akanabo abantwana ukungebakhe U-Hlengiwe begodu umumuntu wengubo ongakhange atjhade epilweni.Uyakhuluma ngesiqunto sakhe sokuthi agcoke indandatho emunweni, Uyigcokela bonyana abantu bembsaji bangamsomi, kodwana baphazamiseke babone ngathi utjhadile.&lt;ref&gt;https://tidingsinfo.com/hlengiwe-mhlaba/&lt;/ref&gt; Wenza lokho ngombana begade bangamfuni lokha nakasese ngutitjhere kodwana nakathoma ukuba mvumi sele bamfuna uthi lokho kutjengisa bona bafuna imali yakhe ingasi yena.

=== Umsebenzi wakhe kwezokuvuma ===
Ikghono lakhe lokuvuma latholwa ngomunye wabavumi bomvumo wesonto u-Sipho Makhabane ekunguye owamfaka ku-Manxusa productions ekukulapho athoma khona ibizelo lakhe lokuvuma.&lt;ref&gt;[https://audiosure.co.za/hlengiwe-mhlaba/ Hlengiwe Mhlaba | Audiosure]&lt;/ref&gt;Ibizelo lakaHlengiwe Mhlaba lathoma ngonyaka we-2005 nakakhipha i-lbhamu yakhe yesihloko esithi “dwala lami”ekungiyo eyamenzelabona aziwe njengomvumi womvumo wesonto.”UJesu uyalalela” yi-albhamu yakhe alandelal ngayo eyabe ikatelela bona umthandazo ngiwo oyipendulo. Wakhupha enye godu i-albhamu ngo-2007 yona eyabe imumethe ifihlo yokobana umvumo wesonto kufanele uzwakale bunjani, uphethe ukulotjha uzimu, ukudansa Kanye nokubonga.Sele akhiphe ama-albhamu aphezulu kwalikhomba.

=== Ipilo yakhe neentjhijilo ===
Uhlengiwe Mhlaba akhange afihle okwenzeke epilweni yakhe waveza kopbana ukhe walinga ukuzikhunga ngesibanga sokugandelelwa mndeni begodu nangesinga sokuba nobudisi kwezemali. Nanyana kunjalo wasebenzisa izinto akhe aqalana nazo ukuthi abasele umvumo wakhe akwazi ukuthi alekelele abanye abanobududisi abacalene nabo  epilweni ngomvumo wakhe.Umumuntu ofundisa ngokuthi abantu kufanele bazigcine baphilile emkhumbulweni wabo babalekele ukugandeleleka ngombana ukugandeleleka kungenza umuntu binyana abe nomcabango wokuzikhunga.Ngalokho wagcina azibandakanya  ku-“Ungazibulali depression  and Suicide Campaign”.&lt;ref&gt;[https://www.news24.com/drum/celebs/news/hlengiwe-mhlaba-marks-20-years-in-music-after-conquering-depression-a-car-crash-20250306 ICYMI: Hlengiwe Mhlaba marks 20 years in music after conquering depression &amp; a car crash | News24]&lt;/ref&gt;Uthanda ukhuluma nesitjhaba anikele abantu ithemba epilweni.

== Iinkomba ==
[[Category:Abavumi]]
[[category:Umvumo wekolo]]</text>
      <sha1>3zctz2j5m0vxr4bn2gnlmfm40hignml</sha1>
    </revision>
    <revision>
      <id>5174</id>
      <parentid>5173</parentid>
      <timestamp>2025-08-14T16:14:15Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5174</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3411" sha1="mrz6u76bjamjtd4olrh0zwt8cef9lsa" xml:space="preserve">'''U-Hlengiwe Mhlaba''' wabelethwa mhlana amalanga ali-7  kuMgwengweni ngonyaka we-1973.&lt;ref&gt;[https://thenation.co.za/biography/hlengiwe-mhlaba-biography/ Hlengiwe Mhlaba Biography: Age, Net Worth, Spouse, Songs, Suicide Attempt, Accident - TheNation]&lt;/ref&gt;Wabelethelwa KwaMashu esiphandeni KwaZulu Natal. Umvumi nomtloli womvumo enarheni yeSewula Afrika,yena uvuma [[umvumo wesonto]].Ikhambo lakhe kwezomvumo lathoma asese mncani nakanikela ipilo yakhe kuKhreste. Wathoma ukuthanda ukuvuma asakhula, ithando lakhe lovuma lakhuliswa  makhreste bewagcina alandela ibizelo lokuba mvumi. Ngaphambi kobana abemvumi obandululiweko u-Hlengiwe Mhlaba wabe angutitjhere afundisa isifundo seembalo nesayensi esikolweni esisemakhaya.

Ngemva kwalokho nasele isiskhathi sikhambile wathola iziqu zokumhlonipha zokuba ngudorhodere ku-theology azithola ku-Immanuel University of Theology, lokho bakwenza babobna ikghono lakhe lokuvuma umvumo wesento.Isitayela sakhe sokuvuma sihlukile simenze bonyana abe nabalandeli abangaphezulu kwe-22 000 ku Instagram ngombana wabela abantu ngokukhuthala umvumo wakhe begodu utlola imilayezo ekhuthazako nokubalandeli bakhe.Akanabo abantwana ukungebakhe U-Hlengiwe begodu umumuntu wengubo ongakhange atjhade epilweni.Uyakhuluma ngesiqunto sakhe sokuthi agcoke indandatho emunweni, Uyigcokela bonyana abantu bembsaji bangamsomi, kodwana baphazamiseke babone ngathi utjhadile.&lt;ref&gt;https://tidingsinfo.com/hlengiwe-mhlaba/&lt;/ref&gt; Wenza lokho ngombana begade bangamfuni lokha nakasese ngutitjhere kodwana nakathoma ukuba mvumi sele bamfuna uthi lokho kutjengisa bona bafuna imali yakhe ingasi yena.

=== Umsebenzi wakhe kwezokuvuma ===
Ikghono lakhe lokuvuma latholwa ngomunye wabavumi bomvumo wesonto u-Sipho Makhabane ekunguye owamfaka ku-Manxusa productions ekukulapho athoma khona ibizelo lakhe lokuvuma.&lt;ref&gt;[https://audiosure.co.za/hlengiwe-mhlaba/ Hlengiwe Mhlaba | Audiosure]&lt;/ref&gt;Ibizelo lakaHlengiwe Mhlaba lathoma ngonyaka we-2005 nakakhipha i-albhamu yakhe yesihloko esithi “dwala lami”ekungiyo eyamenzelabona aziwe njengomvumi womvumo wesonto.”UJesu uyalalela” yi-albhamu yakhe alandelal ngayo eyabe ikatelela bona umthandazo ngiwo oyipendulo. Wakhupha enye godu i-albhamu ngo-2007 yona eyabe imumethe ifihlo yokobana umvumo wesonto kufanele uzwakale bunjani, uphethe ukulotjha uzimu, ukudansa Kanye nokubonga.Sele akhiphe ama-albhamu aphezulu kwalikhomba.

=== Ipilo yakhe neentjhijilo ===
Uhlengiwe Mhlaba akhange afihle okwenzeke epilweni yakhe waveza kopbana ukhe walinga ukuzikhunga ngesibanga sokugandelelwa mndeni begodu nangesinga sokuba nobudisi kwezemali. Nanyana kunjalo wasebenzisa izinto akhe aqalana nazo ukuthi abasele umvumo wakhe akwazi ukuthi alekelele abanye abanobududisi abacalene nabo  epilweni ngomvumo wakhe.Umumuntu ofundisa ngokuthi abantu kufanele bazigcine baphilile emkhumbulweni wabo babalekele ukugandeleleka ngombana ukugandeleleka kungenza umuntu binyana abe nomcabango wokuzikhunga.Ngalokho wagcina azibandakanya  ku-“Ungazibulali depression  and Suicide Campaign”.&lt;ref&gt;[https://www.news24.com/drum/celebs/news/hlengiwe-mhlaba-marks-20-years-in-music-after-conquering-depression-a-car-crash-20250306 ICYMI: Hlengiwe Mhlaba marks 20 years in music after conquering depression &amp; a car crash | News24]&lt;/ref&gt;Uthanda ukhuluma nesitjhaba anikele abantu ithemba epilweni.

== Iinkomba ==
[[Category:Abavumi]]
[[category:Umvumo wekolo]]</text>
      <sha1>mrz6u76bjamjtd4olrh0zwt8cef9lsa</sha1>
    </revision>
    <revision>
      <id>5175</id>
      <parentid>5174</parentid>
      <timestamp>2025-08-14T16:16:40Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5175</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3419" sha1="9erm515o9nr3bbgy5tnihej2cwgbq5z" xml:space="preserve">'''U-Hlengiwe Mhlaba''' wabelethwa mhlana amalanga ali-7  kuMgwengweni ngonyaka we-1973.&lt;ref&gt;[https://thenation.co.za/biography/hlengiwe-mhlaba-biography/ Hlengiwe Mhlaba Biography: Age, Net Worth, Spouse, Songs, Suicide Attempt, Accident - TheNation]&lt;/ref&gt;Wabelethelwa KwaMashu esiphandeni KwaZulu Natal. Umvumi nomtloli womvumo enarheni yeSewula Afrika,yena uvuma [[umvumo wesonto]].Ikhambo lakhe kwezomvumo lathoma asese mncani nakanikela ipilo yakhe kuKhreste. Wathoma ukuthanda ukuvuma asakhula, ithando lakhe lovuma lakhuliswa  makhreste bewagcina alandela ibizelo lokuba mvumi. Ngaphambi kobana abemvumi obandululiweko u-Hlengiwe Mhlaba wabe angutitjhere afundisa isifundo seembalo nesayensi esikolweni esisemakhaya.

Ngemva kwalokho nasele isiskhathi sikhambile wathola iziqu zokumhlonipha zokuba ngudorhodere ku-''theology'' azithola ku-''Immanuel University of Theology'', lokho bakwenza babobna ikghono lakhe lokuvuma umvumo wesento. Isitayela sakhe sokuvuma sihlukile simenze bonyana abe nabalandeli abangaphezulu kwe-22 000 ku Instagram ngombana wabela abantu ngokukhuthala umvumo wakhe begodu utlola imilayezo ekhuthazako nokubalandeli bakhe.Akanabo abantwana ukungebakhe U-Hlengiwe begodu umumuntu wengubo ongakhange atjhade epilweni.Uyakhuluma ngesiqunto sakhe sokuthi agcoke indandatho emunweni, Uyigcokela bonyana abantu bembsaji bangamsomi, kodwana baphazamiseke babone ngathi utjhadile.&lt;ref&gt;https://tidingsinfo.com/hlengiwe-mhlaba/&lt;/ref&gt; Wenza lokho ngombana begade bangamfuni lokha nakasese ngutitjhere kodwana nakathoma ukuba mvumi sele bamfuna uthi lokho kutjengisa bona bafuna imali yakhe ingasi yena.

=== Umsebenzi wakhe kwezokuvuma ===
Ikghono lakhe lokuvuma latholwa ngomunye wabavumi bomvumo wesonto u-Sipho Makhabane ekunguye owamfaka ku-Manxusa productions ekukulapho athoma khona ibizelo lakhe lokuvuma.&lt;ref&gt;[https://audiosure.co.za/hlengiwe-mhlaba/ Hlengiwe Mhlaba | Audiosure]&lt;/ref&gt;Ibizelo lakaHlengiwe Mhlaba lathoma ngonyaka we-2005 nakakhipha i-albhamu yakhe yesihloko esithi “dwala lami”ekungiyo eyamenzelabona aziwe njengomvumi womvumo wesonto.”UJesu uyalalela” yi-albhamu yakhe alandelal ngayo eyabe ikatelela bona umthandazo ngiwo oyipendulo. Wakhupha enye godu i-albhamu ngo-2007 yona eyabe imumethe ifihlo yokobana umvumo wesonto kufanele uzwakale bunjani, uphethe ukulotjha uzimu, ukudansa Kanye nokubonga.Sele akhiphe ama-albhamu aphezulu kwalikhomba.

=== Ipilo yakhe neentjhijilo ===
Uhlengiwe Mhlaba akhange afihle okwenzeke epilweni yakhe waveza kobana ukhe walinga ukuzikhunga ngesibanga sokugandelelwa mndeni begodu nangesinga sokuba nobudisi kwezemali. Nanyana kunjalo wasebenzisa izinto akhe aqalana nazo ukuthi abasele umvumo wakhe akwazi ukuthi alekelele abanye abanobududisi abacalene nabo  epilweni ngomvumo wakhe.Umumuntu ofundisa ngokuthi abantu kufanele bazigcine baphilile emkhumbulweni wabo babalekele ukugandeleleka ngombana ukugandeleleka kungenza umuntu binyana abe nomcabango wokuzikhunga.Ngalokho wagcina azibandakanya  ku-“Ungazibulali depression  and Suicide Campaign”.&lt;ref&gt;[https://www.news24.com/drum/celebs/news/hlengiwe-mhlaba-marks-20-years-in-music-after-conquering-depression-a-car-crash-20250306 ICYMI: Hlengiwe Mhlaba marks 20 years in music after conquering depression &amp; a car crash | News24]&lt;/ref&gt;Uthanda ukhuluma nesitjhaba anikele abantu ithemba epilweni.

== Iinkomba ==
[[Category:Abavumi]]
[[category:Umvumo wekolo]]</text>
      <sha1>9erm515o9nr3bbgy5tnihej2cwgbq5z</sha1>
    </revision>
    <revision>
      <id>5178</id>
      <parentid>5175</parentid>
      <timestamp>2025-08-14T16:28:40Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5178</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3418" sha1="9tzeaxihnnel087rrugdg23g84p67rm" xml:space="preserve">'''U-Hlengiwe Mhlaba''' wabelethwa mhlana amalanga ali-7  kuMgwengweni ngonyaka we-1973.&lt;ref&gt;[https://thenation.co.za/biography/hlengiwe-mhlaba-biography/ Hlengiwe Mhlaba Biography: Age, Net Worth, Spouse, Songs, Suicide Attempt, Accident - TheNation]&lt;/ref&gt;Wabelethelwa KwaMashu esiphandeni KwaZulu Natal. Umvumi nomtloli womvumo enarheni yeSewula Afrika,yena uvuma [[umvumo wesonto]].Ikhambo lakhe kwezomvumo lathoma asese mncani nakathoma ukulandela ubuKhreste. Wathoma ukuthanda ukuvuma asakhula, ithando lakhe lovuma lakhuliswa  makhreste bewagcina alandela ibizelo lokuba mvumi. Ngaphambi kobana abemvumi obandululiweko u-Hlengiwe Mhlaba wabe angutitjhere afundisa isifundo seembalo nesayensi esikolweni esisemakhaya.

Ngemva kwalokho nasele isiskhathi sikhambile wathola iziqu zokumhlonipha zokuba ngudorhodere ku-''theology'' azithola ku-''Immanuel University of Theology'', lokho bakwenza babobna ikghono lakhe lokuvuma umvumo wesento. Isitayela sakhe sokuvuma sihlukile simenze bonyana abe nabalandeli abangaphezulu kwe-22 000 ku Instagram ngombana wabela abantu ngokukhuthala umvumo wakhe begodu utlola imilayezo ekhuthazako nokubalandeli bakhe.Akanabo abantwana ukungebakhe U-Hlengiwe begodu umumuntu wengubo ongakhange atjhade epilweni.Uyakhuluma ngesiqunto sakhe sokuthi agcoke indandatho emunweni, Uyigcokela bonyana abantu bembsaji bangamsomi, kodwana baphazamiseke babone ngathi utjhadile.&lt;ref&gt;https://tidingsinfo.com/hlengiwe-mhlaba/&lt;/ref&gt; Wenza lokho ngombana begade bangamfuni lokha nakasese ngutitjhere kodwana nakathoma ukuba mvumi sele bamfuna uthi lokho kutjengisa bona bafuna imali yakhe ingasi yena.

=== Umsebenzi wakhe kwezokuvuma ===
Ikghono lakhe lokuvuma latholwa ngomunye wabavumi bomvumo wesonto u-Sipho Makhabane ekunguye owamfaka ku-Manxusa productions ekukulapho athoma khona ibizelo lakhe lokuvuma.&lt;ref&gt;[https://audiosure.co.za/hlengiwe-mhlaba/ Hlengiwe Mhlaba | Audiosure]&lt;/ref&gt;Ibizelo lakaHlengiwe Mhlaba lathoma ngonyaka we-2005 nakakhipha i-albhamu yakhe yesihloko esithi “dwala lami”ekungiyo eyamenzelabona aziwe njengomvumi womvumo wesonto.”UJesu uyalalela” yi-albhamu yakhe alandelal ngayo eyabe ikatelela bona umthandazo ngiwo oyipendulo. Wakhupha enye godu i-albhamu ngo-2007 yona eyabe imumethe ifihlo yokobana umvumo wesonto kufanele uzwakale bunjani, uphethe ukulotjha uzimu, ukudansa Kanye nokubonga.Sele akhiphe ama-albhamu aphezulu kwalikhomba.

=== Ipilo yakhe neentjhijilo ===
Uhlengiwe Mhlaba akhange afihle okwenzeke epilweni yakhe waveza kobana ukhe walinga ukuzikhunga ngesibanga sokugandelelwa mndeni begodu nangesinga sokuba nobudisi kwezemali. Nanyana kunjalo wasebenzisa izinto akhe aqalana nazo ukuthi abasele umvumo wakhe akwazi ukuthi alekelele abanye abanobududisi abacalene nabo  epilweni ngomvumo wakhe.Umumuntu ofundisa ngokuthi abantu kufanele bazigcine baphilile emkhumbulweni wabo babalekele ukugandeleleka ngombana ukugandeleleka kungenza umuntu binyana abe nomcabango wokuzikhunga.Ngalokho wagcina azibandakanya  ku-“Ungazibulali depression  and Suicide Campaign”.&lt;ref&gt;[https://www.news24.com/drum/celebs/news/hlengiwe-mhlaba-marks-20-years-in-music-after-conquering-depression-a-car-crash-20250306 ICYMI: Hlengiwe Mhlaba marks 20 years in music after conquering depression &amp; a car crash | News24]&lt;/ref&gt;Uthanda ukhuluma nesitjhaba anikele abantu ithemba epilweni.

== Iinkomba ==
[[Category:Abavumi]]
[[category:Umvumo wekolo]]</text>
      <sha1>9tzeaxihnnel087rrugdg23g84p67rm</sha1>
    </revision>
    <revision>
      <id>5229</id>
      <parentid>5178</parentid>
      <timestamp>2025-08-25T09:35:11Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5229</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3429" sha1="dytoeb8ov7clht7okvyj7zjrndl9znt" xml:space="preserve">'''U-Hlengiwe Mhlaba''' wabelethwa mhlana amalanga ali-7  kuMgwengweni ngonyaka we-1973.&lt;ref&gt;[https://thenation.co.za/biography/hlengiwe-mhlaba-biography/ Hlengiwe Mhlaba Biography: Age, Net Worth, Spouse, Songs, Suicide Attempt, Accident - TheNation]&lt;/ref&gt;Wabelethelwa endaweni yaKwaMashu esiphandeni seKwaZulu Natal. Umvumi nomtloli womvumo enarheni yeSewula Afrika,yena uvuma umvumo wevangeli.Ikhambo lakhe kwezomvumo lathoma asese mncani nakathoma ukulandela ubuKhreste. Wathoma ukuthanda ukuvuma asakhula, ithando lakhe lovuma lakhuliswa  makhreste bewagcina alandela ibizelo lokuba mvumi. Ngaphambi kobana abemvumi obandululiweko u-Hlengiwe Mhlaba wabe angutitjhere afundisa isifundo seembalo nesayensi esikolweni esisemakhaya.

Ngemva kwalokho nasele isikhathi sikhambile wathola iziqu zokumhlonipha zokuba ngudorhodere ku-''theology'' azithola ku-''Immanuel University of Theology'', lokho bakwenza baboba ikghono lakhe lokuvuma umvumo wevangeli. Isitayela sakhe sokuvuma sihlukile simenze bonyana abe nabalandeli abangaphezulu kwe-22 000 ku Instagram ngombana wabela abantu ngokukhuthala umvumo wakhe begodu utlola imilayezo ekhuthazako nokubalandeli bakhe.Akanabo abantwana ukungebakhe U-Hlengiwe begodu umumuntu wengubo ongakhange atjhade epilweni.Uyakhuluma ngesiqunto sakhe sokuthi agcoke indandatho emunweni, Uyigcokela bonyana abantu bembsaji bangamsomi, kodwana baphazamiseke babone ngathi utjhadile.&lt;ref&gt;https://tidingsinfo.com/hlengiwe-mhlaba/&lt;/ref&gt; Wenza lokho ngombana begade bangamfuni lokha nakasese ngutitjhere kodwana nakathoma ukuba mvumi sele bamfuna uthi lokho kutjengisa bona bafuna imali yakhe ingasi yena.

=== Umsebenzi wakhe kwezokuvuma ===
Ikghono lakhe lokuvuma latholwa ngomunye wabavumi bomvumo wesonto u-Sipho Makhabane ekunguye owamfaka ku-Manxusa productions ekukulapho athoma khona ibizelo lakhe lokuvuma.&lt;ref&gt;[https://audiosure.co.za/hlengiwe-mhlaba/ Hlengiwe Mhlaba | Audiosure]&lt;/ref&gt;Ibizelo lakaHlengiwe Mhlaba lathoma ngonyaka we-2005 nakakhipha i-albhamu yakhe yesihloko esithi “dwala lami”ekungiyo eyamenzelabona aziwe njengomvumi womvumo wesonto.”UJesu uyalalela” yi-albhamu yakhe alandelal ngayo eyabe ikatelela bona umthandazo ngiwo oyipendulo. Wakhupha enye godu i-albhamu ngo-2007 yona eyabe imumethe ifihlo yokobana umvumo wesonto kufanele uzwakale bunjani, uphethe ukulotjha uzimu, ukudansa Kanye nokubonga.Sele akhiphe ama-albhamu aphezulu kwalikhomba.

=== Ipilo yakhe neentjhijilo ===
Uhlengiwe Mhlaba akhange afihle okwenzeke epilweni yakhe waveza kobana ukhe walinga ukuzikhunga ngesibanga sokugandelelwa mndeni begodu nangesinga sokuba nobudisi kwezemali. Nanyana kunjalo wasebenzisa izinto akhe aqalana nazo ukuthi abasele umvumo wakhe akwazi ukuthi alekelele abanye abanobududisi abacalene nabo  epilweni ngomvumo wakhe.Umumuntu ofundisa ngokuthi abantu kufanele bazigcine baphilile emkhumbulweni wabo babalekele ukugandeleleka ngombana ukugandeleleka kungenza umuntu binyana abe nomcabango wokuzikhunga.Ngalokho wagcina azibandakanya  ku-“Ungazibulali depression  and Suicide Campaign”.&lt;ref&gt;[https://www.news24.com/drum/celebs/news/hlengiwe-mhlaba-marks-20-years-in-music-after-conquering-depression-a-car-crash-20250306 ICYMI: Hlengiwe Mhlaba marks 20 years in music after conquering depression &amp; a car crash | News24]&lt;/ref&gt;Uthanda ukhuluma nesitjhaba anikele abantu ithemba epilweni.

== Iinkomba ==
[[Category:Abavumi]]
[[category:Umvumo wekolo]]</text>
      <sha1>dytoeb8ov7clht7okvyj7zjrndl9znt</sha1>
    </revision>
    <revision>
      <id>5230</id>
      <parentid>5229</parentid>
      <timestamp>2025-08-25T09:35:56Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5230</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3430" sha1="jbtr427a14dbekl78xzdp08gvhexl52" xml:space="preserve">'''U-Hlengiwe Mhlaba''' wabelethwa mhlana amalanga ali-7  kuMgwengweni ngonyaka we-1973.&lt;ref&gt;[https://thenation.co.za/biography/hlengiwe-mhlaba-biography/ Hlengiwe Mhlaba Biography: Age, Net Worth, Spouse, Songs, Suicide Attempt, Accident - TheNation]&lt;/ref&gt;Wabelethelwa endaweni yaKwaMashu esiphandeni seKwaZulu Natal. Umvumi nomtloli womvumo enarheni yeSewula Afrika,yena uvuma umvumo wevangeli.Ikhambo lakhe kwezomvumo lathoma asese mncani nakathoma ukulandela ubuKhreste. Wathoma ukuthanda ukuvuma asakhula, ithando lakhe lovuma lakhuliswa  makhreste bewagcina alandela ibizelo lokuba mvumi. Ngaphambi kobana abemvumi obandululiweko u-Hlengiwe Mhlaba wabe angutitjhere afundisa isifundo seembalo nesayensi esikolweni esisemakhaya.

Ngemva kwalokho nasele isikhathi sikhambile wathola iziqu zokumhlonipha zokuba ngudorhodere ku-''theology'' azithola ku-''Immanuel University of Theology'', lokho bakwenza baboba ikghono lakhe lokuvuma umvumo wevangeli. Isitayela sakhe sokuvuma sihlukile simenze bonyana abe nabalandeli abangaphezulu kwe-22 000 ku Instagram ngombana wabela abantu ngokukhuthala umvumo wakhe begodu utlola imilayezo ekhuthazako nokubalandeli bakhe.Akanabo abantwana ukungebakhe U-Hlengiwe begodu umumuntu wengubo ongakhange atjhade epilweni.Uyakhuluma ngesiqunto sakhe sokuthi agcoke indandatho emunweni, Uyigcokela bonyana abantu bembsaji bangamsomi, kodwana baphazamiseke babone ngathi utjhadile.&lt;ref&gt;https://tidingsinfo.com/hlengiwe-mhlaba/&lt;/ref&gt; Wenza lokho ngombana begade bangamfuni lokha nakasese ngutitjhere kodwana nakathoma ukuba mvumi sele bamfuna uthi lokho kutjengisa bona bafuna imali yakhe ingasi yena.

=== Umsebenzi wakhe kwezokuvuma ===
Ikghono lakhe lokuvuma latholwa ngomunye wabavumi bomvumo wevangeli u-Sipho Makhabane ekunguye owamfaka ku-Manxusa productions ekukulapho athoma khona ibizelo lakhe lokuvuma.&lt;ref&gt;[https://audiosure.co.za/hlengiwe-mhlaba/ Hlengiwe Mhlaba | Audiosure]&lt;/ref&gt;Ibizelo lakaHlengiwe Mhlaba lathoma ngonyaka we-2005 nakakhipha i-albhamu yakhe yesihloko esithi “dwala lami”ekungiyo eyamenzelabona aziwe njengomvumi womvumo wesonto.”UJesu uyalalela” yi-albhamu yakhe alandela ngayo eyabe ikatelela bona umthandazo ngiwo oyipendulo. Wakhupha enye godu i-albhamu ngo-2007 yona eyabe imumethe ifihlo yokobana umvumo wesonto kufanele uzwakale bunjani, uphethe ukulotjha uzimu, ukudansa Kanye nokubonga.Sele akhiphe ama-albhamu aphezulu kwalikhomba.

=== Ipilo yakhe neentjhijilo ===
Uhlengiwe Mhlaba akhange afihle okwenzeke epilweni yakhe waveza kobana ukhe walinga ukuzikhunga ngesibanga sokugandelelwa mndeni begodu nangesinga sokuba nobudisi kwezemali. Nanyana kunjalo wasebenzisa izinto akhe aqalana nazo ukuthi abasele umvumo wakhe akwazi ukuthi alekelele abanye abanobududisi abacalene nabo  epilweni ngomvumo wakhe.Umumuntu ofundisa ngokuthi abantu kufanele bazigcine baphilile emkhumbulweni wabo babalekele ukugandeleleka ngombana ukugandeleleka kungenza umuntu binyana abe nomcabango wokuzikhunga.Ngalokho wagcina azibandakanya  ku-“Ungazibulali depression  and Suicide Campaign”.&lt;ref&gt;[https://www.news24.com/drum/celebs/news/hlengiwe-mhlaba-marks-20-years-in-music-after-conquering-depression-a-car-crash-20250306 ICYMI: Hlengiwe Mhlaba marks 20 years in music after conquering depression &amp; a car crash | News24]&lt;/ref&gt;Uthanda ukhuluma nesitjhaba anikele abantu ithemba epilweni.

== Iinkomba ==
[[Category:Abavumi]]
[[category:Umvumo wekolo]]</text>
      <sha1>jbtr427a14dbekl78xzdp08gvhexl52</sha1>
    </revision>
    <revision>
      <id>5240</id>
      <parentid>5230</parentid>
      <timestamp>2025-08-30T10:25:32Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5240</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3434" sha1="jhqggo17r8lvpk8qyi1m0z9pnqalryc" xml:space="preserve">'''U-Hlengiwe Mhlaba''' wabelethwa mhlana amalanga ali-7  kuMgwengweni ngonyaka we-1973.&lt;ref&gt;[https://thenation.co.za/biography/hlengiwe-mhlaba-biography/ Hlengiwe Mhlaba Biography: Age, Net Worth, Spouse, Songs, Suicide Attempt, Accident - TheNation]&lt;/ref&gt;Wabelethelwa endaweni yaKwaMashu esiphandeni seKwaZulu Natal. Umvumi nomtloli womvumo enarheni yeSewula Afrika,yena uvuma umvumo wevangeli.Ikhambo lakhe kwezomvumo lathoma asese mncani nakathoma ukulandela [[ubukresite]]. Wathoma ukuthanda ukuvuma asakhula, ithando lakhe lovuma lakhuliswa  makhreste bewagcina alandela ibizelo lokuba mvumi. Ngaphambi kobana abemvumi obandululiweko u-Hlengiwe Mhlaba wabe angutitjhere afundisa isifundo seembalo nesayensi esikolweni esisemakhaya.

Ngemva kwalokho nasele isikhathi sikhambile wathola iziqu zokumhlonipha zokuba ngudorhodere ku-''theology'' azithola ku-''Immanuel University of Theology'', lokho bakwenza baboba ikghono lakhe lokuvuma umvumo wevangeli. Isitayela sakhe sokuvuma sihlukile simenze bonyana abe nabalandeli abangaphezulu kwe-22 000 ku Instagram ngombana wabela abantu ngokukhuthala umvumo wakhe begodu utlola imilayezo ekhuthazako nokubalandeli bakhe.Akanabo abantwana ukungebakhe U-Hlengiwe begodu umumuntu wengubo ongakhange atjhade epilweni.Uyakhuluma ngesiqunto sakhe sokuthi agcoke indandatho emunweni, Uyigcokela bonyana abantu bembsaji bangamsomi, kodwana baphazamiseke babone ngathi utjhadile.&lt;ref&gt;https://tidingsinfo.com/hlengiwe-mhlaba/&lt;/ref&gt; Wenza lokho ngombana begade bangamfuni lokha nakasese ngutitjhere kodwana nakathoma ukuba mvumi sele bamfuna uthi lokho kutjengisa bona bafuna imali yakhe ingasi yena.

=== Umsebenzi wakhe kwezokuvuma ===
Ikghono lakhe lokuvuma latholwa ngomunye wabavumi bomvumo wevangeli u-Sipho Makhabane ekunguye owamfaka ku-Manxusa productions ekukulapho athoma khona ibizelo lakhe lokuvuma.&lt;ref&gt;[https://audiosure.co.za/hlengiwe-mhlaba/ Hlengiwe Mhlaba | Audiosure]&lt;/ref&gt;Ibizelo lakaHlengiwe Mhlaba lathoma ngonyaka we-2005 nakakhipha i-albhamu yakhe yesihloko esithi “dwala lami”ekungiyo eyamenzelabona aziwe njengomvumi womvumo wesonto.”UJesu uyalalela” yi-albhamu yakhe alandela ngayo eyabe ikatelela bona umthandazo ngiwo oyipendulo. Wakhupha enye godu i-albhamu ngo-2007 yona eyabe imumethe ifihlo yokobana umvumo wesonto kufanele uzwakale bunjani, uphethe ukulotjha uzimu, ukudansa Kanye nokubonga.Sele akhiphe ama-albhamu aphezulu kwalikhomba.

=== Ipilo yakhe neentjhijilo ===
Uhlengiwe Mhlaba akhange afihle okwenzeke epilweni yakhe waveza kobana ukhe walinga ukuzikhunga ngesibanga sokugandelelwa mndeni begodu nangesinga sokuba nobudisi kwezemali. Nanyana kunjalo wasebenzisa izinto akhe aqalana nazo ukuthi abasele umvumo wakhe akwazi ukuthi alekelele abanye abanobududisi abacalene nabo  epilweni ngomvumo wakhe.Umumuntu ofundisa ngokuthi abantu kufanele bazigcine baphilile emkhumbulweni wabo babalekele ukugandeleleka ngombana ukugandeleleka kungenza umuntu binyana abe nomcabango wokuzikhunga.Ngalokho wagcina azibandakanya  ku-“Ungazibulali depression  and Suicide Campaign”.&lt;ref&gt;[https://www.news24.com/drum/celebs/news/hlengiwe-mhlaba-marks-20-years-in-music-after-conquering-depression-a-car-crash-20250306 ICYMI: Hlengiwe Mhlaba marks 20 years in music after conquering depression &amp; a car crash | News24]&lt;/ref&gt;Uthanda ukhuluma nesitjhaba anikele abantu ithemba epilweni.

== Iinkomba ==
[[Category:Abavumi]]
[[category:Umvumo wekolo]]</text>
      <sha1>jhqggo17r8lvpk8qyi1m0z9pnqalryc</sha1>
    </revision>
    <revision>
      <id>5714</id>
      <parentid>5240</parentid>
      <timestamp>2025-09-07T12:17:08Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5714</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3437" sha1="bwo2pjdhvhv6tp7u5zodlaixosdyk5h" xml:space="preserve">'''U-Hlengiwe Mhlaba''' wabelethwa mhlana amalanga ali-7  kuMgwengweni ngonyaka we-1973.&lt;ref&gt;[https://thenation.co.za/biography/hlengiwe-mhlaba-biography/ Hlengiwe Mhlaba Biography: Age, Net Worth, Spouse, Songs, Suicide Attempt, Accident - TheNation]&lt;/ref&gt;Wabelethelwa endaweni yaKwaMashu esiphandeni seKwaZulu Natal. Umvumi nomtloli womvumo enarheni yeSewula Afrika,yena uvuma umvumo wevangeli.Ikhambo lakhe kwezomvumo lathoma asese mncani nakathoma ukulandela [[ubukresite]]. Wathoma ukuthanda ukuvuma asakhula, ithando lakhe lovuma lakhuliswa  makhreste bewagcina alandela ibizelo lokuba mvumi. Ngaphambi kobana abemvumi obandululiweko u-Hlengiwe Mhlaba wabe angutitjhere afundisa isifundo seembalo nesayensi esikolweni esisemakhaya.

Ngemva kwalokho nasele isikhathi sikhambile wathola iziqu zokumhlonipha zokuba ngudorhodere ku-''theology'' azithola ku-''Immanuel University of Theology'', lokho bakwenza baboba ikghono lakhe lokuvuma umvumo wevangeli. Isitayela sakhe sokuvuma sihlukile simenze bonyana abe nabalandeli abangaphezulu kwe-22 000 ku Instagram ngombana wabela abantu ngokukhuthala umvumo wakhe begodu utlola imilayezo ekhuthazako nokubalandeli bakhe.Akanabo abantwana ukungebakhe U-Hlengiwe begodu umumuntu wengubo ongakhange atjhade epilweni.Uyakhuluma ngesiqunto sakhe sokuthi agcoke indandatho emunweni, Uyigcokela bonyana abantu bembaji bangamsomi, kodwana baphazamiseke babone ngathi utjhadile.&lt;ref&gt;https://tidingsinfo.com/hlengiwe-mhlaba/&lt;/ref&gt; Wenza lokho ngombana begade bangamfuni lokha nakasese ngutitjhere kodwana nakathoma ukuba mvumi sele bamfuna uthi lokho kutjengisa bona bafuna imali yakhe ingasi yena.

=== Umsebenzi wakhe kwezokuvuma ===
Ikghono lakhe lokuvuma latholwa ngomunye wabavumi bomvumo wevangeli u-[[Sipho Makhabane]] ekunguye owamfaka ku-Manxusa productions ekukulapho athoma khona ibizelo lakhe lokuvuma.&lt;ref&gt;[https://audiosure.co.za/hlengiwe-mhlaba/ Hlengiwe Mhlaba | Audiosure]&lt;/ref&gt;Ibizelo lakaHlengiwe Mhlaba lathoma ngonyaka we-2005 nakakhipha i-albhamu yakhe yesihloko esithi “dwala lami”ekungiyo eyamenzelabona aziwe njengomvumi womvumo wesonto.”UJesu uyalalela” yi-albhamu yakhe alandela ngayo eyabe ikatelela bona umthandazo ngiwo oyipendulo. Wakhupha enye godu i-albhamu ngo-2007 yona eyabe imumethe ifihlo yokobana umvumo wesonto kufanele uzwakale bunjani, uphethe ukulotjha uzimu, ukudansa Kanye nokubonga.Sele akhiphe ama-albhamu aphezulu kwalikhomba.

=== Ipilo yakhe neentjhijilo ===
Uhlengiwe Mhlaba akhange afihle okwenzeke epilweni yakhe waveza kobana ukhe walinga ukuzikhunga ngesibanga sokugandelelwa mndeni begodu nangesinga sokuba nobudisi kwezemali. Nanyana kunjalo wasebenzisa izinto akhe aqalana nazo ukuthi abasele umvumo wakhe akwazi ukuthi alekelele abanye abanobududisi abacalene nabo  epilweni ngomvumo wakhe.Umumuntu ofundisa ngokuthi abantu kufanele bazigcine baphilile emkhumbulweni wabo babalekele ukugandeleleka ngombana ukugandeleleka kungenza umuntu binyana abe nomcabango wokuzikhunga.Ngalokho wagcina azibandakanya  ku-“Ungazibulali depression  and Suicide Campaign”.&lt;ref&gt;[https://www.news24.com/drum/celebs/news/hlengiwe-mhlaba-marks-20-years-in-music-after-conquering-depression-a-car-crash-20250306 ICYMI: Hlengiwe Mhlaba marks 20 years in music after conquering depression &amp; a car crash | News24]&lt;/ref&gt;Uthanda ukhuluma nesitjhaba anikele abantu ithemba epilweni.

== Iinkomba ==
[[Category:Abavumi]]
[[category:Umvumo wekolo]]</text>
      <sha1>bwo2pjdhvhv6tp7u5zodlaixosdyk5h</sha1>
    </revision>
    <revision>
      <id>5715</id>
      <parentid>5714</parentid>
      <timestamp>2025-09-07T12:17:40Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5715</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3440" sha1="q5gymjspgh032za82fad6fygq936qpr" xml:space="preserve">'''U-Hlengiwe Mhlaba''' wabelethwa mhlana amalanga ali-7  kuMgwengweni ngonyaka we-1973.&lt;ref&gt;[https://thenation.co.za/biography/hlengiwe-mhlaba-biography/ Hlengiwe Mhlaba Biography: Age, Net Worth, Spouse, Songs, Suicide Attempt, Accident - TheNation]&lt;/ref&gt;Wabelethelwa endaweni yaKwaMashu esiphandeni seKwaZulu Natal. Umvumi nomtloli womvumo enarheni yeSewula Afrika,yena uvuma umvumo wevangeli.Ikhambo lakhe kwezomvumo lathoma asese mncani nakathoma ukulandela [[ubukresite]]. Wathoma ukuthanda ukuvuma asakhula, ithando lakhe lovuma lakhuliswa  makhreste bewagcina alandela ibizelo lokuba mvumi. Ngaphambi kobana abemvumi obandululiweko u-Hlengiwe Mhlaba wabe angutitjhere afundisa isifundo seembalo nesayensi esikolweni esisemakhaya.

Ngemva kwalokho nasele isikhathi sikhambile wathola iziqu zokumhlonipha zokuba ngudorhodere ku-''theology'' azithola ku-''Immanuel University of Theology'', lokho bakwenza baboba ikghono lakhe lokuvuma umvumo wevangeli. Isitayela sakhe sokuvuma sihlukile simenze bonyana abe nabalandeli abangaphezulu kwe-22 000 ku Instagram ngombana wabela abantu ngokukhuthala umvumo wakhe begodu utlola imilayezo ekhuthazako nokubalandeli bakhe.Akanabo abantwana ukungebakhe U-Hlengiwe begodu umumuntu wengubo ongakhange atjhade epilweni.Uyakhuluma ngesiqunto sakhe sokuthi agcoke indandatho emunweni, Uyigcokela bonyana abantu bembaji bangamsomi, kodwana baphazamiseke babone ngathi utjhadile.&lt;ref&gt;https://tidingsinfo.com/hlengiwe-mhlaba/&lt;/ref&gt; Wenza lokho ngombana begade bangamfuni lokha nakasese ngutitjhere kodwana nakathoma ukuba mvumi sele bamfuna uthi lokho kutjengisa bona bafuna imali yakhe ingasi yena.

=== Umsebenzi wakhe kwezokuvuma ===
Ikghono lakhe lokuvuma latholwa ngomunye wabavumi bomvumo wevangeli u-[[Sipho Makhabane]] ekunguye owamfaka ku-Manxusa productions ekukulapho athoma khona ibizelo lakhe lokuvuma.&lt;ref&gt;[https://audiosure.co.za/hlengiwe-mhlaba/ Hlengiwe Mhlaba | Audiosure]&lt;/ref&gt;Ibizelo lakaHlengiwe Mhlaba lathoma ngonyaka we-2005 nakakhipha i-albhamu yakhe yesihloko esithi “dwala lami”ekungiyo eyamenzelabona aziwe njengomvumi womvumo wesonto.”UJesu uyalalela” yi-albhamu yakhe alandela ngayo eyabe ikatelela bona umthandazo ngiwo oyipendulo. Wakhupha enye godu i-albhamu ngo-2007 yona eyabe imumethe ifihlo yokobana umvumo wesonto kufanele uzwakale bunjani, uphethe ukulotjha uzimu, ukudansa Kanye nokubonga.Sele akhiphe ama-albhamu aphezulu kwalikhomba.

=== Ipilo yakhe neentjhijilo ===
Uhlengiwe Mhlaba akhange afihle okwenzeke epilweni yakhe waveza kobana ukhe walinga ukuzikhunga ngesibanga sokugandelelwa mndeni begodu nangesinga sokuba nobudisi kwezemali. Nanyana kunjalo wasebenzisa izinto akhe aqalana nazo ukuthi abasele umvumo wakhe akwazi ukuthi alekelele abanye abanobududisi abacalene nabo  epilweni ngomvumo wakhe.Umumuntu ofundisa ngokuthi abantu kufanele bazigcine baphilile emkhumbulweni wabo babalekele ukugandeleleka ngombana ukugandeleleka kungenza umuntu binyana abe nomcabango wokuzikhunga.Ngalokho wagcina azibandakanya  ku-“Ungazibulali depression  and Suicide Campaign”.&lt;ref&gt;[https://www.news24.com/drum/celebs/news/hlengiwe-mhlaba-marks-20-years-in-music-after-conquering-depression-a-car-crash-20250306 ICYMI: Hlengiwe Mhlaba marks 20 years in music after conquering depression &amp; a car crash | News24]&lt;/ref&gt;Uthanda ukhuluma nesitjhaba anikele abantu ithemba epilweni.

== Iinkomba ==
[[Category:Abavumi]]
[[category:Umvumo wevangeli]]</text>
      <sha1>q5gymjspgh032za82fad6fygq936qpr</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi asiqongelane:Lungile M. Mabhena</title>
    <ns>3</ns>
    <id>763</id>
    <revision>
      <id>5180</id>
      <timestamp>2025-08-15T13:09:14Z</timestamp>
      <contributor>
        <username>Indiphile Ntliziyombi (WMZA)</username>
        <id>512</id>
      </contributor>
      <comment>/* Invitation: Join Us in Celebrating South Africa’s Linguistic Diversity */ new section</comment>
      <origin>5180</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="978" sha1="kcctqjxffa8eay2gddes1p6tyo2y8c8" xml:space="preserve">== Invitation: Join Us in Celebrating South Africa’s Linguistic Diversity ==

'''Hello fellow Wikipedian!'''

Wikimedia South Africa, in collaboration with the Wikimedia Foundation, is on a mission to create a short video celebrating South Africa’s rich linguistic and cultural diversity. We would like to invite you to take part as an active contributor to one of the South African language Wikipedias.

Through this project, we aim to honour the people who make knowledge in these languages available on Wikipedia, while showcasing the vibrant languages and cultures that shape our nation.

We hope you will join us in this meaningful initiative.

Thank you for your time and for your dedication to making knowledge accessible in South African languages.


Best regards,

'''Wikimedia South Africa''' [[Umsebenzisi:Indiphile Ntliziyombi (WMZA)|Indiphile Ntliziyombi (WMZA)]] ([[Umsebenzisi asiqongelane:Indiphile Ntliziyombi (WMZA)|talk]]) 15:09, 15 Ncwabakazi 2025 (SAST)</text>
      <sha1>kcctqjxffa8eay2gddes1p6tyo2y8c8</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi asiqongelane:Jetro mahlangu</title>
    <ns>3</ns>
    <id>764</id>
    <revision>
      <id>5181</id>
      <timestamp>2025-08-15T13:10:01Z</timestamp>
      <contributor>
        <username>Indiphile Ntliziyombi (WMZA)</username>
        <id>512</id>
      </contributor>
      <comment>/* Invitation: Join Us in Celebrating South Africa’s Linguistic Diversity */ new section</comment>
      <origin>5181</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="978" sha1="i49jiejswkumrmxv6rzgg5gss1q97bh" xml:space="preserve">== Invitation: Join Us in Celebrating South Africa’s Linguistic Diversity ==

'''Hello fellow Wikipedian!'''

Wikimedia South Africa, in collaboration with the Wikimedia Foundation, is on a mission to create a short video celebrating South Africa’s rich linguistic and cultural diversity. We would like to invite you to take part as an active contributor to one of the South African language Wikipedias.

Through this project, we aim to honour the people who make knowledge in these languages available on Wikipedia, while showcasing the vibrant languages and cultures that shape our nation.

We hope you will join us in this meaningful initiative.

Thank you for your time and for your dedication to making knowledge accessible in South African languages.


Best regards,

'''Wikimedia South Africa''' [[Umsebenzisi:Indiphile Ntliziyombi (WMZA)|Indiphile Ntliziyombi (WMZA)]] ([[Umsebenzisi asiqongelane:Indiphile Ntliziyombi (WMZA)|talk]]) 15:10, 15 Ncwabakazi 2025 (SAST)</text>
      <sha1>i49jiejswkumrmxv6rzgg5gss1q97bh</sha1>
    </revision>
    <revision>
      <id>5182</id>
      <parentid>5181</parentid>
      <timestamp>2025-08-15T14:02:42Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>/* Invitation: Join Us in Celebrating South Africa’s Linguistic Diversity */ Reply</comment>
      <origin>5182</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1230" sha1="147dbrep4t30cvs4xfhxj5vf5g5yd7r" xml:space="preserve">== Invitation: Join Us in Celebrating South Africa’s Linguistic Diversity ==

'''Hello fellow Wikipedian!'''

Wikimedia South Africa, in collaboration with the Wikimedia Foundation, is on a mission to create a short video celebrating South Africa’s rich linguistic and cultural diversity. We would like to invite you to take part as an active contributor to one of the South African language Wikipedias.

Through this project, we aim to honour the people who make knowledge in these languages available on Wikipedia, while showcasing the vibrant languages and cultures that shape our nation.

We hope you will join us in this meaningful initiative.

Thank you for your time and for your dedication to making knowledge accessible in South African languages.


Best regards,

'''Wikimedia South Africa''' [[Umsebenzisi:Indiphile Ntliziyombi (WMZA)|Indiphile Ntliziyombi (WMZA)]] ([[Umsebenzisi asiqongelane:Indiphile Ntliziyombi (WMZA)|talk]]) 15:10, 15 Ncwabakazi 2025 (SAST)

:@[[Umsebenzisi:Indiphile Ntliziyombi (WMZA)|Indiphile Ntliziyombi (WMZA)]] noted thank you i would love to participate. [[Umsebenzisi:Jetro mahlangu|Jetro mahlangu]] ([[Umsebenzisi asiqongelane:Jetro mahlangu|talk]]) 16:02, 15 Ncwabakazi 2025 (SAST)</text>
      <sha1>147dbrep4t30cvs4xfhxj5vf5g5yd7r</sha1>
    </revision>
    <revision>
      <id>5210</id>
      <parentid>5182</parentid>
      <timestamp>2025-08-18T07:49:39Z</timestamp>
      <contributor>
        <username>Indiphile Ntliziyombi (WMZA)</username>
        <id>512</id>
      </contributor>
      <comment>/* Invitation: Join Us in Celebrating South Africa’s Linguistic Diversity */ Reply</comment>
      <origin>5210</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1539" sha1="24glzdm3ddiirjzmjdeeq19z79q5v0a" xml:space="preserve">== Invitation: Join Us in Celebrating South Africa’s Linguistic Diversity ==

'''Hello fellow Wikipedian!'''

Wikimedia South Africa, in collaboration with the Wikimedia Foundation, is on a mission to create a short video celebrating South Africa’s rich linguistic and cultural diversity. We would like to invite you to take part as an active contributor to one of the South African language Wikipedias.

Through this project, we aim to honour the people who make knowledge in these languages available on Wikipedia, while showcasing the vibrant languages and cultures that shape our nation.

We hope you will join us in this meaningful initiative.

Thank you for your time and for your dedication to making knowledge accessible in South African languages.


Best regards,

'''Wikimedia South Africa''' [[Umsebenzisi:Indiphile Ntliziyombi (WMZA)|Indiphile Ntliziyombi (WMZA)]] ([[Umsebenzisi asiqongelane:Indiphile Ntliziyombi (WMZA)|talk]]) 15:10, 15 Ncwabakazi 2025 (SAST)

:@[[Umsebenzisi:Indiphile Ntliziyombi (WMZA)|Indiphile Ntliziyombi (WMZA)]] noted thank you i would love to participate. [[Umsebenzisi:Jetro mahlangu|Jetro mahlangu]] ([[Umsebenzisi asiqongelane:Jetro mahlangu|talk]]) 16:02, 15 Ncwabakazi 2025 (SAST)
::@[[Umsebenzisi:Jetro mahlangu|Jetro mahlangu]] That's great! Could you please share your email address so we can discuss this further? [[Umsebenzisi:Indiphile Ntliziyombi (WMZA)|Indiphile Ntliziyombi (WMZA)]] ([[Umsebenzisi asiqongelane:Indiphile Ntliziyombi (WMZA)|talk]]) 09:49, 18 Ncwabakazi 2025 (SAST)</text>
      <sha1>24glzdm3ddiirjzmjdeeq19z79q5v0a</sha1>
    </revision>
    <revision>
      <id>5211</id>
      <parentid>5210</parentid>
      <timestamp>2025-08-18T08:23:38Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>/* Invitation: Join Us in Celebrating South Africa’s Linguistic Diversity */ Reply</comment>
      <origin>5211</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1769" sha1="r3m5keex9up80jb7dkn82t4av51p4j9" xml:space="preserve">== Invitation: Join Us in Celebrating South Africa’s Linguistic Diversity ==

'''Hello fellow Wikipedian!'''

Wikimedia South Africa, in collaboration with the Wikimedia Foundation, is on a mission to create a short video celebrating South Africa’s rich linguistic and cultural diversity. We would like to invite you to take part as an active contributor to one of the South African language Wikipedias.

Through this project, we aim to honour the people who make knowledge in these languages available on Wikipedia, while showcasing the vibrant languages and cultures that shape our nation.

We hope you will join us in this meaningful initiative.

Thank you for your time and for your dedication to making knowledge accessible in South African languages.


Best regards,

'''Wikimedia South Africa''' [[Umsebenzisi:Indiphile Ntliziyombi (WMZA)|Indiphile Ntliziyombi (WMZA)]] ([[Umsebenzisi asiqongelane:Indiphile Ntliziyombi (WMZA)|talk]]) 15:10, 15 Ncwabakazi 2025 (SAST)

:@[[Umsebenzisi:Indiphile Ntliziyombi (WMZA)|Indiphile Ntliziyombi (WMZA)]] noted thank you i would love to participate. [[Umsebenzisi:Jetro mahlangu|Jetro mahlangu]] ([[Umsebenzisi asiqongelane:Jetro mahlangu|talk]]) 16:02, 15 Ncwabakazi 2025 (SAST)
::@[[Umsebenzisi:Jetro mahlangu|Jetro mahlangu]] That's great! Could you please share your email address so we can discuss this further? [[Umsebenzisi:Indiphile Ntliziyombi (WMZA)|Indiphile Ntliziyombi (WMZA)]] ([[Umsebenzisi asiqongelane:Indiphile Ntliziyombi (WMZA)|talk]]) 09:49, 18 Ncwabakazi 2025 (SAST)
:::@[[Umsebenzisi:Indiphile Ntliziyombi (WMZA)|Indiphile Ntliziyombi (WMZA)]] johnmafika9@gmail.com [[Umsebenzisi:Jetro mahlangu|Jetro mahlangu]] ([[Umsebenzisi asiqongelane:Jetro mahlangu|talk]]) 10:23, 18 Ncwabakazi 2025 (SAST)</text>
      <sha1>r3m5keex9up80jb7dkn82t4av51p4j9</sha1>
    </revision>
    <revision>
      <id>5212</id>
      <parentid>5211</parentid>
      <timestamp>2025-08-19T09:43:50Z</timestamp>
      <contributor>
        <username>Indiphile Ntliziyombi (WMZA)</username>
        <id>512</id>
      </contributor>
      <comment>/* Invitation: Join Us in Celebrating South Africa’s Linguistic Diversity */ Reply</comment>
      <origin>5212</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2003" sha1="36ypjkfa5o2ya6bma2f5enkzmi63ld4" xml:space="preserve">== Invitation: Join Us in Celebrating South Africa’s Linguistic Diversity ==

'''Hello fellow Wikipedian!'''

Wikimedia South Africa, in collaboration with the Wikimedia Foundation, is on a mission to create a short video celebrating South Africa’s rich linguistic and cultural diversity. We would like to invite you to take part as an active contributor to one of the South African language Wikipedias.

Through this project, we aim to honour the people who make knowledge in these languages available on Wikipedia, while showcasing the vibrant languages and cultures that shape our nation.

We hope you will join us in this meaningful initiative.

Thank you for your time and for your dedication to making knowledge accessible in South African languages.


Best regards,

'''Wikimedia South Africa''' [[Umsebenzisi:Indiphile Ntliziyombi (WMZA)|Indiphile Ntliziyombi (WMZA)]] ([[Umsebenzisi asiqongelane:Indiphile Ntliziyombi (WMZA)|talk]]) 15:10, 15 Ncwabakazi 2025 (SAST)

:@[[Umsebenzisi:Indiphile Ntliziyombi (WMZA)|Indiphile Ntliziyombi (WMZA)]] noted thank you i would love to participate. [[Umsebenzisi:Jetro mahlangu|Jetro mahlangu]] ([[Umsebenzisi asiqongelane:Jetro mahlangu|talk]]) 16:02, 15 Ncwabakazi 2025 (SAST)
::@[[Umsebenzisi:Jetro mahlangu|Jetro mahlangu]] That's great! Could you please share your email address so we can discuss this further? [[Umsebenzisi:Indiphile Ntliziyombi (WMZA)|Indiphile Ntliziyombi (WMZA)]] ([[Umsebenzisi asiqongelane:Indiphile Ntliziyombi (WMZA)|talk]]) 09:49, 18 Ncwabakazi 2025 (SAST)
:::@[[Umsebenzisi:Indiphile Ntliziyombi (WMZA)|Indiphile Ntliziyombi (WMZA)]] johnmafika9@gmail.com [[Umsebenzisi:Jetro mahlangu|Jetro mahlangu]] ([[Umsebenzisi asiqongelane:Jetro mahlangu|talk]]) 10:23, 18 Ncwabakazi 2025 (SAST)
::::@[[Umsebenzisi:Jetro mahlangu|Jetro mahlangu]] Thank you! [[Umsebenzisi:Indiphile Ntliziyombi (WMZA)|Indiphile Ntliziyombi (WMZA)]] ([[Umsebenzisi asiqongelane:Indiphile Ntliziyombi (WMZA)|talk]]) 11:43, 19 Ncwabakazi 2025 (SAST)</text>
      <sha1>36ypjkfa5o2ya6bma2f5enkzmi63ld4</sha1>
    </revision>
  </page>
  <page>
    <title>Abantu bendabuko be-Afrika ama-Khoisan</title>
    <ns>0</ns>
    <id>765</id>
    <revision>
      <id>5183</id>
      <timestamp>2025-08-15T22:41:18Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>Ngitlole ikhasi elitjha</comment>
      <origin>5183</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6232" sha1="n77yk7l0xn3itfy45ob5p7ei10ki95e" xml:space="preserve">== Ama-Khoisan ==
[[Isimumathi:Bushmen hunters (cropped).png|thumb|Umzumi wama-Khoisan ]]
Ama-'''Khoisan''' babantu bomdabu be-'''San''' ne-'''Khoekhoe''' be'''Sewula_Afrika.'''

Ngaphambilini bebaziwa ngokuthi &quot;banemibala&quot;nje basebenzisa ilungelo labo lokuzazisa begodu baziveza njengama-'''San''' nama-'''Khoekhoe''' nofana ama-'''Khoe-San.'''

=== Ukwamukelwa kwama-'''Khoisan''' ===
I'''Sewula Afrika''' ivowudele ukwamukelwa kwesimemezelo se-'''UN''' malungana namalungelo wabantu bendabuko kodwana ayikavumi i-'''ILO''' Convension NO.169.Abantu bendabuko be-'''San''' ne-'''Khoekhoe''' abavunywa ngokusemthethweni ngokuya ngomthetho welizwe njengomphakathi wesintu.Lokhu kuyatjhuguluka ngomthetho woburholi wendabuko nomthethomlingwa we-'''Khoisan''' okuhloswe bona wethulwe e-Palamende.Inani elipheleleko labantu be'''Sewula Afrika''' lingaba ziingidi ezima-50,lapho kulinganiselwa bona isiqhema sabantu bomdabu sijame phezu ku-1%.

==== Iinqhema zama-Khoisan neendawo zawo ====
Iinqhema ezikulu zama '''Khoisan''' zifaka hlangana ama-'''San Khomani''' ahlala khulu esifundeni se-'''Khalahari''' kunye nama-'''Khwe''' nama-'''Xun,'''ahlala khulu e-'''Platfontein''' e-'''Kimberley.'''I'''Khoekhoe''' ibunjwa ma-'''Nama''' ahlala khulu esifundeni se-'''North Cape.'''I'''Koran''' khulukhulu eendaweni ze-'''Kimberley''' ne-'''Free State.'''I'''Griqua''' eendaweni ze-'''Western Cape,Eastern Cape,Northern Cape,Free State''' kunye ne-'''Kwa-Zulu Natal.'''Ama-Cape '''Khoekhoe''' e-'''Western Cape''' ne-'''Eastern Cape''' ngokukhula kwamaphakethe eemfundazweni ze-'''Gauteng''' ne-'''Free State.'''E'''Sewula Afrika''' yanje imiphakathi yama-'''Khoisan''' itjengisa iindlela zokuphila ezahlukahlukeneko zezomnotho namasiko.Amatjhuguluko wezehlalakuhle nezepolotiki alethwe lihlelo lezepolotiki le'''Sewula Afrika''' yanje edale isikhala sokuhlukaniswa kwemikhakha yezehlalakuhle yebandlululo efana nombala.

===== Ilwazi lomdabu nama-prhrojekthi wama-Khoisan =====
Umthetho wokuvikelwa,ukuthuthukiswa nokuphathwa kwamahlelo welwazi lendabuko ka-2014 wasungula ukuvikelwa,ukuthuthukisa nokuphathwa kwenkhungo zelwazi lendabuko yemiphakathi.Umthethomlingwa lo unikela ngokusungulwa nokusebenza kwe-ofisi lenarha leenhlelo zelwazi lendabuko nokuphathwa kwamalungelo wabanikazi belwazi lendabuko.Iphrojekthi womthetho welwazi lomdabu isungula indlela yokuthola ilwazi lomdabu lemiphakathi yendawo.Ukungezelela umthethomlingwa lo uhlathulula ikambiso yokutlolisa,ukugunyaza noku qinisekisa abasebenzi belwazi lomdabu.Inguqulo yesibili womthethomlingwa lo yenziwe ngokuya komjikelezo wokuthoma wokungena,begodu inguqulo etja yesibili yavulwa bona ibonisane nomphakathi ngo-'''Nobayeni''' wee-2016.

Ikomidi ye-Palamende ye'''Sewula Afrika''' yokubusa ngokubambisana nezindaba zendabuko yethule umthethomlingwa woburholi bendabuko nama-'''Khoisan''' phambi kwe-Palamende ngo-2016.Iphrojekthi le ifuna ukutjheja bona imiphakathi yama-'''Khoisan''' yomlando sele yamukelwa ngeminye imiphakathi yamasiko ye'''Sewula Afrika.'''Ngokokuthoma eminyakeni ema-300 edlulileko,umthethomlingwa lo unganikela ukuvunywa okusemthethweni begodu uvule amathuba wokufikelela ubulungiswa emiphakathini yomlando wama-'''Khoisan'''.Umthethomlingwa lo uzokuvumela ama-'''Khoisan''' bona afakwe eenkambisweni zokuphatha zika-Rhulumende ngaphakathi kweenkonzo ezihlukahlukeneko begodu uvumele iinkonzo lezi bona zenze amalungiselelo athileko wezinto eziqakathekileko zehlalakuhle,zomnotho nezamasiko wemiphakathi yama-'''Khoisan'''.
[[Isimumathi:Khoisan languages.svg|thumb|I-diagramu yama-limi wama-Khoisan]]

====== Imizamo yokubulunga amasiko wama-Khoisan ======
Iinhlelo ezinengi ezihloswe ukubulunga amalimi wama-'''Khoisan''',amasiko kunye namahlelo welwazi zithole ukuthandwa umnyaka woke.I-South African National Editor's Forum (SANEF),i-PanSALB-i-Pan South African Language Board kunye ne-UN bathoma isemina ngendima yabezindaba ekuthuthukisweni nekulondolozweni amalimi wendabuko.Umnyanya lo obanjwe mhlana zi-07 ku'''Rhoboyi''' wee-2024,ukhulume ngomthelela wobuhlakani bokufakelwa eendabeni kunye namaqhinga lapho umkhakha weendaba zamalimi wendabuko ungadosa ngakho ukukhangisa kwedijithali.Isemina le idose ababiki beendaba,iimfundiswa,abahlaziyi kunye nabasebenzi emkhakheni weendaba zamabhizinisi ngokudzimelela ebantwini beendaba zomphakathi.

Amaphrojekthi wokusebenzisana neenkhungo zefundo kunye neenhlangano zamasiko ahlonywa ukutlola nokukhuthaza amagugu wendabuko.I-PanSALB ibawe bona kube nendlela epheleleko yokukhuthaza ukuhlonipha amalimi wendabuko nokukhomba iindawo ezitlhogwa ukuvuselelwa.Lokhu kwagandelelwa ngesikhathi se-'''Khoisan''' National Language Indaba,umhlangano owahlanganisa ababambindima begodu okhambisana ne-International Decade of Indigenous Languages 2022-2032.I-'''PanSALB''' ikhuthaze woke amazinga kaRhulumende bona athathe amagadango wokuphendula iincomo ezenziwe ngesikhathi se Indaba.

====== Amanothi neenkhombo ======
1. The Indigenous Peoples of Africa Co-ordinating Committee. (19 February 2020). Southern Africa - The Indigenous Peoples of Africa Co-ordinating Committee.https://www.ipacc.org.za/southern-africa/#:~:text=The%20indigenous%20peoples%20of%20South,Khoekhoe%2C%20including%20Nama%20and%20Griqua
2. Cassette, J., &amp; Roos, E. (n.d.). Traditional Khoi-San Leadership Act: The importance of meaningful public participation during the law-making process. Cliffe Dekker Hofmeyr.https://www.cliffedekkerhofmeyr.com/news/publications/2023/Practice/ProBono/pro-bono-and-human-rights-alert-9-june-traditional-khoi-san-leadership-act
3.  Jansen, Lesle and Horton, Theo. “South Africa”. In The Indigenous World 2024, ed. D. Mamo, IWGIA. April 2024. pp. 116-122.https://iwgia.org/en/south-africa/5358-iw-2024-southafrica.html
4. Zondo, W. B. (19 December 2024). In peril: How the traditional and Khoi-San Leadership Bill 2024 continues to threaten informal land rights and rural democracy — African law matters. African Law Matters.https://www.africanlawmatters.com/blog/in-peril-how-the-traditional-and-khoi-san-leadership-bill-2024-continues-to-threaten-informal-land-rights-and-rural-democracy
5.The Khoisan | South African History Online. (n.d.).https://www.sahistory.org.za/article/khoisan</text>
      <sha1>n77yk7l0xn3itfy45ob5p7ei10ki95e</sha1>
    </revision>
    <revision>
      <id>6563</id>
      <parentid>5183</parentid>
      <timestamp>2026-05-18T20:45:39Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <origin>6563</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5856" sha1="hms0cmq2egqxp048ah171jku79hpsqc" xml:space="preserve">'''Ama-Khoisan''' babantu bomdabu be-San ne-Khoekhoe beSewula Afrika. Ngaphambilini bebaziwa ngokuthi banemibala nje basebenzisa ilungelo labo lokuzazisa begodu baziveza njengama-San nama-Khoekhoe nofana ama-Khoe-San.

== Ukwamukelwa kwama-Khoisan ==
ISewula Afrika ivowudele ukwamukelwa kwesimemezelo se-UN malungana namalungelo wabantu bendabuko kodwana ayikavumi i-ILO Convention No. 169. Abantu bendabuko be-San ne-Khoekhoe abavunywa ngokusemthethweni ngokuya ngomthetho welizwe njengomphakathi wesintu. Lokhu kuyatjhuguluka ngomthetho woburholi wendabuko nomthethomlingwa we-Khoisan okuhloswe bona wethulwe e-Palamende. Inani elipheleleko labantu beSewula Afrika lingaba ziingidi ezima-50, lapho kulinganiselwa bona isiqhema sabantu bomdabu sijame phezu ku-1%.

== Iinqhema zama-Khoisan neendawo zawo ==
Iinqhema ezikulu zama-Khoisan zifaka hlangana ama-San Khomani ahlala khulu esifundeni se-Khalahari kunye nama-Khwe nama-Xun, ahlala khulu e-Platfontein e-Kimberley. IKhoekhoe ibunjwa ma-Nama ahlala khulu esifundeni se-North Cape. I-Koran khulukhulu eendaweni ze-Kimberley ne-Free State. I-Griqua eendaweni ze-Western Cape, Eastern Cape, Northern Cape, Free State kanye naKwaZulu-Natal. Ama-Cape Khoekhoe e-Western Cape ne-Eastern Cape ngokukhula kwamaphakethe eemfundazweni ze-Gauteng ne-Free State. ESewula Afrika yanje imiphakathi yama-Khoisan itjengisa iindlela zokuphila ezahlukahlukeneko zezomnotho namasiko. Amatjhuguluko wezehlalakuhle nezepolotiki alethwe lihlelo lezepolotiki leSewula Afrika yanje edale isikhala sokuhlukaniswa kwemikhakha yezehlalakuhle yebandlululo efana nombala.

== Ilwazi lomdabu namaphrojekthi wama-Khoisan ==
Umthetho wokuvikelwa, ukuthuthukiswa nokuphathwa kwamahlelo welwazi lendabuko ka-2014 wasungula ukuvikelwa, ukuthuthukisa nokuphathwa kweenkhungo zelwazi lendabuko yemiphakathi. Umthethomlingwa lo unikela ngokusungulwa nokusebenza kwe-ofisi lenarha leenhlelo zelwazi lendabuko nokuphathwa kwamalungelo wabanikazi belwazi lendabuko. Iphrojekthi womthetho welwazi lomdabu isungula indlela yokuthola ilwazi lomdabu lemiphakathi yendawo. Ukungezelela umthethomlingwa lo uhlathulula ikambiso yokutlolisa, ukugunyaza nokuqinisekisa abasebenzi belwazi lomdabu. Inguqulo yesibili womthethomlingwa lo yenziwe ngokuya komjikelezo wokuthoma wokungena begodu inguqulo etja yesibili yavulwa bona ibonisane nomphakathi ngo-Nobayeni wee-2016.

Ikomidi yePalamende yeSewula Afrika yokubusa ngokubambisana neendaba zendabuko yethule umthethomlingwa woburholi bendabuko nama-Khoisan phambi kwePalamende ngo-2016. Iphrojekthi le ifuna ukutjheja bona imiphakathi yama-Khoisan yomlando sele yamukelwa ngeminye imiphakathi yamasiko yeSewula Afrika. Ngokokuthoma eminyakeni ema-300 edlulileko, umthethomlingwa lo unganikela ukuvunywa okusemthethweni begodu uvule amathuba wokufikelela ubulungiswa emiphakathini yomlando wama-Khoisan. Umthethomlingwa lo uzokuvumela ama-Khoisan bona afakwe eenkambisweni zokuphatha zikaRhulumende ngaphakathi kweenkonzo ezihlukahlukeneko begodu uvumele iinkonzo lezi bona zenze amalungiselelo athileko wezinto eziqakathekileko zehlalakuhle, zomnotho nezamasiko wemiphakathi yama-Khoisan.
[[Isimumathi:Khoisan languages.svg|thumb|I-diagramu yama-limi wama-Khoisan]]

== Imizamo yokubulunga amasiko wama-Khoisan ==
Iinhlelo ezinengi ezihloswe ukubulunga amalimi wama-Khoisan, amasiko kunye namahlelo welwazi zithole ukuthandwa umnyaka woke. I-South African National Editor's Forum (SANEF), i-Pan South African Language Board (PanSALB) kunye ne-UN bathoma isemina ngendima yabezindaba ekuthuthukisweni nekulondolozweni amalimi wendabuko. Umnyanya lo obanjwe mhlazana amalanga ali-07 kuRhoboyi wee-2024, ukhulume ngomthelela wobuhlakani bokufakelwa eendabeni kunye namaqhinga lapho umkhakha weendaba zamalimi wendabuko ungadosa ngakho ukukhangisa kwedijithali. Isemina le idose ababiki beendaba, iimfundiswa, abahlaziyi kanye nabasebenzi emkhakheni weendaba zamabhizinisi ngokudzimelela ebantwini beendaba zomphakathi.

Amaphrojekthi wokusebenzisana neenkhungo zefundo kanye neenhlangano zamasiko ahlonywa ukutlola nokukhuthaza amagugu wendabuko. I-PanSALB ibawe bona kube nendlela epheleleko yokukhuthaza ukuhlonipha amalimi wendabuko nokukhomba iindawo ezitlhogwa ukuvuselelwa. Lokhu kwagandelelwa ngesikhathi se-Khoisan National Language Indaba,umhlangano owahlanganisa ababambindima begodu okhambisana ne-International Decade of Indigenous Languages 2022-2032. I-PanSALB ikhuthaze woke amazinga kaRhulumende bona athathe amagadango wokuphendula iincomo ezenziwe ngesikhathi se Indaba.

== Amanothi neenkhombo ==
1. The Indigenous Peoples of Africa Co-ordinating Committee. (19 February 2020). Southern Africa - The Indigenous Peoples of Africa Co-ordinating Committee.https://www.ipacc.org.za/southern-africa/#:~:text=The%20indigenous%20peoples%20of%20South,Khoekhoe%2C%20including%20Nama%20and%20Griqua
2. Cassette, J., &amp; Roos, E. (n.d.). Traditional Khoi-San Leadership Act: The importance of meaningful public participation during the law-making process. Cliffe Dekker Hofmeyr.https://www.cliffedekkerhofmeyr.com/news/publications/2023/Practice/ProBono/pro-bono-and-human-rights-alert-9-june-traditional-khoi-san-leadership-act
3.  Jansen, Lesle and Horton, Theo. “South Africa”. In The Indigenous World 2024, ed. D. Mamo, IWGIA. April 2024. pp. 116-122.https://iwgia.org/en/south-africa/5358-iw-2024-southafrica.html
4. Zondo, W. B. (19 December 2024). In peril: How the traditional and Khoi-San Leadership Bill 2024 continues to threaten informal land rights and rural democracy — African law matters. African Law Matters.https://www.africanlawmatters.com/blog/in-peril-how-the-traditional-and-khoi-san-leadership-bill-2024-continues-to-threaten-informal-land-rights-and-rural-democracy
5.The Khoisan | South African History Online. (n.d.).https://www.sahistory.org.za/article/khoisan</text>
      <sha1>hms0cmq2egqxp048ah171jku79hpsqc</sha1>
    </revision>
  </page>
  <page>
    <title>Lillian Ngoyi</title>
    <ns>0</ns>
    <id>766</id>
    <revision>
      <id>5195</id>
      <timestamp>2025-08-16T10:15:49Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''Lillian Masediba Ngoyi''' Wabelethwa mhlana amalanga ama-25 kuKhukhulamungu ngonyaka we-1911, endaweni ye –Pretoria. Ipilo yakhe ibukafazi bokuzimisela ukulwisana nombuso wegandelelo Kanye nokubandlulula ngokobulili. Wazinikela ukulwela amalungelo, ikuleleko, nokulingana eSewula Afrika. UNgoyi wathoma ikhambo lakhe kwezepolitiki ngonnyaka we-1970 ekukulapho abalilungale-Garment workers’ union lapho gade asebenza khona ngemitjhini efekthrini yezambatho. Ukuba lilun...&quot;</comment>
      <origin>5195</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2769" sha1="7e05e4nkh1hfg2pydq3vqucwdu70ows" xml:space="preserve">'''Lillian Masediba Ngoyi''' Wabelethwa mhlana amalanga ama-25 kuKhukhulamungu ngonyaka we-1911, endaweni ye –Pretoria. Ipilo yakhe ibukafazi bokuzimisela ukulwisana nombuso wegandelelo Kanye nokubandlulula ngokobulili. Wazinikela ukulwela amalungelo, ikuleleko, nokulingana eSewula Afrika. UNgoyi wathoma ikhambo lakhe kwezepolitiki ngonnyaka we-1970 ekukulapho abalilungale-Garment workers’ union lapho gade asebenza khona ngemitjhini efekthrini yezambatho. Ukuba lilunga kwakhe le- union le kwamenza bona agcine sele alilunga le-African National congress ngonyaka we-1950, Ngesi khathi se-defiance campaign. Ukuba nekghono lokudosa phambili kwamlekela bonyana agcine sele athola ezinye iinkhundla ku- ANC women’s legue naku Federation of South African Women (FEDSAW).&lt;ref&gt;[https://www.sahra.org.za/lilian-ngoyi/ LILIAN NGOYI - SAHRA 2025]&lt;/ref&gt;

Ukumatjha kwabantu bengubo

U-Lillian Ngoyi wakghona ukuba ngomunye waboma abadosa phambili ekumatjheni kwabomma nofana kwabantu bengubo ekwenzeka ngelanga le-9 kuRhoboyi ngonyaka we-1956 ekukulapho kwaphuma khona abantu bengubo benarheni yoke yeSewula Afrika abadlula ku-20 000. Bakhamba baya e-union building, ePitori ukuyokunghonghoyila ngomthetho wokudlula ebantwini bengubo. Ngukhona ikwakhe ukukhuluma wazilekelela ngombana wakghona boyana atjele isitjhaba samma bonyana sithule amamithi ama-30 amzabalalzweni.&lt;ref&gt;[https://sahistory.org.za/people/lilian-masediba-ngoyi Lilian Masediba Ngoyi | South African History Online]&lt;/ref&gt;

Amakhambo wakhe

Bekanande akhamba aye ngaphetjheya ekungeminye yemisikinyeko yakhe yango-1955 waya ku-world Congress of Mothers, eLuasane, Switzerland.&lt;ref&gt;[https://www.blackhistoryheroes.com/2015/07/lillian-ngoyi-mother-of-black.html Black History Heroes: Lillian Ngoyi: Mother of the Black Resistance in South Africa]&lt;/ref&gt; Kukulapho akhuluma khona khona ngabantu bephasi ngokugandelelwa abomma beSewula Afrika abacalene nabo. Ukukhamba kwakhe kwakhe godu kwamusa e-Europe, China neRussia ekukulapho ahlangana khona nabanye abantu bengubo wenza nabo ubudlelwane.Lokho kwasiza kobana akghone ukuthi akhulise umsikinyeko wakhe wokulwisana nombuso wegandelelo.Kwathi asenze njalo wazingelwa lijima elabe lijamele umbuso wegandelelo. Bamlisisa ezinye zezinto, begodu kwaquntwa namakhambo wakhe wokuya emihlanganweni, nokuthi athule ikulumo lapho kuhlangene khona abantu abanengi. Wathoma ukujanyiswa ngonyaka we1960. Waphila iminyaka ema-15 ngaphambi kwemibandela lena. Nanyana kunjalo waragela phambili ukukhuthaza abanye ngesibindi anaso nokubekezela ebunzimeni.Eskhathini sanje ukhunjulwa njengomuntu owadlala indima ekulweni ikululeko yesitjhaba seSewula Afrika. Usakhunjulwa ngombana kuneentrada, imakhiwo namatliniki abizwa ngegama lakhe, ukwenzela bona ahlale akhunjulwa.</text>
      <sha1>7e05e4nkh1hfg2pydq3vqucwdu70ows</sha1>
    </revision>
    <revision>
      <id>5196</id>
      <parentid>5195</parentid>
      <timestamp>2025-08-16T10:17:26Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5196</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2823" sha1="isz3sbq89nz7bwj5uxlxm7kbvqbpfbj" xml:space="preserve">'''Lillian Masediba Ngoyi''' Wabelethwa mhlana amalanga ama-25 kuKhukhulamungu ngonyaka we-1911, endaweni ye –Pretoria. Ipilo yakhe ibukafazi bokuzimisela ukulwisana nombuso wegandelelo Kanye nokubandlulula ngokobulili. Wazinikela ukulwela amalungelo, ikuleleko, nokulingana eSewula Afrika. UNgoyi wathoma ikhambo lakhe kwezepolitiki ngonyaka we-1970 ekukulapho abalilungale-Garment workers’ union lapho gade asebenza khona ngemitjhini efekthrini yezambatho. Ukuba lilunga kwakhe le- union le kwamenza bona agcine sele alilunga le-African National congress ngonyaka we-1950, Ngesi khathi se-defiance campaign. Ukuba nekghono lokudosa phambili kwamlekela bonyana agcine sele athola ezinye iinkhundla ku- ANC women’s legue naku Federation of South African Women (FEDSAW).&lt;ref&gt;[https://www.sahra.org.za/lilian-ngoyi/ LILIAN NGOYI - SAHRA 2025]&lt;/ref&gt;

Ukumatjha kwabantu bengubo
[[Isimumathi:Lilian Ngoyi.jpg|thumb|Lillian Ngoyi]]
U-Lillian Ngoyi wakghona ukuba ngomunye waboma abadosa phambili ekumatjheni kwabomma nofana kwabantu bengubo ekwenzeka ngelanga le-9 kuRhoboyi ngonyaka we-1956 ekukulapho kwaphuma khona abantu bengubo benarheni yoke yeSewula Afrika abadlula ku-20 000. Bakhamba baya e-union building, ePitori ukuyokunghonghoyila ngomthetho wokudlula ebantwini bengubo. Ngukhona ikwakhe ukukhuluma wazilekelela ngombana wakghona boyana atjele isitjhaba samma bonyana sithule amamithi ama-30 amzabalalzweni.&lt;ref&gt;[https://sahistory.org.za/people/lilian-masediba-ngoyi Lilian Masediba Ngoyi | South African History Online]&lt;/ref&gt;

Amakhambo wakhe

Bekanande akhamba aye ngaphetjheya ekungeminye yemisikinyeko yakhe yango-1955 waya ku-world Congress of Mothers, eLuasane, Switzerland.&lt;ref&gt;[https://www.blackhistoryheroes.com/2015/07/lillian-ngoyi-mother-of-black.html Black History Heroes: Lillian Ngoyi: Mother of the Black Resistance in South Africa]&lt;/ref&gt; Kukulapho akhuluma khona khona ngabantu bephasi ngokugandelelwa abomma beSewula Afrika abacalene nabo. Ukukhamba kwakhe kwakhe godu kwamusa e-Europe, China neRussia ekukulapho ahlangana khona nabanye abantu bengubo wenza nabo ubudlelwane.Lokho kwasiza kobana akghone ukuthi akhulise umsikinyeko wakhe wokulwisana nombuso wegandelelo.Kwathi asenze njalo wazingelwa lijima elabe lijamele [[umbuso wegandelelo]]. Bamlisisa ezinye zezinto, begodu kwaquntwa namakhambo wakhe wokuya emihlanganweni, nokuthi athule ikulumo lapho kuhlangene khona abantu abanengi. Wathoma ukujanyiswa ngonyaka we1960. Waphila iminyaka ema-15 ngaphambi kwemibandela lena. Nanyana kunjalo waragela phambili ukukhuthaza abanye ngesibindi anaso nokubekezela ebunzimeni.Eskhathini sanje ukhunjulwa njengomuntu owadlala indima ekulweni ikululeko yesitjhaba seSewula Afrika. Usakhunjulwa ngombana kuneentrada, imakhiwo namatliniki abizwa ngegama lakhe, ukwenzela bona ahlale akhunjulwa.</text>
      <sha1>isz3sbq89nz7bwj5uxlxm7kbvqbpfbj</sha1>
    </revision>
    <revision>
      <id>5197</id>
      <parentid>5196</parentid>
      <timestamp>2025-08-16T10:24:55Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5197</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3074" sha1="br1pasybxjk60i9gqhx2a0wqbdnn4j5" xml:space="preserve">'''Lillian Masediba Ngoyi''' Wabelethelwa emndenini wabentwana aba-6. Wabelethwa mhlana amalanga ama-25 kuKhukhulamungu ngonyaka we-1911, endaweni ye –Pretoria esiphandeni se-Gauteng.Waceda ukufunda isikolo samabanga aphasi ekilneton. Ipilo yakhe ibukafazi bokuzimisela ukulwisana nombuso wegandelelo Kanye nokubandlulula ngokobulili. Wazinikela ukulwela amalungelo, ikuleleko, nokulingana eSewula Afrika. UNgoyi wathoma ikhambo lakhe kwezepolitiki ngonyaka we-1970 ekukulapho abalilungale-Garment workers’ union lapho gade asebenza khona ngemitjhini efekthrini yezambatho. Ukuba lilunga kwakhe le- union le kwamenza bona agcine sele alilunga le-African National congress ngonyaka we-1950, Ngesi khathi se-defiance campaign. Ukuba nekghono lokudosa phambili kwamlekela bonyana agcine sele athola ezinye iinkhundla ku- ANC women’s legue abeliseka lomengameli naku Federation of South African Women (FEDSAW) abe ngumongameli wakhona.&lt;ref&gt;[https://www.sahra.org.za/lilian-ngoyi/ LILIAN NGOYI - SAHRA 2025]&lt;/ref&gt;

=== Ukumatjha kwabantu bengubo ===
[[Isimumathi:Lilian Ngoyi.jpg|thumb|Lillian Ngoyi]]
U-Lillian Ngoyi, no Helen Joseph, Rahina Mooosa, Sophia Williams de Bruyn bakghona ukuba ngabanye baboma abadosa phambili ekumatjheni kwabomma nofana kwabantu bengubo ekwenzeka ngelanga le-9 kuRhoboyi ngonyaka we-1956 ekukulapho kwaphuma khona abantu bengubo benarheni yoke yeSewula Afrika abadlula ku-20 000. Bakhamba baya e-union building, ePitori ukuyokunghonghoyila ngomthetho wokudlula ebantwini bengubo. Ngukhona ikwakhe ukukhuluma wazilekelela ngombana wakghona boyana atjele isitjhaba samma bonyana sithule amamithi ama-30 amzabalalzweni.&lt;ref&gt;[https://sahistory.org.za/people/lilian-masediba-ngoyi Lilian Masediba Ngoyi | South African History Online]&lt;/ref&gt;

=== Amakhambo wakhe ===
Bekanande akhamba aye ngaphetjheya ekungeminye yemisikinyeko yakhe yango-1955 waya ku-world Congress of Mothers, eLuasane, Switzerland.&lt;ref&gt;[https://www.blackhistoryheroes.com/2015/07/lillian-ngoyi-mother-of-black.html Black History Heroes: Lillian Ngoyi: Mother of the Black Resistance in South Africa]&lt;/ref&gt; Kukulapho akhuluma khona khona ngabantu bephasi ngokugandelelwa abomma beSewula Afrika abacalene nabo. Ukukhamba kwakhe kwakhe godu kwamusa e-Europe, China neRussia ekukulapho ahlangana khona nabanye abantu bengubo wenza nabo ubudlelwane.Lokho kwasiza kobana akghone ukuthi akhulise umsikinyeko wakhe wokulwisana nombuso wegandelelo.Kwathi asenze njalo wazingelwa lijima elabe lijamele [[umbuso wegandelelo]]. Bamlisisa ezinye zezinto, begodu kwaquntwa namakhambo wakhe wokuya emihlanganweni, nokuthi athule ikulumo lapho kuhlangene khona abantu abanengi. Wathoma ukujanyiswa ngonyaka we1960. Waphila iminyaka ema-15 ngaphambi kwemibandela lena. Nanyana kunjalo waragela phambili ukukhuthaza abanye ngesibindi anaso nokubekezela ebunzimeni.Eskhathini sanje ukhunjulwa njengomuntu owadlala indima ekulweni ikululeko yesitjhaba seSewula Afrika. Usakhunjulwa ngombana kuneentrada, imakhiwo namatliniki abizwa ngegama lakhe, ukwenzela bona ahlale akhunjulwa.

== Iinkomba ==</text>
      <sha1>br1pasybxjk60i9gqhx2a0wqbdnn4j5</sha1>
    </revision>
    <revision>
      <id>5198</id>
      <parentid>5197</parentid>
      <timestamp>2025-08-16T10:26:38Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>5198</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3169" sha1="5tn8yuhsqj30ic93z7182jtc4c6pdsw" xml:space="preserve">'''Lillian Masediba Ngoyi''' Wabelethelwa emndenini wabentwana aba-6. Wabelethwa mhlana amalanga ama-25 kuKhukhulamungu ngonyaka we-1911, endaweni ye –Pretoria esiphandeni se-Gauteng.Waceda ukufunda isikolo samabanga aphasi ekilneton. Ipilo yakhe ibukafazi bokuzimisela ukulwisana nombuso wegandelelo Kanye nokubandlulula ngokobulili. Wazinikela ukulwela amalungelo, ikuleleko, nokulingana eSewula Afrika. UNgoyi wathoma ikhambo lakhe kwezepolitiki ngonyaka we-1970 ekukulapho abalilungale-Garment workers’ union lapho gade asebenza khona ngemitjhini efekthrini yezambatho. Ukuba lilunga kwakhe le- union le kwamenza bona agcine sele alilunga le-African National congress ngonyaka we-1950, Ngesi khathi se-defiance campaign. Ukuba nekghono lokudosa phambili kwamlekela bonyana agcine sele athola ezinye iinkhundla ku- ANC women’s legue abeliseka lomengameli naku Federation of South African Women (FEDSAW) abe ngumongameli wakhona.&lt;ref&gt;[https://www.sahra.org.za/lilian-ngoyi/ LILIAN NGOYI - SAHRA 2025]&lt;/ref&gt;

=== Ukumatjha kwabantu bengubo ===
[[Isimumathi:Lilian Ngoyi.jpg|thumb|Lillian Ngoyi]]
U-Lillian Ngoyi, no Helen Joseph, Rahina Mooosa, Sophia Williams de Bruyn bakghona ukuba ngabanye baboma abadosa phambili ekumatjheni kwabomma nofana kwabantu bengubo ekwenzeka ngelanga le-9 kuRhoboyi ngonyaka we-1956 ekukulapho kwaphuma khona abantu bengubo benarheni yoke yeSewula Afrika abadlula ku-20 000. Bakhamba baya e-union building, ePitori ukuyokunghonghoyila ngomthetho wokudlula ebantwini bengubo. Ngukhona ikwakhe ukukhuluma wazilekelela ngombana wakghona boyana atjele isitjhaba samma bonyana sithule amamithi ama-30 amzabalalzweni.&lt;ref&gt;[https://sahistory.org.za/people/lilian-masediba-ngoyi Lilian Masediba Ngoyi | South African History Online]&lt;/ref&gt;

=== Amakhambo wakhe ===
Bekanande akhamba aye ngaphetjheya ekungeminye yemisikinyeko yakhe yango-1955 waya ku-world Congress of Mothers, eLuasane, Switzerland.&lt;ref&gt;[https://www.blackhistoryheroes.com/2015/07/lillian-ngoyi-mother-of-black.html Black History Heroes: Lillian Ngoyi: Mother of the Black Resistance in South Africa]&lt;/ref&gt; Kukulapho akhuluma khona khona ngabantu bephasi ngokugandelelwa abomma beSewula Afrika abacalene nabo. Ukukhamba kwakhe kwakhe godu kwamusa e-Europe, China neRussia ekukulapho ahlangana khona nabanye abantu bengubo wenza nabo ubudlelwane.Lokho kwasiza kobana akghone ukuthi akhulise umsikinyeko wakhe wokulwisana nombuso wegandelelo.Kwathi asenze njalo wazingelwa lijima elabe lijamele [[umbuso wegandelelo]]. Bamlisisa ezinye zezinto, begodu kwaquntwa namakhambo wakhe wokuya emihlanganweni, nokuthi athule ikulumo lapho kuhlangene khona abantu abanengi. Wathoma ukujanyiswa ngonyaka we1960. Waphila iminyaka ema-15 ngaphambi kwemibandela lena. Nanyana kunjalo waragela phambili ukukhuthaza abanye ngesibindi anaso nokubekezela ebunzimeni.Eskhathini sanje ukhunjulwa njengomuntu owadlala indima ekulweni ikululeko yesitjhaba seSewula Afrika. Usakhunjulwa ngombana kuneentrada, imakhiwo namatliniki abizwa ngegama lakhe, ukwenzela bona ahlale akhunjulwa.

== Iinkomba ==
[[Category:Lillian Ngoyi]]
[[Category:Ubumso wegandelelo]]
[[Category:ilanga labantu bengubo]]</text>
      <sha1>5tn8yuhsqj30ic93z7182jtc4c6pdsw</sha1>
    </revision>
    <revision>
      <id>5199</id>
      <parentid>5198</parentid>
      <timestamp>2025-08-16T10:39:21Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5199</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3482" sha1="jo8zqe250ho6i7anjyoubhv3gvbr8dt" xml:space="preserve">'''Lillian Masediba Ngoyi''' wabelethwa mhlana amalanga ama-25 kuKhukhulamungu ngonyaka we-1911, endaweni ye –Pretoria esiphandeni se-Gauteng.Wabangomunye wabantwana aba-6 emndenini wakhe.&lt;ref&gt;[https://www.blackhistoryheroes.com/2015/07/lillian-ngoyi-mother-of-black.html Black History Heroes: Lillian Ngoyi: Mother of the Black Resistance in South Africa]&lt;/ref&gt; Uyise wabe esebeza emayini begodu unia wabe asebenza ukuhlanza izambatho.Waceda ukufunda isikolo samabanga aphasi ekilneton. Ipilo yakhe ibukafazi bokuzimisela ukulwisana nombuso wegandelelo Kanye nokubandlulula ngokobulili. Wazinikela ukulwela amalungelo, ikuleleko, nokulingana eSewula Afrika.

UNgoyi wathoma ikhambo lakhe kwezepolitiki ngonyaka we-1970 ekukulapho abalilungale-Garment workers’ union lapho gade asebenza khona ngemitjhini efekthrini yezambatho. Ukuba lilunga kwakhe le- union le kwamenza bona agcine sele alilunga le-African National congress ngonyaka we-1950, Ngesi khathi se-defiance campaign. Ukuba nekghono lokudosa phambili kwamlekela bonyana agcine sele athola ezinye iinkhundla ku- ANC women’s legue abeliseka lomengameli naku Federation of South African Women (FEDSAW) abe ngumongameli wakhona.&lt;ref&gt;[https://www.sahra.org.za/lilian-ngoyi/ LILIAN NGOYI - SAHRA 2025]&lt;/ref&gt;

=== Ukumatjha kwabantu bengubo ===
[[Isimumathi:Lilian Ngoyi.jpg|thumb|Lillian Ngoyi]]
U-Lillian Ngoyi, no Helen Joseph, Rahina Mooosa, Sophia Williams de Bruyn bakghona ukuba ngabanye baboma abadosa phambili ekumatjheni kwabomma nofana kwabantu bengubo ekwenzeka ngelanga le-9 kuRhoboyi ngonyaka we-1956 ekukulapho kwaphuma khona abantu bengubo benarheni yoke yeSewula Afrika abadlula ku-20 000. Bakhamba baya e-union building, ePitori ukuyokunghonghoyila ngomthetho wokudlula ebantwini bengubo. Ngukhona ikwakhe ukukhuluma wazilekelela ngombana wakghona boyana atjele isitjhaba samma bonyana sithule amamithi ama-30 amzabalalzweni.&lt;ref&gt;[https://sahistory.org.za/people/lilian-masediba-ngoyi Lilian Masediba Ngoyi | South African History Online]&lt;/ref&gt;

=== Amakhambo wakhe ===
Bekanande akhamba aye ngaphetjheya ekungeminye yemisikinyeko yakhe yango-1955 waya ku-world Congress of Mothers, eLuasane, Switzerland.&lt;ref&gt;[https://www.blackhistoryheroes.com/2015/07/lillian-ngoyi-mother-of-black.html Black History Heroes: Lillian Ngoyi: Mother of the Black Resistance in South Africa]&lt;/ref&gt; Kukulapho akhuluma khona khona ngabantu bephasi ngokugandelelwa abomma beSewula Afrika abacalene nabo. Ukukhamba kwakhe kwakhe godu kwamusa e-Europe, China neRussia ekukulapho ahlangana khona nabanye abantu bengubo wenza nabo ubudlelwane.Lokho kwasiza kobana akghone ukuthi akhulise umsikinyeko wakhe wokulwisana nombuso wegandelelo.

=== Ukuqunto kwamakhambo ===
Kwathi nakubuya eSewula Afrika njalo wazingelwa lijim lamapholisa elabe lijamele [[umbuso wegandelelo]]. Bamlisisa ezinye zezinto, begodu kwaquntwa namakhambo wakhe wokuya emihlanganweni, nokuthi athule ikulumo lapho kuhlangene khona abantu abanengi. Wathoma ukujanyiswa ngonyaka we1960. Waphila iminyaka ema-15 ngaphambi kwemibandela lena. Nanyana kunjalo waragela phambili ukukhuthaza abanye ngesibindi anaso nokubekezela ebunzimeni.Eskhathini sanje ukhunjulwa njengomuntu owadlala indima ekulweni ikululeko yesitjhaba seSewula Afrika. Usakhunjulwa ngombana kuneentrada, imakhiwo namatliniki abizwa ngegama lakhe, ukwenzela bona ahlale akhunjulwa.

== Iinkomba ==
[[Category:Lillian Ngoyi]]
[[Category:Ubumso wegandelelo]]
[[Category:ilanga labantu bengubo]]</text>
      <sha1>jo8zqe250ho6i7anjyoubhv3gvbr8dt</sha1>
    </revision>
    <revision>
      <id>5200</id>
      <parentid>5199</parentid>
      <timestamp>2025-08-16T10:39:52Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5200</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3483" sha1="dif2zaxn20zx8uh093xvqbp0zpz522n" xml:space="preserve">'''Lillian Masediba Ngoyi''' wabelethwa mhlana amalanga ama-25 kuKhukhulamungu ngonyaka we-1911, endaweni ye –Pretoria esiphandeni se-Gauteng.Wabangomunye wabantwana aba-6 emndenini wakhe.&lt;ref&gt;[https://www.blackhistoryheroes.com/2015/07/lillian-ngoyi-mother-of-black.html Black History Heroes: Lillian Ngoyi: Mother of the Black Resistance in South Africa]&lt;/ref&gt; Uyise wabe esebeza emayini begodu unia wabe asebenza ukuhlanza izambatho.Waceda ukufunda isikolo samabanga aphasi ekilneton. Ipilo yakhe ibukafazi bokuzimisela ukulwisana nombuso wegandelelo Kanye nokubandlulula ngokobulili. Wazinikela ukulwela amalungelo, ikuleleko, nokulingana eSewula Afrika.

UNgoyi wathoma ikhambo lakhe kwezepolitiki ngonyaka we-1970 ekukulapho abalilungale-Garment workers’ union lapho gade asebenza khona ngemitjhini efekthrini yezambatho. Ukuba lilunga kwakhe le- union le kwamenza bona agcine sele alilunga le-African National congress ngonyaka we-1950, Ngesi khathi se-defiance campaign. Ukuba nekghono lokudosa phambili kwamlekela bonyana agcine sele athola ezinye iinkhundla ku- ANC women’s legue abeliseka lomengameli naku Federation of South African Women (FEDSAW) abe ngumongameli wakhona.&lt;ref&gt;[https://www.sahra.org.za/lilian-ngoyi/ LILIAN NGOYI - SAHRA 2025]&lt;/ref&gt;

=== Ukumatjha kwabantu bengubo ===
[[Isimumathi:Lilian Ngoyi.jpg|thumb|Lillian Ngoyi]]
U-Lillian Ngoyi, no Helen Joseph, Rahina Mooosa, Sophia Williams de Bruyn bakghona ukuba ngabanye baboma abadosa phambili ekumatjheni kwabomma nofana kwabantu bengubo ekwenzeka ngelanga le-9 kuRhoboyi ngonyaka we-1956 ekukulapho kwaphuma khona abantu bengubo benarheni yoke yeSewula Afrika abadlula ku-20 000. Bakhamba baya e-union building, ePitori ukuyokunghonghoyila ngomthetho wokudlula ebantwini bengubo. Ngukhona ikwakhe ukukhuluma wazilekelela ngombana wakghona boyana atjele isitjhaba samma bonyana sithule amamithi ama-30 amzabalalzweni.&lt;ref&gt;[https://sahistory.org.za/people/lilian-masediba-ngoyi Lilian Masediba Ngoyi | South African History Online]&lt;/ref&gt;

=== Amakhambo wakhe ===
Bekanande akhamba aye ngaphetjheya ekungeminye yemisikinyeko yakhe yango-1955 waya ku-world Congress of Mothers, eLuasane, Switzerland.&lt;ref&gt;[https://www.blackhistoryheroes.com/2015/07/lillian-ngoyi-mother-of-black.html Black History Heroes: Lillian Ngoyi: Mother of the Black Resistance in South Africa]&lt;/ref&gt; Kukulapho akhuluma khona khona ngabantu bephasi ngokugandelelwa abomma beSewula Afrika abacalene nabo. Ukukhamba kwakhe kwakhe godu kwamusa e-Europe, China neRussia ekukulapho ahlangana khona nabanye abantu bengubo wenza nabo ubudlelwane.Lokho kwasiza kobana akghone ukuthi akhulise umsikinyeko wakhe wokulwisana nombuso wegandelelo.

=== Ukuquntwa kwamakhambo ===
Kwathi nakubuya eSewula Afrika njalo wazingelwa lijim lamapholisa elabe lijamele [[umbuso wegandelelo]]. Bamlisisa ezinye zezinto, begodu kwaquntwa namakhambo wakhe wokuya emihlanganweni, nokuthi athule ikulumo lapho kuhlangene khona abantu abanengi. Wathoma ukujanyiswa ngonyaka we1960. Waphila iminyaka ema-15 ngaphambi kwemibandela lena. Nanyana kunjalo waragela phambili ukukhuthaza abanye ngesibindi anaso nokubekezela ebunzimeni.Eskhathini sanje ukhunjulwa njengomuntu owadlala indima ekulweni ikululeko yesitjhaba seSewula Afrika. Usakhunjulwa ngombana kuneentrada, imakhiwo namatliniki abizwa ngegama lakhe, ukwenzela bona ahlale akhunjulwa.

== Iinkomba ==
[[Category:Lillian Ngoyi]]
[[Category:Ubumso wegandelelo]]
[[Category:ilanga labantu bengubo]]</text>
      <sha1>dif2zaxn20zx8uh093xvqbp0zpz522n</sha1>
    </revision>
    <revision>
      <id>5201</id>
      <parentid>5200</parentid>
      <timestamp>2025-08-16T10:44:14Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5201</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3617" sha1="m8m795vlgkchc1phktdcgzg1h2gocot" xml:space="preserve">'''Lillian Masediba Ngoyi''' wabelethwa mhlana amalanga ama-25 kuKhukhulamungu ngonyaka we-1911, endaweni ye –Pretoria esiphandeni se-Gauteng.Wabangomunye wabantwana aba-6 emndenini wakhe.&lt;ref&gt;[https://www.blackhistoryheroes.com/2015/07/lillian-ngoyi-mother-of-black.html Black History Heroes: Lillian Ngoyi: Mother of the Black Resistance in South Africa]&lt;/ref&gt; Uyise wabe esebeza emayini begodu unia wabe asebenza ukuhlanza izambatho.Waceda ukufunda isikolo samabanga aphasi ekilneton. Ipilo yakhe ibukafazi bokuzimisela ukulwisana nombuso wegandelelo Kanye nokubandlulula ngokobulili. Wazinikela ukulwela amalungelo, ikuleleko, nokulingana eSewula Afrika. Umndeni wakhe wavela bonyana uhlobene nekosi u-Phatudi ehlala e-Lebowa. Abantu bomndeni wakhe babonakala banekghono lokudosa phambili

UNgoyi wathoma ikhambo lakhe kwezepolitiki ngonyaka we-1970 ekukulapho abalilungale-Garment workers’ union lapho gade asebenza khona ngemitjhini efekthrini yezambatho. Ukuba lilunga kwakhe le- union le kwamenza bona agcine sele alilunga le-African National congress ngonyaka we-1950, Ngesi khathi se-defiance campaign. Ukuba nekghono lokudosa phambili kwamlekela bonyana agcine sele athola ezinye iinkhundla ku- ANC women’s legue abeliseka lomengameli naku Federation of South African Women (FEDSAW) abe ngumongameli wakhona.&lt;ref&gt;[https://www.sahra.org.za/lilian-ngoyi/ LILIAN NGOYI - SAHRA 2025]&lt;/ref&gt;

=== Ukumatjha kwabantu bengubo ===
[[Isimumathi:Lilian Ngoyi.jpg|thumb|Lillian Ngoyi]]
U-Lillian Ngoyi, no Helen Joseph, Rahina Mooosa, Sophia Williams de Bruyn bakghona ukuba ngabanye baboma abadosa phambili ekumatjheni kwabomma nofana kwabantu bengubo ekwenzeka ngelanga le-9 kuRhoboyi ngonyaka we-1956 ekukulapho kwaphuma khona abantu bengubo benarheni yoke yeSewula Afrika abadlula ku-20 000. Bakhamba baya e-union building, ePitori ukuyokunghonghoyila ngomthetho wokudlula ebantwini bengubo. Ngukhona ikwakhe ukukhuluma wazilekelela ngombana wakghona boyana atjele isitjhaba samma bonyana sithule amamithi ama-30 amzabalalzweni.&lt;ref&gt;[https://sahistory.org.za/people/lilian-masediba-ngoyi Lilian Masediba Ngoyi | South African History Online]&lt;/ref&gt;

=== Amakhambo wakhe ===
Bekanande akhamba aye ngaphetjheya ekungeminye yemisikinyeko yakhe yango-1955 waya ku-world Congress of Mothers, eLuasane, Switzerland.&lt;ref&gt;[https://www.blackhistoryheroes.com/2015/07/lillian-ngoyi-mother-of-black.html Black History Heroes: Lillian Ngoyi: Mother of the Black Resistance in South Africa]&lt;/ref&gt; Kukulapho akhuluma khona khona ngabantu bephasi ngokugandelelwa abomma beSewula Afrika abacalene nabo. Ukukhamba kwakhe kwakhe godu kwamusa e-Europe, China neRussia ekukulapho ahlangana khona nabanye abantu bengubo wenza nabo ubudlelwane.Lokho kwasiza kobana akghone ukuthi akhulise umsikinyeko wakhe wokulwisana nombuso wegandelelo.

=== Ukuquntwa kwamakhambo ===
Kwathi nakubuya eSewula Afrika njalo wazingelwa lijim lamapholisa elabe lijamele [[umbuso wegandelelo]]. Bamlisisa ezinye zezinto, begodu kwaquntwa namakhambo wakhe wokuya emihlanganweni, nokuthi athule ikulumo lapho kuhlangene khona abantu abanengi. Wathoma ukujanyiswa ngonyaka we1960. Waphila iminyaka ema-15 ngaphambi kwemibandela lena. Nanyana kunjalo waragela phambili ukukhuthaza abanye ngesibindi anaso nokubekezela ebunzimeni.Eskhathini sanje ukhunjulwa njengomuntu owadlala indima ekulweni ikululeko yesitjhaba seSewula Afrika. Usakhunjulwa ngombana kuneentrada, imakhiwo namatliniki abizwa ngegama lakhe, ukwenzela bona ahlale akhunjulwa.

== Iinkomba ==
[[Category:Lillian Ngoyi]]
[[Category:Ubumso wegandelelo]]
[[Category:ilanga labantu bengubo]]</text>
      <sha1>m8m795vlgkchc1phktdcgzg1h2gocot</sha1>
    </revision>
  </page>
  <page>
    <title>KwaNdebele</title>
    <ns>0</ns>
    <id>767</id>
    <revision>
      <id>5214</id>
      <timestamp>2025-08-19T16:20:11Z</timestamp>
      <contributor>
        <username>Mojonom</username>
        <id>593</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1273565397|KwaNdebele]]&quot;</comment>
      <origin>5214</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1652" sha1="ixtehwannjmy6ffkzf2s4npgcvs7vzz" xml:space="preserve">


 


'''I-KwaNdebele''' bekuyi- Bantustan [[Isewula Afrika|eSewula Afrika]], ebegade ihloswe ngurhulumende webandlululo njengelizwe elizijameleko labantu besitjhaba [[AmaNdebele|sama-Ndebele]] . Indawo le yabunjwa ngemva kokobana urhulumende we[[Isewula Afrika|Sewula Afrika]] wangesikhathi sebandlululo azokuthatha isinqumo sokobanyana ilimi nelimi elikhona ngaphasi kwenarha le kufanele libe nendawo yalo engumazibuse, lapha abantu bakhona bazokukhuluma lelo limi kwaphela.

== Umlando ==
Inarha le yavunyelwa ukuzibusa ngoSihlabantangana (April) emnyakeni wee-1981. [[Siyabuswa|I-Siyabuswa]] yakhethwa njengedorobha elikhulu lenarha le, kodwana ngo-1986, idorobha elikhulu lathuthelwa KwaMhlanga . Isibethamthetho saKwaNdebele saveza ikareko lokufuna ukuzijamela (njengombana kwenzeka eendaweni ezifana ne -Transkei, i-Bophuthatswana, i-Venda kanye ne -Ciskei ) ngoMrhayili (May) 1982. Nokho aba khona amalungiselelo enziwako, kodwana ukutlhayela okukhulu kwezomnotho kanye nokuphikisana ngweendawo kwakuvimbela lokhu.  

I-KwaNdebele yabuyiselwa enarhei ye [[Isewula Afrika|Sewula Afrika]] ngemva kwekhetho lika-1994 leSewula Afrika . Njenganje inarha enengi yendawo le iyingcenye yesifunda se [[Isifunda seMpumalanga|-Mpumalanga]] .

== Iimfunda ngo-1991 ==
Iimfunda za[[KwaNdebele]] kanye nenani labantu ngesikhathi sokubalwa kwabantu ngo-1991. 

* [[Mdutjana]]: 125,485
* [[Mkobola]]: 212,771
* Mbibana: 65,989

== Qala godu ==

* AboNgqongqotjhe abaKhulu baKwaNdebele

== Imitlolo ekufunyenwe kiyo ilwazi ==

* South Africa 1980/81 – Official Yearbook of the Republic of South Africa {{ISBN|0-908393-51-2}}, {{ISSN|0302-0681}} 
{{Reflist}}</text>
      <sha1>ixtehwannjmy6ffkzf2s4npgcvs7vzz</sha1>
    </revision>
  </page>
  <page>
    <title>Thuli Madonsela</title>
    <ns>0</ns>
    <id>768</id>
    <revision>
      <id>5215</id>
      <timestamp>2025-08-19T18:11:36Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1291995529|Thuli Madonsela]]&quot;</comment>
      <origin>5215</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2705" sha1="me44zc8fr6bgd14arpfnjnc04tfl9u3" xml:space="preserve">
 

'''U-Thulisile Nomkhosi''' &quot;'''Thuli'''&quot;'''Madonsela''' wabelethwa mhlaka-28kuNobayeni 1962.Mmeli weSewula Afrika nophrofesa wezomthetho,ophethe isihlalo sezobulungiswa bezehlalakahle e-Stellenbosch University kusukela ngoTjhirhweni 2018.Wasebenza njengomvikeli womphakathi weSewula Afrika kusukela mhlana ali-19 kuSewula 2009 ukufika mhlaka-14 kuSewula 2016.Ngo-1996,wasiza ngokutlola umthethosisekelo wokugcina weSewula Afrika owamenyezelwa nguMengameli u-Nelson Mandela. 

== Ipilo yokuthoma nefundo ==
U-Madonsela wabelethwa e-Goli ngo-1962,indodakazi yabarhwebi abangakahleleki u-Bafana no-Nomasonto, begodu wakhulela e-Soweto.Waya e-Evelyn Baring High School e-Nhlangano e-Swatini,lapho umndenakhe uvela khona.Waphothula nge-BA kwezomthetho e-University of the Swaziland ngo-1987,kunye ne-LLB e-University of the Witwatersrand ngo-1990.NgoNtaka ka-2015,u-Madonsela wanikelwa i-Doctor of Laws degree,''LL.'' ''D.(Honoris causa)'' evela eYunivesithi ye-Stellenbosch,kulandele enye idigri kaDorhodera wezomthetho,i-LL.D.(''honoris causa'')evela e -University of Cape Town ngoMgwengweni ka-2015.Ubuye abe nama-doctorate ahloniphekileko avela e-Rhodes University kunye ne-University of Fort Hare.

== Ipolotiki ==
U-Madonsela,bekube ngu-2007,bekalilunga elivamileko legatja le-Pitori le-African National Congress (ANC). Ngesikhathi sebandlululo u-Madonsela wasebenza ku-ANC kunye nehlangano ye-United Democratic Front elwisana nebandlululo.Ukholelwa bona ukubamba isikhundla sepolotiki angeze kwaba &quot;yigalelo lakhe elihle khulu njengomuntu&quot;. Ngo-1994 wala isikhundla se-ANC MP ePalamende yokuthoma yeSewula Afrika ngemva kwebandlululo. NgoTjhirhweni wee-2014 kwabikwa bona amagatja amanengi we-ANC e-Gauteng akhenge aphumelele ukumkhetha njengomuntu ozokujamela i-ANC ku-National Assembly nofana kwenye yeziphathimandla zesifunda ekhethweni mazombe lango-2014.Umkhulumeli wakhe wathi bekangazi ngokuphakanyiswa kwakhe begodu bengeze akwamukele.

== Umsebenzi wokuthoma ==
U-Madonsela bekasebenzela iinyunyana zabasebenzi begodu nasemikhakheni yomphakathi neyangasese kusukela ngeminyaka yabo-1980.Bekalilunga lesiqhema esatlama umthethosisekelo wokugcina weSewula Afrika owamenyezelwa nguMongameli wangaleso sikhathi u-Nelson Mandela ngo-1996.Ngemva kokuhlongakala kwaka-Mandela, u-Madonsela wathi ngokumhlonipha:&quot;Sizokuhlala simhlonipha ngokunikela ngethabo ukuphathwa kwakhe ekuhlolweni okufana neenkhungo ukusekela intando yenengi lokha izenzo zayo nazibuzwako.&quot;Ngaphambi kokubekwa njengo mvikeli womphakathi,u-Madonsela bekasebenza njengelunga lesikhathi esizeleko lekhomitjhini yokutjhugulula umthetho weSewula Afrika,wabekwa esikhundleni ngo-2007 nguMongameli wangaleso sikhathi u-Thabo Mbeki.</text>
      <sha1>me44zc8fr6bgd14arpfnjnc04tfl9u3</sha1>
    </revision>
    <revision>
      <id>5216</id>
      <parentid>5215</parentid>
      <timestamp>2025-08-20T12:05:13Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1291995529|Thuli Madonsela]]&quot;</comment>
      <origin>5216</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7736" sha1="ewljvxja78tcz567k5xn3lfjpwp5y3n" xml:space="preserve">
 

'''U-Thulisile Nomkhosi''' &quot;'''Thuli'''&quot;'''Madonsela''' wabelethwa mhlaka-28kuNobayeni 1962.Mmeli weSewula Afrika nophrofesa wezomthetho,ophethe isihlalo sezobulungiswa bezehlalakahle e-Stellenbosch University kusukela ngoTjhirhweni 2018.Wasebenza njengomvikeli womphakathi weSewula Afrika kusukela mhlana ali-19 kuSewula 2009 ukufika mhlaka-14 kuSewula 2016.Ngo-1996,wasiza ngokutlola umthethosisekelo wokugcina weSewula Afrika owamenyezelwa nguMengameli u-Nelson Mandela. 

== Ipilo yokuthoma nefundo ==
U-Madonsela wabelethwa e-Goli ngo-1962,indodakazi yabarhwebi abangakahleleki u-Bafana no-Nomasonto, begodu wakhulela e-Soweto.Waya e-Evelyn Baring High School e-Nhlangano e-Swatini,lapho umndenakhe uvela khona.Waphothula nge-BA kwezomthetho e-University of the Swaziland ngo-1987,kunye ne-LLB e-University of the Witwatersrand ngo-1990.NgoNtaka ka-2015,u-Madonsela wanikelwa i-Doctor of Laws degree,''LL.'' ''D.(Honoris causa)'' evela eYunivesithi ye-Stellenbosch,kulandele enye idigri kaDorhodera wezomthetho,i-LL.D.(''honoris causa'')evela e -University of Cape Town ngoMgwengweni ka-2015.Ubuye abe nama-doctorate ahloniphekileko avela e-Rhodes University kunye ne-University of Fort Hare.

== Ipolotiki ==
U-Madonsela,bekube ngu-2007,bekalilunga elivamileko legatja le-Pitori le-African National Congress (ANC). Ngesikhathi sebandlululo u-Madonsela wasebenza ku-ANC kunye nehlangano ye-United Democratic Front elwisana nebandlululo.Ukholelwa bona ukubamba isikhundla sepolotiki angeze kwaba &quot;yigalelo lakhe elihle khulu njengomuntu&quot;. Ngo-1994 wala isikhundla se-ANC MP ePalamende yokuthoma yeSewula Afrika ngemva kwebandlululo. NgoTjhirhweni wee-2014 kwabikwa bona amagatja amanengi we-ANC e-Gauteng akhenge aphumelele ukumkhetha njengomuntu ozokujamela i-ANC ku-National Assembly nofana kwenye yeziphathimandla zesifunda ekhethweni mazombe lango-2014.Umkhulumeli wakhe wathi bekangazi ngokuphakanyiswa kwakhe begodu bengeze akwamukele.

== Umsebenzi wokuthoma ==
U-Madonsela bekasebenzela iinyunyana zabasebenzi begodu nasemikhakheni yomphakathi neyangasese kusukela ngeminyaka yabo-1980.Bekalilunga lesiqhema esatlama umthethosisekelo wokugcina weSewula Afrika owamenyezelwa nguMongameli wangaleso sikhathi u-Nelson Mandela ngo-1996.Ngemva kokuhlongakala kwaka-Mandela, u-Madonsela wathi ngokumhlonipha:&quot;Sizokuhlala simhlonipha ngokunikela ngethabo ukuphathwa kwakhe ekuhlolweni okufana neenkhungo ukusekela intando yenengi lokha izenzo zayo nazibuzwako.&quot;Ngaphambi kokubekwa njengo mvikeli womphakathi,u-Madonsela bekasebenza njengelunga lesikhathi esizeleko lekhomitjhini yokutjhugulula umthetho weSewula Afrika,wabekwa esikhundleni ngo-2007 nguMongameli wangaleso sikhathi u-Thabo Mbeki.

== Umvikeli womphakathi ==
U-Madonsela wabekwa njengo-mvikeli womphakathi nguMengameli u-Jacob Zuma weminyaka elikhomba engavuselelekiko ethoma mhlana ali-19&amp;nbsp;kuSewula&amp;nbsp;2009, ngokusekelwa ngazwi linye yi-National Assembly yeenqhema ezinengi.Ekumenyezelweni kokuqatjhwa kwakhe,uZuma wathi uMadonsela &quot;uzokutlhoga ukuqinisekisa bona i-ofisi le iragela phambili nokufinyeleleka ebantwini abajayelekileko begodu yenza umsebenzi wayo ngaphandle kokwesaba namkha ukuthandwa&quot;.U-Madonsela ufanisa indima yakhe njengomvikeli womphakathi nobabakazi wenduna yama -Venda owaziwa nge-M''akhadzi'',umuntu ongasi wezepolotiki &quot;onikela abantu ilizwi ngesikhathi anikela umrholi wesintu umzwangedwa&quot;.

Ngomnyaka ka-2012,waphenya &quot;iinhlawulo&quot;ezatholwa ngu -Julius Malema malungana neenkontraga zomnyango weenkoloyi ezinikelwe ikontraga yangaphandle i-On-Point Engineering.

Njengomvikeli womPhakathi,u-Madonsela wahlolisisa iinghonghoyilo eziphathelene nokusetjenziswa kwemali yomphakathi emzini kaZuma wangasese edorobheni le -KwaZulu-Natal le-Nkandla.Umbiko wakhe wokugcina malungana nokuthuthukiswa kwezokuphepha ekhaya lakaZuma elibizwa nge-''Secure in Comfort'' wagadangiswa mhlana ali-19 kuNtaka 2014.UMadonsela wathola bona uZuma uzuze ngokungakafaneli emalini engu -R246 yeengidi umbuso ebegade ayisebenzise ekuthuthukisweni.Umbiko wakhe uhlangabezane nokusolwa nokuphikiswa okukhulu ngabajameli behlangano ebusako ye-ANC.Ngaphambi kokuthi umbiko wakhe wokugcina wenziwe emphakathini, unobhala jikelele we-ANC u-Gwede Mantashe noNgqongqotjhe wekhabinethi u-Lindiwe Sisulu benza iintatimende zomphakathi ezibukela phasi u-Madonsela nombiko wakhe,u-Mantashe wawubiza ngokuthi &quot;ngumbiko wezepolotiki&quot;.Ngemva kokugadangiswa kwayo,i -African National Congress Youth League (ANCYL) yabawa bona u-Madonsela atjhiye umsebenzi,begodu amalunga we-ANCYL kunye ne-ANC-aligned Congress of South African Students (COSAS)enza amazwi ahlambalazako ngaye.I-COSAS, ebegade ikhutjhwe mphathiswa wekhabinethi wesifazana u-Nosiviwe Mapisa-Nqakula ngekulumo &quot;yokubandlulula ngokobulili&quot;,ngemva kwalokho yarhoqisa &quot;ikulumo yomuntu mathupha eya kumngani u-Madonsela&quot;.I-ANC chief whip u-Stone Sizani wathi &quot;sikholelwa khulu bona weqe umkhawulo&quot; ngokwenza &quot;amazwi ahlambalazako&quot; &quot;aneenthombe zepolotiki&quot;.Isiqhema samagqwetha we-KwaZulu-Natal sathoma ijima lomphakathi wokuhlambalaza umbiko wakhe, begodu wasolwa ngokuba nehlelo lezepolotiki nguNgqongqotjhe weKhabinethi u-Fikile Mbalula.Mhlana ali-4 kuVelabahlinze 2014,amalunga we-ANC ekomidini lephothifoliyo yezobulungiswa aphikisana &quot;nemibono ka-Madonsela enepolotiki&quot; begodu umgcinisihlalo wekomidi u-Mathole Motshekga waphakamisa bona amandla womvikeli womphakathi,alawulwa mthethosisekelo welizwe, abuyekezwe.

=== &quot;Ubujamo bokuthunjwa kombuso&quot; umbiko ===
Umbiko wokugcina ka-Madonsela,&quot;Ubujamo Bokuthunjwa&quot;, wakhutjhwa ngesikhathi isikhathi sakhe seminyaka eyi-7 se-ofisini siphela ngoSewula wee-2016.Umbiko wakhe bewungumphumela wesikhalazo esathunyelwa mfundisi wamaKatolika ubaba u-Stanslaus Muyebe.Umbiko lo uthole ubufakazi bokuthunjwa kombuso,okufaka hlangana ukuthonya okungakalungi komndeni wakwa-Gupta kuMengameli u-Jacob Zuma.U-Madonsela wayala umengameli bona akhethe ikhomitjhini yokuphenya,edoswa phambili lijaji eliqanjwe lijaji elikhulu.U-Zuma wabiza umbiko lo ngokuthi &quot;yi-propaganda yezepolotiki&quot; begodu wawuphikisa ekhotho,kodwana ikhotho ephakemeko yalahla itjhijilo ngoNobayeni 2017,yathola bona u-Zuma kufuze asebenzise amagadango wokulungisa kungakapheli amalanga ama-30, begodu wenza umyalo weendleko zomuntu mathupha ngokujamelene no-Zuma.

== Eminye imisebenzi ==
Ngomnyaka ka-2018 u-Madonsela wanikelwa i -Order of Merit of the Federal Republic of Germany,ngumengameli we-German u-Frank-Walter Steinmeier ngesikhathi avakatjhele iSewula Afrika.U-Steinmeier wathi &quot;Thuli Madonsela, usifundisa bona intando yenengi iqine kangangani nangabe sivikela iinkambisolawulo zayo ngokuzimisela. Kilokhu, uyisibonelo kithi soke samademokhrasi.&quot;

Ngo-2023,u-Madonsela wakhethwa ngunobhala zombelele we-United Nations u-António Guterres eBhodini lezeSayensi le-United Nations.

== Ipilo yomuntu mathupha ==
UMadonsela wakhulisa abantwabakhe ababili, umsana uMusawabantu uFidel nentombazana, uWenzile Una njengombelethi oyedwa.Umyeni wakhe wahlongakala lokha abantwana basebancani khulu.Ngo-1980,u-Madonsela wathoma umsebenzi wakhe njengomsizi wathitjhere esikolweni sakhe sangaphambili,i-Evelyn Baring High School, e-Swaziland. Ngo-1982 waba msizi wathitjhere e-Naledi High School e-Soweto,esinye sezikolo ebezisemkhathini we-1976 Soweto Uprising.Ekupheleni kukaVelabahlinze wee-2018, kwavezwa bona u-Madonsela bekathembisene no-Dick Foxton,umcebisi wezokuthintana nomphakathi.

== Iinkomba ==
1.https://web.archive.org/web/20091129041958/http://www.pprotect.org/about_us/profile_public_protector.asp

2.http://www.whoswho.co.za/thulisile-madonsela-9068

3.https://web.archive.org/web/20091129041958/http://www.pprotect.org/about_us/profile_public_protector.asp&lt;nowiki/&gt;{{Reflist|30em}}</text>
      <sha1>ewljvxja78tcz567k5xn3lfjpwp5y3n</sha1>
    </revision>
    <revision>
      <id>5217</id>
      <parentid>5216</parentid>
      <timestamp>2025-08-20T12:08:30Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>ngifake isithombe esitjha</comment>
      <origin>5217</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7834" sha1="9d9q379i1fizpo6hmg5d0mppsrlkbwi" xml:space="preserve">[[Isimumathi:Thuli Madonsela April 2014.png|thumb|Umvikeli womphakathi walokha u-Thuli Madonsela]]
 

'''U-Thulisile Nomkhosi''' &quot;'''Thuli'''&quot;'''Madonsela''' wabelethwa mhlaka-28kuNobayeni 1962.Mmeli weSewula Afrika nophrofesa wezomthetho,ophethe isihlalo sezobulungiswa bezehlalakahle e-Stellenbosch University kusukela ngoTjhirhweni 2018.Wasebenza njengomvikeli womphakathi weSewula Afrika kusukela mhlana ali-19 kuSewula 2009 ukufika mhlaka-14 kuSewula 2016.Ngo-1996,wasiza ngokutlola umthethosisekelo wokugcina weSewula Afrika owamenyezelwa nguMengameli u-Nelson Mandela. 

== Ipilo yokuthoma nefundo ==
U-Madonsela wabelethwa e-Goli ngo-1962,indodakazi yabarhwebi abangakahleleki u-Bafana no-Nomasonto, begodu wakhulela e-Soweto.Waya e-Evelyn Baring High School e-Nhlangano e-Swatini,lapho umndenakhe uvela khona.Waphothula nge-BA kwezomthetho e-University of the Swaziland ngo-1987,kunye ne-LLB e-University of the Witwatersrand ngo-1990.NgoNtaka ka-2015,u-Madonsela wanikelwa i-Doctor of Laws degree,''LL.'' ''D.(Honoris causa)'' evela eYunivesithi ye-Stellenbosch,kulandele enye idigri kaDorhodera wezomthetho,i-LL.D.(''honoris causa'')evela e -University of Cape Town ngoMgwengweni ka-2015.Ubuye abe nama-doctorate ahloniphekileko avela e-Rhodes University kunye ne-University of Fort Hare.

== Ipolotiki ==
U-Madonsela,bekube ngu-2007,bekalilunga elivamileko legatja le-Pitori le-African National Congress (ANC). Ngesikhathi sebandlululo u-Madonsela wasebenza ku-ANC kunye nehlangano ye-United Democratic Front elwisana nebandlululo.Ukholelwa bona ukubamba isikhundla sepolotiki angeze kwaba &quot;yigalelo lakhe elihle khulu njengomuntu&quot;. Ngo-1994 wala isikhundla se-ANC MP ePalamende yokuthoma yeSewula Afrika ngemva kwebandlululo. NgoTjhirhweni wee-2014 kwabikwa bona amagatja amanengi we-ANC e-Gauteng akhenge aphumelele ukumkhetha njengomuntu ozokujamela i-ANC ku-National Assembly nofana kwenye yeziphathimandla zesifunda ekhethweni mazombe lango-2014.Umkhulumeli wakhe wathi bekangazi ngokuphakanyiswa kwakhe begodu bengeze akwamukele.

== Umsebenzi wokuthoma ==
U-Madonsela bekasebenzela iinyunyana zabasebenzi begodu nasemikhakheni yomphakathi neyangasese kusukela ngeminyaka yabo-1980.Bekalilunga lesiqhema esatlama umthethosisekelo wokugcina weSewula Afrika owamenyezelwa nguMongameli wangaleso sikhathi u-Nelson Mandela ngo-1996.Ngemva kokuhlongakala kwaka-Mandela, u-Madonsela wathi ngokumhlonipha:&quot;Sizokuhlala simhlonipha ngokunikela ngethabo ukuphathwa kwakhe ekuhlolweni okufana neenkhungo ukusekela intando yenengi lokha izenzo zayo nazibuzwako.&quot;Ngaphambi kokubekwa njengo mvikeli womphakathi,u-Madonsela bekasebenza njengelunga lesikhathi esizeleko lekhomitjhini yokutjhugulula umthetho weSewula Afrika,wabekwa esikhundleni ngo-2007 nguMongameli wangaleso sikhathi u-Thabo Mbeki.

== Umvikeli womphakathi ==
U-Madonsela wabekwa njengo-mvikeli womphakathi nguMengameli u-Jacob Zuma weminyaka elikhomba engavuselelekiko ethoma mhlana ali-19&amp;nbsp;kuSewula&amp;nbsp;2009, ngokusekelwa ngazwi linye yi-National Assembly yeenqhema ezinengi.Ekumenyezelweni kokuqatjhwa kwakhe,uZuma wathi uMadonsela &quot;uzokutlhoga ukuqinisekisa bona i-ofisi le iragela phambili nokufinyeleleka ebantwini abajayelekileko begodu yenza umsebenzi wayo ngaphandle kokwesaba namkha ukuthandwa&quot;.U-Madonsela ufanisa indima yakhe njengomvikeli womphakathi nobabakazi wenduna yama -Venda owaziwa nge-M''akhadzi'',umuntu ongasi wezepolotiki &quot;onikela abantu ilizwi ngesikhathi anikela umrholi wesintu umzwangedwa&quot;.

Ngomnyaka ka-2012,waphenya &quot;iinhlawulo&quot;ezatholwa ngu -Julius Malema malungana neenkontraga zomnyango weenkoloyi ezinikelwe ikontraga yangaphandle i-On-Point Engineering.

Njengomvikeli womPhakathi,u-Madonsela wahlolisisa iinghonghoyilo eziphathelene nokusetjenziswa kwemali yomphakathi emzini kaZuma wangasese edorobheni le -KwaZulu-Natal le-Nkandla.Umbiko wakhe wokugcina malungana nokuthuthukiswa kwezokuphepha ekhaya lakaZuma elibizwa nge-''Secure in Comfort'' wagadangiswa mhlana ali-19 kuNtaka 2014.UMadonsela wathola bona uZuma uzuze ngokungakafaneli emalini engu -R246 yeengidi umbuso ebegade ayisebenzise ekuthuthukisweni.Umbiko wakhe uhlangabezane nokusolwa nokuphikiswa okukhulu ngabajameli behlangano ebusako ye-ANC.Ngaphambi kokuthi umbiko wakhe wokugcina wenziwe emphakathini, unobhala jikelele we-ANC u-Gwede Mantashe noNgqongqotjhe wekhabinethi u-Lindiwe Sisulu benza iintatimende zomphakathi ezibukela phasi u-Madonsela nombiko wakhe,u-Mantashe wawubiza ngokuthi &quot;ngumbiko wezepolotiki&quot;.Ngemva kokugadangiswa kwayo,i -African National Congress Youth League (ANCYL) yabawa bona u-Madonsela atjhiye umsebenzi,begodu amalunga we-ANCYL kunye ne-ANC-aligned Congress of South African Students (COSAS)enza amazwi ahlambalazako ngaye.I-COSAS, ebegade ikhutjhwe mphathiswa wekhabinethi wesifazana u-Nosiviwe Mapisa-Nqakula ngekulumo &quot;yokubandlulula ngokobulili&quot;,ngemva kwalokho yarhoqisa &quot;ikulumo yomuntu mathupha eya kumngani u-Madonsela&quot;.I-ANC chief whip u-Stone Sizani wathi &quot;sikholelwa khulu bona weqe umkhawulo&quot; ngokwenza &quot;amazwi ahlambalazako&quot; &quot;aneenthombe zepolotiki&quot;.Isiqhema samagqwetha we-KwaZulu-Natal sathoma ijima lomphakathi wokuhlambalaza umbiko wakhe, begodu wasolwa ngokuba nehlelo lezepolotiki nguNgqongqotjhe weKhabinethi u-Fikile Mbalula.Mhlana ali-4 kuVelabahlinze 2014,amalunga we-ANC ekomidini lephothifoliyo yezobulungiswa aphikisana &quot;nemibono ka-Madonsela enepolotiki&quot; begodu umgcinisihlalo wekomidi u-Mathole Motshekga waphakamisa bona amandla womvikeli womphakathi,alawulwa mthethosisekelo welizwe, abuyekezwe.

=== &quot;Ubujamo bokuthunjwa kombuso&quot; umbiko ===
Umbiko wokugcina ka-Madonsela,&quot;Ubujamo Bokuthunjwa&quot;, wakhutjhwa ngesikhathi isikhathi sakhe seminyaka eyi-7 se-ofisini siphela ngoSewula wee-2016.Umbiko wakhe bewungumphumela wesikhalazo esathunyelwa mfundisi wamaKatolika ubaba u-Stanslaus Muyebe.Umbiko lo uthole ubufakazi bokuthunjwa kombuso,okufaka hlangana ukuthonya okungakalungi komndeni wakwa-Gupta kuMengameli u-Jacob Zuma.U-Madonsela wayala umengameli bona akhethe ikhomitjhini yokuphenya,edoswa phambili lijaji eliqanjwe lijaji elikhulu.U-Zuma wabiza umbiko lo ngokuthi &quot;yi-propaganda yezepolotiki&quot; begodu wawuphikisa ekhotho,kodwana ikhotho ephakemeko yalahla itjhijilo ngoNobayeni 2017,yathola bona u-Zuma kufuze asebenzise amagadango wokulungisa kungakapheli amalanga ama-30, begodu wenza umyalo weendleko zomuntu mathupha ngokujamelene no-Zuma.

== Eminye imisebenzi ==
Ngomnyaka ka-2018 u-Madonsela wanikelwa i -Order of Merit of the Federal Republic of Germany,ngumengameli we-German u-Frank-Walter Steinmeier ngesikhathi avakatjhele iSewula Afrika.U-Steinmeier wathi &quot;Thuli Madonsela, usifundisa bona intando yenengi iqine kangangani nangabe sivikela iinkambisolawulo zayo ngokuzimisela. Kilokhu, uyisibonelo kithi soke samademokhrasi.&quot;

Ngo-2023,u-Madonsela wakhethwa ngunobhala zombelele we-United Nations u-António Guterres eBhodini lezeSayensi le-United Nations.

== Ipilo yomuntu mathupha ==
UMadonsela wakhulisa abantwabakhe ababili, umsana uMusawabantu uFidel nentombazana, uWenzile Una njengombelethi oyedwa.Umyeni wakhe wahlongakala lokha abantwana basebancani khulu.Ngo-1980,u-Madonsela wathoma umsebenzi wakhe njengomsizi wathitjhere esikolweni sakhe sangaphambili,i-Evelyn Baring High School, e-Swaziland. Ngo-1982 waba msizi wathitjhere e-Naledi High School e-Soweto,esinye sezikolo ebezisemkhathini we-1976 Soweto Uprising.Ekupheleni kukaVelabahlinze wee-2018, kwavezwa bona u-Madonsela bekathembisene no-Dick Foxton,umcebisi wezokuthintana nomphakathi.

== Iinkomba ==
1.https://web.archive.org/web/20091129041958/http://www.pprotect.org/about_us/profile_public_protector.asp

2.http://www.whoswho.co.za/thulisile-madonsela-9068

3.https://web.archive.org/web/20091129041958/http://www.pprotect.org/about_us/profile_public_protector.asp&lt;nowiki/&gt;{{Reflist|30em}}</text>
      <sha1>9d9q379i1fizpo6hmg5d0mppsrlkbwi</sha1>
    </revision>
  </page>
  <page>
    <title>U-Dorhodere Nothembi Mkhwebane</title>
    <ns>0</ns>
    <id>770</id>
    <revision>
      <id>5223</id>
      <timestamp>2025-08-21T12:55:35Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>i added a new article</comment>
      <origin>5223</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4416" sha1="59i4cq8j4m0t2o2beh622gl3dsfpgcu" xml:space="preserve">== U-Dorh Nothembi Mkhwebane ==
[[Isimumathi:Guitar MET DP217185.jpg|thumb|Igatara ]]
U-'''Peki Emelia Nothembi Mkhwebane''' wabelethwa e-Carolina e-Mpumalanga mhlana ali-1 kuTjhirhweni 1953.Waba intandani aneminyaka emihlanu,wakhuliswa ngu-gogo nomkhulu ebebangakghoni ukumbhadalela ifundo ehlelekileko.Isikhathi esinengi sepilo yakhe yekukhuleni wasichitha ngokutlhogomela iinkomo nezimvu zika bamkhulu wakhe.Leyo bekungiyo indlela ebegade baziphilisa ngayo ngaleso sikhathi begodu bekungasimsebenzi omumbi khulu kumntazana.

=== Ukuthanda umvumo nomndeni ===
Umndeni kaMkhwebane bewuthanda umvumo begodu wakhulisa ithando lakhe lokuthoma ngeengoma zesiNdebele.Ugogo wakhe wamfundisa ukudlala i-reed flute,lokha udadwabo amfundisa isikumero.Umalume wakhe wamfundisa ukudlala igatara eyenziwe ngekhaya,esikhungweni somvumo namasiko wesiNdebele ,uMkhwebane wafunda okunengi ngokunotha kwamasiko wakhe begodu ngokukhamba kwesikhathi wathoma isiqhema somvumo esaziwa ngokuthi ZIizelamani Zako Nomaziyana ebegade zidlala emibuthanweni nemitjhadweni.

Ngokukhamba kwesikhathi wathenga ikhibhodi negatari ngomqopho wokutlama iingoma ezazirekhoda.Nanyana gade aphumelele khulu bekasatlhoga ukuthola ikhamphani yokurekhoda,khulukhulu ngombana enye yezinto ebezigade zimliya bekukungaka fundi kwakhe okwaba sithiyo ekufumaneni imali evela ekuphumeleleni kokurekhoda.

==== Ukuba yindlovukazi yomvumo wesiNdebele ====
Bekangakaze aphelelwe lithemba begodu akhuthazwa lithando ne-thalenta lakhe,uMkhwebane wahlula inengi leentjhijilo waba mvumi odumileko ephasini loke ngomvumo wesiNdebele.UKhambe khulu eenarheni zangaphandle adlala eenarheni ezifana ne-United States Of America (USA),Austria,Germany,Portugal kunye ne-France.Ngomnyaka ka-1988 e-New York ne-London begodu wafumana umvuzo wengoma yesiNdebele ehle khulu.Waziwa bonyana yindlovukazi womvumo wesiNdebele phakathi komnyaka ka-1984 ukuya ngomnyaka ka-2001,wakhupha ama-albhamu womvumo abunane.Ukuhlabela kwakhe,ukujida kwakhe nokumbatha kwakhe kwamukela isithombe esinemikhakha eminengi yamasiko wamaNdebele.

===== Ukuthuthukisa ilimi lesiNdebele nabo nongorwana =====
Waphakamisela phezulu isiko lamaNdebele ephasini loke,esikhathini lapho abantu abanengi bebalithatha njengelingaka qakatheki ephasini loke.Nakabona umphumela omumbi wokungafundi emsebenzini wakhe,uMkhwebane waqunta ukubuyela esikolweni ngomqopho omkhulu wokwenza i-digri womvumo.Ngembatho lakhe nangendlela avuma ngayo ukghonile ukuthuthukisa isiNdebele emikhakheni eminengi kunye neenarheni zangaphetjheya ezinengi lapho khona bekangavumi kwaphela kodwana bekakhangisa ngevunulo ehlukahlukeneko eembathwa sitjhaba samaNdebele.

UMkhwebane uphiwe imitlomelo eminengi,lokhu kufaka hlangana i-Woza Africa Foundation Award ngo-1988.U -Femina/NNTV owengubo wama-90s ngo-1995,inxusa lezokuvakatjha le-Sewula Afrika ngo-1998 kunye ne-Mpumalanga Sports Recreational Arts and Culture Award ngo-1999.Wabuya godu wafumana i-South African Music Award:Honorary Award:Best Ndebele Music Ikwekwezi fm bgo-1999,kunye ne Bow and Arrow ngo-2001.I-Order Of Ikhamanga in Silver iqakathekisa ukugqugquzela okukhulu kwamaqhawekazi amanengi wamasiko wethu.

====== Ijima lokuthuthukisa umphakathi ======
[[Isimumathi:Ndebele Architecture.jpg|thumb|Indlu egwale ngesiNdebele]]
Indlovukazi yomvumo wesiNdebele u-Dorh Nothembi Mkhwebane utjhugulule ikhaya lakhe e-Pitori laba yindawo yobuciko nomvumo ukuhlomisa umphakathi wakhe.UMkhwebane  umvumi onelwazi uthe ngesikhungo lesi ubinge ukuthuthukisa amakghono wabantu abatjha nabakhulu.Isikhungo sathoma egaraji lakhe ngo-2019 begodu sikhule eminyakeni emithathu edlulileko.

Ngebanga lokutlhogeka kwamakghono anikelwako,u-Mkhwebane wakateleleka bona akhe indawo ekulu ngokusizwa mnyango wezemidlalo,ubukghwari namasiko.Lapha abantu bafundiswa bona bangakha njani imikhiqizo yomncamo,ubuciko nemihlobiso.UMkhwebane godu usebenzisa isikhungo lesi ukwabelana ngesiko lamaNdebele,ukufundisa iinsimbi zomdabu,umvumo kunye nokwabelana ngelwazi lokudla kwesintu nesizukulwana esitjha.

====== Iinkhombo ======
1.https://www.sowetanlive.co.za/entertainment/2023-07-31-musician-nothembi-turns-her-home-into-museum/
2.https://www.last.fm/music/Nothembi+Mkhwebane/+wiki
3.https://www.kaya959.co.za/nothembi-mkhwebane-queen-of-ndebele-music/
4.https://www.thepresidency.gov.za/peki-emelia-nothembi-mkhwebane-1953
5.https://annabellelombard.wordpress.com/tag/dr-nothembi-mkhwebane/</text>
      <sha1>59i4cq8j4m0t2o2beh622gl3dsfpgcu</sha1>
    </revision>
  </page>
  <page>
    <title>E-Middelburg, e-Mpumalanga</title>
    <ns>0</ns>
    <id>771</id>
    <revision>
      <id>5225</id>
      <timestamp>2025-08-24T23:04:19Z</timestamp>
      <contributor>
        <username>Mojonom</username>
        <id>593</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1307115169|Middelburg, Mpumalanga]]&quot;</comment>
      <origin>5225</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6444" sha1="fmjwgx32h6amtagnsh2nuj5xvp7rv4q" xml:space="preserve">
'''I-Middelburg''' yidorobha elikhulu elisesifundeni se[[Isifunda seMpumalanga|-Mpumalanga]] [[Isewula Afrika|eSewula Afrika]] .

== Umlando ==
Kokuthoma indawo le yasungulwa njengesitetjhi esiphakathi kwendawo ye-Lydenburg ne-Pitori yi- Republic of Lydenburg ngo-1860. . Iriphabliki leyo yahlangana neRiphabhliki yeSewula Afrika (i-ZAR) ngemva kwesikhathi esingasi side. &lt;ref name=&quot;Pan743&quot; /&gt; : 30 Idorobha elahlongozwako lasungulwa hlangana namamaplasi amabili, ''i-Klipfontein'' ne ''-Keerom.'' Kodwana ke, lokha iBandla le-Dutch Reformed nalisungula isondo eliseduze neplasi le ''-Sterkfontein'', idorobha leli lathuthelwa lapho. Ekuthomeni, khabe libizwa njenge-Nasareth ngo -1864, libizwa ma-Voortrekkers emahlangothini [[Umlambo i-Olifants (i-Limpopo)|womlambo i-Klein Olifants]].&lt;ref name=&quot;Pan743&quot; /&gt; Ngomnyaka ka-1872 yatjhugululwa ibizo yaba yi-Middelburg ekulibizo elitshwaya  bona indawo namkha idorobha leli  lihlangana nedorobha elikhulu le- Transvaal i-Pretoria, kunye  nedorobha le- Lydenburg ekungelamamayini wegolide .  &lt;ref name=&quot;Pan743&quot; /&gt;isondo le bandla le-Dutch Reformed lakhiwa ngo-1890. &lt;ref name=&quot;Pan743&quot; /&gt;  AmaNgisi akha ikampa ekulu yokubeka iimbotjhwa e-Middelburg ngesikhathi sePi yesiBili yamaBhunu . &lt;ref name=&quot;Pan743&quot; /&gt;  Imyuziyamu yeSikhumbuzo yakhiwe endaweni eduze kwamathuna ali-1,381 wabantu abasikazi nabantwana abahlongakala ekampeni leli leembotjhwa. &lt;ref name=&quot;Pan743&quot; /&gt;. 

== I-Geography ==

=== Imiphakathi ===

* I-Aerorand - Idorojana elitjha eMiddleburg
* I-CBD - ingcenye encani khulu yedrobhena
* I-Groenkol - izindlu ezilungisiweko ezisezingeni eliphezulu
* I-Dennesig - ebizwa ngemithi ye-conifer esakazeke edorojaneni
* I-Golfsig - idorojana elisezingeni eliphezulu elinekundla yomdlalo i-golf
* I-Clubville - idorojana elizele amakari elinamabala amanengi we golf
* Indawo yamabubulo - amabhizinisi ahlukahlukeneko wamabubulo
* I-Kanonkop - Indawo lapha kunamathuna wabantu ebebabekwe ekampeni leembotjhwa le-Britain.
* Mhluzi - Ngaphambilini bekuyindawo yama- Afrikha ngesikhathi sombuso webandlululo
* I-Mineralia - idorojana elithiywe ngemva kwamadiphozithi wamaminerali
* I-Nasareth - Idorobha ebegade lingelama Colored elisepumalanga yedorobha 
* I-Eastdene - Ngaphambilini bekuyidorojana lama-Indian
* I-Rockdale - indawo yokuhlala emaphethelweni weplasi i-Rockdale 442 JS
* Hlalamnandi- Ngelinye lamadorojana atholakala eMiddleburg.

== Iinbalo zabantu ==
 
Amakhulu wabantu abasuka eenarheni zangaphandle nemindeni yabobathuthela edorobheni leli ngeminyaka yabo-1950, 1960 kunye neyabo 1970. Ngobunengi khabe bavela e-United Kingdom nakwezinye iindawo ze-Europe. Ukuza kwabo kwaba ngebanga lokugwema ukuwohloka kwemikhakha yamabubulo neyokukhiqiza ekwabangelwa  yiPi yesi-II yePhasi emazweni lawo. Imindeni le beyikhangwa sidingo sobucwephetjhe kwezebubulo eentjalweni, begodu kanengi bathokozwa ngezindlu ezixhaswe ziinkampani begodu abanye behliselwa imali eemfundweni zabo.

Abantwana bemindeni yabafuduki labo bathuthela emadorobheni amakhulu aseduze we-Witbank, i-Pitori kunye ne-Johannesburg, ukuyokufuna umsebenzi, nofana basale baba yingcenye yemisebenzi yezomnotho ekhulako endaweni leyo.

Namhlanjesi, idorobha liqalene neendaba ezinengi ezijayelekileko emadorojaneni weSewula Afrika. Lokhu kufaka iintjhijilo ezifana nokukhuluma ngokungalingani kwabantu nasiza ekuletheni insiza ebantwini nemakhiweni khulukhulu emalokitjhini nemadorojaneni aseduze, ebekenzelwe imihlobo yabantu abanzima kunye neyamandiya, ngaphasi kombuso webandlululo. Amasiko wedorobha ahlukile, ukusuka emindenini ekhuluma  iAfrikaans, kuya kweminye imihlobo yabantu abanzima. Godu kuphinde kube namasiko wabafuduki abavela e- United Kingdom ne -Europe. Esinye isitjhijilo esikhona kumumukghwa wokufuduka okurhabako kwabantu bedorobheli basuka emadorobheni amancani batjhinge emadorobheni amakhulu ukufuna amathuba kwezomnotho.

Ngo-2016, abantu ababaliweko abahlala endaweni le khabe bayi -278,000 begodu izinga lokukhula elingama-4.9%.umnyango wezeembalo kamasipala uveze isilinaniso sokobana inani labantu lizakuba yi-500,000 ngo-2030. Idorobheli linamabutho wamapholisa amakhulu khulu esifundeni, isibhedlela kunye nomtholampilo. kanye neembhedlela ezizijameleko. Godu iinkolo zomphakathi ezinengi.

=== Ikolo ===
I-Middelburg inevelaphi yobuKrestu, ngombana isondo le-Dutch Reformed elidala khulu ngelo elikhulunywe ngalo ngehla elaziwa ngcono nge-&quot;Die Witkerk.&quot;

Amabandla edorobheni:

* I-Dutch Reformed (NG Kerk)
* I-Nederduitsch Hervormde Kerk van Afrika (i-Nederduits Reformed Church of Africa) kusukela mhlazi-01.04.1864 - amapharishi amabili, i-Middelburg ne-Middelburg-Noord mhlana ama-28.08.1977
* I-AFM-AGS Apostolic Faith Mission (Lighuis Gemeente, Corpus Christi, AGS Sentraal)
* Ibandla lePentekoste lamaProthestani (i-Lofdal Gesinskerk, e-Woord-en-Kruis Gemeente.)
* I-Baptist
* I-Baptist etja ezijameleko ye-Fundamentalist
* I-Methodist
* I-African Methodist Episcopal Church (Nazareth Chapel)
* amaKatolika
* I-Full Gospel Church (i-VEK Presence Church)
* Isonto lamaKrestu leZiyoni
* Ibandla le-Holy Trinity Anglican
* Amasonto azijameleko
* Ibandla le-Evangelical Lutheran
* Ibandla le-Lutheran Bapedi
* Isonto le-St Peter's Confessional Lutheran of South Africa
* I-Presbyterian
* I-ECF (Eastdene Christian Fellowship) 1988
* Isonto lamaKrestu le-Shalom
* Ibandla le-Solid Ground

.

== Zomnotho ==
Amabhizinisi amakhulu atholakala edorobheni leli yi-Columbus Stainless, ifemu ekulu yeensimbi eyakhiwa ngo-1965, kunye ne-Thos Begbie &amp; Co, ekuyikampani eyathonywa ngo-1887 ngu-Thomas Begbie. 

== Amasiko nepilo yesimanjemanje ==

=== Ivakatjhobukela ===
[[Isimumathi:Station_Middelburg_MP.JPG|left|thumb|Isitetjhi sesitimela se-Middelburg]]
Ezinye iindawo ezikhona hlangana nedorobheli kuyimyuziyamu yesitetjhi se-Botshabelo [https://web.archive.org/web/20090623041241/http://www.places.co.za/html/botshabelo.html] ekuyindawo egwalwe sitjhaba [[AmaNdebele|sama-Ndebele]]. 

== Abantu Abaziwako. ==

*
* U-Jele othabileko - umdlali webholo. Wake waba ngukaputeni we -Orlando Pirates, begodu omunye wabadlali abadlale isikhathi eside khulu be-Orlando Pirates.
* [[Esther Mahlangu]] - isikghwari esivela esitjhabeni [[AmaNdebele|samaNdebele]] . Waziwa ngemigwalo yakhe.
* U- Vincent Mahlangu - umlingisi nomvumi
* U-Gerhardus Pienaar - umphosi we-javelin
* U- Nothando Vilakazi - umdlali wesiqhema sebholo sesitjhaba se -Spain Primera Division neSewula Afrika</text>
      <sha1>fmjwgx32h6amtagnsh2nuj5xvp7rv4q</sha1>
    </revision>
  </page>
  <page>
    <title>IYunivesithi ye-Pitori</title>
    <ns>0</ns>
    <id>772</id>
    <revision>
      <id>5226</id>
      <timestamp>2025-08-24T23:31:33Z</timestamp>
      <contributor>
        <username>Mojonom</username>
        <id>593</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1305292120|University of Pretoria]]&quot;</comment>
      <origin>5226</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1677" sha1="ducwq1o7uz8yv6thxrgndybwz5priqg" xml:space="preserve">
'''IYunivesithi ye-Pitori''' kuyiyunivesithi eyathonywa ngo-1908 njengekhampasi yePitori engaphasi kwe Transvaal University College ese- [[Johannesburg|Jwanashege]]. Iyunivesithi yathoma ngokuba nabafundi abama-32 ngomnyaka we 1908 kufikela ebafundini abama-53 000 ngo-2025. Nje, iyunivesithi leinamakhampasi alikhomba akhona hlangana nedorobha lePitori.

Iyunivesithi ivamise ukubizwa ngokuthi yi-UP, i-Tuks namkha i-Tukkies.
[[File:University_of_Pretoria_Old_Arts_building.jpg|left|thumb|Umakhiwo we Old Arts Building ofunyaniseka ngaphakathi kweYunivesithi.{{center|The [[Old Arts Building (University of Pretoria)|Old Arts Building]] in 1910, now a [[Provincial heritage site (South Africa)|provincial heritage site]]}}]]
[[Isimumathi:University_of_Pretoria_Campus_plan_1930.jpg|left|thumb|uMebhe weYunivesithi ngomnyaka ka 1930{{center|University of Pretoria Main Campus master plan in 1930}}]]

== Ukuphathwa nokuhlela ==

=== Ama Faculty Akhona neminyaka yokuthonywa kwawo. ===
{| class=&quot;toccolours&quot; style=&quot;float:right; margin-left:1em; font-size:90%; line-height:1.4em; width:300px;&quot;
! colspan=&quot;2&quot; style=&quot;text-align: center;&quot; |Ukuthonywa kweFaculty
|-
|iFaculty
|Umnyaka Wokuthonywa
|-
| colspan=&quot;2&quot; |
----
|-
|I-Fakhalthi yezeSayensi yezomNotho neyokuPhatha
| 1920
|-
| I-Fakhalthi yezeFundo
| 1902
|-
|IFaculty yezobunjiniyera, ukwakha kunye nobucwephethe
| 1908
|-
| I-Faculty yezeSayensi yezamaPhilo
| 1943
|-
| I-Faculty of Humanities
| 1908
|-
| I-Faculty yezomThetho
| 1908
|-
| I-Faculty yezeSayensi yezeMvelo neyezokuLima
| 1917
|-
| I-Faculty yezekolo
| 1919
|-
|I Faculty Yezokutjhejwa kweenlwana
| 1920
|-
| I-Gordon Institute of Business Science
| 2000
|}</text>
      <sha1>ducwq1o7uz8yv6thxrgndybwz5priqg</sha1>
    </revision>
  </page>
  <page>
    <title>IYunivesithi ye-Pretoria</title>
    <ns>0</ns>
    <id>773</id>
    <revision>
      <id>5228</id>
      <timestamp>2025-08-24T23:44:37Z</timestamp>
      <contributor>
        <username>Mojonom</username>
        <id>593</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1305292120|University of Pretoria]]&quot;</comment>
      <origin>5228</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1739" sha1="0mkdfl1xv06henk2tsc7jt4n39ymmtn" xml:space="preserve">
'''IYunivesithi YePretoria''' kuyiyunivesithi eyathonywa ngo-1908 njengekhampasi yePitori engaphasi kwe Transvaal University College ese- [[Johannesburg|Jwanashege]]. Iyunivesithi yathoma ngokuba nabafundi abama-32 ngomnyaka we 1908 kufikela ebafundini abama-53 000 ngo-2025. Nje, iyunivesithi leinamakhampasi alikhomba akhona hlangana nedorobha lePitori. 


Iyunivesithi ivamise ukubizwa ngokuthi yi-UP, i-Tuks namkha i-Tukkies.
[[File:University_of_Pretoria_Old_Arts_building.jpg|left|thumb|Umakhiwo we Old Arts Building{{center|The [[Old Arts Building (University of Pretoria)|Old Arts Building]] in 1910, now a [[Provincial heritage site (South Africa)|provincial heritage site]]}}]]
[[Isimumathi:University_of_Pretoria_Campus_plan_1930.jpg|left|thumb|Umebhe we Yunivesithi ngomnyaka ka 1930{{center|University of Pretoria Main Campus master plan in 1930}}]]

== Ama Faculty we Yunivesity ==
{| class=&quot;toccolours&quot; style=&quot;float:right; margin-left:1em; font-size:90%; line-height:1.4em; width:300px;&quot;
! colspan=&quot;2&quot; style=&quot;text-align: center;&quot; |Ukusungulwa kwefakhalthi
|-
| '''I-Fakhalthi'''
| '''Umnyaka owasungulwa'''
|-
| colspan=&quot;2&quot; |
----
|-
|I-Fakhalthi yezeSayensi yezomNotho neyokuPhatha
| 1920
|-
| I-Fakhalthi yezeFundo
| 1902
|-
| Ubunjiniyela, iBhoduluko elakhiweko kanye neThekhnoloji yeLwazi
| 1908
|-
| I-Faculty yezeSayensi yezamaPhilo
| 1943
|-
| I-Faculty of Humanities
| 1908
|-
| I-Faculty yezomThetho
| 1908
|-
| I-Faculty yezeSayensi yezeMvelo neyezokuLima
| 1917
|-
| I-Faculty yezekolo
| 1919
|-
|IFaculty Yeenlwana
| 1920
|-
| I-Gordon Institute of Business Science
| 2000
|}

== Ikhampasi ekulu ==
[[Isimumathi:Ou_Lettere,_d,_Tuks.jpg|left|thumb| {{center|The Old Arts building now contains several museums}}]]</text>
      <sha1>0mkdfl1xv06henk2tsc7jt4n39ymmtn</sha1>
    </revision>
    <revision>
      <id>5235</id>
      <parentid>5228</parentid>
      <timestamp>2025-08-26T22:15:47Z</timestamp>
      <contributor>
        <username>Mojonom</username>
        <id>593</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1305292120|University of Pretoria]]&quot;</comment>
      <origin>5235</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1693" sha1="6gzyfenu2n43l2zy8rjc131jhn717gh" xml:space="preserve">
iYunivesithi yePretoria kuyiYunivesithi enzinze edorobheni elikhulu lenarha ye[[Isewula Afrika|Sewula Afrikha]] i [[:en:Pretoria|Pretoria]] (IPitori). iYunivesithi le yatlanywa ngomnyaka we-1908, njengekhampasi esePitori yesikolo ekhabe sibizwa ngokuthi yi Transvaal University College. Njenganje, iYunivesithi le inamakhampasi alikhomba asabalale eendaweni ezihlukileko khona ngaphakathi kwedorobha lePitori. Kokuthoma, iYunivesithi le yaba nabafundi abama-32. Kodwana ngokukhamba kweminyana, inani nokho lakhula kwaze kwafika enanini lapha sele inabantwana abandlula ku 55 000 ngomnyaka ka 2023. Amagama ajwayelekileko weYunivesithi le, ligama le UP namkha i Tuks. 
[[File:University_of_Pretoria_Old_Arts_building.jpg|left|thumb|Umakhiwo we Old Arts ngaphakathi kweYunivesithi. eKhampasini yase Hatfield{{center|The [[Old Arts Building (University of Pretoria)|Old Arts Building]] in 1910, now a [[Provincial heritage site (South Africa)|provincial heritage site]]}}]]

== Ama-Faculty we Yunivesithi ==
{| class=&quot;toccolours&quot; style=&quot;float:right; margin-left:1em; font-size:90%; line-height:1.4em; width:300px;&quot;
! colspan=&quot;2&quot; style=&quot;text-align: center;&quot; |Ama-Faculty Nokuthonywa kwabo
|-
|I-Faculty
|Umnyaka wokuthonywa kwe-Faculty
|-
| colspan=&quot;2&quot; |
----
|-
|i-Faculty yobusayensi bomnotho nokuphatha
| 1920
|-
|i-Faculty yeFundo
| 1902
|-
|i-Faculty yobunjiniyera, Ukwakha eendaweni neyezobucwephetjhe
| 1908
|-
|i-Faculty yesayensi nepilo
| 1943
|-
|i-Faculty yezobuntu
| 1908
|-
| I-Faculty yezomThetho
| 1908
|-
|i-Faculty yesayenzi yeMvelo neyokulima
| 1917
|-
| I-Faculty yezekolo
| 1919
|-
| I-Fakhalthi yeSayensi yeenlwana
| 1920
|-
| I-Gordon Institute of Business Science
| 2000
|}</text>
      <sha1>6gzyfenu2n43l2zy8rjc131jhn717gh</sha1>
    </revision>
  </page>
  <page>
    <title>UMasipala we Dr JS Moroka</title>
    <ns>0</ns>
    <id>774</id>
    <revision>
      <id>5234</id>
      <timestamp>2025-08-26T22:00:12Z</timestamp>
      <contributor>
        <username>Mojonom</username>
        <id>593</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1274415085|Dr JS Moroka Local Municipality]]&quot;</comment>
      <origin>5234</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1655" sha1="p4p4v8ci265ghvconysbpui089iuv79" xml:space="preserve">'''uMasipala we Dr JS Moroka'''  ngumasipala wemakhaya ongaphasi kukaMasipala wesiFunda se-Nkangala, esifundeni se[[Isifunda seMpumalanga|-Mpumalanga]] [[Isewula Afrika|eSewula Afrika]] . I-Ofisi elikhulu likaMasipala lo linzinze endaweni ye[[Siyabuswa]]. Uthiyelelwe ngobaba u[[:en:James_Moroka|James Moroka]], obekanguMengameli-Jikelele wesi-8 wehlangano i[[:en:African_National_Congress|African National Congress.]]

== Iindawo ezikulu ==
Ngokweembalo balo zomnyaka ka 2001, Iindawo ezikumasipala lo zihlukaniseke ngendlela elandelako.
{| class=&quot;wikitable sortable&quot;
!Indawo
!Ikhowudi
! Indawo (km &lt;sup&gt;2&lt;/sup&gt; )
!Inani labantu
! Ilimi elikhulunywa khulu
|-
| [[Dr JS Moroka]]
| [http://census.adrianfrith.com/place/81301 81301]
| 186.37
| 185
| IsiSotho seTlhagwini
|-
| [[Kameelpoort]]
| [http://census.adrianfrith.com/place/81302 81302]
| 0.93
| 1,639
| IsiSotho seTlhagwini
|-
| Mbibana
| [http://census.adrianfrith.com/place/81303 81303]
| 16.73
| 6,098
| IsiSotho seTlhagwini
|-
| [[Mdutjana]]
| [http://census.adrianfrith.com/place/81304 81304]
| 260.44
| 84,756
| [[Isindebele|IsiNdebele seSewula]]
|-
| [[Moretele, Mpumalanga|Moretele]]
| [http://census.adrianfrith.com/place/81305 81305]
| 915.02
| 112,330
| IsiTswana
|-
| [[Moutse 2]]
| [http://census.adrianfrith.com/place/81306 81306]
| 4.40
| 0
| -
|-
| [[Siyabuswa]]
| [http://census.adrianfrith.com/place/81307 81307]
| 13.56
| 26,273
| IsiNdebele seSewula
|-
| I-Toitskraal
| [http://census.adrianfrith.com/place/81308 81308]
| 0.47
| 207
| IsiNdebele seSewula
|-
| [[IVaalbank|I-Libangeni]]
| [http://census.adrianfrith.com/place/81309 81309]
| 3.85
| 11,818
| IsiSotho seTlhagwini
|}</text>
      <sha1>p4p4v8ci265ghvconysbpui089iuv79</sha1>
    </revision>
  </page>
  <page>
    <title>Umasipala wendawo we-Thembisile Hani</title>
    <ns>0</ns>
    <id>775</id>
    <revision>
      <id>5236</id>
      <timestamp>2025-08-26T22:30:17Z</timestamp>
      <contributor>
        <username>Mojonom</username>
        <id>593</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1250821622|Thembisile Hani Local Municipality]]&quot;</comment>
      <origin>5236</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2717" sha1="g8jqssjcwh8t35f5pztic33js5we5ff" xml:space="preserve">'''Umasipala we-Thembisile Hani''' ngumasipala wemakhaya ongaphasi kukaMasipala wesiFunda se-Nkangala, esifunndeni se[[Isifunda seMpumalanga|-Mpumalanga]], [[Isewula Afrika|eSewula Afrika]]. uMasipala lo, uneendawo zemakhaya ezima-57 begodu amalokitjhi akhona malokitjhi amahlanu. Ngesikhathi sebandlululo, iindawo ezinengi ngaphasi komasipala lo khabe kuziindawo ezingsaphasi kombuso ozijameleko waKwaNdebele. Umasipala uthiyelelwe ngobaba uThembisile Chris Hani, ebekangunobhala wehlangano i South African Communist Party, owabulawa mhlazana ali 10 ku Sihlabantangana ngo 1993. Eminye yemirhatjho eyaziwa khulu nerhatjhwa kilendawo, kumrhatjho obizwa ngokobanyana yi Flare Fm SA, ekumrhatjho onzinze endaweni yase Phola. KwaMhlanga.

== Iindawo eziku Masipala ==
Iimbalobalo zangomnyaka ka 2001 ziveza ukubalwa kwabantu ngaphasi komasipala lo ngendlela elandelako.
{| class=&quot;wikitable sortable&quot;
!Indawo
!Ikhowudi
! Indawo (km &lt;sup&gt;2&lt;/sup&gt; )
!Inani labantu
! Ilimi elikhulunywa khulu
|-
| Ekangala
| [http://census.adrianfrith.com/place/81201 81201]
| 5.61
| 1,509
| IsiZulu
|-
| KwaMhlanga Part 1
| [http://census.adrianfrith.com/place/81202 81202]
| 254.72
| 71,756
| [[Isindebele|IsiNdebele seSewula]]
|-
| KwaMhlanga Part 1
| [http://census.adrianfrith.com/place/81215 81215]
| 5.91
| 6,085
| IsiNdebele seSewula
|-
| [[Mabusa National Park|I-Mabusa National Park]]
| [http://census.adrianfrith.com/place/81203 81203]
| 100.64
| 99
| IsiSuthu
|-
| [[Mkobola]]
| [http://census.adrianfrith.com/place/81204 81204]
| 320.15
| 107,560
| IsiNdebele seSewula
|-
| [[Moutse 3]]
| [http://census.adrianfrith.com/place/81205 81205]
| 1.68
| 1,788
| IsiSotho seTlhagwini
|-
| [[Sokhulumi]]
| [http://census.adrianfrith.com/place/81206 81206]
| 0.33
| 610
| IsiNdebele seSewula
|-
| [[Thokoza, Mpumalanga|Thokoza]]
| [http://census.adrianfrith.com/place/81208 81208]
| 2.27
| 4,459
| IsiNdebele seSewula
|-
| [[Tweefontein North|I-Tweefontein North]]
| [http://census.adrianfrith.com/place/81210 81210]
| 12.07
| 30000
| IsiNdebele seSewula
|-
| [[Tweefontein South|I-Tweefontein South]]
| [http://census.adrianfrith.com/place/81211 81211]
| 13.91
| 24,407
| IsiNdebele seSewula
|-
| [[Tweefontein]]
| [http://census.adrianfrith.com/place/81209 81209]
| 23.26
| 45
| IsiSotho seTlhagwini
|-
| [[Vezubuhle]]
| [http://census.adrianfrith.com/place/81212 81212]
| 5.26
| 10,399
| IsiNdebele seSewula
|-
| Vlakfontein
| [http://census.adrianfrith.com/place/81213 81213]
| 0.76
| 548
| IsiNdebele seSewula
|-
| Wolvenkop
| [http://census.adrianfrith.com/place/81214 81214]
| 1.34
| 2,161
| IsiNdebele seSewula
|-
|Iindawo eziseleleko
| [http://census.adrianfrith.com/place/81207 81207]
| 1,761.83
| 6,704
|isiNdebele seSewula
|}</text>
      <sha1>g8jqssjcwh8t35f5pztic33js5we5ff</sha1>
    </revision>
  </page>
  <page>
    <title>Ingwenyama uMayitjha II</title>
    <ns>0</ns>
    <id>776</id>
    <revision>
      <id>5237</id>
      <timestamp>2025-08-26T23:12:45Z</timestamp>
      <contributor>
        <username>Mojonom</username>
        <id>593</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1278181374|Mayitjha II]]&quot;</comment>
      <origin>5237</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2856" sha1="1b5a24dlxdgah2i83mh5lmqoeut0qx1" xml:space="preserve">
'''Ingwenyama uMayitjha II''' (2 June 1947 – 30 June 2005), owabelethwa angu '''Nyumbabo Cornelius Mahlangu''', khabe ayingwenyama yesitjhaba [[AmaNdebele|samaNdebele wakwaNdzundza]] e [[Isifunda seMpumalanga|-Mpumalanga, eSewula Afrika]]. Wathoma ukubusa ngemva kukayise, Ingwenyama uMabusabesala II. Wathoma ukubusa ngosukela ngomnyaka ka1992 bekwaba kulapha ilanga licima khona ngo-2005.

Ngesikhathi sebandlululo, isitjhaba samaNdebele khabe sibuswa ngaphasi kombuso ozijameleko wa[[KwaNdebele]]. Ngaso lesi sikhathi, iNgwenyama u-Mayitjha wasebenza eenkhundleni ezinengi ekhabhinethini yabaphathi bombuso waKwaNdebele,

== Ipilo yakhe asesemutjha nemisebenzi ==
Ingwenyama yabelethwa mhlazana amalanga ama-2 ku Mgwengweni ngomnyaka ka 1947  ibelethelwa eNdaweni yase Mthambothini. uYise khabe kuyiNgwenyama uMabhoko II (uMabusabesala David Mahlangu) obekabelethwa ngu Mayitjha I. Baziinzukulwana zeNgwenyama   UMusi kaMhlanga kaMafana. 



Ngesikhathi asesemutjha, iNgwenyama uMayitjha II wakhombisa ikareko elikhulu kwezamabhizinisi wokwakha kunye nokulima. Ngomnyaka ka 1960, wangenelela zepolotiki khudlwana lapha aba lilunga le Ndzundza Tribal Authority, eyathonywa ngebanga lomthetho we [[:en:Bantu_Authorities_Act,_1951|Bantu Authorities Act]] ekhabe ukhona ngesikhathi sebandlululo.


Ngesikhathi sokuphila kwakhe, uMayitjha waragela phambili namabhizinisi wokwakha nokulima, begodu wathoma umsebenzi wezepolotiki ngo-1969 njengelunga le-Ndzundza Tribal Authority, eyasungulwa ngokuya komThetho weBantu Authorities wesikhathi sebandlululo ukubusa abantu beNdebele beSewula yesifunda. Ngomnyaka ka 1979, Ingwenyama yaba nguNqgongqotjhe wezeFundo kusukela ngomnyaka ka 1984. Kusukela ngo 1984, waba ngu Ngqongqotjhe wezePilo. Kanti ke, kusukela ngomnyaka ka 1990 kufikela ngomnyaka ka 1992, Ingwenyama yaba ngu Ngqongqotjhe wezeMisebenzi yoMphakathi

== Ukubusa kwakhe: 1992–2005 ==
Ngomnyaka ka 1992, ngemva kokuhlongakala kukayise, wabekwa njengeNgwenyama yesitjhaba samaNdebele wakwa Nzunza. Kanti, ke, ngesikhathi sokuhlongakala kwakhe ngomnyaka ka 2005, i Nhlapo Commission on Traditional Leadership Disputes and Claims beyiphakathi nephenyo layo. Begodu INgwenyama uMayitjha bekasakhulumisana neNgwenyama uMakhosoke II wesitjhaba samaNdebele wakwaManala mayelana nokuhlanganisa isitjhaba samaNdebele bonyana sibe ngaphasi kobukhosi bunye. Ilanga lacima nhlazana amalanga ama-20 kuMgwengweni 

2005.

== IPilo yeNgwenyama ==
Ngomnyaka ka 1975, Ingwenyama yatjhada nekosazana uSiphila Dlamini ophuma esitjhabeni samaSwati, obeka ngumma wokuthoma. Kusukela lapho, wathatha uLena Masilela njengomfazi wesibili. Umfazi wesithathu khabe kungu Nomsa Sanny-Flora Mtshweni. Kanti ke, wesine kungu Gabisile Elizabeth Mabona. Wesihlanu khabe kungu Nomsa Daphane Mdaka. Abantwana bakhe boke pheze balinganiselwa ematjhumini amabili sele baphelele.</text>
      <sha1>1b5a24dlxdgah2i83mh5lmqoeut0qx1</sha1>
    </revision>
  </page>
  <page>
    <title>I-Botshabelo, eMpumalanga</title>
    <ns>0</ns>
    <id>777</id>
    <revision>
      <id>5238</id>
      <timestamp>2025-08-28T16:22:00Z</timestamp>
      <contributor>
        <username>Mojonom</username>
        <id>593</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1294468980|Botshabelo, Mpumalanga]]&quot;</comment>
      <origin>5238</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3559" sha1="qpq6jjf44gn3is6uq4dre1vw6uylwpp" xml:space="preserve"> {{Reflist}}

'''I-Botshabelo''' (&quot;indawo yokuphephela&quot; ngelimi le -Northern Sotho ) kuyindawe eseduze nedorobha le[[E-Middelburg, e-Mpumalanga|-Middelburg]], esifundeni [[Isifunda seMpumalanga|se-Mpumalanga]], e[[Isewula Afrika|Sewula Afrika]]. Indawo ye, yathoma njengesitetjhi samamitjhinari, ekusitetjhi esasungulwa ngu -Alexander Merensky ophuma ehlanganweni ye Berlin Missionary Society (BMS) ngenyanga kaMhlolanja emnyakeni we-1865. Indawo le ngesikhathi leso khabe ingaphasi komkhawulo we-Transvaal Republic (ZAR) . Ngemva komnyaka munye sekle kusungulwe isitetjhi lesi, inani labantu esitetjhini lakhula khulu, pheze lalifika enanini elima -420 yabantu. Ngomnyaka we 1873, omunye wamamitjhinari we BMS,  ekungu Johannes Winter, wahlanganyelana no Merensky, kodwana ngemva kwesikhathi, naye watjhinga e Thaba Mosego bonyana ayozitlamela sakhe isitetjhi, ekusitetjhi esadlala indima ekulu ekuthomeni isondo le Lutheran Bapedi Church ngomnyaka we1889. Lapha ke, besele bahlukene nehlangano ye BMS.   

Esikhathini sanje, i-Botshabelo ingenye yama myuziyamu (museum) ekhombisa izakhiwo ezinemigwalo yesitjhaba sam[[amaNdebele]]. Indawo le ivezwe njengendawo enomlando omuhle tle begodu nenabisa ivakatjhobukelo lesifunda seMpumalanga. Yize kunjalo, kunamatshwayo amanengi akhombisa ukungatjhejisiswa kwendawo le, njengombanyana izakhiwo ezinengi kunye nemigwalo yazo ikhombisa ukungakatjhejwa, eminye imakhiwo seyize iphenduke amarubhi. Unobangela omkhulu ngalokhu ziinkinga eziphathelene nokutlhayela kweensiza zokubulunga indawo le, kunye nemibono ehlukileko ephathelene nokuthi ngubani ekufanele aphathe indawo le.  

== Iincwadi ezimayelana ne-Botshabelo Mission Station ==


Indawo ye Botshabelo ifunyaneka emitlolweni eminengi efana nama Journal, ama Article, kunye namaphephandaba.  Imitlolo le, iveze indawo le yeBotshabelo njengendawo eqakathekileko kwamambala. Hlangana neminye yemitlolo ekhona, elandelako ngeminye yemitlolo enamakhasi akhuluma ngendawo le. 

* Delius, P. 1983. ''The land belongs to us: the Pedi polity, the Boers and the British in the nineteenth century Transvaal.'' Ravan Press: Johannesburg.
* Rikotso, G, J. 2003. ''Rev. A. Merensky and the Bapedi people of Sekhukhune.'' University of Pretoria: Magister Atrium (Theology)
* Delius, P. &amp; Ruther, K. 2013. The King, the missionary and the missionary’s daughter. ''Journal of Southern African Studies.'' Vol. 39 (3) pp. 597 – 614.
* Malunga, F. 2003. Sekhukhune II and the Pedi Operations and the Anglo – Boer War, 1899 – 1902. ''Scientia Militaria.'' 31 (1). Pp. 19 – 36.
* Pakendorf, G. 1997. “''For there is no power but of God:” The Berlin Mission and the challenges of Colonial South Africa''. Missionalia. (Available online: &lt;nowiki&gt;https://www.oocities.org/missionalia/germiss1.htm&lt;/nowiki&gt;)
* Pakendorf, G. 2011. A Brief History of the Berlin Mission Society in South Africa. ''History Compass'' Vol 9 (2). Pp.106–118,
* Poewe, K.  &amp; v.d. Heyden, U. 1999. The Berlin Mission Society and its Theology:
* The Bapedi Mission Church and the Independent Bapedi Lutheran Church. ''South African Historical Journal.'' 40 (May 1999). Pp. 21 – 50
* Ruther, K. 2012. Through the eyes of missionaries and their archives they created. The interwoven histories of power and authority in the 19&lt;sup&gt;th&lt;/sup&gt; century Transvaal. ''Journal of Southern African Studies.'' Vol. 38 (2). Pp. 369 – 384.
* van der Heyden, U. 1996. The archives and library of the Berlin Missionary Society. ''History in Africa.'' Vol 23. Pp. 411 – 427

*

== Imithombo yelwazi ==</text>
      <sha1>qpq6jjf44gn3is6uq4dre1vw6uylwpp</sha1>
    </revision>
    <revision>
      <id>5239</id>
      <parentid>5238</parentid>
      <timestamp>2025-08-28T16:24:26Z</timestamp>
      <contributor>
        <username>Mojonom</username>
        <id>593</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1294468980|Botshabelo, Mpumalanga]]&quot;</comment>
      <origin>5239</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3561" sha1="7e44kgmlxvo9mw7l6rphnsg8d3oswgf" xml:space="preserve"> {{Reflist}}

'''I-Botshabelo''' (Ibizo leli kulibizo lesiSotho elithi :'isibalekelo') kuyindawo eseduze nedorobha le[[E-Middelburg, e-Mpumalanga|-Middelburg]], esifundeni [[Isifunda seMpumalanga|se-Mpumalanga]], e[[Isewula Afrika|Sewula Afrika]]. Indawo ye, yathoma njengesitetjhi samamitjhinari, ekusitetjhi esasungulwa ngu -Alexander Merensky ophuma ehlanganweni ye Berlin Missionary Society (BMS) ngenyanga kaMhlolanja emnyakeni we-1865. Indawo le ngesikhathi leso khabe ingaphasi komkhawulo we-Transvaal Republic (ZAR) . Ngemva komnyaka munye sekle kusungulwe isitetjhi lesi, inani labantu esitetjhini lakhula khulu, pheze lalifika enanini elima -420 yabantu. Ngomnyaka we 1873, omunye wamamitjhinari we BMS,  ekungu Johannes Winter, wahlanganyelana no Merensky, kodwana ngemva kwesikhathi, naye watjhinga e Thaba Mosego bonyana ayozitlamela sakhe isitetjhi, ekusitetjhi esadlala indima ekulu ekuthomeni isondo le Lutheran Bapedi Church ngomnyaka we1889. Lapha ke, besele bahlukene nehlangano ye BMS.   

Esikhathini sanje, i-Botshabelo ingenye yama myuziyamu (museum) ekhombisa izakhiwo ezinemigwalo yesitjhaba sam[[amaNdebele]]. Indawo le ivezwe njengendawo enomlando omuhle tle begodu nenabisa ivakatjhobukelo lesifunda seMpumalanga. Yize kunjalo, kunamatshwayo amanengi akhombisa ukungatjhejisiswa kwendawo le, njengombanyana izakhiwo ezinengi kunye nemigwalo yazo ikhombisa ukungakatjhejwa, eminye imakhiwo seyize iphenduke amarubhi. Unobangela omkhulu ngalokhu ziinkinga eziphathelene nokutlhayela kweensiza zokubulunga indawo le, kunye nemibono ehlukileko ephathelene nokuthi ngubani ekufanele aphathe indawo le.  

== Iincwadi ezimayelana ne-Botshabelo Mission Station ==


Indawo ye Botshabelo ifunyaneka emitlolweni eminengi efana nama Journal, ama Article, kunye namaphephandaba.  Imitlolo le, iveze indawo le yeBotshabelo njengendawo eqakathekileko kwamambala. Hlangana neminye yemitlolo ekhona, elandelako ngeminye yemitlolo enamakhasi akhuluma ngendawo le. 

* Delius, P. 1983. ''The land belongs to us: the Pedi polity, the Boers and the British in the nineteenth century Transvaal.'' Ravan Press: Johannesburg.
* Rikotso, G, J. 2003. ''Rev. A. Merensky and the Bapedi people of Sekhukhune.'' University of Pretoria: Magister Atrium (Theology)
* Delius, P. &amp; Ruther, K. 2013. The King, the missionary and the missionary’s daughter. ''Journal of Southern African Studies.'' Vol. 39 (3) pp. 597 – 614.
* Malunga, F. 2003. Sekhukhune II and the Pedi Operations and the Anglo – Boer War, 1899 – 1902. ''Scientia Militaria.'' 31 (1). Pp. 19 – 36.
* Pakendorf, G. 1997. “''For there is no power but of God:” The Berlin Mission and the challenges of Colonial South Africa''. Missionalia. (Available online: &lt;nowiki&gt;https://www.oocities.org/missionalia/germiss1.htm&lt;/nowiki&gt;)
* Pakendorf, G. 2011. A Brief History of the Berlin Mission Society in South Africa. ''History Compass'' Vol 9 (2). Pp.106–118,
* Poewe, K.  &amp; v.d. Heyden, U. 1999. The Berlin Mission Society and its Theology:
* The Bapedi Mission Church and the Independent Bapedi Lutheran Church. ''South African Historical Journal.'' 40 (May 1999). Pp. 21 – 50
* Ruther, K. 2012. Through the eyes of missionaries and their archives they created. The interwoven histories of power and authority in the 19&lt;sup&gt;th&lt;/sup&gt; century Transvaal. ''Journal of Southern African Studies.'' Vol. 38 (2). Pp. 369 – 384.
* van der Heyden, U. 1996. The archives and library of the Berlin Missionary Society. ''History in Africa.'' Vol 23. Pp. 411 – 427

*

== Imithombo yelwazi ==</text>
      <sha1>7e44kgmlxvo9mw7l6rphnsg8d3oswgf</sha1>
    </revision>
  </page>
  <page>
    <title>UMkabayi KaJama</title>
    <ns>0</ns>
    <id>778</id>
    <revision>
      <id>5242</id>
      <timestamp>2025-08-30T23:58:50Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>New article</comment>
      <origin>5242</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4717" sha1="0lpq1ogjofj3s983610rmeson876mo3" xml:space="preserve">'''UMkabayi kaJama''' bekangomunye wabantu besifazana abadlala indima ekulu ebukhosini bakwaZulu. Wabelethwa ngo-1750 wahlongakala ngo-1843. Uyise nguJama kaNdaba, ungudadwabo omdala wekosi uSenzangakhona, begodu bekaliwele nodadwabo uMamma. Bekaziwa njengomfazi webukhosini okghona ukuzijamela. Amagadango awathathako ngesikhathi asaphila bekatjengisa ukukhalipha engqondweni, nokuthanda isitjhaba sekhabo, kangangobana kwafuze athathe iinqunto ezibudisi ukuvikela isitjhaba sakwaZulu.&lt;ref name=&quot;:0&quot;&gt;ULwazi (2025) ''Princess Mkabayi Kajama, an Early Zulu Feminist.'' Retrieved from: https://www.ulwaziprogramme.org/princess-mkabayi-kajama-an-early-zulu-feminist/ Retrieved on 31/08/2025.&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;Maxwel Z Shamase (2014) The royal women of the Zulu monarchy–through the keyhole of oral history: Princess Mkabayi Kajama (c. 1750–c. 1843). Inkanyiso: Journal of Humanities and Social Sciences, 6(1), pp.15-22. Retrived from: https://uzspace.unizulu.ac.za/server/api/core/bitstreams/a6886ed0-073d-4216-9fd6-63b9b1c17076/content Retrieved on 31/08/2025.&lt;/ref&gt;

== Umlando Webuncanini Bakhe ==
UMkabayi wabelethelwa esitjhabeni sakwaZulu nodadwabo uMamma ngo-1750. Emihleni leyo bekukholelwa bona ukubelethwa kwamaphahla kuletha itjhudu elimbi esitjhabeni, mhlamunye bekufe nababelethi babo. Yeke bekuthi qobe nakubelethwa amaphahla elinye libulawe. Kodwana kosi uJama kaNdaba walikhomba libaba wathi nakubantwana bakhe bazokuphila bobabili. Yeke uMkabayi noMamma baphila bobabili. Kodwana lokho khenge kusiphathe kuhle isitjhaba, yeke uMkabayi wakhula ahloyiwe njalo. Kwathi nakaneminyaka emihlanu unina kaMkabayi wahlongakala. Abantu basola yena ngokuhlongakala kukanina. Unina ufa nje angakabeletheli uJama indlalifa yobukhosi.&lt;ref&gt;Manyathi PPP (1997). ''Ucwaningo Ngeqhaza labesifazane esizweni samaZulu, Kubhekiswe kakhulukazi kuMkabayi kaJama''. pp. 86–103.&lt;/ref&gt;

== Umlando Ekukhuleni Kwakhe ==
Wakhula njalo uMkabayi uyise anganayo indlalifa. Lokho kwenza bona ngo-1777 uMkabayi ayokufunela uyise umfazi ozomzalela indlalifa, nakuya azamtholela uMthaniya wesitjhaba sakwaSibiya. UMthaniya wambelethela indodana wayithiya ibizo bona nguSenzangakhona, ngombana ikosi ikghonile ukwenza ngakhona ngebanga lendodakazakhe uMkabayi. Lokho kwenza isitjhaba samthanda uMkabayi ngombana ikosi uJama kaNdaba besele athole umfazi wamaThonga ngokungasi seMthethweni, umfazi loyo waba sidisi wabeletha indodana kwathiwa nguSojiyisa. Kusukela ngalesosikhathi uMkabayi wathathwa njengomfazi othatha iinqunto ezihlakaniphileko bona avikele isitjhaba, ngombana ubukhosi bebuzokuwela ezandleni zevezandlebe. UMkabayi kaJama khenge enda, begodu wahlongakala angakendi.&lt;ref name=&quot;:1&quot; /&gt; Ngikho abizwa ngokobana nguMkabani kaJama (ekadeni abantu bebathefula nabakhulumako, yeke esikhundleni sokuthi bambize ngoMkabani, bathi nguMkabayi.)

=== UMkabayi Ngesikhathi Sokubusa KukaSenzangakhona ===
Ngokukhamba kwesikhathi uyise uJama wahlongakala. UMkabayi wazibeka esihlalweni sobukhosi wabambela uSenzangakhona ngombana bekasesemncani bona angabusa. Emihleni leyo isitjhaba besiphathwa madoda, ngikho nje bekunabantu emkhandlwini ebebangamthandisisi kuhle. Kodwana kwafuze bakubekezelele ukuphathwa mfazi. Lokho kwamenza waba nesithunzi namandla. Kwakuneenkhathi lapha bekufuze avikele khona isitjhaba ngokuthumela amabutho bona ayokulwa noSojiyisa ebekucatjangwa bona angaba yingozi ebukhosini bukaSenzangakhona. Yeke abantu bebamthatha njengomuntu onenturhu.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;

Wakhula uSenzangakhona, uMkabayi kwafuze ehle esihlalweni ngomnyaka ka-1781. Njengombana uSenzangakhona besele ayikosi nje uMkabayi waba ngumeluleki wakhe. Iindaba ezinengi zobukhosi uSenzangakhona bekazicoca naye uMkabayi. Nakuya uSenzangakhona azokukhulelisa uNandi kaBhebhe bangakatjhadi, bathola indodana bayithiya ngoSigidi. Ngemva kwalokho uNandi nendodanakhe baqothwa esitjhabeni. Kwathi bona uSigidi akhule ayokuhlala esitjhabeni sakwaMthethwa uMkabayi bekasolo amthanda.&lt;ref name=&quot;:1&quot; /&gt;

=== UMkabayi Ngesikhathi Sokubusa KukaShaka ===
UShaka wagcina abuthethe ubukhosi, wabulala umfowabo uSigujana. UMkabayi wamamukela uShaka njengekosi yesitjhaba sakwaZulu, waraga nokubusa. Kwathi ngokukhamba  kwesikhathi uShaka wathoma ukuba yingozi esitjhabeni. Abantu abanengi bafa babulawa yikosi uShaka. UMkabayi kwaba nguye oza neqhinga lokuthi uShaka kufuze abulawe bona kuphephiswe isitjhaba. Iqhingelo walibopha noDingane, uMhlangana noMbopha kaSithayi. Ekugcineni kwathi ngo-1828 bambulala uShaka. Kwathi bona uDingane athathe isihlalo wadingisa uMkabayi kaJama esitjhabeni esibizwa ngokuthi kusebaQulusini. UMkabayi wafela lapho, asilukazi, kunganamuntu omtjhejako.&lt;ref name=&quot;:1&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>0lpq1ogjofj3s983610rmeson876mo3</sha1>
    </revision>
    <revision>
      <id>6101</id>
      <parentid>5242</parentid>
      <timestamp>2025-12-22T06:59:03Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <minor />
      <comment>/* Umlando Webuncanini Bakhe */ spelling fix</comment>
      <origin>6101</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4717" sha1="dt4tfqg2z63sqgw36bhebwdf6nfkk0a" xml:space="preserve">'''UMkabayi kaJama''' bekangomunye wabantu besifazana abadlala indima ekulu ebukhosini bakwaZulu. Wabelethwa ngo-1750 wahlongakala ngo-1843. Uyise nguJama kaNdaba, ungudadwabo omdala wekosi uSenzangakhona, begodu bekaliwele nodadwabo uMamma. Bekaziwa njengomfazi webukhosini okghona ukuzijamela. Amagadango awathathako ngesikhathi asaphila bekatjengisa ukukhalipha engqondweni, nokuthanda isitjhaba sekhabo, kangangobana kwafuze athathe iinqunto ezibudisi ukuvikela isitjhaba sakwaZulu.&lt;ref name=&quot;:0&quot;&gt;ULwazi (2025) ''Princess Mkabayi Kajama, an Early Zulu Feminist.'' Retrieved from: https://www.ulwaziprogramme.org/princess-mkabayi-kajama-an-early-zulu-feminist/ Retrieved on 31/08/2025.&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;Maxwel Z Shamase (2014) The royal women of the Zulu monarchy–through the keyhole of oral history: Princess Mkabayi Kajama (c. 1750–c. 1843). Inkanyiso: Journal of Humanities and Social Sciences, 6(1), pp.15-22. Retrived from: https://uzspace.unizulu.ac.za/server/api/core/bitstreams/a6886ed0-073d-4216-9fd6-63b9b1c17076/content Retrieved on 31/08/2025.&lt;/ref&gt;

== Umlando Webuncanini Bakhe ==
UMkabayi wabelethelwa esitjhabeni sakwaZulu nodadwabo uMamma ngo-1750. Emihleni leyo bekukholelwa bona ukubelethwa kwamaphahla kuletha itjhudu elimbi esitjhabeni, mhlamunye bekufe nababelethi bawo. Yeke bekuthi qobe nakubelethwa amaphahla elinye libulawe. Kodwana kosi uJama kaNdaba walikhomba libaba wathi nakubantwana bakhe bazokuphila bobabili. Yeke uMkabayi noMamma baphila bobabili. Kodwana lokho khenge kusiphathe kuhle isitjhaba, yeke uMkabayi wakhula ahloyiwe njalo. Kwathi nakaneminyaka emihlanu unina kaMkabayi wahlongakala. Abantu basola yena ngokuhlongakala kukanina. Unina ufa nje angakabeletheli uJama indlalifa yobukhosi.&lt;ref&gt;Manyathi PPP (1997). ''Ucwaningo Ngeqhaza labesifazane esizweni samaZulu, Kubhekiswe kakhulukazi kuMkabayi kaJama''. pp. 86–103.&lt;/ref&gt;

== Umlando Ekukhuleni Kwakhe ==
Wakhula njalo uMkabayi uyise anganayo indlalifa. Lokho kwenza bona ngo-1777 uMkabayi ayokufunela uyise umfazi ozomzalela indlalifa, nakuya azamtholela uMthaniya wesitjhaba sakwaSibiya. UMthaniya wambelethela indodana wayithiya ibizo bona nguSenzangakhona, ngombana ikosi ikghonile ukwenza ngakhona ngebanga lendodakazakhe uMkabayi. Lokho kwenza isitjhaba samthanda uMkabayi ngombana ikosi uJama kaNdaba besele athole umfazi wamaThonga ngokungasi seMthethweni, umfazi loyo waba sidisi wabeletha indodana kwathiwa nguSojiyisa. Kusukela ngalesosikhathi uMkabayi wathathwa njengomfazi othatha iinqunto ezihlakaniphileko bona avikele isitjhaba, ngombana ubukhosi bebuzokuwela ezandleni zevezandlebe. UMkabayi kaJama khenge enda, begodu wahlongakala angakendi.&lt;ref name=&quot;:1&quot; /&gt; Ngikho abizwa ngokobana nguMkabani kaJama (ekadeni abantu bebathefula nabakhulumako, yeke esikhundleni sokuthi bambize ngoMkabani, bathi nguMkabayi.)

=== UMkabayi Ngesikhathi Sokubusa KukaSenzangakhona ===
Ngokukhamba kwesikhathi uyise uJama wahlongakala. UMkabayi wazibeka esihlalweni sobukhosi wabambela uSenzangakhona ngombana bekasesemncani bona angabusa. Emihleni leyo isitjhaba besiphathwa madoda, ngikho nje bekunabantu emkhandlwini ebebangamthandisisi kuhle. Kodwana kwafuze bakubekezelele ukuphathwa mfazi. Lokho kwamenza waba nesithunzi namandla. Kwakuneenkhathi lapha bekufuze avikele khona isitjhaba ngokuthumela amabutho bona ayokulwa noSojiyisa ebekucatjangwa bona angaba yingozi ebukhosini bukaSenzangakhona. Yeke abantu bebamthatha njengomuntu onenturhu.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;

Wakhula uSenzangakhona, uMkabayi kwafuze ehle esihlalweni ngomnyaka ka-1781. Njengombana uSenzangakhona besele ayikosi nje uMkabayi waba ngumeluleki wakhe. Iindaba ezinengi zobukhosi uSenzangakhona bekazicoca naye uMkabayi. Nakuya uSenzangakhona azokukhulelisa uNandi kaBhebhe bangakatjhadi, bathola indodana bayithiya ngoSigidi. Ngemva kwalokho uNandi nendodanakhe baqothwa esitjhabeni. Kwathi bona uSigidi akhule ayokuhlala esitjhabeni sakwaMthethwa uMkabayi bekasolo amthanda.&lt;ref name=&quot;:1&quot; /&gt;

=== UMkabayi Ngesikhathi Sokubusa KukaShaka ===
UShaka wagcina abuthethe ubukhosi, wabulala umfowabo uSigujana. UMkabayi wamamukela uShaka njengekosi yesitjhaba sakwaZulu, waraga nokubusa. Kwathi ngokukhamba  kwesikhathi uShaka wathoma ukuba yingozi esitjhabeni. Abantu abanengi bafa babulawa yikosi uShaka. UMkabayi kwaba nguye oza neqhinga lokuthi uShaka kufuze abulawe bona kuphephiswe isitjhaba. Iqhingelo walibopha noDingane, uMhlangana noMbopha kaSithayi. Ekugcineni kwathi ngo-1828 bambulala uShaka. Kwathi bona uDingane athathe isihlalo wadingisa uMkabayi kaJama esitjhabeni esibizwa ngokuthi kusebaQulusini. UMkabayi wafela lapho, asilukazi, kunganamuntu omtjhejako.&lt;ref name=&quot;:1&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>dt4tfqg2z63sqgw36bhebwdf6nfkk0a</sha1>
    </revision>
    <revision>
      <id>6102</id>
      <parentid>6101</parentid>
      <timestamp>2025-12-22T07:02:03Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <minor />
      <comment>/* Umlando Webuncanini Bakhe */ spelling fix</comment>
      <origin>6102</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4718" sha1="nkde5qc0s2yzpt4plydwczp8jtsjdbp" xml:space="preserve">'''UMkabayi kaJama''' bekangomunye wabantu besifazana abadlala indima ekulu ebukhosini bakwaZulu. Wabelethwa ngo-1750 wahlongakala ngo-1843. Uyise nguJama kaNdaba, ungudadwabo omdala wekosi uSenzangakhona, begodu bekaliwele nodadwabo uMamma. Bekaziwa njengomfazi webukhosini okghona ukuzijamela. Amagadango awathathako ngesikhathi asaphila bekatjengisa ukukhalipha engqondweni, nokuthanda isitjhaba sekhabo, kangangobana kwafuze athathe iinqunto ezibudisi ukuvikela isitjhaba sakwaZulu.&lt;ref name=&quot;:0&quot;&gt;ULwazi (2025) ''Princess Mkabayi Kajama, an Early Zulu Feminist.'' Retrieved from: https://www.ulwaziprogramme.org/princess-mkabayi-kajama-an-early-zulu-feminist/ Retrieved on 31/08/2025.&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;Maxwel Z Shamase (2014) The royal women of the Zulu monarchy–through the keyhole of oral history: Princess Mkabayi Kajama (c. 1750–c. 1843). Inkanyiso: Journal of Humanities and Social Sciences, 6(1), pp.15-22. Retrived from: https://uzspace.unizulu.ac.za/server/api/core/bitstreams/a6886ed0-073d-4216-9fd6-63b9b1c17076/content Retrieved on 31/08/2025.&lt;/ref&gt;

== Umlando Webuncanini Bakhe ==
UMkabayi wabelethelwa esitjhabeni sakwaZulu nodadwabo uMamma ngo-1750. Emihleni leyo bekukholelwa bona ukubelethwa kwamaphahla kuletha itjhudu elimbi esitjhabeni, mhlamunye bekufe nababelethi bawo. Yeke bekuthi qobe nakubelethwa amaphahla elinye libulawe. Kodwana ikosi uJama kaNdaba walikhomba libaba wathi nakubantwana bakhe bazokuphila bobabili. Yeke uMkabayi noMamma baphila bobabili. Kodwana lokho khenge kusiphathe kuhle isitjhaba, yeke uMkabayi wakhula ahloyiwe njalo. Kwathi nakaneminyaka emihlanu unina kaMkabayi wahlongakala. Abantu basola yena ngokuhlongakala kukanina. Unina ufa nje angakabeletheli uJama indlalifa yobukhosi.&lt;ref&gt;Manyathi PPP (1997). ''Ucwaningo Ngeqhaza labesifazane esizweni samaZulu, Kubhekiswe kakhulukazi kuMkabayi kaJama''. pp. 86–103.&lt;/ref&gt;

== Umlando Ekukhuleni Kwakhe ==
Wakhula njalo uMkabayi uyise anganayo indlalifa. Lokho kwenza bona ngo-1777 uMkabayi ayokufunela uyise umfazi ozomzalela indlalifa, nakuya azamtholela uMthaniya wesitjhaba sakwaSibiya. UMthaniya wambelethela indodana wayithiya ibizo bona nguSenzangakhona, ngombana ikosi ikghonile ukwenza ngakhona ngebanga lendodakazakhe uMkabayi. Lokho kwenza isitjhaba samthanda uMkabayi ngombana ikosi uJama kaNdaba besele athole umfazi wamaThonga ngokungasi seMthethweni, umfazi loyo waba sidisi wabeletha indodana kwathiwa nguSojiyisa. Kusukela ngalesosikhathi uMkabayi wathathwa njengomfazi othatha iinqunto ezihlakaniphileko bona avikele isitjhaba, ngombana ubukhosi bebuzokuwela ezandleni zevezandlebe. UMkabayi kaJama khenge enda, begodu wahlongakala angakendi.&lt;ref name=&quot;:1&quot; /&gt; Ngikho abizwa ngokobana nguMkabani kaJama (ekadeni abantu bebathefula nabakhulumako, yeke esikhundleni sokuthi bambize ngoMkabani, bathi nguMkabayi.)

=== UMkabayi Ngesikhathi Sokubusa KukaSenzangakhona ===
Ngokukhamba kwesikhathi uyise uJama wahlongakala. UMkabayi wazibeka esihlalweni sobukhosi wabambela uSenzangakhona ngombana bekasesemncani bona angabusa. Emihleni leyo isitjhaba besiphathwa madoda, ngikho nje bekunabantu emkhandlwini ebebangamthandisisi kuhle. Kodwana kwafuze bakubekezelele ukuphathwa mfazi. Lokho kwamenza waba nesithunzi namandla. Kwakuneenkhathi lapha bekufuze avikele khona isitjhaba ngokuthumela amabutho bona ayokulwa noSojiyisa ebekucatjangwa bona angaba yingozi ebukhosini bukaSenzangakhona. Yeke abantu bebamthatha njengomuntu onenturhu.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;

Wakhula uSenzangakhona, uMkabayi kwafuze ehle esihlalweni ngomnyaka ka-1781. Njengombana uSenzangakhona besele ayikosi nje uMkabayi waba ngumeluleki wakhe. Iindaba ezinengi zobukhosi uSenzangakhona bekazicoca naye uMkabayi. Nakuya uSenzangakhona azokukhulelisa uNandi kaBhebhe bangakatjhadi, bathola indodana bayithiya ngoSigidi. Ngemva kwalokho uNandi nendodanakhe baqothwa esitjhabeni. Kwathi bona uSigidi akhule ayokuhlala esitjhabeni sakwaMthethwa uMkabayi bekasolo amthanda.&lt;ref name=&quot;:1&quot; /&gt;

=== UMkabayi Ngesikhathi Sokubusa KukaShaka ===
UShaka wagcina abuthethe ubukhosi, wabulala umfowabo uSigujana. UMkabayi wamamukela uShaka njengekosi yesitjhaba sakwaZulu, waraga nokubusa. Kwathi ngokukhamba  kwesikhathi uShaka wathoma ukuba yingozi esitjhabeni. Abantu abanengi bafa babulawa yikosi uShaka. UMkabayi kwaba nguye oza neqhinga lokuthi uShaka kufuze abulawe bona kuphephiswe isitjhaba. Iqhingelo walibopha noDingane, uMhlangana noMbopha kaSithayi. Ekugcineni kwathi ngo-1828 bambulala uShaka. Kwathi bona uDingane athathe isihlalo wadingisa uMkabayi kaJama esitjhabeni esibizwa ngokuthi kusebaQulusini. UMkabayi wafela lapho, asilukazi, kunganamuntu omtjhejako.&lt;ref name=&quot;:1&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>nkde5qc0s2yzpt4plydwczp8jtsjdbp</sha1>
    </revision>
  </page>
  <page>
    <title>ILanga LaboMma</title>
    <ns>0</ns>
    <id>779</id>
    <revision>
      <id>5243</id>
      <timestamp>2025-08-31T00:08:08Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>New article</comment>
      <origin>5243</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5156" sha1="m8ux7zs26vnc5ohyun23xye5ezn3c3o" xml:space="preserve">[[Isimumathi:Women of Ndebele village, Mpumalanga, South Africa (20489604056).jpg|thumb|380x380px|Abomma bamaNdebele]]
'''ILanga laboMma''' lilanga eligidingwa qobe mnyaka eSewula Afrika ngomhla ka-9 kuRhoboyi. Ilangeli likhumbula isenzakalo esenzekka ngomnyaka wango-1956 lokha abomma abanzima babamba umtjhagalo omayelana nokuphasiswa kwemiThetho yePasa ebafazini ngesikhathi somBuso weBandlululo. Umthetho lo wawutlanyelwe ukugandelela abomma bona bangakghoni ukuzenzela. Yeke abomma abangaba zii-20 000 bamatjha batjhinga e-''Union Building'' ePitori bona bafake isinghonghoyilo esiphikisana nomThetho i-''Population Registration Act'' bona nabazokukhamba eSewula Afrika kufuze bahlale baphethe ipasa.&lt;ref name=&quot;:0&quot;&gt;South African Government (9 August 2025) ''Women's Day 2025.'' Retrieved From: https://www.gov.za/WomensDay2025. Retrieved on 25/08/2025.&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;South African History (2 August 2012) ''South Africa celebrates the first National Women’s Day.'' Retrieved From: https://sahistory.org.za/dated-event/south-africa-celebrates-first-national-womens-day. Retrieved on 25/08/2025.&lt;/ref&gt; 

ILanga laboMma aligidingi isenzakalweso kwaphela, kodwana ligidinga nezinye izenzakalo lapho kunabomma ababa mavulandlela kilenarha yeSewula Afrika kusukela ngo-1913, lokha abomma abanjengo-Charlotte Maxeke basungula iLigi yaboMma (''Womens League'') ehlanganweni ye-ANC ekhuthaza abomma bona bazibandakanye ekulweleni itjhaphuluko. Amavulandlela la ahlanganisa nabo-Cissy, u-Jaynab no-Amina Gool, ebebaphakathi kwabadosiphambili be-''National Liberation League'' nebe-''Non-European United Front'' yangabo-1930. Ngikho nje inyanga kaRhoboyi yoke nje kuyinyanga ekhethelwe ukugidinga abomma boke beSewula Afrika nokugidinga labo abadlale indima ekulwelweni kwamalungelo wobuntu.&lt;ref name=&quot;:0&quot; /&gt;

== Ukusungulwa KweLanga LaboMma&lt;ref name=&quot;:1&quot; /&gt; ==
ILanga laboMma lagidingwa kokuthoma ngomhla ka-9 kuRhuboyi 1994 ngesikhathi iSewula Afrika iba yiriphabliki yedemokhrasi. Umhla ka-9 kaRhoboyi wamenyezelwa bona uzokuba yiholideyi lapha amaSewula Afrika azokuhlonipha khona abomma ababa nesibindi sokujamelana nemithetho ebandlulula ngokobulili ebeyikhandela ukutjhaphuluka nokulingana. Kusukela ngeLanga laboMma lokuthoma isikhundla sabomma emphakathini sithuthuke khulu. Ngokwesibonelo, ngo-1994, abomma bebakha isibalo esimaphesenthe amathathu epalamende yeSewula Afrika, kodwana namhlanjesi sele bamaphesente ama-40.&lt;ref&gt;Bankmed (2025) ''Women's Month - you strike a woman you strike a rock.'' Retrieved From: https://www.bankmed.co.za/portal/individual/bankmed-article-womens-day. Retrieved on 25/08/2025.&lt;/ref&gt;

== Umtjhagalo Wabomma Wango-1956 ==
[[Isimumathi:Mandela burn pass 1960.jpg|thumb|311x311px|UNelson Mandela atjhisa ipasakhe ]]
Umnqopho omkhulu womBuso weBandlululo bekukuhlukanisa abantu ngokobutjhaba khona uzokukghona ukubalawula kuhle. Lokho bekwenzelwe bona abantu abanzima basebenze emakhuweni wendaweni yemakhabo. Kodwana amadlelo alihlaza besele atholakala ngaphandle kwendawo ababelwe kiyo, yeke abantu abanzima besele batholakala eendaweni ezingaphandle kwalezo abahlala kizo. Ngikho nje umBuso weBandlululo weza nehlelo lokuthi nangabe umuntu uzokuya namkha asebenze andaweni yangaphandle kweyekhabo kufuze uthole imvumo. Woke umuntu ofuna ukusuka lapha ahlala khona aye kenye indawo ngananyana ngiliphi ibanga bekufuze aphathe ipasa. Yeke imithetho le yathoma ngokusebenza khulukhulu emadodeni. UmBuso wabeka imithetho emayelana nalokho.&lt;ref name=&quot;:2&quot;&gt;Ntsoxeko Maluleke (6 March 2023) ''Discovery: the 'dompas' – A young person’s perspective,'' Nelson Mandela Foundation website''.'' Retrieved from: https://www.nelsonmandela.org/news/entry/discovery-the-dompas-a-young-persons-perspective. Retrieved on 25/08/2025.&lt;/ref&gt;&lt;ref name=&quot;:3&quot;&gt;O' Malley (2025) ''1923. Native Urban Areas Act No 21.'' Retrieved from: https://omalley.nelsonmandela.org/index.php/site/q/03lv01538/04lv01646/05lv01758.htm. Retrieved on 25/08/2025.&lt;/ref&gt;
UmThetho i-'''''Natives (Urban Areas) Act''''' wango-1923 bewuthi woke umuntu onzima oyindoda otholakala eendaweni zabamhlophe kufuze aphathe ipasa ngaso soke isikhathi. Nanyana ngubani ozokutholakala angakaphathi ipasa uzokubotjhwa athunyelwe ethrestini lekhabo.&lt;ref name=&quot;:3&quot; /&gt; Ngo-1955 urhulumende webandlululo waqunta bona amapasa bekungakafuzi aphathwe madoda kwaphela, kodwana nananyana ngimuphi umfazi ongaphezu kweminyaka eli-16 kufuze aphathe ipasa nakaya eendaweni ezihlala abamhlophe. Lokho kwabatshwenya khulu abafazi ngombana bebayibona indlela umthetho wepasa othinta ngayo amadoda abaphila nawo. Kwezinye iikhathi bekungibo abafazi abezako bazokukhupha amadoda ejele ababanjwe ngombana bakhohlwe amapasa ekhaya.&lt;ref name=&quot;:2&quot; /&gt; 

Lokho ngikho okwenza abomma abangaphasi kwehlangano i-''Federation of South African Women (FSAW)'' bathathe igadango lokutjhagala. Ngomhla ka-9 kuRhoboyi 1956 abomma abazii-20 000 bamatjhela e-''Union Building ePitori'' ngesinghonghoyilo sokuthi awuphele umthetho wamapasa. Kodwana kwafana nokuthela amanzi emhlana wedada. Ngikho nje ilangeli ligidingwa eSewula Afrika yoke ngoRhoboyi, iNyanga yaboMma.&lt;ref name=&quot;:2&quot; /&gt;

== Iinkhombo ==</text>
      <sha1>m8ux7zs26vnc5ohyun23xye5ezn3c3o</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Kgapane2025</title>
    <ns>2</ns>
    <id>780</id>
    <revision>
      <id>5245</id>
      <timestamp>2025-09-03T09:37:19Z</timestamp>
      <contributor>
        <username>Kgapane2025</username>
        <id>900</id>
      </contributor>
      <comment>ke tshenthitse leina laka.</comment>
      <origin>5245</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="27" sha1="h3hmitjlccye8wrkvhejd10k23v0ctm" xml:space="preserve">leina laka ke Jerry Raolane</text>
      <sha1>h3hmitjlccye8wrkvhejd10k23v0ctm</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Xikombiso1</title>
    <ns>2</ns>
    <id>781</id>
    <revision>
      <id>5246</id>
      <timestamp>2025-09-03T09:37:27Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <comment>Ngifake igama lami</comment>
      <origin>5246</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="28" sha1="pf2ylfg1h86y4rn1whk341mia6a26bi" xml:space="preserve">Igama lami ngingu Xikombiso.</text>
      <sha1>pf2ylfg1h86y4rn1whk341mia6a26bi</sha1>
    </revision>
    <revision>
      <id>5282</id>
      <parentid>5246</parentid>
      <timestamp>2025-09-03T10:11:43Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <minor />
      <comment>Created 3 sub-pages</comment>
      <origin>5282</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="165" sha1="ioig9330lq8bdw9ggus0q3xefi2iwee" xml:space="preserve">Igama lami ngingu Xikombiso.


[[Umsebenzisi:Xikombiso1/Page 1|Page 1]]   |   [[Umsebenzisi:Xikombiso1/Page 2|Page 2]]   |   [[Umsebenzisi:Xikombiso1/Page 3|Page 3]]</text>
      <sha1>ioig9330lq8bdw9ggus0q3xefi2iwee</sha1>
    </revision>
    <revision>
      <id>5295</id>
      <parentid>5282</parentid>
      <timestamp>2025-09-03T10:12:55Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <origin>5295</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="63" sha1="k4ryunnuijmysogrkxrlva53ys1hqyt" xml:space="preserve">Igama lami ngingu Xikombiso.


Page 1   |   Page 2   |   Page 3</text>
      <sha1>k4ryunnuijmysogrkxrlva53ys1hqyt</sha1>
    </revision>
    <revision>
      <id>5312</id>
      <parentid>5295</parentid>
      <timestamp>2025-09-03T10:15:06Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <minor />
      <comment>Created 3 sub pages</comment>
      <origin>5312</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="165" sha1="ioig9330lq8bdw9ggus0q3xefi2iwee" xml:space="preserve">Igama lami ngingu Xikombiso.


[[Umsebenzisi:Xikombiso1/Page 1|Page 1]]   |   [[Umsebenzisi:Xikombiso1/Page 2|Page 2]]   |   [[Umsebenzisi:Xikombiso1/Page 3|Page 3]]</text>
      <sha1>ioig9330lq8bdw9ggus0q3xefi2iwee</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Kholeka19721</title>
    <ns>2</ns>
    <id>782</id>
    <revision>
      <id>5247</id>
      <timestamp>2025-09-03T09:37:29Z</timestamp>
      <contributor>
        <username>Kholeka19721</username>
        <id>889</id>
      </contributor>
      <comment>ngifake igama lami</comment>
      <origin>5247</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="30" sha1="3g00hy1qbs7t7r3qb9dyc48xwzxg577" xml:space="preserve">Igama lami ngingu Kholeka19721</text>
      <sha1>3g00hy1qbs7t7r3qb9dyc48xwzxg577</sha1>
    </revision>
    <revision>
      <id>5281</id>
      <parentid>5247</parentid>
      <timestamp>2025-09-03T09:48:06Z</timestamp>
      <contributor>
        <username>Kholeka19721</username>
        <id>889</id>
      </contributor>
      <minor />
      <comment>ngifake itshwayo.</comment>
      <origin>5281</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="31" sha1="i5f4zv85ikeahtrz08kj8jc4gdk9fmc" xml:space="preserve">Igama lami ngingu Kholeka19721.</text>
      <sha1>i5f4zv85ikeahtrz08kj8jc4gdk9fmc</sha1>
    </revision>
    <revision>
      <id>5301</id>
      <parentid>5281</parentid>
      <timestamp>2025-09-03T10:13:15Z</timestamp>
      <contributor>
        <username>Kholeka19721</username>
        <id>889</id>
      </contributor>
      <minor />
      <origin>5301</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="155" sha1="tmvd9ura09h9tj5ftqm3b93p5awzwhg" xml:space="preserve">Igama lami ngingu Kholeka19721.


[[Umsebenzisi:Kholeka19721/|Page 1 |]]   [[Umsebenzisi:Kholeka19721/|Page 2]]    |   [[Umsebenzisi:Kholeka19721/|Page 3]]</text>
      <sha1>tmvd9ura09h9tj5ftqm3b93p5awzwhg</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Lerato Ruffy</title>
    <ns>2</ns>
    <id>783</id>
    <revision>
      <id>5248</id>
      <timestamp>2025-09-03T09:37:30Z</timestamp>
      <contributor>
        <username>Lerato Ruffy</username>
        <id>846</id>
      </contributor>
      <comment>Ngifake igama lami</comment>
      <origin>5248</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="30" sha1="12tpynrolvv1mn453v05bydnl54oh57" xml:space="preserve">Igama lami ngingu Lerato Ruffy</text>
      <sha1>12tpynrolvv1mn453v05bydnl54oh57</sha1>
    </revision>
    <revision>
      <id>5293</id>
      <parentid>5248</parentid>
      <timestamp>2025-09-03T10:12:28Z</timestamp>
      <contributor>
        <username>Lerato Ruffy</username>
        <id>846</id>
      </contributor>
      <comment>I have edited 3 sub-pages</comment>
      <origin>5293</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="177" sha1="73bnxmrmnj6ghe5ox1tn734of7kqmc5" xml:space="preserve">Igama lami ngingu Lerato Ruffy


[[Umsebenzisi:Lerato Ruffy/Page 1|Page 1]]   |   [[Umsebenzisi:Lerato Ruffy/Page 2|Page 2]]   |   [[Umsebenzisi:Lerato Ruffy/Page 3|Page 3]]   |</text>
      <sha1>73bnxmrmnj6ghe5ox1tn734of7kqmc5</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Journey2026</title>
    <ns>2</ns>
    <id>784</id>
    <revision>
      <id>5249</id>
      <timestamp>2025-09-03T09:37:30Z</timestamp>
      <contributor>
        <username>Journey2026</username>
        <id>881</id>
      </contributor>
      <comment>Ngifake igama lami</comment>
      <origin>5249</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="28" sha1="krt22hn9gxflkytyxdkkq4zlt7ttwpn" xml:space="preserve">Igama lami nginguJourney2026</text>
      <sha1>krt22hn9gxflkytyxdkkq4zlt7ttwpn</sha1>
    </revision>
    <revision>
      <id>5314</id>
      <parentid>5249</parentid>
      <timestamp>2025-09-03T10:15:47Z</timestamp>
      <contributor>
        <username>Journey2026</username>
        <id>881</id>
      </contributor>
      <origin>5314</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="72" sha1="huwsw0ppv5qcl5uac7e8iicrqapzi21" xml:space="preserve">Igama lami nginguJourney2026 


[[Page 1]]|     [[Page 2]]|  [[Page 3]]|</text>
      <sha1>huwsw0ppv5qcl5uac7e8iicrqapzi21</sha1>
    </revision>
    <revision>
      <id>5403</id>
      <parentid>5314</parentid>
      <timestamp>2025-09-03T12:08:42Z</timestamp>
      <contributor>
        <username>Journey2026</username>
        <id>881</id>
      </contributor>
      <minor />
      <origin>5403</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="103" sha1="75fy3a0o3ou8x15po4l9ou620dblr5r" xml:space="preserve">Igama lami nginguJourney2026 


[[Umsebenzisi:Journey2026/Page 1|Page 1]]|     [[Page 2]]|  [[Page 3]]|</text>
      <sha1>75fy3a0o3ou8x15po4l9ou620dblr5r</sha1>
    </revision>
    <revision>
      <id>5405</id>
      <parentid>5403</parentid>
      <timestamp>2025-09-03T12:12:11Z</timestamp>
      <contributor>
        <username>Journey2026</username>
        <id>881</id>
      </contributor>
      <minor />
      <comment>created draft pages</comment>
      <origin>5405</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="169" sha1="o7e0lvqnmi7r9ed313asp6tta6hu9s8" xml:space="preserve">Igama lami nginguJourney2026 


[[Umsebenzisi:Journey2026/Page 1|Page 1]]|     [[Umsebenzisi:Journey2026/Page 2|Page 2]]  |  [[Umsebenzisi:Journey2026/Page 3|Page 3]]  |</text>
      <sha1>o7e0lvqnmi7r9ed313asp6tta6hu9s8</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Tarryn 29</title>
    <ns>2</ns>
    <id>785</id>
    <revision>
      <id>5250</id>
      <timestamp>2025-09-03T09:37:30Z</timestamp>
      <contributor>
        <username>Tarryn 29</username>
        <id>886</id>
      </contributor>
      <comment>Ngifake igama lami</comment>
      <origin>5250</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="24" sha1="0jjk7jwanjugeqalf2m3tv95l8iz2mn" xml:space="preserve">Igama lami ngingu Tarryn</text>
      <sha1>0jjk7jwanjugeqalf2m3tv95l8iz2mn</sha1>
    </revision>
    <revision>
      <id>5297</id>
      <parentid>5250</parentid>
      <timestamp>2025-09-03T10:13:03Z</timestamp>
      <contributor>
        <username>Tarryn 29</username>
        <id>886</id>
      </contributor>
      <comment>Created 3 sub-pages</comment>
      <origin>5297</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="159" sha1="2eawwsau9mfmk9tv21etrft1kmvsra0" xml:space="preserve">Igama lami ngingu Tarryn.


[[Umsebenzisi:Tarryn 29/Page 1|Page 1]]   |   [[Umsebenzisi:Tarryn 29/Page 2|Page 2]]   |   [[Umsebenzisi:Tarryn 29/Page 3|Page 3]]</text>
      <sha1>2eawwsau9mfmk9tv21etrft1kmvsra0</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Pruddy01</title>
    <ns>2</ns>
    <id>786</id>
    <revision>
      <id>5251</id>
      <timestamp>2025-09-03T09:37:30Z</timestamp>
      <contributor>
        <username>Pruddy01</username>
        <id>895</id>
      </contributor>
      <comment>ngifake igama lami.</comment>
      <origin>5251</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="25" sha1="33y46xj4x6pbavhc2wjkykm14moup77" xml:space="preserve">Igama lami ngingu Pruddy.</text>
      <sha1>33y46xj4x6pbavhc2wjkykm14moup77</sha1>
    </revision>
    <revision>
      <id>5292</id>
      <parentid>5251</parentid>
      <timestamp>2025-09-03T10:12:18Z</timestamp>
      <contributor>
        <username>Pruddy01</username>
        <id>895</id>
      </contributor>
      <comment>I have created 3 sub pages</comment>
      <origin>5292</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="154" sha1="5ftigyx0x2acpv07ovzr9ntmpwmt5vw" xml:space="preserve">Igama lami ngingu Pruddy.


[[Umsebenzisi:Pruddy01/Page 1|Page 1]]   | [[Umsebenzisi:Pruddy01/Page 2|Page 2]]   |   [[Umsebenzisi:Pruddy01/Page 3|Page 3]]</text>
      <sha1>5ftigyx0x2acpv07ovzr9ntmpwmt5vw</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:NaMathibela</title>
    <ns>2</ns>
    <id>787</id>
    <revision>
      <id>5252</id>
      <timestamp>2025-09-03T09:37:31Z</timestamp>
      <contributor>
        <username>NaMathibela</username>
        <id>888</id>
      </contributor>
      <comment>Ngifake igama lami</comment>
      <origin>5252</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="22" sha1="gurwm2gz57lv46jr7w47ad2al9ot9fe" xml:space="preserve">Igama lami nginguEmely</text>
      <sha1>gurwm2gz57lv46jr7w47ad2al9ot9fe</sha1>
    </revision>
    <revision>
      <id>5299</id>
      <parentid>5252</parentid>
      <timestamp>2025-09-03T10:13:06Z</timestamp>
      <contributor>
        <username>NaMathibela</username>
        <id>888</id>
      </contributor>
      <minor />
      <origin>5299</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="162" sha1="2c4im8ikgoao1fpi5k09v2uay90i4wk" xml:space="preserve">Igama lami nginguEmely


[[Umsebenzisi:NaMathibela/Page 1|Page 1]]   |   [[Umsebenzisi:NaMathibela/Page 2|Page 2]]   |   [[Umsebenzisi:NaMathibela/Page 3|Page 3]]</text>
      <sha1>2c4im8ikgoao1fpi5k09v2uay90i4wk</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:White Edits</title>
    <ns>2</ns>
    <id>788</id>
    <revision>
      <id>5253</id>
      <timestamp>2025-09-03T09:37:31Z</timestamp>
      <contributor>
        <username>White Edits</username>
        <id>894</id>
      </contributor>
      <comment>Ngifake igama lami</comment>
      <origin>5253</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="29" sha1="9i9vj9luug9fbp8b2pmpvrozmwt2ckx" xml:space="preserve">Igama lami ngingu white edits</text>
      <sha1>9i9vj9luug9fbp8b2pmpvrozmwt2ckx</sha1>
    </revision>
    <revision>
      <id>5288</id>
      <parentid>5253</parentid>
      <timestamp>2025-09-03T10:12:00Z</timestamp>
      <contributor>
        <username>White Edits</username>
        <id>894</id>
      </contributor>
      <comment>created 3 sub pages</comment>
      <origin>5288</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="168" sha1="6c9ybgvf2bsonicgsw6q85ycuwhnrz0" xml:space="preserve">Igama lami ngingu white edits


[[Umsebenzisi:White Edits/Page 1|page 1]]   |  [[Umsebenzisi:White Edits/Page 2|page 2]]   |   [[Umsebenzisi:White Edits/Page 3|page 3]]</text>
      <sha1>6c9ybgvf2bsonicgsw6q85ycuwhnrz0</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Nothi2003</title>
    <ns>2</ns>
    <id>789</id>
    <revision>
      <id>5254</id>
      <timestamp>2025-09-03T09:37:31Z</timestamp>
      <contributor>
        <username>Nothi2003</username>
        <id>833</id>
      </contributor>
      <comment>Ngifake igama lami.</comment>
      <origin>5254</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="27" sha1="pbbhy1cey6xg95de8nloqlozz7k8xqp" xml:space="preserve">Igama lami nginguNothi2003.</text>
      <sha1>pbbhy1cey6xg95de8nloqlozz7k8xqp</sha1>
    </revision>
    <revision>
      <id>5284</id>
      <parentid>5254</parentid>
      <timestamp>2025-09-03T10:11:54Z</timestamp>
      <contributor>
        <username>Nothi2003</username>
        <id>833</id>
      </contributor>
      <comment>created sub-pages</comment>
      <origin>5284</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="161" sha1="33vx5bfbwb4ieax08hp3xzq6ql4bxq1" xml:space="preserve">Igama lami nginguNothi2003.


[[Umsebenzisi:Nothi2003/Page 1|Page 1]]   |   [[Umsebenzisi:Nothi2003/Page 2|Page 2]]   |   [[Umsebenzisi:Nothi2003/Page 3|Page 3]]</text>
      <sha1>33vx5bfbwb4ieax08hp3xzq6ql4bxq1</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:ThokozaniSlaki</title>
    <ns>2</ns>
    <id>790</id>
    <revision>
      <id>5255</id>
      <timestamp>2025-09-03T09:37:41Z</timestamp>
      <contributor>
        <username>ThokozaniSlaki</username>
        <id>842</id>
      </contributor>
      <comment>Ngifake igama lami,</comment>
      <origin>5255</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="34" sha1="q4omrrn16mo41a7qfm8u58r8vjzrw1i" xml:space="preserve">igama lami ngingu Thokozani Moses.</text>
      <sha1>q4omrrn16mo41a7qfm8u58r8vjzrw1i</sha1>
    </revision>
    <revision>
      <id>5300</id>
      <parentid>5255</parentid>
      <timestamp>2025-09-03T10:13:10Z</timestamp>
      <contributor>
        <username>ThokozaniSlaki</username>
        <id>842</id>
      </contributor>
      <comment>I have created 3 sub headings. Ngenze iinhlokwana ezintathu.</comment>
      <origin>5300</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="181" sha1="av5w5gly0udeon4azetdk0pypciu1tc" xml:space="preserve">igama lami ngingu Thokozani Moses.


[[Umsebenzisi:ThokozaniSlaki/Page 1|Page 1]]   | [[Umsebenzisi:ThokozaniSlaki/Page 2|Page 2]]   |   [[Umsebenzisi:ThokozaniSlaki/Page 3|Page 3]]</text>
      <sha1>av5w5gly0udeon4azetdk0pypciu1tc</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Nomhle R</title>
    <ns>2</ns>
    <id>791</id>
    <revision>
      <id>5256</id>
      <timestamp>2025-09-03T09:37:45Z</timestamp>
      <contributor>
        <username>Nomhle R</username>
        <id>799</id>
      </contributor>
      <comment>mgifake igama lami ngesindebele</comment>
      <origin>5256</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="26" sha1="mhnxqbdrkjccd55n4m1hl6we5mvorkx" xml:space="preserve">Igama lami ngingu Nomhle R</text>
      <sha1>mhnxqbdrkjccd55n4m1hl6we5mvorkx</sha1>
    </revision>
    <revision>
      <id>5283</id>
      <parentid>5256</parentid>
      <timestamp>2025-09-03T10:11:51Z</timestamp>
      <contributor>
        <username>Nomhle R</username>
        <id>799</id>
      </contributor>
      <comment>created 3 sub-pages</comment>
      <origin>5283</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="156" sha1="rxfjgql0kwwmgqi314rd3xzgs3ego92" xml:space="preserve">Igama lami ngingu Nomhle R


[[Umsebenzisi:Nomhle R/Page 1|page 1]]  | [[Umsebenzisi:Nomhle R/Page 2|page 2]]   | [[Umsebenzisi:Nomhle R/Page 3|page 3]]   |</text>
      <sha1>rxfjgql0kwwmgqi314rd3xzgs3ego92</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Nabungela</title>
    <ns>2</ns>
    <id>792</id>
    <revision>
      <id>5257</id>
      <timestamp>2025-09-03T09:38:20Z</timestamp>
      <contributor>
        <username>Nabungela</username>
        <id>885</id>
      </contributor>
      <comment>Ngifake igama lami</comment>
      <origin>5257</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="27" sha1="9d3up5aqjkpznbmhlot6vb33yk8yist" xml:space="preserve">Igama lami ngingu Nabungela</text>
      <sha1>9d3up5aqjkpznbmhlot6vb33yk8yist</sha1>
    </revision>
    <revision>
      <id>5303</id>
      <parentid>5257</parentid>
      <timestamp>2025-09-03T10:13:43Z</timestamp>
      <contributor>
        <username>Nabungela</username>
        <id>885</id>
      </contributor>
      <minor />
      <origin>5303</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="161" sha1="cewzi6pnrx5nodemcm8xzvud5fsslor" xml:space="preserve">Igama lami ngingu Nabungela


[[Umsebenzisi:Nabungela/Page 1|Page 1]]   |   [[Umsebenzisi:Nabungela/Page 2|Page 2]]   |   [[Umsebenzisi:Nabungela/Page 3|Page 3]]</text>
      <sha1>cewzi6pnrx5nodemcm8xzvud5fsslor</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Mtsweni S</title>
    <ns>2</ns>
    <id>793</id>
    <revision>
      <id>5258</id>
      <timestamp>2025-09-03T09:38:24Z</timestamp>
      <contributor>
        <username>Mtsweni S</username>
        <id>835</id>
      </contributor>
      <comment>Ngibhale igama lami.</comment>
      <origin>5258</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="27" sha1="f9vd3i1alqw3zev8ljv45dyhjh6eqi5" xml:space="preserve">Igama lami ngingu Mtsweni S</text>
      <sha1>f9vd3i1alqw3zev8ljv45dyhjh6eqi5</sha1>
    </revision>
    <revision>
      <id>5290</id>
      <parentid>5258</parentid>
      <timestamp>2025-09-03T10:12:10Z</timestamp>
      <contributor>
        <username>Mtsweni S</username>
        <id>835</id>
      </contributor>
      <minor />
      <comment>Created 3 sub pages</comment>
      <origin>5290</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="161" sha1="1wknxbhnjwlyb1mst796zvczxg6fged" xml:space="preserve">Igama lami ngingu Mtsweni S


[[Umsebenzisi:Mtsweni S/Page 1|Page 1.]]  |   [[Umsebenzisi:Mtsweni S/Page 2|Page 2]]   |   [[Umsebenzisi:Mtsweni S/Page 3|Page 3]]</text>
      <sha1>1wknxbhnjwlyb1mst796zvczxg6fged</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:NASKHOSANA</title>
    <ns>2</ns>
    <id>794</id>
    <revision>
      <id>5259</id>
      <timestamp>2025-09-03T09:38:30Z</timestamp>
      <contributor>
        <username>NASKHOSANA</username>
        <id>884</id>
      </contributor>
      <comment>Ngifake igama lami</comment>
      <origin>5259</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="28" sha1="27ch07rjwb7pt2k1uaxsyfzhpsdpppl" xml:space="preserve">Igama lami ngingu NASKHOSANA</text>
      <sha1>27ch07rjwb7pt2k1uaxsyfzhpsdpppl</sha1>
    </revision>
    <revision>
      <id>5307</id>
      <parentid>5259</parentid>
      <timestamp>2025-09-03T10:14:15Z</timestamp>
      <contributor>
        <username>NASKHOSANA</username>
        <id>884</id>
      </contributor>
      <minor />
      <origin>5307</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="163" sha1="4jajlm9v8v9azl9pkrx3fqag29dc0d8" xml:space="preserve">Igama lami ngingu NASKHOSANA


[[Umsebenzisi:NASKHOSANA/Page 1|Page 1]]   |  [[Umsebenzisi:NASKHOSANA/Page 2|Page 2]]   |  [[Umsebenzisi:NASKHOSANA/Page 3|Page 3]]</text>
      <sha1>4jajlm9v8v9azl9pkrx3fqag29dc0d8</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Dladlakamogelo07</title>
    <ns>2</ns>
    <id>795</id>
    <revision>
      <id>5260</id>
      <timestamp>2025-09-03T09:38:48Z</timestamp>
      <contributor>
        <username>Dladlakamogelo07</username>
        <id>903</id>
      </contributor>
      <comment>hdfgvhsdbgvfhdbg</comment>
      <origin>5260</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="21" sha1="tc69s32wfka7a37aw3d8irdhvmpxm5c" xml:space="preserve">fdkfdkhgfgfghfkgfkfkg</text>
      <sha1>tc69s32wfka7a37aw3d8irdhvmpxm5c</sha1>
    </revision>
    <revision>
      <id>5271</id>
      <parentid>5260</parentid>
      <timestamp>2025-09-03T09:40:03Z</timestamp>
      <contributor>
        <username>Dladlakamogelo07</username>
        <id>903</id>
      </contributor>
      <comment>Ngifake igama lami</comment>
      <origin>5271</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="23" sha1="k7rbg528lxdnknsscvow1vhkruadnok" xml:space="preserve">Igama lami ngingu $ick0</text>
      <sha1>k7rbg528lxdnknsscvow1vhkruadnok</sha1>
    </revision>
    <revision>
      <id>5310</id>
      <parentid>5271</parentid>
      <timestamp>2025-09-03T10:14:35Z</timestamp>
      <contributor>
        <username>Dladlakamogelo07</username>
        <id>903</id>
      </contributor>
      <origin>5310</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="178" sha1="irn3xkhrnqzada7fj008yvh06b7ntfi" xml:space="preserve">Igama lami ngingu $ick0


[[Umsebenzisi:Dladlakamogelo07/Page 1|Page 1]]   |   [[Umsebenzisi:Dladlakamogelo07/Page 2|Page 2]]   |   [[Umsebenzisi:Dladlakamogelo07/Page 3|Page 3]]</text>
      <sha1>irn3xkhrnqzada7fj008yvh06b7ntfi</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:2003.Ma</title>
    <ns>2</ns>
    <id>796</id>
    <revision>
      <id>5261</id>
      <timestamp>2025-09-03T09:38:49Z</timestamp>
      <contributor>
        <username>2003.Ma</username>
        <id>882</id>
      </contributor>
      <comment>Created page with &quot;Igama lami ngingu 2003.Ma. Ngitlole igama lami&quot;</comment>
      <origin>5261</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="46" sha1="2t9c3kcc23ndizq6zcvqlqf9rpupx6h" xml:space="preserve">Igama lami ngingu 2003.Ma. Ngitlole igama lami</text>
      <sha1>2t9c3kcc23ndizq6zcvqlqf9rpupx6h</sha1>
    </revision>
    <revision>
      <id>5298</id>
      <parentid>5261</parentid>
      <timestamp>2025-09-03T10:13:04Z</timestamp>
      <contributor>
        <username>2003.Ma</username>
        <id>882</id>
      </contributor>
      <minor />
      <comment>I've created three sub pages</comment>
      <origin>5298</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="160" sha1="ciycsqosdwkn5ow8vpwlldy2kl4ib3e" xml:space="preserve">Igama lami ngingu 2003.Ma. Ngitlole igama lami  


[[Umsebenzisi:2003.Ma/Page1|Page1]] |[[Umsebenzisi:2003.Ma/|page 2]]|   [[Umsebenzisi:2003.Ma/Page 3|page 3]]</text>
      <sha1>ciycsqosdwkn5ow8vpwlldy2kl4ib3e</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:MahlanguLucky23</title>
    <ns>2</ns>
    <id>797</id>
    <revision>
      <id>5262</id>
      <timestamp>2025-09-03T09:38:50Z</timestamp>
      <contributor>
        <username>MahlanguLucky23</username>
        <id>876</id>
      </contributor>
      <comment>ngifake igama lami</comment>
      <origin>5262</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="25" sha1="l0q8k410qhrl5yb5zb6hua21vbgynon" xml:space="preserve">Igama lami ngingu XIbambo</text>
      <sha1>l0q8k410qhrl5yb5zb6hua21vbgynon</sha1>
    </revision>
    <revision>
      <id>5308</id>
      <parentid>5262</parentid>
      <timestamp>2025-09-03T10:14:24Z</timestamp>
      <contributor>
        <username>MahlanguLucky23</username>
        <id>876</id>
      </contributor>
      <origin>5308</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="176" sha1="g0p5jaewd8d7o86a63x2yke2ed5d9ib" xml:space="preserve">Igama lami ngingu XIbambo



[[Umsebenzisi:MahlanguLucky23/Page 1|Page 1]] |  [[Umsebenzisi:MahlanguLucky23/Page 2|Page  2]]  |  [[Umsebenzisi:MahlanguLucky23/Page 3|Page 3]] |</text>
      <sha1>g0p5jaewd8d7o86a63x2yke2ed5d9ib</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Nomsa Skosana</title>
    <ns>2</ns>
    <id>798</id>
    <revision>
      <id>5263</id>
      <timestamp>2025-09-03T09:39:04Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <comment>I have added my details.</comment>
      <origin>5263</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="211" sha1="45ax0qs8ypmy45fvb5gzfxtr567lzu5" xml:space="preserve">Igama lami nginguNomsa Skosana, ngimrhubhululi welimi lesiNdebele. Nginetjiseko yokutlola nokubulunga ilimi lesiNdebele kuWikiphidiya. Ngimdosi phambili nehlelweni lakwa-SADiLaR-Wikipedia-PanSALB (SWiP) Project.</text>
      <sha1>45ax0qs8ypmy45fvb5gzfxtr567lzu5</sha1>
    </revision>
    <revision>
      <id>5280</id>
      <parentid>5263</parentid>
      <timestamp>2025-09-03T09:48:01Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <origin>5280</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="446" sha1="rdilhrwz312o0ehgaideil0qaa86ptm" xml:space="preserve">Igama lami nginguNomsa Skosana, ngimrhubhululi welimi lesiNdebele. Nginetjiseko yokutlola nokubulunga ilimi lesiNdebele kuWikiphidiya. Ngimdosi phambili nehlelweni lakwa-SADiLaR-Wikipedia-PanSALB (SWiP) Project, ihlelweli lithuthukisa ukubulungwa kwamalimi asemthethweni weSewula Afrikha. Likhambela woke amaYunivesithi akhona enerheni le, lifundisa abafundi, abafundisi nalabo abathanda amalimi bona bangawabulunga njani amalimabo kuWikiphidiya.</text>
      <sha1>rdilhrwz312o0ehgaideil0qaa86ptm</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Ghostingghost</title>
    <ns>2</ns>
    <id>799</id>
    <revision>
      <id>5264</id>
      <timestamp>2025-09-03T09:39:07Z</timestamp>
      <contributor>
        <username>Ghostingghost</username>
        <id>890</id>
      </contributor>
      <comment>Ngifake igama lami</comment>
      <origin>5264</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="31" sha1="7qs6s73f42roc0rx8x49wugea3msxjs" xml:space="preserve">Igama lami ngingu Ghostingghost</text>
      <sha1>7qs6s73f42roc0rx8x49wugea3msxjs</sha1>
    </revision>
    <revision>
      <id>5311</id>
      <parentid>5264</parentid>
      <timestamp>2025-09-03T10:14:56Z</timestamp>
      <contributor>
        <username>Ghostingghost</username>
        <id>890</id>
      </contributor>
      <minor />
      <comment>Create sub-pages</comment>
      <origin>5311</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="181" sha1="6cvcbmyai7kjqwc0nzdxg47zmnedlpg" xml:space="preserve">Igama lami ngingu Ghostingghost




[[Umsebenzisi:Ghostingghost/Page 1|Page 1]]    |   [[Umsebenzisi:Ghostingghost/Page 2|Page 2]]  |  [[Umsebenzisi:Ghostingghost/Page 3|Page 3]]  |</text>
      <sha1>6cvcbmyai7kjqwc0nzdxg47zmnedlpg</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Mbonani JayJay</title>
    <ns>2</ns>
    <id>800</id>
    <revision>
      <id>5265</id>
      <timestamp>2025-09-03T09:39:10Z</timestamp>
      <contributor>
        <username>Mbonani JayJay</username>
        <id>892</id>
      </contributor>
      <comment>Ngifake igama lami</comment>
      <origin>5265</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="24" sha1="rqrhcdj3900lwwbi0dg9na9qmm1fimf" xml:space="preserve">Igama lami ngingu JayJay</text>
      <sha1>rqrhcdj3900lwwbi0dg9na9qmm1fimf</sha1>
    </revision>
    <revision>
      <id>5296</id>
      <parentid>5265</parentid>
      <timestamp>2025-09-03T10:12:59Z</timestamp>
      <contributor>
        <username>Mbonani JayJay</username>
        <id>892</id>
      </contributor>
      <origin>5296</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="175" sha1="6dcs0k78o9d9ap1nz6iz718gf0iv3bt" xml:space="preserve">Igama lami ngingu JayJay


[[Umsebenzisi:Mbonani JayJay/Page 1/|Page 1]]   |    [[Umsebenzisi:Mbonani JayJay/Page 2|Page 2]]   |   [[Umsebenzisi:Mbonani JayJay/Page 3|Page 3]]</text>
      <sha1>6dcs0k78o9d9ap1nz6iz718gf0iv3bt</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:F.K MAHLANGU</title>
    <ns>2</ns>
    <id>801</id>
    <revision>
      <id>5266</id>
      <timestamp>2025-09-03T09:39:18Z</timestamp>
      <contributor>
        <username>F.K MAHLANGU</username>
        <id>891</id>
      </contributor>
      <comment>Ngifake igama lami.</comment>
      <origin>5266</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="31" sha1="2clm1cfbd2q7mxscnff7v54xtvgw1ve" xml:space="preserve">Igama lami ngingu F.K MAHLANGU.</text>
      <sha1>2clm1cfbd2q7mxscnff7v54xtvgw1ve</sha1>
    </revision>
    <revision>
      <id>5305</id>
      <parentid>5266</parentid>
      <timestamp>2025-09-03T10:14:06Z</timestamp>
      <contributor>
        <username>F.K MAHLANGU</username>
        <id>891</id>
      </contributor>
      <minor />
      <comment>created 3 sub-pages</comment>
      <origin>5305</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="174" sha1="jdgsfh271ycjheqs2zgkl8cfejgo59f" xml:space="preserve">Igama lami ngingu F.K MAHLANGU.


[[Umsebenzisi:F.K MAHLANGU/Page 1|page 1]]   |   [[Umsebenzisi:F.K MAHLANGU/Page 2|page 2]]   |   [[Umsebenzisi:F.K MAHLANGU/Page 3|page 3]]</text>
      <sha1>jdgsfh271ycjheqs2zgkl8cfejgo59f</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Tiny Engeline</title>
    <ns>2</ns>
    <id>802</id>
    <revision>
      <id>5267</id>
      <timestamp>2025-09-03T09:39:22Z</timestamp>
      <contributor>
        <username>Tiny Engeline</username>
        <id>896</id>
      </contributor>
      <comment>Ngifake igama lami</comment>
      <origin>5267</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="31" sha1="rhshexz48kr5b4ooc54cnhdife8v4px" xml:space="preserve">Igama lami ngingu Tiny Engeline</text>
      <sha1>rhshexz48kr5b4ooc54cnhdife8v4px</sha1>
    </revision>
    <revision>
      <id>5294</id>
      <parentid>5267</parentid>
      <timestamp>2025-09-03T10:12:43Z</timestamp>
      <contributor>
        <username>Tiny Engeline</username>
        <id>896</id>
      </contributor>
      <comment>Imininigwano</comment>
      <origin>5294</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="176" sha1="0ep4xfnn49y67fevv4f0nq7uqz6ioaa" xml:space="preserve">Igama lami ngingu Tiny Engeline

[[Umsebenzisi:Tiny Engeline/Page 1|Page 1]]   |   [[Umsebenzisi:Tiny Engeline/Page2|Page2]]   |   [[Umsebenzisi:Tiny Engeline/Page3|Page3]]   |</text>
      <sha1>0ep4xfnn49y67fevv4f0nq7uqz6ioaa</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Imkabini</title>
    <ns>2</ns>
    <id>803</id>
    <revision>
      <id>5268</id>
      <timestamp>2025-09-03T09:39:32Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <comment>Ngifake igama lami</comment>
      <origin>5268</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="26" sha1="kufug1mf0isvep4cwdtvuvlvm38wk01" xml:space="preserve">Igama lami ngingu Imkabini</text>
      <sha1>kufug1mf0isvep4cwdtvuvlvm38wk01</sha1>
    </revision>
    <revision>
      <id>5287</id>
      <parentid>5268</parentid>
      <timestamp>2025-09-03T10:12:00Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <minor />
      <comment>ngifake amakhasi amathathu</comment>
      <origin>5287</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="161" sha1="5913ws1fjte15ivvn3ki86a0gogyscy" xml:space="preserve">Igama lami ngingu Imkabini


[[Umsebenzisi:Imkabini/Page 1|Page 1]]   |   [[Umsebenzisi:Imkabini/Page 2|Page 2]]   |   [[Umsebenzisi:Imkabini/Page 3|Page 3]]   |</text>
      <sha1>5913ws1fjte15ivvn3ki86a0gogyscy</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Enthusiastic Lady</title>
    <ns>2</ns>
    <id>804</id>
    <revision>
      <id>5269</id>
      <timestamp>2025-09-03T09:39:52Z</timestamp>
      <contributor>
        <username>Enthusiastic Lady</username>
        <id>899</id>
      </contributor>
      <comment>Ngifake igama lami</comment>
      <origin>5269</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="35" sha1="8xv6ur1mkem5lq7knxjdc6vajx2gqkl" xml:space="preserve">Igama lami ngingu Enthusiastic Lady</text>
      <sha1>8xv6ur1mkem5lq7knxjdc6vajx2gqkl</sha1>
    </revision>
    <revision>
      <id>5291</id>
      <parentid>5269</parentid>
      <timestamp>2025-09-03T10:12:13Z</timestamp>
      <contributor>
        <username>Enthusiastic Lady</username>
        <id>899</id>
      </contributor>
      <minor />
      <origin>5291</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="193" sha1="ld6w7n7ey58fbdall9u1ga35iwvsacq" xml:space="preserve">Igama lami ngingu Enthusiastic Lady


[[Umsebenzisi:Enthusiastic Lady/Page 1|Page 1]]  |   [[Umsebenzisi:Enthusiastic Lady/Page 2|Page 2]]   |    [[Umsebenzisi:Enthusiastic Lady/Page 3|Page 3]]</text>
      <sha1>ld6w7n7ey58fbdall9u1ga35iwvsacq</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Pholap</title>
    <ns>2</ns>
    <id>805</id>
    <revision>
      <id>5270</id>
      <timestamp>2025-09-03T09:39:53Z</timestamp>
      <contributor>
        <username>Pholap</username>
        <id>883</id>
      </contributor>
      <comment>Ngifake igama lami</comment>
      <origin>5270</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="24" sha1="ktdlrozgvoo87mt8y7ld9ooy2to1u5h" xml:space="preserve">Igama lami ngingu Pholap</text>
      <sha1>ktdlrozgvoo87mt8y7ld9ooy2to1u5h</sha1>
    </revision>
    <revision>
      <id>5277</id>
      <parentid>5270</parentid>
      <timestamp>2025-09-03T09:40:53Z</timestamp>
      <contributor>
        <username>Pholap</username>
        <id>883</id>
      </contributor>
      <minor />
      <origin>5277</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="38" sha1="p9uiqhgfgczrey40i3sfiwz8w4q4ykp" xml:space="preserve">Igama lami ngingu Pholap and i am here</text>
      <sha1>p9uiqhgfgczrey40i3sfiwz8w4q4ykp</sha1>
    </revision>
    <revision>
      <id>5278</id>
      <parentid>5277</parentid>
      <timestamp>2025-09-03T09:41:15Z</timestamp>
      <contributor>
        <username>Pholap</username>
        <id>883</id>
      </contributor>
      <minor />
      <origin>5278</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="24" sha1="ktdlrozgvoo87mt8y7ld9ooy2to1u5h" xml:space="preserve">Igama lami ngingu Pholap</text>
      <sha1>ktdlrozgvoo87mt8y7ld9ooy2to1u5h</sha1>
    </revision>
    <revision>
      <id>5289</id>
      <parentid>5278</parentid>
      <timestamp>2025-09-03T10:12:03Z</timestamp>
      <contributor>
        <username>Pholap</username>
        <id>883</id>
      </contributor>
      <comment>Created 3 subheadings</comment>
      <origin>5289</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="147" sha1="rag7ctq4v7xruwehxxr7myi84aqko1r" xml:space="preserve">Igama lami ngingu Pholap




[[Umsebenzisi:Pholap/Page 1|Page]]  1 |  [[Umsebenzisi:Pholap/Page 2|Page 2]] | [[Umsebenzisi:Pholap/Page 3|Page 3]] |</text>
      <sha1>rag7ctq4v7xruwehxxr7myi84aqko1r</sha1>
    </revision>
    <revision>
      <id>5313</id>
      <parentid>5289</parentid>
      <timestamp>2025-09-03T10:15:16Z</timestamp>
      <contributor>
        <username>Pholap</username>
        <id>883</id>
      </contributor>
      <minor />
      <comment>Created 3 sub pages</comment>
      <origin>5313</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="145" sha1="k1j93x3wpwff1ach7mpola33q8pth23" xml:space="preserve">Igama lami ngingu Pholap




[[Umsebenzisi:Pholap/Page 1|Page]] 1 | [[Umsebenzisi:Pholap/Page 2|Page 2]] | [[Umsebenzisi:Pholap/Page 3|Page 3]] |</text>
      <sha1>k1j93x3wpwff1ach7mpola33q8pth23</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:2000Gp01</title>
    <ns>2</ns>
    <id>806</id>
    <revision>
      <id>5272</id>
      <timestamp>2025-09-03T09:40:37Z</timestamp>
      <contributor>
        <username>2000Gp01</username>
        <id>880</id>
      </contributor>
      <comment>ngifake igama lami</comment>
      <origin>5272</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="22" sha1="sj7oudsepyjhcdbwdf8u4lee2ezjqs2" xml:space="preserve">Igama lami ngu2000Gp01</text>
      <sha1>sj7oudsepyjhcdbwdf8u4lee2ezjqs2</sha1>
    </revision>
    <revision>
      <id>5286</id>
      <parentid>5272</parentid>
      <timestamp>2025-09-03T10:11:59Z</timestamp>
      <contributor>
        <username>2000Gp01</username>
        <id>880</id>
      </contributor>
      <comment>I've created 3 sub-pages</comment>
      <origin>5286</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="150" sha1="tu9tos2d4jy4yja4cupmhwua6764rxk" xml:space="preserve">Igama lami ngu2000Gp01


[[Umsebenzisi:2000Gp01/Page 1|Page 1]]  |   [[Umsebenzisi:2000Gp01/Page 2|Page 2]]   | [[Umsebenzisi:2000Gp01/Page 3|Page 3]]</text>
      <sha1>tu9tos2d4jy4yja4cupmhwua6764rxk</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:ThembekileSihle29</title>
    <ns>2</ns>
    <id>807</id>
    <revision>
      <id>5273</id>
      <timestamp>2025-09-03T09:40:45Z</timestamp>
      <contributor>
        <username>ThembekileSihle29</username>
        <id>887</id>
      </contributor>
      <comment>Ngifake igama lami.</comment>
      <origin>5273</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="35" sha1="51ur3maxmqfzl9v6aeyiplryeu5wbl9" xml:space="preserve">Igama lami nginguThembekileSihle29.</text>
      <sha1>51ur3maxmqfzl9v6aeyiplryeu5wbl9</sha1>
    </revision>
    <revision>
      <id>5306</id>
      <parentid>5273</parentid>
      <timestamp>2025-09-03T10:14:12Z</timestamp>
      <contributor>
        <username>ThembekileSihle29</username>
        <id>887</id>
      </contributor>
      <comment>I have created 3 sub headings.Ngenze iinhlokwana ezintathu.</comment>
      <origin>5306</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="195" sha1="q5ju9diktots0kofj1e7x8d431x8wz6" xml:space="preserve">Igama lami ngingu ThembekileSihle29.



[[Umsebenzisi:ThembekileSihle29/Page 1|Page 1]]   |   [[Umsebenzisi:ThembekileSihle29/Page 2|Page 2]]   |   [[Umsebenzisi:ThembekileSihle29/Page 3|Page 3]]</text>
      <sha1>q5ju9diktots0kofj1e7x8d431x8wz6</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Sister01</title>
    <ns>2</ns>
    <id>808</id>
    <revision>
      <id>5274</id>
      <timestamp>2025-09-03T09:40:46Z</timestamp>
      <contributor>
        <username>Sister01</username>
        <id>893</id>
      </contributor>
      <comment>Ngifake igama lami.</comment>
      <origin>5274</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="24" sha1="qp1pxdcro2vao2p7akvcl10g1bed2rf" xml:space="preserve">Igama lami ngingu Sister</text>
      <sha1>qp1pxdcro2vao2p7akvcl10g1bed2rf</sha1>
    </revision>
    <revision>
      <id>5302</id>
      <parentid>5274</parentid>
      <timestamp>2025-09-03T10:13:18Z</timestamp>
      <contributor>
        <username>Sister01</username>
        <id>893</id>
      </contributor>
      <comment>I created sub pages</comment>
      <origin>5302</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="155" sha1="bfq3fsza2gcdoxc1hrqsbd3uba7a18f" xml:space="preserve">Igama lami ngingu Sister


[[Umsebenzisi:Sister01/Page 1|Page 1]]   |   [[Umsebenzisi:Sister01/Page 2|Page 2]]   |   [[Umsebenzisi:Sister01/Page 3|Page 3]]</text>
      <sha1>bfq3fsza2gcdoxc1hrqsbd3uba7a18f</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Zanokuhle14</title>
    <ns>2</ns>
    <id>809</id>
    <revision>
      <id>5275</id>
      <timestamp>2025-09-03T09:40:49Z</timestamp>
      <contributor>
        <username>Zanokuhle14</username>
        <id>897</id>
      </contributor>
      <comment>Ngibhale igama lami</comment>
      <origin>5275</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="27" sha1="edvukj00y8u12f1xc0wgdzt4b10770e" xml:space="preserve">Igama lami ngingu Zanokuhle</text>
      <sha1>edvukj00y8u12f1xc0wgdzt4b10770e</sha1>
    </revision>
    <revision>
      <id>5309</id>
      <parentid>5275</parentid>
      <timestamp>2025-09-03T10:14:29Z</timestamp>
      <contributor>
        <username>Zanokuhle14</username>
        <id>897</id>
      </contributor>
      <minor />
      <comment>Created 3 sub-pages</comment>
      <origin>5309</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="168" sha1="hnb73n3e0saub0d1vi1x0hxdlu8e9cy" xml:space="preserve">Igama lami ngingu Zanokuhle


[[Umsebenzisi:Zanokuhle14/Page 1|Page  1]]   |   [[Umsebenzisi:Zanokuhle14/Page 2|Page 2]]   |   [[Umsebenzisi:Zanokuhle14/Page 3|Page 3]]</text>
      <sha1>hnb73n3e0saub0d1vi1x0hxdlu8e9cy</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Londiwe23</title>
    <ns>2</ns>
    <id>810</id>
    <revision>
      <id>5276</id>
      <timestamp>2025-09-03T09:40:49Z</timestamp>
      <contributor>
        <username>Londiwe23</username>
        <id>902</id>
      </contributor>
      <comment>Ngifake igama lami</comment>
      <origin>5276</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="25" sha1="4rgmphreco8sb2b3heimxf7j6o7fo7a" xml:space="preserve">Igama lami ngingu Londiwe</text>
      <sha1>4rgmphreco8sb2b3heimxf7j6o7fo7a</sha1>
    </revision>
    <revision>
      <id>5304</id>
      <parentid>5276</parentid>
      <timestamp>2025-09-03T10:14:00Z</timestamp>
      <contributor>
        <username>Londiwe23</username>
        <id>902</id>
      </contributor>
      <comment>Created 3 sub-pages</comment>
      <origin>5304</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="159" sha1="ra8xom5b0qfhd9cqou8ix3ip6iw60vq" xml:space="preserve">Igama lami ngingu Londiwe


[[Umsebenzisi:Londiwe23/Page 1|Page 1]]   |   [[Umsebenzisi:Londiwe23/Page 2|Page 2]]   |   [[Umsebenzisi:Londiwe23/Page 3|Page 3]]</text>
      <sha1>ra8xom5b0qfhd9cqou8ix3ip6iw60vq</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Mannroy</title>
    <ns>2</ns>
    <id>811</id>
    <revision>
      <id>5279</id>
      <timestamp>2025-09-03T09:44:56Z</timestamp>
      <contributor>
        <username>Mannroy</username>
        <id>879</id>
      </contributor>
      <comment>Ngifake igama lami.</comment>
      <origin>5279</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="35" sha1="fqnz51dujh9lkqrjmvz8p8spedv5rpl" xml:space="preserve">Lotjhani, igama lami ngingu Mannroy</text>
      <sha1>fqnz51dujh9lkqrjmvz8p8spedv5rpl</sha1>
    </revision>
    <revision>
      <id>5285</id>
      <parentid>5279</parentid>
      <timestamp>2025-09-03T10:11:55Z</timestamp>
      <contributor>
        <username>Mannroy</username>
        <id>879</id>
      </contributor>
      <comment>Ngifake iinhlokwanan ezintathu</comment>
      <origin>5285</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="159" sha1="i58ynf9mr9eycinmiw2ly4by01hzpwv" xml:space="preserve">Lotjhani, igama lami ngingu Mannroy


[[Umsebenzisi:Mannroy/Page 1|Page 1]]   | [[Umsebenzisi:Mannroy/Page 2|Page 2]]   | [[Umsebenzisi:Mannroy/Page 3|Page 3]]</text>
      <sha1>i58ynf9mr9eycinmiw2ly4by01hzpwv</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Xikombiso1/Page 1</title>
    <ns>2</ns>
    <id>812</id>
    <revision>
      <id>5315</id>
      <timestamp>2025-09-03T10:17:48Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <comment>Created sub-page 1</comment>
      <origin>5315</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="22" sha1="hwmiw332bq71gkswwriny0ylkehr845" xml:space="preserve">Page 1:  Draft space 1</text>
      <sha1>hwmiw332bq71gkswwriny0ylkehr845</sha1>
    </revision>
    <revision>
      <id>5402</id>
      <parentid>5315</parentid>
      <timestamp>2025-09-03T10:49:50Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <origin>5402</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1116" sha1="smzilmz3mz0jrpmo2zb2puoscslrs8b" xml:space="preserve">Page 1:  Draft space 1

 

== Umsuka womlambo ==
Umlambo i-Olifants uthoma phakathi kweendawo i-Breyten ne-Bethal, [[Isifunda seMpumalanga|esifundeni se-Mpumalanga]].  Umlambo lo ugelezela tjhuba langetlhagwini ukuya e[[Limpopo|sifundeni seLimpopo]] ngokudlula e-Witbank Dam&lt;ref&gt;[https://www.mpumalanga.com/press-media/blog/a-record-breaking-dam A Record Breaking Dam - Mpumalanga]&lt;/ref&gt;, begodu idlule nase Loskop Dam. Kusukela lapho, ikatelelwa ziintaba ze Transvaal Drankensberg bonyana itjhinge ngepumalanga yeLimpopo. Sele useLimpopo, udlula e-Abel Erasmus Pass bese ugelezela ngepumalanga uyokudlula i-Lowveld (esehleni) lapha uyokuhlangana khona nomlambo i-Letaba. Nawusuka lapho, umlambo lo ukhamba utjhinge esifundeni se-Gaza, [[Mozambique|ese-Mozambique]]. ngemva kokuba namajikajika ngonobangela weentaba ze-Lebombo ngendlela ye-[[Olifants Gorge]]. Lapha ke, umlambo lo sewubizwa ngokuthi yi ''-Rio dos Elefantes'', ngelimi lesi [[Portuguese]].  Ekugcineni kwayo ihlangana nomlambo i-Limpopo eselelwe makhilomitha ama-40km bonyana ingene elwandle i-Indian Ocean e-Xai-Xai etlhagwini ye-[[Maputo]]. 




*</text>
      <sha1>smzilmz3mz0jrpmo2zb2puoscslrs8b</sha1>
    </revision>
    <revision>
      <id>5435</id>
      <parentid>5402</parentid>
      <timestamp>2025-09-04T07:35:48Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <origin>5435</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1101" sha1="sawxgtlv0njxcsv334n0olyr38duqbl" xml:space="preserve">Page 1:  Draft space 1

 

== Umsuka womlambo ==
Umlambo i-Olifants uthoma phakathi kweendawo i-Breyten ne-Bethal, [[Isifunda seMpumalanga|esifundeni se-Mpumalanga]].  Umlambo lo ugelezela tjhuba langetlhagwini ukuya e[[Limpopo|sifundeni seLimpopo]] ngokudlula e-Witbank Dam&lt;ref&gt;[https://www.mpumalanga.com/press-media/blog/a-record-breaking-dam A Record Breaking Dam - Mpumalanga]&lt;/ref&gt;, begodu idlule nase Loskop Dam. Kusukela lapho, ikatelelwa ziintaba ze Transvaal Drankensberg bonyana itjhinge ngepumalanga yeLimpopo. Sele useLimpopo, udlula e-Abel Erasmus Pass bese ugelezela ngepumalanga uyokudlula i-Lowveld (esehleni) lapha uyokuhlangana khona nomlambo i-Letaba. Nawusuka lapho, umlambo lo ukhamba utjhinge esifundeni se-Gaza, ese-Mozambique. ngemva kokuba namajikajika ngonobangela weentaba ze-Lebombo ngendlela ye-[[Olifants Gorge]]. Lapha ke, umlambo lo sewubizwa ngokuthi yi ''-Rio dos Elefantes'', ngelimi lesi [[Portuguese]].  Ekugcineni kwayo ihlangana nomlambo i-Limpopo eselelwe makhilomitha ama-40km bonyana ingene elwandle i-Indian Ocean e-Xai-Xai etlhagwini ye-[[Maputo]]. 




*</text>
      <sha1>sawxgtlv0njxcsv334n0olyr38duqbl</sha1>
    </revision>
    <revision>
      <id>5437</id>
      <parentid>5435</parentid>
      <timestamp>2025-09-04T07:48:11Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <comment>Added reference section</comment>
      <origin>5437</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1122" sha1="8y4l32dk4bs9lqk6ctankjy6b8v6wg3" xml:space="preserve">Page 1:  Draft space 1

 

== Umsuka womlambo ==
Umlambo i-Olifants uthoma phakathi kweendawo i-Breyten ne-Bethal, [[Isifunda seMpumalanga|esifundeni se-Mpumalanga]].  Umlambo lo ugelezela tjhuba langetlhagwini ukuya e[[Limpopo|sifundeni seLimpopo]] ngokudlula e-Witbank Dam&lt;ref&gt;[https://www.mpumalanga.com/press-media/blog/a-record-breaking-dam A Record Breaking Dam - Mpumalanga]&lt;/ref&gt;, begodu idlule nase Loskop Dam. Kusukela lapho, ikatelelwa ziintaba ze Transvaal Drankensberg bonyana itjhinge ngepumalanga yeLimpopo. Sele useLimpopo, udlula e-Abel Erasmus Pass bese ugelezela ngepumalanga uyokudlula i-Lowveld (esehleni) lapha uyokuhlangana khona nomlambo i-Letaba. Nawusuka lapho, umlambo lo ukhamba utjhinge esifundeni se-Gaza, ese-Mozambique. ngemva kokuba namajikajika ngonobangela weentaba ze-Lebombo ngendlela ye-[[Olifants Gorge]]. Lapha ke, umlambo lo sewubizwa ngokuthi yi ''-Rio dos Elefantes'', ngelimi lesi [[Portuguese]].  Ekugcineni kwayo ihlangana nomlambo i-Limpopo eselelwe makhilomitha ama-40km bonyana ingene elwandle i-Indian Ocean e-Xai-Xai etlhagwini ye-[[Maputo]]. 



=== Imithombo lwazi ===</text>
      <sha1>8y4l32dk4bs9lqk6ctankjy6b8v6wg3</sha1>
    </revision>
    <revision>
      <id>5441</id>
      <parentid>5437</parentid>
      <timestamp>2025-09-04T07:49:58Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <comment>Added references list</comment>
      <origin>5441</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1137" sha1="91jww4nn4q4a5gc3s90e75az0g0yut9" xml:space="preserve">Page 1:  Draft space 1

 

== Umsuka womlambo ==
Umlambo i-Olifants uthoma phakathi kweendawo i-Breyten ne-Bethal, [[Isifunda seMpumalanga|esifundeni se-Mpumalanga]].  Umlambo lo ugelezela tjhuba langetlhagwini ukuya e[[Limpopo|sifundeni seLimpopo]] ngokudlula e-Witbank Dam&lt;ref&gt;[https://www.mpumalanga.com/press-media/blog/a-record-breaking-dam A Record Breaking Dam - Mpumalanga]&lt;/ref&gt;, begodu idlule nase Loskop Dam. Kusukela lapho, ikatelelwa ziintaba ze Transvaal Drankensberg bonyana itjhinge ngepumalanga yeLimpopo. Sele useLimpopo, udlula e-Abel Erasmus Pass bese ugelezela ngepumalanga uyokudlula i-Lowveld (esehleni) lapha uyokuhlangana khona nomlambo i-Letaba. Nawusuka lapho, umlambo lo ukhamba utjhinge esifundeni se-Gaza, ese-Mozambique. ngemva kokuba namajikajika ngonobangela weentaba ze-Lebombo ngendlela ye-[[Olifants Gorge]]. Lapha ke, umlambo lo sewubizwa ngokuthi yi ''-Rio dos Elefantes'', ngelimi lesi [[Portuguese]].  Ekugcineni kwayo ihlangana nomlambo i-Limpopo eselelwe makhilomitha ama-40km bonyana ingene elwandle i-Indian Ocean e-Xai-Xai etlhagwini ye-[[Maputo]]. 



=== Imithombo lwazi ===
&lt;references /&gt;</text>
      <sha1>91jww4nn4q4a5gc3s90e75az0g0yut9</sha1>
    </revision>
    <revision>
      <id>5443</id>
      <parentid>5441</parentid>
      <timestamp>2025-09-04T07:51:02Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <comment>Redoing example</comment>
      <origin>5443</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1094" sha1="1l6n4tt4x2kze89ir6uan2fkszu0gaq" xml:space="preserve">Page 1:  Draft space 1

 

== Umsuka womlambo ==
Umlambo i-Olifants uthoma phakathi kweendawo i-Breyten ne-Bethal, [[Isifunda seMpumalanga|esifundeni se-Mpumalanga]].  Umlambo lo ugelezela tjhuba langetlhagwini ukuya e[[Limpopo|sifundeni seLimpopo]] ngokudlula e-Witbank Dam&lt;ref&gt;[https://www.mpumalanga.com/press-media/blog/a-record-breaking-dam A Record Breaking Dam - Mpumalanga]&lt;/ref&gt;, begodu idlule nase Loskop Dam. Kusukela lapho, ikatelelwa ziintaba ze Transvaal Drankensberg bonyana itjhinge ngepumalanga yeLimpopo. Sele useLimpopo, udlula e-Abel Erasmus Pass bese ugelezela ngepumalanga uyokudlula i-Lowveld (esehleni) lapha uyokuhlangana khona nomlambo i-Letaba. Nawusuka lapho, umlambo lo ukhamba utjhinge esifundeni se-Gaza, ese-Mozambique. ngemva kokuba namajikajika ngonobangela weentaba ze-Lebombo ngendlela ye-[[Olifants Gorge]]. Lapha ke, umlambo lo sewubizwa ngokuthi yi ''-Rio dos Elefantes'', ngelimi lesi [[Portuguese]].  Ekugcineni kwayo ihlangana nomlambo i-Limpopo eselelwe makhilomitha ama-40km bonyana ingene elwandle i-Indian Ocean e-Xai-Xai etlhagwini ye-[[Maputo]].</text>
      <sha1>1l6n4tt4x2kze89ir6uan2fkszu0gaq</sha1>
    </revision>
    <revision>
      <id>5444</id>
      <parentid>5443</parentid>
      <timestamp>2025-09-04T07:51:57Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <comment>Added references list</comment>
      <origin>5444</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1149" sha1="7amocblewuq5ga1e4exr2ohbu00gy8w" xml:space="preserve">Page 1:  Draft space 1

 

== Umsuka womlambo ==
Umlambo i-Olifants uthoma phakathi kweendawo i-Breyten ne-Bethal, [[Isifunda seMpumalanga|esifundeni se-Mpumalanga]].  Umlambo lo ugelezela tjhuba langetlhagwini ukuya e[[Limpopo|sifundeni seLimpopo]] ngokudlula e-Witbank Dam&lt;ref&gt;[https://www.mpumalanga.com/press-media/blog/a-record-breaking-dam A Record Breaking Dam - Mpumalanga]&lt;/ref&gt;, begodu idlule nase Loskop Dam. Kusukela lapho, ikatelelwa ziintaba ze Transvaal Drankensberg bonyana itjhinge ngepumalanga yeLimpopo. Sele useLimpopo, udlula e-Abel Erasmus Pass bese ugelezela ngepumalanga uyokudlula i-Lowveld (esehleni) lapha uyokuhlangana khona nomlambo i-Letaba. Nawusuka lapho, umlambo lo ukhamba utjhinge esifundeni se-Gaza, ese-Mozambique. ngemva kokuba namajikajika ngonobangela weentaba ze-Lebombo ngendlela ye-[[Olifants Gorge]]. Lapha ke, umlambo lo sewubizwa ngokuthi yi ''-Rio dos Elefantes'', ngelimi lesi [[Portuguese]].  Ekugcineni kwayo ihlangana nomlambo i-Limpopo eselelwe makhilomitha ama-40km bonyana ingene elwandle i-Indian Ocean e-Xai-Xai etlhagwini ye-[[Maputo]].
&lt;references /&gt;

=== Imithombo lwazi ===
&lt;references /&gt;</text>
      <sha1>7amocblewuq5ga1e4exr2ohbu00gy8w</sha1>
    </revision>
    <revision>
      <id>5445</id>
      <parentid>5444</parentid>
      <timestamp>2025-09-04T07:52:17Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <origin>5445</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1134" sha1="jx0uvu19ao10ywtud1t0x1gfgmul9kr" xml:space="preserve">Page 1:  Draft space 1

 

== Umsuka womlambo ==
Umlambo i-Olifants uthoma phakathi kweendawo i-Breyten ne-Bethal, [[Isifunda seMpumalanga|esifundeni se-Mpumalanga]].  Umlambo lo ugelezela tjhuba langetlhagwini ukuya e[[Limpopo|sifundeni seLimpopo]] ngokudlula e-Witbank Dam&lt;ref&gt;[https://www.mpumalanga.com/press-media/blog/a-record-breaking-dam A Record Breaking Dam - Mpumalanga]&lt;/ref&gt;, begodu idlule nase Loskop Dam. Kusukela lapho, ikatelelwa ziintaba ze Transvaal Drankensberg bonyana itjhinge ngepumalanga yeLimpopo. Sele useLimpopo, udlula e-Abel Erasmus Pass bese ugelezela ngepumalanga uyokudlula i-Lowveld (esehleni) lapha uyokuhlangana khona nomlambo i-Letaba. Nawusuka lapho, umlambo lo ukhamba utjhinge esifundeni se-Gaza, ese-Mozambique. ngemva kokuba namajikajika ngonobangela weentaba ze-Lebombo ngendlela ye-[[Olifants Gorge]]. Lapha ke, umlambo lo sewubizwa ngokuthi yi ''-Rio dos Elefantes'', ngelimi lesi [[Portuguese]].  Ekugcineni kwayo ihlangana nomlambo i-Limpopo eselelwe makhilomitha ama-40km bonyana ingene elwandle i-Indian Ocean e-Xai-Xai etlhagwini ye-[[Maputo]].

=== Imithombo lwazi ===
&lt;references /&gt;</text>
      <sha1>jx0uvu19ao10ywtud1t0x1gfgmul9kr</sha1>
    </revision>
    <revision>
      <id>5448</id>
      <parentid>5445</parentid>
      <timestamp>2025-09-04T07:53:42Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <origin>5448</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1113" sha1="pr8qfcxalfp1k9caaenn5rh9xg5mzms" xml:space="preserve">Page 1:  Draft space 1
----

Umlambo i-Olifants uthoma phakathi kweendawo i-Breyten ne-Bethal, [[Isifunda seMpumalanga|esifundeni se-Mpumalanga]].  Umlambo lo ugelezela tjhuba langetlhagwini ukuya e[[Limpopo|sifundeni seLimpopo]] ngokudlula e-Witbank Dam&lt;ref&gt;[https://www.mpumalanga.com/press-media/blog/a-record-breaking-dam A Record Breaking Dam - Mpumalanga]&lt;/ref&gt;, begodu idlule nase Loskop Dam. Kusukela lapho, ikatelelwa ziintaba ze Transvaal Drankensberg bonyana itjhinge ngepumalanga yeLimpopo. Sele useLimpopo, udlula e-Abel Erasmus Pass bese ugelezela ngepumalanga uyokudlula i-Lowveld (esehleni) lapha uyokuhlangana khona nomlambo i-Letaba. Nawusuka lapho, umlambo lo ukhamba utjhinge esifundeni se-Gaza, ese-Mozambique. ngemva kokuba namajikajika ngonobangela weentaba ze-Lebombo ngendlela ye-[[Olifants Gorge]]. Lapha ke, umlambo lo sewubizwa ngokuthi yi ''-Rio dos Elefantes'', ngelimi lesi [[Portuguese]].  Ekugcineni kwayo ihlangana nomlambo i-Limpopo eselelwe makhilomitha ama-40km bonyana ingene elwandle i-Indian Ocean e-Xai-Xai etlhagwini ye-[[Maputo]].

=== Imithombo lwazi ===
&lt;references /&gt;</text>
      <sha1>pr8qfcxalfp1k9caaenn5rh9xg5mzms</sha1>
    </revision>
    <revision>
      <id>5467</id>
      <parentid>5448</parentid>
      <timestamp>2025-09-04T08:19:10Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <origin>5467</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1000" sha1="a75mz7oy4ky3wr7c51803yfkojxdr66" xml:space="preserve">Page 1:  Draft space 1
----

Umlambo i-Olifants uthoma phakathi kweendawo i-Breyten ne-Bethal, [[Isifunda seMpumalanga|esifundeni se-Mpumalanga]].  Umlambo lo ugelezela tjhuba langetlhagwini ukuya e[[Limpopo|sifundeni seLimpopo]] ngokudlula e-Witbank Dam, begodu idlule nase Loskop Dam. Kusukela lapho, ikatelelwa ziintaba ze Transvaal Drankensberg bonyana itjhinge ngepumalanga yeLimpopo. Sele useLimpopo, udlula e-Abel Erasmus Pass bese ugelezela ngepumalanga uyokudlula i-Lowveld (esehleni) lapha uyokuhlangana khona nomlambo i-Letaba. Nawusuka lapho, umlambo lo ukhamba utjhinge esifundeni se-Gaza, ese-Mozambique. ngemva kokuba namajikajika ngonobangela weentaba ze-Lebombo ngendlela ye-[[Olifants Gorge]]. Lapha ke, umlambo lo sewubizwa ngokuthi yi ''-Rio dos Elefantes'', ngelimi lesi [[Portuguese]].  Ekugcineni kwayo ihlangana nomlambo i-Limpopo eselelwe makhilomitha ama-40km bonyana ingene elwandle i-Indian Ocean e-Xai-Xai etlhagwini ye-[[Maputo]].

=== Imithombo lwazi ===
&lt;references /&gt;</text>
      <sha1>a75mz7oy4ky3wr7c51803yfkojxdr66</sha1>
    </revision>
    <revision>
      <id>5470</id>
      <parentid>5467</parentid>
      <timestamp>2025-09-04T08:24:23Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <comment>Added reference</comment>
      <origin>5470</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1175" sha1="ersb1ktoyvknssh9yb9yejnngqi14ee" xml:space="preserve">Page 1:  Draft space 1
----

Umlambo i-Olifants uthoma phakathi kweendawo i-Breyten ne-Bethal, [[Isifunda seMpumalanga|esifundeni se-Mpumalanga]].  Umlambo lo ugelezela tjhuba langetlhagwini ukuya e[[Limpopo|sifundeni seLimpopo]] ngokudlula e-Witbank Dam, begodu idlule nase Loskop Dam &lt;ref&gt;{{Cite web |title=A Record Breaking Dam |url=http://www.mpumalanga.com/press-media/blog/a-record-breaking-dam |access-date=2025-09-04 |website=www.mpumalanga.com}}&lt;/ref&gt;. Kusukela lapho, ikatelelwa ziintaba ze Transvaal Drankensberg bonyana itjhinge ngepumalanga yeLimpopo. Sele useLimpopo, udlula e-Abel Erasmus Pass bese ugelezela ngepumalanga uyokudlula i-Lowveld (esehleni) lapha uyokuhlangana khona nomlambo i-Letaba. Nawusuka lapho, umlambo lo ukhamba utjhinge esifundeni se-Gaza, ese-Mozambique. ngemva kokuba namajikajika ngonobangela weentaba ze-Lebombo ngendlela ye-[[Olifants Gorge]]. Lapha ke, umlambo lo sewubizwa ngokuthi yi ''-Rio dos Elefantes'', ngelimi lesi [[Portuguese]].  Ekugcineni kwayo ihlangana nomlambo i-Limpopo eselelwe makhilomitha ama-40km bonyana ingene elwandle i-Indian Ocean e-Xai-Xai etlhagwini ye-[[Maputo]].

=== Imithombo lwazi ===
&lt;references /&gt;</text>
      <sha1>ersb1ktoyvknssh9yb9yejnngqi14ee</sha1>
    </revision>
    <revision>
      <id>5472</id>
      <parentid>5470</parentid>
      <timestamp>2025-09-04T08:29:08Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <comment>Added second reference</comment>
      <origin>5472</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1431" sha1="efna8ee7k60y7ja8g04b7omr78tjovu" xml:space="preserve">Page 1:  Draft space 1
----

Umlambo i-Olifants (begodu laziwa nge Lepelle)&lt;ref&gt;{{Cite web |title=Kruger Park Times - Olifants River now called Lepelle |url=https://www.krugerpark.co.za/krugerpark-times-2-15-olifants-river-lepelle-20557.html |access-date=2025-09-04 |website=www.krugerpark.co.za}}&lt;/ref&gt; uthoma phakathi kweendawo i-Breyten ne-Bethal, [[Isifunda seMpumalanga|esifundeni se-Mpumalanga]].  Umlambo lo ugelezela tjhuba langetlhagwini ukuya e[[Limpopo|sifundeni seLimpopo]] ngokudlula e-Witbank Dam, begodu idlule nase Loskop Dam &lt;ref&gt;{{Cite web |title=A Record Breaking Dam |url=http://www.mpumalanga.com/press-media/blog/a-record-breaking-dam |access-date=2025-09-04 |website=www.mpumalanga.com}}&lt;/ref&gt;. Kusukela lapho, ikatelelwa ziintaba ze Transvaal Drankensberg bonyana itjhinge ngepumalanga yeLimpopo. Sele useLimpopo, udlula e-Abel Erasmus Pass bese ugelezela ngepumalanga uyokudlula i-Lowveld (esehleni) lapha uyokuhlangana khona nomlambo i-Letaba. Nawusuka lapho, umlambo lo ukhamba utjhinge esifundeni se-Gaza, ese-Mozambique. ngemva kokuba namajikajika ngonobangela weentaba ze-Lebombo ngendlela ye-[[Olifants Gorge]]. Lapha ke, umlambo lo sewubizwa ngokuthi yi ''-Rio dos Elefantes'', ngelimi lesi [[Portuguese]].  Ekugcineni kwayo ihlangana nomlambo i-Limpopo eselelwe makhilomitha ama-40km bonyana ingene elwandle i-Indian Ocean e-Xai-Xai etlhagwini ye-[[Maputo]].

=== Imithombo lwazi ===
&lt;references /&gt;</text>
      <sha1>efna8ee7k60y7ja8g04b7omr78tjovu</sha1>
    </revision>
    <revision>
      <id>5510</id>
      <parentid>5472</parentid>
      <timestamp>2025-09-04T09:15:58Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <origin>5510</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1257" sha1="tmsejcrgjs2d9a6r11jx4r9kinfub7o" xml:space="preserve">Page 1:  Draft space 1
----

Umlambo i-Olifants (begodu laziwa nge Lepelle)&lt;ref&gt;{{Cite web |title=Kruger Park Times - Olifants River now called Lepelle |url=https://www.krugerpark.co.za/krugerpark-times-2-15-olifants-river-lepelle-20557.html |access-date=2025-09-04 |website=www.krugerpark.co.za}}&lt;/ref&gt; uthoma phakathi kweendawo i-Breyten ne-Bethal, [[Isifunda seMpumalanga|esifundeni se-Mpumalanga]].  Umlambo lo ugelezela tjhuba langetlhagwini ukuya e[[Limpopo|sifundeni seLimpopo]] ngokudlula e-Witbank Dam, begodu idlule nase Loskop Dam . Kusukela lapho, ikatelelwa ziintaba ze Transvaal Drankensberg bonyana itjhinge ngepumalanga yeLimpopo. Sele useLimpopo, udlula e-Abel Erasmus Pass bese ugelezela ngepumalanga uyokudlula i-Lowveld (esehleni) lapha uyokuhlangana khona nomlambo i-Letaba. Nawusuka lapho, umlambo lo ukhamba utjhinge esifundeni se-Gaza, ese-Mozambique. ngemva kokuba namajikajika ngonobangela weentaba ze-Lebombo ngendlela ye-[[Olifants Gorge]]. Lapha ke, umlambo lo sewubizwa ngokuthi yi ''-Rio dos Elefantes'', ngelimi lesi [[Portuguese]].  Ekugcineni kwayo ihlangana nomlambo i-Limpopo eselelwe makhilomitha ama-40km bonyana ingene elwandle i-Indian Ocean e-Xai-Xai etlhagwini ye-[[Maputo]].

=== Imithombo lwazi ===
&lt;references /&gt;</text>
      <sha1>tmsejcrgjs2d9a6r11jx4r9kinfub7o</sha1>
    </revision>
    <revision>
      <id>5513</id>
      <parentid>5510</parentid>
      <timestamp>2025-09-04T09:17:19Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <origin>5513</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1480" sha1="t0y2v1asw43r4xcg826m6g0b0awjjg2" xml:space="preserve">Page 1:  Draft space 1
----

Umlambo i-Olifants (begodu laziwa nge Lepelle)&lt;ref&gt;{{Cite web |title=Kruger Park Times - Olifants River now called Lepelle |url=https://www.krugerpark.co.za/krugerpark-times-2-15-olifants-river-lepelle-20557.html |access-date=2025-09-04 |website=www.krugerpark.co.za}}&lt;/ref&gt; uthoma phakathi kweendawo i-Breyten ne-Bethal, [[Isifunda seMpumalanga|esifundeni se-Mpumalanga]].  Umlambo lo ugelezela tjhuba langetlhagwini ukuya e[[Limpopo|sifundeni seLimpopo]] ngokudlula e-Witbank Dam, begodu idlule nase Loskop Dam.&lt;ref&gt;{{Cite web|title=Kruger Park Times - Olifants River now called Lepelle|url=https://www.krugerpark.co.za/krugerpark-times-2-15-olifants-river-lepelle-20557.html|access-date=2025-09-04|website=www.krugerpark.co.za}}&lt;/ref&gt; Kusukela lapho, ikatelelwa ziintaba ze Transvaal Drankensberg bonyana itjhinge ngepumalanga yeLimpopo. Sele useLimpopo, udlula e-Abel Erasmus Pass bese ugelezela ngepumalanga uyokudlula i-Lowveld (esehleni) lapha uyokuhlangana khona nomlambo i-Letaba. Nawusuka lapho, umlambo lo ukhamba utjhinge esifundeni se-Gaza, ese-Mozambique. ngemva kokuba namajikajika ngonobangela weentaba ze-Lebombo ngendlela ye-[[Olifants Gorge]]. Lapha ke, umlambo lo sewubizwa ngokuthi yi ''-Rio dos Elefantes'', ngelimi lesi [[Portuguese]].  Ekugcineni kwayo ihlangana nomlambo i-Limpopo eselelwe makhilomitha ama-40km bonyana ingene elwandle i-Indian Ocean e-Xai-Xai etlhagwini ye-[[Maputo]].

=== Imithombo lwazi ===
&lt;references /&gt;</text>
      <sha1>t0y2v1asw43r4xcg826m6g0b0awjjg2</sha1>
    </revision>
    <revision>
      <id>5518</id>
      <parentid>5513</parentid>
      <timestamp>2025-09-04T09:19:42Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <origin>5518</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1507" sha1="ar8t90uhnc0b17prz2iovi0dwykyl0f" xml:space="preserve">Page 1:  Draft space 1
----

Umlambo i-Olifants (begodu laziwa nge Lepelle)&lt;ref&gt;{{Cite web |title=Kruger Park Times - Olifants River now called Lepelle |url=https://www.krugerpark.co.za/krugerpark-times-2-15-olifants-river-lepelle-20557.html |access-date=2025-09-04 |website=www.krugerpark.co.za}}&lt;/ref&gt; uthoma phakathi kweendawo i-Breyten ne-Bethal, [[Isifunda seMpumalanga|esifundeni se-Mpumalanga]].  

=== Umlando womlambo ===
Umlambo lo ugelezela tjhuba langetlhagwini ukuya e[[Limpopo|sifundeni seLimpopo]] ngokudlula e-Witbank Dam, begodu idlule nase Loskop Dam.&lt;ref&gt;{{Cite web|title=Kruger Park Times - Olifants River now called Lepelle|url=https://www.krugerpark.co.za/krugerpark-times-2-15-olifants-river-lepelle-20557.html|access-date=2025-09-04|website=www.krugerpark.co.za}}&lt;/ref&gt; Kusukela lapho, ikatelelwa ziintaba ze Transvaal Drankensberg bonyana itjhinge ngepumalanga yeLimpopo. Sele useLimpopo, udlula e-Abel Erasmus Pass bese ugelezela ngepumalanga uyokudlula i-Lowveld (esehleni) lapha uyokuhlangana khona nomlambo i-Letaba. Nawusuka lapho, umlambo lo ukhamba utjhinge esifundeni se-Gaza, ese-Mozambique. ngemva kokuba namajikajika ngonobangela weentaba ze-Lebombo ngendlela ye-[[Olifants Gorge]]. Lapha ke, umlambo lo sewubizwa ngokuthi yi ''-Rio dos Elefantes'', ngelimi lesi [[Portuguese]].  Ekugcineni kwayo ihlangana nomlambo i-Limpopo eselelwe makhilomitha ama-40km bonyana ingene elwandle i-Indian Ocean e-Xai-Xai etlhagwini ye-[[Maputo]].

=== Imithombo lwazi ===
&lt;references /&gt;</text>
      <sha1>ar8t90uhnc0b17prz2iovi0dwykyl0f</sha1>
    </revision>
    <revision>
      <id>5533</id>
      <parentid>5518</parentid>
      <timestamp>2025-09-04T09:26:28Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <comment>Added a link</comment>
      <origin>5533</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1522" sha1="itam8i5ydz81nmnvadbtvoz5d92icvm" xml:space="preserve">Page 1:  Draft space 1
----

Umlambo i-Olifants (begodu laziwa nge Lepelle)&lt;ref&gt;{{Cite web |title=Kruger Park Times - Olifants River now called Lepelle |url=https://www.krugerpark.co.za/krugerpark-times-2-15-olifants-river-lepelle-20557.html |access-date=2025-09-04 |website=www.krugerpark.co.za}}&lt;/ref&gt; uthoma phakathi kweendawo i-Breyten ne-Bethal, [[Isifunda seMpumalanga|esifundeni se-Mpumalanga]].  

=== Umlando womlambo ===
Umlambo lo ugelezela tjhuba langetlhagwini ukuya e[[Limpopo|sifundeni seLimpopo]] ngokudlula e-Witbank Dam, begodu idlule nase Loskop Dam.&lt;ref&gt;{{Cite web|title=Kruger Park Times - Olifants River now called Lepelle|url=https://www.krugerpark.co.za/krugerpark-times-2-15-olifants-river-lepelle-20557.html|access-date=2025-09-04|website=www.krugerpark.co.za}}&lt;/ref&gt; Kusukela lapho, ikatelelwa ziintaba ze Transvaal Drankensberg bonyana itjhinge ngepumalanga yeLimpopo. Sele useLimpopo, udlula e-Abel Erasmus Pass bese ugelezela ngepumalanga uyokudlula i-Lowveld (esehleni) lapha uyokuhlangana khona nomlambo i-Letaba. Nawusuka lapho, umlambo lo ukhamba utjhinge esifundeni se-Gaza, [[Mozambique|ese-Mozambique]]. ngemva kokuba namajikajika ngonobangela weentaba ze-Lebombo ngendlela ye-[[Olifants Gorge]]. Lapha ke, umlambo lo sewubizwa ngokuthi yi ''-Rio dos Elefantes'', ngelimi lesi [[Portuguese]].  Ekugcineni kwayo ihlangana nomlambo i-Limpopo eselelwe makhilomitha ama-40km bonyana ingene elwandle i-Indian Ocean e-Xai-Xai etlhagwini ye-[[Maputo]].

=== Imithombo lwazi ===
&lt;references /&gt;</text>
      <sha1>itam8i5ydz81nmnvadbtvoz5d92icvm</sha1>
    </revision>
    <revision>
      <id>5546</id>
      <parentid>5533</parentid>
      <timestamp>2025-09-04T09:35:26Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <origin>5546</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1510" sha1="i2n39vkq2jqv27jf1yi8x0syd5hoemx" xml:space="preserve">Page 1:  Draft space 1
----

Umlambo i-Olifants (begodu laziwa nge Lepelle)&lt;ref&gt;{{Cite web |title=Kruger Park Times - Olifants River now called Lepelle |url=https://www.krugerpark.co.za/krugerpark-times-2-15-olifants-river-lepelle-20557.html |access-date=2025-09-04 |website=www.krugerpark.co.za}}&lt;/ref&gt; uthoma phakathi kweendawo i-Breyten ne-Bethal, [[Isifunda seMpumalanga|esifundeni se-Mpumalanga]].  

=== Umlando womlambo ===
Umlambo lo ugelezela tjhuba langetlhagwini ukuya esifundeni seLimpopo ngokudlula e-Witbank Dam, begodu idlule nase Loskop Dam.&lt;ref&gt;{{Cite web|title=Kruger Park Times - Olifants River now called Lepelle|url=https://www.krugerpark.co.za/krugerpark-times-2-15-olifants-river-lepelle-20557.html|access-date=2025-09-04|website=www.krugerpark.co.za}}&lt;/ref&gt; Kusukela lapho, ikatelelwa ziintaba ze Transvaal Drankensberg bonyana itjhinge ngepumalanga yeLimpopo. Sele useLimpopo, udlula e-Abel Erasmus Pass bese ugelezela ngepumalanga uyokudlula i-Lowveld (esehleni) lapha uyokuhlangana khona nomlambo i-Letaba. Nawusuka lapho, umlambo lo ukhamba utjhinge esifundeni se-Gaza, [[Mozambique|ese-Mozambique]]. ngemva kokuba namajikajika ngonobangela weentaba ze-Lebombo ngendlela ye-[[Olifants Gorge]]. Lapha ke, umlambo lo sewubizwa ngokuthi yi ''-Rio dos Elefantes'', ngelimi lesi [[Portuguese]].  Ekugcineni kwayo ihlangana nomlambo i-Limpopo eselelwe makhilomitha ama-40km bonyana ingene elwandle i-Indian Ocean e-Xai-Xai etlhagwini ye-[[Maputo]].

=== Imithombo lwazi ===
&lt;references /&gt;</text>
      <sha1>i2n39vkq2jqv27jf1yi8x0syd5hoemx</sha1>
    </revision>
    <revision>
      <id>5551</id>
      <parentid>5546</parentid>
      <timestamp>2025-09-04T09:37:00Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <origin>5551</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1522" sha1="24dciegh6ymsyapamp8s9ywrejoeyng" xml:space="preserve">Page 1:  Draft space 1
----

Umlambo i-Olifants (begodu laziwa nge Lepelle)&lt;ref&gt;{{Cite web |title=Kruger Park Times - Olifants River now called Lepelle |url=https://www.krugerpark.co.za/krugerpark-times-2-15-olifants-river-lepelle-20557.html |access-date=2025-09-04 |website=www.krugerpark.co.za}}&lt;/ref&gt; uthoma phakathi kweendawo i-Breyten ne-Bethal, [[Isifunda seMpumalanga|esifundeni se-Mpumalanga]].  

=== Umlando womlambo ===
Umlambo lo ugelezela tjhuba langetlhagwini ukuya [[Limpopo|esifundeni seLimpopo]] ngokudlula e-Witbank Dam, begodu idlule nase Loskop Dam.&lt;ref&gt;{{Cite web|title=Kruger Park Times - Olifants River now called Lepelle|url=https://www.krugerpark.co.za/krugerpark-times-2-15-olifants-river-lepelle-20557.html|access-date=2025-09-04|website=www.krugerpark.co.za}}&lt;/ref&gt; Kusukela lapho, ikatelelwa ziintaba ze Transvaal Drankensberg bonyana itjhinge ngepumalanga yeLimpopo. Sele useLimpopo, udlula e-Abel Erasmus Pass bese ugelezela ngepumalanga uyokudlula i-Lowveld (esehleni) lapha uyokuhlangana khona nomlambo i-Letaba. Nawusuka lapho, umlambo lo ukhamba utjhinge esifundeni se-Gaza, [[Mozambique|ese-Mozambique]]. ngemva kokuba namajikajika ngonobangela weentaba ze-Lebombo ngendlela ye-[[Olifants Gorge]]. Lapha ke, umlambo lo sewubizwa ngokuthi yi ''-Rio dos Elefantes'', ngelimi lesi [[Portuguese]].  Ekugcineni kwayo ihlangana nomlambo i-Limpopo eselelwe makhilomitha ama-40km bonyana ingene elwandle i-Indian Ocean e-Xai-Xai etlhagwini ye-[[Maputo]].

=== Imithombo lwazi ===
&lt;references /&gt;</text>
      <sha1>24dciegh6ymsyapamp8s9ywrejoeyng</sha1>
    </revision>
    <revision>
      <id>5613</id>
      <parentid>5551</parentid>
      <timestamp>2025-09-04T10:39:04Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <comment>Added picture to the article</comment>
      <origin>5613</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1625" sha1="e12u80v3r4eaaa4kfxtlcu7kbopo5ha" xml:space="preserve">Page 1:  Draft space 1
----
[[Isimumathi:Olifants River at Dusk (2393448250).jpg|thumb|Isithombe somalmbo we-Olifants eMpumalanga]]
Umlambo i-Olifants (begodu laziwa nge Lepelle)&lt;ref&gt;{{Cite web |title=Kruger Park Times - Olifants River now called Lepelle |url=https://www.krugerpark.co.za/krugerpark-times-2-15-olifants-river-lepelle-20557.html |access-date=2025-09-04 |website=www.krugerpark.co.za}}&lt;/ref&gt; uthoma phakathi kweendawo i-Breyten ne-Bethal, [[Isifunda seMpumalanga|esifundeni se-Mpumalanga]].  

=== Umlando womlambo ===
Umlambo lo ugelezela tjhuba langetlhagwini ukuya [[Limpopo|esifundeni seLimpopo]] ngokudlula e-Witbank Dam, begodu idlule nase Loskop Dam.&lt;ref&gt;{{Cite web|title=Kruger Park Times - Olifants River now called Lepelle|url=https://www.krugerpark.co.za/krugerpark-times-2-15-olifants-river-lepelle-20557.html|access-date=2025-09-04|website=www.krugerpark.co.za}}&lt;/ref&gt; Kusukela lapho, ikatelelwa ziintaba ze Transvaal Drankensberg bonyana itjhinge ngepumalanga yeLimpopo. Sele useLimpopo, udlula e-Abel Erasmus Pass bese ugelezela ngepumalanga uyokudlula i-Lowveld (esehleni) lapha uyokuhlangana khona nomlambo i-Letaba. Nawusuka lapho, umlambo lo ukhamba utjhinge esifundeni se-Gaza, [[Mozambique|ese-Mozambique]]. ngemva kokuba namajikajika ngonobangela weentaba ze-Lebombo ngendlela ye-[[Olifants Gorge]]. Lapha ke, umlambo lo sewubizwa ngokuthi yi ''-Rio dos Elefantes'', ngelimi lesi [[Portuguese]].  Ekugcineni kwayo ihlangana nomlambo i-Limpopo eselelwe makhilomitha ama-40km bonyana ingene elwandle i-Indian Ocean e-Xai-Xai etlhagwini ye-[[Maputo]].

=== Imithombo lwazi ===
&lt;references /&gt;</text>
      <sha1>e12u80v3r4eaaa4kfxtlcu7kbopo5ha</sha1>
    </revision>
    <revision>
      <id>5620</id>
      <parentid>5613</parentid>
      <timestamp>2025-09-04T10:40:31Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <origin>5620</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1521" sha1="dsnzpllyp698r0vdyz5bubeo9kwtzw7" xml:space="preserve">Page 1:  Draft space 1
----
Umlambo i-Olifants (begodu laziwa nge Lepelle)&lt;ref&gt;{{Cite web |title=Kruger Park Times - Olifants River now called Lepelle |url=https://www.krugerpark.co.za/krugerpark-times-2-15-olifants-river-lepelle-20557.html |access-date=2025-09-04 |website=www.krugerpark.co.za}}&lt;/ref&gt; uthoma phakathi kweendawo i-Breyten ne-Bethal, [[Isifunda seMpumalanga|esifundeni se-Mpumalanga]].  

=== Umlando womlambo ===
Umlambo lo ugelezela tjhuba langetlhagwini ukuya [[Limpopo|esifundeni seLimpopo]] ngokudlula e-Witbank Dam, begodu idlule nase Loskop Dam.&lt;ref&gt;{{Cite web|title=Kruger Park Times - Olifants River now called Lepelle|url=https://www.krugerpark.co.za/krugerpark-times-2-15-olifants-river-lepelle-20557.html|access-date=2025-09-04|website=www.krugerpark.co.za}}&lt;/ref&gt; Kusukela lapho, ikatelelwa ziintaba ze Transvaal Drankensberg bonyana itjhinge ngepumalanga yeLimpopo. Sele useLimpopo, udlula e-Abel Erasmus Pass bese ugelezela ngepumalanga uyokudlula i-Lowveld (esehleni) lapha uyokuhlangana khona nomlambo i-Letaba. Nawusuka lapho, umlambo lo ukhamba utjhinge esifundeni se-Gaza, [[Mozambique|ese-Mozambique]]. ngemva kokuba namajikajika ngonobangela weentaba ze-Lebombo ngendlela ye-[[Olifants Gorge]]. Lapha ke, umlambo lo sewubizwa ngokuthi yi ''-Rio dos Elefantes'', ngelimi lesi [[Portuguese]].  Ekugcineni kwayo ihlangana nomlambo i-Limpopo eselelwe makhilomitha ama-40km bonyana ingene elwandle i-Indian Ocean e-Xai-Xai etlhagwini ye-[[Maputo]].

=== Imithombo lwazi ===
&lt;references /&gt;</text>
      <sha1>dsnzpllyp698r0vdyz5bubeo9kwtzw7</sha1>
    </revision>
    <revision>
      <id>5627</id>
      <parentid>5620</parentid>
      <timestamp>2025-09-04T10:43:04Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <comment>Inserted a picture</comment>
      <origin>5627</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1625" sha1="e12u80v3r4eaaa4kfxtlcu7kbopo5ha" xml:space="preserve">Page 1:  Draft space 1
----
[[Isimumathi:Olifants River at Dusk (2393448250).jpg|thumb|Isithombe somalmbo we-Olifants eMpumalanga]]
Umlambo i-Olifants (begodu laziwa nge Lepelle)&lt;ref&gt;{{Cite web |title=Kruger Park Times - Olifants River now called Lepelle |url=https://www.krugerpark.co.za/krugerpark-times-2-15-olifants-river-lepelle-20557.html |access-date=2025-09-04 |website=www.krugerpark.co.za}}&lt;/ref&gt; uthoma phakathi kweendawo i-Breyten ne-Bethal, [[Isifunda seMpumalanga|esifundeni se-Mpumalanga]].  

=== Umlando womlambo ===
Umlambo lo ugelezela tjhuba langetlhagwini ukuya [[Limpopo|esifundeni seLimpopo]] ngokudlula e-Witbank Dam, begodu idlule nase Loskop Dam.&lt;ref&gt;{{Cite web|title=Kruger Park Times - Olifants River now called Lepelle|url=https://www.krugerpark.co.za/krugerpark-times-2-15-olifants-river-lepelle-20557.html|access-date=2025-09-04|website=www.krugerpark.co.za}}&lt;/ref&gt; Kusukela lapho, ikatelelwa ziintaba ze Transvaal Drankensberg bonyana itjhinge ngepumalanga yeLimpopo. Sele useLimpopo, udlula e-Abel Erasmus Pass bese ugelezela ngepumalanga uyokudlula i-Lowveld (esehleni) lapha uyokuhlangana khona nomlambo i-Letaba. Nawusuka lapho, umlambo lo ukhamba utjhinge esifundeni se-Gaza, [[Mozambique|ese-Mozambique]]. ngemva kokuba namajikajika ngonobangela weentaba ze-Lebombo ngendlela ye-[[Olifants Gorge]]. Lapha ke, umlambo lo sewubizwa ngokuthi yi ''-Rio dos Elefantes'', ngelimi lesi [[Portuguese]].  Ekugcineni kwayo ihlangana nomlambo i-Limpopo eselelwe makhilomitha ama-40km bonyana ingene elwandle i-Indian Ocean e-Xai-Xai etlhagwini ye-[[Maputo]].

=== Imithombo lwazi ===
&lt;references /&gt;</text>
      <sha1>e12u80v3r4eaaa4kfxtlcu7kbopo5ha</sha1>
    </revision>
    <revision>
      <id>5682</id>
      <parentid>5627</parentid>
      <timestamp>2025-09-04T11:34:39Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <comment>Replaced content with &quot;Page 1:  Draft space 1 ----&quot;</comment>
      <origin>5682</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="27" sha1="gjzlwy7ekziequqtca4lvmw8iscxvuq" xml:space="preserve">Page 1:  Draft space 1
----</text>
      <sha1>gjzlwy7ekziequqtca4lvmw8iscxvuq</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:MahlanguLucky23/Page 1</title>
    <ns>2</ns>
    <id>813</id>
    <revision>
      <id>5316</id>
      <timestamp>2025-09-03T10:17:51Z</timestamp>
      <contributor>
        <username>MahlanguLucky23</username>
        <id>876</id>
      </contributor>
      <comment>created sub page 1</comment>
      <origin>5316</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="20" sha1="f01fhqizy6udynq520459t3r1u0ghj5" xml:space="preserve">Page 1:Draft space 1</text>
      <sha1>f01fhqizy6udynq520459t3r1u0ghj5</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Mannroy/Page 1</title>
    <ns>2</ns>
    <id>814</id>
    <revision>
      <id>5317</id>
      <timestamp>2025-09-03T10:17:52Z</timestamp>
      <contributor>
        <username>Mannroy</username>
        <id>879</id>
      </contributor>
      <comment>Created sub page 1</comment>
      <origin>5317</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="21" sha1="pch87y1k6hovfegi0kuhokbawmoj8oz" xml:space="preserve">Page 1: Draft space 1</text>
      <sha1>pch87y1k6hovfegi0kuhokbawmoj8oz</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:2000Gp01/Page 1</title>
    <ns>2</ns>
    <id>815</id>
    <revision>
      <id>5318</id>
      <timestamp>2025-09-03T10:17:52Z</timestamp>
      <contributor>
        <username>2000Gp01</username>
        <id>880</id>
      </contributor>
      <comment>created sub page 1</comment>
      <origin>5318</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="23" sha1="doivssrsormm3hww7rfg9dm479qe3et" xml:space="preserve">Page 1:   Draft space 1</text>
      <sha1>doivssrsormm3hww7rfg9dm479qe3et</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Nothi2003/Page 1</title>
    <ns>2</ns>
    <id>816</id>
    <revision>
      <id>5319</id>
      <timestamp>2025-09-03T10:17:53Z</timestamp>
      <contributor>
        <username>Nothi2003</username>
        <id>833</id>
      </contributor>
      <comment>created sub-page 1</comment>
      <origin>5319</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="21" sha1="2z9ncrivqyskfwvfssnegqmegx09wet" xml:space="preserve">Page 1; Draft space 1</text>
      <sha1>2z9ncrivqyskfwvfssnegqmegx09wet</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:NASKHOSANA/Page 1</title>
    <ns>2</ns>
    <id>817</id>
    <revision>
      <id>5320</id>
      <timestamp>2025-09-03T10:17:54Z</timestamp>
      <contributor>
        <username>NASKHOSANA</username>
        <id>884</id>
      </contributor>
      <comment>created sub page 1</comment>
      <origin>5320</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="22" sha1="knogjfzraf0nzjynff4ab297dg4qzlm" xml:space="preserve">Page 1 : Draft space 1</text>
      <sha1>knogjfzraf0nzjynff4ab297dg4qzlm</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Nomhle R/Page 1</title>
    <ns>2</ns>
    <id>818</id>
    <revision>
      <id>5321</id>
      <timestamp>2025-09-03T10:17:54Z</timestamp>
      <contributor>
        <username>Nomhle R</username>
        <id>799</id>
      </contributor>
      <comment>created sub -page 1</comment>
      <origin>5321</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="21" sha1="sff752jsrwdsx24a36pfxfcwhowyqcb" xml:space="preserve">page :1 draft space 1</text>
      <sha1>sff752jsrwdsx24a36pfxfcwhowyqcb</sha1>
    </revision>
    <revision>
      <id>5440</id>
      <parentid>5321</parentid>
      <timestamp>2025-09-04T07:48:40Z</timestamp>
      <contributor>
        <username>Nomhle R</username>
        <id>799</id>
      </contributor>
      <minor />
      <comment>ngifake umthombo lwazi</comment>
      <origin>5440</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="45" sha1="jvhjsbzxu0j7o5gzwrbvm466s6msld0" xml:space="preserve">page :1 draft space 1

=== umthombo lwazi ===</text>
      <sha1>jvhjsbzxu0j7o5gzwrbvm466s6msld0</sha1>
    </revision>
    <revision>
      <id>5512</id>
      <parentid>5440</parentid>
      <timestamp>2025-09-04T09:17:14Z</timestamp>
      <contributor>
        <username>Nomhle R</username>
        <id>799</id>
      </contributor>
      <minor />
      <comment>what is bullying</comment>
      <origin>5512</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="720" sha1="dlfzldl6vtl6i5y00g9fcwzjqsrllcn" xml:space="preserve">page :1 draft space 1

== ukutlhorisa/ ukutlhoriswa ngeenkolweni ==
ukutlhorisa nofana ukutlhoriswa ngeenolweni kulokha nawufunyana omunye umntwana ahlukumeza omunye umntwana ngokumbetha ngezandlanofana ngesikhali, ukusabalalisa iindaba ezilimelako namkhana eziyifihlo ngomunye umntwna wesikolo, ukuhlukumeza omunye emoyeni begodu nokubandlulula omunye umntwana bona azibandakanye anabane abentwana ngesikhathi sesikolo&lt;ref&gt;Kallman, J., Han, J. and Vanderbilt, D.L., 2021. What is bullying?. ''Clinics in Integrated Care'', ''5'', p.100046.&lt;/ref&gt;.

=== Unobangela wokutlhorisa nofana ukutlhoriswa ngeenkolweni. ===

=== imithelela yokutlhorisa nofana ukutlhoriswa ngeenkolweni. ===

=== umthombo lwazi ===
&lt;references /&gt;</text>
      <sha1>dlfzldl6vtl6i5y00g9fcwzjqsrllcn</sha1>
    </revision>
    <revision>
      <id>5560</id>
      <parentid>5512</parentid>
      <timestamp>2025-09-04T09:43:40Z</timestamp>
      <contributor>
        <username>Nomhle R</username>
        <id>799</id>
      </contributor>
      <comment>linkked ukutlhoswa</comment>
      <origin>5560</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="842" sha1="5ylema76tdk3fjaq3401h0zewwpf0nm" xml:space="preserve">page :1 draft space 1

ukutlhorisa/ ukutlhoriswa 


khuyini ukutlhorisa nofana ukutlhorisa


[[Ukutlhoriswa kwabantu bengubo eSewula Afrika|ukutlhorisa]] nofana ukutlhoriswa ngeenolweni kulokha nawufunyana omunye umntwana ahlukumeza omunye umntwana ngokumbetha ngezandlanofana ngesikhali, ukusabalalisa iindaba ezilimelako namkhana eziyifihlo ngomunye umntwna wesikolo, ukuhlukumeza omunye emoyeni begodu nokubandlulula omunye umntwana bona azibandakanye anabane abentwana ngesikhathi sesikolo&lt;ref&gt;Kallman, J., Han, J. and Vanderbilt, D.L., 2021. What is bullying?. ''Clinics in Integrated Care'', ''5'', p.100046.&lt;/ref&gt;

=== Unobangela wokutlhorisa nofana ukutlhoriswa ngeenkolweni. ===
ukubhoviselana ngamandla ngomunye wabonobangela 

=== imithelela yokutlhorisa nofana ukutlhoriswa ngeenkolweni. ===

=== umthombo lwazi ===
&lt;references /&gt;</text>
      <sha1>5ylema76tdk3fjaq3401h0zewwpf0nm</sha1>
    </revision>
    <revision>
      <id>5567</id>
      <parentid>5560</parentid>
      <timestamp>2025-09-04T09:47:37Z</timestamp>
      <contributor>
        <username>Nomhle R</username>
        <id>799</id>
      </contributor>
      <comment>/* Unobangela wokutlhorisa nofana ukutlhoriswa ngeenkolweni. */</comment>
      <origin>5567</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="901" sha1="rfcjzo1vsot20v1m8gz4k0gg8vlekq6" xml:space="preserve">page :1 draft space 1

ukutlhorisa/ ukutlhoriswa 


khuyini ukutlhorisa nofana ukutlhorisa


[[Ukutlhoriswa kwabantu bengubo eSewula Afrika|ukutlhorisa]] nofana ukutlhoriswa ngeenolweni kulokha nawufunyana omunye umntwana ahlukumeza omunye umntwana ngokumbetha ngezandlanofana ngesikhali, ukusabalalisa iindaba ezilimelako namkhana eziyifihlo ngomunye umntwna wesikolo, ukuhlukumeza omunye emoyeni begodu nokubandlulula omunye umntwana bona azibandakanye anabane abentwana ngesikhathi sesikolo&lt;ref&gt;Kallman, J., Han, J. and Vanderbilt, D.L., 2021. What is bullying?. ''Clinics in Integrated Care'', ''5'', p.100046.&lt;/ref&gt;

=== Unobangela wokutlhorisa nofana ukutlhoriswa ngeenkolweni. ===
ukubhoviselana ngamandla ngomunye wabonobangela wokutlhorisana ngeengolweni. ufunyana lokha omunye umntwan 

=== imithelela yokutlhorisa nofana ukutlhoriswa ngeenkolweni. ===

=== umthombo lwazi ===
&lt;references /&gt;</text>
      <sha1>rfcjzo1vsot20v1m8gz4k0gg8vlekq6</sha1>
    </revision>
    <revision>
      <id>5617</id>
      <parentid>5567</parentid>
      <timestamp>2025-09-04T10:39:22Z</timestamp>
      <contributor>
        <username>Nomhle R</username>
        <id>799</id>
      </contributor>
      <comment>added a picture</comment>
      <origin>5617</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1030" sha1="aiumzqkkfuvfz8l6b3kyf4tp62alqmr" xml:space="preserve">page :1 draft space 1
[[Isimumathi:Bullying on Instituto Regional Federico Errázuriz (IRFE) in March 5, 2007.jpg|thumb|isithombe sokuhlukunyezwa ]]  

ukutlhorisa/ ukutlhoriswa 


khuyini ukutlhorisa nofana ukutlhorisa


[[Ukutlhoriswa kwabantu bengubo eSewula Afrika|ukutlhorisa]] nofana ukutlhoriswa ngeenolweni kulokha nawufunyana omunye umntwana ahlukumeza omunye umntwana ngokumbetha ngezandlanofana ngesikhali, ukusabalalisa iindaba ezilimelako namkhana eziyifihlo ngomunye umntwna wesikolo, ukuhlukumeza omunye emoyeni begodu nokubandlulula omunye umntwana bona azibandakanye anabane abentwana ngesikhathi sesikolo&lt;ref&gt;Kallman, J., Han, J. and Vanderbilt, D.L., 2021. What is bullying?. ''Clinics in Integrated Care'', ''5'', p.100046.&lt;/ref&gt;

=== Unobangela wokutlhorisa nofana ukutlhoriswa ngeenkolweni. ===
ukubhoviselana ngamandla ngomunye wabonobangela wokutlhorisana ngeengolweni. ufunyana lokha omunye umntwan 

=== imithelela yokutlhorisa nofana ukutlhoriswa ngeenkolweni. ===

=== umthombo lwazi ===
&lt;references /&gt;</text>
      <sha1>aiumzqkkfuvfz8l6b3kyf4tp62alqmr</sha1>
    </revision>
    <revision>
      <id>5685</id>
      <parentid>5617</parentid>
      <timestamp>2025-09-04T11:36:46Z</timestamp>
      <contributor>
        <username>Nomhle R</username>
        <id>799</id>
      </contributor>
      <comment>khuyini ukutlhoriswa ngeenkolweni</comment>
      <origin>5685</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="779" sha1="ndqcxdby1yalnh3m6zqfbf27gc1sv83" xml:space="preserve">page :1 draft space 1
[[Isimumathi:Bullying on Instituto Regional Federico Errázuriz (IRFE) in March 5, 2007.jpg|thumb|isithombe sokuhlukunyezwa ]]

=== ukutlhorisa/ ukutlhoriswa ===

===  khuyini ukutlhorisa nofana ukutlhoriswa ===


[[Ukutlhoriswa kwabantu bengubo eSewula Afrika|ukutlhorisa]] nofana ukutlhoriswa ngeenolweni kulokha nawufunyana omunye umntwana ahlukumeza omunye umntwana ngokumbetha ngezandlanofana ngesikhali, ukusabalalisa iindaba ezilimelako namkhana eziyifihlo ngomunye umntwna wesikolo, ukuhlukumeza omunye emoyeni begodu nokubandlulula omunye umntwana bona azibandakanye anabane abentwana ngesikhathi sesikolo&lt;ref&gt;Kallman, J., Han, J. and Vanderbilt, D.L., 2021. What is bullying?. ''Clinics in Integrated Care'', ''5'', p.100046.&lt;/ref&gt;

&lt;references /&gt;</text>
      <sha1>ndqcxdby1yalnh3m6zqfbf27gc1sv83</sha1>
    </revision>
    <revision>
      <id>5797</id>
      <parentid>5685</parentid>
      <timestamp>2025-09-24T19:54:57Z</timestamp>
      <contributor>
        <username>Nomhle R</username>
        <id>799</id>
      </contributor>
      <minor />
      <comment>unobangela wokutlhorissana ngeenkolweni</comment>
      <origin>5797</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2635" sha1="0mf2jx07t6uamr9hod0vm4ebefuwkpn" xml:space="preserve">page :1 draft space 1
[[Isimumathi:Bullying on Instituto Regional Federico Errázuriz (IRFE) in March 5, 2007.jpg|thumb|isithombe sokuhlukunyezwa ]]

=== Ukutlhorisa/ ukutlhoriswa ===

===  Khuyini ukutlhorisa nofana ukutlhoriswa. ===


[[Ukutlhoriswa kwabantu bengubo eSewula Afrika|ukutlhorisa]] nofana ukutlhoriswa ngeenolweni kulokha nawufunyana omunye umntwana ahlukumeza omunye umntwana ngokumbetha ngezandlanofana ngesikhali, ukusabalalisa iindaba ezilumelako begodu eziyifihlo ngomunye umntwna wesikolo, ukuhlukumeza omunye emoyeni begodu nokubandlulula omunye umntwaa lokha nakafuna ukuzibandakanya nabenye abentwana ngesikhathi sesikolo.&lt;ref&gt;Kallman, J., Han, J. and Vanderbilt, D.L., 2021. What is bullying?. ''Clinics in Integrated Care'', ''5'', p.100046.&lt;/ref&gt;

=== Unobangela wokutlhorisa nofana ukutlhoriswa ngeenkolweni.Umntwana obuya emndenini lapho ukutlhorisa nofana ukutlhoriswa kulisiko lalapho, esikhathini esinengi uzifunyaya naye sele afuna ukulingisa lokhu akubonako ngendlini kwabanye abentwana. ===

# Ibhoduluko lesikolo. ibhoduluko lesikolo lapho ukutlhoriswa kwabantwana kungathathelwa ehloko namkhana amagadando linomthelela omukhulu. lokhu kwenzeka lokha abafundisi bakuleso sikolo bangathathi amagadango angakhandela bona ukutlhorisa nofan ukutlhoriswanofana ukutlhorisa kungenzeki nangelinye ilanga.
# inkundla zokuthintana 
#
# '''Peer Influence''': Bullying often occurs within peer groups, where the presence of bystanders can either condone or discourage bullying behavior. Children may bully to gain social status or acceptance among their peers. 
# '''School Climate''': The overall environment of a school plays a significant role in bullying. Schools with a negative climate, where bullying is tolerated or ignored by staff, can see higher rates of bullying behavior. Conversely, a positive school culture can reduce bullying incidents. 
# '''Psychological Factors''': Jealousy, envy, and low self-esteem can trigger bullying behavior. Children who struggle academically or socially may resort to bullying as a way to cope with their frustrations. 
# '''Media Influence''': Exposure to violence in media can desensitize children and normalize aggressive behavior, contributing to bullying tendencies. 
# '''Lack of Moral and Social Education''': Insufficient education on empathy, conflict resolution, and social skills can lead to misunderstandings and aggressive interactions among students. 
# 4 Sources

=== Conclusion ===
Understanding the causes of bullying is crucial for developing effective interventions. Addressing these factors requires a collaborative effort from

&lt;references /&gt;</text>
      <sha1>0mf2jx07t6uamr9hod0vm4ebefuwkpn</sha1>
    </revision>
    <revision>
      <id>5945</id>
      <parentid>5797</parentid>
      <timestamp>2025-11-05T11:12:05Z</timestamp>
      <contributor>
        <username>Nomhle R</username>
        <id>799</id>
      </contributor>
      <minor />
      <comment>unobangele wokutlhorisana eenkolweni</comment>
      <origin>5945</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1887" sha1="r3ivywebwbgbbhmjimfbkh5ag6amwpx" xml:space="preserve">page :1 draft space 1
[[Isimumathi:Bullying on Instituto Regional Federico Errázuriz (IRFE) in March 5, 2007.jpg|thumb|isithombe sokuhlukunyezwa ]]

=== ukutlhorisa/ ukutlhoriswa ngeenkolweni. ===


khuyini ukutlhorisa nofana ukutlhorisa


[[Ukutlhoriswa kwabantu bengubo eSewula Afrika|ukutlhorisa]] nofana ukutlhoriswa ngeenolweni kulokha nawufunyana omunye umntwana ahlukumeza omunye umntwana ngokumbetha ngezandlanofana ngesikhali, ukusabalalisa iindaba ezilimelako namkhana eziyifihlo ngomunye umntwna wesikolo, ukuhlukumeza omunye emoyeni begodu nokubandlulula omunye umntwana bona azibandakanye anabane abentwana ngesikhathi sesikolo&lt;ref&gt;Kallman, J., Han, J. and Vanderbilt, D.L., 2021. What is bullying?. ''Clinics in Integrated Care'', ''5'', p.100046.&lt;/ref&gt;

=== Unobangela wokutlhorisa nofana ukutlhoriswa ngeenkolweni. ===
Abentwana abekhulela ebhodulukweni lapho ukutlhoriswa namkhana ukutlhorisana kulisoko lalapho, esikhathini esinengi kuvamile bonyana batlhorise abanye abentwana. Lokhu bakwenza ngombana balingisa lokhu ebakubonako namkhana balingisela abantu abahlalanabo ngendlini. Kwesinye isikhathi balingisela imikwha abayifunda ebanganini babo ebadlala nabo.Iinkundla zokuthintana nazo zinomthelela omumbi ekuthuthukisa ukutlhoriswa nofana ukutlhorisa ngeenkolweni. Abentwana balingisela lokhu abekubona ngeenkundleni zokuthintana njenge facebook ne TickTock.Umfundi ohlukumeza abanye abentwana bese angajeziwa ngesenzo leso kubangela bona  abanye abentwana nabo batlhorise abanye abafundi ngombana angeze babenze litho. 

Abentwana abazizwa amandla kwamanye abentwana nofana abazwana nokubukwa esikhathini esinengi ngobo abatlhorisa abanye abafundi.bagabisela abanye abantwana ngamandla wabo.lokhu bakwenza ngombana bafuna ukuzizwa baneskhundla.Umntwana   

=== imithelela yokutlhorisa nofana ukutlhoriswa ngeenkolweni. ===

=== umthombo lwazi ===
&lt;references /&gt;</text>
      <sha1>r3ivywebwbgbbhmjimfbkh5ag6amwpx</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Pruddy01/Page 1</title>
    <ns>2</ns>
    <id>819</id>
    <revision>
      <id>5322</id>
      <timestamp>2025-09-03T10:17:54Z</timestamp>
      <contributor>
        <username>Pruddy01</username>
        <id>895</id>
      </contributor>
      <comment>Created sub page 1</comment>
      <origin>5322</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="22" sha1="hwmiw332bq71gkswwriny0ylkehr845" xml:space="preserve">Page 1:  Draft space 1</text>
      <sha1>hwmiw332bq71gkswwriny0ylkehr845</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:2003.Ma/Page1</title>
    <ns>2</ns>
    <id>820</id>
    <revision>
      <id>5323</id>
      <timestamp>2025-09-03T10:17:54Z</timestamp>
      <contributor>
        <username>2003.Ma</username>
        <id>882</id>
      </contributor>
      <comment>crated sub page 1</comment>
      <origin>5323</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="15" sha1="0girjckjibpoypwq3bdg494mls7q3sf" xml:space="preserve">Page 1: draft 1</text>
      <sha1>0girjckjibpoypwq3bdg494mls7q3sf</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:White Edits/Page 1</title>
    <ns>2</ns>
    <id>821</id>
    <revision>
      <id>5324</id>
      <timestamp>2025-09-03T10:17:57Z</timestamp>
      <contributor>
        <username>White Edits</username>
        <id>894</id>
      </contributor>
      <comment>created sub page 1</comment>
      <origin>5324</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="22" sha1="knogjfzraf0nzjynff4ab297dg4qzlm" xml:space="preserve">Page 1 : Draft space 1</text>
      <sha1>knogjfzraf0nzjynff4ab297dg4qzlm</sha1>
    </revision>
    <revision>
      <id>5412</id>
      <parentid>5324</parentid>
      <timestamp>2025-09-03T18:54:44Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <origin>5412</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3239" sha1="1cm4ipwv9evcidq6q660pbxy8xwwuvm" xml:space="preserve">Page 1 : Draft space 1
----



Ukusebenza Kwezemakethe Nokurhwebelana.

Imakethe nokurhwebelana yizinto ezibaluleke khulu kwezomnotho, zidlala indima ekulu ekwabelaneni kwensenjenziswa kanye nokusatshalaliswa kwepahla eyisizo khulu enarheni mazombe. Imakethe yindawo lapho abathengi nabathengisi bahlangana khona ukuze batjhentjhisane ngepahla neensetjenziswa zemphakathini, bese kuthi ukurhwebelana kube yisenzo sokuthenga nokuthengisa leyo pahla neensetjenziswa.

Imihlobo yemakethe esinayo.

Kukhona imihlobo ehlukeneko yemakethe, efaka hlangana:

1. Iphikiswano ephelele (Perfect Competition): Lomhlobo wemakethe kulapho kunabathengi nabathengisi abanengi, ukungena nokuphuma okulula, kanye nelwazi eliphelele (Smith, 1776).

2. Ukunqoba (Monopoly): Lomhlobo wemakethe kulapho ikhampani eyodwa kwaphela ikhiqiza imikhiqizo nofana iinsetjenziswa ezithileko enikela ngazo kumakethe.(Marshall, 1890).

3. Ukubumbana kwamakhampani ambalwa (Oligopoly): Lomhlobo wemakethe kulapho amakhampani ambalwa abusa khona begodu aphikisana ngokunikela kumakethe(Chamberlin, 1933).


Iindlela Zokurhwebelana( Trading Mechanisms)

Iindlela zokurhwebelana zifaka hlangana imigomo nemibandela elawula ukuthenga nokuthengisa epahleni neensetjenziswa  kumakethe. Lezi iindlela zingaba:

1. Ukurhwebelana Ngokuzwisisana (Auction-based trading): Lomhlobo yindlela lapho abathengi nabathengisi bafaka amanani wabo, iintengo zibekwa ngendlela yokuhlangabezana kwesidingo nokunikelwa ngepahla nanyana iinsetjenziswa ezithize kumakethe (Milgrom, 2004).

2. Ukurwebelana Ngaphandle kokuzwisisana (Quote-driven trading):Lomhlobo yindlela lapho abenzi bemakethe banikeza amanani wokuthenga nokuthengisa, abathengi bangakhetha ukuwamukela nofana ukuwalandula (Hasbrouck, 2007).

Ukusebenza Kwemakethe (Market Efficiency)

Ukusebenza kwemakethe kutjho ikghono lemakethe lokubonisa loke ilwazi elokhona eentengweni. Kune mihlobo emithathu yokusebenza kwemakethe:

1. Ifomu Elibuthakathaka (Weak form efficiency): Iintengo zibonisa loke ilwazi lamanani adlulileko (Fama, 1970).

2.Ifomu Eliphakathi (Semi-strong form efficiency): Iintengo zikhombisa loke ilwazi elikhona emphakathini (Fama, 1970).

3. Ifomu Elinamandla (Strong form efficiency): Iintengo zikhombisa loke ilwazi, kungaba ngelikhona emphakathini nofana elifihlakeleko (Fama, 1970).

Imakethe bokurhwebelana kuyizinto ezinganakuthembeka begodu ezitjhugulukako mihla namalanga ezidlala indima ekulu ekwabelaneni kweensetjenziswa nekusatshalalisweni kwepahla neensetjensiza. Ukulemula iminhlobo ehlukeneko yemakethe, iindlela zokurhwebelana, nokusebenza kwemakethe kubalulekile ekuthatheni iinqumo ezihlakaniphileko zokwandisa imali nokuzwisisa ubunzima bokwandisa umnotho esikhathini sanje.

Umthombo welwazi

Chamberlin, E. H. (1933). The Theory of Monopolistic Competition. Harvard University Press.  
Fama, E. F. (1970). Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance, 25(2), 383-417.  
Hasbrouck, J. (2007). Empirical Market Microstructure. Oxford University Press.  
Marshall, A. (1890). Principles of Economics. Macmillan.  
Milgrom, P. (2004). Putting Auction Theory to Work. Cambridge University Press.  
Smith, A. (1776). The Wealth of Nations. Penguin Books.</text>
      <sha1>1cm4ipwv9evcidq6q660pbxy8xwwuvm</sha1>
    </revision>
    <revision>
      <id>5474</id>
      <parentid>5412</parentid>
      <timestamp>2025-09-04T08:30:28Z</timestamp>
      <contributor>
        <username>White Edits</username>
        <id>894</id>
      </contributor>
      <origin>5474</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3298" sha1="3qtrf1j1c3907098t1gsjout710s6uf" xml:space="preserve">Page 1 : Draft space 1
----



== Ukusebenza Kwezemakethe Nokurhwebelana. ==
Imakethe nokurhwebelana yizinto ezibaluleke khulu kwezomnotho, zidlala indima ekulu ekwabelaneni kwensenjenziswa kanye nokusatshalaliswa kwepahla eyisizo khulu enarheni mazombe. Imakethe yindawo lapho abathengi nabathengisi bahlangana khona ukuze batjhentjhisane ngepahla neensetjenziswa zemphakathini, bese kuthi ukurhwebelana kube yisenzo sokuthenga nokuthengisa leyo pahla neensetjenziswa.

=== Imihlobo yemakethe esinayo. ===
Kukhona imihlobo ehlukeneko yemakethe, efaka hlangana:

1. Iphikiswano ephelele (Perfect Competition): Lomhlobo wemakethe kulapho kunabathengi nabathengisi abanengi, ukungena nokuphuma okulula, kanye nelwazi eliphelele (Smith, 1776).

2. Ukunqoba (Monopoly): Lomhlobo wemakethe kulapho ikhampani eyodwa kwaphela ikhiqiza imikhiqizo nofana iinsetjenziswa ezithileko enikela ngazo kumakethe.(Marshall, 1890).

3. Ukubumbana kwamakhampani ambalwa (Oligopoly): Lomhlobo wemakethe kulapho amakhampani ambalwa abusa khona begodu aphikisana ngokunikela kumakethe(Chamberlin, 1933).

====  Iindlela Zokurhwebelana( Trading Mechanisms) ====
Iindlela zokurhwebelana zifaka hlangana imigomo nemibandela elawula ukuthenga nokuthengisa epahleni neensetjenziswa  kumakethe. Lezi iindlela zingaba:

1. Ukurhwebelana Ngokuzwisisana (Auction-based trading): Lomhlobo yindlela lapho abathengi nabathengisi bafaka amanani wabo, iintengo zibekwa ngendlela yokuhlangabezana kwesidingo nokunikelwa ngepahla nanyana iinsetjenziswa ezithize kumakethe (Milgrom, 2004).

2. Ukurwebelana Ngaphandle kokuzwisisana (Quote-driven trading):Lomhlobo yindlela lapho abenzi bemakethe banikeza amanani wokuthenga nokuthengisa, abathengi bangakhetha ukuwamukela nofana ukuwalandula (Hasbrouck, 2007).

===== Ukusebenza Kwemakethe (Market Efficiency) =====
Ukusebenza kwemakethe kutjho ikghono lemakethe lokubonisa loke ilwazi elokhona eentengweni. Kune mihlobo emithathu yokusebenza kwemakethe:

1. Ifomu Elibuthakathaka (Weak form efficiency): Iintengo zibonisa loke ilwazi lamanani adlulileko (Fama, 1970).

2.Ifomu Eliphakathi (Semi-strong form efficiency): Iintengo zikhombisa loke ilwazi elikhona emphakathini (Fama, 1970).

3. Ifomu Elinamandla (Strong form efficiency): Iintengo zikhombisa loke ilwazi, kungaba ngelikhona emphakathini nofana elifihlakeleko (Fama, 1970).

Imakethe bokurhwebelana kuyizinto ezinganakuthembeka begodu ezitjhugulukako mihla namalanga ezidlala indima ekulu ekwabelaneni kweensetjenziswa nekusatshalalisweni kwepahla neensetjensiza. Ukulemula iminhlobo ehlukeneko yemakethe, iindlela zokurhwebelana, nokusebenza kwemakethe kubalulekile ekuthatheni iinqumo ezihlakaniphileko zokwandisa imali nokuzwisisa ubunzima bokwandisa umnotho esikhathini sanje.

====== Imithombo lwazi ======
Chamberlin, E. H. (1933). The Theory of Monopolistic Competition. Harvard University Press.  

Fama, E. F. (1970). Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance, 25(2), 383-417. 

Hasbrouck, J. (2007). Empirical Market Microstructure. Oxford University Press. 

Marshall, A. (1890). Principles of Economics. Macmillan.  
Milgrom, P. (2004). Putting Auction Theory to Work. Cambridge University Press.

Smith, A. (1776). The Wealth of Nations. Penguin Books.
&lt;references /&gt;</text>
      <sha1>3qtrf1j1c3907098t1gsjout710s6uf</sha1>
    </revision>
    <revision>
      <id>5481</id>
      <parentid>5474</parentid>
      <timestamp>2025-09-04T08:48:17Z</timestamp>
      <contributor>
        <username>White Edits</username>
        <id>894</id>
      </contributor>
      <origin>5481</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3432" sha1="8v8knyl03ib1kxgibwnwad52cv5hh13" xml:space="preserve">Page 1 : Draft space 1
----



== Ukusebenza Kwezemakethe Nokurhwebelana. ==
Imakethe nokurhwebelana yizinto ezibaluleke khulu kwezomnotho, zidlala indima ekulu ekwabelaneni kwensenjenziswa kanye nokusatshalaliswa kwepahla eyisizo khulu enarheni mazombe. Imakethe yindawo lapho abathengi nabathengisi bahlangana khona ukuze batjhentjhisane ngepahla neensetjenziswa zemphakathini, bese kuthi ukurhwebelana kube yisenzo sokuthenga nokuthengisa leyo pahla neensetjenziswa.

=== Imihlobo yemakethe esinayo. ===
Kukhona imihlobo ehlukeneko yemakethe, efaka hlangana:

1. Iphikiswano ephelele (Perfect Competition): Lomhlobo wemakethe kulapho kunabathengi nabathengisi abanengi, ukungena nokuphuma okulula, kanye nelwazi eliphelele (Smith, 1776).

2. Ukunqoba (Monopoly): Lomhlobo wemakethe kulapho ikhampani eyodwa kwaphela ikhiqiza imikhiqizo nofana iinsetjenziswa ezithileko enikela ngazo kumakethe.(Marshall, 1890).

3. Ukubumbana kwamakhampani ambalwa (Oligopoly): Lomhlobo wemakethe kulapho amakhampani ambalwa abusa khona begodu aphikisana ngokunikela kumakethe.&lt;ref&gt;{{Cite book|last=Chamberlin|first=E. H|title=The Theory of Monopolistic Competition.|date=1993|publisher=Harvard University Press|year=1993}}&lt;/ref&gt;

====  Iindlela Zokurhwebelana( Trading Mechanisms) ====
Iindlela zokurhwebelana zifaka hlangana imigomo nemibandela elawula ukuthenga nokuthengisa epahleni neensetjenziswa  kumakethe. Lezi iindlela zingaba:

1. Ukurhwebelana Ngokuzwisisana (Auction-based trading): Lomhlobo yindlela lapho abathengi nabathengisi bafaka amanani wabo, iintengo zibekwa ngendlela yokuhlangabezana kwesidingo nokunikelwa ngepahla nanyana iinsetjenziswa ezithize kumakethe (Milgrom, 2004).

2. Ukurwebelana Ngaphandle kokuzwisisana (Quote-driven trading):Lomhlobo yindlela lapho abenzi bemakethe banikeza amanani wokuthenga nokuthengisa, abathengi bangakhetha ukuwamukela nofana ukuwalandula (Hasbrouck, 2007).

===== Ukusebenza Kwemakethe (Market Efficiency) =====
Ukusebenza kwemakethe kutjho ikghono lemakethe lokubonisa loke ilwazi elokhona eentengweni. Kune mihlobo emithathu yokusebenza kwemakethe:

1. Ifomu Elibuthakathaka (Weak form efficiency): Iintengo zibonisa loke ilwazi lamanani adlulileko (Fama, 1970).

2.Ifomu Eliphakathi (Semi-strong form efficiency): Iintengo zikhombisa loke ilwazi elikhona emphakathini (Fama, 1970).

3. Ifomu Elinamandla (Strong form efficiency): Iintengo zikhombisa loke ilwazi, kungaba ngelikhona emphakathini nofana elifihlakeleko (Fama, 1970).

Imakethe bokurhwebelana kuyizinto ezinganakuthembeka begodu ezitjhugulukako mihla namalanga ezidlala indima ekulu ekwabelaneni kweensetjenziswa nekusatshalalisweni kwepahla neensetjensiza. Ukulemula iminhlobo ehlukeneko yemakethe, iindlela zokurhwebelana, nokusebenza kwemakethe kubalulekile ekuthatheni iinqumo ezihlakaniphileko zokwandisa imali nokuzwisisa ubunzima bokwandisa umnotho esikhathini sanje.

====== Imithombo lwazi ======
Chamberlin, E. H. (1933). The Theory of Monopolistic Competition. Harvard University Press.  

Fama, E. F. (1970). Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance, 25(2), 383-417. 

Hasbrouck, J. (2007). Empirical Market Microstructure. Oxford University Press. 

Marshall, A. (1890). Principles of Economics. Macmillan.  
Milgrom, P. (2004). Putting Auction Theory to Work. Cambridge University Press.

Smith, A. (1776). The Wealth of Nations. Penguin Books.
&lt;references /&gt;</text>
      <sha1>8v8knyl03ib1kxgibwnwad52cv5hh13</sha1>
    </revision>
    <revision>
      <id>5484</id>
      <parentid>5481</parentid>
      <timestamp>2025-09-04T08:49:35Z</timestamp>
      <contributor>
        <username>White Edits</username>
        <id>894</id>
      </contributor>
      <origin>5484</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3431" sha1="1gtebtxkdi88mf4m08hye4s4iby8oxb" xml:space="preserve">Page 1 : Draft space 1
----



== Ukusebenza Kwezemakethe Nokurhwebelana. ==
Imakethe nokurhwebelana yizinto ezibaluleke khulu kwezomnotho, zidlala indima ekulu ekwabelaneni kwensenjenziswa kanye nokusatshalaliswa kwepahla eyisizo khulu enarheni mazombe. Imakethe yindawo lapho abathengi nabathengisi bahlangana khona ukuze batjhentjhisane ngepahla neensetjenziswa zemphakathini, bese kuthi ukurhwebelana kube yisenzo sokuthenga nokuthengisa leyo pahla neensetjenziswa.

=== Imihlobo yemakethe esinayo. ===
Kukhona imihlobo ehlukeneko yemakethe, efaka hlangana:

1. Iphikiswano ephelele (Perfect Competition): Lomhlobo wemakethe kulapho kunabathengi nabathengisi abanengi, ukungena nokuphuma okulula, kanye nelwazi eliphelele (Smith, 1776).

2. Ukunqoba (Monopoly): Lomhlobo wemakethe kulapho ikhampani eyodwa kwaphela ikhiqiza imikhiqizo nofana iinsetjenziswa ezithileko enikela ngazo kumakethe.(Marshall, 1890).

3. Ukubumbana kwamakhampani ambalwa (Oligopoly): Lomhlobo wemakethe kulapho amakhampani ambalwa abusa khona begodu aphikisana ngokunikela kumakethe.&lt;ref&gt;{{Cite book|last=Chamberlin|first=E. H|title=The Theory of Monopolistic Competition.|date=1993|publisher=Harvard University Press|year=1993}}&lt;/ref&gt;

====  Iindlela Zokurhwebelana( Trading Mechanisms) ====
Iindlela zokurhwebelana zifaka hlangana imigomo nemibandela elawula ukuthenga nokuthengisa epahleni neensetjenziswa  kumakethe. Lezi iindlela zingaba:

1. Ukurhwebelana Ngokuzwisisana (Auction-based trading): Lomhlobo yindlela lapho abathengi nabathengisi bafaka amanani wabo, iintengo zibekwa ngendlela yokuhlangabezana kwesidingo nokunikelwa ngepahla nanyana iinsetjenziswa ezithize kumakethe (Milgrom, 2004).

2. Ukurwebelana Ngaphandle kokuzwisisana (Quote-driven trading):Lomhlobo yindlela lapho abenzi bemakethe banikeza amanani wokuthenga nokuthengisa, abathengi bangakhetha ukuwamukela nofana ukuwalandula (Hasbrouck, 2007).

===== Ukusebenza Kwemakethe (Market Efficiency) =====
Ukusebenza kwemakethe kutjho ikghono lemakethe lokubonisa loke ilwazi elokhona eentengweni. Kune mihlobo emithathu yokusebenza kwemakethe:

1. Ifomu Elibuthakathaka (Weak form efficiency): Iintengo zibonisa loke ilwazi lamanani adlulileko (Fama, 1970).

2.Ifomu Eliphakathi (Semi-strong form efficiency): Iintengo zikhombisa loke ilwazi elikhona emphakathini (Fama, 1970).

3. Ifomu Elinamandla (Strong form efficiency): Iintengo zikhombisa loke ilwazi, kungaba ngelikhona emphakathini nofana elifihlakeleko (Fama, 1970).

Imakethe bokurhwebelana kuyizinto ezinganakuthembeka begodu ezitjhugulukako mihla namalanga ezidlala indima ekulu ekwabelaneni kweensetjenziswa nekusatshalalisweni kwepahla neensetjensiza. Ukulemula iminhlobo ehlukeneko yemakethe, iindlela zokurhwebelana, nokusebenza kwemakethe kubalulekile ekuthatheni iinqumo ezihlakaniphileko zokwandisa imali nokuzwisisa ubunzima bokwandisa umnotho esikhathini sanje.



Chamberlin, E. H. (1933). The Theory of Monopolistic Competition. Harvard University Press.

Fama, E. F. (1970). Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance, 25(2), 383-417. 

Hasbrouck, J. (2007). Empirical Market Microstructure. Oxford University Press. 

Marshall, A. (1890). Principles of Economics. Macmillan.  
Milgrom, P. (2004). Putting Auction Theory to Work. Cambridge University Press.

Smith, A. (1776). The Wealth of Nations. Penguin Books
====== Imithombo lwazi ======
&lt;references /&gt;</text>
      <sha1>1gtebtxkdi88mf4m08hye4s4iby8oxb</sha1>
    </revision>
    <revision>
      <id>5504</id>
      <parentid>5484</parentid>
      <timestamp>2025-09-04T09:10:35Z</timestamp>
      <contributor>
        <username>White Edits</username>
        <id>894</id>
      </contributor>
      <origin>5504</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3923" sha1="eons5joxtss6uccipya5hmhnmb112wi" xml:space="preserve">Page 1 : Draft space 1
----



== Ukusebenza Kwezemakethe Nokurhwebelana. ==
Imakethe nokurhwebelana yizinto ezibaluleke khulu kwezomnotho, zidlala indima ekulu ekwabelaneni kwensenjenziswa kanye nokusatshalaliswa kwepahla eyisizo khulu enarheni mazombe. Imakethe yindawo lapho abathengi nabathengisi bahlangana khona ukuze batjhentjhisane ngepahla neensetjenziswa zemphakathini, bese kuthi ukurhwebelana kube yisenzo sokuthenga nokuthengisa leyo pahla neensetjenziswa.

=== Imihlobo yemakethe esinayo. ===
Kukhona imihlobo ehlukeneko yemakethe, efaka hlangana:

1. Iphikiswano ephelele (Perfect Competition): Lomhlobo wemakethe kulapho kunabathengi nabathengisi abanengi, ukungena nokuphuma okulula, kanye nelwazi eliphelele (Smith, 1776).

2. Ukunqoba (Monopoly): Lomhlobo wemakethe kulapho ikhampani eyodwa kwaphela ikhiqiza imikhiqizo nofana iinsetjenziswa ezithileko enikela ngazo kumakethe.(Marshall, 1890).

3. Ukubumbana kwamakhampani ambalwa (Oligopoly): Lomhlobo wemakethe kulapho amakhampani ambalwa abusa khona begodu aphikisana ngokunikela kumakethe.&lt;ref&gt;{{Cite book|last=Chamberlin|first=E. H|title=The Theory of Monopolistic Competition.|date=1993|publisher=Harvard University Press|year=1993}}&lt;/ref&gt;

====  Iindlela Zokurhwebelana( Trading Mechanisms) ====
Iindlela zokurhwebelana zifaka hlangana imigomo nemibandela elawula ukuthenga nokuthengisa epahleni neensetjenziswa  kumakethe. Lezi iindlela zingaba:

1. Ukurhwebelana Ngokuzwisisana (Auction-based trading): Lomhlobo yindlela lapho abathengi nabathengisi bafaka amanani wabo, iintengo zibekwa ngendlela yokuhlangabezana kwesidingo nokunikelwa ngepahla nanyana iinsetjenziswa ezithize kumakethe (Milgrom, 2004).

2. Ukurwebelana Ngaphandle kokuzwisisana (Quote-driven trading):Lomhlobo yindlela lapho abenzi bemakethe banikeza amanani wokuthenga nokuthengisa, abathengi bangakhetha ukuwamukela nofana ukuwalandula (Hasbrouck, 2007).

===== Ukusebenza Kwemakethe (Market Efficiency) =====
Ukusebenza kwemakethe kutjho ikghono lemakethe lokubonisa loke ilwazi elokhona eentengweni. Kune mihlobo emithathu yokusebenza kwemakethe:

1. Ifomu Elibuthakathaka (Weak form efficiency): Iintengo zibonisa loke ilwazi lamanani adlulileko.&lt;ref&gt;{{Cite journal|last=Fama|first=E. F.|date=1970|title=Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance|journal=Journal of Finance}}&lt;/ref&gt;

2.Ifomu Eliphakathi (Semi-strong form efficiency): Iintengo zikhombisa loke ilwazi elikhona emphakathini.&lt;ref&gt;{{Cite journal|last=Fama|first=E. F.|date=1970|title=Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance|journal=Journal of Finance}}&lt;/ref&gt;

3. Ifomu Elinamandla (Strong form efficiency): Iintengo zikhombisa loke ilwazi, kungaba ngelikhona emphakathini nofana elifihlakeleko.&lt;ref&gt;{{Cite journal|last=Fama|first=E. F.|date=1970|title=Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance|journal=Journal of Finance}}&lt;/ref&gt;

Imakethe bokurhwebelana kuyizinto ezinganakuthembeka begodu ezitjhugulukako mihla namalanga ezidlala indima ekulu ekwabelaneni kweensetjenziswa nekusatshalalisweni kwepahla neensetjensiza. Ukulemula iminhlobo ehlukeneko yemakethe, iindlela zokurhwebelana, nokusebenza kwemakethe kubalulekile ekuthatheni iinqumo ezihlakaniphileko zokwandisa imali nokuzwisisa ubunzima bokwandisa umnotho esikhathini sanje.



Chamberlin, E. H. (1933). The Theory of Monopolistic Competition. Harvard University Press.

Fama, E. F. (1970). Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance, 25(2), 383-417. 

Hasbrouck, J. (2007). Empirical Market Microstructure. Oxford University Press. 

Marshall, A. (1890). Principles of Economics. Macmillan.  
Milgrom, P. (2004). Putting Auction Theory to Work. Cambridge University Press.

Smith, A. (1776). The Wealth of Nations. Penguin Books
====== Imithombo lwazi ======
&lt;references /&gt;</text>
      <sha1>eons5joxtss6uccipya5hmhnmb112wi</sha1>
    </revision>
    <revision>
      <id>5539</id>
      <parentid>5504</parentid>
      <timestamp>2025-09-04T09:28:57Z</timestamp>
      <contributor>
        <username>White Edits</username>
        <id>894</id>
      </contributor>
      <origin>5539</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4063" sha1="c8kuct4jbo370t4bcaj8p1k8bfkzmlq" xml:space="preserve">Page 1 : Draft space 1
----



== Ukusebenza Kwezemakethe Nokurhwebelana. ==
Imakethe nokurhwebelana yizinto ezibaluleke khulu kwezomnotho, zidlala indima ekulu ekwabelaneni kwensenjenziswa kanye nokusatshalaliswa kwepahla eyisizo khulu enarheni mazombe. Imakethe yindawo lapho abathengi nabathengisi bahlangana khona ukuze batjhentjhisane ngepahla neensetjenziswa zemphakathini, bese kuthi ukurhwebelana kube yisenzo sokuthenga nokuthengisa leyo pahla neensetjenziswa.

=== Imihlobo yemakethe esinayo. ===
Kukhona imihlobo ehlukeneko yemakethe, efaka hlangana:

1. Iphikiswano ephelele (Perfect Competition): Lomhlobo wemakethe kulapho kunabathengi nabathengisi abanengi, ukungena nokuphuma okulula, kanye nelwazi eliphelele (Smith, 1776).

2. Ukunqoba (Monopoly): Lomhlobo wemakethe kulapho ikhampani eyodwa kwaphela ikhiqiza imikhiqizo nofana iinsetjenziswa ezithileko enikela ngazo kumakethe.(Marshall, 1890).

3. Ukubumbana kwamakhampani ambalwa (Oligopoly): Lomhlobo wemakethe kulapho amakhampani ambalwa abusa khona begodu aphikisana ngokunikela kumakethe.&lt;ref&gt;{{Cite book|last=Chamberlin|first=E. H|title=The Theory of Monopolistic Competition.|date=1993|publisher=Harvard University Press|year=1993}}&lt;/ref&gt;

====  Iindlela Zokurhwebelana( Trading Mechanisms) ====
Iindlela zokurhwebelana zifaka hlangana imigomo nemibandela elawula ukuthenga nokuthengisa epahleni neensetjenziswa  kumakethe. Lezi iindlela zingaba:

1. Ukurhwebelana Ngokuzwisisana (Auction-based trading): Lomhlobo yindlela lapho abathengi nabathengisi bafaka amanani wabo, iintengo zibekwa ngendlela yokuhlangabezana kwesidingo nokunikelwa ngepahla nanyana iinsetjenziswa ezithize kumakethe (Milgrom, 2004).

2. Ukurwebelana Ngaphandle kokuzwisisana (Quote-driven trading):Lomhlobo yindlela lapho abenzi bemakethe banikeza amanani wokuthenga nokuthengisa, abathengi bangakhetha ukuwamukela nofana ukuwalandula.&lt;ref name=&quot;:0&quot;&gt;{{Cite book|last=Hasbrouck|first=Hasbrouck|title=Empirical Market Microstructure|date=2007|publisher=Oxford University Press.|year=2007}}&lt;/ref&gt;

===== Ukusebenza Kwemakethe (Market Efficiency) =====
Ukusebenza kwemakethe kutjho ikghono lemakethe lokubonisa loke ilwazi elokhona eentengweni. Kune mihlobo emithathu yokusebenza kwemakethe:

1. Ifomu Elibuthakathaka (Weak form efficiency): Iintengo zibonisa loke ilwazi lamanani adlulileko.&lt;ref&gt;{{Cite journal|last=Fama|first=E. F.|date=1970|title=Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance|journal=Journal of Finance}}&lt;/ref&gt;

2.Ifomu Eliphakathi (Semi-strong form efficiency): Iintengo zikhombisa loke ilwazi elikhona emphakathini.&lt;ref&gt;{{Cite journal|last=Fama|first=E. F.|date=1970|title=Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance|journal=Journal of Finance}}&lt;/ref&gt;

3. Ifomu Elinamandla (Strong form efficiency): Iintengo zikhombisa loke ilwazi, kungaba ngelikhona emphakathini nofana elifihlakeleko.&lt;ref&gt;{{Cite journal|last=Fama|first=E. F.|date=1970|title=Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance|journal=Journal of Finance}}&lt;/ref&gt;

Imakethe bokurhwebelana kuyizinto ezinganakuthembeka begodu ezitjhugulukako mihla namalanga ezidlala indima ekulu ekwabelaneni kweensetjenziswa nekusatshalalisweni kwepahla neensetjensiza. Ukulemula iminhlobo ehlukeneko yemakethe, iindlela zokurhwebelana, nokusebenza kwemakethe kubalulekile ekuthatheni iinqumo ezihlakaniphileko zokwandisa imali nokuzwisisa ubunzima bokwandisa umnotho esikhathini sanje.



Chamberlin, E. H. (1933). The Theory of Monopolistic Competition. Harvard University Press.

Fama, E. F. (1970). Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance, 25(2), 383-417. 

Hasbrouck, J. (2007). Empirical Market Microstructure. Oxford University Press. 

Marshall, A. (1890). Principles of Economics. Macmillan.  
Milgrom, P. (2004). Putting Auction Theory to Work. Cambridge University Press.

Smith, A. (1776). The Wealth of Nations. Penguin Books
====== Imithombo lwazi ======
&lt;references /&gt;</text>
      <sha1>c8kuct4jbo370t4bcaj8p1k8bfkzmlq</sha1>
    </revision>
    <revision>
      <id>5544</id>
      <parentid>5539</parentid>
      <timestamp>2025-09-04T09:34:18Z</timestamp>
      <contributor>
        <username>White Edits</username>
        <id>894</id>
      </contributor>
      <origin>5544</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4174" sha1="bqflevip82n4kh50wegpfs68izs4rem" xml:space="preserve">Page 1 : Draft space 1
----



== Ukusebenza Kwezemakethe Nokurhwebelana. ==
Imakethe nokurhwebelana yizinto ezibaluleke khulu kwezomnotho, zidlala indima ekulu ekwabelaneni kwensenjenziswa kanye nokusatshalaliswa kwepahla eyisizo khulu enarheni mazombe. Imakethe yindawo lapho abathengi nabathengisi bahlangana khona ukuze batjhentjhisane ngepahla neensetjenziswa zemphakathini, bese kuthi ukurhwebelana kube yisenzo sokuthenga nokuthengisa leyo pahla neensetjenziswa.

=== Imihlobo yemakethe esinayo. ===
Kukhona imihlobo ehlukeneko yemakethe, efaka hlangana:

1. Iphikiswano ephelele (Perfect Competition): Lomhlobo wemakethe kulapho kunabathengi nabathengisi abanengi, ukungena nokuphuma okulula, kanye nelwazi eliphelele (Smith, 1776).

2. Ukunqoba (Monopoly): Lomhlobo wemakethe kulapho ikhampani eyodwa kwaphela ikhiqiza imikhiqizo nofana iinsetjenziswa ezithileko enikela ngazo kumakethe.(Marshall, 1890).

3. Ukubumbana kwamakhampani ambalwa (Oligopoly): Lomhlobo wemakethe kulapho amakhampani ambalwa abusa khona begodu aphikisana ngokunikela kumakethe.&lt;ref&gt;{{Cite book|last=Chamberlin|first=E. H|title=The Theory of Monopolistic Competition.|date=1993|publisher=Harvard University Press|year=1993}}&lt;/ref&gt;

====  Iindlela Zokurhwebelana( Trading Mechanisms) ====
Iindlela zokurhwebelana zifaka hlangana imigomo nemibandela elawula ukuthenga nokuthengisa epahleni neensetjenziswa  kumakethe. Lezi iindlela zingaba:

1. Ukurhwebelana Ngokuzwisisana (Auction-based trading): Lomhlobo yindlela lapho abathengi nabathengisi bafaka amanani wabo, iintengo zibekwa ngendlela yokuhlangabezana kwesidingo nokunikelwa ngepahla nanyana iinsetjenziswa ezithize kumakethe..&lt;ref name=&quot;:1&quot;&gt;{{Cite book|last=Marshall|first=A|title=Principles of Economics|date=1990|publisher=Macmillan|year=1990}}&lt;/ref&gt;

2. Ukurwebelana Ngaphandle kokuzwisisana (Quote-driven trading):Lomhlobo yindlela lapho abenzi bemakethe banikeza amanani wokuthenga nokuthengisa, abathengi bangakhetha ukuwamukela nofana ukuwalandula.&lt;ref name=&quot;:0&quot;&gt;{{Cite book|last=Hasbrouck|first=Hasbrouck|title=Empirical Market Microstructure|date=2007|publisher=Oxford University Press.|year=2007}}&lt;/ref&gt;

===== Ukusebenza Kwemakethe (Market Efficiency) =====
Ukusebenza kwemakethe kutjho ikghono lemakethe lokubonisa loke ilwazi elokhona eentengweni. Kune mihlobo emithathu yokusebenza kwemakethe:

1. Ifomu Elibuthakathaka (Weak form efficiency): Iintengo zibonisa loke ilwazi lamanani adlulileko.&lt;ref&gt;{{Cite journal|last=Fama|first=E. F.|date=1970|title=Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance|journal=Journal of Finance}}&lt;/ref&gt;

2.Ifomu Eliphakathi (Semi-strong form efficiency): Iintengo zikhombisa loke ilwazi elikhona emphakathini.&lt;ref&gt;{{Cite journal|last=Fama|first=E. F.|date=1970|title=Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance|journal=Journal of Finance}}&lt;/ref&gt;

3. Ifomu Elinamandla (Strong form efficiency): Iintengo zikhombisa loke ilwazi, kungaba ngelikhona emphakathini nofana elifihlakeleko.&lt;ref&gt;{{Cite journal|last=Fama|first=E. F.|date=1970|title=Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance|journal=Journal of Finance}}&lt;/ref&gt;

Imakethe bokurhwebelana kuyizinto ezinganakuthembeka begodu ezitjhugulukako mihla namalanga ezidlala indima ekulu ekwabelaneni kweensetjenziswa nekusatshalalisweni kwepahla neensetjensiza. Ukulemula iminhlobo ehlukeneko yemakethe, iindlela zokurhwebelana, nokusebenza kwemakethe kubalulekile ekuthatheni iinqumo ezihlakaniphileko zokwandisa imali nokuzwisisa ubunzima bokwandisa umnotho esikhathini sanje.



Chamberlin, E. H. (1933). The Theory of Monopolistic Competition. Harvard University Press.

Fama, E. F. (1970). Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance, 25(2), 383-417. 

Hasbrouck, J. (2007). Empirical Market Microstructure. Oxford University Press. 

Marshall, A. (1890). Principles of Economics. Macmillan.  
Milgrom, P. (2004). Putting Auction Theory to Work. Cambridge University Press.

Smith, A. (1776). The Wealth of Nations. Penguin Books
====== Imithombo lwazi ======
&lt;references /&gt;</text>
      <sha1>bqflevip82n4kh50wegpfs68izs4rem</sha1>
    </revision>
    <revision>
      <id>5584</id>
      <parentid>5544</parentid>
      <timestamp>2025-09-04T09:56:27Z</timestamp>
      <contributor>
        <username>White Edits</username>
        <id>894</id>
      </contributor>
      <origin>5584</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4155" sha1="63z1bqzds0ql6nc5mi639dl9iuv9nhg" xml:space="preserve">Page 1 : Draft space 1
----



== Ukusebenza Kwezemakethe Nokurhwebelana. ==
Imakethe nokurhwebelana yizinto ezibaluleke khulu kwezomnotho, zidlala indima ekulu ekwabelaneni kwensenjenziswa kanye nokusatshalaliswa kwepahla eyisizo khulu enarheni mazombe. Imakethe yindawo lapho abathengi nabathengisi bahlangana khona ukuze batjhentjhisane ngepahla neensetjenziswa zemphakathini, bese kuthi ukurhwebelana kube yisenzo sokuthenga nokuthengisa leyo pahla neensetjenziswa.

=== Imihlobo yemakethe esinayo. ===
Kukhona imihlobo ehlukeneko yemakethe, efaka hlangana:

1. Iphikiswano ephelele (Perfect Competition): Lomhlobo wemakethe kulapho kunabathengi nabathengisi abanengi, ukungena nokuphuma okulula, kanye nelwazi eliphelele (Smith, 1776).

2. Ukunqoba (Monopoly): Lomhlobo wemakethe kulapho ikhampani eyodwa kwaphela ikhiqiza imikhiqizo nofana iinsetjenziswa ezithileko enikela ngazo kumakethe.(Marshall, 1890).

3. Ukubumbana kwamakhampani ambalwa (Oligopoly): Lomhlobo wemakethe kulapho amakhampani ambalwa abusa khona begodu aphikisana ngokunikela kumakethe.&lt;ref&gt;{{Cite book|last=Chamberlin|first=E. H|title=The Theory of Monopolistic Competition.|date=1993|publisher=Harvard University Press|year=1993}}&lt;/ref&gt;

==== Iindlela Zokurhwebelana (Trading Mechanisms) ====
Iindlela zokurhwebelana zifaka hlangana imigomo nemibandela elawula ukuthenga nokuthengisa epahleni neensetjenziswa  kumakethe. Lezi iindlela zingaba:

1. Ukurhwebelana Ngokuzwisisana (Auction-based trading): Lomhlobo yindlela lapho abathengi nabathengisi bafaka amanani wabo, iintengo zibekwa ngendlela yokuhlangabezana kwesidingo nokunikelwa ngepahla nanyana iinsetjenziswa ezithize kumakethe..&lt;ref name=&quot;:1&quot;&gt;{{Cite book|last=Marshall|first=A|title=Principles of Economics|date=1990|publisher=Macmillan|year=1990}}&lt;/ref&gt;

2. Ukurwebelana Ngaphandle kokuzwisisana (Quote-driven trading):Lomhlobo yindlela lapho abenzi bemakethe banikeza amanani wokuthenga nokuthengisa, abathengi bangakhetha ukuwamukela nofana ukuwalandula.&lt;ref&gt;{{Cite book|last=Milgrom|first=P|title=Putting Auction Theory to Work|date=2004|publisher=Cambridge University Press.|year=2004}}&lt;/ref&gt;

===== Ukusebenza Kwemakethe (Market Efficiency) =====
Ukusebenza kwemakethe kutjho ikghono lemakethe lokubonisa loke ilwazi elokhona eentengweni. Kune mihlobo emithathu yokusebenza kwemakethe:

1. Ifomu Elibuthakathaka (Weak form efficiency): Iintengo zibonisa loke ilwazi lamanani adlulileko.&lt;ref&gt;{{Cite journal|last=Fama|first=E. F.|date=1970|title=Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance|journal=Journal of Finance}}&lt;/ref&gt;

2.Ifomu Eliphakathi (Semi-strong form efficiency): Iintengo zikhombisa loke ilwazi elikhona emphakathini.&lt;ref&gt;{{Cite journal|last=Fama|first=E. F.|date=1970|title=Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance|journal=Journal of Finance}}&lt;/ref&gt;

3. Ifomu Elinamandla (Strong form efficiency): Iintengo zikhombisa loke ilwazi, kungaba ngelikhona emphakathini nofana elifihlakeleko.&lt;ref&gt;{{Cite journal|last=Fama|first=E. F.|date=1970|title=Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance|journal=Journal of Finance}}&lt;/ref&gt;

Imakethe bokurhwebelana kuyizinto ezinganakuthembeka begodu ezitjhugulukako mihla namalanga ezidlala indima ekulu ekwabelaneni kweensetjenziswa nekusatshalalisweni kwepahla neensetjensiza. Ukulemula iminhlobo ehlukeneko yemakethe, iindlela zokurhwebelana, nokusebenza kwemakethe kubalulekile ekuthatheni iinqumo ezihlakaniphileko zokwandisa imali nokuzwisisa ubunzima bokwandisa umnotho esikhathini sanje.



Chamberlin, E. H. (1933). The Theory of Monopolistic Competition. Harvard University Press.

Fama, E. F. (1970). Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance, 25(2), 383-417. 

Hasbrouck, J. (2007). Empirical Market Microstructure. Oxford University Press. 

Marshall, A. (1890). Principles of Economics. Macmillan.  
Milgrom, P. (2004). Putting Auction Theory to Work. Cambridge University Press.

Smith, A. (1776). The Wealth of Nations. Penguin Books
====== Imithombo lwazi ======
&lt;references /&gt;</text>
      <sha1>63z1bqzds0ql6nc5mi639dl9iuv9nhg</sha1>
    </revision>
    <revision>
      <id>5588</id>
      <parentid>5584</parentid>
      <timestamp>2025-09-04T09:59:45Z</timestamp>
      <contributor>
        <username>White Edits</username>
        <id>894</id>
      </contributor>
      <origin>5588</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4254" sha1="tocdtk870dv57cybwugkmghfw2q6dnd" xml:space="preserve">Page 1 : Draft space 1
----



== Ukusebenza Kwezemakethe Nokurhwebelana. ==
Imakethe nokurhwebelana yizinto ezibaluleke khulu kwezomnotho, zidlala indima ekulu ekwabelaneni kwensenjenziswa kanye nokusatshalaliswa kwepahla eyisizo khulu enarheni mazombe. Imakethe yindawo lapho abathengi nabathengisi bahlangana khona ukuze batjhentjhisane ngepahla neensetjenziswa zemphakathini, bese kuthi ukurhwebelana kube yisenzo sokuthenga nokuthengisa leyo pahla neensetjenziswa.

=== Imihlobo yemakethe esinayo. ===
Kukhona imihlobo ehlukeneko yemakethe, efaka hlangana:

1. Iphikiswano ephelele (Perfect Competition): Lomhlobo wemakethe kulapho kunabathengi nabathengisi abanengi, ukungena nokuphuma okulula, kanye nelwazi eliphelele (Smith, 1776).

2. Ukunqoba (Monopoly): Lomhlobo wemakethe kulapho ikhampani eyodwa kwaphela ikhiqiza imikhiqizo nofana iinsetjenziswa ezithileko enikela ngazo kumakethe.&lt;ref&gt;{{Cite book|last=Marshall|first=A|title=Principles of Economics|date=1890|publisher=Macmillan|year=1890}}&lt;/ref&gt;

3. Ukubumbana kwamakhampani ambalwa (Oligopoly): Lomhlobo wemakethe kulapho amakhampani ambalwa abusa khona begodu aphikisana ngokunikela kumakethe.&lt;ref&gt;{{Cite book|last=Chamberlin|first=E. H|title=The Theory of Monopolistic Competition.|date=1993|publisher=Harvard University Press|year=1993}}&lt;/ref&gt;

==== Iindlela Zokurhwebelana (Trading Mechanisms) ====
Iindlela zokurhwebelana zifaka hlangana imigomo nemibandela elawula ukuthenga nokuthengisa epahleni neensetjenziswa  kumakethe. Lezi iindlela zingaba:

1. Ukurhwebelana Ngokuzwisisana (Auction-based trading): Lomhlobo yindlela lapho abathengi nabathengisi bafaka amanani wabo, iintengo zibekwa ngendlela yokuhlangabezana kwesidingo nokunikelwa ngepahla nanyana iinsetjenziswa ezithize kumakethe..&lt;ref name=&quot;:1&quot;&gt;{{Cite book|last=Marshall|first=A|title=Principles of Economics|date=1990|publisher=Macmillan|year=1990}}&lt;/ref&gt;

2. Ukurwebelana Ngaphandle kokuzwisisana (Quote-driven trading):Lomhlobo yindlela lapho abenzi bemakethe banikeza amanani wokuthenga nokuthengisa, abathengi bangakhetha ukuwamukela nofana ukuwalandula.&lt;ref&gt;{{Cite book|last=Milgrom|first=P|title=Putting Auction Theory to Work|date=2004|publisher=Cambridge University Press.|year=2004}}&lt;/ref&gt;

===== Ukusebenza Kwemakethe (Market Efficiency) =====
Ukusebenza kwemakethe kutjho ikghono lemakethe lokubonisa loke ilwazi elokhona eentengweni. Kune mihlobo emithathu yokusebenza kwemakethe:

1. Ifomu Elibuthakathaka (Weak form efficiency): Iintengo zibonisa loke ilwazi lamanani adlulileko.&lt;ref&gt;{{Cite journal|last=Fama|first=E. F.|date=1970|title=Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance|journal=Journal of Finance}}&lt;/ref&gt;

2.Ifomu Eliphakathi (Semi-strong form efficiency): Iintengo zikhombisa loke ilwazi elikhona emphakathini.&lt;ref&gt;{{Cite journal|last=Fama|first=E. F.|date=1970|title=Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance|journal=Journal of Finance}}&lt;/ref&gt;

3. Ifomu Elinamandla (Strong form efficiency): Iintengo zikhombisa loke ilwazi, kungaba ngelikhona emphakathini nofana elifihlakeleko.&lt;ref&gt;{{Cite journal|last=Fama|first=E. F.|date=1970|title=Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance|journal=Journal of Finance}}&lt;/ref&gt;

Imakethe bokurhwebelana kuyizinto ezinganakuthembeka begodu ezitjhugulukako mihla namalanga ezidlala indima ekulu ekwabelaneni kweensetjenziswa nekusatshalalisweni kwepahla neensetjensiza. Ukulemula iminhlobo ehlukeneko yemakethe, iindlela zokurhwebelana, nokusebenza kwemakethe kubalulekile ekuthatheni iinqumo ezihlakaniphileko zokwandisa imali nokuzwisisa ubunzima bokwandisa umnotho esikhathini sanje.



Chamberlin, E. H. (1933). The Theory of Monopolistic Competition. Harvard University Press.

Fama, E. F. (1970). Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance, 25(2), 383-417. 

Hasbrouck, J. (2007). Empirical Market Microstructure. Oxford University Press. 

Marshall, A. (1890). Principles of Economics. Macmillan.  
Milgrom, P. (2004). Putting Auction Theory to Work. Cambridge University Press.

Smith, A. (1776). The Wealth of Nations. Penguin Books
====== Imithombo lwazi ======
&lt;references /&gt;</text>
      <sha1>tocdtk870dv57cybwugkmghfw2q6dnd</sha1>
    </revision>
    <revision>
      <id>5638</id>
      <parentid>5588</parentid>
      <timestamp>2025-09-04T10:51:26Z</timestamp>
      <contributor>
        <username>White Edits</username>
        <id>894</id>
      </contributor>
      <origin>5638</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4379" sha1="s3p0kaonan62z5rajea462xsyt8u7ty" xml:space="preserve">Page 1 : Draft space 1
----
[[Isimumathi:Market data on display at Taiwan Stock Exchange 20210208.jpg|thumb|Market data on display at a Stock Exchange]]



== Ukusebenza Kwezemakethe Nokurhwebelana. ==
Imakethe nokurhwebelana yizinto ezibaluleke khulu kwezomnotho, zidlala indima ekulu ekwabelaneni kwensenjenziswa kanye nokusatshalaliswa kwepahla eyisizo khulu enarheni mazombe. Imakethe yindawo lapho abathengi nabathengisi bahlangana khona ukuze batjhentjhisane ngepahla neensetjenziswa zemphakathini, bese kuthi ukurhwebelana kube yisenzo sokuthenga nokuthengisa leyo pahla neensetjenziswa.

=== Imihlobo yemakethe esinayo. ===
Kukhona imihlobo ehlukeneko yemakethe, efaka hlangana:

1. Iphikiswano ephelele (Perfect Competition): Lomhlobo wemakethe kulapho kunabathengi nabathengisi abanengi, ukungena nokuphuma okulula, kanye nelwazi eliphelele (Smith, 1776).

2. Ukunqoba (Monopoly): Lomhlobo wemakethe kulapho ikhampani eyodwa kwaphela ikhiqiza imikhiqizo nofana iinsetjenziswa ezithileko enikela ngazo kumakethe.&lt;ref&gt;{{Cite book|last=Marshall|first=A|title=Principles of Economics|date=1890|publisher=Macmillan|year=1890}}&lt;/ref&gt;

3. Ukubumbana kwamakhampani ambalwa (Oligopoly): Lomhlobo wemakethe kulapho amakhampani ambalwa abusa khona begodu aphikisana ngokunikela kumakethe.&lt;ref&gt;{{Cite book|last=Chamberlin|first=E. H|title=The Theory of Monopolistic Competition.|date=1993|publisher=Harvard University Press|year=1993}}&lt;/ref&gt;

==== Iindlela Zokurhwebelana (Trading Mechanisms) ====
Iindlela zokurhwebelana zifaka hlangana imigomo nemibandela elawula ukuthenga nokuthengisa epahleni neensetjenziswa  kumakethe. Lezi iindlela zingaba:

1. Ukurhwebelana Ngokuzwisisana (Auction-based trading): Lomhlobo yindlela lapho abathengi nabathengisi bafaka amanani wabo, iintengo zibekwa ngendlela yokuhlangabezana kwesidingo nokunikelwa ngepahla nanyana iinsetjenziswa ezithize kumakethe..&lt;ref name=&quot;:1&quot;&gt;{{Cite book|last=Marshall|first=A|title=Principles of Economics|date=1990|publisher=Macmillan|year=1990}}&lt;/ref&gt;

2. Ukurwebelana Ngaphandle kokuzwisisana (Quote-driven trading):Lomhlobo yindlela lapho abenzi bemakethe banikeza amanani wokuthenga nokuthengisa, abathengi bangakhetha ukuwamukela nofana ukuwalandula.&lt;ref&gt;{{Cite book|last=Milgrom|first=P|title=Putting Auction Theory to Work|date=2004|publisher=Cambridge University Press.|year=2004}}&lt;/ref&gt;

===== Ukusebenza Kwemakethe (Market Efficiency) =====
Ukusebenza kwemakethe kutjho ikghono lemakethe lokubonisa loke ilwazi elokhona eentengweni. Kune mihlobo emithathu yokusebenza kwemakethe:

1. Ifomu Elibuthakathaka (Weak form efficiency): Iintengo zibonisa loke ilwazi lamanani adlulileko.&lt;ref&gt;{{Cite journal|last=Fama|first=E. F.|date=1970|title=Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance|journal=Journal of Finance}}&lt;/ref&gt;

2.Ifomu Eliphakathi (Semi-strong form efficiency): Iintengo zikhombisa loke ilwazi elikhona emphakathini.&lt;ref&gt;{{Cite journal|last=Fama|first=E. F.|date=1970|title=Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance|journal=Journal of Finance}}&lt;/ref&gt;

3. Ifomu Elinamandla (Strong form efficiency): Iintengo zikhombisa loke ilwazi, kungaba ngelikhona emphakathini nofana elifihlakeleko.&lt;ref&gt;{{Cite journal|last=Fama|first=E. F.|date=1970|title=Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance|journal=Journal of Finance}}&lt;/ref&gt;

Imakethe bokurhwebelana kuyizinto ezinganakuthembeka begodu ezitjhugulukako mihla namalanga ezidlala indima ekulu ekwabelaneni kweensetjenziswa nekusatshalalisweni kwepahla neensetjensiza. Ukulemula iminhlobo ehlukeneko yemakethe, iindlela zokurhwebelana, nokusebenza kwemakethe kubalulekile ekuthatheni iinqumo ezihlakaniphileko zokwandisa imali nokuzwisisa ubunzima bokwandisa umnotho esikhathini sanje.



Chamberlin, E. H. (1933). The Theory of Monopolistic Competition. Harvard University Press.

Fama, E. F. (1970). Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance, 25(2), 383-417. 

Hasbrouck, J. (2007). Empirical Market Microstructure. Oxford University Press. 

Marshall, A. (1890). Principles of Economics. Macmillan.  
Milgrom, P. (2004). Putting Auction Theory to Work. Cambridge University Press.

Smith, A. (1776). The Wealth of Nations. Penguin Books
====== Imithombo lwazi ======
&lt;references /&gt;</text>
      <sha1>s3p0kaonan62z5rajea462xsyt8u7ty</sha1>
    </revision>
    <revision>
      <id>5639</id>
      <parentid>5638</parentid>
      <timestamp>2025-09-04T10:53:03Z</timestamp>
      <contributor>
        <username>White Edits</username>
        <id>894</id>
      </contributor>
      <origin>5639</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4471" sha1="68rx3v8mk29ca359euorikks19n9nap" xml:space="preserve">[[Isimumathi:Stock market charts illustration.jpg|thumb|Stock market charts illustration.]]
Page 1 : Draft space 1
----
[[Isimumathi:Market data on display at Taiwan Stock Exchange 20210208.jpg|thumb|Market data on display at a Stock Exchange]]



== Ukusebenza Kwezemakethe Nokurhwebelana. ==
Imakethe nokurhwebelana yizinto ezibaluleke khulu kwezomnotho, zidlala indima ekulu ekwabelaneni kwensenjenziswa kanye nokusatshalaliswa kwepahla eyisizo khulu enarheni mazombe. Imakethe yindawo lapho abathengi nabathengisi bahlangana khona ukuze batjhentjhisane ngepahla neensetjenziswa zemphakathini, bese kuthi ukurhwebelana kube yisenzo sokuthenga nokuthengisa leyo pahla neensetjenziswa.

=== Imihlobo yemakethe esinayo. ===
Kukhona imihlobo ehlukeneko yemakethe, efaka hlangana:

1. Iphikiswano ephelele (Perfect Competition): Lomhlobo wemakethe kulapho kunabathengi nabathengisi abanengi, ukungena nokuphuma okulula, kanye nelwazi eliphelele (Smith, 1776).

2. Ukunqoba (Monopoly): Lomhlobo wemakethe kulapho ikhampani eyodwa kwaphela ikhiqiza imikhiqizo nofana iinsetjenziswa ezithileko enikela ngazo kumakethe.&lt;ref&gt;{{Cite book|last=Marshall|first=A|title=Principles of Economics|date=1890|publisher=Macmillan|year=1890}}&lt;/ref&gt;

3. Ukubumbana kwamakhampani ambalwa (Oligopoly): Lomhlobo wemakethe kulapho amakhampani ambalwa abusa khona begodu aphikisana ngokunikela kumakethe.&lt;ref&gt;{{Cite book|last=Chamberlin|first=E. H|title=The Theory of Monopolistic Competition.|date=1993|publisher=Harvard University Press|year=1993}}&lt;/ref&gt;

==== Iindlela Zokurhwebelana (Trading Mechanisms) ====
Iindlela zokurhwebelana zifaka hlangana imigomo nemibandela elawula ukuthenga nokuthengisa epahleni neensetjenziswa  kumakethe. Lezi iindlela zingaba:

1. Ukurhwebelana Ngokuzwisisana (Auction-based trading): Lomhlobo yindlela lapho abathengi nabathengisi bafaka amanani wabo, iintengo zibekwa ngendlela yokuhlangabezana kwesidingo nokunikelwa ngepahla nanyana iinsetjenziswa ezithize kumakethe..&lt;ref name=&quot;:1&quot;&gt;{{Cite book|last=Marshall|first=A|title=Principles of Economics|date=1990|publisher=Macmillan|year=1990}}&lt;/ref&gt;

2. Ukurwebelana Ngaphandle kokuzwisisana (Quote-driven trading):Lomhlobo yindlela lapho abenzi bemakethe banikeza amanani wokuthenga nokuthengisa, abathengi bangakhetha ukuwamukela nofana ukuwalandula.&lt;ref&gt;{{Cite book|last=Milgrom|first=P|title=Putting Auction Theory to Work|date=2004|publisher=Cambridge University Press.|year=2004}}&lt;/ref&gt;

===== Ukusebenza Kwemakethe (Market Efficiency) =====
Ukusebenza kwemakethe kutjho ikghono lemakethe lokubonisa loke ilwazi elokhona eentengweni. Kune mihlobo emithathu yokusebenza kwemakethe:

1. Ifomu Elibuthakathaka (Weak form efficiency): Iintengo zibonisa loke ilwazi lamanani adlulileko.&lt;ref&gt;{{Cite journal|last=Fama|first=E. F.|date=1970|title=Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance|journal=Journal of Finance}}&lt;/ref&gt;

2.Ifomu Eliphakathi (Semi-strong form efficiency): Iintengo zikhombisa loke ilwazi elikhona emphakathini.&lt;ref&gt;{{Cite journal|last=Fama|first=E. F.|date=1970|title=Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance|journal=Journal of Finance}}&lt;/ref&gt;

3. Ifomu Elinamandla (Strong form efficiency): Iintengo zikhombisa loke ilwazi, kungaba ngelikhona emphakathini nofana elifihlakeleko.&lt;ref&gt;{{Cite journal|last=Fama|first=E. F.|date=1970|title=Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance|journal=Journal of Finance}}&lt;/ref&gt;

Imakethe bokurhwebelana kuyizinto ezinganakuthembeka begodu ezitjhugulukako mihla namalanga ezidlala indima ekulu ekwabelaneni kweensetjenziswa nekusatshalalisweni kwepahla neensetjensiza. Ukulemula iminhlobo ehlukeneko yemakethe, iindlela zokurhwebelana, nokusebenza kwemakethe kubalulekile ekuthatheni iinqumo ezihlakaniphileko zokwandisa imali nokuzwisisa ubunzima bokwandisa umnotho esikhathini sanje.



Chamberlin, E. H. (1933). The Theory of Monopolistic Competition. Harvard University Press.

Fama, E. F. (1970). Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance, 25(2), 383-417. 

Hasbrouck, J. (2007). Empirical Market Microstructure. Oxford University Press. 

Marshall, A. (1890). Principles of Economics. Macmillan.  
Milgrom, P. (2004). Putting Auction Theory to Work. Cambridge University Press.

Smith, A. (1776). The Wealth of Nations. Penguin Books
====== Imithombo lwazi ======
&lt;references /&gt;</text>
      <sha1>68rx3v8mk29ca359euorikks19n9nap</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:ThokozaniSlaki/Page 1</title>
    <ns>2</ns>
    <id>822</id>
    <revision>
      <id>5325</id>
      <timestamp>2025-09-03T10:18:31Z</timestamp>
      <contributor>
        <username>ThokozaniSlaki</username>
        <id>842</id>
      </contributor>
      <comment>Created sub page 1</comment>
      <origin>5325</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="22" sha1="133m6gml1cn7sbpnlpqfc3kpquq7p0g" xml:space="preserve">Page 1: Draft space 1.</text>
      <sha1>133m6gml1cn7sbpnlpqfc3kpquq7p0g</sha1>
    </revision>
    <revision>
      <id>5431</id>
      <parentid>5325</parentid>
      <timestamp>2025-09-04T06:16:56Z</timestamp>
      <contributor>
        <username>ThokozaniSlaki</username>
        <id>842</id>
      </contributor>
      <comment>Ngitlole isifundo sami sokuthoma</comment>
      <origin>5431</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2837" sha1="9kwcdh026lpubounbw3j33nwb15yapb" xml:space="preserve">Page 1: Draft space 1.

'''Ungubani igama lakho? Your surname is actually your first name. (Isifundo sokuthoma)'''

Isithambo sesokana sikhamba nesibongo. Isibongo kuligama lomuntu lamambala begodu lokuthoma (first name).

Umntwana oduna oliNdebele ubelethwa egameni lakhe lokuthoma (isibongo e.g Mabhena), aphiwe igama lesibili ekungileli abikwa ngalo ebeZimini nabathokoza bona baphiwe umntwana (e.g Sibusiso). Nakakhulako abaMsegwabo (uMsegwabo akusi msana ongakaweli kodwana msana oyokuwela) uphiwa igama lesithathu (e.g Thungela), bese nakagwabako angena esigabengi sokuba lisokana aphiwe igama lakhe lesine (e.g Maduma) bese uthi angathatha kukhithizwe woke amagama laye bese abizwe ngegama lakhe lokuthoma okusibongo (e.g Mabhena)

Umsana usingathwa beZimu bakhe asese lincele (isana) kuthi lokha nakayokuwela boke abeZimu bakhe bayatjhida kuye, asale anganabo abeZimu. UZimakhe omutjha oyokuba naye ipilwakhe yoke umthola ngemphadwini, kungakho kuneNtanga. Nakutjalwa intangetjha kulapho kuvuka khona abeZimu beNtanga leyo ababa beZimu bomlisa. Ukhamba anganaZimu, abuye anoZimu (e.g Nangabe iNtanga etjalwako Maphogo, iQhegu lekhabo eliyiPhogo kuvuka lona). INtanga, isithambo nesibongo zibuya ethambeni linye ledlozi. Akukghonakali ukuthi ungasebenzisa isibongo seKhenemkhulu (Mahlangu) ngombana ukhulele khona unguMasalekhaya bese nawuwelako uthathe isithambo sekhenu sakwaMabhena bese ubuye uzokwakha umuzi ngesibongo se-Step father ngombana nakhu ummakho usale waba netjhudu lomendo nawuqeda ukuwela.

Banengi abantwana abasebenzisa amagamabo (isibongo) ngokungasisemthethweni nofana abathwese iinthambo ekungasizo zamagamabo.

Umntwana wawiselwa boMalume, wathola isithambo sekhabomkhulu akusakghonakali bona angabuye athathe igama likababakhe (isibongo sekhabo). Gamare ubabakhe abuye athi uyamfuna, akasanalo ilungelo lokumnikela isibongo – udliwe umntwana.

Abantu abanengi bagulwisa kukuthi baphumela emaKhabomkhulu nabayokuwela bese nabahlabako bahlabela emakhabo nofana bathatha iinthambo zemakhabo kube baphumele emakhabomkhulu. Abantu bagulwisa kukuthi bawiselwa boMalume bese nakufanele bathathe bathathiswa ngesibongo engazange sabagwabisa. Abantu babiza iimbongo zemakhabo ezange zabagwabisa. Umbuzo uthi unguMasalekhaya nofana ungeweenthimbeni? Akukghonakali bona uthathe koke ukuphethele kwangathi uNtuli unguSithole.

Umraro ohlangahlanganisa ipilwakho kukuthi uthwele iinthunzi zamaQhegu amabili ngombana wathi uphethelwa kwathathwa ngapha nangapha wanikelwa, iinkunzi ezimbili azihlali esibayeni esisodwa. Ungubani wena igama lakho? Igamelo likhambo nesithambo sakho na? Igamelo nguZimu owakugwabisa na? Nasi indaba irara ibandla – abantu baya eenyangeni bathi baloyiwe kanti bathwele kumbi, ngizokugcina la namhlanjesi kuthi ngelanga elizako ngizoyithatha ngale nawusikazi soloko ngikubuza igama lakho.</text>
      <sha1>9kwcdh026lpubounbw3j33nwb15yapb</sha1>
    </revision>
    <revision>
      <id>5540</id>
      <parentid>5431</parentid>
      <timestamp>2025-09-04T09:29:30Z</timestamp>
      <contributor>
        <username>ThokozaniSlaki</username>
        <id>842</id>
      </contributor>
      <comment>i have added the sub section</comment>
      <origin>5540</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3249" sha1="47n4llrwk18zu2t2ys61tvsd6ox3bet" xml:space="preserve">Page 1: Draft space 1.

'''Ungubani igama lakho? Your surname is actually your first name. (Isifundo sokuthoma)'''

=== Imvelo yegama lomuntu. ===
Isithambo sesokana sikhamba nesibongo. Isibongo kuligama lomuntu lamambala begodu lokuthoma (first name).

Umntwana oduna oliNdebele ubelethwa egameni lakhe lokuthoma (isibongo e.g Mabhena), aphiwe igama lesibili ekungileli abikwa ngalo ebeZimini nabathokoza bona baphiwe umntwana (e.g Sibusiso). Nakakhulako abaMsegwabo (uMsegwabo akusi msana ongakaweli kodwana msana oyokuwela) uphiwa igama lesithathu (e.g Thungela), bese nakagwabako angena esigabengi sokuba lisokana aphiwe igama lakhe lesine (e.g Maduma) bese uthi angathatha kukhithizwe woke amagama laye bese abizwe ngegama lakhe lokuthoma okusibongo (e.g Mabhena)

Umsana usingathwa beZimu bakhe asese lincele (isana) kuthi lokha nakayokuwela boke abeZimu bakhe bayatjhida kuye, asale anganabo abeZimu. UZimakhe omutjha oyokuba naye ipilwakhe yoke umthola ngemphadwini, kungakho kuneNtanga. Nakutjalwa intangetjha kulapho kuvuka khona abeZimu beNtanga leyo ababa beZimu bomlisa. &lt;ref&gt;Azevêdo, E.S., 2023. The meaning of names and family names as a tracer of cultural values. ''Aspects of Language: Studies in Honour of Mario Alinei, Volume II: Theoretical and Applied Semantics: Papers Presented to Mario Alinei by His Friends, Colleagues and Former Students on the Occasion of His 60-th Birthday'', ''2'', p.17.&lt;/ref&gt;  Ukhamba anganaZimu, abuye anoZimu (e.g Nangabe iNtanga etjalwako Maphogo, iQhegu lekhabo eliyiPhogo kuvuka lona). INtanga, isithambo nesibongo zibuya ethambeni linye ledlozi. Akukghonakali ukuthi ungasebenzisa isibongo seKhenemkhulu (Mahlangu) ngombana ukhulele khona unguMasalekhaya bese nawuwelako uthathe isithambo sekhenu sakwaMabhena bese ubuye uzokwakha umuzi ngesibongo se-Step father ngombana nakhu ummakho usale waba netjhudu lomendo nawuqeda ukuwela.

Banengi abantwana abasebenzisa amagamabo (isibongo) ngokungasisemthethweni nofana abathwese iinthambo ekungasizo zamagamabo.

Umntwana wawiselwa boMalume, wathola isithambo sekhabomkhulu akusakghonakali bona angabuye athathe igama likababakhe (isibongo sekhabo). Gamare ubabakhe abuye athi uyamfuna, akasanalo ilungelo lokumnikela isibongo – udliwe umntwana.

Abantu abanengi bagulwisa kukuthi baphumela emaKhabomkhulu nabayokuwela bese nabahlabako bahlabela emakhabo nofana bathatha iinthambo zemakhabo kube baphumele emakhabomkhulu. Abantu bagulwisa kukuthi bawiselwa boMalume bese nakufanele bathathe bathathiswa ngesibongo engazange sabagwabisa. Abantu babiza iimbongo zemakhabo ezange zabagwabisa. Umbuzo uthi unguMasalekhaya nofana ungeweenthimbeni? Akukghonakali bona uthathe koke ukuphethele kwangathi uNtuli unguSithole.

Umraro ohlangahlanganisa ipilwakho kukuthi uthwele iinthunzi zamaQhegu amabili ngombana wathi uphethelwa kwathathwa ngapha nangapha wanikelwa, iinkunzi ezimbili azihlali esibayeni esisodwa. Ungubani wena igama lakho? Igamelo likhambo nesithambo sakho na? Igamelo nguZimu owakugwabisa na? Nasi indaba irara ibandla – abantu baya eenyangeni bathi baloyiwe kanti bathwele kumbi, ngizokugcina la namhlanjesi kuthi ngelanga elizako ngizoyithatha ngale nawusikazi soloko ngikubuza igama lakho.

=== Imithombolwazi ===
&lt;references /&gt;</text>
      <sha1>47n4llrwk18zu2t2ys61tvsd6ox3bet</sha1>
    </revision>
    <revision>
      <id>5629</id>
      <parentid>5540</parentid>
      <timestamp>2025-09-04T10:44:15Z</timestamp>
      <contributor>
        <username>ThokozaniSlaki</username>
        <id>842</id>
      </contributor>
      <comment>I have added a picture. Ngifake isithombe samaNdebele</comment>
      <origin>5629</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3347" sha1="6au6u99mkd9r5hehn3o9rniocz3g2ej" xml:space="preserve">Page 1: Draft space 1.

[[Isimumathi:Ndebele skanzen.jpg|thumb|Amandebele nekambiso ekhona ekunikelweni umntwana gama.]]

'''Ungubani igama lakho? Your surname is actually your first name. (Isifundo sokuthoma)'''

=== Imvelo yegama lomuntu. ===
Isithambo sesokana sikhamba nesibongo. Isibongo kuligama lomuntu lamambala begodu lokuthoma (first name).

Umntwana oduna oliNdebele ubelethwa egameni lakhe lokuthoma (isibongo e.g Mabhena), aphiwe igama lesibili ekungileli abikwa ngalo ebeZimini nabathokoza bona baphiwe umntwana (e.g Sibusiso). Nakakhulako abaMsegwabo (uMsegwabo akusi msana ongakaweli kodwana msana oyokuwela) uphiwa igama lesithathu (e.g Thungela), bese nakagwabako angena esigabengi sokuba lisokana aphiwe igama lakhe lesine (e.g Maduma) bese uthi angathatha kukhithizwe woke amagama laye bese abizwe ngegama lakhe lokuthoma okusibongo (e.g Mabhena)

Umsana usingathwa beZimu bakhe asese lincele (isana) kuthi lokha nakayokuwela boke abeZimu bakhe bayatjhida kuye, asale anganabo abeZimu. UZimakhe omutjha oyokuba naye ipilwakhe yoke umthola ngemphadwini, kungakho kuneNtanga. Nakutjalwa intangetjha kulapho kuvuka khona abeZimu beNtanga leyo ababa beZimu bomlisa. &lt;ref&gt;Azevêdo, E.S., 2023. The meaning of names and family names as a tracer of cultural values. ''Aspects of Language: Studies in Honour of Mario Alinei, Volume II: Theoretical and Applied Semantics: Papers Presented to Mario Alinei by His Friends, Colleagues and Former Students on the Occasion of His 60-th Birthday'', ''2'', p.17.&lt;/ref&gt;  Ukhamba anganaZimu, abuye anoZimu (e.g Nangabe iNtanga etjalwako Maphogo, iQhegu lekhabo eliyiPhogo kuvuka lona). INtanga, isithambo nesibongo zibuya ethambeni linye ledlozi. Akukghonakali ukuthi ungasebenzisa isibongo seKhenemkhulu (Mahlangu) ngombana ukhulele khona unguMasalekhaya bese nawuwelako uthathe isithambo sekhenu sakwaMabhena bese ubuye uzokwakha umuzi ngesibongo se-Step father ngombana nakhu ummakho usale waba netjhudu lomendo nawuqeda ukuwela.

Banengi abantwana abasebenzisa amagamabo (isibongo) ngokungasisemthethweni nofana abathwese iinthambo ekungasizo zamagamabo.

Umntwana wawiselwa boMalume, wathola isithambo sekhabomkhulu akusakghonakali bona angabuye athathe igama likababakhe (isibongo sekhabo). Gamare ubabakhe abuye athi uyamfuna, akasanalo ilungelo lokumnikela isibongo – udliwe umntwana.

Abantu abanengi bagulwisa kukuthi baphumela emaKhabomkhulu nabayokuwela bese nabahlabako bahlabela emakhabo nofana bathatha iinthambo zemakhabo kube baphumele emakhabomkhulu. Abantu bagulwisa kukuthi bawiselwa boMalume bese nakufanele bathathe bathathiswa ngesibongo engazange sabagwabisa. Abantu babiza iimbongo zemakhabo ezange zabagwabisa. Umbuzo uthi unguMasalekhaya nofana ungeweenthimbeni? Akukghonakali bona uthathe koke ukuphethele kwangathi uNtuli unguSithole.

Umraro ohlangahlanganisa ipilwakho kukuthi uthwele iinthunzi zamaQhegu amabili ngombana wathi uphethelwa kwathathwa ngapha nangapha wanikelwa, iinkunzi ezimbili azihlali esibayeni esisodwa. Ungubani wena igama lakho? Igamelo likhambo nesithambo sakho na? Igamelo nguZimu owakugwabisa na? Nasi indaba irara ibandla – abantu baya eenyangeni bathi baloyiwe kanti bathwele kumbi, ngizokugcina la namhlanjesi kuthi ngelanga elizako ngizoyithatha ngale nawusikazi soloko ngikubuza igama lakho.

=== Imithombolwazi ===
&lt;references /&gt;</text>
      <sha1>6au6u99mkd9r5hehn3o9rniocz3g2ej</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:F.K MAHLANGU/Page 1</title>
    <ns>2</ns>
    <id>823</id>
    <revision>
      <id>5326</id>
      <timestamp>2025-09-03T10:18:51Z</timestamp>
      <contributor>
        <username>F.K MAHLANGU</username>
        <id>891</id>
      </contributor>
      <comment>created sub-page 1</comment>
      <origin>5326</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="20" sha1="sbz3po4o90ghas7kf24xjfdj8a6oupk" xml:space="preserve">page:1 draft space 1</text>
      <sha1>sbz3po4o90ghas7kf24xjfdj8a6oupk</sha1>
    </revision>
    <revision>
      <id>5413</id>
      <parentid>5326</parentid>
      <timestamp>2025-09-03T20:39:43Z</timestamp>
      <contributor>
        <username>F.K MAHLANGU</username>
        <id>891</id>
      </contributor>
      <comment>Ubukghwari besiNdebele kanye nemakhiwo.</comment>
      <origin>5413</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2190" sha1="pxiah2thmnb3zg4kxrmvuga2ah1g4ar" xml:space="preserve">page:1 draft space 1

=== UbuKghwari besiNdebele kanye nemakhiwo yakhona. ===
Abantu bamaNdebele beSewula Afrika baziwa khulu ngobuhle bemibalabala nendlela ehlukileko yokuhlobisa izindlu. Isiko leli lenziwa khulu maNdebele weSewula (amaNdzundza kanye naManala) esifundazweni se-Mpumalanga nese-Gauteng.

=== Ukupendwa kwezindlu. ===
Omunye wemihlobo edumileko yobukghwari bamaNdebele kukupendwa kwezindlu ngemibala ehlukahlukeneko. Amaboda wemizi ahlotjiswe ngemibala ekhanyako efana nobomvu, otjheli, ohlaza satjani, kanye  nonzima. Amaphetheni avamise ukuvezwa ngombala onzinyana, okwenza boabonakale kuhle.

Ukupendwa lokhu kwenziwa babantu abasikazi begodu bakudlulisele eenzukulwaneni. Imitlolo kanengi inehlathululo yamasiko, etjengisa ubunikazi, amagugu, nokutjhuguluka komphakathi. Ubukghwari lobu baqina ekuthomeni kwekhulu lama-20 njengendlela yokutjengisa ukuzikhakhazisa nokuqina ngaphasi kwezimo ezibudisi.&lt;ref&gt;Meiring, T. (2005). ''Ndebele: A People and Their Art''. Johannesburg: Jacana Media.&lt;/ref&gt;

=== Ukusebenza ngobuhlalu. ===
Ukwenza ubuhlalu ngenye into eqakathekileko yobukghwari bamaNdebele. Abomma benza imigexo, ama-ephroni, nemihlobiso yemilenze basebenzisa ubuhlalu obuncani obukhanyelako. Umbala ngamunye nephetheni kungaba nehlathululo, njengokutjengisa bona umuntu wengubo utjhadile namkha usesemntazana.

=== Imakhiwo. ===
Izindlu zesintu zamaNdebele zakhelwe emindenini ngobunengi, zazakhiwe ngombumbo begodu ziyindulunga, zihlotjiswe ngaphandle. Ngokukhamba kwesikhathi, izindlu ezikhulu ezinamaboda amakhulu zaba yinto evamileko, okwenza bona kube nesikhala esinengi sokutlola imifanekiso emibalabala.

=== Ukuqakathekiswa kwesimanjemanje. ===
Ubukghwari bamaNdebele sele baziwa khulu ephasini loke. Abadwebi abafana no-Esther Mahlangu bathathe isiko baliphakamisa, bapenda iinkoloyi, iimphaphamtjhini, kanye namaboda wegalari basebenzisa isitayela esifanako. Ama&quot; Museum&quot; kanye namaqembu wamagugu eSewula Afrika naphetjheya aragela phambili  nokugidinga ubukghwari besiNdebele.&lt;ref&gt;Nuttall, S. &amp; Coetzee, C. (1998). ''Negotiating the Past: The Making of Memory in South Africa''. Oxford University Press.&lt;/ref&gt;

=== irhelo lemithombo. ===
&lt;references /&gt;</text>
      <sha1>pxiah2thmnb3zg4kxrmvuga2ah1g4ar</sha1>
    </revision>
    <revision>
      <id>5442</id>
      <parentid>5413</parentid>
      <timestamp>2025-09-04T07:50:18Z</timestamp>
      <contributor>
        <username>F.K MAHLANGU</username>
        <id>891</id>
      </contributor>
      <origin>5442</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2191" sha1="hftzjlkses52w8rg5g1povezs37icvf" xml:space="preserve">page:1 draft space 1

=== UbuKghwari besiNdebele kanye nemakhiwo yakhona. ===
Abantu bamaNdebele beSewula Afrika baziwa khulu ngobuhle bemibalabala nendlela ehlukileko yokuhlobisa izindlu. Isiko leli lenziwa khulu maNdebele weSewula (amaNdzundza kanye naManala) esifundazweni se-Mpumalanga nese-Gauteng.

=== Ukupendwa kwezindlu. ===
Omunye wemihlobo edumileko yobukghwari bamaNdebele kukupendwa kwezindlu ngemibala ehlukahlukeneko. Amaboda wemizi ahlotjiswe ngemibala ekhanyako efana nobomvu, otjheli, ohlaza satjani, kanye  nonzima. Amaphetheni avamise ukuvezwa ngombala onzinyana, okwenza boabonakale kuhle.

Ukupendwa lokhu kwenziwa babantu abasikazi begodu bakudlulisele eenzukulwaneni. Imitlolo kanengi inehlathululo yamasiko, etjengisa ubunikazi, amagugu, nokutjhuguluka komphakathi. Ubukghwari lobu baqina ekuthomeni kwekhulu lama-20 njengendlela yokutjengisa ukuzikhakhazisa nokuqina ngaphasi kwezimo ezibudisi.&lt;ref&gt;Meiring, T. (2005). ''Ndebele: A People and Their Art''. Johannesburg: Jacana Media.&lt;/ref&gt;

=== Ukusebenza ngobuhlalu. ===
Ukwenza ubuhlalu ngenye into eqakathekileko yobukghwari bamaNdebele. Abomma benza imigexo, ama-ephroni, nemihlobiso yemilenze basebenzisa ubuhlalu obuncani obukhanyelako. Umbala ngamunye nephetheni kungaba nehlathululo, njengokutjengisa bona umuntu wengubo utjhadile namkha usesemntazana.

=== Imakhiwo. ===
Izindlu zesintu zamaNdebele zakhelwe emindenini ngobunengi, zazakhiwe ngombumbo begodu ziyindulunga, zihlotjiswe ngaphandle. Ngokukhamba kwesikhathi, izindlu ezikhulu ezinamaboda amakhulu zaba yinto evamileko, okwenza bona kube nesikhala esinengi sokutlola imifanekiso emibalabala.

=== Ukuqakathekiswa kwesimanjemanje. ===
Ubukghwari bamaNdebele sele baziwa khulu ephasini loke. Abadwebi abafana no-Esther Mahlangu bathathe isiko baliphakamisa, bapenda iinkoloyi, iimphaphamtjhini, kanye namaboda wegalari basebenzisa isitayela esifanako. Ama&quot; Museum&quot; kanye namaqembu wamagugu eSewula Afrika naphetjheya aragela phambili  nokugidinga ubukghwari besiNdebele.&lt;ref&gt;Nuttall, S. &amp; Coetzee, C. (1998). ''Negotiating the Past: The Making of Memory in South Africa''. Oxford University Press.&lt;/ref&gt;

=== irherho lemithombo. ===
&lt;references /&gt;</text>
      <sha1>hftzjlkses52w8rg5g1povezs37icvf</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Imkabini/Page 1</title>
    <ns>2</ns>
    <id>824</id>
    <revision>
      <id>5327</id>
      <timestamp>2025-09-03T10:18:52Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <comment>created the page</comment>
      <origin>5327</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="27" sha1="bcwxqii2y452dg5to6u3qh4tg3a0042" xml:space="preserve">'''page 1: Draft space 1'''</text>
      <sha1>bcwxqii2y452dg5to6u3qh4tg3a0042</sha1>
    </revision>
    <revision>
      <id>5515</id>
      <parentid>5327</parentid>
      <timestamp>2025-09-04T09:17:44Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <comment>added pictures</comment>
      <origin>5515</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2276" sha1="il1nfmroz8jszl86uzd947yasv6a1r7" xml:space="preserve">'''page 1: Draft space 1'''

== Iinarhakazi zephasi ==
'''Ephasini''' kuneenarhakazi ezilikhomba, enye nenye inarhakazi inamasiko wayo, amatshwayo wayo neenarha ezingaphakthi kwayo
Iinarhakazi zephasi.

=== Amagama weenarhakazi zephasi nehlathululo yazo ===
[[Isimumathi:Africa and Europe from a Million Miles Away.png|left|thumb|184x184px|inarhakazi yeAfrika]]


I-Africa

Yinarhakazi yesibili ekulu begodu ngaphakathi iphethe inarha ezima-55 ezifaka hlangana

i-Sewula Africa, i-gibhithe neZimbabwe



[[Isimumathi:Mt Herschel, Antarctica, Jan 2006.jpg|left|thumb|191x191px|Inarha ye-&quot;Antarctica&quot;]]


I-Antarctica

Yinarhakazi encani begodu emakhaza ukuzidlula zoke. Enarhakazini le akuhlali abantu kodwana kuhlala iinlwana zemangweni kwaphela.


[[Isimumathi:Asia satellite orthographic.jpg|left|thumb|195x195px|Inarha ye-&quot;Asia&quot;]]


I-Asia

Lapha kuneenarha ezima-49, ezifaka hlagana I inarha ye China, India Kanye ne Russia ekuyinarha ekulu ukuzidlula zoke ephasini. Inarhakazi le ngekulu ukuzidlula zoke ephasini


[[Isimumathi:Australia satellite plane.jpg|left|thumb|188x188px|Inarha ye-&quot;Australia&quot;]]


I-Australia

Le yinarhakazi encani ehlalwa babantu ephasini, ngaphakathi iineenarha ezi-6 ezine zazo yi- New Zealad, Papua New Guiea ne Australia.


[[Isimumathi:Europe and the European Union.svg|left|thumb|184x184px|Inarha ye-&quot;Europe&quot;]]


I-Europe

Kulenarhakazi kunenarha ezima-50 ezifaka I- Germany, iFrance, ne-United kingdom.Inarhakazi le ngeyesithandathu ekulu



[[Isimumathi:North America physical map blank.jpg|left|thumb|190x190px|Inarha ye-&quot;North America&quot;]]


I-North America

Inarhakazi le ilikhaya leenarha ezima-23 begodu ingeyesithathu ekulu.



[[Isimumathi:South america tr.jpg|left|thumb|242x242px|Inarha ye-&quot;South America&quot;]]



I-South America

Inarhakazi le ineenarha ezili-12 begodu ingee ingeyesine ekule eenarhakazini






== Iinkomba ==

# Yearwood, P.J., 2014. Continents and consequences: the history of a concept. ''Journal of Global History'', ''9''(3), pp.329-356.
# Khapoya, V., 2015. ''The African Experience''. Routledge.
# Prange, C., 2019. Asia: The continent of superlatives and contradictions. In ''Management Practices in Asia: Case Studies on Market Entry, CSR, and Coaching'' (pp. 3-9). Cham: Springer International Publishing</text>
      <sha1>il1nfmroz8jszl86uzd947yasv6a1r7</sha1>
    </revision>
    <revision>
      <id>5516</id>
      <parentid>5515</parentid>
      <timestamp>2025-09-04T09:18:57Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <comment>/* Amagama weenarhakazi zephasi nehlathululo yazo */</comment>
      <origin>5516</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2294" sha1="jnr8bqm03z1fxpjq6okjtmaoc6wlepk" xml:space="preserve">'''page 1: Draft space 1'''

== Iinarhakazi zephasi ==
'''Ephasini''' kuneenarhakazi ezilikhomba, enye nenye inarhakazi inamasiko wayo, amatshwayo wayo neenarha ezingaphakthi kwayo
Iinarhakazi zephasi.

=== Amagama weenarhakazi zephasi nehlathululo yazo ===
[[Isimumathi:Africa and Europe from a Million Miles Away.png|left|thumb|184x184px|inarhakazi yeAfrika]]


I-Africa

Yinarhakazi yesibili ekulu begodu ngaphakathi iphethe inarha ezima-55 ezifaka hlangana

i-Sewula Africa, i-gibhithe neZimbabwe



[[Isimumathi:Mt Herschel, Antarctica, Jan 2006.jpg|left|thumb|191x191px|Inarha ye-&quot;Antarctica&quot;]]


I-Antarctica

Yinarhakazi encani begodu emakhaza ukuzidlula zoke. Enarhakazini le akuhlali abantu kodwana kuhlala iinlwana zemangweni kwaphela.


[[Isimumathi:Asia satellite orthographic.jpg|left|thumb|195x195px|Inarha ye-&quot;Asia&quot;]]


I-Asia

Lapha kuneenarha ezima-49, ezifaka hlagana I inarha ye China, India Kanye ne Russia ekuyinarha ekulu ukuzidlula zoke ephasini. Inarhakazi le ngekulu ukuzidlula zoke ephasini


[[Isimumathi:Australia satellite plane.jpg|left|thumb|188x188px|Inarha ye-&quot;Australia&quot;]]


I-Australia

Le yinarhakazi encani ehlalwa babantu ephasini, ngaphakathi iineenarha ezi-6 ezine zazo yi- New Zealad, Papua New Guiea ne Australia.


[[Isimumathi:Europe and the European Union.svg|left|thumb|184x184px|Inarha ye-&quot;Europe&quot;]]


I-Europe

Kulenarhakazi kunenarha ezima-50 ezifaka I- Germany, iFrance, ne-United kingdom.Inarhakazi le ngeyesithandathu ekulu



[[Isimumathi:North America physical map blank.jpg|left|thumb|190x190px|Inarha ye-&quot;North America&quot;]]





I-North America

Inarhakazi le ilikhaya leenarha ezima-23 begodu ingeyesithathu ekulu.



[[Isimumathi:South america tr.jpg|left|thumb|242x242px|Inarha ye-&quot;South America&quot;]]


I-South America

I-South America

Inarhakazi le ineenarha ezili-12 begodu ingee ingeyesine ekule eenarhakazini





== Iinkomba ==

# Yearwood, P.J., 2014. Continents and consequences: the history of a concept. ''Journal of Global History'', ''9''(3), pp.329-356.
# Khapoya, V., 2015. ''The African Experience''. Routledge.
# Prange, C., 2019. Asia: The continent of superlatives and contradictions. In ''Management Practices in Asia: Case Studies on Market Entry, CSR, and Coaching'' (pp. 3-9). Cham: Springer International Publishing</text>
      <sha1>jnr8bqm03z1fxpjq6okjtmaoc6wlepk</sha1>
    </revision>
    <revision>
      <id>5520</id>
      <parentid>5516</parentid>
      <timestamp>2025-09-04T09:21:49Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <comment>/* Iinkomba */</comment>
      <origin>5520</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2276" sha1="lxs0jr2s7yln999rl71o8ddr6ofy4a6" xml:space="preserve">'''page 1: Draft space 1'''

== Iinarhakazi zephasi ==
'''Ephasini''' kuneenarhakazi ezilikhomba, enye nenye inarhakazi inamasiko wayo, amatshwayo wayo neenarha ezingaphakthi kwayo
Iinarhakazi zephasi.

=== Amagama weenarhakazi zephasi nehlathululo yazo ===
[[Isimumathi:Africa and Europe from a Million Miles Away.png|left|thumb|184x184px|inarhakazi yeAfrika]]



I-Africa

Yinarhakazi yesibili ekulu begodu ngaphakathi iphethe inarha ezima-55 ezifaka hlangana

i-Sewula Africa, i-gibhithe neZimbabwe



[[Isimumathi:Mt Herschel, Antarctica, Jan 2006.jpg|left|thumb|191x191px|Inarha ye-&quot;Antarctica&quot;]]





I-Antarctica

Yinarhakazi encani begodu emakhaza ukuzidlula zoke. Enarhakazini le akuhlali abantu kodwana kuhlala iinlwana zemangweni kwaphela.


[[Isimumathi:Asia satellite orthographic.jpg|left|thumb|195x195px|Inarha ye-&quot;Asia&quot;]]

I-Asia

Lapha kuneenarha ezima-49, ezifaka hlagana I inarha ye China, India Kanye ne Russia ekuyinarha ekulu ukuzidlula zoke ephasini. Inarhakazi le ngekulu ukuzidlula zoke ephasin
[[Isimumathi:Australia satellite plane.jpg|left|thumb|188x188px|Inarha ye-&quot;Australia&quot;]]

I-Australia

Le yinarhakazi encani ehlalwa babantu ephasini, ngaphakathi iineenarha ezi-6 ezine zazo yi- New Zealad, Papua New Guiea ne Australia.


[[Isimumathi:Europe and the European Union.svg|left|thumb|184x184px|Inarha ye-&quot;Europe&quot;]]

I-Europe

Kulenarhakazi kunenarha ezima-50 ezifaka I- Germany, iFrance, ne-United kingdom.Inarhakazi le ngeyesithandathu ekulu



[[Isimumathi:North America physical map blank.jpg|left|thumb|190x190px|Inarha ye-&quot;North America&quot;]]



I-North America

Inarhakazi le ilikhaya leenarha ezima-23 begodu ingeyesithathu ekulu.



[[Isimumathi:South america tr.jpg|left|thumb|242x242px|Inarha ye-&quot;South America&quot;]]





I-South America

Inarhakazi le ineenarha ezili-12 begodu ingee ingeyesine ekule eenarhakazini





== Iinkomba ==

# Yearwood, P.J., 2014. Continents and consequences: the history of a concept. ''Journal of Global History'', ''9''(3), pp.329-356.
# Khapoya, V., 2015. ''The African Experience''. Routledge.
# Prange, C., 2019. Asia: The continent of superlatives and contradictions. In ''Management Practices in Asia: Case Studies on Market Entry, CSR, and Coaching'' (pp. 3-9). Cham: Springer International Publishing</text>
      <sha1>lxs0jr2s7yln999rl71o8ddr6ofy4a6</sha1>
    </revision>
    <revision>
      <id>5529</id>
      <parentid>5520</parentid>
      <timestamp>2025-09-04T09:24:58Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <comment>added reference</comment>
      <origin>5529</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2294" sha1="kc952bibyp3ees12s53fbhh0t9dss3s" xml:space="preserve">'''page 1: Draft space 1'''

== Iinarhakazi zephasi ==
'''Ephasini''' kuneenarhakazi ezilikhomba, enye nenye inarhakazi inamasiko wayo, amatshwayo wayo neenarha ezingaphakthi kwayo
Iinarhakazi zephasi.

=== Amagama weenarhakazi zephasi nehlathululo yazo ===
[[Isimumathi:Africa and Europe from a Million Miles Away.png|left|thumb|184x184px|inarhakazi yeAfrika]]



I-Africa

Yinarhakazi yesibili ekulu begodu ngaphakathi iphethe inarha ezima-55 ezifaka hlangana

i-Sewula Africa, i-gibhithe neZimbabwe



[[Isimumathi:Mt Herschel, Antarctica, Jan 2006.jpg|left|thumb|191x191px|Inarha ye-&quot;Antarctica&quot;]]





I-Antarctica

Yinarhakazi encani begodu emakhaza ukuzidlula zoke. Enarhakazini le akuhlali abantu kodwana kuhlala iinlwana zemangweni kwaphela.


[[Isimumathi:Asia satellite orthographic.jpg|left|thumb|195x195px|Inarha ye-&quot;Asia&quot;]]

I-Asia

Lapha kuneenarha ezima-49, ezifaka hlagana I inarha ye China, India Kanye ne Russia ekuyinarha ekulu ukuzidlula zoke ephasini. Inarhakazi le ngekulu ukuzidlula zoke ephasini




[[Isimumathi:Australia satellite plane.jpg|left|thumb|188x188px|Inarha ye-&quot;Australia&quot;]]
I-Australia

I-Australia

Le yinarhakazi encani ehlalwa babantu ephasini, ngaphakathi iineenarha ezi-6 ezine zazo yi- New Zealad, Papua New Guiea ne Australia.


[[Isimumathi:Europe and the European Union.svg|left|thumb|184x184px|Inarha ye-&quot;Europe&quot;]]



I-Europe

Kulenarhakazi kunenarha ezima-50 ezifaka I- Germany, iFrance, ne-United kingdom.Inarhakazi le ngeyesithandathu ekulu



[[Isimumathi:North America physical map blank.jpg|left|thumb|190x190px|Inarha ye-&quot;North America&quot;]]



I-North America

Inarhakazi le ilikhaya leenarha ezima-23 begodu ingeyesithathu ekulu.



[[Isimumathi:South america tr.jpg|left|thumb|242x242px|Inarha ye-&quot;South America&quot;]]





I-South America

Inarhakazi le ineenarha ezili-12 begodu ingee ingeyesine ekule eenarhakazini



=== Iinkomba ===
# Yearwood, P.J., 2014. Continents and consequences: the history of a concept. ''Journal of Global History'', ''9''(3), pp.329-356.
# Khapoya, V., 2015. ''The African Experience''. Routledge.
# Prange, C., 2019. Asia: The continent of superlatives and contradictions. In ''Management Practices in Asia: Case Studies on Market Entry, CSR, and Coaching'' (pp. 3-9). Cham: Springer International Publishing</text>
      <sha1>kc952bibyp3ees12s53fbhh0t9dss3s</sha1>
    </revision>
    <revision>
      <id>5531</id>
      <parentid>5529</parentid>
      <timestamp>2025-09-04T09:26:04Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <origin>5531</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2282" sha1="bfpohrohiccwjm6r6z1qhe35uhr9dtp" xml:space="preserve">'''page 1: Draft space 1'''

== Iinarhakazi zephasi ==
'''Ephasini''' kuneenarhakazi ezilikhomba, enye nenye inarhakazi inamasiko wayo, amatshwayo wayo neenarha ezingaphakthi kwayo
Iinarhakazi zephasi.

=== Amagama weenarhakazi zephasi nehlathululo yazo ===
[[Isimumathi:Africa and Europe from a Million Miles Away.png|left|thumb|184x184px|inarhakazi yeAfrika]]



I-Africa

Yinarhakazi yesibili ekulu begodu ngaphakathi iphethe inarha ezima-55 ezifaka hlangana

i-Sewula Africa, i-gibhithe neZimbabwe



[[Isimumathi:Mt Herschel, Antarctica, Jan 2006.jpg|left|thumb|191x191px|Inarha ye-&quot;Antarctica&quot;]]





I-Antarctica

Yinarhakazi encani begodu emakhaza ukuzidlula zoke. Enarhakazini le akuhlali abantu kodwana kuhlala iinlwana zemangweni kwaphela.


[[Isimumathi:Asia satellite orthographic.jpg|left|thumb|195x195px|Inarha ye-&quot;Asia&quot;]]

I-Asia

Lapha kuneenarha ezima-49, ezifaka hlagana I inarha ye China, India Kanye ne Russia ekuyinarha ekulu ukuzidlula zoke ephasini. Inarhakazi le ngekulu ukuzidlula zoke ephasini




[[Isimumathi:Australia satellite plane.jpg|left|thumb|188x188px|Inarha ye-&quot;Australia&quot;]]I-Australia

Le yinarhakazi encani ehlalwa babantu ephasini, ngaphakathi iineenarha ezi-6 ezine zazo yi- New Zealad, Papua New Guiea ne Australia.


[[Isimumathi:Europe and the European Union.svg|left|thumb|184x184px|Inarha ye-&quot;Europe&quot;]]



I-Europe

Kulenarhakazi kunenarha ezima-50 ezifaka I- Germany, iFrance, ne-United kingdom.Inarhakazi le ngeyesithandathu ekulu



[[Isimumathi:North America physical map blank.jpg|left|thumb|190x190px|Inarha ye-&quot;North America&quot;]]



I-North America

Inarhakazi le ilikhaya leenarha ezima-23 begodu ingeyesithathu ekulu.



[[Isimumathi:South america tr.jpg|left|thumb|242x242px|Inarha ye-&quot;South America&quot;]]





I-South America

Inarhakazi le ineenarha ezili-12 begodu ingee ingeyesine ekule eenarhakazini





=== Iinkomba ===
# Yearwood, P.J., 2014. Continents and consequences: the history of a concept. ''Journal of Global History'', ''9''(3), pp.329-356.
# Khapoya, V., 2015. ''The African Experience''. Routledge.
# Prange, C., 2019. Asia: The continent of superlatives and contradictions. In ''Management Practices in Asia: Case Studies on Market Entry, CSR, and Coaching'' (pp. 3-9). Cham: Springer International Publishing</text>
      <sha1>bfpohrohiccwjm6r6z1qhe35uhr9dtp</sha1>
    </revision>
    <revision>
      <id>5543</id>
      <parentid>5531</parentid>
      <timestamp>2025-09-04T09:34:06Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <minor />
      <comment>umthombo lwazi</comment>
      <origin>5543</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2541" sha1="967lxbx6n2zp4wirqj6x0tu6yzwmcd6" xml:space="preserve">'''page 1: Draft space 1'''

== Iinarhakazi zephasi ==
'''Ephasini''' kuneenarhakazi ezilikhomba, enye nenye inarhakazi inamasiko wayo, amatshwayo wayo neenarha ezingaphakthi kwayo
Iinarhakazi zephasi.

=== Amagama weenarhakazi zephasi nehlathululo yazo ===
[[Isimumathi:Africa and Europe from a Million Miles Away.png|left|thumb|184x184px|inarhakazi yeAfrika]]



I-Africa

Yinarhakazi yesibili ekulu begodu ngaphakathi iphethe inarha ezima-55 ezifaka hlangana

i-Sewula Africa, i-gibhithe neZimbabwe



[[Isimumathi:Mt Herschel, Antarctica, Jan 2006.jpg|left|thumb|191x191px|Inarha ye-&quot;Antarctica&quot;]]





I-Antarctica

Yinarhakazi encani begodu emakhaza ukuzidlula zoke. Enarhakazini le akuhlali abantu kodwana kuhlala iinlwana zemangweni kwaphela.


[[Isimumathi:Asia satellite orthographic.jpg|left|thumb|195x195px|Inarha ye-&quot;Asia&quot;]]

I-Asia

Lapha kuneenarha ezima-49, ezifaka hlagana I inarha ye China, India Kanye ne Russia ekuyinarha ekulu ukuzidlula zoke ephasini. Inarhakazi le ngekulu ukuzidlula zoke ephasini




[[Isimumathi:Australia satellite plane.jpg|left|thumb|188x188px|Inarha ye-&quot;Australia&quot;]]I-Australia

Le yinarhakazi encani ehlalwa babantu ephasini, ngaphakathi iineenarha ezi-6 ezine zazo yi- New Zealad, Papua New Guiea ne Australia.


[[Isimumathi:Europe and the European Union.svg|left|thumb|184x184px|Inarha ye-&quot;Europe&quot;]]



I-Europe

Kulenarhakazi kunenarha ezima-50 ezifaka I- Germany, iFrance, ne-United kingdom.Inarhakazi le ngeyesithandathu ekulu



[[Isimumathi:North America physical map blank.jpg|left|thumb|190x190px|Inarha ye-&quot;North America&quot;]]



I-North America

Inarhakazi le ilikhaya leenarha ezima-23 begodu ingeyesithathu ekulu.



[[Isimumathi:South america tr.jpg|left|thumb|242x242px|Inarha ye-&quot;South America&quot;]]





I-South America

Inarhakazi le ineenarha ezili-12 begodu ingee ingeyesine ekule eenarhakazini






=== Imithombo Lwazi ===

# [https://www.cambridge.org/core/journals/journal-of-global-history/article/abs/continents-and-consequences-the-history-of-a-concept/13ECF8CEEB508069D4372266DA9C87A8 Continents and consequences: the history of a concept | Journal of Global History | Cambridge Core]
# [https://www.taylorfrancis.com/books/edit/10.4324/9781315662596/african-experience-vincent-khapoya The African Experience | Vincent B. Khapoya | Taylor &amp; Francis eBooks,]. 
# Prange, C., 2019. Asia: The continent of superlatives and contradictions. In ''Management Practices in Asia: Case Studies on Market Entry, CSR, and Coaching'' (pp. 3-9). Cham: Springer International Publishing</text>
      <sha1>967lxbx6n2zp4wirqj6x0tu6yzwmcd6</sha1>
    </revision>
    <revision>
      <id>5550</id>
      <parentid>5543</parentid>
      <timestamp>2025-09-04T09:36:52Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <comment>added</comment>
      <origin>5550</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2562" sha1="nte25b8wd0jiejnin801gjfv4q1kw7o" xml:space="preserve">'''page 1: Draft space 1 -''' Editing an article

== Iinarhakazi zephasi ==
'''Ephasini''' kuneenarhakazi ezilikhomba, enye nenye inarhakazi inamasiko wayo, amatshwayo wayo neenarha ezingaphakthi kwayo
Iinarhakazi zephasi.

=== Amagama weenarhakazi zephasi nehlathululo yazo ===
[[Isimumathi:Africa and Europe from a Million Miles Away.png|left|thumb|184x184px|inarhakazi yeAfrika]]



I-Africa

Yinarhakazi yesibili ekulu begodu ngaphakathi iphethe inarha ezima-55 ezifaka hlangana

i-Sewula Africa, i-gibhithe neZimbabwe



[[Isimumathi:Mt Herschel, Antarctica, Jan 2006.jpg|left|thumb|191x191px|Inarha ye-&quot;Antarctica&quot;]]





I-Antarctica

Yinarhakazi encani begodu emakhaza ukuzidlula zoke. Enarhakazini le akuhlali abantu kodwana kuhlala iinlwana zemangweni kwaphela.


[[Isimumathi:Asia satellite orthographic.jpg|left|thumb|195x195px|Inarha ye-&quot;Asia&quot;]]

I-Asia

Lapha kuneenarha ezima-49, ezifaka hlagana I inarha ye China, India Kanye ne Russia ekuyinarha ekulu ukuzidlula zoke ephasini. Inarhakazi le ngekulu ukuzidlula zoke ephasini




[[Isimumathi:Australia satellite plane.jpg|left|thumb|188x188px|Inarha ye-&quot;Australia&quot;]]I-Australia

Le yinarhakazi encani ehlalwa babantu ephasini, ngaphakathi iineenarha ezi-6 ezine zazo yi- New Zealad, Papua New Guiea ne Australia.


[[Isimumathi:Europe and the European Union.svg|left|thumb|184x184px|Inarha ye-&quot;Europe&quot;]]



I-Europe

Kulenarhakazi kunenarha ezima-50 ezifaka I- Germany, iFrance, ne-United kingdom.Inarhakazi le ngeyesithandathu ekulu



[[Isimumathi:North America physical map blank.jpg|left|thumb|190x190px|Inarha ye-&quot;North America&quot;]]



I-North America

Inarhakazi le ilikhaya leenarha ezima-23 begodu ingeyesithathu ekulu.



[[Isimumathi:South america tr.jpg|left|thumb|242x242px|Inarha ye-&quot;South America&quot;]]





I-South America

Inarhakazi le ineenarha ezili-12 begodu ingee ingeyesine ekule eenarhakazini






=== Imithombo Lwazi ===

# [https://www.cambridge.org/core/journals/journal-of-global-history/article/abs/continents-and-consequences-the-history-of-a-concept/13ECF8CEEB508069D4372266DA9C87A8 Continents and consequences: the history of a concept | Journal of Global History | Cambridge Core]
# [https://www.taylorfrancis.com/books/edit/10.4324/9781315662596/african-experience-vincent-khapoya The African Experience | Vincent B. Khapoya | Taylor &amp; Francis eBooks,]. 
# Prange, C., 2019. Asia: The continent of superlatives and contradictions. In ''Management Practices in Asia: Case Studies on Market Entry, CSR, and Coaching'' (pp. 3-9). Cham: Springer International Publishing</text>
      <sha1>nte25b8wd0jiejnin801gjfv4q1kw7o</sha1>
    </revision>
    <revision>
      <id>5559</id>
      <parentid>5550</parentid>
      <timestamp>2025-09-04T09:42:19Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <minor />
      <comment>added links</comment>
      <origin>5559</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2503" sha1="1n9wmilsz6gw3zs45l4v63xwgzg8exz" xml:space="preserve">'''page 1: Draft space 1 -''' Editing an article

== Iinarhakazi zephasi ==
'''Ephasini''' kuneenarhakazi ezilikhomba, enye nenye inarhakazi inamasiko wayo, amatshwayo wayo neenarha ezingaphakthi kwayo
Iinarhakazi zephasi.

=== Amagama weenarhakazi zephasi nehlathululo yazo ===
[[Isimumathi:Africa and Europe from a Million Miles Away.png|left|thumb|184x184px|inarhakazi yeAfrika]]



I-Africa

Yinarhakazi yesibili ekulu begodu ngaphakathi iphethe inarha ezima-55 ezifaka hlangana

i-Sewula Africa, i-gibhithe neZimbabwe



[[Isimumathi:Mt Herschel, Antarctica, Jan 2006.jpg|left|thumb|191x191px|Inarha ye-&quot;Antarctica&quot;]]


I-Antarctica

Yinarhakazi encani begodu emakhaza ukuzidlula zoke. Enarhakazini le akuhlali abantu kodwana kuhlala iinlwana zemangweni kwaphela.


[[Isimumathi:Asia satellite orthographic.jpg|left|thumb|195x195px|Inarha ye-&quot;Asia&quot;]]



I-Asia

Lapha kuneenarha ezima-49, ezifaka hlagana I inarha ye China, India Kanye ne Russia ekuyinarha ekulu ukuzidlula zoke ephasini. Inarhakazi le ngekulu ukuzidlula zoke ephasini


[[Isimumathi:Australia satellite plane.jpg|left|thumb|188x188px|Inarha ye-&quot;Australia&quot;]]


I-Australia

Le yinarhakazi encani ehlalwa babantu ephasini, ngaphakathi iineenarha ezi-6 ezine zazo yi- New Zealad, Papua New Guiea ne Australia.


[[Isimumathi:Europe and the European Union.svg|left|thumb|184x184px|Inarha ye-&quot;Europe&quot;]]



I-Europe

Kulenarhakazi kunenarha ezima-50 ezifaka I- Germany, iFrance, ne-United kingdom.Inarhakazi le ngeyesithandathu ekulu



[[Isimumathi:North America physical map blank.jpg|left|thumb|190x190px|Inarha ye-&quot;North America&quot;]]



I-North America

Inarhakazi le ilikhaya leenarha ezima-23 begodu ingeyesithathu ekulu.



[[Isimumathi:South america tr.jpg|left|thumb|242x242px|Inarha ye-&quot;South America&quot;]]





I-South America

Inarhakazi le ineenarha ezili-12 begodu ingee ingeyesine ekule eenarhakazini





=== Imithombo Lwazi ===

# [https://www.cambridge.org/core/journals/journal-of-global-history/article/abs/continents-and-consequences-the-history-of-a-concept/13ECF8CEEB508069D4372266DA9C87A8 Continents and consequences: the history of a concept | Journal of Global History | Cambridge Core]
# [https://www.taylorfrancis.com/books/edit/10.4324/9781315662596/african-experience-vincent-khapoya The African Experience | Vincent B. Khapoya | Taylor &amp; Francis eBooks,]. 
# [https://link.springer.com/book/10.1007/978-3-030-19662-2 Management Practices in Asia: Case Studies on Market Entry, CSR, and Coaching | SpringerLink]</text>
      <sha1>1n9wmilsz6gw3zs45l4v63xwgzg8exz</sha1>
    </revision>
    <revision>
      <id>5565</id>
      <parentid>5559</parentid>
      <timestamp>2025-09-04T09:45:55Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <origin>5565</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2500" sha1="cprr1pxt814x6hfzq5e4dmkej0fk5dc" xml:space="preserve">'''page 1: Draft space 1 -''' Editing an article

== Iinarhakazi zephasi ==
'''Ephasini''' kuneenarhakazi ezilikhomba, enye nenye inarhakazi inamasiko wayo, amatshwayo wayo neenarha ezingaphakthi kwayo
Iinarhakazi zephasi.

=== Amagama weenarhakazi zephasi nehlathululo yazo ===
[[Isimumathi:Africa and Europe from a Million Miles Away.png|left|thumb|184x184px|inarhakazi yeAfrika]]



I-Africa

Yinarhakazi yesibili ekulu begodu ngaphakathi iphethe inarha ezima-55 ezifaka hlangana

i-Sewula Africa, i-gibhithe neZimbabwe



[[Isimumathi:Mt Herschel, Antarctica, Jan 2006.jpg|left|thumb|191x191px|Inarha ye-&quot;Antarctica&quot;]]


I-Antarctica

Yinarhakazi encani begodu emakhaza ukuzidlula zoke. Enarhakazini le akuhlali abantu kodwana kuhlala iinlwana zemangweni kwaphela.


[[Isimumathi:Asia satellite orthographic.jpg|left|thumb|195x195px|Inarha ye-&quot;Asia&quot;]]



I-Asia

Lapha kuneenarha ezima-49, ezifaka hlagana I inarha ye China, India Kanye ne Russia ekuyinarha ekulu ukuzidlula zoke ephasini. Inarhakazi le ngekulu ukuzidlula zoke ephasini


[[Isimumathi:Australia satellite plane.jpg|left|thumb|188x188px|Inarha ye-&quot;Australia&quot;]]


I-Australia

Le yinarhakazi encani ehlalwa babantu ephasini, ngaphakathi iineenarha ezi-6 ezine zazo yi- New Zealad, Papua New Guiea ne Australia.


[[Isimumathi:Europe and the European Union.svg|left|thumb|184x184px|Inarha ye-&quot;Europe&quot;]]



I-Europe

Kulenarhakazi kunenarha ezima-50 ezifaka I- Germany, iFrance, ne-United kingdom.Inarhakazi le ngeyesithandathu ekulu



[[Isimumathi:North America physical map blank.jpg|left|thumb|190x190px|Inarha ye-&quot;North America&quot;]]



I-North America

Inarhakazi le ilikhaya leenarha ezima-23 begodu ingeyesithathu ekulu.



[[Isimumathi:South america tr.jpg|left|thumb|242x242px|Inarha ye-&quot;South America&quot;]]





I-South America

Inarhakazi le ineenarha ezili-12 begodu ingee ingeyesine ekule eenarhakazini





== Imithombo Lwazi ==
# [https://www.cambridge.org/core/journals/journal-of-global-history/article/abs/continents-and-consequences-the-history-of-a-concept/13ECF8CEEB508069D4372266DA9C87A8 Continents and consequences: the history of a concept | Journal of Global History | Cambridge Core]
# [https://www.taylorfrancis.com/books/edit/10.4324/9781315662596/african-experience-vincent-khapoya The African Experience | Vincent B. Khapoya | Taylor &amp; Francis eBooks,]. 
# [https://link.springer.com/book/10.1007/978-3-030-19662-2 Management Practices in Asia: Case Studies on Market Entry, CSR, and Coaching | SpringerLink]</text>
      <sha1>cprr1pxt814x6hfzq5e4dmkej0fk5dc</sha1>
    </revision>
    <revision>
      <id>5575</id>
      <parentid>5565</parentid>
      <timestamp>2025-09-04T09:52:35Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <origin>5575</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2939" sha1="abww814rav433vn93lcm7whpx6qktme" xml:space="preserve">'''page 1: Draft space 1 -''' Editing an article

== Iinarhakazi zephasi ==
'''Ephasini''' kuneenarhakazi ezilikhomba, enye nenye inarhakazi inamasiko wayo, amatshwayo wayo neenarha ezingaphakthi kwayo
Iinarhakazi zephasi.&lt;/nowiki&gt;&lt;ref&gt;{{Cite journal |last=Yearwood |first=Peter J. |date=2014 |title=Continents and consequences: the history of a concept |url=https://www.cambridge.org/core/journals/journal-of-global-history/article/abs/continents-and-consequences-the-history-of-a-concept/13ECF8CEEB508069D4372266DA9C87A8 |journal=Journal of Global History |language=en |volume=9 |issue=3 |pages=329–356 |doi=10.1017/S1740022814000151 |issn=1740-0228}}&lt;/ref&gt;

=== Amagama weenarhakazi zephasi nehlathululo yazo ===
[[Isimumathi:Africa and Europe from a Million Miles Away.png|left|thumb|184x184px|inarhakazi yeAfrika]]



I-Africa

Yinarhakazi yesibili ekulu begodu ngaphakathi iphethe inarha ezima-55 ezifaka hlangana

i-Sewula Africa, i-gibhithe neZimbabwe



[[Isimumathi:Mt Herschel, Antarctica, Jan 2006.jpg|left|thumb|191x191px|Inarha ye-&quot;Antarctica&quot;]]


I-Antarctica

Yinarhakazi encani begodu emakhaza ukuzidlula zoke. Enarhakazini le akuhlali abantu kodwana kuhlala iinlwana zemangweni kwaphela.


[[Isimumathi:Asia satellite orthographic.jpg|left|thumb|195x195px|Inarha ye-&quot;Asia&quot;]]



I-Asia

Lapha kuneenarha ezima-49, ezifaka hlagana I inarha ye China, India Kanye ne Russia ekuyinarha ekulu ukuzidlula zoke ephasini. Inarhakazi le ngekulu ukuzidlula zoke ephasini


[[Isimumathi:Australia satellite plane.jpg|left|thumb|188x188px|Inarha ye-&quot;Australia&quot;]]


I-Australia

Le yinarhakazi encani ehlalwa babantu ephasini, ngaphakathi iineenarha ezi-6 ezine zazo yi- New Zealad, Papua New Guiea ne Australia.


[[Isimumathi:Europe and the European Union.svg|left|thumb|184x184px|Inarha ye-&quot;Europe&quot;]]



I-Europe

Kulenarhakazi kunenarha ezima-50 ezifaka I- Germany, iFrance, ne-United kingdom.Inarhakazi le ngeyesithandathu ekulu



[[Isimumathi:North America physical map blank.jpg|left|thumb|190x190px|Inarha ye-&quot;North America&quot;]]



I-North America

Inarhakazi le ilikhaya leenarha ezima-23 begodu ingeyesithathu ekulu.



[[Isimumathi:South america tr.jpg|left|thumb|242x242px|Inarha ye-&quot;South America&quot;]]





I-South America

Inarhakazi le ineenarha ezili-12 begodu ingee ingeyesine ekule eenarhakazini





== Imithombo Lwazi ==
# [https://www.cambridge.org/core/journals/journal-of-global-history/article/abs/continents-and-consequences-the-history-of-a-concept/13ECF8CEEB508069D4372266DA9C87A8 Continents and consequences: the history of a concept | Journal of Global History | Cambridge Core]
# [https://www.taylorfrancis.com/books/edit/10.4324/9781315662596/african-experience-vincent-khapoya The African Experience | Vincent B. Khapoya | Taylor &amp; Francis eBooks,]. 
# [https://link.springer.com/book/10.1007/978-3-030-19662-2 Management Practices in Asia: Case Studies on Market Entry, CSR, and Coaching | SpringerLink]</text>
      <sha1>abww814rav433vn93lcm7whpx6qktme</sha1>
    </revision>
    <revision>
      <id>5576</id>
      <parentid>5575</parentid>
      <timestamp>2025-09-04T09:53:00Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <origin>5576</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2930" sha1="ecvwi9inex9yd9s77avqpdqtsr12vuc" xml:space="preserve">'''page 1: Draft space 1 -''' Editing an article

== Iinarhakazi zephasi ==
'''Ephasini''' kuneenarhakazi ezilikhomba, enye nenye inarhakazi inamasiko wayo, amatshwayo wayo neenarha ezingaphakthi kwayo
Iinarhakazi zephasi.&lt;ref&gt;{{Cite journal |last=Yearwood |first=Peter J. |date=2014 |title=Continents and consequences: the history of a concept |url=https://www.cambridge.org/core/journals/journal-of-global-history/article/abs/continents-and-consequences-the-history-of-a-concept/13ECF8CEEB508069D4372266DA9C87A8 |journal=Journal of Global History |language=en |volume=9 |issue=3 |pages=329–356 |doi=10.1017/S1740022814000151 |issn=1740-0228}}&lt;/ref&gt;

=== Amagama weenarhakazi zephasi nehlathululo yazo ===
[[Isimumathi:Africa and Europe from a Million Miles Away.png|left|thumb|184x184px|inarhakazi yeAfrika]]



I-Africa

Yinarhakazi yesibili ekulu begodu ngaphakathi iphethe inarha ezima-55 ezifaka hlangana

i-Sewula Africa, i-gibhithe neZimbabwe



[[Isimumathi:Mt Herschel, Antarctica, Jan 2006.jpg|left|thumb|191x191px|Inarha ye-&quot;Antarctica&quot;]]


I-Antarctica

Yinarhakazi encani begodu emakhaza ukuzidlula zoke. Enarhakazini le akuhlali abantu kodwana kuhlala iinlwana zemangweni kwaphela.


[[Isimumathi:Asia satellite orthographic.jpg|left|thumb|195x195px|Inarha ye-&quot;Asia&quot;]]



I-Asia

Lapha kuneenarha ezima-49, ezifaka hlagana I inarha ye China, India Kanye ne Russia ekuyinarha ekulu ukuzidlula zoke ephasini. Inarhakazi le ngekulu ukuzidlula zoke ephasini


[[Isimumathi:Australia satellite plane.jpg|left|thumb|188x188px|Inarha ye-&quot;Australia&quot;]]


I-Australia

Le yinarhakazi encani ehlalwa babantu ephasini, ngaphakathi iineenarha ezi-6 ezine zazo yi- New Zealad, Papua New Guiea ne Australia.


[[Isimumathi:Europe and the European Union.svg|left|thumb|184x184px|Inarha ye-&quot;Europe&quot;]]



I-Europe

Kulenarhakazi kunenarha ezima-50 ezifaka I- Germany, iFrance, ne-United kingdom.Inarhakazi le ngeyesithandathu ekulu



[[Isimumathi:North America physical map blank.jpg|left|thumb|190x190px|Inarha ye-&quot;North America&quot;]]



I-North America

Inarhakazi le ilikhaya leenarha ezima-23 begodu ingeyesithathu ekulu.



[[Isimumathi:South america tr.jpg|left|thumb|242x242px|Inarha ye-&quot;South America&quot;]]





I-South America

Inarhakazi le ineenarha ezili-12 begodu ingee ingeyesine ekule eenarhakazini





== Imithombo Lwazi ==
# [https://www.cambridge.org/core/journals/journal-of-global-history/article/abs/continents-and-consequences-the-history-of-a-concept/13ECF8CEEB508069D4372266DA9C87A8 Continents and consequences: the history of a concept | Journal of Global History | Cambridge Core]
# [https://www.taylorfrancis.com/books/edit/10.4324/9781315662596/african-experience-vincent-khapoya The African Experience | Vincent B. Khapoya | Taylor &amp; Francis eBooks,]. 
# [https://link.springer.com/book/10.1007/978-3-030-19662-2 Management Practices in Asia: Case Studies on Market Entry, CSR, and Coaching | SpringerLink]</text>
      <sha1>ecvwi9inex9yd9s77avqpdqtsr12vuc</sha1>
    </revision>
    <revision>
      <id>5578</id>
      <parentid>5576</parentid>
      <timestamp>2025-09-04T09:53:55Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <origin>5578</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2500" sha1="btwlw91ex5ke8xo2dusy0rg2ibsxb7c" xml:space="preserve">'''page 1: Draft space 1 -''' Editing an article

== Iinarhakazi zephasi ==
'''Ephasini''' kuneenarhakazi ezilikhomba, enye nenye inarhakazi inamasiko wayo, amatshwayo wayo neenarha ezingaphakthi kwayo
Iinarhakazi zephasi.

=== Amagama weenarhakazi zephasi nehlathululo yazo ===
[[Isimumathi:Africa and Europe from a Million Miles Away.png|left|thumb|184x184px|inarhakazi yeAfrika]]



I-Africa

Yinarhakazi yesibili ekulu begodu ngaphakathi iphethe inarha ezima-55 ezifaka hlangana

i-Sewula Africa, i-gibhithe neZimbabwe



[[Isimumathi:Mt Herschel, Antarctica, Jan 2006.jpg|left|thumb|191x191px|Inarha ye-&quot;Antarctica&quot;]]


I-Antarctica

Yinarhakazi encani begodu emakhaza ukuzidlula zoke. Enarhakazini le akuhlali abantu kodwana kuhlala iinlwana zemangweni kwaphela.


[[Isimumathi:Asia satellite orthographic.jpg|left|thumb|195x195px|Inarha ye-&quot;Asia&quot;]]



I-Asia

Lapha kuneenarha ezima-49, ezifaka hlagana I inarha ye China, India Kanye ne Russia ekuyinarha ekulu ukuzidlula zoke ephasini. Inarhakazi le ngekulu ukuzidlula zoke ephasini


[[Isimumathi:Australia satellite plane.jpg|left|thumb|188x188px|Inarha ye-&quot;Australia&quot;]]


I-Australia

Le yinarhakazi encani ehlalwa babantu ephasini, ngaphakathi iineenarha ezi-6 ezine zazo yi- New Zealad, Papua New Guiea ne Australia.


[[Isimumathi:Europe and the European Union.svg|left|thumb|184x184px|Inarha ye-&quot;Europe&quot;]]



I-Europe

Kulenarhakazi kunenarha ezima-50 ezifaka I- Germany, iFrance, ne-United kingdom.Inarhakazi le ngeyesithandathu ekulu



[[Isimumathi:North America physical map blank.jpg|left|thumb|190x190px|Inarha ye-&quot;North America&quot;]]



I-North America

Inarhakazi le ilikhaya leenarha ezima-23 begodu ingeyesithathu ekulu.



[[Isimumathi:South america tr.jpg|left|thumb|242x242px|Inarha ye-&quot;South America&quot;]]





I-South America

Inarhakazi le ineenarha ezili-12 begodu ingee ingeyesine ekule eenarhakazini

*[https://www.cambridge.org/core/journals/journal-of-global-history/article/abs/continents-and-consequences-the-history-of-a-concept/13ECF8CEEB508069D4372266DA9C87A8 Continents and consequences: the history of a concept | Journal of Global History | Cambridge Core]
* [https://www.taylorfrancis.com/books/edit/10.4324/9781315662596/african-experience-vincent-khapoya The African Experience | Vincent B. Khapoya | Taylor &amp; Francis eBooks,].
* [https://link.springer.com/book/10.1007/978-3-030-19662-2 Management Practices in Asia: Case Studies on Market Entry, CSR, and Coaching | SpringerLink]






== Imithombo Lwazi ==</text>
      <sha1>btwlw91ex5ke8xo2dusy0rg2ibsxb7c</sha1>
    </revision>
    <revision>
      <id>5580</id>
      <parentid>5578</parentid>
      <timestamp>2025-09-04T09:54:21Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <origin>5580</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2501" sha1="32540zg4i8brfl009vw13on53kmww86" xml:space="preserve">'''page 1: Draft space 1 -''' Editing an article

== Iinarhakazi zephasi ==
'''Ephasini''' kuneenarhakazi ezilikhomba, enye nenye inarhakazi inamasiko wayo, amatshwayo wayo neenarha ezingaphakthi kwayo
Iinarhakazi zephasi.

=== Amagama weenarhakazi zephasi nehlathululo yazo ===
[[Isimumathi:Africa and Europe from a Million Miles Away.png|left|thumb|184x184px|inarhakazi yeAfrika]]



I-Africa

Yinarhakazi yesibili ekulu begodu ngaphakathi iphethe inarha ezima-55 ezifaka hlangana

i-Sewula Africa, i-gibhithe neZimbabwe



[[Isimumathi:Mt Herschel, Antarctica, Jan 2006.jpg|left|thumb|191x191px|Inarha ye-&quot;Antarctica&quot;]]


I-Antarctica

Yinarhakazi encani begodu emakhaza ukuzidlula zoke. Enarhakazini le akuhlali abantu kodwana kuhlala iinlwana zemangweni kwaphela.


[[Isimumathi:Asia satellite orthographic.jpg|left|thumb|195x195px|Inarha ye-&quot;Asia&quot;]]



I-Asia

Lapha kuneenarha ezima-49, ezifaka hlagana I inarha ye China, India Kanye ne Russia ekuyinarha ekulu ukuzidlula zoke ephasini. Inarhakazi le ngekulu ukuzidlula zoke ephasini


[[Isimumathi:Australia satellite plane.jpg|left|thumb|188x188px|Inarha ye-&quot;Australia&quot;]]


I-Australia

Le yinarhakazi encani ehlalwa babantu ephasini, ngaphakathi iineenarha ezi-6 ezine zazo yi- New Zealad, Papua New Guiea ne Australia.


[[Isimumathi:Europe and the European Union.svg|left|thumb|184x184px|Inarha ye-&quot;Europe&quot;]]



I-Europe

Kulenarhakazi kunenarha ezima-50 ezifaka I- Germany, iFrance, ne-United kingdom.Inarhakazi le ngeyesithandathu ekulu



[[Isimumathi:North America physical map blank.jpg|left|thumb|190x190px|Inarha ye-&quot;North America&quot;]]



I-North America

Inarhakazi le ilikhaya leenarha ezima-23 begodu ingeyesithathu ekulu.



[[Isimumathi:South america tr.jpg|left|thumb|242x242px|Inarha ye-&quot;South America&quot;]]





I-South America

Inarhakazi le ineenarha ezili-12 begodu ingee ingeyesine ekule eenarhakazini

*[https://www.cambridge.org/core/journals/journal-of-global-history/article/abs/continents-and-consequences-the-history-of-a-concept/13ECF8CEEB508069D4372266DA9C87A8 Continents and consequences: the history of a concept | Journal of Global History | Cambridge Core]
* [https://www.taylorfrancis.com/books/edit/10.4324/9781315662596/african-experience-vincent-khapoya The African Experience | Vincent B. Khapoya | Taylor &amp; Francis eBooks,].
* [https://link.springer.com/book/10.1007/978-3-030-19662-2 Management Practices in Asia: Case Studies on Market Entry, CSR, and Coaching | SpringerLink]







== Imithombo Lwazi ==</text>
      <sha1>32540zg4i8brfl009vw13on53kmww86</sha1>
    </revision>
    <revision>
      <id>5586</id>
      <parentid>5580</parentid>
      <timestamp>2025-09-04T09:57:05Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <origin>5586</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3098" sha1="lhib8gge548ycxsdpjv1mx6pjiygc5w" xml:space="preserve">'''page 1: Draft space 1 -''' Editing an article

== Iinarhakazi zephasi ==
'''Ephasini''' kuneenarhakazi ezilikhomba, enye nenye inarhakazi inamasiko wayo, amatshwayo wayo neenarha ezingaphakthi kwayo
Iinarhakazi zephasi.&lt;ref&gt;{{Cite journal |last=Yearwood |first=Peter J. |date=2014 |title=Continents and consequences: the history of a concept |url=https://www.cambridge.org/core/journals/journal-of-global-history/article/abs/continents-and-consequences-the-history-of-a-concept/13ECF8CEEB508069D4372266DA9C87A8 |journal=Journal of Global History |language=en |volume=9 |issue=3 |pages=329–356 |doi=10.1017/S1740022814000151 |issn=1740-0228}}&lt;/ref&gt;


The African Experience | Vincent B. Khapoya | Taylor &amp; Francis eBooks,.
Management Practices in Asia: Case Studies on Market Entry, CSR, and Coaching | SpringerLink

=== Amagama weenarhakazi zephasi nehlathululo yazo ===
[[Isimumathi:Africa and Europe from a Million Miles Away.png|left|thumb|184x184px|inarhakazi yeAfrika]]



I-Africa

Yinarhakazi yesibili ekulu begodu ngaphakathi iphethe inarha ezima-55 ezifaka hlangana

i-Sewula Africa, i-gibhithe neZimbabwe



[[Isimumathi:Mt Herschel, Antarctica, Jan 2006.jpg|left|thumb|191x191px|Inarha ye-&quot;Antarctica&quot;]]


I-Antarctica

Yinarhakazi encani begodu emakhaza ukuzidlula zoke. Enarhakazini le akuhlali abantu kodwana kuhlala iinlwana zemangweni kwaphela.


[[Isimumathi:Asia satellite orthographic.jpg|left|thumb|195x195px|Inarha ye-&quot;Asia&quot;]]



I-Asia

Lapha kuneenarha ezima-49, ezifaka hlagana I inarha ye China, India Kanye ne Russia ekuyinarha ekulu ukuzidlula zoke ephasini. Inarhakazi le ngekulu ukuzidlula zoke ephasini


[[Isimumathi:Australia satellite plane.jpg|left|thumb|188x188px|Inarha ye-&quot;Australia&quot;]]


I-Australia

Le yinarhakazi encani ehlalwa babantu ephasini, ngaphakathi iineenarha ezi-6 ezine zazo yi- New Zealad, Papua New Guiea ne Australia.


[[Isimumathi:Europe and the European Union.svg|left|thumb|184x184px|Inarha ye-&quot;Europe&quot;]]



I-Europe

Kulenarhakazi kunenarha ezima-50 ezifaka I- Germany, iFrance, ne-United kingdom.Inarhakazi le ngeyesithandathu ekulu



[[Isimumathi:North America physical map blank.jpg|left|thumb|190x190px|Inarha ye-&quot;North America&quot;]]



I-North America

Inarhakazi le ilikhaya leenarha ezima-23 begodu ingeyesithathu ekulu.



[[Isimumathi:South america tr.jpg|left|thumb|242x242px|Inarha ye-&quot;South America&quot;]]





I-South America

Inarhakazi le ineenarha ezili-12 begodu ingee ingeyesine ekule eenarhakazini

*[https://www.cambridge.org/core/journals/journal-of-global-history/article/abs/continents-and-consequences-the-history-of-a-concept/13ECF8CEEB508069D4372266DA9C87A8 Continents and consequences: the history of a concept | Journal of Global History | Cambridge Core]
* [https://www.taylorfrancis.com/books/edit/10.4324/9781315662596/african-experience-vincent-khapoya The African Experience | Vincent B. Khapoya | Taylor &amp; Francis eBooks,].
* [https://link.springer.com/book/10.1007/978-3-030-19662-2 Management Practices in Asia: Case Studies on Market Entry, CSR, and Coaching | SpringerLink]







== Imithombo Lwazi ==</text>
      <sha1>lhib8gge548ycxsdpjv1mx6pjiygc5w</sha1>
    </revision>
    <revision>
      <id>5589</id>
      <parentid>5586</parentid>
      <timestamp>2025-09-04T09:59:48Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <origin>5589</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3087" sha1="1biqdxxnh4dflty5gdm17j02bxkm1gn" xml:space="preserve">'''page 1: Draft space 1 -''' Editing an article

== Iinarhakazi zephasi ==
'''Ephasini''' kuneenarhakazi ezilikhomba, enye nenye inarhakazi inamasiko wayo, amatshwayo wayo neenarha ezingaphakthi kwayo
Iinarhakazi zephasi.&lt;ref&gt;{{Cite journal|last=Yearwood|first=Peter J.|date=2014|title=Continents and consequences: the history of a concept|url=https://www.cambridge.org/core/journals/journal-of-global-history/article/abs/continents-and-consequences-the-history-of-a-concept/13ECF8CEEB508069D4372266DA9C87A8|journal=Journal of Global History|language=en|volume=9|issue=3|pages=329–356|doi=10.1017/S1740022814000151|issn=1740-0228}}&lt;/ref&gt;



The African Experience | Vincent B. Khapoya | Taylor &amp; Francis eBooks,.
Management Practices in Asia: Case Studies on Market Entry, CSR, and Coaching | SpringerLink

=== Amagama weenarhakazi zephasi nehlathululo yazo ===
[[Isimumathi:Africa and Europe from a Million Miles Away.png|left|thumb|184x184px|inarhakazi yeAfrika]]



I-Africa

Yinarhakazi yesibili ekulu begodu ngaphakathi iphethe inarha ezima-55 ezifaka hlangana

i-Sewula Africa, i-gibhithe neZimbabwe



[[Isimumathi:Mt Herschel, Antarctica, Jan 2006.jpg|left|thumb|191x191px|Inarha ye-&quot;Antarctica&quot;]]


I-Antarctica

Yinarhakazi encani begodu emakhaza ukuzidlula zoke. Enarhakazini le akuhlali abantu kodwana kuhlala iinlwana zemangweni kwaphela.


[[Isimumathi:Asia satellite orthographic.jpg|left|thumb|195x195px|Inarha ye-&quot;Asia&quot;]]



I-Asia

Lapha kuneenarha ezima-49, ezifaka hlagana I inarha ye China, India Kanye ne Russia ekuyinarha ekulu ukuzidlula zoke ephasini. Inarhakazi le ngekulu ukuzidlula zoke ephasini


[[Isimumathi:Australia satellite plane.jpg|left|thumb|188x188px|Inarha ye-&quot;Australia&quot;]]


I-Australia

Le yinarhakazi encani ehlalwa babantu ephasini, ngaphakathi iineenarha ezi-6 ezine zazo yi- New Zealad, Papua New Guiea ne Australia.


[[Isimumathi:Europe and the European Union.svg|left|thumb|184x184px|Inarha ye-&quot;Europe&quot;]]



I-Europe

Kulenarhakazi kunenarha ezima-50 ezifaka I- Germany, iFrance, ne-United kingdom.Inarhakazi le ngeyesithandathu ekulu



[[Isimumathi:North America physical map blank.jpg|left|thumb|190x190px|Inarha ye-&quot;North America&quot;]]



I-North America

Inarhakazi le ilikhaya leenarha ezima-23 begodu ingeyesithathu ekulu.



[[Isimumathi:South america tr.jpg|left|thumb|242x242px|Inarha ye-&quot;South America&quot;]]





I-South America

Inarhakazi le ineenarha ezili-12 begodu ingee ingeyesine ekule eenarhakazini

*[https://www.cambridge.org/core/journals/journal-of-global-history/article/abs/continents-and-consequences-the-history-of-a-concept/13ECF8CEEB508069D4372266DA9C87A8 Continents and consequences: the history of a concept | Journal of Global History | Cambridge Core]
* [https://www.taylorfrancis.com/books/edit/10.4324/9781315662596/african-experience-vincent-khapoya The African Experience | Vincent B. Khapoya | Taylor &amp; Francis eBooks,].
* [https://link.springer.com/book/10.1007/978-3-030-19662-2 Management Practices in Asia: Case Studies on Market Entry, CSR, and Coaching | SpringerLink]







== Imithombo Lwazi ==</text>
      <sha1>1biqdxxnh4dflty5gdm17j02bxkm1gn</sha1>
    </revision>
    <revision>
      <id>5592</id>
      <parentid>5589</parentid>
      <timestamp>2025-09-04T10:06:10Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <origin>5592</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2933" sha1="tupk66v9uwbshxhztgspiejg2lsoxsh" xml:space="preserve">'''page 1: Draft space 1 -''' Editing an article

== Iinarhakazi zephasi ==
'''Ephasini''' kuneenarhakazi ezilikhomba, enye nenye inarhakazi inamasiko wayo, amatshwayo wayo neenarha ezingaphakthi kwayo
Iinarhakazi zephasi.&lt;ref&gt;{{Cite journal |last=Yearwood |first=Peter J. |date=2014-11 |title=Continents and consequences: the history of a concept |url=https://www.cambridge.org/core/journals/journal-of-global-history/article/abs/continents-and-consequences-the-history-of-a-concept/13ECF8CEEB508069D4372266DA9C87A8 |journal=Journal of Global History |language=en |volume=9 |issue=3 |pages=329–356 |doi=10.1017/S1740022814000151 |issn=1740-0228}}&lt;/ref&gt;

=== Amagama weenarhakazi zephasi nehlathululo yazo ===
[[Isimumathi:Africa and Europe from a Million Miles Away.png|left|thumb|184x184px|inarhakazi yeAfrika]]



I-Africa

Yinarhakazi yesibili ekulu begodu ngaphakathi iphethe inarha ezima-55 ezifaka hlangana

i-Sewula Africa, i-gibhithe neZimbabwe



[[Isimumathi:Mt Herschel, Antarctica, Jan 2006.jpg|left|thumb|191x191px|Inarha ye-&quot;Antarctica&quot;]]


I-Antarctica

Yinarhakazi encani begodu emakhaza ukuzidlula zoke. Enarhakazini le akuhlali abantu kodwana kuhlala iinlwana zemangweni kwaphela.


[[Isimumathi:Asia satellite orthographic.jpg|left|thumb|195x195px|Inarha ye-&quot;Asia&quot;]]



I-Asia

Lapha kuneenarha ezima-49, ezifaka hlagana I inarha ye China, India Kanye ne Russia ekuyinarha ekulu ukuzidlula zoke ephasini. Inarhakazi le ngekulu ukuzidlula zoke ephasini


[[Isimumathi:Australia satellite plane.jpg|left|thumb|188x188px|Inarha ye-&quot;Australia&quot;]]


I-Australia

Le yinarhakazi encani ehlalwa babantu ephasini, ngaphakathi iineenarha ezi-6 ezine zazo yi- New Zealad, Papua New Guiea ne Australia.


[[Isimumathi:Europe and the European Union.svg|left|thumb|184x184px|Inarha ye-&quot;Europe&quot;]]



I-Europe

Kulenarhakazi kunenarha ezima-50 ezifaka I- Germany, iFrance, ne-United kingdom.Inarhakazi le ngeyesithandathu ekulu



[[Isimumathi:North America physical map blank.jpg|left|thumb|190x190px|Inarha ye-&quot;North America&quot;]]



I-North America

Inarhakazi le ilikhaya leenarha ezima-23 begodu ingeyesithathu ekulu.



[[Isimumathi:South america tr.jpg|left|thumb|242x242px|Inarha ye-&quot;South America&quot;]]





I-South America

Inarhakazi le ineenarha ezili-12 begodu ingee ingeyesine ekule eenarhakazini





== Imithombo Lwazi ==
# [https://www.cambridge.org/core/journals/journal-of-global-history/article/abs/continents-and-consequences-the-history-of-a-concept/13ECF8CEEB508069D4372266DA9C87A8 Continents and consequences: the history of a concept | Journal of Global History | Cambridge Core]
# [https://www.taylorfrancis.com/books/edit/10.4324/9781315662596/african-experience-vincent-khapoya The African Experience | Vincent B. Khapoya | Taylor &amp; Francis eBooks,]. 
# [https://link.springer.com/book/10.1007/978-3-030-19662-2 Management Practices in Asia: Case Studies on Market Entry, CSR, and Coaching | SpringerLink]</text>
      <sha1>tupk66v9uwbshxhztgspiejg2lsoxsh</sha1>
    </revision>
    <revision>
      <id>5593</id>
      <parentid>5592</parentid>
      <timestamp>2025-09-04T10:08:19Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <origin>5593</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2491" sha1="8pvo5vpjrqpsj2p8sp8qttsrr09ac1z" xml:space="preserve">'''page 1: Draft space 1 -''' Editing an article

== Iinarhakazi zephasi ==
'''Ephasini''' kuneenarhakazi ezilikhomba, enye nenye inarhakazi inamasiko wayo, amatshwayo wayo neenarha ezingaphakthi kwayo
Iinarhakazi zephasi.

Amagama weenarhakazi zephasi nehlathululo yazo[[Isimumathi:Africa and Europe from a Million Miles Away.png|left|thumb|184x184px|inarhakazi yeAfrika]]



I-Africa

Yinarhakazi yesibili ekulu begodu ngaphakathi iphethe inarha ezima-55 ezifaka hlangana

i-Sewula Africa, i-gibhithe neZimbabwe



[[Isimumathi:Mt Herschel, Antarctica, Jan 2006.jpg|left|thumb|191x191px|Inarha ye-&quot;Antarctica&quot;]]


I-Antarctica

Yinarhakazi encani begodu emakhaza ukuzidlula zoke. Enarhakazini le akuhlali abantu kodwana kuhlala iinlwana zemangweni kwaphela.


[[Isimumathi:Asia satellite orthographic.jpg|left|thumb|195x195px|Inarha ye-&quot;Asia&quot;]]



I-Asia

Lapha kuneenarha ezima-49, ezifaka hlagana I inarha ye China, India Kanye ne Russia ekuyinarha ekulu ukuzidlula zoke ephasini. Inarhakazi le ngekulu ukuzidlula zoke ephasini


[[Isimumathi:Australia satellite plane.jpg|left|thumb|188x188px|Inarha ye-&quot;Australia&quot;]]


I-Australia

Le yinarhakazi encani ehlalwa babantu ephasini, ngaphakathi iineenarha ezi-6 ezine zazo yi- New Zealad, Papua New Guiea ne Australia.


[[Isimumathi:Europe and the European Union.svg|left|thumb|184x184px|Inarha ye-&quot;Europe&quot;]]



I-Europe

Kulenarhakazi kunenarha ezima-50 ezifaka I- Germany, iFrance, ne-United kingdom.Inarhakazi le ngeyesithandathu ekulu



[[Isimumathi:North America physical map blank.jpg|left|thumb|190x190px|Inarha ye-&quot;North America&quot;]]



I-North America

Inarhakazi le ilikhaya leenarha ezima-23 begodu ingeyesithathu ekulu.



[[Isimumathi:South america tr.jpg|left|thumb|242x242px|Inarha ye-&quot;South America&quot;]]





I-South America

Inarhakazi le ineenarha ezili-12 begodu ingee ingeyesine ekule eenarhakazini





== Imithombo Lwazi ==
# [https://www.cambridge.org/core/journals/journal-of-global-history/article/abs/continents-and-consequences-the-history-of-a-concept/13ECF8CEEB508069D4372266DA9C87A8 Continents and consequences: the history of a concept | Journal of Global History | Cambridge Core]
# [https://www.taylorfrancis.com/books/edit/10.4324/9781315662596/african-experience-vincent-khapoya The African Experience | Vincent B. Khapoya | Taylor &amp; Francis eBooks,]. 
# [https://link.springer.com/book/10.1007/978-3-030-19662-2 Management Practices in Asia: Case Studies on Market Entry, CSR, and Coaching | SpringerLink]</text>
      <sha1>8pvo5vpjrqpsj2p8sp8qttsrr09ac1z</sha1>
    </revision>
    <revision>
      <id>5597</id>
      <parentid>5593</parentid>
      <timestamp>2025-09-04T10:14:25Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <origin>5597</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2940" sha1="k3thrlxfyvpievkyqn95qwd9l144yb2" xml:space="preserve">'''page 1: Draft space 1 -''' Editing an article

== Iinarhakazi zephasi ==
'''Ephasini''' kuneenarhakazi ezilikhomba, enye nenye inarhakazi inamasiko wayo, amatshwayo wayo neenarha ezingaphakthi kwayo
Iinarhakazi zephasi.

Amagama weenarhakazi zephasi nehlathululo yazo[[Isimumathi:Africa and Europe from a Million Miles Away.png|left|thumb|184x184px|inarhakazi yeAfrika]]&lt;ref&gt;{{Cite journal |last=Yearwood |first=Peter J. |date=2014-11 |title=Continents and consequences: the history of a concept |url=https://www.cambridge.org/core/journals/journal-of-global-history/article/abs/continents-and-consequences-the-history-of-a-concept/13ECF8CEEB508069D4372266DA9C87A8 |journal=Journal of Global History |language=en |volume=9 |issue=3 |pages=329–356 |doi=10.1017/S1740022814000151 |issn=1740-0228}}&lt;/ref&gt;



I-Africa

Yinarhakazi yesibili ekulu begodu ngaphakathi iphethe inarha ezima-55 ezifaka hlangana

i-Sewula Africa, i-gibhithe neZimbabwe



[[Isimumathi:Mt Herschel, Antarctica, Jan 2006.jpg|left|thumb|191x191px|Inarha ye-&quot;Antarctica&quot;]]


I-Antarctica

Yinarhakazi encani begodu emakhaza ukuzidlula zoke. Enarhakazini le akuhlali abantu kodwana kuhlala iinlwana zemangweni kwaphela.


[[Isimumathi:Asia satellite orthographic.jpg|left|thumb|195x195px|Inarha ye-&quot;Asia&quot;]]



I-Asia

Lapha kuneenarha ezima-49, ezifaka hlagana I inarha ye China, India Kanye ne Russia ekuyinarha ekulu ukuzidlula zoke ephasini. Inarhakazi le ngekulu ukuzidlula zoke ephasini


[[Isimumathi:Australia satellite plane.jpg|left|thumb|188x188px|Inarha ye-&quot;Australia&quot;]]


I-Australia

Le yinarhakazi encani ehlalwa babantu ephasini, ngaphakathi iineenarha ezi-6 ezine zazo yi- New Zealad, Papua New Guiea ne Australia.


[[Isimumathi:Europe and the European Union.svg|left|thumb|184x184px|Inarha ye-&quot;Europe&quot;]]



I-Europe

Kulenarhakazi kunenarha ezima-50 ezifaka I- Germany, iFrance, ne-United kingdom.Inarhakazi le ngeyesithandathu ekulu



[[Isimumathi:North America physical map blank.jpg|left|thumb|190x190px|Inarha ye-&quot;North America&quot;]]



I-North America

Inarhakazi le ilikhaya leenarha ezima-23 begodu ingeyesithathu ekulu.



[[Isimumathi:South america tr.jpg|left|thumb|242x242px|Inarha ye-&quot;South America&quot;]]





I-South America

Inarhakazi le ineenarha ezili-12 begodu ingee ingeyesine ekule eenarhakazini





== Imithombo Lwazi ==
&lt;references /&gt;

# [https://www.cambridge.org/core/journals/journal-of-global-history/article/abs/continents-and-consequences-the-history-of-a-concept/13ECF8CEEB508069D4372266DA9C87A8 Continents and consequences: the history of a concept | Journal of Global History | Cambridge Core]
# [https://www.taylorfrancis.com/books/edit/10.4324/9781315662596/african-experience-vincent-khapoya The African Experience | Vincent B. Khapoya | Taylor &amp; Francis eBooks,]. 
# [https://link.springer.com/book/10.1007/978-3-030-19662-2 Management Practices in Asia: Case Studies on Market Entry, CSR, and Coaching | SpringerLink]</text>
      <sha1>k3thrlxfyvpievkyqn95qwd9l144yb2</sha1>
    </revision>
    <revision>
      <id>5598</id>
      <parentid>5597</parentid>
      <timestamp>2025-09-04T10:15:17Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <origin>5598</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2940" sha1="tgelkvp1p2pn658s9d1rquhcp2i2nm0" xml:space="preserve">'''page 1: Draft space 1 -''' Editing an article

== Iinarhakazi zephasi ==
'''Ephasini''' kuneenarhakazi ezilikhomba, enye nenye inarhakazi inamasiko wayo, amatshwayo wayo neenarha ezingaphakthi kwayo
Iinarhakazi zephasi.&lt;ref&gt;{{Cite journal |last=Yearwood |first=Peter J. |date=2014-11 |title=Continents and consequences: the history of a concept |url=https://www.cambridge.org/core/journals/journal-of-global-history/article/abs/continents-and-consequences-the-history-of-a-concept/13ECF8CEEB508069D4372266DA9C87A8 |journal=Journal of Global History |language=en |volume=9 |issue=3 |pages=329–356 |doi=10.1017/S1740022814000151 |issn=1740-0228}}&lt;/ref&gt;

Amagama weenarhakazi zephasi nehlathululo yazo[[Isimumathi:Africa and Europe from a Million Miles Away.png|left|thumb|184x184px|inarhakazi yeAfrika]]



I-Africa

Yinarhakazi yesibili ekulu begodu ngaphakathi iphethe inarha ezima-55 ezifaka hlangana

i-Sewula Africa, i-gibhithe neZimbabwe



[[Isimumathi:Mt Herschel, Antarctica, Jan 2006.jpg|left|thumb|191x191px|Inarha ye-&quot;Antarctica&quot;]]


I-Antarctica

Yinarhakazi encani begodu emakhaza ukuzidlula zoke. Enarhakazini le akuhlali abantu kodwana kuhlala iinlwana zemangweni kwaphela.


[[Isimumathi:Asia satellite orthographic.jpg|left|thumb|195x195px|Inarha ye-&quot;Asia&quot;]]



I-Asia

Lapha kuneenarha ezima-49, ezifaka hlagana I inarha ye China, India Kanye ne Russia ekuyinarha ekulu ukuzidlula zoke ephasini. Inarhakazi le ngekulu ukuzidlula zoke ephasini


[[Isimumathi:Australia satellite plane.jpg|left|thumb|188x188px|Inarha ye-&quot;Australia&quot;]]


I-Australia

Le yinarhakazi encani ehlalwa babantu ephasini, ngaphakathi iineenarha ezi-6 ezine zazo yi- New Zealad, Papua New Guiea ne Australia.


[[Isimumathi:Europe and the European Union.svg|left|thumb|184x184px|Inarha ye-&quot;Europe&quot;]]



I-Europe

Kulenarhakazi kunenarha ezima-50 ezifaka I- Germany, iFrance, ne-United kingdom.Inarhakazi le ngeyesithandathu ekulu



[[Isimumathi:North America physical map blank.jpg|left|thumb|190x190px|Inarha ye-&quot;North America&quot;]]



I-North America

Inarhakazi le ilikhaya leenarha ezima-23 begodu ingeyesithathu ekulu.



[[Isimumathi:South america tr.jpg|left|thumb|242x242px|Inarha ye-&quot;South America&quot;]]





I-South America

Inarhakazi le ineenarha ezili-12 begodu ingee ingeyesine ekule eenarhakazini





== Imithombo Lwazi ==
&lt;references /&gt;

# [https://www.cambridge.org/core/journals/journal-of-global-history/article/abs/continents-and-consequences-the-history-of-a-concept/13ECF8CEEB508069D4372266DA9C87A8 Continents and consequences: the history of a concept | Journal of Global History | Cambridge Core]
# [https://www.taylorfrancis.com/books/edit/10.4324/9781315662596/african-experience-vincent-khapoya The African Experience | Vincent B. Khapoya | Taylor &amp; Francis eBooks,]. 
# [https://link.springer.com/book/10.1007/978-3-030-19662-2 Management Practices in Asia: Case Studies on Market Entry, CSR, and Coaching | SpringerLink]</text>
      <sha1>tgelkvp1p2pn658s9d1rquhcp2i2nm0</sha1>
    </revision>
    <revision>
      <id>5601</id>
      <parentid>5598</parentid>
      <timestamp>2025-09-04T10:19:55Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <origin>5601</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2931" sha1="oqzhfqooy30hvca56552r80h2jp6hs5" xml:space="preserve">'''page 1: Draft space 1 -''' Editing an article

== Iinarhakazi zephasi ==
'''Ephasini''' kuneenarhakazi ezilikhomba, enye nenye inarhakazi inamasiko wayo, amatshwayo wayo neenarha ezingaphakthi kwayo
Iinarhakazi zephasi. &lt;ref&gt;{{Cite journal|last=Yearwood|first=Peter J.|date=2014-11|title=Continents and consequences: the history of a concept|url=https://www.cambridge.org/core/journals/journal-of-global-history/article/abs/continents-and-consequences-the-history-of-a-concept/13ECF8CEEB508069D4372266DA9C87A8|journal=Journal of Global History|language=en|volume=9|issue=3|pages=329–356|doi=10.1017/S1740022814000151|issn=1740-0228}}&lt;/ref&gt;



Amagama weenarhakazi zephasi nehlathululo yazo[[Isimumathi:Africa and Europe from a Million Miles Away.png|left|thumb|184x184px|inarhakazi yeAfrika]]



I-Africa

Yinarhakazi yesibili ekulu begodu ngaphakathi iphethe inarha ezima-55 ezifaka hlangana

i-Sewula Africa, i-gibhithe neZimbabwe



[[Isimumathi:Mt Herschel, Antarctica, Jan 2006.jpg|left|thumb|191x191px|Inarha ye-&quot;Antarctica&quot;]]


I-Antarctica

Yinarhakazi encani begodu emakhaza ukuzidlula zoke. Enarhakazini le akuhlali abantu kodwana kuhlala iinlwana zemangweni kwaphela.


[[Isimumathi:Asia satellite orthographic.jpg|left|thumb|195x195px|Inarha ye-&quot;Asia&quot;]]



I-Asia

Lapha kuneenarha ezima-49, ezifaka hlagana I inarha ye China, India Kanye ne Russia ekuyinarha ekulu ukuzidlula zoke ephasini. Inarhakazi le ngekulu ukuzidlula zoke ephasini


[[Isimumathi:Australia satellite plane.jpg|left|thumb|188x188px|Inarha ye-&quot;Australia&quot;]]


I-Australia

Le yinarhakazi encani ehlalwa babantu ephasini, ngaphakathi iineenarha ezi-6 ezine zazo yi- New Zealad, Papua New Guiea ne Australia.


[[Isimumathi:Europe and the European Union.svg|left|thumb|184x184px|Inarha ye-&quot;Europe&quot;]]



I-Europe

Kulenarhakazi kunenarha ezima-50 ezifaka I- Germany, iFrance, ne-United kingdom.Inarhakazi le ngeyesithandathu ekulu



[[Isimumathi:North America physical map blank.jpg|left|thumb|190x190px|Inarha ye-&quot;North America&quot;]]



I-North America

Inarhakazi le ilikhaya leenarha ezima-23 begodu ingeyesithathu ekulu.



[[Isimumathi:South america tr.jpg|left|thumb|242x242px|Inarha ye-&quot;South America&quot;]]





I-South America

Inarhakazi le ineenarha ezili-12 begodu ingee ingeyesine ekule eenarhakazini





== Imithombo Lwazi ==
&lt;references /&gt;

# [https://www.cambridge.org/core/journals/journal-of-global-history/article/abs/continents-and-consequences-the-history-of-a-concept/13ECF8CEEB508069D4372266DA9C87A8 Continents and consequences: the history of a concept | Journal of Global History | Cambridge Core]
# [https://www.taylorfrancis.com/books/edit/10.4324/9781315662596/african-experience-vincent-khapoya The African Experience | Vincent B. Khapoya | Taylor &amp; Francis eBooks,]. 
# [https://link.springer.com/book/10.1007/978-3-030-19662-2 Management Practices in Asia: Case Studies on Market Entry, CSR, and Coaching | SpringerLink]</text>
      <sha1>oqzhfqooy30hvca56552r80h2jp6hs5</sha1>
    </revision>
    <revision>
      <id>5602</id>
      <parentid>5601</parentid>
      <timestamp>2025-09-04T10:21:45Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <origin>5602</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2947" sha1="2n4a4kyshtel8vlkxo45w58kqtma3hv" xml:space="preserve">'''page 1: Draft space 1 -''' Editing an article

== Iinarhakazi zephasi ==
'''Ephasini''' kuneenarhakazi ezilikhomba, enye nenye inarhakazi inamasiko wayo, amatshwayo wayo neenarha ezingaphakthi kwayo
Iinarhakazi zephasi. &lt;ref name=&quot;Yearwood&quot;&gt;{{Cite journal|last=Yearwood|first=Peter J.|date=2014-11|title=Continents and consequences: the history of a concept|url=https://www.cambridge.org/core/journals/journal-of-global-history/article/abs/continents-and-consequences-the-history-of-a-concept/13ECF8CEEB508069D4372266DA9C87A8|journal=Journal of Global History|language=en|volume=9|issue=3|pages=329–356|doi=10.1017/S1740022814000151|issn=1740-0228}}&lt;/ref&gt;



Amagama weenarhakazi zephasi nehlathululo yazo[[Isimumathi:Africa and Europe from a Million Miles Away.png|left|thumb|184x184px|inarhakazi yeAfrika]]



I-Africa

Yinarhakazi yesibili ekulu begodu ngaphakathi iphethe inarha ezima-55 ezifaka hlangana

i-Sewula Africa, i-gibhithe neZimbabwe



[[Isimumathi:Mt Herschel, Antarctica, Jan 2006.jpg|left|thumb|191x191px|Inarha ye-&quot;Antarctica&quot;]]


I-Antarctica

Yinarhakazi encani begodu emakhaza ukuzidlula zoke. Enarhakazini le akuhlali abantu kodwana kuhlala iinlwana zemangweni kwaphela.


[[Isimumathi:Asia satellite orthographic.jpg|left|thumb|195x195px|Inarha ye-&quot;Asia&quot;]]



I-Asia

Lapha kuneenarha ezima-49, ezifaka hlagana I inarha ye China, India Kanye ne Russia ekuyinarha ekulu ukuzidlula zoke ephasini. Inarhakazi le ngekulu ukuzidlula zoke ephasini


[[Isimumathi:Australia satellite plane.jpg|left|thumb|188x188px|Inarha ye-&quot;Australia&quot;]]


I-Australia

Le yinarhakazi encani ehlalwa babantu ephasini, ngaphakathi iineenarha ezi-6 ezine zazo yi- New Zealad, Papua New Guiea ne Australia.


[[Isimumathi:Europe and the European Union.svg|left|thumb|184x184px|Inarha ye-&quot;Europe&quot;]]



I-Europe

Kulenarhakazi kunenarha ezima-50 ezifaka I- Germany, iFrance, ne-United kingdom.Inarhakazi le ngeyesithandathu ekulu



[[Isimumathi:North America physical map blank.jpg|left|thumb|190x190px|Inarha ye-&quot;North America&quot;]]



I-North America

Inarhakazi le ilikhaya leenarha ezima-23 begodu ingeyesithathu ekulu.



[[Isimumathi:South america tr.jpg|left|thumb|242x242px|Inarha ye-&quot;South America&quot;]]





I-South America

Inarhakazi le ineenarha ezili-12 begodu ingee ingeyesine ekule eenarhakazini





== Imithombo Lwazi ==
&lt;references /&gt;

# [https://www.cambridge.org/core/journals/journal-of-global-history/article/abs/continents-and-consequences-the-history-of-a-concept/13ECF8CEEB508069D4372266DA9C87A8 Continents and consequences: the history of a concept | Journal of Global History | Cambridge Core]
# [https://www.taylorfrancis.com/books/edit/10.4324/9781315662596/african-experience-vincent-khapoya The African Experience | Vincent B. Khapoya | Taylor &amp; Francis eBooks,]. 
# [https://link.springer.com/book/10.1007/978-3-030-19662-2 Management Practices in Asia: Case Studies on Market Entry, CSR, and Coaching | SpringerLink]</text>
      <sha1>2n4a4kyshtel8vlkxo45w58kqtma3hv</sha1>
    </revision>
    <revision>
      <id>5603</id>
      <parentid>5602</parentid>
      <timestamp>2025-09-04T10:22:59Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <minor />
      <origin>5603</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3118" sha1="gyjfll49cpyhy5c25qabozxxv3bvq3v" xml:space="preserve">'''page 1: Draft space 1 -''' Editing an article

== Iinarhakazi zephasi ==
'''Ephasini''' kuneenarhakazi ezilikhomba, enye nenye inarhakazi inamasiko wayo, amatshwayo wayo neenarha ezingaphakthi kwayo
Iinarhakazi zephasi. &lt;ref name=&quot;Yearwood&quot;&gt;{{Cite journal|last=Yearwood|first=Peter J.|date=2014-11|title=Continents and consequences: the history of a concept|url=https://www.cambridge.org/core/journals/journal-of-global-history/article/abs/continents-and-consequences-the-history-of-a-concept/13ECF8CEEB508069D4372266DA9C87A8|journal=Journal of Global History|language=en|volume=9|issue=3|pages=329–356|doi=10.1017/S1740022814000151|issn=1740-0228}}&lt;/ref&gt;&lt;ref&gt;{{Cite web|title=A Record Breaking Dam|url=http://www.mpumalanga.com/press-media/blog/a-record-breaking-dam|access-date=2025-09-04|website=www.mpumalanga.com}}&lt;/ref&gt;




Amagama weenarhakazi zephasi nehlathululo yazo[[Isimumathi:Africa and Europe from a Million Miles Away.png|left|thumb|184x184px|inarhakazi yeAfrika]]



I-Africa

Yinarhakazi yesibili ekulu begodu ngaphakathi iphethe inarha ezima-55 ezifaka hlangana

i-Sewula Africa, i-gibhithe neZimbabwe



[[Isimumathi:Mt Herschel, Antarctica, Jan 2006.jpg|left|thumb|191x191px|Inarha ye-&quot;Antarctica&quot;]]


I-Antarctica

Yinarhakazi encani begodu emakhaza ukuzidlula zoke. Enarhakazini le akuhlali abantu kodwana kuhlala iinlwana zemangweni kwaphela.


[[Isimumathi:Asia satellite orthographic.jpg|left|thumb|195x195px|Inarha ye-&quot;Asia&quot;]]



I-Asia

Lapha kuneenarha ezima-49, ezifaka hlagana I inarha ye China, India Kanye ne Russia ekuyinarha ekulu ukuzidlula zoke ephasini. Inarhakazi le ngekulu ukuzidlula zoke ephasini


[[Isimumathi:Australia satellite plane.jpg|left|thumb|188x188px|Inarha ye-&quot;Australia&quot;]]


I-Australia

Le yinarhakazi encani ehlalwa babantu ephasini, ngaphakathi iineenarha ezi-6 ezine zazo yi- New Zealad, Papua New Guiea ne Australia.


[[Isimumathi:Europe and the European Union.svg|left|thumb|184x184px|Inarha ye-&quot;Europe&quot;]]



I-Europe

Kulenarhakazi kunenarha ezima-50 ezifaka I- Germany, iFrance, ne-United kingdom.Inarhakazi le ngeyesithandathu ekulu



[[Isimumathi:North America physical map blank.jpg|left|thumb|190x190px|Inarha ye-&quot;North America&quot;]]



I-North America

Inarhakazi le ilikhaya leenarha ezima-23 begodu ingeyesithathu ekulu.



[[Isimumathi:South america tr.jpg|left|thumb|242x242px|Inarha ye-&quot;South America&quot;]]





I-South America

Inarhakazi le ineenarha ezili-12 begodu ingee ingeyesine ekule eenarhakazini





== Imithombo Lwazi ==
&lt;references /&gt;

# [https://www.cambridge.org/core/journals/journal-of-global-history/article/abs/continents-and-consequences-the-history-of-a-concept/13ECF8CEEB508069D4372266DA9C87A8 Continents and consequences: the history of a concept | Journal of Global History | Cambridge Core]
# [https://www.taylorfrancis.com/books/edit/10.4324/9781315662596/african-experience-vincent-khapoya The African Experience | Vincent B. Khapoya | Taylor &amp; Francis eBooks,]. 
# [https://link.springer.com/book/10.1007/978-3-030-19662-2 Management Practices in Asia: Case Studies on Market Entry, CSR, and Coaching | SpringerLink]</text>
      <sha1>gyjfll49cpyhy5c25qabozxxv3bvq3v</sha1>
    </revision>
    <revision>
      <id>5606</id>
      <parentid>5603</parentid>
      <timestamp>2025-09-04T10:23:28Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <origin>5606</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2510" sha1="acrx15m9efur5ntvkiz0fvlyii0oatp" xml:space="preserve">'''page 1: Draft space 1 -''' Editing an article

== Iinarhakazi zephasi ==
'''Ephasini''' kuneenarhakazi ezilikhomba, enye nenye inarhakazi inamasiko wayo, amatshwayo wayo neenarha ezingaphakthi kwayo
Iinarhakazi zephasi.




Amagama weenarhakazi zephasi nehlathululo yazo[[Isimumathi:Africa and Europe from a Million Miles Away.png|left|thumb|184x184px|inarhakazi yeAfrika]]



I-Africa

Yinarhakazi yesibili ekulu begodu ngaphakathi iphethe inarha ezima-55 ezifaka hlangana

i-Sewula Africa, i-gibhithe neZimbabwe



[[Isimumathi:Mt Herschel, Antarctica, Jan 2006.jpg|left|thumb|191x191px|Inarha ye-&quot;Antarctica&quot;]]


I-Antarctica

Yinarhakazi encani begodu emakhaza ukuzidlula zoke. Enarhakazini le akuhlali abantu kodwana kuhlala iinlwana zemangweni kwaphela.


[[Isimumathi:Asia satellite orthographic.jpg|left|thumb|195x195px|Inarha ye-&quot;Asia&quot;]]



I-Asia

Lapha kuneenarha ezima-49, ezifaka hlagana I inarha ye China, India Kanye ne Russia ekuyinarha ekulu ukuzidlula zoke ephasini. Inarhakazi le ngekulu ukuzidlula zoke ephasini


[[Isimumathi:Australia satellite plane.jpg|left|thumb|188x188px|Inarha ye-&quot;Australia&quot;]]


I-Australia

Le yinarhakazi encani ehlalwa babantu ephasini, ngaphakathi iineenarha ezi-6 ezine zazo yi- New Zealad, Papua New Guiea ne Australia.


[[Isimumathi:Europe and the European Union.svg|left|thumb|184x184px|Inarha ye-&quot;Europe&quot;]]



I-Europe

Kulenarhakazi kunenarha ezima-50 ezifaka I- Germany, iFrance, ne-United kingdom.Inarhakazi le ngeyesithandathu ekulu



[[Isimumathi:North America physical map blank.jpg|left|thumb|190x190px|Inarha ye-&quot;North America&quot;]]



I-North America

Inarhakazi le ilikhaya leenarha ezima-23 begodu ingeyesithathu ekulu.



[[Isimumathi:South america tr.jpg|left|thumb|242x242px|Inarha ye-&quot;South America&quot;]]





I-South America

Inarhakazi le ineenarha ezili-12 begodu ingee ingeyesine ekule eenarhakazini





== Imithombo Lwazi ==
&lt;references /&gt;

# [https://www.cambridge.org/core/journals/journal-of-global-history/article/abs/continents-and-consequences-the-history-of-a-concept/13ECF8CEEB508069D4372266DA9C87A8 Continents and consequences: the history of a concept | Journal of Global History | Cambridge Core]
# [https://www.taylorfrancis.com/books/edit/10.4324/9781315662596/african-experience-vincent-khapoya The African Experience | Vincent B. Khapoya | Taylor &amp; Francis eBooks,]. 
# [https://link.springer.com/book/10.1007/978-3-030-19662-2 Management Practices in Asia: Case Studies on Market Entry, CSR, and Coaching | SpringerLink]</text>
      <sha1>acrx15m9efur5ntvkiz0fvlyii0oatp</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Sister01/Page 1</title>
    <ns>2</ns>
    <id>825</id>
    <revision>
      <id>5328</id>
      <timestamp>2025-09-03T10:18:52Z</timestamp>
      <contributor>
        <username>Sister01</username>
        <id>893</id>
      </contributor>
      <comment>Created sub page 1</comment>
      <origin>5328</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="21" sha1="pch87y1k6hovfegi0kuhokbawmoj8oz" xml:space="preserve">Page 1: Draft space 1</text>
      <sha1>pch87y1k6hovfegi0kuhokbawmoj8oz</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Enthusiastic Lady/Page 1</title>
    <ns>2</ns>
    <id>826</id>
    <revision>
      <id>5329</id>
      <timestamp>2025-09-03T10:18:53Z</timestamp>
      <contributor>
        <username>Enthusiastic Lady</username>
        <id>899</id>
      </contributor>
      <comment>Created sub page 1</comment>
      <origin>5329</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="23" sha1="q8ryzqfplohklyzd83p5zichd67kuvr" xml:space="preserve">Page 1 :  Draft space 1</text>
      <sha1>q8ryzqfplohklyzd83p5zichd67kuvr</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Lerato Ruffy/Page 1</title>
    <ns>2</ns>
    <id>827</id>
    <revision>
      <id>5330</id>
      <timestamp>2025-09-03T10:18:53Z</timestamp>
      <contributor>
        <username>Lerato Ruffy</username>
        <id>846</id>
      </contributor>
      <comment>Created sub page 1</comment>
      <origin>5330</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="21" sha1="pch87y1k6hovfegi0kuhokbawmoj8oz" xml:space="preserve">Page 1: Draft space 1</text>
      <sha1>pch87y1k6hovfegi0kuhokbawmoj8oz</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Tarryn 29/Page 1</title>
    <ns>2</ns>
    <id>828</id>
    <revision>
      <id>5331</id>
      <timestamp>2025-09-03T10:18:54Z</timestamp>
      <contributor>
        <username>Tarryn 29</username>
        <id>886</id>
      </contributor>
      <comment>Created sub-page 1</comment>
      <origin>5331</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="21" sha1="9ftw1r6vmsezasi4z1uo8hcqzfpwjbs" xml:space="preserve">Page 1: Draft Space 1</text>
      <sha1>9ftw1r6vmsezasi4z1uo8hcqzfpwjbs</sha1>
    </revision>
    <revision>
      <id>5618</id>
      <parentid>5331</parentid>
      <timestamp>2025-09-04T10:39:31Z</timestamp>
      <contributor>
        <username>Tarryn 29</username>
        <id>886</id>
      </contributor>
      <comment>Ngifake isithombe</comment>
      <origin>5618</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6502" sha1="7btijgmjw1lj36c9ny2dq9409haluyd" xml:space="preserve">Page 1: Draft Space 1
[[Isimumathi:Bonang Matheba.jpg|thumb|Isithombe saka Bonang Dorothy Matheba]]
'''U-Bonang Dorothy Matheba''' (wabelethwa mhla amalanga ama-25 kuMgwengweni 1987),  ngusaziwako wakumabonakude weSewula Afrika, ubuntu bomrhatjho, umtloli kanye nosomarhwebo. Waziwa ngamakghono wakhe wokwethula okuhle kanye nephimbo lakhe eliqakathekileko. Wethula umdlalo womculo we-SABC 1 ''LIVE'' (nje ekuthiwa ''yi-Live Amp'' ) owakha ukukhanya kwakhe eembonini &lt;ref&gt;{{Cite web|title=Figure 2: Female, 38 years old, squamous cell carcinoma of the cervix, p16 negative.|url=https://doi.org/10.7717/peerj.19387/fig-2|access-date=2025-09-04|website=doi.org}}&lt;/ref&gt;.  Ngo-2006 bekangumsingathi emdlalweni wokubhadela ebusuku. Abahlanganyeli bekufuze badose umtato bese baqagele ipendulo yephazili elula bese bathole imitlomelo yemali.

Ngomnyaka ka-2011, waba ngusaziwako wokuthoma weSewula Afrika owathoma umdlalo wamambala weenkundla zokuthintana owaziwa nge ''-B*Dazzled'' &lt;ref&gt;{{Cite book|url=https://doi.org/10.1093/gmo/9781561592630.article.l2275249|title=Bonang|date=2015-01-13|publisher=Oxford University Press|series=Oxford Music Online}}&lt;/ref&gt;.  Ngomnyaka ka-2013, waba lithunywa lokuthoma leentjhabatjhaba lomhlobo wezimonyo i-Revlon, ngaphandle kwe-US.

Ngomnyaka ka-2014, waba ngumsingathi we-2014 MTV Europe Music Awards pre-show, okwenza bona abe mSewula Afrika wokuthoma ukusingatha umnyanya wangaphambili.  Ngo-2015, waba m-Afrika wokuthoma ukunikelwa i-E! Iindaba ezikhethekileko ze-Afrika ku-E! .  UBonang Matheba unabalandeli abangaphezu kweengidi ezihlanu ku-Instagram ne-Twitter.

Ngomnyaka ka-2016, wavela kukhava ye-Forbes Woman Africa, eduze nabanye abantu bengubo abathathu boke banikelwe isihloko sokuba yi-Faces of Entrepreneurship.  Wakhupha incwadi yakhe ethi ''Kusuka ku-A ukuya ku-B'' begodu waveza umdlalo wakhe we- ''Being Bonang'', kokubili ngo-2017&lt;ref&gt;{{Cite book|last=Matheba|first=Bonang|title=From A to B|date=17 July 2017|publisher=BlackBird Books|year=2017|isbn=9781928337423}}&lt;/ref&gt;.   Ngo-2018, wavezwa emlandwini wamandla we-GQ SA, we-edishini kaKhukhulamungu.  Ngomnyaka ka-2024, waba mthuli wemitlomelo ye- Earthshot Prize ngomnyaka wee-2024 ebanjelwe e-Cape Town, e[[ISewula Afrika ne-Afrika eseSewula (South Africa and Southern Africa).|Sewula Afrika]], othoma ngemitlomelo kinoma ngiyiphi inarha ye-Afrika.

== Ipilo yokuthoma ==
U-Bonang wabelethwa mhla amalanga ama-25 kuMgwengweni  emnyakeni we-1987 eMahikeng borough eNorth West.  Ubelethwa ngumma uCharlotte Mokoena uSekela-Mongameli oPhetheko we-Human Resource kanye nezeKampanini neSasol. Ubabakhe nguGampi Matheba, umfundisi omkhulu eNorth West University.  UBonang ngewesitjhaba esikhuluma isiTswana.

Umndeni wakhe wathuthela e-Leondale, eMpumalanga eJwanisbhege, ngesikhathi u-Bonang asafunda esikolweni sikaRhulumede esibiza ngokuthi yi-Fourways High School esise-Fourways eJwanisbhege.

== Ibizelo ==

=== Umabonakude kanye nefilimu ===
Ngomnyaka ka-2002, uBonang wenza ukudlala kwakhe kokuthoma kumabonakude emdlalweni wabantwana weSABC 2, ''i-Manhattan Fantasy Challenge'' nakaneminyaka eli-15.  Wabuya wavela keminye imidlalo yabantwana ye-SABC 2.  Ngomnyaka ka-2007, uBonang wenza i-audition yesizini yokuthoma yomdlalo womculo weSABC 1 ''LIVE'' ( eyaziwa nge ''-Live Amp'' namhlanje) ngemva kokutjhiya i-varsity.  Ngokukhamba kwesikhathi wabekwa umqhele womnqobi womdlalo lo ukuze abe ngumsingathi no-Tbo Touch. Imisebenzi yakhe yokwethula yaba yipumelelo ekulu begodu kulapho ibizo lakhe elithi &quot;Queen B&quot; ladalwa khona. Isiqephu sakhe sokugcina sarhatjhwa mhla amalanga ama-31 kuRhoboyi emnyakeni wee-2012 njengombana amemezela bona utjhiya umdlalo.  Ngemva kokusuka kwakhe ku- ''LIVE'', waba neminye imidlalo eminengi efaka hlangana iClash of the Choirs SA, Afternoon Express, Top Billing kanye ne ''-KFC'' Taste Kitchen.

UBonang Matheba sele amukele amashowu amanengi wemitlomelo neminyanya eqakathekileko khulu iMTV Africa Music Awards 2016, Miss South Africa 2018 kanye nemidlalo yangaphambi kwe-2014 MTV Europe Music Awards kanye ne- BET Awards 2016.   Mhla amalanga ali-2 kuNobayeni ngomnyaka wee-2018, uBonang Matheba wabamba ikhonsathi ye- Global Citizen: Mandela 100 kanye nosomahlaya u-Trevor Noah, i-supermodel uNaomi Campbell, [https://www.newshub360.net/a-reece-net-worth/ i-PistolWhipPapi] nabanye abantu abadumileko.

Ngo-2008, uBonang Matheba wenza indima yakhe yokuthoma emdlalweni we-SABC 1, i ''-InterSEXions'' lapho adlala khona indima ka-Nurse Seipati.  Kusukela ngo-2019, wadlala begodu wakhiqiza ifilimu yedokhumenthri ''ethi Public Figure'', eyathoma ukuvezwa mhla amalanga ali-9 kuNtaka e-Manchester Film Festival.

UBonang wasungula indlu yakhe yokukhiqiza ebizwa nge-Bonang Matheba Entertainment ngo-2017. Iyunithi yokukhiqiza inomdlalo owodwa, okuyi- 1 Magic reality show, ''u-Being Bonang'' ozimiseleko begodu otjengisa ipilo kaBonang Matheba yelanga nelanga.

NgoMrhayili 2022, waba msingathi we-Africa Magic Viewers' Choice Awards.

Ngenyanga kaRhoboyi  ngomnyaka wee-2023, uBonang wamenyezelwa njengomsingathi wephaliswano le-Miss South Africa 2023.

Ngasekupheleni kukaVelabahlinze ngomnyaka wee-2024, uBonang wamemezela umdlalo wakhe weqiniso ''u-B'Dazzled osungulwe nguye'', oqale ku-SABC 3 ngo-18:00 ebusuku SAST, mhla amalanga ama-29 kuNtaka.

Ekuthomeni kwakaKhukhulamungu ngomnyaka wee-2024, uBonang wamenyezelwa njengomsingathi we-Miss Universe Pageant.

UBonang Matheba, kanye no-Billy Porter, babamba i-Earthshot Prize Awards ebanjelwe e-Cape Town mhla amalanga asi-6 kuNobayeni 2024.

=== Umrhatjho ===
Ngomnyaka wee-2009, uBonang wathola umtato ovela esitetjhini somrhatjho i-YFM lapho atjelwa khona bona uzokufakwa emhakheni omutjha wabethuli.  Wafumana umdlalo wakhe wangepelaveke wemini obizwa ngokuthi, &quot;I-B* Hive&quot;, owaba yipumelelo msinyana ngokudzimelela ebalalelini abatjha. Watjhiya umsebenzi ngomnyaka wee-2014.

UBonang Matheba wamenyezelwa njengo-DJ omutjha womrhatjho we-Metro FM ngo-2015.  Wathatha isikhundla saka-Siphokazi u-January owaba mtjhayeli we-Metro FM.  Umdlalo kaMatheba we-slot ''i-The Front Row'', waba nabalaleli abakhulu nabathabileko bekwaba kulapho kuvela ukungazwani nomphathi wesitetjhi somrhatjho, ngemva kokutjhugululwa komrhatjho, u-Bonang wabamba umdlalo ecadi komphikisi wakhe wesikhathi eside u-Lerato Kganyago ngaphandle kwesaziso sakhe.  Ngokukwata kanye nokungakhulumisani kkwabo, u-Bonang watjhiya umsebenzi esitetjhini somrhatjho ngelanga elilandelako. 

=== Imithombo lwazi ===
&lt;references /&gt;</text>
      <sha1>7btijgmjw1lj36c9ny2dq9409haluyd</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Ghostingghost/Page 1</title>
    <ns>2</ns>
    <id>830</id>
    <revision>
      <id>5333</id>
      <timestamp>2025-09-03T10:18:55Z</timestamp>
      <contributor>
        <username>Ghostingghost</username>
        <id>890</id>
      </contributor>
      <comment>Created sub-page 1</comment>
      <origin>5333</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="21" sha1="pch87y1k6hovfegi0kuhokbawmoj8oz" xml:space="preserve">Page 1: Draft space 1</text>
      <sha1>pch87y1k6hovfegi0kuhokbawmoj8oz</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:NaMathibela/Page 1</title>
    <ns>2</ns>
    <id>831</id>
    <revision>
      <id>5334</id>
      <timestamp>2025-09-03T10:18:57Z</timestamp>
      <contributor>
        <username>NaMathibela</username>
        <id>888</id>
      </contributor>
      <comment>Created sub page 1</comment>
      <origin>5334</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="23" sha1="q8ryzqfplohklyzd83p5zichd67kuvr" xml:space="preserve">Page 1 :  Draft space 1</text>
      <sha1>q8ryzqfplohklyzd83p5zichd67kuvr</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Nomhle R/Page 2</title>
    <ns>2</ns>
    <id>832</id>
    <revision>
      <id>5335</id>
      <timestamp>2025-09-03T10:19:10Z</timestamp>
      <contributor>
        <username>Nomhle R</username>
        <id>799</id>
      </contributor>
      <comment>created sub-page 2</comment>
      <origin>5335</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="12" sha1="lqkflz819qn225qnedpklbx0qqo35q6" xml:space="preserve">draft page 2</text>
      <sha1>lqkflz819qn225qnedpklbx0qqo35q6</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Nothi2003/Page 2</title>
    <ns>2</ns>
    <id>833</id>
    <revision>
      <id>5336</id>
      <timestamp>2025-09-03T10:19:18Z</timestamp>
      <contributor>
        <username>Nothi2003</username>
        <id>833</id>
      </contributor>
      <comment>created sub page 2</comment>
      <origin>5336</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="15" sha1="by4y7y0i9pnxhspatkt2e85nvzsd15p" xml:space="preserve">Page 2: Draft 2</text>
      <sha1>by4y7y0i9pnxhspatkt2e85nvzsd15p</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:ThokozaniSlaki/Page 2</title>
    <ns>2</ns>
    <id>834</id>
    <revision>
      <id>5337</id>
      <timestamp>2025-09-03T10:19:41Z</timestamp>
      <contributor>
        <username>ThokozaniSlaki</username>
        <id>842</id>
      </contributor>
      <comment>I have created sub page 2</comment>
      <origin>5337</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="20" sha1="bd55l8qrc3tj832o91miqv75vwble9h" xml:space="preserve">Page 2: Draft page 2</text>
      <sha1>bd55l8qrc3tj832o91miqv75vwble9h</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Dladlakamogelo07/Page 1</title>
    <ns>2</ns>
    <id>835</id>
    <revision>
      <id>5338</id>
      <timestamp>2025-09-03T10:19:52Z</timestamp>
      <contributor>
        <username>Dladlakamogelo07</username>
        <id>903</id>
      </contributor>
      <comment>Created sub page 1</comment>
      <origin>5338</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="21" sha1="pch87y1k6hovfegi0kuhokbawmoj8oz" xml:space="preserve">Page 1: Draft space 1</text>
      <sha1>pch87y1k6hovfegi0kuhokbawmoj8oz</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Pruddy01/Page 2</title>
    <ns>2</ns>
    <id>836</id>
    <revision>
      <id>5339</id>
      <timestamp>2025-09-03T10:19:53Z</timestamp>
      <contributor>
        <username>Pruddy01</username>
        <id>895</id>
      </contributor>
      <comment>Created sub page 2</comment>
      <origin>5339</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="20" sha1="s7uw7t2ypuq4z3htck485fe8k8u5mlg" xml:space="preserve">Page 2: Draft Page 2</text>
      <sha1>s7uw7t2ypuq4z3htck485fe8k8u5mlg</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Londiwe23/Page 1</title>
    <ns>2</ns>
    <id>837</id>
    <revision>
      <id>5340</id>
      <timestamp>2025-09-03T10:19:53Z</timestamp>
      <contributor>
        <username>Londiwe23</username>
        <id>902</id>
      </contributor>
      <comment>Created sub-page 1</comment>
      <origin>5340</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="20" sha1="5ptxk4tf151qj1zljwluqfd8ku4dlok" xml:space="preserve">Page1: Draft space 1</text>
      <sha1>5ptxk4tf151qj1zljwluqfd8ku4dlok</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:F.K MAHLANGU/Page 2</title>
    <ns>2</ns>
    <id>838</id>
    <revision>
      <id>5341</id>
      <timestamp>2025-09-03T10:19:57Z</timestamp>
      <contributor>
        <username>F.K MAHLANGU</username>
        <id>891</id>
      </contributor>
      <comment>created sub-page 2</comment>
      <origin>5341</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="20" sha1="srqzdaq2isma9plfafqqx0rd7c98ruh" xml:space="preserve">page 2: draft page 2</text>
      <sha1>srqzdaq2isma9plfafqqx0rd7c98ruh</sha1>
    </revision>
    <revision>
      <id>5417</id>
      <parentid>5341</parentid>
      <timestamp>2025-09-03T21:10:45Z</timestamp>
      <contributor>
        <username>F.K MAHLANGU</username>
        <id>891</id>
      </contributor>
      <comment>added references and a picture of Nelson Mandela.</comment>
      <origin>5417</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2308" sha1="hd1t88hhv88acbe5vtfxspclee4947m" xml:space="preserve">page 2: draft page 2
[[Isimumathi:Nelson Mandela 1994.jpg|thumb|&lt;ref&gt;[https://upload.wikimedia.org/wikipedia/commons/0/02/Nelson_Mandela_1994.jpg Nelson_Mandela_1994.jpg (1500×1940)]&lt;/ref&gt;Nelson Mandela]]
Mandela wabelethwa ngomhlaka 18 kuVelabahlinze 1918, esgodini seMvezo ngendaweni ebizwa ngokuthi yiMtata, eEastern Cape&lt;ref&gt;Mandela, N. (1994). ''Long Walk to Freedom: The Autobiography of Nelson Mandela''. Boston: Little, Brown and Company.&lt;/ref&gt;. Wanikelwa igama likaRolihlahla, igama lesiXhosa elitjho ukuthi &quot;troublemaker&quot;&lt;ref&gt;Lodge, T. (2006). ''Mandela: A Critical Life''. Oxford: Oxford University Press.&lt;/ref&gt; kwathi emnyakeni elandelako wathoma ukwaziwa ngesithakazelo sakhe, uMadiba. Ukhokhomkhulu wakhe wehlangothini lika yise, uNgubengcuka wayemdosiphambili wesizwe siThembu eTranskeian kwiphrovinsi yeEastern Cape&lt;ref&gt;Meredith, M. (2010). ''Mandela: A Biography''. New York: PublicAffairs.&lt;/ref&gt;. Omunye wamadodana kaNgubengcuka, ibizo lakhe ekungu Mandela, umkhulu kaNelson, ekunguye ebamthiyelela ngaye. Ngebanga lokobana uMandela wayebelethwa ngendlini yomfazi obuya esitjhabeni seIxhiba, kwenza bona angarhoni ukuba yikosana elandelako.

Ubaba kanelson Mandela, uGadla Henry Mphakanyiswa Mandela, wayeyikosana, wabekwaesihlalweni ngomyaka ka1915, ngemva kokuthi umkhandlo wakhe wakhe uthweswe ngomlandu wokukhwabanisa, uthweswa mkhandlu wabantu abamhlophe&lt;ref&gt;Sampson, A. (1999). ''Mandela: The Authorized Biography''. London: HarperCollins.&lt;/ref&gt;. Ngo1926, uGadla waqotjhwa emsebenzini ngonobangela wokukhwabanisa, kodwana uNelson bamtjela ukuthi uyise bamqothele ukujamela amalungelo nobulungiswa emkhandlwini. UGadla wayenesithembu, abafazi abane, amadodana amane kanye namadodakazi alithoba, ebebahlala endaweni ezihlukileko. Unina kaNelson wayemfazi wesithathu, uNosekeni Fanny, indodakazi kaNkedama wendlu yangesidleni, ilunga lesitjhaba samaMpemvu.

=== Irherho lemithombo. ===

# Nelson_Mandela_1994.jpg (1500×1940)
# Mandela, N. (1994). ''Long Walk to Freedom: The Autobiography of Nelson Mandela''. Boston: Little, Brown and Company.
# Lodge, T. (2006). ''Mandela: A Critical Life''. Oxford: Oxford University Press.
# Meredith, M. (2010). ''Mandela: A Biography''. New York: PublicAffairs.
# Sampson, A. (1999). ''Mandela: The Authorized Biography''. London: HarperCollins.</text>
      <sha1>hd1t88hhv88acbe5vtfxspclee4947m</sha1>
    </revision>
    <revision>
      <id>5419</id>
      <parentid>5417</parentid>
      <timestamp>2025-09-03T21:13:33Z</timestamp>
      <contributor>
        <username>F.K MAHLANGU</username>
        <id>891</id>
      </contributor>
      <origin>5419</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1907" sha1="gpcrnxsq6bbbhvbwae1gvqnxvdihnjj" xml:space="preserve">page 2: draft page 2
[[Isimumathi:Nelson Mandela 1994.jpg|thumb|&lt;ref&gt;[https://upload.wikimedia.org/wikipedia/commons/0/02/Nelson_Mandela_1994.jpg Nelson_Mandela_1994.jpg (1500×1940)]&lt;/ref&gt;Nelson Mandela]]
Mandela wabelethwa ngomhlaka 18 kuVelabahlinze 1918, esgodini seMvezo ngendaweni ebizwa ngokuthi yiMtata, eEastern Cape&lt;ref&gt;Mandela, N. (1994). ''Long Walk to Freedom: The Autobiography of Nelson Mandela''. Boston: Little, Brown and Company.&lt;/ref&gt;. Wanikelwa igama likaRolihlahla, igama lesiXhosa elitjho ukuthi &quot;troublemaker&quot;&lt;ref&gt;Lodge, T. (2006). ''Mandela: A Critical Life''. Oxford: Oxford University Press.&lt;/ref&gt; kwathi emnyakeni elandelako wathoma ukwaziwa ngesithakazelo sakhe, uMadiba. Ukhokhomkhulu wakhe wehlangothini lika yise, uNgubengcuka wayemdosiphambili wesizwe siThembu eTranskeian kwiphrovinsi yeEastern Cape&lt;ref&gt;Meredith, M. (2010). ''Mandela: A Biography''. New York: PublicAffairs.&lt;/ref&gt;. Omunye wamadodana kaNgubengcuka, ibizo lakhe ekungu Mandela, umkhulu kaNelson, ekunguye ebamthiyelela ngaye. Ngebanga lokobana uMandela wayebelethwa ngendlini yomfazi obuya esitjhabeni seIxhiba, kwenza bona angarhoni ukuba yikosana elandelako.

Ubaba kanelson Mandela, uGadla Henry Mphakanyiswa Mandela, wayeyikosana, wabekwaesihlalweni ngomyaka ka1915, ngemva kokuthi umkhandlo wakhe wakhe uthweswe ngomlandu wokukhwabanisa, uthweswa mkhandlu wabantu abamhlophe&lt;ref&gt;Sampson, A. (1999). ''Mandela: The Authorized Biography''. London: HarperCollins.&lt;/ref&gt;. Ngo1926, uGadla waqotjhwa emsebenzini ngonobangela wokukhwabanisa, kodwana uNelson bamtjela ukuthi uyise bamqothele ukujamela amalungelo nobulungiswa emkhandlwini. UGadla wayenesithembu, abafazi abane, amadodana amane kanye namadodakazi alithoba, ebebahlala endaweni ezihlukileko. Unina kaNelson wayemfazi wesithathu, uNosekeni Fanny, indodakazi kaNkedama wendlu yangesidleni, ilunga lesitjhaba samaMpemvu.

=== Irherho lemithombo. ===</text>
      <sha1>gpcrnxsq6bbbhvbwae1gvqnxvdihnjj</sha1>
    </revision>
    <revision>
      <id>5514</id>
      <parentid>5419</parentid>
      <timestamp>2025-09-04T09:17:35Z</timestamp>
      <contributor>
        <username>F.K MAHLANGU</username>
        <id>891</id>
      </contributor>
      <comment>added reference number 2</comment>
      <origin>5514</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1990" sha1="k37iessng46a2a1a99tj3wre36syrb3" xml:space="preserve">page 2: draft page 2
[[Isimumathi:Nelson Mandela 1994.jpg|thumb|&lt;ref&gt;[https://upload.wikimedia.org/wikipedia/commons/0/02/Nelson_Mandela_1994.jpg Nelson_Mandela_1994.jpg (1500×1940)]&lt;/ref&gt;Nelson Mandela]]
Mandela wabelethwa ngomhlaka 18 kuVelabahlinze 1918, esgodini seMvezo ngendaweni ebizwa ngokuthi yiMtata, eEastern Cape&lt;ref&gt;Van Wyk, J.H. (1995-03-06). &quot;Long Walk to Freedom: The Autobiography of Nelson Mandela&quot;. ''Koers - Bulletin for Christian Scholarship''. '''60''' (4). doi:10.4102/koers.v60i4.652. ISSN&amp;nbsp;2304-8557.&lt;/ref&gt;. Wanikelwa igama likaRolihlahla, igama lesiXhosa elitjho ukuthi &quot;troublemaker&quot;&lt;ref&gt;Lodge, T. (2006). ''Mandela: A Critical Life''. Oxford: Oxford University Press.&lt;/ref&gt; kwathi emnyakeni elandelako wathoma ukwaziwa ngesithakazelo sakhe, uMadiba. Ukhokhomkhulu wakhe wehlangothini lika yise, uNgubengcuka wayemdosiphambili wesizwe siThembu eTranskeian kwiphrovinsi yeEastern Cape&lt;ref&gt;Meredith, M. (2010). ''Mandela: A Biography''. New York: PublicAffairs.&lt;/ref&gt;. Omunye wamadodana kaNgubengcuka, ibizo lakhe ekungu Mandela, umkhulu kaNelson, ekunguye ebamthiyelela ngaye. Ngebanga lokobana uMandela wayebelethwa ngendlini yomfazi obuya esitjhabeni seIxhiba, kwenza bona angarhoni ukuba yikosana elandelako.

Ubaba kanelson Mandela, uGadla Henry Mphakanyiswa Mandela, wayeyikosana, wabekwaesihlalweni ngomyaka ka1915, ngemva kokuthi umkhandlo wakhe wakhe uthweswe ngomlandu wokukhwabanisa, uthweswa mkhandlu wabantu abamhlophe&lt;ref&gt;Sampson, A. (1999). ''Mandela: The Authorized Biography''. London: HarperCollins.&lt;/ref&gt;. Ngo1926, uGadla waqotjhwa emsebenzini ngonobangela wokukhwabanisa, kodwana uNelson bamtjela ukuthi uyise bamqothele ukujamela amalungelo nobulungiswa emkhandlwini. UGadla wayenesithembu, abafazi abane, amadodana amane kanye namadodakazi alithoba, ebebahlala endaweni ezihlukileko. Unina kaNelson wayemfazi wesithathu, uNosekeni Fanny, indodakazi kaNkedama wendlu yangesidleni, ilunga lesitjhaba samaMpemvu.

=== Irherho lemithombo. ===</text>
      <sha1>k37iessng46a2a1a99tj3wre36syrb3</sha1>
    </revision>
    <revision>
      <id>5517</id>
      <parentid>5514</parentid>
      <timestamp>2025-09-04T09:19:20Z</timestamp>
      <contributor>
        <username>F.K MAHLANGU</username>
        <id>891</id>
      </contributor>
      <comment>added reference number 3</comment>
      <origin>5517</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2109" sha1="m2vbucbwdhsrp5r5c6s2msc204krfv7" xml:space="preserve">page 2: draft page 2
[[Isimumathi:Nelson Mandela 1994.jpg|thumb|&lt;ref&gt;[https://upload.wikimedia.org/wikipedia/commons/0/02/Nelson_Mandela_1994.jpg Nelson_Mandela_1994.jpg (1500×1940)]&lt;/ref&gt;Nelson Mandela]]
Mandela wabelethwa ngomhlaka 18 kuVelabahlinze 1918, esgodini seMvezo ngendaweni ebizwa ngokuthi yiMtata, eEastern Cape&lt;ref&gt;Van Wyk, J.H. (1995-03-06). &quot;Long Walk to Freedom: The Autobiography of Nelson Mandela&quot;. ''Koers - Bulletin for Christian Scholarship''. '''60''' (4). doi:10.4102/koers.v60i4.652. ISSN&amp;nbsp;2304-8557.&lt;/ref&gt;. Wanikelwa igama likaRolihlahla, igama lesiXhosa elitjho ukuthi &quot;troublemaker&quot;&lt;ref&gt;Lodge, Tom (2020-03-31), &quot;The Many Lives of Nelson Mandela&quot;, ''Oxford Research Encyclopedia of African History'', Oxford University Press, ISBN&amp;nbsp;&lt;bdi&gt;978-0-19-027773-4&lt;/bdi&gt;, retrieved 2025-09-04&lt;/ref&gt; kwathi emnyakeni elandelako wathoma ukwaziwa ngesithakazelo sakhe, uMadiba. Ukhokhomkhulu wakhe wehlangothini lika yise, uNgubengcuka wayemdosiphambili wesizwe siThembu eTranskeian kwiphrovinsi yeEastern Cape&lt;ref&gt;Meredith, M. (2010). ''Mandela: A Biography''. New York: PublicAffairs.&lt;/ref&gt;. Omunye wamadodana kaNgubengcuka, ibizo lakhe ekungu Mandela, umkhulu kaNelson, ekunguye ebamthiyelela ngaye. Ngebanga lokobana uMandela wayebelethwa ngendlini yomfazi obuya esitjhabeni seIxhiba, kwenza bona angarhoni ukuba yikosana elandelako.

Ubaba kanelson Mandela, uGadla Henry Mphakanyiswa Mandela, wayeyikosana, wabekwaesihlalweni ngomyaka ka1915, ngemva kokuthi umkhandlo wakhe wakhe uthweswe ngomlandu wokukhwabanisa, uthweswa mkhandlu wabantu abamhlophe&lt;ref&gt;Sampson, A. (1999). ''Mandela: The Authorized Biography''. London: HarperCollins.&lt;/ref&gt;. Ngo1926, uGadla waqotjhwa emsebenzini ngonobangela wokukhwabanisa, kodwana uNelson bamtjela ukuthi uyise bamqothele ukujamela amalungelo nobulungiswa emkhandlwini. UGadla wayenesithembu, abafazi abane, amadodana amane kanye namadodakazi alithoba, ebebahlala endaweni ezihlukileko. Unina kaNelson wayemfazi wesithathu, uNosekeni Fanny, indodakazi kaNkedama wendlu yangesidleni, ilunga lesitjhaba samaMpemvu.

=== Irherho lemithombo. ===</text>
      <sha1>m2vbucbwdhsrp5r5c6s2msc204krfv7</sha1>
    </revision>
    <revision>
      <id>5526</id>
      <parentid>5517</parentid>
      <timestamp>2025-09-04T09:24:06Z</timestamp>
      <contributor>
        <username>F.K MAHLANGU</username>
        <id>891</id>
      </contributor>
      <origin>5526</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2142" sha1="n5zcyl7efq1j6jvgobdt3f4jzgr5xu0" xml:space="preserve">page 2: draft page 2

== umlando kaNelson Mandela. ==
[[Isimumathi:Nelson Mandela 1994.jpg|thumb|&lt;ref&gt;[https://upload.wikimedia.org/wikipedia/commons/0/02/Nelson_Mandela_1994.jpg Nelson_Mandela_1994.jpg (1500×1940)]&lt;/ref&gt;Nelson Mandela]]
Mandela wabelethwa ngomhlaka 18 kuVelabahlinze 1918, esgodini seMvezo ngendaweni ebizwa ngokuthi yiMtata, eEastern Cape&lt;ref&gt;Van Wyk, J.H. (1995-03-06). &quot;Long Walk to Freedom: The Autobiography of Nelson Mandela&quot;. ''Koers - Bulletin for Christian Scholarship''. '''60''' (4). doi:10.4102/koers.v60i4.652. ISSN&amp;nbsp;2304-8557.&lt;/ref&gt;. Wanikelwa igama likaRolihlahla, igama lesiXhosa elitjho ukuthi &quot;troublemaker&quot;&lt;ref&gt;Lodge, Tom (2020-03-31), &quot;The Many Lives of Nelson Mandela&quot;, ''Oxford Research Encyclopedia of African History'', Oxford University Press, ISBN&amp;nbsp;&lt;bdi&gt;978-0-19-027773-4&lt;/bdi&gt;, retrieved 2025-09-04&lt;/ref&gt; kwathi emnyakeni elandelako wathoma ukwaziwa ngesithakazelo sakhe, uMadiba. Ukhokhomkhulu wakhe wehlangothini lika yise, uNgubengcuka wayemdosiphambili wesizwe siThembu eTranskeian kwiphrovinsi yeEastern Cape&lt;ref&gt;Meredith, M. (2010). ''Mandela: A Biography''. New York: PublicAffairs.&lt;/ref&gt;. Omunye wamadodana kaNgubengcuka, ibizo lakhe ekungu Mandela, umkhulu kaNelson, ekunguye ebamthiyelela ngaye. Ngebanga lokobana uMandela wayebelethwa ngendlini yomfazi obuya esitjhabeni seIxhiba, kwenza bona angarhoni ukuba yikosana elandelako.

Ubaba kanelson Mandela, uGadla Henry Mphakanyiswa Mandela, wayeyikosana, wabekwaesihlalweni ngomyaka ka1915, ngemva kokuthi umkhandlo wakhe wakhe uthweswe ngomlandu wokukhwabanisa, uthweswa mkhandlu wabantu abamhlophe&lt;ref&gt;Sampson, A. (1999). ''Mandela: The Authorized Biography''. London: HarperCollins.&lt;/ref&gt;. Ngo1926, uGadla waqotjhwa emsebenzini ngonobangela wokukhwabanisa, kodwana uNelson bamtjela ukuthi uyise bamqothele ukujamela amalungelo nobulungiswa emkhandlwini. UGadla wayenesithembu, abafazi abane, amadodana amane kanye namadodakazi alithoba, ebebahlala endaweni ezihlukileko. Unina kaNelson wayemfazi wesithathu, uNosekeni Fanny, indodakazi kaNkedama wendlu yangesidleni, ilunga lesitjhaba samaMpemvu.

=== Irherho lemithombo. ===</text>
      <sha1>n5zcyl7efq1j6jvgobdt3f4jzgr5xu0</sha1>
    </revision>
    <revision>
      <id>5563</id>
      <parentid>5526</parentid>
      <timestamp>2025-09-04T09:45:28Z</timestamp>
      <contributor>
        <username>F.K MAHLANGU</username>
        <id>891</id>
      </contributor>
      <origin>5563</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2217" sha1="mh2vkcwmb7a6dhavw4u6fuz1zz19aeu" xml:space="preserve">page 2: draft page 2

== umlando kaNelson Mandela. ==
[[Isimumathi:Nelson Mandela 1994.jpg|thumb|&lt;ref&gt;[https://upload.wikimedia.org/wikipedia/commons/0/02/Nelson_Mandela_1994.jpg Nelson_Mandela_1994.jpg (1500×1940)]&lt;/ref&gt;Nelson Mandela]]
Mandela wabelethwa ngomhlaka 18 kuVelabahlinze 1918, esgodini seMvezo ngendaweni ebizwa ngokuthi yiMtata, [[:en:Eastern_Cape|eEastern Cape]]&lt;ref&gt;Van Wyk, J.H. (1995-03-06). &quot;Long Walk to Freedom: The Autobiography of Nelson Mandela&quot;. ''Koers - Bulletin for Christian Scholarship''. '''60''' (4). doi:10.4102/koers.v60i4.652. ISSN&amp;nbsp;2304-8557.&lt;/ref&gt;. Wanikelwa igama likaRolihlahla, igama [[Amalimi WeSewula Afrika#IsiXhosa|lesiXhosa]] elitjho ukuthi &quot;troublemaker&quot;&lt;ref&gt;Lodge, Tom (2020-03-31), &quot;The Many Lives of Nelson Mandela&quot;, ''Oxford Research Encyclopedia of African History'', Oxford University Press, ISBN&amp;nbsp;&lt;bdi&gt;978-0-19-027773-4&lt;/bdi&gt;, retrieved 2025-09-04&lt;/ref&gt; kwathi emnyakeni elandelako wathoma ukwaziwa ngesithakazelo sakhe, uMadiba. Ukhokhomkhulu wakhe wehlangothini lika yise, uNgubengcuka wayemdosiphambili wesizwe siThembu [[:en:Transkei|eTranskeian]] kwiphrovinsi yeEastern Cape&lt;ref&gt;Meredith, M. (2010). ''Mandela: A Biography''. New York: PublicAffairs.&lt;/ref&gt;. Omunye wamadodana kaNgubengcuka, ibizo lakhe ekungu Mandela, umkhulu kaNelson, ekunguye ebamthiyelela ngaye. Ngebanga lokobana uMandela wayebelethwa ngendlini yomfazi obuya esitjhabeni seIxhiba, kwenza bona angarhoni ukuba yikosana elandelako.

Ubaba kanelson Mandela, uGadla Henry Mphakanyiswa Mandela, wayeyikosana, wabekwaesihlalweni ngomyaka ka1915, ngemva kokuthi umkhandlo wakhe wakhe uthweswe ngomlandu wokukhwabanisa, uthweswa mkhandlu wabantu abamhlophe&lt;ref&gt;Sampson, A. (1999). ''Mandela: The Authorized Biography''. London: HarperCollins.&lt;/ref&gt;. Ngo1926, uGadla waqotjhwa emsebenzini ngonobangela wokukhwabanisa, kodwana uNelson bamtjela ukuthi uyise bamqothele ukujamela amalungelo nobulungiswa emkhandlwini. UGadla wayenesithembu, abafazi abane, amadodana amane kanye namadodakazi alithoba, ebebahlala endaweni ezihlukileko. Unina kaNelson wayemfazi wesithathu, uNosekeni Fanny, indodakazi kaNkedama wendlu yangesidleni, ilunga lesitjhaba samaMpemvu.

=== Irherho lemithombo. ===</text>
      <sha1>mh2vkcwmb7a6dhavw4u6fuz1zz19aeu</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:ThembekileSihle29/Page 1</title>
    <ns>2</ns>
    <id>839</id>
    <revision>
      <id>5342</id>
      <timestamp>2025-09-03T10:19:58Z</timestamp>
      <contributor>
        <username>ThembekileSihle29</username>
        <id>887</id>
      </contributor>
      <comment>Created sub page 1</comment>
      <origin>5342</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="19" sha1="sbxl09v7gqxk1cc91gik8ty7hwkla0n" xml:space="preserve">Page 1: Draft space</text>
      <sha1>sbxl09v7gqxk1cc91gik8ty7hwkla0n</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:MahlanguLucky23/Page 2</title>
    <ns>2</ns>
    <id>840</id>
    <revision>
      <id>5343</id>
      <timestamp>2025-09-03T10:19:59Z</timestamp>
      <contributor>
        <username>MahlanguLucky23</username>
        <id>876</id>
      </contributor>
      <comment>created sub page 2</comment>
      <origin>5343</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="19" sha1="3knm0i0yjr9rxfuemtohjncka9a9i8x" xml:space="preserve">Page 2:Draft page 2</text>
      <sha1>3knm0i0yjr9rxfuemtohjncka9a9i8x</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:2003.Ma/</title>
    <ns>2</ns>
    <id>841</id>
    <revision>
      <id>5344</id>
      <timestamp>2025-09-03T10:19:59Z</timestamp>
      <contributor>
        <username>2003.Ma</username>
        <id>882</id>
      </contributor>
      <comment>created sub page 2</comment>
      <origin>5344</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="15" sha1="by4y7y0i9pnxhspatkt2e85nvzsd15p" xml:space="preserve">Page 2: Draft 2</text>
      <sha1>by4y7y0i9pnxhspatkt2e85nvzsd15p</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Mbonani JayJay/Page 1/</title>
    <ns>2</ns>
    <id>842</id>
    <revision>
      <id>5345</id>
      <timestamp>2025-09-03T10:20:00Z</timestamp>
      <contributor>
        <username>Mbonani JayJay</username>
        <id>892</id>
      </contributor>
      <comment>Created page 1</comment>
      <origin>5345</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="21" sha1="pch87y1k6hovfegi0kuhokbawmoj8oz" xml:space="preserve">Page 1: Draft space 1</text>
      <sha1>pch87y1k6hovfegi0kuhokbawmoj8oz</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Lerato Ruffy/Page 2</title>
    <ns>2</ns>
    <id>843</id>
    <revision>
      <id>5346</id>
      <timestamp>2025-09-03T10:20:19Z</timestamp>
      <contributor>
        <username>Lerato Ruffy</username>
        <id>846</id>
      </contributor>
      <comment>Created sub page 2</comment>
      <origin>5346</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="20" sha1="s7uw7t2ypuq4z3htck485fe8k8u5mlg" xml:space="preserve">Page 2: Draft Page 2</text>
      <sha1>s7uw7t2ypuq4z3htck485fe8k8u5mlg</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Nomhle R/Page 3</title>
    <ns>2</ns>
    <id>844</id>
    <revision>
      <id>5347</id>
      <timestamp>2025-09-03T10:20:37Z</timestamp>
      <contributor>
        <username>Nomhle R</username>
        <id>799</id>
      </contributor>
      <comment>Created page with &quot;draft sub page 3&quot;</comment>
      <origin>5347</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="16" sha1="t3862b4247e2dh7p2wky1uvkkl0cckf" xml:space="preserve">draft sub page 3</text>
      <sha1>t3862b4247e2dh7p2wky1uvkkl0cckf</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:2000Gp01/Page 2</title>
    <ns>2</ns>
    <id>845</id>
    <revision>
      <id>5348</id>
      <timestamp>2025-09-03T10:20:53Z</timestamp>
      <contributor>
        <username>2000Gp01</username>
        <id>880</id>
      </contributor>
      <comment>created sub page 2</comment>
      <origin>5348</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="20" sha1="8kt9uym9wd403t2ex0vblvgvflgf9rm" xml:space="preserve">Page 2: draft page 2</text>
      <sha1>8kt9uym9wd403t2ex0vblvgvflgf9rm</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Sister01/Page 2</title>
    <ns>2</ns>
    <id>846</id>
    <revision>
      <id>5349</id>
      <timestamp>2025-09-03T10:20:54Z</timestamp>
      <contributor>
        <username>Sister01</username>
        <id>893</id>
      </contributor>
      <comment>I created sub page 2</comment>
      <origin>5349</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="14" sha1="i84ka6678atjj7i54uv1jtaokfeq495" xml:space="preserve">Page 2 Draft 2</text>
      <sha1>i84ka6678atjj7i54uv1jtaokfeq495</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:F.K MAHLANGU/Page 3</title>
    <ns>2</ns>
    <id>847</id>
    <revision>
      <id>5350</id>
      <timestamp>2025-09-03T10:20:55Z</timestamp>
      <contributor>
        <username>F.K MAHLANGU</username>
        <id>891</id>
      </contributor>
      <comment>created sub-page 3</comment>
      <origin>5350</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="20" sha1="5dtj3hc39dqevetf8sesv25clbbxo86" xml:space="preserve">page 3: draft page 3</text>
      <sha1>5dtj3hc39dqevetf8sesv25clbbxo86</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Mtsweni S/Page 1</title>
    <ns>2</ns>
    <id>848</id>
    <revision>
      <id>5351</id>
      <timestamp>2025-09-03T10:20:56Z</timestamp>
      <contributor>
        <username>Mtsweni S</username>
        <id>835</id>
      </contributor>
      <comment>Created sub page 1</comment>
      <origin>5351</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="21" sha1="pch87y1k6hovfegi0kuhokbawmoj8oz" xml:space="preserve">Page 1: Draft space 1</text>
      <sha1>pch87y1k6hovfegi0kuhokbawmoj8oz</sha1>
    </revision>
    <revision>
      <id>5418</id>
      <parentid>5351</parentid>
      <timestamp>2025-09-03T21:10:53Z</timestamp>
      <contributor>
        <username>Mtsweni S</username>
        <id>835</id>
      </contributor>
      <comment>Translated an English article to isiNdebele</comment>
      <origin>5418</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="11551" sha1="bxenbpv8zd1lqfauwgthvlhhpyhawnn" xml:space="preserve">Page 1: Draft space 1

THUSO MBEDU

U-Thuso Nokwanda Mbedu (owabelethwa mhla amalanga abunane ku-Velabahlinze ngonyaka we-1991) ungomunye wabadlali bakumabonwakude be-Sewula Afrika. Waduma khulu ngendima ayidlalako emdlalweni we-Sewula Afrika wabantu abatjha obizwa ngokobana yi-Sthunzi, lapho akhethwa khona ngokulandelana ukuthi athathe unongorwana wangaphetjheya obizwa nge- International Emmy ngonyaka wee-2017 kanye no-2018. U-Mbedu ekukhambeni kwesikhathi wavela ehlanganweni ebizwa ngokuthi yi- Forbes Africa 30 ngaphasi kwabantu abangaphasi kweminyaka ematjhumi amathathu ubudala ngonyaka wee-2018.

Ngonyaka wee-2021, wadlala ehlelweni elibizwa nge-Underground Railroad elitholakala kuAmazon Video, lapho kunamahlelo amanengi nekungilo elamenza bona abemdlali wokuthoma we-Sewula Afrika okhamba phambili kwezamahlelo adlala kumabonwakude we-America. Lokhu kwamenza bona athumbe unongorwana obizwa bona yi-Independent Spirit Award etholwa mumuntu wengubo okhamba phambili ngokuba mdlali wakumabonwakude ehlelweni elitjha. Waragela phambili waba ngomunye wabalingisi ehlelweni elimlando wangaphetjheya e-America obizwa ngokobana yi- The Woman King (2022) lapho adlala khona iskhundla saka Nawi.

IPILO YEBUNCANINI NEFUNDO 

U-Mbedu wabelethelwa e-Midlands Medical Centre endaweni ye-Pietermaritzburg, KwaZulu-Natal. Ubelethwa ngumma okhuluma isiZulu kanye noyise okhuluma isiSotho nesiXhosa. Wakhuliswa e-Pelham ngugogo wakhe , owabamumuntu omtlhogomelako ngemva kokuhlongakalelwa babelethi bakhe bobabili asesemncani.

U-Mbedu wafunda e-Pelham Primary School bese waya e- [[Pietermaritzburg Girls' High School]] . &lt;ref&gt;{{Cite journal|url=https://www.news24.com/witness/news/from-pmb-to-the-worlds-tvs-20170129|title=From PMB to the world's TVs|journal=The Witness|first=Nompilo|last=Kunene|date=30 January 2017|access-date=21 October 2021}}&lt;/ref&gt; Waragela phambili nokufunda i-Physical Theatre kanye ne-Performing Arts Management e- [[University of the Witwatersrand]] (Wits), waphothula ngo-2013 ngama-honor, &lt;ref&gt;{{cite web|url=https://www.goodthingsguy.com/people/thuso-mbedu-underground-railroad/|title=Meet the first South African actress to lead an American series!!!|website=Good Things Guy|date=17 April 2019}}&lt;/ref&gt; ngemva kokuthatha ikhosi e- [[Stella Adler Studio of Acting]] e-New York City ngo-2012. &lt;ref&gt;{{cite web|url=http://www.youthvillage.co.za/2016/05/10-things-you-didnt-know-about-scandal-actress-thuso-mbedu/|title=10 Things You Didn't Know About Scandal Actress Thuso Mbedu|website=Youth Village|date=16 May 2016}}&lt;/ref&gt; &lt;ref name=&quot;:1&quot;&gt;{{Cite journal|url=https://www.timeslive.co.za/tshisa-live/tshisa-live/2020-09-28-i-had-no-clue-what-they-were-saying-thuso-mbedu-on-connecting-with-her-sotho-heritage/|title='I had no clue what they were saying'-Thuso Mbedu on connecting with her Sotho heritage|journal=Times Live|first=Deepika|last=Naidoo|date=28 September 2020|access-date=3 November 2021}}&lt;/ref&gt;

IBIZELO

Ekupheleni konyaka wee-2014, u-Mbedu waba nendima encani kusizini yesibili ye- [[Mzansi Magic]] soapie ''[[Isibaya]]'', ''&lt;ref name=&quot;:0&quot;&gt;{{Cite news|url=https://www.channel24.co.za/TV/News/thuso-mbedu-from-out-of-work-to-emmy-nominee-20180211|title=Thuso Mbedu: From out of work to Emmy nominee|work=Channel24|access-date=24 March 2018|language=en}}&lt;/ref&gt;'' ngaphambi kokuthi athole indima yakhe njengomfundi wezobuntatheli nomntwana u-Kitso ku ''[[Scandal! (eTV soapie)|-Scandal!]]'' . ''['' ''&lt;ref&gt;{{cite web|url=http://www.news24.com/MoveMag/Archive/thuso-mbedu-on-how-she-made-it-against-all-odds-20170728|title=Thuso Mbedu on how she made it against all odds|date=28 July 2017|work=[[News24 (website)|News24]]}}&lt;/ref&gt; &lt;ref&gt;{{Cite news|url=http://www.youthvillage.co.za/2016/05/10-things-you-didnt-know-about-scandal-actress-thuso-mbedu/|title=10 Things You Didn't Know About Scandal Actress Thuso Mbedu|date=16 May 2016|work=Youth Village|access-date=24 March 2018|language=en-US}}&lt;/ref&gt;''[[SABC 2|​]]  kanye nendima ephambili njengo-Boni Khumalo emdlalweni kamabonakude bbizwa kobana yi- ''Saints and Sinners.&lt;ref&gt;{{Cite news|last=Vieira|first=Genevieve|title=Thuso Mbedu is truly blessed|language=en|work=The Citizen|url=https://citizen.co.za/lifestyle/your-life-entertainment-your-life/entertainment-celebrities/316910/thuso-mbedu-is-truly-blessed/|access-date=24 March 2018}}&lt;/ref&gt;''

Ngemva kokungasebenzi iinyanga ezisithandathu, u-Mbedu wathola indima yakhe yokuthoma kumabonakude emdlalweni we [[Mzansi Magic|-Mzansi Magic]] welutjha ''[[Is'Thunzi|-Is'Thunzi]]'', owathoma ngoMgwengweni enyakeni wee-2016. &lt;ref name=&quot;:02&quot;&gt;{{Cite news|url=https://www.channel24.co.za/TV/News/thuso-mbedu-from-out-of-work-to-emmy-nominee-20180211|title=Thuso Mbedu: From out of work to Emmy nominee|work=Channel24|access-date=24 March 2018|language=en}}&lt;/ref&gt; &lt;ref&gt;{{Cite news|url=https://www.timeslive.co.za/tshisa-live/tshisa-live/2017-09-28-heres-5-things-you-need-to-know-about-actress-thuso-mbedu/|title=Here's 5 things you need to know about actress Thuso Mbedu|work=[[TimesLIVE]]|access-date=24 March 2018|language=en-US}}&lt;/ref&gt; Emdlalweni lo, wadlala indima ka-Winnie, umdlali othanda ukuzikhakhazisa, ofuna ukutjhada nomdlali we-rugby onjingileko nodumileko kodwana ibhudango lakhe liyatjhabalala lokha nakufanele akhambe ayokuhlala nokgharakhe obukhali e-Bergville. Lokha nakalingisa  isiqephu sokudlwengulwa emdlalweni, wahlaselwa livalo. &lt;ref&gt;{{Cite news|url=https://www.huffingtonpost.co.za/2017/11/13/thuso-mbedu-is-leaving-for-the-international-emmys-with-hope-for-south-africans_a_23275431/|title=Thuso Mbedu Is Leaving For The International Emmys With Hope For South Africans|date=13 November 2017|work=Huffington Post South Africa|access-date=24 March 2018|language=en-ZA}}&lt;/ref&gt; NgoNobayeni 2017, waphakanyiswa enongorwaneni we [[International Emmy Award|-International Emmy Award]] esigabeni sokudlala okuhle khulu komlingisi ngendima yakhe njengo-Winnie ku ''-Is'Thunzi'' &lt;ref&gt;{{Cite news|url=https://www.timeslive.co.za/tshisa-live/tshisa-live/2018-01-18-thuso-mbedu-on-life-after-emmy-nod-the-truth-is-we-are-very-dispensable/|title=Thuso Mbedu on life after Emmy nod: 'The truth is we are very dispensable'|work=Times LIVE|access-date=24 March 2018|language=en-US}}&lt;/ref&gt; begodu bekunguye kwaphela umuntu we Sewula-Afrika owaphakanyiswa ngalowo mnyaka. &lt;ref&gt;{{Cite news|url=https://www.iol.co.za/entertainment/celebrity-news/local/isthunzi-star-thuso-mbedu-nominated-for-emmy-award-11386771|title='Is'thunzi' star Thuso Mbedu nominated for #Emmy Award {{!}} IOL Entertainment|access-date=24 March 2018|language=en}}&lt;/ref&gt;

U-Mbedu wenza ukudlala kwakhe kokuthoma njengo-Cora kubemlando ngonyaka wee-2021 [[Amazon Prime Video|we-Amazon Video]] ''[[The Underground Railroad (miniseries)|i-The Underground Railroad]]'', esekelwe enovelini [[The Underground Railroad (novel)|enegama elifanako]] ka [[Colson Whitehead|-Colson Whitehead]] begodu iqondiswe beyakhiqizwa ngomunye owathumba i [[Academy Awards|-Academy Award]] [[Barry Jenkins|u-Barry Jenkins]] . &lt;ref&gt;{{Cite web|last=Ramos|first=Dino-Ray|date=21 October 2020|title='The Underground Railroad' Teaser: Barry Jenkins Offers First Glimpse Of Thuso Mbedu As Cora In Amazon Limited Series|url=https://deadline.com/2020/10/the-underground-railroad-teaser-trailer-berry-jenkins-thuso-mbedu-as-cora-amazon-series-1234601236/|access-date=21 October 2020|website=Deadline|language=en-US}}&lt;/ref&gt; &lt;ref&gt;{{Cite web|title=Thuso Mbedu can't wait for viewers to see her new series with Barry Jenkins|url=https://www.news24.com/channel/tv/news/thuso-mbedu-cant-wait-for-viewers-to-see-her-new-series-with-barry-jenkins-20201020-2|access-date=21 October 2020|website=Channel|date=19 October 2020|language=en}}&lt;/ref&gt; UMbedu wathola i [[Hollywood Critics Association TV Awards|-Hollywood Critics Association Award]], i- [[Independent Spirit Awards|Independent Spirit Award]], kanye ne [[Gotham Awards|-Gotham Award]] yomdlalo. &lt;ref&gt;{{Cite web|last=Ngwenya|first=Nkhensani|date=30 August 2021|title=Thuso Mbedu Walks Away With An International Award|url=https://surgezirc.co.za/2021-08-30-gossip-thuso-mbedu-walks-away-with-an-international-award/|access-date=30 August 2021|website=Surge Zirc SA|language=en-GB}}&lt;/ref&gt;

Ngenyanga kaMrhayili 2021, kwamenyezelwa bona uMbedu uzokwenza ifilimu yakhe yokuthoma njengo-Nawi aqalene no [[Viola Davis|-Viola Davis]] ku- ''[[The Woman King]]'', ifilimu yomlando ephefumulelwe ngezehlakalo zamambala ezenzeka eMbusweni we-Dahomey, &lt;ref&gt;{{Cite web|last=Höffele|first=Lerato|title=Thuso Mbedu bags role alongside Viola Davis in 'The Woman King'|url=https://ewn.co.za/2021/04/29/thuso-mbedu-bags-role-alongside-viola-davis-in-the-woman-king|access-date=30 April 2021|website=ewn.co.za|language=en}}&lt;/ref&gt; omunye wemibuso enamandla khulu ye-Afrika ngekhulu le-18 nele-19. Ifilimu le beyiqondiswe ngu [[Gina Prince-Bythewood|-Gina Prince-Bythewood]], ukusuka emtlolweni womtloli we- ''[[Fatherhood (film)|Fatherhood]]'' [[Dana Stevens (screenwriter)|u-Dana Stevens]] . &lt;ref name=&quot;Kroll&quot;&gt;{{Cite web|last=Kroll|first=Justin|date=28 April 2021|title='Underground Railroad's Thuso Mbedu To Star Opposite Viola Davis In 'The Woman King King'|url=https://deadline.com/2021/04/thuso-mbedu-viola-davis-woman-king-1234746073/|access-date=28 April 2021|website=Deadline|language=en-US}}&lt;/ref&gt; &lt;ref&gt;{{Cite web|last=Morkel|first=Graye|title=Thuso Mbedu to star opposite Viola Davis in The Woman King|url=https://www.news24.com/channel/movies/news/thuso-mbedu-to-star-opposite-viola-davis-in-the-woman-king-20210429|access-date=30 April 2021|website=Channel|language=en-US}}&lt;/ref&gt; &lt;ref&gt;{{Cite web|title=Africans making waves in Hollywood|url=https://www.sowetanlive.co.za/entertainment/2021-04-30-africans-making-waves-in-hollywood/|access-date=30 April 2021|website=SowetanLIVE|language=en-ZA}}&lt;/ref&gt;

Ngo-2023, u-Mbedu waba yinxusa nomkhulumeli we [[L'Oréal|-L'Oréal]] we-Sub-Saharan Africa. &lt;ref&gt;{{Cite web|title=The Woman King star Thuso Mbedu named L'Oréal Paris Brand Ambassador|url=https://cosmeticsbusiness.com/news/article_page/The_Woman_King_star_Thuso_Mbedu_named_LOreal_Paris_Brand_Ambassador/209187|access-date=23 June 2023|website=Cosmetics Business}}&lt;/ref&gt; &lt;ref&gt;{{Cite web|title=Thuso Mbedu named L'Oréal Paris brand ambassador|url=https://www.news24.com/life/arts-and-entertainment/celebrities/thuso-mbedu-named-loreal-paris-brand-ambassador-20230529|access-date=23 June 2023|website=News24}}&lt;/ref&gt; &lt;ref&gt;{{cite web|title=Thuso Mbedu: The infamous marathon cheats|url=https://curio.io/shows/retold/thuso-mbedu-the-not-quite-redemption-of-south-africas-infamous-ultra-marathon-cheats|website=Curio}}&lt;/ref&gt; NgoTjhirhweni 2025 [[Deadline Hollywood|''i-Deadline'']] yabika bona u-Mbedu ukhethwe indima ephambili kufilimu ezako [[Paramount Pictures|ye-Paramount]] i- ''[[Children of Blood and Bone (film)|Children of Blood and Bone]]'' njengo-Zélie hlangana no [[Viola Davis|-Viola Davis]], [[Cynthia Erivo|u-Cynthia Erivo]], [[Damson Idris|u-Damson Idris]], [[Amandla Stenberg|u-Amandla Stenberg]], u- [[Idris Elba]] no- [[Tosin Cole]] . &lt;ref&gt;{{Cite web|last=Moorman|first=Taijuan|title=Star-studded 'Children of Blood and Bone' cast revealed: What we know so far|url=https://www.usatoday.com/story/entertainment/movies/2025/01/23/children-of-blood-and-bone-cast-amandla-stenberg/77900352007/#:~:text=Star-studded%20'Children%20of%20Blood,What%20we%20know%20so%20far&amp;text=Anticipation%20is%20growing%20for%20the,those%20powers%20to%20her%20people.|access-date=2025-02-06|website=USA TODAY|language=en-US}}&lt;/ref&gt;</text>
      <sha1>bxenbpv8zd1lqfauwgthvlhhpyhawnn</sha1>
    </revision>
    <revision>
      <id>5463</id>
      <parentid>5418</parentid>
      <timestamp>2025-09-04T08:16:03Z</timestamp>
      <contributor>
        <username>Mtsweni S</username>
        <id>835</id>
      </contributor>
      <origin>5463</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="11592" sha1="hmatpvyh52enmtmwfb9mxvcnspg579c" xml:space="preserve">Page 1: Draft space 1

THUSO MBEDU

U-Thuso Nokwanda Mbedu (owabelethwa mhla amalanga abunane ku-Velabahlinze ngonyaka we-1991) ungomunye wabadlali bakumabonwakude be-Sewula Afrika. Waduma khulu ngendima ayidlalako emdlalweni we-Sewula Afrika wabantu abatjha obizwa ngokobana yi-Sthunzi, lapho akhethwa khona ngokulandelana ukuthi athathe unongorwana wangaphetjheya obizwa nge- International Emmy ngonyaka wee-2017 kanye no-2018. U-Mbedu ekukhambeni kwesikhathi wavela ehlanganweni ebizwa ngokuthi yi- Forbes Africa 30 ngaphasi kwabantu abangaphasi kweminyaka ematjhumi amathathu ubudala ngonyaka wee-2018.

Ngonyaka wee-2021, wadlala ehlelweni elibizwa nge-Underground Railroad elitholakala kuAmazon Video, lapho kunamahlelo amanengi nekungilo elamenza bona abemdlali wokuthoma we-Sewula Afrika okhamba phambili kwezamahlelo adlala kumabonwakude we-America. Lokhu kwamenza bona athumbe unongorwana obizwa bona yi-Independent Spirit Award etholwa mumuntu wengubo okhamba phambili ngokuba mdlali wakumabonwakude ehlelweni elitjha. Waragela phambili waba ngomunye wabalingisi ehlelweni elimlando wangaphetjheya e-America obizwa ngokobana yi- The Woman King (2022) lapho adlala khona iskhundla saka Nawi.

IPILO YEBUNCANINI NEFUNDO 

U-Mbedu wabelethelwa e-Midlands Medical Centre endaweni ye-Pietermaritzburg, KwaZulu-Natal. Ubelethwa ngumma okhuluma isiZulu kanye noyise okhuluma isiSotho nesiXhosa. Wakhuliswa e-Pelham ngugogo wakhe , owabamumuntu omtlhogomelako ngemva kokuhlongakalelwa babelethi bakhe bobabili asesemncani.

U-Mbedu wafunda e-Pelham Primary School bese waya e- [[Pietermaritzburg Girls' High School]] . &lt;ref&gt;{{Cite journal|url=https://www.news24.com/witness/news/from-pmb-to-the-worlds-tvs-20170129|title=From PMB to the world's TVs|journal=The Witness|first=Nompilo|last=Kunene|date=30 January 2017|access-date=21 October 2021}}&lt;/ref&gt; Waragela phambili nokufunda i-Physical Theatre kanye ne-Performing Arts Management e- [[University of the Witwatersrand]] (Wits), waphothula ngo-2013 ngama-honor, &lt;ref&gt;{{cite web|url=https://www.goodthingsguy.com/people/thuso-mbedu-underground-railroad/|title=Meet the first South African actress to lead an American series!!!|website=Good Things Guy|date=17 April 2019}}&lt;/ref&gt; ngemva kokuthatha ikhosi e- [[Stella Adler Studio of Acting]] e-New York City ngo-2012. &lt;ref&gt;{{cite web|url=http://www.youthvillage.co.za/2016/05/10-things-you-didnt-know-about-scandal-actress-thuso-mbedu/|title=10 Things You Didn't Know About Scandal Actress Thuso Mbedu|website=Youth Village|date=16 May 2016}}&lt;/ref&gt; &lt;ref name=&quot;:1&quot;&gt;{{Cite journal|url=https://www.timeslive.co.za/tshisa-live/tshisa-live/2020-09-28-i-had-no-clue-what-they-were-saying-thuso-mbedu-on-connecting-with-her-sotho-heritage/|title='I had no clue what they were saying'-Thuso Mbedu on connecting with her Sotho heritage|journal=Times Live|first=Deepika|last=Naidoo|date=28 September 2020|access-date=3 November 2021}}&lt;/ref&gt;

IBIZELO

Ekupheleni konyaka wee-2014, u-Mbedu waba nendima encani kusizini yesibili ye- [[Mzansi Magic]] soapie ''[[Isibaya]]'', ''&lt;ref name=&quot;:0&quot;&gt;{{Cite news|url=https://www.channel24.co.za/TV/News/thuso-mbedu-from-out-of-work-to-emmy-nominee-20180211|title=Thuso Mbedu: From out of work to Emmy nominee|work=Channel24|access-date=24 March 2018|language=en}}&lt;/ref&gt;'' ngaphambi kokuthi athole indima yakhe njengomfundi wezobuntatheli nomntwana u-Kitso ku ''[[Scandal! (eTV soapie)|-Scandal!]]'' . ''['' ''&lt;ref&gt;{{cite web|url=http://www.news24.com/MoveMag/Archive/thuso-mbedu-on-how-she-made-it-against-all-odds-20170728|title=Thuso Mbedu on how she made it against all odds|date=28 July 2017|work=[[News24 (website)|News24]]}}&lt;/ref&gt; &lt;ref&gt;{{Cite news|url=http://www.youthvillage.co.za/2016/05/10-things-you-didnt-know-about-scandal-actress-thuso-mbedu/|title=10 Things You Didn't Know About Scandal Actress Thuso Mbedu|date=16 May 2016|work=Youth Village|access-date=24 March 2018|language=en-US}}&lt;/ref&gt;''[[SABC 2|​]]  kanye nendima ephambili njengo-Boni Khumalo emdlalweni kamabonakude bbizwa kobana yi- ''Saints and Sinners.&lt;ref&gt;{{Cite news|last=Vieira|first=Genevieve|title=Thuso Mbedu is truly blessed|language=en|work=The Citizen|url=https://citizen.co.za/lifestyle/your-life-entertainment-your-life/entertainment-celebrities/316910/thuso-mbedu-is-truly-blessed/|access-date=24 March 2018}}&lt;/ref&gt;''

Ngemva kokungasebenzi iinyanga ezisithandathu, u-Mbedu wathola indima yakhe yokuthoma kumabonakude emdlalweni we [[Mzansi Magic|-Mzansi Magic]] welutjha ''[[Is'Thunzi|-Is'Thunzi]]'', owathoma ngoMgwengweni enyakeni wee-2016. &lt;ref name=&quot;:02&quot;&gt;{{Cite news|url=https://www.channel24.co.za/TV/News/thuso-mbedu-from-out-of-work-to-emmy-nominee-20180211|title=Thuso Mbedu: From out of work to Emmy nominee|work=Channel24|access-date=24 March 2018|language=en}}&lt;/ref&gt; &lt;ref&gt;{{Cite news|url=https://www.timeslive.co.za/tshisa-live/tshisa-live/2017-09-28-heres-5-things-you-need-to-know-about-actress-thuso-mbedu/|title=Here's 5 things you need to know about actress Thuso Mbedu|work=[[TimesLIVE]]|access-date=24 March 2018|language=en-US}}&lt;/ref&gt; Emdlalweni lo, wadlala indima ka-Winnie, umdlali othanda ukuzikhakhazisa, ofuna ukutjhada nomdlali we-rugby onjingileko nodumileko kodwana ibhudango lakhe liyatjhabalala lokha nakufanele akhambe ayokuhlala nokgharakhe obukhali e-Bergville. Lokha nakalingisa  isiqephu sokudlwengulwa emdlalweni, wahlaselwa livalo. &lt;ref&gt;{{Cite news|url=https://www.huffingtonpost.co.za/2017/11/13/thuso-mbedu-is-leaving-for-the-international-emmys-with-hope-for-south-africans_a_23275431/|title=Thuso Mbedu Is Leaving For The International Emmys With Hope For South Africans|date=13 November 2017|work=Huffington Post South Africa|access-date=24 March 2018|language=en-ZA}}&lt;/ref&gt; NgoNobayeni 2017, waphakanyiswa enongorwaneni we [[International Emmy Award|-International Emmy Award]] esigabeni sokudlala okuhle khulu komlingisi ngendima yakhe njengo-Winnie ku ''-Is'Thunzi'' &lt;ref&gt;{{Cite news|url=https://www.timeslive.co.za/tshisa-live/tshisa-live/2018-01-18-thuso-mbedu-on-life-after-emmy-nod-the-truth-is-we-are-very-dispensable/|title=Thuso Mbedu on life after Emmy nod: 'The truth is we are very dispensable'|work=Times LIVE|access-date=24 March 2018|language=en-US}}&lt;/ref&gt; begodu bekunguye kwaphela umuntu we Sewula-Afrika owaphakanyiswa ngalowo mnyaka. &lt;ref&gt;{{Cite news|url=https://www.iol.co.za/entertainment/celebrity-news/local/isthunzi-star-thuso-mbedu-nominated-for-emmy-award-11386771|title='Is'thunzi' star Thuso Mbedu nominated for #Emmy Award {{!}} IOL Entertainment|access-date=24 March 2018|language=en}}&lt;/ref&gt;

U-Mbedu wenza ukudlala kwakhe kokuthoma njengo-Cora kubemlando ngonyaka wee-2021 [[Amazon Prime Video|we-Amazon Video]] ''[[The Underground Railroad (miniseries)|i-The Underground Railroad]]'', esekelwe enovelini [[The Underground Railroad (novel)|enegama elifanako]] ka [[Colson Whitehead|-Colson Whitehead]] begodu iqondiswe beyakhiqizwa ngomunye owathumba i [[Academy Awards|-Academy Award]] [[Barry Jenkins|u-Barry Jenkins]] . &lt;ref&gt;{{Cite web|last=Ramos|first=Dino-Ray|date=21 October 2020|title='The Underground Railroad' Teaser: Barry Jenkins Offers First Glimpse Of Thuso Mbedu As Cora In Amazon Limited Series|url=https://deadline.com/2020/10/the-underground-railroad-teaser-trailer-berry-jenkins-thuso-mbedu-as-cora-amazon-series-1234601236/|access-date=21 October 2020|website=Deadline|language=en-US}}&lt;/ref&gt; &lt;ref&gt;{{Cite web|title=Thuso Mbedu can't wait for viewers to see her new series with Barry Jenkins|url=https://www.news24.com/channel/tv/news/thuso-mbedu-cant-wait-for-viewers-to-see-her-new-series-with-barry-jenkins-20201020-2|access-date=21 October 2020|website=Channel|date=19 October 2020|language=en}}&lt;/ref&gt; UMbedu wathola i [[Hollywood Critics Association TV Awards|-Hollywood Critics Association Award]], i- [[Independent Spirit Awards|Independent Spirit Award]], kanye ne [[Gotham Awards|-Gotham Award]] yomdlalo. &lt;ref&gt;{{Cite web|last=Ngwenya|first=Nkhensani|date=30 August 2021|title=Thuso Mbedu Walks Away With An International Award|url=https://surgezirc.co.za/2021-08-30-gossip-thuso-mbedu-walks-away-with-an-international-award/|access-date=30 August 2021|website=Surge Zirc SA|language=en-GB}}&lt;/ref&gt;

Ngenyanga kaMrhayili 2021, kwamenyezelwa bona uMbedu uzokwenza ifilimu yakhe yokuthoma njengo-Nawi aqalene no [[Viola Davis|-Viola Davis]] ku- ''[[The Woman King]]'', ifilimu yomlando ephefumulelwe ngezehlakalo zamambala ezenzeka eMbusweni we-Dahomey, &lt;ref&gt;{{Cite web|last=Höffele|first=Lerato|title=Thuso Mbedu bags role alongside Viola Davis in 'The Woman King'|url=https://ewn.co.za/2021/04/29/thuso-mbedu-bags-role-alongside-viola-davis-in-the-woman-king|access-date=30 April 2021|website=ewn.co.za|language=en}}&lt;/ref&gt; omunye wemibuso enamandla khulu ye-Afrika ngekhulu le-18 nele-19. Ifilimu le beyiqondiswe ngu [[Gina Prince-Bythewood|-Gina Prince-Bythewood]], ukusuka emtlolweni womtloli we- ''[[Fatherhood (film)|Fatherhood]]'' [[Dana Stevens (screenwriter)|u-Dana Stevens]] . &lt;ref name=&quot;Kroll&quot;&gt;{{Cite web|last=Kroll|first=Justin|date=28 April 2021|title='Underground Railroad's Thuso Mbedu To Star Opposite Viola Davis In 'The Woman King King'|url=https://deadline.com/2021/04/thuso-mbedu-viola-davis-woman-king-1234746073/|access-date=28 April 2021|website=Deadline|language=en-US}}&lt;/ref&gt; &lt;ref&gt;{{Cite web|last=Morkel|first=Graye|title=Thuso Mbedu to star opposite Viola Davis in The Woman King|url=https://www.news24.com/channel/movies/news/thuso-mbedu-to-star-opposite-viola-davis-in-the-woman-king-20210429|access-date=30 April 2021|website=Channel|language=en-US}}&lt;/ref&gt; &lt;ref&gt;{{Cite web|title=Africans making waves in Hollywood|url=https://www.sowetanlive.co.za/entertainment/2021-04-30-africans-making-waves-in-hollywood/|access-date=30 April 2021|website=SowetanLIVE|language=en-ZA}}&lt;/ref&gt;

Ngo-2023, u-Mbedu waba yinxusa nomkhulumeli we [[L'Oréal|-L'Oréal]] we-Sub-Saharan Africa. &lt;ref&gt;{{Cite web|title=The Woman King star Thuso Mbedu named L'Oréal Paris Brand Ambassador|url=https://cosmeticsbusiness.com/news/article_page/The_Woman_King_star_Thuso_Mbedu_named_LOreal_Paris_Brand_Ambassador/209187|access-date=23 June 2023|website=Cosmetics Business}}&lt;/ref&gt; &lt;ref&gt;{{Cite web|title=Thuso Mbedu named L'Oréal Paris brand ambassador|url=https://www.news24.com/life/arts-and-entertainment/celebrities/thuso-mbedu-named-loreal-paris-brand-ambassador-20230529|access-date=23 June 2023|website=News24}}&lt;/ref&gt; &lt;ref&gt;{{cite web|title=Thuso Mbedu: The infamous marathon cheats|url=https://curio.io/shows/retold/thuso-mbedu-the-not-quite-redemption-of-south-africas-infamous-ultra-marathon-cheats|website=Curio}}&lt;/ref&gt; NgoTjhirhweni 2025 [[Deadline Hollywood|''i-Deadline'']] yabika bona u-Mbedu ukhethwe indima ephambili kufilimu ezako [[Paramount Pictures|ye-Paramount]] i- ''[[Children of Blood and Bone (film)|Children of Blood and Bone]]'' njengo-Zélie hlangana no [[Viola Davis|-Viola Davis]], [[Cynthia Erivo|u-Cynthia Erivo]], [[Damson Idris|u-Damson Idris]], [[Amandla Stenberg|u-Amandla Stenberg]], u- [[Idris Elba]] no- [[Tosin Cole]] . &lt;ref&gt;{{Cite web|last=Moorman|first=Taijuan|title=Star-studded 'Children of Blood and Bone' cast revealed: What we know so far|url=https://www.usatoday.com/story/entertainment/movies/2025/01/23/children-of-blood-and-bone-cast-amandla-stenberg/77900352007/#:~:text=Star-studded%20'Children%20of%20Blood,What%20we%20know%20so%20far&amp;text=Anticipation%20is%20growing%20for%20the,those%20powers%20to%20her%20people.|access-date=2025-02-06|website=USA TODAY|language=en-US}}&lt;/ref&gt;

=== Imithombo lwazi ===

&lt;references /&gt;</text>
      <sha1>hmatpvyh52enmtmwfb9mxvcnspg579c</sha1>
    </revision>
    <revision>
      <id>5476</id>
      <parentid>5463</parentid>
      <timestamp>2025-09-04T08:32:52Z</timestamp>
      <contributor>
        <username>Mtsweni S</username>
        <id>835</id>
      </contributor>
      <comment>Created a list of references and edited sub headings</comment>
      <origin>5476</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="11610" sha1="0piz50pyrzin0mubl95bzcmj9jydy1q" xml:space="preserve">Page 1: Draft space 1

== THUSO MBEDU ==
U-Thuso Nokwanda Mbedu (owabelethwa mhla amalanga abunane ku-Velabahlinze ngonyaka we-1991) ungomunye wabadlali bakumabonwakude be-Sewula Afrika. Waduma khulu ngendima ayidlalako emdlalweni we-Sewula Afrika wabantu abatjha obizwa ngokobana yi-Sthunzi, lapho akhethwa khona ngokulandelana ukuthi athathe unongorwana wangaphetjheya obizwa nge- International Emmy ngonyaka wee-2017 kanye no-2018. U-Mbedu ekukhambeni kwesikhathi wavela ehlanganweni ebizwa ngokuthi yi- Forbes Africa 30 ngaphasi kwabantu abangaphasi kweminyaka ematjhumi amathathu ubudala ngonyaka wee-2018.

Ngonyaka wee-2021, wadlala ehlelweni elibizwa nge-Underground Railroad elitholakala kuAmazon Video, lapho kunamahlelo amanengi nekungilo elamenza bona abemdlali wokuthoma we-Sewula Afrika okhamba phambili kwezamahlelo adlala kumabonwakude we-America. Lokhu kwamenza bona athumbe unongorwana obizwa bona yi-Independent Spirit Award etholwa mumuntu wengubo okhamba phambili ngokuba mdlali wakumabonwakude ehlelweni elitjha. Waragela phambili waba ngomunye wabalingisi ehlelweni elimlando wangaphetjheya e-America obizwa ngokobana yi- The Woman King (2022) lapho adlala khona iskhundla saka Nawi.

=== IPILO YEBUNCANINI NEFUNDO ===
U-Mbedu wabelethelwa e-Midlands Medical Centre endaweni ye-Pietermaritzburg, KwaZulu-Natal. Ubelethwa ngumma okhuluma isiZulu kanye noyise okhuluma isiSotho nesiXhosa. Wakhuliswa e-Pelham ngugogo wakhe , owabamumuntu omtlhogomelako ngemva kokuhlongakalelwa babelethi bakhe bobabili asesemncani.

U-Mbedu wafunda e-Pelham Primary School bese waya e- [[Pietermaritzburg Girls' High School]] . &lt;ref&gt;{{Cite journal|url=https://www.news24.com/witness/news/from-pmb-to-the-worlds-tvs-20170129|title=From PMB to the world's TVs|journal=The Witness|first=Nompilo|last=Kunene|date=30 January 2017|access-date=21 October 2021}}&lt;/ref&gt; Waragela phambili nokufunda i-Physical Theatre kanye ne-Performing Arts Management e- [[University of the Witwatersrand]] (Wits), waphothula ngo-2013 ngama-honor, &lt;ref&gt;{{cite web|url=https://www.goodthingsguy.com/people/thuso-mbedu-underground-railroad/|title=Meet the first South African actress to lead an American series!!!|website=Good Things Guy|date=17 April 2019}}&lt;/ref&gt; ngemva kokuthatha ikhosi e- [[Stella Adler Studio of Acting]] e-New York City ngo-2012. &lt;ref&gt;{{cite web|url=http://www.youthvillage.co.za/2016/05/10-things-you-didnt-know-about-scandal-actress-thuso-mbedu/|title=10 Things You Didn't Know About Scandal Actress Thuso Mbedu|website=Youth Village|date=16 May 2016}}&lt;/ref&gt; &lt;ref name=&quot;:1&quot;&gt;{{Cite journal|url=https://www.timeslive.co.za/tshisa-live/tshisa-live/2020-09-28-i-had-no-clue-what-they-were-saying-thuso-mbedu-on-connecting-with-her-sotho-heritage/|title='I had no clue what they were saying'-Thuso Mbedu on connecting with her Sotho heritage|journal=Times Live|first=Deepika|last=Naidoo|date=28 September 2020|access-date=3 November 2021}}&lt;/ref&gt;

=== IBIZELO ===
Ekupheleni konyaka wee-2014, u-Mbedu waba nendima encani kusizini yesibili ye- [[Mzansi Magic]] soapie ''[[Isibaya]]'', ''&lt;ref name=&quot;:0&quot;&gt;{{Cite news|url=https://www.channel24.co.za/TV/News/thuso-mbedu-from-out-of-work-to-emmy-nominee-20180211|title=Thuso Mbedu: From out of work to Emmy nominee|work=Channel24|access-date=24 March 2018|language=en}}&lt;/ref&gt;'' ngaphambi kokuthi athole indima yakhe njengomfundi wezobuntatheli nomntwana u-Kitso ku ''[[Scandal! (eTV soapie)|-Scandal!]]'' . ''['' ''&lt;ref&gt;{{cite web|url=http://www.news24.com/MoveMag/Archive/thuso-mbedu-on-how-she-made-it-against-all-odds-20170728|title=Thuso Mbedu on how she made it against all odds|date=28 July 2017|work=[[News24 (website)|News24]]}}&lt;/ref&gt; &lt;ref&gt;{{Cite news|url=http://www.youthvillage.co.za/2016/05/10-things-you-didnt-know-about-scandal-actress-thuso-mbedu/|title=10 Things You Didn't Know About Scandal Actress Thuso Mbedu|date=16 May 2016|work=Youth Village|access-date=24 March 2018|language=en-US}}&lt;/ref&gt;''[[SABC 2|​]]  kanye nendima ephambili njengo-Boni Khumalo emdlalweni kamabonakude bbizwa kobana yi- ''Saints and Sinners.&lt;ref&gt;{{Cite news|last=Vieira|first=Genevieve|title=Thuso Mbedu is truly blessed|language=en|work=The Citizen|url=https://citizen.co.za/lifestyle/your-life-entertainment-your-life/entertainment-celebrities/316910/thuso-mbedu-is-truly-blessed/|access-date=24 March 2018}}&lt;/ref&gt;''

Ngemva kokungasebenzi iinyanga ezisithandathu, u-Mbedu wathola indima yakhe yokuthoma kumabonakude emdlalweni we [[Mzansi Magic|-Mzansi Magic]] welutjha ''[[Is'Thunzi|-Is'Thunzi]]'', owathoma ngoMgwengweni enyakeni wee-2016. &lt;ref name=&quot;:02&quot;&gt;{{Cite news|url=https://www.channel24.co.za/TV/News/thuso-mbedu-from-out-of-work-to-emmy-nominee-20180211|title=Thuso Mbedu: From out of work to Emmy nominee|work=Channel24|access-date=24 March 2018|language=en}}&lt;/ref&gt; &lt;ref&gt;{{Cite news|url=https://www.timeslive.co.za/tshisa-live/tshisa-live/2017-09-28-heres-5-things-you-need-to-know-about-actress-thuso-mbedu/|title=Here's 5 things you need to know about actress Thuso Mbedu|work=[[TimesLIVE]]|access-date=24 March 2018|language=en-US}}&lt;/ref&gt; Emdlalweni lo, wadlala indima ka-Winnie, umdlali othanda ukuzikhakhazisa, ofuna ukutjhada nomdlali we-rugby onjingileko nodumileko kodwana ibhudango lakhe liyatjhabalala lokha nakufanele akhambe ayokuhlala nokgharakhe obukhali e-Bergville. Lokha nakalingisa  isiqephu sokudlwengulwa emdlalweni, wahlaselwa livalo. &lt;ref&gt;{{Cite news|url=https://www.huffingtonpost.co.za/2017/11/13/thuso-mbedu-is-leaving-for-the-international-emmys-with-hope-for-south-africans_a_23275431/|title=Thuso Mbedu Is Leaving For The International Emmys With Hope For South Africans|date=13 November 2017|work=Huffington Post South Africa|access-date=24 March 2018|language=en-ZA}}&lt;/ref&gt; NgoNobayeni 2017, waphakanyiswa enongorwaneni we [[International Emmy Award|-International Emmy Award]] esigabeni sokudlala okuhle khulu komlingisi ngendima yakhe njengo-Winnie ku ''-Is'Thunzi'' &lt;ref&gt;{{Cite news|url=https://www.timeslive.co.za/tshisa-live/tshisa-live/2018-01-18-thuso-mbedu-on-life-after-emmy-nod-the-truth-is-we-are-very-dispensable/|title=Thuso Mbedu on life after Emmy nod: 'The truth is we are very dispensable'|work=Times LIVE|access-date=24 March 2018|language=en-US}}&lt;/ref&gt; begodu bekunguye kwaphela umuntu we Sewula-Afrika owaphakanyiswa ngalowo mnyaka. &lt;ref&gt;{{Cite news|url=https://www.iol.co.za/entertainment/celebrity-news/local/isthunzi-star-thuso-mbedu-nominated-for-emmy-award-11386771|title='Is'thunzi' star Thuso Mbedu nominated for #Emmy Award {{!}} IOL Entertainment|access-date=24 March 2018|language=en}}&lt;/ref&gt;

U-Mbedu wenza ukudlala kwakhe kokuthoma njengo-Cora kubemlando ngonyaka wee-2021 [[Amazon Prime Video|we-Amazon Video]] ''[[The Underground Railroad (miniseries)|i-The Underground Railroad]]'', esekelwe enovelini [[The Underground Railroad (novel)|enegama elifanako]] ka [[Colson Whitehead|-Colson Whitehead]] begodu iqondiswe beyakhiqizwa ngomunye owathumba i [[Academy Awards|-Academy Award]] [[Barry Jenkins|u-Barry Jenkins]] . &lt;ref&gt;{{Cite web|last=Ramos|first=Dino-Ray|date=21 October 2020|title='The Underground Railroad' Teaser: Barry Jenkins Offers First Glimpse Of Thuso Mbedu As Cora In Amazon Limited Series|url=https://deadline.com/2020/10/the-underground-railroad-teaser-trailer-berry-jenkins-thuso-mbedu-as-cora-amazon-series-1234601236/|access-date=21 October 2020|website=Deadline|language=en-US}}&lt;/ref&gt; &lt;ref&gt;{{Cite web|title=Thuso Mbedu can't wait for viewers to see her new series with Barry Jenkins|url=https://www.news24.com/channel/tv/news/thuso-mbedu-cant-wait-for-viewers-to-see-her-new-series-with-barry-jenkins-20201020-2|access-date=21 October 2020|website=Channel|date=19 October 2020|language=en}}&lt;/ref&gt; UMbedu wathola i [[Hollywood Critics Association TV Awards|-Hollywood Critics Association Award]], i- [[Independent Spirit Awards|Independent Spirit Award]], kanye ne [[Gotham Awards|-Gotham Award]] yomdlalo. &lt;ref&gt;{{Cite web|last=Ngwenya|first=Nkhensani|date=30 August 2021|title=Thuso Mbedu Walks Away With An International Award|url=https://surgezirc.co.za/2021-08-30-gossip-thuso-mbedu-walks-away-with-an-international-award/|access-date=30 August 2021|website=Surge Zirc SA|language=en-GB}}&lt;/ref&gt;

Ngenyanga kaMrhayili 2021, kwamenyezelwa bona uMbedu uzokwenza ifilimu yakhe yokuthoma njengo-Nawi aqalene no [[Viola Davis|-Viola Davis]] ku- ''[[The Woman King]]'', ifilimu yomlando ephefumulelwe ngezehlakalo zamambala ezenzeka eMbusweni we-Dahomey, &lt;ref&gt;{{Cite web|last=Höffele|first=Lerato|title=Thuso Mbedu bags role alongside Viola Davis in 'The Woman King'|url=https://ewn.co.za/2021/04/29/thuso-mbedu-bags-role-alongside-viola-davis-in-the-woman-king|access-date=30 April 2021|website=ewn.co.za|language=en}}&lt;/ref&gt; omunye wemibuso enamandla khulu ye-Afrika ngekhulu le-18 nele-19. Ifilimu le beyiqondiswe ngu [[Gina Prince-Bythewood|-Gina Prince-Bythewood]], ukusuka emtlolweni womtloli we- ''[[Fatherhood (film)|Fatherhood]]'' [[Dana Stevens (screenwriter)|u-Dana Stevens]] . &lt;ref name=&quot;Kroll&quot;&gt;{{Cite web|last=Kroll|first=Justin|date=28 April 2021|title='Underground Railroad's Thuso Mbedu To Star Opposite Viola Davis In 'The Woman King King'|url=https://deadline.com/2021/04/thuso-mbedu-viola-davis-woman-king-1234746073/|access-date=28 April 2021|website=Deadline|language=en-US}}&lt;/ref&gt; &lt;ref&gt;{{Cite web|last=Morkel|first=Graye|title=Thuso Mbedu to star opposite Viola Davis in The Woman King|url=https://www.news24.com/channel/movies/news/thuso-mbedu-to-star-opposite-viola-davis-in-the-woman-king-20210429|access-date=30 April 2021|website=Channel|language=en-US}}&lt;/ref&gt; &lt;ref&gt;{{Cite web|title=Africans making waves in Hollywood|url=https://www.sowetanlive.co.za/entertainment/2021-04-30-africans-making-waves-in-hollywood/|access-date=30 April 2021|website=SowetanLIVE|language=en-ZA}}&lt;/ref&gt;

Ngo-2023, u-Mbedu waba yinxusa nomkhulumeli we [[L'Oréal|-L'Oréal]] we-Sub-Saharan Africa. &lt;ref&gt;{{Cite web|title=The Woman King star Thuso Mbedu named L'Oréal Paris Brand Ambassador|url=https://cosmeticsbusiness.com/news/article_page/The_Woman_King_star_Thuso_Mbedu_named_LOreal_Paris_Brand_Ambassador/209187|access-date=23 June 2023|website=Cosmetics Business}}&lt;/ref&gt; &lt;ref&gt;{{Cite web|title=Thuso Mbedu named L'Oréal Paris brand ambassador|url=https://www.news24.com/life/arts-and-entertainment/celebrities/thuso-mbedu-named-loreal-paris-brand-ambassador-20230529|access-date=23 June 2023|website=News24}}&lt;/ref&gt; &lt;ref&gt;{{cite web|title=Thuso Mbedu: The infamous marathon cheats|url=https://curio.io/shows/retold/thuso-mbedu-the-not-quite-redemption-of-south-africas-infamous-ultra-marathon-cheats|website=Curio}}&lt;/ref&gt; NgoTjhirhweni 2025 [[Deadline Hollywood|''i-Deadline'']] yabika bona u-Mbedu ukhethwe indima ephambili kufilimu ezako [[Paramount Pictures|ye-Paramount]] i- ''[[Children of Blood and Bone (film)|Children of Blood and Bone]]'' njengo-Zélie hlangana no [[Viola Davis|-Viola Davis]], [[Cynthia Erivo|u-Cynthia Erivo]], [[Damson Idris|u-Damson Idris]], [[Amandla Stenberg|u-Amandla Stenberg]], u- [[Idris Elba]] no- [[Tosin Cole]] . &lt;ref&gt;{{Cite web|last=Moorman|first=Taijuan|title=Star-studded 'Children of Blood and Bone' cast revealed: What we know so far|url=https://www.usatoday.com/story/entertainment/movies/2025/01/23/children-of-blood-and-bone-cast-amandla-stenberg/77900352007/#:~:text=Star-studded%20'Children%20of%20Blood,What%20we%20know%20so%20far&amp;text=Anticipation%20is%20growing%20for%20the,those%20powers%20to%20her%20people.|access-date=2025-02-06|website=USA TODAY|language=en-US}}&lt;/ref&gt;

=== Imithombo lwazi ===

&lt;references /&gt;</text>
      <sha1>0piz50pyrzin0mubl95bzcmj9jydy1q</sha1>
    </revision>
    <revision>
      <id>5625</id>
      <parentid>5476</parentid>
      <timestamp>2025-09-04T10:42:19Z</timestamp>
      <contributor>
        <username>Mtsweni S</username>
        <id>835</id>
      </contributor>
      <comment>Added a picture</comment>
      <origin>5625</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="11695" sha1="828lb95j412yvmszea3e34suc4aks3v" xml:space="preserve">Page 1: Draft space 1

== THUSO MBEDU ==
[[Isimumathi:Thuso Mbedu talking in 2019 02.png|thumb|Isithombe sakaThuso Mbedu]]



U-Thuso Nokwanda Mbedu (owabelethwa mhla amalanga abunane ku-Velabahlinze ngonyaka we-1991) ungomunye wabadlali bakumabonwakude be-Sewula Afrika. Waduma khulu ngendima ayidlalako emdlalweni we-Sewula Afrika wabantu abatjha obizwa ngokobana yi-Sthunzi, lapho akhethwa khona ngokulandelana ukuthi athathe unongorwana wangaphetjheya obizwa nge- International Emmy ngonyaka wee-2017 kanye no-2018. U-Mbedu ekukhambeni kwesikhathi wavela ehlanganweni ebizwa ngokuthi yi- Forbes Africa 30 ngaphasi kwabantu abangaphasi kweminyaka ematjhumi amathathu ubudala ngonyaka wee-2018.

Ngonyaka wee-2021, wadlala ehlelweni elibizwa nge-Underground Railroad elitholakala kuAmazon Video, lapho kunamahlelo amanengi nekungilo elamenza bona abemdlali wokuthoma we-Sewula Afrika okhamba phambili kwezamahlelo adlala kumabonwakude we-America. Lokhu kwamenza bona athumbe unongorwana obizwa bona yi-Independent Spirit Award etholwa mumuntu wengubo okhamba phambili ngokuba mdlali wakumabonwakude ehlelweni elitjha. Waragela phambili waba ngomunye wabalingisi ehlelweni elimlando wangaphetjheya e-America obizwa ngokobana yi- The Woman King (2022) lapho adlala khona iskhundla saka Nawi.

=== IPILO YEBUNCANINI NEFUNDO ===
U-Mbedu wabelethelwa e-Midlands Medical Centre endaweni ye-Pietermaritzburg, KwaZulu-Natal. Ubelethwa ngumma okhuluma isiZulu kanye noyise okhuluma isiSotho nesiXhosa. Wakhuliswa e-Pelham ngugogo wakhe , owabamumuntu omtlhogomelako ngemva kokuhlongakalelwa babelethi bakhe bobabili asesemncani.

U-Mbedu wafunda e-Pelham Primary School bese waya e- [[Pietermaritzburg Girls' High School]] . &lt;ref&gt;{{Cite journal|url=https://www.news24.com/witness/news/from-pmb-to-the-worlds-tvs-20170129|title=From PMB to the world's TVs|journal=The Witness|first=Nompilo|last=Kunene|date=30 January 2017|access-date=21 October 2021}}&lt;/ref&gt; Waragela phambili nokufunda i-Physical Theatre kanye ne-Performing Arts Management e- [[University of the Witwatersrand]] (Wits), waphothula ngo-2013 ngama-honor, &lt;ref&gt;{{cite web|url=https://www.goodthingsguy.com/people/thuso-mbedu-underground-railroad/|title=Meet the first South African actress to lead an American series!!!|website=Good Things Guy|date=17 April 2019}}&lt;/ref&gt; ngemva kokuthatha ikhosi e- [[Stella Adler Studio of Acting]] e-New York City ngo-2012. &lt;ref&gt;{{cite web|url=http://www.youthvillage.co.za/2016/05/10-things-you-didnt-know-about-scandal-actress-thuso-mbedu/|title=10 Things You Didn't Know About Scandal Actress Thuso Mbedu|website=Youth Village|date=16 May 2016}}&lt;/ref&gt; &lt;ref name=&quot;:1&quot;&gt;{{Cite journal|url=https://www.timeslive.co.za/tshisa-live/tshisa-live/2020-09-28-i-had-no-clue-what-they-were-saying-thuso-mbedu-on-connecting-with-her-sotho-heritage/|title='I had no clue what they were saying'-Thuso Mbedu on connecting with her Sotho heritage|journal=Times Live|first=Deepika|last=Naidoo|date=28 September 2020|access-date=3 November 2021}}&lt;/ref&gt;

=== IBIZELO ===
Ekupheleni konyaka wee-2014, u-Mbedu waba nendima encani kusizini yesibili ye- [[Mzansi Magic]] soapie ''[[Isibaya]]'', ''&lt;ref name=&quot;:0&quot;&gt;{{Cite news|url=https://www.channel24.co.za/TV/News/thuso-mbedu-from-out-of-work-to-emmy-nominee-20180211|title=Thuso Mbedu: From out of work to Emmy nominee|work=Channel24|access-date=24 March 2018|language=en}}&lt;/ref&gt;'' ngaphambi kokuthi athole indima yakhe njengomfundi wezobuntatheli nomntwana u-Kitso ku ''[[Scandal! (eTV soapie)|-Scandal!]]'' . ''['' ''&lt;ref&gt;{{cite web|url=http://www.news24.com/MoveMag/Archive/thuso-mbedu-on-how-she-made-it-against-all-odds-20170728|title=Thuso Mbedu on how she made it against all odds|date=28 July 2017|work=[[News24 (website)|News24]]}}&lt;/ref&gt; &lt;ref&gt;{{Cite news|url=http://www.youthvillage.co.za/2016/05/10-things-you-didnt-know-about-scandal-actress-thuso-mbedu/|title=10 Things You Didn't Know About Scandal Actress Thuso Mbedu|date=16 May 2016|work=Youth Village|access-date=24 March 2018|language=en-US}}&lt;/ref&gt;''[[SABC 2|​]]  kanye nendima ephambili njengo-Boni Khumalo emdlalweni kamabonakude bbizwa kobana yi- ''Saints and Sinners.&lt;ref&gt;{{Cite news|last=Vieira|first=Genevieve|title=Thuso Mbedu is truly blessed|language=en|work=The Citizen|url=https://citizen.co.za/lifestyle/your-life-entertainment-your-life/entertainment-celebrities/316910/thuso-mbedu-is-truly-blessed/|access-date=24 March 2018}}&lt;/ref&gt;''

Ngemva kokungasebenzi iinyanga ezisithandathu, u-Mbedu wathola indima yakhe yokuthoma kumabonakude emdlalweni we [[Mzansi Magic|-Mzansi Magic]] welutjha ''[[Is'Thunzi|-Is'Thunzi]]'', owathoma ngoMgwengweni enyakeni wee-2016. &lt;ref name=&quot;:02&quot;&gt;{{Cite news|url=https://www.channel24.co.za/TV/News/thuso-mbedu-from-out-of-work-to-emmy-nominee-20180211|title=Thuso Mbedu: From out of work to Emmy nominee|work=Channel24|access-date=24 March 2018|language=en}}&lt;/ref&gt; &lt;ref&gt;{{Cite news|url=https://www.timeslive.co.za/tshisa-live/tshisa-live/2017-09-28-heres-5-things-you-need-to-know-about-actress-thuso-mbedu/|title=Here's 5 things you need to know about actress Thuso Mbedu|work=[[TimesLIVE]]|access-date=24 March 2018|language=en-US}}&lt;/ref&gt; Emdlalweni lo, wadlala indima ka-Winnie, umdlali othanda ukuzikhakhazisa, ofuna ukutjhada nomdlali we-rugby onjingileko nodumileko kodwana ibhudango lakhe liyatjhabalala lokha nakufanele akhambe ayokuhlala nokgharakhe obukhali e-Bergville. Lokha nakalingisa  isiqephu sokudlwengulwa emdlalweni, wahlaselwa livalo. &lt;ref&gt;{{Cite news|url=https://www.huffingtonpost.co.za/2017/11/13/thuso-mbedu-is-leaving-for-the-international-emmys-with-hope-for-south-africans_a_23275431/|title=Thuso Mbedu Is Leaving For The International Emmys With Hope For South Africans|date=13 November 2017|work=Huffington Post South Africa|access-date=24 March 2018|language=en-ZA}}&lt;/ref&gt; NgoNobayeni 2017, waphakanyiswa enongorwaneni we [[International Emmy Award|-International Emmy Award]] esigabeni sokudlala okuhle khulu komlingisi ngendima yakhe njengo-Winnie ku ''-Is'Thunzi'' &lt;ref&gt;{{Cite news|url=https://www.timeslive.co.za/tshisa-live/tshisa-live/2018-01-18-thuso-mbedu-on-life-after-emmy-nod-the-truth-is-we-are-very-dispensable/|title=Thuso Mbedu on life after Emmy nod: 'The truth is we are very dispensable'|work=Times LIVE|access-date=24 March 2018|language=en-US}}&lt;/ref&gt; begodu bekunguye kwaphela umuntu we Sewula-Afrika owaphakanyiswa ngalowo mnyaka. &lt;ref&gt;{{Cite news|url=https://www.iol.co.za/entertainment/celebrity-news/local/isthunzi-star-thuso-mbedu-nominated-for-emmy-award-11386771|title='Is'thunzi' star Thuso Mbedu nominated for #Emmy Award {{!}} IOL Entertainment|access-date=24 March 2018|language=en}}&lt;/ref&gt;

U-Mbedu wenza ukudlala kwakhe kokuthoma njengo-Cora kubemlando ngonyaka wee-2021 [[Amazon Prime Video|we-Amazon Video]] ''[[The Underground Railroad (miniseries)|i-The Underground Railroad]]'', esekelwe enovelini [[The Underground Railroad (novel)|enegama elifanako]] ka [[Colson Whitehead|-Colson Whitehead]] begodu iqondiswe beyakhiqizwa ngomunye owathumba i [[Academy Awards|-Academy Award]] [[Barry Jenkins|u-Barry Jenkins]] . &lt;ref&gt;{{Cite web|last=Ramos|first=Dino-Ray|date=21 October 2020|title='The Underground Railroad' Teaser: Barry Jenkins Offers First Glimpse Of Thuso Mbedu As Cora In Amazon Limited Series|url=https://deadline.com/2020/10/the-underground-railroad-teaser-trailer-berry-jenkins-thuso-mbedu-as-cora-amazon-series-1234601236/|access-date=21 October 2020|website=Deadline|language=en-US}}&lt;/ref&gt; &lt;ref&gt;{{Cite web|title=Thuso Mbedu can't wait for viewers to see her new series with Barry Jenkins|url=https://www.news24.com/channel/tv/news/thuso-mbedu-cant-wait-for-viewers-to-see-her-new-series-with-barry-jenkins-20201020-2|access-date=21 October 2020|website=Channel|date=19 October 2020|language=en}}&lt;/ref&gt; UMbedu wathola i [[Hollywood Critics Association TV Awards|-Hollywood Critics Association Award]], i- [[Independent Spirit Awards|Independent Spirit Award]], kanye ne [[Gotham Awards|-Gotham Award]] yomdlalo. &lt;ref&gt;{{Cite web|last=Ngwenya|first=Nkhensani|date=30 August 2021|title=Thuso Mbedu Walks Away With An International Award|url=https://surgezirc.co.za/2021-08-30-gossip-thuso-mbedu-walks-away-with-an-international-award/|access-date=30 August 2021|website=Surge Zirc SA|language=en-GB}}&lt;/ref&gt;

Ngenyanga kaMrhayili 2021, kwamenyezelwa bona uMbedu uzokwenza ifilimu yakhe yokuthoma njengo-Nawi aqalene no [[Viola Davis|-Viola Davis]] ku- ''[[The Woman King]]'', ifilimu yomlando ephefumulelwe ngezehlakalo zamambala ezenzeka eMbusweni we-Dahomey, &lt;ref&gt;{{Cite web|last=Höffele|first=Lerato|title=Thuso Mbedu bags role alongside Viola Davis in 'The Woman King'|url=https://ewn.co.za/2021/04/29/thuso-mbedu-bags-role-alongside-viola-davis-in-the-woman-king|access-date=30 April 2021|website=ewn.co.za|language=en}}&lt;/ref&gt; omunye wemibuso enamandla khulu ye-Afrika ngekhulu le-18 nele-19. Ifilimu le beyiqondiswe ngu [[Gina Prince-Bythewood|-Gina Prince-Bythewood]], ukusuka emtlolweni womtloli we- ''[[Fatherhood (film)|Fatherhood]]'' [[Dana Stevens (screenwriter)|u-Dana Stevens]] . &lt;ref name=&quot;Kroll&quot;&gt;{{Cite web|last=Kroll|first=Justin|date=28 April 2021|title='Underground Railroad's Thuso Mbedu To Star Opposite Viola Davis In 'The Woman King King'|url=https://deadline.com/2021/04/thuso-mbedu-viola-davis-woman-king-1234746073/|access-date=28 April 2021|website=Deadline|language=en-US}}&lt;/ref&gt; &lt;ref&gt;{{Cite web|last=Morkel|first=Graye|title=Thuso Mbedu to star opposite Viola Davis in The Woman King|url=https://www.news24.com/channel/movies/news/thuso-mbedu-to-star-opposite-viola-davis-in-the-woman-king-20210429|access-date=30 April 2021|website=Channel|language=en-US}}&lt;/ref&gt; &lt;ref&gt;{{Cite web|title=Africans making waves in Hollywood|url=https://www.sowetanlive.co.za/entertainment/2021-04-30-africans-making-waves-in-hollywood/|access-date=30 April 2021|website=SowetanLIVE|language=en-ZA}}&lt;/ref&gt;

Ngo-2023, u-Mbedu waba yinxusa nomkhulumeli we [[L'Oréal|-L'Oréal]] we-Sub-Saharan Africa. &lt;ref&gt;{{Cite web|title=The Woman King star Thuso Mbedu named L'Oréal Paris Brand Ambassador|url=https://cosmeticsbusiness.com/news/article_page/The_Woman_King_star_Thuso_Mbedu_named_LOreal_Paris_Brand_Ambassador/209187|access-date=23 June 2023|website=Cosmetics Business}}&lt;/ref&gt; &lt;ref&gt;{{Cite web|title=Thuso Mbedu named L'Oréal Paris brand ambassador|url=https://www.news24.com/life/arts-and-entertainment/celebrities/thuso-mbedu-named-loreal-paris-brand-ambassador-20230529|access-date=23 June 2023|website=News24}}&lt;/ref&gt; &lt;ref&gt;{{cite web|title=Thuso Mbedu: The infamous marathon cheats|url=https://curio.io/shows/retold/thuso-mbedu-the-not-quite-redemption-of-south-africas-infamous-ultra-marathon-cheats|website=Curio}}&lt;/ref&gt; NgoTjhirhweni 2025 [[Deadline Hollywood|''i-Deadline'']] yabika bona u-Mbedu ukhethwe indima ephambili kufilimu ezako [[Paramount Pictures|ye-Paramount]] i- ''[[Children of Blood and Bone (film)|Children of Blood and Bone]]'' njengo-Zélie hlangana no [[Viola Davis|-Viola Davis]], [[Cynthia Erivo|u-Cynthia Erivo]], [[Damson Idris|u-Damson Idris]], [[Amandla Stenberg|u-Amandla Stenberg]], u- [[Idris Elba]] no- [[Tosin Cole]] . &lt;ref&gt;{{Cite web|last=Moorman|first=Taijuan|title=Star-studded 'Children of Blood and Bone' cast revealed: What we know so far|url=https://www.usatoday.com/story/entertainment/movies/2025/01/23/children-of-blood-and-bone-cast-amandla-stenberg/77900352007/#:~:text=Star-studded%20'Children%20of%20Blood,What%20we%20know%20so%20far&amp;text=Anticipation%20is%20growing%20for%20the,those%20powers%20to%20her%20people.|access-date=2025-02-06|website=USA TODAY|language=en-US}}&lt;/ref&gt;

=== Imithombo lwazi ===

&lt;references /&gt;</text>
      <sha1>828lb95j412yvmszea3e34suc4aks3v</sha1>
    </revision>
    <revision>
      <id>5656</id>
      <parentid>5625</parentid>
      <timestamp>2025-09-04T11:08:31Z</timestamp>
      <contributor>
        <username>Mtsweni S</username>
        <id>835</id>
      </contributor>
      <comment>edited some errors</comment>
      <origin>5656</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="11103" sha1="fpr6g1xwehhs0m7pio7fh6xgribe8lo" xml:space="preserve">Page 1: Draft space 1

== THUSO MBEDU ==
[[Isimumathi:Thuso Mbedu talking in 2019 02.png|thumb|Isithombe sakaThuso Mbedu]]



U-Thuso Nokwanda Mbedu (owabelethwa mhla amalanga abunane ku-Velabahlinze ngonyaka we-1991) ungomunye wabadlali bakumabonwakude be-Sewula Afrika. Waduma khulu ngendima ayidlalako emdlalweni we-Sewula Afrika wabantu abatjha obizwa ngokobana yi-Sthunzi, lapho akhethwa khona ngokulandelana ukuthi athathe unongorwana wangaphetjheya obizwa nge- International Emmy ngonyaka wee-2017 kanye no-2018. U-Mbedu ekukhambeni kwesikhathi wavela ehlanganweni ebizwa ngokuthi yi- Forbes Africa 30 ngaphasi kwabantu abangaphasi kweminyaka ematjhumi amathathu ubudala ngonyaka wee-2018.

Ngonyaka wee-2021, wadlala ehlelweni elibizwa nge-Underground Railroad elitholakala kuAmazon Video, lapho kunamahlelo amanengi nekungilo elamenza bona abemdlali wokuthoma we-Sewula Afrika okhamba phambili kwezamahlelo adlala kumabonwakude we-America. Lokhu kwamenza bona athumbe unongorwana obizwa bona yi-Independent Spirit Award etholwa mumuntu wengubo okhamba phambili ngokuba mdlali wakumabonwakude ehlelweni elitjha. Waragela phambili waba ngomunye wabalingisi ehlelweni elimlando wangaphetjheya e-America obizwa ngokobana yi- The Woman King (2022) lapho adlala khona iskhundla saka Nawi.

=== IPILO YEBUNCANINI NEFUNDO ===
U-Mbedu wabelethelwa e-Midlands Medical Centre endaweni ye-Pietermaritzburg, KwaZulu-Natal. Ubelethwa ngumma okhuluma isiZulu kanye noyise okhuluma isiSotho nesiXhosa. Wakhuliswa e-Pelham ngugogo wakhe , owabamumuntu omtlhogomelako ngemva kokuhlongakalelwa babelethi bakhe bobabili asesemncani.

U-Mbedu wafunda e-Pelham Primary School bese waya e- Pietermaritzburg Girls' High School . &lt;ref&gt;{{Cite journal|url=https://www.news24.com/witness/news/from-pmb-to-the-worlds-tvs-20170129|title=From PMB to the world's TVs|journal=The Witness|first=Nompilo|last=Kunene|date=30 January 2017|access-date=21 October 2021}}&lt;/ref&gt; Waragela phambili nokufunda i-Physical Theatre kanye ne-Performing Arts Management e- University of the Witwatersrand (Wits), waphothula ngo-2013 ngama-honor, &lt;ref&gt;{{cite web|url=https://www.goodthingsguy.com/people/thuso-mbedu-underground-railroad/|title=Meet the first South African actress to lead an American series!!!|website=Good Things Guy|date=17 April 2019}}&lt;/ref&gt; ngemva kokuthatha ikhosi e- Stella Adler Studio of Acting e-New York City ngo-2012. &lt;ref&gt;{{cite web|url=http://www.youthvillage.co.za/2016/05/10-things-you-didnt-know-about-scandal-actress-thuso-mbedu/|title=10 Things You Didn't Know About Scandal Actress Thuso Mbedu|website=Youth Village|date=16 May 2016}}&lt;/ref&gt; &lt;ref name=&quot;:1&quot;&gt;{{Cite journal|url=https://www.timeslive.co.za/tshisa-live/tshisa-live/2020-09-28-i-had-no-clue-what-they-were-saying-thuso-mbedu-on-connecting-with-her-sotho-heritage/|title='I had no clue what they were saying'-Thuso Mbedu on connecting with her Sotho heritage|journal=Times Live|first=Deepika|last=Naidoo|date=28 September 2020|access-date=3 November 2021}}&lt;/ref&gt;

=== IBIZELO ===
Ekupheleni konyaka wee-2014, u-Mbedu waba nendima encani kusizini yesibili ye- Mzansi Magic soapie ''[[Isibaya]]'', ''&lt;ref name=&quot;:0&quot;&gt;{{Cite news|url=https://www.channel24.co.za/TV/News/thuso-mbedu-from-out-of-work-to-emmy-nominee-20180211|title=Thuso Mbedu: From out of work to Emmy nominee|work=Channel24|access-date=24 March 2018|language=en}}&lt;/ref&gt;'' ngaphambi kokuthi athole indima yakhe njengomfundi wezobuntatheli nomntwana u-Kitso ku ''-Scandal!'' . ''['' ''&lt;ref&gt;{{cite web|url=http://www.news24.com/MoveMag/Archive/thuso-mbedu-on-how-she-made-it-against-all-odds-20170728|title=Thuso Mbedu on how she made it against all odds|date=28 July 2017|work=[[News24 (website)|News24]]}}&lt;/ref&gt; &lt;ref&gt;{{Cite news|url=http://www.youthvillage.co.za/2016/05/10-things-you-didnt-know-about-scandal-actress-thuso-mbedu/|title=10 Things You Didn't Know About Scandal Actress Thuso Mbedu|date=16 May 2016|work=Youth Village|access-date=24 March 2018|language=en-US}}&lt;/ref&gt;''[[SABC 2|​]]  kanye nendima ephambili njengo-Boni Khumalo emdlalweni kamabonakude bbizwa kobana yi- ''Saints and Sinners.&lt;ref&gt;{{Cite news|last=Vieira|first=Genevieve|title=Thuso Mbedu is truly blessed|language=en|work=The Citizen|url=https://citizen.co.za/lifestyle/your-life-entertainment-your-life/entertainment-celebrities/316910/thuso-mbedu-is-truly-blessed/|access-date=24 March 2018}}&lt;/ref&gt;''

Ngemva kokungasebenzi iinyanga ezisithandathu, u-Mbedu wathola indima yakhe yokuthoma kumabonakude emdlalweni we -Mzansi Magic welutjha ''-Is'Thunzi'', owathoma ngoMgwengweni enyakeni wee-2016. &lt;ref name=&quot;:02&quot;&gt;{{Cite news|url=https://www.channel24.co.za/TV/News/thuso-mbedu-from-out-of-work-to-emmy-nominee-20180211|title=Thuso Mbedu: From out of work to Emmy nominee|work=Channel24|access-date=24 March 2018|language=en}}&lt;/ref&gt; &lt;ref&gt;{{Cite news|url=https://www.timeslive.co.za/tshisa-live/tshisa-live/2017-09-28-heres-5-things-you-need-to-know-about-actress-thuso-mbedu/|title=Here's 5 things you need to know about actress Thuso Mbedu|work=[[TimesLIVE]]|access-date=24 March 2018|language=en-US}}&lt;/ref&gt; Emdlalweni lo, wadlala indima ka-Winnie, umdlali othanda ukuzikhakhazisa, ofuna ukutjhada nomdlali we-rugby onjingileko nodumileko kodwana ibhudango lakhe liyatjhabalala lokha nakufanele akhambe ayokuhlala nokgharakhe obukhali e-Bergville. Lokha nakalingisa  isiqephu sokudlwengulwa emdlalweni, wahlaselwa livalo. &lt;ref&gt;{{Cite news|url=https://www.huffingtonpost.co.za/2017/11/13/thuso-mbedu-is-leaving-for-the-international-emmys-with-hope-for-south-africans_a_23275431/|title=Thuso Mbedu Is Leaving For The International Emmys With Hope For South Africans|date=13 November 2017|work=Huffington Post South Africa|access-date=24 March 2018|language=en-ZA}}&lt;/ref&gt; NgoNobayeni 2017, waphakanyiswa enongorwaneni we -International Emmy Award esigabeni sokudlala okuhle khulu komlingisi ngendima yakhe njengo-Winnie ku ''-Is'Thunzi'' &lt;ref&gt;{{Cite news|url=https://www.timeslive.co.za/tshisa-live/tshisa-live/2018-01-18-thuso-mbedu-on-life-after-emmy-nod-the-truth-is-we-are-very-dispensable/|title=Thuso Mbedu on life after Emmy nod: 'The truth is we are very dispensable'|work=Times LIVE|access-date=24 March 2018|language=en-US}}&lt;/ref&gt; begodu bekunguye kwaphela umuntu we Sewula-Afrika owaphakanyiswa ngalowo mnyaka. &lt;ref&gt;{{Cite news|url=https://www.iol.co.za/entertainment/celebrity-news/local/isthunzi-star-thuso-mbedu-nominated-for-emmy-award-11386771|title='Is'thunzi' star Thuso Mbedu nominated for #Emmy Award {{!}} IOL Entertainment|access-date=24 March 2018|language=en}}&lt;/ref&gt;

U-Mbedu wenza ukudlala kwakhe kokuthoma njengo-Cora kubemlando ngonyaka wee-2021 we-Amazon Video ''i-The Underground Railroad'', esekelwe enovelini enegama elifanako ka -Colson Whitehead begodu iqondiswe beyakhiqizwa ngomunye owathumba i -Academy Award u-Barry Jenkins . &lt;ref&gt;{{Cite web|last=Ramos|first=Dino-Ray|date=21 October 2020|title='The Underground Railroad' Teaser: Barry Jenkins Offers First Glimpse Of Thuso Mbedu As Cora In Amazon Limited Series|url=https://deadline.com/2020/10/the-underground-railroad-teaser-trailer-berry-jenkins-thuso-mbedu-as-cora-amazon-series-1234601236/|access-date=21 October 2020|website=Deadline|language=en-US}}&lt;/ref&gt; &lt;ref&gt;{{Cite web|title=Thuso Mbedu can't wait for viewers to see her new series with Barry Jenkins|url=https://www.news24.com/channel/tv/news/thuso-mbedu-cant-wait-for-viewers-to-see-her-new-series-with-barry-jenkins-20201020-2|access-date=21 October 2020|website=Channel|date=19 October 2020|language=en}}&lt;/ref&gt; UMbedu wathola i -Hollywood Critics Association Award, i- Independent Spirit Award, kanye ne -Gotham Award yomdlalo. &lt;ref&gt;{{Cite web|last=Ngwenya|first=Nkhensani|date=30 August 2021|title=Thuso Mbedu Walks Away With An International Award|url=https://surgezirc.co.za/2021-08-30-gossip-thuso-mbedu-walks-away-with-an-international-award/|access-date=30 August 2021|website=Surge Zirc SA|language=en-GB}}&lt;/ref&gt;

Ngenyanga kaMrhayili 2021, kwamenyezelwa bona uMbedu uzokwenza ifilimu yakhe yokuthoma njengo-Nawi aqalene no -Viola Davis ku- ''The Woman King'', ifilimu yomlando ephefumulelwe ngezehlakalo zamambala ezenzeka eMbusweni we-Dahomey, &lt;ref&gt;{{Cite web|last=Höffele|first=Lerato|title=Thuso Mbedu bags role alongside Viola Davis in 'The Woman King'|url=https://ewn.co.za/2021/04/29/thuso-mbedu-bags-role-alongside-viola-davis-in-the-woman-king|access-date=30 April 2021|website=ewn.co.za|language=en}}&lt;/ref&gt; omunye wemibuso enamandla khulu ye-Afrika ngekhulu le-18 nele-19. Ifilimu le beyiqondiswe ngu [[Gina Prince-Bythewood|-Gina Prince-Bythewood]], ukusuka emtlolweni womtloli we- ''Fatherhood'' u-Dana Stevens . &lt;ref name=&quot;Kroll&quot;&gt;{{Cite web|last=Kroll|first=Justin|date=28 April 2021|title='Underground Railroad's Thuso Mbedu To Star Opposite Viola Davis In 'The Woman King King'|url=https://deadline.com/2021/04/thuso-mbedu-viola-davis-woman-king-1234746073/|access-date=28 April 2021|website=Deadline|language=en-US}}&lt;/ref&gt; &lt;ref&gt;{{Cite web|last=Morkel|first=Graye|title=Thuso Mbedu to star opposite Viola Davis in The Woman King|url=https://www.news24.com/channel/movies/news/thuso-mbedu-to-star-opposite-viola-davis-in-the-woman-king-20210429|access-date=30 April 2021|website=Channel|language=en-US}}&lt;/ref&gt; &lt;ref&gt;{{Cite web|title=Africans making waves in Hollywood|url=https://www.sowetanlive.co.za/entertainment/2021-04-30-africans-making-waves-in-hollywood/|access-date=30 April 2021|website=SowetanLIVE|language=en-ZA}}&lt;/ref&gt;

Ngo-2023, u-Mbedu waba yinxusa nomkhulumeli we [[L'Oréal|-L'Oréal]] we-Sub-Saharan Africa. &lt;ref&gt;{{Cite web|title=The Woman King star Thuso Mbedu named L'Oréal Paris Brand Ambassador|url=https://cosmeticsbusiness.com/news/article_page/The_Woman_King_star_Thuso_Mbedu_named_LOreal_Paris_Brand_Ambassador/209187|access-date=23 June 2023|website=Cosmetics Business}}&lt;/ref&gt; &lt;ref&gt;{{Cite web|title=Thuso Mbedu named L'Oréal Paris brand ambassador|url=https://www.news24.com/life/arts-and-entertainment/celebrities/thuso-mbedu-named-loreal-paris-brand-ambassador-20230529|access-date=23 June 2023|website=News24}}&lt;/ref&gt; &lt;ref&gt;{{cite web|title=Thuso Mbedu: The infamous marathon cheats|url=https://curio.io/shows/retold/thuso-mbedu-the-not-quite-redemption-of-south-africas-infamous-ultra-marathon-cheats|website=Curio}}&lt;/ref&gt; NgoTjhirhweni 2025 ''i-Deadline'' yabika bona u-Mbedu ukhethwe indima ephambili kufilimu ezako ye-Paramount i- ''Children of Blood and Bone'' njengo-Zélie hlangana no -Viola Davis, u-Cynthia Erivo, u-Damson Idris, u-Amandla Stenberg, u- Idris Elba no- Tosin Cole . &lt;ref&gt;{{Cite web|last=Moorman|first=Taijuan|title=Star-studded 'Children of Blood and Bone' cast revealed: What we know so far|url=https://www.usatoday.com/story/entertainment/movies/2025/01/23/children-of-blood-and-bone-cast-amandla-stenberg/77900352007/#:~:text=Star-studded%20'Children%20of%20Blood,What%20we%20know%20so%20far&amp;text=Anticipation%20is%20growing%20for%20the,those%20powers%20to%20her%20people.|access-date=2025-02-06|website=USA TODAY|language=en-US}}&lt;/ref&gt;

=== Imithombo lwazi ===

&lt;references /&gt;</text>
      <sha1>fpr6g1xwehhs0m7pio7fh6xgribe8lo</sha1>
    </revision>
    <revision>
      <id>5669</id>
      <parentid>5656</parentid>
      <timestamp>2025-09-04T11:20:23Z</timestamp>
      <contributor>
        <username>Mtsweni S</username>
        <id>835</id>
      </contributor>
      <origin>5669</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="11101" sha1="qi3l6t5j4ba815dlk4aabp7hy6kiugm" xml:space="preserve">Page 1: Draft space 1

== THUSO MBEDU ==
[[Isimumathi:Thuso Mbedu talking in 2019 02.png|thumb|Isithombe sakaThuso Mbedu]]

U-Thuso Nokwanda Mbedu (owabelethwa mhla amalanga abunane ku-Velabahlinze ngonyaka we-1991) ungomunye wabadlali bakumabonwakude be-Sewula Afrika. Waduma khulu ngendima ayidlalako emdlalweni we-Sewula Afrika wabantu abatjha obizwa ngokobana yi-Sthunzi, lapho akhethwa khona ngokulandelana ukuthi athathe unongorwana wangaphetjheya obizwa nge- International Emmy ngonyaka wee-2017 kanye no-2018. U-Mbedu ekukhambeni kwesikhathi wavela ehlanganweni ebizwa ngokuthi yi- Forbes Africa 30 ngaphasi kwabantu abangaphasi kweminyaka ematjhumi amathathu ubudala ngonyaka wee-2018.

Ngonyaka wee-2021, wadlala ehlelweni elibizwa nge-Underground Railroad elitholakala kuAmazon Video, lapho kunamahlelo amanengi nekungilo elamenza bona abemdlali wokuthoma we-Sewula Afrika okhamba phambili kwezamahlelo adlala kumabonwakude we-America. Lokhu kwamenza bona athumbe unongorwana obizwa bona yi-Independent Spirit Award etholwa mumuntu wengubo okhamba phambili ngokuba mdlali wakumabonwakude ehlelweni elitjha. Waragela phambili waba ngomunye wabalingisi ehlelweni elimlando wangaphetjheya e-America obizwa ngokobana yi- The Woman King (2022) lapho adlala khona iskhundla saka Nawi.

=== IPILO YEBUNCANINI NEFUNDO ===
U-Mbedu wabelethelwa e-Midlands Medical Centre endaweni ye-Pietermaritzburg, KwaZulu-Natal. Ubelethwa ngumma okhuluma isiZulu kanye noyise okhuluma isiSotho nesiXhosa. Wakhuliswa e-Pelham ngugogo wakhe , owabamumuntu omtlhogomelako ngemva kokuhlongakalelwa babelethi bakhe bobabili asesemncani.

U-Mbedu wafunda e-Pelham Primary School bese waya e- Pietermaritzburg Girls' High School . &lt;ref&gt;{{Cite journal|url=https://www.news24.com/witness/news/from-pmb-to-the-worlds-tvs-20170129|title=From PMB to the world's TVs|journal=The Witness|first=Nompilo|last=Kunene|date=30 January 2017|access-date=21 October 2021}}&lt;/ref&gt; Waragela phambili nokufunda i-Physical Theatre kanye ne-Performing Arts Management e- University of the Witwatersrand (Wits), waphothula ngo-2013 ngama-honor, &lt;ref&gt;{{cite web|url=https://www.goodthingsguy.com/people/thuso-mbedu-underground-railroad/|title=Meet the first South African actress to lead an American series!!!|website=Good Things Guy|date=17 April 2019}}&lt;/ref&gt; ngemva kokuthatha ikhosi e- Stella Adler Studio of Acting e-New York City ngo-2012. &lt;ref&gt;{{cite web|url=http://www.youthvillage.co.za/2016/05/10-things-you-didnt-know-about-scandal-actress-thuso-mbedu/|title=10 Things You Didn't Know About Scandal Actress Thuso Mbedu|website=Youth Village|date=16 May 2016}}&lt;/ref&gt; &lt;ref name=&quot;:1&quot;&gt;{{Cite journal|url=https://www.timeslive.co.za/tshisa-live/tshisa-live/2020-09-28-i-had-no-clue-what-they-were-saying-thuso-mbedu-on-connecting-with-her-sotho-heritage/|title='I had no clue what they were saying'-Thuso Mbedu on connecting with her Sotho heritage|journal=Times Live|first=Deepika|last=Naidoo|date=28 September 2020|access-date=3 November 2021}}&lt;/ref&gt;

=== IBIZELO ===
Ekupheleni konyaka wee-2014, u-Mbedu waba nendima encani kusizini yesibili ye- Mzansi Magic soapie ''[[Isibaya]]'', ''&lt;ref name=&quot;:0&quot;&gt;{{Cite news|url=https://www.channel24.co.za/TV/News/thuso-mbedu-from-out-of-work-to-emmy-nominee-20180211|title=Thuso Mbedu: From out of work to Emmy nominee|work=Channel24|access-date=24 March 2018|language=en}}&lt;/ref&gt;'' ngaphambi kokuthi athole indima yakhe njengomfundi wezobuntatheli nomntwana u-Kitso ku ''-Scandal!'' . ''['' ''&lt;ref&gt;{{cite web|url=http://www.news24.com/MoveMag/Archive/thuso-mbedu-on-how-she-made-it-against-all-odds-20170728|title=Thuso Mbedu on how she made it against all odds|date=28 July 2017|work=[[News24 (website)|News24]]}}&lt;/ref&gt; &lt;ref&gt;{{Cite news|url=http://www.youthvillage.co.za/2016/05/10-things-you-didnt-know-about-scandal-actress-thuso-mbedu/|title=10 Things You Didn't Know About Scandal Actress Thuso Mbedu|date=16 May 2016|work=Youth Village|access-date=24 March 2018|language=en-US}}&lt;/ref&gt;''[[SABC 2|​]]  kanye nendima ephambili njengo-Boni Khumalo emdlalweni kamabonakude bbizwa kobana yi- ''Saints and Sinners.&lt;ref&gt;{{Cite news|last=Vieira|first=Genevieve|title=Thuso Mbedu is truly blessed|language=en|work=The Citizen|url=https://citizen.co.za/lifestyle/your-life-entertainment-your-life/entertainment-celebrities/316910/thuso-mbedu-is-truly-blessed/|access-date=24 March 2018}}&lt;/ref&gt;''

Ngemva kokungasebenzi iinyanga ezisithandathu, u-Mbedu wathola indima yakhe yokuthoma kumabonakude emdlalweni we -Mzansi Magic welutjha ''-Is'Thunzi'', owathoma ngoMgwengweni enyakeni wee-2016. &lt;ref name=&quot;:02&quot;&gt;{{Cite news|url=https://www.channel24.co.za/TV/News/thuso-mbedu-from-out-of-work-to-emmy-nominee-20180211|title=Thuso Mbedu: From out of work to Emmy nominee|work=Channel24|access-date=24 March 2018|language=en}}&lt;/ref&gt; &lt;ref&gt;{{Cite news|url=https://www.timeslive.co.za/tshisa-live/tshisa-live/2017-09-28-heres-5-things-you-need-to-know-about-actress-thuso-mbedu/|title=Here's 5 things you need to know about actress Thuso Mbedu|work=[[TimesLIVE]]|access-date=24 March 2018|language=en-US}}&lt;/ref&gt; Emdlalweni lo, wadlala indima ka-Winnie, umdlali othanda ukuzikhakhazisa, ofuna ukutjhada nomdlali we-rugby onjingileko nodumileko kodwana ibhudango lakhe liyatjhabalala lokha nakufanele akhambe ayokuhlala nokgharakhe obukhali e-Bergville. Lokha nakalingisa  isiqephu sokudlwengulwa emdlalweni, wahlaselwa livalo. &lt;ref&gt;{{Cite news|url=https://www.huffingtonpost.co.za/2017/11/13/thuso-mbedu-is-leaving-for-the-international-emmys-with-hope-for-south-africans_a_23275431/|title=Thuso Mbedu Is Leaving For The International Emmys With Hope For South Africans|date=13 November 2017|work=Huffington Post South Africa|access-date=24 March 2018|language=en-ZA}}&lt;/ref&gt; NgoNobayeni 2017, waphakanyiswa enongorwaneni we -International Emmy Award esigabeni sokudlala okuhle khulu komlingisi ngendima yakhe njengo-Winnie ku ''-Is'Thunzi'' &lt;ref&gt;{{Cite news|url=https://www.timeslive.co.za/tshisa-live/tshisa-live/2018-01-18-thuso-mbedu-on-life-after-emmy-nod-the-truth-is-we-are-very-dispensable/|title=Thuso Mbedu on life after Emmy nod: 'The truth is we are very dispensable'|work=Times LIVE|access-date=24 March 2018|language=en-US}}&lt;/ref&gt; begodu bekunguye kwaphela umuntu we Sewula-Afrika owaphakanyiswa ngalowo mnyaka. &lt;ref&gt;{{Cite news|url=https://www.iol.co.za/entertainment/celebrity-news/local/isthunzi-star-thuso-mbedu-nominated-for-emmy-award-11386771|title='Is'thunzi' star Thuso Mbedu nominated for #Emmy Award {{!}} IOL Entertainment|access-date=24 March 2018|language=en}}&lt;/ref&gt;

U-Mbedu wenza ukudlala kwakhe kokuthoma njengo-Cora kubemlando ngonyaka wee-2021 we-Amazon Video ''i-The Underground Railroad'', esekelwe enovelini enegama elifanako ka -Colson Whitehead begodu iqondiswe beyakhiqizwa ngomunye owathumba i -Academy Award u-Barry Jenkins . &lt;ref&gt;{{Cite web|last=Ramos|first=Dino-Ray|date=21 October 2020|title='The Underground Railroad' Teaser: Barry Jenkins Offers First Glimpse Of Thuso Mbedu As Cora In Amazon Limited Series|url=https://deadline.com/2020/10/the-underground-railroad-teaser-trailer-berry-jenkins-thuso-mbedu-as-cora-amazon-series-1234601236/|access-date=21 October 2020|website=Deadline|language=en-US}}&lt;/ref&gt; &lt;ref&gt;{{Cite web|title=Thuso Mbedu can't wait for viewers to see her new series with Barry Jenkins|url=https://www.news24.com/channel/tv/news/thuso-mbedu-cant-wait-for-viewers-to-see-her-new-series-with-barry-jenkins-20201020-2|access-date=21 October 2020|website=Channel|date=19 October 2020|language=en}}&lt;/ref&gt; UMbedu wathola i -Hollywood Critics Association Award, i- Independent Spirit Award, kanye ne -Gotham Award yomdlalo. &lt;ref&gt;{{Cite web|last=Ngwenya|first=Nkhensani|date=30 August 2021|title=Thuso Mbedu Walks Away With An International Award|url=https://surgezirc.co.za/2021-08-30-gossip-thuso-mbedu-walks-away-with-an-international-award/|access-date=30 August 2021|website=Surge Zirc SA|language=en-GB}}&lt;/ref&gt;

Ngenyanga kaMrhayili 2021, kwamenyezelwa bona uMbedu uzokwenza ifilimu yakhe yokuthoma njengo-Nawi aqalene no -Viola Davis ku- ''The Woman King'', ifilimu yomlando ephefumulelwe ngezehlakalo zamambala ezenzeka eMbusweni we-Dahomey, &lt;ref&gt;{{Cite web|last=Höffele|first=Lerato|title=Thuso Mbedu bags role alongside Viola Davis in 'The Woman King'|url=https://ewn.co.za/2021/04/29/thuso-mbedu-bags-role-alongside-viola-davis-in-the-woman-king|access-date=30 April 2021|website=ewn.co.za|language=en}}&lt;/ref&gt; omunye wemibuso enamandla khulu ye-Afrika ngekhulu le-18 nele-19. Ifilimu le beyiqondiswe ngu [[Gina Prince-Bythewood|-Gina Prince-Bythewood]], ukusuka emtlolweni womtloli we- ''Fatherhood'' u-Dana Stevens . &lt;ref name=&quot;Kroll&quot;&gt;{{Cite web|last=Kroll|first=Justin|date=28 April 2021|title='Underground Railroad's Thuso Mbedu To Star Opposite Viola Davis In 'The Woman King King'|url=https://deadline.com/2021/04/thuso-mbedu-viola-davis-woman-king-1234746073/|access-date=28 April 2021|website=Deadline|language=en-US}}&lt;/ref&gt; &lt;ref&gt;{{Cite web|last=Morkel|first=Graye|title=Thuso Mbedu to star opposite Viola Davis in The Woman King|url=https://www.news24.com/channel/movies/news/thuso-mbedu-to-star-opposite-viola-davis-in-the-woman-king-20210429|access-date=30 April 2021|website=Channel|language=en-US}}&lt;/ref&gt; &lt;ref&gt;{{Cite web|title=Africans making waves in Hollywood|url=https://www.sowetanlive.co.za/entertainment/2021-04-30-africans-making-waves-in-hollywood/|access-date=30 April 2021|website=SowetanLIVE|language=en-ZA}}&lt;/ref&gt;

Ngo-2023, u-Mbedu waba yinxusa nomkhulumeli we [[L'Oréal|-L'Oréal]] we-Sub-Saharan Africa. &lt;ref&gt;{{Cite web|title=The Woman King star Thuso Mbedu named L'Oréal Paris Brand Ambassador|url=https://cosmeticsbusiness.com/news/article_page/The_Woman_King_star_Thuso_Mbedu_named_LOreal_Paris_Brand_Ambassador/209187|access-date=23 June 2023|website=Cosmetics Business}}&lt;/ref&gt; &lt;ref&gt;{{Cite web|title=Thuso Mbedu named L'Oréal Paris brand ambassador|url=https://www.news24.com/life/arts-and-entertainment/celebrities/thuso-mbedu-named-loreal-paris-brand-ambassador-20230529|access-date=23 June 2023|website=News24}}&lt;/ref&gt; &lt;ref&gt;{{cite web|title=Thuso Mbedu: The infamous marathon cheats|url=https://curio.io/shows/retold/thuso-mbedu-the-not-quite-redemption-of-south-africas-infamous-ultra-marathon-cheats|website=Curio}}&lt;/ref&gt; NgoTjhirhweni 2025 ''i-Deadline'' yabika bona u-Mbedu ukhethwe indima ephambili kufilimu ezako ye-Paramount i- ''Children of Blood and Bone'' njengo-Zélie hlangana no -Viola Davis, u-Cynthia Erivo, u-Damson Idris, u-Amandla Stenberg, u- Idris Elba no- Tosin Cole . &lt;ref&gt;{{Cite web|last=Moorman|first=Taijuan|title=Star-studded 'Children of Blood and Bone' cast revealed: What we know so far|url=https://www.usatoday.com/story/entertainment/movies/2025/01/23/children-of-blood-and-bone-cast-amandla-stenberg/77900352007/#:~:text=Star-studded%20'Children%20of%20Blood,What%20we%20know%20so%20far&amp;text=Anticipation%20is%20growing%20for%20the,those%20powers%20to%20her%20people.|access-date=2025-02-06|website=USA TODAY|language=en-US}}&lt;/ref&gt;

=== Imithombo lwazi ===

&lt;references /&gt;</text>
      <sha1>qi3l6t5j4ba815dlk4aabp7hy6kiugm</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:NASKHOSANA/Page 2</title>
    <ns>2</ns>
    <id>849</id>
    <revision>
      <id>5352</id>
      <timestamp>2025-09-03T10:20:57Z</timestamp>
      <contributor>
        <username>NASKHOSANA</username>
        <id>884</id>
      </contributor>
      <comment>created sub page 2</comment>
      <origin>5352</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="19" sha1="36m665z4dseopgsuspddznzjzbbtugn" xml:space="preserve">Page 2 : Draft page</text>
      <sha1>36m665z4dseopgsuspddznzjzbbtugn</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:MahlanguLucky23/Page 3</title>
    <ns>2</ns>
    <id>851</id>
    <revision>
      <id>5354</id>
      <timestamp>2025-09-03T10:21:01Z</timestamp>
      <contributor>
        <username>MahlanguLucky23</username>
        <id>876</id>
      </contributor>
      <comment>created sub page 3</comment>
      <origin>5354</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="19" sha1="pocsm5aj3qa61x0zye8ursbxal6wf7d" xml:space="preserve">Page 3:Draft page 3</text>
      <sha1>pocsm5aj3qa61x0zye8ursbxal6wf7d</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Lerato Ruffy/Page 3</title>
    <ns>2</ns>
    <id>852</id>
    <revision>
      <id>5355</id>
      <timestamp>2025-09-03T10:21:01Z</timestamp>
      <contributor>
        <username>Lerato Ruffy</username>
        <id>846</id>
      </contributor>
      <comment>Created sub page 3</comment>
      <origin>5355</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="20" sha1="pqos22cd6z9lm37sa4xzr60a4iywmun" xml:space="preserve">Page 3: Draft Page 3</text>
      <sha1>pqos22cd6z9lm37sa4xzr60a4iywmun</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:2003.Ma/Page 3</title>
    <ns>2</ns>
    <id>853</id>
    <revision>
      <id>5356</id>
      <timestamp>2025-09-03T10:21:02Z</timestamp>
      <contributor>
        <username>2003.Ma</username>
        <id>882</id>
      </contributor>
      <comment>Created page with &quot;Page 3: Draft 3&quot;</comment>
      <origin>5356</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="15" sha1="9phup95sufp5yqccpkf3mhddo3m80m5" xml:space="preserve">Page 3: Draft 3</text>
      <sha1>9phup95sufp5yqccpkf3mhddo3m80m5</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Kholeka19721/</title>
    <ns>2</ns>
    <id>854</id>
    <revision>
      <id>5357</id>
      <timestamp>2025-09-03T10:21:04Z</timestamp>
      <contributor>
        <username>Kholeka19721</username>
        <id>889</id>
      </contributor>
      <comment>created sub page 1.</comment>
      <origin>5357</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="21" sha1="pch87y1k6hovfegi0kuhokbawmoj8oz" xml:space="preserve">Page 1: Draft space 1</text>
      <sha1>pch87y1k6hovfegi0kuhokbawmoj8oz</sha1>
    </revision>
    <revision>
      <id>5378</id>
      <parentid>5357</parentid>
      <timestamp>2025-09-03T10:23:57Z</timestamp>
      <contributor>
        <username>Kholeka19721</username>
        <id>889</id>
      </contributor>
      <minor />
      <comment>created sub page 2.</comment>
      <origin>5378</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="21" sha1="sj5j4tpbq6u91cwhumtp8yadvek3tbg" xml:space="preserve">Page 2: Draft space 2</text>
      <sha1>sj5j4tpbq6u91cwhumtp8yadvek3tbg</sha1>
    </revision>
    <revision>
      <id>5397</id>
      <parentid>5378</parentid>
      <timestamp>2025-09-03T10:26:18Z</timestamp>
      <contributor>
        <username>Kholeka19721</username>
        <id>889</id>
      </contributor>
      <minor />
      <comment>created sub page 3.</comment>
      <origin>5397</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="21" sha1="m77cqvnm3yvmr1kbewu39fhrfvnguw9" xml:space="preserve">Page 3: Draft space 3</text>
      <sha1>m77cqvnm3yvmr1kbewu39fhrfvnguw9</sha1>
    </revision>
    <revision>
      <id>5641</id>
      <parentid>5397</parentid>
      <timestamp>2025-09-04T10:54:26Z</timestamp>
      <contributor>
        <username>Kholeka19721</username>
        <id>889</id>
      </contributor>
      <minor />
      <origin>5641</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="21" sha1="pch87y1k6hovfegi0kuhokbawmoj8oz" xml:space="preserve">Page 1: Draft space 1</text>
      <sha1>pch87y1k6hovfegi0kuhokbawmoj8oz</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Nothi2003/Page 3</title>
    <ns>2</ns>
    <id>855</id>
    <revision>
      <id>5358</id>
      <timestamp>2025-09-03T10:21:17Z</timestamp>
      <contributor>
        <username>Nothi2003</username>
        <id>833</id>
      </contributor>
      <comment>created sub page 3</comment>
      <origin>5358</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="15" sha1="3o0nsob5vmg5h2jcie0tl3gaz6bp5ap" xml:space="preserve">Page 3, Draft 3</text>
      <sha1>3o0nsob5vmg5h2jcie0tl3gaz6bp5ap</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Xikombiso1/Page 2</title>
    <ns>2</ns>
    <id>856</id>
    <revision>
      <id>5359</id>
      <timestamp>2025-09-03T10:21:53Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <comment>created sub-page 2</comment>
      <origin>5359</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="20" sha1="bd55l8qrc3tj832o91miqv75vwble9h" xml:space="preserve">Page 2: Draft page 2</text>
      <sha1>bd55l8qrc3tj832o91miqv75vwble9h</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Pruddy01/Page 3</title>
    <ns>2</ns>
    <id>857</id>
    <revision>
      <id>5360</id>
      <timestamp>2025-09-03T10:21:55Z</timestamp>
      <contributor>
        <username>Pruddy01</username>
        <id>895</id>
      </contributor>
      <comment>I created sub page 3</comment>
      <origin>5360</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="20" sha1="pqos22cd6z9lm37sa4xzr60a4iywmun" xml:space="preserve">Page 3: Draft Page 3</text>
      <sha1>pqos22cd6z9lm37sa4xzr60a4iywmun</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:2000Gp01/Page 3</title>
    <ns>2</ns>
    <id>858</id>
    <revision>
      <id>5361</id>
      <timestamp>2025-09-03T10:21:55Z</timestamp>
      <contributor>
        <username>2000Gp01</username>
        <id>880</id>
      </contributor>
      <comment>created sub page 3</comment>
      <origin>5361</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="20" sha1="sqnyoolrno5g7woykpaocbxsm5l48zx" xml:space="preserve">Page 3: Draft page 3</text>
      <sha1>sqnyoolrno5g7woykpaocbxsm5l48zx</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Tarryn 29/Page 2</title>
    <ns>2</ns>
    <id>859</id>
    <revision>
      <id>5362</id>
      <timestamp>2025-09-03T10:21:59Z</timestamp>
      <contributor>
        <username>Tarryn 29</username>
        <id>886</id>
      </contributor>
      <comment>Created sub-page 2</comment>
      <origin>5362</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="21" sha1="hj1t9def8g501yxsvs0ln480bmy69oc" xml:space="preserve">Page 2: Draft Space 2</text>
      <sha1>hj1t9def8g501yxsvs0ln480bmy69oc</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Dladlakamogelo07/Page 2</title>
    <ns>2</ns>
    <id>860</id>
    <revision>
      <id>5363</id>
      <timestamp>2025-09-03T10:22:01Z</timestamp>
      <contributor>
        <username>Dladlakamogelo07</username>
        <id>903</id>
      </contributor>
      <comment>Created sub page 2</comment>
      <origin>5363</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="21" sha1="tfl460wmy4pbs06ut8tuut8cl7ye1zn" xml:space="preserve">Page 2: draft space 2</text>
      <sha1>tfl460wmy4pbs06ut8tuut8cl7ye1zn</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Mbonani JayJay/Page 2</title>
    <ns>2</ns>
    <id>861</id>
    <revision>
      <id>5364</id>
      <timestamp>2025-09-03T10:22:01Z</timestamp>
      <contributor>
        <username>Mbonani JayJay</username>
        <id>892</id>
      </contributor>
      <comment>created sub-page 2</comment>
      <origin>5364</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="21" sha1="sj5j4tpbq6u91cwhumtp8yadvek3tbg" xml:space="preserve">Page 2: Draft space 2</text>
      <sha1>sj5j4tpbq6u91cwhumtp8yadvek3tbg</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Sister01/Page 3</title>
    <ns>2</ns>
    <id>862</id>
    <revision>
      <id>5365</id>
      <timestamp>2025-09-03T10:22:05Z</timestamp>
      <contributor>
        <username>Sister01</username>
        <id>893</id>
      </contributor>
      <comment>I created sub page 3</comment>
      <origin>5365</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="14" sha1="g9620gkrh70rvv34x6fxwxbn3ev5f4a" xml:space="preserve">Page 3 draft 3</text>
      <sha1>g9620gkrh70rvv34x6fxwxbn3ev5f4a</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:White Edits/Page 2</title>
    <ns>2</ns>
    <id>863</id>
    <revision>
      <id>5366</id>
      <timestamp>2025-09-03T10:22:06Z</timestamp>
      <contributor>
        <username>White Edits</username>
        <id>894</id>
      </contributor>
      <comment>created sub page 2</comment>
      <origin>5366</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="20" sha1="srqzdaq2isma9plfafqqx0rd7c98ruh" xml:space="preserve">page 2: draft page 2</text>
      <sha1>srqzdaq2isma9plfafqqx0rd7c98ruh</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Mtsweni S/Page 2</title>
    <ns>2</ns>
    <id>864</id>
    <revision>
      <id>5367</id>
      <timestamp>2025-09-03T10:22:11Z</timestamp>
      <contributor>
        <username>Mtsweni S</username>
        <id>835</id>
      </contributor>
      <comment>created sub page 2</comment>
      <origin>5367</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="19" sha1="s7lthaa81i8dgqqdkrfbcy6ibrfs4hj" xml:space="preserve">Page 2 Draft page 2</text>
      <sha1>s7lthaa81i8dgqqdkrfbcy6ibrfs4hj</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Nabungela/Page 1</title>
    <ns>2</ns>
    <id>865</id>
    <revision>
      <id>5368</id>
      <timestamp>2025-09-03T10:22:57Z</timestamp>
      <contributor>
        <username>Nabungela</username>
        <id>885</id>
      </contributor>
      <comment>Created sub page1</comment>
      <origin>5368</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="21" sha1="pch87y1k6hovfegi0kuhokbawmoj8oz" xml:space="preserve">Page 1: Draft space 1</text>
      <sha1>pch87y1k6hovfegi0kuhokbawmoj8oz</sha1>
    </revision>
    <revision>
      <id>5475</id>
      <parentid>5368</parentid>
      <timestamp>2025-09-04T08:32:42Z</timestamp>
      <contributor>
        <username>Nabungela</username>
        <id>885</id>
      </contributor>
      <origin>5475</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="17499" sha1="dtgha8h27aaw0ygyghfnyepky4uuq5a" xml:space="preserve">Page 1: Draft space 1

U- '''Siviwe Gwarube''' (wabelethwa mhlana ali-14 kuNtaka 1989) usopolotiki [[Isewula Afrika|weSewula Afrika]] osebenza njengoNgqongqotjhe [[Minister of Basic Education|wezeFundo yeSisekelo]] kuRhulumende [[Third Cabinet of Cyril Ramaphosa|weBumbano leNarha]] (i-GNU) kusukela ngoNtaka 2024. Ulilunga le- [[Democratic Alliance (South Africa)|Democratic Alliance]] (DA), bekayilunga le-Democratic Alliance (DA), bekayi [[National Assembly of South Africa|-Chief Whip ye-Official Opposition]] hlangana kwakaRhoboyi 2020 ukuya kuRhoboyi 24. Wajoyina i [[National Assembly of South Africa|-National. I-Assembly yeSewula Afrika]] kukhetho [[2019 South African general election|lukaMeyi 2019]]

Wabelethelwa e [[Eastern Cape|-Eastern Cape]], u-Gwarube wangena kwezepolotiki ngo-2012 njengomkhulumeli womrholi wepalamende we-DA [[Lindiwe Mazibuko|u-Lindiwe Mazibuko]] . Ngesikhathi [[27th South African Parliament|sePalamende yesiThupha]], ngaphambi kokukhethwa njengoMphathiswa we-DA, wasebenza njengoNgqongqotjhe [[Official Opposition Shadow Cabinet (South Africa)|wezamaPhilo]] kusukela ngoMgwengweni 2019 ukuya kuMhlolanja 2022, umkhulumeli wezwe loke we [[Minister of Health (South Africa)|-]] DA kusukela ngoNobayeni 2020 ukuya kuRhoboyi 2022, kanye noSekela loMphathiswa kusukela ngoNobayeni 2021 ukuya kuRhoboyi 2022.

'''Ipilo yokuthoma nomsebenzi'''

U-Gwarube wabelethwa mhlana ali-14 kuNtaka 1989, &lt;ref name=&quot;:122&quot;&gt;{{Cite web|date=10 April 2024|title=Final Candidate Lists for 2024 National and Provincial Elections: National Candidates|url=https://www.elections.org.za/pw/Documents/Candidates-List-NPE2024/National%20Candidates%20List.pdf|access-date=2024-03-26|website=Electoral Commission of South Africa}}&lt;/ref&gt; uGwarube wakhulela e-KwaMdingi, idolobhana elingaphandle [[King William's Town|kweDorobha le-King William]] e- [[Cape Province]] . &lt;ref name=&quot;:02&quot;&gt;{{Cite web|last=Felix|first=Jason|date=10 September 2022|title=Leading the pack: Siviwe Gwarube stands tall at helm of DA's charge in Parliament|url=https://www.news24.com/news24/opinions/analysis/saturday-profile-leading-the-pack-siviwe-gwarube-stands-tall-at-helm-of-das-charge-in-parliament-20220910|access-date=2024-07-03|website=News24|language=en-US}}&lt;/ref&gt; Wakhuliswa ngugogo wakhe, obekangutitjhere ongakatjhadi. &lt;ref name=&quot;:1&quot;&gt;{{Cite web|last=Huisman|first=Biénne|date=2019-11-18|title=Face to face with shadow health minister Siviwe Gwarube|url=https://www.dailymaverick.co.za/article/2019-11-19-face-to-face-with-shadow-health-minister-siviwe-gwarube/|access-date=2024-07-03|website=Daily Maverick|language=en}}&lt;/ref&gt; Ngemva kokuphothula e-Kingsridge High School for Girls e-King William's Town, wafunda umthetho, ipolotiki, kanye nefilosofi e- [[Rhodes University]] e- [[Grahamstown]] . Waphothula nge-Bachelor of Arts ngo-2012

Ngomnyaka wakhe wokugcina njengomfundi, u-Gwarube waqatjhwa ehlelweni labadosiphambili abatjha [[Democratic Alliance (South Africa)|be-Democratic Alliance]] (DA). &lt;ref name=&quot;:12&quot;&gt;{{Cite web|last=Huisman|first=Biénne|date=2019-11-18|title=Face to face with shadow health minister Siviwe Gwarube|url=https://www.dailymaverick.co.za/article/2019-11-19-face-to-face-with-shadow-health-minister-siviwe-gwarube/|access-date=2024-07-03|website=Daily Maverick|language=en}}&lt;/ref&gt; Ehlelweni wahlangana no [[Lindiwe Mazibuko|-Lindiwe Mazibuko]], [[Leader of the Opposition (South Africa)|uMdosiphambili wePhikisako]], owaba mfundisi wakhe. &lt;ref&gt;{{Cite news|date=21 August 2022|title=‘I am nobody’s experiment,’ says DA’s new chief whip|url=https://www.timeslive.co.za/sunday-times/news/politics/2022-08-21-i-am-nobodys-experiment-says-das-new-chief-whip/|access-date=3 July 2024|work=Sunday Times}}&lt;/ref&gt; NgoTjhirhweni 2012, ngemva nje kokuphothula, uGwarube wathuthela [[Cape Town|eKapa]] ukuyokuthoma umsebenzi njengomkhulumeli ehhovisini lakaMazibuko. &lt;ref name=&quot;:12&quot; /&gt; Ngemva kwalokho wathuthela emNyangweni [[Western Cape Department of Health|wezamaPhilo we-Western Cape]], lapho bekayisikhulumeli nomphathi weNgqongqotjhe ngaphasi kwakaNgqongqotjhe wePhrovinsi [[Nomafrench Mbombo|uNomafrench Mbombo]] . Ngaphambi [[2019 South African general election|kokhetho luka-2019]], bekangumnqophisi omkhulu wezokuthintana we-DA

'''Umsebenzi wezepolotiki'''

'''I-DA caucus: 2019–2024'''

Ngokhetho lukaMeyi 2019, u-Gwarube wakhethwa bona ajamele i-DA e- [[National Assembly of South Africa|National Assembly]], indlu ephasi yePalamende [[South African Parliament|yeSewula Afrika]] . Wabekwa godu njengoNgqongqotjhe [[Official Opposition Shadow Cabinet (South Africa)|wezamaPhilo]] [[Shadow Cabinet of Mmusi Maimane|ekhabhinethi yomdosiphambili]] we-DA u [[Minister of Health (South Africa)|-]] [[Musi Maimane|Mmusi Maimane]], u [[Lindy Wilson|-Lindy Wilson]] abe msekeli wakhe. &lt;ref&gt;{{cite news|last1=Nkanjeni|first1=Unathi|date=6 June 2019|title=DA shadow cabinet: What you need to know|url=https://www.timeslive.co.za/politics/2019-06-06-da-shadow-cabinet-what-you-need-to-know/|accessdate=8 April 2020|newspaper=Sunday Times}}&lt;/ref&gt; &lt;ref&gt;{{cite news|last1=Gerber|first1=Jan|date=5 June 2019|title=Here's the DA's 'shadow cabinet'|url=https://www.news24.com/SouthAfrica/News/heres-the-das-shadow-cabinet-20190605|accessdate=8 April 2020|newspaper=News24}}&lt;/ref&gt; Wagcina isikhundla leso [[Shadow Cabinet of John Steenhuisen|ekhabhinethi yesithunzi]] yomlandeli ka-Maimane, [[John Steenhuisen|u-John Steenhuisen]] . &lt;ref&gt;{{Cite news|last=Mazzone|first=Natasha|date=5 December 2020|title=DA announces new Shadow Cabinet that will bring Real Hope and Real Change|url=https://www.da.org.za/2020/12/da-announces-new-shadow-cabinet-that-will-bring-real-hope-and-real-change|access-date=5 December 2020|work=Democratic Alliance}}&lt;/ref&gt; Isikhathi sakhe emkhakheni wezamaphilo sahlangana nobhubhane [[COVID-19 pandemic in South Africa|lwe-COVID-19]], kanye [[Zweli Mkhize#Digital Vibes scandal|nehlazo le-Digital Vibes]] eliphathelene nekohlakalo emNyangweni [[Department of Health (South Africa)|wezamaPhilo]] ; &lt;ref name=&quot;:03&quot;&gt;{{Cite web|last=Felix|first=Jason|date=10 September 2022|title=Leading the pack: Siviwe Gwarube stands tall at helm of DA's charge in Parliament|url=https://www.news24.com/news24/opinions/analysis/saturday-profile-leading-the-pack-siviwe-gwarube-stands-tall-at-helm-of-das-charge-in-parliament-20220910|access-date=2024-07-03|website=News24|language=en-US}}&lt;/ref&gt; malungana nokugcina, u-Gwarube wabeka amacala wobulelesi kuNgqongqotjhe wezamaPhilo [[Zweli Mkhize|u-Zweli Mkhize]].

Ngokhetho lukaMeyi 2019, u-Gwarube wakhethwa bona ajamele i-DA e- [[National Assembly of South Africa|National Assembly]], indlu ephasi yePalamende [[South African Parliament|yeSewula Afrika]] . Wabekwa godu njengoNgqongqotjhe [[Official Opposition Shadow Cabinet (South Africa)|wezamaPhilo]] [[Shadow Cabinet of Mmusi Maimane|ekhabhinethi yomdosiphambili]] we-DA u [[Minister of Health (South Africa)|-]] [[Musi Maimane|Mmusi Maimane]], u [[Lindy Wilson|-Lindy Wilson]] abe msekeli wakhe. &lt;ref&gt;{{cite news|last1=Nkanjeni|first1=Unathi|date=6 June 2019|title=DA shadow cabinet: What you need to know|url=https://www.timeslive.co.za/politics/2019-06-06-da-shadow-cabinet-what-you-need-to-know/|accessdate=8 April 2020|newspaper=Sunday Times}}&lt;/ref&gt; &lt;ref&gt;{{cite news|last1=Gerber|first1=Jan|date=5 June 2019|title=Here's the DA's 'shadow cabinet'|url=https://www.news24.com/SouthAfrica/News/heres-the-das-shadow-cabinet-20190605|accessdate=8 April 2020|newspaper=News24}}&lt;/ref&gt; Wagcina isikhundla leso [[Shadow Cabinet of John Steenhuisen|ekhabhinethi yesithunzi]] yomlandeli ka-Maimane, [[John Steenhuisen|u-John Steenhuisen]] . &lt;ref&gt;{{Cite news|last=Mazzone|first=Natasha|date=5 December 2020|title=DA announces new Shadow Cabinet that will bring Real Hope and Real Change|url=https://www.da.org.za/2020/12/da-announces-new-shadow-cabinet-that-will-bring-real-hope-and-real-change|access-date=5 December 2020|work=Democratic Alliance}}&lt;/ref&gt; Isikhathi sakhe emkhakheni wezamaphilo sahlangana nobhubhane [[COVID-19 pandemic in South Africa|lwe-COVID-19]], kanye [[Zweli Mkhize#Digital Vibes scandal|nehlazo le-Digital Vibes]] eliphathelene nekohlakalo emNyangweni [[Department of Health (South Africa)|wezamaPhilo]] ; &lt;ref name=&quot;:04&quot;&gt;{{Cite web|last=Felix|first=Jason|date=10 September 2022|title=Leading the pack: Siviwe Gwarube stands tall at helm of DA's charge in Parliament|url=https://www.news24.com/news24/opinions/analysis/saturday-profile-leading-the-pack-siviwe-gwarube-stands-tall-at-helm-of-das-charge-in-parliament-20220910|access-date=2024-07-03|website=News24|language=en-US}}&lt;/ref&gt; malungana nokugcina, u-Gwarube wabeka amacala wobulelesi kuNgqongqotjhe wezamaPhilo [[Zweli Mkhize|u-Zweli Mkhize.]]

Mhlana amalanga ali-18 kuRhoboyi wee-2022, u-Gwarube waphakanyiswa waba yi-chief whip ye-DA caucus e-National Assembly; umuntu ophethe isikhundla, [[Natasha Mazzone|u-Natasha Mazzone]], waxoshwa. &lt;ref&gt;{{Cite web|last=|date=18 August 2022|title=Siviwe Gwarube appointed DA's new chief whip as axe falls on Mazzone|url=https://www.sowetanlive.co.za/news/south-africa/2022-08-18-siviwe-gwarube-appointed-das-new-chief-whip-as-axe-falls-on-mazzone/|access-date=2022-08-18|website=Sowetan|language=en-ZA}}&lt;/ref&gt; &lt;ref&gt;{{Cite web|title=Siviwe Gwarube appointed DA Chief Whip|url=https://www.enca.com/news/siviwe-gwarube-appointed-da-chief-whip|access-date=2022-08-18|website=eNCA|language=en}}&lt;/ref&gt; Abahlaziyi baphawule &quot;ukukhuphuka okukhulu&quot; kukaGwarube ngokusebenzisa i-caucus. &lt;ref name=&quot;:2&quot;&gt;{{Cite news|date=18 August 2022|title=Siviwe Gwarube is new DA chief whip after Natasha Mazzone is demoted|url=https://www.businesslive.co.za/bd/national/2022-08-18-siviwe-gwarube-is-new-da-chief-whip-after-natasha-mazzone-is-demoted/|access-date=3 July 2024|work=Business Day}}&lt;/ref&gt; &lt;ref&gt;{{Cite web|last=Hussain|first=Muhammad|date=24 February 2024|title=Siviwe Gwarube: DA does have deep sense of internal introspection|url=https://www.news24.com/news24/opinions/analysis/saturday-profile-siviwe-gwarube-da-does-have-deep-sense-of-internal-introspection-20240224|access-date=2024-07-03|website=News24|language=en-US}}&lt;/ref&gt; Emtlolweni wokuhlela, [[Mondli Makhanya|u-Mondli Makhanya]] we ''[[City Press (South Africa)|-City Press]]'' wathi, nanyana &quot;bekalilunga lePhalamende elikhuluma ngokuzwakalako, elizithembako nomkhulumeli wehlangano ongeze waphuthelwa lilizwi lakhe&quot;, u-Gwarube wahlala anganalwazi; wamxwayisa bona aqaphele &quot;ukubekwa bona ahluleke&quot;. &lt;ref&gt;{{Cite web|date=21 August 2022|title=Editorial: Allow Gwarube to lead|url=https://www.news24.com/citypress/voices/editorial-allow-gwarube-to-lead-20220821|access-date=2024-07-03|website=City Press|language=en-US}}&lt;/ref&gt; U-Gwarube, nanyana kunjalo, wathi bekakulungele ukudlala indima leyo begodu bekahlose &quot;ukukhamba endaweni le ngendlela eqinisekileko&quot;. &lt;ref&gt;{{Cite news|date=27 August 2022|title=New DA whip says she’s tough enough for the job|url=https://www.iol.co.za/weekend-argus/news/new-da-whip-says-shes-tough-enough-for-the-job-a73d0080-4018-42b9-b541-71828a282caa|access-date=3 July 2024|work=Weekend Argus}}&lt;/ref&gt; [[Cilliers Brink|U-Cilliers Brink]] no-Solly Malatsi bakhethwa bona bathathe imisebenzi yakhe njengomkhulumeli we-DA.

'''UNgqongqotjhe wezefundo ezisisekelo: 2024-nje'''

U-Gwarube wakhethwa godu esihlalweni sakhe sepalamende [[2024 South African general election|ngokhetho lukaMeyi 2024]], begodu bekalilunga lesiqhema samalunga amane ebesimele i-DA ngesikhathi seengcoco ezilandelako zokubambisana ne- [[African National Congress]] (ANC). &lt;ref&gt;{{Cite web|last=Ramushwana|first=Alpha|date=2 June 2024|title=DA declares coalition team to lead talks over the next 5 years|url=https://www.ewn.co.za/2024/06/02/da-declares-coalition-team-to-lead-talks-over-the-next-5-years|access-date=2024-07-03|website=EWN|language=en}}&lt;/ref&gt; Ngokuhambisana [[2024 South African government formation|nesivumelwano sokusebenzisana]] esifinyelelwe hlangana ne-DA ne-ANC, uMongameli [[Cyril Ramaphosa|u-Cyril Ramaphosa]] wamkhetha njengoNgqongqotjhe [[Minister of Basic Education|wezeFundo eSisekelo]] . &lt;ref&gt;{{Cite news|date=2 July 2024|title=I’m itching to get stuck in – Siviwe Gwarube ready to start tenure as basic education minister|url=https://www.sowetanlive.co.za/news/south-africa/2024-07-02-im-itching-to-get-stuck-in-whats-already-on-basic-education-minister-siviwe-gwarubes-in-tray/#google_vignette|access-date=3 July 2024|work=The Sowetan}}&lt;/ref&gt; U [[Reginah Mhaule|-Reginah Mhaule]] we-ANC wakhethwa njengesekela lakhe. &lt;ref&gt;{{Cite web|last=Ramaphosa|first=Cyril|date=30 June 2024|title=Working together to 'serve the people': Ramaphosa names new Cabinet|url=https://www.news24.com/news24/southafrica/news/read-in-full-working-together-to-serve-the-people-ramaphosa-names-new-cabinet-20240630|access-date=2024-07-03|website=News24|language=en-US}}&lt;/ref&gt; Wafungiswa esikhundleni mhlazi-3 kuNtaka 2024, &lt;ref&gt;{{Cite web|last=Ludidi|first=Velani|date=2024-07-03|title=Historic day for SA as GNU ministers sworn into office|url=https://www.dailymaverick.co.za/article/2024-07-03-historic-day-for-sa-as-government-of-national-unity-ministers-take-oath-of-office/|access-date=2024-07-16|website=Daily Maverick|language=en}}&lt;/ref&gt; begodu [[George Michalakis|u-George Michalakis]] wathatha isikhundla sakhe njengesihluthu esikhulu se-DA.

U-Gwarube wakhethwa godu esihlalweni sakhe sepalamende [[2024 South African general election|ngokhetho lukaMeyi 2024]], begodu bekalilunga lesiqhema samalunga amane ebesimele i-DA ngesikhathi seengcoco ezilandelako zokubambisana ne- [[African National Congress]] (ANC). &lt;ref&gt;{{Cite web|last=Ramushwana|first=Alpha|date=2 June 2024|title=DA declares coalition team to lead talks over the next 5 years|url=https://www.ewn.co.za/2024/06/02/da-declares-coalition-team-to-lead-talks-over-the-next-5-years|access-date=2024-07-03|website=EWN|language=en}}&lt;/ref&gt; Ngokuhambisana [[2024 South African government formation|nesivumelwano sokusebenzisana]] esifinyelelwe hlangana ne-DA ne-ANC, uMongameli [[Cyril Ramaphosa|u-Cyril Ramaphosa]] wamkhetha njengoNgqongqotjhe [[Minister of Basic Education|wezeFundo eSisekelo]] . &lt;ref&gt;{{Cite news|date=2 July 2024|title=I’m itching to get stuck in – Siviwe Gwarube ready to start tenure as basic education minister|url=https://www.sowetanlive.co.za/news/south-africa/2024-07-02-im-itching-to-get-stuck-in-whats-already-on-basic-education-minister-siviwe-gwarubes-in-tray/#google_vignette|access-date=3 July 2024|work=The Sowetan}}&lt;/ref&gt; U [[Reginah Mhaule|-Reginah Mhaule]] we-ANC wakhethwa njengesekela lakhe. &lt;ref&gt;{{Cite web|last=Ramaphosa|first=Cyril|date=30 June 2024|title=Working together to 'serve the people': Ramaphosa names new Cabinet|url=https://www.news24.com/news24/southafrica/news/read-in-full-working-together-to-serve-the-people-ramaphosa-names-new-cabinet-20240630|access-date=2024-07-03|website=News24|language=en-US}}&lt;/ref&gt; Wafungiswa esikhundleni mhlazi-3 kuNtaka 2024, &lt;ref&gt;{{Cite web|last=Ludidi|first=Velani|date=2024-07-03|title=Historic day for SA as GNU ministers sworn into office|url=https://www.dailymaverick.co.za/article/2024-07-03-historic-day-for-sa-as-government-of-national-unity-ministers-take-oath-of-office/|access-date=2024-07-16|website=Daily Maverick|language=en}}&lt;/ref&gt; begodu [[George Michalakis|u-George Michalakis]] wathatha isikhundla sakhe njengesihluthu esikhulu se-DA.

U-Gwarube wakhethwa godu esihlalweni sakhe sepalamende [[2024 South African general election|ngokhetho lukaMeyi 2024]], begodu bekalilunga lesiqhema samalunga amane ebesimele i-DA ngesikhathi seengcoco ezilandelako zokubambisana ne- [[African National Congress]] (ANC). &lt;ref&gt;{{Cite web|last=Ramushwana|first=Alpha|date=2 June 2024|title=DA declares coalition team to lead talks over the next 5 years|url=https://www.ewn.co.za/2024/06/02/da-declares-coalition-team-to-lead-talks-over-the-next-5-years|access-date=2024-07-03|website=EWN|language=en}}&lt;/ref&gt; Ngokuhambisana [[2024 South African government formation|nesivumelwano sokusebenzisana]] esifinyelelwe hlangana ne-DA ne-ANC, uMongameli [[Cyril Ramaphosa|u-Cyril Ramaphosa]] wamkhetha njengoNgqongqotjhe [[Minister of Basic Education|wezeFundo eSisekelo]] . &lt;ref&gt;{{Cite news|date=2 July 2024|title=I’m itching to get stuck in – Siviwe Gwarube ready to start tenure as basic education minister|url=https://www.sowetanlive.co.za/news/south-africa/2024-07-02-im-itching-to-get-stuck-in-whats-already-on-basic-education-minister-siviwe-gwarubes-in-tray/#google_vignette|access-date=3 July 2024|work=The Sowetan}}&lt;/ref&gt; U [[Reginah Mhaule|-Reginah Mhaule]] we-ANC wakhethwa njengesekela lakhe. &lt;ref&gt;{{Cite web|last=Ramaphosa|first=Cyril|date=30 June 2024|title=Working together to 'serve the people': Ramaphosa names new Cabinet|url=https://www.news24.com/news24/southafrica/news/read-in-full-working-together-to-serve-the-people-ramaphosa-names-new-cabinet-20240630|access-date=2024-07-03|website=News24|language=en-US}}&lt;/ref&gt; Wafungiswa esikhundleni mhlazi-3 kuNtaka 2024, &lt;ref&gt;{{Cite web|last=Ludidi|first=Velani|date=2024-07-03|title=Historic day for SA as GNU ministers sworn into office|url=https://www.dailymaverick.co.za/article/2024-07-03-historic-day-for-sa-as-government-of-national-unity-ministers-take-oath-of-office/|access-date=2024-07-16|website=Daily Maverick|language=en}}&lt;/ref&gt; begodu [[George Michalakis|u-George Michalakis]] wathatha isikhundla sakhe njengesihluthu esikhulu se-DA.

'''UMTHOMBO-LWAZI'''</text>
      <sha1>dtgha8h27aaw0ygyghfnyepky4uuq5a</sha1>
    </revision>
    <revision>
      <id>5497</id>
      <parentid>5475</parentid>
      <timestamp>2025-09-04T09:03:26Z</timestamp>
      <contributor>
        <username>Nabungela</username>
        <id>885</id>
      </contributor>
      <origin>5497</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="17532" sha1="b8cwxnxe0qyb5oyqqwff3pmfsuyzgi7" xml:space="preserve">Page 1: Draft space 1

'''&lt;big&gt;SIVIWE GWARUBE&lt;/big&gt;'''

U- '''Siviwe Gwarube''' (wabelethwa mhlana ali-14 kuNtaka 1989) usopolotiki [[Isewula Afrika|weSewula Afrika]] osebenza njengoNgqongqotjhe [[Minister of Basic Education|wezeFundo yeSisekelo]] kuRhulumende [[Third Cabinet of Cyril Ramaphosa|weBumbano leNarha]] (i-GNU) kusukela ngoNtaka 2024. Ulilunga le- [[Democratic Alliance (South Africa)|Democratic Alliance]] (DA), bekayilunga le-Democratic Alliance (DA), bekayi [[National Assembly of South Africa|-Chief Whip ye-Official Opposition]] hlangana kwakaRhoboyi 2020 ukuya kuRhoboyi 24. Wajoyina i [[National Assembly of South Africa|-National. I-Assembly yeSewula Afrika]] kukhetho [[2019 South African general election|lukaMeyi 2019]]

Wabelethelwa e [[Eastern Cape|-Eastern Cape]], u-Gwarube wangena kwezepolotiki ngo-2012 njengomkhulumeli womrholi wepalamende we-DA [[Lindiwe Mazibuko|u-Lindiwe Mazibuko]] . Ngesikhathi [[27th South African Parliament|sePalamende yesiThupha]], ngaphambi kokukhethwa njengoMphathiswa we-DA, wasebenza njengoNgqongqotjhe [[Official Opposition Shadow Cabinet (South Africa)|wezamaPhilo]] kusukela ngoMgwengweni 2019 ukuya kuMhlolanja 2022, umkhulumeli wezwe loke we [[Minister of Health (South Africa)|-]] DA kusukela ngoNobayeni 2020 ukuya kuRhoboyi 2022, kanye noSekela loMphathiswa kusukela ngoNobayeni 2021 ukuya kuRhoboyi 2022.

'''Ipilo yokuthoma nomsebenzi'''

U-Gwarube wabelethwa mhlana ali-14 kuNtaka 1989, &lt;ref name=&quot;:122&quot;&gt;{{Cite web|date=10 April 2024|title=Final Candidate Lists for 2024 National and Provincial Elections: National Candidates|url=https://www.elections.org.za/pw/Documents/Candidates-List-NPE2024/National%20Candidates%20List.pdf|access-date=2024-03-26|website=Electoral Commission of South Africa}}&lt;/ref&gt; uGwarube wakhulela e-KwaMdingi, idolobhana elingaphandle [[King William's Town|kweDorobha le-King William]] e- [[Cape Province]] . &lt;ref name=&quot;:02&quot;&gt;{{Cite web|last=Felix|first=Jason|date=10 September 2022|title=Leading the pack: Siviwe Gwarube stands tall at helm of DA's charge in Parliament|url=https://www.news24.com/news24/opinions/analysis/saturday-profile-leading-the-pack-siviwe-gwarube-stands-tall-at-helm-of-das-charge-in-parliament-20220910|access-date=2024-07-03|website=News24|language=en-US}}&lt;/ref&gt; Wakhuliswa ngugogo wakhe, obekangutitjhere ongakatjhadi. &lt;ref name=&quot;:1&quot;&gt;{{Cite web|last=Huisman|first=Biénne|date=2019-11-18|title=Face to face with shadow health minister Siviwe Gwarube|url=https://www.dailymaverick.co.za/article/2019-11-19-face-to-face-with-shadow-health-minister-siviwe-gwarube/|access-date=2024-07-03|website=Daily Maverick|language=en}}&lt;/ref&gt; Ngemva kokuphothula e-Kingsridge High School for Girls e-King William's Town, wafunda umthetho, ipolotiki, kanye nefilosofi e- [[Rhodes University]] e- [[Grahamstown]] . Waphothula nge-Bachelor of Arts ngo-2012

Ngomnyaka wakhe wokugcina njengomfundi, u-Gwarube waqatjhwa ehlelweni labadosiphambili abatjha [[Democratic Alliance (South Africa)|be-Democratic Alliance]] (DA). &lt;ref name=&quot;:12&quot;&gt;{{Cite web|last=Huisman|first=Biénne|date=2019-11-18|title=Face to face with shadow health minister Siviwe Gwarube|url=https://www.dailymaverick.co.za/article/2019-11-19-face-to-face-with-shadow-health-minister-siviwe-gwarube/|access-date=2024-07-03|website=Daily Maverick|language=en}}&lt;/ref&gt; Ehlelweni wahlangana no [[Lindiwe Mazibuko|-Lindiwe Mazibuko]], [[Leader of the Opposition (South Africa)|uMdosiphambili wePhikisako]], owaba mfundisi wakhe. &lt;ref&gt;{{Cite news|date=21 August 2022|title=‘I am nobody’s experiment,’ says DA’s new chief whip|url=https://www.timeslive.co.za/sunday-times/news/politics/2022-08-21-i-am-nobodys-experiment-says-das-new-chief-whip/|access-date=3 July 2024|work=Sunday Times}}&lt;/ref&gt; NgoTjhirhweni 2012, ngemva nje kokuphothula, uGwarube wathuthela [[Cape Town|eKapa]] ukuyokuthoma umsebenzi njengomkhulumeli ehhovisini lakaMazibuko. &lt;ref name=&quot;:12&quot; /&gt; Ngemva kwalokho wathuthela emNyangweni [[Western Cape Department of Health|wezamaPhilo we-Western Cape]], lapho bekayisikhulumeli nomphathi weNgqongqotjhe ngaphasi kwakaNgqongqotjhe wePhrovinsi [[Nomafrench Mbombo|uNomafrench Mbombo]] . Ngaphambi [[2019 South African general election|kokhetho luka-2019]], bekangumnqophisi omkhulu wezokuthintana we-DA

'''Umsebenzi wezepolotiki'''

'''I-DA caucus: 2019–2024'''

Ngokhetho lukaMeyi 2019, u-Gwarube wakhethwa bona ajamele i-DA e- [[National Assembly of South Africa|National Assembly]], indlu ephasi yePalamende [[South African Parliament|yeSewula Afrika]] . Wabekwa godu njengoNgqongqotjhe [[Official Opposition Shadow Cabinet (South Africa)|wezamaPhilo]] [[Shadow Cabinet of Mmusi Maimane|ekhabhinethi yomdosiphambili]] we-DA u [[Minister of Health (South Africa)|-]] [[Musi Maimane|Mmusi Maimane]], u [[Lindy Wilson|-Lindy Wilson]] abe msekeli wakhe. &lt;ref&gt;{{cite news|last1=Nkanjeni|first1=Unathi|date=6 June 2019|title=DA shadow cabinet: What you need to know|url=https://www.timeslive.co.za/politics/2019-06-06-da-shadow-cabinet-what-you-need-to-know/|accessdate=8 April 2020|newspaper=Sunday Times}}&lt;/ref&gt; &lt;ref&gt;{{cite news|last1=Gerber|first1=Jan|date=5 June 2019|title=Here's the DA's 'shadow cabinet'|url=https://www.news24.com/SouthAfrica/News/heres-the-das-shadow-cabinet-20190605|accessdate=8 April 2020|newspaper=News24}}&lt;/ref&gt; Wagcina isikhundla leso [[Shadow Cabinet of John Steenhuisen|ekhabhinethi yesithunzi]] yomlandeli ka-Maimane, [[John Steenhuisen|u-John Steenhuisen]] . &lt;ref&gt;{{Cite news|last=Mazzone|first=Natasha|date=5 December 2020|title=DA announces new Shadow Cabinet that will bring Real Hope and Real Change|url=https://www.da.org.za/2020/12/da-announces-new-shadow-cabinet-that-will-bring-real-hope-and-real-change|access-date=5 December 2020|work=Democratic Alliance}}&lt;/ref&gt; Isikhathi sakhe emkhakheni wezamaphilo sahlangana nobhubhane [[COVID-19 pandemic in South Africa|lwe-COVID-19]], kanye [[Zweli Mkhize#Digital Vibes scandal|nehlazo le-Digital Vibes]] eliphathelene nekohlakalo emNyangweni [[Department of Health (South Africa)|wezamaPhilo]] ; &lt;ref name=&quot;:03&quot;&gt;{{Cite web|last=Felix|first=Jason|date=10 September 2022|title=Leading the pack: Siviwe Gwarube stands tall at helm of DA's charge in Parliament|url=https://www.news24.com/news24/opinions/analysis/saturday-profile-leading-the-pack-siviwe-gwarube-stands-tall-at-helm-of-das-charge-in-parliament-20220910|access-date=2024-07-03|website=News24|language=en-US}}&lt;/ref&gt; malungana nokugcina, u-Gwarube wabeka amacala wobulelesi kuNgqongqotjhe wezamaPhilo [[Zweli Mkhize|u-Zweli Mkhize]].

Ngokhetho lukaMeyi 2019, u-Gwarube wakhethwa bona ajamele i-DA e- [[National Assembly of South Africa|National Assembly]], indlu ephasi yePalamende [[South African Parliament|yeSewula Afrika]] . Wabekwa godu njengoNgqongqotjhe [[Official Opposition Shadow Cabinet (South Africa)|wezamaPhilo]] [[Shadow Cabinet of Mmusi Maimane|ekhabhinethi yomdosiphambili]] we-DA u [[Minister of Health (South Africa)|-]] [[Musi Maimane|Mmusi Maimane]], u [[Lindy Wilson|-Lindy Wilson]] abe msekeli wakhe. &lt;ref&gt;{{cite news|last1=Nkanjeni|first1=Unathi|date=6 June 2019|title=DA shadow cabinet: What you need to know|url=https://www.timeslive.co.za/politics/2019-06-06-da-shadow-cabinet-what-you-need-to-know/|accessdate=8 April 2020|newspaper=Sunday Times}}&lt;/ref&gt; &lt;ref&gt;{{cite news|last1=Gerber|first1=Jan|date=5 June 2019|title=Here's the DA's 'shadow cabinet'|url=https://www.news24.com/SouthAfrica/News/heres-the-das-shadow-cabinet-20190605|accessdate=8 April 2020|newspaper=News24}}&lt;/ref&gt; Wagcina isikhundla leso [[Shadow Cabinet of John Steenhuisen|ekhabhinethi yesithunzi]] yomlandeli ka-Maimane, [[John Steenhuisen|u-John Steenhuisen]] . &lt;ref&gt;{{Cite news|last=Mazzone|first=Natasha|date=5 December 2020|title=DA announces new Shadow Cabinet that will bring Real Hope and Real Change|url=https://www.da.org.za/2020/12/da-announces-new-shadow-cabinet-that-will-bring-real-hope-and-real-change|access-date=5 December 2020|work=Democratic Alliance}}&lt;/ref&gt; Isikhathi sakhe emkhakheni wezamaphilo sahlangana nobhubhane [[COVID-19 pandemic in South Africa|lwe-COVID-19]], kanye [[Zweli Mkhize#Digital Vibes scandal|nehlazo le-Digital Vibes]] eliphathelene nekohlakalo emNyangweni [[Department of Health (South Africa)|wezamaPhilo]] ; &lt;ref name=&quot;:04&quot;&gt;{{Cite web|last=Felix|first=Jason|date=10 September 2022|title=Leading the pack: Siviwe Gwarube stands tall at helm of DA's charge in Parliament|url=https://www.news24.com/news24/opinions/analysis/saturday-profile-leading-the-pack-siviwe-gwarube-stands-tall-at-helm-of-das-charge-in-parliament-20220910|access-date=2024-07-03|website=News24|language=en-US}}&lt;/ref&gt; malungana nokugcina, u-Gwarube wabeka amacala wobulelesi kuNgqongqotjhe wezamaPhilo [[Zweli Mkhize|u-Zweli Mkhize.]]

Mhlana amalanga ali-18 kuRhoboyi wee-2022, u-Gwarube waphakanyiswa waba yi-chief whip ye-DA caucus e-National Assembly; umuntu ophethe isikhundla, [[Natasha Mazzone|u-Natasha Mazzone]], waxoshwa. &lt;ref&gt;{{Cite web|last=|date=18 August 2022|title=Siviwe Gwarube appointed DA's new chief whip as axe falls on Mazzone|url=https://www.sowetanlive.co.za/news/south-africa/2022-08-18-siviwe-gwarube-appointed-das-new-chief-whip-as-axe-falls-on-mazzone/|access-date=2022-08-18|website=Sowetan|language=en-ZA}}&lt;/ref&gt; &lt;ref&gt;{{Cite web|title=Siviwe Gwarube appointed DA Chief Whip|url=https://www.enca.com/news/siviwe-gwarube-appointed-da-chief-whip|access-date=2022-08-18|website=eNCA|language=en}}&lt;/ref&gt; Abahlaziyi baphawule &quot;ukukhuphuka okukhulu&quot; kukaGwarube ngokusebenzisa i-caucus. &lt;ref name=&quot;:2&quot;&gt;{{Cite news|date=18 August 2022|title=Siviwe Gwarube is new DA chief whip after Natasha Mazzone is demoted|url=https://www.businesslive.co.za/bd/national/2022-08-18-siviwe-gwarube-is-new-da-chief-whip-after-natasha-mazzone-is-demoted/|access-date=3 July 2024|work=Business Day}}&lt;/ref&gt; &lt;ref&gt;{{Cite web|last=Hussain|first=Muhammad|date=24 February 2024|title=Siviwe Gwarube: DA does have deep sense of internal introspection|url=https://www.news24.com/news24/opinions/analysis/saturday-profile-siviwe-gwarube-da-does-have-deep-sense-of-internal-introspection-20240224|access-date=2024-07-03|website=News24|language=en-US}}&lt;/ref&gt; Emtlolweni wokuhlela, [[Mondli Makhanya|u-Mondli Makhanya]] we ''[[City Press (South Africa)|-City Press]]'' wathi, nanyana &quot;bekalilunga lePhalamende elikhuluma ngokuzwakalako, elizithembako nomkhulumeli wehlangano ongeze waphuthelwa lilizwi lakhe&quot;, u-Gwarube wahlala anganalwazi; wamxwayisa bona aqaphele &quot;ukubekwa bona ahluleke&quot;. &lt;ref&gt;{{Cite web|date=21 August 2022|title=Editorial: Allow Gwarube to lead|url=https://www.news24.com/citypress/voices/editorial-allow-gwarube-to-lead-20220821|access-date=2024-07-03|website=City Press|language=en-US}}&lt;/ref&gt; U-Gwarube, nanyana kunjalo, wathi bekakulungele ukudlala indima leyo begodu bekahlose &quot;ukukhamba endaweni le ngendlela eqinisekileko&quot;. &lt;ref&gt;{{Cite news|date=27 August 2022|title=New DA whip says she’s tough enough for the job|url=https://www.iol.co.za/weekend-argus/news/new-da-whip-says-shes-tough-enough-for-the-job-a73d0080-4018-42b9-b541-71828a282caa|access-date=3 July 2024|work=Weekend Argus}}&lt;/ref&gt; [[Cilliers Brink|U-Cilliers Brink]] no-Solly Malatsi bakhethwa bona bathathe imisebenzi yakhe njengomkhulumeli we-DA.

'''UNgqongqotjhe wezefundo ezisisekelo: 2024-nje'''

U-Gwarube wakhethwa godu esihlalweni sakhe sepalamende [[2024 South African general election|ngokhetho lukaMeyi 2024]], begodu bekalilunga lesiqhema samalunga amane ebesimele i-DA ngesikhathi seengcoco ezilandelako zokubambisana ne- [[African National Congress]] (ANC). &lt;ref&gt;{{Cite web|last=Ramushwana|first=Alpha|date=2 June 2024|title=DA declares coalition team to lead talks over the next 5 years|url=https://www.ewn.co.za/2024/06/02/da-declares-coalition-team-to-lead-talks-over-the-next-5-years|access-date=2024-07-03|website=EWN|language=en}}&lt;/ref&gt; Ngokuhambisana [[2024 South African government formation|nesivumelwano sokusebenzisana]] esifinyelelwe hlangana ne-DA ne-ANC, uMongameli [[Cyril Ramaphosa|u-Cyril Ramaphosa]] wamkhetha njengoNgqongqotjhe [[Minister of Basic Education|wezeFundo eSisekelo]] . &lt;ref&gt;{{Cite news|date=2 July 2024|title=I’m itching to get stuck in – Siviwe Gwarube ready to start tenure as basic education minister|url=https://www.sowetanlive.co.za/news/south-africa/2024-07-02-im-itching-to-get-stuck-in-whats-already-on-basic-education-minister-siviwe-gwarubes-in-tray/#google_vignette|access-date=3 July 2024|work=The Sowetan}}&lt;/ref&gt; U [[Reginah Mhaule|-Reginah Mhaule]] we-ANC wakhethwa njengesekela lakhe. &lt;ref&gt;{{Cite web|last=Ramaphosa|first=Cyril|date=30 June 2024|title=Working together to 'serve the people': Ramaphosa names new Cabinet|url=https://www.news24.com/news24/southafrica/news/read-in-full-working-together-to-serve-the-people-ramaphosa-names-new-cabinet-20240630|access-date=2024-07-03|website=News24|language=en-US}}&lt;/ref&gt; Wafungiswa esikhundleni mhlazi-3 kuNtaka 2024, &lt;ref&gt;{{Cite web|last=Ludidi|first=Velani|date=2024-07-03|title=Historic day for SA as GNU ministers sworn into office|url=https://www.dailymaverick.co.za/article/2024-07-03-historic-day-for-sa-as-government-of-national-unity-ministers-take-oath-of-office/|access-date=2024-07-16|website=Daily Maverick|language=en}}&lt;/ref&gt; begodu [[George Michalakis|u-George Michalakis]] wathatha isikhundla sakhe njengesihluthu esikhulu se-DA.

U-Gwarube wakhethwa godu esihlalweni sakhe sepalamende [[2024 South African general election|ngokhetho lukaMeyi 2024]], begodu bekalilunga lesiqhema samalunga amane ebesimele i-DA ngesikhathi seengcoco ezilandelako zokubambisana ne- [[African National Congress]] (ANC). &lt;ref&gt;{{Cite web|last=Ramushwana|first=Alpha|date=2 June 2024|title=DA declares coalition team to lead talks over the next 5 years|url=https://www.ewn.co.za/2024/06/02/da-declares-coalition-team-to-lead-talks-over-the-next-5-years|access-date=2024-07-03|website=EWN|language=en}}&lt;/ref&gt; Ngokuhambisana [[2024 South African government formation|nesivumelwano sokusebenzisana]] esifinyelelwe hlangana ne-DA ne-ANC, uMongameli [[Cyril Ramaphosa|u-Cyril Ramaphosa]] wamkhetha njengoNgqongqotjhe [[Minister of Basic Education|wezeFundo eSisekelo]] . &lt;ref&gt;{{Cite news|date=2 July 2024|title=I’m itching to get stuck in – Siviwe Gwarube ready to start tenure as basic education minister|url=https://www.sowetanlive.co.za/news/south-africa/2024-07-02-im-itching-to-get-stuck-in-whats-already-on-basic-education-minister-siviwe-gwarubes-in-tray/#google_vignette|access-date=3 July 2024|work=The Sowetan}}&lt;/ref&gt; U [[Reginah Mhaule|-Reginah Mhaule]] we-ANC wakhethwa njengesekela lakhe. &lt;ref&gt;{{Cite web|last=Ramaphosa|first=Cyril|date=30 June 2024|title=Working together to 'serve the people': Ramaphosa names new Cabinet|url=https://www.news24.com/news24/southafrica/news/read-in-full-working-together-to-serve-the-people-ramaphosa-names-new-cabinet-20240630|access-date=2024-07-03|website=News24|language=en-US}}&lt;/ref&gt; Wafungiswa esikhundleni mhlazi-3 kuNtaka 2024, &lt;ref&gt;{{Cite web|last=Ludidi|first=Velani|date=2024-07-03|title=Historic day for SA as GNU ministers sworn into office|url=https://www.dailymaverick.co.za/article/2024-07-03-historic-day-for-sa-as-government-of-national-unity-ministers-take-oath-of-office/|access-date=2024-07-16|website=Daily Maverick|language=en}}&lt;/ref&gt; begodu [[George Michalakis|u-George Michalakis]] wathatha isikhundla sakhe njengesihluthu esikhulu se-DA.

U-Gwarube wakhethwa godu esihlalweni sakhe sepalamende [[2024 South African general election|ngokhetho lukaMeyi 2024]], begodu bekalilunga lesiqhema samalunga amane ebesimele i-DA ngesikhathi seengcoco ezilandelako zokubambisana ne- [[African National Congress]] (ANC). &lt;ref&gt;{{Cite web|last=Ramushwana|first=Alpha|date=2 June 2024|title=DA declares coalition team to lead talks over the next 5 years|url=https://www.ewn.co.za/2024/06/02/da-declares-coalition-team-to-lead-talks-over-the-next-5-years|access-date=2024-07-03|website=EWN|language=en}}&lt;/ref&gt; Ngokuhambisana [[2024 South African government formation|nesivumelwano sokusebenzisana]] esifinyelelwe hlangana ne-DA ne-ANC, uMongameli [[Cyril Ramaphosa|u-Cyril Ramaphosa]] wamkhetha njengoNgqongqotjhe [[Minister of Basic Education|wezeFundo eSisekelo]] . &lt;ref&gt;{{Cite news|date=2 July 2024|title=I’m itching to get stuck in – Siviwe Gwarube ready to start tenure as basic education minister|url=https://www.sowetanlive.co.za/news/south-africa/2024-07-02-im-itching-to-get-stuck-in-whats-already-on-basic-education-minister-siviwe-gwarubes-in-tray/#google_vignette|access-date=3 July 2024|work=The Sowetan}}&lt;/ref&gt; U [[Reginah Mhaule|-Reginah Mhaule]] we-ANC wakhethwa njengesekela lakhe. &lt;ref&gt;{{Cite web|last=Ramaphosa|first=Cyril|date=30 June 2024|title=Working together to 'serve the people': Ramaphosa names new Cabinet|url=https://www.news24.com/news24/southafrica/news/read-in-full-working-together-to-serve-the-people-ramaphosa-names-new-cabinet-20240630|access-date=2024-07-03|website=News24|language=en-US}}&lt;/ref&gt; Wafungiswa esikhundleni mhlazi-3 kuNtaka 2024, &lt;ref&gt;{{Cite web|last=Ludidi|first=Velani|date=2024-07-03|title=Historic day for SA as GNU ministers sworn into office|url=https://www.dailymaverick.co.za/article/2024-07-03-historic-day-for-sa-as-government-of-national-unity-ministers-take-oath-of-office/|access-date=2024-07-16|website=Daily Maverick|language=en}}&lt;/ref&gt; begodu [[George Michalakis|u-George Michalakis]] wathatha isikhundla sakhe njengesihluthu esikhulu se-DA.

'''UMTHOMBO-LWAZI'''</text>
      <sha1>b8cwxnxe0qyb5oyqqwff3pmfsuyzgi7</sha1>
    </revision>
    <revision>
      <id>5607</id>
      <parentid>5497</parentid>
      <timestamp>2025-09-04T10:25:05Z</timestamp>
      <contributor>
        <username>Nabungela</username>
        <id>885</id>
      </contributor>
      <origin>5607</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="18088" sha1="e3bkgft4lpywi81a3xc24809y8mge7f" xml:space="preserve">Page 1: Draft space 1

'''&lt;big&gt;SIVIWE GWARUBE&lt;/big&gt;'''
U- '''Siviwe Gwarube''' (wabelethwa mhlana ali-14 kuNtaka 1989) usopolotiki [[Isewula Afrika|weSewula Afrika]] osebenza njengoNgqongqotjhe [[Minister of Basic Education|wezeFundo yeSisekelo]] kuRhulumende [[Third Cabinet of Cyril Ramaphosa|weBumbano leNarha]] (i-GNU) kusukela ngoNtaka 2024. Ulilunga le- [[Democratic Alliance (South Africa)|Democratic Alliance]] (DA), bekayilunga le-Democratic Alliance (DA), bekayi [[National Assembly of South Africa|-Chief Whip ye-Official Opposition]] hlangana kwakaRhoboyi 2020 ukuya kuRhoboyi 24. Wajoyina i [[National Assembly of South Africa|-National. I-Assembly yeSewula Afrika]] kukhetho [[2019 South African general election|lukaMeyi 2019]]

U- '''Siviwe Gwarube''' (wabelethwa mhlana ali-14 kuNtaka 1989) usopolotiki [[Isewula Afrika|weSewula Afrika]] osebenza njengoNgqongqotjhe [[Minister of Basic Education|wezeFundo yeSisekelo]] kuRhulumende [[Third Cabinet of Cyril Ramaphosa|weBumbano leNarha]] (i-GNU) kusukela ngoNtaka 2024. le-Democratic Alliance (DA), bekayi [[National Assembly of South Africa|-Chief Whip ye-Official Opposition]] hlangana kwakaRhoboyi 2020 ukuya kuRhoboyi 24. Wajoyina i [[National Assembly of South Africa|-National. I-Assembly yeSewula Afrika]] kukhetho [[2019 South African general election|lukaMeyi 2019]]

Wabelethelwa e [[Eastern Cape|-Eastern Cape]], u-Gwarube wangena kwezepolotiki ngo-2012 njengomkhulumeli womrholi wepalamende we-DA [[Lindiwe Mazibuko|u-Lindiwe Mazibuko]] . Ngesikhathi [[27th South African Parliament|sePalamende yesiThupha]], ngaphambi kokukhethwa njengoMphathiswa we-DA, wasebenza njengoNgqongqotjhe [[Official Opposition Shadow Cabinet (South Africa)|wezamaPhilo]] kusukela ngoMgwengweni 2019 ukuya kuMhlolanja 2022, umkhulumeli wezwe loke we [[Minister of Health (South Africa)|-]] DA kusukela ngoNobayeni 2020 ukuya kuRhoboyi 2022, kanye noSekela loMphathiswa kusukela ngoNobayeni 2021 ukuya kuRhoboyi 2022.

'''Ipilo yokuthoma nomsebenzi'''

U-Gwarube wabelethwa mhlana ali-14 kuNtaka 1989, &lt;ref name=&quot;:122&quot;&gt;{{Cite web|date=10 April 2024|title=Final Candidate Lists for 2024 National and Provincial Elections: National Candidates|url=https://www.elections.org.za/pw/Documents/Candidates-List-NPE2024/National%20Candidates%20List.pdf|access-date=2024-03-26|website=Electoral Commission of South Africa}}&lt;/ref&gt; uGwarube wakhulela e-KwaMdingi, idolobhana elingaphandle [[King William's Town|kweDorobha le-King William]] e- [[Cape Province]] . &lt;ref name=&quot;:02&quot;&gt;{{Cite web|last=Felix|first=Jason|date=10 September 2022|title=Leading the pack: Siviwe Gwarube stands tall at helm of DA's charge in Parliament|url=https://www.news24.com/news24/opinions/analysis/saturday-profile-leading-the-pack-siviwe-gwarube-stands-tall-at-helm-of-das-charge-in-parliament-20220910|access-date=2024-07-03|website=News24|language=en-US}}&lt;/ref&gt; Wakhuliswa ngugogo wakhe, obekangutitjhere ongakatjhadi. &lt;ref name=&quot;:1&quot;&gt;{{Cite web|last=Huisman|first=Biénne|date=2019-11-18|title=Face to face with shadow health minister Siviwe Gwarube|url=https://www.dailymaverick.co.za/article/2019-11-19-face-to-face-with-shadow-health-minister-siviwe-gwarube/|access-date=2024-07-03|website=Daily Maverick|language=en}}&lt;/ref&gt; Ngemva kokuphothula e-Kingsridge High School for Girls e-King William's Town, wafunda umthetho, ipolotiki, kanye nefilosofi e- [[Rhodes University]] e- [[Grahamstown]] . Waphothula nge-Bachelor of Arts ngo-2012

Ngomnyaka wakhe wokugcina njengomfundi, u-Gwarube waqatjhwa ehlelweni labadosiphambili abatjha [[Democratic Alliance (South Africa)|be-Democratic Alliance]] (DA). &lt;ref name=&quot;:12&quot;&gt;{{Cite web|last=Huisman|first=Biénne|date=2019-11-18|title=Face to face with shadow health minister Siviwe Gwarube|url=https://www.dailymaverick.co.za/article/2019-11-19-face-to-face-with-shadow-health-minister-siviwe-gwarube/|access-date=2024-07-03|website=Daily Maverick|language=en}}&lt;/ref&gt; Ehlelweni wahlangana no [[Lindiwe Mazibuko|-Lindiwe Mazibuko]], [[Leader of the Opposition (South Africa)|uMdosiphambili wePhikisako]], owaba mfundisi wakhe. &lt;ref&gt;{{Cite news|date=21 August 2022|title=‘I am nobody’s experiment,’ says DA’s new chief whip|url=https://www.timeslive.co.za/sunday-times/news/politics/2022-08-21-i-am-nobodys-experiment-says-das-new-chief-whip/|access-date=3 July 2024|work=Sunday Times}}&lt;/ref&gt; NgoTjhirhweni 2012, ngemva nje kokuphothula, uGwarube wathuthela [[Cape Town|eKapa]] ukuyokuthoma umsebenzi njengomkhulumeli ehhovisini lakaMazibuko. &lt;ref name=&quot;:12&quot; /&gt; Ngemva kwalokho wathuthela emNyangweni [[Western Cape Department of Health|wezamaPhilo we-Western Cape]], lapho bekayisikhulumeli nomphathi weNgqongqotjhe ngaphasi kwakaNgqongqotjhe wePhrovinsi [[Nomafrench Mbombo|uNomafrench Mbombo]] . Ngaphambi [[2019 South African general election|kokhetho luka-2019]], bekangumnqophisi omkhulu wezokuthintana we-DA

'''Umsebenzi wezepolotiki'''

'''I-DA caucus: 2019–2024'''

Ngokhetho lukaMeyi 2019, u-Gwarube wakhethwa bona ajamele i-DA e- [[National Assembly of South Africa|National Assembly]], indlu ephasi yePalamende [[South African Parliament|yeSewula Afrika]] . Wabekwa godu njengoNgqongqotjhe [[Official Opposition Shadow Cabinet (South Africa)|wezamaPhilo]] [[Shadow Cabinet of Mmusi Maimane|ekhabhinethi yomdosiphambili]] we-DA u [[Minister of Health (South Africa)|-]] [[Musi Maimane|Mmusi Maimane]], u [[Lindy Wilson|-Lindy Wilson]] abe msekeli wakhe. &lt;ref&gt;{{cite news|last1=Nkanjeni|first1=Unathi|date=6 June 2019|title=DA shadow cabinet: What you need to know|url=https://www.timeslive.co.za/politics/2019-06-06-da-shadow-cabinet-what-you-need-to-know/|accessdate=8 April 2020|newspaper=Sunday Times}}&lt;/ref&gt; &lt;ref&gt;{{cite news|last1=Gerber|first1=Jan|date=5 June 2019|title=Here's the DA's 'shadow cabinet'|url=https://www.news24.com/SouthAfrica/News/heres-the-das-shadow-cabinet-20190605|accessdate=8 April 2020|newspaper=News24}}&lt;/ref&gt; Wagcina isikhundla leso [[Shadow Cabinet of John Steenhuisen|ekhabhinethi yesithunzi]] yomlandeli ka-Maimane, [[John Steenhuisen|u-John Steenhuisen]] . &lt;ref&gt;{{Cite news|last=Mazzone|first=Natasha|date=5 December 2020|title=DA announces new Shadow Cabinet that will bring Real Hope and Real Change|url=https://www.da.org.za/2020/12/da-announces-new-shadow-cabinet-that-will-bring-real-hope-and-real-change|access-date=5 December 2020|work=Democratic Alliance}}&lt;/ref&gt; Isikhathi sakhe emkhakheni wezamaphilo sahlangana nobhubhane [[COVID-19 pandemic in South Africa|lwe-COVID-19]], kanye [[Zweli Mkhize#Digital Vibes scandal|nehlazo le-Digital Vibes]] eliphathelene nekohlakalo emNyangweni [[Department of Health (South Africa)|wezamaPhilo]] ; &lt;ref name=&quot;:03&quot;&gt;{{Cite web|last=Felix|first=Jason|date=10 September 2022|title=Leading the pack: Siviwe Gwarube stands tall at helm of DA's charge in Parliament|url=https://www.news24.com/news24/opinions/analysis/saturday-profile-leading-the-pack-siviwe-gwarube-stands-tall-at-helm-of-das-charge-in-parliament-20220910|access-date=2024-07-03|website=News24|language=en-US}}&lt;/ref&gt; malungana nokugcina, u-Gwarube wabeka amacala wobulelesi kuNgqongqotjhe wezamaPhilo [[Zweli Mkhize|u-Zweli Mkhize]].

Ngokhetho lukaMeyi 2019, u-Gwarube wakhethwa bona ajamele i-DA e- National Assembly, indlu ephasi yePalamende [[South African Parliament|yeSewula Afrika]] . Wabekwa godu njengoNgqongqotjhe [[Official Opposition Shadow Cabinet (South Africa)|wezamaPhilo]] [[Shadow Cabinet of Mmusi Maimane|ekhabhinethi yomdosiphambili]] we-DA u [[Minister of Health (South Africa)|-]] [[Musi Maimane|Mmusi Maimane]], u [[Lindy Wilson|-Lindy Wilson]] abe msekeli wakhe. &lt;ref&gt;{{cite news|last1=Nkanjeni|first1=Unathi|date=6 June 2019|title=DA shadow cabinet: What you need to know|url=https://www.timeslive.co.za/politics/2019-06-06-da-shadow-cabinet-what-you-need-to-know/|accessdate=8 April 2020|newspaper=Sunday Times}}&lt;/ref&gt; &lt;ref&gt;{{cite news|last1=Gerber|first1=Jan|date=5 June 2019|title=Here's the DA's 'shadow cabinet'|url=https://www.news24.com/SouthAfrica/News/heres-the-das-shadow-cabinet-20190605|accessdate=8 April 2020|newspaper=News24}}&lt;/ref&gt; Wagcina isikhundla leso [[Shadow Cabinet of John Steenhuisen|ekhabhinethi yesithunzi]] yomlandeli ka-Maimane, [[John Steenhuisen|u-John Steenhuisen]] . &lt;ref&gt;{{Cite news|last=Mazzone|first=Natasha|date=5 December 2020|title=DA announces new Shadow Cabinet that will bring Real Hope and Real Change|url=https://www.da.org.za/2020/12/da-announces-new-shadow-cabinet-that-will-bring-real-hope-and-real-change|access-date=5 December 2020|work=Democratic Alliance}}&lt;/ref&gt; Isikhathi sakhe emkhakheni wezamaphilo sahlangana nobhubhane [[COVID-19 pandemic in South Africa|lwe-COVID-19]], kanye [[Zweli Mkhize#Digital Vibes scandal|nehlazo le-Digital Vibes]] eliphathelene nekohlakalo emNyangweni [[Department of Health (South Africa)|wezamaPhilo]] ; &lt;ref name=&quot;:04&quot;&gt;{{Cite web|last=Felix|first=Jason|date=10 September 2022|title=Leading the pack: Siviwe Gwarube stands tall at helm of DA's charge in Parliament|url=https://www.news24.com/news24/opinions/analysis/saturday-profile-leading-the-pack-siviwe-gwarube-stands-tall-at-helm-of-das-charge-in-parliament-20220910|access-date=2024-07-03|website=News24|language=en-US}}&lt;/ref&gt; malungana nokugcina, u-Gwarube wabeka amacala wobulelesi kuNgqongqotjhe wezamaPhilo [[Zweli Mkhize|u-Zweli Mkhize.]]

Mhlana amalanga ali-18 kuRhoboyi wee-2022, u-Gwarube waphakanyiswa waba yi-chief whip ye-DA caucus e-National Assembly; umuntu ophethe isikhundla, [[Natasha Mazzone|u-Natasha Mazzone]], waxoshwa. &lt;ref&gt;{{Cite web|last=|date=18 August 2022|title=Siviwe Gwarube appointed DA's new chief whip as axe falls on Mazzone|url=https://www.sowetanlive.co.za/news/south-africa/2022-08-18-siviwe-gwarube-appointed-das-new-chief-whip-as-axe-falls-on-mazzone/|access-date=2022-08-18|website=Sowetan|language=en-ZA}}&lt;/ref&gt; &lt;ref&gt;{{Cite web|title=Siviwe Gwarube appointed DA Chief Whip|url=https://www.enca.com/news/siviwe-gwarube-appointed-da-chief-whip|access-date=2022-08-18|website=eNCA|language=en}}&lt;/ref&gt; Abahlaziyi baphawule &quot;ukukhuphuka okukhulu&quot; kukaGwarube ngokusebenzisa i-caucus. &lt;ref name=&quot;:2&quot;&gt;{{Cite news|date=18 August 2022|title=Siviwe Gwarube is new DA chief whip after Natasha Mazzone is demoted|url=https://www.businesslive.co.za/bd/national/2022-08-18-siviwe-gwarube-is-new-da-chief-whip-after-natasha-mazzone-is-demoted/|access-date=3 July 2024|work=Business Day}}&lt;/ref&gt; &lt;ref&gt;{{Cite web|last=Hussain|first=Muhammad|date=24 February 2024|title=Siviwe Gwarube: DA does have deep sense of internal introspection|url=https://www.news24.com/news24/opinions/analysis/saturday-profile-siviwe-gwarube-da-does-have-deep-sense-of-internal-introspection-20240224|access-date=2024-07-03|website=News24|language=en-US}}&lt;/ref&gt; Emtlolweni wokuhlela, [[Mondli Makhanya|u-Mondli Makhanya]] we ''[[City Press (South Africa)|-City Press]]'' wathi, nanyana &quot;bekalilunga lePhalamende elikhuluma ngokuzwakalako, elizithembako nomkhulumeli wehlangano ongeze waphuthelwa lilizwi lakhe&quot;, u-Gwarube wahlala anganalwazi; wamxwayisa bona aqaphele &quot;ukubekwa bona ahluleke&quot;. &lt;ref&gt;{{Cite web|date=21 August 2022|title=Editorial: Allow Gwarube to lead|url=https://www.news24.com/citypress/voices/editorial-allow-gwarube-to-lead-20220821|access-date=2024-07-03|website=City Press|language=en-US}}&lt;/ref&gt; U-Gwarube, nanyana kunjalo, wathi bekakulungele ukudlala indima leyo begodu bekahlose &quot;ukukhamba endaweni le ngendlela eqinisekileko&quot;. &lt;ref&gt;{{Cite news|date=27 August 2022|title=New DA whip says she’s tough enough for the job|url=https://www.iol.co.za/weekend-argus/news/new-da-whip-says-shes-tough-enough-for-the-job-a73d0080-4018-42b9-b541-71828a282caa|access-date=3 July 2024|work=Weekend Argus}}&lt;/ref&gt; [[Cilliers Brink|U-Cilliers Brink]] no-Solly Malatsi bakhethwa bona bathathe imisebenzi yakhe njengomkhulumeli we-DA.

'''UNgqongqotjhe wezefundo ezisisekelo: 2024-nje'''

U-Gwarube wakhethwa godu esihlalweni sakhe sepalamende [[2024 South African general election|ngokhetho lukaMeyi 2024]], begodu bekalilunga lesiqhema samalunga amane ebesimele i-DA ngesikhathi seengcoco ezilandelako zokubambisana ne- African National Congress (ANC). &lt;ref&gt;{{Cite web|last=Ramushwana|first=Alpha|date=2 June 2024|title=DA declares coalition team to lead talks over the next 5 years|url=https://www.ewn.co.za/2024/06/02/da-declares-coalition-team-to-lead-talks-over-the-next-5-years|access-date=2024-07-03|website=EWN|language=en}}&lt;/ref&gt; Ngokuhambisana [[2024 South African government formation|nesivumelwano sokusebenzisana]] esifinyelelwe hlangana ne-DA ne-ANC, uMongameli [[Cyril Ramaphosa|u-Cyril Ramaphosa]] wamkhetha njengoNgqongqotjhe [[Minister of Basic Education|wezeFundo eSisekelo]] . &lt;ref&gt;{{Cite news|date=2 July 2024|title=I’m itching to get stuck in – Siviwe Gwarube ready to start tenure as basic education minister|url=https://www.sowetanlive.co.za/news/south-africa/2024-07-02-im-itching-to-get-stuck-in-whats-already-on-basic-education-minister-siviwe-gwarubes-in-tray/#google_vignette|access-date=3 July 2024|work=The Sowetan}}&lt;/ref&gt; U [[Reginah Mhaule|-Reginah Mhaule]] we-ANC wakhethwa njengesekela lakhe. &lt;ref&gt;{{Cite web|last=Ramaphosa|first=Cyril|date=30 June 2024|title=Working together to 'serve the people': Ramaphosa names new Cabinet|url=https://www.news24.com/news24/southafrica/news/read-in-full-working-together-to-serve-the-people-ramaphosa-names-new-cabinet-20240630|access-date=2024-07-03|website=News24|language=en-US}}&lt;/ref&gt; Wafungiswa esikhundleni mhlazi-3 kuNtaka 2024, &lt;ref&gt;{{Cite web|last=Ludidi|first=Velani|date=2024-07-03|title=Historic day for SA as GNU ministers sworn into office|url=https://www.dailymaverick.co.za/article/2024-07-03-historic-day-for-sa-as-government-of-national-unity-ministers-take-oath-of-office/|access-date=2024-07-16|website=Daily Maverick|language=en}}&lt;/ref&gt; begodu [[George Michalakis|u-George Michalakis]] wathatha isikhundla sakhe njengesihluthu esikhulu se-DA.

U-Gwarube wakhethwa godu esihlalweni sakhe sepalamende [[2024 South African general election|ngokhetho lukaMeyi 2024]], begodu bekalilunga lesiqhema samalunga amane ebesimele i-DA ngesikhathi seengcoco ezilandelako zokubambisana ne- [[African National Congress]] (ANC). &lt;ref&gt;{{Cite web|last=Ramushwana|first=Alpha|date=2 June 2024|title=DA declares coalition team to lead talks over the next 5 years|url=https://www.ewn.co.za/2024/06/02/da-declares-coalition-team-to-lead-talks-over-the-next-5-years|access-date=2024-07-03|website=EWN|language=en}}&lt;/ref&gt; Ngokuhambisana [[2024 South African government formation|nesivumelwano sokusebenzisana]] esifinyelelwe hlangana ne-DA ne-ANC, uMongameli [[Cyril Ramaphosa|u-Cyril Ramaphosa]] wamkhetha njengoNgqongqotjhe [[Minister of Basic Education|wezeFundo eSisekelo]] . &lt;ref&gt;{{Cite news|date=2 July 2024|title=I’m itching to get stuck in – Siviwe Gwarube ready to start tenure as basic education minister|url=https://www.sowetanlive.co.za/news/south-africa/2024-07-02-im-itching-to-get-stuck-in-whats-already-on-basic-education-minister-siviwe-gwarubes-in-tray/#google_vignette|access-date=3 July 2024|work=The Sowetan}}&lt;/ref&gt; U [[Reginah Mhaule|-Reginah Mhaule]] we-ANC wakhethwa njengesekela lakhe. &lt;ref&gt;{{Cite web|last=Ramaphosa|first=Cyril|date=30 June 2024|title=Working together to 'serve the people': Ramaphosa names new Cabinet|url=https://www.news24.com/news24/southafrica/news/read-in-full-working-together-to-serve-the-people-ramaphosa-names-new-cabinet-20240630|access-date=2024-07-03|website=News24|language=en-US}}&lt;/ref&gt; Wafungiswa esikhundleni mhlazi-3 kuNtaka 2024, &lt;ref&gt;{{Cite web|last=Ludidi|first=Velani|date=2024-07-03|title=Historic day for SA as GNU ministers sworn into office|url=https://www.dailymaverick.co.za/article/2024-07-03-historic-day-for-sa-as-government-of-national-unity-ministers-take-oath-of-office/|access-date=2024-07-16|website=Daily Maverick|language=en}}&lt;/ref&gt; begodu [[George Michalakis|u-George Michalakis]] wathatha isikhundla sakhe njengesihluthu esikhulu se-DA.

U-Gwarube wakhethwa godu esihlalweni sakhe sepalamende [[2024 South African general election|ngokhetho lukaMeyi 2024]], begodu bekalilunga lesiqhema samalunga amane ebesimele i-DA ngesikhathi seengcoco ezilandelako zokubambisana ne- [[African National Congress]] (ANC). &lt;ref&gt;{{Cite web|last=Ramushwana|first=Alpha|date=2 June 2024|title=DA declares coalition team to lead talks over the next 5 years|url=https://www.ewn.co.za/2024/06/02/da-declares-coalition-team-to-lead-talks-over-the-next-5-years|access-date=2024-07-03|website=EWN|language=en}}&lt;/ref&gt; Ngokuhambisana [[2024 South African government formation|nesivumelwano sokusebenzisana]] esifinyelelwe hlangana ne-DA ne-ANC, uMongameli [[Cyril Ramaphosa|u-Cyril Ramaphosa]] wamkhetha njengoNgqongqotjhe [[Minister of Basic Education|wezeFundo eSisekelo]] . &lt;ref&gt;{{Cite news|date=2 July 2024|title=I’m itching to get stuck in – Siviwe Gwarube ready to start tenure as basic education minister|url=https://www.sowetanlive.co.za/news/south-africa/2024-07-02-im-itching-to-get-stuck-in-whats-already-on-basic-education-minister-siviwe-gwarubes-in-tray/#google_vignette|access-date=3 July 2024|work=The Sowetan}}&lt;/ref&gt; U [[Reginah Mhaule|-Reginah Mhaule]] we-ANC wakhethwa njengesekela lakhe. &lt;ref&gt;{{Cite web|last=Ramaphosa|first=Cyril|date=30 June 2024|title=Working together to 'serve the people': Ramaphosa names new Cabinet|url=https://www.news24.com/news24/southafrica/news/read-in-full-working-together-to-serve-the-people-ramaphosa-names-new-cabinet-20240630|access-date=2024-07-03|website=News24|language=en-US}}&lt;/ref&gt; Wafungiswa esikhundleni mhlazi-3 kuNtaka 2024, &lt;ref&gt;{{Cite web|last=Ludidi|first=Velani|date=2024-07-03|title=Historic day for SA as GNU ministers sworn into office|url=https://www.dailymaverick.co.za/article/2024-07-03-historic-day-for-sa-as-government-of-national-unity-ministers-take-oath-of-office/|access-date=2024-07-16|website=Daily Maverick|language=en}}&lt;/ref&gt; begodu [[George Michalakis|u-George Michalakis]] wathatha isikhundla sakhe njengesihluthu esikhulu se-DA.

'''UMTHOMBO-LWAZI'''</text>
      <sha1>e3bkgft4lpywi81a3xc24809y8mge7f</sha1>
    </revision>
    <revision>
      <id>5614</id>
      <parentid>5607</parentid>
      <timestamp>2025-09-04T10:39:10Z</timestamp>
      <contributor>
        <username>Nabungela</username>
        <id>885</id>
      </contributor>
      <comment>added picture</comment>
      <origin>5614</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="18163" sha1="i729mw17wii10uv8w5gfbp928zmwgoa" xml:space="preserve">Page 1: Draft space 1
[[Isimumathi:Siviwe Gwarube 2024.jpg|thumb|Isithombe saka Siviwe Gwarube]]

'''&lt;big&gt;SIVIWE GWARUBE&lt;/big&gt;'''
U- '''Siviwe Gwarube''' (wabelethwa mhlana ali-14 kuNtaka 1989) usopolotiki [[Isewula Afrika|weSewula Afrika]] osebenza njengoNgqongqotjhe [[Minister of Basic Education|wezeFundo yeSisekelo]] kuRhulumende [[Third Cabinet of Cyril Ramaphosa|weBumbano leNarha]] (i-GNU) kusukela ngoNtaka 2024. Ulilunga le- [[Democratic Alliance (South Africa)|Democratic Alliance]] (DA), bekayilunga le-Democratic Alliance (DA), bekayi [[National Assembly of South Africa|-Chief Whip ye-Official Opposition]] hlangana kwakaRhoboyi 2020 ukuya kuRhoboyi 24. Wajoyina i [[National Assembly of South Africa|-National. I-Assembly yeSewula Afrika]] kukhetho [[2019 South African general election|lukaMeyi 2019]]

U- '''Siviwe Gwarube''' (wabelethwa mhlana ali-14 kuNtaka 1989) usopolotiki [[Isewula Afrika|weSewula Afrika]] osebenza njengoNgqongqotjhe [[Minister of Basic Education|wezeFundo yeSisekelo]] kuRhulumende [[Third Cabinet of Cyril Ramaphosa|weBumbano leNarha]] (i-GNU) kusukela ngoNtaka 2024. le-Democratic Alliance (DA), bekayi [[National Assembly of South Africa|-Chief Whip ye-Official Opposition]] hlangana kwakaRhoboyi 2020 ukuya kuRhoboyi 24. Wajoyina i [[National Assembly of South Africa|-National. I-Assembly yeSewula Afrika]] kukhetho [[2019 South African general election|lukaMeyi 2019]]

Wabelethelwa e [[Eastern Cape|-Eastern Cape]], u-Gwarube wangena kwezepolotiki ngo-2012 njengomkhulumeli womrholi wepalamende we-DA [[Lindiwe Mazibuko|u-Lindiwe Mazibuko]] . Ngesikhathi [[27th South African Parliament|sePalamende yesiThupha]], ngaphambi kokukhethwa njengoMphathiswa we-DA, wasebenza njengoNgqongqotjhe [[Official Opposition Shadow Cabinet (South Africa)|wezamaPhilo]] kusukela ngoMgwengweni 2019 ukuya kuMhlolanja 2022, umkhulumeli wezwe loke we [[Minister of Health (South Africa)|-]] DA kusukela ngoNobayeni 2020 ukuya kuRhoboyi 2022, kanye noSekela loMphathiswa kusukela ngoNobayeni 2021 ukuya kuRhoboyi 2022.

'''Ipilo yokuthoma nomsebenzi'''

U-Gwarube wabelethwa mhlana ali-14 kuNtaka 1989, &lt;ref name=&quot;:122&quot;&gt;{{Cite web|date=10 April 2024|title=Final Candidate Lists for 2024 National and Provincial Elections: National Candidates|url=https://www.elections.org.za/pw/Documents/Candidates-List-NPE2024/National%20Candidates%20List.pdf|access-date=2024-03-26|website=Electoral Commission of South Africa}}&lt;/ref&gt; uGwarube wakhulela e-KwaMdingi, idolobhana elingaphandle [[King William's Town|kweDorobha le-King William]] e- [[Cape Province]] . &lt;ref name=&quot;:02&quot;&gt;{{Cite web|last=Felix|first=Jason|date=10 September 2022|title=Leading the pack: Siviwe Gwarube stands tall at helm of DA's charge in Parliament|url=https://www.news24.com/news24/opinions/analysis/saturday-profile-leading-the-pack-siviwe-gwarube-stands-tall-at-helm-of-das-charge-in-parliament-20220910|access-date=2024-07-03|website=News24|language=en-US}}&lt;/ref&gt; Wakhuliswa ngugogo wakhe, obekangutitjhere ongakatjhadi. &lt;ref name=&quot;:1&quot;&gt;{{Cite web|last=Huisman|first=Biénne|date=2019-11-18|title=Face to face with shadow health minister Siviwe Gwarube|url=https://www.dailymaverick.co.za/article/2019-11-19-face-to-face-with-shadow-health-minister-siviwe-gwarube/|access-date=2024-07-03|website=Daily Maverick|language=en}}&lt;/ref&gt; Ngemva kokuphothula e-Kingsridge High School for Girls e-King William's Town, wafunda umthetho, ipolotiki, kanye nefilosofi e- [[Rhodes University]] e- [[Grahamstown]] . Waphothula nge-Bachelor of Arts ngo-2012

Ngomnyaka wakhe wokugcina njengomfundi, u-Gwarube waqatjhwa ehlelweni labadosiphambili abatjha [[Democratic Alliance (South Africa)|be-Democratic Alliance]] (DA). &lt;ref name=&quot;:12&quot;&gt;{{Cite web|last=Huisman|first=Biénne|date=2019-11-18|title=Face to face with shadow health minister Siviwe Gwarube|url=https://www.dailymaverick.co.za/article/2019-11-19-face-to-face-with-shadow-health-minister-siviwe-gwarube/|access-date=2024-07-03|website=Daily Maverick|language=en}}&lt;/ref&gt; Ehlelweni wahlangana no [[Lindiwe Mazibuko|-Lindiwe Mazibuko]], [[Leader of the Opposition (South Africa)|uMdosiphambili wePhikisako]], owaba mfundisi wakhe. &lt;ref&gt;{{Cite news|date=21 August 2022|title=‘I am nobody’s experiment,’ says DA’s new chief whip|url=https://www.timeslive.co.za/sunday-times/news/politics/2022-08-21-i-am-nobodys-experiment-says-das-new-chief-whip/|access-date=3 July 2024|work=Sunday Times}}&lt;/ref&gt; NgoTjhirhweni 2012, ngemva nje kokuphothula, uGwarube wathuthela [[Cape Town|eKapa]] ukuyokuthoma umsebenzi njengomkhulumeli ehhovisini lakaMazibuko. &lt;ref name=&quot;:12&quot; /&gt; Ngemva kwalokho wathuthela emNyangweni [[Western Cape Department of Health|wezamaPhilo we-Western Cape]], lapho bekayisikhulumeli nomphathi weNgqongqotjhe ngaphasi kwakaNgqongqotjhe wePhrovinsi [[Nomafrench Mbombo|uNomafrench Mbombo]] . Ngaphambi [[2019 South African general election|kokhetho luka-2019]], bekangumnqophisi omkhulu wezokuthintana we-DA

'''Umsebenzi wezepolotiki'''

'''I-DA caucus: 2019–2024'''

Ngokhetho lukaMeyi 2019, u-Gwarube wakhethwa bona ajamele i-DA e- [[National Assembly of South Africa|National Assembly]], indlu ephasi yePalamende [[South African Parliament|yeSewula Afrika]] . Wabekwa godu njengoNgqongqotjhe [[Official Opposition Shadow Cabinet (South Africa)|wezamaPhilo]] [[Shadow Cabinet of Mmusi Maimane|ekhabhinethi yomdosiphambili]] we-DA u [[Minister of Health (South Africa)|-]] [[Musi Maimane|Mmusi Maimane]], u [[Lindy Wilson|-Lindy Wilson]] abe msekeli wakhe. &lt;ref&gt;{{cite news|last1=Nkanjeni|first1=Unathi|date=6 June 2019|title=DA shadow cabinet: What you need to know|url=https://www.timeslive.co.za/politics/2019-06-06-da-shadow-cabinet-what-you-need-to-know/|accessdate=8 April 2020|newspaper=Sunday Times}}&lt;/ref&gt; &lt;ref&gt;{{cite news|last1=Gerber|first1=Jan|date=5 June 2019|title=Here's the DA's 'shadow cabinet'|url=https://www.news24.com/SouthAfrica/News/heres-the-das-shadow-cabinet-20190605|accessdate=8 April 2020|newspaper=News24}}&lt;/ref&gt; Wagcina isikhundla leso [[Shadow Cabinet of John Steenhuisen|ekhabhinethi yesithunzi]] yomlandeli ka-Maimane, [[John Steenhuisen|u-John Steenhuisen]] . &lt;ref&gt;{{Cite news|last=Mazzone|first=Natasha|date=5 December 2020|title=DA announces new Shadow Cabinet that will bring Real Hope and Real Change|url=https://www.da.org.za/2020/12/da-announces-new-shadow-cabinet-that-will-bring-real-hope-and-real-change|access-date=5 December 2020|work=Democratic Alliance}}&lt;/ref&gt; Isikhathi sakhe emkhakheni wezamaphilo sahlangana nobhubhane [[COVID-19 pandemic in South Africa|lwe-COVID-19]], kanye [[Zweli Mkhize#Digital Vibes scandal|nehlazo le-Digital Vibes]] eliphathelene nekohlakalo emNyangweni [[Department of Health (South Africa)|wezamaPhilo]] ; &lt;ref name=&quot;:03&quot;&gt;{{Cite web|last=Felix|first=Jason|date=10 September 2022|title=Leading the pack: Siviwe Gwarube stands tall at helm of DA's charge in Parliament|url=https://www.news24.com/news24/opinions/analysis/saturday-profile-leading-the-pack-siviwe-gwarube-stands-tall-at-helm-of-das-charge-in-parliament-20220910|access-date=2024-07-03|website=News24|language=en-US}}&lt;/ref&gt; malungana nokugcina, u-Gwarube wabeka amacala wobulelesi kuNgqongqotjhe wezamaPhilo [[Zweli Mkhize|u-Zweli Mkhize]].

Ngokhetho lukaMeyi 2019, u-Gwarube wakhethwa bona ajamele i-DA e- National Assembly, indlu ephasi yePalamende [[South African Parliament|yeSewula Afrika]] . Wabekwa godu njengoNgqongqotjhe [[Official Opposition Shadow Cabinet (South Africa)|wezamaPhilo]] [[Shadow Cabinet of Mmusi Maimane|ekhabhinethi yomdosiphambili]] we-DA u [[Minister of Health (South Africa)|-]] [[Musi Maimane|Mmusi Maimane]], u [[Lindy Wilson|-Lindy Wilson]] abe msekeli wakhe. &lt;ref&gt;{{cite news|last1=Nkanjeni|first1=Unathi|date=6 June 2019|title=DA shadow cabinet: What you need to know|url=https://www.timeslive.co.za/politics/2019-06-06-da-shadow-cabinet-what-you-need-to-know/|accessdate=8 April 2020|newspaper=Sunday Times}}&lt;/ref&gt; &lt;ref&gt;{{cite news|last1=Gerber|first1=Jan|date=5 June 2019|title=Here's the DA's 'shadow cabinet'|url=https://www.news24.com/SouthAfrica/News/heres-the-das-shadow-cabinet-20190605|accessdate=8 April 2020|newspaper=News24}}&lt;/ref&gt; Wagcina isikhundla leso [[Shadow Cabinet of John Steenhuisen|ekhabhinethi yesithunzi]] yomlandeli ka-Maimane, [[John Steenhuisen|u-John Steenhuisen]] . &lt;ref&gt;{{Cite news|last=Mazzone|first=Natasha|date=5 December 2020|title=DA announces new Shadow Cabinet that will bring Real Hope and Real Change|url=https://www.da.org.za/2020/12/da-announces-new-shadow-cabinet-that-will-bring-real-hope-and-real-change|access-date=5 December 2020|work=Democratic Alliance}}&lt;/ref&gt; Isikhathi sakhe emkhakheni wezamaphilo sahlangana nobhubhane [[COVID-19 pandemic in South Africa|lwe-COVID-19]], kanye [[Zweli Mkhize#Digital Vibes scandal|nehlazo le-Digital Vibes]] eliphathelene nekohlakalo emNyangweni [[Department of Health (South Africa)|wezamaPhilo]] ; &lt;ref name=&quot;:04&quot;&gt;{{Cite web|last=Felix|first=Jason|date=10 September 2022|title=Leading the pack: Siviwe Gwarube stands tall at helm of DA's charge in Parliament|url=https://www.news24.com/news24/opinions/analysis/saturday-profile-leading-the-pack-siviwe-gwarube-stands-tall-at-helm-of-das-charge-in-parliament-20220910|access-date=2024-07-03|website=News24|language=en-US}}&lt;/ref&gt; malungana nokugcina, u-Gwarube wabeka amacala wobulelesi kuNgqongqotjhe wezamaPhilo [[Zweli Mkhize|u-Zweli Mkhize.]]

Mhlana amalanga ali-18 kuRhoboyi wee-2022, u-Gwarube waphakanyiswa waba yi-chief whip ye-DA caucus e-National Assembly; umuntu ophethe isikhundla, [[Natasha Mazzone|u-Natasha Mazzone]], waxoshwa. &lt;ref&gt;{{Cite web|last=|date=18 August 2022|title=Siviwe Gwarube appointed DA's new chief whip as axe falls on Mazzone|url=https://www.sowetanlive.co.za/news/south-africa/2022-08-18-siviwe-gwarube-appointed-das-new-chief-whip-as-axe-falls-on-mazzone/|access-date=2022-08-18|website=Sowetan|language=en-ZA}}&lt;/ref&gt; &lt;ref&gt;{{Cite web|title=Siviwe Gwarube appointed DA Chief Whip|url=https://www.enca.com/news/siviwe-gwarube-appointed-da-chief-whip|access-date=2022-08-18|website=eNCA|language=en}}&lt;/ref&gt; Abahlaziyi baphawule &quot;ukukhuphuka okukhulu&quot; kukaGwarube ngokusebenzisa i-caucus. &lt;ref name=&quot;:2&quot;&gt;{{Cite news|date=18 August 2022|title=Siviwe Gwarube is new DA chief whip after Natasha Mazzone is demoted|url=https://www.businesslive.co.za/bd/national/2022-08-18-siviwe-gwarube-is-new-da-chief-whip-after-natasha-mazzone-is-demoted/|access-date=3 July 2024|work=Business Day}}&lt;/ref&gt; &lt;ref&gt;{{Cite web|last=Hussain|first=Muhammad|date=24 February 2024|title=Siviwe Gwarube: DA does have deep sense of internal introspection|url=https://www.news24.com/news24/opinions/analysis/saturday-profile-siviwe-gwarube-da-does-have-deep-sense-of-internal-introspection-20240224|access-date=2024-07-03|website=News24|language=en-US}}&lt;/ref&gt; Emtlolweni wokuhlela, [[Mondli Makhanya|u-Mondli Makhanya]] we ''[[City Press (South Africa)|-City Press]]'' wathi, nanyana &quot;bekalilunga lePhalamende elikhuluma ngokuzwakalako, elizithembako nomkhulumeli wehlangano ongeze waphuthelwa lilizwi lakhe&quot;, u-Gwarube wahlala anganalwazi; wamxwayisa bona aqaphele &quot;ukubekwa bona ahluleke&quot;. &lt;ref&gt;{{Cite web|date=21 August 2022|title=Editorial: Allow Gwarube to lead|url=https://www.news24.com/citypress/voices/editorial-allow-gwarube-to-lead-20220821|access-date=2024-07-03|website=City Press|language=en-US}}&lt;/ref&gt; U-Gwarube, nanyana kunjalo, wathi bekakulungele ukudlala indima leyo begodu bekahlose &quot;ukukhamba endaweni le ngendlela eqinisekileko&quot;. &lt;ref&gt;{{Cite news|date=27 August 2022|title=New DA whip says she’s tough enough for the job|url=https://www.iol.co.za/weekend-argus/news/new-da-whip-says-shes-tough-enough-for-the-job-a73d0080-4018-42b9-b541-71828a282caa|access-date=3 July 2024|work=Weekend Argus}}&lt;/ref&gt; [[Cilliers Brink|U-Cilliers Brink]] no-Solly Malatsi bakhethwa bona bathathe imisebenzi yakhe njengomkhulumeli we-DA.

'''UNgqongqotjhe wezefundo ezisisekelo: 2024-nje'''

U-Gwarube wakhethwa godu esihlalweni sakhe sepalamende [[2024 South African general election|ngokhetho lukaMeyi 2024]], begodu bekalilunga lesiqhema samalunga amane ebesimele i-DA ngesikhathi seengcoco ezilandelako zokubambisana ne- African National Congress (ANC). &lt;ref&gt;{{Cite web|last=Ramushwana|first=Alpha|date=2 June 2024|title=DA declares coalition team to lead talks over the next 5 years|url=https://www.ewn.co.za/2024/06/02/da-declares-coalition-team-to-lead-talks-over-the-next-5-years|access-date=2024-07-03|website=EWN|language=en}}&lt;/ref&gt; Ngokuhambisana [[2024 South African government formation|nesivumelwano sokusebenzisana]] esifinyelelwe hlangana ne-DA ne-ANC, uMongameli [[Cyril Ramaphosa|u-Cyril Ramaphosa]] wamkhetha njengoNgqongqotjhe [[Minister of Basic Education|wezeFundo eSisekelo]] . &lt;ref&gt;{{Cite news|date=2 July 2024|title=I’m itching to get stuck in – Siviwe Gwarube ready to start tenure as basic education minister|url=https://www.sowetanlive.co.za/news/south-africa/2024-07-02-im-itching-to-get-stuck-in-whats-already-on-basic-education-minister-siviwe-gwarubes-in-tray/#google_vignette|access-date=3 July 2024|work=The Sowetan}}&lt;/ref&gt; U [[Reginah Mhaule|-Reginah Mhaule]] we-ANC wakhethwa njengesekela lakhe. &lt;ref&gt;{{Cite web|last=Ramaphosa|first=Cyril|date=30 June 2024|title=Working together to 'serve the people': Ramaphosa names new Cabinet|url=https://www.news24.com/news24/southafrica/news/read-in-full-working-together-to-serve-the-people-ramaphosa-names-new-cabinet-20240630|access-date=2024-07-03|website=News24|language=en-US}}&lt;/ref&gt; Wafungiswa esikhundleni mhlazi-3 kuNtaka 2024, &lt;ref&gt;{{Cite web|last=Ludidi|first=Velani|date=2024-07-03|title=Historic day for SA as GNU ministers sworn into office|url=https://www.dailymaverick.co.za/article/2024-07-03-historic-day-for-sa-as-government-of-national-unity-ministers-take-oath-of-office/|access-date=2024-07-16|website=Daily Maverick|language=en}}&lt;/ref&gt; begodu [[George Michalakis|u-George Michalakis]] wathatha isikhundla sakhe njengesihluthu esikhulu se-DA.

U-Gwarube wakhethwa godu esihlalweni sakhe sepalamende [[2024 South African general election|ngokhetho lukaMeyi 2024]], begodu bekalilunga lesiqhema samalunga amane ebesimele i-DA ngesikhathi seengcoco ezilandelako zokubambisana ne- [[African National Congress]] (ANC). &lt;ref&gt;{{Cite web|last=Ramushwana|first=Alpha|date=2 June 2024|title=DA declares coalition team to lead talks over the next 5 years|url=https://www.ewn.co.za/2024/06/02/da-declares-coalition-team-to-lead-talks-over-the-next-5-years|access-date=2024-07-03|website=EWN|language=en}}&lt;/ref&gt; Ngokuhambisana [[2024 South African government formation|nesivumelwano sokusebenzisana]] esifinyelelwe hlangana ne-DA ne-ANC, uMongameli [[Cyril Ramaphosa|u-Cyril Ramaphosa]] wamkhetha njengoNgqongqotjhe [[Minister of Basic Education|wezeFundo eSisekelo]] . &lt;ref&gt;{{Cite news|date=2 July 2024|title=I’m itching to get stuck in – Siviwe Gwarube ready to start tenure as basic education minister|url=https://www.sowetanlive.co.za/news/south-africa/2024-07-02-im-itching-to-get-stuck-in-whats-already-on-basic-education-minister-siviwe-gwarubes-in-tray/#google_vignette|access-date=3 July 2024|work=The Sowetan}}&lt;/ref&gt; U [[Reginah Mhaule|-Reginah Mhaule]] we-ANC wakhethwa njengesekela lakhe. &lt;ref&gt;{{Cite web|last=Ramaphosa|first=Cyril|date=30 June 2024|title=Working together to 'serve the people': Ramaphosa names new Cabinet|url=https://www.news24.com/news24/southafrica/news/read-in-full-working-together-to-serve-the-people-ramaphosa-names-new-cabinet-20240630|access-date=2024-07-03|website=News24|language=en-US}}&lt;/ref&gt; Wafungiswa esikhundleni mhlazi-3 kuNtaka 2024, &lt;ref&gt;{{Cite web|last=Ludidi|first=Velani|date=2024-07-03|title=Historic day for SA as GNU ministers sworn into office|url=https://www.dailymaverick.co.za/article/2024-07-03-historic-day-for-sa-as-government-of-national-unity-ministers-take-oath-of-office/|access-date=2024-07-16|website=Daily Maverick|language=en}}&lt;/ref&gt; begodu [[George Michalakis|u-George Michalakis]] wathatha isikhundla sakhe njengesihluthu esikhulu se-DA.

U-Gwarube wakhethwa godu esihlalweni sakhe sepalamende [[2024 South African general election|ngokhetho lukaMeyi 2024]], begodu bekalilunga lesiqhema samalunga amane ebesimele i-DA ngesikhathi seengcoco ezilandelako zokubambisana ne- [[African National Congress]] (ANC). &lt;ref&gt;{{Cite web|last=Ramushwana|first=Alpha|date=2 June 2024|title=DA declares coalition team to lead talks over the next 5 years|url=https://www.ewn.co.za/2024/06/02/da-declares-coalition-team-to-lead-talks-over-the-next-5-years|access-date=2024-07-03|website=EWN|language=en}}&lt;/ref&gt; Ngokuhambisana [[2024 South African government formation|nesivumelwano sokusebenzisana]] esifinyelelwe hlangana ne-DA ne-ANC, uMongameli [[Cyril Ramaphosa|u-Cyril Ramaphosa]] wamkhetha njengoNgqongqotjhe [[Minister of Basic Education|wezeFundo eSisekelo]] . &lt;ref&gt;{{Cite news|date=2 July 2024|title=I’m itching to get stuck in – Siviwe Gwarube ready to start tenure as basic education minister|url=https://www.sowetanlive.co.za/news/south-africa/2024-07-02-im-itching-to-get-stuck-in-whats-already-on-basic-education-minister-siviwe-gwarubes-in-tray/#google_vignette|access-date=3 July 2024|work=The Sowetan}}&lt;/ref&gt; U [[Reginah Mhaule|-Reginah Mhaule]] we-ANC wakhethwa njengesekela lakhe. &lt;ref&gt;{{Cite web|last=Ramaphosa|first=Cyril|date=30 June 2024|title=Working together to 'serve the people': Ramaphosa names new Cabinet|url=https://www.news24.com/news24/southafrica/news/read-in-full-working-together-to-serve-the-people-ramaphosa-names-new-cabinet-20240630|access-date=2024-07-03|website=News24|language=en-US}}&lt;/ref&gt; Wafungiswa esikhundleni mhlazi-3 kuNtaka 2024, &lt;ref&gt;{{Cite web|last=Ludidi|first=Velani|date=2024-07-03|title=Historic day for SA as GNU ministers sworn into office|url=https://www.dailymaverick.co.za/article/2024-07-03-historic-day-for-sa-as-government-of-national-unity-ministers-take-oath-of-office/|access-date=2024-07-16|website=Daily Maverick|language=en}}&lt;/ref&gt; begodu [[George Michalakis|u-George Michalakis]] wathatha isikhundla sakhe njengesihluthu esikhulu se-DA.

'''UMTHOMBO-LWAZI'''</text>
      <sha1>i729mw17wii10uv8w5gfbp928zmwgoa</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Imkabini/Page 2</title>
    <ns>2</ns>
    <id>866</id>
    <revision>
      <id>5369</id>
      <timestamp>2025-09-03T10:22:57Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <comment>created a page</comment>
      <origin>5369</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="33" sha1="sqz5z572qzugwnpzmu388rp7w4g7c9n" xml:space="preserve">== '''Page 2: Draft space 2''' ==</text>
      <sha1>sqz5z572qzugwnpzmu388rp7w4g7c9n</sha1>
    </revision>
    <revision>
      <id>5600</id>
      <parentid>5369</parentid>
      <timestamp>2025-09-04T10:18:10Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <origin>5600</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1187" sha1="ewchmsg3xgllwdu9kwhq6yewi28xpg4" xml:space="preserve">== '''Page 2: Draft space 2''' ==

== Umsuka womlambo ==
[[Isimumathi:Olifants River ... - 50620204322.jpg|thumb]]
Umlambo i-Olifants uthoma phakathi kweendawo i-Breyten ne-Bethal, [[Isifunda seMpumalanga|esifundeni se-Mpumalanga]].  Umlambo lo ugelezela tjhuba langetlhagwini ukuya e[[Limpopo|sifundeni seLimpopo]] ngokudlula e-Witbank Dam&lt;ref&gt;[https://www.mpumalanga.com/press-media/blog/a-record-breaking-dam A Record Breaking Dam - Mpumalanga]&lt;/ref&gt;, begodu idlule nase Loskop Dam. Kusukela lapho, ikatelelwa ziintaba ze Transvaal Drankensberg bonyana itjhinge ngepumalanga yeLimpopo. Sele useLimpopo, udlula e-Abel Erasmus Pass bese ugelezela ngepumalanga uyokudlula i-Lowveld (esehleni) lapha uyokuhlangana khona nomlambo i-Letaba. Nawusuka lapho, umlambo lo ukhamba utjhinge esifundeni se-Gaza, [[Mozambique|ese-Mozambique]]. ngemva kokuba namajikajika ngonobangela weentaba ze-Lebombo ngendlela ye-Olifants Gorge. Lapha ke, umlambo lo sewubizwa ngokuthi yi ''-Rio dos Elefantes'', ngelimi lesi Portuguese.  Ekugcineni kwayo ihlangana nomlambo i-Limpopo eselelwe makhilomitha ama-40km bonyana ingene elwandle i-Indian Ocean e-Xai-Xai etlhagwini ye-Maputo.








*
&lt;references /&gt;</text>
      <sha1>ewchmsg3xgllwdu9kwhq6yewi28xpg4</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Londiwe23/Page 2</title>
    <ns>2</ns>
    <id>867</id>
    <revision>
      <id>5370</id>
      <timestamp>2025-09-03T10:22:57Z</timestamp>
      <contributor>
        <username>Londiwe23</username>
        <id>902</id>
      </contributor>
      <comment>created sub-page 2</comment>
      <origin>5370</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="21" sha1="sj5j4tpbq6u91cwhumtp8yadvek3tbg" xml:space="preserve">Page 2: Draft space 2</text>
      <sha1>sj5j4tpbq6u91cwhumtp8yadvek3tbg</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Xikombiso1/Page 3</title>
    <ns>2</ns>
    <id>868</id>
    <revision>
      <id>5371</id>
      <timestamp>2025-09-03T10:22:59Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <comment>created sub-page 3</comment>
      <origin>5371</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="20" sha1="sqnyoolrno5g7woykpaocbxsm5l48zx" xml:space="preserve">Page 3: Draft page 3</text>
      <sha1>sqnyoolrno5g7woykpaocbxsm5l48zx</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:ThokozaniSlaki/Page 3</title>
    <ns>2</ns>
    <id>869</id>
    <revision>
      <id>5372</id>
      <timestamp>2025-09-03T10:22:59Z</timestamp>
      <contributor>
        <username>ThokozaniSlaki</username>
        <id>842</id>
      </contributor>
      <comment>I have created sub page 3</comment>
      <origin>5372</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="20" sha1="sqnyoolrno5g7woykpaocbxsm5l48zx" xml:space="preserve">Page 3: Draft page 3</text>
      <sha1>sqnyoolrno5g7woykpaocbxsm5l48zx</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:ThembekileSihle29/Page 2</title>
    <ns>2</ns>
    <id>870</id>
    <revision>
      <id>5373</id>
      <timestamp>2025-09-03T10:23:01Z</timestamp>
      <contributor>
        <username>ThembekileSihle29</username>
        <id>887</id>
      </contributor>
      <comment>I have created sub page 2</comment>
      <origin>5373</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="22" sha1="1tz9p5gquaxygsqcs958zscgjzwrdmf" xml:space="preserve">Page 2: I draft page 2</text>
      <sha1>1tz9p5gquaxygsqcs958zscgjzwrdmf</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Mtsweni S/Page 3</title>
    <ns>2</ns>
    <id>871</id>
    <revision>
      <id>5374</id>
      <timestamp>2025-09-03T10:23:01Z</timestamp>
      <contributor>
        <username>Mtsweni S</username>
        <id>835</id>
      </contributor>
      <comment>created sub page 3</comment>
      <origin>5374</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="19" sha1="mpxldueffkg1dqiti9d649bndasb6ls" xml:space="preserve">Page 3 Draft page 3</text>
      <sha1>mpxldueffkg1dqiti9d649bndasb6ls</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Mbonani JayJay/Page 3</title>
    <ns>2</ns>
    <id>872</id>
    <revision>
      <id>5375</id>
      <timestamp>2025-09-03T10:23:01Z</timestamp>
      <contributor>
        <username>Mbonani JayJay</username>
        <id>892</id>
      </contributor>
      <comment>created sub-page 3</comment>
      <origin>5375</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="21" sha1="m77cqvnm3yvmr1kbewu39fhrfvnguw9" xml:space="preserve">Page 3: Draft space 3</text>
      <sha1>m77cqvnm3yvmr1kbewu39fhrfvnguw9</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:White Edits/Page 3</title>
    <ns>2</ns>
    <id>873</id>
    <revision>
      <id>5376</id>
      <timestamp>2025-09-03T10:23:06Z</timestamp>
      <contributor>
        <username>White Edits</username>
        <id>894</id>
      </contributor>
      <comment>created sub page 3</comment>
      <origin>5376</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="20" sha1="5dtj3hc39dqevetf8sesv25clbbxo86" xml:space="preserve">page 3: draft page 3</text>
      <sha1>5dtj3hc39dqevetf8sesv25clbbxo86</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Mannroy/Page 2</title>
    <ns>2</ns>
    <id>874</id>
    <revision>
      <id>5377</id>
      <timestamp>2025-09-03T10:23:07Z</timestamp>
      <contributor>
        <username>Mannroy</username>
        <id>879</id>
      </contributor>
      <comment>Created sub page 2</comment>
      <origin>5377</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="20" sha1="bd55l8qrc3tj832o91miqv75vwble9h" xml:space="preserve">Page 2: Draft page 2</text>
      <sha1>bd55l8qrc3tj832o91miqv75vwble9h</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Tarryn 29/Page 3</title>
    <ns>2</ns>
    <id>876</id>
    <revision>
      <id>5380</id>
      <timestamp>2025-09-03T10:23:58Z</timestamp>
      <contributor>
        <username>Tarryn 29</username>
        <id>886</id>
      </contributor>
      <comment>Created sub-page 3</comment>
      <origin>5380</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="21" sha1="oc28k2s6at1jmfn133ibopuuhankgkx" xml:space="preserve">Page 3: Draft Space 3</text>
      <sha1>oc28k2s6at1jmfn133ibopuuhankgkx</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Enthusiastic Lady/Page 2</title>
    <ns>2</ns>
    <id>877</id>
    <revision>
      <id>5381</id>
      <timestamp>2025-09-03T10:24:02Z</timestamp>
      <contributor>
        <username>Enthusiastic Lady</username>
        <id>899</id>
      </contributor>
      <comment>Created sup page 2</comment>
      <origin>5381</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="22" sha1="qayvdbsazii0c9b0pvu0ydrw0tekyno" xml:space="preserve">Page 2 :  Draft page 2</text>
      <sha1>qayvdbsazii0c9b0pvu0ydrw0tekyno</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Pholap/Page 1</title>
    <ns>2</ns>
    <id>878</id>
    <revision>
      <id>5382</id>
      <timestamp>2025-09-03T10:24:07Z</timestamp>
      <contributor>
        <username>Pholap</username>
        <id>883</id>
      </contributor>
      <comment>Created sub-page 1</comment>
      <origin>5382</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="21" sha1="pch87y1k6hovfegi0kuhokbawmoj8oz" xml:space="preserve">Page 1: Draft space 1</text>
      <sha1>pch87y1k6hovfegi0kuhokbawmoj8oz</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Zanokuhle14/Page 1</title>
    <ns>2</ns>
    <id>879</id>
    <revision>
      <id>5383</id>
      <timestamp>2025-09-03T10:24:08Z</timestamp>
      <contributor>
        <username>Zanokuhle14</username>
        <id>897</id>
      </contributor>
      <comment>Created sub-page1</comment>
      <origin>5383</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="21" sha1="pch87y1k6hovfegi0kuhokbawmoj8oz" xml:space="preserve">Page 1: Draft space 1</text>
      <sha1>pch87y1k6hovfegi0kuhokbawmoj8oz</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Tiny Engeline/Page 1</title>
    <ns>2</ns>
    <id>880</id>
    <revision>
      <id>5384</id>
      <timestamp>2025-09-03T10:24:08Z</timestamp>
      <contributor>
        <username>Tiny Engeline</username>
        <id>896</id>
      </contributor>
      <comment>Isihlokwana 1</comment>
      <origin>5384</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="20" sha1="5ptxk4tf151qj1zljwluqfd8ku4dlok" xml:space="preserve">Page1: Draft space 1</text>
      <sha1>5ptxk4tf151qj1zljwluqfd8ku4dlok</sha1>
    </revision>
    <revision>
      <id>5486</id>
      <parentid>5384</parentid>
      <timestamp>2025-09-04T08:51:16Z</timestamp>
      <contributor>
        <username>Tiny Engeline</username>
        <id>896</id>
      </contributor>
      <comment>Added reference 1</comment>
      <origin>5486</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="85" sha1="fgau17d0jn0e6158wtwcnde8cvte07d" xml:space="preserve">Page1: Draft space 1
 &quot;Umlando wamaNdebele&quot;. southafrica.co.za. Retrieved 2025-09-04.</text>
      <sha1>fgau17d0jn0e6158wtwcnde8cvte07d</sha1>
    </revision>
    <revision>
      <id>5487</id>
      <parentid>5486</parentid>
      <timestamp>2025-09-04T08:54:18Z</timestamp>
      <contributor>
        <username>Tiny Engeline</username>
        <id>896</id>
      </contributor>
      <comment>Added reference 1</comment>
      <origin>5487</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="163" sha1="f8dwgsthi3gjq1ttfzzu03o2mfy2ix4" xml:space="preserve">Page1: Draft space 1
 &quot;Umlando wamaNdebele&quot;. southafrica.co.za. Retrieved 2025-09-04.&lt;ref&gt;&quot;Umlando wamaNdebele&quot;. ''southafrica.co.za''. Retrieved 2025-09-04.&lt;/ref&gt;</text>
      <sha1>f8dwgsthi3gjq1ttfzzu03o2mfy2ix4</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:NASKHOSANA/Page 3</title>
    <ns>2</ns>
    <id>881</id>
    <revision>
      <id>5385</id>
      <timestamp>2025-09-03T10:24:10Z</timestamp>
      <contributor>
        <username>NASKHOSANA</username>
        <id>884</id>
      </contributor>
      <comment>created sub page 3</comment>
      <origin>5385</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="20" sha1="sqnyoolrno5g7woykpaocbxsm5l48zx" xml:space="preserve">Page 3: Draft page 3</text>
      <sha1>sqnyoolrno5g7woykpaocbxsm5l48zx</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Londiwe23/Page 3</title>
    <ns>2</ns>
    <id>882</id>
    <revision>
      <id>5386</id>
      <timestamp>2025-09-03T10:24:58Z</timestamp>
      <contributor>
        <username>Londiwe23</username>
        <id>902</id>
      </contributor>
      <comment>created sub-page3</comment>
      <origin>5386</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="20" sha1="8iyujd648w5pjts3e0sgz8yoio9kxso" xml:space="preserve">Page3: draft space 3</text>
      <sha1>8iyujd648w5pjts3e0sgz8yoio9kxso</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Nabungela/Page 2</title>
    <ns>2</ns>
    <id>883</id>
    <revision>
      <id>5387</id>
      <timestamp>2025-09-03T10:25:00Z</timestamp>
      <contributor>
        <username>Nabungela</username>
        <id>885</id>
      </contributor>
      <comment>Created sub-page 2</comment>
      <origin>5387</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="20" sha1="bd55l8qrc3tj832o91miqv75vwble9h" xml:space="preserve">Page 2: Draft page 2</text>
      <sha1>bd55l8qrc3tj832o91miqv75vwble9h</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Enthusiastic Lady/Page 3</title>
    <ns>2</ns>
    <id>884</id>
    <revision>
      <id>5388</id>
      <timestamp>2025-09-03T10:25:01Z</timestamp>
      <contributor>
        <username>Enthusiastic Lady</username>
        <id>899</id>
      </contributor>
      <comment>Created sup page 3</comment>
      <origin>5388</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="15" sha1="jyp4fakxsjp7s0hd024b3t2rkc0f536" xml:space="preserve">Draft  : Page 3</text>
      <sha1>jyp4fakxsjp7s0hd024b3t2rkc0f536</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:ThembekileSihle29/Page 3</title>
    <ns>2</ns>
    <id>885</id>
    <revision>
      <id>5389</id>
      <timestamp>2025-09-03T10:25:08Z</timestamp>
      <contributor>
        <username>ThembekileSihle29</username>
        <id>887</id>
      </contributor>
      <comment>I have created sub page 3</comment>
      <origin>5389</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="20" sha1="sqnyoolrno5g7woykpaocbxsm5l48zx" xml:space="preserve">Page 3: Draft page 3</text>
      <sha1>sqnyoolrno5g7woykpaocbxsm5l48zx</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Ghostingghost/Page 2</title>
    <ns>2</ns>
    <id>886</id>
    <revision>
      <id>5390</id>
      <timestamp>2025-09-03T10:25:12Z</timestamp>
      <contributor>
        <username>Ghostingghost</username>
        <id>890</id>
      </contributor>
      <comment>Created sub-page 2</comment>
      <origin>5390</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="21" sha1="sj5j4tpbq6u91cwhumtp8yadvek3tbg" xml:space="preserve">Page 2: Draft space 2</text>
      <sha1>sj5j4tpbq6u91cwhumtp8yadvek3tbg</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:NaMathibela/Page 2</title>
    <ns>2</ns>
    <id>887</id>
    <revision>
      <id>5391</id>
      <timestamp>2025-09-03T10:25:14Z</timestamp>
      <contributor>
        <username>NaMathibela</username>
        <id>888</id>
      </contributor>
      <comment>created sub page 2</comment>
      <origin>5391</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="22" sha1="jec4r1diwpy51g699dmw4ut5v7g3kmj" xml:space="preserve">Page 2 : Draft Space 2</text>
      <sha1>jec4r1diwpy51g699dmw4ut5v7g3kmj</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Imkabini/Page 3</title>
    <ns>2</ns>
    <id>888</id>
    <revision>
      <id>5392</id>
      <timestamp>2025-09-03T10:25:17Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <comment>created another page</comment>
      <origin>5392</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="29" sha1="he28wl5ew4w8dhnr9ez80w3oqa690hd" xml:space="preserve">=== Page 3: Draft Space 3 ===</text>
      <sha1>he28wl5ew4w8dhnr9ez80w3oqa690hd</sha1>
    </revision>
    <revision>
      <id>5612</id>
      <parentid>5392</parentid>
      <timestamp>2025-09-04T10:34:18Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <origin>5612</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1274" sha1="f4zfcqm8mn07k1eb7o1bsbo8emijvsg" xml:space="preserve">=== Page 3: Draft Space 3 ===
'''I-Japan''' lilizwe eliyisiqhingi e-East Asia. Isendaweni ye-Pacific Ocean eduze ne-northeast coast ye-Asia mainland, begodu inemngcele ngeTjingalanga ngeLwandle le-Japan begodu isuka eLwandle le-Okhotsk ngetlhagwini ukuya eLwandle le-East China ngeSewula. I-archipelago ye-Japan ineenhlengele ezine ezikulu—i-Hokkaido, i-Honshu, i-Shikoku, ne-Kyushu—kanye neenkulungwana zeenqhingi ezincani, ezihlanganisa amakhilomitha ayi-377,975 (145,937 sq mi). I-Japan inabantu abapheze babe ziingidi ezili-124 ukusukela ngo-2024, begodu yinarha yetjhumi nanye enabantu abanengi. Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-Tokyo; i-Greater Tokyo Area yindawo ekulu khulu yedorobha ephasini, enabantu abangaphezu kweengidi ezingama-38 ukusukela ngo-2016. I-Japan ihlukaniswe yaba ziindawo ezima-47 zokuphatha kanye neendawo ezibunane zesintu. Pheze amakota amathathu wendawo yenarha le ineentaba begodu inamahlathi amanengi, igxile kwezokulima kanye nabantu abahlala emadorobheni khulu emathafeni wayo asepumalanga. Inarha le ihlezi e-Pacific Ring of Fire, okwenza bona iinhlenge zayo zibe sengozini yokusikinyeka kwephasi okubhubhisako kanye nama-tsunami.

== Iinkomba ==

# &lt;nowiki&gt;https://www.britannica.com/place/Japan/History&lt;/nowiki&gt;</text>
      <sha1>f4zfcqm8mn07k1eb7o1bsbo8emijvsg</sha1>
    </revision>
    <revision>
      <id>5623</id>
      <parentid>5612</parentid>
      <timestamp>2025-09-04T10:40:51Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <origin>5623</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1493" sha1="qrjhonnm5qbuuw86defnx8o159qhube" xml:space="preserve">=== Page 3: Draft Space 3 ===
'''I-Japan''' lilizwe eliyisiqhingi e-East Asia. Isendaweni ye-Pacific Ocean eduze ne-northeast coast ye-Asia mainland, begodu inemngcele ngeTjingalanga ngeLwandle le-Japan begodu isuka eLwandle le-Okhotsk ngetlhagwini ukuya eLwandle le-East China ngeSewula. I-archipelago ye-Japan ineenhlengele ezine ezikulu—i-Hokkaido, i-Honshu, i-Shikoku, ne-Kyushu—kanye neenkulungwana zeenqhingi ezincani, ezihlanganisa amakhilomitha ayi-377,975 (145,937 sq mi). I-Japan inabantu abapheze babe ziingidi ezili-124 ukusukela ngo-2024, begodu yinarha yetjhumi nanye enabantu abanengi. Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-Tokyo; i-Greater Tokyo Area yindawo ekulu khulu yedorobha ephasini, enabantu abangaphezu kweengidi ezingama-38 ukusukela ngo-2016. I-Japan ihlukaniswe yaba ziindawo ezima-47 zokuphatha kanye neendawo ezibunane zesintu. Pheze amakota amathathu wendawo yenarha le ineentaba begodu inamahlathi amanengi, igxile kwezokulima kanye nabantu abahlala emadorobheni khulu emathafeni wayo asepumalanga. Inarha le ihlezi e-Pacific Ring of Fire, okwenza bona iinhlenge zayo zibe sengozini yokusikinyeka kwephasi okubhubhisako kanye nama-tsunami.&lt;ref&gt;{{Cite web |date=2025-09-04 |title=Japan - Shintoism, Buddhism, Samurai {{!}} Britannica |url=https://www.britannica.com/place/Japan/History |access-date=2025-09-04 |website=www.britannica.com |language=en}}&lt;/ref&gt;


== Iinkomba ==

# &lt;nowiki&gt;https://www.britannica.com/place/Japan/History&lt;/nowiki&gt;</text>
      <sha1>qrjhonnm5qbuuw86defnx8o159qhube</sha1>
    </revision>
    <revision>
      <id>5624</id>
      <parentid>5623</parentid>
      <timestamp>2025-09-04T10:41:15Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <origin>5624</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1426" sha1="277hxrgfwh1gy9nfmu2oiwf1wur81op" xml:space="preserve">=== Page 3: Draft Space 3 ===
'''I-Japan''' lilizwe eliyisiqhingi e-East Asia. Isendaweni ye-Pacific Ocean eduze ne-northeast coast ye-Asia mainland, begodu inemngcele ngeTjingalanga ngeLwandle le-Japan begodu isuka eLwandle le-Okhotsk ngetlhagwini ukuya eLwandle le-East China ngeSewula. I-archipelago ye-Japan ineenhlengele ezine ezikulu—i-Hokkaido, i-Honshu, i-Shikoku, ne-Kyushu—kanye neenkulungwana zeenqhingi ezincani, ezihlanganisa amakhilomitha ayi-377,975 (145,937 sq mi). I-Japan inabantu abapheze babe ziingidi ezili-124 ukusukela ngo-2024, begodu yinarha yetjhumi nanye enabantu abanengi. Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-Tokyo; i-Greater Tokyo Area yindawo ekulu khulu yedorobha ephasini, enabantu abangaphezu kweengidi ezingama-38 ukusukela ngo-2016. I-Japan ihlukaniswe yaba ziindawo ezima-47 zokuphatha kanye neendawo ezibunane zesintu. Pheze amakota amathathu wendawo yenarha le ineentaba begodu inamahlathi amanengi, igxile kwezokulima kanye nabantu abahlala emadorobheni khulu emathafeni wayo asepumalanga. Inarha le ihlezi e-Pacific Ring of Fire, okwenza bona iinhlenge zayo zibe sengozini yokusikinyeka kwephasi okubhubhisako kanye nama-tsunami.&lt;ref&gt;{{Cite web |date=2025-09-04 |title=Japan - Shintoism, Buddhism, Samurai {{!}} Britannica |url=https://www.britannica.com/place/Japan/History |access-date=2025-09-04 |website=www.britannica.com |language=en}}&lt;/ref&gt;


== Iinkomba ==</text>
      <sha1>277hxrgfwh1gy9nfmu2oiwf1wur81op</sha1>
    </revision>
    <revision>
      <id>5632</id>
      <parentid>5624</parentid>
      <timestamp>2025-09-04T10:46:15Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <origin>5632</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1740" sha1="ecvglk9cj50ki6s7ghlqfvg0wqnv89f" xml:space="preserve">=== Page 3: Draft Space 3 ===
'''I-Japan''' lilizwe eliyisiqhingi e-East Asia. Isendaweni ye-Pacific Ocean eduze ne-northeast coast ye-Asia mainland, begodu inemngcele ngeTjingalanga ngeLwandle le-Japan begodu isuka eLwandle le-Okhotsk ngetlhagwini ukuya eLwandle le-East China ngeSewula. I-archipelago ye-Japan ineenhlengele ezine ezikulu—i-Hokkaido, i-Honshu, i-Shikoku, ne-Kyushu—kanye neenkulungwana zeenqhingi ezincani, ezihlanganisa amakhilomitha ayi-377,975 (145,937 sq mi). I-Japan inabantu abapheze babe ziingidi ezili-124 ukusukela ngo-2024, begodu yinarha yetjhumi nanye enabantu abanengi.&lt;ref&gt;NY Post. (2025). ''Japan records nearly 1M more deaths than births in 2024 - as country's population continues to plummet''. Retrieved from &lt;nowiki&gt;https://nypost.com/2025/08/07/world-news/japan-records-nearly-1-million-more-deaths-than-births-in-2024-as-countrys-natality-continues-to-plummet/&lt;/nowiki&gt;&lt;/ref&gt; Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-Tokyo; i-Greater Tokyo Area yindawo ekulu khulu yedorobha ephasini, enabantu abangaphezu kweengidi ezingama-38 ukusukela ngo-2016. I-Japan ihlukaniswe yaba ziindawo ezima-47 zokuphatha kanye neendawo ezibunane zesintu. Pheze amakota amathathu wendawo yenarha le ineentaba begodu inamahlathi amanengi, igxile kwezokulima kanye nabantu abahlala emadorobheni khulu emathafeni wayo asepumalanga. Inarha le ihlezi e-Pacific Ring of Fire, okwenza bona iinhlenge zayo zibe sengozini yokusikinyeka kwephasi okubhubhisako kanye nama-tsunami.&lt;ref&gt;{{Cite web |date=2025-09-04 |title=Japan - Shintoism, Buddhism, Samurai {{!}} Britannica |url=https://www.britannica.com/place/Japan/History |access-date=2025-09-04 |website=www.britannica.com |language=en}}&lt;/ref&gt;


== Iinkomba ==</text>
      <sha1>ecvglk9cj50ki6s7ghlqfvg0wqnv89f</sha1>
    </revision>
    <revision>
      <id>5633</id>
      <parentid>5632</parentid>
      <timestamp>2025-09-04T10:47:15Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <origin>5633</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1975" sha1="safhip4n37mx8ioptjxe0e8gj0a793c" xml:space="preserve">=== Page 3: Draft Space 3 ===
'''I-Japan''' lilizwe eliyisiqhingi e-East Asia. Isendaweni ye-Pacific Ocean eduze ne-northeast coast ye-Asia mainland, begodu inemngcele ngeTjingalanga ngeLwandle le-Japan begodu isuka eLwandle le-Okhotsk ngetlhagwini ukuya eLwandle le-East China ngeSewula. I-archipelago ye-Japan ineenhlengele ezine ezikulu—i-Hokkaido, i-Honshu, i-Shikoku, ne-Kyushu—kanye neenkulungwana zeenqhingi ezincani, ezihlanganisa amakhilomitha ayi-377,975 (145,937 sq mi). I-Japan inabantu abapheze babe ziingidi ezili-124 ukusukela ngo-2024, begodu yinarha yetjhumi nanye enabantu abanengi.&lt;ref&gt;NY Post. (2025). ''Japan records nearly 1M more deaths than births in 2024 - as country's population continues to plummet''. Retrieved from &lt;nowiki&gt;https://nypost.com/2025/08/07/world-news/japan-records-nearly-1-million-more-deaths-than-births-in-2024-as-countrys-natality-continues-to-plummet/&lt;/nowiki&gt;&lt;/ref&gt; Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-Tokyo; i-Greater Tokyo Area yindawo ekulu khulu yedorobha ephasini, enabantu abangaphezu kweengidi ezingama-38 ukusukela ngo-2016. I-Japan ihlukaniswe yaba ziindawo ezima-47 zokuphatha kanye neendawo ezibunane zesintu. Pheze amakota amathathu wendawo yenarha le ineentaba begodu inamahlathi amanengi, igxile kwezokulima kanye nabantu abahlala emadorobheni khulu emathafeni wayo asepumalanga. Inarha le ihlezi e-Pacific Ring of Fire, okwenza bona iinhlenge zayo zibe sengozini yokusikinyeka kwephasi okubhubhisako kanye nama-tsunami.&lt;ref&gt;{{Cite web |date=2025-09-04 |title=Japan - Shintoism, Buddhism, Samurai {{!}} Britannica |url=https://www.britannica.com/place/Japan/History |access-date=2025-09-04 |website=www.britannica.com |language=en}}&lt;/ref&gt;&lt;ref&gt;The Times. (2025). ''Japan accelerating towards extinction, birthrate expert warns''. Retrieved from &lt;nowiki&gt;https://www.thetimes.co.uk/article/japan-accelerating-towards-extinction-birthrate-expert-warns-g69gs8wr6&lt;/nowiki&gt;&lt;/ref&gt;



== Iinkomba ==</text>
      <sha1>safhip4n37mx8ioptjxe0e8gj0a793c</sha1>
    </revision>
    <revision>
      <id>5637</id>
      <parentid>5633</parentid>
      <timestamp>2025-09-04T10:51:17Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <origin>5637</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1657" sha1="aex2wxbcsjz0pfb89takd7r12vqeikw" xml:space="preserve">=== Page 3: Draft Space 3 ===
'''I-Japan''' lilizwe eliyisiqhingi e-East Asia. Isendaweni ye-Pacific Ocean eduze ne-northeast coast ye-Asia mainland, begodu inemngcele ngeTjingalanga ngeLwandle le-Japan begodu isuka eLwandle le-Okhotsk ngetlhagwini ukuya eLwandle le-East China ngeSewula. I-archipelago ye-Japan ineenhlengele ezine ezikulu—i-Hokkaido, i-Honshu, i-Shikoku, ne-Kyushu—kanye neenkulungwana zeenqhingi ezincani, ezihlanganisa amakhilomitha ayi-377,975 (145,937 sq mi). I-Japan inabantu abapheze babe ziingidi ezili-124 ukusukela ngo-2024, begodu yinarha yetjhumi nanye enabantu abanengi.&lt;ref&gt;NY Post. (2025). ''Japan records nearly 1M more deaths than births in 2024 - as country's population continues to plummet''. Retrieved from &lt;nowiki&gt;https://nypost.com/2025/08/07/world-news/japan-records-nearly-1-million-more-deaths-than-births-in-2024-as-countrys-natality-continues-to-plummet/&lt;/nowiki&gt;&lt;/ref&gt; Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-Tokyo; i-Greater Tokyo Area yindawo ekulu khulu yedorobha ephasini, enabantu abangaphezu kweengidi ezingama-38 ukusukela ngo-2016. I-Japan ihlukaniswe yaba ziindawo ezima-47 zokuphatha kanye neendawo ezibunane zesintu. Pheze amakota amathathu wendawo yenarha le ineentaba begodu inamahlathi amanengi, igxile kwezokulima kanye nabantu abahlala emadorobheni khulu emathafeni wayo asepumalanga. Inarha le ihlezi e-Pacific Ring of Fire, okwenza bona iinhlenge zayo zibe sengozini yokusikinyeka kwephasi okubhubhisako kanye nama-tsunami.&lt;ref&gt;{{Cite report |url=https://doi.org/10.34051/p/2020.344 |title=Data Snapshot: U.S. Population Growth Continues to Slow Due to Fewer


== Iinkomba ==</text>
      <sha1>aex2wxbcsjz0pfb89takd7r12vqeikw</sha1>
    </revision>
    <revision>
      <id>5657</id>
      <parentid>5637</parentid>
      <timestamp>2025-09-04T11:08:35Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <origin>5657</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1523" sha1="k8fcecorbztxrl3lycnycczpjgewkkl" xml:space="preserve">=== Page 3: Draft Space 3 ===
'''I-Japan''' lilizwe eliyisiqhingi e-East Asia. Isendaweni ye-Pacific Ocean eduze ne-northeast coast ye-Asia mainland, begodu inemngcele ngeTjingalanga ngeLwandle le-Japan begodu isuka eLwandle le-Okhotsk ngetlhagwini ukuya eLwandle le-East China ngeSewula. I-archipelago ye-Japan ineenhlengele ezine ezikulu—i-Hokkaido, i-Honshu, i-Shikoku, ne-Kyushu—kanye neenkulungwana zeenqhingi ezincani, ezihlanganisa amakhilomitha ayi-377,975 (145,937 sq mi). I-Japan inabantu abapheze babe ziingidi ezili-124 ukusukela ngo-2024, begodu yinarha yetjhumi nanye enabantu abanengi.&lt;ref&gt;NY Post. (2025). ''Japan records nearly 1M more deaths than births in 2024 - as country's population continues to plummet''. Retrieved from &lt;nowiki&gt;https://nypost.com/2025/08/07/world-news/japan-records-nearly-1-million-more-deaths-than-births-in-2024-as-countrys-natality-continues-to-plummet/&lt;/nowiki&gt;&lt;/ref&gt; Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-Tokyo; i-Greater Tokyo Area yindawo ekulu khulu yedorobha ephasini, enabantu abangaphezu kweengidi ezingama-38 ukusukela ngo-2016. I-Japan ihlukaniswe yaba ziindawo ezima-47 zokuphatha kanye neendawo ezibunane zesintu. Pheze amakota amathathu wendawo yenarha le ineentaba begodu inamahlathi amanengi, igxile kwezokulima kanye nabantu abahlala emadorobheni khulu emathafeni wayo asepumalanga. Inarha le ihlezi e-Pacific Ring of Fire, okwenza bona iinhlenge zayo zibe sengozini yokusikinyeka kwephasi okubhubhisako kanye nama-tsunami.



== Iinkomba ==</text>
      <sha1>k8fcecorbztxrl3lycnycczpjgewkkl</sha1>
    </revision>
    <revision>
      <id>5659</id>
      <parentid>5657</parentid>
      <timestamp>2025-09-04T11:10:26Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <origin>5659</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1583" sha1="8h4b7sqnz3hyr97u50a30ulynaxnmzf" xml:space="preserve">=== Page 3: Draft Space 3 ===
[[Isimumathi:Horyu-ji18s3200.jpg|thumb|Isithombe se-Japan]]
'''I-Japan''' lilizwe eliyisiqhingi e-East Asia. Isendaweni ye-Pacific Ocean eduze ne-northeast coast ye-Asia mainland, begodu inemngcele ngeTjingalanga ngeLwandle le-Japan begodu isuka eLwandle le-Okhotsk ngetlhagwini ukuya eLwandle le-East China ngeSewula. I-archipelago ye-Japan ineenhlengele ezine ezikulu—i-Hokkaido, i-Honshu, i-Shikoku, ne-Kyushu—kanye neenkulungwana zeenqhingi ezincani, ezihlanganisa amakhilomitha ayi-377,975 (145,937 sq mi). I-Japan inabantu abapheze babe ziingidi ezili-124 ukusukela ngo-2024, begodu yinarha yetjhumi nanye enabantu abanengi.&lt;ref&gt;NY Post. (2025). ''Japan records nearly 1M more deaths than births in 2024 - as country's population continues to plummet''. Retrieved from &lt;nowiki&gt;https://nypost.com/2025/08/07/world-news/japan-records-nearly-1-million-more-deaths-than-births-in-2024-as-countrys-natality-continues-to-plummet/&lt;/nowiki&gt;&lt;/ref&gt; Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-Tokyo; i-Greater Tokyo Area yindawo ekulu khulu yedorobha ephasini, enabantu abangaphezu kweengidi ezingama-38 ukusukela ngo-2016. I-Japan ihlukaniswe yaba ziindawo ezima-47 zokuphatha kanye neendawo ezibunane zesintu. Pheze amakota amathathu wendawo yenarha le ineentaba begodu inamahlathi amanengi, igxile kwezokulima kanye nabantu abahlala emadorobheni khulu emathafeni wayo asepumalanga. Inarha le ihlezi e-Pacific Ring of Fire, okwenza bona iinhlenge zayo zibe sengozini yokusikinyeka kwephasi okubhubhisako kanye nama-tsunami.



== Iinkomba ==</text>
      <sha1>8h4b7sqnz3hyr97u50a30ulynaxnmzf</sha1>
    </revision>
    <revision>
      <id>5663</id>
      <parentid>5659</parentid>
      <timestamp>2025-09-04T11:14:58Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <origin>5663</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1604" sha1="t8sqsd3ps2206hwpv23ledpbw4r16jq" xml:space="preserve">=== Page 3: Draft Space 3 ===
[[Isimumathi:Horyu-ji18s3200.jpg|thumb|Isithombe se-Japan|292x292px]]
'''I-Japan''' lilizwe eliyisiqhingi e-East Asia. Isendaweni ye-Pacific Ocean eduze ne-northeast coast ye-Asia mainland, begodu inemngcele ngeTjingalanga ngeLwandle le-Japan begodu isuka eLwandle le-Okhotsk ngetlhagwini ukuya eLwandle le-East China ngeSewula. I-archipelago ye-Japan ineenhlengele ezine ezikulu—i-Hokkaido, i-Honshu, i-Shikoku, ne-Kyushu—kanye neenkulungwana zeenqhingi ezincani, ezihlanganisa amakhilomitha ayi-377,975 (145,937 sq mi). I-[[Japane|Japan]] inabantu abapheze babe ziingidi ezili-124 ukusukela ngo-2024, begodu yinarha yetjhumi nanye enabantu abanengi.&lt;ref&gt;NY Post. (2025). ''Japan records nearly 1M more deaths than births in 2024 - as country's population continues to plummet''. Retrieved from &lt;nowiki&gt;https://nypost.com/2025/08/07/world-news/japan-records-nearly-1-million-more-deaths-than-births-in-2024-as-countrys-natality-continues-to-plummet/&lt;/nowiki&gt;&lt;/ref&gt; Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-Tokyo; i-Greater Tokyo Area yindawo ekulu khulu yedorobha ephasini, enabantu abangaphezu kweengidi ezingama-38 ukusukela ngo-2016. I-Japan ihlukaniswe yaba ziindawo ezima-47 zokuphatha kanye neendawo ezibunane zesintu. Pheze amakota amathathu wendawo yenarha le ineentaba begodu inamahlathi amanengi, igxile kwezokulima kanye nabantu abahlala emadorobheni khulu emathafeni wayo asepumalanga. Inarha le ihlezi e-Pacific Ring of Fire, okwenza bona iinhlenge zayo zibe sengozini yokusikinyeka kwephasi okubhubhisako kanye nama-tsunami.



== Iinkomba ==</text>
      <sha1>t8sqsd3ps2206hwpv23ledpbw4r16jq</sha1>
    </revision>
    <revision>
      <id>5665</id>
      <parentid>5663</parentid>
      <timestamp>2025-09-04T11:16:03Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <origin>5665</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1781" sha1="gkuwu2hq86efls6m5l7fig7aqchyjsb" xml:space="preserve">=== Page 3: Draft Space 3 ===
[[Isimumathi:Horyu-ji18s3200.jpg|thumb|Isithombe se-Japan|292x292px]]
'''I-Japan''' lilizwe eliyisiqhingi e-East Asia. Isendaweni ye-Pacific Ocean eduze ne-northeast coast ye-Asia mainland, begodu inemngcele ngeTjingalanga ngeLwandle le-Japan begodu isuka eLwandle le-Okhotsk ngetlhagwini ukuya eLwandle le-East China ngeSewula. I-archipelago ye-Japan ineenhlengele ezine ezikulu—i-Hokkaido, i-Honshu, i-Shikoku, ne-Kyushu—kanye neenkulungwana zeenqhingi ezincani, ezihlanganisa amakhilomitha ayi-377,975 (145,937 sq mi). I-[[Japane|Japan]] inabantu abapheze babe ziingidi ezili-124 ukusukela ngo-2024, begodu yinarha yetjhumi nanye enabantu abanengi.&lt;ref&gt;NY Post. (2025). ''Japan records nearly 1M more deaths than births in 2024 - as country's population continues to plummet''. Retrieved from &lt;nowiki&gt;https://nypost.com/2025/08/07/world-news/japan-records-nearly-1-million-more-deaths-than-births-in-2024-as-countrys-natality-continues-to-plummet/&lt;/nowiki&gt;&lt;/ref&gt; Inhlokodolobha yayo nedorobha elikhulu kunazo zoke yi-Tokyo; i-Greater Tokyo Area yindawo ekulu khulu yedorobha ephasini, enabantu abangaphezu kweengidi ezingama-38 ukusukela ngo-2016.&lt;ref&gt;'''Japan Statistical Yearbook. (2017).''' ''Statistics Bureau of Japan''. Retrieved from &lt;nowiki&gt;https://www.stat.go.jp/english/data/nenkan/index.html&lt;/nowiki&gt;&lt;/ref&gt; I-Japan ihlukaniswe yaba ziindawo ezima-47 zokuphatha kanye neendawo ezibunane zesintu. Pheze amakota amathathu wendawo yenarha le ineentaba begodu inamahlathi amanengi, igxile kwezokulima kanye nabantu abahlala emadorobheni khulu emathafeni wayo asepumalanga. Inarha le ihlezi e-Pacific Ring of Fire, okwenza bona iinhlenge zayo zibe sengozini yokusikinyeka kwephasi okubhubhisako kanye nama-tsunami.



== Imithombo lwazi ==</text>
      <sha1>gkuwu2hq86efls6m5l7fig7aqchyjsb</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Mannroy/Page 3</title>
    <ns>2</ns>
    <id>889</id>
    <revision>
      <id>5393</id>
      <timestamp>2025-09-03T10:25:20Z</timestamp>
      <contributor>
        <username>Mannroy</username>
        <id>879</id>
      </contributor>
      <comment>Created sub page 3</comment>
      <origin>5393</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="21" sha1="m77cqvnm3yvmr1kbewu39fhrfvnguw9" xml:space="preserve">Page 3: Draft space 3</text>
      <sha1>m77cqvnm3yvmr1kbewu39fhrfvnguw9</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Zanokuhle14/Page 2</title>
    <ns>2</ns>
    <id>890</id>
    <revision>
      <id>5394</id>
      <timestamp>2025-09-03T10:26:01Z</timestamp>
      <contributor>
        <username>Zanokuhle14</username>
        <id>897</id>
      </contributor>
      <comment>Created page with &quot;Page 2: Draft space 2&quot;</comment>
      <origin>5394</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="21" sha1="sj5j4tpbq6u91cwhumtp8yadvek3tbg" xml:space="preserve">Page 2: Draft space 2</text>
      <sha1>sj5j4tpbq6u91cwhumtp8yadvek3tbg</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Nabungela/Page 3</title>
    <ns>2</ns>
    <id>891</id>
    <revision>
      <id>5395</id>
      <timestamp>2025-09-03T10:26:04Z</timestamp>
      <contributor>
        <username>Nabungela</username>
        <id>885</id>
      </contributor>
      <comment>Created sub-page 3</comment>
      <origin>5395</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="20" sha1="sqnyoolrno5g7woykpaocbxsm5l48zx" xml:space="preserve">Page 3: Draft page 3</text>
      <sha1>sqnyoolrno5g7woykpaocbxsm5l48zx</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:NaMathibela/Page 3</title>
    <ns>2</ns>
    <id>892</id>
    <revision>
      <id>5396</id>
      <timestamp>2025-09-03T10:26:07Z</timestamp>
      <contributor>
        <username>NaMathibela</username>
        <id>888</id>
      </contributor>
      <comment>created sub page 3</comment>
      <origin>5396</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="22" sha1="fqw0lgqww2p7yof9bc53v0bqgkjv3cw" xml:space="preserve">Page 3  : Draft Page 3</text>
      <sha1>fqw0lgqww2p7yof9bc53v0bqgkjv3cw</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Zanokuhle14/Page 3</title>
    <ns>2</ns>
    <id>893</id>
    <revision>
      <id>5398</id>
      <timestamp>2025-09-03T10:27:21Z</timestamp>
      <contributor>
        <username>Zanokuhle14</username>
        <id>897</id>
      </contributor>
      <comment>Created page with &quot;Page 3 draft: Space3&quot;</comment>
      <origin>5398</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="20" sha1="4j788uexapck8s3ac636domo8tkd0og" xml:space="preserve">Page 3 draft: Space3</text>
      <sha1>4j788uexapck8s3ac636domo8tkd0og</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Tiny Engeline/Page2</title>
    <ns>2</ns>
    <id>894</id>
    <revision>
      <id>5399</id>
      <timestamp>2025-09-03T10:36:46Z</timestamp>
      <contributor>
        <username>Tiny Engeline</username>
        <id>896</id>
      </contributor>
      <comment>Created page with &quot;Draft 2:&quot;</comment>
      <origin>5399</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8" sha1="6ym9fl5b3akrw129nez7aobm1vdd054" xml:space="preserve">Draft 2:</text>
      <sha1>6ym9fl5b3akrw129nez7aobm1vdd054</sha1>
    </revision>
    <revision>
      <id>5400</id>
      <parentid>5399</parentid>
      <timestamp>2025-09-03T10:37:31Z</timestamp>
      <contributor>
        <username>Tiny Engeline</username>
        <id>896</id>
      </contributor>
      <origin>5400</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="15" sha1="swsjn7yoostg0651rtfdt4y3qk3cgl6" xml:space="preserve">Draft 2: page 2</text>
      <sha1>swsjn7yoostg0651rtfdt4y3qk3cgl6</sha1>
    </revision>
    <revision>
      <id>5528</id>
      <parentid>5400</parentid>
      <timestamp>2025-09-04T09:24:56Z</timestamp>
      <contributor>
        <username>Tiny Engeline</username>
        <id>896</id>
      </contributor>
      <comment>Created draft of Nzunza</comment>
      <origin>5528</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1634" sha1="4c18hecshp98tpwo7oi1z6ngtviv52y" xml:space="preserve">Draft 2: page 2




Buka imisebenzi.Mmangaliso Nzuza, Indoda engakaze ilele, 2023

Indoda engakaze ilale, 2023

Abelana

U-Mmangaliso Nzuza (wabelethwa ngo-1998) mdwebi ohlala begodu usebenza e-Cape Town, eSewula Afrika.

U-Nzuza ufumana umfutho emlandwini wakhe kanye namasiko adumileko. Uyaziwa ngokubunjwa kwakhe okuphefumulelwe yi-cubism, isitayela sakhe sibonakala ngokusebenzisa kwakhe upende wamafutha we-impasto kanye nokudweba okuqinileko. Uvame ukuveza iinhloko zakhe zisebujameni bokuzicabangela nokuzindla, asebenzisa umbala nokwakheka ukudlulisa umqondo wokujula nokuhlangahlangana.

Ngokudzimelela emidwebeni emikhulu yamafutha, uNzuza wakha ilimi elihlukileko lokuveza iinhloko zakhe. Isenzo sokuveza umfanekiso siba sifundo sokuveza umlingiswa ocatshangelwako; ukuthungwa kwangaphakathi, ama-swathes wepende, kanye nemigqa ekhululekileko yenza ifomu nomuzwa ocacileko. Iinthombe zaka-Nzuza, ngamathoni wazo athambileko nokuzibonakalisa, ziduma ngamandla wokunyakaza aqakathekileko.

&quot;Umqondo wokuma nokuthuthuka kwengqondo mmongo ophindaphindwako emsebenzini wami begodu kimi, ukwakheka kwemifanekiso yami yindlela yokuveza ubuntu bomuntu. Lokhu kuyinto eqakathekileko emkhubeni wami ngemidwebo yamafutha etjengisa ikareko yami ngobujamo bomuntu.&quot;

U-Nzuza uhlanganyele emibukisweni yamaqembu efakahlangana i-RE-KNEW-ED e-The Gallery Society e-Edinburgh kanye ne-Sasol New Signatures: Art Beyond Imagination ebanjelwe e-Pretoria Art Museum e-South Africa. Ube neenkulumo ezithengiswa khulu e-Cape Town Art Fair kanye ne-1-54 New York, begodu uzokutjengiswa e-Enter Art Fair ne-1-54 London engcenyeni yokugcina ka-2023.</text>
      <sha1>4c18hecshp98tpwo7oi1z6ngtviv52y</sha1>
    </revision>
    <revision>
      <id>5594</id>
      <parentid>5528</parentid>
      <timestamp>2025-09-04T10:08:25Z</timestamp>
      <contributor>
        <username>Tiny Engeline</username>
        <id>896</id>
      </contributor>
      <comment>Nzunza</comment>
      <origin>5594</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1655" sha1="4rcir006t0zmxhh38wpgpsdmb42hslc" xml:space="preserve">Draft 2: page 2





Qala imisebenzi kaMmangaliso Nzuza, Indoda engazange ilale, 2023

Indoda engazange ilale, 2023

Abelana

UMmangaliso Nzuza wabelethwa ngo-1998 ngunogwala ohlala begodu osebenza e-Cape Town, eSewula Afrika.

UNzuza ufumana umfutho emlandwini wakhe kanye namasiko adumileko. Uyaziwa ngokubunjwa kwakhe okuphefumulelwe yi-cubism, isitayela sakhe sibonakala ngokusebenzisa kwakhe ipende yamafutha we-impasto kanye nokugwala okuqinileko. Uvame ukuveza iinhloko zakhe zisebujameni bokuzicabangela nokuzindla, asebenzisa umbala nokwakheka ukudlulisa umqondo wokujula nokuhlangahlangana.

Ngokudzimelela emidwebeni emikhulu yamafutha, uNzuza wakha ilimi elihlukileko lokuveza iinhloko zakhe. Isenzo sokuveza umfanekiso siba sifundo sokuveza umlingiswa ocatshangelwako; ukuthungwa kwangaphakathi, ama-swathes wepende, kanye nemigqa ekhululekileko yenza ifomu nomuzwa ocacileko. Iinthombe zaka-Nzuza, ngamathoni wazo athambileko nokuzibonakalisa, ziduma ngamandla wokunyakaza aqakathekileko.

&quot;Umqondo wokujamelana nokuthuthuka kwengqondo mmongo ophindaphindwako emsebenzini wami begodu kimi, ukwakheka kwemifanekiso yami yindlela yokuveza ubuntu bomuntu. Lokhu kuyinto eqakathekileko emkhubeni wami ngamagwalo wami wamafutha atjengisa ikareko enginayo ngobujamo bomuntu.&quot;

UNzuza uhlanganyele emibukisweni yenqhema ezifaka hlangana i-RE-KNEW-ED e-The Gallery Society e-Edinburgh kanye ne-Sasol New Signatures: Art Beyond Imagination ebanjelwe e-Pretoria Art Museum e-South Africa. Ube neenkulumo ezithengiswa khulu e-Cape Town Art Fair kanye ne-1-54 New York, begodu uzokutjengiswa e-Enter Art Fair ne-1-54 London engcenyeni yokugcina ka-2023.</text>
      <sha1>4rcir006t0zmxhh38wpgpsdmb42hslc</sha1>
    </revision>
    <revision>
      <id>5604</id>
      <parentid>5594</parentid>
      <timestamp>2025-09-04T10:23:10Z</timestamp>
      <contributor>
        <username>Tiny Engeline</username>
        <id>896</id>
      </contributor>
      <comment>Nzunza1</comment>
      <origin>5604</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1638" sha1="fmjjxgj1ga41v7zqdaom186bw6xme6f" xml:space="preserve">Draft 2: page 2





Qala imisebenzi.Mmangaliso Nzuza, Indoda engazange ilale, 2023

Indoda engazange ilale, 2023

Abelana

UMmangaliso Nzuza (wabelethwa ngo-1998) ngunogwala ohlala begodu osebenza e-Cape Town, eSewula Afrika.

UNzuza ufumana umfutho emlandwini wakhe kanye namasiko adumileko. Uyaziwa ngokubunjwa kwakhe okuphefumulelwe yi-cubism, isitayela sakhe sibonakala ngokusebenzisa kwakhe ipende yamafutha we-impasto kanye nokugwala okuqinileko. Uvame ukuveza iinhloko zakhe zisebujameni bokuzicabangela nokuzindla, asebenzisa umbala nokwakheka ukudlulisa umqondo wokujula nokuhlangahlangana.

Ngokudzimelela emidwebeni emikhulu yamafutha, uNzuza wakha ilimi elihlukileko lokuveza iinhloko zakhe. Isenzo sokuveza umfanekiso siba sifundo sokuveza umlingiswa ocatshangelwako; ukuthungwa kwangaphakathi, ama-swathes wepende, kanye nemigqa ekhululekileko yenza ifomu nomuzwa ocacileko. Iinthombe zaka-Nzuza, ngamathoni wazo athambileko nokuzibonakalisa, ziduma ngamandla wokunyakaza aqakathekileko.

&quot;Umqondo wokuma nokuthuthuka kwengqondo mmongo ophindaphindwako emsebenzini wami begodu kimi, ukwakheka kwemifanekiso yami yindlela yokuveza ubuntu bomuntu. Lokhu kuyinto eqakathekileko emkhubeni wami ngemidwebo yamafutha etjengisa ikareko yami ngobujamo bomuntu.&quot;

U-Nzuza uhlanganyele emibukisweni yamaqembu efakahlangana i-RE-KNEW-ED e-The Gallery Society e-Edinburgh kanye ne-Sasol New Signatures: Art Beyond Imagination ebanjelwe e-Pretoria Art Museum e-South Africa. Ube neenkulumo ezithengiswa khulu eCape Town Art Fair kanye ne-1-54 New York, begodu uzokutjengiswa e-Enter Art Fair ne-1-54 London engcenyeni yokugcina ka-2023.</text>
      <sha1>fmjjxgj1ga41v7zqdaom186bw6xme6f</sha1>
    </revision>
    <revision>
      <id>5608</id>
      <parentid>5604</parentid>
      <timestamp>2025-09-04T10:26:04Z</timestamp>
      <contributor>
        <username>Tiny Engeline</username>
        <id>896</id>
      </contributor>
      <origin>5608</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1705" sha1="abok06lysv3r0q2rw0sjuooe3xcznf7" xml:space="preserve">Draft 2: page 2





Qala imisebenzi.Mmangaliso Nzuza, Indoda engazange ilale, 2023

Indoda engazange ilale, 2023

Abelana

UMmangaliso Nzuza (wabelethwa ngo-1998) ngunogwala ohlala begodu osebenza e-Cape Town, eSewula Afrika.

UNzuza ufumana umfutho emlandwini wakhe kanye namasiko adumileko. Uyaziwa ngokubunjwa kwakhe okuphefumulelwe yi-cubism, isitayela sakhe sibonakala ngokusebenzisa kwakhe ipende yamafutha we-impasto kanye nokugwala okuqinileko. Uvame ukuveza iinhloko zakhe zisebujameni bokuzicabangela nokuzindla, asebenzisa umbala nokwakheka ukudlulisa umqondo wokujula nokuhlangahlangana.

Ngokudzimelela emidwebeni emikhulu yamafutha, uNzuza wakha ilimi elihlukileko lokuveza iinhloko zakhe. Isenzo sokuveza umfanekiso siba sifundo sokuveza umlingiswa ocatshangelwako; ukuthungwa kwangaphakathi, ama-swathes wepende, kanye nemigqa ekhululekileko yenza ifomu nomuzwa ocacileko. Iinthombe zaka-Nzuza, ngamathoni wazo athambileko nokuzibonakalisa, ziduma ngamandla wokunyakaza aqakathekileko.

&quot;Umqondo wokuma nokuthuthuka kwengqondo mmongo ophindaphindwako emsebenzini wami begodu kimi, ukwakheka kwemifanekiso yami yindlela yokuveza ubuntu bomuntu. Lokhu kuyinto eqakathekileko emkhubeni wami ngemidwebo yamafutha etjengisa ikareko yami ngobujamo bomuntu.&quot;

U-Nzuza uhlanganyele emibukisweni yamaqembu efakahlangana i-RE-KNEW-ED e-The Gallery Society e-Edinburgh kanye ne-Sasol New Signatures: Art Beyond Imagination ebanjelwe e-Pretoria Art Museum e-South Africa. Ube neenkulumo ezithengiswa khulu eCape Town Art Fair kanye ne-1-54 New York, begodu uzokutjengiswa e-Enter Art Fair ne-1-54 London engcenyeni yokugcina ka-2023 &quot;Mmangaliso Nzuza - Biography&quot;. THK Gallery. Retrieved 2025-09-04..</text>
      <sha1>abok06lysv3r0q2rw0sjuooe3xcznf7</sha1>
    </revision>
    <revision>
      <id>5609</id>
      <parentid>5608</parentid>
      <timestamp>2025-09-04T10:27:00Z</timestamp>
      <contributor>
        <username>Tiny Engeline</username>
        <id>896</id>
      </contributor>
      <minor />
      <origin>5609</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1706" sha1="of9aasizoul5su37zrau2kkloaqv1f4" xml:space="preserve">Draft 2: page 2





Qala imisebenzi.Mmangaliso Nzuza, Indoda engazange ilale, 2023

Indoda engazange ilale, 2023

Abelana

UMmangaliso Nzuza (wabelethwa ngo-1998) ngunogwala ohlala begodu osebenza e-Cape Town, eSewula Afrika.

UNzuza ufumana umfutho emlandwini wakhe kanye namasiko adumileko. Uyaziwa ngokubunjwa kwakhe okuphefumulelwe yi-cubism, isitayela sakhe sibonakala ngokusebenzisa kwakhe ipende yamafutha we-impasto kanye nokugwala okuqinileko. Uvame ukuveza iinhloko zakhe zisebujameni bokuzicabangela nokuzindla, asebenzisa umbala nokwakheka ukudlulisa umqondo wokujula nokuhlangahlangana.

Ngokudzimelela emidwebeni emikhulu yamafutha, uNzuza wakha ilimi elihlukileko lokuveza iinhloko zakhe. Isenzo sokuveza umfanekiso siba sifundo sokuveza umlingiswa ocatshangelwako; ukuthungwa kwangaphakathi, ama-swathes wepende, kanye nemigqa ekhululekileko yenza ifomu nomuzwa ocacileko. Iinthombe zaka-Nzuza, ngamathoni wazo athambileko nokuzibonakalisa, ziduma ngamandla wokunyakaza aqakathekileko.

&quot;Umqondo wokuma nokuthuthuka kwengqondo mmongo ophindaphindwako emsebenzini wami begodu kimi, ukwakheka kwemifanekiso yami yindlela yokuveza ubuntu bomuntu. Lokhu kuyinto eqakathekileko emkhubeni wami ngemidwebo yamafutha etjengisa ikareko yami ngobujamo bomuntu.&quot;

U-Nzuza uhlanganyele emibukisweni yamaqembu efakahlangana i-RE-KNEW-ED e-The Gallery Society e-Edinburgh kanye ne-Sasol New Signatures: Art Beyond Imagination ebanjelwe e-Pretoria Art Museum e-South Africa. Ube neenkulumo ezithengiswa khulu eCape Town Art Fair kanye ne-1-54 New York, begodu uzokutjengiswa e-Enter Art Fair ne-1-54 London engcenyeni yokugcina ka-2023  &quot;Mmangaliso Nzuza - Biography&quot;. THK Gallery. Retrieved 2025-09-04..</text>
      <sha1>of9aasizoul5su37zrau2kkloaqv1f4</sha1>
    </revision>
    <revision>
      <id>5619</id>
      <parentid>5609</parentid>
      <timestamp>2025-09-04T10:39:49Z</timestamp>
      <contributor>
        <username>Tiny Engeline</username>
        <id>896</id>
      </contributor>
      <origin>5619</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1705" sha1="abok06lysv3r0q2rw0sjuooe3xcznf7" xml:space="preserve">Draft 2: page 2





Qala imisebenzi.Mmangaliso Nzuza, Indoda engazange ilale, 2023

Indoda engazange ilale, 2023

Abelana

UMmangaliso Nzuza (wabelethwa ngo-1998) ngunogwala ohlala begodu osebenza e-Cape Town, eSewula Afrika.

UNzuza ufumana umfutho emlandwini wakhe kanye namasiko adumileko. Uyaziwa ngokubunjwa kwakhe okuphefumulelwe yi-cubism, isitayela sakhe sibonakala ngokusebenzisa kwakhe ipende yamafutha we-impasto kanye nokugwala okuqinileko. Uvame ukuveza iinhloko zakhe zisebujameni bokuzicabangela nokuzindla, asebenzisa umbala nokwakheka ukudlulisa umqondo wokujula nokuhlangahlangana.

Ngokudzimelela emidwebeni emikhulu yamafutha, uNzuza wakha ilimi elihlukileko lokuveza iinhloko zakhe. Isenzo sokuveza umfanekiso siba sifundo sokuveza umlingiswa ocatshangelwako; ukuthungwa kwangaphakathi, ama-swathes wepende, kanye nemigqa ekhululekileko yenza ifomu nomuzwa ocacileko. Iinthombe zaka-Nzuza, ngamathoni wazo athambileko nokuzibonakalisa, ziduma ngamandla wokunyakaza aqakathekileko.

&quot;Umqondo wokuma nokuthuthuka kwengqondo mmongo ophindaphindwako emsebenzini wami begodu kimi, ukwakheka kwemifanekiso yami yindlela yokuveza ubuntu bomuntu. Lokhu kuyinto eqakathekileko emkhubeni wami ngemidwebo yamafutha etjengisa ikareko yami ngobujamo bomuntu.&quot;

U-Nzuza uhlanganyele emibukisweni yamaqembu efakahlangana i-RE-KNEW-ED e-The Gallery Society e-Edinburgh kanye ne-Sasol New Signatures: Art Beyond Imagination ebanjelwe e-Pretoria Art Museum e-South Africa. Ube neenkulumo ezithengiswa khulu eCape Town Art Fair kanye ne-1-54 New York, begodu uzokutjengiswa e-Enter Art Fair ne-1-54 London engcenyeni yokugcina ka-2023 &quot;Mmangaliso Nzuza - Biography&quot;. THK Gallery. Retrieved 2025-09-04..</text>
      <sha1>abok06lysv3r0q2rw0sjuooe3xcznf7</sha1>
    </revision>
    <revision>
      <id>5636</id>
      <parentid>5619</parentid>
      <timestamp>2025-09-04T10:51:05Z</timestamp>
      <contributor>
        <username>Tiny Engeline</username>
        <id>896</id>
      </contributor>
      <comment>inserted reference 1</comment>
      <origin>5636</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1720" sha1="tgvru2m6sj6jg19xtrezx0qebn7o7b8" xml:space="preserve">Draft 2: page 2





Qala imisebenzi.Mmangaliso Nzuza, Indoda engazange ilale, 2023

Indoda engazange ilale, 2023

Abelana

UMmangaliso Nzuza (wabelethwa ngo-1998) ngunogwala ohlala begodu osebenza e-Cape Town, eSewula Afrika.

UNzuza ufumana umfutho emlandwini wakhe kanye namasiko adumileko. Uyaziwa ngokubunjwa kwakhe okuphefumulelwe yi-cubism, isitayela sakhe sibonakala ngokusebenzisa kwakhe ipende yamafutha we-impasto kanye nokugwala okuqinileko. Uvame ukuveza iinhloko zakhe zisebujameni bokuzicabangela nokuzindla, asebenzisa umbala nokwakheka ukudlulisa umqondo wokujula nokuhlangahlangana.

Ngokudzimelela emidwebeni emikhulu yamafutha, uNzuza wakha ilimi elihlukileko lokuveza iinhloko zakhe. Isenzo sokuveza umfanekiso siba sifundo sokuveza umlingiswa ocatshangelwako; ukuthungwa kwangaphakathi, ama-swathes wepende, kanye nemigqa ekhululekileko yenza ifomu nomuzwa ocacileko. Iinthombe zaka-Nzuza, ngamathoni wazo athambileko nokuzibonakalisa, ziduma ngamandla wokunyakaza aqakathekileko.

&quot;Umqondo wokuma nokuthuthuka kwengqondo mmongo ophindaphindwako emsebenzini wami begodu kimi, ukwakheka kwemifanekiso yami yindlela yokuveza ubuntu bomuntu. Lokhu kuyinto eqakathekileko emkhubeni wami ngemidwebo yamafutha etjengisa ikareko yami ngobujamo bomuntu.&quot;

U-Nzuza uhlanganyele emibukisweni yamaqembu efakahlangana i-RE-KNEW-ED e-The Gallery Society e-Edinburgh kanye ne-Sasol New Signatures: Art Beyond Imagination ebanjelwe e-Pretoria Art Museum e-South Africa. Ube neenkulumo ezithengiswa khulu eCape Town Art Fair kanye ne-1-54 New York, begodu uzokutjengiswa e-Enter Art Fair ne-1-54 London engcenyeni yokugcina ka-2023&lt;ref&gt;&quot;Mmangaliso Nzuza - Biography&quot;. ''THK Gallery''. Retrieved 2025-09-04.&lt;/ref&gt; .</text>
      <sha1>tgvru2m6sj6jg19xtrezx0qebn7o7b8</sha1>
    </revision>
    <revision>
      <id>5652</id>
      <parentid>5636</parentid>
      <timestamp>2025-09-04T11:06:36Z</timestamp>
      <contributor>
        <username>Tiny Engeline</username>
        <id>896</id>
      </contributor>
      <comment>added reference 1</comment>
      <origin>5652</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1719" sha1="8by58stdrrw6du4gikmabr9c8ve533w" xml:space="preserve">Draft 2: page 2





Qala imisebenzi.Mmangaliso Nzuza, Indoda engazange ilale, 2023

Indoda engazange ilale, 2023

Abelana

UMmangaliso Nzuza (wabelethwa ngo-1998) ngunogwala ohlala begodu osebenza e-Cape Town, eSewula Afrika.

UNzuza ufumana umfutho emlandwini wakhe kanye namasiko adumileko. Uyaziwa ngokubunjwa kwakhe okuphefumulelwe yi-cubism, isitayela sakhe sibonakala ngokusebenzisa kwakhe ipende yamafutha we-impasto kanye nokugwala okuqinileko. Uvame ukuveza iinhloko zakhe zisebujameni bokuzicabangela nokuzindla, asebenzisa umbala nokwakheka ukudlulisa umqondo wokujula nokuhlangahlangana.

Ngokudzimelela emidwebeni emikhulu yamafutha, uNzuza wakha ilimi elihlukileko lokuveza iinhloko zakhe. Isenzo sokuveza umfanekiso siba sifundo sokuveza umlingiswa ocatshangelwako; ukuthungwa kwangaphakathi, ama-swathes wepende, kanye nemigqa ekhululekileko yenza ifomu nomuzwa ocacileko. Iinthombe zaka-Nzuza, ngamathoni wazo athambileko nokuzibonakalisa, ziduma ngamandla wokunyakaza aqakathekileko.

&quot;Umqondo wokuma nokuthuthuka kwengqondo mmongo ophindaphindwako emsebenzini wami begodu kimi, ukwakheka kwemifanekiso yami yindlela yokuveza ubuntu bomuntu. Lokhu kuyinto eqakathekileko emkhubeni wami ngemidwebo yamafutha etjengisa ikareko yami ngobujamo bomuntu.&quot;

U-Nzuza uhlanganyele emibukisweni yamaqembu efakahlangana i-RE-KNEW-ED e-The Gallery Society e-Edinburgh kanye ne-Sasol New Signatures: Art Beyond Imagination ebanjelwe e-Pretoria Art Museum e-South Africa. Ube neenkulumo ezithengiswa khulu eCape Town Art Fair kanye ne-1-54 New York, begodu uzokutjengiswa e-Enter Art Fair ne-1-54 London engcenyeni yokugcina ka-2023&lt;ref&gt;&quot;Mmangaliso Nzuza - Biography&quot;. ''THK Gallery''. Retrieved 2025-09-04.&lt;/ref&gt;.</text>
      <sha1>8by58stdrrw6du4gikmabr9c8ve533w</sha1>
    </revision>
    <revision>
      <id>5666</id>
      <parentid>5652</parentid>
      <timestamp>2025-09-04T11:16:17Z</timestamp>
      <contributor>
        <username>Tiny Engeline</username>
        <id>896</id>
      </contributor>
      <minor />
      <origin>5666</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1703" sha1="t5xyq3ndausokjhsox3cl70iwntvgjh" xml:space="preserve">Draft 2: page 2





Qala imisebenzi.Mmangaliso Nzuza, Indoda engazange ilale, 2023

Indoda engazange ilale, 2023

Abelana

UMmangaliso Nzuza (wabelethwa ngo-1998) ngunogwala ohlala begodu osebenza e-Cape Town, eSewula Afrika.

UNzuza ufumana umfutho emlandwini wakhe kanye namasiko adumileko. Uyaziwa ngokubunjwa kwakhe okuphefumulelwe yi-cubism, isitayela sakhe sibonakala ngokusebenzisa kwakhe ipende yamafutha we-impasto kanye nokugwala okuqinileko. Uvame ukuveza iinhloko zakhe zisebujameni bokuzicabangela nokuzindla, asebenzisa umbala nokwakheka ukudlulisa umqondo wokujula nokuhlangahlangana.

Ngokudzimelela emidwebeni emikhulu yamafutha, uNzuza wakha ilimi elihlukileko lokuveza iinhloko zakhe. Isenzo sokuveza umfanekiso siba sifundo sokuveza umlingiswa ocatshangelwako; ukuthungwa kwangaphakathi, ama-swathes wepende, kanye nemigqa ekhululekileko yenza ifomu nomuzwa ocacileko. Iinthombe zaka-Nzuza, ngamathoni wazo athambileko nokuzibonakalisa, ziduma ngamandla wokunyakaza aqakathekileko.

&quot;Umqondo wokuma nokuthuthuka kwengqondo mmongo ophindaphindwako emsebenzini wami begodu kimi, ukwakheka kwemifanekiso yami yindlela yokuveza ubuntu bomuntu. Lokhu kuyinto eqakathekileko emkhubeni wami ngemidwebo yamafutha etjengisa ikareko yami ngobujamo bomuntu.&quot;

U-Nzuza uhlanganyele emibukisweni yamaqembu efakahlangana i-RE-KNEW-ED e-The Gallery Society e-Edinburgh kanye ne-Sasol New Signatures: Art Beyond Imagination ebanjelwe e-Pretoria Art Museum e-South Africa. Ube neenkulumo ezithengiswa khulu eCape Town Art Fair kanye ne-1-54 New York, begodu uzokutjengiswa e-Enter Art Fair ne-1-54 London engcenyeni yokugcina ka-2023Mmangaliso Nzuza - Biography&quot;. THK Gallery. Retrieved 2025-09-04..</text>
      <sha1>t5xyq3ndausokjhsox3cl70iwntvgjh</sha1>
    </revision>
    <revision>
      <id>5668</id>
      <parentid>5666</parentid>
      <timestamp>2025-09-04T11:18:38Z</timestamp>
      <contributor>
        <username>Tiny Engeline</username>
        <id>896</id>
      </contributor>
      <comment>remove he row</comment>
      <origin>5668</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1752" sha1="28sozntorolbydej9pmcb9lyipwskqz" xml:space="preserve">Draft 2: page 2





Qala imisebenzi.Mmangaliso Nzuza, Indoda engazange ilale, 2023

Indoda engazange ilale, 2023

Abelana

UMmangaliso Nzuza (wabelethwa ngo-1998) ngunogwala ohlala begodu osebenza e-Cape Town, eSewula Afrika.

UNzuza ufumana umfutho emlandwini wakhe kanye namasiko adumileko. Uyaziwa ngokubunjwa kwakhe okuphefumulelwe yi-cubism, isitayela sakhe sibonakala ngokusebenzisa kwakhe ipende yamafutha we-impasto kanye nokugwala okuqinileko. Uvame ukuveza iinhloko zakhe zisebujameni bokuzicabangela nokuzindla, asebenzisa umbala nokwakheka ukudlulisa umqondo wokujula nokuhlangahlangana.

Ngokudzimelela emidwebeni emikhulu yamafutha, uNzuza wakha ilimi elihlukileko lokuveza iinhloko zakhe. Isenzo sokuveza umfanekiso siba sifundo sokuveza umlingiswa ocatshangelwako; ukuthungwa kwangaphakathi, ama-swathes wepende, kanye nemigqa ekhululekileko yenza ifomu nomuzwa ocacileko. Iinthombe zaka-Nzuza, ngamathoni wazo athambileko nokuzibonakalisa, ziduma ngamandla wokunyakaza aqakathekileko.

&quot;Umqondo wokuma nokuthuthuka kwengqondo mmongo ophindaphindwako emsebenzini wami begodu kimi, ukwakheka kwemifanekiso yami yindlela yokuveza ubuntu bomuntu. Lokhu kuyinto eqakathekileko emkhubeni wami ngemidwebo yamafutha etjengisa ikareko yami ngobujamo bomuntu.&quot;

U-Nzuza uhlanganyele emibukisweni yamaqembu efakahlangana i-RE-KNEW-ED e-The Gallery Society e-Edinburgh kanye ne-Sasol New Signatures: Art Beyond Imagination ebanjelwe e-Pretoria Art Museum e-South Africa. Ube neenkulumo ezithengiswa khulu eCape Town Art Fair kanye ne-1-54 New York, begodu uzokutjengiswa e-Enter Art Fair ne-1-54 London engcenyeni yokugcina ka-2023&lt;ref&gt;Mmangaliso Nzuza - Biography&quot;. ''THK Gallery''. Retrieved 2025-09-04.&lt;/ref&gt;
&lt;references group=&quot;reference&quot; /&gt;
.</text>
      <sha1>28sozntorolbydej9pmcb9lyipwskqz</sha1>
    </revision>
    <revision>
      <id>5679</id>
      <parentid>5668</parentid>
      <timestamp>2025-09-04T11:33:57Z</timestamp>
      <contributor>
        <username>Tiny Engeline</username>
        <id>896</id>
      </contributor>
      <minor />
      <origin>5679</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1752" sha1="gmga9r7qm69lvgq1cslxx0zmn11vmjm" xml:space="preserve">Draft 2: page 2

Qala imisebenzi.Mmangaliso Nzuza, Indoda engazange ilale, 2023

Indoda engazange ilale, 2023

Abelana

UMmangaliso Nzuza (wabelethwa ngo-1998) ngunogwala ohlala begodu osebenza e-Cape Town, eSewula Afrika.

UNzuza ufumana umfutho emlandwini wakhe kanye namasiko adumileko. Uyaziwa ngokubunjwa kwakhe okuphefumulelwe yi-cubism, isitayela sakhe sibonakala ngokusebenzisa kwakhe ipende yamafutha we-impasto kanye nokugwala okuqinileko. Uvame ukuveza iinhloko zakhe zisebujameni bokuzicabangela nokuzindla, asebenzisa umbala nokwakheka ukudlulisa umqondo wokujula nokuhlangahlangana.

Ngokudzimelela emidwebeni emikhulu yamafutha, uNzuza wakha ilimi elihlukileko lokuveza iinhloko zakhe. Isenzo sokuveza umfanekiso siba sifundo sokuveza umlingiswa ocatshangelwako; ukuthungwa kwangaphakathi, ama-swathes wepende, kanye nemigqa ekhululekileko yenza ifomu nomuzwa ocacileko. Iinthombe zaka-Nzuza, ngamathoni wazo athambileko nokuzibonakalisa, ziduma ngamandla wokunyakaza aqakathekileko.

&quot;Umqondo wokuma nokuthuthuka kwengqondo mmongo ophindaphindwako emsebenzini wami begodu kimi, ukwakheka kwemifanekiso yami yindlela yokuveza ubuntu bomuntu. Lokhu kuyinto eqakathekileko emkhubeni wami ngemidwebo yamafutha etjengisa ikareko yami ngobujamo bomuntu.&quot;

U-Nzuza uhlanganyele emibukisweni yamaqembu efakahlangana i-RE-KNEW-ED e-The Gallery Society e-Edinburgh kanye ne-Sasol New Signatures: Art Beyond Imagination ebanjelwe e-Pretoria Art Museum e-South Africa. Ube neenkulumo ezithengiswa khulu eCape Town Art Fair kanye ne-1-54 New York, begodu uzokutjengiswa e-Enter Art Fair ne-1-54 London engcenyeni yokugcina ka-2023&lt;ref&gt;Mmangaliso Nzuza - Biography&quot;. ''THK Gallery''. Retrieved 2025-09-04.&lt;/ref&gt;.

=== UMTHOMBOLWAZI ===
&lt;references /&gt;</text>
      <sha1>gmga9r7qm69lvgq1cslxx0zmn11vmjm</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Pholap/Page 2</title>
    <ns>2</ns>
    <id>895</id>
    <revision>
      <id>5401</id>
      <timestamp>2025-09-03T10:37:53Z</timestamp>
      <contributor>
        <username>Pholap</username>
        <id>883</id>
      </contributor>
      <comment>created draft space 2</comment>
      <origin>5401</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="21" sha1="sj5j4tpbq6u91cwhumtp8yadvek3tbg" xml:space="preserve">Page 2: Draft space 2</text>
      <sha1>sj5j4tpbq6u91cwhumtp8yadvek3tbg</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Journey2026/Page 1</title>
    <ns>2</ns>
    <id>896</id>
    <revision>
      <id>5406</id>
      <timestamp>2025-09-03T12:12:57Z</timestamp>
      <contributor>
        <username>Journey2026</username>
        <id>881</id>
      </contributor>
      <comment>created first draft page</comment>
      <origin>5406</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7" sha1="6sqh13mnsdpl0zij97r8y5tbo55s8lx" xml:space="preserve">Draft 1</text>
      <sha1>6sqh13mnsdpl0zij97r8y5tbo55s8lx</sha1>
    </revision>
    <revision>
      <id>5439</id>
      <parentid>5406</parentid>
      <timestamp>2025-09-04T07:48:38Z</timestamp>
      <contributor>
        <username>Journey2026</username>
        <id>881</id>
      </contributor>
      <minor />
      <comment>Added a reference</comment>
      <origin>5439</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="33" sha1="sb4kyvy06i7vnglecwabim0bd2p3qxd" xml:space="preserve">Draft 1


=== Imithombo lwazi ===</text>
      <sha1>sb4kyvy06i7vnglecwabim0bd2p3qxd</sha1>
    </revision>
    <revision>
      <id>5447</id>
      <parentid>5439</parentid>
      <timestamp>2025-09-04T07:53:25Z</timestamp>
      <contributor>
        <username>Journey2026</username>
        <id>881</id>
      </contributor>
      <minor />
      <comment>Added Mandela day</comment>
      <origin>5447</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="297" sha1="ph3wv5on45k8bw5pgn4iq1sjmos1lme" xml:space="preserve">Draft 1



Nelson Mandela International Day is an annual international day in honour of Nelson Mandela, celebrated each year on 18 July, Mandela's birthday. The day was officially declared by the United Nations in November 2009, with the first UN Mandela Day held on 18 July 2010. 

&lt;references /&gt;</text>
      <sha1>ph3wv5on45k8bw5pgn4iq1sjmos1lme</sha1>
    </revision>
    <revision>
      <id>5450</id>
      <parentid>5447</parentid>
      <timestamp>2025-09-04T07:55:46Z</timestamp>
      <contributor>
        <username>Journey2026</username>
        <id>881</id>
      </contributor>
      <minor />
      <comment>Added a reference</comment>
      <origin>5450</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="333" sha1="o0ucptsrxhkxzjzn57wkm7mdvswn8j2" xml:space="preserve">Draft 1

Nelson Mandela International Day is an annual international day in honour of Nelson Mandela, celebrated each year on 18 July, Mandela's birthday. The day was officially declared by the United Nations in November 2009, with the first UN Mandela Day held on 18 July 2010.

&lt;references responsive=&quot;&quot; /&gt;

=== Imithombo lwazi ===</text>
      <sha1>o0ucptsrxhkxzjzn57wkm7mdvswn8j2</sha1>
    </revision>
    <revision>
      <id>5555</id>
      <parentid>5450</parentid>
      <timestamp>2025-09-04T09:39:01Z</timestamp>
      <contributor>
        <username>Journey2026</username>
        <id>881</id>
      </contributor>
      <minor />
      <comment>Added a link</comment>
      <origin>5555</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="337" sha1="ti91z1nd4i3dldo3reohar0hwy3a0z2" xml:space="preserve">Draft 1

Nelson Mandela International Day is an annual international day in honour of [[Nelson Mandela]], celebrated each year on 18 July, Mandela's birthday. The day was officially declared by the United Nations in November 2009, with the first UN Mandela Day held on 18 July 2010.

&lt;references responsive=&quot;&quot; /&gt;

=== Imithombo lwazi ===</text>
      <sha1>ti91z1nd4i3dldo3reohar0hwy3a0z2</sha1>
    </revision>
    <revision>
      <id>5628</id>
      <parentid>5555</parentid>
      <timestamp>2025-09-04T10:43:29Z</timestamp>
      <contributor>
        <username>Journey2026</username>
        <id>881</id>
      </contributor>
      <minor />
      <comment>Added a picture</comment>
      <origin>5628</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="410" sha1="nl8tevos9ks4xmy4l39ucs50vr3rzhg" xml:space="preserve">[[Isimumathi:Nelson Mandela 1994.jpg|thumb|Isithombe sikababa uMandela]]
Draft 1

Nelson Mandela International Day is an annual international day in honour of [[Nelson Mandela]], celebrated each year on 18 July, Mandela's birthday. The day was officially declared by the United Nations in November 2009, with the first UN Mandela Day held on 18 July 2010.

&lt;references responsive=&quot;&quot; /&gt;

=== Imithombo lwazi ===</text>
      <sha1>nl8tevos9ks4xmy4l39ucs50vr3rzhg</sha1>
    </revision>
  </page>
  <page>
    <title>Ngalokho-ke Mbedu</title>
    <ns>0</ns>
    <id>898</id>
    <revision>
      <id>5415</id>
      <timestamp>2025-09-03T21:00:39Z</timestamp>
      <contributor>
        <username>Mtsweni S</username>
        <id>835</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1301355356|Thuso Mbedu]]&quot;</comment>
      <origin>5415</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4163" sha1="480phbczihezwlshcyxdg7k0bh6iiyp" xml:space="preserve">






 


U-Thuso Nokwanda Mbedu (owabelethwa mhla amalanga abunane ku-Velabahlinze ngonyaka we-1991) ungomunye wabadlali bakumabonwakude be-Sewula Afrika. Waduma khulu ngendima ayidlalako emdlalweni we-Sewula Afrika wabantu abatjha obizwa ngokobana yi-Sthunzi, lapho akhethwa khona ngokulandelana ukuthi athathe unongorwana wangaphetjheya obizwa nge- International Emmy ngonyaka wee-2017 kanye no-2018. U-Mbedu ekukhambeni kwesikhathi wavela ehlanganweni ebizwa ngokuthi yi- Forbes Africa 30 ngaphasi kwabantu abangaphasi kweminyaka ematjhumi amathathu ubudala ngonyaka wee-2018.

Ngonyaka wee-2021, wadlala ehlelweni elibizwa nge-Underground Railroad elitholakala kuAmazon Video, lapho kunamahlelo amanengi nekungilo elamenza bona abemdlali wokuthoma we-Sewula Afrika okhamba phambili kwezamahlelo adlala kumabonwakude we-America. Lokhu kwamenza bona athumbe unongorwana obizwa bona yi-Independent Spirit Award etholwa mumuntu wengubo okhamba phambili ngokuba mdlali wakumabonwakude ehlelweni elitjha. Waragela phambili waba ngomunye wabalingisi ehlelweni elimlando wangaphetjheya e-America obizwa ngokobana yi- The Woman King (2022) lapho adlala khona iskhundla saka Nawi.

== Ipilo yebuncanini nefundo ==
U-Mbedu wabelethelwa e-Midlands Medical Centre endaweni ye-Pietermaritzburg, KwaZulu-Natal. Ubelethwa ngumma okhuluma isiZulu kanye noyise okhuluma isiSotho nesiXhosa. Wakhuliswa e-Pelham ngugogo wakhe , owabamumuntu omtlhogomelako ngemva kokuhlongakalelwa babelethi bakhe bobabili asesemncani.  

U-Mbedu wafunda e-Pelham Primary School bese waya e- Pietermaritzburg Girls' High School .  Waragela phambili nokufunda i-Physical Theatre kanye ne-Performing Arts Management e- University of the Witwatersrand (Wits), waphothula ngo-2013 ngama-honor,  ngemva kokuthatha ikhosi e- Stella Adler Studio of Acting e-New York City ngo-2012.  

== Ibizelo ==
Ekupheleni konyaka wee-2014, u-Mbedu waba nendima encani kusizini yesibili ye- Mzansi Magic soapie ''Isibaya'',  ngaphambi kokuthi athole indima yakhe njengomfundi wezobuntatheli nomntwana u-Kitso ku ''-Scandal!'' . ''['' ​  kanye nendima ephambili njengo-Boni Khumalo emdlalweni kamabonakude bbizwa kobana yi- ''Saints and Sinners.''

Ngemva kokungasebenzi iinyanga ezisithandathu, u-Mbedu wathola indima yakhe yokuthoma kumabonakude emdlalweni we -Mzansi Magic welutjha ''-Is'Thunzi'', owathoma ngoMgwengweni enyakeni wee-2016.   Emdlalweni lo, wadlala indima ka-Winnie, umdlali othanda ukuzikhakhazisa, ofuna ukutjhada nomdlali we-rugby onjingileko nodumileko kodwana ibhudango lakhe liyatjhabalala lokha nakufanele akhambe ayokuhlala nokgharakhe obukhali e-Bergville. Lokha nakalingisa  isiqephu sokudlwengulwa emdlalweni, wahlaselwa livalo.  NgoNobayeni 2017, waphakanyiswa enongorwaneni we -International Emmy Award esigabeni sokudlala okuhle khulu komlingisi ngendima yakhe njengo-Winnie ku ''-Is'Thunzi''  begodu bekunguye kwaphela umuntu we Sewula-Afrika owaphakanyiswa ngalowo mnyaka. 

U-Mbedu wenza ukudlala kwakhe kokuthoma njengo-Cora kubemlando ngonyaka wee-2021 we-Amazon Video ''i-The Underground Railroad'', esekelwe enovelini enegama elifanako ka -Colson Whitehead begodu iqondiswe beyakhiqizwa ngomunye owathumba i -Academy Award u-Barry Jenkins .   UMbedu wathola i -Hollywood Critics Association Award, i- Independent Spirit Award, kanye ne -Gotham Award yomdlalo. 


Ngenyanga kaMrhayili 2021, kwamenyezelwa bona uMbedu uzokwenza ifilimu yakhe yokuthoma njengo-Nawi aqalene no -Viola Davis ku- ''The Woman King'', ifilimu yomlando ephefumulelwe ngezehlakalo zamambala ezenzeka eMbusweni we-Dahomey,  omunye wemibuso enamandla khulu ye-Afrika ngekhulu le-18 nele-19. Ifilimu le beyiqondiswe ngu -Gina Prince-Bythewood, ukusuka emtlolweni womtloli we- ''Fatherhood'' u-Dana Stevens .   

Ngo-2023, u-Mbedu waba yinxusa nomkhulumeli we -L'Oréal we-Sub-Saharan Africa.    NgoTjhirhweni 2025 &lt;nowiki&gt;&lt;i id=&quot;mw3w&quot;&gt;i-Deadline&lt;/i&gt;&lt;/nowiki&gt; yabika bona u-Mbedu ukhethwe indima ephambili kufilimu ezako ye-Paramount i- ''Children of Blood and Bone'' njengo-Zélie hlangana no -Viola Davis, u-Cynthia Erivo, u-Damson Idris, u-Amandla Stenberg, u- Idris Elba no- Tosin Cole . {{Reflist}}</text>
      <sha1>480phbczihezwlshcyxdg7k0bh6iiyp</sha1>
    </revision>
  </page>
  <page>
    <title>Thuso Mbedu</title>
    <ns>0</ns>
    <id>899</id>
    <revision>
      <id>5416</id>
      <timestamp>2025-09-03T21:01:41Z</timestamp>
      <contributor>
        <username>Mtsweni S</username>
        <id>835</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1301355356|Thuso Mbedu]]&quot;</comment>
      <origin>5416</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4163" sha1="480phbczihezwlshcyxdg7k0bh6iiyp" xml:space="preserve">






 


U-Thuso Nokwanda Mbedu (owabelethwa mhla amalanga abunane ku-Velabahlinze ngonyaka we-1991) ungomunye wabadlali bakumabonwakude be-Sewula Afrika. Waduma khulu ngendima ayidlalako emdlalweni we-Sewula Afrika wabantu abatjha obizwa ngokobana yi-Sthunzi, lapho akhethwa khona ngokulandelana ukuthi athathe unongorwana wangaphetjheya obizwa nge- International Emmy ngonyaka wee-2017 kanye no-2018. U-Mbedu ekukhambeni kwesikhathi wavela ehlanganweni ebizwa ngokuthi yi- Forbes Africa 30 ngaphasi kwabantu abangaphasi kweminyaka ematjhumi amathathu ubudala ngonyaka wee-2018.

Ngonyaka wee-2021, wadlala ehlelweni elibizwa nge-Underground Railroad elitholakala kuAmazon Video, lapho kunamahlelo amanengi nekungilo elamenza bona abemdlali wokuthoma we-Sewula Afrika okhamba phambili kwezamahlelo adlala kumabonwakude we-America. Lokhu kwamenza bona athumbe unongorwana obizwa bona yi-Independent Spirit Award etholwa mumuntu wengubo okhamba phambili ngokuba mdlali wakumabonwakude ehlelweni elitjha. Waragela phambili waba ngomunye wabalingisi ehlelweni elimlando wangaphetjheya e-America obizwa ngokobana yi- The Woman King (2022) lapho adlala khona iskhundla saka Nawi.

== Ipilo yebuncanini nefundo ==
U-Mbedu wabelethelwa e-Midlands Medical Centre endaweni ye-Pietermaritzburg, KwaZulu-Natal. Ubelethwa ngumma okhuluma isiZulu kanye noyise okhuluma isiSotho nesiXhosa. Wakhuliswa e-Pelham ngugogo wakhe , owabamumuntu omtlhogomelako ngemva kokuhlongakalelwa babelethi bakhe bobabili asesemncani.  

U-Mbedu wafunda e-Pelham Primary School bese waya e- Pietermaritzburg Girls' High School .  Waragela phambili nokufunda i-Physical Theatre kanye ne-Performing Arts Management e- University of the Witwatersrand (Wits), waphothula ngo-2013 ngama-honor,  ngemva kokuthatha ikhosi e- Stella Adler Studio of Acting e-New York City ngo-2012.  

== Ibizelo ==
Ekupheleni konyaka wee-2014, u-Mbedu waba nendima encani kusizini yesibili ye- Mzansi Magic soapie ''Isibaya'',  ngaphambi kokuthi athole indima yakhe njengomfundi wezobuntatheli nomntwana u-Kitso ku ''-Scandal!'' . ''['' ​  kanye nendima ephambili njengo-Boni Khumalo emdlalweni kamabonakude bbizwa kobana yi- ''Saints and Sinners.''

Ngemva kokungasebenzi iinyanga ezisithandathu, u-Mbedu wathola indima yakhe yokuthoma kumabonakude emdlalweni we -Mzansi Magic welutjha ''-Is'Thunzi'', owathoma ngoMgwengweni enyakeni wee-2016.   Emdlalweni lo, wadlala indima ka-Winnie, umdlali othanda ukuzikhakhazisa, ofuna ukutjhada nomdlali we-rugby onjingileko nodumileko kodwana ibhudango lakhe liyatjhabalala lokha nakufanele akhambe ayokuhlala nokgharakhe obukhali e-Bergville. Lokha nakalingisa  isiqephu sokudlwengulwa emdlalweni, wahlaselwa livalo.  NgoNobayeni 2017, waphakanyiswa enongorwaneni we -International Emmy Award esigabeni sokudlala okuhle khulu komlingisi ngendima yakhe njengo-Winnie ku ''-Is'Thunzi''  begodu bekunguye kwaphela umuntu we Sewula-Afrika owaphakanyiswa ngalowo mnyaka. 

U-Mbedu wenza ukudlala kwakhe kokuthoma njengo-Cora kubemlando ngonyaka wee-2021 we-Amazon Video ''i-The Underground Railroad'', esekelwe enovelini enegama elifanako ka -Colson Whitehead begodu iqondiswe beyakhiqizwa ngomunye owathumba i -Academy Award u-Barry Jenkins .   UMbedu wathola i -Hollywood Critics Association Award, i- Independent Spirit Award, kanye ne -Gotham Award yomdlalo. 


Ngenyanga kaMrhayili 2021, kwamenyezelwa bona uMbedu uzokwenza ifilimu yakhe yokuthoma njengo-Nawi aqalene no -Viola Davis ku- ''The Woman King'', ifilimu yomlando ephefumulelwe ngezehlakalo zamambala ezenzeka eMbusweni we-Dahomey,  omunye wemibuso enamandla khulu ye-Afrika ngekhulu le-18 nele-19. Ifilimu le beyiqondiswe ngu -Gina Prince-Bythewood, ukusuka emtlolweni womtloli we- ''Fatherhood'' u-Dana Stevens .   

Ngo-2023, u-Mbedu waba yinxusa nomkhulumeli we -L'Oréal we-Sub-Saharan Africa.    NgoTjhirhweni 2025 &lt;nowiki&gt;&lt;i id=&quot;mw3w&quot;&gt;i-Deadline&lt;/i&gt;&lt;/nowiki&gt; yabika bona u-Mbedu ukhethwe indima ephambili kufilimu ezako ye-Paramount i- ''Children of Blood and Bone'' njengo-Zélie hlangana no -Viola Davis, u-Cynthia Erivo, u-Damson Idris, u-Amandla Stenberg, u- Idris Elba no- Tosin Cole . {{Reflist}}</text>
      <sha1>480phbczihezwlshcyxdg7k0bh6iiyp</sha1>
    </revision>
    <revision>
      <id>5449</id>
      <parentid>5416</parentid>
      <timestamp>2025-09-04T07:54:16Z</timestamp>
      <contributor>
        <username>Mtsweni S</username>
        <id>835</id>
      </contributor>
      <comment>Added a reference list</comment>
      <origin>5449</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4203" sha1="7p8ot6wfxs52fcxx7zhknx5vdfz6z56" xml:space="preserve">






 


U-Thuso Nokwanda Mbedu (owabelethwa mhla amalanga abunane ku-Velabahlinze ngonyaka we-1991) ungomunye wabadlali bakumabonwakude be-Sewula Afrika. Waduma khulu ngendima ayidlalako emdlalweni we-Sewula Afrika wabantu abatjha obizwa ngokobana yi-Sthunzi, lapho akhethwa khona ngokulandelana ukuthi athathe unongorwana wangaphetjheya obizwa nge- International Emmy ngonyaka wee-2017 kanye no-2018. U-Mbedu ekukhambeni kwesikhathi wavela ehlanganweni ebizwa ngokuthi yi- Forbes Africa 30 ngaphasi kwabantu abangaphasi kweminyaka ematjhumi amathathu ubudala ngonyaka wee-2018.

Ngonyaka wee-2021, wadlala ehlelweni elibizwa nge-Underground Railroad elitholakala kuAmazon Video, lapho kunamahlelo amanengi nekungilo elamenza bona abemdlali wokuthoma we-Sewula Afrika okhamba phambili kwezamahlelo adlala kumabonwakude we-America. Lokhu kwamenza bona athumbe unongorwana obizwa bona yi-Independent Spirit Award etholwa mumuntu wengubo okhamba phambili ngokuba mdlali wakumabonwakude ehlelweni elitjha. Waragela phambili waba ngomunye wabalingisi ehlelweni elimlando wangaphetjheya e-America obizwa ngokobana yi- The Woman King (2022) lapho adlala khona iskhundla saka Nawi.

== Ipilo yebuncanini nefundo ==
U-Mbedu wabelethelwa e-Midlands Medical Centre endaweni ye-Pietermaritzburg, KwaZulu-Natal. Ubelethwa ngumma okhuluma isiZulu kanye noyise okhuluma isiSotho nesiXhosa. Wakhuliswa e-Pelham ngugogo wakhe , owabamumuntu omtlhogomelako ngemva kokuhlongakalelwa babelethi bakhe bobabili asesemncani.  

U-Mbedu wafunda e-Pelham Primary School bese waya e- Pietermaritzburg Girls' High School .  Waragela phambili nokufunda i-Physical Theatre kanye ne-Performing Arts Management e- University of the Witwatersrand (Wits), waphothula ngo-2013 ngama-honor,  ngemva kokuthatha ikhosi e- Stella Adler Studio of Acting e-New York City ngo-2012.  

== Ibizelo ==
Ekupheleni konyaka wee-2014, u-Mbedu waba nendima encani kusizini yesibili ye- Mzansi Magic soapie ''Isibaya'',  ngaphambi kokuthi athole indima yakhe njengomfundi wezobuntatheli nomntwana u-Kitso ku ''-Scandal!'' . ''['' ​  kanye nendima ephambili njengo-Boni Khumalo emdlalweni kamabonakude bbizwa kobana yi- ''Saints and Sinners.''

Ngemva kokungasebenzi iinyanga ezisithandathu, u-Mbedu wathola indima yakhe yokuthoma kumabonakude emdlalweni we -Mzansi Magic welutjha ''-Is'Thunzi'', owathoma ngoMgwengweni enyakeni wee-2016.   Emdlalweni lo, wadlala indima ka-Winnie, umdlali othanda ukuzikhakhazisa, ofuna ukutjhada nomdlali we-rugby onjingileko nodumileko kodwana ibhudango lakhe liyatjhabalala lokha nakufanele akhambe ayokuhlala nokgharakhe obukhali e-Bergville. Lokha nakalingisa  isiqephu sokudlwengulwa emdlalweni, wahlaselwa livalo.  NgoNobayeni 2017, waphakanyiswa enongorwaneni we -International Emmy Award esigabeni sokudlala okuhle khulu komlingisi ngendima yakhe njengo-Winnie ku ''-Is'Thunzi''  begodu bekunguye kwaphela umuntu we Sewula-Afrika owaphakanyiswa ngalowo mnyaka. 

U-Mbedu wenza ukudlala kwakhe kokuthoma njengo-Cora kubemlando ngonyaka wee-2021 we-Amazon Video ''i-The Underground Railroad'', esekelwe enovelini enegama elifanako ka -Colson Whitehead begodu iqondiswe beyakhiqizwa ngomunye owathumba i -Academy Award u-Barry Jenkins .   UMbedu wathola i -Hollywood Critics Association Award, i- Independent Spirit Award, kanye ne -Gotham Award yomdlalo. 


Ngenyanga kaMrhayili 2021, kwamenyezelwa bona uMbedu uzokwenza ifilimu yakhe yokuthoma njengo-Nawi aqalene no -Viola Davis ku- ''The Woman King'', ifilimu yomlando ephefumulelwe ngezehlakalo zamambala ezenzeka eMbusweni we-Dahomey,  omunye wemibuso enamandla khulu ye-Afrika ngekhulu le-18 nele-19. Ifilimu le beyiqondiswe ngu -Gina Prince-Bythewood, ukusuka emtlolweni womtloli we- ''Fatherhood'' u-Dana Stevens .   

Ngo-2023, u-Mbedu waba yinxusa nomkhulumeli we -L'Oréal we-Sub-Saharan Africa.    NgoTjhirhweni 2025 &lt;nowiki&gt;&lt;i id=&quot;mw3w&quot;&gt;i-Deadline&lt;/i&gt;&lt;/nowiki&gt; yabika bona u-Mbedu ukhethwe indima ephambili kufilimu ezako ye-Paramount i- ''Children of Blood and Bone'' njengo-Zélie hlangana no -Viola Davis, u-Cynthia Erivo, u-Damson Idris, u-Amandla Stenberg, u- Idris Elba no- osin Cole . 

=== Imithombo lwazi ===
&lt;references /&gt;
{{Reflist}}</text>
      <sha1>7p8ot6wfxs52fcxx7zhknx5vdfz6z56</sha1>
    </revision>
    <revision>
      <id>5673</id>
      <parentid>5449</parentid>
      <timestamp>2025-09-04T11:25:56Z</timestamp>
      <contributor>
        <username>Mtsweni S</username>
        <id>835</id>
      </contributor>
      <origin>5673</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2992" sha1="e5xdvoha7voj101g9s13h5e6a9wtf77" xml:space="preserve">== THUSO MBEDU ==
[[Isimumathi:Thuso Mbedu talking in 2019 02.png|thumb|Isithombe sakaThuso Mbedu]]

U-Thuso Nokwanda Mbedu (owabelethwa mhla amalanga abunane ku-Velabahlinze ngonyaka we-1991) ungomunye wabadlali bakumabonwakude be-Sewula Afrika. Waduma khulu ngendima ayidlalako emdlalweni we-Sewula Afrika wabantu abatjha obizwa ngokobana yi-Sthunzi, lapho akhethwa khona ngokulandelana ukuthi athathe unongorwana wangaphetjheya obizwa nge- International Emmy ngonyaka wee-2017 kanye no-2018. U-Mbedu ekukhambeni kwesikhathi wavela ehlanganweni ebizwa ngokuthi yi- Forbes Africa 30 ngaphasi kwabantu abangaphasi kweminyaka ematjhumi amathathu ubudala ngonyaka wee-2018.

Ngonyaka wee-2021, wadlala ehlelweni elibizwa nge-Underground Railroad elitholakala kuAmazon Video, lapho kunamahlelo amanengi nekungilo elamenza bona abemdlali wokuthoma we-Sewula Afrika okhamba phambili kwezamahlelo adlala kumabonwakude we-America. Lokhu kwamenza bona athumbe unongorwana obizwa bona yi-Independent Spirit Award etholwa mumuntu wengubo okhamba phambili ngokuba mdlali wakumabonwakude ehlelweni elitjha. Waragela phambili waba ngomunye wabalingisi ehlelweni elimlando wangaphetjheya e-America obizwa ngokobana yi- The Woman King (2022) lapho adlala khona iskhundla saka Nawi.

=== IPILO YEBUNCANINI NEFUNDO ===
U-Mbedu wabelethelwa e-Midlands Medical Centre endaweni ye-Pietermaritzburg, KwaZulu-Natal. Ubelethwa ngumma okhuluma isiZulu kanye noyise okhuluma isiSotho nesiXhosa. Wakhuliswa e-Pelham ngugogo wakhe , owabamumuntu omtlhogomelako ngemva kokuhlongakalelwa babelethi bakhe bobabili asesemncani.

U-Mbedu wafunda e-Pelham Primary School bese waya e- Pietermaritzburg Girls' High School . &lt;ref&gt;{{Cite journal|url=https://www.news24.com/witness/news/from-pmb-to-the-worlds-tvs-20170129|title=From PMB to the world's TVs|journal=The Witness|first=Nompilo|last=Kunene|date=30 January 2017|access-date=21 October 2021}}&lt;/ref&gt; Waragela phambili nokufunda i-Physical Theatre kanye ne-Performing Arts Management e- University of the Witwatersrand (Wits), waphothula ngo-2013 ngama-honor, &lt;ref&gt;{{cite web|url=https://www.goodthingsguy.com/people/thuso-mbedu-underground-railroad/|title=Meet the first South African actress to lead an American series!!!|website=Good Things Guy|date=17 April 2019}}&lt;/ref&gt; ngemva kokuthatha ikhosi e- Stella Adler Studio of Acting e-New York City ngo-2012. &lt;ref&gt;{{cite web|url=http://www.youthvillage.co.za/2016/05/10-things-you-didnt-know-about-scandal-actress-thuso-mbedu/|title=10 Things You Didn't Know About Scandal Actress Thuso Mbedu|website=Youth Village|date=16 May 2016}}&lt;/ref&gt; &lt;ref name=&quot;:1&quot;&gt;{{Cite journal|url=https://www.timeslive.co.za/tshisa-live/tshisa-live/2020-09-28-i-had-no-clue-what-they-were-saying-thuso-mbedu-on-connecting-with-her-sotho-heritage/|title='I had no clue what they were saying'-Thuso Mbedu on connecting with her Sotho heritage|journal=Times Live|first=Deepika|last=Naidoo|date=28 September 2020|access-date=3 November 2021}}&lt;/ref&gt;</text>
      <sha1>e5xdvoha7voj101g9s13h5e6a9wtf77</sha1>
    </revision>
    <revision>
      <id>5674</id>
      <parentid>5673</parentid>
      <timestamp>2025-09-04T11:28:12Z</timestamp>
      <contributor>
        <username>Mtsweni S</username>
        <id>835</id>
      </contributor>
      <origin>5674</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="11060" sha1="7twtdgbdjf1z2vd31p8u8zn0316w1rr" xml:space="preserve">[[Isimumathi:Thuso Mbedu talking in 2019 02.png|thumb|Isithombe sakaThuso Mbedu]]

U-Thuso Nokwanda Mbedu (owabelethwa mhla amalanga abunane ku-Velabahlinze ngonyaka we-1991) ungomunye wabadlali bakumabonwakude be-Sewula Afrika. Waduma khulu ngendima ayidlalako emdlalweni we-Sewula Afrika wabantu abatjha obizwa ngokobana yi-Sthunzi, lapho akhethwa khona ngokulandelana ukuthi athathe unongorwana wangaphetjheya obizwa nge- International Emmy ngonyaka wee-2017 kanye no-2018. U-Mbedu ekukhambeni kwesikhathi wavela ehlanganweni ebizwa ngokuthi yi- Forbes Africa 30 ngaphasi kwabantu abangaphasi kweminyaka ematjhumi amathathu ubudala ngonyaka wee-2018.

Ngonyaka wee-2021, wadlala ehlelweni elibizwa nge-Underground Railroad elitholakala kuAmazon Video, lapho kunamahlelo amanengi nekungilo elamenza bona abemdlali wokuthoma we-Sewula Afrika okhamba phambili kwezamahlelo adlala kumabonwakude we-America. Lokhu kwamenza bona athumbe unongorwana obizwa bona yi-Independent Spirit Award etholwa mumuntu wengubo okhamba phambili ngokuba mdlali wakumabonwakude ehlelweni elitjha. Waragela phambili waba ngomunye wabalingisi ehlelweni elimlando wangaphetjheya e-America obizwa ngokobana yi- The Woman King (2022) lapho adlala khona iskhundla saka Nawi.

=== IPILO YEBUNCANINI NEFUNDO ===
U-Mbedu wabelethelwa e-Midlands Medical Centre endaweni ye-Pietermaritzburg, KwaZulu-Natal. Ubelethwa ngumma okhuluma isiZulu kanye noyise okhuluma isiSotho nesiXhosa. Wakhuliswa e-Pelham ngugogo wakhe , owabamumuntu omtlhogomelako ngemva kokuhlongakalelwa babelethi bakhe bobabili asesemncani.

U-Mbedu wafunda e-Pelham Primary School bese waya e- Pietermaritzburg Girls' High School . &lt;ref&gt;{{Cite journal|url=https://www.news24.com/witness/news/from-pmb-to-the-worlds-tvs-20170129|title=From PMB to the world's TVs|journal=The Witness|first=Nompilo|last=Kunene|date=30 January 2017|access-date=21 October 2021}}&lt;/ref&gt; Waragela phambili nokufunda i-Physical Theatre kanye ne-Performing Arts Management e- University of the Witwatersrand (Wits), waphothula ngo-2013 ngama-honor, &lt;ref&gt;{{cite web|url=https://www.goodthingsguy.com/people/thuso-mbedu-underground-railroad/|title=Meet the first South African actress to lead an American series!!!|website=Good Things Guy|date=17 April 2019}}&lt;/ref&gt; ngemva kokuthatha ikhosi e- Stella Adler Studio of Acting e-New York City ngo-2012. &lt;ref&gt;{{cite web|url=http://www.youthvillage.co.za/2016/05/10-things-you-didnt-know-about-scandal-actress-thuso-mbedu/|title=10 Things You Didn't Know About Scandal Actress Thuso Mbedu|website=Youth Village|date=16 May 2016}}&lt;/ref&gt; &lt;ref name=&quot;:1&quot;&gt;{{Cite journal|url=https://www.timeslive.co.za/tshisa-live/tshisa-live/2020-09-28-i-had-no-clue-what-they-were-saying-thuso-mbedu-on-connecting-with-her-sotho-heritage/|title='I had no clue what they were saying'-Thuso Mbedu on connecting with her Sotho heritage|journal=Times Live|first=Deepika|last=Naidoo|date=28 September 2020|access-date=3 November 2021}}&lt;/ref&gt;

=== IBIZELO ===
Ekupheleni konyaka wee-2014, u-Mbedu waba nendima encani kusizini yesibili ye- Mzansi Magic soapie ''[[Isibaya]]'', ''&lt;ref name=&quot;:0&quot;&gt;{{Cite news|url=https://www.channel24.co.za/TV/News/thuso-mbedu-from-out-of-work-to-emmy-nominee-20180211|title=Thuso Mbedu: From out of work to Emmy nominee|work=Channel24|access-date=24 March 2018|language=en}}&lt;/ref&gt;'' ngaphambi kokuthi athole indima yakhe njengomfundi wezobuntatheli nomntwana u-Kitso ku ''-Scandal!'' . ''['' ''&lt;ref&gt;{{cite web|url=http://www.news24.com/MoveMag/Archive/thuso-mbedu-on-how-she-made-it-against-all-odds-20170728|title=Thuso Mbedu on how she made it against all odds|date=28 July 2017|work=[[News24 (website)|News24]]}}&lt;/ref&gt; &lt;ref&gt;{{Cite news|url=http://www.youthvillage.co.za/2016/05/10-things-you-didnt-know-about-scandal-actress-thuso-mbedu/|title=10 Things You Didn't Know About Scandal Actress Thuso Mbedu|date=16 May 2016|work=Youth Village|access-date=24 March 2018|language=en-US}}&lt;/ref&gt;''[[SABC 2|​]]  kanye nendima ephambili njengo-Boni Khumalo emdlalweni kamabonakude bbizwa kobana yi- ''Saints and Sinners.&lt;ref&gt;{{Cite news|last=Vieira|first=Genevieve|title=Thuso Mbedu is truly blessed|language=en|work=The Citizen|url=https://citizen.co.za/lifestyle/your-life-entertainment-your-life/entertainment-celebrities/316910/thuso-mbedu-is-truly-blessed/|access-date=24 March 2018}}&lt;/ref&gt;''

Ngemva kokungasebenzi iinyanga ezisithandathu, u-Mbedu wathola indima yakhe yokuthoma kumabonakude emdlalweni we -Mzansi Magic welutjha ''-Is'Thunzi'', owathoma ngoMgwengweni enyakeni wee-2016. &lt;ref name=&quot;:02&quot;&gt;{{Cite news|url=https://www.channel24.co.za/TV/News/thuso-mbedu-from-out-of-work-to-emmy-nominee-20180211|title=Thuso Mbedu: From out of work to Emmy nominee|work=Channel24|access-date=24 March 2018|language=en}}&lt;/ref&gt; &lt;ref&gt;{{Cite news|url=https://www.timeslive.co.za/tshisa-live/tshisa-live/2017-09-28-heres-5-things-you-need-to-know-about-actress-thuso-mbedu/|title=Here's 5 things you need to know about actress Thuso Mbedu|work=[[TimesLIVE]]|access-date=24 March 2018|language=en-US}}&lt;/ref&gt; Emdlalweni lo, wadlala indima ka-Winnie, umdlali othanda ukuzikhakhazisa, ofuna ukutjhada nomdlali we-rugby onjingileko nodumileko kodwana ibhudango lakhe liyatjhabalala lokha nakufanele akhambe ayokuhlala nokgharakhe obukhali e-Bergville. Lokha nakalingisa  isiqephu sokudlwengulwa emdlalweni, wahlaselwa livalo. &lt;ref&gt;{{Cite news|url=https://www.huffingtonpost.co.za/2017/11/13/thuso-mbedu-is-leaving-for-the-international-emmys-with-hope-for-south-africans_a_23275431/|title=Thuso Mbedu Is Leaving For The International Emmys With Hope For South Africans|date=13 November 2017|work=Huffington Post South Africa|access-date=24 March 2018|language=en-ZA}}&lt;/ref&gt; NgoNobayeni 2017, waphakanyiswa enongorwaneni we -International Emmy Award esigabeni sokudlala okuhle khulu komlingisi ngendima yakhe njengo-Winnie ku ''-Is'Thunzi'' &lt;ref&gt;{{Cite news|url=https://www.timeslive.co.za/tshisa-live/tshisa-live/2018-01-18-thuso-mbedu-on-life-after-emmy-nod-the-truth-is-we-are-very-dispensable/|title=Thuso Mbedu on life after Emmy nod: 'The truth is we are very dispensable'|work=Times LIVE|access-date=24 March 2018|language=en-US}}&lt;/ref&gt; begodu bekunguye kwaphela umuntu we Sewula-Afrika owaphakanyiswa ngalowo mnyaka. &lt;ref&gt;{{Cite news|url=https://www.iol.co.za/entertainment/celebrity-news/local/isthunzi-star-thuso-mbedu-nominated-for-emmy-award-11386771|title='Is'thunzi' star Thuso Mbedu nominated for #Emmy Award {{!}} IOL Entertainment|access-date=24 March 2018|language=en}}&lt;/ref&gt;

U-Mbedu wenza ukudlala kwakhe kokuthoma njengo-Cora kubemlando ngonyaka wee-2021 we-Amazon Video ''i-The Underground Railroad'', esekelwe enovelini enegama elifanako ka -Colson Whitehead begodu iqondiswe beyakhiqizwa ngomunye owathumba i -Academy Award u-Barry Jenkins . &lt;ref&gt;{{Cite web|last=Ramos|first=Dino-Ray|date=21 October 2020|title='The Underground Railroad' Teaser: Barry Jenkins Offers First Glimpse Of Thuso Mbedu As Cora In Amazon Limited Series|url=https://deadline.com/2020/10/the-underground-railroad-teaser-trailer-berry-jenkins-thuso-mbedu-as-cora-amazon-series-1234601236/|access-date=21 October 2020|website=Deadline|language=en-US}}&lt;/ref&gt; &lt;ref&gt;{{Cite web|title=Thuso Mbedu can't wait for viewers to see her new series with Barry Jenkins|url=https://www.news24.com/channel/tv/news/thuso-mbedu-cant-wait-for-viewers-to-see-her-new-series-with-barry-jenkins-20201020-2|access-date=21 October 2020|website=Channel|date=19 October 2020|language=en}}&lt;/ref&gt; UMbedu wathola i -Hollywood Critics Association Award, i- Independent Spirit Award, kanye ne -Gotham Award yomdlalo. &lt;ref&gt;{{Cite web|last=Ngwenya|first=Nkhensani|date=30 August 2021|title=Thuso Mbedu Walks Away With An International Award|url=https://surgezirc.co.za/2021-08-30-gossip-thuso-mbedu-walks-away-with-an-international-award/|access-date=30 August 2021|website=Surge Zirc SA|language=en-GB}}&lt;/ref&gt;

Ngenyanga kaMrhayili 2021, kwamenyezelwa bona uMbedu uzokwenza ifilimu yakhe yokuthoma njengo-Nawi aqalene no -Viola Davis ku- ''The Woman King'', ifilimu yomlando ephefumulelwe ngezehlakalo zamambala ezenzeka eMbusweni we-Dahomey, &lt;ref&gt;{{Cite web|last=Höffele|first=Lerato|title=Thuso Mbedu bags role alongside Viola Davis in 'The Woman King'|url=https://ewn.co.za/2021/04/29/thuso-mbedu-bags-role-alongside-viola-davis-in-the-woman-king|access-date=30 April 2021|website=ewn.co.za|language=en}}&lt;/ref&gt; omunye wemibuso enamandla khulu ye-Afrika ngekhulu le-18 nele-19. Ifilimu le beyiqondiswe ngu [[Gina Prince-Bythewood|-Gina Prince-Bythewood]], ukusuka emtlolweni womtloli we- ''Fatherhood'' u-Dana Stevens . &lt;ref name=&quot;Kroll&quot;&gt;{{Cite web|last=Kroll|first=Justin|date=28 April 2021|title='Underground Railroad's Thuso Mbedu To Star Opposite Viola Davis In 'The Woman King King'|url=https://deadline.com/2021/04/thuso-mbedu-viola-davis-woman-king-1234746073/|access-date=28 April 2021|website=Deadline|language=en-US}}&lt;/ref&gt; &lt;ref&gt;{{Cite web|last=Morkel|first=Graye|title=Thuso Mbedu to star opposite Viola Davis in The Woman King|url=https://www.news24.com/channel/movies/news/thuso-mbedu-to-star-opposite-viola-davis-in-the-woman-king-20210429|access-date=30 April 2021|website=Channel|language=en-US}}&lt;/ref&gt; &lt;ref&gt;{{Cite web|title=Africans making waves in Hollywood|url=https://www.sowetanlive.co.za/entertainment/2021-04-30-africans-making-waves-in-hollywood/|access-date=30 April 2021|website=SowetanLIVE|language=en-ZA}}&lt;/ref&gt;

Ngo-2023, u-Mbedu waba yinxusa nomkhulumeli we [[L'Oréal|-L'Oréal]] we-Sub-Saharan Africa. &lt;ref&gt;{{Cite web|title=The Woman King star Thuso Mbedu named L'Oréal Paris Brand Ambassador|url=https://cosmeticsbusiness.com/news/article_page/The_Woman_King_star_Thuso_Mbedu_named_LOreal_Paris_Brand_Ambassador/209187|access-date=23 June 2023|website=Cosmetics Business}}&lt;/ref&gt; &lt;ref&gt;{{Cite web|title=Thuso Mbedu named L'Oréal Paris brand ambassador|url=https://www.news24.com/life/arts-and-entertainment/celebrities/thuso-mbedu-named-loreal-paris-brand-ambassador-20230529|access-date=23 June 2023|website=News24}}&lt;/ref&gt; &lt;ref&gt;{{cite web|title=Thuso Mbedu: The infamous marathon cheats|url=https://curio.io/shows/retold/thuso-mbedu-the-not-quite-redemption-of-south-africas-infamous-ultra-marathon-cheats|website=Curio}}&lt;/ref&gt; NgoTjhirhweni 2025 ''i-Deadline'' yabika bona u-Mbedu ukhethwe indima ephambili kufilimu ezako ye-Paramount i- ''Children of Blood and Bone'' njengo-Zélie hlangana no -Viola Davis, u-Cynthia Erivo, u-Damson Idris, u-Amandla Stenberg, u- Idris Elba no- Tosin Cole . &lt;ref&gt;{{Cite web|last=Moorman|first=Taijuan|title=Star-studded 'Children of Blood and Bone' cast revealed: What we know so far|url=https://www.usatoday.com/story/entertainment/movies/2025/01/23/children-of-blood-and-bone-cast-amandla-stenberg/77900352007/#:~:text=Star-studded%20'Children%20of%20Blood,What%20we%20know%20so%20far&amp;text=Anticipation%20is%20growing%20for%20the,those%20powers%20to%20her%20people.|access-date=2025-02-06|website=USA TODAY|language=en-US}}&lt;/ref&gt;

=== Imithombo lwazi ===

&lt;references /&gt;</text>
      <sha1>7twtdgbdjf1z2vd31p8u8zn0316w1rr</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Nabungela/Shandesh</title>
    <ns>2</ns>
    <id>900</id>
    <revision>
      <id>5420</id>
      <timestamp>2025-09-03T21:42:11Z</timestamp>
      <contributor>
        <username>Nabungela</username>
        <id>885</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1304603443|Shandesh]]&quot;</comment>
      <origin>5420</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4542" sha1="bwh0lboeq9vyke4zjs0yhmty1zim26c" xml:space="preserve">
'''''Shandesh''''' 

Rakgoale Nelly Machete

'''Wabelethwa''': 24 January 2004 (Iminyaka ematjhumi amabili nambili) Ga-Modjadji, Mohlabaneng, Limpopo eSewula Afrika.

'''Isihlalo: Umvumi'''

'''Iminyaka athoma ngawo''': 2018-bekube semnyakeni wanje

'''Ibizelo lomvumo'''

'''Indabuko yakhe''': Solomondale, Limpopo

'''Igenre''': Lekompo

'''Ama-instrumenti''': Ivokhali

'''Amaleyibula''' Shandesh Music-Virgin Active


'''U-Rakgoale Nelly Machete''' (wabelethwa mhlana ama-24 kuTjhirhweni 2004) umvumi [[Isewula Afrika|weSewula Afrika]] owaziwa ngo- '''Shandesh''' . Wathoma ukuhlonitjhwa ngo-2018 ngemva kokukhutjhwa kwengoma yakhe yokuthoma &quot;Lomolo&quot;. Iingoma zakhe ezithi &quot;Ga Mmapula&quot; kanye ne-&quot;Sdudla or Slender&quot; ziqinisekiswe ngegolide neplatinamu, ngokulandelana eSewula Afrika.

== Ipilo yokuthoma ==
Wabelethwa mhlana amalanga ama-24 kuTjhirhweni 2004,  e -Ga-Modjadji, endaweni eyaziwa nge Mohlabaneng, [[Limpopo|esifundazweni se-Limpopo]] seSewula Afrika begodu wakhulela e-Solomonidale, khona e-Limpopo,  u-Rakgoale Nelly Machete waziwa khulu ngo-Shandesh. 

== Ibizelo ==
Wathoma ikhambo lakhe lomvumo ngebanga lesine lokha nakajoyina ikhwaya yesonto neyesikolo. Nakakhuluma nomagazini ''we-DRUM'', wathi wathoma ukurekhoda umvumo ngokweprofetjhinali lokha nakasebangeni lesificaminwembili ngo-2018,  aneminyaka eli-14. &lt;ref name=&quot;News24&quot; /&gt; u-Shandesh wathola ukuhlonitjhwa ngemva kokukhutjhwa kwengoma yakhe yokuthoma &quot;Lomolo&quot; eyathola ama-gigs wakhe edorobheni lakubo.  Wasebenza nabantu abafana no -King Monada no -Shebeshxt . 

Ngomnyaka ka-2025, nomkhiqizi wamarekhodi weSewula Afrika u-Mvzzle, wakhipha i-&quot;Sdudla nofana i-Slender&quot; eyafika endaweni yesibili kumatjhadi weSewula Afrika asemthethweni (i-TOSAC).  Ngalowo mnyaka, laba ababili baragela phambili nokukhipha i-&quot;Di Chopper&quot; eyathoma ukuvela endaweni yesihlanu ku-TOSAC, &quot;i-Ga Mmapula&quot; yafikelela endaweni yamatjhumi amathuthu nambili ngeveke yetjhumi nesithatndathu. &lt;ref name=&quot;TOSAC&quot; /&gt;Wathola iplakhi yokukhumbula ipumelelo yakhe ethi &quot;i-Ga Mmapula&quot; beyiqinisekiswe njengegolide begodu i-&quot;Sdudla nofana i-Sdulender&quot; beyiqinisekiswe ngeplatinamu eSewula Afrika ngeRekhodi Ibubulo leSewula Afrika . 

U-Shandesh godu uhlela ukuthoma i-Rakgoale Foundation, ihlangano yokusiza abantwana abatlhagako ngamaphasela wokudla, amathawula wokuhlanza kanye neenyathelo zesikolo. 

== I-Discography ==

=== Imidlalo enabileko ===

* ''Mphoentle'' (2022)
* ''Okuhlukahlukeneko'' (2024)

=== Iingoma ezitjhadiweko ===

==== Njengomdwebi odosa phambili ====
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+Irhelo lama-single njengabaculi abadosa phambili, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iintifikeyti
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | SA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; 
|-
! scope=&quot;row&quot; | &quot;I-Sdudla nofana i-Slender&quot; (with -Mvzzle )
| rowspan=&quot;7&quot; | 2025
| 2
| RiSA : Iplatinamu | {{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Di Chopper&quot; (with Mvzzle, featuring Abi wa Mampela and Naleboy Young King)
| 5
|| {{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ga Mmapula&quot; (featuring Hitboss)
| 32
| I-RiSA: Igolide &lt;ref name=&quot;Bona&quot; /&gt;| {{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Isiyeleliso&quot; (featuring u-Shebeshxt, u-King Salah no-KayCherlow)
| 14
|| {{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Mamenemene&quot; (with DJ Janisto and King Salah)
| 39
|| {{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ipasipoti&quot; (with Mvzzle)
| 36
|| {{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Tshwara Tlhogo&quot; (featuring Abi wa Mampela and Hitboss SA)
| 57 
|| {{non-album single}}
|}

==== Njengomdwebi wesivakatjhi ====
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+Irhelo lama-single njengabaculi abaveziweko, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iintifikeyketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | SA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; 
|-
! scope=&quot;row&quot; | &quot;Shapa Bell&quot; (Naleboy Young King featuring Shandesh and King WaveMusiq)
| 2025
| 34 
|| {{non-album single}}
|}

== Amarefarensi ==</text>
      <sha1>bwh0lboeq9vyke4zjs0yhmty1zim26c</sha1>
    </revision>
    <revision>
      <id>5428</id>
      <parentid>5420</parentid>
      <timestamp>2025-09-03T22:57:39Z</timestamp>
      <contributor>
        <username>Nabungela</username>
        <id>885</id>
      </contributor>
      <comment>Shandesh</comment>
      <origin>5428</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4547" sha1="2qg07dflk9k8lohh8ap1d0k96vgvrmg" xml:space="preserve">
'''''Shandesh''''' 

Rakgoale Nelly Machete

'''Wabelethwa''': 24 January 2004 (Iminyaka ematjhumi amabili nambili) Ga-Modjadji, Mohlabaneng, Limpopo eSewula Afrika.

'''Isihlalo: Umvumi'''

'''Iminyaka athoma ngawo''': 2018-bekube semnyakeni wanje     

'''Ibizelo lomvumo'''

'''Indabuko yakhe''': Solomondale, Limpopo

'''Igenre''': Lekompo

'''Ama-instrumenti''': Ivokhali

'''Amaleyibula''' Shandesh Music-Virgin Active


'''U-Rakgoale Nelly Machete''' (wabelethwa mhlana ama-24 kuTjhirhweni 2004) umvumi [[Isewula Afrika|weSewula Afrika]] owaziwa ngo- '''Shandesh''' . Wathoma ukuhlonitjhwa ngo-2018 ngemva kokukhutjhwa kwengoma yakhe yokuthoma &quot;Lomolo&quot;. Iingoma zakhe ezithi &quot;Ga Mmapula&quot; kanye ne-&quot;Sdudla or Slender&quot; ziqinisekiswe ngegolide neplatinamu, ngokulandelana eSewula Afrika.

== Ipilo yokuthoma ==
Wabelethwa mhlana amalanga ama-24 kuTjhirhweni 2004,  e -Ga-Modjadji, endaweni eyaziwa nge Mohlabaneng, [[Limpopo|esifundazweni se-Limpopo]] seSewula Afrika begodu wakhulela e-Solomonidale, khona e-Limpopo,  u-Rakgoale Nelly Machete waziwa khulu ngo-Shandesh. 

== Ibizelo ==
Wathoma ikhambo lakhe lomvumo ngebanga lesine lokha nakajoyina ikhwaya yesonto neyesikolo. Nakakhuluma nomagazini ''we-DRUM'', wathi wathoma ukurekhoda umvumo ngokweprofetjhinali lokha nakasebangeni lesificaminwembili ngo-2018,  aneminyaka eli-14. &lt;ref name=&quot;News24&quot; /&gt; u-Shandesh wathola ukuhlonitjhwa ngemva kokukhutjhwa kwengoma yakhe yokuthoma &quot;Lomolo&quot; eyathola ama-gigs wakhe edorobheni lakubo.  Wasebenza nabantu abafana no -King Monada no -Shebeshxt . 

Ngomnyaka ka-2025, nomkhiqizi wamarekhodi weSewula Afrika u-Mvzzle, wakhipha i-&quot;Sdudla nofana i-Slender&quot; eyafika endaweni yesibili kumatjhadi weSewula Afrika asemthethweni (i-TOSAC).  Ngalowo mnyaka, laba ababili baragela phambili nokukhipha i-&quot;Di Chopper&quot; eyathoma ukuvela endaweni yesihlanu ku-TOSAC, &quot;i-Ga Mmapula&quot; yafikelela endaweni yamatjhumi amathuthu nambili ngeveke yetjhumi nesithatndathu. &lt;ref name=&quot;TOSAC&quot; /&gt;Wathola iplakhi yokukhumbula ipumelelo yakhe ethi &quot;i-Ga Mmapula&quot; beyiqinisekiswe njengegolide begodu i-&quot;Sdudla nofana i-Sdulender&quot; beyiqinisekiswe ngeplatinamu eSewula Afrika ngeRekhodi Ibubulo leSewula Afrika . 

U-Shandesh godu uhlela ukuthoma i-Rakgoale Foundation, ihlangano yokusiza abantwana abatlhagako ngamaphasela wokudla, amathawula wokuhlanza kanye neenyathelo zesikolo. 

== I-Discography ==

=== Imidlalo enabileko ===

* ''Mphoentle'' (2022)
* ''Okuhlukahlukeneko'' (2024)

=== Iingoma ezitjhadiweko ===

==== Njengomdwebi odosa phambili ====
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+Irhelo lama-single njengabaculi abadosa phambili, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iintifikeyti
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | SA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; 
|-
! scope=&quot;row&quot; | &quot;I-Sdudla nofana i-Slender&quot; (with -Mvzzle )
| rowspan=&quot;7&quot; | 2025
| 2
| RiSA : Iplatinamu | {{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Di Chopper&quot; (with Mvzzle, featuring Abi wa Mampela and Naleboy Young King)
| 5
|| {{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ga Mmapula&quot; (featuring Hitboss)
| 32
| I-RiSA: Igolide &lt;ref name=&quot;Bona&quot; /&gt;| {{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Isiyeleliso&quot; (featuring u-Shebeshxt, u-King Salah no-KayCherlow)
| 14
|| {{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Mamenemene&quot; (with DJ Janisto and King Salah)
| 39
|| {{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ipasipoti&quot; (with Mvzzle)
| 36
|| {{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Tshwara Tlhogo&quot; (featuring Abi wa Mampela and Hitboss SA)
| 57 
|| {{non-album single}}
|}

==== Njengomdwebi wesivakatjhi ====
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+Irhelo lama-single njengabaculi abaveziweko, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iintifikeyketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | SA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; 
|-
! scope=&quot;row&quot; | &quot;Shapa Bell&quot; (Naleboy Young King featuring Shandesh and King WaveMusiq)
| 2025
| 34 
|| {{non-album single}}
|}

== Amarefarensi ==</text>
      <sha1>2qg07dflk9k8lohh8ap1d0k96vgvrmg</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Pholap/Page 3</title>
    <ns>2</ns>
    <id>901</id>
    <revision>
      <id>5422</id>
      <timestamp>2025-09-03T21:52:11Z</timestamp>
      <contributor>
        <username>Pholap</username>
        <id>883</id>
      </contributor>
      <comment>Created 3 draft space</comment>
      <origin>5422</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="21" sha1="m77cqvnm3yvmr1kbewu39fhrfvnguw9" xml:space="preserve">Page 3: Draft space 3</text>
      <sha1>m77cqvnm3yvmr1kbewu39fhrfvnguw9</sha1>
    </revision>
    <revision>
      <id>5432</id>
      <parentid>5422</parentid>
      <timestamp>2025-09-04T06:36:43Z</timestamp>
      <contributor>
        <username>Pholap</username>
        <id>883</id>
      </contributor>
      <comment>created a article</comment>
      <origin>5432</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2461" sha1="jabo8w7dayyvan3grvpm1wzzn3c9pbx" xml:space="preserve">== '''&lt;big&gt;I-Enactus ye-Yunivesithi ye-Mpumalanga&lt;/big&gt;''' ==

== I-Enactus ye-Yunivesithi ye-Mpumalanga mtjhayeli weentjhabatjhaba weSewula Afrika we-2025 ku-Enactus National Competition. Isiqhema siyingcenye ye-Enactus South Africa, ihlangano engenzi inzuzo ehlanganisa abafundi beyunivesithi, iimfundiswa, nabadosiphambili bamabhizinisi ngamaphrojekthi asekelwe emabhizinisini ahloselwe ukwenza umthelela omuhle emphakathini. ==

== '''Isendlalelo''' ==

== I-Enactus South Africa isebenza ngaphasi kwenethiwekhi ye-Enactus yephasi loke, esebenza emazweni angaphezu kwama-30. Ihlangano le inikela abafundi indawo yokuklama nokusebenzisa amaphrojekthi womphakathi ahlanganisa ukusungulwa kwebhizinisi nokuziphendulela emphakathini. ==

== Isiqhema seYunivesithi ye-Mpumalanga sibe mhlanganyeli okhutheleko emncintiswaneni weentjhabatjhaba, sidzimelele eenhlelweni zentuthuko esimemeko kanye namaphrojekthi wobusomabhizinisi akhambisana neendingo zomphakathi wendawo. ==

== '''2025 Umqhudelwano weNarha''' ==

== Ngenyanga kaRhoboyi wee-2025, iYunivesithi ye-Mpumalanga yakhethwa njengeTjhugululi yeNarha emncintiswaneni weNarha we-Enactus South Africa. Ipumelelo yabo yagujwa begodu ngokukhamba kwesikhathi yavezwa ku-IsiNdebele News ku-SABC 1, kuveza amaphrojekthi neminikelo yesiqhema. ==

== Ihlelo elivezwe kumabonakude ligcizelele indlela yokwenza izinto ezitjha zesiqhema kanye nomnqopho omkhulu we-Enactus wokukhuthaza uburholi bamabhizinisi hlangana nelutjha leSewula Afrika. ==

== '''Ukuqakatheka''' ==

== Ukuthumba umncintiswano weentjhabatjhaba kwenza bona isiqhema seYunivesithi ye-Mpumalanga sikwazi ukujamela iSewula Afrika eNdebeni yePhasi ye-Enactus, iplatifomu yamazwe ngamazwe lapho amathimu wabafundi aveza khona amaphrojekthi wawo wamabhizinisi ebantwini bephasi loke babadosiphambili bamabhizinisi, abafundisi, nabontanga. ==

== Ukuhlonitjhwa lokhu kuveza idumela elikhulako leyunivesithi emkhakheni wezamabhizinisi wezenhlalakahle nokuthuthukisa umphakathi. ==

== '''Qala godu''' ==

== Enactus South Africa ==

== Enactus World Cup ==

== University of Mpumalanga ==
'''Umthombo welwazi'''

# Enactus South Africa. (2025, August 14). ''Proudly in the News! Enactus South Africa was featured on IsiNdebele News on SABC 1, celebrating the remarkable journey of our 2025 National Champion – Enactus University of Mpumalanga.'' X (formerly Twitter). Retrieved from &lt;nowiki&gt;https://x.com/enactusZA/status/1955940496150303014&lt;/nowiki&gt;.</text>
      <sha1>jabo8w7dayyvan3grvpm1wzzn3c9pbx</sha1>
    </revision>
    <revision>
      <id>5453</id>
      <parentid>5432</parentid>
      <timestamp>2025-09-04T07:58:25Z</timestamp>
      <contributor>
        <username>Pholap</username>
        <id>883</id>
      </contributor>
      <minor />
      <origin>5453</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2448" sha1="p3kqagvcssc3p3gnxw1th4rfnbswcxd" xml:space="preserve">== '''&lt;big&gt;I-Enactus ye-Yunivesithi ye-Mpumalanga&lt;/big&gt;''' ==

== I-Enactus ye-Yunivesithi ye-Mpumalanga mtjhayeli weentjhabatjhaba weSewula Afrika we-2025 ku-Enactus National Competition. Isiqhema siyingcenye ye-Enactus South Africa, ihlangano engenzi inzuzo ehlanganisa abafundi beyunivesithi, iimfundiswa, nabadosiphambili bamabhizinisi ngamaphrojekthi asekelwe emabhizinisini ahloselwe ukwenza umthelela omuhle emphakathini. ==

== '''Isendlalelo''' ==

== I-Enactus South Africa isebenza ngaphasi kwenethiwekhi ye-Enactus yephasi loke, esebenza emazweni angaphezu kwama-30. Ihlangano le inikela abafundi indawo yokuklama nokusebenzisa amaphrojekthi womphakathi ahlanganisa ukusungulwa kwebhizinisi nokuziphendulela emphakathini. ==

== Isiqhema seYunivesithi ye-Mpumalanga sibe mhlanganyeli okhutheleko emncintiswaneni weentjhabatjhaba, sidzimelele eenhlelweni zentuthuko esimemeko kanye namaphrojekthi wobusomabhizinisi akhambisana neendingo zomphakathi wendawo. ==

== '''2025 Umqhudelwano weNarha''' ==

== Ngenyanga kaRhoboyi wee-2025, iYunivesithi ye-Mpumalanga yakhethwa njengeTjhugululi yeNarha emncintiswaneni weNarha we-Enactus South Africa. Ipumelelo yabo yagujwa begodu ngokukhamba kwesikhathi yavezwa ku-IsiNdebele News ku-SABC 1, kuveza amaphrojekthi neminikelo yesiqhema. ==

== Ihlelo elivezwe kumabonakude ligcizelele indlela yokwenza izinto ezitjha zesiqhema kanye nomnqopho omkhulu we-Enactus wokukhuthaza uburholi bamabhizinisi hlangana nelutjha leSewula Afrika. ==

== '''Ukuqakatheka''' ==

== Ukuthumba umncintiswano weentjhabatjhaba kwenza bona isiqhema seYunivesithi ye-Mpumalanga sikwazi ukujamela iSewula Afrika eNdebeni yePhasi ye-Enactus, iplatifomu yamazwe ngamazwe lapho amathimu wabafundi aveza khona amaphrojekthi wawo wamabhizinisi ebantwini bephasi loke babadosiphambili bamabhizinisi, abafundisi, nabontanga. ==

== Ukuhlonitjhwa lokhu kuveza idumela elikhulako leyunivesithi emkhakheni wezamabhizinisi wezenhlalakahle nokuthuthukisa umphakathi. ==

== '''Qala godu''' ==
Enactus South Africa

Enactus World Cup

University of Mpumalanga

== '''Umthombo welwazi''' ==
# Enactus South Africa. (2025, August 14). ''Proudly in the News! Enactus South Africa was featured on IsiNdebele News on SABC 1, celebrating the remarkable journey of our 2025 National Champion – Enactus University of Mpumalanga.'' X (formerly Twitter). Retrieved from &lt;nowiki&gt;https://x.com/enactusZA/status/1955940496150303014&lt;/nowiki&gt;.</text>
      <sha1>p3kqagvcssc3p3gnxw1th4rfnbswcxd</sha1>
    </revision>
    <revision>
      <id>5511</id>
      <parentid>5453</parentid>
      <timestamp>2025-09-04T09:17:13Z</timestamp>
      <contributor>
        <username>Pholap</username>
        <id>883</id>
      </contributor>
      <minor />
      <origin>5511</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2648" sha1="12hw1akup32fbahnh12nk3liwsba7sw" xml:space="preserve">[[Isimumathi:UMP Enactus.png|thumb|UMP Enactus]]

== '''&lt;big&gt;I-Enactus ye-Yunivesithi ye-Mpumalanga&lt;/big&gt;''' ==

== I-Enactus ye-Yunivesithi ye-Mpumalanga mtjhayeli weentjhabatjhaba weSewula Afrika we-2025 ku-Enactus National Competition.&lt;ref&gt;[https://www.ump.ac.za/News-and-Events/News/2025/UMP-WINS-THE-2025-ENACTUS-SA-CHAMPIONSHIP UMP - UMP WINS THE 2025 ENACTUS SA CHAMPIONSHIP]&lt;/ref&gt; Isiqhema siyingcenye ye-Enactus South Africa, ihlangano engenzi inzuzo ehlanganisa abafundi beyunivesithi, iimfundiswa, nabadosiphambili bamabhizinisi ngamaphrojekthi asekelwe emabhizinisini ahloselwe ukwenza umthelela omuhle emphakathini. ==

== '''Isendlalelo''' ==

== I-Enactus South Africa isebenza ngaphasi kwenethiwekhi ye-Enactus yephasi loke, esebenza emazweni angaphezu kwama-30. Ihlangano le inikela abafundi indawo yokuklama nokusebenzisa amaphrojekthi womphakathi ahlanganisa ukusungulwa kwebhizinisi nokuziphendulela emphakathini. ==

== Isiqhema seYunivesithi ye-Mpumalanga sibe mhlanganyeli okhutheleko emncintiswaneni weentjhabatjhaba, sidzimelele eenhlelweni zentuthuko esimemeko kanye namaphrojekthi wobusomabhizinisi akhambisana neendingo zomphakathi wendawo. ==

== '''2025 Umqhudelwano weNarha''' ==

== Ngenyanga kaRhoboyi wee-2025, iYunivesithi ye-Mpumalanga yakhethwa njengeTjhugululi yeNarha emncintiswaneni weNarha we-Enactus South Africa. Ipumelelo yabo yagujwa begodu ngokukhamba kwesikhathi yavezwa ku-IsiNdebele News ku-SABC 1, kuveza amaphrojekthi neminikelo yesiqhema. ==

== Ihlelo elivezwe kumabonakude ligcizelele indlela yokwenza izinto ezitjha zesiqhema kanye nomnqopho omkhulu we-Enactus wokukhuthaza uburholi bamabhizinisi hlangana nelutjha leSewula Afrika. ==

== '''Ukuqakatheka''' ==

== Ukuthumba umncintiswano weentjhabatjhaba kwenza bona isiqhema seYunivesithi ye-Mpumalanga sikwazi ukujamela iSewula Afrika eNdebeni yePhasi ye-Enactus, iplatifomu yamazwe ngamazwe lapho amathimu wabafundi aveza khona amaphrojekthi wawo wamabhizinisi ebantwini bephasi loke babadosiphambili bamabhizinisi, abafundisi, nabontanga. ==

== Ukuhlonitjhwa lokhu kuveza idumela elikhulako leyunivesithi emkhakheni wezamabhizinisi wezenhlalakahle nokuthuthukisa umphakathi. ==

== '''Qala godu''' ==
Enactus South Africa

Enactus World Cup

University of Mpumalanga

== '''Umthombo welwazi''' ==
# Enactus South Africa. (2025, August 14). ''Proudly in the News! Enactus South Africa was featured on IsiNdebele News on SABC 1, celebrating the remarkable journey of our 2025 National Champion – Enactus University of Mpumalanga.'' X (formerly Twitter). Retrieved from &lt;nowiki&gt;https://x.com/enactusZA/status/1955940496150303014&lt;/nowiki&gt;.</text>
      <sha1>12hw1akup32fbahnh12nk3liwsba7sw</sha1>
    </revision>
    <revision>
      <id>5523</id>
      <parentid>5511</parentid>
      <timestamp>2025-09-04T09:23:32Z</timestamp>
      <contributor>
        <username>Pholap</username>
        <id>883</id>
      </contributor>
      <minor />
      <origin>5523</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2878" sha1="eyowss0rc18w85r2ln80zt0a34svsgu" xml:space="preserve">[[Isimumathi:UMP Enactus.png|thumb|UMP Enactus]]

== '''&lt;big&gt;I-Enactus ye-Yunivesithi ye-Mpumalanga&lt;/big&gt;''' ==

== I-Enactus ye-Yunivesithi ye-Mpumalanga mtjhayeli weentjhabatjhaba weSewula Afrika we-2025 ku-Enactus National Competition.&lt;ref&gt;[https://www.ump.ac.za/News-and-Events/News/2025/UMP-WINS-THE-2025-ENACTUS-SA-CHAMPIONSHIP UMP - UMP WINS THE 2025 ENACTUS SA CHAMPIONSHIP]&lt;/ref&gt; Isiqhema siyingcenye ye-Enactus South Africa, ihlangano engenzi inzuzo ehlanganisa abafundi beyunivesithi, iimfundiswa, nabadosiphambili bamabhizinisi ngamaphrojekthi asekelwe emabhizinisini ahloselwe ukwenza umthelela omuhle emphakathini. ==

== '''Isendlalelo''' ==

== I-Enactus South Africa isebenza ngaphasi kwenethiwekhi ye-Enactus yephasi loke, esebenza emazweni angaphezu kwama-30. Ihlangano le inikela abafundi indawo yokuklama nokusebenzisa amaphrojekthi womphakathi ahlanganisa ukusungulwa kwebhizinisi nokuziphendulela emphakathini. ==

== Isiqhema seYunivesithi ye-Mpumalanga sibe mhlanganyeli okhutheleko emncintiswaneni weentjhabatjhaba, sidzimelele eenhlelweni zentuthuko esimemeko kanye namaphrojekthi wobusomabhizinisi akhambisana neendingo zomphakathi wendawo. ==

== '''2025 Umqhudelwano weNarha''' ==

== Ngenyanga kaRhoboyi wee-2025, iYunivesithi ye-Mpumalanga yakhethwa njengeTjhugululi yeNarha emncintiswaneni weNarha we-Enactus South Africa. Ipumelelo yabo yagujwa begodu ngokukhamba kwesikhathi yavezwa ku-IsiNdebele News ku-SABC 1, kuveza amaphrojekthi neminikelo yesiqhema.&lt;ref&gt;[https://www.sabcnews.com/sabcnews/ Official SABC News - SABC News - Breaking news, special reports, world, business, sport coverage of all South African current events. Africa's news leader.]&lt;/ref&gt; ==

== Ihlelo elivezwe kumabonakude ligcizelele indlela yokwenza izinto ezitjha zesiqhema kanye nomnqopho omkhulu we-Enactus wokukhuthaza uburholi bamabhizinisi hlangana nelutjha leSewula Afrika. ==

== '''Ukuqakatheka''' ==

== Ukuthumba umncintiswano weentjhabatjhaba kwenza bona isiqhema [[Yunivesithi yempulanga|seYunivesithi ye-Mpumalanga]] sikwazi ukujamela iSewula Afrika eNdebeni yePhasi ye-Enactus, iplatifomu yamazwe ngamazwe lapho amathimu wabafundi aveza khona amaphrojekthi wawo wamabhizinisi ebantwini bephasi loke babadosiphambili bamabhizinisi, abafundisi, nabontanga. ==

== Ukuhlonitjhwa lokhu kuveza idumela elikhulako leyunivesithi emkhakheni wezamabhizinisi wezenhlalakahle nokuthuthukisa umphakathi. ==

== '''Qala godu''' ==
Enactus South Africa

Enactus World Cup

University of Mpumalanga

== '''Umthombo welwazi''' ==
# Enactus South Africa. (2025, August 14). ''Proudly in the News! Enactus South Africa was featured on IsiNdebele News on SABC 1, celebrating the remarkable journey of our 2025 National Champion – Enactus University of Mpumalanga.'' X (formerly Twitter). Retrieved from &lt;nowiki&gt;https://x.com/enactusZA/status/1955940496150303014&lt;/nowiki&gt;.</text>
      <sha1>eyowss0rc18w85r2ln80zt0a34svsgu</sha1>
    </revision>
    <revision>
      <id>5530</id>
      <parentid>5523</parentid>
      <timestamp>2025-09-04T09:25:59Z</timestamp>
      <contributor>
        <username>Pholap</username>
        <id>883</id>
      </contributor>
      <minor />
      <origin>5530</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2897" sha1="041raf54erkddujmqzubtap5n527ads" xml:space="preserve">[[Isimumathi:UMP Enactus.png|thumb|UMP Enactus]]

== '''&lt;big&gt;I-Enactus ye-Yunivesithi ye-Mpumalanga&lt;/big&gt;''' ==

== I-Enactus ye-Yunivesithi ye-Mpumalanga mtjhayeli weentjhabatjhaba weSewula Afrika we-2025 ku-Enactus National Competition.&lt;ref&gt;[https://www.ump.ac.za/News-and-Events/News/2025/UMP-WINS-THE-2025-ENACTUS-SA-CHAMPIONSHIP UMP - UMP WINS THE 2025 ENACTUS SA CHAMPIONSHIP]&lt;/ref&gt; Isiqhema siyingcenye ye-Enactus [[Isewula Afrika|South Africa]], ihlangano engenzi inzuzo ehlanganisa abafundi beyunivesithi, iimfundiswa, nabadosiphambili bamabhizinisi ngamaphrojekthi asekelwe emabhizinisini ahloselwe ukwenza umthelela omuhle emphakathini. ==

== '''Isendlalelo''' ==

== I-Enactus South Africa isebenza ngaphasi kwenethiwekhi ye-Enactus yephasi loke, esebenza emazweni angaphezu kwama-30. Ihlangano le inikela abafundi indawo yokuklama nokusebenzisa amaphrojekthi womphakathi ahlanganisa ukusungulwa kwebhizinisi nokuziphendulela emphakathini. ==

== Isiqhema seYunivesithi ye-Mpumalanga sibe mhlanganyeli okhutheleko emncintiswaneni weentjhabatjhaba, sidzimelele eenhlelweni zentuthuko esimemeko kanye namaphrojekthi wobusomabhizinisi akhambisana neendingo zomphakathi wendawo. ==

== '''2025 Umqhudelwano weNarha''' ==

== Ngenyanga kaRhoboyi wee-2025, iYunivesithi ye-Mpumalanga yakhethwa njengeTjhugululi yeNarha emncintiswaneni weNarha we-Enactus South Africa. Ipumelelo yabo yagujwa begodu ngokukhamba kwesikhathi yavezwa ku-IsiNdebele News ku-SABC 1, kuveza amaphrojekthi neminikelo yesiqhema.&lt;ref&gt;[https://www.sabcnews.com/sabcnews/ Official SABC News - SABC News - Breaking news, special reports, world, business, sport coverage of all South African current events. Africa's news leader.]&lt;/ref&gt; ==

== Ihlelo elivezwe kumabonakude ligcizelele indlela yokwenza izinto ezitjha zesiqhema kanye nomnqopho omkhulu we-Enactus wokukhuthaza uburholi bamabhizinisi hlangana nelutjha leSewula Afrika. ==

== '''Ukuqakatheka''' ==

== Ukuthumba umncintiswano weentjhabatjhaba kwenza bona isiqhema [[Yunivesithi yempulanga|seYunivesithi ye-Mpumalanga]] sikwazi ukujamela iSewula Afrika eNdebeni yePhasi ye-Enactus, iplatifomu yamazwe ngamazwe lapho amathimu wabafundi aveza khona amaphrojekthi wawo wamabhizinisi ebantwini bephasi loke babadosiphambili bamabhizinisi, abafundisi, nabontanga. ==

== Ukuhlonitjhwa lokhu kuveza idumela elikhulako leyunivesithi emkhakheni wezamabhizinisi wezenhlalakahle nokuthuthukisa umphakathi. ==

== '''Qala godu''' ==
Enactus South Africa

Enactus World Cup

University of Mpumalanga

== '''Umthombo welwazi''' ==
# Enactus South Africa. (2025, August 14). ''Proudly in the News! Enactus South Africa was featured on IsiNdebele News on SABC 1, celebrating the remarkable journey of our 2025 National Champion – Enactus University of Mpumalanga.'' X (formerly Twitter). Retrieved from &lt;nowiki&gt;https://x.com/enactusZA/status/1955940496150303014&lt;/nowiki&gt;.</text>
      <sha1>041raf54erkddujmqzubtap5n527ads</sha1>
    </revision>
    <revision>
      <id>5569</id>
      <parentid>5530</parentid>
      <timestamp>2025-09-04T09:48:54Z</timestamp>
      <contributor>
        <username>Pholap</username>
        <id>883</id>
      </contributor>
      <minor />
      <origin>5569</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2569" sha1="c9v3m341kghhlw6tmyknufypueczbnw" xml:space="preserve">[[Isimumathi:UMP Enactus.png|thumb|UMP Enactus]]

== '''&lt;big&gt;I-Enactus ye-Yunivesithi ye-Mpumalanga&lt;/big&gt;''' ==

== I-Enactus ye-Yunivesithi ye-Mpumalanga mtjhayeli weentjhabatjhaba weSewula Afrika we-2025 ku-Enactus National Competition.&lt;ref&gt;[https://www.ump.ac.za/News-and-Events/News/2025/UMP-WINS-THE-2025-ENACTUS-SA-CHAMPIONSHIP UMP - UMP WINS THE 2025 ENACTUS SA CHAMPIONSHIP]&lt;/ref&gt; Isiqhema siyingcenye ye-Enactus [[Isewula Afrika|South Africa]], ihlangano engenzi inzuzo ehlanganisa abafundi beyunivesithi, iimfundiswa, nabadosiphambili bamabhizinisi ngamaphrojekthi asekelwe emabhizinisini ahloselwe ukwenza umthelela omuhle emphakathini. ==

== '''Isendlalelo''' ==

== [[I-Enactus]] South Africa isebenza ngaphasi kwenethiwekhi ye-Enactus yephasi loke, esebenza emazweni angaphezu kwama-30. Ihlangano le inikela abafundi indawo yokuklama nokusebenzisa amaphrojekthi womphakathi ahlanganisa ukusungulwa kwebhizinisi nokuziphendulela emphakathini. ==

== Isiqhema seYunivesithi ye-Mpumalanga sibe mhlanganyeli okhutheleko emncintiswaneni weentjhabatjhaba, sidzimelele eenhlelweni zentuthuko esimemeko kanye namaphrojekthi wobusomabhizinisi akhambisana neendingo zomphakathi wendawo. ==

== '''2025 Umqhudelwano weNarha''' ==

== Ngenyanga kaRhoboyi wee-2025, iYunivesithi ye-Mpumalanga yakhethwa njengeTjhugululi yeNarha emncintiswaneni weNarha we-Enactus South Africa. Ipumelelo yabo yagujwa begodu ngokukhamba kwesikhathi yavezwa ku-IsiNdebele News ku-[[SABC|SABC 1]], kuveza amaphrojekthi neminikelo yesiqhema.&lt;ref&gt;[https://www.sabcnews.com/sabcnews/ Official SABC News - SABC News - Breaking news, special reports, world, business, sport coverage of all South African current events. Africa's news leader.]&lt;/ref&gt; ==

== Ihlelo elivezwe kumabonakude ligcizelele indlela yokwenza izinto ezitjha zesiqhema kanye nomnqopho omkhulu we-Enactus wokukhuthaza uburholi bamabhizinisi hlangana nelutjha leSewula Afrika. ==

== '''Ukuqakatheka''' ==

== Ukuthumba umncintiswano weentjhabatjhaba kwenza bona isiqhema [[Yunivesithi yempulanga|seYunivesithi ye-Mpumalanga]] sikwazi ukujamela iSewula Afrika eNdebeni yePhasi ye-Enactus, iplatifomu yamazwe ngamazwe lapho amathimu wabafundi aveza khona amaphrojekthi wawo wamabhizinisi ebantwini bephasi loke babadosiphambili bamabhizinisi, abafundisi, nabontanga. ==

== Ukuhlonitjhwa lokhu kuveza idumela elikhulako leyunivesithi emkhakheni wezamabhizinisi wezenhlalakahle nokuthuthukisa umphakathi. ==

== '''Qala godu''' ==
Enactus South Africa

Enactus World Cup

University of Mpumalanga

== '''Umthombo welwazi''' ==</text>
      <sha1>c9v3m341kghhlw6tmyknufypueczbnw</sha1>
    </revision>
    <revision>
      <id>5573</id>
      <parentid>5569</parentid>
      <timestamp>2025-09-04T09:49:57Z</timestamp>
      <contributor>
        <username>Pholap</username>
        <id>883</id>
      </contributor>
      <minor />
      <origin>5573</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2598" sha1="nb9mu3w7bjajrpsl2i3i4wwfvv2aqlh" xml:space="preserve">[[Isimumathi:UMP Enactus.png|thumb|UMP Enactus]]

== '''&lt;big&gt;I-Enactus ye-Yunivesithi ye-Mpumalanga&lt;/big&gt;''' ==

== I-Enactus [[University of Mpumalanga|ye-Yunivesithi ye-Mpumalanga]] mtjhayeli weentjhabatjhaba weSewula Afrika we-2025 ku-Enactus National Competition.&lt;ref&gt;[https://www.ump.ac.za/News-and-Events/News/2025/UMP-WINS-THE-2025-ENACTUS-SA-CHAMPIONSHIP UMP - UMP WINS THE 2025 ENACTUS SA CHAMPIONSHIP]&lt;/ref&gt; Isiqhema siyingcenye ye-Enactus [[Isewula Afrika|South Africa]], ihlangano engenzi inzuzo ehlanganisa abafundi beyunivesithi, iimfundiswa, nabadosiphambili bamabhizinisi ngamaphrojekthi asekelwe emabhizinisini ahloselwe ukwenza umthelela omuhle emphakathini. ==

== '''Isendlalelo''' ==

== [[I-Enactus]] South Africa isebenza ngaphasi kwenethiwekhi ye-Enactus yephasi loke, esebenza emazweni angaphezu kwama-30. Ihlangano le inikela abafundi indawo yokuklama nokusebenzisa amaphrojekthi womphakathi ahlanganisa ukusungulwa kwebhizinisi nokuziphendulela emphakathini. ==

== Isiqhema seYunivesithi ye-Mpumalanga sibe mhlanganyeli okhutheleko emncintiswaneni weentjhabatjhaba, sidzimelele eenhlelweni zentuthuko esimemeko kanye namaphrojekthi wobusomabhizinisi akhambisana neendingo zomphakathi wendawo. ==

== '''2025 Umqhudelwano weNarha''' ==

== Ngenyanga kaRhoboyi wee-2025, iYunivesithi ye-Mpumalanga yakhethwa njengeTjhugululi yeNarha emncintiswaneni weNarha we-Enactus South Africa. Ipumelelo yabo yagujwa begodu ngokukhamba kwesikhathi yavezwa ku-IsiNdebele News ku-[[SABC|SABC 1]], kuveza amaphrojekthi neminikelo yesiqhema.&lt;ref&gt;[https://www.sabcnews.com/sabcnews/ Official SABC News - SABC News - Breaking news, special reports, world, business, sport coverage of all South African current events. Africa's news leader.]&lt;/ref&gt; ==

== Ihlelo elivezwe kumabonakude ligcizelele indlela yokwenza izinto ezitjha zesiqhema kanye nomnqopho omkhulu we-Enactus wokukhuthaza uburholi bamabhizinisi hlangana nelutjha leSewula Afrika. ==

== '''Ukuqakatheka''' ==

== Ukuthumba umncintiswano weentjhabatjhaba kwenza bona isiqhema [[Yunivesithi yempulanga|seYunivesithi ye-Mpumalanga]] sikwazi ukujamela iSewula Afrika eNdebeni yePhasi ye-Enactus, iplatifomu yamazwe ngamazwe lapho amathimu wabafundi aveza khona amaphrojekthi wawo wamabhizinisi ebantwini bephasi loke babadosiphambili bamabhizinisi, abafundisi, nabontanga. ==

== Ukuhlonitjhwa lokhu kuveza idumela elikhulako leyunivesithi emkhakheni wezamabhizinisi wezenhlalakahle nokuthuthukisa umphakathi. ==

== '''Qala godu''' ==
Enactus South Africa

Enactus World Cup

University of Mpumalanga

== '''Umthombo welwazi''' ==</text>
      <sha1>nb9mu3w7bjajrpsl2i3i4wwfvv2aqlh</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:F.K MAHLANGU/University of Mpumalanga</title>
    <ns>2</ns>
    <id>902</id>
    <revision>
      <id>5423</id>
      <timestamp>2025-09-03T21:52:34Z</timestamp>
      <contributor>
        <username>F.K MAHLANGU</username>
        <id>891</id>
      </contributor>
      <comment>Created by translating the section &quot;History&quot; from the page &quot;[[:en:Special:Redirect/revision/1306769322|University of Mpumalanga]]&quot;</comment>
      <origin>5423</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2497" sha1="rov6uizz3nv50ihvm7zasju54mjecz9" xml:space="preserve">== History ==

[[Isimumathi:University of Mpumalanga.jpg|thumb|267x267px|&lt;ref&gt;[[:Isimumathi:University of Mpumalanga.jpg|Isimumathi:University of Mpumalanga.jpg - Wikiphidiya]]&lt;/ref&gt; University of Mpumalanga]]
Ngomnyaka ka-1996 iKomidi yezeFundo yeYunivesithi neKomidi yokuBambisana yezeFundo yeYunivesithi ye-Technikon yahlangana begodu yanikelwa umsebenzi wokulandela ukusungulwa kweyunivesithi esiFundeni ngu-MEC wangaphambilini wezeFundo, uNom. DD Mabuza. I-National Institute for Higher Education (i-Mpumalanga), eyasungulwa ngomnyaka ka-2006, ngaphasi koburholi baka-Prof CC Mokadi ongasekho yahlanganisa ukunikelwa kwe-Higher Education esifundazweni. Igadango eliqakathekileko kwaba siqunto esathathwa emhlanganweni we-African National Congress's National General Council owabanjelwa e-eThekwini ( i-Durban ) ngomnyaka ka-2010 owaqunta ukusungulwa kwamayunivesithi amabili amatjha. Isinqumo lesi sibe lisizo khulu ekwenzeni lula ukusungulwa kweyunivesithi esifundazweni se-Mpumalanga&lt;ref&gt;University of Mpumalanga (UMP). (2023). ''History of UMP''. Available at: &lt;nowiki&gt;https://www.ump.ac.za&lt;/nowiki&gt;&lt;/ref&gt;.

Ngomnyaka ka-2010, uNgqongqotjhe wezeFundo neBandulo eliPhakemeko, uDorhodera B. E. Nzimande, wabeka iinqhema ezimbili ezizokuphenya bona kungenzeka na ukusungula amayunivesithi amatjha e-Mpumalanga ne-Northern Cape. Isiqhema sokusebenza se-Mpumalanga esathumela umbiko omuhle ngoNobayeni wee-2011, esiphakamisela ukusungulwa kweyunivesithi etja e-Mpumalanga besidoswa phambili ngu-Prof TZ Mthembu&lt;ref&gt;Department of Higher Education and Training (DHET). (2012). ''Report of the Ministerial Task Team on the Establishment of New Universities in Mpumalanga and the Northern Cape''. Pretoria: DHET.&lt;/ref&gt;.

NgoNtaka 2013, uMengameli weNarha, uNom. Jacob Zuma, wamemezela ibizo leyunivesithi etja ngokuthi yiYunivesithi '''ye-Mpumalanga''' kanye namagama wamalunga womKhandlu wesiKhatjhana azokutjheja ukusungulwa kwayo ngokusemthethweni. IYunivesithi ye-Mpumalanga, iyunivesithi epheleleko, yamenyezelwa ngokusemthethweni nangokomthetho ngokugadangiswa kweSaziso sikaRhulumende (Nombolo 36772) mhlazi-22 kuRhoboyi 2013 begodu yathonywa mhlana ama-31 kuMgwengweni 2013. UmKhandlu wesiKhatjhana wabeka iQhema lokuPhatha eliPhakemeko ebelilawula ukusebenza kweyunivesithi kwangamalanga&lt;ref&gt;University of Mpumalanga (UMP). (2013). ''Establishment and Launch of the University of Mpumalanga''. Available at: &lt;nowiki&gt;https://www.ump.ac.za&lt;/nowiki&gt;&lt;/ref&gt;.

irherho lemithombo.
&lt;references /&gt;</text>
      <sha1>rov6uizz3nv50ihvm7zasju54mjecz9</sha1>
    </revision>
  </page>
  <page>
    <title>I-Shoprite Holdings Ltd</title>
    <ns>0</ns>
    <id>903</id>
    <revision>
      <id>5424</id>
      <timestamp>2025-09-03T22:18:12Z</timestamp>
      <contributor>
        <username>Mojonom</username>
        <id>593</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1309335077|Shoprite Holdings Ltd]]&quot;</comment>
      <origin>5424</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="938" sha1="d5pxi8mpapf4hmlp8tuiddhg77spi1g" xml:space="preserve">
Isitolo '''iShoprite''' (ngokusemthethweni y'''i-Shoprite Holdings Ltd''' ) kusitolo esikulu kunazo zoke iintolo enarhenikazi ye omkhulu [[I-Afrika|we-Afrika]]. Ama Ofisi amakhulu wesitolo lesi atholakala endaweni ye-Cape Town, [[Isewula Afrika|eSewula Afrika]]. Godu ke, indawo ye Cape Town kuyindawo lapha isitolwesi sasungulwa khona ngomnyaka we 1979

Isitolwesi kusitolo esitloliswe ngaphasi Johannesburg Stock Exchange. Kanti ke, itlolisiwe nakwamanye ama-stock exchange, njenge stock exchange senarha ye-Namibia  kunye nenarha ye-Lusaka .

Njengekampani ekulu kunazo zoke, iShoprite ineentolo ezinengana tle enarheni yeSewula Afrika nakwezinye iinarha. Godu, Iphinde ibe nezinye iintolo, njengesitolo  i-USave, iMedrite, Transpharm, House &amp; Home, Computicket, kunye Ne Checkers, ekuziintolo ezingaphasi kweKampani iShoprite.



[[Isimumathi:Shoprite_Availability.svg|thumb|Iinarha ezibovu ziinarha ezineentolo zekampani iShoprite]]</text>
      <sha1>d5pxi8mpapf4hmlp8tuiddhg77spi1g</sha1>
    </revision>
  </page>
  <page>
    <title>Kwa Bulawayo</title>
    <ns>0</ns>
    <id>904</id>
    <revision>
      <id>5425</id>
      <timestamp>2025-09-03T22:26:59Z</timestamp>
      <contributor>
        <username>Mojonom</username>
        <id>593</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1297221407|Bulawayo]]&quot;</comment>
      <origin>5425</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="402" sha1="dcjoyn6q69zkq3sptipyuzadlaf1ubs" xml:space="preserve">
'''iKwaBulawayo'''  kungelinye lamadorobha amakhulu [[Zimbabwe|eZimbabwe]], Begodu kulidorobha elikhulu kunamanye esifundeni se- Matabeleland, ekusifunda lapha idorobha leli linzinze khona . Idorobheli lasungulwa yikosi yamaNdebele weTlhagwini uLobengula, ekhabe ayindodana yekosi uMzilikazi kaMatshobana. Ibizo ledorobheli, elithi &quot;Bulawayo&quot; lisuselwe ebizweni lesiNdebele seTlhagwini elithi 'bulala'</text>
      <sha1>dcjoyn6q69zkq3sptipyuzadlaf1ubs</sha1>
    </revision>
  </page>
  <page>
    <title>IYunivesithi yeSewula Afrika</title>
    <ns>0</ns>
    <id>905</id>
    <revision>
      <id>5426</id>
      <timestamp>2025-09-03T22:33:59Z</timestamp>
      <contributor>
        <username>Mojonom</username>
        <id>593</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1305341657|University of South Africa]]&quot;</comment>
      <origin>5426</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="529" sha1="kju6ajijyw7sjec1752zio4grl7pdoe" xml:space="preserve">
I University Of South Africa (Unisa) Kuyiyunivesithi ekulu kunawo woke amayunivesithi eSewula Afrika. IYunivesithi le pheze inabafundi abandlula eenkulungwaneni ezimakhulu amane, ekubala hlangana abafundi abavela eenarheni ezingaphetjheya. Lokhu kwenza bonyana iYunivesithi le ibe sesibalweni samaYunivesithi amakhulu khulu ephasini zombelele. Kanti ke, kungiyo yodwa iyunivesithi ekulu kangaka enarhenikazi ye Afrika.


Iyunivesithi le yasungulwa ngomnyaka we 1873 begodu khabe ibizwa ngokobanyana kuyi University Of Good Hope.</text>
      <sha1>kju6ajijyw7sjec1752zio4grl7pdoe</sha1>
    </revision>
  </page>
  <page>
    <title>U-Angie Motshekga</title>
    <ns>0</ns>
    <id>906</id>
    <revision>
      <id>5427</id>
      <timestamp>2025-09-03T22:49:16Z</timestamp>
      <contributor>
        <username>NASKHOSANA</username>
        <id>884</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1296732526|Angie Motshekga]]&quot;</comment>
      <origin>5427</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2232" sha1="ggpgpypkjih0aj6f6g7hmkdrqt73rsu" xml:space="preserve">
 

'''U-Matsie Angelina &quot;Angie&quot; Motshekga''' (wabelethwa mhla amalanga ali-19 kuMgwengweni ngomnyaka we-1955).Ungusopolotiki begodu mfundisi [[Isewula Afrika|weSewula Afrika]] osele aberega njengoNgqongqotjhe wezokuVikela amajoni weButho kusukela mhla amalanga ali-3 kuNtaka ngomnyaka wee-2024. Uberege njengomengameli weRiphabhliki yeSewula Afrika kusukela mhla amalanga ali-17 kuRhoboyi ngomnyaka wee-2024, ngesikhathi uMongameli u Cyril Ramaphosa akhambele  UmHlangano we-44th weenhloko zombuso noRhulumende we -Southern African

Development Community e- Harare, e-Zimbabwe .  U-Motshekga godu wasebenza njengoNgqongqotjhe wezeFundo Sisekelo kusukela ngoMeyi ngomnyaka wee-2009 ukuya emnyakeni wee-2024. Ngaphambili, bekalilunga lomKhandlu oPhetheko kurhulumende wesifunda sange-Gauteng . U-Motshekga ulilunga le- African National Congress . Bekangumongameli wangaphambilini weligi yabantu abasikazi behlangano.



U-Motshekga wabelethwa mhla amalanga ali-19 ngenyanga ka Mgwengweni ngomnyaka we-1955 eSoweto, nge Transvaal Province .  Wafumana ifundo yakhe yamabanga aphasi eenkolweni ezihlukahlukeneko e-Soweto. Waphumelela esikolweni sokuhlala e -Matatiele . &lt;ref name=&quot;Parl&quot; /&gt; U-Motshekga wafunda e- University of the North, lapho athola khona idigri yakhe ye-Bachelor of Arts ku-Education. E- University of the Witwatersrand, u-Motshekga wathola i-Bachelor of Educational Science degree kanye ne-master's degree. 

Ngomnyaka we-1981, u-Motshekga waqatjhwa njengotitjhere e-Orlando High School. Waberega esikolweni bekwafika umnyaka we-1983, lokha nakatjhiya umsebenzi ngemva kokuqatjhwa njengomfundisi e-Soweto College of Education. U-Motshekga waba mfundisi e-University of the Witwatersrand ngomnyaka we-1985. Wafundisa e-University bekwafika umnyaka we-1994. 





'''''ama linki ajamelana nerhubhululo leli'''''

* {{cite web|title=Minister of Basic Education: Matsie Angelina Motshekga, Ms|url=https://www.education.gov.za/AboutUs/AboutDBE/MinisterofBasicEducation/tabid/77/Default.aspx|website=Department of Basic Education|access-date=25 July 2020}}
* {{cite web|title=Mrs Angie Motshekga|url=https://www.pa.org.za/person/matsie-angelina-motshekga/|website=People's Assembly|access-date=25 July 2020}}

{{Reflist}}</text>
      <sha1>ggpgpypkjih0aj6f6g7hmkdrqt73rsu</sha1>
    </revision>
    <revision>
      <id>5473</id>
      <parentid>5427</parentid>
      <timestamp>2025-09-04T08:29:11Z</timestamp>
      <contributor>
        <username>NASKHOSANA</username>
        <id>884</id>
      </contributor>
      <comment>added reference</comment>
      <origin>5473</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2256" sha1="mm9oztc5t2zy5v78owjbymv5d9l412s" xml:space="preserve">
 

'''U-Matsie Angelina &quot;Angie&quot; Motshekga''' (wabelethwa mhla amalanga ali-19 kuMgwengweni ngomnyaka we-1955).Ungusopolotiki begodu mfundisi [[Isewula Afrika|weSewula Afrika]] osele aberega njengoNgqongqotjhe wezokuVikela amajoni weButho kusukela mhla amalanga ali-3 kuNtaka ngomnyaka wee-2024.&lt;ref&gt;MOTSHEKGA, M.A. and MINISTER, M., 2022. Department of Basic Education.&lt;/ref&gt; Uberege njengomengameli weRiphabhliki yeSewula Afrika kusukela mhla amalanga ali-17 kuRhoboyi ngomnyaka wee-2024, ngesikhathi uMongameli u Cyril Ramaphosa akhambele  UmHlangano we-44th weenhloko zombuso noRhulumende we -Southern African

Development Community e- Harare, e-Zimbabwe .  U-Motshekga godu wasebenza njengoNgqongqotjhe wezeFundo Sisekelo kusukela ngoMeyi ngomnyaka wee-2009 ukuya emnyakeni wee-2024. Ngaphambili, bekalilunga lomKhandlu oPhetheko kurhulumende wesifunda sange-Gauteng . U-Motshekga ulilunga le- African National Congress . Bekangumongameli wangaphambilini weligi yabantu abasikazi behlangano https://www.google.com/search?gs_ssp=eJzj4tLP1TcwrSrJTS8xYPTiT8xLz0xVyM0vKc5IzU5PBACLowns&amp;q=angie+motshekga&amp;rlz=1C1CHZN_enZA1178&amp;oq=engie+mots&amp;gs_lcrp=EgZjaHJvbWUqDwgBEC4YChiDARixAxiABDIGCAAQRRg5Mg8IARAuGAoYgwEYsQMYgAQyCQgCEAAYChiABDIJCAMQABgKGIAEMgkIBBAAGAoYgAQyCQgFEAAYChiABDIJCAYQABgKGIAEMgkIBxAAGAoYgAQyCQgIEAAYChiABNIBCjExMzQxajBqMTWoAgiwAgHxBRsVNfoPeX-6&amp;sourceid=chrome&amp;ie=UTF-8.

U-Motshekga wabelethwa mhla amalanga ali-19 ngenyanga ka Mgwengweni ngomnyaka we-1955 eSoweto, nge Transvaal Province .Wafumana ifundo yakhe yamabanga aphasi eenkolweni ezihlukahlukeneko e-Soweto. Waphumelela esikolweni sokuhlala e -Matatiele. U-Motshekga wafunda e- University of the North, lapho athola khona idigri yakhe ye-Bachelor of Arts ku-Education. E- University of the Witwatersrand, u-Motshekga wathola i-Bachelor of Educational Science degree kanye ne-master's degree.

Ngomnyaka we-1981, u-Motshekga waqatjhwa njengotitjhere e-Orlando High School. Waberega esikolweni bekwafika umnyaka we-1983, lokha nakatjhiya umsebenzi ngemva kokuqatjhwa njengomfundisi e-Soweto College of Education. U-Motshekga waba mfundisi e-University of the Witwatersrand ngomnyaka we-1985. Wafundisa e-University bekwafika umnyaka we-1994. 



== '''Imithombo lwazi''' ==
{{Reflist}}</text>
      <sha1>mm9oztc5t2zy5v78owjbymv5d9l412s</sha1>
    </revision>
    <revision>
      <id>5493</id>
      <parentid>5473</parentid>
      <timestamp>2025-09-04T09:01:44Z</timestamp>
      <contributor>
        <username>NASKHOSANA</username>
        <id>884</id>
      </contributor>
      <origin>5493</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2120" sha1="bm5cmfdgn005mwuu5n2nknk1e8gnrvk" xml:space="preserve">
 

'''U-Matsie Angelina &quot;Angie&quot; Motshekga''' Angie&lt;ref&gt;{{Cite web |title=Angie Motshekga, Ms {{!}} South African Government |url=https://www.gov.za/about-government/contact-directory/defence-and-military-veterans-ministry/angie-motshekga-ms |access-date=2025-09-04 |website=www.gov.za}}&lt;/ref&gt;  (wabelethwa mhla amalanga ali-19 kuMgwengweni ngomnyaka we-1955).Ungusopolotiki begodu mfundisi [[Isewula Afrika|weSewula Afrika]] osele aberega njengoNgqongqotjhe wezokuVikela amajoni weButho kusukela mhla amalanga ali-3 kuNtaka ngomnyaka wee-2024.&lt;ref&gt;MOTSHEKGA, M.A. and MINISTER, M., 2022. Department of Basic Education.&lt;/ref&gt; Uberege njengomengameli weRiphabhliki yeSewula Afrika kusukela mhla amalanga ali-17 kuRhoboyi ngomnyaka wee-2024, ngesikhathi uMongameli u Cyril Ramaphosa akhambele  UmHlangano we-44th weenhloko zombuso noRhulumende we -Southern African

Development Community e- Harare, e-Zimbabwe .  U-Motshekga godu wasebenza njengoNgqongqotjhe wezeFundo Sisekelo kusukela ngoMeyi ngomnyaka wee-2009 ukuya emnyakeni wee-2024. Ngaphambili, bekalilunga lomKhandlu oPhetheko kurhulumende wesifunda sange-Gauteng . U-Motshekga ulilunga le- African National Congress . Bekangumongameli wangaphambilini weligi yabantu abasikazi behlangano.

U-Motshekga wabelethwa mhla amalanga ali-19 ngenyanga ka Mgwengweni ngomnyaka we-1955 eSoweto, nge Transvaal Province .Wafumana ifundo yakhe yamabanga aphasi eenkolweni ezihlukahlukeneko e-Soweto. Waphumelela esikolweni sokuhlala e -Matatiele. U-Motshekga wafunda e- University of the North, lapho athola khona idigri yakhe ye-Bachelor of Arts ku-Education. E- University of the Witwatersrand, u-Motshekga wathola i-Bachelor of Educational Science degree kanye ne-master's degree.

Ngomnyaka we-1981, u-Motshekga waqatjhwa njengotitjhere e-Orlando High School. Waberega esikolweni bekwafika umnyaka we-1983, lokha nakatjhiya umsebenzi ngemva kokuqatjhwa njengomfundisi e-Soweto College of Education. U-Motshekga waba mfundisi e-University of the Witwatersrand ngomnyaka we-1985. Wafundisa e-University bekwafika umnyaka we-1994. 



== '''Imithombo lwazi''' ==
{{Reflist}}</text>
      <sha1>bm5cmfdgn005mwuu5n2nknk1e8gnrvk</sha1>
    </revision>
    <revision>
      <id>5496</id>
      <parentid>5493</parentid>
      <timestamp>2025-09-04T09:02:19Z</timestamp>
      <contributor>
        <username>NASKHOSANA</username>
        <id>884</id>
      </contributor>
      <origin>5496</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2114" sha1="ebb7k88h5fvzyqn6xbgbtk7mpadw1ig" xml:space="preserve">
 

'''U-Matsie Angelina &quot;Angie&quot; Motshekga'''&lt;ref&gt;{{Cite web |title=Angie Motshekga, Ms {{!}} South African Government |url=https://www.gov.za/about-government/contact-directory/defence-and-military-veterans-ministry/angie-motshekga-ms |access-date=2025-09-04 |website=www.gov.za}}&lt;/ref&gt;  (wabelethwa mhla amalanga ali-19 kuMgwengweni ngomnyaka we-1955).Ungusopolotiki begodu mfundisi [[Isewula Afrika|weSewula Afrika]] osele aberega njengoNgqongqotjhe wezokuVikela amajoni weButho kusukela mhla amalanga ali-3 kuNtaka ngomnyaka wee-2024.&lt;ref&gt;MOTSHEKGA, M.A. and MINISTER, M., 2022. Department of Basic Education.&lt;/ref&gt; Uberege njengomengameli weRiphabhliki yeSewula Afrika kusukela mhla amalanga ali-17 kuRhoboyi ngomnyaka wee-2024, ngesikhathi uMongameli u Cyril Ramaphosa akhambele  UmHlangano we-44th weenhloko zombuso noRhulumende we -Southern African

Development Community e- Harare, e-Zimbabwe .  U-Motshekga godu wasebenza njengoNgqongqotjhe wezeFundo Sisekelo kusukela ngoMeyi ngomnyaka wee-2009 ukuya emnyakeni wee-2024. Ngaphambili, bekalilunga lomKhandlu oPhetheko kurhulumende wesifunda sange-Gauteng . U-Motshekga ulilunga le- African National Congress . Bekangumongameli wangaphambilini weligi yabantu abasikazi behlangano.

U-Motshekga wabelethwa mhla amalanga ali-19 ngenyanga ka Mgwengweni ngomnyaka we-1955 eSoweto, nge Transvaal Province .Wafumana ifundo yakhe yamabanga aphasi eenkolweni ezihlukahlukeneko e-Soweto. Waphumelela esikolweni sokuhlala e -Matatiele. U-Motshekga wafunda e- University of the North, lapho athola khona idigri yakhe ye-Bachelor of Arts ku-Education. E- University of the Witwatersrand, u-Motshekga wathola i-Bachelor of Educational Science degree kanye ne-master's degree.

Ngomnyaka we-1981, u-Motshekga waqatjhwa njengotitjhere e-Orlando High School. Waberega esikolweni bekwafika umnyaka we-1983, lokha nakatjhiya umsebenzi ngemva kokuqatjhwa njengomfundisi e-Soweto College of Education. U-Motshekga waba mfundisi e-University of the Witwatersrand ngomnyaka we-1985. Wafundisa e-University bekwafika umnyaka we-1994. 



== '''Imithombo lwazi''' ==
{{Reflist}}</text>
      <sha1>ebb7k88h5fvzyqn6xbgbtk7mpadw1ig</sha1>
    </revision>
    <revision>
      <id>5506</id>
      <parentid>5496</parentid>
      <timestamp>2025-09-04T09:12:22Z</timestamp>
      <contributor>
        <username>NASKHOSANA</username>
        <id>884</id>
      </contributor>
      <origin>5506</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2362" sha1="drvkht2sxrpop1erdf3azdad8lploo6" xml:space="preserve">
 

'''U-Matsie Angelina &quot;Angie&quot; Motshekga'''&lt;ref&gt;{{Cite web |title=Angie Motshekga, Ms {{!}} South African Government |url=https://www.gov.za/about-government/contact-directory/defence-and-military-veterans-ministry/angie-motshekga-ms |access-date=2025-09-04 |website=www.gov.za}}&lt;/ref&gt;  (wabelethwa mhla amalanga ali-19 kuMgwengweni ngomnyaka we-1955).Ungusopolotiki begodu mfundisi [[Isewula Afrika|weSewula Afrika]] osele aberega njengoNgqongqotjhe wezokuVikela amajoni weButho kusukela mhla amalanga ali-3 kuNtaka ngomnyaka wee-2024.&lt;ref&gt;MOTSHEKGA, M.A. and MINISTER, M., 2022. Department of Basic Education.&lt;/ref&gt; Uberege njengomengameli weRiphabhliki yeSewula Afrika kusukela mhla amalanga ali-17 kuRhoboyi ngomnyaka wee-2024, ngesikhathi uMongameli u Cyril Ramaphosa akhambele  UmHlangano we-44th weenhloko zombuso noRhulumende we -Southern African angie &lt;ref&gt;{{Cite web |last=website |first=2025 © Department of Military Veterans |title=The Department of Military Veterans |url=http://www.dmv.gov.za/ |access-date=2025-09-04 |website=The official Department of Military Veterans website}}&lt;/ref&gt;

Development Community e- Harare, e-Zimbabwe .  U-Motshekga godu wasebenza njengoNgqongqotjhe wezeFundo Sisekelo kusukela ngoMeyi ngomnyaka wee-2009 ukuya emnyakeni wee-2024. Ngaphambili, bekalilunga lomKhandlu oPhetheko kurhulumende wesifunda sange-Gauteng . U-Motshekga ulilunga le- African National Congress . Bekangumongameli wangaphambilini weligi yabantu abasikazi behlangano.

U-Motshekga wabelethwa mhla amalanga ali-19 ngenyanga ka Mgwengweni ngomnyaka we-1955 eSoweto, nge Transvaal Province .Wafumana ifundo yakhe yamabanga aphasi eenkolweni ezihlukahlukeneko e-Soweto. Waphumelela esikolweni sokuhlala e -Matatiele. U-Motshekga wafunda e- University of the North, lapho athola khona idigri yakhe ye-Bachelor of Arts ku-Education. E- University of the Witwatersrand, u-Motshekga wathola i-Bachelor of Educational Science degree kanye ne-master's degree.

Ngomnyaka we-1981, u-Motshekga waqatjhwa njengotitjhere e-Orlando High School. Waberega esikolweni bekwafika umnyaka we-1983, lokha nakatjhiya umsebenzi ngemva kokuqatjhwa njengomfundisi e-Soweto College of Education. U-Motshekga waba mfundisi e-University of the Witwatersrand ngomnyaka we-1985. Wafundisa e-University bekwafika umnyaka we-1994. 



== '''Imithombo lwazi''' ==
{{Reflist}}</text>
      <sha1>drvkht2sxrpop1erdf3azdad8lploo6</sha1>
    </revision>
    <revision>
      <id>5521</id>
      <parentid>5506</parentid>
      <timestamp>2025-09-04T09:21:59Z</timestamp>
      <contributor>
        <username>NASKHOSANA</username>
        <id>884</id>
      </contributor>
      <origin>5521</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2539" sha1="8lkwlta23d5iql1pgaznkzjjg79eaes" xml:space="preserve">
 

'''U-Matsie Angelina &quot;Angie&quot; Motshekga'''&lt;ref&gt;{{Cite web |title=Angie Motshekga, Ms {{!}} South African Government |url=https://www.gov.za/about-government/contact-directory/defence-and-military-veterans-ministry/angie-motshekga-ms |access-date=2025-09-04 |website=www.gov.za}}&lt;/ref&gt;  (wabelethwa mhla amalanga ali-19 kuMgwengweni ngomnyaka we-1955).Ungusopolotiki begodu mfundisi [[Isewula Afrika|weSewula Afrika]] osele aberega njengoNgqongqotjhe wezokuVikela amajoni weButho kusukela mhla amalanga ali-3 kuNtaka ngomnyaka wee-2024.&lt;ref&gt;MOTSHEKGA, M.A. and MINISTER, M., 2022. Department of Basic Education.&lt;/ref&gt; Uberege njengomengameli weRiphabhliki yeSewula Afrika kusukela mhla amalanga ali-17 kuRhoboyi ngomnyaka wee-2024, ngesikhathi uMongameli u Cyril Ramaphosa akhambele  UmHlangano we-44th weenhloko zombuso noRhulumende we -Southern African angie &lt;ref&gt;{{Cite web |last=website |first=2025 © Department of Military Veterans |title=The Department of Military Veterans |url=http://www.dmv.gov.za/ |access-date=2025-09-04 |website=The official Department of Military Veterans website}}&lt;/ref&gt;

Development Community e- Harare, e-Zimbabwe .  U-Motshekga godu wasebenza njengoNgqongqotjhe wezeFundo Sisekelo kusukela ngoMeyi ngomnyaka wee-2009 ukuya emnyakeni wee-2024. Ngaphambili, bekalilunga lomKhandlu oPhetheko kurhulumende wesifunda sange-Gauteng . U-Motshekga ulilunga le- African National Congress . Bekangumongameli wangaphambilini weligi yabantu abasikazi behlangano angie&lt;ref&gt;{{Cite web |title=Angie Motshekga |url=http://www.pa.org.za/person/matsie-angelina-motshekga/ |access-date=2025-09-04 |website=People's Assembly |language=en}}&lt;/ref&gt; .

U-Motshekga wabelethwa mhla amalanga ali-19 ngenyanga ka Mgwengweni ngomnyaka we-1955 eSoweto, nge Transvaal Province .Wafumana ifundo yakhe yamabanga aphasi eenkolweni ezihlukahlukeneko e-Soweto. Waphumelela esikolweni sokuhlala e -Matatiele. U-Motshekga wafunda e- University of the North, lapho athola khona idigri yakhe ye-Bachelor of Arts ku-Education. E- University of the Witwatersrand, u-Motshekga wathola i-Bachelor of Educational Science degree kanye ne-master's degree.

Ngomnyaka we-1981, u-Motshekga waqatjhwa njengotitjhere e-Orlando High School. Waberega esikolweni bekwafika umnyaka we-1983, lokha nakatjhiya umsebenzi ngemva kokuqatjhwa njengomfundisi e-Soweto College of Education. U-Motshekga waba mfundisi e-University of the Witwatersrand ngomnyaka we-1985. Wafundisa e-University bekwafika umnyaka we-1994. 



== '''Imithombo lwazi''' ==
{{Reflist}}</text>
      <sha1>8lkwlta23d5iql1pgaznkzjjg79eaes</sha1>
    </revision>
    <revision>
      <id>5535</id>
      <parentid>5521</parentid>
      <timestamp>2025-09-04T09:27:20Z</timestamp>
      <contributor>
        <username>NASKHOSANA</username>
        <id>884</id>
      </contributor>
      <comment>link reference</comment>
      <origin>5535</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2543" sha1="fuzxtm37r09vpnifcl5dzc2tbpidmlk" xml:space="preserve">
 

'''U-Matsie Angelina &quot;Angie&quot; Motshekga'''&lt;ref&gt;{{Cite web |title=Angie Motshekga, Ms {{!}} South African Government |url=https://www.gov.za/about-government/contact-directory/defence-and-military-veterans-ministry/angie-motshekga-ms |access-date=2025-09-04 |website=www.gov.za}}&lt;/ref&gt;  (wabelethwa mhla amalanga ali-19 kuMgwengweni ngomnyaka we-1955).Ungusopolotiki begodu mfundisi [[Isewula Afrika|weSewula Afrika]] osele aberega njengoNgqongqotjhe wezokuVikela amajoni weButho kusukela mhla amalanga ali-3 kuNtaka ngomnyaka wee-2024.&lt;ref&gt;MOTSHEKGA, M.A. and MINISTER, M., 2022. Department of Basic Education.&lt;/ref&gt; Uberege njengomengameli weRiphabhliki yeSewula Afrika kusukela mhla amalanga ali-17 kuRhoboyi ngomnyaka wee-2024, ngesikhathi uMongameli u Cyril Ramaphosa akhambele  UmHlangano we-44th weenhloko zombuso noRhulumende we -Southern African angie &lt;ref&gt;{{Cite web |last=website |first=2025 © Department of Military Veterans |title=The Department of Military Veterans |url=http://www.dmv.gov.za/ |access-date=2025-09-04 |website=The official Department of Military Veterans website}}&lt;/ref&gt;

Development Community e- Harare, e-Zimbabwe .  U-Motshekga godu wasebenza njengoNgqongqotjhe wezeFundo Sisekelo kusukela ngoMeyi ngomnyaka wee-2009 ukuya emnyakeni wee-2024. Ngaphambili, bekalilunga lomKhandlu oPhetheko kurhulumende wesifunda sange-Gauteng . U-Motshekga ulilunga le- [[African National Congress]] . Bekangumongameli wangaphambilini weligi yabantu abasikazi behlangano angie&lt;ref&gt;{{Cite web |title=Angie Motshekga |url=http://www.pa.org.za/person/matsie-angelina-motshekga/ |access-date=2025-09-04 |website=People's Assembly |language=en}}&lt;/ref&gt; .

U-Motshekga wabelethwa mhla amalanga ali-19 ngenyanga ka Mgwengweni ngomnyaka we-1955 eSoweto, nge Transvaal Province .Wafumana ifundo yakhe yamabanga aphasi eenkolweni ezihlukahlukeneko e-Soweto. Waphumelela esikolweni sokuhlala e -Matatiele. U-Motshekga wafunda e- University of the North, lapho athola khona idigri yakhe ye-Bachelor of Arts ku-Education. E- University of the Witwatersrand, u-Motshekga wathola i-Bachelor of Educational Science degree kanye ne-master's degree.

Ngomnyaka we-1981, u-Motshekga waqatjhwa njengotitjhere e-Orlando High School. Waberega esikolweni bekwafika umnyaka we-1983, lokha nakatjhiya umsebenzi ngemva kokuqatjhwa njengomfundisi e-Soweto College of Education. U-Motshekga waba mfundisi e-University of the Witwatersrand ngomnyaka we-1985. Wafundisa e-University bekwafika umnyaka we-1994. 



== '''Imithombo lwazi''' ==
{{Reflist}}</text>
      <sha1>fuzxtm37r09vpnifcl5dzc2tbpidmlk</sha1>
    </revision>
    <revision>
      <id>5542</id>
      <parentid>5535</parentid>
      <timestamp>2025-09-04T09:30:21Z</timestamp>
      <contributor>
        <username>NASKHOSANA</username>
        <id>884</id>
      </contributor>
      <comment>link reference</comment>
      <origin>5542</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2573" sha1="k21bfkl19oza818k7bk1d95fwfikoja" xml:space="preserve">
 

'''U-Matsie Angelina &quot;Angie&quot; Motshekga'''&lt;ref&gt;{{Cite web |title=Angie Motshekga, Ms {{!}} South African Government |url=https://www.gov.za/about-government/contact-directory/defence-and-military-veterans-ministry/angie-motshekga-ms |access-date=2025-09-04 |website=www.gov.za}}&lt;/ref&gt;  (wabelethwa mhla amalanga ali-19 kuMgwengweni ngomnyaka we-1955).Ungusopolotiki begodu mfundisi [[Isewula Afrika|weSewula Afrika]] osele aberega njengoNgqongqotjhe wezokuVikela amajoni weButho kusukela mhla amalanga ali-3 kuNtaka ngomnyaka wee-2024.&lt;ref&gt;MOTSHEKGA, M.A. and MINISTER, M., 2022. Department of Basic Education.&lt;/ref&gt; Uberege njengomengameli weRiphabhliki yeSewula Afrika kusukela mhla amalanga ali-17 kuRhoboyi ngomnyaka wee-2024, ngesikhathi uMongameli u Cyril Ramaphosa akhambele  UmHlangano we-44th weenhloko zombuso noRhulumende we -Southern African angie &lt;ref&gt;{{Cite web |last=website |first=2025 © Department of Military Veterans |title=The Department of Military Veterans |url=http://www.dmv.gov.za/ |access-date=2025-09-04 |website=The official Department of Military Veterans website}}&lt;/ref&gt;

Development Community e- Harare, e-Zimbabwe .  U-Motshekga godu wasebenza njengoNgqongqotjhe wezeFundo Sisekelo kusukela ngoMeyi ngomnyaka wee-2009 ukuya emnyakeni wee-2024. Ngaphambili, bekalilunga lomKhandlu oPhetheko kurhulumende wesifunda sange-Gauteng . U-Motshekga ulilunga le- [[:en:African_National_Congress|African National Congress]] . Bekangumongameli wangaphambilini weligi yabantu abasikazi behlangano angie&lt;ref&gt;{{Cite web |title=Angie Motshekga |url=http://www.pa.org.za/person/matsie-angelina-motshekga/ |access-date=2025-09-04 |website=People's Assembly |language=en}}&lt;/ref&gt; .

U-Motshekga wabelethwa mhla amalanga ali-19 ngenyanga ka Mgwengweni ngomnyaka we-1955 eSoweto, nge Transvaal Province .Wafumana ifundo yakhe yamabanga aphasi eenkolweni ezihlukahlukeneko e-Soweto. Waphumelela esikolweni sokuhlala e -Matatiele. U-Motshekga wafunda e- University of the North, lapho athola khona idigri yakhe ye-Bachelor of Arts ku-Education. E- University of the Witwatersrand, u-Motshekga wathola i-Bachelor of Educational Science degree kanye ne-master's degree.

Ngomnyaka we-1981, u-Motshekga waqatjhwa njengotitjhere e-Orlando High School. Waberega esikolweni bekwafika umnyaka we-1983, lokha nakatjhiya umsebenzi ngemva kokuqatjhwa njengomfundisi e-Soweto College of Education. U-Motshekga waba mfundisi e-University of the Witwatersrand ngomnyaka we-1985. Wafundisa e-University bekwafika umnyaka we-1994. 



== '''Imithombo lwazi''' ==
{{Reflist}}</text>
      <sha1>k21bfkl19oza818k7bk1d95fwfikoja</sha1>
    </revision>
    <revision>
      <id>5577</id>
      <parentid>5542</parentid>
      <timestamp>2025-09-04T09:53:32Z</timestamp>
      <contributor>
        <username>NASKHOSANA</username>
        <id>884</id>
      </contributor>
      <origin>5577</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2577" sha1="nfajcrwp1ypdz8a41vbyudnyse87r6h" xml:space="preserve">
 

'''U-Matsie Angelina &quot;Angie&quot; Motshekga'''&lt;ref&gt;{{Cite web |title=Angie Motshekga, Ms {{!}} South African Government |url=https://www.gov.za/about-government/contact-directory/defence-and-military-veterans-ministry/angie-motshekga-ms |access-date=2025-09-04 |website=www.gov.za}}&lt;/ref&gt;  (wabelethwa mhla amalanga ali-19 kuMgwengweni ngomnyaka we-1955).Ungusopolotiki begodu mfundisi [[Isewula Afrika|weSewula Afrika]] osele aberega njengoNgqongqotjhe wezokuVikela amajoni weButho kusukela mhla amalanga ali-3 kuNtaka ngomnyaka wee-2024.&lt;ref&gt;MOTSHEKGA, M.A. and MINISTER, M., 2022. Department of Basic Education.&lt;/ref&gt; Uberege njengomengameli weRiphabhliki yeSewula Afrika kusukela mhla amalanga ali-17 kuRhoboyi ngomnyaka wee-2024, ngesikhathi uMongameli u Cyril Ramaphosa akhambele  UmHlangano we-44th weenhloko zombuso noRhulumende we -Southern African angie &lt;ref&gt;{{Cite web |last=website |first=2025 © Department of Military Veterans |title=The Department of Military Veterans |url=http://www.dmv.gov.za/ |access-date=2025-09-04 |website=The official Department of Military Veterans website}}&lt;/ref&gt;

Development Community e- Harare, e-[[Zimbabwe]] .  U-Motshekga godu wasebenza njengoNgqongqotjhe wezeFundo Sisekelo kusukela ngoMeyi ngomnyaka wee-2009 ukuya emnyakeni wee-2024. Ngaphambili, bekalilunga lomKhandlu oPhetheko kurhulumende wesifunda sange-Gauteng . U-Motshekga ulilunga le- [[:en:African_National_Congress|African National Congress]] . Bekangumongameli wangaphambilini weligi yabantu abasikazi behlangano angie&lt;ref&gt;{{Cite web |title=Angie Motshekga |url=http://www.pa.org.za/person/matsie-angelina-motshekga/ |access-date=2025-09-04 |website=People's Assembly |language=en}}&lt;/ref&gt; .

U-Motshekga wabelethwa mhla amalanga ali-19 ngenyanga ka Mgwengweni ngomnyaka we-1955 eSoweto, nge Transvaal Province .Wafumana ifundo yakhe yamabanga aphasi eenkolweni ezihlukahlukeneko e-Soweto. Waphumelela esikolweni sokuhlala e -Matatiele. U-Motshekga wafunda e- University of the North, lapho athola khona idigri yakhe ye-Bachelor of Arts ku-Education. E- University of the Witwatersrand, u-Motshekga wathola i-Bachelor of Educational Science degree kanye ne-master's degree.

Ngomnyaka we-1981, u-Motshekga waqatjhwa njengotitjhere e-Orlando High School. Waberega esikolweni bekwafika umnyaka we-1983, lokha nakatjhiya umsebenzi ngemva kokuqatjhwa njengomfundisi e-Soweto College of Education. U-Motshekga waba mfundisi e-University of the Witwatersrand ngomnyaka we-1985. Wafundisa e-University bekwafika umnyaka we-1994. 



== '''Imithombo lwazi''' ==
{{Reflist}}</text>
      <sha1>nfajcrwp1ypdz8a41vbyudnyse87r6h</sha1>
    </revision>
    <revision>
      <id>5621</id>
      <parentid>5577</parentid>
      <timestamp>2025-09-04T10:40:36Z</timestamp>
      <contributor>
        <username>NASKHOSANA</username>
        <id>884</id>
      </contributor>
      <origin>5621</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2658" sha1="mjk2zkxcve1xupfl4tppwhscu2l1ebw" xml:space="preserve">[[Isimumathi:Minister Angie Motshekga.jpg|thumb|isithombe saka  Angie motshekga]]
 

'''U-Matsie Angelina &quot;Angie&quot; Motshekga'''&lt;ref&gt;{{Cite web |title=Angie Motshekga, Ms {{!}} South African Government |url=https://www.gov.za/about-government/contact-directory/defence-and-military-veterans-ministry/angie-motshekga-ms |access-date=2025-09-04 |website=www.gov.za}}&lt;/ref&gt;  (wabelethwa mhla amalanga ali-19 kuMgwengweni ngomnyaka we-1955).Ungusopolotiki begodu mfundisi [[Isewula Afrika|weSewula Afrika]] osele aberega njengoNgqongqotjhe wezokuVikela amajoni weButho kusukela mhla amalanga ali-3 kuNtaka ngomnyaka wee-2024.&lt;ref&gt;MOTSHEKGA, M.A. and MINISTER, M., 2022. Department of Basic Education.&lt;/ref&gt; Uberege njengomengameli weRiphabhliki yeSewula Afrika kusukela mhla amalanga ali-17 kuRhoboyi ngomnyaka wee-2024, ngesikhathi uMongameli u Cyril Ramaphosa akhambele  UmHlangano we-44th weenhloko zombuso noRhulumende we -Southern African angie &lt;ref&gt;{{Cite web |last=website |first=2025 © Department of Military Veterans |title=The Department of Military Veterans |url=http://www.dmv.gov.za/ |access-date=2025-09-04 |website=The official Department of Military Veterans website}}&lt;/ref&gt;

Development Community e- Harare, e-[[Zimbabwe]] .  U-Motshekga godu wasebenza njengoNgqongqotjhe wezeFundo Sisekelo kusukela ngoMeyi ngomnyaka wee-2009 ukuya emnyakeni wee-2024. Ngaphambili, bekalilunga lomKhandlu oPhetheko kurhulumende wesifunda sange-Gauteng . U-Motshekga ulilunga le- [[:en:African_National_Congress|African National Congress]] . Bekangumongameli wangaphambilini weligi yabantu abasikazi behlangano angie&lt;ref&gt;{{Cite web |title=Angie Motshekga |url=http://www.pa.org.za/person/matsie-angelina-motshekga/ |access-date=2025-09-04 |website=People's Assembly |language=en}}&lt;/ref&gt; .

U-Motshekga wabelethwa mhla amalanga ali-19 ngenyanga ka Mgwengweni ngomnyaka we-1955 eSoweto, nge Transvaal Province .Wafumana ifundo yakhe yamabanga aphasi eenkolweni ezihlukahlukeneko e-Soweto. Waphumelela esikolweni sokuhlala e -Matatiele. U-Motshekga wafunda e- University of the North, lapho athola khona idigri yakhe ye-Bachelor of Arts ku-Education. E- University of the Witwatersrand, u-Motshekga wathola i-Bachelor of Educational Science degree kanye ne-master's degree.

Ngomnyaka we-1981, u-Motshekga waqatjhwa njengotitjhere e-Orlando High School. Waberega esikolweni bekwafika umnyaka we-1983, lokha nakatjhiya umsebenzi ngemva kokuqatjhwa njengomfundisi e-Soweto College of Education. U-Motshekga waba mfundisi e-University of the Witwatersrand ngomnyaka we-1985. Wafundisa e-University bekwafika umnyaka we-1994. 



== '''Imithombo lwazi''' ==
{{Reflist}}</text>
      <sha1>mjk2zkxcve1xupfl4tppwhscu2l1ebw</sha1>
    </revision>
  </page>
  <page>
    <title>Bonang Matheba</title>
    <ns>0</ns>
    <id>907</id>
    <revision>
      <id>5429</id>
      <timestamp>2025-09-04T00:10:02Z</timestamp>
      <contributor>
        <username>Tarryn 29</username>
        <id>886</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1303041580|Bonang Matheba]]&quot;</comment>
      <origin>5429</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7381" sha1="7y1ar04e1tv4wdc83p4wvrmmlh6eid6" xml:space="preserve"> 

'''U-Bonang Dorothy Matheba''' (wabelethwa mhla amalanga ama-25 kuMgwengweni 1987),  ngusaziwako wakumabonakude weSewula Afrika, ubuntu bomrhatjho, umtloli kanye nosomarhwebo. Waziwa ngamakghono wakhe wokwethula okuhle kanye nephimbo lakhe eliqakathekileko. Wethula umdlalo womculo we-SABC 1 ''LIVE'' (nje ekuthiwa ''yi-Live Amp'' ) owakha ukukhanya kwakhe embonini.  Ngo-2006 bekangumsingathi emdlalweni wokubhadela ebusuku. Abahlanganyeli bekufuze badose umtato bese baqagele ipendulo yephazili elula bese bathole imitlomelo yemali.

Ngomnyaka ka-2011, waba ngusaziwako wokuthoma weSewula Afrika owathoma umdlalo wamambala weenkundla zokuthintana owaziwa nge ''-B*Dazzled'' .  Ngomnyaka ka-2013, waba lithunywa lokuthoma leentjhabatjhaba lomhlobo wezimonyo i-Revlon, ngaphandle kwe-US. 

Ngomnyaka ka-2014, waba ngumsingathi we-2014 MTV Europe Music Awards pre-show, okwenza bona abe mSewula Afrika wokuthoma ukusingatha umnyanya wangaphambili.  Ngo-2015, waba m-Afrika wokuthoma ukunikelwa i-E! Iindaba ezikhethekileko ze-Afrika ku-E! .  UBonang Matheba unabalandeli abangaphezu kweengidi ezihlanu ku-Instagram ne-Twitter.

Ngomnyaka ka-2016, wavela kukhava ye-Forbes Woman Africa, eduze nabanye abantu bengubo abathathu boke banikelwe isihloko sokuba yi-Faces of Entrepreneurship.  Wakhupha incwadi yakhe ethi ''Kusuka ku-A ukuya ku-B'' begodu waveza umdlalo wakhe we- ''Being Bonang'', kokubili ngo-2017.   Ngo-2018, wavezwa emlandwini wamandla we-GQ SA, we-edishini kaKhukhulamungu.  Ngomnyaka ka-2024, waba mthuli wemitlomelo ye- Earthshot Prize ngomnyaka wee-2024 ebanjelwe e-Cape Town, eSewula Afrika, othoma ngemitlomelo kinoma ngiyiphi inarha ye-Afrika.

== Ipilo yokuthoma ==
U-Bonang wabelethwa mhla amalanga ama-25 kuMgwengweni  emnyakeni we-1987 eMahikeng borough eNorth West.  Ubelethwa ngumma uCharlotte Mokoena uSekela-Mongameli oPhetheko we-Human Resource kanye nezeKampanini neSasol. Ubabakhe nguGampi Matheba, umfundisi omkhulu eNorth West University.  UBonang ngewesitjhaba esikhuluma isiTswana.  

Umndeni wakhe wathuthela e-Leondale, eMpumalanga eJwanisbhege, ngesikhathi u-Bonang asafunda esikolweni sikaRhulumede esibiza ngokuthi yi-Fourways High School esise-Fourways eJwanisbhege. 

== Ibizelo ==

=== Umabonakude kanye nefilimu ===
Ngomnyaka ka-2002, uBonang wenza ukudlala kwakhe kokuthoma kumabonakude emdlalweni wabantwana weSABC 2, ''i-Manhattan Fantasy Challenge'' nakaneminyaka eli-15.  Wabuya wavela keminye imidlalo yabantwana ye-SABC 2.  Ngomnyaka ka-2007, uBonang wenza i-audition yesizini yokuthoma yomdlalo womculo weSABC 1 ''LIVE'' ( eyaziwa nge ''-Live Amp'' namhlanje) ngemva kokutjhiya i-varsity.  Ngokukhamba kwesikhathi wabekwa umqhele womnqobi womdlalo lo ukuze abe ngumsingathi no-Tbo Touch. Imisebenzi yakhe yokwethula yaba yipumelelo ekulu begodu kulapho ibizo lakhe elithi &quot;Queen B&quot; ladalwa khona. Isiqephu sakhe sokugcina sarhatjhwa mhla amalanga ama-31 kuRhoboyi emnyakeni wee-2012 njengombana amemezela bona utjhiya umdlalo.  Ngemva kokusuka kwakhe ku- ''LIVE'', waba neminye imidlalo eminengi efaka hlangana iClash of the Choirs SA, Afternoon Express, Top Billing kanye ne ''-KFC'' Taste Kitchen. 

UBonang Matheba sele amukele amashowu amanengi wemitlomelo neminyanya eqakathekileko khulu iMTV Africa Music Awards 2016, Miss South Africa 2018 kanye nemidlalo yangaphambi kwe-2014 MTV Europe Music Awards kanye ne- BET Awards 2016.   Mhla amalanga ali-2 kuNobayeni ngomnyaka wee-2018, uBonang Matheba wabamba ikhonsathi ye- Global Citizen: Mandela 100 kanye nosomahlaya u-Trevor Noah, i-supermodel uNaomi Campbell, [https://www.newshub360.net/a-reece-net-worth/ i-PistolWhipPapi] nabanye abantu abadumileko. 

Ngo-2008, uBonang Matheba wenza indima yakhe yokuthoma emdlalweni we-SABC 1, i ''-InterSEXions'' lapho adlala khona indima ka-Nurse Seipati.  Kusukela ngo-2019, wadlala begodu wakhiqiza ifilimu yedokhumenthri ''ethi Public Figure'', eyathoma ukuvezwa mhla amalanga ali-9 kuNtaka e-Manchester Film Festival. 

UBonang wasungula indlu yakhe yokukhiqiza ebizwa nge-Bonang Matheba Entertainment ngo-2017. Iyunithi yokukhiqiza inomdlalo owodwa, okuyi- 1 Magic reality show, ''u-Being Bonang'' ozimiseleko begodu otjengisa ipilo kaBonang Matheba yelanga nelanga. 

NgoMrhayili 2022, waba msingathi we-Africa Magic Viewers' Choice Awards. 

Ngenyanga kaRhoboyi  ngomnyaka wee-2023, uBonang wamenyezelwa njengomsingathi wephaliswano le-Miss South Africa 2023. 

Ngasekupheleni kukaVelabahlinze ngomnyaka wee-2024, uBonang wamemezela umdlalo wakhe weqiniso ''u-B'Dazzled osungulwe nguye'', oqale ku-SABC 3 ngo-18:00 ebusuku SAST, mhla amalanga ama-29 kuNtaka. 

Ekuthomeni kwakaKhukhulamungu ngomnyaka wee-2024, uBonang wamenyezelwa njengomsingathi we-Miss Universe Pageant. 

UBonang Matheba, kanye no-Billy Porter, babamba i-Earthshot Prize Awards ebanjelwe e-Cape Town mhla amalanga asi-6 kuNobayeni 2024. 

=== Umrhatjho ===
Ngomnyaka wee-2009, uBonang wathola umtato ovela esitetjhini somrhatjho i-YFM lapho atjelwa khona bona uzokufakwa emhakheni omutjha wabethuli.  Wafumana umdlalo wakhe wangepelaveke wemini obizwa ngokuthi, &quot;I-B* Hive&quot;, owaba yipumelelo msinyana ngokudzimelela ebalalelini abatjha. Watjhiya umsebenzi ngomnyaka wee-2014. 

UBonang Matheba wamenyezelwa njengo-DJ omutjha womrhatjho we-Metro FM ngo-2015.  Wathatha isikhundla saka-Siphokazi u-January owaba mtjhayeli we-Metro FM.  Umdlalo kaMatheba we-slot ''i-The Front Row'', waba nabalaleli abakhulu nabathabileko bekwaba kulapho kuvela ukungazwani nomphathi wesitetjhi somrhatjho, ngemva kokutjhugululwa komrhatjho, u-Bonang wabamba umdlalo ecadi komphikisi wakhe wesikhathi eside u-Lerato Kganyago ngaphandle kwesaziso sakhe.  Ngokukwata kanye nokungakhulumisani kkwabo, u-Bonang watjhiya umsebenzi esitetjhini somrhatjho ngelanga elilandelako. 
{| class=&quot;wikitable sortable&quot;
!Year
!Title
!Role
! class=&quot;unsortable&quot; |Notes
|-
|-
|2007–2012
|''Live Amp''
|Herself
|Host
|-
|2011
|''InterSEXions''
|Nurse Seipati
|Television series
|-
|2012
|''18th South African Music Awards''
|Herself
|Host
|-
|2012
|''Top Billing''
|Herself
|Presenter
|-
|2013
|''Don't Judge''
|Herself
|
|-
|2014
|''Zaziwa''
|Herself
|Guest
|-
|2014
|''2014 MTV Europe Music Awards''
|Herself
|Pre-show host
|-
|2015–2016
|''Afternoon Express''
|Herself
|Presenter
|-
|2016
|''E! Africa Red-Carpet''
|Herself
|Host
|-
|2016
|''BET Awards 2016''
|Herself
|Pre-show host
|-
|2016
|''MTV Africa Music Awards 2016''
|Herself
|Co-Host
|-
|2017
|''2017 Namibia Annual Music Awards''
|Herself
|Host
|-
|2017
|''KFC Taste Kitchen''
|Herself
|Host
|-
|2017–2019
|''Being Bonang''
|Herself
|Main role
|-
|2017
|''2017 DStv Mzansi Viewers' Choice Awards''
|Herself
|Host
|-
|2018
|''Miss South Africa 2018''
|Herself
|Host
|-
|2018
|''Real Talk''
|Herself
|Guest
|-
|2018
|''2018 DStv Mzansi Viewers' Choice Awards''
|Herself
|Host
|-
|2018
|''Global Citizen: Mandela 100''
|Herself
|Co-host
|-
|2018
|''Tropika Smoooth Fan''
|Herself
|Celebrity Guest
|-
|2019
|''PSL Awards''
|Herself
|Host
|-
|2019
|''Miss South Africa 2019''
| rowspan=&quot;4&quot; |Herself
| rowspan=&quot;3&quot; |Host
|-
|2023
|''Miss South Africa 2023''
|-
|2024
|''Miss South Africa 2024''
|-
|2024
|''Earthshot Prize Awards''
|Co-host
|}

=== Ifilimu ===
{| class=&quot;wikitable sortable&quot;
!Year
!Title
!Role
! class=&quot;unsortable&quot; |Notes
|-
|2019
|''Public Figure''
|Herself
|Appearance&lt;br /&gt;&lt;br /&gt;Co-producer
|}
{{Reflist}}</text>
      <sha1>7y1ar04e1tv4wdc83p4wvrmmlh6eid6</sha1>
    </revision>
    <revision>
      <id>5548</id>
      <parentid>5429</parentid>
      <timestamp>2025-09-04T09:36:07Z</timestamp>
      <contributor>
        <username>Tarryn 29</username>
        <id>886</id>
      </contributor>
      <comment>Linked an article</comment>
      <origin>5548</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7452" sha1="gvp94zmetkbi6vtzh3z8qjcdded4vlc" xml:space="preserve">'''U-Bonang Dorothy Matheba''' (wabelethwa mhla amalanga ama-25 kuMgwengweni 1987),  ngusaziwako wakumabonakude weSewula Afrika, ubuntu bomrhatjho, umtloli kanye nosomarhwebo. Waziwa ngamakghono wakhe wokwethula okuhle kanye nephimbo lakhe eliqakathekileko. Wethula umdlalo womculo we-SABC 1 ''LIVE'' (nje ekuthiwa ''yi-Live Amp'' ) owakha ukukhanya kwakhe embonini.  Ngo-2006 bekangumsingathi emdlalweni wokubhadela ebusuku. Abahlanganyeli bekufuze badose umtato bese baqagele ipendulo yephazili elula bese bathole imitlomelo yemali.

Ngomnyaka ka-2011, waba ngusaziwako wokuthoma weSewula Afrika owathoma umdlalo wamambala weenkundla zokuthintana owaziwa nge ''-B*Dazzled'' .  Ngomnyaka ka-2013, waba lithunywa lokuthoma leentjhabatjhaba lomhlobo wezimonyo i-Revlon, ngaphandle kwe-US. 

Ngomnyaka ka-2014, waba ngumsingathi we-2014 MTV Europe Music Awards pre-show, okwenza bona abe mSewula Afrika wokuthoma ukusingatha umnyanya wangaphambili.  Ngo-2015, waba m-Afrika wokuthoma ukunikelwa i-E! Iindaba ezikhethekileko ze-Afrika ku-E! .  UBonang Matheba unabalandeli abangaphezu kweengidi ezihlanu ku-Instagram ne-Twitter.

Ngomnyaka ka-2016, wavela kukhava ye-Forbes Woman Africa, eduze nabanye abantu bengubo abathathu boke banikelwe isihloko sokuba yi-Faces of Entrepreneurship.  Wakhupha incwadi yakhe ethi ''Kusuka ku-A ukuya ku-B'' begodu waveza umdlalo wakhe we- ''Being Bonang'', kokubili ngo-2017.   Ngo-2018, wavezwa emlandwini wamandla we-GQ SA, we-edishini kaKhukhulamungu.  Ngomnyaka ka-2024, waba mthuli wemitlomelo ye- Earthshot Prize ngomnyaka wee-2024 ebanjelwe e-Cape Town, e[[ISewula Afrika ne-Afrika eseSewula (South Africa and Southern Africa).|Sewula Afrika]], othoma ngemitlomelo kinoma ngiyiphi inarha ye-Afrika.

== Ipilo yokuthoma ==
U-Bonang wabelethwa mhla amalanga ama-25 kuMgwengweni  emnyakeni we-1987 eMahikeng borough eNorth West.  Ubelethwa ngumma uCharlotte Mokoena uSekela-Mongameli oPhetheko we-Human Resource kanye nezeKampanini neSasol. Ubabakhe nguGampi Matheba, umfundisi omkhulu eNorth West University.  UBonang ngewesitjhaba esikhuluma isiTswana.  

Umndeni wakhe wathuthela e-Leondale, eMpumalanga eJwanisbhege, ngesikhathi u-Bonang asafunda esikolweni sikaRhulumede esibiza ngokuthi yi-Fourways High School esise-Fourways eJwanisbhege. 

== Ibizelo ==

=== Umabonakude kanye nefilimu ===
Ngomnyaka ka-2002, uBonang wenza ukudlala kwakhe kokuthoma kumabonakude emdlalweni wabantwana weSABC 2, ''i-Manhattan Fantasy Challenge'' nakaneminyaka eli-15.  Wabuya wavela keminye imidlalo yabantwana ye-SABC 2.  Ngomnyaka ka-2007, uBonang wenza i-audition yesizini yokuthoma yomdlalo womculo weSABC 1 ''LIVE'' ( eyaziwa nge ''-Live Amp'' namhlanje) ngemva kokutjhiya i-varsity.  Ngokukhamba kwesikhathi wabekwa umqhele womnqobi womdlalo lo ukuze abe ngumsingathi no-Tbo Touch. Imisebenzi yakhe yokwethula yaba yipumelelo ekulu begodu kulapho ibizo lakhe elithi &quot;Queen B&quot; ladalwa khona. Isiqephu sakhe sokugcina sarhatjhwa mhla amalanga ama-31 kuRhoboyi emnyakeni wee-2012 njengombana amemezela bona utjhiya umdlalo.  Ngemva kokusuka kwakhe ku- ''LIVE'', waba neminye imidlalo eminengi efaka hlangana iClash of the Choirs SA, Afternoon Express, Top Billing kanye ne ''-KFC'' Taste Kitchen. 

UBonang Matheba sele amukele amashowu amanengi wemitlomelo neminyanya eqakathekileko khulu iMTV Africa Music Awards 2016, Miss South Africa 2018 kanye nemidlalo yangaphambi kwe-2014 MTV Europe Music Awards kanye ne- BET Awards 2016.   Mhla amalanga ali-2 kuNobayeni ngomnyaka wee-2018, uBonang Matheba wabamba ikhonsathi ye- Global Citizen: Mandela 100 kanye nosomahlaya u-Trevor Noah, i-supermodel uNaomi Campbell, [https://www.newshub360.net/a-reece-net-worth/ i-PistolWhipPapi] nabanye abantu abadumileko. 

Ngo-2008, uBonang Matheba wenza indima yakhe yokuthoma emdlalweni we-SABC 1, i ''-InterSEXions'' lapho adlala khona indima ka-Nurse Seipati.  Kusukela ngo-2019, wadlala begodu wakhiqiza ifilimu yedokhumenthri ''ethi Public Figure'', eyathoma ukuvezwa mhla amalanga ali-9 kuNtaka e-Manchester Film Festival. 

UBonang wasungula indlu yakhe yokukhiqiza ebizwa nge-Bonang Matheba Entertainment ngo-2017. Iyunithi yokukhiqiza inomdlalo owodwa, okuyi- 1 Magic reality show, ''u-Being Bonang'' ozimiseleko begodu otjengisa ipilo kaBonang Matheba yelanga nelanga. 

NgoMrhayili 2022, waba msingathi we-Africa Magic Viewers' Choice Awards. 

Ngenyanga kaRhoboyi  ngomnyaka wee-2023, uBonang wamenyezelwa njengomsingathi wephaliswano le-Miss South Africa 2023. 

Ngasekupheleni kukaVelabahlinze ngomnyaka wee-2024, uBonang wamemezela umdlalo wakhe weqiniso ''u-B'Dazzled osungulwe nguye'', oqale ku-SABC 3 ngo-18:00 ebusuku SAST, mhla amalanga ama-29 kuNtaka. 

Ekuthomeni kwakaKhukhulamungu ngomnyaka wee-2024, uBonang wamenyezelwa njengomsingathi we-Miss Universe Pageant. 

UBonang Matheba, kanye no-Billy Porter, babamba i-Earthshot Prize Awards ebanjelwe e-Cape Town mhla amalanga asi-6 kuNobayeni 2024. 

=== Umrhatjho ===
Ngomnyaka wee-2009, uBonang wathola umtato ovela esitetjhini somrhatjho i-YFM lapho atjelwa khona bona uzokufakwa emhakheni omutjha wabethuli.  Wafumana umdlalo wakhe wangepelaveke wemini obizwa ngokuthi, &quot;I-B* Hive&quot;, owaba yipumelelo msinyana ngokudzimelela ebalalelini abatjha. Watjhiya umsebenzi ngomnyaka wee-2014. 

UBonang Matheba wamenyezelwa njengo-DJ omutjha womrhatjho we-Metro FM ngo-2015.  Wathatha isikhundla saka-Siphokazi u-January owaba mtjhayeli we-Metro FM.  Umdlalo kaMatheba we-slot ''i-The Front Row'', waba nabalaleli abakhulu nabathabileko bekwaba kulapho kuvela ukungazwani nomphathi wesitetjhi somrhatjho, ngemva kokutjhugululwa komrhatjho, u-Bonang wabamba umdlalo ecadi komphikisi wakhe wesikhathi eside u-Lerato Kganyago ngaphandle kwesaziso sakhe.  Ngokukwata kanye nokungakhulumisani kkwabo, u-Bonang watjhiya umsebenzi esitetjhini somrhatjho ngelanga elilandelako. 
{| class=&quot;wikitable sortable&quot;
!Year
!Title
!Role
! class=&quot;unsortable&quot; |Notes
|-
|-
|2007–2012
|''Live Amp''
|Herself
|Host
|-
|2011
|''InterSEXions''
|Nurse Seipati
|Television series
|-
|2012
|''18th South African Music Awards''
|Herself
|Host
|-
|2012
|''Top Billing''
|Herself
|Presenter
|-
|2013
|''Don't Judge''
|Herself
|
|-
|2014
|''Zaziwa''
|Herself
|Guest
|-
|2014
|''2014 MTV Europe Music Awards''
|Herself
|Pre-show host
|-
|2015–2016
|''Afternoon Express''
|Herself
|Presenter
|-
|2016
|''E! Africa Red-Carpet''
|Herself
|Host
|-
|2016
|''BET Awards 2016''
|Herself
|Pre-show host
|-
|2016
|''MTV Africa Music Awards 2016''
|Herself
|Co-Host
|-
|2017
|''2017 Namibia Annual Music Awards''
|Herself
|Host
|-
|2017
|''KFC Taste Kitchen''
|Herself
|Host
|-
|2017–2019
|''Being Bonang''
|Herself
|Main role
|-
|2017
|''2017 DStv Mzansi Viewers' Choice Awards''
|Herself
|Host
|-
|2018
|''Miss South Africa 2018''
|Herself
|Host
|-
|2018
|''Real Talk''
|Herself
|Guest
|-
|2018
|''2018 DStv Mzansi Viewers' Choice Awards''
|Herself
|Host
|-
|2018
|''Global Citizen: Mandela 100''
|Herself
|Co-host
|-
|2018
|''Tropika Smoooth Fan''
|Herself
|Celebrity Guest
|-
|2019
|''PSL Awards''
|Herself
|Host
|-
|2019
|''Miss South Africa 2019''
| rowspan=&quot;4&quot; |Herself
| rowspan=&quot;3&quot; |Host
|-
|2023
|''Miss South Africa 2023''
|-
|2024
|''Miss South Africa 2024''
|-
|2024
|''Earthshot Prize Awards''
|Co-host
|}

=== Ifilimu ===
{| class=&quot;wikitable sortable&quot;
!Year
!Title
!Role
! class=&quot;unsortable&quot; |Notes
|-
|2019
|''Public Figure''
|Herself
|Appearance&lt;br /&gt;&lt;br /&gt;Co-producer
|}
{{Reflist}}</text>
      <sha1>gvp94zmetkbi6vtzh3z8qjcdded4vlc</sha1>
    </revision>
    <revision>
      <id>5658</id>
      <parentid>5548</parentid>
      <timestamp>2025-09-04T11:09:04Z</timestamp>
      <contributor>
        <username>Tarryn 29</username>
        <id>886</id>
      </contributor>
      <comment>Ngingezelele ilwazi</comment>
      <origin>5658</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6489" sha1="tqdivoudjy5sen0oi6myn95bgk0jb10" xml:space="preserve">[[Isimumathi:Bonang Matheba.jpg|thumb|Isithombe sakaBonang Dorothy Matheba]]
'''U-Bonang Dorothy Matheba''' (wabelethwa mhla amalanga ama-25 kuMgwengweni 1987),  ngusaziwako wakumabonakude weSewula Afrika, ubuntu bomrhatjho, umtloli kanye nosomarhwebo. Waziwa ngamakghono wakhe wokwethula okuhle kanye nephimbo lakhe eliqakathekileko. Wethula umdlalo womculo we-SABC 1 ''LIVE'' (nje ekuthiwa ''yi-Live Amp'' ) owakha ukukhanya kwakhe eembonini &lt;ref&gt;{{Cite web|title=Figure 2: Female, 38 years old, squamous cell carcinoma of the cervix, p16 negative.|url=https://doi.org/10.7717/peerj.19387/fig-2|access-date=2025-09-04|website=doi.org}}&lt;/ref&gt;.  Ngo-2006 bekangumsingathi emdlalweni wokubhadela ebusuku. Abahlanganyeli bekufuze badose umtato bese baqagele ipendulo yephazili elula bese bathole imitlomelo yemali.

Ngomnyaka ka-2011, waba ngusaziwako wokuthoma weSewula Afrika owathoma umdlalo wamambala weenkundla zokuthintana owaziwa nge ''-B*Dazzled'' &lt;ref&gt;{{Cite book|url=https://doi.org/10.1093/gmo/9781561592630.article.l2275249|title=Bonang|date=2015-01-13|publisher=Oxford University Press|series=Oxford Music Online}}&lt;/ref&gt;.  Ngomnyaka ka-2013, waba lithunywa lokuthoma leentjhabatjhaba lomhlobo wezimonyo i-Revlon, ngaphandle kwe-US.

Ngomnyaka ka-2014, waba ngumsingathi we-2014 MTV Europe Music Awards pre-show, okwenza bona abe mSewula Afrika wokuthoma ukusingatha umnyanya wangaphambili.  Ngo-2015, waba m-Afrika wokuthoma ukunikelwa i-E! Iindaba ezikhethekileko ze-Afrika ku-E! .  UBonang Matheba unabalandeli abangaphezu kweengidi ezihlanu ku-Instagram ne-Twitter.

Ngomnyaka ka-2016, wavela kukhava ye-Forbes Woman Africa, eduze nabanye abantu bengubo abathathu boke banikelwe isihloko sokuba yi-Faces of Entrepreneurship.  Wakhupha incwadi yakhe ethi ''Kusuka ku-A ukuya ku-B'' begodu waveza umdlalo wakhe we- ''Being Bonang'', kokubili ngo-2017&lt;ref&gt;{{Cite book|last=Matheba|first=Bonang|title=From A to B|date=17 July 2017|publisher=BlackBird Books|year=2017|isbn=9781928337423}}&lt;/ref&gt;.   Ngo-2018, wavezwa emlandwini wamandla we-GQ SA, we-edishini kaKhukhulamungu.  Ngomnyaka ka-2024, waba mthuli wemitlomelo ye- Earthshot Prize ngomnyaka wee-2024 ebanjelwe e-Cape Town, e[[ISewula Afrika ne-Afrika eseSewula (South Africa and Southern Africa).|Sewula Afrika]], othoma ngemitlomelo kinoma ngiyiphi inarha ye-Afrika.

== Ipilo yokuthoma ==
U-Bonang wabelethwa mhla amalanga ama-25 kuMgwengweni  emnyakeni we-1987 eMahikeng borough eNorth West.  Ubelethwa ngumma uCharlotte Mokoena uSekela-Mongameli oPhetheko we-Human Resource kanye nezeKampanini neSasol. Ubabakhe nguGampi Matheba, umfundisi omkhulu eNorth West University.  UBonang ngewesitjhaba esikhuluma isiTswana.

Umndeni wakhe wathuthela e-Leondale, eMpumalanga eJwanisbhege, ngesikhathi u-Bonang asafunda esikolweni sikaRhulumede esibiza ngokuthi yi-Fourways High School esise-Fourways eJwanisbhege.

== Ibizelo ==
=== Umabonakude kanye nefilimu ===
Ngomnyaka ka-2002, uBonang wenza ukudlala kwakhe kokuthoma kumabonakude emdlalweni wabantwana weSABC 2, ''i-Manhattan Fantasy Challenge'' nakaneminyaka eli-15.  Wabuya wavela keminye imidlalo yabantwana ye-SABC 2.  Ngomnyaka ka-2007, uBonang wenza i-audition yesizini yokuthoma yomdlalo womculo weSABC 1 ''LIVE'' ( eyaziwa nge ''-Live Amp'' namhlanje) ngemva kokutjhiya i-varsity.  Ngokukhamba kwesikhathi wabekwa umqhele womnqobi womdlalo lo ukuze abe ngumsingathi no-Tbo Touch. Imisebenzi yakhe yokwethula yaba yipumelelo ekulu begodu kulapho ibizo lakhe elithi &quot;Queen B&quot; ladalwa khona. Isiqephu sakhe sokugcina sarhatjhwa mhla amalanga ama-31 kuRhoboyi emnyakeni wee-2012 njengombana amemezela bona utjhiya umdlalo.  Ngemva kokusuka kwakhe ku- ''LIVE'', waba neminye imidlalo eminengi efaka hlangana iClash of the Choirs SA, Afternoon Express, Top Billing kanye ne ''-KFC'' Taste Kitchen.

UBonang Matheba sele amukele amashowu amanengi wemitlomelo neminyanya eqakathekileko khulu iMTV Africa Music Awards 2016, Miss South Africa 2018 kanye nemidlalo yangaphambi kwe-2014 MTV Europe Music Awards kanye ne- BET Awards 2016.   Mhla amalanga ali-2 kuNobayeni ngomnyaka wee-2018, uBonang Matheba wabamba ikhonsathi ye- Global Citizen: Mandela 100 kanye nosomahlaya u-Trevor Noah, i-supermodel uNaomi Campbell, [https://www.newshub360.net/a-reece-net-worth/ i-PistolWhipPapi] nabanye abantu abadumileko.

Ngo-2008, uBonang Matheba wenza indima yakhe yokuthoma emdlalweni we-SABC 1, i ''-InterSEXions'' lapho adlala khona indima ka-Nurse Seipati.  Kusukela ngo-2019, wadlala begodu wakhiqiza ifilimu yedokhumenthri ''ethi Public Figure'', eyathoma ukuvezwa mhla amalanga ali-9 kuNtaka e-Manchester Film Festival.

UBonang wasungula indlu yakhe yokukhiqiza ebizwa nge-Bonang Matheba Entertainment ngo-2017. Iyunithi yokukhiqiza inomdlalo owodwa, okuyi- 1 Magic reality show, ''u-Being Bonang'' ozimiseleko begodu otjengisa ipilo kaBonang Matheba yelanga nelanga.

NgoMrhayili 2022, waba msingathi we-Africa Magic Viewers' Choice Awards.

Ngenyanga kaRhoboyi  ngomnyaka wee-2023, uBonang wamenyezelwa njengomsingathi wephaliswano le-Miss South Africa 2023.

Ngasekupheleni kukaVelabahlinze ngomnyaka wee-2024, uBonang wamemezela umdlalo wakhe weqiniso ''u-B'Dazzled osungulwe nguye'', oqale ku-SABC 3 ngo-18:00 ebusuku SAST, mhla amalanga ama-29 kuNtaka.

Ekuthomeni kwakaKhukhulamungu ngomnyaka wee-2024, uBonang wamenyezelwa njengomsingathi we-Miss Universe Pageant.

UBonang Matheba, kanye no-Billy Porter, babamba i-Earthshot Prize Awards ebanjelwe e-Cape Town mhla amalanga asi-6 kuNobayeni 2024.

=== Umrhatjho ===
Ngomnyaka wee-2009, uBonang wathola umtato ovela esitetjhini somrhatjho i-YFM lapho atjelwa khona bona uzokufakwa emhakheni omutjha wabethuli.  Wafumana umdlalo wakhe wangepelaveke wemini obizwa ngokuthi, &quot;I-B* Hive&quot;, owaba yipumelelo msinyana ngokudzimelela ebalalelini abatjha. Watjhiya umsebenzi ngomnyaka wee-2014.

UBonang Matheba wamenyezelwa njengo-DJ omutjha womrhatjho we-Metro FM ngo-2015.  Wathatha isikhundla saka-Siphokazi u-January owaba mtjhayeli we-Metro FM.  Umdlalo kaMatheba we-slot ''i-The Front Row'', waba nabalaleli abakhulu nabathabileko bekwaba kulapho kuvela ukungazwani nomphathi wesitetjhi somrhatjho, ngemva kokutjhugululwa komrhatjho, u-Bonang wabamba umdlalo ecadi komphikisi wakhe wesikhathi eside u-Lerato Kganyago ngaphandle kwesaziso sakhe.  Ngokukwata kanye nokungakhulumisani kkwabo, u-Bonang watjhiya umsebenzi esitetjhini somrhatjho ngelanga elilandelako.

=== Imithombo lwazi ===
&lt;references /&gt;
{{Reflist}}</text>
      <sha1>tqdivoudjy5sen0oi6myn95bgk0jb10</sha1>
    </revision>
    <revision>
      <id>5694</id>
      <parentid>5658</parentid>
      <timestamp>2025-09-04T11:48:50Z</timestamp>
      <contributor>
        <username>Tarryn 29</username>
        <id>886</id>
      </contributor>
      <origin>5694</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6473" sha1="pm232w0x48pi8kdog3nkvveasp40qn6" xml:space="preserve">[[Isimumathi:Bonang Matheba.jpg|thumb|Isithombe sakaBonang Dorothy Matheba]]
'''U-Bonang Dorothy Matheba''' wabelethwa mhla amalanga ama-25 kuMgwengweni 1987, ngusaziwako wakumabonakude weSewula Afrika, ubuntu bomrhatjho, umtloli kanye nosomarhwebo. Waziwa ngamakghono wakhe wokwethula okuhle kanye nephimbo lakhe eliqakathekileko. Wethula umdlalo womculo we-SABC 1 ''LIVE'' (nje ekuthiwa ''yi-Live Amp'') owakha ukukhanya kwakhe eembonini &lt;ref&gt;{{Cite web|title=Figure 2: Female, 38 years old, squamous cell carcinoma of the cervix, p16 negative.|url=https://doi.org/10.7717/peerj.19387/fig-2|access-date=2025-09-04|website=doi.org}}&lt;/ref&gt;.  Ngo-2006 bekangumsingathi emdlalweni wokubhadela ebusuku. Abahlanganyeli bekufuze badose umtato bese baqagele ipendulo yephazili elula bese bathole imitlomelo yemali.

Ngomnyaka ka-2011, waba ngusaziwako wokuthoma weSewula Afrika owathoma umdlalo wamambala weenkundla zokuthintana owaziwa nge ''-B*Dazzled'' &lt;ref&gt;{{Cite book|url=https://doi.org/10.1093/gmo/9781561592630.article.l2275249|title=Bonang|date=2015-01-13|publisher=Oxford University Press|series=Oxford Music Online}}&lt;/ref&gt;.  Ngomnyaka ka-2013, waba lithunywa lokuthoma leentjhabatjhaba lomhlobo wezimonyo i-Revlon, ngaphandle kwe-US.

Ngomnyaka ka-2014, waba ngumsingathi we-2014 MTV Europe Music Awards pre-show, okwenza bona abe mSewula Afrika wokuthoma ukusingatha umnyanya wangaphambili.  Ngo-2015, waba m-Afrika wokuthoma ukunikelwa i-E! Iindaba ezikhethekileko ze-Afrika ku-E! .  UBonang Matheba unabalandeli abangaphezu kweengidi ezihlanu ku-Instagram ne-Twitter.

Ngomnyaka ka-2016, wavela kukhava ye-Forbes Woman Africa, eduze nabanye abantu bengubo abathathu boke banikelwe isihloko sokuba yi-Faces of Entrepreneurship.  Wakhupha incwadi yakhe ethi ''Kusuka ku-A ukuya ku-B'' begodu waveza umdlalo wakhe we- ''Being Bonang'', kokubili ngo-2017&lt;ref&gt;{{Cite book|last=Matheba|first=Bonang|title=From A to B|date=17 July 2017|publisher=BlackBird Books|year=2017|isbn=9781928337423}}&lt;/ref&gt;.   Ngo-2018, wavezwa emlandwini wamandla we-GQ SA, we-edishini kaKhukhulamungu.  Ngomnyaka ka-2024, waba mthuli wemitlomelo ye- Earthshot Prize ngomnyaka wee-2024 ebanjelwe e-Cape Town, e[[ISewula Afrika ne-Afrika eseSewula (South Africa and Southern Africa).|Sewula Afrika]], othoma ngemitlomelo kinoma ngiyiphi inarha ye-Afrika.

== Ipilo yokuthoma ==
U-Bonang wabelethwa mhla amalanga ama-25 kuMgwengweni  emnyakeni we-1987 eMahikeng borough eNorth West.  Ubelethwa ngumma uCharlotte Mokoena uSekela-Mongameli oPhetheko we-Human Resource kanye nezeKampanini neSasol. Ubabakhe nguGampi Matheba, umfundisi omkhulu eNorth West University.  UBonang ngewesitjhaba esikhuluma isiTswana.

Umndeni wakhe wathuthela e-Leondale, eMpumalanga eJwanisbhege, ngesikhathi u-Bonang asafunda esikolweni sikaRhulumede esibiza ngokuthi yi-Fourways High School esise-Fourways eJwanisbhege.

== Ibizelo ==
=== Umabonakude kanye nefilimu ===
Ngomnyaka ka-2002, uBonang wenza ukudlala kwakhe kokuthoma kumabonakude emdlalweni wabantwana weSABC 2, ''i-Manhattan Fantasy Challenge'' nakaneminyaka eli-15.  Wabuya wavela keminye imidlalo yabantwana ye-SABC 2.  Ngomnyaka ka-2007, uBonang wenza i-audition yesizini yokuthoma yomdlalo womculo weSABC 1 ''LIVE'' ( eyaziwa nge ''-Live Amp'' namhlanje) ngemva kokutjhiya i-varsity.  Ngokukhamba kwesikhathi wabekwa umqhele womnqobi womdlalo lo ukuze abe ngumsingathi no-Tbo Touch. Imisebenzi yakhe yokwethula yaba yipumelelo ekulu begodu kulapho ibizo lakhe elithi &quot;Queen B&quot; ladalwa khona. Isiqephu sakhe sokugcina sarhatjhwa mhla amalanga ama-31 kuRhoboyi emnyakeni wee-2012 njengombana amemezela bona utjhiya umdlalo.  Ngemva kokusuka kwakhe ku- ''LIVE'', waba neminye imidlalo eminengi efaka hlangana iClash of the Choirs SA, Afternoon Express, Top Billing kanye ne ''-KFC'' Taste Kitchen.

UBonang Matheba sele amukele amashowu amanengi wemitlomelo neminyanya eqakathekileko khulu iMTV Africa Music Awards 2016, Miss South Africa 2018 kanye nemidlalo yangaphambi kwe-2014 MTV Europe Music Awards kanye ne- BET Awards 2016.   Mhla amalanga ali-2 kuNobayeni ngomnyaka wee-2018, uBonang Matheba wabamba ikhonsathi ye- Global Citizen: Mandela 100 kanye nosomahlaya u-Trevor Noah, i-supermodel uNaomi Campbell, [https://www.newshub360.net/a-reece-net-worth/ i-PistolWhipPapi] nabanye abantu abadumileko.

Ngo-2008, uBonang Matheba wenza indima yakhe yokuthoma emdlalweni we-SABC 1, i ''-InterSEXions'' lapho adlala khona indima ka-Nurse Seipati.  Kusukela ngo-2019, wadlala begodu wakhiqiza ifilimu yedokhumenthri ''ethi Public Figure'', eyathoma ukuvezwa mhla amalanga ali-9 kuNtaka e-Manchester Film Festival.

UBonang wasungula indlu yakhe yokukhiqiza ebizwa nge-Bonang Matheba Entertainment ngo-2017. Iyunithi yokukhiqiza inomdlalo owodwa, okuyi- 1 Magic reality show, ''u-Being Bonang'' ozimiseleko begodu otjengisa ipilo kaBonang Matheba yelanga nelanga.

NgoMrhayili 2022, waba msingathi we-Africa Magic Viewers' Choice Awards.

Ngenyanga kaRhoboyi  ngomnyaka wee-2023, uBonang wamenyezelwa njengomsingathi wephaliswano le-Miss South Africa 2023.

Ngasekupheleni kukaVelabahlinze ngomnyaka wee-2024, uBonang wamemezela umdlalo wakhe weqiniso ''u-B'Dazzled osungulwe nguye'', oqale ku-SABC 3 ngo-18:00 ebusuku SAST, mhla amalanga ama-29 kuNtaka.

Ekuthomeni kwakaKhukhulamungu ngomnyaka wee-2024, uBonang wamenyezelwa njengomsingathi we-Miss Universe Pageant.

UBonang Matheba, kanye no-Billy Porter, babamba i-Earthshot Prize Awards ebanjelwe e-Cape Town mhla amalanga asi-6 kuNobayeni 2024.

=== Umrhatjho ===
Ngomnyaka wee-2009, uBonang wathola umtato ovela esitetjhini somrhatjho i-YFM lapho atjelwa khona bona uzokufakwa emhakheni omutjha wabethuli.  Wafumana umdlalo wakhe wangepelaveke wemini obizwa ngokuthi, &quot;I-B* Hive&quot;, owaba yipumelelo msinyana ngokudzimelela ebalalelini abatjha. Watjhiya umsebenzi ngomnyaka wee-2014.

UBonang Matheba wamenyezelwa njengo-DJ omutjha womrhatjho we-Metro FM ngo-2015.  Wathatha isikhundla saka-Siphokazi u-January owaba mtjhayeli we-Metro FM.  Umdlalo kaMatheba we-slot ''i-The Front Row'', waba nabalaleli abakhulu nabathabileko bekwaba kulapho kuvela ukungazwani nomphathi wesitetjhi somrhatjho, ngemva kokutjhugululwa komrhatjho, u-Bonang wabamba umdlalo ecadi komphikisi wakhe wesikhathi eside u-Lerato Kganyago ngaphandle kwesaziso sakhe.  Ngokukwata kanye nokungakhulumisani kkwabo, u-Bonang watjhiya umsebenzi esitetjhini somrhatjho ngelanga elilandelako.

=== Imithombo lwazi ===
&lt;references /&gt;</text>
      <sha1>pm232w0x48pi8kdog3nkvveasp40qn6</sha1>
    </revision>
  </page>
  <page>
    <title>I-Kaizer Chiefs FC</title>
    <ns>0</ns>
    <id>908</id>
    <revision>
      <id>5433</id>
      <timestamp>2025-09-04T06:45:25Z</timestamp>
      <contributor>
        <username>Mbonani JayJay</username>
        <id>892</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1309345035|Kaizer Chiefs F.C.]]&quot;</comment>
      <origin>5433</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2295" sha1="ot86pfvtt518nnmoltbqmy8y5eoirai" xml:space="preserve">
{{Infobox football club|clubname=Kaizer Chiefs|image=Kaizer Chiefs logo.svg|image_size=180px|short name=Chiefs|nickname={{Plainlist|
* ''AmaKhosi'' (Kings)
* '' The Phefeni Boys ''
* '' Abafana bokuthula noxolo'' (The Boys of Love &amp; Peace)
* '' The Glamour Boys ''
}}|fullname=Kaizer Chiefs Football Club|founded={{Start date and age|1970|01|07|df=y}}|ground=[[FNB Stadium]]|capacity=94,797|chairman=[[Kaizer Motaung]]|league=[[South African Premiership|Betway Premiership]]|season=[[2024–25 South African Premiership|2024–25]]|current=2025–26 Kaizer Chiefs F.C. season|stadium=[[FNB Stadium]]|position=9th|manager=[[Nasreddine Nabi]]|website={{URL|https://www.kaizerchiefs.com/}}|owner=[[Kaizer Motaung]]|chrtitle=Chairman}}'''I-Kaizer Chiefs Football Club''' (eyaziwa ngokuthi '''yi-Chiefs)''' yisiqhema sebholo ye -Sewula Afrika ese-Naturena, e-Johannesburg South, edlala ku- Premiership￼. Isiqhema sibizwa nge ''-AmaKhosi'', okutjho &quot;amaKhosi&quot; ngesiZulu, kanye nama ''-Phefeni Glamour Boys.'' I-Chiefs sele inqobe iinhlandla ezinengi zeligi kanye namatrophi. Indebe yakamuva yasekhaya bekuyiNdebe ye-Nedbank ka-2024-25￼. Baphethe iinkezo ezinengi khulu hlangana nazo zoke iinqhema zeSewula Afrika begodu bayisiqhema esiphumelele khulu emlandwini webholo yeSewula Afrika solo kwathoma izinga eliphezulu ngo-1970.

Isiqhema sinomncintiswano omkhulu wendawo, i -Soweto derby, ne -Orlando Pirates, isiqhema se-Soweto umsunguli we-Chiefs u-Kaizer Motaung adlala kiso ekuthomeni komsebenzi wakhe wokudlala.  Abadlali abadumileko ebegade bambatha ijezi elimnyama negolide esikhathini esidlulileko bafaka hlangana abokapteni besiqhema &lt;ref name=&quot;thepresidency.gov.za&quot; /&gt;lesitjhaba [[Neil Tovey|u-Neil Tovey]] no -Lucas Radebe kanye no -Patrick Ntsoelengoe, u-Gary Bailey, u-John &quot;Shoes&quot; Moshoeu, u-Shaun Bartlett, u- Steve Komphela, u-Siyabonga Nomvete, u- Doctor no-Khumalo .

Yisiqhema esisekelwa khulu [[Isewula Afrika|eSewula Afrika]]￼. I-Kaizer Chiefs beyinesisekelo esingaphezu kweengidi ezili-16 ekuthomeni kwekhulu leminyaka. Bathola isilinganiso sabantu abafika ekhaya esingu-16,144 ngesizini ka-2019-20, okuphezulu khulu kuligi. Isiqhema sidlala imidlalo eminengi yangekhaya e- FNB Stadium enabantu abama-94,797.  NgoTjhirhweni 2025, i-Kaizer Chiefs yagidinga iminyaka ema-55.</text>
      <sha1>ot86pfvtt518nnmoltbqmy8y5eoirai</sha1>
    </revision>
    <revision>
      <id>5434</id>
      <parentid>5433</parentid>
      <timestamp>2025-09-04T06:48:03Z</timestamp>
      <contributor>
        <username>Mbonani JayJay</username>
        <id>892</id>
      </contributor>
      <origin>5434</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2309" sha1="qg3kveod32v1q8zuod4hk6f7o43u6dh" xml:space="preserve">
{{Infobox football club|clubname=Kaizer Chiefs|image=Kaizer Chiefs logo.svg|image_size=180px|short name=Chiefs|nickname={{Plainlist|
* ''AmaKhosi'' (Kings)
* '' The Phefeni Boys ''
* '' Abafana bokuthula noxolo'' (The Boys of Love &amp; Peace)
* '' The Glamour Boys ''
}}|fullname=Kaizer Chiefs Football Club|founded={{Start date and age|1970|01|07|df=y}}|ground=[[FNB Stadium]]|capacity=94,797|chairman=[[Kaizer Motaung]]|league=[[South African Premiership|Betway Premiership]]|season=[[2024–25 South African Premiership|2024–25]]|current=2025–26 Kaizer Chiefs F.C. season|stadium=[[FNB Stadium]]|position=9th|manager=[[Nasreddine Nabi]]|website={{URL|https://www.kaizerchiefs.com/}}|owner=[[Kaizer Motaung]]|chrtitle=Chairman}}'''I-Kaizer Chiefs Football Club''' (eyaziwa ngokuthi '''yi-Chiefs)''' yisiqhema sebholo ye -Sewula Afrika ese-Naturena, e-Johannesburg South, edlala ku- Premiership￼. Isiqhema sibizwa nge ''-AmaKhosi'', okutjho &quot;amaKhosi&quot; ngesiZulu, kanye nama ''-Phefeni Glamour Boys.'' I-Chiefs sele inqobe iinhlandla ezinengi zeligi kanye namatrophi. Indebe yakamuva yasekhaya bekuyiNdebe ye-Nedbank ka-2024-25￼. Baphethe iinkezo ezinengi khulu hlangana nazo zoke iinqhema zeSewula Afrika begodu bayisiqhema esiphumelele khulu emlandwini webholo yeSewula Afrika solo kwathoma izinga eliphezulu ngo-1970.

Isiqhema sinomncintiswano omkhulu wendawo, i -Soweto derby, ne -Orlando Pirates, isiqhema se-Soweto umsunguli we-Chiefs u-Kaizer Motaung adlala kiso ekuthomeni komsebenzi wakhe wokudlala.  Abadlali abadumileko ebegade bambatha ijezi elimnyama negolide esikhathini esidlulileko bafaka hlangana abokapteni besiqhema &lt;ref name=&quot;thepresidency.gov.za&quot; /&gt;lesitjhaba [[Neil Tovey|u-Neil Tovey]] no -Lucas Radebe kanye no -Patrick Ntsoelengoe, u-Gary Bailey, u-John &quot;Shoes&quot; Moshoeu, u-Shaun Bartlett, u- Steve Komphela, u-Siyabonga Nomvete, u- Doctor no-Khumalo.

Yisiqhema esisekelwa khulu [[Isewula Afrika|eSewula Afrika]]￼. I-Kaizer Chiefs beyinesisekelo esingaphezu kweengidi ezili-16 ekuthomeni kwekhulu leminyaka. Bathola isilinganiso sabantu abafika ekhaya esingu-16,144 ngesizini ka-2019-20, okuphezulu khulu kuligi. Isiqhema sidlala imidlalo eminengi yangekhaya e- FNB Stadium enabantu abama-94,797.  NgoTjhirhweni 2025, i-Kaizer Chiefs yagidinga iminyaka ema-55.
&lt;references /&gt;</text>
      <sha1>qg3kveod32v1q8zuod4hk6f7o43u6dh</sha1>
    </revision>
    <revision>
      <id>5438</id>
      <parentid>5434</parentid>
      <timestamp>2025-09-04T07:48:26Z</timestamp>
      <contributor>
        <username>Mbonani JayJay</username>
        <id>892</id>
      </contributor>
      <comment>added reference section</comment>
      <origin>5438</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2334" sha1="0hvrwpi1z86jpwm3ufzwt30k67l2sz2" xml:space="preserve">
{{Infobox football club|clubname=Kaizer Chiefs|image=Kaizer Chiefs logo.svg|image_size=180px|short name=Chiefs|nickname={{Plainlist|
* ''AmaKhosi'' (Kings)
* '' The Phefeni Boys ''
* '' Abafana bokuthula noxolo'' (The Boys of Love &amp; Peace)
* '' The Glamour Boys ''
}}|fullname=Kaizer Chiefs Football Club|founded={{Start date and age|1970|01|07|df=y}}|ground=[[FNB Stadium]]|capacity=94,797|chairman=[[Kaizer Motaung]]|league=[[South African Premiership|Betway Premiership]]|season=[[2024–25 South African Premiership|2024–25]]|current=2025–26 Kaizer Chiefs F.C. season|stadium=[[FNB Stadium]]|position=9th|manager=[[Nasreddine Nabi]]|website={{URL|https://www.kaizerchiefs.com/}}|owner=[[Kaizer Motaung]]|chrtitle=Chairman}}'''I-Kaizer Chiefs Football Club''' (eyaziwa ngokuthi '''yi-Chiefs)''' yisiqhema sebholo ye -Sewula Afrika ese-Naturena, e-Johannesburg South, edlala ku- Premiership￼. Isiqhema sibizwa nge ''-AmaKhosi'', okutjho &quot;amaKhosi&quot; ngesiZulu, kanye nama ''-Phefeni Glamour Boys.'' I-Chiefs sele inqobe iinhlandla ezinengi zeligi kanye namatrophi. Indebe yakamuva yasekhaya bekuyiNdebe ye-Nedbank ka-2024-25￼. Baphethe iinkezo ezinengi khulu hlangana nazo zoke iinqhema zeSewula Afrika begodu bayisiqhema esiphumelele khulu emlandwini webholo yeSewula Afrika solo kwathoma izinga eliphezulu ngo-1970.

Isiqhema sinomncintiswano omkhulu wendawo, i -Soweto derby, ne -Orlando Pirates, isiqhema se-Soweto umsunguli we-Chiefs u-Kaizer Motaung adlala kiso ekuthomeni komsebenzi wakhe wokudlala.  Abadlali abadumileko ebegade bambatha ijezi elimnyama negolide esikhathini esidlulileko bafaka hlangana abokapteni besiqhema &lt;ref name=&quot;thepresidency.gov.za&quot; /&gt;lesitjhaba [[Neil Tovey|u-Neil Tovey]] no -Lucas Radebe kanye no -Patrick Ntsoelengoe, u-Gary Bailey, u-John &quot;Shoes&quot; Moshoeu, u-Shaun Bartlett, u- Steve Komphela, u-Siyabonga Nomvete, u- Doctor no-Khumalo.

Yisiqhema esisekelwa khulu [[Isewula Afrika|eSewula Afrika]]￼. I-Kaizer Chiefs beyinesisekelo esingaphezu kweengidi ezili-16 ekuthomeni kwekhulu leminyaka. Bathola isilinganiso sabantu abafika ekhaya esingu-16,144 ngesizini ka-2019-20, okuphezulu khulu kuligi. Isiqhema sidlala imidlalo eminengi yangekhaya e- FNB Stadium enabantu abama-94,797.  NgoTjhirhweni 2025, i-Kaizer Chiefs yagidinga iminyaka ema-55.

=== Imithombo lwazi ===
&lt;references /&gt;</text>
      <sha1>0hvrwpi1z86jpwm3ufzwt30k67l2sz2</sha1>
    </revision>
    <revision>
      <id>5452</id>
      <parentid>5438</parentid>
      <timestamp>2025-09-04T07:57:23Z</timestamp>
      <contributor>
        <username>Mbonani JayJay</username>
        <id>892</id>
      </contributor>
      <origin>5452</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2322" sha1="pxn3ra914ksw77gqrqpjfhwla0j4vom" xml:space="preserve">
{{Infobox football club|clubname=Kaizer Chiefs|image=Kaizer Chiefs logo.svg|image_size=180px|short name=Chiefs|nickname={{Plainlist|
* ''AmaKhosi'' (Kings)
* '' The Phefeni Boys ''
* '' Abafana bokuthula noxolo'' (The Boys of Love &amp; Peace)
* '' The Glamour Boys ''
}}|fullname=Kaizer Chiefs Football Club|founded={{Start date and age|1970|01|07|df=y}}|ground=[[FNB Stadium]]|capacity=94,797|chairman=[[Kaizer Motaung]]|league=[[South African Premiership|Betway Premiership]]|season=[[2024–25 South African Premiership|2024–25]]|current=2025–26 Kaizer Chiefs F.C. season|stadium=[[FNB Stadium]]|position=9th|manager=[[Nasreddine Nabi]]|website={{URL|https://www.kaizerchiefs.com/}}|owner=[[Kaizer Motaung]]|chrtitle=Chairman}}'''I-Kaizer Chiefs Football Club''' (eyaziwa ngokuthi '''yi-Chiefs)''' yisiqhema sebholo ye -Sewula Afrika ese-Naturena, e-Johannesburg South, edlala ku- Premiership￼. Isiqhema sibizwa nge ''-AmaKhosi'', okutjho &quot;amaKhosi&quot; ngesiZulu, kanye nama ''-Phefeni Glamour Boys.'' I-Chiefs sele inqobe iinhlandla ezinengi zeligi kanye namatrophi. Indebe yakamuva yasekhaya bekuyiNdebe ye-Nedbank ka-2024-25￼. Baphethe iinkezo ezinengi khulu hlangana nazo zoke iinqhema zeSewula Afrika begodu bayisiqhema esiphumelele khulu emlandwini webholo yeSewula Afrika solo kwathoma izinga eliphezulu ngo-1970.

Isiqhema sinomncintiswano omkhulu wendawo, i -Soweto derby, ne -Orlando Pirates, isiqhema se-Soweto umsunguli we-Chiefs u-Kaizer Motaung adlala kiso ekuthomeni komsebenzi wakhe wokudlala.  Abadlali abadumileko ebegade bambatha ijezi elimnyama negolide esikhathini esidlulileko bafaka hlangana abokapteni besiqhema &lt;ref name=&quot;thepresidency.gov.za&quot; /&gt;lesitjhaba [[Neil Tovey|u-Neil Tovey]] no -Lucas Radebe kanye no -Patrick Ntsoelengoe, u-Gary Bailey, u-John &quot;Shoes&quot; Moshoeu, u-Shaun Bartlett, u- Steve Komphela, u-Siyabonga Nomvete, u- Doctor no-Khumalo.

Yisiqhema esisekelwa khulu [[Isewula Afrika|eSewula Afrika]]￼. I-Kaizer Chiefs beyinesisekelo esingaphezu kweengidi ezili-16 ekuthomeni kwekhulu leminyaka. Bathola isilinganiso sabantu abafika ekhaya esingu-16,144 ngesizini ka-2019-20, okuphezulu khulu kuligi. Isiqhema sidlala imidlalo eminengi yangekhaya e- FNB Stadium enabantu abama-94,797.  NgoTjhirhweni 2025, i-Kaizer Chiefs yagidinga iminyaka ema-55.

=== Imithombo lwazi ===

#</text>
      <sha1>pxn3ra914ksw77gqrqpjfhwla0j4vom</sha1>
    </revision>
    <revision>
      <id>5479</id>
      <parentid>5452</parentid>
      <timestamp>2025-09-04T08:41:53Z</timestamp>
      <contributor>
        <username>Mbonani JayJay</username>
        <id>892</id>
      </contributor>
      <origin>5479</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2323" sha1="s47dz8qhsdjbou5ts8j1nl4vegkl4uv" xml:space="preserve">
{{Infobox football club|clubname=Kaizer Chiefs|image=Kaizer Chiefs logo.svg|image_size=180px|short name=Chiefs|nickname={{Plainlist|
* ''AmaKhosi'' (Kings)
* '' The Phefeni Boys ''
* '' Abafana bokuthula noxolo'' (The Boys of Love &amp; Peace)
* '' The Glamour Boys ''
}}|fullname=Kaizer Chiefs Football Club|founded={{Start date and age|1970|01|07|df=y}}|ground=[[FNB Stadium]]|capacity=94,797|chairman=[[Kaizer Motaung]]|league=[[South African Premiership|Betway Premiership]]|season=[[2024–25 South African Premiership|2024–25]]|current=2025–26 Kaizer Chiefs F.C. season|stadium=[[FNB Stadium]]|position=9th|manager=[[Nasreddine Nabi]]|website={{URL|https://www.kaizerchiefs.com/}}|owner=[[Kaizer Motaung]]|chrtitle=Chairman}}'''I-Kaizer Chiefs Football Club''' (eyaziwa ngokuthi '''yi-Chiefs)''' yisiqhema sebholo ye -Sewula Afrika ese-Naturena, e-Johannesburg South, edlala ku- Premiership￼. Isiqhema sibizwa nge ''-AmaKhosi'', okutjho &quot;amaKhosi&quot; ngesiZulu, kanye nama ''-Phefeni Glamour Boys.'' I-Chiefs sele inqobe iinhlandla ezinengi zeligi kanye namatrophi. Indebe yakamuva yasekhaya bekuyiNdebe ye-Nedbank ka-2024-25￼. Baphethe iinkezo ezinengi khulu hlangana nazo zoke iinqhema zeSewula Afrika begodu bayisiqhema esiphumelele khulu emlandwini webholo yeSewula Afrika solo kwathoma izinga eliphezulu ngo-1970.

Isiqhema sinomncintiswano omkhulu wendawo, i -Soweto derby, ne -Orlando Pirates, isiqhema se-Soweto umsunguli we-Chiefs u-Kaizer Motaung adlala kiso ekuthomeni komsebenzi wakhe wokudlala.  Abadlali abadumileko ebegade bambatha ijezi elimnyama negolide esikhathini esidlulileko bafaka hlangana abokapteni besiqhema &lt;ref name=&quot;thepresidency.gov.za&quot; /&gt;lesitjhaba [[Neil Tovey|u-Neil Tovey]] no -Lucas Radebe kanye no -Patrick Ntsoelengoe, u-Gary Bailey, u-John &quot;Shoes&quot; Moshoeu, u-Shaun Bartlett, u- Steve Komphela, u-Siyabonga Nomvete, u- Doctor no-Khumalo.

Yisiqhema esisekelwa khulu [[Isewula Afrika|eSewula Afrika]]￼. I-Kaizer Chiefs beyinesisekelo esingaphezu kweengidi ezili-16 ekuthomeni kwekhulu leminyaka. Bathola isilinganiso sabantu abafika ekhaya esingu-16,144 ngesizini ka-2019-20, okuphezulu khulu kuligi. Isiqhema sidlala imidlalo eminengi yangekhaya e- FNB Stadium enabantu abama-94,797.  NgoTjhirhweni 2025, i-Kaizer Chiefs yagidinga iminyaka ema-55.

=== Imithombo lwazi ===

##</text>
      <sha1>s47dz8qhsdjbou5ts8j1nl4vegkl4uv</sha1>
    </revision>
    <revision>
      <id>5480</id>
      <parentid>5479</parentid>
      <timestamp>2025-09-04T08:46:16Z</timestamp>
      <contributor>
        <username>Mbonani JayJay</username>
        <id>892</id>
      </contributor>
      <origin>5480</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2520" sha1="skf939isrxe5orh8rpn34nwrfx4uivl" xml:space="preserve">
{{Infobox football club|clubname=Kaizer Chiefs|image=Kaizer Chiefs logo.svg|image_size=180px|short name=Chiefs|nickname={{Plainlist|
* ''AmaKhosi'' (Kings)
* '' The Phefeni Boys ''
* '' Abafana bokuthula noxolo'' (The Boys of Love &amp; Peace)
* '' The Glamour Boys ''
}}|fullname=Kaizer Chiefs Football Club|founded={{Start date and age|1970|01|07|df=y}}|ground=[[FNB Stadium]]|capacity=94,797|chairman=[[Kaizer Motaung]]|league=[[South African Premiership|Betway Premiership]]|season=[[2024–25 South African Premiership|2024–25]]|current=2025–26 Kaizer Chiefs F.C. season|stadium=[[FNB Stadium]]|position=9th|manager=[[Nasreddine Nabi]]|website={{URL|https://www.kaizerchiefs.com/}}|owner=[[Kaizer Motaung]]|chrtitle=Chairman}}'''I-Kaizer Chiefs Football Club''' (eyaziwa ngokuthi '''yi-Chiefs)''' yisiqhema sebholo ye -Sewula Afrika ese-Naturena, e-Johannesburg South, edlala ku- Premiership￼. Isiqhema sibizwa nge ''-AmaKhosi'', okutjho &quot;amaKhosi&quot; ngesiZulu, kanye nama ''-Phefeni Glamour Boys.'' I-Chiefs sele inqobe iinhlandla ezinengi zeligi kanye namatrophi. Indebe yakamuva yasekhaya bekuyiNdebe ye-Nedbank ka-2024-25￼. Baphethe iinkezo ezinengi khulu hlangana nazo zoke iinqhema zeSewula Afrika begodu bayisiqhema esiphumelele khulu emlandwini webholo yeSewula Afrika solo kwathoma izinga eliphezulu ngo-1970.

Isiqhema sinomncintiswano omkhulu wendawo, i -Soweto derby, ne -Orlando Pirates, isiqhema se-Soweto umsunguli we-Chiefs u-Kaizer Motaung adlala kiso ekuthomeni komsebenzi wakhe wokudlala.  Abadlali abadumileko ebegade bambatha ijezi elimnyama negolide esikhathini esidlulileko bafaka hlangana abokapteni besiqhema &lt;ref name=&quot;thepresidency.gov.za&quot; /&gt;lesitjhaba [[Neil Tovey|u-Neil Tovey]] no -Lucas Radebe kanye no -Patrick Ntsoelengoe, u-Gary Bailey, u-John &quot;Shoes&quot; Moshoeu, u-Shaun Bartlett, u- Steve Komphela, u-Siyabonga Nomvete, u- Doctor no-Khumalo.

Yisiqhema esisekelwa khulu [[Isewula Afrika|eSewula Afrika]]￼. I-Kaizer Chiefs beyinesisekelo esingaphezu kweengidi ezili-16 ekuthomeni kwekhulu leminyaka. Bathola isilinganiso sabantu abafika ekhaya esingu-16,144 ngesizini ka-2019-20, okuphezulu khulu kuligi. Isiqhema sidlala imidlalo eminengi yangekhaya e- FNB Stadium enabantu abama-94,797.  NgoTjhirhweni 2025, i-Kaizer Chiefs yagidinga iminyaka ema-55.

=== Imithombo lwazi ===

# &lt;ref&gt;{{Citation|title=Kaizer Chiefs F.C.|date=2025-09-03|work=Wikipedia|url=https://en.wikipedia.org/w/index.php?title=Kaizer_Chiefs_F.C.&amp;oldid=1309345035|access-date=2025-09-04|language=en}}&lt;/ref&gt;</text>
      <sha1>skf939isrxe5orh8rpn34nwrfx4uivl</sha1>
    </revision>
    <revision>
      <id>5494</id>
      <parentid>5480</parentid>
      <timestamp>2025-09-04T09:02:08Z</timestamp>
      <contributor>
        <username>Mbonani JayJay</username>
        <id>892</id>
      </contributor>
      <origin>5494</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2523" sha1="3luz7vguxlzqi7obf16r0iauc6o8t3o" xml:space="preserve">
{{Infobox football club|clubname=Kaizer Chiefs|image=Kaizer Chiefs logo.svg|image_size=180px|short name=Chiefs|nickname={{Plainlist|
* ''AmaKhosi'' (Kings)
* '' The Phefeni Boys ''
* '' Abafana bokuthula noxolo'' (The Boys of Love &amp; Peace)
* '' The Glamour Boys ''
}}|fullname=Kaizer Chiefs Football Club|founded={{Start date and age|1970|01|07|df=y}}|ground=[[FNB Stadium]]|capacity=94,797|chairman=[[Kaizer Motaung]]|league=[[South African Premiership|Betway Premiership]]|season=[[2024–25 South African Premiership|2024–25]]|current=2025–26 Kaizer Chiefs F.C. season|stadium=[[FNB Stadium]]|position=9th|manager=[[Nasreddine Nabi]]|website={{URL|https://www.kaizerchiefs.com/}}|owner=[[Kaizer Motaung]]|chrtitle=Chairman}}'''I-Kaizer Chiefs Football Club''' (eyaziwa ngokuthi '''yi-Chiefs)''' yisiqhema sebholo ye -Sewula Afrika ese-Naturena, e-Johannesburg South, edlala ku- Premiership￼. Isiqhema sibizwa nge ''-AmaKhosi'', okutjho &quot;amaKhosi&quot; ngesiZulu, kanye nama ''-Phefeni Glamour Boys.'' I-Chiefs sele inqobe iinhlandla ezinengi zeligi kanye namatrophi. Indebe yakamuva yasekhaya bekuyiNdebe ye-Nedbank ka-2024-25￼. Baphethe iinkezo ezinengi khulu hlangana nazo zoke iinqhema zeSewula Afrika begodu bayisiqhema esiphumelele khulu emlandwini webholo yeSewula Afrika solo kwathoma izinga eliphezulu ngo-1970.&lt;ref&gt;{{Citation |title=Kaizer Chiefs F.C. |date=2025-09-03 |work=Wikipedia |url=https://en.wikipedia.org/w/index.php?title=Kaizer_Chiefs_F.C.&amp;oldid=1309345035 |access-date=2025-09-04 |language=en}}&lt;/ref&gt;


Isiqhema sinomncintiswano omkhulu wendawo, i -Soweto derby, ne -Orlando Pirates, isiqhema se-Soweto umsunguli we-Chiefs u-Kaizer Motaung adlala kiso ekuthomeni komsebenzi wakhe wokudlala.  Abadlali abadumileko ebegade bambatha ijezi elimnyama negolide esikhathini esidlulileko bafaka hlangana abokapteni besiqhema &lt;ref name=&quot;thepresidency.gov.za&quot; /&gt;lesitjhaba [[Neil Tovey|u-Neil Tovey]] no -Lucas Radebe kanye no -Patrick Ntsoelengoe, u-Gary Bailey, u-John &quot;Shoes&quot; Moshoeu, u-Shaun Bartlett, u- Steve Komphela, u-Siyabonga Nomvete, u- Doctor no-Khumalo.

Yisiqhema esisekelwa khulu [[Isewula Afrika|eSewula Afrika]]￼. I-Kaizer Chiefs beyinesisekelo esingaphezu kweengidi ezili-16 ekuthomeni kwekhulu leminyaka. Bathola isilinganiso sabantu abafika ekhaya esingu-16,144 ngesizini ka-2019-20, okuphezulu khulu kuligi. Isiqhema sidlala imidlalo eminengi yangekhaya e- FNB Stadium enabantu abama-94,797.  NgoTjhirhweni 2025, i-Kaizer Chiefs yagidinga iminyaka ema-55.

=== Imithombo lwazi ===</text>
      <sha1>3luz7vguxlzqi7obf16r0iauc6o8t3o</sha1>
    </revision>
    <revision>
      <id>5503</id>
      <parentid>5494</parentid>
      <timestamp>2025-09-04T09:09:58Z</timestamp>
      <contributor>
        <username>Mbonani JayJay</username>
        <id>892</id>
      </contributor>
      <origin>5503</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2751" sha1="2u3790erc2eo1dj2wh6ebguczi5f7w4" xml:space="preserve">
{{Infobox football club|clubname=Kaizer Chiefs|image=Kaizer Chiefs logo.svg|image_size=180px|short name=Chiefs|nickname={{Plainlist|
* ''AmaKhosi'' (Kings)
* '' The Phefeni Boys ''
* '' Abafana bokuthula noxolo'' (The Boys of Love &amp; Peace)
* '' The Glamour Boys ''
}}|fullname=Kaizer Chiefs Football Club|founded={{Start date and age|1970|01|07|df=y}}|ground=[[FNB Stadium]]|capacity=94,797|chairman=[[Kaizer Motaung]]|league=[[South African Premiership|Betway Premiership]]|season=[[2024–25 South African Premiership|2024–25]]|current=2025–26 Kaizer Chiefs F.C. season|stadium=[[FNB Stadium]]|position=9th|manager=[[Nasreddine Nabi]]|website={{URL|https://www.kaizerchiefs.com/}}|owner=[[Kaizer Motaung]]|chrtitle=Chairman}}'''I-Kaizer Chiefs Football Club''' (eyaziwa ngokuthi '''yi-Chiefs)''' yisiqhema sebholo ye -Sewula Afrika ese-Naturena, e-Johannesburg South, edlala ku- Premiership￼. Isiqhema sibizwa nge ''-AmaKhosi'', okutjho &quot;amaKhosi&quot; ngesiZulu, kanye nama ''-Phefeni Glamour Boys.'' I-Chiefs sele inqobe iinhlandla ezinengi zeligi kanye namatrophi. Indebe yakamuva yasekhaya bekuyiNdebe ye-Nedbank ka-2024-25￼. Baphethe iinkezo ezinengi khulu hlangana nazo zoke iinqhema zeSewula Afrika begodu bayisiqhema esiphumelele khulu emlandwini webholo yeSewula Afrika solo kwathoma izinga eliphezulu ngo-1970.&lt;ref&gt;{{Citation |title=Kaizer Chiefs F.C. |date=2025-09-03 |work=Wikipedia |url=https://en.wikipedia.org/w/index.php?title=Kaizer_Chiefs_F.C.&amp;oldid=1309345035 |access-date=2025-09-04 |language=en}}&lt;/ref&gt;


Isiqhema sinomncintiswano omkhulu wendawo, i -Soweto derby, ne -Orlando Pirates, isiqhema se-Soweto umsunguli we-Chiefs u-Kaizer Motaung adlala kiso ekuthomeni komsebenzi wakhe wokudlala.  Abadlali abadumileko ebegade bambatha ijezi elimnyama negolide esikhathini esidlulileko bafaka hlangana abokapteni besiqhema &lt;ref name=&quot;thepresidency.gov.za&quot; /&gt;lesitjhaba [[Neil Tovey|u-Neil Tovey]] no -Lucas Radebe kanye no -Patrick Ntsoelengoe, u-Gary Bailey, u-John &quot;Shoes&quot; Moshoeu, u-Shaun Bartlett, u- Steve Komphela, u-Siyabonga Nomvete, u- Doctor no-Khumalo.

Yisiqhema esisekelwa khulu [[Isewula Afrika|eSewula Afrika]]￼. I-Kaizer Chiefs beyinesisekelo esingaphezu kweengidi ezili-16 ekuthomeni kwekhulu leminyaka. Bathola isilinganiso sabantu abafika ekhaya esingu-16,144 ngesizini ka-2019-20, okuphezulu khulu kuligi. Isiqhema sidlala imidlalo eminengi yangekhaya e- FNB Stadium enabantu abama-94,797.  NgoTjhirhweni 2025, i-Kaizer Chiefs yagidinga iminyaka ema-55.

=== Imithombo lwazi ===
&lt;ref&gt;{{Cite journal |last=Kaizer |first=Ted |date=2012-10-26 |title=Dura‐Europos |url=https://doi.org/10.1002/9781444338386.wbeah18037 |journal=The Encyclopedia of Ancient History |doi=10.1002/9781444338386.wbeah18037}}&lt;/ref&gt;</text>
      <sha1>2u3790erc2eo1dj2wh6ebguczi5f7w4</sha1>
    </revision>
    <revision>
      <id>5507</id>
      <parentid>5503</parentid>
      <timestamp>2025-09-04T09:12:39Z</timestamp>
      <contributor>
        <username>Mbonani JayJay</username>
        <id>892</id>
      </contributor>
      <origin>5507</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2316" sha1="mhyf9n5ipsu6666kq729brun74jmfig" xml:space="preserve">
{{Infobox football club|clubname=Kaizer Chiefs|image=Kaizer Chiefs logo.svg|image_size=180px|short name=Chiefs|nickname={{Plainlist|
* ''AmaKhosi'' (Kings)
* '' The Phefeni Boys ''
* '' Abafana bokuthula noxolo'' (The Boys of Love &amp; Peace)
* '' The Glamour Boys ''
}}|fullname=Kaizer Chiefs Football Club|founded={{Start date and age|1970|01|07|df=y}}|ground=[[FNB Stadium]]|capacity=94,797|chairman=[[Kaizer Motaung]]|league=[[South African Premiership|Betway Premiership]]|season=[[2024–25 South African Premiership|2024–25]]|current=2025–26 Kaizer Chiefs F.C. season|stadium=[[FNB Stadium]]|position=9th|manager=[[Nasreddine Nabi]]|website={{URL|https://www.kaizerchiefs.com/}}|owner=[[Kaizer Motaung]]|chrtitle=Chairman}}'''I-Kaizer Chiefs Football Club''' (eyaziwa ngokuthi '''yi-Chiefs)''' yisiqhema sebholo ye -Sewula Afrika ese-Naturena, e-Johannesburg South, edlala ku- Premiership￼. Isiqhema sibizwa nge ''-AmaKhosi'', okutjho &quot;amaKhosi&quot; ngesiZulu, kanye nama ''-Phefeni Glamour Boys.'' I-Chiefs sele inqobe iinhlandla ezinengi zeligi kanye namatrophi. Indebe yakamuva yasekhaya bekuyiNdebe ye-Nedbank ka-2024-25￼. Baphethe iinkezo ezinengi khulu hlangana nazo zoke iinqhema zeSewula Afrika begodu bayisiqhema esiphumelele khulu emlandwini webholo yeSewula Afrika solo kwathoma izinga eliphezulu ngo-1970.


Isiqhema sinomncintiswano omkhulu wendawo, i -Soweto derby, ne -Orlando Pirates, isiqhema se-Soweto umsunguli we-Chiefs u-Kaizer Motaung adlala kiso ekuthomeni komsebenzi wakhe wokudlala.  Abadlali abadumileko ebegade bambatha ijezi elimnyama negolide esikhathini esidlulileko bafaka hlangana abokapteni besiqhema &lt;ref name=&quot;thepresidency.gov.za&quot; /&gt;lesitjhaba [[Neil Tovey|u-Neil Tovey]] no -Lucas Radebe kanye no -Patrick Ntsoelengoe, u-Gary Bailey, u-John &quot;Shoes&quot; Moshoeu, u-Shaun Bartlett, u- Steve Komphela, u-Siyabonga Nomvete, u- Doctor no-Khumalo.

Yisiqhema esisekelwa khulu [[Isewula Afrika|eSewula Afrika]]￼. I-Kaizer Chiefs beyinesisekelo esingaphezu kweengidi ezili-16 ekuthomeni kwekhulu leminyaka. Bathola isilinganiso sabantu abafika ekhaya esingu-16,144 ngesizini ka-2019-20, okuphezulu khulu kuligi. Isiqhema sidlala imidlalo eminengi yangekhaya e- FNB Stadium enabantu abama-94,797.  NgoTjhirhweni 2025, i-Kaizer Chiefs yagidinga iminyaka ema-55.

=== Imithombo lwazi</text>
      <sha1>mhyf9n5ipsu6666kq729brun74jmfig</sha1>
    </revision>
    <revision>
      <id>5525</id>
      <parentid>5507</parentid>
      <timestamp>2025-09-04T09:24:05Z</timestamp>
      <contributor>
        <username>Mbonani JayJay</username>
        <id>892</id>
      </contributor>
      <origin>5525</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2312" sha1="qnoycpeoi57l5f0ks2bttj7np8t5yl7" xml:space="preserve">
{{Infobox football club|clubname=Kaizer Chiefs|image=Kaizer Chiefs logo.svg|image_size=180px|short name=Chiefs|nickname={{Plainlist|
* ''AmaKhosi'' (Kings)
* '' The Phefeni Boys ''
* '' Abafana bokuthula noxolo'' (The Boys of Love &amp; Peace)
* '' The Glamour Boys ''
}}|fullname=Kaizer Chiefs Football Club|founded={{Start date and age|1970|01|07|df=y}}|ground=[[FNB Stadium]]|capacity=94,797|chairman=[[Kaizer Motaung]]|league=[[South African Premiership|Betway Premiership]]|season=[[2024–25 South African Premiership|2024–25]]|current=2025–26 Kaizer Chiefs F.C. season|stadium=[[FNB Stadium]]|position=9th|manager=[[Nasreddine Nabi]]|website={{URL|https://www.kaizerchiefs.com/}}|owner=[[Kaizer Motaung]]|chrtitle=Chairman}}'''I-Kaizer Chiefs Football Club''' (eyaziwa ngokuthi '''yi-Chiefs)''' yisiqhema sebholo ye -Sewula Afrika ese-Naturena, e-Johannesburg South, edlala ku- Premiership￼. Isiqhema sibizwa nge ''-AmaKhosi'', okutjho &quot;amaKhosi&quot; ngesiZulu, kanye nama ''-Phefeni Glamour Boys.'' I-Chiefs sele inqobe iinhlandla ezinengi zeligi kanye namatrophi. Indebe yakamuva yasekhaya bekuyiNdebe ye-Nedbank ka-2024-25￼. Baphethe iinkezo ezinengi khulu hlangana nazo zoke iinqhema zeSewula Afrika begodu bayisiqhema esiphumelele khulu emlandwini webholo yeSewula Afrika solo kwathoma izinga eliphezulu ngo-1970.


Isiqhema sinomncintiswano omkhulu wendawo, i -Soweto derby, ne -Orlando Pirates, isiqhema se-Soweto umsunguli we-Chiefs u-Kaizer Motaung adlala kiso ekuthomeni komsebenzi wakhe wokudlala.  Abadlali abadumileko ebegade bambatha ijezi elimnyama negolide esikhathini esidlulileko bafaka hlangana abokapteni besiqhema &lt;ref name=&quot;thepresidency.gov.za&quot; /&gt;lesitjhaba [[Neil Tovey|u-Neil Tovey]] no -Lucas Radebe kanye no -Patrick Ntsoelengoe, u-Gary Bailey, u-John &quot;Shoes&quot; Moshoeu, u-Shaun Bartlett, u- Steve Komphela, u-Siyabonga Nomvete, u- Doctor no-Khumalo.

Yisiqhema esisekelwa khulu [[Isewula Afrika|eSewula Afrika]]￼. I-Kaizer Chiefs beyinesisekelo esingaphezu kweengidi ezili-16 ekuthomeni kwekhulu leminyaka. Bathola isilinganiso sabantu abafika ekhaya esingu-16,144 ngesizini ka-2019-20, okuphezulu khulu kuligi. Isiqhema sidlala imidlalo eminengi yangekhaya e- FNB Stadium enabantu abama-94,797.  NgoTjhirhweni 2025, i-Kaizer Chiefs yagidinga iminyaka ema-55.

Imithombo lwazi</text>
      <sha1>qnoycpeoi57l5f0ks2bttj7np8t5yl7</sha1>
    </revision>
    <revision>
      <id>5536</id>
      <parentid>5525</parentid>
      <timestamp>2025-09-04T09:27:41Z</timestamp>
      <contributor>
        <username>Mbonani JayJay</username>
        <id>892</id>
      </contributor>
      <origin>5536</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2516" sha1="3oho22zryt5q8eyapyp3uv4jy3ekdik" xml:space="preserve">
{{Infobox football club|clubname=Kaizer Chiefs|image=Kaizer Chiefs logo.svg|image_size=180px|short name=Chiefs|nickname={{Plainlist|
* ''AmaKhosi'' (Kings)
* '' The Phefeni Boys ''
* '' Abafana bokuthula noxolo'' (The Boys of Love &amp; Peace)
* '' The Glamour Boys ''
}}|fullname=Kaizer Chiefs Football Club|founded={{Start date and age|1970|01|07|df=y}}|ground=[[FNB Stadium]]|capacity=94,797|chairman=[[Kaizer Motaung]]|league=[[South African Premiership|Betway Premiership]]|season=[[2024–25 South African Premiership|2024–25]]|current=2025–26 Kaizer Chiefs F.C. season|stadium=[[FNB Stadium]]|position=9th|manager=[[Nasreddine Nabi]]|website={{URL|https://www.kaizerchiefs.com/}}|owner=[[Kaizer Motaung]]|chrtitle=Chairman}}'''I-Kaizer Chiefs Football Club''' (eyaziwa ngokuthi '''yi-Chiefs)''' yisiqhema sebholo ye -Sewula Afrika ese-Naturena, e-Johannesburg South, edlala ku- Premiership￼. Isiqhema sibizwa nge ''-AmaKhosi'', okutjho &quot;amaKhosi&quot; ngesiZulu, kanye nama ''-Phefeni Glamour Boys.'' I-Chiefs sele inqobe iinhlandla ezinengi zeligi kanye namatrophi. Indebe yakamuva yasekhaya bekuyiNdebe ye-Nedbank ka-2024-25￼. Baphethe iinkezo ezinengi khulu hlangana nazo zoke iinqhema zeSewula Afrika begodu bayisiqhema esiphumelele khulu emlandwini webholo yeSewula Afrika solo kwathoma izinga eliphezulu ngo-1970.


Isiqhema sinomncintiswano omkhulu wendawo, i -Soweto derby, ne -Orlando Pirates, isiqhema se-Soweto umsunguli we-Chiefs u-Kaizer Motaung adlala kiso ekuthomeni komsebenzi wakhe wokudlala.  Abadlali abadumileko ebegade bambatha ijezi elimnyama negolide esikhathini esidlulileko bafaka hlangana abokapteni besiqhema &lt;ref name=&quot;thepresidency.gov.za&quot; /&gt;lesitjhaba [[Neil Tovey|u-Neil Tovey]] no -Lucas Radebe kanye no -Patrick Ntsoelengoe, u-Gary Bailey, u-John &quot;Shoes&quot; Moshoeu, u-Shaun Bartlett, u- Steve Komphela, u-Siyabonga Nomvete, u- Doctor no-Khumalo.

Yisiqhema esisekelwa khulu [[Isewula Afrika|eSewula Afrika]]￼. I-Kaizer Chiefs beyinesisekelo esingaphezu kweengidi ezili-16 ekuthomeni kwekhulu leminyaka. Bathola isilinganiso sabantu abafika ekhaya esingu-16,144 ngesizini ka-2019-20, okuphezulu khulu kuligi. Isiqhema sidlala imidlalo eminengi yangekhaya e- FNB Stadium enabantu abama-94,797.  NgoTjhirhweni 2025, i-Kaizer Chiefs yagidinga iminyaka ema-55.

Imithombo lwazi
&lt;ref&gt;{{Citation |title=Kaizer Chiefs F.C. |date=2025-09-03 |work=Wikipedia |url=https://en.wikipedia.org/w/index.php?title=Kaizer_Chiefs_F.C.&amp;oldid=1309345035 |access-date=2025-09-04 |language=en}}&lt;/ref&gt;</text>
      <sha1>3oho22zryt5q8eyapyp3uv4jy3ekdik</sha1>
    </revision>
    <revision>
      <id>5541</id>
      <parentid>5536</parentid>
      <timestamp>2025-09-04T09:29:32Z</timestamp>
      <contributor>
        <username>Mbonani JayJay</username>
        <id>892</id>
      </contributor>
      <origin>5541</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2514" sha1="dkqrv5jhytoxfbtyjimcdgveli5g8ui" xml:space="preserve">
{{Infobox football club|clubname=Kaizer Chiefs|image=Kaizer Chiefs logo.svg|image_size=180px|short name=Chiefs|nickname={{Plainlist|
* ''AmaKhosi'' (Kings)
* '' The Phefeni Boys ''
* '' Abafana bokuthula noxolo'' (The Boys of Love &amp; Peace)
* '' The Glamour Boys ''
}}|fullname=Kaizer Chiefs Football Club|founded={{Start date and age|1970|01|07|df=y}}|ground=[[FNB Stadium]]|capacity=94,797|chairman=[[Kaizer Motaung]]|league=[[South African Premiership|Betway Premiership]]|season=[[2024–25 South African Premiership|2024–25]]|current=2025–26 Kaizer Chiefs F.C. season|stadium=[[FNB Stadium]]|position=9th|manager=[[Nasreddine Nabi]]|website={{URL|https://www.kaizerchiefs.com/}}|owner=[[Kaizer Motaung]]|chrtitle=Chairman}}'''I-Kaizer Chiefs Football Club''' (eyaziwa ngokuthi '''yi-Chiefs)''' yisiqhema sebholo ye -Sewula Afrika ese-Naturena, e-Johannesburg South, edlala ku- Premiership￼. Isiqhema sibizwa nge ''-AmaKhosi'', okutjho &quot;amaKhosi&quot; ngesiZulu, kanye nama ''-Phefeni Glamour Boys.'' I-Chiefs sele inqobe iinhlandla ezinengi zeligi kanye namatrophi. Indebe yakamuva yasekhaya bekuyiNdebe ye-Nedbank ka-2024-25￼. Baphethe iinkezo ezinengi khulu hlangana nazo zoke iinqhema zeSewula Afrika begodu bayisiqhema esiphumelele khulu emlandwini webholo yeSewula Afrika solo kwathoma izinga eliphezulu ngo-1970.&lt;ref&gt;{{Citation |title=Kaizer Chiefs F.C. |date=2025-09-03 |work=Wikipedia |url=https://en.wikipedia.org/w/index.php?title=Kaizer_Chiefs_F.C.&amp;oldid=1309345035 |access-date=2025-09-04 |language=en}}&lt;/ref&gt;

Isiqhema sinomncintiswano omkhulu wendawo, i -Soweto derby, ne -Orlando Pirates, isiqhema se-Soweto umsunguli we-Chiefs u-Kaizer Motaung adlala kiso ekuthomeni komsebenzi wakhe wokudlala.  Abadlali abadumileko ebegade bambatha ijezi elimnyama negolide esikhathini esidlulileko bafaka hlangana abokapteni besiqhema &lt;ref name=&quot;thepresidency.gov.za&quot; /&gt;lesitjhaba [[Neil Tovey|u-Neil Tovey]] no -Lucas Radebe kanye no -Patrick Ntsoelengoe, u-Gary Bailey, u-John &quot;Shoes&quot; Moshoeu, u-Shaun Bartlett, u- Steve Komphela, u-Siyabonga Nomvete, u- Doctor no-Khumalo.

Yisiqhema esisekelwa khulu [[Isewula Afrika|eSewula Afrika]]￼. I-Kaizer Chiefs beyinesisekelo esingaphezu kweengidi ezili-16 ekuthomeni kwekhulu leminyaka. Bathola isilinganiso sabantu abafika ekhaya esingu-16,144 ngesizini ka-2019-20, okuphezulu khulu kuligi. Isiqhema sidlala imidlalo eminengi yangekhaya e- FNB Stadium enabantu abama-94,797.  NgoTjhirhweni 2025, i-Kaizer Chiefs yagidinga iminyaka ema-55.

Imithombo lwazi</text>
      <sha1>dkqrv5jhytoxfbtyjimcdgveli5g8ui</sha1>
    </revision>
    <revision>
      <id>5564</id>
      <parentid>5541</parentid>
      <timestamp>2025-09-04T09:45:53Z</timestamp>
      <contributor>
        <username>Mbonani JayJay</username>
        <id>892</id>
      </contributor>
      <origin>5564</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2531" sha1="7tjb5r6eg31ixonovub8686zusrfwka" xml:space="preserve">
{{Infobox football club|clubname=Kaizer Chiefs|image=Kaizer Chiefs logo.svg|image_size=180px|short name=Chiefs|nickname={{Plainlist|
* ''AmaKhosi'' (Kings)
* '' The Phefeni Boys ''
* '' Abafana bokuthula noxolo'' (The Boys of Love &amp; Peace)
* '' The Glamour Boys ''
}}|fullname=Kaizer Chiefs Football Club|founded={{Start date and age|1970|01|07|df=y}}|ground=[[FNB Stadium]]|capacity=94,797|chairman=[[Kaizer Motaung]]|league=[[South African Premiership|Betway Premiership]]|season=[[2024–25 South African Premiership|2024–25]]|current=2025–26 Kaizer Chiefs F.C. season|stadium=[[FNB Stadium]]|position=9th|manager=[[Nasreddine Nabi]]|website={{URL|https://www.kaizerchiefs.com/}}|owner=[[Kaizer Motaung]]|chrtitle=Chairman}}'''I-Kaizer Chiefs Football Club''' (eyaziwa ngokuthi '''yi-Chiefs)''' yisiqhema sebholo ye -Sewula Afrika ese-Naturena, e[[Johannesburg|-Johannesburg]] South, edlala ku- Premiership￼. Isiqhema sibizwa nge ''-AmaKhosi'', okutjho &quot;amaKhosi&quot; ngesiZulu, kanye nama ''-Phefeni Glamour Boys.'' I-Chiefs sele inqobe iinhlandla ezinengi zeligi kanye namatrophi. Indebe yakamuva yasekhaya bekuyiNdebe ye-Nedbank ka-2024-25￼. Baphethe iinkezo ezinengi khulu hlangana nazo zoke iinqhema zeSewula Afrika begodu bayisiqhema esiphumelele khulu emlandwini webholo yeSewula Afrika solo kwathoma izinga eliphezulu ngo-1970.&lt;ref&gt;{{Citation |title=Kaizer Chiefs F.C. |date=2025-09-03 |work=Wikipedia |url=https://en.wikipedia.org/w/index.php?title=Kaizer_Chiefs_F.C.&amp;oldid=1309345035 |access-date=2025-09-04 |language=en}}&lt;/ref&gt;

Isiqhema sinomncintiswano omkhulu wendawo, i -Soweto derby, ne -Orlando Pirates, isiqhema se-Soweto umsunguli we-Chiefs u-Kaizer Motaung adlala kiso ekuthomeni komsebenzi wakhe wokudlala.  Abadlali abadumileko ebegade bambatha ijezi elimnyama negolide esikhathini esidlulileko bafaka hlangana abokapteni besiqhema &lt;ref name=&quot;thepresidency.gov.za&quot; /&gt;lesitjhaba [[Neil Tovey|u-Neil Tovey]] no -Lucas Radebe kanye no -Patrick Ntsoelengoe, u-Gary Bailey, u-John &quot;Shoes&quot; Moshoeu, u-Shaun Bartlett, u- Steve Komphela, u-Siyabonga Nomvete, u- Doctor no-Khumalo.

Yisiqhema esisekelwa khulu [[Isewula Afrika|eSewula Afrika]]￼. I-Kaizer Chiefs beyinesisekelo esingaphezu kweengidi ezili-16 ekuthomeni kwekhulu leminyaka. Bathola isilinganiso sabantu abafika ekhaya esingu-16,144 ngesizini ka-2019-20, okuphezulu khulu kuligi. Isiqhema sidlala imidlalo eminengi yangekhaya e- FNB Stadium enabantu abama-94,797.  NgoTjhirhweni 2025, i-Kaizer Chiefs yagidinga iminyaka ema-55.

Imithombo lwazi</text>
      <sha1>7tjb5r6eg31ixonovub8686zusrfwka</sha1>
    </revision>
    <revision>
      <id>5581</id>
      <parentid>5564</parentid>
      <timestamp>2025-09-04T09:54:31Z</timestamp>
      <contributor>
        <username>Mbonani JayJay</username>
        <id>892</id>
      </contributor>
      <origin>5581</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2797" sha1="szba8nxmgepw71r3iwgeked0643kvvr" xml:space="preserve">
{{Infobox football club|clubname=Kaizer Chiefs|image=Kaizer Chiefs logo.svg|image_size=180px|short name=Chiefs|nickname={{Plainlist|
* ''AmaKhosi'' (Kings)
* '' The Phefeni Boys ''
* '' Abafana bokuthula noxolo'' (The Boys of Love &amp; Peace)
* '' The Glamour Boys ''
}}|fullname=Kaizer Chiefs Football Club|founded={{Start date and age|1970|01|07|df=y}}|ground=[[FNB Stadium]]|capacity=94,797|chairman=[[Kaizer Motaung]]|league=[[South African Premiership|Betway Premiership]]|season=[[2024–25 South African Premiership|2024–25]]|current=2025–26 Kaizer Chiefs F.C. season|stadium=[[FNB Stadium]]|position=9th|manager=[[Nasreddine Nabi]]|website={{URL|https://www.kaizerchiefs.com/}}|owner=[[Kaizer Motaung]]|chrtitle=Chairman}}'''I-Kaizer Chiefs Football Club''' (eyaziwa ngokuthi '''yi-Chiefs)''' yisiqhema sebholo ye -Sewula Afrika ese-Naturena, e[[Johannesburg|-Johannesburg]] South, edlala ku- Premiership￼. Isiqhema sibizwa nge ''-AmaKhosi'', okutjho &quot;amaKhosi&quot; ngesiZulu, kanye nama ''-Phefeni Glamour Boys.'' I-Chiefs sele inqobe iinhlandla ezinengi zeligi kanye namatrophi. Indebe yakamuva yasekhaya bekuyiNdebe ye-Nedbank ka-2024-25￼. Baphethe iinkezo ezinengi khulu hlangana nazo zoke iinqhema zeSewula Afrika begodu bayisiqhema esiphumelele khulu emlandwini webholo yeSewula Afrika solo kwathoma izinga eliphezulu ngo-1970.&lt;ref&gt;{{Citation |title=Kaizer Chiefs F.C. |date=2025-09-03 |work=Wikipedia |url=https://en.wikipedia.org/w/index.php?title=Kaizer_Chiefs_F.C.&amp;oldid=1309345035 |access-date=2025-09-04 |language=en}}&lt;/ref&gt;

Isiqhema sinomncintiswano omkhulu wendawo, i -Soweto derby, ne -Orlando Pirates, isiqhema se-Soweto umsunguli we-Chiefs u-Kaizer Motaung adlala kiso ekuthomeni komsebenzi wakhe wokudlala.  Abadlali abadumileko ebegade bambatha ijezi elimnyama negolide esikhathini esidlulileko bafaka hlangana abokapteni besiqhema &lt;ref name=&quot;thepresidency.gov.za&quot; /&gt;lesitjhaba [[Neil Tovey|u-Neil Tovey]] no -Lucas Radebe kanye no -Patrick Ntsoelengoe, u-Gary Bailey, u-John &quot;Shoes&quot; Moshoeu, u-Shaun Bartlett, u- Steve Komphela, u-Siyabonga Nomvete, u- Doctor no-Khumalo.

Yisiqhema esisekelwa khulu [[Isewula Afrika|eSewula Afrika]]￼. I-Kaizer Chiefs beyinesisekelo esingaphezu kweengidi ezili-16 ekuthomeni kwekhulu leminyaka. Bathola isilinganiso sabantu abafika ekhaya esingu-16,144 ngesizini ka-2019-20, okuphezulu khulu kuligi. Isiqhema sidlala imidlalo eminengi yangekhaya e- FNB Stadium enabantu abama-94,797&lt;ref&gt;{{Citation |last=Villela |first=Roger |title=.NET Platform |date=2020 |work=Pro .NET 5 Custom Libraries |pages=1–27 |url=https://doi.org/10.1007/978-1-4842-6391-4_1 |access-date=2025-09-04 |place=Berkeley, CA |publisher=Apress |isbn=978-1-4842-6390-7}}&lt;/ref&gt;
.  NgoTjhirhweni 2025, i-Kaizer Chiefs yagidinga iminyaka ema-55.

Imithombo lwazi</text>
      <sha1>szba8nxmgepw71r3iwgeked0643kvvr</sha1>
    </revision>
    <revision>
      <id>5640</id>
      <parentid>5581</parentid>
      <timestamp>2025-09-04T10:53:51Z</timestamp>
      <contributor>
        <username>Mbonani JayJay</username>
        <id>892</id>
      </contributor>
      <origin>5640</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2876" sha1="5o76m6zeqyml7oov7dfn1ki7s9xzl79" xml:space="preserve">
{{Infobox football club|clubname=Kaizer Chiefs|image=Kaizer Chiefs logo.svg|image_size=180px|short name=Chiefs|nickname={{Plainlist|
* ''AmaKhosi'' (Kings)
* '' The Phefeni Boys ''
* '' Abafana bokuthula noxolo'' (The Boys of Love &amp; Peace)
* '' The Glamour Boys ''
}}|fullname=Kaizer Chiefs Football Club|founded={{Start date and age|1970|01|07|df=y}}|ground=[[FNB Stadium]]|capacity=94,797|chairman=[[Kaizer Motaung]]|league=[[South African Premiership|Betway Premiership]]|season=[[2024–25 South African Premiership|2024–25]]|current=2025–26 Kaizer Chiefs F.C. season|stadium=[[FNB Stadium]]|position=9th|manager=[[Nasreddine Nabi]]|website={{URL|https://www.kaizerchiefs.com/}}|owner=[[Kaizer Motaung]]|chrtitle=Chairman}}'''I-Kaizer Chiefs Football Club''' (eyaziwa ngokuthi '''yi-Chiefs)''' yisiqhema sebholo ye -Sewula Afrika ese-Naturena, e[[Johannesburg|-Johannesburg]] South, edlala ku- Premiership￼. Isiqhema sibizwa nge ''-AmaKhosi'', okutjho &quot;amaKhosi&quot; ngesiZulu, kanye nama ''-Phefeni Glamour Boys.'' I-Chiefs sele inqobe iinhlandla ezinengi zeligi kanye namatrophi. Indebe yakamuva yasekhaya bekuyiNdebe ye-Nedbank ka-2024-25￼. Baphethe iinkezo ezinengi khulu hlangana nazo zoke iinqhema zeSewula Afrika begodu bayisiqhema esiphumelele khulu emlandwini webholo yeSewula Afrika solo kwathoma izinga eliphezulu ngo-1970.&lt;ref&gt;{{Citation |title=Kaizer Chiefs F.C. |date=2025-09-03 |work=Wikipedia |url=https://en.wikipedia.org/w/index.php?title=Kaizer_Chiefs_F.C.&amp;oldid=1309345035 |access-date=2025-09-04 |language=en}}&lt;/ref&gt;
[[Isimumathi:Kaizer Chiefs Stand.jpg|thumb|284x284px|Kaizer Chiefs club house]]
Isiqhema sinomncintiswano omkhulu wendawo, i -Soweto derby, ne -Orlando Pirates, isiqhema se-Soweto umsunguli we-Chiefs u-Kaizer Motaung adlala kiso ekuthomeni komsebenzi wakhe wokudlala.  Abadlali abadumileko ebegade bambatha ijezi elimnyama negolide esikhathini esidlulileko bafaka hlangana abokapteni besiqhema &lt;ref name=&quot;thepresidency.gov.za&quot; /&gt;lesitjhaba [[Neil Tovey|u-Neil Tovey]] no -Lucas Radebe kanye no -Patrick Ntsoelengoe, u-Gary Bailey, u-John &quot;Shoes&quot; Moshoeu, u-Shaun Bartlett, u- Steve Komphela, u-Siyabonga Nomvete, u- Doctor no-Khumalo.

Yisiqhema esisekelwa khulu [[Isewula Afrika|eSewula Afrika]]￼. I-Kaizer Chiefs beyinesisekelo esingaphezu kweengidi ezili-16 ekuthomeni kwekhulu leminyaka. Bathola isilinganiso sabantu abafika ekhaya esingu-16,144 ngesizini ka-2019-20, okuphezulu khulu kuligi. Isiqhema sidlala imidlalo eminengi yangekhaya e- FNB Stadium enabantu abama-94,797&lt;ref&gt;{{Citation |last=Villela |first=Roger |title=.NET Platform |date=2020 |work=Pro .NET 5 Custom Libraries |pages=1–27 |url=https://doi.org/10.1007/978-1-4842-6391-4_1 |access-date=2025-09-04 |place=Berkeley, CA |publisher=Apress |isbn=978-1-4842-6390-7}}&lt;/ref&gt;
.  NgoTjhirhweni 2025, i-Kaizer Chiefs yagidinga iminyaka ema-55.

Imithombo lwazi</text>
      <sha1>5o76m6zeqyml7oov7dfn1ki7s9xzl79</sha1>
    </revision>
    <revision>
      <id>5661</id>
      <parentid>5640</parentid>
      <timestamp>2025-09-04T11:12:54Z</timestamp>
      <contributor>
        <username>Mbonani JayJay</username>
        <id>892</id>
      </contributor>
      <origin>5661</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2841" sha1="h5t07i48ybz2123tohwksfp9o6vqia3" xml:space="preserve">
{{Infobox football club|clubname=Kaizer Chiefs|image=Kaizer Chiefs logo.svg|image_size=180px|short name=Chiefs|nickname={{Plainlist|
* ''AmaKhosi'' (Kings)
* '' The Phefeni Boys ''
* '' Abafana bokuthula noxolo'' (The Boys of Love &amp; Peace)
* '' The Glamour Boys ''
}}|fullname=Kaizer Chiefs Football Club|founded={{Start date and age|1970|01|07|df=y}}|ground=[[FNB Stadium]]|capacity=94,797|chairman=[[Kaizer Motaung]]|league=[[South African Premiership|Betway Premiership]]|season=[[2024–25 South African Premiership|2024–25]]|current=2025–26 Kaizer Chiefs F.C. season|stadium=[[FNB Stadium]]|position=9th|manager=[[Nasreddine Nabi]]|website={{URL|https://www.kaizerchiefs.com/}}|owner=[[Kaizer Motaung]]|chrtitle=Chairman}}'''I-Kaizer Chiefs Football Club''' (eyaziwa ngokuthi '''yi-Chiefs)''' yisiqhema sebholo ye -Sewula Afrika ese-Naturena, e[[Johannesburg|-Johannesburg]] South, edlala ku- Premiership￼. Isiqhema sibizwa nge ''-AmaKhosi'', okutjho &quot;amaKhosi&quot; ngesiZulu, kanye nama ''-Phefeni Glamour Boys.'' I-Chiefs sele inqobe iinhlandla ezinengi zeligi kanye namatrophi. Indebe yakamuva yasekhaya bekuyiNdebe ye-Nedbank ka-2024-25￼. Baphethe iinkezo ezinengi khulu hlangana nazo zoke iinqhema zeSewula Afrika begodu bayisiqhema esiphumelele khulu emlandwini webholo yeSewula Afrika solo kwathoma izinga eliphezulu ngo-1970.&lt;ref&gt;{{Citation |title=Kaizer Chiefs F.C. |date=2025-09-03 |work=Wikipedia |url=https://en.wikipedia.org/w/index.php?title=Kaizer_Chiefs_F.C.&amp;oldid=1309345035 |access-date=2025-09-04 |language=en}}&lt;/ref&gt;
[[Isimumathi:Kaizer Chiefs Stand.jpg|thumb|284x284px|Kaizer Chiefs club house]]
Isiqhema sinomncintiswano omkhulu wendawo, i -Soweto derby, ne -Orlando Pirates, isiqhema se-Soweto umsunguli we-Chiefs u-Kaizer Motaung adlala kiso ekuthomeni komsebenzi wakhe wokudlala.  Abadlali abadumileko ebegade bambatha ijezi elimnyama negolide esikhathini esidlulileko bafaka hlangana abokapteni besiqhema lesitjhaba [[Neil Tovey|u-Neil Tovey]] no -Lucas Radebe kanye no -Patrick Ntsoelengoe, u-Gary Bailey, u-John &quot;Shoes&quot; Moshoeu, u-Shaun Bartlett, u- Steve Komphela, u-Siyabonga Nomvete, u- Doctor no-Khumalo.

Yisiqhema esisekelwa khulu [[Isewula Afrika|eSewula Afrika]]￼. I-Kaizer Chiefs beyinesisekelo esingaphezu kweengidi ezili-16 ekuthomeni kwekhulu leminyaka. Bathola isilinganiso sabantu abafika ekhaya esingu-16,144 ngesizini ka-2019-20, okuphezulu khulu kuligi. Isiqhema sidlala imidlalo eminengi yangekhaya e- FNB Stadium enabantu abama-94,797&lt;ref&gt;{{Citation |last=Villela |first=Roger |title=.NET Platform |date=2020 |work=Pro .NET 5 Custom Libraries |pages=1–27 |url=https://doi.org/10.1007/978-1-4842-6391-4_1 |access-date=2025-09-04 |place=Berkeley, CA |publisher=Apress |isbn=978-1-4842-6390-7}}&lt;/ref&gt;
.  NgoTjhirhweni 2025, i-Kaizer Chiefs yagidinga iminyaka ema-55.

Imithombo lwazi</text>
      <sha1>h5t07i48ybz2123tohwksfp9o6vqia3</sha1>
    </revision>
    <revision>
      <id>5662</id>
      <parentid>5661</parentid>
      <timestamp>2025-09-04T11:14:32Z</timestamp>
      <contributor>
        <username>Mbonani JayJay</username>
        <id>892</id>
      </contributor>
      <origin>5662</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2816" sha1="f223zmq6d8efhkjs6v46jq23erjauaz" xml:space="preserve">clubname=Kaizer Chiefs|image=Kaizer Chiefs logo.svg|image_size=180px|short name=Chiefs|nickname={{Plainlist|
* ''AmaKhosi'' (Kings)
* '' The Phefeni Boys ''
* '' Abafana bokuthula noxolo'' (The Boys of Love &amp; Peace)
* '' The Glamour Boys ''
}}|fullname=Kaizer Chiefs Football Club|founded={{Start date and age|1970|01|07|df=y}}|ground=[[FNB Stadium]]|capacity=94,797|chairman=[[Kaizer Motaung]]|league=[[South African Premiership|Betway Premiership]]|season=[[2024–25 South African Premiership|2024–25]]|current=2025–26 Kaizer Chiefs F.C. season|stadium=[[FNB Stadium]]|position=9th|manager=[[Nasreddine Nabi]]|website={{URL|https://www.kaizerchiefs.com/}}|owner=[[Kaizer Motaung]]|chrtitle=Chairman}}'''I-Kaizer Chiefs Football Club''' (eyaziwa ngokuthi '''yi-Chiefs)''' yisiqhema sebholo ye -Sewula Afrika ese-Naturena, e[[Johannesburg|-Johannesburg]] South, edlala ku- Premiership￼. Isiqhema sibizwa nge ''-AmaKhosi'', okutjho &quot;amaKhosi&quot; ngesiZulu, kanye nama ''-Phefeni Glamour Boys.'' I-Chiefs sele inqobe iinhlandla ezinengi zeligi kanye namatrophi. Indebe yakamuva yasekhaya bekuyiNdebe ye-Nedbank ka-2024-25￼. Baphethe iinkezo ezinengi khulu hlangana nazo zoke iinqhema zeSewula Afrika begodu bayisiqhema esiphumelele khulu emlandwini webholo yeSewula Afrika solo kwathoma izinga eliphezulu ngo-1970.&lt;ref&gt;{{Citation |title=Kaizer Chiefs F.C. |date=2025-09-03 |work=Wikipedia |url=https://en.wikipedia.org/w/index.php?title=Kaizer_Chiefs_F.C.&amp;oldid=1309345035 |access-date=2025-09-04 |language=en}}&lt;/ref&gt;
[[Isimumathi:Kaizer Chiefs Stand.jpg|thumb|284x284px|Kaizer Chiefs club house]]
Isiqhema sinomncintiswano omkhulu wendawo, i -Soweto derby, ne -Orlando Pirates, isiqhema se-Soweto umsunguli we-Chiefs u-Kaizer Motaung adlala kiso ekuthomeni komsebenzi wakhe wokudlala.  Abadlali abadumileko ebegade bambatha ijezi elimnyama negolide esikhathini esidlulileko bafaka hlangana abokapteni besiqhema lesitjhaba [[Neil Tovey|u-Neil Tovey]] no -Lucas Radebe kanye no -Patrick Ntsoelengoe, u-Gary Bailey, u-John &quot;Shoes&quot; Moshoeu, u-Shaun Bartlett, u- Steve Komphela, u-Siyabonga Nomvete, u- Doctor no-Khumalo.

Yisiqhema esisekelwa khulu [[Isewula Afrika|eSewula Afrika]]￼. I-Kaizer Chiefs beyinesisekelo esingaphezu kweengidi ezili-16 ekuthomeni kwekhulu leminyaka. Bathola isilinganiso sabantu abafika ekhaya esingu-16,144 ngesizini ka-2019-20, okuphezulu khulu kuligi. Isiqhema sidlala imidlalo eminengi yangekhaya e- FNB Stadium enabantu abama-94,797&lt;ref&gt;{{Citation |last=Villela |first=Roger |title=.NET Platform |date=2020 |work=Pro .NET 5 Custom Libraries |pages=1–27 |url=https://doi.org/10.1007/978-1-4842-6391-4_1 |access-date=2025-09-04 |place=Berkeley, CA |publisher=Apress |isbn=978-1-4842-6390-7}}&lt;/ref&gt;
.  NgoTjhirhweni 2025, i-Kaizer Chiefs yagidinga iminyaka ema-55.

Imithombo lwazi</text>
      <sha1>f223zmq6d8efhkjs6v46jq23erjauaz</sha1>
    </revision>
    <revision>
      <id>5664</id>
      <parentid>5662</parentid>
      <timestamp>2025-09-04T11:15:20Z</timestamp>
      <contributor>
        <username>Mbonani JayJay</username>
        <id>892</id>
      </contributor>
      <origin>5664</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2841" sha1="h5t07i48ybz2123tohwksfp9o6vqia3" xml:space="preserve">
{{Infobox football club|clubname=Kaizer Chiefs|image=Kaizer Chiefs logo.svg|image_size=180px|short name=Chiefs|nickname={{Plainlist|
* ''AmaKhosi'' (Kings)
* '' The Phefeni Boys ''
* '' Abafana bokuthula noxolo'' (The Boys of Love &amp; Peace)
* '' The Glamour Boys ''
}}|fullname=Kaizer Chiefs Football Club|founded={{Start date and age|1970|01|07|df=y}}|ground=[[FNB Stadium]]|capacity=94,797|chairman=[[Kaizer Motaung]]|league=[[South African Premiership|Betway Premiership]]|season=[[2024–25 South African Premiership|2024–25]]|current=2025–26 Kaizer Chiefs F.C. season|stadium=[[FNB Stadium]]|position=9th|manager=[[Nasreddine Nabi]]|website={{URL|https://www.kaizerchiefs.com/}}|owner=[[Kaizer Motaung]]|chrtitle=Chairman}}'''I-Kaizer Chiefs Football Club''' (eyaziwa ngokuthi '''yi-Chiefs)''' yisiqhema sebholo ye -Sewula Afrika ese-Naturena, e[[Johannesburg|-Johannesburg]] South, edlala ku- Premiership￼. Isiqhema sibizwa nge ''-AmaKhosi'', okutjho &quot;amaKhosi&quot; ngesiZulu, kanye nama ''-Phefeni Glamour Boys.'' I-Chiefs sele inqobe iinhlandla ezinengi zeligi kanye namatrophi. Indebe yakamuva yasekhaya bekuyiNdebe ye-Nedbank ka-2024-25￼. Baphethe iinkezo ezinengi khulu hlangana nazo zoke iinqhema zeSewula Afrika begodu bayisiqhema esiphumelele khulu emlandwini webholo yeSewula Afrika solo kwathoma izinga eliphezulu ngo-1970.&lt;ref&gt;{{Citation |title=Kaizer Chiefs F.C. |date=2025-09-03 |work=Wikipedia |url=https://en.wikipedia.org/w/index.php?title=Kaizer_Chiefs_F.C.&amp;oldid=1309345035 |access-date=2025-09-04 |language=en}}&lt;/ref&gt;
[[Isimumathi:Kaizer Chiefs Stand.jpg|thumb|284x284px|Kaizer Chiefs club house]]
Isiqhema sinomncintiswano omkhulu wendawo, i -Soweto derby, ne -Orlando Pirates, isiqhema se-Soweto umsunguli we-Chiefs u-Kaizer Motaung adlala kiso ekuthomeni komsebenzi wakhe wokudlala.  Abadlali abadumileko ebegade bambatha ijezi elimnyama negolide esikhathini esidlulileko bafaka hlangana abokapteni besiqhema lesitjhaba [[Neil Tovey|u-Neil Tovey]] no -Lucas Radebe kanye no -Patrick Ntsoelengoe, u-Gary Bailey, u-John &quot;Shoes&quot; Moshoeu, u-Shaun Bartlett, u- Steve Komphela, u-Siyabonga Nomvete, u- Doctor no-Khumalo.

Yisiqhema esisekelwa khulu [[Isewula Afrika|eSewula Afrika]]￼. I-Kaizer Chiefs beyinesisekelo esingaphezu kweengidi ezili-16 ekuthomeni kwekhulu leminyaka. Bathola isilinganiso sabantu abafika ekhaya esingu-16,144 ngesizini ka-2019-20, okuphezulu khulu kuligi. Isiqhema sidlala imidlalo eminengi yangekhaya e- FNB Stadium enabantu abama-94,797&lt;ref&gt;{{Citation |last=Villela |first=Roger |title=.NET Platform |date=2020 |work=Pro .NET 5 Custom Libraries |pages=1–27 |url=https://doi.org/10.1007/978-1-4842-6391-4_1 |access-date=2025-09-04 |place=Berkeley, CA |publisher=Apress |isbn=978-1-4842-6390-7}}&lt;/ref&gt;
.  NgoTjhirhweni 2025, i-Kaizer Chiefs yagidinga iminyaka ema-55.

Imithombo lwazi</text>
      <sha1>h5t07i48ybz2123tohwksfp9o6vqia3</sha1>
    </revision>
    <revision>
      <id>5676</id>
      <parentid>5664</parentid>
      <timestamp>2025-09-04T11:30:34Z</timestamp>
      <contributor>
        <username>Mbonani JayJay</username>
        <id>892</id>
      </contributor>
      <origin>5676</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2842" sha1="d1wtn30pbm9diyw11nataxngjq2mrzj" xml:space="preserve">
{{Infobox football club|clubname=Kaizer Chiefs|image=Kaizer Chiefs logo.svg|image_size=180px|short name=Chiefs|nickname={{Plainlist|
* ''AmaKhosi'' (Kings)
* '' The Phefeni Boys ''
* '' Abafana bokuthula noxolo'' (The Boys of Love &amp; Peace)
* '' The Glamour Boys ''
}}|fullname=Kaizer Chiefs Football Club|founded={{Start date and age|1970|01|07|df=y}}|ground=[[FNB Stadium]]|capacity=94,797|chairman=[[Kaizer Motaung]]|league=[[South African Premiership|Betway Premiership]]|season=[[2024–25 South African Premiership|2024–25]]|current=2025–26 Kaizer Chiefs F.C. season|stadium=[[FNB Stadium]]|position=9th|manager=[[Nasreddine Nabi]]|website={{URL|https://www.kaizerchiefs.com/}}|owner=[[Kaizer Motaung]]|chrtitle=Chairman}}'''I-Kaizer Chiefs Football Club''' (eyaziwa ngokuthi '''yi-Chiefs)''' yisiqhema sebholo ye -Sewula Afrika ese-Naturena, e[[Johannesburg|-Johannesburg]] South, edlala ku- Premiership￼. Isiqhema sibizwa nge ''-AmaKhosi'', okutjho &quot;amaKhosi&quot; ngesiZulu, kanye nama ''-Phefeni Glamour Boys.'' I-Chiefs sele inqobe iinhlandla ezinengi zeligi kanye namatrophi. Indebe yakamuva yasekhaya bekuyiNdebe ye-Nedbank ka-2024-25￼. Baphethe iinkezo ezinengi khulu hlangana nazo zoke iinqhema zeSewula Afrika begodu bayisiqhema esiphumelele khulu emlandwini webholo yeSewula Afrika solo kwathoma izinga eliphezulu ngo-1970.Absol Internet Business Solutions. &quot;Kaizer Motaung | The Presidency&quot;. www.thepresidency.gov.za. Archived from the original on 2023-10-16. Retrieved 2025-09-04. {{cite web}}: |last= has generic name (help)
[[Isimumathi:Kaizer Chiefs Stand.jpg|thumb|284x284px|Kaizer Chiefs club house]]
Isiqhema sinomncintiswano omkhulu wendawo, i -Soweto derby, ne -Orlando Pirates, isiqhema se-Soweto umsunguli we-Chiefs u-Kaizer Motaung adlala kiso ekuthomeni komsebenzi wakhe wokudlala.  Abadlali abadumileko ebegade bambatha ijezi elimnyama negolide esikhathini esidlulileko bafaka hlangana abokapteni besiqhema lesitjhaba [[Neil Tovey|u-Neil Tovey]] no -Lucas Radebe kanye no -Patrick Ntsoelengoe, u-Gary Bailey, u-John &quot;Shoes&quot; Moshoeu, u-Shaun Bartlett, u- Steve Komphela, u-Siyabonga Nomvete, u- Doctor no-Khumalo.

Yisiqhema esisekelwa khulu [[Isewula Afrika|eSewula Afrika]]￼. I-Kaizer Chiefs beyinesisekelo esingaphezu kweengidi ezili-16 ekuthomeni kwekhulu leminyaka. Bathola isilinganiso sabantu abafika ekhaya esingu-16,144 ngesizini ka-2019-20, okuphezulu khulu kuligi. Isiqhema sidlala imidlalo eminengi yangekhaya e- FNB Stadium enabantu abama-94,797&lt;ref&gt;{{Citation |last=Villela |first=Roger |title=.NET Platform |date=2020 |work=Pro .NET 5 Custom Libraries |pages=1–27 |url=https://doi.org/10.1007/978-1-4842-6391-4_1 |access-date=2025-09-04 |place=Berkeley, CA |publisher=Apress |isbn=978-1-4842-6390-7}}&lt;/ref&gt;
.  NgoTjhirhweni 2025, i-Kaizer Chiefs yagidinga iminyaka ema-55.

Imithombo lwazi</text>
      <sha1>d1wtn30pbm9diyw11nataxngjq2mrzj</sha1>
    </revision>
    <revision>
      <id>5677</id>
      <parentid>5676</parentid>
      <timestamp>2025-09-04T11:31:34Z</timestamp>
      <contributor>
        <username>Mbonani JayJay</username>
        <id>892</id>
      </contributor>
      <origin>5677</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2810" sha1="ksh23rzf6jykibu7rmxnth83kq1d48v" xml:space="preserve">
{{Infobox football club|clubname=Kaizer Chiefs|image=Kaizer Chiefs logo.svg|image_size=180px|short name=Chiefs|nickname={{Plainlist|
* ''AmaKhosi'' (Kings)
* '' The Phefeni Boys ''
* '' Abafana bokuthula noxolo'' (The Boys of Love &amp; Peace)
* '' The Glamour Boys ''
}}|fullname=Kaizer Chiefs Football Club|founded={{Start date and age|1970|01|07|df=y}}|ground=[[FNB Stadium]]|capacity=94,797|chairman=[[Kaizer Motaung]]|league=[[South African Premiership|Betway Premiership]]|season=[[2024–25 South African Premiership|2024–25]]|current=2025–26 Kaizer Chiefs F.C. season|stadium=[[FNB Stadium]]|position=9th|manager=[[Nasreddine Nabi]]|website={{URL|https://www.kaizerchiefs.com/}}|owner=[[Kaizer Motaung]]|chrtitle=Chairman}}'''I-Kaizer Chiefs Football Club''' (eyaziwa ngokuthi '''yi-Chiefs)''' yisiqhema sebholo ye -Sewula Afrika ese-Naturena, e[[Johannesburg|-Johannesburg]] South, edlala ku- Premiership￼. Isiqhema sibizwa nge ''-AmaKhosi'', okutjho &quot;amaKhosi&quot; ngesiZulu, kanye nama ''-Phefeni Glamour Boys.'' I-Chiefs sele inqobe iinhlandla ezinengi zeligi kanye namatrophi. Indebe yakamuva yasekhaya bekuyiNdebe ye-Nedbank ka-2024-25￼. Baphethe iinkezo ezinengi khulu hlangana nazo zoke iinqhema zeSewula Afrika begodu bayisiqhema esiphumelele khulu emlandwini webholo yeSewula Afrika solo kwathoma izinga eliphezulu ngo-1970.Absol Internet Business Solutions. &quot;Kaizer Motaung | The Presidency&quot;. www.thepresidency.gov.za. Archived from the original on 2023-10-16. Retrieved 2025-09-04. {{cite web}}
[[Isimumathi:Kaizer Chiefs Stand.jpg|thumb|284x284px|Kaizer Chiefs club house]]
Isiqhema sinomncintiswano omkhulu wendawo, i -Soweto derby, ne -Orlando Pirates, isiqhema se-Soweto umsunguli we-Chiefs u-Kaizer Motaung adlala kiso ekuthomeni komsebenzi wakhe wokudlala.  Abadlali abadumileko ebegade bambatha ijezi elimnyama negolide esikhathini esidlulileko bafaka hlangana abokapteni besiqhema lesitjhaba [[Neil Tovey|u-Neil Tovey]] no -Lucas Radebe kanye no -Patrick Ntsoelengoe, u-Gary Bailey, u-John &quot;Shoes&quot; Moshoeu, u-Shaun Bartlett, u- Steve Komphela, u-Siyabonga Nomvete, u- Doctor no-Khumalo.

Yisiqhema esisekelwa khulu [[Isewula Afrika|eSewula Afrika]]￼. I-Kaizer Chiefs beyinesisekelo esingaphezu kweengidi ezili-16 ekuthomeni kwekhulu leminyaka. Bathola isilinganiso sabantu abafika ekhaya esingu-16,144 ngesizini ka-2019-20, okuphezulu khulu kuligi. Isiqhema sidlala imidlalo eminengi yangekhaya e- FNB Stadium enabantu abama-94,797&lt;ref&gt;{{Citation |last=Villela |first=Roger |title=.NET Platform |date=2020 |work=Pro .NET 5 Custom Libraries |pages=1–27 |url=https://doi.org/10.1007/978-1-4842-6391-4_1 |access-date=2025-09-04 |place=Berkeley, CA |publisher=Apress |isbn=978-1-4842-6390-7}}&lt;/ref&gt;
.  NgoTjhirhweni 2025, i-Kaizer Chiefs yagidinga iminyaka ema-55.

Imithombo lwazi</text>
      <sha1>ksh23rzf6jykibu7rmxnth83kq1d48v</sha1>
    </revision>
    <revision>
      <id>5680</id>
      <parentid>5677</parentid>
      <timestamp>2025-09-04T11:34:01Z</timestamp>
      <contributor>
        <username>Mbonani JayJay</username>
        <id>892</id>
      </contributor>
      <origin>5680</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2638" sha1="mnfjrrp9dl4lzr94whlnn5lrf0raxb9" xml:space="preserve">
{{Infobox football club|clubname=Kaizer Chiefs|image=Kaizer Chiefs logo.svg|image_size=180px|short name=Chiefs|nickname={{Plainlist|
* ''AmaKhosi'' (Kings)
* '' The Phefeni Boys ''
* '' Abafana bokuthula noxolo'' (The Boys of Love &amp; Peace)
* '' The Glamour Boys ''
}}|fullname=Kaizer Chiefs Football Club|founded={{Start date and age|1970|01|07|df=y}}|ground=[[FNB Stadium]]|capacity=94,797|chairman=[[Kaizer Motaung]]|league=[[South African Premiership|Betway Premiership]]|season=[[2024–25 South African Premiership|2024–25]]|current=2025–26 Kaizer Chiefs F.C. season|stadium=[[FNB Stadium]]|position=9th|manager=[[Nasreddine Nabi]]|website={{URL|https://www.kaizerchiefs.com/}}|owner=[[Kaizer Motaung]]|chrtitle=Chairman}}'''I-Kaizer Chiefs Football Club''' (eyaziwa ngokuthi '''yi-Chiefs)''' yisiqhema sebholo ye -Sewula Afrika ese-Naturena, e[[Johannesburg|-Johannesburg]] South, edlala ku- Premiership￼. Isiqhema sibizwa nge ''-AmaKhosi'', okutjho &quot;amaKhosi&quot; ngesiZulu, kanye nama ''-Phefeni Glamour Boys.'' I-Chiefs sele inqobe iinhlandla ezinengi zeligi kanye namatrophi. Indebe yakamuva yasekhaya bekuyiNdebe ye-Nedbank ka-2024-25￼. Baphethe iinkezo ezinengi khulu hlangana nazo zoke iinqhema zeSewula Afrika begodu bayisiqhema esiphumelele khulu emlandwini webholo yeSewula Afrika solo kwathoma izinga eliphezulu ngo-1970.
[[Isimumathi:Kaizer Chiefs Stand.jpg|thumb|284x284px|Kaizer Chiefs club house]]
Isiqhema sinomncintiswano omkhulu wendawo, i -Soweto derby, ne -Orlando Pirates, isiqhema se-Soweto umsunguli we-Chiefs u-Kaizer Motaung adlala kiso ekuthomeni komsebenzi wakhe wokudlala.  Abadlali abadumileko ebegade bambatha ijezi elimnyama negolide esikhathini esidlulileko bafaka hlangana abokapteni besiqhema lesitjhaba [[Neil Tovey|u-Neil Tovey]] no -Lucas Radebe kanye no -Patrick Ntsoelengoe, u-Gary Bailey, u-John &quot;Shoes&quot; Moshoeu, u-Shaun Bartlett, u- Steve Komphela, u-Siyabonga Nomvete, u- Doctor no-Khumalo.

Yisiqhema esisekelwa khulu [[Isewula Afrika|eSewula Afrika]]￼. I-Kaizer Chiefs beyinesisekelo esingaphezu kweengidi ezili-16 ekuthomeni kwekhulu leminyaka. Bathola isilinganiso sabantu abafika ekhaya esingu-16,144 ngesizini ka-2019-20, okuphezulu khulu kuligi. Isiqhema sidlala imidlalo eminengi yangekhaya e- FNB Stadium enabantu abama-94,797&lt;ref&gt;{{Citation |last=Villela |first=Roger |title=.NET Platform |date=2020 |work=Pro .NET 5 Custom Libraries |pages=1–27 |url=https://doi.org/10.1007/978-1-4842-6391-4_1 |access-date=2025-09-04 |place=Berkeley, CA |publisher=Apress |isbn=978-1-4842-6390-7}}&lt;/ref&gt;
.  NgoTjhirhweni 2025, i-Kaizer Chiefs yagidinga iminyaka ema-55.

Imithombo lwazi</text>
      <sha1>mnfjrrp9dl4lzr94whlnn5lrf0raxb9</sha1>
    </revision>
    <revision>
      <id>5691</id>
      <parentid>5680</parentid>
      <timestamp>2025-09-04T11:40:40Z</timestamp>
      <contributor>
        <username>Mbonani JayJay</username>
        <id>892</id>
      </contributor>
      <origin>5691</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2950" sha1="oioxv0hdogocbk0p6bx5q6yga7psrvq" xml:space="preserve">
{{Infobox football club|clubname=Kaizer Chiefs|image=Kaizer Chiefs logo.svg|image_size=180px|short name=Chiefs|nickname={{Plainlist|
* ''AmaKhosi'' (Kings)
* '' The Phefeni Boys ''
* '' Abafana bokuthula noxolo'' (The Boys of Love &amp; Peace)
* '' The Glamour Boys ''
}}|fullname=Kaizer Chiefs Football Club|founded={{Start date and age|1970|01|07|df=y}}|ground=[[FNB Stadium]]|capacity=94,797|chairman=[[Kaizer Motaung]]|league=[[South African Premiership|Betway Premiership]]|season=[[2024–25 South African Premiership|2024–25]]|current=2025–26 Kaizer Chiefs F.C. season|stadium=[[FNB Stadium]]|position=9th|manager=[[Nasreddine Nabi]]|website={{URL|https://www.kaizerchiefs.com/}}|owner=[[Kaizer Motaung]]|chrtitle=Chairman}}'''I-Kaizer Chiefs Football Club''' (eyaziwa ngokuthi '''yi-Chiefs)''' yisiqhema sebholo ye -Sewula Afrika ese-Naturena, e[[Johannesburg|-Johannesburg]] South, edlala ku- Premiership￼. Isiqhema sibizwa nge ''-AmaKhosi'', okutjho &quot;amaKhosi&quot; ngesiZulu, kanye nama ''-Phefeni Glamour Boys.'' I-Chiefs sele inqobe iinhlandla ezinengi zeligi kanye namatrophi. Indebe yakamuva yasekhaya bekuyiNdebe ye-Nedbank ka-2024-25￼. Baphethe iinkezo ezinengi khulu hlangana nazo zoke iinqhema zeSewula Afrika begodu bayisiqhema esiphumelele khulu emlandwini webholo yeSewula Afrika solo kwathoma izinga eliphezulu ngo-1970.
[[Isimumathi:Kaizer Chiefs Stand.jpg|thumb|284x284px|Kaizer Chiefs club house]]
Isiqhema sinomncintiswano omkhulu wendawo, i -Soweto derby, ne -Orlando Pirates, isiqhema se-Soweto umsunguli we-Chiefs u-Kaizer Motaung adlala kiso ekuthomeni komsebenzi wakhe wokudlala &lt;ref&gt;{{Cite web |title=Kaizer Motaung {{!}} The Presidency |url=https://thepresidency.gov.za/kaizer-motaung |archive-url=http://web.archive.org/web/20250619184316/https://thepresidency.gov.za/kaizer-motaung |archive-date=2025-06-19 |access-date=2025-09-04 |website=www.thepresidency.gov.za |language=en}}&lt;/ref&gt;
.  Abadlali abadumileko ebegade bambatha ijezi elimnyama negolide esikhathini esidlulileko bafaka hlangana abokapteni besiqhema lesitjhaba [[Neil Tovey|u-Neil Tovey]] no -Lucas Radebe kanye no -Patrick Ntsoelengoe, u-Gary Bailey, u-John &quot;Shoes&quot; Moshoeu, u-Shaun Bartlett, u- Steve Komphela, u-Siyabonga Nomvete, u- Doctor no-Khumalo.

Yisiqhema esisekelwa khulu [[Isewula Afrika|eSewula Afrika]]￼. I-Kaizer Chiefs beyinesisekelo esingaphezu kweengidi ezili-16 ekuthomeni kwekhulu leminyaka. Bathola isilinganiso sabantu abafika ekhaya esingu-16,144 ngesizini ka-2019-20, okuphezulu khulu kuligi. Isiqhema sidlala imidlalo eminengi yangekhaya e- FNB Stadium enabantu abama-94,797&lt;ref&gt;{{Citation |last=Villela |first=Roger |title=.NET Platform |date=2020 |work=Pro .NET 5 Custom Libraries |pages=1–27 |url=https://doi.org/10.1007/978-1-4842-6391-4_1 |access-date=2025-09-04 |place=Berkeley, CA |publisher=Apress |isbn=978-1-4842-6390-7}}&lt;/ref&gt;
.  NgoTjhirhweni 2025, i-Kaizer Chiefs yagidinga iminyaka ema-55.

Imithombo lwazi</text>
      <sha1>oioxv0hdogocbk0p6bx5q6yga7psrvq</sha1>
    </revision>
    <revision>
      <id>5692</id>
      <parentid>5691</parentid>
      <timestamp>2025-09-04T11:46:06Z</timestamp>
      <contributor>
        <username>Mbonani JayJay</username>
        <id>892</id>
      </contributor>
      <origin>5692</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2852" sha1="sl23nqr19uyrlbmnhs6u6y2fhfomwb7" xml:space="preserve">
{{Infobox football club|clubname=Kaizer Chiefs|image=Kaizer Chiefs logo.svg|image_size=180px|short name=Chiefs|nickname={{Plainlist|
* ''AmaKhosi'' (Kings)
* '' The Phefeni Boys ''
* '' Abafana bokuthula noxolo'' (The Boys of Love &amp; Peace)
* '' The Glamour Boys ''
}}|fullname=Kaizer Chiefs Football Club|founded={{Start date and age|1970|01|07|df=y}}|ground=[[FNB Stadium]]|capacity=94,797|chairman=[[Kaizer Motaung]]|league=[[South African Premiership|Betway Premiership]]|season=[[2024–25 South African Premiership|2024–25]]|current=2025–26 Kaizer Chiefs F.C. season|stadium=[[FNB Stadium]]|position=9th|manager=[[Nasreddine Nabi]]|website={{URL|https://www.kaizerchiefs.com/}}|owner=[[Kaizer Motaung]]|chrtitle=Chairman}}'''I-Kaizer Chiefs Football Club''' (eyaziwa ngokuthi '''yi-Chiefs)''' yisiqhema sebholo ye -Sewula Afrika ese-Naturena, e[[Johannesburg|-Johannesburg]] South, edlala ku- Premiership￼. Isiqhema sibizwa nge ''-AmaKhosi'', okutjho &quot;amaKhosi&quot; ngesiZulu, kanye nama ''-Phefeni Glamour Boys.'' I-Chiefs sele inqobe iinhlandla ezinengi zeligi kanye namatrophi. Indebe yakamuva yasekhaya bekuyiNdebe ye-Nedbank ka-2024-25￼. Baphethe iinkezo ezinengi khulu hlangana nazo zoke iinqhema zeSewula Afrika begodu bayisiqhema esiphumelele khulu emlandwini webholo yeSewula Afrika solo kwathoma izinga eliphezulu ngo-1970.
[[Isimumathi:Kaizer Chiefs Stand.jpg|thumb|284x284px|Kaizer Chiefs club house]]
Isiqhema sinomncintiswano omkhulu wendawo, i -Soweto derby, ne -Orlando Pirates, isiqhema se-Soweto umsunguli we-Chiefs u-Kaizer Motaung adlala kiso ekuthomeni komsebenzi wakhe wokudlala &lt;ref&gt;{{Cite web |title=Kaizer Motaung {{!}} The Presidency |url=https://thepresidency.gov.za/kaizer-motaung |archive-url=http://web.archive.org/web/20250619184316/https://thepresidency.gov.za/kaizer-motaung |archive-date=2025-06-19 |access-date=2025-09-04 |website=www.thepresidency.gov.za |language=en}}&lt;/ref&gt;
.  Abadlali abadumileko ebegade bambatha ijezi elimnyama negolide esikhathini esidlulileko bafaka hlangana abokapteni besiqhema lesitjhaba [[Neil Tovey|u-Neil Tovey]] no -Lucas Radebe kanye no -Patrick Ntsoelengoe, u-Gary Bailey, u-John &quot;Shoes&quot; Moshoeu, u-Shaun Bartlett, u- Steve Komphela, u-Siyabonga Nomvete, u- Doctor no-Khumalo.

Yisiqhema esisekelwa khulu [[Isewula Afrika|eSewula Afrika]]￼. I-Kaizer Chiefs beyinesisekelo esingaphezu kweengidi ezili-16 ekuthomeni kwekhulu leminyaka. Bathola isilinganiso sabantu abafika ekhaya esingu-16,144 ngesizini ka-2019-20, okuphezulu khulu kuligi. Isiqhema sidlala imidlalo eminengi yangekhaya e- FNB Stadium enabantu abama-94,797.&lt;ref&gt;{{Cite web |date=2025-09-02 |title=worldfootball.net |url=https://www.worldfootball.net/ |access-date=2025-09-04 |website=worldfootball.net |language=en}}&lt;/ref&gt;

.  NgoTjhirhweni 2025, i-Kaizer Chiefs yagidinga iminyaka ema-55.

Imithombo lwazi</text>
      <sha1>sl23nqr19uyrlbmnhs6u6y2fhfomwb7</sha1>
    </revision>
    <revision>
      <id>5693</id>
      <parentid>5692</parentid>
      <timestamp>2025-09-04T11:46:47Z</timestamp>
      <contributor>
        <username>Mbonani JayJay</username>
        <id>892</id>
      </contributor>
      <origin>5693</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2848" sha1="1b9a107cc6r69p5c7if31u9couqht4q" xml:space="preserve">
{{Infobox football club|clubname=Kaizer Chiefs|image=Kaizer Chiefs logo.svg|image_size=180px|short name=Chiefs|nickname={{Plainlist|
* ''AmaKhosi'' (Kings)
* '' The Phefeni Boys ''
* '' Abafana bokuthula noxolo'' (The Boys of Love &amp; Peace)
* '' The Glamour Boys ''
}}|fullname=Kaizer Chiefs Football Club|founded={{Start date and age|1970|01|07|df=y}}|ground=[[FNB Stadium]]|capacity=94,797|chairman=[[Kaizer Motaung]]|league=[[South African Premiership|Betway Premiership]]|season=[[2024–25 South African Premiership|2024–25]]|current=2025–26 Kaizer Chiefs F.C. season|stadium=[[FNB Stadium]]|position=9th|manager=[[Nasreddine Nabi]]|website={{URL|https://www.kaizerchiefs.com/}}|owner=[[Kaizer Motaung]]|chrtitle=Chairman}}'''I-Kaizer Chiefs Football Club''' (eyaziwa ngokuthi '''yi-Chiefs)''' yisiqhema sebholo ye -Sewula Afrika ese-Naturena, e[[Johannesburg|-Johannesburg]] South, edlala ku- Premiership￼. Isiqhema sibizwa nge ''-AmaKhosi'', okutjho &quot;amaKhosi&quot; ngesiZulu, kanye nama ''-Phefeni Glamour Boys.'' I-Chiefs sele inqobe iinhlandla ezinengi zeligi kanye namatrophi. Indebe yakamuva yasekhaya bekuyiNdebe ye-Nedbank ka-2024-25￼. Baphethe iinkezo ezinengi khulu hlangana nazo zoke iinqhema zeSewula Afrika begodu bayisiqhema esiphumelele khulu emlandwini webholo yeSewula Afrika solo kwathoma izinga eliphezulu ngo-1970.
[[Isimumathi:Kaizer Chiefs Stand.jpg|thumb|284x284px|Kaizer Chiefs club house]]
Isiqhema sinomncintiswano omkhulu wendawo, i -Soweto derby, ne -Orlando Pirates, isiqhema se-Soweto umsunguli we-Chiefs u-Kaizer Motaung adlala kiso ekuthomeni komsebenzi wakhe wokudlala &lt;ref&gt;{{Cite web |title=Kaizer Motaung {{!}} The Presidency |url=https://thepresidency.gov.za/kaizer-motaung |archive-url=http://web.archive.org/web/20250619184316/https://thepresidency.gov.za/kaizer-motaung |archive-date=2025-06-19 |access-date=2025-09-04 |website=www.thepresidency.gov.za |language=en}}&lt;/ref&gt;
.  Abadlali abadumileko ebegade bambatha ijezi elimnyama negolide esikhathini esidlulileko bafaka hlangana abokapteni besiqhema lesitjhaba [[Neil Tovey|u-Neil Tovey]] no -Lucas Radebe kanye no -Patrick Ntsoelengoe, u-Gary Bailey, u-John &quot;Shoes&quot; Moshoeu, u-Shaun Bartlett, u- Steve Komphela, u-Siyabonga Nomvete, u- Doctor no-Khumalo.

Yisiqhema esisekelwa khulu [[Isewula Afrika|eSewula Afrika]]￼. I-Kaizer Chiefs beyinesisekelo esingaphezu kweengidi ezili-16 ekuthomeni kwekhulu leminyaka. Bathola isilinganiso sabantu abafika ekhaya esingu-16,144 ngesizini ka-2019-20, okuphezulu khulu kuligi. Isiqhema sidlala imidlalo eminengi yangekhaya e- FNB Stadium enabantu abama-94,797.&lt;ref&gt;{{Cite web |date=2025-09-02 |title=worldfootball.net |url=https://www.worldfootball.net/ |access-date=2025-09-04 |website=worldfootball.net |language=en}}&lt;/ref&gt;
NgoTjhirhweni 2025, i-Kaizer Chiefs yagidinga iminyaka ema-55.

Imithombo lwazi</text>
      <sha1>1b9a107cc6r69p5c7if31u9couqht4q</sha1>
    </revision>
    <revision>
      <id>5695</id>
      <parentid>5693</parentid>
      <timestamp>2025-09-04T11:50:31Z</timestamp>
      <contributor>
        <username>Mbonani JayJay</username>
        <id>892</id>
      </contributor>
      <origin>5695</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3093" sha1="hzovmdy7owttulhkbbf8ocdamjq13wq" xml:space="preserve">
{{Infobox football club|clubname=Kaizer Chiefs|image=Kaizer Chiefs logo.svg|image_size=180px|short name=Chiefs|nickname={{Plainlist|
* ''AmaKhosi'' (Kings)
* '' The Phefeni Boys ''
* '' Abafana bokuthula noxolo'' (The Boys of Love &amp; Peace)
* '' The Glamour Boys ''
}}|fullname=Kaizer Chiefs Football Club|founded={{Start date and age|1970|01|07|df=y}}|ground=[[FNB Stadium]]|capacity=94,797|chairman=[[Kaizer Motaung]]|league=[[South African Premiership|Betway Premiership]]|season=[[2024–25 South African Premiership|2024–25]]|current=2025–26 Kaizer Chiefs F.C. season|stadium=[[FNB Stadium]]|position=9th|manager=[[Nasreddine Nabi]]|website={{URL|https://www.kaizerchiefs.com/}}|owner=[[Kaizer Motaung]]|chrtitle=Chairman}}'''I-Kaizer Chiefs Football Club''' (eyaziwa ngokuthi '''yi-Chiefs)''' yisiqhema sebholo ye -Sewula Afrika ese-Naturena, e[[Johannesburg|-Johannesburg]] South, edlala ku- Premiership￼. Isiqhema sibizwa nge ''-AmaKhosi'', okutjho &quot;amaKhosi&quot; ngesiZulu, kanye nama ''-Phefeni Glamour Boys.'' I-Chiefs sele inqobe iinhlandla ezinengi zeligi kanye namatrophi. Indebe yakamuva yasekhaya bekuyiNdebe ye-Nedbank ka-2024-25￼. Baphethe iinkezo ezinengi khulu hlangana nazo zoke iinqhema zeSewula Afrika begodu bayisiqhema esiphumelele khulu emlandwini webholo yeSewula Afrika solo kwathoma izinga eliphezulu ngo-1970.
[[Isimumathi:Kaizer Chiefs Stand.jpg|thumb|284x284px|Kaizer Chiefs club house]]
Isiqhema sinomncintiswano omkhulu wendawo, i -Soweto derby, ne -Orlando Pirates, isiqhema se-Soweto umsunguli we-Chiefs u-Kaizer Motaung adlala kiso ekuthomeni komsebenzi wakhe wokudlala &lt;ref&gt;{{Cite web |title=Kaizer Motaung {{!}} The Presidency |url=https://thepresidency.gov.za/kaizer-motaung |archive-url=http://web.archive.org/web/20250619184316/https://thepresidency.gov.za/kaizer-motaung |archive-date=2025-06-19 |access-date=2025-09-04 |website=www.thepresidency.gov.za |language=en}}&lt;/ref&gt;
.  Abadlali abadumileko ebegade bambatha ijezi elimnyama negolide esikhathini esidlulileko bafaka hlangana abokapteni besiqhema lesitjhaba [[Neil Tovey|u-Neil Tovey]] no -Lucas Radebe kanye no -Patrick Ntsoelengoe, u-Gary Bailey, u-John &quot;Shoes&quot; Moshoeu, u-Shaun Bartlett, u- Steve Komphela, u-Siyabonga Nomvete, u- Doctor no-Khumalo.

Yisiqhema esisekelwa khulu [[Isewula Afrika|eSewula Afrika]]￼. I-Kaizer Chiefs beyinesisekelo esingaphezu kweengidi ezili-16 ekuthomeni kwekhulu leminyaka. Bathola isilinganiso sabantu abafika ekhaya esingu-16,144 ngesizini ka-2019-20, okuphezulu khulu kuligi. Isiqhema sidlala imidlalo eminengi yangekhaya e- FNB Stadium enabantu abama-94,797.&lt;ref&gt;{{Cite web |date=2025-09-02 |title=worldfootball.net |url=https://www.worldfootball.net/ |access-date=2025-09-04 |website=worldfootball.net |language=en}}&lt;/ref&gt;
NgoTjhirhweni 2025, i-Kaizer Chiefs yagidinga iminyaka ema-55.&lt;ref&gt;{{Cite web |title=Kaizer Chiefs Reacts To 'Identical' Black / Gold Barcelona Kit |url=https://www.footyheadlines.com/2020/07/twinned-by-design-nike-kaizer-chiefs-50.html |access-date=2025-09-04 |website=Footy Headlines |language=en}}&lt;/ref&gt;


Imithombo lwazi</text>
      <sha1>hzovmdy7owttulhkbbf8ocdamjq13wq</sha1>
    </revision>
  </page>
  <page>
    <title>DD Mabuza</title>
    <ns>0</ns>
    <id>909</id>
    <revision>
      <id>5436</id>
      <timestamp>2025-09-04T07:39:19Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <comment>Created by translating the opening section from the page &quot;[[:en:Special:Redirect/revision/1303322720|DD Mabuza]]&quot;</comment>
      <origin>5436</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1453" sha1="pntre2te12e2lraqop4vk50tvw802bq" xml:space="preserve">
U-David Dabede Mabuza wabelethwa mhlazi-25 kuRhoboyi wee-1960 e -Phola eduze ne-Hazyview endaweni eyaba [[Isifunda seMpumalanga|sifundazwe se-Mpumalanga]] .  Ababelethi bakhe bebabalimi.  Bekangowesithandathu ebantwaneni abali-12 - amantombazana abunane nabafana abane.  Wafunda e-Khumbula High School, nayo ese-Mpumalanga.  Wafumana idiploma yokufundisa, ekhethekileko yefundo yeembalo, e-Mgwenya College of Education ngo-1985; gade angunobhala we- Black Consciousness -aligned Azania Student Organization (AZASO) kusukela ngo-1984 ukuya ku-1985. &lt;ref name=&quot;:1&quot; /&gt; &lt;ref name=&quot;GovZA&quot; /&gt; Ngesikhathi afunda e -University of South Africa ukuthola i-Bachelor of Arts ku-psychology, ayifumana ngo-1989, wathoma ukusebenza njengotitjhere wesikolo. &lt;ref name=&quot;GovZA&quot; /&gt; ] &lt;ref name=&quot;:1&quot; /&gt;​ &lt;ref name=&quot;GovZA&quot; /&gt;

Waragela phambili nokuzibandakanya kwakhe kwezepolotiki: waba ngusihlalo we-National Education Union of South Africa kusukela ngo-1986 ukuya ku-1988, umgcinimafa we-Foundation for Education with Production kusukela ngo-1986 ukuya ku-1990, begodu waba mhlanganisi weKomidi yezeFundo yeNarha kusukela ngo-1987 ukuya ku-1988   U-Ferial Haffajee, u-Mathews Phosa waqasha u-Mabuza e- United Democratic Front ngo-1986.   Kusukela ngo-1988 ukuya ku-1991, esigabeni sokugcina sebandlululo, waba ngusihlalo we -South African Democratic Teachers Union, ihlangano enethonya ye-Congress of South African Traons Union . &lt;ref name=&quot;GovZA&quot; /&gt;

&lt;references /&gt;</text>
      <sha1>pntre2te12e2lraqop4vk50tvw802bq</sha1>
    </revision>
  </page>
  <page>
    <title>Bongiwe Msomi</title>
    <ns>0</ns>
    <id>911</id>
    <revision>
      <id>5451</id>
      <timestamp>2025-09-04T07:56:06Z</timestamp>
      <contributor>
        <username>Lerato Ruffy</username>
        <id>846</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1297625561|Bongiwe Msomi]]&quot;</comment>
      <origin>5451</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6316" sha1="mujhrdy4try6crjbjqiw4341nvfrbgs" xml:space="preserve">

'''U-Bongiwe Msomi''' (wabelethwa mhla amalanga ali-19 kuTjhirhweni 1988) bekangumdlali we-netball weentjhabatjhaba weSewula Afrika begodu ungumqeqetjhi we-netball. Hlangana nomnyaka ka-2011 ukuya ku-2023, u-Msomi wenze imidlalo eli-171 yeSewula Afrika. Ujamele iSewula Afrika emidlalweni ye-Netball World Cups yango-2011, 2015, 2019 kanye ne-2023 kanye naku -2014, 2018 kanye ne -2022 ye-Commonwealth Games . Bekalilunga lamaqembu weSewula Afrika aphumelele iindondo ku -2012 World University Netball Championship kanye ne -2012 Fast5 Netball World Series . Phakathi kuka-2016 ukuya ku-2023 waba ngukaputeni weSewula Afrika. Lokha nakathatha umhlalaphasi, bekangumdlali weentjhabatjhaba we-netball odlale khulu eSewula Afrika. U-Msomi gade alilunga lamaqembu amabili we-Netball Superleague athumbe iphaliswano le-Netball Superleague – ngo -2015 ne -Surrey Storm begodu ngo -2017 ne -Wasps Netball . Ngo-2022 waba ngukaputeni we-Gauteng Golden Fireballs lokha nabathumba isicoco se -Telkom Netball League . Kusukela ngo-2019, u-Msomi usebenze njengomqeqetjhi omkhulu we-netball e- University of Johannesburg .

== Ipilo yokuthoma, umndeni kanye nefundo ==
UMsomi wabelethwa begodu wakhulela elokitjhiini le- Hammarsdale eduze ne-Durban, e-KwaZulu-Natal . Ngowesihlanu ebantwaneni ababunane. Unina begade asebenza emafemini. Ngomnyaka ka-2008, uyise, umdosiphambili womphakathi, wahlongakala. Wafunda e-Chief Luthayi High School.       Ngomnyaka ka-2012, u-Msomi waphothula e -Durban University of Technology ngediploma yesitjhaba yokuPhathwa kwezeMidlalo. &lt;ref name=&quot;uj260819&quot; /&gt;    Udadwabo omncani ka-Msomi, u-Sinenhlanhla Msomi, bekadlala i-netball ku -Gauteng Golden Fireballs .  UMsomi wakhula akhuluma isiZulu begodu wafunda [[Ilimi lesiNgisi|isiNgisi]] ngemva kokuthatha i-netball begodu waba ngukaputeni wesiqhema. &lt;ref name=&quot;av220718&quot; /&gt; &lt;ref name=&quot;birmingham2022&quot; /&gt;

== Umsebenzi wokudlala ==

=== Umsebenzi wokuthoma ===
Ngo-2004, u-Msomi wathoma ukudlala i-netball, aneminyaka eli-16, ngesikhathi ase-Chief Luthayi High School. Bekabukela abangani bakhe bahlanganyela esigabeni sokubandula lokha nakamenywa bona ahlanganyele ukwenza amanani. Umqeqetjhi wambawa bonyana abubye azokudlala ngesigaba esilandelako. U-Msomi uthokoza u-S'thembiso G. Mncwabe, umrhelebhi wakhe wokuthoma webholo ye-netball ngokuthoma nokusekela umsebenzi wakhe we-netball. UMsomi ukhumbula ukuthi uMncwabe wasebenzisa imali yakhe ukuthenga amabholo, amakhoni kanye neenyathelo ukuze abentazana ebagade abaqeqetjha bakwazi ukudlala. Ngomnyaka ka-2005, uMsomi wakhethwa bona azokujamela i-eThekwini emphaliswaneni zangekhaya.    

=== Kingdom Stars ===
Phakathi komnyaka wee-2014 ne-2016, u-Msomi wadlalela i- Kingdom Stars ku- Brutal Fruit Netball Cup . Ngomnyaka ka-2014 u-Stars wathumba indawo yesibili ku -Division Two Shield begodu uMsomi wakhethwa njengomdlali wabadlali we-Tournament. Ngomnyaka ka-2015 waba ngukaputeni we-Stars njengombana athumba i-Shield begodu wakhethwa njengomvikeli omuhle khulu wephaliswano. Ngomnyaka wee-2016 waba ngukaputeni we-Stars ukuya endaweni yesihlanu, isikhundla sabo esihle khulu kuligi. Abalingani bakhe be-Stars bafaka hlangana u-Precious Mthembu .     Lokha nakadlalela i-Stars, u-Msomi wasebenza njengotitjhere nomqeqetjhi we-netball e-Northlands Primary School e -Durban North . &lt;ref name=&quot;citizen240615&quot; /&gt; 

=== Surrey Storm ===
Ngomnyaka wee- 2015, u-Msomi watlikitla i- Surrey Storm ye- Netball Superleague .   U-Tamsin Greenway, umqeqetjhi omkhulu we-Surrey Storm, wathoma ukubona u-Msomi edlala ku -2014 Commonwealth Games . Ngemva kwalokho wathintana naye nge -Facebook begodu wammema bona adlalele i-Storm.   &lt;ref name=&quot;storm120315&quot; /&gt; ​  Mhla amalanga ali-17 kuNtaka 2015, wenza ukuthoma kwakhe kokuthoma ekunqobeni kwe -Team Bath ngo-61-39 begodu wakhethwa njengomdlali ophuma phambili kibo boke.   Igalelo laka-Msomi lisize isiqhema se-Surrey Storm ngomnyaka wee-2015 bona siphumelele eemphaliswaneni. Emdlalweni wokugcina omkhulu bahlula i-Hertfordshire Mavericks ngo-56-39. 

Ngenyanga kaKhukhulamungu 2016, u-Msomi watlikitla i -Wasps Netball ye -Netball Superleague, wahlangana godu ne- Tamsin Greenway .   Ngemva kwalokho waba lilunga lesiqhema se-Wasps esathumba isicoco se -Netball Superleague yango-2017 begodu emdlalweni omkhulu wakhethwa njengomdlali womdlalo.  Ngemva kokuchitha isizini ka-2018 ne -Adelaide Thunderbirds, u-Msomi wabuyela ku-Wasps ngesizini ye-2019 Netball Superleague   begodu bekalilunga lesiqhema sabo esaqeda njengesesibili. 

Hlangana nomnyaka ka-2011 no-2023, u-Msomi wenze imidlalo eli-171 yeSewula Afrika . Phakathi kuka-2016 ukuya ku-2023 waba ngukaputeni weSewula Afrika. Lokha nakathatha umhlalaphasi, bekangumdlali weentjhabatjhaba we-netball odlale khulu eSewula Afrika.   ​     Wenza umdlalo wakhe wokuqala weSewula Afrika edlala ne -Jamaica ku- 2011 World Netball Championships .  Bekalilunga lamathimu weSewula Afrika aphumelele iindondo ku- 2012 World University Netball Championship    kanye ne -2012 Fast5 Netball World Series .   Ngomnyaka ka-2013 waba ngusekela-kakaputeni ka- Maryka Holtzhausen begodu waba ngukaputeni wesiqhema seSewula Afrika esathumba i -2013 Diamond Challenge . &lt;ref name=&quot;nsa190816&quot; /&gt;   Ngemva kwalokho wajamela iSewula Afrika emidlalweni ye-Commonwealth ka-2014 kanye neNdebe yePhasi ye-Netball ka-2015 .    Ngenyanga kaRhoboyi wee-2016, u-Msomi wamenyezelwa njengokaputeni weSewula Afrika we -2016 Netball Quad Series, athatha isikhundla se-Holtzhausen unomphela. &lt;ref name=&quot;nsa190816&quot; /&gt; Mhlana amalanga ama-3 kuNobayeni 2017, u-Msomi waba ngukaputeni weSewula Afrika ekunqobeni kwabo kokuthoma kwe-Netball Quad Series lokha nabahlula i-England ngo-54-51.  ] ​ &lt;ref name=&quot;nsa210520&quot; /&gt; 

Ngaphambi kwemidlalo ye-Commonwealth yango-2022, i-Netball South Africa yanikela abadlali iinomboro zobungcweti kokuthoma. UMsomi ubengomunye wabadlali abama-24 abathola isivumelwano.   Emdlalweni we -Commonwealth Games Parade of Nations wango-2022, u-Msomi wakhethwa njengomunye wabathwali beflegi yeSewula Afrika .   Ngenyanga kaRhoboyi ngomyaka ka 2022, u-Msomi waba mdlali weentjhabatjhaba we-netball odlale khulu eSewula Afrika lokha nakadlalako we-151 ngesikhathi sephaliswano we-Netball World Cup ka-2023 .  Ngo -2023, u-Msomi wenza ukubonakala kwakhe kwesine eNdebeni yePhasi ye-Netball .</text>
      <sha1>mujhrdy4try6crjbjqiw4341nvfrbgs</sha1>
    </revision>
    <revision>
      <id>5460</id>
      <parentid>5451</parentid>
      <timestamp>2025-09-04T08:11:05Z</timestamp>
      <contributor>
        <username>Lerato Ruffy</username>
        <id>846</id>
      </contributor>
      <minor />
      <comment>edited</comment>
      <origin>5460</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6137" sha1="abww4mv7pg2fezr76mg9ystua55od6k" xml:space="preserve">

'''U-Bongiwe Msomi''' wabelethwa mhla amalanga ali-19 kuTjhirhweni ngomnyaka we-1988 bekangumdlali we-netball weentjhabatjhaba zeSewula Afrika begodu angumqeqetjhi we-netball. Hlangana nomnyaka ka-2011 ukuya ku-2023, u-Msomi wenze imidlalo eli-171 yeSewula Afrika. Ujamele iSewula Afrika emidlalweni ye-Netball World Cups yango-2011, 2015, 2019 kanye ne-2023 kanye naku -2014, 2018 kanye ne -2022 ye-Commonwealth Games. Bekalilunga lamaqembu weSewula Afrika aphumelele iindondo ku -2012 World University Netball Championship kanye ne -2012 Fast5 Netball World Series. Phakathi kuka-2016 ukuya ku-2023 waba ngukaputeni weSewula Afrika. Lokha nakathatha umhlalaphasi bekangumdlali weentjhabatjhaba we-netball odlale khulu eSewula Afrika. U-Msomi gade alilunga lamaqembu amabili we-Netball Superleague athumbe iphaliswano le-Netball Superleague ne Surrey Storm ngo 2015 begodu ngo 2017 ne Wasps Netball .Ngo-2022 waba ngukaputeni we-Gauteng Golden Fireballs lokha nabathumba isicoco se -Telkom Netball League. Kusukela ngo-2019 u-Msomi wasebenza njengomqeqetjhi omkhulu we-netball e- University of Johannesburg.

== Ipilo yokuthoma, umndeni kanye nefundo ==
UMsomi wabelethwa begodu wakhulela elokitjhiini le Hammarsdale eduze ne-Durban, e-KwaZulu-Natal . Ngowesihlanu ebantwaneni ababunane. Unina begade asebenza emafemini. Ngomnyaka ka-2008 uyise, umdosiphambili womphakathi wahlongakala. Wafunda e-Chief Luthayi High School. Ngomnyaka ka-2012, uMsomi wathola iziqu e -Durban University of Technology zediploma yesitjhaba yokuPhathwa kwezeMidlalo. Udadwabo omncani ka-Msomi, u-Sinenhlanhla Msomi, bekadlala i-netball ku -Gauteng Golden Fireballs. UMsomi wakhula akhuluma isiZulu begodu wafunda [[Ilimi lesiNgisi|isiNgisi]] ngemva kokuthatha i-netball begodu waba ngukaputeni wesiqhema. &lt;ref name=&quot;av220718&quot; /&gt; &lt;ref name=&quot;birmingham2022&quot; /&gt;

== Umsebenzi wokudlala ==

=== Umsebenzi wokuthoma ===
Ngo-2004, u-Msomi wathoma ukudlala i-netball, aneminyaka eli-16, ngesikhathi ase-Chief Luthayi High School. Bekabukela abangani bakhe bahlanganyela esigabeni sokubandula lokha nakamenywa bona ahlanganyele ukwenza amanani. Umqeqetjhi wambawa bonyana abubye azokudlala ngesigaba esilandelako. U-Msomi uthokoza u-S'thembiso G. Mncwabe, umrhelebhi wakhe wokuthoma webholo ye-netball ngokuthoma nokusekela umsebenzi wakhe we-netball. UMsomi ukhumbula ukuthi uMncwabe wasebenzisa imali yakhe ukuthenga amabholo, amakhoni kanye neenyathelo ukuze abentazana ebagade abaqeqetjha bakwazi ukudlala. Ngomnyaka ka-2005, uMsomi wakhethwa bona azokujamela i-eThekwini emphaliswaneni zangekhaya.    

=== Kingdom Stars ===
Phakathi komnyaka wee-2014 ne-2016, u-Msomi wadlalela i- Kingdom Stars ku- Brutal Fruit Netball Cup . Ngomnyaka ka-2014 u-Stars wathumba indawo yesibili ku -Division Two Shield begodu uMsomi wakhethwa njengomdlali wabadlali we-Tournament. Ngomnyaka ka-2015 waba ngukaputeni we-Stars njengombana athumba i-Shield begodu wakhethwa njengomvikeli omuhle khulu wephaliswano. Ngomnyaka wee-2016 waba ngukaputeni we-Stars ukuya endaweni yesihlanu, isikhundla sabo esihle khulu kuligi. Abalingani bakhe be-Stars bafaka hlangana u-Precious Mthembu .     Lokha nakadlalela i-Stars, u-Msomi wasebenza njengotitjhere nomqeqetjhi we-netball e-Northlands Primary School e -Durban North . 

=== Surrey Storm ===
Ngomnyaka wee- 2015, u-Msomi watlikitla i- Surrey Storm ye- Netball Superleague .   U-Tamsin Greenway, umqeqetjhi omkhulu we-Surrey Storm, wathoma ukubona u-Msomi edlala ku -2014 Commonwealth Games . Ngemva kwalokho wathintana naye nge -Facebook begodu wammema bona adlalele i-Storm.  Mhla amalanga ali-17 kuNtaka 2015, wenza ukuthoma kwakhe kokuthoma ekunqobeni kwe -Team Bath ngo-61-39 begodu wakhethwa njengomdlali ophuma phambili kibo boke.   Igalelo laka-Msomi lisize isiqhema se-Surrey Storm ngomnyaka wee-2015 bona siphumelele eemphaliswaneni. Emdlalweni wokugcina omkhulu bahlula i-Hertfordshire Mavericks ngo-56-39. 

Ngenyanga kaKhukhulamungu 2016, u-Msomi watlikitla i -Wasps Netball ye -Netball Superleague, wahlangana godu ne- Tamsin Greenway .   Ngemva kwalokho waba lilunga lesiqhema se-Wasps esathumba isicoco se -Netball Superleague yango-2017 begodu emdlalweni omkhulu wakhethwa njengomdlali womdlalo.  Ngemva kokuchitha isizini ka-2018 ne -Adelaide Thunderbirds, u-Msomi wabuyela ku-Wasps ngesizini ye-2019 Netball Superleague   begodu bekalilunga lesiqhema sabo esaqeda njengesesibili. 

Hlangana nomnyaka ka-2011 no-2023, u-Msomi wenze imidlalo eli-171 yeSewula Afrika . Phakathi kuka-2016 ukuya ku-2023 waba ngukaputeni weSewula Afrika. Lokha nakathatha umhlalaphasi, bekangumdlali weentjhabatjhaba we-netball odlale khulu eSewula Afrika.   ​     Wenza umdlalo wakhe wokuqala weSewula Afrika edlala ne -Jamaica ku- 2011 World Netball Championships .  Bekalilunga lamathimu weSewula Afrika aphumelele iindondo ku- 2012 World University Netball Championship    kanye ne -2012 Fast5 Netball World Series .   Ngomnyaka ka-2013 waba ngusekela-kakaputeni ka- Maryka Holtzhausen begodu waba ngukaputeni wesiqhema seSewula Afrika esathumba i -2013 Diamond Challenge . Ngemva kwalokho wajamela iSewula Afrika emidlalweni ye-Commonwealth ka-2014 kanye neNdebe yePhasi ye-Netball ka-2015 .    Ngenyanga kaRhoboyi wee-2016, u-Msomi wamenyezelwa njengokaputeni weSewula Afrika we -2016 Netball Quad Series, athatha isikhundla se-Holtzhausen unomphela. Mhlana amalanga ama-3 kuNobayeni 2017, u-Msomi waba ngukaputeni weSewula Afrika ekunqobeni kwabo kokuthoma kwe-Netball Quad Series lokha nabahlula i-England ngo-54-51.  ] ​ 

Ngaphambi kwemidlalo ye-Commonwealth yango-2022, i-Netball South Africa yanikela abadlali iinomboro zobungcweti kokuthoma. UMsomi ubengomunye wabadlali abama-24 abathola isivumelwano.   Emdlalweni we -Commonwealth Games Parade of Nations wango-2022, u-Msomi wakhethwa njengomunye wabathwali beflegi yeSewula Afrika .   Ngenyanga kaRhoboyi ngomyaka ka 2022, u-Msomi waba mdlali weentjhabatjhaba we-netball odlale khulu eSewula Afrika lokha nakadlalako we-151 ngesikhathi sephaliswano we-Netball World Cup ka-2023 .  Ngo -2023, u-Msomi wenza ukubonakala kwakhe kwesine eNdebeni yePhasi ye-Netball .</text>
      <sha1>abww4mv7pg2fezr76mg9ystua55od6k</sha1>
    </revision>
    <revision>
      <id>5549</id>
      <parentid>5460</parentid>
      <timestamp>2025-09-04T09:36:29Z</timestamp>
      <contributor>
        <username>Lerato Ruffy</username>
        <id>846</id>
      </contributor>
      <comment>I edited the whole article, changed it from English to IsiNdebele</comment>
      <origin>5549</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7755" sha1="cti2imuc57dgwx8zi7k3vwy33y1wu7b" xml:space="preserve">

'''U-Bongiwe Msomi''' wabelethwa mhla amalanga ali-19 kuTjhirhweni ngomnyaka we-1988 bekangumdlali we-netball weentjhabatjhaba zeSewula Afrika begodu angumbanduli webholo lezandla. Hlangana nomnyaka ka-2011 ukuya ku-2023, u-Msomi wenze imidlalo eli-171 yeSewula Afrika. Ujamele iSewula Afrika emidlalweni ye-Netball World Cups yango-2011, 2015, 2019 kanye ne-2023 kanye naku -2014, 2018 kanye ne -2022 ye-Commonwealth Games. Bekalilunga lamaqembu weSewula Afrika aphumelele iindondo ku -2012 World University Netball Championship kanye ne -2012 Fast5 Netball World Series. Phakathi kuka-2016 ukuya ku-2023 waba ngukaputeni weSewula Afrika. Lokha nakathatha umhlalaphasi bekangumdlali weentjhabatjhaba we-netball odlale khulu eSewula Afrika. U-Msomi gade alilunga lamaqembu amabili we-Netball Superleague athumbe iphaliswano le-Netball Superleague ne Surrey Storm ngo 2015 begodu ngo 2017 ne Wasps Netball .Ngo-2022 waba ngukaputeni we-Gauteng Golden Fireballs lokha nabathumba isicoco se -Telkom Netball League. Kusukela ngo-2019 u-Msomi wasebenza njengomqeqetjhi omkhulu we-netball e- University of Johannesburg.

== Ipilo yokuthoma, umndeni kanye nefundo ==
UMsomi wabelethwa begodu wakhulela elokitjhiini le Hammarsdale eduze ne-Durban, e-KwaZulu-Natal. Ngowesihlanu ebantwaneni ababunane. Unina begade asebenza emafemini. Ngomnyaka ka-2008 uyise, umdosiphambili womphakathi wahlongakala. Wafunda e-Chief Luthayi High School. Ngomnyaka ka-2012, uMsomi wathola iziqu e -Durban University of Technology zediploma yesitjhaba yokuPhathwa kwezeMidlalo. Udadwabo omncani ka-Msomi, u-Sinenhlanhla Msomi bekadlala ibholo lesandla ku Gauteng Golden Fireballs. UMsomi wakhula akhuluma isiZulu begodu wafunda [[Ilimi lesiNgisi|isiKhuwa]] ngemva kokudlala ibholo lesandla waba ngukaputeni wesiqhema. 

== Umsebenzi wokudlala ==

=== Umsebenzi wokuthoma ===
Ngo-2004, uMsomi wathoma ukudlala ibholo yezandla aneminyaka eli-16 ngesikhathi asesikolweni samabanga aphezulu i-Chief Luthayi. Bekabukela abangani bakhe bahlanganyela lokha nabazilulako nakamenywa bona ahlanganyele ukwenza amanani. Umqeqetjhi wambawa bonyana abuye azokudlala ngesigaba esilandelako. UMsomi uthokoza uSthembiso G. Mncwabe umrhelebhi wakhe wokuthoma webholo yezandla ngokuthoma nokusekela umsebenzi wakhe webholo. UMsomi ukhumbula ukuthi uMncwabe wasebenzisa imali yakhe ukuthenga amabholo, amakhoni kanye neenyathelo ukuze abentazana ebagade abaqeqetjha bakwazi ukudlala. Ngomnyaka ka-2005 uMsomi wakhethwa bona azokujamela i-eThekwini eemphaliswaneni zangekhaya.    

=== Kingdom Stars ===
Phakathi komnyaka wee-2014 ne-2016 uMsomi wadlalela i Kingdom Stars ku Brutal Fruit Netball Cup. Ngomnyaka ka-2014 uStars wathumba indawo yesibili ku Division Two Shield begodu uMsomi wakhethwa njengomdlali odlale kuhle khulu ukudlula boke abadlali. Ngomnyaka ka-2015 waba ngukaputeni we-Stars njengombana athumba i-Shield begodu wakhethwa njengomvikeli odlale kuhle khulu wephaliswano. Ngomnyaka wee-2016 waba ngukaputeni we-Stars ukuya endaweni yesihlanu isikhundla sabo esihle khulu kuligi. Abalingani bakhe be-Stars bafaka hlangana uPrecious Mthembu. Lokha nakadlalela i-Stars uMsomi wasebenza njengotitjhere nomqeqetjhi webholo lezandla e-Northlands Primary School eDurban North. 

=== Surrey Storm ===
Ngomnyaka wee- 2015 uMsomi watlikitla ne Surrey Storm ye Netball Superleague . UTamsin Greenway ongumbanduli omkhulu we-Surrey Storm wathoma ukubona uMsomi adlala kumdlalo we Commonwealth ngomnyaka ka 2014. Ngemva kwalokho wathintana naye nge Facebook begodu wammema bona adlalele i-Storm. Mhla amalanga ali-17 kuNtaka 2015 wenza ukuthoma kwakhe kokuthoma ekunqobeni kwe Team Bath ngo-61-39 begodu wakhethwa njengomdlali ophuma phambili kibo boke. Igalelo lakaMsomi lisize isiqhema se Surrey Storm ngomnyaka wee-2015 bona siphumelele eemphaliswaneni. Emdlalweni wokugcina omkhulu bahlula i-Hertfordshire Mavericks ngo-56-39. 

=== '''WASPS''' ===
Ngenyanga kaKhukhulamungu 2016, uMsomi watlikitla i Wasps Netball ye -Netball Superleague wahlangana godu no Tamsin Greenway . Ngemva kwalokho waba lilunga lesiqhema se-Wasps esathumba ku-Netball Superleague yango-2017 begodu emdlalweni omkhulu wakhethwa njengomdlali womdlalo.  Ngemva kokuphetha isizini ka-2018 ne -Adelaide Thunderbirds uMsomi wabuyela ku Wasps ngesizini ye-2019 Netball Superleague  begodu bekalilunga lesiqhema sabo esaqeda njengesesibili. 

=== '''I-Adelaide Thunderbirds''' ===
U-Msomi wajoyina [[Adelaide Thunderbirds|i-Adelaide Thunderbirds]] [[2018 Suncorp Super Netball season|ngesikhathi se-2018 Suncorp Super Netball]]. Ngemva kwalokho wenza ukuvela kwe-11 kwabadala kodwana bekungasi yisizini ebaphumelela kiyo. I-Thunderbirds iqede isizini ka-2018 ingathumbi. Lokha nakadlalela i-Thunderbirds waphinda waqeda isikhathi sokubandula e [[Contax Netball Club|-Contax Netball Club]].  

=== Gauteng Golden Fireballs ===
Ngomnyaka wee-2020 UMsomi wabalilunga lesiqhema se [[Gauteng Golden Fireballs]] esaqeda endaweni yesithathu ku [[Telkom Netball League]]. &lt;ref name=&quot;nsa261020&quot;&gt;{{cite web|url=https://netball-sa.co.za/aloes-win-division-b-and-fireballs-claim-bronze-medal-in-division-a/|title=Aloes Win Division B And Fireballs Claim Bronze Medal In Division A|publisher=netball-sa.co.za|archive-url=https://web.archive.org/web/20201101015806/https://netball-sa.co.za/aloes-win-division-b-and-fireballs-claim-bronze-medal-in-division-a/|archive-date=1 November 2020|date=26 October 2020|access-date=5 September 2024}}&lt;/ref&gt; Abalingani bakhe bangomnyaka ka 2020 eFireballs bafaka hlangana udadwabo omncani uSinenhlanhla Msomi. &lt;ref name=&quot;gsport071020&quot;&gt;{{cite web|url=https://gsport.co.za/sne-msomi-living-her-own-netball-dream/|title=Sne Msomi Living Her Own Netball Dream|publisher=gsport.co.za|date=7 October 2020|access-date=27 November 2024}}&lt;/ref&gt; Ngo-2022,uMsomi waba ngukaputeni wesiqhema se Fireballs lokha nabathumba isicoco se-TNL. Emdlalweni wokugcina bahlula [[Gauteng Jaguars|i-Gauteng Jaguars]] ngo-35-32.

=== ISewula Afrika ===
Hlangana nomnyaka ka-2011 no 2023, uMsomi wenze imidlalo eli-171 yeSewula Afrika. Phakathi kuka-2016 ukuya ku-2023 waba ngukaputeni weSewula Afrika. Lokha nakathatha umhlalaphasi bekangumdlali weentjhabatjhaba webholo lezandla odlale kuhle khulu eSewula Afrika. Wenza umdlalo wakhe wokuthoma weSewula Afrika edlala ne Jamaica ku 2011 World Netball Championships.  Bekalilunga lamaqembu weSewula Afrika aphumelele iindondo ku- 2012 World University Netball Championship kanye ne -2012 Fast5 Netball World Series. Ngomnyaka ka 2013 waba ngusekela kakaputeni uMaryka Holtzhausen begodu waba ngukaputeni wesiqhema seSewula Afrika esathumba i 2013 Diamond Challenge. Ngemva kwalokho wajamela iSewula Afrika emidlalweni ye-Commonwealth ka-2014 kanye neNdebe yePhasi ye Netball ka-2015. Ngenyanga kaRhoboyi wee-2016, uMsomi wamenyezelwa njengokaputeni weSewula Afrika we -2016 Netball Quad Series athatha isikhundla se-Holtzhausen unomphela. Mhla amalanga ama-3 kuNobayeni 2017 waba ngukaputeni weSewula Afrika ekunqobeni kwabo kokuthoma kwe Netball Quad Series lokha nabahlula i-England ngo-54-51. ​ 

Ngaphambi kwemidlalo ye-Commonwealth yango-2022, i Netball South Africa yanikela abadlali iinomboro zabadlala ababoqhephetjhe kokuthoma. UMsomi ubengomunye wabadlali abama 24 abathola isivumelwano. Emdlalweni we Commonwealth Games Parade of Nations wangomnyaka wee-2022 uMsomi wakhethwa njengomunye wabathwali beflegi yeSewula Afrika.   Ngenyanga kaRhoboyi ngomyaka ka 2022 waba mdlali weentjhabatjhaba webholo lezandla odlale khulu eSewula Afrika lokha nakadlalako umdlalo we-151 ngesikhathi sephaliswano se Netball World Cup ngomnyaka wee-2023 . Ngo 2023, uMsomi wenza ukubonakala kwakhe kwesine eNdebeni yePhasi yebholo lezandla.

=== IMITHOMBO LWAZO ===
&lt;references /&gt;</text>
      <sha1>cti2imuc57dgwx8zi7k3vwy33y1wu7b</sha1>
    </revision>
    <revision>
      <id>5630</id>
      <parentid>5549</parentid>
      <timestamp>2025-09-04T10:44:32Z</timestamp>
      <contributor>
        <username>Lerato Ruffy</username>
        <id>846</id>
      </contributor>
      <comment>I added references</comment>
      <origin>5630</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8641" sha1="1v20szmiioosmhnocos5v2budcgy5fp" xml:space="preserve">
U '''Bongiwe Msomi''' wabelethwa mhla amalanga ali-19 kuTjhirhweni ngomnyaka we-1988 bekangumdlali we-netball weentjhabatjhaba zeSewula Afrika begodu angumbanduli webholo lezandla. Hlangana nomnyaka ka-2011 ukuya ku-2023, u-Msomi wenze imidlalo eli-171 yeSewula Afrika. Ujamele iSewula Afrika emidlalweni ye-Netball World Cups yango-2011, 2015, 2019 kanye ne-2023 kanye naku -2014, 2018 kanye ne -2022 ye-Commonwealth Games. Bekalilunga lamaqembu weSewula Afrika aphumelele iindondo ku -2012 World University Netball Championship kanye ne -2012 Fast5 Netball World Series. Phakathi kuka-2016 ukuya ku-2023 waba ngukaputeni weSewula Afrika. Lokha nakathatha umhlalaphasi bekangumdlali weentjhabatjhaba we-netball odlale khulu eSewula Afrika. U-Msomi gade alilunga lamaqembu amabili we-Netball Superleague athumbe iphaliswano le-Netball Superleague ne Surrey Storm ngo 2015 begodu ngo 2017 ne Wasps Netball. Ngo-2022 waba ngukaputeni we-Gauteng Golden Fireballs lokha nabathumba isicoco se -Telkom Netball League. Kusukela ngo-2019 u-Msomi wasebenza njengomqeqetjhi omkhulu we-netball e- University of Johannesburg.

== Ipilo yokuthoma, umndeni kanye nefundo ==
UMsomi wabelethwa begodu wakhulela elokitjhiini le Hammarsdale eduze ne-Durban, e-KwaZulu-Natal. Ngowesihlanu ebantwaneni ababunane. Unina begade asebenza emafemini. Ngomnyaka ka-2008 uyise, umdosiphambili womphakathi wahlongakala. Wafunda e-Chief Luthayi High School. Ngomnyaka ka-2012, uMsomi wathola iziqu e -Durban University of Technology zediploma yesitjhaba yokuPhathwa kwezeMidlalo. Udadwabo omncani ka-Msomi, u-Sinenhlanhla Msomi bekadlala ibholo lesandla ku Gauteng Golden Fireballs. UMsomi wakhula akhuluma isiZulu begodu wafunda isiKhuwa ngemva kokudlala ibholo lesandla waba ngukaputeni wesiqhema. 

== Umsebenzi wokudlala ==

=== Umsebenzi wokuthoma ===
Ngo-2004, uMsomi wathoma ukudlala ibholo yezandla aneminyaka eli-16 ngesikhathi asesikolweni samabanga aphezulu i-Chief Luthayi. Bekabukela abangani bakhe bahlanganyela lokha nabazilulako nakamenywa bona ahlanganyele ukwenza amanani. Umqeqetjhi wambawa bonyana abuye azokudlala ngesigaba esilandelako. UMsomi uthokoza uSthembiso G. Mncwabe umrhelebhi wakhe wokuthoma webholo yezandla ngokuthoma nokusekela umsebenzi wakhe webholo.&lt;ref&gt;[https://www.birmingham2022.com/queens-baton-relay/batonbearer-stories/bongiwe-msomi Bongiwe Msomi]&lt;/ref&gt; UMsomi ukhumbula ukuthi uMncwabe wasebenzisa imali yakhe ukuthenga amabholo, amakhoni kanye neenyathelo ukuze abentazana ebagade abaqeqetjha bakwazi ukudlala. Ngomnyaka ka-2005 uMsomi wakhethwa bona azokujamela i-eThekwini eemphaliswaneni zangekhaya.    

=== Kingdom Stars ===
Phakathi komnyaka wee-2014 ne-2016 uMsomi wadlalela i Kingdom Stars ku Brutal Fruit Netball Cup. Ngomnyaka ka-2014 uStars wathumba indawo yesibili ku Division Two Shield begodu uMsomi wakhethwa njengomdlali odlale kuhle khulu ukudlula boke abadlali. &lt;ref&gt;[https://www.teamsa.co.za/burger-injury-blow-for-proteas-ahead-of-wales-series/netball-2016-brutal-fruit-netball-premier-league-western-cape-southern-stings-v-kwazulu-natal-kingdom-stars-olive-convention-centre-durban/ Netball - 2016 Brutal Fruit Netball Premier League - Western Cape Southern Stings v KwaZulu Natal Kingdom Stars - Olive Convention Centre - Durban | TeamSA]&lt;/ref&gt;Ngomnyaka ka-2015 waba ngukaputeni we-Stars njengombana athumba i-Shield begodu wakhethwa njengomvikeli odlale kuhle khulu wephaliswano. Ngomnyaka wee-2016 waba ngukaputeni we-Stars ukuya endaweni yesihlanu isikhundla sabo esihle khulu kuligi. Abalingani bakhe be-Stars bafaka hlangana uPrecious Mthembu. Lokha nakadlalela i-Stars uMsomi wasebenza njengotitjhere nomqeqetjhi webholo lezandla e-Northlands Primary School eDurban North. 

=== Surrey Storm ===
Ngomnyaka wee- 2015 uMsomi watlikitla ne Surrey Storm ye Netball Superleague . UTamsin Greenway ongumbanduli omkhulu we-Surrey Storm wathoma ukubona uMsomi adlala kumdlalo we Commonwealth ngomnyaka ka 2014. Ngemva kwalokho wathintana naye nge Facebook begodu wammema bona adlalele i-Storm.&lt;ref&gt;[https://www.bbc.com/sport/netball/47610448 Bongi Msomi: South Africa captain on how Facebook message changed her life - BBC Sport]&lt;/ref&gt; Mhla amalanga ali-17 kuNtaka 2015 wenza ukuthoma kwakhe kokuthoma ekunqobeni kwe Team Bath ngo-61-39 begodu wakhethwa njengomdlali ophuma phambili kibo boke. Igalelo lakaMsomi lisize isiqhema se Surrey Storm ngomnyaka wee-2015 bona siphumelele eemphaliswaneni. Emdlalweni wokugcina omkhulu bahlula i-Hertfordshire Mavericks ngo-56-39. 

=== WASPS ===
Ngenyanga kaKhukhulamungu 2016, uMsomi watlikitla i Wasps Netball ye -Netball Superleague wahlangana godu no Tamsin Greenway. Ngemva kwalokho waba lilunga lesiqhema se-Wasps esathumba ku Netball Superleague yango 2017 begodu emdlalweni omkhulu wakhethwa njengomdlali womdlalo.  Ngemva kokuphetha isizini ka-2018 ne Adelaide Thunderbirds uMsomi wabuyela ku Wasps ngesizini ye-2019 Netball Superleague  begodu bekalilunga lesiqhema sabo esaqeda njengesesibili. 

=== I-Adelaide Thunderbirds ===
U-Msomi wajoyina i-Adelaide Thunderbirds ngesikhathi se-2018 Suncorp Super Netball. Ngemva kwalokho wenza ukuvela kwe-11 kwabadala kodwana bekungasi yisizini ebaphumelela kiyo. I-Thunderbirds iqede isizini ka-2018 ingathumbi. Lokha nakadlalela i-Thunderbirds waphinda waqeda isikhathi sokubandula e Contax Netball Club.

=== Gauteng Golden Fireballs ===
Ngomnyaka wee-2020 UMsomi wabalilunga lesiqhema se Gauteng Golden Fireballs esaqeda endaweni yesithathu ku Telkom Netball League.  Abalingani bakhe bangomnyaka ka 2020 eFireballs bafaka hlangana udadwabo omncani uSinenhlanhla Msomi. Ngo-2022,uMsomi waba ngukaputeni wesiqhema se Fireballs lokha nabathumba isicoco se-TNL. Emdlalweni wokugcina bahlula i-Gauteng Jaguars ngo-35-32.

=== ISewula Afrika ===
Hlangana nomnyaka ka-2011 no 2023, uMsomi wenze imidlalo eli-171 yeSewula Afrika. Phakathi kuka-2016 ukuya ku-2023 waba ngukaputeni weSewula Afrika. Lokha nakathatha umhlalaphasi bekangumdlali weentjhabatjhaba webholo lezandla odlale kuhle khulu eSewula Afrika. Wenza umdlalo wakhe wokuthoma weSewula Afrika edlala ne Jamaica ku 2011 World Netball Championships.  Bekalilunga lamaqembu weSewula Afrika aphumelele iindondo ku- 2012 World University Netball Championship kanye ne -2012 Fast5 Netball World Series. Ngomnyaka ka 2013 waba ngusekela kakaputeni uMaryka Holtzhausen begodu waba ngukaputeni wesiqhema seSewula Afrika esathumba i 2013 Diamond Challenge.&lt;ref&gt;[https://web.archive.org/web/20220706013359/https://netball-sa.co.za/8892-2/ South African Netball sides named ahead of Diamond Challenge - Netball South Africa]&lt;/ref&gt; Ngemva kwalokho wajamela iSewula Afrika emidlalweni ye-Commonwealth ka-2014 kanye neNdebe yePhasi ye Netball ka-2015. Ngenyanga kaRhoboyi wee-2016, uMsomi wamenyezelwa njengokaputeni weSewula Afrika we -2016 Netball Quad Series athatha isikhundla se-Holtzhausen unomphela. Mhla amalanga ama-3 kuNobayeni 2017 waba ngukaputeni weSewula Afrika ekunqobeni kwabo kokuthoma kwe Netball Quad Series lokha nabahlula i-England ngo-54-51.&lt;ref&gt;[https://gsport.co.za/gauteng-fireballs-look-to-defend-their-telkom-netball-league-title/ Gauteng Fireballs Look to Defend their Telkom Netball League Title - gsport4girls]&lt;/ref&gt; ​ 

Ngaphambi kwemidlalo ye-Commonwealth yango-2022, i Netball South Africa yanikela abadlali iinomboro zabadlala ababoqhephetjhe kokuthoma. UMsomi ubengomunye wabadlali abama 24 abathola isivumelwano. Emdlalweni we Commonwealth Games Parade of Nations wangomnyaka wee-2022.&lt;ref&gt;[https://web.archive.org/web/20200112170328/http://www.todor66.com/others/Netball/Commonwealth/Women_2018.html Women Netball Commonwealth Games Golden Goast, Australia 2018 - 05-15.04 - Winner England (1st)]&lt;/ref&gt;uMsomi wakhethwa njengomunye wabathwali beflegi yeSewula Afrika.   Ngenyanga kaRhoboyi ngomyaka ka 2022 waba mdlali weentjhabatjhaba webholo lezandla odlale khulu eSewula Afrika lokha nakadlalako umdlalo we-151 ngesikhathi sephaliswano se Netball World Cup ngomnyaka wee-2023. Ngo 2023, uMsomi wenza ukubonakala kwakhe kwesine eNdebeni yePhasi yebholo lezandla.

=== Umsebenzi wokubandula ===

=== Ibholo yezandla e-UJ ===
Ngenyanga kaRhoboyi ngomnyaka wee-2019 uMsomi wakhethwa njengombanduli omkhulu we University of Johannesburg Netball Club.Ngo 2023  wadosela i-UJ Netball emdlalweni wabo wokuthoma we-Varsity Netball. Kodwana baqeda njengabalandeli ngemva kokuhlulwa yi UP Tuks ngo-63-61 emdlalweni wokugcina. Ngo-2024, u-Msomi wahola i-UJ Netball ukuya kuma-final ngomnyaka wesibili ngokulandelana. Kodwana, baphinda baqeda njengababili, kulokhu bahlulwa 58-55 ku -UFS Kovsies .

=== IMITHOMBO LWAZO ===
&lt;references /&gt;</text>
      <sha1>1v20szmiioosmhnocos5v2budcgy5fp</sha1>
    </revision>
    <revision>
      <id>5690</id>
      <parentid>5630</parentid>
      <timestamp>2025-09-04T11:39:53Z</timestamp>
      <contributor>
        <username>Lerato Ruffy</username>
        <id>846</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1297625561|Bongiwe Msomi]]&quot;</comment>
      <origin>5690</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9627" sha1="jt60h9o2a7snn2fxpsy4bkuh86s918j" xml:space="preserve">

U '''Bongiwe Msomi''' wabelethwa mhla amalanga ali-19 kuTjhirhweni ngomnyaka we-1988 bekangumdlali we-netball weentjhabatjhaba zeSewula Afrika begodu angumbanduli webholo lezandla. Hlangana nomnyaka ka-2011 ukuya ku-2023, u-Msomi wenze imidlalo eli-171 yeSewula Afrika. Ujamele iSewula Afrika emidlalweni ye-Netball World Cups yango-2011, 2015, 2019 kanye ne-2023 kanye naku -2014, 2018 kanye ne -2022 ye-Commonwealth Games. Bekalilunga lamaqembu weSewula Afrika aphumelele iindondo ku -2012 World University Netball Championship kanye ne -2012 Fast5 Netball World Series. Phakathi kuka-2016 ukuya ku-2023 waba ngukaputeni weSewula Afrika. Lokha nakathatha umhlalaphasi bekangumdlali weentjhabatjhaba we-netball odlale khulu eSewula Afrika. U-Msomi gade alilunga lamaqembu amabili we-Netball Superleague athumbe iphaliswano le-Netball Superleague ne Surrey Storm ngo 2015 begodu ngo 2017 ne Wasps Netball. Ngo-2022 waba ngukaputeni we-Gauteng Golden Fireballs lokha nabathumba isicoco se -Telkom Netball League. Kusukela ngo-2019 u-Msomi wasebenza njengomqeqetjhi omkhulu we-netball e- University of Johannesburg.

UMsomi wabelethwa begodu wakhulela elokitjhiini le Hammarsdale eduze ne-Durban, e-KwaZulu-Natal. Ngowesihlanu ebantwaneni ababunane. Unina begade asebenza emafemini. Ngomnyaka ka-2008 uyise, umdosiphambili womphakathi wahlongakala. Wafunda e-Chief Luthayi High School. Ngomnyaka ka-2012, uMsomi wathola iziqu e -Durban University of Technology zediploma yesitjhaba yokuPhathwa kwezeMidlalo. Udadwabo omncani ka-Msomi, u-Sinenhlanhla Msomi bekadlala ibholo lesandla ku Gauteng Golden Fireballs. UMsomi wakhula akhuluma isiZulu begodu wafunda isiKhuwa ngemva kokudlala ibholo lesandla waba ngukaputeni wesiqhema

== Umsebenzi wokudlala ==

=== Umsebenzi wokuthoma ===
Ngo-2004, uMsomi wathoma ukudlala ibholo yezandla aneminyaka eli-16 ngesikhathi asesikolweni samabanga aphezulu i-Chief Luthayi. Bekabukela abangani bakhe bahlanganyela lokha nabazilulako nakamenywa bona ahlanganyele ukwenza amanani. Umqeqetjhi wambawa bonyana abuye azokudlala ngesigaba esilandelako. UMsomi uthokoza uSthembiso G. Mncwabe umrhelebhi wakhe wokuthoma webholo yezandla ngokuthoma nokusekela umsebenzi wakhe webholo. UMsomi ukhumbula ukuthi uMncwabe wasebenzisa imali yakhe ukuthenga amabholo, amakhoni kanye neenyathelo ukuze abentazana ebagade abaqeqetjha bakwazi ukudlala. Ngomnyaka ka-2005 uMsomi wakhethwa bona azokujamela i-eThekwini eemphaliswaneni zangekhaya.

=== Kingdom Stars ===
Phakathi komnyaka wee-2014 ne-2016 uMsomi wadlalela i Kingdom Stars ku Brutal Fruit Netball Cup. Ngomnyaka ka-2014 uStars wathumba indawo yesibili ku Division Two Shield begodu uMsomi wakhethwa njengomdlali odlale kuhle khulu ukudlula boke abadlali. Ngomnyaka ka-2015 waba ngukaputeni we-Stars njengombana athumba i-Shield begodu wakhethwa njengomvikeli odlale kuhle khulu wephaliswano. Ngomnyaka wee-2016 waba ngukaputeni we-Stars ukuya endaweni yesihlanu isikhundla sabo esihle khulu kuligi. Abalingani bakhe be-Stars bafaka hlangana uPrecious Mthembu. Lokha nakadlalela i-Stars uMsomi wasebenza njengotitjhere nomqeqetjhi webholo lezandla e-Northlands Primary School eDurban North.

=== Surrey Storm ===
Ngomnyaka wee- 2015 uMsomi watlikitla ne Surrey Storm ye Netball Superleague . UTamsin Greenway ongumbanduli omkhulu we-Surrey Storm wathoma ukubona uMsomi adlala kumdlalo we Commonwealth ngomnyaka ka 2014. Ngemva kwalokho wathintana naye nge Facebook begodu wammema bona adlalele i-Storm. Mhla amalanga ali-17 kuNtaka 2015 wenza ukuthoma kwakhe kokuthoma ekunqobeni kwe Team Bath ngo-61-39 begodu wakhethwa njengomdlali ophuma phambili kibo boke. Igalelo lakaMsomi lisize isiqhema se Surrey Storm ngomnyaka wee-2015 bona siphumelele eemphaliswaneni. Emdlalweni wokugcina omkhulu bahlula i-Hertfordshire Mavericks ngo-56-39.

=== Wasps ===
Ngenyanga kaKhukhulamungu 2016, uMsomi watlikitla i Wasps Netball ye -Netball Superleague wahlangana godu no Tamsin Greenway. Ngemva kwalokho waba lilunga lesiqhema se-Wasps esathumba ku Netball Superleague yango 2017 begodu emdlalweni omkhulu wakhethwa njengomdlali womdlalo. Ngemva kokuphetha isizini ka-2018 ne Adelaide Thunderbirds uMsomi wabuyela ku Wasps ngesizini ye-2019 Netball Superleague begodu bekalilunga lesiqhema sabo esaqeda njengesesibili.

=== I-Adelaide Thunderbirds ===
U-Msomi wajoyina i-Adelaide Thunderbirds ngesikhathi se-2018 Suncorp Super Netball. Ngemva kwalokho wenza ukuvela kwe-11 kwabadala kodwana bekungasi yisizini ebaphumelela kiyo. I-Thunderbirds iqede isizini ka-2018 ingathumbi. Lokha nakadlalela i-Thunderbirds waphinda waqeda isikhathi sokubandula e Contax Netball Club.

Ngomnyaka wee-2020 UMsomi wabalilunga lesiqhema se Gauteng Golden Fireballs esaqeda endaweni yesithathu ku Telkom Netball League. Abalingani bakhe bangomnyaka ka 2020 eFireballs bafaka hlangana udadwabo omncani uSinenhlanhla Msomi. Ngo-2022,uMsomi waba ngukaputeni wesiqhema se Fireballs lokha nabathumba isicoco se-TNL. Emdlalweni wokugcina bahlula i-Gauteng Jaguars ngo-35-32.

=== ISewula Afrika ===
Hlangana nomnyaka ka-2011 no 2023, uMsomi wenze imidlalo eli-171 yeSewula Afrika. Phakathi kuka-2016 ukuya ku-2023 waba ngukaputeni weSewula Afrika. Lokha nakathatha umhlalaphasi bekangumdlali weentjhabatjhaba webholo lezandla odlale kuhle khulu eSewula Afrika. Wenza umdlalo wakhe wokuthoma weSewula Afrika edlala ne Jamaica ku 2011 World Netball Championships. Bekalilunga lamaqembu weSewula Afrika aphumelele iindondo ku- 2012 World University Netball Championship kanye ne -2012 Fast5 Netball World Series. Ngomnyaka ka 2013 waba ngusekela kakaputeni uMaryka Holtzhausen begodu waba ngukaputeni wesiqhema seSewula Afrika esathumba i 2013 Diamond Challenge. Ngemva kwalokho wajamela iSewula Afrika emidlalweni ye-Commonwealth ka-2014 kanye neNdebe yePhasi ye Netball ka-2015. Ngenyanga kaRhoboyi wee-2016, uMsomi wamenyezelwa njengokaputeni weSewula Afrika we -2016 Netball Quad Series athatha isikhundla se-Holtzhausen unomphela. Mhla amalanga ama-3 kuNobayeni 2017 waba ngukaputeni weSewula Afrika ekunqobeni kwabo kokuthoma kwe Netball Quad Series lokha nabahlula i-England ngo-54-51. 

Ngaphambi kwemidlalo ye-Commonwealth yango-2022, i Netball South Africa yanikela abadlali iinomboro zabadlala ababoqhephetjhe kokuthoma. UMsomi ubengomunye wabadlali abama 24 abathola isivumelwano. Emdlalweni we Commonwealth Games Parade of Nations wangomnyaka wee-2022.uMsomi wakhethwa njengomunye wabathwali beflegi yeSewula Afrika. Ngenyanga kaRhoboyi ngomyaka ka 2022 waba mdlali weentjhabatjhaba webholo lezandla odlale khulu eSewula Afrika lokha nakadlalako umdlalo we-151 ngesikhathi sephaliswano se Netball World Cup ngomnyaka wee-2023. Ngo 2023, uMsomi wenza ukubonakala kwakhe kwesine eNdebeni yePhasi yebholo lezandla.

{| class=&quot;wikitable collapsible&quot;
!Tournaments
!Place
|-
|2011 World Netball Championships
|5th
|-
|2011 World Netball Series
|5th
|-
|2012 World University Netball Championship
|
|-
|2012 Diamond Challenge
|1st
|-
|2012 Netball Quad Series
|4th
|-
|2012 Fast5 Netball World Series
|
|-
|2013 African Netball Championship
|1st
|-
|2013 Diamond Challenge
|1st
|-
|2013 Fast5 Netball World Series
|6th
|-
|2014 Commonwealth Games&lt;ref name=&quot;en230916&quot; /&gt;&lt;ref name=&quot;skysports230916&quot; /&gt;
|6th
|-
|2015 Diamond Challenge
|1st
|-
|2015 Taini Jamison Trophy Series
|2nd
|-
|2015 Netball World Cup&lt;ref name=&quot;en230916&quot; /&gt;&lt;ref name=&quot;skysports230916&quot; /&gt;
|5th
|-
|2016 Netball Quad Series&lt;ref name=&quot;nsa190816&quot; /&gt;
|4th
|-
|2016 Diamond Challenge
|1st
|-
|2017 Netball Quad Series (January/February)
|4th
|-
|2017 Netball Quad Series (August/September)
|4th
|-
|2018 Netball Quad Series (January)
|4th
|-
|2018 Commonwealth Games
|5th
|-
|2018 Netball Quad Series (September)
|4th
|-
|2018 Diamond Challenge
|1st
|-
|2019 Netball Quad Series
|4th
|-
|2019 Netball World Cup
|4th
|-
|2019 Africa Netball Cup&lt;ref name=&quot;nsa210520&quot; /&gt;
|1st
|-
|2019 South Africa England netball series
|2nd
|-
|2020 Netball Nations Cup
|4th
|-
|2020 South Africa Malawi netball series
|1st
|- 
|2021 SPAR Challenge Series
|1st
|-
|2021 Africa Netball Cup
|1st
|-
|2022 Netball Quad Series
|4th
|-
|2022 Commonwealth Games
|6th
|-
|2023 Netball World Cup qualification – Africa
|1st
|-
|2022 SPAR Diamond Challenge
|1st
|-
|2023 Netball Quad Series
|4th
|-
|2023 Netball World Cup
|6th
|-
|}

== Umsebenzi wokubandula ==

=== I-UJ Netball ===
Ngenyanga kaRhoboyi ngomnyaka wee-2019 uMsomi wakhethwa njengombanduli omkhulu we University of Johannesburg Netball Club.Ngo 2023 wadosela i-UJ Netball emdlalweni wabo wokuthoma we-Varsity Netball. Kodwana baqeda njengabalandeli ngemva kokuhlulwa yi UP Tuks ngo-63-61 emdlalweni wokugcina. Ngo-2024, u-Msomi wahola i-UJ Netball ukuya kuma-final ngomnyaka wesibili ngokulandelana. Kodwana, baphinda baqeda njengababili, kulokhu bahlulwa 58-55 ku -UFS Kovsies .

== Ukuhlonitjhwa ==

=== Umdlali ===

* '''INdebe yebholo ye-Afrika'''
** ''Abaphumeleleko'' : 2013, 2019, 2021
* '''Inselelo yedayimani'''
** ''Abaphumeleleko'' : 2012, 2013, 2015, 2016, 2018, 2021, 2022
* '''Umqhudelwano webholo ye-World University'''
** ''Abathatha indawo yesibili'' : 2012

; Isiqhema se Surrey Storm

* '''I-Netball Superleague'''
** ''Abaphumeleleko'' : 2015

; I-Wasps Netball

* '''I-Superleague ye-Netball'''
** ''Abaphumeleleko'' : 2017
** ''Abathatha indawo yesibili'' : 2019

; I-Gauteng Golden Fireballs

* '''I-Telkom Netball League'''
** ''Abaphumeleleko'' : 2022

; Kingdom Stars

* '''Isihlangu seSigaba sesibili'''
** ''Abaphumeleleko'' : 2015

=== Ukubandula ===

; I-UJ Netball

* '''I-Varsity Netball'''
** ''Abathatha indawo yesibili'' : 2023, 2024</text>
      <sha1>jt60h9o2a7snn2fxpsy4bkuh86s918j</sha1>
    </revision>
  </page>
  <page>
    <title>MaWhoo</title>
    <ns>0</ns>
    <id>912</id>
    <revision>
      <id>5454</id>
      <timestamp>2025-09-04T08:02:00Z</timestamp>
      <contributor>
        <username>Nothi2003</username>
        <id>833</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1307753445|MaWhoo]]&quot;</comment>
      <origin>5454</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9415" sha1="3e9ovwuctif6o35hz4mkjwd0by929jd" xml:space="preserve"> 

'''U-Thandeka Nontobeko Ngema''' (wabelethwa mhlana amalanga ali-16 kuNobayeni 1994), owaziwa ngokuthi '''ngu-MaWhoo''', mquli nomtloli weengoma weSewula Afrika.    Wathola ukuhlonitjhwa okukhulu ngemva kokukhipha ingoma yakhe yokuthoma ethi &quot;Umshado&quot; eno- Heavy-K .

U-Ngema uvele godu kumavidiyo womvumo amanengi, okufaka hlangana ukulingisa iindima eziqakathekileko. Ubuye waba yimodeli yamabhrendi ngaphakathi nangaphandle kweSewula Afrika. Usebenze ne-Tribe Afrique, House of Supreme, kanye ne-Convoy Clothing South Africa. Usebenzisane nabantu abafana no -DJ Maphorisa, u-Master KG, u-Tsisto, u-Kabza De Small no-Vigro Deep.   

Ngaphandle kwelizwe lakwabo, u-Ngema sele adlale emazweni we-Afrika afana ne [[Botswana|-Botswana]], [[Eswatini|i-Eswatini]], [[Zimbabwe|i-Zimbabwe]] ne [[Mozambique|-Mozambique]] .   

== Isendlalelo ==

=== Ipilo yokuthoma ===
U-Thandeka Nontobeko Ngema wabelethwa mhlana amalanga ali-16 kuNobayeni ngo1994 e- Eshowe, KwaZulu-Natal, eSewula Afrika. Wathoma umsebenzi wakhe womvumo asesemncani. Lokha nakaneminyaka elitjhumi nanye, wathatha ingoma yakhe erekhodiweko wayisa emsakazweni wendawo bona idlalwe emoyeni kodwana akhenge bamvumele ngombana bekasesemncani khulu.  

==== Amagama wesiteji ====
Engcocweni, wabelane ngokuthi ibizo lakhe lesiteji litjho &quot;umlingo&quot; ngelimi lesiJapan . Watjho  bona ibizo lavela ngo-Okmalumkoolcat.  

=== Ifundo ===
U-Ngema unesiqu asifumene e- University of South Africa (i-UNISA). 

== Ibizelo ==
Ingoma yakhe ethi &quot;Bengicela&quot; no-GL_Ceekay, i-Thukuthela ene-Jazzworx yakhutjhwa mhlana amalanga ali-13 kuMgwengweni 2025.  Yafika endaweni yokuthoma ematjhadini we-Apple Music, ingoma edumileko ku-YouTube, ingoma ethandwa khulu ku-Shazam begodu yingoma yesihlanu kumatjhadi weengoma eziphezulu ze-Spotify ngokulandelana. 

== Ukuphikisana ==
Ngo-2024 ngesikhathi sokukhulumisana no-L-Tido, u-Ngema waveza bona unamadoda amanengi ku-akhawunti yakhe yezokuthintana amthintako, okufaka hlangana umrepha u-Lil Wayne, u-Jay Z no -Rick Ross .  Abalandeli bakhe bamgandelela bona afakazele bona lokhu kuliqiniso na, lapho uNgema abelana khona ngesithombe sengcoco no-Lil Wayne.  

== I-Discography ==

=== Ama-albhamu we-studio ===

* What a time to be alive (2022)
* ''The chosen'' (2023)
* ''The sound of magic''(2024)
* Amazwi Okubonga (2025)

== Abangakathathi ==

=== Njengomdwebi odosa phambili ===
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+List of singles as lead artist, with selected chart positions and certifications, showing year released and album name
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Title
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Year
! colspan=&quot;1&quot; scope=&quot;col&quot; |Peak chart positions
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; |Certifications
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Album
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; |ZA&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; |&quot;Umshado&quot; (featuring Heavy-K)
|2019
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Ngiyamthanda&quot; (MaWhoo, Master KG featuring Lowsheen)
| rowspan=&quot;2&quot; |2021
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Inkanyezi&quot; (MaWhoo, Master KG  featuring Lowsheen)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Ngithakazele&quot; (MaWhoo, DJ Fanzy featuring Andry K)
| rowspan=&quot;4&quot; |2022
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Ngithakazele&quot;
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;10k Ye McDonald's&quot; (MaWhoo featuring Mdoovar, 9umba)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Thokoza&quot; (Sam Deep, MaWhoo)
|—
|RiSA: 2× Platinum 
|''Ace of Spades''
|-
! scope=&quot;row&quot; |&quot;Umlilo&quot; (DJ Ngwazi, Pouler D’musiq, MaWhoo)
| rowspan=&quot;5&quot; |2023
|—
|
|
|-
! scope=&quot;row&quot; |&quot;Nduma Ndumane&quot; (MaWhoo, Kabza De Small, DJ Maphorisa featuring Da Muziqal Chef)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Bayangzonda&quot; (Mac Lopez, MaWhoo)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;NgizoWela&quot; (Slade, MaWhoo, Tycoon featuring Marcus MC, Stacy)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Ngifunani&quot; (Femi Large, MaWhoo)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Imizi Yobaba&quot; (Soulfreakah, MaWhoo)
| rowspan=&quot;2&quot; |2024


|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Uthukela&quot; (MaWhoo featuring Harry Cane, Eemoh)
|_
|
|{{non-album single}}
|-
!&quot;Gucci&quot; (Mthandeni SK featuring MaWhoo)
|
|_
|
|Non-album single
|-
!&quot;Ngeke&quot; (Yumbs, Zwayetoven &amp; MaWhoo featuring Mthunzi)
|
|_
|
|Non-album single
|-
!&quot;Khuluma&quot; (Oskido, Master KG &amp; MaWhoo featuring Lilyfaith, Lowsheen &amp; Theo Kgosinkwe)
|
|_
|
|Non-album single
|-
!&quot;Uzizwa Kanjan' (Jazzworx, Thukuthela, MaWhoo &amp; GL_Ceejay)
|2025
|5
|
|Non-album single
|-
!&quot;Ziphi Nkomo&quot; (Sir Trill, MaWhoo &amp; B33kay SA featuring DJ 2k, Frank Mabeat &amp; Tumisho)
|
|_
|
|Non-album single
|-
!&quot;Phakade Lami&quot; (Da Capo, Soul Star &amp; MaWhoo)
|
|_
|
|Non-album single
|-
!&quot;Bengicela&quot; (MaWhoo, GL_ Ceejay &amp; Thukuthela featuring Jazzworx)
|
|1
|
|Amazwi Okubonga
|-
!&quot;Smomondiya&quot; (Frank Mabeat &amp; MaWhoo featuring B33kay SA)
|
|_
|
|Non-album single
|-
!&quot;Sono Sam&quot; (TBO, MaWhoo &amp; Ntsika featuring Ngwato &amp; Ave Songsmith)
|
|_
|
|Non-album single
|-
!&quot;MA AFRIKA&quot; (Deep Sen, MaWhoo &amp; M.J featuring Ntando Yamahlubi)
|
|_
|
|Non-album single
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; |&quot;—&quot; denotes a recording that did not chart or was not released in that territory.
|}
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+Irhelo lama-single njengabaculi abaveziweko, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;Moya Wami&quot; (u-Oscar Mbo ahlanganisa u-MaWhoo)
| rowspan=&quot;2&quot; | 2020
| —
| Irhawuda
| ''Kwama-Groovists''
|-
! scope=&quot;row&quot; | &quot;Bambelela&quot; (i-Caltonic SA ehlanganisa u-Sje Konka, u-MaWhoo, u-Thabz Le Madonga)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Uqobo Lwami&quot; (u-DJ Fanzy ohlanganisa u-MaWhoo)
| 2021
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ikhadi le-Indoda Nge&quot; (DJ Moscow, Deepsen, Eddie The Vocalist feat. DJ Moscow, MaWhoo)
| rowspan=&quot;2&quot; | 2022
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Khumbul' Ekhaya&quot; (u-Knowley-D ohlanganisa u-Busta 929, u-MaWhoo)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Dali Wam&quot; (Pabi Cooper, Yumbs ehlanganisa uMaWhoo, uNkosazana Daughter )
| rowspan=&quot;9&quot; | 2023
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Isthutha&quot; (Inkinga Abangan Bam)&quot; (Sam Deep, De Mthuda ehlanganisa uMawhoo, Mkeyz)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ungiphethe Kahle&quot; (Kabza De Small, DJ Maphorisa ahlanganisa uNokwazi, MaWhoo, Mashudu &amp; LeeArt)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Noma Kanjani&quot; (u-Sino Msolo ohlanganisa u-Kabza De Small, u-MaWhoo, u-Azana)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Uthando&quot; (I-Groovist ehlanganisa u-MaWhoo)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Zibonakalise&quot; (ama-HK ahlanganisa u-MaWhoo)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Wena My Dali&quot; (I-Focalistic featuring Ch'cco, MaWhoo, EeQue, Thama Tee)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Impilo&quot; (u-Marlode no-Owams abahlanganisa ama-2woBunnies, u-MaWhoo, u-Leandra.Vert, u-Toby Franco, u-Gilano, u-Sponge 101)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Kutsa&quot; (u-DJ Sliqe ahlanganisa u-Yanga Chief, u-MaWhoo, u-2woshort, u-Makwa)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ungithandile&quot; (u-Baby Momo ohlanganisa u-MaWhoo, u-Ceenday, u-Jay Sax, u-Shino Kikai, u-DJ 2K)
| rowspan=&quot;6&quot; | 2024
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ngifa Nawe&quot; (MFR Souls, Kabza De Small ene-MaWhoo, Bassie, T-Man SA, Shane907)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Amabhoza&quot; ( Aymos, Mas Musiq featuring MaWhoo)
| —
|
| ''Impilo''
|-
! scope=&quot;row&quot; | &quot;Ematshwaleni&quot; ( Kususa, Anatti featuring MaWhoo, Noxolo Ngema, King Deetoy)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Injabulo&quot; (u-Lily Faith ahlanganisa u-Theo Kgosinkwe, u-X-Wise, u-Oskido, u-MaWhoo)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Gucci&quot; (Mthandeni SK, ehlanganisa u-MaWhoo)
| 1  
||{{non-album single}} 
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; | &quot;—&quot; kutjho ukurekhoda okungazange kushadi namkha okungakakhutjhwa endaweni leyo.
|}
{| class=&quot;wikitable plainrowheaders&quot; border=&quot;1&quot; style=&quot;text-align:center;&quot;
|+Irhelo lezinye iingoma ezitjhadiweko, ezineendawo ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;Kulula&quot; (Mawhoo, DJ Maphorisa, Kabza De Small)
| 2022
| —
| Igolide 
| ''Yisikhathi esingangani sokuphila''
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; | &quot;—&quot; kutjho ukurekhoda okungazange kushadi namkha okungakakhutjhwa endaweni leyo.
|}

== Ipilo yomuntu mathupha ==
Kube nemibiko yokuthi uNgema uthandana noHlubi Nkosi.   Iinthandani bezibikwe bona zinikelana ngezipho.  

== Imithombo lwazi ==
{{Reflist}}</text>
      <sha1>3e9ovwuctif6o35hz4mkjwd0by929jd</sha1>
    </revision>
    <revision>
      <id>5508</id>
      <parentid>5454</parentid>
      <timestamp>2025-09-04T09:14:03Z</timestamp>
      <contributor>
        <username>Nothi2003</username>
        <id>833</id>
      </contributor>
      <comment>i added references</comment>
      <origin>5508</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="10685" sha1="o1z4knzabxeig04sb351rref5q6kvzh" xml:space="preserve"> 

'''U-Thandeka Nontobeko Ngema''' (wabelethwa mhlana amalanga ali-16 kuNobayeni 1994), owaziwa ngokuthi '''ngu-MaWhoo''', mquli nomtloli weengoma weSewula Afrika.&lt;ref&gt;[https://slikouronlife.co.za/blog/24023/mawhoos-kulula-surpasses-1-million-streams/ MaWhoo's 'Kulula' Surpasses 1 Million Streams | Slikouronlife]&lt;/ref&gt; Wathola ukuhlonitjhwa okukhulu ngemva kokukhipha ingoma yakhe yokuthoma ethi &quot;Umshado&quot; leno- Heavy-K.&lt;ref&gt;[https://kingminds.net/mawhoo-nontobeko-thandeka-ngema-biography-early-life-age-career-songs-net-worth/ Mawhoo (Nontobeko Thandeka Ngema) Biography, Early Life, Age, Career, Songs, Net Worth - KingMinds]&lt;/ref&gt;

U-Ngema uvele godu kumavidiyo womvumo amanengi, okufaka hlangana ukulingisa iindima eziqakathekileko. Ubuye waba yimodeli yamabhrendi ngaphakathi nangaphandle kweSewula Afrika.&lt;ref&gt;[https://www.bona.co.za/entertainment/mawhoos-shocking-revelation-american-a-listers-who-slid-into-her-dms/ Mawhoo's shocking revelation! American A-listers who slid into her DMs | Bona Magazine]&lt;/ref&gt; Usebenze ne-Tribe Afrique, House of Supreme, kanye ne-Convoy Clothing South Africa.&lt;ref&gt;[[:en:MaWhoo|MaWhoo - Wikipedia]]&lt;/ref&gt; Usebenzisane nabantu abafana no -DJ Maphorisa, u-Master KG, u-Tsisto, u-Kabza De Small no-Vigro Deep.   

Ngaphandle kwelizwe lakwabo, u-Ngema sele adlale emazweni we-Afrika afana ne [[Botswana|-Botswana]], [[Eswatini|i-Eswatini]], [[Zimbabwe|i-Zimbabwe]] ne [[Mozambique|-Mozambique]] .   

== Isendlalelo ==

=== Ipilo yokuthoma ===
U-Thandeka Nontobeko Ngema wabelethwa mhlana amalanga ali-16 kuNobayeni ngo1994 e- Eshowe, KwaZulu-Natal, eSewula Afrika. Wathoma umsebenzi wakhe womvumo asesemncani. Lokha nakaneminyaka elitjhumi nanye, wathatha ingoma yakhe erekhodiweko wayisa emsakazweni wendawo bona idlalwe emoyeni kodwana akhenge bamvumele ngombana bekasesemncani khulu.  

==== Amagama wesiteji ====
Engcocweni, wabelane ngokuthi ibizo lakhe lesiteji litjho &quot;umlingo&quot; ngelimi lesiJapan . Watjho  bona ibizo lavela ngo-Okmalumkoolcat.  

=== Ifundo ===
U-Ngema unesiqu asifumene e- University of South Africa (i-UNISA). 

== Ibizelo ==
Ingoma yakhe ethi &quot;Bengicela&quot; no-GL_Ceekay, i-Thukuthela ene-Jazzworx yakhutjhwa mhlana amalanga ali-13 kuMgwengweni 2025.&lt;ref&gt;{{Cite web|last=Rethabile|first=Thandi|date=2025-06-05|title=MaWhoo, GL_Ceejay &amp; Thukuthela – Bengicela (Tholukuthi ) ft. JazzWorx|url=https://ceemuzic.com/music/mawhoo-gl-ceejay-thukuthela-bengicela-tholukuthi-ft-jazzworx-m66/|access-date=2025-09-04|website=CeeMuzic|language=en}}&lt;/ref&gt;  Yafika endaweni yokuthoma ematjhadini we-Apple Music, ingoma edumileko ku-YouTube, ingoma ethandwa khulu ku-Shazam begodu yingoma yesihlanu kumatjhadi weengoma eziphezulu ze-Spotify ngokulandelana. 

== Ukuphikisana ==
Ngo-2024 ngesikhathi sokukhulumisana no-L-Tido, u-Ngema waveza bona unamadoda amanengi ku-akhawunti yakhe yezokuthintana amthintako, okufaka hlangana umrepha u-Lil Wayne, u-Jay Z no -Rick Ross .  Abalandeli bakhe bamgandelela bona afakazele bona lokhu kuliqiniso na, lapho uNgema abelana khona ngesithombe sengcoco no-Lil Wayne.  

== I-Discography ==

=== Ama-albhamu we-studio ===

* What a time to be alive (2022)
* ''The chosen'' (2023)
* ''The sound of magic''(2024)
* Amazwi Okubonga (2025)

== Abangakathathi ==

=== Njengomdwebi odosa phambili ===
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+List of singles as lead artist, with selected chart positions and certifications, showing year released and album name
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Title
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Year
! colspan=&quot;1&quot; scope=&quot;col&quot; |Peak chart positions
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; |Certifications
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Album
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; |ZA&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; |&quot;Umshado&quot; (featuring Heavy-K)
|2019
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Ngiyamthanda&quot; (MaWhoo, Master KG featuring Lowsheen)
| rowspan=&quot;2&quot; |2021
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Inkanyezi&quot; (MaWhoo, Master KG  featuring Lowsheen)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Ngithakazele&quot; (MaWhoo, DJ Fanzy featuring Andry K)
| rowspan=&quot;4&quot; |2022
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Ngithakazele&quot;
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;10k Ye McDonald's&quot; (MaWhoo featuring Mdoovar, 9umba)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Thokoza&quot; (Sam Deep, MaWhoo)
|—
|RiSA: 2× Platinum 
|''Ace of Spades''
|-
! scope=&quot;row&quot; |&quot;Umlilo&quot; (DJ Ngwazi, Pouler D’musiq, MaWhoo)
| rowspan=&quot;5&quot; |2023
|—
|
|
|-
! scope=&quot;row&quot; |&quot;Nduma Ndumane&quot; (MaWhoo, Kabza De Small, DJ Maphorisa featuring Da Muziqal Chef)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Bayangzonda&quot; (Mac Lopez, MaWhoo)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;NgizoWela&quot; (Slade, MaWhoo, Tycoon featuring Marcus MC, Stacy)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Ngifunani&quot; (Femi Large, MaWhoo)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Imizi Yobaba&quot; (Soulfreakah, MaWhoo)
| rowspan=&quot;2&quot; |2024


|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Uthukela&quot; (MaWhoo featuring Harry Cane, Eemoh)
|_
|
|{{non-album single}}
|-
!&quot;Gucci&quot; (Mthandeni SK featuring MaWhoo)
|
|_
|
|Non-album single
|-
!&quot;Ngeke&quot; (Yumbs, Zwayetoven &amp; MaWhoo featuring Mthunzi)
|
|_
|
|Non-album single
|-
!&quot;Khuluma&quot; (Oskido, Master KG &amp; MaWhoo featuring Lilyfaith, Lowsheen &amp; Theo Kgosinkwe)
|
|_
|
|Non-album single
|-
!&quot;Uzizwa Kanjan' (Jazzworx, Thukuthela, MaWhoo &amp; GL_Ceejay)
|2025
|5
|
|Non-album single
|-
!&quot;Ziphi Nkomo&quot; (Sir Trill, MaWhoo &amp; B33kay SA featuring DJ 2k, Frank Mabeat &amp; Tumisho)
|
|_
|
|Non-album single
|-
!&quot;Phakade Lami&quot; (Da Capo, Soul Star &amp; MaWhoo)
|
|_
|
|Non-album single
|-
!&quot;Bengicela&quot; (MaWhoo, GL_ Ceejay &amp; Thukuthela featuring Jazzworx)
|
|1
|
|Amazwi Okubonga
|-
!&quot;Smomondiya&quot; (Frank Mabeat &amp; MaWhoo featuring B33kay SA)
|
|_
|
|Non-album single
|-
!&quot;Sono Sam&quot; (TBO, MaWhoo &amp; Ntsika featuring Ngwato &amp; Ave Songsmith)
|
|_
|
|Non-album single
|-
!&quot;MA AFRIKA&quot; (Deep Sen, MaWhoo &amp; M.J featuring Ntando Yamahlubi)
|
|_
|
|Non-album single
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; |&quot;—&quot; denotes a recording that did not chart or was not released in that territory.
|}
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+Irhelo lama-single njengabaculi abaveziweko, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;Moya Wami&quot; (u-Oscar Mbo ahlanganisa u-MaWhoo)
| rowspan=&quot;2&quot; | 2020
| —
| Irhawuda
| ''Kwama-Groovists''
|-
! scope=&quot;row&quot; | &quot;Bambelela&quot; (i-Caltonic SA ehlanganisa u-Sje Konka, u-MaWhoo, u-Thabz Le Madonga)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Uqobo Lwami&quot; (u-DJ Fanzy ohlanganisa u-MaWhoo)
| 2021
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ikhadi le-Indoda Nge&quot; (DJ Moscow, Deepsen, Eddie The Vocalist feat. DJ Moscow, MaWhoo)
| rowspan=&quot;2&quot; | 2022
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Khumbul' Ekhaya&quot; (u-Knowley-D ohlanganisa u-Busta 929, u-MaWhoo)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Dali Wam&quot; (Pabi Cooper, Yumbs ehlanganisa uMaWhoo, uNkosazana Daughter )
| rowspan=&quot;9&quot; | 2023
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Isthutha&quot; (Inkinga Abangan Bam)&quot; (Sam Deep, De Mthuda ehlanganisa uMawhoo, Mkeyz)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ungiphethe Kahle&quot; (Kabza De Small, DJ Maphorisa ahlanganisa uNokwazi, MaWhoo, Mashudu &amp; LeeArt)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Noma Kanjani&quot; (u-Sino Msolo ohlanganisa u-Kabza De Small, u-MaWhoo, u-Azana)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Uthando&quot; (I-Groovist ehlanganisa u-MaWhoo)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Zibonakalise&quot; (ama-HK ahlanganisa u-MaWhoo)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Wena My Dali&quot; (I-Focalistic featuring Ch'cco, MaWhoo, EeQue, Thama Tee)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Impilo&quot; (u-Marlode no-Owams abahlanganisa ama-2woBunnies, u-MaWhoo, u-Leandra.Vert, u-Toby Franco, u-Gilano, u-Sponge 101)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Kutsa&quot; (u-DJ Sliqe ahlanganisa u-Yanga Chief, u-MaWhoo, u-2woshort, u-Makwa)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ungithandile&quot; (u-Baby Momo ohlanganisa u-MaWhoo, u-Ceenday, u-Jay Sax, u-Shino Kikai, u-DJ 2K)
| rowspan=&quot;6&quot; | 2024
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ngifa Nawe&quot; (MFR Souls, Kabza De Small ene-MaWhoo, Bassie, T-Man SA, Shane907)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Amabhoza&quot; ( Aymos, Mas Musiq featuring MaWhoo)
| —
|
| ''Impilo''
|-
! scope=&quot;row&quot; | &quot;Ematshwaleni&quot; ( Kususa, Anatti featuring MaWhoo, Noxolo Ngema, King Deetoy)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Injabulo&quot; (u-Lily Faith ahlanganisa u-Theo Kgosinkwe, u-X-Wise, u-Oskido, u-MaWhoo)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Gucci&quot; (Mthandeni SK, ehlanganisa u-MaWhoo)
| 1  
||{{non-album single}} 
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; | &quot;—&quot; kutjho ukurekhoda okungazange kushadi namkha okungakakhutjhwa endaweni leyo.
|}
{| class=&quot;wikitable plainrowheaders&quot; border=&quot;1&quot; style=&quot;text-align:center;&quot;
|+Irhelo lezinye iingoma ezitjhadiweko, ezineendawo ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;Kulula&quot; (Mawhoo, DJ Maphorisa, Kabza De Small)
| 2022
| —
| Igolide 
| ''Yisikhathi esingangani sokuphila''
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; | &quot;—&quot; kutjho ukurekhoda okungazange kushadi namkha okungakakhutjhwa endaweni leyo.
|}

== Ipilo yomuntu mathupha ==
Kube nemibiko yokuthi uNgema uthandana noHlubi Nkosi.   Iinthandani bezibikwe bona zinikelana ngezipho.  

== Imithombo lwazi ==

# &lt;ref&gt;[https://www.bona.co.za/entertainment/mawhoos-shocking-revelation-american-a-listers-who-slid-into-her-dms/ Mawhoo's shocking revelation! American A-listers who slid into her DMs | Bona Magazine]&lt;/ref&gt;
# &lt;ref&gt;[https://slikouronlife.co.za/blog/24023/mawhoos-kulula-surpasses-1-million-streams/ MaWhoo's 'Kulula' Surpasses 1 Million Streams | Slikouronlife]&lt;/ref&gt;</text>
      <sha1>o1z4knzabxeig04sb351rref5q6kvzh</sha1>
    </revision>
    <revision>
      <id>5556</id>
      <parentid>5508</parentid>
      <timestamp>2025-09-04T09:39:52Z</timestamp>
      <contributor>
        <username>Nothi2003</username>
        <id>833</id>
      </contributor>
      <comment>added links</comment>
      <origin>5556</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="10684" sha1="q5d2gba80dln7wiwxv2otwf33g3p3wk" xml:space="preserve"> 

'''U-Thandeka Nontobeko Ngema''' (wabelethwa mhlana amalanga ali-16 kuNobayeni 1994), owaziwa ngokuthi '''ngu-MaWhoo''', mquli nomtloli weengoma weSewula Afrika.&lt;ref&gt;[https://slikouronlife.co.za/blog/24023/mawhoos-kulula-surpasses-1-million-streams/ MaWhoo's 'Kulula' Surpasses 1 Million Streams | Slikouronlife]&lt;/ref&gt; Wathola ukuhlonitjhwa okukhulu ngemva kokukhipha ingoma yakhe yokuthoma ethi &quot;Umshado&quot; leno- Heavy-K.&lt;ref&gt;[https://kingminds.net/mawhoo-nontobeko-thandeka-ngema-biography-early-life-age-career-songs-net-worth/ Mawhoo (Nontobeko Thandeka Ngema) Biography, Early Life, Age, Career, Songs, Net Worth - KingMinds]&lt;/ref&gt;

U-Ngema uvele godu kumavidiyo womvumo amanengi, okufaka hlangana ukulingisa iindima eziqakathekileko. Ubuye waba yimodeli yamabhrendi ngaphakathi nangaphandle kweSewula Afrika.&lt;ref&gt;[https://www.bona.co.za/entertainment/mawhoos-shocking-revelation-american-a-listers-who-slid-into-her-dms/ Mawhoo's shocking revelation! American A-listers who slid into her DMs | Bona Magazine]&lt;/ref&gt; Usebenze ne-Tribe Afrique, House of Supreme, kanye ne-Convoy Clothing South Africa.&lt;ref&gt;[[:en:MaWhoo|MaWhoo - Wikipedia]]&lt;/ref&gt; Usebenzisane nabantu abafana no -DJ Maphorisa, u-Master KG, u-Tsisto, u-Kabza De Small no-Vigro Deep.   

Ngaphandle kwelizwe lakwabo, u-Ngema sele adlale emazweni we-Afrika afana ne [[Botswana|-Botswana]], [[Eswatini|i-Eswatini]], [[Zimbabwe|i-Zimbabwe]] ne [[Mozambique|-Mozambique]].   

== Isendlalelo ==

=== Ipilo yokuthoma ===
U-Thandeka Nontobeko Ngema wabelethwa mhlana amalanga ali-16 kuNobayeni ngo1994 e- Eshowe, KwaZulu-Natal, eSewula Afrika. Wathoma umsebenzi wakhe womvumo asesemncani. Lokha nakaneminyaka elitjhumi nanye, wathatha ingoma yakhe erekhodiweko wayisa emsakazweni wendawo bona idlalwe emoyeni kodwana akhenge bamvumele ngombana bekasesemncani khulu.  

==== Amagama wesiteji ====
Engcocweni, wabelane ngokuthi ibizo lakhe lesiteji litjho &quot;umlingo&quot; ngelimi lesiJapan . Watjho  bona ibizo lavela ngo-Okmalumkoolcat.  

=== Ifundo ===
U-Ngema unesiqu asifumene e- University of South Africa (i-UNISA). 

== Ibizelo ==
Ingoma yakhe ethi &quot;Bengicela&quot; no-GL_Ceekay, i-Thukuthela ene-Jazzworx yakhutjhwa mhlana amalanga ali-13 kuMgwengweni 2025.&lt;ref&gt;{{Cite web|last=Rethabile|first=Thandi|date=2025-06-05|title=MaWhoo, GL_Ceejay &amp; Thukuthela – Bengicela (Tholukuthi ) ft. JazzWorx|url=https://ceemuzic.com/music/mawhoo-gl-ceejay-thukuthela-bengicela-tholukuthi-ft-jazzworx-m66/|access-date=2025-09-04|website=CeeMuzic|language=en}}&lt;/ref&gt;  Yafika endaweni yokuthoma ematjhadini we-Apple Music, ingoma edumileko ku-YouTube, ingoma ethandwa khulu ku-Shazam begodu yingoma yesihlanu kumatjhadi weengoma eziphezulu ze-Spotify ngokulandelana. 

== Ukuphikisana ==
Ngo-2024 ngesikhathi sokukhulumisana no-L-Tido, u-Ngema waveza bona unamadoda amanengi ku-akhawunti yakhe yezokuthintana amthintako, okufaka hlangana umrepha u-Lil Wayne, u-Jay Z no -Rick Ross .  Abalandeli bakhe bamgandelela bona afakazele bona lokhu kuliqiniso na, lapho uNgema abelana khona ngesithombe sengcoco no-Lil Wayne.  

== I-Discography ==

=== Ama-albhamu we-studio ===

* What a time to be alive (2022)
* ''The chosen'' (2023)
* ''The sound of magic''(2024)
* Amazwi Okubonga (2025)

== Abangakathathi ==

=== Njengomdwebi odosa phambili ===
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+List of singles as lead artist, with selected chart positions and certifications, showing year released and album name
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Title
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Year
! colspan=&quot;1&quot; scope=&quot;col&quot; |Peak chart positions
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; |Certifications
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Album
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; |ZA&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; |&quot;Umshado&quot; (featuring Heavy-K)
|2019
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Ngiyamthanda&quot; (MaWhoo, Master KG featuring Lowsheen)
| rowspan=&quot;2&quot; |2021
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Inkanyezi&quot; (MaWhoo, Master KG  featuring Lowsheen)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Ngithakazele&quot; (MaWhoo, DJ Fanzy featuring Andry K)
| rowspan=&quot;4&quot; |2022
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Ngithakazele&quot;
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;10k Ye McDonald's&quot; (MaWhoo featuring Mdoovar, 9umba)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Thokoza&quot; (Sam Deep, MaWhoo)
|—
|RiSA: 2× Platinum 
|''Ace of Spades''
|-
! scope=&quot;row&quot; |&quot;Umlilo&quot; (DJ Ngwazi, Pouler D’musiq, MaWhoo)
| rowspan=&quot;5&quot; |2023
|—
|
|
|-
! scope=&quot;row&quot; |&quot;Nduma Ndumane&quot; (MaWhoo, Kabza De Small, DJ Maphorisa featuring Da Muziqal Chef)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Bayangzonda&quot; (Mac Lopez, MaWhoo)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;NgizoWela&quot; (Slade, MaWhoo, Tycoon featuring Marcus MC, Stacy)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Ngifunani&quot; (Femi Large, MaWhoo)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Imizi Yobaba&quot; (Soulfreakah, MaWhoo)
| rowspan=&quot;2&quot; |2024


|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Uthukela&quot; (MaWhoo featuring Harry Cane, Eemoh)
|_
|
|{{non-album single}}
|-
!&quot;Gucci&quot; (Mthandeni SK featuring MaWhoo)
|
|_
|
|Non-album single
|-
!&quot;Ngeke&quot; (Yumbs, Zwayetoven &amp; MaWhoo featuring Mthunzi)
|
|_
|
|Non-album single
|-
!&quot;Khuluma&quot; (Oskido, Master KG &amp; MaWhoo featuring Lilyfaith, Lowsheen &amp; Theo Kgosinkwe)
|
|_
|
|Non-album single
|-
!&quot;Uzizwa Kanjan' (Jazzworx, Thukuthela, MaWhoo &amp; GL_Ceejay)
|2025
|5
|
|Non-album single
|-
!&quot;Ziphi Nkomo&quot; (Sir Trill, MaWhoo &amp; B33kay SA featuring DJ 2k, Frank Mabeat &amp; Tumisho)
|
|_
|
|Non-album single
|-
!&quot;Phakade Lami&quot; (Da Capo, Soul Star &amp; MaWhoo)
|
|_
|
|Non-album single
|-
!&quot;Bengicela&quot; (MaWhoo, GL_ Ceejay &amp; Thukuthela featuring Jazzworx)
|
|1
|
|Amazwi Okubonga
|-
!&quot;Smomondiya&quot; (Frank Mabeat &amp; MaWhoo featuring B33kay SA)
|
|_
|
|Non-album single
|-
!&quot;Sono Sam&quot; (TBO, MaWhoo &amp; Ntsika featuring Ngwato &amp; Ave Songsmith)
|
|_
|
|Non-album single
|-
!&quot;MA AFRIKA&quot; (Deep Sen, MaWhoo &amp; M.J featuring Ntando Yamahlubi)
|
|_
|
|Non-album single
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; |&quot;—&quot; denotes a recording that did not chart or was not released in that territory.
|}
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+Irhelo lama-single njengabaculi abaveziweko, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;Moya Wami&quot; (u-Oscar Mbo ahlanganisa u-MaWhoo)
| rowspan=&quot;2&quot; | 2020
| —
| Irhawuda
| ''Kwama-Groovists''
|-
! scope=&quot;row&quot; | &quot;Bambelela&quot; (i-Caltonic SA ehlanganisa u-Sje Konka, u-MaWhoo, u-Thabz Le Madonga)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Uqobo Lwami&quot; (u-DJ Fanzy ohlanganisa u-MaWhoo)
| 2021
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ikhadi le-Indoda Nge&quot; (DJ Moscow, Deepsen, Eddie The Vocalist feat. DJ Moscow, MaWhoo)
| rowspan=&quot;2&quot; | 2022
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Khumbul' Ekhaya&quot; (u-Knowley-D ohlanganisa u-Busta 929, u-MaWhoo)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Dali Wam&quot; (Pabi Cooper, Yumbs ehlanganisa uMaWhoo, uNkosazana Daughter )
| rowspan=&quot;9&quot; | 2023
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Isthutha&quot; (Inkinga Abangan Bam)&quot; (Sam Deep, De Mthuda ehlanganisa uMawhoo, Mkeyz)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ungiphethe Kahle&quot; (Kabza De Small, DJ Maphorisa ahlanganisa uNokwazi, MaWhoo, Mashudu &amp; LeeArt)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Noma Kanjani&quot; (u-Sino Msolo ohlanganisa u-Kabza De Small, u-MaWhoo, u-Azana)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Uthando&quot; (I-Groovist ehlanganisa u-MaWhoo)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Zibonakalise&quot; (ama-HK ahlanganisa u-MaWhoo)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Wena My Dali&quot; (I-Focalistic featuring Ch'cco, MaWhoo, EeQue, Thama Tee)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Impilo&quot; (u-Marlode no-Owams abahlanganisa ama-2woBunnies, u-MaWhoo, u-Leandra.Vert, u-Toby Franco, u-Gilano, u-Sponge 101)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Kutsa&quot; (u-DJ Sliqe ahlanganisa u-Yanga Chief, u-MaWhoo, u-2woshort, u-Makwa)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ungithandile&quot; (u-Baby Momo ohlanganisa u-MaWhoo, u-Ceenday, u-Jay Sax, u-Shino Kikai, u-DJ 2K)
| rowspan=&quot;6&quot; | 2024
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ngifa Nawe&quot; (MFR Souls, Kabza De Small ene-MaWhoo, Bassie, T-Man SA, Shane907)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Amabhoza&quot; ( Aymos, Mas Musiq featuring MaWhoo)
| —
|
| ''Impilo''
|-
! scope=&quot;row&quot; | &quot;Ematshwaleni&quot; ( Kususa, Anatti featuring MaWhoo, Noxolo Ngema, King Deetoy)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Injabulo&quot; (u-Lily Faith ahlanganisa u-Theo Kgosinkwe, u-X-Wise, u-Oskido, u-MaWhoo)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Gucci&quot; (Mthandeni SK, ehlanganisa u-MaWhoo)
| 1  
||{{non-album single}} 
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; | &quot;—&quot; kutjho ukurekhoda okungazange kushadi namkha okungakakhutjhwa endaweni leyo.
|}
{| class=&quot;wikitable plainrowheaders&quot; border=&quot;1&quot; style=&quot;text-align:center;&quot;
|+Irhelo lezinye iingoma ezitjhadiweko, ezineendawo ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;Kulula&quot; (Mawhoo, DJ Maphorisa, Kabza De Small)
| 2022
| —
| Igolide 
| ''Yisikhathi esingangani sokuphila''
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; | &quot;—&quot; kutjho ukurekhoda okungazange kushadi namkha okungakakhutjhwa endaweni leyo.
|}

== Ipilo yomuntu mathupha ==
Kube nemibiko yokuthi uNgema uthandana noHlubi Nkosi.   Iinthandani bezibikwe bona zinikelana ngezipho.  

== Imithombo lwazi ==

# &lt;ref&gt;[https://www.bona.co.za/entertainment/mawhoos-shocking-revelation-american-a-listers-who-slid-into-her-dms/ Mawhoo's shocking revelation! American A-listers who slid into her DMs | Bona Magazine]&lt;/ref&gt;
# &lt;ref&gt;[https://slikouronlife.co.za/blog/24023/mawhoos-kulula-surpasses-1-million-streams/ MaWhoo's 'Kulula' Surpasses 1 Million Streams | Slikouronlife]&lt;/ref&gt;</text>
      <sha1>q5d2gba80dln7wiwxv2otwf33g3p3wk</sha1>
    </revision>
    <revision>
      <id>5635</id>
      <parentid>5556</parentid>
      <timestamp>2025-09-04T10:51:02Z</timestamp>
      <contributor>
        <username>Nothi2003</username>
        <id>833</id>
      </contributor>
      <comment>added a picture</comment>
      <origin>5635</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="10783" sha1="cni5qnsmkjwldwp2u580bpms8cx8r3x" xml:space="preserve"> 
[[Isimumathi:Maker Faire, Berlin (BL7C0113).jpg|thumb|indawo lapha u-Mawhoo aqulela khona abantu.]]
'''U-Thandeka Nontobeko Ngema''' (wabelethwa mhlana amalanga ali-16 kuNobayeni 1994), owaziwa ngokuthi '''ngu-MaWhoo''', mquli nomtloli weengoma weSewula Afrika.&lt;ref&gt;[https://slikouronlife.co.za/blog/24023/mawhoos-kulula-surpasses-1-million-streams/ MaWhoo's 'Kulula' Surpasses 1 Million Streams | Slikouronlife]&lt;/ref&gt; Wathola ukuhlonitjhwa okukhulu ngemva kokukhipha ingoma yakhe yokuthoma ethi &quot;Umshado&quot; leno- Heavy-K.&lt;ref&gt;[https://kingminds.net/mawhoo-nontobeko-thandeka-ngema-biography-early-life-age-career-songs-net-worth/ Mawhoo (Nontobeko Thandeka Ngema) Biography, Early Life, Age, Career, Songs, Net Worth - KingMinds]&lt;/ref&gt;

U-Ngema uvele godu kumavidiyo womvumo amanengi, okufaka hlangana ukulingisa iindima eziqakathekileko. Ubuye waba yimodeli yamabhrendi ngaphakathi nangaphandle kweSewula Afrika.&lt;ref&gt;[https://www.bona.co.za/entertainment/mawhoos-shocking-revelation-american-a-listers-who-slid-into-her-dms/ Mawhoo's shocking revelation! American A-listers who slid into her DMs | Bona Magazine]&lt;/ref&gt; Usebenze ne-Tribe Afrique, House of Supreme, kanye ne-Convoy Clothing South Africa.&lt;ref&gt;[[:en:MaWhoo|MaWhoo - Wikipedia]]&lt;/ref&gt; Usebenzisane nabantu abafana no -DJ Maphorisa, u-Master KG, u-Tsisto, u-Kabza De Small no-Vigro Deep.   

Ngaphandle kwelizwe lakwabo, u-Ngema sele adlale emazweni we-Afrika afana ne [[Botswana|-Botswana]], [[Eswatini|i-Eswatini]], [[Zimbabwe|i-Zimbabwe]] ne [[Mozambique|-Mozambique]].   

== Isendlalelo ==

=== Ipilo yokuthoma ===
U-Thandeka Nontobeko Ngema wabelethwa mhlana amalanga ali-16 kuNobayeni ngo1994 e- Eshowe, KwaZulu-Natal, eSewula Afrika. Wathoma umsebenzi wakhe womvumo asesemncani. Lokha nakaneminyaka elitjhumi nanye, wathatha ingoma yakhe erekhodiweko wayisa emsakazweni wendawo bona idlalwe emoyeni kodwana akhenge bamvumele ngombana bekasesemncani khulu.  

==== Amagama wesiteji ====
Engcocweni, wabelane ngokuthi ibizo lakhe lesiteji litjho &quot;umlingo&quot; ngelimi lesiJapan . Watjho  bona ibizo lavela ngo-Okmalumkoolcat.  

=== Ifundo ===
U-Ngema unesiqu asifumene e- University of South Africa (i-UNISA). 

== Ibizelo ==
Ingoma yakhe ethi &quot;Bengicela&quot; no-GL_Ceekay, i-Thukuthela ene-Jazzworx yakhutjhwa mhlana amalanga ali-13 kuMgwengweni 2025.&lt;ref&gt;{{Cite web|last=Rethabile|first=Thandi|date=2025-06-05|title=MaWhoo, GL_Ceejay &amp; Thukuthela – Bengicela (Tholukuthi ) ft. JazzWorx|url=https://ceemuzic.com/music/mawhoo-gl-ceejay-thukuthela-bengicela-tholukuthi-ft-jazzworx-m66/|access-date=2025-09-04|website=CeeMuzic|language=en}}&lt;/ref&gt;  Yafika endaweni yokuthoma ematjhadini we-Apple Music, ingoma edumileko ku-YouTube, ingoma ethandwa khulu ku-Shazam begodu yingoma yesihlanu kumatjhadi weengoma eziphezulu ze-Spotify ngokulandelana. 

== Ukuphikisana ==
Ngo-2024 ngesikhathi sokukhulumisana no-L-Tido, u-Ngema waveza bona unamadoda amanengi ku-akhawunti yakhe yezokuthintana amthintako, okufaka hlangana umrepha u-Lil Wayne, u-Jay Z no -Rick Ross .  Abalandeli bakhe bamgandelela bona afakazele bona lokhu kuliqiniso na, lapho uNgema abelana khona ngesithombe sengcoco no-Lil Wayne.  

== I-Discography ==

=== Ama-albhamu we-studio ===

* What a time to be alive (2022)
* ''The chosen'' (2023)
* ''The sound of magic''(2024)
* Amazwi Okubonga (2025)

== Abangakathathi ==

=== Njengomdwebi odosa phambili ===
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+List of singles as lead artist, with selected chart positions and certifications, showing year released and album name
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Title
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Year
! colspan=&quot;1&quot; scope=&quot;col&quot; |Peak chart positions
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; |Certifications
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Album
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; |ZA&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; |&quot;Umshado&quot; (featuring Heavy-K)
|2019
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Ngiyamthanda&quot; (MaWhoo, Master KG featuring Lowsheen)
| rowspan=&quot;2&quot; |2021
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Inkanyezi&quot; (MaWhoo, Master KG  featuring Lowsheen)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Ngithakazele&quot; (MaWhoo, DJ Fanzy featuring Andry K)
| rowspan=&quot;4&quot; |2022
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Ngithakazele&quot;
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;10k Ye McDonald's&quot; (MaWhoo featuring Mdoovar, 9umba)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Thokoza&quot; (Sam Deep, MaWhoo)
|—
|RiSA: 2× Platinum 
|''Ace of Spades''
|-
! scope=&quot;row&quot; |&quot;Umlilo&quot; (DJ Ngwazi, Pouler D’musiq, MaWhoo)
| rowspan=&quot;5&quot; |2023
|—
|
|
|-
! scope=&quot;row&quot; |&quot;Nduma Ndumane&quot; (MaWhoo, Kabza De Small, DJ Maphorisa featuring Da Muziqal Chef)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Bayangzonda&quot; (Mac Lopez, MaWhoo)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;NgizoWela&quot; (Slade, MaWhoo, Tycoon featuring Marcus MC, Stacy)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Ngifunani&quot; (Femi Large, MaWhoo)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Imizi Yobaba&quot; (Soulfreakah, MaWhoo)
| rowspan=&quot;2&quot; |2024


|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Uthukela&quot; (MaWhoo featuring Harry Cane, Eemoh)
|_
|
|{{non-album single}}
|-
!&quot;Gucci&quot; (Mthandeni SK featuring MaWhoo)
|
|_
|
|Non-album single
|-
!&quot;Ngeke&quot; (Yumbs, Zwayetoven &amp; MaWhoo featuring Mthunzi)
|
|_
|
|Non-album single
|-
!&quot;Khuluma&quot; (Oskido, Master KG &amp; MaWhoo featuring Lilyfaith, Lowsheen &amp; Theo Kgosinkwe)
|
|_
|
|Non-album single
|-
!&quot;Uzizwa Kanjan' (Jazzworx, Thukuthela, MaWhoo &amp; GL_Ceejay)
|2025
|5
|
|Non-album single
|-
!&quot;Ziphi Nkomo&quot; (Sir Trill, MaWhoo &amp; B33kay SA featuring DJ 2k, Frank Mabeat &amp; Tumisho)
|
|_
|
|Non-album single
|-
!&quot;Phakade Lami&quot; (Da Capo, Soul Star &amp; MaWhoo)
|
|_
|
|Non-album single
|-
!&quot;Bengicela&quot; (MaWhoo, GL_ Ceejay &amp; Thukuthela featuring Jazzworx)
|
|1
|
|Amazwi Okubonga
|-
!&quot;Smomondiya&quot; (Frank Mabeat &amp; MaWhoo featuring B33kay SA)
|
|_
|
|Non-album single
|-
!&quot;Sono Sam&quot; (TBO, MaWhoo &amp; Ntsika featuring Ngwato &amp; Ave Songsmith)
|
|_
|
|Non-album single
|-
!&quot;MA AFRIKA&quot; (Deep Sen, MaWhoo &amp; M.J featuring Ntando Yamahlubi)
|
|_
|
|Non-album single
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; |&quot;—&quot; denotes a recording that did not chart or was not released in that territory.
|}
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+Irhelo lama-single njengabaculi abaveziweko, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;Moya Wami&quot; (u-Oscar Mbo ahlanganisa u-MaWhoo)
| rowspan=&quot;2&quot; | 2020
| —
| Irhawuda
| ''Kwama-Groovists''
|-
! scope=&quot;row&quot; | &quot;Bambelela&quot; (i-Caltonic SA ehlanganisa u-Sje Konka, u-MaWhoo, u-Thabz Le Madonga)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Uqobo Lwami&quot; (u-DJ Fanzy ohlanganisa u-MaWhoo)
| 2021
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ikhadi le-Indoda Nge&quot; (DJ Moscow, Deepsen, Eddie The Vocalist feat. DJ Moscow, MaWhoo)
| rowspan=&quot;2&quot; | 2022
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Khumbul' Ekhaya&quot; (u-Knowley-D ohlanganisa u-Busta 929, u-MaWhoo)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Dali Wam&quot; (Pabi Cooper, Yumbs ehlanganisa uMaWhoo, uNkosazana Daughter )
| rowspan=&quot;9&quot; | 2023
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Isthutha&quot; (Inkinga Abangan Bam)&quot; (Sam Deep, De Mthuda ehlanganisa uMawhoo, Mkeyz)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ungiphethe Kahle&quot; (Kabza De Small, DJ Maphorisa ahlanganisa uNokwazi, MaWhoo, Mashudu &amp; LeeArt)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Noma Kanjani&quot; (u-Sino Msolo ohlanganisa u-Kabza De Small, u-MaWhoo, u-Azana)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Uthando&quot; (I-Groovist ehlanganisa u-MaWhoo)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Zibonakalise&quot; (ama-HK ahlanganisa u-MaWhoo)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Wena My Dali&quot; (I-Focalistic featuring Ch'cco, MaWhoo, EeQue, Thama Tee)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Impilo&quot; (u-Marlode no-Owams abahlanganisa ama-2woBunnies, u-MaWhoo, u-Leandra.Vert, u-Toby Franco, u-Gilano, u-Sponge 101)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Kutsa&quot; (u-DJ Sliqe ahlanganisa u-Yanga Chief, u-MaWhoo, u-2woshort, u-Makwa)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ungithandile&quot; (u-Baby Momo ohlanganisa u-MaWhoo, u-Ceenday, u-Jay Sax, u-Shino Kikai, u-DJ 2K)
| rowspan=&quot;6&quot; | 2024
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ngifa Nawe&quot; (MFR Souls, Kabza De Small ene-MaWhoo, Bassie, T-Man SA, Shane907)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Amabhoza&quot; ( Aymos, Mas Musiq featuring MaWhoo)
| —
|
| ''Impilo''
|-
! scope=&quot;row&quot; | &quot;Ematshwaleni&quot; ( Kususa, Anatti featuring MaWhoo, Noxolo Ngema, King Deetoy)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Injabulo&quot; (u-Lily Faith ahlanganisa u-Theo Kgosinkwe, u-X-Wise, u-Oskido, u-MaWhoo)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Gucci&quot; (Mthandeni SK, ehlanganisa u-MaWhoo)
| 1  
||{{non-album single}} 
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; | &quot;—&quot; kutjho ukurekhoda okungazange kushadi namkha okungakakhutjhwa endaweni leyo.
|}
{| class=&quot;wikitable plainrowheaders&quot; border=&quot;1&quot; style=&quot;text-align:center;&quot;
|+Irhelo lezinye iingoma ezitjhadiweko, ezineendawo ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;Kulula&quot; (Mawhoo, DJ Maphorisa, Kabza De Small)
| 2022
| —
| Igolide 
| ''Yisikhathi esingangani sokuphila''
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; | &quot;—&quot; kutjho ukurekhoda okungazange kushadi namkha okungakakhutjhwa endaweni leyo.
|}

== Ipilo yomuntu mathupha ==
Kube nemibiko yokuthi uNgema uthandana noHlubi Nkosi.   Iinthandani bezibikwe bona zinikelana ngezipho.  

== Imithombo lwazi ==

# &lt;ref&gt;[https://www.bona.co.za/entertainment/mawhoos-shocking-revelation-american-a-listers-who-slid-into-her-dms/ Mawhoo's shocking revelation! American A-listers who slid into her DMs | Bona Magazine]&lt;/ref&gt;
# &lt;ref&gt;[https://slikouronlife.co.za/blog/24023/mawhoos-kulula-surpasses-1-million-streams/ MaWhoo's 'Kulula' Surpasses 1 Million Streams | Slikouronlife]&lt;/ref&gt;</text>
      <sha1>cni5qnsmkjwldwp2u580bpms8cx8r3x</sha1>
    </revision>
    <revision>
      <id>5689</id>
      <parentid>5635</parentid>
      <timestamp>2025-09-04T11:38:09Z</timestamp>
      <contributor>
        <username>Nothi2003</username>
        <id>833</id>
      </contributor>
      <comment>edited</comment>
      <origin>5689</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="10781" sha1="fr884bxkohywhm5dhklj3ucko6irufd" xml:space="preserve"> 
[[Isimumathi:Maker Faire, Berlin (BL7C0113).jpg|thumb|indawo lapha u-Mawhoo aqulela khona abantu.]]
'''U-Thandeka Nontobeko Ngema''' (wabelethwa mhlana amalanga ali-16 kuNobayeni 1994), owaziwa ngokuthi '''ngu-MaWhoo''', mquli nomtloli weengoma weSewula Afrika.&lt;ref&gt;[https://slikouronlife.co.za/blog/24023/mawhoos-kulula-surpasses-1-million-streams/ MaWhoo's 'Kulula' Surpasses 1 Million Streams | Slikouronlife]&lt;/ref&gt; Wathola ukuhlonitjhwa okukhulu ngemva kokukhipha ingoma yakhe yokuthoma ethi &quot;Umshado&quot; leno- Heavy-K.&lt;ref&gt;[https://kingminds.net/mawhoo-nontobeko-thandeka-ngema-biography-early-life-age-career-songs-net-worth/ Mawhoo (Nontobeko Thandeka Ngema) Biography, Early Life, Age, Career, Songs, Net Worth - KingMinds]&lt;/ref&gt;

U-Ngema uvele godu kumavidiyo womvumo amanengi, okufaka hlangana ukulingisa iindima eziqakathekileko. Ubuye waba yimodeli yamabhrendi ngaphakathi nangaphandle kweSewula Afrika.&lt;ref&gt;[https://www.bona.co.za/entertainment/mawhoos-shocking-revelation-american-a-listers-who-slid-into-her-dms/ Mawhoo's shocking revelation! American A-listers who slid into her DMs | Bona Magazine]&lt;/ref&gt; Usebenze ne-Tribe Afrique, House of Supreme, kanye ne-Convoy Clothing South Africa.&lt;ref&gt;[[:en:MaWhoo|MaWhoo - Wikipedia]]&lt;/ref&gt; Usebenzisane nabantu abafana no -DJ Maphorisa, u-Master KG, u-Tsisto, u-Kabza De Small no-Vigro Deep.   

Ngaphandle kwelizwe lakwabo, u-Ngema sele adlale emazweni we-Afrika afana ne [[Botswana|-Botswana]], [[Eswatini|i-Eswatini]], [[Zimbabwe|i-Zimbabwe]] ne [[Mozambique|-Mozambique]].   

== Isendlalelo ==

=== Ipilo yokuthoma ===
U-Thandeka Nontobeko Ngema wabelethwa mhlana amalanga ali-16 kuNobayeni ngo1994 e- Eshowe, KwaZulu-Natal, eSewula Afrika. Wathoma umsebenzi wakhe womvumo asesemncani. Lokha nakaneminyaka elitjhumi nanye, wathatha ingoma yakhe erekhodiweko wayisa emsakazweni wendawo bona idlalwe emoyeni kodwana akhenge bamvumele ngombana bekasesemncani khulu.  

==== Amagama wesiteji ====
Engcocweni, wabelane ngokuthi ibizo lakhe lesiteji litjho &quot;umlingo&quot; ngelimi lesiJapan . Watjho  bona ibizo lavela ngo-Okmalumkoolcat.  

=== Ifundo ===
U-Ngema unesiqu asifumene e- University of South Africa (i-UNISA). 

== Ibizelo ==
Ingoma yakhe ethi &quot;Bengicela&quot; no-GL_Ceekay, i-Thukuthela ene-Jazzworx yakhutjhwa mhlana amalanga ali-13 kuMgwengweni 2025.&lt;ref&gt;{{Cite web|last=Rethabile|first=Thandi|date=2025-06-05|title=MaWhoo, GL_Ceejay &amp; Thukuthela – Bengicela (Tholukuthi ) ft. JazzWorx|url=https://ceemuzic.com/music/mawhoo-gl-ceejay-thukuthela-bengicela-tholukuthi-ft-jazzworx-m66/|access-date=2025-09-04|website=CeeMuzic|language=en}}&lt;/ref&gt;  Yafika endaweni yokuthoma ematjhadini we-Apple Music, ingoma edumileko ku-YouTube, ingoma ethandwa khulu ku-Shazam begodu yingoma yesihlanu kumatjhadi weengoma eziphezulu ze-Spotify ngokulandelana. 

== Ukuphikisana ==
Ngo-2024 ngesikhathi sokukhulumisana no-L-Tido, u-Ngema waveza bona unamadoda amanengi ku-akhawunti yakhe yezokuthintana amthintako, okufaka hlangana umrepha u-Lil Wayne, u-Jay Z no -Rick Ross.  Abalandeli bakhe bamgandelela bona afakazele bona lokhu kuliqiniso na, lapho uNgema abelana khona ngesithombe sengcoco no-Lil Wayne.  

== I-Discography ==

=== Ama-albhamu we-studio ===

* What a time to be alive (2022)
* ''The chosen'' (2023)
* ''The sound of magic'' (2024)
* Amazwi Okubonga (2025)

== Abangakathathi ==

=== Njengomdwebi odosa phambili ===
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+List of singles as lead artist, with selected chart positions and certifications, showing year released and album name
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Title
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Year
! colspan=&quot;1&quot; scope=&quot;col&quot; |Peak chart positions
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; |Certifications
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Album
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; |ZA&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; |&quot;Umshado&quot; (featuring Heavy-K)
|2019
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Ngiyamthanda&quot; (MaWhoo, Master KG featuring Lowsheen)
| rowspan=&quot;2&quot; |2021
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Inkanyezi&quot; (MaWhoo, Master KG  featuring Lowsheen)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Ngithakazele&quot; (MaWhoo, DJ Fanzy featuring Andry K)
| rowspan=&quot;4&quot; |2022
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Ngithakazele&quot;
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;10k Ye McDonald's&quot; (MaWhoo featuring Mdoovar, 9umba)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Thokoza&quot; (Sam Deep, MaWhoo)
|—
|RiSA: 2× Platinum 
|''Ace of Spades''
|-
! scope=&quot;row&quot; |&quot;Umlilo&quot; (DJ Ngwazi, Pouler D’musiq, MaWhoo)
| rowspan=&quot;5&quot; |2023
|—
|
|
|-
! scope=&quot;row&quot; |&quot;Nduma Ndumane&quot; (MaWhoo, Kabza De Small, DJ Maphorisa featuring Da Muziqal Chef)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Bayangzonda&quot; (Mac Lopez, MaWhoo)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;NgizoWela&quot; (Slade, MaWhoo, Tycoon featuring Marcus MC, Stacy)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Ngifunani&quot; (Femi Large, MaWhoo)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Imizi Yobaba&quot; (Soulfreakah, MaWhoo)
| rowspan=&quot;2&quot; |2024


|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Uthukela&quot; (MaWhoo featuring Harry Cane, Eemoh)
|_
|
|{{non-album single}}
|-
!&quot;Gucci&quot; (Mthandeni SK featuring MaWhoo)
|
|_
|
|Non-album single
|-
!&quot;Ngeke&quot; (Yumbs, Zwayetoven &amp; MaWhoo featuring Mthunzi)
|
|_
|
|Non-album single
|-
!&quot;Khuluma&quot; (Oskido, Master KG &amp; MaWhoo featuring Lilyfaith, Lowsheen &amp; Theo Kgosinkwe)
|
|_
|
|Non-album single
|-
!&quot;Uzizwa Kanjan' (Jazzworx, Thukuthela, MaWhoo &amp; GL_Ceejay)
|2025
|5
|
|Non-album single
|-
!&quot;Ziphi Nkomo&quot; (Sir Trill, MaWhoo &amp; B33kay SA featuring DJ 2k, Frank Mabeat &amp; Tumisho)
|
|_
|
|Non-album single
|-
!&quot;Phakade Lami&quot; (Da Capo, Soul Star &amp; MaWhoo)
|
|_
|
|Non-album single
|-
!&quot;Bengicela&quot; (MaWhoo, GL_ Ceejay &amp; Thukuthela featuring Jazzworx)
|
|1
|
|Amazwi Okubonga
|-
!&quot;Smomondiya&quot; (Frank Mabeat &amp; MaWhoo featuring B33kay SA)
|
|_
|
|Non-album single
|-
!&quot;Sono Sam&quot; (TBO, MaWhoo &amp; Ntsika featuring Ngwato &amp; Ave Songsmith)
|
|_
|
|Non-album single
|-
!&quot;MA AFRIKA&quot; (Deep Sen, MaWhoo &amp; M.J featuring Ntando Yamahlubi)
|
|_
|
|Non-album single
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; |&quot;—&quot; denotes a recording that did not chart or was not released in that territory.
|}
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+Irhelo lama-single njengabaculi abaveziweko, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;Moya Wami&quot; (u-Oscar Mbo ahlanganisa u-MaWhoo)
| rowspan=&quot;2&quot; | 2020
| —
| Irhawuda
| ''Kwama-Groovists''
|-
! scope=&quot;row&quot; | &quot;Bambelela&quot; (i-Caltonic SA ehlanganisa u-Sje Konka, u-MaWhoo, u-Thabz Le Madonga)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Uqobo Lwami&quot; (u-DJ Fanzy ohlanganisa u-MaWhoo)
| 2021
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ikhadi le-Indoda Nge&quot; (DJ Moscow, Deepsen, Eddie The Vocalist feat. DJ Moscow, MaWhoo)
| rowspan=&quot;2&quot; | 2022
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Khumbul' Ekhaya&quot; (u-Knowley-D ohlanganisa u-Busta 929, u-MaWhoo)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Dali Wam&quot; (Pabi Cooper, Yumbs ehlanganisa uMaWhoo, uNkosazana Daughter )
| rowspan=&quot;9&quot; | 2023
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Isthutha&quot; (Inkinga Abangan Bam)&quot; (Sam Deep, De Mthuda ehlanganisa uMawhoo, Mkeyz)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ungiphethe Kahle&quot; (Kabza De Small, DJ Maphorisa ahlanganisa uNokwazi, MaWhoo, Mashudu &amp; LeeArt)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Noma Kanjani&quot; (u-Sino Msolo ohlanganisa u-Kabza De Small, u-MaWhoo, u-Azana)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Uthando&quot; (I-Groovist ehlanganisa u-MaWhoo)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Zibonakalise&quot; (ama-HK ahlanganisa u-MaWhoo)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Wena My Dali&quot; (I-Focalistic featuring Ch'cco, MaWhoo, EeQue, Thama Tee)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Impilo&quot; (u-Marlode no-Owams abahlanganisa ama-2woBunnies, u-MaWhoo, u-Leandra.Vert, u-Toby Franco, u-Gilano, u-Sponge 101)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Kutsa&quot; (u-DJ Sliqe ahlanganisa u-Yanga Chief, u-MaWhoo, u-2woshort, u-Makwa)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ungithandile&quot; (u-Baby Momo ohlanganisa u-MaWhoo, u-Ceenday, u-Jay Sax, u-Shino Kikai, u-DJ 2K)
| rowspan=&quot;6&quot; | 2024
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ngifa Nawe&quot; (MFR Souls, Kabza De Small ene-MaWhoo, Bassie, T-Man SA, Shane907)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Amabhoza&quot; ( Aymos, Mas Musiq featuring MaWhoo)
| —
|
| ''Impilo''
|-
! scope=&quot;row&quot; | &quot;Ematshwaleni&quot; ( Kususa, Anatti featuring MaWhoo, Noxolo Ngema, King Deetoy)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Injabulo&quot; (u-Lily Faith ahlanganisa u-Theo Kgosinkwe, u-X-Wise, u-Oskido, u-MaWhoo)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Gucci&quot; (Mthandeni SK, ehlanganisa u-MaWhoo)
| 1  
||{{non-album single}} 
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; | &quot;—&quot; kutjho ukurekhoda okungazange kushadi namkha okungakakhutjhwa endaweni leyo.
|}
{| class=&quot;wikitable plainrowheaders&quot; border=&quot;1&quot; style=&quot;text-align:center;&quot;
|+Irhelo lezinye iingoma ezitjhadiweko, ezineendawo ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;Kulula&quot; (Mawhoo, DJ Maphorisa, Kabza De Small)
| 2022
| —
| Igolide 
| ''Yisikhathi esingangani sokuphila''
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; | &quot;—&quot; kutjho ukurekhoda okungazange kushadi namkha okungakakhutjhwa endaweni leyo.
|}

== Ipilo yomuntu mathupha ==
Kube nemibiko yokuthi uNgema uthandana noHlubi Nkosi. Iinthandani bezibikwe bona zinikelana ngezipho.  

== Imithombo lwazi ==

# &lt;ref&gt;[https://www.bona.co.za/entertainment/mawhoos-shocking-revelation-american-a-listers-who-slid-into-her-dms/ Mawhoo's shocking revelation! American A-listers who slid into her DMs | Bona Magazine]&lt;/ref&gt;
# &lt;ref&gt;[https://slikouronlife.co.za/blog/24023/mawhoos-kulula-surpasses-1-million-streams/ MaWhoo's 'Kulula' Surpasses 1 Million Streams | Slikouronlife]&lt;/ref&gt;</text>
      <sha1>fr884bxkohywhm5dhklj3ucko6irufd</sha1>
    </revision>
    <revision>
      <id>6009</id>
      <parentid>5689</parentid>
      <timestamp>2025-11-19T16:28:57Z</timestamp>
      <contributor>
        <username>~2025-34856-96</username>
        <id>1140</id>
      </contributor>
      <origin>6009</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="10897" sha1="auhmp45uh8tnw62p37uvksslqgmqxo1" xml:space="preserve"> 
[[Isimumathi:Maker Faire, Berlin (BL7C0113).jpg|thumb|indawo lapha u-Mawhoo aqulela khona abantu.]]
'''U-Thandeka Nontobeko Ngema''' (wabelethwa mhlana amalanga ali-16 kuNobayeni 1994), owaziwa ngokuthi '''ngu-MaWhoo''', mquli nomtloli weengoma weSewula Afrika.&lt;ref&gt;[https://slikouronlife.co.za/blog/24023/mawhoos-kulula-surpasses-1-million-streams/ MaWhoo's 'Kulula' Surpasses 1 Million Streams | Slikouronlife]&lt;/ref&gt; Wathola ukuhlonitjhwa okukhulu ngemva kokukhipha ingoma yakhe yokuthoma ethi &quot;Umshado&quot; leno- Heavy-K.&lt;ref&gt;[https://kingminds.net/mawhoo-nontobeko-thandeka-ngema-biography-early-life-age-career-songs-net-worth/ Mawhoo (Nontobeko Thandeka Ngema) Biography, Early Life, Age, Career, Songs, Net Worth - KingMinds]&lt;/ref&gt;

U-Ngema uvele godu kumavidiyo womvumo amanengi, okufaka hlangana ukulingisa iindima eziqakathekileko. Ubuye waba yimodeli yamabhrendi ngaphakathi nangaphandle kweSewula Afrika.&lt;ref&gt;[https://www.bona.co.za/entertainment/mawhoos-shocking-revelation-american-a-listers-who-slid-into-her-dms/ Mawhoo's shocking revelation! American A-listers who slid into her DMs | Bona Magazine]&lt;/ref&gt; Usebenze ne-Tribe Afrique, House of Supreme, kanye ne-Convoy Clothing South Africa.&lt;ref&gt;[[:en:MaWhoo|MaWhoo - Wikipedia]]&lt;/ref&gt; Usebenzisane nabantu abafana no -DJ Maphorisa, u-Master KG, u-Tsisto, u-Kabza De Small no-Vigro Deep.   

Ngaphandle kwelizwe lakwabo, u-Ngema sele adlale emazweni we-Afrika afana ne [[Botswana|-Botswana]], [[Eswatini|i-Eswatini]], [[Zimbabwe|i-Zimbabwe]] ne [[Mozambique|-Mozambique]].   

== Isendlalelo ==

=== Ipilo yokuthoma ===
U-Thandeka Nontobeko Ngema wabelethwa mhlana amalanga ali-16 kuNobayeni ngo1994 e- Eshowe, KwaZulu-Natal, eSewula Afrika. Wathoma umsebenzi wakhe womvumo asesemncani. Lokha nakaneminyaka elitjhumi nanye, wathatha ingoma yakhe erekhodiweko wayisa emsakazweni wendawo bona idlalwe emoyeni kodwana akhenge bamvumele ngombana bekasesemncani khulu.  

==== Amagama wesiteji ====
Engcocweni, wabelane ngokuthi ibizo lakhe lesiteji litjho &quot;umlingo&quot; ngelimi lesiJapan . Watjho  bona ibizo lavela ngo-Okmalumkoolcat.  

=== Ifundo ===
U-Ngema unesiqu asifumene e- University of South Africa (i-UNISA). 

== Ibizelo ==
Ingoma yakhe ethi &quot;Bengicela&quot; no-GL_Ceekay, i-Thukuthela ene-Jazzworx yakhutjhwa mhlana amalanga ali-13 kuMgwengweni 2025.&lt;ref&gt;{{Cite web|last=Rethabile|first=Thandi|date=2025-06-05|title=MaWhoo, GL_Ceejay &amp; Thukuthela – Bengicela (Tholukuthi ) ft. JazzWorx|url=https://ceemuzic.com/music/mawhoo-gl-ceejay-thukuthela-bengicela-tholukuthi-ft-jazzworx-m66/|access-date=2025-09-04|website=CeeMuzic|language=en}}&lt;/ref&gt;  Yafika endaweni yokuthoma ematjhadini we-Apple Music, ingoma edumileko ku-YouTube, ingoma ethandwa khulu ku-Shazam begodu yingoma yesihlanu kumatjhadi weengoma eziphezulu ze-Spotify ngokulandelana.&lt;ref&gt;https://ceemuzic.co.za/celebrity-gist/four-for-mawhoo-star-bags-multiple-ukhozi-fm-song-of-the-year-noms/&lt;/ref&gt; 

== Ukuphikisana ==
Ngo-2024 ngesikhathi sokukhulumisana no-L-Tido, u-Ngema waveza bona unamadoda amanengi ku-akhawunti yakhe yezokuthintana amthintako, okufaka hlangana umrepha u-Lil Wayne, u-Jay Z no -Rick Ross.  Abalandeli bakhe bamgandelela bona afakazele bona lokhu kuliqiniso na, lapho uNgema abelana khona ngesithombe sengcoco no-Lil Wayne.  

== I-Discography ==

=== Ama-albhamu we-studio ===

* What a time to be alive (2022)
* ''The chosen'' (2023)
* ''The sound of magic'' (2024)
* Amazwi Okubonga (2025)

== Abangakathathi ==

=== Njengomdwebi odosa phambili ===
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+List of singles as lead artist, with selected chart positions and certifications, showing year released and album name
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Title
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Year
! colspan=&quot;1&quot; scope=&quot;col&quot; |Peak chart positions
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; |Certifications
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Album
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; |ZA&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; |&quot;Umshado&quot; (featuring Heavy-K)
|2019
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Ngiyamthanda&quot; (MaWhoo, Master KG featuring Lowsheen)
| rowspan=&quot;2&quot; |2021
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Inkanyezi&quot; (MaWhoo, Master KG  featuring Lowsheen)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Ngithakazele&quot; (MaWhoo, DJ Fanzy featuring Andry K)
| rowspan=&quot;4&quot; |2022
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Ngithakazele&quot;
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;10k Ye McDonald's&quot; (MaWhoo featuring Mdoovar, 9umba)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Thokoza&quot; (Sam Deep, MaWhoo)
|—
|RiSA: 2× Platinum 
|''Ace of Spades''
|-
! scope=&quot;row&quot; |&quot;Umlilo&quot; (DJ Ngwazi, Pouler D’musiq, MaWhoo)
| rowspan=&quot;5&quot; |2023
|—
|
|
|-
! scope=&quot;row&quot; |&quot;Nduma Ndumane&quot; (MaWhoo, Kabza De Small, DJ Maphorisa featuring Da Muziqal Chef)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Bayangzonda&quot; (Mac Lopez, MaWhoo)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;NgizoWela&quot; (Slade, MaWhoo, Tycoon featuring Marcus MC, Stacy)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Ngifunani&quot; (Femi Large, MaWhoo)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Imizi Yobaba&quot; (Soulfreakah, MaWhoo)
| rowspan=&quot;2&quot; |2024


|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Uthukela&quot; (MaWhoo featuring Harry Cane, Eemoh)
|_
|
|{{non-album single}}
|-
!&quot;Gucci&quot; (Mthandeni SK featuring MaWhoo)
|
|_
|
|Non-album single
|-
!&quot;Ngeke&quot; (Yumbs, Zwayetoven &amp; MaWhoo featuring Mthunzi)
|
|_
|
|Non-album single
|-
!&quot;Khuluma&quot; (Oskido, Master KG &amp; MaWhoo featuring Lilyfaith, Lowsheen &amp; Theo Kgosinkwe)
|
|_
|
|Non-album single
|-
!&quot;Uzizwa Kanjan' (Jazzworx, Thukuthela, MaWhoo &amp; GL_Ceejay)
|2025
|5
|
|Non-album single
|-
!&quot;Ziphi Nkomo&quot; (Sir Trill, MaWhoo &amp; B33kay SA featuring DJ 2k, Frank Mabeat &amp; Tumisho)
|
|_
|
|Non-album single
|-
!&quot;Phakade Lami&quot; (Da Capo, Soul Star &amp; MaWhoo)
|
|_
|
|Non-album single
|-
!&quot;Bengicela&quot; (MaWhoo, GL_ Ceejay &amp; Thukuthela featuring Jazzworx)
|
|1
|
|Amazwi Okubonga
|-
!&quot;Smomondiya&quot; (Frank Mabeat &amp; MaWhoo featuring B33kay SA)
|
|_
|
|Non-album single
|-
!&quot;Sono Sam&quot; (TBO, MaWhoo &amp; Ntsika featuring Ngwato &amp; Ave Songsmith)
|
|_
|
|Non-album single
|-
!&quot;MA AFRIKA&quot; (Deep Sen, MaWhoo &amp; M.J featuring Ntando Yamahlubi)
|
|_
|
|Non-album single
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; |&quot;—&quot; denotes a recording that did not chart or was not released in that territory.
|}
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+Irhelo lama-single njengabaculi abaveziweko, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;Moya Wami&quot; (u-Oscar Mbo ahlanganisa u-MaWhoo)
| rowspan=&quot;2&quot; | 2020
| —
| Irhawuda
| ''Kwama-Groovists''
|-
! scope=&quot;row&quot; | &quot;Bambelela&quot; (i-Caltonic SA ehlanganisa u-Sje Konka, u-MaWhoo, u-Thabz Le Madonga)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Uqobo Lwami&quot; (u-DJ Fanzy ohlanganisa u-MaWhoo)
| 2021
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ikhadi le-Indoda Nge&quot; (DJ Moscow, Deepsen, Eddie The Vocalist feat. DJ Moscow, MaWhoo)
| rowspan=&quot;2&quot; | 2022
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Khumbul' Ekhaya&quot; (u-Knowley-D ohlanganisa u-Busta 929, u-MaWhoo)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Dali Wam&quot; (Pabi Cooper, Yumbs ehlanganisa uMaWhoo, uNkosazana Daughter )
| rowspan=&quot;9&quot; | 2023
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Isthutha&quot; (Inkinga Abangan Bam)&quot; (Sam Deep, De Mthuda ehlanganisa uMawhoo, Mkeyz)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ungiphethe Kahle&quot; (Kabza De Small, DJ Maphorisa ahlanganisa uNokwazi, MaWhoo, Mashudu &amp; LeeArt)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Noma Kanjani&quot; (u-Sino Msolo ohlanganisa u-Kabza De Small, u-MaWhoo, u-Azana)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Uthando&quot; (I-Groovist ehlanganisa u-MaWhoo)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Zibonakalise&quot; (ama-HK ahlanganisa u-MaWhoo)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Wena My Dali&quot; (I-Focalistic featuring Ch'cco, MaWhoo, EeQue, Thama Tee)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Impilo&quot; (u-Marlode no-Owams abahlanganisa ama-2woBunnies, u-MaWhoo, u-Leandra.Vert, u-Toby Franco, u-Gilano, u-Sponge 101)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Kutsa&quot; (u-DJ Sliqe ahlanganisa u-Yanga Chief, u-MaWhoo, u-2woshort, u-Makwa)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ungithandile&quot; (u-Baby Momo ohlanganisa u-MaWhoo, u-Ceenday, u-Jay Sax, u-Shino Kikai, u-DJ 2K)
| rowspan=&quot;6&quot; | 2024
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ngifa Nawe&quot; (MFR Souls, Kabza De Small ene-MaWhoo, Bassie, T-Man SA, Shane907)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Amabhoza&quot; ( Aymos, Mas Musiq featuring MaWhoo)
| —
|
| ''Impilo''
|-
! scope=&quot;row&quot; | &quot;Ematshwaleni&quot; ( Kususa, Anatti featuring MaWhoo, Noxolo Ngema, King Deetoy)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Injabulo&quot; (u-Lily Faith ahlanganisa u-Theo Kgosinkwe, u-X-Wise, u-Oskido, u-MaWhoo)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Gucci&quot; (Mthandeni SK, ehlanganisa u-MaWhoo)
| 1  
||{{non-album single}} 
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; | &quot;—&quot; kutjho ukurekhoda okungazange kushadi namkha okungakakhutjhwa endaweni leyo.
|}
{| class=&quot;wikitable plainrowheaders&quot; border=&quot;1&quot; style=&quot;text-align:center;&quot;
|+Irhelo lezinye iingoma ezitjhadiweko, ezineendawo ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;Kulula&quot; (Mawhoo, DJ Maphorisa, Kabza De Small)
| 2022
| —
| Igolide 
| ''Yisikhathi esingangani sokuphila''
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; | &quot;—&quot; kutjho ukurekhoda okungazange kushadi namkha okungakakhutjhwa endaweni leyo.
|}

== Ipilo yomuntu mathupha ==
Kube nemibiko yokuthi uNgema uthandana noHlubi Nkosi. Iinthandani bezibikwe bona zinikelana ngezipho.  

== Imithombo lwazi ==

# &lt;ref&gt;[https://www.bona.co.za/entertainment/mawhoos-shocking-revelation-american-a-listers-who-slid-into-her-dms/ Mawhoo's shocking revelation! American A-listers who slid into her DMs | Bona Magazine]&lt;/ref&gt;
# &lt;ref&gt;[https://slikouronlife.co.za/blog/24023/mawhoos-kulula-surpasses-1-million-streams/ MaWhoo's 'Kulula' Surpasses 1 Million Streams | Slikouronlife]&lt;/ref&gt;</text>
      <sha1>auhmp45uh8tnw62p37uvksslqgmqxo1</sha1>
    </revision>
    <revision>
      <id>6304</id>
      <parentid>6009</parentid>
      <timestamp>2026-03-15T10:06:30Z</timestamp>
      <contributor>
        <username>Lp0 on fire</username>
        <id>1366</id>
      </contributor>
      <comment>Reverted 1 edit by [[Special:Contributions/~2025-34856-96|~2025-34856-96]] ([[User talk:~2025-34856-96|talk]]): Spam link (TwinkleGlobal)</comment>
      <origin>6304</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="10781" sha1="fr884bxkohywhm5dhklj3ucko6irufd" xml:space="preserve"> 
[[Isimumathi:Maker Faire, Berlin (BL7C0113).jpg|thumb|indawo lapha u-Mawhoo aqulela khona abantu.]]
'''U-Thandeka Nontobeko Ngema''' (wabelethwa mhlana amalanga ali-16 kuNobayeni 1994), owaziwa ngokuthi '''ngu-MaWhoo''', mquli nomtloli weengoma weSewula Afrika.&lt;ref&gt;[https://slikouronlife.co.za/blog/24023/mawhoos-kulula-surpasses-1-million-streams/ MaWhoo's 'Kulula' Surpasses 1 Million Streams | Slikouronlife]&lt;/ref&gt; Wathola ukuhlonitjhwa okukhulu ngemva kokukhipha ingoma yakhe yokuthoma ethi &quot;Umshado&quot; leno- Heavy-K.&lt;ref&gt;[https://kingminds.net/mawhoo-nontobeko-thandeka-ngema-biography-early-life-age-career-songs-net-worth/ Mawhoo (Nontobeko Thandeka Ngema) Biography, Early Life, Age, Career, Songs, Net Worth - KingMinds]&lt;/ref&gt;

U-Ngema uvele godu kumavidiyo womvumo amanengi, okufaka hlangana ukulingisa iindima eziqakathekileko. Ubuye waba yimodeli yamabhrendi ngaphakathi nangaphandle kweSewula Afrika.&lt;ref&gt;[https://www.bona.co.za/entertainment/mawhoos-shocking-revelation-american-a-listers-who-slid-into-her-dms/ Mawhoo's shocking revelation! American A-listers who slid into her DMs | Bona Magazine]&lt;/ref&gt; Usebenze ne-Tribe Afrique, House of Supreme, kanye ne-Convoy Clothing South Africa.&lt;ref&gt;[[:en:MaWhoo|MaWhoo - Wikipedia]]&lt;/ref&gt; Usebenzisane nabantu abafana no -DJ Maphorisa, u-Master KG, u-Tsisto, u-Kabza De Small no-Vigro Deep.   

Ngaphandle kwelizwe lakwabo, u-Ngema sele adlale emazweni we-Afrika afana ne [[Botswana|-Botswana]], [[Eswatini|i-Eswatini]], [[Zimbabwe|i-Zimbabwe]] ne [[Mozambique|-Mozambique]].   

== Isendlalelo ==

=== Ipilo yokuthoma ===
U-Thandeka Nontobeko Ngema wabelethwa mhlana amalanga ali-16 kuNobayeni ngo1994 e- Eshowe, KwaZulu-Natal, eSewula Afrika. Wathoma umsebenzi wakhe womvumo asesemncani. Lokha nakaneminyaka elitjhumi nanye, wathatha ingoma yakhe erekhodiweko wayisa emsakazweni wendawo bona idlalwe emoyeni kodwana akhenge bamvumele ngombana bekasesemncani khulu.  

==== Amagama wesiteji ====
Engcocweni, wabelane ngokuthi ibizo lakhe lesiteji litjho &quot;umlingo&quot; ngelimi lesiJapan . Watjho  bona ibizo lavela ngo-Okmalumkoolcat.  

=== Ifundo ===
U-Ngema unesiqu asifumene e- University of South Africa (i-UNISA). 

== Ibizelo ==
Ingoma yakhe ethi &quot;Bengicela&quot; no-GL_Ceekay, i-Thukuthela ene-Jazzworx yakhutjhwa mhlana amalanga ali-13 kuMgwengweni 2025.&lt;ref&gt;{{Cite web|last=Rethabile|first=Thandi|date=2025-06-05|title=MaWhoo, GL_Ceejay &amp; Thukuthela – Bengicela (Tholukuthi ) ft. JazzWorx|url=https://ceemuzic.com/music/mawhoo-gl-ceejay-thukuthela-bengicela-tholukuthi-ft-jazzworx-m66/|access-date=2025-09-04|website=CeeMuzic|language=en}}&lt;/ref&gt;  Yafika endaweni yokuthoma ematjhadini we-Apple Music, ingoma edumileko ku-YouTube, ingoma ethandwa khulu ku-Shazam begodu yingoma yesihlanu kumatjhadi weengoma eziphezulu ze-Spotify ngokulandelana. 

== Ukuphikisana ==
Ngo-2024 ngesikhathi sokukhulumisana no-L-Tido, u-Ngema waveza bona unamadoda amanengi ku-akhawunti yakhe yezokuthintana amthintako, okufaka hlangana umrepha u-Lil Wayne, u-Jay Z no -Rick Ross.  Abalandeli bakhe bamgandelela bona afakazele bona lokhu kuliqiniso na, lapho uNgema abelana khona ngesithombe sengcoco no-Lil Wayne.  

== I-Discography ==

=== Ama-albhamu we-studio ===

* What a time to be alive (2022)
* ''The chosen'' (2023)
* ''The sound of magic'' (2024)
* Amazwi Okubonga (2025)

== Abangakathathi ==

=== Njengomdwebi odosa phambili ===
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+List of singles as lead artist, with selected chart positions and certifications, showing year released and album name
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Title
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Year
! colspan=&quot;1&quot; scope=&quot;col&quot; |Peak chart positions
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; |Certifications
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Album
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; |ZA&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; |&quot;Umshado&quot; (featuring Heavy-K)
|2019
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Ngiyamthanda&quot; (MaWhoo, Master KG featuring Lowsheen)
| rowspan=&quot;2&quot; |2021
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Inkanyezi&quot; (MaWhoo, Master KG  featuring Lowsheen)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Ngithakazele&quot; (MaWhoo, DJ Fanzy featuring Andry K)
| rowspan=&quot;4&quot; |2022
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Ngithakazele&quot;
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;10k Ye McDonald's&quot; (MaWhoo featuring Mdoovar, 9umba)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Thokoza&quot; (Sam Deep, MaWhoo)
|—
|RiSA: 2× Platinum 
|''Ace of Spades''
|-
! scope=&quot;row&quot; |&quot;Umlilo&quot; (DJ Ngwazi, Pouler D’musiq, MaWhoo)
| rowspan=&quot;5&quot; |2023
|—
|
|
|-
! scope=&quot;row&quot; |&quot;Nduma Ndumane&quot; (MaWhoo, Kabza De Small, DJ Maphorisa featuring Da Muziqal Chef)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Bayangzonda&quot; (Mac Lopez, MaWhoo)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;NgizoWela&quot; (Slade, MaWhoo, Tycoon featuring Marcus MC, Stacy)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Ngifunani&quot; (Femi Large, MaWhoo)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Imizi Yobaba&quot; (Soulfreakah, MaWhoo)
| rowspan=&quot;2&quot; |2024


|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Uthukela&quot; (MaWhoo featuring Harry Cane, Eemoh)
|_
|
|{{non-album single}}
|-
!&quot;Gucci&quot; (Mthandeni SK featuring MaWhoo)
|
|_
|
|Non-album single
|-
!&quot;Ngeke&quot; (Yumbs, Zwayetoven &amp; MaWhoo featuring Mthunzi)
|
|_
|
|Non-album single
|-
!&quot;Khuluma&quot; (Oskido, Master KG &amp; MaWhoo featuring Lilyfaith, Lowsheen &amp; Theo Kgosinkwe)
|
|_
|
|Non-album single
|-
!&quot;Uzizwa Kanjan' (Jazzworx, Thukuthela, MaWhoo &amp; GL_Ceejay)
|2025
|5
|
|Non-album single
|-
!&quot;Ziphi Nkomo&quot; (Sir Trill, MaWhoo &amp; B33kay SA featuring DJ 2k, Frank Mabeat &amp; Tumisho)
|
|_
|
|Non-album single
|-
!&quot;Phakade Lami&quot; (Da Capo, Soul Star &amp; MaWhoo)
|
|_
|
|Non-album single
|-
!&quot;Bengicela&quot; (MaWhoo, GL_ Ceejay &amp; Thukuthela featuring Jazzworx)
|
|1
|
|Amazwi Okubonga
|-
!&quot;Smomondiya&quot; (Frank Mabeat &amp; MaWhoo featuring B33kay SA)
|
|_
|
|Non-album single
|-
!&quot;Sono Sam&quot; (TBO, MaWhoo &amp; Ntsika featuring Ngwato &amp; Ave Songsmith)
|
|_
|
|Non-album single
|-
!&quot;MA AFRIKA&quot; (Deep Sen, MaWhoo &amp; M.J featuring Ntando Yamahlubi)
|
|_
|
|Non-album single
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; |&quot;—&quot; denotes a recording that did not chart or was not released in that territory.
|}
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+Irhelo lama-single njengabaculi abaveziweko, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;Moya Wami&quot; (u-Oscar Mbo ahlanganisa u-MaWhoo)
| rowspan=&quot;2&quot; | 2020
| —
| Irhawuda
| ''Kwama-Groovists''
|-
! scope=&quot;row&quot; | &quot;Bambelela&quot; (i-Caltonic SA ehlanganisa u-Sje Konka, u-MaWhoo, u-Thabz Le Madonga)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Uqobo Lwami&quot; (u-DJ Fanzy ohlanganisa u-MaWhoo)
| 2021
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ikhadi le-Indoda Nge&quot; (DJ Moscow, Deepsen, Eddie The Vocalist feat. DJ Moscow, MaWhoo)
| rowspan=&quot;2&quot; | 2022
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Khumbul' Ekhaya&quot; (u-Knowley-D ohlanganisa u-Busta 929, u-MaWhoo)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Dali Wam&quot; (Pabi Cooper, Yumbs ehlanganisa uMaWhoo, uNkosazana Daughter )
| rowspan=&quot;9&quot; | 2023
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Isthutha&quot; (Inkinga Abangan Bam)&quot; (Sam Deep, De Mthuda ehlanganisa uMawhoo, Mkeyz)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ungiphethe Kahle&quot; (Kabza De Small, DJ Maphorisa ahlanganisa uNokwazi, MaWhoo, Mashudu &amp; LeeArt)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Noma Kanjani&quot; (u-Sino Msolo ohlanganisa u-Kabza De Small, u-MaWhoo, u-Azana)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Uthando&quot; (I-Groovist ehlanganisa u-MaWhoo)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Zibonakalise&quot; (ama-HK ahlanganisa u-MaWhoo)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Wena My Dali&quot; (I-Focalistic featuring Ch'cco, MaWhoo, EeQue, Thama Tee)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Impilo&quot; (u-Marlode no-Owams abahlanganisa ama-2woBunnies, u-MaWhoo, u-Leandra.Vert, u-Toby Franco, u-Gilano, u-Sponge 101)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Kutsa&quot; (u-DJ Sliqe ahlanganisa u-Yanga Chief, u-MaWhoo, u-2woshort, u-Makwa)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ungithandile&quot; (u-Baby Momo ohlanganisa u-MaWhoo, u-Ceenday, u-Jay Sax, u-Shino Kikai, u-DJ 2K)
| rowspan=&quot;6&quot; | 2024
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ngifa Nawe&quot; (MFR Souls, Kabza De Small ene-MaWhoo, Bassie, T-Man SA, Shane907)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Amabhoza&quot; ( Aymos, Mas Musiq featuring MaWhoo)
| —
|
| ''Impilo''
|-
! scope=&quot;row&quot; | &quot;Ematshwaleni&quot; ( Kususa, Anatti featuring MaWhoo, Noxolo Ngema, King Deetoy)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Injabulo&quot; (u-Lily Faith ahlanganisa u-Theo Kgosinkwe, u-X-Wise, u-Oskido, u-MaWhoo)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Gucci&quot; (Mthandeni SK, ehlanganisa u-MaWhoo)
| 1  
||{{non-album single}} 
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; | &quot;—&quot; kutjho ukurekhoda okungazange kushadi namkha okungakakhutjhwa endaweni leyo.
|}
{| class=&quot;wikitable plainrowheaders&quot; border=&quot;1&quot; style=&quot;text-align:center;&quot;
|+Irhelo lezinye iingoma ezitjhadiweko, ezineendawo ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;Kulula&quot; (Mawhoo, DJ Maphorisa, Kabza De Small)
| 2022
| —
| Igolide 
| ''Yisikhathi esingangani sokuphila''
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; | &quot;—&quot; kutjho ukurekhoda okungazange kushadi namkha okungakakhutjhwa endaweni leyo.
|}

== Ipilo yomuntu mathupha ==
Kube nemibiko yokuthi uNgema uthandana noHlubi Nkosi. Iinthandani bezibikwe bona zinikelana ngezipho.  

== Imithombo lwazi ==

# &lt;ref&gt;[https://www.bona.co.za/entertainment/mawhoos-shocking-revelation-american-a-listers-who-slid-into-her-dms/ Mawhoo's shocking revelation! American A-listers who slid into her DMs | Bona Magazine]&lt;/ref&gt;
# &lt;ref&gt;[https://slikouronlife.co.za/blog/24023/mawhoos-kulula-surpasses-1-million-streams/ MaWhoo's 'Kulula' Surpasses 1 Million Streams | Slikouronlife]&lt;/ref&gt;</text>
      <sha1>fr884bxkohywhm5dhklj3ucko6irufd</sha1>
    </revision>
    <revision>
      <id>6700</id>
      <parentid>6304</parentid>
      <timestamp>2026-06-12T08:29:09Z</timestamp>
      <contributor>
        <username>MissHadassah</username>
        <id>1561</id>
      </contributor>
      <comment>changed formatting</comment>
      <origin>6700</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="10785" sha1="ms8g411vkz3pm3m71xyv441zop1zr7a" xml:space="preserve"> 
[[Isimumathi:Maker Faire, Berlin (BL7C0113).jpg|thumb|indawo lapha u-Mawhoo aqulela khona abantu.]]
'''U-Thandeka Nontobeko Ngema''' (wabelethwa mhlana amalanga ali-16 kuNobayeni 1994), owaziwa ngokuthi '''ngu-MaWhoo''', mquli nomtloli weengoma weSewula Afrika.&lt;ref&gt;[https://slikouronlife.co.za/blog/24023/mawhoos-kulula-surpasses-1-million-streams/ MaWhoo's 'Kulula' Surpasses 1 Million Streams | Slikouronlife]&lt;/ref&gt; Wathola ukuhlonitjhwa okukhulu ngemva kokukhipha ingoma yakhe yokuthoma ethi ''&quot;Umshado&quot;'' leno- Heavy-K.&lt;ref&gt;[https://kingminds.net/mawhoo-nontobeko-thandeka-ngema-biography-early-life-age-career-songs-net-worth/ Mawhoo (Nontobeko Thandeka Ngema) Biography, Early Life, Age, Career, Songs, Net Worth - KingMinds]&lt;/ref&gt;

U-Ngema uvele godu kumavidiyo womvumo amanengi, okufaka hlangana ukulingisa iindima eziqakathekileko. Ubuye waba yimodeli yamabhrendi ngaphakathi nangaphandle kweSewula Afrika.&lt;ref&gt;[https://www.bona.co.za/entertainment/mawhoos-shocking-revelation-american-a-listers-who-slid-into-her-dms/ Mawhoo's shocking revelation! American A-listers who slid into her DMs | Bona Magazine]&lt;/ref&gt; Usebenze ne-Tribe Afrique, House of Supreme, kanye ne-Convoy Clothing South Africa.&lt;ref&gt;[[:en:MaWhoo|MaWhoo - Wikipedia]]&lt;/ref&gt; Usebenzisane nabantu abafana no -DJ Maphorisa, u-Master KG, u-Tsisto, u-Kabza De Small no-Vigro Deep.   

Ngaphandle kwelizwe lakwabo, u-Ngema sele adlale emazweni we-Afrika afana ne [[Botswana|-Botswana]], [[Eswatini|i-Eswatini]], [[Zimbabwe|i-Zimbabwe]] ne [[Mozambique|-Mozambique]].   

== Isendlalelo ==

=== Ipilo yokuthoma ===
U-Thandeka Nontobeko Ngema wabelethwa mhlana amalanga ali-16 kuNobayeni ngo1994 e- Eshowe, KwaZulu-Natal, eSewula Afrika. Wathoma umsebenzi wakhe womvumo asesemncani. Lokha nakaneminyaka elitjhumi nanye, wathatha ingoma yakhe erekhodiweko wayisa emsakazweni wendawo bona idlalwe emoyeni kodwana akhenge bamvumele ngombana bekasesemncani khulu.  

==== Amagama wesiteji ====
Engcocweni, wabelane ngokuthi ibizo lakhe lesiteji litjho &quot;umlingo&quot; ngelimi lesiJapan . Watjho  bona ibizo lavela ngo-Okmalumkoolcat.  

=== Ifundo ===
U-Ngema unesiqu asifumene e- University of South Africa (i-UNISA). 

== Ibizelo ==
Ingoma yakhe ethi &quot;Bengicela&quot; no-GL_Ceekay, i-Thukuthela ene-Jazzworx yakhutjhwa mhlana amalanga ali-13 kuMgwengweni 2025.&lt;ref&gt;{{Cite web|last=Rethabile|first=Thandi|date=2025-06-05|title=MaWhoo, GL_Ceejay &amp; Thukuthela – Bengicela (Tholukuthi ) ft. JazzWorx|url=https://ceemuzic.com/music/mawhoo-gl-ceejay-thukuthela-bengicela-tholukuthi-ft-jazzworx-m66/|access-date=2025-09-04|website=CeeMuzic|language=en}}&lt;/ref&gt;  Yafika endaweni yokuthoma ematjhadini we-Apple Music, ingoma edumileko ku-YouTube, ingoma ethandwa khulu ku-Shazam begodu yingoma yesihlanu kumatjhadi weengoma eziphezulu ze-Spotify ngokulandelana. 

== Ukuphikisana ==
Ngo-2024 ngesikhathi sokukhulumisana no-L-Tido, u-Ngema waveza bona unamadoda amanengi ku-akhawunti yakhe yezokuthintana amthintako, okufaka hlangana umrepha u-Lil Wayne, u-Jay Z no -Rick Ross.  Abalandeli bakhe bamgandelela bona afakazele bona lokhu kuliqiniso na, lapho uNgema abelana khona ngesithombe sengcoco no-Lil Wayne.  

== I-Discography ==

=== Ama-albhamu we-studio ===

* What a time to be alive (2022)
* ''The chosen'' (2023)
* ''The sound of magic'' (2024)
* Amazwi Okubonga (2025)

== Abangakathathi ==

=== Njengomdwebi odosa phambili ===
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+List of singles as lead artist, with selected chart positions and certifications, showing year released and album name
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Title
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Year
! colspan=&quot;1&quot; scope=&quot;col&quot; |Peak chart positions
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; |Certifications
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Album
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; |ZA&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; |&quot;Umshado&quot; (featuring Heavy-K)
|2019
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Ngiyamthanda&quot; (MaWhoo, Master KG featuring Lowsheen)
| rowspan=&quot;2&quot; |2021
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Inkanyezi&quot; (MaWhoo, Master KG  featuring Lowsheen)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Ngithakazele&quot; (MaWhoo, DJ Fanzy featuring Andry K)
| rowspan=&quot;4&quot; |2022
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Ngithakazele&quot;
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;10k Ye McDonald's&quot; (MaWhoo featuring Mdoovar, 9umba)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Thokoza&quot; (Sam Deep, MaWhoo)
|—
|RiSA: 2× Platinum 
|''Ace of Spades''
|-
! scope=&quot;row&quot; |&quot;Umlilo&quot; (DJ Ngwazi, Pouler D’musiq, MaWhoo)
| rowspan=&quot;5&quot; |2023
|—
|
|
|-
! scope=&quot;row&quot; |&quot;Nduma Ndumane&quot; (MaWhoo, Kabza De Small, DJ Maphorisa featuring Da Muziqal Chef)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Bayangzonda&quot; (Mac Lopez, MaWhoo)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;NgizoWela&quot; (Slade, MaWhoo, Tycoon featuring Marcus MC, Stacy)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Ngifunani&quot; (Femi Large, MaWhoo)
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Imizi Yobaba&quot; (Soulfreakah, MaWhoo)
| rowspan=&quot;2&quot; |2024


|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Uthukela&quot; (MaWhoo featuring Harry Cane, Eemoh)
|_
|
|{{non-album single}}
|-
!&quot;Gucci&quot; (Mthandeni SK featuring MaWhoo)
|
|_
|
|Non-album single
|-
!&quot;Ngeke&quot; (Yumbs, Zwayetoven &amp; MaWhoo featuring Mthunzi)
|
|_
|
|Non-album single
|-
!&quot;Khuluma&quot; (Oskido, Master KG &amp; MaWhoo featuring Lilyfaith, Lowsheen &amp; Theo Kgosinkwe)
|
|_
|
|Non-album single
|-
!&quot;Uzizwa Kanjan' (Jazzworx, Thukuthela, MaWhoo &amp; GL_Ceejay)
|2025
|5
|
|Non-album single
|-
!&quot;Ziphi Nkomo&quot; (Sir Trill, MaWhoo &amp; B33kay SA featuring DJ 2k, Frank Mabeat &amp; Tumisho)
|
|_
|
|Non-album single
|-
!&quot;Phakade Lami&quot; (Da Capo, Soul Star &amp; MaWhoo)
|
|_
|
|Non-album single
|-
!&quot;Bengicela&quot; (MaWhoo, GL_ Ceejay &amp; Thukuthela featuring Jazzworx)
|
|1
|
|Amazwi Okubonga
|-
!&quot;Smomondiya&quot; (Frank Mabeat &amp; MaWhoo featuring B33kay SA)
|
|_
|
|Non-album single
|-
!&quot;Sono Sam&quot; (TBO, MaWhoo &amp; Ntsika featuring Ngwato &amp; Ave Songsmith)
|
|_
|
|Non-album single
|-
!&quot;MA AFRIKA&quot; (Deep Sen, MaWhoo &amp; M.J featuring Ntando Yamahlubi)
|
|_
|
|Non-album single
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; |&quot;—&quot; denotes a recording that did not chart or was not released in that territory.
|}
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+Irhelo lama-single njengabaculi abaveziweko, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;Moya Wami&quot; (u-Oscar Mbo ahlanganisa u-MaWhoo)
| rowspan=&quot;2&quot; | 2020
| —
| Irhawuda
| ''Kwama-Groovists''
|-
! scope=&quot;row&quot; | &quot;Bambelela&quot; (i-Caltonic SA ehlanganisa u-Sje Konka, u-MaWhoo, u-Thabz Le Madonga)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Uqobo Lwami&quot; (u-DJ Fanzy ohlanganisa u-MaWhoo)
| 2021
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ikhadi le-Indoda Nge&quot; (DJ Moscow, Deepsen, Eddie The Vocalist feat. DJ Moscow, MaWhoo)
| rowspan=&quot;2&quot; | 2022
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Khumbul' Ekhaya&quot; (u-Knowley-D ohlanganisa u-Busta 929, u-MaWhoo)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Dali Wam&quot; (Pabi Cooper, Yumbs ehlanganisa uMaWhoo, uNkosazana Daughter )
| rowspan=&quot;9&quot; | 2023
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Isthutha&quot; (Inkinga Abangan Bam)&quot; (Sam Deep, De Mthuda ehlanganisa uMawhoo, Mkeyz)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ungiphethe Kahle&quot; (Kabza De Small, DJ Maphorisa ahlanganisa uNokwazi, MaWhoo, Mashudu &amp; LeeArt)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Noma Kanjani&quot; (u-Sino Msolo ohlanganisa u-Kabza De Small, u-MaWhoo, u-Azana)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Uthando&quot; (I-Groovist ehlanganisa u-MaWhoo)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Zibonakalise&quot; (ama-HK ahlanganisa u-MaWhoo)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Wena My Dali&quot; (I-Focalistic featuring Ch'cco, MaWhoo, EeQue, Thama Tee)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Impilo&quot; (u-Marlode no-Owams abahlanganisa ama-2woBunnies, u-MaWhoo, u-Leandra.Vert, u-Toby Franco, u-Gilano, u-Sponge 101)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Kutsa&quot; (u-DJ Sliqe ahlanganisa u-Yanga Chief, u-MaWhoo, u-2woshort, u-Makwa)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ungithandile&quot; (u-Baby Momo ohlanganisa u-MaWhoo, u-Ceenday, u-Jay Sax, u-Shino Kikai, u-DJ 2K)
| rowspan=&quot;6&quot; | 2024
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ngifa Nawe&quot; (MFR Souls, Kabza De Small ene-MaWhoo, Bassie, T-Man SA, Shane907)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Amabhoza&quot; ( Aymos, Mas Musiq featuring MaWhoo)
| —
|
| ''Impilo''
|-
! scope=&quot;row&quot; | &quot;Ematshwaleni&quot; ( Kususa, Anatti featuring MaWhoo, Noxolo Ngema, King Deetoy)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Injabulo&quot; (u-Lily Faith ahlanganisa u-Theo Kgosinkwe, u-X-Wise, u-Oskido, u-MaWhoo)
| — 
|| {{Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Gucci&quot; (Mthandeni SK, ehlanganisa u-MaWhoo)
| 1  
||{{non-album single}} 
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; | &quot;—&quot; kutjho ukurekhoda okungazange kushadi namkha okungakakhutjhwa endaweni leyo.
|}
{| class=&quot;wikitable plainrowheaders&quot; border=&quot;1&quot; style=&quot;text-align:center;&quot;
|+Irhelo lezinye iingoma ezitjhadiweko, ezineendawo ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;Kulula&quot; (Mawhoo, DJ Maphorisa, Kabza De Small)
| 2022
| —
| Igolide 
| ''Yisikhathi esingangani sokuphila''
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; | &quot;—&quot; kutjho ukurekhoda okungazange kushadi namkha okungakakhutjhwa endaweni leyo.
|}

== Ipilo yomuntu mathupha ==
Kube nemibiko yokuthi uNgema uthandana noHlubi Nkosi. Iinthandani bezibikwe bona zinikelana ngezipho.  

== Imithombo lwazi ==

# &lt;ref&gt;[https://www.bona.co.za/entertainment/mawhoos-shocking-revelation-american-a-listers-who-slid-into-her-dms/ Mawhoo's shocking revelation! American A-listers who slid into her DMs | Bona Magazine]&lt;/ref&gt;
# &lt;ref&gt;[https://slikouronlife.co.za/blog/24023/mawhoos-kulula-surpasses-1-million-streams/ MaWhoo's 'Kulula' Surpasses 1 Million Streams | Slikouronlife]&lt;/ref&gt;</text>
      <sha1>ms8g411vkz3pm3m71xyv441zop1zr7a</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Mashiloane. N</title>
    <ns>2</ns>
    <id>913</id>
    <revision>
      <id>5455</id>
      <timestamp>2025-09-04T08:02:14Z</timestamp>
      <contributor>
        <username>Mashiloane. N</username>
        <id>907</id>
      </contributor>
      <comment>Created my user page</comment>
      <origin>5455</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="38" sha1="o26or9uk42jtl3ige2tctzlmat5adv7" xml:space="preserve">Hi, my name is Nompumelelo Mashiloane.</text>
      <sha1>o26or9uk42jtl3ige2tctzlmat5adv7</sha1>
    </revision>
    <revision>
      <id>5458</id>
      <parentid>5455</parentid>
      <timestamp>2025-09-04T08:09:22Z</timestamp>
      <contributor>
        <username>Mashiloane. N</username>
        <id>907</id>
      </contributor>
      <comment>created my draft pages</comment>
      <origin>5458</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="181" sha1="6yqzv6pliwh3a64kzgu4pujpbmfj7el" xml:space="preserve">Hi, my name is Nompumelelo Mashiloane.


[[Umsebenzisi:Mashiloane. N/Page 1|Page 1]]  |  [[Umsebenzisi:Mashiloane. N/Page 2|page 2]]  |   [[Umsebenzisi:Mashiloane. N/Page 3|page 3]]</text>
      <sha1>6yqzv6pliwh3a64kzgu4pujpbmfj7el</sha1>
    </revision>
  </page>
  <page>
    <title>Kamo Mphela</title>
    <ns>0</ns>
    <id>914</id>
    <revision>
      <id>5456</id>
      <timestamp>2025-09-04T08:07:25Z</timestamp>
      <contributor>
        <username>Enthusiastic Lady</username>
        <id>899</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1307755036|Kamo Mphela]]&quot;</comment>
      <origin>5456</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7472" sha1="6hfrcuwa83hijpv1p8auq657m113hoj" xml:space="preserve">
[[Isimumathi:Kamo Mphela.jpg|left|thumb|283x283px|Mphela in 2019]]



&lt;ref&gt;{{cite web|title=Trace Awards 2025: All the winners|url=https://www.musicinafrica.net/magazine/trace-awards-2025-all-winners|date=2025-02-27|work=Music in Africa|access-date=2025-03-02|first=Ano|last=Shumba}}&lt;/ref&gt;    
















'''U-Kamogelo Matona''' (wabelethwa ngomhlaka-29 kuNobayeni 1999),  owaziwa ngokomsebenzi ngokuthi ngu '''-Kamo Mphela''', mdansi nomvumi we-amapiano weSewula Afrika. Waba ngusaziwako we-inthanethi ngemva kobana afake ividiyo yakhe yokugida ku-akhawunti yakhe yezokuthintana. 

== Ipilo yokuthoma nefundo ==
UMphela wakhulela elokishini le-Emdeni, e-Soweto . Wafunda i-Media e-Boston Media House, umnyaka. 

== Ibizelo ==
Ithando lakhe lokudansa lathoma asesemncani, lokha nakakhaphe uyise emsebenzini wakhe e- YFM .Bekathi nakakhambisana noyise asale adlala khona esiteji nekuyinto eyamenza bona abe mumuntu odume khulu. Ngokukhamba kwesikhathi  waba mumuntu edumileko ngokufaka amavidiyo ku -Instagram lapho atjengisa khona amakghono wakhe wokuvuma.  Ngaphambi kokobana aragele phambili nomsebenzi wakhe wokuvuma bekazame ukulingisa begodu wafumana ithuba lokuba mdlali ongezelelweko ku-TV soap Isibaya, kodwana ngokukhamba kwesikhathi wabona bona bekungasilo ibizelo lakhe ukuba mlingisi wathoma ukudlala njengomdansi emidlalweni.  Amakghono wakhe wokudansa agcina wamenze &quot;Ndlovukazi ye-Amapiano&quot;. 

Ngomnyaka ka-2019, watlikitla i-Major League Music bewakhupha i-EP yakhe ebizwa ngokuthi, ''i-Twentee'' ngaphasi kwelebula.  Ubuye wakhupha iingoma ethi &quot;Suka Emabozen&quot; ne ama-&quot;Menemene&quot; begodu usebenzisane nomvumi weSewula Afrika u-Busiswa ngengoma ethi &quot;Sbwl&quot;  begodu uvele engomeni ye-MFR Soulz ethi &quot;Amanikiniki&quot; ebekwe ku-#1 ku- Good Hope FM 's SA House Music Top 10 Chart.   Ubuye wadlala begodu wasebenza nabavumi bendawo abafana no -Nadia Nakai no -Killer Kau . Uvele njengomvumi nomdansi eengomeni ze-amapiano ezifana ne-&quot;Sukendleleni&quot; kanye ne-&quot;Labantwana Ama Uber&quot;.  Ngaphandle kwe -amapiano, sele avume neminye imihlobo yomvumo odumileko weSewula Afrika okufaka hlangana i-gqom, i-kwaito kanye ne-pantsula . 

I-&quot; Dalie &quot; no -Tyler ICU no-Khalil Harrison ehlanganisa u-Baby SON ekhutjhwe mhlana ali-11 kuNobayeni 2023. Ingoma le yathoma ukuvela endaweni yokuthoma emazweni amathathu i-Malawi, Zimbabwe kanye neSewula Afrika begodu yafika endaweni ye-11 emashadini we-Shazam wephasi loke.  Ukungezelela ingoma le yaba ngedumileko kumadijithali ngeengidi ezimbili emalangeni ama-4 begodu yaqinisekiswa ngegolide eSewula Afrika.   Ingoma le ifinyelele isitifiketi se-Platinum. 
{| class=&quot;wikitable sortable plainrowheaders&quot; style=&quot;border:none; margin:0;&quot;
|+Imitlomelo nokukhethwa kwamukelwa ngu-Kamo Mphela
! scope=&quot;col&quot; | Ihlangano
! scope=&quot;col&quot; | Umnyaka
! scope=&quot;col&quot; | Umkhakha
! scope=&quot;col&quot; | Umamukeli namkha okhethiweko
! scope=&quot;col&quot; | Umphumela
! class=&quot;unsortable&quot; scope=&quot;col&quot; | Ref.
|-
| rowspan=&quot;3&quot; scope=&quot;row&quot; | Imitlomelo yomvumo we-Metro FM
| rowspan=&quot;3&quot; | 2023
| Ingoma yomnyaka 
| rowspan=&quot;8&quot; |{{center|&quot;[[Dalie]]&quot;}}| {{nom}}
| style=&quot;text-align:center&quot; | 
|-
| Ividiyo yomculo ehle khulu| {{nom}}
| style=&quot;text-align:center&quot; | &lt;ref name=&quot;:0&quot; /&gt;
|-
| Itjhijilo elihle khulu| {{nom}}
| style=&quot;text-align:center&quot; | &lt;ref name=&quot;:0&quot; /&gt;
|-
| rowspan=&quot;3&quot; scope=&quot;row&quot; | Basadi emiklomelweni yomvumo
| rowspan=&quot;7&quot; | 2024
| Isikghwari somnyaka we-Amapiano|{{won}} 
| rowspan=&quot;3&quot; |  
|-
| Ingoma yomnyaka|{{nom}} 
|-
| Ividiyo yomvumo yomnyaka|{{won}}
|-
| scope=&quot;row&quot; | Imiklomelo yokuzithabisa ye-Afrika e-USA
| Ingoma yomnyaka|{{nominated}} 
| 
|-
| rowspan=&quot;2&quot; scope=&quot;row&quot; | Imiklomelo ye-DStv Content Creator
| Ingoma yomnyaka|{{nom}} 
| rowspan=&quot;2&quot; | 
|-
| Umvuzo wefeshini nesitayela
| rowspan=&quot;2&quot; | Yena ngokwakhe|{{nom}}
|-
| scope=&quot;row&quot; | Imiklomelo yokulandelela
| Umdansi omuhle khulu| {{nom}} 
| 
|}

== I-Discography ==

* ''Twentee'' (2019) 
* ''ifundo'' (2021) 

== Abangakathathi ==

=== Njengomdwebi odosa phambili ===
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+Irhelo lama-single njengabaculi abadosa phambili, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;2&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
! UK Afro Beats
|-
! scope=&quot;row&quot; | &quot;Dubai&quot; (okufaka hlangana u-Daliwonga, u-Sizwe Alakine, u-Tyler ICU)
| rowspan=&quot;2&quot; | 2021
| —
|
|
|
|-
! scope=&quot;row&quot; | &quot;iPiano&quot; (Sha Sha, Kamo Mphela ehlanganisa u-Felo Le Tee)
| 21
|
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Isipoko&quot; (okufaka hlangana u-Daliwonga, u-Felo Le Tee)
| 2022
| —
|
|
|
|-
! scope=&quot;row&quot; | &quot;U-Hannah Montana&quot;
| rowspan=&quot;3&quot; | 2023
| —
| -
|-
! scope=&quot;row&quot; | &quot;Umhlolo&quot; (Kamo Mphela, i-Masterpiece YVK ene-AyaProw &amp; Yumbs)
| —
| -
|
|
|-
! scope=&quot;row&quot; | &quot; U-Dalie &quot; (u-Kamo Mphela, u-Tyler ICU, u-Khalil Haris, one-Baby SON)
| 1
| 17
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;Partii&quot; (Kamo Mphela, Aymos, Que DJ &amp; Jay Music featuring SpacePose)
| 2025
| 13
| 28
|
|
|-
| colspan=&quot;9&quot; style=&quot;font-size:90%&quot; | &quot;—&quot; kutjho ukurekhoda okungazange kushadi namkha okungakakhutjhwa endaweni leyo.
|}

=== Njengomdwebi ovezweko ===
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+Irhelo lama-single njengabaculi abaveziweko, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;SBWL&quot; (Busiswa featuring Kamo Mphela)
| rowspan=&quot;2&quot; | 2020
| —
|
|
|-
! scope=&quot;row&quot; | &quot;U-Elon Musk&quot; (Da LES feat. Focalistic, Kamo Mphela &amp; Jobe London)
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Lashiteku&quot; (I-Tipcee ehlanganisa u-Kamo Mphela, u-DJ Tira, u-Blaqshandis, ukuziphatha okumbi khulu)
| rowspan=&quot;4&quot; | 2021
| —
|
|
|-
! scope=&quot;row&quot; | &quot;I-Universe&quot; (u-Hip-Naughtic Sean ohlanganisa u-Kamo Mphela, u-Kay Invictus, u-Toss)
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Ama Million&quot; (i-King Groove ehlanganisa u-Kamo Mphela)
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Izinga eliphezulu (DJ Sumbody ehlanganisa uKamo Mphela, The Lowkeys)
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Siyavuma (Re-Up)&quot; (okufaka hlangana u-Kamo Mphela, u-MJ, u-Tom London, u-Flakko, u-HolaDjBash, u-Njabz Finest)
| 2022
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Woza La&quot; (UMs. Cosmo featuring Blxckie, Kamo Mphela, RudeBoyz &amp; Nobantu Vilakazi)
| rowspan=&quot;2&quot; | 2023
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Ikhefu&quot; (i-TI ehlanganisa u-Kamo Mphela)
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Hade Boss (Re-Up)&quot; (u-DJ Lag, u-DJ Maphorisa, i-Robot Boii ehlanganisa u-Kamo Mphela, u-2woshort, u-Xduppy, u-KC Driller, u-Mr Nation Thingz)
| 2024
| —
|
|
|-
! &quot;Ukubuya kwaka-Tobetsa&quot; (u-ShaunMusiq, u-Ftears &amp; Myztro ohlanganisa u-Focalistic, u-Daliwonga, u-Kamo Mphela, u-Mbali The Real, u-BoiBizza, u-Stompiiey no-2woshort)
| 2025
| _
|
| Ukubuya kwaka-Tobetsa
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; | &quot;—&quot; kutjho ukurekhoda okungazange kushadi namkha okungakakhutjhwa endaweni leyo.
|}

== Imithombo lwazi ==

== Amalinki wangaphandle ==

* Kamo Mphela on Twitter</text>
      <sha1>6hfrcuwa83hijpv1p8auq657m113hoj</sha1>
    </revision>
    <revision>
      <id>5492</id>
      <parentid>5456</parentid>
      <timestamp>2025-09-04T09:01:28Z</timestamp>
      <contributor>
        <username>Enthusiastic Lady</username>
        <id>899</id>
      </contributor>
      <comment>/* Imithombo lwazi */</comment>
      <origin>5492</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3153" sha1="7gipj6thv8x4i0tamxwh4fijro4hywo" xml:space="preserve">'''KAMO MPHELA'''[[Isimumathi:Kamo Mphela.jpg|left|thumb|283x283px|'''Mphela in 2019''']]



&lt;ref&gt;{{cite web|title=Trace Awards 2025: All the winners|url=https://www.musicinafrica.net/magazine/trace-awards-2025-all-winners|date=2025-02-27|work=Music in Africa|access-date=2025-03-02|first=Ano|last=Shumba}}&lt;/ref&gt;    






'''U-Kamogelo Matona''' Kamo&lt;ref&gt;{{Cite web |date=2022-10-11 |title=Kamo Mphela Biography: Boyfriend, Father, Pictures, Songs, Age, Net Worth, Husband, Car, House - The History |url=https://www.thehistory.co.za/kamo-mphela-biography/ |access-date=2025-09-04 |website=www.thehistory.co.za |language=en-US}}&lt;/ref&gt; 
(wabelethwa ngomhlaka-29 kuNobayeni 1999),  owaziwa ngokomsebenzi ngokuthi ngu '''-Kamo Mphela''', mdansi nomvumi we-amapiano weSewula Afrika. Waba ngusaziwako we-inthanethi ngemva kobana afake ividiyo yakhe yokugida ku-akhawunti yakhe yezokuthintana. 

== Ipilo yokuthoma nefundo ==
UMphela wakhulela elokishini le-Emdeni, e-Soweto . Wafunda i-Media e-Boston Media House, umnyaka. 

== Ibizelo ==
Ithando lakhe lokudansa lathoma asesemncani, lokha nakakhaphe uyise emsebenzini wakhe e- YFM .Bekathi nakakhambisana noyise asale adlala khona esiteji nekuyinto eyamenza bona abe mumuntu odume khulu. Ngokukhamba kwesikhathi  waba mumuntu edumileko ngokufaka amavidiyo ku -Instagram lapho atjengisa khona amakghono wakhe wokuvuma.  Ngaphambi kokobana aragele phambili nomsebenzi wakhe wokuvuma bekazame ukulingisa begodu wafumana ithuba lokuba mdlali ongezelelweko ku-TV soap Isibaya, kodwana ngokukhamba kwesikhathi wabona bona bekungasilo ibizelo lakhe ukuba mlingisi wathoma ukudlala njengomdansi emidlalweni.  Amakghono wakhe wokudansa agcina wamenze &quot;Ndlovukazi ye-Amapiano&quot;. 

Ngomnyaka ka-2019, watlikitla i-Major League Music bewakhupha i-EP yakhe ebizwa ngokuthi, ''i-Twentee'' ngaphasi kwelebula.Mphela 19&lt;ref&gt;{{Cite web |date=2023-11-29 |title=Kamo Mphela Biography: Age, Career, Songs &amp; Net Worth - Wiki South Africa |url=https://wikisouthafrica.co.za/kamo-mphela/ |access-date=2025-09-04 |language=en-US}}&lt;/ref&gt; 
  Ubuye wakhupha iingoma ethi &quot;Suka Emabozen&quot; ne ama-&quot;Menemene&quot; begodu usebenzisane nomvumi weSewula Afrika u-Busiswa ngengoma ethi &quot;Sbwl&quot;  begodu uvele engomeni ye-MFR Soulz ethi &quot;Amanikiniki&quot; ebekwe ku-#1 ku- Good Hope FM 's SA House Music Top 10 Chart.   Ubuye wadlala begodu wasebenza nabavumi bendawo abafana no -Nadia Nakai no -Killer Kau . Uvele njengomvumi nomdansi eengomeni ze-amapiano ezifana ne-&quot;Sukendleleni&quot; kanye ne-&quot;Labantwana Ama Uber&quot;.  Ngaphandle kwe -amapiano, sele avume neminye imihlobo yomvumo odumileko weSewula Afrika okufaka hlangana i-gqom, i-kwaito kanye ne-pantsula . 

I-&quot; Dalie &quot; no -Tyler ICU no-Khalil Harrison ehlanganisa u-Baby SON ekhutjhwe mhlana ali-11 kuNobayeni 2023. Ingoma le yathoma ukuvela endaweni yokuthoma emazweni amathathu i-Malawi, Zimbabwe kanye neSewula Afrika begodu yafika endaweni ye-11 emashadini we-Shazam wephasi loke.  Ukungezelela ingoma le yaba ngedumileko kumadijithali ngeengidi ezimbili emalangeni ama-4 begodu yaqinisekiswa ngegolide eSewula Afrika.   Ingoma le ifinyelele isitifiketi se-Platinum.  

=== '''Imithomo lwazi''' ===</text>
      <sha1>7gipj6thv8x4i0tamxwh4fijro4hywo</sha1>
    </revision>
    <revision>
      <id>5552</id>
      <parentid>5492</parentid>
      <timestamp>2025-09-04T09:37:37Z</timestamp>
      <contributor>
        <username>Enthusiastic Lady</username>
        <id>899</id>
      </contributor>
      <comment>Chances created with links</comment>
      <origin>5552</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3161" sha1="dcq9pi1hm9cz3istpofte68okblv3fe" xml:space="preserve">'''KAMO MPHELA'''[[Isimumathi:Kamo Mphela.jpg|left|thumb|283x283px|'''Mphela in 2019''']]



&lt;ref&gt;{{cite web|title=Trace Awards 2025: All the winners|url=https://www.musicinafrica.net/magazine/trace-awards-2025-all-winners|date=2025-02-27|work=Music in Africa|access-date=2025-03-02|first=Ano|last=Shumba}}&lt;/ref&gt;    






'''U-Kamogelo Matona''' Kamo&lt;ref&gt;{{Cite web |date=2022-10-11 |title=Kamo Mphela Biography: Boyfriend, Father, Pictures, Songs, Age, Net Worth, Husband, Car, House - The History |url=https://www.thehistory.co.za/kamo-mphela-biography/ |access-date=2025-09-04 |website=www.thehistory.co.za |language=en-US}}&lt;/ref&gt; 
(wabelethwa ngomhlaka-29 kuNobayeni 1999),  owaziwa ngokomsebenzi ngokuthi ngu '''-Kamo Mphela''', mdansi nomvumi we-amapiano weSewula Afrika. Waba ngusaziwako we-inthanethi ngemva kobana afake ividiyo yakhe yokugida ku-akhawunti yakhe yezokuthintana. 

== Ipilo yokuthoma nefundo ==
UMphela wakhulela elokishini le-Emdeni, e-Soweto . Wafunda i-Media e-Boston Media House, umnyaka. 

== Ibizelo ==
Ithando lakhe lokudansa lathoma asesemncani, lokha nakakhaphe uyise emsebenzini wakhe e- YFM .Bekathi nakakhambisana noyise asale adlala khona esiteji nekuyinto eyamenza bona abe mumuntu odume khulu. Ngokukhamba kwesikhathi  waba mumuntu edumileko ngokufaka amavidiyo ku -Instagram lapho atjengisa khona amakghono wakhe wokuvuma.  Ngaphambi kokobana aragele phambili nomsebenzi wakhe wokuvuma bekazame ukulingisa begodu wafumana ithuba lokuba mdlali ongezelelweko ku-TV soap [[Isibaya]], kodwana ngokukhamba kwesikhathi wabona bona bekungasilo ibizelo lakhe ukuba mlingisi wathoma ukudlala njengomdansi emidlalweni.  Amakghono wakhe wokudansa agcina wamenze &quot;Ndlovukazi ye-Amapiano&quot;. 

Ngomnyaka ka-2019, watlikitla i-Major League Music bewakhupha i-EP yakhe ebizwa ngokuthi, ''i-Twentee'' ngaphasi kwelebula.Mphela 19&lt;ref&gt;{{Cite web |date=2023-11-29 |title=Kamo Mphela Biography: Age, Career, Songs &amp; Net Worth - Wiki South Africa |url=https://wikisouthafrica.co.za/kamo-mphela/ |access-date=2025-09-04 |language=en-US}}&lt;/ref&gt; 
  Ubuye wakhupha iingoma ethi &quot;Suka Emabozen&quot; ne ama-&quot;Menemene&quot; begodu usebenzisane nomvumi weSewula Afrika u-Busiswa ngengoma ethi &quot;Sbwl&quot;  begodu uvele engomeni ye-MFR Soulz ethi &quot;Amanikiniki&quot; ebekwe ku-#1 ku- Good Hope FM 's SA House Music Top 10 Chart.   Ubuye wadlala begodu wasebenza nabavumi bendawo abafana no -Nadia Nakai no -Killer Kau . Uvele njengomvumi nomdansi eengomeni ze-amapiano ezifana ne-&quot;Sukendleleni&quot; kanye ne-&quot;Labantwana Ama Uber&quot;.  Ngaphandle kwe -amapiano, sele avume neminye imihlobo yomvumo odumileko weSewula Afrika okufaka hlangana i-gqom, i-kwaito kanye ne-pantsula . 

I-&quot; Dalie &quot; no -Tyler ICU no-Khalil Harrison ehlanganisa u-Baby SON ekhutjhwe mhlana ali-11 kuNobayeni 2023. Ingoma le yathoma ukuvela endaweni yokuthoma emazweni amathathu i-Malawi, [[Zimbabwe]] kanye neSewula Afrika begodu yafika endaweni ye-11 emashadini we-Shazam wephasi loke.  Ukungezelela ingoma le yaba ngedumileko kumadijithali ngeengidi ezimbili emalangeni ama-4 begodu yaqinisekiswa ngegolide eSewula Afrika.   Ingoma le ifinyelele isitifiketi se-Platinum.  

=== '''Imithomo lwazi''' ===</text>
      <sha1>dcq9pi1hm9cz3istpofte68okblv3fe</sha1>
    </revision>
    <revision>
      <id>5645</id>
      <parentid>5552</parentid>
      <timestamp>2025-09-04T10:59:54Z</timestamp>
      <contributor>
        <username>Enthusiastic Lady</username>
        <id>899</id>
      </contributor>
      <comment>created article</comment>
      <origin>5645</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2935" sha1="lp9ik5v0n4wkdk3bwu66ub30gcgir3v" xml:space="preserve">'''KAMO MPHELA'''
[[Isimumathi:Kamo Mphela 2021 SAA Awards.jpg|thumb|Isithombe saka Kamo Mphela]]
'''U-Kamogelo Matona''' Kamo&lt;ref&gt;{{Cite web |date=2022-10-11 |title=Kamo Mphela Biography: Boyfriend, Father, Pictures, Songs, Age, Net Worth, Husband, Car, House - The History |url=https://www.thehistory.co.za/kamo-mphela-biography/ |access-date=2025-09-04 |website=www.thehistory.co.za |language=en-US}}&lt;/ref&gt; 
(wabelethwa ngomhlaka-29 kuNobayeni 1999),  owaziwa ngokomsebenzi ngokuthi ngu '''-Kamo Mphela''', mdansi nomvumi we-amapiano weSewula Afrika. Waba ngusaziwako we-inthanethi ngemva kobana afake ividiyo yakhe yokugida ku-akhawunti yakhe yezokuthintana.

== Ipilo yokuthoma nefundo ==
UMphela wakhulela elokishini le-Emdeni, e-Soweto . Wafunda i-Media e-Boston Media House, umnyaka. 

== Ibizelo ==
Ithando lakhe lokudansa lathoma asesemncani, lokha nakakhaphe uyise emsebenzini wakhe e- YFM .Bekathi nakakhambisana noyise asale adlala khona esiteji nekuyinto eyamenza bona abe mumuntu odume khulu. Ngokukhamba kwesikhathi  waba mumuntu edumileko ngokufaka amavidiyo ku -Instagram lapho atjengisa khona amakghono wakhe wokuvuma.  Ngaphambi kokobana aragele phambili nomsebenzi wakhe wokuvuma bekazame ukulingisa begodu wafumana ithuba lokuba mdlali ongezelelweko ku-TV soap [[Isibaya]], kodwana ngokukhamba kwesikhathi wabona bona bekungasilo ibizelo lakhe ukuba mlingisi wathoma ukudlala njengomdansi emidlalweni.  Amakghono wakhe wokudansa agcina wamenze &quot;Ndlovukazi ye-Amapiano&quot;. 

Ngomnyaka ka-2019, watlikitla i-Major League Music bewakhupha i-EP yakhe ebizwa ngokuthi, ''i-Twentee'' ngaphasi kwelebula.Mphela 19&lt;ref&gt;{{Cite web |date=2023-11-29 |title=Kamo Mphela Biography: Age, Career, Songs &amp; Net Worth - Wiki South Africa |url=https://wikisouthafrica.co.za/kamo-mphela/ |access-date=2025-09-04 |language=en-US}}&lt;/ref&gt; 
  Ubuye wakhupha iingoma ethi &quot;Suka Emabozen&quot; ne ama-&quot;Menemene&quot; begodu usebenzisane nomvumi weSewula Afrika u-Busiswa ngengoma ethi &quot;Sbwl&quot;  begodu uvele engomeni ye-MFR Soulz ethi &quot;Amanikiniki&quot; ebekwe ku-#1 ku- Good Hope FM 's SA House Music Top 10 Chart.   Ubuye wadlala begodu wasebenza nabavumi bendawo abafana no -Nadia Nakai no -Killer Kau . Uvele njengomvumi nomdansi eengomeni ze-amapiano ezifana ne-&quot;Sukendleleni&quot; kanye ne-&quot;Labantwana Ama Uber&quot;.  Ngaphandle kwe -amapiano, sele avume neminye imihlobo yomvumo odumileko weSewula Afrika okufaka hlangana i-gqom, i-kwaito kanye ne-pantsula . 

I-&quot; Dalie &quot; no -Tyler ICU no-Khalil Harrison ehlanganisa u-Baby SON ekhutjhwe mhlana ali-11 kuNobayeni 2023. Ingoma le yathoma ukuvela endaweni yokuthoma emazweni amathathu i-Malawi, [[Zimbabwe]] kanye neSewula Afrika begodu yafika endaweni ye-11 emashadini we-Shazam wephasi loke.  Ukungezelela ingoma le yaba ngedumileko kumadijithali ngeengidi ezimbili emalangeni ama-4 begodu yaqinisekiswa ngegolide eSewula Afrika.   Ingoma le ifinyelele isitifiketi se-Platinum.  

=== '''Imithomo lwazi''' ===</text>
      <sha1>lp9ik5v0n4wkdk3bwu66ub30gcgir3v</sha1>
    </revision>
    <revision>
      <id>5649</id>
      <parentid>5645</parentid>
      <timestamp>2025-09-04T11:06:03Z</timestamp>
      <contributor>
        <username>Enthusiastic Lady</username>
        <id>899</id>
      </contributor>
      <minor />
      <comment>added [[Category:Isibaya]] using [[Help:Gadget-HotCat|HotCat]]</comment>
      <origin>5649</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2956" sha1="8e5ey48zde2resa92tbi6vfmpl1aeyv" xml:space="preserve">'''KAMO MPHELA'''
[[Isimumathi:Kamo Mphela 2021 SAA Awards.jpg|thumb|Isithombe saka Kamo Mphela]]
'''U-Kamogelo Matona''' Kamo&lt;ref&gt;{{Cite web |date=2022-10-11 |title=Kamo Mphela Biography: Boyfriend, Father, Pictures, Songs, Age, Net Worth, Husband, Car, House - The History |url=https://www.thehistory.co.za/kamo-mphela-biography/ |access-date=2025-09-04 |website=www.thehistory.co.za |language=en-US}}&lt;/ref&gt; 
(wabelethwa ngomhlaka-29 kuNobayeni 1999),  owaziwa ngokomsebenzi ngokuthi ngu '''-Kamo Mphela''', mdansi nomvumi we-amapiano weSewula Afrika. Waba ngusaziwako we-inthanethi ngemva kobana afake ividiyo yakhe yokugida ku-akhawunti yakhe yezokuthintana.

== Ipilo yokuthoma nefundo ==
UMphela wakhulela elokishini le-Emdeni, e-Soweto . Wafunda i-Media e-Boston Media House, umnyaka. 

== Ibizelo ==
Ithando lakhe lokudansa lathoma asesemncani, lokha nakakhaphe uyise emsebenzini wakhe e- YFM .Bekathi nakakhambisana noyise asale adlala khona esiteji nekuyinto eyamenza bona abe mumuntu odume khulu. Ngokukhamba kwesikhathi  waba mumuntu edumileko ngokufaka amavidiyo ku -Instagram lapho atjengisa khona amakghono wakhe wokuvuma.  Ngaphambi kokobana aragele phambili nomsebenzi wakhe wokuvuma bekazame ukulingisa begodu wafumana ithuba lokuba mdlali ongezelelweko ku-TV soap [[Isibaya]], kodwana ngokukhamba kwesikhathi wabona bona bekungasilo ibizelo lakhe ukuba mlingisi wathoma ukudlala njengomdansi emidlalweni.  Amakghono wakhe wokudansa agcina wamenze &quot;Ndlovukazi ye-Amapiano&quot;. 

Ngomnyaka ka-2019, watlikitla i-Major League Music bewakhupha i-EP yakhe ebizwa ngokuthi, ''i-Twentee'' ngaphasi kwelebula.Mphela 19&lt;ref&gt;{{Cite web |date=2023-11-29 |title=Kamo Mphela Biography: Age, Career, Songs &amp; Net Worth - Wiki South Africa |url=https://wikisouthafrica.co.za/kamo-mphela/ |access-date=2025-09-04 |language=en-US}}&lt;/ref&gt; 
  Ubuye wakhupha iingoma ethi &quot;Suka Emabozen&quot; ne ama-&quot;Menemene&quot; begodu usebenzisane nomvumi weSewula Afrika u-Busiswa ngengoma ethi &quot;Sbwl&quot;  begodu uvele engomeni ye-MFR Soulz ethi &quot;Amanikiniki&quot; ebekwe ku-#1 ku- Good Hope FM 's SA House Music Top 10 Chart.   Ubuye wadlala begodu wasebenza nabavumi bendawo abafana no -Nadia Nakai no -Killer Kau . Uvele njengomvumi nomdansi eengomeni ze-amapiano ezifana ne-&quot;Sukendleleni&quot; kanye ne-&quot;Labantwana Ama Uber&quot;.  Ngaphandle kwe -amapiano, sele avume neminye imihlobo yomvumo odumileko weSewula Afrika okufaka hlangana i-gqom, i-kwaito kanye ne-pantsula . 

I-&quot; Dalie &quot; no -Tyler ICU no-Khalil Harrison ehlanganisa u-Baby SON ekhutjhwe mhlana ali-11 kuNobayeni 2023. Ingoma le yathoma ukuvela endaweni yokuthoma emazweni amathathu i-Malawi, [[Zimbabwe]] kanye neSewula Afrika begodu yafika endaweni ye-11 emashadini we-Shazam wephasi loke.  Ukungezelela ingoma le yaba ngedumileko kumadijithali ngeengidi ezimbili emalangeni ama-4 begodu yaqinisekiswa ngegolide eSewula Afrika.   Ingoma le ifinyelele isitifiketi se-Platinum.  

=== '''Imithomo lwazi''' ===

[[Mkhakha:Isibaya]]</text>
      <sha1>8e5ey48zde2resa92tbi6vfmpl1aeyv</sha1>
    </revision>
    <revision>
      <id>5651</id>
      <parentid>5649</parentid>
      <timestamp>2025-09-04T11:06:14Z</timestamp>
      <contributor>
        <username>Enthusiastic Lady</username>
        <id>899</id>
      </contributor>
      <minor />
      <comment>removed [[Category:Isibaya]] using [[Help:Gadget-HotCat|HotCat]]</comment>
      <origin>5651</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2935" sha1="lp9ik5v0n4wkdk3bwu66ub30gcgir3v" xml:space="preserve">'''KAMO MPHELA'''
[[Isimumathi:Kamo Mphela 2021 SAA Awards.jpg|thumb|Isithombe saka Kamo Mphela]]
'''U-Kamogelo Matona''' Kamo&lt;ref&gt;{{Cite web |date=2022-10-11 |title=Kamo Mphela Biography: Boyfriend, Father, Pictures, Songs, Age, Net Worth, Husband, Car, House - The History |url=https://www.thehistory.co.za/kamo-mphela-biography/ |access-date=2025-09-04 |website=www.thehistory.co.za |language=en-US}}&lt;/ref&gt; 
(wabelethwa ngomhlaka-29 kuNobayeni 1999),  owaziwa ngokomsebenzi ngokuthi ngu '''-Kamo Mphela''', mdansi nomvumi we-amapiano weSewula Afrika. Waba ngusaziwako we-inthanethi ngemva kobana afake ividiyo yakhe yokugida ku-akhawunti yakhe yezokuthintana.

== Ipilo yokuthoma nefundo ==
UMphela wakhulela elokishini le-Emdeni, e-Soweto . Wafunda i-Media e-Boston Media House, umnyaka. 

== Ibizelo ==
Ithando lakhe lokudansa lathoma asesemncani, lokha nakakhaphe uyise emsebenzini wakhe e- YFM .Bekathi nakakhambisana noyise asale adlala khona esiteji nekuyinto eyamenza bona abe mumuntu odume khulu. Ngokukhamba kwesikhathi  waba mumuntu edumileko ngokufaka amavidiyo ku -Instagram lapho atjengisa khona amakghono wakhe wokuvuma.  Ngaphambi kokobana aragele phambili nomsebenzi wakhe wokuvuma bekazame ukulingisa begodu wafumana ithuba lokuba mdlali ongezelelweko ku-TV soap [[Isibaya]], kodwana ngokukhamba kwesikhathi wabona bona bekungasilo ibizelo lakhe ukuba mlingisi wathoma ukudlala njengomdansi emidlalweni.  Amakghono wakhe wokudansa agcina wamenze &quot;Ndlovukazi ye-Amapiano&quot;. 

Ngomnyaka ka-2019, watlikitla i-Major League Music bewakhupha i-EP yakhe ebizwa ngokuthi, ''i-Twentee'' ngaphasi kwelebula.Mphela 19&lt;ref&gt;{{Cite web |date=2023-11-29 |title=Kamo Mphela Biography: Age, Career, Songs &amp; Net Worth - Wiki South Africa |url=https://wikisouthafrica.co.za/kamo-mphela/ |access-date=2025-09-04 |language=en-US}}&lt;/ref&gt; 
  Ubuye wakhupha iingoma ethi &quot;Suka Emabozen&quot; ne ama-&quot;Menemene&quot; begodu usebenzisane nomvumi weSewula Afrika u-Busiswa ngengoma ethi &quot;Sbwl&quot;  begodu uvele engomeni ye-MFR Soulz ethi &quot;Amanikiniki&quot; ebekwe ku-#1 ku- Good Hope FM 's SA House Music Top 10 Chart.   Ubuye wadlala begodu wasebenza nabavumi bendawo abafana no -Nadia Nakai no -Killer Kau . Uvele njengomvumi nomdansi eengomeni ze-amapiano ezifana ne-&quot;Sukendleleni&quot; kanye ne-&quot;Labantwana Ama Uber&quot;.  Ngaphandle kwe -amapiano, sele avume neminye imihlobo yomvumo odumileko weSewula Afrika okufaka hlangana i-gqom, i-kwaito kanye ne-pantsula . 

I-&quot; Dalie &quot; no -Tyler ICU no-Khalil Harrison ehlanganisa u-Baby SON ekhutjhwe mhlana ali-11 kuNobayeni 2023. Ingoma le yathoma ukuvela endaweni yokuthoma emazweni amathathu i-Malawi, [[Zimbabwe]] kanye neSewula Afrika begodu yafika endaweni ye-11 emashadini we-Shazam wephasi loke.  Ukungezelela ingoma le yaba ngedumileko kumadijithali ngeengidi ezimbili emalangeni ama-4 begodu yaqinisekiswa ngegolide eSewula Afrika.   Ingoma le ifinyelele isitifiketi se-Platinum.  

=== '''Imithomo lwazi''' ===</text>
      <sha1>lp9ik5v0n4wkdk3bwu66ub30gcgir3v</sha1>
    </revision>
    <revision>
      <id>5653</id>
      <parentid>5651</parentid>
      <timestamp>2025-09-04T11:06:41Z</timestamp>
      <contributor>
        <username>Enthusiastic Lady</username>
        <id>899</id>
      </contributor>
      <minor />
      <comment>added [[Category:Zimbabwe]] using [[Help:Gadget-HotCat|HotCat]]</comment>
      <origin>5653</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2957" sha1="jgqt9u4q7i6g7x4wtevxs3660ss81km" xml:space="preserve">'''KAMO MPHELA'''
[[Isimumathi:Kamo Mphela 2021 SAA Awards.jpg|thumb|Isithombe saka Kamo Mphela]]
'''U-Kamogelo Matona''' Kamo&lt;ref&gt;{{Cite web |date=2022-10-11 |title=Kamo Mphela Biography: Boyfriend, Father, Pictures, Songs, Age, Net Worth, Husband, Car, House - The History |url=https://www.thehistory.co.za/kamo-mphela-biography/ |access-date=2025-09-04 |website=www.thehistory.co.za |language=en-US}}&lt;/ref&gt; 
(wabelethwa ngomhlaka-29 kuNobayeni 1999),  owaziwa ngokomsebenzi ngokuthi ngu '''-Kamo Mphela''', mdansi nomvumi we-amapiano weSewula Afrika. Waba ngusaziwako we-inthanethi ngemva kobana afake ividiyo yakhe yokugida ku-akhawunti yakhe yezokuthintana.

== Ipilo yokuthoma nefundo ==
UMphela wakhulela elokishini le-Emdeni, e-Soweto . Wafunda i-Media e-Boston Media House, umnyaka. 

== Ibizelo ==
Ithando lakhe lokudansa lathoma asesemncani, lokha nakakhaphe uyise emsebenzini wakhe e- YFM .Bekathi nakakhambisana noyise asale adlala khona esiteji nekuyinto eyamenza bona abe mumuntu odume khulu. Ngokukhamba kwesikhathi  waba mumuntu edumileko ngokufaka amavidiyo ku -Instagram lapho atjengisa khona amakghono wakhe wokuvuma.  Ngaphambi kokobana aragele phambili nomsebenzi wakhe wokuvuma bekazame ukulingisa begodu wafumana ithuba lokuba mdlali ongezelelweko ku-TV soap [[Isibaya]], kodwana ngokukhamba kwesikhathi wabona bona bekungasilo ibizelo lakhe ukuba mlingisi wathoma ukudlala njengomdansi emidlalweni.  Amakghono wakhe wokudansa agcina wamenze &quot;Ndlovukazi ye-Amapiano&quot;. 

Ngomnyaka ka-2019, watlikitla i-Major League Music bewakhupha i-EP yakhe ebizwa ngokuthi, ''i-Twentee'' ngaphasi kwelebula.Mphela 19&lt;ref&gt;{{Cite web |date=2023-11-29 |title=Kamo Mphela Biography: Age, Career, Songs &amp; Net Worth - Wiki South Africa |url=https://wikisouthafrica.co.za/kamo-mphela/ |access-date=2025-09-04 |language=en-US}}&lt;/ref&gt; 
  Ubuye wakhupha iingoma ethi &quot;Suka Emabozen&quot; ne ama-&quot;Menemene&quot; begodu usebenzisane nomvumi weSewula Afrika u-Busiswa ngengoma ethi &quot;Sbwl&quot;  begodu uvele engomeni ye-MFR Soulz ethi &quot;Amanikiniki&quot; ebekwe ku-#1 ku- Good Hope FM 's SA House Music Top 10 Chart.   Ubuye wadlala begodu wasebenza nabavumi bendawo abafana no -Nadia Nakai no -Killer Kau . Uvele njengomvumi nomdansi eengomeni ze-amapiano ezifana ne-&quot;Sukendleleni&quot; kanye ne-&quot;Labantwana Ama Uber&quot;.  Ngaphandle kwe -amapiano, sele avume neminye imihlobo yomvumo odumileko weSewula Afrika okufaka hlangana i-gqom, i-kwaito kanye ne-pantsula . 

I-&quot; Dalie &quot; no -Tyler ICU no-Khalil Harrison ehlanganisa u-Baby SON ekhutjhwe mhlana ali-11 kuNobayeni 2023. Ingoma le yathoma ukuvela endaweni yokuthoma emazweni amathathu i-Malawi, [[Zimbabwe]] kanye neSewula Afrika begodu yafika endaweni ye-11 emashadini we-Shazam wephasi loke.  Ukungezelela ingoma le yaba ngedumileko kumadijithali ngeengidi ezimbili emalangeni ama-4 begodu yaqinisekiswa ngegolide eSewula Afrika.   Ingoma le ifinyelele isitifiketi se-Platinum.  

=== '''Imithomo lwazi''' ===

[[Mkhakha:Zimbabwe]]</text>
      <sha1>jgqt9u4q7i6g7x4wtevxs3660ss81km</sha1>
    </revision>
    <revision>
      <id>5655</id>
      <parentid>5653</parentid>
      <timestamp>2025-09-04T11:07:41Z</timestamp>
      <contributor>
        <username>Enthusiastic Lady</username>
        <id>899</id>
      </contributor>
      <minor />
      <comment>removed [[Category:Zimbabwe]] using [[Help:Gadget-HotCat|HotCat]]</comment>
      <origin>5655</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2935" sha1="lp9ik5v0n4wkdk3bwu66ub30gcgir3v" xml:space="preserve">'''KAMO MPHELA'''
[[Isimumathi:Kamo Mphela 2021 SAA Awards.jpg|thumb|Isithombe saka Kamo Mphela]]
'''U-Kamogelo Matona''' Kamo&lt;ref&gt;{{Cite web |date=2022-10-11 |title=Kamo Mphela Biography: Boyfriend, Father, Pictures, Songs, Age, Net Worth, Husband, Car, House - The History |url=https://www.thehistory.co.za/kamo-mphela-biography/ |access-date=2025-09-04 |website=www.thehistory.co.za |language=en-US}}&lt;/ref&gt; 
(wabelethwa ngomhlaka-29 kuNobayeni 1999),  owaziwa ngokomsebenzi ngokuthi ngu '''-Kamo Mphela''', mdansi nomvumi we-amapiano weSewula Afrika. Waba ngusaziwako we-inthanethi ngemva kobana afake ividiyo yakhe yokugida ku-akhawunti yakhe yezokuthintana.

== Ipilo yokuthoma nefundo ==
UMphela wakhulela elokishini le-Emdeni, e-Soweto . Wafunda i-Media e-Boston Media House, umnyaka. 

== Ibizelo ==
Ithando lakhe lokudansa lathoma asesemncani, lokha nakakhaphe uyise emsebenzini wakhe e- YFM .Bekathi nakakhambisana noyise asale adlala khona esiteji nekuyinto eyamenza bona abe mumuntu odume khulu. Ngokukhamba kwesikhathi  waba mumuntu edumileko ngokufaka amavidiyo ku -Instagram lapho atjengisa khona amakghono wakhe wokuvuma.  Ngaphambi kokobana aragele phambili nomsebenzi wakhe wokuvuma bekazame ukulingisa begodu wafumana ithuba lokuba mdlali ongezelelweko ku-TV soap [[Isibaya]], kodwana ngokukhamba kwesikhathi wabona bona bekungasilo ibizelo lakhe ukuba mlingisi wathoma ukudlala njengomdansi emidlalweni.  Amakghono wakhe wokudansa agcina wamenze &quot;Ndlovukazi ye-Amapiano&quot;. 

Ngomnyaka ka-2019, watlikitla i-Major League Music bewakhupha i-EP yakhe ebizwa ngokuthi, ''i-Twentee'' ngaphasi kwelebula.Mphela 19&lt;ref&gt;{{Cite web |date=2023-11-29 |title=Kamo Mphela Biography: Age, Career, Songs &amp; Net Worth - Wiki South Africa |url=https://wikisouthafrica.co.za/kamo-mphela/ |access-date=2025-09-04 |language=en-US}}&lt;/ref&gt; 
  Ubuye wakhupha iingoma ethi &quot;Suka Emabozen&quot; ne ama-&quot;Menemene&quot; begodu usebenzisane nomvumi weSewula Afrika u-Busiswa ngengoma ethi &quot;Sbwl&quot;  begodu uvele engomeni ye-MFR Soulz ethi &quot;Amanikiniki&quot; ebekwe ku-#1 ku- Good Hope FM 's SA House Music Top 10 Chart.   Ubuye wadlala begodu wasebenza nabavumi bendawo abafana no -Nadia Nakai no -Killer Kau . Uvele njengomvumi nomdansi eengomeni ze-amapiano ezifana ne-&quot;Sukendleleni&quot; kanye ne-&quot;Labantwana Ama Uber&quot;.  Ngaphandle kwe -amapiano, sele avume neminye imihlobo yomvumo odumileko weSewula Afrika okufaka hlangana i-gqom, i-kwaito kanye ne-pantsula . 

I-&quot; Dalie &quot; no -Tyler ICU no-Khalil Harrison ehlanganisa u-Baby SON ekhutjhwe mhlana ali-11 kuNobayeni 2023. Ingoma le yathoma ukuvela endaweni yokuthoma emazweni amathathu i-Malawi, [[Zimbabwe]] kanye neSewula Afrika begodu yafika endaweni ye-11 emashadini we-Shazam wephasi loke.  Ukungezelela ingoma le yaba ngedumileko kumadijithali ngeengidi ezimbili emalangeni ama-4 begodu yaqinisekiswa ngegolide eSewula Afrika.   Ingoma le ifinyelele isitifiketi se-Platinum.  

=== '''Imithomo lwazi''' ===</text>
      <sha1>lp9ik5v0n4wkdk3bwu66ub30gcgir3v</sha1>
    </revision>
  </page>
  <page>
    <title>Benjamin Dube</title>
    <ns>0</ns>
    <id>915</id>
    <revision>
      <id>5457</id>
      <timestamp>2025-09-04T08:08:50Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1289103748|Benjamin Dube]]&quot;</comment>
      <origin>5457</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2086" sha1="cuwf9585nb7oylb1kqodfwu6hmsn16b" xml:space="preserve">
Benjamin Dube 

Wabelethwa 1962(age 62-63)

eJohanisibhege, eSewula Africa

Ungumvumi wezeKolo

Wathoma ngomhlaka 1980 - kufikela namhlanje

abentwana: amadodana ama-4

U '''-Benjamin Dube''' (wabelethwa ngo-1962) [[South African gospel recording artist|mculi wevangeli weSewula Afrika]] owakhula waba yidumo ekuthomeni kwabo-80. Eminyakeni edlulileko ukhuphe ama-albhamu amanengi afinyelele esigabeni segolide neplatinamu emazingeni womvumo weSewula Afrika. U-Dube godu [[Vosloorus|mfundisi odosa phambili we-High Praise Center e-Vosloorus]], ngepumalanga ye-Johannesburg. &lt;ref name=&quot;AllMusic&quot;&gt;{{Cite web|url=https://www.allmusic.com/artist/pastor-benjamin-dube-mn0000125817/biography|title=Pastor Benjamin Dube Biography|author=Thom Jurek|publisher=AllMusic}}&lt;/ref&gt; 

== Iminyaka yokuthoma ==
Njengombana avela emndenini okholelwako, ikareko [[Dube's music|kaDube]] yomvumo yathoma asesemncani. Wathoma ukuvuma umvumo wevangeli ndawonye nomndenakhe nakaneminyaka elikhomba.    Nakaneminyaka elitjhumi nambili, u-Benjamin wathoma ukuhlabelela nabafowabo abadala esontweni, begodu baziwa ngokuthi bavumi be-Dube Family. Kodwana ngebhadi, izinto bezizokutjhuguluka unomphela emndenini ka-Dube lokha umkhosi wabo noyise nakabulawa kumbi ngo-1976. Umndeni waqunta ukuvuma nokwabelana ngeendaba zokuhlongakala kwakayise. UDkt Tumi ngomunye wabavumi asebenzisana nabo.

== I-Discography ==

* Umnyanya (1994)
* Ngiyazizwa ngifuna ukuragela phambili (2000)
* Ukudumisa okukhulu (2002)
* ngentaba ngayinye...ngiyathokoza (2004)
* Uyangibusisa Nanje (2005)
* Ebukhoneni bakhe (2007) 
* Ukukhonza ebukhoneni bakhe (2010)
* Ukupholisa ebukhoneni bakhe (2012)
* Ukuvuselelwa ebukhoneni bakhe (2014)
* Ukucwengiswa ebukhoneni bakhe (2015)
* Ukunqoba ebukhoneni bakhe (2017)
* Inkazimulo ebukhoneni bakhe (2019)
* Odume khulu ebukhoneni bakhe (2023)
* Odume khulu ebukhoneni bakhe 2 (2024)
* Nasiqala emuva &lt;ref&gt;{{Cite web|url=https://www.last.fm/music/Benjamin+Dube/+albums|title=Benjamin Dube albums and discography}}&lt;/ref&gt;

== Iinkomba ==
&lt;references /&gt;
{{Reflist}}{{DEFAULTSORT:Dube, Benjamin}}</text>
      <sha1>cuwf9585nb7oylb1kqodfwu6hmsn16b</sha1>
    </revision>
    <revision>
      <id>5466</id>
      <parentid>5457</parentid>
      <timestamp>2025-09-04T08:17:47Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1289103748|Benjamin Dube]]&quot;</comment>
      <origin>5466</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2075" sha1="d64dc7gxj5nhjhtdtjo51hna0x26hi0" xml:space="preserve">
Benjamin Dube 

Wabelethwa 1962(age 62-63)

eJohanisibhege, eSewula Africa

Ungumvumi wezeKolo

Wathoma ngomhlaka 1980 - kufikela namhlanje

abentwana: amadodana ama-4

U '''-Benjamin Dube''' (wabelethwa ngo-1962) [[South African gospel recording artist|mculi wevangeli weSewula Afrika]] owakhula waba yidumo ekuthomeni kwabo-80. Eminyakeni edlulileko ukhuphe ama-albhamu amanengi afinyelele esigabeni segolide neplatinamu emazingeni womvumo weSewula Afrika. U-Dube godu [[Vosloorus|mfundisi odosa phambili we-High Praise Center e-Vosloorus]], ngepumalanga ye-Johannesburg. &lt;ref name=&quot;AllMusic&quot;&gt;{{Cite web|url=https://www.allmusic.com/artist/pastor-benjamin-dube-mn0000125817/biography|title=Pastor Benjamin Dube Biography|author=Thom Jurek|publisher=AllMusic}}&lt;/ref&gt; 

== Iminyaka yokuthoma ==
Njengombana avela emndenini okholelwako, ikareko [[Dube's music|kaDube]] yomvumo yathoma asesemncani. Wathoma ukuvuma umvumo wevangeli ndawonye nomndenakhe nakaneminyaka elikhomba.    Nakaneminyaka elitjhumi nambili, u-Benjamin wathoma ukuhlabelela nabafowabo abadala esontweni, begodu baziwa ngokuthi bavumi be-Dube Family. Kodwana ngebhadi, izinto bezizokutjhuguluka unomphela emndenini ka-Dube lokha umkhosi wabo noyise nakabulawa kumbi ngo-1976. Umndeni waqunta ukuvuma nokwabelana ngeendaba zokuhlongakala kwakayise. UDkt Tumi ngomunye wabavumi asebenzisana nabo.

== I-Discography ==

* Umnyanya (1994)
* Ngiyazizwa ngifuna ukuragela phambili (2000)
* Ukudumisa okukhulu (2002)
* ngentaba ngayinye...ngiyathokoza (2004)
* Uyangibusisa Nanje (2005)
* Ebukhoneni bakhe (2007) 
* Ukukhonza ebukhoneni bakhe (2010)
* Ukupholisa ebukhoneni bakhe (2012)
* Ukuvuselelwa ebukhoneni bakhe (2014)
* Ukucwengiswa ebukhoneni bakhe (2015)
* Ukunqoba ebukhoneni bakhe (2017)
* Inkazimulo ebukhoneni bakhe (2019)
* Odume khulu ebukhoneni bakhe (2023)
* Odume khulu ebukhoneni bakhe 2 (2024)
* Nasiqala emuva &lt;ref&gt;{{Cite web|url=https://www.last.fm/music/Benjamin+Dube/+albums|title=Benjamin Dube albums and discography}}&lt;/ref&gt;

== Iinkomba ==
&lt;references /&gt;
{{DEFAULTSORT:Dube, Benjamin}}</text>
      <sha1>d64dc7gxj5nhjhtdtjo51hna0x26hi0</sha1>
    </revision>
    <revision>
      <id>5478</id>
      <parentid>5466</parentid>
      <timestamp>2025-09-04T08:39:29Z</timestamp>
      <contributor>
        <username>Imkabini</username>
        <id>901</id>
      </contributor>
      <comment>/* Iminyaka yokuthoma */</comment>
      <origin>5478</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2678" sha1="sxtc56y8rjgf4144btew4d226wyjkbk" xml:space="preserve">
Benjamin Dube 

Wabelethwa 1962(age 62-63)

eJohanisibhege, eSewula Africa

Ungumvumi wezeKolo

Wathoma ngomhlaka 1980 - kufikela namhlanje

abentwana: amadodana ama-4

U '''-Benjamin Dube''' (wabelethwa ngo-1962) [[South African gospel recording artist|mculi wevangeli weSewula Afrika]] owakhula waba yidumo ekuthomeni kwabo-80. Eminyakeni edlulileko ukhuphe ama-albhamu amanengi afinyelele esigabeni segolide neplatinamu emazingeni womvumo weSewula Afrika. U-Dube godu [[Vosloorus|mfundisi odosa phambili we-High Praise Center e-Vosloorus]], ngepumalanga ye-Johannesburg. &lt;ref name=&quot;AllMusic&quot;&gt;{{Cite web|url=https://www.allmusic.com/artist/pastor-benjamin-dube-mn0000125817/biography|title=Pastor Benjamin Dube Biography|author=Thom Jurek|publisher=AllMusic}}&lt;/ref&gt;&lt;ref&gt;[https://www.news24.com/citypress/trending/benjamin-dube-to-celebrate-60th-birthday-with-other-sa-music-heavyweights-20221027 Benjamin Dube to celebrate 60th birthday with other SA music heavyweights | News24]&lt;/ref&gt; 

== Iminyaka yokuthoma ==
Njengombana avela emndenini okholelwako, ikareko [[Dube's music|kaDube]] yomvumo yathoma asesemncani. Wathoma ukuvuma umvumo wevangeli ndawonye nomndenakhe nakaneminyaka elikhomba.&lt;ref name=&quot;AllMusic&quot; /&gt;&lt;ref&gt;[https://iol.co.za/the-star/news/2023-03-26-gospel-inspired-gala-dinner-ushers-in-easter-at-birchwood-hotel/ Gospel-inspired gala dinner ushers in Easter at Birchwood Hotel]&lt;/ref&gt;&lt;ref&gt;https://www.timeslive.co.za/tshisa-live/tshisa-live/2022-05-21-its-like-she-knew-she-didnt-have-much-time-left-benjamin-dube-reveals-last-phone-call-to-deborah-fraser/&lt;/ref&gt; Nakaneminyaka elitjhumi nambili, u-Benjamin wathoma ukuhlabelela nabafowabo abadala esontweni, begodu baziwa ngokuthi bavumi be-Dube Family. Kodwana ngebhadi, izinto bezizokutjhuguluka unomphela emndenini ka-Dube lokha umkhosi wabo noyise nakabulawa kumbi ngo-1976. Umndeni waqunta ukuvuma nokwabelana ngeendaba zokuhlongakala kwakayise. UDkt Tumi ngomunye wabavumi asebenzisana nabo. 

== I-Discography ==

* Umnyanya (1994)
* Ngiyazizwa ngifuna ukuragela phambili (2000)
* Ukudumisa okukhulu (2002)
* ngentaba ngayinye...ngiyathokoza (2004)
* Uyangibusisa Nanje (2005)
* Ebukhoneni bakhe (2007) 
* Ukukhonza ebukhoneni bakhe (2010)
* Ukupholisa ebukhoneni bakhe (2012)
* Ukuvuselelwa ebukhoneni bakhe (2014)
* Ukucwengiswa ebukhoneni bakhe (2015)
* Ukunqoba ebukhoneni bakhe (2017)
* Inkazimulo ebukhoneni bakhe (2019)
* Odume khulu ebukhoneni bakhe (2023)
* Odume khulu ebukhoneni bakhe 2 (2024)
* Nasiqala emuva &lt;ref&gt;{{Cite web|url=https://www.last.fm/music/Benjamin+Dube/+albums|title=Benjamin Dube albums and discography}}&lt;/ref&gt;

== Iinkomba ==
&lt;references /&gt;
{{DEFAULTSORT:Dube, Benjamin}}</text>
      <sha1>sxtc56y8rjgf4144btew4d226wyjkbk</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Mashiloane. N/Page 1</title>
    <ns>2</ns>
    <id>916</id>
    <revision>
      <id>5459</id>
      <timestamp>2025-09-04T08:10:32Z</timestamp>
      <contributor>
        <username>Mashiloane. N</username>
        <id>907</id>
      </contributor>
      <comment>created draft page 1</comment>
      <origin>5459</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="12" sha1="afp03u1j074u8tcgcbaj967ibr6214a" xml:space="preserve">Draft page 1</text>
      <sha1>afp03u1j074u8tcgcbaj967ibr6214a</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Mashiloane. N/Page 2</title>
    <ns>2</ns>
    <id>917</id>
    <revision>
      <id>5461</id>
      <timestamp>2025-09-04T08:11:19Z</timestamp>
      <contributor>
        <username>Mashiloane. N</username>
        <id>907</id>
      </contributor>
      <comment>created draft page 2</comment>
      <origin>5461</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="12" sha1="1y073976bih31w96iv6vkkfsku3dysg" xml:space="preserve">Draft page 2</text>
      <sha1>1y073976bih31w96iv6vkkfsku3dysg</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Mashiloane. N/Page 3</title>
    <ns>2</ns>
    <id>918</id>
    <revision>
      <id>5462</id>
      <timestamp>2025-09-04T08:11:58Z</timestamp>
      <contributor>
        <username>Mashiloane. N</username>
        <id>907</id>
      </contributor>
      <comment>created draft page 3</comment>
      <origin>5462</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="12" sha1="14x97d3nmpd56blutc44fo4hqu4kfzg" xml:space="preserve">Draft page 3</text>
      <sha1>14x97d3nmpd56blutc44fo4hqu4kfzg</sha1>
    </revision>
  </page>
  <page>
    <title>I-Enactus</title>
    <ns>0</ns>
    <id>919</id>
    <revision>
      <id>5464</id>
      <timestamp>2025-09-04T08:16:26Z</timestamp>
      <contributor>
        <username>Pruddy01</username>
        <id>895</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1287039970|Enactus]]&quot;</comment>
      <origin>5464</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4160" sha1="3i85dlum9pc5w6dn40jwvmk218et2fm" xml:space="preserve">
{{Infobox award|name=Enactus|awardname=World Cup|former name=Students in Free Enterprise or SIFE World Cup|established=1975|winner=[[Tunisia business school]]|image=Enactus Full Color logo.png|motto=To engage the next generation of entrepreneurial leaders to use innovation and business principles to improve the world.|year2=2024}}I '''-Enactus World Cup''', nofana '''i-Enactus''', yiphaliswano yokwethula amaphrojekthi wezenhlalakahle weentjhabatjhaba wabafundi beyunivesithi ohlelwe yi-Enactus, ihlangano yamazwe ngamazwe engenzi inzuzo esekelwe e -New York City . Umqhudelwano ogade waziwa nge '''-Students in Free Enterprise''' nofana '''i-SIFE''' bewubanjwa qobe mnyaka kusukela ngo-1975. As of 2024 , amazwe ama-33 abambe iqhaza emncintiswaneni.

== Umlando ==
Ihlangano le yasungulwa ngo-1975 e-United States njengephrojekthi ye- [[National Leadership Institute]] ngaphasi kwebizo elithi Students In Free Enterprise nofana i-SIFE. Bekuyiphaliswano wokwethula iphrojekthi yabosomabhizinisi beentjhabatjhaba wabafundi beyunivesithi ebewuhlelwe yi-Enactus, ihlangano engenzi inzuzo yamazwe ngamazwe ese -Springfield, e-Missouri .      .Ngomnyaka ka-2021, bekuneenqhema ze-Enactus ezili-1,730 emakholijiini namayunivesithi emazweni ama-35 anabafundi abangaba zi-500,000. 

Umnqopho wephrojekthi bekukwenza abafundi bathabe ngomnotho wemakethe yamahhala begodu babacwilise endimeni yabosomabhizinisi namakhamphani ngaphakathi komnotho wemakethe. Igadango leli belisebenza e-US kwaphela, lapho inani lamathimu ahlanganyelako nabafundi lakhula khona ngokuthe ngcembe. Ngo-1995, abafundi be- University of Nebraska-Lincoln babeka isisekelo sokukhula kwephasi loke lokha nababuya e-US baya emazweni wabo. NgoNobayeni wee-2012, ihlangano leyo yabizwa ngokuthi yi-Enactus ngemva kokuhlola kwamalunga yibhodi. 

Mhlana ali-13 kuNtaka 2023, uMongameli no-CEO we-Enactus, u-Robyn Fehrman, wamemezela bona i-Enactus United States ne-Enactus Global bazokuvala imisebenzi yayo yangelanga ekupheleni kukaRhoboyi 2023 ngokuveza iintjhijilo zeezimali.  U-Fehrman wathi izehlakalo ze-Enactus nezahluko zingaragela phambili nokusebenza ngokuzijamela.

Mhlana ali-15 kuMhlolanja 2024, kwamenyezelwa bona [https://resolutionproject.org/ iPhrojekthi ye-Resolution yeenhlangano] ezingenzi inzuzo yamazwe ngamazwe izakuzibophelela ngemali nabantu ukwakha kabutjha i-Enactus Global begodu yenze enye yeenhlangano ezinkulu khulu ezingenzi inzuzo ekuhlanganisweni koburholi belutjha nobusomabhizinisi bezenhlalakahle – ukuhlanganyela abantu abatjha abangaphezu kwe-40,000 qobe mnyaka pheze emazweni ama-1000.  Ngomhlana ali-24 kuNtaka 2025, umsunguli we-Resolution Project kanye nomphathi omkhulu, u-George Tsiatis, watlola i-op-ed ku- Stanford Social Innovation Review acacisa ikambiso yokuhlanganiswa hlangana neenhlangano ezimbili. 

=== Iphaliswano ===
Iphaliswano lliba khona qobe mnyaka kusukela ngo-1975 ngemva kokusungulwa mmeli we-Texas u-Robert T. Davis, ekuthomeni owabizwa ngokuthi ma-Students in Free Enterprise nofana i-SIFE.   kusukela ngomnyaka we-2021 , amazwe ama-33 abambe iqhaza ephgaliswaneni  IYunivesithi ye-Al-Azhar ye -Egypt yathumba umncintiswano wango-2020.  Ngebanga lomtlhago we-COVID-19, umqhudelwano wango-2021 wabanjelwa nge-inthanethi, umnqobi waba mhlana ali-6 kuNobayeni weYunivesithi ye-Egypt.  I-2022 Enactus World Cup yabanjwa mhlazi-30 kuMgwengweni – mhlana ali-2 kuSinyikhaba ngo 2022 e-Puerto Rico, begodu umnqobi bekuyi -Ain Shams University  ye Egypt.   Umcimbi wango-2023 bewuhlelelwe mhlazi-17 ukuya ku-20 kuNobayeni 2023 e- Utrecht, e-Netherlands.  Umnyanya we-2024 bewubanjelwe e -Astana, e-Kazakhstan lapho i-Tunis Business School evela e-Tunisia yathumba umnyanya lo. 

=== Ukuphatha ===


Ngomnyaka ka-2014, umphathi owayengu-Sam M. Walton SIFE Fellow (njengombana abeluleki be-SIFE bebaziwa ngaleso sikhathi) watlola imemori malungana nesipiliyoni sakhe ne-SIFE. Igama lencwadi  elithi, ''How High Is Up'', beyigxeka ukuphathwa kwe-SIFE nemikghwa yokuziphatha. Ngomphumela, ibhodo ye-SIFE yathumela iphenyo elizijameleko elabangela amatjhuguluko amanengi eenlawulweni zangaphakathi kwama nrhwebo. 

== Iinkomba ==
{{Reflist}}</text>
      <sha1>3i85dlum9pc5w6dn40jwvmk218et2fm</sha1>
    </revision>
  </page>
  <page>
    <title>I-Cassper Nyovest</title>
    <ns>0</ns>
    <id>920</id>
    <revision>
      <id>5465</id>
      <timestamp>2025-09-04T08:17:21Z</timestamp>
      <contributor>
        <username>Sister01</username>
        <id>893</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1301911924|Cassper Nyovest]]&quot;</comment>
      <origin>5465</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="14490" sha1="k7r0wv9kkxzttgmfq18mymm38o8ljt8" xml:space="preserve">
 

'''U-Refiloe Maele Phoolo''' (wabelethwa mhla amalanga ali-16 kuNobayeni 1990), owaziwa ngomsebenzi ngo- '''Cassper Nyovest''', mrepha weSewula Afrika, umtloli weengoma, usomabhizinisi, umkhiphi wamarekhodi kanye nomdlali wamaguduva.  Wabelethwa begodu wakhulela e -Mahikeng, e-North West, uthathwa njengomunye wabavumi abaphumelele khulu eSewula Afrika.  Ngo-2014, wasungula ilebula yakhe yokurekhoda, i-Family Tree Records .  U-Nyovest waduma ngokukhutjhwa kwe-albhamu yakhe yokuthoma, ''i-Tsholofelo'' (2014) eyakhipha iingoma ezidumileko ezithi &quot; Gusheshe &quot; kanye ne-&quot;Doc Shebeleza&quot;. 

Ngepumelelo yakhe yokuthengisa amathikithi wekhonsathi yakhe, ''i-Fill Up the Dome'' (2015) ebeyibanjwe e- Ticketpro Dome e [[Johannesburg|-Goli]] .  Ipumelelo yomnyanya lo yalandelela i-Nyovest ngesihlanganisi esithi &quot;Fill Up&quot; ukukhuthaza amakhonsathi amanengi eenkundleni ezihlukahlukeneko qobe mnyaka, kufaka hlangana i-Orlando Stadium (2016) ne -FNB Stadium (2017), nazo zombili e-Johannesburg, i-Moses Mabhida Stadium (2018) e- Durban, kanye ne -Royal Stadium (2019) e- North West . 

U-Nyovest wakhipha i-albhamu yakhe enebizo [[wiktionary:eponym|elifanako]], ''i-Refiloe'', eyakhutjhwa mhla amalanga ama-31 kuMgwengweni 2015, ekhonsathini yakhe ''ye-Fill Up The Dome'' . I-albhamu le isebenzisana nabavumi abanengi abafaka hlangana i-The Game, i-DJ Drama, i-Stonebwoy kanye ne -Casey Veggies .  Walandela ipumelelo le nge-albhamu yakhe yesithathu eyadunyiswa khulu ''i-Thuto'' (2018), kanye ne-albhamu yakhe yesine ye- Kwaito, ''i-Sweet and Short'' (2019).

== Ipilo yokuthoma ==
 
U-Refiloe Maele Phoolo wabelethwa mhla amalanga ali-16 kuNobayeni 1990 e- Mafikeng, idorobha le- North West, ku-Muzuki no-Letsebela Phoolo. UNyovest unodadwabo okuthiwa ngu-Tsholofelo Phoolo; umfowabo ongasekho, u-Khotso Phoolo, wahlongakala ngo-2003.   u-Nyovest waya e-Sol Plaatjie Secondary School lapho bekangumdlali, adlala imidlalo eminengi, begodu wathoma ukurepha aneminyaka eli-12.  Ngo-2006, u-Nyovest akhange aphumelela ebangeni lakhe le-10; lokhu kwamenza wathuthela emzini kagogo wakhe e -Potchefstroom . Ngemva kwalokhu, ngo-2007,  wathatha umhlal pahsi esikolweni samabanga aphezulu aneminyaka eli-16. 

Ngomnyaka ka-2008, u-Nyovest wathuthela e-Goli, ukuyokwenza umsebenzi womqulo njengomrepha nomkhiqizi. Wenza igadango ngemva kokutjela ababelethi bakhe bona angakhetha ukulandelela amabhudango wakhe agade abona angakghona ukuwafinyelela kunokuthi adlale &quot;ngokuzitjheja&quot; begodu &quot;azisole&quot; ipilo yakhe yoke. 

== Umsebenzi wokuvuma ==

=== 2004–2014: Ukuthoma kanye ne ''-Tsholofelo'' ===
 
Ngo-2004, nakaneminyaka eli-13 kwaphela, u-Nyovest wakha isiqhema se -hip hop esibizwa nge ''-Childhood Gangsta'' nabangani bakhe. Wabe watjhiya ukujoyina isiqhema sakhe esilandelako, ''i-Slow Motion'', ebesinamalunga abunane, kufaka hlangana umkhiqizi wamarekhodi u-Aashish Gangaram we-Ganja Beatz.  Eminyakeni eli-16, begodu ngemva kokutjhiya isikolo, u-Nyovest watlikitla ne -motswako record label Impact Sounds, nayo eyatlikitla abavumi abafana no -Tuks Senganga no-Morafe (ngo-2006);  ubudlelwano hlangana ne-Nyovest ne-Impact Sounds bagcina buphela ngebanga lokungafuni izinto ezifanako.  Ngo-2008, zombili iinhlangano zahlukana, u-Nyovest waba mvumi ozijameleko.

U-Nyovest wabuyela ekhaya, wazakhela irekhodi lakhe.  Ngaphambi kokobana asungule ilebula yakhe, watholwa mrepha u -Hip Hop Pantsula ngesikhathi adlala, owafaka u-Nyovest engomeni yakhe ethi &quot;Wamo Tseba Mtho&quot;. 

U-Nyovest wakhipha ingoma yakhe yokuthoma, &quot; Gusheshe &quot; (ehlanganisa u-Okmalumkoolkat ), ngo-2013  begodu, ngo-2014, wasungula irekhodi lakhe elibizwa nge -Family Tree Records .  Ingoma yakhe yesibili, &quot;Doc Shebeleza&quot;, yakhutjhwa ngomnyaka ofanako, begodu yabizwa ngegama lomculi we -kwaito u-Doc Shebeleza .  Ingoma le yathola ukubuyekezwa okuhle emphakathini, begodu yadunyiswa babantu abadumileko, njengomvumi u-Yvonne Chaka Chaka . 

Mhla amalanga ali-18 kuNtaka 2014, u-Nyovest wakhipha i-albhamu yakhe yokuthoma ''i-Tsholofelo'', ebizwa ngodadewabo.  I-albhamu le ibe yipumelelo ehle khulu, yafika endaweni yokuthoma ku -iTunes ''SA'' (yeSewula Afrika) ama-albhamu eenyangeni ezimbili ezilandelanako (ngoVelabahlinze kanye noRhoboyi 2014).  NgoMgwengweni 2014, u-Nyovest wabekwa njengomvumi ophezulu emdlalweni we -MTV Base i ''-The Hottest MC in Africa'', begodu wabekwa njengonomboro. 2 ku-“ MTV SA’s Hottest MCs ” ngalowo mnyaka. 

=== 2015–2016: ''Refiloe'' ===
 
Ngepumelelo ye ''-Tsholofelo'', uNyovest wakhipha i-albhamu yeplatinamu lokhu kufaka hlangana iingoma ezitjha nokusebenzisana no- Casey Veggies, u-DJ Drama, u-Wizkid no -Anatii .  I-editjhini yeplatinamu yakhutjhwa mhla amalanga-17 kuMrhayili 2015, ngomkhawulo wamakhophi ali-10,000 agadangisiweko.

Ekupheleni kwekota yesithathu ka-2015, u-Nyovest wamemezela ihloso yakhe yokudosa phambili ekhonsathini ebizwa nge ''-Fill Up The Dome'' e- Ticketpro Dome, [[Johannesburg|e-Goli]], mhlazi-31 kuMgwengweni wee-2015. umthamo&quot;.  Wamemezela nokuthi i-albhamu yakhe yesibili, ebizwa nge ''-Refiloe'', izokukhutjhwa ngelanga lomnyanya.

Mhla ali-14 kuRhoboyi wee-2015, u-Nyovest wakhipha i-“Mama I Made It” ''(#MIMI)'', ingoma ephambili ye-albhamu yakhe yesibili, kanye nenye yeengoma zokukhangisa zekhonsathi ye- ''Fill Up The Dome'' .  U-Nyovest wakghona ukuthengisa woke amathikithi womnyanya wakhe njengombana begade ahlosile mhla ama-25 kuNobayeni 2015, lokhu kwamenyezelwa eenkundleni zokuthintana ekuyi Twitter  Ngelanga lomnyanya, abathengi bamathikithi bathola ikhophi yamahhala ye-albhamu ye- ''Refiloe'' .  Ukukhuthazwa lokhu kwabangela bona i-albhamu leyo ibe yigolide ngelanga lelo.  I-albhamu leyo yaqinisekiswa njengeplatinamu malungana nokuthunyelwa kwamakhophi angaphezu kwama-40,000, ngaphakathi kwelizwe. 

UNyovest wamemezela umnyanya wesibili, ''i-Fill Up Orlando Stadium'', ozokubanjelwa e- Orlando Stadium, e-Soweto, e-Johannesburg mhla ama-29 kuNobayeni 2016 amalanga amabili ngaphambi komnyanya we-Ticketpro Dome.  Umnyanya lo waphumelela, begodu bekunabantu abangama-40,000 (abantu ebegade bangena enkundleni) ebegade bakhona. Inani elihlanganisiweko labantu abangaba zi-80,000 bebakhona emakhonsathini womabili.  Kokubili ngo-2015 no-2016, uNyovest beyibekwa ku-no. 1 ku- MTV Base: I-SA's Hottest MCs list. Waphinda waba sesigabeni esingu-1. 1 ku-2016 Hottest Rapper e-Afrika kusukela ngo-2014.  

=== 2017–2019: ''Thuto'' no- ''Sweet no-Short'' ===
{{Reflist|30em}}
Mhlana amalanga ama-4 kuNtaka 2017, u-Nyovest wakhipha ingoma ephambili ethi &quot;Tito Mboweni&quot; evela ku-albhamu yakhe yesithathu ''i-Thuto'' .  Ibizwe ngoNgqongqotjhe wezeeMali weSewula Afrika begodu owayengumbusi we-SARB u-Tito Mboweni, ingoma le yathengiswa khulu ngebanga lengoma yayo, &quot;Shaa Shaa&quot; okuyi- onomatopoeia yomdumo wenothi yemali. 

''I-Thuto'' yakhutjhwa mhla amalanga ama-5 kuMrhayili 2017. Yaqinisekiswa yigolide ekuyi -RiSA ngelanga lokukhutjhwa kwayo begodu yaqinisekiswa njengeplatinamu ngemveke ezilandelanako.  U-Nyovest umemezele umnyanya wakhe wesithathu &quot;we-Fill Up&quot;, owabanjwa mhla amalanga ali-17 kuNobayeni 2017, enkundleni ezi-94,736, i-FNB Stadium, e-Goli.   Umnyanya lo bewuhlelelwe ukuzalisa abantu aba-75,000 kwaphela ebekuyinselele yakhe ekulu. U-Nyovest waba nobudisi bokubhadela umdlalo lo, kodwana ekugcineni wathola abaxhasi aba-3 abakhulu ukumsiza: i-Cîroc SA, i-SABC 1 kanye ne -Budweiser .  Umnyanya lo akhange uthengise woke amathikithi wawo kodwana waba yipumelelo.

Ngomnyaka ka-2018, u-Nyovest wakhupha i-albhamu yakhe yesine ''i-Sweet and Short'' . I-albhamu yaqinisekiswa njengeplatinamu ngelanga yayo yokukhutjhwa.  Indawo yomcimbi olandelako we-Nyovest &quot;Fill Up&quot; bekuse- Moses Mabhida Stadium, e-Durban ebekuhlelelwe mhlazi-1 kuNobayeni 2018.  Wakghona ukuthengisa amathikithi ama-68,000 okwaba mphumela omuhle.  Ngelanga elilandelako, u-Nyovest wenza umnyanya emcimbini owethulwe yi-Motsepe Foundation, i-Global Citizen Festival : Mandela 100 ebeyiholwa ba-Carters .  E-Mzansi Kwaito kanye ne-House Music Awards, ingoma yakhe ethi &quot;Gets Getsa 2.0&quot; yawina umvuzo we-Best New Age Kwaito Song.  Mhlana amalanga ali-15 kuNobayeni 2019, u-Nyovest wenza umnyanya wakhe wesihlanu we-&quot;Fill Up&quot; owabanjelwa e- Royal Bafokeng Stadium e- Rustenburg, idorobha le -North West – isifunda lapho azalelwa khona.   Ngemva kokuhlatjwa balandeli be-hip hop ngokutjhiya umhlobo lo, u-Nyovest wabuya ngo-2020 ngengoma ye-hip hop ebizwa nge- [https://hiphopza.com/cassper-nyovest-good-for-that/ Good For That] Archived   .

=== 2020–2022: ''Nanyana ngimuphi umzuzu nje'', ''omnandi nomfitjhani 2.0'' ===
Mhlana amalanga ali-11 kuNobayeni wee-2020, i-albhamu yakhe yesihlanu ye ''-Any Minute Now'' yakhutjhwa.    I-albhamu ifaka hlangana u-Zola 7, u-Samthing Soweto, u-Langa Mavuso, u-Tellaman, u-YoungstaCPT, u-Busiswa, u- Nadia Nakai, u-Khuli Chana, u-Tuks, u-Mo' Molemi, u-Towdee Mac no-DJ Lemonka. 

Mhlana amalanga ama-30 kuNtaka 2021, u-Cassper wakhupha i-albhamu yakhe yokuthoma ye-Amapiano studio ''Sweet And Short 2.0'', eneengoma ezili-10 ezihlanganisa u-Abidoza, u-Samthing Soweto, u-LuuDadeejay, u-Kammu Dee, u-Lady Du, u-Ma Lemon, u-Semi Tee, u-Boohle, u- [[Oupa John Sefoka (Dj Sumbody)|DJ Sumbody]], u-Zuelisa, u-Zuelisa, no-Zumaz.  mhlana amalanga abu-4 kuNobayeni 2021, waya e-United Kingdom ukuya e-AmaFest Tour kanye no-DJ Maphorisa, DBN Gogo kanye ne -Focalistic ukuthuthukisa umhlobo we -Amapiano . 

U-Cassper wavela emhlanganweni &quot;Umjolo&quot; no-Abidoza no -Boohle okhutjhwe mhlazi-30 kuNobayeni 2021.  

=== 2023-nje: ''u-Solomon'', i-African Throne World Tour ===
UCassper umemezele i-albhamu yakhe ye-studio ''Solomon'', ngasekupheleni kukaMeyi, ebegade izokhutjhwa mhlazi-28 kuNtaka 2023. 

NgoMeyi 2023, u-Cassper Nyovest no -Nasty C bamemezela i-African Throne World Tour, efaka hlangana amalanga ali-12.  Izokuthoma mhlana ali-18 kuRhoboyi, e-Arusha, e-Tanzania bekube mhlazi-28 kuMgwengweni mhlazi-28, e-Goli, eSewula Afrika.

I-albhamu yahlehliswa begodu yamenyezelwa ingoma &quot;018&quot; ene- Maglera Doe Boy .  Ingoma le yakhutjhwa mhlazi-15 kuNobayeni 2023, njenge-albhamu ephambili. 

''U-Solomon'' wakhutjhwa mhlana ali-15 kuNobayeni 2023.  Yaba yinombolo yokuthoma eSewula Afrika. 

Mhlana amalanga ali-9 kuNobayeni 2021, waba msingathi ''womdlalo we-The Braai no-Cass'' osakazwa ku- SABC 1 .  

=== Ukuvunywa ===
U-Nyovest ufumene iimvumelwano ezinengi zokuvunywa neenkhamphani ezihlukahlukeneko, khulukhulu nomhlobo we-vodka, ''i-Ciroc'' okungenye yeenvumelwano zakhe ezikulu zokuvunywa emsebenzini wakhe bekube nje.  Ukusekelwa kwabo kwathoma ngo-2017, lokha u-Nyovest nakaveza ividiyo yakhe yomvumo, ''u-Tito Mboweni'' amabhodlela amanengi we-Cîroc. I-Ciroc yaveza isivumelwano sayo ne-Nyovest. Ngomnyaka ka-2015, u-Nyovest wavumelana ne -MTN ne ''-AG Mobile'' ekuthomeni i -smartphone ebizwa ngokuthi, ''i-AG Hashtag'' eyaphefumulelwa begodu yakhiwe nguye.  Waphinde wasekela amanye amabhrendi afakahlangana, i-Shoprite, i-Samsung ''South Africa'', i-Coca-Cola, i-KFC ''SA'', i-Castle Lite, i-Nike ''SA'' kanye ne-Bitcasino.  

Njengosomabhizinisi, i-Nyovest isungule i- Family Tree Records . Ilebula yamarekhodi yasungulwa ngo-2014 ngemva kokutjhiya kwakhe ilebula, ''i-Impact Soundz'' . 

=== Umsuka wodumo ===
NgoJulayi 2021, wasungula ikhamphani yama-sneaker i-Root of Fame, ngaphasi kwe-Drip Footwear. 

=== U-Billiato ===

== Isibhakela ==

=== Udumo ngokujamelana nomthelela ===

=== Umlingisi nomvumi ===
Umdlalo wesibhakela onesihloko esithi &quot;Actor vs Musician&quot; wabanjwa e -Sun City Stadium mhlazi-9 kuMrhayili 2022.  u-Cassper Nyovest wahlulwa yi- NaakMusiQ ngemva kokumthatha waya emzuliswaneni wesihlanu. 

NgoJulayi 2015, ngemva kweenyanga ezinengi baphika nanyana ngikuphi ukuzibandakanya ngothando, uNyovest nomlingisi uBoity Thulo ekugcineni baqinisekisa (kumagazini kaJulayi we ''-DRUM'' ) bona bayathandana. Isihloko esisekhava kamagazini besitjho bona abathandanako bebathembisene, kodwana u-Nyovest no-Thulo ngokukhamba kwesikhathi bakuphika lokhu, bathi umagazini wasebenzisa isihloko njengeqhinga lokukhuphula ukuthengisa kwabo.  Iinthandani zahlukana ngoNobayeni 2015.

=== Ukurarana ===
Ngomnyaka ka-2014, i-Nyovest beyihlangahlangene nembangi yesikhathi eside, i-AKA .  Njengoba uNyovest athi ingoma yakhe ethi &quot;Doc Shebeleza&quot; bekuyingoma ekulu kunazo zoke ku-Hip-Hop yeSewula Afrika, AKA obekakhuthaza ingoma yakhe etja ethi &quot; Congratulate &quot;, watjengisa ukuphikisana lokha nakathumela ku-Twitter, &quot;Kunomrepha ogijima athi unengoma ekulu khulu enarheni ... Ngikuphonsela inselelo yokuthi ufumane ingoma yakhe ku-Top 10&quot;.  Ngemva kwalokho, u-Nyovest waphendula nge-tweet eveza iinzathu zokuthi kubayini ingoma yakhe beyinkulu kune-AKA. Ukuphikisana kwakhula njengombana bobabili abarepha bebaphendulana kanengi.  Ngenyanga kaRhoboyi wee-2014, bobabili bebahlelwe bona bobabili badlale emdlalweni womculo we-SABC 1, ''i-Live Amp'' lokha ilunga leqembu le-AKA kuthiwa ladosa isibhamu ku-Cassper nesiqhema sakhe.  Kwavela ukuphikisana okunye ngo-2015, lokha u-Cassper nakasola u-AKA ngokumshaya ngempama okwabangela bona bobabili abarepha bakhuphe iingoma ezimbi. Ngomnyaka ka-2018 lokha uNyovest nakabuzwa ngobujamo bokuphikisana kwakhe ne-AKA, wathi bobabili angeze babuyisana, okube kuliqiniso bekube nje. 

Ngomnyaka ka-2018, umvumi we -Xitsonga, u-Benny Mayengani bekazokwenza ikhonsathi yakhe ebizwa ngokuthi, ''#FillUpGiyaniStadium'' . Njengoba u-Mayengani asebenzise isihlanganisi esifanako (&quot;Fill Up&quot;/&quot;#FillUp&quot;) njengo-Nyovest, u-Nyovest wabe esesola u-Mayengani ngokusebenzisa itshwayo lakhe lokurhweba ngendlela yokumthumela incwadi yokujama nokujama .  Iphenyo liveze bona i-Nyovest ayikabi nomnikazi wephawu lokuthengisa le-#FillUp begodu angeze yathatha nanyana ngiliphi igadango. 

== Imiklomelo nokuphakanyiswa ==
U-Nyovest unikelwe begodu wakhethelwa imiklomelo yomvumo ehlukileko ekhaya neyamazwe ngamazwe. Isethi yakhe yokuthoma yemiklomelo beyingo-2013 lokha nakathola imiklomelo emine emdlalweni wesibili we ''-South Africa Hip Hop Awards'' .  Mhlana ali-13 kuMrhayili 2018, wathola ukuphakanyiswa ku-12th Headies Award e-Nigeria emkhakheni we-Best African Artiste eceleni kuka-Nasty C, u-Sarkodie we-Ghana, isiqhema se-Kenya i-Sauti Sol, kanye nomvumi we-Tanzania u-Vanessa Mdee. 

== I-Discography ==

* ''Tsholofelo'' (2014)
* ''Refiloe'' (2015)
* ''Thuto'' (2017)
* ''Okumnandi nokufitjhani'' (2018)
* ''AMN (Any Minute Now)'' (2020)
* ''I-Sweet and Short 2.0'' (2021)
* ''USolomon'' (2023)

== Umthombo lwazi ==
{{Reflist|30em}}</text>
      <sha1>k7r0wv9kkxzttgmfq18mymm38o8ljt8</sha1>
    </revision>
  </page>
  <page>
    <title>U-Justin Timberlake</title>
    <ns>0</ns>
    <id>922</id>
    <revision>
      <id>5471</id>
      <timestamp>2025-09-04T08:24:28Z</timestamp>
      <contributor>
        <username>2000Gp01</username>
        <id>880</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1309121808|Justin Timberlake]]&quot;</comment>
      <origin>5471</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="878" sha1="0cfuis7jyjbseclucd8m7n7u4fc6b3i" xml:space="preserve">
 

U- '''Justin Randall Timberlake''' (wabelethwa mhlazi-31 kuTjhirhweni 1981)  mvumi we-America, umtloli weengoma, umlingisi, umkhiqizi wamarekhodi, nomdansi.  Ebizwa ngokuthi &lt;nowiki&gt;&quot;&lt;/nowiki&gt; yikosana ye-Pop &lt;nowiki&gt;&quot;&lt;/nowiki&gt;, ''i-Billboard'' yamhlonipha njengomlingisi omumuntu wembaji odlala yedwa ngcono ku -Pop Airplay begodu omunye wabadlali abakhulu be-Pop abamakhulu ama-21 .   U-Timberlake uhlala hlangana nabaculi abarekhodako abathengisa khulu, ngokuthengisa amarekhodi angaphezu kweengidi ezima-88 ephasini loke. Imitlomelo yakhe ifakahlangana ama-Grammy Awards alitjhumi, ama-Primetime Emmy amane, ama-Brit amathathu, &lt;nowiki&gt;&lt;i id=&quot;mwNA&quot;&gt;ama-BMA&lt;/i&gt;&lt;/nowiki&gt; alithoba, i- Contemporary Icon Award ye- Songwriters Hall of Fame, kanye ne- MTV 's Michael Jackson Video Vanguard Award . Usolo asebenzisana nabakhiqizi abafana ne -The Neptunes kanye ne-Timbaland .</text>
      <sha1>0cfuis7jyjbseclucd8m7n7u4fc6b3i</sha1>
    </revision>
    <revision>
      <id>5489</id>
      <parentid>5471</parentid>
      <timestamp>2025-09-04T08:57:44Z</timestamp>
      <contributor>
        <username>2000Gp01</username>
        <id>880</id>
      </contributor>
      <origin>5489</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1158" sha1="mqm72ze7yp3v1fgpo94j21o83shvccw" xml:space="preserve">
 

U- '''Justin Randall Timberlake''' Justin &lt;ref&gt;{{Cite web |date=2025-08-10 |title=Justin Timberlake {{!}} Songs, Movies, Lyme Disease, Wife, Britney Spears, &amp; Facts {{!}} Britannica |url=https://www.britannica.com/biography/Justin-Timberlake |access-date=2025-09-04 |website=www.britannica.com |language=en}}&lt;/ref&gt;
(wabelethwa mhlazi-31 kuTjhirhweni 1981)  mvumi we-America, umtloli weengoma, umlingisi, umkhiqizi wamarekhodi, nomdansi.  Ebizwa ngokuthi &lt;nowiki&gt;&quot;&lt;/nowiki&gt; yikosana ye-Pop &lt;nowiki&gt;&quot;&lt;/nowiki&gt;, ''i-Billboard'' yamhlonipha njengomlingisi omumuntu wembaji odlala yedwa ngcono ku -Pop Airplay begodu omunye wabadlali abakhulu be-Pop abamakhulu ama-21 .   U-Timberlake uhlala hlangana nabaculi abarekhodako abathengisa khulu, ngokuthengisa amarekhodi angaphezu kweengidi ezima-88 ephasini loke. Imitlomelo yakhe ifakahlangana ama-Grammy Awards alitjhumi, ama-Primetime Emmy amane, ama-Brit amathathu, &lt;nowiki&gt;&lt;i id=&quot;mwNA&quot;&gt;ama-BMA&lt;/i&gt;&lt;/nowiki&gt; alithoba, i- Contemporary Icon Award ye- Songwriters Hall of Fame, kanye ne- MTV 's Michael Jackson Video Vanguard Award . Usolo asebenzisana nabakhiqizi abafana ne -The Neptunes kanye ne-Timbaland .</text>
      <sha1>mqm72ze7yp3v1fgpo94j21o83shvccw</sha1>
    </revision>
    <revision>
      <id>5490</id>
      <parentid>5489</parentid>
      <timestamp>2025-09-04T08:59:56Z</timestamp>
      <contributor>
        <username>2000Gp01</username>
        <id>880</id>
      </contributor>
      <comment>added reference</comment>
      <origin>5490</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1181" sha1="ovnx5ujbbg0zzgckf678btp4zcb5k09" xml:space="preserve">
 

U- '''Justin Randall Timberlake''' Justin &lt;ref&gt;{{Cite web |date=2025-08-10 |title=Justin Timberlake {{!}} Songs, Movies, Lyme Disease, Wife, Britney Spears, &amp; Facts {{!}} Britannica |url=https://www.britannica.com/biography/Justin-Timberlake |access-date=2025-09-04 |website=www.britannica.com |language=en}}&lt;/ref&gt;
(wabelethwa mhlazi-31 kuTjhirhweni 1981)  mvumi we-America, umtloli weengoma, umlingisi, umkhiqizi wamarekhodi, nomdansi.  Ebizwa ngokuthi &lt;nowiki&gt;&quot;&lt;/nowiki&gt; yikosana ye-Pop &lt;nowiki&gt;&quot;&lt;/nowiki&gt;, ''i-Billboard'' yamhlonipha njengomlingisi omumuntu wembaji odlala yedwa ngcono ku -Pop Airplay begodu omunye wabadlali abakhulu be-Pop abamakhulu ama-21 .   U-Timberlake uhlala hlangana nabaculi abarekhodako abathengisa khulu, ngokuthengisa amarekhodi angaphezu kweengidi ezima-88 ephasini loke. Imitlomelo yakhe ifakahlangana ama-Grammy Awards alitjhumi, ama-Primetime Emmy amane, ama-Brit amathathu, &lt;nowiki&gt;&lt;i id=&quot;mwNA&quot;&gt;ama-BMA&lt;/i&gt;&lt;/nowiki&gt; alithoba, i- Contemporary Icon Award ye- Songwriters Hall of Fame, kanye ne- MTV 's Michael Jackson Video Vanguard Award . Usolo asebenzisana nabakhiqizi abafana ne -The Neptunes kanye ne-Timbaland .

== Imithombo lwazi ==</text>
      <sha1>ovnx5ujbbg0zzgckf678btp4zcb5k09</sha1>
    </revision>
    <revision>
      <id>5502</id>
      <parentid>5490</parentid>
      <timestamp>2025-09-04T09:09:20Z</timestamp>
      <contributor>
        <username>2000Gp01</username>
        <id>880</id>
      </contributor>
      <origin>5502</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1433" sha1="pwnzblyq66hmqob716vwlyzbgrrgqek" xml:space="preserve">
 

U- '''Justin Randall Timberlake''' &lt;ref&gt;{{Cite web |date=2025-08-10 |title=Justin Timberlake {{!}} Songs, Movies, Lyme Disease, Wife, Britney Spears, &amp; Facts {{!}} Britannica |url=https://www.britannica.com/biography/Justin-Timberlake |access-date=2025-09-04 |website=www.britannica.com |language=en}}&lt;/ref&gt;
(wabelethwa mhlazi-31 kuTjhirhweni 1981)  mvumi we-America, umtloli weengoma, umlingisi, umkhiqizi wamarekhodi, nomdansi.  Ebizwa ngokuthi &lt;nowiki&gt;&quot;&lt;/nowiki&gt; yikosana ye-Pop &lt;nowiki&gt;&quot;&lt;/nowiki&gt;, ''i-Billboard'' &lt;ref&gt;{{Cite book |last=Inc |first=Nielsen Business Media |url=https://books.google.com/books?id=bQ8EAAAAMBAJ&amp;q=2003+billboard+music+awards+justin+timberlake&amp;pg=PA20 |title=Billboard |date=2003-12-13 |publisher=Nielsen Business Media, Inc. |language=en}}&lt;/ref&gt; yamhlonipha njengomlingisi omumuntu wembaji odlala yedwa ngcono ku -Pop Airplay begodu omunye wabadlali abakhulu be-Pop abamakhulu ama-21.   U-Timberlake uhlala hlangana nabaculi abarekhodako abathengisa khulu, ngokuthengisa amarekhodi angaphezu kweengidi ezima-88 ephasini loke. Imitlomelo yakhe ifakahlangana ama-Grammy Awards alitjhumi, ama-Primetime Emmy amane, ama-Brit amathathu, &lt;nowiki&gt;&lt;i id=&quot;mwNA&quot;&gt;ama-BMA&lt;/i&gt;&lt;/nowiki&gt; alithoba, i- Contemporary Icon Award ye- Songwriters Hall of Fame, kanye ne- MTV 's Michael Jackson Video Vanguard Award . Usolo asebenzisana nabakhiqizi abafana ne -The Neptunes kanye ne-Timbaland .

== Imithombo lwazi ==</text>
      <sha1>pwnzblyq66hmqob716vwlyzbgrrgqek</sha1>
    </revision>
    <revision>
      <id>5509</id>
      <parentid>5502</parentid>
      <timestamp>2025-09-04T09:15:05Z</timestamp>
      <contributor>
        <username>2000Gp01</username>
        <id>880</id>
      </contributor>
      <origin>5509</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1621" sha1="squi0s5wl0h5znwa4y78xxccevdxpov" xml:space="preserve">
 

U- '''Justin Randall Timberlake''' &lt;ref&gt;{{Cite web |date=2025-08-10 |title=Justin Timberlake {{!}} Songs, Movies, Lyme Disease, Wife, Britney Spears, &amp; Facts {{!}} Britannica |url=https://www.britannica.com/biography/Justin-Timberlake |access-date=2025-09-04 |website=www.britannica.com |language=en}}&lt;/ref&gt;
(wabelethwa mhlazi-31 kuTjhirhweni 1981)  mvumi we-America, umtloli weengoma, umlingisi, umkhiqizi wamarekhodi, nomdansi.  Ebizwa ngokuthi &lt;nowiki&gt;&quot;&lt;/nowiki&gt; yikosana ye-Pop &lt;nowiki&gt;&quot;&lt;/nowiki&gt;, ''i-Billboard'' &lt;ref&gt;{{Cite book |last=Inc |first=Nielsen Business Media |url=https://books.google.com/books?id=bQ8EAAAAMBAJ&amp;q=2003+billboard+music+awards+justin+timberlake&amp;pg=PA20 |title=Billboard |date=2003-12-13 |publisher=Nielsen Business Media, Inc. |language=en}}&lt;/ref&gt; yamhlonipha njengomlingisi omumuntu wembaji odlala yedwa ngcono ku -Pop Airplay begodu omunye wabadlali abakhulu be-Pop abamakhulu ama-21.   U-Timberlake uhlala hlangana nabaculi abarekhodako abathengisa khulu, ngokuthengisa amarekhodi angaphezu kweengidi ezima-88 ephasini loke. Imitlomelo yakhe ifakahlangana ama-Grammy Awards alitjhumi, ama-Primetime Emmy amane, ama-Brit amathathu, &lt;nowiki&gt;&lt;i id=&quot;mwNA&quot;&gt;ama-BMA&lt;/i&gt;&lt;/nowiki&gt; alithoba, i- Contemporary Icon Award ye- Songwriters Hall of Fame&lt;ref&gt;{{Cite web |title=Justin Timberlake |url=https://memphismusichalloffame.com/inductee/justintimberlake/ |access-date=2025-09-04 |website=Memphis Music Hall of Fame |language=en}}&lt;/ref&gt;, kanye ne- MTV 's Michael Jackson Video Vanguard Award . Usolo asebenzisana nabakhiqizi abafana ne -The Neptunes kanye ne-Timbaland .

== Imithombo lwazi ==</text>
      <sha1>squi0s5wl0h5znwa4y78xxccevdxpov</sha1>
    </revision>
    <revision>
      <id>5522</id>
      <parentid>5509</parentid>
      <timestamp>2025-09-04T09:23:03Z</timestamp>
      <contributor>
        <username>2000Gp01</username>
        <id>880</id>
      </contributor>
      <origin>5522</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1799" sha1="nu8jck4u8y4psr7dipesglwpdq3t4ji" xml:space="preserve">
 

U- '''Justin Randall Timberlake''' &lt;ref&gt;{{Cite web |date=2025-08-10 |title=Justin Timberlake {{!}} Songs, Movies, Lyme Disease, Wife, Britney Spears, &amp; Facts {{!}} Britannica |url=https://www.britannica.com/biography/Justin-Timberlake |access-date=2025-09-04 |website=www.britannica.com |language=en}}&lt;/ref&gt;
(wabelethwa mhlazi-31 kuTjhirhweni 1981)  mvumi we-America, umtloli weengoma, umlingisi, umkhiqizi wamarekhodi, nomdansi.  Ebizwa ngokuthi &lt;nowiki&gt;&quot;&lt;/nowiki&gt; yikosana ye-Pop &lt;nowiki&gt;&quot;&lt;/nowiki&gt;, ''i-Billboard'' &lt;ref&gt;{{Cite book |last=Inc |first=Nielsen Business Media |url=https://books.google.com/books?id=bQ8EAAAAMBAJ&amp;q=2003+billboard+music+awards+justin+timberlake&amp;pg=PA20 |title=Billboard |date=2003-12-13 |publisher=Nielsen Business Media, Inc. |language=en}}&lt;/ref&gt; yamhlonipha njengomlingisi omumuntu wembaji odlala yedwa ngcono ku -Pop Airplay begodu omunye wabadlali abakhulu be-Pop abamakhulu ama-21.   U-Timberlake uhlala hlangana nabaculi abarekhodako abathengisa khulu, ngokuthengisa amarekhodi angaphezu kweengidi ezima-88 ephasini loke. Imitlomelo yakhe ifakahlangana ama-Grammy Awards&lt;ref&gt;{{Cite web |title=Justin Timberlake {{!}} Artist {{!}} GRAMMY.com |url=https://grammy.com/artists/justin-timberlake/15478 |access-date=2025-09-04 |website=grammy.com}}&lt;/ref&gt; alitjhumi, ama-Primetime Emmy amane, ama-Brit amathathu, &lt;nowiki&gt;&lt;i id=&quot;mwNA&quot;&gt;ama-BMA&lt;/i&gt;&lt;/nowiki&gt; alithoba, i- Contemporary Icon Award ye- Songwriters Hall of Fame&lt;ref&gt;{{Cite web |title=Justin Timberlake |url=https://memphismusichalloffame.com/inductee/justintimberlake/ |access-date=2025-09-04 |website=Memphis Music Hall of Fame |language=en}}&lt;/ref&gt;, kanye ne- MTV 's Michael Jackson Video Vanguard Award . Usolo asebenzisana nabakhiqizi abafana ne -The Neptunes kanye ne-Timbaland .

== Imithombo lwazi ==</text>
      <sha1>nu8jck4u8y4psr7dipesglwpdq3t4ji</sha1>
    </revision>
    <revision>
      <id>5615</id>
      <parentid>5522</parentid>
      <timestamp>2025-09-04T10:39:15Z</timestamp>
      <contributor>
        <username>2000Gp01</username>
        <id>880</id>
      </contributor>
      <comment>added picture</comment>
      <origin>5615</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1870" sha1="9shazj9hwpjp2opkx5jgeqg5z47yiir" xml:space="preserve">
 
[[Isimumathi:Justin Timberlake by Gage Skidmore 2.jpg|thumb|uJustin Timberlake]]


U- '''Justin Randall Timberlake''' &lt;ref&gt;{{Cite web |date=2025-08-10 |title=Justin Timberlake {{!}} Songs, Movies, Lyme Disease, Wife, Britney Spears, &amp; Facts {{!}} Britannica |url=https://www.britannica.com/biography/Justin-Timberlake |access-date=2025-09-04 |website=www.britannica.com |language=en}}&lt;/ref&gt;
(wabelethwa mhlazi-31 kuTjhirhweni 1981)  mvumi wenarheni yange-America  e-Montana, umtloli weengoma, umlingisi, umkhiqizi wamarekhodi, nomdansi.  Ebizwa ngokuthi &lt;nowiki&gt;&quot;&lt;/nowiki&gt; yikosana ye-Pop &lt;nowiki&gt;&quot;&lt;/nowiki&gt;, ''i-Billboard'' &lt;ref&gt;{{Cite book |last=Inc |first=Nielsen Business Media |url=https://books.google.com/books?id=bQ8EAAAAMBAJ&amp;q=2003+billboard+music+awards+justin+timberlake&amp;pg=PA20 |title=Billboard |date=2003-12-13 |publisher=Nielsen Business Media, Inc. |language=en}}&lt;/ref&gt; yamhlonipha njengomlingisi omumuntu wembaji odlala yedwa ngcono ku -Pop Airplay begodu omunye wabadlali abakhulu be-Pop abamakhulu ama-21.  U-Timberlake uhlala hlangana nabaculi abarekhodako abathengisa khulu, ngokuthengisa amarekhodi angaphezu kweengidi ezima-88 ephasini loke. Imitlomelo yakhe ifakahlangana ama-Grammy Awards&lt;ref&gt;{{Cite web |title=Justin Timberlake {{!}} Artist {{!}} GRAMMY.com |url=https://grammy.com/artists/justin-timberlake/15478 |access-date=2025-09-04 |website=grammy.com}}&lt;/ref&gt; alitjhumi, ama-Primetime Emmy amane, ama-Brit amathathu,ama-BMA alithoba, i- Contemporary Icon Award ye- Songwriters Hall of Fame&lt;ref&gt;{{Cite web |title=Justin Timberlake |url=https://memphismusichalloffame.com/inductee/justintimberlake/ |access-date=2025-09-04 |website=Memphis Music Hall of Fame |language=en}}&lt;/ref&gt;, kanye ne- MTV 's Michael Jackson Video Vanguard Award . Usolo asebenzisana nabakhiqizi  abafana ne -The Neptunes kanye ne-Timbaland .

== Imithombo lwazi ==</text>
      <sha1>9shazj9hwpjp2opkx5jgeqg5z47yiir</sha1>
    </revision>
    <revision>
      <id>5654</id>
      <parentid>5615</parentid>
      <timestamp>2025-09-04T11:07:40Z</timestamp>
      <contributor>
        <username>2000Gp01</username>
        <id>880</id>
      </contributor>
      <minor />
      <comment>added [[Category:Music]] using [[Help:Gadget-HotCat|HotCat]]</comment>
      <origin>5654</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1889" sha1="eccjpc8jxcjsfqaj4xfzl25n6ww3iuk" xml:space="preserve">
 
[[Isimumathi:Justin Timberlake by Gage Skidmore 2.jpg|thumb|uJustin Timberlake]]


U- '''Justin Randall Timberlake''' &lt;ref&gt;{{Cite web |date=2025-08-10 |title=Justin Timberlake {{!}} Songs, Movies, Lyme Disease, Wife, Britney Spears, &amp; Facts {{!}} Britannica |url=https://www.britannica.com/biography/Justin-Timberlake |access-date=2025-09-04 |website=www.britannica.com |language=en}}&lt;/ref&gt;
(wabelethwa mhlazi-31 kuTjhirhweni 1981)  mvumi wenarheni yange-America  e-Montana, umtloli weengoma, umlingisi, umkhiqizi wamarekhodi, nomdansi.  Ebizwa ngokuthi &lt;nowiki&gt;&quot;&lt;/nowiki&gt; yikosana ye-Pop &lt;nowiki&gt;&quot;&lt;/nowiki&gt;, ''i-Billboard'' &lt;ref&gt;{{Cite book |last=Inc |first=Nielsen Business Media |url=https://books.google.com/books?id=bQ8EAAAAMBAJ&amp;q=2003+billboard+music+awards+justin+timberlake&amp;pg=PA20 |title=Billboard |date=2003-12-13 |publisher=Nielsen Business Media, Inc. |language=en}}&lt;/ref&gt; yamhlonipha njengomlingisi omumuntu wembaji odlala yedwa ngcono ku -Pop Airplay begodu omunye wabadlali abakhulu be-Pop abamakhulu ama-21.  U-Timberlake uhlala hlangana nabaculi abarekhodako abathengisa khulu, ngokuthengisa amarekhodi angaphezu kweengidi ezima-88 ephasini loke. Imitlomelo yakhe ifakahlangana ama-Grammy Awards&lt;ref&gt;{{Cite web |title=Justin Timberlake {{!}} Artist {{!}} GRAMMY.com |url=https://grammy.com/artists/justin-timberlake/15478 |access-date=2025-09-04 |website=grammy.com}}&lt;/ref&gt; alitjhumi, ama-Primetime Emmy amane, ama-Brit amathathu,ama-BMA alithoba, i- Contemporary Icon Award ye- Songwriters Hall of Fame&lt;ref&gt;{{Cite web |title=Justin Timberlake |url=https://memphismusichalloffame.com/inductee/justintimberlake/ |access-date=2025-09-04 |website=Memphis Music Hall of Fame |language=en}}&lt;/ref&gt;, kanye ne- MTV 's Michael Jackson Video Vanguard Award . Usolo asebenzisana nabakhiqizi  abafana ne -The Neptunes kanye ne-Timbaland .

== Imithombo lwazi ==

[[Mkhakha:Music]]</text>
      <sha1>eccjpc8jxcjsfqaj4xfzl25n6ww3iuk</sha1>
    </revision>
  </page>
  <page>
    <title>Big Zulu</title>
    <ns>0</ns>
    <id>923</id>
    <revision>
      <id>5477</id>
      <timestamp>2025-09-04T08:38:20Z</timestamp>
      <contributor>
        <username>Kholeka19721</username>
        <id>889</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1301948005|Big Zulu]]&quot;</comment>
      <origin>5477</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="12767" sha1="bnrf596t914fnlul6dpzaana1stv0ha" xml:space="preserve">
'''BIG ZULU'''                         
[[Isimumathi:Big zulu.jpg|left|thumb|BIG ZULU]]
'''IMINININGWANA YANGEMUVA'''

'''IBIZO:'''  Siyabonga Nene

'''UKUBELETHWA:'''  7 KuSihlabantangana 1986

'''UMSEBENZI:''' Umrepha, umtloli weengoma

'''UNYAKA WOKUDUMA:''' 2003- njenganje

'''AMALEBULA:''' Universal Records(kwangaphambilini), Nkabi Records.

'''USiyabonga Nene''' (wabelethwa mhlana amalanga alikhomba, kuMrhayili ngomnyaka we-1986  ), owaziwa ngebizo elibizwa laka '''Big Zulu''', mrepha nomtloli weengoma weSewula Afrika.  Waphakama ngemva kokukhipha ingoma ethi &quot;Donsa Nkabi&quot; ngomnyaka wee-2016.

Watlikitla isivumelwano sokurekhoda ne -Universal Music ngomnyaka wee- 2015 begodu  wakhipha i-albhamu yakhe yokuthoma, ''u-Ushun Wenkabi'' (2018)  no ''-Ungqongqoshe Wongqongqoshe'' (2019).

I-albhamu yesithathu ka Big Zulu ''Ichwane Lenyoka'' (2021), yakhiqiza ama-single amathathu aphuma phambili &quot; Mali Eningi &quot;, &quot;Inhlupheko&quot; kanye no-&quot;Umuzi eSandton&quot;. Ingoma yayo ephambili &quot;i-Mali Eningi&quot;, yaqinisekiswa yi-double platinum yi- Recording Industry of South Africa (RiSA). 

UBig Zulu wabuye wavela emidlalweni kamabonakude ''i-Isibaya'', ''One Mic'' (2017-2020),  ''Uzalo'' (2020), ''Isithembiso'', kanye ''no-Ushuni Womhlaba'' (2024).  Imitlomelo  yakhe ifaka hlangana imitlomelo  ye-Hip Hop yeSewula Afrika elikhomba, umtlomelo  owodwa we-South African Music Award kanye ne-Metro FM Music Awards eyodwa.

== Ipilo yokuthoma ==
USiyabonga Nene wabelethwa begodu wakhulela e -Bergville, KwaZulu-Natal. Wakhula alalele umvumo ka -Maskandi no-Isichathamiya, athonywa ngu -Ladysmith Black Mambazo, Phuzekemisi no-Imithente. 

== IIMVELAPHI YOBUVUMO ==

=== Izithonyo ===
Uthonywe ngu-Maskandi no-Scathamiya.  Bekahlala e-Vaal endaweni ebizwa nge-Palm Springs.

== Ibizelo ==

=== Ukuthoma komsebenzi ===
UZulu wahlala iminyaka eminengi amtjhayeli wetekisi begodu watjhiya ngomnyaka wee-2008 ukobana aragele phambili nomsebenzi wakhe wezomvumo. Ngomnyaka wee-2009, ngemva kobana atjhiye ibubulo lamathekisi wathoma ukutlola iingoma nokudlala.

Ngemva kweminyaka emine ngomnyaka wee-2013, u-Zulu waphalisana begodu waba ngowokuthoma ukuthumba iphalisano le Red Bull Back to the city.  Ingoma yakhe yokuthoma ethi &quot;Donsa Nkabi&quot; yakhutjhwa ngomnyaka wee-2016. 

=== 2014–2019: ''Ushun Wenkabi'', ''Ungqongqoshe Wongqongqoshe'' ===
Ngemva kweminyaka eminengi njengomvumi ozijameleko, watlikitla isivumelwano sokurekhoda ne-Universal Music Records ngomnyaka wee-2015 begodu wakhupha i-albhamu yakhe yokuthoma ''i-Ushun Wenkabi'' ngenyanga ka Velabahlinze ngomnyaka wee-2018, eneengoma ezifaka hlangana &quot;u-Ang'mazi umama&quot; no-&quot;Home&quot;. 

I-albhamu yakhe yesibili ye-studio ''u-Ungqongqoshe Wongqongqoshe'' yakhutjhwa ngomnyaka wee-2019,  ihlanganisa u-Ab Crazy, u-Mnqobi Yazo, u-FiFi Cooper, u-Kwesta, u-Caspper Nyovest, u-Musiholiq no-Truhitz.  Ingoma ephambili ethi &quot;Ak'laleki&quot; eno-Kwesta yakhutjhwa. Mhlana amalanga amabili kuRhoboyi ingoma yakhe yesibili ethi &quot;Ama Million&quot; eno- Cassper Nyovest &amp; Musiholiq yakhutjhwa begodu yafika endaweni yesihlanu ku-iTunes Chart.   Ingoma le beyiqinisekiswe njengeplatinamu.   Mhlana amalanga ali-14 kuRhoboyi, ingoma yakhe yesithathu ethi &quot;Vuma dlozi&quot; ehlanganisa u-Mnqobi Yazo yakhutjhwa  begodu yaqinisekiswa yi-platinamu yibubulo lokurekhoda leSewula Afrika (i-RiSA) ngokuthengisa amakhophi ama-50 000. &lt;ref name=&quot;ubetoo&quot; /&gt; I-albhamu le yaqinisekiswa njengegolide yi-Recording Industry of South Africa (RiSA)  begodu yathola ukukhethwa ku- South African Music Awards (SAMA26)  ye-Best Hip Hop Album.  Ngomnyaka ofanako, wee-2019, i-albhamu leyo yakhethwa njenge-Best Male Artist of the Year kanye ne-albhamu yomnyaka e -South African Hip Hop Awards .  Wasungula ilebula yakhe yamarekhodi i-Nkabi Records. 

=== 2020–2022: ''Ichwane Lenyoka'', ''Nkabi Nation'' ===
Mhlana amalanga ama-20 kuNobayeni ngomnyaka wee- 2020, ingoma yakhe ethi &quot; Mali Eningi &quot; yakhutjhwa ifaka hlangana umvumi ongu Intaba Yase Dubai no-Ricky Rick njengengoma ephambili ye-albhamu. Ingoma le yavela endaweni yesibili kumatjhadi we ''[[Channel 0 (South Africa)|-Channel 0]]'' Top 30  begodu yaqinisekiswa njenge-double platinum.  Emnyanyeni we -27th annual South African Music Awards,ingoma i  &quot;Mali Eningi&quot; yathumba isigaba sokubambisana okuhle khulu.  Ekupheleni komnyaka wee-2020 wakhethwa kokuthoma ku -MTV Base: SA's Hottest MCs, endaweni yesihlanu. 

Ngasekupheleni kukaTjhirhweni ngomnyaka wee-2021, wamemezela ukusebenza kwe-albhamu yakhe yesithathu.   

Mhlana amalanga ali-11 kuNtaka ngomnyaka wee-2021, wakhupha ingoma &quot;Inhlupheko&quot; enoMduduzi Ncube njengengoma yesibili.  Ingoma le yafika endaweni yokuthoma ematjhadini we-iTunes weSewula Afrika begodu yafika endaweni yesine ematjhadini we-Shazam. 

Mhlana amalanga amathathu kuNtaka ngomnyaka wee-2021, wamemezela ingoma etja ebizwa ngokuthi &quot;Umuzi eSandton&quot; ehlanganisa u-Lwah Ndlunkulu ku -Twitter .  Ingoma le yakhutjhwa mhlana amalanga alithoba kuNtaka ngomnyaka wee-2021;  Yavezwa ku-albhamu yakhe ''i-Ichwane Lenyoka'', eyakhutjhwa mhlana amalanga amathathu kuNobayeni 2021.  Ingoma ethi &quot;Umuzi eSandton&quot; yafika endaweni yokuthoma ematjhadini we-Shazam. 

Mhlana amalanga ali-13 kuNobayeni ngomnyaka wee-2021, wenza isizini yetjhumi nane ku- ''Idols South Africa'' .  UZulu uthumbe imitlomelo elikhomba efaka hlangana; I-albhamu yomnyaka, ingoma yomnyaka (&quot; Mali Eningi &quot;), ividiyo yomculo ehle khulu, umvuzo we-Best Male and Ubuntu Activism, Best Collaboration, kanye no-Best Digital Sales kuma -2021 South African Hip Hop Awards .  Ekupheleni komnyaka wee-2021 wakhethwa godu ku-MTV Base: SA's Hottest MCs, wakhuphukela endaweni yesibili. 

I-&quot;iVolovolo&quot; eno Xowla yakhutjhwa mhlana amalanga alitjhumi nanye kuMhlolanja ngomnyaka wee-2022. Ingoma le yathoma ukudlala phambili eSewula Afrika.  

I-&quot;Voicemail&quot; ka-Big Zulu, Mduduzi Ncube, Lwah Ndlunkulu, Siya Ntuli no-Xowla yakhutjhwa njengengoma ephambili ye-albhamu mhlana amalanga ama-24 kuMgwengweni ngonyaka wee-2022.  Ingoma le yaqinisekiswa njengegolide begodu yafika endaweni yokuthoma eSewula Afrika.  

Wakhupha  i-&quot;150 Bars (Ke hip hop Dawg)&quot; mhlana amalanga ama-20 kuRhoboyi ngomnyaka wee-2022. Ingoma le yangena ematjhadini we-Local Top 10 Radio endaweni yesikhombisa. 

Wamemezela  ilanga lokukhutjhwa kwama-albhamu kanye irhelo lokugcina lwengoma ku-Instagram, ekhutjhwe mhlana amalanga alithoba kuNobayeni ngomnyaka wee-2022. 

&quot;Dear My Love&quot; ehlanganisa u-KO, Xowla no-Siya Ntuli ingoma eyodwa ka-Big Zulu ekhutjhwe mhlazi-25 kuNobayeni 2022.

=== 2023-nje: Inkabi Zezwe, ''Ukhamba'', ''Ngises' Congweni'' ===
Mhlana amalanga ali-17 kuNtaka 2023, u-Big Zulu no-Sjava bamemezela ukusebenza nge-albhamu yabo ehlangeneko ''i-Ukhamba'' njenge-duo Inkabi Zezwe . &quot; Umbayimbayi &quot; yakhutjhwa mhlana amalanga ama-24 kuNtaka ngomnyaka wee-2023 njengengoma ephambili ye-albhamu.  Ingoma le yavela kuyingoma yokuthoma ku-iTunes Top 50 kanye ne-Spotify Top 100 South Africa ngokulandelana.  Ingoma le yaqinisekiswa njenge-3× Platinum eSewula Afrika.   

Mhlana kuthoma inyanga kaMrhayili, u-Zulu wamemezela i-Inkabi Zezwe Tour eyathoma ngoMgwengweni bekwaba nguNobayeni ngomnyaka wee-2023.

I-albhamu le yakhutjhwa mhlana amalanga ali-12 kuMrhayili ngomnyaka wee-2023. Yaba yinto yokuthoma emazweni amabili weSewula Afrika ne-Eswatini ngokulandelana. 

Ngasekupheleni kukaTjhirhweni ngomnyaka wee-2024, uZulu wamemezela ukusebenza nge-albhamu yakhe yesine ye-studio kanye ne-albhamu yakhe ephambili &quot;Awufuni Ukung' Qoma&quot;. ''I-Ngises' Congweni'' yakhutjhwa mhlana amalanga ama-27 kuNtaka ngomnyaka wee- 2023.    

=== Umabonakude ===
Ngenyanga kaMgwengweni ngomnyaka wee-2024, uZulu wangenela  umdlalo wokufuna amathalenta ''u-Ushuni Womhlaba'', njengomahluleli  ku-SABC 1 mhlana amalanga alikhomba kuNtaka. 

=== Amanye amabubulo ===
Ngomnyaka wee-2019, uZulu wasungula ilebula yamarekhodi i-Inkabi Records.  UZulu sele asayine uMduduzi Ncube, uLwah Ndlunkulu, uXowla no Siya Ntuli. 

Mhlana amalanga ama-21 kuNobayeni ngomnyaka wee-2021, uZulu wathoma ukusiza abantu abadla imbuya ngelithi begodu wanikela ngemitjhininqondo namaphrinta e-Obonjaneni Primary School. 

Kusukela ngoRhoboyi ngomnyaka wee- 2020, wasebenzisana no Spitz njengomsekeli (ambassador) we-Carvela.  

== I-Discography ==

=== Ama-albhamu we-studio ===

* ''Ushun Wenkabi'' (2018)
* ''Ungqongqoshe Wongqongqoshe'' (2019)
* ''Ichwane Lenyoka'' (2021) 
* ''Ngises' Congweni'' (2024)
* ''Icala Le Mpumelelo'' (2025)

=== Ama-albhamu wokubambisana ===

* ''Inkabi Nation'' (2022)
* ''Ukhamba'' (2023)

=== Njengomdosi phambili kwezomvumo ===
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+Irhelo lama-single njengabaculi abadosa phambili, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;AmaMillion&quot; ene-Musiholiq, Cassper Nyovest
| 2019
|
| Iplatinamu 
| rowspan=&quot;2&quot; | ''Ngqongqoshe Wongqongqoshe''
|-
! scope=&quot;row&quot; | &quot;Vuma Dlozi&quot; ehlanganisa uMnqobi Yazo
| 2020
|
| Iplatinamu &lt;ref name=&quot;DailySUN&quot; /&gt;
|-
! scope=&quot;row&quot; | &quot; Mali Eningi &quot; ehlanganisa u-Ntaba Yase Dubai, u-Ricky Rick
| rowspan=&quot;3&quot; | 2021
| 2
| 2× Iplatinamu
| rowspan=&quot;4&quot; | ''Ichwane Lenyoka''
|-
! scope=&quot;row&quot; | &quot;Umuzi eSandton&quot; nge- Lwah Ndlunkulu
| —
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;Inhlupheko&quot; ehlanganisa uMduduzi Ncube
| 1
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;iVolovolo&quot; ene-Xowla
| 2022
| —
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;Dear My Love&quot; ene-Xowla, KO no -Siya Ntuli
| 2022
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Awufuni Ukung' Qoma&quot;
| rowspan=&quot;3&quot; | 2024
| —
|
| ''UCongweni kaNgises''
|-
! scope=&quot;row&quot; | &quot;200 Bars&quot;
| — 
||{{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ay Ka'Ncane&quot; (Big Zulu, Tony Dayimane)
| — 
||{{non-album single}} 
|-
! scope=&quot;row&quot; | &quot;Amacala Othando&quot; (Big Zulu, Azana, Malungelo)
| rowspan=&quot;2&quot; | 2025
| — 
||{{non-album single}} 
|-
! scope=&quot;row&quot; | &quot;Abazazi Bafunani&quot; (ehlanganisa u-Emtee )
| 2 
|
| Icala Le Mpumelelo
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; | &quot;—&quot; kutjho ukurekhoda okungazange kushadi namkha okungakakhutjhwa endaweni leyo.
|}
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center&quot;
|+Irhelo lazingoma azihlanganyele nabanye njengabaculi abaveziweko, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;Isigingci&quot; (Mduduzi ehlanganisa uBig Zulu)
| 2020
| —
|
| ''Isitimela''
|-
! scope=&quot;row&quot; | &quot;Alusafani&quot; ( Qwabe Twins featuring Big Zulu, Mduduzi, Xowla)
| rowspan=&quot;2&quot; | 2021
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Qoma&quot; ( Blaq Diamond nge-Siya Ntuli, Big Zulu)
| —
| I-RiSA: Iplatinamu 
| Ithando lesiZulu
|-
! scope=&quot;row&quot; | &quot;Amalobolo&quot; ( u-Nomfundo Moh ohlanganisa u-Big Zulu)
| 2023
| —
|
| ''Ugcobo''
|-
! scope=&quot;row&quot; | &quot;Beng' dakiwe (u-Xowla ahlanganisa u-Big Zulu, u-DJ Tira )
| rowspan=&quot;2&quot; | 2023
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;My Ex&quot; (Big Xhosa featuring Big Zulu)
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Mfazi Wephepha&quot; (Nkosazana Daughter, Master Kg featuring Big Zulu, Zee Nxumalo )
| 2024
| 4 
|
| ''Makhelwane''
|}

== Imitlomelo nokuphakanyiswa ==
{| class=&quot;wikitable&quot;
!Umnyaka
! Umtlomelo
! Umkhakha
! Imiphumela
! Ref.
|-
| rowspan=&quot;3&quot; | 2019
| rowspan=&quot;2&quot; | SAHHA
| I-albhamu yomnyaka| {{nom}}
| rowspan=&quot;2&quot; |  
|-
| Umdwebi wesilisa ophuma phambili womnyaka|{{nom}}
|-
| I-SAMA 26
| I-albhamu ye-Hip Hop ehle khulu| {{nom}}
|  
|-
| 2020
| SAHHA
| I-Remix ehle khulu| {{Nom}}
| 
|-
| 2021
| I-SAMA 27
| Ukusebenzisana okuhle khulu|{{won}}
|  
|-
| rowspan=&quot;8&quot; | 2021
| rowspan=&quot;8&quot; | I-SAHHA 10
| I-albhamu yomnyaka|{{won}}
| rowspan=&quot;8&quot; |  
|-
| Owesilisa ophuma phambili|{{won}}
|-
| Ingoma yomnyaka|{{won}}
|-
| Ukusebenzisana okuhle khulu|{{won}}
|-
| I-MVP/Umtjhayeli womnyaka|{{nom}}
|-
| Ividiyo ehle khulu|{{won}}
|-
| Umvuzo we-Ubuntu Activism|{{won}}
|-
| Ukuthengisa okuhle khulu kwedijithali|{{won}}
|-
| rowspan=&quot;2&quot; | 2022
| rowspan=&quot;2&quot; | DStv MVCA
| Ingoma engiyithandako| {{nom}}
| rowspan=&quot;2&quot; | 
|-
| Umculi womculo othandwako/isiqhema|{{nom}}
|-
| 2023
| 17th Metro FM Music Awards
| I-Duo/Isiqhema esihle khulu |{{Won}} 
|
|}

== UMTHOMBO LWAZI ==</text>
      <sha1>bnrf596t914fnlul6dpzaana1stv0ha</sha1>
    </revision>
    <revision>
      <id>5519</id>
      <parentid>5477</parentid>
      <timestamp>2025-09-04T09:21:25Z</timestamp>
      <contributor>
        <username>Kholeka19721</username>
        <id>889</id>
      </contributor>
      <minor />
      <comment>added 1 reference</comment>
      <origin>5519</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="13379" sha1="8xqmre94m854see427cdx848kp706bg" xml:space="preserve">
'''BIG ZULU'''                         
[[Isimumathi:Big zulu.jpg|left|thumb|BIG ZULU]]
'''IMINININGWANA YANGEMUVA'''

'''IBIZO:'''  Siyabonga Nene

'''UKUBELETHWA:'''  7 KuSihlabantangana 1986

'''UMSEBENZI:''' Umrepha, umtloli weengoma

'''UNYAKA WOKUDUMA:''' 2003- njenganje

'''AMALEBULA:''' Universal Records(kwangaphambilini), Nkabi Records.

'''USiyabonga Nene''' (wabelethwa mhlana amalanga alikhomba, kuMrhayili ngomnyaka we-1986  )&lt;ref&gt;{{Cite web |last=Mag |first=SA Hip Hop |date=2021-04-07 |title=Happy Birthday Big Zulu! A Look Into Big Zulu's Best Selling Records |url=https://sahiphopmag.co.za/2021/04/happy-birthday-big-zulu-a-look-into-big-zulus-best-selling-records/ |access-date=2025-09-04 |website=SA Hip Hop Mag |language=en-US}}&lt;/ref&gt;&lt;ref&gt;{{Citation |last=Ladson-Billings |first=Gloria |title=From Big Homie the O.G., to GLB |date=2018-03-23 |work=#HipHopEd: The Compilation on Hip-hop Education |pages=21–26 |url=https://doi.org/10.1163/9789004371873_003 |access-date=2025-09-04 |publisher=BRILL |isbn=978-90-04-37187-3}}&lt;/ref&gt;
, owaziwa ngebizo elibizwa laka '''Big Zulu''', mrepha nomtloli weengoma weSewula Afrika.  Waphakama ngemva kokukhipha ingoma ethi &quot;Donsa Nkabi&quot; ngomnyaka wee-2016.

Watlikitla isivumelwano sokurekhoda ne -Universal Music ngomnyaka wee- 2015 begodu  wakhipha i-albhamu yakhe yokuthoma, ''u-Ushun Wenkabi'' (2018)  no ''-Ungqongqoshe Wongqongqoshe'' (2019).

I-albhamu yesithathu ka Big Zulu ''Ichwane Lenyoka'' (2021), yakhiqiza ama-single amathathu aphuma phambili &quot; Mali Eningi &quot;, &quot;Inhlupheko&quot; kanye no-&quot;Umuzi eSandton&quot;. Ingoma yayo ephambili &quot;i-Mali Eningi&quot;, yaqinisekiswa yi-double platinum yi- Recording Industry of South Africa (RiSA). 

UBig Zulu wabuye wavela emidlalweni kamabonakude ''i-Isibaya'', ''One Mic'' (2017-2020),  ''Uzalo'' (2020), ''Isithembiso'', kanye ''no-Ushuni Womhlaba'' (2024).  Imitlomelo  yakhe ifaka hlangana imitlomelo  ye-Hip Hop yeSewula Afrika elikhomba, umtlomelo  owodwa we-South African Music Award kanye ne-Metro FM Music Awards eyodwa.

== Ipilo yokuthoma ==
USiyabonga Nene wabelethwa begodu wakhulela e -Bergville, KwaZulu-Natal. Wakhula alalele umvumo ka -Maskandi no-Isichathamiya, athonywa ngu -Ladysmith Black Mambazo, Phuzekemisi no-Imithente. 

== IIMVELAPHI YOBUVUMO ==

=== Izithonyo ===
Uthonywe ngu-Maskandi no-Scathamiya.  Bekahlala e-Vaal endaweni ebizwa nge-Palm Springs.

== Ibizelo ==

=== Ukuthoma komsebenzi ===
UZulu wahlala iminyaka eminengi amtjhayeli wetekisi begodu watjhiya ngomnyaka wee-2008 ukobana aragele phambili nomsebenzi wakhe wezomvumo. Ngomnyaka wee-2009, ngemva kobana atjhiye ibubulo lamathekisi wathoma ukutlola iingoma nokudlala.

Ngemva kweminyaka emine ngomnyaka wee-2013, u-Zulu waphalisana begodu waba ngowokuthoma ukuthumba iphalisano le Red Bull Back to the city.  Ingoma yakhe yokuthoma ethi &quot;Donsa Nkabi&quot; yakhutjhwa ngomnyaka wee-2016. 

=== 2014–2019: ''Ushun Wenkabi'', ''Ungqongqoshe Wongqongqoshe'' ===
Ngemva kweminyaka eminengi njengomvumi ozijameleko, watlikitla isivumelwano sokurekhoda ne-Universal Music Records ngomnyaka wee-2015 begodu wakhupha i-albhamu yakhe yokuthoma ''i-Ushun Wenkabi'' ngenyanga ka Velabahlinze ngomnyaka wee-2018, eneengoma ezifaka hlangana &quot;u-Ang'mazi umama&quot; no-&quot;Home&quot;. 

I-albhamu yakhe yesibili ye-studio ''u-Ungqongqoshe Wongqongqoshe'' yakhutjhwa ngomnyaka wee-2019,  ihlanganisa u-Ab Crazy, u-Mnqobi Yazo, u-FiFi Cooper, u-Kwesta, u-Caspper Nyovest, u-Musiholiq no-Truhitz.  Ingoma ephambili ethi &quot;Ak'laleki&quot; eno-Kwesta yakhutjhwa. Mhlana amalanga amabili kuRhoboyi ingoma yakhe yesibili ethi &quot;Ama Million&quot; eno- Cassper Nyovest &amp; Musiholiq yakhutjhwa begodu yafika endaweni yesihlanu ku-iTunes Chart.   Ingoma le beyiqinisekiswe njengeplatinamu.   Mhlana amalanga ali-14 kuRhoboyi, ingoma yakhe yesithathu ethi &quot;Vuma dlozi&quot; ehlanganisa u-Mnqobi Yazo yakhutjhwa  begodu yaqinisekiswa yi-platinamu yibubulo lokurekhoda leSewula Afrika (i-RiSA) ngokuthengisa amakhophi ama-50 000. &lt;ref name=&quot;ubetoo&quot; /&gt; I-albhamu le yaqinisekiswa njengegolide yi-Recording Industry of South Africa (RiSA)  begodu yathola ukukhethwa ku- South African Music Awards (SAMA26)  ye-Best Hip Hop Album.  Ngomnyaka ofanako, wee-2019, i-albhamu leyo yakhethwa njenge-Best Male Artist of the Year kanye ne-albhamu yomnyaka e -South African Hip Hop Awards .  Wasungula ilebula yakhe yamarekhodi i-Nkabi Records. 

=== 2020–2022: ''Ichwane Lenyoka'', ''Nkabi Nation'' ===
Mhlana amalanga ama-20 kuNobayeni ngomnyaka wee- 2020, ingoma yakhe ethi &quot; Mali Eningi &quot; yakhutjhwa ifaka hlangana umvumi ongu Intaba Yase Dubai no-Ricky Rick njengengoma ephambili ye-albhamu. Ingoma le yavela endaweni yesibili kumatjhadi we ''[[Channel 0 (South Africa)|-Channel 0]]'' Top 30  begodu yaqinisekiswa njenge-double platinum.  Emnyanyeni we -27th annual South African Music Awards,ingoma i  &quot;Mali Eningi&quot; yathumba isigaba sokubambisana okuhle khulu.  Ekupheleni komnyaka wee-2020 wakhethwa kokuthoma ku -MTV Base: SA's Hottest MCs, endaweni yesihlanu. 

Ngasekupheleni kukaTjhirhweni ngomnyaka wee-2021, wamemezela ukusebenza kwe-albhamu yakhe yesithathu.   

Mhlana amalanga ali-11 kuNtaka ngomnyaka wee-2021, wakhupha ingoma &quot;Inhlupheko&quot; enoMduduzi Ncube njengengoma yesibili.  Ingoma le yafika endaweni yokuthoma ematjhadini we-iTunes weSewula Afrika begodu yafika endaweni yesine ematjhadini we-Shazam. 

Mhlana amalanga amathathu kuNtaka ngomnyaka wee-2021, wamemezela ingoma etja ebizwa ngokuthi &quot;Umuzi eSandton&quot; ehlanganisa u-Lwah Ndlunkulu ku -Twitter .  Ingoma le yakhutjhwa mhlana amalanga alithoba kuNtaka ngomnyaka wee-2021;  Yavezwa ku-albhamu yakhe ''i-Ichwane Lenyoka'', eyakhutjhwa mhlana amalanga amathathu kuNobayeni 2021.  Ingoma ethi &quot;Umuzi eSandton&quot; yafika endaweni yokuthoma ematjhadini we-Shazam. 

Mhlana amalanga ali-13 kuNobayeni ngomnyaka wee-2021, wenza isizini yetjhumi nane ku- ''Idols South Africa'' .  UZulu uthumbe imitlomelo elikhomba efaka hlangana; I-albhamu yomnyaka, ingoma yomnyaka (&quot; Mali Eningi &quot;), ividiyo yomculo ehle khulu, umvuzo we-Best Male and Ubuntu Activism, Best Collaboration, kanye no-Best Digital Sales kuma -2021 South African Hip Hop Awards .  Ekupheleni komnyaka wee-2021 wakhethwa godu ku-MTV Base: SA's Hottest MCs, wakhuphukela endaweni yesibili. 

I-&quot;iVolovolo&quot; eno Xowla yakhutjhwa mhlana amalanga alitjhumi nanye kuMhlolanja ngomnyaka wee-2022. Ingoma le yathoma ukudlala phambili eSewula Afrika.  

I-&quot;Voicemail&quot; ka-Big Zulu, Mduduzi Ncube, Lwah Ndlunkulu, Siya Ntuli no-Xowla yakhutjhwa njengengoma ephambili ye-albhamu mhlana amalanga ama-24 kuMgwengweni ngonyaka wee-2022.  Ingoma le yaqinisekiswa njengegolide begodu yafika endaweni yokuthoma eSewula Afrika.  

Wakhupha  i-&quot;150 Bars (Ke hip hop Dawg)&quot; mhlana amalanga ama-20 kuRhoboyi ngomnyaka wee-2022. Ingoma le yangena ematjhadini we-Local Top 10 Radio endaweni yesikhombisa. 

Wamemezela  ilanga lokukhutjhwa kwama-albhamu kanye irhelo lokugcina lwengoma ku-Instagram, ekhutjhwe mhlana amalanga alithoba kuNobayeni ngomnyaka wee-2022. 

&quot;Dear My Love&quot; ehlanganisa u-KO, Xowla no-Siya Ntuli ingoma eyodwa ka-Big Zulu ekhutjhwe mhlazi-25 kuNobayeni 2022.

=== 2023-nje: Inkabi Zezwe, ''Ukhamba'', ''Ngises' Congweni'' ===
Mhlana amalanga ali-17 kuNtaka 2023, u-Big Zulu no-Sjava bamemezela ukusebenza nge-albhamu yabo ehlangeneko ''i-Ukhamba'' njenge-duo Inkabi Zezwe . &quot; Umbayimbayi &quot; yakhutjhwa mhlana amalanga ama-24 kuNtaka ngomnyaka wee-2023 njengengoma ephambili ye-albhamu.  Ingoma le yavela kuyingoma yokuthoma ku-iTunes Top 50 kanye ne-Spotify Top 100 South Africa ngokulandelana.  Ingoma le yaqinisekiswa njenge-3× Platinum eSewula Afrika.   

Mhlana kuthoma inyanga kaMrhayili, u-Zulu wamemezela i-Inkabi Zezwe Tour eyathoma ngoMgwengweni bekwaba nguNobayeni ngomnyaka wee-2023.

I-albhamu le yakhutjhwa mhlana amalanga ali-12 kuMrhayili ngomnyaka wee-2023. Yaba yinto yokuthoma emazweni amabili weSewula Afrika ne-Eswatini ngokulandelana. 

Ngasekupheleni kukaTjhirhweni ngomnyaka wee-2024, uZulu wamemezela ukusebenza nge-albhamu yakhe yesine ye-studio kanye ne-albhamu yakhe ephambili &quot;Awufuni Ukung' Qoma&quot;. ''I-Ngises' Congweni'' yakhutjhwa mhlana amalanga ama-27 kuNtaka ngomnyaka wee- 2023.    

=== Umabonakude ===
Ngenyanga kaMgwengweni ngomnyaka wee-2024, uZulu wangenela  umdlalo wokufuna amathalenta ''u-Ushuni Womhlaba'', njengomahluleli  ku-SABC 1 mhlana amalanga alikhomba kuNtaka. 

=== Amanye amabubulo ===
Ngomnyaka wee-2019, uZulu wasungula ilebula yamarekhodi i-Inkabi Records.  UZulu sele asayine uMduduzi Ncube, uLwah Ndlunkulu, uXowla no Siya Ntuli. 

Mhlana amalanga ama-21 kuNobayeni ngomnyaka wee-2021, uZulu wathoma ukusiza abantu abadla imbuya ngelithi begodu wanikela ngemitjhininqondo namaphrinta e-Obonjaneni Primary School. 

Kusukela ngoRhoboyi ngomnyaka wee- 2020, wasebenzisana no Spitz njengomsekeli (ambassador) we-Carvela.  

== I-Discography ==

=== Ama-albhamu we-studio ===

* ''Ushun Wenkabi'' (2018)
* ''Ungqongqoshe Wongqongqoshe'' (2019)
* ''Ichwane Lenyoka'' (2021) 
* ''Ngises' Congweni'' (2024)
* ''Icala Le Mpumelelo'' (2025)

=== Ama-albhamu wokubambisana ===

* ''Inkabi Nation'' (2022)
* ''Ukhamba'' (2023)

=== Njengomdosi phambili kwezomvumo ===
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+Irhelo lama-single njengabaculi abadosa phambili, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;AmaMillion&quot; ene-Musiholiq, Cassper Nyovest
| 2019
|
| Iplatinamu 
| rowspan=&quot;2&quot; | ''Ngqongqoshe Wongqongqoshe''
|-
! scope=&quot;row&quot; | &quot;Vuma Dlozi&quot; ehlanganisa uMnqobi Yazo
| 2020
|
| Iplatinamu &lt;ref name=&quot;DailySUN&quot; /&gt;
|-
! scope=&quot;row&quot; | &quot; Mali Eningi &quot; ehlanganisa u-Ntaba Yase Dubai, u-Ricky Rick
| rowspan=&quot;3&quot; | 2021
| 2
| 2× Iplatinamu
| rowspan=&quot;4&quot; | ''Ichwane Lenyoka''
|-
! scope=&quot;row&quot; | &quot;Umuzi eSandton&quot; nge- Lwah Ndlunkulu
| —
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;Inhlupheko&quot; ehlanganisa uMduduzi Ncube
| 1
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;iVolovolo&quot; ene-Xowla
| 2022
| —
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;Dear My Love&quot; ene-Xowla, KO no -Siya Ntuli
| 2022
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Awufuni Ukung' Qoma&quot;
| rowspan=&quot;3&quot; | 2024
| —
|
| ''UCongweni kaNgises''
|-
! scope=&quot;row&quot; | &quot;200 Bars&quot;
| — 
||{{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ay Ka'Ncane&quot; (Big Zulu, Tony Dayimane)
| — 
||{{non-album single}} 
|-
! scope=&quot;row&quot; | &quot;Amacala Othando&quot; (Big Zulu, Azana, Malungelo)
| rowspan=&quot;2&quot; | 2025
| — 
||{{non-album single}} 
|-
! scope=&quot;row&quot; | &quot;Abazazi Bafunani&quot; (ehlanganisa u-Emtee )
| 2 
|
| Icala Le Mpumelelo
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; | &quot;—&quot; kutjho ukurekhoda okungazange kushadi namkha okungakakhutjhwa endaweni leyo.
|}
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center&quot;
|+Irhelo lazingoma azihlanganyele nabanye njengabaculi abaveziweko, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;Isigingci&quot; (Mduduzi ehlanganisa uBig Zulu)
| 2020
| —
|
| ''Isitimela''
|-
! scope=&quot;row&quot; | &quot;Alusafani&quot; ( Qwabe Twins featuring Big Zulu, Mduduzi, Xowla)
| rowspan=&quot;2&quot; | 2021
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Qoma&quot; ( Blaq Diamond nge-Siya Ntuli, Big Zulu)
| —
| I-RiSA: Iplatinamu 
| Ithando lesiZulu
|-
! scope=&quot;row&quot; | &quot;Amalobolo&quot; ( u-Nomfundo Moh ohlanganisa u-Big Zulu)
| 2023
| —
|
| ''Ugcobo''
|-
! scope=&quot;row&quot; | &quot;Beng' dakiwe (u-Xowla ahlanganisa u-Big Zulu, u-DJ Tira )
| rowspan=&quot;2&quot; | 2023
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;My Ex&quot; (Big Xhosa featuring Big Zulu)
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Mfazi Wephepha&quot; (Nkosazana Daughter, Master Kg featuring Big Zulu, Zee Nxumalo )
| 2024
| 4 
|
| ''Makhelwane''
|}

== Imitlomelo nokuphakanyiswa ==
{| class=&quot;wikitable&quot;
!Umnyaka
! Umtlomelo
! Umkhakha
! Imiphumela
! Ref.
|-
| rowspan=&quot;3&quot; | 2019
| rowspan=&quot;2&quot; | SAHHA
| I-albhamu yomnyaka| {{nom}}
| rowspan=&quot;2&quot; |  
|-
| Umdwebi wesilisa ophuma phambili womnyaka|{{nom}}
|-
| I-SAMA 26
| I-albhamu ye-Hip Hop ehle khulu| {{nom}}
|  
|-
| 2020
| SAHHA
| I-Remix ehle khulu| {{Nom}}
| 
|-
| 2021
| I-SAMA 27
| Ukusebenzisana okuhle khulu|{{won}}
|  
|-
| rowspan=&quot;8&quot; | 2021
| rowspan=&quot;8&quot; | I-SAHHA 10
| I-albhamu yomnyaka|{{won}}
| rowspan=&quot;8&quot; |  
|-
| Owesilisa ophuma phambili|{{won}}
|-
| Ingoma yomnyaka|{{won}}
|-
| Ukusebenzisana okuhle khulu|{{won}}
|-
| I-MVP/Umtjhayeli womnyaka|{{nom}}
|-
| Ividiyo ehle khulu|{{won}}
|-
| Umvuzo we-Ubuntu Activism|{{won}}
|-
| Ukuthengisa okuhle khulu kwedijithali|{{won}}
|-
| rowspan=&quot;2&quot; | 2022
| rowspan=&quot;2&quot; | DStv MVCA
| Ingoma engiyithandako| {{nom}}
| rowspan=&quot;2&quot; | 
|-
| Umculi womculo othandwako/isiqhema|{{nom}}
|-
| 2023
| 17th Metro FM Music Awards
| I-Duo/Isiqhema esihle khulu |{{Won}} 
|
|}

== UMTHOMBO LWAZI ==</text>
      <sha1>8xqmre94m854see427cdx848kp706bg</sha1>
    </revision>
    <revision>
      <id>5545</id>
      <parentid>5519</parentid>
      <timestamp>2025-09-04T09:34:54Z</timestamp>
      <contributor>
        <username>Kholeka19721</username>
        <id>889</id>
      </contributor>
      <minor />
      <comment>added reference 2</comment>
      <origin>5545</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="13597" sha1="kfpzvec2mec5aupjz027l82ls85id54" xml:space="preserve">
'''BIG ZULU'''                         
[[Isimumathi:Big zulu.jpg|left|thumb|BIG ZULU]]
'''IMINININGWANA YANGEMUVA'''

'''IBIZO:'''  Siyabonga Nene

'''UKUBELETHWA:'''  7 KuSihlabantangana 1986

'''UMSEBENZI:''' Umrepha, umtloli weengoma

'''UNYAKA WOKUDUMA:''' 2003- njenganje

'''AMALEBULA:''' Universal Records(kwangaphambilini), Nkabi Records.

'''USiyabonga Nene''' (wabelethwa mhlana amalanga alikhomba, kuMrhayili ngomnyaka we-1986  )&lt;ref&gt;{{Cite web |last=Mag |first=SA Hip Hop |date=2021-04-07 |title=Happy Birthday Big Zulu! A Look Into Big Zulu's Best Selling Records |url=https://sahiphopmag.co.za/2021/04/happy-birthday-big-zulu-a-look-into-big-zulus-best-selling-records/ |access-date=2025-09-04 |website=SA Hip Hop Mag |language=en-US}}&lt;/ref&gt;&lt;ref&gt;{{Citation |last=Ladson-Billings |first=Gloria |title=From Big Homie the O.G., to GLB |date=2018-03-23 |work=#HipHopEd: The Compilation on Hip-hop Education |pages=21–26 |url=https://doi.org/10.1163/9789004371873_003 |access-date=2025-09-04 |publisher=BRILL |isbn=978-90-04-37187-3}}&lt;/ref&gt;
, owaziwa ngebizo elibizwa laka '''Big Zulu''', mrepha nomtloli weengoma weSewula Afrika.  Waphakama ngemva kokukhipha ingoma ethi &quot;Donsa Nkabi&quot; ngomnyaka wee-2016.

Watlikitla isivumelwano sokurekhoda ne -Universal Music ngomnyaka wee- 2015 begodu  wakhipha i-albhamu yakhe yokuthoma, ''u-Ushun Wenkabi'' (2018)  no ''-Ungqongqoshe Wongqongqoshe'' (2019).

I-albhamu yesithathu ka Big Zulu ''Ichwane Lenyoka'' (2021), yakhiqiza ama-single amathathu aphuma phambili &quot; Mali Eningi &quot;, &quot;Inhlupheko&quot; kanye no-&quot;Umuzi eSandton&quot;. Ingoma yayo ephambili &quot;i-Mali Eningi&quot;, yaqinisekiswa yi-double platinum yi- Recording Industry of South Africa (RiSA). 

UBig Zulu wabuye wavela emidlalweni kamabonakude ''i-Isibaya'', ''One Mic'' (2017-2020),  ''Uzalo'' (2020), ''Isithembiso'', kanye ''no-Ushuni Womhlaba'' (2024).  Imitlomelo  yakhe ifaka hlangana imitlomelo  ye-Hip Hop yeSewula Afrika elikhomba, umtlomelo  owodwa we-South African Music Award kanye ne-Metro FM Music Awards eyodwa.

== Ipilo yokuthoma ==
USiyabonga Nene wabelethwa begodu wakhulela e -Bergville, KwaZulu-Natal. Wakhula alalele umvumo ka -Maskandi no-Isichathamiya, athonywa ngu -Ladysmith Black Mambazo, Phuzekemisi no-Imithente. Dacre, Richard (2015-05-28), &quot;Worth, Harry [real name Harry Bourlon Illingsworth] (1917–1989), comedian&quot;, Oxford Dictionary of National Biography, Oxford University Press, ISBN 978-0-19-861412-8, retrieved 2025-09-04

== IIMVELAPHI YOBUVUMO ==

=== Izithonyo ===
Uthonywe ngu-Maskandi no-Scathamiya.  Bekahlala e-Vaal endaweni ebizwa nge-Palm Springs.

== Ibizelo ==

=== Ukuthoma komsebenzi ===
UZulu wahlala iminyaka eminengi amtjhayeli wetekisi begodu watjhiya ngomnyaka wee-2008 ukobana aragele phambili nomsebenzi wakhe wezomvumo. Ngomnyaka wee-2009, ngemva kobana atjhiye ibubulo lamathekisi wathoma ukutlola iingoma nokudlala.

Ngemva kweminyaka emine ngomnyaka wee-2013, u-Zulu waphalisana begodu waba ngowokuthoma ukuthumba iphalisano le Red Bull Back to the city.  Ingoma yakhe yokuthoma ethi &quot;Donsa Nkabi&quot; yakhutjhwa ngomnyaka wee-2016. 

=== 2014–2019: ''Ushun Wenkabi'', ''Ungqongqoshe Wongqongqoshe'' ===
Ngemva kweminyaka eminengi njengomvumi ozijameleko, watlikitla isivumelwano sokurekhoda ne-Universal Music Records ngomnyaka wee-2015 begodu wakhupha i-albhamu yakhe yokuthoma ''i-Ushun Wenkabi'' ngenyanga ka Velabahlinze ngomnyaka wee-2018, eneengoma ezifaka hlangana &quot;u-Ang'mazi umama&quot; no-&quot;Home&quot;. 

I-albhamu yakhe yesibili ye-studio ''u-Ungqongqoshe Wongqongqoshe'' yakhutjhwa ngomnyaka wee-2019,  ihlanganisa u-Ab Crazy, u-Mnqobi Yazo, u-FiFi Cooper, u-Kwesta, u-Caspper Nyovest, u-Musiholiq no-Truhitz.  Ingoma ephambili ethi &quot;Ak'laleki&quot; eno-Kwesta yakhutjhwa. Mhlana amalanga amabili kuRhoboyi ingoma yakhe yesibili ethi &quot;Ama Million&quot; eno- Cassper Nyovest &amp; Musiholiq yakhutjhwa begodu yafika endaweni yesihlanu ku-iTunes Chart.   Ingoma le beyiqinisekiswe njengeplatinamu.   Mhlana amalanga ali-14 kuRhoboyi, ingoma yakhe yesithathu ethi &quot;Vuma dlozi&quot; ehlanganisa u-Mnqobi Yazo yakhutjhwa  begodu yaqinisekiswa yi-platinamu yibubulo lokurekhoda leSewula Afrika (i-RiSA) ngokuthengisa amakhophi ama-50 000. &lt;ref name=&quot;ubetoo&quot; /&gt; I-albhamu le yaqinisekiswa njengegolide yi-Recording Industry of South Africa (RiSA)  begodu yathola ukukhethwa ku- South African Music Awards (SAMA26)  ye-Best Hip Hop Album.  Ngomnyaka ofanako, wee-2019, i-albhamu leyo yakhethwa njenge-Best Male Artist of the Year kanye ne-albhamu yomnyaka e -South African Hip Hop Awards .  Wasungula ilebula yakhe yamarekhodi i-Nkabi Records. 

=== 2020–2022: ''Ichwane Lenyoka'', ''Nkabi Nation'' ===
Mhlana amalanga ama-20 kuNobayeni ngomnyaka wee- 2020, ingoma yakhe ethi &quot; Mali Eningi &quot; yakhutjhwa ifaka hlangana umvumi ongu Intaba Yase Dubai no-Ricky Rick njengengoma ephambili ye-albhamu. Ingoma le yavela endaweni yesibili kumatjhadi we ''[[Channel 0 (South Africa)|-Channel 0]]'' Top 30  begodu yaqinisekiswa njenge-double platinum.  Emnyanyeni we -27th annual South African Music Awards,ingoma i  &quot;Mali Eningi&quot; yathumba isigaba sokubambisana okuhle khulu.  Ekupheleni komnyaka wee-2020 wakhethwa kokuthoma ku -MTV Base: SA's Hottest MCs, endaweni yesihlanu. 

Ngasekupheleni kukaTjhirhweni ngomnyaka wee-2021, wamemezela ukusebenza kwe-albhamu yakhe yesithathu.   

Mhlana amalanga ali-11 kuNtaka ngomnyaka wee-2021, wakhupha ingoma &quot;Inhlupheko&quot; enoMduduzi Ncube njengengoma yesibili.  Ingoma le yafika endaweni yokuthoma ematjhadini we-iTunes weSewula Afrika begodu yafika endaweni yesine ematjhadini we-Shazam. 

Mhlana amalanga amathathu kuNtaka ngomnyaka wee-2021, wamemezela ingoma etja ebizwa ngokuthi &quot;Umuzi eSandton&quot; ehlanganisa u-Lwah Ndlunkulu ku -Twitter .  Ingoma le yakhutjhwa mhlana amalanga alithoba kuNtaka ngomnyaka wee-2021;  Yavezwa ku-albhamu yakhe ''i-Ichwane Lenyoka'', eyakhutjhwa mhlana amalanga amathathu kuNobayeni 2021.  Ingoma ethi &quot;Umuzi eSandton&quot; yafika endaweni yokuthoma ematjhadini we-Shazam. 

Mhlana amalanga ali-13 kuNobayeni ngomnyaka wee-2021, wenza isizini yetjhumi nane ku- ''Idols South Africa'' .  UZulu uthumbe imitlomelo elikhomba efaka hlangana; I-albhamu yomnyaka, ingoma yomnyaka (&quot; Mali Eningi &quot;), ividiyo yomculo ehle khulu, umvuzo we-Best Male and Ubuntu Activism, Best Collaboration, kanye no-Best Digital Sales kuma -2021 South African Hip Hop Awards .  Ekupheleni komnyaka wee-2021 wakhethwa godu ku-MTV Base: SA's Hottest MCs, wakhuphukela endaweni yesibili. 

I-&quot;iVolovolo&quot; eno Xowla yakhutjhwa mhlana amalanga alitjhumi nanye kuMhlolanja ngomnyaka wee-2022. Ingoma le yathoma ukudlala phambili eSewula Afrika.  

I-&quot;Voicemail&quot; ka-Big Zulu, Mduduzi Ncube, Lwah Ndlunkulu, Siya Ntuli no-Xowla yakhutjhwa njengengoma ephambili ye-albhamu mhlana amalanga ama-24 kuMgwengweni ngonyaka wee-2022.  Ingoma le yaqinisekiswa njengegolide begodu yafika endaweni yokuthoma eSewula Afrika.  

Wakhupha  i-&quot;150 Bars (Ke hip hop Dawg)&quot; mhlana amalanga ama-20 kuRhoboyi ngomnyaka wee-2022. Ingoma le yangena ematjhadini we-Local Top 10 Radio endaweni yesikhombisa. 

Wamemezela  ilanga lokukhutjhwa kwama-albhamu kanye irhelo lokugcina lwengoma ku-Instagram, ekhutjhwe mhlana amalanga alithoba kuNobayeni ngomnyaka wee-2022. 

&quot;Dear My Love&quot; ehlanganisa u-KO, Xowla no-Siya Ntuli ingoma eyodwa ka-Big Zulu ekhutjhwe mhlazi-25 kuNobayeni 2022.

=== 2023-nje: Inkabi Zezwe, ''Ukhamba'', ''Ngises' Congweni'' ===
Mhlana amalanga ali-17 kuNtaka 2023, u-Big Zulu no-Sjava bamemezela ukusebenza nge-albhamu yabo ehlangeneko ''i-Ukhamba'' njenge-duo Inkabi Zezwe . &quot; Umbayimbayi &quot; yakhutjhwa mhlana amalanga ama-24 kuNtaka ngomnyaka wee-2023 njengengoma ephambili ye-albhamu.  Ingoma le yavela kuyingoma yokuthoma ku-iTunes Top 50 kanye ne-Spotify Top 100 South Africa ngokulandelana.  Ingoma le yaqinisekiswa njenge-3× Platinum eSewula Afrika.   

Mhlana kuthoma inyanga kaMrhayili, u-Zulu wamemezela i-Inkabi Zezwe Tour eyathoma ngoMgwengweni bekwaba nguNobayeni ngomnyaka wee-2023.

I-albhamu le yakhutjhwa mhlana amalanga ali-12 kuMrhayili ngomnyaka wee-2023. Yaba yinto yokuthoma emazweni amabili weSewula Afrika ne-Eswatini ngokulandelana. 

Ngasekupheleni kukaTjhirhweni ngomnyaka wee-2024, uZulu wamemezela ukusebenza nge-albhamu yakhe yesine ye-studio kanye ne-albhamu yakhe ephambili &quot;Awufuni Ukung' Qoma&quot;. ''I-Ngises' Congweni'' yakhutjhwa mhlana amalanga ama-27 kuNtaka ngomnyaka wee- 2023.    

=== Umabonakude ===
Ngenyanga kaMgwengweni ngomnyaka wee-2024, uZulu wangenela  umdlalo wokufuna amathalenta ''u-Ushuni Womhlaba'', njengomahluleli  ku-SABC 1 mhlana amalanga alikhomba kuNtaka. 

=== Amanye amabubulo ===
Ngomnyaka wee-2019, uZulu wasungula ilebula yamarekhodi i-Inkabi Records.  UZulu sele asayine uMduduzi Ncube, uLwah Ndlunkulu, uXowla no Siya Ntuli. 

Mhlana amalanga ama-21 kuNobayeni ngomnyaka wee-2021, uZulu wathoma ukusiza abantu abadla imbuya ngelithi begodu wanikela ngemitjhininqondo namaphrinta e-Obonjaneni Primary School. 

Kusukela ngoRhoboyi ngomnyaka wee- 2020, wasebenzisana no Spitz njengomsekeli (ambassador) we-Carvela.  

== I-Discography ==

=== Ama-albhamu we-studio ===

* ''Ushun Wenkabi'' (2018)
* ''Ungqongqoshe Wongqongqoshe'' (2019)
* ''Ichwane Lenyoka'' (2021) 
* ''Ngises' Congweni'' (2024)
* ''Icala Le Mpumelelo'' (2025)

=== Ama-albhamu wokubambisana ===

* ''Inkabi Nation'' (2022)
* ''Ukhamba'' (2023)

=== Njengomdosi phambili kwezomvumo ===
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+Irhelo lama-single njengabaculi abadosa phambili, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;AmaMillion&quot; ene-Musiholiq, Cassper Nyovest
| 2019
|
| Iplatinamu 
| rowspan=&quot;2&quot; | ''Ngqongqoshe Wongqongqoshe''
|-
! scope=&quot;row&quot; | &quot;Vuma Dlozi&quot; ehlanganisa uMnqobi Yazo
| 2020
|
| Iplatinamu &lt;ref name=&quot;DailySUN&quot; /&gt;
|-
! scope=&quot;row&quot; | &quot; Mali Eningi &quot; ehlanganisa u-Ntaba Yase Dubai, u-Ricky Rick
| rowspan=&quot;3&quot; | 2021
| 2
| 2× Iplatinamu
| rowspan=&quot;4&quot; | ''Ichwane Lenyoka''
|-
! scope=&quot;row&quot; | &quot;Umuzi eSandton&quot; nge- Lwah Ndlunkulu
| —
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;Inhlupheko&quot; ehlanganisa uMduduzi Ncube
| 1
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;iVolovolo&quot; ene-Xowla
| 2022
| —
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;Dear My Love&quot; ene-Xowla, KO no -Siya Ntuli
| 2022
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Awufuni Ukung' Qoma&quot;
| rowspan=&quot;3&quot; | 2024
| —
|
| ''UCongweni kaNgises''
|-
! scope=&quot;row&quot; | &quot;200 Bars&quot;
| — 
||{{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ay Ka'Ncane&quot; (Big Zulu, Tony Dayimane)
| — 
||{{non-album single}} 
|-
! scope=&quot;row&quot; | &quot;Amacala Othando&quot; (Big Zulu, Azana, Malungelo)
| rowspan=&quot;2&quot; | 2025
| — 
||{{non-album single}} 
|-
! scope=&quot;row&quot; | &quot;Abazazi Bafunani&quot; (ehlanganisa u-Emtee )
| 2 
|
| Icala Le Mpumelelo
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; | &quot;—&quot; kutjho ukurekhoda okungazange kushadi namkha okungakakhutjhwa endaweni leyo.
|}
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center&quot;
|+Irhelo lazingoma azihlanganyele nabanye njengabaculi abaveziweko, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;Isigingci&quot; (Mduduzi ehlanganisa uBig Zulu)
| 2020
| —
|
| ''Isitimela''
|-
! scope=&quot;row&quot; | &quot;Alusafani&quot; ( Qwabe Twins featuring Big Zulu, Mduduzi, Xowla)
| rowspan=&quot;2&quot; | 2021
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Qoma&quot; ( Blaq Diamond nge-Siya Ntuli, Big Zulu)
| —
| I-RiSA: Iplatinamu 
| Ithando lesiZulu
|-
! scope=&quot;row&quot; | &quot;Amalobolo&quot; ( u-Nomfundo Moh ohlanganisa u-Big Zulu)
| 2023
| —
|
| ''Ugcobo''
|-
! scope=&quot;row&quot; | &quot;Beng' dakiwe (u-Xowla ahlanganisa u-Big Zulu, u-DJ Tira )
| rowspan=&quot;2&quot; | 2023
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;My Ex&quot; (Big Xhosa featuring Big Zulu)
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Mfazi Wephepha&quot; (Nkosazana Daughter, Master Kg featuring Big Zulu, Zee Nxumalo )
| 2024
| 4 
|
| ''Makhelwane''
|}

== Imitlomelo nokuphakanyiswa ==
{| class=&quot;wikitable&quot;
!Umnyaka
! Umtlomelo
! Umkhakha
! Imiphumela
! Ref.
|-
| rowspan=&quot;3&quot; | 2019
| rowspan=&quot;2&quot; | SAHHA
| I-albhamu yomnyaka| {{nom}}
| rowspan=&quot;2&quot; |  
|-
| Umdwebi wesilisa ophuma phambili womnyaka|{{nom}}
|-
| I-SAMA 26
| I-albhamu ye-Hip Hop ehle khulu| {{nom}}
|  
|-
| 2020
| SAHHA
| I-Remix ehle khulu| {{Nom}}
| 
|-
| 2021
| I-SAMA 27
| Ukusebenzisana okuhle khulu|{{won}}
|  
|-
| rowspan=&quot;8&quot; | 2021
| rowspan=&quot;8&quot; | I-SAHHA 10
| I-albhamu yomnyaka|{{won}}
| rowspan=&quot;8&quot; |  
|-
| Owesilisa ophuma phambili|{{won}}
|-
| Ingoma yomnyaka|{{won}}
|-
| Ukusebenzisana okuhle khulu|{{won}}
|-
| I-MVP/Umtjhayeli womnyaka|{{nom}}
|-
| Ividiyo ehle khulu|{{won}}
|-
| Umvuzo we-Ubuntu Activism|{{won}}
|-
| Ukuthengisa okuhle khulu kwedijithali|{{won}}
|-
| rowspan=&quot;2&quot; | 2022
| rowspan=&quot;2&quot; | DStv MVCA
| Ingoma engiyithandako| {{nom}}
| rowspan=&quot;2&quot; | 
|-
| Umculi womculo othandwako/isiqhema|{{nom}}
|-
| 2023
| 17th Metro FM Music Awards
| I-Duo/Isiqhema esihle khulu |{{Won}} 
|
|}

== UMTHOMBO LWAZI ==</text>
      <sha1>kfpzvec2mec5aupjz027l82ls85id54</sha1>
    </revision>
    <revision>
      <id>5558</id>
      <parentid>5545</parentid>
      <timestamp>2025-09-04T09:42:13Z</timestamp>
      <contributor>
        <username>Kholeka19721</username>
        <id>889</id>
      </contributor>
      <minor />
      <comment>added a link</comment>
      <origin>5558</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="13601" sha1="2qk21jy5tsb0rn6ud47rbb0sev6w1e3" xml:space="preserve">
'''BIG ZULU'''                         
[[Isimumathi:Big zulu.jpg|left|thumb|BIG ZULU]]
'''IMINININGWANA YANGEMUVA'''

'''IBIZO:'''  Siyabonga Nene

'''UKUBELETHWA:'''  7 KuSihlabantangana 1986

'''UMSEBENZI:''' Umrepha, umtloli weengoma

'''UNYAKA WOKUDUMA:''' 2003- njenganje

'''AMALEBULA:''' Universal Records(kwangaphambilini), Nkabi Records.

'''USiyabonga Nene''' (wabelethwa mhlana amalanga alikhomba, kuMrhayili ngomnyaka we-1986  )&lt;ref&gt;{{Cite web |last=Mag |first=SA Hip Hop |date=2021-04-07 |title=Happy Birthday Big Zulu! A Look Into Big Zulu's Best Selling Records |url=https://sahiphopmag.co.za/2021/04/happy-birthday-big-zulu-a-look-into-big-zulus-best-selling-records/ |access-date=2025-09-04 |website=SA Hip Hop Mag |language=en-US}}&lt;/ref&gt;&lt;ref&gt;{{Citation |last=Ladson-Billings |first=Gloria |title=From Big Homie the O.G., to GLB |date=2018-03-23 |work=#HipHopEd: The Compilation on Hip-hop Education |pages=21–26 |url=https://doi.org/10.1163/9789004371873_003 |access-date=2025-09-04 |publisher=BRILL |isbn=978-90-04-37187-3}}&lt;/ref&gt;
, owaziwa ngebizo elibizwa laka '''Big Zulu''', mrepha nomtloli weengoma weSewula Afrika.  Waphakama ngemva kokukhipha ingoma ethi &quot;Donsa Nkabi&quot; ngomnyaka wee-2016.

Watlikitla isivumelwano sokurekhoda ne -Universal Music ngomnyaka wee- 2015 begodu  wakhipha i-albhamu yakhe yokuthoma, ''u-Ushun Wenkabi'' (2018)  no ''-Ungqongqoshe Wongqongqoshe'' (2019).

I-albhamu yesithathu ka Big Zulu ''Ichwane Lenyoka'' (2021), yakhiqiza ama-single amathathu aphuma phambili &quot; Mali Eningi &quot;, &quot;Inhlupheko&quot; kanye no-&quot;Umuzi eSandton&quot;. Ingoma yayo ephambili &quot;i-Mali Eningi&quot;, yaqinisekiswa yi-double platinum yi- Recording Industry of South Africa (RiSA). 

U[[Big Zulu]] wabuye wavela emidlalweni kamabonakude ''i-Isibaya'', ''One Mic'' (2017-2020),  ''Uzalo'' (2020), ''Isithembiso'', kanye ''no-Ushuni Womhlaba'' (2024).  Imitlomelo  yakhe ifaka hlangana imitlomelo  ye-Hip Hop yeSewula Afrika elikhomba, umtlomelo  owodwa we-South African Music Award kanye ne-Metro FM Music Awards eyodwa.

== Ipilo yokuthoma ==
USiyabonga Nene wabelethwa begodu wakhulela e -Bergville, KwaZulu-Natal. Wakhula alalele umvumo ka -Maskandi no-Isichathamiya, athonywa ngu -Ladysmith Black Mambazo, Phuzekemisi no-Imithente. Dacre, Richard (2015-05-28), &quot;Worth, Harry [real name Harry Bourlon Illingsworth] (1917–1989), comedian&quot;, Oxford Dictionary of National Biography, Oxford University Press, ISBN 978-0-19-861412-8, retrieved 2025-09-04

== IIMVELAPHI YOBUVUMO ==

=== Izithonyo ===
Uthonywe ngu-Maskandi no-Scathamiya.  Bekahlala e-Vaal endaweni ebizwa nge-Palm Springs.

== Ibizelo ==

=== Ukuthoma komsebenzi ===
UZulu wahlala iminyaka eminengi amtjhayeli wetekisi begodu watjhiya ngomnyaka wee-2008 ukobana aragele phambili nomsebenzi wakhe wezomvumo. Ngomnyaka wee-2009, ngemva kobana atjhiye ibubulo lamathekisi wathoma ukutlola iingoma nokudlala.

Ngemva kweminyaka emine ngomnyaka wee-2013, u-Zulu waphalisana begodu waba ngowokuthoma ukuthumba iphalisano le Red Bull Back to the city.  Ingoma yakhe yokuthoma ethi &quot;Donsa Nkabi&quot; yakhutjhwa ngomnyaka wee-2016. 

=== 2014–2019: ''Ushun Wenkabi'', ''Ungqongqoshe Wongqongqoshe'' ===
Ngemva kweminyaka eminengi njengomvumi ozijameleko, watlikitla isivumelwano sokurekhoda ne-Universal Music Records ngomnyaka wee-2015 begodu wakhupha i-albhamu yakhe yokuthoma ''i-Ushun Wenkabi'' ngenyanga ka Velabahlinze ngomnyaka wee-2018, eneengoma ezifaka hlangana &quot;u-Ang'mazi umama&quot; no-&quot;Home&quot;. 

I-albhamu yakhe yesibili ye-studio ''u-Ungqongqoshe Wongqongqoshe'' yakhutjhwa ngomnyaka wee-2019,  ihlanganisa u-Ab Crazy, u-Mnqobi Yazo, u-FiFi Cooper, u-Kwesta, u-Caspper Nyovest, u-Musiholiq no-Truhitz.  Ingoma ephambili ethi &quot;Ak'laleki&quot; eno-Kwesta yakhutjhwa. Mhlana amalanga amabili kuRhoboyi ingoma yakhe yesibili ethi &quot;Ama Million&quot; eno- Cassper Nyovest &amp; Musiholiq yakhutjhwa begodu yafika endaweni yesihlanu ku-iTunes Chart.   Ingoma le beyiqinisekiswe njengeplatinamu.   Mhlana amalanga ali-14 kuRhoboyi, ingoma yakhe yesithathu ethi &quot;Vuma dlozi&quot; ehlanganisa u-Mnqobi Yazo yakhutjhwa  begodu yaqinisekiswa yi-platinamu yibubulo lokurekhoda leSewula Afrika (i-RiSA) ngokuthengisa amakhophi ama-50 000. &lt;ref name=&quot;ubetoo&quot; /&gt; I-albhamu le yaqinisekiswa njengegolide yi-Recording Industry of South Africa (RiSA)  begodu yathola ukukhethwa ku- South African Music Awards (SAMA26)  ye-Best Hip Hop Album.  Ngomnyaka ofanako, wee-2019, i-albhamu leyo yakhethwa njenge-Best Male Artist of the Year kanye ne-albhamu yomnyaka e -South African Hip Hop Awards .  Wasungula ilebula yakhe yamarekhodi i-Nkabi Records. 

=== 2020–2022: ''Ichwane Lenyoka'', ''Nkabi Nation'' ===
Mhlana amalanga ama-20 kuNobayeni ngomnyaka wee- 2020, ingoma yakhe ethi &quot; Mali Eningi &quot; yakhutjhwa ifaka hlangana umvumi ongu Intaba Yase Dubai no-Ricky Rick njengengoma ephambili ye-albhamu. Ingoma le yavela endaweni yesibili kumatjhadi we ''[[Channel 0 (South Africa)|-Channel 0]]'' Top 30  begodu yaqinisekiswa njenge-double platinum.  Emnyanyeni we -27th annual South African Music Awards,ingoma i  &quot;Mali Eningi&quot; yathumba isigaba sokubambisana okuhle khulu.  Ekupheleni komnyaka wee-2020 wakhethwa kokuthoma ku -MTV Base: SA's Hottest MCs, endaweni yesihlanu. 

Ngasekupheleni kukaTjhirhweni ngomnyaka wee-2021, wamemezela ukusebenza kwe-albhamu yakhe yesithathu.   

Mhlana amalanga ali-11 kuNtaka ngomnyaka wee-2021, wakhupha ingoma &quot;Inhlupheko&quot; enoMduduzi Ncube njengengoma yesibili.  Ingoma le yafika endaweni yokuthoma ematjhadini we-iTunes weSewula Afrika begodu yafika endaweni yesine ematjhadini we-Shazam. 

Mhlana amalanga amathathu kuNtaka ngomnyaka wee-2021, wamemezela ingoma etja ebizwa ngokuthi &quot;Umuzi eSandton&quot; ehlanganisa u-Lwah Ndlunkulu ku -Twitter .  Ingoma le yakhutjhwa mhlana amalanga alithoba kuNtaka ngomnyaka wee-2021;  Yavezwa ku-albhamu yakhe ''i-Ichwane Lenyoka'', eyakhutjhwa mhlana amalanga amathathu kuNobayeni 2021.  Ingoma ethi &quot;Umuzi eSandton&quot; yafika endaweni yokuthoma ematjhadini we-Shazam. 

Mhlana amalanga ali-13 kuNobayeni ngomnyaka wee-2021, wenza isizini yetjhumi nane ku- ''Idols South Africa'' .  UZulu uthumbe imitlomelo elikhomba efaka hlangana; I-albhamu yomnyaka, ingoma yomnyaka (&quot; Mali Eningi &quot;), ividiyo yomculo ehle khulu, umvuzo we-Best Male and Ubuntu Activism, Best Collaboration, kanye no-Best Digital Sales kuma -2021 South African Hip Hop Awards .  Ekupheleni komnyaka wee-2021 wakhethwa godu ku-MTV Base: SA's Hottest MCs, wakhuphukela endaweni yesibili. 

I-&quot;iVolovolo&quot; eno Xowla yakhutjhwa mhlana amalanga alitjhumi nanye kuMhlolanja ngomnyaka wee-2022. Ingoma le yathoma ukudlala phambili eSewula Afrika.  

I-&quot;Voicemail&quot; ka-Big Zulu, Mduduzi Ncube, Lwah Ndlunkulu, Siya Ntuli no-Xowla yakhutjhwa njengengoma ephambili ye-albhamu mhlana amalanga ama-24 kuMgwengweni ngonyaka wee-2022.  Ingoma le yaqinisekiswa njengegolide begodu yafika endaweni yokuthoma eSewula Afrika.  

Wakhupha  i-&quot;150 Bars (Ke hip hop Dawg)&quot; mhlana amalanga ama-20 kuRhoboyi ngomnyaka wee-2022. Ingoma le yangena ematjhadini we-Local Top 10 Radio endaweni yesikhombisa. 

Wamemezela  ilanga lokukhutjhwa kwama-albhamu kanye irhelo lokugcina lwengoma ku-Instagram, ekhutjhwe mhlana amalanga alithoba kuNobayeni ngomnyaka wee-2022. 

&quot;Dear My Love&quot; ehlanganisa u-KO, Xowla no-Siya Ntuli ingoma eyodwa ka-Big Zulu ekhutjhwe mhlazi-25 kuNobayeni 2022.

=== 2023-nje: Inkabi Zezwe, ''Ukhamba'', ''Ngises' Congweni'' ===
Mhlana amalanga ali-17 kuNtaka 2023, u-Big Zulu no-Sjava bamemezela ukusebenza nge-albhamu yabo ehlangeneko ''i-Ukhamba'' njenge-duo Inkabi Zezwe . &quot; Umbayimbayi &quot; yakhutjhwa mhlana amalanga ama-24 kuNtaka ngomnyaka wee-2023 njengengoma ephambili ye-albhamu.  Ingoma le yavela kuyingoma yokuthoma ku-iTunes Top 50 kanye ne-Spotify Top 100 South Africa ngokulandelana.  Ingoma le yaqinisekiswa njenge-3× Platinum eSewula Afrika.   

Mhlana kuthoma inyanga kaMrhayili, u-Zulu wamemezela i-Inkabi Zezwe Tour eyathoma ngoMgwengweni bekwaba nguNobayeni ngomnyaka wee-2023.

I-albhamu le yakhutjhwa mhlana amalanga ali-12 kuMrhayili ngomnyaka wee-2023. Yaba yinto yokuthoma emazweni amabili weSewula Afrika ne-Eswatini ngokulandelana. 

Ngasekupheleni kukaTjhirhweni ngomnyaka wee-2024, uZulu wamemezela ukusebenza nge-albhamu yakhe yesine ye-studio kanye ne-albhamu yakhe ephambili &quot;Awufuni Ukung' Qoma&quot;. ''I-Ngises' Congweni'' yakhutjhwa mhlana amalanga ama-27 kuNtaka ngomnyaka wee- 2023.    

=== Umabonakude ===
Ngenyanga kaMgwengweni ngomnyaka wee-2024, uZulu wangenela  umdlalo wokufuna amathalenta ''u-Ushuni Womhlaba'', njengomahluleli  ku-SABC 1 mhlana amalanga alikhomba kuNtaka. 

=== Amanye amabubulo ===
Ngomnyaka wee-2019, uZulu wasungula ilebula yamarekhodi i-Inkabi Records.  UZulu sele asayine uMduduzi Ncube, uLwah Ndlunkulu, uXowla no Siya Ntuli. 

Mhlana amalanga ama-21 kuNobayeni ngomnyaka wee-2021, uZulu wathoma ukusiza abantu abadla imbuya ngelithi begodu wanikela ngemitjhininqondo namaphrinta e-Obonjaneni Primary School. 

Kusukela ngoRhoboyi ngomnyaka wee- 2020, wasebenzisana no Spitz njengomsekeli (ambassador) we-Carvela.  

== I-Discography ==

=== Ama-albhamu we-studio ===

* ''Ushun Wenkabi'' (2018)
* ''Ungqongqoshe Wongqongqoshe'' (2019)
* ''Ichwane Lenyoka'' (2021) 
* ''Ngises' Congweni'' (2024)
* ''Icala Le Mpumelelo'' (2025)

=== Ama-albhamu wokubambisana ===

* ''Inkabi Nation'' (2022)
* ''Ukhamba'' (2023)

=== Njengomdosi phambili kwezomvumo ===
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+Irhelo lama-single njengabaculi abadosa phambili, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;AmaMillion&quot; ene-Musiholiq, Cassper Nyovest
| 2019
|
| Iplatinamu 
| rowspan=&quot;2&quot; | ''Ngqongqoshe Wongqongqoshe''
|-
! scope=&quot;row&quot; | &quot;Vuma Dlozi&quot; ehlanganisa uMnqobi Yazo
| 2020
|
| Iplatinamu &lt;ref name=&quot;DailySUN&quot; /&gt;
|-
! scope=&quot;row&quot; | &quot; Mali Eningi &quot; ehlanganisa u-Ntaba Yase Dubai, u-Ricky Rick
| rowspan=&quot;3&quot; | 2021
| 2
| 2× Iplatinamu
| rowspan=&quot;4&quot; | ''Ichwane Lenyoka''
|-
! scope=&quot;row&quot; | &quot;Umuzi eSandton&quot; nge- Lwah Ndlunkulu
| —
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;Inhlupheko&quot; ehlanganisa uMduduzi Ncube
| 1
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;iVolovolo&quot; ene-Xowla
| 2022
| —
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;Dear My Love&quot; ene-Xowla, KO no -Siya Ntuli
| 2022
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Awufuni Ukung' Qoma&quot;
| rowspan=&quot;3&quot; | 2024
| —
|
| ''UCongweni kaNgises''
|-
! scope=&quot;row&quot; | &quot;200 Bars&quot;
| — 
||{{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ay Ka'Ncane&quot; (Big Zulu, Tony Dayimane)
| — 
||{{non-album single}} 
|-
! scope=&quot;row&quot; | &quot;Amacala Othando&quot; (Big Zulu, Azana, Malungelo)
| rowspan=&quot;2&quot; | 2025
| — 
||{{non-album single}} 
|-
! scope=&quot;row&quot; | &quot;Abazazi Bafunani&quot; (ehlanganisa u-Emtee )
| 2 
|
| Icala Le Mpumelelo
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; | &quot;—&quot; kutjho ukurekhoda okungazange kushadi namkha okungakakhutjhwa endaweni leyo.
|}
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center&quot;
|+Irhelo lazingoma azihlanganyele nabanye njengabaculi abaveziweko, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;Isigingci&quot; (Mduduzi ehlanganisa uBig Zulu)
| 2020
| —
|
| ''Isitimela''
|-
! scope=&quot;row&quot; | &quot;Alusafani&quot; ( Qwabe Twins featuring Big Zulu, Mduduzi, Xowla)
| rowspan=&quot;2&quot; | 2021
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Qoma&quot; ( Blaq Diamond nge-Siya Ntuli, Big Zulu)
| —
| I-RiSA: Iplatinamu 
| Ithando lesiZulu
|-
! scope=&quot;row&quot; | &quot;Amalobolo&quot; ( u-Nomfundo Moh ohlanganisa u-Big Zulu)
| 2023
| —
|
| ''Ugcobo''
|-
! scope=&quot;row&quot; | &quot;Beng' dakiwe (u-Xowla ahlanganisa u-Big Zulu, u-DJ Tira )
| rowspan=&quot;2&quot; | 2023
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;My Ex&quot; (Big Xhosa featuring Big Zulu)
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Mfazi Wephepha&quot; (Nkosazana Daughter, Master Kg featuring Big Zulu, Zee Nxumalo )
| 2024
| 4 
|
| ''Makhelwane''
|}

== Imitlomelo nokuphakanyiswa ==
{| class=&quot;wikitable&quot;
!Umnyaka
! Umtlomelo
! Umkhakha
! Imiphumela
! Ref.
|-
| rowspan=&quot;3&quot; | 2019
| rowspan=&quot;2&quot; | SAHHA
| I-albhamu yomnyaka| {{nom}}
| rowspan=&quot;2&quot; |  
|-
| Umdwebi wesilisa ophuma phambili womnyaka|{{nom}}
|-
| I-SAMA 26
| I-albhamu ye-Hip Hop ehle khulu| {{nom}}
|  
|-
| 2020
| SAHHA
| I-Remix ehle khulu| {{Nom}}
| 
|-
| 2021
| I-SAMA 27
| Ukusebenzisana okuhle khulu|{{won}}
|  
|-
| rowspan=&quot;8&quot; | 2021
| rowspan=&quot;8&quot; | I-SAHHA 10
| I-albhamu yomnyaka|{{won}}
| rowspan=&quot;8&quot; |  
|-
| Owesilisa ophuma phambili|{{won}}
|-
| Ingoma yomnyaka|{{won}}
|-
| Ukusebenzisana okuhle khulu|{{won}}
|-
| I-MVP/Umtjhayeli womnyaka|{{nom}}
|-
| Ividiyo ehle khulu|{{won}}
|-
| Umvuzo we-Ubuntu Activism|{{won}}
|-
| Ukuthengisa okuhle khulu kwedijithali|{{won}}
|-
| rowspan=&quot;2&quot; | 2022
| rowspan=&quot;2&quot; | DStv MVCA
| Ingoma engiyithandako| {{nom}}
| rowspan=&quot;2&quot; | 
|-
| Umculi womculo othandwako/isiqhema|{{nom}}
|-
| 2023
| 17th Metro FM Music Awards
| I-Duo/Isiqhema esihle khulu |{{Won}} 
|
|}

== UMTHOMBO LWAZI ==</text>
      <sha1>2qk21jy5tsb0rn6ud47rbb0sev6w1e3</sha1>
    </revision>
    <revision>
      <id>5562</id>
      <parentid>5558</parentid>
      <timestamp>2025-09-04T09:45:11Z</timestamp>
      <contributor>
        <username>Kholeka19721</username>
        <id>889</id>
      </contributor>
      <minor />
      <origin>5562</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="13629" sha1="bvw9c3wbk5fkqhvwq8dhh185hnkwpdc" xml:space="preserve">
'''BIG ZULU'''                         
[[Isimumathi:Big zulu.jpg|left|thumb|BIG ZULU]]
'''IMINININGWANA YANGEMUVA'''

'''IBIZO:'''  Siyabonga Nene

'''UKUBELETHWA:'''  7 KuSihlabantangana 1986

'''UMSEBENZI:''' Umrepha, umtloli weengoma

'''UNYAKA WOKUDUMA:''' 2003- njenganje

'''AMALEBULA:''' Universal Records(kwangaphambilini), Nkabi Records.

'''USiyabonga Nene''' (wabelethwa mhlana amalanga alikhomba, kuMrhayili ngomnyaka we-1986  )&lt;ref&gt;{{Cite web |last=Mag |first=SA Hip Hop |date=2021-04-07 |title=Happy Birthday Big Zulu! A Look Into Big Zulu's Best Selling Records |url=https://sahiphopmag.co.za/2021/04/happy-birthday-big-zulu-a-look-into-big-zulus-best-selling-records/ |access-date=2025-09-04 |website=SA Hip Hop Mag |language=en-US}}&lt;/ref&gt;&lt;ref&gt;{{Citation |last=Ladson-Billings |first=Gloria |title=From Big Homie the O.G., to GLB |date=2018-03-23 |work=#HipHopEd: The Compilation on Hip-hop Education |pages=21–26 |url=https://doi.org/10.1163/9789004371873_003 |access-date=2025-09-04 |publisher=BRILL |isbn=978-90-04-37187-3}}&lt;/ref&gt;
, owaziwa ngebizo elibizwa laka '''Big Zulu''', mrepha nomtloli weengoma we[[Isewula Afrika|Sewula Afrika]].  Waphakama ngemva kokukhipha ingoma ethi &quot;Donsa Nkabi&quot; ngomnyaka wee-2016.

Watlikitla isivumelwano sokurekhoda ne -Universal Music ngomnyaka wee- 2015 begodu  wakhipha i-albhamu yakhe yokuthoma, ''u-Ushun Wenkabi'' (2018)  no ''-Ungqongqoshe Wongqongqoshe'' (2019).

I-albhamu yesithathu ka Big Zulu ''Ichwane Lenyoka'' (2021), yakhiqiza ama-single amathathu aphuma phambili &quot; Mali Eningi &quot;, &quot;Inhlupheko&quot; kanye no-&quot;Umuzi eSandton&quot;. Ingoma yayo ephambili &quot;i-Mali Eningi&quot;, yaqinisekiswa yi-double platinum yi- Recording Industry of South Africa (RiSA). 

[[Big Zulu|UBig Zulu]] wabuye wavela emidlalweni kamabonakude ''i-Isibaya'', ''One Mic'' (2017-2020),  ''Uzalo'' (2020), ''Isithembiso'', kanye ''no-Ushuni Womhlaba'' (2024).  Imitlomelo  yakhe ifaka hlangana imitlomelo  ye-Hip Hop yeSewula Afrika elikhomba, umtlomelo  owodwa we-South African Music Award kanye ne-Metro FM Music Awards eyodwa.

== Ipilo yokuthoma ==
USiyabonga Nene wabelethwa begodu wakhulela e -Bergville, KwaZulu-Natal. Wakhula alalele umvumo ka -Maskandi no-Isichathamiya, athonywa ngu -Ladysmith Black Mambazo, Phuzekemisi no-Imithente. Dacre, Richard (2015-05-28), &quot;Worth, Harry [real name Harry Bourlon Illingsworth] (1917–1989), comedian&quot;, Oxford Dictionary of National Biography, Oxford University Press, ISBN 978-0-19-861412-8, retrieved 2025-09-04

== IIMVELAPHI YOBUVUMO ==

=== Izithonyo ===
Uthonywe ngu-Maskandi no-Scathamiya.  Bekahlala e-Vaal endaweni ebizwa nge-Palm Springs.

== Ibizelo ==

=== Ukuthoma komsebenzi ===
UZulu wahlala iminyaka eminengi amtjhayeli wetekisi begodu watjhiya ngomnyaka wee-2008 ukobana aragele phambili nomsebenzi wakhe wezomvumo. Ngomnyaka wee-2009, ngemva kobana atjhiye ibubulo lamathekisi wathoma ukutlola iingoma nokudlala.

Ngemva kweminyaka emine ngomnyaka wee-2013, u-Zulu waphalisana begodu waba ngowokuthoma ukuthumba iphalisano le Red Bull Back to the city.  Ingoma yakhe yokuthoma ethi &quot;Donsa Nkabi&quot; yakhutjhwa ngomnyaka wee-2016. 

=== 2014–2019: ''Ushun Wenkabi'', ''Ungqongqoshe Wongqongqoshe'' ===
Ngemva kweminyaka eminengi njengomvumi ozijameleko, watlikitla isivumelwano sokurekhoda ne-Universal Music Records ngomnyaka wee-2015 begodu wakhupha i-albhamu yakhe yokuthoma ''i-Ushun Wenkabi'' ngenyanga ka Velabahlinze ngomnyaka wee-2018, eneengoma ezifaka hlangana &quot;u-Ang'mazi umama&quot; no-&quot;Home&quot;. 

I-albhamu yakhe yesibili ye-studio ''u-Ungqongqoshe Wongqongqoshe'' yakhutjhwa ngomnyaka wee-2019,  ihlanganisa u-Ab Crazy, u-Mnqobi Yazo, u-FiFi Cooper, u-Kwesta, u-Caspper Nyovest, u-Musiholiq no-Truhitz.  Ingoma ephambili ethi &quot;Ak'laleki&quot; eno-Kwesta yakhutjhwa. Mhlana amalanga amabili kuRhoboyi ingoma yakhe yesibili ethi &quot;Ama Million&quot; eno- Cassper Nyovest &amp; Musiholiq yakhutjhwa begodu yafika endaweni yesihlanu ku-iTunes Chart.   Ingoma le beyiqinisekiswe njengeplatinamu.   Mhlana amalanga ali-14 kuRhoboyi, ingoma yakhe yesithathu ethi &quot;Vuma dlozi&quot; ehlanganisa u-Mnqobi Yazo yakhutjhwa  begodu yaqinisekiswa yi-platinamu yibubulo lokurekhoda leSewula Afrika (i-RiSA) ngokuthengisa amakhophi ama-50 000. &lt;ref name=&quot;ubetoo&quot; /&gt; I-albhamu le yaqinisekiswa njengegolide yi-Recording Industry of South Africa (RiSA)  begodu yathola ukukhethwa ku- South African Music Awards (SAMA26)  ye-Best Hip Hop Album.  Ngomnyaka ofanako, wee-2019, i-albhamu leyo yakhethwa njenge-Best Male Artist of the Year kanye ne-albhamu yomnyaka e -South African Hip Hop Awards .  Wasungula ilebula yakhe yamarekhodi i-Nkabi Records. 

=== 2020–2022: ''Ichwane Lenyoka'', ''Nkabi Nation'' ===
Mhlana amalanga ama-20 kuNobayeni ngomnyaka wee- 2020, ingoma yakhe ethi &quot; Mali Eningi &quot; yakhutjhwa ifaka hlangana umvumi ongu Intaba Yase Dubai no-Ricky Rick njengengoma ephambili ye-albhamu. Ingoma le yavela endaweni yesibili kumatjhadi we ''[[Channel 0 (South Africa)|-Channel 0]]'' Top 30  begodu yaqinisekiswa njenge-double platinum.  Emnyanyeni we -27th annual South African Music Awards,ingoma i  &quot;Mali Eningi&quot; yathumba isigaba sokubambisana okuhle khulu.  Ekupheleni komnyaka wee-2020 wakhethwa kokuthoma ku -MTV Base: SA's Hottest MCs, endaweni yesihlanu. 

Ngasekupheleni kukaTjhirhweni ngomnyaka wee-2021, wamemezela ukusebenza kwe-albhamu yakhe yesithathu.   

Mhlana amalanga ali-11 kuNtaka ngomnyaka wee-2021, wakhupha ingoma &quot;Inhlupheko&quot; enoMduduzi Ncube njengengoma yesibili.  Ingoma le yafika endaweni yokuthoma ematjhadini we-iTunes weSewula Afrika begodu yafika endaweni yesine ematjhadini we-Shazam. 

Mhlana amalanga amathathu kuNtaka ngomnyaka wee-2021, wamemezela ingoma etja ebizwa ngokuthi &quot;Umuzi eSandton&quot; ehlanganisa u-Lwah Ndlunkulu ku -Twitter .  Ingoma le yakhutjhwa mhlana amalanga alithoba kuNtaka ngomnyaka wee-2021;  Yavezwa ku-albhamu yakhe ''i-Ichwane Lenyoka'', eyakhutjhwa mhlana amalanga amathathu kuNobayeni 2021.  Ingoma ethi &quot;Umuzi eSandton&quot; yafika endaweni yokuthoma ematjhadini we-Shazam. 

Mhlana amalanga ali-13 kuNobayeni ngomnyaka wee-2021, wenza isizini yetjhumi nane ku- ''Idols South Africa'' .  UZulu uthumbe imitlomelo elikhomba efaka hlangana; I-albhamu yomnyaka, ingoma yomnyaka (&quot; Mali Eningi &quot;), ividiyo yomculo ehle khulu, umvuzo we-Best Male and Ubuntu Activism, Best Collaboration, kanye no-Best Digital Sales kuma -2021 South African Hip Hop Awards .  Ekupheleni komnyaka wee-2021 wakhethwa godu ku-MTV Base: SA's Hottest MCs, wakhuphukela endaweni yesibili. 

I-&quot;iVolovolo&quot; eno Xowla yakhutjhwa mhlana amalanga alitjhumi nanye kuMhlolanja ngomnyaka wee-2022. Ingoma le yathoma ukudlala phambili eSewula Afrika.  

I-&quot;Voicemail&quot; ka-Big Zulu, Mduduzi Ncube, Lwah Ndlunkulu, Siya Ntuli no-Xowla yakhutjhwa njengengoma ephambili ye-albhamu mhlana amalanga ama-24 kuMgwengweni ngonyaka wee-2022.  Ingoma le yaqinisekiswa njengegolide begodu yafika endaweni yokuthoma eSewula Afrika.  

Wakhupha  i-&quot;150 Bars (Ke hip hop Dawg)&quot; mhlana amalanga ama-20 kuRhoboyi ngomnyaka wee-2022. Ingoma le yangena ematjhadini we-Local Top 10 Radio endaweni yesikhombisa. 

Wamemezela  ilanga lokukhutjhwa kwama-albhamu kanye irhelo lokugcina lwengoma ku-Instagram, ekhutjhwe mhlana amalanga alithoba kuNobayeni ngomnyaka wee-2022. 

&quot;Dear My Love&quot; ehlanganisa u-KO, Xowla no-Siya Ntuli ingoma eyodwa ka-Big Zulu ekhutjhwe mhlazi-25 kuNobayeni 2022.

=== 2023-nje: Inkabi Zezwe, ''Ukhamba'', ''Ngises' Congweni'' ===
Mhlana amalanga ali-17 kuNtaka 2023, u-Big Zulu no-Sjava bamemezela ukusebenza nge-albhamu yabo ehlangeneko ''i-Ukhamba'' njenge-duo Inkabi Zezwe . &quot; Umbayimbayi &quot; yakhutjhwa mhlana amalanga ama-24 kuNtaka ngomnyaka wee-2023 njengengoma ephambili ye-albhamu.  Ingoma le yavela kuyingoma yokuthoma ku-iTunes Top 50 kanye ne-Spotify Top 100 South Africa ngokulandelana.  Ingoma le yaqinisekiswa njenge-3× Platinum eSewula Afrika.   

Mhlana kuthoma inyanga kaMrhayili, u-Zulu wamemezela i-Inkabi Zezwe Tour eyathoma ngoMgwengweni bekwaba nguNobayeni ngomnyaka wee-2023.

I-albhamu le yakhutjhwa mhlana amalanga ali-12 kuMrhayili ngomnyaka wee-2023. Yaba yinto yokuthoma emazweni amabili weSewula Afrika ne-Eswatini ngokulandelana. 

Ngasekupheleni kukaTjhirhweni ngomnyaka wee-2024, uZulu wamemezela ukusebenza nge-albhamu yakhe yesine ye-studio kanye ne-albhamu yakhe ephambili &quot;Awufuni Ukung' Qoma&quot;. ''I-Ngises' Congweni'' yakhutjhwa mhlana amalanga ama-27 kuNtaka ngomnyaka wee- 2023.    

=== Umabonakude ===
Ngenyanga kaMgwengweni ngomnyaka wee-2024, uZulu wangenela  umdlalo wokufuna amathalenta ''u-Ushuni Womhlaba'', njengomahluleli  ku-SABC 1 mhlana amalanga alikhomba kuNtaka. 

=== Amanye amabubulo ===
Ngomnyaka wee-2019, uZulu wasungula ilebula yamarekhodi i-Inkabi Records.  UZulu sele asayine uMduduzi Ncube, uLwah Ndlunkulu, uXowla no Siya Ntuli. 

Mhlana amalanga ama-21 kuNobayeni ngomnyaka wee-2021, uZulu wathoma ukusiza abantu abadla imbuya ngelithi begodu wanikela ngemitjhininqondo namaphrinta e-Obonjaneni Primary School. 

Kusukela ngoRhoboyi ngomnyaka wee- 2020, wasebenzisana no Spitz njengomsekeli (ambassador) we-Carvela.  

== I-Discography ==

=== Ama-albhamu we-studio ===

* ''Ushun Wenkabi'' (2018)
* ''Ungqongqoshe Wongqongqoshe'' (2019)
* ''Ichwane Lenyoka'' (2021) 
* ''Ngises' Congweni'' (2024)
* ''Icala Le Mpumelelo'' (2025)

=== Ama-albhamu wokubambisana ===

* ''Inkabi Nation'' (2022)
* ''Ukhamba'' (2023)

=== Njengomdosi phambili kwezomvumo ===
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+Irhelo lama-single njengabaculi abadosa phambili, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;AmaMillion&quot; ene-Musiholiq, Cassper Nyovest
| 2019
|
| Iplatinamu 
| rowspan=&quot;2&quot; | ''Ngqongqoshe Wongqongqoshe''
|-
! scope=&quot;row&quot; | &quot;Vuma Dlozi&quot; ehlanganisa uMnqobi Yazo
| 2020
|
| Iplatinamu &lt;ref name=&quot;DailySUN&quot; /&gt;
|-
! scope=&quot;row&quot; | &quot; Mali Eningi &quot; ehlanganisa u-Ntaba Yase Dubai, u-Ricky Rick
| rowspan=&quot;3&quot; | 2021
| 2
| 2× Iplatinamu
| rowspan=&quot;4&quot; | ''Ichwane Lenyoka''
|-
! scope=&quot;row&quot; | &quot;Umuzi eSandton&quot; nge- Lwah Ndlunkulu
| —
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;Inhlupheko&quot; ehlanganisa uMduduzi Ncube
| 1
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;iVolovolo&quot; ene-Xowla
| 2022
| —
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;Dear My Love&quot; ene-Xowla, KO no -Siya Ntuli
| 2022
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Awufuni Ukung' Qoma&quot;
| rowspan=&quot;3&quot; | 2024
| —
|
| ''UCongweni kaNgises''
|-
! scope=&quot;row&quot; | &quot;200 Bars&quot;
| — 
||{{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ay Ka'Ncane&quot; (Big Zulu, Tony Dayimane)
| — 
||{{non-album single}} 
|-
! scope=&quot;row&quot; | &quot;Amacala Othando&quot; (Big Zulu, Azana, Malungelo)
| rowspan=&quot;2&quot; | 2025
| — 
||{{non-album single}} 
|-
! scope=&quot;row&quot; | &quot;Abazazi Bafunani&quot; (ehlanganisa u-Emtee )
| 2 
|
| Icala Le Mpumelelo
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; | &quot;—&quot; kutjho ukurekhoda okungazange kushadi namkha okungakakhutjhwa endaweni leyo.
|}
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center&quot;
|+Irhelo lazingoma azihlanganyele nabanye njengabaculi abaveziweko, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;Isigingci&quot; (Mduduzi ehlanganisa uBig Zulu)
| 2020
| —
|
| ''Isitimela''
|-
! scope=&quot;row&quot; | &quot;Alusafani&quot; ( Qwabe Twins featuring Big Zulu, Mduduzi, Xowla)
| rowspan=&quot;2&quot; | 2021
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Qoma&quot; ( Blaq Diamond nge-Siya Ntuli, Big Zulu)
| —
| I-RiSA: Iplatinamu 
| Ithando lesiZulu
|-
! scope=&quot;row&quot; | &quot;Amalobolo&quot; ( u-Nomfundo Moh ohlanganisa u-Big Zulu)
| 2023
| —
|
| ''Ugcobo''
|-
! scope=&quot;row&quot; | &quot;Beng' dakiwe (u-Xowla ahlanganisa u-Big Zulu, u-DJ Tira )
| rowspan=&quot;2&quot; | 2023
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;My Ex&quot; (Big Xhosa featuring Big Zulu)
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Mfazi Wephepha&quot; (Nkosazana Daughter, Master Kg featuring Big Zulu, Zee Nxumalo )
| 2024
| 4 
|
| ''Makhelwane''
|}

== Imitlomelo nokuphakanyiswa ==
{| class=&quot;wikitable&quot;
!Umnyaka
! Umtlomelo
! Umkhakha
! Imiphumela
! Ref.
|-
| rowspan=&quot;3&quot; | 2019
| rowspan=&quot;2&quot; | SAHHA
| I-albhamu yomnyaka| {{nom}}
| rowspan=&quot;2&quot; |  
|-
| Umdwebi wesilisa ophuma phambili womnyaka|{{nom}}
|-
| I-SAMA 26
| I-albhamu ye-Hip Hop ehle khulu| {{nom}}
|  
|-
| 2020
| SAHHA
| I-Remix ehle khulu| {{Nom}}
| 
|-
| 2021
| I-SAMA 27
| Ukusebenzisana okuhle khulu|{{won}}
|  
|-
| rowspan=&quot;8&quot; | 2021
| rowspan=&quot;8&quot; | I-SAHHA 10
| I-albhamu yomnyaka|{{won}}
| rowspan=&quot;8&quot; |  
|-
| Owesilisa ophuma phambili|{{won}}
|-
| Ingoma yomnyaka|{{won}}
|-
| Ukusebenzisana okuhle khulu|{{won}}
|-
| I-MVP/Umtjhayeli womnyaka|{{nom}}
|-
| Ividiyo ehle khulu|{{won}}
|-
| Umvuzo we-Ubuntu Activism|{{won}}
|-
| Ukuthengisa okuhle khulu kwedijithali|{{won}}
|-
| rowspan=&quot;2&quot; | 2022
| rowspan=&quot;2&quot; | DStv MVCA
| Ingoma engiyithandako| {{nom}}
| rowspan=&quot;2&quot; | 
|-
| Umculi womculo othandwako/isiqhema|{{nom}}
|-
| 2023
| 17th Metro FM Music Awards
| I-Duo/Isiqhema esihle khulu |{{Won}} 
|
|}

== UMTHOMBO LWAZI ==</text>
      <sha1>bvw9c3wbk5fkqhvwq8dhh185hnkwpdc</sha1>
    </revision>
    <revision>
      <id>5571</id>
      <parentid>5562</parentid>
      <timestamp>2025-09-04T09:49:44Z</timestamp>
      <contributor>
        <username>Kholeka19721</username>
        <id>889</id>
      </contributor>
      <minor />
      <origin>5571</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="13659" sha1="8vd6qgwd7qe1f460x02d1cpjn7n2e8t" xml:space="preserve">
'''BIG ZULU'''                         
[[Isimumathi:Big zulu.jpg|left|thumb|BIG ZULU]]
'''IMINININGWANA YANGEMUVA'''

'''IBIZO:'''  Siyabonga Nene

'''UKUBELETHWA:'''  7 KuSihlabantangana 1986

'''UMSEBENZI:''' Umrepha, umtloli weengoma

'''UNYAKA WOKUDUMA:''' 2003- njenganje

'''AMALEBULA:''' Universal Records(kwangaphambilini), Nkabi Records.

'''USiyabonga Nene''' (wabelethwa mhlana amalanga alikhomba, kuMrhayili ngomnyaka we-1986  )&lt;ref&gt;{{Cite web |last=Mag |first=SA Hip Hop |date=2021-04-07 |title=Happy Birthday Big Zulu! A Look Into Big Zulu's Best Selling Records |url=https://sahiphopmag.co.za/2021/04/happy-birthday-big-zulu-a-look-into-big-zulus-best-selling-records/ |access-date=2025-09-04 |website=SA Hip Hop Mag |language=en-US}}&lt;/ref&gt;&lt;ref&gt;{{Citation |last=Ladson-Billings |first=Gloria |title=From Big Homie the O.G., to GLB |date=2018-03-23 |work=#HipHopEd: The Compilation on Hip-hop Education |pages=21–26 |url=https://doi.org/10.1163/9789004371873_003 |access-date=2025-09-04 |publisher=BRILL |isbn=978-90-04-37187-3}}&lt;/ref&gt;
, owaziwa ngebizo elibizwa laka '''Big Zulu''', mrepha nomtloli weengoma we[[Isewula Afrika|Sewula Afrika]].  Waphakama ngemva kokukhipha ingoma ethi &quot;Donsa NkaDobi&quot; ngomnyaka wee-2016.

Watlikitla isivumelwano sokurekhoda ne -Universal Music ngomnyaka wee- 2015 begodu  wakhipha i-albhamu yakhe yokuthoma, ''u-Ushun Wenkabi'' (2018) no ''-Ungqongqoshe Wongqongqoshe'' (2019).

I-albhamu yesithathu ka Big Zulu ''Ichwane Lenyoka'' (2021), yakhiqiza ama-single amathathu aphuma phambili &quot; Mali Eningi &quot;, &quot;Inhlupheko&quot; kanye no-&quot;Umuzi eSandton&quot;. Ingoma yayo ephambili &quot;i-Mali Eningi&quot;, yaqinisekiswa yi-double platinum yi- Recording Industry of South Africa (RiSA). 

[[Big Zulu|UBig Zulu]] wabuye wavela emidlalweni kamabonakude ''i-Isibaya'', ''One Mic'' (2017-2020),  ''Uzalo'' (2020), ''Isithembiso'', kanye ''no-Ushuni Womhlaba'' (2024).  Imitlomelo  yakhe ifaka hlangana imitlomelo  ye-Hip Hop yeSewula Afrika elikhomba, umtlomelo  owodwa we-South African Music Award kanye ne-Metro FM Music Awards eyodwa.

== Ipilo yokuthoma ==
USiyabonga Nene wabelethwa begodu wakhulela e -Bergville, KwaZulu-Natal. Wakhula alalele umvumo ka -Maskandi no-Isichathamiya, athonywa ngu -Ladysmith Black Mambazo, Phuzekemisi no-Imithente. Dacre, Richard (2015-05-28), &quot;Worth, Harry [real name Harry Bourlon Illingsworth] (1917–1989), comedian&quot;, Oxford Dictionary of National Biography, Oxford University Press, ISBN 978-0-19-861412-8, retrieved 2025-09-04

== IIMVELAPHI YOBUVUMO ==

=== Izithonyo ===
Uthonywe ngu-Maskandi no-Scathamiya.  Bekahlala e-Vaal endaweni ebizwa nge-Palm Springs.

== Ibizelo ==

=== Ukuthoma komsebenzi ===
UZulu wahlala iminyaka eminengi amtjhayeli wetekisi begodu watjhiya ngomnyaka wee-2008 ukobana aragele phambili nomsebenzi wakhe wezomvumo. Ngomnyaka wee-2009, ngemva kobana atjhiye ibubulo lamathekisi wathoma ukutlola iingoma nokudlala.

Ngemva kweminyaka emine ngomnyaka wee-2013, u-Zulu waphalisana begodu waba ngowokuthoma ukuthumba iphalisano le Red Bull Back to the city.  Ingoma yakhe yokuthoma ethi &quot;Donsa Nkabi&quot; yakhutjhwa ngomnyaka wee-2016. 

=== 2014–2019: ''Ushun Wenkabi'', ''Ungqongqoshe Wongqongqoshe'' ===
Ngemva kweminyaka eminengi njengomvumi ozijameleko, watlikitla isivumelwano sokurekhoda ne-Universal Music Records ngomnyaka wee-2015 begodu wakhupha i-albhamu yakhe yokuthoma ''i-Ushun Wenkabi'' ngenyanga ka Velabahlinze ngomnyaka wee-2018, eneengoma ezifaka hlangana &quot;u-Ang'mazi umama&quot; no-&quot;Home&quot;. 

I-albhamu yakhe yesibili ye-studio ''u-Ungqongqoshe Wongqongqoshe'' yakhutjhwa ngomnyaka wee-2019,  ihlanganisa u-Ab Crazy, u-Mnqobi Yazo, u-FiFi Cooper, u-Kwesta, u-Caspper Nyovest, u-Musiholiq no-Truhitz.  Ingoma ephambili ethi &quot;Ak'laleki&quot; eno-Kwesta yakhutjhwa. Mhlana amalanga amabili kuRhoboyi ingoma yakhe yesibili ethi &quot;Ama Million&quot; eno- Cassper Nyovest &amp; Musiholiq yakhutjhwa begodu yafika endaweni yesihlanu ku-iTunes Chart.   Ingoma le beyiqinisekiswe njengeplatinamu.   Mhlana amalanga ali-14 kuRhoboyi, ingoma yakhe yesithathu ethi &quot;Vuma dlozi&quot; ehlanganisa u-Mnqobi Yazo yakhutjhwa  begodu yaqinisekiswa yi-platinamu yibubulo lokurekhoda leSewula Afrika (i-RiSA) ngokuthengisa amakhophi ama-50 000. &lt;ref name=&quot;ubetoo&quot; /&gt; I-albhamu le yaqinisekiswa njengegolide yi-Recording Industry of South Africa (RiSA)  begodu yathola ukukhethwa ku- South African Music Awards (SAMA26)  ye-Best Hip Hop Album.  Ngomnyaka ofanako, wee-2019, i-albhamu leyo yakhethwa njenge-Best Male Artist of the Year kanye ne-albhamu yomnyaka e -South African Hip Hop Awards .  Wasungula ilebula yakhe yamarekhodi i-Nkabi Records. 

=== 2020–2022: ''Ichwane Lenyoka'', ''Nkabi Nation'' ===
Mhlana amalanga ama-20 kuNobayeni ngomnyaka wee- 2020, ingoma yakhe ethi &quot; Mali Eningi &quot; yakhutjhwa ifaka hlangana umvumi ongu Intaba Yase Dubai no-Ricky Rick njengengoma ephambili ye-albhamu. Ingoma le yavela endaweni yesibili kumatjhadi we ''[[Channel 0 (South Africa)|-Channel 0]]'' Top 30  begodu yaqinisekiswa njenge-double platinum.  Emnyanyeni we -27th annual South African Music Awards,ingoma i  &quot;Mali Eningi&quot; yathumba isigaba sokubambisana okuhle khulu.  Ekupheleni komnyaka wee-2020 wakhethwa kokuthoma ku -MTV Base: SA's Hottest MCs, endaweni yesihlanu. 

Ngasekupheleni kukaTjhirhweni ngomnyaka wee-2021, wamemezela ukusebenza kwe-albhamu yakhe yesithathu.   

Mhlana amalanga ali-11 kuNtaka ngomnyaka wee-2021, wakhupha ingoma &quot;Inhlupheko&quot; enoMduduzi Ncube njengengoma yesibili.  Ingoma le yafika endaweni yokuthoma ematjhadini we-iTunes weSewula Afrika begodu yafika endaweni yesine ematjhadini we-Shazam. 

Mhlana amalanga amathathu kuNtaka ngomnyaka wee-2021, wamemezela ingoma etja ebizwa ngokuthi &quot;Umuzi eSandton&quot; ehlanganisa u-Lwah Ndlunkulu ku -Twitter .  Ingoma le yakhutjhwa mhlana amalanga alithoba kuNtaka ngomnyaka wee-2021;  Yavezwa ku-albhamu yakhe ''i-Ichwane Lenyoka'', eyakhutjhwa mhlana amalanga amathathu kuNobayeni 2021.  Ingoma ethi &quot;Umuzi eSandton&quot; yafika endaweni yokuthoma ematjhadini we-Shazam. 

Mhlana amalanga ali-13 kuNobayeni ngomnyaka wee-2021, wenza isizini yetjhumi nane ku- ''Idols South Africa'' .  UZulu uthumbe imitlomelo elikhomba efaka hlangana; I-albhamu yomnyaka, ingoma yomnyaka (&quot; Mali Eningi &quot;), ividiyo yomculo ehle khulu, umvuzo we-Best Male and Ubuntu Activism, Best Collaboration, kanye no-Best Digital Sales kuma -2021 South African Hip Hop Awards .  Ekupheleni komnyaka wee-2021 wakhethwa godu ku-MTV Base: SA's Hottest MCs, wakhuphukela endaweni yesibili. 

I-&quot;iVolovolo&quot; eno Xowla yakhutjhwa mhlana amalanga alitjhumi nanye kuMhlolanja ngomnyaka wee-2022. Ingoma le yathoma ukudlala phambili eSewula Afrika.  

I-&quot;Voicemail&quot; ka-Big Zulu, Mduduzi Ncube, Lwah Ndlunkulu, Siya Ntuli no-Xowla yakhutjhwa njengengoma ephambili ye-albhamu mhlana amalanga ama-24 kuMgwengweni ngonyaka wee-2022.  Ingoma le yaqinisekiswa njengegolide begodu yafika endaweni yokuthoma eSewula Afrika.  

Wakhupha  i-&quot;150 Bars (Ke hip hop Dawg)&quot; mhlana amalanga ama-20 kuRhoboyi ngomnyaka wee-2022. Ingoma le yangena ematjhadini we-Local Top 10 Radio endaweni yesikhombisa. 

Wamemezela  ilanga lokukhutjhwa kwama-albhamu kanye irhelo lokugcina lwengoma ku-Instagram, ekhutjhwe mhlana amalanga alithoba kuNobayeni ngomnyaka wee-2022. 

&quot;Dear My Love&quot; ehlanganisa u-KO, Xowla no-Siya Ntuli ingoma eyodwa ka-Big Zulu ekhutjhwe mhlazi-25 kuNobayeni 2022.

=== 2023-nje: Inkabi Zezwe, ''Ukhamba'', ''Ngises' Congweni'' ===
Mhlana amalanga ali-17 kuNtaka 2023, u-Big Zulu no-Sjava bamemezela ukusebenza nge-albhamu yabo ehlangeneko ''i-Ukhamba'' njenge-duo Inkabi Zezwe . &quot; Umbayimbayi &quot; yakhutjhwa mhlana amalanga ama-24 kuNtaka ngomnyaka wee-2023 njengengoma ephambili ye-albhamu.  Ingoma le yavela kuyingoma yokuthoma ku-iTunes Top 50 kanye ne-Spotify Top 100 South Africa ngokulandelana.  Ingoma le yaqinisekiswa njenge-3× Platinum eSewula Afrika.   

Mhlana kuthoma inyanga kaMrhayili, u-Zulu wamemezela i-Inkabi Zezwe Tour eyathoma ngoMgwengweni bekwaba nguNobayeni ngomnyaka wee-2023.

I-albhamu le yakhutjhwa mhlana amalanga ali-12 kuMrhayili ngomnyaka wee-2023. Yaba yinto yokuthoma emazweni amabili weSewula Afrika ne-Eswatini ngokulandelana. 

Ngasekupheleni kukaTjhirhweni ngomnyaka wee-2024, uZulu wamemezela ukusebenza nge-albhamu yakhe yesine ye-studio kanye ne-albhamu yakhe ephambili &quot;Awufuni Ukung' Qoma&quot;. ''I-Ngises' Congweni'' yakhutjhwa mhlana amalanga ama-27 kuNtaka ngomnyaka wee- 2023.    

=== Umabonakude ===
Ngenyanga kaMgwengweni ngomnyaka wee-2024, uZulu wangenela  umdlalo wokufuna amathalenta ''u-Ushuni Womhlaba'', njengomahluleli  ku-SABC 1 mhlana amalanga alikhomba kuNtaka. 

=== Amanye amabubulo ===
Ngomnyaka wee-2019, uZulu wasungula ilebula yamarekhodi i-Inkabi Records.  UZulu sele asayine uMduduzi Ncube, uLwah Ndlunkulu, uXowla no Siya Ntuli. 

Mhlana amalanga ama-21 kuNobayeni ngomnyaka wee-2021, uZulu wathoma ukusiza abantu abadla imbuya ngelithi begodu wanikela ngemitjhininqondo namaphrinta e-Obonjaneni Primary School. 

Kusukela ngoRhoboyi ngomnyaka wee- 2020, wasebenzisana no Spitz njengomsekeli (ambassador) we-Carvela.  

== I-Discography ==

=== Ama-albhamu we-studio ===

* ''Ushun Wenkabi'' (2018)
* ''Ungqongqoshe Wongqongqoshe'' (2019)
* ''Ichwane Lenyoka'' (2021) 
* ''Ngises' Congweni'' (2024)
* ''Icala Le Mpumelelo'' (2025)

=== Ama-albhamu wokubambisana ===

* ''Inkabi Nation'' (2022)
* ''Ukhamba'' (2023)

=== Njengomdosi phambili kwezomvumo ===
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+Irhelo lama-single njengabaculi abadosa phambili, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;AmaMillion&quot; ene-Musiholiq, Cassper Nyovest
| 2019
|
| Iplatinamu 
| rowspan=&quot;2&quot; | ''Ngqongqoshe Wongqongqoshe''
|-
! scope=&quot;row&quot; | &quot;Vuma Dlozi&quot; ehlanganisa uMnqobi Yazo
| 2020
|
| Iplatinamu &lt;ref name=&quot;DailySUN&quot; /&gt;
|-
! scope=&quot;row&quot; | &quot; Mali Eningi &quot; ehlanganisa u-Ntaba Yase Dubai, u-Ricky Rick
| rowspan=&quot;3&quot; | 2021
| 2
| 2× Iplatinamu
| rowspan=&quot;4&quot; | ''Ichwane Lenyoka''
|-
! scope=&quot;row&quot; | &quot;Umuzi eSandton&quot; nge- Lwah Ndlunkulu
| —
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;Inhlupheko&quot; ehlanganisa uMduduzi Ncube
| 1
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;iVolovolo&quot; ene-Xowla
| 2022
| —
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;Dear My Love&quot; ene-Xowla, KO no -Siya Ntuli
| 2022
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Awufuni Ukung' Qoma&quot;
| rowspan=&quot;3&quot; | 2024
| —
|
| ''UCongweni kaNgises''
|-
! scope=&quot;row&quot; | &quot;200 Bars&quot;
| — 
||{{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ay Ka'Ncane&quot; (Big Zulu, Tony Dayimane)
| — 
||{{non-album single}} 
|-
! scope=&quot;row&quot; | &quot;Amacala Othando&quot; (Big Zulu, Azana, Malungelo)
| rowspan=&quot;2&quot; | 2025
| — 
||{{non-album single}} 
|-
! scope=&quot;row&quot; | &quot;Abazazi Bafunani&quot; (ehlanganisa u-Emtee )
| 2 
|
| Icala Le Mpumelelo
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; | &quot;—&quot; kutjho ukurekhoda okungazange kushadi namkha okungakakhutjhwa endaweni leyo.
|}
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center&quot;
|+Irhelo lazingoma azihlanganyele nabanye njengabaculi abaveziweko, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;Isigingci&quot; (Mduduzi ehlanganisa uBig Zulu)
| 2020
| —
|
| ''Isitimela''
|-
! scope=&quot;row&quot; | &quot;Alusafani&quot; ( Qwabe Twins featuring Big Zulu, Mduduzi, Xowla)
| rowspan=&quot;2&quot; | 2021
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Qoma&quot; ( Blaq Diamond nge-Siya Ntuli, Big Zulu)
| —
| I-RiSA: Iplatinamu 
| Ithando lesiZulu
|-
! scope=&quot;row&quot; | &quot;Amalobolo&quot; ( u-Nomfundo Moh ohlanganisa u-Big Zulu)
| 2023
| —
|
| ''Ugcobo''
|-
! scope=&quot;row&quot; | &quot;Beng' dakiwe (u-Xowla ahlanganisa u-Big Zulu, u-DJ Tira )
| rowspan=&quot;2&quot; | 2023
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;My Ex&quot; (Big Xhosa featuring Big Zulu)
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Mfazi Wephepha&quot; (Nkosazana Daughter, Master Kg featuring Big Zulu, Zee Nxumalo )
| 2024
| 4 
|
| ''Makhelwane''
|}

== Imitlomelo nokuphakanyiswa ==
{| class=&quot;wikitable&quot;
!Umnyaka
! Umtlomelo
! Umkhakha
! Imiphumela
! Ref.
|-
| rowspan=&quot;3&quot; | 2019
| rowspan=&quot;2&quot; | SAHHA
| I-albhamu yomnyaka| {{nom}}
| rowspan=&quot;2&quot; |  
|-
| Umdwebi wesilisa ophuma phambili womnyaka|{{nom}}
|-
| I-SAMA 26
| I-albhamu ye-Hip Hop ehle khulu| {{nom}}
|  
|-
| 2020
| SAHHA
| I-Remix ehle khulu| {{Nom}}
| 
|-
| 2021
| I-SAMA 27
| Ukusebenzisana okuhle khulu|{{won}}
|  
|-
| rowspan=&quot;8&quot; | 2021
| rowspan=&quot;8&quot; | I-SAHHA 10
| I-albhamu yomnyaka|{{won}}
| rowspan=&quot;8&quot; |  
|-
| Owesilisa ophuma phambili|{{won}}
|-
| Ingoma yomnyaka|{{won}}
|-
| Ukusebenzisana okuhle khulu|{{won}}
|-
| I-MVP/Umtjhayeli womnyaka|{{nom}}
|-
| Ividiyo ehle khulu|{{won}}
|-
| Umvuzo we-Ubuntu Activism|{{won}}
|-
| Ukuthengisa okuhle khulu kwedijithali|{{won}}
|-
| rowspan=&quot;2&quot; | 2022
| rowspan=&quot;2&quot; | DStv MVCA
| Ingoma engiyithandako| {{nom}}
| rowspan=&quot;2&quot; | 
|-
| Umculi womculo othandwako/isiqhema|{{nom}}
|-
| 2023
| 17th Metro FM Music Awards
| I-Duo/Isiqhema esihle khulu |{{Won}} 
|
|}

== UMTHOMBO LWAZI ==
&lt;references responsive=&quot;&quot; /&gt;</text>
      <sha1>8vd6qgwd7qe1f460x02d1cpjn7n2e8t</sha1>
    </revision>
    <revision>
      <id>5591</id>
      <parentid>5571</parentid>
      <timestamp>2025-09-04T10:02:40Z</timestamp>
      <contributor>
        <username>Kholeka19721</username>
        <id>889</id>
      </contributor>
      <minor />
      <origin>5591</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="13627" sha1="51ggx9dkg3133j1b1e2x3e16aybpfs5" xml:space="preserve">
'''BIG ZULU'''                         
[[Isimumathi:Big zulu.jpg|left|thumb|BIG ZULU]]
'''IMINININGWANA YANGEMUVA'''

'''IBIZO:'''  Siyabonga Nene

'''UKUBELETHWA:'''  7 KuSihlabantangana 1986

'''UMSEBENZI:''' Umrepha, umtloli weengoma

'''UNYAKA WOKUDUMA:''' 2003- njenganje

'''AMALEBULA:''' Universal Records(kwangaphambilini), Nkabi Records.

'''USiyabonga Nene''' (wabelethwa mhlana amalanga alikhomba, kuMrhayili ngomnyaka we-1986  )&lt;ref&gt;{{Cite web |last=Mag |first=SA Hip Hop |date=2021-04-07 |title=Happy Birthday Big Zulu! A Look Into Big Zulu's Best Selling Records |url=https://sahiphopmag.co.za/2021/04/happy-birthday-big-zulu-a-look-into-big-zulus-best-selling-records/ |access-date=2025-09-04 |website=SA Hip Hop Mag |language=en-US}}&lt;/ref&gt;&lt;ref&gt;{{Citation |last=Ladson-Billings |first=Gloria |title=From Big Homie the O.G., to GLB |date=2018-03-23 |work=#HipHopEd: The Compilation on Hip-hop Education |pages=21–26 |url=https://doi.org/10.1163/9789004371873_003 |access-date=2025-09-04 |publisher=BRILL |isbn=978-90-04-37187-3}}&lt;/ref&gt;
, owaziwa ngebizo elibizwa laka '''Big Zulu''', mrepha nomtloli weengoma we[[Isewula Afrika|Sewula Afrika]].  Waphakama ngemva kokukhipha ingoma ethi &quot;Donsa NkaDobi&quot; ngomnyaka wee-2016.

Watlikitla isivumelwano sokurekhoda ne -Universal Music ngomnyaka wee- 2015 begodu  wakhipha i-albhamu yakhe yokuthoma, ''u-Ushun Wenkabi'' (2018) no ''-Ungqongqoshe Wongqongqoshe'' (2019).

I-albhamu yesithathu ka Big Zulu ''Ichwane Lenyoka'' (2021), yakhiqiza ama-single amathathu aphuma phambili &quot; Mali Eningi &quot;, &quot;Inhlupheko&quot; kanye no-&quot;Umuzi eSandton&quot;. Ingoma yayo ephambili &quot;i-Mali Eningi&quot;, yaqinisekiswa yi-double platinum yi- Recording Industry of South Africa (RiSA). 

[[Big Zulu|UBig Zulu]] wabuye wavela emidlalweni kamabonakude ''i-Isibaya'', ''One Mic'' (2017-2020),  ''Uzalo'' (2020), ''Isithembiso'', kanye ''no-Ushuni Womhlaba'' (2024).  Imitlomelo  yakhe ifaka hlangana imitlomelo  ye-Hip Hop yeSewula Afrika elikhomba, umtlomelo  owodwa we-South African Music Award kanye ne-Metro FM Music Awards eyodwa.

== Ipilo yokuthoma ==
USiyabonga Nene wabelethwa begodu wakhulela e -Bergville, KwaZulu-Natal. Wakhula alalele umvumo ka -Maskandi no-Isichathamiya, athonywa ngu -Ladysmith Black Mambazo, Phuzekemisi no-Imithente. Dacre, Richard (2015-05-28), &quot;Worth, Harry [real name Harry Bourlon Illingsworth] (1917–1989), comedian&quot;, Oxford Dictionary of National Biography, Oxford University Press, ISBN 978-0-19-861412-8, retrieved 2025-09-04

== IIMVELAPHI YOBUVUMO ==

=== Izithonyo ===
Uthonywe ngu-Maskandi no-Scathamiya.  Bekahlala e-Vaal endaweni ebizwa nge-Palm Springs.

== Ibizelo ==

=== Ukuthoma komsebenzi ===
UZulu wahlala iminyaka eminengi amtjhayeli wetekisi begodu watjhiya ngomnyaka wee-2008 ukobana aragele phambili nomsebenzi wakhe wezomvumo. Ngomnyaka wee-2009, ngemva kobana atjhiye ibubulo lamathekisi wathoma ukutlola iingoma nokudlala.

Ngemva kweminyaka emine ngomnyaka wee-2013, u-Zulu waphalisana begodu waba ngowokuthoma ukuthumba iphalisano le Red Bull Back to the city.  Ingoma yakhe yokuthoma ethi &quot;Donsa Nkabi&quot; yakhutjhwa ngomnyaka wee-2016. 

=== 2014–2019: ''Ushun Wenkabi'', ''Ungqongqoshe Wongqongqoshe'' ===
Ngemva kweminyaka eminengi njengomvumi ozijameleko, watlikitla isivumelwano sokurekhoda ne-Universal Music Records ngomnyaka wee-2015 begodu wakhupha i-albhamu yakhe yokuthoma ''i-Ushun Wenkabi'' ngenyanga ka Velabahlinze ngomnyaka wee-2018, eneengoma ezifaka hlangana &quot;u-Ang'mazi umama&quot; no-&quot;Home&quot;. 

I-albhamu yakhe yesibili ye-studio ''u-Ungqongqoshe Wongqongqoshe'' yakhutjhwa ngomnyaka wee-2019,  ihlanganisa u-Ab Crazy, u-Mnqobi Yazo, u-FiFi Cooper, u-Kwesta, u-Caspper Nyovest, u-Musiholiq no-Truhitz.  Ingoma ephambili ethi &quot;Ak'laleki&quot; eno-Kwesta yakhutjhwa. Mhlana amalanga amabili kuRhoboyi ingoma yakhe yesibili ethi &quot;Ama Million&quot; eno- Cassper Nyovest &amp; Musiholiq yakhutjhwa begodu yafika endaweni yesihlanu ku-iTunes Chart.   Ingoma le beyiqinisekiswe njengeplatinamu.   Mhlana amalanga ali-14 kuRhoboyi, ingoma yakhe yesithathu ethi &quot;Vuma dlozi&quot; ehlanganisa u-Mnqobi Yazo yakhutjhwa  begodu yaqinisekiswa yi-platinamu yibubulo lokurekhoda leSewula Afrika (i-RiSA) ngokuthengisa amakhophi ama-50 000. &lt;ref name=&quot;ubetoo&quot; /&gt; I-albhamu le yaqinisekiswa njengegolide yi-Recording Industry of South Africa (RiSA)  begodu yathola ukukhethwa ku- South African Music Awards (SAMA26)  ye-Best Hip Hop Album.  Ngomnyaka ofanako, wee-2019, i-albhamu leyo yakhethwa njenge-Best Male Artist of the Year kanye ne-albhamu yomnyaka e -South African Hip Hop Awards.  Wasungula ilebula yakhe yamarekhodi i-Nkabi Records. 

=== 2020–2022: ''Ichwane Lenyoka'', ''Nkabi Nation'' ===
Mhlana amalanga ama-20 kuNobayeni ngomnyaka wee- 2020, ingoma yakhe ethi &quot; Mali Eningi &quot; yakhutjhwa ifaka hlangana umvumi ongu Intaba Yase Dubai no-Ricky Rick njengengoma ephambili ye-albhamu. Ingoma le yavela endaweni yesibili kumatjhadi we ''-Channel 0'' Top 30  begodu yaqinisekiswa njenge-double platinum.  Emnyanyeni we -27th annual South African Music Awards,ingoma i  &quot;Mali Eningi&quot; yathumba isigaba sokubambisana okuhle khulu.  Ekupheleni komnyaka wee-2020 wakhethwa kokuthoma ku -MTV Base: SA's Hottest MCs, endaweni yesihlanu. 

Ngasekupheleni kukaTjhirhweni ngomnyaka wee-2021, wamemezela ukusebenza kwe-albhamu yakhe yesithathu.   

Mhlana amalanga ali-11 kuNtaka ngomnyaka wee-2021, wakhupha ingoma &quot;Inhlupheko&quot; enoMduduzi Ncube njengengoma yesibili.  Ingoma le yafika endaweni yokuthoma ematjhadini we-iTunes weSewula Afrika begodu yafika endaweni yesine ematjhadini we-Shazam. 

Mhlana amalanga amathathu kuNtaka ngomnyaka wee-2021, wamemezela ingoma etja ebizwa ngokuthi &quot;Umuzi eSandton&quot; ehlanganisa u-Lwah Ndlunkulu ku -Twitter.  Ingoma le yakhutjhwa mhlana amalanga alithoba kuNtaka ngomnyaka wee-2021;  Yavezwa ku-albhamu yakhe ''i-Ichwane Lenyoka'', eyakhutjhwa mhlana amalanga amathathu kuNobayeni 2021.  Ingoma ethi &quot;Umuzi eSandton&quot; yafika endaweni yokuthoma ematjhadini we-Shazam. 

Mhlana amalanga ali-13 kuNobayeni ngomnyaka wee-2021, wenza isizini yetjhumi nane ku- ''Idols South Africa.''  UZulu uthumbe imitlomelo elikhomba efaka hlangana; I-albhamu yomnyaka, ingoma yomnyaka (&quot; Mali Eningi &quot;), ividiyo yomculo ehle khulu, umvuzo we-Best Male and Ubuntu Activism, Best Collaboration, kanye no-Best Digital Sales kuma -2021 South African Hip Hop Awards.  Ekupheleni komnyaka wee-2021 wakhethwa godu ku-MTV Base: SA's Hottest MCs, wakhuphukela endaweni yesibili. 

I-&quot;iVolovolo&quot; eno Xowla yakhutjhwa mhlana amalanga alitjhumi nanye kuMhlolanja ngomnyaka wee-2022. Ingoma le yathoma ukudlala phambili eSewula Afrika.  

I-&quot;Voicemail&quot; ka-Big Zulu, Mduduzi Ncube, Lwah Ndlunkulu, Siya Ntuli no-Xowla yakhutjhwa njengengoma ephambili ye-albhamu mhlana amalanga ama-24 kuMgwengweni ngonyaka wee-2022.  Ingoma le yaqinisekiswa njengegolide begodu yafika endaweni yokuthoma eSewula Afrika.  

Wakhupha  i-&quot;150 Bars (Ke hip hop Dawg)&quot; mhlana amalanga ama-20 kuRhoboyi ngomnyaka wee-2022. Ingoma le yangena ematjhadini we-Local Top 10 Radio endawen&quot;i yesikhombisa. 

Wamemezela  ilanga lokukhutjhwa kwama-albhamu kanye irhelo lokugcina lwengoma ku-Instagram, ekhutjhwe mhlana amalanga alithoba kuNobayeni ngomnyaka wee-2022. 

&quot;Dear My Love&quot; ehlanganisa u KO, Xowla no-Siya Ntuli ingoma eyodwa ka-Big Zulu ekhutjhwe mhlazi-25 kuNobayeni 2022.

=== 2023-nje: Inkabi Zezwe, ''Ukhamba'', ''Ngises' Congweni'' ===
Mhlana amalanga ali-17 kuNtaka 2023, u-Big Zulu no-Sjava bamemezela ukusebenza nge-albhamu yabo ehlangeneko ''i-Ukhamba'' njenge-duo Inkabi Zezwe . &quot; Umbayimbayi &quot; yakhutjhwa mhlana amalanga ama-24 kuNtaka ngomnyaka wee-2023 njengengoma ephambili ye-albhamu.  Ingoma le yavela kuyingoma yokuthoma ku-iTunes Top 50 kanye ne-Spotify Top 100 South Africa ngokulandelana.  Ingoma le yaqinisekiswa njenge-3× Platinum eSewula Afrika.   

Mhlana kuthoma inyanga kaMrhayili, u-Zulu wamemezela i-Inkabi Zezwe Tour eyathoma ngoMgwengweni bekwaba nguNobayeni ngomnyaka wee-2023.

I-albhamu le yakhutjhwa mhlana amalanga ali-12 kuMrhayili ngomnyaka wee-2023. Yaba yinto yokuthoma emazweni amabili weSewula Afrika ne-Eswatini ngokulandelana. 

Ngasekupheleni kukaTjhirhweni ngomnyaka wee-2024, uZulu wamemezela ukusebenza nge-albhamu yakhe yesine ye-studio kanye ne-albhamu yakhe ephambili &quot;Awufuni Ukung' Qoma&quot;. ''I-Ngises' Congweni'' yakhutjhwa mhlana amalanga ama-27 kuNtaka ngomnyaka wee- 2023.    

=== Umabonakude ===
Ngenyanga kaMgwengweni ngomnyaka wee-2024, uZulu wangenela  umdlalo wokufuna amathalenta ''u-Ushuni Womhlaba'', njengomahluleli  ku-SABC 1 mhlana amalanga alikhomba kuNtaka. 

=== Amanye amabubulo ===
Ngomnyaka wee-2019, uZulu wasungula ilebula yamarekhodi i-Inkabi Records.  UZulu sele asayine uMduduzi Ncube, uLwah Ndlunkulu, uXowla no Siya Ntuli. 

Mhlana amalanga ama-21 kuNobayeni ngomnyaka wee-2021, uZulu wathoma ukusiza abantu abadla imbuya ngelithi begodu wanikela ngemitjhininqondo namaphrinta e-Obonjaneni Primary School. 

Kusukela ngoRhoboyi ngomnyaka wee- 2020, wasebenzisana no Spitz njengomsekeli (ambassador) we-Carvela.  

== I-Discography ==

=== Ama-albhamu we-studio ===

* ''Ushun Wenkabi'' (2018)
* ''Ungqongqoshe Wongqongqoshe'' (2019)
* ''Ichwane Lenyoka'' (2021) 
* ''Ngises' Congweni'' (2024)
* ''Icala Le Mpumelelo'' (2025)

=== Ama-albhamu wokubambisana ===

* ''Inkabi Nation'' (2022)
* ''Ukhamba'' (2023)

=== Njengomdosi phambili kwezomvumo ===
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+Irhelo lama-single njengabaculi abadosa phambili, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;AmaMillion&quot; ene-Musiholiq, Cassper Nyovest
| 2019
|
| Iplatinamu 
| rowspan=&quot;2&quot; | ''Ngqongqoshe Wongqongqoshe''
|-
! scope=&quot;row&quot; | &quot;Vuma Dlozi&quot; ehlanganisa uMnqobi Yazo
| 2020
|
| Iplatinamu &lt;ref name=&quot;DailySUN&quot; /&gt;
|-
! scope=&quot;row&quot; | &quot; Mali Eningi &quot; ehlanganisa u-Ntaba Yase Dubai, u-Ricky Rick
| rowspan=&quot;3&quot; | 2021
| 2
| 2× Iplatinamu
| rowspan=&quot;4&quot; | ''Ichwane Lenyoka''
|-
! scope=&quot;row&quot; | &quot;Umuzi eSandton&quot; nge- Lwah Ndlunkulu
| —
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;Inhlupheko&quot; ehlanganisa uMduduzi Ncube
| 1
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;iVolovolo&quot; ene-Xowla
| 2022
| —
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;Dear My Love&quot; ene-Xowla, KO no -Siya Ntuli
| 2022
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Awufuni Ukung' Qoma&quot;
| rowspan=&quot;3&quot; | 2024
| —
|
| ''UCongweni kaNgises''
|-
! scope=&quot;row&quot; | &quot;200 Bars&quot;
| — 
||{{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ay Ka'Ncane&quot; (Big Zulu, Tony Dayimane)
| — 
||{{non-album single}} 
|-
! scope=&quot;row&quot; | &quot;Amacala Othando&quot; (Big Zulu, Azana, Malungelo)
| rowspan=&quot;2&quot; | 2025
| — 
||{{non-album single}} 
|-
! scope=&quot;row&quot; | &quot;Abazazi Bafunani&quot; (ehlanganisa u-Emtee )
| 2 
|
| Icala Le Mpumelelo
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; | &quot;—&quot; kutjho ukurekhoda okungazange kushadi namkha okungakakhutjhwa endaweni leyo.
|}
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center&quot;
|+Irhelo lazingoma azihlanganyele nabanye njengabaculi abaveziweko, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;Isigingci&quot; (Mduduzi ehlanganisa uBig Zulu)
| 2020
| —
|
| ''Isitimela''
|-
! scope=&quot;row&quot; | &quot;Alusafani&quot; ( Qwabe Twins featuring Big Zulu, Mduduzi, Xowla)
| rowspan=&quot;2&quot; | 2021
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Qoma&quot; ( Blaq Diamond nge-Siya Ntuli, Big Zulu)
| —
| I-RiSA: Iplatinamu 
| Ithando lesiZulu
|-
! scope=&quot;row&quot; | &quot;Amalobolo&quot; ( u-Nomfundo Moh ohlanganisa u-Big Zulu)
| 2023
| —
|
| ''Ugcobo''
|-
! scope=&quot;row&quot; | &quot;Beng' dakiwe (u-Xowla ahlanganisa u-Big Zulu, u-DJ Tira )
| rowspan=&quot;2&quot; | 2023
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;My Ex&quot; (Big Xhosa featuring Big Zulu)
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Mfazi Wephepha&quot; (Nkosazana Daughter, Master Kg featuring Big Zulu, Zee Nxumalo )
| 2024
| 4 
|
| ''Makhelwane''
|}

== Imitlomelo nokuphakanyiswa ==
{| class=&quot;wikitable&quot;
!Umnyaka
! Umtlomelo
! Umkhakha
! Imiphumela
! Ref.
|-
| rowspan=&quot;3&quot; | 2019
| rowspan=&quot;2&quot; | SAHHA
| I-albhamu yomnyaka| {{nom}}
| rowspan=&quot;2&quot; |  
|-
| Umdwebi wesilisa ophuma phambili womnyaka|{{nom}}
|-
| I-SAMA 26
| I-albhamu ye-Hip Hop ehle khulu| {{nom}}
|  
|-
| 2020
| SAHHA
| I-Remix ehle khulu| {{Nom}}
| 
|-
| 2021
| I-SAMA 27
| Ukusebenzisana okuhle khulu|{{won}}
|  
|-
| rowspan=&quot;8&quot; | 2021
| rowspan=&quot;8&quot; | I-SAHHA 10
| I-albhamu yomnyaka|{{won}}
| rowspan=&quot;8&quot; |  
|-
| Owesilisa ophuma phambili|{{won}}
|-
| Ingoma yomnyaka|{{won}}
|-
| Ukusebenzisana okuhle khulu|{{won}}
|-
| I-MVP/Umtjhayeli womnyaka|{{nom}}
|-
| Ividiyo ehle khulu|{{won}}
|-
| Umvuzo we-Ubuntu Activism|{{won}}
|-
| Ukuthengisa okuhle khulu kwedijithali|{{won}}
|-
| rowspan=&quot;2&quot; | 2022
| rowspan=&quot;2&quot; | DStv MVCA
| Ingoma engiyithandako| {{nom}}
| rowspan=&quot;2&quot; | 
|-
| Umculi womculo othandwako/isiqhema|{{nom}}
|-
| 2023
| 17th Metro FM Music Awards
| I-Duo/Isiqhema esihle khulu |{{Won}} 
|
|}

== UMTHOMBO LWAZI ==
&lt;references responsive=&quot;&quot; /&gt;</text>
      <sha1>51ggx9dkg3133j1b1e2x3e16aybpfs5</sha1>
    </revision>
    <revision>
      <id>5595</id>
      <parentid>5591</parentid>
      <timestamp>2025-09-04T10:09:03Z</timestamp>
      <contributor>
        <username>Kholeka19721</username>
        <id>889</id>
      </contributor>
      <minor />
      <comment>added a second link</comment>
      <origin>5595</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="13648" sha1="ft7isusq1mru1d8lfw2yb4rbfrla2av" xml:space="preserve">
'''BIG ZULU'''                         
[[Isimumathi:Big zulu.jpg|left|thumb|BIG ZULU]]
'''IMINININGWANA YANGEMUVA'''

'''IBIZO:'''  Siyabonga Nene

'''UKUBELETHWA:'''  7 KuSihlabantangana 1986

'''UMSEBENZI:''' Umrepha, umtloli weengoma

'''UNYAKA WOKUDUMA:''' 2003- njenganje

'''AMALEBULA:''' Universal Records(kwangaphambilini), Nkabi Records.

'''USiyabonga Nene''' (wabelethwa mhlana amalanga alikhomba, kuMrhayili ngomnyaka we-1986  )&lt;ref&gt;{{Cite web |last=Mag |first=SA Hip Hop |date=2021-04-07 |title=Happy Birthday Big Zulu! A Look Into Big Zulu's Best Selling Records |url=https://sahiphopmag.co.za/2021/04/happy-birthday-big-zulu-a-look-into-big-zulus-best-selling-records/ |access-date=2025-09-04 |website=SA Hip Hop Mag |language=en-US}}&lt;/ref&gt;&lt;ref&gt;{{Citation |last=Ladson-Billings |first=Gloria |title=From Big Homie the O.G., to GLB |date=2018-03-23 |work=#HipHopEd: The Compilation on Hip-hop Education |pages=21–26 |url=https://doi.org/10.1163/9789004371873_003 |access-date=2025-09-04 |publisher=BRILL |isbn=978-90-04-37187-3}}&lt;/ref&gt;
, owaziwa ngebizo elibizwa laka '''Big Zulu''', mrepha nomtloli weengoma we[[Isewula Afrika|Sewula Afrika]].  Waphakama ngemva kokukhipha ingoma ethi &quot;Donsa NkaDobi&quot; ngomnyaka wee-2016.

Watlikitla isivumelwano sokurekhoda ne -Universal Music ngomnyaka wee- 2015 begodu  wakhipha i-albhamu yakhe yokuthoma, ''u-Ushun Wenkabi'' (2018) no ''-Ungqongqoshe Wongqongqoshe'' (2019).

I-albhamu yesithathu ka Big Zulu ''Ichwane Lenyoka'' (2021), yakhiqiza ama-single amathathu aphuma phambili &quot; Mali Eningi &quot;, &quot;Inhlupheko&quot; kanye no-&quot;Umuzi eSandton&quot;. Ingoma yayo ephambili &quot;i-Mali Eningi&quot;, yaqinisekiswa yi-double platinum yi- Recording Industry of South Africa (RiSA). 

[[Big Zulu|UBig Zulu]] wabuye wavela emidlalweni kamabonakude ''i-Isibaya'', ''One Mic'' (2017-2020),  ''Uzalo'' (2020), ''Isithembiso'', kanye ''no-Ushuni Womhlaba'' (2024).  Imitlomelo  yakhe ifaka hlangana imitlomelo  ye-Hip Hop yeSewula Afrika elikhomba, umtlomelo  owodwa we-South African Music Award kanye ne-Metro FM Music Awards eyodwa.

== Ipilo yokuthoma ==
USiyabonga Nene wabelethwa begodu wakhulela e -Bergville, KwaZulu-Natal. Wakhula alalele umvumo ka -Maskandi no-Isichathamiya, athonywa ngu -Ladysmith Black Mambazo, Phuzekemisi no-Imithente. Dacre, Richard (2015-05-28), &quot;Worth, Harry [real name Harry Bourlon Illingsworth] (1917–1989), comedian&quot;, Oxford Dictionary of National Biography, Oxford University Press, ISBN 978-0-19-861412-8, retrieved 2025-09-04

== IIMVELAPHI YOBUVUMO ==

=== Izithonyo ===
Uthonywe ngu-Maskandi no-Scathamiya.  Bekahlala e-Vaal endaweni ebizwa nge-Palm Springs.

== Ibizelo ==

=== Ukuthoma komsebenzi ===
UZulu wahlala iminyaka eminengi amtjhayeli wetekisi begodu watjhiya ngomnyaka wee-2008 ukobana aragele phambili nomsebenzi wakhe wezomvumo. Ngomnyaka wee-2009, ngemva kobana atjhiye ibubulo lamathekisi wathoma ukutlola iingoma nokudlala.

Ngemva kweminyaka emine ngomnyaka wee-2013, u-Zulu waphalisana begodu waba ngowokuthoma ukuthumba iphalisano le Red Bull Back to the city.  Ingoma yakhe yokuthoma ethi &quot;Donsa Nkabi&quot; yakhutjhwa ngomnyaka wee-2016. 

=== 2014–2019: ''Ushun Wenkabi'', ''Ungqongqoshe Wongqongqoshe'' ===
Ngemva kweminyaka eminengi njengomvumi ozijameleko, watlikitla isivumelwano sokurekhoda ne-Universal Music Records ngomnyaka wee-2015 begodu wakhupha i-albhamu yakhe yokuthoma ''i-Ushun Wenkabi'' ngenyanga ka Velabahlinze ngomnyaka wee-2018, eneengoma ezifaka hlangana &quot;u-Ang'mazi umama&quot; no-&quot;Home&quot;. 

I-albhamu yakhe yesibili ye-studio ''u-Ungqongqoshe Wongqongqoshe'' yakhutjhwa ngomnyaka wee-2019,  ihlanganisa u-Ab Crazy, u-Mnqobi Yazo, u-FiFi Cooper, u-Kwesta, no [[Cassper Nyovest|Caspper Nyovest]], u-Musiholiq no-Truhitz.  Ingoma ephambili ethi &quot;Ak'laleki&quot; eno-Kwesta yakhutjhwa. Mhlana amalanga amabili kuRhoboyi ingoma yakhe yesibili ethi &quot;Ama Million&quot; eno- Cassper Nyovest &amp; Musiholiq yakhutjhwa begodu yafika endaweni yesihlanu ku-iTunes Chart.   Ingoma le beyiqinisekiswe njengeplatinamu.   Mhlana amalanga ali-14 kuRhoboyi, ingoma yakhe yesithathu ethi &quot;Vuma dlozi&quot; ehlanganisa u-Mnqobi Yazo yakhutjhwa  begodu yaqinisekiswa yi-platinamu yibubulo lokurekhoda leSewula Afrika (i-RiSA) ngokuthengisa amakhophi ama-50 000. &lt;ref name=&quot;ubetoo&quot; /&gt; I-albhamu le yaqinisekiswa njengegolide yi-Recording Industry of South Africa (RiSA)  begodu yathola ukukhethwa ku- South African Music Awards (SAMA26)  ye-Best Hip Hop Album.  Ngomnyaka ofanako, wee-2019, i-albhamu leyo yakhethwa njenge-Best Male Artist of the Year kanye ne-albhamu yomnyaka e -South African Hip Hop Awards.  Wasungula ilebula yakhe yamarekhodi i-Nkabi Records. 

=== 2020–2022: ''Ichwane Lenyoka'', ''Nkabi Nation'' ===
Mhlana amalanga ama-20 kuNobayeni ngomnyaka wee- 2020, ingoma yakhe ethi &quot; Mali Eningi &quot; yakhutjhwa ifaka hlangana umvumi ongu Intaba Yase Dubai no-Ricky Rick njengengoma ephambili ye-albhamu. Ingoma le yavela endaweni yesibili kumatjhadi we ''-Channel 0'' Top 30  begodu yaqinisekiswa njenge-double platinum.  Emnyanyeni we -27th annual South African Music Awards,ingoma i  &quot;Mali Eningi&quot; yathumba isigaba sokubambisana okuhle khulu.  Ekupheleni komnyaka wee-2020 wakhethwa kokuthoma ku -MTV Base: SA's Hottest MCs, endaweni yesihlanu. 

Ngasekupheleni kukaTjhirhweni ngomnyaka wee-2021, wamemezela ukusebenza kwe-albhamu yakhe yesithathu.   

Mhlana amalanga ali-11 kuNtaka ngomnyaka wee-2021, wakhupha ingoma &quot;Inhlupheko&quot; enoMduduzi Ncube njengengoma yesibili.  Ingoma le yafika endaweni yokuthoma ematjhadini we-iTunes weSewula Afrika begodu yafika endaweni yesine ematjhadini we-Shazam. 

Mhlana amalanga amathathu kuNtaka ngomnyaka wee-2021, wamemezela ingoma etja ebizwa ngokuthi &quot;Umuzi eSandton&quot; ehlanganisa u-Lwah Ndlunkulu ku -Twitter.  Ingoma le yakhutjhwa mhlana amalanga alithoba kuNtaka ngomnyaka wee-2021;  Yavezwa ku-albhamu yakhe ''i-Ichwane Lenyoka'', eyakhutjhwa mhlana amalanga amathathu kuNobayeni 2021.  Ingoma ethi &quot;Umuzi eSandton&quot; yafika endaweni yokuthoma ematjhadini we-Shazam. 

Mhlana amalanga ali-13 kuNobayeni ngomnyaka wee-2021, wenza isizini yetjhumi nane ku- ''Idols South Africa.''  UZulu uthumbe imitlomelo elikhomba efaka hlangana; I-albhamu yomnyaka, ingoma yomnyaka (&quot; Mali Eningi &quot;), ividiyo yomculo ehle khulu, umvuzo we-Best Male and Ubuntu Activism, Best Collaboration, kanye no-Best Digital Sales kuma -2021 South African Hip Hop Awards.  Ekupheleni komnyaka wee-2021 wakhethwa godu ku-MTV Base: SA's Hottest MCs, wakhuphukela endaweni yesibili. 

I-&quot;iVolovolo&quot; eno Xowla yakhutjhwa mhlana amalanga alitjhumi nanye kuMhlolanja ngomnyaka wee-2022. Ingoma le yathoma ukudlala phambili eSewula Afrika.  

I-&quot;Voicemail&quot; ka-Big Zulu, Mduduzi Ncube, Lwah Ndlunkulu, Siya Ntuli no-Xowla yakhutjhwa njengengoma ephambili ye-albhamu mhlana amalanga ama-24 kuMgwengweni ngonyaka wee-2022.  Ingoma le yaqinisekiswa njengegolide begodu yafika endaweni yokuthoma eSewula Afrika.  

Wakhupha  i-&quot;150 Bars (Ke hip hop Dawg)&quot; mhlana amalanga ama-20 kuRhoboyi ngomnyaka wee-2022. Ingoma le yangena ematjhadini we-Local Top 10 Radio endawen&quot;i yesikhombisa. 

Wamemezela  ilanga lokukhutjhwa kwama-albhamu kanye irhelo lokugcina lwengoma ku-Instagram, ekhutjhwe mhlana amalanga alithoba kuNobayeni ngomnyaka wee-2022. 

&quot;Dear My Love&quot; ehlanganisa u KO, Xowla no-Siya Ntuli ingoma eyodwa ka-Big Zulu ekhutjhwe mhlazi-25 kuNobayeni 2022.

=== 2023-nje: Inkabi Zezwe, ''Ukhamba'', ''Ngises' Congweni'' ===
Mhlana amalanga ali-17 kuNtaka 2023, u-Big Zulu no-Sjava bamemezela ukusebenza nge-albhamu yabo ehlangeneko ''i-Ukhamba'' njenge-duo Inkabi Zezwe . &quot; Umbayimbayi &quot; yakhutjhwa mhlana amalanga ama-24 kuNtaka ngomnyaka wee-2023 njengengoma ephambili ye-albhamu.  Ingoma le yavela kuyingoma yokuthoma ku-iTunes Top 50 kanye ne-Spotify Top 100 South Africa ngokulandelana.  Ingoma le yaqinisekiswa njenge-3× Platinum eSewula Afrika.   

Mhlana kuthoma inyanga kaMrhayili, u-Zulu wamemezela i-Inkabi Zezwe Tour eyathoma ngoMgwengweni bekwaba nguNobayeni ngomnyaka wee-2023.

I-albhamu le yakhutjhwa mhlana amalanga ali-12 kuMrhayili ngomnyaka wee-2023. Yaba yinto yokuthoma emazweni amabili weSewula Afrika ne-Eswatini ngokulandelana. 

Ngasekupheleni kukaTjhirhweni ngomnyaka wee-2024, uZulu wamemezela ukusebenza nge-albhamu yakhe yesine ye-studio kanye ne-albhamu yakhe ephambili &quot;Awufuni Ukung' Qoma&quot;. ''I-Ngises' Congweni'' yakhutjhwa mhlana amalanga ama-27 kuNtaka ngomnyaka wee- 2023.    

=== Umabonakude ===
Ngenyanga kaMgwengweni ngomnyaka wee-2024, uZulu wangenela  umdlalo wokufuna amathalenta ''u-Ushuni Womhlaba'', njengomahluleli  ku-SABC 1 mhlana amalanga alikhomba kuNtaka. 

=== Amanye amabubulo ===
Ngomnyaka wee-2019, uZulu wasungula ilebula yamarekhodi i-Inkabi Records.  UZulu sele asayine uMduduzi Ncube, uLwah Ndlunkulu, uXowla no Siya Ntuli. 

Mhlana amalanga ama-21 kuNobayeni ngomnyaka wee-2021, uZulu wathoma ukusiza abantu abadla imbuya ngelithi begodu wanikela ngemitjhininqondo namaphrinta e-Obonjaneni Primary School. 

Kusukela ngoRhoboyi ngomnyaka wee- 2020, wasebenzisana no Spitz njengomsekeli (ambassador) we-Carvela.  

== I-Discography ==

=== Ama-albhamu we-studio ===

* ''Ushun Wenkabi'' (2018)
* ''Ungqongqoshe Wongqongqoshe'' (2019)
* ''Ichwane Lenyoka'' (2021) 
* ''Ngises' Congweni'' (2024)
* ''Icala Le Mpumelelo'' (2025)

=== Ama-albhamu wokubambisana ===

* ''Inkabi Nation'' (2022)
* ''Ukhamba'' (2023)

=== Njengomdosi phambili kwezomvumo ===
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+Irhelo lama-single njengabaculi abadosa phambili, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;AmaMillion&quot; ene-Musiholiq, Cassper Nyovest
| 2019
|
| Iplatinamu 
| rowspan=&quot;2&quot; | ''Ngqongqoshe Wongqongqoshe''
|-
! scope=&quot;row&quot; | &quot;Vuma Dlozi&quot; ehlanganisa uMnqobi Yazo
| 2020
|
| Iplatinamu &lt;ref name=&quot;DailySUN&quot; /&gt;
|-
! scope=&quot;row&quot; | &quot; Mali Eningi &quot; ehlanganisa u-Ntaba Yase Dubai, u-Ricky Rick
| rowspan=&quot;3&quot; | 2021
| 2
| 2× Iplatinamu
| rowspan=&quot;4&quot; | ''Ichwane Lenyoka''
|-
! scope=&quot;row&quot; | &quot;Umuzi eSandton&quot; nge- Lwah Ndlunkulu
| —
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;Inhlupheko&quot; ehlanganisa uMduduzi Ncube
| 1
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;iVolovolo&quot; ene-Xowla
| 2022
| —
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;Dear My Love&quot; ene-Xowla, KO no -Siya Ntuli
| 2022
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Awufuni Ukung' Qoma&quot;
| rowspan=&quot;3&quot; | 2024
| —
|
| ''UCongweni kaNgises''
|-
! scope=&quot;row&quot; | &quot;200 Bars&quot;
| — 
||{{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ay Ka'Ncane&quot; (Big Zulu, Tony Dayimane)
| — 
||{{non-album single}} 
|-
! scope=&quot;row&quot; | &quot;Amacala Othando&quot; (Big Zulu, Azana, Malungelo)
| rowspan=&quot;2&quot; | 2025
| — 
||{{non-album single}} 
|-
! scope=&quot;row&quot; | &quot;Abazazi Bafunani&quot; (ehlanganisa u-Emtee )
| 2 
|
| Icala Le Mpumelelo
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; | &quot;—&quot; kutjho ukurekhoda okungazange kushadi namkha okungakakhutjhwa endaweni leyo.
|}
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center&quot;
|+Irhelo lazingoma azihlanganyele nabanye njengabaculi abaveziweko, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;Isigingci&quot; (Mduduzi ehlanganisa uBig Zulu)
| 2020
| —
|
| ''Isitimela''
|-
! scope=&quot;row&quot; | &quot;Alusafani&quot; ( Qwabe Twins featuring Big Zulu, Mduduzi, Xowla)
| rowspan=&quot;2&quot; | 2021
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Qoma&quot; ( Blaq Diamond nge-Siya Ntuli, Big Zulu)
| —
| I-RiSA: Iplatinamu 
| Ithando lesiZulu
|-
! scope=&quot;row&quot; | &quot;Amalobolo&quot; ( u-Nomfundo Moh ohlanganisa u-Big Zulu)
| 2023
| —
|
| ''Ugcobo''
|-
! scope=&quot;row&quot; | &quot;Beng' dakiwe (u-Xowla ahlanganisa u-Big Zulu, u-DJ Tira )
| rowspan=&quot;2&quot; | 2023
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;My Ex&quot; (Big Xhosa featuring Big Zulu)
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Mfazi Wephepha&quot; (Nkosazana Daughter, Master Kg featuring Big Zulu, Zee Nxumalo )
| 2024
| 4 
|
| ''Makhelwane''
|}

== Imitlomelo nokuphakanyiswa ==
{| class=&quot;wikitable&quot;
!Umnyaka
! Umtlomelo
! Umkhakha
! Imiphumela
! Ref.
|-
| rowspan=&quot;3&quot; | 2019
| rowspan=&quot;2&quot; | SAHHA
| I-albhamu yomnyaka| {{nom}}
| rowspan=&quot;2&quot; |  
|-
| Umdwebi wesilisa ophuma phambili womnyaka|{{nom}}
|-
| I-SAMA 26
| I-albhamu ye-Hip Hop ehle khulu| {{nom}}
|  
|-
| 2020
| SAHHA
| I-Remix ehle khulu| {{Nom}}
| 
|-
| 2021
| I-SAMA 27
| Ukusebenzisana okuhle khulu|{{won}}
|  
|-
| rowspan=&quot;8&quot; | 2021
| rowspan=&quot;8&quot; | I-SAHHA 10
| I-albhamu yomnyaka|{{won}}
| rowspan=&quot;8&quot; |  
|-
| Owesilisa ophuma phambili|{{won}}
|-
| Ingoma yomnyaka|{{won}}
|-
| Ukusebenzisana okuhle khulu|{{won}}
|-
| I-MVP/Umtjhayeli womnyaka|{{nom}}
|-
| Ividiyo ehle khulu|{{won}}
|-
| Umvuzo we-Ubuntu Activism|{{won}}
|-
| Ukuthengisa okuhle khulu kwedijithali|{{won}}
|-
| rowspan=&quot;2&quot; | 2022
| rowspan=&quot;2&quot; | DStv MVCA
| Ingoma engiyithandako| {{nom}}
| rowspan=&quot;2&quot; | 
|-
| Umculi womculo othandwako/isiqhema|{{nom}}
|-
| 2023
| 17th Metro FM Music Awards
| I-Duo/Isiqhema esihle khulu |{{Won}} 
|
|}

== UMTHOMBO LWAZI ==
&lt;references responsive=&quot;&quot; /&gt;</text>
      <sha1>ft7isusq1mru1d8lfw2yb4rbfrla2av</sha1>
    </revision>
    <revision>
      <id>5599</id>
      <parentid>5595</parentid>
      <timestamp>2025-09-04T10:15:59Z</timestamp>
      <contributor>
        <username>Kholeka19721</username>
        <id>889</id>
      </contributor>
      <minor />
      <origin>5599</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="13656" sha1="j10u82mst53zkye9gz1tqec0v4jq15f" xml:space="preserve">
'''BIG ZULU'''                         
[[Isimumathi:Big zulu.jpg|left|thumb|BIG ZULU]]
'''IMINININGWANA YANGEMUVA'''

'''IBIZO:'''  Siyabonga Nene

'''UKUBELETHWA:'''  7 KuSihlabantangana 1986

'''UMSEBENZI:''' Umrepha, umtloli weengoma

'''UNYAKA WOKUDUMA:''' 2003- njenganje

'''AMALEBULA:''' Universal Records(kwangaphambilini), Nkabi Records.

'''USiyabonga Nene''' (wabelethwa mhlana amalanga alikhomba, kuMrhayili ngomnyaka we-1986  )&lt;ref&gt;{{Cite web |last=Mag |first=SA Hip Hop |date=2021-04-07 |title=Happy Birthday Big Zulu! A Look Into Big Zulu's Best Selling Records |url=https://sahiphopmag.co.za/2021/04/happy-birthday-big-zulu-a-look-into-big-zulus-best-selling-records/ |access-date=2025-09-04 |website=SA Hip Hop Mag |language=en-US}}&lt;/ref&gt;&lt;ref&gt;{{Citation |last=Ladson-Billings |first=Gloria |title=From Big Homie the O.G., to GLB |date=2018-03-23 |work=#HipHopEd: The Compilation on Hip-hop Education |pages=21–26 |url=https://doi.org/10.1163/9789004371873_003 |access-date=2025-09-04 |publisher=BRILL |isbn=978-90-04-37187-3}}&lt;/ref&gt;
, owaziwa ngebizo elibizwa laka '''Big Zulu''', mrepha nomtloli weengoma we[[Isewula Afrika|Sewula Afrika]].  Waphakama ngemva kokukhipha ingoma ethi &quot;Donsa NkaDobi&quot; ngomnyaka wee-2016.

Watlikitla isivumelwano sokurekhoda ne -Universal Music ngomnyaka wee- 2015 begodu  wakhipha i-albhamu yakhe yokuthoma, ''u-Ushun Wenkabi'' (2018) no ''-Ungqongqoshe Wongqongqoshe'' (2019).

I-albhamu yesithathu ka Big Zulu ''Ichwane Lenyoka'' (2021), yakhiqiza ama-single amathathu aphuma phambili &quot; Mali Eningi &quot;, &quot;Inhlupheko&quot; kanye no-&quot;Umuzi eSandton&quot;. Ingoma yayo ephambili &quot;i-Mali Eningi&quot;, yaqinisekiswa yi-double platinum yi- Recording Industry of South Africa (RiSA). 

[[Big Zulu|UBig Zulu]] wabuye wavela emidlalweni kamabonakude ''i-Isibaya'', ''One Mic'' (2017-2020),  ''Uzalo'' (2020), ''Isithembiso'', kanye ''no-Ushuni Womhlaba'' (2024).  Imitlomelo  yakhe ifaka hlangana imitlomelo  ye-Hip Hop yeSewula Afrika elikhomba, umtlomelo  owodwa we-South African Music Award kanye ne-Metro FM Music Awards eyodwa.

== Ipilo yokuthoma ==
USiyabonga Nene wabelethwa begodu wakhulela e -Bergville, KwaZulu-Natal. Wakhula alalele umvumo ka -Maskandi no-Isichathamiya, athonywa ngu -Ladysmith Black Mambazo, Phuzekemisi no-Imithente. Dacre, Richard (2015-05-28), &quot;Worth, Harry [real name Harry Bourlon Illingsworth] (1917–1989), comedian&quot;, Oxford Dictionary of National Biography, Oxford University Press, ISBN 978-0-19-861412-8, retrieved 2025-09-04

== IIMVELAPHI YOBUVUMO ==

=== Izithonyo ===
Uthonywe ngu-Maskandi no-Scathamiya.  Bekahlala e-Vaal endaweni ebizwa nge-Palm Springs.

== Ibizelo ==

=== Ukuthoma komsebenzi ===
UZulu wahlala iminyaka eminengi amtjhayeli wetekisi begodu watjhiya ngomnyaka wee-2008 ukobana aragele phambili nomsebenzi wakhe wezomvumo. Ngomnyaka wee-2009, ngemva kobana atjhiye ibubulo lamathekisi wathoma ukutlola iingoma nokudlala.

Ngemva kweminyaka emine ngomnyaka wee-2013, u-Zulu waphalisana begodu waba ngowokuthoma ukuthumba iphalisano le Red Bull Back to the city.  Ingoma yakhe yokuthoma ethi &quot;Donsa Nkabi&quot; yakhutjhwa ngomnyaka wee-2016. 

=== 2014–2019: ''Ushun Wenkabi'', ''Ungqongqoshe Wongqongqoshe'' ===
Ngemva kweminyaka eminengi njengomvumi ozijameleko, watlikitla isivumelwano sokurekhoda ne-Universal Music Records ngomnyaka wee-2015 begodu wakhupha i-albhamu yakhe yokuthoma ''i-Ushun Wenkabi'' ngenyanga ka Velabahlinze ngomnyaka wee-2018, eneengoma ezifaka hlangana &quot;u-Ang'mazi umama&quot; no-&quot;Home&quot;. 

I-albhamu yakhe yesibili ye-studio ''u-Ungqongqoshe Wongqongqoshe'' yakhutjhwa ngomnyaka wee-2019,  ihlanganisa u-Ab Crazy, u-Mnqobi Yazo, u-FiFi Cooper, u-Kwesta, no [[Cassper Nyovest|Caspper Nyovest]], u-Musiholiq no-Truhitz.  Ingoma ephambili ethi &quot;Ak'laleki&quot; eno-Kwesta yakhutjhwa. Mhlana amalanga amabili kuRhoboyi ingoma yakhe yesibili ethi &quot;Ama Million&quot; eno- Cassper Nyovest &amp; Musiholiq yakhutjhwa begodu yafika endaweni yesihlanu ku-iTunes Chart.   Ingoma le beyiqinisekiswe njengeplatinamu.   Mhlana amalanga ali-14 kuRhoboyi, ingoma yakhe yesithathu ethi &quot;Vuma dlozi&quot; ehlanganisa u-Mnqobi Yazo yakhutjhwa  begodu yaqinisekiswa yi-platinamu yibubulo lokurekhoda leSewula Afrika (i-RiSA) ngokuthengisa amakhophi ama-50 000. &lt;ref name=&quot;ubetoo&quot; /&gt; I-albhamu le yaqinisekiswa njengegolide yi-Recording Industry of South Africa (RiSA)  begodu yathola ukukhethwa ku- South African Music Awards (SAMA26)  ye-Best Hip Hop Album.  Ngomnyaka ofanako, wee-2019, i-albhamu leyo yakhethwa njenge-Best Male Artist of the Year kanye ne-albhamu yomnyaka e -South African Hip Hop Awards.  Wasungula ilebula yakhe yamarekhodi i-Nkabi Records. 

=== 2020–2022: ''Ichwane Lenyoka'', ''Nkabi Nation'' ===
Mhlana amalanga ama-20 kuNobayeni ngomnyaka wee- 2020, ingoma yakhe ethi &quot; Mali Eningi &quot; yakhutjhwa ifaka hlangana umvumi ongu Intaba Yase Dubai no-Ricky Rick njengengoma ephambili ye-albhamu. Ingoma le yavela endaweni yesibili kumatjhadi we ''-Channel 0'' Top 30  begodu yaqinisekiswa njenge-double platinum.  Emnyanyeni we -27th annual South African Music Awards,ingoma i  &quot;Mali Eningi&quot; yathumba isigaba sokubambisana okuhle khulu.  Ekupheleni komnyaka wee-2020 wakhethwa kokuthoma ku -MTV Base: SA's Hottest MCs, endaweni yesihlanu. 

Ngasekupheleni kukaTjhirhweni ngomnyaka wee-2021, wamemezela ukusebenza kwe-albhamu yakhe yesithathu.   

Mhlana amalanga ali-11 kuNtaka ngomnyaka wee-2021, wakhupha ingoma &quot;Inhlupheko&quot; eno Mduduzi Ncube njengengoma yesibili.  Ingoma le yafika endaweni yokuthoma ematjhadini we-iTunes weSewula Afrika begodu yafika endaweni yesine ematjhadini we-Shazam. 

Mhlana amalanga amathathu kuNtaka ngomnyaka wee-2021, wamemezela ingoma etja ebizwa ngokuthi &quot;Umuzi eSandton&quot; ehlanganisa u-Lwah Ndlunkulu ku -Twitter.  Ingoma le yakhutjhwa mhlana amalanga alithoba kuNtaka ngomnyaka wee-2021;  Yavezwa ku-albhamu yakhe ''i-Ichwane Lenyoka'', eyakhutjhwa mhlana amalanga amathathu kuNobayeni 2021.  Ingoma ethi &quot;Umuzi eSandton&quot; yafika endaweni yokuthoma ematjhadini we-Shazam. 

Mhlana amalanga ali-13 kuNobayeni ngomnyaka wee-2021, wenza isizini yetjhumi nane ku- ''Idols South Africa.''  UZulu uthumbe imitlomelo elikhomba efaka hlangana; I-albhamu yomnyaka, ingoma yomnyaka (&quot; Mali Eningi &quot;), ividiyo yomculo ehle khulu, umvuzo we-Best Male and Ubuntu Activism, Best Collaboration, kanye no-Best Digital Sales kuma -2021 South African Hip Hop Awards.  Ekupheleni komnyaka wee-2021 wakhethwa godu ku-MTV Base: SA's Hottest MCs, wakhuphukela endaweni yesibili. 

I-&quot;iVolovolo&quot; eno Xowla yakhutjhwa mhlana amalanga alitjhumi nanye kuMhlolanja ngomnyaka wee-2022. Ingoma le yathoma ukudlala phambili eSewula Afrika.  

I-&quot;Voicemail&quot; ka-Big Zulu, Mduduzi Ncube, Lwah Ndlunkulu, Siya Ntuli no-Xowla yakhutjhwa njengengoma ephambili ye-albhamu mhlana amalanga ama-24 kuMgwengweni ngonyaka wee-2022.  Ingoma le yaqinisekiswa njengegolide begodu yafika endaweni yokuthoma eSewula Afrika.  

Wakhupha  i-&quot;150 Bars (Ke hip hop Dawg)&quot; mhlana amalanga ama-20 kuRhoboyi ngomnyaka wee-2022. Ingoma le yangena ematjhadini we-Local Top 10 Radio endawen&quot;i yesikhombisa. 

Wamemezela  ilanga lokukhutjhwa kwama-albhamu kanye irhelo lokugcina lwengoma ku-Instagram, ekhutjhwe mhlana amalanga alithoba kuNobayeni ngomnyaka wee-2022. 

&quot;Dear My Love&quot; ehlanganisa u KO, Xowla no-Siya Ntuli ingoma eyodwa ka-Big Zulu ekhutjhwe mhlazi-25 kuNobayeni 2022.

=== 2023-nje: Inkabi Zezwe, ''Ukhamba'', ''Ngises' Congweni'' ===
Mhlana amalanga ali-17 kuNtaka 2023, u-Big Zulu no-Sjava bamemezela ukusebenza nge-albhamu yabo ehlangeneko ''i-Ukhamba'' njenge-duo Inkabi Zezwe . &quot; Umbayimbayi &quot; yakhutjhwa mhlana amalanga ama-24 kuNtaka ngomnyaka wee-2023 njengengoma ephambili ye-albhamu.  Ingoma le yavela kuyingoma yokuthoma ku-iTunes Top 50 kanye ne-Spotify Top 100 South Africa ngokulandelana.  Ingoma le yaqinisekiswa njenge-3× Platinum eSewula Afrika.   

Mhlana kuthoma inyanga kaMrhayili, u-Zulu wamemezela i-Inkabi Zezwe Tour eyathoma ngoMgwengweni bekwaba nguNobayeni ngomnyaka wee-2023.

I-albhamu le yakhutjhwa mhlana amalanga ali-12 kuMrhayili ngomnyaka wee-2023. Yaba yinto yokuthoma emazweni amabili weSewula Afrika ne-Eswatini ngokulandelana. 

Ngasekupheleni kukaTjhirhweni ngomnyaka wee-2024, uZulu wamemezela ukusebenza nge-albhamu yakhe yesine ye-studio kanye ne-albhamu yakhe ephambili &quot;Awufuni Ukung' Qoma&quot;. ''I-Ngises' Congweni'' yakhutjhwa mhlana amalanga ama-27 kuNtaka ngomnyaka wee- 2023.    

=== Umabonakude ===
Ngenyanga kaMgwengweni ngomnyaka wee-2024, uZulu wangenela  umdlalo wokufuna amathalenta ''u-Ushuni Womhlaba'', njengomahluleli  ku-SABC 1 mhlana amalanga alikhomba kuNtaka. 

=== Amanye amabubulo ===
Ngomnyaka wee-2019, uZulu wasungula ilebula yamarekhodi i-Inkabi Records.  UZulu sele asayine uMduduzi Ncube, uLwah Ndlunkulu, uXowla no Siya Ntuli. 

Mhlana amalanga ama-21 kuNobayeni ngomnyaka wee-2021, uZulu wathoma ukusiza abantu abadla imbuya ngelithi begodu wanikela ngemitjhininqondo namaphrinta e-Obonjaneni Primary School. 

Kusukela ngoRhoboyi ngomnyaka wee- 2020, wasebenzisana nestolo i Spitz njengomsekeli (ambassador) we-Carvela.  

== I-Discography ==

=== Ama-albhamu we-studio ===

* ''Ushun Wenkabi'' (2018)
* ''Ungqongqoshe Wongqongqoshe'' (2019)
* ''Ichwane Lenyoka'' (2021) 
* ''Ngises' Congweni'' (2024)
* ''Icala Le Mpumelelo'' (2025)

=== Ama-albhamu wokubambisana ===

* ''Inkabi Nation'' (2022)
* ''Ukhamba'' (2023)

=== Njengomdosi phambili kwezomvumo ===
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+Irhelo lama-single njengabaculi abadosa phambili, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;AmaMillion&quot; ene-Musiholiq, Cassper Nyovest
| 2019
|
| Iplatinamu 
| rowspan=&quot;2&quot; | ''Ngqongqoshe Wongqongqoshe''
|-
! scope=&quot;row&quot; | &quot;Vuma Dlozi&quot; ehlanganisa uMnqobi Yazo
| 2020
|
| Iplatinamu &lt;ref name=&quot;DailySUN&quot; /&gt;
|-
! scope=&quot;row&quot; | &quot; Mali Eningi &quot; ehlanganisa u-Ntaba Yase Dubai, u-Ricky Rick
| rowspan=&quot;3&quot; | 2021
| 2
| 2× Iplatinamu
| rowspan=&quot;4&quot; | ''Ichwane Lenyoka''
|-
! scope=&quot;row&quot; | &quot;Umuzi eSandton&quot; nge- Lwah Ndlunkulu
| —
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;Inhlupheko&quot; ehlanganisa uMduduzi Ncube
| 1
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;iVolovolo&quot; ene-Xowla
| 2022
| —
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;Dear My Love&quot; ene-Xowla, KO no -Siya Ntuli
| 2022
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Awufuni Ukung' Qoma&quot;
| rowspan=&quot;3&quot; | 2024
| —
|
| ''UCongweni kaNgises''
|-
! scope=&quot;row&quot; | &quot;200 Bars&quot;
| — 
||{{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ay Ka'Ncane&quot; (Big Zulu, Tony Dayimane)
| — 
||{{non-album single}} 
|-
! scope=&quot;row&quot; | &quot;Amacala Othando&quot; (Big Zulu, Azana, Malungelo)
| rowspan=&quot;2&quot; | 2025
| — 
||{{non-album single}} 
|-
! scope=&quot;row&quot; | &quot;Abazazi Bafunani&quot; (ehlanganisa u-Emtee )
| 2 
|
| Icala Le Mpumelelo
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; | &quot;—&quot; kutjho ukurekhoda okungazange kushadi namkha okungakakhutjhwa endaweni leyo.
|}
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center&quot;
|+Irhelo lazingoma azihlanganyele nabanye njengabaculi abaveziweko, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;Isigingci&quot; (Mduduzi ehlanganisa uBig Zulu)
| 2020
| —
|
| ''Isitimela''
|-
! scope=&quot;row&quot; | &quot;Alusafani&quot; ( Qwabe Twins featuring Big Zulu, Mduduzi, Xowla)
| rowspan=&quot;2&quot; | 2021
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Qoma&quot; ( Blaq Diamond nge-Siya Ntuli, Big Zulu)
| —
| I-RiSA: Iplatinamu 
| Ithando lesiZulu
|-
! scope=&quot;row&quot; | &quot;Amalobolo&quot; ( u-Nomfundo Moh ohlanganisa u-Big Zulu)
| 2023
| —
|
| ''Ugcobo''
|-
! scope=&quot;row&quot; | &quot;Beng' dakiwe (u-Xowla ahlanganisa u-Big Zulu, u-DJ Tira )
| rowspan=&quot;2&quot; | 2023
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;My Ex&quot; (Big Xhosa featuring Big Zulu)
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Mfazi Wephepha&quot; (Nkosazana Daughter, Master Kg featuring Big Zulu, Zee Nxumalo )
| 2024
| 4 
|
| ''Makhelwane''
|}

== Imitlomelo nokuphakanyiswa ==
{| class=&quot;wikitable&quot;
!Umnyaka
! Umtlomelo
! Umkhakha
! Imiphumela
! Ref.
|-
| rowspan=&quot;3&quot; | 2019
| rowspan=&quot;2&quot; | SAHHA
| I-albhamu yomnyaka| {{nom}}
| rowspan=&quot;2&quot; |  
|-
| Umdwebi wesilisa ophuma phambili womnyaka|{{nom}}
|-
| I-SAMA 26
| I-albhamu ye-Hip Hop ehle khulu| {{nom}}
|  
|-
| 2020
| SAHHA
| I-Remix ehle khulu| {{Nom}}
| 
|-
| 2021
| I-SAMA 27
| Ukusebenzisana okuhle khulu|{{won}}
|  
|-
| rowspan=&quot;8&quot; | 2021
| rowspan=&quot;8&quot; | I-SAHHA 10
| I-albhamu yomnyaka|{{won}}
| rowspan=&quot;8&quot; |  
|-
| Owesilisa ophuma phambili|{{won}}
|-
| Ingoma yomnyaka|{{won}}
|-
| Ukusebenzisana okuhle khulu|{{won}}
|-
| I-MVP/Umtjhayeli womnyaka|{{nom}}
|-
| Ividiyo ehle khulu|{{won}}
|-
| Umvuzo we-Ubuntu Activism|{{won}}
|-
| Ukuthengisa okuhle khulu kwedijithali|{{won}}
|-
| rowspan=&quot;2&quot; | 2022
| rowspan=&quot;2&quot; | DStv MVCA
| Ingoma engiyithandako| {{nom}}
| rowspan=&quot;2&quot; | 
|-
| Umculi womculo othandwako/isiqhema|{{nom}}
|-
| 2023
| 17th Metro FM Music Awards
| I-Duo/Isiqhema esihle khulu |{{Won}} 
|
|}

== UMTHOMBO LWAZI ==
&lt;references responsive=&quot;&quot; /&gt;</text>
      <sha1>j10u82mst53zkye9gz1tqec0v4jq15f</sha1>
    </revision>
    <revision>
      <id>5605</id>
      <parentid>5599</parentid>
      <timestamp>2025-09-04T10:23:26Z</timestamp>
      <contributor>
        <username>Kholeka19721</username>
        <id>889</id>
      </contributor>
      <minor />
      <origin>5605</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="13772" sha1="rg3xnm5ktx5bfowd2p7d9i3t5ft85so" xml:space="preserve">
'''BIG ZULU'''                         
[[Isimumathi:Big zulu.jpg|left|thumb|BIG ZULU]]
'''IMINININGWANA YANGEMUVA'''

'''IBIZO:'''  Siyabonga Nene

'''UKUBELETHWA:'''  7 KuSihlabantangana 1986

'''UMSEBENZI:''' Umrepha, umtloli weengoma

'''UNYAKA WOKUDUMA:''' 2003- njenganje

'''AMALEBULA:''' Universal Records(kwangaphambilini), Nkabi Records.

'''USiyabonga Nene''' (wabelethwa mhlana amalanga alikhomba, kuMrhayili ngomnyaka we-1986  )&lt;ref&gt;{{Cite web |last=Mag |first=SA Hip Hop |date=2021-04-07 |title=Happy Birthday Big Zulu! A Look Into Big Zulu's Best Selling Records |url=https://sahiphopmag.co.za/2021/04/happy-birthday-big-zulu-a-look-into-big-zulus-best-selling-records/ |access-date=2025-09-04 |website=SA Hip Hop Mag |language=en-US}}&lt;/ref&gt;&lt;ref&gt;{{Citation |last=Ladson-Billings |first=Gloria |title=From Big Homie the O.G., to GLB |date=2018-03-23 |work=#HipHopEd: The Compilation on Hip-hop Education |pages=21–26 |url=https://doi.org/10.1163/9789004371873_003 |access-date=2025-09-04 |publisher=BRILL |isbn=978-90-04-37187-3}}&lt;/ref&gt;
, owaziwa ngebizo elibizwa laka '''Big Zulu''', mrepha nomtloli weengoma we[[Isewula Afrika|Sewula Afrika]].  Waphakama ngemva kokukhipha ingoma ethi &quot;Donsa NkaDobi&quot; ngomnyaka wee-2016.

Watlikitla isivumelwano sokurekhoda ne -Universal Music ngomnyaka wee- 2015 begodu  wakhipha i-albhamu yakhe yokuthoma, ''u-Ushun Wenkabi'' (2018) no ''-Ungqongqoshe Wongqongqoshe'' (2019).

I-albhamu yesithathu ka Big Zulu ''Ichwane Lenyoka'' (2021), yakhiqiza ama-single amathathu aphuma phambili &quot; Mali Eningi &quot;, &quot;Inhlupheko&quot; kanye no-&quot;Umuzi eSandton&quot;. Ingoma yayo ephambili &quot;i-Mali Eningi&quot;, yaqinisekiswa yi-double platinum yi- Recording Industry of South Africa (RiSA). 

[[Big Zulu|UBig Zulu]] wabuye wavela emidlalweni kamabonakude ''i-Isibaya'', ''One Mic'' (2017-2020),  ''Uzalo'' (2020), ''Isithembiso'', kanye ''no-Ushuni Womhlaba'' (2024).  Imitlomelo  yakhe ifaka hlangana imitlomelo  ye-Hip Hop yeSewula Afrika elikhomba, umtlomelo  owodwa we-South African Music Award kanye ne-Metro FM Music Awards eyodwa.

== Ipilo yokuthoma ==
USiyabonga Nene wabelethwa begodu wakhulela e -Bergville, KwaZulu-Natal. Wakhula alalele umvumo ka -Maskandi no-Isichathamiya, athonywa ngu -Ladysmith Black Mambazo, Phuzekemisi no-Imithente. Dacre, Richard (2015-05-28), &quot;Worth, Harry [real name Harry Bourlon Illingsworth] (1917–1989), comedian&quot;, Oxford Dictionary of National Biography, Oxford University Press, ISBN 978-0-19-861412-8, retrieved 2025-09-04

== IIMVELAPHI YOBUVUMO ==

=== Izithonyo ===
Uthonywe ngu-Maskandi no-Scathamiya.  Bekahlala e-Vaal endaweni ebizwa nge-Palm Springs.

== Ibizelo ==

=== Ukuthoma komsebenzi ===
UZulu wahlala iminyaka eminengi amtjhayeli wetekisi begodu watjhiya ngomnyaka wee-2008 ukobana aragele phambili nomsebenzi wakhe wezomvumo. Ngomnyaka wee-2009, ngemva kobana atjhiye ibubulo lamathekisi wathoma ukutlola iingoma nokudlala.

Ngemva kweminyaka emine ngomnyaka wee-2013, u-Zulu waphalisana begodu waba ngowokuthoma ukuthumba iphalisano le Red Bull Back to the city.  Ingoma yakhe yokuthoma ethi &quot;Donsa Nkabi&quot; yakhutjhwa ngomnyaka wee-2016. 

=== 2014–2019: ''Ushun Wenkabi'', ''Ungqongqoshe Wongqongqoshe'' ===
Ngemva kweminyaka eminengi njengomvumi ozijameleko, watlikitla isivumelwano sokurekhoda ne-Universal Music Records ngomnyaka wee-2015 begodu wakhupha i-albhamu yakhe yokuthoma ''i-Ushun Wenkabi'' ngenyanga ka Velabahlinze ngomnyaka wee-2018, eneengoma ezifaka hlangana &quot;u-Ang'mazi umama&quot; no-&quot;Home&quot;. 

I-albhamu yakhe yesibili ye-studio ''u-Ungqongqoshe Wongqongqoshe'' yakhutjhwa ngomnyaka wee-2019,  ihlanganisa u-Ab Crazy, u-Mnqobi Yazo, u-FiFi Cooper, u-Kwesta, no [[Cassper Nyovest|Caspper Nyovest]], u-Musiholiq no-Truhitz.  Ingoma ephambili ethi &quot;Ak'laleki&quot; eno-Kwesta yakhutjhwa. Mhlana amalanga amabili kuRhoboyi ingoma yakhe yesibili ethi &quot;Ama Million&quot; eno- Cassper Nyovest &amp; Musiholiq yakhutjhwa begodu yafika endaweni yesihlanu ku-iTunes Chart.   Ingoma le beyiqinisekiswe njengeplatinamu.   Mhlana amalanga ali-14 kuRhoboyi, ingoma yakhe yesithathu ethi &quot;Vuma dlozi&quot; ehlanganisa u-Mnqobi Yazo yakhutjhwa  begodu yaqinisekiswa yi-platinamu yibubulo lokurekhoda leSewula Afrika (i-RiSA) ngokuthengisa amakhophi ama-50 000. &lt;ref name=&quot;ubetoo&quot; /&gt; I-albhamu le yaqinisekiswa njengegolide yi-Recording Industry of South Africa (RiSA)  begodu yathola ukukhethwa ku- South African Music Awards (SAMA26)  ye-Best Hip Hop Album.  Ngomnyaka ofanako, wee-2019, i-albhamu leyo yakhethwa njenge-Best Male Artist of the Year kanye ne-albhamu yomnyaka e -South African Hip Hop Awards.  Wasungula ilebula yakhe yamarekhodi i-Nkabi Records. 

=== 2020–2022: ''Ichwane Lenyoka'', ''Nkabi Nation'' ===
Mhlana amalanga ama-20 kuNobayeni ngomnyaka wee- 2020, ingoma yakhe ethi &quot; Mali Eningi &quot; yakhutjhwa ifaka hlangana umvumi ongu Intaba Yase Dubai no-Ricky Rick njengengoma ephambili ye-albhamu. Ingoma le yavela endaweni yesibili kumatjhadi we ''-Channel 0'' Top 30  begodu yaqinisekiswa njenge-double platinum.  Emnyanyeni we -27th annual South African Music Awards,ingoma i  &quot;Mali Eningi&quot; yathumba isigaba sokubambisana okuhle khulu.  Ekupheleni komnyaka wee-2020 wakhethwa kokuthoma ku -MTV Base: SA's Hottest MCs, endaweni yesihlanu. 

Ngasekupheleni kukaTjhirhweni ngomnyaka wee-2021, wamemezela ukusebenza kwe-albhamu yakhe yesithathu.   

Mhlana amalanga ali-11 kuNtaka ngomnyaka wee-2021, wakhupha ingoma &quot;Inhlupheko&quot; eno Mduduzi Ncube njengengoma yesibili.  Ingoma le yafika endaweni yokuthoma ematjhadini we-iTunes weSewula Afrika begodu yafika endaweni yesine ematjhadini we-Shazam. 

Mhlana amalanga amathathu kuNtaka ngomnyaka wee-2021, wamemezela ingoma etja ebizwa ngokuthi &quot;Umuzi eSandton&quot; ehlanganisa u-Lwah Ndlunkulu ku -Twitter.  Ingoma le yakhutjhwa mhlana amalanga alithoba kuNtaka ngomnyaka wee-2021;  Yavezwa ku-albhamu yakhe ''i-Ichwane Lenyoka'', eyakhutjhwa mhlana amalanga amathathu kuNobayeni 2021.  Ingoma ethi &quot;Umuzi eSandton&quot; yafika endaweni yokuthoma ematjhadini we-Shazam. 

Mhlana amalanga ali-13 kuNobayeni ngomnyaka wee-2021, wenza isizini yetjhumi nane ku- ''Idols South Africa.''  UZulu uthumbe imitlomelo elikhomba efaka hlangana; I-albhamu yomnyaka, ingoma yomnyaka (&quot; Mali Eningi &quot;), ividiyo yomculo ehle khulu, umvuzo we-Best Male and Ubuntu Activism, Best Collaboration, kanye no-Best Digital Sales kuma -2021 South African Hip Hop Awards.  Ekupheleni komnyaka wee-2021 wakhethwa godu ku-MTV Base: SA's Hottest MCs, wakhuphukela endaweni yesibili. 

I-&quot;iVolovolo&quot; eno Xowla yakhutjhwa mhlana amalanga alitjhumi nanye kuMhlolanja ngomnyaka wee-2022. Ingoma le yathoma ukudlala phambili eSewula Afrika.  

I-&quot;Voicemail&quot; ka-Big Zulu, Mduduzi Ncube, Lwah Ndlunkulu, Siya Ntuli no-Xowla yakhutjhwa njengengoma ephambili ye-albhamu mhlana amalanga ama-24 kuMgwengweni ngonyaka wee-2022.  Ingoma le yaqinisekiswa njengegolide begodu yafika endaweni yokuthoma eSewula Afrika.  

Wakhupha  i-&quot;150 Bars (Ke hip hop Dawg)&quot; mhlana amalanga ama-20 kuRhoboyi ngomnyaka wee-2022. Ingoma le yangena ematjhadini we-Local Top 10 Radio endawen&quot;i yesikhombisa. 

Wamemezela  ilanga lokukhutjhwa kwama-albhamu kanye irhelo lokugcina lwengoma ku-Instagram, ekhutjhwe mhlana amalanga alithoba kuNobayeni ngomnyaka wee-2022. 

&quot;Dear My Love&quot; ehlanganisa u KO, Xowla no-Siya Ntuli ingoma eyodwa ka-Big Zulu ekhutjhwe mhlazi-25 kuNobayeni 2022.

=== 2023-nje: Inkabi Zezwe, ''Ukhamba'', ''Ngises' Congweni'' ===
Mhlana amalanga ali-17 kuNtaka 2023, u-Big Zulu no-Sjava bamemezela ukusebenza nge-albhamu yabo ehlangeneko ''i-Ukhamba'' njenge-duo Inkabi Zezwe . &quot; Umbayimbayi &quot; yakhutjhwa mhlana amalanga ama-24 kuNtaka ngomnyaka wee-2023 njengengoma ephambili ye-albhamu.  Ingoma le yavela kuyingoma yokuthoma ku-iTunes Top 50 kanye ne-Spotify Top 100 South Africa ngokulandelana.  Ingoma le yaqinisekiswa njenge-3× Platinum eSewula Afrika. Kube khona ingoma lapho asebenzisana no [[Mlindo the Vocalist]] kanye no Makhadzi ku albhumi ethi ngises' congweni.   

Mhlana kuthoma inyanga kaMrhayili, u-Zulu wamemezela i-Inkabi Zezwe Tour eyathoma ngoMgwengweni bekwaba nguNobayeni ngomnyaka wee-2023.

I-albhamu le yakhutjhwa mhlana amalanga ali-12 kuMrhayili ngomnyaka wee-2023. Yaba yinto yokuthoma emazweni amabili weSewula Afrika ne-Eswatini ngokulandelana. 

Ngasekupheleni kukaTjhirhweni ngomnyaka wee-2024, uZulu wamemezela ukusebenza nge-albhamu yakhe yesine ye-studio kanye ne-albhamu yakhe ephambili &quot;Awufuni Ukung' Qoma&quot;. ''I-Ngises' Congweni'' yakhutjhwa mhlana amalanga ama-27 kuNtaka ngomnyaka wee- 2023.    

=== Umabonakude ===
Ngenyanga kaMgwengweni ngomnyaka wee-2024, uZulu wangenela  umdlalo wokufuna amathalenta ''u-Ushuni Womhlaba'', njengomahluleli  ku-SABC 1 mhlana amalanga alikhomba kuNtaka. 

=== Amanye amabubulo ===
Ngomnyaka wee-2019, uZulu wasungula ilebula yamarekhodi i-Inkabi Records.  UZulu sele asayine uMduduzi Ncube, uLwah Ndlunkulu, uXowla no Siya Ntuli. 

Mhlana amalanga ama-21 kuNobayeni ngomnyaka wee-2021, uZulu wathoma ukusiza abantu abadla imbuya ngelithi begodu wanikela ngemitjhininqondo namaphrinta e-Obonjaneni Primary School. 

Kusukela ngoRhoboyi ngomnyaka wee- 2020, wasebenzisana nestolo i Spitz njengomsekeli (ambassador) we-Carvela.  

== I-Discography ==

=== Ama-albhamu we-studio ===

* ''Ushun Wenkabi'' (2018)
* ''Ungqongqoshe Wongqongqoshe'' (2019)
* ''Ichwane Lenyoka'' (2021) 
* ''Ngises' Congweni'' (2024)
* ''Icala Le Mpumelelo'' (2025)

=== Ama-albhamu wokubambisana ===

* ''Inkabi Nation'' (2022)
* ''Ukhamba'' (2023)

=== Njengomdosi phambili kwezomvumo ===
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+Irhelo lama-single njengabaculi abadosa phambili, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;AmaMillion&quot; ene-Musiholiq, Cassper Nyovest
| 2019
|
| Iplatinamu 
| rowspan=&quot;2&quot; | ''Ngqongqoshe Wongqongqoshe''
|-
! scope=&quot;row&quot; | &quot;Vuma Dlozi&quot; ehlanganisa uMnqobi Yazo
| 2020
|
| Iplatinamu &lt;ref name=&quot;DailySUN&quot; /&gt;
|-
! scope=&quot;row&quot; | &quot; Mali Eningi &quot; ehlanganisa u-Ntaba Yase Dubai, u-Ricky Rick
| rowspan=&quot;3&quot; | 2021
| 2
| 2× Iplatinamu
| rowspan=&quot;4&quot; | ''Ichwane Lenyoka''
|-
! scope=&quot;row&quot; | &quot;Umuzi eSandton&quot; nge- Lwah Ndlunkulu
| —
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;Inhlupheko&quot; ehlanganisa uMduduzi Ncube
| 1
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;iVolovolo&quot; ene-Xowla
| 2022
| —
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;Dear My Love&quot; ene-Xowla, KO no -Siya Ntuli
| 2022
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Awufuni Ukung' Qoma&quot;
| rowspan=&quot;3&quot; | 2024
| —
|
| ''UCongweni kaNgises''
|-
! scope=&quot;row&quot; | &quot;200 Bars&quot;
| — 
||{{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ay Ka'Ncane&quot; (Big Zulu, Tony Dayimane)
| — 
||{{non-album single}} 
|-
! scope=&quot;row&quot; | &quot;Amacala Othando&quot; (Big Zulu, Azana, Malungelo)
| rowspan=&quot;2&quot; | 2025
| — 
||{{non-album single}} 
|-
! scope=&quot;row&quot; | &quot;Abazazi Bafunani&quot; (ehlanganisa u-Emtee )
| 2 
|
| Icala Le Mpumelelo
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; | &quot;—&quot; kutjho ukurekhoda okungazange kushadi namkha okungakakhutjhwa endaweni leyo.
|}
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center&quot;
|+Irhelo lazingoma azihlanganyele nabanye njengabaculi abaveziweko, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;Isigingci&quot; (Mduduzi ehlanganisa uBig Zulu)
| 2020
| —
|
| ''Isitimela''
|-
! scope=&quot;row&quot; | &quot;Alusafani&quot; ( Qwabe Twins featuring Big Zulu, Mduduzi, Xowla)
| rowspan=&quot;2&quot; | 2021
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Qoma&quot; ( Blaq Diamond nge-Siya Ntuli, Big Zulu)
| —
| I-RiSA: Iplatinamu 
| Ithando lesiZulu
|-
! scope=&quot;row&quot; | &quot;Amalobolo&quot; ( u-Nomfundo Moh ohlanganisa u-Big Zulu)
| 2023
| —
|
| ''Ugcobo''
|-
! scope=&quot;row&quot; | &quot;Beng' dakiwe (u-Xowla ahlanganisa u-Big Zulu, u-DJ Tira )
| rowspan=&quot;2&quot; | 2023
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;My Ex&quot; (Big Xhosa featuring Big Zulu)
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Mfazi Wephepha&quot; (Nkosazana Daughter, Master Kg featuring Big Zulu, Zee Nxumalo )
| 2024
| 4 
|
| ''Makhelwane''
|}

== Imitlomelo nokuphakanyiswa ==
{| class=&quot;wikitable&quot;
!Umnyaka
! Umtlomelo
! Umkhakha
! Imiphumela
! Ref.
|-
| rowspan=&quot;3&quot; | 2019
| rowspan=&quot;2&quot; | SAHHA
| I-albhamu yomnyaka| {{nom}}
| rowspan=&quot;2&quot; |  
|-
| Umdwebi wesilisa ophuma phambili womnyaka|{{nom}}
|-
| I-SAMA 26
| I-albhamu ye-Hip Hop ehle khulu| {{nom}}
|  
|-
| 2020
| SAHHA
| I-Remix ehle khulu| {{Nom}}
| 
|-
| 2021
| I-SAMA 27
| Ukusebenzisana okuhle khulu|{{won}}
|  
|-
| rowspan=&quot;8&quot; | 2021
| rowspan=&quot;8&quot; | I-SAHHA 10
| I-albhamu yomnyaka|{{won}}
| rowspan=&quot;8&quot; |  
|-
| Owesilisa ophuma phambili|{{won}}
|-
| Ingoma yomnyaka|{{won}}
|-
| Ukusebenzisana okuhle khulu|{{won}}
|-
| I-MVP/Umtjhayeli womnyaka|{{nom}}
|-
| Ividiyo ehle khulu|{{won}}
|-
| Umvuzo we-Ubuntu Activism|{{won}}
|-
| Ukuthengisa okuhle khulu kwedijithali|{{won}}
|-
| rowspan=&quot;2&quot; | 2022
| rowspan=&quot;2&quot; | DStv MVCA
| Ingoma engiyithandako| {{nom}}
| rowspan=&quot;2&quot; | 
|-
| Umculi womculo othandwako/isiqhema|{{nom}}
|-
| 2023
| 17th Metro FM Music Awards
| I-Duo/Isiqhema esihle khulu |{{Won}} 
|
|}

== UMTHOMBO LWAZI ==
&lt;references responsive=&quot;&quot; /&gt;</text>
      <sha1>rg3xnm5ktx5bfowd2p7d9i3t5ft85so</sha1>
    </revision>
    <revision>
      <id>5622</id>
      <parentid>5605</parentid>
      <timestamp>2025-09-04T10:40:48Z</timestamp>
      <contributor>
        <username>Kholeka19721</username>
        <id>889</id>
      </contributor>
      <minor />
      <comment>adjusted a picture</comment>
      <origin>5622</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="13777" sha1="ouxrys2tiuhd32c1eq45lpyrduksusq" xml:space="preserve">
'''BIG ZULU'''                         
[[Isimumathi:Big zulu.jpg|thumb|BIG ZULU|583x583px]]
'''IMINININGWANA YANGEMUVA'''

'''IBIZO:'''  Siyabonga Nene

'''UKUBELETHWA:'''  7 KuSihlabantangana 1986

'''UMSEBENZI:''' Umrepha, umtloli weengoma

'''UNYAKA WOKUDUMA:''' 2003- njenganje

'''AMALEBULA:''' Universal Records(kwangaphambilini), Nkabi Records.

'''USiyabonga Nene''' (wabelethwa mhlana amalanga alikhomba, kuMrhayili ngomnyaka we-1986  )&lt;ref&gt;{{Cite web |last=Mag |first=SA Hip Hop |date=2021-04-07 |title=Happy Birthday Big Zulu! A Look Into Big Zulu's Best Selling Records |url=https://sahiphopmag.co.za/2021/04/happy-birthday-big-zulu-a-look-into-big-zulus-best-selling-records/ |access-date=2025-09-04 |website=SA Hip Hop Mag |language=en-US}}&lt;/ref&gt;&lt;ref&gt;{{Citation |last=Ladson-Billings |first=Gloria |title=From Big Homie the O.G., to GLB |date=2018-03-23 |work=#HipHopEd: The Compilation on Hip-hop Education |pages=21–26 |url=https://doi.org/10.1163/9789004371873_003 |access-date=2025-09-04 |publisher=BRILL |isbn=978-90-04-37187-3}}&lt;/ref&gt;
, owaziwa ngebizo elibizwa laka '''Big Zulu''', mrepha nomtloli weengoma we[[Isewula Afrika|Sewula Afrika]].  Waphakama ngemva kokukhipha ingoma ethi &quot;Donsa NkaDobi&quot; ngomnyaka wee-2016.

Watlikitla isivumelwano sokurekhoda ne -Universal Music ngomnyaka wee- 2015 begodu  wakhipha i-albhamu yakhe yokuthoma, ''u-Ushun Wenkabi'' (2018) no ''-Ungqongqoshe Wongqongqoshe'' (2019).

I-albhamu yesithathu ka Big Zulu ''Ichwane Lenyoka'' (2021), yakhiqiza ama-single amathathu aphuma phambili &quot; Mali Eningi &quot;, &quot;Inhlupheko&quot; kanye no-&quot;Umuzi eSandton&quot;. Ingoma yayo ephambili &quot;i-Mali Eningi&quot;, yaqinisekiswa yi-double platinum yi- Recording Industry of South Africa (RiSA). 

[[Big Zulu|UBig Zulu]] wabuye wavela emidlalweni kamabonakude ''i-Isibaya'', ''One Mic'' (2017-2020),  ''Uzalo'' (2020), ''Isithembiso'', kanye ''no-Ushuni Womhlaba'' (2024).  Imitlomelo  yakhe ifaka hlangana imitlomelo  ye-Hip Hop yeSewula Afrika elikhomba, umtlomelo  owodwa we-South African Music Award kanye ne-Metro FM Music Awards eyodwa.

== Ipilo yokuthoma ==
USiyabonga Nene wabelethwa begodu wakhulela e -Bergville, KwaZulu-Natal. Wakhula alalele umvumo ka -Maskandi no-Isichathamiya, athonywa ngu -Ladysmith Black Mambazo, Phuzekemisi no-Imithente. Dacre, Richard (2015-05-28), &quot;Worth, Harry [real name Harry Bourlon Illingsworth] (1917–1989), comedian&quot;, Oxford Dictionary of National Biography, Oxford University Press, ISBN 978-0-19-861412-8, retrieved 2025-09-04

== IIMVELAPHI YOBUVUMO ==

=== Izithonyo ===
Uthonywe ngu-Maskandi no-Scathamiya.  Bekahlala e-Vaal endaweni ebizwa nge-Palm Springs.

== Ibizelo ==

=== Ukuthoma komsebenzi ===
UZulu wahlala iminyaka eminengi amtjhayeli wetekisi begodu watjhiya ngomnyaka wee-2008 ukobana aragele phambili nomsebenzi wakhe wezomvumo. Ngomnyaka wee-2009, ngemva kobana atjhiye ibubulo lamathekisi wathoma ukutlola iingoma nokudlala.

Ngemva kweminyaka emine ngomnyaka wee-2013, u-Zulu waphalisana begodu waba ngowokuthoma ukuthumba iphalisano le Red Bull Back to the city.  Ingoma yakhe yokuthoma ethi &quot;Donsa Nkabi&quot; yakhutjhwa ngomnyaka wee-2016. 

=== 2014–2019: ''Ushun Wenkabi'', ''Ungqongqoshe Wongqongqoshe'' ===
Ngemva kweminyaka eminengi njengomvumi ozijameleko, watlikitla isivumelwano sokurekhoda ne-Universal Music Records ngomnyaka wee-2015 begodu wakhupha i-albhamu yakhe yokuthoma ''i-Ushun Wenkabi'' ngenyanga ka Velabahlinze ngomnyaka wee-2018, eneengoma ezifaka hlangana &quot;u-Ang'mazi umama&quot; no-&quot;Home&quot;. 

I-albhamu yakhe yesibili ye-studio ''u-Ungqongqoshe Wongqongqoshe'' yakhutjhwa ngomnyaka wee-2019,  ihlanganisa u-Ab Crazy, u-Mnqobi Yazo, u-FiFi Cooper, u-Kwesta, no [[Cassper Nyovest|Caspper Nyovest]], u-Musiholiq no-Truhitz.  Ingoma ephambili ethi &quot;Ak'laleki&quot; eno-Kwesta yakhutjhwa. Mhlana amalanga amabili kuRhoboyi ingoma yakhe yesibili ethi &quot;Ama Million&quot; eno- Cassper Nyovest &amp; Musiholiq yakhutjhwa begodu yafika endaweni yesihlanu ku-iTunes Chart.   Ingoma le beyiqinisekiswe njengeplatinamu.   Mhlana amalanga ali-14 kuRhoboyi, ingoma yakhe yesithathu ethi &quot;Vuma dlozi&quot; ehlanganisa u-Mnqobi Yazo yakhutjhwa  begodu yaqinisekiswa yi-platinamu yibubulo lokurekhoda leSewula Afrika (i-RiSA) ngokuthengisa amakhophi ama-50 000. &lt;ref name=&quot;ubetoo&quot; /&gt; I-albhamu le yaqinisekiswa njengegolide yi-Recording Industry of South Africa (RiSA)  begodu yathola ukukhethwa ku- South African Music Awards (SAMA26)  ye-Best Hip Hop Album.  Ngomnyaka ofanako, wee-2019, i-albhamu leyo yakhethwa njenge-Best Male Artist of the Year kanye ne-albhamu yomnyaka e -South African Hip Hop Awards.  Wasungula ilebula yakhe yamarekhodi i-Nkabi Records. 

=== 2020–2022: ''Ichwane Lenyoka'', ''Nkabi Nation'' ===
Mhlana amalanga ama-20 kuNobayeni ngomnyaka wee- 2020, ingoma yakhe ethi &quot; Mali Eningi &quot; yakhutjhwa ifaka hlangana umvumi ongu Intaba Yase Dubai no-Ricky Rick njengengoma ephambili ye-albhamu. Ingoma le yavela endaweni yesibili kumatjhadi we ''-Channel 0'' Top 30  begodu yaqinisekiswa njenge-double platinum.  Emnyanyeni we -27th annual South African Music Awards,ingoma i  &quot;Mali Eningi&quot; yathumba isigaba sokubambisana okuhle khulu.  Ekupheleni komnyaka wee-2020 wakhethwa kokuthoma ku -MTV Base: SA's Hottest MCs, endaweni yesihlanu. 

Ngasekupheleni kukaTjhirhweni ngomnyaka wee-2021, wamemezela ukusebenza kwe-albhamu yakhe yesithathu.   

Mhlana amalanga ali-11 kuNtaka ngomnyaka wee-2021, wakhupha ingoma &quot;Inhlupheko&quot; eno Mduduzi Ncube njengengoma yesibili.  Ingoma le yafika endaweni yokuthoma ematjhadini we-iTunes weSewula Afrika begodu yafika endaweni yesine ematjhadini we-Shazam. 

Mhlana amalanga amathathu kuNtaka ngomnyaka wee-2021, wamemezela ingoma etja ebizwa ngokuthi &quot;Umuzi eSandton&quot; ehlanganisa u-Lwah Ndlunkulu ku -Twitter.  Ingoma le yakhutjhwa mhlana amalanga alithoba kuNtaka ngomnyaka wee-2021;  Yavezwa ku-albhamu yakhe ''i-Ichwane Lenyoka'', eyakhutjhwa mhlana amalanga amathathu kuNobayeni 2021.  Ingoma ethi &quot;Umuzi eSandton&quot; yafika endaweni yokuthoma ematjhadini we-Shazam. 

Mhlana amalanga ali-13 kuNobayeni ngomnyaka wee-2021, wenza isizini yetjhumi nane ku- ''Idols South Africa.''  UZulu uthumbe imitlomelo elikhomba efaka hlangana; I-albhamu yomnyaka, ingoma yomnyaka (&quot; Mali Eningi &quot;), ividiyo yomculo ehle khulu, umvuzo we-Best Male and Ubuntu Activism, Best Collaboration, kanye no-Best Digital Sales kuma -2021 South African Hip Hop Awards.  Ekupheleni komnyaka wee-2021 wakhethwa godu ku-MTV Base: SA's Hottest MCs, wakhuphukela endaweni yesibili. 

I-&quot;iVolovolo&quot; eno Xowla yakhutjhwa mhlana amalanga alitjhumi nanye kuMhlolanja ngomnyaka wee-2022. Ingoma le yathoma ukudlala phambili eSewula Afrika.  

I-&quot;Voicemail&quot; ka-Big Zulu, Mduduzi Ncube, Lwah Ndlunkulu, Siya Ntuli no-Xowla yakhutjhwa njengengoma ephambili ye-albhamu mhlana amalanga ama-24 kuMgwengweni ngonyaka wee-2022.  Ingoma le yaqinisekiswa njengegolide begodu yafika endaweni yokuthoma eSewula Afrika.  

Wakhupha  i-&quot;150 Bars (Ke hip hop Dawg)&quot; mhlana amalanga ama-20 kuRhoboyi ngomnyaka wee-2022. Ingoma le yangena ematjhadini we-Local Top 10 Radio endawen&quot;i yesikhombisa. 

Wamemezela  ilanga lokukhutjhwa kwama-albhamu kanye irhelo lokugcina lwengoma ku-Instagram, ekhutjhwe mhlana amalanga alithoba kuNobayeni ngomnyaka wee-2022. 

&quot;Dear My Love&quot; ehlanganisa u KO, Xowla no-Siya Ntuli ingoma eyodwa ka-Big Zulu ekhutjhwe mhlazi-25 kuNobayeni 2022.

=== 2023-nje: Inkabi Zezwe, ''Ukhamba'', ''Ngises' Congweni'' ===
Mhlana amalanga ali-17 kuNtaka 2023, u-Big Zulu no-Sjava bamemezela ukusebenza nge-albhamu yabo ehlangeneko ''i-Ukhamba'' njenge-duo Inkabi Zezwe . &quot; Umbayimbayi &quot; yakhutjhwa mhlana amalanga ama-24 kuNtaka ngomnyaka wee-2023 njengengoma ephambili ye-albhamu.  Ingoma le yavela kuyingoma yokuthoma ku-iTunes Top 50 kanye ne-Spotify Top 100 South Africa ngokulandelana.  Ingoma le yaqinisekiswa njenge-3× Platinum eSewula Afrika. Kube khona ingoma lapho asebenzisana no [[Mlindo the Vocalist]] kanye no Makhadzi ku albhumi ethi ngises' congweni.   

Mhlana kuthoma inyanga kaMrhayili, u-Zulu wamemezela i-Inkabi Zezwe Tour eyathoma ngoMgwengweni bekwaba nguNobayeni ngomnyaka wee-2023.

I-albhamu le yakhutjhwa mhlana amalanga ali-12 kuMrhayili ngomnyaka wee-2023. Yaba yinto yokuthoma emazweni amabili weSewula Afrika ne-Eswatini ngokulandelana. 

Ngasekupheleni kukaTjhirhweni ngomnyaka wee-2024, uZulu wamemezela ukusebenza nge-albhamu yakhe yesine ye-studio kanye ne-albhamu yakhe ephambili &quot;Awufuni Ukung' Qoma&quot;. ''I-Ngises' Congweni'' yakhutjhwa mhlana amalanga ama-27 kuNtaka ngomnyaka wee- 2023.    

=== Umabonakude ===
Ngenyanga kaMgwengweni ngomnyaka wee-2024, uZulu wangenela  umdlalo wokufuna amathalenta ''u-Ushuni Womhlaba'', njengomahluleli  ku-SABC 1 mhlana amalanga alikhomba kuNtaka. 

=== Amanye amabubulo ===
Ngomnyaka wee-2019, uZulu wasungula ilebula yamarekhodi i-Inkabi Records.  UZulu sele asayine uMduduzi Ncube, uLwah Ndlunkulu, uXowla no Siya Ntuli. 

Mhlana amalanga ama-21 kuNobayeni ngomnyaka wee-2021, uZulu wathoma ukusiza abantu abadla imbuya ngelithi begodu wanikela ngemitjhininqondo namaphrinta e-Obonjaneni Primary School. 

Kusukela ngoRhoboyi ngomnyaka wee- 2020, wasebenzisana nestolo i Spitz njengomsekeli (ambassador) we-Carvela.  

== I-Discography ==

=== Ama-albhamu we-studio ===

* ''Ushun Wenkabi'' (2018)
* ''Ungqongqoshe Wongqongqoshe'' (2019)
* ''Ichwane Lenyoka'' (2021) 
* ''Ngises' Congweni'' (2024)
* ''Icala Le Mpumelelo'' (2025)

=== Ama-albhamu wokubambisana ===

* ''Inkabi Nation'' (2022)
* ''Ukhamba'' (2023)

=== Njengomdosi phambili kwezomvumo ===
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+Irhelo lama-single njengabaculi abadosa phambili, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;AmaMillion&quot; ene-Musiholiq, Cassper Nyovest
| 2019
|
| Iplatinamu 
| rowspan=&quot;2&quot; | ''Ngqongqoshe Wongqongqoshe''
|-
! scope=&quot;row&quot; | &quot;Vuma Dlozi&quot; ehlanganisa uMnqobi Yazo
| 2020
|
| Iplatinamu &lt;ref name=&quot;DailySUN&quot; /&gt;
|-
! scope=&quot;row&quot; | &quot; Mali Eningi &quot; ehlanganisa u-Ntaba Yase Dubai, u-Ricky Rick
| rowspan=&quot;3&quot; | 2021
| 2
| 2× Iplatinamu
| rowspan=&quot;4&quot; | ''Ichwane Lenyoka''
|-
! scope=&quot;row&quot; | &quot;Umuzi eSandton&quot; nge- Lwah Ndlunkulu
| —
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;Inhlupheko&quot; ehlanganisa uMduduzi Ncube
| 1
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;iVolovolo&quot; ene-Xowla
| 2022
| —
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;Dear My Love&quot; ene-Xowla, KO no -Siya Ntuli
| 2022
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Awufuni Ukung' Qoma&quot;
| rowspan=&quot;3&quot; | 2024
| —
|
| ''UCongweni kaNgises''
|-
! scope=&quot;row&quot; | &quot;200 Bars&quot;
| — 
||{{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ay Ka'Ncane&quot; (Big Zulu, Tony Dayimane)
| — 
||{{non-album single}} 
|-
! scope=&quot;row&quot; | &quot;Amacala Othando&quot; (Big Zulu, Azana, Malungelo)
| rowspan=&quot;2&quot; | 2025
| — 
||{{non-album single}} 
|-
! scope=&quot;row&quot; | &quot;Abazazi Bafunani&quot; (ehlanganisa u-Emtee )
| 2 
|
| Icala Le Mpumelelo
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; | &quot;—&quot; kutjho ukurekhoda okungazange kushadi namkha okungakakhutjhwa endaweni leyo.
|}
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center&quot;
|+Irhelo lazingoma azihlanganyele nabanye njengabaculi abaveziweko, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;Isigingci&quot; (Mduduzi ehlanganisa uBig Zulu)
| 2020
| —
|
| ''Isitimela''
|-
! scope=&quot;row&quot; | &quot;Alusafani&quot; ( Qwabe Twins featuring Big Zulu, Mduduzi, Xowla)
| rowspan=&quot;2&quot; | 2021
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Qoma&quot; ( Blaq Diamond nge-Siya Ntuli, Big Zulu)
| —
| I-RiSA: Iplatinamu 
| Ithando lesiZulu
|-
! scope=&quot;row&quot; | &quot;Amalobolo&quot; ( u-Nomfundo Moh ohlanganisa u-Big Zulu)
| 2023
| —
|
| ''Ugcobo''
|-
! scope=&quot;row&quot; | &quot;Beng' dakiwe (u-Xowla ahlanganisa u-Big Zulu, u-DJ Tira )
| rowspan=&quot;2&quot; | 2023
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;My Ex&quot; (Big Xhosa featuring Big Zulu)
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Mfazi Wephepha&quot; (Nkosazana Daughter, Master Kg featuring Big Zulu, Zee Nxumalo )
| 2024
| 4 
|
| ''Makhelwane''
|}

== Imitlomelo nokuphakanyiswa ==
{| class=&quot;wikitable&quot;
!Umnyaka
! Umtlomelo
! Umkhakha
! Imiphumela
! Ref.
|-
| rowspan=&quot;3&quot; | 2019
| rowspan=&quot;2&quot; | SAHHA
| I-albhamu yomnyaka| {{nom}}
| rowspan=&quot;2&quot; |  
|-
| Umdwebi wesilisa ophuma phambili womnyaka|{{nom}}
|-
| I-SAMA 26
| I-albhamu ye-Hip Hop ehle khulu| {{nom}}
|  
|-
| 2020
| SAHHA
| I-Remix ehle khulu| {{Nom}}
| 
|-
| 2021
| I-SAMA 27
| Ukusebenzisana okuhle khulu|{{won}}
|  
|-
| rowspan=&quot;8&quot; | 2021
| rowspan=&quot;8&quot; | I-SAHHA 10
| I-albhamu yomnyaka|{{won}}
| rowspan=&quot;8&quot; |  
|-
| Owesilisa ophuma phambili|{{won}}
|-
| Ingoma yomnyaka|{{won}}
|-
| Ukusebenzisana okuhle khulu|{{won}}
|-
| I-MVP/Umtjhayeli womnyaka|{{nom}}
|-
| Ividiyo ehle khulu|{{won}}
|-
| Umvuzo we-Ubuntu Activism|{{won}}
|-
| Ukuthengisa okuhle khulu kwedijithali|{{won}}
|-
| rowspan=&quot;2&quot; | 2022
| rowspan=&quot;2&quot; | DStv MVCA
| Ingoma engiyithandako| {{nom}}
| rowspan=&quot;2&quot; | 
|-
| Umculi womculo othandwako/isiqhema|{{nom}}
|-
| 2023
| 17th Metro FM Music Awards
| I-Duo/Isiqhema esihle khulu |{{Won}} 
|
|}

== UMTHOMBO LWAZI ==
&lt;references responsive=&quot;&quot; /&gt;</text>
      <sha1>ouxrys2tiuhd32c1eq45lpyrduksusq</sha1>
    </revision>
    <revision>
      <id>5626</id>
      <parentid>5622</parentid>
      <timestamp>2025-09-04T10:42:54Z</timestamp>
      <contributor>
        <username>Kholeka19721</username>
        <id>889</id>
      </contributor>
      <minor />
      <origin>5626</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="13775" sha1="jdoydit4vthonj3jegtlym0oquw78p4" xml:space="preserve">
'''BIG ZULU'''                         
[[Isimumathi:Big zulu.jpg|thumb|BIG ZULU|583x583px]]
'''IMINININGWANA YANGEMUVA'''

'''IBIZO:'''  Siyabonga Nene

'''UKUBELETHWA:'''  7 KuSihlabantangana 1986

'''UMSEBENZI:''' Umrepha, umtloli weengoma

'''UNYAKA WOKUDUMA:''' 2003- njenganje

'''AMALEBULA:''' Universal Records(kwangaphambilini), Nkabi Records.

'''USiyabonga Nene''' (wabelethwa mhlana amalanga alikhomba, kuMrhayili ngomnyaka we-1986  )&lt;ref&gt;{{Cite web |last=Mag |first=SA Hip Hop |date=2021-04-07 |title=Happy Birthday Big Zulu! A Look Into Big Zulu's Best Selling Records |url=https://sahiphopmag.co.za/2021/04/happy-birthday-big-zulu-a-look-into-big-zulus-best-selling-records/ |access-date=2025-09-04 |website=SA Hip Hop Mag |language=en-US}}&lt;/ref&gt;&lt;ref&gt;{{Citation |last=Ladson-Billings |first=Gloria |title=From Big Homie the O.G., to GLB |date=2018-03-23 |work=#HipHopEd: The Compilation on Hip-hop Education |pages=21–26 |url=https://doi.org/10.1163/9789004371873_003 |access-date=2025-09-04 |publisher=BRILL |isbn=978-90-04-37187-3}}&lt;/ref&gt;
, owaziwa ngebizo elibizwa laka '''Big Zulu''', mrepha nomtloli weengoma we[[Isewula Afrika|Sewula Afrika]].  Waphakama ngemva kokukhipha ingoma ethi &quot;Donsa Nkabi&quot; ngomnyaka wee-2016.

Watlikitla isivumelwano sokurekhoda ne -Universal Music ngomnyaka wee- 2015 begodu  wakhipha i-albhamu yakhe yokuthoma, ''u-Ushun Wenkabi'' (2018) no ''-Ungqongqoshe Wongqongqoshe'' (2019).

I-albhamu yesithathu ka Big Zulu ''Ichwane Lenyoka'' (2021), yakhiqiza ama-single amathathu aphuma phambili &quot; Mali Eningi &quot;, &quot;Inhlupheko&quot; kanye no-&quot;Umuzi eSandton&quot;. Ingoma yayo ephambili &quot;i-Mali Eningi&quot;, yaqinisekiswa yi-double platinum yi- Recording Industry of South Africa (RiSA). 

[[Big Zulu|UBig Zulu]] wabuye wavela emidlalweni kamabonakude ''i-Isibaya'', ''One Mic'' (2017-2020),  ''Uzalo'' (2020), ''Isithembiso'', kanye ''no-Ushuni Womhlaba'' (2024).  Imitlomelo  yakhe ifaka hlangana imitlomelo  ye-Hip Hop yeSewula Afrika elikhomba, umtlomelo  owodwa we-South African Music Award kanye ne-Metro FM Music Awards eyodwa.

== Ipilo yokuthoma ==
USiyabonga Nene wabelethwa begodu wakhulela e -Bergville, KwaZulu-Natal. Wakhula alalele umvumo ka -Maskandi no-Isichathamiya, athonywa ngu -Ladysmith Black Mambazo, Phuzekemisi no-Imithente. Dacre, Richard (2015-05-28), &quot;Worth, Harry [real name Harry Bourlon Illingsworth] (1917–1989), comedian&quot;, Oxford Dictionary of National Biography, Oxford University Press, ISBN 978-0-19-861412-8, retrieved 2025-09-04

== IIMVELAPHI YOBUVUMO ==

=== Izithonyo ===
Uthonywe ngu-Maskandi no-Scathamiya.  Bekahlala e-Vaal endaweni ebizwa nge-Palm Springs.

== Ibizelo ==

=== Ukuthoma komsebenzi ===
UZulu wahlala iminyaka eminengi amtjhayeli wetekisi begodu watjhiya ngomnyaka wee-2008 ukobana aragele phambili nomsebenzi wakhe wezomvumo. Ngomnyaka wee-2009, ngemva kobana atjhiye ibubulo lamathekisi wathoma ukutlola iingoma nokudlala.

Ngemva kweminyaka emine ngomnyaka wee-2013, u-Zulu waphalisana begodu waba ngowokuthoma ukuthumba iphalisano le Red Bull Back to the city.  Ingoma yakhe yokuthoma ethi &quot;Donsa Nkabi&quot; yakhutjhwa ngomnyaka wee-2016. 

=== 2014–2019: ''Ushun Wenkabi'', ''Ungqongqoshe Wongqongqoshe'' ===
Ngemva kweminyaka eminengi njengomvumi ozijameleko, watlikitla isivumelwano sokurekhoda ne-Universal Music Records ngomnyaka wee-2015 begodu wakhupha i-albhamu yakhe yokuthoma ''i-Ushun Wenkabi'' ngenyanga ka Velabahlinze ngomnyaka wee-2018, eneengoma ezifaka hlangana &quot;u-Ang'mazi umama&quot; no-&quot;Home&quot;. 

I-albhamu yakhe yesibili ye-studio ''u-Ungqongqoshe Wongqongqoshe'' yakhutjhwa ngomnyaka wee-2019,  ihlanganisa u-Ab Crazy, u-Mnqobi Yazo, u-FiFi Cooper, u-Kwesta, no [[Cassper Nyovest|Caspper Nyovest]], u-Musiholiq no-Truhitz.  Ingoma ephambili ethi &quot;Ak'laleki&quot; eno-Kwesta yakhutjhwa. Mhlana amalanga amabili kuRhoboyi ingoma yakhe yesibili ethi &quot;Ama Million&quot; eno- Cassper Nyovest &amp; Musiholiq yakhutjhwa begodu yafika endaweni yesihlanu ku-iTunes Chart.   Ingoma le beyiqinisekiswe njengeplatinamu.   Mhlana amalanga ali-14 kuRhoboyi, ingoma yakhe yesithathu ethi &quot;Vuma dlozi&quot; ehlanganisa u-Mnqobi Yazo yakhutjhwa  begodu yaqinisekiswa yi-platinamu yibubulo lokurekhoda leSewula Afrika (i-RiSA) ngokuthengisa amakhophi ama-50 000. &lt;ref name=&quot;ubetoo&quot; /&gt; I-albhamu le yaqinisekiswa njengegolide yi-Recording Industry of South Africa (RiSA)  begodu yathola ukukhethwa ku- South African Music Awards (SAMA26)  ye-Best Hip Hop Album.  Ngomnyaka ofanako, wee-2019, i-albhamu leyo yakhethwa njenge-Best Male Artist of the Year kanye ne-albhamu yomnyaka e -South African Hip Hop Awards.  Wasungula ilebula yakhe yamarekhodi i-Nkabi Records. 

=== 2020–2022: ''Ichwane Lenyoka'', ''Nkabi Nation'' ===
Mhlana amalanga ama-20 kuNobayeni ngomnyaka wee- 2020, ingoma yakhe ethi &quot; Mali Eningi &quot; yakhutjhwa ifaka hlangana umvumi ongu Intaba Yase Dubai no-Ricky Rick njengengoma ephambili ye-albhamu. Ingoma le yavela endaweni yesibili kumatjhadi we ''-Channel 0'' Top 30  begodu yaqinisekiswa njenge-double platinum.  Emnyanyeni we -27th annual South African Music Awards,ingoma i  &quot;Mali Eningi&quot; yathumba isigaba sokubambisana okuhle khulu.  Ekupheleni komnyaka wee-2020 wakhethwa kokuthoma ku -MTV Base: SA's Hottest MCs, endaweni yesihlanu. 

Ngasekupheleni kukaTjhirhweni ngomnyaka wee-2021, wamemezela ukusebenza kwe-albhamu yakhe yesithathu.   

Mhlana amalanga ali-11 kuNtaka ngomnyaka wee-2021, wakhupha ingoma &quot;Inhlupheko&quot; eno Mduduzi Ncube njengengoma yesibili.  Ingoma le yafika endaweni yokuthoma ematjhadini we-iTunes weSewula Afrika begodu yafika endaweni yesine ematjhadini we-Shazam. 

Mhlana amalanga amathathu kuNtaka ngomnyaka wee-2021, wamemezela ingoma etja ebizwa ngokuthi &quot;Umuzi eSandton&quot; ehlanganisa u-Lwah Ndlunkulu ku -Twitter.  Ingoma le yakhutjhwa mhlana amalanga alithoba kuNtaka ngomnyaka wee-2021;  Yavezwa ku-albhamu yakhe ''i-Ichwane Lenyoka'', eyakhutjhwa mhlana amalanga amathathu kuNobayeni 2021.  Ingoma ethi &quot;Umuzi eSandton&quot; yafika endaweni yokuthoma ematjhadini we-Shazam. 

Mhlana amalanga ali-13 kuNobayeni ngomnyaka wee-2021, wenza isizini yetjhumi nane ku- ''Idols South Africa.''  UZulu uthumbe imitlomelo elikhomba efaka hlangana; I-albhamu yomnyaka, ingoma yomnyaka (&quot; Mali Eningi &quot;), ividiyo yomculo ehle khulu, umvuzo we-Best Male and Ubuntu Activism, Best Collaboration, kanye no-Best Digital Sales kuma -2021 South African Hip Hop Awards.  Ekupheleni komnyaka wee-2021 wakhethwa godu ku-MTV Base: SA's Hottest MCs, wakhuphukela endaweni yesibili. 

I-&quot;iVolovolo&quot; eno Xowla yakhutjhwa mhlana amalanga alitjhumi nanye kuMhlolanja ngomnyaka wee-2022. Ingoma le yathoma ukudlala phambili eSewula Afrika.  

I-&quot;Voicemail&quot; ka-Big Zulu, Mduduzi Ncube, Lwah Ndlunkulu, Siya Ntuli no-Xowla yakhutjhwa njengengoma ephambili ye-albhamu mhlana amalanga ama-24 kuMgwengweni ngonyaka wee-2022.  Ingoma le yaqinisekiswa njengegolide begodu yafika endaweni yokuthoma eSewula Afrika.  

Wakhupha  i-&quot;150 Bars (Ke hip hop Dawg)&quot; mhlana amalanga ama-20 kuRhoboyi ngomnyaka wee-2022. Ingoma le yangena ematjhadini we-Local Top 10 Radio endawen&quot;i yesikhombisa. 

Wamemezela  ilanga lokukhutjhwa kwama-albhamu kanye irhelo lokugcina lwengoma ku-Instagram, ekhutjhwe mhlana amalanga alithoba kuNobayeni ngomnyaka wee-2022. 

&quot;Dear My Love&quot; ehlanganisa u KO, Xowla no-Siya Ntuli ingoma eyodwa ka-Big Zulu ekhutjhwe mhlazi-25 kuNobayeni 2022.

=== 2023-nje: Inkabi Zezwe, ''Ukhamba'', ''Ngises' Congweni'' ===
Mhlana amalanga ali-17 kuNtaka 2023, u-Big Zulu no-Sjava bamemezela ukusebenza nge-albhamu yabo ehlangeneko ''i-Ukhamba'' njenge-duo Inkabi Zezwe . &quot; Umbayimbayi &quot; yakhutjhwa mhlana amalanga ama-24 kuNtaka ngomnyaka wee-2023 njengengoma ephambili ye-albhamu.  Ingoma le yavela kuyingoma yokuthoma ku-iTunes Top 50 kanye ne-Spotify Top 100 South Africa ngokulandelana.  Ingoma le yaqinisekiswa njenge-3× Platinum eSewula Afrika. Kube khona ingoma lapho asebenzisana no [[Mlindo the Vocalist]] kanye no Makhadzi ku albhumi ethi ngises' congweni.   

Mhlana kuthoma inyanga kaMrhayili, u-Zulu wamemezela i-Inkabi Zezwe Tour eyathoma ngoMgwengweni bekwaba nguNobayeni ngomnyaka wee-2023.

I-albhamu le yakhutjhwa mhlana amalanga ali-12 kuMrhayili ngomnyaka wee-2023. Yaba yinto yokuthoma emazweni amabili weSewula Afrika ne-Eswatini ngokulandelana. 

Ngasekupheleni kukaTjhirhweni ngomnyaka wee-2024, uZulu wamemezela ukusebenza nge-albhamu yakhe yesine ye-studio kanye ne-albhamu yakhe ephambili &quot;Awufuni Ukung' Qoma&quot;. ''I-Ngises' Congweni'' yakhutjhwa mhlana amalanga ama-27 kuNtaka ngomnyaka wee- 2023.    

=== Umabonakude ===
Ngenyanga kaMgwengweni ngomnyaka wee-2024, uZulu wangenela  umdlalo wokufuna amathalenta ''u-Ushuni Womhlaba'', njengomahluleli  ku-SABC 1 mhlana amalanga alikhomba kuNtaka. 

=== Amanye amabubulo ===
Ngomnyaka wee-2019, uZulu wasungula ilebula yamarekhodi i-Inkabi Records.  UZulu sele asayine uMduduzi Ncube, uLwah Ndlunkulu, uXowla no Siya Ntuli. 

Mhlana amalanga ama-21 kuNobayeni ngomnyaka wee-2021, uZulu wathoma ukusiza abantu abadla imbuya ngelithi begodu wanikela ngemitjhininqondo namaphrinta e-Obonjaneni Primary School. 

Kusukela ngoRhoboyi ngomnyaka wee- 2020, wasebenzisana nestolo i Spitz njengomsekeli (ambassador) we-Carvela.  

== I-Discography ==

=== Ama-albhamu we-studio ===

* ''Ushun Wenkabi'' (2018)
* ''Ungqongqoshe Wongqongqoshe'' (2019)
* ''Ichwane Lenyoka'' (2021) 
* ''Ngises' Congweni'' (2024)
* ''Icala Le Mpumelelo'' (2025)

=== Ama-albhamu wokubambisana ===

* ''Inkabi Nation'' (2022)
* ''Ukhamba'' (2023)

=== Njengomdosi phambili kwezomvumo ===
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+Irhelo lama-single njengabaculi abadosa phambili, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;AmaMillion&quot; ene-Musiholiq, Cassper Nyovest
| 2019
|
| Iplatinamu 
| rowspan=&quot;2&quot; | ''Ngqongqoshe Wongqongqoshe''
|-
! scope=&quot;row&quot; | &quot;Vuma Dlozi&quot; ehlanganisa uMnqobi Yazo
| 2020
|
| Iplatinamu &lt;ref name=&quot;DailySUN&quot; /&gt;
|-
! scope=&quot;row&quot; | &quot; Mali Eningi &quot; ehlanganisa u-Ntaba Yase Dubai, u-Ricky Rick
| rowspan=&quot;3&quot; | 2021
| 2
| 2× Iplatinamu
| rowspan=&quot;4&quot; | ''Ichwane Lenyoka''
|-
! scope=&quot;row&quot; | &quot;Umuzi eSandton&quot; nge- Lwah Ndlunkulu
| —
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;Inhlupheko&quot; ehlanganisa uMduduzi Ncube
| 1
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;iVolovolo&quot; ene-Xowla
| 2022
| —
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;Dear My Love&quot; ene-Xowla, KO no -Siya Ntuli
| 2022
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Awufuni Ukung' Qoma&quot;
| rowspan=&quot;3&quot; | 2024
| —
|
| ''UCongweni kaNgises''
|-
! scope=&quot;row&quot; | &quot;200 Bars&quot;
| — 
||{{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ay Ka'Ncane&quot; (Big Zulu, Tony Dayimane)
| — 
||{{non-album single}} 
|-
! scope=&quot;row&quot; | &quot;Amacala Othando&quot; (Big Zulu, Azana, Malungelo)
| rowspan=&quot;2&quot; | 2025
| — 
||{{non-album single}} 
|-
! scope=&quot;row&quot; | &quot;Abazazi Bafunani&quot; (ehlanganisa u-Emtee )
| 2 
|
| Icala Le Mpumelelo
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; | &quot;—&quot; kutjho ukurekhoda okungazange kushadi namkha okungakakhutjhwa endaweni leyo.
|}
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center&quot;
|+Irhelo lazingoma azihlanganyele nabanye njengabaculi abaveziweko, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;Isigingci&quot; (Mduduzi ehlanganisa uBig Zulu)
| 2020
| —
|
| ''Isitimela''
|-
! scope=&quot;row&quot; | &quot;Alusafani&quot; ( Qwabe Twins featuring Big Zulu, Mduduzi, Xowla)
| rowspan=&quot;2&quot; | 2021
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Qoma&quot; ( Blaq Diamond nge-Siya Ntuli, Big Zulu)
| —
| I-RiSA: Iplatinamu 
| Ithando lesiZulu
|-
! scope=&quot;row&quot; | &quot;Amalobolo&quot; ( u-Nomfundo Moh ohlanganisa u-Big Zulu)
| 2023
| —
|
| ''Ugcobo''
|-
! scope=&quot;row&quot; | &quot;Beng' dakiwe (u-Xowla ahlanganisa u-Big Zulu, u-DJ Tira )
| rowspan=&quot;2&quot; | 2023
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;My Ex&quot; (Big Xhosa featuring Big Zulu)
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Mfazi Wephepha&quot; (Nkosazana Daughter, Master Kg featuring Big Zulu, Zee Nxumalo )
| 2024
| 4 
|
| ''Makhelwane''
|}

== Imitlomelo nokuphakanyiswa ==
{| class=&quot;wikitable&quot;
!Umnyaka
! Umtlomelo
! Umkhakha
! Imiphumela
! Ref.
|-
| rowspan=&quot;3&quot; | 2019
| rowspan=&quot;2&quot; | SAHHA
| I-albhamu yomnyaka| {{nom}}
| rowspan=&quot;2&quot; |  
|-
| Umdwebi wesilisa ophuma phambili womnyaka|{{nom}}
|-
| I-SAMA 26
| I-albhamu ye-Hip Hop ehle khulu| {{nom}}
|  
|-
| 2020
| SAHHA
| I-Remix ehle khulu| {{Nom}}
| 
|-
| 2021
| I-SAMA 27
| Ukusebenzisana okuhle khulu|{{won}}
|  
|-
| rowspan=&quot;8&quot; | 2021
| rowspan=&quot;8&quot; | I-SAHHA 10
| I-albhamu yomnyaka|{{won}}
| rowspan=&quot;8&quot; |  
|-
| Owesilisa ophuma phambili|{{won}}
|-
| Ingoma yomnyaka|{{won}}
|-
| Ukusebenzisana okuhle khulu|{{won}}
|-
| I-MVP/Umtjhayeli womnyaka|{{nom}}
|-
| Ividiyo ehle khulu|{{won}}
|-
| Umvuzo we-Ubuntu Activism|{{won}}
|-
| Ukuthengisa okuhle khulu kwedijithali|{{won}}
|-
| rowspan=&quot;2&quot; | 2022
| rowspan=&quot;2&quot; | DStv MVCA
| Ingoma engiyithandako| {{nom}}
| rowspan=&quot;2&quot; | 
|-
| Umculi womculo othandwako/isiqhema|{{nom}}
|-
| 2023
| 17th Metro FM Music Awards
| I-Duo/Isiqhema esihle khulu |{{Won}} 
|
|}

== UMTHOMBO LWAZI ==
&lt;references responsive=&quot;&quot; /&gt;</text>
      <sha1>jdoydit4vthonj3jegtlym0oquw78p4</sha1>
    </revision>
    <revision>
      <id>5634</id>
      <parentid>5626</parentid>
      <timestamp>2025-09-04T10:47:16Z</timestamp>
      <contributor>
        <username>Kholeka19721</username>
        <id>889</id>
      </contributor>
      <minor />
      <comment>added a link</comment>
      <origin>5634</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="13774" sha1="iqqj3sdp6roe39o3vulpqbjevm136ju" xml:space="preserve">
'''BIG ZULU'''                         
[[Isimumathi:Big zulu.jpg|thumb|BIG ZULU|583x583px]]
'''IMINININGWANA YANGEMUVA'''

'''IBIZO:'''  Siyabonga Nene

'''UKUBELETHWA:'''  7 KuSihlabantangana 1986

'''UMSEBENZI:''' Umrepha, umtloli weengoma

'''UNYAKA WOKUDUMA:''' 2003- njenganje

'''AMALEBULA:''' Universal Records(kwangaphambilini), Nkabi Records.

'''USiyabonga Nene''' (wabelethwa mhlana amalanga alikhomba, kuMrhayili ngomnyaka we-1986  )&lt;ref&gt;{{Cite web |last=Mag |first=SA Hip Hop |date=2021-04-07 |title=Happy Birthday Big Zulu! A Look Into Big Zulu's Best Selling Records |url=https://sahiphopmag.co.za/2021/04/happy-birthday-big-zulu-a-look-into-big-zulus-best-selling-records/ |access-date=2025-09-04 |website=SA Hip Hop Mag |language=en-US}}&lt;/ref&gt;&lt;ref&gt;{{Citation |last=Ladson-Billings |first=Gloria |title=From Big Homie the O.G., to GLB |date=2018-03-23 |work=#HipHopEd: The Compilation on Hip-hop Education |pages=21–26 |url=https://doi.org/10.1163/9789004371873_003 |access-date=2025-09-04 |publisher=BRILL |isbn=978-90-04-37187-3}}&lt;/ref&gt;
, owaziwa ngebizo elibizwa laka '''Big Zulu''', mrepha nomtloli weengoma we[[Isewula Afrika|Sewula Afrika]].  Waphakama ngemva kokukhipha ingoma ethi &quot;Donsa Nkabi&quot; ngomnyaka wee-2016.

Watlikitla isivumelwano sokurekhoda ne -Universal Music ngomnyaka wee- 2015 begodu  wakhipha i-albhamu yakhe yokuthoma, ''u-Ushun Wenkabi'' (2018) no ''-Ungqongqoshe Wongqongqoshe'' (2019).

I-albhamu yesithathu ka Big Zulu ''Ichwane Lenyoka'' (2021), yakhiqiza ama-single amathathu aphuma phambili &quot; Mali Eningi &quot;, &quot;Inhlupheko&quot; kanye no-&quot;Umuzi eSandton&quot;. Ingoma yayo ephambili &quot;i-Mali Eningi&quot;, yaqinisekiswa yi-double platinum yi- Recording Industry of South Africa (RiSA). 

[[Big Zulu|UBig Zulu]] wabuye wavela emidlalweni kamabonakude ''i-Isibaya'', ''One Mic'' (2017-2020),  ''Uzalo'' (2020), ''Isithembiso'', kanye ''no-Ushuni Womhlaba'' (2024).  Imitlomelo  yakhe ifaka hlangana imitlomelo  ye-Hip Hop yeSewula Afrika elikhomba, umtlomelo  owodwa we-South African Music Award kanye ne-Metro FM Music Awards eyodwa.

== Ipilo yokuthoma ==
USiyabonga Nene wabelethwa begodu wakhulela e -Bergville, KwaZulu-Natal. Wakhula alalele umvumo ka -Maskandi no-Isichathamiya, athonywa yi Ladysmith Black Mambazo, Phuzekemisi no-Imithente. Dacre, Richard (2015-05-28), &quot;Worth, Harry [real name Harry Bourlon Illingsworth] (1917–1989), comedian&quot;, Oxford Dictionary of National Biography, Oxford University Press, ISBN 978-0-19-861412-8, retrieved 2025-09-04

== IIMVELAPHI YOBUVUMO ==

=== Izithonyo ===
Uthonywe ngu-Maskandi nesi Scathamiya.  Bekahlala e-Vaal endaweni ebizwa nge-Palm Springs.

== Ibizelo ==

=== Ukuthoma komsebenzi ===
UZulu wahlala iminyaka eminengi amtjhayeli wetekisi begodu watjhiya ngomnyaka wee-2008 ukobana aragele phambili nomsebenzi wakhe wezomvumo. Ngomnyaka wee-2009, ngemva kobana atjhiye ibubulo lamathekisi wathoma ukutlola iingoma nokudlala.

Ngemva kweminyaka emine ngomnyaka wee-2013, uZulu waphalisana begodu waba ngowokuthoma ukuthumba iphalisano le Red Bull Back to the city.  Ingoma yakhe yokuthoma ethi &quot;Donsa Nkabi&quot; yakhutjhwa ngomnyaka wee-2016. 

=== 2014–2019: ''Ushun Wenkabi'', ''Ungqongqoshe Wongqongqoshe'' ===
Ngemva kweminyaka eminengi njengomvumi ozijameleko, watlikitla isivumelwano sokurekhoda ne-Universal Music Records ngomnyaka wee-2015 begodu wakhupha i-albhamu yakhe yokuthoma ''i-Ushun Wenkabi'' ngenyanga ka Velabahlinze ngomnyaka wee-2018, eneengoma ezifaka hlangana &quot;u-Ang'mazi umama&quot; no-&quot;Home&quot;. 

I-albhamu yakhe yesibili ye-studio ''u-Ungqongqoshe Wongqongqoshe'' yakhutjhwa ngomnyaka wee-2019,  ihlanganisa u-Ab Crazy, u-Mnqobi Yazo, u-FiFi Cooper, u-Kwesta, no [[Cassper Nyovest|Caspper Nyovest]], u-Musiholiq no-Truhitz.  Ingoma ephambili ethi &quot;Ak'laleki&quot; eno-Kwesta yakhutjhwa. Mhlana amalanga amabili kuRhoboyi ingoma yakhe yesibili ethi &quot;Ama Million&quot; eno- Cassper Nyovest &amp; Musiholiq yakhutjhwa begodu yafika endaweni yesihlanu ku-iTunes Chart.   Ingoma le beyiqinisekiswe njengeplatinamu.   Mhlana amalanga ali-14 kuRhoboyi, ingoma yakhe yesithathu ethi &quot;Vuma dlozi&quot; ehlanganisa u-Mnqobi Yazo yakhutjhwa  begodu yaqinisekiswa yi-platinamu yibubulo lokurekhoda leSewula Afrika (i-RiSA) ngokuthengisa amakhophi ama-50 000. &lt;ref name=&quot;ubetoo&quot; /&gt; I-albhamu le yaqinisekiswa njengegolide yi-Recording Industry of South Africa (RiSA)  begodu yathola ukukhethwa ku- South African Music Awards (SAMA26)  ye-Best Hip Hop Album.  Ngomnyaka ofanako, wee-2019, i-albhamu leyo yakhethwa njenge-Best Male Artist of the Year kanye ne-albhamu yomnyaka e -South African Hip Hop Awards.  Wasungula ilebula yakhe yamarekhodi i-Nkabi Records. 

=== 2020–2022: ''Ichwane Lenyoka'', ''Nkabi Nation'' ===
Mhlana amalanga ama-20 kuNobayeni ngomnyaka wee- 2020, ingoma yakhe ethi &quot; Mali Eningi &quot; yakhutjhwa ifaka hlangana umvumi ongu Intaba Yase Dubai no-Ricky Rick njengengoma ephambili ye-albhamu. Ingoma le yavela endaweni yesibili kumatjhadi we ''-Channel 0'' Top 30  begodu yaqinisekiswa njenge-double platinum.  Emnyanyeni we -27th annual South African Music Awards,ingoma i  &quot;Mali Eningi&quot; yathumba isigaba sokubambisana okuhle khulu.  Ekupheleni komnyaka wee-2020 wakhethwa kokuthoma ku -MTV Base: SA's Hottest MCs, endaweni yesihlanu. 

Ngasekupheleni kukaTjhirhweni ngomnyaka wee-2021, wamemezela ukusebenza kwe-albhamu yakhe yesithathu.   

Mhlana amalanga ali-11 kuNtaka ngomnyaka wee-2021, wakhupha ingoma &quot;Inhlupheko&quot; eno Mduduzi Ncube njengengoma yesibili.  Ingoma le yafika endaweni yokuthoma ematjhadini we-iTunes weSewula Afrika begodu yafika endaweni yesine ematjhadini we-Shazam. 

Mhlana amalanga amathathu kuNtaka ngomnyaka wee-2021, wamemezela ingoma etja ebizwa ngokuthi &quot;Umuzi eSandton&quot; ehlanganisa u-Lwah Ndlunkulu ku -Twitter.  Ingoma le yakhutjhwa mhlana amalanga alithoba kuNtaka ngomnyaka wee-2021;  Yavezwa ku-albhamu yakhe ''i-Ichwane Lenyoka'', eyakhutjhwa mhlana amalanga amathathu kuNobayeni 2021.  Ingoma ethi &quot;Umuzi eSandton&quot; yafika endaweni yokuthoma ematjhadini we-Shazam. 

Mhlana amalanga ali-13 kuNobayeni ngomnyaka wee-2021, wenza isizini yetjhumi nane ku- ''Idols South Africa.''  UZulu uthumbe imitlomelo elikhomba efaka hlangana; I-albhamu yomnyaka, ingoma yomnyaka (&quot; Mali Eningi &quot;), ividiyo yomculo ehle khulu, umvuzo we-Best Male and Ubuntu Activism, Best Collaboration, kanye no-Best Digital Sales kuma -2021 South African Hip Hop Awards.  Ekupheleni komnyaka wee-2021 wakhethwa godu ku-MTV Base: SA's Hottest MCs, wakhuphukela endaweni yesibili. 

I-&quot;iVolovolo&quot; eno Xowla yakhutjhwa mhlana amalanga alitjhumi nanye kuMhlolanja ngomnyaka wee-2022. Ingoma le yathoma ukudlala phambili eSewula Afrika.  

I-&quot;Voicemail&quot; ka-Big Zulu, Mduduzi Ncube, Lwah Ndlunkulu, Siya Ntuli no-Xowla yakhutjhwa njengengoma ephambili ye-albhamu mhlana amalanga ama-24 kuMgwengweni ngonyaka wee-2022.  Ingoma le yaqinisekiswa njengegolide begodu yafika endaweni yokuthoma eSewula Afrika.  

Wakhupha  i-&quot;150 Bars (Ke hip hop Dawg)&quot; mhlana amalanga ama-20 kuRhoboyi ngomnyaka wee-2022. Ingoma le yangena ematjhadini we-Local Top 10 Radio endawen&quot;i yesikhombisa. 

Wamemezela  ilanga lokukhutjhwa kwama-albhamu kanye irhelo lokugcina lwengoma ku-Instagram, ekhutjhwe mhlana amalanga alithoba kuNobayeni ngomnyaka wee-2022. 

&quot;Dear My Love&quot; ehlanganisa u KO, Xowla no-Siya Ntuli ingoma eyodwa ka-Big Zulu ekhutjhwe mhlazi-25 kuNobayeni 2022.

=== 2023-nje: Inkabi Zezwe, ''Ukhamba'', ''Ngises' Congweni'' ===
Mhlana amalanga ali-17 kuNtaka 2023, u-Big Zulu no-Sjava bamemezela ukusebenza nge-albhamu yabo ehlangeneko ''i-Ukhamba'' njenge-duo Inkabi Zezwe . &quot; Umbayimbayi &quot; yakhutjhwa mhlana amalanga ama-24 kuNtaka ngomnyaka wee-2023 njengengoma ephambili ye-albhamu.  Ingoma le yavela kuyingoma yokuthoma ku-iTunes Top 50 kanye ne-Spotify Top 100 South Africa ngokulandelana.  Ingoma le yaqinisekiswa njenge-3× Platinum eSewula Afrika. Kube khona ingoma lapho asebenzisana no [[Mlindo the Vocalist]] kanye no Makhadzi ku albhumi ethi ngises' congweni.   

Mhlana kuthoma inyanga kaMrhayili, u-Zulu wamemezela i-Inkabi Zezwe Tour eyathoma ngoMgwengweni bekwaba nguNobayeni ngomnyaka wee-2023.

I-albhamu le yakhutjhwa mhlana amalanga ali-12 kuMrhayili ngomnyaka wee-2023. Yaba yinto yokuthoma emazweni amabili weSewula Afrika ne-Eswatini ngokulandelana. 

Ngasekupheleni kukaTjhirhweni ngomnyaka wee-2024, uZulu wamemezela ukusebenza nge-albhamu yakhe yesine ye-studio kanye ne-albhamu yakhe ephambili &quot;Awufuni Ukung' Qoma&quot;. ''I-Ngises' Congweni'' yakhutjhwa mhlana amalanga ama-27 kuNtaka ngomnyaka wee- 2023.    

=== Umabonakude ===
Ngenyanga kaMgwengweni ngomnyaka wee-2024, uZulu wangenela  umdlalo wokufuna amathalenta ''u-Ushuni Womhlaba'', njengomahluleli  ku-SABC 1 mhlana amalanga alikhomba kuNtaka. 

=== Amanye amabubulo ===
Ngomnyaka wee-2019, uZulu wasungula ilebula yamarekhodi i-Inkabi Records.  UZulu sele asayine uMduduzi Ncube, uLwah Ndlunkulu, uXowla no Siya Ntuli. 

Mhlana amalanga ama-21 kuNobayeni ngomnyaka wee-2021, uZulu wathoma ukusiza abantu abadla imbuya ngelithi begodu wanikela ngemitjhininqondo namaphrinta e-Obonjaneni Primary School. 

Kusukela ngoRhoboyi ngomnyaka wee- 2020, wasebenzisana nestolo i Spitz njengomsekeli (ambassador) we-Carvela.  

== I-Discography ==

=== Ama-albhamu we-studio ===

* ''Ushun Wenkabi'' (2018)
* ''Ungqongqoshe Wongqongqoshe'' (2019)
* ''Ichwane Lenyoka'' (2021) 
* ''Ngises' Congweni'' (2024)
* ''Icala Le Mpumelelo'' (2025)

=== Ama-albhamu wokubambisana ===

* ''Inkabi Nation'' (2022)
* ''Ukhamba'' (2023)

=== Njengomdosi phambili kwezomvumo ===
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+Irhelo lama-single njengabaculi abadosa phambili, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;AmaMillion&quot; ene-Musiholiq, Cassper Nyovest
| 2019
|
| Iplatinamu 
| rowspan=&quot;2&quot; | ''Ngqongqoshe Wongqongqoshe''
|-
! scope=&quot;row&quot; | &quot;Vuma Dlozi&quot; ehlanganisa uMnqobi Yazo
| 2020
|
| Iplatinamu &lt;ref name=&quot;DailySUN&quot; /&gt;
|-
! scope=&quot;row&quot; | &quot; Mali Eningi &quot; ehlanganisa u-Ntaba Yase Dubai, u-Ricky Rick
| rowspan=&quot;3&quot; | 2021
| 2
| 2× Iplatinamu
| rowspan=&quot;4&quot; | ''Ichwane Lenyoka''
|-
! scope=&quot;row&quot; | &quot;Umuzi eSandton&quot; nge- Lwah Ndlunkulu
| —
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;Inhlupheko&quot; ehlanganisa uMduduzi Ncube
| 1
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;iVolovolo&quot; ene-Xowla
| 2022
| —
| Iplatinamu
|-
! scope=&quot;row&quot; | &quot;Dear My Love&quot; ene-Xowla, KO no -Siya Ntuli
| 2022
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Awufuni Ukung' Qoma&quot;
| rowspan=&quot;3&quot; | 2024
| —
|
| ''UCongweni kaNgises''
|-
! scope=&quot;row&quot; | &quot;200 Bars&quot;
| — 
||{{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Ay Ka'Ncane&quot; (Big Zulu, Tony Dayimane)
| — 
||{{non-album single}} 
|-
! scope=&quot;row&quot; | &quot;Amacala Othando&quot; (Big Zulu, Azana, Malungelo)
| rowspan=&quot;2&quot; | 2025
| — 
||{{non-album single}} 
|-
! scope=&quot;row&quot; | &quot;Abazazi Bafunani&quot; (ehlanganisa u-Emtee )
| 2 
|
| Icala Le Mpumelelo
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; | &quot;—&quot; kutjho ukurekhoda okungazange kushadi namkha okungakakhutjhwa endaweni leyo.
|}
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center&quot;
|+Irhelo lazingoma azihlanganyele nabanye njengabaculi abaveziweko, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;Isigingci&quot; (Mduduzi ehlanganisa uBig Zulu)
| 2020
| —
|
| ''Isitimela''
|-
! scope=&quot;row&quot; | &quot;Alusafani&quot; ( Qwabe Twins featuring Big Zulu, Mduduzi, Xowla)
| rowspan=&quot;2&quot; | 2021
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Qoma&quot; ( Blaq Diamond nge-Siya Ntuli, Big Zulu)
| —
| I-RiSA: Iplatinamu 
| Ithando lesiZulu
|-
! scope=&quot;row&quot; | &quot;Amalobolo&quot; ( u-Nomfundo Moh ohlanganisa u-Big Zulu)
| 2023
| —
|
| ''Ugcobo''
|-
! scope=&quot;row&quot; | &quot;Beng' dakiwe (u-Xowla ahlanganisa u-Big Zulu, u-DJ Tira )
| rowspan=&quot;2&quot; | 2023
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;My Ex&quot; (Big Xhosa featuring Big Zulu)
| — 
||{{N/A|Non-album single}}
|-
! scope=&quot;row&quot; | &quot;Mfazi Wephepha&quot; (Nkosazana Daughter, Master Kg featuring Big Zulu, Zee Nxumalo )
| 2024
| 4 
|
| ''Makhelwane''
|}

== Imitlomelo nokuphakanyiswa ==
{| class=&quot;wikitable&quot;
!Umnyaka
! Umtlomelo
! Umkhakha
! Imiphumela
! Ref.
|-
| rowspan=&quot;3&quot; | 2019
| rowspan=&quot;2&quot; | SAHHA
| I-albhamu yomnyaka| {{nom}}
| rowspan=&quot;2&quot; |  
|-
| Umdwebi wesilisa ophuma phambili womnyaka|{{nom}}
|-
| I-SAMA 26
| I-albhamu ye-Hip Hop ehle khulu| {{nom}}
|  
|-
| 2020
| SAHHA
| I-Remix ehle khulu| {{Nom}}
| 
|-
| 2021
| I-SAMA 27
| Ukusebenzisana okuhle khulu|{{won}}
|  
|-
| rowspan=&quot;8&quot; | 2021
| rowspan=&quot;8&quot; | I-SAHHA 10
| I-albhamu yomnyaka|{{won}}
| rowspan=&quot;8&quot; |  
|-
| Owesilisa ophuma phambili|{{won}}
|-
| Ingoma yomnyaka|{{won}}
|-
| Ukusebenzisana okuhle khulu|{{won}}
|-
| I-MVP/Umtjhayeli womnyaka|{{nom}}
|-
| Ividiyo ehle khulu|{{won}}
|-
| Umvuzo we-Ubuntu Activism|{{won}}
|-
| Ukuthengisa okuhle khulu kwedijithali|{{won}}
|-
| rowspan=&quot;2&quot; | 2022
| rowspan=&quot;2&quot; | DStv MVCA
| Ingoma engiyithandako| {{nom}}
| rowspan=&quot;2&quot; | 
|-
| Umculi womculo othandwako/isiqhema|{{nom}}
|-
| 2023
| 17th Metro FM Music Awards
| I-Duo/Isiqhema esihle khulu |{{Won}} 
|
|}

== UMTHOMBO LWAZI ==
&lt;references responsive=&quot;&quot; /&gt;</text>
      <sha1>iqqj3sdp6roe39o3vulpqbjevm136ju</sha1>
    </revision>
  </page>
  <page>
    <title>Zee Nxumalo</title>
    <ns>0</ns>
    <id>924</id>
    <revision>
      <id>5482</id>
      <timestamp>2025-09-04T08:48:21Z</timestamp>
      <contributor>
        <username>Sister01</username>
        <id>893</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1308261202|Zee Nxumalo]]&quot;</comment>
      <origin>5482</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7918" sha1="s1s6n9eahja1ycat6pm8fur94z1urlz" xml:space="preserve">

 

'''U-Zandile Nxumalo''' (wabelethwa mhlana ali-6 kuTjhirhweni 2003  ) owaziwa nge- '''Zee Nxumalo''', mhlabeleli nomtloli weengoma we-Swazi-Sewula Afrika.   Ingoma yakhe ethi &quot;Funk 55&quot;, eyakhutjhwa ngo-2023, yamenza waba yipumelelo ekulu begodu yaqinisekiswa njenge-5× Platinum eSewula Afrika.  

== Ipilo yokuthoma ==
UZandile Nxumalo wabelethwa mhlana amalanga asi-6 kuTjhirhweni ngomnyaka ka 2003 e [[Eswatini|-Eswatini]] .  Umndeni wakhe wathuthela e -Alexandra, e-Goli lapho ahlala khona ebuntwaneni bakhe. &lt;ref name=&quot;online&quot; /&gt; 

== Ibizelo ==
Umdlalo wakhe wokuthoma we ''-KwaNxumalo'', wakhutjhwa mhlazi-28 kuMgwengweni 2022.   &quot;U-Funk 55&quot; ka-Shakes &amp; Les, u-DBN Gogo no-Zee Nxumalo ohlanganisa u-Ceeka RSA no-Chley wakhutjhwa mhlana ali-1 kuNobayeni 2023. Wathoma ukuvezwa ku-  2 Local St. Ingoma yakhe ''i-Thula Mabota'' no-Pabi Cooper no-031choppa, ene-Shakes &amp; Les. yakhutjhwa mhlana amalanga ama-29 kuNtaka 2024. Yaqinisekiswa njengeplatinamu eSewula Afrika. 

Wabuye wavela ku-Ama Gear no -Dlala Thukzin kanye ne-Funky QLA, ehlanganisa i-MK Productions, ekhutjhwe mhlazi-5 kuNtaka 2024. Ingoma le yathoma ukuvela endaweni yesi-5 ku-Local Streaming Top 10.  Ekuthomeni kwakaMgwengweni 2024, wamemezela umdlalo wakhe we- ''Inja Ye Game'', okhutjhwe mhlana amalanga ali-15 kuNobayeni 2024   &quot;Malume&quot; no-Djy Biza no-031 Choppa, okufaka hlangana u-Springle no- DJ Tira, yakhutjhwa mhlana amalanga ama-26 kuNobayeni 2024, njengengoma ephambili.

== Imivumo ayiqula ayedwa ==

=== Njengomdwebi odosa phambili ===
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+List of singles as lead artist, with selected chart positions and certifications, showing year released and album name
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Title
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Year
! colspan=&quot;1&quot; scope=&quot;col&quot; |Peak chart positions
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; |Certifications
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Album
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; |ZA&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; |&quot;Siyajola&quot;
| rowspan=&quot;2&quot; |2022
|—
|
| rowspan=&quot;2&quot; |''KwaNxumalo''
|-
! scope=&quot;row&quot; |&quot;Hamba&quot;
|—
|
|-
! scope=&quot;row&quot; |&quot;Sobabili&quot; (Zee Nxumalo, Profound, MFR Souls)
| rowspan=&quot;2&quot; |2023
|—
|
|''KwaNxumalo (Deluxe)''
|-
! scope=&quot;row&quot; |&quot; Funk 55&quot; (Shake &amp; Les, DBN Gogo, Zee Nxumalo featuring Ceeka RSA, Chley)
|1
|5× Platinum
|''Funk Series''
|-
! scope=&quot;row&quot; |&quot;Uyang'user&quot; (Tranquillo, Zee Nxumalo, Khanyisa featuring Chley &amp; Rif effect)
| rowspan=&quot;9&quot; |2024
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Thula Mabota&quot; (Zee Nxumalo, Pabi Cooper, 031choppa featuring Shakes &amp; Les)
|
|Platinum
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Chengu Shesha&quot; (DJ Tshegu, Leemckrazy, Zee Nxumalo featuring Al Xapo, Vyno Keys &amp; QuayR Musiq)
|—
|
|
|-
! scope=&quot;row&quot; |&quot;Abantu&quot; (Piano City, Marlode &amp; Owams, Zee Nxumalo featuring Leemckrazy, FLUXX)
|—
|
|
|-
! scope=&quot;row&quot; |&quot;Ama Gear (Edit)&quot; (Dlala Thukzin, Funky Qla, Zee Nxumalo featuring MK Productions)
|5
|
|{{non-album single}}
|-
! scope=&quot;row&quot; |&quot;Ngisakuthanda&quot; (featuring PYY Log Drum King, Dj Tearz, Dr Thulz)
|1
|RiSA: 3x platinum
| rowspan=&quot;3&quot; |''Inja Ye Game''
|-
! scope=&quot;row&quot; |&quot;Malume&quot; (Zee Nxumalo, Djy Biza, 031 Choppa featuring Springle, DJ Tira)
|—
|
|-
! scope=&quot;row&quot; |&quot;Inja Ye Game&quot;
|—
|
|-
! scope=&quot;row&quot; |&quot;THE GRIMACE SHAKE&quot; (Grimace, Zee Nxumalo)
|—
|
|{{non-album single}} 
|-
!&quot;Yonke Into&quot; (Reece Madlisa, Zee Nxumalo &amp; M00tion)
|2025
|_
|
|Everything Is On Me
|-
!&quot;Balele&quot; (Sjavasdadeejay, DJ Maphorisa &amp; Zee Nxumalo featuring Xduppy, Madumane &amp; Dutch)
|
|_
|
|Non-album single
|-
!&quot;Ngisakuthanda [3-step Remix]&quot; (Dr Thulz, Zee Nxumalo &amp; TBO)
|
|_
|
|Non-album single
|-
!&quot;Ngisakuthanda (Edit)&quot; (Zee Nxumalo, TBO &amp; PYY Drum Log King)
|
|
|
|Non-album single
|-
!&quot;Imnandi&quot; (N.I.D Muziq, Zee Nxumalo &amp; RIVALZ)
|
|_
|
|Non-album 
single
|-
!&quot;Sajola Kamnandi&quot; (Sminofu &amp; Zee Nxumalo)
|
|49
|
|Non-album single
|-
!&quot;Hamba&quot; (DJ Obza &amp; Zee Nxumalo)
|
|_
|
|
|-
!&quot;U'Spongè&quot; (Zee Nxumalo featuring Gino Brown)
|
|_
|
|Non-album single
|-
!&quot;In &amp; Out&quot; (Raluka, Millforlife &amp; Zee Nxumalo)
|
|_
|
|Non-album single
|-
!&quot;Bhampa&quot; (Vigro Deep, Zee Nxumalo &amp; Ch'cco)
|
|30
|
|Non-album single
|-
!&quot;Rato Laka&quot; (Shebeshxt, Naqua SA &amp; Zee Nxumalo featuring Slidoo Man
|
|23
|
|Non-album single
|-
!&quot;In &amp; Out (ReMan Remix)&quot; (Raluka, Millforlife, Zee Nxumalo &amp; ReMan)
|
|_
|
|Non-album single
|-
!&quot;Mamma&quot; (Zee Nxumalo, Skillz &amp; Sykes)
|
|5
|
|Non-album single
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; |&quot;—&quot; denotes a recording that did not chart or was not released in that territory.
|-
|
|
|
|
|
|
|
|
|}
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center&quot;
|+Irhelo lama-single njengabaculi abaveziweko, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;Hai Kabi&quot; (Jovislash ehlanganisa uZee Nxumalo)
| rowspan=&quot;2&quot; | 2022
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Jabula&quot; (i-ProSiRa ehlanganisa u-Zee Nxumalo)
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Asim'bonanga&quot; (DJ Stresser Given Kanu, Finomol ehlanganisa uZee Nxumalo, Thatohatsi Vocals, Jaz &amp; Csqo)
| rowspan=&quot;3&quot; | 2023
| —
|
|
|-
! scope=&quot;row&quot; | &quot;SHAYIMOTO&quot; (Zulu Makhathini featuring Zee Nxumalo)
| —
|
|
|-
! scope=&quot;row&quot; | &quot;SHAYIMOTO 2.0&quot; (Zulu Makhathini featuring Zee Nxumalo, PRVIS3, Kweyama Brothers, Triple X Da Ghost)
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Inkululeko&quot; ( DJ Tira, Heavy-K featuring Makhadzi, Zee Nxumalo, Afro Brothers)
| rowspan=&quot;10&quot; | 2024
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Rise&quot; (u-Faizal ohlanganisa i-The Real Prechly, u-Dj Guti BPM, u-Tega Boi DC, u-Berri-Tiga, u-Carterefe, u-Hotkid, u-Poco Lee, u-Goldie, u-Zee Nxumalo)
| —
|
|
|-
! scope=&quot;row&quot; | &quot;FOMO&quot; (GildMax, Dlala Thukzin, Funky Qla featuring Zee Nxumalo, Beast Rsa)
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Propella&quot; (u-Faizal ohlanganisa i-The Real Prechly, u-Dj Guti BPM, u-Tega Boi DC, u-Berri-Tiga, u-Carterefe, u-Zee Nxumalo, u-Poco Lee, u-Ggoldie, u-Hotkid)
| — 
||{{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Pholoba&quot; (I-Danger Flex ehlanganisa u-Zee Nxumalo, u-Dj Mpiczah)
| — 
||{{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Abo Gogo&quot; (Ziibeats, 031choppa, Shakes &amp; Les nge-Zee Nxumalo)
| — 
||{{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Rockstar&quot; (u-Bjørn Vidø ahlanganisa u-Zee Nxumalo, u-Mac J)
| — 
||{{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Mfazi Wephepha&quot; (Nkosazana Daughter, Master KG featuring Big Zulu, Zee Nxumalo)
| 4 
|
| ''Makhelwane''
|-
! scope=&quot;row&quot; | &quot;Ipilo Yephathi&quot; (U-Nasty C, u-Lekaa Beats, u-Daliwonga ohlanganisa u-Zee Nxumalo, u-Yumbs)
| —
|
| ''Didanisa Isitha''
|-
! scope=&quot;row&quot; | &quot;Iskhathi&quot; (I-Danger flex ehlanganisa u-Zee Nxumalo, u-Msongi, u-Ama Grootman, u-SeeZus Beats)
| — 
||{{non-album single}} 
|-
! scope=&quot;row&quot; | &quot;Samba Sonke 2.0&quot; (Karabo Small, Noxx, Tyler ICU ene-Zee Nxumalo, Kailey Botman, Tyrone Dee, AI Xapo)
|
| — 
||{{non-album single}} 
|-
! &quot;Amabomu&quot; (u-DJ Maphorisa no-Xduppy bahlanganisa u-Daliwonga, u-Zee Nxumalo, u-CowBoii no-Blxckie)
| 2025
| _
|
| Umdanso omumbi
|-
! &quot;Hlangene&quot; (u-DJ Maphorisa, u-Xduppy no-Zee Nxumalo bahlanganisa u-Daliwonga)
|
| _
|
| Umdanso omumbi
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; | &quot;—&quot; kutjho ukurekhoda okungazange kushadi namkha okungakakhutjhwa endaweni leyo.
|}

=== Imidlalo enabileko ===
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
! scope=&quot;col&quot; style=&quot;width:14em;&quot; |Ithayitlela
! scope=&quot;col&quot; | Umnyaka
! scope=&quot;col&quot; | Abanye abadwebi
! scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;row&quot; | &quot;Ipilo yePhathi&quot;
| 2024
| U-Leeka Beats, u-Nasty C, u-Daliwonga, u-Yumbs
| ''Didanisa Isitha''
|}

=== Basadi emitlomelweni yomvumo ===
   {{Reflist}}</text>
      <sha1>s1s6n9eahja1ycat6pm8fur94z1urlz</sha1>
    </revision>
    <revision>
      <id>5534</id>
      <parentid>5482</parentid>
      <timestamp>2025-09-04T09:26:49Z</timestamp>
      <contributor>
        <username>Sister01</username>
        <id>893</id>
      </contributor>
      <comment>I added references</comment>
      <origin>5534</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8557" sha1="tg6lphhzapvs2u4sfu2iq94hacvr9rw" xml:space="preserve">

 

'''U-Zandile Nxumalo''' (wabelethwa mhlana ali-6 kuTjhirhweni 2003 ) owaziwa nge- '''Zee Nxumalo''', mhlabeleli nomtloli weengoma we-Swazi-Sewula Afrika.   Ingoma yakhe ethi &quot;Funk 55&quot;, eyakhutjhwa ngo-2023, yamenza waba yipumelelo ekulu begodu yaqinisekiswa njenge-5× Platinum eSewula Afrika.&lt;ref&gt;[https://www.sowetanlive.co.za/entertainment/2022-07-22-social-media-puts-zee-nxumalo-on-crest-of-a-wave/ Social media puts Zee Nxumalo on crest of a wave]&lt;/ref&gt;  

== Ipilo yokuthoma ==
UZandile Nxumalo wabelethwa mhlana amalanga asi-6 kuTjhirhweni ngomnyaka ka 2003 e [[Eswatini|-Eswatini]] .  Umndeni wakhe wathuthela e -Alexandra, e-Goli lapho ahlala khona ebuntwaneni bakhe. &lt;ref&gt;[https://www.news24.com/citypress/trending/zee-nxumalo-brings-amapiano-fire-to-mzansi-20240121 Zee Nxumalo brings Amapiano fire to Mzansi | News24]&lt;/ref&gt; 

== Ibizelo ==
Umdlalo wakhe wokuthoma we ''-KwaNxumalo'', wakhutjhwa mhlazi-28 kuMgwengweni 2022.   &quot;U-Funk 55&quot; ka-Shakes &amp; Les, u-DBN Gogo no-Zee Nxumalo ohlanganisa u-Ceeka RSA no-Chley wakhutjhwa mhlana ali-1 kuNobayeni 2023. Wathoma ukuvezwa ku-  2 Local St. Ingoma yakhe ''i-Thula Mabota'' no-Pabi Cooper no-031choppa, ene-Shakes &amp; Les. yakhutjhwa mhlana amalanga ama-29 kuNtaka 2024. Yaqinisekiswa njengeplatinamu eSewula Afrika.&lt;ref&gt;[https://www.musicinafrica.net/magazine/sa-zee-nxumalo-drops-debut-ep-kwanxumalo SA: Zee Nxumalo drops debut EP KwaNxumalo | Music In Africa]&lt;/ref&gt; 

Wabuye wavela ku-Ama Gear no -Dlala Thukzin kanye ne-Funky QLA, ehlanganisa i-MK Productions, ekhutjhwe mhlazi-5 kuNtaka 2024. Ingoma le yathoma ukuvela endaweni yesi-5 ku-Local Streaming Top 10.  Ekuthomeni kwakaMgwengweni 2024, wamemezela umdlalo wakhe we- ''Inja Ye Game'', okhutjhwe mhlana amalanga ali-15 kuNobayeni 2024   &quot;Malume&quot; no-Djy Biza no-031 Choppa, okufaka hlangana u-Springle no- DJ Tira, yakhutjhwa mhlana amalanga ama-26 kuNobayeni 2024, njengengoma ephambili.&lt;ref&gt;[https://iol.co.za/sunday-tribune/entertainment/2024-06-12-amapiano-sensation-zee-nxumalo-on-taking-her-career-to-new-heights/ Amapiano sensation Zee Nxumalo on taking her career to new heights]&lt;/ref&gt;

== Imivumo ayiqula ayedwa ==

=== Njengomdwebi odosa phambili ===
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+List of singles as lead artist, with selected chart positions and certifications, showing year released and album name
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Title
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Year
! colspan=&quot;1&quot; scope=&quot;col&quot; |Peak chart positions
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; |Certifications
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Album
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; |ZA&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; |&quot;Siyajola&quot;
| rowspan=&quot;2&quot; |2022
|—
|
| rowspan=&quot;2&quot; |''KwaNxumalo''
|-
! scope=&quot;row&quot; |&quot;Hamba&quot;
|—
|
|-
! scope=&quot;row&quot; |&quot;Sobabili&quot; (Zee Nxumalo, Profound, MFR Souls)
| rowspan=&quot;2&quot; |2023
|—
|
|''KwaNxumalo (Deluxe)''
|-
! scope=&quot;row&quot; |&quot; Funk 55&quot; (Shake &amp; Les, DBN Gogo, Zee Nxumalo featuring Ceeka RSA, Chley)
|1
|5× Platinum
|''Funk Series''
|-
! scope=&quot;row&quot; |&quot;Uyang'user&quot; (Tranquillo, Zee Nxumalo, Khanyisa featuring Chley &amp; Rif effect)
| rowspan=&quot;9&quot; |2024
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Thula Mabota&quot; (Zee Nxumalo, Pabi Cooper, 031choppa featuring Shakes &amp; Les)
|
|Platinum
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Chengu Shesha&quot; (DJ Tshegu, Leemckrazy, Zee Nxumalo featuring Al Xapo, Vyno Keys &amp; QuayR Musiq)
|—
|
|
|-
! scope=&quot;row&quot; |&quot;Abantu&quot; (Piano City, Marlode &amp; Owams, Zee Nxumalo featuring Leemckrazy, FLUXX)
|—
|
|
|-
! scope=&quot;row&quot; |&quot;Ama Gear (Edit)&quot; (Dlala Thukzin, Funky Qla, Zee Nxumalo featuring MK Productions)
|5
|
|{{non-album single}}
|-
! scope=&quot;row&quot; |&quot;Ngisakuthanda&quot; (featuring PYY Log Drum King, Dj Tearz, Dr Thulz)
|1
|RiSA: 3x platinum
| rowspan=&quot;3&quot; |''Inja Ye Game''
|-
! scope=&quot;row&quot; |&quot;Malume&quot; (Zee Nxumalo, Djy Biza, 031 Choppa featuring Springle, DJ Tira)
|—
|
|-
! scope=&quot;row&quot; |&quot;Inja Ye Game&quot;
|—
|
|-
! scope=&quot;row&quot; |&quot;THE GRIMACE SHAKE&quot; (Grimace, Zee Nxumalo)
|—
|
|{{non-album single}} 
|-
!&quot;Yonke Into&quot; (Reece Madlisa, Zee Nxumalo &amp; M00tion)
|2025
|_
|
|Everything Is On Me
|-
!&quot;Balele&quot; (Sjavasdadeejay, DJ Maphorisa &amp; Zee Nxumalo featuring Xduppy, Madumane &amp; Dutch)
|
|_
|
|Non-album single
|-
!&quot;Ngisakuthanda [3-step Remix]&quot; (Dr Thulz, Zee Nxumalo &amp; TBO)
|
|_
|
|Non-album single
|-
!&quot;Ngisakuthanda (Edit)&quot; (Zee Nxumalo, TBO &amp; PYY Drum Log King)
|
|
|
|Non-album single
|-
!&quot;Imnandi&quot; (N.I.D Muziq, Zee Nxumalo &amp; RIVALZ)
|
|_
|
|Non-album 
single
|-
!&quot;Sajola Kamnandi&quot; (Sminofu &amp; Zee Nxumalo)
|
|49
|
|Non-album single
|-
!&quot;Hamba&quot; (DJ Obza &amp; Zee Nxumalo)
|
|_
|
|
|-
!&quot;U'Spongè&quot; (Zee Nxumalo featuring Gino Brown)
|
|_
|
|Non-album single
|-
!&quot;In &amp; Out&quot; (Raluka, Millforlife &amp; Zee Nxumalo)
|
|_
|
|Non-album single
|-
!&quot;Bhampa&quot; (Vigro Deep, Zee Nxumalo &amp; Ch'cco)
|
|30
|
|Non-album single
|-
!&quot;Rato Laka&quot; (Shebeshxt, Naqua SA &amp; Zee Nxumalo featuring Slidoo Man
|
|23
|
|Non-album single
|-
!&quot;In &amp; Out (ReMan Remix)&quot; (Raluka, Millforlife, Zee Nxumalo &amp; ReMan)
|
|_
|
|Non-album single
|-
!&quot;Mamma&quot; (Zee Nxumalo, Skillz &amp; Sykes)
|
|5
|
|Non-album single
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; |&quot;—&quot; denotes a recording that did not chart or was not released in that territory.
|-
|
|
|
|
|
|
|
|
|}
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center&quot;
|+Irhelo lama-single njengabaculi abaveziweko, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;Hai Kabi&quot; (Jovislash ehlanganisa uZee Nxumalo)
| rowspan=&quot;2&quot; | 2022
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Jabula&quot; (i-ProSiRa ehlanganisa u-Zee Nxumalo)
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Asim'bonanga&quot; (DJ Stresser Given Kanu, Finomol ehlanganisa uZee Nxumalo, Thatohatsi Vocals, Jaz &amp; Csqo)
| rowspan=&quot;3&quot; | 2023
| —
|
|
|-
! scope=&quot;row&quot; | &quot;SHAYIMOTO&quot; (Zulu Makhathini featuring Zee Nxumalo)
| —
|
|
|-
! scope=&quot;row&quot; | &quot;SHAYIMOTO 2.0&quot; (Zulu Makhathini featuring Zee Nxumalo, PRVIS3, Kweyama Brothers, Triple X Da Ghost)
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Inkululeko&quot; ( DJ Tira, Heavy-K featuring Makhadzi, Zee Nxumalo, Afro Brothers)
| rowspan=&quot;10&quot; | 2024
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Rise&quot; (u-Faizal ohlanganisa i-The Real Prechly, u-Dj Guti BPM, u-Tega Boi DC, u-Berri-Tiga, u-Carterefe, u-Hotkid, u-Poco Lee, u-Goldie, u-Zee Nxumalo)
| —
|
|
|-
! scope=&quot;row&quot; | &quot;FOMO&quot; (GildMax, Dlala Thukzin, Funky Qla featuring Zee Nxumalo, Beast Rsa)
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Propella&quot; (u-Faizal ohlanganisa i-The Real Prechly, u-Dj Guti BPM, u-Tega Boi DC, u-Berri-Tiga, u-Carterefe, u-Zee Nxumalo, u-Poco Lee, u-Ggoldie, u-Hotkid)
| — 
||{{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Pholoba&quot; (I-Danger Flex ehlanganisa u-Zee Nxumalo, u-Dj Mpiczah)
| — 
||{{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Abo Gogo&quot; (Ziibeats, 031choppa, Shakes &amp; Les nge-Zee Nxumalo)
| — 
||{{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Rockstar&quot; (u-Bjørn Vidø ahlanganisa u-Zee Nxumalo, u-Mac J)
| — 
||{{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Mfazi Wephepha&quot; (Nkosazana Daughter, Master KG featuring Big Zulu, Zee Nxumalo)
| 4 
|
| ''Makhelwane''
|-
! scope=&quot;row&quot; | &quot;Ipilo Yephathi&quot; (U-Nasty C, u-Lekaa Beats, u-Daliwonga ohlanganisa u-Zee Nxumalo, u-Yumbs)
| —
|
| ''Didanisa Isitha''
|-
! scope=&quot;row&quot; | &quot;Iskhathi&quot; (I-Danger flex ehlanganisa u-Zee Nxumalo, u-Msongi, u-Ama Grootman, u-SeeZus Beats)
| — 
||{{non-album single}} 
|-
! scope=&quot;row&quot; | &quot;Samba Sonke 2.0&quot; (Karabo Small, Noxx, Tyler ICU ene-Zee Nxumalo, Kailey Botman, Tyrone Dee, AI Xapo)
|
| — 
||{{non-album single}} 
|-
! &quot;Amabomu&quot; (u-DJ Maphorisa no-Xduppy bahlanganisa u-Daliwonga, u-Zee Nxumalo, u-CowBoii no-Blxckie)
| 2025
| _
|
| Umdanso omumbi
|-
! &quot;Hlangene&quot; (u-DJ Maphorisa, u-Xduppy no-Zee Nxumalo bahlanganisa u-Daliwonga)
|
| _
|
| Umdanso omumbi
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; | &quot;—&quot; kutjho ukurekhoda okungazange kushadi namkha okungakakhutjhwa endaweni leyo.
|}

=== Imidlalo enabileko ===
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
! scope=&quot;col&quot; style=&quot;width:14em;&quot; |Ithayitlela
! scope=&quot;col&quot; | Umnyaka
! scope=&quot;col&quot; | Abanye abadwebi
! scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;row&quot; | &quot;Ipilo yePhathi&quot;
| 2024
| U-Leeka Beats, u-Nasty C, u-Daliwonga, u-Yumbs
| ''Didanisa Isitha''
|}

=== Umthombo lwazi ===
{{Reflist}}</text>
      <sha1>tg6lphhzapvs2u4sfu2iq94hacvr9rw</sha1>
    </revision>
    <revision>
      <id>5570</id>
      <parentid>5534</parentid>
      <timestamp>2025-09-04T09:49:31Z</timestamp>
      <contributor>
        <username>Sister01</username>
        <id>893</id>
      </contributor>
      <comment>I added references</comment>
      <origin>5570</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8557" sha1="1e5arhrfnqchs35rli5nbd3bvltxup1" xml:space="preserve">

 

'''U-Zandile Nxumalo''' (wabelethwa mhlana ali-6 kuTjhirhweni 2003) owaziwa nge- '''Zee Nxumalo''', mhlabeleli nomtloli weengoma we-Swazi-Sewula Afrika.   Ingoma yakhe ethi &quot;Funk 55&quot;, eyakhutjhwa ngo-2023, yamenza waba yipumelelo ekulu begodu yaqinisekiswa njenge-5× Platinum eSewula Afrika.&lt;ref&gt;[https://www.sowetanlive.co.za/entertainment/2022-07-22-social-media-puts-zee-nxumalo-on-crest-of-a-wave/ Social media puts Zee Nxumalo on crest of a wave]&lt;/ref&gt;  

== Ipilo yokuthoma ==
UZandile Nxumalo wabelethwa mhlana amalanga asi-6 kuTjhirhweni ngomnyaka ka 2003 e [[Eswatini|-Eswatini]] .  Umndeni wakhe wathuthela e -Alexandra, e-Goli lapho ahlala khona ebuntwaneni bakhe. &lt;ref&gt;[https://www.news24.com/citypress/trending/zee-nxumalo-brings-amapiano-fire-to-mzansi-20240121 Zee Nxumalo brings Amapiano fire to Mzansi | News24]&lt;/ref&gt; 

== Ibizelo ==
Umdlalo wakhe wokuthoma we ''-KwaNxumalo'', wakhutjhwa mhlazi-28 kuMgwengweni 2022.   &quot;U-Funk 55&quot; ka-Shakes &amp; Les, u-DBN Gogo no-Zee Nxumalo ohlanganisa u-Ceeka RSA no-Chley wakhutjhwa mhlana ali-1 kuNobayeni 2023. Wathoma ukuvezwa ku-  2 Local St. Ingoma yakhe ''i-Thula Mabota'' no-Pabi Cooper no-031choppa, ene-Shakes &amp; Les. yakhutjhwa mhlana amalanga ama-29 kuNtaka 2024. Yaqinisekiswa njengeplatinamu eSewula Afrika.&lt;ref&gt;[https://www.musicinafrica.net/magazine/sa-zee-nxumalo-drops-debut-ep-kwanxumalo SA: Zee Nxumalo drops debut EP KwaNxumalo | Music In Africa]&lt;/ref&gt; 

Wabuye wavela ku-Ama Gear no -Dlala Thukzin kanye ne-Funky QLA, ehlanganisa i-MK Productions, ekhutjhwe mhlazi-5 kuNtaka 2024. Ingoma le yathoma ukuvela endaweni yesi-5 ku-Local Streaming Top 10.  Ekuthomeni kwakaMgwengweni 2024, wamemezela umdlalo wakhe we- ''Inja Ye Game'', okhutjhwe mhlana amalanga ali-15 kuNobayeni 2024   &quot;Malume&quot; no-Djy Biza no-031 Choppa, okufaka hlangana u-Springle no- DJ Tira, yakhutjhwa mhlana amalanga ama-26 kuNobayeni 2024, njengengoma ephambili.&lt;ref&gt;[https://iol.co.za/sunday-tribune/entertainment/2024-06-12-amapiano-sensation-zee-nxumalo-on-taking-her-career-to-new-heights/ Amapiano sensation Zee Nxumalo on taking her career to new heights]&lt;/ref&gt;

== Imivumo ayiqula ayedwa ==

=== Njengomdwebi odosa phambili ===
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+List of singles as lead artist, with selected chart positions and certifications, showing year released and album name
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Title
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Year
! colspan=&quot;1&quot; scope=&quot;col&quot; |Peak chart positions
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; |Certifications
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Album
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; |ZA&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; |&quot;Siyajola&quot;
| rowspan=&quot;2&quot; |2022
|—
|
| rowspan=&quot;2&quot; |''KwaNxumalo''
|-
! scope=&quot;row&quot; |&quot;Hamba&quot;
|—
|
|-
! scope=&quot;row&quot; |&quot;Sobabili&quot; (Zee Nxumalo, Profound, MFR Souls)
| rowspan=&quot;2&quot; |2023
|—
|
|''KwaNxumalo (Deluxe)''
|-
! scope=&quot;row&quot; |&quot; Funk 55&quot; (Shake &amp; Les, DBN Gogo, Zee Nxumalo featuring Ceeka RSA, Chley)
|1
|5× Platinum
|''Funk Series''
|-
! scope=&quot;row&quot; |&quot;Uyang'user&quot; (Tranquillo, Zee Nxumalo, Khanyisa featuring Chley &amp; Rif effect)
| rowspan=&quot;9&quot; |2024
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Thula Mabota&quot; (Zee Nxumalo, Pabi Cooper, 031choppa featuring Shakes &amp; Les)
|
|Platinum
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Chengu Shesha&quot; (DJ Tshegu, Leemckrazy, Zee Nxumalo featuring Al Xapo, Vyno Keys &amp; QuayR Musiq)
|—
|
|
|-
! scope=&quot;row&quot; |&quot;Abantu&quot; (Piano City, Marlode &amp; Owams, Zee Nxumalo featuring Leemckrazy, FLUXX)
|—
|
|
|-
! scope=&quot;row&quot; |&quot;Ama Gear (Edit)&quot; (Dlala Thukzin, Funky Qla, Zee Nxumalo featuring MK Productions)
|5
|
|{{non-album single}}
|-
! scope=&quot;row&quot; |&quot;Ngisakuthanda&quot; (featuring PYY Log Drum King, Dj Tearz, Dr Thulz)
|1
|RiSA: 3x platinum
| rowspan=&quot;3&quot; |''Inja Ye Game''
|-
! scope=&quot;row&quot; |&quot;Malume&quot; (Zee Nxumalo, Djy Biza, 031 Choppa featuring Springle, DJ Tira)
|—
|
|-
! scope=&quot;row&quot; |&quot;Inja Ye Game&quot;
|—
|
|-
! scope=&quot;row&quot; |&quot;THE GRIMACE SHAKE&quot; (Grimace, Zee Nxumalo)
|—
|
|{{non-album single}} 
|-
!&quot;Yonke Into&quot; (Reece Madlisa, Zee Nxumalo &amp; M00tion)
|2025
|_
|
|Everything Is On Me
|-
!&quot;Balele&quot; (Sjavasdadeejay, DJ Maphorisa &amp; Zee Nxumalo featuring Xduppy, Madumane &amp; Dutch)
|
|_
|
|Non-album single
|-
!&quot;Ngisakuthanda [3-step Remix]&quot; (Dr Thulz, Zee Nxumalo &amp; TBO)
|
|_
|
|Non-album single
|-
!&quot;Ngisakuthanda (Edit)&quot; (Zee Nxumalo, TBO &amp; PYY Drum Log King)
|
|
|
|Non-album single
|-
!&quot;Imnandi&quot; (N.I.D Muziq, Zee Nxumalo &amp; RIVALZ)
|
|_
|
|Non-album 
single
|-
!&quot;Sajola Kamnandi&quot; (Sminofu &amp; Zee Nxumalo)
|
|49
|
|Non-album single
|-
!&quot;Hamba&quot; (DJ Obza &amp; Zee Nxumalo)
|
|_
|
|
|-
!&quot;U'Spongè&quot; (Zee Nxumalo featuring Gino Brown)
|
|_
|
|Non-album single
|-
!&quot;In &amp; Out&quot; (Raluka, Millforlife &amp; Zee Nxumalo)
|
|_
|
|Non-album single
|-
!&quot;Bhampa&quot; (Vigro Deep, Zee Nxumalo &amp; Ch'cco)
|
|30
|
|Non-album single
|-
!&quot;Rato Laka&quot; (Shebeshxt, Naqua SA &amp; Zee Nxumalo featuring Slidoo Man
|
|23
|
|Non-album single
|-
!&quot;In &amp; Out (ReMan Remix)&quot; (Raluka, Millforlife, Zee Nxumalo &amp; ReMan)
|
|_
|
|Non-album single
|-
!&quot;Mamma&quot; (Zee Nxumalo, Skillz &amp; Sykes)
|
|5
|
|Non-album single
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; |&quot;—&quot; denotes a recording that did not chart or was not released in that territory.
|-
|
|
|
|
|
|
|
|
|}
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center&quot;
|+Irhelo lama-single njengabaculi abaveziweko, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;Hai Kabi&quot; (Jovislash ehlanganisa uZee Nxumalo)
| rowspan=&quot;2&quot; | 2022
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Jabula&quot; (i-ProSiRa ehlanganisa u-Zee Nxumalo)
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Asim'bonanga&quot; (DJ Stresser Given Kanu, Finomol ehlanganisa uZee Nxumalo, Thatohatsi Vocals, Jaz &amp; Csqo)
| rowspan=&quot;3&quot; | 2023
| —
|
|
|-
! scope=&quot;row&quot; | &quot;SHAYIMOTO&quot; (Zulu Makhathini featuring Zee Nxumalo)
| —
|
|
|-
! scope=&quot;row&quot; | &quot;SHAYIMOTO 2.0&quot; (Zulu Makhathini featuring Zee Nxumalo, PRVIS3, Kweyama Brothers, Triple X Da Ghost)
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Inkululeko&quot; ( DJ Tira, Heavy-K featuring Makhadzi, Zee Nxumalo, Afro Brothers)
| rowspan=&quot;10&quot; | 2024
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Rise&quot; (u-Faizal ohlanganisa i-The Real Prechly, u-Dj Guti BPM, u-Tega Boi DC, u-Berri-Tiga, u-Carterefe, u-Hotkid, u-Poco Lee, u-Goldie, u-Zee Nxumalo)
| —
|
|
|-
! scope=&quot;row&quot; | &quot;FOMO&quot; (GildMax, Dlala Thukzin, Funky Qla featuring Zee Nxumalo, Beast Rsa)
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Propella&quot; (u-Faizal ohlanganisa i-The Real Prechly, u-Dj Guti BPM, u-Tega Boi DC, u-Berri-Tiga, u-Carterefe, u-Zee Nxumalo, u-Poco Lee, u-Ggoldie, u-Hotkid)
| — 
||{{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Pholoba&quot; (I-Danger Flex ehlanganisa u-Zee Nxumalo, u-Dj Mpiczah)
| — 
||{{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Abo Gogo&quot; (Ziibeats, 031choppa, Shakes &amp; Les nge-Zee Nxumalo)
| — 
||{{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Rockstar&quot; (u-Bjørn Vidø ahlanganisa u-Zee Nxumalo, u-Mac J)
| — 
||{{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Mfazi Wephepha&quot; (Nkosazana Daughter, Master KG featuring Big Zulu, Zee Nxumalo)
| 4 
|
| ''Makhelwane''
|-
! scope=&quot;row&quot; | &quot;Ipilo Yephathi&quot; (U-Nasty C, u-Lekaa Beats, u-Daliwonga ohlanganisa u-Zee Nxumalo, u-Yumbs)
| —
|
| ''Didanisa Isitha''
|-
! scope=&quot;row&quot; | &quot;Iskhathi&quot; (I-Danger flex ehlanganisa u-Zee Nxumalo, u-Msongi, u-Ama Grootman, u-SeeZus Beats)
| — 
||{{non-album single}} 
|-
! scope=&quot;row&quot; | &quot;Samba Sonke 2.0&quot; (Karabo Small, Noxx, Tyler ICU ene-Zee Nxumalo, Kailey Botman, Tyrone Dee, AI Xapo)
|
| — 
||{{non-album single}} 
|-
! &quot;Amabomu&quot; (u-DJ Maphorisa no-Xduppy bahlanganisa u-Daliwonga, u-Zee Nxumalo, u-CowBoii no-Blxckie)
| 2025
| _
|
| Umdanso omumbi
|-
! &quot;Hlangene&quot; (u-DJ Maphorisa, u-Xduppy no-Zee Nxumalo bahlanganisa u-Daliwonga)
|
| _
|
| Umdanso omumbi
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; | &quot;—&quot; kutjho ukurekhoda okungazange kushadi namkha okungakakhutjhwa endaweni leyo.
|}

=== Imidlalo enabileko ===
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
! scope=&quot;col&quot; style=&quot;width:14em;&quot; |Ithayitlela
! scope=&quot;col&quot; | Umnyaka
! scope=&quot;col&quot; | Abanye abadwebi
! scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;row&quot; | &quot;Ipilo yePhathi&quot;
| 2024
| U-Leeka Beats, u-Nasty C, u-Daliwonga, u-Yumbs
| ''Didanisa Isitha''
|}

=== Imithombo lwazi ===
{{Reflist}}</text>
      <sha1>1e5arhrfnqchs35rli5nbd3bvltxup1</sha1>
    </revision>
    <revision>
      <id>5610</id>
      <parentid>5570</parentid>
      <timestamp>2025-09-04T10:28:50Z</timestamp>
      <contributor>
        <username>Sister01</username>
        <id>893</id>
      </contributor>
      <comment>i edited</comment>
      <origin>5610</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8566" sha1="0bv8lgw2hp8dc7giibe8z5hn1q9c72u" xml:space="preserve">

 

'''U-Zandile Nxumalo''' (wabelethwa mhlana amalanga ali-6 kuTjhirhweni 2003) owaziwa nge- '''Zee Nxumalo''', mhlabeleli nomtloli weengoma we-Swazi-Sewula Afrika.   Ingoma yakhe ethi &quot;Funk 55&quot;, eyakhutjhwa ngo-2023, yamenza waba yipumelelo ekulu begodu yaqinisekiswa njenge-5× Platinum eSewula Afrika.&lt;ref&gt;[https://www.sowetanlive.co.za/entertainment/2022-07-22-social-media-puts-zee-nxumalo-on-crest-of-a-wave/ Social media puts Zee Nxumalo on crest of a wave]&lt;/ref&gt;  

== Ipilo yokuthoma ==
UZandile Nxumalo wabelethwa mhlana amalanga asi-6 kuTjhirhweni ngomnyaka ka 2003 e [[Eswatini|-Eswatini]] .  Umndeni wakhe wathuthela e -Alexandra, e-Goli lapho ahlala khona ebuntwaneni bakhe. &lt;ref&gt;[https://www.news24.com/citypress/trending/zee-nxumalo-brings-amapiano-fire-to-mzansi-20240121 Zee Nxumalo brings Amapiano fire to Mzansi | News24]&lt;/ref&gt; 

== Ibizelo ==
Umdlalo wakhe wokuthoma we ''-KwaNxumalo'', wakhutjhwa mhlazi-28 kuMgwengweni 2022.   &quot;U-Funk 55&quot; ka-Shakes &amp; Les, u-DBN Gogo no-Zee Nxumalo ohlanganisa u-Ceeka RSA no-Chley wakhutjhwa mhlana ali-1 kuNobayeni 2023. Wathoma ukuvezwa ku-  2 Local St. Ingoma yakhe ''i-Thula Mabota'' no-Pabi Cooper no-031choppa, ene-Shakes &amp; Les. yakhutjhwa mhlana amalanga ama-29 kuNtaka 2024. Yaqinisekiswa njengeplatinamu eSewula Afrika.&lt;ref&gt;[https://www.musicinafrica.net/magazine/sa-zee-nxumalo-drops-debut-ep-kwanxumalo SA: Zee Nxumalo drops debut EP KwaNxumalo | Music In Africa]&lt;/ref&gt; 

Wabuye wavela ku-Ama Gear no -Dlala Thukzin kanye ne-Funky QLA, ehlanganisa i-MK Productions, ekhutjhwe mhlazi-5 kuNtaka 2024. Ingoma le yathoma ukuvela endaweni yesi-5 ku-Local Streaming Top 10.  Ekuthomeni kwakaMgwengweni 2024, wamemezela umdlalo wakhe we- ''Inja Ye Game'', okhutjhwe mhlana amalanga ali-15 kuNobayeni 2024   &quot;Malume&quot; no-Djy Biza no-031 Choppa, okufaka hlangana u-Springle no- DJ Tira, yakhutjhwa mhlana amalanga ama-26 kuNobayeni 2024, njengengoma ephambili.&lt;ref&gt;[https://iol.co.za/sunday-tribune/entertainment/2024-06-12-amapiano-sensation-zee-nxumalo-on-taking-her-career-to-new-heights/ Amapiano sensation Zee Nxumalo on taking her career to new heights]&lt;/ref&gt;

== Imivumo ayiqula ayedwa ==

=== Njengomdwebi odosa phambili ===
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+List of singles as lead artist, with selected chart positions and certifications, showing year released and album name
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Title
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Year
! colspan=&quot;1&quot; scope=&quot;col&quot; |Peak chart positions
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; |Certifications
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Album
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; |ZA&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; |&quot;Siyajola&quot;
| rowspan=&quot;2&quot; |2022
|—
|
| rowspan=&quot;2&quot; |''KwaNxumalo''
|-
! scope=&quot;row&quot; |&quot;Hamba&quot;
|—
|
|-
! scope=&quot;row&quot; |&quot;Sobabili&quot; (Zee Nxumalo, Profound, MFR Souls)
| rowspan=&quot;2&quot; |2023
|—
|
|''KwaNxumalo (Deluxe)''
|-
! scope=&quot;row&quot; |&quot; Funk 55&quot; (Shake &amp; Les, DBN Gogo, Zee Nxumalo featuring Ceeka RSA, Chley)
|1
|5× Platinum
|''Funk Series''
|-
! scope=&quot;row&quot; |&quot;Uyang'user&quot; (Tranquillo, Zee Nxumalo, Khanyisa featuring Chley &amp; Rif effect)
| rowspan=&quot;9&quot; |2024
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Thula Mabota&quot; (Zee Nxumalo, Pabi Cooper, 031choppa featuring Shakes &amp; Les)
|
|Platinum
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Chengu Shesha&quot; (DJ Tshegu, Leemckrazy, Zee Nxumalo featuring Al Xapo, Vyno Keys &amp; QuayR Musiq)
|—
|
|
|-
! scope=&quot;row&quot; |&quot;Abantu&quot; (Piano City, Marlode &amp; Owams, Zee Nxumalo featuring Leemckrazy, FLUXX)
|—
|
|
|-
! scope=&quot;row&quot; |&quot;Ama Gear (Edit)&quot; (Dlala Thukzin, Funky Qla, Zee Nxumalo featuring MK Productions)
|5
|
|{{non-album single}}
|-
! scope=&quot;row&quot; |&quot;Ngisakuthanda&quot; (featuring PYY Log Drum King, Dj Tearz, Dr Thulz)
|1
|RiSA: 3x platinum
| rowspan=&quot;3&quot; |''Inja Ye Game''
|-
! scope=&quot;row&quot; |&quot;Malume&quot; (Zee Nxumalo, Djy Biza, 031 Choppa featuring Springle, DJ Tira)
|—
|
|-
! scope=&quot;row&quot; |&quot;Inja Ye Game&quot;
|—
|
|-
! scope=&quot;row&quot; |&quot;THE GRIMACE SHAKE&quot; (Grimace, Zee Nxumalo)
|—
|
|{{non-album single}} 
|-
!&quot;Yonke Into&quot; (Reece Madlisa, Zee Nxumalo &amp; M00tion)
|2025
|_
|
|Everything Is On Me
|-
!&quot;Balele&quot; (Sjavasdadeejay, DJ Maphorisa &amp; Zee Nxumalo featuring Xduppy, Madumane &amp; Dutch)
|
|_
|
|Non-album single
|-
!&quot;Ngisakuthanda [3-step Remix]&quot; (Dr Thulz, Zee Nxumalo &amp; TBO)
|
|_
|
|Non-album single
|-
!&quot;Ngisakuthanda (Edit)&quot; (Zee Nxumalo, TBO &amp; PYY Drum Log King)
|
|
|
|Non-album single
|-
!&quot;Imnandi&quot; (N.I.D Muziq, Zee Nxumalo &amp; RIVALZ)
|
|_
|
|Non-album 
single
|-
!&quot;Sajola Kamnandi&quot; (Sminofu &amp; Zee Nxumalo)
|
|49
|
|Non-album single
|-
!&quot;Hamba&quot; (DJ Obza &amp; Zee Nxumalo)
|
|_
|
|
|-
!&quot;U'Spongè&quot; (Zee Nxumalo featuring Gino Brown)
|
|_
|
|Non-album single
|-
!&quot;In &amp; Out&quot; (Raluka, Millforlife &amp; Zee Nxumalo)
|
|_
|
|Non-album single
|-
!&quot;Bhampa&quot; (Vigro Deep, Zee Nxumalo &amp; Ch'cco)
|
|30
|
|Non-album single
|-
!&quot;Rato Laka&quot; (Shebeshxt, Naqua SA &amp; Zee Nxumalo featuring Slidoo Man
|
|23
|
|Non-album single
|-
!&quot;In &amp; Out (ReMan Remix)&quot; (Raluka, Millforlife, Zee Nxumalo &amp; ReMan)
|
|_
|
|Non-album single
|-
!&quot;Mamma&quot; (Zee Nxumalo, Skillz &amp; Sykes)
|
|5
|
|Non-album single
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; |&quot;—&quot; denotes a recording that did not chart or was not released in that territory.
|-
|
|
|
|
|
|
|
|
|}
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center&quot;
|+Irhelo lama-single njengabaculi abaveziweko, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;Hai Kabi&quot; (Jovislash ehlanganisa uZee Nxumalo)
| rowspan=&quot;2&quot; | 2022
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Jabula&quot; (i-ProSiRa ehlanganisa u-Zee Nxumalo)
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Asim'bonanga&quot; (DJ Stresser Given Kanu, Finomol ehlanganisa uZee Nxumalo, Thatohatsi Vocals, Jaz &amp; Csqo)
| rowspan=&quot;3&quot; | 2023
| —
|
|
|-
! scope=&quot;row&quot; | &quot;SHAYIMOTO&quot; (Zulu Makhathini featuring Zee Nxumalo)
| —
|
|
|-
! scope=&quot;row&quot; | &quot;SHAYIMOTO 2.0&quot; (Zulu Makhathini featuring Zee Nxumalo, PRVIS3, Kweyama Brothers, Triple X Da Ghost)
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Inkululeko&quot; ( DJ Tira, Heavy-K featuring Makhadzi, Zee Nxumalo, Afro Brothers)
| rowspan=&quot;10&quot; | 2024
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Rise&quot; (u-Faizal ohlanganisa i-The Real Prechly, u-Dj Guti BPM, u-Tega Boi DC, u-Berri-Tiga, u-Carterefe, u-Hotkid, u-Poco Lee, u-Goldie, u-Zee Nxumalo)
| —
|
|
|-
! scope=&quot;row&quot; | &quot;FOMO&quot; (GildMax, Dlala Thukzin, Funky Qla featuring Zee Nxumalo, Beast Rsa)
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Propella&quot; (u-Faizal ohlanganisa i-The Real Prechly, u-Dj Guti BPM, u-Tega Boi DC, u-Berri-Tiga, u-Carterefe, u-Zee Nxumalo, u-Poco Lee, u-Ggoldie, u-Hotkid)
| — 
||{{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Pholoba&quot; (I-Danger Flex ehlanganisa u-Zee Nxumalo, u-Dj Mpiczah)
| — 
||{{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Abo Gogo&quot; (Ziibeats, 031choppa, Shakes &amp; Les nge-Zee Nxumalo)
| — 
||{{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Rockstar&quot; (u-Bjørn Vidø ahlanganisa u-Zee Nxumalo, u-Mac J)
| — 
||{{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Mfazi Wephepha&quot; (Nkosazana Daughter, Master KG featuring Big Zulu, Zee Nxumalo)
| 4 
|
| ''Makhelwane''
|-
! scope=&quot;row&quot; | &quot;Ipilo Yephathi&quot; (U-Nasty C, u-Lekaa Beats, u-Daliwonga ohlanganisa u-Zee Nxumalo, u-Yumbs)
| —
|
| ''Didanisa Isitha''
|-
! scope=&quot;row&quot; | &quot;Iskhathi&quot; (I-Danger flex ehlanganisa u-Zee Nxumalo, u-Msongi, u-Ama Grootman, u-SeeZus Beats)
| — 
||{{non-album single}} 
|-
! scope=&quot;row&quot; | &quot;Samba Sonke 2.0&quot; (Karabo Small, Noxx, Tyler ICU ene-Zee Nxumalo, Kailey Botman, Tyrone Dee, AI Xapo)
|
| — 
||{{non-album single}} 
|-
! &quot;Amabomu&quot; (u-DJ Maphorisa no-Xduppy bahlanganisa u-Daliwonga, u-Zee Nxumalo, u-CowBoii no-Blxckie)
| 2025
| _
|
| Umdanso omumbi
|-
! &quot;Hlangene&quot; (u-DJ Maphorisa, u-Xduppy no-Zee Nxumalo bahlanganisa u-Daliwonga)
|
| _
|
| Umdanso omumbi
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; | &quot;—&quot; kutjho ukurekhoda okungazange kushadi namkha okungakakhutjhwa endaweni leyo.
|}

=== Imidlalo enabileko ===
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
! scope=&quot;col&quot; style=&quot;width:14em;&quot; |Ithayitlela
! scope=&quot;col&quot; | Umnyaka
! scope=&quot;col&quot; | Abanye abadwebi
! scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;row&quot; | &quot;Ipilo yePhathi&quot;
| 2024
| U-Leeka Beats, u-Nasty C, u-Daliwonga, u-Yumbs
| ''Didanisa Isitha''
|}

=== Imithombo lwazi ===
{{Reflist}}</text>
      <sha1>0bv8lgw2hp8dc7giibe8z5hn1q9c72u</sha1>
    </revision>
    <revision>
      <id>6410</id>
      <parentid>5610</parentid>
      <timestamp>2026-04-13T07:21:58Z</timestamp>
      <contributor>
        <username>Kwamikagami</username>
        <id>1412</id>
      </contributor>
      <origin>6410</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8545" sha1="ayp1sopcbldh1hc0gkox670ydjjsa10" xml:space="preserve">'''U-Zandile Nxumalo''' (wabelethwa mhlana amalanga ali-6 kuTjhirhweni 2003) owaziwa nge-'''Zee Nxumalo''', mhlabeleli nomtloli weengoma we-Swazi-Sewula Afrika. Ingoma yakhe ethi &quot;Funk 55&quot;, eyakhutjhwa ngo-2023, yamenza waba yipumelelo ekulu begodu yaqinisekiswa njenge-5× Platinum eSewula Afrika.&lt;ref&gt;[https://www.sowetanlive.co.za/entertainment/2022-07-22-social-media-puts-zee-nxumalo-on-crest-of-a-wave/ Social media puts Zee Nxumalo on crest of a wave]&lt;/ref&gt;  

== Ipilo yokuthoma ==
UZandile Nxumalo wabelethwa mhlana amalanga asi-6 kuTjhirhweni ngomnyaka ka 2003 e [[Eswatini|-Eswatini]]. Umndeni wakhe wathuthela e-Alexandra, e-Goli lapho ahlala khona ebuntwaneni bakhe. &lt;ref&gt;[https://www.news24.com/citypress/trending/zee-nxumalo-brings-amapiano-fire-to-mzansi-20240121 Zee Nxumalo brings Amapiano fire to Mzansi | News24]&lt;/ref&gt; 

== Ibizelo ==
Umdlalo wakhe wokuthoma we-''KwaNxumalo'', wakhutjhwa mhlazi-28 kuMgwengweni 2022. &quot;U-Funk 55&quot; ka-Shakes &amp; Les, u-DBN Gogo no-Zee Nxumalo ohlanganisa u-Ceeka RSA no-Chley wakhutjhwa mhlana ali-1 kuNobayeni 2023. Wathoma ukuvezwa ku-2 Local St. Ingoma yakhe ''i-Thula Mabota'' no-Pabi Cooper no-031choppa, ene-Shakes &amp; Les. yakhutjhwa mhlana amalanga ama-29 kuNtaka 2024. Yaqinisekiswa njengeplatinamu eSewula Afrika.&lt;ref&gt;[https://www.musicinafrica.net/magazine/sa-zee-nxumalo-drops-debut-ep-kwanxumalo SA: Zee Nxumalo drops debut EP KwaNxumalo | Music In Africa]&lt;/ref&gt; 

Wabuye wavela ku-Ama Gear no-Dlala Thukzin kanye ne-Funky QLA, ehlanganisa i-MK Productions, ekhutjhwe mhlazi-5 kuNtaka 2024. Ingoma le yathoma ukuvela endaweni yesi-5 ku-Local Streaming Top 10.  Ekuthomeni kwakaMgwengweni 2024, wamemezela umdlalo wakhe we- ''Inja Ye Game'', okhutjhwe mhlana amalanga ali-15 kuNobayeni 2024 &quot;Malume&quot; no-Djy Biza no-031 Choppa, okufaka hlangana u-Springle no-DJ Tira, yakhutjhwa mhlana amalanga ama-26 kuNobayeni 2024, njengengoma ephambili.&lt;ref&gt;[https://iol.co.za/sunday-tribune/entertainment/2024-06-12-amapiano-sensation-zee-nxumalo-on-taking-her-career-to-new-heights/ Amapiano sensation Zee Nxumalo on taking her career to new heights]&lt;/ref&gt;

== Imivumo ayiqula ayedwa ==

=== Njengomdwebi odosa phambili ===
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
|+List of singles as lead artist, with selected chart positions and certifications, showing year released and album name
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Title
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Year
! colspan=&quot;1&quot; scope=&quot;col&quot; |Peak chart positions
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; |Certifications
! rowspan=&quot;2&quot; scope=&quot;col&quot; |Album
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; |ZA&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; |&quot;Siyajola&quot;
| rowspan=&quot;2&quot; |2022
|—
|
| rowspan=&quot;2&quot; |''KwaNxumalo''
|-
! scope=&quot;row&quot; |&quot;Hamba&quot;
|—
|
|-
! scope=&quot;row&quot; |&quot;Sobabili&quot; (Zee Nxumalo, Profound, MFR Souls)
| rowspan=&quot;2&quot; |2023
|—
|
|''KwaNxumalo (Deluxe)''
|-
! scope=&quot;row&quot; |&quot; Funk 55&quot; (Shake &amp; Les, DBN Gogo, Zee Nxumalo featuring Ceeka RSA, Chley)
|1
|5× Platinum
|''Funk Series''
|-
! scope=&quot;row&quot; |&quot;Uyang'user&quot; (Tranquillo, Zee Nxumalo, Khanyisa featuring Chley &amp; Rif effect)
| rowspan=&quot;9&quot; |2024
|—
|
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Thula Mabota&quot; (Zee Nxumalo, Pabi Cooper, 031choppa featuring Shakes &amp; Les)
|
|Platinum
|{{non-album single}} 
|-
! scope=&quot;row&quot; |&quot;Chengu Shesha&quot; (DJ Tshegu, Leemckrazy, Zee Nxumalo featuring Al Xapo, Vyno Keys &amp; QuayR Musiq)
|—
|
|
|-
! scope=&quot;row&quot; |&quot;Abantu&quot; (Piano City, Marlode &amp; Owams, Zee Nxumalo featuring Leemckrazy, FLUXX)
|—
|
|
|-
! scope=&quot;row&quot; |&quot;Ama Gear (Edit)&quot; (Dlala Thukzin, Funky Qla, Zee Nxumalo featuring MK Productions)
|5
|
|{{non-album single}}
|-
! scope=&quot;row&quot; |&quot;Ngisakuthanda&quot; (featuring PYY Log Drum King, Dj Tearz, Dr Thulz)
|1
|RiSA: 3x platinum
| rowspan=&quot;3&quot; |''Inja Ye Game''
|-
! scope=&quot;row&quot; |&quot;Malume&quot; (Zee Nxumalo, Djy Biza, 031 Choppa featuring Springle, DJ Tira)
|—
|
|-
! scope=&quot;row&quot; |&quot;Inja Ye Game&quot;
|—
|
|-
! scope=&quot;row&quot; |&quot;THE GRIMACE SHAKE&quot; (Grimace, Zee Nxumalo)
|—
|
|{{non-album single}} 
|-
!&quot;Yonke Into&quot; (Reece Madlisa, Zee Nxumalo &amp; M00tion)
|2025
|_
|
|Everything Is On Me
|-
!&quot;Balele&quot; (Sjavasdadeejay, DJ Maphorisa &amp; Zee Nxumalo featuring Xduppy, Madumane &amp; Dutch)
|
|_
|
|Non-album single
|-
!&quot;Ngisakuthanda [3-step Remix]&quot; (Dr Thulz, Zee Nxumalo &amp; TBO)
|
|_
|
|Non-album single
|-
!&quot;Ngisakuthanda (Edit)&quot; (Zee Nxumalo, TBO &amp; PYY Drum Log King)
|
|
|
|Non-album single
|-
!&quot;Imnandi&quot; (N.I.D Muziq, Zee Nxumalo &amp; RIVALZ)
|
|_
|
|Non-album 
single
|-
!&quot;Sajola Kamnandi&quot; (Sminofu &amp; Zee Nxumalo)
|
|49
|
|Non-album single
|-
!&quot;Hamba&quot; (DJ Obza &amp; Zee Nxumalo)
|
|_
|
|
|-
!&quot;U'Spongè&quot; (Zee Nxumalo featuring Gino Brown)
|
|_
|
|Non-album single
|-
!&quot;In &amp; Out&quot; (Raluka, Millforlife &amp; Zee Nxumalo)
|
|_
|
|Non-album single
|-
!&quot;Bhampa&quot; (Vigro Deep, Zee Nxumalo &amp; Ch'cco)
|
|30
|
|Non-album single
|-
!&quot;Rato Laka&quot; (Shebeshxt, Naqua SA &amp; Zee Nxumalo featuring Slidoo Man
|
|23
|
|Non-album single
|-
!&quot;In &amp; Out (ReMan Remix)&quot; (Raluka, Millforlife, Zee Nxumalo &amp; ReMan)
|
|_
|
|Non-album single
|-
!&quot;Mamma&quot; (Zee Nxumalo, Skillz &amp; Sykes)
|
|5
|
|Non-album single
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; |&quot;—&quot; denotes a recording that did not chart or was not released in that territory.
|-
|
|
|
|
|
|
|
|
|}
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center&quot;
|+Irhelo lama-single njengabaculi abaveziweko, abanezikhundla ezikhethiweko kanye nezitifiketi, ezitjengisa umnyaka wokukhutjhwa kanye nebizo le-albhamu
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Ithayitlela
! rowspan=&quot;2&quot; scope=&quot;col&quot; | Umnyaka
! colspan=&quot;1&quot; scope=&quot;col&quot; | Iindawo eziphezulu zetjhadi
! rowspan=&quot;2&quot; scope=&quot;col&quot; style=&quot;width:12em;&quot; | Iimtifiketi
! rowspan=&quot;2&quot; scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;col&quot; style=&quot;width:3em;font-size:100%;&quot; | ZA&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
|-
! scope=&quot;row&quot; | &quot;Hai Kabi&quot; (Jovislash ehlanganisa uZee Nxumalo)
| rowspan=&quot;2&quot; | 2022
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Jabula&quot; (i-ProSiRa ehlanganisa u-Zee Nxumalo)
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Asim'bonanga&quot; (DJ Stresser Given Kanu, Finomol ehlanganisa uZee Nxumalo, Thatohatsi Vocals, Jaz &amp; Csqo)
| rowspan=&quot;3&quot; | 2023
| —
|
|
|-
! scope=&quot;row&quot; | &quot;SHAYIMOTO&quot; (Zulu Makhathini featuring Zee Nxumalo)
| —
|
|
|-
! scope=&quot;row&quot; | &quot;SHAYIMOTO 2.0&quot; (Zulu Makhathini featuring Zee Nxumalo, PRVIS3, Kweyama Brothers, Triple X Da Ghost)
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Inkululeko&quot; ( DJ Tira, Heavy-K featuring Makhadzi, Zee Nxumalo, Afro Brothers)
| rowspan=&quot;10&quot; | 2024
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Rise&quot; (u-Faizal ohlanganisa i-The Real Prechly, u-Dj Guti BPM, u-Tega Boi DC, u-Berri-Tiga, u-Carterefe, u-Hotkid, u-Poco Lee, u-Goldie, u-Zee Nxumalo)
| —
|
|
|-
! scope=&quot;row&quot; | &quot;FOMO&quot; (GildMax, Dlala Thukzin, Funky Qla featuring Zee Nxumalo, Beast Rsa)
| —
|
|
|-
! scope=&quot;row&quot; | &quot;Propella&quot; (u-Faizal ohlanganisa i-The Real Prechly, u-Dj Guti BPM, u-Tega Boi DC, u-Berri-Tiga, u-Carterefe, u-Zee Nxumalo, u-Poco Lee, u-Ggoldie, u-Hotkid)
| — 
||{{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Pholoba&quot; (I-Danger Flex ehlanganisa u-Zee Nxumalo, u-Dj Mpiczah)
| — 
||{{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Abo Gogo&quot; (Ziibeats, 031choppa, Shakes &amp; Les nge-Zee Nxumalo)
| — 
||{{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Rockstar&quot; (u-Bjørn Vidø ahlanganisa u-Zee Nxumalo, u-Mac J)
| — 
||{{non-album single}}
|-
! scope=&quot;row&quot; | &quot;Mfazi Wephepha&quot; (Nkosazana Daughter, Master KG featuring Big Zulu, Zee Nxumalo)
| 4 
|
| ''Makhelwane''
|-
! scope=&quot;row&quot; | &quot;Ipilo Yephathi&quot; (U-Nasty C, u-Lekaa Beats, u-Daliwonga ohlanganisa u-Zee Nxumalo, u-Yumbs)
| —
|
| ''Didanisa Isitha''
|-
! scope=&quot;row&quot; | &quot;Iskhathi&quot; (I-Danger flex ehlanganisa u-Zee Nxumalo, u-Msongi, u-Ama Grootman, u-SeeZus Beats)
| — 
||{{non-album single}} 
|-
! scope=&quot;row&quot; | &quot;Samba Sonke 2.0&quot; (Karabo Small, Noxx, Tyler ICU ene-Zee Nxumalo, Kailey Botman, Tyrone Dee, AI Xapo)
|
| — 
||{{non-album single}} 
|-
! &quot;Amabomu&quot; (u-DJ Maphorisa no-Xduppy bahlanganisa u-Daliwonga, u-Zee Nxumalo, u-CowBoii no-Blxckie)
| 2025
| _
|
| Umdanso omumbi
|-
! &quot;Hlangene&quot; (u-DJ Maphorisa, u-Xduppy no-Zee Nxumalo bahlanganisa u-Daliwonga)
|
| _
|
| Umdanso omumbi
|-
| colspan=&quot;8&quot; style=&quot;font-size:90%&quot; | &quot;—&quot; kutjho ukurekhoda okungazange kushadi namkha okungakakhutjhwa endaweni leyo.
|}

=== Imidlalo enabileko ===
{| class=&quot;wikitable plainrowheaders&quot; style=&quot;text-align:center;&quot;
! scope=&quot;col&quot; style=&quot;width:14em;&quot; |Ithayitlela
! scope=&quot;col&quot; | Umnyaka
! scope=&quot;col&quot; | Abanye abadwebi
! scope=&quot;col&quot; | I-albhamu
|-
! scope=&quot;row&quot; | &quot;Ipilo yePhathi&quot;
| 2024
| U-Leeka Beats, u-Nasty C, u-Daliwonga, u-Yumbs
| ''Didanisa Isitha''
|}

=== Imithombo lwazi ===
{{Reflist}}</text>
      <sha1>ayp1sopcbldh1hc0gkox670ydjjsa10</sha1>
    </revision>
  </page>
  <page>
    <title>Beyoncé</title>
    <ns>0</ns>
    <id>925</id>
    <revision>
      <id>5483</id>
      <timestamp>2025-09-04T08:49:11Z</timestamp>
      <contributor>
        <username>Londiwe23</username>
        <id>902</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1309326525|Beyoncé]]&quot;</comment>
      <origin>5483</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="481" sha1="defmd641iv40xo4rhz2cvnwzazpxj7d" xml:space="preserve">'''Beyoncé Giselle Knowles-Carter''' ( /b i ˈ ɒ n s eɪ / ⓘ bee-ON -thi ;  ngomhlaka-4 kuNobayeni 1981 mvumi we-America, umtloli weengoma, umlingisi, kanye nosomabhizinisi. Waziwa ngekghono lakhe lokukhuluma, ukutjhugulula ubuciko, nokudlala bukhoma, uthathwa njengomunye wabantu abaqakathekileko emasikweni wekhulu lama-21 . Udunyiswa ngokutjhugulula ibubulo lomvumo, u-Beyoncé kanengi uthathwa njengomunye wabathabisi abakhulu begodu abaculi abanomthelela khulu emlandwini.</text>
      <sha1>defmd641iv40xo4rhz2cvnwzazpxj7d</sha1>
    </revision>
    <revision>
      <id>5557</id>
      <parentid>5483</parentid>
      <timestamp>2025-09-04T09:41:52Z</timestamp>
      <contributor>
        <username>Londiwe23</username>
        <id>902</id>
      </contributor>
      <origin>5557</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="453" sha1="51fmodaqs8s37823xcrzbmofovcv3ud" xml:space="preserve">'''Beyoncé Giselle Knowles-Carter''' wabelethwa   ngomhlaka-4 kuNobayeni 1981. mvumi we-America, umtloli weengoma, mlingisi, begodu nosomabhizinisi. Waziwa ngekghono lakhe lokukhuluma, ukutjhugulula ubuciko, nokudlala bukhoma, uthathwa njengomunye wabantu abaqakathekileko emasikweni wekhulu lama-21 . Udunyiswa ngokutjhugulula ibubulo lomvumo, u-Beyoncé kanengi uthathwa njengomunye wabathabisi abakhulu begodu abaculi abanomthelela khulu emlandwini.</text>
      <sha1>51fmodaqs8s37823xcrzbmofovcv3ud</sha1>
    </revision>
    <revision>
      <id>5574</id>
      <parentid>5557</parentid>
      <timestamp>2025-09-04T09:50:28Z</timestamp>
      <contributor>
        <username>Londiwe23</username>
        <id>902</id>
      </contributor>
      <comment>created reference section</comment>
      <origin>5574</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="492" sha1="iioqpaeofsltx03c7oahhm39x3715d0" xml:space="preserve">'''Beyoncé Giselle Knowles-Carter''' wabelethwa   ngomhlaka-4 kuNobayeni 1981. mvumi we-America, umtloli weengoma, mlingisi, begodu nosomabhizinisi. Waziwa ngekghono lakhe lokukhuluma, ukutjhugulula ubuciko, nokudlala bukhoma, uthathwa njengomunye wabantu abaqakathekileko emasikweni wekhulu lama-21 . Udunyiswa ngokutjhugulula ibubulo lomvumo, u-Beyoncé kanengi uthathwa njengomunye wabathabisi abakhulu begodu abaculi abanomthelela khulu emlandwini.

=== umthombo lwazi ===
&lt;references /&gt;</text>
      <sha1>iioqpaeofsltx03c7oahhm39x3715d0</sha1>
    </revision>
  </page>
  <page>
    <title>Sindi Dlathu</title>
    <ns>0</ns>
    <id>926</id>
    <revision>
      <id>5485</id>
      <timestamp>2025-09-04T08:49:51Z</timestamp>
      <contributor>
        <username>Zanokuhle14</username>
        <id>897</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1305352254|Sindi Dlathu]]&quot;</comment>
      <origin>5485</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1657" sha1="amlbfo6l3qsb0yv3c3niwcfsxtqpuwg" xml:space="preserve">
 


U Sindiswa Dlathu watjhiya umdlalo wakumabonakude obizwa  ngo ''Muvhango'' wayokudlala indima ephambili ku-telenovela &lt;nowiki&gt;&lt;i id=&quot;mwIg&quot;&gt;i-The River&lt;/i&gt;&lt;/nowiki&gt;, lapho adlala khona indima ka-Lindiwe Dlamini-Dikana, umfazi obukhali obekangenza nanyana yini ukuvikela umnotho wakhe kanye ne pilo yakhe yokuzikhakhazisa. 

== Ibizelo ==
UDlathu wakhethwa njengomdlali oqakathekileko emdlalweni wesiteji ka ''-Sarafina!'' . Ekuvezweni kwakhe kuka mabonakude , wasebenza no -Whoopi Goldberg begodu wathunyelwa njengomsizi we-choreography ku -Michael Peters . Ngo-1988, nesiqhema sesibili esidoswa phambili ngu-Seipati Sothoane u-Sindi bekangakafundi kuhle. Lokha umdlalo lo nawuthoma ukuvakatjhela umabonakude, wasala ngemva begodu wenza omunye umdlalo obizwa Township fever ngo-1989 ukuya ku-1990 avakatjhela i-US ngomdlalo lo isikhathi esingangomnyaka. 

UDlathu wabuyela esikolweni ngemva kweminyaka emine aneenkghwari ezizinikeleko zikaMbongeni Ngema . Waqeda iimfundo zakhe zebanga letjhumi nambili ngo-1996,  bese wabuyela emsebenzini wakhe wezomvumo  nokudlala esiteji ngo-1997. Bekasemdlalweni we-FNB Vita Award-winning Game, lapho adlala khona no -Mary Twala, u-Abigail Kubeka, no- Nomhle Nkonyeni ongasekho ephasini.

Uthumbe imitlomelo wokuba mlingisi othandwako  ephaliswaneni lango-2020 ku-DStv Mzansi Viewers' Choice Awards .


uSindiswa Dlathiu, owaziwa ngo Lindiwe Dlamini emdlalweni we The River, uvezwe emdlaweni welizwe odumileko okuyi Thr Queen, lapho uvezwe njongomngani womdosi phambili womdlalo  u, Harriet Khoza-Sebata.


Ngo-2021, wathumba umvuzo we-SAFTA emkhakheni we-Best Actress ngendima yakhe ka-Lindiwe ku ''-The River'' .</text>
      <sha1>amlbfo6l3qsb0yv3c3niwcfsxtqpuwg</sha1>
    </revision>
    <revision>
      <id>5561</id>
      <parentid>5485</parentid>
      <timestamp>2025-09-04T09:44:32Z</timestamp>
      <contributor>
        <username>Zanokuhle14</username>
        <id>897</id>
      </contributor>
      <origin>5561</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1659" sha1="2h65vqn38alhx3q2hsbwbo7uokmc6rq" xml:space="preserve">
 

U Sindiswa Dlathu watjhiya umdlalo wakumabonakude obizwa  ngo ''Muvhango'' wayokudlala indima ephambili ku-telenovela i-The River, lapho adlala khona indima ka-Lindiwe Dlamini-Dikana, umfazi obukhali obekangenza nanyana yini ukuvikela umnotho wakhe kanye ne pilo yakhe yokuzikhakhazisa. 

== Ibizelo ==
UDlathu wakhethwa njengomdlali oqakathekileko emdlalweni wesiteji ka ''-Sarafina!'' . Ekuvezweni kwakhe kuka mabonakude , wasebenza no -Whoopi Goldberg begodu wathunyelwa njengomsizi we-choreography ku -Michael Peters . Ngo-1988, nesiqhema sesibili esidoswa phambili ngu-Seipati Sothoane u-Sindi bekangakafundi kuhle. Lokha umdlalo lo nawuthoma ukuvakatjhela umabonakude, wasala ngemva begodu wenza omunye umdlalo obizwa Township fever ngo-1989 ukuya ku-1990 avakatjhela i-US ngomdlalo lo isikhathi esingangomnyaka. 

UDlathu wabuyela esikolweni ngemva kweminyaka emine aneenkghwari ezizinikeleko zikaMbongeni Ngema . Waqeda iimfundo zakhe zebanga letjhumi nambili ngo-1996,  bese wabuyela emsebenzini wakhe wezomvumo  nokudlala esiteji ngo-1997. Bekasemdlalweni we-FNB Vita Award-winning Game, lapho adlala khona no -Mary Twala, u-Abigail Kubeka, no- Nomhle Nkonyeni ongasekho ephasini.

Uthumbe imitlomelo wokuba mlingisi othandwako  ephaliswaneni lango-2020 ku-DStv Mzansi Viewers' Choice Awards .

uSindiswa Dlathiu, owaziwa ngo Lindiwe Dlamini emdlalweni we The River, uvezwe emdlaweni welizwe odumileko okuyi Thr Queen, lapho uvezwe njongomngani womdosi phambili womdlalo  u, Harriet Khoza-Sebata.
Ngo-2021, wathumba umvuzo we-SAFTA emkhakheni we-Best Actress ngendima yakhe ka-Lindiwe ku ''-The River'' .

=== Imithombo lwazi ===
&lt;references /&gt;</text>
      <sha1>2h65vqn38alhx3q2hsbwbo7uokmc6rq</sha1>
    </revision>
  </page>
  <page>
    <title>KwaMhlanga</title>
    <ns>0</ns>
    <id>927</id>
    <revision>
      <id>5488</id>
      <timestamp>2025-09-04T08:57:03Z</timestamp>
      <contributor>
        <username>Pholap</username>
        <id>883</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1289543492|KwaMhlanga]]&quot;</comment>
      <origin>5488</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1435" sha1="5ek7kzk2bpn6dkwb76bt0n78q08bcoy" xml:space="preserve">#

'''I-KwaMhlanga''' yidorobha elisemasipala wesifunda se -Nkangala esifundazweni se [[Isifunda seMpumalanga|-Mpumalanga]] [[Isewula Afrika|eSewula Afrika]] . Yikhaya lomoya lesitjhaba [[AmaNdebele|samaNdebele]] esahlala lapha ekuthomeni kwekhulu le-18.

KwaMhlanga uneminyaka ema-73&amp;nbsp;Ikhilomitha namkha i-awa ukusuka edolobheni elikhulu lenarha, i-Pitoli emgwaqweni u-R573 .

Idorobha leli lathuthuka laba yindawo yokuphatha karhulumende wendawo, begodu nje lihlala ukuphatha kwakarhulumende wesifunda seTlhagwini yeTjingalanga yePhrovinsi ye-Mpumalanga.

Ngasenyakatho ye-KwaMhlanga, emgwaqweni we-R568 eduze nedorobha le -Klipfontein, kune-Manala Royal Kraal; i-Ndzundza Mabhoko Royal Kraal itholakala enyakatho e-Weltevreden. Ngokuhleleka okukhethekileko, womabili ama-kraal la angavakatjhelwa maqembu amancani.

== Imidlalo ==
Isiqhema se -National First Division i-Casric Stars sise-KwaMhlanga, sidlala imidlalo yaso ekhaya e- Solomon Mahlangu Stadium . 

== Izehlakalo ==
Mhlana ali-18 kuMhlolanja 2025, u-Aserie Ndlovu, intathelizindaba, nomlingani wakhe, u-Zodwa Mdhluli bathunjwa babulawa.  Imizimba yabo yatholakala ngoMeyi 2025 ngaphandle kwe-Rust De Winter Nature Reserve .  

== Qala godu ==

* [[KwaNdebele]]
* [[Siyabuswa]]
* [[IVaalbank|I-Vaalbank]]

== Umthombolwazi ==

# &quot;Premier Soccer League-www.psl.co.za-official website
# Seleka, Ntwaagae
# &quot;Police make breakthrough in missing journalist case | SAnews.
#</text>
      <sha1>5ek7kzk2bpn6dkwb76bt0n78q08bcoy</sha1>
    </revision>
    <revision>
      <id>5491</id>
      <parentid>5488</parentid>
      <timestamp>2025-09-04T09:01:03Z</timestamp>
      <contributor>
        <username>Pholap</username>
        <id>883</id>
      </contributor>
      <minor />
      <origin>5491</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1519" sha1="0tbtn0mjywl2cy5m6zwu3zezc0mb97b" xml:space="preserve">'''I-KwaMhlanga''' yidorobha elisemasipala wesifunda se -Nkangala esifundazweni se [[Isifunda seMpumalanga|-Mpumalanga]] [[Isewula Afrika|eSewula Afrika]] . Yikhaya lomoya lesitjhaba [[AmaNdebele|samaNdebele]] esahlala lapha ekuthomeni kwekhulu le-18.

KwaMhlanga uneminyaka ema-73&amp;nbsp;Ikhilomitha namkha i-awa ukusuka edolobheni elikhulu lenarha, i-Pitoli emgwaqweni u-R573 .

Idorobha leli lathuthuka laba yindawo yokuphatha karhulumende wendawo, begodu nje lihlala ukuphatha kwakarhulumende wesifunda seTlhagwini yeTjingalanga yePhrovinsi ye-Mpumalanga.

Ngasenyakatho ye-KwaMhlanga, emgwaqweni we-R568 eduze nedorobha le -Klipfontein, kune-Manala Royal Kraal; i-Ndzundza Mabhoko Royal Kraal itholakala enyakatho e-Weltevreden. Ngokuhleleka okukhethekileko, womabili ama-kraal la angavakatjhelwa maqembu amancani.

== Imidlalo ==
Isiqhema se -National First Division i-Casric Stars sise-KwaMhlanga, sidlala imidlalo yaso ekhaya e- Solomon Mahlangu Stadium.&lt;ref&gt;[https://psl.co.za/ Premier Soccer League - www.psl.co.za - official website]&lt;/ref&gt; 

== Izehlakalo ==
Mhlana ali-18 kuMhlolanja 2025, u-Aserie Ndlovu, intathelizindaba, nomlingani wakhe, u-Zodwa Mdhluli bathunjwa babulawa.  Imizimba yabo yatholakala ngoMeyi 2025 ngaphandle kwe-Rust De Winter Nature Reserve .  

== Qala godu ==

* [[KwaNdebele]]
* [[Siyabuswa]]
* [[IVaalbank|I-Vaalbank]]

== Umthombolwazi ==

# &quot;Premier Soccer League-www.psl.co.za-official website
# Seleka, Ntwaagae
# &quot;Police make breakthrough in missing journalist case | SAnews.
#</text>
      <sha1>0tbtn0mjywl2cy5m6zwu3zezc0mb97b</sha1>
    </revision>
    <revision>
      <id>5553</id>
      <parentid>5491</parentid>
      <timestamp>2025-09-04T09:37:52Z</timestamp>
      <contributor>
        <username>Pholap</username>
        <id>883</id>
      </contributor>
      <minor />
      <origin>5553</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1803" sha1="a78ib0ivkhjdvpuh0k7baxn7ci13re3" xml:space="preserve">[[Isimumathi:KwaMhlanga, R573-R568-kruising, Mpumalanga.jpg|thumb|KwaMhlanga, R573]]
'''[[KwaMhlanga|I-KwaMhlanga]]''' yidorobha elisemasipala wesifunda se -Nkangala esifundazweni se [[Isifunda seMpumalanga|-Mpumalanga]] [[Isewula Afrika|eSewula Afrika]] . Yikhaya lomoya lesitjhaba [[AmaNdebele|samaNdebele]] esahlala lapha ekuthomeni kwekhulu le-18.

KwaMhlanga uneminyaka ema-73&amp;nbsp;Ikhilomitha namkha i-awa ukusuka edolobheni elikhulu lenarha, i-Pitoli emgwaqweni u-R573 .

Idorobha leli lathuthuka laba yindawo yokuphatha karhulumende wendawo, begodu nje lihlala ukuphatha kwakarhulumende wesifunda seTlhagwini yeTjingalanga yePhrovinsi ye-Mpumalanga.

Ngasenyakatho ye-KwaMhlanga, emgwaqweni we-R568 eduze nedorobha le -Klipfontein, kune-Manala Royal Kraal; i-Ndzundza Mabhoko Royal Kraal itholakala enyakatho e-Weltevreden. Ngokuhleleka okukhethekileko, womabili ama-kraal la angavakatjhelwa maqembu amancani.

== Imidlalo ==
Isiqhema se -National First Division i-Casric Stars sise-KwaMhlanga, sidlala imidlalo yaso ekhaya e- Solomon Mahlangu Stadium.&lt;ref&gt;[https://www.national-football-teams.com/club/30720/2024_1/Casric_Stars_Kwamhlanga.html Casric Stars KwaMhlanga (2024/25) | National Football Teams]&lt;/ref&gt;&lt;ref&gt;[https://psl.co.za/ Premier Soccer League - www.psl.co.za - official website]&lt;/ref&gt; 

== Izehlakalo ==
Mhlana ali-18 kuMhlolanja 2025, u-Aserie Ndlovu, intathelizindaba, nomlingani wakhe, u-Zodwa Mdhluli bathunjwa babulawa.  Imizimba yabo yatholakala ngoMeyi 2025 ngaphandle kwe-Rust De Winter Nature Reserve.&lt;ref&gt;[https://www.ewn.co.za/2025/05/15/aserie-ndlovu-zodwa-mdhluli-case-three-suspects-due-in-court Aserie Ndlovu, Zodwa Mdhluli case: Three suspects due in court]&lt;/ref&gt;  

== Qala godu ==

* [[KwaNdebele]]
* [[Siyabuswa]]
* [[IVaalbank|I-Vaalbank]]

== Umthombolwazi ==</text>
      <sha1>a78ib0ivkhjdvpuh0k7baxn7ci13re3</sha1>
    </revision>
    <revision>
      <id>5583</id>
      <parentid>5553</parentid>
      <timestamp>2025-09-04T09:55:34Z</timestamp>
      <contributor>
        <username>Pholap</username>
        <id>883</id>
      </contributor>
      <minor />
      <origin>5583</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2057" sha1="etkgsq1fyxzt5zehq6qljv14e0r12je" xml:space="preserve">[[Isimumathi:KwaMhlanga, R573-R568-kruising, Mpumalanga.jpg|thumb|KwaMhlanga, R573]]

== &lt;small&gt;'''[[KwaMhlanga|I-KwaMhlanga]]''' yidorobha elisemasipala wesifunda se -Nkangala esifundazweni se [[Isifunda seMpumalanga|-Mpumalanga]] [[Isewula Afrika|eSewula Afrika]] . Yikhaya lomoya lesitjhaba [[AmaNdebele|samaNdebele]] esahlala lapha ekuthomeni kwekhulu le-18.&lt;/small&gt; ==

== &lt;small&gt;KwaMhlanga uneminyaka ema-73&amp;nbsp;Ikhilomitha namkha i-awa ukusuka edolobheni elikhulu lenarha, i-Pitoli emgwaqweni u-R573 .&lt;/small&gt; ==

== &lt;small&gt;Idorobha leli lathuthuka laba yindawo yokuphatha karhulumende wendawo, begodu nje lihlala ukuphatha kwakarhulumende wesifunda seTlhagwini yeTjingalanga yePhrovinsi ye-Mpumalanga.&lt;/small&gt; ==

== &lt;small&gt;Ngasenyakatho ye-KwaMhlanga, emgwaqweni we-R568 eduze nedorobha le -Klipfontein, kune-Manala Royal Kraal; i-Ndzundza Mabhoko Royal Kraal itholakala enyakatho e-Weltevreden. Ngokuhleleka okukhethekileko, womabili ama-kraal la angavakatjhelwa maqembu amancani.&lt;/small&gt; ==

== &lt;small&gt;'''Imidlalo'''&lt;/small&gt; ==

== &lt;small&gt;Isiqhema se -National First Division i-Casric Stars sise-KwaMhlanga, sidlala imidlalo yaso ekhaya e- Solomon Mahlangu Stadium.&lt;ref&gt;[https://www.national-football-teams.com/club/30720/2024_1/Casric_Stars_Kwamhlanga.html Casric Stars KwaMhlanga (2024/25) | National Football Teams]&lt;/ref&gt;&lt;ref&gt;[https://psl.co.za/ Premier Soccer League - www.psl.co.za - official website]&lt;/ref&gt;&lt;/small&gt; ==

== &lt;small&gt;'''Izehlakalo'''&lt;/small&gt; ==

== &lt;small&gt;Mhlana ali-18 kuMhlolanja 2025, u-Aserie Ndlovu, intathelizindaba, nomlingani wakhe, u-Zodwa Mdhluli bathunjwa babulawa.  Imizimba yabo yatholakala ngoMeyi 2025 ngaphandle kwe-Rust De Winter Nature Reserve.&lt;ref&gt;[https://www.ewn.co.za/2025/05/15/aserie-ndlovu-zodwa-mdhluli-case-three-suspects-due-in-court Aserie Ndlovu, Zodwa Mdhluli case: Three suspects due in court]&lt;/ref&gt;&lt;/small&gt; ==

== &lt;small&gt;'''Qala godu'''&lt;/small&gt; ==
* &lt;small&gt;[[KwaNdebele]]&lt;/small&gt;
* &lt;small&gt;[[Siyabuswa]]&lt;/small&gt;
* [[IVaalbank|&lt;small&gt;I-Vaalbank&lt;/small&gt;]]

== &lt;small&gt;'''Umthombolwazi'''&lt;/small&gt; ==</text>
      <sha1>etkgsq1fyxzt5zehq6qljv14e0r12je</sha1>
    </revision>
    <revision>
      <id>5782</id>
      <parentid>5583</parentid>
      <timestamp>2025-09-22T22:48:41Z</timestamp>
      <contributor>
        <username>Mojonom</username>
        <id>593</id>
      </contributor>
      <minor />
      <origin>5782</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2054" sha1="rm3lja7cwkg1i8f5fgz5teu5zhs0le5" xml:space="preserve">[[Isimumathi:KwaMhlanga, R573-R568-kruising, Mpumalanga.jpg|thumb|KwaMhlanga, R573]]

== &lt;small&gt;'''[[KwaMhlanga|I-KwaMhlanga]]''' yidorobha elikumasipala wesifunda se -Nkangala esifundeni se [[Isifunda seMpumalanga|-Mpumalanga]] [[Isewula Afrika|eSewula Afrika]] . Yikhaya lomoya lesitjhaba [[AmaNdebele|samaNdebele]] esahlala lapha ekuthomeni kwekhulu le-18.&lt;/small&gt; ==

== &lt;small&gt;KwaMhlanga uneminyaka ema-73&amp;nbsp;Ikhilomitha namkha i-awa ukusuka edolobheni elikhulu lenarha, i-Pitoli emgwaqweni u-R573 .&lt;/small&gt; ==

== &lt;small&gt;Idorobha leli lathuthuka laba yindawo yokuphatha karhulumende wendawo, begodu nje lihlala ukuphatha kwakarhulumende wesifunda seTlhagwini yeTjingalanga yePhrovinsi ye-Mpumalanga.&lt;/small&gt; ==

== &lt;small&gt;Ngasenyakatho ye-KwaMhlanga, emgwaqweni we-R568 eduze nedorobha le -Klipfontein, kune-Manala Royal Kraal; i-Ndzundza Mabhoko Royal Kraal itholakala enyakatho e-Weltevreden. Ngokuhleleka okukhethekileko, womabili ama-kraal la angavakatjhelwa maqembu amancani.&lt;/small&gt; ==

== &lt;small&gt;'''Imidlalo'''&lt;/small&gt; ==

== &lt;small&gt;Isiqhema se -National First Division i-Casric Stars sise-KwaMhlanga, sidlala imidlalo yaso ekhaya e- Solomon Mahlangu Stadium.&lt;ref&gt;[https://www.national-football-teams.com/club/30720/2024_1/Casric_Stars_Kwamhlanga.html Casric Stars KwaMhlanga (2024/25) | National Football Teams]&lt;/ref&gt;&lt;ref&gt;[https://psl.co.za/ Premier Soccer League - www.psl.co.za - official website]&lt;/ref&gt;&lt;/small&gt; ==

== &lt;small&gt;'''Izehlakalo'''&lt;/small&gt; ==

== &lt;small&gt;Mhlana ali-18 kuMhlolanja 2025, u-Aserie Ndlovu, intathelizindaba, nomlingani wakhe, u-Zodwa Mdhluli bathunjwa babulawa.  Imizimba yabo yatholakala ngoMeyi 2025 ngaphandle kwe-Rust De Winter Nature Reserve.&lt;ref&gt;[https://www.ewn.co.za/2025/05/15/aserie-ndlovu-zodwa-mdhluli-case-three-suspects-due-in-court Aserie Ndlovu, Zodwa Mdhluli case: Three suspects due in court]&lt;/ref&gt;&lt;/small&gt; ==

== &lt;small&gt;'''Qala godu'''&lt;/small&gt; ==
* &lt;small&gt;[[KwaNdebele]]&lt;/small&gt;
* &lt;small&gt;[[Siyabuswa]]&lt;/small&gt;
* [[IVaalbank|&lt;small&gt;I-Vaalbank&lt;/small&gt;]]

== &lt;small&gt;'''Umthombolwazi'''&lt;/small&gt; ==</text>
      <sha1>rm3lja7cwkg1i8f5fgz5teu5zhs0le5</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:CharlotteDineo</title>
    <ns>2</ns>
    <id>928</id>
    <revision>
      <id>5495</id>
      <timestamp>2025-09-04T09:02:15Z</timestamp>
      <contributor>
        <username>CharlotteDineo</username>
        <id>908</id>
      </contributor>
      <comment>page created</comment>
      <origin>5495</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="43" sha1="7304qd9gdnwppwm9hueqq3h8wcjx19b" xml:space="preserve">Igama lami ngingu charlotte 

page 1
page 2</text>
      <sha1>7304qd9gdnwppwm9hueqq3h8wcjx19b</sha1>
    </revision>
    <revision>
      <id>5498</id>
      <parentid>5495</parentid>
      <timestamp>2025-09-04T09:05:58Z</timestamp>
      <contributor>
        <username>CharlotteDineo</username>
        <id>908</id>
      </contributor>
      <comment>created page</comment>
      <origin>5498</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="81" sha1="857ahvu1zwkm4rxqi5x1xmu7ntcmxbf" xml:space="preserve">Igama lami ngingu charlotte 

[[Umsebenzisi:CharlotteDineo/Page 1|page 1]]
page 2</text>
      <sha1>857ahvu1zwkm4rxqi5x1xmu7ntcmxbf</sha1>
    </revision>
    <revision>
      <id>5499</id>
      <parentid>5498</parentid>
      <timestamp>2025-09-04T09:06:43Z</timestamp>
      <contributor>
        <username>CharlotteDineo</username>
        <id>908</id>
      </contributor>
      <comment>created page 2</comment>
      <origin>5499</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="119" sha1="o0a1cq6xjki3gl9gqau5exqclavat8e" xml:space="preserve">Igama lami ngingu charlotte 

[[Umsebenzisi:CharlotteDineo/Page 1|page 1]]
[[Umsebenzisi:CharlotteDineo/Page 2|page 2]]</text>
      <sha1>o0a1cq6xjki3gl9gqau5exqclavat8e</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:CharlotteDineo/Page 1</title>
    <ns>2</ns>
    <id>929</id>
    <revision>
      <id>5500</id>
      <timestamp>2025-09-04T09:07:45Z</timestamp>
      <contributor>
        <username>CharlotteDineo</username>
        <id>908</id>
      </contributor>
      <comment>created page</comment>
      <origin>5500</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="20" sha1="pow2azk7uzw5neett0e35sruzf1dwen" xml:space="preserve">this is a draft page</text>
      <sha1>pow2azk7uzw5neett0e35sruzf1dwen</sha1>
    </revision>
    <revision>
      <id>5532</id>
      <parentid>5500</parentid>
      <timestamp>2025-09-04T09:26:24Z</timestamp>
      <contributor>
        <username>CharlotteDineo</username>
        <id>908</id>
      </contributor>
      <comment>created page</comment>
      <origin>5532</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="162" sha1="8r0i38yoqeidengr5j45zq5ekqxtzvh" xml:space="preserve">this is a draft page
*  https://lh3.googleusercontent.com/CWKMFjeF5UlQ0fZD3vj5lOtqU63Pwf7ti4c7LuKCP5lkt8f4On4JUQbT2H2zeMzcJWroqBztEJdh4mePD9OS0RAGZdqZtHbafA=s1200</text>
      <sha1>8r0i38yoqeidengr5j45zq5ekqxtzvh</sha1>
    </revision>
    <revision>
      <id>5537</id>
      <parentid>5532</parentid>
      <timestamp>2025-09-04T09:27:42Z</timestamp>
      <contributor>
        <username>CharlotteDineo</username>
        <id>908</id>
      </contributor>
      <origin>5537</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="370" sha1="2a71xrmbmor0qjv7czzbedhb79mkjs8" xml:space="preserve">this is a draft page
*  https://lh3.googleusercontent.com/CWKMFjeF5UlQ0fZD3vj5lOtqU63Pwf7ti4c7LuKCP5lkt8f4On4JUQbT2H2zeMzcJWroqBztEJdh4mePD9OS0RAGZdqZtHbafA=s1200
*  Thando Mahlangu said he felt embarrassed when he was asked to leave Boulders Shopping Centre because he was dressed in traditional Ndebele attire. was the treatment fair since he wearing a cultural attire</text>
      <sha1>2a71xrmbmor0qjv7czzbedhb79mkjs8</sha1>
    </revision>
    <revision>
      <id>5547</id>
      <parentid>5537</parentid>
      <timestamp>2025-09-04T09:35:46Z</timestamp>
      <contributor>
        <username>CharlotteDineo</username>
        <id>908</id>
      </contributor>
      <comment>Created page with &quot;&lt;ref&gt;&lt;/ref&gt;&quot;</comment>
      <origin>5547</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="378" sha1="9k1tdeel5hyv8it40j729cykkd50a17" xml:space="preserve">this is a draft page
*  https://lh3.googleusercontent.com/CWKMFjeF5UlQ0fZD3vj5lOtqU63Pwf7ti4c7LuKCP5lkt8f4On4JUQbT2H2zeMzcJWroqBztEJdh4mePD9OS0RAGZdqZtHbafA=s1200
*  u Thando Mahlangu uthi uzizwe ahlambalazekile maka tjhelwa bonyana a phume ngenthabathabeni zeentolo e Boulders Shopping Centre ngombana beka mbethe izembatho zakhe ze sikhethu . Ingabe ipatho beyi fanelekile na?</text>
      <sha1>9k1tdeel5hyv8it40j729cykkd50a17</sha1>
    </revision>
    <revision>
      <id>5678</id>
      <parentid>5547</parentid>
      <timestamp>2025-09-04T11:31:54Z</timestamp>
      <contributor>
        <username>CharlotteDineo</username>
        <id>908</id>
      </contributor>
      <origin>5678</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2538" sha1="jqz57a93c9zvel6rwcbzc8csfx69lvj" xml:space="preserve">this is a draft page
*  https://lh3.googleusercontent.com/CWKMFjeF5UlQ0fZD3vj5lOtqU63Pwf7ti4c7LuKCP5lkt8f4On4JUQbT2H2zeMzcJWroqBztEJdh4mePD9OS0RAGZdqZtHbafA=s1200
*  u thando mahlangu ukhakhazisa isikhethu e seula Africa https://en.wikipedia.org/wiki/South_African
*  u Thando Mahlangu uthi uzizwe ahlambalazekile maka tjhelwa bonyana a phume ngenthabathabeni zeentolo e Boulders Shopping Centre ngombana beka mbethe izembatho zakhe ze sikhethu . Ingabe ipatho beyi fanelekile na? Boulders Shopping Centre umaneja Jose Maponyane utjele i CRL Rights Commission ngoMsombuluko ukuthi yenze lokhu ukuvikela amalungelo wa bathengi abanye u Thando Mahlangu bekangaka mbhathi kuhle.  “Uthe maka bona ngendlela u thando ambethe ngayo,bekabonakala angaka mbathi kuhle. beku ngana mnyanya we sindu e  Midrand lokho bekuzo yelelisa bonyana kunomnyanya we sintu . isiqithi ngabantu begodu kube yinto engingaka yiboni phambilini.  Mangibona bonyana sihlala endaweni la abantu bangakaphilanga kuhle ehloko ngiyaxolisa uku sebenzisa igama leli,bengi zibuza bonyana u phile kuhle ehloko ngombana azange ngibone into efana nale, utjho njalo.Maponyane, aseduze no mmeli wakhe, uvele phambi kwe khomisini nje ngoba umlandu uqhubekela phambili nge Ndebele activist u Thando Mahlangu angavumelwa kobana angene enthabathabeni zeentolo ambethe izembatho zesintu ku ntaka.  U Maponyane uphiwe ithuba loku khuluma no ku phendula kiyo yoke insolo ezi phakamiswe ngu Mahlangu. U thome ngoku qolisa wathi i vidio yesigameko i susiweku  context.  “nge 24 ku Ntaka ngabo 12.15pm, be ka thenga ukudla kwe kwa laba asebenza nabo . ngisa jamele ukudla , ngizwe umsindo ophezulu ukusuka e kioski ukusuka ku mama,kube yinto emangazako.I thethe i ngenze nganaka yona khulu,kula ngibone khona i sokana nga bheka ngabona bonyana bonyana ngaphambili bekungaka valwa ,beka qhoke i sembatho sangaphasi esinqane esifana neengubo.  U Maponyane  uthe u bawe abalindi bendawo kobana ba bawe u  Mahlangu kobana ambathe. uthe une lungelo lonje nge center manager ukuthi a khulumise isimo lesi abalindi bendawo bathe maba buya bathi u Mahlangu uwale ukwembatha noma ukuzivala kuhle.  “ngiye khona ngakhulumisana no Mahlangu bese ngambuza kuhle kobana ngibawa a zivale kuhle ngombana lendawo le ngeye sitjhaba wala wathi yi sintu sakhe   Maponyane uthe ikulumo yakhe no Mahlangu i thethe imizuzu emithathu nama sekoni ama hlanu bese wa khamba nasele imimoya i phezulu.  U Mahlangu uphe ikulumo yakhe phambilini 
*i patho le beyirerhe nje ngombana beka mbethe izembatho ze sindu na?</text>
      <sha1>jqz57a93c9zvel6rwcbzc8csfx69lvj</sha1>
    </revision>
    <revision>
      <id>5686</id>
      <parentid>5678</parentid>
      <timestamp>2025-09-04T11:37:18Z</timestamp>
      <contributor>
        <username>CharlotteDineo</username>
        <id>908</id>
      </contributor>
      <origin>5686</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2580" sha1="95130wt2qo3qy2fzxxzrjynvb7bdlj3" xml:space="preserve">[[Isimumathi:Abomma nabo baba.jpg|thumb]]
this is a draft page
*  https://lh3.googleusercontent.com/CWKMFjeF5UlQ0fZD3vj5lOtqU63Pwf7ti4c7LuKCP5lkt8f4On4JUQbT2H2zeMzcJWroqBztEJdh4mePD9OS0RAGZdqZtHbafA=s1200
*  u thando mahlangu ukhakhazisa isikhethu e seula Africa https://en.wikipedia.org/wiki/South_African
*  u Thando Mahlangu uthi uzizwe ahlambalazekile maka tjhelwa bonyana a phume ngenthabathabeni zeentolo e Boulders Shopping Centre ngombana beka mbethe izembatho zakhe ze sikhethu . Ingabe ipatho beyi fanelekile na? Boulders Shopping Centre umaneja Jose Maponyane utjele i CRL Rights Commission ngoMsombuluko ukuthi yenze lokhu ukuvikela amalungelo wa bathengi abanye u Thando Mahlangu bekangaka mbhathi kuhle.  “Uthe maka bona ngendlela u thando ambethe ngayo,bekabonakala angaka mbathi kuhle. beku ngana mnyanya we sindu e  Midrand lokho bekuzo yelelisa bonyana kunomnyanya we sintu . isiqithi ngabantu begodu kube yinto engingaka yiboni phambilini.  Mangibona bonyana sihlala endaweni la abantu bangakaphilanga kuhle ehloko ngiyaxolisa uku sebenzisa igama leli,bengi zibuza bonyana u phile kuhle ehloko ngombana azange ngibone into efana nale, utjho njalo.Maponyane, aseduze no mmeli wakhe, uvele phambi kwe khomisini nje ngoba umlandu uqhubekela phambili nge Ndebele activist u Thando Mahlangu angavumelwa kobana angene enthabathabeni zeentolo ambethe izembatho zesintu ku ntaka.  U Maponyane uphiwe ithuba loku khuluma no ku phendula kiyo yoke insolo ezi phakamiswe ngu Mahlangu. U thome ngoku qolisa wathi i vidio yesigameko i susiweku  context.  “nge 24 ku Ntaka ngabo 12.15pm, be ka thenga ukudla kwe kwa laba asebenza nabo . ngisa jamele ukudla , ngizwe umsindo ophezulu ukusuka e kioski ukusuka ku mama,kube yinto emangazako.I thethe i ngenze nganaka yona khulu,kula ngibone khona i sokana nga bheka ngabona bonyana bonyana ngaphambili bekungaka valwa ,beka qhoke i sembatho sangaphasi esinqane esifana neengubo.  U Maponyane  uthe u bawe abalindi bendawo kobana ba bawe u  Mahlangu kobana ambathe. uthe une lungelo lonje nge center manager ukuthi a khulumise isimo lesi abalindi bendawo bathe maba buya bathi u Mahlangu uwale ukwembatha noma ukuzivala kuhle.  “ngiye khona ngakhulumisana no Mahlangu bese ngambuza kuhle kobana ngibawa a zivale kuhle ngombana lendawo le ngeye sitjhaba wala wathi yi sintu sakhe   Maponyane uthe ikulumo yakhe no Mahlangu i thethe imizuzu emithathu nama sekoni ama hlanu bese wa khamba nasele imimoya i phezulu.  U Mahlangu uphe ikulumo yakhe phambilini 
*i patho le beyirerhe nje ngombana beka mbethe izembatho ze sindu na?</text>
      <sha1>95130wt2qo3qy2fzxxzrjynvb7bdlj3</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:CharlotteDineo/Page 2</title>
    <ns>2</ns>
    <id>930</id>
    <revision>
      <id>5501</id>
      <timestamp>2025-09-04T09:08:24Z</timestamp>
      <contributor>
        <username>CharlotteDineo</username>
        <id>908</id>
      </contributor>
      <comment>created page 2</comment>
      <origin>5501</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="20" sha1="pow2azk7uzw5neett0e35sruzf1dwen" xml:space="preserve">this is a draft page</text>
      <sha1>pow2azk7uzw5neett0e35sruzf1dwen</sha1>
    </revision>
    <revision>
      <id>5527</id>
      <parentid>5501</parentid>
      <timestamp>2025-09-04T09:24:30Z</timestamp>
      <contributor>
        <username>CharlotteDineo</username>
        <id>908</id>
      </contributor>
      <comment>Created page with &quot;&lt;ref&gt;&lt;/ref&gt;&quot;</comment>
      <origin>5527</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="292" sha1="c3akldw6tgx5bzt1g8k8ykfjznuni8l" xml:space="preserve">[[Thuso Mbedu|this]] i[https://lh3.googleusercontent.com/CWKMFjeF5UlQ0fZD3vj5lOtqU63Pwf7ti4c7LuKCP5lkt8f4On4JUQbT2H2zeMzcJWroqBztEJdh4mePD9OS0RAGZdqZtHbafA=s1200 CWKMFjeF5UlQ0fZD3vj5lOtqU63Pwf7ti4c7LuKCP5lkt8f4On4JUQbT2H2zeMzcJWroqBztEJdh4mePD9OS0RAGZdqZtHbafA=s1200 (866×800)]s a draft page</text>
      <sha1>c3akldw6tgx5bzt1g8k8ykfjznuni8l</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Cite journal</title>
    <ns>10</ns>
    <id>931</id>
    <revision>
      <id>5505</id>
      <timestamp>2025-09-04T09:10:36Z</timestamp>
      <contributor>
        <username>Mbonani JayJay</username>
        <id>892</id>
      </contributor>
      <comment>Created page with &quot;&lt;ref&gt;{{Cite journal |last=Kaizer |first=Ted |date=2012-10-26 |title=Dura‐Europos |url=https://doi.org/10.1002/9781444338386.wbeah18037 |journal=The Encyclopedia of Ancient History |doi=10.1002/9781444338386.wbeah18037}}&lt;/ref&gt;&quot;</comment>
      <origin>5505</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="227" sha1="7zmh9t07cgddes5mzssxach6iqlivvi" xml:space="preserve">&lt;ref&gt;{{Cite journal |last=Kaizer |first=Ted |date=2012-10-26 |title=Dura‐Europos |url=https://doi.org/10.1002/9781444338386.wbeah18037 |journal=The Encyclopedia of Ancient History |doi=10.1002/9781444338386.wbeah18037}}&lt;/ref&gt;</text>
      <sha1>7zmh9t07cgddes5mzssxach6iqlivvi</sha1>
    </revision>
  </page>
  <page>
    <title>U-Connie Ferguson</title>
    <ns>0</ns>
    <id>932</id>
    <revision>
      <id>5524</id>
      <timestamp>2025-09-04T09:23:44Z</timestamp>
      <contributor>
        <username>ThembekileSihle29</username>
        <id>887</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1308750348|Connie Ferguson]]&quot;</comment>
      <origin>5524</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3445" sha1="9t0v9qhkoo91ncgv5g0qjkja2omt8qw" xml:space="preserve">
 

'''U-Constance Connie Ferguson''' (Masilo ; wabelethwa mhla amalanga ali-10 kuMgwengweni 1970)   mlingisi weSewula Afrika we-Motswana, umenzi wamafilimu, umkhiqizi kanye nosomabhizinisi. Waziwa khulu ngendima yakhe engu-Karabo Moroka kwenye yemidlalo eyaduma khulu  eSewula Afrika, ''i-Generations''.   Wadlala emdlalweni lo kusukela ekuthomeni kwawo ngo-1993 bekwaba kulapho aphuma khona ngo-2010. Ngo-2014, waphinda wadlala indima yakhe emdlalweni ngemva kokungabi khona iminyaka emine.  U-Ferguson bekasekhava yemagazini ''ye-Forbes Woman Africa'' ngo-2018. 

== Ibizelo ==

=== ''Umdlalo we-Generations (1993–2010; 2014–2016; 2023)'' ===
Ngomnyaka ka-1993, wathoma ukudlala indima ekulu ka-Karabo Moroka, umka- Tau Mogale nodadewabo ka-Archie Moroka, kumdlalo odumileko weSewula Afrika, ''i-Generations.''  Wadlala no- Menzi Ngubane, u-Slindile Nodangala no- Sophie Ndaba. Ngomnyaka ka-2010, ngemva kokudlala indima ephambili ka-Karabo Moroka iminyaka eli-16,  u-Connie wamemezela ukutjhiya kwakhe i-Generations &quot;ukuyokwenza eminye yemisebenzi&quot;.  U-Ferguson watjhiya i-Generations ngobuhle njengombana abuyela emdlalweni lo ngemva kweminyaka emine, ngo-2014, ukusiza ukuthoma kabutjha ''i-Generations: The Legacy''.  Watjhiya umdlalo lo godu ngomnyaka ka-2016.  Kwathi ngomnyaka ka-2023, u-Ferguson wabuyela emdlalweni, kanye no-Rapulana Seiphemo ukuyokudlala iindima zabo ezidumileko njengo-Karabo Moroka no-Tau Mogale. 

=== ''I-The Wild (2010–2013)'' ===
Ngemva kokusuka kwakhe ku ''-Generations'' ngo-2010, waragela phambili nokudlala indima ephambili ye- M-Net telenovela ''The Wild,''  eyadutjulwa eplasini lenyamazana elingakajayeleki eSewula Afrika. Wadlala ndawonye nomyeni wakhe wamambala, u-Shona Ferguson, bekwaba kulapho ikhanselwa khona ngoRhoboyi ngo-2013.  

=== Amafilimu we-Ferguson (2010-nje) ===
U-Connie nomyeni wakhe, u-Shona, bathoma ikhamphani kamabonakude i-Ferguson Films ngo-2010.  Umkhiqizo wabo wokuthoma, ''i-Rockville'',  wathunyelwa yi-M-Net ngemva kweminyaka emithathu. Eminye imikhiqizo yemidlalo yabo ifaka hlangana,  ''Isipho'',  ''Isihlalo sobukhosi'',  ''Indlovukazi''  kanye ''noMkhohlisi'' .  Iinthandani zivame ukuvela emidlalweni yazo; ngokwesibonelo, u-Connie wadlala indima ka-Harriet Khoza ku ''-The Queen.'' 

''Umdlalo i The Queen'' yaphakanyiswa emikhakheni eminengi e- South African Film and Television Awards ngomnyaka ka-2018. 

Uvela emdlalweni we-Netflix obizwa nge &quot;Kings of Jo'burg&quot; owangena emlandweni wesibili ngoTjhirhweni 2023.  Abalingisi abanye babo bekungu -Cindy Mahlangu, u-Buhle Samuels, u-Zolisa Xaluva kanye nomlingisi we-Nigeria u-Enyinna Nwigwe. 

=== AmaBhizinisi ===
U-Ferguson wathoma ibhizinisi lokuthengisa izinto zokuhlamba elibizwa nge-True Self ngo-2008, kanye nesizeso somzimba ngo-2014. 

== Ipilo yomuntu mathupha ==
U-Ferguson watjhada nomlingisi omunye u-Neo Matsunyane ngo-1992. NgoNobayeni 1993, babusiswa ngendodakazi. Bahlukana ngo-1998, ngemva kweminyaka emihlanu batjhadile. 

NgoJulayi 2001 e-Matseliso Secondary, u-Ferguson wahlangana nomlingisi u- Shona Ferguson.  NgoNovemba 2001, ngemva kweminyaka emithathu ahlukene no-Matsunyane, batjhada. NgoMgwengweni 2002, iinthandani zamukela indodakazi.  Ngemva kweminyaka engaba ma-20 yomtjhado, u-Shona Ferguson wahlongakala ntambama mhla amalanga am-30 kuNtaka 2021 ngebanga lemiraro ehlobene ne [[Ingogwana ye covid-19|-COVID-19]]. {{Reflist|2}}
[[Mkhakha:Pages with unreviewed translations]]</text>
      <sha1>9t0v9qhkoo91ncgv5g0qjkja2omt8qw</sha1>
    </revision>
    <revision>
      <id>5585</id>
      <parentid>5524</parentid>
      <timestamp>2025-09-04T09:56:47Z</timestamp>
      <contributor>
        <username>ThembekileSihle29</username>
        <id>887</id>
      </contributor>
      <comment>I have created Imithombo lwazi</comment>
      <origin>5585</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4555" sha1="halg8iykuuzffz2l7y6je4k34tysu2j" xml:space="preserve">
 

'''U-Constance Connie Ferguson''' (Masilo ; wabelethwa mhla amalanga ali-10 kuMgwengweni 1970). &lt;ref&gt;''@Connie_Ferguson (5 April 2015).'' &quot;birthplace&quot; ''(''Tweet''). Retrieved 24 June 2020 &amp;#x2013; via'' Twitter''.''&lt;/ref&gt;  &lt;ref&gt;&quot;Ferguson Films&quot;''. b2bhint.''&lt;/ref&gt; mlingisi weSewula Afrika we-Motswana, umenzi wamafilimu, umkhiqizi kanye nosomabhizinisi. Waziwa khulu ngendima yakhe engu-Karabo Moroka kwenye yemidlalo eyaduma khulu  eSewula Afrika, ''i-Generations''&lt;ref&gt;The South African TV authority. Currently plays Harriet Khoza on the Ferguson Films and M-net original soap The Queen , ''Connie Furguson'', 2014. Retrieved on 4 October 2014.&lt;/ref&gt;&lt;ref&gt;All4Women &quot;Connie Ferguson&quot; {{Webarchive|url=https://web.archive.org/web/20141006095052/http://www.all4women.co.za/entertainment/celebrity-gossip/connie-ferguson-mourns-the-death-of-her-mother|date=6 October 2014}}, ''Connie Ferguson mourns the death of her mother'', Johannesburg, 29 July 2013. Retrieved on 4 October 2014.&lt;/ref&gt;.   Wadlala emdlalweni lo kusukela ekuthomeni kwawo ngo-1993 bekwaba kulapho aphuma khona ngo-2010. Ngo-2014, waphinda wadlala indima yakhe emdlalweni ngemva kokungabi khona iminyaka emine.&lt;ref&gt;Bernice Maune &quot;Confirmed: Connie Ferguson is coming back to 'Generations'&quot;, ''The Times (South Africa)'', Johannesburg, 23 October 2014. Retrieved on 24 October 2014.&lt;/ref&gt;U-Ferguson bekasekhava yemagazini ''ye-Forbes Woman Africa'' ngo-2018.&lt;ref&gt;''Selisho, Kaunda.'' &quot;Connie Ferguson stuns on the cover of Forbes Woman&quot;''. The Citizen. Retrieved 2 November 2018.''&lt;/ref&gt; 

== Ibizelo ==

=== ''Umdlalo we-Generations (1993–2010; 2014–2016; 2023)'' ===
Ngomnyaka ka-1993, wathoma ukudlala indima ekulu ka-Karabo Moroka, umka- Tau Mogale nodadewabo ka-Archie Moroka, kumdlalo odumileko weSewula Afrika, ''i-Generations.''   Wadlala no- Menzi Ngubane, u-Slindile Nodangala no- Sophie Ndaba. Ngomnyaka ka-2010, ngemva kokudlala indima ephambili ka-Karabo Moroka iminyaka eli-16,&lt;ref&gt;&quot;Karabo's clumsy exit from Generations&quot;''. SowetanLIVE. Retrieved 28 May 2024.''&lt;/ref&gt; u-Connie wamemezela ukutjhiya kwakhe i-Generations &quot;ukuyokwenza eminye yemisebenzi&quot;.  U-Ferguson watjhiya i-Generations ngobuhle njengombana abuyela emdlalweni lo ngemva kweminyaka emine, ngo-2014, ukusiza ukuthoma kabutjha ''i-Generations: The Legacy''.  Watjhiya umdlalo lo godu ngomnyaka ka-2016.  Kwathi ngomnyaka ka-2023, u-Ferguson wabuyela emdlalweni, kanye no-Rapulana Seiphemo ukuyokudlala iindima zabo ezidumileko njengo-Karabo Moroka no-Tau Mogale. 

=== ''I-The Wild (2010–2013)'' ===
Ngemva kokusuka kwakhe ku ''-Generations'' ngo-2010, waragela phambili nokudlala indima ephambili ye- M-Net telenovela ''The Wild,''  eyadutjulwa eplasini lenyamazana elingakajayeleki eSewula Afrika. Wadlala ndawonye nomyeni wakhe wamambala, u-Shona Ferguson, bekwaba kulapho ikhanselwa khona ngoRhoboyi ngo-2013.  

=== Amafilimu we-Ferguson (2010-nje) ===
U-Connie nomyeni wakhe, u-Shona, bathoma ikhamphani kamabonakude i-Ferguson Films ngo-2010.  Umkhiqizo wabo wokuthoma, ''i-Rockville'',  wathunyelwa yi-M-Net ngemva kweminyaka emithathu. Eminye imikhiqizo yemidlalo yabo ifaka hlangana,  ''Isipho'',  ''Isihlalo sobukhosi'',  ''Indlovukazi''  kanye ''noMkhohlisi'' .  Iinthandani zivame ukuvela emidlalweni yazo; ngokwesibonelo, u-Connie wadlala indima ka-Harriet Khoza ku ''-The Queen.'' 

''Umdlalo i The Queen'' yaphakanyiswa emikhakheni eminengi e- South African Film and Television Awards ngomnyaka ka-2018. 

Uvela emdlalweni we-Netflix obizwa nge &quot;Kings of Jo'burg&quot; owangena emlandweni wesibili ngoTjhirhweni 2023.  Abalingisi abanye babo bekungu -Cindy Mahlangu, u-Buhle Samuels, u-Zolisa Xaluva kanye nomlingisi we-Nigeria u-Enyinna Nwigwe. 

=== AmaBhizinisi ===
U-Ferguson wathoma ibhizinisi lokuthengisa izinto zokuhlamba elibizwa nge-True Self ngo-2008, kanye nesizeso somzimba ngo-2014. 

== Ipilo yomuntu mathupha ==
U-Ferguson watjhada nomlingisi omunye u-Neo Matsunyane ngo-1992. NgoNobayeni 1993, babusiswa ngendodakazi. Bahlukana ngo-1998, ngemva kweminyaka emihlanu batjhadile. 

NgoJulayi 2001 e-Matseliso Secondary, u-Ferguson wahlangana nomlingisi u- Shona Ferguson.  NgoNovemba 2001, ngemva kweminyaka emithathu ahlukene no-Matsunyane, batjhada. NgoMgwengweni 2002, iinthandani zamukela indodakazi.  Ngemva kweminyaka engaba ma-20 yomtjhado, u-Shona Ferguson wahlongakala ntambama mhla amalanga am-30 kuNtaka 2021 ngebanga lemiraro ehlobene ne [[Ingogwana ye covid-19|-COVID-19]]. 

=== Imithombolwazi ===
{{Reflist|2}}
[[Mkhakha:Pages with unreviewed translations]]</text>
      <sha1>halg8iykuuzffz2l7y6je4k34tysu2j</sha1>
    </revision>
    <revision>
      <id>5616</id>
      <parentid>5585</parentid>
      <timestamp>2025-09-04T10:39:15Z</timestamp>
      <contributor>
        <username>ThembekileSihle29</username>
        <id>887</id>
      </contributor>
      <comment>Added picture</comment>
      <origin>5616</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5530" sha1="lduw7er13ikervvbfj95utq6whg49c2" xml:space="preserve">
 
[[Isimumathi:Connie Ferguson in 2018.jpg|thumb|Isithombe saka Connie Ferguson]]


'''U-Constance Connie Ferguson''' (Masilo; wabelethwa mhla amalanga ali-10 kuMgwengweni 1970). &lt;ref&gt;''@Connie_Ferguson (5 April 2015).'' &quot;birthplace&quot; ''(''Tweet''). Retrieved 24 June 2020 &amp;#x2013; via'' Twitter''.''&lt;/ref&gt;  &lt;ref&gt;&quot;Ferguson Films&quot;''. b2bhint.''&lt;/ref&gt; mlingisi weSewula Afrika we-Motswana, umenzi wamafilimu, umkhiqizi kanye nosomabhizinisi. Waziwa khulu ngendima yakhe engu-Karabo Moroka kwenye yemidlalo eyaduma khulu eSewula Afrika, ''i-Generations''&lt;ref&gt;The South African TV authority. Currently plays Harriet Khoza on the Ferguson Films and M-net original soap The Queen , ''Connie Furguson'', 2014. Retrieved on 4 October 2014.&lt;/ref&gt;&lt;ref&gt;All4Women &quot;Connie Ferguson&quot; {{Webarchive|url=https://web.archive.org/web/20141006095052/http://www.all4women.co.za/entertainment/celebrity-gossip/connie-ferguson-mourns-the-death-of-her-mother|date=6 October 2014}}, ''Connie Ferguson mourns the death of her mother'', Johannesburg, 29 July 2013. Retrieved on 4 October 2014.&lt;/ref&gt;.   Wadlala emdlalweni lo kusukela ekuthomeni kwawo ngo-1993 bekwaba kulapho aphuma khona ngo-2010. Ngo-2014, waphinda wadlala indima yakhe emdlalweni ngemva kokungabi khona iminyaka emine.&lt;ref&gt;Bernice Maune &quot;Confirmed: Connie Ferguson is coming back to 'Generations'&quot;, ''The Times (South Africa)'', Johannesburg, 23 October 2014. Retrieved on 24 October 2014.&lt;/ref&gt;U-Ferguson bekasekhava yemagazini ''ye-Forbes Woman Africa'' ngo-2018.&lt;ref&gt;''Selisho, Kaunda.'' &quot;Connie Ferguson stuns on the cover of Forbes Woman&quot;''. The Citizen. Retrieved 2 November 2018.''&lt;/ref&gt; 

== Ibizelo ==

=== ''Umdlalo we-Generations (1993–2010; 2014–2016; 2023)'' ===
Ngomnyaka ka-1993, wathoma ukudlala indima ekulu ka-Karabo Moroka, umka- Tau Mogale nodadewabo ka-Archie Moroka, kumdlalo odumileko weSewula Afrika, ''i-Generations.''   Wadlala no- Menzi Ngubane, u-Slindile Nodangala no- Sophie Ndaba. Ngomnyaka ka-2010, ngemva kokudlala indima ephambili ka-Karabo Moroka iminyaka eli-16,&lt;ref&gt;&quot;Karabo's clumsy exit from Generations&quot;''. SowetanLIVE. Retrieved 28 May 2024.''&lt;/ref&gt; u-Connie wamemezela ukutjhiya kwakhe i-Generations &quot;ukuyokwenza eminye yemisebenzi&quot;&lt;ref&gt;&quot;Connie Ferguson leaves Generations. Again. | News | TVSA&quot;''. www.tvsa.co.za. Retrieved 28 May 2024''&lt;/ref&gt;.  U-Ferguson watjhiya i-Generations ngobuhle njengombana abuyela emdlalweni lo ngemva kweminyaka emine, ngo-2014, ukusiza ukuthoma kabutjha ''i-Generations: The Legacy''. &lt;ref&gt;&quot;Confirmed: Connie Ferguson is coming back to 'Generations'&quot;''. TimesLIVE. Retrieved 28 May 2024.''&lt;/ref&gt; Watjhiya umdlalo lo godu ngomnyaka ka-2016.&lt;ref&gt;&quot;'Till we meet again'- Connie Ferguson leaves the set of Generations: The Legacy&quot;''. TimesLIVE. 29 June 2016. Retrieved 28 May 2024.''&lt;/ref&gt;  Kwathi ngomnyaka ka-2023, u-Ferguson wabuyela emdlalweni, kanye no-Rapulana Seiphemo ukuyokudlala iindima zabo ezidumileko njengo-Karabo Moroka no-Tau Mogale.&lt;ref&gt;''Tlhoaele, Kgalalelo.'' &quot;Top stars return to Generations: The legacy&quot;''. Daily Sun. Retrieved 28 May 2024.''&lt;/ref&gt; 

=== ''I-The Wild (2010–2013)'' ===
Ngemva kokusuka kwakhe ku ''-Generations'' ngo-2010, waragela phambili nokudlala indima ephambili ye- M-Net telenovela ''The Wild,''&lt;ref&gt;&quot;Watch The Wild - Season 1 | Prime Video&quot;''. www.amazon.com. Retrieved 28 May 2024.''&lt;/ref&gt;  eyadutjulwa eplasini lenyamazana elingakajayeleki eSewula Afrika. Wadlala ndawonye nomyeni wakhe wamambala, u-Shona Ferguson, bekwaba kulapho ikhanselwa khona ngoRhoboyi ngo-2013.&lt;ref&gt;&quot;Couple set to rock the box&quot;''. Independent Online. 20 May 2013. Retrieved 16 August 2024''&lt;/ref&gt;&lt;ref&gt;''Ferreira, Thinus.'' &quot;M-Net cancels The Wild&quot;''. Life. Retrieved 28 May 2024.''&lt;/ref&gt;  

=== Amafilimu we-Ferguson (2010-nje) ===
U-Connie nomyeni wakhe, u-Shona, bathoma ikhamphani kamabonakude i-Ferguson Films ngo-2010.  Umkhiqizo wabo wokuthoma, ''i-Rockville'', wathunyelwa yi-M-Net ngemva kweminyaka emithathu&lt;ref&gt;''Morkel, Graye.'' &quot;Connie and Shona Ferguson: Their love story in 11 photos&quot;''. Life. Retrieved 28 May 2024.''&lt;/ref&gt;. Eminye imikhiqizo yemidlalo yabo ifaka hlangana,  ''Isipho'',  ''Isihlalo sobukhosi'',  ''Indlovukazi''  kanye ''noMkhohlisi.''  Iinthandani zivame ukuvela emidlalweni yazo; ngokwesibonelo, u-Connie wadlala indima ka-Harriet Khoza ku ''-The Queen.'' 

''Umdlalo i The Queen'' yaphakanyiswa emikhakheni eminengi e- South African Film and Television Awards ngomnyaka ka-2018. 

Uvela emdlalweni we-Netflix obizwa nge &quot;Kings of Jo'burg&quot; owangena emlandweni wesibili ngoTjhirhweni 2023.  Abalingisi abanye babo bekungu -Cindy Mahlangu, u-Buhle Samuels, u-Zolisa Xaluva kanye nomlingisi we-Nigeria u-Enyinna Nwigwe. 

=== AmaBhizinisi ===
U-Ferguson wathoma ibhizinisi lokuthengisa izinto zokuhlamba elibizwa nge-True Self ngo-2008, kanye nesizeso somzimba ngo-2014. 

== Ipilo yomuntu mathupha ==
U-Ferguson watjhada nomlingisi omunye u-Neo Matsunyane ngo-1992. NgoNobayeni 1993, babusiswa ngendodakazi. Bahlukana ngo-1998, ngemva kweminyaka emihlanu batjhadile. 

NgoJulayi 2001 e-Matseliso Secondary, u-Ferguson wahlangana nomlingisi u- Shona Ferguson.  NgoNovemba 2001, ngemva kweminyaka emithathu ahlukene no-Matsunyane, batjhada. NgoMgwengweni 2002, iinthandani zamukela indodakazi.  Ngemva kweminyaka engaba ma-20 yomtjhado, u-Shona Ferguson wahlongakala ntambama mhla amalanga am-30 kuNtaka 2021 ngebanga lemiraro ehlobene ne [[Ingogwana ye covid-19|-COVID-19]]. 

=== Imithombolwazi ===
{{Reflist|2}}
[[Mkhakha:Pages with unreviewed translations]]</text>
      <sha1>lduw7er13ikervvbfj95utq6whg49c2</sha1>
    </revision>
    <revision>
      <id>5696</id>
      <parentid>5616</parentid>
      <timestamp>2025-09-04T12:05:55Z</timestamp>
      <contributor>
        <username>ThembekileSihle29</username>
        <id>887</id>
      </contributor>
      <origin>5696</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7222" sha1="ldff4gjh3a0luvsh04hgn3nxfogtf89" xml:space="preserve">
 
[[Isimumathi:Connie Ferguson in 2018.jpg|thumb|Isithombe saka Connie Ferguson]]


'''U-Constance Connie Ferguson''' (Masilo; wabelethwa mhla amalanga ali-10 kuMgwengweni 1970). &lt;ref&gt;''@Connie_Ferguson (5 April 2015).'' &quot;birthplace&quot; ''(''Tweet''). Retrieved 24 June 2020 &amp;#x2013; via'' Twitter''.''&lt;/ref&gt;  &lt;ref&gt;&quot;Ferguson Films&quot;''. b2bhint.''&lt;/ref&gt; mlingisi weSewula Afrika we-Motswana, umenzi wamafilimu, umkhiqizi kanye nosomabhizinisi. Waziwa khulu ngendima yakhe engu-Karabo Moroka kwenye yemidlalo eyaduma khulu eSewula Afrika, ''i-Generations''&lt;ref&gt;The South African TV authority. Currently plays Harriet Khoza on the Ferguson Films and M-net original soap The Queen , ''Connie Furguson'', 2014. Retrieved on 4 October 2014.&lt;/ref&gt;&lt;ref&gt;All4Women &quot;Connie Ferguson&quot; {{Webarchive|url=https://web.archive.org/web/20141006095052/http://www.all4women.co.za/entertainment/celebrity-gossip/connie-ferguson-mourns-the-death-of-her-mother|date=6 October 2014}}, ''Connie Ferguson mourns the death of her mother'', Johannesburg, 29 July 2013. Retrieved on 4 October 2014.&lt;/ref&gt;.   Wadlala emdlalweni lo kusukela ekuthomeni kwawo ngo-1993 bekwaba kulapho aphuma khona ngo-2010. Ngo-2014, waphinda wadlala indima yakhe emdlalweni ngemva kokungabi khona iminyaka emine.&lt;ref&gt;Bernice Maune &quot;Confirmed: Connie Ferguson is coming back to 'Generations'&quot;, ''The Times (South Africa)'', Johannesburg, 23 October 2014. Retrieved on 24 October 2014.&lt;/ref&gt;U-Ferguson bekasekhava yemagazini ''ye-Forbes Woman Africa'' ngo-2018.&lt;ref&gt;''Selisho, Kaunda.'' &quot;Connie Ferguson stuns on the cover of Forbes Woman&quot;''. The Citizen. Retrieved 2 November 2018.''&lt;/ref&gt; 

== Ibizelo ==

=== ''Umdlalo we-Generations (1993–2010; 2014–2016; 2023)'' ===
Ngomnyaka ka-1993, wathoma ukudlala indima ekulu ka-Karabo Moroka, umka- Tau Mogale nodadewabo ka-Archie Moroka, kumdlalo odumileko weSewula Afrika, ''i-Generations.''   Wadlala no- Menzi Ngubane, u-Slindile Nodangala no- Sophie Ndaba. Ngomnyaka ka-2010, ngemva kokudlala indima ephambili ka-Karabo Moroka iminyaka eli-16,&lt;ref&gt;&quot;Karabo's clumsy exit from Generations&quot;''. SowetanLIVE. Retrieved 28 May 2024.''&lt;/ref&gt; u-Connie wamemezela ukutjhiya kwakhe i-Generations &quot;ukuyokwenza eminye yemisebenzi&quot;&lt;ref&gt;&quot;Connie Ferguson leaves Generations. Again. | News | TVSA&quot;''. www.tvsa.co.za. Retrieved 28 May 2024''&lt;/ref&gt;.  U-Ferguson watjhiya i-Generations ngobuhle njengombana abuyela emdlalweni lo ngemva kweminyaka emine, ngo-2014, ukusiza ukuthoma kabutjha ''i-Generations: The Legacy''. &lt;ref&gt;&quot;Confirmed: Connie Ferguson is coming back to 'Generations'&quot;''. TimesLIVE. Retrieved 28 May 2024.''&lt;/ref&gt; Watjhiya umdlalo lo godu ngomnyaka ka-2016.&lt;ref&gt;&quot;'Till we meet again'- Connie Ferguson leaves the set of Generations: The Legacy&quot;''. TimesLIVE. 29 June 2016. Retrieved 28 May 2024.''&lt;/ref&gt;  Kwathi ngomnyaka ka-2023, u-Ferguson wabuyela emdlalweni, kanye no-Rapulana Seiphemo ukuyokudlala iindima zabo ezidumileko njengo-Karabo Moroka no-Tau Mogale.&lt;ref&gt;''Tlhoaele, Kgalalelo.'' &quot;Top stars return to Generations: The legacy&quot;''. Daily Sun. Retrieved 28 May 2024.''&lt;/ref&gt; 

=== ''I-The Wild (2010–2013)'' ===
Ngemva kokusuka kwakhe ku ''-Generations'' ngo-2010, waragela phambili nokudlala indima ephambili ye- M-Net telenovela ''The Wild,''&lt;ref&gt;&quot;Watch The Wild - Season 1 | Prime Video&quot;''. www.amazon.com. Retrieved 28 May 2024.''&lt;/ref&gt;  eyadutjulwa eplasini lenyamazana elingakajayeleki eSewula Afrika. Wadlala ndawonye nomyeni wakhe wamambala, u-Shona Ferguson, bekwaba kulapho ikhanselwa khona ngoRhoboyi ngo-2013.&lt;ref&gt;&quot;Couple set to rock the box&quot;''. Independent Online. 20 May 2013. Retrieved 16 August 2024''&lt;/ref&gt;&lt;ref&gt;''Ferreira, Thinus.'' &quot;M-Net cancels The Wild&quot;''. Life. Retrieved 28 May 2024.''&lt;/ref&gt;  

=== Amafilimu we-Ferguson (2010-nje) ===
U-Connie nomyeni wakhe, u-Shona, bathoma ikhamphani kamabonakude i-Ferguson Films ngo-2010.  Umkhiqizo wabo wokuthoma, ''i-Rockville'',&lt;ref&gt;''Nyhaba, Theo (17 March 2021).'' &quot;Rockville making a comeback to the small screen&quot;''. Sunday World. Retrieved 28 May 2024.''&lt;/ref&gt; wathunyelwa yi-M-Net ngemva kweminyaka emithathu&lt;ref&gt;''Morkel, Graye.'' &quot;Connie and Shona Ferguson: Their love story in 11 photos&quot;''. Life. Retrieved 28 May 2024.''&lt;/ref&gt;. Eminye imikhiqizo yemidlalo yabo ifaka hlangana, The ''Gift, The Throne,''&lt;ref&gt;&quot;She reigns! - The Throne&quot;''. M-Net - She reigns! - The Throne. Retrieved 28 May 2024.''&lt;/ref&gt; ''The Queen''&lt;ref&gt;''Mathobela, Phuti.'' &quot;The Queen actors: Siyabonga, Ferguson Films and Mzansi!&quot;''. Daily Sun. Retrieved 28 May 2024.''&lt;/ref&gt;  kanye ''ne-The imposter.''&lt;ref&gt;''Marshall, Rhodé.'' &quot;The Imposter presents a new era in storytelling&quot;''. City Press. Retrieved 28 May 2024.''&lt;/ref&gt;  Iinthandani zivame ukuvela emidlalweni yazo; ngokwesibonelo, u-Connie wadlala indima ka-Harriet Khoza ku ''-The Queen.''&lt;ref&gt;&quot;Connie Ferguson says goodbye to Harriet Khoza as filming on 'The Queen' wraps up&quot;''. Independent Online. 31 October 2022. Retrieved 16 August 2024.''&lt;/ref&gt; 

''Umdlalo i -The Queen'' yaphakanyiswa emikhakheni eminengi e- South African Film and Television Awards ngomnyaka ka-2018.&lt;ref&gt;''Javan, Melissa (2 October 2018).'' &quot;5 Things You Should Know About Connie and Shona Ferguson's Growing TV and Film Empire - SME&quot;''. SME. Archived from'' the original ''on 16 April 2019. Retrieved 2 November 2018.''&lt;/ref&gt; 

Uvela emdlalweni we-Netflix obizwa nge &quot;Kings of Jo'burg&quot; owangena emlandweni wesibili ngoTjhirhweni 2023.&lt;ref&gt;''Selisho, Kaunda (27 January 2023).'' &quot;Is 'Kings Of Joburg 2' worth the watch?&quot;''. The Citizen. Retrieved 28 May 2024.''&lt;/ref&gt;  Abalingisi abanye babo bekungu -Cindy Mahlangu, u-Buhle Samuels, u-Zolisa Xaluva kanye nomlingisi we-Nigeria u-Enyinna Nwigwe&lt;ref&gt;''BellaNaija.com (23 January 2023).'' &quot;Red Carpet Glam from Netflix's &quot;Kings of Jo'Burg&quot; Johannesburg Premiere&quot;''. BellaNaija. Retrieved 10 June 2023.''&lt;/ref&gt;. 

=== AmaBhizinisi ===
U-Ferguson wathoma ibhizinisi lokuthengisa izinto zokuhlamba elibizwa nge-True Self ngo-2008, kanye nesizeso somzimba ngo-2014.&lt;ref&gt;&lt;sup&gt;&amp;#x5B;''permanent dead link''&amp;#x5D;&lt;/sup&gt;&lt;/ref&gt; 

== Ipilo yomuntu mathupha ==
U-Ferguson watjhada nomlingisi omunye u-Neo Matsunyane ngo-1992. NgoNobayeni 1993, babusiswa ngendodakazi. Bahlukana ngo-1998, ngemva kweminyaka emihlanu batjhadile.&lt;ref&gt;&quot;Connie Ferguson's ex-husband Neo Matsunyane to appear in season 2 of Kings of Joburg&quot;''. www.zimoja.co.za. Retrieved 28 May 2024.''&lt;/ref&gt; 

NgoJulayi 2001 e-Matseliso Secondary, u-Ferguson wahlangana nomlingisi u- Shona Ferguson.  NgoNovemba 2001, ngemva kweminyaka emithathu ahlukene no-Matsunyane, batjhada.&lt;ref&gt;&quot;Connie Ferguson pens tribute to late husband&quot;''. instagram. 31 July 2021. Archived from the original on 25 December 2021.''&lt;/ref&gt; NgoMgwengweni 2002, iinthandani zamukela indodakazi.&lt;ref&gt;&quot;Connie Ferguson: 5 things you didn't know about The Queen's Harriet - My TV News&quot;''. My TV News. 1 March 2018. Retrieved 2 November 2018.''&lt;/ref&gt;  Ngemva kweminyaka engaba ma-20 yomtjhado, u-Shona Ferguson wahlongakala ntambama mhla amalanga am-30 kuNtaka 2021 ngebanga lemiraro ehlobene ne [[Ingogwana ye covid-19|-COVID-19]].&lt;ref&gt;&quot;Shona Ferguson, 47, has died&quot;''.''&lt;/ref&gt; 

=== Imithombolwazi. ===
{{Reflist|2}}
[[Mkhakha:Pages with unreviewed translations]]</text>
      <sha1>ldff4gjh3a0luvsh04hgn3nxfogtf89</sha1>
    </revision>
  </page>
  <page>
    <title>Ivakatjhobukela eSewula Afrika</title>
    <ns>0</ns>
    <id>933</id>
    <revision>
      <id>5566</id>
      <timestamp>2025-09-04T09:46:27Z</timestamp>
      <contributor>
        <username>Mashiloane. N</username>
        <id>907</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1302705272|Tourism in South Africa]]&quot;</comment>
      <origin>5566</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2436" sha1="jrf9xn24rhsfe2uvcq3zfx6si5oaz5y" xml:space="preserve">[[Isimumathi:Tourists_looking_at_Table_Mountain_and_Cape_Town_from_viewpoint_on_Robben_Island.jpg|alt=A straight stone pathway through a rocky area, elevated in places from the walkway, with a low retaining wall and chain fence on the left. Beyond is an area of ocean; at the far background on the left is a large flat rocky mountain with a peaked one at its left. Closer to the camera is a small building on the right; people are milling around it and the paths, some taking pictures|thumb|300x300px|Abavakatjhi abaqala i -Cape Town ne -Table Mountain, ukusuka e [[I-Roben island|-Robben Island]]]]
[[Isewula Afrika|ISewula Afrika]] yindawo ekulu yeemvakatjhi ephasini loke, lapho ibubulo lezokuvakatjha libalelwa ku-3.3% we-GDP yelizwe ukusukela ngenyanga kaMrhayili 2025, ngokuya kwe -Statistics South Africa (Stats SA). 

Ngomnyaka ka-2024, iSewula Afrika yathola ukukhula kwamanani wezokuvakatjha, lapho ukufika kwabagibeli okuhlanganisiweko ngamachweba ahlukahlukeneko wokungena kwanda kwaba ziingidi ezi-8.92 zabantu. 

Ngomnyaka ka-2025, iSewula Afrika yathathwa njengelizwe lesi-4 elihle khulu ephasini abantu abangavakatjhela kilo, kanye nelihle khulu esifundeni se-Afrika ne-Indian Ocean, yi- ''The Telegraph'' . 

i-World Travel &amp; Tourism Council (WTTC), ibubulo lezevakatjhobukela linikele ngokunqophileko nge-R 102 yamabhiliyoni ku -GDP yeSewula Afrika ngo-2012, kungenzeka lisekela i-10.3% yemisebenzi yelizwe. [1] Abantu abaziingidi eziyi-1.8 baqatjhwe emkhakheni wezozokuvakatjha weSewula Afrika ekuthomeni konyaka ka-2025, okwenzekako inani leli kulindeleke bona likhule khulu eminyakeni  ezako. [2]

ISewula Afrika inike abavakatjhi bekhaya iindlela zemveloko, nanyana kunjalo iindawo ezihle zemvelo kanye nendawo yokugcina iinlwana, amagugu wamasiko akho kanye namawayini ahlonitjha khulu. Ezinye zeendawo ezithandwa khulu zifaka amapaki weentjhabatjhaba, afana ne -Kruger National Park ebanzi enyakatho yenarha, ama-coastlines namabhishi we- KwaZulu-Natal kanye ne -Western Cape, kanye namadorobha amakhulu we-Cape Town, Durban, kanye ne -Johannesburg.

I-United States, i-United Kingdom, i-Germany, i-Netherlands, ne-France. I-Southern African Development Community (SADC). I-Malunga nabavakatjhi abavela emazweni we-SADC, i-Zimbabwe beyiphmbili ngama-31%, ilandelwa yi -Lesotho, i-Mozambique, i-Eswatini, ne -Botswana . Ukungezelela, i-Nigeria bekuyinarha ekuvela abavakatjhi abafika eSewula Afrika abama-30%. [1]</text>
      <sha1>jrf9xn24rhsfe2uvcq3zfx6si5oaz5y</sha1>
    </revision>
    <revision>
      <id>5568</id>
      <parentid>5566</parentid>
      <timestamp>2025-09-04T09:48:51Z</timestamp>
      <contributor>
        <username>Mashiloane. N</username>
        <id>907</id>
      </contributor>
      <minor />
      <origin>5568</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2511" sha1="cuel1b2qflal4h3g5wncv9d8hd1zlvd" xml:space="preserve">[[Isimumathi:Tourists_looking_at_Table_Mountain_and_Cape_Town_from_viewpoint_on_Robben_Island.jpg|alt=A straight stone pathway through a rocky area, elevated in places from the walkway, with a low retaining wall and chain fence on the left. Beyond is an area of ocean; at the far background on the left is a large flat rocky mountain with a peaked one at its left. Closer to the camera is a small building on the right; people are milling around it and the paths, some taking pictures|thumb|300x300px|Abavakatjhi abaqala i -Cape Town ne -Table Mountain, ukusuka e [[I-Roben island|-Robben Island]]]]
[[Isewula Afrika|ISewula Afrika]] yindawo ekulu yeemvakatjhi ephasini loke, lapho ibubulo lezokuvakatjha libalelwa ku-3.3% we-GDP yelizwe ukusukela ngenyanga kaMrhayili 2025, ngokuya kwe -Statistics South Africa (Stats SA). 

Ngomnyaka ka-2024, [[ISewula Afrika ne-Afrika eseSewula (South Africa and Southern Africa).|iSewula Afrika]] yathola ukukhula kwamanani wezokuvakatjha, lapho ukufika kwabagibeli okuhlanganisiweko ngamachweba ahlukahlukeneko wokungena kwanda kwaba ziingidi ezi-8.92 zabantu. 

Ngomnyaka ka-2025, iSewula Afrika yathathwa njengelizwe lesi-4 elihle khulu ephasini abantu abangavakatjhela kilo, kanye nelihle khulu esifundeni se-Afrika ne-Indian Ocean, yi- ''The Telegraph'' . 

i-World Travel &amp; Tourism Council (WTTC), ibubulo lezevakatjhobukela linikele ngokunqophileko nge-R 102 yamabhiliyoni ku -GDP yeSewula Afrika ngo-2012, kungenzeka lisekela i-10.3% yemisebenzi yelizwe. [1] Abantu abaziingidi eziyi-1.8 baqatjhwe emkhakheni wezozokuvakatjha weSewula Afrika ekuthomeni konyaka ka-2025, okwenzekako inani leli kulindeleke bona likhule khulu eminyakeni  ezako. [2]

ISewula Afrika inike abavakatjhi bekhaya iindlela zemveloko, nanyana kunjalo iindawo ezihle zemvelo kanye nendawo yokugcina iinlwana, amagugu wamasiko akho kanye namawayini ahlonitjha khulu. Ezinye zeendawo ezithandwa khulu zifaka amapaki weentjhabatjhaba, afana ne -Kruger National Park ebanzi enyakatho yenarha, ama-coastlines namabhishi we- KwaZulu-Natal kanye ne -Western Cape, kanye namadorobha amakhulu we-Cape Town, Durban, kanye ne -Johannesburg.

I-United States, i-United Kingdom, i-Germany, i-Netherlands, ne-France. I-Southern African Development Community (SADC). I-Malunga nabavakatjhi abavela emazweni we-SADC, i-Zimbabwe beyiphmbili ngama-31%, ilandelwa yi -Lesotho, i-Mozambique, i-Eswatini, ne -Botswana . Ukungezelela, i-Nigeria bekuyinarha ekuvela abavakatjhi abafika eSewula Afrika abama-30%. [1]</text>
      <sha1>cuel1b2qflal4h3g5wncv9d8hd1zlvd</sha1>
    </revision>
    <revision>
      <id>5572</id>
      <parentid>5568</parentid>
      <timestamp>2025-09-04T09:49:55Z</timestamp>
      <contributor>
        <username>Mashiloane. N</username>
        <id>907</id>
      </contributor>
      <minor />
      <origin>5572</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2530" sha1="i75uk0fk2cv66i1ucyfjvm26mm6yidq" xml:space="preserve">[[Isimumathi:Tourists_looking_at_Table_Mountain_and_Cape_Town_from_viewpoint_on_Robben_Island.jpg|alt=A straight stone pathway through a rocky area, elevated in places from the walkway, with a low retaining wall and chain fence on the left. Beyond is an area of ocean; at the far background on the left is a large flat rocky mountain with a peaked one at its left. Closer to the camera is a small building on the right; people are milling around it and the paths, some taking pictures|thumb|300x300px|Abavakatjhi abaqala i -Cape Town ne -Table Mountain, ukusuka e [[I-Roben island|-Robben Island]]]]
[[Isewula Afrika|ISewula Afrika]] yindawo ekulu yeemvakatjhi ephasini loke, lapho ibubulo lezokuvakatjha libalelwa ku-3.3% we-GDP yelizwe ukusukela ngenyanga kaMrhayili 2025, ngokuya kwe -Statistics South Africa (Stats SA). 

Ngomnyaka ka-2024, [[ISewula Afrika ne-Afrika eseSewula (South Africa and Southern Africa).|iSewula Afrika]] yathola ukukhula kwamanani wezokuvakatjha, lapho ukufika kwabagibeli okuhlanganisiweko ngamachweba ahlukahlukeneko wokungena kwanda kwaba ziingidi ezi-8.92 zabantu. 

Ngomnyaka ka-2025, [[Isewula Afrika|iSewula Afrika]] yathathwa njengelizwe lesi-4 elihle khulu ephasini abantu abangavakatjhela kilo, kanye nelihle khulu esifundeni se-Afrika ne-Indian Ocean, yi- ''The Telegraph'' . 

i-World Travel &amp; Tourism Council (WTTC), ibubulo lezevakatjhobukela linikele ngokunqophileko nge-R 102 yamabhiliyoni ku -GDP yeSewula Afrika ngo-2012, kungenzeka lisekela i-10.3% yemisebenzi yelizwe. [1] Abantu abaziingidi eziyi-1.8 baqatjhwe emkhakheni wezozokuvakatjha weSewula Afrika ekuthomeni konyaka ka-2025, okwenzekako inani leli kulindeleke bona likhule khulu eminyakeni  ezako. [2]

ISewula Afrika inike abavakatjhi bekhaya iindlela zemveloko, nanyana kunjalo iindawo ezihle zemvelo kanye nendawo yokugcina iinlwana, amagugu wamasiko akho kanye namawayini ahlonitjha khulu. Ezinye zeendawo ezithandwa khulu zifaka amapaki weentjhabatjhaba, afana ne -Kruger National Park ebanzi enyakatho yenarha, ama-coastlines namabhishi we- KwaZulu-Natal kanye ne -Western Cape, kanye namadorobha amakhulu we-Cape Town, Durban, kanye ne -Johannesburg.

I-United States, i-United Kingdom, i-Germany, i-Netherlands, ne-France. I-Southern African Development Community (SADC). I-Malunga nabavakatjhi abavela emazweni we-SADC, i-Zimbabwe beyiphmbili ngama-31%, ilandelwa yi -Lesotho, i-Mozambique, i-Eswatini, ne -Botswana . Ukungezelela, i-Nigeria bekuyinarha ekuvela abavakatjhi abafika eSewula Afrika abama-30%. [1]</text>
      <sha1>i75uk0fk2cv66i1ucyfjvm26mm6yidq</sha1>
    </revision>
    <revision>
      <id>5579</id>
      <parentid>5572</parentid>
      <timestamp>2025-09-04T09:53:57Z</timestamp>
      <contributor>
        <username>Mashiloane. N</username>
        <id>907</id>
      </contributor>
      <minor />
      <origin>5579</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2594" sha1="dohsiccrfvo89qzi8hczouevx6tmwmi" xml:space="preserve">[[Isimumathi:Tourists_looking_at_Table_Mountain_and_Cape_Town_from_viewpoint_on_Robben_Island.jpg|alt=A straight stone pathway through a rocky area, elevated in places from the walkway, with a low retaining wall and chain fence on the left. Beyond is an area of ocean; at the far background on the left is a large flat rocky mountain with a peaked one at its left. Closer to the camera is a small building on the right; people are milling around it and the paths, some taking pictures|thumb|300x300px|Abavakatjhi abaqala i -Cape Town ne -Table Mountain, ukusuka e [[I-Roben island|-Robben Island]]]]
[[Isewula Afrika|ISewula Afrika]] yindawo ekulu yeemvakatjhi ephasini loke, lapho ibubulo lezokuvakatjha libalelwa ku-3.3% we-GDP yelizwe ukusukela ngenyanga kaMrhayili 2025, ngokuya kwe -Statistics South Africa (Stats SA). 

Ngomnyaka ka-2024, [[ISewula Afrika ne-Afrika eseSewula (South Africa and Southern Africa).|iSewula Afrika]] yathola ukukhula kwamanani wezokuvakatjha, lapho ukufika kwabagibeli okuhlanganisiweko ngamachweba ahlukahlukeneko wokungena kwanda kwaba ziingidi ezi-8.92 zabantu. 

Ngomnyaka ka-2025, [[Isewula Afrika|iSewula Afrika]] yathathwa njengelizwe lesi-4 elihle khulu ephasini abantu abangavakatjhela kilo, kanye nelihle khulu esifundeni se-Afrika ne-Indian Ocean, yi- ''The Telegraph'' . 

I-World Travel &amp; Tourism Council (WTTC), ibubulo lezevakatjhobukela linikele ngokunqophileko nge-R 102 yamabhiliyoni ku -GDP yeSewula Afrika ngo-2012, kungenzeka lisekela i-10.3% yemisebenzi yelizwe.&lt;ref&gt;[https://wttc.org/ World Travel &amp; Tourism Council (WTTC)]&lt;/ref&gt; Abantu abaziingidi eziyi-1.8 baqatjhwe emkhakheni wezozokuvakatjha weSewula Afrika ekuthomeni konyaka ka-2025, okwenzekako inani leli kulindeleke bona likhule khulu eminyakeni  ezako. [2]

ISewula Afrika inike abavakatjhi bekhaya iindlela zemveloko, nanyana kunjalo iindawo ezihle zemvelo kanye nendawo yokugcina iinlwana, amagugu wamasiko akho kanye namawayini ahlonitjha khulu. Ezinye zeendawo ezithandwa khulu zifaka amapaki weentjhabatjhaba, afana ne -Kruger National Park ebanzi enyakatho yenarha, ama-coastlines namabhishi we- KwaZulu-Natal kanye ne -Western Cape, kanye namadorobha amakhulu we-Cape Town, Durban, kanye ne -Johannesburg.

I-United States, i-United Kingdom, i-Germany, i-Netherlands, ne-France. I-Southern African Development Community (SADC). I-Malunga nabavakatjhi abavela emazweni we-SADC, i-Zimbabwe beyiphmbili ngama-31%, ilandelwa yi -Lesotho, i-Mozambique, i-Eswatini, ne -Botswana . Ukungezelela, i-Nigeria bekuyinarha ekuvela abavakatjhi abafika eSewula Afrika abama-30%. [1]</text>
      <sha1>dohsiccrfvo89qzi8hczouevx6tmwmi</sha1>
    </revision>
    <revision>
      <id>5582</id>
      <parentid>5579</parentid>
      <timestamp>2025-09-04T09:55:33Z</timestamp>
      <contributor>
        <username>Mashiloane. N</username>
        <id>907</id>
      </contributor>
      <minor />
      <origin>5582</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2613" sha1="i81l12v74vpecfp12ethmlbx3mma2ez" xml:space="preserve">[[Isimumathi:Tourists_looking_at_Table_Mountain_and_Cape_Town_from_viewpoint_on_Robben_Island.jpg|alt=A straight stone pathway through a rocky area, elevated in places from the walkway, with a low retaining wall and chain fence on the left. Beyond is an area of ocean; at the far background on the left is a large flat rocky mountain with a peaked one at its left. Closer to the camera is a small building on the right; people are milling around it and the paths, some taking pictures|thumb|300x300px|Abavakatjhi abaqala i -Cape Town ne -Table Mountain, ukusuka e [[I-Roben island|-Robben Island]]]]
[[Isewula Afrika|ISewula Afrika]] yindawo ekulu yeemvakatjhi ephasini loke, lapho ibubulo lezokuvakatjha libalelwa ku-3.3% we-GDP yelizwe ukusukela ngenyanga kaMrhayili 2025, ngokuya kwe -Statistics South Africa (Stats SA). 

Ngomnyaka ka-2024, [[ISewula Afrika ne-Afrika eseSewula (South Africa and Southern Africa).|iSewula Afrika]] yathola ukukhula kwamanani wezokuvakatjha, lapho ukufika kwabagibeli okuhlanganisiweko ngamachweba ahlukahlukeneko wokungena kwanda kwaba ziingidi ezi-8.92 zabantu. 

Ngomnyaka ka-2025, [[Isewula Afrika|iSewula Afrika]] yathathwa njengelizwe lesi-4 elihle khulu ephasini abantu abangavakatjhela kilo, kanye nelihle khulu esifundeni se-Afrika ne-Indian Ocean, yi- ''The Telegraph'' . 

I-World Travel &amp; Tourism Council (WTTC), ibubulo lezevakatjhobukela linikele ngokunqophileko nge-R 102 yamabhiliyoni ku -GDP yeSewula Afrika ngo-2012, kungenzeka lisekela i-10.3% yemisebenzi yelizwe.&lt;ref&gt;[https://wttc.org/ World Travel &amp; Tourism Council (WTTC)]&lt;/ref&gt; Abantu abaziingidi eziyi-1.8 baqatjhwe emkhakheni wezozokuvakatjha weSewula Afrika ekuthomeni konyaka ka-2025, okwenzekako inani leli kulindeleke bona likhule khulu eminyakeni  ezako. [2]

ISewula Afrika inike abavakatjhi bekhaya iindlela zemveloko, nanyana kunjalo iindawo ezihle zemvelo kanye nendawo yokugcina iinlwana, amagugu wamasiko akho kanye namawayini ahlonitjha khulu. Ezinye zeendawo ezithandwa khulu zifaka amapaki weentjhabatjhaba, afana ne -Kruger National Park ebanzi enyakatho yenarha, ama-coastlines namabhishi we- KwaZulu-Natal kanye ne -Western Cape, kanye namadorobha amakhulu we-Cape Town, Durban, kanye ne -Johannesburg.

I-United States, i-United Kingdom, i-Germany, i-Netherlands, ne-France. I-Southern African Development Community (SADC). I-Malunga nabavakatjhi abavela emazweni we-SADC, i-Zimbabwe beyiphmbili ngama-31%, ilandelwa yi -Lesotho, i-Mozambique, i-Eswatini, ne -Botswana . Ukungezelela, i-Nigeria bekuyinarha ekuvela abavakatjhi abafika eSewula Afrika abama-30%.

=== Umthombolwazi ===</text>
      <sha1>i81l12v74vpecfp12ethmlbx3mma2ez</sha1>
    </revision>
    <revision>
      <id>5587</id>
      <parentid>5582</parentid>
      <timestamp>2025-09-04T09:58:49Z</timestamp>
      <contributor>
        <username>Mashiloane. N</username>
        <id>907</id>
      </contributor>
      <minor />
      <origin>5587</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2659" sha1="qp7nd9xhaf5ho6tzamrprbz7i4dnql6" xml:space="preserve">[[Isimumathi:Tourists_looking_at_Table_Mountain_and_Cape_Town_from_viewpoint_on_Robben_Island.jpg|alt=A straight stone pathway through a rocky area, elevated in places from the walkway, with a low retaining wall and chain fence on the left. Beyond is an area of ocean; at the far background on the left is a large flat rocky mountain with a peaked one at its left. Closer to the camera is a small building on the right; people are milling around it and the paths, some taking pictures|thumb|300x300px|Abavakatjhi abaqala i -Cape Town ne -Table Mountain, ukusuka e [[I-Roben island|-Robben Island]]]]
[[Isewula Afrika|ISewula Afrika]] yindawo ekulu yeemvakatjhi ephasini loke, lapho ibubulo lezokuvakatjha libalelwa ku-3.3% we-GDP yelizwe ukusukela ngenyanga kaMrhayili 2025, ngokuya kwe -Statistics South Africa (Stats SA). 

Ngomnyaka ka-2024, [[ISewula Afrika ne-Afrika eseSewula (South Africa and Southern Africa).|iSewula Afrika]] yathola ukukhula kwamanani wezokuvakatjha, lapho ukufika kwabagibeli okuhlanganisiweko ngamachweba ahlukahlukeneko wokungena kwanda kwaba ziingidi ezi-8.92 zabantu. 

Ngomnyaka ka-2025, [[Isewula Afrika|iSewula Afrika]] yathathwa njengelizwe lesi-4 elihle khulu ephasini abantu abangavakatjhela kilo, kanye nelihle khulu esifundeni se-Afrika ne-Indian Ocean, yi- ''The Telegraph'' . 

I-World Travel &amp; Tourism Council (WTTC), ibubulo lezevakatjhobukela linikele ngokunqophileko nge-R 102 yamabhiliyoni ku -GDP yeSewula Afrika ngo-2012, kungenzeka lisekela i-10.3% yemisebenzi yelizwe.&lt;ref&gt;[https://wttc.org/ World Travel &amp; Tourism Council (WTTC)]&lt;/ref&gt; Abantu abaziingidi eziyi-1.8 baqatjhwe emkhakheni wezozokuvakatjha weSewula Afrika ekuthomeni konyaka ka-2025, okwenzekako inani leli kulindeleke bona likhule khulu eminyakeni  ezako. [2]

ISewula Afrika inike abavakatjhi bekhaya iindlela zemveloko, nanyana kunjalo iindawo ezihle zemvelo kanye nendawo yokugcina iinlwana, amagugu wamasiko akho kanye namawayini ahlonitjha khulu. Ezinye zeendawo ezithandwa khulu zifaka amapaki weentjhabatjhaba, afana ne -Kruger National Park ebanzi enyakatho yenarha, ama-coastlines namabhishi we- KwaZulu-Natal kanye ne -Western Cape, kanye namadorobha amakhulu we-Cape Town, Durban, kanye ne -Johannesburg.

I-United States, i-United Kingdom, i-Germany, i-Netherlands, ne-France. I-Southern African Development Community (SADC).&lt;ref&gt;[https://www.sadc.int/ Home | SADC]&lt;/ref&gt; I-Malunga nabavakatjhi abavela emazweni we-SADC, i-Zimbabwe beyiphmbili ngama-31%, ilandelwa yi -Lesotho, i-Mozambique, i-Eswatini, ne -Botswana . Ukungezelela, i-Nigeria bekuyinarha ekuvela abavakatjhi abafika eSewula Afrika abama-30%.

=== Umthombolwazi ===</text>
      <sha1>qp7nd9xhaf5ho6tzamrprbz7i4dnql6</sha1>
    </revision>
    <revision>
      <id>5590</id>
      <parentid>5587</parentid>
      <timestamp>2025-09-04T10:02:27Z</timestamp>
      <contributor>
        <username>Mashiloane. N</username>
        <id>907</id>
      </contributor>
      <minor />
      <origin>5590</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2773" sha1="p4rxmtsle47pfolpyge5w1xsvqdjduo" xml:space="preserve">[[Isimumathi:Tourists_looking_at_Table_Mountain_and_Cape_Town_from_viewpoint_on_Robben_Island.jpg|alt=A straight stone pathway through a rocky area, elevated in places from the walkway, with a low retaining wall and chain fence on the left. Beyond is an area of ocean; at the far background on the left is a large flat rocky mountain with a peaked one at its left. Closer to the camera is a small building on the right; people are milling around it and the paths, some taking pictures|thumb|300x300px|Abavakatjhi abaqala i -Cape Town ne -Table Mountain, ukusuka e [[I-Roben island|-Robben Island]]]]
[[Isewula Afrika|ISewula Afrika]] yindawo ekulu yeemvakatjhi ephasini loke, lapho ibubulo lezokuvakatjha libalelwa ku-3.3% we-GDP yelizwe ukusukela ngenyanga kaMrhayili 2025, ngokuya kwe -Statistics South Africa (Stats SA). 

Ngomnyaka ka-2024, [[ISewula Afrika ne-Afrika eseSewula (South Africa and Southern Africa).|iSewula Afrika]] yathola ukukhula kwamanani wezokuvakatjha, lapho ukufika kwabagibeli okuhlanganisiweko ngamachweba ahlukahlukeneko wokungena kwanda kwaba ziingidi ezi-8.92 zabantu. 

Ngomnyaka ka-2025, [[Isewula Afrika|iSewula Afrika]] yathathwa njengelizwe lesi-4 elihle khulu ephasini abantu abangavakatjhela kilo, kanye nelihle khulu esifundeni se-Afrika ne-Indian Ocean, yi- ''The Telegraph'' . 

I-World Travel &amp; Tourism Council (WTTC), ibubulo lezevakatjhobukela linikele ngokunqophileko nge-R 102 yamabhiliyoni ku -GDP yeSewula Afrika ngo-2012, kungenzeka lisekela i-10.3% yemisebenzi yelizwe.&lt;ref&gt;[https://wttc.org/ World Travel &amp; Tourism Council (WTTC)]&lt;/ref&gt; Abantu abaziingidi eziyi-1.8 baqatjhwe emkhakheni wezozokuvakatjha weSewula Afrika ekuthomeni konyaka ka-2025, okwenzekako inani leli kulindeleke bona likhule khulu eminyakeni  ezako. [2]

ISewula Afrika inike abavakatjhi bekhaya iindlela zemvelo, nanyana kunjalo iindawo ezihle zemvelo kanye nendawo yokugcina iinlwana, amagugu wamasiko akhona kanye namawayini ahlonitjha khulu.&lt;ref&gt;Du Plessis, E., Saayman, M. and Van der Merwe, A., 2015. What makes South African tourism competitive?.&lt;/ref&gt; Ezinye zeendawo ezithandwa khulu zifaka amapaki weentjhabatjhaba, afana ne -Kruger National Park ebanzi enyakatho yenarha, ama-coastlines namabhishi we- KwaZulu-Natal kanye ne -Western Cape, kanye namadorobha amakhulu we-Cape Town, Durban, kanye ne -Johannesburg.

I-United States, i-United Kingdom, i-Germany, i-Netherlands, ne-France. I-Southern African Development Community (SADC).&lt;ref&gt;[https://www.sadc.int/ Home | SADC]&lt;/ref&gt; I-Malunga nabavakatjhi abavela emazweni we-SADC, i-Zimbabwe beyiphmbili ngama-31%, ilandelwa yi -Lesotho, i-Mozambique, i-Eswatini, ne -Botswana . Ukungezelela, i-Nigeria bekuyinarha ekuvela abavakatjhi abafika eSewula Afrika abama-30%.

=== Umthombolwazi ===</text>
      <sha1>p4rxmtsle47pfolpyge5w1xsvqdjduo</sha1>
    </revision>
    <revision>
      <id>5596</id>
      <parentid>5590</parentid>
      <timestamp>2025-09-04T10:09:53Z</timestamp>
      <contributor>
        <username>Mashiloane. N</username>
        <id>907</id>
      </contributor>
      <minor />
      <origin>5596</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2851" sha1="hx3u0yw37bac5sw3s68owp30v008rp2" xml:space="preserve">[[Isimumathi:Tourists_looking_at_Table_Mountain_and_Cape_Town_from_viewpoint_on_Robben_Island.jpg|alt=A straight stone pathway through a rocky area, elevated in places from the walkway, with a low retaining wall and chain fence on the left. Beyond is an area of ocean; at the far background on the left is a large flat rocky mountain with a peaked one at its left. Closer to the camera is a small building on the right; people are milling around it and the paths, some taking pictures|thumb|300x300px|Abavakatjhi abaqala i -Cape Town ne -Table Mountain, ukusuka e [[I-Roben island|-Robben Island]]]]
[[Isewula Afrika|ISewula Afrika]] yindawo ekulu yeemvakatjhi ephasini loke, lapho ibubulo lezokuvakatjha libalelwa ku-3.3% we-GDP yelizwe ukusukela ngenyanga kaMrhayili 2025, ngokuya kwe -Statistics South Africa (Stats SA).&lt;ref&gt;[https://www.statssa.gov.za/?m=2024 2024 | Statistics South Africa]&lt;/ref&gt; 

Ngomnyaka ka-2024, [[ISewula Afrika ne-Afrika eseSewula (South Africa and Southern Africa).|iSewula Afrika]] yathola ukukhula kwamanani wezokuvakatjha, lapho ukufika kwabagibeli okuhlanganisiweko ngamachweba ahlukahlukeneko wokungena kwanda kwaba ziingidi ezi-8.92 zabantu. 

Ngomnyaka ka-2025, [[Isewula Afrika|iSewula Afrika]] yathathwa njengelizwe lesi-4 elihle khulu ephasini abantu abangavakatjhela kilo, kanye nelihle khulu esifundeni se-Afrika ne-Indian Ocean, yi- ''The Telegraph'' . 

I-World Travel &amp; Tourism Council (WTTC), ibubulo lezevakatjhobukela linikele ngokunqophileko nge-R 102 yamabhiliyoni ku -GDP yeSewula Afrika ngo-2012, kungenzeka lisekela i-10.3% yemisebenzi yelizwe.&lt;ref&gt;[https://wttc.org/ World Travel &amp; Tourism Council (WTTC)]&lt;/ref&gt; Abantu abaziingidi eziyi-1.8 baqatjhwe emkhakheni wezozokuvakatjha weSewula Afrika ekuthomeni konyaka ka-2025, okwenzekako inani leli kulindeleke bona likhule khulu eminyakeni  ezako. [2]

ISewula Afrika inike abavakatjhi bekhaya iindlela zemvelo, nanyana kunjalo iindawo ezihle zemvelo kanye nendawo yokugcina iinlwana, amagugu wamasiko akhona kanye namawayini ahlonitjha khulu.&lt;ref&gt;Du Plessis, E., Saayman, M. and Van der Merwe, A., 2015. What makes South African tourism competitive?.&lt;/ref&gt; Ezinye zeendawo ezithandwa khulu zifaka amapaki weentjhabatjhaba, afana ne -Kruger National Park ebanzi enyakatho yenarha, ama-coastlines namabhishi we- KwaZulu-Natal kanye ne -Western Cape, kanye namadorobha amakhulu we-Cape Town, Durban, kanye ne -Johannesburg.

I-United States, i-United Kingdom, i-Germany, i-Netherlands, ne-France. I-Southern African Development Community (SADC).&lt;ref&gt;[https://www.sadc.int/ Home | SADC]&lt;/ref&gt; I-Malunga nabavakatjhi abavela emazweni we-SADC, i-Zimbabwe beyiphmbili ngama-31%, ilandelwa yi -Lesotho, i-Mozambique, i-Eswatini, ne -Botswana . Ukungezelela, i-Nigeria bekuyinarha ekuvela abavakatjhi abafika eSewula Afrika abama-30%.

=== Umthombolwazi ===</text>
      <sha1>hx3u0yw37bac5sw3s68owp30v008rp2</sha1>
    </revision>
    <revision>
      <id>5611</id>
      <parentid>5596</parentid>
      <timestamp>2025-09-04T10:31:27Z</timestamp>
      <contributor>
        <username>Mashiloane. N</username>
        <id>907</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1302705272|Tourism in South Africa]]&quot;</comment>
      <origin>5611</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3226" sha1="pw6k7divbeeo8zm5avp97s1f6hzduiq" xml:space="preserve">[[Isimumathi:Tourists_looking_at_Table_Mountain_and_Cape_Town_from_viewpoint_on_Robben_Island.jpg|alt=A straight stone pathway through a rocky area, elevated in places from the walkway, with a low retaining wall and chain fence on the left. Beyond is an area of ocean; at the far background on the left is a large flat rocky mountain with a peaked one at its left. Closer to the camera is a small building on the right; people are milling around it and the paths, some taking pictures|thumb|300x300px|Abavakatjhi abaqala i -Cape Town ne -Table Mountain, ukusuka e [[I-Roben island|-Robben Island]]]]
[[Isewula Afrika|ISewula Afrika]] yindawo ekulu yeemvakatjhi ephasini loke, lapho ibubulo lezokuvakatjha libalelwa ku-3.3% we-GDP yelizwe ukusukela ngenyanga kaMrhayili 2025, ngokuya kwe -Statistics South Africa (Stats SA). 

Ngomnyaka ka-2024, iSewula Afrika yathola ukukhula kwamanani wezokuvakatjha, lapho ukufika kwabagibeli okuhlanganisiweko ngamachweba ahlukahlukeneko wokungena kwanda kwaba ziingidi ezi-8.92 zabantu. 

Ngomnyaka ka-2025, iSewula Afrika yathathwa njengelizwe lesi-4 elihle khulu ephasini abantu abangavakatjhela kilo, kanye nelihle khulu esifundeni se-Afrika ne-Indian Ocean, yi- ''The Telegraph'' . 

i-World Travel &amp; Tourism Council (WTTC), ibubulo lezevakatjhobukela linikele ngokunqophileko nge-R 102 yamabhiliyoni ku -GDP yeSewula Afrika ngo-2012, kungenzeka lisekela i-10.3% yemisebenzi yelizwe. [1] Abantu abaziingidi eziyi-1.8 baqatjhwe emkhakheni wezozokuvakatjha weSewula Afrika ekuthomeni konyaka ka-2025, okwenzekako inani leli kulindeleke bona likhule khulu eminyakeni  ezako. [2]

ISewula Afrika inike abavakatjhi bekhaya iindlela zemveloko, nanyana kunjalo iindawo ezihle zemvelo kanye nendawo yokugcina iinlwana, amagugu wamasiko akho kanye namawayini ahlonitjha khulu. Ezinye zeendawo ezithandwa khulu zifaka amapaki weentjhabatjhaba, afana ne -Kruger National Park ebanzi enyakatho yenarha, ama-coastlines namabhishi we- KwaZulu-Natal kanye ne -Western Cape, kanye namadorobha amakhulu we-Cape Town, Durban, kanye ne -Johannesburg.

I-United States, i-United Kingdom, i-Germany, i-Netherlands, ne-France. I-Southern African Development Community (SADC). I-Malunga nabavakatjhi abavela emazweni we-SADC, i-Zimbabwe beyiphmbili ngama-31%, ilandelwa yi -Lesotho, i-Mozambique, i-Eswatini, ne -Botswana . Ukungezelela, i-Nigeria bekuyinarha ekuvela abavakatjhi abafika eSewula Afrika abama-30%. [1]

== Iindawo ezikarisako ==

=== Ukuhlukahlukana kwezinto eziphilako kanye ne-ecotourism ===
[[Isimumathi:Kruger_Park_Elephants.jpg|thumb|300x300px|Umndeni weendlovu emgodini wamanzi owenziwe e- Kruger National Park, e [[Isifunda seMpumalanga|-Mpumalanga]]]]
ISewula Afrika ibekwe endaweni yesine kwezilitjhumi nathoba emazweni wephasi aneenlwana ezizako ezimatjhumi amabili [1] ISewula Afrika ineenlwana ezizako. I-Hlangana neenlwana ezinkulu ezimunyisako ezis ehlathini elisenyakatho zifaka hlangana amabhubezi, ingwe, iingwe, ubhejane omhlophe, i-blue wildebeest, ama-kudu, iimpala, ama-hyena, iimvubu kanye nama-giraffe. Indawo enengi yamahlathi ikhona enyakatho-mpumalanga, indawo enengi i-Kruger National Park, enye yeendawo ezinkulu khulu e-Afrika, kanye ne- Sabi Sand Game Reserve .</text>
      <sha1>pw6k7divbeeo8zm5avp97s1f6hzduiq</sha1>
    </revision>
    <revision>
      <id>5631</id>
      <parentid>5611</parentid>
      <timestamp>2025-09-04T10:46:04Z</timestamp>
      <contributor>
        <username>Mashiloane. N</username>
        <id>907</id>
      </contributor>
      <minor />
      <comment>ngifake isthombe</comment>
      <origin>5631</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2358" sha1="orplgqsqenc5f6vaq02a6mh3le7p14b" xml:space="preserve">[[Isimumathi:Mapungubwe, Limpopo, South Africa (20517884676).jpg|thumb|Isithombe se Mapungubwe eLimpopo]]
[[Isewula Afrika|ISewula Afrika]] yindawo ekulu yeemvakatjhi ephasini loke, lapho ibubulo lezokuvakatjha libalelwa ku-3.3% we-GDP yelizwe ukusukela ngenyanga kaMrhayili 2025, ngokuya kwe -Statistics South Africa (Stats SA).&lt;ref&gt;[https://www.statssa.gov.za/?m=2024 2024 | Statistics South Africa]&lt;/ref&gt; 

Ngomnyaka ka-2024, [[ISewula Afrika ne-Afrika eseSewula (South Africa and Southern Africa).|iSewula Afrika]] yathola ukukhula kwamanani wezokuvakatjha, lapho ukufika kwabagibeli okuhlanganisiweko ngamachweba ahlukahlukeneko wokungena kwanda kwaba ziingidi ezi-8.92 zabantu. 

Ngomnyaka ka-2025, [[Isewula Afrika|iSewula Afrika]] yathathwa njengelizwe lesi-4 elihle khulu ephasini abantu abangavakatjhela kilo, kanye nelihle khulu esifundeni se-Afrika ne-Indian Ocean, yi- ''The Telegraph'' . 

I-World Travel &amp; Tourism Council (WTTC), ibubulo lezevakatjhobukela linikele ngokunqophileko nge-R 102 yamabhiliyoni ku -GDP yeSewula Afrika ngo-2012, kungenzeka lisekela i-10.3% yemisebenzi yelizwe.&lt;ref&gt;[https://wttc.org/ World Travel &amp; Tourism Council (WTTC)]&lt;/ref&gt; Abantu abaziingidi eziyi-1.8 baqatjhwe emkhakheni wezozokuvakatjha weSewula Afrika ekuthomeni konyaka ka-2025, okwenzekako inani leli kulindeleke bona likhule khulu eminyakeni  ezako. [2]

ISewula Afrika inike abavakatjhi bekhaya iindlela zemvelo, nanyana kunjalo iindawo ezihle zemvelo kanye nendawo yokugcina iinlwana, amagugu wamasiko akhona kanye namawayini ahlonitjha khulu.&lt;ref&gt;Du Plessis, E., Saayman, M. and Van der Merwe, A., 2015. What makes South African tourism competitive?.&lt;/ref&gt; Ezinye zeendawo ezithandwa khulu zifaka amapaki weentjhabatjhaba, afana ne -Kruger National Park ebanzi enyakatho yenarha, ama-coastlines namabhishi we- KwaZulu-Natal kanye ne -Western Cape, kanye namadorobha amakhulu we-Cape Town, Durban, kanye ne -Johannesburg.

I-United States, i-United Kingdom, i-Germany, i-Netherlands, ne-France. I-Southern African Development Community (SADC).&lt;ref&gt;[https://www.sadc.int/ Home | SADC]&lt;/ref&gt; I-Malunga nabavakatjhi abavela emazweni we-SADC, i-Zimbabwe beyiphambili ngama-31%, ilandelwa yi -Lesotho, i-Mozambique, i-Eswatini, ne -Botswana . Ukungezelela, i-Nigeria bekuyinarha ekuvela abavakatjhi abafika eSewula Afrika abama-30%.

=== Umthombolwazi ===</text>
      <sha1>orplgqsqenc5f6vaq02a6mh3le7p14b</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Imilambo</title>
    <ns>14</ns>
    <id>934</id>
    <revision>
      <id>5648</id>
      <timestamp>2025-09-04T11:05:53Z</timestamp>
      <contributor>
        <username>Xikombiso1</username>
        <id>898</id>
      </contributor>
      <comment>created a category</comment>
      <origin>5648</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1" sha1="6t9fg2gmch401ldtk8m7pyzz632ixbb" xml:space="preserve">.</text>
      <sha1>6t9fg2gmch401ldtk8m7pyzz632ixbb</sha1>
    </revision>
  </page>
  <page>
    <title>University of Mpumalanga Enactus</title>
    <ns>0</ns>
    <id>935</id>
    <revision>
      <id>5667</id>
      <timestamp>2025-09-04T11:18:33Z</timestamp>
      <contributor>
        <username>Pholap</username>
        <id>883</id>
      </contributor>
      <comment>new article</comment>
      <origin>5667</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2535" sha1="dix6zy75q0y1fzpbvbeh7cn5qw9nn2f" xml:space="preserve">[[Isimumathi:UMP Enactus.png|thumb|UMP Enactus]]

== I-Enactus [[University of Mpumalanga|ye-Yunivesithi ye-Mpumalanga]] mtjhayeli weentjhabatjhaba weSewula Afrika we-2025 ku-Enactus National Competition.&lt;ref&gt;[https://www.ump.ac.za/News-and-Events/News/2025/UMP-WINS-THE-2025-ENACTUS-SA-CHAMPIONSHIP UMP - UMP WINS THE 2025 ENACTUS SA CHAMPIONSHIP]&lt;/ref&gt; Isiqhema siyingcenye ye-Enactus [[Isewula Afrika|South Africa]], ihlangano engenzi inzuzo ehlanganisa abafundi beyunivesithi, iimfundiswa, nabadosiphambili bamabhizinisi ngamaphrojekthi asekelwe emabhizinisini ahloselwe ukwenza umthelela omuhle emphakathini. ==

== '''Isendlalelo''' ==

== [[I-Enactus]] South Africa isebenza ngaphasi kwenethiwekhi ye-Enactus yephasi loke, esebenza emazweni angaphezu kwama-30. Ihlangano le inikela abafundi indawo yokuklama nokusebenzisa amaphrojekthi womphakathi ahlanganisa ukusungulwa kwebhizinisi nokuziphendulela emphakathini. ==

== Isiqhema seYunivesithi ye-Mpumalanga sibe mhlanganyeli okhutheleko emncintiswaneni weentjhabatjhaba, sidzimelele eenhlelweni zentuthuko esimemeko kanye namaphrojekthi wobusomabhizinisi akhambisana neendingo zomphakathi wendawo. ==

== '''2025 Umqhudelwano weNarha''' ==

== Ngenyanga kaRhoboyi wee-2025, iYunivesithi ye-Mpumalanga yakhethwa njengeTjhugululi yeNarha emncintiswaneni weNarha we-Enactus South Africa. Ipumelelo yabo yagujwa begodu ngokukhamba kwesikhathi yavezwa ku-IsiNdebele News ku-[[SABC|SABC 1]], kuveza amaphrojekthi neminikelo yesiqhema.&lt;ref&gt;[https://www.sabcnews.com/sabcnews/ Official SABC News - SABC News - Breaking news, special reports, world, business, sport coverage of all South African current events. Africa's news leader.]&lt;/ref&gt; ==

== Ihlelo elivezwe kumabonakude ligcizelele indlela yokwenza izinto ezitjha zesiqhema kanye nomnqopho omkhulu we-Enactus wokukhuthaza uburholi bamabhizinisi hlangana nelutjha leSewula Afrika. ==

== '''Ukuqakatheka''' ==

== Ukuthumba umncintiswano weentjhabatjhaba kwenza bona isiqhema [[Yunivesithi yempulanga|seYunivesithi ye-Mpumalanga]] sikwazi ukujamela iSewula Afrika eNdebeni yePhasi ye-Enactus, iplatifomu yamazwe ngamazwe lapho amathimu wabafundi aveza khona amaphrojekthi wawo wamabhizinisi ebantwini bephasi loke babadosiphambili bamabhizinisi, abafundisi, nabontanga. ==

== Ukuhlonitjhwa lokhu kuveza idumela elikhulako leyunivesithi emkhakheni wezamabhizinisi wezenhlalakahle nokuthuthukisa umphakathi. ==

== '''Qala godu''' ==
Enactus South Africa

Enactus World Cup

University of Mpumalanga

== '''Umthombo welwazi''' ==</text>
      <sha1>dix6zy75q0y1fzpbvbeh7cn5qw9nn2f</sha1>
    </revision>
  </page>
  <page>
    <title>Ukusebenza Kwezemakethe Nokurhwebelana.</title>
    <ns>0</ns>
    <id>936</id>
    <revision>
      <id>5672</id>
      <timestamp>2025-09-04T11:25:55Z</timestamp>
      <contributor>
        <username>White Edits</username>
        <id>894</id>
      </contributor>
      <comment>Created page with &quot;  Imakethe nokurhwebelana yizinto ezibaluleke khulu kwezomnotho, zidlala indima ekulu ekwabelaneni kwensenjenziswa kanye nokusatshalaliswa kwepahla eyisizo khulu enarheni mazombe. Imakethe yindawo lapho abathengi nabathengisi bahlangana khona ukuze batjhentjhisane ngepahla neensetjenziswa zemphakathini, bese kuthi ukurhwebelana kube yisenzo sokuthenga nokuthengisa leyo pahla neensetjenziswa.  === Imihlobo yemakethe esinayo. === Kukhona imihlobo ehlukeneko yemakethe, efak...&quot;</comment>
      <origin>5672</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4175" sha1="93bok7v2i642nr53bluv25h98oyz7cp" xml:space="preserve"> 
Imakethe nokurhwebelana yizinto ezibaluleke khulu kwezomnotho, zidlala indima ekulu ekwabelaneni kwensenjenziswa kanye nokusatshalaliswa kwepahla eyisizo khulu enarheni mazombe. Imakethe yindawo lapho abathengi nabathengisi bahlangana khona ukuze batjhentjhisane ngepahla neensetjenziswa zemphakathini, bese kuthi ukurhwebelana kube yisenzo sokuthenga nokuthengisa leyo pahla neensetjenziswa.

=== Imihlobo yemakethe esinayo. ===
Kukhona imihlobo ehlukeneko yemakethe, efaka hlangana:

1. Iphikiswano ephelele (Perfect Competition): Lomhlobo wemakethe kulapho kunabathengi nabathengisi abanengi, ukungena nokuphuma okulula, kanye nelwazi eliphelele (Smith, 1776).

2. Ukunqoba (Monopoly): Lomhlobo wemakethe kulapho ikhampani eyodwa kwaphela ikhiqiza imikhiqizo nofana iinsetjenziswa ezithileko enikela ngazo kumakethe.&lt;ref&gt;{{Cite book|last=Marshall|first=A|title=Principles of Economics|date=1890|publisher=Macmillan|year=1890}}&lt;/ref&gt;

3. Ukubumbana kwamakhampani ambalwa (Oligopoly): Lomhlobo wemakethe kulapho amakhampani ambalwa abusa khona begodu aphikisana ngokunikela kumakethe.&lt;ref&gt;{{Cite book|last=Chamberlin|first=E. H|title=The Theory of Monopolistic Competition.|date=1993|publisher=Harvard University Press|year=1993}}&lt;/ref&gt;

==== Iindlela Zokurhwebelana (Trading Mechanisms) ====
Iindlela zokurhwebelana zifaka hlangana imigomo nemibandela elawula ukuthenga nokuthengisa epahleni neensetjenziswa  kumakethe. Lezi iindlela zingaba:

1. Ukurhwebelana Ngokuzwisisana (Auction-based trading): Lomhlobo yindlela lapho abathengi nabathengisi bafaka amanani wabo, iintengo zibekwa ngendlela yokuhlangabezana kwesidingo nokunikelwa ngepahla nanyana iinsetjenziswa ezithize kumakethe..&lt;ref name=&quot;:1&quot;&gt;{{Cite book|last=Marshall|first=A|title=Principles of Economics|date=1990|publisher=Macmillan|year=1990}}&lt;/ref&gt;

2. Ukurwebelana Ngaphandle kokuzwisisana (Quote-driven trading):Lomhlobo yindlela lapho abenzi bemakethe banikeza amanani wokuthenga nokuthengisa, abathengi bangakhetha ukuwamukela nofana ukuwalandula.&lt;ref&gt;{{Cite book|last=Milgrom|first=P|title=Putting Auction Theory to Work|date=2004|publisher=Cambridge University Press.|year=2004}}&lt;/ref&gt;

===== Ukusebenza Kwemakethe (Market Efficiency) =====
Ukusebenza kwemakethe kutjho ikghono lemakethe lokubonisa loke ilwazi elokhona eentengweni. Kune mihlobo emithathu yokusebenza kwemakethe:

1. Ifomu Elibuthakathaka (Weak form efficiency): Iintengo zibonisa loke ilwazi lamanani adlulileko.&lt;ref&gt;{{Cite journal|last=Fama|first=E. F.|date=1970|title=Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance|journal=Journal of Finance}}&lt;/ref&gt;

2.Ifomu Eliphakathi (Semi-strong form efficiency): Iintengo zikhombisa loke ilwazi elikhona emphakathini.&lt;ref&gt;{{Cite journal|last=Fama|first=E. F.|date=1970|title=Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance|journal=Journal of Finance}}&lt;/ref&gt;

3. Ifomu Elinamandla (Strong form efficiency): Iintengo zikhombisa loke ilwazi, kungaba ngelikhona emphakathini nofana elifihlakeleko.&lt;ref&gt;{{Cite journal|last=Fama|first=E. F.|date=1970|title=Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance|journal=Journal of Finance}}&lt;/ref&gt;

Imakethe bokurhwebelana kuyizinto ezinganakuthembeka begodu ezitjhugulukako mihla namalanga ezidlala indima ekulu ekwabelaneni kweensetjenziswa nekusatshalalisweni kwepahla neensetjensiza. Ukulemula iminhlobo ehlukeneko yemakethe, iindlela zokurhwebelana, nokusebenza kwemakethe kubalulekile ekuthatheni iinqumo ezihlakaniphileko zokwandisa imali nokuzwisisa ubunzima bokwandisa umnotho esikhathini sanje.

Chamberlin, E. H. (1933). The Theory of Monopolistic Competition. Harvard University Press.

Fama, E. F. (1970). Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance, 25(2), 383-417.

Hasbrouck, J. (2007). Empirical Market Microstructure. Oxford University Press.

Marshall, A. (1890). Principles of Economics. Macmillan.  Milgrom, P. (2004). Putting Auction Theory to Work. Cambridge University Press.

Smith, A. (1776). The Wealth of Nations. Penguin Books

====== Imithombo lwazi ======
&lt;references /&gt;</text>
      <sha1>93bok7v2i642nr53bluv25h98oyz7cp</sha1>
    </revision>
    <revision>
      <id>5684</id>
      <parentid>5672</parentid>
      <timestamp>2025-09-04T11:36:37Z</timestamp>
      <contributor>
        <username>White Edits</username>
        <id>894</id>
      </contributor>
      <origin>5684</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4231" sha1="m3tdkhf44yjmniycybpza8o2q8tocky" xml:space="preserve">[[Isimumathi:Stock market charts illustration.jpg|thumb]]
Imakethe nokurhwebelana yizinto ezibaluleke khulu kwezomnotho, zidlala indima ekulu ekwabelaneni kwensenjenziswa kanye nokusatshalaliswa kwepahla eyisizo khulu enarheni mazombe. Imakethe yindawo lapho abathengi nabathengisi bahlangana khona ukuze batjhentjhisane ngepahla neensetjenziswa zemphakathini, bese kuthi ukurhwebelana kube yisenzo sokuthenga nokuthengisa leyo pahla neensetjenziswa.

=== Imihlobo yemakethe esinayo. ===
Kukhona imihlobo ehlukeneko yemakethe, efaka hlangana:

1. Iphikiswano ephelele (Perfect Competition): Lomhlobo wemakethe kulapho kunabathengi nabathengisi abanengi, ukungena nokuphuma okulula, kanye nelwazi eliphelele (Smith, 1776).

2. Ukunqoba (Monopoly): Lomhlobo wemakethe kulapho ikhampani eyodwa kwaphela ikhiqiza imikhiqizo nofana iinsetjenziswa ezithileko enikela ngazo kumakethe.&lt;ref&gt;{{Cite book|last=Marshall|first=A|title=Principles of Economics|date=1890|publisher=Macmillan|year=1890}}&lt;/ref&gt;

3. Ukubumbana kwamakhampani ambalwa (Oligopoly): Lomhlobo wemakethe kulapho amakhampani ambalwa abusa khona begodu aphikisana ngokunikela kumakethe.&lt;ref&gt;{{Cite book|last=Chamberlin|first=E. H|title=The Theory of Monopolistic Competition.|date=1993|publisher=Harvard University Press|year=1993}}&lt;/ref&gt;

==== Iindlela Zokurhwebelana (Trading Mechanisms) ====
Iindlela zokurhwebelana zifaka hlangana imigomo nemibandela elawula ukuthenga nokuthengisa epahleni neensetjenziswa  kumakethe. Lezi iindlela zingaba:

1. Ukurhwebelana Ngokuzwisisana (Auction-based trading): Lomhlobo yindlela lapho abathengi nabathengisi bafaka amanani wabo, iintengo zibekwa ngendlela yokuhlangabezana kwesidingo nokunikelwa ngepahla nanyana iinsetjenziswa ezithize kumakethe..&lt;ref name=&quot;:1&quot;&gt;{{Cite book|last=Marshall|first=A|title=Principles of Economics|date=1990|publisher=Macmillan|year=1990}}&lt;/ref&gt;

2. Ukurwebelana Ngaphandle kokuzwisisana (Quote-driven trading):Lomhlobo yindlela lapho abenzi bemakethe banikeza amanani wokuthenga nokuthengisa, abathengi bangakhetha ukuwamukela nofana ukuwalandula.&lt;ref&gt;{{Cite book|last=Milgrom|first=P|title=Putting Auction Theory to Work|date=2004|publisher=Cambridge University Press.|year=2004}}&lt;/ref&gt;

===== Ukusebenza Kwemakethe (Market Efficiency) =====
Ukusebenza kwemakethe kutjho ikghono lemakethe lokubonisa loke ilwazi elokhona eentengweni. Kune mihlobo emithathu yokusebenza kwemakethe:

1. Ifomu Elibuthakathaka (Weak form efficiency): Iintengo zibonisa loke ilwazi lamanani adlulileko.&lt;ref&gt;{{Cite journal|last=Fama|first=E. F.|date=1970|title=Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance|journal=Journal of Finance}}&lt;/ref&gt;

2.Ifomu Eliphakathi (Semi-strong form efficiency): Iintengo zikhombisa loke ilwazi elikhona emphakathini.&lt;ref&gt;{{Cite journal|last=Fama|first=E. F.|date=1970|title=Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance|journal=Journal of Finance}}&lt;/ref&gt;

3. Ifomu Elinamandla (Strong form efficiency): Iintengo zikhombisa loke ilwazi, kungaba ngelikhona emphakathini nofana elifihlakeleko.&lt;ref&gt;{{Cite journal|last=Fama|first=E. F.|date=1970|title=Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance|journal=Journal of Finance}}&lt;/ref&gt;

Imakethe bokurhwebelana kuyizinto ezinganakuthembeka begodu ezitjhugulukako mihla namalanga ezidlala indima ekulu ekwabelaneni kweensetjenziswa nekusatshalalisweni kwepahla neensetjensiza. Ukulemula iminhlobo ehlukeneko yemakethe, iindlela zokurhwebelana, nokusebenza kwemakethe kubalulekile ekuthatheni iinqumo ezihlakaniphileko zokwandisa imali nokuzwisisa ubunzima bokwandisa umnotho esikhathini sanje.

Chamberlin, E. H. (1933). The Theory of Monopolistic Competition. Harvard University Press.

Fama, E. F. (1970). Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance, 25(2), 383-417.

Hasbrouck, J. (2007). Empirical Market Microstructure. Oxford University Press.

Marshall, A. (1890). Principles of Economics. Macmillan.  Milgrom, P. (2004). Putting Auction Theory to Work. Cambridge University Press.

Smith, A. (1776). The Wealth of Nations. Penguin Books

====== Imithombo lwazi ======
&lt;references /&gt;</text>
      <sha1>m3tdkhf44yjmniycybpza8o2q8tocky</sha1>
    </revision>
    <revision>
      <id>5687</id>
      <parentid>5684</parentid>
      <timestamp>2025-09-04T11:37:21Z</timestamp>
      <contributor>
        <username>White Edits</username>
        <id>894</id>
      </contributor>
      <origin>5687</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4313" sha1="afnubzdslzjqwet8bhm1dpjrl5fan6r" xml:space="preserve">[[Isimumathi:Stock market charts illustration.jpg|thumb]]
[[Isimumathi:Market data on display at Taiwan Stock Exchange 20210208.jpg|thumb]]
Imakethe nokurhwebelana yizinto ezibaluleke khulu kwezomnotho, zidlala indima ekulu ekwabelaneni kwensenjenziswa kanye nokusatshalaliswa kwepahla eyisizo khulu enarheni mazombe. Imakethe yindawo lapho abathengi nabathengisi bahlangana khona ukuze batjhentjhisane ngepahla neensetjenziswa zemphakathini, bese kuthi ukurhwebelana kube yisenzo sokuthenga nokuthengisa leyo pahla neensetjenziswa.

=== Imihlobo yemakethe esinayo. ===
Kukhona imihlobo ehlukeneko yemakethe, efaka hlangana:

1. Iphikiswano ephelele (Perfect Competition): Lomhlobo wemakethe kulapho kunabathengi nabathengisi abanengi, ukungena nokuphuma okulula, kanye nelwazi eliphelele (Smith, 1776).

2. Ukunqoba (Monopoly): Lomhlobo wemakethe kulapho ikhampani eyodwa kwaphela ikhiqiza imikhiqizo nofana iinsetjenziswa ezithileko enikela ngazo kumakethe.&lt;ref&gt;{{Cite book|last=Marshall|first=A|title=Principles of Economics|date=1890|publisher=Macmillan|year=1890}}&lt;/ref&gt;

3. Ukubumbana kwamakhampani ambalwa (Oligopoly): Lomhlobo wemakethe kulapho amakhampani ambalwa abusa khona begodu aphikisana ngokunikela kumakethe.&lt;ref&gt;{{Cite book|last=Chamberlin|first=E. H|title=The Theory of Monopolistic Competition.|date=1993|publisher=Harvard University Press|year=1993}}&lt;/ref&gt;

==== Iindlela Zokurhwebelana (Trading Mechanisms) ====
Iindlela zokurhwebelana zifaka hlangana imigomo nemibandela elawula ukuthenga nokuthengisa epahleni neensetjenziswa  kumakethe. Lezi iindlela zingaba:

1. Ukurhwebelana Ngokuzwisisana (Auction-based trading): Lomhlobo yindlela lapho abathengi nabathengisi bafaka amanani wabo, iintengo zibekwa ngendlela yokuhlangabezana kwesidingo nokunikelwa ngepahla nanyana iinsetjenziswa ezithize kumakethe..&lt;ref name=&quot;:1&quot;&gt;{{Cite book|last=Marshall|first=A|title=Principles of Economics|date=1990|publisher=Macmillan|year=1990}}&lt;/ref&gt;

2. Ukurwebelana Ngaphandle kokuzwisisana (Quote-driven trading):Lomhlobo yindlela lapho abenzi bemakethe banikeza amanani wokuthenga nokuthengisa, abathengi bangakhetha ukuwamukela nofana ukuwalandula.&lt;ref&gt;{{Cite book|last=Milgrom|first=P|title=Putting Auction Theory to Work|date=2004|publisher=Cambridge University Press.|year=2004}}&lt;/ref&gt;

===== Ukusebenza Kwemakethe (Market Efficiency) =====
Ukusebenza kwemakethe kutjho ikghono lemakethe lokubonisa loke ilwazi elokhona eentengweni. Kune mihlobo emithathu yokusebenza kwemakethe:

1. Ifomu Elibuthakathaka (Weak form efficiency): Iintengo zibonisa loke ilwazi lamanani adlulileko.&lt;ref&gt;{{Cite journal|last=Fama|first=E. F.|date=1970|title=Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance|journal=Journal of Finance}}&lt;/ref&gt;

2.Ifomu Eliphakathi (Semi-strong form efficiency): Iintengo zikhombisa loke ilwazi elikhona emphakathini.&lt;ref&gt;{{Cite journal|last=Fama|first=E. F.|date=1970|title=Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance|journal=Journal of Finance}}&lt;/ref&gt;

3. Ifomu Elinamandla (Strong form efficiency): Iintengo zikhombisa loke ilwazi, kungaba ngelikhona emphakathini nofana elifihlakeleko.&lt;ref&gt;{{Cite journal|last=Fama|first=E. F.|date=1970|title=Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance|journal=Journal of Finance}}&lt;/ref&gt;

Imakethe bokurhwebelana kuyizinto ezinganakuthembeka begodu ezitjhugulukako mihla namalanga ezidlala indima ekulu ekwabelaneni kweensetjenziswa nekusatshalalisweni kwepahla neensetjensiza. Ukulemula iminhlobo ehlukeneko yemakethe, iindlela zokurhwebelana, nokusebenza kwemakethe kubalulekile ekuthatheni iinqumo ezihlakaniphileko zokwandisa imali nokuzwisisa ubunzima bokwandisa umnotho esikhathini sanje.

Chamberlin, E. H. (1933). The Theory of Monopolistic Competition. Harvard University Press.

Fama, E. F. (1970). Efficient Capital Markets: A Review of Theory and Empirical Work. Journal of Finance, 25(2), 383-417.

Hasbrouck, J. (2007). Empirical Market Microstructure. Oxford University Press.

Marshall, A. (1890). Principles of Economics. Macmillan.  Milgrom, P. (2004). Putting Auction Theory to Work. Cambridge University Press.

Smith, A. (1776). The Wealth of Nations. Penguin Books

====== Imithombo lwazi ======
&lt;references /&gt;</text>
      <sha1>afnubzdslzjqwet8bhm1dpjrl5fan6r</sha1>
    </revision>
  </page>
  <page>
    <title>I-Mkhombo Nature Reserve</title>
    <ns>0</ns>
    <id>937</id>
    <revision>
      <id>5675</id>
      <timestamp>2025-09-04T11:29:18Z</timestamp>
      <contributor>
        <username>Pholap</username>
        <id>883</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1272472128|Mkhombo Nature Reserve]]&quot;</comment>
      <origin>5675</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="967" sha1="fuc46t7fquj3e8w2bkrb8cpyamq8lpd" xml:space="preserve">
'''I-Mkhombo Nature Reserve''' yindawo evikelweko e [[Isifunda seMpumalanga|-Mpumalanga]], [[Isewula Afrika|eSewula Afrika]]. Yindawo ekulu, eyi-11,223 ha elondoloza ibhoduluko elisempumalanga ye-Kalahari eduze nedamu le-Mkhombo.  Indawo yokugcina indawo inendawo ejwayelekileko yotjani ephakemeko enethiwekhi yamaxhaphozi kanye namadwala aphumako. 

Indawo yokugcina imvelo yaziwa ngokuphila kwayo kweenyoni. Hlangana nemihlobo yeenlwana ezivela endaweni le kune- reed cormorant, I-African yellow-billed hornbill, I-African grey hornbill, I-white-breasted cormorant, I-little swift, I- hamerkop, I-red-winged starling, I- pectoral sandpiper, I-grey plover, I -barred wren-warble, ne- wailwarta yellow . 

Yindawo evame ukuvakatjhelwa ziimvakatjhi ezivela ephasini loke. Imihlobo yeenlwana ezitholakala endaweni le ifakahlangana iindlovu, amabhubezi, iingwe, iindlovu, iinyathi, ubhejane, iimvubu, kanye nemihlobo eminengi yama-antelope. 

== Iinkomba ==
{{Reflist}}</text>
      <sha1>fuc46t7fquj3e8w2bkrb8cpyamq8lpd</sha1>
    </revision>
    <revision>
      <id>5688</id>
      <parentid>5675</parentid>
      <timestamp>2025-09-04T11:37:30Z</timestamp>
      <contributor>
        <username>Pholap</username>
        <id>883</id>
      </contributor>
      <minor />
      <comment>NEW ARTICLE</comment>
      <origin>5688</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1182" sha1="2beh8r03c41mb3uphtrpdlgvltmsbvj" xml:space="preserve">
'''Mkhombo Nature Reserve''' yindawo evikelweko e [[Isifunda seMpumalanga|-Mpumalanga]], [[Isewula Afrika|eSewula Afrika]]. Yindawo ekulu, eyi-11,223 ha elondoloza ibhoduluko elisempumalanga ye-Kalahari eduze nedamu le-Mkhombo.  Indawo yokugcina indawo inendawo ejwayelekileko yotjani ephakemeko enethiwekhi yamaxhaphozi kanye namadwala aphumako.&lt;ref&gt;[https://www.mpumalanga.com/our-provincial-parks/mkhombo-nature-reserve Mkhombo Nature Reserve - Mpumalanga]&lt;/ref&gt; 

Indawo yokugcina imvelo yaziwa ngokuphila kwayo kweenyoni. Hlangana nemihlobo yeenlwana ezivela endaweni le kune- reed cormorant, I-African yellow-billed hornbill, I-African grey hornbill, I-white-breasted cormorant, I-little swift, I- hamerkop, I-red-winged starling, I- pectoral sandpiper, I-grey plover, I -barred wren-warble, ne- wailwarta yellow.&lt;ref&gt;[[:en:Southern_yellow-billed_hornbill|Southern yellow-billed hornbill - Wikipedia]]&lt;/ref&gt; 

Yindawo evame ukuvakatjhelwa ziimvakatjhi ezivela ephasini loke. Imihlobo yeenlwana ezitholakala endaweni le ifakahlangana iindlovu, amabhubezi, iingwe, iindlovu, iinyathi, ubhejane, iimvubu, kanye nemihlobo eminengi yama-antelope. 

== Umthombolwazi ==
{{Reflist}}</text>
      <sha1>2beh8r03c41mb3uphtrpdlgvltmsbvj</sha1>
    </revision>
    <revision>
      <id>6668</id>
      <parentid>5688</parentid>
      <timestamp>2026-06-07T15:08:34Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>Added</comment>
      <origin>6668</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1558" sha1="85vrqbdqjdv8wseblu4v53wj0ozabkv" xml:space="preserve">{{Infobox park
| name = I-Mkhombo Nature Reserve
| image = Mkhombodam, waadvoëls aan oewer, a.jpg
| image_size = 
| image_alt = 
| image_caption =
| type = 
| location = [[Mpumalanga]], [[South Africa]]
| coordinates = {{coord|-25.114|28.825|type:forest|display=inline,title}}
| area = 
| created = &lt;!-- {{Start date|YYYY}} --&gt;
| operator = 
| visitation_num = 
| status =
}}
'''Mkhombo Nature Reserve''' yindawo evikelweko e [[Isifunda seMpumalanga|-Mpumalanga]], [[Isewula Afrika|eSewula Afrika]]. Yindawo ekulu, eyi-11,223 ha elondoloza ibhoduluko elisempumalanga ye-Kalahari eduze nedamu le-Mkhombo.  Indawo yokugcina indawo inendawo ejwayelekileko yotjani ephakemeko enethiwekhi yamaxhaphozi kanye namadwala aphumako.&lt;ref&gt;[https://www.mpumalanga.com/our-provincial-parks/mkhombo-nature-reserve Mkhombo Nature Reserve - Mpumalanga]&lt;/ref&gt; 

Indawo yokugcina imvelo yaziwa ngokuphila kwayo kweenyoni. Hlangana nemihlobo yeenlwana ezivela endaweni le kune- reed cormorant, I-African yellow-billed hornbill, I-African grey hornbill, I-white-breasted cormorant, I-little swift, I- hamerkop, I-red-winged starling, I- pectoral sandpiper, I-grey plover, I -barred wren-warble, ne- wailwarta yellow.&lt;ref&gt;[[:en:Southern_yellow-billed_hornbill|Southern yellow-billed hornbill - Wikipedia]]&lt;/ref&gt; 

Yindawo evame ukuvakatjhelwa ziimvakatjhi ezivela ephasini loke. Imihlobo yeenlwana ezitholakala endaweni le ifakahlangana iindlovu, amabhubezi, iingwe, iindlovu, iinyathi, ubhejane, iimvubu, kanye nemihlobo eminengi yama-antelope. 

== Umthombolwazi ==
{{Reflist}}</text>
      <sha1>85vrqbdqjdv8wseblu4v53wj0ozabkv</sha1>
    </revision>
    <revision>
      <id>6670</id>
      <parentid>6668</parentid>
      <timestamp>2026-06-07T15:19:18Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>Added an image. Not sure what module is in vernacular</comment>
      <origin>6670</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1310" sha1="4afk8xp99bem31b23n72vxj1x1lq9xv" xml:space="preserve">[[File:3-banded plover last weekend at Mkhombo Dam (36902155813).jpg|3-banded plover last weekend at Mkhombo Dam (36902155813)]]
'''Mkhombo Nature Reserve''' yindawo evikelweko e [[Isifunda seMpumalanga|-Mpumalanga]], [[Isewula Afrika|eSewula Afrika]]. Yindawo ekulu, eyi-11,223 ha elondoloza ibhoduluko elisempumalanga ye-Kalahari eduze nedamu le-Mkhombo.  Indawo yokugcina indawo inendawo ejwayelekileko yotjani ephakemeko enethiwekhi yamaxhaphozi kanye namadwala aphumako.&lt;ref&gt;[https://www.mpumalanga.com/our-provincial-parks/mkhombo-nature-reserve Mkhombo Nature Reserve - Mpumalanga]&lt;/ref&gt; 

Indawo yokugcina imvelo yaziwa ngokuphila kwayo kweenyoni. Hlangana nemihlobo yeenlwana ezivela endaweni le kune- reed cormorant, I-African yellow-billed hornbill, I-African grey hornbill, I-white-breasted cormorant, I-little swift, I- hamerkop, I-red-winged starling, I- pectoral sandpiper, I-grey plover, I -barred wren-warble, ne- wailwarta yellow.&lt;ref&gt;[[:en:Southern_yellow-billed_hornbill|Southern yellow-billed hornbill - Wikipedia]]&lt;/ref&gt; 

Yindawo evame ukuvakatjhelwa ziimvakatjhi ezivela ephasini loke. Imihlobo yeenlwana ezitholakala endaweni le ifakahlangana iindlovu, amabhubezi, iingwe, iindlovu, iinyathi, ubhejane, iimvubu, kanye nemihlobo eminengi yama-antelope. 

== Umthombolwazi ==
{{Reflist}}</text>
      <sha1>4afk8xp99bem31b23n72vxj1x1lq9xv</sha1>
    </revision>
    <revision>
      <id>6671</id>
      <parentid>6670</parentid>
      <timestamp>2026-06-07T15:19:54Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>Try again</comment>
      <origin>6671</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1316" sha1="qekt1m93mgclu7b80j5lr12gkx6kinr" xml:space="preserve">[[File:3-banded plover last weekend at Mkhombo Dam (36902155813).jpg|thumb|3-banded plover last weekend at Mkhombo Dam (36902155813)]]
'''Mkhombo Nature Reserve''' yindawo evikelweko e [[Isifunda seMpumalanga|-Mpumalanga]], [[Isewula Afrika|eSewula Afrika]]. Yindawo ekulu, eyi-11,223 ha elondoloza ibhoduluko elisempumalanga ye-Kalahari eduze nedamu le-Mkhombo.  Indawo yokugcina indawo inendawo ejwayelekileko yotjani ephakemeko enethiwekhi yamaxhaphozi kanye namadwala aphumako.&lt;ref&gt;[https://www.mpumalanga.com/our-provincial-parks/mkhombo-nature-reserve Mkhombo Nature Reserve - Mpumalanga]&lt;/ref&gt; 

Indawo yokugcina imvelo yaziwa ngokuphila kwayo kweenyoni. Hlangana nemihlobo yeenlwana ezivela endaweni le kune- reed cormorant, I-African yellow-billed hornbill, I-African grey hornbill, I-white-breasted cormorant, I-little swift, I- hamerkop, I-red-winged starling, I- pectoral sandpiper, I-grey plover, I -barred wren-warble, ne- wailwarta yellow.&lt;ref&gt;[[:en:Southern_yellow-billed_hornbill|Southern yellow-billed hornbill - Wikipedia]]&lt;/ref&gt; 

Yindawo evame ukuvakatjhelwa ziimvakatjhi ezivela ephasini loke. Imihlobo yeenlwana ezitholakala endaweni le ifakahlangana iindlovu, amabhubezi, iingwe, iindlovu, iinyathi, ubhejane, iimvubu, kanye nemihlobo eminengi yama-antelope. 

== Umthombolwazi ==
{{Reflist}}</text>
      <sha1>qekt1m93mgclu7b80j5lr12gkx6kinr</sha1>
    </revision>
    <revision>
      <id>6672</id>
      <parentid>6671</parentid>
      <timestamp>2026-06-07T15:23:54Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>Added</comment>
      <origin>6672</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1505" sha1="2fpt9t6lwr17t7ajeu0itlutmasw64u" xml:space="preserve">{{multiple image
| border = infobox
| perrow = 1/2/2/1
| total_width = 290
| align = center
| caption_align = center
|image1 = 3-banded plover last weekend at Mkhombo Dam (36902155813).jpg
| caption1 = 
| image2             = 
| caption2           = 
|image3 = 
| caption3 = 
| image4          = 
| caption4          = 
}}

'''Mkhombo Nature Reserve''' yindawo evikelweko e [[Isifunda seMpumalanga|-Mpumalanga]], [[Isewula Afrika|eSewula Afrika]]. Yindawo ekulu, eyi-11,223 ha elondoloza ibhoduluko elisempumalanga ye-Kalahari eduze nedamu le-Mkhombo.  Indawo yokugcina indawo inendawo ejwayelekileko yotjani ephakemeko enethiwekhi yamaxhaphozi kanye namadwala aphumako.&lt;ref&gt;[https://www.mpumalanga.com/our-provincial-parks/mkhombo-nature-reserve Mkhombo Nature Reserve - Mpumalanga]&lt;/ref&gt; 

Indawo yokugcina imvelo yaziwa ngokuphila kwayo kweenyoni. Hlangana nemihlobo yeenlwana ezivela endaweni le kune- reed cormorant, I-African yellow-billed hornbill, I-African grey hornbill, I-white-breasted cormorant, I-little swift, I- hamerkop, I-red-winged starling, I- pectoral sandpiper, I-grey plover, I -barred wren-warble, ne- wailwarta yellow.&lt;ref&gt;[[:en:Southern_yellow-billed_hornbill|Southern yellow-billed hornbill - Wikipedia]]&lt;/ref&gt; 

Yindawo evame ukuvakatjhelwa ziimvakatjhi ezivela ephasini loke. Imihlobo yeenlwana ezitholakala endaweni le ifakahlangana iindlovu, amabhubezi, iingwe, iindlovu, iinyathi, ubhejane, iimvubu, kanye nemihlobo eminengi yama-antelope. 

== Umthombolwazi ==
{{Reflist}}</text>
      <sha1>2fpt9t6lwr17t7ajeu0itlutmasw64u</sha1>
    </revision>
    <revision>
      <id>6677</id>
      <parentid>6672</parentid>
      <timestamp>2026-06-07T15:39:52Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <origin>6677</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1181" sha1="gguzi4xf8urmz53njyhrapnvet6k2zz" xml:space="preserve">'''Mkhombo Nature Reserve''' yindawo evikelweko e [[Isifunda seMpumalanga|-Mpumalanga]], [[Isewula Afrika|eSewula Afrika]]. Yindawo ekulu, eyi-11,223 ha elondoloza ibhoduluko elisempumalanga ye-Kalahari eduze nedamu le-Mkhombo.  Indawo yokugcina indawo inendawo ejwayelekileko yotjani ephakemeko enethiwekhi yamaxhaphozi kanye namadwala aphumako.&lt;ref&gt;[https://www.mpumalanga.com/our-provincial-parks/mkhombo-nature-reserve Mkhombo Nature Reserve - Mpumalanga]&lt;/ref&gt; 

Indawo yokugcina imvelo yaziwa ngokuphila kwayo kweenyoni. Hlangana nemihlobo yeenlwana ezivela endaweni le kune- reed cormorant, I-African yellow-billed hornbill, I-African grey hornbill, I-white-breasted cormorant, I-little swift, I- hamerkop, I-red-winged starling, I- pectoral sandpiper, I-grey plover, I -barred wren-warble, ne- wailwarta yellow.&lt;ref&gt;[[:en:Southern_yellow-billed_hornbill|Southern yellow-billed hornbill - Wikipedia]]&lt;/ref&gt; 

Yindawo evame ukuvakatjhelwa ziimvakatjhi ezivela ephasini loke. Imihlobo yeenlwana ezitholakala endaweni le ifakahlangana iindlovu, amabhubezi, iingwe, iindlovu, iinyathi, ubhejane, iimvubu, kanye nemihlobo eminengi yama-antelope. 

== Umthombolwazi ==
{{Reflist}}</text>
      <sha1>gguzi4xf8urmz53njyhrapnvet6k2zz</sha1>
    </revision>
    <revision>
      <id>6728</id>
      <parentid>6677</parentid>
      <timestamp>2026-06-15T09:16:37Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>added</comment>
      <origin>6728</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1678" sha1="hu89i64xvq4ws9kite7vzn9b9brzath" xml:space="preserve">{{multiple image|border=infobox|perrow=2/1/|total_width=290|align=right|caption_align=center|image1=3-banded plover last weekend at Mkhombo Dam (36902155813).jpg|caption1=[[:en:Three-banded_plover|Three banded plover]]|image2=Black-winged_pratincole_(Glareola_nordmanni)_at_Mkhombo_Dam,_Mpumalanga_(36861637734).jpg|caption2=[[:en:Black-winged pratincole |Black winged pratincole ]]|image3=Common greenshank at Mkhombo Dam.jpg|caption3=[[:en:Marsh_sandpiper|Marsh sandpiper]]|image4=|caption4=}}

'''Mkhombo Nature Reserve''' yindawo evikelweko e [[Isifunda seMpumalanga|-Mpumalanga]], [[Isewula Afrika|eSewula Afrika]]. Yindawo ekulu, eyi-11,223 ha elondoloza ibhoduluko elisempumalanga ye-Kalahari eduze nedamu le-Mkhombo.  Indawo yokugcina indawo inendawo ejwayelekileko yotjani ephakemeko enethiwekhi yamaxhaphozi kanye namadwala aphumako.&lt;ref&gt;[https://www.mpumalanga.com/our-provincial-parks/mkhombo-nature-reserve Mkhombo Nature Reserve - Mpumalanga]&lt;/ref&gt; 

Indawo yokugcina imvelo yaziwa ngokuphila kwayo kweenyoni. Hlangana nemihlobo yeenlwana ezivela endaweni le kune- reed cormorant, I-African yellow-billed hornbill, I-African grey hornbill, I-white-breasted cormorant, I-little swift, I- hamerkop, I-red-winged starling, I- pectoral sandpiper, I-grey plover, I -barred wren-warble, ne- wailwarta yellow.&lt;ref&gt;[[:en:Southern_yellow-billed_hornbill|Southern yellow-billed hornbill - Wikipedia]]&lt;/ref&gt; 

Yindawo evame ukuvakatjhelwa ziimvakatjhi ezivela ephasini loke. Imihlobo yeenlwana ezitholakala endaweni le ifakahlangana iindlovu, amabhubezi, iingwe, iindlovu, iinyathi, ubhejane, iimvubu, kanye nemihlobo eminengi yama-antelope. 

== Umthombolwazi ==
{{Reflist}}</text>
      <sha1>hu89i64xvq4ws9kite7vzn9b9brzath</sha1>
    </revision>
  </page>
  <page>
    <title>Kungwini Local Municipality</title>
    <ns>0</ns>
    <id>938</id>
    <revision>
      <id>5699</id>
      <timestamp>2025-09-05T21:34:34Z</timestamp>
      <contributor>
        <username>Mojonom</username>
        <id>593</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1058767160|Kungwini Local Municipality]]&quot;</comment>
      <origin>5699</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5470" sha1="317ma3hokdzlddu2qj8ukigiapcm24w" xml:space="preserve">{{Infobox settlement   &lt;!-- See Template:Infobox settlement for additional fields and descriptions --&gt;|name=Kungwini Local Municipality|settlement_type=[[Local municipality (South Africa)|Local municipality]]
&lt;!-- images, nickname ---&gt;|image_skyline=|imagesize=|image_caption=|nickname=&lt;!-- maps and coordinates ------&gt;|image_map=Map of Gauteng with Kungwini highlighted.svg|mapsize=|map_alt=Location in Gauteng|map_caption=Location in [[Gauteng]]|image_map1=|mapsize1=|map_alt1=|map_caption1=|coordinates=|coordinates_footnotes=&lt;!-- for references: use &lt;ref&gt; tags --&gt;
&lt;!-- location ------------------&gt;|subdivision_type=[[List of sovereign states|Country]]|subdivision_name=[[South Africa]]|subdivision_type1=[[Provinces of South Africa|Province]]|subdivision_name1=[[Gauteng]]|subdivision_type2=[[Districts of South Africa|District]]|subdivision_name2=[[Metsweding District Municipality|Metsweding District]]
&lt;!-- seat, smaller parts -------&gt;|seat=[[Bronkhorstspruit]]|parts_type=&lt;!-- e.g., Local municipalities in this district (defaults to: Boroughs) --&gt;|parts=&lt;!-- header for parts list --&gt;|p1=|p2=|p3=|p4=|p5=&lt;!-- etc., up to p50: for parts to be listed--&gt;
&lt;!-- government leaders --&gt;|government_footnotes=&lt;!-- for references: use &lt;ref&gt; tags --&gt;|government_type=|leader_party=|leader_title=|leader_name=|leader_title1=|leader_name1=|leader_title2=|leader_name2=&lt;!-- area ----------------------&gt;|area_footnotes=&lt;!-- for references: use &lt;ref&gt; tags --&gt;|area_total_km2=2202|area_total_sq_mi=&lt;!-- population ----------------&gt;|population_footnotes=&lt;ref&gt;{{cite web |url=http://www.statssa.gov.za/Publications/P03011/P030112007.pdf |publisher=Statistics South Africa |title=Community Survey, 2007: Basic Results Municipalities |format=PDF |accessdate=2009-10-20 |archive-url=https://web.archive.org/web/20130825124835/http://www.statssa.gov.za/Publications/P03011/P030112007.pdf |archive-date=2013-08-25 |url-status=dead }}&lt;/ref&gt;|population_total=104149|population_as_of=2007|population_rank=|population_density_km2=auto|population_density_sq_mi=|population_est=|pop_est_as_of=|population_blank1_title=Households|population_blank1=31 665|population_density_blank1_km2=|population_density_blank1_sq_mi=|population_note=&lt;!-- demographics (Racial makeup) --&gt;|demographics_type1=Racial makeup|demographics1_footnotes=&lt;ref&gt;{{cite web |url=http://www.statssa.gov.za/community_new/content.asp?link=interactivedata.asp |title=Community Survey 2007 interactive data |publisher=Statistics South Africa |accessdate=19 October 2009 |url-status=dead |archiveurl=https://archive.today/20120805164522/http://www.statssa.gov.za/community_new/content.asp?link=interactivedata.asp |archivedate=5 August 2012 }}&lt;/ref&gt; (2007)|demographics1_title1=[[Black African]]|demographics1_info1=84.03%|demographics1_title2=[[White South African|White]]|demographics1_info2=14.12%|demographics1_title3=[[Coloured]]|demographics1_info3=1.59%|demographics1_title4=[[Indian South African|Indian]] or [[Asian South African|Asian]]|demographics1_info4=0.26%
&lt;!-- Other demographics
| demographics_type2      = Languages
| demographics2_footnotes = &lt;ref&gt;{{cite web |url=http://www.statssa.gov.za/census01/html/C2001Interactive.asp |title=Census 2001 interactive data |publisher=Statistics South Africa |accessdate=19 October 2009}}&lt;/ref&gt; (2001)
| demographics2_title1    = 
| demographics2_info1     = 
| demographics2_title2    = 
| demographics2_info2     = 
| demographics2_title3    = 
| demographics2_info3     =  --&gt;
&lt;!-- time zone(s) --------------&gt;|timezone1=[[South African Standard Time|SAST]]|utc_offset1=+2
&lt;!-- Municipal code --&gt;|blank_name_sec1=Municipal&amp;nbsp;code|blank_info_sec1=GT462
&lt;!-- website, footnotes --&gt;|website=|footnotes=}}'''UMasipala we-Kungwini''' khabe kungumasipala wendawo obewungaphasi kwesiyingi se [[:en:Metsweding_District_Municipality|Metsweding]] ebesingaphasi kwesifunda se [[:en:Gauteng|Gauteng]] e[[Isewula Afrika|Sewula Afrika]]. Idorobha elikhulu likaMasipala lo khabe kulidorobha le [[:en:Bronkhorstspruit|Bronkhorstspruit]].


uMasipala lo, kunye nesiyingi waso iMetsweding wafakwa ngaphasi kukaMasipala omkhulu i[[:en:Tshwane_Metropolitan_Municipality|Tshwane Metropolitan Municipality]] mhlazana ali -18 kuMrhayili ngomnyaka ka 2011. Ibizo elithi &quot;Kungwini&quot; kulibizo lesi[[:en:Southern_Ndebele_language|Ndebele seSewula]] elisuselwe ebizweni elithi iKungu. Lokhu kungombana indawo le kuyindawo ethandwa yikungu ngendlela erarako.





== Iindawo ezikulu ==
Iindawo ezikulu zikaMasipala lo, ekuziimbalo ezifunyenwe nakubalwa abantu ngomnyaka ka 2001: 
{| class=&quot;wikitable sortable&quot; border=&quot;1&quot;
!Ukubeka
! Ikhodi
! Ilimi elikhulunywa khulu
|-
| I-Bronkhorstspruit
| [http://census.adrianfrith.com/place/78201 78201]
| IsiBhunu
|-
| [[Ekandustria]]
| [http://census.adrianfrith.com/place/78202 78202]
| IsiSotho seTlhagwini
|-
| Ekangala
| [http://census.adrianfrith.com/place/88201 88201]
| IsiZulu
|-
| [[Kungwini|I-Kungwini]] 1
| [http://census.adrianfrith.com/place/88202 88202]
|
|-
| [[Kungwini|I-Kungwini]] 2
| [http://census.adrianfrith.com/place/78203 78203]
| [[Isindebele|IsiNdebele seSewula]]
|-
| I-Pitori
| [http://census.adrianfrith.com/place/78204 78204]
| I-Setswana
|-
| [[Rethabiseng|I-Zithabiseni]]
| [http://census.adrianfrith.com/place/78205 78205]
| IsiZulu
|-
| [[Sehlakwana]]
| [http://census.adrianfrith.com/place/78206 78206]
| IsiNdebele seSewula
|-
| Zithobeni
| [http://census.adrianfrith.com/place/78207 78207]
| IsiNdebele seSewula
|}</text>
      <sha1>317ma3hokdzlddu2qj8ukigiapcm24w</sha1>
    </revision>
  </page>
  <page>
    <title>Sipho Makhabane</title>
    <ns>0</ns>
    <id>939</id>
    <revision>
      <id>5709</id>
      <timestamp>2025-09-07T11:56:18Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''U-Sipho Makhabane''' wabelethwa mhlana amalaga ama-3 enyangeni kaSinyikhaba ngonyaka we-1965 enarheni yeSewula Afrika eSwaziland.&lt;ref&gt;[https://buzzsouthafrica.com/sipho-makhabane-biography/ Sipho Makhabane Biography and Everything About the Gospel Singer]&lt;/ref&gt; Elinye igama waziwa ngokuthi ngu ”The Big Fish” okutjho bona ifesi ekulu ngelimi lesiNdebele. Umtloli womvumo wevangeli,umvumi osele akhiphe ama albhamu angaphezulu kwe-5. Ukhulele emndenini edobha phasi be...&quot;</comment>
      <origin>5709</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2246" sha1="npkzxxj7rgh0sxtiabh5jfi1hxhl52q" xml:space="preserve">'''U-Sipho Makhabane''' wabelethwa mhlana amalaga ama-3 enyangeni kaSinyikhaba ngonyaka we-1965 enarheni yeSewula Afrika eSwaziland.&lt;ref&gt;[https://buzzsouthafrica.com/sipho-makhabane-biography/ Sipho Makhabane Biography and Everything About the Gospel Singer]&lt;/ref&gt; Elinye igama waziwa ngokuthi ngu ”The Big Fish” okutjho bona ifesi ekulu ngelimi lesiNdebele. Umtloli womvumo wevangeli,umvumi osele akhiphe ama albhamu angaphezulu kwe-5. Ukhulele emndenini edobha phasi bedogu wahlongakalelwa nguyise asese mncani, kwakose bonyana alise isikolo akhambe ayokufuna amatorho ukuze akghone ukondla unina. Ngokunga bambeleli ebudisini lobu waragela phambili ukuthi afezekisa ibhudango lakhe lokuba mvumi.

Wathoma ibezelo lokubamvumi phakathi konyaka wango 1990 ekukulapho akhipha khan i-albhamu yakhe yokuthoma ”ngizinikela kuwe” ngonyaka we-1996, ekungiyo evela ngayo njengomvumi womvumo wevangeli. Walandelelwa ngenye i-albhamu yesihloko esithi”Yek’ intokozo” eyenza wavela njengokuthi sele amvumi okhona kwezomvumo wevangeli. Ukuphumelela ekukhipheni ama albhamu lawa kwmenzela iindlela bona akghone ukwenzela ama albhamu wakhe alandelako estudiyo.

Ibizelweni lakhe lezomvumo uMakhabe ukhiphe ama-albhamu amanengi afaka hlangana “uyigugu” “calvary” “hamba nami” namanye. Umvumo wakhe akhange umnikele abalanelii abanengi kwaphela kodwa ukghonile nokuth athumbe abonongorwana nokukhethwa.Ku-Glory awards ngonyaka we-2001 wathola unongorwana wokuba mkhuphi womvumi okhamba phambili nangonyaka we-2007. Ngonyaka we-2008 wathumba ku Mama Beka Community Empowerment Award.  Ngokubonakala komsebenzi wakhe emvumeni wevangeli wanikelwa unongorwana wokuhlonitjhwa  ngonyaka we-2024  ku-South African Music Awards.

Ngaphezulu kokuthi kwalokho akuzuzileko mgimvumo wakhe, u-Sipho Makhabane  unekghone lokuthi akhulise italente alibonako ebantwini abasathomako ukuvuma. Nge Big Fish Music ukghonile ukuthi adose phambili abavumi  abafana nabo hlengiwe mhlaba, Thobekile Mkhwanazi, Pastor Ncanda,  no Thsepiso Motaung, abanikele isekelo abalitlhogako ukuthi baphumelele emvumeni. Ukuzinikela kwakhe kwavusa ukuthuthukisa ilutjha eMpumalanga wadosa phambili ukuthoma kwekhaya yomvumo wevangeli ebizwa bona yi-Mpumalanga Praise.</text>
      <sha1>npkzxxj7rgh0sxtiabh5jfi1hxhl52q</sha1>
    </revision>
    <revision>
      <id>5710</id>
      <parentid>5709</parentid>
      <timestamp>2025-09-07T12:00:20Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5710</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2377" sha1="myyj72wgn4llzlbuq7sq2d9mu5xbxi3" xml:space="preserve">'''U-Sipho Makhabane''' wabelethwa mhlana amalaga ama-3 enyangeni kaSinyikhaba ngonyaka we-1965 enarheni yeSewula Afrika eSwaziland.&lt;ref&gt;[https://buzzsouthafrica.com/sipho-makhabane-biography/ Sipho Makhabane Biography and Everything About the Gospel Singer]&lt;/ref&gt; Elinye igama waziwa ngokuthi ngu ”The Big Fish” okutjho bona ifesi ekulu ngelimi lesiNdebele. Umtloli womvumo wevangeli,umvumi osele akhiphe ama albhamu angaphezulu kwe-5. Ukhulele emndenini edobha phasi bedogu wahlongakalelwa nguyise asese mncani, kwakose bonyana alise isikolo akhambe ayokufuna amatorho ukuze akghone ukondla unina. Ngokunga bambeleli ebudisini lobu waragela phambili ukuthi afezekisa ibhudango lakhe lokuba mvumi.

=== Ukuthoma kwakhe ukuba mvumi ===
Wathoma ibezelo lokubamvumi phakathi konyaka wango 1990 ekukulapho akhipha khan i-albhamu yakhe yokuthoma ”ngizinikela kuwe” ngonyaka we-1996, ekungiyo evela ngayo njengomvumi womvumo wevangeli. Walandelelwa ngenye i-albhamu yesihloko esithi”Yek’ intokozo” eyenza wavela njengokuthi sele amvumi okhona kwezomvumo wevangeli. Ukuphumelela ekukhipheni ama albhamu lawa kwmenzela iindlela bona akghone ukwenzela ama albhamu wakhe alandelako estudiyo.

=== Ukuthumba kwakhe ===
Ibizelweni lakhe lezomvumo uMakhabe ukhiphe ama-albhamu amanengi afaka hlangana “uyigugu” “calvary” “hamba nami” namanye. Umvumo wakhe akhange umnikele abalanelii abanengi kwaphela kodwa ukghonile nokuth athumbe abonongorwana nokukhethwa.Ku-Glory awards ngonyaka we-2001 wathola unongorwana wokuba mkhuphi womvumi okhamba phambili nangonyaka we-2007. Ngonyaka we-2008 wathumba ku Mama Beka Community Empowerment Award.  Ngokubonakala komsebenzi wakhe emvumeni wevangeli wanikelwa unongorwana wokuhlonitjhwa  ngonyaka we-2024  ku-South African Music Awards.

=== Abantu abalekeleleko kwezomvumi wevangeli ===
Ngaphezulu kokuthi kwalokho akuzuzileko mgimvumo wakhe, u-Sipho Makhabane  unekghone lokuthi akhulise italente alibonako ebantwini abasathomako ukuvuma. Nge Big Fish Music ukghonile ukuthi adose phambili abavumi  abafana nabo [[Hlengiwe Mhlaba]], Thobekile Mkhwanazi, Pastor Ncanda,  no Thsepiso Motaung, abanikele isekelo abalitlhogako ukuthi baphumelele emvumeni. Ukuzinikela kwakhe kwavusa ukuthuthukisa ilutjha eMpumalanga wadosa phambili ukuthoma kwekhaya yomvumo wevangeli ebizwa bona yi-Mpumalanga Praise.

== Iinkomba ==</text>
      <sha1>myyj72wgn4llzlbuq7sq2d9mu5xbxi3</sha1>
    </revision>
    <revision>
      <id>5711</id>
      <parentid>5710</parentid>
      <timestamp>2025-09-07T12:04:00Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5711</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2510" sha1="fr8rgjisx2gw6uuv26zxfa31u9x92ab" xml:space="preserve">'''U-Sipho Makhabane''' wabelethwa mhlana amalaga ama-3 enyangeni kaSinyikhaba ngonyaka we-1965 enarheni yeSewula Afrika eSwaziland.&lt;ref&gt;[https://buzzsouthafrica.com/sipho-makhabane-biography/ Sipho Makhabane Biography and Everything About the Gospel Singer]&lt;/ref&gt;&lt;ref&gt;[https://africanmusiclibrary.org/artist/Sipho%20Makhabane Sipho Makhabane Profile and Discography | African Music Library]&lt;/ref&gt; Elinye igama waziwa ngokuthi ngu ”The Big Fish” okutjho bona ifesi ekulu ngelimi lesiNdebele. Umtloli womvumo wevangeli,umvumi osele akhiphe ama albhamu angaphezulu kwe-5. Ukhulele emndenini edobha phasi bedogu wahlongakalelwa nguyise asese mncani, kwakose bonyana alise isikolo akhambe ayokufuna amatorho ukuze akghone ukondla unina. Ngokunga bambeleli ebudisini lobu waragela phambili ukuthi afezekisa ibhudango lakhe lokuba mvumi.

=== Ukuthoma kwakhe ukuba mvumi ===
Wathoma ibezelo lokubamvumi phakathi konyaka wango 1990 ekukulapho akhipha khan i-albhamu yakhe yokuthoma ”ngizinikela kuwe” ngonyaka we-1996, ekungiyo evela ngayo njengomvumi womvumo wevangeli. Walandelelwa ngenye i-albhamu yesihloko esithi”Yek’ intokozo” eyenza wavela njengokuthi sele amvumi okhona kwezomvumo wevangeli. Ukuphumelela ekukhipheni ama albhamu lawa kwmenzela iindlela bona akghone ukwenzela ama albhamu wakhe alandelako estudiyo.

=== Ukuthumba kwakhe ===
Ibizelweni lakhe lezomvumo uMakhabe ukhiphe ama-albhamu amanengi afaka hlangana “uyigugu” “calvary” “hamba nami” namanye. Umvumo wakhe akhange umnikele abalanelii abanengi kwaphela kodwa ukghonile nokuth athumbe abonongorwana nokukhethwa.Ku-Glory awards ngonyaka we-2001 wathola unongorwana wokuba mkhuphi womvumi okhamba phambili nangonyaka we-2007. Ngonyaka we-2008 wathumba ku Mama Beka Community Empowerment Award.  Ngokubonakala komsebenzi wakhe emvumeni wevangeli wanikelwa unongorwana wokuhlonitjhwa  ngonyaka we-2024  ku-South African Music Awards.

=== Abantu abalekeleleko kwezomvumi wevangeli ===
Ngaphezulu kokuthi kwalokho akuzuzileko mgimvumo wakhe, u-Sipho Makhabane  unekghone lokuthi akhulise italente alibonako ebantwini abasathomako ukuvuma. Nge Big Fish Music ukghonile ukuthi adose phambili abavumi  abafana nabo [[Hlengiwe Mhlaba]], Thobekile Mkhwanazi, Pastor Ncanda,  no Thsepiso Motaung, abanikele isekelo abalitlhogako ukuthi baphumelele emvumeni. Ukuzinikela kwakhe kwavusa ukuthuthukisa ilutjha eMpumalanga wadosa phambili ukuthoma kwekhaya yomvumo wevangeli ebizwa bona yi-Mpumalanga Praise.

== Iinkomba ==</text>
      <sha1>fr8rgjisx2gw6uuv26zxfa31u9x92ab</sha1>
    </revision>
    <revision>
      <id>5712</id>
      <parentid>5711</parentid>
      <timestamp>2025-09-07T12:12:19Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5712</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2875" sha1="eu2xr2cpud4k0igsq5pf44pmkjobreo" xml:space="preserve">'''U-Sipho Makhabane''' wabelethwa mhlana amalaga ama-3 enyangeni kaSinyikhaba ngonyaka we-1965 enarheni yeSewula Afrika eSwaziland.&lt;ref&gt;[https://buzzsouthafrica.com/sipho-makhabane-biography/ Sipho Makhabane Biography and Everything About the Gospel Singer]&lt;/ref&gt;&lt;ref&gt;[https://africanmusiclibrary.org/artist/Sipho%20Makhabane Sipho Makhabane Profile and Discography | African Music Library]&lt;/ref&gt; Elinye igama waziwa ngokuthi ngu ”The Big Fish” okutjho bona ifesi ekulu ngelimi lesiNdebele. Umtloli womvumo wevangeli,umvumi osele akhiphe ama albhamu angaphezulu kwe-5. Ukhulele emndenini edobha phasi bedogu wahlongakalelwa nguyise asese mncani, kwakose bonyana alise isikolo akhambe ayokufuna amatorho ukuze akghone ukondla unina. Ngokunga bambeleli ebudisini lobu waragela phambili ukuthi afezekisa ibhudango lakhe lokuba mvumi.

=== Ukuthoma kwakhe ukuba mvumi ===
Wathoma ibezelo lokubamvumi phakathi konyaka wango 1990 ekukulapho akhipha khan i-albhamu yakhe yokuthoma ”ngizinikela kuwe” ngonyaka we-1996, ekungiyo evela ngayo njengomvumi womvumo wevangeli. Walandelelwa ngenye i-albhamu yesihloko esithi”Yek’ intokozo” eyenza wavela njengokuthi sele amvumi okhona kwezomvumo wevangeli. Ukuphumelela ekukhipheni ama albhamu lawa kwmenzela iindlela bona akghone ukwenzela ama albhamu wakhe alandelako estudiyo.&lt;ref&gt;[https://gospelmusic.co.za/sipho-makhabane-the-visionary-behind-south-africas-gospel-music-renaissance/ Sipho Makhabane: The Visionary Behind South Africa’s Gospel Music Renaissance - South African Gospel Music Magazine]&lt;/ref&gt;

=== Ukuthumba kwakhe ===
Ibizelweni lakhe lezomvumo uMakhabe ukhiphe ama-albhamu amanengi afaka hlangana “uyigugu” “calvary” “hamba nami” namanye. Umvumo wakhe akhange umnikele abalanelii abanengi kwaphela kodwa ukghonile nokuth athumbe abonongorwana nokukhethwa.Ku-Glory awards ngonyaka we-2001 wathola unongorwana wokuba mkhuphi womvumi okhamba phambili nangonyaka we-2007. Ngonyaka we-2008 wathumba ku Mama Beka Community Empowerment Award.&lt;ref&gt;[https://buzzsouthafrica.com/sipho-makhabane-biography/ Sipho Makhabane Biography and Everything About the Gospel Singer]&lt;/ref&gt;  Ngokubonakala komsebenzi wakhe emvumeni wevangeli wanikelwa unongorwana wokuhlonitjhwa  ngonyaka we-2024  ku-South African Music Awards.

=== Abantu abalekeleleko kwezomvumi wevangeli ===
Ngaphezulu kokuthi kwalokho akuzuzileko mgimvumo wakhe, u-Sipho Makhabane  unekghone lokuthi akhulise italente alibonako ebantwini abasathomako ukuvuma. Nge Big Fish Music ukghonile ukuthi adose phambili abavumi  abafana nabo [[Hlengiwe Mhlaba]], Thobekile Mkhwanazi, Pastor Ncanda,  no Thsepiso Motaung, abanikele isekelo abalitlhogako ukuthi baphumelele emvumeni. Ukuzinikela kwakhe kwavusa ukuthuthukisa ilutjha eMpumalanga wadosa phambili ukuthoma kwekhaya yomvumo wevangeli ebizwa bona yi-Mpumalanga Praise.

== Iinkomba ==</text>
      <sha1>eu2xr2cpud4k0igsq5pf44pmkjobreo</sha1>
    </revision>
    <revision>
      <id>5713</id>
      <parentid>5712</parentid>
      <timestamp>2025-09-07T12:13:36Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5713</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2926" sha1="r6y17t9r07cm9wkrqa42b58ic5zbb6m" xml:space="preserve">'''U-Sipho Makhabane''' wabelethwa mhlana amalaga ama-3 enyangeni kaSinyikhaba ngonyaka we-1965 enarheni yeSewula Afrika eSwaziland.&lt;ref&gt;[https://buzzsouthafrica.com/sipho-makhabane-biography/ Sipho Makhabane Biography and Everything About the Gospel Singer]&lt;/ref&gt;&lt;ref&gt;[https://africanmusiclibrary.org/artist/Sipho%20Makhabane Sipho Makhabane Profile and Discography | African Music Library]&lt;/ref&gt; Elinye igama waziwa ngokuthi ngu ”The Big Fish” okutjho bona ifesi ekulu ngelimi lesiNdebele. Umtloli womvumo wevangeli,umvumi osele akhiphe ama albhamu angaphezulu kwe-5. Ukhulele emndenini edobha phasi bedogu wahlongakalelwa nguyise asese mncani, kwakose bonyana alise isikolo akhambe ayokufuna amatorho ukuze akghone ukondla unina. Ngokunga bambeleli ebudisini lobu waragela phambili ukuthi afezekisa ibhudango lakhe lokuba mvumi.

=== Ukuthoma kwakhe ukuba mvumi ===
Wathoma ibezelo lokubamvumi phakathi konyaka wango 1990 ekukulapho akhipha khan i-albhamu yakhe yokuthoma ”ngizinikela kuwe” ngonyaka we-1996, ekungiyo evela ngayo njengomvumi womvumo wevangeli. Walandelelwa ngenye i-albhamu yesihloko esithi”Yek’ intokozo” eyenza wavela njengokuthi sele amvumi okhona kwezomvumo wevangeli. Ukuphumelela ekukhipheni ama albhamu lawa kwmenzela iindlela bona akghone ukwenzela ama albhamu wakhe alandelako estudiyo.&lt;ref&gt;[https://gospelmusic.co.za/sipho-makhabane-the-visionary-behind-south-africas-gospel-music-renaissance/ Sipho Makhabane: The Visionary Behind South Africa’s Gospel Music Renaissance - South African Gospel Music Magazine]&lt;/ref&gt;

=== Ukuthumba kwakhe ===
Ibizelweni lakhe lezomvumo uMakhabe ukhiphe ama-albhamu amanengi afaka hlangana “uyigugu” “calvary” “hamba nami” namanye. Umvumo wakhe akhange umnikele abalanelii abanengi kwaphela kodwa ukghonile nokuth athumbe abonongorwana nokukhethwa.Ku-Glory awards ngonyaka we-2001 wathola unongorwana wokuba mkhuphi womvumi okhamba phambili nangonyaka we-2007. Ngonyaka we-2008 wathumba ku Mama Beka Community Empowerment Award.&lt;ref&gt;[https://buzzsouthafrica.com/sipho-makhabane-biography/ Sipho Makhabane Biography and Everything About the Gospel Singer]&lt;/ref&gt;  Ngokubonakala komsebenzi wakhe emvumeni wevangeli wanikelwa unongorwana wokuhlonitjhwa  ngonyaka we-2024  ku-South African Music Awards.

=== Abantu abalekeleleko kwezomvumi wevangeli ===
Ngaphezulu kokuthi kwalokho akuzuzileko mgimvumo wakhe, u-Sipho Makhabane  unekghone lokuthi akhulise italente alibonako ebantwini abasathomako ukuvuma. Nge Big Fish Music ukghonile ukuthi adose phambili abavumi  abafana nabo [[Hlengiwe Mhlaba]], Thobekile Mkhwanazi, Pastor Ncanda,  no Thsepiso Motaung, abanikele isekelo abalitlhogako ukuthi baphumelele emvumeni. Ukuzinikela kwakhe kwavusa ukuthuthukisa ilutjha eMpumalanga wadosa phambili ukuthoma kwekhaya yomvumo wevangeli ebizwa bona yi-Mpumalanga Praise.

== Iinkomba ==
[[Category:Umvumo wevangeli]]
[[Category:Abavumi]]</text>
      <sha1>r6y17t9r07cm9wkrqa42b58ic5zbb6m</sha1>
    </revision>
  </page>
  <page>
    <title>Iinrhurhubi</title>
    <ns>0</ns>
    <id>940</id>
    <revision>
      <id>5716</id>
      <timestamp>2025-09-07T12:25:27Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''Iinrhurhubi''' kumhlobo eminengi ehlukileko yeembandana ekukade ikhona ephasini.&lt;ref&gt;[https://www.britannica.com/animal/reptile Reptile | Definition, Characteristics, Examples, &amp; Facts | Britannica]&lt;/ref&gt; Ziboanakala ngokuthi zinegazi elimakhaza, okutjho bona ukutjhis akomzimba walo kulawula libhoduluko ezikilo. Iinrhurhubi zikghona ukubekela amaqada, zinamaqabunga begodu ziyaphefumula.  === Imihlobo yeenrhurhubi === 1. Iinyoka zona zide begodu azinazo iinyawo, zihlal...&quot;</comment>
      <origin>5716</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3010" sha1="rlnkz267d0bi16dwqo2egh6w2tdt2ty" xml:space="preserve">'''Iinrhurhubi''' kumhlobo eminengi ehlukileko yeembandana ekukade ikhona ephasini.&lt;ref&gt;[https://www.britannica.com/animal/reptile Reptile | Definition, Characteristics, Examples, &amp; Facts | Britannica]&lt;/ref&gt; Ziboanakala ngokuthi zinegazi elimakhaza, okutjho bona ukutjhis akomzimba walo kulawula libhoduluko ezikilo. Iinrhurhubi zikghona ukubekela amaqada, zinamaqabunga begodu ziyaphefumula.

=== Imihlobo yeenrhurhubi ===
1. Iinyoka zona zide begodu azinazo iinyawo, zihlala endaweni ehlukahlukeno njengehlabathini enengi, ehlathini, nofana endaweni ezizele ngamanzi. Zidla inyaa begodu zinekghona lokunukelele elikhethekileko

2. Iimbadwa kusiqhema seenrhurhubi ezingasizikulu ngokomzimba, zinemisila emide begodu zikghona ukuthi zifihle nofana zitjhuguluke umbala wazo lokha nazingaphasi kwebhoduluko elithileko. Iimbadwa zikghona ukuthi zikhulise imisila yazo kabutjha nangabe kheyahlephuka.

3. Amafudu: kuzirhurhubi lezi ezinamaqephe lawa azivikelako emzimbeni bona ungalimali. Zitholakala ebhodulukweni elizele ngamanzi elifana nelwandle, emlanjeni nofana emadamini. Zibuthaka ngokukhamba begodu zikghona ukuphila isikhathi eside

4. Iingwenya kuzimbana ezikulu ezidla inyama ezitholakala endaweni ezitjhisako nezingatjhisi khulu. Zinemihlathi enamandla begodu kuzimbana ezinenturhu ngokuphatha. Imisila yengwenya mide begodu inamandla.Ziceda iskhathi zaso esinengi emanzini kodwana ziyakghona nokuphila ngaphandle kwamanzi bese zothele ilanga.

5. i-alligator- kuzimbandana ezifana neengwenya ngokubukeka kodwna wona atholakala ebhodulukweni elinamanzi akhambako njengemilanjeni. Nawo adla inyama, Anomphimbo obanzi oyindulungu.

=== Amathswayo weenrhurhubi ===

==== Isikhumba esiliqephe nokubeka amaqanda ====
Iirhurhubi zibonakala ngokuthi umzimba yazo ivalwe maqephe ngaphandle. Amaqephe wakhona enziwe nge-Keratin ekuyiphrotheyini le eyenza amazipho neenhluthi zabantu zemvelo. Amaqephela la avikela iinrhurhubi begodu ayazilekela bonyana zingalahlekelwa mamanzi emzimbeni. Iirhurhubi ezinengi zkghon ukubeka amaqanda kodwana kungasi zoke. Amaqanda wakhona aneqephe eliqinilko ngombana livikela  ubungu osakhulako.

=== Ukuphefumula negazi elimakhaza ===
Iirhurhubi ziphefumula ummoya wazi zisebenzisa umaphaphu, begodu zinendlela  ezinengi ezizisebezisako ukuthi zikghone ukuthi zibulunge i-oksijini Kanye nanzi emzimbeni.  Zinegazi elimakhaza okutjo bona zokghona ukulawula ukutjhisa komzimba wazo zibenzisa izinto ezingaphande ebhodulukweni lazo ezifana nelanga, ilitje elibambe umtjhiso. Azikghoni ukukhipha umtjhiso ngaphakathi.

=== Indima edlalwa ziinrhurhubi ebhodulukweni ===
Inrhurhubi zidlala indima eqakathekileko ehlelweni lemveko ngombana zikghona ukuthi zibe ziinyamzana ezidla ezinye nofana zona zibe ziinyamanzana ezidliwako. Ngokubanjalo zikghona ukuthi zilekelele ukuthi inani leendwa lihla linzinzile begodu nemvelo inzinze. Zimthombo wokudla wezinye imbandana nebantwini. Ziqakathekile emasikweni wabantu ngombana zinamathswayo wamandla, nobude besikhathi.

== Iinkomba ==</text>
      <sha1>rlnkz267d0bi16dwqo2egh6w2tdt2ty</sha1>
    </revision>
    <revision>
      <id>5717</id>
      <parentid>5716</parentid>
      <timestamp>2025-09-07T12:42:34Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5717</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3983" sha1="78knpadvl05rpo2gcmkrsdvadwbaj8c" xml:space="preserve">[[Isimumathi:AgamaSinaita01 ST 10.jpg|thumb|Isibhadwa]]
'''Iinrhurhubi''' kumhlobo eminengi ehlukileko yeembandana ekukade ikhona ephasini.&lt;ref&gt;[https://www.britannica.com/animal/reptile Reptile | Definition, Characteristics, Examples, &amp; Facts | Britannica]&lt;/ref&gt; Ziboanakala ngokuthi zinegazi elimakhaza, okutjho bona ukutjhis akomzimba walo kulawula libhoduluko ezikilo. Iinrhurhubi zikghona ukubekela amaqanda, zinamaqabunga begodu ziyaphefumula.

=== Imihlobo yeenrhurhubi ===
1. Iinyoka zona zide begodu azinazo iinyawo, zihlala endaweni ehlukahlukeno njengehlabathini enengi, ehlathini, nofana endaweni ezizele ngamanzi. Zidla inyaa begodu zinekghona lokunukelele elikhethekileko.

2. Iimbadwa kusiqhema seenrhurhubi ezingasizikulu ngokomzimba, zinemisila emide begodu zikghona ukuthi zifihle nofana zitjhuguluke umbala wazo lokha nazingaphasi kwebhoduluko elithileko. Iimbadwa zikghona ukuthi zikhulise imisila yazo kabutjha nangabe kheyahlephuka.&lt;ref&gt;O'Malley, B., 2017. Anatomy and physiology of reptiles. ''Reptile medicine and surgery in clinical practice'', pp.15-32.&lt;/ref&gt;Iimbadwa zinamaqephe aqinileko atjhelelelako nofana arhwarako ukwenzela kuthi zikghone ukuvikeleka ebhodulukweni ezihlala kilo. Zinama zipho eziwasebenzisako ukugubha, ukukakarela ezintweni. Amazipho wazo angaba made, ahlabe,abe dege nofana apatalale ngokuya kwendawo lapho sitholakala khona.

3. Amafudu: kuzirhurhubi lezi ezinamaqephe lawa azivikelako emzimbeni bona ungalimali. Zitholakala ebhodulukweni elizele ngamanzi elifana nelwandle, emlanjeni nofana emadamini. Zibuthaka ngokukhamba begodu zikghona ukuphila isikhathi eside.

4. Iingwenya kuzimbana ezikulu ezidla inyama ezitholakala endaweni ezitjhisako nezingatjhisi khulu. Zinemihlathi enamandla begodu kuzimbana ezinenturhu ngokuphatha. Imisila yengwenya mide begodu inamandla.Ziceda iskhathi zaso esinengi emanzini kodwana ziyakghona nokuphila ngaphandle kwamanzi bese zothele ilanga. I-alligator- kuzimbandana ezifana neengwenya ngokubukeka kodwna wona atholakala ebhodulukweni elinamanzi akhambako njengemilanjeni. Nawo adla inyama, Anomphimbo obanzi oyindulungu.&lt;ref&gt;Vliet, K.A., 2020. ''Alligators: the illustrated guide to their biology, behavior, and conservation''. JHU Press.&lt;/ref&gt;

=== Amathswayo weenrhurhubi ===

==== Isikhumba esiliqephe nokubeka amaqanda ====
Iirhurhubi zibonakala ngokuthi umzimba yazo ivalwe maqephe ngaphandle. Amaqephe wakhona enziwe nge-Keratin ekuyiphrotheyini le eyenza amazipho neenhluthi zabantu zemvelo. Amaqephela la avikela iinrhurhubi begodu ayazilekela bonyana zingalahlekelwa mamanzi emzimbeni. Iirhurhubi ezinengi zkghon ukubeka amaqanda kodwana kungasi zoke. Amaqanda wakhona aneqephe eliqinilko ngombana livikela  umbungu osakhulako.&lt;ref&gt;Blackburn, D.G., 2018. Reproduction in reptiles. ''Encyclopedia of reproduction'', ''6'', pp.573-578.&lt;/ref&gt;

=== Ukuphefumula negazi elimakhaza ===
Iirhurhubi ziphefumula ummoya wazi zisebenzisa umaphaphu, begodu zinendlela  ezinengi ezizisebezisako ukuthi zikghone ukuthi zibulunge i-oksijini Kanye nanzi emzimbeni.  Zinegazi elimakhaza okutjo bona zokghona ukulawula ukutjhisa komzimba wazo zibenzisa izinto ezingaphande ebhodulukweni lazo ezifana nelanga, ilitje elibambe umtjhiso.&lt;ref&gt;[https://royalsocietypublishing.org/doi/full/10.1098/rstb.2024.0129 Cold-blooded culture? Assessing cultural behaviour in reptiles and its potential conservation implications | Philosophical Transactions of the Royal Society B: Biological Sciences]&lt;/ref&gt;Azikghoni ukukhipha umtjhiso ngaphakathi.

=== Indima edlalwa ziinrhurhubi ebhodulukweni ===
Inrhurhubi zidlala indima eqakathekileko ehlelweni lemveko ngombana zikghona ukuthi zibe ziinyamzana ezidla ezinye nofana zona zibe ziinyamanzana ezidliwako. Ngokubanjalo zikghona ukuthi zilekelele ukuthi inani leendwa lihla linzinzile begodu nemvelo inzinze. Zimthombo wokudla wezinye imbandana nebantwini. Ziqakathekile emasikweni wabantu ngombana zinamathswayo wamandla, nobude besikhathi.

== Iinkomba ==</text>
      <sha1>78knpadvl05rpo2gcmkrsdvadwbaj8c</sha1>
    </revision>
    <revision>
      <id>5718</id>
      <parentid>5717</parentid>
      <timestamp>2025-09-07T12:43:34Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5718</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3989" sha1="i020q0frk02q16bdagbzfdg0kmonl23" xml:space="preserve">[[Isimumathi:AgamaSinaita01 ST 10.jpg|thumb|Isibhadwa]]
'''Iinrhurhubi''' kumhlobo eminengi ehlukileko yeembandana ekukade ikhona ephasini.&lt;ref&gt;[https://www.britannica.com/animal/reptile Reptile | Definition, Characteristics, Examples, &amp; Facts | Britannica]&lt;/ref&gt; Ziboanakala ngokuthi zinegazi elimakhaza, okutjho bona ukutjhis akomzimba walo kulawula libhoduluko ezikilo. Iinrhurhubi zikghona ukubekela amaqanda, zinamaqabunga begodu ziyaphefumula.

=== Imihlobo yeenrhurhubi ===
1. Iinyoka zona zide begodu azinazo iinyawo, zihlala endaweni ehlukahlukeno njengehlabathini enengi, ehlathini, nofana endaweni ezizele ngamanzi. Zidla inyaa begodu zinekghona lokunukelele elikhethekileko.

2. Iimbadwa kusiqhema seenrhurhubi ezingasizikulu ngokomzimba, zinemisila emide begodu zikghona ukuthi zifihle nofana zitjhuguluke umbala wazo lokha nazingaphasi kwebhoduluko elithileko. Iimbadwa zikghona ukuthi zikhulise imisila yazo kabutjha nangabe kheyahlephuka.&lt;ref&gt;O'Malley, B., 2017. Anatomy and physiology of reptiles. ''Reptile medicine and surgery in clinical practice'', pp.15-32.&lt;/ref&gt;Iimbadwa zinamaqephe aqinileko atjhelelelako nofana arhwarako ukwenzela kuthi zikghone ukuvikeleka ebhodulukweni ezihlala kilo. Zinama zipho eziwasebenzisako ukugubha, ukukakarela ezintweni. Amazipho wazo angaba made, ahlabe,abe dege nofana apatalale ngokuya kwendawo lapho sitholakala khona.

3. Amafudu: kuzirhurhubi lezi ezinamaqephe lawa azivikelako emzimbeni bona ungalimali. Zitholakala ebhodulukweni elizele ngamanzi elifana nelwandle, emlanjeni nofana emadamini. Zibuthaka ngokukhamba begodu zikghona ukuphila isikhathi eside.

4. Iingwenya kuzimbana ezikulu ezidla inyama ezitholakala endaweni ezitjhisako nezingatjhisi khulu. Zinemihlathi enamandla begodu kuzimbana ezinenturhu ngokuphatha. Imisila yengwenya mide begodu inamandla.Ziceda iskhathi zaso esinengi emanzini kodwana ziyakghona nokuphila ngaphandle kwamanzi bese zothele ilanga. I-alligator- kuzimbandana ezifana neengwenya ngokubukeka kodwna wona atholakala ebhodulukweni elinamanzi akhambako njengemilanjeni. Nawo adla inyama, Anomphimbo obanzi oyindulungu.&lt;ref&gt;Vliet, K.A., 2020. ''Alligators: the illustrated guide to their biology, behavior, and conservation''. JHU Press.&lt;/ref&gt;

=== Amathswayo weenrhurhubi ===

==== Isikhumba esiliqephe nokubeka amaqanda ====
Iirhurhubi zibonakala ngokuthi umzimba yazo ivalwe maqephe ngaphandle. Amaqephe wakhona enziwe nge-Keratin ekuyiphrotheyini le eyenza amazipho neenhluthi zabantu zemvelo. Amaqephela la avikela iinrhurhubi begodu ayazilekela bonyana zingalahlekelwa mamanzi emzimbeni. Iirhurhubi ezinengi zikghona ukubeka [[amaqanda]] kodwana kungasi zoke. Amaqanda wakhona aneqephe eliqinilko ngombana livikela  umbungu osakhulako.&lt;ref&gt;Blackburn, D.G., 2018. Reproduction in reptiles. ''Encyclopedia of reproduction'', ''6'', pp.573-578.&lt;/ref&gt;

=== Ukuphefumula negazi elimakhaza ===
Iirhurhubi ziphefumula ummoya wazi zisebenzisa umaphaphu, begodu zinendlela  ezinengi ezizisebezisako ukuthi zikghone ukuthi zibulunge i-oksijini Kanye nanzi emzimbeni.  Zinegazi elimakhaza okutjo bona zokghona ukulawula ukutjhisa komzimba wazo zibenzisa izinto ezingaphande ebhodulukweni lazo ezifana nelanga, ilitje elibambe umtjhiso.&lt;ref&gt;[https://royalsocietypublishing.org/doi/full/10.1098/rstb.2024.0129 Cold-blooded culture? Assessing cultural behaviour in reptiles and its potential conservation implications | Philosophical Transactions of the Royal Society B: Biological Sciences]&lt;/ref&gt;Azikghoni ukukhipha umtjhiso ngaphakathi.

=== Indima edlalwa ziinrhurhubi ebhodulukweni ===
Inrhurhubi zidlala indima eqakathekileko ehlelweni lemveko ngombana zikghona ukuthi zibe ziinyamzana ezidla ezinye nofana zona zibe ziinyamanzana ezidliwako. Ngokubanjalo zikghona ukuthi zilekelele ukuthi inani leendwa lihla linzinzile begodu nemvelo inzinze. Zimthombo wokudla wezinye imbandana nebantwini. Ziqakathekile emasikweni wabantu ngombana zinamathswayo wamandla, nobude besikhathi.

== Iinkomba ==</text>
      <sha1>i020q0frk02q16bdagbzfdg0kmonl23</sha1>
    </revision>
    <revision>
      <id>5719</id>
      <parentid>5718</parentid>
      <timestamp>2025-09-07T12:45:27Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>5719</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4073" sha1="a2lnzqka0kexe8b6740c25wkt0dyuvz" xml:space="preserve">[[Isimumathi:AgamaSinaita01 ST 10.jpg|thumb|Isibhadwa]]
'''Iinrhurhubi''' kumhlobo eminengi ehlukileko yeembandana ekukade ikhona ephasini.&lt;ref&gt;[https://www.britannica.com/animal/reptile Reptile | Definition, Characteristics, Examples, &amp; Facts | Britannica]&lt;/ref&gt; Ziboanakala ngokuthi zinegazi elimakhaza, okutjho bona ukutjhis akomzimba walo kulawula libhoduluko ezikilo. Iinrhurhubi zikghona ukubekela amaqanda, zinamaqabunga begodu ziyaphefumula.

=== Imihlobo yeenrhurhubi ===
1. Iinyoka zona zide begodu azinazo iinyawo, zihlala endaweni ehlukahlukeno njengehlabathini enengi, ehlathini, nofana endaweni ezizele ngamanzi. Zidla inyaa begodu zinekghona lokunukelele elikhethekileko.

2. Iimbadwa kusiqhema seenrhurhubi ezingasizikulu ngokomzimba, zinemisila emide begodu zikghona ukuthi zifihle nofana zitjhuguluke umbala wazo lokha nazingaphasi kwebhoduluko elithileko. Iimbadwa zikghona ukuthi zikhulise imisila yazo kabutjha nangabe kheyahlephuka.&lt;ref&gt;O'Malley, B., 2017. Anatomy and physiology of reptiles. ''Reptile medicine and surgery in clinical practice'', pp.15-32.&lt;/ref&gt;Iimbadwa zinamaqephe aqinileko atjhelelelako nofana arhwarako ukwenzela kuthi zikghone ukuvikeleka ebhodulukweni ezihlala kilo. Zinama zipho eziwasebenzisako ukugubha, ukukakarela ezintweni. Amazipho wazo angaba made, ahlabe,abe dege nofana apatalale ngokuya kwendawo lapho sitholakala khona.

3. Amafudu: kuzirhurhubi lezi ezinamaqephe lawa azivikelako emzimbeni bona ungalimali. Zitholakala ebhodulukweni elizele ngamanzi elifana nelwandle, emlanjeni nofana emadamini. Zibuthaka ngokukhamba begodu zikghona ukuphila isikhathi eside.

4. Iingwenya kuzimbana ezikulu ezidla inyama ezitholakala endaweni ezitjhisako nezingatjhisi khulu. Zinemihlathi enamandla begodu kuzimbana ezinenturhu ngokuphatha. Imisila yengwenya mide begodu inamandla.Ziceda iskhathi zaso esinengi emanzini kodwana ziyakghona nokuphila ngaphandle kwamanzi bese zothele ilanga. I-alligator- kuzimbandana ezifana neengwenya ngokubukeka kodwna wona atholakala ebhodulukweni elinamanzi akhambako njengemilanjeni. Nawo adla inyama, Anomphimbo obanzi oyindulungu.&lt;ref&gt;Vliet, K.A., 2020. ''Alligators: the illustrated guide to their biology, behavior, and conservation''. JHU Press.&lt;/ref&gt;

=== Amathswayo weenrhurhubi ===

==== Isikhumba esiliqephe nokubeka amaqanda ====
Iirhurhubi zibonakala ngokuthi umzimba yazo ivalwe maqephe ngaphandle. Amaqephe wakhona enziwe nge-Keratin ekuyiphrotheyini le eyenza amazipho neenhluthi zabantu zemvelo. Amaqephela la avikela iinrhurhubi begodu ayazilekela bonyana zingalahlekelwa mamanzi emzimbeni. Iirhurhubi ezinengi zikghona ukubeka [[amaqanda]] kodwana kungasi zoke. Amaqanda wakhona aneqephe eliqinilko ngombana livikela  umbungu osakhulako.&lt;ref&gt;Blackburn, D.G., 2018. Reproduction in reptiles. ''Encyclopedia of reproduction'', ''6'', pp.573-578.&lt;/ref&gt;

=== Ukuphefumula negazi elimakhaza ===
Iirhurhubi ziphefumula ummoya wazi zisebenzisa umaphaphu, begodu zinendlela  ezinengi ezizisebezisako ukuthi zikghone ukuthi zibulunge i-oksijini Kanye nanzi emzimbeni.  Zinegazi elimakhaza okutjo bona zokghona ukulawula ukutjhisa komzimba wazo zibenzisa izinto ezingaphande ebhodulukweni lazo ezifana nelanga, ilitje elibambe umtjhiso.&lt;ref&gt;[https://royalsocietypublishing.org/doi/full/10.1098/rstb.2024.0129 Cold-blooded culture? Assessing cultural behaviour in reptiles and its potential conservation implications | Philosophical Transactions of the Royal Society B: Biological Sciences]&lt;/ref&gt;Azikghoni ukukhipha umtjhiso ngaphakathi.

=== Indima edlalwa ziinrhurhubi ebhodulukweni ===
Inrhurhubi zidlala indima eqakathekileko ehlelweni lemveko ngombana zikghona ukuthi zibe ziinyamzana ezidla ezinye nofana zona zibe ziinyamanzana ezidliwako. Ngokubanjalo zikghona ukuthi zilekelele ukuthi inani leendwa lihla linzinzile begodu nemvelo inzinze. Zimthombo wokudla wezinye imbandana nebantwini. Ziqakathekile emasikweni wabantu ngombana zinamathswayo wamandla, nobude besikhathi.

== Iinkomba ==
[[Category:Iimbadwa]]
[[Category: inrhurhubi]]
[[Category:Iinlwa ezibeka amaqanda]]</text>
      <sha1>a2lnzqka0kexe8b6740c25wkt0dyuvz</sha1>
    </revision>
    <revision>
      <id>5720</id>
      <parentid>5719</parentid>
      <timestamp>2025-09-07T20:04:01Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5720</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4468" sha1="2j74wlg54lr7mhy1gmlxtwrknv0cwci" xml:space="preserve">[[Isimumathi:AgamaSinaita01 ST 10.jpg|thumb|Isibhadwa]]
'''Iinrhurhubi''' kumhlobo eminengi ehlukileko yeembandana ekukade ikhona ephasini.&lt;ref&gt;[https://www.britannica.com/animal/reptile Reptile | Definition, Characteristics, Examples, &amp; Facts | Britannica]&lt;/ref&gt; Zibonakala ngokuthi zinegazi elimakhaza, okutjho bona ukutjhis akomzimba walo kulawula libhoduluko ezikilo. Iinrhurhubi zikghona ukubekela amaqanda, zinamaqabunga begodu ziyaphefumula. Ziphila iskhathi eside, zinemihlathi enamandla, ezinye zinetjhefu, ezinye zinekghona lokutjhukulula umbala njenge  ndlela yokuzifihla nazifika ngaphasi kwebhoduluko elithileko.

=== Imihlobo yeenrhurhubi ===
1. Iinyoka zona zide begodu azinazo iinyawo, zihlala endaweni ehlukahlukeno njengehlabathini enengi, ehlathini, nofana endaweni ezizele ngamanzi. Zidla inyama begodu zinekghona lokunukelele elikhethekileko. Inyoka nakufika ubusika ziyakhamba ziyokubhaca endaweni ezifihlakeleko ngombana azizwani namakhaza. Azinalo ikghono lokukhulisa abantwana bazo, zibeka amaqanda  bese ziwatjhiye lapho, ngaphandle kokuthi ziwa nakekele.

2. Iimbadwa kusiqhema seenrhurhubi ezingasizikulu ngokomzimba, zinemisila emide begodu zikghona ukuthi zifihle nofana zitjhuguluke umbala wazo lokha nazingaphasi kwebhoduluko elithileko. Iimbadwa zikghona ukuthi zikhulise imisila yazo kabutjha nangabe kheyahlephuka.&lt;ref&gt;O'Malley, B., 2017. Anatomy and physiology of reptiles. ''Reptile medicine and surgery in clinical practice'', pp.15-32.&lt;/ref&gt;Iimbadwa zinamaqephe aqinileko atjhelelelako nofana arhwarako ukwenzela kuthi zikghone ukuvikeleka ebhodulukweni ezihlala kilo. Zinama zipho eziwasebenzisako ukugubha, ukukakarela ezintweni. Amazipho wazo angaba made, ahlabe,abe dege nofana apatalale ngokuya kwendawo lapho sitholakala khona.

3. Amafudu: kuzirhurhubi lezi ezinamaqephe lawa azivikelako emzimbeni bona ungalimali. Zitholakala ebhodulukweni elizele ngamanzi elifana nelwandle, emlanjeni nofana emadamini. Zibuthaka ngokukhamba begodu zikghona ukuphila isikhathi eside.

4. Iingwenya kuzimbana ezikulu ezidla inyama ezitholakala endaweni ezitjhisako nezingatjhisi khulu. Zinemihlathi enamandla begodu kuzimbana ezinenturhu ngokuphatha. Imisila yengwenya mide begodu inamandla.Ziceda iskhathi zaso esinengi emanzini kodwana ziyakghona nokuphila ngaphandle kwamanzi bese zothele ilanga. I-alligator- kuzimbandana ezifana neengwenya ngokubukeka kodwna wona atholakala ebhodulukweni elinamanzi akhambako njengemilanjeni. Nawo adla inyama, Anomphimbo obanzi oyindulungu.&lt;ref&gt;Vliet, K.A., 2020. ''Alligators: the illustrated guide to their biology, behavior, and conservation''. JHU Press.&lt;/ref&gt;

=== Amathswayo weenrhurhubi ===

==== Isikhumba esiliqephe nokubeka amaqanda ====
Iirhurhubi zibonakala ngokuthi umzimba yazo ivalwe maqephe ngaphandle. Amaqephe wakhona enziwe nge-Keratin ekuyiphrotheyini le eyenza amazipho neenhluthi zabantu zemvelo. Amaqephela la avikela iinrhurhubi begodu ayazilekela bonyana zingalahlekelwa mamanzi emzimbeni. Iirhurhubi ezinengi zikghona ukubeka [[amaqanda]] kodwana kungasi zoke. Amaqanda wakhona aneqephe eliqinilko ngombana livikela  umbungu osakhulako.&lt;ref&gt;Blackburn, D.G., 2018. Reproduction in reptiles. ''Encyclopedia of reproduction'', ''6'', pp.573-578.&lt;/ref&gt;

=== Ukuphefumula negazi elimakhaza ===
Iirhurhubi ziphefumula ummoya wazi zisebenzisa umaphaphu, begodu zinendlela  ezinengi ezizisebezisako ukuthi zikghone ukuthi zibulunge i-oksijini Kanye nanzi emzimbeni.  Zinegazi elimakhaza okutjo bona zokghona ukulawula ukutjhisa komzimba wazo zibenzisa izinto ezingaphande ebhodulukweni lazo ezifana nelanga, ilitje elibambe umtjhiso.&lt;ref&gt;[https://royalsocietypublishing.org/doi/full/10.1098/rstb.2024.0129 Cold-blooded culture? Assessing cultural behaviour in reptiles and its potential conservation implications | Philosophical Transactions of the Royal Society B: Biological Sciences]&lt;/ref&gt;Azikghoni ukukhipha umtjhiso ngaphakathi.

=== Indima edlalwa ziinrhurhubi ebhodulukweni ===
Inrhurhubi zidlala indima eqakathekileko ehlelweni lemveko ngombana zikghona ukuthi zibe ziinyamzana ezidla ezinye nofana zona zibe ziinyamanzana ezidliwako. Ngokubanjalo zikghona ukuthi zilekelele ukuthi inani leendwa lihla linzinzile begodu nemvelo inzinze. Zimthombo wokudla wezinye imbandana nebantwini. Ziqakathekile emasikweni wabantu ngombana zinamathswayo wamandla, nobude besikhathi.

== Iinkomba ==
[[Category:Iimbadwa]]
[[Category: inrhurhubi]]
[[Category:Iinlwa ezibeka amaqanda]]</text>
      <sha1>2j74wlg54lr7mhy1gmlxtwrknv0cwci</sha1>
    </revision>
    <revision>
      <id>5721</id>
      <parentid>5720</parentid>
      <timestamp>2025-09-07T20:05:50Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5721</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4470" sha1="rhtp07rdop5omc93m2jfgvdrl4j8hrw" xml:space="preserve">[[Isimumathi:AgamaSinaita01 ST 10.jpg|thumb|Isibhadwa]]
'''Iinrhurhubi''' kumhlobo eminengi ehlukileko yeembandana ekukade ikhona ephasini.&lt;ref&gt;[https://www.britannica.com/animal/reptile Reptile | Definition, Characteristics, Examples, &amp; Facts | Britannica]&lt;/ref&gt; Zibonakala ngokuthi zinegazi elimakhaza, okutjho bona ukutjhis akomzimba walo kulawula libhoduluko ezikilo. Iinrhurhubi zikghona ukubekela amaqanda, zinamaqabunga begodu ziyaphefumula. Ziphila iskhathi eside, zinemihlathi enamandla, ezinye zinetjhefu, ezinye zinekghona lokutjhukulula umbala njenge  ndlela yokuzifihla nazifika ngaphasi kwebhoduluko elithileko.

=== Imihlobo yeenrhurhubi ===
1. Iinyoka zona zide begodu azinazo iinyawo, zihlala endaweni ehlukahlukeno njengehlabathini enengi, ehlathini, nofana endaweni ezizele ngamanzi. Zidla inyama begodu zinekghona lokunukelele elikhethekileko. Inyoka nakufika ubusika ziyakhamba ziyokubhaca endaweni ezifihlakeleko ngombana azizwani namakhaza. Azinalo ikghono lokukhulisa abantwana bazo, zibeka amaqanda  bese ziwatjhiye lapho, ngaphandle kokuthi ziwa nakekele.

2. Iimbadwa kusiqhema seenrhurhubi ezingasizikulu ngokomzimba, zinemisila emide begodu zikghona ukuthi zifihle nofana zitjhuguluke umbala wazo lokha nazingaphasi kwebhoduluko elithileko. Iimbadwa zikghona ukuthi zikhulise imisila yazo kabutjha nangabe kheyahlephuka.&lt;ref&gt;O'Malley, B., 2017. Anatomy and physiology of reptiles. ''Reptile medicine and surgery in clinical practice'', pp.15-32.&lt;/ref&gt;Iimbadwa zinamaqephe aqinileko atjhelelelako nofana arhwarako ukwenzela kuthi zikghone ukuvikeleka ebhodulukweni ezihlala kilo. Zinama zipho eziwasebenzisako ukugubha, ukukakarela ezintweni. Amazipho wazo angaba made, ahlabe,abe dege nofana apatalale ngokuya kwendawo lapho sitholakala khona.

3. Amafudu: kuzirhurhubi lezi ezinamaqephe lawa azivikelako emzimbeni bona ungalimali. Zitholakala ebhodulukweni elizele ngamanzi elifana nelwandle, emlanjeni nofana emadamini. Zibuthaka ngokukhamba begodu zikghona ukuphila isikhathi eside.

4. Iingwenya kuzimbana ezikulu ezidla inyama ezitholakala endaweni ezitjhisako nezingatjhisi khulu. Zinemihlathi enamandla begodu kuzimbana ezinenturhu ngokuphatha. Imisila yengwenya mide begodu inamandla.Ziceda iskhathi zaso esinengi emanzini kodwana ziyakghona nokuphila ngaphandle kwamanzi bese zothele ilanga. I-alligator- kuzimbandana ezifana neengwenya ngokubukeka kodwna wona atholakala ebhodulukweni elinamanzi akhambako njengemilanjeni. Nawo adla inyama, Anomphimbo obanzi oyindulungu.&lt;ref&gt;Vliet, K.A., 2020. ''Alligators: the illustrated guide to their biology, behavior, and conservation''. JHU Press.&lt;/ref&gt;

=== Amathswayo weenrhurhubi ===

==== Isikhumba esiliqephe nokubeka amaqanda ====
Iirhurhubi zibonakala ngokuthi umzimba yazo ivalwe maqephe ngaphandle. Amaqephe wakhona enziwe nge-Keratin ekuyiphrotheyini le eyenza amazipho neenhluthi zabantu zemvelo. Amaqephela la avikela iinrhurhubi begodu ayazilekela bonyana zingalahlekelwa mamanzi emzimbeni. Iirhurhubi ezinengi zikghona ukubeka [[amaqanda]] kodwana kungasi zoke. Amaqanda wakhona aneqephe eliqinilko ngombana livikela  umbungu osakhulako.&lt;ref&gt;Blackburn, D.G., 2018. Reproduction in reptiles. ''Encyclopedia of reproduction'', ''6'', pp.573-578.&lt;/ref&gt;

==== Ukuphefumula negazi elimakhaza ====
Iirhurhubi ziphefumula ummoya wazi zisebenzisa umaphaphu, begodu zinendlela  ezinengi ezizisebezisako ukuthi zikghone ukuthi zibulunge i-oksijini Kanye nanzi emzimbeni.  Zinegazi elimakhaza okutjo bona zokghona ukulawula ukutjhisa komzimba wazo zibenzisa izinto ezingaphande ebhodulukweni lazo ezifana nelanga, ilitje elibambe umtjhiso.&lt;ref&gt;[https://royalsocietypublishing.org/doi/full/10.1098/rstb.2024.0129 Cold-blooded culture? Assessing cultural behaviour in reptiles and its potential conservation implications | Philosophical Transactions of the Royal Society B: Biological Sciences]&lt;/ref&gt;Azikghoni ukukhipha umtjhiso ngaphakathi.

=== Indima edlalwa ziinrhurhubi ebhodulukweni ===
Inrhurhubi zidlala indima eqakathekileko ehlelweni lemveko ngombana zikghona ukuthi zibe ziinyamzana ezidla ezinye nofana zona zibe ziinyamanzana ezidliwako. Ngokubanjalo zikghona ukuthi zilekelele ukuthi inani leendwa lihla linzinzile begodu nemvelo inzinze. Zimthombo wokudla wezinye imbandana nebantwini. Ziqakathekile emasikweni wabantu ngombana zinamathswayo wamandla, nobude besikhathi.

== Iinkomba ==
[[Category:Iimbadwa]]
[[Category: inrhurhubi]]
[[Category:Iinlwa ezibeka amaqanda]]</text>
      <sha1>rhtp07rdop5omc93m2jfgvdrl4j8hrw</sha1>
    </revision>
    <revision>
      <id>5792</id>
      <parentid>5721</parentid>
      <timestamp>2025-09-23T18:07:02Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5792</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4682" sha1="fo4ani7dau11nej6t4n1lv5mb9x3ior" xml:space="preserve">[[Isimumathi:AgamaSinaita01 ST 10.jpg|thumb|Isibhadwa]]
'''Iinrhurhubi''' kumhlobo eminengi ehlukileko yeembandana ekukade ikhona ephasini.&lt;ref&gt;[https://www.britannica.com/animal/reptile Reptile | Definition, Characteristics, Examples, &amp; Facts | Britannica]&lt;/ref&gt; Zibonakala ngokuthi zinegazi elimakhaza, okutjho bona ukutjhis akomzimba walo kulawula libhoduluko ezikilo. Iinrhurhubi zikghona ukubekela amaqanda, zinamaqabunga begodu ziyaphefumula. Ziphila iskhathi eside, zinemihlathi enamandla, ezinye zinetjhefu, ezinye zinekghona lokutjhukulula umbala njenge  ndlela yokuzifihla nazifika ngaphasi kwebhoduluko elithileko.

=== Imihlobo yeenrhurhubi ===
1. Iinyoka zona zide begodu azinazo iinyawo, zihlala endaweni ehlukahlukeno njengehlabathini enengi, ehlathini, nofana endaweni ezizele ngamanzi. Zidla inyama begodu zinekghono lokunukelele elikhethekileko. Inyoka nakufika ubusika ziyakhamba ziyokubhaca endaweni ezifihlakeleko ngombana azizwani namakhaza. Azinalo ikghono lokukhulisa abantwana bazo, zibeka amaqanda  bese ziwatjhiye lapho, ngaphandle kokuthi ziwa nakekele. Inyoka ziyahluka ngobungozi, ezinye ziyingozi ngokuthi zikhufula itjhefu engabulala umuntu, ezinye zingozi ngokuthi yakuthola iyakuntantela kabuhlungu ikubulaler ngokukuvala ummoya. Ezinye inyoka azisiyo ingozi.

2. Iimbadwa kusiqhema seenrhurhubi ezingasizikulu ngokomzimba, zinemisila emide begodu zikghona ukuthi zifihle nofana zitjhuguluke umbala wazo lokha nazingaphasi kwebhoduluko elithileko. Iimbadwa zikghona ukuthi zikhulise imisila yazo kabutjha nangabe kheyahlephuka.&lt;ref&gt;O'Malley, B., 2017. Anatomy and physiology of reptiles. ''Reptile medicine and surgery in clinical practice'', pp.15-32.&lt;/ref&gt;Iimbadwa zinamaqephe aqinileko atjhelelelako nofana arhwarako ukwenzela kuthi zikghone ukuvikeleka ebhodulukweni ezihlala kilo. Zinama zipho eziwasebenzisako ukugubha, ukukakarela ezintweni. Amazipho wazo angaba made, ahlabe,abe dege nofana apatalale ngokuya kwendawo lapho sitholakala khona.

3. Amafudu: kuzirhurhubi lezi ezinamaqephe lawa azivikelako emzimbeni bona ungalimali. Zitholakala ebhodulukweni elizele ngamanzi elifana nelwandle, emlanjeni nofana emadamini. Zibuthaka ngokukhamba begodu zikghona ukuphila isikhathi eside.

4. Iingwenya kuzimbana ezikulu ezidla inyama ezitholakala endaweni ezitjhisako nezingatjhisi khulu. Zinemihlathi enamandla begodu kuzimbana ezinenturhu ngokuphatha. Imisila yengwenya mide begodu inamandla.Ziceda iskhathi zaso esinengi emanzini kodwana ziyakghona nokuphila ngaphandle kwamanzi bese zothele ilanga. I-alligator- kuzimbandana ezifana neengwenya ngokubukeka kodwna wona atholakala ebhodulukweni elinamanzi akhambako njengemilanjeni. Nawo adla inyama, Anomphimbo obanzi oyindulungu.&lt;ref&gt;Vliet, K.A., 2020. ''Alligators: the illustrated guide to their biology, behavior, and conservation''. JHU Press.&lt;/ref&gt;

=== Amathswayo weenrhurhubi ===

==== Isikhumba esiliqephe nokubeka amaqanda ====
Iirhurhubi zibonakala ngokuthi umzimba yazo ivalwe maqephe ngaphandle. Amaqephe wakhona enziwe nge-Keratin ekuyiphrotheyini le eyenza amazipho neenhluthi zabantu zemvelo. Amaqephela la avikela iinrhurhubi begodu ayazilekela bonyana zingalahlekelwa mamanzi emzimbeni. Iirhurhubi ezinengi zikghona ukubeka [[amaqanda]] kodwana kungasi zoke. Amaqanda wakhona aneqephe eliqinilko ngombana livikela  umbungu osakhulako.&lt;ref&gt;Blackburn, D.G., 2018. Reproduction in reptiles. ''Encyclopedia of reproduction'', ''6'', pp.573-578.&lt;/ref&gt;

==== Ukuphefumula negazi elimakhaza ====
Iirhurhubi ziphefumula ummoya wazi zisebenzisa umaphaphu, begodu zinendlela  ezinengi ezizisebezisako ukuthi zikghone ukuthi zibulunge i-oksijini Kanye nanzi emzimbeni.  Zinegazi elimakhaza okutjo bona zokghona ukulawula ukutjhisa komzimba wazo zibenzisa izinto ezingaphande ebhodulukweni lazo ezifana nelanga, ilitje elibambe umtjhiso.&lt;ref&gt;[https://royalsocietypublishing.org/doi/full/10.1098/rstb.2024.0129 Cold-blooded culture? Assessing cultural behaviour in reptiles and its potential conservation implications | Philosophical Transactions of the Royal Society B: Biological Sciences]&lt;/ref&gt;Azikghoni ukukhipha umtjhiso ngaphakathi.

=== Indima edlalwa ziinrhurhubi ebhodulukweni ===
Inrhurhubi zidlala indima eqakathekileko ehlelweni lemveko ngombana zikghona ukuthi zibe ziinyamzana ezidla ezinye nofana zona zibe ziinyamanzana ezidliwako. Ngokubanjalo zikghona ukuthi zilekelele ukuthi inani leendwa lihla linzinzile begodu nemvelo inzinze. Zimthombo wokudla wezinye imbandana nebantwini. Ziqakathekile emasikweni wabantu ngombana zinamathswayo wamandla, nobude besikhathi.

== Iinkomba ==
[[Category:Iimbadwa]]
[[Category: inrhurhubi]]
[[Category:Iinlwa ezibeka amaqanda]]</text>
      <sha1>fo4ani7dau11nej6t4n1lv5mb9x3ior</sha1>
    </revision>
    <revision>
      <id>5793</id>
      <parentid>5792</parentid>
      <timestamp>2025-09-23T18:14:38Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5793</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4950" sha1="f5n5pdhsnqvt1dp995s6tvbmew9kplk" xml:space="preserve">[[Isimumathi:AgamaSinaita01 ST 10.jpg|thumb|Isibhadwa]]
'''Iinrhurhubi''' kumhlobo eminengi ehlukileko yeembandana ekukade ikhona ephasini.&lt;ref&gt;[https://www.britannica.com/animal/reptile Reptile | Definition, Characteristics, Examples, &amp; Facts | Britannica]&lt;/ref&gt; Zibonakala ngokuthi zinegazi elimakhaza, okutjho bona ukutjhis akomzimba walo kulawula libhoduluko ezikilo. Iinrhurhubi zikghona ukubekela amaqanda, zinamaqabunga begodu ziyaphefumula. Ziphila iskhathi eside, zinemihlathi enamandla, ezinye zinetjhefu, ezinye zinekghona lokutjhukulula umbala njenge  ndlela yokuzifihla nazifika ngaphasi kwebhoduluko elithileko.

=== Imihlobo yeenrhurhubi ===
1. Iinyoka zona zide begodu azinazo iinyawo, zihlala endaweni ehlukahlukeno njengehlabathini enengi, ehlathini, nofana endaweni ezizele ngamanzi. Zidla inyama begodu zinekghono lokunukelele elikhethekileko. Inyoka nakufika ubusika ziyakhamba ziyokubhaca endaweni ezifihlakeleko ngombana azizwani namakhaza. Azinalo ikghono lokukhulisa abantwana bazo, zibeka amaqanda  bese ziwatjhiye lapho, ngaphandle kokuthi ziwa nakekele. Inyoka ziyahluka ngobungozi, ezinye ziyingozi ngokuthi zikhufula itjhefu engabulala umuntu, ezinye zingozi ngokuthi yakuthola iyakuntantela kabuhlungu ikubulaler ngokukuvala ummoya. Ezinye inyoka azisiyo ingozi.

2. Iimbadwa kusiqhema seenrhurhubi ezingasizikulu ngokomzimba, zinemisila emide begodu zikghona ukuthi zifihle nofana zitjhuguluke umbala wazo lokha nazingaphasi kwebhoduluko elithileko. Iimbadwa zikghona ukuthi zikhulise imisila yazo kabutjha nangabe kheyahlephuka.&lt;ref&gt;O'Malley, B., 2017. Anatomy and physiology of reptiles. ''Reptile medicine and surgery in clinical practice'', pp.15-32.&lt;/ref&gt;Iimbadwa zinamaqephe aqinileko atjhelelelako nofana arhwarako ukwenzela kuthi zikghone ukuvikeleka ebhodulukweni ezihlala kilo. Zinama zipho eziwasebenzisako ukugubha, ukukakarela ezintweni. Amazipho wazo angaba made, ahlabe,abe dege nofana apatalale ngokuya kwendawo lapho sitholakala khona.

3. Amafudu: kuzirhurhubi lezi ezinamaqephe lawa azivikelako emzimbeni bona ungalimali. Zitholakala ebhodulukweni elizele ngamanzi elifana nelwandle, emlanjeni nofana emadamini. Zibuthaka ngokukhamba begodu zikghona ukuphila isikhathi eside. Amanye amafudu adla inyama efana namfesi begodu lawa amanye adla utjani, amanye alde nanoma yini. Iinrhurhubi lezi zikghona ukuphila emabhodulukweni ahlukahlukeneko ngaphandle kokuthikamezeka. Amafudu wemanzini akghona ukukhamba ibanga elide ngaphandle kokudinwa.

4. Iingwenya kuzimbana ezikulu ezidla inyama ezitholakala endaweni ezitjhisako nezingatjhisi khulu. Zinemihlathi enamandla begodu kuzimbana ezinenturhu ngokuphatha. Imisila yengwenya mide begodu inamandla.Ziceda iskhathi zaso esinengi emanzini kodwana ziyakghona nokuphila ngaphandle kwamanzi bese zothele ilanga. ''I-alligator-'' kuzimbandana ezifana neengwenya ngokubukeka kodwna wona atholakala ebhodulukweni elinamanzi akhambako njengemilanjeni. Nawo adla inyama, Anomphimbo obanzi oyindulungu.&lt;ref&gt;Vliet, K.A., 2020. ''Alligators: the illustrated guide to their biology, behavior, and conservation''. JHU Press.&lt;/ref&gt;

=== Amathswayo weenrhurhubi ===

==== Isikhumba esiliqephe nokubeka amaqanda ====
Iirhurhubi zibonakala ngokuthi umzimba yazo ivalwe maqephe ngaphandle. Amaqephe wakhona enziwe nge-Keratin ekuyiphrotheyini le eyenza amazipho neenhluthi zabantu zemvelo. Amaqephela la avikela iinrhurhubi begodu ayazilekela bonyana zingalahlekelwa mamanzi emzimbeni. Iirhurhubi ezinengi zikghona ukubeka [[amaqanda]] kodwana kungasi zoke. Amaqanda wakhona aneqephe eliqinilko ngombana livikela  umbungu osakhulako.&lt;ref&gt;Blackburn, D.G., 2018. Reproduction in reptiles. ''Encyclopedia of reproduction'', ''6'', pp.573-578.&lt;/ref&gt;

==== Ukuphefumula negazi elimakhaza ====
Iirhurhubi ziphefumula ummoya wazi zisebenzisa umaphaphu, begodu zinendlela  ezinengi ezizisebezisako ukuthi zikghone ukuthi zibulunge i-oksijini Kanye nanzi emzimbeni.  Zinegazi elimakhaza okutjo bona zokghona ukulawula ukutjhisa komzimba wazo zibenzisa izinto ezingaphande ebhodulukweni lazo ezifana nelanga, ilitje elibambe umtjhiso.&lt;ref&gt;[https://royalsocietypublishing.org/doi/full/10.1098/rstb.2024.0129 Cold-blooded culture? Assessing cultural behaviour in reptiles and its potential conservation implications | Philosophical Transactions of the Royal Society B: Biological Sciences]&lt;/ref&gt;Azikghoni ukukhipha umtjhiso ngaphakathi.

=== Indima edlalwa ziinrhurhubi ebhodulukweni ===
Inrhurhubi zidlala indima eqakathekileko ehlelweni lemveko ngombana zikghona ukuthi zibe ziinyamzana ezidla ezinye nofana zona zibe ziinyamanzana ezidliwako. Ngokubanjalo zikghona ukuthi zilekelele ukuthi inani leendwa lihla linzinzile begodu nemvelo inzinze. Zimthombo wokudla wezinye imbandana nebantwini. Ziqakathekile emasikweni wabantu ngombana zinamathswayo wamandla, nobude besikhathi.

== Iinkomba ==
[[Category:Iimbadwa]]
[[Category: inrhurhubi]]
[[Category:Iinlwa ezibeka amaqanda]]</text>
      <sha1>f5n5pdhsnqvt1dp995s6tvbmew9kplk</sha1>
    </revision>
    <revision>
      <id>6683</id>
      <parentid>5793</parentid>
      <timestamp>2026-06-09T15:53:06Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <origin>6683</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4946" sha1="qpdlf2jz8ds4bmtf1o0fkiveshy2hsw" xml:space="preserve">[[Isimumathi:AgamaSinaita01 ST 10.jpg|thumb|Isibhadwa]]
'''Iinrhurhubi''' kumhlobo eminengi ehlukileko yeembandana ekukade ikhona ephasini.&lt;ref&gt;[https://www.britannica.com/animal/reptile Reptile | Definition, Characteristics, Examples, &amp; Facts | Britannica]&lt;/ref&gt; Zibonakala ngokuthi zinegazi elimakhaza, okutjho bona ukutjhis akomzimba walo kulawula libhoduluko ezikilo. Iinrhurhubi zikghona ukubekela amaqanda, zinamaqabunga begodu ziyaphefumula. Ziphila iskhathi eside, zinemihlathi enamandla, ezinye zinetjhefu, ezinye zinekghona lokutjhukulula umbala njenge  ndlela yokuzifihla nazifika ngaphasi kwebhoduluko elithileko.

== Imihlobo yeenrhurhubi ==
1. Iinyoka zona zide begodu azinazo iinyawo, zihlala endaweni ehlukahlukeno njengehlabathini enengi, ehlathini, nofana endaweni ezizele ngamanzi. Zidla inyama begodu zinekghono lokunukelele elikhethekileko. Inyoka nakufika ubusika ziyakhamba ziyokubhaca endaweni ezifihlakeleko ngombana azizwani namakhaza. Azinalo ikghono lokukhulisa abantwana bazo, zibeka amaqanda  bese ziwatjhiye lapho, ngaphandle kokuthi ziwa nakekele. Inyoka ziyahluka ngobungozi, ezinye ziyingozi ngokuthi zikhufula itjhefu engabulala umuntu, ezinye zingozi ngokuthi yakuthola iyakuntantela kabuhlungu ikubulaler ngokukuvala ummoya. Ezinye inyoka azisiyo ingozi.

2. Iimbadwa kusiqhema seenrhurhubi ezingasizikulu ngokomzimba, zinemisila emide begodu zikghona ukuthi zifihle nofana zitjhuguluke umbala wazo lokha nazingaphasi kwebhoduluko elithileko. Iimbadwa zikghona ukuthi zikhulise imisila yazo kabutjha nangabe kheyahlephuka.&lt;ref&gt;O'Malley, B., 2017. Anatomy and physiology of reptiles. ''Reptile medicine and surgery in clinical practice'', pp.15-32.&lt;/ref&gt;Iimbadwa zinamaqephe aqinileko atjhelelelako nofana arhwarako ukwenzela kuthi zikghone ukuvikeleka ebhodulukweni ezihlala kilo. Zinama zipho eziwasebenzisako ukugubha, ukukakarela ezintweni. Amazipho wazo angaba made, ahlabe,abe dege nofana apatalale ngokuya kwendawo lapho sitholakala khona.

3. Amafudu: kuzirhurhubi lezi ezinamaqephe lawa azivikelako emzimbeni bona ungalimali. Zitholakala ebhodulukweni elizele ngamanzi elifana nelwandle, emlanjeni nofana emadamini. Zibuthaka ngokukhamba begodu zikghona ukuphila isikhathi eside. Amanye amafudu adla inyama efana namfesi begodu lawa amanye adla utjani, amanye alde nanoma yini. Iinrhurhubi lezi zikghona ukuphila emabhodulukweni ahlukahlukeneko ngaphandle kokuthikamezeka. Amafudu wemanzini akghona ukukhamba ibanga elide ngaphandle kokudinwa.

4. Iingwenya kuzimbana ezikulu ezidla inyama ezitholakala endaweni ezitjhisako nezingatjhisi khulu. Zinemihlathi enamandla begodu kuzimbana ezinenturhu ngokuphatha. Imisila yengwenya mide begodu inamandla.Ziceda iskhathi zaso esinengi emanzini kodwana ziyakghona nokuphila ngaphandle kwamanzi bese zothele ilanga. ''I-alligator-'' kuzimbandana ezifana neengwenya ngokubukeka kodwna wona atholakala ebhodulukweni elinamanzi akhambako njengemilanjeni. Nawo adla inyama, Anomphimbo obanzi oyindulungu.&lt;ref&gt;Vliet, K.A., 2020. ''Alligators: the illustrated guide to their biology, behavior, and conservation''. JHU Press.&lt;/ref&gt;

== Amathswayo weenrhurhubi ==

==== Isikhumba esiliqephe nokubeka amaqanda ====
Iirhurhubi zibonakala ngokuthi umzimba yazo ivalwe maqephe ngaphandle. Amaqephe wakhona enziwe nge-Keratin ekuyiphrotheyini le eyenza amazipho neenhluthi zabantu zemvelo. Amaqephela la avikela iinrhurhubi begodu ayazilekela bonyana zingalahlekelwa mamanzi emzimbeni. Iirhurhubi ezinengi zikghona ukubeka [[amaqanda]] kodwana kungasi zoke. Amaqanda wakhona aneqephe eliqinilko ngombana livikela  umbungu osakhulako.&lt;ref&gt;Blackburn, D.G., 2018. Reproduction in reptiles. ''Encyclopedia of reproduction'', ''6'', pp.573-578.&lt;/ref&gt;

==== Ukuphefumula negazi elimakhaza ====
Iirhurhubi ziphefumula ummoya wazi zisebenzisa umaphaphu, begodu zinendlela  ezinengi ezizisebezisako ukuthi zikghone ukuthi zibulunge i-oksijini Kanye nanzi emzimbeni.  Zinegazi elimakhaza okutjo bona zokghona ukulawula ukutjhisa komzimba wazo zibenzisa izinto ezingaphande ebhodulukweni lazo ezifana nelanga, ilitje elibambe umtjhiso.&lt;ref&gt;[https://royalsocietypublishing.org/doi/full/10.1098/rstb.2024.0129 Cold-blooded culture? Assessing cultural behaviour in reptiles and its potential conservation implications | Philosophical Transactions of the Royal Society B: Biological Sciences]&lt;/ref&gt;Azikghoni ukukhipha umtjhiso ngaphakathi.

=== Indima edlalwa ziinrhurhubi ebhodulukweni ===
Inrhurhubi zidlala indima eqakathekileko ehlelweni lemveko ngombana zikghona ukuthi zibe ziinyamzana ezidla ezinye nofana zona zibe ziinyamanzana ezidliwako. Ngokubanjalo zikghona ukuthi zilekelele ukuthi inani leendwa lihla linzinzile begodu nemvelo inzinze. Zimthombo wokudla wezinye imbandana nebantwini. Ziqakathekile emasikweni wabantu ngombana zinamathswayo wamandla, nobude besikhathi.

== Iinkomba ==
[[Category:Iimbadwa]]
[[Category: inrhurhubi]]
[[Category:Iinlwa ezibeka amaqanda]]</text>
      <sha1>qpdlf2jz8ds4bmtf1o0fkiveshy2hsw</sha1>
    </revision>
  </page>
  <page>
    <title>Rhandza xikolo xa wena</title>
    <ns>0</ns>
    <id>941</id>
    <revision>
      <id>5722</id>
      <timestamp>2025-09-08T15:28:04Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;Rhandza xikolo xa wena kuiykhampheyini eyasungulwa ngokuhlanyela hlangana komnynango wezefundo weMpuamalnga Kanye  nomnyango wezokulima.Ikhampheyini le ihlose kobana ukwakha ububana komphakathi ekutheni ukghone ukuthi u bulunge iinkolo, ikhuthaza nokuthi kuhlale kuhlanziwe eenkolweni, begodu abafundi bafundele lapho kuphephe khona.&lt;ref&gt;dardlea.mpg.gov.za/documents/news/Rhandza_Campaign.pdf&lt;/ref&gt; Khuthanza  amalunga womphakath kobana ukuthi akhombise ukuba banikazi been...&quot;</comment>
      <origin>5722</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2518" sha1="s3q3r1stxur60zsb2twjstoqwshb4s2" xml:space="preserve">Rhandza xikolo xa wena kuiykhampheyini eyasungulwa ngokuhlanyela hlangana komnynango wezefundo weMpuamalnga Kanye  nomnyango wezokulima.Ikhampheyini le ihlose kobana ukwakha ububana komphakathi ekutheni ukghone ukuthi u bulunge iinkolo, ikhuthaza nokuthi kuhlale kuhlanziwe eenkolweni, begodu abafundi bafundele lapho kuphephe khona.&lt;ref&gt;dardlea.mpg.gov.za/documents/news/Rhandza_Campaign.pdf&lt;/ref&gt; Khuthanza  amalunga womphakath kobana ukuthi akhombise ukuba banikazi beenkolo ezisendaweni laphobahlala khona begodu bazibandakanye ekulungiseni esikolo.

Bakhuthaza ukutlhogonyewa kwebhoduluko ngokuthi kutjalwe imithi, kwenziwe iimvande begodu kususwe ukusilaphazeka okungaba khona ebhodulukweni lesikolo. Iletha ukuthi ukuziphedulela  phezulu kwabafundi esikolweni, abotitjhere neemphakathini ngokuphathwa kuhle kwesikolo. Okhunye kukobana ikhandela bona kungabi nokumotjheka kweensetjenziswa zesikolo ngombana kuzokwaziwa bonyana ngezomphakathi.&lt;ref&gt;[https://www.citizen.co.za/mpumalanga-news/news-headlines/local-news/2023/07/31/mpumalanga-department-of-educations-rhandza-xikolo-xa-wena-campaign-activated/ Mpumalanga Department of Education’s Rhandza Xikolo Xa Wena Campaign activated | Mpumalanga News]&lt;/ref&gt;

Izinto ezenziwako

Umphakathi uyahlangana bese kuhlwengisa isikolo. Kungavaswa amafesidere, kuthanyelwe isiskolo nokhunye. Kutjalwa imithi begodu kwenziwe imvande ukuze kuzokuba nomthunzi esikolweni begodu nommoya ungasilaphazeki.Kubuthelwa izinto ezingabuya zisetjenziswe kabutjha ezifana namaphepha amabhodlelo bese athathe yokwenziswa kabutjha. Kulingiswa izinto ezimotjhakeleko.

Umthelela wekhampheyini le

Abafundi bathola ibhoduluko elihle lokufundela lapho bazokufundela khona bathabile begodu kuhlanzekile. Kuba khona ubudlelwane obuhle phakathi komphakathi  nesikolo ngombana umphakathi ufunda ukuthi ukghone ukujamela isikolo lapho abantwana babo baceda khona esikhathi sabo esinengi bazithuthukisa.&lt;ref&gt;[https://www.mpg.gov.za/sites/default/files/resources/Rhandza%20XiKolo%20Xa%20Wena%20Campaign%20Newsletter.pdf Rhandza XiKolo Xa Wena Campaign Newsletter]&lt;/ref&gt; Amalunga wompkhathi athola Ifundiso ngokutlhogomela ibhoduluko lelo abaphila kilo nokuthi bafunde ukuthi ngiziphi izinto ezihle efanele zenziwe ukunakekela ibhoduluko. Abomaspala bendawo eziseduze bakghona ukuthi basekele iinkolo ngokuthi banikele iinkolo izinto abangazi sebenzisa ukuhlwengisa isikolo. Old mutual  ikghona ukuthi inikele ngemali ukuze iinkolo zikhone ukuthenga izinto zokwenza umsebenzi lo eenkolweni</text>
      <sha1>s3q3r1stxur60zsb2twjstoqwshb4s2</sha1>
    </revision>
    <revision>
      <id>5723</id>
      <parentid>5722</parentid>
      <timestamp>2025-09-08T15:29:15Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5723</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2554" sha1="e2fbz5pevw49prgiwhf2tvsokfr47ow" xml:space="preserve">'''Rhandza xikolo xa wena''' kuyikhampheyini eyasungulwa ngokuhlanyela hlangana komnynango wezefundo weMpuamalnga Kanye  nomnyango wezokulima.Ikhampheyini le ihlose kobana ukwakha ububana komphakathi ekutheni ukghone ukuthi u bulunge iinkolo, ikhuthaza nokuthi kuhlale kuhlanziwe eenkolweni, begodu abafundi bafundele lapho kuphephe khona.&lt;ref&gt;dardlea.mpg.gov.za/documents/news/Rhandza_Campaign.pdf&lt;/ref&gt; Khuthanza  amalunga womphakath kobana ukuthi akhombise ukuba banikazi beenkolo ezisendaweni laphobahlala khona begodu bazibandakanye ekulungiseni esikolo.

Bakhuthaza ukutlhogonyewa kwebhoduluko ngokuthi kutjalwe imithi, kwenziwe iimvande begodu kususwe ukusilaphazeka okungaba khona ebhodulukweni lesikolo. Iletha ukuthi ukuziphedulela  phezulu kwabafundi esikolweni, abotitjhere neemphakathini ngokuphathwa kuhle kwesikolo. Okhunye kukobana ikhandela bona kungabi nokumotjheka kweensetjenziswa zesikolo ngombana kuzokwaziwa bonyana ngezomphakathi.&lt;ref&gt;[https://www.citizen.co.za/mpumalanga-news/news-headlines/local-news/2023/07/31/mpumalanga-department-of-educations-rhandza-xikolo-xa-wena-campaign-activated/ Mpumalanga Department of Education’s Rhandza Xikolo Xa Wena Campaign activated | Mpumalanga News]&lt;/ref&gt;

=== Izinto ezenziwako ===
Umphakathi uyahlangana bese kuhlwengisa isikolo. Kungavaswa amafesidere, kuthanyelwe isiskolo nokhunye. Kutjalwa imithi begodu kwenziwe imvande ukuze kuzokuba nomthunzi esikolweni begodu nommoya ungasilaphazeki.Kubuthelwa izinto ezingabuya zisetjenziswe kabutjha ezifana namaphepha amabhodlelo bese athathe yokwenziswa kabutjha. Kulingiswa izinto ezimotjhakeleko.

=== Umthelela wekhampheyini le ===
Abafundi bathola ibhoduluko elihle lokufundela lapho bazokufundela khona bathabile begodu kuhlanzekile. Kuba khona ubudlelwane obuhle phakathi komphakathi  nesikolo ngombana umphakathi ufunda ukuthi ukghone ukujamela isikolo lapho abantwana babo baceda khona esikhathi sabo esinengi bazithuthukisa.&lt;ref&gt;[https://www.mpg.gov.za/sites/default/files/resources/Rhandza%20XiKolo%20Xa%20Wena%20Campaign%20Newsletter.pdf Rhandza XiKolo Xa Wena Campaign Newsletter]&lt;/ref&gt; Amalunga wompkhathi athola Ifundiso ngokutlhogomela ibhoduluko lelo abaphila kilo nokuthi bafunde ukuthi ngiziphi izinto ezihle efanele zenziwe ukunakekela ibhoduluko. Abomaspala bendawo eziseduze bakghona ukuthi basekele iinkolo ngokuthi banikele iinkolo izinto abangazi sebenzisa ukuhlwengisa isikolo. Old mutual  ikghona ukuthi inikele ngemali ukuze iinkolo zikhone ukuthenga izinto zokwenza umsebenzi lo eenkolweni

== Iinkomba ==</text>
      <sha1>e2fbz5pevw49prgiwhf2tvsokfr47ow</sha1>
    </revision>
    <revision>
      <id>5724</id>
      <parentid>5723</parentid>
      <timestamp>2025-09-08T15:30:29Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5724</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2601" sha1="cg23mxqjqrte2to4f1jx68xoldoigob" xml:space="preserve">'''Rhandza xikolo xa wena''' kuyikhampheyini eyasungulwa ngokuhlanyela hlangana komnynango wezefundo weMpuamalnga Kanye  nomnyango wezokulima.Ikhampheyini le ihlose kobana ukwakha ububana komphakathi ekutheni ukghone ukuthi u bulunge iinkolo, ikhuthaza nokuthi kuhlale kuhlanziwe eenkolweni, begodu abafundi bafundele lapho kuphephe khona.&lt;ref&gt;dardlea.mpg.gov.za/documents/news/Rhandza_Campaign.pdf&lt;/ref&gt; Khuthanza  amalunga womphakath kobana ukuthi akhombise ukuba banikazi beenkolo ezisendaweni laphobahlala khona begodu bazibandakanye ekulungiseni esikolo.

Bakhuthaza ukutlhogonyewa kwebhoduluko ngokuthi kutjalwe imithi, kwenziwe iimvande begodu kususwe ukusilaphazeka okungaba khona ebhodulukweni lesikolo. Iletha ukuthi ukuziphedulela  phezulu kwabafundi esikolweni, abotitjhere neemphakathini ngokuphathwa kuhle kwesikolo. Okhunye kukobana ikhandela bona kungabi nokumotjheka kweensetjenziswa zesikolo ngombana kuzokwaziwa bonyana ngezomphakathi.&lt;ref&gt;[https://www.citizen.co.za/mpumalanga-news/news-headlines/local-news/2023/07/31/mpumalanga-department-of-educations-rhandza-xikolo-xa-wena-campaign-activated/ Mpumalanga Department of Education’s Rhandza Xikolo Xa Wena Campaign activated | Mpumalanga News]&lt;/ref&gt;

=== Izinto ezenziwako ===
Umphakathi uyahlangana bese kuhlwengisa isikolo. Kungavaswa amafesidere, kuthanyelwe isiskolo nokhunye. Kutjalwa imithi begodu kwenziwe imvande ukuze kuzokuba nomthunzi esikolweni begodu nommoya ungasilaphazeki.Kubuthelwa izinto ezingabuya zisetjenziswe kabutjha ezifana namaphepha amabhodlelo bese athathe yokwenziswa kabutjha. Kulingiswa izinto ezimotjhakeleko.

=== Umthelela wekhampheyini le ===
Abafundi bathola ibhoduluko elihle lokufundela lapho bazokufundela khona bathabile begodu kuhlanzekile. Kuba khona ubudlelwane obuhle phakathi komphakathi  nesikolo ngombana umphakathi ufunda ukuthi ukghone ukujamela isikolo lapho abantwana babo baceda khona esikhathi sabo esinengi bazithuthukisa.&lt;ref&gt;[https://www.mpg.gov.za/sites/default/files/resources/Rhandza%20XiKolo%20Xa%20Wena%20Campaign%20Newsletter.pdf Rhandza XiKolo Xa Wena Campaign Newsletter]&lt;/ref&gt; Amalunga wompkhathi athola Ifundiso ngokutlhogomela ibhoduluko lelo abaphila kilo nokuthi bafunde ukuthi ngiziphi izinto ezihle efanele zenziwe ukunakekela ibhoduluko. Abomaspala bendawo eziseduze bakghona ukuthi basekele iinkolo ngokuthi banikele iinkolo izinto abangazi sebenzisa ukuhlwengisa isikolo. Old mutual  ikghona ukuthi inikele ngemali ukuze iinkolo zikhone ukuthenga izinto zokwenza umsebenzi lo eenkolweni

== Iinkomba ==
[[Category:Ukuhlwengisa]]
[[Category:Isikolo]]</text>
      <sha1>cg23mxqjqrte2to4f1jx68xoldoigob</sha1>
    </revision>
    <revision>
      <id>5725</id>
      <parentid>5724</parentid>
      <timestamp>2025-09-08T15:37:55Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5725</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2886" sha1="1bgrq00c7yn32k56kvpmfff2hnr9egc" xml:space="preserve">'''Rhandza xikolo xa wena''' kuyikhampheyini eyasungulwa ngokuhlanyela hlangana komnynango wezefundo weMpuamalnga Kanye  nomnyango wezokulima.Ikhampheyini le ihlose kobana ukwakha ububana komphakathi ekutheni ukghone ukuthi u bulunge iinkolo, ikhuthaza nokuthi kuhlale kuhlanziwe eenkolweni, begodu abafundi bafundele lapho kuphephe khona.&lt;ref&gt;dardlea.mpg.gov.za/documents/news/Rhandza_Campaign.pdf&lt;/ref&gt; Khuthanza  amalunga womphakath kobana ukuthi akhombise ukuba banikazi beenkolo ezisendaweni laphobahlala khona begodu bazibandakanye ekulungiseni esikolo.

=== Izinto ezenziwako ===
Bakhuthaza ukutlhogonyelwa kwebhoduluko ngokuthi kutjalwe imithi, kwenziwe iimvande begodu kususwe ukusilaphazeka okungaba khona ebhodulukweni lesikolo. Iletha ukuthi ukuziphedulela  phezulu kwabafundi esikolweni, abotitjhere neemphakathini ngokuphathwa kuhle kwesikolo. Okhunye kukobana ikhandela bona kungabi nokumotjheka kweensetjenziswa zesikolo ngombana kuzokwaziwa bonyana ngezomphakathi.&lt;ref&gt;[https://www.citizen.co.za/mpumalanga-news/news-headlines/local-news/2023/07/31/mpumalanga-department-of-educations-rhandza-xikolo-xa-wena-campaign-activated/ Mpumalanga Department of Education’s Rhandza Xikolo Xa Wena Campaign activated | Mpumalanga News]&lt;/ref&gt; Umphakathi uyahlangana bese kuhlwengiswa isikolo. Kungavaswa amafesidere, kuthanyelwe isiskolo nokhunye.

Kutjalwa imithi begodu kwenziwe imvande ukuze kuzokuba nomthunzi esikolweni begodu nommoya ungasilaphazeki. Kubuthelelwa izinto ezingabuya zisetjenziswe kabutjha ezifana namaphepha amabhodlelo bese athathe yokwenziswa kabutjha. Kulingiswa izinto ezimotjhakeleko. Ihlelo leli likhuthaza umphakathi bonyana ungahlali phasi uthule lokha ubona iinkolo zimotjhakala nofana zingenelwa botsotsi ngombana iinkolo ziyindawo yokuthola ilwazi, ukukhula, nokuthuthukisa umphakathi.Namapholisa amalunga wokuqinisekisa bonyana iinkolo zihlala zivikelekile.

=== Umthelela wekhampheyini le ===
Abafundi bathola ibhoduluko elihle lokufundela lapho bazokufundela khona bathabile begodu kuhlanzekile. Kuba khona ubudlelwane obuhle phakathi komphakathi  nesikolo ngombana umphakathi ufunda ukuthi ukghone ukujamela isikolo lapho abantwana babo baceda khona esikhathi sabo esinengi bazithuthukisa.&lt;ref&gt;[https://www.mpg.gov.za/sites/default/files/resources/Rhandza%20XiKolo%20Xa%20Wena%20Campaign%20Newsletter.pdf Rhandza XiKolo Xa Wena Campaign Newsletter]&lt;/ref&gt; Amalunga wompkhathi athola Ifundiso ngokutlhogomela ibhoduluko lelo abaphila kilo nokuthi bafunde ukuthi ngiziphi izinto ezihle efanele zenziwe ukunakekela ibhoduluko. Abomaspala bendawo eziseduze bakghona ukuthi basekele iinkolo ngokuthi banikele iinkolo izinto abangazi sebenzisa ukuhlwengisa isikolo. Old mutual  ikghona ukuthi inikele ngemali ukuze iinkolo zikhone ukuthenga izinto zokwenza umsebenzi lo eenkolweni

== Iinkomba ==
[[Category:Ukuhlwengisa]]
[[Category:Isikolo]]</text>
      <sha1>1bgrq00c7yn32k56kvpmfff2hnr9egc</sha1>
    </revision>
    <revision>
      <id>5801</id>
      <parentid>5725</parentid>
      <timestamp>2025-09-26T18:08:34Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5801</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2958" sha1="tmj3i71l5r8zyioe15woqgnfo9t9yel" xml:space="preserve">[[Isimumathi:Ukuhlwengisa.jpg|thumb|Abafundi bahlwengisa isikolo sabo]]
'''Rhandza xikolo xa wena''' kuyikhampheyini eyasungulwa ngokuhlanyela hlangana komnynango wezefundo weMpuamalnga Kanye  nomnyango wezokulima.Ikhampheyini le ihlose kobana ukwakha ububana komphakathi ekutheni ukghone ukuthi u bulunge iinkolo, ikhuthaza nokuthi kuhlale kuhlanziwe eenkolweni, begodu abafundi bafundele lapho kuphephe khona.&lt;ref&gt;dardlea.mpg.gov.za/documents/news/Rhandza_Campaign.pdf&lt;/ref&gt; Khuthanza  amalunga womphakath kobana ukuthi akhombise ukuba banikazi beenkolo ezisendaweni laphobahlala khona begodu bazibandakanye ekulungiseni esikolo.

=== Izinto ezenziwako ===
Bakhuthaza ukutlhogonyelwa kwebhoduluko ngokuthi kutjalwe imithi, kwenziwe iimvande begodu kususwe ukusilaphazeka okungaba khona ebhodulukweni lesikolo. Iletha ukuthi ukuziphedulela  phezulu kwabafundi esikolweni, abotitjhere neemphakathini ngokuphathwa kuhle kwesikolo. Okhunye kukobana ikhandela bona kungabi nokumotjheka kweensetjenziswa zesikolo ngombana kuzokwaziwa bonyana ngezomphakathi.&lt;ref&gt;[https://www.citizen.co.za/mpumalanga-news/news-headlines/local-news/2023/07/31/mpumalanga-department-of-educations-rhandza-xikolo-xa-wena-campaign-activated/ Mpumalanga Department of Education’s Rhandza Xikolo Xa Wena Campaign activated | Mpumalanga News]&lt;/ref&gt; Umphakathi uyahlangana bese kuhlwengiswa isikolo. Kungavaswa amafesidere, kuthanyelwe isiskolo nokhunye.

Kutjalwa imithi begodu kwenziwe imvande ukuze kuzokuba nomthunzi esikolweni begodu nommoya ungasilaphazeki. Kubuthelelwa izinto ezingabuya zisetjenziswe kabutjha ezifana namaphepha amabhodlelo bese athathe yokwenziswa kabutjha. Kulingiswa izinto ezimotjhakeleko. Ihlelo leli likhuthaza umphakathi bonyana ungahlali phasi uthule lokha ubona iinkolo zimotjhakala nofana zingenelwa botsotsi ngombana iinkolo ziyindawo yokuthola ilwazi, ukukhula, nokuthuthukisa umphakathi.Namapholisa amalunga wokuqinisekisa bonyana iinkolo zihlala zivikelekile.

=== Umthelela wekhampheyini le ===
Abafundi bathola ibhoduluko elihle lokufundela lapho bazokufundela khona bathabile begodu kuhlanzekile. Kuba khona ubudlelwane obuhle phakathi komphakathi  nesikolo ngombana umphakathi ufunda ukuthi ukghone ukujamela isikolo lapho abantwana babo baceda khona esikhathi sabo esinengi bazithuthukisa.&lt;ref&gt;[https://www.mpg.gov.za/sites/default/files/resources/Rhandza%20XiKolo%20Xa%20Wena%20Campaign%20Newsletter.pdf Rhandza XiKolo Xa Wena Campaign Newsletter]&lt;/ref&gt; Amalunga wompkhathi athola Ifundiso ngokutlhogomela ibhoduluko lelo abaphila kilo nokuthi bafunde ukuthi ngiziphi izinto ezihle efanele zenziwe ukunakekela ibhoduluko. Abomaspala bendawo eziseduze bakghona ukuthi basekele iinkolo ngokuthi banikele iinkolo izinto abangazi sebenzisa ukuhlwengisa isikolo. Old mutual  ikghona ukuthi inikele ngemali ukuze iinkolo zikhone ukuthenga izinto zokwenza umsebenzi lo eenkolweni

== Iinkomba ==
[[Category:Ukuhlwengisa]]
[[Category:Isikolo]]</text>
      <sha1>tmj3i71l5r8zyioe15woqgnfo9t9yel</sha1>
    </revision>
  </page>
  <page>
    <title>Ilanga lamagugu</title>
    <ns>0</ns>
    <id>942</id>
    <revision>
      <id>5726</id>
      <timestamp>2025-09-08T15:45:16Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''Ilanga lamagugu''' eSewula afrika  kulanga eligidingwa cobe nyaka mhlana amalanga ali-24. Ilanga leli liskhumbuzo somlando wombuso wegandelelo, ukuhlukaniswa ngokobuhlanga Kanye nokutlhagela ikululeko. Ilanga leli likhombisa ukubumbana kwesitjhaba likhuthaze amaSewula Afrika bonyana ahlangane begodu agidinge ukuhlukana ngokobuhlanga nangamasiko.&lt;ref&gt;Drummond, J.H., 2024. Contested heritage in South Africa: Perspectives from mahikeng. ''Modern geográfia'', ''19''(2),...&quot;</comment>
      <origin>5726</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2131" sha1="ljvjrximol32bxk1qst7h3ocs7qv6e8" xml:space="preserve">'''Ilanga lamagugu''' eSewula afrika  kulanga eligidingwa cobe nyaka mhlana amalanga ali-24. Ilanga leli liskhumbuzo somlando wombuso wegandelelo, ukuhlukaniswa ngokobuhlanga Kanye nokutlhagela ikululeko. Ilanga leli likhombisa ukubumbana kwesitjhaba likhuthaze amaSewula Afrika bonyana ahlangane begodu agidinge ukuhlukana ngokobuhlanga nangamasiko.&lt;ref&gt;Drummond, J.H., 2024. Contested heritage in South Africa: Perspectives from mahikeng. ''Modern geográfia'', ''19''(2), pp.91-108.&lt;/ref&gt; 

'''Imvelaphi yomlando'''

Ilanga lamagugu livela ku ”Shaka Day” ekwabe kulilanga elabe lenzelwe ukuhlonipha ikosi uShaka Zulu, ekungomunye wabanu abomlando oqakathekileko eSewula Afrika.Ngesibanga sokufuka kwekululeko ngonya we-1994, ilanga leli latjhugulula labizwa bona yilanga lamasiko nofana lamagugu ukuthi kukhuthazwe ukugidingwa kwamasiko wabant boke abshlala eSewula Afrika. Itjhuguluko leli likhombisa ukubumbana kwesitjhaba nokuzikhkhazisa ngabo amasiko akhona enarheni. Kukhunjulwa bekuhlonitjhwe umlando nendabuko yeenqheema zoke zamasiko.

Ukugidinga nemisebenzi eyenziwako

Ilanga leli ligidingwa ngeendlela ezinengi eSewula Afrika. Abanye baligidinga ngokuthi bambathe izembatho ezitjengisa bona bangebaliphi isiko. Abanye bagcoka izembatho zemibala ekhanyoko enaphetheni ahlukileko njenga maNdebele. Nofana bagcoke amatjhika aphilako wesishweshwe. Abane bakghona ukuthi bagidinge ngoku benze umnyanyo wougidinga amamsiko ngokuthi balilise umvumo, badanse, benze ubukghwari nofana benze Ukudla kwesintu lokho kumbumba ukuhlangana komphakathi. Abanye bathanda ukubasa inyama bahlale boke kube nommoya wokuzwana. Eminye imiphakathi iyaphuma ivakatjhele indawo eziphethe umlando wamasiko, ezifana nama myuziyamu ukuthi bakghone ukufunda ngamasiko wabo

'''Ukuqakatheka kwelanga lamagugu'''

Kulilanga elikhuthaza ukubulunga amagugu wamasiko, namalimi kuqinisekiswe bonyana adluliselwa kwezinye inzukulwana ngendlela afaneleko. Inikela amaSewula ithuba lokobana akghone ukufundisana ngomlando wabo, ukuhluka kwamasiko nangokuqakatheka kokubumbana nentando yenengi. Abantu bakghona ukuhloniphana emphakathini abaphila kiwo</text>
      <sha1>ljvjrximol32bxk1qst7h3ocs7qv6e8</sha1>
    </revision>
    <revision>
      <id>5727</id>
      <parentid>5726</parentid>
      <timestamp>2025-09-08T15:48:14Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5727</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2335" sha1="ouhjdo506dl368api0dh0lwckq1braq" xml:space="preserve">'''Ilanga lamagugu''' eSewula afrika  kulanga eligidingwa cobe nyaka mhlana amalanga ali-24. Ilanga leli liskhumbuzo somlando wombuso wegandelelo, ukuhlukaniswa ngokobuhlanga Kanye nokutlhagela ikululeko. Ilanga leli likhombisa ukubumbana kwesitjhaba likhuthaze amaSewula Afrika bonyana ahlangane begodu agidinge ukuhlukana ngokobuhlanga nangamasiko.&lt;ref&gt;Drummond, J.H., 2024. Contested heritage in South Africa: Perspectives from mahikeng. ''Modern geográfia'', ''19''(2), pp.91-108.&lt;/ref&gt; 

'''Imvelaphi yomlando'''

Ilanga lamagugu livela ku ”Shaka Day” ekwabe kulilanga elabe lenzelwe ukuhlonipha ikosi uShaka Zulu, ekungomunye wabanu abomlando oqakathekileko eSewula Afrika.&lt;ref&gt;[https://sahistory.org.za/article/heritage-day-braai-day-or-shaka-day-whose-heritage-it-anyway Heritage day, Braai Day or Shaka Day: Whose Heritage is it Anyway? | South African History Online]&lt;/ref&gt;Ngesibanga sokufuka kwekululeko ngonya we-1994, ilanga leli latjhugulula labizwa bona yilanga lamasiko nofana lamagugu ukuthi kukhuthazwe ukugidingwa kwamasiko wabant boke abshlala eSewula Afrika. Itjhuguluko leli likhombisa ukubumbana kwesitjhaba nokuzikhkhazisa ngabo amasiko akhona enarheni. Kukhunjulwa bekuhlonitjhwe umlando nendabuko yeenqheema zoke zamasiko.

Ukugidinga nemisebenzi eyenziwako

Ilanga leli ligidingwa ngeendlela ezinengi eSewula Afrika. Abanye baligidinga ngokuthi bambathe izembatho ezitjengisa bona bangebaliphi isiko. Abanye bagcoka izembatho zemibala ekhanyoko enaphetheni ahlukileko njenga maNdebele. Nofana bagcoke amatjhika aphilako wesishweshwe. Abane bakghona ukuthi bagidinge ngoku benze umnyanyo wougidinga amamsiko ngokuthi balilise umvumo, badanse, benze ubukghwari nofana benze Ukudla kwesintu lokho kumbumba ukuhlangana komphakathi. Abanye bathanda ukubasa inyama bahlale boke kube nommoya wokuzwana. Eminye imiphakathi iyaphuma ivakatjhele indawo eziphethe umlando wamasiko, ezifana nama myuziyamu ukuthi bakghone ukufunda ngamasiko wabo

'''Ukuqakatheka kwelanga lamagugu'''

Kulilanga elikhuthaza ukubulunga amagugu wamasiko, namalimi kuqinisekiswe bonyana adluliselwa kwezinye inzukulwana ngendlela afaneleko. Inikela amaSewula ithuba lokobana akghone ukufundisana ngomlando wabo, ukuhluka kwamasiko nangokuqakatheka kokubumbana nentando yenengi. Abantu bakghona ukuhloniphana emphakathini abaphila kiwo</text>
      <sha1>ouhjdo506dl368api0dh0lwckq1braq</sha1>
    </revision>
    <revision>
      <id>5728</id>
      <parentid>5727</parentid>
      <timestamp>2025-09-08T15:50:25Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5728</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2372" sha1="5er6v6nr7524cgwl4bobqvge65i1br9" xml:space="preserve">'''Ilanga lamagugu''' eSewula afrika kulilanga eligidingwa cobe nyaka mhlana amalanga ali-24 kuKhukhulamungu. Ilanga leli liskhumbuzo somlando wombuso wegandelelo, ukuhlukaniswa ngokobuhlanga Kanye nokutlhagela ikululeko. Ilanga leli likhombisa ukubumbana kwesitjhaba likhuthaze amaSewula Afrika bonyana ahlangane begodu agidinge ukuhlukana ngokobuhlanga nangamasiko.&lt;ref&gt;Drummond, J.H., 2024. Contested heritage in South Africa: Perspectives from mahikeng. ''Modern geográfia'', ''19''(2), pp.91-108.&lt;/ref&gt; 

'''Imvelaphi yomlando'''

Ilanga lamagugu livela ku ”Shaka Day” ekwabe kulilanga elabe lenzelwe ukuhlonipha ikosi uShaka Zulu, ekungomunye wabanu abomlando oqakathekileko eSewula Afrika.&lt;ref&gt;[https://sahistory.org.za/article/heritage-day-braai-day-or-shaka-day-whose-heritage-it-anyway Heritage day, Braai Day or Shaka Day: Whose Heritage is it Anyway? | South African History Online]&lt;/ref&gt;Ngesibanga sokufika kwekululeko ngonyaka we-1994, ilanga leli latjhugulula labizwa bona yilanga lamasiko nofana lamagugu ukuthi kukhuthazwe ukugidingwa kwamasiko wabantu boke abahlala eSewula Afrika. Itjhuguluko leli likhombisa ukubumbana kwesitjhaba nokuzikhkhazisa ngabo amasiko akhona enarheni. Kukhunjulwa bekuhlonitjhwe umlando nendabuko yeenqheema zoke zamasiko.

Ukugidinga nemisebenzi eyenziwako

Ilanga leli ligidingwa ngeendlela ezinengi eSewula Afrika. Abanye baligidinga ngokuthi bambathe izembatho ezitjengisa bona bangebaliphi isiko. Abanye bagcoka izembatho zemibala ekhanyoko enaphetheni ahlukileko njenga maNdebele. Nofana bagcoke amatjhika aphilako wesishweshwe. Abane bakghona ukuthi bagidinge ngoku benze umnyanyo wougidinga amamsiko ngokuthi balilise umvumo, badanse, benze ubukghwari nofana benze Ukudla kwesintu lokho kumbumba ukuhlangana komphakathi. Abanye bathanda ukubasa inyama bahlale boke kube nommoya wokuzwana. Eminye imiphakathi iyaphuma ivakatjhele indawo eziphethe umlando wamasiko, ezifana nama myuziyamu ukuthi bakghone ukufunda ngamasiko wabo

'''Ukuqakatheka kwelanga lamagugu'''

Kulilanga elikhuthaza ukubulunga amagugu wamasiko, namalimi kuqinisekiswe bonyana adluliselwa kwezinye inzukulwana ngendlela afaneleko. Inikela amaSewula ithuba lokobana akghone ukufundisana ngomlando wabo, ukuhluka kwamasiko nangokuqakatheka kokubumbana nentando yenengi. Abantu bakghona ukuhloniphana emphakathini abaphila kiwo.

== Iinkomba ==</text>
      <sha1>5er6v6nr7524cgwl4bobqvge65i1br9</sha1>
    </revision>
    <revision>
      <id>5753</id>
      <parentid>5728</parentid>
      <timestamp>2025-09-20T15:02:01Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5753</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2465" sha1="0sq4ajci3h87vvq5lujte346naf8v2f" xml:space="preserve">[[Isimumathi:Mapoch.- Femmes Ndebele in Cultural Village (2).jpg|thumb|Abomma bamaNdebele ]]
'''Ilanga lamagugu''' eSewula afrika kulilanga eligidingwa cobe nyaka mhlana amalanga ali-24 kuKhukhulamungu. Ilanga leli liskhumbuzo somlando wombuso wegandelelo, ukuhlukaniswa ngokobuhlanga Kanye nokutlhagela ikululeko. Ilanga leli likhombisa ukubumbana kwesitjhaba likhuthaze amaSewula Afrika bonyana ahlangane begodu agidinge ukuhlukana ngokobuhlanga nangamasiko.&lt;ref&gt;Drummond, J.H., 2024. Contested heritage in South Africa: Perspectives from mahikeng. ''Modern geográfia'', ''19''(2), pp.91-108.&lt;/ref&gt; 

'''Imvelaphi yomlando'''

Ilanga lamagugu livela ku ”Shaka Day” ekwabe kulilanga elabe lenzelwe ukuhlonipha ikosi uShaka Zulu, ekungomunye wabanu abomlando oqakathekileko eSewula Afrika.&lt;ref&gt;[https://sahistory.org.za/article/heritage-day-braai-day-or-shaka-day-whose-heritage-it-anyway Heritage day, Braai Day or Shaka Day: Whose Heritage is it Anyway? | South African History Online]&lt;/ref&gt;Ngesibanga sokufika kwekululeko ngonyaka we-1994, ilanga leli latjhugulula labizwa bona yilanga lamasiko nofana lamagugu ukuthi kukhuthazwe ukugidingwa kwamasiko wabantu boke abahlala eSewula Afrika. Itjhuguluko leli likhombisa ukubumbana kwesitjhaba nokuzikhkhazisa ngabo amasiko akhona enarheni. Kukhunjulwa bekuhlonitjhwe umlando nendabuko yeenqheema zoke zamasiko.

Ukugidinga nemisebenzi eyenziwako

Ilanga leli ligidingwa ngeendlela ezinengi eSewula Afrika. Abanye baligidinga ngokuthi bambathe izembatho ezitjengisa bona bangebaliphi isiko. Abanye bagcoka izembatho zemibala ekhanyoko enaphetheni ahlukileko njenga maNdebele. Nofana bagcoke amatjhika aphilako wesishweshwe. Abane bakghona ukuthi bagidinge ngoku benze umnyanyo wougidinga amamsiko ngokuthi balilise umvumo, badanse, benze ubukghwari nofana benze Ukudla kwesintu lokho kumbumba ukuhlangana komphakathi. Abanye bathanda ukubasa inyama bahlale boke kube nommoya wokuzwana. Eminye imiphakathi iyaphuma ivakatjhele indawo eziphethe umlando wamasiko, ezifana nama myuziyamu ukuthi bakghone ukufunda ngamasiko wabo

'''Ukuqakatheka kwelanga lamagugu'''

Kulilanga elikhuthaza ukubulunga amagugu wamasiko, namalimi kuqinisekiswe bonyana adluliselwa kwezinye inzukulwana ngendlela afaneleko. Inikela amaSewula ithuba lokobana akghone ukufundisana ngomlando wabo, ukuhluka kwamasiko nangokuqakatheka kokubumbana nentando yenengi. Abantu bakghona ukuhloniphana emphakathini abaphila kiwo.

== Iinkomba ==</text>
      <sha1>0sq4ajci3h87vvq5lujte346naf8v2f</sha1>
    </revision>
    <revision>
      <id>5754</id>
      <parentid>5753</parentid>
      <timestamp>2025-09-20T15:03:44Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5754</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2543" sha1="21i9o9d4kvzahfzlz2bfsqkfnbqaoyp" xml:space="preserve">[[Isimumathi:Mapoch.- Femmes Ndebele in Cultural Village (2).jpg|thumb|Abomma bamaNdebele ]]
'''Ilanga lamagugu''' eSewula afrika kulilanga eligidingwa cobe nyaka mhlana amalanga ali-24 kuKhukhulamungu. Ilanga leli liskhumbuzo somlando wombuso wegandelelo, ukuhlukaniswa ngokobuhlanga Kanye nokutlhagela ikululeko. Ilanga leli likhombisa ukubumbana kwesitjhaba likhuthaze amaSewula Afrika bonyana ahlangane begodu agidinge ukuhlukana ngokobuhlanga nangamasiko.&lt;ref&gt;Drummond, J.H., 2024. Contested heritage in South Africa: Perspectives from mahikeng. ''Modern geográfia'', ''19''(2), pp.91-108.&lt;/ref&gt; 

'''Imvelaphi yomlando'''

Ilanga lamagugu livela ku ”Shaka Day” ekwabe kulilanga elabe lenzelwe ukuhlonipha ikosi uShaka Zulu, ekungomunye wabanu abomlando oqakathekileko eSewula Afrika.&lt;ref&gt;[https://sahistory.org.za/article/heritage-day-braai-day-or-shaka-day-whose-heritage-it-anyway Heritage day, Braai Day or Shaka Day: Whose Heritage is it Anyway? | South African History Online]&lt;/ref&gt;Ngesibanga sokufika kwekululeko ngonyaka we-1994, ilanga leli latjhugulula labizwa bona yilanga lamasiko nofana lamagugu ukuthi kukhuthazwe ukugidingwa kwamasiko wabantu boke abahlala eSewula Afrika. Itjhuguluko leli likhombisa ukubumbana kwesitjhaba nokuzikhkhazisa ngabo amasiko akhona enarheni. Kukhunjulwa bekuhlonitjhwe umlando nendabuko yeenqheema zoke zamasiko.

Ukugidinga nemisebenzi eyenziwako

Ilanga leli ligidingwa ngeendlela ezinengi eSewula Afrika. Abanye baligidinga ngokuthi bambathe izembatho ezitjengisa bona bangebaliphi isiko. Abanye bagcoka izembatho zemibala ekhanyoko enaphetheni ahlukileko njenga maNdebele. Nofana bagcoke amatjhika aphilako wesishweshwe. Abane bakghona ukuthi bagidinge ngoku benze umnyanyo wougidinga amamsiko ngokuthi balilise umvumo, badanse, benze ubukghwari nofana benze Ukudla kwesintu lokho kumbumba ukuhlangana komphakathi. Abanye bathanda ukubasa inyama bahlale boke kube nommoya wokuzwana. Eminye imiphakathi iyaphuma ivakatjhele indawo eziphethe umlando wamasiko, ezifana nama myuziyamu ukuthi bakghone ukufunda ngamasiko wabo

'''Ukuqakatheka kwelanga lamagugu'''

Kulilanga elikhuthaza ukubulunga amagugu wamasiko, namalimi kuqinisekiswe bonyana adluliselwa kwezinye inzukulwana ngendlela afaneleko. Inikela amaSewula ithuba lokobana akghone ukufundisana ngomlando wabo, ukuhluka kwamasiko nangokuqakatheka kokubumbana nentando yenengi. Abantu bakghona ukuhloniphana emphakathini abaphila kiwo.

== Iinkomba ==
[[Category: Ukubulungwa kwamagugu]]
[[Category: Isiko]]
[[category: Amasiko]]</text>
      <sha1>21i9o9d4kvzahfzlz2bfsqkfnbqaoyp</sha1>
    </revision>
    <revision>
      <id>5755</id>
      <parentid>5754</parentid>
      <timestamp>2025-09-20T15:06:08Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5755</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2658" sha1="fexme80f8th4k0444fmnvp0trisrg1l" xml:space="preserve">[[Isimumathi:Mapoch.- Femmes Ndebele in Cultural Village (2).jpg|thumb|Abomma bamaNdebele ]]
'''Ilanga lamagugu''' eSewula afrika kulilanga eligidingwa cobe nyaka mhlana amalanga ali-24 kuKhukhulamungu. Ilanga leli liskhumbuzo somlando wombuso wegandelelo, ukuhlukaniswa ngokobuhlanga Kanye nokutlhagela ikululeko. Ilanga leli likhombisa ukubumbana kwesitjhaba likhuthaze amaSewula Afrika bonyana ahlangane begodu agidinge ukuhlukana ngokobuhlanga nangamasiko.&lt;ref&gt;Drummond, J.H., 2024. Contested heritage in South Africa: Perspectives from mahikeng. ''Modern geográfia'', ''19''(2), pp.91-108.&lt;/ref&gt;Nasikhuluma ngamagugu sikhuluma ngamasiko, nomlando odluliselwa ukusuka esizukulwaneni ukuya kwesinye isizukulwane. 

'''Imvelaphi yomlando'''

Ilanga lamagugu livela ku ”Shaka Day” ekwabe kulilanga elabe lenzelwe ukuhlonipha ikosi uShaka Zulu, ekungomunye wabanu abomlando oqakathekileko eSewula Afrika.&lt;ref&gt;[https://sahistory.org.za/article/heritage-day-braai-day-or-shaka-day-whose-heritage-it-anyway Heritage day, Braai Day or Shaka Day: Whose Heritage is it Anyway? | South African History Online]&lt;/ref&gt;Ngesibanga sokufika kwekululeko ngonyaka we-1994, ilanga leli latjhugulula labizwa bona yilanga lamasiko nofana lamagugu ukuthi kukhuthazwe ukugidingwa kwamasiko wabantu boke abahlala eSewula Afrika. Itjhuguluko leli likhombisa ukubumbana kwesitjhaba nokuzikhkhazisa ngabo amasiko akhona enarheni. Kukhunjulwa bekuhlonitjhwe umlando nendabuko yeenqheema zoke zamasiko.

Ukugidinga nemisebenzi eyenziwako

Ilanga leli ligidingwa ngeendlela ezinengi eSewula Afrika. Abanye baligidinga ngokuthi bambathe izembatho ezitjengisa bona bangebaliphi isiko. Abanye bagcoka izembatho zemibala ekhanyoko enaphetheni ahlukileko njenga maNdebele. Nofana bagcoke amatjhika aphilako wesishweshwe. Abane bakghona ukuthi bagidinge ngoku benze umnyanyo wougidinga amamsiko ngokuthi balilise umvumo, badanse, benze ubukghwari nofana benze Ukudla kwesintu lokho kumbumba ukuhlangana komphakathi. Abanye bathanda ukubasa inyama bahlale boke kube nommoya wokuzwana. Eminye imiphakathi iyaphuma ivakatjhele indawo eziphethe umlando wamasiko, ezifana nama myuziyamu ukuthi bakghone ukufunda ngamasiko wabo

'''Ukuqakatheka kwelanga lamagugu'''

Kulilanga elikhuthaza ukubulunga amagugu wamasiko, namalimi kuqinisekiswe bonyana adluliselwa kwezinye inzukulwana ngendlela afaneleko. Inikela amaSewula ithuba lokobana akghone ukufundisana ngomlando wabo, ukuhluka kwamasiko nangokuqakatheka kokubumbana nentando yenengi. Abantu bakghona ukuhloniphana emphakathini abaphila kiwo.

== Iinkomba ==
[[Category: Ukubulungwa kwamagugu]]
[[Category: Isiko]]
[[category: Amasiko]]</text>
      <sha1>fexme80f8th4k0444fmnvp0trisrg1l</sha1>
    </revision>
    <revision>
      <id>5756</id>
      <parentid>5755</parentid>
      <timestamp>2025-09-20T15:07:13Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5756</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2693" sha1="150su134h0jmks7r1035n9dkmm8h1sg" xml:space="preserve">[[Isimumathi:Mapoch.- Femmes Ndebele in Cultural Village (2).jpg|thumb|Abomma bamaNdebele ]]
'''Ilanga lamagugu''' eSewula afrika kulilanga eligidingwa cobe nyaka mhlana amalanga ali-24 kuKhukhulamungu. Ilanga leli liskhumbuzo somlando wombuso wegandelelo, ukuhlukaniswa ngokobuhlanga Kanye nokutlhagela ikululeko. Ilanga leli likhombisa ukubumbana kwesitjhaba likhuthaze amaSewula Afrika bonyana ahlangane begodu agidinge ukuhlukana ngokobuhlanga nangamasiko.&lt;ref&gt;Drummond, J.H., 2024. Contested heritage in South Africa: Perspectives from mahikeng. ''Modern geográfia'', ''19''(2), pp.91-108.&lt;/ref&gt;Nasikhuluma ngamagugu sikhuluma ngamasiko, nomlando odluliselwa ukusuka esizukulwaneni ukuya kwesinye isizukulwane. 

=== '''Imvelaphi yomlando''' ===
Ilanga lamagugu livela ku ”Shaka Day” ekwabe kulilanga elabe lenzelwe ukuhlonipha ikosi uShaka Zulu, ekungomunye wabanu abomlando oqakathekileko eSewula Afrika.&lt;ref&gt;[https://sahistory.org.za/article/heritage-day-braai-day-or-shaka-day-whose-heritage-it-anyway Heritage day, Braai Day or Shaka Day: Whose Heritage is it Anyway? | South African History Online]&lt;/ref&gt;Ngesibanga sokufika kwekululeko ngonyaka we-1994, ilanga leli latjhugulula labizwa bona yilanga lamasiko nofana lamagugu ukuthi kukhuthazwe ukugidingwa kwamasiko wabantu boke abahlala eSewula Afrika. Itjhuguluko leli likhombisa ukubumbana kwesitjhaba nokuzikhkhazisa ngabo amasiko akhona enarheni. Kukhunjulwa bekuhlonitjhwe umlando nendabuko yeenqheema zoke zamasiko.

=== Ukugidinga nemisebenzi eyenziwako ngelanga leli ===
Ilanga leli ligidingwa ngeendlela ezinengi eSewula Afrika. Abanye baligidinga ngokuthi bambathe izembatho ezitjengisa bona bangebaliphi isiko. Abanye bagcoka izembatho zemibala ekhanyoko enaphetheni ahlukileko njenga maNdebele. Nofana bagcoke amatjhika aphilako wesishweshwe. Abane bakghona ukuthi bagidinge ngoku benze umnyanyo wougidinga amamsiko ngokuthi balilise umvumo, badanse, benze ubukghwari nofana benze Ukudla kwesintu lokho kumbumba ukuhlangana komphakathi. Abanye bathanda ukubasa inyama bahlale boke kube nommoya wokuzwana. Eminye imiphakathi iyaphuma ivakatjhele indawo eziphethe umlando wamasiko, ezifana nama myuziyamu ukuthi bakghone ukufunda ngamasiko wabo

=== '''Ukuqakatheka kwelanga lamagugu''' ===
Kulilanga elikhuthaza ukubulunga amagugu wamasiko, namalimi kuqinisekiswe bonyana adluliselwa kwezinye inzukulwana ngendlela afaneleko. Inikela amaSewula ithuba lokobana akghone ukufundisana ngomlando wabo, ukuhluka kwamasiko nangokuqakatheka kokubumbana nentando yenengi. Abantu bakghona ukuhloniphana emphakathini abaphila kiwo.

== Iinkomba ==
[[Category: Ukubulungwa kwamagugu]]
[[Category: Isiko]]
[[category: Amasiko]]</text>
      <sha1>150su134h0jmks7r1035n9dkmm8h1sg</sha1>
    </revision>
    <revision>
      <id>5757</id>
      <parentid>5756</parentid>
      <timestamp>2025-09-20T15:08:38Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5757</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2697" sha1="82152jsv5rosnn8ipuf24kd1t1ron8v" xml:space="preserve">[[Isimumathi:Mapoch.- Femmes Ndebele in Cultural Village (2).jpg|thumb|Abomma bamaNdebele ]]
'''Ilanga lamagugu''' eSewula afrika kulilanga eligidingwa cobe nyaka mhlana amalanga ali-24 kuKhukhulamungu. Ilanga leli liskhumbuzo somlando wombuso wegandelelo, ukuhlukaniswa ngokobuhlanga Kanye nokutlhagela ikululeko. Ilanga leli likhombisa ukubumbana kwesitjhaba likhuthaze amaSewula Afrika bonyana ahlangane begodu agidinge ukuhlukana ngokobuhlanga nang[[amasiko]].&lt;ref&gt;Drummond, J.H., 2024. Contested heritage in South Africa: Perspectives from mahikeng. ''Modern geográfia'', ''19''(2), pp.91-108.&lt;/ref&gt;Nasikhuluma ngamagugu sikhuluma ngamasiko, nomlando odluliselwa ukusuka esizukulwaneni ukuya kwesinye isizukulwane. 

=== '''Imvelaphi yomlando''' ===
Ilanga lamagugu livela ku ”Shaka Day” ekwabe kulilanga elabe lenzelwe ukuhlonipha ikosi uShaka Zulu, ekungomunye wabanu abomlando oqakathekileko eSewula Afrika.&lt;ref&gt;[https://sahistory.org.za/article/heritage-day-braai-day-or-shaka-day-whose-heritage-it-anyway Heritage day, Braai Day or Shaka Day: Whose Heritage is it Anyway? | South African History Online]&lt;/ref&gt;Ngesibanga sokufika kwekululeko ngonyaka we-1994, ilanga leli latjhugulula labizwa bona yilanga lamasiko nofana lamagugu ukuthi kukhuthazwe ukugidingwa kwamasiko wabantu boke abahlala eSewula Afrika. Itjhuguluko leli likhombisa ukubumbana kwesitjhaba nokuzikhkhazisa ngabo amasiko akhona enarheni. Kukhunjulwa bekuhlonitjhwe umlando nendabuko yeenqheema zoke zamasiko.

=== Ukugidinga nemisebenzi eyenziwako ngelanga leli ===
Ilanga leli ligidingwa ngeendlela ezinengi eSewula Afrika. Abanye baligidinga ngokuthi bambathe izembatho ezitjengisa bona bangebaliphi isiko. Abanye bagcoka izembatho zemibala ekhanyoko enaphetheni ahlukileko njenga maNdebele. Nofana bagcoke amatjhika aphilako wesishweshwe. Abane bakghona ukuthi bagidinge ngoku benze umnyanyo wougidinga amamsiko ngokuthi balilise umvumo, badanse, benze ubukghwari nofana benze Ukudla kwesintu lokho kumbumba ukuhlangana komphakathi. Abanye bathanda ukubasa inyama bahlale boke kube nommoya wokuzwana. Eminye imiphakathi iyaphuma ivakatjhele indawo eziphethe umlando wamasiko, ezifana nama myuziyamu ukuthi bakghone ukufunda ngamasiko wabo

=== '''Ukuqakatheka kwelanga lamagugu''' ===
Kulilanga elikhuthaza ukubulunga amagugu wamasiko, namalimi kuqinisekiswe bonyana adluliselwa kwezinye inzukulwana ngendlela afaneleko. Inikela amaSewula ithuba lokobana akghone ukufundisana ngomlando wabo, ukuhluka kwamasiko nangokuqakatheka kokubumbana nentando yenengi. Abantu bakghona ukuhloniphana emphakathini abaphila kiwo.

== Iinkomba ==
[[Category: Ukubulungwa kwamagugu]]
[[Category: Isiko]]
[[category: Amasiko]]</text>
      <sha1>82152jsv5rosnn8ipuf24kd1t1ron8v</sha1>
    </revision>
    <revision>
      <id>5798</id>
      <parentid>5757</parentid>
      <timestamp>2025-09-26T17:58:45Z</timestamp>
      <contributor>
        <username>~2025-26793-08</username>
        <id>970</id>
      </contributor>
      <origin>5798</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2798" sha1="pmbfcs36km4yy6ft05s2alyciitmbk3" xml:space="preserve">[[Isimumathi:Mapoch.- Femmes Ndebele in Cultural Village (2).jpg|thumb|Abomma bamaNdebele ]]
'''Ilanga lamagugu''' eSewula afrika kulilanga eligidingwa cobe nyaka mhlana amalanga ali-24 kuKhukhulamungu. Ilanga leli liskhumbuzo somlando wombuso wegandelelo, ukuhlukaniswa ngokobuhlanga Kanye nokutlhagela ikululeko. Ilanga leli likhombisa ukubumbana kwesitjhaba likhuthaze amaSewula Afrika bonyana ahlangane begodu agidinge ukuhlukana ngokobuhlanga nang[[amasiko]].&lt;ref&gt;Drummond, J.H., 2024. Contested heritage in South Africa: Perspectives from mahikeng. ''Modern geográfia'', ''19''(2), pp.91-108.&lt;/ref&gt;Nasikhuluma ngamagugu sikhuluma ngamasiko, nomlando odluliselwa ukusuka esizukulwaneni ukuya kwesinye isizukulwane. 

=== '''Imvelaphi yomlando''' ===
Ilanga lamagugu livela ku ”Shaka Day” ekwabe kulilanga elabe lenzelwe ukuhlonipha ikosi uShaka Zulu, ekungomunye wabanu abomlando oqakathekileko eSewula Afrika.&lt;ref&gt;[https://sahistory.org.za/article/heritage-day-braai-day-or-shaka-day-whose-heritage-it-anyway Heritage day, Braai Day or Shaka Day: Whose Heritage is it Anyway? | South African History Online]&lt;/ref&gt;Ngesibanga sokufika kwekululeko ngonyaka we-1994, ilanga leli latjhugulula labizwa bona yilanga lamasiko nofana lamagugu ukuthi kukhuthazwe ukugidingwa kwamasiko wabantu boke abahlala eSewula Afrika. Itjhuguluko leli likhombisa ukubumbana kwesitjhaba nokuzikhkhazisa ngabo amasiko akhona enarheni. Kukhunjulwa bekuhlonitjhwe umlando nendabuko yeenqheema zoke zamasiko.

=== Ukugidinga nemisebenzi eyenziwako ngelanga leli ===
[[Isimumathi:Amagugu.jpg|thumb|Abafundi bamabanga aphasi bazokugidinga ilanga lamagugu esikolweni]]
Ilanga leli ligidingwa ngeendlela ezinengi eSewula Afrika. Abanye baligidinga ngokuthi bambathe izembatho ezitjengisa bona bangebaliphi isiko. Abanye bagcoka izembatho zemibala ekhanyoko enaphetheni ahlukileko njenga maNdebele. Nofana bagcoke amatjhika aphilako wesishweshwe. Abane bakghona ukuthi bagidinge ngoku benze umnyanyo wougidinga amamsiko ngokuthi balilise umvumo, badanse, benze ubukghwari nofana benze Ukudla kwesintu lokho kumbumba ukuhlangana komphakathi. Abanye bathanda ukubasa inyama bahlale boke kube nommoya wokuzwana. Eminye imiphakathi iyaphuma ivakatjhele indawo eziphethe umlando wamasiko, ezifana nama myuziyamu ukuthi bakghone ukufunda ngamasiko wabo.

=== '''Ukuqakatheka kwelanga lamagugu''' ===
Kulilanga elikhuthaza ukubulunga amagugu wamasiko, namalimi kuqinisekiswe bonyana adluliselwa kwezinye inzukulwana ngendlela afaneleko. Inikela amaSewula ithuba lokobana akghone ukufundisana ngomlando wabo, ukuhluka kwamasiko nangokuqakatheka kokubumbana nentando yenengi. Abantu bakghona ukuhloniphana emphakathini abaphila kiwo.

== Iinkomba ==
[[Category: Ukubulungwa kwamagugu]]
[[Category: Isiko]]
[[category: Amasiko]]</text>
      <sha1>pmbfcs36km4yy6ft05s2alyciitmbk3</sha1>
    </revision>
    <revision>
      <id>5799</id>
      <parentid>5798</parentid>
      <timestamp>2025-09-26T18:03:07Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5799</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2864" sha1="jvjf4g1cpgyq31ysznp2x6nfl1qwmxv" xml:space="preserve">[[Isimumathi:Mapoch.- Femmes Ndebele in Cultural Village (2).jpg|thumb|Abomma bamaNdebele ]]
'''Ilanga lamagugu''' eSewula afrika kulilanga eligidingwa cobe nyaka mhlana amalanga ali-24 kuKhukhulamungu. Ilanga leli liskhumbuzo somlando wombuso wegandelelo, ukuhlukaniswa ngokobuhlanga Kanye nokutlhagela ikululeko. Ilanga leli likhombisa ukubumbana kwesitjhaba likhuthaze amaSewula Afrika bonyana ahlangane begodu agidinge ukuhlukana ngokobuhlanga nang[[amasiko]].&lt;ref&gt;Drummond, J.H., 2024. Contested heritage in South Africa: Perspectives from mahikeng. ''Modern geográfia'', ''19''(2), pp.91-108.&lt;/ref&gt;Nasikhuluma ngamagugu sikhuluma ngamasiko, nomlando odluliselwa ukusuka esizukulwaneni ukuya kwesinye isizukulwane. 

=== '''Imvelaphi yomlando''' ===
Ilanga lamagugu livela ku ”Shaka Day” ekwabe kulilanga elabe lenzelwe ukuhlonipha ikosi uShaka Zulu, ekungomunye wabanu abomlando oqakathekileko eSewula Afrika.&lt;ref&gt;[https://sahistory.org.za/article/heritage-day-braai-day-or-shaka-day-whose-heritage-it-anyway Heritage day, Braai Day or Shaka Day: Whose Heritage is it Anyway? | South African History Online]&lt;/ref&gt;Ngesibanga sokufika kwekululeko ngonyaka we-1994, ilanga leli latjhugulula labizwa bona yilanga lamasiko nofana lamagugu ukuthi kukhuthazwe ukugidingwa kwamasiko wabantu boke abahlala eSewula Afrika. Itjhuguluko leli likhombisa ukubumbana kwesitjhaba nokuzikhkhazisa ngabo amasiko akhona enarheni. Kukhunjulwa bekuhlonitjhwe umlando nendabuko yeenqheema zoke zamasiko.

=== Ukugidinga nemisebenzi eyenziwako ngelanga leli ===
[[Isimumathi:Amagugu.jpg|thumb|Abafundi bamabanga aphasi bazokugidinga ilanga lamagugu esikolweni]]
Ilanga leli ligidingwa ngeendlela ezinengi eSewula Afrika. Abanye baligidinga ngokuthi bambathe izembatho ezitjengisa bona bangebaliphi isiko. Abanye bagcoka izembatho zemibala ekhanyoko enaphetheni ahlukileko njenga maNdebele. Nofana bagcoke amatjhika aphilako wesishweshwe. Abane bakghona ukuthi bagidinge ngoku benze umnyanyo wougidinga amamsiko ngokuthi balilise umvumo, badanse, benze ubukghwari nofana benze Ukudla kwesintu lokho kumbumba ukuhlangana komphakathi. Abanye bathanda ukubasa inyama bahlale boke kube nommoya wokuzwana. Eminye imiphakathi iyaphuma ivakatjhele indawo eziphethe umlando wamasiko, ezifana nama myuziyamu ukuthi bakghone ukufunda ngamasiko wabo.

=== '''Ukuqakatheka kwelanga lamagugu''' ===
[[Isimumathi:Ukugida.jpg|thumb|Abafundi besikolo bagida isiZulu]]
Kulilanga elikhuthaza ukubulunga amagugu wamasiko, namalimi kuqinisekiswe bonyana adluliselwa kwezinye inzukulwana ngendlela afaneleko. Inikela amaSewula ithuba lokobana akghone ukufundisana ngomlando wabo, ukuhluka kwamasiko nangokuqakatheka kokubumbana nentando yenengi. Abantu bakghona ukuhloniphana emphakathini abaphila kiwo.

== Iinkomba ==
[[Category: Ukubulungwa kwamagugu]]
[[Category: Isiko]]
[[category: Amasiko]]</text>
      <sha1>jvjf4g1cpgyq31ysznp2x6nfl1qwmxv</sha1>
    </revision>
    <revision>
      <id>5800</id>
      <parentid>5799</parentid>
      <timestamp>2025-09-26T18:04:38Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5800</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2866" sha1="ky143m3486mx7b6f7fefuuq750f2n9j" xml:space="preserve">[[Isimumathi:Mapoch.- Femmes Ndebele in Cultural Village (2).jpg|thumb|Abomma bamaNdebele ]]
'''Ilanga lamagugu''' eSewula afrika kulilanga eligidingwa cobe nyaka mhlana amalanga ali-24 kuKhukhulamungu. Ilanga leli lisikhumbuzo somlando wombuso wegandelelo, ukuhlukaniswa ngokobuhlanga Kanye nokutlhagela ikululeko. Ilanga leli likhombisa ukubumbana kwesitjhaba likhuthaze amaSewula Afrika bonyana ahlangane begodu agidinge ukuhlukana ngokobuhlanga nang[[amasiko]].&lt;ref&gt;Drummond, J.H., 2024. Contested heritage in South Africa: Perspectives from mahikeng. ''Modern geográfia'', ''19''(2), pp.91-108.&lt;/ref&gt;Nasikhuluma ngamagugu sikhuluma ngamasiko, nomlando odluliselwa ukusuka esizukulwaneni ukuya kwesinye isizukulwane. 

=== '''Imvelaphi yomlando''' ===
Ilanga lamagugu livela ku ”Shaka Day” ekwabe kulilanga elabe lenzelwe ukuhlonipha ikosi uShaka Zulu, ekungomunye wabantu abomlando oqakathekileko eSewula Afrika.&lt;ref&gt;[https://sahistory.org.za/article/heritage-day-braai-day-or-shaka-day-whose-heritage-it-anyway Heritage day, Braai Day or Shaka Day: Whose Heritage is it Anyway? | South African History Online]&lt;/ref&gt;Ngesibanga sokufika kwekululeko ngonyaka we-1994, ilanga leli latjhugulula labizwa bona yilanga lamasiko nofana lamagugu ukuthi kukhuthazwe ukugidingwa kwamasiko wabantu boke abahlala eSewula Afrika. Itjhuguluko leli likhombisa ukubumbana kwesitjhaba nokuzikhkhazisa ngabo amasiko akhona enarheni. Kukhunjulwa bekuhlonitjhwe umlando nendabuko yeenqheema zoke zamasiko.

=== Ukugidinga nemisebenzi eyenziwako ngelanga leli ===
[[Isimumathi:Amagugu.jpg|thumb|Abafundi bamabanga aphasi bazokugidinga ilanga lamagugu esikolweni]]
Ilanga leli ligidingwa ngeendlela ezinengi eSewula Afrika. Abanye baligidinga ngokuthi bambathe izembatho ezitjengisa bona bangebaliphi isiko. Abanye bagcoka izembatho zemibala ekhanyoko enaphetheni ahlukileko njenga maNdebele. Nofana bagcoke amatjhika aphilako wesishweshwe. Abane bakghona ukuthi bagidinge ngoku benze umnyanyo wougidinga amamsiko ngokuthi balilise umvumo, badanse, benze ubukghwari nofana benze Ukudla kwesintu lokho kumbumba ukuhlangana komphakathi. Abanye bathanda ukubasa inyama bahlale boke kube nommoya wokuzwana. Eminye imiphakathi iyaphuma ivakatjhele indawo eziphethe umlando wamasiko, ezifana nama myuziyamu ukuthi bakghone ukufunda ngamasiko wabo.

=== '''Ukuqakatheka kwelanga lamagugu''' ===
[[Isimumathi:Ukugida.jpg|thumb|Abafundi besikolo bagida isiZulu]]
Kulilanga elikhuthaza ukubulunga amagugu wamasiko, namalimi kuqinisekiswe bonyana adluliselwa kwezinye inzukulwana ngendlela afaneleko. Inikela amaSewula ithuba lokobana akghone ukufundisana ngomlando wabo, ukuhluka kwamasiko nangokuqakatheka kokubumbana nentando yenengi. Abantu bakghona ukuhloniphana emphakathini abaphila kiwo.

== Iinkomba ==
[[Category: Ukubulungwa kwamagugu]]
[[Category: Isiko]]
[[category: Amasiko]]</text>
      <sha1>ky143m3486mx7b6f7fefuuq750f2n9j</sha1>
    </revision>
    <revision>
      <id>5804</id>
      <parentid>5800</parentid>
      <timestamp>2025-09-29T10:03:09Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5804</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2864" sha1="mg5q4560xylw3tant6d032aj6bsxuh0" xml:space="preserve">[[Isimumathi:Mapoch.- Femmes Ndebele in Cultural Village (2).jpg|thumb|Abomma bamaNdebele ]]
'''Ilanga lamagugu''' eSewula afrika kulilanga eligidingwa cobe nyaka mhlana amalanga ali-24 kuKhukhulamungu. Ilanga leli lisikhumbuzo somlando wombuso wegandelelo, ukuhlukaniswa ngokobuhlanga Kanye nokutlhagela ikululeko. Ilanga leli likhombisa ukubumbana kwesitjhaba likhuthaze amaSewula Afrika bonyana ahlangane begodu agidinge ukuhlukana ngokobuhlanga nang[[amasiko]].&lt;ref&gt;Drummond, J.H., 2024. Contested heritage in South Africa: Perspectives from mahikeng. ''Modern geográfia'', ''19''(2), pp.91-108.&lt;/ref&gt;Nasikhuluma ngamagugu sikhuluma ngamasiko, nomlando odluliselwa ukusuka esizukulwaneni ukuya kwesinye isizukulwane. 

=== '''Imvelaphi yomlando''' ===
Ilanga lamagugu livela ku ”Shaka Day” ekwabe kulilanga elabe lenzelwe ukuhlonipha ikosi uShaka Zulu, ekungomunye wabantu abomlando oqakathekileko eSewula Afrika.&lt;ref&gt;[https://sahistory.org.za/article/heritage-day-braai-day-or-shaka-day-whose-heritage-it-anyway Heritage day, Braai Day or Shaka Day: Whose Heritage is it Anyway? | South African History Online]&lt;/ref&gt;Ngesibanga sokufika kwekululeko ngonyaka we-1994, ilanga leli latjhugulula labizwa bona yilanga lamasiko nofana lamagugu ukuthi kukhuthazwe ukugidingwa kwamasiko wabantu boke abahlala eSewula Afrika. Itjhuguluko leli likhombisa ukubumbana kwesitjhaba nokuzikhkhazisa ngabo amasiko akhona enarheni. Kukhunjulwa bekuhlonitjhwe umlando nendabuko yeenqheema zoke zamasiko.

=== Ukugidinga nemisebenzi eyenziwako ngelanga leli ===
[[Isimumathi:Amagugu.jpg|thumb|Abafundi bamabanga aphasi bazokugidinga ilanga lamagugu esikolweni]]
Ilanga leli ligidingwa ngeendlela ezinengi eSewula Afrika. Abanye baligidinga ngokuthi bambathe izembatho ezitjengisa bona bangebaliphi isiko. Abanye bagcoka izembatho zemibala ekhanyoko enaphetheni ahlukileko njenga maNdebele. Nofana bagcoke amatjhika aphilako wesishweshwe. Abane bakghona ukuthi bagidinge ngoku benze umnyanyo wougidinga amamsiko ngokuthi balilise umvumo, badanse, benze ubukghwari nofana benze Ukudla kwesintu lokho kumbumba ukuhlangana komphakathi. Abanye bathanda ukubasa inyama bahlale boke kube nommoya wokuzwana. Eminye imiphakathi iyaphuma ivakatjhele indawo eziphethe umlando wamasiko, ezifana nama myuziyamu ukuthi bakghone ukufunda ngamasiko wabo.

=== '''Ukuqakatheka kwelanga lamagugu''' ===
[[Isimumathi:Ukugida.jpg|thumb|Abafundi besikolo bagida isiZulu]]
Kulilanga elikhuthaza ukubulunga amagugu wamasiko, namalimi kuqinisekiswe bonyana adluliselwa kwezinye inzukulwana ngendlela afaneleko. Inikela amaSewula ithuba lokobana akghone ukufundisana ngomlando wabo, ukuhluka kwamasiko, ukuqakatheka kokubumbana, nentando yenengi. Abantu bakghona ukuhloniphana emphakathini abaphila kiwo.

== Iinkomba ==
[[Category: Ukubulungwa kwamagugu]]
[[Category: Isiko]]
[[category: Amasiko]]</text>
      <sha1>mg5q4560xylw3tant6d032aj6bsxuh0</sha1>
    </revision>
    <revision>
      <id>5843</id>
      <parentid>5804</parentid>
      <timestamp>2025-09-30T07:16:16Z</timestamp>
      <contributor>
        <username>~2025-27165-86</username>
        <id>1036</id>
      </contributor>
      <origin>5843</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2885" sha1="pevan53o8czzxk6wfjmc7kaihfbefe4" xml:space="preserve">[[Isimumathi:Mapoch.- Femmes Ndebele in Cultural Village (2).jpg|thumb|Abomma bamaNdebele ]]
'''Ilanga lamagugu''' eSewula afrika kulilanga eligidingwa cobe nyaka mhlana amalanga ali-24 kuKhukhulamungu. Ilanga leli lisikhumbuzo somlando wombuso wegandelelo, ukuhlukaniswa ngokobuhlanga Kanye nokutlhagela ikululeko. Ilanga leli likhombisa ukubumbana kwesitjhaba likhuthaze amaSewula Afrika bonyana ahlangane begodu agidinge ukuhlukana ngokobuhlanga nang[[amasiko]].&lt;ref&gt;Drummond, J.H., 2024. Contested heritage in South Africa: Perspectives from mahikeng. ''Modern geográfia'', ''19''(2), pp.91-108.&lt;/ref&gt;Nasikhuluma ngamagugu sikhuluma ngamasiko, nomlando odluliselwa ukusuka esizukulwaneni ukuya kwesinye isizukulwane. 

=== '''Imvelaphi yomlando''' ===
Ilanga lamagugu livela ku ”Shaka Day” ekwabe kulilanga elabe lenzelwe ukuhlonipha ikosi uShaka Zulu, ekungomunye wabantu abomlando oqakathekileko eSewula Afrika.&lt;ref&gt;[https://sahistory.org.za/article/heritage-day-braai-day-or-shaka-day-whose-heritage-it-anyway Heritage day, Braai Day or Shaka Day: Whose Heritage is it Anyway? | South African History Online]&lt;/ref&gt;Ngesibanga sokufika kwekululeko ngonyaka we-1994, ilanga leli latjhugulula labizwa bona yilanga lamasiko nofana lamagugu ukuthi kukhuthazwe ukugidingwa kwamasiko wabantu boke abahlala eSewula Afrika. Itjhuguluko leli likhombisa ukubumbana kwesitjhaba nokuzikhkhazisa ngabo amasiko akhona enarheni. Kukhunjulwa bekuhlonitjhwe umlando nendabuko yeenqheema zoke zamasiko.

=== Ukugidinga nemisebenzi eyenziwako ngelanga leli ===
[[Isimumathi:Amagugu.jpg|thumb|Abafundi bamabanga aphasi bazokugidinga ilanga lamagugu esikolweni]]
Ilanga leli ligidingwa ngeendlela ezinengi eSewula Afrika. Abanye baligidinga ngokuthi bambathe izembatho ezitjengisa bona bangebaliphi isiko. Abanye bagcoka izembatho zemibala ekhanyoko enaphetheni ahlukileko njenga maNdebele. Nofana bagcoke amatjhika aphilako wesishweshwe. Abane bakghona ukuthi bagidinge ngoku benze umnyanyo wougidinga amamsiko ngokuthi balilise umvumo, badanse, benze ubukghwari nofana benze Ukudla kwesintu lokho kumbumba ukuhlangana komphakathi. Abanye bathanda ukubasa inyama bahlale boke kube nommoya wokuzwana. Eminye imiphakathi iyaphuma ivakatjhele indawo eziphethe umlando wamasiko, ezifana nama myuziyamu ukuthi bakghone ukufunda ngamasiko wabo.

=== '''Ukuqakatheka kwelanga lamagugu''' ===
[[Isimumathi:Ukugida.jpg|thumb|Abafundi besikolo bagida isiZulu]]
Kulilanga elikhuthaza ukubulunga amagugu wamasiko, namalimi kuqinisekiswe bonyana adluliselwa kwezinye inzukulwana ngendlela afaneleko. Inikela amaSewula ithuba lokobana akghone ukufundisana ngomlando wabo, ukuhluka kwamasiko, ukuqakatheka kokubumbana, nentando yenengi. Abantu bakghona ukuhloniphana emphakathini abaphila kiwo.

== Iinkomba ==
[[Category: Ukubulungwa kwamagugu]]
[[Category: Isiko]]
[[category: Amasiko]]
[[Category:Amagugu]]</text>
      <sha1>pevan53o8czzxk6wfjmc7kaihfbefe4</sha1>
    </revision>
  </page>
  <page>
    <title>Ukusitheka kwenyanga</title>
    <ns>0</ns>
    <id>943</id>
    <revision>
      <id>5729</id>
      <timestamp>2025-09-10T10:29:24Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>ngenze ikhasi elitjha</comment>
      <origin>5729</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4272" sha1="gc6nd51r9p06a4yf8c7q6l22naph9it" xml:space="preserve">== Ukusitheka kwenyanga ==
[[Isimumathi:Blood Moon (103843657).jpeg|thumb|Inyanga yeengazi]]
'''Inyanga''' yeengazi kukhanya okubomvu okukarisako kwenyanga ngesikhathi sokusitheka kwenyanga ngokupheleleko.Kwenzeka lokha isithunzi sephasi simboza inyanga epheleleko,sihlunga ukukhanya kwenyanga emkhathini wethu begodu senza ubuso benyanga bube bomvu khulu nofana bube nzima njengethusi.Ngombana umjikelezo wenyanga utjhinga kancani,iinyanga ezinengi ezizeleko azikhambisani kuhle.Kodwana lokha nazenza njalo,umphumela kuba kusitheka kwenyanga okukarisako.Into ebegade ithabisa ababukeli bezulu amakhulu weminyaka. 

=== Inyanga yeengazi elandelako izakuba nini? ===
Inyanga elandelako yeengazi izokwenzeka mhlazi-7kuKhukhulamungu 2025.Izokubonakala ukusuka ekuthomeni ukuya ekugcineni kiyo yoke i-https://en.wikipedia.org/wiki/Asia ne-https://en.wikipedia.org/wiki/Western_Australia&lt;nowiki/&gt;.Ukubona ezinye iingaba kuzokukghonakala ukusuka e-https://en.wikipedia.org/wiki/Europe&lt;nowiki/&gt;,e-https://en.wiktionary.org/wiki/Afrika&lt;nowiki/&gt;,e-pumalanga ye-https://en.wikipedia.org/wiki/Australia_(continent) ne-https://en.wikipedia.org/wiki/New_Zealand&lt;nowiki/&gt;.Umnyanya lo angeze wabonwa ukusuka e-https://en.wikipedia.org/wiki/United_States.

==== Kubayini kuthiwa inyanga yeengazi? ====
Ibizwa ngokuthi yinyanga yeengazi ngombana ngesikhathi sokusitheka kwenyanga,umkhathi wephasi uhlunga ukukhanya bese uratjha ukukhanya okuluhlazana satjani,kutjhiye inyanga ikhanya obomvu nofana ithusi.

Pheze ama-29% wokusitheka kwenyanga kusitheka kwenyanga ngokupheleleko.Iphasi lihlangabezana nokusitheka kwenyanga okulinganiselwa kabili ngomnyaka.Iindawo ezinengi ephasini zingalindela ukubona ukusitheka kwenyanga okupheleleko kanye ngemva kweminyaka emibili.

===== Kwenzekani ngesikhathi senyanga yeengazi? =====
[[Isimumathi:Blood Moon Graphic.png|thumb|I-graphu ekhombisa bonyana kubayini inyanga yeengazi ibomvu]]
Akusikho koke ukusitheka kwenyanga okwenza inyanga yeengazi.Nangabe iphasi livala ilanga kancani,ingcenye enzima khulu yesithunzi sayo ivala ingcenye yephasi lenyanga okwenza bona kube nokusitheka kwenyanga okunkani.Kubonakala ngasuthi ukulunywa okunzima kukhutjhwe enyangeni.Kwesinye isikhathi inyanga idlula esithunzini sangaphandle esikhanyako esaziwa nge-'''Penumbra''',okwenza bona kube nokusitheka kwelanga okungabonakaliko kangangobana babantu abanolwazi lokuqala umkayi kwaphela ababona ukufiphala okuncani.

Ngesikhathi sokusitheka kwenyanga,inyanga ihlala ngaphakathi kwesithunzi sephasi begodu kulapho umphumela wenyanga yeengazi ovule khona.Ukukhanya kwelanga okudlula emkhathini wephasi kuyahlungwa begodu kusabalale,ukukhanya okuhlaza satjani kuyasuswa kutjhiye amagagasi amade abomvu nawowolintshi ukufikela enyangeni.Lokhu kungumphumela ofanako owenza ukuphuma kwelanga nokutjhinga kwelanga kubonakale kubomvu,begodu kugezisa inyanga ngokukhanya kwethusi.

Umthunzi onqophileko wenyanga yeengazi ungahluka ngokuya ngobujamo bomkhathi.Umlotha we-'''Volcano''',iintuthu womlilo womango,ithuli nofana ukusilaphazeka kungenza bona kubonakale kunzima nofana kuqinile.Ngokuya kwe-'''NASA''' ukusitheka kwenyanga kabili ukuya kane kwenzeka qobe mnyaka,begodu ngalinye lingabonwa pheze engcenyen i yeplanethi.Nanyana amaplanethi neenyanga ehlelweni lelanga zibeka amathunzi,liphasi kwaphela elikhiqiza ukufiphala kwenyanga okuvala inyanga yayo ngokupheleleko.Ukulungiswa kwe-'''cosmic''' okungekhe kwahlala unomphela njengombana inyanga ikhukhuleka kancani kancani ngamasemntimitha ama-4 qobe mnyaka.

====== isiphetho ======
Nanyana kunamaplanethi neenyanga kilo loke ihlelo lelanga,mhlaba kwaphela onetjhudu lokubona ukusitheka kwenyanga ngombana isithunzi sawo sikhulu ngokwaneleko ukuvala inyanga ngokupheleleko.Inyanga isuka kancani kancani eplanethini yethu ngama sentimitha ayi-1.6 nofana amasenthimitha amane ngomnyaka begodu ubujamo lobu angeze buragele phambili unomphela.Ngokuya kwe-'''NASA''' kunokusitheka okulinganiselwa kabili ukuya kane qobe mnyaka,begodu ngamunye ubonakala phezu kwencgenye yephasi.

====== Inkhombo ======
1.https://www.space.com/39471-what-is-a-blood-moon.html
2.https://www.space.com/stargazing/lunar-eclipses/blood-moon-best-photos-total-lunar-eclipse-sept-7-2025
3.https://www.shutterstock.com/search/red-moon-tree</text>
      <sha1>gc6nd51r9p06a4yf8c7q6l22naph9it</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Databox</title>
    <ns>10</ns>
    <id>944</id>
    <revision>
      <id>5731</id>
      <timestamp>2025-09-18T11:12:37Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>Created page with &quot;Lets see&quot;</comment>
      <origin>5731</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8" sha1="tsaojb0ncpwrkimg4hyluig60zl6ln4" xml:space="preserve">Lets see</text>
      <sha1>tsaojb0ncpwrkimg4hyluig60zl6ln4</sha1>
    </revision>
    <revision>
      <id>5736</id>
      <parentid>5731</parentid>
      <timestamp>2025-09-18T11:28:36Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>Blanked the page</comment>
      <origin>5736</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
    <revision>
      <id>5737</id>
      <parentid>5736</parentid>
      <timestamp>2025-09-18T11:31:09Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <origin>5737</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="95" sha1="19tiizsi0ho34pjq4ndav7aqh2fo6j2" xml:space="preserve">&lt;includeonly&gt;{{#invoke:Databoxs|databox}}&lt;/includeonly&gt;&lt;noinclude&gt;{{Documentation}}&lt;/noinclude&gt;</text>
      <sha1>19tiizsi0ho34pjq4ndav7aqh2fo6j2</sha1>
    </revision>
    <revision>
      <id>5738</id>
      <parentid>5737</parentid>
      <timestamp>2025-09-18T11:34:56Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <origin>5738</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="94" sha1="n9iofqc5lssqju7t1pfjiwh2kui7izb" xml:space="preserve">&lt;includeonly&gt;{{#invoke:Databox|databox}}&lt;/includeonly&gt;&lt;noinclude&gt;{{Documentation}}&lt;/noinclude&gt;</text>
      <sha1>n9iofqc5lssqju7t1pfjiwh2kui7izb</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Databox</title>
    <ns>828</ns>
    <id>945</id>
    <revision>
      <id>5732</id>
      <timestamp>2025-09-18T11:17:14Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>Created page with &quot;--this has been adapted from the EN Wikipedia Site.&quot;</comment>
      <origin>5732</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="51" sha1="spq69wojy2wrnjht5a2dcrgx31h0g2a" xml:space="preserve">--this has been adapted from the EN Wikipedia Site.</text>
      <sha1>spq69wojy2wrnjht5a2dcrgx31h0g2a</sha1>
    </revision>
    <revision>
      <id>5733</id>
      <parentid>5732</parentid>
      <timestamp>2025-09-18T11:18:22Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <origin>5733</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="6689" sha1="a8ndgx23p8raindqoqqai83soxr7lc9" xml:space="preserve">-- A more extensive version is stored and documented at the Swedish Wikipedia site, sv.wikipedia.org/wiki/Modul:Databox
-- It is supposed to work for any language.

local property_blacklist = {
    'P360', --is a list of
    'P4224', --category contains
    'P935', -- Commons gallery
    'P1472', -- Commons Creator page
    'P1612', -- Commons Institution page
    'P373', -- Commons category
    'P3722', -- Commons maps category
    'P1151', -- topic's main Wikimedia portal
    'P1424', -- topic's main template
    'P910', -- topic's main category
    'P1200', -- bodies of water basin category
    'P1792', -- category of associated people
    'P1464', -- category for people born here
    'P1465', -- category for people who died here
    'P1791', -- category of people buried here
    'P1740', -- category for films shot at this location
    'P2033', -- Category for pictures taken with camera
    'P2517', -- category for recipients of this award
    'P4195', -- category for employees of the organization
    'P1754', -- category related to list
    'P301', -- category's main topic
    'P971', -- category combines topics
    'P3876', -- category for alumni of educational institution
    'P1753', -- list related to category
    'P3921', -- Wikidata SPARQL query equivalent
    'P1204', -- Wikimedia portal's main topic
    'P1423', -- template's main topic
    'P1709', -- equivalent class
    'P3950', -- narrower external class
    'P2888', -- exact match
    'P1382', -- coincident with
    'P527', -- has part
    'P2670', -- has parts of the class
    'P3113', -- does not have part
    'P2737', -- union of
    'P2738', -- disjoint union of
    'P2445', -- metasubclass of
    'P1963', -- properties for this type
    'P3176', -- uses property
    'P1889', -- different from
    'P460', -- said to be the same as
    'P2959', -- permanent duplicated item
    'P2860', -- cites
    'P5125', -- wikimedia outline
    'P5008', -- on focus list of Wikimedia project
    'P2559', -- Wikidata usage instructions
    'P1343', -- described by source
    'P972', --  catalogu
    'P1282', -- OSM tag or key
    'P4839', -- Wolfram Language entity code
    'P6104', -- Maintained by Wikiproject
    'P5996' -- Category for films in this language
}

function valuesToKeys(array)
	local result = {}
	for _, v in pairs(array) do
		result[v] = true
	end
	return result
end

local p = {}

function p.databox(frame)
    local args = frame:getParent().args
    local itemId = nil
    if args.item then
        itemId = args.item
    end
    local lang = mw.language.getContentLanguage()
    local item = mw.wikibase.getEntity(itemId)
    
    if item == nil then
        mw.addWarning(&quot;Wikidata item not found&quot;)
        return &quot;&quot;
    end
    
    local databoxRoot = mw.html.create('div')
        :addClass('infobox')
        :css({
            float = 'right',
            border = '1px solid #aaa',
            ['max-width'] = '300px',
            padding = '0 0.4em',
            margin = '0 0 0.4em 0.4em',
        })

    --Title
    databoxRoot:tag('div')
        :css({
            ['text-align'] = 'center',
            ['background-color'] = '#f5f5f5',
            padding = '0.5em 0',
            margin = '0.5em 0',
            ['font-size'] = '120%',
            ['font-weight'] = 'bold',
        })
        :wikitext(item:getLabel() or mw.title.getCurrentTitle().text)

     --Image
    local images = item:getBestStatements('P18')
    if #images &gt;= 1 then
        databoxRoot
            :tag('div')
            :wikitext('[[File:' .. images[1].mainsnak.datavalue.value .. '|frameless|300px]]')
    end

    --Table
    local dataTable = databoxRoot
        :tag('table')
        :css({
            ['text-align'] = 'left',
            ['font-size'] = '90%',
            ['word-break'] = 'break-word',
            ['width'] = '100%',
            ['table-layout'] = 'fixed',
        })
    
    dataTable:tag('caption')
             :css({
             	['background-color'] = '#f5f5f5',
             	['font-weight'] = 'bold',
             	['margin-top'] = '0.2em',
             })
    		 :wikitext(item:formatStatements('P31').value)
  
    local properties = mw.wikibase.orderProperties(item:getProperties())
    local property_blacklist_hash = valuesToKeys(property_blacklist)
    property_blacklist_hash['P31'] = true --Special property

	local edit_message = mw.message.new('vector-view-edit'):plain()
    for _, property in pairs(properties) do
        local datatype = item.claims[property][1].mainsnak.datatype
        local valueCount = #item:getBestStatements(property)
        if datatype ~= 'commonsMedia' and datatype ~= 'external-id' and datatype ~= 'quantity' and datatype ~= 'wikibase-property' and datatype ~= 'geo-shape' and datatype ~= 'tabular-data' and not property_blacklist_hash[property] and valueCount &gt; 0 and valueCount &lt;= 5 then
            local propertyValue = item:formatStatements(property)
            dataTable:tag('tr')
                :tag('th')
                    :attr('scope', 'row')
                    :wikitext(lang:ucfirst(propertyValue.label)):done()
                :tag('td')
                    :wikitext(frame:preprocess(propertyValue.value))
                    :wikitext('&amp;nbsp;[[File:OOjs UI icon edit-ltr.svg|' .. edit_message .. '|12px|baseline|class=noviewer|link=https://www.wikidata.org/wiki/' .. item.id .. '#' .. property .. ']]')
        end
    end
     
     --Map
    local coordinates_statements = item:getBestStatements('P625')
    if #coordinates_statements &gt;= 1 and coordinates_statements[1].mainsnak.datavalue and coordinates_statements[1].mainsnak.datavalue.value.globe == 'http://www.wikidata.org/entity/Q2' then
        --We build the call to mapframe
        local latitude = coordinates_statements[1].mainsnak.datavalue.value.latitude
        local longitude = coordinates_statements[1].mainsnak.datavalue.value.longitude
        local geojson = {
            type = 'Feature',
            geometry = {
                type = 'Point',
                coordinates = { longitude, latitude }
            },
            properties = {
                title = item:getLabel() or mw.title.getCurrentTitle().text,
                ['marker-symbol'] = 'marker',
                ['marker-color'] =  '#224422',
            }
        }
        databoxRoot:wikitext(frame:extensionTag('mapframe', mw.text.jsonEncode(geojson), {
            height = 300,
            width = 300,
            frameless = 'frameless',
            align = 'center',
            latitude = latitude,
            longitude = longitude,
            zoom = zoom
        }))
     end
     
     return tostring(databoxRoot)
end

return p</text>
      <sha1>a8ndgx23p8raindqoqqai83soxr7lc9</sha1>
    </revision>
  </page>
  <page>
    <title>Rebecca Malope</title>
    <ns>0</ns>
    <id>946</id>
    <revision>
      <id>5741</id>
      <timestamp>2025-09-20T14:23:34Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''Rebecca Malope''' mvumi enarheni yeSewula Afrika owabelethwa ngenyanga ka Mngwengweni ngonyaka we-1968 endaweni ye Likazi eduze neNelspruit esiphandeni seMpumalanga.&lt;ref&gt;[https://www.rebeccamalope.co.za/rebeccamalope_about.html About REBECCA MALOPE - South African Gospel Music Icon]&lt;/ref&gt; Ikhambo lakhe lathoma yena nodadwabo  bafuna ukuya e-Johannesburg bayokuzuma umsebenzi nethuba lokulandela ithando lokhe lokubamvumi. Ipilo yakhe  yakade ihlangana neentjhijilo ezi...&quot;</comment>
      <origin>5741</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2166" sha1="qk3w0xsrw44xl7jjkdnbgoy6mxxuztq" xml:space="preserve">'''Rebecca Malope''' mvumi enarheni yeSewula Afrika owabelethwa ngenyanga ka Mngwengweni ngonyaka we-1968 endaweni ye Likazi eduze neNelspruit esiphandeni seMpumalanga.&lt;ref&gt;[https://www.rebeccamalope.co.za/rebeccamalope_about.html About REBECCA MALOPE - South African Gospel Music Icon]&lt;/ref&gt; Ikhambo lakhe lathoma yena nodadwabo  bafuna ukuya e-Johannesburg bayokuzuma umsebenzi nethuba lokulandela ithando lokhe lokubamvumi. Ipilo yakhe  yakade ihlangana neentjhijilo ezifaka hlangana nokuthi abodorhodere bakhe bakholwa bona angekhe  asakghona ukukhamba ngesibanga sokugula ekwakhe kwambamba. Nanyana kunjalo kunjalo umndeni wakhe wakholwa bonyana uzokuphila.

Wathola indawo kwezomvumo wathoma ukuvuma esontweni lakhe, lokho kwenza bona akghone ukuba lilunga kekhwaya. Ithalente lakhe lokuvuma lathoma nguSizwe Zakwe owamlekelela ukuthi akghone ukugadangisa umvumo wakhe. Wathoma ukuphumelela ekuvumeni ngonyaka we -1987 lapho athumba khona iphaliswano le”Road shell to fame” ngengoma yakhe eyabe ithi “shine on”. Ukuthumba kwakhe lokho kwamlekelela boynana naye abe ngomunye wabavumi abaziwako enarheni yeSewula Afrika. Uyimile imihlobo eminengi yomvumo kodwana ubonakele bonyana uzinikele ekuvumeni umvumo wevangeli.

U-Rebeca Malope uneminyaka engaphezulukwama-30 emvumeni wevangeli begodu sele akhiphe ama- albhamu angaphezulu kwama-20. I-albhamu yakhe yokuthoma yabe ineshloko esithi “umoya wami” kwalandela I”shwele baba” namanye ama-nalbhamu alandela ngemva kwalawa. Umthelela ka Rebecca Malope wabonakalaekubulungeni amasikweni womvumo weSewula Afrika. Wahlonitjhwa ngeziqu zobudorhedere esikhngweni samaziko aphakemeko Kwazulu Natal ne-Califonia ngesibanga sokwenza umvumo.Phezulu wakhe wathoma ihlelo lakhe kumabona kude elabe labizwa bona yi “its gospel time” elabe lidlala ku SABC 2. Begodu waphinda bawa lijaji  ku “clash of the Choirs South Africa”.ukuvela kwkahe kumabonwa kude kwenza bona akghone ukukhuthaza iinzukulwana ezisakhulako zabavumi bonyana bomvumo wevangeli. U-Rebecca uzakhele igama ngokuthi azimisele ukuthi  amamezele umlayezo wokuletha ithemba  ngomvumo wakhe begodu ama-albhamu wakhe athengwa khuli.</text>
      <sha1>qk3w0xsrw44xl7jjkdnbgoy6mxxuztq</sha1>
    </revision>
    <revision>
      <id>5742</id>
      <parentid>5741</parentid>
      <timestamp>2025-09-20T14:26:24Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5742</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2301" sha1="myuu0atrmjq7h3sp5v1m6tqztwo8vfr" xml:space="preserve">'''Rebecca Malope''' mvumi enarheni yeSewula Afrika owabelethwa ngenyanga ka Mngwengweni ngonyaka we-1968 endaweni ye Likazi eduze neNelspruit esiphandeni seMpumalanga.&lt;ref&gt;[https://www.rebeccamalope.co.za/rebeccamalope_about.html About REBECCA MALOPE - South African Gospel Music Icon]&lt;/ref&gt; Ikhambo lakhe lathoma yena nodadwabo  bafuna ukuya e-Johannesburg bayokuzuma umsebenzi nethuba lokulandela ithando lokhe lokubamvumi. Ipilo yakhe yakade ihlangana neentjhijilo ezifaka hlangana nokuthi abodorhodere bakhe bakholwa bona angekhe  asakghona ukukhamba ngesibanga sokugula ekwakhe kwambamba. Nanyana kunjalo kunjalo umndeni wakhe wakholwa bonyana uzokuphila.

Wathola indawo kwezomvumo wathoma ukuvuma esontweni lakhe, lokho kwenza bona akghone ukuba lilunga kekhwaya. Ithalente lakhe lokuvuma lathoma nguSizwe Zakwe owamlekelela ukuthi akghone ukugadangisa umvumo wakhe. Wathoma ukuphumelela ekuvumeni ngonyaka we -1987 lapho athumba khona iphaliswano le ”Road shell to fame” ngengoma yakhe eyabe ithi “shine on”. Ukuthumba kwakhe lokho kwamlekelela boynana naye abe ngomunye wabavumi abaziwako enarheni yeSewula Afrika. Uyimile imihlobo eminengi yomvumo kodwana ubonakele bonyana uzinikele ekuvumeni umvumo wevangeli.

U-Rebeca Malope uneminyaka engaphezulukwama-30 emvumeni wevangeli begodu sele akhiphe ama- albhamu angaphezulu kwama-20. I-albhamu yakhe yokuthoma yabe ineshloko esithi “umoya wami” kwalandela I”shwele baba” namanye ama-nalbhamu alandela ngemva kwalawa. Umthelela ka Rebecca Malope wabonakala ekubulungeni amasikweni womvumo weSewula Afrika. Wahlonitjhwa ngeziqu zobudorhedere esikhngweni samaziko aphakemeko Kwazulu Natal ne-Califonia ngesibanga sokwenza umvumo. Phezulu wakhe wathoma ihlelo lakhe kumabona kude elabe labizwa bona yi “its gospel time” elabe lidlala ku SABC 2.&lt;ref&gt;[https://www.tvsa.co.za/shows/viewshowseasons.aspx?showId=2776&amp;season=2 It's Gospel Time | Season 2 | TVSA]&lt;/ref&gt; Begodu waphinda bawa lijaji  ku “clash of the Choirs South Africa” .ukuvela kwkahe kumabonwa kude kwenza bona akghone ukukhuthaza iinzukulwana ezisakhulako zabavumi bonyana bomvumo wevangeli. U-Rebecca uzakhele igama ngokuthi azimisele ukuthi amamezele umlayezo wokuletha ithemba ngomvumo wakhe begodu ama-albhamu wakhe athengwa khuli.

== Iinkomba ==</text>
      <sha1>myuu0atrmjq7h3sp5v1m6tqztwo8vfr</sha1>
    </revision>
    <revision>
      <id>5743</id>
      <parentid>5742</parentid>
      <timestamp>2025-09-20T14:28:06Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5743</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2367" sha1="2zmdp770ucvu5ic9xif5ic7hz17o3x1" xml:space="preserve">'''Rebecca Malope''' mvumi enarheni yeSewula Afrika owabelethwa ngenyanga ka Mngwengweni ngonyaka we-1968 endaweni ye Likazi eduze neNelspruit esiphandeni seMpumalanga.&lt;ref&gt;[https://www.rebeccamalope.co.za/rebeccamalope_about.html About REBECCA MALOPE - South African Gospel Music Icon]&lt;/ref&gt; Ikhambo lakhe lathoma yena nodadwabo  bafuna ukuya e-Johannesburg bayokuzuma umsebenzi nethuba lokulandela ithando lokhe lokubamvumi. Ipilo yakhe yakade ihlangana neentjhijilo ezifaka hlangana nokuthi abodorhodere bakhe bakholwa bona angekhe  asakghona ukukhamba ngesibanga sokugula ekwakhe kwambamba. Nanyana kunjalo kunjalo umndeni wakhe wakholwa bonyana uzokuphila.

Wathola indawo kwezomvumo wathoma ukuvuma esontweni lakhe, lokho kwenza bona akghone ukuba lilunga kekhwaya. Ithalente lakhe lokuvuma lathoma nguSizwe Zakwe owamlekelela ukuthi akghone ukugadangisa umvumo wakhe. Wathoma ukuphumelela ekuvumeni ngonyaka we -1987 lapho athumba khona iphaliswano le ”Road shell to fame” ngengoma yakhe eyabe ithi “shine on”. Ukuthumba kwakhe lokho kwamlekelela boynana naye abe ngomunye wabavumi abaziwako enarheni yeSewula Afrika. Uyimile imihlobo eminengi yomvumo kodwana ubonakele bonyana uzinikele ekuvumeni umvumo wevangeli.

U-Rebeca Malope uneminyaka engaphezulukwama-30 emvumeni wevangeli begodu sele akhiphe ama- albhamu angaphezulu kwama-20. I-albhamu yakhe yokuthoma yabe ineshloko esithi “umoya wami” kwalandela I”shwele baba” namanye ama-nalbhamu alandela ngemva kwalawa. Umthelela ka Rebecca Malope wabonakala ekubulungeni amasikweni womvumo weSewula Afrika. Wahlonitjhwa ngeziqu zobudorhedere esikhngweni samaziko aphakemeko Kwazulu Natal ne-Califonia ngesibanga sokwenza umvumo. Phezulu wakhe wathoma ihlelo lakhe kumabona kude elabe labizwa bona yi “its gospel time” elabe lidlala ku SABC 2.&lt;ref&gt;[https://www.tvsa.co.za/shows/viewshowseasons.aspx?showId=2776&amp;season=2 It's Gospel Time | Season 2 | TVSA]&lt;/ref&gt; Begodu waphinda bawa lijaji  ku “clash of the Choirs South Africa” .ukuvela kwkahe kumabonwa kude kwenza bona akghone ukukhuthaza iinzukulwana ezisakhulako zabavumi bonyana bomvumo wevangeli. U-Rebecca uzakhele igama ngokuthi azimisele ukuthi amamezele umlayezo wokuletha ithemba ngomvumo wakhe begodu ama-albhamu wakhe athengwa khuli.

== Iinkomba ==
[[Category:Abavumi eSewula Afrika]]
[[Category:Umvumo wevangeli]]</text>
      <sha1>2zmdp770ucvu5ic9xif5ic7hz17o3x1</sha1>
    </revision>
    <revision>
      <id>5744</id>
      <parentid>5743</parentid>
      <timestamp>2025-09-20T14:30:14Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5744</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2421" sha1="9a25a2ae5qwhozgxhtdyq76oytzxkdo" xml:space="preserve">[[Isimumathi:Ribs Malope.jpg|thumb|Rebecca Malope]]
'''Rebecca Malope''' mvumi enarheni yeSewula Afrika owabelethwa ngenyanga ka Mngwengweni ngonyaka we-1968 endaweni ye Likazi eduze neNelspruit esiphandeni seMpumalanga.&lt;ref&gt;[https://www.rebeccamalope.co.za/rebeccamalope_about.html About REBECCA MALOPE - South African Gospel Music Icon]&lt;/ref&gt; Ikhambo lakhe lathoma yena nodadwabo bafuna ukuya e-Johannesburg bayokuzuma umsebenzi nethuba lokulandela ithando lokhe lokubamvumi. Ipilo yakhe yakade ihlangana neentjhijilo ezifaka hlangana nokuthi abodorhodere bakhe bakholwa bona angekhe asakghona ukukhamba ngesibanga sokugula ekwakhe kwambamba. Nanyana kunjalo kunjalo umndeni wakhe wakholwa bonyana uzokuphila.

Wathola indawo kwezomvumo wathoma ukuvuma esontweni lakhe, lokho kwenza bona akghone ukuba lilunga kekhwaya. Ithalente lakhe lokuvuma lathoma nguSizwe Zakwe owamlekelela ukuthi akghone ukugadangisa umvumo wakhe. Wathoma ukuphumelela ekuvumeni ngonyaka we -1987 lapho athumba khona iphaliswano le” Road shell to fame” ngengoma yakhe eyabe ithi “shine on”. Ukuthumba kwakhe lokho kwamlekelela boynana naye abe ngomunye wabavumi abaziwako enarheni yeSewula Afrika. Uyivumile imihlobo eminengi yomvumo kodwana ubonakele bonyana uzinikele ekuvumeni umvumo wevangeli.

U-Rebeca Malope uneminyaka engaphezulukwama-30 emvumeni wevangeli begodu sele akhiphe ama- albhamu angaphezulu kwama-20. I-albhamu yakhe yokuthoma yabe ineshloko esithi “umoya wami” kwalandela I ”shwele baba” namanye ama-nalbhamu alandela ngemva kwalawa. Umthelela ka Rebecca Malope wabonakala ekubulungeni amasikweni womvumo weSewula Afrika. Wahlonitjhwa ngeziqu zobudorhedere esikhngweni samaziko aphakemeko Kwazulu Natal ne-Califonia ngesibanga sokwenza umvumo. Phezulu wakhe wathoma ihlelo lakhe kumabona kude elabe labizwa bona yi “its gospel time” elabe lidlala ku SABC 2.&lt;ref&gt;[https://www.tvsa.co.za/shows/viewshowseasons.aspx?showId=2776&amp;season=2 It's Gospel Time | Season 2 | TVSA]&lt;/ref&gt; Begodu waphinda bawa lijaji  ku “clash of the Choirs South Africa” . Ukuvela kwkahe kumabonwa kude kwenza bona akghone ukukhuthaza iinzukulwana ezisakhulako zabavumi bonyana bomvumo wevangeli. U-Rebecca uzakhele igama ngokuthi azimisele ukuthi amamezele umlayezo wokuletha ithemba ngomvumo wakhe begodu ama-albhamu wakhe athengwa khuli.

== Iinkomba ==
[[Category:Abavumi eSewula Afrika]]
[[Category:Umvumo wevangeli]]</text>
      <sha1>9a25a2ae5qwhozgxhtdyq76oytzxkdo</sha1>
    </revision>
    <revision>
      <id>5745</id>
      <parentid>5744</parentid>
      <timestamp>2025-09-20T14:32:37Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5745</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2526" sha1="3ut0nfnfi79xazjxmlf85i0ymxu6fwv" xml:space="preserve">[[Isimumathi:Ribs Malope.jpg|thumb|Rebecca Malope]]
'''Rebecca Malope''' mvumi enarheni yeSewula Afrika owabelethwa ngenyanga ka Mngwengweni ngonyaka we-1968 endaweni ye Likazi eduze neNelspruit esiphandeni seMpumalanga.&lt;ref&gt;[https://www.rebeccamalope.co.za/rebeccamalope_about.html About REBECCA MALOPE - South African Gospel Music Icon]&lt;/ref&gt; Ikhambo lakhe lathoma yena nodadwabo bafuna ukuya e-Johannesburg bayokuzuma umsebenzi nethuba lokulandela ithando lokhe lokubamvumi. Ipilo yakhe yakade ihlangana neentjhijilo ezifaka hlangana nokuthi abodorhodere bakhe bakholwa bona angekhe asakghona ukukhamba ngesibanga sokugula ekwakhe kwambamba. Nanyana kunjalo kunjalo umndeni wakhe wakholwa bonyana uzokuphila.

Wathola indawo kwezomvumo wathoma ukuvuma esontweni lakhe, lokho kwenza bona akghone ukuba lilunga kekhwaya. Ithalente lakhe lokuvuma lathoma nguSizwe Zakwe owamlekelela ukuthi akghone ukugadangisa umvumo wakhe. Wathoma ukuphumelela ekuvumeni ngonyaka we -1987 lapho athumba khona iphaliswano le” Road shell to fame” ngengoma yakhe eyabe ithi “shine on”. Ukuthumba kwakhe lokho kwamlekelela bonyana naye abe ngomunye wabavumi abaziwako enarheni yeSewula Afrika.&lt;ref&gt;[https://sahistory.org.za/people/rebecca-malope Rebecca Malope | South African History Online]&lt;/ref&gt; Uyivumile imihlobo eminengi yomvumo kodwana ubonakele bonyana uzinikele ekuvumeni umvumo wevangeli.

U-Rebeca Malope uneminyaka engaphezulukwama-30 emvumeni wevangeli begodu sele akhiphe ama- albhamu angaphezulu kwama-20. I-albhamu yakhe yokuthoma yabe ineshloko esithi “umoya wami” kwalandela I ”shwele baba” namanye ama-nalbhamu alandela ngemva kwalawa. Umthelela ka Rebecca Malope wabonakala ekubulungeni amasikweni womvumo weSewula Afrika. Wahlonitjhwa ngeziqu zobudorhedere esikhngweni samaziko aphakemeko Kwazulu Natal ne-Califonia ngesibanga sokwenza umvumo. Phezulu wakhe wathoma ihlelo lakhe kumabona kude elabe labizwa bona yi “its gospel time” elabe lidlala ku SABC 2.&lt;ref&gt;[https://www.tvsa.co.za/shows/viewshowseasons.aspx?showId=2776&amp;season=2 It's Gospel Time | Season 2 | TVSA]&lt;/ref&gt; Begodu waphinda bawa lijaji  ku “clash of the Choirs South Africa” . Ukuvela kwkahe kumabonwa kude kwenza bona akghone ukukhuthaza iinzukulwana ezisakhulako zabavumi bonyana bomvumo wevangeli. U-Rebecca uzakhele igama ngokuthi azimisele ukuthi amamezele umlayezo wokuletha ithemba ngomvumo wakhe begodu ama-albhamu wakhe athengwa khuli.

== Iinkomba ==
[[Category:Abavumi eSewula Afrika]]
[[Category:Umvumo wevangeli]]</text>
      <sha1>3ut0nfnfi79xazjxmlf85i0ymxu6fwv</sha1>
    </revision>
    <revision>
      <id>5746</id>
      <parentid>5745</parentid>
      <timestamp>2025-09-20T14:33:51Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5746</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2525" sha1="aimz5n0ed0pquqn2ydai8v86bfon8is" xml:space="preserve">[[Isimumathi:Ribs Malope.jpg|thumb|Rebecca Malope]]
'''Rebecca Malope''' mvumi enarheni yeSewula Afrika owabelethwa ngenyanga ka Mngwengweni ngonyaka we-1968 endaweni ye Likazi eduze neNelspruit esiphandeni seMpumalanga.&lt;ref&gt;[https://www.rebeccamalope.co.za/rebeccamalope_about.html About REBECCA MALOPE - South African Gospel Music Icon]&lt;/ref&gt; Ikhambo lakhe lathoma yena nodadwabo bafuna ukuya e-Johannesburg bayokuzuma umsebenzi nethuba lokulandela ithando lokhe lokubamvumi. Ipilo yakhe yakade ihlangana neentjhijilo ezifaka hlangana nokuthi abodorhodere bakhe bakholwa bona angekhe asakghona ukukhamba ngesibanga sokugula ekwakhe kwambamba. Nanyana kunjalo kunjalo umndeni wakhe wakholwa bonyana uzokuphila.

Wathola indawo kwezomvumo wathoma ukuvuma esontweni lakhe, lokho kwenza bona akghone ukuba lilunga kekhwaya. Ithalente lakhe lokuvuma lathoma nguSizwe Zakwe owamlekelela ukuthi akghone ukugadangisa umvumo wakhe. Wathoma ukuphumelela ekuvumeni ngonyaka we -1987 lapho athumba khona iphaliswano le” Road shell to fame” ngengoma yakhe eyabe ithi “shine on”. Ukuthumba kwakhe lokho kwamlekelela bonyana naye abe ngomunye wabavumi abaziwako enarheni yeSewula Afrika.&lt;ref&gt;[https://sahistory.org.za/people/rebecca-malope Rebecca Malope | South African History Online]&lt;/ref&gt; Uyivumile imihlobo eminengi yomvumo kodwana ubonakele bonyana uzinikele ekuvumeni umvumo wevangeli.

U-Rebeca Malope uneminyaka engaphezulukwama-30 emvumeni wevangeli begodu sele akhiphe ama- albhamu angaphezulu kwama-20. I-albhamu yakhe yokuthoma yabe ineshloko esithi “umoya wami” kwalandela I ”shwele baba” namanye ama-albhamu alandela ngemva kwalawa. Umthelela ka Rebecca Malope wabonakala ekubulungeni amasikweni womvumo weSewula Afrika. Wahlonitjhwa ngeziqu zobudorhedere esikhngweni samaziko aphakemeko Kwazulu Natal ne-Califonia ngesibanga sokwenza umvumo. Phezulu wakhe wathoma ihlelo lakhe kumabona kude elabe labizwa bona yi “its gospel time” elabe lidlala ku SABC 2.&lt;ref&gt;[https://www.tvsa.co.za/shows/viewshowseasons.aspx?showId=2776&amp;season=2 It's Gospel Time | Season 2 | TVSA]&lt;/ref&gt; Begodu waphinda bawa lijaji  ku “clash of the Choirs South Africa” . Ukuvela kwkahe kumabonwa kude kwenza bona akghone ukukhuthaza iinzukulwana ezisakhulako zabavumi bonyana bomvumo wevangeli. U-Rebecca uzakhele igama ngokuthi azimisele ukuthi amamezele umlayezo wokuletha ithemba ngomvumo wakhe begodu ama-albhamu wakhe athengwa khuli.

== Iinkomba ==
[[Category:Abavumi eSewula Afrika]]
[[Category:Umvumo wevangeli]]</text>
      <sha1>aimz5n0ed0pquqn2ydai8v86bfon8is</sha1>
    </revision>
    <revision>
      <id>5747</id>
      <parentid>5746</parentid>
      <timestamp>2025-09-20T14:36:48Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5747</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2610" sha1="pt0ncywtu65anyztf10ihbcwvixjkc4" xml:space="preserve">[[Isimumathi:Ribs Malope.jpg|thumb|Rebecca Malope]]
'''Rebecca Malope''' mvumi enarheni yeSewula Afrika owabelethwa ngenyanga ka Mngwengweni ngonyaka we-1968 endaweni ye Likazi eduze neNelspruit esiphandeni seMpumalanga.&lt;ref&gt;[https://www.rebeccamalope.co.za/rebeccamalope_about.html About REBECCA MALOPE - South African Gospel Music Icon]&lt;/ref&gt; Ikhambo lakhe lathoma yena nodadwabo bafuna ukuya e-Johannesburg bayokuzuma umsebenzi nethuba lokulandela ithando lokhe lokubamvumi. Ipilo yakhe yakade ihlangana neentjhijilo ezifaka hlangana nokuthi abodorhodere bakhe bakholwa bona angekhe asakghona ukukhamba ngesibanga sokugula ekwakhe kwambamba. Nanyana kunjalo kunjalo umndeni wakhe wakholwa bonyana uzokuphila.

=== Ukuthoma kwebizelo lakhe emvumeni ===
Wathola indawo kwezomvumo wathoma ukuvuma esontweni lakhe, lokho kwenza bona akghone ukuba lilunga kekhwaya. Ithalente lakhe lokuvuma lathoma nguSizwe Zakwe owamlekelela ukuthi akghone ukugadangisa umvumo wakhe. Wathoma ukuphumelela ekuvumeni ngonyaka we -1987 lapho athumba khona iphaliswano le” Road shell to fame” ngengoma yakhe eyabe ithi “shine on”. Ukuthumba kwakhe lokho kwamlekelela bonyana naye abe ngomunye wabavumi abaziwako enarheni yeSewula Afrika.&lt;ref&gt;[https://sahistory.org.za/people/rebecca-malope Rebecca Malope | South African History Online]&lt;/ref&gt; Uyivumile imihlobo eminengi yomvumo kodwana ubonakele bonyana uzinikele ekuvumeni umvumo wevangeli.

=== Umthelelala abe nawo ngokuba mvumi ===
U-Rebeca Malope uneminyaka engaphezulukwama-30 emvumeni wevangeli begodu sele akhiphe ama- albhamu angaphezulu kwama-20. I-albhamu yakhe yokuthoma yabe ineshloko esithi “umoya wami” kwalandela I ”shwele baba” namanye ama-albhamu alandela ngemva kwalawa. Umthelela ka Rebecca Malope wabonakala ekubulungeni amasikweni womvumo weSewula Afrika. Wahlonitjhwa ngeziqu zobudorhedere esikhngweni samaziko aphakemeko Kwazulu Natal ne-Califonia ngesibanga sokwenza umvumo. Phezulu wakhe wathoma ihlelo lakhe kumabona kude elabe labizwa bona yi “its gospel time” elabe lidlala ku SABC 2.&lt;ref&gt;[https://www.tvsa.co.za/shows/viewshowseasons.aspx?showId=2776&amp;season=2 It's Gospel Time | Season 2 | TVSA]&lt;/ref&gt; Begodu waphinda bawa lijaji  ku “clash of the Choirs South Africa” . Ukuvela kwkahe kumabonwa kude kwenza bona akghone ukukhuthaza iinzukulwana ezisakhulako zabavumi bonyana bomvumo wevangeli. U-Rebecca uzakhele igama ngokuthi azimisele ukuthi amamezele umlayezo wokuletha ithemba ngomvumo wakhe begodu ama-albhamu wakhe athengwa khuli.

== Iinkomba ==
[[Category:Abavumi eSewula Afrika]]
[[Category:Umvumo wevangeli]]</text>
      <sha1>pt0ncywtu65anyztf10ihbcwvixjkc4</sha1>
    </revision>
  </page>
  <page>
    <title>Izinja</title>
    <ns>0</ns>
    <id>947</id>
    <revision>
      <id>5748</id>
      <timestamp>2025-09-20T14:44:46Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;Izinja kuzinlwana ezinenyawo ezine, ziyakhokhonta lokha nazibona into engakalungi. Kusilwane esikghona ukwenziwa ifuyo sithandwa esihlala ngaphandle kwendlu ziqaphe. Inja inekghono elikhethekileko lokunekelela, lokuzwa begodu nokubona kwazo kuhlukile kunokwabantu. Izinja zimhlobo zimhlobo omnengi begodu zihluka ngobukhulu, ukuziphatha nangoboya. Zinekghono lokulekelela abantu ukuthi bararulule imiraro. Inja yaziwa njengomngani omkhulu womuntu ngombana ziyakghona ukunikel...&quot;</comment>
      <origin>5748</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3221" sha1="rrsb10ay8llasobx7qktib5yug38dhb" xml:space="preserve">Izinja kuzinlwana ezinenyawo ezine, ziyakhokhonta lokha nazibona into engakalungi. Kusilwane esikghona ukwenziwa ifuyo sithandwa esihlala ngaphandle kwendlu ziqaphe. Inja inekghono elikhethekileko lokunekelela, lokuzwa begodu nokubona kwazo kuhlukile kunokwabantu. Izinja zimhlobo zimhlobo omnengi begodu zihluka ngobukhulu, ukuziphatha nangoboya. Zinekghono lokulekelela abantu ukuthi bararulule imiraro. Inja yaziwa njengomngani omkhulu womuntu ngombana ziyakghona ukunikela abantu isekelo nokuthi zisebenzisane nabo.&lt;ref&gt;[[mwod:dog|DOG Definition &amp; Meaning - Merriam-Webster]]&lt;/ref&gt;

Izinja eziqakaphako
[[Isimumathi:NZ Police Dog.jpg|thumb|Ipholisa likhamba nenja yalo]]
Kumhlobo wezinja othwasiselwa bonyana ukghone ukuvikela abantu, indawo, ivikelwa ebatwini abangaba batsotsibafune ukungenela Indawo. Kusukela ekadeni izinja lezi zabe zikghona ukuthi ukugada nokuvikela indawo. Zikghona ukuzwa itjhada msinya begodu zilalela lokho okutjhiwo banikazi bazo kwaphela. Zikhamba indawo yoke lapho zigae khona njengekhaya nofana ebubulweni ngaphandle kokusaba. Izinja ziyakghona ukuziphatha kuhl lokha nazihlangana ngabantu ngombana zithwasise kuhle ukuthi zikghone ukulalela abanikazi.

Izinja ezihlahla abaphopheleko

Izinja lezi zithwasiselwe bonyana zikghone ukuthi zilekelele abanu abaphopheleko nofana abanobudisi bokubona kuhle bonyana bakghone  ukuthola indlela nokuthi bakghone ukuzikhambela ngesekelo lezinja lezi. Izinja lezi zidosa phambili abanikazi bazo zibalekelela bonyana bangaweli phezulu kweenqabo begodu zibakhombe nendlela. Zenza abanikazi bonyana abanikazi bakghone ukukhamba ngokuzithemba emabhodulukweni hlukaneko. Zibanikwela ukuvikeleka emabhodulukweni ahlukahlukeneko. Nolokha nangabe indlela isikhisi nofana kunamataka wemithi alengileko angalimaza abantu abaphopheleko. Ziyakghona ukuthi zenze umsebenzi wazo ngombana ziyathwasiswa ukuthi zikghone ukulandela imilayo evela kubanikazi bazo begodu nokuthi zikwazi ukudosa abantu abaphopheleko phambili. Izinja lezi zikhethwa ngokuthi zihlakaniphile, zinommoya ophasi begodu zikghona ukujwayela amabhoduluko ahlukahlukeneko.

Izinja zamapholisa

Izinja zamapholisa kuzizinja ezithasiswe ngokwezinga eliphezulu ngombana zisebenza ukuqinisekisa ukuvikeleka kwabantu nokurhubhulula ubugebengu. Izinjalezi ziyakghoa ukuthi zinukelele ziveze lapho kuneendakamizwa khona, nalapho kufihlwe khona amabhomu nofana izinto zokuwenza.Izinja lezo ziyakghona  ukuthi zizume abantu abasolelwa ngokwenza umlandu,  nofana ukuthola abantu abalahlekileko engozini. Zikghona  ukuphekelela amapholisa  lokha nakaya lapho abizwe khona begodu awaphephise zinekelele nalapho kubulungwe khona abantu ngokungasise mthethweni.

Izinja Ezizumako

Izinja ezizumako ziyakghona ukugijima ngebelo elikhulu nokuthi zithole lapho kuneenyamazana khona. Izinja lezi zinekghono lokunukelela lapho inyamazana ingakhona ngokuzwa iphunga lenyamazana. Ezinye zomhlobo lo zikhamba nabazumi abadubulula isigidi bese zilandele lapho isigidi sidubule khona zidubule khona ukwenzela bona zikghone ukobha inyamazana. Ukuze izinja lezi zikghone ukwenza umsebenzi wazo kufuze bona zibe nekghone lokulalela lokha nazi thwasisako, zibenepilo emzimbeni begodu zihlale zizibandula ngamalanga.</text>
      <sha1>rrsb10ay8llasobx7qktib5yug38dhb</sha1>
    </revision>
    <revision>
      <id>5749</id>
      <parentid>5748</parentid>
      <timestamp>2025-09-20T14:46:11Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5749</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3290" sha1="on8ys9uayg86dthr5hcwcaq3gnhottb" xml:space="preserve">'''Izinja''' kuzinlwana ezinenyawo ezine, ziyakhokhonta lokha nazibona into engakalungi. Kusilwane esikghona ukwenziwa ifuyo sithandwa esihlala ngaphandle kwendlu ziqaphe. Inja inekghono elikhethekileko lokunekelela, lokuzwa begodu nokubona kwazo kuhlukile kunokwabantu. Izinja zimhlobo zimhlobo omnengi begodu zihluka ngobukhulu, ukuziphatha nangoboya. Zinekghono lokulekelela abantu ukuthi bararulule imiraro. Inja yaziwa njengomngani omkhulu womuntu ngombana ziyakghona ukunikela abantu isekelo nokuthi zisebenzisane nabo.&lt;ref&gt;[[mwod:dog|DOG Definition &amp; Meaning - Merriam-Webster]]&lt;/ref&gt;

=== Imihlobo yezinja ===

==== Izinja eziqakaphako ====
[[Isimumathi:NZ Police Dog.jpg|thumb|Ipholisa likhamba nenja yalo]]
Kumhlobo wezinja othwasiselwa bonyana ukghone ukuvikela abantu, indawo, ivikelwa ebatwini abangaba batsotsibafune ukungenela Indawo. Kusukela ekadeni izinja lezi zabe zikghona ukuthi ukugada nokuvikela indawo. Zikghona ukuzwa itjhada msinya begodu zilalela lokho okutjhiwo banikazi bazo kwaphela. Zikhamba indawo yoke lapho zigae khona njengekhaya nofana ebubulweni ngaphandle kokusaba. Izinja ziyakghona ukuziphatha kuhl lokha nazihlangana ngabantu ngombana zithwasise kuhle ukuthi zikghone ukulalela abanikazi.

==== Izinja ezihlahla abaphopheleko ====
Izinja lezi zithwasiselwe bonyana zikghone ukuthi zilekelele abanu abaphopheleko nofana abanobudisi bokubona kuhle bonyana bakghone  ukuthola indlela nokuthi bakghone ukuzikhambela ngesekelo lezinja lezi. Izinja lezi zidosa phambili abanikazi bazo zibalekelela bonyana bangaweli phezulu kweenqabo begodu zibakhombe nendlela. Zenza abanikazi bonyana abanikazi bakghone ukukhamba ngokuzithemba emabhodulukweni hlukaneko. Zibanikwela ukuvikeleka emabhodulukweni ahlukahlukeneko. Nolokha nangabe indlela isikhisi nofana kunamataka wemithi alengileko angalimaza abantu abaphopheleko. Ziyakghona ukuthi zenze umsebenzi wazo ngombana ziyathwasiswa ukuthi zikghone ukulandela imilayo evela kubanikazi bazo begodu nokuthi zikwazi ukudosa abantu abaphopheleko phambili. Izinja lezi zikhethwa ngokuthi zihlakaniphile, zinommoya ophasi begodu zikghona ukujwayela amabhoduluko ahlukahlukeneko.

==== Izinja zamapholisa ====
Izinja zamapholisa kuzizinja ezithasiswe ngokwezinga eliphezulu ngombana zisebenza ukuqinisekisa ukuvikeleka kwabantu nokurhubhulula ubugebengu. Izinjalezi ziyakghoa ukuthi zinukelele ziveze lapho kuneendakamizwa khona, nalapho kufihlwe khona amabhomu nofana izinto zokuwenza.Izinja lezo ziyakghona  ukuthi zizume abantu abasolelwa ngokwenza umlandu,  nofana ukuthola abantu abalahlekileko engozini. Zikghona  ukuphekelela amapholisa  lokha nakaya lapho abizwe khona begodu awaphephise zinekelele nalapho kubulungwe khona abantu ngokungasise mthethweni.

==== Izinja Ezizumako ====
Izinja ezizumako ziyakghona ukugijima ngebelo elikhulu nokuthi zithole lapho kuneenyamazana khona. Izinja lezi zinekghono lokunukelela lapho inyamazana ingakhona ngokuzwa iphunga lenyamazana. Ezinye zomhlobo lo zikhamba nabazumi abadubulula isigidi bese zilandele lapho isigidi sidubule khona zidubule khona ukwenzela bona zikghone ukobha inyamazana. Ukuze izinja lezi zikghone ukwenza umsebenzi wazo kufuze bona zibe nekghone lokulalela lokha nazi thwasisako, zibenepilo emzimbeni begodu zihlale zizibandula ngamalanga.</text>
      <sha1>on8ys9uayg86dthr5hcwcaq3gnhottb</sha1>
    </revision>
    <revision>
      <id>5750</id>
      <parentid>5749</parentid>
      <timestamp>2025-09-20T14:47:11Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5750</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3306" sha1="3od4jevl331706svk520mt2shsnednj" xml:space="preserve">'''Izinja''' kuzinlwana ezinenyawo ezine, ziyakhokhonta lokha nazibona into engakalungi. Kusilwane esikghona ukwenziwa ifuyo sithandwa esihlala ngaphandle kwendlu ziqaphe. Inja inekghono elikhethekileko lokunekelela, lokuzwa begodu nokubona kwazo kuhlukile kunokwabantu. Izinja zimhlobo zimhlobo omnengi begodu zihluka ngobukhulu, ukuziphatha nangoboya. Zinekghono lokulekelela abantu ukuthi bararulule imiraro. Inja yaziwa njengomngani omkhulu womuntu ngombana ziyakghona ukunikela abantu isekelo nokuthi zisebenzisane nabo.&lt;ref&gt;[[mwod:dog|DOG Definition &amp; Meaning - Merriam-Webster]]&lt;/ref&gt;

=== Imihlobo yezinja ===

==== Izinja eziqakaphako ====
[[Isimumathi:NZ Police Dog.jpg|thumb|Ipholisa likhamba nenja yalo]]
Kumhlobo wezinja othwasiselwa bonyana ukghone ukuvikela abantu, indawo, ivikelwa ebatwini abangaba batsotsibafune ukungenela Indawo. Kusukela ekadeni izinja lezi zabe zikghona ukuthi ukugada nokuvikela indawo. Zikghona ukuzwa itjhada msinya begodu zilalela lokho okutjhiwo banikazi bazo kwaphela. Zikhamba indawo yoke lapho zigae khona njengekhaya nofana ebubulweni ngaphandle kokusaba. Izinja ziyakghona ukuziphatha kuhl lokha nazihlangana ngabantu ngombana zithwasise kuhle ukuthi zikghone ukulalela abanikazi.

==== Izinja ezihlahla abaphopheleko ====
Izinja lezi zithwasiselwe bonyana zikghone ukuthi zilekelele abanu abaphopheleko nofana abanobudisi bokubona kuhle bonyana bakghone  ukuthola indlela nokuthi bakghone ukuzikhambela ngesekelo lezinja lezi. Izinja lezi zidosa phambili abanikazi bazo zibalekelela bonyana bangaweli phezulu kweenqabo begodu zibakhombe nendlela. Zenza abanikazi bonyana abanikazi bakghone ukukhamba ngokuzithemba emabhodulukweni hlukaneko. Zibanikwela ukuvikeleka emabhodulukweni ahlukahlukeneko. Nolokha nangabe indlela isikhisi nofana kunamataka wemithi alengileko angalimaza abantu abaphopheleko. Ziyakghona ukuthi zenze umsebenzi wazo ngombana ziyathwasiswa ukuthi zikghone ukulandela imilayo evela kubanikazi bazo begodu nokuthi zikwazi ukudosa abantu abaphopheleko phambili. Izinja lezi zikhethwa ngokuthi zihlakaniphile, zinommoya ophasi begodu zikghona ukujwayela amabhoduluko ahlukahlukeneko.

==== Izinja zamapholisa ====
Izinja zamapholisa kuzizinja ezithasiswe ngokwezinga eliphezulu ngombana zisebenza ukuqinisekisa ukuvikeleka kwabantu nokurhubhulula ubugebengu. Izinjalezi ziyakghoa ukuthi zinukelele ziveze lapho kuneendakamizwa khona, nalapho kufihlwe khona amabhomu nofana izinto zokuwenza.Izinja lezo ziyakghona  ukuthi zizume abantu abasolelwa ngokwenza umlandu,  nofana ukuthola abantu abalahlekileko engozini. Zikghona  ukuphekelela amapholisa  lokha nakaya lapho abizwe khona begodu awaphephise zinekelele nalapho kubulungwe khona abantu ngokungasise mthethweni.

==== Izinja Ezizumako ====
Izinja ezizumako ziyakghona ukugijima ngebelo elikhulu nokuthi zithole lapho kuneenyamazana khona. Izinja lezi zinekghono lokunukelela lapho inyamazana ingakhona ngokuzwa iphunga lenyamazana. Ezinye zomhlobo lo zikhamba nabazumi abadubulula isigidi bese zilandele lapho isigidi sidubule khona zidubule khona ukwenzela bona zikghone ukobha inyamazana. Ukuze izinja lezi zikghone ukwenza umsebenzi wazo kufuze bona zibe nekghone lokulalela lokha nazi thwasisako, zibenepilo emzimbeni begodu zihlale zizibandula ngamalanga.

== Iinkomba ==</text>
      <sha1>3od4jevl331706svk520mt2shsnednj</sha1>
    </revision>
    <revision>
      <id>5751</id>
      <parentid>5750</parentid>
      <timestamp>2025-09-20T14:48:38Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5751</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3355" sha1="b4xksthno4fw15z7ailh0meyrhsfjxl" xml:space="preserve">'''Izinja''' kuzinlwana ezinenyawo ezine, ziyakhokhonta lokha nazibona into engakalungi. Kusilwane esikghona ukwenziwa ifuyo sithandwa esihlala ngaphandle kwendlu ziqaphe. Inja inekghono elikhethekileko lokunekelela, lokuzwa begodu nokubona kwazo kuhlukile kunokwabantu. Izinja zimhlobo zimhlobo omnengi begodu zihluka ngobukhulu, ukuziphatha nangoboya. Zinekghono lokulekelela abantu ukuthi bararulule imiraro. Inja yaziwa njengomngani omkhulu womuntu ngombana ziyakghona ukunikela abantu isekelo nokuthi zisebenzisane nabo.&lt;ref&gt;[[mwod:dog|DOG Definition &amp; Meaning - Merriam-Webster]]&lt;/ref&gt;

=== Imihlobo yezinja ===

==== Izinja eziqakaphako ====
[[Isimumathi:NZ Police Dog.jpg|thumb|Ipholisa likhamba nenja yalo]]
Kumhlobo wezinja othwasiselwa bonyana ukghone ukuvikela abantu, indawo, ivikelwa ebatwini abangaba batsotsibafune ukungenela Indawo. Kusukela ekadeni izinja lezi zabe zikghona ukuthi ukugada nokuvikela indawo. Zikghona ukuzwa itjhada msinya begodu zilalela lokho okutjhiwo banikazi bazo kwaphela. Zikhamba indawo yoke lapho zigae khona njengekhaya nofana ebubulweni ngaphandle kokusaba. Izinja ziyakghona ukuziphatha kuhl lokha nazihlangana ngabantu ngombana zithwasise kuhle ukuthi zikghone ukulalela abanikazi.

==== Izinja ezihlahla abaphopheleko ====
Izinja lezi zithwasiselwe bonyana zikghone ukuthi zilekelele abanu abaphopheleko nofana abanobudisi bokubona kuhle bonyana bakghone  ukuthola indlela nokuthi bakghone ukuzikhambela ngesekelo lezinja lezi. Izinja lezi zidosa phambili abanikazi bazo zibalekelela bonyana bangaweli phezulu kweenqabo begodu zibakhombe nendlela. Zenza abanikazi bonyana abanikazi bakghone ukukhamba ngokuzithemba emabhodulukweni hlukaneko. Zibanikwela ukuvikeleka emabhodulukweni ahlukahlukeneko. Nolokha nangabe indlela isikhisi nofana kunamataka wemithi alengileko angalimaza abantu abaphopheleko. Ziyakghona ukuthi zenze umsebenzi wazo ngombana ziyathwasiswa ukuthi zikghone ukulandela imilayo evela kubanikazi bazo begodu nokuthi zikwazi ukudosa abantu abaphopheleko phambili. Izinja lezi zikhethwa ngokuthi zihlakaniphile, zinommoya ophasi begodu zikghona ukujwayela amabhoduluko ahlukahlukeneko.

==== Izinja zamapholisa ====
Izinja zamapholisa kuzizinja ezithasiswe ngokwezinga eliphezulu ngombana zisebenza ukuqinisekisa ukuvikeleka kwabantu nokurhubhulula ubugebengu. Izinjalezi ziyakghoa ukuthi zinukelele ziveze lapho kuneendakamizwa khona, nalapho kufihlwe khona amabhomu nofana izinto zokuwenza.Izinja lezo ziyakghona  ukuthi zizume abantu abasolelwa ngokwenza umlandu,  nofana ukuthola abantu abalahlekileko engozini. Zikghona  ukuphekelela amapholisa  lokha nakaya lapho abizwe khona begodu awaphephise zinekelele nalapho kubulungwe khona abantu ngokungasise mthethweni.

==== Izinja Ezizumako ====
Izinja ezizumako ziyakghona ukugijima ngebelo elikhulu nokuthi zithole lapho kuneenyamazana khona. Izinja lezi zinekghono lokunukelela lapho inyamazana ingakhona ngokuzwa iphunga lenyamazana. Ezinye zomhlobo lo zikhamba nabazumi abadubulula isigidi bese zilandele lapho isigidi sidubule khona zidubule khona ukwenzela bona zikghone ukobha inyamazana. Ukuze izinja lezi zikghone ukwenza umsebenzi wazo kufuze bona zibe nekghone lokulalela lokha nazi thwasisako, zibenepilo emzimbeni begodu zihlale zizibandula ngamalanga.

== Iinkomba ==
[[category: Ifuyo sithandwa]]
[[Category: Inja]]</text>
      <sha1>b4xksthno4fw15z7ailh0meyrhsfjxl</sha1>
    </revision>
    <revision>
      <id>5752</id>
      <parentid>5751</parentid>
      <timestamp>2025-09-20T14:57:08Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5752</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4089" sha1="sbtmjb5f47y49syspy0hd8ph3mzxe0u" xml:space="preserve">'''Izinja''' kuzinlwana ezinenyawo ezine, ziyakhokhonta lokha nazibona into engakalungi. Kusilwane esikghona ukwenziwa ifuyo sithandwa esihlala ngaphandle kwendlu ziqaphe. Inja inekghono elikhethekileko lokunekelela, lokuzwa begodu nokubona kwazo kuhlukile kunokwabantu. Izinja zimhlobo zimhlobo omnengi begodu zihluka ngobukhulu, ukuziphatha nangoboya. Zinekghono lokulekelela abantu ukuthi bararulule imiraro. Inja yaziwa njengomngani omkhulu womuntu ngombana ziyakghona ukunikela abantu isekelo nokuthi zisebenzisane nabo.&lt;ref&gt;[[mwod:dog|DOG Definition &amp; Meaning - Merriam-Webster]]&lt;/ref&gt;

=== Imihlobo yezinja ===

==== Izinja eziqakaphako ====
[[Isimumathi:NZ Police Dog.jpg|thumb|Ipholisa likhamba nenja yalo]]
Kumhlobo wezinja othwasiselwa bonyana ukghone ukuvikela abantu, indawo, ivikelwa ebatwini abangaba batsotsibafune ukungenela Indawo. Kusukela ekadeni izinja lezi zabe zikghona ukuthi ukugada nokuvikela indawo.&lt;ref&gt;Coppinger, L. and Coppinger, R., 2024. Dogs for herding and guarding livestock. In ''Livestock handling and transport'' (pp. 296-313). GB: CABI.&lt;/ref&gt; Zikghona ukuzwa itjhada msinya begodu zilalela lokho okutjhiwo banikazi bazo kwaphela. Zikhamba indawo yoke lapho zigae khona njengekhaya nofana ebubulweni ngaphandle kokusaba. Izinja ziyakghona ukuziphatha kuhl lokha nazihlangana ngabantu ngombana zithwasise kuhle ukuthi zikghone ukulalela abanikazi.

==== Izinja ezihlahla abaphopheleko ====
Izinja lezi zithwasiselwe bonyana zikghone ukuthi zilekelele abanu abaphopheleko nofana abanobudisi bokubona kuhle bonyana bakghone  ukuthola indlela nokuthi bakghone ukuzikhambela ngesekelo lezinja lezi. Izinja lezi zidosa phambili abanikazi bazo zibalekelela bonyana bangaweli phezulu kweenqabo begodu zibakhombe nendlela.&lt;ref&gt;Glenk, L.M., Přibylová, L., Stetina, B.U., Demirel, S. and Weissenbacher, K., 2019. Perceptions on health benefits of guide dog ownership in an Austrian population of blind people with and without a guide dog. ''Animals'', ''9''(7), p.428.&lt;/ref&gt; Zenza abanikazi bonyana abanikazi bakghone ukukhamba ngokuzithemba emabhodulukweni hlukaneko. Zibanikwela ukuvikeleka emabhodulukweni ahlukahlukeneko. Nolokha nangabe indlela isikhisi nofana kunamataka wemithi alengileko angalimaza abantu abaphopheleko. Ziyakghona ukuthi zenze umsebenzi wazo ngombana ziyathwasiswa ukuthi zikghone ukulandela imilayo evela kubanikazi bazo begodu nokuthi zikwazi ukudosa abantu abaphopheleko phambili. Izinja lezi zikhethwa ngokuthi zihlakaniphile, zinommoya ophasi begodu zikghona ukujwayela amabhoduluko ahlukahlukeneko.

==== Izinja zamapholisa ====
Izinja zamapholisa kuzizinja ezithasiswe ngokwezinga eliphezulu ngombana zisebenza ukuqinisekisa ukuvikeleka kwabantu nokurhubhulula ubugebengu. Izinjalezi ziyakghoa ukuthi zinukelele ziveze lapho kuneendakamizwa khona, nalapho kufihlwe khona amabhomu nofana izinto zokuwenza.&lt;ref&gt;Unver, Y. and Shahed, B., 2023. The Role of Detective Dogs in the Process of Discovering and Verifying Evidence of Crime. ''Comparative Criminal Jurisprudence'', ''2''(5), pp.617-627.&lt;/ref&gt; Izinja lezo ziyakghona  ukuthi zizume abantu abasolelwa ngokwenza umlandu,  nofana ukuthola abantu abalahlekileko engozini. Zikghona  ukuphekelela amapholisa  lokha nakaya lapho abizwe khona begodu awaphephise zinekelele nalapho kubulungwe khona abantu ngokungasise mthethweni.

==== Izinja Ezizumako ====
Izinja ezizumako ziyakghona ukugijima ngebelo elikhulu nokuthi zithole lapho kuneenyamazana khona. Izinja lezi zinekghono lokunukelela lapho inyamazana ingakhona ngokuzwa iphunga lenyamazana.&lt;ref&gt;Koster, J., 2009. Hunting dogs in the lowland Neotropics. ''Journal of Anthropological Research'', ''65''(4), pp.575-610.&lt;/ref&gt; Ezinye zomhlobo lo zikhamba nabazumi abadubulula isigidi bese zilandele lapho isigidi sidubule khona zidubule khona ukwenzela bona zikghone ukobha inyamazana. Ukuze izinja lezi zikghone ukwenza umsebenzi wazo kufuze bona zibe nekghone lokulalela lokha nazi thwasisako, zibenepilo emzimbeni begodu zihlale zizibandula ngamalanga.

== Iinkomba ==
[[category: Ifuyo sithandwa]]
[[Category: Inja]]</text>
      <sha1>sbtmjb5f47y49syspy0hd8ph3mzxe0u</sha1>
    </revision>
    <revision>
      <id>5896</id>
      <parentid>5752</parentid>
      <timestamp>2025-10-04T11:14:29Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5896</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4093" sha1="ly5tawqb936yslhpp4l8ezvyvp8jwk0" xml:space="preserve">'''Izinja''' kuzinlwana ezinenyawo ezine, ziyakhokhonta lokha nazibona into engakalungi. Kusilwane esikghona ukwenziwa [[ifuyo sithandwa]] esihlala ngaphandle kwendlu ziqaphe. Inja inekghono elikhethekileko lokunekelela, lokuzwa begodu nokubona kwazo kuhlukile kunokwabantu. Izinja zimhlobo zimhlobo omnengi begodu zihluka ngobukhulu, ukuziphatha nangoboya. Zinekghono lokulekelela abantu ukuthi bararulule imiraro. Inja yaziwa njengomngani omkhulu womuntu ngombana ziyakghona ukunikela abantu isekelo nokuthi zisebenzisane nabo.&lt;ref&gt;[[mwod:dog|DOG Definition &amp; Meaning - Merriam-Webster]]&lt;/ref&gt;

=== Imihlobo yezinja ===

==== Izinja eziqakaphako ====
[[Isimumathi:NZ Police Dog.jpg|thumb|Ipholisa likhamba nenja yalo]]
Kumhlobo wezinja othwasiselwa bonyana ukghone ukuvikela abantu, indawo, ivikelwa ebatwini abangaba batsotsibafune ukungenela Indawo. Kusukela ekadeni izinja lezi zabe zikghona ukuthi ukugada nokuvikela indawo.&lt;ref&gt;Coppinger, L. and Coppinger, R., 2024. Dogs for herding and guarding livestock. In ''Livestock handling and transport'' (pp. 296-313). GB: CABI.&lt;/ref&gt; Zikghona ukuzwa itjhada msinya begodu zilalela lokho okutjhiwo banikazi bazo kwaphela. Zikhamba indawo yoke lapho zigae khona njengekhaya nofana ebubulweni ngaphandle kokusaba. Izinja ziyakghona ukuziphatha kuhl lokha nazihlangana ngabantu ngombana zithwasise kuhle ukuthi zikghone ukulalela abanikazi.

==== Izinja ezihlahla abaphopheleko ====
Izinja lezi zithwasiselwe bonyana zikghone ukuthi zilekelele abanu abaphopheleko nofana abanobudisi bokubona kuhle bonyana bakghone  ukuthola indlela nokuthi bakghone ukuzikhambela ngesekelo lezinja lezi. Izinja lezi zidosa phambili abanikazi bazo zibalekelela bonyana bangaweli phezulu kweenqabo begodu zibakhombe nendlela.&lt;ref&gt;Glenk, L.M., Přibylová, L., Stetina, B.U., Demirel, S. and Weissenbacher, K., 2019. Perceptions on health benefits of guide dog ownership in an Austrian population of blind people with and without a guide dog. ''Animals'', ''9''(7), p.428.&lt;/ref&gt; Zenza abanikazi bonyana abanikazi bakghone ukukhamba ngokuzithemba emabhodulukweni hlukaneko. Zibanikwela ukuvikeleka emabhodulukweni ahlukahlukeneko. Nolokha nangabe indlela isikhisi nofana kunamataka wemithi alengileko angalimaza abantu abaphopheleko. Ziyakghona ukuthi zenze umsebenzi wazo ngombana ziyathwasiswa ukuthi zikghone ukulandela imilayo evela kubanikazi bazo begodu nokuthi zikwazi ukudosa abantu abaphopheleko phambili. Izinja lezi zikhethwa ngokuthi zihlakaniphile, zinommoya ophasi begodu zikghona ukujwayela amabhoduluko ahlukahlukeneko.

==== Izinja zamapholisa ====
Izinja zamapholisa kuzizinja ezithasiswe ngokwezinga eliphezulu ngombana zisebenza ukuqinisekisa ukuvikeleka kwabantu nokurhubhulula ubugebengu. Izinjalezi ziyakghoa ukuthi zinukelele ziveze lapho kuneendakamizwa khona, nalapho kufihlwe khona amabhomu nofana izinto zokuwenza.&lt;ref&gt;Unver, Y. and Shahed, B., 2023. The Role of Detective Dogs in the Process of Discovering and Verifying Evidence of Crime. ''Comparative Criminal Jurisprudence'', ''2''(5), pp.617-627.&lt;/ref&gt; Izinja lezo ziyakghona  ukuthi zizume abantu abasolelwa ngokwenza umlandu,  nofana ukuthola abantu abalahlekileko engozini. Zikghona  ukuphekelela amapholisa  lokha nakaya lapho abizwe khona begodu awaphephise zinekelele nalapho kubulungwe khona abantu ngokungasise mthethweni.

==== Izinja Ezizumako ====
Izinja ezizumako ziyakghona ukugijima ngebelo elikhulu nokuthi zithole lapho kuneenyamazana khona. Izinja lezi zinekghono lokunukelela lapho inyamazana ingakhona ngokuzwa iphunga lenyamazana.&lt;ref&gt;Koster, J., 2009. Hunting dogs in the lowland Neotropics. ''Journal of Anthropological Research'', ''65''(4), pp.575-610.&lt;/ref&gt; Ezinye zomhlobo lo zikhamba nabazumi abadubulula isigidi bese zilandele lapho isigidi sidubule khona zidubule khona ukwenzela bona zikghone ukobha inyamazana. Ukuze izinja lezi zikghone ukwenza umsebenzi wazo kufuze bona zibe nekghone lokulalela lokha nazi thwasisako, zibenepilo emzimbeni begodu zihlale zizibandula ngamalanga.

== Iinkomba ==
[[category: Ifuyo sithandwa]]
[[Category: Inja]]</text>
      <sha1>ly5tawqb936yslhpp4l8ezvyvp8jwk0</sha1>
    </revision>
    <revision>
      <id>5897</id>
      <parentid>5896</parentid>
      <timestamp>2025-10-04T11:16:24Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5897</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4096" sha1="f4ccw1eyp06mt7kt7ad3c03lou9n7rd" xml:space="preserve">'''Izinja''' kuzinlwana ezinenyawo ezine, ziyakhokhonta lokha nazibona into engakalungi. Kusilwane esikghona ukwenziwa [[ifuyo sithandwa]] esihlala ngaphandle kwendlu ziqaphe. Inja inekghono elikhethekileko lokunekelela, lokuzwa begodu nokubona kwazo kuhlukile kunokwabantu. Izinja zimhlobo zimhlobo omnengi begodu zihluka ngobukhulu, ukuziphatha nangoboya. Zinekghono lokulekelela abantu ukuthi bararulule imiraro. Inja yaziwa njengomngani omkhulu womuntu ngombana ziyakghona ukunikela abantu isekelo nokuthi zisebenzisane nabo.&lt;ref&gt;[[mwod:dog|DOG Definition &amp; Meaning - Merriam-Webster]]&lt;/ref&gt;

=== Imihlobo yezinja ===

==== Izinja eziqakaphako ====
[[Isimumathi:NZ Police Dog.jpg|thumb|Ipholisa likhamba nenja yalo]]
Kumhlobo wezinja othwasiselwa bonyana ukghone ukuvikela abantu, indawo, ivikelwa ebatwini abangaba batsotsi bafune ukungenela Indawo. Kusukela ekadeni izinja lezi zabe zikghona ukuthi ukugada nokuvikela indawo.&lt;ref&gt;Coppinger, L. and Coppinger, R., 2024. Dogs for herding and guarding livestock. In ''Livestock handling and transport'' (pp. 296-313). GB: CABI.&lt;/ref&gt; Zikghona ukuzwa itjhada msinya begodu zilalela lokho okutjhiwo banikazi bazo kwaphela. Zikhamba indawo yoke lapho zigae khona njengekhaya nofana ebubulweni ngaphandle kokusaba. Izinja ziyakghona ukuziphatha kuhl lokha nazihlangana ngabantu ngombana zithwasise kuhle ukuthi zikghone ukulalela abanikazi.

==== Izinja ezihlahla abaphopheleko ====
Izinja lezi zithwasiselwe bonyana zikghone ukuthi zilekelele abantu abaphopheleko nofana abanobudisi bokubona kuhle bonyana bakghone  ukuthola indlela nokuthi bakghone ukuzikhambela ngesekelo lezinja lezi. Izinja lezi zidosa phambili abanikazi bazo zibalekelela bonyana bangaweli phezulu kweenqabo begodu zibakhombe nendlela.&lt;ref&gt;Glenk, L.M., Přibylová, L., Stetina, B.U., Demirel, S. and Weissenbacher, K., 2019. Perceptions on health benefits of guide dog ownership in an Austrian population of blind people with and without a guide dog. ''Animals'', ''9''(7), p.428.&lt;/ref&gt; Zenza abanikazi bonyana abanikazi bakghone ukukhamba ngokuzithemba emabhodulukweni hlukaneko. Zibanikwela ukuvikeleka emabhodulukweni ahlukahlukeneko. Nolokha nangabe indlela isikhisi nofana kunamataka wemithi alengileko angalimaza abantu abaphopheleko. Ziyakghona ukuthi zenze umsebenzi wazo ngombana ziyathwasiswa ukuthi zikghone ukulandela imilayo evela kubanikazi bazo begodu nokuthi zikwazi ukudosa abantu abaphopheleko phambili. Izinja lezi zikhethwa ngokuthi zihlakaniphile, zinommoya ophasi begodu zikghona ukujwayela amabhoduluko ahlukahlukeneko.

==== Izinja zamapholisa ====
Izinja zamapholisa kuzizinja ezithasiswe ngokwezinga eliphezulu ngombana zisebenza ukuqinisekisa ukuvikeleka kwabantu nokurhubhulula ubugebengu. Izinjalezi ziyakghoa ukuthi zinukelele ziveze lapho kuneendakamizwa khona, nalapho kufihlwe khona amabhomu nofana izinto zokuwenza.&lt;ref&gt;Unver, Y. and Shahed, B., 2023. The Role of Detective Dogs in the Process of Discovering and Verifying Evidence of Crime. ''Comparative Criminal Jurisprudence'', ''2''(5), pp.617-627.&lt;/ref&gt; Izinja lezo ziyakghona  ukuthi zizume abantu abasolelwa ngokwenza umlandu,  nofana ukuthola abantu abalahlekileko engozini. Zikghona  ukuphekelela amapholisa  lokha nakaya lapho abizwe khona begodu awaphephise zinekelele nalapho kubulungwe khona abantu ngokungasise mthethweni.

==== Izinja Ezizumako ====
Izinja ezizumako ziyakghona ukugijima ngebelo elikhulu nokuthi zithole lapho kuneenyamazana khona. Izinja lezi zinekghono lokunukelela lapho inyamazana zingakhona ngokuzwa iphunga lenyamazana.&lt;ref&gt;Koster, J., 2009. Hunting dogs in the lowland Neotropics. ''Journal of Anthropological Research'', ''65''(4), pp.575-610.&lt;/ref&gt; Ezinye zomhlobo lo zikhamba nabazumi abadubula isigidi bese zilandele lapho isigidi sidubule khona zidubule khona ukwenzela bona zikghone ukudobha inyamazana. Ukuze izinja lezi zikghone ukwenza umsebenzi wazo kufuze bona zibe nekghone lokulalela lokha nazi thwasisako, zibenepilo emzimbeni begodu zihlale zizibandula ngamalanga.

== Iinkomba ==
[[category: Ifuyo sithandwa]]
[[Category: Inja]]</text>
      <sha1>f4ccw1eyp06mt7kt7ad3c03lou9n7rd</sha1>
    </revision>
  </page>
  <page>
    <title>Ukubulunga amagugu</title>
    <ns>0</ns>
    <id>948</id>
    <revision>
      <id>5760</id>
      <timestamp>2025-09-21T09:41:21Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;Ukubulunga kufaka imzamo yokuvikela nokubeka kuhle amasiko, umlando neemvelo yamagugu. Uqinisekise bonyana izinto eziqakathekileko abantu abekhe bazithola baphakathi kwazo zibekiwe ukuze iinzukulwana ezizako zazi ngazo begodu kungaba ngokuthi zicocwe nofana kufundwe ngazo. Amagugu afaka hlangana izinto ezingabonakaliko ezifana namasiko, ilimi, umvumo nomlando ococwa ngomlomo. Ukubulunga amagugu kuyinto eyenziwe iphasi loke ngombana iqakathekile ukwenza bona kugidingwe am...&quot;</comment>
      <origin>5760</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2470" sha1="h2jdhm65hj81iohqtq4meigntv71mge" xml:space="preserve">Ukubulunga kufaka imzamo yokuvikela nokubeka kuhle amasiko, umlando neemvelo yamagugu. Uqinisekise bonyana izinto eziqakathekileko abantu abekhe bazithola baphakathi kwazo zibekiwe ukuze iinzukulwana ezizako zazi ngazo begodu kungaba ngokuthi zicocwe nofana kufundwe ngazo. Amagugu afaka hlangana izinto ezingabonakaliko ezifana namasiko, ilimi, umvumo nomlando ococwa ngomlomo. Ukubulunga amagugu kuyinto eyenziwe iphasi loke ngombana iqakathekile ukwenza bona kugidingwe amasiko ahlukileko ngokuwamukela woke begodu ikhuthaze ukuzwana kwabantu.

Ukuqakatheka kokubulunga amagugu

Nakubulungwa amagugu abantu bazokwazi bonyana babobani bavelaphi ngokomlando wabo. Bazokghona ukuthi bazi ukuthi bavelaphi ngokomlando wabo. Bazokghona ukuthi bavakatjhele indawo zamagugu wezinto ezihlukileko eziphathelene namagugu. Ukubulungwa komlando kwenza bonyana umphakathi uzibandakanye begodu nomnotho wendawo ukhule ngombana umphakathi walapho kunendawo yamagugu ukghona ukuthola imali lokha nawuvakatjhelweko.

Iindlela zokubunga amagugu

Ukubulunga amagugu kungenzeka ngokuthi abantu batlole phasi izinto eziqakathekileko zamagugu. Okhunye kukuthi nangabe kunezinto eziphathekako ezifana nezinto ezibunjiweko nofana okhunye  zithathwe ziyokubekwa kuhle endaweni  zokubulungwa njenge myuziyamu . kufanelwe bona izibekwe itshwayo le- UNESCO  ukuvikela indawo lezo ukutjengisa bona ziphethe umlando namasiko wabantu aqakathekileko  esitjhabeni. Phezulu kwalokho kukobana  umlando ungagadangiswa ngokwedijithali ukwenzela bona ungalahleki.&lt;ref&gt;Skublewska-Paszkowska, M., Milosz, M., Powroznik, P. and Lukasik, E., 2022. 3D technologies for intangible cultural heritage preservation—literature review for selected databases. ''Heritage Science'', ''10''(1), p.3.&lt;/ref&gt; ISewula Afrika inothe ngamagugu wamasiko nemvelo avela endaweni lapho kunomlando wokuthoma nokutjhuguluka kwabantu. Endaweni ezifana nemadwaleni we-sterkfontein ne-Mapungubwe. Indawo lezi zikhombisa ukwahlukana kwamasiko nomlando wakhona odephileko nobudisi. Iindlela zokubulunga amagugu zifaka hlangana ukuthi umuntu azwisise isikhathi sakade senarha nokuthi akhuuthanze amasiko. Ukusebenzisa amathulusi wedijithali ngenye yeendlela ezingasetjenziswa ukubulunga amagugu angaphathekiko wesitjhaba. Ukubulunga amagugu kuyinto etjhugulukako eletha ukudzimelela kokuvikela isikhathi sakade ngokungakhombisi isisdingo sanje nesikhathi esizako. Ubandakanya imiphakathi, urhulumende ukugcina umlando uvikelekile.</text>
      <sha1>h2jdhm65hj81iohqtq4meigntv71mge</sha1>
    </revision>
    <revision>
      <id>5761</id>
      <parentid>5760</parentid>
      <timestamp>2025-09-21T09:42:30Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5761</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2514" sha1="s2qimc0vw9zu3tkd7boornluc6k29hu" xml:space="preserve">'''Ukubulunga amagugu''' kufaka imzamo yokuvikela nokubeka kuhle amasiko, umlando neemvelo yamagugu. Uqinisekise bonyana izinto eziqakathekileko abantu abekhe bazithola baphakathi kwazo zibekiwe ukuze iinzukulwana ezizako zazi ngazo begodu kungaba ngokuthi zicocwe nofana kufundwe ngazo. Amagugu afaka hlangana izinto ezingabonakaliko ezifana namasiko, ilimi, umvumo nomlando ococwa ngomlomo. Ukubulunga amagugu kuyinto eyenziwe iphasi loke ngombana iqakathekile ukwenza bona kugidingwe amasiko ahlukileko ngokuwamukela woke begodu ikhuthaze ukuzwana kwabantu.

=== Ukuqakatheka kokubulunga amagugu ===
Nakubulungwa amagugu abantu bazokwazi bonyana babobani bavelaphi ngokomlando wabo. Bazokghona ukuthi bazi ukuthi bavelaphi ngokomlando wabo. Bazokghona ukuthi bavakatjhele indawo zamagugu wezinto ezihlukileko eziphathelene namagugu. Ukubulungwa komlando kwenza bonyana umphakathi uzibandakanye begodu nomnotho wendawo ukhule ngombana umphakathi walapho kunendawo yamagugu ukghona ukuthola imali lokha nawuvakatjhelweko.

=== Iindlela zokubunga amagugu ===
Ukubulunga amagugu kungenzeka ngokuthi abantu batlole phasi izinto eziqakathekileko zamagugu. Okhunye kukuthi nangabe kunezinto eziphathekako ezifana nezinto ezibunjiweko nofana okhunye  zithathwe ziyokubekwa kuhle endaweni  zokubulungwa njenge myuziyamu . kufanelwe bona izibekwe itshwayo le- UNESCO  ukuvikela indawo lezo ukutjengisa bona ziphethe umlando namasiko wabantu aqakathekileko  esitjhabeni. Phezulu kwalokho kukobana  umlando ungagadangiswa ngokwedijithali ukwenzela bona ungalahleki.&lt;ref&gt;Skublewska-Paszkowska, M., Milosz, M., Powroznik, P. and Lukasik, E., 2022. 3D technologies for intangible cultural heritage preservation—literature review for selected databases. ''Heritage Science'', ''10''(1), p.3.&lt;/ref&gt; ISewula Afrika inothe ngamagugu wamasiko nemvelo avela endaweni lapho kunomlando wokuthoma nokutjhuguluka kwabantu. Endaweni ezifana nemadwaleni we-sterkfontein ne-Mapungubwe. Indawo lezi zikhombisa ukwahlukana kwamasiko nomlando wakhona odephileko nobudisi. Iindlela zokubulunga amagugu zifaka hlangana ukuthi umuntu azwisise isikhathi sakade senarha nokuthi akhuuthanze amasiko. Ukusebenzisa amathulusi wedijithali ngenye yeendlela ezingasetjenziswa ukubulunga amagugu angaphathekiko wesitjhaba. Ukubulunga amagugu kuyinto etjhugulukako eletha ukudzimelela kokuvikela isikhathi sakade ngokungakhombisi isisdingo sanje nesikhathi esizako. Ubandakanya imiphakathi, urhulumende ukugcina umlando uvikelekile.

== Iinkomba ==</text>
      <sha1>s2qimc0vw9zu3tkd7boornluc6k29hu</sha1>
    </revision>
    <revision>
      <id>5762</id>
      <parentid>5761</parentid>
      <timestamp>2025-09-21T09:43:35Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>5762</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2564" sha1="pzjggmnca6hmaej7xzih0ljw4oq1s0y" xml:space="preserve">'''Ukubulunga amagugu''' kufaka imzamo yokuvikela nokubeka kuhle amasiko, umlando neemvelo yamagugu. Uqinisekise bonyana izinto eziqakathekileko abantu abekhe bazithola baphakathi kwazo zibekiwe ukuze iinzukulwana ezizako zazi ngazo begodu kungaba ngokuthi zicocwe nofana kufundwe ngazo. Amagugu afaka hlangana izinto ezingabonakaliko ezifana namasiko, ilimi, umvumo nomlando ococwa ngomlomo. Ukubulunga amagugu kuyinto eyenziwe iphasi loke ngombana iqakathekile ukwenza bona kugidingwe amasiko ahlukileko ngokuwamukela woke begodu ikhuthaze ukuzwana kwabantu.

=== Ukuqakatheka kokubulunga amagugu ===
Nakubulungwa amagugu abantu bazokwazi bonyana babobani bavelaphi ngokomlando wabo. Bazokghona ukuthi bazi ukuthi bavelaphi ngokomlando wabo. Bazokghona ukuthi bavakatjhele indawo zamagugu wezinto ezihlukileko eziphathelene namagugu. Ukubulungwa komlando kwenza bonyana umphakathi uzibandakanye begodu nomnotho wendawo ukhule ngombana umphakathi walapho kunendawo yamagugu ukghona ukuthola imali lokha nawuvakatjhelweko.

=== Iindlela zokubunga amagugu ===
Ukubulunga amagugu kungenzeka ngokuthi abantu batlole phasi izinto eziqakathekileko zamagugu. Okhunye kukuthi nangabe kunezinto eziphathekako ezifana nezinto ezibunjiweko nofana okhunye  zithathwe ziyokubekwa kuhle endaweni  zokubulungwa njenge myuziyamu . kufanelwe bona izibekwe itshwayo le- UNESCO  ukuvikela indawo lezo ukutjengisa bona ziphethe umlando namasiko wabantu aqakathekileko  esitjhabeni. Phezulu kwalokho kukobana  umlando ungagadangiswa ngokwedijithali ukwenzela bona ungalahleki.&lt;ref&gt;Skublewska-Paszkowska, M., Milosz, M., Powroznik, P. and Lukasik, E., 2022. 3D technologies for intangible cultural heritage preservation—literature review for selected databases. ''Heritage Science'', ''10''(1), p.3.&lt;/ref&gt; ISewula Afrika inothe ngamagugu wamasiko nemvelo avela endaweni lapho kunomlando wokuthoma nokutjhuguluka kwabantu. Endaweni ezifana nemadwaleni we-sterkfontein ne-Mapungubwe. Indawo lezi zikhombisa ukwahlukana kwamasiko nomlando wakhona odephileko nobudisi. Iindlela zokubulunga amagugu zifaka hlangana ukuthi umuntu azwisise isikhathi sakade senarha nokuthi akhuuthanze amasiko. Ukusebenzisa amathulusi wedijithali ngenye yeendlela ezingasetjenziswa ukubulunga amagugu angaphathekiko wesitjhaba. Ukubulunga amagugu kuyinto etjhugulukako eletha ukudzimelela kokuvikela isikhathi sakade ngokungakhombisi isisdingo sanje nesikhathi esizako. Ubandakanya imiphakathi, urhulumende ukugcina umlando uvikelekile.

== Iinkomba ==
[[Category:ilanga lamagugu]]
[[Category:Amagugu]]</text>
      <sha1>pzjggmnca6hmaej7xzih0ljw4oq1s0y</sha1>
    </revision>
    <revision>
      <id>5763</id>
      <parentid>5762</parentid>
      <timestamp>2025-09-21T09:45:17Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5763</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2575" sha1="6qbztt0fizrzwclvq2gt1q57mqfhmby" xml:space="preserve">'''Ukubulunga amagugu''' kufaka imzamo yokuvikela nokubeka kuhle amasiko, umlando neemvelo yamagugu. Uqinisekise bonyana izinto eziqakathekileko abantu abekhe bazithola baphakathi kwazo zibekiwe ukuze iinzukulwana ezizako zazi ngazo begodu kungaba ngokuthi zicocwe nofana kufundwe ngazo. Amagugu afaka hlangana izinto ezingabonakaliko ezifana namasiko, ilimi, umvumo nomlando ococwa ngomlomo. Ukubulunga amagugu kuyinto eyenziwe iphasi loke ngombana iqakathekile ukwenza bona kugidingwe amasiko ahlukileko ngokuwamukela woke begodu ikhuthaze ukuzwana kwabantu.

=== Ukuqakatheka kokubulunga amagugu ===
Nakubulungwa amagugu abantu bazokwazi bonyana babobani bavelaphi ngokomlando wabo. Bazokghona ukuthi bazi ukuthi bavelaphi ngokomlando wabo. Bazokghona ukuthi bavakatjhele indawo zamagugu wezinto ezihlukileko eziphathelene namagugu. Ukubulungwa komlando kwenza bonyana umphakathi uzibandakanye begodu nomnotho wendawo ukhule ngombana umphakathi walapho kunendawo yamagugu ukghona ukuthola imali lokha nawuvakatjhelweko.

=== Iindlela zokubunga amagugu ===
Ukubulunga amagugu kungenzeka ngokuthi abantu batlole phasi izinto eziqakathekileko zamagugu. Okhunye kukuthi nangabe kunezinto eziphathekako ezifana nezinto ezibunjiweko nofana okhunye  zithathwe ziyokubekwa kuhle endaweni  zokubulungwa njenge myuziyamu . kufanelwe bona izibekwe itshwayo le- UNESCO  ukuvikela indawo lezo ukutjengisa bona ziphethe umlando namasiko wabantu aqakathekileko  esitjhabeni. Phezulu kwalokho kukobana  umlando ungagadangiswa ngokwedijithali ukwenzela bona ungalahleki.&lt;ref&gt;Skublewska-Paszkowska, M., Milosz, M., Powroznik, P. and Lukasik, E., 2022. 3D technologies for intangible cultural heritage preservation—literature review for selected databases. ''Heritage Science'', ''10''(1), p.3.&lt;/ref&gt; ISewula Afrika inothe ngamagugu wamasiko nemvelo avela endaweni lapho kunomlando wokuthoma nokutjhuguluka kwabantu. Endaweni ezifana nemadwaleni we-sterkfontein, [[iMapungubwe]] nezinye. Indawo lezi zikhombisa ukwahlukana kwamasiko nomlando wakhona odephileko nobudisi. Iindlela zokubulunga amagugu zifaka hlangana ukuthi umuntu azwisise isikhathi sakade senarha nokuthi akhuuthanze amasiko. Ukusebenzisa amathulusi wedijithali ngenye yeendlela ezingasetjenziswa ukubulunga amagugu angaphathekiko wesitjhaba. Ukubulunga amagugu kuyinto etjhugulukako eletha ukudzimelela kokuvikela isikhathi sakade ngokungakhombisi isisdingo sanje nesikhathi esizako. Ubandakanya imiphakathi, urhulumende ukugcina umlando uvikelekile.

== Iinkomba ==
[[Category:ilanga lamagugu]]
[[Category:Amagugu]]</text>
      <sha1>6qbztt0fizrzwclvq2gt1q57mqfhmby</sha1>
    </revision>
    <revision>
      <id>5764</id>
      <parentid>5763</parentid>
      <timestamp>2025-09-21T09:48:59Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5764</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2679" sha1="0iinqni3e0wk4e2lkhjr1qz5n6psxtw" xml:space="preserve">'''Ukubulunga amagugu''' kufaka imzamo yokuvikela nokubeka kuhle amasiko, umlando neemvelo yamagugu. Uqinisekise bonyana izinto eziqakathekileko abantu abekhe bazithola baphakathi kwazo zibekiwe ukuze iinzukulwana ezizako zazi ngazo begodu kungaba ngokuthi zicocwe nofana kufundwe ngazo. Amagugu afaka hlangana izinto ezingabonakaliko ezifana namasiko, ilimi, umvumo nomlando ococwa ngomlomo. Ukubulunga amagugu kuyinto eyenziwe iphasi loke ngombana iqakathekile ukwenza bona kugidingwe amasiko ahlukileko ngokuwamukela woke begodu ikhuthaze ukuzwana kwabantu.

=== Ukuqakatheka kokubulunga amagugu ===
[[Isimumathi:UNESCO logo English.svg|thumb|UNESCO ibulunga indawo zamagugu ezinomlando oqakathekileko]]
Nakubulungwa amagugu abantu bazokwazi bonyana babobani bavelaphi ngokomlando wabo. Bazokghona ukuthi bazi ukuthi bavelaphi ngokomlando wabo. Bazokghona ukuthi bavakatjhele indawo zamagugu wezinto ezihlukileko eziphathelene namagugu. Ukubulungwa komlando kwenza bonyana umphakathi uzibandakanye begodu nomnotho wendawo ukhule ngombana umphakathi walapho kunendawo yamagugu ukghona ukuthola imali lokha nawuvakatjhelweko.

=== Iindlela zokubunga amagugu ===
Ukubulunga amagugu kungenzeka ngokuthi abantu batlole phasi izinto eziqakathekileko zamagugu. Okhunye kukuthi nangabe kunezinto eziphathekako ezifana nezinto ezibunjiweko nofana okhunye  zithathwe ziyokubekwa kuhle endaweni  zokubulungwa njenge myuziyamu . kufanelwe bona izibekwe itshwayo le- UNESCO  ukuvikela indawo lezo ukutjengisa bona ziphethe umlando namasiko wabantu aqakathekileko  esitjhabeni. Phezulu kwalokho kukobana  umlando ungagadangiswa ngokwedijithali ukwenzela bona ungalahleki.&lt;ref&gt;Skublewska-Paszkowska, M., Milosz, M., Powroznik, P. and Lukasik, E., 2022. 3D technologies for intangible cultural heritage preservation—literature review for selected databases. ''Heritage Science'', ''10''(1), p.3.&lt;/ref&gt; ISewula Afrika inothe ngamagugu wamasiko nemvelo avela endaweni lapho kunomlando wokuthoma nokutjhuguluka kwabantu. Endaweni ezifana nemadwaleni we-sterkfontein, [[iMapungubwe]] nezinye. Indawo lezi zikhombisa ukwahlukana kwamasiko nomlando wakhona odephileko nobudisi. Iindlela zokubulunga amagugu zifaka hlangana ukuthi umuntu azwisise isikhathi sakade senarha nokuthi akhuuthanze amasiko. Ukusebenzisa amathulusi wedijithali ngenye yeendlela ezingasetjenziswa ukubulunga amagugu angaphathekiko wesitjhaba. Ukubulunga amagugu kuyinto etjhugulukako eletha ukudzimelela kokuvikela isikhathi sakade ngokungakhombisi isisdingo sanje nesikhathi esizako. Ubandakanya imiphakathi, urhulumende ukugcina umlando uvikelekile.

== Iinkomba ==
[[Category:ilanga lamagugu]]
[[Category:Amagugu]]</text>
      <sha1>0iinqni3e0wk4e2lkhjr1qz5n6psxtw</sha1>
    </revision>
    <revision>
      <id>5765</id>
      <parentid>5764</parentid>
      <timestamp>2025-09-21T09:52:38Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5765</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3062" sha1="6pqvxum5kvmu4d4i7e8cxh96poyf8j0" xml:space="preserve">'''Ukubulunga amagugu''' kufaka imzamo yokuvikela nokubeka kuhle amasiko, umlando neemvelo yamagugu. Uqinisekise bonyana izinto eziqakathekileko abantu abekhe bazithola baphakathi kwazo zibekiwe ukuze iinzukulwana ezizako zazi ngazo begodu kungaba ngokuthi zicocwe nofana kufundwe ngazo.&lt;ref&gt;Snowball, J.D. and Courtney, S., 2010. Cultural heritage routes in South Africa: Effective tools for heritage conservation and local economic development?. ''Development Southern Africa'', ''27''(4), pp.563-576.&lt;/ref&gt; Amagugu afaka hlangana izinto ezingabonakaliko ezifana namasiko, ilimi, umvumo nomlando ococwa ngomlomo. Ukubulunga amagugu kuyinto eyenziwe iphasi loke ngombana iqakathekile ukwenza bona kugidingwe amasiko ahlukileko ngokuwamukela woke begodu ikhuthaze ukuzwana kwabantu.

=== Ukuqakatheka kokubulunga amagugu ===
[[Isimumathi:UNESCO logo English.svg|thumb|UNESCO ibulunga indawo zamagugu ezinomlando oqakathekileko]]
Nakubulungwa amagugu abantu bazokwazi bonyana babobani bavelaphi ngokomlando wabo. Bazokghona ukuthi bazi ukuthi bavelaphi ngokomlando wabo. Bazokghona ukuthi bavakatjhele indawo zamagugu wezinto ezihlukileko eziphathelene namagugu.&lt;ref&gt;[https://www.longdom.org/open-access/cultural-heritage-its-significance-and-preserving-105460.html Cultural Heritage: Its Significance and Preserving]&lt;/ref&gt; Ukubulungwa komlando kwenza bonyana umphakathi uzibandakanye begodu nomnotho wendawo ukhule ngombana umphakathi walapho kunendawo yamagugu ukghona ukuthola imali lokha nawuvakatjhelweko.

=== Iindlela zokubunga amagugu ===
Ukubulunga amagugu kungenzeka ngokuthi abantu batlole phasi izinto eziqakathekileko zamagugu. Okhunye kukuthi nangabe kunezinto eziphathekako ezifana nezinto ezibunjiweko nofana okhunye  zithathwe ziyokubekwa kuhle endaweni  zokubulungwa njenge myuziyamu . kufanelwe bona izibekwe itshwayo le- UNESCO  ukuvikela indawo lezo ukutjengisa bona ziphethe umlando namasiko wabantu aqakathekileko  esitjhabeni. Phezulu kwalokho kukobana  umlando ungagadangiswa ngokwedijithali ukwenzela bona ungalahleki.&lt;ref&gt;Skublewska-Paszkowska, M., Milosz, M., Powroznik, P. and Lukasik, E., 2022. 3D technologies for intangible cultural heritage preservation—literature review for selected databases. ''Heritage Science'', ''10''(1), p.3.&lt;/ref&gt; ISewula Afrika inothe ngamagugu wamasiko nemvelo avela endaweni lapho kunomlando wokuthoma nokutjhuguluka kwabantu. Endaweni ezifana nemadwaleni we-sterkfontein, [[iMapungubwe]] nezinye. Indawo lezi zikhombisa ukwahlukana kwamasiko nomlando wakhona odephileko nobudisi. Iindlela zokubulunga amagugu zifaka hlangana ukuthi umuntu azwisise isikhathi sakade senarha nokuthi akhuuthanze amasiko. Ukusebenzisa amathulusi wedijithali ngenye yeendlela ezingasetjenziswa ukubulunga amagugu angaphathekiko wesitjhaba. Ukubulunga amagugu kuyinto etjhugulukako eletha ukudzimelela kokuvikela isikhathi sakade ngokungakhombisi isisdingo sanje nesikhathi esizako. Ubandakanya imiphakathi, urhulumende ukugcina umlando uvikelekile.

== Iinkomba ==
[[Category:ilanga lamagugu]]
[[Category:Amagugu]]</text>
      <sha1>6pqvxum5kvmu4d4i7e8cxh96poyf8j0</sha1>
    </revision>
    <revision>
      <id>5766</id>
      <parentid>5765</parentid>
      <timestamp>2025-09-21T09:54:44Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5766</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3066" sha1="jhjzafw0s4vhn7g0x197fvjsxeiz853" xml:space="preserve">'''Ukubulunga amagugu''' kufaka imzamo yokuvikela nokubeka kuhle amasiko, umlando neemvelo yamagugu. Uqinisekise bonyana izinto eziqakathekileko abantu abekhe bazithola baphakathi kwazo zibekiwe ukuze iinzukulwana ezizako zazi ngazo begodu kungaba ngokuthi zicocwe nofana kufundwe ngazo.&lt;ref&gt;Snowball, J.D. and Courtney, S., 2010. Cultural heritage routes in South Africa: Effective tools for heritage conservation and local economic development?. ''Development Southern Africa'', ''27''(4), pp.563-576.&lt;/ref&gt; Amagugu afaka hlangana izinto ezingabonakaliko ezifana namasiko, ilimi, umvumo nomlando ococwa ngomlomo. Ukubulunga amagugu kuyinto eyenziwe iphasi loke ngombana iqakathekile ukwenza bona kugidingwe amasiko ahlukileko ngokuwamukela woke begodu ikhuthaze ukuzwana kwabantu.

=== Ukuqakatheka kokubulunga amagugu ===
[[Isimumathi:UNESCO logo English.svg|thumb|UNESCO ibulunga indawo zamagugu ezinomlando oqakathekileko]]
Nakubulungwa [[amagugu]] abantu bazokwazi bonyana babobani bavelaphi ngokomlando wabo. Bazokghona ukuthi bazi ukuthi bavelaphi ngokomlando wabo. Bazokghona ukuthi bavakatjhele indawo zamagugu wezinto ezihlukileko eziphathelene namagugu.&lt;ref&gt;[https://www.longdom.org/open-access/cultural-heritage-its-significance-and-preserving-105460.html Cultural Heritage: Its Significance and Preserving]&lt;/ref&gt; Ukubulungwa komlando kwenza bonyana umphakathi uzibandakanye begodu nomnotho wendawo ukhule ngombana umphakathi walapho kunendawo yamagugu ukghona ukuthola imali lokha nawuvakatjhelweko.

=== Iindlela zokubunga amagugu ===
Ukubulunga amagugu kungenzeka ngokuthi abantu batlole phasi izinto eziqakathekileko zamagugu. Okhunye kukuthi nangabe kunezinto eziphathekako ezifana nezinto ezibunjiweko nofana okhunye  zithathwe ziyokubekwa kuhle endaweni  zokubulungwa njenge myuziyamu . kufanelwe bona izibekwe itshwayo le- UNESCO  ukuvikela indawo lezo ukutjengisa bona ziphethe umlando namasiko wabantu aqakathekileko  esitjhabeni. Phezulu kwalokho kukobana  umlando ungagadangiswa ngokwedijithali ukwenzela bona ungalahleki.&lt;ref&gt;Skublewska-Paszkowska, M., Milosz, M., Powroznik, P. and Lukasik, E., 2022. 3D technologies for intangible cultural heritage preservation—literature review for selected databases. ''Heritage Science'', ''10''(1), p.3.&lt;/ref&gt; ISewula Afrika inothe ngamagugu wamasiko nemvelo avela endaweni lapho kunomlando wokuthoma nokutjhuguluka kwabantu. Endaweni ezifana nemadwaleni we-sterkfontein, [[iMapungubwe]] nezinye. Indawo lezi zikhombisa ukwahlukana kwamasiko nomlando wakhona odephileko nobudisi. Iindlela zokubulunga amagugu zifaka hlangana ukuthi umuntu azwisise isikhathi sakade senarha nokuthi akhuuthanze amasiko. Ukusebenzisa amathulusi wedijithali ngenye yeendlela ezingasetjenziswa ukubulunga amagugu angaphathekiko wesitjhaba. Ukubulunga amagugu kuyinto etjhugulukako eletha ukudzimelela kokuvikela isikhathi sakade ngokungakhombisi isisdingo sanje nesikhathi esizako. Ubandakanya imiphakathi, urhulumende ukugcina umlando uvikelekile.

== Iinkomba ==
[[Category:ilanga lamagugu]]
[[Category:Amagugu]]</text>
      <sha1>jhjzafw0s4vhn7g0x197fvjsxeiz853</sha1>
    </revision>
  </page>
  <page>
    <title>Amagugu</title>
    <ns>0</ns>
    <id>949</id>
    <revision>
      <id>5767</id>
      <timestamp>2025-09-21T09:59:13Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;Amagugu  '''Amagugu''' akhuluma ngamasiko namasiko adluliswelwa kusuka esizukulwaneni ukuya kwesinye isizukulwane aphethe indlela yokwenza izinto zokwenza izinto zamasiko ahlukahlukeneko, ukuziphatha, ikambiso ekungiyo ehlathulula  umphakathi begodu inikele abantu ubunjalo babo, bazizwe bamukelekile.&lt;ref&gt;[https://dictionary.cambridge.org/dictionary/english/heritage HERITAGE | English meaning - Cambridge Dictionary]&lt;/ref&gt;  === Imihlobo yamagugu ===  ==== Amagugu ngamasik...&quot;</comment>
      <origin>5767</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1558" sha1="pqji9aih706srbe4zitqn44cazusb9l" xml:space="preserve">Amagugu

'''Amagugu''' akhuluma ngamasiko namasiko adluliswelwa kusuka esizukulwaneni ukuya kwesinye isizukulwane aphethe indlela yokwenza izinto zokwenza izinto zamasiko ahlukahlukeneko, ukuziphatha, ikambiso ekungiyo ehlathulula  umphakathi begodu inikele abantu ubunjalo babo, bazizwe bamukelekile.&lt;ref&gt;[https://dictionary.cambridge.org/dictionary/english/heritage HERITAGE | English meaning - Cambridge Dictionary]&lt;/ref&gt;

=== Imihlobo yamagugu ===

==== Amagugu ngamasiko ====
Lokhu kufaka hlangana ubukgwari, umtlolo, umvumo nokhunye, ekuyindlela yokuziveza  ngobukghwari besiye nesinye isitjhaba.

==== Amagugu womlando ====
Lapho sikhuluma ngezinto ezibambekako nofana  ezingabambekiko zakudala ezifana nemakhiwo, izinto ezubunjiweko namasiko lawa aphethe umlando oqakathekilekowesitjhaba esithileko. Amagugu alekelela  abantu bona bafunde ngezinto zesikhathi sakade, ukuzwisisa amatjhuguluko anzekako emphakathini nokuthi kwenzeke irhubhululo ngomalndo wabantu nofana wezinto. Indawo lezi zidosa abavakatjhi bonyana bavakatjhele indawo lapho imakhiwo enomlando inomlando ikhona.Isibonelo i-Roben island ingeye yendawo yamagugu eziphethe umlando wombuso wegandelelo eSewula Afrika.

==== Amagugu wemvelo ====
Amagugu wemvelo afaka iindawo, nehlelo lemvelo ekuyizinto ezithathwa njengokuthi kufanele bona zibulungelwe isizukulwane esizako.

==== Amagugu angabonakaliko ====
Magugu apheth izinto ezingabonakaliko ngokomzimba zamasiko ezifana nama namasiko nendlela yokuwenza, ilwazi elidluliselwa  ngomlomo nangokufundisa ngokwenza.

== Iinkomba ==</text>
      <sha1>pqji9aih706srbe4zitqn44cazusb9l</sha1>
    </revision>
    <revision>
      <id>5768</id>
      <parentid>5767</parentid>
      <timestamp>2025-09-21T10:00:59Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>5768</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1644" sha1="tdi3b8166v359bndiakwfzp7h1neuge" xml:space="preserve">Amagugu

'''Amagugu''' akhuluma ngamasiko namasiko adluliswelwa kusuka esizukulwaneni ukuya kwesinye isizukulwane aphethe indlela yokwenza izinto zokwenza izinto zamasiko ahlukahlukeneko, ukuziphatha, ikambiso ekungiyo ehlathulula  umphakathi begodu inikele abantu ubunjalo babo, bazizwe bamukelekile.&lt;ref&gt;[https://dictionary.cambridge.org/dictionary/english/heritage HERITAGE | English meaning - Cambridge Dictionary]&lt;/ref&gt;

=== Imihlobo yamagugu ===

==== Amagugu ngamasiko ====
Lokhu kufaka hlangana ubukgwari, umtlolo, umvumo nokhunye, ekuyindlela yokuziveza  ngobukghwari besiye nesinye isitjhaba.

==== Amagugu womlando ====
Lapho sikhuluma ngezinto ezibambekako nofana  ezingabambekiko zakudala ezifana nemakhiwo, izinto ezubunjiweko namasiko lawa aphethe umlando oqakathekilekowesitjhaba esithileko. Amagugu alekelela  abantu bona bafunde ngezinto zesikhathi sakade, ukuzwisisa amatjhuguluko anzekako emphakathini nokuthi kwenzeke irhubhululo ngomalndo wabantu nofana wezinto. Indawo lezi zidosa abavakatjhi bonyana bavakatjhele indawo lapho imakhiwo enomlando inomlando ikhona.Isibonelo i-Roben island ingeye yendawo yamagugu eziphethe umlando wombuso wegandelelo eSewula Afrika.

==== Amagugu wemvelo ====
Amagugu wemvelo afaka iindawo, nehlelo lemvelo ekuyizinto ezithathwa njengokuthi kufanele bona zibulungelwe isizukulwane esizako.

==== Amagugu angabonakaliko ====
Magugu apheth izinto ezingabonakaliko ngokomzimba zamasiko ezifana nama namasiko nendlela yokuwenza, ilwazi elidluliselwa  ngomlomo nangokufundisa ngokwenza.

== Iinkomba ==
[[Category: Ukubulunga Amagugu]]
[[Category: Amasiko]]
[[Category: Umlando wamasiko]]</text>
      <sha1>tdi3b8166v359bndiakwfzp7h1neuge</sha1>
    </revision>
    <revision>
      <id>5769</id>
      <parentid>5768</parentid>
      <timestamp>2025-09-21T10:22:23Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5769</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2280" sha1="gorppgq3dds00tc0n39zq8z4ijuhg87" xml:space="preserve">Amagugu

'''Amagugu''' akhuluma ngamasiko namasiko adluliswelwa kusuka esizukulwaneni ukuya kwesinye isizukulwane aphethe indlela yokwenza izinto zokwenza izinto zamasiko ahlukahlukeneko, ukuziphatha, ikambiso ekungiyo ehlathulula  umphakathi begodu inikele abantu ubunjalo babo, bazizwe bamukelekile.&lt;ref&gt;[https://dictionary.cambridge.org/dictionary/english/heritage HERITAGE | English meaning - Cambridge Dictionary]&lt;/ref&gt;

=== Imihlobo yamagugu ===

==== Amagugu ngamasiko ====
Lokhu kufaka hlangana ubukgwari, umtlolo, umvumo nokhunye, ekuyindlela yokuziveza  ngobukghwari besiye nesinye isitjhaba. Amagugug la afaka hlangana amasiko nofana ikambiso evela kwabadala yadluliselwa esizukulwaneni sanje. Amagugu ngamasiko angafaka indlea yokugida, ukwenziwa kweminyanya ulandela ikambiso ethileko nokuthi  imvelo iphathwa bunjani.

==== Amagugu womlando ====
Lapho sikhuluma ngezinto ezibambekako nofana  ezingabambekiko zakudala ezifana nemakhiwo, izinto ezubunjiweko namasiko lawa aphethe umlando oqakathekilekowesitjhaba esithileko. Amagugu alekelela  abantu bona bafunde ngezinto zesikhathi sakade, ukuzwisisa amatjhuguluko anzekako emphakathini nokuthi kwenzeke irhubhululo ngomalndo wabantu nofana wezinto. Indawo lezi zidosa abavakatjhi bonyana bavakatjhele indawo lapho imakhiwo enomlando inomlando ikhona.Isibonelo i-Roben island ingeye yendawo yamagugu eziphethe umlando wombuso wegandelelo eSewula Afrika.

==== Amagugu wemvelo ====
Amagugu wemvelo afaka iindawo, nehlelo lemvelo ekuyizinto ezithathwa njengokuthi kufanele bona zibulungelwe isizukulwane esizako.

==== Amagugu angabonakaliko ====
Magugu apheth izinto ezingabonakaliko ngokomzimba zamasiko ezifana nama namasiko nendlela yokuwenza, ilwazi elidluliselwa  ngomlomo nangokufundisa ngokwenza. Amagugu angabonakaliko angahlala angakhombisi ukudlulisw kwamasiko wakudala kodwana imikhuba yesikhathi sanje, yendaweni ezisemkahya nofana emadorobheni lapho iinqhema  zamasiko ahlukahlukeneko zihlanganyela khona. Amagugu angabonakaliko wavusi imibuzo yokuthi imikghwa ethileko iqondene nesiko, kodwana ilekelela ekutheni imiphakathi ibumbane bona bazizwe ayingcenye yomphakathi owodwa  nofana ohlukileko.

== Iinkomba ==
[[Category: Ukubulunga Amagugu]]
[[Category: Amasiko]]
[[Category: Umlando wamasiko]]</text>
      <sha1>gorppgq3dds00tc0n39zq8z4ijuhg87</sha1>
    </revision>
    <revision>
      <id>5770</id>
      <parentid>5769</parentid>
      <timestamp>2025-09-21T10:29:53Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5770</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2792" sha1="fb06btghm5pzqj82acyga2gkh7865p7" xml:space="preserve">Amagugu
[[Isimumathi:Tsonga girls in South Africa showing off their traditional clothing.jpg|thumb|Abentazana bamaTsonga]]
'''Amagugu''' akhuluma ngamasiko namasiko adluliswelwa kusuka esizukulwaneni ukuya kwesinye isizukulwane aphethe indlela yokwenza izinto zokwenza izinto zamasiko ahlukahlukeneko, ukuziphatha, ikambiso ekungiyo ehlathulula  umphakathi begodu inikele abantu ubunjalo babo, bazizwe bamukelekile.&lt;ref&gt;[https://dictionary.cambridge.org/dictionary/english/heritage HERITAGE | English meaning - Cambridge Dictionary]&lt;/ref&gt;

=== Imihlobo yamagugu ===

==== Amagugu ngamasiko ====
[[Isimumathi:South Africa Shy Ndebele Woman (4608424073).jpg|thumb|Umma weNdebele]]
Lokhu kufaka hlangana ubukgwari, umtlolo, umvumo nokhunye, ekuyindlela yokuziveza  ngobukghwari besiye nesinye isitjhaba. Amagugug la afaka hlangana amasiko nofana ikambiso evela kwabadala yadluliselwa esizukulwaneni sanje. Amagugu ngamasiko angafaka indlea yokugida, ukwenziwa kweminyanya ulandela ikambiso ethileko nokuthi  imvelo iphathwa bunjani.

==== Amagugu womlando ====
Lapho sikhuluma ngezinto ezibambekako nofana  ezingabambekiko zakudala ezifana nemakhiwo, izinto ezubunjiweko namasiko lawa aphethe umlando oqakathekilekowesitjhaba esithileko. Amagugu alekelela  abantu bona bafunde ngezinto zesikhathi sakade, ukuzwisisa amatjhuguluko anzekako emphakathini nokuthi kwenzeke irhubhululo ngomalndo wabantu nofana wezinto.&lt;ref&gt;[https://sahistory.org.za/article/what-heritage What is heritage? | South African History Online]&lt;/ref&gt; Indawo lezi zidosa abavakatjhi bonyana bavakatjhele indawo lapho imakhiwo enomlando inomlando ikhona.Isibonelo i-Roben island ingeye yendawo yamagugu eziphethe umlando wombuso wegandelelo eSewula Afrika.

==== Amagugu wemvelo ====
Amagugu wemvelo afaka iindawo, nehlelo lemvelo ekuyizinto ezithathwa njengokuthi kufanele bona zibulungelwe isizukulwane esizako.

==== Amagugu angabonakaliko ====
[[Isimumathi:Swazi Warriors.jpg|thumb|Amadoda wamaSwati]]
Magugu apheth izinto ezingabonakaliko ngokomzimba zamasiko ezifana nama namasiko nendlela yokuwenza, ilwazi elidluliselwa  ngomlomo nangokufundisa ngokwenza. Amagugu angabonakaliko angahlala angakhombisi ukudlulisw kwamasiko wakudala kodwana imikhuba yesikhathi sanje, yendaweni ezisemkahya nofana emadorobheni lapho iinqhema  zamasiko ahlukahlukeneko zihlanganyela khona. Amagugu angabonakaliko wavusi imibuzo yokuthi imikghwa ethileko iqondene nesiko, kodwana ilekelela ekutheni imiphakathi ibumbane bona bazizwe ayingcenye yomphakathi owodwa  nofana ohlukileko.&lt;ref&gt;[https://ich.unesco.org/en/what-is-intangible-heritage-00003 What is Intangible Cultural Heritage? - UNESCO Intangible Cultural Heritage]&lt;/ref&gt;

== Iinkomba ==
[[Category: Ukubulunga Amagugu]]
[[Category: Amasiko]]
[[Category: Umlando wamasiko]]</text>
      <sha1>fb06btghm5pzqj82acyga2gkh7865p7</sha1>
    </revision>
    <revision>
      <id>5771</id>
      <parentid>5770</parentid>
      <timestamp>2025-09-21T10:33:06Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5771</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3236" sha1="m398lvvqkj9i8091rxkmfl0790maz12" xml:space="preserve">Amagugu
[[Isimumathi:Tsonga girls in South Africa showing off their traditional clothing.jpg|thumb|Abentazana bamaTsonga]]
'''Amagugu''' akhuluma ngamasiko namasiko adluliswelwa kusuka esizukulwaneni ukuya kwesinye isizukulwane aphethe indlela yokwenza izinto zokwenza izinto zamasiko ahlukahlukeneko, ukuziphatha, ikambiso ekungiyo ehlathulula  umphakathi begodu inikele abantu ubunjalo babo, bazizwe bamukelekile.&lt;ref&gt;[https://dictionary.cambridge.org/dictionary/english/heritage HERITAGE | English meaning - Cambridge Dictionary]&lt;/ref&gt; Ukwenza isibonelo, amagugu angafaka hlangana umlando womndeni; ukuzibandakanya kwabo nekolo abayilandelako; nofana amasiko wamasiko. Nanyana kunjalo amagugu afaka hlangana nalokho okuyingcenye yokuzwisisa kwesitjhaba. Umuntu obelethwe eSewula Afrika, ngokwesibonelo, unegugu lenarha yeSewula Afrika, kanye nelifa lomuntu mathupha neliyifihlo. Umuntu onjalo angathathwa njengomuntu onelifa le-Afrika, ngombana wabelethwa enarhakazini ye-Afrika.

=== Imihlobo yamagugu ===

==== Amagugu ngamasiko ====
[[Isimumathi:South Africa Shy Ndebele Woman (4608424073).jpg|thumb|Umma weNdebele]]
Lokhu kufaka hlangana ubukgwari, umtlolo, umvumo nokhunye, ekuyindlela yokuziveza  ngobukghwari besiye nesinye isitjhaba. Amagugug la afaka hlangana amasiko nofana ikambiso evela kwabadala yadluliselwa esizukulwaneni sanje. Amagugu ngamasiko angafaka indlea yokugida, ukwenziwa kweminyanya ulandela ikambiso ethileko nokuthi  imvelo iphathwa bunjani.

==== Amagugu womlando ====
Lapho sikhuluma ngezinto ezibambekako nofana  ezingabambekiko zakudala ezifana nemakhiwo, izinto ezubunjiweko namasiko lawa aphethe umlando oqakathekilekowesitjhaba esithileko. Amagugu alekelela  abantu bona bafunde ngezinto zesikhathi sakade, ukuzwisisa amatjhuguluko anzekako emphakathini nokuthi kwenzeke irhubhululo ngomalndo wabantu nofana wezinto.&lt;ref&gt;[https://sahistory.org.za/article/what-heritage What is heritage? | South African History Online]&lt;/ref&gt; Indawo lezi zidosa abavakatjhi bonyana bavakatjhele indawo lapho imakhiwo enomlando inomlando ikhona.Isibonelo i-Roben island ingeye yendawo yamagugu eziphethe umlando wombuso wegandelelo eSewula Afrika.

==== Amagugu wemvelo ====
Amagugu wemvelo afaka iindawo, nehlelo lemvelo ekuyizinto ezithathwa njengokuthi kufanele bona zibulungelwe isizukulwane esizako.

==== Amagugu angabonakaliko ====
[[Isimumathi:Swazi Warriors.jpg|thumb|Amadoda wamaSwati]]
Magugu apheth izinto ezingabonakaliko ngokomzimba zamasiko ezifana nama namasiko nendlela yokuwenza, ilwazi elidluliselwa  ngomlomo nangokufundisa ngokwenza. Amagugu angabonakaliko angahlala angakhombisi ukudlulisw kwamasiko wakudala kodwana imikhuba yesikhathi sanje, yendaweni ezisemkahya nofana emadorobheni lapho iinqhema  zamasiko ahlukahlukeneko zihlanganyela khona. Amagugu angabonakaliko wavusi imibuzo yokuthi imikghwa ethileko iqondene nesiko, kodwana ilekelela ekutheni imiphakathi ibumbane bona bazizwe ayingcenye yomphakathi owodwa  nofana ohlukileko.&lt;ref&gt;[https://ich.unesco.org/en/what-is-intangible-heritage-00003 What is Intangible Cultural Heritage? - UNESCO Intangible Cultural Heritage]&lt;/ref&gt;

== Iinkomba ==
[[Category: Ukubulunga Amagugu]]
[[Category: Amasiko]]
[[Category: Umlando wamasiko]]</text>
      <sha1>m398lvvqkj9i8091rxkmfl0790maz12</sha1>
    </revision>
    <revision>
      <id>5772</id>
      <parentid>5771</parentid>
      <timestamp>2025-09-21T10:37:17Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5772</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3702" sha1="epywh8e6q9plr1nok9kqyjh6b8gphbd" xml:space="preserve">Amagugu
[[Isimumathi:Tsonga girls in South Africa showing off their traditional clothing.jpg|thumb|Abentazana bamaTsonga]]
'''Amagugu''' akhuluma ngamasiko namasiko adluliswelwa kusuka esizukulwaneni ukuya kwesinye isizukulwane aphethe indlela yokwenza izinto zokwenza izinto zamasiko ahlukahlukeneko, ukuziphatha, ikambiso ekungiyo ehlathulula  umphakathi begodu inikele abantu ubunjalo babo, bazizwe bamukelekile.&lt;ref&gt;[https://dictionary.cambridge.org/dictionary/english/heritage HERITAGE | English meaning - Cambridge Dictionary]&lt;/ref&gt; Ukwenza isibonelo, amagugu angafaka hlangana umlando womndeni; ukuzibandakanya kwabo nekolo abayilandelako; nofana amasiko wamasiko. Nanyana kunjalo amagugu afaka hlangana nalokho okuyingcenye yokuzwisisa kwesitjhaba. Umuntu obelethwe eSewula Afrika, ngokwesibonelo, unegugu lenarha yeSewula Afrika, kanye nelifa lomuntu mathupha neliyifihlo. Umuntu onjalo angathathwa njengomuntu onelifa le-Afrika, ngombana wabelethwa enarhakazini ye-Afrika.

=== Imihlobo yamagugu ===

==== Amagugu ngamasiko ====
[[Isimumathi:South Africa Shy Ndebele Woman (4608424073).jpg|thumb|Umma weNdebele]]
Lokhu kufaka hlangana ubukgwari, umtlolo, umvumo nokhunye, ekuyindlela yokuziveza  ngobukghwari besiye nesinye isitjhaba. Amagugug la afaka hlangana amasiko nofana ikambiso evela kwabadala yadluliselwa esizukulwaneni sanje. Amagugu ngamasiko angafaka indlea yokugida, ukwenziwa kweminyanya ulandela ikambiso ethileko nokuthi  imvelo iphathwa bunjani.

==== Amagugu womlando ====
Lapho sikhuluma ngezinto ezibambekako nofana  ezingabambekiko zakudala ezifana nemakhiwo, izinto ezubunjiweko namasiko lawa aphethe umlando oqakathekilekowesitjhaba esithileko. Amagugu alekelela  abantu bona bafunde ngezinto zesikhathi sakade, ukuzwisisa amatjhuguluko anzekako emphakathini nokuthi kwenzeke irhubhululo ngomalndo wabantu nofana wezinto.&lt;ref&gt;[https://sahistory.org.za/article/what-heritage What is heritage? | South African History Online]&lt;/ref&gt; Indawo lezi zidosa abavakatjhi bonyana bavakatjhele indawo lapho imakhiwo enomlando inomlando ikhona.Isibonelo i-Roben island ingeye yendawo yamagugu eziphethe umlando wombuso wegandelelo eSewula Afrika.

==== Amagugu wemvelo ====
Amagugu wemvelo afaka iindawo, nehlelo lemvelo ekuyizinto ezithathwa njengokuthi kufanele bona zibulungelwe isizukulwane esizako. Igugu lemvelo leSewula Afrika lakhiwe ziiNdawo zamagugu wePhasi kanye neentaba zawo ezihle, iinlwana zeganga ezifakahlangana ‘''i-Big Five''’, iintjalo, iinyoni  nazo yoke ikariso mraro yemvelo yephasi, eendaweni ezisewula khulu ye-Afrika.Ngalokhu sifisa ukunikela zoke izakhamuzi amandla wokufunda ngamagugu wazo ngelimi lazo, zizikhakhazise ngemirabhu yazo begodu zikhambe ziye esikhathini esizako ngokuzwisisa nokuhlonipha ubuhle bemvelo bezwe elikhulu leli.

==== Amagugu angabonakaliko ====
[[Isimumathi:Swazi Warriors.jpg|thumb|Amadoda wamaSwati]]
Magugu apheth izinto ezingabonakaliko ngokomzimba zamasiko ezifana nama namasiko nendlela yokuwenza, ilwazi elidluliselwa  ngomlomo nangokufundisa ngokwenza. Amagugu angabonakaliko angahlala angakhombisi ukudlulisw kwamasiko wakudala kodwana imikhuba yesikhathi sanje, yendaweni ezisemkahya nofana emadorobheni lapho iinqhema  zamasiko ahlukahlukeneko zihlanganyela khona. Amagugu angabonakaliko wavusi imibuzo yokuthi imikghwa ethileko iqondene nesiko, kodwana ilekelela ekutheni imiphakathi ibumbane bona bazizwe ayingcenye yomphakathi owodwa  nofana ohlukileko.&lt;ref&gt;[https://ich.unesco.org/en/what-is-intangible-heritage-00003 What is Intangible Cultural Heritage? - UNESCO Intangible Cultural Heritage]&lt;/ref&gt;

== Iinkomba ==
[[Category: Ukubulunga Amagugu]]
[[Category: Amasiko]]
[[Category: Umlando wamasiko]]</text>
      <sha1>epywh8e6q9plr1nok9kqyjh6b8gphbd</sha1>
    </revision>
    <revision>
      <id>5773</id>
      <parentid>5772</parentid>
      <timestamp>2025-09-21T10:44:11Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5773</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4761" sha1="k1d5rg119wo09lg2g640c4ysdgcqyvo" xml:space="preserve">Amagugu
[[Isimumathi:Tsonga girls in South Africa showing off their traditional clothing.jpg|thumb|Abentazana bamaTsonga]]
'''Amagugu''' akhuluma ngamasiko namasiko adluliswelwa kusuka esizukulwaneni ukuya kwesinye isizukulwane aphethe indlela yokwenza izinto zokwenza izinto zamasiko ahlukahlukeneko, ukuziphatha, ikambiso ekungiyo ehlathulula  umphakathi begodu inikele abantu ubunjalo babo, bazizwe bamukelekile.&lt;ref&gt;[https://dictionary.cambridge.org/dictionary/english/heritage HERITAGE | English meaning - Cambridge Dictionary]&lt;/ref&gt; Ukwenza isibonelo, amagugu angafaka hlangana umlando womndeni; ukuzibandakanya kwabo nekolo abayilandelako; nofana amasiko wamasiko. Nanyana kunjalo amagugu afaka hlangana nalokho okuyingcenye yokuzwisisa kwesitjhaba. Umuntu obelethwe eSewula Afrika, ngokwesibonelo, unegugu lenarha yeSewula Afrika, kanye nelifa lomuntu mathupha neliyifihlo. Umuntu onjalo angathathwa njengomuntu onelifa le-Afrika, ngombana wabelethwa enarhakazini ye-Afrika.

=== Imihlobo yamagugu ===

==== Amagugu ngamasiko ====
[[Isimumathi:South Africa Shy Ndebele Woman (4608424073).jpg|thumb|Umma weNdebele]]
Lokhu kufaka hlangana ubukgwari, umtlolo, umvumo nokhunye, ekuyindlela yokuziveza  ngobukghwari besiye nesinye isitjhaba. Amagugug la afaka hlangana amasiko nofana ikambiso evela kwabadala yadluliselwa esizukulwaneni sanje. Amagugu ngamasiko angafaka indlea yokugida, ukwenziwa kweminyanya ulandela ikambiso ethileko nokuthi  imvelo iphathwa bunjani.Baveza amagugu wamasiko &quot;njengezinto ezibonakalako kanye nezinto ezingaphathekiko zesiqhema nofana zomphakathi.&quot; Izinto ezibonakalako zingahluka khulu; i-2009 UNESCO Framework for Cultural Statistics glossary ibala &quot;izikhumbuzo, isiqhema sezakhiwo namasayithi, iminyuziyamu enamagugu ahlukahlukeneko afakahlangana amatshwayo, umlando, ubuhle, ubuhlanga nofana ubuntu, isayensi nokuqakatheka kwezenhlalakahle.&quot; Lokhu ngikho okubizwa yi-Fremework glossary ngokuthi &quot;amagugu aphathekako (athuthekako, angakhambiko nangaphasi kwamanzi).&quot; Irhelo lalokho okuligugu eliphathekako alipheleli, ngombana lingafaka hlangana okunengi ukudlula iinkhumbuzo zomphakathi nofana izakhiwo. Kunezinto ngaphakathi kwemyuziyamu. Imisebenzi yobukghwari, iincwadi, izinto ezikhunjulwako, iinkhali, ukubumba, izinto ezitholwe ziinthombe zakade.&lt;ref&gt;[https://rotel.pressbooks.pub/heritagesofchange/chapter/part-1-what-is-cultural-heritage/ &lt;nowiki&gt;Part 1: What is Cultural Heritage? – Heritages of Change: Curatorial Activism and First-Year Writing [Revised Edition]&lt;/nowiki&gt;]&lt;/ref&gt;

==== Amagugu womlando ====
Lapho sikhuluma ngezinto ezibambekako nofana  ezingabambekiko zakudala ezifana nemakhiwo, izinto ezubunjiweko namasiko lawa aphethe umlando oqakathekilekowesitjhaba esithileko. Amagugu alekelela  abantu bona bafunde ngezinto zesikhathi sakade, ukuzwisisa amatjhuguluko anzekako emphakathini nokuthi kwenzeke irhubhululo ngomalndo wabantu nofana wezinto.&lt;ref&gt;[https://sahistory.org.za/article/what-heritage What is heritage? | South African History Online]&lt;/ref&gt; Indawo lezi zidosa abavakatjhi bonyana bavakatjhele indawo lapho imakhiwo enomlando inomlando ikhona.Isibonelo i-Roben island ingeye yendawo yamagugu eziphethe umlando wombuso wegandelelo eSewula Afrika.

==== Amagugu wemvelo ====
Amagugu wemvelo afaka iindawo, nehlelo lemvelo ekuyizinto ezithathwa njengokuthi kufanele bona zibulungelwe isizukulwane esizako. Igugu lemvelo leSewula Afrika lakhiwe ziiNdawo zamagugu wePhasi kanye neentaba zawo ezihle, iinlwana zeganga ezifakahlangana ‘''i-Big Five''’, iintjalo, iinyoni  nazo yoke ikariso mraro yemvelo yephasi, eendaweni ezisewula khulu ye-Afrika.Ngalokhu sifisa ukunikela zoke izakhamuzi amandla wokufunda ngamagugu wazo ngelimi lazo, zizikhakhazise ngemirabhu yazo begodu zikhambe ziye esikhathini esizako ngokuzwisisa nokuhlonipha ubuhle bemvelo bezwe elikhulu leli.

==== Amagugu angabonakaliko ====
[[Isimumathi:Swazi Warriors.jpg|thumb|Amadoda wamaSwati]]
Magugu apheth izinto ezingabonakaliko ngokomzimba zamasiko ezifana nama namasiko nendlela yokuwenza, ilwazi elidluliselwa  ngomlomo nangokufundisa ngokwenza. Amagugu angabonakaliko angahlala angakhombisi ukudlulisw kwamasiko wakudala kodwana imikhuba yesikhathi sanje, yendaweni ezisemkahya nofana emadorobheni lapho iinqhema  zamasiko ahlukahlukeneko zihlanganyela khona. Amagugu angabonakaliko wavusi imibuzo yokuthi imikghwa ethileko iqondene nesiko, kodwana ilekelela ekutheni imiphakathi ibumbane bona bazizwe ayingcenye yomphakathi owodwa  nofana ohlukileko.&lt;ref&gt;[https://ich.unesco.org/en/what-is-intangible-heritage-00003 What is Intangible Cultural Heritage? - UNESCO Intangible Cultural Heritage]&lt;/ref&gt;

== Iinkomba ==
[[Category: Ukubulunga Amagugu]]
[[Category: Amasiko]]
[[Category: Umlando wamasiko]]</text>
      <sha1>k1d5rg119wo09lg2g640c4ysdgcqyvo</sha1>
    </revision>
    <revision>
      <id>5774</id>
      <parentid>5773</parentid>
      <timestamp>2025-09-21T10:47:07Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5774</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4945" sha1="iqvmmqixtm6dgxcjnybxvafvp1g8mod" xml:space="preserve">Amagugu
[[Isimumathi:Tsonga girls in South Africa showing off their traditional clothing.jpg|thumb|Abentazana bamaTsonga]]
'''Amagugu''' akhuluma ngamasiko namasiko adluliswelwa kusuka esizukulwaneni ukuya kwesinye isizukulwane aphethe indlela yokwenza izinto zokwenza izinto zamasiko ahlukahlukeneko, ukuziphatha, ikambiso ekungiyo ehlathulula  umphakathi begodu inikele abantu ubunjalo babo, bazizwe bamukelekile.&lt;ref&gt;[https://dictionary.cambridge.org/dictionary/english/heritage HERITAGE | English meaning - Cambridge Dictionary]&lt;/ref&gt; Ukwenza isibonelo, amagugu angafaka hlangana umlando womndeni; ukuzibandakanya kwabo nekolo abayilandelako; nofana amasiko wamasiko. Nanyana kunjalo amagugu afaka hlangana nalokho okuyingcenye yokuzwisisa kwesitjhaba. Umuntu obelethwe eSewula Afrika, ngokwesibonelo, unegugu lenarha yeSewula Afrika, kanye nelifa lomuntu mathupha neliyifihlo. Umuntu onjalo angathathwa njengomuntu onelifa le-Afrika, ngombana wabelethwa enarhakazini ye-Afrika.&lt;ref&gt;Harrison, R., 2010. What is heritage. ''Understanding the politics of heritage'', ''9''.&lt;/ref&gt;

=== Imihlobo yamagugu ===

==== Amagugu ngamasiko ====
[[Isimumathi:South Africa Shy Ndebele Woman (4608424073).jpg|thumb|Umma weNdebele]]
Lokhu kufaka hlangana ubukgwari, umtlolo, umvumo nokhunye, ekuyindlela yokuziveza  ngobukghwari besiye nesinye isitjhaba. Amagugug la afaka hlangana amasiko nofana ikambiso evela kwabadala yadluliselwa esizukulwaneni sanje. Amagugu ngamasiko angafaka indlea yokugida, ukwenziwa kweminyanya ulandela ikambiso ethileko nokuthi  imvelo iphathwa bunjani.&lt;ref&gt;Heritage, U.I.C., 2019. ''What is intangible cultural heritage'' [online]&lt;/ref&gt; Baveza amagugu wamasiko &quot;njengezinto ezibonakalako kanye nezinto ezingaphathekiko zesiqhema nofana zomphakathi.&quot; Izinto ezibonakalako zingahluka khulu; i-2009 UNESCO Framework for Cultural Statistics glossary ibala &quot;izikhumbuzo, isiqhema sezakhiwo namasayithi, iminyuziyamu enamagugu ahlukahlukeneko afakahlangana amatshwayo, umlando, ubuhle, ubuhlanga nofana ubuntu, isayensi nokuqakatheka kwezenhlalakahle.&quot; Lokhu ngikho okubizwa yi-Fremework glossary ngokuthi &quot;amagugu aphathekako (athuthekako, angakhambiko nangaphasi kwamanzi).&quot; Irhelo lalokho okuligugu eliphathekako alipheleli, ngombana lingafaka hlangana okunengi ukudlula iinkhumbuzo zomphakathi nofana izakhiwo. Kunezinto ngaphakathi kwemyuziyamu. Imisebenzi yobukghwari, iincwadi, izinto ezikhunjulwako, iinkhali, ukubumba, izinto ezitholwe ziinthombe zakade.&lt;ref&gt;[https://rotel.pressbooks.pub/heritagesofchange/chapter/part-1-what-is-cultural-heritage/ &lt;nowiki&gt;Part 1: What is Cultural Heritage? – Heritages of Change: Curatorial Activism and First-Year Writing [Revised Edition]&lt;/nowiki&gt;]&lt;/ref&gt;

==== Amagugu womlando ====
Lapho sikhuluma ngezinto ezibambekako nofana  ezingabambekiko zakudala ezifana nemakhiwo, izinto ezubunjiweko namasiko lawa aphethe umlando oqakathekilekowesitjhaba esithileko. Amagugu alekelela  abantu bona bafunde ngezinto zesikhathi sakade, ukuzwisisa amatjhuguluko anzekako emphakathini nokuthi kwenzeke irhubhululo ngomalndo wabantu nofana wezinto.&lt;ref&gt;[https://sahistory.org.za/article/what-heritage What is heritage? | South African History Online]&lt;/ref&gt; Indawo lezi zidosa abavakatjhi bonyana bavakatjhele indawo lapho imakhiwo enomlando inomlando ikhona.Isibonelo i-Roben island ingeye yendawo yamagugu eziphethe umlando wombuso wegandelelo eSewula Afrika.

==== Amagugu wemvelo ====
Amagugu wemvelo afaka iindawo, nehlelo lemvelo ekuyizinto ezithathwa njengokuthi kufanele bona zibulungelwe isizukulwane esizako. Igugu lemvelo leSewula Afrika lakhiwe ziiNdawo zamagugu wePhasi kanye neentaba zawo ezihle, iinlwana zeganga ezifakahlangana ‘''i-Big Five''’, iintjalo, iinyoni  nazo yoke ikariso mraro yemvelo yephasi, eendaweni ezisewula khulu ye-Afrika.Ngalokhu sifisa ukunikela zoke izakhamuzi amandla wokufunda ngamagugu wazo ngelimi lazo, zizikhakhazise ngemirabhu yazo begodu zikhambe ziye esikhathini esizako ngokuzwisisa nokuhlonipha ubuhle bemvelo bezwe elikhulu leli.

==== Amagugu angabonakaliko ====
[[Isimumathi:Swazi Warriors.jpg|thumb|Amadoda wamaSwati]]
Magugu apheth izinto ezingabonakaliko ngokomzimba zamasiko ezifana nama namasiko nendlela yokuwenza, ilwazi elidluliselwa  ngomlomo nangokufundisa ngokwenza. Amagugu angabonakaliko angahlala angakhombisi ukudlulisw kwamasiko wakudala kodwana imikhuba yesikhathi sanje, yendaweni ezisemkahya nofana emadorobheni lapho iinqhema  zamasiko ahlukahlukeneko zihlanganyela khona. Amagugu angabonakaliko wavusi imibuzo yokuthi imikghwa ethileko iqondene nesiko, kodwana ilekelela ekutheni imiphakathi ibumbane bona bazizwe ayingcenye yomphakathi owodwa  nofana ohlukileko.&lt;ref&gt;[https://ich.unesco.org/en/what-is-intangible-heritage-00003 What is Intangible Cultural Heritage? - UNESCO Intangible Cultural Heritage]&lt;/ref&gt;

== Iinkomba ==
[[Category: Ukubulunga Amagugu]]
[[Category: Amasiko]]
[[Category: Umlando wamasiko]]</text>
      <sha1>iqvmmqixtm6dgxcjnybxvafvp1g8mod</sha1>
    </revision>
    <revision>
      <id>5775</id>
      <parentid>5774</parentid>
      <timestamp>2025-09-21T10:48:47Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5775</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4949" sha1="aox3yvfk7pqohigzh4bd9a9rt66n3n3" xml:space="preserve">Amagugu
[[Isimumathi:Tsonga girls in South Africa showing off their traditional clothing.jpg|thumb|Abentazana bamaTsonga]]
'''Amagugu''' akhuluma ngamasiko namasiko adluliswelwa kusuka esizukulwaneni ukuya kwesinye isizukulwane aphethe indlela yokwenza izinto zokwenza izinto z[[amasiko]] ahlukahlukeneko, ukuziphatha, ikambiso ekungiyo ehlathulula  umphakathi begodu inikele abantu ubunjalo babo, bazizwe bamukelekile.&lt;ref&gt;[https://dictionary.cambridge.org/dictionary/english/heritage HERITAGE | English meaning - Cambridge Dictionary]&lt;/ref&gt; Ukwenza isibonelo, amagugu angafaka hlangana umlando womndeni; ukuzibandakanya kwabo nekolo abayilandelako; nofana amasiko wamasiko. Nanyana kunjalo amagugu afaka hlangana nalokho okuyingcenye yokuzwisisa kwesitjhaba. Umuntu obelethwe eSewula Afrika, ngokwesibonelo, unegugu lenarha yeSewula Afrika, kanye nelifa lomuntu mathupha neliyifihlo. Umuntu onjalo angathathwa njengomuntu onelifa le-Afrika, ngombana wabelethwa enarhakazini ye-Afrika.&lt;ref&gt;Harrison, R., 2010. What is heritage. ''Understanding the politics of heritage'', ''9''.&lt;/ref&gt;

=== Imihlobo yamagugu ===

==== Amagugu ngamasiko ====
[[Isimumathi:South Africa Shy Ndebele Woman (4608424073).jpg|thumb|Umma weNdebele]]
Lokhu kufaka hlangana ubukgwari, umtlolo, umvumo nokhunye, ekuyindlela yokuziveza  ngobukghwari besiye nesinye isitjhaba. Amagugug la afaka hlangana amasiko nofana ikambiso evela kwabadala yadluliselwa esizukulwaneni sanje. Amagugu ngamasiko angafaka indlea yokugida, ukwenziwa kweminyanya ulandela ikambiso ethileko nokuthi  imvelo iphathwa bunjani.&lt;ref&gt;Heritage, U.I.C., 2019. ''What is intangible cultural heritage'' [online]&lt;/ref&gt; Baveza amagugu wamasiko &quot;njengezinto ezibonakalako kanye nezinto ezingaphathekiko zesiqhema nofana zomphakathi.&quot; Izinto ezibonakalako zingahluka khulu; i-2009 UNESCO Framework for Cultural Statistics glossary ibala &quot;izikhumbuzo, isiqhema sezakhiwo namasayithi, iminyuziyamu enamagugu ahlukahlukeneko afakahlangana amatshwayo, umlando, ubuhle, ubuhlanga nofana ubuntu, isayensi nokuqakatheka kwezenhlalakahle.&quot; Lokhu ngikho okubizwa yi-Fremework glossary ngokuthi &quot;amagugu aphathekako (athuthekako, angakhambiko nangaphasi kwamanzi).&quot; Irhelo lalokho okuligugu eliphathekako alipheleli, ngombana lingafaka hlangana okunengi ukudlula iinkhumbuzo zomphakathi nofana izakhiwo. Kunezinto ngaphakathi kwemyuziyamu. Imisebenzi yobukghwari, iincwadi, izinto ezikhunjulwako, iinkhali, ukubumba, izinto ezitholwe ziinthombe zakade.&lt;ref&gt;[https://rotel.pressbooks.pub/heritagesofchange/chapter/part-1-what-is-cultural-heritage/ &lt;nowiki&gt;Part 1: What is Cultural Heritage? – Heritages of Change: Curatorial Activism and First-Year Writing [Revised Edition]&lt;/nowiki&gt;]&lt;/ref&gt;

==== Amagugu womlando ====
Lapho sikhuluma ngezinto ezibambekako nofana  ezingabambekiko zakudala ezifana nemakhiwo, izinto ezubunjiweko namasiko lawa aphethe umlando oqakathekilekowesitjhaba esithileko. Amagugu alekelela  abantu bona bafunde ngezinto zesikhathi sakade, ukuzwisisa amatjhuguluko anzekako emphakathini nokuthi kwenzeke irhubhululo ngomalndo wabantu nofana wezinto.&lt;ref&gt;[https://sahistory.org.za/article/what-heritage What is heritage? | South African History Online]&lt;/ref&gt; Indawo lezi zidosa abavakatjhi bonyana bavakatjhele indawo lapho imakhiwo enomlando inomlando ikhona.Isibonelo i-Roben island ingeye yendawo yamagugu eziphethe umlando wombuso wegandelelo eSewula Afrika.

==== Amagugu wemvelo ====
Amagugu wemvelo afaka iindawo, nehlelo lemvelo ekuyizinto ezithathwa njengokuthi kufanele bona zibulungelwe isizukulwane esizako. Igugu lemvelo leSewula Afrika lakhiwe ziiNdawo zamagugu wePhasi kanye neentaba zawo ezihle, iinlwana zeganga ezifakahlangana ‘''i-Big Five''’, iintjalo, iinyoni  nazo yoke ikariso mraro yemvelo yephasi, eendaweni ezisewula khulu ye-Afrika.Ngalokhu sifisa ukunikela zoke izakhamuzi amandla wokufunda ngamagugu wazo ngelimi lazo, zizikhakhazise ngemirabhu yazo begodu zikhambe ziye esikhathini esizako ngokuzwisisa nokuhlonipha ubuhle bemvelo bezwe elikhulu leli.

==== Amagugu angabonakaliko ====
[[Isimumathi:Swazi Warriors.jpg|thumb|Amadoda wamaSwati]]
Magugu apheth izinto ezingabonakaliko ngokomzimba zamasiko ezifana nama namasiko nendlela yokuwenza, ilwazi elidluliselwa  ngomlomo nangokufundisa ngokwenza. Amagugu angabonakaliko angahlala angakhombisi ukudlulisw kwamasiko wakudala kodwana imikhuba yesikhathi sanje, yendaweni ezisemkahya nofana emadorobheni lapho iinqhema  zamasiko ahlukahlukeneko zihlanganyela khona. Amagugu angabonakaliko wavusi imibuzo yokuthi imikghwa ethileko iqondene nesiko, kodwana ilekelela ekutheni imiphakathi ibumbane bona bazizwe ayingcenye yomphakathi owodwa  nofana ohlukileko.&lt;ref&gt;[https://ich.unesco.org/en/what-is-intangible-heritage-00003 What is Intangible Cultural Heritage? - UNESCO Intangible Cultural Heritage]&lt;/ref&gt;

== Iinkomba ==
[[Category: Ukubulunga Amagugu]]
[[Category: Amasiko]]
[[Category: Umlando wamasiko]]</text>
      <sha1>aox3yvfk7pqohigzh4bd9a9rt66n3n3</sha1>
    </revision>
  </page>
  <page>
    <title>Mbombela</title>
    <ns>0</ns>
    <id>950</id>
    <revision>
      <id>5802</id>
      <timestamp>2025-09-28T23:41:45Z</timestamp>
      <contributor>
        <username>Mojonom</username>
        <id>593</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1311296106|Mbombela]]&quot;</comment>
      <origin>5802</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2283" sha1="2ack40vrli9mv1bib625ui18kynsjzm" xml:space="preserve">
'''I-Mbombela,''' ebegade ibizwa nge Nelspruit, kulidorobha elinzinze eTlhagwini Pumalanga ye[[Isewula Afrika|Sewula Afrika]] Kulidorobha elikhulu lesifunda i[[:en:Mpumalanga|Mpumalanga]]. Idorobheli pheze likude ngamakhilomitha ali-110 nomkhawulo wenarha [[Mozambique|iMozambique]], amakhilomitha ama-330 nomkhawulo wedorobha le[[Johannesburg|Jwanasbhege]]. Liphinde godu libe kude ngamakhilomitha ama-82 nomkhawulo wenarha ye[[Eswatini|Swazini]]. I-Mbombela bekungelinye lamadorobha ebelineemvakatjhi ngesikhathi se [[:en:2010_FIFA_World_Cup|2010 FIFA World Cup]]. Lokhu kungombanyana iMbombela Stadium bekungenye yeenkundla lapha bekudlalwa khona ibholo [[:en:2010_FIFA_World_Cup|yebhigiri yephasi ngomnyaka wee-2010.]]

=== Ukutjhuguluka kwebizo ===
Ngenyanga kaSewula ngomnyaka wee-2009, urhulumende weSewula Afrika watjhugulula igama likamasipala wendawo le nge Mbombela. IKruger Lowveld Chamber of Business and Tourisim batjhinga e[[:en:High_Court_of_South_Africa|Khoto ePhakemeko yeSewula Afrika]] ukuyokufaka isibawo sokuphikisana nesiqunto, bebaveza neenzathu zokobanyana akhange kwaziswe inengi labantu begodu azikho neemali ezilingeneko edorobheni bonyana kungabhadalelwa ukutjhugulula amatshwayo wendlela kunye namakhasi wezethungelelwano. Kanti ke, Igama leli laqgina litjhugululwe ngomnyaka wee-2014 yi[[:en:North_Gauteng_High_Court|Khotho Ekulu YeTlhagwini ye Gauteng]]. Ibizo elithi 'Mbombela' kulibizo lelimi lesi[[:en:Swazi_language|Swazi]] elitjho ukuthi &quot;Abantu abanengi bahlanganyelene endaweni encani&quot;.

== Zokuthutha ==
Idorobha leMbombela lineenthuthi ezijwayelekileko zama Taxi. Ezithutha abantu kusuka eendaweni ezisemalokitjhini aseduze zibase edorobheni, emisebenzini kunye neendaweni lapha bafunyana iinsiza. Kanti godu, Indawo ye Nelspruit izele ngokunengi ngamabhesi weKampani i Buscor, ekungezinye zeenthuthi eziveleleko eendaweni zedorobha leli namaphethelo. 

== Zemidlalo ==
[[Isimumathi:Mbombela_Stadium_Aerial_View.jpg|alt=|thumb|Ikundla ye-Mbombela]]

=== I Stadium seMbombela ===
 
Ikundla yezemidlalo ye-Mbombela yakhiwa njengekundla yebholo kamakhakhulararhwe. Yacedwa ukwakhiwa ngenyanga kaSinyikhaba ngomnyaka wee-2009.  Bekunyenye yekundla yezemidlalo ebeyibambe imidlalo ye[[:en:2010_FIFA_World_Cup|bhigiri yephasi yomnyaka ka 2010.]]</text>
      <sha1>2ack40vrli9mv1bib625ui18kynsjzm</sha1>
    </revision>
    <revision>
      <id>5938</id>
      <parentid>5802</parentid>
      <timestamp>2025-11-01T11:48:43Z</timestamp>
      <contributor>
        <username>Hlalithwa</username>
        <id>996</id>
      </contributor>
      <minor />
      <comment>Spelling errors and grammar</comment>
      <origin>5938</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2306" sha1="eeec6syd5um3a7whl3nmqahaoaezdbn" xml:space="preserve">
'''I-Mbombela,''' ebegade ibizwa nge Nelspruit, kulidorobha elinzinze eTlhagwini Pumalanga ye[[Isewula Afrika|Sewula Afrika]] Kulidorobha elikhulu lesifunda [[:en:Mpumalanga|seMpumalanga]]. Idorobheli pheze likude ngamakhilomitha ali-110 nomkhawulo wenarha [[Mozambique|iMozambique]], amakhilomitha ama-330 nomkhawulo wedorobha le[[Johannesburg|-Jwanasbhege]]. Liphinde godu libe kude ngamakhilomitha ama-82 nomkhawulo wenarha ye[[Eswatini|Swazini]]. I-Mbombela bekungelinye lamadorobha ebelineemvakatjhi ngesikhathi se [[:en:2010_FIFA_World_Cup|2010 FIFA World Cup]]. Lokhu kungombana iMbombela Stadium bekungenye yeenkundla lapha bekudlalelwa khona ibholo [[:en:2010_FIFA_World_Cup|yebhigiri yephasi ngomnyaka wee-2010.]]

=== Ukutjhuguluka kwebizo ===
Ngenyanga kaSewula ngomnyaka wee-2009, urhulumende weSewula Afrika watjhugulula igama likamasipala wendawo le yathiywa nge Mbombela. IKruger Lowveld Chamber of Business and Tourisim batjhinga e[[:en:High_Court_of_South_Africa|Khoto ePhakemeko yeSewula Afrika]] ukuyokufaka isibawo sokuphikisana nesiqunto esathathwako, bebaveza neenzathu zokobanyana akhange kwaziswe inengi labantu begodu azikho neemali ezilingeneko edorobheni bonyana kungabhadalelwa ukutjhugulula amatshwayo wendlela kunye namakhasi wezethungelelwano. Kanti ke, Igama leli lagcina litjhugululwe ngomnyaka wee-2014 yi[[:en:North_Gauteng_High_Court|Khotho Ekulu YeTlhagwini ye Gauteng]]. Ibizo elithi 'Mbombela' kulibizo lelimi lesi[[:en:Swazi_language|Swazi]] elitjho ukuthi &quot;Abantu abanengi bahlanganyelene endaweni encani&quot;.

== Zokuthutha ==
Idorobha leMbombela lineenthuthi ezijwayelekileko zama Taxi. Ezithutha abantu kusuka eendaweni ezisemalokitjhini aseduze zibase edorobheni, emisebenzini kunye neendaweni lapha bafunyana iinsiza. Kanti godu, Indawo ye Nelspruit izele ngokunengi ngamabhesi weKampani i Buscor, ekungezinye zeenthuthi eziveleleko eendaweni zedorobha leli namaphethelo. 

== Zemidlalo ==
[[Isimumathi:Mbombela_Stadium_Aerial_View.jpg|alt=|thumb|Ikundla ye-Mbombela]]

=== I Stadium seMbombela ===
 
Ikundla yezemidlalo ye-Mbombela yakhiwa njengekundla yebholo kamakhakhulararhwe. Yacedwa ukwakhiwa ngenyanga kaSinyikhaba ngomnyaka wee-2009.  Bekungenye yeenkundla zemidlalo ebeyibambe imidlalo ye[[:en:2010_FIFA_World_Cup|bhigiri yephasi yomnyaka ka 2010.]]</text>
      <sha1>eeec6syd5um3a7whl3nmqahaoaezdbn</sha1>
    </revision>
  </page>
  <page>
    <title>Ukufaka hlangana (ifundo)</title>
    <ns>0</ns>
    <id>951</id>
    <revision>
      <id>5805</id>
      <timestamp>2025-09-29T11:08:04Z</timestamp>
      <contributor>
        <username>Hlalithwa</username>
        <id>996</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1309941514|Inclusion (education)]]&quot;</comment>
      <origin>5805</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1215" sha1="3ga1j71n3vrg0sjc1ws5f8ojheej6e1" xml:space="preserve">'''Ukufaka hlangana''' [[Ifundo|emfundweni]] kutjho ukufaka hlangana boke abafundi bona bafinyelele emathubeni alinganako wefundo nokufunda,  begodu kuhlukile ekulinganiseni kwefundo nofana ukulingana kwefundo. Yavela ngokommongo wefundo ekhethekileko ngehlelo lefundo elikhethekileko nofana ihlelo lamakhulu amahlanu nane (504), begodu yakhiwe emqondweni wokobana kuphumelela khulu ebafundini abaneemfuno ezikhethekileko ukuba nesipiliyoni esihlukileko esitjhiwoko ukuze baphumelele khulu ekusebenzisaneni nomphakathi okurholela ekuphumeleleni okungezeleliweko epilweni. Ifilosofi yokusetjenziswa kwemodeli yokufaka hlangana ayibeki phambili, kodwana isahlinzeka ngokusetjenziswa kwamakilasi akhethekileko neenkolo ezikhethekileko zokufundisa abafundi abakhubazekileko. Amamodeli wefundo afaka woke umuntu athonywa ngabaphathi bezefundo ngehloso yokusuka emamodelini wokuzihlukanisa wefundo ekhethekileko ukuya ngezinga elipheleleko elisebenzako, umqondo kukuthi kuzokuzuzisa umphakathi wabafundi befundo jikelele nabafundi befundo ekhethekileko ngokufanako, lapho abafundi abanekghono khulu basebenze njengamamodeli wabontanga begodu labo abangakwaziko basebenze njengesikhuthazo sokufunda ngokuzwelana nabafundi.</text>
      <sha1>3ga1j71n3vrg0sjc1ws5f8ojheej6e1</sha1>
    </revision>
    <revision>
      <id>5808</id>
      <parentid>5805</parentid>
      <timestamp>2025-09-29T11:10:00Z</timestamp>
      <contributor>
        <username>Hlalithwa</username>
        <id>996</id>
      </contributor>
      <comment>Spelling</comment>
      <origin>5808</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1216" sha1="m5juxie8h1si6rzorbsq62gqfikk6hh" xml:space="preserve">'''Ukufaka hlangana''' [[Ifundo|emfundweni]] kutjho ukufaka hlangana boke abafundi bona bafinyelele emathubeni alinganako wefundo nokufunda,  begodu kuhlukile ekulinganiseni kwefundo nofana ukulingana kwefundo. Yavela ngokommongo wefundo ekhethekileko ngehlelo lefundo elikhethekileko nofana ihlelo lamakhulu amahlanu nane (504), begodu yakhiwe emqondweni wokobana kuphumelela khulu ebafundini abaneemfundo ezikhethekileko ukuba nesipiliyoni esihlukileko esitjhiwoko ukuze baphumelele khulu ekusebenzisaneni nomphakathi okurholela ekuphumeleleni okungezeleliweko epilweni. Ifilosofi yokusetjenziswa kwemodeli yokufaka hlangana ayibeki phambili, kodwana isahlinzeka ngokusetjenziswa kwamakilasi akhethekileko neenkolo ezikhethekileko zokufundisa abafundi abakhubazekileko. Amamodeli wefundo afaka woke umuntu athonywa ngabaphathi bezefundo ngehloso yokusuka emamodelini wokuzihlukanisa wefundo ekhethekileko ukuya ngezinga elipheleleko elisebenzako, umqondo kukuthi kuzokuzuzisa umphakathi wabafundi befundo jikelele nabafundi befundo ekhethekileko ngokufanako, lapho abafundi abanekghono khulu basebenze njengamamodeli wabontanga begodu labo abangakwaziko basebenze njengesikhuthazo sokufunda ngokuzwelana nabafundi.</text>
      <sha1>m5juxie8h1si6rzorbsq62gqfikk6hh</sha1>
    </revision>
    <revision>
      <id>5818</id>
      <parentid>5808</parentid>
      <timestamp>2025-09-29T12:37:27Z</timestamp>
      <contributor>
        <username>Hlalithwa</username>
        <id>996</id>
      </contributor>
      <origin>5818</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1229" sha1="1d5ma01bi7s8rjazpovav56zpu6w5qc" xml:space="preserve">'''Ukufaka hlangana''' [[Ifundo|emfundweni]] kutjho ukufaka hlangana boke abafundi bona bafinyelele emathubeni alinganako wefundo nokufunda,  begodu kuhlukile ekulinganisweni kwefundo nofana ukulingana kwefundo. Yavela ngokommongo wefundo ekhethekileko ngehlelo lefundo elikhethekileko nofana ihlelo lamakhulu amahlanu nane (504), begodu yakhiwe emqondweni wokobana kuphumelela khulu ebafundini abaneemfundo ezikhethekileko ukuba nesipiliyoni esihlukileko ekukhulunywa ngaso ukuze baphumelele ekusebenzisaneni nomphakathi okurholela ekuphumeleleni okungezeleliweko epilweni. Ifilosofi yokusetjenziswa kwemodeli yokufaka hlangana ayibandakanyi boke abafundi, kodwana isahlinzeka ngokusetjenziswa kwamakilasi akhethekileko neenkolo ezikhethekileko zokufundisa abafundi abakhubazekileko. Amamodeli wefundo afaka woke umuntu athonywa ngabaphathi bezefundo ngehloso yokusuka emamodelini wokuzihlukanisa wefundo ekhethekileko ukuya ngezinga elipheleleko elisebenzako, umqondo kukuthi kuzokuzuzisa umphakathi wabafundi befundo jikelele nabafundi befundo ekhethekileko ngokufanako, lapho abafundi abanekghono khulu basebenze njengamamodeli wabontanga begodu labo abangakwaziko basebenze njengesikhuthazo sokufunda ngokuzwelana nabafundi.</text>
      <sha1>1d5ma01bi7s8rjazpovav56zpu6w5qc</sha1>
    </revision>
    <revision>
      <id>5820</id>
      <parentid>5818</parentid>
      <timestamp>2025-09-29T12:38:41Z</timestamp>
      <contributor>
        <username>Hlalithwa</username>
        <id>996</id>
      </contributor>
      <origin>5820</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1235" sha1="fb8t2nbr66zsd0vd5mg78piuhjk2ly3" xml:space="preserve">'''Ukufaka hlangana''' [[Ifundo|emfundweni]] kutjho ukufaka hlangana boke abafundi bona bafinyelele emathubeni alinganako wefundo nokufunda,  begodu kuhlukile ekulinganisweni kwefundo nofana ukulingana kwefundo. Yavela ngokommongo wefundo ekhethekileko ngehlelo lefundo elikhethekileko nofana ihlelo lamakhulu amahlanu nane (504), begodu yakhiwe emqondweni wokobana kuphumelela khulu ebafundini abaneemfundo ezikhethekileko ukuba nesipiliyoni esihlukileko ekukhulunywa ngaso ukuze baphumelele ekusebenzisaneni nomphakathi okurholela ekuphumeleleni okungezeleliweko empilweni zabo. Ifilosofi yokusetjenziswa kwemodeli yokufaka hlangana ayibandakanyi boke abafundi, kodwana isahlinzeka ngokusetjenziswa kwamakilasi akhethekileko neenkolo ezikhethekileko zokufundisa abafundi abakhubazekileko. Amamodeli wefundo afaka woke umuntu athonywa ngabaphathi bezefundo ngehloso yokusuka emamodelini wokuzihlukanisa wefundo ekhethekileko ukuya ngezinga elipheleleko elisebenzako, umqondo kukuthi kuzokuzuzisa umphakathi wabafundi befundo jikelele nabafundi befundo ekhethekileko ngokufanako, lapho abafundi abanekghono khulu basebenze njengamamodeli wabontanga begodu labo abangakwaziko basebenze njengesikhuthazo sokufunda ngokuzwelana nabafundi.</text>
      <sha1>fb8t2nbr66zsd0vd5mg78piuhjk2ly3</sha1>
    </revision>
    <revision>
      <id>5828</id>
      <parentid>5820</parentid>
      <timestamp>2025-09-29T13:19:55Z</timestamp>
      <contributor>
        <username>Hlalithwa</username>
        <id>996</id>
      </contributor>
      <comment>Isilululwazi</comment>
      <origin>5828</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1332" sha1="px3u40l5gehxxg3gk8sontv132yu2ld" xml:space="preserve">'''Ukufaka hlangana''' [[Ifundo|emfundweni]] kutjho ukufaka hlangana boke abafundi bona bafinyelele emathubeni alinganako wefundo nokufunda,  begodu kuhlukile ekulinganisweni kwefundo nofana ukulingana kwefundo. Yavela ngokommongo wefundo ekhethekileko ngehlelo lefundo elikhethekileko nofana ihlelo lamakhulu amahlanu nane (504), begodu yakhiwe emqondweni wokobana kuphumelela khulu ebafundini abaneemfundo ezikhethekileko ukuba nesipiliyoni esihlukileko ekukhulunywa ngaso ukuze baphumelele ekusebenzisaneni nomphakathi okurholela ekuphumeleleni okungezeleliweko empilweni zabo. Ifilosofi yokusetjenziswa kwemodeli yokufaka hlangana ayibandakanyi boke abafundi, kodwana isahlinzeka ngokusetjenziswa kwamakilasi akhethekileko neenkolo ezikhethekileko zokufundisa abafundi abakhubazekileko. Amamodeli wefundo afaka woke umuntu athonywa ngabaphathi bezefundo ngehloso yokusuka emamodelini wokuzihlukanisa wefundo ekhethekileko ukuya ngezinga elipheleleko elisebenzako, umqondo kukuthi kuzokuzuzisa umphakathi wabafundi befundo jikelele nabafundi befundo ekhethekileko ngokufanako, lapho abafundi abanekghono khulu basebenze njengamamodeli wabontanga begodu labo abangakwaziko basebenze njengesikhuthazo sokufunda ngokuzwelana nabafundi.&lt;ref&gt;https://www.tandfonline.com/doi/full/10.1080/13603116.2017.1412506&lt;/ref&gt;

== Isilululwazi ==</text>
      <sha1>px3u40l5gehxxg3gk8sontv132yu2ld</sha1>
    </revision>
  </page>
  <page>
    <title>I-Rivonia Trial</title>
    <ns>0</ns>
    <id>952</id>
    <revision>
      <id>5806</id>
      <timestamp>2025-09-29T11:09:17Z</timestamp>
      <contributor>
        <username>MBIJANA123</username>
        <id>998</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1311869275|Rivonia Trial]]&quot;</comment>
      <origin>5806</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="492" sha1="rxybphhrfserkjpxk5l4duel3zs0zsr" xml:space="preserve">
'''I-Rivonia Trial''' bekuyi-Trayela  eyenzeka eSewula Afrika yesikhathi sebandlululo mhlana amalanga ali-9 kuNobayeni 1963 ukuya mhlana amalanga ali-12 kuMgwengweni 1964, ngemva kokobana isiqhema sabalweli bekululeko sibotjhwe e -Liliesleaf Farm e -Rivonia . Iplasi le beliyindawo eyifihlo lapho kubanjelwa khona imihlangano ye -uMkhonto we Sizwe (MK), iphiko elitjha elihlomileko le -African National Congress .  I-Trayela le yenzeka e -Pitori e- Palace of Justice kanye ne -Old Synagoge .</text>
      <sha1>rxybphhrfserkjpxk5l4duel3zs0zsr</sha1>
    </revision>
    <revision>
      <id>5829</id>
      <parentid>5806</parentid>
      <timestamp>2025-09-29T13:22:08Z</timestamp>
      <contributor>
        <username>MBIJANA123</username>
        <id>998</id>
      </contributor>
      <origin>5829</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="597" sha1="gvgli9ympl4s7u06tmic25car1ce5t7" xml:space="preserve">
'''I-Rivonia Trial''' bekuyi-Trayela  eyenzeka eSewula Afrika yesikhathi sebandlululo mhlana amalanga ali-9 kuNobayeni 1963 ukuya mhlana amalanga ali-12 kuMgwengweni 1964, ngemva kokobana isiqhema sabalweli bekululeko sibotjhwe e -Liliesleaf Farm e -Rivonia . Iplasi le beliyindawo eyifihlo lapho kubanjelwa khona imihlangano ye -uMkhonto we Sizwe (MK), iphiko elitjha elihlomileko le -African National Congress .  I-Trayela le yenzeka e -Pitori e- Palace of Justice kanye ne -Old Synagoge.&lt;ref&gt;https://www.theheritageportal.co.za/article/liliesleaf-making-case-survival&lt;/ref&gt;

== Isilululwazi ==</text>
      <sha1>gvgli9ympl4s7u06tmic25car1ce5t7</sha1>
    </revision>
    <revision>
      <id>5935</id>
      <parentid>5829</parentid>
      <timestamp>2025-10-25T10:38:19Z</timestamp>
      <contributor>
        <username>MBIJANA123</username>
        <id>998</id>
      </contributor>
      <minor />
      <origin>5935</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="594" sha1="lnhu87cs9q6fvs56sv117ojvm87ard4" xml:space="preserve">
'''I-Rivonia Trial''' bekuyi-Trayela  eyenzeka eSewula Afrika yesikhathi sebandlululo mhlana amalanga ali-9 kuNobayeni 1963 ukuya mhlana amalanga ali-12 kuMgwengweni 1964, ngemva kokobana isiqhema sabalweli bekululeko sibotjhwe e -Liliesleaf Farm e -Rivonia . Iplasi le beliyindawo eyifihlo lapho kubanjelwa khona imihlangano ye -uMkhonto we Sizwe (MK), iphiko elitjha elihlomileko le -African National Congress .  I-Trayela le yenzeka e-Pitori e-Palace of Justice kanye ne-Old Synagoge.&lt;ref&gt;https://www.theheritageportal.co.za/article/liliesleaf-making-case-survival&lt;/ref&gt;

== Isilululwazi ==</text>
      <sha1>lnhu87cs9q6fvs56sv117ojvm87ard4</sha1>
    </revision>
  </page>
  <page>
    <title>Ilimi lesiKalanga</title>
    <ns>0</ns>
    <id>953</id>
    <revision>
      <id>5807</id>
      <timestamp>2025-09-29T11:09:27Z</timestamp>
      <contributor>
        <username>Nomsothando</username>
        <id>995</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1305698868|Kalanga language]]&quot;</comment>
      <origin>5807</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="698" sha1="c6ua0atzxl66zmeue1ildjl8iqgvrrd" xml:space="preserve">'''IsiKalanga''' , nofana '''i-TjiKalanga''' (e-Zimbabwe), lilimi lako-Bantu elikhulunywa babantu abasuka enarheni yeZimbabwe kanye ne[[Botswana]] abakhuluma isiKalanga, ekubabantu abayingcenye yelimi lesiShona nofana Shonic(Shona-Nyai). Ilimeli linemidumo yelimi, ukuhlangana kweendebe, imilozi kanye nokuphafuzeka komoya lokha naliphimiswako ilimeli. 

IsiKalanga samukelwe njengelimi elisemthethweni kumThethosisekelo we-Zimbabwe wangomnyaka ka-2013 begodu sifundiswa eenkolweni eendaweni lapho abakhulumi baso babanengi khona. Ilimi lesi-Kalanga lihlobana khulu nelimi le -Nambya, le-TshiVenda, kanye nelimi le [[KheLobedu language|-KheLobedu]] le-Zimbabwe neSewula [[Isewula Afrika|Afrika]] .</text>
      <sha1>c6ua0atzxl66zmeue1ildjl8iqgvrrd</sha1>
    </revision>
  </page>
  <page>
    <title>Ukubasidisi Kwabatjha</title>
    <ns>0</ns>
    <id>954</id>
    <revision>
      <id>5809</id>
      <timestamp>2025-09-29T12:12:56Z</timestamp>
      <contributor>
        <username>Stillbelieveingooddays</username>
        <id>1018</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1311743049|Teenage pregnancy]]&quot;</comment>
      <origin>5809</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1860" sha1="748ixash8y17emgw6v7qwj3mbfnt24p" xml:space="preserve">
'''Ukubasidisi kwabatjha''', okwaziwa nangokuthi '''kukubasebantwini kwabatjha''', kubasidisi komuntu wengubo ongaphasi kweminyaka ematjhumi amabili. 

Ephasini loke, ubudisi bokubasidisi bubangela khulu ukuhlongakala kwabomma nabentazana abaneminyaka elitjhumi nahlanu ukuya kelitjhumi nethoba.  Ihlathululo yokubasidisi kwabatjha ifaka hlangana labo abathathwa njengabantu abadala ngokomthetho enarheni yabo.  Ihlangano yezamaphilo yephasi loke ihlathulula ''ubutjha'' njengesikhathi esiphakathi kweminyaka elitjhumi ukuya kwelitjhumi nethoba.  Ukubasidisi kungenzeka ngokuya emsemeni ngemva kokuthoma kokuvuthwa, okungenzeka ngaphambi kwesikhathi sokuthoma sokuya esikhathini ( ''menarche'' ).  Ebantazaneni abaphilileko, isikhathi sokuthoma sivame ukwenzeka hlangana neminyaka elitjhumi nambili ukuya kwelitjhumi nathathu. 

Abantwana abasesebatjha abakhulelweko baqalana nemiraro eminengi efanako ehlobene nokubasidisi njengabomma abadala.   Abantwana abasesebatjha bavame ukuhlangabezana nemiraro yokubasidisi nofana ukuhlongakala kwabomma ukudlula abafazi abaneminyaka ematjhumi amabili nofana ngaphezulu. Kunokunye ukutshwenyeka kwalabo abangaphasi kweminyaka elitjhumi nahlanu ngombana akunakwenzeka bona bathuthuke emzimbeni ukobana bakghone ukukhulelwa kuhle nofana ukubeletha.  Ebantwaneni abaneminyaka elitjhumi nahlanu ukuya kwelitjhumi nethoba, ubungozi buhlotjaniswa khulu nezinto zehlalakuhle nezomnotho kunemiphumela yezinto eziphilako yeminyaka.  Ubungozi bokubeletha okuncani, ukubeletha ngaphambi kwesikhathi, ukuncipha kweengazi, kanye ne-pre-eclampsia akuhlobene neminyaka yezinto eziphilako ngesikhathi umntazana oneminyaka elitjhumi nesithandathu, ngombana ayibonakali ekubelethweni ukuya ebantwaneni abadala ngemva kokulawula ezinye izinto eziyingozi, njengokufikelela ekunakekelweni kwangaphambi kokubeletha okusezingeni eliphezulu.</text>
      <sha1>748ixash8y17emgw6v7qwj3mbfnt24p</sha1>
    </revision>
    <revision>
      <id>5813</id>
      <parentid>5809</parentid>
      <timestamp>2025-09-29T12:24:58Z</timestamp>
      <contributor>
        <username>Stillbelieveingooddays</username>
        <id>1018</id>
      </contributor>
      <origin>5813</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1873" sha1="0kxziw237nugv05mmcd3ekk59sjtgjq" xml:space="preserve">
'''Ukubasidisi kwabatjha''', okwaziwa nangokuthi '''kukubasebantwini kwabatjha''', kubasidisi komuntu wengubo ongaphasi kweminyaka ematjhumi amabili. 

Ephasini loke, ubudisi bokubasebantwini bubangela khulu ukuhlongakala kwabomma nabentazana abaneminyaka elitjhumi nahlanu ukuya kelitjhumi nethoba.  Ihlathululo yokubasidisi kwabatjha ifaka hlangana labo abathathwa njengabantu abadala ngokomthetho enarheni yabo.  Ihlangano yezamaphilo yephasi loke ihlathulula ''ubutjha'' njengesikhathi esiphakathi kweminyaka elitjhumi ukuya kwelitjhumi nethoba.  Ukubasidisi kungenzeka ngokuya emsemeni ngemva kokuthoma kokuvuthwa, okungenzeka ngaphambi kwesikhathi sokuthoma sokuya esikhathini ( ''menarche'' ).  Ebantazaneni abaphilileko, isikhathi sokuthoma sivame ukwenzeka hlangana neminyaka elitjhumi nambili ukuya kwelitjhumi nantathu. 

Abantwana abasesebatjha abakhulelweko baqalana nemiraro eminengi efanako efaka hlangana nokubasidisi njengabomma abadala.   Abantwana abasesebatjha bavame ukuhlangabezana nemiraro yokubasidisi nofana ukuhlongakala kwabomma ukudlula abafazi abaneminyaka ematjhumi amabili nofana ngaphezulu. Kunokhunye ukutshwenyeka kwalabo abangaphasi kweminyaka elitjhumi nahlanu ngombana akunakwenzeka bona bathuthuke emzimbeni ukobana bakghone ukubasidisi kuhle nofana ukubeletha.  Ebantwaneni abaneminyaka elitjhumi nahlanu ukuya kwelitjhumi nethoba, ubungozi buhlotjaniswa khulu nezinto zehlalakuhle nezomnotho kunemiphumela yezinto eziphilako yeminyaka.  Ubungozi bokubeletha okuncani, ukubeletha ngaphambi kwesikhathi, ukuncipha kweengazi, kanye ne-pre-eclampsia akukahlobani neminyaka yezinto eziphilako ngesikhathi umntazana oneminyaka elitjhumi nesithandathu, ngombana ayibonakali ekubelethweni ukuya ebantwaneni abadala ngemva kokulawula ezinye izinto eziyingozi, njengokufikelela ekunakekelweni kwangaphambi kokubeletha okusezingeni eliphezulu.</text>
      <sha1>0kxziw237nugv05mmcd3ekk59sjtgjq</sha1>
    </revision>
    <revision>
      <id>5814</id>
      <parentid>5813</parentid>
      <timestamp>2025-09-29T12:26:59Z</timestamp>
      <contributor>
        <username>Stillbelieveingooddays</username>
        <id>1018</id>
      </contributor>
      <origin>5814</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1869" sha1="ldrtayu3vyecwp3p2y58jl3nvuyzn2c" xml:space="preserve">
'''Ukubasidisi kwabatjha''', okwaziwa nangokuthi '''kukubasebantwini kwabatjha''', kubasidisi komuntu wengubo ongaphasi kweminyaka ematjhumi amabili. 

Ephasini loke, ubudisi bokubasebantwini bubangela khulu ukuhlongakala kwabomma nabentazana abaneminyaka elitjhumi nahlanu ukuya kelitjhumi nethoba.  Ihlathululo yokubasidisi kwabatjha ifaka hlangana labo abathathwa njengabantu abadala ngokomthetho enarheni yabo.  Ihlangano yezamaphilo yephasi loke ihlathulula ''ubutjha'' njengesikhathi esiphakathi kweminyaka elitjhumi ukuya kwelitjhumi nethoba.  Ukubasidisi kungenzeka ngokuya emsemeni ngemva kokuthoma kokuvuthwa, okungenzeka ngaphambi kwesikhathi sokuthoma sokuya esikhathini ( ''menarche'' ).  Ebantazaneni abaphilileko, isikhathi sokuthoma sivame ukwenzeka hlangana neminyaka elitjhumi nambili ukuya kwelitjhumi nantathu. 

Abantwana abasesebatjha abasidisi baqalana nemiraro eminengi efanako efaka hlangana nokubasidisi njengabomma abadala.   Abantwana abasesebatjha bavame ukuhlangabezana nemiraro yokubasidisi nofana ukuhlongakala kwabomma ukudlula abafazi abaneminyaka ematjhumi amabili nofana ngaphezulu. Kunokhunye ukutshwenyeka kwalabo abangaphasi kweminyaka elitjhumi nahlanu ngombana akunakwenzeka bona bathuthuke emzimbeni ukobana bakghone ukubasidisi kuhle nofana ukubeletha.  Ebantwaneni abaneminyaka elitjhumi nahlanu ukuya kwelitjhumi nethoba, ubungozi buhlotjaniswa khulu nezinto zehlalakuhle nezomnotho kunemiphumela yezinto eziphilako yeminyaka.  Ubungozi bokubeletha okuncani, ukubeletha ngaphambi kwesikhathi, ukuncipha kweengazi, kanye ne-pre-eclampsia akukahlobani neminyaka yezinto eziphilako ngesikhathi umntazana oneminyaka elitjhumi nesithandathu, ngombana ayibonakali ekubelethweni ukuya ebantwaneni abadala ngemva kokulawula ezinye izinto eziyingozi, njengokufikelela ekunakekelweni kwangaphambi kokubeletha okusezingeni eliphezulu.</text>
      <sha1>ldrtayu3vyecwp3p2y58jl3nvuyzn2c</sha1>
    </revision>
    <revision>
      <id>5831</id>
      <parentid>5814</parentid>
      <timestamp>2025-09-29T13:26:08Z</timestamp>
      <contributor>
        <username>Stillbelieveingooddays</username>
        <id>1018</id>
      </contributor>
      <minor />
      <origin>5831</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1970" sha1="kw0bohqdk3132vtibivwnfajx4pwjfe" xml:space="preserve">
'''Ukubasidisi kwabatjha''', okwaziwa nangokuthi '''kukubasebantwini kwabatjha''', kubasidisi komuntu wengubo ongaphasi kweminyaka ematjhumi amabili. 

Ephasini loke, ubudisi bokubasebantwini bubangela khulu ukuhlongakala kwabomma nabentazana abaneminyaka elitjhumi nahlanu ukuya kelitjhumi nethoba &lt;ref&gt;https://www.who.int/news-room/fact-sheets/detail/adolescent-pregnancy&lt;/ref&gt;.  Ihlathululo yokubasidisi kwabatjha ifaka hlangana labo abathathwa njengabantu abadala ngokomthetho enarheni yabo.  Ihlangano yezamaphilo yephasi loke ihlathulula ''ubutjha'' njengesikhathi esiphakathi kweminyaka elitjhumi ukuya kwelitjhumi nethoba.  Ukubasidisi kungenzeka ngokuya emsemeni ngemva kokuthoma kokuvuthwa, okungenzeka ngaphambi kwesikhathi sokuthoma sokuya esikhathini ( ''menarche'' ).  Ebantazaneni abaphilileko, isikhathi sokuthoma sivame ukwenzeka hlangana neminyaka elitjhumi nambili ukuya kwelitjhumi nantathu. 

Abantwana abasesebatjha abasidisi baqalana nemiraro eminengi efanako efaka hlangana nokubasidisi njengabomma abadala.   Abantwana abasesebatjha bavame ukuhlangabezana nemiraro yokubasidisi nofana ukuhlongakala kwabomma ukudlula abafazi abaneminyaka ematjhumi amabili nofana ngaphezulu. Kunokhunye ukutshwenyeka kwalabo abangaphasi kweminyaka elitjhumi nahlanu ngombana akunakwenzeka bona bathuthuke emzimbeni ukobana bakghone ukubasidisi kuhle nofana ukubeletha.  Ebantwaneni abaneminyaka elitjhumi nahlanu ukuya kwelitjhumi nethoba, ubungozi buhlotjaniswa khulu nezinto zehlalakuhle nezomnotho kunemiphumela yezinto eziphilako yeminyaka.  Ubungozi bokubeletha okuncani, ukubeletha ngaphambi kwesikhathi, ukuncipha kweengazi, kanye ne-pre-eclampsia akukahlobani neminyaka yezinto eziphilako ngesikhathi umntazana oneminyaka elitjhumi nesithandathu, ngombana ayibonakali ekubelethweni ukuya ebantwaneni abadala ngemva kokulawula ezinye izinto eziyingozi, njengokufikelela ekunakekelweni kwangaphambi kokubeletha okusezingeni eliphezulu.

== Isilululwazi ==</text>
      <sha1>kw0bohqdk3132vtibivwnfajx4pwjfe</sha1>
    </revision>
    <revision>
      <id>5838</id>
      <parentid>5831</parentid>
      <timestamp>2025-09-29T13:38:18Z</timestamp>
      <contributor>
        <username>Stillbelieveingooddays</username>
        <id>1018</id>
      </contributor>
      <minor />
      <origin>5838</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2660" sha1="ivd2l2y3jx6ikhq1mj1v2kqkm1y2fg5" xml:space="preserve">
'''Ukubasidisi kwabatjha''', okwaziwa nangokuthi '''kukubasebantwini kwabatjha''', kubasidisi komuntu wengubo ongaphasi kweminyaka ematjhumi amabili. 

Ephasini loke, ubudisi bokubasebantwini bubangela khulu ukuhlongakala kwabomma nabentazana abaneminyaka elitjhumi nahlanu ukuya kelitjhumi nethoba.&lt;ref&gt;https://www.who.int/news-room/fact-sheets/detail/adolescent-pregnancy&lt;/ref&gt; Ihlathululo yokubasidisi kwabatjha ifaka hlangana labo abathathwa njengabantu abadala ngokomthetho enarheni yabo.&lt;ref&gt;https://iris.who.int/bitstream/10665/42903/1/9241591455_eng.pdf&lt;/ref&gt; Ihlangano yezamaphilo yephasi loke ihlathulula ''ubutjha'' njengesikhathi esiphakathi kweminyaka elitjhumi ukuya kwelitjhumi nethoba.&lt;ref&gt;https://www.who.int/health-topics/adolescent-health#tab=tab_1&lt;/ref&gt; Ukubasidisi kungenzeka ngokuya emsemeni ngemva kokuthoma kokuvuthwa, okungenzeka ngaphambi kwesikhathi sokuthoma sokuya esikhathini ( ''menarche'' ).&lt;ref&gt;https://kidshealth.org/en/teens/pre-period.html&lt;/ref&gt; Ebantazaneni abaphilileko, isikhathi sokuthoma sivame ukwenzeka hlangana neminyaka elitjhumi nambili ukuya kwelitjhumi nantathu.&lt;ref&gt;https://pmc.ncbi.nlm.nih.gov/articles/PMC8734600/&lt;/ref&gt; 

Abantwana abasesebatjha abasidisi baqalana nemiraro eminengi efanako efaka hlangana nokubasidisi njengabomma abadala.&lt;ref&gt;https://www.nytimes.com/2022/07/18/health/young-girls-pregnancy-childbirth.html&lt;/ref&gt;&lt;ref&gt;https://journals.sagepub.com/doi/full/10.3233/NPM-15814038&lt;/ref&gt; Abantwana abasesebatjha bavame ukuhlangabezana nemiraro yokubasidisi nofana ukuhlongakala kwabomma ukudlula abafazi abaneminyaka ematjhumi amabili nofana ngaphezulu. Kunokhunye ukutshwenyeka kwalabo abangaphasi kweminyaka elitjhumi nahlanu ngombana akunakwenzeka bona bathuthuke emzimbeni ukobana bakghone ukubasidisi kuhle nofana ukubeletha.&lt;ref&gt;https://pmc.ncbi.nlm.nih.gov/articles/PMC411126/&lt;/ref&gt; Ebantwaneni abaneminyaka elitjhumi nahlanu ukuya kwelitjhumi nethoba, ubungozi buhlotjaniswa khulu nezinto zehlalakuhle nezomnotho kunemiphumela yezinto eziphilako yeminyaka.&lt;ref&gt;https://www.jstor.org/stable/2135024?origin=crossref&amp;seq=1&lt;/ref&gt; Ubungozi bokubeletha okuncani, ukubeletha ngaphambi kwesikhathi, ukuncipha kweengazi, kanye ne-pre-eclampsia akukahlobani neminyaka yezinto eziphilako ngesikhathi umntazana oneminyaka elitjhumi nesithandathu, ngombana ayibonakali ekubelethweni ukuya ebantwaneni abadala ngemva kokulawula ezinye izinto eziyingozi, njengokufikelela ekunakekelweni kwangaphambi kokubeletha okusezingeni eliphezulu.&lt;ref&gt;https://en.wikipedia.org/wiki/Teenage_pregnancy#cite_note-13&lt;/ref&gt;&lt;ref&gt;https://academic.oup.com/eurpub/article/16/2/157/505752?login=true&lt;/ref&gt;

== Isilululwazi ==</text>
      <sha1>ivd2l2y3jx6ikhq1mj1v2kqkm1y2fg5</sha1>
    </revision>
  </page>
  <page>
    <title>Ukungalingani Ngokobulili ESewula Afrikha</title>
    <ns>0</ns>
    <id>955</id>
    <revision>
      <id>5810</id>
      <timestamp>2025-09-29T12:16:24Z</timestamp>
      <contributor>
        <username>Diamond096</username>
        <id>997</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1292000815|Gender inequality in South Africa]]&quot;</comment>
      <origin>5810</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="685" sha1="5c2axlob8r4lvcgp6nwdf87tfqcqvgq" xml:space="preserve">'''Ukungalingani ngokobulili nokubandlululwa''' kusese miraro emikhulu [[Isewula Afrika|eSewula Afrika]], nangaphandle komthethosisekelo welizwe othuthukako kanye namagadango womthethokambiso ahlukahlukeneko aqaliswe ukuthuthukisa ukulingana ngokobulili.  Iinkambiso zomphakathi, ukungalingani kwezomnotho, kanye neentjhijilo ezihlelekileko eziragela phambili nokungalingani ngokobulili nokubandlululwa kumraro odephileko. Ubujamo obukhona eSewula Afrika buyihlekelele njengombana umphakathi usalandela umqondo wobukhosi begodu unemikghwa yamasiko engavimbela abafazi bona babe namaphothifoliyo wobuqhwephetjhe aphezulu . Ukungalingani ngokobulili nokubandlululwa kwenzeka yoke indawo.</text>
      <sha1>5c2axlob8r4lvcgp6nwdf87tfqcqvgq</sha1>
    </revision>
    <revision>
      <id>5826</id>
      <parentid>5810</parentid>
      <timestamp>2025-09-29T13:18:42Z</timestamp>
      <contributor>
        <username>Diamond096</username>
        <id>997</id>
      </contributor>
      <origin>5826</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1034" sha1="3c5d8uxubyjmt8rgpd6m0xhcajkzqd5" xml:space="preserve">'''Ukungalingani ngokobulili nokubandlululwa''' kusese miraro emikhulu [[Isewula Afrika|eSewula Afrika]], nangaphandle komthethosisekelo welizwe othuthukako kanye namagadango womthethokambiso ahlukahlukeneko aqaliswe ukuthuthukisa ukulingana ngokobulili. &lt;ref&gt;{{Cite journal|last=Segalo|first=P|date=2015|title=Gender, social cohesion and everyday struggles in South Africa|url=http://dx.doi.org/10.17159/2309-8708/2015/n49a6|journal=Psychology in Society|volume=49|pages=70–82|doi=10.17159/2309-8708/2015/n49a6|issn=1015-6046|doi-access=free|hdl=10500/27655|hdl-access=free}}&lt;/ref&gt; Iinkambiso zomphakathi, ukungalingani kwezomnotho, kanye neentjhijilo ezihlelekileko eziragela phambili nokungalingani ngokobulili nokubandlululwa kumraro odephileko. Ubujamo obukhona eSewula Afrika buyihlekelele njengombana umphakathi usalandela umqondo wobukhosi begodu unemikghwa yamasiko engavimbela abafazi bona babe namaphothifoliyo wobuqhwephetjhe aphezulu . Ukungalingani ngokobulili nokubandlululwa kwenzeka yoke indawo.

== Isilululwazi ==</text>
      <sha1>3c5d8uxubyjmt8rgpd6m0xhcajkzqd5</sha1>
    </revision>
    <revision>
      <id>5827</id>
      <parentid>5826</parentid>
      <timestamp>2025-09-29T13:19:44Z</timestamp>
      <contributor>
        <username>Diamond096</username>
        <id>997</id>
      </contributor>
      <origin>5827</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1034" sha1="keyznfyo2pirhz2scmuvzgharg34m06" xml:space="preserve">'''Ukungalingani ngokobulili nokubandlululwa''' kusese miraro emikhulu [[Isewula Afrika|eSewula Afrika]], nangaphandle komthethosisekelo welizwe othuthukako kanye namagadango womthethokambiso ahlukahlukeneko aqaliswe ukuthuthukisa ukulingana ngokobulili.&lt;ref&gt;{{Cite journal|last=Segalo|first=P|date=2015|title=Gender, social cohesion and everyday struggles in South Africa|url=http://dx.doi.org/10.17159/2309-8708/2015/n49a6|journal=Psychology in Society|volume=49|pages=70–82|doi=10.17159/2309-8708/2015/n49a6|issn=1015-6046|doi-access=free|hdl=10500/27655|hdl-access=free}}&lt;/ref&gt;  Iinkambiso zomphakathi, ukungalingani kwezomnotho, kanye neentjhijilo ezihlelekileko eziragela phambili nokungalingani ngokobulili nokubandlululwa kumraro odephileko. Ubujamo obukhona eSewula Afrika buyihlekelele njengombana umphakathi usalandela umqondo wobukhosi begodu unemikghwa yamasiko engavimbela abafazi bona babe namaphothifoliyo wobuqhwephetjhe aphezulu . Ukungalingani ngokobulili nokubandlululwa kwenzeka yoke indawo.

== Isilululwazi ==</text>
      <sha1>keyznfyo2pirhz2scmuvzgharg34m06</sha1>
    </revision>
    <revision>
      <id>5830</id>
      <parentid>5827</parentid>
      <timestamp>2025-09-29T13:23:51Z</timestamp>
      <contributor>
        <username>Diamond096</username>
        <id>997</id>
      </contributor>
      <minor />
      <origin>5830</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="798" sha1="fisuxzxpbb8p60rktga2tykm6heg6g3" xml:space="preserve">'''Ukungalingani ngokobulili nokubandlululwa''' kusese miraro emikhulu [[Isewula Afrika|eSewula Afrika]], nangaphandle komthethosisekelo welizwe othuthukako kanye namagadango womthethokambiso ahlukahlukeneko aqaliswe ukuthuthukisa ukulingana ngokobulili.&lt;ref&gt;https://www.scielo.org.za/scielo.php?pid=S1015-60462015000200006&amp;script=sci_arttext&lt;/ref&gt; Iinkambiso zomphakathi, ukungalingani kwezomnotho, kanye neentjhijilo ezihlelekileko eziragela phambili nokungalingani ngokobulili nokubandlululwa kumraro odephileko. Ubujamo obukhona eSewula Afrika buyihlekelele njengombana umphakathi usalandela umqondo wobukhosi begodu unemikghwa yamasiko engavimbela abafazi bona babe namaphothifoliyo wobuqhwephetjhe aphezulu . Ukungalingani ngokobulili nokubandlululwa kwenzeka yoke indawo.

== Isilululwazi ==</text>
      <sha1>fisuxzxpbb8p60rktga2tykm6heg6g3</sha1>
    </revision>
  </page>
  <page>
    <title>Thabo Bester</title>
    <ns>0</ns>
    <id>956</id>
    <revision>
      <id>5811</id>
      <timestamp>2025-09-29T12:21:26Z</timestamp>
      <contributor>
        <username>Nosayjeni</username>
        <id>1029</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1311723031|Thabo Bester]]&quot;</comment>
      <origin>5811</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1725" sha1="51gafuzkayt7uzjapgakvxooesaowew" xml:space="preserve">
'''U-Thabo Bester''' (wabelethwa mhlana ali-13 kuMgwengweni ngonyaka ka-1986)  mkati begodu mbulali weSewula Afrikha owaphunyuka e- Mangaung Correctional Center eSewula [[Isewula Afrika|Afrikha]] ngemva kokuleya amala wokobana wahlongakala emlilweni ngeseleni lakhe lejele ngoMrhayili 2022.   Bekaphila ngokubaleka pheze unyaka ngaphambi kobana abanjwe eTanzaunia ngenyanga kaRhoboyi 8 2023.  Wabotjhwa kanye nomlingani wakhe, udorhodere ongusaziwako uNandipha Magudumana .  UBester waziwa ngokuthi &quot;mkati we-Facebook&quot; ngombana bekasebenzisa iinkhundla zokuthintana ukuheha amamodeli ngamathuba womsebenzi amamanga.  Wavuma icala lokukata kabili nokubulala kanye begodu wagwetjwa isigwebo sepilo ejele.

== Ipilo yokuthoma ==
U-Thabo Bester wabelethwa esibhedlela se-Chris Hani Baragwanath eSoweto, eSewula Afrikha mhlana ali-13 kuMgwengweni ngonyaka ka-1986. UNgqongqotjhe WezeHlalo u-Aaron Motsoaledi watjela abantu beendaba ngonyaka ka-2023, bona u-Maria Mabaso, unina kaThabo, akhenge akghone ukutlolisa indodanakhe ngemva kokuyibeletha.  UMabaso bekangakatloliswa ngokwakhe, ngebanga lokuthi unina bekasebenza emaplasini, ngonobangela loyo akhange atlolise ukubelethwa kwakhe.  UNgqongqotjhe WezeHlalo wathi uThabo Bester wathoma ukugwetjwa nakaneminyaka eli-17, lokha nakazokufumana umazisi. &lt;ref name=&quot;ewnza2023&quot; /&gt; UBester sele adume khulu ngezenzo zakhe zobulelesi nokuleya amala.  Usebenzise amabizo amanengi wamala kiyo yoke imisebenzi yakhe yobulelesi. Nakaneminyaka eli-19, wahlala iminyaka emibili ejele ngebanga lokukhwabanisa ngaphambi kokwephula iparoli nokudlwengula amamodeli amabili nokubulala intombi yakhe, uNomfundo Tiyhulu. Wavuma icala lokukata ngo-2011 nokubulala ngo-2012. Wathola isigwebo sepilo.</text>
      <sha1>51gafuzkayt7uzjapgakvxooesaowew</sha1>
    </revision>
    <revision>
      <id>5817</id>
      <parentid>5811</parentid>
      <timestamp>2025-09-29T12:32:49Z</timestamp>
      <contributor>
        <username>Nosayjeni</username>
        <id>1029</id>
      </contributor>
      <origin>5817</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1722" sha1="b9cdlo6epsiwwufjf1pmiky4qa8fqry" xml:space="preserve">
'''UThabo Bester''' (wabelethwa mhlana ali-13 kuMgwengweni ngonyaka ka-1986)  mkati begodu mbulali weSewula Afrikha owaphunyuka e- Mangaung Correctional Center eSewula [[Isewula Afrika|Afrikha]] ngemva kokuleya amala wokobana wahlongakala emlilweni ngeseleni lakhe lejele ngoMrhayili 2022.   Bekaphila ngokubaleka pheze unyaka ngaphambi kobana abanjwe eTanzaunia ngenyanga kaRhoboyi 8 2023.  Wabotjhwa kanye nomlingani wakhe, udorhodere ongusaziwako uNandipha Magudumana .  UBester waziwa ngokuthi &quot;mkati we-Facebook&quot; ngombana bekasebenzisa iinkhundla zokuthintana ukuheha amamodeli ngamathuba womsebenzi amamanga.  Wavuma icala lokukata kabili nokubulala kanye begodu wagwetjwa isigwebo sepilo ejele.

== Ipilo yokuthoma ==
UThabo Bester wabelethwa esibhedlela se-Chris Hani Baragwanath eSoweto, eSewula Afrikha mhlana ali-13 kuMgwengweni ngonyaka ka-1986. UNgqongqotjhe WezeHlalo u-Aaron Motsoaledi watjela abantu beendaba ngonyaka ka-2023, bona uMaria Mabaso, unina kaThabo, akhenge akghone ukutlolisa indodanakhe ngemva kokuyibeletha.  UMabaso bekangakatloliswa ngokwakhe, ngebanga lokuthi unina bekasebenza emaplasini, ngonobangela loyo akhange atlolise ukubelethwa kwakhe.  UNgqongqotjhe WezeHlalo wathi uThabo Bester wathoma ukugwetjwa nakaneminyaka eli-17, lokha nakazokufumana umazisi. &lt;ref name=&quot;ewnza2023&quot; /&gt; UBester sele adume khulu ngezenzo zakhe zobulelesi nokuleya amala.  Usebenzise amabizo amanengi wamala kiyo yoke imisebenzi yakhe yobulelesi. Nakaneminyaka eli-19, wahlala iminyaka emibili ejele ngebanga lokukhwabanisa ngaphambi kokwephula iparoli nokudlwengula amamodeli amabili nokubulala intombi yakhe, uNomfundo Tiyhulu. Wavuma icala lokukata ngo-2011 nokubulala ngo-2012. Wathola isigwebo sepilo.</text>
      <sha1>b9cdlo6epsiwwufjf1pmiky4qa8fqry</sha1>
    </revision>
    <revision>
      <id>5819</id>
      <parentid>5817</parentid>
      <timestamp>2025-09-29T12:38:17Z</timestamp>
      <contributor>
        <username>Nosayjeni</username>
        <id>1029</id>
      </contributor>
      <origin>5819</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1731" sha1="3irgl2z8ol2yv07ozdelkuqjl3ucw3k" xml:space="preserve">
'''UThabo Bester''' (wabelethwa mhlana ali-13 kuMgwengweni ngonyaka ka-1986)  mkati begodu mbulali weSewula Afrikha owaphunyuka e- Mangaung Correctional Center eSewula [[Isewula Afrika|Afrikha]] ngemva kokuleya amala wokobana wahlongakala emlilweni ngeseleni lakhe lejele ngoMrhayili 2022.   Bekaphila ngokubaleka pheze unyaka woke ngaphambi kobana abanjwe eTanzaunia ngenyanga kaRhoboyi 8 2023.  Wabotjhwa kanye nomlingani wakhe, udorhodere ongusaziwako uNandipha Magudumana .  UBester waziwa ngokuthi &quot;mkati we-Facebook&quot; ngombana bekasebenzisa iinkhundla zokuthintana ukuheha amamodeli ngamathuba womsebenzi amamanga.  Wavuma icala lokukata kabili nokubulala kanye begodu wagwetjwa isigwebo sepilo ejele.

== Ipilo yokuthoma ==
UThabo Bester wabelethwa esibhedlela se-Chris Hani Baragwanath eSoweto, eSewula Afrikha mhlana ali-13 kuMgwengweni ngonyaka ka-1986. UNgqongqotjhe WezeHlalo u-Aaron Motsoaledi watjela abantu beendaba ngonyaka ka-2023, bona uMaria Mabaso, unina kaThabo, akhenge akghone ukutlolisa indodanakhe ngemva kokuyibeletha.  UMabaso bekangakatloliswa ngokwakhe, ngebanga lokuthi unina bekasebenza emaplasini, ngonobangela loyo akhange atlolise ukubelethwa kwakhe.  UNgqongqotjhe WezeHlalo wathi uThabo Bester wathoma ukugwetjwa nakaneminyaka eli-17, lokha nakaqeda ukufumana umazisi. &lt;ref name=&quot;ewnza2023&quot; /&gt; UBester sele adume khulu ngezenzo zakhe zobulelesi nokuleya amala.  Usebenzise amabizo amanengi wamala kiyo yoke imisebenzi yakhe yobulelesi. Nakaneminyaka eli-19, wahlala iminyaka emibili ejele ngebanga lokukhwabanisa ngaphambi kokwephula iparoli nokudlwengula amamodeli amabili nokubulala intombi yakhe, uNomfundo Tiyhulu. Wavuma icala lokukata ngo-2011 nokubulala ngo-2012. Wathola isigwebo sepilo.</text>
      <sha1>3irgl2z8ol2yv07ozdelkuqjl3ucw3k</sha1>
    </revision>
    <revision>
      <id>5821</id>
      <parentid>5819</parentid>
      <timestamp>2025-09-29T12:39:34Z</timestamp>
      <contributor>
        <username>Nosayjeni</username>
        <id>1029</id>
      </contributor>
      <origin>5821</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1728" sha1="1g9rgic6oarkbr11w73q7fkm8ed5zf7" xml:space="preserve">
'''UThabo Bester''' (wabelethwa mhlana ali-13 kuMgwengweni ngonyaka ka-1986)  mkati begodu mbulali weSewula Afrikha owaphunyuka e- Mangaung Correctional Center eSewula [[Isewula Afrika|Afrikha]] ngemva kokuleya amala wokobana wahlongakala emlilweni ngeseleni lakhe lejele ngoMrhayili 2022.   Bekaphila ngokubaleka pheze unyaka woke ngaphambi kobana abanjwe eTanzaunia ngenyanga kaRhoboyi 8 2023.  Wabotjhwa kanye nomlingani wakhe, udorhodere ongusaziwako uNandipha Magudumana .  UBester waziwa ngokuthi &quot;mkati we-Facebook&quot; ngombana bekasebenzisa iinkhundla zokuthintana ukuheha amamodeli ngamathuba womsebenzi amamanga.  Wavuma icala lokukata kabili nokubulala kanye begodu wagwetjwa isigwebo sepilo ejele.

== Ipilo yokuthoma ==
UThabo Bester wabelethwa esibhedlela se-Chris Hani Baragwanath eSoweto, eSewula Afrikha mhlana ali-13 kuMgwengweni ngonyaka ka-1986. UNgqongqotjhe WezeHlalo u-Aaron Motsoaledi watjela abantu beendaba ngonyaka ka-2023, bona uMaria Mabaso, unina kaThabo, akhenge akghone ukutlolisa indodanakhe ngemva kokuyibeletha.  UMabaso bekangakatloliswa ngokwakhe, ngebanga lokuthi unina bekasebenza emaplasini, ngonobangela loyo akhange atlolise ukubelethwa kwakhe.  UNgqongqotjhe WezeHlalo wathi uThabo Bester wathoma ukugwetjwa nakaneminyaka eli-17, ngemva kobana afumane umazisi. &lt;ref name=&quot;ewnza2023&quot; /&gt; UBester sele adume khulu ngezenzo zakhe zobulelesi nokuleya amala.  Usebenzise amabizo amanengi wamala kiyo yoke imisebenzi yakhe yobulelesi. Nakaneminyaka eli-19, wahlala iminyaka emibili ejele ngebanga lokukhwabanisa ngaphambi kokwephula iparoli nokudlwengula amamodeli amabili nokubulala intombi yakhe, uNomfundo Tiyhulu. Wavuma icala lokukata ngo-2011 nokubulala ngo-2012. Wathola isigwebo sepilo.</text>
      <sha1>1g9rgic6oarkbr11w73q7fkm8ed5zf7</sha1>
    </revision>
    <revision>
      <id>5823</id>
      <parentid>5821</parentid>
      <timestamp>2025-09-29T13:05:33Z</timestamp>
      <contributor>
        <username>Nosayjeni</username>
        <id>1029</id>
      </contributor>
      <origin>5823</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1775" sha1="7zh01evjm521o3j9fzaxnn9dwv2rpzo" xml:space="preserve">
'''UThabo Bester''' (wabelethwa mhlana ali-13 kuMgwengweni ngonyaka ka-1986)  mkati begodu mbulali weSewula Afrikha owaphunyuka e- Mangaung Correctional Center eSewula [[Isewula Afrika|Afrikha]] ngemva kokuleya amala wokobana wahlongakala emlilweni ngeseleni lakhe lejele ngoMrhayili 2022. Bekaphila ngokubaleka pheze unyaka woke ngaphambi kobana abanjwe eTanzaunia ngenyanga kaRhoboyi 8 2023.  Wabotjhwa kanye nomlingani wakhe, udorhodere ongusaziwako uNandipha Magudumana .  UBester waziwa ngokuthi &quot;mkati we-Facebook&quot; ngombana bekasebenzisa iinkhundla zokuthintana ukuheha amamodeli ngamathuba womsebenzi amamanga.  Wavuma icala lokukata kabili nokubulala kanye begodu wagwetjwa isigwebo sepilo ejele.

== Ipilo yokuthoma ==
UThabo Bester wabelethwa esibhedlela se-Chris Hani Baragwanath eSoweto, eSewula Afrikha mhlana ali-13 kuMgwengweni ngonyaka ka-1986. UNgqongqotjhe WezeHlalo u-Aaron Motsoaledi watjela abantu beendaba ngonyaka ka-2023, bona uMaria Mabaso, unina kaThabo, akhenge akghone ukutlolisa indodanakhe ngemva kokuyibeletha.  UMabaso bekangakatloliswa ngokwakhe, ngebanga lokuthi unina bekasebenza emaplasini, ngonobangela loyo akhange atlolise ukubelethwa kwakhe.  UNgqongqotjhe WezeHlalo wathi uThabo Bester wathoma ukugwetjwa nakaneminyaka eli-17, ngemva kobana afumane umazisi. &lt;ref name=&quot;ewnza2023&quot; /&gt; UBester sele adume khulu ngezenzo zakhe zobulelesi nokuleya amala.  Usebenzise amabizo amanengi wamala kiyo yoke imisebenzi yakhe yobulelesi. Nakaneminyaka eli-19, wahlala iminyaka emibili ejele ngebanga lokukhwabanisa ngaphambi kokwephula iparoli nokudlwengula amamodeli amabili nokubulala intombi yakhe, uNomfundo Tiyhulu. Wavuma icala lokukata ngo-2011 nokubulala ngo-2012. Wathola isigwebo sepilo.

== Isilululwazi ==
&lt;references responsive=&quot;&quot; /&gt;</text>
      <sha1>7zh01evjm521o3j9fzaxnn9dwv2rpzo</sha1>
    </revision>
    <revision>
      <id>5834</id>
      <parentid>5823</parentid>
      <timestamp>2025-09-29T13:34:36Z</timestamp>
      <contributor>
        <username>Nosayjeni</username>
        <id>1029</id>
      </contributor>
      <comment>Added the references</comment>
      <origin>5834</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2350" sha1="4ue4qhijttqa9m4q9tz5cagthna1fqg" xml:space="preserve">
'''UThabo Bester''' (wabelethwa mhlana ali-13 kuMgwengweni ngonyaka ka-1986)&lt;ref&gt;https://www.citizen.co.za/news/south-africa/thabo-bester-not-registered-with-home-affairs-april-2023/&lt;/ref&gt;  mkati begodu mbulali weSewula Afrikha owaphunyuka e- Mangaung Correctional Center eSewula [[Isewula Afrika|Afrikha]] ngemva kokuleya amala wokobana wahlongakala emlilweni ngeseleni lakhe lejele ngoMrhayili 2022.&lt;ref&gt;https://www.bbc.com/news/world-africa-65260508&lt;/ref&gt;&lt;ref&gt;https://briefly.co.za/facts-lifehacks/celebrities-biographies/157081-who-thabo-bester-everything-south-african-fugitive/&lt;/ref&gt; Bekaphila ngokubaleka pheze unyaka woke ngaphambi kobana abanjwe eTanzaunia ngenyanga kaRhoboyi 8 2023.&lt;ref&gt;https://www.bbc.com/news/world-africa-65194147&lt;/ref&gt;  Wabotjhwa kanye nomlingani wakhe, udorhodere ongusaziwako uNandipha Magudumana.&lt;ref&gt;https://www.ewn.co.za/2023/04/13/thabo-bester-a-timeline-of-what-you-need-to-know-from-escape-to-re-arrest&lt;/ref&gt;  UBester waziwa ngokuthi &quot;mkati we-Facebook&quot; ngombana bekasebenzisa iinkhundla zokuthintana ukuheha amamodeli ngamathuba womsebenzi amamanga.&lt;ref&gt;https://groundup.org.za/article/many-mysteries-surround-death-facebook-rapist-thabo-bester/&lt;/ref&gt;  Wavuma icala lokukata kabili nokubulala kanye begodu wagwetjwa isigwebo sepilo ejele.

== Ipilo yokuthoma ==
UThabo Bester wabelethwa esibhedlela se-Chris Hani Baragwanath eSoweto, eSewula Afrikha mhlana ali-13 kuMgwengweni ngonyaka ka-1986. UNgqongqotjhe WezeHlalo u-Aaron Motsoaledi watjela abantu beendaba ngonyaka ka-2023, bona uMaria Mabaso, unina kaThabo, akhenge akghone ukutlolisa indodanakhe ngemva kokuyibeletha.  UMabaso bekangakatloliswa ngokwakhe, ngebanga lokuthi unina bekasebenza emaplasini, ngonobangela loyo akhange atlolise ukubelethwa kwakhe.  UNgqongqotjhe WezeHlalo wathi uThabo Bester wathoma ukugwetjwa nakaneminyaka eli-17, ngemva kobana afumane umazisi. &lt;ref name=&quot;ewnza2023&quot; /&gt; UBester sele adume khulu ngezenzo zakhe zobulelesi nokuleya amala.  Usebenzise amabizo amanengi wamala kiyo yoke imisebenzi yakhe yobulelesi. Nakaneminyaka eli-19, wahlala iminyaka emibili ejele ngebanga lokukhwabanisa ngaphambi kokwephula iparoli nokudlwengula amamodeli amabili nokubulala intombi yakhe, uNomfundo Tiyhulu. Wavuma icala lokukata ngo-2011 nokubulala ngo-2012. Wathola isigwebo sepilo.

== Isilululwazi ==
&lt;references responsive=&quot;&quot; /&gt;</text>
      <sha1>4ue4qhijttqa9m4q9tz5cagthna1fqg</sha1>
    </revision>
    <revision>
      <id>5836</id>
      <parentid>5834</parentid>
      <timestamp>2025-09-29T13:36:38Z</timestamp>
      <contributor>
        <username>Nosayjeni</username>
        <id>1029</id>
      </contributor>
      <origin>5836</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2505" sha1="8d6u07l0eft6tntq4f3woml6jopvfnp" xml:space="preserve">
'''UThabo Bester''' (wabelethwa mhlana ali-13 kuMgwengweni ngonyaka ka-1986)&lt;ref&gt;https://www.citizen.co.za/news/south-africa/thabo-bester-not-registered-with-home-affairs-april-2023/&lt;/ref&gt;  mkati begodu mbulali weSewula Afrikha owaphunyuka e- Mangaung Correctional Center eSewula [[Isewula Afrika|Afrikha]] ngemva kokuleya amala wokobana wahlongakala emlilweni ngeseleni lakhe lejele ngoMrhayili 2022.&lt;ref&gt;https://www.bbc.com/news/world-africa-65260508&lt;/ref&gt;&lt;ref&gt;https://briefly.co.za/facts-lifehacks/celebrities-biographies/157081-who-thabo-bester-everything-south-african-fugitive/&lt;/ref&gt; Bekaphila ngokubaleka pheze unyaka woke ngaphambi kobana abanjwe eTanzaunia ngenyanga kaRhoboyi 8 2023.&lt;ref&gt;https://www.bbc.com/news/world-africa-65194147&lt;/ref&gt;  Wabotjhwa kanye nomlingani wakhe, udorhodere ongusaziwako uNandipha Magudumana.&lt;ref&gt;https://www.ewn.co.za/2023/04/13/thabo-bester-a-timeline-of-what-you-need-to-know-from-escape-to-re-arrest&lt;/ref&gt;  UBester waziwa ngokuthi &quot;mkati we-Facebook&quot; ngombana bekasebenzisa iinkhundla zokuthintana ukuheha amamodeli ngamathuba womsebenzi amamanga.&lt;ref&gt;https://groundup.org.za/article/many-mysteries-surround-death-facebook-rapist-thabo-bester/&lt;/ref&gt;  Wavuma icala lokukata kabili nokubulala kanye begodu wagwetjwa isigwebo sepilo ejele.

== Ipilo yokuthoma ==
UThabo Bester wabelethwa esibhedlela se-Chris Hani Baragwanath eSoweto, eSewula Afrikha mhlana ali-13 kuMgwengweni ngonyaka ka-1986. UNgqongqotjhe WezeHlalo u-Aaron Motsoaledi watjela abantu beendaba ngonyaka ka-2023, bona uMaria Mabaso, unina kaThabo, akhenge akghone ukutlolisa indodanakhe ngemva kokuyibeletha.  UMabaso bekangakatloliswa ngokwakhe, ngebanga lokuthi unina bekasebenza emaplasini, ngonobangela loyo akhange atlolise ukubelethwa kwakhe.  UNgqongqotjhe WezeHlalo wathi uThabo Bester wathoma ukugwetjwa nakaneminyaka eli-17, ngemva kobana afumane umazisi. &lt;ref name=&quot;ewnza2023&quot;&gt;https://web.archive.org/web/20230414133435/https://www.ewn.co.za/2023/04/14/thabo-bester-never-registered-as-an-sa-citizen-with-home-affairs-motsoaledi&lt;/ref&gt; UBester sele adume khulu ngezenzo zakhe zobulelesi nokuleya amala.  Usebenzise amabizo amanengi wamala kiyo yoke imisebenzi yakhe yobulelesi. Nakaneminyaka eli-19, wahlala iminyaka emibili ejele ngebanga lokukhwabanisa ngaphambi kokwephula iparoli nokudlwengula amamodeli amabili nokubulala intombi yakhe, uNomfundo Tiyhulu. Wavuma icala lokukata ngo-2011 nokubulala ngo-2012. Wathola isigwebo sepilo.

== Isilululwazi ==
&lt;references responsive=&quot;&quot; /&gt;</text>
      <sha1>8d6u07l0eft6tntq4f3woml6jopvfnp</sha1>
    </revision>
    <revision>
      <id>5839</id>
      <parentid>5836</parentid>
      <timestamp>2025-09-29T13:41:37Z</timestamp>
      <contributor>
        <username>Nosayjeni</username>
        <id>1029</id>
      </contributor>
      <origin>5839</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2689" sha1="99o07n0vku8yyv2u3dh2z9brgcp6foa" xml:space="preserve">
'''UThabo Bester''' (wabelethwa mhlana ali-13 kuMgwengweni ngonyaka ka-1986)&lt;ref&gt;https://www.citizen.co.za/news/south-africa/thabo-bester-not-registered-with-home-affairs-april-2023/&lt;/ref&gt;  mkati begodu mbulali weSewula Afrikha owaphunyuka e- Mangaung Correctional Center eSewula [[Isewula Afrika|Afrikha]] ngemva kokuleya amala wokobana wahlongakala emlilweni ngeseleni lakhe lejele ngoMrhayili 2022.&lt;ref&gt;https://www.bbc.com/news/world-africa-65260508&lt;/ref&gt;&lt;ref&gt;https://briefly.co.za/facts-lifehacks/celebrities-biographies/157081-who-thabo-bester-everything-south-african-fugitive/&lt;/ref&gt; Bekaphila ngokubaleka pheze unyaka woke ngaphambi kobana abanjwe eTanzaunia ngenyanga kaRhoboyi 8 2023.&lt;ref&gt;https://www.bbc.com/news/world-africa-65194147&lt;/ref&gt;  Wabotjhwa kanye nomlingani wakhe, udorhodere ongusaziwako uNandipha Magudumana.&lt;ref&gt;https://www.ewn.co.za/2023/04/13/thabo-bester-a-timeline-of-what-you-need-to-know-from-escape-to-re-arrest&lt;/ref&gt;  UBester waziwa ngokuthi &quot;mkati we-Facebook&quot; ngombana bekasebenzisa iinkhundla zokuthintana ukuheha amamodeli ngamathuba womsebenzi amamanga.&lt;ref&gt;https://groundup.org.za/article/many-mysteries-surround-death-facebook-rapist-thabo-bester/&lt;/ref&gt;  Wavuma icala lokukata kabili nokubulala kanye begodu wagwetjwa isigwebo sepilo ejele.

== Ipilo yokuthoma ==
UThabo Bester wabelethwa esibhedlela se-Chris Hani Baragwanath eSoweto, eSewula Afrikha mhlana ali-13 kuMgwengweni ngonyaka ka-1986. UNgqongqotjhe WezeHlalo u-Aaron Motsoaledi watjela abantu beendaba ngonyaka ka-2023, bona uMaria Mabaso, unina kaThabo, akhenge akghone ukutlolisa indodanakhe ngemva kokuyibeletha.&lt;ref name=&quot;:0&quot;&gt;https://web.archive.org/web/20230414133435/https://www.ewn.co.za/2023/04/14/thabo-bester-never-registered-as-an-sa-citizen-with-home-affairs-motsoaledi&lt;/ref&gt;  UMabaso bekangakatloliswa ngokwakhe, ngebanga lokuthi unina bekasebenza emaplasini, ngonobangela loyo akhange atlolise ukubelethwa kwakhe.&lt;ref name=&quot;:1&quot;&gt;https://www.timeslive.co.za/news/south-africa/2023-04-14-born-at-bara-to-mom-of-4-but-thabo-bester-was-never-registered-with-home-affairs/&lt;/ref&gt; UNgqongqotjhe WezeHlalo wathi uThabo Bester wathoma ukugwetjwa nakaneminyaka eli-17, ngemva kobana afumane umazisi.&lt;ref name=&quot;:0&quot; /&gt; UBester sele adume khulu ngezenzo zakhe zobulelesi nokuleya amala.&lt;ref name=&quot;:1&quot; /&gt;  Usebenzise amabizo amanengi wamala kiyo yoke imisebenzi yakhe yobulelesi. Nakaneminyaka eli-19, wahlala iminyaka emibili ejele ngebanga lokukhwabanisa ngaphambi kokwephula iparoli nokudlwengula amamodeli amabili nokubulala intombi yakhe, uNomfundo Tiyhulu. Wavuma icala lokukata ngo-2011 nokubulala ngo-2012. Wathola isigwebo sepilo.

== Isilululwazi ==
&lt;references responsive=&quot;&quot; /&gt;</text>
      <sha1>99o07n0vku8yyv2u3dh2z9brgcp6foa</sha1>
    </revision>
    <revision>
      <id>5841</id>
      <parentid>5839</parentid>
      <timestamp>2025-09-30T07:06:24Z</timestamp>
      <contributor>
        <username>Nosayjeni</username>
        <id>1029</id>
      </contributor>
      <origin>5841</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2687" sha1="8joashw8f2fuhisyv1z6s0683h9h1sc" xml:space="preserve">
'''UThabo Bester''' (wabelethwa mhlana ali-13 kuMgwengweni ngonyaka ka-1986)&lt;ref&gt;https://www.citizen.co.za/news/south-africa/thabo-bester-not-registered-with-home-affairs-april-2023/&lt;/ref&gt;  mkati begodu mbulali weSewula Afrikha owaphunyuka eMangaung Correctional Center eSewula [[Isewula Afrika|Afrikha]] ngemva kokuleya amala wokobana wahlongakala emlilweni ngeseleni lakhe lejele ngoMrhayili 2022.&lt;ref&gt;https://www.bbc.com/news/world-africa-65260508&lt;/ref&gt;&lt;ref&gt;https://briefly.co.za/facts-lifehacks/celebrities-biographies/157081-who-thabo-bester-everything-south-african-fugitive/&lt;/ref&gt; Bekaphila ngokubaleka pheze unyaka woke ngaphambi kobana abanjwe eTanzaunia ngenyanga kaRhoboyi 8 2023.&lt;ref&gt;https://www.bbc.com/news/world-africa-65194147&lt;/ref&gt;  Wabotjhwa kanye nomlingani wakhe, udorhodere ongusaziwako uNandipha Magudumana.&lt;ref&gt;https://www.ewn.co.za/2023/04/13/thabo-bester-a-timeline-of-what-you-need-to-know-from-escape-to-re-arrest&lt;/ref&gt;  UBester waziwa ngokuthi &quot;mkati we-Facebook&quot; ngombana bekasebenzisa iinkhundla zokuthintana ukuheha amamodeli ngamathuba womsebenzi amamanga.&lt;ref&gt;https://groundup.org.za/article/many-mysteries-surround-death-facebook-rapist-thabo-bester/&lt;/ref&gt;  Wavuma icala lokukata kabili nokubulala kanye begodu wagwetjwa isigwebo sepilo ejele.

== Ipilo yokuthoma ==
UThabo Bester wabelethwa esibhedlela se-Chris Hani Baragwanath eSoweto, eSewula Afrikha mhlana ali-13 kuMgwengweni ngonyaka ka-1986. UNgqongqotjhe WezeHlalo u-Aaron Motsoaledi watjela abantu beendaba ngonyaka ka-2023, bona uMaria Mabaso, unina kaThabo, akhenge akghone ukutlolisa indodanakhe ngemva kokuyibeletha.&lt;ref name=&quot;:0&quot;&gt;https://web.archive.org/web/20230414133435/https://www.ewn.co.za/2023/04/14/thabo-bester-never-registered-as-an-sa-citizen-with-home-affairs-motsoaledi&lt;/ref&gt;  UMabaso bekangakatloliswa ngokwakhe, ngebanga lokuthi unina bekasebenza emaplasini, ngonobangela loyo akhange atlolise ukubelethwa kwakhe.&lt;ref name=&quot;:1&quot;&gt;https://www.timeslive.co.za/news/south-africa/2023-04-14-born-at-bara-to-mom-of-4-but-thabo-bester-was-never-registered-with-home-affairs/&lt;/ref&gt; UNgqongqotjhe WezeHlalo wathi uThabo Bester wathoma ukugwetjwa nakaneminyaka eli-17, ngemva kobana afumane umazisi.&lt;ref name=&quot;:0&quot; /&gt; UBester sele adume khulu ngezenzo zakhe zobulelesi nokuleya amala.&lt;ref name=&quot;:1&quot; /&gt;  Usebenzise amabizo amanengi wamala kiyo yoke imisebenzi yakhe yobulelesi. Nakaneminyaka eli-19, wahlala iminyaka emibili ejele ngebanga lokukhwabanisa ngaphambi kokwephula iparoli nokudlwengula amamodeli amabili nokubulala intombi yakhe, uNomfundo Tiyhulu. Wavuma icala lokukata ngo-2011 nokubulala ngo-2012. Wathola isigwebo sepilo.

== Isilululwazi ==
&lt;references responsive=&quot;&quot; /&gt;</text>
      <sha1>8joashw8f2fuhisyv1z6s0683h9h1sc</sha1>
    </revision>
    <revision>
      <id>5842</id>
      <parentid>5841</parentid>
      <timestamp>2025-09-30T07:08:29Z</timestamp>
      <contributor>
        <username>Nosayjeni</username>
        <id>1029</id>
      </contributor>
      <origin>5842</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2686" sha1="fbss4kio4l1jh1bzatcwli9mnn3nj4c" xml:space="preserve">
'''UThabo Bester''' (wabelethwa mhlana ali-13 kuMgwengweni ngonyaka ka-1986)&lt;ref&gt;https://www.citizen.co.za/news/south-africa/thabo-bester-not-registered-with-home-affairs-april-2023/&lt;/ref&gt;  mkati begodu mbulali weSewula Afrikha owaphunyuka eMangaung Correctional Center eSewula [[Isewula Afrika|Afrikha]] ngemva kokuleya amala wokobana wahlongakala emlilweni ngeseleni lakhe lejele ngoMrhayili 2022.&lt;ref&gt;https://www.bbc.com/news/world-africa-65260508&lt;/ref&gt;&lt;ref&gt;https://briefly.co.za/facts-lifehacks/celebrities-biographies/157081-who-thabo-bester-everything-south-african-fugitive/&lt;/ref&gt; Bekaphila ngokubaleka pheze unyaka woke ngaphambi kobana abanjwe eTanzania ngenyanga kaRhoboyi 8 2023.&lt;ref&gt;https://www.bbc.com/news/world-africa-65194147&lt;/ref&gt;  Wabotjhwa kanye nomlingani wakhe, udorhodere ongusaziwako uNandipha Magudumana.&lt;ref&gt;https://www.ewn.co.za/2023/04/13/thabo-bester-a-timeline-of-what-you-need-to-know-from-escape-to-re-arrest&lt;/ref&gt;  UBester waziwa ngokuthi &quot;mkati we-Facebook&quot; ngombana bekasebenzisa iinkhundla zokuthintana ukuheha amamodeli ngamathuba womsebenzi amamanga.&lt;ref&gt;https://groundup.org.za/article/many-mysteries-surround-death-facebook-rapist-thabo-bester/&lt;/ref&gt;  Wavuma icala lokukata kabili nokubulala kanye begodu wagwetjwa isigwebo sepilo ejele.

== Ipilo yokuthoma ==
UThabo Bester wabelethwa esibhedlela se-Chris Hani Baragwanath eSoweto, eSewula Afrikha mhlana ali-13 kuMgwengweni ngonyaka ka-1986. UNgqongqotjhe WezeHlalo u-Aaron Motsoaledi watjela abantu beendaba ngonyaka ka-2023, bona uMaria Mabaso, unina kaThabo, akhenge akghone ukutlolisa indodanakhe ngemva kokuyibeletha.&lt;ref name=&quot;:0&quot;&gt;https://web.archive.org/web/20230414133435/https://www.ewn.co.za/2023/04/14/thabo-bester-never-registered-as-an-sa-citizen-with-home-affairs-motsoaledi&lt;/ref&gt;  UMabaso bekangakatloliswa ngokwakhe, ngebanga lokuthi unina bekasebenza emaplasini, ngonobangela loyo akhange atlolise ukubelethwa kwakhe.&lt;ref name=&quot;:1&quot;&gt;https://www.timeslive.co.za/news/south-africa/2023-04-14-born-at-bara-to-mom-of-4-but-thabo-bester-was-never-registered-with-home-affairs/&lt;/ref&gt; UNgqongqotjhe WezeHlalo wathi uThabo Bester wathoma ukugwetjwa nakaneminyaka eli-17, ngemva kobana afumane umazisi.&lt;ref name=&quot;:0&quot; /&gt; UBester sele adume khulu ngezenzo zakhe zobulelesi nokuleya amala.&lt;ref name=&quot;:1&quot; /&gt;  Usebenzise amabizo amanengi wamala kiyo yoke imisebenzi yakhe yobulelesi. Nakaneminyaka eli-19, wahlala iminyaka emibili ejele ngebanga lokukhwabanisa ngaphambi kokwephula iparoli nokudlwengula amamodeli amabili nokubulala intombi yakhe, uNomfundo Tiyhulu. Wavuma icala lokukata ngo-2011 nokubulala ngo-2012. Wathola isigwebo sepilo.

== Isilululwazi ==
&lt;references responsive=&quot;&quot; /&gt;</text>
      <sha1>fbss4kio4l1jh1bzatcwli9mnn3nj4c</sha1>
    </revision>
    <revision>
      <id>5862</id>
      <parentid>5842</parentid>
      <timestamp>2025-09-30T08:41:01Z</timestamp>
      <contributor>
        <username>Nosayjeni</username>
        <id>1029</id>
      </contributor>
      <comment>Added a link</comment>
      <origin>5862</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2686" sha1="lfg7vj6zxc4uz8m69593kion00pzdo2" xml:space="preserve">
'''UThabo Bester''' (wabelethwa mhlana ali-13 kuMgwengweni ngonyaka ka-1986)&lt;ref&gt;https://www.citizen.co.za/news/south-africa/thabo-bester-not-registered-with-home-affairs-april-2023/&lt;/ref&gt;  mkati begodu mbulali weSewula Afrikha owaphunyuka eMangaung Correctional Center e[[Isewula Afrika|Sewula Afrikha]] ngemva kokuleya amala wokobana wahlongakala emlilweni ngeseleni lakhe lejele ngoMrhayili 2022.&lt;ref&gt;https://www.bbc.com/news/world-africa-65260508&lt;/ref&gt;&lt;ref&gt;https://briefly.co.za/facts-lifehacks/celebrities-biographies/157081-who-thabo-bester-everything-south-african-fugitive/&lt;/ref&gt; Bekaphila ngokubaleka pheze unyaka woke ngaphambi kobana abanjwe eTanzania ngenyanga kaRhoboyi 8 2023.&lt;ref&gt;https://www.bbc.com/news/world-africa-65194147&lt;/ref&gt;  Wabotjhwa kanye nomlingani wakhe, udorhodere ongusaziwako uNandipha Magudumana.&lt;ref&gt;https://www.ewn.co.za/2023/04/13/thabo-bester-a-timeline-of-what-you-need-to-know-from-escape-to-re-arrest&lt;/ref&gt;  UBester waziwa ngokuthi &quot;mkati we-Facebook&quot; ngombana bekasebenzisa iinkhundla zokuthintana ukuheha amamodeli ngamathuba womsebenzi amamanga.&lt;ref&gt;https://groundup.org.za/article/many-mysteries-surround-death-facebook-rapist-thabo-bester/&lt;/ref&gt;  Wavuma icala lokukata kabili nokubulala kanye begodu wagwetjwa isigwebo sepilo ejele.

== Ipilo yokuthoma ==
UThabo Bester wabelethwa esibhedlela se-Chris Hani Baragwanath eSoweto, eSewula Afrikha mhlana ali-13 kuMgwengweni ngonyaka ka-1986. UNgqongqotjhe WezeHlalo u-Aaron Motsoaledi watjela abantu beendaba ngonyaka ka-2023, bona uMaria Mabaso, unina kaThabo, akhenge akghone ukutlolisa indodanakhe ngemva kokuyibeletha.&lt;ref name=&quot;:0&quot;&gt;https://web.archive.org/web/20230414133435/https://www.ewn.co.za/2023/04/14/thabo-bester-never-registered-as-an-sa-citizen-with-home-affairs-motsoaledi&lt;/ref&gt;  UMabaso bekangakatloliswa ngokwakhe, ngebanga lokuthi unina bekasebenza emaplasini, ngonobangela loyo akhange atlolise ukubelethwa kwakhe.&lt;ref name=&quot;:1&quot;&gt;https://www.timeslive.co.za/news/south-africa/2023-04-14-born-at-bara-to-mom-of-4-but-thabo-bester-was-never-registered-with-home-affairs/&lt;/ref&gt; UNgqongqotjhe WezeHlalo wathi uThabo Bester wathoma ukugwetjwa nakaneminyaka eli-17, ngemva kobana afumane umazisi.&lt;ref name=&quot;:0&quot; /&gt; UBester sele adume khulu ngezenzo zakhe zobulelesi nokuleya amala.&lt;ref name=&quot;:1&quot; /&gt;  Usebenzise amabizo amanengi wamala kiyo yoke imisebenzi yakhe yobulelesi. Nakaneminyaka eli-19, wahlala iminyaka emibili ejele ngebanga lokukhwabanisa ngaphambi kokwephula iparoli nokudlwengula amamodeli amabili nokubulala intombi yakhe, uNomfundo Tiyhulu. Wavuma icala lokukata ngo-2011 nokubulala ngo-2012. Wathola isigwebo sepilo.

== Isilululwazi ==
&lt;references responsive=&quot;&quot; /&gt;</text>
      <sha1>lfg7vj6zxc4uz8m69593kion00pzdo2</sha1>
    </revision>
  </page>
  <page>
    <title>Ifundo yokuzibandula</title>
    <ns>0</ns>
    <id>957</id>
    <revision>
      <id>5812</id>
      <timestamp>2025-09-29T12:24:41Z</timestamp>
      <contributor>
        <username>Tozi1153</username>
        <id>1030</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1313490045|Physical education]]&quot;</comment>
      <origin>5812</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1400" sha1="8r116kwb4dn72ahxhapzq0a2yfo2kmr" xml:space="preserve">'''Ifundo yokuzibandula''' (eyaziwa nangokuthi yi-PE) yifundo yemazingeni aphezulu efundiswa eenkolweni ephasini loke, efaka hlangana ifundo yamabanga aphasi, yamabanga aphezulu, begodu kwesinye isikhathi amabanga aphakamileko. Ivamise ukubizwa ngokuthi yi-Phys. Ed. nofana i-PE, begodu e-United States ibizwa ngokuthi yi -gym class nofana i-gym. Ifundo yokuzibandula ngokuvamileko iqalele ekuthuthukiseni ukuqina komzimba, amakghono wokusebenzisa umzimba, ukutjheja ipilo, nokuthintana nomphakathi ngemisebenzi efana nezemidlalo, ukuzithabulula, kanye nefundo yokunyakaza.  Nanyana ikharikhyulamu ihluka ngokuya ngezwe, i-PE ngokuvamileko ihlose ukuthuthukisa ukuzibandula nokuphila kuhle. Ngokungafani nezinye iimfundo zefundo, ifundo yokuzibandula ihlukile ngombana ihlanganisa abafundi kizo zoke iindawo zokufunda zemikhumbula, zemizwa, zehlalakuhle, [[Isiko|nezamasiko]] .  Okuqukethwe yifundo yokuzibandula kuyahluka emazweni ngamazwe, njengoba imisebenzi yokuzibandula  ivame ukubonisa ubujamo bendawo, amasiko, kanye nendawo yesifunda ngasinye.  Nanyana umnqopho wemfundo yokuzibandula  uphikiswa, enye yemigomo yayo eqakathekileko ithathwa njengokuhlanganisa nokunikela abantu abatjha amandla wokuthi baqakathekise begodu bahlanganyele emasikweni ahlukahlukeneko wokunyakaza nokuzibandula. &lt;ref name=&quot;:1&quot; /&gt;   

== Iinhlangano ezihlanu zokufunda ku-PE (Iindawo zokufunda eziqakathekileko) ==</text>
      <sha1>8r116kwb4dn72ahxhapzq0a2yfo2kmr</sha1>
    </revision>
    <revision>
      <id>5824</id>
      <parentid>5812</parentid>
      <timestamp>2025-09-29T13:10:29Z</timestamp>
      <contributor>
        <username>Tozi1153</username>
        <id>1030</id>
      </contributor>
      <origin>5824</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1420" sha1="le2egdk7df5aswgn88jhp3l4wt725sr" xml:space="preserve">'''Ifundo yokuzibandula''' (eyaziwa nangokuthi yi-PE) yifundo yemazingeni aphezulu efundiswa eenkolweni ephasini loke, efaka hlangana ifundo yamabanga aphasi, yamabanga aphezulu, begodu kwesinye isikhathi amabanga aphakamileko. Ivamise ukubizwa ngokuthi yi-Phys. Ed. nofana i-PE, begodu e-United States ibizwa ngokuthi yi -gym class nofana i-gym. Ifundo yokuzibandula ngokuvamileko iqalele ekuthuthukiseni ukuqina komzimba, amakghono wokusebenzisa umzimba, ukutjheja ipilo, nokuthintana nomphakathi ngemisebenzi efana nezemidlalo, ukuzithabulula, kanye nefundo yokunyakaza.  Nanyana ikharikhyulamu ihluka ngokuya ngezwe, i-PE ngokuvamileko ihlose ukuthuthukisa ukuzibandula nokuphila kuhle. Ngokungafani nezinye iimfundo zefundo, ifundo yokuzibandula ihlukile ngombana ihlanganisa abafundi kizo zoke iindawo zokufunda zemikhumbula, zemizwa, zehlalakuhle, [[Isiko|nezamasiko]] .  Okuqukethwe yifundo yokuzibandula kuyahluka emazweni ngamazwe, njengoba imisebenzi yokuzibandula  ivame ukubonisa ubujamo bendawo, amasiko, kanye nendawo yesifunda ngasinye.  Nanyana umnqopho wemfundo yokuzibandula  uphikiswa, enye yemigomo yayo eqakathekileko ithathwa njengokuhlanganisa nokunikela abantu abatjha amandla wokuthi baqakathekise begodu bahlanganyele emasikweni ahlukahlukeneko wokunyakaza nokuzibandula. &lt;ref name=&quot;:1&quot; /&gt;   

== Iinhlangano ezihlanu zokufunda ku-PE (Iindawo zokufunda eziqakathekileko) ==

== Isilululwazi ==</text>
      <sha1>le2egdk7df5aswgn88jhp3l4wt725sr</sha1>
    </revision>
    <revision>
      <id>5833</id>
      <parentid>5824</parentid>
      <timestamp>2025-09-29T13:33:28Z</timestamp>
      <contributor>
        <username>Tozi1153</username>
        <id>1030</id>
      </contributor>
      <comment>added reference</comment>
      <origin>5833</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1557" sha1="oei2ka57qrent0whok21h2lbbfcq1xi" xml:space="preserve">'''Ifundo yokuzibandula''' (eyaziwa nangokuthi yi-PE) yifundo yemazingeni aphezulu efundiswa eenkolweni ephasini loke, efaka hlangana ifundo yamabanga aphasi, yamabanga aphezulu, begodu kwesinye isikhathi amabanga aphakamileko. Ivamise ukubizwa ngokuthi yi-Phys. Ed. nofana i-PE, begodu e-United States ibizwa ngokuthi yi -gym class nofana i-gym. Ifundo yokuzibandula ngokuvamileko iqalele ekuthuthukiseni ukuqina komzimba, amakghono wokusebenzisa umzimba, ukutjheja ipilo, nokuthintana nomphakathi ngemisebenzi efana nezemidlalo, ukuzithabulula, kanye nefundo yokunyakaza.  Nanyana ikharikhyulamu ihluka ngokuya ngezwe, i-PE ngokuvamileko ihlose ukuthuthukisa ukuzibandula nokuphila kuhle. Ngokungafani nezinye iimfundo zefundo, ifundo yokuzibandula ihlukile ngombana ihlanganisa abafundi kizo zoke iindawo zokufunda zemikhumbula, zemizwa, zehlalakuhle, [[Isiko|nezamasiko]] . &lt;ref&gt;https://www.tandfonline.com/doi/full/10.1080/00336297.2024.2393624&lt;/ref&gt; Okuqukethwe yifundo yokuzibandula kuyahluka emazweni ngamazwe, njengoba imisebenzi yokuzibandula  ivame ukubonisa ubujamo bendawo, amasiko, kanye nendawo yesifunda ngasinye.  Nanyana umnqopho wemfundo yokuzibandula  uphikiswa, enye yemigomo yayo eqakathekileko ithathwa njengokuhlanganisa nokunikela abantu abatjha amandla wokuthi baqakathekise begodu bahlanganyele emasikweni ahlukahlukeneko wokunyakaza nokuzibandula. &lt;ref&gt;https://www.tandfonline.com/doi/abs/10.1080/00336297.1996.10484196&lt;/ref&gt;   

== Iinhlangano ezihlanu zokufunda ku-PE (Iindawo zokufunda eziqakathekileko) ==

== Isilululwazi ==</text>
      <sha1>oei2ka57qrent0whok21h2lbbfcq1xi</sha1>
    </revision>
    <revision>
      <id>5835</id>
      <parentid>5833</parentid>
      <timestamp>2025-09-29T13:34:57Z</timestamp>
      <contributor>
        <username>Tozi1153</username>
        <id>1030</id>
      </contributor>
      <comment>added reference</comment>
      <origin>5835</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1634" sha1="8qr3p4b9kc4uld9rzt7mjo2kzk2voy7" xml:space="preserve">&lt;ref&gt;https://www.tandfonline.com/doi/abs/10.1080/00971170.1980.10626550&lt;/ref&gt;'''Ifundo yokuzibandula''' (eyaziwa nangokuthi yi-PE) yifundo yemazingeni aphezulu efundiswa eenkolweni ephasini loke, efaka hlangana ifundo yamabanga aphasi, yamabanga aphezulu, begodu kwesinye isikhathi amabanga aphakamileko. Ivamise ukubizwa ngokuthi yi-Phys. Ed. nofana i-PE, begodu e-United States ibizwa ngokuthi yi -gym class nofana i-gym. Ifundo yokuzibandula ngokuvamileko iqalele ekuthuthukiseni ukuqina komzimba, amakghono wokusebenzisa umzimba, ukutjheja ipilo, nokuthintana nomphakathi ngemisebenzi efana nezemidlalo, ukuzithabulula, kanye nefundo yokunyakaza.  Nanyana ikharikhyulamu ihluka ngokuya ngezwe, i-PE ngokuvamileko ihlose ukuthuthukisa ukuzibandula nokuphila kuhle. Ngokungafani nezinye iimfundo zefundo, ifundo yokuzibandula ihlukile ngombana ihlanganisa abafundi kizo zoke iindawo zokufunda zemikhumbula, zemizwa, zehlalakuhle, [[Isiko|nezamasiko]] . &lt;ref&gt;https://www.tandfonline.com/doi/full/10.1080/00336297.2024.2393624&lt;/ref&gt; Okuqukethwe yifundo yokuzibandula kuyahluka emazweni ngamazwe, njengoba imisebenzi yokuzibandula  ivame ukubonisa ubujamo bendawo, amasiko, kanye nendawo yesifunda ngasinye.  Nanyana umnqopho wemfundo yokuzibandula  uphikiswa, enye yemigomo yayo eqakathekileko ithathwa njengokuhlanganisa nokunikela abantu abatjha amandla wokuthi baqakathekise begodu bahlanganyele emasikweni ahlukahlukeneko wokunyakaza nokuzibandula. &lt;ref&gt;https://www.tandfonline.com/doi/abs/10.1080/00336297.1996.10484196&lt;/ref&gt;   

== Iinhlangano ezihlanu zokufunda ku-PE (Iindawo zokufunda eziqakathekileko) ==

== Isilululwazi ==</text>
      <sha1>8qr3p4b9kc4uld9rzt7mjo2kzk2voy7</sha1>
    </revision>
  </page>
  <page>
    <title>Umvumo WesiNdebele</title>
    <ns>0</ns>
    <id>958</id>
    <revision>
      <id>5815</id>
      <timestamp>2025-09-29T12:27:14Z</timestamp>
      <contributor>
        <username>Ntonto23</username>
        <id>999</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1292166945|Ndebele music]]&quot;</comment>
      <origin>5815</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="358" sha1="29vcnpvk61xhhdlbljc7orafdveaz4e" xml:space="preserve">Umvumo wesintu wamaNdebele ubonakala khulu ngokusetjenziswa kwengoma yekhorali ekhambisana namahlwayi, iinwahlo, nokuwahla izandla. Nayimadaniswa nengoma yekhorali, ukuvuma wedwa nomvumo weensimbi akukaqakatheki khulu. NjengamaShona, amaNdebele nawo asebenzisa  iskumere, kunye nesidonodono, edlalelwa  khulu ngokuzithabisa siqu . 

== Abavumi bamaNdebele ==</text>
      <sha1>29vcnpvk61xhhdlbljc7orafdveaz4e</sha1>
    </revision>
    <revision>
      <id>5837</id>
      <parentid>5815</parentid>
      <timestamp>2025-09-29T13:36:53Z</timestamp>
      <contributor>
        <username>Ntonto23</username>
        <id>999</id>
      </contributor>
      <comment>Added a reference</comment>
      <origin>5837</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="447" sha1="dvm76drhpl1xsq6gh1olcbd88qpyw8j" xml:space="preserve">[[Umculo wesiNdebele|Umvumo]] wesintu wamaNdebele ubonakala khulu ngokusetjenziswa kwengoma yekhorali ekhambisana namahlwayi, iinwahlo, nokuwahla izandla. Nayimadaniswa nengoma yekhorali, ukuvuma wedwa nomvumo weensimbi akukaqakatheki khulu. NjengamaShona, amaNdebele nawo asebenzisa  iskumere, kunye nesidonodono, edlalelwa  khulu ngokuzithabisa siqu.&lt;ref&gt;https://intellectdiscover.com/content/journals/10.1386/rajo.6.1.5_4&lt;/ref&gt; 

== Iinkomba ==</text>
      <sha1>dvm76drhpl1xsq6gh1olcbd88qpyw8j</sha1>
    </revision>
    <revision>
      <id>6776</id>
      <parentid>5837</parentid>
      <timestamp>2026-08-14T12:39:17Z</timestamp>
      <contributor>
        <username>SandisiweMahlangu</username>
        <id>1620</id>
      </contributor>
      <comment>Edit</comment>
      <origin>6776</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
  </page>
  <page>
    <title>Ukutlhoriswa Kwabantwana Ebholweni</title>
    <ns>0</ns>
    <id>959</id>
    <revision>
      <id>5816</id>
      <timestamp>2025-09-29T12:31:37Z</timestamp>
      <contributor>
        <username>Wikabena2</username>
        <id>1031</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1311765706|Child abuse in football]]&quot;</comment>
      <origin>5816</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1533" sha1="joghvr554o9vvlqusx6sdd8lks36xcq" xml:space="preserve">
'''Ukutlhoriswa kwabantwana eenhlanganweni zebholo''' kutjho izehlakalo lapho abantwana bazibandakanya khona eenhlanganweni zebholo, kungaba ngendlela yokobana babe badlali namkha bazibandakanye kezinye iindima, bese bayatlhoriswa ngeendlela ezihlukahlukeneko, okufaka hlangana ukutlhoriswa  ngokomzimba, ngokwamazizo nangokwamabhayi.

Ukutlhoriswa kwabantwana ebholweni kubikwe emazweni ahlukahlukeneko begodu kufaka hlangana amazinga wabantu abasafundako nalabo esele babomakekere emdlalweni lo. Ukutlhoriswa kungenzeka ngaphakathi kweenqhema zebholo, kuma-akhademi namkha kezinye iinhlangano ezihlobene nebholo, begodu kungabandakanya ababanduli, amalunga wabasebenzi, nofana abanye abantu abaseenkhundleni eziphezulu. Amacala amanengi aphezulu alethe ukutjhejwa endabeni le begodu arholele ekuphenyweni, ekuthathweni kwamagadango womthetho kanye nekuthatheni amagadango angcono wokuvikela ngaphakathi ebholweni.

Imikhandlu elawula ibholo, efana ne -FIFA kanye neenhlangano zebholo yeentjhabatjhaba, isebenzise amagadango ahlukahlukeneko wokuvikela abazibandakanyi abatjha. Amagadango la afaka hlangana ukuhlolwa okuthuthukisiweko kwemvelaphi yababanduli kanye nabasebenzi, ukusungulwa kwemithetho yokuziphatha ecacileko neendlela zokubika kanye nokubandulwa kokuvikela okukatelelekileko kwalabo abazibandakanya ebholweni yelutjha. Phezu kwalokho, kwenziwe imibuzorhubhululo kanye namaphenyo azijameleko ukwembula ubungako bokutlhoriswa kwabantwana ebholweni begodu nokunikela ngeemphakamiso zokwenza ngcono iindlela zokuvikela.</text>
      <sha1>joghvr554o9vvlqusx6sdd8lks36xcq</sha1>
    </revision>
    <revision>
      <id>5822</id>
      <parentid>5816</parentid>
      <timestamp>2025-09-29T12:47:21Z</timestamp>
      <contributor>
        <username>Wikabena2</username>
        <id>1031</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1311765706|Child abuse in football]]&quot;</comment>
      <origin>5822</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1895" sha1="ltfgfsbfkr2quskceexkrvp2q0koxg1" xml:space="preserve">
'''Ukutlhoriswa kwabantwana eenhlanganweni zebholo''' kutjho izehlakalo lapho abantwana bazibandakanya khona eenhlanganweni zebholo, kungaba ngendlela yokobana babe badlali namkha bazibandakanye kezinye iindima, bese bayatlhoriswa ngeendlela ezihlukahlukeneko, okufaka hlangana ukutlhoriswa  ngokomzimba, ngokwamazizo nangokwamabhayi.

Ukutlhoriswa kwabantwana ebholweni kubikwe emazweni ahlukahlukeneko begodu kufaka hlangana amazinga wabantu abasafundako nalabo esele babomakekere emdlalweni lo. Ukutlhoriswa kungenzeka ngaphakathi kweenqhema zebholo, kuma-akhademi namkha kezinye iinhlangano ezihlobene nebholo, begodu kungabandakanya ababanduli, amalunga wabasebenzi, nofana abanye abantu abaseenkhundleni eziphezulu. Amacala amanengi aphezulu alethe ukutjhejwa endabeni le begodu arholele ekuphenyweni, ekuthathweni kwamagadango womthetho kanye nekuthatheni amagadango angcono wokuvikela ngaphakathi ebholweni.

Imikhandlu elawula ibholo, efana ne -FIFA kanye neenhlangano zebholo yeentjhabatjhaba, isebenzise amagadango ahlukahlukeneko wokuvikela abazibandakanyi abatjha. Amagadango la afaka hlangana ukuhlolwa okuthuthukisiweko kwemvelaphi yababanduli kanye nabasebenzi, ukusungulwa kwemithetho yokuziphatha ecacileko neendlela zokubika kanye nokubandulwa kokuvikela okukatelelekileko kwalabo abazibandakanya ebholweni yelutjha. Phezu kwalokho, kwenziwe imibuzorhubhululo kanye namaphenyo azijameleko ukwembula ubungako bokutlhoriswa kwabantwana ebholweni begodu nokunikela ngeemphakamiso zokwenza ngcono iindlela zokuvikela.

== Isirhunyezo ==

=== Ihlathululo ===
 
Ukutlhoriswa kwabantwana eenhlanganweni zebholo yeenyawo namkha ebholweni kutjho izehlakalo lapha abantwana abazibandakanya ebholweni, kungaba ngendlela yokobana babe badlali namkha bazibandakanye eendleleni ezahlukahlukeneko zokutlhoriswa, okufaka hlangana ukutlhoriswa ngokomzimba, ngokwamazizo namkha ngokwamabhayi.</text>
      <sha1>ltfgfsbfkr2quskceexkrvp2q0koxg1</sha1>
    </revision>
    <revision>
      <id>5825</id>
      <parentid>5822</parentid>
      <timestamp>2025-09-29T13:10:48Z</timestamp>
      <contributor>
        <username>Wikabena2</username>
        <id>1031</id>
      </contributor>
      <minor />
      <origin>5825</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1912" sha1="k6vba7uezo3f03acahhwb19itmz3co4" xml:space="preserve">
'''Ukutlhoriswa kwabantwana eenhlanganweni zebholo''' kutjho izehlakalo lapho abantwana bazibandakanya khona eenhlanganweni zebholo, kungaba ngendlela yokobana babe badlali namkha bazibandakanye kezinye iindima, bese bayatlhoriswa ngeendlela ezihlukahlukeneko, okufaka hlangana ukutlhoriswa  ngokomzimba, ngokwamazizo nangokwamabhayi.

Ukutlhoriswa kwabantwana ebholweni kubikwe emazweni ahlukahlukeneko begodu kufaka hlangana amazinga wabantu abasafundako nalabo esele babomakekere emdlalweni lo. Ukutlhoriswa kungenzeka ngaphakathi kweenqhema zebholo, kuma-akhademi namkha kezinye iinhlangano ezihlobene nebholo, begodu kungabandakanya ababanduli, amalunga wabasebenzi, nofana abanye abantu abaseenkhundleni eziphezulu. Amacala amanengi aphezulu alethe ukutjhejwa endabeni le begodu arholele ekuphenyweni, ekuthathweni kwamagadango womthetho kanye nekuthatheni amagadango angcono wokuvikela ngaphakathi ebholweni.

Imikhandlu elawula ibholo, efana ne -FIFA kanye neenhlangano zebholo yeentjhabatjhaba, isebenzise amagadango ahlukahlukeneko wokuvikela abazibandakanyi abatjha. Amagadango la afaka hlangana ukuhlolwa okuthuthukisiweko kwemvelaphi yababanduli kanye nabasebenzi, ukusungulwa kwemithetho yokuziphatha ecacileko neendlela zokubika kanye nokubandulwa kokuvikela okukatelelekileko kwalabo abazibandakanya ebholweni yelutjha. Phezu kwalokho, kwenziwe imibuzorhubhululo kanye namaphenyo azijameleko ukwembula ubungako bokutlhoriswa kwabantwana ebholweni begodu nokunikela ngeemphakamiso zokwenza ngcono iindlela zokuvikela.

== Isirhunyezo ==

=== Ihlathululo ===
 
Ukutlhoriswa kwabantwana eenhlanganweni zebholo yeenyawo namkha ebholweni kutjho izehlakalo lapha abantwana abazibandakanya ebholweni, kungaba ngendlela yokobana babe badlali namkha bazibandakanye eendleleni ezahlukahlukeneko zokutlhoriswa, okufaka hlangana ukutlhoriswa ngokomzimba, ngokwamazizo namkha ngokwamabhayi.

== Imithombo ==</text>
      <sha1>k6vba7uezo3f03acahhwb19itmz3co4</sha1>
    </revision>
    <revision>
      <id>5832</id>
      <parentid>5825</parentid>
      <timestamp>2025-09-29T13:31:36Z</timestamp>
      <contributor>
        <username>Wikabena2</username>
        <id>1031</id>
      </contributor>
      <minor />
      <comment>/* Imithombo */</comment>
      <origin>5832</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2034" sha1="reddxvd3c1zx04dfkjzo03nvhllobf9" xml:space="preserve">
'''Ukutlhoriswa kwabantwana eenhlanganweni zebholo''' kutjho izehlakalo lapho abantwana bazibandakanya khona eenhlanganweni zebholo, kungaba ngendlela yokobana babe badlali namkha bazibandakanye kezinye iindima, bese bayatlhoriswa ngeendlela ezihlukahlukeneko, okufaka hlangana ukutlhoriswa  ngokomzimba, ngokwamazizo nangokwamabhayi.

Ukutlhoriswa kwabantwana ebholweni kubikwe emazweni ahlukahlukeneko begodu kufaka hlangana amazinga wabantu abasafundako nalabo esele babomakekere emdlalweni lo. Ukutlhoriswa kungenzeka ngaphakathi kweenqhema zebholo, kuma-akhademi namkha kezinye iinhlangano ezihlobene nebholo, begodu kungabandakanya ababanduli, amalunga wabasebenzi, nofana abanye abantu abaseenkhundleni eziphezulu. Amacala amanengi aphezulu alethe ukutjhejwa endabeni le begodu arholele ekuphenyweni, ekuthathweni kwamagadango womthetho kanye nekuthatheni amagadango angcono wokuvikela ngaphakathi ebholweni.

Imikhandlu elawula ibholo, efana ne -FIFA kanye neenhlangano zebholo yeentjhabatjhaba, isebenzise amagadango ahlukahlukeneko wokuvikela abazibandakanyi abatjha. Amagadango la afaka hlangana ukuhlolwa okuthuthukisiweko kwemvelaphi yababanduli kanye nabasebenzi, ukusungulwa kwemithetho yokuziphatha ecacileko neendlela zokubika kanye nokubandulwa kokuvikela okukatelelekileko kwalabo abazibandakanya ebholweni yelutjha. Phezu kwalokho, kwenziwe imibuzorhubhululo kanye namaphenyo azijameleko ukwembula ubungako bokutlhoriswa kwabantwana ebholweni begodu nokunikela ngeemphakamiso zokwenza ngcono iindlela zokuvikela.

== Isirhunyezo ==

=== Ihlathululo ===
 
Ukutlhoriswa kwabantwana eenhlanganweni zebholo yeenyawo namkha ebholweni kutjho izehlakalo lapha abantwana abazibandakanya ebholweni, kungaba ngendlela yokobana babe badlali namkha bazibandakanye eendleleni ezahlukahlukeneko zokutlhoriswa, okufaka hlangana ukutlhoriswa ngokomzimba, ngokwamazizo namkha ngokwamabhayi.

== Imithombo&lt;ref&gt;https://www.playthegame.org/news/sexual-abuse-in-football-presidential-predators-and-pedophile-child-molesters/&lt;/ref&gt; ==</text>
      <sha1>reddxvd3c1zx04dfkjzo03nvhllobf9</sha1>
    </revision>
    <revision>
      <id>5840</id>
      <parentid>5832</parentid>
      <timestamp>2025-09-29T13:47:09Z</timestamp>
      <contributor>
        <username>Wikabena2</username>
        <id>1031</id>
      </contributor>
      <minor />
      <origin>5840</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2034" sha1="72hvswmuyqfydho8x8c7rl0xpnpe0la" xml:space="preserve">
'''Ukutlhoriswa kwabantwana eenhlanganweni zebholo''' kutjho izehlakalo lapho abantwana bazibandakanya khona eenhlanganweni zebholo, kungaba ngendlela yokobana babe badlali namkha bazibandakanye kezinye iindima, bese bayatlhoriswa ngeendlela ezihlukahlukeneko, okufaka hlangana ukutlhoriswa  ngokomzimba, ngokwamazizo nangokwamabhayi.

Ukutlhoriswa kwabantwana ebholweni kubikwe emazweni ahlukahlukeneko begodu kufaka hlangana amazinga wabantu abasafundako nalabo esele babomakekere emdlalweni lo. Ukutlhoriswa kungenzeka ngaphakathi kweenqhema zebholo, kuma-akhademi namkha kezinye iinhlangano ezihlobene nebholo, begodu kungabandakanya ababanduli, amalunga wabasebenzi, nofana abanye abantu abaseenkhundleni eziphezulu. Amacala amanengi aphezulu alethe ukutjhejwa endabeni le begodu arholele ekuphenyweni, ekuthathweni kwamagadango womthetho kanye nekuthatheni amagadango angcono wokuvikela ngaphakathi ebholweni.

Imikhandlu elawula ibholo, efana ne -FIFA kanye neenhlangano zebholo yeentjhabatjhaba, isebenzise amagadango ahlukahlukeneko wokuvikela abazibandakanyi abatjha. Amagadango la afaka hlangana ukuhlolwa okuthuthukisiweko kwemvelaphi yababanduli kanye nabasebenzi, ukusungulwa kwemithetho yokuziphatha ecacileko neendlela zokubika kanye nokubandulwa kokuvikela okukatelelekileko kwalabo abazibandakanya ebholweni yelutjha. Phezu kwalokho, kwenziwe imibuzorhubhululo kanye namaphenyo azijameleko ukwembula ubungako bokutlhoriswa kwabantwana ebholweni begodu nokunikela ngeemphakamiso zokwenza ngcono iindlela zokuvikela.

== Isirhunyezo ==

=== Ihlathululo ===
 
Ukutlhoriswa kwabantwana eenhlanganweni zebholo yeenyawo namkha ebholweni kutjho izehlakalo lapha abantwana abazibandakanya ebholweni, kungaba ngendlela yokobana babe badlali namkha bazibandakanye eendleleni ezahlukahlukeneko zokutlhoriswa, okufaka hlangana ukutlhoriswa ngokomzimba, ngokwamazizo namkha ngokwamabhayi.&lt;ref&gt;https://www.playthegame.org/news/sexual-abuse-in-football-presidential-predators-and-pedophile-child-molesters/&lt;/ref&gt;

== Imithombo ==</text>
      <sha1>72hvswmuyqfydho8x8c7rl0xpnpe0la</sha1>
    </revision>
  </page>
  <page>
    <title>Ruth Seopedi Motau</title>
    <ns>0</ns>
    <id>960</id>
    <revision>
      <id>5844</id>
      <timestamp>2025-09-30T07:19:43Z</timestamp>
      <contributor>
        <username>TKReitu</username>
        <id>1035</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1292458035|Ruth Seopedi Motau]]&quot;</comment>
      <origin>5844</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="420" sha1="0p49yzbx6lkgs3q90vg78sde2poanzx" xml:space="preserve">
'''U-Ruth Seopedi Motau''' (wabelethwa ngo-1968) mthwebuli weenthombe weSewula Afrika ohlala begodu usebenza e-Johannesburg, eSewula Afrika. U-Motau bekangumthwebuli weenthombe wesifazana onzima wokuthoma owaqatjhwa liphephandaba leSewula Afrika njengomhleli weenthombe.  Ukuthwebula kwakhe iinthombe kunzimelele emtlolweni wezenhlalakuhle othonywa yi-photojournalism nokubekelwa eceleni kwabantu abanzima nemiphakathi.</text>
      <sha1>0p49yzbx6lkgs3q90vg78sde2poanzx</sha1>
    </revision>
    <revision>
      <id>5845</id>
      <parentid>5844</parentid>
      <timestamp>2025-09-30T07:21:47Z</timestamp>
      <contributor>
        <username>TKReitu</username>
        <id>1035</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1292458035|Ruth Seopedi Motau]]&quot;</comment>
      <origin>5845</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="424" sha1="h5q6fu5cbf6rpwhfty5ic3863bobkzh" xml:space="preserve">
 

'''U-Ruth Seopedi Motau''' (wabelethwa ngo-1968) mthwebuli weenthombe weSewula Afrika ohlala begodu usebenza e-Johannesburg, eSewula Afrika. U-Motau bekangumthwebuli weenthombe wesifazana onzima wokuthoma owaqatjhwa liphephandaba leSewula Afrika njengomhleli weenthombe.  Ukuthwebula kwakhe iinthombe kunzimelele emtlolweni wezenhlalakuhle othonywa yi-photojournalism nokubekelwa eceleni kwabantu abanzima nemiphakathi.</text>
      <sha1>h5q6fu5cbf6rpwhfty5ic3863bobkzh</sha1>
    </revision>
    <revision>
      <id>5846</id>
      <parentid>5845</parentid>
      <timestamp>2025-09-30T07:26:29Z</timestamp>
      <contributor>
        <username>TKReitu</username>
        <id>1035</id>
      </contributor>
      <minor />
      <origin>5846</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="669" sha1="rxjakc9zv0d0vbsojvw8envfqr7ey9t" xml:space="preserve">
 

'''U-Ruth Seopedi Motau''' (wabelethwa ngo-1968) mthwebuli weenthombe weSewula Afrika ohlala begodu usebenza e-Johannesburg, eSewula Afrika. U-Motau bekangumthwebuli weenthombe wesifazana onzima wokuthoma owaqatjhwa liphephandaba leSewula Afrika njengomhleli weenthombe &lt;ref&gt;{{Cite news|url=https://www.sowetanlive.co.za/sundayworld/lifestyle/2019-03-13-their-lenses-capture-the-present--for-the-future/|title=Their lenses capture the present ... for the future|newspaper=Sowetanlive|access-date=2019-07-19}}&lt;/ref&gt;.  Ukuthwebula kwakhe iinthombe kunzimelele emtlolweni wezenhlalakuhle othonywa yi-photojournalism nokubekelwa eceleni kwabantu abanzima nemiphakathi.</text>
      <sha1>rxjakc9zv0d0vbsojvw8envfqr7ey9t</sha1>
    </revision>
    <revision>
      <id>5848</id>
      <parentid>5846</parentid>
      <timestamp>2025-09-30T07:31:10Z</timestamp>
      <contributor>
        <username>TKReitu</username>
        <id>1035</id>
      </contributor>
      <minor />
      <origin>5848</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="691" sha1="m5guya81rux0sfqul9j7th4kowlnd80" xml:space="preserve">
 

'''U-Ruth Seopedi Motau''' (wabelethwa ngo-1968) mthwebuli weenthombe weSewula Afrika ohlala begodu usebenza e-Johannesburg, eSewula Afrika. U-Motau bekangumthwebuli weenthombe wesifazana onzima wokuthoma owaqatjhwa liphephandaba leSewula Afrika njengomhleli weenthombe &lt;ref&gt;{{Cite news|url=https://www.sowetanlive.co.za/sundayworld/lifestyle/2019-03-13-their-lenses-capture-the-present--for-the-future/|title=Their lenses capture the present ... for the future|newspaper=Sowetanlive|access-date=2019-07-19}}&lt;/ref&gt;.  Ukuthwebula kwakhe iinthombe kunzimelele emtlolweni wezenhlalakuhle othonywa yi-photojournalism nokubekelwa eceleni kwabantu abanzima nemiphakathi.

== Umthombo lwazi ==</text>
      <sha1>m5guya81rux0sfqul9j7th4kowlnd80</sha1>
    </revision>
    <revision>
      <id>5849</id>
      <parentid>5848</parentid>
      <timestamp>2025-09-30T07:35:42Z</timestamp>
      <contributor>
        <username>TKReitu</username>
        <id>1035</id>
      </contributor>
      <minor />
      <origin>5849</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1034" sha1="6cl239fo999j9bv7w1wl9d56d529mgy" xml:space="preserve">
 

'''U-Ruth Seopedi Motau''' (wabelethwa ngo-1968) mthwebuli weenthombe weSewula Afrika ohlala begodu usebenza e-Johannesburg, eSewula Afrika. U-Motau bekangumthwebuli weenthombe wesifazana onzima wokuthoma owaqatjhwa liphephandaba leSewula Afrika njengomhleli weenthombe &lt;ref&gt;{{Cite news|url=https://www.sowetanlive.co.za/sundayworld/lifestyle/2019-03-13-their-lenses-capture-the-present--for-the-future/|title=Their lenses capture the present ... for the future|newspaper=Sowetanlive|access-date=2019-07-19}}&lt;/ref&gt;.  Ukuthwebula kwakhe iinthombe kunzimelele emtlolweni wezenhlalakuhle othonywa yi-photojournalism nokubekelwa eceleni kwabantu abanzima nemiphakathi.&lt;ref&gt;{{Cite journal|date=2000-01-01|title=Selection of image from photographic exhibition, by Ruth Motau, 'Women and municipal service delivery'|url=https://www.tandfonline.com/doi/abs/10.1080/10130950.2000.9675880|journal=Agenda|volume=16|issue=46|pages=98–99|doi=10.2307/4066287|jstor=4066287|issn=1013-0950|url-access=subscription}}&lt;/ref&gt;

== Umthombo lwazi ==</text>
      <sha1>6cl239fo999j9bv7w1wl9d56d529mgy</sha1>
    </revision>
    <revision>
      <id>5850</id>
      <parentid>5849</parentid>
      <timestamp>2025-09-30T07:37:20Z</timestamp>
      <contributor>
        <username>TKReitu</username>
        <id>1035</id>
      </contributor>
      <minor />
      <origin>5850</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="911" sha1="t1pxf278gtoyuw2btapk5qq1dso8996" xml:space="preserve">
 

'''U-Ruth Seopedi Motau''' (wabelethwa ngo-1968) mthwebuli weenthombe weSewula Afrika ohlala begodu usebenza e-Johannesburg, eSewula Afrika. U-Motau bekangumthwebuli weenthombe wesifazana onzima wokuthoma owaqatjhwa liphephandaba leSewula Afrika njengomhleli weenthombe &lt;ref&gt;{{Cite news|url=https://www.sowetanlive.co.za/sundayworld/lifestyle/2019-03-13-their-lenses-capture-the-present--for-the-future/|title=Their lenses capture the present ... for the future|newspaper=Sowetanlive|access-date=2019-07-19}}&lt;/ref&gt;.  Ukuthwebula kwakhe iinthombe kunzimelele emtlolweni wezenhlalakuhle othonywa yi-photojournalism nokubekelwa eceleni kwabantu abanzima nemiphakathi.&lt;ref&gt;&quot;Selection of image from photographic exhibition, by Ruth Motau, 'Women and municipal service delivery'&quot;. ''Agenda''. '''16''' (46): 98–99. 1 January 2000. doi:10.2307/4066287. ISSN 1013-0950. JSTOR 4066287.&lt;/ref&gt;

== Umthombo lwazi ==</text>
      <sha1>t1pxf278gtoyuw2btapk5qq1dso8996</sha1>
    </revision>
    <revision>
      <id>5853</id>
      <parentid>5850</parentid>
      <timestamp>2025-09-30T07:47:58Z</timestamp>
      <contributor>
        <username>TKReitu</username>
        <id>1035</id>
      </contributor>
      <minor />
      <origin>5853</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="979" sha1="scxf3kpno06gclbx00v7kt70wlqe2md" xml:space="preserve">[[Isimumathi:Ruth Seopedi Motau.jpg|thumb|Ruth Seopedi Motau, 2019]]
 

'''U-Ruth Seopedi Motau''' (wabelethwa ngo-1968) mthwebuli weenthombe weSewula Afrika ohlala begodu usebenza e-Johannesburg, eSewula Afrika. U-Motau bekangumthwebuli weenthombe wesifazana onzima wokuthoma owaqatjhwa liphephandaba leSewula Afrika njengomhleli weenthombe &lt;ref&gt;{{Cite news|url=https://www.sowetanlive.co.za/sundayworld/lifestyle/2019-03-13-their-lenses-capture-the-present--for-the-future/|title=Their lenses capture the present ... for the future|newspaper=Sowetanlive|access-date=2019-07-19}}&lt;/ref&gt;.  Ukuthwebula kwakhe iinthombe kunzimelele emtlolweni wezenhlalakuhle othonywa yi-photojournalism nokubekelwa eceleni kwabantu abanzima nemiphakathi.&lt;ref&gt;&quot;Selection of image from photographic exhibition, by Ruth Motau, 'Women and municipal service delivery'&quot;. ''Agenda''. '''16''' (46): 98–99. 1 January 2000. doi:10.2307/4066287. ISSN 1013-0950. JSTOR 4066287.&lt;/ref&gt;

== Umthombo lwazi ==</text>
      <sha1>scxf3kpno06gclbx00v7kt70wlqe2md</sha1>
    </revision>
  </page>
  <page>
    <title>Iindawo zamagugu wephasi</title>
    <ns>0</ns>
    <id>961</id>
    <revision>
      <id>5847</id>
      <timestamp>2025-09-30T07:29:27Z</timestamp>
      <contributor>
        <username>~2025-27165-86</username>
        <id>1036</id>
      </contributor>
      <comment>Created page with &quot;'''kunemihlobo''' emibili yendawo zamagugu wephasi. yokuthoma ijamele amasiko, yesbili ijamele amagugu wemvelo.  indawo zamagugu wamasiko  ukuthi indawo yenziww bona kube yindawo yamagugu w[[amasiko]]  kufanele ibenetshwayo lobikghwari babantu nokuqakatheka kwamamgugu isikhathi eside. Amatshwayo la kufanele bonyana abonakale amakhiweni ku thenolloji, ekuhleleni idorobha nokutlayweni kwendawo.&lt;ref&gt;https://sahistory.org.za/article/definition-natural-and-cultural-heritage-s...&quot;</comment>
      <origin>5847</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="762" sha1="6a9ectg9d2tncp2efs18wypx5o26ad6" xml:space="preserve">'''kunemihlobo''' emibili yendawo zamagugu wephasi. yokuthoma ijamele amasiko, yesbili ijamele amagugu wemvelo.

indawo zamagugu wamasiko

ukuthi indawo yenziww bona kube yindawo yamagugu w[[amasiko]]  kufanele ibenetshwayo lobikghwari babantu nokuqakatheka kwamamgugu isikhathi eside. Amatshwayo la kufanele bonyana abonakale amakhiweni ku thenolloji, ekuhleleni idorobha nokutlayweni kwendawo.&lt;ref&gt;https://sahistory.org.za/article/definition-natural-and-cultural-heritage-sites&lt;/ref&gt; Inawo yakhona kufanele ibe bufakaz i besintu begodu itjhuguluko elakhe lenzeka esikhathin sakade nofana sanje. Indawo leyo kungaba mhlobo omuhle weskhiwo nofana isiqhema sesakhiwo, ukusetjenziswa  kwetheknolojji nofana ukutjengisa amagadango aqakathekileko emalndweni wabantu.</text>
      <sha1>6a9ectg9d2tncp2efs18wypx5o26ad6</sha1>
    </revision>
    <revision>
      <id>5851</id>
      <parentid>5847</parentid>
      <timestamp>2025-09-30T07:41:59Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5851</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1704" sha1="723jgfha8ibp1fx226b74fga7htybbu" xml:space="preserve">'''kunemihlobo''' emibili yendawo zamagugu wephasi. yokuthoma ijamele amasiko, yesbili ijamele amagugu wemvelo.

=== Indawo zamagugu wamasiko ===
ukuthi indawo yenziww bona kube yindawo yamagugu w[[amasiko]]  kufanele ibenetshwayo lobikghwari babantu nokuqakatheka kwamamgugu isikhathi eside. Amatshwayo la kufanele bonyana abonakale amakhiweni ku thenolloji, ekuhleleni idorobha nokutlayweni kwendawo.&lt;ref&gt;https://sahistory.org.za/article/definition-natural-and-cultural-heritage-sites&lt;/ref&gt; Inawo yakhona kufanele ibe bufakaz i besintu begodu itjhuguluko elakhe lenzeka esikhathin sakade nofana sanje. Indawo leyo kungaba mhlobo omuhle weskhiwo nofana isiqhema sesakhiwo, ukusetjenziswa  kwetheknolojji nofana ukutjengisa amagadango aqakathekileko emalndweni wabantu.indawo lapho abantu bahlala khina begodu basebenzisa inarha ngedlela ejamele amasiko wabo nayo ingaba yindawo  yamagugu khulu khulu nangabe  indawo le inthintwe litjhuguluko elingeze labuyiselwa emuva kufanele liveze  ubuqiniso nendlela isayithi ivikelwe ngakhina begodu ilawula ngoayo nazizinto eziqakathekileko.

Indawo yamagugu yemvelo

Lezi kuzindawo ezingathathwa njengendawo zamagugu wephasi kufanele zitjngise amagadango amakhullu emlandwini wephasilokhu kungaba mafosili, amatje, nokuthi inarha inezinto zemvelo ezifana  neeentaba ezakheke kuhle ngokwendlela yakhona. Nangabe kuyimakhiwo yemvelo kufanele yakheke ngendlela eyikariso yomraro ebantwini. Kufanale ibe neendawo zokuhlala, nofana imihlobo hlobo yeenlwana neentjalo ezingaba khina lapho kwaphela, kube yinto eqakathekileko ukuthi iphephiswe. Lhu kwenza bona kube yindawo yamagugu wephasi loke, njengendawo zamasiko ukutlhogomela indawo kuqakathekile.

== Iinkomba ==</text>
      <sha1>723jgfha8ibp1fx226b74fga7htybbu</sha1>
    </revision>
    <revision>
      <id>5852</id>
      <parentid>5851</parentid>
      <timestamp>2025-09-30T07:44:12Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5852</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1752" sha1="b649qhz3ppaezh6p5dbywr0xtylgqpf" xml:space="preserve">'''kunemihlobo''' emibili yendawo zamagugu wephasi. yokuthoma ijamele amasiko, yesbili ijamele amagugu wemvelo.

=== Indawo zamagugu wamasiko ===
ukuthi indawo yenziww bona kube yindawo yamagugu w[[amasiko]]  kufanele ibenetshwayo lobikghwari babantu nokuqakatheka kwamamgugu isikhathi eside. Amatshwayo la kufanele bonyana abonakale amakhiweni ku thenolloji, ekuhleleni idorobha nokutlayweni kwendawo.&lt;ref&gt;https://sahistory.org.za/article/definition-natural-and-cultural-heritage-sites&lt;/ref&gt; Inawo yakhona kufanele ibe bufakaz i besintu begodu itjhuguluko elakhe lenzeka esikhathin sakade nofana sanje. Indawo leyo kungaba mhlobo omuhle weskhiwo nofana isiqhema sesakhiwo, ukusetjenziswa  kwetheknolojji nofana ukutjengisa amagadango aqakathekileko emalndweni wabantu.indawo lapho abantu bahlala khina begodu basebenzisa inarha ngedlela ejamele amasiko wabo nayo ingaba yindawo  yamagugu khulu khulu nangabe  indawo le inthintwe litjhuguluko elingeze labuyiselwa emuva kufanele liveze  ubuqiniso nendlela isayithi ivikelwe ngakhina begodu ilawula ngoayo nazizinto eziqakathekileko.

Indawo yamagugu yemvelo

Lezi kuzindawo ezingathathwa njengendawo zamagugu wephasi kufanele zitjngise amagadango amakhullu emlandwini wephasilokhu kungaba mafosili, amatje, nokuthi inarha inezinto zemvelo ezifana  neeentaba ezakheke kuhle ngokwendlela yakhona. Nangabe kuyimakhiwo yemvelo kufanele yakheke ngendlela eyikariso yomraro ebantwini.&lt;ref&gt;https://whc.unesco.org/en/criteria/&lt;/ref&gt; Kufanale ibe neendawo zokuhlala, nofana imihlobo hlobo yeenlwana neentjalo ezingaba khina lapho kwaphela, kube yinto eqakathekileko ukuthi iphephiswe. Lokhu kwenza bona kube yindawo yamagugu wephasi loke, njengendawo zamasiko ukutlhogomela indawo kuqakathekile.

== Iinkomba ==</text>
      <sha1>b649qhz3ppaezh6p5dbywr0xtylgqpf</sha1>
    </revision>
    <revision>
      <id>5854</id>
      <parentid>5852</parentid>
      <timestamp>2025-09-30T07:57:15Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5854</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2336" sha1="t2onkikm2a59w5dsl4r3z1f4euqt6iq" xml:space="preserve">'''kunemihlobo''' emibili yendawo zamagugu wephasi. yokuthoma ijamele amasiko, yesbili ijamele amagugu wemvelo. Ezinye iindawo eziqakathekileko  ziwela emasikweni namagugwini wemvelo begodu ngo-1992  i-UNESCO yaqunta bonyana iindawo ezitjengisa ubudlelwana hlangana nabantu nebhoduluko labo ziingaba ziindawo zamasiko. ISewula Afriak ilikhaya alamasayithi ali-12 we UNESCO akhombisa ukunotha kwenarha le ngamasiko nangamagugu wemvelo. Iindawo lezi azikaqakatheki eSewula Afrika kwaphela kodwana ephasinin loke ngombana zidosa abavakatjhi abavela ephasini zombelele ukuzokubona ubuhle bamasiko nemvelo esenarheni le, bafunde ngazo begodu abanye benze  nerhubhululo lesayensi endaweni lezi.

=== Indawo zamagugu wamasiko ===
ukuthi indawo yenziww bona kube yindawo yamagugu w[[amasiko]]  kufanele ibenetshwayo lobikghwari babantu nokuqakatheka kwamamgugu isikhathi eside. Amatshwayo la kufanele bonyana abonakale amakhiweni ku thenolloji, ekuhleleni idorobha nokutlayweni kwendawo.&lt;ref&gt;https://sahistory.org.za/article/definition-natural-and-cultural-heritage-sites&lt;/ref&gt; Inawo yakhona kufanele ibe bufakaz i besintu begodu itjhuguluko elakhe lenzeka esikhathin sakade nofana sanje. Indawo leyo kungaba mhlobo omuhle weskhiwo nofana isiqhema sesakhiwo, ukusetjenziswa  kwetheknolojji nofana ukutjengisa amagadango aqakathekileko emalndweni wabantu.indawo lapho abantu bahlala khina begodu basebenzisa inarha ngedlela ejamele amasiko wabo nayo ingaba yindawo  yamagugu khulu khulu nangabe  indawo le inthintwe litjhuguluko elingeze labuyiselwa emuva kufanele liveze  ubuqiniso nendlela isayithi ivikelwe ngakhina begodu ilawula ngoayo nazizinto eziqakathekileko.

=== Indawo yamagugu yemvelo ===
Lezi kuzindawo ezingathathwa njengendawo zamagugu wephasi kufanele zitjngise amagadango amakhullu emlandwini wephasilokhu kungaba mafosili, amatje, nokuthi inarha inezinto zemvelo ezifana  neeentaba ezakheke kuhle ngokwendlela yakhona. Nangabe kuyimakhiwo yemvelo kufanele yakheke ngendlela eyikariso yomraro ebantwini.&lt;ref&gt;https://whc.unesco.org/en/criteria/&lt;/ref&gt; Kufanale ibe neendawo zokuhlala, nofana imihlobo hlobo yeenlwana neentjalo ezingaba khina lapho kwaphela, kube yinto eqakathekileko ukuthi iphephiswe. Lokhu kwenza bona kube yindawo yamagugu wephasi loke, njengendawo zamasiko ukutlhogomela indawo kuqakathekile.

== Iinkomba ==</text>
      <sha1>t2onkikm2a59w5dsl4r3z1f4euqt6iq</sha1>
    </revision>
    <revision>
      <id>5855</id>
      <parentid>5854</parentid>
      <timestamp>2025-09-30T08:05:50Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5855</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2825" sha1="2qbyz53hhckb8hs031mu2sd81esmlsr" xml:space="preserve">'''kunemihlobo''' emibili yendawo zamagugu wephasi. yokuthoma ijamele amasiko, yesbili ijamele [[amagugu]] wemvelo. Ezinye iindawo eziqakathekileko  ziwela emasikweni namagugwini wemvelo begodu ngo-1992  i-UNESCO yaqunta bonyana iindawo ezitjengisa ubudlelwana hlangana nabantu nebhoduluko labo ziingaba ziindawo zamasiko. ISewula Afriak ilikhaya alamasayithi ali-12 we UNESCO akhombisa ukunotha kwenarha le ngamasiko nangamagugu wemvelo. Iindawo lezi azikaqakatheki eSewula Afrika kwaphela kodwana ephasinin loke ngombana zidosa abavakatjhi abavela ephasini zombelele ukuzokubona ubuhle bamasiko nemvelo esenarheni le, bafunde ngazo begodu abanye benze  nerhubhululo lesayensi endaweni lezi.&lt;ref&gt;Taruvinga, P., 2019. Stakeholders, conservation and socio-economic development: the case of Mapungubwe Cultural Landscape World Heritage Site, South Africa.&lt;/ref&gt;

=== Indawo zamagugu wamasiko ===
ukuthi indawo yenziww bona kube yindawo yamagugu w[[amasiko]]  kufanele ibenetshwayo lobikghwari babantu nokuqakatheka kwamamgugu isikhathi eside. Amatshwayo la kufanele bonyana abonakale amakhiweni ku thenolloji, ekuhleleni idorobha nokutlayweni kwendawo.&lt;ref&gt;https://sahistory.org.za/article/definition-natural-and-cultural-heritage-sites&lt;/ref&gt; Inawo yakhona kufanele ibe bufakaz i besintu begodu itjhuguluko elakhe lenzeka esikhathin sakade nofana sanje. Indawo leyo kungaba mhlobo omuhle weskhiwo nofana isiqhema sesakhiwo, ukusetjenziswa  kwetheknolojji nofana ukutjengisa amagadango aqakathekileko emalndweni wabantu.indawo lapho abantu bahlala khina begodu basebenzisa inarha ngedlela ejamele amasiko wabo nayo ingaba yindawo  yamagugu khulu khulu nangabe  indawo le inthintwe litjhuguluko elingeze labuyiselwa emuva kufanele liveze  ubuqiniso nendlela isayithi ivikelwe ngakhina begodu ilawula ngoayo nazizinto eziqakathekileko.

==== Amagama wendawo zamasiko wamagugu ====

* iRobben island

* IMapungubwe cultural landscape 

* Khomani cultural landscape

* Richterveld cultural and botanical landscape

=== Indawo yamagugu yemvelo ===
Lezi kuzindawo ezingathathwa njengendawo zamagugu wephasi kufanele zitjngise amagadango amakhullu emlandwini wephasilokhu kungaba mafosili, amatje, nokuthi inarha inezinto zemvelo ezifana  neeentaba ezakheke kuhle ngokwendlela yakhona. Nangabe kuyimakhiwo yemvelo kufanele yakheke ngendlela eyikariso yomraro ebantwini.&lt;ref&gt;https://whc.unesco.org/en/criteria/&lt;/ref&gt; Kufanale ibe neendawo zokuhlala, nofana imihlobo hlobo yeenlwana neentjalo ezingaba khina lapho kwaphela, kube yinto eqakathekileko ukuthi iphephiswe. Lokhu kwenza bona kube yindawo yamagugu wephasi loke, njengendawo zamasiko ukutlhogomela indawo kuqakathekile.

==== Amagama wendawo zamagugu wemvelo ====

* Isimangaliso wetland park
* Cape floral region
* Vredefort dome
* Barberton makhonjwa mountain

== Iinkomba ==</text>
      <sha1>2qbyz53hhckb8hs031mu2sd81esmlsr</sha1>
    </revision>
    <revision>
      <id>5856</id>
      <parentid>5855</parentid>
      <timestamp>2025-09-30T08:10:18Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5856</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2910" sha1="mpnmnovqelu5dtk9n3g0phhufm844hh" xml:space="preserve">'''kunemihlobo''' emibili yendawo zamagugu wephasi. yokuthoma ijamele amasiko, yesbili ijamele [[amagugu]] wemvelo. Ezinye iindawo eziqakathekileko  ziwela emasikweni namagugwini wemvelo begodu ngo-1992  i-UNESCO yaqunta bonyana iindawo ezitjengisa ubudlelwana hlangana nabantu nebhoduluko labo ziingaba ziindawo zamasiko. ISewula Afriak ilikhaya alamasayithi ali-12 we UNESCO akhombisa ukunotha kwenarha le ngamasiko nangamagugu wemvelo. Iindawo lezi azikaqakatheki eSewula Afrika kwaphela kodwana ephasinin loke ngombana zidosa abavakatjhi abavela ephasini zombelele ukuzokubona ubuhle bamasiko nemvelo esenarheni le, bafunde ngazo begodu abanye benze  nerhubhululo lesayensi endaweni lezi.&lt;ref&gt;Taruvinga, P., 2019. Stakeholders, conservation and socio-economic development: the case of Mapungubwe Cultural Landscape World Heritage Site, South Africa.&lt;/ref&gt;

=== Indawo zamagugu wamasiko ===
ukuthi indawo yenziww bona kube yindawo yamagugu w[[amasiko]]  kufanele ibenetshwayo lobikghwari babantu nokuqakatheka kwamamgugu isikhathi eside. Amatshwayo la kufanele bonyana abonakale amakhiweni ku thenolloji, ekuhleleni idorobha nokutlayweni kwendawo.&lt;ref&gt;https://sahistory.org.za/article/definition-natural-and-cultural-heritage-sites&lt;/ref&gt; Inawo yakhona kufanele ibe bufakaz i besintu begodu itjhuguluko elakhe lenzeka esikhathin sakade nofana sanje. Indawo leyo kungaba mhlobo omuhle weskhiwo nofana isiqhema sesakhiwo, ukusetjenziswa  kwetheknolojji nofana ukutjengisa amagadango aqakathekileko emalndweni wabantu.indawo lapho abantu bahlala khina begodu basebenzisa inarha ngedlela ejamele amasiko wabo nayo ingaba yindawo  yamagugu khulu khulu nangabe  indawo le inthintwe litjhuguluko elingeze labuyiselwa emuva kufanele liveze  ubuqiniso nendlela isayithi ivikelwe ngakhina begodu ilawula ngoayo nazizinto eziqakathekileko.

==== Amagama wendawo zamasiko wamagugu ====

* iRobben island

* IMapungubwe cultural landscape 

* Khomani cultural landscape

* [[Isimumathi:Mapungubwe, Limpopo, South Africa (20550797491).jpg|thumb|I-Mapungubwe]]Richterveld cultural and botanical landscape

=== Indawo yamagugu yemvelo ===
Lezi kuzindawo ezingathathwa njengendawo zamagugu wephasi kufanele zitjngise amagadango amakhullu emlandwini wephasilokhu kungaba mafosili, amatje, nokuthi inarha inezinto zemvelo ezifana  neeentaba ezakheke kuhle ngokwendlela yakhona. Nangabe kuyimakhiwo yemvelo kufanele yakheke ngendlela eyikariso yomraro ebantwini.&lt;ref&gt;https://whc.unesco.org/en/criteria/&lt;/ref&gt; Kufanale ibe neendawo zokuhlala, nofana imihlobo hlobo yeenlwana neentjalo ezingaba khina lapho kwaphela, kube yinto eqakathekileko ukuthi iphephiswe. Lokhu kwenza bona kube yindawo yamagugu wephasi loke, njengendawo zamasiko ukutlhogomela indawo kuqakathekile.

==== Amagama wendawo zamagugu wemvelo ====

* Isimangaliso wetland park
* Cape floral region
* Vredefort dome
* Barberton makhonjwa mountain

== Iinkomba ==</text>
      <sha1>mpnmnovqelu5dtk9n3g0phhufm844hh</sha1>
    </revision>
    <revision>
      <id>5857</id>
      <parentid>5856</parentid>
      <timestamp>2025-09-30T08:11:27Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5857</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3004" sha1="05it6cbtd714uy767ut7tjvsm18vsl7" xml:space="preserve">[[Isimumathi:B-Section, Maximum Security Prison, Robben Island (01).jpg|thumb|Robben Island]]
'''kunemihlobo''' emibili yendawo zamagugu wephasi. yokuthoma ijamele amasiko, yesbili ijamele [[amagugu]] wemvelo. Ezinye iindawo eziqakathekileko  ziwela emasikweni namagugwini wemvelo begodu ngo-1992  i-UNESCO yaqunta bonyana iindawo ezitjengisa ubudlelwana hlangana nabantu nebhoduluko labo ziingaba ziindawo zamasiko. ISewula Afrika ilikhaya alamasayithi ali-12 we UNESCO akhombisa ukunotha kwenarha le ngamasiko nangamagugu wemvelo. Iindawo lezi azikaqakatheki eSewula Afrika kwaphela kodwana ephasinin loke ngombana zidosa abavakatjhi abavela ephasini zombelele ukuzokubona ubuhle bamasiko nemvelo esenarheni le, bafunde ngazo begodu abanye benze  nerhubhululo lesayensi endaweni lezi.&lt;ref&gt;Taruvinga, P., 2019. Stakeholders, conservation and socio-economic development: the case of Mapungubwe Cultural Landscape World Heritage Site, South Africa.&lt;/ref&gt;

=== Indawo zamagugu wamasiko ===
ukuthi indawo yenziww bona kube yindawo yamagugu w[[amasiko]]  kufanele ibenetshwayo lobikghwari babantu nokuqakatheka kwamamgugu isikhathi eside. Amatshwayo la kufanele bonyana abonakale amakhiweni ku thenolloji, ekuhleleni idorobha nokutlayweni kwendawo.&lt;ref&gt;https://sahistory.org.za/article/definition-natural-and-cultural-heritage-sites&lt;/ref&gt; Inawo yakhona kufanele ibe bufakaz i besintu begodu itjhuguluko elakhe lenzeka esikhathin sakade nofana sanje. Indawo leyo kungaba mhlobo omuhle weskhiwo nofana isiqhema sesakhiwo, ukusetjenziswa  kwetheknolojji nofana ukutjengisa amagadango aqakathekileko emalndweni wabantu.indawo lapho abantu bahlala khina begodu basebenzisa inarha ngedlela ejamele amasiko wabo nayo ingaba yindawo  yamagugu khulu khulu nangabe  indawo le inthintwe litjhuguluko elingeze labuyiselwa emuva kufanele liveze  ubuqiniso nendlela isayithi ivikelwe ngakhina begodu ilawula ngoayo nazizinto eziqakathekileko.

==== Amagama wendawo zamasiko wamagugu ====

* iRobben island

* IMapungubwe cultural landscape 

* Khomani cultural landscape

* [[Isimumathi:Mapungubwe, Limpopo, South Africa (20550797491).jpg|thumb|I-Mapungubwe]]Richterveld cultural and botanical landscape

=== Indawo yamagugu yemvelo ===
Lezi kuzindawo ezingathathwa njengendawo zamagugu wephasi kufanele zitjngise amagadango amakhullu emlandwini wephasilokhu kungaba mafosili, amatje, nokuthi inarha inezinto zemvelo ezifana  neeentaba ezakheke kuhle ngokwendlela yakhona. Nangabe kuyimakhiwo yemvelo kufanele yakheke ngendlela eyikariso yomraro ebantwini.&lt;ref&gt;https://whc.unesco.org/en/criteria/&lt;/ref&gt; Kufanale ibe neendawo zokuhlala, nofana imihlobo hlobo yeenlwana neentjalo ezingaba khina lapho kwaphela, kube yinto eqakathekileko ukuthi iphephiswe. Lokhu kwenza bona kube yindawo yamagugu wephasi loke, njengendawo zamasiko ukutlhogomela indawo kuqakathekile.

==== Amagama wendawo zamagugu wemvelo ====

* Isimangaliso wetland park
* Cape floral region
* Vredefort dome
* Barberton makhonjwa mountain

== Iinkomba ==</text>
      <sha1>05it6cbtd714uy767ut7tjvsm18vsl7</sha1>
    </revision>
    <revision>
      <id>5859</id>
      <parentid>5857</parentid>
      <timestamp>2025-09-30T08:16:25Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5859</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3203" sha1="mt42wmvwthsk8uozqkzrsvrnnzx7u58" xml:space="preserve">[[Isimumathi:B-Section, Maximum Security Prison, Robben Island (01).jpg|thumb|Robben Island]]
'''kunemihlobo''' emibili yendawo zamagugu wephasi. yokuthoma ijamele amasiko, yesbili ijamele [[amagugu]] wemvelo. Ezinye iindawo eziqakathekileko  ziwela emasikweni namagugwini wemvelo begodu ngo-1992  i-UNESCO yaqunta bonyana iindawo ezitjengisa ubudlelwana hlangana nabantu nebhoduluko labo ziingaba ziindawo zamasiko. ISewula Afrika ilikhaya alamasayithi ali-12 we UNESCO akhombisa ukunotha kwenarha le ngamasiko nangamagugu wemvelo. Iindawo lezi azikaqakatheki eSewula Afrika kwaphela kodwana ephasinin loke ngombana zidosa abavakatjhi abavela ephasini zombelele ukuzokubona ubuhle bamasiko nemvelo esenarheni le, bafunde ngazo begodu abanye benze  nerhubhululo lesayensi endaweni lezi.&lt;ref&gt;Taruvinga, P., 2019. Stakeholders, conservation and socio-economic development: the case of Mapungubwe Cultural Landscape World Heritage Site, South Africa.&lt;/ref&gt;

=== Indawo zamagugu wamasiko ===
ukuthi indawo yenziww bona kube yindawo yamagugu w[[amasiko]]  kufanele ibenetshwayo lobikghwari babantu nokuqakatheka kwamamgugu isikhathi eside. Amatshwayo la kufanele bonyana abonakale amakhiweni ku thenolloji, ekuhleleni idorobha nokutlayweni kwendawo.&lt;ref&gt;https://sahistory.org.za/article/definition-natural-and-cultural-heritage-sites&lt;/ref&gt; Inawo yakhona kufanele ibe bufakaz i besintu begodu itjhuguluko elakhe lenzeka esikhathin sakade nofana sanje. Indawo leyo kungaba mhlobo omuhle weskhiwo nofana isiqhema sesakhiwo, ukusetjenziswa  kwetheknolojji nofana ukutjengisa amagadango aqakathekileko emalndweni wabantu.indawo lapho abantu bahlala khina begodu basebenzisa inarha ngedlela ejamele amasiko wabo nayo ingaba yindawo  yamagugu khulu khulu nangabe  indawo le inthintwe litjhuguluko elingeze labuyiselwa emuva kufanele liveze  ubuqiniso nendlela isayithi ivikelwe ngakhina begodu ilawula ngoayo nazizinto eziqakathekileko.

==== Amagama wendawo zamasiko wamagugu ====

* iRobben island

* IMapungubwe cultural landscape 

* Khomani cultural landscape

* [[Isimumathi:Mapungubwe, Limpopo, South Africa (20550797491).jpg|thumb|I-Mapungubwe]]Richterveld cultural and botanical landscape

=== Indawo yamagugu yemvelo ===
[[Isimumathi:ISimangaliso Wetland Park, gravel road.jpg|thumb|Isimangaliso wetland park]]
[[Isimumathi:Cape Floral Region Protected Areas map.jpg|thumb|Iindawo eziphephisiweko zeCape floral region]]
Lezi kuzindawo ezingathathwa njengendawo zamagugu wephasi kufanele zitjngise amagadango amakhullu emlandwini wephasilokhu kungaba mafosili, amatje, nokuthi inarha inezinto zemvelo ezifana  neeentaba ezakheke kuhle ngokwendlela yakhona. Nangabe kuyimakhiwo yemvelo kufanele yakheke ngendlela eyikariso yomraro ebantwini.&lt;ref&gt;https://whc.unesco.org/en/criteria/&lt;/ref&gt; Kufanale ibe neendawo zokuhlala, nofana imihlobo hlobo yeenlwana neentjalo ezingaba khina lapho kwaphela, kube yinto eqakathekileko ukuthi iphephiswe. Lokhu kwenza bona kube yindawo yamagugu wephasi loke, njengendawo zamasiko ukutlhogomela indawo kuqakathekile.

==== Amagama wendawo zamagugu wemvelo ====

* Isimangaliso wetland park
* Cape floral region
* Vredefort dome
* Barberton makhonjwa mountain

== Iinkomba ==</text>
      <sha1>mt42wmvwthsk8uozqkzrsvrnnzx7u58</sha1>
    </revision>
    <revision>
      <id>5860</id>
      <parentid>5859</parentid>
      <timestamp>2025-09-30T08:17:56Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5860</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3227" sha1="4el2xhwvqj2pjojocgj2xns8nzx5e04" xml:space="preserve">[[Isimumathi:B-Section, Maximum Security Prison, Robben Island (01).jpg|thumb|Robben Island]]
'''kunemihlobo''' emibili yendawo zamagugu wephasi. yokuthoma ijamele amasiko, yesbili ijamele [[amagugu]] wemvelo. Ezinye iindawo eziqakathekileko  ziwela emasikweni namagugwini wemvelo begodu ngo-1992  i-UNESCO yaqunta bonyana iindawo ezitjengisa ubudlelwana hlangana nabantu nebhoduluko labo ziingaba ziindawo zamasiko. ISewula Afrika ilikhaya alamasayithi ali-12 we UNESCO akhombisa ukunotha kwenarha le ngamasiko nangamagugu wemvelo. Iindawo lezi azikaqakatheki eSewula Afrika kwaphela kodwana ephasinin loke ngombana zidosa abavakatjhi abavela ephasini zombelele ukuzokubona ubuhle bamasiko nemvelo esenarheni le, bafunde ngazo begodu abanye benze  nerhubhululo lesayensi endaweni lezi.&lt;ref&gt;Taruvinga, P., 2019. Stakeholders, conservation and socio-economic development: the case of Mapungubwe Cultural Landscape World Heritage Site, South Africa.&lt;/ref&gt;

=== Indawo zamagugu wamasiko ===
ukuthi indawo yenziww bona kube yindawo yamagugu w[[amasiko]]  kufanele ibenetshwayo lobikghwari babantu nokuqakatheka kwamamgugu isikhathi eside. Amatshwayo la kufanele bonyana abonakale amakhiweni ku thenolloji, ekuhleleni idorobha nokutlayweni kwendawo.&lt;ref&gt;https://sahistory.org.za/article/definition-natural-and-cultural-heritage-sites&lt;/ref&gt; Inawo yakhona kufanele ibe bufakaz i besintu begodu itjhuguluko elakhe lenzeka esikhathin sakade nofana sanje. Indawo leyo kungaba mhlobo omuhle weskhiwo nofana isiqhema sesakhiwo, ukusetjenziswa  kwetheknolojji nofana ukutjengisa amagadango aqakathekileko emalndweni wabantu.indawo lapho abantu bahlala khina begodu basebenzisa inarha ngedlela ejamele amasiko wabo nayo ingaba yindawo  yamagugu khulu khulu nangabe  indawo le inthintwe litjhuguluko elingeze labuyiselwa emuva kufanele liveze  ubuqiniso nendlela isayithi ivikelwe ngakhina begodu ilawula ngoayo nazizinto eziqakathekileko.

==== Amagama wendawo zamasiko wamagugu ====

* [[IRobben island|i-Robben island]]

* [[IMapungubwe]] cultural landscape 

* Khomani cultural landscape

* [[Isimumathi:Mapungubwe, Limpopo, South Africa (20550797491).jpg|thumb|I-Mapungubwe]]Richterveld cultural and botanical landscape

=== Indawo yamagugu yemvelo ===
[[Isimumathi:ISimangaliso Wetland Park, gravel road.jpg|thumb|Isimangaliso wetland park]]
[[Isimumathi:Cape Floral Region Protected Areas map.jpg|thumb|Iindawo eziphephisiweko zeCape floral region]]
Lezi kuzindawo ezingathathwa njengendawo zamagugu wephasi kufanele zitjngise amagadango amakhullu emlandwini wephasilokhu kungaba mafosili, amatje, nokuthi inarha inezinto zemvelo ezifana  neeentaba ezakheke kuhle ngokwendlela yakhona. Nangabe kuyimakhiwo yemvelo kufanele yakheke ngendlela eyikariso yomraro ebantwini.&lt;ref&gt;https://whc.unesco.org/en/criteria/&lt;/ref&gt; Kufanale ibe neendawo zokuhlala, nofana imihlobo hlobo yeenlwana neentjalo ezingaba khina lapho kwaphela, kube yinto eqakathekileko ukuthi iphephiswe. Lokhu kwenza bona kube yindawo yamagugu wephasi loke, njengendawo zamasiko ukutlhogomela indawo kuqakathekile.

==== Amagama wendawo zamagugu wemvelo ====

* Isimangaliso wetland park
* Cape floral region
* Vredefort dome
* Barberton makhonjwa mountain

== Iinkomba ==</text>
      <sha1>4el2xhwvqj2pjojocgj2xns8nzx5e04</sha1>
    </revision>
    <revision>
      <id>5861</id>
      <parentid>5860</parentid>
      <timestamp>2025-09-30T08:24:37Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5861</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3210" sha1="pcj904wbus0k02evisqpcdea7jjyhw4" xml:space="preserve">[[Isimumathi:B-Section, Maximum Security Prison, Robben Island (01).jpg|thumb|Roben Island]]
'''kunemihlobo''' emibili yendawo zamagugu wephasi. yokuthoma ijamele amasiko, yesbili ijamele [[amagugu]] wemvelo. Ezinye iindawo eziqakathekileko  ziwela emasikweni namagugwini wemvelo begodu ngo-1992  i-UNESCO yaqunta bonyana iindawo ezitjengisa ubudlelwana hlangana nabantu nebhoduluko labo ziingaba ziindawo zamasiko. ISewula Afrika ilikhaya alamasayithi ali-12 we UNESCO akhombisa ukunotha kwenarha le ngamasiko nangamagugu wemvelo. Iindawo lezi azikaqakatheki eSewula Afrika kwaphela kodwana ephasinin loke ngombana zidosa abavakatjhi abavela ephasini zombelele ukuzokubona ubuhle bamasiko nemvelo esenarheni le, bafunde ngazo begodu abanye benze  nerhubhululo lesayensi endaweni lezi.&lt;ref&gt;Taruvinga, P., 2019. Stakeholders, conservation and socio-economic development: the case of Mapungubwe Cultural Landscape World Heritage Site, South Africa.&lt;/ref&gt;

=== Indawo zamagugu wamasiko ===
ukuthi indawo yenziww bona kube yindawo yamagugu w[[amasiko]]  kufanele ibenetshwayo lobikghwari babantu nokuqakatheka kwamamgugu isikhathi eside. Amatshwayo la kufanele bonyana abonakale amakhiweni ku thenolloji, ekuhleleni idorobha nokutlayweni kwendawo.&lt;ref&gt;https://sahistory.org.za/article/definition-natural-and-cultural-heritage-sites&lt;/ref&gt; Inawo yakhona kufanele ibe bufakaz i besintu begodu itjhuguluko elakhe lenzeka esikhathin sakade nofana sanje. Indawo leyo kungaba mhlobo omuhle weskhiwo nofana isiqhema sesakhiwo, ukusetjenziswa  kwetheknolojji nofana ukutjengisa amagadango aqakathekileko emalndweni wabantu.indawo lapho abantu bahlala khina begodu basebenzisa inarha ngedlela ejamele amasiko wabo nayo ingaba yindawo  yamagugu khulu khulu nangabe  indawo le inthintwe litjhuguluko elingeze labuyiselwa emuva kufanele liveze  ubuqiniso nendlela isayithi ivikelwe ngakhina begodu ilawula ngoayo nazizinto eziqakathekileko.

==== Amagama wendawo zamasiko wamagugu ====

* [[I-Roben island]]

* [[IMapungubwe]] cultural landscape 

* Khomani cultural landscape

* [[Isimumathi:Mapungubwe, Limpopo, South Africa (20550797491).jpg|thumb|I-Mapungubwe]]Richterveld cultural and botanical landscape

=== Indawo yamagugu yemvelo ===
[[Isimumathi:ISimangaliso Wetland Park, gravel road.jpg|thumb|Isimangaliso wetland park]]
[[Isimumathi:Cape Floral Region Protected Areas map.jpg|thumb|Iindawo eziphephisiweko zeCape floral region]]
Lezi kuzindawo ezingathathwa njengendawo zamagugu wephasi kufanele zitjngise amagadango amakhullu emlandwini wephasilokhu kungaba mafosili, amatje, nokuthi inarha inezinto zemvelo ezifana  neeentaba ezakheke kuhle ngokwendlela yakhona. Nangabe kuyimakhiwo yemvelo kufanele yakheke ngendlela eyikariso yomraro ebantwini.&lt;ref&gt;https://whc.unesco.org/en/criteria/&lt;/ref&gt; Kufanale ibe neendawo zokuhlala, nofana imihlobo hlobo yeenlwana neentjalo ezingaba khina lapho kwaphela, kube yinto eqakathekileko ukuthi iphephiswe. Lokhu kwenza bona kube yindawo yamagugu wephasi loke, njengendawo zamasiko ukutlhogomela indawo kuqakathekile.

==== Amagama wendawo zamagugu wemvelo ====

* Isimangaliso wetland park
* Cape floral region
* Vredefort dome
* Barberton makhonjwa mountain

== Iinkomba ==</text>
      <sha1>pcj904wbus0k02evisqpcdea7jjyhw4</sha1>
    </revision>
    <revision>
      <id>5986</id>
      <parentid>5861</parentid>
      <timestamp>2025-11-15T14:53:45Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>5986</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3316" sha1="9beejzzpj4pyi647ox5ty1my7rsxnvo" xml:space="preserve">[[Isimumathi:B-Section, Maximum Security Prison, Robben Island (01).jpg|thumb|Roben Island]]
'''kunemihlobo''' emibili yendawo zamagugu wephasi. yokuthoma ijamele amasiko, yesbili ijamele [[amagugu]] wemvelo. Ezinye iindawo eziqakathekileko  ziwela emasikweni namagugwini wemvelo begodu ngo-1992  i-UNESCO yaqunta bonyana iindawo ezitjengisa ubudlelwana hlangana nabantu nebhoduluko labo ziingaba ziindawo zamasiko. ISewula Afrika ilikhaya alamasayithi ali-12 we UNESCO akhombisa ukunotha kwenarha le ngamasiko nangamagugu wemvelo. Iindawo lezi azikaqakatheki eSewula Afrika kwaphela kodwana ephasinin loke ngombana zidosa abavakatjhi abavela ephasini zombelele ukuzokubona ubuhle bamasiko nemvelo esenarheni le, bafunde ngazo begodu abanye benze  nerhubhululo lesayensi endaweni lezi.&lt;ref&gt;Taruvinga, P., 2019. Stakeholders, conservation and socio-economic development: the case of Mapungubwe Cultural Landscape World Heritage Site, South Africa.&lt;/ref&gt;

=== Indawo zamagugu wamasiko ===
ukuthi indawo yenziww bona kube yindawo yamagugu w[[amasiko]]  kufanele ibenetshwayo lobikghwari babantu nokuqakatheka kwamamgugu isikhathi eside. Amatshwayo la kufanele bonyana abonakale amakhiweni ku thenolloji, ekuhleleni idorobha nokutlayweni kwendawo.&lt;ref&gt;https://sahistory.org.za/article/definition-natural-and-cultural-heritage-sites&lt;/ref&gt; Inawo yakhona kufanele ibe bufakaz i besintu begodu itjhuguluko elakhe lenzeka esikhathin sakade nofana sanje. Indawo leyo kungaba mhlobo omuhle weskhiwo nofana isiqhema sesakhiwo, ukusetjenziswa  kwetheknolojji nofana ukutjengisa amagadango aqakathekileko emalndweni wabantu.indawo lapho abantu bahlala khina begodu basebenzisa inarha ngedlela ejamele amasiko wabo nayo ingaba yindawo  yamagugu khulu khulu nangabe  indawo le inthintwe litjhuguluko elingeze labuyiselwa emuva kufanele liveze  ubuqiniso nendlela isayithi ivikelwe ngakhina begodu ilawula ngoayo nazizinto eziqakathekileko.

==== Amagama wendawo zamasiko wamagugu ====

* [[I-Roben island]]

* [[IMapungubwe]] cultural landscape 

* Khomani cultural landscape

* [[Isimumathi:Mapungubwe, Limpopo, South Africa (20550797491).jpg|thumb|I-Mapungubwe]]Richterveld cultural and botanical landscape

=== Indawo yamagugu yemvelo ===
[[Isimumathi:ISimangaliso Wetland Park, gravel road.jpg|thumb|Isimangaliso wetland park]]
[[Isimumathi:Cape Floral Region Protected Areas map.jpg|thumb|Iindawo eziphephisiweko zeCape floral region]]
Lezi kuzindawo ezingathathwa njengendawo zamagugu wephasi kufanele zitjngise amagadango amakhullu emlandwini wephasilokhu kungaba mafosili, amatje, nokuthi inarha inezinto zemvelo ezifana  neeentaba ezakheke kuhle ngokwendlela yakhona. Nangabe kuyimakhiwo yemvelo kufanele yakheke ngendlela eyikariso yomraro ebantwini.&lt;ref&gt;https://whc.unesco.org/en/criteria/&lt;/ref&gt; Kufanale ibe neendawo zokuhlala, nofana imihlobo hlobo yeenlwana neentjalo ezingaba khina lapho kwaphela, kube yinto eqakathekileko ukuthi iphephiswe. Lokhu kwenza bona kube yindawo yamagugu wephasi loke, njengendawo zamasiko ukutlhogomela indawo kuqakathekile.

==== Amagama wendawo zamagugu wemvelo ====

* Isimangaliso wetland park
* Cape floral region
* Vredefort dome
* Barberton makhonjwa mountain

== Iinkomba ==
[[category: Amagugu]]
[[Category: Amasiko]]
[[Category: Iindawo zamagugu]]
[[Category: ivakatjho bukela]]</text>
      <sha1>9beejzzpj4pyi647ox5ty1my7rsxnvo</sha1>
    </revision>
  </page>
  <page>
    <title>Umtjhado wesiNdebele isimanje</title>
    <ns>0</ns>
    <id>962</id>
    <revision>
      <id>5865</id>
      <timestamp>2025-09-30T12:48:13Z</timestamp>
      <contributor>
        <username>TKReitu</username>
        <id>1035</id>
      </contributor>
      <comment>created a new article</comment>
      <origin>5865</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1962" sha1="aazea5ppa6xjiyqhpwphs4pe7tp9k2n" xml:space="preserve">'''Kuyafika''' isikhathi lapha khona umuntu azitjela bona sele kusikhathi sokuthatha, sokwenda, sokutjhada. Umtjhado mnyanya ohlanganisa imindeni emibili, umndeni kamakoti kanye nomkhwenyana. Umnyanya ofana nesimaje mnyanya oyenzeka ngemva kwamalobolo. [[Amalobolo]] kulapha kuhlala khona imindeni yabantu abazokutjhada, bakomkhwenyana bangakhipha iinkomo, imali, izipho bazikhiphela bekhabo makoti.&lt;ref&gt;https://ww2.coh.ukzn.ac.za/news/2025/05/ilobolo-under-the-lens-in-masters-study/&lt;/ref&gt;
[[Isimumathi:Abomma nabo baba.jpg|thumb|umalukazana nomkhwenyana ]]

== Khuyini isimanje ==
Isimanje siyafana nomtjhado wetjhila elimhlophe kodwana ngewesintu samaNdebele. Isimanje senzeka ngemva kwamalobolo lapha khona umakoti azilungiselela ukuya ekhakwakhe (khabo likamkhwenyana) ayokufundiswa imithetho yalapho. Umakoti uzokuhlala isikhathanyana emzini ngaphambi kobanyana bayokuhlangana nomkhwenyana batjho iimfungo zabo bafake nenzilamunwana. Ngemva kokuvumelwana kuzwene hlangana nebekhabo makoti nomkhwenyana bona [[umtjhado]] uyenzeka. 

Emtjhadweni wesimanje umakoti akabhathi irogo elimhlophe kodwana ingubo (ibhidi) &lt;ref&gt;https://www.aranda.co.za/products/ibhidi-black-red?srsltid=AfmBOoqbSE9obFHO_Sfhz-KeumQT4-e3MxlZFtG-ufzYvxU4rouknTc_&lt;/ref&gt;, ngilo irogo lakhe, umkhwenyana yena angabhatha ibhanji nokhunywe kwesintu. Ngelanga lomtjhado imideni izokunikezana izipho ukuthokoza ukuhlangana kwabentwana (abantu abatjhadako). &lt;ref&gt;[https://cite.org.zw/modern-ndebele-marriage-practices/#:~:text=Gift%20exchange:%20Once%20the%20relationship,absence%20of%20the%20other%20partner. https://cite.org.zw/modern-ndebele-marriage-practices/#:~:text=Gift%20exchange:%20Once%20the%20relationship,absence%20of%20the%20other%20partner.]&lt;/ref&gt;Ngemva kwalomtjhado asikho isizathu sokobanyana ubekhona omunye umtjhado. Mtjhado omuhle wona begodu kunengi okwenzekako okukarisako.  

== Umthombo lwazi. ==
[[Mkhakha:Umtjhado]]
[[Mkhakha:Amalobolo]]
[[Mkhakha:Ukwenda komtazana]]</text>
      <sha1>aazea5ppa6xjiyqhpwphs4pe7tp9k2n</sha1>
    </revision>
    <revision>
      <id>5869</id>
      <parentid>5865</parentid>
      <timestamp>2025-09-30T13:07:24Z</timestamp>
      <contributor>
        <username>TKReitu</username>
        <id>1035</id>
      </contributor>
      <minor />
      <origin>5869</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1959" sha1="m6s2pg3xc7wkvv37h2viw9fvez8hmou" xml:space="preserve">'''Kuyafika''' isikhathi lapha khona umuntu azitjela bona sele kusikhathi sokuthatha, sokwenda, sokutjhada. Umtjhado mnyanya ohlanganisa imindeni emibili, umndeni kamakoti kanye nomkhwenyana. Umnyanya ofana nesimaje mnyanya oyenzeka ngemva kwamalobolo. [[Amalobolo]] kulapha kuhlala khona imindeni yabantu abazokutjhada, bakomkhwenyana bangakhipha iinkomo, imali, izipho bazikhiphela bekhabo makoti.&lt;ref&gt;https://ww2.coh.ukzn.ac.za/news/2025/05/ilobolo-under-the-lens-in-masters-study/&lt;/ref&gt;
[[Isimumathi:Abomma nabo baba.jpg|thumb|umalukazana nomkhwenyana ]]

== Khuyini isimanje ==
Isimanje siyafana nomtjhado wetjhila elimhlophe kodwana ngewesintu samaNdebele. Isimanje senzeka ngemva kwamalobolo lapha khona umakoti azilungiselela ukuya ekhakwakhe (khabo likamkhwenyana) ayokufundiswa imithetho yalapho. Umakoti uzokuhlala isikhathanyana emzini ngaphambi kobanyana bayokuhlangana nomkhwenyana batjho iimfungo zabo bafake nenzilamunwana. Ngemva kokuvumelwana kuzwene hlangana nebekhabo makoti nomkhwenyana bona [[umtjhado]] uyenzeka. 

Emtjhadweni wesimanje umakoti akabhathi irogo elimhlophe kodwana ingubo (ibhidi)&lt;ref&gt;https://www.aranda.co.za/products/ibhidi-black-red?srsltid=AfmBOoqbSE9obFHO_Sfhz-KeumQT4-e3MxlZFtG-ufzYvxU4rouknTc_&lt;/ref&gt; ngilo irogo lakhe, umkhwenyana yena angabhatha ibhanji nokhunywe kwesintu. Ngelanga lomtjhado imideni izokunikezana izipho ukuthokoza ukuhlangana kwabentwana (abantu abatjhadako).&lt;ref&gt;[https://cite.org.zw/modern-ndebele-marriage-practices/#:~:text=Gift%20exchange:%20Once%20the%20relationship,absence%20of%20the%20other%20partner. https://cite.org.zw/modern-ndebele-marriage-practices/#:~:text=Gift%20exchange:%20Once%20the%20relationship,absence%20of%20the%20other%20partner.]&lt;/ref&gt; Ngemva kwalomtjhado asikho isizathu sokobanyana ubekhona omunye umtjhado. Mtjhado omuhle wona begodu kunengi okwenzekako okukarisako.  

== Umthombo lwazi ==
[[Mkhakha:Umtjhado]]
[[Mkhakha:Amalobolo]]
[[Mkhakha:Ukwenda komtazana]]</text>
      <sha1>m6s2pg3xc7wkvv37h2viw9fvez8hmou</sha1>
    </revision>
    <revision>
      <id>6704</id>
      <parentid>5869</parentid>
      <timestamp>2026-06-12T08:41:54Z</timestamp>
      <contributor>
        <username>MissHadassah</username>
        <id>1561</id>
      </contributor>
      <comment>changed formatting</comment>
      <origin>6704</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1967" sha1="46r2csd59wgqqsm23phaompfco25ofs" xml:space="preserve">'''Kuyafika''' isikhathi lapha khona umuntu azitjela bona sele kusikhathi sokuthatha, sokwenda, sokutjhada. Umtjhado mnyanya ohlanganisa imindeni emibili, umndeni kamakoti kanye nomkhwenyana. Umnyanya ofana nesimaje mnyanya oyenzeka ngemva kwamalobolo. [[Ilobolo|Amalobolo]] kulapha kuhlala khona imindeni yabantu abazokutjhada, bakomkhwenyana bangakhipha iinkomo, imali, izipho bazikhiphela bekhabo makoti.&lt;ref&gt;https://ww2.coh.ukzn.ac.za/news/2025/05/ilobolo-under-the-lens-in-masters-study/&lt;/ref&gt;
[[Isimumathi:Abomma nabo baba.jpg|thumb|umalukazana nomkhwenyana ]]

== Khuyini isimanje ==
Isimanje siyafana nomtjhado wetjhila elimhlophe kodwana ngewesintu samaNdebele. Isimanje senzeka ngemva kwamalobolo lapha khona umakoti azilungiselela ukuya ekhakwakhe (khabo likamkhwenyana) ayokufundiswa imithetho yalapho. Umakoti uzokuhlala isikhathanyana emzini ngaphambi kobanyana bayokuhlangana nomkhwenyana batjho iimfungo zabo bafake nenzilamunwana. Ngemva kokuvumelwana kuzwene hlangana nebekhabo makoti nomkhwenyana bona [[umtjhado]] uyenzeka. 

Emtjhadweni wesimanje umakoti akabhathi irogo elimhlophe kodwana ingubo (ibhidi)&lt;ref&gt;https://www.aranda.co.za/products/ibhidi-black-red?srsltid=AfmBOoqbSE9obFHO_Sfhz-KeumQT4-e3MxlZFtG-ufzYvxU4rouknTc_&lt;/ref&gt; ngilo irogo lakhe, umkhwenyana yena angabhatha ibhanji nokhunywe kwesintu. Ngelanga lomtjhado imideni izokunikezana izipho ukuthokoza ukuhlangana kwabentwana (abantu abatjhadako).&lt;ref&gt;[https://cite.org.zw/modern-ndebele-marriage-practices/#:~:text=Gift%20exchange:%20Once%20the%20relationship,absence%20of%20the%20other%20partner. https://cite.org.zw/modern-ndebele-marriage-practices/#:~:text=Gift%20exchange:%20Once%20the%20relationship,absence%20of%20the%20other%20partner.]&lt;/ref&gt; Ngemva kwalomtjhado asikho isizathu sokobanyana ubekhona omunye umtjhado. Mtjhado omuhle wona begodu kunengi okwenzekako okukarisako.  

== Umthombo lwazi ==
[[Mkhakha:Umtjhado]]
[[Mkhakha:Amalobolo]]
[[Mkhakha:Ukwenda komtazana]]</text>
      <sha1>46r2csd59wgqqsm23phaompfco25ofs</sha1>
    </revision>
    <revision>
      <id>6705</id>
      <parentid>6704</parentid>
      <timestamp>2026-06-12T08:55:21Z</timestamp>
      <contributor>
        <username>MissHadassah</username>
        <id>1561</id>
      </contributor>
      <comment>changed formatting</comment>
      <origin>6705</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1989" sha1="tvnk31k6hn01deqpvwx8tk5z2foockr" xml:space="preserve">'''Kuyafika''' isikhathi lapha khona umuntu azitjela bona sele kusikhathi ''sokuthatha, sokwenda, sokutjhada''. Umtjhado mnyanya ohlanganisa imindeni emibili, umndeni kamakoti kanye nomkhwenyana. Umnyanya ofana nesimaje mnyanya oyenzeka ngemva kwamalobolo. [[Ilobolo|Amalobolo]] kulapha kuhlala khona imindeni yabantu abazokutjhada, bakomkhwenyana bangakhipha iinkomo, imali, izipho bazikhiphela bekhabo makoti.&lt;ref&gt;https://ww2.coh.ukzn.ac.za/news/2025/05/ilobolo-under-the-lens-in-masters-study/&lt;/ref&gt;[[Isimumathi:Abomma nabo baba.jpg|thumb|umalukazana nomkhwenyana ]]

== Khuyini isimanje ==
Isimanje siyafana nomtjhado wetjhila elimhlophe kodwana ngewesintu samaNdebele. Isimanje senzeka ngemva kwamalobolo lapha khona umakoti azilungiselela ukuya ekhakwakhe (khabo likamkhwenyana) ayokufundiswa imithetho yalapho. Umakoti uzokuhlala isikhathanyana emzini ngaphambi kobanyana bayokuhlangana nomkhwenyana batjho iimfungo zabo bafake nenzilamunwana. Ngemva kokuvumelwana kuzwene hlangana nebekhabo makoti nomkhwenyana bona [[umtjhado]] uyenzeka. 

Emtjhadweni  wesimanje vambane isphetho, umakoti akabhathi irogo elimhlophe kodwana ingubo (ibhidi)&lt;ref&gt;https://www.aranda.co.za/products/ibhidi-black-red?srsltid=AfmBOoqbSE9obFHO_Sfhz-KeumQT4-e3MxlZFtG-ufzYvxU4rouknTc_&lt;/ref&gt; ngilo irogo lakhe, umkhwenyana yena angabhatha ibhanji nokhunywe kwesintu. Ngelanga lomtjhado imideni izokunikezana izipho ukuthokoza ukuhlangana kwabentwana (abantu abatjhadako).&lt;ref&gt;[https://cite.org.zw/modern-ndebele-marriage-practices/#:~:text=Gift%20exchange:%20Once%20the%20relationship,absence%20of%20the%20other%20partner. https://cite.org.zw/modern-ndebele-marriage-practices/#:~:text=Gift%20exchange:%20Once%20the%20relationship,absence%20of%20the%20other%20partner.]&lt;/ref&gt; Ngemva kwalomtjhado asikho isizathu sokobanyana ubekhona omunye umtjhado. Mtjhado omuhle wona begodu kunengi okwenzekako okukarisako.  

== Umthombo lwazi ==
[[Mkhakha:Umtjhado]]
[[Mkhakha:Amalobolo]]
[[Mkhakha:Ukwenda komtazana]]</text>
      <sha1>tvnk31k6hn01deqpvwx8tk5z2foockr</sha1>
    </revision>
  </page>
  <page>
    <title>Ukwetjiwa kweenkoloyi ezidala eSewula Afrika</title>
    <ns>0</ns>
    <id>963</id>
    <revision>
      <id>5866</id>
      <timestamp>2025-09-30T13:00:55Z</timestamp>
      <contributor>
        <username>MBIJANA123</username>
        <id>998</id>
      </contributor>
      <comment>I have not changed much bu created an article about old cars being stolen more recently</comment>
      <origin>5866</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1188" sha1="1yda8yxolnjfe0fe4o7e4m71nw50f2g" xml:space="preserve">'''Ukwetjiwa kweenkoloyi ezidala esewula Afrika''', semkhuba omutjha okhona emalangeni esiphila kiwo la, ngombana amalanga la iingebengu sezizithathela iinkoloyi ezidala ngebanga lokoban zona azinalo izinga le theknoloji eselikhona enkoloyini ezitja nofana eziqeda ukwenziwa amalanga, ngalokho ke kwenza bonyana kube lula bonyana iingebengu zikwazi ukuzithatha lula ngaphandle kokobana zitlhage.
[[Isimumathi:Old US cars in Havana - Flickr - exfordy.jpg|thumb|442x442px|Iinkoloyi ezetjiwako mihlobo efana nale engehla esithombeni.]]

=== Inkoloyi ezetjiwako ===
iinzathu ezenza bona iinkoloyi ezidala zetjiwe khulu mamalanga kukobana iinsimbi zakhona zokobana zilunge azisatholakali entolo emalanga, ngebanga sikobana sekungezakade khulu begodu eentolo sebaphatha iinsimbi zenkoloyi zanamhlanjesi. yeke ke lokhu kwenza bona iinkoloyi ezidala zingasakwazi ukulungiseka, lokhu kumthelela omumbi ekoloyini ezidala ngombana uthola bonyana abanikazi basazithanda  begodu bangenza nomayini ukwenza bona iinkoloyi abo zihlala zisesimeni isihle sepilo. Okwenza bona iinlelesi zikwazi ukuthatha inkoyezi kangaka kukobana bayakwazi ukuzidumisa ngentambo nangezinye indlela zokobana bazidumise lula.</text>
      <sha1>1yda8yxolnjfe0fe4o7e4m71nw50f2g</sha1>
    </revision>
    <revision>
      <id>5876</id>
      <parentid>5866</parentid>
      <timestamp>2025-09-30T13:16:48Z</timestamp>
      <contributor>
        <username>MBIJANA123</username>
        <id>998</id>
      </contributor>
      <minor />
      <comment>added reference</comment>
      <origin>5876</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1364" sha1="dvhbu5ezz3pwgok8i85qiqfalyxbe7p" xml:space="preserve">'''Ukwetjiwa kweenkoloyi ezidala esewula Afrika''', semkhuba omutjha okhona emalangeni esiphila kiwo la, ngombana amalanga la iingebengu sezizithathela iinkoloyi ezidala ngebanga lokoban zona azinalo izinga le theknoloji eselikhona enkoloyini ezitja nofana eziqeda ukwenziwa amalanga, ngalokho ke kwenza bonyana kube lula bonyana iingebengu zikwazi ukuzithatha lula ngaphandle kokobana zitlhage.&lt;ref&gt;https://rucore.libraries.rutgers.edu/rutgers-lib/36286/&lt;/ref&gt;
[[Isimumathi:Old US cars in Havana - Flickr - exfordy.jpg|thumb|442x442px|Iinkoloyi ezetjiwako mihlobo efana nale engehla esithombeni.]]

=== Inkoloyi ezetjiwako ===
iinzathu ezenza bona iinkoloyi ezidala zetjiwe khulu mamalanga kukobana iinsimbi zakhona zokobana zilunge azisatholakali entolo emalanga, ngebanga sikobana sekungezakade khulu begodu eentolo sebaphatha iinsimbi zenkoloyi zanamhlanjesi. yeke ke lokhu kwenza bona iinkoloyi ezidala zingasakwazi ukulungiseka, lokhu kumthelela omumbi ekoloyini ezidala ngombana uthola bonyana abanikazi basazithanda  begodu bangenza nomayini ukwenza bona iinkoloyi abo zihlala zisesimeni isihle sepilo. Okwenza bona iinlelesi zikwazi ukuthatha inkoyezi kangaka kukobana bayakwazi ukuzidumisa ngentambo nangezinye indlela zokobana bazidumise lula.&lt;ref&gt;https://journals.library.ualberta.ca/pandpr/index.php/pandpr/article/view/29434&lt;/ref&gt;

== Isilululwazi ==</text>
      <sha1>dvhbu5ezz3pwgok8i85qiqfalyxbe7p</sha1>
    </revision>
    <revision>
      <id>5878</id>
      <parentid>5876</parentid>
      <timestamp>2025-09-30T13:24:36Z</timestamp>
      <contributor>
        <username>MBIJANA123</username>
        <id>998</id>
      </contributor>
      <minor />
      <comment>removed a sub heading and added a heading</comment>
      <origin>5878</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1362" sha1="7j3ktc5ab7piyavrdqcuzvav8y6uwmn" xml:space="preserve">'''Ukwetjiwa kweenkoloyi ezidala esewula Afrika''', semkhuba omutjha okhona emalangeni esiphila kiwo la, ngombana amalanga la iingebengu sezizithathela iinkoloyi ezidala ngebanga lokoban zona azinalo izinga le theknoloji eselikhona enkoloyini ezitja nofana eziqeda ukwenziwa amalanga, ngalokho ke kwenza bonyana kube lula bonyana iingebengu zikwazi ukuzithatha lula ngaphandle kokobana zitlhage.&lt;ref&gt;https://rucore.libraries.rutgers.edu/rutgers-lib/36286/&lt;/ref&gt;
[[Isimumathi:Old US cars in Havana - Flickr - exfordy.jpg|thumb|442x442px|Iinkoloyi ezetjiwako mihlobo efana nale engehla esithombeni.]]

== Inkoloyi ezetjiwako ==
iinzathu ezenza bona iinkoloyi ezidala zetjiwe khulu mamalanga kukobana iinsimbi zakhona zokobana zilunge azisatholakali entolo emalanga, ngebanga sikobana sekungezakade khulu begodu eentolo sebaphatha iinsimbi zenkoloyi zanamhlanjesi. yeke ke lokhu kwenza bona iinkoloyi ezidala zingasakwazi ukulungiseka, lokhu kumthelela omumbi ekoloyini ezidala ngombana uthola bonyana abanikazi basazithanda  begodu bangenza nomayini ukwenza bona iinkoloyi abo zihlala zisesimeni isihle sepilo. Okwenza bona iinlelesi zikwazi ukuthatha inkoyezi kangaka kukobana bayakwazi ukuzidumisa ngentambo nangezinye indlela zokobana bazidumise lula.&lt;ref&gt;https://journals.library.ualberta.ca/pandpr/index.php/pandpr/article/view/29434&lt;/ref&gt;

== Isilululwazi ==</text>
      <sha1>7j3ktc5ab7piyavrdqcuzvav8y6uwmn</sha1>
    </revision>
    <revision>
      <id>5888</id>
      <parentid>5878</parentid>
      <timestamp>2025-09-30T18:16:36Z</timestamp>
      <contributor>
        <username>MBIJANA123</username>
        <id>998</id>
      </contributor>
      <comment>just fixed a spelling</comment>
      <origin>5888</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1363" sha1="qyfxntb2ojif2wp2m414kmiempth6u4" xml:space="preserve">'''Ukwetjiwa kweenkoloyi ezidala esewula Afrika''', semkhuba omutjha okhona emalangeni esiphila kiwo la, ngombana amalanga la iingebengu sezizithathela iinkoloyi ezidala ngebanga lokoban zona azinalo izinga le theknoloji eselikhona enkoloyini ezitja nofana eziqeda ukwenziwa amalanga, ngalokho ke kwenza bonyana kube lula bonyana iingebengu zikwazi ukuzithatha lula ngaphandle kokobana zitlhage.&lt;ref&gt;https://rucore.libraries.rutgers.edu/rutgers-lib/36286/&lt;/ref&gt;
[[Isimumathi:Old US cars in Havana - Flickr - exfordy.jpg|thumb|442x442px|Iinkoloyi ezetjiwako mihlobo efana nale engehla esithombeni.]]

== Iinkoloyi ezetjiwako ==
iinzathu ezenza bona iinkoloyi ezidala zetjiwe khulu mamalanga kukobana iinsimbi zakhona zokobana zilunge azisatholakali entolo emalanga, ngebanga sikobana sekungezakade khulu begodu eentolo sebaphatha iinsimbi zenkoloyi zanamhlanjesi. yeke ke lokhu kwenza bona iinkoloyi ezidala zingasakwazi ukulungiseka, lokhu kumthelela omumbi ekoloyini ezidala ngombana uthola bonyana abanikazi basazithanda  begodu bangenza nomayini ukwenza bona iinkoloyi abo zihlala zisesimeni isihle sepilo. Okwenza bona iinlelesi zikwazi ukuthatha inkoyezi kangaka kukobana bayakwazi ukuzidumisa ngentambo nangezinye indlela zokobana bazidumise lula.&lt;ref&gt;https://journals.library.ualberta.ca/pandpr/index.php/pandpr/article/view/29434&lt;/ref&gt;

== Isilululwazi ==</text>
      <sha1>qyfxntb2ojif2wp2m414kmiempth6u4</sha1>
    </revision>
    <revision>
      <id>5939</id>
      <parentid>5888</parentid>
      <timestamp>2025-11-01T11:53:46Z</timestamp>
      <contributor>
        <username>Hlalithwa</username>
        <id>996</id>
      </contributor>
      <minor />
      <comment>ukwetjiwa kweenkoloyi enarheni yekhethu</comment>
      <origin>5939</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1375" sha1="85ntcglfugkt4z1b87bgd0jy89rkcpo" xml:space="preserve">'''Ukwetjiwa kweenkoloyi ezidala esewula Afrika''', semkhuba omutjha okhona emalangeni esiphila kiwo la, ngombana amalanga la iingebengu sezizithathela iinkoloyi ezidala ngebanga lokobana zona azinalo izinga le theknoloji eselikhona enkoloyini ezitja nofana eziqeda ukwenziwa amalanga la, ngalokho ke kwenza bonyana kube lula bonyana iingebengwezi zikwazi ukuzithatha lula ngaphandle kokobana zitlhage.&lt;ref&gt;https://rucore.libraries.rutgers.edu/rutgers-lib/36286/&lt;/ref&gt;
[[Isimumathi:Old US cars in Havana - Flickr - exfordy.jpg|thumb|442x442px|Iinkoloyi ezetjiwako mihlobo efana nale engehla esithombeni.]]

== Iinkoloyi ezetjiwako ==
iinzathu ezenza bona iinkoloyi ezidala zetjiwe khulu malangala kukobana iinsimbi zakhona zokobana zilunge azisatholakali entolo, ngesibanga sokobana sekungezakade khulu begodu eentolo sebaphatha iinsimbi zenkoloyi zanamhlanjesi. yeke ke lokhu kwenza bona iinkoloyi ezidala zingasakwazi ukulungiseka, lokhu kumthelela omumbi ekoloyini ezidala ngombana uthola bonyana abanikazi bazo basazithanda  begodu bangenza nanyana yini ukwenza bona iinkoloyi zabo zihlala zisesimeni isihle sepilo. Okwenza bona iinlelesi zikwazi ukuthatha inkoloyezi kangaka kukobana bayakwazi ukuzidumisa ngentambo nangezinye indlela zokobana bazidumise lula.&lt;ref&gt;https://journals.library.ualberta.ca/pandpr/index.php/pandpr/article/view/29434&lt;/ref&gt;

== Isilululwazi ==</text>
      <sha1>85ntcglfugkt4z1b87bgd0jy89rkcpo</sha1>
    </revision>
  </page>
  <page>
    <title>Isitjhaba SamaNdebele</title>
    <ns>0</ns>
    <id>964</id>
    <revision>
      <id>5867</id>
      <timestamp>2025-09-30T13:05:45Z</timestamp>
      <contributor>
        <username>Ntonto23</username>
        <id>999</id>
      </contributor>
      <comment>added a reference</comment>
      <origin>5867</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3593" sha1="q3qd2h1o89xps5gmy31nffz9kcuq6ia" xml:space="preserve">'''AmaNdebele''' babantu abanzima abatholakala endaweni yangakwaMhlanga ukuya emva le kiboSiyabuswa, esifundeni sePumalanga kanye nesifundeni sange-Gauteng, eSewula Afrikha. Bababantu abaziwa ngemibala ekhanyako nemigwalo emihle. Baziwa nangokuba nobuntu nethando. &lt;ref&gt;https://ndebelekingdom.org/history&lt;/ref&gt;
[[Isimumathi:Mapoch.- Femmes Ndebele in Cultural Village (2).jpg|thumb]]

== Ilimi ==
AmaNdebele ahlukane kabili, sinamaNzunza naManala. AManala abuswa yiNgwenyama uMakhosonke II bese kuthi amaNzunza wona abuswe yiNgwenyama uMabhoko III.&lt;ref&gt;https://ndebelekingdom.org/history&lt;/ref&gt; Amalimi abawakhulumako akafani kukhamba kuba nomehluko omncani lapho nalapho. Isibonelo, amaNzunza ayadla aManala ayagoma. AmaNzunza abuya ageze bese aManala acophe.&lt;ref&gt;https://www.krugerpark.co.za/africa_ndebele.html&lt;/ref&gt;

== Ivunulo ==
Amandebele avunula ngokuya ngokweengaba zawo. umntazana, itlawana nomma abavunuli ivunulo efanako. ngokufanako nabobaba nabasegwabo. Abomma bamaNdebele babonakala ngedzila entanyeni, iinrholwani zeenyaweni ezimbili inyawo ngalinye, bavunule nengubo ebizwa ngebhidi enombala onzima nobovu, ukutjengisa bona sele babafazi bakosobantu. Ibhidi balimbatha khulukhulu nabaya eminyanyeni ethileko yamaNdebele. Bambatha netjorholo nesithimba. Amatlwana wona avunula irasu, ithawula bese bafake nerhabi phezulu. Abobaba bambatha amaporiyana, abogedlami nemitjhotjho. Sibe nengubo enimibala emihlanu ekhanyako ebizwa ngombhalo nofana unokhethwabo yona embatha masokana nakabuya engomeni nabentazana abenze umnyanya wequde.&lt;ref&gt;https://ndebelekingdom.org/history&lt;/ref&gt;

== Ukudla ==
Amandebele adla ukudla okufaka hlangana iinredlho, itlhodlho, igcatjha, umrorho, umratha, amabhutata kanye namatjhatjhatjha. &lt;ref&gt;https://ndebelekingdom.org/history&lt;/ref&gt;

== Amasiko nomvumo ==
Isitjhaba samaNdebele saziwa ngomvumo waso omnandi nopholileko owenzwa ngokusebenzisa iinsimbi neenodo. Ezifana negatara, isidonodono, iskewura, amahlwayi neewahlo. Umvumabo ubaneembongo zeenkosi, iingwenyama kunye namasikwabo. Imivumabo iba neemfundo ongazithola. Bavuma iingoma zabo eminyanyeni efana nedwende, iqude, umnyanya wamasokana, ukuhlabisa iinzukulwana, nokungenisa abobaba hlangana kweminye yawo. &lt;ref&gt;https://ndebelekingdom.org/history&lt;/ref&gt;

Amasikwabo afakahlangana amasikopilo afana nengoma, iqude nedwendwe. Ingoma kulokha umsana akhamba naboyise nabomnakwabo entabeni ayokuthatha ubusokana bakhe bekathole nentanga. Kuthi iqude ke mnyanya wokukhulisa umntwana womntazana osele akhulakhulile lapha ayokuyalwa khona ngokuziphatha nomemdo. Yena-ke akabonani nabantu abaduna nebemzini isikhathi esithileko bekudle iqude kube mhlubulwakhe ngombana vane azilile. Idwendwe lona mtjhado wesiNdebele lapha isokana eliwelileko elinentanga lithatha umntazana othombileko lizomvunulisa iitjorholo zakwabo. Bese kuthi ngeLesihlanu umkhwenyana lo aphekelelwe bangani bakhe bentangakhe base umakoti kwabo naye aphekelelwa bafazi bemzini endele kiwo bamuse kwabo neenkomo nofana nobukhazi nedwendwe. Sibe nomnynya wokungenisa abobaba lomnyanya wokungenisa uSosokana ngakwandodanakhe nabakhaphi bakhe. &lt;ref&gt;https://ndebelekingdom.org/history&lt;/ref&gt;

== Ukuziphatha ==
Amandebele babantu abahlonipha khulu, umuntu omdala nakakhulumako umntwana uyalalela begodu agobe ihloko akaphenduli bangakamtjeli bona enze njalo. Abantu abadala balotjhiswa ngezandla zombili nofana ngasinye ngokusekela esingaphasi. Byazi bona umuntu uyalotjhiswa nanyana amncani, ihlonipho ayikhethi minyaka. Nabalotjhisako bathi &quot;Lotjhani&quot; nofana &quot;Akwande&quot; okutjho bona akwande umusa, ukuthula nethando. 

== Imikhombo ==</text>
      <sha1>q3qd2h1o89xps5gmy31nffz9kcuq6ia</sha1>
    </revision>
    <revision>
      <id>5868</id>
      <parentid>5867</parentid>
      <timestamp>2025-09-30T13:06:30Z</timestamp>
      <contributor>
        <username>Ntonto23</username>
        <id>999</id>
      </contributor>
      <minor />
      <origin>5868</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3413" sha1="gv72dl0fl07uehvjsrr65fvp7tpjyxs" xml:space="preserve">'''AmaNdebele''' babantu abanzima abatholakala endaweni yangakwaMhlanga ukuya emva le kiboSiyabuswa, esifundeni sePumalanga kanye nesifundeni sange-Gauteng, eSewula Afrikha. Bababantu abaziwa ngemibala ekhanyako nemigwalo emihle. Baziwa nangokuba nobuntu nethando. &lt;ref&gt;https://ndebelekingdom.org/history&lt;/ref&gt;
[[Isimumathi:Mapoch.- Femmes Ndebele in Cultural Village (2).jpg|thumb]]

== Ilimi ==
AmaNdebele ahlukane kabili, sinamaNzunza naManala. AManala abuswa yiNgwenyama uMakhosonke II bese kuthi amaNzunza wona abuswe yiNgwenyama uMabhoko III.&lt;ref&gt;https://ndebelekingdom.org/history&lt;/ref&gt; Amalimi abawakhulumako akafani kukhamba kuba nomehluko omncani lapho nalapho. Isibonelo, amaNzunza ayadla aManala ayagoma. AmaNzunza abuya ageze bese aManala acophe.&lt;ref&gt;https://www.krugerpark.co.za/africa_ndebele.html&lt;/ref&gt;

== Ivunulo ==
Amandebele avunula ngokuya ngokweengaba zawo. umntazana, itlawana nomma abavunuli ivunulo efanako. ngokufanako nabobaba nabasegwabo. Abomma bamaNdebele babonakala ngedzila entanyeni, iinrholwani zeenyaweni ezimbili inyawo ngalinye, bavunule nengubo ebizwa ngebhidi enombala onzima nobovu, ukutjengisa bona sele babafazi bakosobantu. Ibhidi balimbatha khulukhulu nabaya eminyanyeni ethileko yamaNdebele. Bambatha netjorholo nesithimba. Amatlwana wona avunula irasu, ithawula bese bafake nerhabi phezulu. Abobaba bambatha amaporiyana, abogedlami nemitjhotjho. Sibe nengubo enimibala emihlanu ekhanyako ebizwa ngombhalo nofana unokhethwabo yona embatha masokana nakabuya engomeni nabentazana abenze umnyanya wequde.

== Ukudla ==
Amandebele adla ukudla okufaka hlangana iinredlho, itlhodlho, igcatjha, umrorho, umratha, amabhutata kanye namatjhatjhatjha. 

== Amasiko nomvumo ==
Isitjhaba samaNdebele saziwa ngomvumo waso omnandi nopholileko owenzwa ngokusebenzisa iinsimbi neenodo. Ezifana negatara, isidonodono, iskewura, amahlwayi neewahlo. Umvumabo ubaneembongo zeenkosi, iingwenyama kunye namasikwabo. Imivumabo iba neemfundo ongazithola. Bavuma iingoma zabo eminyanyeni efana nedwende, iqude, umnyanya wamasokana, ukuhlabisa iinzukulwana, nokungenisa abobaba hlangana kweminye yawo. 

Amasikwabo afakahlangana amasikopilo afana nengoma, iqude nedwendwe. Ingoma kulokha umsana akhamba naboyise nabomnakwabo entabeni ayokuthatha ubusokana bakhe bekathole nentanga. Kuthi iqude ke mnyanya wokukhulisa umntwana womntazana osele akhulakhulile lapha ayokuyalwa khona ngokuziphatha nomemdo. Yena-ke akabonani nabantu abaduna nebemzini isikhathi esithileko bekudle iqude kube mhlubulwakhe ngombana vane azilile. Idwendwe lona mtjhado wesiNdebele lapha isokana eliwelileko elinentanga lithatha umntazana othombileko lizomvunulisa iitjorholo zakwabo. Bese kuthi ngeLesihlanu umkhwenyana lo aphekelelwe bangani bakhe bentangakhe base umakoti kwabo naye aphekelelwa bafazi bemzini endele kiwo bamuse kwabo neenkomo nofana nobukhazi nedwendwe. Sibe nomnynya wokungenisa abobaba lomnyanya wokungenisa uSosokana ngakwandodanakhe nabakhaphi bakhe. 

== Ukuziphatha ==
Amandebele babantu abahlonipha khulu, umuntu omdala nakakhulumako umntwana uyalalela begodu agobe ihloko akaphenduli bangakamtjeli bona enze njalo. Abantu abadala balotjhiswa ngezandla zombili nofana ngasinye ngokusekela esingaphasi. Byazi bona umuntu uyalotjhiswa nanyana amncani, ihlonipho ayikhethi minyaka. Nabalotjhisako bathi &quot;Lotjhani&quot; nofana &quot;Akwande&quot; okutjho bona akwande umusa, ukuthula nethando. 

== Imikhombo ==</text>
      <sha1>gv72dl0fl07uehvjsrr65fvp7tpjyxs</sha1>
    </revision>
    <revision>
      <id>5886</id>
      <parentid>5868</parentid>
      <timestamp>2025-09-30T13:47:32Z</timestamp>
      <contributor>
        <username>Ntonto23</username>
        <id>999</id>
      </contributor>
      <comment>added references and links</comment>
      <origin>5886</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4016" sha1="ay6cp5vrfz002g97dqxf1ssv21mbu1q" xml:space="preserve">'''AmaNdebele''' babantu abanzima abatholakala endaweni yangakwaMhlanga ukuya emva le kiboSiyabuswa, esifundeni sePumalanga kanye nesifundeni sange-Gauteng, eSewula Afrikha. Bababantu abaziwa ngemibala ekhanyako nemigwalo emihle. Baziwa nangokuba nobuntu nethando. &lt;ref&gt;https://ndebelekingdom.org/history&lt;/ref&gt;
[[Isimumathi:Mapoch.- Femmes Ndebele in Cultural Village (2).jpg|thumb]]

== Ilimi ==
AmaNdebele ahlukane kabili, sinamaNzunza naManala. AManala abuswa yiNgwenyama uMakhosonke II bese kuthi amaNzunza wona abuswe yiNgwenyama uMabhoko III.&lt;ref&gt;https://ndebelekingdom.org/history&lt;/ref&gt; [[Amalimi WeSewula Afrika|Amalimi]] abawakhulumako akafani kukhamba kuba nomehluko omncani lapho nalapho. Isibonelo, amaNzunza ayadla aManala ayagoma. AmaNzunza abuya ageze bese aManala acophe.&lt;ref&gt;https://www.krugerpark.co.za/africa_ndebele.html&lt;/ref&gt;

== Ivunulo ==
[[AmaNdebele|Amandebele]] avunula ngokuya ngokweengaba zawo. umntazana, itlawana nomma abavunuli ivunulo efanako. ngokufanako nabobaba nabasegwabo. Abomma bamaNdebele babonakala ngedzila entanyeni, iinrholwani zeenyaweni ezimbili inyawo ngalinye, bavunule nengubo ebizwa ngebhidi enombala onzima nobovu, ukutjengisa bona sele babafazi bakosobantu.&lt;ref&gt;https://www.africancraftsmarket.com/african-tribes/ndebele-people.html&lt;/ref&gt; Ibhidi balimbatha khulukhulu nabaya eminyanyeni ethileko yamaNdebele. Bambatha netjorholo nesithimba. Amatlwana wona avunula irasu, ithawula bese bafake nerhabi phezulu. Abobaba bambatha amaporiyana, abogedlami nemitjhotjho. Sibe nengubo enimibala emihlanu ekhanyako ebizwa ngombhalo nofana unokhethwabo yona embatha masokana nakabuya engomeni nabentazana abenze umnyanya wequde.&lt;ref&gt;https://www.krugerpark.co.za/africa_ndebele.html&lt;/ref&gt;

== Ukudla ==
Amandebele adla ukudla okufaka hlangana iinredlho, itlhodlho, igcatjha, [[U-Dorhodere Nothembi Mkhwebane|umrorho]], umratha, amabhutata kanye namatjhatjhatjha.&lt;ref&gt;https://www.britannica.com/topic/Ndebele-South-African-people&lt;/ref&gt; 

== Amasiko nomvumo ==
Isitjhaba samaNdebele saziwa ngomvumo waso omnandi nopholileko owenzwa ngokusebenzisa iinsimbi neenodo. Ezifana negatara, isidonodono, iskumere, amahlwayi neewahlo. Umvumabo ubaneembongo zeenkosi, iingwenyama kunye namasikwabo. Imivumabo iba neemfundo ongazithola. Bavuma iingoma zabo eminyanyeni efana nedwende, iqude, umnyanya wamasokana, ukuhlabisa iinzukulwana, nokungenisa abobaba hlangana kweminye yawo.&lt;ref&gt;https://mukurukurumedia.wordpress.com/2015/09/21/queen-of-ndebele-music-on-a-mission-to-preserve-heritage-and-culture/&lt;/ref&gt; 

Amasikwabo afakahlangana amasikopilo afana nengoma, iqude nedwendwe. Ingoma kulokha umsana akhamba naboyise nabomnakwabo entabeni ayokuthatha ubusokana bakhe bekathole nentanga. Kuthi iqude ke mnyanya wokukhulisa umntwana womntazana osele akhulakhulile lapha ayokuyalwa khona ngokuziphatha nomemdo. Yena-ke akabonani nabantu abaduna nebemzini isikhathi esithileko bekudle iqude kube mhlubulwakhe ngombana vane azilile.&lt;ref&gt;https://sahistory.org.za/article/ndebele&lt;/ref&gt;Idwendwe lona mtjhado wesiNdebele lapha isokana eliwelileko elinentanga lithatha umntazana othombileko lizomvunulisa iitjorholo zakwabo. Bese kuthi ngeLesihlanu umkhwenyana lo aphekelelwe bangani bakhe bentangakhe base umakoti kwabo naye aphekelelwa bafazi bemzini endele kiwo bamuse kwabo neenkomo nofana nobukhazi nedwendwe. Sibe nomnyanya wokungenisa abobaba lo mnyanya wokungenisa uSosokana ngakwandodanakhe akhamba nabakhambisanani bakhe okungaba banakwabo nabangani bakhe. 

== [[Ukuziphatha kuhle.|Ukuziphath]]&lt;nowiki/&gt;a ==
Amandebele babantu abahlonipha khulu, umuntu omdala nakakhulumako umntwana uyalalela begodu agobe ihloko akaphenduli bangakamtjeli bona enze njalo. Abantu abadala balotjhiswa ngezandla zombili nofana ngasinye ngokusekela esingaphasi. Byazi bona umuntu uyalotjhiswa nanyana amncani, ihlonipho ayikhethi minyaka. Nabalotjhisako bathi &quot;Lotjhani&quot; nofana &quot;Akwande&quot; okutjho bona akwande umusa, ukuthula nethando.&lt;ref&gt;https://sahistory.org.za/article/ndebele&lt;/ref&gt; 

== Imikhombo ==</text>
      <sha1>ay6cp5vrfz002g97dqxf1ssv21mbu1q</sha1>
    </revision>
    <revision>
      <id>5887</id>
      <parentid>5886</parentid>
      <timestamp>2025-09-30T13:56:20Z</timestamp>
      <contributor>
        <username>Ntonto23</username>
        <id>999</id>
      </contributor>
      <comment>spelling errors</comment>
      <origin>5887</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4018" sha1="elihxg84s5gadpwnpu8da5ya9okc0pi" xml:space="preserve">'''AmaNdebele''' babantu abanzima abatholakala endaweni yangakwaMhlanga ukuya emva le kiboSiyabuswa, esifundeni sePumalanga kanye nesifundeni sange-Gauteng, eSewula Afrikha. Bababantu abaziwa ngemibala ekhanyako nemigwalo emihle. Baziwa nangokuba nobuntu nethando. &lt;ref&gt;https://ndebelekingdom.org/history&lt;/ref&gt;
[[Isimumathi:Mapoch.- Femmes Ndebele in Cultural Village (2).jpg|thumb]]

== Ilimi ==
AmaNdebele ahlukane kabili, sinamaNzunza naManala. AManala abuswa yiNgwenyama uMakhosonke II bese kuthi amaNzunza wona abuswe yiNgwenyama uMabhoko III.&lt;ref&gt;https://ndebelekingdom.org/history&lt;/ref&gt; [[Amalimi WeSewula Afrika|Amalimi]] abawakhulumako akafani kukhamba kuba nomehluko omncani lapho nalapho. Isibonelo, amaNzunza ayadla aManala ayagoma. AmaNzunza abuya ageze bese aManala acophe.&lt;ref&gt;https://www.krugerpark.co.za/africa_ndebele.html&lt;/ref&gt;

== Ivunulo ==
[[AmaNdebele|Amandebele]] avunula ngokuya ngokweengaba zawo. Umntazana, itlawana nomma abavunuli ivunulo efanako. ngokufanako nabobaba nabasegwabo. Abomma bamaNdebele babonakala ngedzila entanyeni, iinrholwani zeenyaweni ezimbili inyawo ngalinye, bavunule nengubo ebizwa ngebhidi enombala onzima nobovu, ukutjengisa bona sele babafazi bakosobantu.&lt;ref&gt;https://www.africancraftsmarket.com/african-tribes/ndebele-people.html&lt;/ref&gt; Ibhidi balimbatha khulukhulu nabaya eminyanyeni ethileko yamaNdebele. Bambatha netjorholo nesithimba. Amatlwana wona avunula irasu, ithawula bese bafake nerhabi phezulu. Abobaba bambatha amaporiyana, abogedlami nemitjhotjho. Sibe nengubo enimibala emihlanu ekhanyako ebizwa ngombhalo nofana unokhethwabo yona embathwa masokana nakabuya engomeni nabentazana abenze umnyanya wequde.&lt;ref&gt;https://www.krugerpark.co.za/africa_ndebele.html&lt;/ref&gt;

== Ukudla ==
Amandebele adla ukudla okufaka hlangana iinredlho, itlhodlho, igcatjha, [[U-Dorhodere Nothembi Mkhwebane|umrorho]], umratha, amabhutata kanye namatjhatjhatjha.&lt;ref&gt;https://www.britannica.com/topic/Ndebele-South-African-people&lt;/ref&gt; 

== Amasiko nomvumo ==
Isitjhaba samaNdebele saziwa ngomvumo waso omnandi nopholileko owenzwa ngokusebenzisa iinsimbi neenodo. Ezifana negatara, isidonodono, iskumere, amahlwayi neewahlo. Umvumabo ubaneembongo zeenkosi, iingwenyama kunye namasikwabo. Imivumabo iba neemfundo ongazithola. Bavuma iingoma zabo eminyanyeni efana nedwende, iqude, umnyanya wamasokana, ukuhlabisa iinzukulwana, nokungenisa abobaba hlangana kweminye yawo.&lt;ref&gt;https://mukurukurumedia.wordpress.com/2015/09/21/queen-of-ndebele-music-on-a-mission-to-preserve-heritage-and-culture/&lt;/ref&gt; 

Amasikwabo afakahlangana amasikopilo afana nengoma, iqude nedwendwe. Ingoma kulokha umsana akhamba naboyise nabomnakwabo entabeni ayokuthatha ubusokana bakhe bekathole nentanga. Kuthi iqude ke mnyanya wokukhulisa umntwana womntazana osele akhulakhulile lapha ayokuyalwa khona ngokuziphatha nomemdo. Yena-ke akabonani nabantu abaduna nebemzini isikhathi esithileko bekudle iqude kube mhlubulwakhe ngombana vane azilile.&lt;ref&gt;https://sahistory.org.za/article/ndebele&lt;/ref&gt;Idwendwe lona mtjhado wesiNdebele lapha isokana eliwelileko elinentanga lithatha umntazana othombileko lizomvunulisa iitjorholo zakwabo. Bese kuthi ngeLesihlanu umkhwenyana lo aphekelelwe bangani bakhe bentangakhe base umakoti kwabo naye aphekelelwa bafazi bemzini endele kiwo bamuse kwabo neenkomo nofana nobukhazi nedwendwe. Sibe nomnyanya wokungenisa abobaba lo mnyanya wokungenisa uSosokana ngakwandodanakhe akhamba nabakhambisanani bakhe okungaba banakwabo nabangani bakhe. 

== [[Ukuziphatha kuhle.|Ukuziphath]]&lt;nowiki/&gt;a ==
Amandebele babantu abahlonipha khulu, umuntu omdala nakakhulumako umntwana uyalalela begodu agobe ihloko akaphenduli bangakamtjeli bona enze njalo. Abantu abadala balotjhiswa ngezandla zombili nofana ngasinye ngokusekela esingaphasi. Bayazi bona umuntu uyalotjhiswa nanyana amncani, ihlonipho ayikhethi minyaka. Nabalotjhisako bathi &quot;Lotjhani&quot; nofana &quot;Akwande&quot; okutjho bona akwande umusa, ukuthula nethando.&lt;ref&gt;https://sahistory.org.za/article/ndebele&lt;/ref&gt; 

== Imikhombo ==</text>
      <sha1>elihxg84s5gadpwnpu8da5ya9okc0pi</sha1>
    </revision>
  </page>
  <page>
    <title>Hlomisa umntwanakho</title>
    <ns>0</ns>
    <id>965</id>
    <revision>
      <id>5870</id>
      <timestamp>2025-09-30T13:07:51Z</timestamp>
      <contributor>
        <username>Nosayjeni</username>
        <id>1029</id>
      </contributor>
      <comment>Added a link</comment>
      <origin>5870</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2698" sha1="3uqdmb08j7pos00n3i8nhh3q7ptkttt" xml:space="preserve">'''Kuqakathekile''' ukuhlomisa umntwanakho epilweni ngombana lokho kuzomenza umuntu onesimilo begodu okwaziko ukuphilisana nabanye abantu. Kazi umhlomisa ngani umntwanakho? Ngemikhwa? Ngeenkhala ezibulalako? Awa, [[akukhulunywa ngeenkhali zokubulala nofana zokulelesa]]. Umntwana umhlomisa ngeenkhali zepilo ewanikelwa zona nawe, unikelwa babelethi bakho usakhula. Iinkhali lezi ziyahlukahlukana epilweni ngonobangela wokobana asikakhuliswa babantu banye begodu iimfundiso ziyahluka emindenini.&lt;ref&gt;https://www.jw.org/xh/ILayibrari/iimagazini/g201505/ukufundisa-abantwana-ukuthobela-ibhayibhile/&lt;/ref&gt; Njengomzali, udade, umalume, umzala, ukghari njll. kukuwe ukobana udlulisele [[Ifundo sikhiya saksasa|ifundiso]] ewayifumama kugogo nofana emndenini wakho kilabo ebeza ngemva kwakho. Izinto ezilandelako zifaka hlangana iinkhali lezo ongazidlulisela komunye.

== Ukuhlwengisa ==
[[Isimumathi:Child labour 20250929.jpg|alt=Teaching children how to clean the environment they live in|thumb|Fundisa labo ebeza ngemuva kwakho ukuhlwengisa indawo ebahlala kiyo.]]
Ugogo uthanda ukuthi indawo ohlala kiyo ifana nehliziyo yakho, akusikuhle umuntu nakahlala endaweni esilaphezekileko ngombana lokho kutjho ukobana ihliziyo yakho nayo ayikahlanzeki. Njengomuntu omkhulu kukuwe ukuthi ufundise ukubaluleka kokuhlala endaweni ehlwengekileko. Izinto ongazifundisa kukuthi umuntu kufuze ahlambe izandla zakhe nakaqeda ukudlala, nakabuya endlwaneni encani, nakaqeda ukufinya, nakaqeda ukuba nomuntu ogulako. [[Izandla]] zihlanjwa ngalendlela elandelako:

# Uthoma ngokuthambisa izandla ngamanzi ahlwengekileko
# Ulandelele ngokuzela isibha ezandleni zombili
# Hlikihla izandla zakho okuncani kube mizuzwana ematjhumi amabili
# Hlakihla hlangana nemino nangemuva kwesandla
# Nawuqeda ukuhlikihla izandla zipule ngamanzi ahlwengekileko.&lt;ref name=&quot;:0&quot;&gt;https://www.healthdirect.gov.au/personal-hygiene&lt;/ref&gt;

Okungehla sibonelo sokuthi ungamfundisa bunjani umntwana ukobana ahlwengise izandla zakhe okuyifundiso ehle. Ifundiso yesibili ongayidlulisela ebantwaneni kuqakatheka kokuhlamba amazinyo, umuntu kufuze ahlambe amazinyo kabili ngelanga.&lt;ref name=&quot;:0&quot; /&gt; Ezinye zezinto eziqakathekileko  kukobana kufuze uhlwengise ibhoduluko ohlala kilo, ngombana likuphatha kuhle nawe liphathe kuhle.&lt;ref&gt;https://www.gov.za/blog/cleaner-environment-starts-us&lt;/ref&gt; Ekuphatheni i[[bhoduluko]] kuhle umuntu kufuze athanyele ngendlini mihla ngamalanga, begodu ukuze akorobhe ukuze kuhlwenge. Zinengi iindlela umuntu angazifundisa abentwana ezizobasiza ekukhuleni kwabo, Ezinye zazo ngokurhunyeziweko ngelezi ezingehla. 

== Imithombolwazi ==
[[Mkhakha:Ukuhlwengisa]]
[[Mkhakha:Abentwana]]
[[Mkhakha:Ipilo]]
[[Mkhakha:Umndeni]]</text>
      <sha1>3uqdmb08j7pos00n3i8nhh3q7ptkttt</sha1>
    </revision>
  </page>
  <page>
    <title>Ubungozi bokusetjenziswa kweendakamizwa lilutjha</title>
    <ns>0</ns>
    <id>966</id>
    <revision>
      <id>5871</id>
      <timestamp>2025-09-30T13:09:35Z</timestamp>
      <contributor>
        <username>Stillbelieveingooddays</username>
        <id>1018</id>
      </contributor>
      <comment>Created page with &quot;'''Ukusebenzisa kweendakamizwa lilutjha''' sekudlange khulu esikhathini sanje. Ilutjha selisebenzisa iindakamizwa njengento yokuzithabisa nokukhipha isizungu. Abanye bakusebenzisa ukuze bakghone ukwamukeliwa ebanganini babo, nofana emphakathini othileko. Lokho kuphetha ngokuthi bagcine bangena phakathi kobungozi obukhulu obufaka hlangana amaphilowabo. Kunzima ukwenza ilutjha leli lazi nofana lamukele bona izenzo zabo zingaphetha ngobungozi bokuthi bangalimala. Abanye bay...&quot;</comment>
      <origin>5871</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4173" sha1="laquufbds5mqb1z1g19m8feizpmzoib" xml:space="preserve">'''Ukusebenzisa kweendakamizwa lilutjha''' sekudlange khulu esikhathini sanje. Ilutjha selisebenzisa iindakamizwa njengento yokuzithabisa nokukhipha isizungu. Abanye bakusebenzisa ukuze bakghone ukwamukeliwa ebanganini babo, nofana emphakathini othileko. Lokho kuphetha ngokuthi bagcine bangena phakathi kobungozi obukhulu obufaka hlangana amaphilowabo. Kunzima ukwenza ilutjha leli lazi nofana lamukele bona izenzo zabo zingaphetha ngobungozi bokuthi bangalimala. Abanye bayazi bona ukusebenzisa iindakamizwa kuyingozi kangangani nokuthi bazwile babona kodwana baragela phambili ngezenzo zabo.
[[Isimumathi:Ubungozi bokusetjenziswa kweendakamizwa lilutjha.jpg|thumb]]

== Isidakamizwa esisetjenziswa khulu amalanga la ==
Ilutjha lanamhlanje lisebenzisa isidakamizwa esaziwa ngelimi lesiyeni bona yi-''disposable vape''.&lt;ref&gt;https://www.sciencedirect.com/science/article/pii/S0033350623005036&lt;/ref&gt; Igwayi leli alifani nalela elibotjhwa ngephepha nofana leli ebelibhenywa bobamkhulu. Leli limhlobo ongakajayeleki wegwayi ngombana aliphuthelwa namkha libotjhwe ngombana lingesigujana esincani esinemibala eyahlukahlukeneko. Inemihlobo eyahlukahlukeneko yeminambitho lokha nawuyidosako.nabatjhoko bathi imnandi khulu. Ukutjengisa bona ngeyesikhathi sanje kukobana isebenza ngegezi. Iminambitho le ilethwa mamanzi lawa atholakala ngaphakathi kwesidakamizwa lesi. ibuye ibe nekhemikhali ngelimi lesiyeni ibizwa bona yi-''nicotine.'' ikhemikhali le ngiyo ebenza bona bangasakghona ukuphila ngaphandle kwayo.&lt;ref&gt;https://perspectivesinmedicine.cshlp.org/content/11/5/a039610.short&lt;/ref&gt; Bayifune kanengi. Amanzi lawo makaphelako kufanele uyilahle.

Igwayi leli liyingozi khulu ukudlula leli esilijayeleko begodu ulirhalela msinya. Ngokuya ngerhubhulo elenziweko lobungozi obufaka hlangana nokusetjenziswa kwesidakamizwa lesi kukuthi baphetha ngokuthi amaphapho wabo abeneentunja ekwenza bona bagcine sele baphefumula ngemitjhini, babuye babe nekankere yamaphaphu neyomlomo. Abanye nabasele sebaphefumula ngemitjhini leyo abasaphili isikhathi eside. omunye umonakalo olethwa sidakamizwa lesi kusilaphazeka kwephasi, ngombana lokha umuntu nasele sebangenelele khulu bayibhema woke amalanga bazithenga zibe zinengi ngombana nayiphelako iyalahlwa. Manje-ke agcine sekamanengi khulu lapha ephasini.

Singatjho bona ilutjha leli lithanda isidakamizwa lesi ngombana siza nemibala emihle khulu nokuthi lokha nawunaso ubonala njengomuntu okhamba nesikhathi nofana umuntu osezingeni eliphezulu. okhunye okubiza ilutjha minambitho le ehlukahlukeneko. ingaba ngeyenthelo ezifana namahabhula namabhanana. Ibuye inuke njengeentjalo ezifana namathuthumbo ahlukahlukeneko kanye nokudla okunye okuneshukela.

== Imihlobo eminye yeendakamizwa nesisombululo ==
Eminye imihlobo yeendakamizwa kungaba butjwala, igwayi, nesinye esibizwa ngelimi lesiyeni bona yi-''hubbly.'' Enye esetjenziswa khulu lapha kwezibaliweko yi-hubbly nayo iyafana nalesi esitjengiswe ngehla esithombeni kodwana sihlukaniswa kukuthi asilahlwa ungasisebenzisa kanengi. Nazo iindakamizwa lezi ziyathandwa lilutjha begodu nazo ziyabubangela ubungozi.&lt;ref&gt;[https://www.ncbi.nlm.nih.gov/books/NBK319/#:~:text=Definition,physical%20dependence%20and%20psychologic%20dependence. https://www.ncbi.nlm.nih.gov/books/NBK319/#:~:text=Definition,physical%20dependence%20and%20psychologic%20dependence.]&lt;/ref&gt; ubungozi obunye obungakajayeleki khulu kukuthi abantu laba abasebangenelele khulu bagcina bangaphasi kwegandelelo lokusebenzisa imali, ekwenza bona baphethe sele baba nesikolodo esingafaka ubuphilo babo engozini. Abanye baphetha sebalahlekelwa yimali enengi. Isisombululo kungaba kukuthi bathome ngokubawa isizo ebantwini abanelwazi. Laba aba bona abasale balisa kusese nesikhathi. Kunamahlangano amanengi lapha umuntu angathola khona isizo. Iimbonelo:&lt;ref&gt;https://changesrehab.co.za/south-african-helplines/&lt;/ref&gt;
{| class=&quot;wikitable&quot;
|Substance Abuse 24hour Helpline
|0800 12 13 14
|-
|Cipla 24-hour Mental Health Helpline
|0800 456 789 (24-hour helpline)
|-
|Alcoholics Anonymous South Africa
|0861 435 722
|-
|Narcotics Anonymous South Africa
|083 900 6962
|}

== Isilululwazi ==
[[Mkhakha:Ukubhema]]
[[Mkhakha:Iindakamizwa]]</text>
      <sha1>laquufbds5mqb1z1g19m8feizpmzoib</sha1>
    </revision>
    <revision>
      <id>5877</id>
      <parentid>5871</parentid>
      <timestamp>2025-09-30T13:18:09Z</timestamp>
      <contributor>
        <username>Stillbelieveingooddays</username>
        <id>1018</id>
      </contributor>
      <minor />
      <origin>5877</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4188" sha1="b1n5gxqmckxudisxq32rfp4ftnm89cs" xml:space="preserve">'''Ukusebenzisa kweendakamizwa lilutjha''' sekudlange khulu esikhathini sanje. Ilutjha selisebenzisa iindakamizwa njengento yokuzithabisa nokukhipha isizungu. Abanye bakusebenzisa ukuze bakghone ukwamukeliwa ebanganini babo, nofana emphakathini othileko. Lokho kuphetha ngokuthi bagcine bangena phakathi kobungozi obukhulu obufaka hlangana amaphilowabo. Kunzima ukwenza ilutjha leli lazi nofana lamukele bona izenzo zabo zingaphetha ngobungozi bokuthi bangalimala. Abanye bayazi bona ukusebenzisa iindakamizwa kuyingozi kangangani nokuthi bazwile babona kodwana baragela phambili ngezenzo zabo.
[[Isimumathi:Ubungozi bokusetjenziswa kweendakamizwa lilutjha.jpg|thumb]]

== Isidakamizwa esisetjenziswa khulu amalanga la ==
Ilutjha lanamhlanje lisebenzisa isidakamizwa esaziwa ngelimi lesiyeni bona yi-''[[Disposable|disposable vape]]''.&lt;ref&gt;https://www.sciencedirect.com/science/article/pii/S0033350623005036&lt;/ref&gt; Igwayi leli alifani nalela elibotjhwa ngephepha nofana leli ebelibhenywa bobamkhulu. Leli limhlobo ongakajayeleki wegwayi ngombana aliphuthelwa namkha libotjhwe ngombana lingesigujana esincani esinemibala eyahlukahlukeneko. Inemihlobo eyahlukahlukeneko yeminambitho lokha nawuyidosako.nabatjhoko bathi imnandi khulu. Ukutjengisa bona ngeyesikhathi sanje kukobana isebenza ngegezi. Iminambitho le ilethwa mamanzi lawa atholakala ngaphakathi kwesidakamizwa lesi. ibuye ibe nekhemikhali ngelimi lesiyeni ibizwa bona yi-''nicotine.'' ikhemikhali le ngiyo ebenza bona bangasakghona ukuphila ngaphandle kwayo.&lt;ref&gt;https://perspectivesinmedicine.cshlp.org/content/11/5/a039610.short&lt;/ref&gt; Bayifune kanengi. Amanzi lawo makaphelako kufanele uyilahle.

Igwayi leli liyingozi khulu ukudlula leli esilijayeleko begodu ulirhalela msinya. Ngokuya ngerhubhulo elenziweko lobungozi obufaka hlangana nokusetjenziswa kwesidakamizwa lesi kukuthi baphetha ngokuthi amaphapho wabo abeneentunja ekwenza bona bagcine sele baphefumula ngemitjhini, babuye babe nekankere yamaphaphu neyomlomo. Abanye nabasele sebaphefumula ngemitjhini leyo abasaphili isikhathi eside. omunye umonakalo olethwa sidakamizwa lesi kusilaphazeka kwephasi, ngombana lokha umuntu nasele sebangenelele khulu bayibhema woke amalanga bazithenga zibe zinengi ngombana nayiphelako iyalahlwa. Manje-ke agcine sekamanengi khulu lapha ephasini.

Singatjho bona ilutjha leli lithanda isidakamizwa lesi ngombana siza nemibala emihle khulu nokuthi lokha nawunaso ubonala njengomuntu okhamba nesikhathi nofana umuntu osezingeni eliphezulu. okhunye okubiza ilutjha minambitho le ehlukahlukeneko. ingaba ngeyenthelo ezifana namahabhula namabhanana. Ibuye inuke njengeentjalo ezifana namathuthumbo ahlukahlukeneko kanye nokudla okunye okuneshukela.

== Imihlobo eminye yeendakamizwa nesisombululo ==
Eminye imihlobo yeendakamizwa kungaba butjwala, igwayi, nesinye esibizwa ngelimi lesiyeni bona yi-''hubbly.'' Enye esetjenziswa khulu lapha kwezibaliweko yi-hubbly nayo iyafana nalesi esitjengiswe ngehla esithombeni kodwana sihlukaniswa kukuthi asilahlwa ungasisebenzisa kanengi. Nazo iindakamizwa lezi ziyathandwa lilutjha begodu nazo ziyabubangela ubungozi.&lt;ref&gt;[https://www.ncbi.nlm.nih.gov/books/NBK319/#:~:text=Definition,physical%20dependence%20and%20psychologic%20dependence. https://www.ncbi.nlm.nih.gov/books/NBK319/#:~:text=Definition,physical%20dependence%20and%20psychologic%20dependence.]&lt;/ref&gt; ubungozi obunye obungakajayeleki khulu kukuthi abantu laba abasebangenelele khulu bagcina bangaphasi kwegandelelo lokusebenzisa imali, ekwenza bona baphethe sele baba nesikolodo esingafaka ubuphilo babo engozini. Abanye baphetha sebalahlekelwa yimali enengi. Isisombululo kungaba kukuthi bathome ngokubawa isizo ebantwini abanelwazi. Laba aba bona abasale balisa kusese nesikhathi. Kunamahlangano amanengi lapha umuntu angathola khona isizo. Iimbonelo:&lt;ref&gt;https://changesrehab.co.za/south-african-helplines/&lt;/ref&gt;
{| class=&quot;wikitable&quot;
|Substance Abuse 24hour Helpline
|0800 12 13 14
|-
|Cipla 24-hour Mental Health Helpline
|0800 456 789 (24-hour helpline)
|-
|Alcoholics Anonymous South Africa
|0861 435 722
|-
|Narcotics Anonymous South Africa
|083 900 6962
|}

== Isilululwazi ==
[[Mkhakha:Ukubhema]]
[[Mkhakha:Iindakamizwa]]</text>
      <sha1>b1n5gxqmckxudisxq32rfp4ftnm89cs</sha1>
    </revision>
    <revision>
      <id>5879</id>
      <parentid>5877</parentid>
      <timestamp>2025-09-30T13:26:39Z</timestamp>
      <contributor>
        <username>Stillbelieveingooddays</username>
        <id>1018</id>
      </contributor>
      <origin>5879</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4037" sha1="byfdgs5gcj6nrc5czhffm3pf5ycpqvq" xml:space="preserve">'''Ukusebenzisa kweendakamizwa lilutjha''' sekudlange khulu esikhathini sanje. Ilutjha selisebenzisa iindakamizwa njengento yokuzithabisa nokukhipha isizungu. Abanye bakusebenzisa ukuze bakghone ukwamukeliwa ebanganini babo, nofana emphakathini othileko. Lokho kuphetha ngokuthi bagcine bangena phakathi kobungozi obukhulu obufaka hlangana amaphilowabo. Kunzima ukwenza ilutjha leli lazi nofana lamukele bona izenzo zabo zingaphetha ngobungozi bokuthi bangalimala. Abanye bayazi bona ukusebenzisa iindakamizwa kuyingozi kangangani nokuthi bazwile babona kodwana baragela phambili ngezenzo zabo.
[[Isimumathi:Ubungozi bokusetjenziswa kweendakamizwa lilutjha.jpg|thumb]]

== Isidakamizwa esisetjenziswa khulu amalanga la ==
Ilutjha lanamhlanje lisebenzisa isidakamizwa esaziwa ngelimi lesiyeni bona yi-''[[Disposable|disposable vape]]''.&lt;ref&gt;https://www.sciencedirect.com/science/article/pii/S0033350623005036&lt;/ref&gt; Igwayi leli alifani nalela elibotjhwa ngephepha nofana leli ebelibhenywa bobamkhulu. Leli limhlobo ongakajayeleki wegwayi ngombana aliphuthelwa namkha libotjhwe ngombana lingesigujana esincani esinemibala eyahlukahlukeneko. Inemihlobo eyahlukahlukeneko yeminambitho lokha nawuyidosako.nabatjhoko bathi imnandi khulu. Ukutjengisa bona ngeyesikhathi sanje kukobana isebenza ngegezi. Iminambitho le ilethwa mamanzi lawa atholakala ngaphakathi kwesidakamizwa lesi. ibuye ibe nekhemikhali ngelimi lesiyeni ibizwa bona yi-''nicotine.'' ikhemikhali le ngiyo ebenza bona bangasakghona ukuphila ngaphandle kwayo.&lt;ref&gt;https://perspectivesinmedicine.cshlp.org/content/11/5/a039610.short&lt;/ref&gt; Bayifune kanengi. Amanzi lawo makaphelako kufanele uyilahle.

Igwayi leli liyingozi khulu ukudlula leli esilijayeleko begodu ulirhalela msinya. Ngokuya ngerhubhulo elenziweko lobungozi obufaka hlangana nokusetjenziswa kwesidakamizwa lesi kukuthi baphetha ngokuthi amaphapho wabo abeneentunja ekwenza bona bagcine sele baphefumula ngemitjhini, babuye babe nekankere yamaphaphu neyomlomo. Abanye nabasele sebaphefumula ngemitjhini leyo abasaphili isikhathi eside. omunye umonakalo olethwa sidakamizwa lesi kusilaphazeka kwephasi, ngombana lokha umuntu nasele sebangenelele khulu bayibhema woke amalanga bazithenga zibe zinengi ngombana nayiphelako iyalahlwa. Manje-ke agcine sekamanengi khulu lapha ephasini.

Singatjho bona ilutjha leli lithanda isidakamizwa lesi ngombana siza nemibala emihle khulu nokuthi lokha nawunaso ubonala njengomuntu okhamba nesikhathi nofana umuntu osezingeni eliphezulu. okhunye okubiza ilutjha minambitho le ehlukahlukeneko. ingaba ngeyenthelo ezifana namahabhula namabhanana. Ibuye inuke njengeentjalo ezifana namathuthumbo ahlukahlukeneko kanye nokudla okunye okuneshukela.

== Imihlobo eminye yeendakamizwa nesisombululo ==
Eminye imihlobo yeendakamizwa kungaba butjwala, igwayi, nesinye esibizwa ngelimi lesiyeni bona yi-''hubbly.'' Enye esetjenziswa khulu lapha kwezibaliweko yi-hubbly nayo iyafana nalesi esitjengiswe ngehla esithombeni kodwana sihlukaniswa kukuthi asilahlwa ungasisebenzisa kanengi. Nazo iindakamizwa lezi ziyathandwa lilutjha begodu nazo ziyabubangela ubungozi.&lt;ref&gt;[https://www.ncbi.nlm.nih.gov/books/NBK319/#:~:text=Definition,physical%20dependence%20and%20psychologic%20dependence. https://www.ncbi.nlm.nih.gov/books/NBK319/#:~:text=Definition,physical%20dependence%20and%20psychologic%20dependence.]&lt;/ref&gt; ubungozi obunye obungakajayeleki khulu kukuthi abantu laba abasebangenelele khulu bagcina bangaphasi kwegandelelo lokusebenzisa imali, ekwenza bona baphethe sele baba nesikolodo esingafaka ubuphilo babo engozini. Abanye baphetha sebalahlekelwa yimali enengi. Isisombululo kungaba kukuthi bathome ngokubawa isizo ebantwini abanelwazi. Laba aba bona abasale balisa kusese nesikhathi. Kunamahlangano amanengi lapha umuntu angathola khona isizo. Iimbonelo:&lt;ref&gt;https://changesrehab.co.za/south-african-helplines/&lt;/ref&gt;

# Substance Abuse 24hour Helpline: 0800 12 13 14
# Alcoholics Anonymous South Africa: 0861435722

== Isilululwazi ==
[[Mkhakha:Ukubhema]]
[[Mkhakha:Iindakamizwa]]</text>
      <sha1>byfdgs5gcj6nrc5czhffm3pf5ycpqvq</sha1>
    </revision>
  </page>
  <page>
    <title>Ukuhlukumezeka Kwabomma Abasemendweni</title>
    <ns>0</ns>
    <id>967</id>
    <revision>
      <id>5872</id>
      <timestamp>2025-09-30T13:11:41Z</timestamp>
      <contributor>
        <username>Wikabena</username>
        <id>1037</id>
      </contributor>
      <comment>I have created a new article</comment>
      <origin>5872</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="16004" sha1="rq31qacyxc1bsq2351vzb115sedn05d" xml:space="preserve">'''Esikhathini''' esinengi abomma abasemendweni bazifumana bahlukumezeka ngokwesiko ngitjho nangokwekolo kusetjenziswe neLizwi lakaZimu ukusekela isiga sokuhlukumeza leso. Umtlolo ovame khulu ukusetjenziswa butjhilweni ngosencwadini '''kaGenesisi 2:18''' othi: “USomnini uZimu wathi: ‘Akusikuhle bona umuntu ahlale yedwa. Yeke ngizomenzela '''umsizi omfaneleko'''.’”&lt;ref&gt;https://cumbooks.co.za/collections/bibles-other-languages/products/ibhayibheli-elicwengileko-isindebele-2012-black-hardcover?srsltid=AfmBOooOf7laiE6UsoShv0RmUSAMmvZJPqjxs5xKf98vaA9ogWdSC9sJ&lt;/ref&gt;; nencwadini '''yebe-Efesu 5:22''' othi, “'''Bafazi, thobelani''' '''amadoda''' wenu sengathi nithobela iKosi ngombana '''indoda iyihloko''' '''yomfazi,''' njengombana uKrestu ayihloko yebandla elimzimba wakhe begodu yena aMsindisi walo.”&lt;ref&gt;https://cumbooks.co.za/collections/bibles-other-languages/products/ibhayibheli-elicwengileko-isindebele-2012-black-hardcover?srsltid=AfmBOooOf7laiE6UsoShv0RmUSAMmvZJPqjxs5xKf98vaA9ogWdSC9sJ&lt;/ref&gt; Umnqopho wephepha leli kuveza ihlathululo yeendimana ezitjhwiwe ngaphezulu ngokomtlolo wesiHebheru nesiGirigi ngehloso yokuletha umkhanyo mayelana nalokho ebekutjhiwo ziindimana lezi ekhabo lakhona. UmTlolo wesiHebheru uzakusetjenziswa ngombana umsuka welimi elisetjenziswe eTestamendeni eliDala siHebheru. UmTlolo wesiGirigi nawo uzakusetjenziswa ngombana umsuka welimi elisetjenziswe eTestamendeni eliTjha siGirigi. Ekugcineni nasele kuhlathululwe iindimana lezi kuzakukhanya bonyana ukusetjenziswa komTlolo ukusekela ukuhlukumezeka kwabomma abasemendweni ngambala kudzimelele eLizwini lakaZimu namkha njani.

== Kuyini Ukuhlukumezeka Namkha Ukuhlukunyezwa Kwabomma Abasemendweni? ==
Ukuya ngokukaKristin ('''2005)''' ukuhlukumezeka kwabomma kungathiwa mguruguru wangekhaya, mguruguru womndeni, kubethwa kwabomma namkha ukuhlukunyezwa kwabalingani.&lt;ref name=&quot;:0&quot;&gt;Catherine Clark Kroeger and James R. Beck, 1996. Women, Abuse, and the Bible. How scripture can be used to hurt or to heal. Baker Books, Michigan&lt;/ref&gt;

Ukuhlukumeza kutjho ukusebenzisa amandla butjhulweni phezu kwaloyo okuthatheka bonyana mncani namkha uyanyazeka.

UKristin (2005) ubuye ahlathulule iingaba zokuhlukumeza namkha zokuhlukumezeka bunje:&lt;ref name=&quot;:0&quot; /&gt;

1.    Ukuhlukunyezwa ngokomzimba: kubandakanya ukubetha (ukuwakala, ukumanya, ukupatlula, ukusawula), ukudula, ukurarha (ukubhakela), ukusunduza (ukukghurumeja, ukukhahlameza) nokusetjenziswa kwesibulawo (isikhali) ngitjho nanyana ungaphuma imivuvu namkha ungabi nayo imivuvu. Koke lokhu kuzizenzo zobelelesi ngokomThethosisekelo.

2.    Ukuhlukunyezwa ngokwamezwi: ukuthethisa, ukukgharameja, ukuthusela, nokudubhulela umlomo.

3.    Ukuhlukunyezwa ngokwamazizo /ngokomkhumbulo: ukwehlisa umuntu isithunzi, ukumbangela bona azinyaze, ukumnyazisa nokumhlambalazisa ngabentwana.

4.    Ukuhlukunyezwa ngokwehlalo:  Lokhu kutjho ukuqotjha umuntu emndenini, ukumlahlisa abangani, ukumlandelela nokumkhola ngomrhala.

5.    Ukuhlukunyezwa ngokwemali: Ukutswinya umlingani ngokweemali ukwenzela bonyana angakghoni ukuzenzela izinto ezithileko, ukusozisa ngokuchitha imali ebeyifanele ibhadekele umkhaya. 

== Imibono Yabatloli Abahlukahlukeneko ==
Lokha nakunezenzo zokuhlukunyezwa kwabomma abasemendweni ngekhaya kuvamisile bonyana kuqalelelwe isiko namkha isondo kobana likhalime. Lokhu kutjho bona indaba leyo ingasiwa ngekosini namkha ingasiwa esondweni kumfundisi, kufunwe intatha. Umbuzo okhona kukuthi isiko nesondo namkha ikolo liyirarulula njani indaba leyo. Siyazi-ke bonyana emalangeni esiphila kiwo sele kukhona nomThethosisekelo ovikela ukuhlukunyezwa, okutjho bona ohlukunyezwako unelungelo lokumangala ekhotho yomthetho. Nokho-ke kileliphepha sizokuqalelela ngehlangothini lekolo bonyana ngambala imitlolo iyavumelana nokuhlukunyezwa kwabomma abasemendweni na?

Kujayelekile bonyana umma nakahlukunyezwako ngekhaya kuthathwe bonyana akakazithobi ngokwaneleko kubaba wakwakhe njengombana kusitjho iBhayibheli encwadini yebe-Efesu 5:22.&lt;ref&gt;IBHAYIBHELI ELICWENGILEKO: isiNdebele Bible – 2012 ...&lt;/ref&gt; Nanyana sele kuthathwa bona kukutlhorswa kwabantwana ngokomthetho wedemokhrasi nje, kodwana ngokujayelekileko, umntwana nakangalaleli ababelethi, unungwanungwa ngeswazana ukuze afakwe endleleni njengombana kusitjho umTlolo encwadini yezAga 23:13-14 “Ungalisi ukukhalima umntwanakho; akazukufa nawumnunga ngeswazi. Wena nawumbetha ngeswazi, uzabe usindisa umphefumulwakhe ekufeni.” Nokho-ke awukho umtlolo othi umma naye kufanele anungwanungwe ngubaba nakube kukhona ukungazwisisani, ije ubaba ayihloko yekhaya.

Ukuya ngokombiko we-Anglican Book Center, (1987:33) umma uyalulekwa kuthiwe kufanele azithobe kubaba ngeenkhathi zoke nebujamweni boke. Kubuye kuthiwe ukuhlukunyezwa kwakhe kusiphambano sakhe okufuze asithwale bekube sekufeni njengombana kwenza uJesu Krestu.&lt;ref&gt;BOOK OF ALTERNATIVE SERVICES OF THE ANGLICAN ...&lt;/ref&gt;

Kanti uBill Gothard we-Institute in Basic Youth Conflicts yena uthi batjho lokha umma nakazithoba endodenakhe emhlukumezako, ufunda ukubekezelela ukutlhagiswa ngebanga lokulunga (Matewu 5:10). Ngamanye amezwi odulwako kufanele aphethe imitlolo ukuze abonise ukulunga nekghono lokunyamezela bese kudzujulwa KwebeGalatiya 5:22, khisibe odulako yena kuvalwe phetjheya ngaye; namkha kuthiwe, “bazambona abanamehlo!”

U-Andy (2015:33) ukhamba adzubhula imibono yabatloli abahlukahlukeneko bunjesi:&lt;ref&gt;Andy Johnson. 2015. Religion and Men’s Violence Against Women. Springer&lt;/ref&gt;

a)    uRuthven (1990) uthi batjho uTertullian owayengomunye wabadosi phambili bezekolo obekuthiwa ma-“Apostolic fathers” umfazi ulisango lakasathana.&lt;ref&gt;Feminist literary studies

Book by K. Ruthven&lt;/ref&gt; Godu batjho uthi umfazi ulithempeli elakhiwe phezu kothuvi:

Banengi-ke abakhambisana nombono lo ngitjho nemphakathini wabakholwako. Kunekulumo ethi umfazi yinyoka, kutjhiwo kunqotjhiswe ku-Eva ngombana batjho wakhohlisa u-Adamu. Abafazi nabo bayazibuyiselela bathi indoda yinja ngombana yase ‘yatla’ isithelo ingazange ibuze. Kazi kutjhiwo u-Adamu-ke njalo.   

b)    uRogers (1996) uthi batjho umpostoli uPowula weTarsus ubegade agandelela khulu bonyana abafazi bazithobe emadodeni wabo.&lt;ref&gt;The troublesome helpmate

Book by Katharine M. Rogers&lt;/ref&gt;

Indaba yokuzithoba kuyabonakala bonyana isuselwa eBhayibhelini ngombana ngitjho nemasikweni wabo boke abantu ephasinapha injalo. Umma ulindeleke bonyana azithobe endodenakhe ngombana indoda iyihloko yomkhaya. Kukhona abayithatha ngommoya omuhle indaba le begodu bayamukele ngokuthula. Kanti nalabo abathotjelwako benza bonyana kube lula ukuthotjelwa. Kukhona-ke ebagugunako indaba le, balikhombe libaba bathi, “Nange ngingakuthobela ungazikhotha!” Khonapho kube ngongaphasi nongaphezulu njengombana sele siphila esikhathini sedemokhrasi nje.

Nokho uJohnson (2015:33) uthi batjho uHove (1999) uhlathulula indaba yakaPowula kuhle kwebeGalatiya 3:28 nakasithi, “AkunamJuda, akunamGrigi, ikhoboka namkha otjhaphulukileko, omduna namkha omsikazi ngombana nimunye noke kuKrestu Jesu.&lt;ref&gt;Hove. R. 1991. ''Equality in Christ: Galatians'' 3:28 ''and the gender dispute'' (p. 17) Wheaton: Crossway. International Center for Research on Women. (2013). US. International Violence Against Women Act. &lt;nowiki&gt;http://www.icrw.org/what-we-do/violence-against-women&lt;/nowiki&gt;. Accessed 11 Feb 2013.&lt;/ref&gt;”Umbono kaJohnson uthi batjho indaba yokuzithoba nokuthotjelwa ibekwe ngendlela elingisa uKrestu nebandla. Ngamye amezwi isiga lesi sokuthoba nokuthotjelwa sifaniswa nangendlela ibandla lithobela ngakho uKrestu, godu noKrestu ngendlela athanda ngakho ibandla (Kwebe-Efesu 5:21-33).

UJohnson (2015:33) ubuye athi batjho uRinck (199) encwadinakhe ethi; “Amadoda Akholwako Ahloye Abomma”&lt;ref&gt;Christian Men who Hate Women: Healing Hurting Relationships

Book by Margaret J. Rinck&lt;/ref&gt;, uthi kunamadoda athileko emphakathini wabakholwako ahlathulula kumbi abe asebenzise butjhulweni ifundiso yeBhayibheli yokuzithoba. Uthi ifundiso okungiyo yokuzithoba ayisihlangothi linye kodwana kuyathotjelwana. Godu ifundiso le igandelela ukuthandana nokuhloniphana, ingasi ukuthotjiswa ngeenkhwepha. Kanti u West (2003) yena umbono wakhe uthi batjho abobaba abahlukumezako bahlukumeza ihlelo elicwengileko lakaZimu begodu isenzo sabo leso sivinyilika esonweni.&lt;ref&gt;'''Theology of the Body Explained: A Commentary on John Paul II's''' &quot;'''Gospel of the Body'''&quot; ... Christopher West makes John Paul II's theology of the body ...&lt;/ref&gt;

c)    UCathrine banoJames (1996:16-27) bona baveza iinkolelo ezine ezisisekelo amakholwa kanengi aziseka ngazo:

1.    UZimu wakubeka bonyana indoda ikhonye bese umfazi uyazithoba

2.    Umfazi mncani kunendoda nje-ke akakwazi ukwenza iinqunto ekhaya

3.    Ukutlhaga kusisekelo samakholwa khulukhulu sabomma

4.    Amakholwa kufanele acolele msinyana, abuyisane nalabo abawahlukumezako.

Kujayelekile bonyana umma nakahlukunyezwako ngekhaya ulindeleke bonyana acolele ubaba nakube ubaba loyo ubonwa umlandu ngezenzo zakhe. Njengombana kubomma khulukhulu abaya esondweni, ikulumo le isuke ibe namandla ngombana kuthiwa, “Angithi uthi ulikholwa! Alo kuba yini ungacoleli? IBhayibheli lithi usilibalele amacala wethu njengombana nathi sibalibalela abanamacala kithi”(Matewu 6:12) khisibe nokho ukuhlukunyezwa khona kuragela phambili. Nakube umma loyo ulila ngokuthi sele kukanengi amlibalela bese kuthiwe kuye, “Angithi neBhayibheli liyatjho bonyana ulibalele umuntu kube ngokubuyelelwe amatjhumi alikhomba nakhomba?” [Matewu 18:21-22]. Khonapho indaba yokuphenduka kwaloyo ohlukumezako yona ayiphathwa.

== Okutjhiwo LiBhayibheli NgoGenesisi 2:18 Nebe-Efesu 5:22 ==
UGenesisi 2:18 uthi, “USomnini uZimu wathi: ‘Akusikuhle bona umuntu ahlale yedwa. Yeke ngizomenzela '''umsizi omfaneleko'''.’”

'''וַיֹּ֙אמֶר֙ יְהוָ֣ה אֱלֹהִ֔ים לֹא־טֹ֛וב הֱיֹ֥ות הָֽאָדָ֖ם לְבַדֹּ֑ו אֶֽעֱשֶׂהּ־לֹּ֥ו עֵ֖זֶר כְּנֶגְדֹּֽו'''׃ [Wayyomer Yahweh Elohim lo towb heyowt ha-Adam lebaddow eseh low ezer kenegdo]&lt;ref&gt;https://en.wikipedia.org/wiki/Hebrew_Bible&lt;/ref&gt;

Leli litjhugululo lesiNdebele lango-2012. Woke amalimi esiwafundako eBhayibhelini alitjhugululo lesiHebheru namkha lesiGirigi. ETestamendeni eliDala ilimi elimsuka siHebheru. Yeke kufanele sibuyele kiso isiHebheru siqale bonyana ikulumo le ithini. Amagama athi, ‘umsizi omfaneleko’ asuselwe kusiHebheru ekulumeni ethi [עזר כנגדו׃] ‘ezer kenegdo’. Ngaphambi kobana siqale ihlathululo yamagama la, kuqakathekile ukuveza bonyana ngokuqalisisa amagama la, akwenziwa imizamo yokuhlaba namkha yokujamelela ihlangothi elithileko. Umnqopho kuveza bona ekhabo lakhona sithini isiHebheru endimeni le.

Igama lokuthoma lithi “ezer” namkha umsizi. NgokwesiHebheru litjho umuntu osiza omunye lokha yena anganamandla wokuzisiza. Umuntu osizako angaba ngonamandla begodu omkhulu kiloyo osizwako namkha kungaba ngomlingani waloyo osizwako ngokwamazinga athileko wepilo. Kufanele sikutjheje-ke lokhu: Akwenzeki bonyana umsizi abe mncani kunosizwako.

Nanyana kungaba ngayiphi indlela kodwana ihlathululo yona itjho bona umsizi wenza umthwalo waloyo osizwako ube lula. Esikhathini esinengi-ke igameli lisetjenziswa ukutjho uSomnini bonyana umsindisi, umsizi, umvikeli, umumenyeli namkha umbhadekeli. Ku-1 Samyeli 7: 12 kuthiwa, “USamyela wathatha ilitje walijamisa phakathi kweMitsipha neTjheni. Walithiya ibizo wathi yi-Ebheni-Ezeri asithi: “Bekube lapha uSomnini usisizile.”  

Igama lesibili lithi khenegdo. NgesiHebheru lingasebenza njengephriphozitjhini litjho ukuthi ngaphambili. Godu lingatjho ukuthi ongafani naye ngobulili namkha ofaneleko. Yeke nasiqala indinyana le ngamanye amezwi ithi:

·       “Ngizomenzela omsizi/umenyeli ozokujama phambi kwakhe.” Siyazi bona umuntu nakwenyelako ujama phambi kwakho ukwenzela bona nanyana yini efuna ukukulimaza ithome ngaye.

·       “Ngizomenzela umsizi ongafani naye ngobulili”

·       “Ngizomenzela umsizi ofaneleko” ngamanye amezwi uzokulingana/uzokukhambisana nesizo afanele amnikele lona.

Incwadi yebe-Efesu 5:22-33 yona ithi, “Bafazi, thobelani amadoda wenu sengathi nithobela iKosi ngombana indoda iyihloko yomfazi, njengombana uKrestu ayihloko yebandla elimzimba wakhe begodu yena aMsindisi walo. Njengombana ibandla limthobela uKrestu, ngokunjalo nabafazi kumele bathobele amadoda wabo kikho koke. Madoda thandani abafazi benu njengombana uKrestu athanda ibandla, wadela ukuphila kwakhe ngebanga lalo. Walicwengisa, walihlanza ngamanzi nangelizwi lakhe begodu waliletha kuye lilibandla elinephazimulo, elinganachaphazi, ukutjhwabana namkha umphambo wananyana yini kodwana licwengile begodu limsulwa. Ngokunjalo namadoda kufanele athande abafazi bawo njengombana athanda imizimba yawo. Othanda umkakhe uzithanda yena ngokwakhe. Akakho owakhe wazonda umzimbakhe kodwana ngiloyo naloyo uyawondla awutlhogomele, njengombana noKrestu asenza ebandleni ngombana sizizitho zomzimbakhe. “Ngalokho-ke indoda izokutjhiya uyise nonina inamathele kumkayo, nje-ke ababili labo babe nyamanye.” Yifihlakalo ekulu le, kodwana ngikhuluma ngoKrestu nebandla. Nokho-ke omunye nomunye wenu kumele athande umkakhe njengombana azithanda yena, nomfazi kumele ahloniphe indodakhe.

Nasiqala eBhayibhelini siyafunyana bonyana uZimu, omnikazi womtjhado, uyithathela phezulu namkha ngokuncama okukhulu indaba yobudlelwana phakathi kwendoda nomfazi kangangobana uyilinganisa nobudlelwana obuphakathi kwakaKrestu nebandla. Lokhu sikubona encwadini yebe-Efesu 5:22. Yeke kuyasibonisa bonyana akukameli ithathwe ngesincele indaba le.  Kuyafuneka-ke bonyana nakudzujulwa indinyana le ingatjhiywa phakathi kodwana kuqalwe indaba yoke lapha ithoma khona bekufike lapha igcina khona. Nasiyifunda kuhle ithi umfazi akathobele indoda yakhe. Lokho akwenze njengalokha ibandla nalithobela uKrestu. Libuye lithi indoda ayithande umkayo. Ithando lelo alibe njengelakaKrestu athanda ngalo ibandla. Umma akaqale bonyana ibandla limthobela njani uKrestu bese naye wenza njalo endodeni yakhe. Indoda ayiqale bona uKrestu ulithanda njani ibandla, naye enze njalo kumkakhe.

Ukrestu akalitlhorisi ibandla, kodwana uyalithanda abe alivikele. Qala incwadi yezEnzo 9:1-4 lapha uKrestu adula khona phasi uSawula ngombani ngombana ahlukumeza ibandla.

Ngemva kobana sele sifumene ihlathululo kaGenesisi 2:18 neyebe-Efesu 5:22 kuyakhanya bonyana kukhona iimponjwana ekudzujulweni kwemitlolo le ukusekela ukuhlukunyezwa kwabomma emendweni. KuGenesisi akukho lapha sifumene khona bonyana umma mncani ebudlelwaneni bomtjhado njengombana kuthatheka emphakathini. ILizwi lakaZimu nabelisithi umma umsizi wakababa azange lithi umma mncani. Siyizwile ihlathululo yesiHebheru mayelana negama elithi umsizi. Kanti nawo amagama athi bazokuba nyamanye atjho bona bamumuntu munye. Alo-ke, kuvelaphi ukobana ngemva sele kuthiwe banyamanye bese kuthiwe omunye mncani omunye mkhulu? Godu ikulumo le ayitjho bona umma akanyaze ubaba angamhloniphi njengombana ingatjho bona ubaba adule namkha atlhorise umma. Nakhe nayibonaphi ihloko yomuntu idulana nomzimba, namkha umzimba uphikisana nehloko? Ihloko isemzimbeni munye, nomzimba unehloko yinye.

Encwadini yebe-Efesu siyafunyana bona ubudlelwano bomtjhado bufaniswa nobudlelwano bakaKrestu nebandla. Kungaba buhlungu nange ubuhle bomuntu bungafaniswa nefarigi. Cabanga sele kuthiwa umuntu lo muhle njengefarigi! Ubudlelwana bakaKrestu nebandla bufaniselwani nobudlelwana bendoda nomfazi nakube indoda ihlukumeza umfazi, nomfazi uhlazisa indoda emendweni?

Kwanga uZimu angazibonakalisa emadodeni ahlukumeza abomma ngendlela efana poro naleyo azibonakalisa ngayo kuSawula obegade ahlukumeza ibandla. Azibonakalise ngokunjalo nakibo abomma abangaphathi kuhle amadoda wabo emendweni. Ngalokho isingathekiso somendo nebandla sizakuba namandla begodu sizwisiseke ngitjho nebantwini abasebenzisa iLizwi lakaZimu butjhilweni ukusekela izenzo ezifana nalezi!

== IMITHOMBOLWAZI ==</text>
      <sha1>rq31qacyxc1bsq2351vzb115sedn05d</sha1>
    </revision>
    <revision>
      <id>5874</id>
      <parentid>5872</parentid>
      <timestamp>2025-09-30T13:15:34Z</timestamp>
      <contributor>
        <username>Wikabena</username>
        <id>1037</id>
      </contributor>
      <comment>I have added a picture</comment>
      <origin>5874</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="16134" sha1="rqklqb5yfz43m9anwiaqla4gtqncanx" xml:space="preserve">'''Esikhathini''' esinengi abomma abasemendweni bazifumana bahlukumezeka ngokwesiko ngitjho nangokwekolo kusetjenziswe neLizwi lakaZimu ukusekela isiga sokuhlukumeza leso. Umtlolo ovame khulu ukusetjenziswa butjhilweni ngosencwadini '''kaGenesisi 2:18''' othi: “USomnini uZimu wathi: ‘Akusikuhle bona umuntu ahlale yedwa. Yeke ngizomenzela '''umsizi omfaneleko'''.’”&lt;ref&gt;https://cumbooks.co.za/collections/bibles-other-languages/products/ibhayibheli-elicwengileko-isindebele-2012-black-hardcover?srsltid=AfmBOooOf7laiE6UsoShv0RmUSAMmvZJPqjxs5xKf98vaA9ogWdSC9sJ&lt;/ref&gt;; nencwadini '''yebe-Efesu 5:22''' othi, “'''Bafazi, thobelani''' '''amadoda''' wenu sengathi nithobela iKosi ngombana '''indoda iyihloko''' '''yomfazi,''' njengombana uKrestu ayihloko yebandla elimzimba wakhe begodu yena aMsindisi walo.”&lt;ref&gt;https://cumbooks.co.za/collections/bibles-other-languages/products/ibhayibheli-elicwengileko-isindebele-2012-black-hardcover?srsltid=AfmBOooOf7laiE6UsoShv0RmUSAMmvZJPqjxs5xKf98vaA9ogWdSC9sJ&lt;/ref&gt; Umnqopho wephepha leli kuveza ihlathululo yeendimana ezitjhwiwe ngaphezulu ngokomtlolo wesiHebheru nesiGirigi ngehloso yokuletha umkhanyo mayelana nalokho ebekutjhiwo ziindimana lezi ekhabo lakhona. UmTlolo wesiHebheru uzakusetjenziswa ngombana umsuka welimi elisetjenziswe eTestamendeni eliDala siHebheru. UmTlolo wesiGirigi nawo uzakusetjenziswa ngombana umsuka welimi elisetjenziswe eTestamendeni eliTjha siGirigi. Ekugcineni nasele kuhlathululwe iindimana lezi kuzakukhanya bonyana ukusetjenziswa komTlolo ukusekela ukuhlukumezeka kwabomma abasemendweni ngambala kudzimelele eLizwini lakaZimu namkha njani.

[[Isimumathi:A Russian poster urging open your eyes - against women being abused (Transparent).png|thumb|Ukutlhoriswa kwabomma]]

== Kuyini Ukuhlukumezeka Namkha Ukuhlukunyezwa Kwabomma Abasemendweni? ==
Ukuya ngokukaKristin ('''2005)''' ukuhlukumezeka kwabomma kungathiwa mguruguru wangekhaya, mguruguru womndeni, kubethwa kwabomma namkha ukuhlukunyezwa kwabalingani.&lt;ref name=&quot;:0&quot;&gt;Catherine Clark Kroeger and James R. Beck, 1996. Women, Abuse, and the Bible. How scripture can be used to hurt or to heal. Baker Books, Michigan&lt;/ref&gt;

Ukuhlukumeza kutjho ukusebenzisa amandla butjhulweni phezu kwaloyo okuthatheka bonyana mncani namkha uyanyazeka.

UKristin (2005) ubuye ahlathulule iingaba zokuhlukumeza namkha zokuhlukumezeka bunje:&lt;ref name=&quot;:0&quot; /&gt;

1.    Ukuhlukunyezwa ngokomzimba: kubandakanya ukubetha (ukuwakala, ukumanya, ukupatlula, ukusawula), ukudula, ukurarha (ukubhakela), ukusunduza (ukukghurumeja, ukukhahlameza) nokusetjenziswa kwesibulawo (isikhali) ngitjho nanyana ungaphuma imivuvu namkha ungabi nayo imivuvu. Koke lokhu kuzizenzo zobelelesi ngokomThethosisekelo.

2.    Ukuhlukunyezwa ngokwamezwi: ukuthethisa, ukukgharameja, ukuthusela, nokudubhulela umlomo.

3.    Ukuhlukunyezwa ngokwamazizo /ngokomkhumbulo: ukwehlisa umuntu isithunzi, ukumbangela bona azinyaze, ukumnyazisa nokumhlambalazisa ngabentwana.

4.    Ukuhlukunyezwa ngokwehlalo:  Lokhu kutjho ukuqotjha umuntu emndenini, ukumlahlisa abangani, ukumlandelela nokumkhola ngomrhala.

5.    Ukuhlukunyezwa ngokwemali: Ukutswinya umlingani ngokweemali ukwenzela bonyana angakghoni ukuzenzela izinto ezithileko, ukusozisa ngokuchitha imali ebeyifanele ibhadekele umkhaya. 

== Imibono Yabatloli Abahlukahlukeneko ==
Lokha nakunezenzo zokuhlukunyezwa kwabomma abasemendweni ngekhaya kuvamisile bonyana kuqalelelwe isiko namkha isondo kobana likhalime. Lokhu kutjho bona indaba leyo ingasiwa ngekosini namkha ingasiwa esondweni kumfundisi, kufunwe intatha. Umbuzo okhona kukuthi isiko nesondo namkha ikolo liyirarulula njani indaba leyo. Siyazi-ke bonyana emalangeni esiphila kiwo sele kukhona nomThethosisekelo ovikela ukuhlukunyezwa, okutjho bona ohlukunyezwako unelungelo lokumangala ekhotho yomthetho. Nokho-ke kileliphepha sizokuqalelela ngehlangothini lekolo bonyana ngambala imitlolo iyavumelana nokuhlukunyezwa kwabomma abasemendweni na?

Kujayelekile bonyana umma nakahlukunyezwako ngekhaya kuthathwe bonyana akakazithobi ngokwaneleko kubaba wakwakhe njengombana kusitjho iBhayibheli encwadini yebe-Efesu 5:22.&lt;ref&gt;IBHAYIBHELI ELICWENGILEKO: isiNdebele Bible – 2012 ...&lt;/ref&gt; Nanyana sele kuthathwa bona kukutlhorswa kwabantwana ngokomthetho wedemokhrasi nje, kodwana ngokujayelekileko, umntwana nakangalaleli ababelethi, unungwanungwa ngeswazana ukuze afakwe endleleni njengombana kusitjho umTlolo encwadini yezAga 23:13-14 “Ungalisi ukukhalima umntwanakho; akazukufa nawumnunga ngeswazi. Wena nawumbetha ngeswazi, uzabe usindisa umphefumulwakhe ekufeni.” Nokho-ke awukho umtlolo othi umma naye kufanele anungwanungwe ngubaba nakube kukhona ukungazwisisani, ije ubaba ayihloko yekhaya.

Ukuya ngokombiko we-Anglican Book Center, (1987:33) umma uyalulekwa kuthiwe kufanele azithobe kubaba ngeenkhathi zoke nebujamweni boke. Kubuye kuthiwe ukuhlukunyezwa kwakhe kusiphambano sakhe okufuze asithwale bekube sekufeni njengombana kwenza uJesu Krestu.&lt;ref&gt;BOOK OF ALTERNATIVE SERVICES OF THE ANGLICAN ...&lt;/ref&gt;

Kanti uBill Gothard we-Institute in Basic Youth Conflicts yena uthi batjho lokha umma nakazithoba endodenakhe emhlukumezako, ufunda ukubekezelela ukutlhagiswa ngebanga lokulunga (Matewu 5:10). Ngamanye amezwi odulwako kufanele aphethe imitlolo ukuze abonise ukulunga nekghono lokunyamezela bese kudzujulwa KwebeGalatiya 5:22, khisibe odulako yena kuvalwe phetjheya ngaye; namkha kuthiwe, “bazambona abanamehlo!”

U-Andy (2015:33) ukhamba adzubhula imibono yabatloli abahlukahlukeneko bunjesi:&lt;ref&gt;Andy Johnson. 2015. Religion and Men’s Violence Against Women. Springer&lt;/ref&gt;

a)    uRuthven (1990) uthi batjho uTertullian owayengomunye wabadosi phambili bezekolo obekuthiwa ma-“Apostolic fathers” umfazi ulisango lakasathana.&lt;ref&gt;Feminist literary studies

Book by K. Ruthven&lt;/ref&gt; Godu batjho uthi umfazi ulithempeli elakhiwe phezu kothuvi:

Banengi-ke abakhambisana nombono lo ngitjho nemphakathini wabakholwako. Kunekulumo ethi umfazi yinyoka, kutjhiwo kunqotjhiswe ku-Eva ngombana batjho wakhohlisa u-Adamu. Abafazi nabo bayazibuyiselela bathi indoda yinja ngombana yase ‘yatla’ isithelo ingazange ibuze. Kazi kutjhiwo u-Adamu-ke njalo.   

b)    uRogers (1996) uthi batjho umpostoli uPowula weTarsus ubegade agandelela khulu bonyana abafazi bazithobe emadodeni wabo.&lt;ref&gt;The troublesome helpmate

Book by Katharine M. Rogers&lt;/ref&gt;

Indaba yokuzithoba kuyabonakala bonyana isuselwa eBhayibhelini ngombana ngitjho nemasikweni wabo boke abantu ephasinapha injalo. Umma ulindeleke bonyana azithobe endodenakhe ngombana indoda iyihloko yomkhaya. Kukhona abayithatha ngommoya omuhle indaba le begodu bayamukele ngokuthula. Kanti nalabo abathotjelwako benza bonyana kube lula ukuthotjelwa. Kukhona-ke ebagugunako indaba le, balikhombe libaba bathi, “Nange ngingakuthobela ungazikhotha!” Khonapho kube ngongaphasi nongaphezulu njengombana sele siphila esikhathini sedemokhrasi nje.

Nokho uJohnson (2015:33) uthi batjho uHove (1999) uhlathulula indaba yakaPowula kuhle kwebeGalatiya 3:28 nakasithi, “AkunamJuda, akunamGrigi, ikhoboka namkha otjhaphulukileko, omduna namkha omsikazi ngombana nimunye noke kuKrestu Jesu.&lt;ref&gt;Hove. R. 1991. ''Equality in Christ: Galatians'' 3:28 ''and the gender dispute'' (p. 17) Wheaton: Crossway. International Center for Research on Women. (2013). US. International Violence Against Women Act. &lt;nowiki&gt;http://www.icrw.org/what-we-do/violence-against-women&lt;/nowiki&gt;. Accessed 11 Feb 2013.&lt;/ref&gt;”Umbono kaJohnson uthi batjho indaba yokuzithoba nokuthotjelwa ibekwe ngendlela elingisa uKrestu nebandla. Ngamye amezwi isiga lesi sokuthoba nokuthotjelwa sifaniswa nangendlela ibandla lithobela ngakho uKrestu, godu noKrestu ngendlela athanda ngakho ibandla (Kwebe-Efesu 5:21-33).

UJohnson (2015:33) ubuye athi batjho uRinck (199) encwadinakhe ethi; “Amadoda Akholwako Ahloye Abomma”&lt;ref&gt;Christian Men who Hate Women: Healing Hurting Relationships

Book by Margaret J. Rinck&lt;/ref&gt;, uthi kunamadoda athileko emphakathini wabakholwako ahlathulula kumbi abe asebenzise butjhulweni ifundiso yeBhayibheli yokuzithoba. Uthi ifundiso okungiyo yokuzithoba ayisihlangothi linye kodwana kuyathotjelwana. Godu ifundiso le igandelela ukuthandana nokuhloniphana, ingasi ukuthotjiswa ngeenkhwepha. Kanti u West (2003) yena umbono wakhe uthi batjho abobaba abahlukumezako bahlukumeza ihlelo elicwengileko lakaZimu begodu isenzo sabo leso sivinyilika esonweni.&lt;ref&gt;'''Theology of the Body Explained: A Commentary on John Paul II's''' &quot;'''Gospel of the Body'''&quot; ... Christopher West makes John Paul II's theology of the body ...&lt;/ref&gt;

c)    UCathrine banoJames (1996:16-27) bona baveza iinkolelo ezine ezisisekelo amakholwa kanengi aziseka ngazo:

1.    UZimu wakubeka bonyana indoda ikhonye bese umfazi uyazithoba

2.    Umfazi mncani kunendoda nje-ke akakwazi ukwenza iinqunto ekhaya

3.    Ukutlhaga kusisekelo samakholwa khulukhulu sabomma

4.    Amakholwa kufanele acolele msinyana, abuyisane nalabo abawahlukumezako.

Kujayelekile bonyana umma nakahlukunyezwako ngekhaya ulindeleke bonyana acolele ubaba nakube ubaba loyo ubonwa umlandu ngezenzo zakhe. Njengombana kubomma khulukhulu abaya esondweni, ikulumo le isuke ibe namandla ngombana kuthiwa, “Angithi uthi ulikholwa! Alo kuba yini ungacoleli? IBhayibheli lithi usilibalele amacala wethu njengombana nathi sibalibalela abanamacala kithi”(Matewu 6:12) khisibe nokho ukuhlukunyezwa khona kuragela phambili. Nakube umma loyo ulila ngokuthi sele kukanengi amlibalela bese kuthiwe kuye, “Angithi neBhayibheli liyatjho bonyana ulibalele umuntu kube ngokubuyelelwe amatjhumi alikhomba nakhomba?” [Matewu 18:21-22]. Khonapho indaba yokuphenduka kwaloyo ohlukumezako yona ayiphathwa.

== Okutjhiwo LiBhayibheli NgoGenesisi 2:18 Nebe-Efesu 5:22 ==
UGenesisi 2:18 uthi, “USomnini uZimu wathi: ‘Akusikuhle bona umuntu ahlale yedwa. Yeke ngizomenzela '''umsizi omfaneleko'''.’”

'''וַיֹּ֙אמֶר֙ יְהוָ֣ה אֱלֹהִ֔ים לֹא־טֹ֛וב הֱיֹ֥ות הָֽאָדָ֖ם לְבַדֹּ֑ו אֶֽעֱשֶׂהּ־לֹּ֥ו עֵ֖זֶר כְּנֶגְדֹּֽו'''׃ [Wayyomer Yahweh Elohim lo towb heyowt ha-Adam lebaddow eseh low ezer kenegdo]&lt;ref&gt;https://en.wikipedia.org/wiki/Hebrew_Bible&lt;/ref&gt;

Leli litjhugululo lesiNdebele lango-2012. Woke amalimi esiwafundako eBhayibhelini alitjhugululo lesiHebheru namkha lesiGirigi. ETestamendeni eliDala ilimi elimsuka siHebheru. Yeke kufanele sibuyele kiso isiHebheru siqale bonyana ikulumo le ithini. Amagama athi, ‘umsizi omfaneleko’ asuselwe kusiHebheru ekulumeni ethi [עזר כנגדו׃] ‘ezer kenegdo’. Ngaphambi kobana siqale ihlathululo yamagama la, kuqakathekile ukuveza bonyana ngokuqalisisa amagama la, akwenziwa imizamo yokuhlaba namkha yokujamelela ihlangothi elithileko. Umnqopho kuveza bona ekhabo lakhona sithini isiHebheru endimeni le.

Igama lokuthoma lithi “ezer” namkha umsizi. NgokwesiHebheru litjho umuntu osiza omunye lokha yena anganamandla wokuzisiza. Umuntu osizako angaba ngonamandla begodu omkhulu kiloyo osizwako namkha kungaba ngomlingani waloyo osizwako ngokwamazinga athileko wepilo. Kufanele sikutjheje-ke lokhu: Akwenzeki bonyana umsizi abe mncani kunosizwako.

Nanyana kungaba ngayiphi indlela kodwana ihlathululo yona itjho bona umsizi wenza umthwalo waloyo osizwako ube lula. Esikhathini esinengi-ke igameli lisetjenziswa ukutjho uSomnini bonyana umsindisi, umsizi, umvikeli, umumenyeli namkha umbhadekeli. Ku-1 Samyeli 7: 12 kuthiwa, “USamyela wathatha ilitje walijamisa phakathi kweMitsipha neTjheni. Walithiya ibizo wathi yi-Ebheni-Ezeri asithi: “Bekube lapha uSomnini usisizile.”  

Igama lesibili lithi khenegdo. NgesiHebheru lingasebenza njengephriphozitjhini litjho ukuthi ngaphambili. Godu lingatjho ukuthi ongafani naye ngobulili namkha ofaneleko. Yeke nasiqala indinyana le ngamanye amezwi ithi:

·       “Ngizomenzela omsizi/umenyeli ozokujama phambi kwakhe.” Siyazi bona umuntu nakwenyelako ujama phambi kwakho ukwenzela bona nanyana yini efuna ukukulimaza ithome ngaye.

·       “Ngizomenzela umsizi ongafani naye ngobulili”

·       “Ngizomenzela umsizi ofaneleko” ngamanye amezwi uzokulingana/uzokukhambisana nesizo afanele amnikele lona.

Incwadi yebe-Efesu 5:22-33 yona ithi, “Bafazi, thobelani amadoda wenu sengathi nithobela iKosi ngombana indoda iyihloko yomfazi, njengombana uKrestu ayihloko yebandla elimzimba wakhe begodu yena aMsindisi walo. Njengombana ibandla limthobela uKrestu, ngokunjalo nabafazi kumele bathobele amadoda wabo kikho koke. Madoda thandani abafazi benu njengombana uKrestu athanda ibandla, wadela ukuphila kwakhe ngebanga lalo. Walicwengisa, walihlanza ngamanzi nangelizwi lakhe begodu waliletha kuye lilibandla elinephazimulo, elinganachaphazi, ukutjhwabana namkha umphambo wananyana yini kodwana licwengile begodu limsulwa. Ngokunjalo namadoda kufanele athande abafazi bawo njengombana athanda imizimba yawo. Othanda umkakhe uzithanda yena ngokwakhe. Akakho owakhe wazonda umzimbakhe kodwana ngiloyo naloyo uyawondla awutlhogomele, njengombana noKrestu asenza ebandleni ngombana sizizitho zomzimbakhe. “Ngalokho-ke indoda izokutjhiya uyise nonina inamathele kumkayo, nje-ke ababili labo babe nyamanye.” Yifihlakalo ekulu le, kodwana ngikhuluma ngoKrestu nebandla. Nokho-ke omunye nomunye wenu kumele athande umkakhe njengombana azithanda yena, nomfazi kumele ahloniphe indodakhe.

Nasiqala eBhayibhelini siyafunyana bonyana uZimu, omnikazi womtjhado, uyithathela phezulu namkha ngokuncama okukhulu indaba yobudlelwana phakathi kwendoda nomfazi kangangobana uyilinganisa nobudlelwana obuphakathi kwakaKrestu nebandla. Lokhu sikubona encwadini yebe-Efesu 5:22. Yeke kuyasibonisa bonyana akukameli ithathwe ngesincele indaba le.  Kuyafuneka-ke bonyana nakudzujulwa indinyana le ingatjhiywa phakathi kodwana kuqalwe indaba yoke lapha ithoma khona bekufike lapha igcina khona. Nasiyifunda kuhle ithi umfazi akathobele indoda yakhe. Lokho akwenze njengalokha ibandla nalithobela uKrestu. Libuye lithi indoda ayithande umkayo. Ithando lelo alibe njengelakaKrestu athanda ngalo ibandla. Umma akaqale bonyana ibandla limthobela njani uKrestu bese naye wenza njalo endodeni yakhe. Indoda ayiqale bona uKrestu ulithanda njani ibandla, naye enze njalo kumkakhe.

Ukrestu akalitlhorisi ibandla, kodwana uyalithanda abe alivikele. Qala incwadi yezEnzo 9:1-4 lapha uKrestu adula khona phasi uSawula ngombani ngombana ahlukumeza ibandla.

Ngemva kobana sele sifumene ihlathululo kaGenesisi 2:18 neyebe-Efesu 5:22 kuyakhanya bonyana kukhona iimponjwana ekudzujulweni kwemitlolo le ukusekela ukuhlukunyezwa kwabomma emendweni. KuGenesisi akukho lapha sifumene khona bonyana umma mncani ebudlelwaneni bomtjhado njengombana kuthatheka emphakathini. ILizwi lakaZimu nabelisithi umma umsizi wakababa azange lithi umma mncani. Siyizwile ihlathululo yesiHebheru mayelana negama elithi umsizi. Kanti nawo amagama athi bazokuba nyamanye atjho bona bamumuntu munye. Alo-ke, kuvelaphi ukobana ngemva sele kuthiwe banyamanye bese kuthiwe omunye mncani omunye mkhulu? Godu ikulumo le ayitjho bona umma akanyaze ubaba angamhloniphi njengombana ingatjho bona ubaba adule namkha atlhorise umma. Nakhe nayibonaphi ihloko yomuntu idulana nomzimba, namkha umzimba uphikisana nehloko? Ihloko isemzimbeni munye, nomzimba unehloko yinye.

Encwadini yebe-Efesu siyafunyana bona ubudlelwano bomtjhado bufaniswa nobudlelwano bakaKrestu nebandla. Kungaba buhlungu nange ubuhle bomuntu bungafaniswa nefarigi. Cabanga sele kuthiwa umuntu lo muhle njengefarigi! Ubudlelwana bakaKrestu nebandla bufaniselwani nobudlelwana bendoda nomfazi nakube indoda ihlukumeza umfazi, nomfazi uhlazisa indoda emendweni?

Kwanga uZimu angazibonakalisa emadodeni ahlukumeza abomma ngendlela efana poro naleyo azibonakalisa ngayo kuSawula obegade ahlukumeza ibandla. Azibonakalise ngokunjalo nakibo abomma abangaphathi kuhle amadoda wabo emendweni. Ngalokho isingathekiso somendo nebandla sizakuba namandla begodu sizwisiseke ngitjho nebantwini abasebenzisa iLizwi lakaZimu butjhilweni ukusekela izenzo ezifana nalezi!

== IMITHOMBOLWAZI ==</text>
      <sha1>rqklqb5yfz43m9anwiaqla4gtqncanx</sha1>
    </revision>
    <revision>
      <id>5880</id>
      <parentid>5874</parentid>
      <timestamp>2025-09-30T13:28:43Z</timestamp>
      <contributor>
        <username>Wikabena</username>
        <id>1037</id>
      </contributor>
      <comment>I added a reference</comment>
      <origin>5880</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="16207" sha1="tpqei5oc7jt6zhmdtbp0mvktf98lr8o" xml:space="preserve">'''Esikhathini''' esinengi abomma abasemendweni bazifumana bahlukumezeka ngokwesiko ngitjho nangokwekolo kusetjenziswe neLizwi lakaZimu ukusekela isiga sokuhlukumeza leso. Umtlolo ovame khulu ukusetjenziswa butjhilweni ngosencwadini '''kaGenesisi 2:18''' othi: “USomnini uZimu wathi: ‘Akusikuhle bona umuntu ahlale yedwa. Yeke ngizomenzela '''umsizi omfaneleko'''.’”&lt;ref&gt;https://cumbooks.co.za/collections/bibles-other-languages/products/ibhayibheli-elicwengileko-isindebele-2012-black-hardcover?srsltid=AfmBOooOf7laiE6UsoShv0RmUSAMmvZJPqjxs5xKf98vaA9ogWdSC9sJ&lt;/ref&gt;; nencwadini '''yebe-Efesu 5:22''' othi, “'''Bafazi, thobelani''' '''amadoda''' wenu sengathi nithobela iKosi ngombana '''indoda iyihloko''' '''yomfazi,''' njengombana uKrestu ayihloko yebandla elimzimba wakhe begodu yena aMsindisi walo.”&lt;ref&gt;https://cumbooks.co.za/collections/bibles-other-languages/products/ibhayibheli-elicwengileko-isindebele-2012-black-hardcover?srsltid=AfmBOooOf7laiE6UsoShv0RmUSAMmvZJPqjxs5xKf98vaA9ogWdSC9sJ&lt;/ref&gt; Umnqopho wephepha leli kuveza ihlathululo yeendimana ezitjhwiwe ngaphezulu ngokomtlolo wesiHebheru nesiGirigi ngehloso yokuletha umkhanyo mayelana nalokho ebekutjhiwo ziindimana lezi ekhabo lakhona. UmTlolo wesiHebheru uzakusetjenziswa ngombana umsuka welimi elisetjenziswe eTestamendeni eliDala siHebheru. UmTlolo wesiGirigi nawo uzakusetjenziswa ngombana umsuka welimi elisetjenziswe eTestamendeni eliTjha siGirigi. Ekugcineni nasele kuhlathululwe iindimana lezi kuzakukhanya bonyana ukusetjenziswa komTlolo ukusekela ukuhlukumezeka kwabomma abasemendweni ngambala kudzimelele eLizwini lakaZimu namkha njani.

[[Isimumathi:A Russian poster urging open your eyes - against women being abused (Transparent).png|thumb|Ukutlhoriswa kwabomma]]

== Kuyini Ukuhlukumezeka Namkha Ukuhlukunyezwa Kwabomma Abasemendweni? ==
Ukuya ngokukaKristin ('''2005)''' ukuhlukumezeka kwabomma kungathiwa mguruguru wangekhaya, mguruguru womndeni, kubethwa kwabomma namkha ukuhlukunyezwa kwabalingani.&lt;ref name=&quot;:0&quot;&gt;Catherine Clark Kroeger and James R. Beck, 1996. Women, Abuse, and the Bible. How scripture can be used to hurt or to heal. Baker Books, Michigan&lt;/ref&gt;

Ukuhlukumeza kutjho ukusebenzisa amandla butjhulweni phezu kwaloyo okuthatheka bonyana mncani namkha uyanyazeka.

UKristin (2005) ubuye ahlathulule iingaba zokuhlukumeza namkha zokuhlukumezeka bunje:&lt;ref name=&quot;:0&quot; /&gt;

1.    Ukuhlukunyezwa ngokomzimba: kubandakanya ukubetha (ukuwakala, ukumanya, ukupatlula, ukusawula), ukudula, ukurarha (ukubhakela), ukusunduza (ukukghurumeja, ukukhahlameza) nokusetjenziswa kwesibulawo (isikhali) ngitjho nanyana ungaphuma imivuvu namkha ungabi nayo imivuvu. Koke lokhu kuzizenzo zobelelesi ngokomThethosisekelo.

2.    Ukuhlukunyezwa ngokwamezwi: ukuthethisa, ukukgharameja, ukuthusela, nokudubhulela umlomo.

3.    Ukuhlukunyezwa ngokwamazizo /ngokomkhumbulo: ukwehlisa umuntu isithunzi, ukumbangela bona azinyaze, ukumnyazisa nokumhlambalazisa ngabentwana.

4.    Ukuhlukunyezwa ngokwehlalo:  Lokhu kutjho ukuqotjha umuntu emndenini, ukumlahlisa abangani, ukumlandelela nokumkhola ngomrhala.

5.    Ukuhlukunyezwa ngokwemali: Ukutswinya umlingani ngokweemali ukwenzela bonyana angakghoni ukuzenzela izinto ezithileko, ukusozisa ngokuchitha imali ebeyifanele ibhadekele umkhaya. 

== Imibono Yabatloli Abahlukahlukeneko ==
Lokha nakunezenzo zokuhlukunyezwa kwabomma abasemendweni ngekhaya kuvamisile bonyana kuqalelelwe isiko namkha isondo kobana likhalime. Lokhu kutjho bona indaba leyo ingasiwa ngekosini namkha ingasiwa esondweni kumfundisi, kufunwe intatha. Umbuzo okhona kukuthi isiko nesondo namkha ikolo liyirarulula njani indaba leyo. Siyazi-ke bonyana emalangeni esiphila kiwo sele kukhona nomThethosisekelo ovikela ukuhlukunyezwa, okutjho bona ohlukunyezwako unelungelo lokumangala ekhotho yomthetho. Nokho-ke kileliphepha sizokuqalelela ngehlangothini lekolo bonyana ngambala imitlolo iyavumelana nokuhlukunyezwa kwabomma abasemendweni na?

Kujayelekile bonyana umma nakahlukunyezwako ngekhaya kuthathwe bonyana akakazithobi ngokwaneleko kubaba wakwakhe njengombana kusitjho iBhayibheli encwadini yebe-Efesu 5:22.&lt;ref&gt;IBHAYIBHELI ELICWENGILEKO: isiNdebele Bible – 2012 ...&lt;/ref&gt; Nanyana sele kuthathwa bona kukutlhorswa kwabantwana ngokomthetho wedemokhrasi nje, kodwana ngokujayelekileko, umntwana nakangalaleli ababelethi, unungwanungwa ngeswazana ukuze afakwe endleleni njengombana kusitjho umTlolo encwadini yezAga 23:13-14 “Ungalisi ukukhalima umntwanakho; akazukufa nawumnunga ngeswazi. Wena nawumbetha ngeswazi, uzabe usindisa umphefumulwakhe ekufeni.” Nokho-ke awukho umtlolo othi umma naye kufanele anungwanungwe ngubaba nakube kukhona ukungazwisisani, ije ubaba ayihloko yekhaya.

Ukuya ngokombiko we-Anglican Book Center, (1987:33) umma uyalulekwa kuthiwe kufanele azithobe kubaba ngeenkhathi zoke nebujamweni boke. Kubuye kuthiwe ukuhlukunyezwa kwakhe kusiphambano sakhe okufuze asithwale bekube sekufeni njengombana kwenza uJesu Krestu.&lt;ref&gt;BOOK OF ALTERNATIVE SERVICES OF THE ANGLICAN ...&lt;/ref&gt;

Kanti uBill Gothard we-Institute in Basic Youth Conflicts yena uthi batjho lokha umma nakazithoba endodenakhe emhlukumezako, ufunda ukubekezelela ukutlhagiswa ngebanga lokulunga (Matewu 5:10). Ngamanye amezwi odulwako kufanele aphethe imitlolo ukuze abonise ukulunga nekghono lokunyamezela bese kudzujulwa KwebeGalatiya 5:22, khisibe odulako yena kuvalwe phetjheya ngaye; namkha kuthiwe, “bazambona abanamehlo!”

U-Andy (2015:33) ukhamba adzubhula imibono yabatloli abahlukahlukeneko bunjesi:&lt;ref&gt;Andy Johnson. 2015. Religion and Men’s Violence Against Women. Springer&lt;/ref&gt;

a)    uRuthven (1990) uthi batjho uTertullian owayengomunye wabadosi phambili bezekolo obekuthiwa ma-“Apostolic fathers” umfazi ulisango lakasathana.&lt;ref&gt;Feminist literary studies

Book by K. Ruthven&lt;/ref&gt; Godu batjho uthi umfazi ulithempeli elakhiwe phezu kothuvi:

Banengi-ke abakhambisana nombono lo ngitjho nemphakathini wabakholwako. Kunekulumo ethi umfazi yinyoka, kutjhiwo kunqotjhiswe ku-Eva ngombana batjho wakhohlisa u-Adamu. Abafazi nabo bayazibuyiselela bathi indoda yinja ngombana yase ‘yatla’ isithelo ingazange ibuze. Kazi kutjhiwo u-Adamu-ke njalo.   

b)    uRogers (1996) uthi batjho umpostoli uPowula weTarsus ubegade agandelela khulu bonyana abafazi bazithobe emadodeni wabo.&lt;ref&gt;The troublesome helpmate

Book by Katharine M. Rogers&lt;/ref&gt;

Indaba yokuzithoba kuyabonakala bonyana isuselwa eBhayibhelini ngombana ngitjho nemasikweni wabo boke abantu ephasinapha injalo. Umma ulindeleke bonyana azithobe endodenakhe ngombana indoda iyihloko yomkhaya. Kukhona abayithatha ngommoya omuhle indaba le begodu bayamukele ngokuthula. Kanti nalabo abathotjelwako benza bonyana kube lula ukuthotjelwa. Kukhona-ke ebagugunako indaba le, balikhombe libaba bathi, “Nange ngingakuthobela ungazikhotha!” Khonapho kube ngongaphasi nongaphezulu njengombana sele siphila esikhathini sedemokhrasi nje.

Nokho uJohnson (2015:33) uthi batjho uHove (1999) uhlathulula indaba yakaPowula kuhle kwebeGalatiya 3:28 nakasithi, “AkunamJuda, akunamGrigi, ikhoboka namkha otjhaphulukileko, omduna namkha omsikazi ngombana nimunye noke kuKrestu Jesu.&lt;ref&gt;Hove. R. 1991. ''Equality in Christ: Galatians'' 3:28 ''and the gender dispute'' (p. 17) Wheaton: Crossway. International Center for Research on Women. (2013). US. International Violence Against Women Act. &lt;nowiki&gt;http://www.icrw.org/what-we-do/violence-against-women&lt;/nowiki&gt;. Accessed 11 Feb 2013.&lt;/ref&gt;”Umbono kaJohnson uthi batjho indaba yokuzithoba nokuthotjelwa ibekwe ngendlela elingisa uKrestu nebandla. Ngamye amezwi isiga lesi sokuthoba nokuthotjelwa sifaniswa nangendlela ibandla lithobela ngakho uKrestu, godu noKrestu ngendlela athanda ngakho ibandla (Kwebe-Efesu 5:21-33).

UJohnson (2015:33) ubuye athi batjho uRinck (199) encwadinakhe ethi; “Amadoda Akholwako Ahloye Abomma”&lt;ref&gt;Christian Men who Hate Women: Healing Hurting Relationships

Book by Margaret J. Rinck&lt;/ref&gt;, uthi kunamadoda athileko emphakathini wabakholwako ahlathulula kumbi abe asebenzise butjhulweni ifundiso yeBhayibheli yokuzithoba. Uthi ifundiso okungiyo yokuzithoba ayisihlangothi linye kodwana kuyathotjelwana. Godu ifundiso le igandelela ukuthandana nokuhloniphana, ingasi ukuthotjiswa ngeenkhwepha. Kanti u West (2003) yena umbono wakhe uthi batjho abobaba abahlukumezako bahlukumeza ihlelo elicwengileko lakaZimu begodu isenzo sabo leso sivinyilika esonweni.&lt;ref&gt;'''Theology of the Body Explained: A Commentary on John Paul II's''' &quot;'''Gospel of the Body'''&quot; ... Christopher West makes John Paul II's theology of the body ...&lt;/ref&gt;

c)    UCathrine banoJames (1996:16-27) bona baveza iinkolelo ezine ezisisekelo amakholwa kanengi aziseka ngazo:&lt;ref&gt;https://www.amazon.com/Self-Love-Katherine-James/dp/1524640808&lt;/ref&gt;

1.    UZimu wakubeka bonyana indoda ikhonye bese umfazi uyazithoba

2.    Umfazi mncani kunendoda nje-ke akakwazi ukwenza iinqunto ekhaya

3.    Ukutlhaga kusisekelo samakholwa khulukhulu sabomma

4.    Amakholwa kufanele acolele msinyana, abuyisane nalabo abawahlukumezako.

Kujayelekile bonyana umma nakahlukunyezwako ngekhaya ulindeleke bonyana acolele ubaba nakube ubaba loyo ubonwa umlandu ngezenzo zakhe. Njengombana kubomma khulukhulu abaya esondweni, ikulumo le isuke ibe namandla ngombana kuthiwa, “Angithi uthi ulikholwa! Alo kuba yini ungacoleli? IBhayibheli lithi usilibalele amacala wethu njengombana nathi sibalibalela abanamacala kithi”(Matewu 6:12) khisibe nokho ukuhlukunyezwa khona kuragela phambili. Nakube umma loyo ulila ngokuthi sele kukanengi amlibalela bese kuthiwe kuye, “Angithi neBhayibheli liyatjho bonyana ulibalele umuntu kube ngokubuyelelwe amatjhumi alikhomba nakhomba?” [Matewu 18:21-22]. Khonapho indaba yokuphenduka kwaloyo ohlukumezako yona ayiphathwa.

== Okutjhiwo LiBhayibheli NgoGenesisi 2:18 Nebe-Efesu 5:22 ==
UGenesisi 2:18 uthi, “USomnini uZimu wathi: ‘Akusikuhle bona umuntu ahlale yedwa. Yeke ngizomenzela '''umsizi omfaneleko'''.’”

'''וַיֹּ֙אמֶר֙ יְהוָ֣ה אֱלֹהִ֔ים לֹא־טֹ֛וב הֱיֹ֥ות הָֽאָדָ֖ם לְבַדֹּ֑ו אֶֽעֱשֶׂהּ־לֹּ֥ו עֵ֖זֶר כְּנֶגְדֹּֽו'''׃ [Wayyomer Yahweh Elohim lo towb heyowt ha-Adam lebaddow eseh low ezer kenegdo]&lt;ref&gt;https://en.wikipedia.org/wiki/Hebrew_Bible&lt;/ref&gt;

Leli litjhugululo lesiNdebele lango-2012. Woke amalimi esiwafundako eBhayibhelini alitjhugululo lesiHebheru namkha lesiGirigi. ETestamendeni eliDala ilimi elimsuka siHebheru. Yeke kufanele sibuyele kiso isiHebheru siqale bonyana ikulumo le ithini. Amagama athi, ‘umsizi omfaneleko’ asuselwe kusiHebheru ekulumeni ethi [עזר כנגדו׃] ‘ezer kenegdo’. Ngaphambi kobana siqale ihlathululo yamagama la, kuqakathekile ukuveza bonyana ngokuqalisisa amagama la, akwenziwa imizamo yokuhlaba namkha yokujamelela ihlangothi elithileko. Umnqopho kuveza bona ekhabo lakhona sithini isiHebheru endimeni le.

Igama lokuthoma lithi “ezer” namkha umsizi. NgokwesiHebheru litjho umuntu osiza omunye lokha yena anganamandla wokuzisiza. Umuntu osizako angaba ngonamandla begodu omkhulu kiloyo osizwako namkha kungaba ngomlingani waloyo osizwako ngokwamazinga athileko wepilo. Kufanele sikutjheje-ke lokhu: Akwenzeki bonyana umsizi abe mncani kunosizwako.

Nanyana kungaba ngayiphi indlela kodwana ihlathululo yona itjho bona umsizi wenza umthwalo waloyo osizwako ube lula. Esikhathini esinengi-ke igameli lisetjenziswa ukutjho uSomnini bonyana umsindisi, umsizi, umvikeli, umumenyeli namkha umbhadekeli. Ku-1 Samyeli 7: 12 kuthiwa, “USamyela wathatha ilitje walijamisa phakathi kweMitsipha neTjheni. Walithiya ibizo wathi yi-Ebheni-Ezeri asithi: “Bekube lapha uSomnini usisizile.”  

Igama lesibili lithi khenegdo. NgesiHebheru lingasebenza njengephriphozitjhini litjho ukuthi ngaphambili. Godu lingatjho ukuthi ongafani naye ngobulili namkha ofaneleko. Yeke nasiqala indinyana le ngamanye amezwi ithi:

·       “Ngizomenzela omsizi/umenyeli ozokujama phambi kwakhe.” Siyazi bona umuntu nakwenyelako ujama phambi kwakho ukwenzela bona nanyana yini efuna ukukulimaza ithome ngaye.

·       “Ngizomenzela umsizi ongafani naye ngobulili”

·       “Ngizomenzela umsizi ofaneleko” ngamanye amezwi uzokulingana/uzokukhambisana nesizo afanele amnikele lona.

Incwadi yebe-Efesu 5:22-33 yona ithi, “Bafazi, thobelani amadoda wenu sengathi nithobela iKosi ngombana indoda iyihloko yomfazi, njengombana uKrestu ayihloko yebandla elimzimba wakhe begodu yena aMsindisi walo. Njengombana ibandla limthobela uKrestu, ngokunjalo nabafazi kumele bathobele amadoda wabo kikho koke. Madoda thandani abafazi benu njengombana uKrestu athanda ibandla, wadela ukuphila kwakhe ngebanga lalo. Walicwengisa, walihlanza ngamanzi nangelizwi lakhe begodu waliletha kuye lilibandla elinephazimulo, elinganachaphazi, ukutjhwabana namkha umphambo wananyana yini kodwana licwengile begodu limsulwa. Ngokunjalo namadoda kufanele athande abafazi bawo njengombana athanda imizimba yawo. Othanda umkakhe uzithanda yena ngokwakhe. Akakho owakhe wazonda umzimbakhe kodwana ngiloyo naloyo uyawondla awutlhogomele, njengombana noKrestu asenza ebandleni ngombana sizizitho zomzimbakhe. “Ngalokho-ke indoda izokutjhiya uyise nonina inamathele kumkayo, nje-ke ababili labo babe nyamanye.” Yifihlakalo ekulu le, kodwana ngikhuluma ngoKrestu nebandla. Nokho-ke omunye nomunye wenu kumele athande umkakhe njengombana azithanda yena, nomfazi kumele ahloniphe indodakhe.

Nasiqala eBhayibhelini siyafunyana bonyana uZimu, omnikazi womtjhado, uyithathela phezulu namkha ngokuncama okukhulu indaba yobudlelwana phakathi kwendoda nomfazi kangangobana uyilinganisa nobudlelwana obuphakathi kwakaKrestu nebandla. Lokhu sikubona encwadini yebe-Efesu 5:22. Yeke kuyasibonisa bonyana akukameli ithathwe ngesincele indaba le.  Kuyafuneka-ke bonyana nakudzujulwa indinyana le ingatjhiywa phakathi kodwana kuqalwe indaba yoke lapha ithoma khona bekufike lapha igcina khona. Nasiyifunda kuhle ithi umfazi akathobele indoda yakhe. Lokho akwenze njengalokha ibandla nalithobela uKrestu. Libuye lithi indoda ayithande umkayo. Ithando lelo alibe njengelakaKrestu athanda ngalo ibandla. Umma akaqale bonyana ibandla limthobela njani uKrestu bese naye wenza njalo endodeni yakhe. Indoda ayiqale bona uKrestu ulithanda njani ibandla, naye enze njalo kumkakhe.

Ukrestu akalitlhorisi ibandla, kodwana uyalithanda abe alivikele. Qala incwadi yezEnzo 9:1-4 lapha uKrestu adula khona phasi uSawula ngombani ngombana ahlukumeza ibandla.

Ngemva kobana sele sifumene ihlathululo kaGenesisi 2:18 neyebe-Efesu 5:22 kuyakhanya bonyana kukhona iimponjwana ekudzujulweni kwemitlolo le ukusekela ukuhlukunyezwa kwabomma emendweni. KuGenesisi akukho lapha sifumene khona bonyana umma mncani ebudlelwaneni bomtjhado njengombana kuthatheka emphakathini. ILizwi lakaZimu nabelisithi umma umsizi wakababa azange lithi umma mncani. Siyizwile ihlathululo yesiHebheru mayelana negama elithi umsizi. Kanti nawo amagama athi bazokuba nyamanye atjho bona bamumuntu munye. Alo-ke, kuvelaphi ukobana ngemva sele kuthiwe banyamanye bese kuthiwe omunye mncani omunye mkhulu? Godu ikulumo le ayitjho bona umma akanyaze ubaba angamhloniphi njengombana ingatjho bona ubaba adule namkha atlhorise umma. Nakhe nayibonaphi ihloko yomuntu idulana nomzimba, namkha umzimba uphikisana nehloko? Ihloko isemzimbeni munye, nomzimba unehloko yinye.

Encwadini yebe-Efesu siyafunyana bona ubudlelwano bomtjhado bufaniswa nobudlelwano bakaKrestu nebandla. Kungaba buhlungu nange ubuhle bomuntu bungafaniswa nefarigi. Cabanga sele kuthiwa umuntu lo muhle njengefarigi! Ubudlelwana bakaKrestu nebandla bufaniselwani nobudlelwana bendoda nomfazi nakube indoda ihlukumeza umfazi, nomfazi uhlazisa indoda emendweni?

Kwanga uZimu angazibonakalisa emadodeni ahlukumeza abomma ngendlela efana poro naleyo azibonakalisa ngayo kuSawula obegade ahlukumeza ibandla. Azibonakalise ngokunjalo nakibo abomma abangaphathi kuhle amadoda wabo emendweni. Ngalokho isingathekiso somendo nebandla sizakuba namandla begodu sizwisiseke ngitjho nebantwini abasebenzisa iLizwi lakaZimu butjhilweni ukusekela izenzo ezifana nalezi!

== IMITHOMBOLWAZI ==</text>
      <sha1>tpqei5oc7jt6zhmdtbp0mvktf98lr8o</sha1>
    </revision>
    <revision>
      <id>5885</id>
      <parentid>5880</parentid>
      <timestamp>2025-09-30T13:37:43Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <origin>5885</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="16165" sha1="3ip4ok9u5vkccf3itfiabmtcg1wubwd" xml:space="preserve">'''Esikhathini''' esinengi abomma abasemendweni bazifumana bahlukumezeka ngokwesiko ngitjho nangokwekolo kusetjenziswe neLizwi lakaZimu ukusekela isiga sokuhlukumeza leso. Umtlolo ovame khulu ukusetjenziswa butjhilweni ngosencwadini kaGenesisi 2:18 othi: “USomnini uZimu wathi: ‘Akusikuhle bona umuntu ahlale yedwa. Yeke ngizomenzela umsizi omfaneleko.’”&lt;ref&gt;https://cumbooks.co.za/collections/bibles-other-languages/products/ibhayibheli-elicwengileko-isindebele-2012-black-hardcover?srsltid=AfmBOooOf7laiE6UsoShv0RmUSAMmvZJPqjxs5xKf98vaA9ogWdSC9sJ&lt;/ref&gt;; nencwadini yebe-Efesu 5:22 othi, “Bafazi, thobelani amadoda wenu sengathi nithobela iKosi ngombana indoda iyihloko yomfazi, njengombana uKrestu ayihloko yebandla elimzimba wakhe begodu yena aMsindisi walo.”&lt;ref&gt;https://cumbooks.co.za/collections/bibles-other-languages/products/ibhayibheli-elicwengileko-isindebele-2012-black-hardcover?srsltid=AfmBOooOf7laiE6UsoShv0RmUSAMmvZJPqjxs5xKf98vaA9ogWdSC9sJ&lt;/ref&gt; Umnqopho wephepha leli kuveza ihlathululo yeendimana ezitjhwiwe ngaphezulu ngokomtlolo wesiHebheru nesiGirigi ngehloso yokuletha umkhanyo mayelana nalokho ebekutjhiwo ziindimana lezi ekhabo lakhona. UmTlolo wesiHebheru uzakusetjenziswa ngombana umsuka welimi elisetjenziswe eTestamendeni eliDala siHebheru. UmTlolo wesiGirigi nawo uzakusetjenziswa ngombana umsuka welimi elisetjenziswe eTestamendeni eliTjha siGirigi. Ekugcineni nasele kuhlathululwe iindimana lezi kuzakukhanya bonyana ukusetjenziswa komTlolo ukusekela ukuhlukumezeka kwabomma abasemendweni ngambala kudzimelele eLizwini lakaZimu namkha njani.

[[Isimumathi:A Russian poster urging open your eyes - against women being abused (Transparent).png|thumb|Ukutlhoriswa kwabomma]]

== Kuyini Ukuhlukumezeka Namkha Ukuhlukunyezwa Kwabomma Abasemendweni? ==
Ukuya ngokukaKristin ('''2005)''' ukuhlukumezeka kwabomma kungathiwa mguruguru wangekhaya, mguruguru womndeni, kubethwa kwabomma namkha ukuhlukunyezwa kwabalingani.&lt;ref name=&quot;:0&quot;&gt;Catherine Clark Kroeger and James R. Beck, 1996. Women, Abuse, and the Bible. How scripture can be used to hurt or to heal. Baker Books, Michigan&lt;/ref&gt;

Ukuhlukumeza kutjho ukusebenzisa amandla butjhulweni phezu kwaloyo okuthatheka bonyana mncani namkha uyanyazeka.

UKristin (2005) ubuye ahlathulule iingaba zokuhlukumeza namkha zokuhlukumezeka bunje:&lt;ref name=&quot;:0&quot; /&gt;

1.    Ukuhlukunyezwa ngokomzimba: kubandakanya ukubetha (ukuwakala, ukumanya, ukupatlula, ukusawula), ukudula, ukurarha (ukubhakela), ukusunduza (ukukghurumeja, ukukhahlameza) nokusetjenziswa kwesibulawo (isikhali) ngitjho nanyana ungaphuma imivuvu namkha ungabi nayo imivuvu. Koke lokhu kuzizenzo zobelelesi ngokomThethosisekelo.

2.    Ukuhlukunyezwa ngokwamezwi: ukuthethisa, ukukgharameja, ukuthusela, nokudubhulela umlomo.

3.    Ukuhlukunyezwa ngokwamazizo /ngokomkhumbulo: ukwehlisa umuntu isithunzi, ukumbangela bona azinyaze, ukumnyazisa nokumhlambalazisa ngabentwana.

4.    Ukuhlukunyezwa ngokwehlalo:  Lokhu kutjho ukuqotjha umuntu emndenini, ukumlahlisa abangani, ukumlandelela nokumkhola ngomrhala.

5.    Ukuhlukunyezwa ngokwemali: Ukutswinya umlingani ngokweemali ukwenzela bonyana angakghoni ukuzenzela izinto ezithileko, ukusozisa ngokuchitha imali ebeyifanele ibhadekele umkhaya. 

== Imibono Yabatloli Abahlukahlukeneko ==
Lokha nakunezenzo zokuhlukunyezwa kwabomma abasemendweni ngekhaya kuvamisile bonyana kuqalelelwe isiko namkha isondo kobana likhalime. Lokhu kutjho bona indaba leyo ingasiwa ngekosini namkha ingasiwa esondweni kumfundisi, kufunwe intatha. Umbuzo okhona kukuthi isiko nesondo namkha ikolo liyirarulula njani indaba leyo. Siyazi-ke bonyana emalangeni esiphila kiwo sele kukhona nomThethosisekelo ovikela ukuhlukunyezwa, okutjho bona ohlukunyezwako unelungelo lokumangala ekhotho yomthetho. Nokho-ke kileliphepha sizokuqalelela ngehlangothini lekolo bonyana ngambala imitlolo iyavumelana nokuhlukunyezwa kwabomma abasemendweni na?

Kujayelekile bonyana umma nakahlukunyezwako ngekhaya kuthathwe bonyana akakazithobi ngokwaneleko kubaba wakwakhe njengombana kusitjho iBhayibheli encwadini yebe-Efesu 5:22.&lt;ref&gt;IBHAYIBHELI ELICWENGILEKO: isiNdebele Bible – 2012 ...&lt;/ref&gt; Nanyana sele kuthathwa bona kukutlhorswa kwabantwana ngokomthetho wedemokhrasi nje, kodwana ngokujayelekileko, umntwana nakangalaleli ababelethi, unungwanungwa ngeswazana ukuze afakwe endleleni njengombana kusitjho umTlolo encwadini yezAga 23:13-14 “Ungalisi ukukhalima umntwanakho; akazukufa nawumnunga ngeswazi. Wena nawumbetha ngeswazi, uzabe usindisa umphefumulwakhe ekufeni.” Nokho-ke awukho umtlolo othi umma naye kufanele anungwanungwe ngubaba nakube kukhona ukungazwisisani, ije ubaba ayihloko yekhaya.

Ukuya ngokombiko we-Anglican Book Center, (1987:33) umma uyalulekwa kuthiwe kufanele azithobe kubaba ngeenkhathi zoke nebujamweni boke. Kubuye kuthiwe ukuhlukunyezwa kwakhe kusiphambano sakhe okufuze asithwale bekube sekufeni njengombana kwenza uJesu Krestu.&lt;ref&gt;BOOK OF ALTERNATIVE SERVICES OF THE ANGLICAN ...&lt;/ref&gt;

Kanti uBill Gothard we-Institute in Basic Youth Conflicts yena uthi batjho lokha umma nakazithoba endodenakhe emhlukumezako, ufunda ukubekezelela ukutlhagiswa ngebanga lokulunga (Matewu 5:10). Ngamanye amezwi odulwako kufanele aphethe imitlolo ukuze abonise ukulunga nekghono lokunyamezela bese kudzujulwa KwebeGalatiya 5:22, khisibe odulako yena kuvalwe phetjheya ngaye; namkha kuthiwe, “bazambona abanamehlo!”

U-Andy (2015:33) ukhamba adzubhula imibono yabatloli abahlukahlukeneko bunjesi:&lt;ref&gt;Andy Johnson. 2015. Religion and Men’s Violence Against Women. Springer&lt;/ref&gt;

a)    uRuthven (1990) uthi batjho uTertullian owayengomunye wabadosi phambili bezekolo obekuthiwa ma-“Apostolic fathers” umfazi ulisango lakasathana.&lt;ref&gt;Feminist literary studies

Book by K. Ruthven&lt;/ref&gt; Godu batjho uthi umfazi ulithempeli elakhiwe phezu kothuvi:

Banengi-ke abakhambisana nombono lo ngitjho nemphakathini wabakholwako. Kunekulumo ethi umfazi yinyoka, kutjhiwo kunqotjhiswe ku-Eva ngombana batjho wakhohlisa u-Adamu. Abafazi nabo bayazibuyiselela bathi indoda yinja ngombana yase ‘yatla’ isithelo ingazange ibuze. Kazi kutjhiwo u-Adamu-ke njalo.   

b)    uRogers (1996) uthi batjho umpostoli uPowula weTarsus ubegade agandelela khulu bonyana abafazi bazithobe emadodeni wabo.&lt;ref&gt;The troublesome helpmate

Book by Katharine M. Rogers&lt;/ref&gt;

Indaba yokuzithoba kuyabonakala bonyana isuselwa eBhayibhelini ngombana ngitjho nemasikweni wabo boke abantu ephasinapha injalo. Umma ulindeleke bonyana azithobe endodenakhe ngombana indoda iyihloko yomkhaya. Kukhona abayithatha ngommoya omuhle indaba le begodu bayamukele ngokuthula. Kanti nalabo abathotjelwako benza bonyana kube lula ukuthotjelwa. Kukhona-ke ebagugunako indaba le, balikhombe libaba bathi, “Nange ngingakuthobela ungazikhotha!” Khonapho kube ngongaphasi nongaphezulu njengombana sele siphila esikhathini sedemokhrasi nje.

Nokho uJohnson (2015:33) uthi batjho uHove (1999) uhlathulula indaba yakaPowula kuhle kwebeGalatiya 3:28 nakasithi, “AkunamJuda, akunamGrigi, ikhoboka namkha otjhaphulukileko, omduna namkha omsikazi ngombana nimunye noke kuKrestu Jesu.&lt;ref&gt;Hove. R. 1991. ''Equality in Christ: Galatians'' 3:28 ''and the gender dispute'' (p. 17) Wheaton: Crossway. International Center for Research on Women. (2013). US. International Violence Against Women Act. &lt;nowiki&gt;http://www.icrw.org/what-we-do/violence-against-women&lt;/nowiki&gt;. Accessed 11 Feb 2013.&lt;/ref&gt;”Umbono kaJohnson uthi batjho indaba yokuzithoba nokuthotjelwa ibekwe ngendlela elingisa uKrestu nebandla. Ngamye amezwi isiga lesi sokuthoba nokuthotjelwa sifaniswa nangendlela ibandla lithobela ngakho uKrestu, godu noKrestu ngendlela athanda ngakho ibandla (Kwebe-Efesu 5:21-33).

UJohnson (2015:33) ubuye athi batjho uRinck (199) encwadinakhe ethi; “Amadoda Akholwako Ahloye Abomma”&lt;ref&gt;Christian Men who Hate Women: Healing Hurting Relationships

Book by Margaret J. Rinck&lt;/ref&gt;, uthi kunamadoda athileko emphakathini wabakholwako ahlathulula kumbi abe asebenzise butjhulweni ifundiso yeBhayibheli yokuzithoba. Uthi ifundiso okungiyo yokuzithoba ayisihlangothi linye kodwana kuyathotjelwana. Godu ifundiso le igandelela ukuthandana nokuhloniphana, ingasi ukuthotjiswa ngeenkhwepha. Kanti u West (2003) yena umbono wakhe uthi batjho abobaba abahlukumezako bahlukumeza ihlelo elicwengileko lakaZimu begodu isenzo sabo leso sivinyilika esonweni.&lt;ref&gt;'''Theology of the Body Explained: A Commentary on John Paul II's''' &quot;'''Gospel of the Body'''&quot; ... Christopher West makes John Paul II's theology of the body ...&lt;/ref&gt;

c)    UCathrine banoJames (1996:16-27) bona baveza iinkolelo ezine ezisisekelo amakholwa kanengi aziseka ngazo:&lt;ref&gt;https://www.amazon.com/Self-Love-Katherine-James/dp/1524640808&lt;/ref&gt;

1.    UZimu wakubeka bonyana indoda ikhonye bese umfazi uyazithoba

2.    Umfazi mncani kunendoda nje-ke akakwazi ukwenza iinqunto ekhaya

3.    Ukutlhaga kusisekelo samakholwa khulukhulu sabomma

4.    Amakholwa kufanele acolele msinyana, abuyisane nalabo abawahlukumezako.

Kujayelekile bonyana umma nakahlukunyezwako ngekhaya ulindeleke bonyana acolele ubaba nakube ubaba loyo ubonwa umlandu ngezenzo zakhe. Njengombana kubomma khulukhulu abaya esondweni, ikulumo le isuke ibe namandla ngombana kuthiwa, “Angithi uthi ulikholwa! Alo kuba yini ungacoleli? IBhayibheli lithi usilibalele amacala wethu njengombana nathi sibalibalela abanamacala kithi”(Matewu 6:12) khisibe nokho ukuhlukunyezwa khona kuragela phambili. Nakube umma loyo ulila ngokuthi sele kukanengi amlibalela bese kuthiwe kuye, “Angithi neBhayibheli liyatjho bonyana ulibalele umuntu kube ngokubuyelelwe amatjhumi alikhomba nakhomba?” [Matewu 18:21-22]. Khonapho indaba yokuphenduka kwaloyo ohlukumezako yona ayiphathwa.

== Okutjhiwo LiBhayibheli NgoGenesisi 2:18 Nebe-Efesu 5:22 ==
UGenesisi 2:18 uthi, “USomnini uZimu wathi: ‘Akusikuhle bona umuntu ahlale yedwa. Yeke ngizomenzela '''umsizi omfaneleko'''.’”

'''וַיֹּ֙אמֶר֙ יְהוָ֣ה אֱלֹהִ֔ים לֹא־טֹ֛וב הֱיֹ֥ות הָֽאָדָ֖ם לְבַדֹּ֑ו אֶֽעֱשֶׂהּ־לֹּ֥ו עֵ֖זֶר כְּנֶגְדֹּֽו'''׃ [Wayyomer Yahweh Elohim lo towb heyowt ha-Adam lebaddow eseh low ezer kenegdo]&lt;ref&gt;https://en.wikipedia.org/wiki/Hebrew_Bible&lt;/ref&gt;

Leli litjhugululo lesiNdebele lango-2012. Woke amalimi esiwafundako eBhayibhelini alitjhugululo lesiHebheru namkha lesiGirigi. ETestamendeni eliDala ilimi elimsuka siHebheru. Yeke kufanele sibuyele kiso isiHebheru siqale bonyana ikulumo le ithini. Amagama athi, ‘umsizi omfaneleko’ asuselwe kusiHebheru ekulumeni ethi [עזר כנגדו׃] ‘ezer kenegdo’. Ngaphambi kobana siqale ihlathululo yamagama la, kuqakathekile ukuveza bonyana ngokuqalisisa amagama la, akwenziwa imizamo yokuhlaba namkha yokujamelela ihlangothi elithileko. Umnqopho kuveza bona ekhabo lakhona sithini isiHebheru endimeni le.

Igama lokuthoma lithi “ezer” namkha umsizi. NgokwesiHebheru litjho umuntu osiza omunye lokha yena anganamandla wokuzisiza. Umuntu osizako angaba ngonamandla begodu omkhulu kiloyo osizwako namkha kungaba ngomlingani waloyo osizwako ngokwamazinga athileko wepilo. Kufanele sikutjheje-ke lokhu: Akwenzeki bonyana umsizi abe mncani kunosizwako.

Nanyana kungaba ngayiphi indlela kodwana ihlathululo yona itjho bona umsizi wenza umthwalo waloyo osizwako ube lula. Esikhathini esinengi-ke igameli lisetjenziswa ukutjho uSomnini bonyana umsindisi, umsizi, umvikeli, umumenyeli namkha umbhadekeli. Ku-1 Samyeli 7: 12 kuthiwa, “USamyela wathatha ilitje walijamisa phakathi kweMitsipha neTjheni. Walithiya ibizo wathi yi-Ebheni-Ezeri asithi: “Bekube lapha uSomnini usisizile.”  

Igama lesibili lithi khenegdo. NgesiHebheru lingasebenza njengephriphozitjhini litjho ukuthi ngaphambili. Godu lingatjho ukuthi ongafani naye ngobulili namkha ofaneleko. Yeke nasiqala indinyana le ngamanye amezwi ithi:

·       “Ngizomenzela omsizi/umenyeli ozokujama phambi kwakhe.” Siyazi bona umuntu nakwenyelako ujama phambi kwakho ukwenzela bona nanyana yini efuna ukukulimaza ithome ngaye.

·       “Ngizomenzela umsizi ongafani naye ngobulili”

·       “Ngizomenzela umsizi ofaneleko” ngamanye amezwi uzokulingana/uzokukhambisana nesizo afanele amnikele lona.

Incwadi yebe-Efesu 5:22-33 yona ithi, “Bafazi, thobelani amadoda wenu sengathi nithobela iKosi ngombana indoda iyihloko yomfazi, njengombana uKrestu ayihloko yebandla elimzimba wakhe begodu yena aMsindisi walo. Njengombana ibandla limthobela uKrestu, ngokunjalo nabafazi kumele bathobele amadoda wabo kikho koke. Madoda thandani abafazi benu njengombana uKrestu athanda ibandla, wadela ukuphila kwakhe ngebanga lalo. Walicwengisa, walihlanza ngamanzi nangelizwi lakhe begodu waliletha kuye lilibandla elinephazimulo, elinganachaphazi, ukutjhwabana namkha umphambo wananyana yini kodwana licwengile begodu limsulwa. Ngokunjalo namadoda kufanele athande abafazi bawo njengombana athanda imizimba yawo. Othanda umkakhe uzithanda yena ngokwakhe. Akakho owakhe wazonda umzimbakhe kodwana ngiloyo naloyo uyawondla awutlhogomele, njengombana noKrestu asenza ebandleni ngombana sizizitho zomzimbakhe. “Ngalokho-ke indoda izokutjhiya uyise nonina inamathele kumkayo, nje-ke ababili labo babe nyamanye.” Yifihlakalo ekulu le, kodwana ngikhuluma ngoKrestu nebandla. Nokho-ke omunye nomunye wenu kumele athande umkakhe njengombana azithanda yena, nomfazi kumele ahloniphe indodakhe.

Nasiqala eBhayibhelini siyafunyana bonyana uZimu, omnikazi womtjhado, uyithathela phezulu namkha ngokuncama okukhulu indaba yobudlelwana phakathi kwendoda nomfazi kangangobana uyilinganisa nobudlelwana obuphakathi kwakaKrestu nebandla. Lokhu sikubona encwadini yebe-Efesu 5:22. Yeke kuyasibonisa bonyana akukameli ithathwe ngesincele indaba le.  Kuyafuneka-ke bonyana nakudzujulwa indinyana le ingatjhiywa phakathi kodwana kuqalwe indaba yoke lapha ithoma khona bekufike lapha igcina khona. Nasiyifunda kuhle ithi umfazi akathobele indoda yakhe. Lokho akwenze njengalokha ibandla nalithobela uKrestu. Libuye lithi indoda ayithande umkayo. Ithando lelo alibe njengelakaKrestu athanda ngalo ibandla. Umma akaqale bonyana ibandla limthobela njani uKrestu bese naye wenza njalo endodeni yakhe. Indoda ayiqale bona uKrestu ulithanda njani ibandla, naye enze njalo kumkakhe.

Ukrestu akalitlhorisi ibandla, kodwana uyalithanda abe alivikele. Qala incwadi yezEnzo 9:1-4 lapha uKrestu adula khona phasi uSawula ngombani ngombana ahlukumeza ibandla.

Ngemva kobana sele sifumene ihlathululo kaGenesisi 2:18 neyebe-Efesu 5:22 kuyakhanya bonyana kukhona iimponjwana ekudzujulweni kwemitlolo le ukusekela ukuhlukunyezwa kwabomma emendweni. KuGenesisi akukho lapha sifumene khona bonyana umma mncani ebudlelwaneni bomtjhado njengombana kuthatheka emphakathini. ILizwi lakaZimu nabelisithi umma umsizi wakababa azange lithi umma mncani. Siyizwile ihlathululo yesiHebheru mayelana negama elithi umsizi. Kanti nawo amagama athi bazokuba nyamanye atjho bona bamumuntu munye. Alo-ke, kuvelaphi ukobana ngemva sele kuthiwe banyamanye bese kuthiwe omunye mncani omunye mkhulu? Godu ikulumo le ayitjho bona umma akanyaze ubaba angamhloniphi njengombana ingatjho bona ubaba adule namkha atlhorise umma. Nakhe nayibonaphi ihloko yomuntu idulana nomzimba, namkha umzimba uphikisana nehloko? Ihloko isemzimbeni munye, nomzimba unehloko yinye.

Encwadini yebe-Efesu siyafunyana bona ubudlelwano bomtjhado bufaniswa nobudlelwano bakaKrestu nebandla. Kungaba buhlungu nange ubuhle bomuntu bungafaniswa nefarigi. Cabanga sele kuthiwa umuntu lo muhle njengefarigi! Ubudlelwana bakaKrestu nebandla bufaniselwani nobudlelwana bendoda nomfazi nakube indoda ihlukumeza umfazi, nomfazi uhlazisa indoda emendweni?

Kwanga uZimu angazibonakalisa emadodeni ahlukumeza abomma ngendlela efana poro naleyo azibonakalisa ngayo kuSawula obegade ahlukumeza ibandla. Azibonakalise ngokunjalo nakibo abomma abangaphathi kuhle amadoda wabo emendweni. Ngalokho isingathekiso somendo nebandla sizakuba namandla begodu sizwisiseke ngitjho nebantwini abasebenzisa iLizwi lakaZimu butjhilweni ukusekela izenzo ezifana nalezi!

== IMITHOMBOLWAZI ==</text>
      <sha1>3ip4ok9u5vkccf3itfiabmtcg1wubwd</sha1>
    </revision>
  </page>
  <page>
    <title>Amagulo ahlasele inarha yekhethu</title>
    <ns>0</ns>
    <id>968</id>
    <revision>
      <id>5873</id>
      <timestamp>2025-09-30T13:12:11Z</timestamp>
      <contributor>
        <username>Hlalithwa</username>
        <id>996</id>
      </contributor>
      <comment>Izinto ezitjhuguliliweko mabizo wobulwelwe obuhlasele inarha yangekhethu</comment>
      <origin>5873</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2716" sha1="1wyh6yk5bt6kvqq2zdglv04g7x2u7vx" xml:space="preserve">Amagulo ahlasele inarha yekhethu, isitjhaba sekhethu sihlaselwa magulo amatjha qobe minyaka begodu ngamagulo la banengi esele baphekelelwe kiboyisemkhulu ngesibanga sokungatholi itjhejo labodorhodere besikhuwa ngesikhathi, ngomnyaka we-2020 kwaba nokurhagala kwe-Covid 19 ezweni lekhethu, ingogwana le yarhatjheka emazweni pheze kiwo woke akhona ephasini beyafika ezweni leSewula Afrika lapha eyatheleleleka khona ebantwini pheze abangaphezu kwengidi ezintathu, amagulo la afaka hlangana ikholera, kanye namanye angakabalwa.&lt;ref&gt;[https://www.sciencedirect.com/science/article/pii/S0738081X20302418 Pandemics throughout the centuries - ScienceDirect]&lt;/ref&gt;

== I-Covid 19 ==
[[Isimumathi:SARS-CoV-2 without background.png|thumb|Itshwayo legongwana ye-Covid19]]
i-Covid 19 mkhuhlani onamandla othelelanako, ngomnyaka we-2020 ngoTjhirhweni ubulwelobu barhatjheka ephasini mazombe, laba ebegade batheleleke ngobulwelobu abanye babo bahlongakala kanti abanye babo basinda, bekunemigomo nemibandela abantu ebekufuze bayilandele ukuze bavikeleke begodu namathuba wokuthi batheleleke ngengogwana abe manqani imigomo nemibandela le beyifaka ukugeza izandla njalo ngaphambi kwemizuzu emihlanu, uhlale ugcoke isifonyo, nawuzizwa ungakaphili kuhle uye emtholapilo nanyana esibhedlela esiseduze uyokutjhegwa bona awukatheleleki nge Covid-19 koke lokhu kwasiza abantu abanengi.&lt;ref&gt;[https://www.sciencenewstoday.org/what-is-covid-19-the-story-of-a-virus-that-changed-the-world What is COVID-19? The Story of a Virus That Changed the World]&lt;/ref&gt;

== Ikholera ==
Ikholera ibangwa kungahlanzeki kwamanzi aselwa babantu, ubulwelwe lobu burhatjheka khulu ngamanzi nokudla esikudlako, Lokha nayingenako emzimbeni, ibhaktheriya inamathela emabodeni wamathumbu amancani okurholela ekurhudeni okukhulu nokuphelelwa mamanzi emzimbeni, abantu abatheleleke ngekholera bangalatjhwa ngesisombululo sokubuyisela amanzi emlonyeni, Amacala amakhulu atlhoga ukufakwa amanzi ngemithambo, ekusisombululo sokubuyisela amanzi emlonyeni kanye nokusetjhenziswa kwama-anthibhayothikhi. &lt;ref&gt;[https://onlinelibrary.wiley.com/doi/abs/10.1128/9781555818364.ch15 Cholera: Pathophysiology, Clinical Features, and Treatment - Vibrio cholerae and Cholera - Wiley Online Library]&lt;/ref&gt;

=== Ikholera eSewula Afrika ===
ISewula Afrika sele ihlangabezana nokuqubuka kwekholera kusukela ngezi 01 kuMhlolanja 2023, begodu kubikwe inani elikhulu labantu abafako eendaweni ezihlukahlukeneko, Ukuqubuka lokhu kukholelwa bona kwavela ebantwini ebegade bavela enarheni yange-Malawi, lapho bekuvamise khona ukutholakala abantu abanekholera.&lt;ref&gt;[https://pmc.ncbi.nlm.nih.gov/articles/PMC10370840/ Imported Cholera Cases, South Africa, 2023 - PMC]&lt;/ref&gt;

== Isilungelelo ==</text>
      <sha1>1wyh6yk5bt6kvqq2zdglv04g7x2u7vx</sha1>
    </revision>
    <revision>
      <id>5875</id>
      <parentid>5873</parentid>
      <timestamp>2025-09-30T13:16:10Z</timestamp>
      <contributor>
        <username>Hlalithwa</username>
        <id>996</id>
      </contributor>
      <comment>Isilululwazi</comment>
      <origin>5875</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2716" sha1="m48xyfvn35opr3ds5b2dtbnnmsszs1a" xml:space="preserve">Amagulo ahlasele inarha yekhethu, isitjhaba sekhethu sihlaselwa magulo amatjha qobe minyaka begodu ngamagulo la banengi esele baphekelelwe kiboyisemkhulu ngesibanga sokungatholi itjhejo labodorhodere besikhuwa ngesikhathi, ngomnyaka we-2020 kwaba nokurhagala kwe-Covid 19 ezweni lekhethu, ingogwana le yarhatjheka emazweni pheze kiwo woke akhona ephasini beyafika ezweni leSewula Afrika lapha eyatheleleleka khona ebantwini pheze abangaphezu kwengidi ezintathu, amagulo la afaka hlangana ikholera, kanye namanye angakabalwa.&lt;ref&gt;[https://www.sciencedirect.com/science/article/pii/S0738081X20302418 Pandemics throughout the centuries - ScienceDirect]&lt;/ref&gt;

== I-Covid 19 ==
[[Isimumathi:SARS-CoV-2 without background.png|thumb|Itshwayo legongwana ye-Covid19]]
i-Covid 19 mkhuhlani onamandla othelelanako, ngomnyaka we-2020 ngoTjhirhweni ubulwelobu barhatjheka ephasini mazombe, laba ebegade batheleleke ngobulwelobu abanye babo bahlongakala kanti abanye babo basinda, bekunemigomo nemibandela abantu ebekufuze bayilandele ukuze bavikeleke begodu namathuba wokuthi batheleleke ngengogwana abe manqani imigomo nemibandela le beyifaka ukugeza izandla njalo ngaphambi kwemizuzu emihlanu, uhlale ugcoke isifonyo, nawuzizwa ungakaphili kuhle uye emtholapilo nanyana esibhedlela esiseduze uyokutjhegwa bona awukatheleleki nge Covid-19 koke lokhu kwasiza abantu abanengi.&lt;ref&gt;[https://www.sciencenewstoday.org/what-is-covid-19-the-story-of-a-virus-that-changed-the-world What is COVID-19? The Story of a Virus That Changed the World]&lt;/ref&gt;

== Ikholera ==
Ikholera ibangwa kungahlanzeki kwamanzi aselwa babantu, ubulwelwe lobu burhatjheka khulu ngamanzi nokudla esikudlako, Lokha nayingenako emzimbeni, ibhaktheriya inamathela emabodeni wamathumbu amancani okurholela ekurhudeni okukhulu nokuphelelwa mamanzi emzimbeni, abantu abatheleleke ngekholera bangalatjhwa ngesisombululo sokubuyisela amanzi emlonyeni, Amacala amakhulu atlhoga ukufakwa amanzi ngemithambo, ekusisombululo sokubuyisela amanzi emlonyeni kanye nokusetjhenziswa kwama-anthibhayothikhi. &lt;ref&gt;[https://onlinelibrary.wiley.com/doi/abs/10.1128/9781555818364.ch15 Cholera: Pathophysiology, Clinical Features, and Treatment - Vibrio cholerae and Cholera - Wiley Online Library]&lt;/ref&gt;

=== Ikholera eSewula Afrika ===
ISewula Afrika sele ihlangabezana nokuqubuka kwekholera kusukela ngezi 01 kuMhlolanja 2023, begodu kubikwe inani elikhulu labantu abafako eendaweni ezihlukahlukeneko, Ukuqubuka lokhu kukholelwa bona kwavela ebantwini ebegade bavela enarheni yange-Malawi, lapho bekuvamise khona ukutholakala abantu abanekholera.&lt;ref&gt;[https://pmc.ncbi.nlm.nih.gov/articles/PMC10370840/ Imported Cholera Cases, South Africa, 2023 - PMC]&lt;/ref&gt;

== Isilululwazi ==</text>
      <sha1>m48xyfvn35opr3ds5b2dtbnnmsszs1a</sha1>
    </revision>
  </page>
  <page>
    <title>Ubumbi bokusebenzisa i AI</title>
    <ns>0</ns>
    <id>969</id>
    <revision>
      <id>5881</id>
      <timestamp>2025-09-30T13:29:11Z</timestamp>
      <contributor>
        <username>Diamond096</username>
        <id>997</id>
      </contributor>
      <comment>Created page with &quot;I-AI ziinkambiso zemitjhini ngqondo  ezikghona ukwenza imisebenzi enzima efaka hlangana nokulungisa iimphoso, umsebenzi wesikolo, ukwenza iinqumo kanye nokusekela izinto. Emalangeni wanamhlanje abantu abanengi basebenzisa i-AI ukwenza izinto ezinengi khulu kokuthi abasakghoni ukuzenzela bona ngokwabo nanoma izinto lezo abazenzako zingatlhogi bona umuntu loyo asebenzise i-[[AI]].&lt;ref&gt;https://link.springer.com/chapter/10.1007/978-3-031-21448-6_2&lt;/ref&gt; Izinto abantu abazise...&quot;</comment>
      <origin>5881</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1805" sha1="pt3voufgb5vdovgooe5wpirddq3dd9t" xml:space="preserve">I-AI ziinkambiso zemitjhini ngqondo  ezikghona ukwenza imisebenzi enzima efaka hlangana nokulungisa iimphoso, umsebenzi wesikolo, ukwenza iinqumo kanye nokusekela izinto. Emalangeni wanamhlanje abantu abanengi basebenzisa i-AI ukwenza izinto ezinengi khulu kokuthi abasakghoni ukuzenzela bona ngokwabo nanoma izinto lezo abazenzako zingatlhogi bona umuntu loyo asebenzise i-[[AI]].&lt;ref&gt;https://link.springer.com/chapter/10.1007/978-3-031-21448-6_2&lt;/ref&gt; Izinto abantu abazisebenzisela i -AI abangakghona ukuzenza ngaphandle kwe AI zifaka hlangana nokuthi abantu bangasafuni ukuya kibodorhodere bomkhumbulo kodwana batlolele i-AI imirarwabo. 

== Ubumbi bayo  ==
Ukusetjenziswa kwe-AI emelangeni la kurhagele khulu ephasini mazombe. Abantu abanengi abasakghoni ukwenza izinto ngaphambi kobana babuze i-AI, khulukhulu abafundi. Bathi nabanikelwa umsebenzi wesikolo into yokuthoma kube kuthatha umsebenzi loyo ngendlela ungakho bawufake ku-AI bese ibaphundelele, abanye bona abasaqali nokobana i-AI leyo ibanikele iimpendulo zamambala nanyana ezingakalungi abanandaba ngombana bayayithemba. Kuyinto embi khulu le ngombana yenza abafundi bangasakghoni ukuziqabangela bona ezintweni ezinengi. Lokhu kwenza abafundi baqabange bona nanoma bakghona ukwenza umsebenzi wesikolo bazibone kwangathi angeze bakghone ukuwenza babodwa.&lt;ref&gt;WyWmemNe8hyG6vgiQoPO-1723214664.pdf&lt;/ref&gt; 

Abanye abantu abanganabo abantu abangakhuluma nabo emaphilwenabo nanyana abanganayo imali yokuya kibodorhodere bomkhumbulo bayisebenzisela ukucoca nayo ngemiraro nanyana iintjhijilo abanazo kunokuthi baye kibodorhodere bomkhumbulo nanoma ibasiza njalo kodwana lokho akusiyinto elungileko ngombana kokuthoma i-AI ayisimumuntu begodu ayinamizwa

== Isilululwazi ==
[[Mkhakha:AI]]
[[Mkhakha:Abafundi]]
[[Mkhakha:Ukusizeka ngookomkhumbulo]]</text>
      <sha1>pt3voufgb5vdovgooe5wpirddq3dd9t</sha1>
    </revision>
    <revision>
      <id>5883</id>
      <parentid>5881</parentid>
      <timestamp>2025-09-30T13:30:12Z</timestamp>
      <contributor>
        <username>Diamond096</username>
        <id>997</id>
      </contributor>
      <origin>5883</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1819" sha1="7p18zbtr7wmfz3ft7c57kqufyd91l76" xml:space="preserve">I-AI ziinkambiso zemitjhini ngqondo  ezikghona ukwenza imisebenzi enzima efaka hlangana nokulungisa iimphoso, umsebenzi wesikolo, ukwenza iinqumo kanye nokusekela izinto. Emalangeni wanamhlanje abantu abanengi basebenzisa i-AI ukwenza izinto ezinengi khulu kokuthi abasakghoni ukuzenzela bona ngokwabo nanoma izinto lezo abazenzako zingatlhogi bona umuntu loyo asebenzise i-[[AI]].&lt;ref&gt;https://link.springer.com/chapter/10.1007/978-3-031-21448-6_2&lt;/ref&gt; Izinto abantu abazisebenzisela i -AI abangakghona ukuzenza ngaphandle kwe AI zifaka hlangana nokuthi abantu bangasafuni ukuya kibodorhodere bomkhumbulo kodwana batlolele i-AI imirarwabo. 

== Ubumbi bayo  ==
Ukusetjenziswa kwe-AI emelangeni la kurhagele khulu ephasini mazombe. Abantu abanengi abasakghoni ukwenza izinto ngaphambi kobana babuze i-AI, khulukhulu abafundi. Bathi nabanikelwa umsebenzi wesikolo into yokuthoma kube kuthatha umsebenzi loyo ngendlela ungakho bawufake ku-AI bese ibaphundelele, abanye bona abasaqali nokobana i-AI leyo ibanikele iimpendulo zamambala nanyana ezingakalungi abanandaba ngombana bayayithemba. Kuyinto embi khulu le ngombana yenza abafundi bangasakghoni ukuziqabangela bona ezintweni ezinengi. Lokhu kwenza abafundi baqabange bona nanoma bakghona ukwenza umsebenzi wesikolo bazibone kwangathi angeze bakghone ukuwenza babodwa.&lt;ref&gt;WyWmemNe8hyG6vgiQoPO-1723214664.pdf&lt;/ref&gt; 

Abanye abantu abanganabo abantu abangakhuluma nabo emaphilwenabo nanyana abanganayo imali yokuya kibodorhodere bomkhumbulo bayisebenzisela ukucoca nayo ngemiraro nanyana iintjhijilo abanazo kunokuthi baye kibodorhodere bomkhumbulo nanoma ibasiza njalo kodwana lokho akusiyinto elungileko ngombana kokuthoma i-AI ayisimumuntu begodu ayinamizwa

== Isilululwazi ==
[[Mkhakha:AI]]
[[Mkhakha:Abafundi]]
&lt;references /&gt;
[[Mkhakha:Ukusizeka ngokomkhumbulo]]</text>
      <sha1>7p18zbtr7wmfz3ft7c57kqufyd91l76</sha1>
    </revision>
    <revision>
      <id>5884</id>
      <parentid>5883</parentid>
      <timestamp>2025-09-30T13:35:35Z</timestamp>
      <contributor>
        <username>Diamond096</username>
        <id>997</id>
      </contributor>
      <minor />
      <origin>5884</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1825" sha1="2nj2p1qyf594cvprogt22y1etgmraqb" xml:space="preserve">I-'''AI''' ziinkambiso zemitjhini ngqondo  ezikghona ukwenza imisebenzi enzima efaka hlangana nokulungisa iimphoso, umsebenzi wesikolo, ukwenza iinqumo kanye nokusekela izinto. Emalangeni wanamhlanje abantu abanengi basebenzisa i-AI ukwenza izinto ezinengi khulu kokuthi abasakghoni ukuzenzela bona ngokwabo nanoma izinto lezo abazenzako zingatlhogi bona umuntu loyo asebenzise i-[[AI]].&lt;ref&gt;https://link.springer.com/chapter/10.1007/978-3-031-21448-6_2&lt;/ref&gt; Izinto abantu abazisebenzisela i -AI abangakghona ukuzenza ngaphandle kwe AI zifaka hlangana nokuthi abantu bangasafuni ukuya kibodorhodere bomkhumbulo kodwana batlolele i-AI imirarwabo. 

== Ubumbi bayo  ==
Ukusetjenziswa kwe-AI emelangeni la kurhagele khulu ephasini mazombe. Abantu abanengi abasakghoni ukwenza izinto ngaphambi kobana babuze i-AI, khulukhulu abafundi. Bathi nabanikelwa umsebenzi wesikolo into yokuthoma kube kuthatha umsebenzi loyo ngendlela ungakho bawufake ku-AI bese ibaphundelele, abanye bona abasaqali nokobana i-AI leyo ibanikele iimpendulo zamambala nanyana ezingakalungi abanandaba ngombana bayayithemba. Kuyinto embi khulu le ngombana yenza abafundi bangasakghoni ukuziqabangela bona ezintweni ezinengi. Lokhu kwenza abafundi baqabange bona nanoma bakghona ukwenza umsebenzi wesikolo bazibone kwangathi angeze bakghone ukuwenza babodwa.&lt;ref&gt;WyWmemNe8hyG6vgiQoPO-1723214664.pdf&lt;/ref&gt; 

Abanye abantu abanganabo abantu abangakhuluma nabo emaphilwenabo nanyana abanganayo imali yokuya kibodorhodere bomkhumbulo bayisebenzisela ukucoca nayo ngemiraro nanyana iintjhijilo abanazo kunokuthi baye kibodorhodere bomkhumbulo nanoma ibasiza njalo kodwana lokho akusiyinto elungileko ngombana kokuthoma i-AI ayisimumuntu begodu ayinamizwa

== Isilululwazi ==
[[Mkhakha:AI]]
[[Mkhakha:Abafundi]]
&lt;references /&gt;
[[Mkhakha:Ukusizeka ngokomkhumbulo]]</text>
      <sha1>2nj2p1qyf594cvprogt22y1etgmraqb</sha1>
    </revision>
  </page>
  <page>
    <title>Ubuhle besivande ngethwasahlobo</title>
    <ns>0</ns>
    <id>970</id>
    <revision>
      <id>5882</id>
      <timestamp>2025-09-30T13:29:14Z</timestamp>
      <contributor>
        <username>Tozi1153</username>
        <id>1030</id>
      </contributor>
      <comment>added reference</comment>
      <origin>5882</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1831" sha1="1xw389fruriki28w8hlzja708ren4tn" xml:space="preserve">'''Kusikhathi somyaka''' lapho amathuthumbo kanye neentjalo zikhula bezihluma khona. Ngemva kwelothe nobusika esibuya kibo sithola imibala eyahlukahlukeneko. Engafaka hlangana imibala, esarulani, ehlaza satjani, kanye neminye imibala eminengi. Abantu bayathaba ngethwasahlobo khulukhulu labo abatjalileko, ngombana bayazi bona bazokuvuna. Sithola imirorho,ihlaza satjani begodu ibonakala bona sele ilungele ukudliwa. Sithola nomuthi wamaperegisi sele ukhipha wawo amathuthumbo amahle nakarisako. Iinyanga lapho sithola khona ithwasahlobo kuba yinyanga kaKhukhulamungu, kaSewula, kanye nenyanga kaSinyikhaba.
[[Isimumathi:Ubuhle besivande ngethwasahlobo.jpg|thumb]]

== Iintjalo ezitholakala ethwasahlobo ==
Zikhona ke iintjalo lezo esithola bona ziba khona ethwasahlobo ,ezifaka hlangana umrorho, ama-habhula nokhunye okunengi. Abantu abatjalileko akutlhogi bonyana bathenge, bavele batjhinge ngesivandeni. Kuqakathekile bonyana sidle imirorho ukuze imizimba yethu ihlale iphilile ngaso soke isikhathi.&lt;ref&gt;https://www.mdpi.com/2076-3417/11/19/8951&lt;/ref&gt; Kungalokho ke kufanele sizifundise ukutjala imirorho yethu, senzele bona songe imali begodu sakhe namathuba wemisebenzi. Kuyinto ehle bona sizikhakhazise ngeeentjalo zethu, lokho singakwenza ngokuqinisekisa bona ngaso soke isikhathi sitlhogomelqa iintjalo zethu, sithelelele besihlwengise lapho sitjale khona.&lt;ref&gt;https://www.sciencedirect.com/science/article/pii/S0006320716311405&lt;/ref&gt; Abanye abantu bakholelwa ekutheni ithwasahlobo liletha ipilo etja, okutjho bona liletha umkhanyo emaphilweni wethu. Amakari atjhugulula imibala yayo isibonelo ngingatjho umrorho wona ubahlaza satjani.Ukubona amakari wemirorho akhula kusikhumbuza ngobuhle benarha nemvelo okutjengisa ukuthula.

== Isilululwazi ==
[[Mkhakha:Amakari wemirorho]]
[[Mkhakha:Imirorho]]
[[Mkhakha:Ithwasahlobo]]</text>
      <sha1>1xw389fruriki28w8hlzja708ren4tn</sha1>
    </revision>
    <revision>
      <id>5954</id>
      <parentid>5882</parentid>
      <timestamp>2025-11-08T11:55:34Z</timestamp>
      <contributor>
        <username>Hlalithwa</username>
        <id>996</id>
      </contributor>
      <minor />
      <comment>Spelling errors and grammar</comment>
      <origin>5954</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1828" sha1="mgf0ihq5e0zio2qojtzsae1551qi1q3" xml:space="preserve">'''Kusikhathi somyaka''' lapho amathuthumbo kanye neentjalo zikhula bezihluma khona. Ngemva kwelothe nobusika esibuya kibo sithola imibala eyahlukahlukeneko. Engafaka hlangana imibala esarulani, ehlaza satjani, kanye neminye imibala eminengi. Abantu bayathaba ngethwasahlobo khulukhulu labo abatjalileko, ngombana bayazi bona bazokuvuna. Sithola imirorho ihlaza satjani begodu ibonakala bona sele ilungele ukudliwa. Sithola nomuthi wamaperegisi sele ukhipha wawo amathuthumbo amahle nakarisako. Iinyanga lapho sithola khona ithwasahlobo kuba yinyanga kaKhukhulamungu, kaSewula, kanye nenyanga kaSinyikhaba.
[[Isimumathi:Ubuhle besivande ngethwasahlobo.jpg|thumb]]

== Iintjalo ezitholakala ethwasahlobo ==
Zikhona ke iintjalo lezo esithola bona ziba khona ethwasahlobo ,ezifaka hlangana umrorho, ama-habhula nokhunye okunengi. Abantu abatjalileko akutlhogi bonyana bathenge, bavele batjhinge ngesivandeni. Kuqakathekile bonyana sidle imirorho ukuze imizimba yethu ihlale iphilile ngaso soke isikhathi.&lt;ref&gt;https://www.mdpi.com/2076-3417/11/19/8951&lt;/ref&gt; Kungalokho ke kufanele sizifundise ukutjala imirorho yethu, senzele bona songe imali begodu sakhe namathuba wemisebenzi. Kuyinto ehle bona sizikhakhazise ngeentjalo zethu, lokho singakwenza ngokuqinisekisa bona ngaso soke isikhathi sitlhogomela iintjalo zethu, sithelelele besihlwengise lapho sitjale khona.&lt;ref&gt;https://www.sciencedirect.com/science/article/pii/S0006320716311405&lt;/ref&gt; Abanye abantu bakholelwa ekutheni ithwasahlobo liletha ipilo etja, okutjho bona liletha umkhanyo emaphilweni wethu. Amakari atjhugulula imibala yayo isibonelo ngingatjho umrorho wona ubahlaza satjani.Ukubona amakari wemirorho akhula kusikhumbuza ngobuhle benarha nemvelo okutjengisa ukuthula.

== Isilululwazi ==
[[Mkhakha:Amakari wemirorho]]
[[Mkhakha:Imirorho]]
[[Mkhakha:Ithwasahlobo]]</text>
      <sha1>mgf0ihq5e0zio2qojtzsae1551qi1q3</sha1>
    </revision>
  </page>
  <page>
    <title>Isintu Namasiko</title>
    <ns>0</ns>
    <id>971</id>
    <revision>
      <id>5893</id>
      <timestamp>2025-10-03T12:11:54Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>New article</comment>
      <origin>5893</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4164" sha1="q50iw1j1g3drjw9vujxbxesso938yiy" xml:space="preserve">[[Isimumathi:AmaNdebele.jpg|thumb|IsiNdebele|478x478px]]
Esinye nesinye isitjhaba ephasini sinendlela yaso yokwenza izinto. Sinemikghwa, sinamasiko nesikopilo. Amanye namanye amasiko abe nendlela yawo yokuwenza engafani nenye. Indlela le ithoma ngokubonakala emakhaya, emphakathini, esitjhabeni nesizweni. Imikghwa yakha amasiko, amasiko akha isintu.&lt;ref name=&quot;:0&quot;&gt;The Brittanica Dictionary (2025) ''Tradition.'' Retrieved  from:https://www.britannica.com/dictionary/tradition Retrieved from: 30/09/2025.&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;Fundamentals (2025) ''Cultural Habits.'' Retrieved from: https://sustainability-directory.com/fundamentals/cultural-habits-fundamentals/ Retrieved on 30//09/2025.&lt;/ref&gt; 

== Isintu ==
Ngokwehlathululo yephasi loke, isintu (''tradition'') yindlela yokucabanga, yokuziphatha neyokwenza imikghwa, enjengamasiko, amariyadlhana, indlela yokumbatha, yokudla neyobukghwari ebeyenziwa ziintjhaba zabantu abanzima, emindenini, emphakathini, nesitjhabeni esele inesikhathi eside ikhona.&lt;ref name=&quot;:0&quot; /&gt; Ngokwehlathululo yesi-Afrika isintu, nendlela yokuziphatha, yokucabanga neyokuphatha abanye abantu ngendlela enobuntu (''humanity''). Isaga esithi, '''&quot;umuntu mumuntu ngabantu&quot;''' mgogodlha wefundiso yesintu. &quot;'''Ungilokho ongikho ngebanga lokuthi abanye bangilokho abangikho'''&quot;.&lt;ref&gt;Herbert Moyo (October 14, 2022) ''Isintu.'' Retrieved from: https://globalcritical.barefield.ua.edu/self-and-persistence/isintu/ Retrieved  on 30/09/25.&lt;/ref&gt; Bubuntu-ke lobo. Ifundiso le kade khulu ikhona. Yeke isintu sibonakala ngemicabango, ngekolelo, ngemizwa nangezenzo ezinobuntu - mimikghwa, isikopilo, amasiko namariyadlhana.&lt;ref&gt;Desmond Tutu (2013), ''Who are we: Human Uniqueness and African Spirit of Ubuntu'' (Video)''.'' Retrieved from: https://www.youtube.com/watch?v=0wZtfqZ271w#t=162 Retreived on 30/09/25.&lt;/ref&gt;

== Amasiko ==
[[Isimumathi:Mapoch.- Femmes Ndebele in Cultural Village (1).jpg|thumb|Indlela yokumbatha yamaNdebele]]
Ayini-ke amasiko? Amasiko yindlela yokwenza izinto yendabuko eyenziwa sitjhaba esithileko ekolweni, embusweni nekuhlalisaneni kwabantu. Indlela le kade yenziwa begodu idluliselwa esizukulwaneni esilandelako ngokufundiswa ngomlomo nangezenzo. Kungaba yindlela yokwenza izenzo ezithileko zendabuko zendlela yokuziphatha, indlela yokuhlalisana nabanye, indlela yokumbatha, indlela yokudla, indlela yokubusa, indlela yokurarulula imiraro, indlela yokuraga amariyadlhana wekolo yesintu namkha yendabuko. Ngamanye amagama umukghwa othileko nawusolo ubuyelelwa iinkhathi ezinengana mumuntu, mndeni, mphakathi nesitjhaba, ugcina sele ulisiko.&lt;ref&gt;Gibbon Rangel (2022) ''Characteristics of Culture, Customs and Traditions,'' from Walsh and Medical Media Websie. Retrieved from: https://www.walshmedicalmedia.com/open-access/characteristics-of-culture-customs-and-traditions-114614.html Retrieved on 30/09/2025.&lt;/ref&gt; 

Aqakatheke kangangani amasiko ebantwini? Amasiko enza umuntu azikhakhazise ngendabuko yakhe. Umuntu nakazikhakhazisa ngendabukwakhe uzozikhakhazisa ngaye ngokwakhe. Ukuzikhakhazisa kumenza azithembe yena ngokwakhe begodu azizwe amumuntu. Amasiko anendlela yokuziphatha neyokuziphatha emukelekako emphakathini nesitjhabeni. Lokha umuntu nakaziphatha kuhle abantu bayamthanda. Ukuthandwa babantu kukwenza uzizwe uhloniphekile unesithunzi, uzizwe unendima eqakathekileko oyidlalako emphakathini othileko. Nanyana kunamasiko angaba nomphumela omumbi emntwini, amasiko amahle angaletha imiphumela emihle.&lt;ref&gt;Frank Sonnenberg (2025) ''7 Reasons Why Traditions Are So Important.'' Retrieved from: https://www.franksonnenbergonline.com/blog/7-reasons-why-traditions-are-so-important/ Retrieved on 30/05/25.&lt;/ref&gt; Ibuthelelo lamasiko ngilo elakha isintu.

== Imikghwa ==
Njengomana kutjhiwo ngehla, imikghwa yakha isiko, isiko lakha isintu. Alo, iyini imikghwa? Imikghwa zizenzo abantu abajayele ukuzenza. Kunemikghwa yokudla, yokukhuluma, neyokwenza, imikghwa yokuziphatha, imikghwa yokuphatha abanye, imigkhwa yokumbatha, yokubukghwari neyombhino. Imikghwa le nayisolo yenziwa mumuntu, mphakathi namkha isitjhaba, bese imukeleke ebantwini igcina sele ilisiko.&lt;ref name=&quot;:1&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>q50iw1j1g3drjw9vujxbxesso938yiy</sha1>
    </revision>
    <revision>
      <id>5895</id>
      <parentid>5893</parentid>
      <timestamp>2025-10-03T12:21:36Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>edited</comment>
      <origin>5895</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4199" sha1="pmx3gm1qklqvjp3mb4zvnmrrsgyzpgx" xml:space="preserve">[[Isimumathi:AmaNdebele.jpg|thumb|IsiNdebele|478x478px]]
'''Esinye nesinye''' isitjhaba ephasini sinendlela yaso yokwenza izinto. Sinemikghwa, sinamasiko nesikopilo. Amanye namanye amasiko abe nendlela yawo yokuwenza engafani nenye. Indlela le ithoma ngokubonakala emakhaya, emphakathini, esitjhabeni nesizweni. Imikghwa yakha amasiko, amasiko akha isintu.&lt;ref name=&quot;:0&quot;&gt;The Brittanica Dictionary (2025) ''Tradition.'' Retrieved  from:https://www.britannica.com/dictionary/tradition Retrieved from: 30/09/2025.&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;Fundamentals (2025) ''Cultural Habits.'' Retrieved from: https://sustainability-directory.com/fundamentals/cultural-habits-fundamentals/ Retrieved on 30//09/2025.&lt;/ref&gt; 

== Isintu ==
Ngokwehlathululo yephasi loke, isintu (''tradition'') yindlela yokucabanga, yokuziphatha neyokwenza imikghwa, enjengamasiko, amariyadlhana, indlela yokumbatha, yokudla neyobukghwari ebeyenziwa ziintjhaba zabantu abanzima ekadeni nanamhlanjesi, emindenini, emphakathini, nesitjhabeni esele inesikhathi eside ikhona.&lt;ref name=&quot;:0&quot; /&gt; Ngokwehlathululo yesi-Afrika, isintu yindlela yokuziphatha, yokucabanga neyokuphatha abanye abantu ngendlela enobuntu (''humanity''). Isaga esithi, '''&quot;umuntu mumuntu ngabantu&quot;''' mgogodlha wefundiso yesintu. &quot;'''Ungilokho ongikho ngebanga lokuthi abanye bangilokho abangikho'''&quot;.&lt;ref&gt;Herbert Moyo (October 14, 2022) ''Isintu.'' Retrieved from: https://globalcritical.barefield.ua.edu/self-and-persistence/isintu/ Retrieved  on 30/09/25.&lt;/ref&gt; Bubuntu-ke lobo. Ifundiso le kade khulu ikhona. Yeke isintu sibonakala ngemicabango, ngekolelo, ngemizwa nangezenzo ezinobuntu - mimikghwa, isikopilo, amasiko namariyadlhana.&lt;ref&gt;Desmond Tutu (2013), ''Who are we: Human Uniqueness and African Spirit of Ubuntu'' (Video)''.'' Retrieved from: https://www.youtube.com/watch?v=0wZtfqZ271w#t=162 Retreived on 30/09/25.&lt;/ref&gt;

== Amasiko ==
[[Isimumathi:Mapoch.- Femmes Ndebele in Cultural Village (1).jpg|thumb|Indlela yokumbatha yamaNdebele]]
Ayini-ke amasiko? Amasiko yindlela yokwenza izinto yendabuko eyenziwa sitjhaba esithileko ekolweni, embusweni nekuhlalisaneni kwabantu. Indlela le kade yenziwa begodu idluliselwa esizukulwaneni esilandelako ngokufundiswa ngomlomo nangezenzo. Kungaba yindlela yokwenza izenzo ezithileko zendabuko zendlela yokuziphatha, indlela yokuhlalisana nabanye, indlela yokumbatha, indlela yokudla, indlela yokubusa, indlela yokurarulula imiraro, indlela yokuraga amariyadlhana wekolo yesintu namkha yendabuko. Ngamanye amagama umukghwa othileko nawusolo ubuyelelwa iinkhathi ezinengana mumuntu, mndeni, mphakathi nesitjhaba, ugcina sele ulisiko.&lt;ref&gt;Gibbon Rangel (2022) ''Characteristics of Culture, Customs and Traditions,'' from Walsh and Medical Media Websie. Retrieved from: https://www.walshmedicalmedia.com/open-access/characteristics-of-culture-customs-and-traditions-114614.html Retrieved on 30/09/2025.&lt;/ref&gt; 

Aqakatheke kangangani amasiko ebantwini? Amasiko enza umuntu azikhakhazise ngendabuko yakhe. Umuntu nakazikhakhazisa ngendabukwakhe uzozikhakhazisa ngaye ngokwakhe. Ukuzikhakhazisa kumenza azithembe yena ngokwakhe begodu azizwe amumuntu. Amasiko anendlela yokuziphatha neyokuphatha abanye emukelekako emphakathini nesitjhabeni. Lokha umuntu nakaziphatha kuhle abantu bayamthanda. Ukuthandwa babantu kukwenza uzizwe uhloniphekile unesithunzi, uzizwe unendima eqakathekileko oyidlalako emphakathini othileko. Nanyana kunamasiko angaba nomphumela omumbi emuntwini, amasiko amahle angaletha imiphumela emihle.&lt;ref&gt;Frank Sonnenberg (2025) ''7 Reasons Why Traditions Are So Important.'' Retrieved from: https://www.franksonnenbergonline.com/blog/7-reasons-why-traditions-are-so-important/ Retrieved on 30/05/25.&lt;/ref&gt; Ibuthelelo lamasiko ngilo elakha isintu.

== Imikghwa ==
Njengomana kutjhiwo ngehla, imikghwa yakha isiko, isiko lakha isintu. Alo, iyini imikghwa? Imikghwa zizenzo abantu abajayele ukuzenza. Kunemikghwa yokudla, yokukhuluma, neyokwenza, imikghwa yokuziphatha, imikghwa yokuphatha abanye, imigkhwa yokumbatha, yokubukghwari neyombhino. Imikghwa le nayisolo yenziwa mumuntu, mphakathi namkha isitjhaba, bese imukeleke ebantwini igcina sele ilisiko.&lt;ref name=&quot;:1&quot; /&gt; 

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>pmx3gm1qklqvjp3mb4zvnmrrsgyzpgx</sha1>
    </revision>
  </page>
  <page>
    <title>INyanga YamaGugu</title>
    <ns>0</ns>
    <id>972</id>
    <revision>
      <id>5894</id>
      <timestamp>2025-10-03T12:15:45Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>New article</comment>
      <origin>5894</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4268" sha1="htqezad6885mqtnszh3nvio8hpddok8" xml:space="preserve">[[Isimumathi:Ndebele Architecture.jpg|thumb|392x392px|Indlu yesiNdebele]]
'''Qobe mnyaka,''' inyanga kaKhukhulamungu yinyanga yokugidinga amagugu namasiko wesintu eSewula Afrika. Ilanga lamaGugu elingomhla ka-24 kuKhukhulamungu, ligidinga amagugu wesintu anjengamasiko, ubukghwari, nokuhlukahluka kwamasiko wendabuko eentjhabeni zeSewula Afrika. 

Asigidingi ukuhlukahluka kwamaSewula Afrika kwaphela, kodwana nokuhlukahluka kwamasiko wephasi loke, ama-Afrika, ama-Asia, ama-Yurobhu namanye amakhontinenti, ikani nje nakanamasiko nesintu sabo esihlukahlukeneko. Lokho kubonakala ngokuthi kuhlelwe izenzakalo ezizokutjengisa ukuhlukahluka kwamagugu wamasiko nobukghwari, njengokuthi umuntu nomuntu ambathe isikhabo, nokuhlelwa kwesenzakalo esinombhino wesitjhaba ngasinye kunye nokukhangiswa kobukghwari obenziwa malunga wesitjhaba ngasinye.&lt;ref&gt;Department of Sport, Arts, and Culture (2023) ''Heritage Month - September.'' Retreived from: https://www.dsac.gov.za/Heritage-Month-2023. Retrieved on 30/09/2025.&lt;/ref&gt; 

== Umlando Wenyanga Yamagugu ==
Kuhlekuhle, ilanga langomhla ka-24 kuKhukhulamungu bekuliLanga likaShaka. Ilangeli beligidinga ukukhunjulwa kweKosi uShaka njengombana adlala indima ekulu yokuhlanganisa izizwe zabeNguni endaweni namhlanjesi ebizwa bona kuKwaZulu Natal. Yeke, qobe mnyaka iinkulungwana zabantu bakwaZulu beziza ethuneni leKosi uShaka bona lizomhlonipha belimkhumbule. Kwathi bona kuwe umBuso weBandlululo urhulumende wethula amaholideyi womphakathi amatjha. Kodwana akhenge ufake iLanga leKosi uShaka emaholideyini lawo. Yeke Inkatha Freedom Party, amalunga wayo amanengi okumaZulu, yabawa bona iLanga likaShaka lirage nokuba yiholideyi yabo. Urhulumende waqunta bona kuzokuba nelanga eliholideyi yomphakathi lapha woke umuntu eSewula Afrika azokugidinga khona amagugu wekhabo. Bekuzakuthi lokha amaZulu nakagidinga amagugu wekhabo ngeLanga likaShaka, nezinye iintjhaba zigidinge amagugu wabo wendabuko ngalo ilangeli. Ngikho nje umhla ka-24 kuKhukhulamungu, ulilanga lamagugu eSewula Afrika, nenyanga yoke kaKhukhula yaba yiNyanga yamaGugu.&lt;ref name=&quot;:0&quot;&gt;Kids Encyclopedia Britannica (2025) ''Heritage Day.'' Retrieved from: https://kids.britannica.com/kids/article/Heritage-Day/602049 Retrieved on 30/09/25&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;African Travel Canvas (Sep 13, 2021) ''National Heritage Day in South Africa: What is Heritage Day and Why Do We Celebrate It.'' Retrieved from: https://africantravelcanvas.com/news/national-heritage-day-in-south-africa-what-is-heritage-day-and-why-do-we-celebrate-it/. Retrieved on 30/09/2025.&lt;/ref&gt;

ILanga lamaGugu lathonywa ukugidingwa ngomhla ka-24 kuKhukhulamungu 1995. U-Atjhibhitjhobhu u-Emeritus Desmond Tutu wasebenzisa ibizo elithi &quot;''Rainbow Nation&quot;''  ukuhlathulula ngendlela amasiko, umlando, amalimi wethu okuhlukahluke ngayo. Ngilokho-ke iLanga lamaGugu elikugidingako. UmNyango wezobuKghwari namaSiko uhlela imihlangano nezenzakalo zaqobe mnyaka zokugidinga iLanga lamaGugu, bese ukhetha nendlela yokuligidingela. Amagugu angahlathululwa ngalokho esinye nesinye isitjhaba enarheni esithi nasikwenzako kusenze sikhumbule indabuko yaso. Lokhu kuhlanganisa ubuhle benarha bemvelo, iindawo zezesayensi namkha zomlando ezisikhumbuzo, amatje wesikhumbuzo, imakhiwo engokomlando, ubukghwari, iincwadi, umbhino, okucocwa ngomlomo namamiziyamu.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt; 

== Ukuqakatheka Kokugidinga INyanga YamaGugu ==
Njengombana amaSewula Afrika wendabuko akhe abuswa mBuso weBandlululo, omunye wemigomo yawo bekukuthi abantu bendabuko bakhohlwe ngomlando wabo, amasikwabo nezici ezenza babe ngibo khona bazokulawuleka. Kwathi bona uwe umBuso webandlululo, urhulumende omutjha wathoma ijima lokuthi ubuyisele isithunzi sabantu bendabuko eSewula Afrika ngokugidinga iNyanga yamaGugu. Ukugidinga isenzakalwesi kungenza umuntu azikhakhazise ngesikhabo, amasiko, ilimi, ubukghwari nombhino wesikhabo. Bese lokho kwenze inarha ibe nabantu abayaziko imveliphi yabo namasiko wabo, okwenza abantu bahlalisane ngokuthula enarheni, bamukelane bona bahlukile endabukweni yabo. Kuphinde kuthuthukise umnotho wenarha.&lt;ref&gt;South African Government (2013) ''Heritage Day.'' Retrieved from: https://www.gov.za/news/events/commemorative-events/heritage-day. Retrieved on 30/09/25.&lt;/ref&gt; 

== Iinkhombo ==</text>
      <sha1>htqezad6885mqtnszh3nvio8hpddok8</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Translated from MDWiki</title>
    <ns>14</ns>
    <id>973</id>
    <revision>
      <id>5898</id>
      <timestamp>2025-10-04T23:38:16Z</timestamp>
      <contributor>
        <username>Mr. Ibrahem</username>
        <id>100</id>
      </contributor>
      <comment>Created page with &quot;__HIDDENCAT__&quot;</comment>
      <origin>5898</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="13" sha1="2twjmejn56ditxo46hqinfh52nh6flb" xml:space="preserve">__HIDDENCAT__</text>
      <sha1>2twjmejn56ditxo46hqinfh52nh6flb</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:1918 births</title>
    <ns>14</ns>
    <id>975</id>
    <revision>
      <id>5909</id>
      <timestamp>2025-10-08T11:52:11Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created page with &quot;Articles linked to Nelson Mandela.&quot;</comment>
      <origin>5909</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="34" sha1="a0uni36oon1xqoytif6m5k0eiodd4f9" xml:space="preserve">Articles linked to Nelson Mandela.</text>
      <sha1>a0uni36oon1xqoytif6m5k0eiodd4f9</sha1>
    </revision>
    <revision>
      <id>5910</id>
      <parentid>5909</parentid>
      <timestamp>2025-10-08T11:52:59Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <minor />
      <comment>Added a categoy.</comment>
      <origin>5910</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="40" sha1="h62wx297ycy30knd3e2f83uc1fc01fh" xml:space="preserve">Articles related to people born in 1918.</text>
      <sha1>h62wx297ycy30knd3e2f83uc1fc01fh</sha1>
    </revision>
  </page>
  <page>
    <title>Idiom</title>
    <ns>0</ns>
    <id>976</id>
    <revision>
      <id>5911</id>
      <timestamp>2025-10-08T14:59:00Z</timestamp>
      <contributor>
        <username>Nosayjeni</username>
        <id>1029</id>
      </contributor>
      <comment>Created by translating the opening section from the page &quot;[[:en:Special:Redirect/revision/1312699213|Idiom]]&quot;</comment>
      <origin>5911</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="657" sha1="4fseow9f5qr0m1gx5zzagowey2ntrcr" xml:space="preserve">Isaga nofana isitjho libinzana lamagama anehlathululo eyakhekhe kwasifaniso nofana kwasingathekiso, kunokobana abe nomqondo onqophileko. Ahlukaniswe njengelimi lefomula, ihlathululo yekulumo yezaga ihlukile eenhlathululweni zeqiniso zegama ngalinye phakathi kwawo.  

Izaga zivela kanengi kiwo woke amaLimi. ELimini lesi[[Ilimi lesiNgisi|Ngisi]] kwaphela kunezaga ezilinganiselwa eenkulungwaneni ezimatjhumi amabili nahlanu.  Ezinye izaga ezaziwako ngesiNgisi zithi &quot;kghuthula amabhontjisi&quot; (okutjho bona &quot;ukuveza ilwazi eliyifihlo&quot;), &quot;kuna abokatsu nezinja&quot; (okutjho bona &quot;izulu lina khulu&quot;), begodu &quot;ukuphula umlenze&quot; (okutjho bona &quot;ube netjhudu elihle&quot;).</text>
      <sha1>4fseow9f5qr0m1gx5zzagowey2ntrcr</sha1>
    </revision>
  </page>
  <page>
    <title>Ukuya emalangeni</title>
    <ns>0</ns>
    <id>978</id>
    <revision>
      <id>5916</id>
      <timestamp>2025-10-20T11:59:23Z</timestamp>
      <contributor>
        <username>Nosayjeni</username>
        <id>1029</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1314301774|Menstruation]]&quot;</comment>
      <origin>5916</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1905" sha1="9kk2uxqj6cq2w7jkrl065kea73mxsts" xml:space="preserve">
'''Ukuya emalangeni''' (okwaziwa nangokuthi yi- '''period''', hlangana namanye amagama avamileko) kuphuma kweengazi kanye nomhlobo wamathe abizwa nge-mucosal tissue avela ngaphakathi kwesibeletho aphuma esithweni sangasese .  Ukuzomba kokuya esikhathini kubonakala ngokunyuka nokwehla kwamahomoni . &lt;ref name=&quot;Thiyagarajan&quot; /&gt; Ukuya emalangeni kubangelwa kukwehla kwamazinga we-homoni ebizwa nge-progesterone, begodu kulitshwayo lokuthi ukuzithwala akhange kwenzeke. &lt;ref name=&quot;Thiyagarajan&quot; /&gt; Kunemikhiqizo yokuhlamba yabantu bengubo esetjenziselwa ukugcina ukuhlanzeka ngesikhathi '''sokuya emalangeni''' .

Ukuya kokuthoma emalangeni, kwaziwa nge-menarche, ukuya emalangeni kuvamise ukuthoma hlangana neminyaka eli-11 ukuya kweli-13.  Nanyana kunjalo, ukuya emalangeni kokuthoma uneminyaka ebunane kuthathwa njengento ejayelekileko.  Emazweni asathuthukako kuvamile ukobana abantu bengubo baye emalangeni kokuthoma sebakhula khulile, begodu baye msinyana emazweni athuthukileko . &lt;ref name=&quot;Diaz2006&quot; /&gt; Ubude besikhathi esijayelekileko hlangana nelanga lokuthoma lokuya emalangeni  nelanga lokuthoma elilandelako lokuya emalangeni kudlulana ngamalanga ama-21 ukuya kwama-45 ebantwini bengubo abasesebatjha; ebantwini bengubo abadala, ibanga liphakathi kwamalanga ama-21 ukuya kwama-35 begodu isimedo sivamise ukuvezwa njengamalanga ama-28. &lt;ref name=&quot;Women2014Men&quot; /&gt;  Esifundweni esikhulu sedatha ye-app yokuya emalangeni, ubude obuphakathi bomjikelezo wokuya esikhathini kwatholakala bona bube malanga ama-29.3.  Ukopha kuvamise ukuthatha amalanga amabili ukuya kwalikhomba. Isikhathi sokuya esikhathini siyajama ngesikhathi sokubasidis begodu kanengi umuntu akasayi emalangeni begodu nangeenyanga zokuthoma zokumunyisa . &lt;ref name=&quot;Women2014Men&quot; /&gt; I-Lochia yenzeka ngemva kokubeletha.  Ukuya emalangeni, kanye nokubasidisi, kuyaphela i, kuvame ukwenzeka hlangana neminyaka ema-45 ukuya kwema-55.</text>
      <sha1>9kk2uxqj6cq2w7jkrl065kea73mxsts</sha1>
    </revision>
  </page>
  <page>
    <title>Ikhomitjhini ye-Madlanga</title>
    <ns>0</ns>
    <id>979</id>
    <revision>
      <id>5917</id>
      <timestamp>2025-10-21T10:10:58Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1317660561|Madlanga Commission]]&quot;</comment>
      <origin>5917</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7598" sha1="nru5a01cfwblyazlaz1u9ws7lmztuan" xml:space="preserve">
 

'''Ikhomitjhini yezobulungiswa yokuphenya ngobulelesi, ukungenelela kwezepolotiki,kanye nekohlakalo ehlelweni lobulungiswa lobulelesi''',eyaziwa ngcono nge-'''Madlanga Commission,''' liphenyo lomphakathi elamenyezelwa ngoVelabahlinze ka-2025 nguMengameli u-Cyril Ramaphosa ukuphenya ngeensolo ezenziwe nguKhomitjhina wamaPholisa wePhrovinsi ye-KwaZulu-Natal u-Lieuten General Nhlanhla Mkhwanazi  hlangana nabosopolotiki, amapholisa aphezulu,abatshutshisi,abasebenzi bezobunhloli kanye namalunga wezobulungiswa, eSewula Afrika.

Irholwa nguJaji weKhotho yomThethosisekelo othathe umhlalaphasi uMbuyiseli Madlanga.Ukulalelwa kwathoma mhlana ali-17 kuKhukhulamungu 2025 ngobufakazi baka-Lieutenant General Nhlanhla Mkhwanazi,lapho ahlathulula khona iinsolo zakhe ngokuzeleko begodu wethula ubufakazi ebegade anabo,ngendlela yemibhalo,imilayezo,nemibiko, hlangana nezinye,ukuqinisekisa ubuqiniso beensolo zakhe. 

Ukulandela u-Mkhwanazi,bekunguKhomitjhina wenarha wesevisi yamaPholisa weSewula Afrika,u-General Fannie Masemola owanikela ubufakazi eKhomishini ye-Madlanga mhlazi-22 kuKhukhulamungu 2025 e -Pitori.

Mhlana amalanga ama-29 kuKhukhulamungu wee-2025, umphathi we-Crime Intelligence u-Dumisani Khumalo wanikela ilwazi elinabileko ngesiqhema seenlelesi esihlelekileko,esibizwa nge-“Big Five”.Waveza bona i-Cartel, esekelwe e-Gauteng,kuthiwa ibandakanyeka emikhakheni ehlukahlukeneko yobulelesi obuhlelekileko,okufakahlangana ukuthengisa iindakamizwa,ukuduna,ukukhwabanisa amathenda,nokubulawa kwabantu ngegontraga. 

== Isendlalelo ==
Mhlana ali-6 kuVelabahlinze,uKhomitjhina wamaPholisa we-KwaZulu-Natal u-Lieutenant General Nhlanhla Mkhwanazi waba nomhlangano weendaba e-SAPS Provincial Headquarters e-Durban.Ngesikhathi sokukhulumisana, wasola uNgqongqotjhe wamaPholisa u-Senzo Mchunu ngokungenelela ephenyweni eliragela phambili.U-Mkhwanazi ngemva kwalokho wabhalisa isikhalazo sobulelesi ngokujamelene no-Mchunu,asola ukungenelela kwezepolotiki emsebenzini we-Political Killings Task Team's South African Police Service's,ebegade isungulwe ukuphenya ukubulawa kwabantu ngebanga lezepolotiki.

== Iinqunto kanye nokuvezwa kobufakazi obuqakathekileko (ngoKhukhulamungu – kuSewula 2025) ==
Ukulalelwa komphakathi,okwathoma phakathi kukaKhukhulamungu wee-2025,kwathoma ukuveza ubujamo bokungenelela kwezepolotiki nokungena kobulelesi obuhlelekileko.

=== Ubufakazi bokungenelela kwezepolotiki ===
Isigaba sokuthoma sokulalelwa kwecala besidzimelele ngensolo eziqakathekileko ezenziwa ngu-Lieutenant General Mkhwanazi.U-Mkhwanazi wanikela ubufakazi obunabileko, waveza ukungenelela kwezepolotiki kanye nemilayo engabazako ayithola eemphathisweni eziphezulu zikaRhulumende malungana nemisebenzi yamapholisa.

Ukulandela u-Mkhwanazi,uKhomitjhina weNarha wePholisa leSewula Afrika,u-General Fannie Masemola,wanikela ubufakazi mhlazi-22 kuKhukhulamungu 2025 e-Pitori. Ubufakazi baka-Masemola bebudzimelele khulu eenquntweni zokusebenza nezokuphatha eziphathelene nokungenelela okusolwako,okufaka hlangana isiqunto sesigungu sokuhlakaza isiqhema sokusebenza sokubulala kwezepolotiki le-KwaZulu-Natal.Okuqakathekileko,isethulo saka-Masemola saqinisekisa khulu iinsolo zaka-Mkhwanazi zokuthoma. Ukuqinisekiswa okusemthethweni okuvela ehloko ye-SAPS bekuyituthuko eqakathekileko,ephakamise ukutshwenyeka kwaka-Mkhwanazi ukusuka ekungavumelanini kwezepolotiki ukuya eqinisweni elamukelekako hlangana noburholi obuphezulu bamapholisa,ngaleyindlela kwaqinisa isisekelo samaqiniso sokuphenya.

=== Ukungena kobulelesi obuhlelekileko: Ubufakazi nge-&quot;Big Five&quot; cartel ===
Indlela yephenyo yatjhuguluka khulu mhlazi-29 kuKhukhulamungu 2025,lokha umphathi we-Crime Intelligence u-Lieutenant General Dumisani Khumalo nakathatha isikhundla.Ubufakazi baka-Khumalo bunikele ilwazi elinabileko ngokungena kweenhlangano zombuso ezihlelekileko.

U-Khumalo wethula ubufakazi obuphathelene nesiqhema esiyinkimbinkimbi esibizwa nge-“Big Five,”esibizwa nangokuthi “i-Cartel,”esisebenza khulu ngaphandle kwe-Gauteng.Imisebenzi esolwako yesiqhema lesi inengi,ifaka hlangana imikhakha emikhulu yobulelesi obuhlelekileko, okufakahlangana ukukhukhuthiswa kweendakamizwa, ukuduna,ukukhwabanisa amathenda,nokubulawa kwabantu ngekontraga.Ukudlula lapho,u-Khumalo uveze imininingwana ethileko yezezimali neyokuthintana,okufaka hlangana imilayezo ye-WhatsApp enikela ubufakazi bokuthengiselana okungekho emthethweni,khulukhulu imininingwana yeenkokhelo ezenziwe ngu -Vusimuzi 'Cat' Matlala ku- Brown Mogotsi.

Ukuvezwa kobufakazi lokhu kwahlathulula kabutjha umnqopho weKhomitjhini,kwaqinisekisa isidingo semibandela ethileko ephathelene &quot;nokusiza ubulelesi obuhlelekileko&quot;. Iimvelo ziqinisekise bona ukubhalelwa kombuso bekungapheleli ekohlakalweni yezepolotiki kodwana bekubandakanya ukuthunjwa kombuso ngamanethiwekhi wobulelesi anobudlova,okuthinta ngqo ukuphepha komphakathi nokuthembeka kwezomnotho.

=== Ubufakazi ngemva kweminyango evaliweko ===
Abadosiphambili bekhomitjhini yobufakazi bathi imihlangano evaliweko evalelweko emphakathini nabezindaba iyatlhogeka ukuvikela ukuphepha kwabofakazi abaqakathekileko abazokufaka hlangana isiqhema sobulelesi,kanye nokuvikela amaqhinga wokuphenya abucayi.I-Daily Maverick ne- News24 zithome ukufaka isibawo se-Madlanga Commission of Inquiry sokubamba iveke yokulalelwa kwayo &quot;ngaphakathi kwekhamera&quot;.Iindaba ziphikisana nalokhu,ziveza umthethosisekelo wobulungiswa obuvulekileko begodu zithi ukuvumelana kufanele kuvumele iinqunto zokuvala bona zenziwe ngokwesimo ngasinye.

=== Ukuragela phambili kwekhomitjhini ===
Umnqopho weKhomishini ye-Madlanga mhlapha nje bewudzimelele eengcocweni ze-WhatsApp ezisola ikohlakalo hlangana nelunga le-cartel yeendakamizwa u-Vusimuzi &quot;Cat&quot; Matlala neemphathiswa eziphezulu zikaRhulumende namapholisa.Ubufakazi obuvela ku-&quot;Witness X&quot; buveze ubudlelwano obuhle hlangana no-Matlala nehloko ye-KwaZulu-Natal Hawks u-Major-General u-Lesetja Senona, basola bona u-Senona wabelane ngolwazi lwamapholisa oluyifihlo no-Matlala begodu wakhuluma naye ngokwenza isivumelwano sepahla yendodanakhe.Iingcoco zibuye zatjengisa ithonya laka-Matlala,njengombana abawa isekela lenduna yamaPholisa we-Ekurhuleni Metro Police Chief u-Julius Mkhwanazi bona &quot;asize&quot; begodu &quot;angenelele&quot; ekubotjhweni komtjhayeli ka-Matlala ogijima ngebelo elikhulu, okuyinto uMkhwanazi okuthiwa yenza njalo.Ngebanga lokutshwenyeka ngeendaba zokuphepha nezobuchwepheshe ezavela ngesikhathi sobufakazi obukude,ikhomitjhini yatjhugulula ikambiso yayo ukufaka hlangana kokubili ubufakazi obuphakathi kwekhamera (obuvaliweko) nobude, ngaphandle kwekhamera bofakazi abazwelako kanye nophenyo oluragela phambili.

== Iinkomba ==
1.{{Cite web|title=Madlanga Commission must confront criminal capture of justice system|url=https://www.polity.org.za/article/madlanga-commission-must-confront-criminal-capture-of-justice-system-2025-09-17|access-date=2025-09-17|website=www.polity.org.za|language=en}}

2.https://www.enca.com/news/mkhwanazi-testifies-about-mchunus-decision-disband-political-killings-task-team

3.{{Cite web|last=Maverick|first=Daily|date=September 17, 2025|title=Follow live: Mkhwanazi first witness at Madlanga Commission|url=https://www.dailymaverick.co.za/article/2025-09-17-live-madlanga-commission-mkhwanazi/|access-date=2025-09-17|website=Daily Maverick|language=en}}

4.{{Cite web|last=Maverick|first=Daily|date=September 17, 2025|title=Follow live: Mkhwanazi first witness at Madlanga Commission|url=https://www.dailymaverick.co.za/article/2025-09-17-live-madlanga-commission-mkhwanazi/|access-date=2025-09-17|website=Daily Maverick|language=en}}</text>
      <sha1>nru5a01cfwblyazlaz1u9ws7lmztuan</sha1>
    </revision>
  </page>
  <page>
    <title>Vusimuzi Matlala</title>
    <ns>0</ns>
    <id>980</id>
    <revision>
      <id>5918</id>
      <timestamp>2025-10-21T13:16:45Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1317983842|Vusimuzi Matlala]]&quot;</comment>
      <origin>5918</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="10332" sha1="7ru66bh3rtbf1ye4n18s9i28fseugso" xml:space="preserve">{{Reflist}}

'''U-Vusimuzi “Cat” Matlala''' msolwa wezelelesi weSewula Afrika owaziwa ngokuzibandakanya kwakhe eenkontrageni ezinkulu zombuso neempikiswano ezihlobene nalokho. Umnikazi wenkampani yezokuphepha,u-Matlala uhlala e -Pitori.Uhlathululwe nga-beendaba &quot;njengomphathi wezokuphepha&quot; kanye&quot; nomsunguli &quot;begodu njenganje ubotjhwe ngebanga lokulinga ukubulala isithandwa sakhe sangaphambilini.

U-Matlala uqondisa amakhamphani amanengi emkhakheni wezokuphepha newezokwelapha.Ukwenza isibonelo, bekangumnqophisi oyedwa we-Medicare 24 Tshwane District,  ikampani enikela ngeenkonzo zokulawula ubungozi bezamaphilo,begodu bekangumnqophisi osebenzako we-Cat VIP Protection Pty Ltd,Falcon Cat Trading and Suppliers ''','''Lux South African Investments Pty Ltd,Cor Kabeng Trading &amp; Suppliers kanye ne-Black AK Trading.Ngamafemu la, wakhuphukela eenkontrageni zokuthengwa kwezinto zikaRhulumende nezeenkonzo zezamaphilo.

== Ibizelo ==
U-Matlala wakha umsebenzi wakhe ekuthengiseni ukuvikeleka kwangasese nokutlhogonyelwa kwezamaphilo. Ngaphezu kwe-Medicare 24,uphethe amakhamphani aphathelene nezokuphepha.Ukhokhele i-Black AK Trading ne-Cor Kabeng Trading (amafemu amancani atlolisiweko ngo-2017)abandakanyeka eenkontrageni zokuphakela iimbhedlela.Abaphenyi batjheja bona i-Black AK ne-Cor Kabeng zadalwa ngaphambi kobana ziphumelele amabhidi, begodu u-Matlala wahlala atlolwe njengomnqophisi wabo bobabili.

Emkhakheni wezokuvikeleka,u-Matlala waziwa ngokutjheja ukuvikelwa kwamakati nokuphepha kanye nama-Cat VIP Holdings.Amafemu la anikele ngezokuphepha nemisebenzi ehlobene nalokho.Ukusebenzelana kwakhe kwezamabhizinisi kwathola izinga eliphezulu emphakathini ngemva kokulandelana kweenkontraga zikaRhulumende phakathi neminyaka yabo-2020.Iimphenyo zeendaba ziveza bona &quot;wakhula waba mkhulu ngeenkontraga ezinengi ezizuzisako noRhulumende weSewula Afrika &quot;. Amakhamphani wakhe aphumelele amathenda amanengi,kodwana adosa ukuhlolisiswa bahloli bamabhugu nabaphenyi.

Imali ka-Matlala ilinganiselwa hlangana ne-R100-R150 yeengidi.

== Ukuzibandakanya kwethenda ==
Ibizo laka-Matlala lihlotjaniswe neenkontraga ezinengi ezikulu zikaRhulumende.Ngomnyaka ka-2021, ummemezeli u-Babita Deokaran,umrholi weyunithi yokulwa nekohlakalo yomnyango wezamaphilo we-Gauteng,waveza ukungalungi eenkontrageni zesibhedlela se-Tembisa ezanikelwa iinkampani azilawulako.Isiqhema saka-Deokaran sathola iingidigidi zama-randa asetjenziswe empahleni nemisebenzi evela ku-Black AK Trading &amp; Suppliers kanye ne-Cor Kabeng Trading &amp; Suppliers,begodu sahlongoza amacala wokukhwabanisa malungana namafemu.U-Deokaran wabulawa ngoRhoboyi wee-2021 ngaphambi kobana iphenyo liphele.Iyunithi ekhethekileko yokuphenya kanye ne-Hawks ngokukhamba kwesikhathi benza iphenyo elifanako eenkontrageni zesibhedlela,u-Matlala wabizwa njengomnqophisi wamafemu abandakanyekako.Ngenyanga kaKhukhulamungu i-SIU ikhuphe imibiko yayo yesikhatjhana begodu sele ilandelele abathengisi abama-41 namkha abanikeli beenkonzo abahlobene nesibhedlela se-Tembisa begodu amakhamphani amathathu anikelwe iinkontraga ezibiza i-R13 538 292 esiqhemeni lesi ahlotjaniswa no-Vusimuzi Matlala.

Ngo-2024, ikhamphani ka-Matlala i-Medicare 24 Tshwane District yanikelwa isivumelwano seenkonzo zezamaphilo seminyaka emithathu ne- South African Police Service (SAPS) esibiza i-R360 yezigidi.Ngaphasi kwesivumelwano lesi,i-Medicare 24 bekufuze inikeze ukuhlolwa kwezokwelapha kanye namasevisi wezamaphilo emalungwini wamapholisa angaba yi-180,000.Imibhalo yokunikela ngokubhida egadangiswe mapholisa,ngoMgwengweni 2024, iqinisekisa bona ikhamphani ka-Matlala bekukuphela kwayo ephumeleleko yokubhida kwekontraga ye-R360m.Umvuzo lo wadonsa ukutjhejwa msinyana,abaphenyi ngokukhamba kwesikhathi baveza ubufakazi bokukhohlisa nokusebenzisana,begodu iimphathiswa zamapholisa zavuma bona ithenda &quot;gade iphawulwe ngokukhwabanisa nobunye ubulelesi&quot;.Phakathi kuka-2025 isivumelwano sakhanselwa msinyana ngukhomitjhina wamapholisa welizwe loke u-Fannie Masemola, aveza ukungalungi.

== Amacala wobulelesi kanye neensolo zekohlakalo ==
Ngo-2024,u-Matlala wabotjhwa begodu wabekwa amacala amanengi.Ngokuya kwemibhalo yekhotho, ubhekene namacala wokulinga ukubulala,ukuvukela ukubulala, nokukhwabanisa imali.Amacala la ahlobana ngokwengcenye nesehlakalo sango-2023 lapho ikoloyi ebegade ithwele intombi yakhe yangaphambilini,umlingisi weSewula Afrika u-Tebogo Thobejane,yadumuzwa eduze ne -Sandton.U-Matlala usolwa ngokuhlela umvumo lo,kodwana uphikile bona ubandakanyeka namkha umnqopho.UThobejane walimala emlenzeni begodu ngokukhamba kwesikhathi wabaleka enarheni,wathi uyesaba ipilo yakhe.Ulandulile amacala kiwo woke amacala begodu usavalelwe ngemva kokuthi anqatshelwe ibheyili,mhlana ali-17 kuKhukhulamungu 2025, ngebanga lokuthi uyingozi yokubaleka begodu uyingozi emphakathini.

Ekulalelweni kwebheyili,iimphathimandla zatjheja izinto ezinengi ezitjengisa bona u-Matlala angabalekela ukutshutshiswa,basola bona unedokhumenti yobunikazi be- Eswatini ekhohlisako kanye nepahla yangaphandle (njenge-jet yangeqadi nama-akhawundi webhanga wangaphandle) engasiza ukuphapha.U-Matlala uphikise iinkolodo lezi, aphikisa ubunikazi bepahla begodu asola abaphenyi ngokutjala ubufakazi.

Ngale kwamacala wobulelesi,u-Matlala ufakwe emacaleni amanengi &quot;wokuthunjwa kwamapholisa,&quot; athi iimphathiswa eziphezulu zamapholisa bezithonywe ngokungakafaneli babantu bezamabhizinisi.Kubikwa bona abaphenyi bamthatha njengomuntu oqakatheke khulu eensolo ezinjalo, okwenza bona kuthonywe iKhomishini yokuPhenya ye-Madlanga ngekohlakalo ye-SAPS.Owayengungqongqotjhe wamapholisa u-Bheki Cele uvumile bona wahlangana no-Matlala amaviki ngaphambi kobana ithenda ye-R360m ikhanselwe.Njengomphumela,amabhizinisi ka-Matlala nokuthintana kwakhe kwezepolotiki kudose ukuhlolisiswa okukhulu komphakathi nomthetho eSewula Afrika.Mhlana amalanga ama-29 kuKhukhulamungu wee-2025,umphathi we-Crime Intelligence u-Dumisani Khumalo wanikela ilwazi elinabileko ngesiqhema seenlelesi esihlelekileko,esibizwa nge-“Big Five” lapho u-Matlala ayingcenye yaso.Waveza bona i-cartel,esekelwe e -Gauteng, kuthiwa ibandakanyeka emikhakheni ehlukahlukeneko yobulelesi obuhlelekileko, okufaka hlangana ukurhweba ngeendakamizwa,ukuduna, ukukhwabanisa amathenda,nokubulawa kwabantu ngeenkontraga.

== Ikhomitjhini ye-Madlanga ==
Ngenyanga kaSewula 2025,ufakazi weKhomitjhini ye-Madlanga waveza bona u-Matlala wathumela imitlolo emithathu ku-Maj-Gen Lesetja Senona,umrholi we-KwaZulu-Natal Hawks,mhlana ali-13 kuSihlabantangana 2025. Hlangana nayo bekunemiphumela yokuphenya okupheleleko kwe-LexisNexis ku-Senzo ne-Thembeka Mchunu Foundation kanye nemininingwana ye-Bizland mayelana neenomboro ezinengi zobunikazi zikaMengameli u-Cyril Ramaphosa.

Ubufakazi obuvezwe eKhomitjhini yokuPhenya ye-Madlanga, khulukhulu ngeengcoco ze -WhatsApp ezitholwe efonini ka-Matlala,buveze ukungenelela kobulelesi emazingeni aphezulu we-SAPS.Imilayezo,eyethulwe ngu-hloko wezobulelesi u-Lt-Gen Dumisani Khumalo,ihlobanisa u-Matlala nosomabhizinisi onethonya we-North West,u-Brown Mogotsi,ohlobene khulu noNgqongqotjhe wamaPholisa ojamisiweko u-Senzo Mchunu .Ukukhulumisana lokhu kutjengisa bona u-Matlala wabhadela iindleko zepolotiki ze-ANC ngo-Mogotsi ngokutjhugulula umusa,okufakahlangana ilwazi nemizamo yokukhandela ukukhanselwa kwesivumelwano sakhe sezamaphilo se-SAPS esibiza iingidigidi zama-randa.

ISekela likaKhomitjhina wamaPholisa weNarha u-Lt-Gen Shadrack Sibiya wanikela ubufakazi phambi kwekomidi yesikhatjhana yepalamende,lapho avuma khona bona uthintane no-Matlala no-Mogotsi kodwana waphika ngokuqinileko bona ubudlelwano bomuntu mathupha nofana ukuzibandakanya ekohlakalweni kanye nomzamo wokuhlakaza i-Politikal Killings Task Team (PKTT). Ukukhulumisana okulinganiselweko kwaka-Sibiya no-Matlala kwahlathululwa njengokusebenzisana kwezobuchwepheshe malungana nokuphikisana kwethenda,ngesikhathi yena athi u-Mogotsi &quot;bekangumlweli&quot; obekamnikela ilwazi ngezinye iinkhathi.

U-Matlala uhlala ejele ngemva kokuthi iKhotho yeMantshi ye-Alexandra ibhalile ngesibawo sakhe sebheyili,imveza njengomuntu ongakghona ukubaleka oneensetjenziswa ezinengi nethonya.Isiqhema sakhe sezomthetho sele siphakamisa isibawo sakhe sebheyili eKhotho ePhakemeko ye-Gauteng e-Johannesburg,okutjengisa umzamo wokuchitha ukuphika kwekhotho ephasi.I-atikili ye ''-Daily Maverick'' ikhuthaza bona u-Matlala kufanele amenyezelwe njenge-“National Key Point”.I-atikili le iveza bona ithonya lakhe lifike kangangani eenkhungweni zombuso.I-atikili ithi ubudlelwano bakhe bezamabhizinisi nezepolotiki,khulukhulu ekuvikelekeni kombuso,amapholisa kanye namathenda, kumenze waba mumuntu oqakathekileko eenkulumiswaneni &quot;zokubamba&quot; zeSewula Afrika.

== Iinkomba ==
1.{{Cite web|last=Maverick|first=Daily|date=September 17, 2025|title=Follow live: Mkhwanazi first witness at Madlanga Commission|url=https://www.dailymaverick.co.za/article/2025-09-17-live-madlanga-commission-mkhwanazi/|access-date=2025-09-17|website=Daily Maverick|language=en}}

2.{{Cite web|last=Sithole|first=Siyabonga|date=2025-09-18|title=State believes it has &quot;water-tight&quot; case against Pretoria businessman Cat Matlala|url=https://capetimes.co.za/news/2025-09-18-state-believes-it-has-water-tight-case-against-pretoria-businessman-cat-matlala/|access-date=2025-09-19|website=Cape Times|language=en}}

3.{{Cite web|last=Pijoos|first=Jeff Wicks &amp; Iavan|title=SILENCED {{!}} Police award R360m contract to Tembisa Hospital tender don|url=https://www.news24.com/investigations/silenced-police-award-r360m-contract-to-tembisa-hospital-tender-don-20241220|access-date=2025-09-19|website=News24|language=en-US}}

4.{{Cite web|last=Pijoos|first=Jeff Wicks &amp; Iavan|title=SILENCED {{!}} Police award R360m contract to Tembisa Hospital tender don|url=https://www.news24.com/investigations/silenced-police-award-r360m-contract-to-tembisa-hospital-tender-don-20241220|access-date=2025-09-19|website=News24|language=en-US}}

5.{{Cite web|last=Majadibodu|first=Simon|date=2025-09-03|title=Businessman Vusimuzi 'Cat' Matlala claims 52 workers lost jobs after SAPS cancelled his R360 million contract|url=https://thestar.co.za/news/crime-and-courts/2025-09-03-businessman-vusimuzi-cat-matlala-claims-52-workers-lost-jobs-after-saps-cancelled-his-r360-million-contract/|access-date=2025-09-19|website=The Star|language=en}}</text>
      <sha1>7ru66bh3rtbf1ye4n18s9i28fseugso</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Tabs/styles.css</title>
    <ns>10</ns>
    <id>981</id>
    <revision>
      <id>5920</id>
      <timestamp>2025-10-23T12:22:28Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>added tabs</comment>
      <origin>5920</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="621" sha1="4edst2rgpx0mooekbnykep8cev6rest" xml:space="preserve">/* {{pp-template}} */
.template-page-tabs {
	background: #F8FCFF;
    color:black;
	width: 100%;
	display: flex;
	flex-wrap: wrap;
	margin-bottom: -4px;
}

.template-page-tabs &gt; span {
	padding: 0.5em;
	line-height: 0.95em;
	border: solid 2px #a3b1bf;
	white-space: nowrap;
	margin-bottom: 4px;
}

.template-page-tabs &gt; span.spacer {
	display: flex; /* hides any whitespace we put inside */
	padding: 0;
	flex: 9px;
	border-width: 0 0 2px 0;
}

.template-page-tabs &gt; span.spacer:last-child {
	/* We want this to get first priority, which flexbox doesn't really understand but hopefully this will do. */
	flex: 1000 1 0;
}</text>
      <sha1>4edst2rgpx0mooekbnykep8cev6rest</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Tabs</title>
    <ns>828</ns>
    <id>982</id>
    <revision>
      <id>5921</id>
      <timestamp>2025-10-23T12:25:13Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>added the module</comment>
      <origin>5921</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="1337" sha1="tnxa98gb8zpy1s3bu54485wik0qunom" xml:space="preserve">-- This module implements {{Page tabs}}.

local getArgs = require('Module:Arguments').getArgs
local yesno = require('Module:Yesno')

local p = {}

function p.main(frame)
	local args = getArgs(frame)
	return p._main(args)
end

function p._main(args)
	local makeTab = p.makeTab
	local root = mw.html.create()
	root:wikitext(yesno(args.NOTOC) and '__NOTOC__' or nil)
	local row = root:tag('div')
		:css('background', args.Background or '#f8fcff')
		:css('color', 'black')
		:cssText(args.style or nil)
		:addClass('template-page-tabs')
		:addClass(args.class or nil)
	if not args[1] then
		args[1] = '{{{1}}}'
	end
	for i, link in ipairs(args) do
		makeTab(row, link, args, i, args[&quot;class&quot; .. i] or nil, args[&quot;style&quot; .. i] or nil)
	end
		
	return tostring(root)
end

function p.makeTab(root, link, args, i, class, css)
	local thisPage = (args.This == 'auto' and link:find('[[' .. mw.title.getCurrentTitle().prefixedText .. '|', 1, true)) or tonumber(args.This) == i
	root:tag('span')
		:addClass(class)
		:css('background-color', thisPage and (args['tab-bg'] or 'white') or (args['tab1-bg'] or '#e0edf6'))
		:css('color', 'black')
		:cssText(thisPage and 'border-bottom:0;font-weight:bold' or 'font-size:95%')
		:cssText(css)
		:wikitext(link)
		:done()
		:wikitext('&lt;span class=&quot;spacer ' .. (class or &quot;&quot;) .. '&quot;&gt;&amp;#32;&lt;/span&gt;')
end

return p</text>
      <sha1>tnxa98gb8zpy1s3bu54485wik0qunom</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Fmbox</title>
    <ns>10</ns>
    <id>983</id>
    <revision>
      <id>5926</id>
      <timestamp>2025-10-23T12:46:46Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>added</comment>
      <origin>5926</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1354" sha1="4ul9l9khxfdrtowctyebnljnqrefvnr" xml:space="preserve">&lt;table {{#if:{{{id|}}}|id=&quot;{{{id|}}}&quot;}} class=&quot;plainlinks fmbox
{{#switch:{{{type|}}}
| warning    = fmbox-warning
| editnotice = fmbox-editnotice
| system          &lt;!-- system = default --&gt;
| #default   = fmbox-system
}} {{{class|}}}&quot; style=&quot;{{{style|}}}&quot;&gt;
&lt;tr&gt;
{{#ifeq:{{{image|}}}|none
| &lt;!-- No image. --&gt;
| &lt;td class=&quot;mbox-image&quot;&gt;
  {{#if:{{{image|}}}
  | {{{image}}}
  | [[File:{{#switch:{{{type|}}}
    | warning    = Cmbox deletion.png
    | editnotice = Information icon4.svg
    | system          &lt;!-- system = default --&gt;
    | #default   = Information icon4.svg
    }}|40x40px|link=|alt=]]
  }}&lt;/td&gt;
}}
&lt;td class=&quot;mbox-text&quot; style=&quot;{{{textstyle|}}}&quot;&gt; {{{text}}} &lt;/td&gt;
{{#if:{{{imageright|}}}
| &lt;td class=&quot;mbox-imageright&quot;&gt; {{{imageright}}} &lt;/td&gt;
}}
&lt;/tr&gt;
&lt;/table&gt;&lt;!--
  Detect and report usage with faulty &quot;type&quot; parameter:
--&gt;{{#switch:{{{type|}}}
|   &lt;!-- No type fed, is also valid input --&gt;
| warning
| editnotice
| system     =    &lt;!-- Do nothing, valid &quot;type&quot; --&gt;
| #default   = &lt;div style=&quot;text-align: center;&quot;&gt;This message box is using an invalid &quot;type={{{type|}}}&quot; parameter and needs fixing.&lt;/div&gt;[[Category:Wikipedia message box parameter needs fixing|{{main other|Main:}}{{FULLPAGENAME}}]]&lt;!-- Sort on namespace --&gt;
}}&lt;noinclude&gt;
{{documentation}}
&lt;!-- Add categories and interwikis to the /doc subpage, not here! --&gt;
&lt;/noinclude&gt;</text>
      <sha1>4ul9l9khxfdrtowctyebnljnqrefvnr</sha1>
    </revision>
    <revision>
      <id>5930</id>
      <parentid>5926</parentid>
      <timestamp>2025-10-23T12:54:32Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>try again</comment>
      <origin>5930</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1845" sha1="klfvyqu4p4h5k1rmk09rc8cxhbgtjk9" xml:space="preserve">&lt;table {{#if:{{{id|}}}|id=&quot;{{{id|}}}&quot;}} class=&quot;plainlinks fmbox
{{#switch:{{{type|}}}
| warning    = fmbox-warning
| editnotice = fmbox-editnotice
| system          &lt;!-- system = default --&gt;
| #default   = fmbox-system
}} {{{class|}}}&quot; style=&quot;clear: both; margin: 0.2em 0; width: 100%; border: 1px solid #aaa; background: #f9f9f9; 
{{#switch:{{{type|}}}
| warning    = background: #ffdbdb; border: 1px solid #bb7070;
| editnotice = background: transparent;
| system          &lt;!-- system = default --&gt;
| #default   = background: #f9f9f9;
}} {{{style|}}}&quot;&gt;
&lt;tr&gt;	
{{#ifeq:{{{image|}}}|none
| &lt;!-- No image. --&gt;
| &lt;td class=&quot;mbox-image&quot; style=&quot;padding: 2px  0 2px 0.9em; border: none; text-align: center;''&gt;
  {{#if:{{{image|}}}
  | {{{image}}}
  | [[File:{{#switch:{{{type|}}}
    | warning    = Ambox warning pn.svg
    | editnotice = Information icon4.svg
    | system          &lt;!-- system = default --&gt;
    | #default   = Information icon4.svg
    }}|40x40px|link=|alt=]]
  }}&lt;/td&gt;
}}
&lt;td class=&quot;mbox-text&quot; style=&quot;padding: 0.25em 0.9em; border: none; width: 100%; {{{textstyle|}}}&quot;&gt; {{{text}}} &lt;/td&gt;
{{#if:{{{imageright|}}}
| &lt;td class=&quot;mbox-imageright&quot; style=&quot;padding: 2px  0.9em 2px 0; border: none; text-align: center;''&gt;  {{{imageright}}} &lt;/td&gt;
}}
&lt;/tr&gt;
&lt;/table&gt;&lt;!--
  Detect and report usage with faulty &quot;type&quot; parameter:
--&gt;{{#switch:{{{type|}}}
|   &lt;!-- No type fed, is also valid input --&gt;
| warning
| editnotice
| system     =    &lt;!-- Do nothing, valid &quot;type&quot; --&gt;
| #default   = &lt;div style=&quot;text-align: center;&quot;&gt;This message box is using an invalid &quot;type={{{type|}}}&quot; parameter and needs fixing.&lt;/div&gt;[[Category:Wikipedia message box parameter needs fixing|{{main other|Main:}}{{FULLPAGENAME}}]]&lt;!-- Sort on namespace --&gt;
}}&lt;noinclude&gt;
{{documentation}}
&lt;!-- Add categories and interwikis to the /doc subpage, not here! --&gt;
&lt;/noinclude&gt;</text>
      <sha1>klfvyqu4p4h5k1rmk09rc8cxhbgtjk9</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Clear</title>
    <ns>10</ns>
    <id>984</id>
    <revision>
      <id>5927</id>
      <timestamp>2025-10-23T12:50:30Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>added</comment>
      <origin>5927</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="81" sha1="6mk3e4afot6hzu6tzbljxxk83e14xv6" xml:space="preserve">&lt;div style=&quot;clear:{{{1|both}}};&quot;&gt;&lt;/div&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>6mk3e4afot6hzu6tzbljxxk83e14xv6</sha1>
    </revision>
  </page>
  <page>
    <title>Isintu Amasiko Nemikghwa</title>
    <ns>0</ns>
    <id>986</id>
    <revision>
      <id>5946</id>
      <timestamp>2025-11-06T10:12:51Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>Created page with &quot;[[Isimumathi:AmaNdebele.jpg|thumb|IsiNdebele|478x478px]] Esinye nesinye isitjhaba ephasini sinendlela yaso yokwenza izinto. Sinemikghwa, sinamasiko nesikopilo. Amanye namanye amasiko abe nendlela yawo yokuwenza engafani nenye. Indlela le ithoma ngokubonakala emakhaya, emphakathini, esitjhabeni nesizweni. Imikghwa yakha amasiko, amasiko akha isintu.&lt;ref name=&quot;:0&quot;&gt;The Brittanica Dictionary (2025) ''Tradition.'' Retrieved  from:https://www.britannica.com/dictionary/traditio...&quot;</comment>
      <origin>5946</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4164" sha1="q50iw1j1g3drjw9vujxbxesso938yiy" xml:space="preserve">[[Isimumathi:AmaNdebele.jpg|thumb|IsiNdebele|478x478px]]
Esinye nesinye isitjhaba ephasini sinendlela yaso yokwenza izinto. Sinemikghwa, sinamasiko nesikopilo. Amanye namanye amasiko abe nendlela yawo yokuwenza engafani nenye. Indlela le ithoma ngokubonakala emakhaya, emphakathini, esitjhabeni nesizweni. Imikghwa yakha amasiko, amasiko akha isintu.&lt;ref name=&quot;:0&quot;&gt;The Brittanica Dictionary (2025) ''Tradition.'' Retrieved  from:https://www.britannica.com/dictionary/tradition Retrieved from: 30/09/2025.&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;Fundamentals (2025) ''Cultural Habits.'' Retrieved from: https://sustainability-directory.com/fundamentals/cultural-habits-fundamentals/ Retrieved on 30//09/2025.&lt;/ref&gt; 

== Isintu ==
Ngokwehlathululo yephasi loke, isintu (''tradition'') yindlela yokucabanga, yokuziphatha neyokwenza imikghwa, enjengamasiko, amariyadlhana, indlela yokumbatha, yokudla neyobukghwari ebeyenziwa ziintjhaba zabantu abanzima, emindenini, emphakathini, nesitjhabeni esele inesikhathi eside ikhona.&lt;ref name=&quot;:0&quot; /&gt; Ngokwehlathululo yesi-Afrika isintu, nendlela yokuziphatha, yokucabanga neyokuphatha abanye abantu ngendlela enobuntu (''humanity''). Isaga esithi, '''&quot;umuntu mumuntu ngabantu&quot;''' mgogodlha wefundiso yesintu. &quot;'''Ungilokho ongikho ngebanga lokuthi abanye bangilokho abangikho'''&quot;.&lt;ref&gt;Herbert Moyo (October 14, 2022) ''Isintu.'' Retrieved from: https://globalcritical.barefield.ua.edu/self-and-persistence/isintu/ Retrieved  on 30/09/25.&lt;/ref&gt; Bubuntu-ke lobo. Ifundiso le kade khulu ikhona. Yeke isintu sibonakala ngemicabango, ngekolelo, ngemizwa nangezenzo ezinobuntu - mimikghwa, isikopilo, amasiko namariyadlhana.&lt;ref&gt;Desmond Tutu (2013), ''Who are we: Human Uniqueness and African Spirit of Ubuntu'' (Video)''.'' Retrieved from: https://www.youtube.com/watch?v=0wZtfqZ271w#t=162 Retreived on 30/09/25.&lt;/ref&gt;

== Amasiko ==
[[Isimumathi:Mapoch.- Femmes Ndebele in Cultural Village (1).jpg|thumb|Indlela yokumbatha yamaNdebele]]
Ayini-ke amasiko? Amasiko yindlela yokwenza izinto yendabuko eyenziwa sitjhaba esithileko ekolweni, embusweni nekuhlalisaneni kwabantu. Indlela le kade yenziwa begodu idluliselwa esizukulwaneni esilandelako ngokufundiswa ngomlomo nangezenzo. Kungaba yindlela yokwenza izenzo ezithileko zendabuko zendlela yokuziphatha, indlela yokuhlalisana nabanye, indlela yokumbatha, indlela yokudla, indlela yokubusa, indlela yokurarulula imiraro, indlela yokuraga amariyadlhana wekolo yesintu namkha yendabuko. Ngamanye amagama umukghwa othileko nawusolo ubuyelelwa iinkhathi ezinengana mumuntu, mndeni, mphakathi nesitjhaba, ugcina sele ulisiko.&lt;ref&gt;Gibbon Rangel (2022) ''Characteristics of Culture, Customs and Traditions,'' from Walsh and Medical Media Websie. Retrieved from: https://www.walshmedicalmedia.com/open-access/characteristics-of-culture-customs-and-traditions-114614.html Retrieved on 30/09/2025.&lt;/ref&gt; 

Aqakatheke kangangani amasiko ebantwini? Amasiko enza umuntu azikhakhazise ngendabuko yakhe. Umuntu nakazikhakhazisa ngendabukwakhe uzozikhakhazisa ngaye ngokwakhe. Ukuzikhakhazisa kumenza azithembe yena ngokwakhe begodu azizwe amumuntu. Amasiko anendlela yokuziphatha neyokuziphatha emukelekako emphakathini nesitjhabeni. Lokha umuntu nakaziphatha kuhle abantu bayamthanda. Ukuthandwa babantu kukwenza uzizwe uhloniphekile unesithunzi, uzizwe unendima eqakathekileko oyidlalako emphakathini othileko. Nanyana kunamasiko angaba nomphumela omumbi emntwini, amasiko amahle angaletha imiphumela emihle.&lt;ref&gt;Frank Sonnenberg (2025) ''7 Reasons Why Traditions Are So Important.'' Retrieved from: https://www.franksonnenbergonline.com/blog/7-reasons-why-traditions-are-so-important/ Retrieved on 30/05/25.&lt;/ref&gt; Ibuthelelo lamasiko ngilo elakha isintu.

== Imikghwa ==
Njengomana kutjhiwo ngehla, imikghwa yakha isiko, isiko lakha isintu. Alo, iyini imikghwa? Imikghwa zizenzo abantu abajayele ukuzenza. Kunemikghwa yokudla, yokukhuluma, neyokwenza, imikghwa yokuziphatha, imikghwa yokuphatha abanye, imigkhwa yokumbatha, yokubukghwari neyombhino. Imikghwa le nayisolo yenziwa mumuntu, mphakathi namkha isitjhaba, bese imukeleke ebantwini igcina sele ilisiko.&lt;ref name=&quot;:1&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>q50iw1j1g3drjw9vujxbxesso938yiy</sha1>
    </revision>
    <revision>
      <id>5947</id>
      <parentid>5946</parentid>
      <timestamp>2025-11-06T10:19:35Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>edits</comment>
      <origin>5947</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4296" sha1="hfaz3hmfgf2urloftwwcqhhvprqzxz9" xml:space="preserve">[[Isimumathi:AmaNdebele.jpg|thumb|IsiNdebele|478x478px]]
Esinye nesinye isitjhaba ephasini sinendlela yaso yokwenza izinto. Sinemikghwa, sinamasiko nesikopilo. Amanye namanye amasiko abe nendlela yawo yokuwenza engafani nenye. Indlela le ithoma ngokubonakala emakhaya, emphakathini, esitjhabeni nesizweni. Imikghwa yakha amasiko, amasiko akha isintu.&lt;ref name=&quot;:0&quot;&gt;The Brittanica Dictionary (2025) ''Tradition.'' Retrieved  from:https://www.britannica.com/dictionary/tradition Retrieved from: 30/09/2025.&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;Fundamentals (2025) ''Cultural Habits.'' Retrieved from: https://sustainability-directory.com/fundamentals/cultural-habits-fundamentals/ Retrieved on 30//09/2025.&lt;/ref&gt; 

== Isintu ==
Ngokwehlathululo yephasi loke, isintu (''tradition'') yindlela yokucabanga, yokuziphatha neyokwenza imikghwa, enjengamasiko, amariyadlhana, indlela yokumbatha, yokudla neyobukghwari ebeyenziwa ziintjhaba zabantu abanzima, emindenini, emphakathini, nesitjhabeni esele inesikhathi eside ikhona.&lt;ref name=&quot;:0&quot; /&gt; Ngokwehlathululo yesi-Afrika isintu, nendlela yokuziphatha, yokucabanga neyokuphatha abanye abantu ngendlela enobuntu (''humanity''). Isaga esithi, '''&quot;umuntu mumuntu ngabantu&quot;''' mgogodlha wefundiso yesintu. &quot;'''Ungilokho ongikho ngebanga lokuthi abanye bangilokho abangikho'''&quot;.&lt;ref&gt;Herbert Moyo (October 14, 2022) ''Isintu.'' Retrieved from: https://globalcritical.barefield.ua.edu/self-and-persistence/isintu/ Retrieved  on 30/09/25.&lt;/ref&gt; Bubuntu-ke lobo. Ifundiso le kade khulu ikhona. Yeke isintu sibonakala ngemicabango, ngekolelo, ngemizwa nangezenzo ezinobuntu - mimikghwa, isikopilo, amasiko namariyadlhana.&lt;ref&gt;Desmond Tutu (2013), ''Who are we: Human Uniqueness and African Spirit of Ubuntu'' (Video)''.'' Retrieved from: https://www.youtube.com/watch?v=0wZtfqZ271w#t=162 Retreived on 30/09/25.&lt;/ref&gt;

== Amasiko ==
[[Isimumathi:Mapoch.- Femmes Ndebele in Cultural Village (1).jpg|thumb|Indlela yokumbatha yamaNdebele]]
Ayini-ke amasiko? Amasiko yindlela yokwenza izinto yendabuko eyenziwa sitjhaba esithileko ekolweni, embusweni nekuhlalisaneni kwabantu. Indlela le kade yenziwa begodu idluliselwa esizukulwaneni esilandelako ngokufundiswa ngomlomo nangezenzo. Kungaba yindlela yokwenza izenzo ezithileko zendabuko zendlela yokuziphatha, indlela yokuhlalisana nabanye, indlela yokumbatha, indlela yokudla, indlela yokubusa, indlela yokurarulula imiraro, indlela yokuraga amariyadlhana wekolo yesintu namkha yendabuko. Ngamanye amagama umukghwa othileko nawusolo ubuyelelwa iinkhathi ezinengana mumuntu, mndeni, mphakathi nesitjhaba, ugcina sele ulisiko.&lt;ref&gt;Gibbon Rangel (2022) ''Characteristics of Culture, Customs and Traditions,'' from Walsh and Medical Media Websie. Retrieved from: https://www.walshmedicalmedia.com/open-access/characteristics-of-culture-customs-and-traditions-114614.html Retrieved on 30/09/2025.&lt;/ref&gt; 

Aqakatheke kangangani amasiko ebantwini? Amasiko enza umuntu azikhakhazise ngendabuko yakhe. Umuntu nakazikhakhazisa ngendabukwakhe uzozikhakhazisa ngaye ngokwakhe. Ukuzikhakhazisa kumenza azithembe yena ngokwakhe begodu azizwe amumuntu. Amasiko anendlela yokuziphatha emukelekako emphakathini nesitjhabeni. Lokha umuntu nakaziphatha kuhle abantu bayamthanda. Ukuthandwa babantu kukwenza uzizwe uhloniphekile unesithunzi, uzizwe unendima eqakathekileko oyidlalako emphakathini othileko. Woke umuntu unesidingo esingokwemvelo sokuthandwa nokuthanda, ngikho nje nakamukelekako emphakathini ngebanga lokuziphatha kwakhe uzizwa amumuntu. Nanyana kunamasiko angaba nomphumela omumbi emntwini, amasiko amahle angaletha imiphumela emihle.&lt;ref&gt;Frank Sonnenberg (2025) ''7 Reasons Why Traditions Are So Important.'' Retrieved from: https://www.franksonnenbergonline.com/blog/7-reasons-why-traditions-are-so-important/ Retrieved on 30/05/25.&lt;/ref&gt; Ibuthelelo lamasiko ngilo elakha isintu.

== Imikghwa ==
Njengomana kutjhiwo ngehla, imikghwa yakha isiko, isiko lakha isintu. Alo, iyini imikghwa? Imikghwa zizenzo abantu abajayele ukuzenza. Kunemikghwa yokudla, yokukhuluma, neyokwenza, imikghwa yokuziphatha, imikghwa yokuphatha abanye, imigkhwa yokumbatha, yokubukghwari neyombhino. Imikghwa le nayisolo yenziwa mumuntu, mphakathi namkha isitjhaba, bese imukeleke ebantwini igcina sele ilisiko.&lt;ref name=&quot;:1&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>hfaz3hmfgf2urloftwwcqhhvprqzxz9</sha1>
    </revision>
  </page>
  <page>
    <title>Charlize Theron</title>
    <ns>0</ns>
    <id>987</id>
    <revision>
      <id>5956</id>
      <timestamp>2025-11-08T18:52:39Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''U-Charlize  Theron''' umumuntu weSewula Afrika begodu omlingisi, nomenzi wamafilimu e-America. Umuntu okhona kwezokuzithabisa. Wabelthwa mhlana  amalanga ama-7 kuRhoboyi ngonyaka we-1975. Wabelethelwa endaweni ye Benoni, eSewula Afrika. U-theron wathoma ikhammbo lakhe le-Sterdom lathoma asesemcancani. Wakhulela  eplasini elingaphandle kwe Johannesburg, ekukulapho  athoma khona ukuba nethando lokudansa bewagcina sele afunda isikolweni senarha sobukghwari.&lt;ref&gt;https...&quot;</comment>
      <origin>5956</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2531" sha1="tc0plubv1509y61euunn2dcvabto6jj" xml:space="preserve">'''U-Charlize  Theron''' umumuntu weSewula Afrika begodu omlingisi, nomenzi wamafilimu e-America. Umuntu okhona kwezokuzithabisa. Wabelthwa mhlana  amalanga ama-7 kuRhoboyi ngonyaka we-1975. Wabelethelwa endaweni ye Benoni, eSewula Afrika. U-theron wathoma ikhammbo lakhe le-Sterdom lathoma asesemcancani. Wakhulela  eplasini elingaphandle kwe Johannesburg, ekukulapho  athoma khona ukuba nethando lokudansa bewagcina sele afunda isikolweni senarha sobukghwari.&lt;ref&gt;https://www.biography.com/actors/charlize-theron&lt;/ref&gt;

Ipilo ka Charlize Theron yaboakala ngokuthi ahluke begodu abe mumuntu akgona ukuza nemibona ehle. Uyise  kaCharlize Theron wabe asogola ngokulisa utjwala, begodu unina, uGerda wadlala india eqakathekileko yokubumba Amandla nokubekezela. Ubuhlungu bamehlela ngeskhathi aneminyaka eli-13, uyise wabulawa ngokuhlasela okufaka unina, owabe alinga ukuzivikela. Isehlakalo lesi saba nomthelela omkhulu epilweni yakhe senza bona agcine sele azinikele ekuthandeni ukudansa nokuthenii abe mlingisi.

Ibizelo lakhe lathoma ngokuthi abe yi modeli ekukulapho wathoma khona wathumba iphaliswano lekhaya elamenza wathola ithuba lokuba yimodeli e-Italy. Ngemva kwesikhathi wasuka waya  e-United States of America ukuthii ayokukwenza I ballet kodwana ngemva kokulimala idolo. Ukuphumelela kwakhe kwavela ngonyaka we19997 ngefilimu I”devil’s Advocates” phambi Keanu reeves ne-AI Pacini, kodwana into eyamenza bona adume khulu  kukuthi wakhe wadlala njongomlingisi ombulali wabantu abanengi angu Aileen Wuornos  ku “monster” ngonyaka we 2003. Sele athumbe a bonongorwana abanengi abafaka hlangana unongorwana we-A academy award otholwa babantu bengubo.

Ukuzimisela kwaka Theron  kuyabonakala ngombana uyazilungiselela lokha nakayokuba mlingisi othileko. Unekghono lokuthi abe adlale indima yabalingisi abahlukeneko begodu ayidlalel ngendlela  ezokuthabisa abantu. Lokho kwamenza bona abe  mumuntu ohloniphekako ku-Hollywood. Amanye amafilimu wakhe aziwako afaka “north country”, “Mad Max”, “Fury Road”, Atomic Bomb nezinye. Ukghona ukuba mlingisi wayo yoke imihlobo yemafillimi, ukkghona ukuba ngusomahlaya nofana womdlalo nokhunye.

Ipilo ka-Theron yazeka ngokuthi ukuzinikele ebantwaeni bakhe ababibili azikhethela boa ukungu-Jackson no- August. Njongo onganye umlingani akafihli ngeentjhijilo ahlangabezana begodu  uyakuthabela ukudllala indima yokuuba mbelelethi. Izinto ahlangabezene nazo selel angumama ngizo ezamkhuthaza bona acale iilo ngnenye indlela begodu athuthaze nabanye abantu.</text>
      <sha1>tc0plubv1509y61euunn2dcvabto6jj</sha1>
    </revision>
    <revision>
      <id>5957</id>
      <parentid>5956</parentid>
      <timestamp>2025-11-08T18:55:09Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5957</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2534" sha1="ggd0eojd8oku2hp8gk4h29abcmx1j8i" xml:space="preserve">'''U-Charlize  Theron''' umumuntu weSewula Afrika begodu omlingisi, nomenzi wamafilimu e-America. Umuntu okhona kwezokuzithabisa. Wabelthwa mhlana  amalanga ama-7 kuRhoboyi ngonyaka we-1975. Wabelethelwa endaweni ye Benoni, eSewula Afrika. U-theron wathoma ikhammbo lakhe le-Sterdom lathoma asesemcancani. Wakhulela  eplasini elingaphandle kwe Johannesburg, ekukulapho  athoma khona ukuba nethando lokudansa bewagcina sele afunda isikolweni senarha sobukghwari.&lt;ref&gt;https://www.biography.com/actors/charlize-theron&lt;/ref&gt;

Ipilo ka Charlize Theron yaboakala ngokuthi ahluke begodu abe mumuntu akgona ukuza nemibona ehle. Uyise  kaCharlize Theron wabe asogola ngokulisa utjwala, begodu unina, uGerda wadlala india eqakathekileko yokubumba Amandla nokubekezela. Ubuhlungu bamehlela ngeskhathi aneminyaka eli-13, uyise wabulawa ngokuhlasela okufaka unina, owabe alinga ukuzivikela. Isehlakalo lesi saba nomthelela omkhulu epilweni yakhe senza bona agcine sele azinikele ekuthandeni ukudansa nokuthenii abe mlingisi.

Ibizelo lakhe lathoma ngokuthi abe yi modeli ekukulapho wathoma khona wathumba iphaliswano lekhaya elamenza wathola ithuba lokuba yimodeli e-Italy. Ngemva kwesikhathi wasuka waya  e-United States of America ukuthi ayokukwenza I ballet kodwana ngemva kokulimala idolo. Ukuphumelela kwakhe kwavela ngonyaka we19997 ngefilimu I”devil’s Advocates” phambi kwe Keanu reeves ne-AI Pacini, kodwana into eyamenza bona adume khulu  kukuthi wakhe wadlala njongomlingisi ombulali wabantu abanengi angu Aileen Wuornos  ku “monster” ngonyaka we 2003. Sele athumbe a bonongorwana abanengi abafaka hlangana unongorwana we-A academy award otholwa babantu bengubo.

Ukuzimisela kwaka Theron  kuyabonakala ngombana uyazilungiselela lokha nakayokuba mlingisi othileko. Unekghono lokuthi abe adlale indima yabalingisi abahlukeneko begodu ayidlalel ngendlela  ezokuthabisa abantu. Lokho kwamenza bona abe  mumuntu ohloniphekako ku-Hollywood. Amanye amafilimu wakhe aziwako afaka “north country”, “Mad Max”, “Fury Road”, Atomic Bomb nezinye. Ukghona ukuba mlingisi wayo yoke imihlobo yemafillimi, ukkghona ukuba ngusomahlaya nofana womdlalo nokhunye.

Ipilo ka-Theron yazeka ngokuthi ukuzinikele ebantwaeni bakhe ababibili azikhethela boa ukungu-Jackson no- August. Njongo onganye umlingani akafihli ngeentjhijilo ahlangabezana begodu  uyakuthabela ukudllala indima yokuuba mbelelethi. Izinto ahlangabezene nazo selel angumama ngizo ezamkhuthaza bona acale iilo ngnenye indlela begodu athuthaze nabanye abantu.</text>
      <sha1>ggd0eojd8oku2hp8gk4h29abcmx1j8i</sha1>
    </revision>
    <revision>
      <id>5958</id>
      <parentid>5957</parentid>
      <timestamp>2025-11-08T19:01:13Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5958</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2741" sha1="k2lpcj0yoxokmtpt42gkj0zpp8uydlt" xml:space="preserve">'''U-Charlize  Theron''' umumuntu weSewula Afrika begodu omlingisi, nomenzi wamafilimu e-America. Umuntu okhona kwezokuzithabisa. Wabelthwa mhlana  amalanga ama-7 kuRhoboyi ngonyaka we-1975. Wabelethelwa endaweni ye Benoni, eSewula Afrika. U-theron wathoma ikhammbo lakhe le-Sterdom lathoma asesemcancani. Wakhulela  eplasini elingaphandle kwe Johannesburg, ekukulapho  athoma khona ukuba nethando lokudansa bewagcina sele afunda isikolweni senarha sobukghwari.&lt;ref&gt;https://www.biography.com/actors/charlize-theron&lt;/ref&gt;Ipilo ka Charlize Theron yaboakala ngokuthi ahluke begodu abe mumuntu akgona ukuza nemibona ehle. 

Uyise  kaCharlize Theron wabe asogola ngokulisa utjwala, begodu unina, uGerda wadlala indima eqakathekileko yokubumba Amandla nokubekezela.&lt;ref&gt;Prenter, T., van Niekerk, R. and Fouché, P.J., 2019. The amazing life of Charlize Theron. In ''New trends in psychobiography'' (pp. 463-479). Cham: Springer International Publishing.&lt;/ref&gt; Ubuhlungu bamehlela ngeskhathi aneminyaka eli-13, uyise wabulawa ngokuhlasela okufaka unina, owabe alinga ukuzivikela. Isehlakalo lesi saba nomthelela omkhulu epilweni yakhe senza bona agcine sele azinikele ekuthandeni ukudansa nokuthenii abe mlingisi.Ibizelo lakhe lathoma ngokuthi abe yi modeli ekukulapho wathoma khona wathumba iphaliswano lekhaya elamenza wathola ithuba lokuba yimodeli e-Italy.

Ngemva kwesikhathi wasuka waya  e-United States of America ukuthi ayokukwenza I ballet kodwana ngemva kokulimala idolo. Ukuphumelela kwakhe kwavela ngonyaka we1997 ngefilimu I”devil’s Advocates” phambi kwe Keanu reeves ne-AI Pacini, kodwana into eyamenza bona adume khulu  kukuthi wakhe wadlala njongomlingisi ombulali wabantu abanengi angu Aileen Wuornos  ku “monster” ngonyaka we 2003. Sele athumbe a bonongorwana abanengi abafaka hlangana unongorwana we-A academy award otholwa babantu bengubo.Ukuzimisela kwaka Theron  kuyabonakala ngombana uyazilungiselela lokha nakayokuba mlingisi othileko. Unekghono lokuthi abe adlale indima yabalingisi abahlukeneko begodu ayidlalel ngendlela  ezokuthabisa abantu. 

Lokho kwamenza bona abe  mumuntu ohloniphekako ku-Hollywood. Amanye amafilimu wakhe aziwako afaka “north country”, “Mad Max”, “Fury Road”, Atomic Bomb nezinye. Ukghona ukuba mlingisi wayo yoke imihlobo yemafillimi, ukkghona ukuba ngusomahlaya nofana womdlalo nokhunye.Ipilo ka-Theron yazeka ngokuthi ukuzinikele ebantwaeni bakhe ababibili azikhethela boa ukungu-Jackson no- August. Njongo onganye umlingani akafihli ngeentjhijilo ahlangabezana begodu  uyakuthabela ukudllala indima yokuuba mbelelethi. Izinto ahlangabezene nazo selel angumama ngizo ezamkhuthaza bona acale iilo ngnenye indlela begodu athuthaze nabanye abantu.

== Iinkomba ==</text>
      <sha1>k2lpcj0yoxokmtpt42gkj0zpp8uydlt</sha1>
    </revision>
    <revision>
      <id>5959</id>
      <parentid>5958</parentid>
      <timestamp>2025-11-08T19:04:01Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5959</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2809" sha1="00t6hd307pg1khkzgt0vvse0v0lx32z" xml:space="preserve">[[Isimumathi:Charlize-theron-IMG 6045.jpg|thumb|U-Charlize Theron]]
'''U-Charlize  Theron''' umumuntu weSewula Afrika begodu omlingisi, nomenzi wamafilimu e-America. Umuntu okhona kwezokuzithabisa. Wabelthwa mhlana  amalanga ama-7 kuRhoboyi ngonyaka we-1975. Wabelethelwa endaweni ye Benoni, eSewula Afrika. U-theron wathoma ikhammbo lakhe le-Sterdom lathoma asesemcancani. Wakhulela  eplasini elingaphandle kwe Johannesburg, ekukulapho  athoma khona ukuba nethando lokudansa bewagcina sele afunda isikolweni senarha sobukghwari.&lt;ref&gt;https://www.biography.com/actors/charlize-theron&lt;/ref&gt;Ipilo ka Charlize Theron yaboakala ngokuthi ahluke begodu abe mumuntu akgona ukuza nemibona ehle. 

Uyise  kaCharlize Theron wabe asogola ngokulisa utjwala, begodu unina, uGerda wadlala indima eqakathekileko yokubumba Amandla nokubekezela.&lt;ref&gt;Prenter, T., van Niekerk, R. and Fouché, P.J., 2019. The amazing life of Charlize Theron. In ''New trends in psychobiography'' (pp. 463-479). Cham: Springer International Publishing.&lt;/ref&gt; Ubuhlungu bamehlela ngeskhathi aneminyaka eli-13, uyise wabulawa ngokuhlasela okufaka unina, owabe alinga ukuzivikela. Isehlakalo lesi saba nomthelela omkhulu epilweni yakhe senza bona agcine sele azinikele ekuthandeni ukudansa nokuthenii abe mlingisi.Ibizelo lakhe lathoma ngokuthi abe yi modeli ekukulapho wathoma khona wathumba iphaliswano lekhaya elamenza wathola ithuba lokuba yimodeli e-Italy.

Ngemva kwesikhathi wasuka waya  e-United States of America ukuthi ayokukwenza I ballet kodwana ngemva kokulimala idolo. Ukuphumelela kwakhe kwavela ngonyaka we1997 ngefilimu I”devil’s Advocates” phambi kwe Keanu reeves ne-AI Pacini, kodwana into eyamenza bona adume khulu  kukuthi wakhe wadlala njongomlingisi ombulali wabantu abanengi angu Aileen Wuornos  ku “monster” ngonyaka we 2003. Sele athumbe a bonongorwana abanengi abafaka hlangana unongorwana we-A academy award otholwa babantu bengubo.Ukuzimisela kwaka Theron  kuyabonakala ngombana uyazilungiselela lokha nakayokuba mlingisi othileko. Unekghono lokuthi abe adlale indima yabalingisi abahlukeneko begodu ayidlalel ngendlela  ezokuthabisa abantu. 

Lokho kwamenza bona abe  mumuntu ohloniphekako ku-Hollywood. Amanye amafilimu wakhe aziwako afaka “north country”, “Mad Max”, “Fury Road”, Atomic Bomb nezinye. Ukghona ukuba mlingisi wayo yoke imihlobo yemafillimi, ukkghona ukuba ngusomahlaya nofana womdlalo nokhunye.Ipilo ka-Theron yazeka ngokuthi ukuzinikele ebantwaeni bakhe ababibili azikhethela boa ukungu-Jackson no- August. Njongo onganye umlingani akafihli ngeentjhijilo ahlangabezana begodu  uyakuthabela ukudllala indima yokuuba mbelelethi. Izinto ahlangabezene nazo selel angumama ngizo ezamkhuthaza bona acale iilo ngnenye indlela begodu athuthaze nabanye abantu.

== Iinkomba ==</text>
      <sha1>00t6hd307pg1khkzgt0vvse0v0lx32z</sha1>
    </revision>
    <revision>
      <id>5960</id>
      <parentid>5959</parentid>
      <timestamp>2025-11-08T19:04:54Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5960</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2813" sha1="8wzoaxsqr7fdgmucv8uy5e23az3qt3l" xml:space="preserve">[[Isimumathi:Charlize-theron-IMG 6045.jpg|thumb|U-Charlize Theron]]
'''U-Charlize  Theron''' umumuntu weSewula Afrika begodu omlingisi, nomenzi wamafilimu e-America. Umuntu okhona kwezokuzithabisa. Wabelethwa mhlana  amalanga ama-7 kuRhoboyi ngonyaka we-1975. Wabelethelwa endaweni ye Benoni, eSewula Afrika. U-theron wathoma ikhammbo lakhe le-Sterdom lathoma asesemcancani. Wakhulela  eplasini elingaphandle kwe Johannesburg, ekukulapho  athoma khona ukuba nethando lokudansa bewagcina sele afunda isikolweni senarha sobukghwari.&lt;ref&gt;https://www.biography.com/actors/charlize-theron&lt;/ref&gt;Ipilo ka Charlize Theron yabonakala ngokuthi ahluke begodu abe mumuntu akghona ukuza nemibono ehle. 

Uyise  kaCharlize Theron wabe asogola ngokulisa utjwala, begodu unina, uGerda wadlala indima eqakathekileko yokubumba Amandla nokubekezela.&lt;ref&gt;Prenter, T., van Niekerk, R. and Fouché, P.J., 2019. The amazing life of Charlize Theron. In ''New trends in psychobiography'' (pp. 463-479). Cham: Springer International Publishing.&lt;/ref&gt; Ubuhlungu bamehlela ngesikhathi aneminyaka eli-13, uyise wabulawa ngokuhlasela okufaka unina, owabe alinga ukuzivikela. Isehlakalo lesi saba nomthelela omkhulu epilweni yakhe senza bona agcine sele azinikele ekuthandeni ukudansa nokuthenii abe mlingisi.Ibizelo lakhe lathoma ngokuthi abe yi modeli ekukulapho wathoma khona wathumba iphaliswano lekhaya elamenza wathola ithuba lokuba yimodeli e-Italy.

Ngemva kwesikhathi wasuka waya  e-United States of America ukuthi ayokukwenza I ballet kodwana ngemva kokulimala idolo. Ukuphumelela kwakhe kwavela ngonyaka we1997 ngefilimu I”devil’s Advocates” phambi kwe Keanu reeves ne-AI Pacini, kodwana into eyamenza bona adume khulu  kukuthi wakhe wadlala njongomlingisi ombulali wabantu abanengi angu Aileen Wuornos  ku “monster” ngonyaka we 2003. Sele athumbe a bonongorwana abanengi abafaka hlangana unongorwana we-A academy award otholwa babantu bengubo.Ukuzimisela kwaka Theron  kuyabonakala ngombana uyazilungiselela lokha nakayokuba mlingisi othileko. Unekghono lokuthi abe adlale indima yabalingisi abahlukeneko begodu ayidlalel ngendlela  ezokuthabisa abantu. 

Lokho kwamenza bona abe  mumuntu ohloniphekako ku-Hollywood. Amanye amafilimu wakhe aziwako afaka “north country”, “Mad Max”, “Fury Road”, Atomic Bomb nezinye. Ukghona ukuba mlingisi wayo yoke imihlobo yemafillimi, ukkghona ukuba ngusomahlaya nofana womdlalo nokhunye.Ipilo ka-Theron yazeka ngokuthi ukuzinikele ebantwaeni bakhe ababibili azikhethela boa ukungu-Jackson no- August. Njongo onganye umlingani akafihli ngeentjhijilo ahlangabezana begodu  uyakuthabela ukudllala indima yokuuba mbelelethi. Izinto ahlangabezene nazo selel angumama ngizo ezamkhuthaza bona acale iilo ngnenye indlela begodu athuthaze nabanye abantu.

== Iinkomba ==</text>
      <sha1>8wzoaxsqr7fdgmucv8uy5e23az3qt3l</sha1>
    </revision>
    <revision>
      <id>5961</id>
      <parentid>5960</parentid>
      <timestamp>2025-11-08T19:07:21Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5961</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2860" sha1="5lgphst8i0w704c3mh8z9i4p4o3qjyj" xml:space="preserve">[[Isimumathi:Charlize-theron-IMG 6045.jpg|thumb|U-Charlize Theron]]
'''U-Charlize  Theron''' umumuntu weSewula Afrika begodu omlingisi, nomenzi wamafilimu e-America. Umuntu okhona kwezokuzithabisa. Wabelethwa mhlana  amalanga ama-7 kuRhoboyi ngonyaka we-1975. Wabelethelwa endaweni ye Benoni, eSewula Afrika. U-theron wathoma ikhammbo lakhe le-Sterdom lathoma asesemcancani. Wakhulela  eplasini elingaphandle kwe Johannesburg, ekukulapho  athoma khona ukuba nethando lokudansa bewagcina sele afunda isikolweni senarha sobukghwari.&lt;ref&gt;https://www.biography.com/actors/charlize-theron&lt;/ref&gt;Ipilo ka Charlize Theron yabonakala ngokuthi ahluke begodu abe mumuntu akghona ukuza nemibono ehle. 

Uyise  kaCharlize Theron wabe asogola ngokulisa utjwala, begodu unina, uGerda wadlala indima eqakathekileko yokubumba Amandla nokubekezela.&lt;ref&gt;Prenter, T., van Niekerk, R. and Fouché, P.J., 2019. The amazing life of Charlize Theron. In ''New trends in psychobiography'' (pp. 463-479). Cham: Springer International Publishing.&lt;/ref&gt; Ubuhlungu bamehlela ngesikhathi aneminyaka eli-13, uyise wabulawa ngokuhlasela okufaka unina, owabe alinga ukuzivikela. Isehlakalo lesi saba nomthelela omkhulu epilweni yakhe senza bona agcine sele azinikele ekuthandeni ukudansa nokuthenii abe mlingisi.Ibizelo lakhe lathoma ngokuthi abe yi modeli ekukulapho wathoma khona wathumba iphaliswano lekhaya elamenza wathola ithuba lokuba yimodeli e-Italy.

Ngemva kwesikhathi wasuka waya  e-United States of America ukuthi ayokukwenza I ballet kodwana ngemva kokulimala idolo. Ukuphumelela kwakhe kwavela ngonyaka we1997 ngefilimu I”devil’s Advocates” phambi kwe Keanu reeves ne-AI Pacini, kodwana into eyamenza bona adume khulu  kukuthi wakhe wadlala njongomlingisi ombulali wabantu abanengi angu Aileen Wuornos  ku “monster” ngonyaka we 2003. Sele athumbe a bonongorwana abanengi abafaka hlangana unongorwana we-A academy award otholwa babantu bengubo.Ukuzimisela kwaka Theron  kuyabonakala ngombana uyazilungiselela lokha nakayokuba mlingisi othileko. Unekghono lokuthi abe adlale indima yabalingisi abahlukeneko begodu ayidlalel ngendlela  ezokuthabisa abantu. 

Lokho kwamenza bona abe  mumuntu ohloniphekako ku-Hollywood. Amanye amafilimu wakhe aziwako afaka “north country”, “Mad Max”, “Fury Road”, Atomic Bomb nezinye. Ukghona ukuba mlingisi wayo yoke imihlobo yemafillimi, ukkghona ukuba ngusomahlaya nofana womdlalo nokhunye.Ipilo ka-Theron yazeka ngokuthi ukuzinikele ebantwaeni bakhe ababibili azikhethela boa ukungu-Jackson no- August. Njongo onganye umlingani akafihli ngeentjhijilo ahlangabezana begodu  uyakuthabela ukudllala indima yokuuba mbelelethi. Izinto ahlangabezene nazo selel angumama ngizo ezamkhuthaza bona acale iilo ngnenye indlela begodu athuthaze nabanye abantu.

== Iinkomba ==
[[Category:Abalingisi]]
[[Category:Amafilimu]]</text>
      <sha1>5lgphst8i0w704c3mh8z9i4p4o3qjyj</sha1>
    </revision>
    <revision>
      <id>5962</id>
      <parentid>5961</parentid>
      <timestamp>2025-11-08T19:09:09Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5962</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2865" sha1="akxfakqs8ke9z54axe4gwa3g6xysh9t" xml:space="preserve">[[Isimumathi:Charlize-theron-IMG 6045.jpg|thumb|U-Charlize Theron]]
'''U-Charlize  Theron''' umumuntu weSewula Afrika begodu omlingisi, nomenzi wamafilimu e-America. Umuntu okhona kwezokuzithabisa. Wabelethwa mhlana  amalanga ama-7 kuRhoboyi ngonyaka we-1975. Wabelethelwa endaweni ye Benoni, eSewula Afrika. U-theron wathoma ikhammbo lakhe le-Sterdom lathoma asesemcancani. Wakhulela  eplasini elingaphandle kwe Johannesburg, ekukulapho  athoma khona ukuba nethando lokudansa bewagcina sele afunda isikolweni senarha sobukghwari.&lt;ref&gt;https://www.biography.com/actors/charlize-theron&lt;/ref&gt;Ipilo ka Charlize Theron yabonakala ngokuthi ahluke begodu abe mumuntu akghona ukuza nemibono ehle. 

Uyise  kaCharlize Theron wabe asogola ngokulisa utjwala, begodu unina, uGerda wadlala indima eqakathekileko yokubumba Amandla nokubekezela.&lt;ref&gt;Prenter, T., van Niekerk, R. and Fouché, P.J., 2019. The amazing life of Charlize Theron. In ''New trends in psychobiography'' (pp. 463-479). Cham: Springer International Publishing.&lt;/ref&gt; Ubuhlungu bamehlela ngesikhathi aneminyaka eli-13, uyise wabulawa ngokuhlasela okufaka unina, owabe alinga ukuzivikela. Isehlakalo lesi saba nomthelela omkhulu epilweni yakhe senza bona agcine sele azinikele ekuthandeni ukudansa nokuthenii abe mlingisi.Ibizelo lakhe lathoma ngokuthi abe yi modeli ekukulapho wathoma khona wathumba iphaliswano lekhaya elamenza wathola ithuba lokuba yimodeli e-Italy.

Ngemva kwesikhathi wasuka waya  e-United States of America ukuthi ayokukwenza I ballet kodwana ngemva kokulimala idolo. Ukuphumelela kwakhe kwavela ngonyaka we1997 ngefilimu I”devil’s Advocates” phambi kwe Keanu reeves ne-AI Pacini, kodwana into eyamenza bona adume khulu  kukuthi wakhe wadlala njongomlingisi ombulali wabantu abanengi angu Aileen Wuornos  ku “monster” ngonyaka we 2003. Sele athumbe a bonongorwana abanengi abafaka hlangana unongorwana we-A academy award otholwa babantu bengubo.Ukuzimisela kwaka Theron  kuyabonakala ngombana uyazilungiselela lokha nakayokuba mlingisi othileko. Unekghono lokuthi abe adlale indima yabalingisi abahlukeneko begodu ayidlalel ngendlela  ezokuthabisa abantu. 

Lokho kwamenza bona abe  mumuntu ohloniphekako ku-Hollywood. Amanye amafilimu wakhe aziwako afaka “north country”, “Mad Max”, “Fury Road”, Atomic Bomb nezinye. Ukghona ukuba mlingisi wayo yoke imihlobo yemafillimi, ukkghona ukuba ngusomahlaya nofana womdlalo nokhunye.Ipilo ka-Theron yazeka ngokuthi ukuzinikele ebantwaeni bakhe ababibili azikhethela boa ukungu-Jackson no- August. Njongomuntu onganaye umlingani akafihli ngeentjhijilo ahlangabezana begodu  uyakuthabela ukudllala indima yokuuba mbelelethi. Izinto ahlangabezene nazo sele angumama ngizo ezamkhuthaza bona acale iilo ngnenye indlela begodu athuthaze nabanye abantu.

== Iinkomba ==
[[Category:Abalingisi]]
[[Category:Amafilimu]]</text>
      <sha1>akxfakqs8ke9z54axe4gwa3g6xysh9t</sha1>
    </revision>
    <revision>
      <id>5963</id>
      <parentid>5962</parentid>
      <timestamp>2025-11-08T19:40:59Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5963</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2862" sha1="ji0j3xm7ecoyuua10n0ssu53eu7p85q" xml:space="preserve">[[Isimumathi:Charlize-theron-IMG 6045.jpg|thumb|U-Charlize Theron]]
'''U-Charlize  Theron''' umumuntu weSewula Afrika begodu omlingisi, nomenzi wamafilimu e-America. Umuntu okhona kwezokuzithabisa. Wabelethwa mhlana  amalanga ama-7 kuRhoboyi ngonyaka we-1975. Wabelethelwa endaweni ye Benoni, eSewula Afrika. U-theron wathoma ikhammbo lakhe le-Sterdom lathoma asesemcancani. Wakhulela  eplasini elingaphandle kwe Johannesburg, ekukulapho  athoma khona ukuba nethando lokudansa bewagcina sele afunda isikolweni senarha sobukghwari.&lt;ref&gt;https://www.biography.com/actors/charlize-theron&lt;/ref&gt;Ipilo ka Charlize Theron yabonakala ngokuthi ahluke begodu abe mumuntu akghona ukuza nemibono ehle. 

Uyise  ka-Charlize Theron wabe asogola ngokulisa utjwala, begodu unina, uGerda wadlala indima eqakathekileko yokubumba Amandla nokubekezela.&lt;ref&gt;Prenter, T., van Niekerk, R. and Fouché, P.J., 2019. The amazing life of Charlize Theron. In ''New trends in psychobiography'' (pp. 463-479). Cham: Springer International Publishing.&lt;/ref&gt; Ubuhlungu bamehlela ngesikhathi aneminyaka eli-13, uyise wabulawa ngokuhlasela okufaka unina, owabe alinga ukuzivikela. Isehlakalo lesi saba nomthelela omkhulu epilweni yakhe senza bona agcine sele azinikele ekuthandeni ukudansa nokuthenii abe mlingisi.Ibizelo lakhe lathoma ngokuthi abe yi modeli ekukulapho wathoma khona wathumba iphaliswano lekhaya elamenza wathola ithuba lokuba yimodeli e-Italy.

Ngemva kwesikhathi wasuka waya  e-United States of America ukuthi ayokukwenza I ballet kodwana ngemva kokulimala idolo. Ukuphumelela kwakhe kwavela ngonyaka we1997 ngefilimu I”devil’s Advocates” phambi kwe Keanu reeves ne-AI Pacini, kodwana into eyamenza bona adume khulu  kukuthi wakhe wadlala njongomlingisi ombulali wabantu abanengi angu Aileen Wuornos  ku “monster” ngonyaka we 2003. Sele athumbe abonongorwana abanengi abafaka hlangana unongorwana we-A academy award otholwa babantu bengubo.Ukuzimisela kwaka Theron  kuyabonakala ngombana uyazilungiselela lokha nakayokuba mlingisi othileko. Unekghono lokuthi abe adlale indima yabalingisi abahlukeneko begodu ayidlalel ngendlela  ezokuthabisa abantu. 

Lokho kwamenza bona abe  mumuntu ohloniphekako ku-Hollywood. Amanye amafilimu wakhe aziwako afaka “north country”, “Mad Max”, “Fury Road”, Atomic Bomb nezinye. Ukghona ukuba mlingisi wayo yoke imihlobo yemafillimi, ukghona ukuba ngusomahlaya nofana womdlalo nokhunye.Ipilo ka-Theron yazeka ngokuthi ukuzinikele ebantwaneni bakhe ababibili azikhethela bona ukungu-Jackson no- August. Njongomuntu onganaye umlingani akafihli ngeentjhijilo ahlangabezana begodu  uyakuthabela ukudlala indima yokuba mbelethi. Izinto ahlangabezene nazo sele angumama ngizo ezamkhuthaza bona acale ipilo ngenye indlela begodu akhuthaze nabanye abantu.

== Iinkomba ==
[[Category:Abalingisi]]
[[Category:Amafilimu]]</text>
      <sha1>ji0j3xm7ecoyuua10n0ssu53eu7p85q</sha1>
    </revision>
    <revision>
      <id>5964</id>
      <parentid>5963</parentid>
      <timestamp>2025-11-08T19:42:11Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5964</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2975" sha1="apgb1v53m5yv1dekt4c1ycgtu1cz5iz" xml:space="preserve">[[Isimumathi:Charlize-theron-IMG 6045.jpg|thumb|U-Charlize Theron]]
'''U-Charlize  Theron''' umumuntu weSewula Afrika begodu omlingisi, nomenzi wamafilimu e-America. Umuntu okhona kwezokuzithabisa. Wabelethwa mhlana  amalanga ama-7 kuRhoboyi ngonyaka we-1975. Wabelethelwa endaweni ye Benoni, eSewula Afrika. U-theron wathoma ikhammbo lakhe le-Sterdom lathoma asesemcancani. Wakhulela  eplasini elingaphandle kwe Johannesburg, ekukulapho  athoma khona ukuba nethando lokudansa bewagcina sele afunda isikolweni senarha sobukghwari.&lt;ref&gt;https://www.biography.com/actors/charlize-theron&lt;/ref&gt;Ipilo ka Charlize Theron yabonakala ngokuthi ahluke begodu abe mumuntu akghona ukuza nemibono ehle. 

Uyise  ka-Charlize Theron wabe asogola ngokulisa utjwala, begodu unina, uGerda wadlala indima eqakathekileko yokubumba Amandla nokubekezela.&lt;ref&gt;Prenter, T., van Niekerk, R. and Fouché, P.J., 2019. The amazing life of Charlize Theron. In ''New trends in psychobiography'' (pp. 463-479). Cham: Springer International Publishing.&lt;/ref&gt; Ubuhlungu bamehlela ngesikhathi aneminyaka eli-13, uyise wabulawa ngokuhlasela okufaka unina, owabe alinga ukuzivikela. Isehlakalo lesi saba nomthelela omkhulu epilweni yakhe senza bona agcine sele azinikele ekuthandeni ukudansa nokuthenii abe mlingisi.Ibizelo lakhe lathoma ngokuthi abe yi modeli ekukulapho wathoma khona wathumba iphaliswano lekhaya elamenza wathola ithuba lokuba yimodeli e-Italy.

Ngemva kwesikhathi wasuka waya  e-United States of America ukuthi ayokukwenza I ballet kodwana ngemva kokulimala idolo. Ukuphumelela kwakhe kwavela ngonyaka we1997 ngefilimu I”devil’s Advocates” phambi kwe Keanu reeves ne-AI Pacini, kodwana into eyamenza bona adume khulu  kukuthi wakhe wadlala njongomlingisi ombulali wabantu abanengi angu Aileen Wuornos  ku “monster” ngonyaka we 2003.&lt;ref&gt;Theron, C., 2012. Charlize Theron. ''Fotogramas &amp; DVD: La primera revista de cine'', (2026), pp.72-75.&lt;/ref&gt; Sele athumbe abonongorwana abanengi abafaka hlangana unongorwana we-A academy award otholwa babantu bengubo.Ukuzimisela kwaka Theron  kuyabonakala ngombana uyazilungiselela lokha nakayokuba mlingisi othileko. Unekghono lokuthi abe adlale indima yabalingisi abahlukeneko begodu ayidlalel ngendlela  ezokuthabisa abantu. 

Lokho kwamenza bona abe  mumuntu ohloniphekako ku-Hollywood. Amanye amafilimu wakhe aziwako afaka “north country”, “Mad Max”, “Fury Road”, Atomic Bomb nezinye. Ukghona ukuba mlingisi wayo yoke imihlobo yemafillimi, ukghona ukuba ngusomahlaya nofana womdlalo nokhunye.Ipilo ka-Theron yazeka ngokuthi ukuzinikele ebantwaneni bakhe ababibili azikhethela bona ukungu-Jackson no- August. Njongomuntu onganaye umlingani akafihli ngeentjhijilo ahlangabezana begodu  uyakuthabela ukudlala indima yokuba mbelethi. Izinto ahlangabezene nazo sele angumama ngizo ezamkhuthaza bona acale ipilo ngenye indlela begodu akhuthaze nabanye abantu.

== Iinkomba ==
[[Category:Abalingisi]]
[[Category:Amafilimu]]</text>
      <sha1>apgb1v53m5yv1dekt4c1ycgtu1cz5iz</sha1>
    </revision>
    <revision>
      <id>5965</id>
      <parentid>5964</parentid>
      <timestamp>2025-11-08T19:43:31Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5965</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2974" sha1="gkas8wz54qbl9ohvy8ul6lxl74370av" xml:space="preserve">[[Isimumathi:Charlize-theron-IMG 6045.jpg|thumb|U-Charlize Theron]]
'''U-Charlize  Theron''' umumuntu weSewula Afrika begodu omlingisi, nomenzi wamafilimu e-America. Umuntu okhona kwezokuzithabisa. Wabelethwa mhlana  amalanga ama-7 kuRhoboyi ngonyaka we-1975. Wabelethelwa endaweni ye Benoni, eSewula Afrika. U-Theron wathoma ikhambo lakhe le-Sterdom lathoma asesemcancani. Wakhulela  eplasini elingaphandle kwe Johannesburg, ekukulapho  athoma khona ukuba nethando lokudansa bewagcina sele afunda isikolweni senarha sobukghwari.&lt;ref&gt;https://www.biography.com/actors/charlize-theron&lt;/ref&gt;Ipilo ka Charlize Theron yabonakala ngokuthi ahluke begodu abe mumuntu akghona ukuza nemibono ehle. 

Uyise  ka-Charlize Theron wabe asogola ngokulisa utjwala, begodu unina, uGerda wadlala indima eqakathekileko yokubumba Amandla nokubekezela.&lt;ref&gt;Prenter, T., van Niekerk, R. and Fouché, P.J., 2019. The amazing life of Charlize Theron. In ''New trends in psychobiography'' (pp. 463-479). Cham: Springer International Publishing.&lt;/ref&gt; Ubuhlungu bamehlela ngesikhathi aneminyaka eli-13, uyise wabulawa ngokuhlasela okufaka unina, owabe alinga ukuzivikela. Isehlakalo lesi saba nomthelela omkhulu epilweni yakhe senza bona agcine sele azinikele ekuthandeni ukudansa nokuthenii abe mlingisi.Ibizelo lakhe lathoma ngokuthi abe yi modeli ekukulapho wathoma khona wathumba iphaliswano lekhaya elamenza wathola ithuba lokuba yimodeli e-Italy.

Ngemva kwesikhathi wasuka waya  e-United States of America ukuthi ayokukwenza I ballet kodwana ngemva kokulimala idolo. Ukuphumelela kwakhe kwavela ngonyaka we1997 ngefilimu I”devil’s Advocates” phambi kwe Keanu reeves ne-AI Pacini, kodwana into eyamenza bona adume khulu  kukuthi wakhe wadlala njongomlingisi ombulali wabantu abanengi angu Aileen Wuornos  ku “monster” ngonyaka we 2003.&lt;ref&gt;Theron, C., 2012. Charlize Theron. ''Fotogramas &amp; DVD: La primera revista de cine'', (2026), pp.72-75.&lt;/ref&gt; Sele athumbe abonongorwana abanengi abafaka hlangana unongorwana we-A academy award otholwa babantu bengubo.Ukuzimisela kwaka Theron  kuyabonakala ngombana uyazilungiselela lokha nakayokuba mlingisi othileko. Unekghono lokuthi abe adlale indima yabalingisi abahlukeneko begodu ayidlalel ngendlela  ezokuthabisa abantu. 

Lokho kwamenza bona abe  mumuntu ohloniphekako ku-Hollywood. Amanye amafilimu wakhe aziwako afaka “north country”, “Mad Max”, “Fury Road”, Atomic Bomb nezinye. Ukghona ukuba mlingisi wayo yoke imihlobo yemafillimi, ukghona ukuba ngusomahlaya nofana womdlalo nokhunye.Ipilo ka-Theron yazeka ngokuthi ukuzinikele ebantwaneni bakhe ababibili azikhethela bona ukungu-Jackson no- August. Njongomuntu onganaye umlingani akafihli ngeentjhijilo ahlangabezana begodu  uyakuthabela ukudlala indima yokuba mbelethi. Izinto ahlangabezene nazo sele angumama ngizo ezamkhuthaza bona acale ipilo ngenye indlela begodu akhuthaze nabanye abantu.

== Iinkomba ==
[[Category:Abalingisi]]
[[Category:Amafilimu]]</text>
      <sha1>gkas8wz54qbl9ohvy8ul6lxl74370av</sha1>
    </revision>
    <revision>
      <id>5989</id>
      <parentid>5965</parentid>
      <timestamp>2025-11-15T15:04:13Z</timestamp>
      <contributor>
        <username>Dumbassman</username>
        <id>1091</id>
      </contributor>
      <minor />
      <comment>removed unnecessary spaces</comment>
      <origin>5989</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2954" sha1="540uiv7x2ku1vbse532l081yemlyudl" xml:space="preserve">[[Isimumathi:Charlize-theron-IMG 6045.jpg|thumb|U-Charlize Theron]]
'''U-Charlize Theron''' umumuntu weSewula Afrika begodu omlingisi, nomenzi wamafilimu e-America. Umuntu okhona kwezokuzithabisa. Wabelethwa mhlana amalanga ama-7 kuRhoboyi ngonyaka we-1975. Wabelethelwa endaweni ye Benoni, eSewula Afrika. U-Theron wathoma ikhambo lakhe le-Sterdom lathoma asesemcancani. Wakhulela eplasini elingaphandle kwe Johannesburg, ekukulapho athoma khona ukuba nethando lokudansa bewagcina sele afunda isikolweni senarha sobukghwari.&lt;ref&gt;https://www.biography.com/actors/charlize-theron&lt;/ref&gt;Ipilo ka Charlize Theron yabonakala ngokuthi ahluke begodu abe mumuntu akghona ukuza nemibono ehle. 

Uyise ka-Charlize Theron wabe asogola ngokulisa utjwala, begodu unina, uGerda wadlala indima eqakathekileko yokubumba Amandla nokubekezela.&lt;ref&gt;Prenter, T., van Niekerk, R. and Fouché, P.J., 2019. The amazing life of Charlize Theron. In ''New trends in psychobiography'' (pp. 463-479). Cham: Springer International Publishing.&lt;/ref&gt; Ubuhlungu bamehlela ngesikhathi aneminyaka eli-13, uyise wabulawa ngokuhlasela okufaka unina, owabe alinga ukuzivikela. Isehlakalo lesi saba nomthelela omkhulu epilweni yakhe senza bona agcine sele azinikele ekuthandeni ukudansa nokuthenii abe mlingisi.Ibizelo lakhe lathoma ngokuthi abe yi modeli ekukulapho wathoma khona wathumba iphaliswano lekhaya elamenza wathola ithuba lokuba yimodeli e-Italy.

Ngemva kwesikhathi wasuka waya e-United States of America ukuthi ayokukwenza I ballet kodwana ngemva kokulimala idolo. Ukuphumelela kwakhe kwavela ngonyaka we1997 ngefilimu I”devil’s Advocates” phambi kwe Keanu reeves ne-AI Pacini, kodwana into eyamenza bona adume khulu kukuthi wakhe wadlala njongomlingisi ombulali wabantu abanengi angu Aileen Wuornos ku “monster” ngonyaka we 2003.&lt;ref&gt;Theron, C., 2012. Charlize Theron. ''Fotogramas &amp; DVD: La primera revista de cine'', (2026), pp.72-75.&lt;/ref&gt; Sele athumbe abonongorwana abanengi abafaka hlangana unongorwana we-A academy award otholwa babantu bengubo.Ukuzimisela kwaka Theron kuyabonakala ngombana uyazilungiselela lokha nakayokuba mlingisi othileko. Unekghono lokuthi abe adlale indima yabalingisi abahlukeneko begodu ayidlalel ngendlela ezokuthabisa abantu.

Lokho kwamenza bona abe mumuntu ohloniphekako ku-Hollywood. Amanye amafilimu wakhe aziwako afaka “north country”, “Mad Max”, “Fury Road”, Atomic Bomb nezinye. Ukghona ukuba mlingisi wayo yoke imihlobo yemafillimi, ukghona ukuba ngusomahlaya nofana womdlalo nokhunye.Ipilo ka-Theron yazeka ngokuthi ukuzinikele ebantwaneni bakhe ababibili azikhethela bona ukungu-Jackson no- August. Njongomuntu onganaye umlingani akafihli ngeentjhijilo ahlangabezana begodu uyakuthabela ukudlala indima yokuba mbelethi. Izinto ahlangabezene nazo sele angumama ngizo ezamkhuthaza bona acale ipilo ngenye indlela begodu akhuthaze nabanye abantu.

== Iinkomba ==
[[Category:Abalingisi]]
[[Category:Amafilimu]]</text>
      <sha1>540uiv7x2ku1vbse532l081yemlyudl</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:我是啊啊啊啊啊啊啊啊啊啊</title>
    <ns>2</ns>
    <id>988</id>
    <revision>
      <id>5966</id>
      <timestamp>2025-11-08T20:54:38Z</timestamp>
      <contributor>
        <username>我是啊啊啊啊啊啊啊啊啊啊</username>
        <id>1110</id>
      </contributor>
      <comment>Created page with &quot;Ngingumsebenzisi we-China.&quot;</comment>
      <origin>5966</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="26" sha1="jzm23jw1way3mrsfjigvmkyxv71rpf3" xml:space="preserve">Ngingumsebenzisi we-China.</text>
      <sha1>jzm23jw1way3mrsfjigvmkyxv71rpf3</sha1>
    </revision>
  </page>
  <page>
    <title>Ukubulawa kwabafazi nabantwana eSewula Afrika</title>
    <ns>0</ns>
    <id>990</id>
    <revision>
      <id>5970</id>
      <timestamp>2025-11-10T06:03:38Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <comment>ADDED PICS</comment>
      <origin>5970</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2360" sha1="059f5qw6rieqm6cn3qg8qktiqm01za1" xml:space="preserve">[https://womenforchange.co&lt;!-- EDIT BELOW THIS LINE --&gt;
Ukubulawa kwabafazi eSewula Afrika sekuyinto yangamalanga. Isibalo esikhona sitjengisa bona abafazi nabantwana bayagagadlhelwa bebabulawe mndeni nofana mumuntu obaziko, lokhu kwenzeka qobe imizuzu elitjhumi elangeni ephasini loke jikelele bese eSewula Afrika abafazi abaziingidi ezilihlanu namakhulu amahlanu bayabulawa. Isibalwesi sakhutjhwa ngomnyaka wee-2020 ukuya kumnyaka wee-2021. [[https://www.unwomen.org/en/news-stories/feature-story/2024/11/tackling-femicide-in-south-africa-through-laws-policies-and-better-policing]] 
[[File:GBV.jpg|thumb|GBV]]
Ngeveke yokuthoma kaSinyikhaba ngomnyaka wee-2025 abantu abatjha eenkundleni zokuthintana njenge-Facebook ne-TikTok bathome ijima lokulwisana naso isigesi. Ihlangano eyaziwa khulu ngokulwela ilungelo lokuphila labafazi eSewula Afrika ebizwa bona yi-Women for Change ngiyo edosa phambili ijimeli. Ihlangano le ayilweli abafazi kwaphela kodwana ilwela nabantwana kanye namadoda, woke umuntu obuleweko iyamulwela begodu koke lokhu bakwenza khulu eenkundleni zokuthintana ngokusunduza ijima elithize. Njenganje bathome ijima lokobana woke umuntu agadangise isithombe sombala omsobo ukuze urhulumende amemezele bekavume bona ukubulawa kwabafazi kube yihlekelele yesitjhaba, kanti-ke abantu abanengi basabele benza njalo. [https://www.timeslive.co.za/news/south-africa/2025-11-09-we-bury-a-woman-every-25-hours-women-for-change-calls-for-national-shutdown-ahead-of-g20/]

I-Women For Change le yasungulwa ngomnyaka wee-2016, basebenzisa amandla aseenkundleni zokuthintana ukuyelelisa abantu boke ngokuhlukumezana ngokobulili kanye nokubulawa kwabafazi eSewula Afrika. Ayigcini lapho, ihlangano le ibuye isekele laba abasindileko beyisunduze itjhuguluko lamambala emphakathini. [https://womenforchange.co.za] 

Okhunye okukhona kukuthi kuphume iphepha lomoya (eliku-inthanethi) lesibawo lokuthi abantu batlikitle ukuze urhulumende asivume isibawo sokuthi ukubulawa kwabafazi kube yihlekelele yesitjhaba. Kanti-ke kuhlelwa nokuthi mhlazana amalanga ama-21 kuSinyikhaba ngomnyaka wona esiphezu kwawo lo kuzokuvalwa yoke into, kungabi nento eyenziwako, woke umuntu ahlale ekhaya - abasebenzako bangayi emsebenzini bese abafundi bangayi neenkolweni. Lokhu ngelimi lesiyeni ibizwa bona yi-national shut down. [https://womenforchange.co.za/g20-women-shutdown/]</text>
      <sha1>059f5qw6rieqm6cn3qg8qktiqm01za1</sha1>
    </revision>
    <revision>
      <id>5971</id>
      <parentid>5970</parentid>
      <timestamp>2025-11-10T06:04:15Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <origin>5971</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2305" sha1="4xivbl66cy8sksllmnlzf9vff1gboh4" xml:space="preserve">[Ukubulawa kwabafazi eSewula Afrika sekuyinto yangamalanga. Isibalo esikhona sitjengisa bona abafazi nabantwana bayagagadlhelwa bebabulawe mndeni nofana mumuntu obaziko, lokhu kwenzeka qobe imizuzu elitjhumi elangeni ephasini loke jikelele bese eSewula Afrika abafazi abaziingidi ezilihlanu namakhulu amahlanu bayabulawa. Isibalwesi sakhutjhwa ngomnyaka wee-2020 ukuya kumnyaka wee-2021. [[https://www.unwomen.org/en/news-stories/feature-story/2024/11/tackling-femicide-in-south-africa-through-laws-policies-and-better-policing]] 
[[File:GBV.jpg|thumb|GBV]]
Ngeveke yokuthoma kaSinyikhaba ngomnyaka wee-2025 abantu abatjha eenkundleni zokuthintana njenge-Facebook ne-TikTok bathome ijima lokulwisana naso isigesi. Ihlangano eyaziwa khulu ngokulwela ilungelo lokuphila labafazi eSewula Afrika ebizwa bona yi-Women for Change ngiyo edosa phambili ijimeli. Ihlangano le ayilweli abafazi kwaphela kodwana ilwela nabantwana kanye namadoda, woke umuntu obuleweko iyamulwela begodu koke lokhu bakwenza khulu eenkundleni zokuthintana ngokusunduza ijima elithize. Njenganje bathome ijima lokobana woke umuntu agadangise isithombe sombala omsobo ukuze urhulumende amemezele bekavume bona ukubulawa kwabafazi kube yihlekelele yesitjhaba, kanti-ke abantu abanengi basabele benza njalo. [https://www.timeslive.co.za/news/south-africa/2025-11-09-we-bury-a-woman-every-25-hours-women-for-change-calls-for-national-shutdown-ahead-of-g20/]

I-Women For Change le yasungulwa ngomnyaka wee-2016, basebenzisa amandla aseenkundleni zokuthintana ukuyelelisa abantu boke ngokuhlukumezana ngokobulili kanye nokubulawa kwabafazi eSewula Afrika. Ayigcini lapho, ihlangano le ibuye isekele laba abasindileko beyisunduze itjhuguluko lamambala emphakathini. [https://womenforchange.co.za] 

Okhunye okukhona kukuthi kuphume iphepha lomoya (eliku-inthanethi) lesibawo lokuthi abantu batlikitle ukuze urhulumende asivume isibawo sokuthi ukubulawa kwabafazi kube yihlekelele yesitjhaba. Kanti-ke kuhlelwa nokuthi mhlazana amalanga ama-21 kuSinyikhaba ngomnyaka wona esiphezu kwawo lo kuzokuvalwa yoke into, kungabi nento eyenziwako, woke umuntu ahlale ekhaya - abasebenzako bangayi emsebenzini bese abafundi bangayi neenkolweni. Lokhu ngelimi lesiyeni ibizwa bona yi-national shut down. [https://womenforchange.co.za/g20-women-shutdown/]</text>
      <sha1>4xivbl66cy8sksllmnlzf9vff1gboh4</sha1>
    </revision>
    <revision>
      <id>5972</id>
      <parentid>5971</parentid>
      <timestamp>2025-11-10T06:20:29Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <origin>5972</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2321" sha1="lmnjug237i6rpk1inxvl1y8loislgkk" xml:space="preserve">Ukubulawa kwabafazi eSewula Afrika sekuyinto yangamalanga. Isibalo esikhona sitjengisa bona abafazi nabantwana bayagagadlhelwa bebabulawe mndeni nofana mumuntu obaziko, lokhu kwenzeka qobe imizuzu elitjhumi elangeni ephasini loke jikelele bese eSewula Afrika abafazi abaziingidi ezilihlanu namakhulu amahlanu bayabulawa. Isibalwesi sakhutjhwa ngomnyaka wee-2020 ukuya kumnyaka wee-2021. [[https://www.unwomen.org/en/news-stories/feature-story/2024/11/tackling-femicide-in-south-africa-through-laws-policies-and-better-policing]] 
[[File:GBV.jpg|thumb|GBV]]
Ngeveke yokuthoma kaSinyikhaba ngomnyaka wee-2025 abantu abatjha eenkundleni zokuthintana njenge-Facebook ne-TikTok bathome ijima lokulwisana naso isigesi. Ihlangano eyaziwa khulu ngokulwela ilungelo lokuphila labafazi eSewula Afrika ebizwa bona yi-Women for Change ngiyo edosa phambili ijimeli. Ihlangano le ayilweli abafazi kwaphela kodwana ilwela nabantwana kanye namadoda, woke umuntu obuleweko iyamulwela begodu koke lokhu bakwenza khulu eenkundleni zokuthintana ngokusunduza ijima elithize. Njenganje bathome ijima lokobana woke umuntu agadangise isithombe sombala omsobo ukuze urhulumende amemezele bekavume bona ukubulawa kwabafazi kube yihlekelele yesitjhaba, kanti-ke abantu abanengi basabele benza njalo. [https://www.timeslive.co.za/news/south-africa/2025-11-09-we-bury-a-woman-every-25-hours-women-for-change-calls-for-national-shutdown-ahead-of-g20/]

I-Women For Change le yasungulwa ngomnyaka wee-2016, basebenzisa amandla aseenkundleni zokuthintana ukuyelelisa abantu boke ngokuhlukumezana ngokobulili kanye nokubulawa kwabafazi eSewula Afrika. Ayigcini lapho, ihlangano le ibuye isekele laba abasindileko beyisunduze itjhuguluko lamambala emphakathini. [https://womenforchange.co.za] 

Okhunye okukhona kukuthi kuphume iphepha lomoya (eliku-inthanethi) lesibawo lokuthi abantu batlikitle ukuze urhulumende asivume isibawo sokuthi ukubulawa kwabafazi kube yihlekelele yesitjhaba. Kanti-ke kuhlelwa nokuthi mhlazana amalanga ama-21 kuSinyikhaba ngomnyaka wona esiphezu kwawo lo kuzokuvalwa yoke into, kungabi nento eyenziwako, woke umuntu ahlale ekhaya - abasebenzako bangayi emsebenzini bese abafundi bangayi neenkolweni. Lokhu ngelimi lesiyeni ibizwa bona yi-national shut down. [https://womenforchange.co.za/g20-women-shutdown/]

== IMIKHOMBA ==</text>
      <sha1>lmnjug237i6rpk1inxvl1y8loislgkk</sha1>
    </revision>
    <revision>
      <id>6097</id>
      <parentid>5972</parentid>
      <timestamp>2025-12-19T17:40:27Z</timestamp>
      <contributor>
        <username>~2025-41814-16</username>
        <id>1235</id>
      </contributor>
      <origin>6097</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2318" sha1="38jio35k0s1wnxu3598qo9o6e9tsru3" xml:space="preserve">Ukubulawa kwabafazi eSewula Afrika sekuyinto yangamalanga. Isibalo esikhona sitjengisa bona abafazi nabantwana bayagagadlhelwa bebabulawe mndeni nofana mumuntu obaziko, lokhu kwenzeka qobe imizuzu elitjhumi elangeni ephasini loke jikelele bese eSewula Afrika abafazi abaziingidi ezilihlanu namakhulu amahlanu bayabulawa. Isibalwesi sakhutjhwa ngomnyaka wee-2020 ukuya kumnyaka wee-2021 [https://www.unwomen.org/en/news-stories/feature-story/2024/11/tackling-femicide-in-south-africa-through-laws-policies-and-better-policing]. 
[[File:GBV.jpg|thumb|GBV]]
Ngeveke yokuthoma kaSinyikhaba ngomnyaka wee-2025 abantu abatjha eenkundleni zokuthintana njenge-Facebook ne-TikTok bathome ijima lokulwisana naso isigesi. Ihlangano eyaziwa khulu ngokulwela ilungelo lokuphila labafazi eSewula Afrika ebizwa bona yi-Women for Change ngiyo edosa phambili ijimeli. Ihlangano le ayilweli abafazi kwaphela kodwana ilwela nabantwana kanye namadoda, woke umuntu obuleweko iyamulwela begodu koke lokhu bakwenza khulu eenkundleni zokuthintana ngokusunduza ijima elithize. Njenganje bathome ijima lokobana woke umuntu agadangise isithombe sombala omsobo ukuze urhulumende amemezele bekavume bona ukubulawa kwabafazi kube yihlekelele yesitjhaba, kanti-ke abantu abanengi basabele benza njalo. [https://www.timeslive.co.za/news/south-africa/2025-11-09-we-bury-a-woman-every-25-hours-women-for-change-calls-for-national-shutdown-ahead-of-g20/]

I-Women For Change le yasungulwa ngomnyaka wee-2016, basebenzisa amandla aseenkundleni zokuthintana ukuyelelisa abantu boke ngokuhlukumezana ngokobulili kanye nokubulawa kwabafazi eSewula Afrika. Ayigcini lapho, ihlangano le ibuye isekele laba abasindileko beyisunduze itjhuguluko lamambala emphakathini[https://womenforchange.co.za]. 

Okhunye okukhona kukuthi kuphume iphepha lomoya (eliku-inthanethi) lesibawo lokuthi abantu batlikitle ukuze urhulumende asivume isibawo sokuthi ukubulawa kwabafazi kube yihlekelele yesitjhaba. Kanti-ke kuhlelwa nokuthi mhlazana amalanga ama-21 kuSinyikhaba ngomnyaka wona esiphezu kwawo lo kuzokuvalwa yoke into, kungabi nento eyenziwako, woke umuntu ahlale ekhaya - abasebenzako bangayi emsebenzini bese abafundi bangayi neenkolweni. Lokhu ngelimi lesiyeni ibizwa bona yi-national shut down [https://womenforchange.co.za/g20-women-shutdown/].

== IMIKHOMBA ==</text>
      <sha1>38jio35k0s1wnxu3598qo9o6e9tsru3</sha1>
    </revision>
    <revision>
      <id>6123</id>
      <parentid>6097</parentid>
      <timestamp>2026-01-13T08:19:35Z</timestamp>
      <contributor>
        <username>Hiro</username>
        <id>1286</id>
      </contributor>
      <minor />
      <comment>([[c:GR|GR]]) [[c:COM:FR|File renamed]]: [[File:GBV.jpg]] → [[File:Gender Based Violence.jpg]] Less ambiguous; there are more entities that use the abbreviation GBV</comment>
      <origin>6123</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2336" sha1="d5ydu66a0ar9mlie26owguc86gg0l35" xml:space="preserve">Ukubulawa kwabafazi eSewula Afrika sekuyinto yangamalanga. Isibalo esikhona sitjengisa bona abafazi nabantwana bayagagadlhelwa bebabulawe mndeni nofana mumuntu obaziko, lokhu kwenzeka qobe imizuzu elitjhumi elangeni ephasini loke jikelele bese eSewula Afrika abafazi abaziingidi ezilihlanu namakhulu amahlanu bayabulawa. Isibalwesi sakhutjhwa ngomnyaka wee-2020 ukuya kumnyaka wee-2021 [https://www.unwomen.org/en/news-stories/feature-story/2024/11/tackling-femicide-in-south-africa-through-laws-policies-and-better-policing]. 
[[File:Gender Based Violence.jpg|thumb|GBV]]
Ngeveke yokuthoma kaSinyikhaba ngomnyaka wee-2025 abantu abatjha eenkundleni zokuthintana njenge-Facebook ne-TikTok bathome ijima lokulwisana naso isigesi. Ihlangano eyaziwa khulu ngokulwela ilungelo lokuphila labafazi eSewula Afrika ebizwa bona yi-Women for Change ngiyo edosa phambili ijimeli. Ihlangano le ayilweli abafazi kwaphela kodwana ilwela nabantwana kanye namadoda, woke umuntu obuleweko iyamulwela begodu koke lokhu bakwenza khulu eenkundleni zokuthintana ngokusunduza ijima elithize. Njenganje bathome ijima lokobana woke umuntu agadangise isithombe sombala omsobo ukuze urhulumende amemezele bekavume bona ukubulawa kwabafazi kube yihlekelele yesitjhaba, kanti-ke abantu abanengi basabele benza njalo. [https://www.timeslive.co.za/news/south-africa/2025-11-09-we-bury-a-woman-every-25-hours-women-for-change-calls-for-national-shutdown-ahead-of-g20/]

I-Women For Change le yasungulwa ngomnyaka wee-2016, basebenzisa amandla aseenkundleni zokuthintana ukuyelelisa abantu boke ngokuhlukumezana ngokobulili kanye nokubulawa kwabafazi eSewula Afrika. Ayigcini lapho, ihlangano le ibuye isekele laba abasindileko beyisunduze itjhuguluko lamambala emphakathini[https://womenforchange.co.za]. 

Okhunye okukhona kukuthi kuphume iphepha lomoya (eliku-inthanethi) lesibawo lokuthi abantu batlikitle ukuze urhulumende asivume isibawo sokuthi ukubulawa kwabafazi kube yihlekelele yesitjhaba. Kanti-ke kuhlelwa nokuthi mhlazana amalanga ama-21 kuSinyikhaba ngomnyaka wona esiphezu kwawo lo kuzokuvalwa yoke into, kungabi nento eyenziwako, woke umuntu ahlale ekhaya - abasebenzako bangayi emsebenzini bese abafundi bangayi neenkolweni. Lokhu ngelimi lesiyeni ibizwa bona yi-national shut down [https://womenforchange.co.za/g20-women-shutdown/].

== IMIKHOMBA ==</text>
      <sha1>d5ydu66a0ar9mlie26owguc86gg0l35</sha1>
    </revision>
  </page>
  <page>
    <title>Ubukghwari</title>
    <ns>0</ns>
    <id>991</id>
    <revision>
      <id>5973</id>
      <timestamp>2025-11-10T18:30:01Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''Ubugkhwari''' kuyinto eyenziwako iphasi loke begodu abantu bakghona ukuthi baveze imicabango,  imizwa nalokho abadlula kikho ngobukghwari. &lt;ref&gt;https://www.vocabulary.com/dictionary/art&lt;/ref&gt;Kusela kade ubukghwari kuyinto eyabe ikhona ngombana abantu kade gade batlola basebenzisa ubukghwari ematjeni  ukuveza ikghono ebanalo nofana ukukhulumisana. Ubukghwari buphethe  imihlobo ehlukilelo yeentayela, amabumbeko evumela bona abantu abenza ubukghwari bakwazi ukuthi bav...&quot;</comment>
      <origin>5973</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3306" sha1="4fsb7rjwnzy8kjysopex6s7cmvzq7kc" xml:space="preserve">'''Ubugkhwari''' kuyinto eyenziwako iphasi loke begodu abantu bakghona ukuthi baveze imicabango,  imizwa nalokho abadlula kikho ngobukghwari. &lt;ref&gt;https://www.vocabulary.com/dictionary/art&lt;/ref&gt;Kusela kade ubukghwari kuyinto eyabe ikhona ngombana abantu kade gade batlola basebenzisa ubukghwari ematjeni  ukuveza ikghono ebanalo nofana ukukhulumisana. Ubukghwari buphethe  imihlobo ehlukilelo yeentayela, amabumbeko evumela bona abantu abenza ubukghwari bakwazi ukuthi baveze  imizwa yabo nalokho abahlangabezana nakho.Imihlobo yobukghwari ifaka hlangana ubukghwari bokuba, ubukghwari bokwenza, ubukghwari bokutlola nokufunda, ubukghwari bedijithali kanye nobukghwari obenziweko.&lt;ref&gt;https://dictionary.cambridge.org/dictionary/english/arts&lt;/ref&gt;

==== Ubukghwari obubonwako ====
Lobu kubukghwarii obenziwa ngokuthi abantu bapende, babaze iinfgodo, batjhude. Phakathi kwazo zoke ukupenda yindlela edala yokwenza ubukghwari obubonwako. Ukupenda bekusetjenziswaa ukuthi ukuveza izehlakalo zekadeni, ihlekalo zingasilo iqninso nesiko pilo. Ukupenda ukuses ngenye indlela enamandla yokwenza ubukghwari nesikhathi sanje ngombana basesekhona abantu abependa kuhle njengo  Frida  Kahlo no Pablo Picasso.Ukupenda kuyaraga ngokuthi kube yinto eyenziwakho ukukhombisa ikghono lobukghwari.

==== Ubukghwari bokwenza ====
Lobu bukghwari ebenza bona kubenokukarisa kwemisikinyeko ethileko okufana nolkudansa, nokwenza umvumo. Okhunye nokhunye kunendlela ehlukileko yokucoca iindaba, ukuveza imizwa Yabantu. Ithiyetha ngenye yeendawo ezidala lapho abantu khona ubukghwari bokwenza nokudlala imidlala yesteji nofana ukudansa. Ubukghwari lobu buyayidla indima emasikweni wabantu, anikela abantu ithuba lokucoca indaba.

==== Ubukghwari bokutlola nokufunda ====
Ubukghwari lobu buphethe iinkondlo, ukucocwa kwendaba, umdlalo, ukubufakazi bamandla welimi nokwakha iinthombe ngokhumbulo. Ngokusebenzisa ukutlola abtloli bakghona ukwakha iphasi, bakhulume ngeenhloko ezibudisi, bathinthe iinhliziyo neengcondo zabantu. Iinkondlo  ngelimi ezisetjenziswa lokha nazitlolwa zingakghona ukuvusa imizwa yomuntu, nokhipha amaqiniso ngamagama ambalwa akhethwe kuhle. Ngendatjana ezivaka Phakathi amanoveli, indatjana kuvumela bafundi bonyana bakghone ukuthi bathole ileazi ngamapilo ahlukahlukeneko, namahlangothi ahlukahlukeneko akhuthaza bone umuntu abenezwelo begodu nokuzwisisa.

==== Ubukghwari bedijithali ====
Yindlela etja yokwenza ubukghwari lapha kusetjenziswa ilwazi le-theknoloji ukwenza ubukghwari. Kilomkhakha wobukghwari kufakwa imidlalo yama vidiyo, ukutjhuda iinthombe, ukwenza abopopayi nokhunye. Ubukghwari bedijithali sele buvule eminye imimnyango yokuveza ubukghwari ivumela abantu abenza ubukghwari bona balinge iindlela ezitja zobukghwari.

==== Ubukghwari bokurhabisa ====
Benzeka lokha umuntu nakafuna ukwenza indawo ibonakale iyihle begodu idose abantu.Ubukghwari lobu bufaka ifetjheni, uhlela ngaphakathi, nokwakha izinto. Kungaba mitlamo yekadeni bekuyokufika emitlameni yesimanje manje. Ngokusebenzisa ukubukghwari lobu abantu bakghona ukuthi bathethe izinto ezijwayelekileko bazitjhugulule basebenzisa ithalente lobukghwari bese kuphume into ehle ekarisa woke umuntu.  Ubukghwari bokurhabisa bungathola eendaweni ezifana nemitjhadweni, emaphathini nakwezinye inndawo lapho kubanjwe khona imigidi.</text>
      <sha1>4fsb7rjwnzy8kjysopex6s7cmvzq7kc</sha1>
    </revision>
    <revision>
      <id>5974</id>
      <parentid>5973</parentid>
      <timestamp>2025-11-10T18:31:12Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5974</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3352" sha1="d5nk4h6uboga6142tz8w8hw1c69f79p" xml:space="preserve">'''Ubugkhwari''' kuyinto eyenziwako iphasi loke begodu abantu bakghona ukuthi baveze imicabango,  imizwa nalokho abadlula kikho ngobukghwari. &lt;ref&gt;https://www.vocabulary.com/dictionary/art&lt;/ref&gt;Kusela kade ubukghwari kuyinto eyabe ikhona ngombana abantu kade gade batlola basebenzisa ubukghwari ematjeni  ukuveza ikghono ebanalo nofana ukukhulumisana. Ubukghwari buphethe  imihlobo ehlukilelo yeentayela, amabumbeko evumela bona abantu abenza ubukghwari bakwazi ukuthi baveze  imizwa yabo nalokho abahlangabezana nakho.Imihlobo yobukghwari ifaka hlangana ubukghwari bokuba, ubukghwari bokwenza, ubukghwari bokutlola nokufunda, ubukghwari bedijithali kanye nobukghwari obenziweko.&lt;ref&gt;https://dictionary.cambridge.org/dictionary/english/arts&lt;/ref&gt;

=== Imihlobo yobukghwari ===

==== Ubukghwari obubonwako ====
Lobu kubukghwarii obenziwa ngokuthi abantu bapende, babaze iinfgodo, batjhude. Phakathi kwazo zoke ukupenda yindlela edala yokwenza ubukghwari obubonwako. Ukupenda bekusetjenziswaa ukuthi ukuveza izehlakalo zekadeni, ihlekalo zingasilo iqninso nesiko pilo. Ukupenda ukuses ngenye indlela enamandla yokwenza ubukghwari nesikhathi sanje ngombana basesekhona abantu abependa kuhle njengo  Frida  Kahlo no Pablo Picasso.Ukupenda kuyaraga ngokuthi kube yinto eyenziwakho ukukhombisa ikghono lobukghwari.

==== Ubukghwari bokwenza ====
Lobu bukghwari ebenza bona kubenokukarisa kwemisikinyeko ethileko okufana nolkudansa, nokwenza umvumo. Okhunye nokhunye kunendlela ehlukileko yokucoca iindaba, ukuveza imizwa Yabantu. Ithiyetha ngenye yeendawo ezidala lapho abantu khona ubukghwari bokwenza nokudlala imidlala yesteji nofana ukudansa. Ubukghwari lobu buyayidla indima emasikweni wabantu, anikela abantu ithuba lokucoca indaba.

==== Ubukghwari bokutlola nokufunda ====
Ubukghwari lobu buphethe iinkondlo, ukucocwa kwendaba, umdlalo, ukubufakazi bamandla welimi nokwakha iinthombe ngokhumbulo. Ngokusebenzisa ukutlola abtloli bakghona ukwakha iphasi, bakhulume ngeenhloko ezibudisi, bathinthe iinhliziyo neengcondo zabantu. Iinkondlo  ngelimi ezisetjenziswa lokha nazitlolwa zingakghona ukuvusa imizwa yomuntu, nokhipha amaqiniso ngamagama ambalwa akhethwe kuhle. Ngendatjana ezivaka Phakathi amanoveli, indatjana kuvumela bafundi bonyana bakghone ukuthi bathole ileazi ngamapilo ahlukahlukeneko, namahlangothi ahlukahlukeneko akhuthaza bone umuntu abenezwelo begodu nokuzwisisa.

==== Ubukghwari bedijithali ====
Yindlela etja yokwenza ubukghwari lapha kusetjenziswa ilwazi le-theknoloji ukwenza ubukghwari. Kilomkhakha wobukghwari kufakwa imidlalo yama vidiyo, ukutjhuda iinthombe, ukwenza abopopayi nokhunye. Ubukghwari bedijithali sele buvule eminye imimnyango yokuveza ubukghwari ivumela abantu abenza ubukghwari bona balinge iindlela ezitja zobukghwari.

==== Ubukghwari bokurhabisa ====
Benzeka lokha umuntu nakafuna ukwenza indawo ibonakale iyihle begodu idose abantu.Ubukghwari lobu bufaka ifetjheni, uhlela ngaphakathi, nokwakha izinto. Kungaba mitlamo yekadeni bekuyokufika emitlameni yesimanje manje. Ngokusebenzisa ukubukghwari lobu abantu bakghona ukuthi bathethe izinto ezijwayelekileko bazitjhugulule basebenzisa ithalente lobukghwari bese kuphume into ehle ekarisa woke umuntu.  Ubukghwari bokurhabisa bungathola eendaweni ezifana nemitjhadweni, emaphathini nakwezinye inndawo lapho kubanjwe khona imigidi.

== Iinkomba ==</text>
      <sha1>d5nk4h6uboga6142tz8w8hw1c69f79p</sha1>
    </revision>
    <revision>
      <id>5975</id>
      <parentid>5974</parentid>
      <timestamp>2025-11-10T18:32:26Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5975</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3360" sha1="jneguk52f7m0cz7d0al59x0otl5c4zq" xml:space="preserve">'''Ubugkhwari''' kuyinto eyenziwako iphasi loke begodu abantu bakghona ukuthi baveze imicabango,  imizwa nalokho abadlula kikho ngobukghwari. &lt;ref&gt;https://www.vocabulary.com/dictionary/art&lt;/ref&gt;Kusela kade [[ubukghwari]] kuyinto eyabe ikhona ngombana abantu kade gade batlola basebenzisa ubukghwari ematjeni  ukuveza ikghono ebanalo nofana ukukhulumisana. Ubukghwari buphethe  imihlobo ehlukilelo yeentayela, amabumbeko evumela bona abantu abenza ubukghwari bakwazi ukuthi baveze  imizwa yabo nalokho abahlangabezana nakho.Imihlobo yobukghwari ifaka hlangana ubukghwari bokuba, ubukghwari bokwenza, ubukghwari bokutlola nokufunda, ubukghwari bedijithali kanye nobukghwari obenziweko.&lt;ref&gt;https://dictionary.cambridge.org/dictionary/english/arts&lt;/ref&gt;

=== Imihlobo yobukghwari ===

==== Ubukghwari obubonwako ====
Lobu kubukghwarii obenziwa ngokuthi abantu bapende, babaze iinfgodo, batjhude. Phakathi kwazo zoke ukupenda yindlela edala yokwenza ubukghwari obubonwako. Ukupenda bekusetjenziswaa ukuthi ukuveza izehlakalo zekadeni, ihlekalo zingasilo iqninso nesiko pilo. [[Ukupenda]] ukuses ngenye indlela enamandla yokwenza ubukghwari nesikhathi sanje ngombana basesekhona abantu abependa kuhle njengo  Frida  Kahlo no Pablo Picasso.Ukupenda kuyaraga ngokuthi kube yinto eyenziwakho ukukhombisa ikghono lobukghwari.

==== Ubukghwari bokwenza ====
Lobu bukghwari ebenza bona kubenokukarisa kwemisikinyeko ethileko okufana nolkudansa, nokwenza umvumo. Okhunye nokhunye kunendlela ehlukileko yokucoca iindaba, ukuveza imizwa Yabantu. Ithiyetha ngenye yeendawo ezidala lapho abantu khona ubukghwari bokwenza nokudlala imidlala yesteji nofana ukudansa. Ubukghwari lobu buyayidla indima emasikweni wabantu, anikela abantu ithuba lokucoca indaba.

==== Ubukghwari bokutlola nokufunda ====
Ubukghwari lobu buphethe iinkondlo, ukucocwa kwendaba, umdlalo, ukubufakazi bamandla welimi nokwakha iinthombe ngokhumbulo. Ngokusebenzisa ukutlola abtloli bakghona ukwakha iphasi, bakhulume ngeenhloko ezibudisi, bathinthe iinhliziyo neengcondo zabantu. Iinkondlo  ngelimi ezisetjenziswa lokha nazitlolwa zingakghona ukuvusa imizwa yomuntu, nokhipha amaqiniso ngamagama ambalwa akhethwe kuhle. Ngendatjana ezivaka Phakathi amanoveli, indatjana kuvumela bafundi bonyana bakghone ukuthi bathole ileazi ngamapilo ahlukahlukeneko, namahlangothi ahlukahlukeneko akhuthaza bone umuntu abenezwelo begodu nokuzwisisa.

==== Ubukghwari bedijithali ====
Yindlela etja yokwenza ubukghwari lapha kusetjenziswa ilwazi le-theknoloji ukwenza ubukghwari. Kilomkhakha wobukghwari kufakwa imidlalo yama vidiyo, ukutjhuda iinthombe, ukwenza abopopayi nokhunye. Ubukghwari bedijithali sele buvule eminye imimnyango yokuveza ubukghwari ivumela abantu abenza ubukghwari bona balinge iindlela ezitja zobukghwari.

==== Ubukghwari bokurhabisa ====
Benzeka lokha umuntu nakafuna ukwenza indawo ibonakale iyihle begodu idose abantu.Ubukghwari lobu bufaka ifetjheni, uhlela ngaphakathi, nokwakha izinto. Kungaba mitlamo yekadeni bekuyokufika emitlameni yesimanje manje. Ngokusebenzisa ukubukghwari lobu abantu bakghona ukuthi bathethe izinto ezijwayelekileko bazitjhugulule basebenzisa ithalente lobukghwari bese kuphume into ehle ekarisa woke umuntu.  Ubukghwari bokurhabisa bungathola eendaweni ezifana nemitjhadweni, emaphathini nakwezinye inndawo lapho kubanjwe khona imigidi.

== Iinkomba ==</text>
      <sha1>jneguk52f7m0cz7d0al59x0otl5c4zq</sha1>
    </revision>
    <revision>
      <id>5976</id>
      <parentid>5975</parentid>
      <timestamp>2025-11-10T18:38:09Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5976</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3363" sha1="qlo2cbh5pads2jel96qz7gkaf1lz8tv" xml:space="preserve">'''Ubugkhwari''' kuyinto eyenziwako iphasi loke begodu abantu bakghona ukuthi baveze imicabango,  imizwa nalokho abadlula kikho ngobukghwari. &lt;ref&gt;https://www.vocabulary.com/dictionary/art&lt;/ref&gt;Kusela kade [[ubukghwari]] kuyinto eyabe ikhona ngombana abantu kade gade batlola basebenzisa ubukghwari ematjeni  ukuveza ikghono ebanalo nofana ukukhulumisana. Ubukghwari buphethe  imihlobo ehlukilelo yeentayela, amabumbeko evumela bona abantu abenza ubukghwari bakwazi ukuthi baveze  imizwa yabo nalokho abahlangabezana nakho.Imihlobo yobukghwari ifaka hlangana ubukghwari bokuba, ubukghwari bokwenza, ubukghwari bokutlola nokufunda, ubukghwari bedijithali kanye nobukghwari obenziweko.&lt;ref&gt;https://dictionary.cambridge.org/dictionary/english/arts&lt;/ref&gt;

=== Imihlobo yobukghwari ===

==== Ubukghwari obubonwako ====
Lobu kubukghwarii obenziwa ngokuthi abantu bapende, babaze iinfgodo, batjhude. Phakathi kwazo zoke ukupenda yindlela edala yokwenza ubukghwari obubonwako. Ukupenda bekusetjenziswaa ukuthi ukuveza izehlakalo zekadeni, ihlekalo zingasilo iqninso nesiko pilo. [[Ukupenda]] ukuses ngenye indlela enamandla yokwenza ubukghwari nesikhathi sanje ngombana basesekhona abantu abependa kuhle njengo  Frida  Kahlo no Pablo Picasso.Ukupenda kuyaraga ngokuthi kube yinto eyenziwakho ukukhombisa ikghono lobukghwari.

==== Ubukghwari bokwenza ====
Lobu bukghwari ebenza bona kubenokukarisa kwemisikinyeko ethileko okufana nolkudansa, nokwenza umvumo. Okhunye nokhunye kunendlela ehlukileko yokucoca iindaba, ukuveza imizwa Yabantu. Ithiyetha ngenye yeendawo ezidala lapho abantu khona ubukghwari bokwenza nokudlala imidlalo yesteji nofana ukudansa. Ubukghwari lobu buyayidla indima emasikweni wabantu, anikela abantu ithuba lokucoca indaba.

==== Ubukghwari bokutlola nokufunda ====
Ubukghwari lobu buphethe iinkondlo, ukucocwa kwendaba, umdlalo, ukubufakazi bamandla welimi nokwakha iinthombe ngokhumbulo. Ngokusebenzisa ukutlola abatloli bakghona ukwakha iphasi, bakhulume ngeenhloko ezibudisi, bathinthe iinhliziyo neengcondo zabantu. Iinkondlo  ngelimi elisetjenziswa lokha nazitlolwa zingakghona ukuvusa imizwa yomuntu, nokhipha amaqiniso ngamagama ambalwa akhethwe kuhle. Ngendatjana ezifaka Phakathi amanoveli, indatjana kuvumela abafundi bonyana bakghone ukuthi bathole ilwazi ngamaphilo ahlukahlukeneko, namahlangothi ahlukahlukeneko akhuthaza bone umuntu abenezwelo begodu nokuzwisisa.

==== Ubukghwari bedijithali ====
Yindlela etja yokwenza ubukghwari lapha kusetjenziswa ilwazi le-theknoloji ukwenza ubukghwari. Kilomkhakha wobukghwari kufakwa imidlalo yama vidiyo, ukutjhuda iinthombe, ukwenza abopopayi nokhunye. Ubukghwari bedijithali sele buvule eminye imimnyango yokuveza ubukghwari ivumela abantu abenza ubukghwari bona balinge iindlela ezitja zobukghwari.

==== Ubukghwari bokurhabisa ====
Benzeka lokha umuntu nakafuna ukwenza indawo ibonakale iyihle begodu idose abantu.Ubukghwari lobu bufaka ifetjheni, uhlela ngaphakathi, nokwakha izinto. Kungaba mitlamo yekadeni bekuyokufika emitlameni yesimanje manje. Ngokusebenzisa ukubukghwari lobu abantu bakghona ukuthi bathethe izinto ezijwayelekileko bazitjhugulule basebenzisa ithalente lobukghwari bese kuphume into ehle ekarisa woke umuntu.  Ubukghwari bokurhabisa bungathola eendaweni ezifana nemitjhadweni, emaphathini nakwezinye inndawo lapho kubanjwe khona imigidi.

== Iinkomba ==</text>
      <sha1>qlo2cbh5pads2jel96qz7gkaf1lz8tv</sha1>
    </revision>
    <revision>
      <id>5977</id>
      <parentid>5976</parentid>
      <timestamp>2025-11-10T18:45:22Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5977</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3710" sha1="1gxwqz7zx98vapwtw3oghjxbbyn45fx" xml:space="preserve">'''Ubugkhwari''' kuyinto eyenziwako iphasi loke begodu abantu bakghona ukuthi baveze imicabango,  imizwa nalokho abadlula kikho ngobukghwari. &lt;ref&gt;https://www.vocabulary.com/dictionary/art&lt;/ref&gt;Kusela kade [[ubukghwari]] kuyinto eyabe ikhona ngombana abantu kade gade batlola basebenzisa ubukghwari ematjeni  ukuveza ikghono ebanalo nofana ukukhulumisana. Ubukghwari buphethe  imihlobo ehlukilelo yeentayela, amabumbeko evumela bona abantu abenza ubukghwari bakwazi ukuthi baveze  imizwa yabo nalokho abahlangabezana nakho.Imihlobo yobukghwari ifaka hlangana ubukghwari bokuba, ubukghwari bokwenza, ubukghwari bokutlola nokufunda, ubukghwari bedijithali kanye nobukghwari obenziweko.&lt;ref&gt;https://dictionary.cambridge.org/dictionary/english/arts&lt;/ref&gt;

=== Imihlobo yobukghwari ===

==== Ubukghwari obubonwako ====
Lobu kubukghwarii obenziwa ngokuthi abantu bapende, babaze iinfgodo, batjhude. Phakathi kwazo zoke ukupenda yindlela edala yokwenza ubukghwari obubonwako. Ukupenda bekusetjenziswaa ukuthi ukuveza izehlakalo zekadeni, ihlekalo zingasilo iqninso nesiko pilo. [[Ukupenda]] ukuses ngenye indlela enamandla yokwenza ubukghwari nesikhathi sanje ngombana basesekhona abantu abependa kuhle njengo  Frida  Kahlo no Pablo Picasso.Ukupenda kuyaraga ngokuthi kube yinto eyenziwakho ukukhombisa ikghono lobukghwari.

==== Ubukghwari bokwenza ====
Lobu bukghwari ebenza bona kubenokukarisa kwemisikinyeko ethileko okufana nolkudansa, nokwenza umvumo.&lt;ref&gt;Simamora, R.M., 2020. The Challenges of online learning during the COVID-19 pandemic: An essay analysis of performing arts education students. ''Studies in Learning and Teaching'', ''1''(2), pp.86-103.&lt;/ref&gt; Okhunye nokhunye kunendlela ehlukileko yokucoca iindaba, ukuveza imizwa Yabantu. Ithiyetha ngenye yeendawo ezidala lapho abantu khona ubukghwari bokwenza nokudlala imidlalo yesteji nofana ukudansa. Ubukghwari lobu buyayidla indima emasikweni wabantu, anikela abantu ithuba lokucoca indaba.

==== Ubukghwari bokutlola nokufunda ====
Ubukghwari lobu buphethe iinkondlo, ukucocwa kwendaba, umdlalo, ukubufakazi bamandla welimi nokwakha iinthombe ngokhumbulo. Ngokusebenzisa ukutlola abatloli bakghona ukwakha iphasi, bakhulume ngeenhloko ezibudisi, bathinthe iinhliziyo neengcondo zabantu. Iinkondlo  ngelimi elisetjenziswa lokha nazitlolwa zingakghona ukuvusa imizwa yomuntu, nokhipha amaqiniso ngamagama ambalwa akhethwe kuhle. Ngendatjana ezifaka Phakathi amanoveli, indatjana kuvumela abafundi bonyana bakghone ukuthi bathole ilwazi ngamaphilo ahlukahlukeneko, namahlangothi ahlukahlukeneko akhuthaza bone umuntu abenezwelo begodu nokuzwisisa.

==== Ubukghwari bedijithali ====
Yindlela etja yokwenza ubukghwari lapha kusetjenziswa ilwazi le-theknoloji ukwenza ubukghwari. Kilomkhakha wobukghwari kufakwa imidlalo yama vidiyo, ukutjhuda iinthombe, ukwenza abopopayi nokhunye.&lt;ref&gt;Bramantyo, T., 2021. Digital art and the future of traditional arts. ''Journal of Music Scholarship'', ''42''(1), pp.96-110.&lt;/ref&gt; Ubukghwari bedijithali sele buvule eminye imimnyango yokuveza ubukghwari ivumela abantu abenza ubukghwari bona balinge iindlela ezitja zobukghwari.

==== Ubukghwari bokurhabisa ====
Benzeka lokha umuntu nakafuna ukwenza indawo ibonakale iyihle begodu idose abantu.Ubukghwari lobu bufaka ifetjheni, uhlela ngaphakathi, nokwakha izinto. Kungaba mitlamo yekadeni bekuyokufika emitlameni yesimanje manje. Ngokusebenzisa ukubukghwari lobu abantu bakghona ukuthi bathethe izinto ezijwayelekileko bazitjhugulule basebenzisa ithalente lobukghwari bese kuphume into ehle ekarisa woke umuntu.  Ubukghwari bokurhabisa bungathola eendaweni ezifana nemitjhadweni, emaphathini nakwezinye inndawo lapho kubanjwe khona imigidi.

== Iinkomba ==</text>
      <sha1>1gxwqz7zx98vapwtw3oghjxbbyn45fx</sha1>
    </revision>
    <revision>
      <id>5978</id>
      <parentid>5977</parentid>
      <timestamp>2025-11-10T18:50:32Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5978</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3788" sha1="0cwqzqytqav45i8808ex5v4lwicc5we" xml:space="preserve">'''Ubugkhwari''' kuyinto eyenziwako iphasi loke begodu abantu bakghona ukuthi baveze imicabango,  imizwa nalokho abadlula kikho ngobukghwari. &lt;ref&gt;https://www.vocabulary.com/dictionary/art&lt;/ref&gt;Kusela kade [[ubukghwari]] kuyinto eyabe ikhona ngombana abantu kade gade batlola basebenzisa ubukghwari ematjeni  ukuveza ikghono ebanalo nofana ukukhulumisana. Ubukghwari buphethe  imihlobo ehlukilelo yeentayela, amabumbeko evumela bona abantu abenza ubukghwari bakwazi ukuthi baveze  imizwa yabo nalokho abahlangabezana nakho.Imihlobo yobukghwari ifaka hlangana ubukghwari bokuba, ubukghwari bokwenza, ubukghwari bokutlola nokufunda, ubukghwari bedijithali kanye nobukghwari obenziweko.&lt;ref&gt;https://dictionary.cambridge.org/dictionary/english/arts&lt;/ref&gt;

=== Imihlobo yobukghwari ===

==== Ubukghwari obubonwako ====
Lobu kubukghwarii obenziwa ngokuthi abantu bapende, babaze iinfgodo, batjhude. Phakathi kwazo zoke ukupenda yindlela edala yokwenza ubukghwari obubonwako. Ukupenda bekusetjenziswaa ukuthi ukuveza izehlakalo zekadeni, ihlekalo zingasilo iqninso nesiko pilo. [[Ukupenda]] ukuses ngenye indlela enamandla yokwenza ubukghwari nesikhathi sanje ngombana basesekhona abantu abependa kuhle njengo  Frida  Kahlo no Pablo Picasso.Ukupenda kuyaraga ngokuthi kube yinto eyenziwakho ukukhombisa ikghono lobukghwari.

==== Ubukghwari bokwenza ====
Lobu bukghwari ebenza bona kubenokukarisa kwemisikinyeko ethileko okufana nolkudansa, nokwenza umvumo.&lt;ref&gt;Simamora, R.M., 2020. The Challenges of online learning during the COVID-19 pandemic: An essay analysis of performing arts education students. ''Studies in Learning and Teaching'', ''1''(2), pp.86-103.&lt;/ref&gt; Okhunye nokhunye kunendlela ehlukileko yokucoca iindaba, ukuveza imizwa Yabantu. Ithiyetha ngenye yeendawo ezidala lapho abantu khona ubukghwari bokwenza nokudlala imidlalo yesteji nofana ukudansa. Ubukghwari lobu buyayidla indima emasikweni wabantu, anikela abantu ithuba lokucoca indaba.

==== Ubukghwari bokutlola nokufunda ====
Ubukghwari lobu buphethe iinkondlo, ukucocwa kwendaba, umdlalo, ukubufakazi bamandla welimi nokwakha iinthombe ngokhumbulo. Ngokusebenzisa ukutlola abatloli bakghona ukwakha iphasi, bakhulume ngeenhloko ezibudisi, bathinthe iinhliziyo neengcondo zabantu. Iinkondlo  ngelimi elisetjenziswa lokha nazitlolwa zingakghona ukuvusa imizwa yomuntu, nokhipha amaqiniso ngamagama ambalwa akhethwe kuhle. Ngendatjana ezifaka Phakathi amanoveli, indatjana kuvumela abafundi bonyana bakghone ukuthi bathole ilwazi ngamaphilo ahlukahlukeneko, namahlangothi ahlukahlukeneko akhuthaza bone umuntu abenezwelo begodu nokuzwisisa.

==== Ubukghwari bedijithali ====
Yindlela etja yokwenza ubukghwari lapha kusetjenziswa ilwazi le-theknoloji ukwenza ubukghwari. Kilomkhakha wobukghwari kufakwa imidlalo yama vidiyo, ukutjhuda iinthombe, ukwenza abopopayi nokhunye.&lt;ref&gt;Bramantyo, T., 2021. Digital art and the future of traditional arts. ''Journal of Music Scholarship'', ''42''(1), pp.96-110.&lt;/ref&gt; Ubukghwari bedijithali sele buvule eminye imimnyango yokuveza ubukghwari ivumela abantu abenza ubukghwari bona balinge iindlela ezitja zobukghwari.

==== Ubukghwari bokurhabisa ====
Benzeka lokha umuntu nakafuna ukwenza indawo ibonakale iyihle begodu idose abantu.&lt;ref&gt;https://www.appliedarts.com/&lt;/ref&gt;Ubukghwari lobu bufaka ifetjheni, uhlela ngaphakathi, nokwakha izinto. Kungaba mitlamo yekadeni bekuyokufika emitlameni yesimanje manje. Ngokusebenzisa ukubukghwari lobu abantu bakghona ukuthi bathethe izinto ezijwayelekileko bazitjhugulule basebenzisa ithalente lobukghwari bese kuphume into ehle ekarisa woke umuntu.  Ubukghwari bokurhabisa bungathola eendaweni ezifana nemitjhadweni, emaphathini nakwezinye inndawo lapho kubanjwe khona imigidi.&lt;ref&gt;https://www.appliedarts.com/&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>0cwqzqytqav45i8808ex5v4lwicc5we</sha1>
    </revision>
    <revision>
      <id>5980</id>
      <parentid>5978</parentid>
      <timestamp>2025-11-15T11:36:25Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5980</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3892" sha1="408c6bmz2ikyhe9i9dgsxpbo7teyb7f" xml:space="preserve">'''Ubugkhwari''' kuyinto eyenziwako iphasi loke begodu abantu bakghona ukuthi baveze imicabango,  imizwa nalokho abadlula kikho ngobukghwari. &lt;ref&gt;https://www.vocabulary.com/dictionary/art&lt;/ref&gt;Kusela kade [[ubukghwari]] kuyinto eyabe ikhona ngombana abantu kade gade batlola basebenzisa ubukghwari ematjeni  ukuveza ikghono ebanalo nofana ukukhulumisana. Ubukghwari buphethe  imihlobo ehlukilelo yeentayela, amabumbeko evumela bona abantu abenza ubukghwari bakwazi ukuthi baveze  imizwa yabo nalokho abahlangabezana nakho.Imihlobo yobukghwari ifaka hlangana ubukghwari bokuba, ubukghwari bokwenza, ubukghwari bokutlola nokufunda, ubukghwari bedijithali kanye nobukghwari obenziweko.&lt;ref&gt;https://dictionary.cambridge.org/dictionary/english/arts&lt;/ref&gt;

=== Imihlobo yobukghwari ===

==== Ubukghwari obubonwako ====
Lobu kubukghwarii obenziwa ngokuthi abantu bapende, babaze iingodo, batjhude. Phakathi kwazo zoke ukupenda yindlela edala yokwenza ubukghwari obubonwako. [[Ukupenda]] bekusetjenziswaa ukuthi ukuveza izehlakalo zekadeni, ihlekalo zingasilo iqninso nesiko pilo. [[Ukupenda]] ukuses ngenye indlela enamandla yokwenza ubukghwari nesikhathi sanje ngombana basesekhona abantu abependa kuhle njengo  Frida  Kahlo no Pablo Picasso.Ukupenda kuyaraga ngokuthi kube yinto eyenziwakho ukukhombisa ikghono lobukghwari.

==== Ubukghwari bokwenza ====
Lobu bukghwari ebenza bona kubenokukarisa kwemisikinyeko ethileko okufana nolkudansa, nokwenza umvumo.&lt;ref&gt;Simamora, R.M., 2020. The Challenges of online learning during the COVID-19 pandemic: An essay analysis of performing arts education students. ''Studies in Learning and Teaching'', ''1''(2), pp.86-103.&lt;/ref&gt; Okhunye nokhunye kunendlela ehlukileko yokucoca iindaba, ukuveza imizwa Yabantu. Ithiyetha ngenye yeendawo ezidala lapho abantu khona ubukghwari bokwenza nokudlala imidlalo yesteji nofana ukudansa. Ubukghwari lobu buyayidla indima emasikweni wabantu, anikela abantu ithuba lokucoca indaba.

==== Ubukghwari bokutlola nokufunda ====
Ubukghwari lobu buphethe iinkondlo, ukucocwa kwendaba, umdlalo, ukubufakazi bamandla welimi nokwakha iinthombe ngokhumbulo. Ngokusebenzisa ukutlola abatloli bakghona ukwakha iphasi, bakhulume ngeenhloko ezibudisi, bathinthe iinhliziyo neengcondo zabantu. Iinkondlo  ngelimi elisetjenziswa lokha nazitlolwa zingakghona ukuvusa imizwa yomuntu, nokhipha amaqiniso ngamagama ambalwa akhethwe kuhle. Ngendatjana ezifaka Phakathi amanoveli, indatjana kuvumela abafundi bonyana bakghone ukuthi bathole ilwazi ngamaphilo ahlukahlukeneko, namahlangothi ahlukahlukeneko akhuthaza bone umuntu abenezwelo begodu nokuzwisisa.

==== Ubukghwari bedijithali ====
[[Isimumathi:Iphepha eligwaliweko ngephetheni yokugwla yamaNdebele.jpg|thumb|Umsebenzi wobukghwari ]]
Yindlela etja yokwenza ubukghwari lapha kusetjenziswa ilwazi le-theknoloji ukwenza ubukghwari. Kilomkhakha wobukghwari kufakwa imidlalo yama vidiyo, ukutjhuda iinthombe, ukwenza abopopayi nokhunye.&lt;ref&gt;Bramantyo, T., 2021. Digital art and the future of traditional arts. ''Journal of Music Scholarship'', ''42''(1), pp.96-110.&lt;/ref&gt; Ubukghwari bedijithali sele buvule eminye imimnyango yokuveza ubukghwari ivumela abantu abenza ubukghwari bona balinge iindlela ezitja zobukghwari.

==== Ubukghwari bokurhabisa ====
Benzeka lokha umuntu nakafuna ukwenza indawo ibonakale iyihle begodu idose abantu.&lt;ref&gt;https://www.appliedarts.com/&lt;/ref&gt;Ubukghwari lobu bufaka ifetjheni, uhlela ngaphakathi, nokwakha izinto. Kungaba mitlamo yekadeni bekuyokufika emitlameni yesimanje manje. Ngokusebenzisa ukubukghwari lobu abantu bakghona ukuthi bathethe izinto ezijwayelekileko bazitjhugulule basebenzisa ithalente lobukghwari bese kuphume into ehle ekarisa woke umuntu.  Ubukghwari bokurhabisa bungathola eendaweni ezifana nemitjhadweni, emaphathini nakwezinye indawo lapho kubanjwe khona imigidi.&lt;ref&gt;https://www.appliedarts.com/&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>408c6bmz2ikyhe9i9dgsxpbo7teyb7f</sha1>
    </revision>
    <revision>
      <id>5988</id>
      <parentid>5980</parentid>
      <timestamp>2025-11-15T15:03:21Z</timestamp>
      <contributor>
        <username>Dumbassman</username>
        <id>1091</id>
      </contributor>
      <minor />
      <comment>removed unnecessary spaces</comment>
      <origin>5988</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3880" sha1="l2z9mya0m4r3qpak1lybgp1ojlq2r3w" xml:space="preserve">'''Ubugkhwari''' kuyinto eyenziwako iphasi loke begodu abantu bakghona ukuthi baveze imicabango, imizwa nalokho abadlula kikho ngobukghwari. &lt;ref&gt;https://www.vocabulary.com/dictionary/art&lt;/ref&gt;Kusela kade [[ubukghwari]] kuyinto eyabe ikhona ngombana abantu kade gade batlola basebenzisa ubukghwari ematjeni ukuveza ikghono ebanalo nofana ukukhulumisana. Ubukghwari buphethe imihlobo ehlukilelo yeentayela, amabumbeko evumela bona abantu abenza ubukghwari bakwazi ukuthi baveze imizwa yabo nalokho abahlangabezana nakho.Imihlobo yobukghwari ifaka hlangana ubukghwari bokuba, ubukghwari bokwenza, ubukghwari bokutlola nokufunda, ubukghwari bedijithali kanye nobukghwari obenziweko.&lt;ref&gt;https://dictionary.cambridge.org/dictionary/english/arts&lt;/ref&gt;

=== Imihlobo yobukghwari ===

==== Ubukghwari obubonwako ====
Lobu kubukghwarii obenziwa ngokuthi abantu bapende, babaze iingodo, batjhude. Phakathi kwazo zoke ukupenda yindlela edala yokwenza ubukghwari obubonwako. [[Ukupenda]] bekusetjenziswaa ukuthi ukuveza izehlakalo zekadeni, ihlekalo zingasilo iqninso nesiko pilo. [[Ukupenda]] ukuses ngenye indlela enamandla yokwenza ubukghwari nesikhathi sanje ngombana basesekhona abantu abependa kuhle njengo Frida Kahlo no Pablo Picasso.Ukupenda kuyaraga ngokuthi kube yinto eyenziwakho ukukhombisa ikghono lobukghwari.

==== Ubukghwari bokwenza ====
Lobu bukghwari ebenza bona kubenokukarisa kwemisikinyeko ethileko okufana nolkudansa, nokwenza umvumo.&lt;ref&gt;Simamora, R.M., 2020. The Challenges of online learning during the COVID-19 pandemic: An essay analysis of performing arts education students. ''Studies in Learning and Teaching'', ''1''(2), pp.86-103.&lt;/ref&gt; Okhunye nokhunye kunendlela ehlukileko yokucoca iindaba, ukuveza imizwa Yabantu. Ithiyetha ngenye yeendawo ezidala lapho abantu khona ubukghwari bokwenza nokudlala imidlalo yesteji nofana ukudansa. Ubukghwari lobu buyayidla indima emasikweni wabantu, anikela abantu ithuba lokucoca indaba.

==== Ubukghwari bokutlola nokufunda ====
Ubukghwari lobu buphethe iinkondlo, ukucocwa kwendaba, umdlalo, ukubufakazi bamandla welimi nokwakha iinthombe ngokhumbulo. Ngokusebenzisa ukutlola abatloli bakghona ukwakha iphasi, bakhulume ngeenhloko ezibudisi, bathinthe iinhliziyo neengcondo zabantu. Iinkondlo ngelimi elisetjenziswa lokha nazitlolwa zingakghona ukuvusa imizwa yomuntu, nokhipha amaqiniso ngamagama ambalwa akhethwe kuhle. Ngendatjana ezifaka Phakathi amanoveli, indatjana kuvumela abafundi bonyana bakghone ukuthi bathole ilwazi ngamaphilo ahlukahlukeneko, namahlangothi ahlukahlukeneko akhuthaza bone umuntu abenezwelo begodu nokuzwisisa.

==== Ubukghwari bedijithali ====
[[Isimumathi:Iphepha eligwaliweko ngephetheni yokugwla yamaNdebele.jpg|thumb|Umsebenzi wobukghwari ]]
Yindlela etja yokwenza ubukghwari lapha kusetjenziswa ilwazi le-theknoloji ukwenza ubukghwari. Kilomkhakha wobukghwari kufakwa imidlalo yama vidiyo, ukutjhuda iinthombe, ukwenza abopopayi nokhunye.&lt;ref&gt;Bramantyo, T., 2021. Digital art and the future of traditional arts. ''Journal of Music Scholarship'', ''42''(1), pp.96-110.&lt;/ref&gt; Ubukghwari bedijithali sele buvule eminye imimnyango yokuveza ubukghwari ivumela abantu abenza ubukghwari bona balinge iindlela ezitja zobukghwari.

==== Ubukghwari bokurhabisa ====
Benzeka lokha umuntu nakafuna ukwenza indawo ibonakale iyihle begodu idose abantu.&lt;ref&gt;https://www.appliedarts.com/&lt;/ref&gt;Ubukghwari lobu bufaka ifetjheni, uhlela ngaphakathi, nokwakha izinto. Kungaba mitlamo yekadeni bekuyokufika emitlameni yesimanje manje. Ngokusebenzisa ukubukghwari lobu abantu bakghona ukuthi bathethe izinto ezijwayelekileko bazitjhugulule basebenzisa ithalente lobukghwari bese kuphume into ehle ekarisa woke umuntu. Ubukghwari bokurhabisa bungathola eendaweni ezifana nemitjhadweni, emaphathini nakwezinye indawo lapho kubanjwe khona imigidi.&lt;ref&gt;https://www.appliedarts.com/&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>l2z9mya0m4r3qpak1lybgp1ojlq2r3w</sha1>
    </revision>
  </page>
  <page>
    <title>Ukupenda</title>
    <ns>0</ns>
    <id>992</id>
    <revision>
      <id>5981</id>
      <timestamp>2025-11-15T14:27:11Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''Ukupenda''' kungenye yendlela  ezidala zokwethula  ubukghwari, ivumela bonyana abantu abenza ubkghwari bakghone ukuveza imizwa yabo beogu bakghone bathule nolokho  abadlula kikho ngokuthi bapende ngemibala ehlukileko, nangeentayela ezihlukahlukeneko ekusekela edadeni kusapendwa emadwaleni ukufikela ebukghwarini banje bedijithali.&lt;ref&gt;Tandirli, E., 2012. Painting education &amp; artistic evolution. ''Procedia-Social and Behavioral Sciences'', ''46'', pp.4493-4497.&lt;/ref&gt;...&quot;</comment>
      <origin>5981</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3336" sha1="11rcu1kmnqgv1nih4z5qkfjgz53icxm" xml:space="preserve">'''Ukupenda''' kungenye yendlela  ezidala zokwethula  ubukghwari, ivumela bonyana abantu abenza ubkghwari bakghone ukuveza imizwa yabo beogu bakghone bathule nolokho  abadlula kikho ngokuthi bapende ngemibala ehlukileko, nangeentayela ezihlukahlukeneko ekusekela edadeni kusapendwa emadwaleni ukufikela ebukghwarini banje bedijithali.&lt;ref&gt;Tandirli, E., 2012. Painting education &amp; artistic evolution. ''Procedia-Social and Behavioral Sciences'', ''46'', pp.4493-4497.&lt;/ref&gt; Ukuoenda kuyinto etjhugulka nesikhathi, itjengisie amasiko, ukuzwana kwabantu nokuthuthuka kwezinga letheknoloji emaphilweni wabantu.ukupenda kubukghwari obutjhuguluka ngokwesikhathi begodu kukhuthaze ababukeli ephasini loke.

Umlando ngokupenda

Ukupenda kuyinto eyathoma kade ebokanakala ngobufakazi ebutholakala emadwalenii, ematjeni wamazindla nemasontweni.&lt;ref&gt;Bakhtiyorovich, K.I. and Shodikulovich, T.A., 2021. The Role of Painting in the Folk Art of Surkhandarya. ''International Journal of Human Computing Studies'', ''3''(2), pp.26-28.&lt;/ref&gt; Izinto ezipendiweko ezidala khulu  zivela bonyana ngezeminyaka eyi-40 000 eyadlulako, ipendwe babantu bakade basenezisa izinto zemvelo namathulusi ebebazenzela wona ngamathmabo. Nakuthoma khona kuba nokuthuthuka komphakathi kwathelelka nokuthi kube nokuthuthuka kokuthi kube neendlela ezinye zokupenda ziza nabantu bakudala abama griki, abamaroma,nebegibithe.Ukupenda kuyinto ekhombisa umlando wabantu obulungiweko. Ngombana ukghona ukusikhombisa izinto ezakhe zenzeka ekadeni, amasiko wabantu begodu nokuthi umphakathi uphila njani.&lt;ref&gt;Wollheim, R., 2023. ''Painting as an Art'' (Vol. 33). Princeton University Press.&lt;/ref&gt; Ukupenda kukuthada ukuthi umuntu akghone  ukwakha inthombe engcondweni yakhe begodu eze neminye imibono. Kulekelela abantu bonyana bakghone ukuthi baphikise imibono yabantu nangabe abavuelani nayo. Ivumela abantu bonyana boakghone ukuveza imizwa yabo basebenzisa umbala nokuwuhlanganisa kwakhona.

Iintayela zokupenda

I-Realism

Lokhu kupenda okunqophileko begodu kuphethe imigwalo ezeleko ngelwazi lephasi. Lapha bantu abenza ubukghwari ngokupenda  bahlose ukuthi bapende ngendlela eveza iphasi ngendlela linjalo ngaphandle kokuthi lihlotjiswe  nofana litjhululwe. Ukuoenda lokhu kubonakala ngokuthi ukupenda kwakhona  kuphuma kusithombe sento njengoba sinjalo. Akufaki imizwa yabantu nofana ukuphikisana nemibono ethileko.

I-Abstract

Kupenda okungakhulumiko ekwenza ekugandelala umbala, ijamo kanye nokuzwakala kwento. Lokhu kupenda  kubonakala ngokuthi kupenda amabumbeko,  umbala  ukuletha uumlayezo othileko. Abantu abapenda ngelndlela le bakghona ukuthii bapende ngokutjhuphuluka ngaphandlekokuthi Basabe imithetho yamasiko neminye imithetho. Lapho ekunanto eveza izinto zeqiniso ezikhona ephasini. Akufaki amagama lokho kutjho bona ababukeli kufanele bona babe nokuhlakanipha  nofunda isiithombe sipendiweko bonyana sitjho ukuthini.

I-surrealism ne-Impression

Kupenda okevezwa njengbhudango, nofana umcabango,ubonakala ngokuthi ibe neenthome ezinganikelani ukuthula emoyeni. Lokhu kufaka ukuthatha iinkhathi lapho kupendwa khona  iinkhathi ezithabisako, kufake nokukhanyan okuthileko ukukhanyisa isithombe sakhona. Esikhathi esinengi kupendwa iukukhombisa iinthado ezingaphandle kwendlu njebala elithileko. Igandelela ipilo yabantu yangemihla yesikhathi sanje.</text>
      <sha1>11rcu1kmnqgv1nih4z5qkfjgz53icxm</sha1>
    </revision>
    <revision>
      <id>5982</id>
      <parentid>5981</parentid>
      <timestamp>2025-11-15T14:28:39Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5982</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3394" sha1="qbe6tgjnljjc159cks1o1f9dg5626yy" xml:space="preserve">'''Ukupenda''' kungenye yendlela  ezidala zokwethula  ubukghwari, ivumela bonyana abantu abenza ubkghwari bakghone ukuveza imizwa yabo beogu bakghone bathule nolokho  abadlula kikho ngokuthi bapende ngemibala ehlukileko, nangeentayela ezihlukahlukeneko ekusekela edadeni kusapendwa emadwaleni ukufikela ebukghwarini banje bedijithali.&lt;ref&gt;Tandirli, E., 2012. Painting education &amp; artistic evolution. ''Procedia-Social and Behavioral Sciences'', ''46'', pp.4493-4497.&lt;/ref&gt; Ukuoenda kuyinto etjhugulka nesikhathi, itjengisie amasiko, ukuzwana kwabantu nokuthuthuka kwezinga letheknoloji emaphilweni wabantu.ukupenda kubukghwari obutjhuguluka ngokwesikhathi begodu kukhuthaze ababukeli ephasini loke.

=== Umlando ngokupenda ===
Ukupenda kuyinto eyathoma kade ebokanakala ngobufakazi ebutholakala emadwalenii, ematjeni wamazindla nemasontweni.&lt;ref&gt;Bakhtiyorovich, K.I. and Shodikulovich, T.A., 2021. The Role of Painting in the Folk Art of Surkhandarya. ''International Journal of Human Computing Studies'', ''3''(2), pp.26-28.&lt;/ref&gt; Izinto ezipendiweko ezidala khulu  zivela bonyana ngezeminyaka eyi-40 000 eyadlulako, ipendwe babantu bakade basenezisa izinto zemvelo namathulusi ebebazenzela wona ngamathmabo. Nakuthoma khona kuba nokuthuthuka komphakathi kwathelelka nokuthi kube nokuthuthuka kokuthi kube neendlela ezinye zokupenda ziza nabantu bakudala abama griki, abamaroma,nebegibithe.Ukupenda kuyinto ekhombisa umlando wabantu obulungiweko. Ngombana ukghona ukusikhombisa izinto ezakhe zenzeka ekadeni, amasiko wabantu begodu nokuthi umphakathi uphila njani.&lt;ref&gt;Wollheim, R., 2023. ''Painting as an Art'' (Vol. 33). Princeton University Press.&lt;/ref&gt; Ukupenda kukuthada ukuthi umuntu akghone  ukwakha inthombe engcondweni yakhe begodu eze neminye imibono. Kulekelela abantu bonyana bakghone ukuthi baphikise imibono yabantu nangabe abavuelani nayo. Ivumela abantu bonyana boakghone ukuveza imizwa yabo basebenzisa umbala nokuwuhlanganisa kwakhona.

=== Iintayela zokupenda ===

==== I-Realism ====
Lokhu kupenda okunqophileko begodu kuphethe imigwalo ezeleko ngelwazi lephasi. Lapha bantu abenza ubukghwari ngokupenda  bahlose ukuthi bapende ngendlela eveza iphasi ngendlela linjalo ngaphandle kokuthi lihlotjiswe  nofana litjhululwe. Ukuoenda lokhu kubonakala ngokuthi ukupenda kwakhona  kuphuma kusithombe sento njengoba sinjalo. Akufaki imizwa yabantu nofana ukuphikisana nemibono ethileko.

==== I-Abstract ====
Kupenda okungakhulumiko ekwenza ekugandelala umbala, ijamo kanye nokuzwakala kwento. Lokhu kupenda  kubonakala ngokuthi kupenda amabumbeko,  umbala  ukuletha uumlayezo othileko. Abantu abapenda ngelndlela le bakghona ukuthii bapende ngokutjhuphuluka ngaphandlekokuthi Basabe imithetho yamasiko neminye imithetho. Lapho ekunanto eveza izinto zeqiniso ezikhona ephasini. Akufaki amagama lokho kutjho bona ababukeli kufanele bona babe nokuhlakanipha  nofunda isiithombe sipendiweko bonyana sitjho ukuthini.

==== I-surrealism ne-Impression ====
Kupenda okevezwa njengbhudango, nofana umcabango,ubonakala ngokuthi ibe neenthome ezinganikelani ukuthula emoyeni. Lokhu kufaka ukuthatha iinkhathi lapho kupendwa khona  iinkhathi ezithabisako, kufake nokukhanyan okuthileko ukukhanyisa isithombe sakhona. Esikhathi esinengi kupendwa iukukhombisa iinthado ezingaphandle kwendlu njebala elithileko. Igandelela ipilo yabantu yangemihla yesikhathi sanje.

== Iinkomba ==</text>
      <sha1>qbe6tgjnljjc159cks1o1f9dg5626yy</sha1>
    </revision>
    <revision>
      <id>5983</id>
      <parentid>5982</parentid>
      <timestamp>2025-11-15T14:31:09Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>5983</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3463" sha1="mfgiq57a8zc4t7z5tb3hnhocdja2x95" xml:space="preserve">'''Ukupenda''' kungenye yendlela  ezidala zokwethula  ubukghwari, ivumela bonyana abantu abenza ubkghwari bakghone ukuveza imizwa yabo beogu bakghone bathule nolokho  abadlula kikho ngokuthi bapende ngemibala ehlukileko, nangeentayela ezihlukahlukeneko ekusekela edadeni kusapendwa emadwaleni ukufikela ebukghwarini banje bedijithali.&lt;ref&gt;Tandirli, E., 2012. Painting education &amp; artistic evolution. ''Procedia-Social and Behavioral Sciences'', ''46'', pp.4493-4497.&lt;/ref&gt; Ukuoenda kuyinto etjhugulka nesikhathi, itjengisie amasiko, ukuzwana kwabantu nokuthuthuka kwezinga letheknoloji emaphilweni wabantu.ukupenda kubukghwari obutjhuguluka ngokwesikhathi begodu kukhuthaze ababukeli ephasini loke.

=== Umlando ngokupenda ===
Ukupenda kuyinto eyathoma kade ebokanakala ngobufakazi ebutholakala emadwalenii, ematjeni wamazindla nemasontweni.&lt;ref&gt;Bakhtiyorovich, K.I. and Shodikulovich, T.A., 2021. The Role of Painting in the Folk Art of Surkhandarya. ''International Journal of Human Computing Studies'', ''3''(2), pp.26-28.&lt;/ref&gt; Izinto ezipendiweko ezidala khulu  zivela bonyana ngezeminyaka eyi-40 000 eyadlulako, ipendwe babantu bakade basenezisa izinto zemvelo namathulusi ebebazenzela wona ngamathmabo. Nakuthoma khona kuba nokuthuthuka komphakathi kwathelelka nokuthi kube nokuthuthuka kokuthi kube neendlela ezinye zokupenda ziza nabantu bakudala abama griki, abamaroma,nebegibithe.Ukupenda kuyinto ekhombisa umlando wabantu obulungiweko. Ngombana ukghona ukusikhombisa izinto ezakhe zenzeka ekadeni, amasiko wabantu begodu nokuthi umphakathi uphila njani.&lt;ref&gt;Wollheim, R., 2023. ''Painting as an Art'' (Vol. 33). Princeton University Press.&lt;/ref&gt; Ukupenda kukuthada ukuthi umuntu akghone  ukwakha inthombe engcondweni yakhe begodu eze neminye imibono. Kulekelela abantu bonyana bakghone ukuthi baphikise imibono yabantu nangabe abavuelani nayo. Ivumela abantu bonyana boakghone ukuveza imizwa yabo basebenzisa umbala nokuwuhlanganisa kwakhona.

=== Iintayela zokupenda ===

==== I-Realism ====
Lokhu kupenda okunqophileko begodu kuphethe imigwalo ezeleko ngelwazi lephasi. Lapha bantu abenza ubukghwari ngokupenda  bahlose ukuthi bapende ngendlela eveza iphasi ngendlela linjalo ngaphandle kokuthi lihlotjiswe  nofana litjhululwe. Ukuoenda lokhu kubonakala ngokuthi ukupenda kwakhona  kuphuma kusithombe sento njengoba sinjalo. Akufaki imizwa yabantu nofana ukuphikisana nemibono ethileko.

==== I-Abstract ====
Kupenda okungakhulumiko ekwenza ekugandelala umbala, ijamo kanye nokuzwakala kwento. Lokhu kupenda  kubonakala ngokuthi kupenda amabumbeko,  umbala  ukuletha uumlayezo othileko. Abantu abapenda ngelndlela le bakghona ukuthii bapende ngokutjhuphuluka ngaphandlekokuthi Basabe imithetho yamasiko neminye imithetho. Lapho ekunanto eveza izinto zeqiniso ezikhona ephasini. Akufaki amagama lokho kutjho bona ababukeli kufanele bona babe nokuhlakanipha  nofunda isiithombe sipendiweko bonyana sitjho ukuthini.

==== I-surrealism ne-Impression ====
Kupenda okevezwa njengbhudango, nofana umcabango,ubonakala ngokuthi ibe neenthome ezinganikelani ukuthula emoyeni. Lokhu kufaka ukuthatha iinkhathi lapho kupendwa khona  iinkhathi ezithabisako, kufake nokukhanyan okuthileko ukukhanyisa isithombe sakhona. Esikhathi esinengi kupendwa iukukhombisa iinthado ezingaphandle kwendlu njebala elithileko. Igandelela ipilo yabantu yangemihla yesikhathi sanje.

== Iinkomba ==
[[Category:Ubukghwari]]
[[Category:Ukugwala]]
[[Category:Ithalente]]</text>
      <sha1>mfgiq57a8zc4t7z5tb3hnhocdja2x95</sha1>
    </revision>
    <revision>
      <id>5984</id>
      <parentid>5983</parentid>
      <timestamp>2025-11-15T14:35:09Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5984</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3479" sha1="9xs8zyki6q75g3nkcxb1whlb4b3blt3" xml:space="preserve">'''Ukupenda''' kungenye yendlela  ezidala zokwethula  ubukghwari, ivumela bonyana abantu abenza [[ubukghwari]] bakghone ukuveza imizwa yabo begodu bakghona ukuthi bathule nolokho  abadlula kikho ngokuthi bapende ngemibala ehlukileko, nangeentayela ezihlukahlukeneko ekusekela ekadeni kusapendwa emadwaleni ukufikela ebukghwarini banje bedijithali.&lt;ref&gt;Tandirli, E., 2012. Painting education &amp; artistic evolution. ''Procedia-Social and Behavioral Sciences'', ''46'', pp.4493-4497.&lt;/ref&gt; Ukupenda kuyinto etjhuguluka nesikhathi, itjengisie amasiko, ukuzwana kwabantu nokuthuthuka kwezinga letheknoloji emaphilweni wabantu.ukupenda kubukghwari obutjhuguluka ngokwesikhathi begodu kukhuthaze ababukeli ephasini loke.

=== Umlando ngokupenda ===
Ukupenda kuyinto eyathoma kade ebokanakala ngobufakazi ebutholakala emadwaleni, ematjeni wamazindla nemasontweni.&lt;ref&gt;Bakhtiyorovich, K.I. and Shodikulovich, T.A., 2021. The Role of Painting in the Folk Art of Surkhandarya. ''International Journal of Human Computing Studies'', ''3''(2), pp.26-28.&lt;/ref&gt; Izinto ezipendiweko ezidala khulu  zivela bonyana ngezeminyaka eyi-40 000 eyadlulako, ipendwe babantu bakade basebenzisa izinto zemvelo namathulusi ebebazenzela wona ngamathambo. Nakuthoma khona kuba nokuthuthuka komphakathi kwatheleleka nokuthi kube nokuthuthuka kokuthi kube neendlela ezinye zokupenda ziza nabantu bakudala abama griki, abamaroma,nebegibithe.Ukupenda kuyinto ekhombisa umlando wabantu obulungiweko. Ngombana ukghona ukusikhombisa izinto ezakhe zenzeka ekadeni, amasiko wabantu begodu nokuthi umphakathi uphila njani.&lt;ref&gt;Wollheim, R., 2023. ''Painting as an Art'' (Vol. 33). Princeton University Press.&lt;/ref&gt; Ukupenda kukuthatha ukuthi umuntu akghone  ukwakha inthombe engcondweni yakhe begodu eze neminye imibono. Kulekelela abantu bonyana bakghone ukuthi baphikise imibono yabantu nangabe abavuelani nayo. Ivumela abantu bonyana boakghone ukuveza imizwa yabo basebenzisa umbala nokuwuhlanganisa kwakhona.

=== Iintayela zokupenda ===

==== I-Realism ====
Lokhu kupenda okunqophileko begodu kuphethe imigwalo ezeleko ngelwazi lephasi. Lapha bantu abenza ubukghwari ngokupenda  bahlose ukuthi bapende ngendlela eveza iphasi ngendlela linjalo ngaphandle kokuthi lihlotjiswe  nofana litjhululwe. Ukupenda lokhu kubonakala ngokuthi ukupenda kwakhona  kuphuma kusithombe sento njengoba sinjalo. Akufaki imizwa yabantu nofana ukuphikisana nemibono ethileko.

==== I-Abstract ====
Kupenda okungakhulumiko ekwenza ekugandelala umbala, ijamo kanye nokuzwakala kwento. Lokhu kupenda  kubonakala ngokuthi kupenda amabumbeko,  umbala  ukuletha uumlayezo othileko. Abantu abapenda ngelndlela le bakghona ukuthii bapende ngokutjhuphuluka ngaphandlekokuthi Basabe imithetho yamasiko neminye imithetho. Lapho ekunanto eveza izinto zeqiniso ezikhona ephasini. Akufaki amagama lokho kutjho bona ababukeli kufanele bona babe nokuhlakanipha  nofunda isiithombe sipendiweko bonyana sitjho ukuthini.

==== I-surrealism ne-Impression ====
Kupenda okevezwa njengbhudango, nofana umcabango,ubonakala ngokuthi ibe neenthome ezinganikelani ukuthula emoyeni. Lokhu kufaka ukuthatha iinkhathi lapho kupendwa khona  iinkhathi ezithabisako, kufake nokukhanyan okuthileko ukukhanyisa isithombe sakhona. Esikhathi esinengi kupendwa iukukhombisa iinthado ezingaphandle kwendlu njebala elithileko. Igandelela ipilo yabantu yangemihla yesikhathi sanje.

== Iinkomba ==
[[Category:Ubukghwari]]
[[Category:Ukugwala]]
[[Category:Ithalente]]</text>
      <sha1>9xs8zyki6q75g3nkcxb1whlb4b3blt3</sha1>
    </revision>
    <revision>
      <id>5985</id>
      <parentid>5984</parentid>
      <timestamp>2025-11-15T14:37:29Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5985</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3597" sha1="9wr4kn3613cx7pvpwrb9fstj3xpzutx" xml:space="preserve">[[Isimumathi:Van Gogh - Starry Night - Google Art Project.jpg|thumb|isithombe esipendiweko kusetjenziswa ubukghwari]]
'''Ukupenda''' kungenye yendlela  ezidala zokwethula  ubukghwari, ivumela bonyana abantu abenza [[ubukghwari]] bakghone ukuveza imizwa yabo begodu bakghona ukuthi bathule nolokho  abadlula kikho ngokuthi bapende ngemibala ehlukileko, nangeentayela ezihlukahlukeneko ekusekela ekadeni kusapendwa emadwaleni ukufikela ebukghwarini banje bedijithali.&lt;ref&gt;Tandirli, E., 2012. Painting education &amp; artistic evolution. ''Procedia-Social and Behavioral Sciences'', ''46'', pp.4493-4497.&lt;/ref&gt; Ukupenda kuyinto etjhuguluka nesikhathi, itjengisie amasiko, ukuzwana kwabantu nokuthuthuka kwezinga letheknoloji emaphilweni wabantu.ukupenda kubukghwari obutjhuguluka ngokwesikhathi begodu kukhuthaze ababukeli ephasini loke.

=== Umlando ngokupenda ===
Ukupenda kuyinto eyathoma kade ebokanakala ngobufakazi ebutholakala emadwaleni, ematjeni wamazindla nemasontweni.&lt;ref&gt;Bakhtiyorovich, K.I. and Shodikulovich, T.A., 2021. The Role of Painting in the Folk Art of Surkhandarya. ''International Journal of Human Computing Studies'', ''3''(2), pp.26-28.&lt;/ref&gt; Izinto ezipendiweko ezidala khulu  zivela bonyana ngezeminyaka eyi-40 000 eyadlulako, ipendwe babantu bakade basebenzisa izinto zemvelo namathulusi ebebazenzela wona ngamathambo. Nakuthoma khona kuba nokuthuthuka komphakathi kwatheleleka nokuthi kube nokuthuthuka kokuthi kube neendlela ezinye zokupenda ziza nabantu bakudala abama griki, abamaroma,nebegibithe.Ukupenda kuyinto ekhombisa umlando wabantu obulungiweko. Ngombana ukghona ukusikhombisa izinto ezakhe zenzeka ekadeni, amasiko wabantu begodu nokuthi umphakathi uphila njani.&lt;ref&gt;Wollheim, R., 2023. ''Painting as an Art'' (Vol. 33). Princeton University Press.&lt;/ref&gt; Ukupenda kukuthatha ukuthi umuntu akghone  ukwakha inthombe engcondweni yakhe begodu eze neminye imibono. Kulekelela abantu bonyana bakghone ukuthi baphikise imibono yabantu nangabe abavuelani nayo. Ivumela abantu bonyana boakghone ukuveza imizwa yabo basebenzisa umbala nokuwuhlanganisa kwakhona.

=== Iintayela zokupenda ===

==== I-Realism ====
Lokhu kupenda okunqophileko begodu kuphethe imigwalo ezeleko ngelwazi lephasi. Lapha bantu abenza ubukghwari ngokupenda  bahlose ukuthi bapende ngendlela eveza iphasi ngendlela linjalo ngaphandle kokuthi lihlotjiswe  nofana litjhululwe. Ukupenda lokhu kubonakala ngokuthi ukupenda kwakhona  kuphuma kusithombe sento njengoba sinjalo. Akufaki imizwa yabantu nofana ukuphikisana nemibono ethileko.

==== I-Abstract ====
Kupenda okungakhulumiko ekwenza ekugandelala umbala, ijamo kanye nokuzwakala kwento. Lokhu kupenda  kubonakala ngokuthi kupenda amabumbeko,  umbala  ukuletha uumlayezo othileko. Abantu abapenda ngelndlela le bakghona ukuthii bapende ngokutjhuphuluka ngaphandlekokuthi Basabe imithetho yamasiko neminye imithetho. Lapho ekunanto eveza izinto zeqiniso ezikhona ephasini. Akufaki amagama lokho kutjho bona ababukeli kufanele bona babe nokuhlakanipha  nofunda isiithombe sipendiweko bonyana sitjho ukuthini.

==== I-surrealism ne-Impression ====
Kupenda okevezwa njengbhudango, nofana umcabango,ubonakala ngokuthi ibe neenthome ezinganikelani ukuthula emoyeni. Lokhu kufaka ukuthatha iinkhathi lapho kupendwa khona  iinkhathi ezithabisako, kufake nokukhanyan okuthileko ukukhanyisa isithombe sakhona. Esikhathi esinengi kupendwa iukukhombisa iinthado ezingaphandle kwendlu njebala elithileko. Igandelela ipilo yabantu yangemihla yesikhathi sanje.

== Iinkomba ==
[[Category:Ubukghwari]]
[[Category:Ukugwala]]
[[Category:Ithalente]]</text>
      <sha1>9wr4kn3613cx7pvpwrb9fstj3xpzutx</sha1>
    </revision>
    <revision>
      <id>5987</id>
      <parentid>5985</parentid>
      <timestamp>2025-11-15T15:02:36Z</timestamp>
      <contributor>
        <username>Dumbassman</username>
        <id>1091</id>
      </contributor>
      <minor />
      <comment>removed unnecessary spaces</comment>
      <origin>5987</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3580" sha1="9dhpo4aqo66tqbo2q3m7apoupcxjjii" xml:space="preserve">[[Isimumathi:Van Gogh - Starry Night - Google Art Project.jpg|thumb|isithombe esipendiweko kusetjenziswa ubukghwari]]
'''Ukupenda''' kungenye yendlela ezidala zokwethula ubukghwari, ivumela bonyana abantu abenza [[ubukghwari]] bakghone ukuveza imizwa yabo begodu bakghona ukuthi bathule nolokho abadlula kikho ngokuthi bapende ngemibala ehlukileko, nangeentayela ezihlukahlukeneko ekusekela ekadeni kusapendwa emadwaleni ukufikela ebukghwarini banje bedijithali.&lt;ref&gt;Tandirli, E., 2012. Painting education &amp; artistic evolution. ''Procedia-Social and Behavioral Sciences'', ''46'', pp.4493-4497.&lt;/ref&gt; Ukupenda kuyinto etjhuguluka nesikhathi, itjengisie amasiko, ukuzwana kwabantu nokuthuthuka kwezinga letheknoloji emaphilweni wabantu.ukupenda kubukghwari obutjhuguluka ngokwesikhathi begodu kukhuthaze ababukeli ephasini loke.

=== Umlando ngokupenda ===
Ukupenda kuyinto eyathoma kade ebokanakala ngobufakazi ebutholakala emadwaleni, ematjeni wamazindla nemasontweni.&lt;ref&gt;Bakhtiyorovich, K.I. and Shodikulovich, T.A., 2021. The Role of Painting in the Folk Art of Surkhandarya. ''International Journal of Human Computing Studies'', ''3''(2), pp.26-28.&lt;/ref&gt; Izinto ezipendiweko ezidala khulu zivela bonyana ngezeminyaka eyi-40 000 eyadlulako, ipendwe babantu bakade basebenzisa izinto zemvelo namathulusi ebebazenzela wona ngamathambo. Nakuthoma khona kuba nokuthuthuka komphakathi kwatheleleka nokuthi kube nokuthuthuka kokuthi kube neendlela ezinye zokupenda ziza nabantu bakudala abama griki, abamaroma,nebegibithe.Ukupenda kuyinto ekhombisa umlando wabantu obulungiweko. Ngombana ukghona ukusikhombisa izinto ezakhe zenzeka ekadeni, amasiko wabantu begodu nokuthi umphakathi uphila njani.&lt;ref&gt;Wollheim, R., 2023. ''Painting as an Art'' (Vol. 33). Princeton University Press.&lt;/ref&gt; Ukupenda kukuthatha ukuthi umuntu akghone ukwakha inthombe engcondweni yakhe begodu eze neminye imibono. Kulekelela abantu bonyana bakghone ukuthi baphikise imibono yabantu nangabe abavuelani nayo. Ivumela abantu bonyana boakghone ukuveza imizwa yabo basebenzisa umbala nokuwuhlanganisa kwakhona.

=== Iintayela zokupenda ===

==== I-Realism ====
Lokhu kupenda okunqophileko begodu kuphethe imigwalo ezeleko ngelwazi lephasi. Lapha bantu abenza ubukghwari ngokupenda bahlose ukuthi bapende ngendlela eveza iphasi ngendlela linjalo ngaphandle kokuthi lihlotjiswe nofana litjhululwe. Ukupenda lokhu kubonakala ngokuthi ukupenda kwakhona kuphuma kusithombe sento njengoba sinjalo. Akufaki imizwa yabantu nofana ukuphikisana nemibono ethileko.

==== I-Abstract ====
Kupenda okungakhulumiko ekwenza ekugandelala umbala, ijamo kanye nokuzwakala kwento. Lokhu kupenda kubonakala ngokuthi kupenda amabumbeko, umbala ukuletha uumlayezo othileko. Abantu abapenda ngelndlela le bakghona ukuthii bapende ngokutjhuphuluka ngaphandlekokuthi Basabe imithetho yamasiko neminye imithetho. Lapho ekunanto eveza izinto zeqiniso ezikhona ephasini. Akufaki amagama lokho kutjho bona ababukeli kufanele bona babe nokuhlakanipha nofunda isiithombe sipendiweko bonyana sitjho ukuthini.

==== I-surrealism ne-Impression ====
Kupenda okevezwa njengbhudango, nofana umcabango,ubonakala ngokuthi ibe neenthome ezinganikelani ukuthula emoyeni. Lokhu kufaka ukuthatha iinkhathi lapho kupendwa khona iinkhathi ezithabisako, kufake nokukhanyan okuthileko ukukhanyisa isithombe sakhona. Esikhathi esinengi kupendwa iukukhombisa iinthado ezingaphandle kwendlu njebala elithileko. Igandelela ipilo yabantu yangemihla yesikhathi sanje.

== Iinkomba ==
[[Category:Ubukghwari]]
[[Category:Ukugwala]]
[[Category:Ithalente]]</text>
      <sha1>9dhpo4aqo66tqbo2q3m7apoupcxjjii</sha1>
    </revision>
  </page>
  <page>
    <title>Imizwa</title>
    <ns>0</ns>
    <id>993</id>
    <revision>
      <id>5990</id>
      <timestamp>2025-11-15T15:10:32Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;Imizwa kuyinto ekungasulula bona abantu bayihlathulule kodwana isuke itjengisa indlela umuntu azizwa ngakhona ngesikhathi esithileko, nakanabantu abathileko begodu ngaphasi kobujamo obuthileko.Isisekelo salokho umuntu adlula kikho begodu  imizwa inothelela endleleni umuntu enza ngayoo izinto, acabanga ngayo nofana ngendlela akghona ukwakha ngakhona ubudlelwano nabanye abantu.&lt;ref&gt;McFarlane, J.M., 2025. Theories of Emotions. ''Introduction to Psychology''.&lt;/ref&gt; Kunamathi...&quot;</comment>
      <origin>5990</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="793" sha1="fog6ube9ortuwbutqk91c13tep8yzev" xml:space="preserve">Imizwa kuyinto ekungasulula bona abantu bayihlathulule kodwana isuke itjengisa indlela umuntu azizwa ngakhona ngesikhathi esithileko, nakanabantu abathileko begodu ngaphasi kobujamo obuthileko.Isisekelo salokho umuntu adlula kikho begodu  imizwa inothelela endleleni umuntu enza ngayoo izinto, acabanga ngayo nofana ngendlela akghona ukwakha ngakhona ubudlelwano nabanye abantu.&lt;ref&gt;McFarlane, J.M., 2025. Theories of Emotions. ''Introduction to Psychology''.&lt;/ref&gt; Kunamathiyori amanengi ahluthula imizwa njenge thiyori ka-James Lange, lapho ahlathulula khona bonyana imizwa evela njengependulo yalokhu umuntu akuzwako ebhodulukweni ahlala kilo.&lt;ref&gt;Livingston, P., 2019. Lange vs James on emotion, passion, and the arts. ''Royal Institute of Philosophy Supplements'', ''85'', pp.39-56.&lt;/ref&gt;</text>
      <sha1>fog6ube9ortuwbutqk91c13tep8yzev</sha1>
    </revision>
    <revision>
      <id>5991</id>
      <parentid>5990</parentid>
      <timestamp>2025-11-15T15:11:19Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5991</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="815" sha1="r33u8u2vesd1lr3aq88b6pyftp8ja3i" xml:space="preserve">'''Imizwa''' kuyinto ekungasulula bona abantu bayihlathulule kodwana isuke itjengisa indlela umuntu azizwa ngakhona ngesikhathi esithileko, nakanabantu abathileko begodu ngaphasi kobujamo obuthileko.Isisekelo salokho umuntu adlula kikho begodu  imizwa inothelela endleleni umuntu enza ngayoo izinto, acabanga ngayo nofana ngendlela akghona ukwakha ngakhona ubudlelwano nabanye abantu.&lt;ref&gt;McFarlane, J.M., 2025. Theories of Emotions. ''Introduction to Psychology''.&lt;/ref&gt; Kunamathiyori amanengi ahluthula imizwa njenge thiyori ka-James Lange, lapho ahlathulula khona bonyana imizwa evela njengependulo yalokhu umuntu akuzwako ebhodulukweni ahlala kilo.&lt;ref&gt;Livingston, P., 2019. Lange vs James on emotion, passion, and the arts. ''Royal Institute of Philosophy Supplements'', ''85'', pp.39-56.&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>r33u8u2vesd1lr3aq88b6pyftp8ja3i</sha1>
    </revision>
    <revision>
      <id>5992</id>
      <parentid>5991</parentid>
      <timestamp>2025-11-15T15:27:59Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5992</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1732" sha1="e9abzovsly1ghjbezoud451epx177nh" xml:space="preserve">'''Imizwa''' kuyinto ekungasulula bona abantu bayihlathulule kodwana isuke itjengisa indlela umuntu azizwa ngakhona ngesikhathi esithileko, nakanabantu abathileko begodu ngaphasi kobujamo obuthileko.Isisekelo salokho umuntu adlula kikho begodu  imizwa inothelela endleleni umuntu enza ngayoo izinto, acabanga ngayo nofana ngendlela akghona ukwakha ngakhona ubudlelwano nabanye abantu.&lt;ref&gt;McFarlane, J.M., 2025. Theories of Emotions. ''Introduction to Psychology''.&lt;/ref&gt; Kunamathiyori amanengi ahluthula imizwa njenge thiyori ka-James Lange, lapho ahlathulula khona bonyana imizwa evela njengependulo yalokhu umuntu akuzwako ebhodulukweni ahlala kilo.&lt;ref&gt;Livingston, P., 2019. Lange vs James on emotion, passion, and the arts. ''Royal Institute of Philosophy Supplements'', ''85'', pp.39-56.&lt;/ref&gt; Abanye abahllathulula imizwa ngamathiyori ngemizwa ngu-cannon-Bard no Schachter-Singer. Imizwa ihlukile kunomuzwa ngombana imizwa ayithathi isikhathi ingatjhuguluka nanoma kukunini begodu akusilula ukuwulawula bese kuthi umuzwa uthathe isiskhathi lokha umuntu nakawuzwako ulawulwa kukuthi umuntu uzwani nofana ubonani ebhodulukweni lakhe.

==== Ukuthaba ====
Ukuthaba kukumizwa evela lokha umuntu azizwa anelisekile emoyeni wakhe begodu kungekho into engaphula umoya wakhe. Imizwa yokuthaba ingavela lokha umuntu nakenzakalelwe yinto ehle efana nokuthi azithole aphumelele nofana athengelwe into ayithandako nokhuye okuthbisako. Umuntu lokha nakathabileko angabonakala nngookuthi amomotheke, aledlhe emzimbeni. ukuthaba kuyinto edlala indima eqakathekileko emaphilweni wabantu ngombana kubalelekela bona babekezele, bahlale banomuzwa wokutlama, begodu bakghone ukuthi bahlanganyele nabanye abantu.

==== Ukudana ====

== Iinkomba ==</text>
      <sha1>e9abzovsly1ghjbezoud451epx177nh</sha1>
    </revision>
    <revision>
      <id>5993</id>
      <parentid>5992</parentid>
      <timestamp>2025-11-15T15:29:48Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5993</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1819" sha1="044tngavkmhawuig7dkhgq6v508naf0" xml:space="preserve">'''Imizwa''' kuyinto ekungasulula bona abantu bayihlathulule kodwana isuke itjengisa indlela umuntu azizwa ngakhona ngesikhathi esithileko, nakanabantu abathileko begodu ngaphasi kobujamo obuthileko.Isisekelo salokho umuntu adlula kikho begodu  imizwa inothelela endleleni umuntu enza ngayoo izinto, acabanga ngayo nofana ngendlela akghona ukwakha ngakhona ubudlelwano nabanye abantu.&lt;ref&gt;McFarlane, J.M., 2025. Theories of Emotions. ''Introduction to Psychology''.&lt;/ref&gt; Kunamathiyori amanengi ahluthula imizwa njenge thiyori ka-James Lange, lapho ahlathulula khona bonyana imizwa evela njengependulo yalokhu umuntu akuzwako ebhodulukweni ahlala kilo.&lt;ref&gt;Livingston, P., 2019. Lange vs James on emotion, passion, and the arts. ''Royal Institute of Philosophy Supplements'', ''85'', pp.39-56.&lt;/ref&gt; Abanye abahllathulula imizwa ngamathiyori ngemizwa ngu-cannon-Bard no Schachter-Singer. Imizwa ihlukile kunomuzwa ngombana imizwa ayithathi isikhathi ingatjhuguluka nanoma kukunini begodu akusilula ukuwulawula bese kuthi umuzwa uthathe isiskhathi lokha umuntu nakawuzwako ulawulwa kukuthi umuntu uzwani nofana ubonani ebhodulukweni lakhe.

==== Ukuthaba ====
Ukuthaba kukumizwa evela lokha umuntu azizwa anelisekile emoyeni wakhe begodu kungekho into engaphula umoya wakhe. Imizwa yokuthaba ingavela lokha umuntu nakenzakalelwe yinto ehle efana nokuthi azithole aphumelele nofana athengelwe into ayithandako nokhuye okuthbisako. Umuntu lokha nakathabileko angabonakala nngookuthi amomotheke, aledlhe emzimbeni. ukuthaba kuyinto edlala indima eqakathekileko emaphilweni wabantu ngombana kubalelekela bona babekezele, bahlale banomuzwa wokutlama, begodu bakghone ukuthi bahlanganyele nabanye abantu.

==== Ukudana ====

== Iinkomba ==
[[Category: imizwa]]
[[Category: Umuzwa]]
[[Category: Ukuthaba]]
[[Category: Ukudana]]</text>
      <sha1>044tngavkmhawuig7dkhgq6v508naf0</sha1>
    </revision>
    <revision>
      <id>5994</id>
      <parentid>5993</parentid>
      <timestamp>2025-11-15T15:39:45Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5994</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2710" sha1="loboori9oc7a4vratw9jzb3trczuacr" xml:space="preserve">'''Imizwa''' kuyinto ekungasulula bona abantu bayihlathulule kodwana isuke itjengisa indlela umuntu azizwa ngakhona ngesikhathi esithileko, nakanabantu abathileko begodu ngaphasi kobujamo obuthileko.Isisekelo salokho umuntu adlula kikho begodu  imizwa inothelela endleleni umuntu enza ngayoo izinto, acabanga ngayo nofana ngendlela akghona ukwakha ngakhona ubudlelwano nabanye abantu.&lt;ref&gt;McFarlane, J.M., 2025. Theories of Emotions. ''Introduction to Psychology''.&lt;/ref&gt; Kunamathiyori amanengi ahluthula imizwa njenge thiyori ka-James Lange, lapho ahlathulula khona bonyana imizwa evela njengependulo yalokhu umuntu akuzwako ebhodulukweni ahlala kilo.&lt;ref&gt;Livingston, P., 2019. Lange vs James on emotion, passion, and the arts. ''Royal Institute of Philosophy Supplements'', ''85'', pp.39-56.&lt;/ref&gt; Abanye abahllathulula imizwa ngamathiyori ngemizwa ngu-cannon-Bard no Schachter-Singer. Imizwa ihlukile kunomuzwa ngombana imizwa ayithathi isikhathi ingatjhuguluka nanoma kukunini begodu akusilula ukuwulawula bese kuthi umuzwa uthathe isiskhathi lokha umuntu nakawuzwako ulawulwa kukuthi umuntu uzwani nofana ubonani ebhodulukweni lakhe.

==== Ukuthaba ====
Ukuthaba kukumizwa evela lokha umuntu azizwa anelisekile emoyeni wakhe begodu kungekho into engaphula umoya wakhe. Imizwa yokuthaba ingavela lokha umuntu nakenzakalelwe yinto ehle efana nokuthi azithole aphumelele nofana athengelwe into ayithandako nokhuye okuthabisako.&lt;ref&gt;PS, S. and Mahalakshmi, G., 2017. Emotion models: a review. ''International Journal of Control Theory and Applications'', ''10''(8), pp.651-657.&lt;/ref&gt; Umuntu lokha nakathabileko angabonakala ngokuthi amomotheke, aledlhe emzimbeni. ukuthaba kuyinto edlala indima eqakathekileko emaphilweni wabantu ngombana kubalelekela bona babekezele, bahlale banomuzwa wokutlama, begodu bakghone ukuthi bahlanganyele nabanye abantu.

==== Ukudana ====
Ukudana kuvezwa mumuzwa wokungabi nethemba, ukuzwa ubuhlungu emoyeni nofana emzimbeni.&lt;ref&gt;Perrotta, G., 2021. The “Human Emotions” and the “Perrotta Human Emotions Model”(PHEM): The new theoretical model. ''Historical, neurobiological and clinical profiles. Arch Depress Anxiety'', ''7''(2), pp.020-027.&lt;/ref&gt; Esikhathini esinengi ukudana kungabangela kukuthi umuntu aphoceke, azwe iiindaba ezibuhlungu nofana ukungaphumeleli. Ukudana kungabonakala ngokuthi umuntu azikhiphe hlangana nanbantu, alile iinyembezi nofana ajame ngendlela elengisa umzimba. ukudana kumizwa obuhlungu kodwana udlala indima eqakathekileko kwabanye abantu ngombana umizwa lo ukhuthaza ukuthi umuntu azihlole yena begodu afune ukulingisa iimphoso zakhe.

== Iinkomba ==
[[Category: imizwa]]
[[Category: Umuzwa]]
[[Category: Ukuthaba]]
[[Category: Ukudana]]</text>
      <sha1>loboori9oc7a4vratw9jzb3trczuacr</sha1>
    </revision>
    <revision>
      <id>5995</id>
      <parentid>5994</parentid>
      <timestamp>2025-11-15T15:49:43Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5995</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3773" sha1="i89v1kfx0ty4jlvdw6hj4qh969w8qpo" xml:space="preserve">'''Imizwa''' kuyinto ekungasulula bona abantu bayihlathulule kodwana isuke itjengisa indlela umuntu azizwa ngakhona ngesikhathi esithileko, nakanabantu abathileko begodu ngaphasi kobujamo obuthileko.Isisekelo salokho umuntu adlula kikho begodu  imizwa inothelela endleleni umuntu enza ngayoo izinto, acabanga ngayo nofana ngendlela akghona ukwakha ngakhona ubudlelwano nabanye abantu.&lt;ref&gt;McFarlane, J.M., 2025. Theories of Emotions. ''Introduction to Psychology''.&lt;/ref&gt; Kunamathiyori amanengi ahluthula imizwa njenge thiyori ka-James Lange, lapho ahlathulula khona bonyana imizwa evela njengependulo yalokhu umuntu akuzwako ebhodulukweni ahlala kilo.&lt;ref&gt;Livingston, P., 2019. Lange vs James on emotion, passion, and the arts. ''Royal Institute of Philosophy Supplements'', ''85'', pp.39-56.&lt;/ref&gt; Abanye abahllathulula imizwa ngamathiyori ngemizwa ngu-cannon-Bard no Schachter-Singer. Imizwa ihlukile kunomuzwa ngombana imizwa ayithathi isikhathi ingatjhuguluka nanoma kukunini begodu akusilula ukuwulawula bese kuthi umuzwa uthathe isiskhathi lokha umuntu nakawuzwako ulawulwa kukuthi umuntu uzwani nofana ubonani ebhodulukweni lakhe.

==== Ukuthaba ====
Ukuthaba kukumizwa evela lokha umuntu azizwa anelisekile emoyeni wakhe begodu kungekho into engaphula umoya wakhe. Imizwa yokuthaba ingavela lokha umuntu nakenzakalelwe yinto ehle efana nokuthi azithole aphumelele nofana athengelwe into ayithandako nokhuye okuthabisako.&lt;ref&gt;PS, S. and Mahalakshmi, G., 2017. Emotion models: a review. ''International Journal of Control Theory and Applications'', ''10''(8), pp.651-657.&lt;/ref&gt; Umuntu lokha nakathabileko angabonakala ngokuthi amomotheke, aledlhe emzimbeni. ukuthaba kuyinto edlala indima eqakathekileko emaphilweni wabantu ngombana kubalelekela bona babekezele, bahlale banomuzwa wokutlama, begodu bakghone ukuthi bahlanganyele nabanye abantu.

==== Ukudana ====
Ukudana kuvezwa mumuzwa wokungabi nethemba, ukuzwa ubuhlungu emoyeni nofana emzimbeni.&lt;ref&gt;Perrotta, G., 2021. The “Human Emotions” and the “Perrotta Human Emotions Model”(PHEM): The new theoretical model. ''Historical, neurobiological and clinical profiles. Arch Depress Anxiety'', ''7''(2), pp.020-027.&lt;/ref&gt; Esikhathini esinengi ukudana kungabangela kukuthi umuntu aphoceke, azwe iiindaba ezibuhlungu nofana ukungaphumeleli. Ukudana kungabonakala ngokuthi umuntu azikhiphe hlangana nanbantu, alile iinyembezi nofana ajame ngendlela elengisa umzimba. ukudana kumizwa obuhlungu kodwana udlala indima eqakathekileko kwabanye abantu ngombana umizwa lo ukhuthaza ukuthi umuntu azihlole yena begodu afune ukulingisa iimphoso zakhe.

=== Ukwesaba ===
Ukwesaba kumumuzwa ovela lokha nangabe umuntu kunento eyingozi athuselwa ngayo nofana emlandelako. Ukwesaba kungavela lokha umuntu nakabona bonyana usemrarweni ongararululeki lula nofana nakabona bonyana ipilo yakhe isengezini.&lt;ref&gt;Stanojlović, O., Šutulović, N., Hrnčić, D., Mladenović, D., Rašić-Marković, A., Radunović, N. and Vesković, M., 2021. Neural pathways underlying the interplay between emotional experience and behavior, from old theories to modern insight. ''Archives of Biological Sciences'', ''73''(3), pp.361-370.&lt;/ref&gt;Umizwa lo ungavela lokha umuntu nakakhamba yedwa ebusuku endaweni lapho kuyingozi khona. Umzimba ungena entweni ebizwa ngokuthi &quot; phendula ngokulwa nofana ubaleke&quot;.&lt;ref&gt;Roelofs, K., 2017. Freeze for action: neurobiological mechanisms in animal and human freezing. ''Philosophical Transactions of the Royal Society B: Biological Sciences'', ''372''(1718), p.20160206.&lt;/ref&gt; Imizwa yokusaba ilekela umuntu bonyana ahlale aqaphelile laphoo akhona nofana akhamba khona begodu angangeni nanoma kukuphi.

== Iinkomba ==
[[Category: imizwa]]
[[Category: Umuzwa]]
[[Category: Ukuthaba]]
[[Category: Ukudana]]</text>
      <sha1>i89v1kfx0ty4jlvdw6hj4qh969w8qpo</sha1>
    </revision>
    <revision>
      <id>5996</id>
      <parentid>5995</parentid>
      <timestamp>2025-11-15T15:51:23Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5996</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3803" sha1="7dt7ic8cno6r307r2ltzb8b7d6mvwgh" xml:space="preserve">'''Imizwa''' kuyinto ekungasulula bona abantu bayihlathulule kodwana isuke itjengisa indlela umuntu azizwa ngakhona ngesikhathi esithileko, nakanabantu abathileko begodu ngaphasi kobujamo obuthileko.Isisekelo salokho umuntu adlula kikho begodu  imizwa inothelela endleleni umuntu enza ngayoo izinto, acabanga ngayo nofana ngendlela akghona ukwakha ngakhona ubudlelwano nabanye abantu.&lt;ref&gt;McFarlane, J.M., 2025. Theories of Emotions. ''Introduction to Psychology''.&lt;/ref&gt; Kunamathiyori amanengi ahluthula imizwa njenge thiyori ka-James Lange, lapho ahlathulula khona bonyana imizwa evela njengependulo yalokhu umuntu akuzwako ebhodulukweni ahlala kilo.&lt;ref&gt;Livingston, P., 2019. Lange vs James on emotion, passion, and the arts. ''Royal Institute of Philosophy Supplements'', ''85'', pp.39-56.&lt;/ref&gt; Abanye abahllathulula imizwa ngamathiyori ngemizwa ngu-cannon-Bard no Schachter-Singer. Imizwa ihlukile kunomuzwa ngombana imizwa ayithathi isikhathi ingatjhuguluka nanoma kukunini begodu akusilula ukuwulawula bese kuthi [[umuzwa]] uthathe isiskhathi lokha umuntu nakawuzwako ulawulwa kukuthi umuntu uzwani nofana ubonani ebhodulukweni lakhe.

=== Imihlobo yemizwa ===

==== Ukuthaba ====
Ukuthaba kukumizwa evela lokha umuntu azizwa anelisekile emoyeni wakhe begodu kungekho into engaphula umoya wakhe. Imizwa yokuthaba ingavela lokha umuntu nakenzakalelwe yinto ehle efana nokuthi azithole aphumelele nofana athengelwe into ayithandako nokhuye okuthabisako.&lt;ref&gt;PS, S. and Mahalakshmi, G., 2017. Emotion models: a review. ''International Journal of Control Theory and Applications'', ''10''(8), pp.651-657.&lt;/ref&gt; Umuntu lokha nakathabileko angabonakala ngokuthi amomotheke, aledlhe emzimbeni. ukuthaba kuyinto edlala indima eqakathekileko emaphilweni wabantu ngombana kubalelekela bona babekezele, bahlale banomuzwa wokutlama, begodu bakghone ukuthi bahlanganyele nabanye abantu.

==== Ukudana ====
Ukudana kuvezwa mumuzwa wokungabi nethemba, ukuzwa ubuhlungu emoyeni nofana emzimbeni.&lt;ref&gt;Perrotta, G., 2021. The “Human Emotions” and the “Perrotta Human Emotions Model”(PHEM): The new theoretical model. ''Historical, neurobiological and clinical profiles. Arch Depress Anxiety'', ''7''(2), pp.020-027.&lt;/ref&gt; Esikhathini esinengi ukudana kungabangela kukuthi umuntu aphoceke, azwe iiindaba ezibuhlungu nofana ukungaphumeleli. Ukudana kungabonakala ngokuthi umuntu azikhiphe hlangana nanbantu, alile iinyembezi nofana ajame ngendlela elengisa umzimba. ukudana kumizwa obuhlungu kodwana udlala indima eqakathekileko kwabanye abantu ngombana umizwa lo ukhuthaza ukuthi umuntu azihlole yena begodu afune ukulingisa iimphoso zakhe.

=== Ukwesaba ===
Ukwesaba kumumuzwa ovela lokha nangabe umuntu kunento eyingozi athuselwa ngayo nofana emlandelako. Ukwesaba kungavela lokha umuntu nakabona bonyana usemrarweni ongararululeki lula nofana nakabona bonyana ipilo yakhe isengezini.&lt;ref&gt;Stanojlović, O., Šutulović, N., Hrnčić, D., Mladenović, D., Rašić-Marković, A., Radunović, N. and Vesković, M., 2021. Neural pathways underlying the interplay between emotional experience and behavior, from old theories to modern insight. ''Archives of Biological Sciences'', ''73''(3), pp.361-370.&lt;/ref&gt;Umizwa lo ungavela lokha umuntu nakakhamba yedwa ebusuku endaweni lapho kuyingozi khona. Umzimba ungena entweni ebizwa ngokuthi &quot; phendula ngokulwa nofana ubaleke&quot;.&lt;ref&gt;Roelofs, K., 2017. Freeze for action: neurobiological mechanisms in animal and human freezing. ''Philosophical Transactions of the Royal Society B: Biological Sciences'', ''372''(1718), p.20160206.&lt;/ref&gt; Imizwa yokusaba ilekela umuntu bonyana ahlale aqaphelile laphoo akhona nofana akhamba khona begodu angangeni nanoma kukuphi.

== Iinkomba ==
[[Category: imizwa]]
[[Category: Umuzwa]]
[[Category: Ukuthaba]]
[[Category: Ukudana]]</text>
      <sha1>7dt7ic8cno6r307r2ltzb8b7d6mvwgh</sha1>
    </revision>
    <revision>
      <id>5997</id>
      <parentid>5996</parentid>
      <timestamp>2025-11-15T15:53:45Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5997</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3866" sha1="0w0pwj16aejaqm1hbh0s61wql60sjew" xml:space="preserve">'''Imizwa''' kuyinto ekungasulula bona abantu bayihlathulule kodwana isuke itjengisa indlela umuntu azizwa ngakhona ngesikhathi esithileko, nakanabantu abathileko begodu ngaphasi kobujamo obuthileko.Isisekelo salokho umuntu adlula kikho begodu  imizwa inothelela endleleni umuntu enza ngayoo izinto, acabanga ngayo nofana ngendlela akghona ukwakha ngakhona ubudlelwano nabanye abantu.&lt;ref&gt;McFarlane, J.M., 2025. Theories of Emotions. ''Introduction to Psychology''.&lt;/ref&gt; Kunamathiyori amanengi ahluthula imizwa njenge thiyori ka-James Lange, lapho ahlathulula khona bonyana imizwa evela njengependulo yalokhu umuntu akuzwako ebhodulukweni ahlala kilo.&lt;ref&gt;Livingston, P., 2019. Lange vs James on emotion, passion, and the arts. ''Royal Institute of Philosophy Supplements'', ''85'', pp.39-56.&lt;/ref&gt; Abanye abahllathulula imizwa ngamathiyori ngemizwa ngu-cannon-Bard no Schachter-Singer. Imizwa ihlukile kunomuzwa ngombana imizwa ayithathi isikhathi ingatjhuguluka nanoma kukunini begodu akusilula ukuwulawula bese kuthi [[umuzwa]] uthathe isiskhathi lokha umuntu nakawuzwako ulawulwa kukuthi umuntu uzwani nofana ubonani ebhodulukweni lakhe.

=== Imihlobo yemizwa ===

==== Ukuthaba ====
[[Isimumathi:Happy men.jpg|thumb|Amadoda atjengisa ukuthaba]]
Ukuthaba kukumizwa evela lokha umuntu azizwa anelisekile emoyeni wakhe begodu kungekho into engaphula umoya wakhe. Imizwa yokuthaba ingavela lokha umuntu nakenzakalelwe yinto ehle efana nokuthi azithole aphumelele nofana athengelwe into ayithandako nokhuye okuthabisako.&lt;ref&gt;PS, S. and Mahalakshmi, G., 2017. Emotion models: a review. ''International Journal of Control Theory and Applications'', ''10''(8), pp.651-657.&lt;/ref&gt; Umuntu lokha nakathabileko angabonakala ngokuthi amomotheke, aledlhe emzimbeni. ukuthaba kuyinto edlala indima eqakathekileko emaphilweni wabantu ngombana kubalelekela bona babekezele, bahlale banomuzwa wokutlama, begodu bakghone ukuthi bahlanganyele nabanye abantu.

==== Ukudana ====
Ukudana kuvezwa mumuzwa wokungabi nethemba, ukuzwa ubuhlungu emoyeni nofana emzimbeni.&lt;ref&gt;Perrotta, G., 2021. The “Human Emotions” and the “Perrotta Human Emotions Model”(PHEM): The new theoretical model. ''Historical, neurobiological and clinical profiles. Arch Depress Anxiety'', ''7''(2), pp.020-027.&lt;/ref&gt; Esikhathini esinengi ukudana kungabangela kukuthi umuntu aphoceke, azwe iiindaba ezibuhlungu nofana ukungaphumeleli. Ukudana kungabonakala ngokuthi umuntu azikhiphe hlangana nabantu, alile iinyembezi nofana ajame ngendlela elengisa umzimba. ukudana kumizwa obuhlungu kodwana udlala indima eqakathekileko kwabanye abantu ngombana umizwa lo ukhuthaza ukuthi umuntu azihlole yena begodu afune ukulingisa iimphoso zakhe.

==== Ukwesaba ====
Ukwesaba kumumuzwa ovela lokha nangabe umuntu kunento eyingozi athuselwa ngayo nofana emlandelako. Ukwesaba kungavela lokha umuntu nakabona bonyana usemrarweni ongararululeki lula nofana nakabona bonyana ipilo yakhe isengezini.&lt;ref&gt;Stanojlović, O., Šutulović, N., Hrnčić, D., Mladenović, D., Rašić-Marković, A., Radunović, N. and Vesković, M., 2021. Neural pathways underlying the interplay between emotional experience and behavior, from old theories to modern insight. ''Archives of Biological Sciences'', ''73''(3), pp.361-370.&lt;/ref&gt;Umizwa lo ungavela lokha umuntu nakakhamba yedwa ebusuku endaweni lapho kuyingozi khona. Umzimba ungena entweni ebizwa ngokuthi &quot; phendula ngokulwa nofana ubaleke&quot;.&lt;ref&gt;Roelofs, K., 2017. Freeze for action: neurobiological mechanisms in animal and human freezing. ''Philosophical Transactions of the Royal Society B: Biological Sciences'', ''372''(1718), p.20160206.&lt;/ref&gt; Imizwa yokusaba ilekela umuntu bonyana ahlale aqaphelile laphoo akhona nofana akhamba khona begodu angangeni nanoma kukuphi.

== Iinkomba ==
[[Category: imizwa]]
[[Category: Umuzwa]]
[[Category: Ukuthaba]]
[[Category: Ukudana]]</text>
      <sha1>0w0pwj16aejaqm1hbh0s61wql60sjew</sha1>
    </revision>
    <revision>
      <id>5998</id>
      <parentid>5997</parentid>
      <timestamp>2025-11-15T16:17:35Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>5998</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4583" sha1="7j88j6qrji2yiotylm32s2kl12nkmlw" xml:space="preserve">'''Imizwa''' kuyinto ekungasulula bona abantu bayihlathulule kodwana isuke itjengisa indlela umuntu azizwa ngakhona ngesikhathi esithileko, nakanabantu abathileko begodu ngaphasi kobujamo obuthileko.Isisekelo salokho umuntu adlula kikho begodu  imizwa inothelela endleleni umuntu enza ngayoo izinto, acabanga ngayo nofana ngendlela akghona ukwakha ngakhona ubudlelwano nabanye abantu.&lt;ref&gt;McFarlane, J.M., 2025. Theories of Emotions. ''Introduction to Psychology''.&lt;/ref&gt; Kunamathiyori amanengi ahluthula imizwa njenge thiyori ka-James Lange, lapho ahlathulula khona bonyana imizwa evela njengependulo yalokhu umuntu akuzwako ebhodulukweni ahlala kilo.&lt;ref&gt;Livingston, P., 2019. Lange vs James on emotion, passion, and the arts. ''Royal Institute of Philosophy Supplements'', ''85'', pp.39-56.&lt;/ref&gt; Abanye abahllathulula imizwa ngamathiyori ngemizwa ngu-cannon-Bard no Schachter-Singer. Imizwa ihlukile kunomuzwa ngombana imizwa ayithathi isikhathi ingatjhuguluka nanoma kukunini begodu akusilula ukuwulawula bese kuthi [[umuzwa]] uthathe isiskhathi lokha umuntu nakawuzwako ulawulwa kukuthi umuntu uzwani nofana ubonani ebhodulukweni lakhe.

=== Imihlobo yemizwa ===

==== Ukuthaba ====
[[Isimumathi:Happy men.jpg|thumb|Amadoda atjengisa ukuthaba]]
Ukuthaba kukumizwa evela lokha umuntu azizwa anelisekile emoyeni wakhe begodu kungekho into engaphula umoya wakhe. Imizwa yokuthaba ingavela lokha umuntu nakenzakalelwe yinto ehle efana nokuthi azithole aphumelele nofana athengelwe into ayithandako nokhuye okuthabisako.&lt;ref&gt;PS, S. and Mahalakshmi, G., 2017. Emotion models: a review. ''International Journal of Control Theory and Applications'', ''10''(8), pp.651-657.&lt;/ref&gt; Umuntu lokha nakathabileko angabonakala ngokuthi amomotheke, aledlhe emzimbeni. ukuthaba kuyinto edlala indima eqakathekileko emaphilweni wabantu ngombana kubalelekela bona babekezele, bahlale banomuzwa wokutlama, begodu bakghone ukuthi bahlanganyele nabanye abantu.

==== Ukudana ====
Ukudana kuvezwa mumuzwa wokungabi nethemba, ukuzwa ubuhlungu emoyeni nofana emzimbeni.&lt;ref&gt;Perrotta, G., 2021. The “Human Emotions” and the “Perrotta Human Emotions Model”(PHEM): The new theoretical model. ''Historical, neurobiological and clinical profiles. Arch Depress Anxiety'', ''7''(2), pp.020-027.&lt;/ref&gt; Esikhathini esinengi ukudana kungabangela kukuthi umuntu aphoceke, azwe iiindaba ezibuhlungu nofana ukungaphumeleli. Ukudana kungabonakala ngokuthi umuntu azikhiphe hlangana nabantu, alile iinyembezi nofana ajame ngendlela elengisa umzimba. ukudana kumizwa obuhlungu kodwana udlala indima eqakathekileko kwabanye abantu ngombana umizwa lo ukhuthaza ukuthi umuntu azihlole yena begodu afune ukulingisa iimphoso zakhe.

==== Ukwesaba ====
Ukwesaba kumumuzwa ovela lokha nangabe umuntu kunento eyingozi athuselwa ngayo nofana emlandelako. Ukwesaba kungavela lokha umuntu nakabona bonyana usemrarweni ongararululeki lula nofana nakabona bonyana ipilo yakhe isengezini.&lt;ref&gt;Stanojlović, O., Šutulović, N., Hrnčić, D., Mladenović, D., Rašić-Marković, A., Radunović, N. and Vesković, M., 2021. Neural pathways underlying the interplay between emotional experience and behavior, from old theories to modern insight. ''Archives of Biological Sciences'', ''73''(3), pp.361-370.&lt;/ref&gt;Umizwa lo ungavela lokha umuntu nakakhamba yedwa ebusuku endaweni lapho kuyingozi khona. Umzimba ungena entweni ebizwa ngokuthi &quot; phendula ngokulwa nofana ubaleke&quot;.&lt;ref&gt;Roelofs, K., 2017. Freeze for action: neurobiological mechanisms in animal and human freezing. ''Philosophical Transactions of the Royal Society B: Biological Sciences'', ''372''(1718), p.20160206.&lt;/ref&gt; Imizwa yokusaba ilekela umuntu bonyana ahlale aqaphelile laphoo akhona nofana akhamba khona begodu angangeni nanoma kukuphi.

==== Ukukwata ====
Ukukwata kummhlobo wemizwa ongavuka lokha umuntu nakenzakalelwa yinto  angayithandiko emenza bona abe nenenturhu nofana athukane.Ukukwata kungabonakala ngokuthi umuntu abumbe izandla zibe ziinqindi, aphakamise iphumbo lakhe lokha nakakhulumako nofana afune ukulwa.Ukukwata kungaba yinto eyenza bona  umuntu amotjhe, nofana agcine enza izinto eziphula umthetho agcine angena emrarweni  lokha nangebe ulawulwa kukwata.&lt;ref&gt;Deniz, P., Lajunen, T., Özkan, T. and Gaygısız, E., 2021. Masculinity, femininity, and angry drivers: Masculinity and femininity as moderators between driver anger and anger expression style among young drivers. ''Accident Analysis &amp; Prevention'', ''161'', p.106347.&lt;/ref&gt;

== Iinkomba ==
[[Category: imizwa]]
[[Category: Umuzwa]]
[[Category: Ukuthaba]]
[[Category: Ukudana]]</text>
      <sha1>7j88j6qrji2yiotylm32s2kl12nkmlw</sha1>
    </revision>
  </page>
  <page>
    <title>Umuzwa</title>
    <ns>0</ns>
    <id>994</id>
    <revision>
      <id>5999</id>
      <timestamp>2025-11-16T11:11:35Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;Umuzwa yindlela ezithobileko umuntu azizwa ngayo ngesibanga yemizwa yakhe, imicabango, nolokho okwenzeka ebhodulukweni ahlala kilo. Umuzwa kuyinto engaphakathi esenza bona sikghone ukuzwisisa imizwa yethu, sikghona ukuhlathulula bonyana sizizwa bunjani ngesibanga sento esihlangabezene nayo. woke umuntu uba nemizwa ehlukahlukaneko ngesibanga sokuthi sibabantu asifani begodu asiboni ngendlela efanako nofana sicabange ngendlela efanako.&lt;ref&gt;Nummenmaa, L., Hari, R., Hietanen...&quot;</comment>
      <origin>5999</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="975" sha1="fxy4px2kwvclsql8dr5v4gjrx670jxc" xml:space="preserve">Umuzwa yindlela ezithobileko umuntu azizwa ngayo ngesibanga yemizwa yakhe, imicabango, nolokho okwenzeka ebhodulukweni ahlala kilo. Umuzwa kuyinto engaphakathi esenza bona sikghone ukuzwisisa imizwa yethu, sikghona ukuhlathulula bonyana sizizwa bunjani ngesibanga sento esihlangabezene nayo. woke umuntu uba nemizwa ehlukahlukaneko ngesibanga sokuthi sibabantu asifani begodu asiboni ngendlela efanako nofana sicabange ngendlela efanako.&lt;ref&gt;Nummenmaa, L., Hari, R., Hietanen, J.K. and Glerean, E., 2018. Maps of subjective feelings. ''Proceedings of the National Academy of Sciences'', ''115''(37), pp.9198-9203.&lt;/ref&gt; Umuzwa ubangelwa zizinto ezinengi ezifana nokuthi umuntu ukhumbula ini nokhunye. Umuzwa ukhambelana nokuthi umuntu uzibona njani yena, isimo sakhe sengcondo nokuthi uziphatha njani. Umuzwa usikhuthaza bona sifune ukwenza izinto ezithileko, ukwakha ubudlelwana nabanye abantu begodu sizivikele engozini. Ukhambelana  nokuphila kuhle emzimbeni nengcondweni.</text>
      <sha1>fxy4px2kwvclsql8dr5v4gjrx670jxc</sha1>
    </revision>
    <revision>
      <id>6000</id>
      <parentid>5999</parentid>
      <timestamp>2025-11-16T11:12:39Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6000</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="997" sha1="91fzo00mitc9gkbnd3xa60jpuza00k8" xml:space="preserve">'''Umuzwa''' yindlela ezithobileko umuntu azizwa ngayo ngesibanga yemizwa yakhe, imicabango, nolokho okwenzeka ebhodulukweni ahlala kilo. Umuzwa kuyinto engaphakathi esenza bona sikghone ukuzwisisa imizwa yethu, sikghona ukuhlathulula bonyana sizizwa bunjani ngesibanga sento esihlangabezene nayo. woke umuntu uba nemizwa ehlukahlukaneko ngesibanga sokuthi sibabantu asifani begodu asiboni ngendlela efanako nofana sicabange ngendlela efanako.&lt;ref&gt;Nummenmaa, L., Hari, R., Hietanen, J.K. and Glerean, E., 2018. Maps of subjective feelings. ''Proceedings of the National Academy of Sciences'', ''115''(37), pp.9198-9203.&lt;/ref&gt; Umuzwa ubangelwa zizinto ezinengi ezifana nokuthi umuntu ukhumbula ini nokhunye. Umuzwa ukhambelana nokuthi umuntu uzibona njani yena, isimo sakhe sengcondo nokuthi uziphatha njani. Umuzwa usikhuthaza bona sifune ukwenza izinto ezithileko, ukwakha ubudlelwana nabanye abantu begodu sizivikele engozini. Ukhambelana  nokuphila kuhle emzimbeni nengcondweni.

== Iinkomba ==</text>
      <sha1>91fzo00mitc9gkbnd3xa60jpuza00k8</sha1>
    </revision>
    <revision>
      <id>6001</id>
      <parentid>6000</parentid>
      <timestamp>2025-11-16T11:15:33Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6001</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1083" sha1="sfhjro6d927m49tj1lr9pvycsd42co7" xml:space="preserve">'''Umuzwa''' yindlela ezithobileko umuntu azizwa ngayo ngesibanga yemizwa yakhe, imicabango, nolokho okwenzeka ebhodulukweni ahlala kilo. Umuzwa kuyinto engaphakathi esenza bona sikghone ukuzwisisa imizwa yethu, sikghona ukuhlathulula bonyana sizizwa bunjani ngesibanga sento esihlangabezene nayo. woke umuntu uba nemizwa ehlukahlukaneko ngesibanga sokuthi sibabantu asifani begodu asiboni ngendlela efanako nofana sicabange ngendlela efanako.&lt;ref&gt;Nummenmaa, L., Hari, R., Hietanen, J.K. and Glerean, E., 2018. Maps of subjective feelings. ''Proceedings of the National Academy of Sciences'', ''115''(37), pp.9198-9203.&lt;/ref&gt; Umuzwa ubangelwa zizinto ezinengi ezifana nokuthi umuntu ukhumbula ini nokhunye. Umuzwa ukhambelana nokuthi umuntu uzibona njani yena, isimo sakhe sengcondo nokuthi uziphatha njani. Umuzwa usikhuthaza bona sifune ukwenza izinto ezithileko, ukwakha ubudlelwana nabanye abantu begodu sizivikele engozini. Ukhambelana  nokuphila kuhle emzimbeni nengcondweni.

== Iinkomba ==
[[Category: Ithando]]
[[Category: Imizwa]]
[[Category: Inzondo]]
[[Category: Ihlazo]]</text>
      <sha1>sfhjro6d927m49tj1lr9pvycsd42co7</sha1>
    </revision>
    <revision>
      <id>6002</id>
      <parentid>6001</parentid>
      <timestamp>2025-11-16T11:38:02Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6002</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2273" sha1="ege2ou0b2oibzqfhjgue759xyozfpg2" xml:space="preserve">'''Umuzwa''' yindlela ezithobileko umuntu azizwa ngayo ngesibanga yemizwa yakhe, imicabango, nolokho okwenzeka ebhodulukweni ahlala kilo. Umuzwa kuyinto engaphakathi esenza bona sikghone ukuzwisisa [[imizwa]] yethu, sikghona ukuhlathulula bonyana sizizwa bunjani ngesibanga sento esihlangabezene nayo. woke umuntu uba nemizwa ehlukahlukaneko ngesibanga sokuthi sibabantu asifani begodu asiboni ngendlela efanako nofana sicabange ngendlela efanako.&lt;ref&gt;Nummenmaa, L., Hari, R., Hietanen, J.K. and Glerean, E., 2018. Maps of subjective feelings. ''Proceedings of the National Academy of Sciences'', ''115''(37), pp.9198-9203.&lt;/ref&gt; Umuzwa ubangelwa zizinto ezinengi ezifana nokuthi umuntu ukhumbula ini nokhunye. Umuzwa ukhambelana nokuthi umuntu uzibona njani yena, isimo sakhe sengcondo nokuthi uziphatha njani. Umuzwa usikhuthaza bona sifune ukwenza izinto ezithileko, ukwakha ubudlelwana nabanye abantu begodu sizivikele engozini. Ukhambelana  nokuphila kuhle emzimbeni nengcondweni. 

=== Imihlobo yemumzwa ===

==== Ithando ====
Lomumunzwa wokuzizwa uthabile begodu uphelele. Kukuhlangana okunamandla kwemizwa nomunye umuntu nofana nenye into.Libonakala ngookuthi umuntu abe netjhejo, ukuthintana ngokukhuluma nokhunye okuhle okwenza bonyana umuntu azizwe athabile emoyeni wakhe. Ithanda lenza bona umuntu aziizwe adududzekile, begodu afuthumele. umuntu nakanomuzwa wokuthanda uzinikela ngokupheleleko begodu anakelele iindingo zomuntu loyo amthandako ukuze bobabili bahlale bathabile. ithando lihlanganisa abantu libenze babemuunye begodu bathole ihlathululo yepilo.

Inzondo

Ngakwelinye ihlangothi inzondo ivellzwa kukuthi umuntuabe nemizwa enamandla yokungathani umuntu nofana into lokho kungabangelwa kukwata nofana kukwata, ukungaphatheki kuhle nofana ukulinyazwa emmoyeni. Umuntu angaba nenzondo ebantwini, entweni, esiqhemeni nofana ebhodulukweni elithileko. Inzondo ithatha imicabango yomuntu imvusele ukusilingeka, ukukwata nofana ukuthi umuntu afune ukuziphindiselela. Yenza bona umuntu azikhiphe ebantwini nofana entweni leyo ayizondako. Iinzondo ingenza bonyana umuntu angakghona ukuhlulela kuhle ngombana angagcina sele ahlangothi linye.

Ukuba mlandu



== Iinkomba ==
[[Category: Ithando]]
[[Category: Imizwa]]
[[Category: Inzondo]]
[[Category: Ihlazo]]</text>
      <sha1>ege2ou0b2oibzqfhjgue759xyozfpg2</sha1>
    </revision>
    <revision>
      <id>6003</id>
      <parentid>6002</parentid>
      <timestamp>2025-11-16T11:40:51Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6003</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2651" sha1="5fwyny10tr9cqb8h485rjs4ia90tjle" xml:space="preserve">'''Umuzwa''' yindlela ezithobileko umuntu azizwa ngayo ngesibanga yemizwa yakhe, imicabango, nolokho okwenzeka ebhodulukweni ahlala kilo. Umuzwa kuyinto engaphakathi esenza bona sikghone ukuzwisisa [[imizwa]] yethu, sikghona ukuhlathulula bonyana sizizwa bunjani ngesibanga sento esihlangabezene nayo. woke umuntu uba nemizwa ehlukahlukaneko ngesibanga sokuthi sibabantu asifani begodu asiboni ngendlela efanako nofana sicabange ngendlela efanako.&lt;ref&gt;Nummenmaa, L., Hari, R., Hietanen, J.K. and Glerean, E., 2018. Maps of subjective feelings. ''Proceedings of the National Academy of Sciences'', ''115''(37), pp.9198-9203.&lt;/ref&gt; Umuzwa ubangelwa zizinto ezinengi ezifana nokuthi umuntu ukhumbula ini nokhunye. Umuzwa ukhambelana nokuthi umuntu uzibona njani yena, isimo sakhe sengcondo nokuthi uziphatha njani. Umuzwa usikhuthaza bona sifune ukwenza izinto ezithileko, ukwakha ubudlelwana nabanye abantu begodu sizivikele engozini. Ukhambelana  nokuphila kuhle emzimbeni nengcondweni. 

=== Imihlobo yemumzwa ===

==== Ithando ====
Lomumunzwa wokuzizwa uthabile begodu uphelele. Kukuhlangana okunamandla kwemizwa nomunye umuntu nofana nenye into. Libonakala ngokuthi umuntu abe netjhejo, ukuthintana ngokukhuluma nokhunye okuhle okwenza bonyana umuntu azizwe athabile emoyeni wakhe.&lt;ref&gt;Sternberg, R.J. and Sternberg, K. eds., 2018. ''The new psychology of love''. Cambridge University Press.&lt;/ref&gt; Ithando lenza bona umuntu aziizwe aduduzekile, begodu afuthumele. umuntu nakanomuzwa wokuthanda uzinikela ngokupheleleko begodu anakelele iindingo zomuntu loyo amthandako ukuze bobabili bahlale bathabile. ithando lihlanganisa abantu libenze babemuunye begodu bathole ihlathululo yepilo.

Inzondo

Ngakwelinye ihlangothi inzondo ivellzwa kukuthi umuntuabe nemizwa enamandla yokungathani umuntu nofana into lokho kungabangelwa kukwata nofana kukwata, ukungaphatheki kuhle nofana ukulinyazwa emmoyeni.&lt;ref&gt;Haas, J. and Vogt, K.M., 2019. Love and Hatred. In ''The routledge handbook of love in philosophy'' (pp. 344-356). Routledge.&lt;/ref&gt; Umuntu angaba nenzondo ebantwini, entweni, esiqhemeni nofana ebhodulukweni elithileko. Inzondo ithatha imicabango yomuntu imvusele ukusilingeka, ukukwata nofana ukuthi umuntu afune ukuziphindiselela. Yenza bona umuntu azikhiphe ebantwini nofana entweni leyo ayizondako.&lt;ref&gt;Fischer, A., Halperin, E., Canetti, D. and Jasini, A., 2018. Why we hate. ''Emotion Review'', ''10''(4), pp.309-320.&lt;/ref&gt; Iinzondo ingenza bonyana umuntu angakghona ukuhlulela kuhle ngombana angagcina sele ahlangothi linye.

Ukuba mlandu



== Iinkomba ==
[[Category: Ithando]]
[[Category: Imizwa]]
[[Category: Inzondo]]
[[Category: Ihlazo]]</text>
      <sha1>5fwyny10tr9cqb8h485rjs4ia90tjle</sha1>
    </revision>
    <revision>
      <id>6004</id>
      <parentid>6003</parentid>
      <timestamp>2025-11-16T11:42:57Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6004</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2711" sha1="j38cxeik0kn63b1rifu6ynt49me6h1x" xml:space="preserve">'''Umuzwa''' yindlela ezithobileko umuntu azizwa ngayo ngesibanga yemizwa yakhe, imicabango, nolokho okwenzeka ebhodulukweni ahlala kilo. Umuzwa kuyinto engaphakathi esenza bona sikghone ukuzwisisa [[imizwa]] yethu, sikghona ukuhlathulula bonyana sizizwa bunjani ngesibanga sento esihlangabezene nayo. woke umuntu uba nemizwa ehlukahlukaneko ngesibanga sokuthi sibabantu asifani begodu asiboni ngendlela efanako nofana sicabange ngendlela efanako.&lt;ref&gt;Nummenmaa, L., Hari, R., Hietanen, J.K. and Glerean, E., 2018. Maps of subjective feelings. ''Proceedings of the National Academy of Sciences'', ''115''(37), pp.9198-9203.&lt;/ref&gt; Umuzwa ubangelwa zizinto ezinengi ezifana nokuthi umuntu ukhumbula ini nokhunye. Umuzwa ukhambelana nokuthi umuntu uzibona njani yena, isimo sakhe sengcondo nokuthi uziphatha njani. Umuzwa usikhuthaza bona sifune ukwenza izinto ezithileko, ukwakha ubudlelwana nabanye abantu begodu sizivikele engozini. Ukhambelana  nokuphila kuhle emzimbeni nengcondweni. 

=== Imihlobo yemumzwa ===

==== Ithando ====
[[Isimumathi:Love proposal.jpg|thumb|Abantu abathandanako]]
Lomumunzwa wokuzizwa uthabile begodu uphelele. Kukuhlangana okunamandla kwemizwa nomunye umuntu nofana nenye into. Libonakala ngokuthi umuntu abe netjhejo, ukuthintana ngokukhuluma nokhunye okuhle okwenza bonyana umuntu azizwe athabile emoyeni wakhe.&lt;ref&gt;Sternberg, R.J. and Sternberg, K. eds., 2018. ''The new psychology of love''. Cambridge University Press.&lt;/ref&gt; Ithando lenza bona umuntu aziizwe aduduzekile, begodu afuthumele. umuntu nakanomuzwa wokuthanda uzinikela ngokupheleleko begodu anakelele iindingo zomuntu loyo amthandako ukuze bobabili bahlale bathabile. ithando lihlanganisa abantu libenze babemuunye begodu bathole ihlathululo yepilo.

Inzondo

Ngakwelinye ihlangothi inzondo ivellzwa kukuthi umuntuabe nemizwa enamandla yokungathani umuntu nofana into lokho kungabangelwa kukwata nofana kukwata, ukungaphatheki kuhle nofana ukulinyazwa emmoyeni.&lt;ref&gt;Haas, J. and Vogt, K.M., 2019. Love and Hatred. In ''The routledge handbook of love in philosophy'' (pp. 344-356). Routledge.&lt;/ref&gt; Umuntu angaba nenzondo ebantwini, entweni, esiqhemeni nofana ebhodulukweni elithileko. Inzondo ithatha imicabango yomuntu imvusele ukusilingeka, ukukwata nofana ukuthi umuntu afune ukuziphindiselela. Yenza bona umuntu azikhiphe ebantwini nofana entweni leyo ayizondako.&lt;ref&gt;Fischer, A., Halperin, E., Canetti, D. and Jasini, A., 2018. Why we hate. ''Emotion Review'', ''10''(4), pp.309-320.&lt;/ref&gt; Iinzondo ingenza bonyana umuntu angakghona ukuhlulela kuhle ngombana angagcina sele ahlangothi linye.

Ukuba mlandu



== Iinkomba ==
[[Category: Ithando]]
[[Category: Imizwa]]
[[Category: Inzondo]]
[[Category: Ihlazo]]</text>
      <sha1>j38cxeik0kn63b1rifu6ynt49me6h1x</sha1>
    </revision>
  </page>
  <page>
    <title>Ukuhlubuka Kwe-Intanethi!</title>
    <ns>0</ns>
    <id>995</id>
    <revision>
      <id>6005</id>
      <timestamp>2025-11-18T12:49:17Z</timestamp>
      <contributor>
        <username>Roman Oy Bobrov</username>
        <id>167</id>
      </contributor>
      <comment>Created page with &quot; Ukuhlubuka Kwe-Intanethi! Noma Umbhalo Wokuhlubuka Kwe-South Ndebelia Kuwo Wonke Amaphephandaba.  Ekwashumi emoyeni we-2025, isithunzi sokuhlubuka sasibekile esifweni lethu se-Intanethi. Isixuku sabahlubukile, abafuthunyezwe amacebo amanga e-Intanethi ngomuntu okuthiwa uNtulikazi, basibeka isandla sobunye bethu ngokwenza udlame oluphephandabeni lukadijithali. Lesi senzakalo sizogcina njenge-Sokuhlubuka Kwe-Intanethi KweSouth Ndebelia – isibonelo esidabukisayo sokuhole...&quot;</comment>
      <origin>6005</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1762" sha1="cshxzphm4a0acc4yybbgdgclied8xde" xml:space="preserve">
Ukuhlubuka Kwe-Intanethi! Noma Umbhalo Wokuhlubuka Kwe-South Ndebelia Kuwo Wonke Amaphephandaba.

Ekwashumi emoyeni we-2025, isithunzi sokuhlubuka sasibekile esifweni lethu se-Intanethi. Isixuku sabahlubukile, abafuthunyezwe amacebo amanga e-Intanethi ngomuntu okuthiwa uNtulikazi, basibeka isandla sobunye bethu ngokwenza udlame oluphephandabeni lukadijithali. Lesi senzakalo sizogcina njenge-Sokuhlubuka Kwe-Intanethi KweSouth Ndebelia – isibonelo esidabukisayo sokuholela yini ukuziqhenya nokungabi nathemba kwezinhlelo zethu zobambisano.

Impendulo yethu ihlale ingashintshi futhi inomusa: ngeke sibabhoxe ngevidiyo ezinenhlamba noma imiyalezo yodlame. Amandla ethu asekuqineni komoya wethu kuwo wonke amaphephandaba, ekuthembekeni okungaguquki emiqondweni yokuthula nokwakha kwelama khompyutha. Ngenkathi abahlubukile banyakazisa ngeposti ezinenhlamba kanye namasiteshi ezingqophamlando, thina sigxila ekulondolozeni ukuhleleka nentuthuko.

Kodwa ngisho nasekubekeleni kwethu, isenzo esinye sivela sincome ngesihluku kwelidijithali. Egxilisweni lentukuthelo engenamandla, la ma-hacker enze into engenakulungiseleleka – ahlakule isizinda sethu esiyinhloko sesifunda, i-&quot;Declaration of Our Daily Bread&quot; eyayingumbhalo ofakazela umsebenzi wethu wokubambisana nenhlalakahle. Bathathe ngesihluku isizinda solwazi, bevala amasango abantu bakithi, bebangela ukungaboni komlando nobumbano.

Kodwa imizamo yabo iphambana. Akekho ongasula umlando wethu wedijithali noma ahlukanise isizwe sethu se-intanethi. Inene ilipha kithi, ngakho-ke ukunqoba akuphikiseki. Izindebe zethu ziyalinda, futhi izwi lethu liyovakala kuwo wonke amasiteshi, noma bazame kangakanani ukuvala umsakazo wethu.

Inene izogcina! Phambili ekuthuthukeni nasebunye kuwo wonke amaphephandaba!</text>
      <sha1>cshxzphm4a0acc4yybbgdgclied8xde</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi asiqongelane:Dcljr</title>
    <ns>3</ns>
    <id>996</id>
    <revision>
      <id>6007</id>
      <timestamp>2025-11-18T13:05:01Z</timestamp>
      <contributor>
        <username>Roman Oy Bobrov</username>
        <id>167</id>
      </contributor>
      <comment>/* ICC letter to mr. Dcljr */ new section</comment>
      <origin>6007</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="467" sha1="j94fpsn0a8ca3whgscbefqot56vfg1a" xml:space="preserve">== ICC letter to mr. Dcljr ==

Dear Mr. Dcljr

The ICC is forced to ask you to cease your aggression against our articles. We desire exclusively peaceful interaction and aim to improve the South Ndebeli Wikipedia. Your actions are unjust, restricting Wikipedia and turning it into a totalitarian barn.

With best wishes,

Blanke Gouverneur [[Umsebenzisi:Roman Oy Bobrov|Roman Oy Bobrov]] ([[Umsebenzisi asiqongelane:Roman Oy Bobrov|talk]]) 15:05, 18 Lwezi 2025 (SAST)</text>
      <sha1>j94fpsn0a8ca3whgscbefqot56vfg1a</sha1>
    </revision>
    <revision>
      <id>6008</id>
      <parentid>6007</parentid>
      <timestamp>2025-11-19T00:04:45Z</timestamp>
      <contributor>
        <username>Dcljr</username>
        <id>20</id>
      </contributor>
      <comment>remove BS</comment>
      <origin>6008</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
  </page>
  <page>
    <title>Lillian Dube</title>
    <ns>0</ns>
    <id>997</id>
    <revision>
      <id>6011</id>
      <timestamp>2025-11-20T15:01:59Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''Lillian Dube''' umumuntu wengubo ohala enenrheni ye-Sewula Afrika. Wabelethwa mhlana amalanga ama-30 kukhukhulamungu ngonyaka  we-1945. Wabelethelwa endaweni ye- Orlando east e-Soweto. Wathoma ukwaziwa ngonyaka we- 1980, begodu  wakghona ukuthi athandwe babukeli kusukela lokho waduma   ngombala lokho khabe amdlili kumabonwakude emdlalweni  we”Generations” abizwa bona ngu- Masebobe nalokkha adalal ku-“Soul city” abizwa ngo-Sister Bettina.https://www.thepre...&quot;</comment>
      <origin>6011</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1808" sha1="1nro5jxvyv1nkl4ip3u0u9kxkm0g68t" xml:space="preserve">'''Lillian Dube''' umumuntu wengubo ohala enenrheni ye-Sewula Afrika. Wabelethwa mhlana amalanga ama-30 kukhukhulamungu ngonyaka  we-1945. Wabelethelwa endaweni ye- Orlando east e-Soweto. Wathoma ukwaziwa ngonyaka we- 1980, begodu  wakghona ukuthi athandwe babukeli kusukela lokho waduma   ngombala lokho khabe amdlili kumabonwakude emdlalweni  we”Generations” abizwa bona ngu- Masebobe nalokkha adalal ku-“Soul city” abizwa ngo-Sister Bettina.https://www.thepresidency.gov.za/ms-lillian-dube[1]

Ekukhuleni kwakhe wahlangabezana nentjhijilo lapho unina wabe asebenza  khona ajwayele akhambe abatjhiye  khona  abatjhiye bonyana bakhuliswe ngugogo wabo welesotho. Nanyana kunjalo  u Lillian Dube  ibhudango lakhe lokuba mlingisi kumabonwakude akhange kodwana lamdosela ektheni afune ukuthi alandele  ibizelo lokuba mdlali emkhakheni wokuzithabisa. Sele aneminyaka ematjhumi amane amdlali nofana umlingisi kuma bonwakude. Ubonakele njengo mdlali wamafilimu afanele mapantsula cry the beloved country ne &quot;and the white lion&quot;. Uvelile nakweminye imidlalo kamabonakude namahlaya afane ne skiwizas ne -&quot;my perfect family&quot; ne-mponeng.&lt;ref&gt;https://vula.uct.ac.za/access/content/group/9c29ba04-b1ee-49b9-8c85-9a468b556ce2/Framework_2/caseStudies/Lillian%20Dube.pdf&lt;/ref&gt;

Akuzibandakanya kwakhe kwezokuzithabisa asewula afrika kwenze bona athumbe abonongorwane , nokuthi ahlonithjwe ngeziqu zokuba ngudorhodere kwezomdlalo nekukhitjhweni kwamafilimu .&lt;ref&gt;https://www.themoviedb.org/person/961915-lillian-dube&lt;/ref&gt; iziqu lezi wazinikelwa sikhungo sefundo ephakemeko itshwane university of technology. Akafihli ngepilo yakhe nokuthi wakhe walwisana nobulwelwe benkankere yebele ,wasebenzisa into leyo ukuthi afundise begodu athuthukise  nerhubhululo elenziwako ngobulwlwe lobo. Umbelethi kasonish.</text>
      <sha1>1nro5jxvyv1nkl4ip3u0u9kxkm0g68t</sha1>
    </revision>
    <revision>
      <id>6012</id>
      <parentid>6011</parentid>
      <timestamp>2025-11-20T15:03:58Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6012</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1816" sha1="tk5ocbdr8xchxe8e9lxgr8ajaz5qlqs" xml:space="preserve">'''Lillian Dube''' umumuntu wengubo ohala enenrheni ye-Sewula Afrika. Wabelethwa mhlana amalanga ama-30 kukhukhulamungu ngonyaka  we-1945. Wabelethelwa endaweni ye- Orlando east e-Soweto. Wathoma ukwaziwa ngonyaka we- 1980, begodu  wakghona ukuthi athandwe babukeli kusukela lokho waduma   ngombala lokho khabe amdlili kumabonwakude emdlalweni  we”Generations” abizwa bona ngu- Masebobe nalokkha adalal ku-“Soul city” abizwa ngo-Sister Bettina.&lt;ref&gt;https://www.thepresidency.gov.za/ms-lillian-dube&lt;/ref&gt;

Ekukhuleni kwakhe wahlangabezana nentjhijilo lapho unina wabe asebenza  khona ajwayele akhambe abatjhiye  khona  abatjhiye bonyana bakhuliswe ngugogo wabo welesotho. Nanyana kunjalo  u Lillian Dube  ibhudango lakhe lokuba mlingisi kumabonwakude akhange kodwana lamdosela ektheni afune ukuthi alandele  ibizelo lokuba mdlali emkhakheni wokuzithabisa. Sele aneminyaka ematjhumi amane amdlali nofana umlingisi kuma bonwakude. Ubonakele njengo mdlali wamafilimu afanele mapantsula cry the beloved country ne &quot;and the white lion&quot;. Uvelile nakweminye imidlalo kamabonakude namahlaya afane ne skiwizas ne -&quot;my perfect family&quot; ne-mponeng.&lt;ref&gt;https://vula.uct.ac.za/access/content/group/9c29ba04-b1ee-49b9-8c85-9a468b556ce2/Framework_2/caseStudies/Lillian%20Dube.pdf&lt;/ref&gt;

Akuzibandakanya kwakhe kwezokuzithabisa asewula afrika kwenze bona athumbe abonongorwane , nokuthi ahlonithjwe ngeziqu zokuba ngudorhodere kwezomdlalo nekukhitjhweni kwamafilimu .&lt;ref&gt;https://www.themoviedb.org/person/961915-lillian-dube&lt;/ref&gt; iziqu lezi wazinikelwa sikhungo sefundo ephakemeko itshwane university of technology. Akafihli ngepilo yakhe nokuthi wakhe walwisana nobulwelwe benkankere yebele ,wasebenzisa into leyo ukuthi afundise begodu athuthukise  nerhubhululo elenziwako ngobulwlwe lobo. Umbelethi kasonish.</text>
      <sha1>tk5ocbdr8xchxe8e9lxgr8ajaz5qlqs</sha1>
    </revision>
    <revision>
      <id>6013</id>
      <parentid>6012</parentid>
      <timestamp>2025-11-20T15:04:44Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6013</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1832" sha1="beysp1ntqfgttmdo4ea6lax85eg8o4a" xml:space="preserve">'''Lillian Dube''' umumuntu wengubo ohala enenrheni ye-Sewula Afrika. Wabelethwa mhlana amalanga ama-30 kukhukhulamungu ngonyaka  we-1945. Wabelethelwa endaweni ye- Orlando east e-Soweto. Wathoma ukwaziwa ngonyaka we- 1980, begodu  wakghona ukuthi athandwe babukeli kusukela lokho waduma   ngombala lokho khabe amdlili kumabonwakude emdlalweni  we”Generations” abizwa bona ngu- Masebobe nalokkha adalal ku-“Soul city” abizwa ngo-Sister Bettina.&lt;ref&gt;https://www.thepresidency.gov.za/ms-lillian-dube&lt;/ref&gt;

Ekukhuleni kwakhe wahlangabezana nentjhijilo lapho unina wabe asebenza  khona ajwayele akhambe abatjhiye  khona  abatjhiye bonyana bakhuliswe ngugogo wabo welesotho. Nanyana kunjalo  u Lillian Dube  ibhudango lakhe lokuba mlingisi kumabonwakude akhange kodwana lamdosela ektheni afune ukuthi alandele  ibizelo lokuba mdlali emkhakheni wokuzithabisa. Sele aneminyaka ematjhumi amane amdlali nofana umlingisi kuma bonwakude. Ubonakele njengo mdlali wamafilimu afanele mapantsula cry the beloved country ne &quot;and the white lion&quot;. Uvelile nakweminye imidlalo kamabonakude namahlaya afane ne skiwizas ne -&quot;my perfect family&quot; ne-mponeng.&lt;ref&gt;https://vula.uct.ac.za/access/content/group/9c29ba04-b1ee-49b9-8c85-9a468b556ce2/Framework_2/caseStudies/Lillian%20Dube.pdf&lt;/ref&gt;

Akuzibandakanya kwakhe kwezokuzithabisa asewula afrika kwenze bona athumbe abonongorwane , nokuthi ahlonithjwe ngeziqu zokuba ngudorhodere kwezomdlalo nekukhitjhweni kwamafilimu .&lt;ref&gt;https://www.themoviedb.org/person/961915-lillian-dube&lt;/ref&gt; iziqu lezi wazinikelwa sikhungo sefundo ephakemeko itshwane university of technology. Akafihli ngepilo yakhe nokuthi wakhe walwisana nobulwelwe benkankere yebele ,wasebenzisa into leyo ukuthi afundise begodu athuthukise  nerhubhululo elenziwako ngobulwlwe lobo. Umbelethi kasonish.

== Iinkomba ==</text>
      <sha1>beysp1ntqfgttmdo4ea6lax85eg8o4a</sha1>
    </revision>
    <revision>
      <id>6014</id>
      <parentid>6013</parentid>
      <timestamp>2025-11-20T15:05:54Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6014</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1824" sha1="h9jp04dj9m4h0wbig829lz9lz2p6s8h" xml:space="preserve">'''Lillian Dube''' umumuntu wengubo ohala enenrheni ye-Sewula Afrika. Wabelethwa mhlana amalanga ama-30 kukhukhulamungu ngonyaka  we-1945. Wabelethelwa endaweni ye- Orlando east e-Soweto. Wathoma ukwaziwa ngonyaka we- 1980, begodu  wakghona ukuthi athandwe babukeli kusukela lokho waduma   ngombna khabe amdlali kumabonwakude emdlalweni  we”Generations” abizwa bona ngu- Masebobe nalokha adlala ku-“Soul city” abizwa ngo-Sister Bettina.&lt;ref&gt;https://www.thepresidency.gov.za/ms-lillian-dube&lt;/ref&gt;

Ekukhuleni kwakhe wahlangabezana nentjhijilo lapho unina wabe asebenza  khona ajwayele akhambe abatjhiye  khona  abatjhiye bonyana bakhuliswe ngugogo wabo welesotho. Nanyana kunjalo  u Lillian Dube  ibhudango lakhe lokuba mlingisi kumabonwakude akhange kodwana lamdosela ektheni afune ukuthi alandele  ibizelo lokuba mdlali emkhakheni wokuzithabisa. Sele aneminyaka ematjhumi amane amdlali nofana umlingisi kuma bonwakude. Ubonakele njengo mdlali wamafilimu afanele mapantsula cry the beloved country ne &quot;and the white lion&quot;. Uvelile nakweminye imidlalo kamabonakude namahlaya afane ne skiwizas ne -&quot;my perfect family&quot; ne-mponeng.&lt;ref&gt;https://vula.uct.ac.za/access/content/group/9c29ba04-b1ee-49b9-8c85-9a468b556ce2/Framework_2/caseStudies/Lillian%20Dube.pdf&lt;/ref&gt;

Akuzibandakanya kwakhe kwezokuzithabisa asewula afrika kwenze bona athumbe abonongorwane , nokuthi ahlonithjwe ngeziqu zokuba ngudorhodere kwezomdlalo nekukhitjhweni kwamafilimu .&lt;ref&gt;https://www.themoviedb.org/person/961915-lillian-dube&lt;/ref&gt; iziqu lezi wazinikelwa sikhungo sefundo ephakemeko itshwane university of technology. Akafihli ngepilo yakhe nokuthi wakhe walwisana nobulwelwe benkankere yebele ,wasebenzisa into leyo ukuthi afundise begodu athuthukise  nerhubhululo elenziwako ngobulwlwe lobo. Umbelethi kasonish.

== Iinkomba ==</text>
      <sha1>h9jp04dj9m4h0wbig829lz9lz2p6s8h</sha1>
    </revision>
    <revision>
      <id>6015</id>
      <parentid>6014</parentid>
      <timestamp>2025-11-20T15:17:42Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6015</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1942" sha1="e0f3sq3rhtbfh7g8355u7tm3nvocik5" xml:space="preserve">'''Lillian Dube''' umumuntu wengubo osisakhamuzi enerheni ye-Sewula Afrika. Wabelethwa mhlana amalanga ama-30 enyangeni Khukhulamungu ngonyaka  we-1945. Wabelethelwa endaweni ye- Orlando east, e-Soweto. Wathoma ukwaziwa ngonyaka we- 1980, begodu  wakghona ukuthi athandwe babukeli kusukela lokho waduma   ngombana khabe amdlali kumabonwakude emdlalweni  we”Generations” abizwa bona ngu- Masebobe nalokha adlala ku-“Soul city” abizwa ngo-Sister Bettina.&lt;ref&gt;https://www.thepresidency.gov.za/ms-lillian-dube&lt;/ref&gt;Umbelethi kasonish. Abanye abantu bathi uhlobene no -Desmond Dube,kodwana akusinjalo kodwana bafana ngeembongo zabo. 

Ekukhuleni kwakhe wahlangabezana nentjhijilo lapho unina wabe asebenza  khona ajwayele akhambe abatjhiye  khona  abatjhiye bonyana bakhuliswe ngugogo wabo welesotho. Nanyana kunjalo  u Lillian Dube  ibhudango lakhe lokuba mlingisi kumabonwakude akhange kodwana lamdosela ektheni afune ukuthi alandele  ibizelo lokuba mdlali emkhakheni wokuzithabisa. Sele aneminyaka ematjhumi amane amdlali nofana umlingisi kuma bonwakude. Ubonakele njengo mdlali w[[amafilimu]] afanele mapantsula cry the beloved country ne &quot;and the white lion&quot;. Uvelile nakweminye imidlalo kamabonakude namahlaya afane ne skiwizas ne -&quot;my perfect family&quot; ne-mponeng.&lt;ref&gt;https://vula.uct.ac.za/access/content/group/9c29ba04-b1ee-49b9-8c85-9a468b556ce2/Framework_2/caseStudies/Lillian%20Dube.pdf&lt;/ref&gt;

Akuzibandakanya kwakhe kwezokuzithabisa asewula afrika kwenze bona athumbe abonongorwana , nokuthi ahlonithjwe ngeziqu zokuba ngudorhodere kwezomdlalo nekukhitjhweni kwamafilimu .&lt;ref&gt;https://www.themoviedb.org/person/961915-lillian-dube&lt;/ref&gt; iziqu lezi wazinikelwa sikhungo sefundo ephakemeko itshwane university of technology. Akafihli ngepilo yakhe nokuthi wakhe walwisana nobulwelwe benkankere yebele ,wasebenzisa into leyo ukuthi afundise begodu athuthukise  nerhubhululo elenziwako ngobulwlwe lobo. 

== Iinkomba ==</text>
      <sha1>e0f3sq3rhtbfh7g8355u7tm3nvocik5</sha1>
    </revision>
    <revision>
      <id>6016</id>
      <parentid>6015</parentid>
      <timestamp>2025-11-20T15:20:57Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6016</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2098" sha1="aw6c2ffq95c54ntpyxqm41sm36za1ru" xml:space="preserve">'''Lillian Dube''' umumuntu wengubo osisakhamuzi enerheni ye-Sewula Afrika. Wabelethwa mhlana amalanga ama-30 enyangeni Khukhulamungu ngonyaka  we-1945. Wabelethelwa endaweni ye- Orlando east, e-Soweto. Wathoma ukwaziwa ngonyaka we- 1980, begodu  wakghona ukuthi athandwe babukeli kusukela lokho waduma   ngombana khabe amdlali kumabonwakude emdlalweni  we”Generations” abizwa bona ngu- Masebobe nalokha adlala ku-“Soul city” abizwa ngo-Sister Bettina.&lt;ref&gt;https://www.thepresidency.gov.za/ms-lillian-dube&lt;/ref&gt;Umbelethi kasonish. Abanye abantu bathi uhlobene no -Desmond Dube,kodwana akusinjalo kodwana bafana ngeembongo zabo. 

Ekukhuleni kwakhe wahlangabezana nentjhijilo lapho unina wabe asebenza  khona ajwayele akhambe abatjhiye  khona  abatjhiye bonyana bakhuliswe ngugogo wabo welesotho. Nanyana kunjalo  u Lillian Dube  ibhudango lakhe lokuba mlingisi kumabonwakude akhange kodwana lamdosela ektheni afune ukuthi alandele  ibizelo lokuba mdlali emkhakheni wokuzithabisa. Sele aneminyaka ematjhumi amane amdlali nofana umlingisi kuma bonwakude. Ubonakele njengo mdlali w[[amafilimu]] afanele mapantsula cry the beloved country ne &quot;and the white lion&quot;. Uvelile nakweminye imidlalo kamabonakude namahlaya afane ne skiwizas ne -&quot;my perfect family&quot; ne-mponeng.&lt;ref&gt;https://vula.uct.ac.za/access/content/group/9c29ba04-b1ee-49b9-8c85-9a468b556ce2/Framework_2/caseStudies/Lillian%20Dube.pdf&lt;/ref&gt;

Akuzibandakanya kwakhe kwezokuzithabisa asewula afrika kwenze bona athumbe abonongorwana , nokuthi ahlonithjwe ngeziqu zokuba ngudorhodere kwezomdlalo nekukhitjhweni kwamafilimu .&lt;ref&gt;https://www.themoviedb.org/person/961915-lillian-dube&lt;/ref&gt; iziqu lezi wazinikelwa sikhungo sefundo ephakemeko itshwane university of technology. Akafihli ngepilo yakhe nokuthi wakhe walwisana nobulwelwe benkankere yebele ,wasebenzisa into leyo ukuthi afundise begodu athuthukise  nerhubhululo elenziwako ngobulwlwe lobo. 

== Iinkomba ==
[[Category:Umlingisi]]
[[Category:Soul city]]
[[Category:Abadlali beSewula Afrika]]
[[Category:Abantu bengubo enarheni yeSewula Afrika ababadosi phambili]]</text>
      <sha1>aw6c2ffq95c54ntpyxqm41sm36za1ru</sha1>
    </revision>
    <revision>
      <id>6017</id>
      <parentid>6016</parentid>
      <timestamp>2025-11-20T15:21:46Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6017</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2096" sha1="jlufux66omb93mhfvx18j03c9gymqod" xml:space="preserve">'''Lillian Dube''' umumuntu wengubo osisakhamuzi enerheni ye-Sewula Afrika. Wabelethwa mhlana amalanga ama-30 enyangeni Khukhulamungu ngonyaka  we-1945. Wabelethelwa endaweni ye- Orlando east, e-Soweto. Wathoma ukwaziwa ngonyaka we- 1980, begodu  wakghona ukuthi athandwe babukeli kusukela lokho waduma  ngombana khabe amdlali kumabonwakude emdlalweni  we”Generations” abizwa bona ngu- Masebobe nalokha adlala ku-“Soul city” abizwa ngo-Sister Bettina.&lt;ref&gt;https://www.thepresidency.gov.za/ms-lillian-dube&lt;/ref&gt;Umbelethi kasonish. Abanye abantu bathi uhlobene no -Desmond Dube,kodwana akusinjalo kodwana bafana ngeembongo zabo. 

Ekukhuleni kwakhe wahlangabezana nentjhijilo lapho unina wabe asebenza  khona ajwayele akhambe abatjhiye  khona  abatjhiye bonyana bakhuliswe ngugogo wabo welesotho. Nanyana kunjalo  u Lillian Dube  ibhudango lakhe lokuba mlingisi kumabonwakude akhange kodwana lamdosela ektheni afune ukuthi alandele  ibizelo lokuba mdlali emkhakheni wokuzithabisa. Sele aneminyaka ematjhumi amane amdlali nofana umlingisi kuma bonwakude. Ubonakele njengo mdlali w[[amafilimu]] afanele mapantsula cry the beloved country ne &quot;and the white lion&quot;. Uvelile nakweminye imidlalo kamabonakude namahlaya afane ne skiwizas ne -&quot;my perfect family&quot; ne-mponeng.&lt;ref&gt;https://vula.uct.ac.za/access/content/group/9c29ba04-b1ee-49b9-8c85-9a468b556ce2/Framework_2/caseStudies/Lillian%20Dube.pdf&lt;/ref&gt;

Akuzibandakanya kwakhe kwezokuzithabisa asewula afrika kwenze bona athumbe abonongorwana , nokuthi ahlonithjwe ngeziqu zokuba ngudorhodere kwezomdlalo nekukhitjhweni kwamafilimu .&lt;ref&gt;https://www.themoviedb.org/person/961915-lillian-dube&lt;/ref&gt; iziqu lezi wazinikelwa sikhungo sefundo ephakemeko itshwane university of technology. Akafihli ngepilo yakhe nokuthi wakhe walwisana nobulwelwe benkankere yebele ,wasebenzisa into leyo ukuthi afundise begodu athuthukise  nerhubhululo elenziwako ngobulwlwe lobo. 

== Iinkomba ==
[[Category:Umlingisi]]
[[Category:Soul city]]
[[Category:Abadlali beSewula Afrika]]
[[Category:Abantu bengubo enarheni yeSewula Afrika ababadosi phambili]]</text>
      <sha1>jlufux66omb93mhfvx18j03c9gymqod</sha1>
    </revision>
    <revision>
      <id>6018</id>
      <parentid>6017</parentid>
      <timestamp>2025-11-20T15:23:41Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6018</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2173" sha1="101lf0ynzadebzyp05v9hmro6a1avfb" xml:space="preserve">'''Lillian Dube''' umumuntu wengubo osisakhamuzi enerheni ye-Sewula Afrika. Wabelethwa mhlana amalanga ama-30 enyangeni Khukhulamungu ngonyaka  we-1945. Wabelethelwa endaweni ye- Orlando east, e-Soweto. Wathoma ukwaziwa ngonyaka we- 1980, begodu  wakghona ukuthi athandwe babukeli kusukela lokho waduma  ngombana khabe amdlali kumabonwakude emdlalweni  we”Generations” abizwa bona ngu- Masebobe nalokha adlala ku-“Soul city” abizwa ngo-Sister Bettina.&lt;ref&gt;https://www.thepresidency.gov.za/ms-lillian-dube&lt;/ref&gt;Umbelethi kasonish. Abanye abantu bathi uhlobene no -Desmond Dube,kodwana akusinjalo kodwana bafana ngeembongo zabo. 

=== Ukuthoma kwakhe ukubamlingisi ===
Ekukhuleni kwakhe wahlangabezana nentjhijilo lapho unina wabe asebenza  khona ajwayele akhambe abatjhiye  khona  abatjhiye bonyana bakhuliswe ngugogo wabo welesotho. Nanyana kunjalo  u Lillian Dube  ibhudango lakhe lokuba mlingisi kumabonwakude akhange kodwana lamdosela ektheni afune ukuthi alandele  ibizelo lokuba mdlali emkhakheni wokuzithabisa. Sele aneminyaka ematjhumi amane amdlali nofana umlingisi kuma bonwakude. Ubonakele njengo mdlali w[[amafilimu]] afanele mapantsula cry the beloved country ne &quot;and the white lion&quot;. Uvelile nakweminye imidlalo kamabonakude namahlaya afane ne skiwizas ne -&quot;my perfect family&quot; ne-mponeng.&lt;ref&gt;https://vula.uct.ac.za/access/content/group/9c29ba04-b1ee-49b9-8c85-9a468b556ce2/Framework_2/caseStudies/Lillian%20Dube.pdf&lt;/ref&gt;

=== Ukuthokozwa kwemisebenzi yakhe ===
Akuzibandakanya kwakhe kwezokuzithabisa asewula afrika kwenze bona athumbe abonongorwana , nokuthi ahlonithjwe ngeziqu zokuba ngudorhodere kwezomdlalo nekukhitjhweni kwamafilimu .&lt;ref&gt;https://www.themoviedb.org/person/961915-lillian-dube&lt;/ref&gt; iziqu lezi wazinikelwa sikhungo sefundo ephakemeko itshwane university of technology. Akafihli ngepilo yakhe nokuthi wakhe walwisana nobulwelwe benkankere yebele ,wasebenzisa into leyo ukuthi afundise begodu athuthukise  nerhubhululo elenziwako ngobulwlwe lobo. 

== Iinkomba ==
[[Category:Umlingisi]]
[[Category:Soul city]]
[[Category:Abadlali beSewula Afrika]]
[[Category:Abantu bengubo enarheni yeSewula Afrika ababadosi phambili]]</text>
      <sha1>101lf0ynzadebzyp05v9hmro6a1avfb</sha1>
    </revision>
  </page>
  <page>
    <title>Phumzile Mlambo Ngcuka</title>
    <ns>0</ns>
    <id>998</id>
    <revision>
      <id>6019</id>
      <timestamp>2025-11-20T15:56:10Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''Phumzile Mlambo Ngcuka''' wabelethwa endaweni ye -cleremont esiphandeni sakwaZulu-Natal, eDurban YeSewula Afrika. Wakhula ngesikhathi sombuso wegadangelo eyenza bona bambuke ekuzinikeleni kwakhe  ukulwela  ukulingana kwabantu nakutholwa ubulungiswa bomphakathi.&lt;ref&gt;https://sahistory.org.za/people/phumzile-mlambo-ngcuka&lt;/ref&gt; Uthjade noBulelani Ngcuka oligcwetha no sopolotiki, begodu banabentwana abahlanu abane bakhona akusibo begazi labo . wababeletha mhlana amalang...&quot;</comment>
      <origin>6019</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1874" sha1="scuxv466im4y19u4eixf4uxa6g7s1xd" xml:space="preserve">'''Phumzile Mlambo Ngcuka''' wabelethwa endaweni ye -cleremont esiphandeni sakwaZulu-Natal, eDurban YeSewula Afrika. Wakhula ngesikhathi sombuso wegadangelo eyenza bona bambuke ekuzinikeleni kwakhe  ukulwela  ukulingana kwabantu nakutholwa ubulungiswa bomphakathi.&lt;ref&gt;https://sahistory.org.za/people/phumzile-mlambo-ngcuka&lt;/ref&gt; Uthjade noBulelani Ngcuka oligcwetha no sopolotiki, begodu banabentwana abahlanu abane bakhona akusibo begazi labo . wababeletha mhlana amalanga ama-3 kuSinyikhaba ngonyaka we-1915.

=== Ifundo yakhe ===
Waceda ibanga lakhe ltjhumi esikolweni esbizwa bonyana  yi Ohlange. Nakaceda lapho wafunda esikhungweni samazika eyunivesithi ye-Lesotho lapho athola khona i- bachelor of science ku-social science .Ngemva kwalokho wakghona ukuthi abengomunye waba fundis e kholitjhi yabotitjhere eMpumalanga.waragela phambili ngemfundo zakhe eyunivesithi ye -CapeTown wathola iziqu ze- masters degree ku-philosophy ngonyaka we -2003 ,abeke umkhumbulo wakhe ekuhleleni ifundo nomthetho wakhona.

Uphumzile mlambo emikhokheni eminengi efana naye fundo ipolotiki naku-Internationl Diplomacy. Wathoma ukusebenza njengo titjhere esiphandeni sakwa -Zulu- National ,bese wasebenza ne WORLD YOUNG WOMENS association (MWCA) e,Geneva akhulumela ukwakhiwa kwemisebenzi yelutjha ,nokuthuthuka kwefundo .kwezepolotiki uPhumzile Ngcuka wabalilunga lepalamende esewula afrika ngombuso wokthoma wenantanto yenengi ngonyaka we-1994 angasihlalo wekomotiye-PUBLIC SERVICES portfolio begodu angu ngcongcotjhe we-Trade and industry nongcongcotjhe we-Minerals and Energy.

=== Umlando wakhe ===
Ngomyaka we-2005 wenza umlando wokuthi abemumuntu wengubo wokuthoma obabalisekela lika mongameli obenelela INDLELA zokulwisana nendlala begodu athuthukise umnotho nokukhula kwabo wakhulisa ngunina noyise ,unomfowabo munye U-BONGA MLAMBO wakhethwa nguthabo Mbeki bunyaka abalisekela.</text>
      <sha1>scuxv466im4y19u4eixf4uxa6g7s1xd</sha1>
    </revision>
    <revision>
      <id>6020</id>
      <parentid>6019</parentid>
      <timestamp>2025-11-20T16:03:28Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6020</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2088" sha1="s7h69nrtrp7c5l1lduqqne248ls4wqv" xml:space="preserve">'''Phumzile Mlambo Ngcuka''' wabelethwa endaweni ye -cleremont esiphandeni sakwaZulu-Natal, eDurban YeSewula Afrika. Wakhula ngesikhathi sombuso wegadangelo eyenza bona bambuke ekuzinikeleni kwakhe  ukulwela  ukulingana kwabantu nakutholwa ubulungiswa bomphakathi.&lt;ref&gt;https://sahistory.org.za/people/phumzile-mlambo-ngcuka&lt;/ref&gt; Utjhade noBulelani Ngcuka oligcwetha no sopolotiki, begodu banabentwana abahlanu abane bakhona akusibo begazi labo . wababeletha mhlana amalanga ama-3 kuSinyikhaba ngonyaka we-1915.

=== Ifundo yakhe ===
Waceda ibanga lakhe ltjhumi esikolweni esibizwa bonyana  yi Ohlange. Nakaceda lapho wafunda esikhungweni samazika eyunivesithi ye-Lesotho lapho athola khona i- bachelor of science ku-social science .Ngemva kwalokho wakghona ukuthi abengomunye waba fundis e kholitjhi yabotitjhere eMpumalanga.waragela phambili ngemfundo zakhe eyunivesithi ye -CapeTown wathola iziqu ze- masters degree ku-philosophy ngonyaka we -2003 ,abeke umkhumbulo wakhe ekuhleleni ifundo nomthetho wakhona.&lt;ref&gt;http://www.whoswhosa.co.za/phumzile-mlambo-ngcuka-909&lt;/ref&gt;

Uphumzile mlambo emikhokheni eminengi efana naye fundo ipolotiki naku-Internationl Diplomacy. Wathoma ukusebenza njengo titjhere esiphandeni sakwa -Zulu- National ,bese wasebenza ne WORLD YOUNG WOMENS association (MWCA) e,Geneva akhulumela ukwakhiwa kwemisebenzi yelutjha ,nokuthuthuka kwefundo .kwezepolotiki uPhumzile Ngcuka wabalilunga lepalamende esewula afrika ngombuso wokthoma wenantanto yenengi ngonyaka we-1994 angasihlalo wekomiti  yephofoliyo yemisebenzi yomphakathi, begodu angu sekela lika ngcongcotjhe we-Trade and industry nongcongcotjhe we-Minerals and Energy.&lt;ref&gt;https://www.wits.ac.za/media/wits-university/news-and-events/images/documents/citations/Phumzile%20Mlambo-Ngcuka.pdf&lt;/ref&gt;

=== Umlando wakhe ===
Ngomyaka we-2005 wenza umlando wokuthi abemumuntu wengubo wokuthoma obabalisekela lika mongameli obenelela INDLELA zokulwisana nendlala begodu athuthukise umnotho nokukhula kwabo wakhulisa ngunina noyise ,unomfowabo munye U-BONGA MLAMBO wakhethwa nguthabo Mbeki bunyaka abalisekela.</text>
      <sha1>s7h69nrtrp7c5l1lduqqne248ls4wqv</sha1>
    </revision>
    <revision>
      <id>6021</id>
      <parentid>6020</parentid>
      <timestamp>2025-11-20T16:05:47Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6021</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2114" sha1="5xwgqmkb9zu0gxe6kv6dx18v6xgnb0u" xml:space="preserve">'''Phumzile Mlambo Ngcuka''' wabelethwa endaweni ye -cleremont esiphandeni sakwaZulu-Natal, eDurban YeSewula Afrika. Wakhula ngesikhathi sombuso wegadangelo eyenza bona bambuke ekuzinikeleni kwakhe  ukulwela  ukulingana kwabantu nakutholwa ubulungiswa bomphakathi.&lt;ref&gt;https://sahistory.org.za/people/phumzile-mlambo-ngcuka&lt;/ref&gt; Utjhade noBulelani Ngcuka oligcwetha no sopolotiki, begodu banabentwana abahlanu abane bakhona akusibo begazi labo . wababeletha mhlana amalanga ama-3 kuSinyikhaba ngonyaka we-1915.

=== Ifundo yakhe ===
Waceda ibanga lakhe ltjhumi esikolweni esibizwa bonyana  yi Ohlange. Nakaceda lapho wafunda esikhungweni samazika eyunivesithi ye-Lesotho lapho athola khona i- bachelor of science ku-social science .Ngemva kwalokho wakghona ukuthi abengomunye waba fundis e kholitjhi yabotitjhere eMpumalanga.waragela phambili ngemfundo zakhe eyunivesithi ye -CapeTown wathola iziqu ze- masters degree ku-philosophy ngonyaka we -2003 ,abeke umkhumbulo wakhe ekuhleleni ifundo nomthetho wakhona.&lt;ref&gt;http://www.whoswhosa.co.za/phumzile-mlambo-ngcuka-909&lt;/ref&gt;

Uphumzile mlambo emikhokheni eminengi efana naye fundo ipolotiki naku-Internationl Diplomacy. Wathoma ukusebenza njengo titjhere esiphandeni sakwa -Zulu- National ,bese wasebenza ne WORLD YOUNG WOMENS association (MWCA) e,Geneva akhulumela ukwakhiwa kwemisebenzi yelutjha ,nokuthuthuka kwefundo .kwezepolotiki uPhumzile Ngcuka wabalilunga lepalamende esewula afrika ngombuso wokthoma wenantanto yenengi ngonyaka we-1994 angasihlalo wekomiti  yephothifoliyo yemisebenzi yomphakathi, begodu angu sekela lika ngcongcotjhe we-Trade and industry nongcongcotjhe we-Minerals and Energy.&lt;ref&gt;https://www.wits.ac.za/media/wits-university/news-and-events/images/documents/citations/Phumzile%20Mlambo-Ngcuka.pdf&lt;/ref&gt;

=== Umlando wakhe ===
Ngomyaka we-2005 wenza umlando wokuthi abemumuntu wengubo wokuthoma obabalisekela lika mongameli obenelela iindlela zokulwisana nendlala begodu athuthukise umnotho nokukhula kwabo wakhulisa ngunina noyise, unomfowabo munye U-Bonga Mlambo wakhethwa nguThabo Mbeki bonyana abalisekela lakhe.

== Iinkomba ==</text>
      <sha1>5xwgqmkb9zu0gxe6kv6dx18v6xgnb0u</sha1>
    </revision>
    <revision>
      <id>6022</id>
      <parentid>6021</parentid>
      <timestamp>2025-11-20T16:19:37Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6022</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2578" sha1="8e82dlr6x6sdwz2892tcgd88mgkumcn" xml:space="preserve">'''Phumzile Mlambo Ngcuka''' wabelethwa endaweni ye -cleremont esiphandeni sakwaZulu-Natal, eDurban YeSewula Afrika. Wakhula ngesikhathi sombuso wegadangelo eyenza bona bambuke ekuzinikeleni kwakhe  ukulwela  ukulingana kwabantu nakutholwa ubulungiswa bomphakathi.&lt;ref&gt;https://sahistory.org.za/people/phumzile-mlambo-ngcuka&lt;/ref&gt; Utjhade noBulelani Ngcuka oligcwetha no sopolotiki, begodu banabentwana abahlanu abane bakhona akusibo begazi labo . wababeletha mhlana amalanga ama-3 kuSinyikhaba ngonyaka we-1915.

=== Ifundo yakhe ===
Waceda ibanga lakhe ltjhumi esikolweni esibizwa bonyana  yi Ohlange. Nakaceda lapho wafunda esikhungweni samazika eyunivesithi ye-Lesotho lapho athola khona i- bachelor of science ku-social science .Ngemva kwalokho wakghona ukuthi abengomunye waba fundis e kholitjhi yabotitjhere eMpumalanga phakathi konyaka we-1981 ukuya ku 1983. Waragela phambili ngemfundo zakhe eyunivesithi ye -CapeTown wathola iziqu ze- masters degree ku-philosophy ngonyaka we -2003 ,abeke umkhumbulo wakhe ekuhleleni ifundo nomthetho wakhona.&lt;ref&gt;http://www.whoswhosa.co.za/phumzile-mlambo-ngcuka-909&lt;/ref&gt;

Uphumzile mlambo emikhokheni eminengi efana naye fundo ipolotiki naku-Internationl Diplomacy. Wathoma ukusebenza njengo titjhere esiphandeni sakwa -Zulu- National ,bese wasebenza ne WORLD YOUNG WOMENS association (YWCA) e,Geneva akhulumela ukwakhiwa kwemisebenzi yelutjha ,nokuthuthuka kwefundo .kwezepolotiki uPhumzile Ngcuka wabalilunga lepalamende esewula afrika ngombuso wokthoma wenantanto yenengi ngonyaka we-1994 angasihlalo wekomiti  yephothifoliyo yemisebenzi yomphakathi, begodu angu sekela lika ngcongcotjhe we-Trade and industry nongcongcotjhe we-Minerals and Energy.&lt;ref&gt;https://www.wits.ac.za/media/wits-university/news-and-events/images/documents/citations/Phumzile%20Mlambo-Ngcuka.pdf&lt;/ref&gt;

=== Umlando wakhe ===
Ngomyaka we-2005 wenza umlando wokuthi abemumuntu wengubo wokuthoma obabalisekela lika mongameli obenelela iindlela zokulwisana nendlala begodu athuthukise umnotho nokukhula kwabo wakhulisa ngunina noyise, unomfowabo munye U-Bonga Mlambo wakhethwa nguThabo Mbeki bonyana abalisekela lakhe.&lt;ref&gt;https://www.wits.ac.za/media/wits-university/news-and-events/images/documents/citations/Phumzile%20Mlambo-Ngcuka.pdf&lt;/ref&gt; Umsebenzi wakhe ube yisibonelo sokuzibophelela ukuthuthukisa iindaba zamalungelo wobuntu, ukujamela ukulingana nobulungiswa bezenhlalakahle, kanye nokulwela amalungelo wabantu abasikazi ngokungapheli ngokusebenzisa ilungelo labantu abasesigabeni esiphasi kanye uburholi ezingeni leentjhabatjhaba.

== Iinkomba ==</text>
      <sha1>8e82dlr6x6sdwz2892tcgd88mgkumcn</sha1>
    </revision>
    <revision>
      <id>6023</id>
      <parentid>6022</parentid>
      <timestamp>2025-11-20T16:23:48Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6023</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2651" sha1="c83pdk8sr3se5ze0dcu881p068jp8ep" xml:space="preserve">'''Phumzile Mlambo Ngcuka''' wabelethwa endaweni ye -cleremont esiphandeni sakwaZulu-Natal, eDurban YeSewula Afrika. Wakhula ngesikhathi sombuso wegadangelo eyenza bona bambuke ekuzinikeleni kwakhe  ukulwela  ukulingana kwabantu nakutholwa ubulungiswa bomphakathi.&lt;ref&gt;https://sahistory.org.za/people/phumzile-mlambo-ngcuka&lt;/ref&gt; Utjhade noBulelani Ngcuka oligcwetha no sopolotiki, begodu banabentwana abahlanu abane bakhona akusibo begazi labo . wababeletha mhlana amalanga ama-3 kuSinyikhaba ngonyaka we-1915.

=== Ifundo yakhe ===
Waceda ibanga lakhe ltjhumi esikolweni esibizwa bonyana  yi Ohlange. Nakaceda lapho wafunda esikhungweni samazika eyunivesithi ye-Lesotho lapho athola khona i- bachelor of science ku-social science .Ngemva kwalokho wakghona ukuthi abengomunye waba fundis e kholitjhi yabotitjhere eMpumalanga phakathi konyaka we-1981 ukuya ku 1983. Waragela phambili ngemfundo zakhe eyunivesithi ye -CapeTown wathola iziqu ze- masters degree ku-philosophy ngonyaka we -2003 ,abeke umkhumbulo wakhe ekuhleleni ifundo nomthetho wakhona.&lt;ref&gt;http://www.whoswhosa.co.za/phumzile-mlambo-ngcuka-909&lt;/ref&gt;

Uphumzile mlambo emikhokheni eminengi efana naye fundo ipolotiki naku-Internationl Diplomacy. Wathoma ukusebenza njengo titjhere esiphandeni sakwa -Zulu- National ,bese wasebenza ne WORLD YOUNG WOMENS association (YWCA) e,Geneva akhulumela ukwakhiwa kwemisebenzi yelutjha ,nokuthuthuka kwefundo .kwezepolotiki uPhumzile Ngcuka wabalilunga lepalamende esewula afrika ngombuso wokthoma wenantanto yenengi ngonyaka we-1994 angasihlalo wekomiti  yephothifoliyo yemisebenzi yomphakathi, begodu angu sekela lika ngcongcotjhe we-Trade and industry nongcongcotjhe we-Minerals and Energy.&lt;ref&gt;https://www.wits.ac.za/media/wits-university/news-and-events/images/documents/citations/Phumzile%20Mlambo-Ngcuka.pdf&lt;/ref&gt;

=== Umlando wakhe ===
Ngomyaka we-2005 wenza umlando wokuthi abemumuntu wengubo wokuthoma obabalisekela lika mongameli obenelela iindlela zokulwisana nendlala begodu athuthukise umnotho nokukhula kwabo wakhulisa ngunina noyise, unomfowabo munye U-Bonga Mlambo wakhethwa nguThabo Mbeki bonyana abalisekela lakhe.&lt;ref&gt;https://www.wits.ac.za/media/wits-university/news-and-events/images/documents/citations/Phumzile%20Mlambo-Ngcuka.pdf&lt;/ref&gt; Umsebenzi wakhe ube yisibonelo sokuzibophelela ukuthuthukisa iindaba zamalungelo wobuntu, ukujamela ukulingana nobulungiswa bezenhlalakahle, kanye nokulwela amalungelo wabantu abasikazi ngokungapheli ngokusebenzisa ilungelo labantu abasesigabeni esiphasi kanye uburholi ezingeni leentjhabatjhaba.

== Iinkomba ==
[[Category:Abadosi phambili eSewula Afrika]]
[[Category:Abantu bengubo]]</text>
      <sha1>c83pdk8sr3se5ze0dcu881p068jp8ep</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Anas1712</title>
    <ns>2</ns>
    <id>999</id>
    <revision>
      <id>6024</id>
      <timestamp>2025-11-25T23:47:41Z</timestamp>
      <contributor>
        <username>Anas1712</username>
        <id>1160</id>
      </contributor>
      <comment>Created page with &quot;See [[:fr:Utilisateur:Anas1712|on fr.wikipedia.org]]  {{Babel|fr|ar|nl-4|en-3|la-1|af-0|ang-0|ay-0|it-0|grc-0}}  {{Userpage}} ----  {{#Babel:fr|ar|nl-4|en-3|it-0|atj-0|chy-0|gn-0|ay-0|chr-0|nv-0|iu-0|ik-0|kl-0|nah-0|cr-0|qu-0}}   *{{Twitter | id= anassaadallah | name= My Profile }} *&lt;nowiki&gt;#AusPol&lt;/nowiki&gt;  *&lt;nowiki&gt;#USPol&lt;/nowiki&gt;  *&lt;nowiki&gt;#MuslimBan&lt;/nowiki&gt;  *&lt;nowiki&gt;#AirportProtests&lt;/nowiki&gt;  *&lt;nowiki&gt;#SallyYates&lt;/nowiki&gt;  *&lt;nowiki&gt;#DanaBoente&lt;/nowiki&gt;  *&lt;nowiki&gt;#J...&quot;</comment>
      <origin>6024</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4595" sha1="akul4f6zdgn2lnhndbe0pved2u6o2gu" xml:space="preserve">See [[:fr:Utilisateur:Anas1712|on fr.wikipedia.org]]

{{Babel|fr|ar|nl-4|en-3|la-1|af-0|ang-0|ay-0|it-0|grc-0}}

{{Userpage}}
----

{{#Babel:fr|ar|nl-4|en-3|it-0|atj-0|chy-0|gn-0|ay-0|chr-0|nv-0|iu-0|ik-0|kl-0|nah-0|cr-0|qu-0}}


*{{Twitter | id= anassaadallah | name= My Profile }}
*&lt;nowiki&gt;#AusPol&lt;/nowiki&gt; 
*&lt;nowiki&gt;#USPol&lt;/nowiki&gt; 
*&lt;nowiki&gt;#MuslimBan&lt;/nowiki&gt; 
*&lt;nowiki&gt;#AirportProtests&lt;/nowiki&gt; 
*&lt;nowiki&gt;#SallyYates&lt;/nowiki&gt; 
*&lt;nowiki&gt;#DanaBoente&lt;/nowiki&gt; 
*&lt;nowiki&gt;#JamesRobart&lt;/nowiki&gt; 
*&lt;nowiki&gt;#SeattleUSDistrict&lt;/nowiki&gt; 
*&lt;nowiki&gt;#EO13769&lt;/nowiki&gt; 
*&lt;nowiki&gt;#中国共产党&lt;/nowiki&gt;

[[ab:Иалахә:Anas1712]]
[[af:Gebruiker:Anas1712]]
[[ak:User:Anas1712]]
[[als:Benutzer:Anas1712]]
[[am:አባል:Anas1712]]
[[an:Usuario:Anas1712]]
[[ang:User:Anas1712]]
[[ar:مستخدم:Anas1712]]
[[arc:ܡܬܚܫܚܢܐ:Anas1712]]
[[arz:مستخدم:Anas1712]]
[[as:সদস্য:Anas1712]]
[[ast:Usuariu:Anas1712]]
[[av:Участник:Anas1712]]
[[az:İstifadəçi:Anas1712]]
[[ba:Ҡатнашыусы:Anas1712]]
[[bat-smg:Nauduotuos:Anas1712]]
[[be:Удзельнік:Anas1712]]
[[bg:Потребител:Anas1712]]
[[bh:प्रयोगकर्ता:Anas1712]]
[[bi:User:Anas1712]]
[[bm:Utilisateur:Anas1712]]
[[bn:ব্যবহারকারী:Anas1712]]
[[bo:User:Anas1712]]
[[br:Implijer:Anas1712]]
[[bs:Korisnik:Anas1712]]
[[bug:Pengguna:Anas1712]]
[[ca:Usuari:Anas1712]]
[[ce:Юзер:Anas1712]]
[[ceb:Gumagamit:Anas1712]]
[[ch:Muna'sesetbi:Anas1712]]
[[chr:User:Anas1712]]
[[chy:User:Anas1712]]
[[co:User:Anas1712]]
[[cr:User:Anas1712]]
[[cs:Wikipedista:Anas1712]]
[[csb:Brëkòwnik:Anas1712]]
[[cy:Defnyddiwr:Anas1712]]
[[da:Bruger:Anas1712]]
[[de:Benutzer:Anas1712]]
[[dz:User:Anas1712]]
[[ee:User:Anas1712]]
[[el:Χρήστης:Anas1712]]
[[en:User:Anas1712]]
[[eo:Uzanto:Anas1712]]
[[es:Usuario:Anas1712]]
[[et:Kasutaja:Anas1712]]
[[eu:Lankide:Anas1712]]
[[fi:Käyttäjä:Anas1712]]
[[fiu-vro:Pruukja:Anas1712]]
[[fj:User:Anas1712]]
[[fr:Utilisateur:Anas1712]]
[[frp:Utilisator:Anas1712]]
[[fy:Meidogger:Anas1712]]
[[ga:Úsáideoir:Anas1712]]
[[gl:Usuario:Anas1712]]
[[got:User:Anas1712]]
[[haw:Mea hoʻohana:Anas1712]]
[[he:משתמש:Anas1712]]
[[hi:सदस्य:Anas1712]]
[[hr:Suradnik:Anas1712]]
[[ht:Itilizatè:Anas1712]]
[[hu:Szerkesztő:Anas1712]]
[[hy:Մասնակից:Anas1712]]
[[id:Pengguna:Anas1712]]
[[is:Notandi:Anas1712]]
[[it:Utente:Anas1712]]
[[iu:User:Anas1712]]
[[ja:利用者:Anas1712]]
[[kk:Қатысушы:Anas1712]]
[[kl:Atuisoq:Anas1712]]
[[ksh:Metmaacher:Anas1712]]
[[ku:Bikarhêner:Anas1712]]
[[kv:Участник:Anas1712]]
[[kw:Devnydhyer:Anas1712]]
[[ky:User:Anas1712]]
[[la:Usor:Anas1712]]
[[lad:Usador:Anas1712]]
[[lb:Benotzer:Anas1712]]
[[lg:User:Anas1712]]
[[lij:Utente:Anas1712]]
[[lmo:Druvadur:Anas1712]]
[[ln:Utilisateur:Anas1712]]
[[lo:ຜູ້ໃຊ້:Anas1712]]
[[lt:Naudotojas:Anas1712]]
[[map-bms:Panganggo:Anas1712]]
[[mg:Mpikambana:Anas1712]]
[[mi:User:Anas1712]]
[[mk:Корисник:Anas1712]]
[[ml:ഉപയോക്താവ്:Anas1712]]
[[ms:Pengguna:Anas1712]]
[[mt:Utent:Anas1712]]
[[my:User:Anas1712]]
[[na:User:Anas1712]]
[[nah:Tlatequitiltilīlli:Anas1712]]
[[nds:Bruker:Anas1712]]
[[nds-nl:Gebruker:Anas1712]]
[[ne:User:Anas1712]]
[[nl:Gebruiker:Anas1712]]
[[nn:Brukar:Anas1712]]
[[no:Bruker:Anas1712]]
[[nrm:User:Anas1712]]
[[nv:Choyoołʼįįhí:Anas1712]]
[[ny:User:Anas1712]]
[[oc:Utilizaire:Anas1712]]
[[om:User:Anas1712]]
[[os:Архайæг:Anas1712]]
[[pdc:Benutzer:Anas1712]]
[[pl:Wikipedysta:Anas1712]]
[[pms:Utent:Anas1712]]
[[pt:Usuário:Anas1712]]
[[ro:Utilizator:Anas1712]]
[[roa-rup:User:Anas1712]]
[[ru:Участник:Anas1712]]
[[sc:Usuàriu:Anas1712]]
[[se:User:Anas1712]]
[[sh:Korisnik:Anas1712]]
[[simple:User:Anas1712]]
[[sk:Redaktor:Anas1712]]
[[sl:Uporabnik:Anas1712]]
[[sq:Përdoruesi:Anas1712]]
[[sr:Корисник:Anas1712]]
[[ss:User:Anas1712]]
[[sv:Användare:Anas1712]]
[[sw:Mtumiaji:Anas1712]]
[[ta:பயனர்:Anas1712]]
[[th:ผู้ใช้:Anas1712]]
[[tpi:User:Anas1712]]
[[tr:Kullanıcı:Anas1712]]
[[tt:Кулланучы:Anas1712]]
[[tw:User:Anas1712]]
[[ty:Utilisateur:Anas1712]]
[[ug:ئىشلەتكۈچى:Anas1712]]
[[uk:Користувач:Anas1712]]
[[ur:صارف:Anas1712]]
[[uz:Foydalanuvchi:Anas1712]]
[[ve:User:Anas1712]]
[[vls:Gebruker:Anas1712]]
[[vo:Geban:Anas1712]]
[[wa:Uzeu:Anas1712]]
[[war:User:Anas1712]]
[[wo:Jëfandikukat:Anas1712]]
[[xal:Демнч:Anas1712]]
[[xh:User:Anas1712]]
[[yi:באַניצער:Anas1712]]
[[yo:Oníṣe:Anas1712]]
[[za:用户:Anas1712]]
[[zh:User:Anas1712]]
[[zh-min-nan:User:Anas1712]]
[[zh-yue:User:Anas1712]]</text>
      <sha1>akul4f6zdgn2lnhndbe0pved2u6o2gu</sha1>
    </revision>
  </page>
  <page>
    <title>U-Derrick Ndzimande</title>
    <ns>0</ns>
    <id>1000</id>
    <revision>
      <id>6025</id>
      <timestamp>2025-11-26T04:24:59Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1324197683|Derrick Ndzimande]]&quot;</comment>
      <origin>6025</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1009" sha1="crzi1hu054avupmikkmcr8h4fb8g42x" xml:space="preserve">
 

U '''-Derrick Ndzimande''' (wabelethwa mhlazi-30 kuNtaka 1954) mhlabeleli wevangeli [[Isewula Afrika|weSewula Afrika]], aphinde abe umfundisi, umkhiqizi womculo begodu owayekade afundisa. Wathola udumo ngabo-1980 no-1990 emasontweni wePentekoste newe-charismatic eSewula Afrika neenarha eziseduze. U-Ndzimande waziwa ngelizwi elihlukileko elijulileko le-falsetto-baritone kanye nomsebenzi omude wokurekhoda ofaka hlangana kokubili ama-albhamu we-studio nokurekhoda bukhoma. 

== Ipilo nomlando ==
Amaphrofayili amanengi agadangisiweko abika bona u-Derrick Ndzimande wabelethwa mhlazi-30 kuNtaka 1954 e-Vermont Farm eduze ne -Lydenburg (eseyaziwa njenge Mashishing) e-Mpumalanga, eSewula Afrika, begodu umndenakhe ngokukhamba kwesikhathi wathuthela e-[[Belfast]] ngo-1966. umvumo.   

== I-Discography ==
(Ingcenye — iinhloko ezikhutjhiweko nokutholakala eensetjenzisweni zokusakaza)

* ''Nangu UJesu'' (1998).
* ''Ama-Greatest Hits, Vol. 1'' (1999).
* ''Halala NgoJesu'' (2002).
* ''Ubusisiwe'' (2007).</text>
      <sha1>crzi1hu054avupmikkmcr8h4fb8g42x</sha1>
    </revision>
    <revision>
      <id>6026</id>
      <parentid>6025</parentid>
      <timestamp>2025-11-26T04:26:07Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1324197683|Derrick Ndzimande]]&quot;</comment>
      <origin>6026</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1300" sha1="mwvb4bhfkiqgaq2fnwtq69565ulkjkr" xml:space="preserve">
 

U '''-Derrick Ndzimande''' (wabelethwa mhlazi-30 kuNtaka 1954) mhlabeleli wevangeli [[Isewula Afrika|weSewula Afrika]], aphinde abe umfundisi, umkhiqizi womculo begodu owayekade afundisa. Wathola udumo ngabo-1980 no-1990 emasontweni wePentekoste newe-charismatic eSewula Afrika neenarha eziseduze. U-Ndzimande waziwa ngelizwi elihlukileko elijulileko le-falsetto-baritone kanye nomsebenzi omude wokurekhoda ofaka hlangana kokubili ama-albhamu we-studio nokurekhoda bukhoma. &lt;ref&gt;https://www.heraldonline.co.zw/msanzis-ndzimande-rescues-local-artiste/&lt;/ref&gt;

== Ipilo nomlando ==
Amaphrofayili amanengi agadangisiweko abika bona u-Derrick Ndzimande wabelethwa mhlazi-30 kuNtaka 1954 e-Vermont Farm eduze ne -Lydenburg (eseyaziwa njenge Mashishing) e-Mpumalanga, eSewula Afrika, begodu umndenakhe ngokukhamba kwesikhathi wathuthela e-[[Belfast]] ngo-1966. umvumo. &lt;ref&gt;https://www.sowetan.co.za/entertainment/2019-11-16-masibuyele-kujehova-records-first-live-dvd/ &lt;/ref&gt; &lt;ref&gt;https://www.newsday.co.zw/news/article/80558/sa-gospel-great-nzimande-for-maranantha-launch &lt;/ref&gt; 

== I-Discography ==
(Ingcenye — iinhloko ezikhutjhiweko nokutholakala eensetjenzisweni zokusakaza)

* ''Nangu UJesu'' (1998).
* ''Ama-Greatest Hits, Vol. 1'' (1999).
* ''Halala NgoJesu'' (2002).
* ''Ubusisiwe'' (2007).</text>
      <sha1>mwvb4bhfkiqgaq2fnwtq69565ulkjkr</sha1>
    </revision>
    <revision>
      <id>6027</id>
      <parentid>6026</parentid>
      <timestamp>2025-11-26T04:26:26Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6027</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1295" sha1="peydl57pr3gu370pm8azgzwo9i96gmx" xml:space="preserve">U '''-Derrick Ndzimande''' (wabelethwa mhlazi-30 kuNtaka 1954) mhlabeleli wevangeli [[Isewula Afrika|weSewula Afrika]], aphinde abe umfundisi, umkhiqizi womculo begodu owayekade afundisa. Wathola udumo ngabo-1980 no-1990 emasontweni wePentekoste newe-charismatic eSewula Afrika neenarha eziseduze. U-Ndzimande waziwa ngelizwi elihlukileko elijulileko le-falsetto-baritone kanye nomsebenzi omude wokurekhoda ofaka hlangana kokubili ama-albhamu we-studio nokurekhoda bukhoma. &lt;ref&gt;https://www.heraldonline.co.zw/msanzis-ndzimande-rescues-local-artiste/&lt;/ref&gt;

== Ipilo nomlando ==
Amaphrofayili amanengi agadangisiweko abika bona u-Derrick Ndzimande wabelethwa mhlazi-30 kuNtaka 1954 e-Vermont Farm eduze ne -Lydenburg (eseyaziwa njenge Mashishing) e-Mpumalanga, eSewula Afrika, begodu umndenakhe ngokukhamba kwesikhathi wathuthela e-[[Belfast]] ngo-1966. umvumo. &lt;ref&gt;https://www.sowetan.co.za/entertainment/2019-11-16-masibuyele-kujehova-records-first-live-dvd/ &lt;/ref&gt; &lt;ref&gt;https://www.newsday.co.zw/news/article/80558/sa-gospel-great-nzimande-for-maranantha-launch &lt;/ref&gt; 

== I-Discography ==
(Ingcenye — iinhloko ezikhutjhiweko nokutholakala eensetjenzisweni zokusakaza)

* ''Nangu UJesu'' (1998).
* ''Ama-Greatest Hits, Vol. 1'' (1999).
* ''Halala NgoJesu'' (2002).
* ''Ubusisiwe'' (2007).</text>
      <sha1>peydl57pr3gu370pm8azgzwo9i96gmx</sha1>
    </revision>
    <revision>
      <id>6028</id>
      <parentid>6027</parentid>
      <timestamp>2025-11-26T04:29:05Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6028</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1492" sha1="a6pdskyrs7gauziybg0f1elkw5qt81t" xml:space="preserve">U '''-Derrick Ndzimande''' (wabelethwa mhlazi-30 kuNtaka 1954) mhlabeleli wevangeli [[Isewula Afrika|weSewula Afrika]], aphinde abe umfundisi, umkhiqizi womculo begodu owayekade afundisa. Wathola udumo ngabo-1980 no-1990 emasontweni wePentekoste newe-charismatic eSewula Afrika neenarha eziseduze. U-Ndzimande waziwa ngelizwi elihlukileko elijulileko le-falsetto-baritone kanye nomsebenzi omude wokurekhoda ofaka hlangana kokubili ama-albhamu we-studio nokurekhoda bukhoma. &lt;ref&gt;https://www.heraldonline.co.zw/msanzis-ndzimande-rescues-local-artiste/&lt;/ref&gt;

== Ipilo nomlando ==
Amaphrofayili amanengi agadangisiweko abika bona u-Derrick Ndzimande wabelethwa mhlazi-30 kuNtaka 1954 e-Vermont Farm eduze ne -Lydenburg (eseyaziwa njenge Mashishing) e-Mpumalanga, eSewula Afrika, begodu umndenakhe ngokukhamba kwesikhathi wathuthela e-[[Belfast]] ngo-1966. umvumo. &lt;ref&gt;https://www.sowetan.co.za/entertainment/2019-11-16-masibuyele-kujehova-records-first-live-dvd/ &lt;/ref&gt; &lt;ref&gt;https://www.newsday.co.zw/news/article/80558/sa-gospel-great-nzimande-for-maranantha-launch &lt;/ref&gt; 

== I-Discography ==
(Ingcenye — iinhloko ezikhutjhiweko nokutholakala eensetjenzisweni zokusakaza)

* ''Nangu UJesu'' (1998).
* ''Ama-Greatest Hits, Vol. 1'' (1999).
* ''Halala NgoJesu'' (2002).
* ''Ubusisiwe'' (2007).

{{DEFAULTSORT:Ndzimande, Derrick}}
[[Category:Abantu abaphilako]]
[[Categoy:Abavumi beSewula Afrika]]
[[Category:Abahlabeleli bevangeli beSewula Afrika]]  
[[Category:Abefundisi beSewula Afrika]]</text>
      <sha1>a6pdskyrs7gauziybg0f1elkw5qt81t</sha1>
    </revision>
    <revision>
      <id>6032</id>
      <parentid>6028</parentid>
      <timestamp>2025-11-26T04:30:41Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6032</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1457" sha1="kh6yokiyribunj90egwlhfps8noktky" xml:space="preserve">U '''-Derrick Ndzimande''' (wabelethwa mhlazi-30 kuNtaka 1954) mhlabeleli wevangeli [[Isewula Afrika|weSewula Afrika]], aphinde abe umfundisi, umkhiqizi womculo begodu owayekade afundisa. Wathola udumo ngabo-1980 no-1990 emasontweni wePentekoste newe-charismatic eSewula Afrika neenarha eziseduze. U-Ndzimande waziwa ngelizwi elihlukileko elijulileko le-falsetto-baritone kanye nomsebenzi omude wokurekhoda ofaka hlangana kokubili ama-albhamu we-studio nokurekhoda bukhoma. &lt;ref&gt;https://www.heraldonline.co.zw/msanzis-ndzimande-rescues-local-artiste/&lt;/ref&gt;

== Ipilo nomlando ==
Amaphrofayili amanengi agadangisiweko abika bona u-Derrick Ndzimande wabelethwa mhlazi-30 kuNtaka 1954 e-Vermont Farm eduze ne -Lydenburg (eseyaziwa njenge Mashishing) e-Mpumalanga, eSewula Afrika, begodu umndenakhe ngokukhamba kwesikhathi wathuthela e-[[Belfast]] ngo-1966. umvumo. &lt;ref&gt;https://www.sowetan.co.za/entertainment/2019-11-16-masibuyele-kujehova-records-first-live-dvd/ &lt;/ref&gt; &lt;ref&gt;https://www.newsday.co.zw/news/article/80558/sa-gospel-great-nzimande-for-maranantha-launch &lt;/ref&gt; 

== I-Discography ==
(Ingcenye — iinhloko ezikhutjhiweko nokutholakala eensetjenzisweni zokusakaza)

* ''Nangu UJesu'' (1998).
* ''Ama-Greatest Hits, Vol. 1'' (1999).
* ''Halala NgoJesu'' (2002).
* ''Ubusisiwe'' (2007).

[[Category:Abantu abaphilako]]
[[Categoy:Abavumi beSewula Afrika]]
[[Category:Abahlabeleli bevangeli beSewula Afrika]]  
[[Category:Abefundisi beSewula Afrika]]</text>
      <sha1>kh6yokiyribunj90egwlhfps8noktky</sha1>
    </revision>
    <revision>
      <id>6033</id>
      <parentid>6032</parentid>
      <timestamp>2025-11-26T04:31:29Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6033</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1458" sha1="2np846mmxnae0yjf9vgxpf6lb6ulhwl" xml:space="preserve">U '''-Derrick Ndzimande''' (wabelethwa mhlazi-30 kuNtaka 1954) mhlabeleli wevangeli [[Isewula Afrika|weSewula Afrika]], aphinde abe umfundisi, umkhiqizi womculo begodu owayekade afundisa. Wathola udumo ngabo-1980 no-1990 emasontweni wePentekoste newe-charismatic eSewula Afrika neenarha eziseduze. U-Ndzimande waziwa ngelizwi elihlukileko elijulileko le-falsetto-baritone kanye nomsebenzi omude wokurekhoda ofaka hlangana kokubili ama-albhamu we-studio nokurekhoda bukhoma. &lt;ref&gt;https://www.heraldonline.co.zw/msanzis-ndzimande-rescues-local-artiste/&lt;/ref&gt;

== Ipilo nomlando ==
Amaphrofayili amanengi agadangisiweko abika bona u-Derrick Ndzimande wabelethwa mhlazi-30 kuNtaka 1954 e-Vermont Farm eduze ne -Lydenburg (eseyaziwa njenge Mashishing) e-Mpumalanga, eSewula Afrika, begodu umndenakhe ngokukhamba kwesikhathi wathuthela e-[[Belfast]] ngo-1966. umvumo. &lt;ref&gt;https://www.sowetan.co.za/entertainment/2019-11-16-masibuyele-kujehova-records-first-live-dvd/ &lt;/ref&gt; &lt;ref&gt;https://www.newsday.co.zw/news/article/80558/sa-gospel-great-nzimande-for-maranantha-launch &lt;/ref&gt; 

== I-Discography ==
(Ingcenye — iinhloko ezikhutjhiweko nokutholakala eensetjenzisweni zokusakaza)

* ''Nangu UJesu'' (1998).
* ''Ama-Greatest Hits, Vol. 1'' (1999).
* ''Halala NgoJesu'' (2002).
* ''Ubusisiwe'' (2007).

[[Category:Abantu abaphilako]]
[[Category:Abavumi beSewula Afrika]]
[[Category:Abahlabeleli bevangeli beSewula Afrika]]  
[[Category:Abefundisi beSewula Afrika]]</text>
      <sha1>2np846mmxnae0yjf9vgxpf6lb6ulhwl</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Abantu abaphilako</title>
    <ns>14</ns>
    <id>1001</id>
    <revision>
      <id>6029</id>
      <timestamp>2025-11-26T04:29:33Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created page with &quot;List of people who are alive.&quot;</comment>
      <origin>6029</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="29" sha1="ac0ssuym8wn328qvxf6f9fd4jwxt790" xml:space="preserve">List of people who are alive.</text>
      <sha1>ac0ssuym8wn328qvxf6f9fd4jwxt790</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Abahlabeleli bevangeli beSewula Afrika</title>
    <ns>14</ns>
    <id>1002</id>
    <revision>
      <id>6030</id>
      <timestamp>2025-11-26T04:29:55Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created page with &quot;South African musicians.&quot;</comment>
      <origin>6030</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="24" sha1="lxk9pset92cdu8c9cecet02cnezu4r4" xml:space="preserve">South African musicians.</text>
      <sha1>lxk9pset92cdu8c9cecet02cnezu4r4</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Abefundisi beSewula Afrika</title>
    <ns>14</ns>
    <id>1003</id>
    <revision>
      <id>6031</id>
      <timestamp>2025-11-26T04:30:12Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created page with &quot;South African Pastors.&quot;</comment>
      <origin>6031</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="22" sha1="r4fx6c98mnjikp68z7r8v0qm9715nse" xml:space="preserve">South African Pastors.</text>
      <sha1>r4fx6c98mnjikp68z7r8v0qm9715nse</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Abavumi beSewula Afrika</title>
    <ns>14</ns>
    <id>1004</id>
    <revision>
      <id>6034</id>
      <timestamp>2025-11-26T04:31:42Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created page with &quot;South African musicians&quot;</comment>
      <origin>6034</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="23" sha1="0sqleekc7om6tqwq78kt08q1y22oij8" xml:space="preserve">South African musicians</text>
      <sha1>0sqleekc7om6tqwq78kt08q1y22oij8</sha1>
    </revision>
  </page>
  <page>
    <title>PKTT</title>
    <ns>0</ns>
    <id>1005</id>
    <revision>
      <id>6036</id>
      <timestamp>2025-11-26T08:31:07Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>I added links</comment>
      <origin>6036</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="10103" sha1="tl4mbr8p5kybh3noz6w63jt34ohev5r" xml:space="preserve">
== I-POLITICAL KILLINGS TASK TEAM. ==
[[Isimumathi:Senzo Mchunu on PolitySA.jpg|thumb|U-Senzo Mchunu ]]

==== I-Political killings task team(PKTT)bekuyiyunithi ekhethekileko yamapholisa eSewula Afrika eyasungulwa ukuphenya nokutjhutjhisa ubulelesi obubangelwa kulwa kwezepolotiki,khulu khulu eendaweni ezifana ne-Kwa Zulu Natal lapho ukubulawa kwabantu ngebanga lepolitiki kuvame khona.Isiqhema sokusebenza sahlakazwa ngokusemthethweni ngoNobayeni 2024 nguNgqongotjhe wamapholisa u-Senzo Mchunu,isiqunto athi sivunywe nguMengameli u-Cyril Ramaphosa. ====

== Umqopho neSakhiwo se-PKTT. ==
Umqopho we-'''PKTT''' bekuphenya ngokubulawa okuhlobene nokuphalisana kwezepolitiki,ngengokulwa ngezikhundla ngaphakathi kweenhlangano zepolotiki nabomasipala.

Isakhiwo se-'''PKTT''' bekuliyunithi ezinikeleko ebegade isebenza namanye ama-ejensi wombuso afana ne-'''National Prosecuting Authority Agency (NPA)'''.Isiqhema siphumelele ekwenzeni ukubopha nokuthola amacala.&lt;ref&gt;I-POLITICAL KILLINGS TASK TEAM.

I-Political killings task team(PKTT)bekuyiyunithi ekhethekileko yamapholisa eSewula Afrika eyasungulwa ukuphenya nokutjhutjhisa ubulelesi obubangelwa kulwa kwezepolotiki,khulu khulu eendaweni ezifana ne-Kwa Zulu Natal lapho ukubulawa kwabantu ngebanga lepolitiki kuvame khona.Isiqhema sokusebenza sahlakazwa ngokusemthethweni ngoNobayeni 2024 nguNgqongotjhe wamapholisa u-Senzo Mchunu,isiqunto athi sivunywe nguMengameli u-Cyril Ramaphosa.

Umqopho neSakhiwo se-PKTT.

Umqopho we-'''PKTT''' bekuphenya ngokubulawa okuhlobene nokuphalisana kwezepolitiki,ngengokulwa ngezikhundla ngaphakathi kweenhlangano zepolotiki nabomasipala.

Isakhiwo se-'''PKTT''' bekuliyunithi ezinikeleko ebegade isebenza namanye ama-ejensi wombuso afana ne-'''National Prosecuting Authority Agency (NPA)'''.Isiqhema siphumelele ekwenzeni ukubopha nokuthola amacala.

Ituthuko eqakathekileko.

'''.'''Ukuphindaphinda kwesibili kwesiqhema somsebenzi kwathonywa ngo-Velabahlinze 2018.

'''.'''Isiqhema besinomthwalo wenani eliphezulu lokubotjhwa nokugwetjwa okuhlobene nokubulawa kwabantu ngebanga lezepolotiki.

'''.'''Iinhlangano zepolotiki ezithinteke khulu bekuyi-'''ANC,IFP,'''ne-'''NFP.'''

Kubayini uNgqongqotjhe wamapholisa e-Sewula Afrika wayala bonyana isiqhema se-PKTT sivalwe?

Imibuzo mibili ekufanele icacise bona umphathintambo bekakhuthazwa ziintshwenyeko ezizwakalako nofana iinhloso zepolotiki ezingakalungi.Emhlanganweni wakhe omangalisako weendaba wango mhlaka-06 kuVelabahlinze 2025,uKhomitjhana wamaPholisa we-Phrovinsi ye-'''KwaZulu-Natal''' u-'''Nhlanhla Mkhwanazi''' iinsolo ezinengi eziphakamisa imibuzo emikhulu ngendima yabosopolotiki abakhohlakeleko namaPholisa ekukhuthazeni ubulelesi obuhlelekileko e-'''Sewula Afrika'''.Ikulumo ka'''Mkhwanazi''' iveze umyalo otlolwe ngu-Ngqongqotjhe wamaPholisa u-'''Senzo Mchunu''' mhlazi-31 kuNobayeni 2024,kobana isiqhema sokusebenza ngokubulalana kwezepolotiki sivalwe msinyana.Waveza bona umyalo lo bewuhloselwe ukukhandela iphenyo lamalunga weenlelesi athokozela ukuvikelwa kwabosopolotiki abakhohlakeleko begodu okungenzeka ahlotjaniswa nokubulawa kwababiki.U-'''Mkhwanazi''' ubonakala aqinisekisa bona amapholisa aphezulu nawo abandakanyeka ekuvimbeleni iphenyo eliragela phambili ngamacala la.Iinsolo zakhe ziphakamisa imibuzo malungana nokuthi u-'''Mchunu''' wenze ngokuzwakalako nangokufaneleko na ngokulaya bona isiqhema sokusebenza sivalwe,nofana bekaneenhloso ezingakalungi.

UNgqongqotjhe wamaPholisa uvikela ukuhlakazwa kwe-PKTT,wathi uMengameli uvume isiqundo.

Ngesikhathi avela uNgqongqotjhe u-'''Mchunu''' wavikela isiqundo sakhe sokuhlakaza i-'''PKTT''' '''Kwa-Zulu Natal''',wazisa ikomidi bona unemvumo kaMengameli u-'''Cyril Ramaphosa''' ukuragela phambili ngesiqundo.U-'''Mchunu''' uveze bona utjele uMengameli u-'''Cyril Ramaphosa''' ngehloso yakhe yokuhlakaza isiqhema somsebenzi begodu begodu uMengameli wasekela ukucabanga kwakhe.Wahlathulula bona ukutjela uMengameli bekuhloswe ngakho ukukhandela ukungezwani kwezepolotiki obuhlobene nesiqhema sokusebenza.&quot;Ngamtjela bona iindaba lezi,hlangana nezinye zingenze ngahlakaza isiqhema lesi.Ngathana bengingakathathi igadango,bekungaba nesikhathi sokuthi kube nekhomitjhini yokuphenya ngeendaba lezo.Nje ke ngaqunda ukukhandela ukubizwa okunjalo.&quot;watjho.Ikomidi ibuye yezwa bona u-'''Mchunu''' weluleka umphathi wakhe wange-ofisini u-'''Cedrick Nkabinde''' bona arekhode ikulumo no-Lieutenant General '''Mkhwanazi''' ngemva kokuthola lokhu ahlathulule bona ziinsongo zokuziphindiselela ezihlobene nokuhlakazwa kwe-'''PKTT'''.Wahlathulula bona ukurekhodwa kwephimbo nge-WhatsApp hlangana no-'''Nkabinde''' no-'''Mkhwanazi''' bekuneentjhijilo zokuthi uKhomitjhina uzokulwa okuvuse ukutshwenyeka ngokuphepha kwakhe.Amagama anqophileko nanyana kunjalo bekangakghoni ukuzwakala kuhle etjhadeni elidlalwe phambi kwekomidi.

Nanyana isiqhema somsebenzi sinedumela lokusebenza kuhle,umthelela waso ekubulaweni kwabantu ngebanga lezepolotiki awucaci.

Eminyakeni eminengi eli-17 edlulileko uNgqongqotjhe wamaPholisa we-'''Sewula Afrika''' bekavela '''Kwa-Zulu Natal'''.Akukho Ngqongqotjhe wamaPholisa owaziwako bona walinga ukukhawulela ithonya lezepolitiki emapholiseni.Isiqhema esisebenzako kungenzeka bona besisilaphazwe lithonya lezepolotiki solo sathoma.Yasungulwa ngo-2016 ngaphasi kuka-'''Nathi Nhleko''' owakhethwa njengo ngqongqotjhe wamapholisa ngumengameli waphambilini u-'''Jacob Zuma''' ngo-2014.Umbuso ka-'''Zuma''' wazibandakanya ekukhohliseni ihlelo lobulungiswa lobulelesi.

Inkhombo.

1.&lt;nowiki&gt;https://issafrica.org/iss-today/why-did-sa-s-police-minister-order-the-political-killings-task-team-shutdown&lt;/nowiki&gt; 2.&lt;nowiki&gt;https://www.parliament.gov.za/news/police-minister-defends-disbanding-political-killings-task-team-saying-president-approved-decision&lt;/nowiki&gt; 3.&lt;nowiki&gt;https://www.enca.com/news/madlanga-commission-mkhwanazi-reveals-why-political-killings-task-team-was-established&lt;/nowiki&gt;&lt;/ref&gt;

==== Ituthuko eqakathekileko. ====
'''.'''Ukuphindaphinda kwesibili kwesiqhema somsebenzi kwathonywa ngo-Velabahlinze 2018.

'''.'''Isiqhema besinomthwalo wenani eliphezulu lokubotjhwa nokugwetjwa okuhlobene nokubulawa kwabantu ngebanga lezepolotiki.

'''.'''Iinhlangano zepolotiki ezithinteke khulu bekuyi-'''ANC,IFP,'''ne-'''NFP.'''

==== Kubayini uNgqongqotjhe wamapholisa e-Sewula Afrika wayala bonyana isiqhema se-PKTT sivalwe? ====
Imibuzo mibili ekufanele icacise bona umphathintambo bekakhuthazwa ziintshwenyeko ezizwakalako nofana iinhloso zepolotiki ezingakalungi.Emhlanganweni wakhe omangalisako weendaba wango mhlaka-06 kuVelabahlinze 2025,uKhomitjhana wamaPholisa we-Phrovinsi ye-'''KwaZulu-Natal''' u-'''Nhlanhla Mkhwanazi''' iinsolo ezinengi eziphakamisa imibuzo emikhulu ngendima yabosopolotiki abakhohlakeleko namaPholisa ekukhuthazeni ubulelesi obuhlelekileko e-'''Sewula Afrika'''.Ikulumo ka'''Mkhwanazi''' iveze umyalo otlolwe ngu-Ngqongqotjhe wamaPholisa u-'''Senzo Mchunu''' mhlazi-31 kuNobayeni 2024,kobana isiqhema sokusebenza ngokubulalana kwezepolotiki sivalwe msinyana.Waveza bona umyalo lo bewuhloselwe ukukhandela iphenyo lamalunga weenlelesi athokozela ukuvikelwa kwabosopolotiki abakhohlakeleko begodu okungenzeka ahlotjaniswa nokubulawa kwababiki.U-'''Mkhwanazi''' ubonakala aqinisekisa bona amapholisa aphezulu nawo abandakanyeka ekuvimbeleni iphenyo eliragela phambili ngamacala la.Iinsolo zakhe ziphakamisa imibuzo malungana nokuthi u-'''Mchunu''' wenze ngokuzwakalako nangokufaneleko na ngokulaya bona isiqhema sokusebenza sivalwe,nofana bekaneenhloso ezingakalungi.

===== UNgqongqotjhe wamaPholisa uvikela ukuhlakazwa kwe-PKTT,wathi uMengameli uvume isiqundo. =====
Ngesikhathi avela uNgqongqotjhe u-'''Mchunu''' wavikela isiqundo sakhe sokuhlakaza i-'''PKTT''' '''Kwa-Zulu Natal''',wazisa ikomidi bona unemvumo kaMengameli u-'''Cyril Ramaphosa''' ukuragela phambili ngesiqundo.U-'''Mchunu''' uveze bona utjele uMengameli u-'''Cyril Ramaphosa''' ngehloso yakhe yokuhlakaza isiqhema somsebenzi begodu begodu uMengameli wasekela ukucabanga kwakhe.Wahlathulula bona ukutjela uMengameli bekuhloswe ngakho ukukhandela ukungezwani kwezepolotiki obuhlobene nesiqhema sokusebenza.&quot;Ngamtjela bona iindaba lezi,hlangana nezinye zingenze ngahlakaza isiqhema lesi.Ngathana bengingakathathi igadango,bekungaba nesikhathi sokuthi kube nekhomitjhini yokuphenya ngeendaba lezo.Nje ke ngaqunda ukukhandela ukubizwa okunjalo.&quot;watjho.Ikomidi ibuye yezwa bona u-'''Mchunu''' weluleka umphathi wakhe wange-ofisini u-'''Cedrick Nkabinde''' bona arekhode ikulumo no-Lieutenant General '''Mkhwanazi''' ngemva kokuthola lokhu ahlathulule bona ziinsongo zokuziphindiselela ezihlobene nokuhlakazwa kwe-'''PKTT'''.Wahlathulula bona ukurekhodwa kwephimbo nge-WhatsApp hlangana no-'''Nkabinde''' no-'''Mkhwanazi''' bekuneentjhijilo zokuthi uKhomitjhina uzokulwa okuvuse ukutshwenyeka ngokuphepha kwakhe.Amagama anqophileko nanyana kunjalo bekangakghoni ukuzwakala kuhle etjhadeni elidlalwe phambi kwekomidi.
[[Isimumathi:Part of a bookshelf containing books by Aristotle (1).jpg|thumb|IINCWADI ZOMTHETHO]]

====== Nanyana isiqhema somsebenzi sinedumela lokusebenza kuhle,umthelela waso ekubulaweni kwabantu ngebanga lezepolotiki awucaci. ======
Eminyakeni eminengi eli-17 edlulileko uNgqongqotjhe wamaPholisa we-'''Sewula Afrika''' bekavela '''Kwa-Zulu Natal'''.Akukho Ngqongqotjhe wamaPholisa owaziwako bona walinga ukukhawulela ithonya lezepolitiki emapholiseni.Isiqhema esisebenzako kungenzeka bona besisilaphazwe lithonya lezepolotiki solo sathoma.Yasungulwa ngo-2016 ngaphasi kuka-'''Nathi Nhleko''' owakhethwa njengo ngqongqotjhe wamapholisa ngumengameli waphambilini u-'''Jacob Zuma''' ngo-2014.Umbuso ka-'''Zuma''' wazibandakanya ekukhohliseni ihlelo lobulungiswa lobulelesi.

====== Inkhombo. ======
1.https://issafrica.org/iss-today/why-did-sa-s-police-minister-order-the-political-killings-task-team-shutdown
2.https://www.parliament.gov.za/news/police-minister-defends-disbanding-political-killings-task-team-saying-president-approved-decision
3.https://www.enca.com/news/madlanga-commission-mkhwanazi-reveals-why-political-killings-task-team-was-established</text>
      <sha1>tl4mbr8p5kybh3noz6w63jt34ohev5r</sha1>
    </revision>
    <revision>
      <id>6037</id>
      <parentid>6036</parentid>
      <timestamp>2025-11-26T11:20:32Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>/* Umqopho neSakhiwo se-PKTT. */ Fixed typo</comment>
      <origin>6037</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5785" sha1="p6t5kv1h039g1iqq9k81hviadf6p2rx" xml:space="preserve">
== I-POLITICAL KILLINGS TASK TEAM. ==
[[Isimumathi:Senzo Mchunu on PolitySA.jpg|thumb|U-Senzo Mchunu ]]

==== I-Political killings task team(PKTT)bekuyiyunithi ekhethekileko yamapholisa eSewula Afrika eyasungulwa ukuphenya nokutjhutjhisa ubulelesi obubangelwa kulwa kwezepolotiki,khulu khulu eendaweni ezifana ne-Kwa Zulu Natal lapho ukubulawa kwabantu ngebanga lepolitiki kuvame khona.Isiqhema sokusebenza sahlakazwa ngokusemthethweni ngoNobayeni 2024 nguNgqongotjhe wamapholisa u-Senzo Mchunu,isiqunto athi sivunywe nguMengameli u-Cyril Ramaphosa. ====

== Umqopho neSakhiwo se-PKTT. ==
Umqopho we-'''PKTT''' bekuphenya ngokubulawa okuhlobene nokuphalisana kwezepolitiki,ngengokulwa ngezikhundla ngaphakathi kweenhlangano zepolotiki nabomasipala.

Isakhiwo se-'''PKTT''' bekuliyunithi ezinikeleko ebegade isebenza namanye ama-ejensi wombuso afana ne-'''National Prosecuting Authority Agency (NPA)'''.Isiqhema siphumelele ekwenzeni ukubopha nokuthola amacala.&lt;ref&gt;I-POLITICAL KILLINGS TASK TEAM.

I-Political killings task team(PKTT)bekuyiyunithi ekhethekileko yamapholisa eSewula Afrika eyasungulwa ukuphenya nokutjhutjhisa ubulelesi obubangelwa kulwa kwezepolotiki,khulu khulu eendaweni ezifana ne-Kwa Zulu Natal lapho ukubulawa kwabantu ngebanga lepolitiki kuvame khona.Isiqhema sokusebenza sahlakazwa ngokusemthethweni ngoNobayeni 2024 nguNgqongotjhe wamapholisa u-Senzo Mchunu,isiqunto athi sivunywe nguMengameli u-Cyril Ramaphosa.

Umqopho neSakhiwo se-PKTT.

Umqopho we-'''PKTT''' bekuphenya ngokubulawa okuhlobene nokuphalisana kwezepolitiki,ngengokulwa ngezikhundla ngaphakathi kweenhlangano zepolotiki nabomasipala.

Isakhiwo se-'''PKTT''' bekuliyunithi ezinikeleko ebegade isebenza namanye ama-ejensi wombuso afana ne-'''National Prosecuting Authority Agency (NPA)'''.Isiqhema siphumelele ekwenzeni ukubopha nokuthola amacala.

Ituthuko eqakathekileko.

'''.'''Ukuphindaphinda kwesibili kwesiqhema somsebenzi kwathonywa ngo-Velabahlinze 2018.

'''.'''Isiqhema besinomthwalo wenani eliphezulu lokubotjhwa nokugwetjwa okuhlobene nokubulawa kwabantu ngebanga lezepolotiki.

'''.'''Iinhlangano zepolotiki ezithinteke khulu bekuyi-'''ANC,IFP,'''ne-'''NFP.'''

Kubayini uNgqongqotjhe wamapholisa e-Sewula Afrika wayala bonyana isiqhema se-PKTT sivalwe?

Imibuzo mibili ekufanele icacise bona umphathintambo bekakhuthazwa ziintshwenyeko ezizwakalako nofana iinhloso zepolotiki ezingakalungi.Emhlanganweni wakhe omangalisako weendaba wango mhlaka-06 kuVelabahlinze 2025,uKhomitjhana wamaPholisa we-Phrovinsi ye-'''KwaZulu-Natal''' u-'''Nhlanhla Mkhwanazi''' iinsolo ezinengi eziphakamisa imibuzo emikhulu ngendima yabosopolotiki abakhohlakeleko namaPholisa ekukhuthazeni ubulelesi obuhlelekileko e-'''Sewula Afrika'''.Ikulumo ka'''Mkhwanazi''' iveze umyalo otlolwe ngu-Ngqongqotjhe wamaPholisa u-'''Senzo Mchunu''' mhlazi-31 kuNobayeni 2024,kobana isiqhema sokusebenza ngokubulalana kwezepolotiki sivalwe msinyana.Waveza bona umyalo lo bewuhloselwe ukukhandela iphenyo lamalunga weenlelesi athokozela ukuvikelwa kwabosopolotiki abakhohlakeleko begodu okungenzeka ahlotjaniswa nokubulawa kwababiki.U-'''Mkhwanazi''' ubonakala aqinisekisa bona amapholisa aphezulu nawo abandakanyeka ekuvimbeleni iphenyo eliragela phambili ngamacala la.Iinsolo zakhe ziphakamisa imibuzo malungana nokuthi u-'''Mchunu''' wenze ngokuzwakalako nangokufaneleko na ngokulaya bona isiqhema sokusebenza sivalwe,nofana bekaneenhloso ezingakalungi.

UNgqongqotjhe wamaPholisa uvikela ukuhlakazwa kwe-PKTT,wathi uMengameli uvume isiqundo.

Ngesikhathi avela uNgqongqotjhe u-'''Mchunu''' wavikela isiqundo sakhe sokuhlakaza i-'''PKTT''' '''Kwa-Zulu Natal''',wazisa ikomidi bona unemvumo kaMengameli u-'''Cyril Ramaphosa''' ukuragela phambili ngesiqundo.U-'''Mchunu''' uveze bona utjele uMengameli u-'''Cyril Ramaphosa''' ngehloso yakhe yokuhlakaza isiqhema somsebenzi begodu begodu uMengameli wasekela ukucabanga kwakhe.Wahlathulula bona ukutjela uMengameli bekuhloswe ngakho ukukhandela ukungezwani kwezepolotiki obuhlobene nesiqhema sokusebenza.&quot;Ngamtjela bona iindaba lezi,hlangana nezinye zingenze ngahlakaza isiqhema lesi.Ngathana bengingakathathi igadango,bekungaba nesikhathi sokuthi kube nekhomitjhini yokuphenya ngeendaba lezo.Nje ke ngaqunda ukukhandela ukubizwa okunjalo.&quot;watjho.Ikomidi ibuye yezwa bona u-'''Mchunu''' weluleka umphathi wakhe wange-ofisini u-'''Cedrick Nkabinde''' bona arekhode ikulumo no-Lieutenant General '''Mkhwanazi''' ngemva kokuthola lokhu ahlathulule bona ziinsongo zokuziphindiselela ezihlobene nokuhlakazwa kwe-'''PKTT'''.Wahlathulula bona ukurekhodwa kwephimbo nge-WhatsApp hlangana no-'''Nkabinde''' no-'''Mkhwanazi''' bekuneentjhijilo zokuthi uKhomitjhina uzokulwa okuvuse ukutshwenyeka ngokuphepha kwakhe.Amagama anqophileko nanyana kunjalo bekangakghoni ukuzwakala kuhle etjhadeni elidlalwe phambi kwekomidi.

Nanyana isiqhema somsebenzi sinedumela lokusebenza kuhle,umthelela waso ekubulaweni kwabantu ngebanga lezepolotiki awucaci.

Eminyakeni eminengi eli-17 edlulileko uNgqongqotjhe wamaPholisa we-'''Sewula Afrika''' bekavela '''Kwa-Zulu Natal'''.Akukho Ngqongqotjhe wamaPholisa owaziwako bona walinga ukukhawulela ithonya lezepolitiki emapholiseni.Isiqhema esisebenzako kungenzeka bona besisilaphazwe lithonya lezepolotiki solo sathoma.Yasungulwa ngo-2016 ngaphasi kuka-'''Nathi Nhleko''' owakhethwa njengo ngqongqotjhe wamapholisa ngumengameli waphambilini u-'''Jacob Zuma''' ngo-2014.Umbuso ka-'''Zuma''' wazibandakanya ekukhohliseni ihlelo lobulungiswa lobulelesi.

Inkhombo.

1.&lt;nowiki&gt;https://issafrica.org/iss-today/why-did-sa-s-police-minister-order-the-political-killings-task-team-shutdown&lt;/nowiki&gt; 2.&lt;nowiki&gt;https://www.parliament.gov.za/news/police-minister-defends-disbanding-political-killings-task-team-saying-president-approved-decision&lt;/nowiki&gt;</text>
      <sha1>p6t5kv1h039g1iqq9k81hviadf6p2rx</sha1>
    </revision>
  </page>
  <page>
    <title>Helen Suzman</title>
    <ns>0</ns>
    <id>1006</id>
    <revision>
      <id>6038</id>
      <timestamp>2025-11-27T06:48:56Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;Helen Suzman wabelethwa mhlana amalanga ali 17-Nobayeni ngo- 1917 endaweni Germiston Esewula afrika .&lt;ref&gt;https://sahistory.org.za/people/helen-suzman&lt;/ref&gt;Wakhulela emndenini wamajuda aphakathi nendawo . Ipilo yakhe yokuthoma iphawulwa ukuveza kokungabi nobulungiswa emphakathini bona agqine sele anekareko kweze polotiki .Waragela phambili nemfundo zakhe eyunivesithi ye-witwatersrand ,lapho aphetha khona iziqu zeembalo nomnotho.   Ukungena kweze polotiki kwasuzman kwatho...&quot;</comment>
      <origin>6038</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1886" sha1="lvf81nks0i4uoxospra0y6d1c6vkt1f" xml:space="preserve">Helen Suzman wabelethwa mhlana amalanga ali 17-Nobayeni ngo- 1917 endaweni Germiston Esewula afrika .&lt;ref&gt;https://sahistory.org.za/people/helen-suzman&lt;/ref&gt;Wakhulela emndenini wamajuda aphakathi nendawo . Ipilo yakhe yokuthoma iphawulwa ukuveza kokungabi nobulungiswa emphakathini bona agqine sele anekareko kweze polotiki .Waragela phambili nemfundo zakhe eyunivesithi ye-witwatersrand ,lapho aphetha khona iziqu zeembalo nomnotho. 

Ukungena kweze polotiki kwasuzman kwathomangomnyakA yab-1950 isikhathi lapho isewula africa beyiqinisa khona imithetho imithetho yebandlululo wajoyina I -united party kodwana msinyana waphelelwa yithemba ngobunjalo bayo endabeni sobuhlanga. Ngo -1953 wasunguza I liberal progressive party nabanye abasekeli ,okufaka hlangana u-colin eglin no-Harry Oppenheimer. uHelen Suzman waba ngomunye wama lunga wepalamende Wokuthoma kwehlangano ngo-1953 isifunda -houngton e-johhanesburg.

Kwaphela iminyaka eli-13 bekayilunga lepalamende ye progressive party asebenzisa iplatfomu yakhe ukwenza ukuphikisa nebandlululo loklwela amalungelo wobuntu. Iinkulumo zakhe zitjengisa ukuthi unesbindi begodu   nokungenelela kwakhe epalamende kamdosela amehlo weentjhabatjhaba, okwenza bona abe mumuntu owaziwako emsikinyekweni wokulwisana nebandlululo.&lt;ref&gt;Nel, C., 2013. ''The life of Helen Suzman: A psychobiographical study'' (Doctoral dissertation, University of the Free State).&lt;/ref&gt;

Intjhijilo nelifa kiwo woke umsebenzi wakhe uSuzman waqalana nokuhlukunyezwa, ukuthuselwa, nokuthathelwa phasi ngurhulumende. Waqundelwa amakhambo begodu wathathelwa nephasipoti yakhe .Nanyana bekanentjhijilo lezi wahlala aqinile wathola ebantwini alingana nabo nebantwini abalwela ubulungiswa bezehlala kuhle amalungelo wobuntu nokulingana igalelo lakhe lavula indlela ennzukulwaneni ezizako nakibosopolitikki okufaka hlangana no-Nelson Mandela owakha naye ubudlelwane obuseduze.</text>
      <sha1>lvf81nks0i4uoxospra0y6d1c6vkt1f</sha1>
    </revision>
    <revision>
      <id>6039</id>
      <parentid>6038</parentid>
      <timestamp>2025-11-27T06:50:04Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6039</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1936" sha1="bmpvugjil9xu11gatosr1ebavq0hug6" xml:space="preserve">[[Isimumathi:HelenSuzman.jpg|thumb|Helen Suzman]]
Helen Suzman wabelethwa mhlana amalanga ali 17-Nobayeni ngo- 1917 endaweni Germiston Esewula afrika .&lt;ref&gt;https://sahistory.org.za/people/helen-suzman&lt;/ref&gt;Wakhulela emndenini wamajuda aphakathi nendawo . Ipilo yakhe yokuthoma iphawulwa ukuveza kokungabi nobulungiswa emphakathini bona agqine sele anekareko kweze polotiki .Waragela phambili nemfundo zakhe eyunivesithi ye-witwatersrand ,lapho aphetha khona iziqu zeembalo nomnotho. 

Ukungena kweze polotiki kwasuzman kwathomangomnyakA yab-1950 isikhathi lapho isewula africa beyiqinisa khona imithetho imithetho yebandlululo wajoyina I -united party kodwana msinyana waphelelwa yithemba ngobunjalo bayo endabeni sobuhlanga. Ngo -1953 wasunguza I liberal progressive party nabanye abasekeli ,okufaka hlangana u-colin eglin no-Harry Oppenheimer. uHelen Suzman waba ngomunye wama lunga wepalamende Wokuthoma kwehlangano ngo-1953 isifunda -houngton e-johhanesburg.

Kwaphela iminyaka eli-13 bekayilunga lepalamende ye progressive party asebenzisa iplatfomu yakhe ukwenza ukuphikisa nebandlululo loklwela amalungelo wobuntu. Iinkulumo zakhe zitjengisa ukuthi unesbindi begodu   nokungenelela kwakhe epalamende kamdosela amehlo weentjhabatjhaba, okwenza bona abe mumuntu owaziwako emsikinyekweni wokulwisana nebandlululo.&lt;ref&gt;Nel, C., 2013. ''The life of Helen Suzman: A psychobiographical study'' (Doctoral dissertation, University of the Free State).&lt;/ref&gt;

Intjhijilo nelifa kiwo woke umsebenzi wakhe uSuzman waqalana nokuhlukunyezwa, ukuthuselwa, nokuthathelwa phasi ngurhulumende. Waqundelwa amakhambo begodu wathathelwa nephasipoti yakhe .Nanyana bekanentjhijilo lezi wahlala aqinile wathola ebantwini alingana nabo nebantwini abalwela ubulungiswa bezehlala kuhle amalungelo wobuntu nokulingana igalelo lakhe lavula indlela ennzukulwaneni ezizako nakibosopolitikki okufaka hlangana no-Nelson Mandela owakha naye ubudlelwane obuseduze.</text>
      <sha1>bmpvugjil9xu11gatosr1ebavq0hug6</sha1>
    </revision>
    <revision>
      <id>6040</id>
      <parentid>6039</parentid>
      <timestamp>2025-11-27T06:51:40Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6040</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1958" sha1="t594y1iryffqcrzwnv9ynubx2uzatz3" xml:space="preserve">[[Isimumathi:HelenSuzman.jpg|thumb|Helen Suzman]]
'''Helen Suzman''' wabelethwa mhlana amalanga ali 17-Nobayeni ngo- 1917 endaweni Germiston Esewula afrika .&lt;ref&gt;https://sahistory.org.za/people/helen-suzman&lt;/ref&gt;Wakhulela emndenini wamajuda aphakathi nendawo . Ipilo yakhe yokuthoma iphawulwa ukuveza kokungabi nobulungiswa emphakathini bona agqine sele anekareko kweze polotiki .Waragela phambili nemfundo zakhe eyunivesithi ye-witwatersrand ,lapho aphetha khona iziqu zeembalo nomnotho. 

Ukungena kweze polotiki kwasuzman kwathomangomnyakA yab-1950 isikhathi lapho isewula africa beyiqinisa khona imithetho imithetho yebandlululo wajoyina I -united party kodwana msinyana waphelelwa yithemba ngobunjalo bayo endabeni sobuhlanga. Ngo -1953 wasunguza I liberal progressive party nabanye abasekeli ,okufaka hlangana u-colin eglin no-Harry Oppenheimer. uHelen Suzman waba ngomunye wama lunga wepalamende Wokuthoma kwehlangano ngo-1953 isifunda -houngton e-johhanesburg.

Kwaphela iminyaka eli-13 bekayilunga lepalamende ye progressive party asebenzisa iplatfomu yakhe ukwenza ukuphikisa nebandlululo loklwela amalungelo wobuntu. Iinkulumo zakhe zitjengisa ukuthi unesbindi begodu   nokungenelela kwakhe epalamende kamdosela amehlo weentjhabatjhaba, okwenza bona abe mumuntu owaziwako emsikinyekweni wokulwisana nebandlululo.&lt;ref&gt;Nel, C., 2013. ''The life of Helen Suzman: A psychobiographical study'' (Doctoral dissertation, University of the Free State).&lt;/ref&gt;

Intjhijilo nelifa kiwo woke umsebenzi wakhe uSuzman waqalana nokuhlukunyezwa, ukuthuselwa, nokuthathelwa phasi ngurhulumende. Waqundelwa amakhambo begodu wathathelwa nephasipoti yakhe .Nanyana bekanentjhijilo lezi wahlala aqinile wathola ebantwini alingana nabo nebantwini abalwela ubulungiswa bezehlala kuhle amalungelo wobuntu nokulingana igalelo lakhe lavula indlela ennzukulwaneni ezizako nakibosopolitikki okufaka hlangana no-Nelson Mandela owakha naye ubudlelwane obuseduze.

== Iinkomba ==</text>
      <sha1>t594y1iryffqcrzwnv9ynubx2uzatz3</sha1>
    </revision>
    <revision>
      <id>6041</id>
      <parentid>6040</parentid>
      <timestamp>2025-11-27T06:59:26Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>6041</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2142" sha1="bkxc0n79crh2vn0ewddtznz4kncs9zd" xml:space="preserve">[[Isimumathi:HelenSuzman.jpg|thumb|Helen Suzman]]
'''Helen Suzman''' wabelethwa mhlana amalanga ali 17-Nobayeni ngo- 1917 endaweni Germiston Esewula afrika .&lt;ref&gt;https://sahistory.org.za/people/helen-suzman&lt;/ref&gt;Wakhulela emndenini wamajuda aphakathi nendawo . Ipilo yakhe yokuthoma iphawulwa ukuveza kokungabi nobulungiswa emphakathini bona agqine sele anekareko kweze polotiki .Waragela phambili nemfundo zakhe eyunivesithi ye-witwatersrand ,lapho aphetha khona iziqu zeembalo nomnotho. 

Ukungena kweze polotiki kwasuzman kwathomangomnyakA yab-1950 isikhathi lapho isewula africa beyiqinisa khona imithetho imithetho yebandlululo wajoyina I -united party kodwana msinyana waphelelwa yithemba ngobunjalo bayo endabeni sobuhlanga. Ngo -1953 wasunguza I liberal progressive party nabanye abasekeli ,okufaka hlangana u-colin eglin no-Harry Oppenheimer. uHelen Suzman waba ngomunye wama lunga wepalamende Wokuthoma kwehlangano ngo-1953 isifunda -houngton e-johhanesburg.

Kwaphela iminyaka eli-13 bekayilunga lepalamende ye progressive party asebenzisa iplatfomu yakhe ukwenza ukuphikisa nebandlululo loklwela amalungelo wobuntu. Iinkulumo zakhe zitjengisa ukuthi unesbindi begodu   nokungenelela kwakhe epalamende kamdosela amehlo weentjhabatjhaba, okwenza bona abe mumuntu owaziwako emsikinyekweni wokulwisana nebandlululo.&lt;ref&gt;Nel, C., 2013. ''The life of Helen Suzman: A psychobiographical study'' (Doctoral dissertation, University of the Free State).&lt;/ref&gt;

Intjhijilo nelifa kiwo woke umsebenzi wakhe uSuzman waqalana nokuhlukunyezwa, ukuthuselwa, nokuthathelwa phasi ngurhulumende. Waqundelwa amakhambo begodu wathathelwa nephasipoti yakhe .Nanyana bekanentjhijilo lezi wahlala aqinile wathola ebantwini alingana nabo nebantwini abalwela ubulungiswa bezehlala kuhle amalungelo wobuntu nokulingana igalelo lakhe lavula indlela ennzukulwaneni ezizako nakibosopolitikki okufaka hlangana no-Nelson Mandela owakha naye ubudlelwane obuseduze.

== Iinkomba ==
[[Category: Umlando wabantu bengubo kwezepolitiki]]
[[Category:Umlando wakade wezepolitiki]]
[[Category: Inkutani ezalwisana nombuso wegandelelo]]
[[Category:umlando weSewula Afrika]]</text>
      <sha1>bkxc0n79crh2vn0ewddtznz4kncs9zd</sha1>
    </revision>
    <revision>
      <id>6042</id>
      <parentid>6041</parentid>
      <timestamp>2025-11-27T07:03:11Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6042</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2386" sha1="oyrrf65etgcw8rss7z7lktrmget46s6" xml:space="preserve">[[Isimumathi:HelenSuzman.jpg|thumb|Helen Suzman]]
'''Helen Suzman''' wabelethwa mhlana amalanga ali 17-Nobayeni ngo- 1917 endaweni Germiston Esewula afrika .&lt;ref&gt;https://sahistory.org.za/people/helen-suzman&lt;/ref&gt;Wakhulela emndenini wamajuda aphakathi nendawo . Ipilo yakhe yokuthoma iphawulwa ukuveza kokungabi nobulungiswa emphakathini bona agqine sele anekareko kweze polotiki .Waragela phambili nemfundo zakhe eyunivesithi ye-witwatersrand ,lapho aphetha khona iziqu zeembalo nomnotho. 

Ukungena kweze polotiki kwasuzman kwathomangomnyakA yab-1950 isikhathi lapho isewula africa beyiqinisa khona imithetho imithetho yebandlululo wajoyina I -united party kodwana msinyana waphelelwa yithemba ngobunjalo bayo endabeni sobuhlanga.&lt;ref&gt;https://www.nytimes.com/1981/09/10/world/apartheid-s-die-Hard-for-fights-on-against-odds.html?searchResultPosition=58&lt;/ref&gt; Ngo -1953 wasunguza I liberal progressive party nabanye abasekeli ,okufaka hlangana u-colin eglin no-Harry Oppenheimer. uHelen Suzman waba ngomunye wama lunga wepalamende Wokuthoma kwehlangano ngo-1953 isifunda -houngton e-johhanesburg.

Kwaphela iminyaka eli-13 bekayilunga lepalamende ye progressive party asebenzisa iplatfomu yakhe ukwenza ukuphikisa nebandlululo loklwela amalungelo wobuntu. Iinkulumo zakhe zitjengisa ukuthi unesbindi begodu   nokungenelela kwakhe epalamende kamdosela amehlo weentjhabatjhaba, okwenza bona abe mumuntu owaziwako emsikinyekweni wokulwisana nebandlululo.&lt;ref&gt;Nel, C., 2013. ''The life of Helen Suzman: A psychobiographical study'' (Doctoral dissertation, University of the Free State).&lt;/ref&gt;

Intjhijilo nelifa kiwo woke umsebenzi wakhe uSuzman waqalana nokuhlukunyezwa, ukuthuselwa, nokuthathelwa phasi ngurhulumende. Waqundelwa amakhambo begodu wathathelwa nephasipoti yakhe .Nanyana bekanentjhijilo lezi wahlala aqinile wathola ebantwini alingana nabo nebantwini abalwela ubulungiswa bezehlala kuhle amalungelo wobuntu nokulingana igalelo lakhe lavula indlela ennzukulwaneni ezizako nakibosopolitikki okufaka hlangana no-Nelson Mandela owakha naye ubudlelwane obuseduze.&lt;ref&gt;https://www.theguardian.com/commentisfree/2014/mar/06/helen-suzman-mandela-forgotten-saint-anti-apartheid&lt;/ref&gt;

== Iinkomba ==
[[Category: Umlando wabantu bengubo kwezepolitiki]]
[[Category:Umlando wakade wezepolitiki]]
[[Category: Inkutani ezalwisana nombuso wegandelelo]]
[[Category:umlando weSewula Afrika]]</text>
      <sha1>oyrrf65etgcw8rss7z7lktrmget46s6</sha1>
    </revision>
    <revision>
      <id>6043</id>
      <parentid>6042</parentid>
      <timestamp>2025-11-27T07:28:52Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6043</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3222" sha1="asiwotrxgr3nneesxgjie9kf10aimb4" xml:space="preserve">[[Isimumathi:HelenSuzman.jpg|thumb|Helen Suzman]]
'''Helen Suzman''' wabelethwa mhlana amalanga ali 17-Nobayeni ngo- 1917 endaweni Germiston Esewula afrika .&lt;ref&gt;https://sahistory.org.za/people/helen-suzman&lt;/ref&gt;Wakhulela emndenini wamajuda aphakathi nendawo . Ipilo yakhe yokuthoma iphawulwa ukuveza kokungabi nobulungiswa emphakathini bona agqine sele anekareko kweze polotiki .Waragela phambili nemfundo zakhe eyunivesithi ye-witwatersrand ,lapho aphetha khona iziqu zeembalo nomnotho. 

=== ukuthoma kwakhe ukusebenza kwezepolitiki ===
Ukungena kweze polotiki kwasuzman kwathomangomnyakA yab-1950 isikhathi lapho isewula africa beyiqinisa khona imithetho imithetho yebandlululo wajoyina I -united party kodwana msinyana waphelelwa yithemba ngobunjalo bayo endabeni sobuhlanga.&lt;ref&gt;https://www.nytimes.com/1981/09/10/world/apartheid-s-die-Hard-for-fights-on-against-odds.html?searchResultPosition=58&lt;/ref&gt; Ngo -1953 wasunguza I liberal progressive party nabanye abasekeli ,okufaka hlangana u-colin eglin no-Harry Oppenheimer. uHelen Suzman waba ngomunye wama lunga wepalamende Wokuthoma kwehlangano ngo-1953 isifunda -houngton e-johhanesburg.

Kwaphela iminyaka eli-13 bekayilunga lepalamende ye progressive party asebenzisa iplatfomu yakhe ukwenza ukuphikisa nebandlululo loklwela amalungelo wobuntu. Iinkulumo zakhe zitjengisa ukuthi unesbindi begodu   nokungenelela kwakhe epalamende kamdosela amehlo weentjhabatjhaba, okwenza bona abe mumuntu owaziwako emsikinyekweni wokulwisana nebandlululo.&lt;ref&gt;Nel, C., 2013. ''The life of Helen Suzman: A psychobiographical study'' (Doctoral dissertation, University of the Free State).&lt;/ref&gt; wayedlala indima ekulu ekuthuthukiseni ubujamo bejele bama lunga we-African National Congress ebegade abanjiwe. Okufaka hlangana u-Nelson Mandela nanyana gade angabaza ngemigomo kaMandela yokuvukela umbuso.

=== Iiintjhijilo adlule kizo ===
Intjhijilo nelifa kiwo woke umsebenzi wakhe uSuzman waqalana nokuhlukunyezwa, ukuthuselwa, nokuthathelwa phasi ngurhulumende. Waqundelwa amakhambo begodu wathathelwa nephasipoti yakhe .Nanyana bekanentjhijilo lezi wahlala aqinile wathola ebantwini alingana nabo nebantwini abalwela ubulungiswa bezehlala kuhle amalungelo wobuntu nokulingana igalelo lakhe lavula indlela ennzukulwaneni ezizako nakibosopolitikki okufaka hlangana no-Nelson Mandela owakha naye ubudlelwane obuseduze.&lt;ref&gt;https://www.theguardian.com/commentisfree/2014/mar/06/helen-suzman-mandela-forgotten-saint-anti-apartheid&lt;/ref&gt;

=== Ukungcwatjwa kwakhe ===
Umma u-Suzman wahlongakala ngokuhlongakala kwemvelo ngesikhathi ameminyaka ema-91 ubudala. wahlongakala ngenyanga kaTjhirhweni ngonyaka we-2009. U-Achmat dango wathi nakafakaza ngaye wathi &quot; Bekalithanda izwe lakhe begodu amumuntu ongasabiko ukulwela amalaungel wakhe nokulwisana nombuso webandlulo&quot;. wangcwatjwa emnyanyeni ofihliweko wamaJuda e west park cemetry eJohannesburg, Kwabe kudosa phambili umfundisi omkhulu u-Warren Goldstein.&lt;ref&gt;https://www.jpost.com/international/suzman-buried-in-jewish-ceremony&lt;/ref&gt;

== Iinkomba ==
[[Category: Umlando wabantu bengubo kwezepolitiki]]
[[Category:Umlando wakade wezepolitiki]]
[[Category: Inkutani ezalwisana nombuso wegandelelo]]
[[Category:umlando weSewula Afrika]]</text>
      <sha1>asiwotrxgr3nneesxgjie9kf10aimb4</sha1>
    </revision>
    <revision>
      <id>6044</id>
      <parentid>6043</parentid>
      <timestamp>2025-11-27T07:30:46Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6044</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3242" sha1="r4i491xujyzwwbgc5w0dy9ym6bgrbf4" xml:space="preserve">[[Isimumathi:HelenSuzman.jpg|thumb|Helen Suzman]]
'''Helen Suzman''' wabelethwa mhlana amalanga ali 17-Nobayeni ngo- 1917 endaweni Germiston Esewula afrika .&lt;ref&gt;https://sahistory.org.za/people/helen-suzman&lt;/ref&gt;Wakhulela emndenini wamajuda aphakathi nendawo . Ipilo yakhe yokuthoma iphawulwa ukuveza kokungabi nobulungiswa emphakathini bona agqine sele anekareko kweze polotiki .Waragela phambili nemfundo zakhe eyunivesithi ye-witwatersrand ,lapho aphetha khona iziqu zeembalo nomnotho. 

=== ukuthoma kwakhe ukusebenza kwezepolitiki ===
Ukungena kweze polotiki kwasuzman kwathomangomnyakA yab-1950 isikhathi lapho isewula africa beyiqinisa khona imithetho imithetho yebandlululo wajoyina I -united party kodwana msinyana waphelelwa yithemba ngobunjalo bayo endabeni sobuhlanga.&lt;ref&gt;https://www.nytimes.com/1981/09/10/world/apartheid-s-die-Hard-for-fights-on-against-odds.html?searchResultPosition=58&lt;/ref&gt; Ngo -1953 wasunguza I liberal progressive party nabanye abasekeli ,okufaka hlangana u-colin eglin no-Harry Oppenheimer. uHelen Suzman waba ngomunye wama lunga wepalamende Wokuthoma kwehlangano ngo-1953 isifunda -houngton e-johhanesburg.

Kwaphela iminyaka eli-13 bekayilunga lepalamende ye progressive party asebenzisa iplatfomu yakhe ukwenza ukuphikisa nebandlululo loklwela amalungelo wobuntu. Iinkulumo zakhe zitjengisa ukuthi unesbindi begodu   nokungenelela kwakhe epalamende kamdosela amehlo weentjhabatjhaba, okwenza bona abe mumuntu owaziwako emsikinyekweni wokulwisana nebandlululo.&lt;ref&gt;Nel, C., 2013. ''The life of Helen Suzman: A psychobiographical study'' (Doctoral dissertation, University of the Free State).&lt;/ref&gt; Wayedlala indima ekulu ekuthuthukiseni ubujamo bejele bama lunga we-African National Congress ebegade abanjiwe. Okufaka hlangana u-Nelson Mandela nanyana gade angabaza ngemigomo kaMandela yokuvukela [[umbuso wegandelelo]].

=== Iiintjhijilo adlule kizo ===
Intjhijilo nelifa kiwo woke umsebenzi wakhe uSuzman waqalana nokuhlukunyezwa, ukuthuselwa, nokuthathelwa phasi ngurhulumende. Waqundelwa amakhambo begodu wathathelwa nephasipoti yakhe .Nanyana bekanentjhijilo lezi wahlala aqinile wathola ebantwini alingana nabo nebantwini abalwela ubulungiswa bezehlala kuhle amalungelo wobuntu nokulingana igalelo lakhe lavula indlela ennzukulwaneni ezizako nakibosopolitikki okufaka hlangana no-[[Nelson Mandela]] owakha naye ubudlelwane obuseduze.&lt;ref&gt;https://www.theguardian.com/commentisfree/2014/mar/06/helen-suzman-mandela-forgotten-saint-anti-apartheid&lt;/ref&gt;

=== Ukungcwatjwa kwakhe ===
Umma u-Suzman wahlongakala ngokuhlongakala kwemvelo ngesikhathi ameminyaka ema-91 ubudala. wahlongakala ngenyanga kaTjhirhweni ngonyaka we-2009. U-Achmat dango wathi nakafakaza ngaye wathi &quot; Bekalithanda izwe lakhe begodu amumuntu ongasabiko ukulwela amalaungel wakhe nokulwisana nombuso webandlulo&quot;. wangcwatjwa emnyanyeni ofihliweko wamaJuda e west park cemetry eJohannesburg, Kwabe kudosa phambili umfundisi omkhulu u-Warren Goldstein.&lt;ref&gt;https://www.jpost.com/international/suzman-buried-in-jewish-ceremony&lt;/ref&gt;

== Iinkomba ==
[[Category: Umlando wabantu bengubo kwezepolitiki]]
[[Category:Umlando wakade wezepolitiki]]
[[Category: Inkutani ezalwisana nombuso wegandelelo]]
[[Category:umlando weSewula Afrika]]</text>
      <sha1>r4i491xujyzwwbgc5w0dy9ym6bgrbf4</sha1>
    </revision>
    <revision>
      <id>6045</id>
      <parentid>6044</parentid>
      <timestamp>2025-11-27T07:36:37Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6045</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3334" sha1="9wpd7dksb87dlnr0gm9wz8m6yyxysb6" xml:space="preserve">[[Isimumathi:HelenSuzman.jpg|thumb|Helen Suzman]]
'''Helen Suzman''' wabelethwa mhlana amalanga ali 17-Nobayeni ngo- 1917 endaweni Germiston Esewula afrika .&lt;ref&gt;https://sahistory.org.za/people/helen-suzman&lt;/ref&gt;Wabelthwa ngu Frieda no Samule Gavronsky.Unina wahlongakala kungasikudala aceda ukumbeletha.Wakhulela emndenini wamajuda aphakathi nendawo . Ipilo yakhe yokuthoma iphawulwa ukuveza kokungabi nobulungiswa emphakathini bona agqine sele anekareko kweze polotiki .Waragela phambili nemfundo zakhe eyunivesithi ye-witwatersrand ,lapho aphetha khona iziqu zeembalo nomnotho. 

=== ukuthoma kwakhe ukusebenza kwezepolitiki ===
Ukungena kweze polotiki kwasuzman kwathomangomnyakA yab-1950 isikhathi lapho isewula africa beyiqinisa khona imithetho imithetho yebandlululo wajoyina I -united party kodwana msinyana waphelelwa yithemba ngobunjalo bayo endabeni sobuhlanga.&lt;ref&gt;https://www.nytimes.com/1981/09/10/world/apartheid-s-die-Hard-for-fights-on-against-odds.html?searchResultPosition=58&lt;/ref&gt; Ngo -1953 wasunguza I liberal progressive party nabanye abasekeli ,okufaka hlangana u-colin eglin no-Harry Oppenheimer. uHelen Suzman waba ngomunye wama lunga wepalamende Wokuthoma kwehlangano ngo-1953 isifunda -houngton e-Johhanesburg.

Kwaphela iminyaka eli-13 bekayilunga lepalamende ye progressive party asebenzisa iplatfomu yakhe ukwenza ukuphikisa nebandlululo loklwela amalungelo wobuntu. Iinkulumo zakhe zitjengisa ukuthi unesbindi begodu   nokungenelela kwakhe epalamende kamdosela amehlo weentjhabatjhaba, okwenza bona abe mumuntu owaziwako emsikinyekweni wokulwisana nebandlululo.&lt;ref&gt;Nel, C., 2013. ''The life of Helen Suzman: A psychobiographical study'' (Doctoral dissertation, University of the Free State).&lt;/ref&gt; Wayedlala indima ekulu ekuthuthukiseni ubujamo bejele bama lunga we-African National Congress ebegade abanjiwe. Okufaka hlangana u-Nelson Mandela nanyana gade angabaza ngemigomo kaMandela yokuvukela [[umbuso wegandelelo]].

=== Iiintjhijilo adlule kizo ===
Intjhijilo nelifa kiwo woke umsebenzi wakhe uSuzman waqalana nokuhlukunyezwa, ukuthuselwa, nokuthathelwa phasi ngurhulumende. Waqundelwa amakhambo begodu wathathelwa nephasipoti yakhe .Nanyana bekanentjhijilo lezi wahlala aqinile wathola ebantwini alingana nabo nebantwini abalwela ubulungiswa bezehlala kuhle amalungelo wobuntu nokulingana igalelo lakhe lavula indlela ennzukulwaneni ezizako nakibosopolitikki okufaka hlangana no-[[Nelson Mandela]] owakha naye ubudlelwane obuseduze.&lt;ref&gt;https://www.theguardian.com/commentisfree/2014/mar/06/helen-suzman-mandela-forgotten-saint-anti-apartheid&lt;/ref&gt;

=== Ukungcwatjwa kwakhe ===
Umma u-Suzman wahlongakala ngokuhlongakala kwemvelo ngesikhathi ameminyaka ema-91 ubudala. wahlongakala ngenyanga kaTjhirhweni ngonyaka we-2009. U-Achmat dango wathi nakafakaza ngaye wathi &quot; Bekalithanda izwe lakhe begodu amumuntu ongasabiko ukulwela amalaungel wakhe nokulwisana nombuso webandlulo&quot;. wangcwatjwa emnyanyeni ofihliweko wamaJuda e west park cemetry eJohannesburg, Kwabe kudosa phambili umfundisi omkhulu u-Warren Goldstein.&lt;ref&gt;https://www.jpost.com/international/suzman-buried-in-jewish-ceremony&lt;/ref&gt;

== Iinkomba ==
[[Category: Umlando wabantu bengubo kwezepolitiki]]
[[Category:Umlando wakade wezepolitiki]]
[[Category: Inkutani ezalwisana nombuso wegandelelo]]
[[Category:umlando weSewula Afrika]]</text>
      <sha1>9wpd7dksb87dlnr0gm9wz8m6yyxysb6</sha1>
    </revision>
  </page>
  <page>
    <title>Umbuso webandlululo</title>
    <ns>0</ns>
    <id>1007</id>
    <revision>
      <id>6046</id>
      <timestamp>2025-11-29T11:29:56Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''Igama elithi &quot;Ibandlululo&quot;''' tjhugululwe ukusuka elimini lesibhuru okutjho 'ukuhlukana', ibandlululo bekuyimbono eyasekelwa ngurhulumende we-National Party (NP) begodu yathonywa eSewula Afrika ngo-1948.&lt;ref&gt;https://sahistory.org.za/article/history-apartheid-south-africa&lt;/ref&gt; Ibandlululo labawa ukuthuthukiswa okuhlukileko kwamakoro weentjhaba ezihlukahlukeneko eSewula Afrika. Ephepheni bekubonakala ngasuthi kufuna ukuthuthukiswa okulinganako nekululeko yokuveza amasi...&quot;</comment>
      <origin>6046</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7820" sha1="dfx43zpsy32qko4gyxzyoaof1obrjmt" xml:space="preserve">'''Igama elithi &quot;Ibandlululo&quot;''' tjhugululwe ukusuka elimini lesibhuru okutjho 'ukuhlukana', ibandlululo bekuyimbono eyasekelwa ngurhulumende we-National Party (NP) begodu yathonywa eSewula Afrika ngo-1948.&lt;ref&gt;https://sahistory.org.za/article/history-apartheid-south-africa&lt;/ref&gt; Ibandlululo labawa ukuthuthukiswa okuhlukileko kwamakoro weentjhaba ezihlukahlukeneko eSewula Afrika. Ephepheni bekubonakala ngasuthi kufuna ukuthuthukiswa okulinganako nekululeko yokuveza amasiko, kodwana indlela ebegade isetjenziswa ngayo yenza bona lokhu kungakghonakali. Imithetho yobandlululo yenza ikatelela iintjhaba ezihlukahlukeneko bona zihlale ngokwehlukana begodu zithuthuke ngokwehlukana, begodu ngokungalingani khulu. Ilinge ukuqeda woke umtjhado nokuhlanganiswa komphakathi hlangana namakoro wobuhlanga. Ngesikhathi sebandlululo, ukuba nobungani nomuntu wobuhlanga obuhlukileko bekuletha iinsolo kuwe, nofana okumbi khulu. Ngaphezu kwalokhu, ibandlululo bekulihlelo lezenhlalakahle ebelihlukumeza khulu inengi labantu, ngombana bebangafani umbala wesikhumba wababusi. Abanengi bebagcinwa ngaphezu kokutlhaga ngombana 'bebangasibo abamhlophe'.

Ngokweenkambisolawulo ezisisekelo, ibandlululo belingafani kangako emthethweni wokuhlukanisa urhulumende weSewula Afrika owawukhona ngaphambi kokuthi i-Afrikaner Nationalist Party ifike emandleni ngo-1948. Umehluko omkhulu kukobana ibandlululo lenze ihlukaniso libe yingcenye yomthetho. Ibandlululo lahlukanisa abantu ngesihlungu nangokugandelela, begodu linehlelo lombuso elithusako lokujezisa labo abangavumelani. Esinye isizathu sokuthi kubayini ibandlululo belibonwa njengelibi khulu ukudlula ukuhlukaniswa, kukuthi ibandlululo lathonywa ngesikhathi lapho amanye amazwe bekatjhiya khona imigomo yobandlululo. Ngaphambi kwePi yesiBili yePhasi inarha yeTjingalanga beyingagxeki kangako ukubandlululwa ngokobuhlanga, begodu i-Afrika beyikoloni ngalesi sikhathi. Ipi yesiBili yePhasi yaveza imiraro yokubandlulula ngokobuhlanga, yenza bona umhlaba ufulathele imigomo enjalo begodu wakhuthaza iimfuno zokususwa kwamakoloni. Kungesikhathi lesi lapho iSewula Afrika yethula khona umthethomgomo oqinileko wobandlululo.

Abantu bavame ukuzibuza bona kubayini umthethomgomo onjalo wethulwe begodu kubayini wasekelwa kangaka. Iinzathu ezihlukahlukeneko zingavezwa ngebandlululo, nanyana zoke zihlobene khulu. Iinzathu ezikulu zilele emibonweni yokuphakama ngokobuhlanga nokwesaba. Ephasini loke, ukubandlululwa ngokobuhlanga kuthonywa mqondo wokobana omunye umhlobo kufuze ube ngaphezu komunye. Imibono enjalo itholakala kiwo woke amaqembu wabantu. Esinye isizathu esikhulu sebandlululo bekukwesaba, njengombana eSewula Afrika abantu abamhlophe bambalwa, begodu inengi belikhathazekile ngokuthi lingalahlekelwa misebenzi, amasiko nelimi. Lokhu akusiso isizathu sebandlululo, kodwana kuhlathulula bona abantu bebacabanga njani.

=== Imithetho yebandlululo ===
Kwaphasiswa imithetho eminengi ekubunjweni kombuso webandlululo. Nanzi iinsika ezimbalwa ebegade zijame kizo: UmThetho wokuTloliswa kwabantu, 1950 UmThetho lo bewufuna bona abantu batloliswe ngokuya ngokobuhlanga babo. Lokhu kutjho bona umNyango wezeKhaya bewuzokuba nerekhodi labantu ngokuya ngokuthi bamhlophe, banemibala, bamnyama, bama-India nofana bama-Asia. Abantu bebazokuphathwa ngendlela ehlukileko ngokuya ngesiqhema sabo, begodu umthetho lo waba sisekelo sebandlululo.&lt;ref&gt;Govender, N. and Reddy, P.S., 2019. Urban regeneration in South Africa-the apartheid legacy and legislative framework re-examined–the case of eThekweni Municipality. ''African Journal of Public Affairs'', ''11''(2), pp.83-102.&lt;/ref&gt; Kodwana bekungasi lula ngaso soke isikhathi ukuqunta bona umuntu uyingcenye yabaphi ubuhlanga, begodu lokhu kwabanga imiraro.

UmThetho weeNdawo weenqhema, 1950 Lo bekumthetho owathoma ukuhlukana hlangana kweentjhaba, khulukhulu eendaweni ezisemadorobheni. Umthetho lo godu ufuna ukususwa kwezinye iinqhema zabantu ziye eendaweni ezibekelwe amaqembu wabo wobuhlanga.UmThetho wokuThuthukiswa kokuZiBusa kwamaBantu, we-1959 UmThetho lo bewuthi iintjhaba ezihlukahlukeneko kufuze zihlale eendaweni ezihlukahlukeneko. Kwasala iphesenteji encani yeSewula Afrika bona abantu abanzima (ebebayinengi labo) bakhe 'amazwe wabo'. Umthetho lo godu wasusa 'amabala amnyama' ngaphakathi kweendawo zabantu abamhlophe, ngokususa boke abantu abamnyama ngaphandle kwedorobha. Ukususwa okwaziwako bekuku-District 6, i-Sophiatown kanye ne-Lady Selborne. Abantu abamnyama laba babe sebefakwa emalokishini angaphandle kwedorobha. Bebangakghoni ukuba nepahla lapha, bayiqatjha kwaphela, ngombana inarha beyingaba ngeyabantu abamhlophe kwaphela. Umthetho lo wabanga ubudisi obukhulu nokucasuka. Abantu balahlekelwa makhaya wabo, basuswa eendaweni ebegade banazo iminyaka eminengi begodu bathuthelwa eendaweni ezingakathuthukiswa kude nendawo abasebenza kiyo.

=== Eminye imithetho eqakathekileko bekuyi: ===
UmThetho wokuVimbela imitjhado ehlangeneko, 1949

UmThetho wokuTjhugulula ukuZiphatha kumbi, 1950

UmThetho wokuJanyelwa okuhlukileko kwabavowudi, 1951

Ukujamelana ngaphambi kwaka-1960

Ukujamelana nebandlululo kwavela kiyo yoke imikhakha, begodu ingasi kwaphela, njengombana kuvame ukucatshangelwa, kilabo abahlangabezana nemiphumela emimbi yokubandlululwa. Ukuhlatjwa kwavela nakwamanye amazwe, begodu amanye wawo anikela isekelo leenhlangano zekululeko zeSewula Afrika.

Ezinye zeenhlangano eziqakatheke khulu ezibandakanyeka emzabalazweni wekululeko bekuyi-African National Congress (ANC), i-Pan-Africanist Congress (PAC), i-Inkatha Freedom Party (IFP), i-Black Consciousness Movement (BCM) kanye ne-United Democratic Front (UDF). Bekunama-India nama-Colored (isib. i-Natal Indian Congress (NIC), i-Colored People's Organisation), amaqembu wabantu abamhlophe (isib. i-Armed Resistance Movement (ARM), kanye ne-Black Sash) kanye namaqembu asekelwe esontweni (i-Christian Institute). Sizokucabangela i-ANC.

I-ANC

I-ANC yabunjwa e-Bloemfontein ngo-1912, msinyana ngemva kwe-Union of South Africa. Ekuthomeni beyibizwa nge-South African Native National Congress (i-SANNC). Kwathonywa njengomkhankaso wabantu abaNzima abaphezulu, okutjho labo abaNzima ebebafundile. Ngo-1919, i-ANC yathumela isithunywa e-London ukuyokuncenga isivumelwano esitjha sabantu abamnyama beSewula Afrika, kodwana azange kube netjhuguluko ebujameni babo.

Isithunywa se-South African Native National Congress e-England, ngoMgwengweni 1919 Umthombo wesithombe

Umlando wokujamelana kwe-ANC udlula eengabeni ezintathu. Eyokuthoma bekukukhulumisana nokufaka isibawo; ukuphikiswa kwesibili okunqophileko begodu kokugcina kube yisikhathi somzabalazo ohlomileko. Ngomnyaka ka-1949, ngemva nje kokuthi kwethulwe ibandlululo, i-ANC yathoma indlela yokulwa, lapho i-Youth League idlala indima eqakathekileko. I-ANC yethula iHlelo layo lokuSebenza ngo-1949, isekela isenzo sokuteleka, ukutjhikiyela nezinye iinhlobo zokujamelana okungasikho kobudlova. U-Nelson Mandela, u-Oliver Tambo no-Walter Sisulu bathoma ukudlala indima eqakathekileko ku-ANC ngesikhathesi. Ngo-1952 i-ANC yathoma umKhankaso wokuTjhiya. Ijima leli belibiza abantu bona baphule imithetho yebandlululo ngamabomu begodu bazinikele bona babotjhwe. Bekuthenjwa bona ukwanda kwezibotjhwa kuzokwenza bona ihlelo libhidlike begodu lithole isekelo leentjhabatjhaba le-ANC. Abantu abanzima bangena 'emabhasini amhlophe', basebenzisa 'amathoyilethi amhlophe', bangena 'eendaweni zabamhlophe' begodu bala ukusebenzisa amaphasi. Nanyana abantu abayi-8 000 bagcina bavalelwe ejele, i-ANC azange ibe yingozi embusweni webandlululo.

I-ANC yaragela phambili ngendlela efanako hlangana neminyaka yabo-1950, bekwaba kulapho ngo-1959 amanye amalunga ahlukana khona akha i-PAC. Amalunga la bekafuna ukulandela indlela enobudlova neyepi, begodu abona ngasuthi ipumelelo angeze yafinyelelwa ngendlela ye-ANC</text>
      <sha1>dfx43zpsy32qko4gyxzyoaof1obrjmt</sha1>
    </revision>
    <revision>
      <id>6047</id>
      <parentid>6046</parentid>
      <timestamp>2025-11-29T11:30:57Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>6047</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7836" sha1="k6duwoka5e0wohevh61fwgghve2te4s" xml:space="preserve">'''Igama elithi &quot;Ibandlululo&quot;''' tjhugululwe ukusuka elimini lesibhuru okutjho 'ukuhlukana', ibandlululo bekuyimbono eyasekelwa ngurhulumende we-National Party (NP) begodu yathonywa eSewula Afrika ngo-1948.&lt;ref&gt;https://sahistory.org.za/article/history-apartheid-south-africa&lt;/ref&gt; Ibandlululo labawa ukuthuthukiswa okuhlukileko kwamakoro weentjhaba ezihlukahlukeneko eSewula Afrika. Ephepheni bekubonakala ngasuthi kufuna ukuthuthukiswa okulinganako nekululeko yokuveza amasiko, kodwana indlela ebegade isetjenziswa ngayo yenza bona lokhu kungakghonakali. Imithetho yobandlululo yenza ikatelela iintjhaba ezihlukahlukeneko bona zihlale ngokwehlukana begodu zithuthuke ngokwehlukana, begodu ngokungalingani khulu. Ilinge ukuqeda woke umtjhado nokuhlanganiswa komphakathi hlangana namakoro wobuhlanga. Ngesikhathi sebandlululo, ukuba nobungani nomuntu wobuhlanga obuhlukileko bekuletha iinsolo kuwe, nofana okumbi khulu. Ngaphezu kwalokhu, ibandlululo bekulihlelo lezenhlalakahle ebelihlukumeza khulu inengi labantu, ngombana bebangafani umbala wesikhumba wababusi. Abanengi bebagcinwa ngaphezu kokutlhaga ngombana 'bebangasibo abamhlophe'.

Ngokweenkambisolawulo ezisisekelo, ibandlululo belingafani kangako emthethweni wokuhlukanisa urhulumende weSewula Afrika owawukhona ngaphambi kokuthi i-Afrikaner Nationalist Party ifike emandleni ngo-1948. Umehluko omkhulu kukobana ibandlululo lenze ihlukaniso libe yingcenye yomthetho. Ibandlululo lahlukanisa abantu ngesihlungu nangokugandelela, begodu linehlelo lombuso elithusako lokujezisa labo abangavumelani. Esinye isizathu sokuthi kubayini ibandlululo belibonwa njengelibi khulu ukudlula ukuhlukaniswa, kukuthi ibandlululo lathonywa ngesikhathi lapho amanye amazwe bekatjhiya khona imigomo yobandlululo. Ngaphambi kwePi yesiBili yePhasi inarha yeTjingalanga beyingagxeki kangako ukubandlululwa ngokobuhlanga, begodu i-Afrika beyikoloni ngalesi sikhathi. Ipi yesiBili yePhasi yaveza imiraro yokubandlulula ngokobuhlanga, yenza bona umhlaba ufulathele imigomo enjalo begodu wakhuthaza iimfuno zokususwa kwamakoloni. Kungesikhathi lesi lapho iSewula Afrika yethula khona umthethomgomo oqinileko wobandlululo.

Abantu bavame ukuzibuza bona kubayini umthethomgomo onjalo wethulwe begodu kubayini wasekelwa kangaka. Iinzathu ezihlukahlukeneko zingavezwa ngebandlululo, nanyana zoke zihlobene khulu. Iinzathu ezikulu zilele emibonweni yokuphakama ngokobuhlanga nokwesaba. Ephasini loke, ukubandlululwa ngokobuhlanga kuthonywa mqondo wokobana omunye umhlobo kufuze ube ngaphezu komunye. Imibono enjalo itholakala kiwo woke amaqembu wabantu. Esinye isizathu esikhulu sebandlululo bekukwesaba, njengombana eSewula Afrika abantu abamhlophe bambalwa, begodu inengi belikhathazekile ngokuthi lingalahlekelwa misebenzi, amasiko nelimi. Lokhu akusiso isizathu sebandlululo, kodwana kuhlathulula bona abantu bebacabanga njani.

=== Imithetho yebandlululo ===
Kwaphasiswa imithetho eminengi ekubunjweni kombuso webandlululo. Nanzi iinsika ezimbalwa ebegade zijame kizo: UmThetho wokuTloliswa kwabantu, 1950 UmThetho lo bewufuna bona abantu batloliswe ngokuya ngokobuhlanga babo. Lokhu kutjho bona umNyango wezeKhaya bewuzokuba nerekhodi labantu ngokuya ngokuthi bamhlophe, banemibala, bamnyama, bama-India nofana bama-Asia. Abantu bebazokuphathwa ngendlela ehlukileko ngokuya ngesiqhema sabo, begodu umthetho lo waba sisekelo sebandlululo.&lt;ref&gt;Govender, N. and Reddy, P.S., 2019. Urban regeneration in South Africa-the apartheid legacy and legislative framework re-examined–the case of eThekweni Municipality. ''African Journal of Public Affairs'', ''11''(2), pp.83-102.&lt;/ref&gt; Kodwana bekungasi lula ngaso soke isikhathi ukuqunta bona umuntu uyingcenye yabaphi ubuhlanga, begodu lokhu kwabanga imiraro.

UmThetho weeNdawo weenqhema, 1950 Lo bekumthetho owathoma ukuhlukana hlangana kweentjhaba, khulukhulu eendaweni ezisemadorobheni. Umthetho lo godu ufuna ukususwa kwezinye iinqhema zabantu ziye eendaweni ezibekelwe amaqembu wabo wobuhlanga.UmThetho wokuThuthukiswa kokuZiBusa kwamaBantu, we-1959 UmThetho lo bewuthi iintjhaba ezihlukahlukeneko kufuze zihlale eendaweni ezihlukahlukeneko. Kwasala iphesenteji encani yeSewula Afrika bona abantu abanzima (ebebayinengi labo) bakhe 'amazwe wabo'. Umthetho lo godu wasusa 'amabala amnyama' ngaphakathi kweendawo zabantu abamhlophe, ngokususa boke abantu abamnyama ngaphandle kwedorobha. Ukususwa okwaziwako bekuku-District 6, i-Sophiatown kanye ne-Lady Selborne. Abantu abamnyama laba babe sebefakwa emalokishini angaphandle kwedorobha. Bebangakghoni ukuba nepahla lapha, bayiqatjha kwaphela, ngombana inarha beyingaba ngeyabantu abamhlophe kwaphela. Umthetho lo wabanga ubudisi obukhulu nokucasuka. Abantu balahlekelwa makhaya wabo, basuswa eendaweni ebegade banazo iminyaka eminengi begodu bathuthelwa eendaweni ezingakathuthukiswa kude nendawo abasebenza kiyo.

=== Eminye imithetho eqakathekileko bekuyi: ===
UmThetho wokuVimbela imitjhado ehlangeneko, 1949

UmThetho wokuTjhugulula ukuZiphatha kumbi, 1950

UmThetho wokuJanyelwa okuhlukileko kwabavowudi, 1951

Ukujamelana ngaphambi kwaka-1960

Ukujamelana nebandlululo kwavela kiyo yoke imikhakha, begodu ingasi kwaphela, njengombana kuvame ukucatshangelwa, kilabo abahlangabezana nemiphumela emimbi yokubandlululwa. Ukuhlatjwa kwavela nakwamanye amazwe, begodu amanye wawo anikela isekelo leenhlangano zekululeko zeSewula Afrika.

Ezinye zeenhlangano eziqakatheke khulu ezibandakanyeka emzabalazweni wekululeko bekuyi-African National Congress (ANC), i-Pan-Africanist Congress (PAC), i-Inkatha Freedom Party (IFP), i-Black Consciousness Movement (BCM) kanye ne-United Democratic Front (UDF). Bekunama-India nama-Colored (isib. i-Natal Indian Congress (NIC), i-Colored People's Organisation), amaqembu wabantu abamhlophe (isib. i-Armed Resistance Movement (ARM), kanye ne-Black Sash) kanye namaqembu asekelwe esontweni (i-Christian Institute). Sizokucabangela i-ANC.

I-ANC

I-ANC yabunjwa e-Bloemfontein ngo-1912, msinyana ngemva kwe-Union of South Africa. Ekuthomeni beyibizwa nge-South African Native National Congress (i-SANNC). Kwathonywa njengomkhankaso wabantu abaNzima abaphezulu, okutjho labo abaNzima ebebafundile. Ngo-1919, i-ANC yathumela isithunywa e-London ukuyokuncenga isivumelwano esitjha sabantu abamnyama beSewula Afrika, kodwana azange kube netjhuguluko ebujameni babo.

Isithunywa se-South African Native National Congress e-England, ngoMgwengweni 1919 Umthombo wesithombe

Umlando wokujamelana kwe-ANC udlula eengabeni ezintathu. Eyokuthoma bekukukhulumisana nokufaka isibawo; ukuphikiswa kwesibili okunqophileko begodu kokugcina kube yisikhathi somzabalazo ohlomileko. Ngomnyaka ka-1949, ngemva nje kokuthi kwethulwe ibandlululo, i-ANC yathoma indlela yokulwa, lapho i-Youth League idlala indima eqakathekileko. I-ANC yethula iHlelo layo lokuSebenza ngo-1949, isekela isenzo sokuteleka, ukutjhikiyela nezinye iinhlobo zokujamelana okungasikho kobudlova. U-Nelson Mandela, u-Oliver Tambo no-Walter Sisulu bathoma ukudlala indima eqakathekileko ku-ANC ngesikhathesi. Ngo-1952 i-ANC yathoma umKhankaso wokuTjhiya. Ijima leli belibiza abantu bona baphule imithetho yebandlululo ngamabomu begodu bazinikele bona babotjhwe. Bekuthenjwa bona ukwanda kwezibotjhwa kuzokwenza bona ihlelo libhidlike begodu lithole isekelo leentjhabatjhaba le-ANC. Abantu abanzima bangena 'emabhasini amhlophe', basebenzisa 'amathoyilethi amhlophe', bangena 'eendaweni zabamhlophe' begodu bala ukusebenzisa amaphasi. Nanyana abantu abayi-8 000 bagcina bavalelwe ejele, i-ANC azange ibe yingozi embusweni webandlululo.

I-ANC yaragela phambili ngendlela efanako hlangana neminyaka yabo-1950, bekwaba kulapho ngo-1959 amanye amalunga ahlukana khona akha i-PAC. Amalunga la bekafuna ukulandela indlela enobudlova neyepi, begodu abona ngasuthi ipumelelo angeze yafinyelelwa ngendlela ye-ANC

== Iinkomba ==</text>
      <sha1>k6duwoka5e0wohevh61fwgghve2te4s</sha1>
    </revision>
    <revision>
      <id>6048</id>
      <parentid>6047</parentid>
      <timestamp>2025-11-29T11:33:06Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6048</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7839" sha1="3jzdfra7k2xp4ussprb33nra7kh636a" xml:space="preserve">'''Igama elithi &quot;Ibandlululo&quot;''' tjhugululwe ukusuka elimini lesibhuru okutjho 'ukuhlukana', ibandlululo bekuyimbono eyasekelwa ngurhulumende we-National Party (NP) begodu yathonywa eSewula Afrika ngo-1948.&lt;ref&gt;https://sahistory.org.za/article/history-apartheid-south-africa&lt;/ref&gt; Ibandlululo labawa ukuthuthukiswa okuhlukileko kwamakoro weentjhaba ezihlukahlukeneko eSewula Afrika. Ephepheni bekubonakala ngasuthi kufuna ukuthuthukiswa okulinganako nekululeko yokuveza amasiko, kodwana indlela ebegade isetjenziswa ngayo yenza bona lokhu kungakghonakali. Imithetho yobandlululo yenza ikatelela iintjhaba ezihlukahlukeneko bona zihlale ngokwehlukana begodu zithuthuke ngokwehlukana, begodu ngokungalingani khulu. Ilinge ukuqeda woke umtjhado nokuhlanganiswa komphakathi hlangana namakoro wobuhlanga. Ngesikhathi sebandlululo, ukuba nobungani nomuntu wobuhlanga obuhlukileko bekuletha iinsolo kuwe, nofana okumbi khulu. Ngaphezu kwalokhu, ibandlululo bekulihlelo lezenhlalakahle ebelihlukumeza khulu inengi labantu, ngombana bebangafani umbala wesikhumba wababusi. Abanengi bebagcinwa ngaphezu kokutlhaga ngombana 'bebangasibo abamhlophe'.

Ngokweenkambisolawulo ezisisekelo, ibandlululo belingafani kangako emthethweni wokuhlukanisa urhulumende weSewula Afrika owawukhona ngaphambi kokuthi i-Afrikaner Nationalist Party ifike emandleni ngo-1948. Umehluko omkhulu kukobana ibandlululo lenze ihlukaniso libe yingcenye yomthetho. Ibandlululo lahlukanisa abantu ngesihlungu nangokugandelela, begodu linehlelo lombuso elithusako lokujezisa labo abangavumelani. Esinye isizathu sokuthi kubayini ibandlululo belibonwa njengelibi khulu ukudlula ukuhlukaniswa, kukuthi ibandlululo lathonywa ngesikhathi lapho amanye amazwe bekatjhiya khona imigomo yobandlululo. Ngaphambi kwePi yesiBili yePhasi inarha yeTjingalanga beyingagxeki kangako ukubandlululwa ngokobuhlanga, begodu i-Afrika beyikoloni ngalesi sikhathi. Ipi yesiBili yePhasi yaveza imiraro yokubandlulula ngokobuhlanga, yenza bona umhlaba ufulathele imigomo enjalo begodu wakhuthaza iimfuno zokususwa kwamakoloni. Kungesikhathi lesi lapho iSewula Afrika yethula khona umthethomgomo oqinileko wobandlululo.

Abantu bavame ukuzibuza bona kubayini umthethomgomo onjalo wethulwe begodu kubayini wasekelwa kangaka. Iinzathu ezihlukahlukeneko zingavezwa ngebandlululo, nanyana zoke zihlobene khulu. Iinzathu ezikulu zilele emibonweni yokuphakama ngokobuhlanga nokwesaba. Ephasini loke, ukubandlululwa ngokobuhlanga kuthonywa mqondo wokobana omunye umhlobo kufuze ube ngaphezu komunye. Imibono enjalo itholakala kiwo woke amaqembu wabantu. Esinye isizathu esikhulu sebandlululo bekukwesaba, njengombana eSewula Afrika abantu abamhlophe bambalwa, begodu inengi belikhathazekile ngokuthi lingalahlekelwa misebenzi, amasiko nelimi. Lokhu akusiso isizathu sebandlululo, kodwana kuhlathulula bona abantu bebacabanga njani.

=== Imithetho yebandlululo ===
Kwaphasiswa imithetho eminengi ekubunjweni kombuso webandlululo. Nanzi iinsika ezimbalwa ebegade zijame kizo: UmThetho wokuTloliswa kwabantu, 1950 UmThetho lo bewufuna bona abantu batloliswe ngokuya ngokobuhlanga babo. Lokhu kutjho bona umNyango wezeKhaya bewuzokuba nerekhodi labantu ngokuya ngokuthi bamhlophe, banemibala, bamnyama, bama-India nofana bama-Asia. Abantu bebazokuphathwa ngendlela ehlukileko ngokuya ngesiqhema sabo, begodu umthetho lo waba sisekelo sebandlululo.&lt;ref&gt;Govender, N. and Reddy, P.S., 2019. Urban regeneration in South Africa-the apartheid legacy and legislative framework re-examined–the case of eThekweni Municipality. ''African Journal of Public Affairs'', ''11''(2), pp.83-102.&lt;/ref&gt; Kodwana bekungasi lula ngaso soke isikhathi ukuqunta bona umuntu uyingcenye yabaphi ubuhlanga, begodu lokhu kwabanga imiraro.

UmThetho weeNdawo weenqhema, 1950 Lo bekumthetho owathoma ukuhlukana hlangana kweentjhaba, khulukhulu eendaweni ezisemadorobheni. Umthetho lo godu ufuna ukususwa kwezinye iinqhema zabantu ziye eendaweni ezibekelwe amaqembu wabo wobuhlanga.UmThetho wokuThuthukiswa kokuZiBusa kwamaBantu, we-1959 UmThetho lo bewuthi iintjhaba ezihlukahlukeneko kufuze zihlale eendaweni ezihlukahlukeneko. Kwasala iphesenteji encani yeSewula Afrika bona abantu abanzima (ebebayinengi labo) bakhe 'amazwe wabo'. Umthetho lo godu wasusa 'amabala amnyama' ngaphakathi kweendawo zabantu abamhlophe, ngokususa boke abantu abamnyama ngaphandle kwedorobha. Ukususwa okwaziwako bekuku-District 6, i-Sophiatown kanye ne-Lady Selborne. Abantu abamnyama laba babe sebefakwa emalokishini angaphandle kwedorobha. Bebangakghoni ukuba nepahla lapha, bayiqatjha kwaphela, ngombana inarha beyingaba ngeyabantu abamhlophe kwaphela. Umthetho lo wabanga ubudisi obukhulu nokusilingeka. Abantu balahlekelwa makhaya wabo, basuswa eendaweni ebegade banazo iminyaka eminengi begodu bathuthelwa eendaweni ezingakathuthukiswa kude nendawo abasebenza kiyo.

=== Eminye imithetho eqakathekileko bekuyi: ===
UmThetho wokuVimbela imitjhado ehlangeneko, 1949

UmThetho wokuTjhugulula ukuZiphatha kumbi, 1950

UmThetho wokuJanyelwa okuhlukileko kwabavowudi, 1951

Ukujamelana ngaphambi kwaka-1960

Ukujamelana nebandlululo kwavela kiyo yoke imikhakha, begodu ingasi kwaphela, njengombana kuvame ukucatshangelwa, kilabo abahlangabezana nemiphumela emimbi yokubandlululwa. Ukuhlatjwa kwavela nakwamanye amazwe, begodu amanye wawo anikela isekelo leenhlangano zekululeko zeSewula Afrika.

Ezinye zeenhlangano eziqakatheke khulu ezibandakanyeka emzabalazweni wekululeko bekuyi-African National Congress (ANC), i-Pan-Africanist Congress (PAC), i-Inkatha Freedom Party (IFP), i-Black Consciousness Movement (BCM) kanye ne-United Democratic Front (UDF). Bekunama-India nama-Colored (isib. i-Natal Indian Congress (NIC), i-Colored People's Organisation), amaqembu wabantu abamhlophe (isib. i-Armed Resistance Movement (ARM), kanye ne-Black Sash) kanye namaqembu asekelwe esontweni (i-Christian Institute). Sizokucabangela i-ANC.

I-ANC

I-ANC yabunjwa e-Bloemfontein ngo-1912, msinyana ngemva kwe-Union of South Africa. Ekuthomeni beyibizwa nge-South African Native National Congress (i-SANNC). Kwathonywa njengomkhankaso wabantu abaNzima abaphezulu, okutjho labo abaNzima ebebafundile. Ngo-1919, i-ANC yathumela isithunywa e-London ukuyokuncenga isivumelwano esitjha sabantu abamnyama beSewula Afrika, kodwana azange kube netjhuguluko ebujameni babo.

Isithunywa se-South African Native National Congress e-England, ngoMgwengweni 1919 Umthombo wesithombe

Umlando wokujamelana kwe-ANC udlula eengabeni ezintathu. Eyokuthoma bekukukhulumisana nokufaka isibawo; ukuphikiswa kwesibili okunqophileko begodu kokugcina kube yisikhathi somzabalazo ohlomileko. Ngomnyaka ka-1949, ngemva nje kokuthi kwethulwe ibandlululo, i-ANC yathoma indlela yokulwa, lapho i-Youth League idlala indima eqakathekileko. I-ANC yethula iHlelo layo lokuSebenza ngo-1949, isekela isenzo sokuteleka, ukutjhikiyela nezinye iinhlobo zokujamelana okungasikho kobudlova. U-Nelson Mandela, u-Oliver Tambo no-Walter Sisulu bathoma ukudlala indima eqakathekileko ku-ANC ngesikhathesi. Ngo-1952 i-ANC yathoma umKhankaso wokuTjhiya. Ijima leli belibiza abantu bona baphule imithetho yebandlululo ngamabomu begodu bazinikele bona babotjhwe. Bekuthenjwa bona ukwanda kwezibotjhwa kuzokwenza bona ihlelo libhidlike begodu lithole isekelo leentjhabatjhaba le-ANC. Abantu abanzima bangena 'emabhasini amhlophe', basebenzisa 'amathoyilethi amhlophe', bangena 'eendaweni zabamhlophe' begodu bala ukusebenzisa amaphasi. Nanyana abantu abayi-8 000 bagcina bavalelwe ejele, i-ANC azange ibe yingozi embusweni webandlululo.

I-ANC yaragela phambili ngendlela efanako hlangana neminyaka yabo-1950, bekwaba kulapho ngo-1959 amanye amalunga ahlukana khona akha i-PAC. Amalunga la bekafuna ukulandela indlela enobudlova neyepi, begodu abona ngasuthi ipumelelo angeze yafinyelelwa ngendlela ye-ANC

== Iinkomba ==</text>
      <sha1>3jzdfra7k2xp4ussprb33nra7kh636a</sha1>
    </revision>
    <revision>
      <id>6049</id>
      <parentid>6048</parentid>
      <timestamp>2025-12-01T06:56:02Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6049</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8269" sha1="t8168s804fnc07capiphgfaj5eo0qso" xml:space="preserve">'''Igama elithi &quot;Ibandlululo&quot;''' tjhugululwe ukusuka elimini lesibhuru okutjho 'ukuhlukana', ibandlululo bekuyimbono eyasekelwa ngurhulumende we-National Party (NP) begodu yathonywa eSewula Afrika ngo-1948.&lt;ref&gt;https://sahistory.org.za/article/history-apartheid-south-africa&lt;/ref&gt; Ibandlululo labawa ukuthuthukiswa okuhlukileko kwamakoro weentjhaba ezihlukahlukeneko eSewula Afrika. Ephepheni bekubonakala ngasuthi kufuna ukuthuthukiswa okulinganako nekululeko yokuveza amasiko, kodwana indlela ebegade isetjenziswa ngayo yenza bona lokhu kungakghonakali. Imithetho yebandlululo yakatelela iintjhaba ezihlukahlukeneko bona zihlale ngokwehlukana begodu zithuthuke ngokwehlukana, begodu ngokungalingani khulu. Ilinge ukuqeda woke umtjhado nokuhlanganiswa komphakathi hlangana namakoro wobuhlanga.&lt;ref&gt;Mhlauli, M.B., Salani, E. and Mokotedi, R., 2015. Understanding apartheid in South Africa through the racial contract. ''International Journal of Asian Social Science'', ''5''(4), pp.203-219.&lt;/ref&gt; Ngesikhathi sebandlululo, ukuba nobungani nomuntu wobuhlanga obuhlukileko bekuletha iinsolo kuwe, nofana okumbi khulu. Ngaphezu kwalokhu, ibandlululo bekulihlelo lezenhlalakahle ebelihlukumeza khulu inengi labantu, ngombana bebangafani umbala wesikhumba wababusi. Abanengi bebagcinwa ngaphezu kokutlhaga ngombana 'bebangasibo abamhlophe'.

Ngokweenkambisolawulo ezisisekelo, ibandlululo belingafani kangako emthethweni wokuhlukanisa urhulumende weSewula Afrika owawukhona ngaphambi kokuthi i-Afrikaner Nationalist Party ifike emandleni ngo-1948. Umehluko omkhulu kukobana ibandlululo lenze ihlukaniso libe yingcenye yomthetho. Ibandlululo lahlukanisa abantu ngesihlungu nangokugandelela, begodu linehlelo lombuso elithusako lokujezisa labo abangavumelani. Esinye isizathu sokuthi kubayini ibandlululo belibonwa njengelibi khulu ukudlula ukuhlukaniswa, kukuthi ibandlululo lathonywa ngesikhathi lapho amanye amazwe bekatjhiya khona imigomo yebandlululo. Ngaphambi kwePi yesiBili yePhasi inarha yeTjingalanga beyingathatheli phasi kangako ukubandlululwa ngokobuhlanga, begodu i-Afrika beyikoloni ngalesi sikhathi. Ipi yesiBili yePhasi yaveza imiraro yokubandlulula ngokobuhlanga, yenza bona umhlaba ufulathele imigomo enjalo begodu wakhuthaza iimfuno zokususwa kwamakoloni. Kungesikhathi lesi lapho iSewula Afrika yethula khona umthethomgomo oqinileko wobandlululo.

Abantu bavame ukuzibuza bona kubayini umthethomgomo onjalo wethulwe begodu kubayini wasekelwa kangaka. Iinzathu ezihlukahlukeneko zingavezwa ngebandlululo, nanyana zoke zihlobene khulu. Iinzathu ezikulu zilele emibonweni yokuphakama ngokobuhlanga nokwesaba. Ephasini loke, ukubandlululwa ngokobuhlanga kuthonywa mqondo wokobana omunye umhlobo kufuze ube ngaphezu komunye. Imibono enjalo itholakala kiwo woke amaqembu wabantu. Esinye isizathu esikhulu sebandlululo bekukwesaba, njengombana eSewula Afrika abantu abamhlophe bambalwa, begodu inengi belitshwenyekile ngokuthi lingalahlekelwa misebenzi, amasiko nelimi.&lt;ref&gt;https://sahistory.org.za/article/history-apartheid-south-africa&lt;/ref&gt; Lokhu akusiso isizathu sebandlululo, kodwana kuhlathulula bona abantu bebacabanga njani.

=== Imithetho yebandlululo ===
Kwaphasiswa imithetho eminengi ekubunjweni kombuso webandlululo. Nanzi iinsika ezimbalwa ebegade zijame kizo: UmThetho wokuTloliswa kwabantu, 1950 UmThetho lo bewufuna bona abantu batloliswe ngokuya ngokobuhlanga babo. Lokhu kutjho bona umNyango wezeKhaya bewuzokuba nerekhodi labantu ngokuya ngokuthi bamhlophe, banemibala, bamnyama, bama-India nofana bama-Asia. Abantu bebazokuphathwa ngendlela ehlukileko ngokuya ngesiqhema sabo, begodu umthetho lo waba sisekelo sebandlululo.&lt;ref&gt;Govender, N. and Reddy, P.S., 2019. Urban regeneration in South Africa-the apartheid legacy and legislative framework re-examined–the case of eThekweni Municipality. ''African Journal of Public Affairs'', ''11''(2), pp.83-102.&lt;/ref&gt; Kodwana bekungasi lula ngaso soke isikhathi ukuqunta bona umuntu uyingcenye yabaphi ubuhlanga, begodu lokhu kwabanga imiraro.

UmThetho weeNdawo weenqhema, 1950 Lo bekumthetho owathoma ukuhlukana hlangana kweentjhaba, khulukhulu eendaweni ezisemadorobheni. Umthetho lo godu ufuna ukususwa kwezinye iinqhema zabantu ziye eendaweni ezibekelwe amaqembu wabo wobuhlanga.UmThetho wokuThuthukiswa kokuZiBusa kwamaBantu, we-1959 UmThetho lo bewuthi iintjhaba ezihlukahlukeneko kufuze zihlale eendaweni ezihlukahlukeneko. Kwasala iphesenteji encani yeSewula Afrika bona abantu abanzima (ebebayinengi labo) bakhe 'amazwe wabo'. Umthetho lo godu wasusa 'amabala amnyama' ngaphakathi kweendawo zabantu abamhlophe, ngokususa boke abantu abamnyama ngaphandle kwedorobha. Ukususwa okwaziwako bekuku-District 6, i-Sophiatown kanye ne-Lady Selborne. Abantu abamnyama laba babe sebefakwa emalokishini angaphandle kwedorobha. Bebangakghoni ukuba nepahla lapha, bayiqatjha kwaphela, ngombana inarha beyingaba ngeyabantu abamhlophe kwaphela. Umthetho lo wabanga ubudisi obukhulu nokusilingeka. Abantu balahlekelwa makhaya wabo, basuswa eendaweni ebegade banazo iminyaka eminengi begodu bathuthelwa eendaweni ezingakathuthukiswa kude nendawo abasebenza kiyo.

=== Eminye imithetho eqakathekileko bekuyi: ===
UmThetho wokuVimbela imitjhado ehlangeneko, 1949

UmThetho wokuTjhugulula ukuZiphatha kumbi, 1950

UmThetho wokuJanyelwa okuhlukileko kwabavowudi, 1951

Ukujamelana ngaphambi kwaka-1960

Ukujamelana nebandlululo kwavela kiyo yoke imikhakha, begodu ingasi kwaphela, njengombana kuvame ukucatshangelwa, kilabo abahlangabezana nemiphumela emimbi yokubandlululwa. Ukuhlatjwa kwavela nakwamanye amazwe, begodu amanye wawo anikela isekelo leenhlangano zekululeko zeSewula Afrika.

Ezinye zeenhlangano eziqakatheke khulu ezibandakanyeka emzabalazweni wekululeko bekuyi-African National Congress (ANC), i-Pan-Africanist Congress (PAC), i-Inkatha Freedom Party (IFP), i-Black Consciousness Movement (BCM) kanye ne-United Democratic Front (UDF). Bekunama-India nama-Colored (isib. i-Natal Indian Congress (NIC), i-Colored People's Organisation), amaqembu wabantu abamhlophe (isib. i-Armed Resistance Movement (ARM), kanye ne-Black Sash) kanye namaqembu asekelwe esontweni (i-Christian Institute). Sizokucabangela i-ANC.

I-ANC

I-ANC yabunjwa e-Bloemfontein ngo-1912, msinyana ngemva kwe-Union of South Africa. Ekuthomeni beyibizwa nge-South African Native National Congress (i-SANNC). Kwathonywa njengomkhankaso wabantu abaNzima abaphezulu, okutjho labo abaNzima ebebafundile. Ngo-1919, i-ANC yathumela isithunywa e-London ukuyokuncenga isivumelwano esitjha sabantu abamnyama beSewula Afrika, kodwana azange kube netjhuguluko ebujameni babo.

Isithunywa se-South African Native National Congress e-England, ngoMgwengweni 1919 Umthombo wesithombe

Umlando wokujamelana kwe-ANC udlula eengabeni ezintathu. Eyokuthoma bekukukhulumisana nokufaka isibawo; ukuphikiswa kwesibili okunqophileko begodu kokugcina kube yisikhathi somzabalazo ohlomileko. Ngomnyaka ka-1949, ngemva nje kokuthi kwethulwe ibandlululo, i-ANC yathoma indlela yokulwa, lapho i-Youth League idlala indima eqakathekileko. &lt;ref&gt;Suttner, R., 2012. The African National Congress centenary: a long and difficult journey. ''International Affairs'', ''88''(4), pp.719-738.&lt;/ref&gt;I-ANC yethula iHlelo layo lokuSebenza ngo-1949, isekela isenzo sokuteleka, ukutjhikiyela nezinye iinhlobo zokujamelana okungasikho kobudlova. U-Nelson Mandela, u-Oliver Tambo no-Walter Sisulu bathoma ukudlala indima eqakathekileko ku-ANC ngesikhathesi. Ngo-1952 i-ANC yathoma umKhankaso wokuTjhiya. Ijima leli belibiza abantu bona baphule imithetho yebandlululo ngamabomu begodu bazinikele bona babotjhwe. Bekuthenjwa bona ukwanda kwezibotjhwa kuzokwenza bona ihlelo libhidlike begodu lithole isekelo leentjhabatjhaba le-ANC. Abantu abanzima bangena 'emabhasini amhlophe', basebenzisa 'amathoyilethi amhlophe', bangena 'eendaweni zabamhlophe' begodu bala ukusebenzisa amaphasi. Nanyana abantu abayi-8 000 bagcina bavalelwe ejele, i-ANC azange ibe yingozi embusweni webandlululo.

I-ANC yaragela phambili ngendlela efanako hlangana neminyaka yabo-1950, bekwaba kulapho ngo-1959 amanye amalunga ahlukana khona akha i-PAC. Amalunga la bekafuna ukulandela indlela enobudlova neyepi, begodu abona ngasuthi ipumelelo angeze yafinyelelwa ngendlela ye-ANC

== Iinkomba ==</text>
      <sha1>t8168s804fnc07capiphgfaj5eo0qso</sha1>
    </revision>
    <revision>
      <id>6050</id>
      <parentid>6049</parentid>
      <timestamp>2025-12-01T06:59:35Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6050</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8426" sha1="bjm8c9g25l05c5sprfzyndq70snp97i" xml:space="preserve">'''Igama elithi &quot;Ibandlululo&quot;''' tjhugululwe ukusuka elimini lesibhuru okutjho 'ukuhlukana', ibandlululo bekuyimbono eyasekelwa ngurhulumende we-National Party (NP) begodu yathonywa eSewula Afrika ngo-1948.&lt;ref&gt;https://sahistory.org.za/article/history-apartheid-south-africa&lt;/ref&gt; Ibandlululo labawa ukuthuthukiswa okuhlukileko kwamakoro weentjhaba ezihlukahlukeneko eSewula Afrika. Ephepheni bekubonakala ngasuthi kufuna ukuthuthukiswa okulinganako nekululeko yokuveza amasiko, kodwana indlela ebegade isetjenziswa ngayo yenza bona lokhu kungakghonakali. Imithetho yebandlululo yakatelela iintjhaba ezihlukahlukeneko bona zihlale ngokwehlukana begodu zithuthuke ngokwehlukana, begodu ngokungalingani khulu. Ilinge ukuqeda woke umtjhado nokuhlanganiswa komphakathi hlangana namakoro wobuhlanga.&lt;ref&gt;Mhlauli, M.B., Salani, E. and Mokotedi, R., 2015. Understanding apartheid in South Africa through the racial contract. ''International Journal of Asian Social Science'', ''5''(4), pp.203-219.&lt;/ref&gt; Ngesikhathi sebandlululo, ukuba nobungani nomuntu wobuhlanga obuhlukileko bekuletha iinsolo kuwe, nofana okumbi khulu. Ngaphezu kwalokhu, ibandlululo bekulihlelo lezenhlalakahle ebelihlukumeza khulu inengi labantu, ngombana bebangafani umbala wesikhumba wababusi. Abanengi bebagcinwa ngaphezu kokutlhaga ngombana 'bebangasibo abamhlophe'.

Ngokweenkambisolawulo ezisisekelo, ibandlululo belingafani kangako emthethweni wokuhlukanisa urhulumende weSewula Afrika owawukhona ngaphambi kokuthi i-Afrikaner Nationalist Party ifike emandleni ngo-1948. Umehluko omkhulu kukobana ibandlululo lenze ihlukaniso libe yingcenye yomthetho. Ibandlululo lahlukanisa abantu ngesihlungu nangokugandelela, begodu linehlelo lombuso elithusako lokujezisa labo abangavumelani. Esinye isizathu sokuthi kubayini ibandlululo belibonwa njengelibi khulu ukudlula ukuhlukaniswa, kukuthi ibandlululo lathonywa ngesikhathi lapho amanye amazwe bekatjhiya khona imigomo yebandlululo. Ngaphambi kwePi yesiBili yePhasi inarha yeTjingalanga beyingathatheli phasi kangako ukubandlululwa ngokobuhlanga, begodu i-Afrika beyikoloni ngalesi sikhathi. Ipi yesiBili yePhasi yaveza imiraro yokubandlulula ngokobuhlanga, yenza bona umhlaba ufulathele imigomo enjalo begodu wakhuthaza iimfuno zokususwa kwamakoloni. Kungesikhathi lesi lapho iSewula Afrika yethula khona umthethomgomo oqinileko wobandlululo.

Abantu bavame ukuzibuza bona kubayini umthethomgomo onjalo wethulwe begodu kubayini wasekelwa kangaka. Iinzathu ezihlukahlukeneko zingavezwa ngebandlululo, nanyana zoke zihlobene khulu. Iinzathu ezikulu zilele emibonweni yokuphakama ngokobuhlanga nokwesaba. Ephasini loke, ukubandlululwa ngokobuhlanga kuthonywa mqondo wokobana omunye umhlobo kufuze ube ngaphezu komunye. Imibono enjalo itholakala kiwo woke amaqembu wabantu. Esinye isizathu esikhulu sebandlululo bekukwesaba, njengombana eSewula Afrika abantu abamhlophe bambalwa, begodu inengi belitshwenyekile ngokuthi lingalahlekelwa misebenzi, amasiko nelimi.&lt;ref&gt;https://sahistory.org.za/article/history-apartheid-south-africa&lt;/ref&gt; Lokhu akusiso isizathu sebandlululo, kodwana kuhlathulula bona abantu bebacabanga njani.

=== Imithetho yebandlululo ===
Kwaphasiswa imithetho eminengi ekubunjweni kombuso webandlululo. Nanzi iinsika ezimbalwa ebegade zijame kizo: UmThetho wokuTloliswa kwabantu, 1950 UmThetho lo bewufuna bona abantu batloliswe ngokuya ngokobuhlanga babo. Lokhu kutjho bona umNyango wezeKhaya bewuzokuba nerekhodi labantu ngokuya ngokuthi bamhlophe, banemibala, bamnyama, bama-India nofana bama-Asia. Abantu bebazokuphathwa ngendlela ehlukileko ngokuya ngesiqhema sabo, begodu umthetho lo waba sisekelo sebandlululo.&lt;ref&gt;Govender, N. and Reddy, P.S., 2019. Urban regeneration in South Africa-the apartheid legacy and legislative framework re-examined–the case of eThekweni Municipality. ''African Journal of Public Affairs'', ''11''(2), pp.83-102.&lt;/ref&gt; Kodwana bekungasi lula ngaso soke isikhathi ukuqunta bona umuntu uyingcenye yabaphi ubuhlanga, begodu lokhu kwabanga imiraro.

UmThetho weeNdawo weenqhema, 1950 Lo bekumthetho owathoma ukuhlukana hlangana kweentjhaba, khulukhulu eendaweni ezisemadorobheni. Umthetho lo godu ufuna ukususwa kwezinye iinqhema zabantu ziye eendaweni ezibekelwe amaqembu wabo wobuhlanga.UmThetho wokuThuthukiswa kokuZiBusa kwamaBantu, we-1959 UmThetho lo bewuthi iintjhaba ezihlukahlukeneko kufuze zihlale eendaweni ezihlukahlukeneko. Kwasala iphesenteji encani yeSewula Afrika bona abantu abanzima (ebebayinengi labo) bakhe 'amazwe wabo'. Umthetho lo godu wasusa 'amabala amnyama' ngaphakathi kweendawo zabantu abamhlophe, ngokususa boke abantu abamnyama ngaphandle kwedorobha. Ukususwa okwaziwako bekuku-District 6, i-Sophiatown kanye ne-Lady Selborne. Abantu abamnyama laba babe sebefakwa emalokishini angaphandle kwedorobha. Bebangakghoni ukuba nepahla lapha, bayiqatjha kwaphela, ngombana inarha beyingaba ngeyabantu abamhlophe kwaphela. Umthetho lo wabanga ubudisi obukhulu nokusilingeka. Abantu balahlekelwa makhaya wabo, basuswa eendaweni ebegade banazo iminyaka eminengi begodu bathuthelwa eendaweni ezingakathuthukiswa kude nendawo abasebenza kiyo.

=== Eminye imithetho eqakathekileko bekuyi: ===
UmThetho wokuVimbela imitjhado ehlangeneko, 1949

UmThetho wokuTjhugulula ukuZiphatha kumbi, 1950

UmThetho wokuJanyelwa okuhlukileko kwabavowudi, 1951

Ukujamelana ngaphambi kwaka-1960

Ukujamelana nebandlululo kwavela kiyo yoke imikhakha, begodu ingasi kwaphela, njengombana kuvame ukucatshangelwa, kilabo abahlangabezana nemiphumela emimbi yokubandlululwa. Ukuhlatjwa kwavela nakwamanye amazwe, begodu amanye wawo anikela isekelo leenhlangano zekululeko zeSewula Afrika.

Ezinye zeenhlangano eziqakatheke khulu ezibandakanyeka emzabalazweni wekululeko bekuyi-African National Congress (ANC), i-Pan-Africanist Congress (PAC), i-Inkatha Freedom Party (IFP), i-Black Consciousness Movement (BCM) kanye ne-United Democratic Front (UDF). Bekunama-India nama-Colored (isib. i-Natal Indian Congress (NIC), i-Colored People's Organisation), amaqembu wabantu abamhlophe (isib. i-Armed Resistance Movement (ARM), kanye ne-Black Sash) kanye namaqembu asekelwe esontweni (i-Christian Institute). Sizokucabangela i-ANC.

I-ANC

I-ANC yabunjwa e-Bloemfontein ngo-1912, msinyana ngemva kwe-Union of South Africa. Ekuthomeni beyibizwa nge-South African Native National Congress (i-SANNC). Kwathonywa njengomkhankaso wabantu abaNzima abaphezulu, okutjho labo abaNzima ebebafundile. Ngo-1919, i-ANC yathumela isithunywa e-London ukuyokuncenga isivumelwano esitjha sabantu abamnyama beSewula Afrika, kodwana azange kube netjhuguluko ebujameni babo.

Isithunywa se-South African Native National Congress e-England, ngoMgwengweni 1919 Umthombo wesithombe

Umlando wokujamelana kwe-ANC udlula eengabeni ezintathu. Eyokuthoma bekukukhulumisana nokufaka isibawo; ukuphikiswa kwesibili okunqophileko begodu kokugcina kube yisikhathi somzabalazo ohlomileko. Ngomnyaka ka-1949, ngemva nje kokuthi kwethulwe ibandlululo, i-ANC yathoma indlela yokulwa, lapho i-Youth League idlala indima eqakathekileko. &lt;ref&gt;Suttner, R., 2012. The African National Congress centenary: a long and difficult journey. ''International Affairs'', ''88''(4), pp.719-738.&lt;/ref&gt;I-ANC yethula iHlelo layo lokuSebenza ngo-1949, isekela isenzo sokuteleka, ukutjhikiyela nezinye iinhlobo zokujamelana okungasikho kobudlova. U-Nelson Mandela, u-Oliver Tambo no-Walter Sisulu bathoma ukudlala indima eqakathekileko ku-ANC ngesikhathesi. Ngo-1952 i-ANC yathoma umKhankaso wokuTjhiya. Ijima leli belibiza abantu bona baphule imithetho yebandlululo ngamabomu begodu bazinikele bona babotjhwe. Bekuthenjwa bona ukwanda kwezibotjhwa kuzokwenza bona ihlelo libhidlike begodu lithole isekelo leentjhabatjhaba le-ANC. Abantu abanzima bangena 'emabhasini amhlophe', basebenzisa 'amathoyilethi amhlophe', bangena 'eendaweni zabamhlophe' begodu bala ukusebenzisa amaphasi. Nanyana abantu abayi-8 000 bagcina bavalelwe ejele, i-ANC azange ibe yingozi embusweni webandlululo.

I-ANC yaragela phambili ngendlela efanako hlangana neminyaka yabo-1950, bekwaba kulapho ngo-1959 amanye amalunga ahlukana khona akha i-PAC. Amalunga la bekafuna ukulandela indlela enobudlova neyepi, begodu abona ngasuthi ipumelelo angeze yafinyelelwa ngendlela ye-ANC

== Iinkomba ==
[[Category:Umbuso wegandelelo]]
[[Category:Ipolitiki]]
[[Category:Umlando weSewula Afrika]]
[[Category:Ibandlululo]]
[[Category: Ukubundlulula ngobuhlanga]]</text>
      <sha1>bjm8c9g25l05c5sprfzyndq70snp97i</sha1>
    </revision>
    <revision>
      <id>6051</id>
      <parentid>6050</parentid>
      <timestamp>2025-12-01T07:03:33Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6051</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8443" sha1="edj71ydt6ue0jtt9ntfhylplty0yoon" xml:space="preserve">'''Igama elithi &quot;Ibandlululo&quot;''' tjhugululwe ukusuka elimini lesibhuru okutjho 'ukuhlukana', ibandlululo bekuyimbono eyasekelwa ngurhulumende we-National Party (NP) begodu yathonywa eSewula Afrika ngo-1948.&lt;ref&gt;https://sahistory.org.za/article/history-apartheid-south-africa&lt;/ref&gt; Ibandlululo labawa ukuthuthukiswa okuhlukileko kwamakoro weentjhaba ezihlukahlukeneko eSewula Afrika. Ephepheni bekubonakala ngasuthi kufuna ukuthuthukiswa okulinganako nekululeko yokuveza amasiko, kodwana indlela ebegade isetjenziswa ngayo yenza bona lokhu kungakghonakali. Imithetho yebandlululo yakatelela iintjhaba ezihlukahlukeneko bona zihlale ngokwehlukana begodu zithuthuke ngokwehlukana, begodu ngokungalingani khulu. Ilinge ukuqeda woke umtjhado nokuhlanganiswa komphakathi hlangana namakoro wobuhlanga.&lt;ref&gt;Mhlauli, M.B., Salani, E. and Mokotedi, R., 2015. Understanding apartheid in South Africa through the racial contract. ''International Journal of Asian Social Science'', ''5''(4), pp.203-219.&lt;/ref&gt; Ngesikhathi sebandlululo, ukuba nobungani nomuntu wobuhlanga obuhlukileko bekuletha iinsolo kuwe, nofana okumbi khulu. Ngaphezu kwalokhu, ibandlululo bekulihlelo lezenhlalakahle ebelihlukumeza khulu inengi labantu, ngombana bebangafani umbala wesikhumba wababusi. Abanengi bebagcinwa ngaphezu kokutlhaga ngombana 'bebangasibo abamhlophe'.

Ngokweenkambisolawulo ezisisekelo, ibandlululo belingafani kangako emthethweni wokuhlukanisa urhulumende weSewula Afrika owawukhona ngaphambi kokuthi i-Afrikaner Nationalist Party ifike emandleni ngo-1948. Umehluko omkhulu kukobana ibandlululo lenze ihlukaniso libe yingcenye yomthetho. Ibandlululo lahlukanisa abantu ngesihlungu nangokugandelela, begodu linehlelo lombuso elithusako lokujezisa labo abangavumelani. Esinye isizathu sokuthi kubayini ibandlululo belibonwa njengelibi khulu ukudlula ukuhlukaniswa, kukuthi ibandlululo lathonywa ngesikhathi lapho amanye amazwe bekatjhiya khona imigomo yebandlululo. Ngaphambi kwePi yesiBili yePhasi inarha yeTjingalanga beyingathatheli phasi kangako ukubandlululwa ngokobuhlanga, begodu i-Afrika beyikoloni ngalesi sikhathi. Ipi yesiBili yePhasi yaveza imiraro yokubandlulula ngokobuhlanga, yenza bona umhlaba ufulathele imigomo enjalo begodu wakhuthaza iimfuno zokususwa kwamakoloni. Kungesikhathi lesi lapho iSewula Afrika yethula khona umthethomgomo oqinileko wobandlululo.

Abantu bavame ukuzibuza bona kubayini umthethomgomo onjalo wethulwe begodu kubayini wasekelwa kangaka. Iinzathu ezihlukahlukeneko zingavezwa ngebandlululo, nanyana zoke zihlobene khulu. Iinzathu ezikulu zilele emibonweni yokuphakama ngokobuhlanga nokwesaba. Ephasini loke, ukubandlululwa ngokobuhlanga kuthonywa mqondo wokobana omunye umhlobo kufuze ube ngaphezu komunye. Imibono enjalo itholakala kiwo woke amaqembu wabantu. Esinye isizathu esikhulu sebandlululo bekukwesaba, njengombana eSewula Afrika abantu abamhlophe bambalwa, begodu inengi belitshwenyekile ngokuthi lingalahlekelwa misebenzi, amasiko nelimi.&lt;ref&gt;https://sahistory.org.za/article/history-apartheid-south-africa&lt;/ref&gt; Lokhu akusiso isizathu sebandlululo, kodwana kuhlathulula bona abantu bebacabanga njani.

=== Imithetho yebandlululo ===
Kwaphasiswa imithetho eminengi ekubunjweni kombuso webandlululo. Nanzi iinsika ezimbalwa ebegade zijame kizo: UmThetho wokuTloliswa kwabantu, 1950 UmThetho lo bewufuna bona abantu batloliswe ngokuya ngokobuhlanga babo. Lokhu kutjho bona umNyango wezeKhaya bewuzokuba nerekhodi labantu ngokuya ngokuthi bamhlophe, banemibala, bamnyama, bama-India nofana bama-Asia. Abantu bebazokuphathwa ngendlela ehlukileko ngokuya ngesiqhema sabo, begodu umthetho lo waba sisekelo sebandlululo.&lt;ref&gt;Govender, N. and Reddy, P.S., 2019. Urban regeneration in South Africa-the apartheid legacy and legislative framework re-examined–the case of eThekweni Municipality. ''African Journal of Public Affairs'', ''11''(2), pp.83-102.&lt;/ref&gt; Kodwana bekungasi lula ngaso soke isikhathi ukuqunta bona umuntu uyingcenye yabaphi ubuhlanga, begodu lokhu kwabanga imiraro.

UmThetho weeNdawo weenqhema, 1950 Lo bekumthetho owathoma ukuhlukana hlangana kweentjhaba, khulukhulu eendaweni ezisemadorobheni. Umthetho lo godu ufuna ukususwa kwezinye iinqhema zabantu ziye eendaweni ezibekelwe amaqembu wabo wobuhlanga.UmThetho wokuThuthukiswa kokuZiBusa kwamaBantu, we-1959 UmThetho lo bewuthi iintjhaba ezihlukahlukeneko kufuze zihlale eendaweni ezihlukahlukeneko. Kwasala iphesenteji encani yeSewula Afrika bona abantu abanzima (ebebayinengi labo) bakhe 'amazwe wabo'. Umthetho lo godu wasusa 'amabala amnyama' ngaphakathi kweendawo zabantu abamhlophe, ngokususa boke abantu abamnyama ngaphandle kwedorobha. Ukususwa okwaziwako bekuku-District 6, i-Sophiatown kanye ne-Lady Selborne. Abantu abamnyama laba babe sebefakwa emalokishini angaphandle kwedorobha. Bebangakghoni ukuba nepahla lapha, bayiqatjha kwaphela, ngombana inarha beyingaba ngeyabantu abamhlophe kwaphela. Umthetho lo wabanga ubudisi obukhulu nokusilingeka. Abantu balahlekelwa makhaya wabo, basuswa eendaweni ebegade banazo iminyaka eminengi begodu bathuthelwa eendaweni ezingakathuthukiswa kude nendawo abasebenza kiyo.

=== Eminye imithetho eqakathekileko bekuyi: ===
UmThetho wokuVimbela imitjhado ehlangeneko, 1949

UmThetho wokuTjhugulula ukuZiphatha kumbi, 1950

UmThetho wokuJanyelwa okuhlukileko kwabavowudi, 1951

=== Ukujamelana ngaphambi kwaka-1960 ===
Ukujamelana nebandlululo kwavela kiyo yoke imikhakha, begodu ingasi kwaphela, njengombana kuvame ukucatshangelwa, kilabo abahlangabezana nemiphumela emimbi yokubandlululwa. Ukuhlatjwa kwavela nakwamanye amazwe, begodu amanye wawo anikela isekelo leenhlangano zekululeko zeSewula Afrika. Ezinye zeenhlangano eziqakatheke khulu ezibandakanyeka emzabalazweni wekululeko bekuyi-African National Congress (ANC), i-Pan-Africanist Congress (PAC), i-Inkatha Freedom Party (IFP), i-Black Consciousness Movement (BCM) kanye ne-United Democratic Front (UDF). Bekunama-India nama-Colored (isib. i-Natal Indian Congress (NIC), i-Colored People's Organisation), amaqembu wabantu abamhlophe (isib. i-Armed Resistance Movement (ARM), kanye ne-Black Sash) kanye namaqembu asekelwe esontweni (i-Christian Institute). Sizokucabangela i-ANC.

=== I-ANC ===
I-ANC yabunjwa e-Bloemfontein ngo-1912, msinyana ngemva kwe-Union of South Africa. Ekuthomeni beyibizwa nge-South African Native National Congress (i-SANNC). Kwathonywa njengomkhankaso wabantu abaNzima abaphezulu, okutjho labo abaNzima ebebafundile. Ngo-1919, i-ANC yathumela isithunywa e-London ukuyokuncenga isivumelwano esitjha sabantu abamnyama beSewula Afrika, kodwana azange kube netjhuguluko ebujameni babo.

Isithunywa se-South African Native National Congress e-England, ngoMgwengweni 1919 Umthombo wesithombe

Umlando wokujamelana kwe-ANC udlula eengabeni ezintathu. Eyokuthoma bekukukhulumisana nokufaka isibawo; ukuphikiswa kwesibili okunqophileko begodu kokugcina kube yisikhathi somzabalazo ohlomileko. Ngomnyaka ka-1949, ngemva nje kokuthi kwethulwe ibandlululo, i-ANC yathoma indlela yokulwa, lapho i-Youth League idlala indima eqakathekileko. &lt;ref&gt;Suttner, R., 2012. The African National Congress centenary: a long and difficult journey. ''International Affairs'', ''88''(4), pp.719-738.&lt;/ref&gt;I-ANC yethula iHlelo layo lokuSebenza ngo-1949, isekela isenzo sokuteleka, ukutjhikiyela nezinye iinhlobo zokujamelana okungasikho kobudlova. U-[[Nelson Mandela]], u-Oliver Tambo no-Walter Sisulu bathoma ukudlala indima eqakathekileko ku-ANC ngesikhathesi. Ngo-1952 i-ANC yathoma umKhankaso wokuTjhiya. Ijima leli belibiza abantu bona baphule imithetho yebandlululo ngamabomu begodu bazinikele bona babotjhwe. Bekuthenjwa bona ukwanda kwezibotjhwa kuzokwenza bona ihlelo libhidlike begodu lithole isekelo leentjhabatjhaba le-ANC. Abantu abanzima bangena 'emabhasini amhlophe', basebenzisa 'amathoyilethi amhlophe', bangena 'eendaweni zabamhlophe' begodu bala ukusebenzisa amaphasi. Nanyana abantu abayi-8 000 bagcina bavalelwe ejele, i-ANC azange ibe yingozi embusweni webandlululo.

I-ANC yaragela phambili ngendlela efanako hlangana neminyaka yabo-1950, bekwaba kulapho ngo-1959 amanye amalunga ahlukana khona akha i-PAC. Amalunga la bekafuna ukulandela indlela enobudlova neyepi, begodu abona ngasuthi ipumelelo angeze yafinyelelwa ngendlela ye-ANC

== Iinkomba ==
[[Category:Umbuso wegandelelo]]
[[Category:Ipolitiki]]
[[Category:Umlando weSewula Afrika]]
[[Category:Ibandlululo]]
[[Category: Ukubundlulula ngobuhlanga]]</text>
      <sha1>edj71ydt6ue0jtt9ntfhylplty0yoon</sha1>
    </revision>
    <revision>
      <id>6052</id>
      <parentid>6051</parentid>
      <timestamp>2025-12-01T07:05:18Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6052</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8440" sha1="izoynpbckgfqeotlhmznhhhf7sy000s" xml:space="preserve">'''Igama elithi &quot;Ibandlululo&quot;''' tjhugululwe ukusuka elimini lesibhuru okutjho 'ukuhlukana', ibandlululo bekuyimbono eyasekelwa ngurhulumende we-National Party (NP) begodu yathonywa eSewula Afrika ngo-1948.&lt;ref&gt;https://sahistory.org.za/article/history-apartheid-south-africa&lt;/ref&gt; Ibandlululo labawa ukuthuthukiswa okuhlukileko kwamakoro weentjhaba ezihlukahlukeneko eSewula Afrika. Ephepheni bekubonakala ngasuthi kufuna ukuthuthukiswa okulinganako nekululeko yokuveza amasiko, kodwana indlela ebegade isetjenziswa ngayo yenza bona lokhu kungakghonakali. Imithetho yebandlululo yakatelela iintjhaba ezihlukahlukeneko bona zihlale ngokwehlukana begodu zithuthuke ngokwehlukana, begodu ngokungalingani khulu. Ilinge ukuqeda woke umtjhado nokuhlanganiswa komphakathi hlangana namakoro wobuhlanga.&lt;ref&gt;Mhlauli, M.B., Salani, E. and Mokotedi, R., 2015. Understanding apartheid in South Africa through the racial contract. ''International Journal of Asian Social Science'', ''5''(4), pp.203-219.&lt;/ref&gt; Ngesikhathi sebandlululo, ukuba nobungani nomuntu wobuhlanga obuhlukileko bekuletha iinsolo kuwe, nofana okumbi khulu. Ngaphezu kwalokhu, ibandlululo bekulihlelo lezenhlalakahle ebelihlukumeza khulu inengi labantu, ngombana bebangafani umbala wesikhumba wababusi. Abanengi bebagcinwa ngaphezu kokutlhaga ngombana 'bebangasibo abamhlophe'.

Ngokweenkambisolawulo ezisisekelo, ibandlululo belingafani kangako emthethweni wokuhlukanisa urhulumende weSewula Afrika owawukhona ngaphambi kokuthi i-Afrikaner Nationalist Party ifike emandleni ngo-1948. Umehluko omkhulu kukobana ibandlululo lenze ihlukaniso libe yingcenye yomthetho. Ibandlululo lahlukanisa abantu ngesihlungu nangokugandelela, begodu linehlelo lombuso elithusako lokujezisa labo abangavumelani. Esinye isizathu sokuthi kubayini ibandlululo belibonwa njengelibi khulu ukudlula ukuhlukaniswa, kukuthi ibandlululo lathonywa ngesikhathi lapho amanye amazwe bekatjhiya khona imigomo yebandlululo. Ngaphambi kwePi yesiBili yePhasi inarha yeTjingalanga beyingathatheli phasi kangako ukubandlululwa ngokobuhlanga, begodu i-Afrika beyikoloni ngalesi sikhathi. Ipi yesiBili yePhasi yaveza imiraro yokubandlulula ngokobuhlanga, yenza bona umhlaba ufulathele imigomo enjalo begodu wakhuthaza iimfuno zokususwa kwamakoloni. Kungesikhathi lesi lapho iSewula Afrika yethula khona umthethomgomo oqinileko wobandlululo.

Abantu bavame ukuzibuza bona kubayini umthethomgomo onjalo wethulwe begodu kubayini wasekelwa kangaka. Iinzathu ezihlukahlukeneko zingavezwa ngebandlululo, nanyana zoke zihlobene khulu. Iinzathu ezikulu zilele emibonweni yokuphakama ngokobuhlanga nokwesaba. Ephasini loke, ukubandlululwa ngokobuhlanga kuthonywa mqondo wokobana omunye umhlobo kufuze ube ngaphezu komunye. Imibono enjalo itholakala kiwo woke amaqembu wabantu. Esinye isizathu esikhulu sebandlululo bekukwesaba, njengombana eSewula Afrika abantu abamhlophe bambalwa, begodu inengi belitshwenyekile ngokuthi lingalahlekelwa misebenzi, amasiko nelimi.&lt;ref&gt;https://sahistory.org.za/article/history-apartheid-south-africa&lt;/ref&gt; Lokhu akusiso isizathu sebandlululo, kodwana kuhlathulula bona abantu bebacabanga njani.

=== Imithetho yebandlululo ===
Kwaphasiswa imithetho eminengi ekubunjweni kombuso webandlululo. Nanzi iinsika ezimbalwa ebegade zijame kizo: UmThetho wokuTloliswa kwabantu, 1950 UmThetho lo bewufuna bona abantu batloliswe ngokuya ngokobuhlanga babo. Lokhu kutjho bona umNyango wezeKhaya bewuzokuba nerekhodi labantu ngokuya ngokuthi bamhlophe, banemibala, bamnyama, bama-India nofana bama-Asia. Abantu bebazokuphathwa ngendlela ehlukileko ngokuya ngesiqhema sabo, begodu umthetho lo waba sisekelo sebandlululo.&lt;ref&gt;Govender, N. and Reddy, P.S., 2019. Urban regeneration in South Africa-the apartheid legacy and legislative framework re-examined–the case of eThekweni Municipality. ''African Journal of Public Affairs'', ''11''(2), pp.83-102.&lt;/ref&gt; Kodwana bekungasi lula ngaso soke isikhathi ukuqunta bona umuntu uyingcenye yabaphi ubuhlanga, begodu lokhu kwabanga imiraro.

UmThetho weeNdawo weenqhema, 1950 Lo bekumthetho owathoma ukuhlukana hlangana kweentjhaba, khulukhulu eendaweni ezisemadorobheni. Umthetho lo godu ufuna ukususwa kwezinye iinqhema zabantu ziye eendaweni ezibekelwe amaqembu wabo wobuhlanga.UmThetho wokuThuthukiswa kokuZiBusa kwamaBantu, we-1959 UmThetho lo bewuthi iintjhaba ezihlukahlukeneko kufuze zihlale eendaweni ezihlukahlukeneko. Kwasala iphesenteji encani yeSewula Afrika bona abantu abanzima (ebebayinengi labo) bakhe 'amazwe wabo'. Umthetho lo godu wasusa 'amabala amnyama' ngaphakathi kweendawo zabantu abamhlophe, ngokususa boke abantu abamnyama ngaphandle kwedorobha. Ukususwa okwaziwako bekuku-District 6, i-Sophiatown kanye ne-Lady Selborne. Abantu abamnyama laba babe sebefakwa emalokishini angaphandle kwedorobha. Bebangakghoni ukuba nepahla lapha, bayiqatjha kwaphela, ngombana inarha beyingaba ngeyabantu abamhlophe kwaphela. Umthetho lo wabanga ubudisi obukhulu nokusilingeka. Abantu balahlekelwa makhaya wabo, basuswa eendaweni ebegade banazo iminyaka eminengi begodu bathuthelwa eendaweni ezingakathuthukiswa kude nendawo abasebenza kiyo.

=== Eminye imithetho eqakathekileko bekuyi: ===
UmThetho wokuVimbela imitjhado ehlangeneko, 1949

UmThetho wokuTjhugulula ukuZiphatha kumbi, 1950

UmThetho wokuJanyelwa okuhlukileko kwabavowudi, 1951

=== Ukujamelana ngaphambi kwaka-1960 ===
Ukujamelana nebandlululo kwavela kiyo yoke imikhakha, begodu ingasi kwaphela, njengombana kuvame ukucatshangelwa, kilabo abahlangabezana nemiphumela emimbi yokubandlululwa. Ukuhlatjwa kwavela nakwamanye amazwe, begodu amanye wawo anikela isekelo leenhlangano zekululeko zeSewula Afrika. Ezinye zeenhlangano eziqakatheke khulu ezibandakanyeka emzabalazweni wekululeko bekuyi-African National Congress (ANC), i-Pan-Africanist Congress (PAC), i-Inkatha Freedom Party (IFP), i-Black Consciousness Movement (BCM) kanye ne-United Democratic Front (UDF). Bekunama-India nama-Colored (isib. i-Natal Indian Congress (NIC), i-Colored People's Organisation), amaqembu wabantu abamhlophe (isib. i-Armed Resistance Movement (ARM), kanye ne-Black Sash) kanye namaqembu asekelwe esontweni (i-Christian Institute). Sizokucabangela i-ANC.

=== I-ANC ===
I-ANC yabunjwa e-Bloemfontein ngo-1912, msinyana ngemva kwe-Union of South Africa. Ekuthomeni beyibizwa nge-South African Native National Congress (i-SANNC). Kwathonywa njengomkhankaso wabantu abaNzima abaphezulu, okutjho labo abaNzima ebebafundile. Ngo-1919, i-ANC yathumela isithunywa e-London ukuyokuncenga isivumelwano esitjha sabantu abamnyama beSewula Afrika, kodwana azange kube netjhuguluko ebujameni babo

Isithunywa se-South African Native National Congress e-England, ngoMgwengweni 1919 Umthombo wesithombe.Umlando wokujamelana kwe-ANC udlula eengabeni ezintathu. Eyokuthoma bekukukhulumisana nokufaka isibawo; ukuphikiswa kwesibili okunqophileko begodu kokugcina kube yisikhathi somzabalazo ohlomileko. Ngomnyaka ka-1949, ngemva nje kokuthi kwethulwe ibandlululo, i-ANC yathoma indlela yokulwa, lapho i-Youth League idlala indima eqakathekileko. &lt;ref&gt;Suttner, R., 2012. The African National Congress centenary: a long and difficult journey. ''International Affairs'', ''88''(4), pp.719-738.&lt;/ref&gt;I-ANC yethula iHlelo layo lokuSebenza ngo-1949, isekela isenzo sokuteleka, ukutjhikiyela nezinye iinhlobo zokujamelana okungasikho kobudlova. U-[[Nelson Mandela]], u-Oliver Tambo no-Walter Sisulu bathoma ukudlala indima eqakathekileko ku-ANC ngesikhathesi. Ngo-1952 i-ANC yathoma umKhankaso wokuTjhiya. Ijima leli belibiza abantu bona baphule imithetho yebandlululo ngamabomu begodu bazinikele bona babotjhwe.

Bekuthenjwa bona ukwanda kwezibotjhwa kuzokwenza bona ihlelo libhidlike begodu lithole isekelo leentjhabatjhaba le-ANC. Abantu abanzima bangena 'emabhasini amhlophe', basebenzisa 'amathoyilethi amhlophe', bangena 'eendaweni zabamhlophe' begodu bala ukusebenzisa amaphasi. Nanyana abantu abayi-8 000 bagcina bavalelwe ejele, i-ANC azange ibe yingozi embusweni webandlululo.I-ANC yaragela phambili ngendlela efanako hlangana neminyaka yabo-1950, bekwaba kulapho ngo-1959 amanye amalunga ahlukana khona akha i-PAC. Amalunga la bekafuna ukulandela indlela enobudlova neyepi, begodu abona ngasuthi ipumelelo angeze yafinyelelwa ngendlela ye-ANC

== Iinkomba ==
[[Category:Umbuso wegandelelo]]
[[Category:Ipolitiki]]
[[Category:Umlando weSewula Afrika]]
[[Category:Ibandlululo]]
[[Category: Ukubundlulula ngobuhlanga]]</text>
      <sha1>izoynpbckgfqeotlhmznhhhf7sy000s</sha1>
    </revision>
    <revision>
      <id>6053</id>
      <parentid>6052</parentid>
      <timestamp>2025-12-01T07:06:28Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6053</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8444" sha1="s60geqeplxbr2uoit3jsl86f4n82z1f" xml:space="preserve">'''Igama elithi &quot;Ibandlululo&quot;''' tjhugululwe ukusuka elimini lesibhuru okutjho 'ukuhlukana', ibandlululo bekuyimbono eyasekelwa ngurhulumende we-National Party (NP) begodu yathonywa eSewula Afrika ngo-1948.&lt;ref&gt;https://sahistory.org.za/article/history-apartheid-south-africa&lt;/ref&gt; Ibandlululo labawa ukuthuthukiswa okuhlukileko kwamakoro weentjhaba ezihlukahlukeneko eSewula Afrika. Ephepheni bekubonakala ngasuthi kufuna ukuthuthukiswa okulinganako nekululeko yokuveza amasiko, kodwana indlela ebegade isetjenziswa ngayo yenza bona lokhu kungakghonakali. Imithetho yebandlululo yakatelela iintjhaba ezihlukahlukeneko bona zihlale ngokwehlukana begodu zithuthuke ngokwehlukana, begodu ngokungalingani khulu. Ilinge ukuqeda woke umtjhado nokuhlanganiswa komphakathi hlangana namakoro wobuhlanga.&lt;ref&gt;Mhlauli, M.B., Salani, E. and Mokotedi, R., 2015. Understanding apartheid in South Africa through the racial contract. ''International Journal of Asian Social Science'', ''5''(4), pp.203-219.&lt;/ref&gt; Ngesikhathi sebandlululo, ukuba nobungani nomuntu wobuhlanga obuhlukileko bekuletha iinsolo kuwe, nofana okumbi khulu. Ngaphezu kwalokhu, [[ibandlululo]] bekulihlelo lezenhlalakahle ebelihlukumeza khulu inengi labantu, ngombana bebangafani umbala wesikhumba wababusi. Abanengi bebagcinwa ngaphezu kokutlhaga ngombana 'bebangasibo abamhlophe'.

Ngokweenkambisolawulo ezisisekelo, ibandlululo belingafani kangako emthethweni wokuhlukanisa urhulumende weSewula Afrika owawukhona ngaphambi kokuthi i-Afrikaner Nationalist Party ifike emandleni ngo-1948. Umehluko omkhulu kukobana ibandlululo lenze ihlukaniso libe yingcenye yomthetho. Ibandlululo lahlukanisa abantu ngesihlungu nangokugandelela, begodu linehlelo lombuso elithusako lokujezisa labo abangavumelani. Esinye isizathu sokuthi kubayini ibandlululo belibonwa njengelibi khulu ukudlula ukuhlukaniswa, kukuthi ibandlululo lathonywa ngesikhathi lapho amanye amazwe bekatjhiya khona imigomo yebandlululo. Ngaphambi kwePi yesiBili yePhasi inarha yeTjingalanga beyingathatheli phasi kangako ukubandlululwa ngokobuhlanga, begodu i-Afrika beyikoloni ngalesi sikhathi. Ipi yesiBili yePhasi yaveza imiraro yokubandlulula ngokobuhlanga, yenza bona umhlaba ufulathele imigomo enjalo begodu wakhuthaza iimfuno zokususwa kwamakoloni. Kungesikhathi lesi lapho iSewula Afrika yethula khona umthethomgomo oqinileko wobandlululo.

Abantu bavame ukuzibuza bona kubayini umthethomgomo onjalo wethulwe begodu kubayini wasekelwa kangaka. Iinzathu ezihlukahlukeneko zingavezwa ngebandlululo, nanyana zoke zihlobene khulu. Iinzathu ezikulu zilele emibonweni yokuphakama ngokobuhlanga nokwesaba. Ephasini loke, ukubandlululwa ngokobuhlanga kuthonywa mqondo wokobana omunye umhlobo kufuze ube ngaphezu komunye. Imibono enjalo itholakala kiwo woke amaqembu wabantu. Esinye isizathu esikhulu sebandlululo bekukwesaba, njengombana eSewula Afrika abantu abamhlophe bambalwa, begodu inengi belitshwenyekile ngokuthi lingalahlekelwa misebenzi, amasiko nelimi.&lt;ref&gt;https://sahistory.org.za/article/history-apartheid-south-africa&lt;/ref&gt; Lokhu akusiso isizathu sebandlululo, kodwana kuhlathulula bona abantu bebacabanga njani.

=== Imithetho yebandlululo ===
Kwaphasiswa imithetho eminengi ekubunjweni kombuso webandlululo. Nanzi iinsika ezimbalwa ebegade zijame kizo: UmThetho wokuTloliswa kwabantu, 1950 UmThetho lo bewufuna bona abantu batloliswe ngokuya ngokobuhlanga babo. Lokhu kutjho bona umNyango wezeKhaya bewuzokuba nerekhodi labantu ngokuya ngokuthi bamhlophe, banemibala, bamnyama, bama-India nofana bama-Asia. Abantu bebazokuphathwa ngendlela ehlukileko ngokuya ngesiqhema sabo, begodu umthetho lo waba sisekelo sebandlululo.&lt;ref&gt;Govender, N. and Reddy, P.S., 2019. Urban regeneration in South Africa-the apartheid legacy and legislative framework re-examined–the case of eThekweni Municipality. ''African Journal of Public Affairs'', ''11''(2), pp.83-102.&lt;/ref&gt; Kodwana bekungasi lula ngaso soke isikhathi ukuqunta bona umuntu uyingcenye yabaphi ubuhlanga, begodu lokhu kwabanga imiraro.

UmThetho weeNdawo weenqhema, 1950 Lo bekumthetho owathoma ukuhlukana hlangana kweentjhaba, khulukhulu eendaweni ezisemadorobheni. Umthetho lo godu ufuna ukususwa kwezinye iinqhema zabantu ziye eendaweni ezibekelwe amaqembu wabo wobuhlanga.UmThetho wokuThuthukiswa kokuZiBusa kwamaBantu, we-1959 UmThetho lo bewuthi iintjhaba ezihlukahlukeneko kufuze zihlale eendaweni ezihlukahlukeneko. Kwasala iphesenteji encani yeSewula Afrika bona abantu abanzima (ebebayinengi labo) bakhe 'amazwe wabo'. Umthetho lo godu wasusa 'amabala amnyama' ngaphakathi kweendawo zabantu abamhlophe, ngokususa boke abantu abamnyama ngaphandle kwedorobha. Ukususwa okwaziwako bekuku-District 6, i-Sophiatown kanye ne-Lady Selborne. Abantu abamnyama laba babe sebefakwa emalokishini angaphandle kwedorobha. Bebangakghoni ukuba nepahla lapha, bayiqatjha kwaphela, ngombana inarha beyingaba ngeyabantu abamhlophe kwaphela. Umthetho lo wabanga ubudisi obukhulu nokusilingeka. Abantu balahlekelwa makhaya wabo, basuswa eendaweni ebegade banazo iminyaka eminengi begodu bathuthelwa eendaweni ezingakathuthukiswa kude nendawo abasebenza kiyo.

=== Eminye imithetho eqakathekileko bekuyi: ===
UmThetho wokuVimbela imitjhado ehlangeneko, 1949

UmThetho wokuTjhugulula ukuZiphatha kumbi, 1950

UmThetho wokuJanyelwa okuhlukileko kwabavowudi, 1951

=== Ukujamelana ngaphambi kwaka-1960 ===
Ukujamelana nebandlululo kwavela kiyo yoke imikhakha, begodu ingasi kwaphela, njengombana kuvame ukucatshangelwa, kilabo abahlangabezana nemiphumela emimbi yokubandlululwa. Ukuhlatjwa kwavela nakwamanye amazwe, begodu amanye wawo anikela isekelo leenhlangano zekululeko zeSewula Afrika. Ezinye zeenhlangano eziqakatheke khulu ezibandakanyeka emzabalazweni wekululeko bekuyi-African National Congress (ANC), i-Pan-Africanist Congress (PAC), i-Inkatha Freedom Party (IFP), i-Black Consciousness Movement (BCM) kanye ne-United Democratic Front (UDF). Bekunama-India nama-Colored (isib. i-Natal Indian Congress (NIC), i-Colored People's Organisation), amaqembu wabantu abamhlophe (isib. i-Armed Resistance Movement (ARM), kanye ne-Black Sash) kanye namaqembu asekelwe esontweni (i-Christian Institute). Sizokucabangela i-ANC.

=== I-ANC ===
I-ANC yabunjwa e-Bloemfontein ngo-1912, msinyana ngemva kwe-Union of South Africa. Ekuthomeni beyibizwa nge-South African Native National Congress (i-SANNC). Kwathonywa njengomkhankaso wabantu abaNzima abaphezulu, okutjho labo abaNzima ebebafundile. Ngo-1919, i-ANC yathumela isithunywa e-London ukuyokuncenga isivumelwano esitjha sabantu abamnyama beSewula Afrika, kodwana azange kube netjhuguluko ebujameni babo

Isithunywa se-South African Native National Congress e-England, ngoMgwengweni 1919 Umthombo wesithombe.Umlando wokujamelana kwe-ANC udlula eengabeni ezintathu. Eyokuthoma bekukukhulumisana nokufaka isibawo; ukuphikiswa kwesibili okunqophileko begodu kokugcina kube yisikhathi somzabalazo ohlomileko. Ngomnyaka ka-1949, ngemva nje kokuthi kwethulwe ibandlululo, i-ANC yathoma indlela yokulwa, lapho i-Youth League idlala indima eqakathekileko. &lt;ref&gt;Suttner, R., 2012. The African National Congress centenary: a long and difficult journey. ''International Affairs'', ''88''(4), pp.719-738.&lt;/ref&gt;I-ANC yethula iHlelo layo lokuSebenza ngo-1949, isekela isenzo sokuteleka, ukutjhikiyela nezinye iinhlobo zokujamelana okungasikho kobudlova. U-[[Nelson Mandela]], u-Oliver Tambo no-Walter Sisulu bathoma ukudlala indima eqakathekileko ku-ANC ngesikhathesi. Ngo-1952 i-ANC yathoma umKhankaso wokuTjhiya. Ijima leli belibiza abantu bona baphule imithetho yebandlululo ngamabomu begodu bazinikele bona babotjhwe.

Bekuthenjwa bona ukwanda kwezibotjhwa kuzokwenza bona ihlelo libhidlike begodu lithole isekelo leentjhabatjhaba le-ANC. Abantu abanzima bangena 'emabhasini amhlophe', basebenzisa 'amathoyilethi amhlophe', bangena 'eendaweni zabamhlophe' begodu bala ukusebenzisa amaphasi. Nanyana abantu abayi-8 000 bagcina bavalelwe ejele, i-ANC azange ibe yingozi embusweni webandlululo.I-ANC yaragela phambili ngendlela efanako hlangana neminyaka yabo-1950, bekwaba kulapho ngo-1959 amanye amalunga ahlukana khona akha i-PAC. Amalunga la bekafuna ukulandela indlela enobudlova neyepi, begodu abona ngasuthi ipumelelo angeze yafinyelelwa ngendlela ye-ANC

== Iinkomba ==
[[Category:Umbuso wegandelelo]]
[[Category:Ipolitiki]]
[[Category:Umlando weSewula Afrika]]
[[Category:Ibandlululo]]
[[Category: Ukubundlulula ngobuhlanga]]</text>
      <sha1>s60geqeplxbr2uoit3jsl86f4n82z1f</sha1>
    </revision>
    <revision>
      <id>6054</id>
      <parentid>6053</parentid>
      <timestamp>2025-12-01T07:07:54Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6054</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8473" sha1="cwat5zgoorrbzml814r8gmznphqi27r" xml:space="preserve">'''Igama elithi &quot;Ibandlululo&quot;''' tjhugululwe ukusuka elimini lesibhuru okutjho 'ukuhlukana', ibandlululo bekuyimbono eyasekelwa ngurhulumende we-National Party (NP) begodu yathonywa eSewula Afrika ngo-1948.&lt;ref&gt;https://sahistory.org.za/article/history-apartheid-south-africa&lt;/ref&gt; Ibandlululo labawa ukuthuthukiswa okuhlukileko kwamakoro weentjhaba ezihlukahlukeneko eSewula Afrika. Ephepheni bekubonakala ngasuthi kufuna ukuthuthukiswa okulinganako nekululeko yokuveza amasiko, kodwana indlela ebegade isetjenziswa ngayo yenza bona lokhu kungakghonakali. Imithetho yebandlululo yakatelela iintjhaba ezihlukahlukeneko bona zihlale ngokwehlukana begodu zithuthuke ngokwehlukana, begodu ngokungalingani khulu. Ilinge ukuqeda woke umtjhado nokuhlanganiswa komphakathi hlangana namakoro wobuhlanga.&lt;ref&gt;Mhlauli, M.B., Salani, E. and Mokotedi, R., 2015. Understanding apartheid in South Africa through the racial contract. ''International Journal of Asian Social Science'', ''5''(4), pp.203-219.&lt;/ref&gt; Ngesikhathi sebandlululo, ukuba nobungani nomuntu wobuhlanga obuhlukileko bekuletha iinsolo kuwe, nofana okumbi khulu. Ngaphezu kwalokhu, [[ibandlululo]] bekulihlelo lezenhlalakahle ebelihlukumeza khulu inengi labantu, ngombana bebangafani umbala wesikhumba wababusi. Abanengi bebagcinwa ngaphezu kokutlhaga ngombana 'bebangasibo abamhlophe'.

Ngokweenkambisolawulo ezisisekelo, ibandlululo belingafani kangako emthethweni wokuhlukanisa urhulumende weSewula Afrika owawukhona ngaphambi kokuthi i-Afrikaner Nationalist Party ifike emandleni ngo-1948. Umehluko omkhulu kukobana ibandlululo lenze ihlukaniso libe yingcenye yomthetho. Ibandlululo lahlukanisa abantu ngesihlungu nangokugandelela, begodu linehlelo lombuso elithusako lokujezisa labo abangavumelani. Esinye isizathu sokuthi kubayini ibandlululo belibonwa njengelibi khulu ukudlula ukuhlukaniswa, kukuthi ibandlululo lathonywa ngesikhathi lapho amanye amazwe bekatjhiya khona imigomo yebandlululo. Ngaphambi kwePi yesiBili yePhasi inarha yeTjingalanga beyingathatheli phasi kangako [[Ukubandlulula ngobuhlanga|ukubandlulula ngokobuhlanga]], begodu i-Afrika beyikoloni ngalesi sikhathi. Ipi yesiBili yePhasi yaveza imiraro yokubandlulula ngokobuhlanga, yenza bona umhlaba ufulathele imigomo enjalo begodu wakhuthaza iimfuno zokususwa kwamakoloni. Kungesikhathi lesi lapho iSewula Afrika yethula khona umthethomgomo oqinileko wobandlululo.

Abantu bavame ukuzibuza bona kubayini umthethomgomo onjalo wethulwe begodu kubayini wasekelwa kangaka. Iinzathu ezihlukahlukeneko zingavezwa ngebandlululo, nanyana zoke zihlobene khulu. Iinzathu ezikulu zilele emibonweni yokuphakama ngokobuhlanga nokwesaba. Ephasini loke, ukubandlululwa ngokobuhlanga kuthonywa mqondo wokobana omunye umhlobo kufuze ube ngaphezu komunye. Imibono enjalo itholakala kiwo woke amaqembu wabantu. Esinye isizathu esikhulu sebandlululo bekukwesaba, njengombana eSewula Afrika abantu abamhlophe bambalwa, begodu inengi belitshwenyekile ngokuthi lingalahlekelwa misebenzi, amasiko nelimi.&lt;ref&gt;https://sahistory.org.za/article/history-apartheid-south-africa&lt;/ref&gt; Lokhu akusiso isizathu sebandlululo, kodwana kuhlathulula bona abantu bebacabanga njani.

=== Imithetho yebandlululo ===
Kwaphasiswa imithetho eminengi ekubunjweni kombuso webandlululo. Nanzi iinsika ezimbalwa ebegade zijame kizo: UmThetho wokuTloliswa kwabantu, 1950 UmThetho lo bewufuna bona abantu batloliswe ngokuya ngokobuhlanga babo. Lokhu kutjho bona umNyango wezeKhaya bewuzokuba nerekhodi labantu ngokuya ngokuthi bamhlophe, banemibala, bamnyama, bama-India nofana bama-Asia. Abantu bebazokuphathwa ngendlela ehlukileko ngokuya ngesiqhema sabo, begodu umthetho lo waba sisekelo sebandlululo.&lt;ref&gt;Govender, N. and Reddy, P.S., 2019. Urban regeneration in South Africa-the apartheid legacy and legislative framework re-examined–the case of eThekweni Municipality. ''African Journal of Public Affairs'', ''11''(2), pp.83-102.&lt;/ref&gt; Kodwana bekungasi lula ngaso soke isikhathi ukuqunta bona umuntu uyingcenye yabaphi ubuhlanga, begodu lokhu kwabanga imiraro.

UmThetho weeNdawo weenqhema, 1950 Lo bekumthetho owathoma ukuhlukana hlangana kweentjhaba, khulukhulu eendaweni ezisemadorobheni. Umthetho lo godu ufuna ukususwa kwezinye iinqhema zabantu ziye eendaweni ezibekelwe amaqembu wabo wobuhlanga.UmThetho wokuThuthukiswa kokuZiBusa kwamaBantu, we-1959 UmThetho lo bewuthi iintjhaba ezihlukahlukeneko kufuze zihlale eendaweni ezihlukahlukeneko. Kwasala iphesenteji encani yeSewula Afrika bona abantu abanzima (ebebayinengi labo) bakhe 'amazwe wabo'. Umthetho lo godu wasusa 'amabala amnyama' ngaphakathi kweendawo zabantu abamhlophe, ngokususa boke abantu abamnyama ngaphandle kwedorobha. Ukususwa okwaziwako bekuku-District 6, i-Sophiatown kanye ne-Lady Selborne. Abantu abamnyama laba babe sebefakwa emalokishini angaphandle kwedorobha. Bebangakghoni ukuba nepahla lapha, bayiqatjha kwaphela, ngombana inarha beyingaba ngeyabantu abamhlophe kwaphela. Umthetho lo wabanga ubudisi obukhulu nokusilingeka. Abantu balahlekelwa makhaya wabo, basuswa eendaweni ebegade banazo iminyaka eminengi begodu bathuthelwa eendaweni ezingakathuthukiswa kude nendawo abasebenza kiyo.

=== Eminye imithetho eqakathekileko bekuyi: ===
UmThetho wokuVimbela imitjhado ehlangeneko, 1949

UmThetho wokuTjhugulula ukuZiphatha kumbi, 1950

UmThetho wokuJanyelwa okuhlukileko kwabavowudi, 1951

=== Ukujamelana ngaphambi kwaka-1960 ===
Ukujamelana nebandlululo kwavela kiyo yoke imikhakha, begodu ingasi kwaphela, njengombana kuvame ukucatshangelwa, kilabo abahlangabezana nemiphumela emimbi yokubandlululwa. Ukuhlatjwa kwavela nakwamanye amazwe, begodu amanye wawo anikela isekelo leenhlangano zekululeko zeSewula Afrika. Ezinye zeenhlangano eziqakatheke khulu ezibandakanyeka emzabalazweni wekululeko bekuyi-African National Congress (ANC), i-Pan-Africanist Congress (PAC), i-Inkatha Freedom Party (IFP), i-Black Consciousness Movement (BCM) kanye ne-United Democratic Front (UDF). Bekunama-India nama-Colored (isib. i-Natal Indian Congress (NIC), i-Colored People's Organisation), amaqembu wabantu abamhlophe (isib. i-Armed Resistance Movement (ARM), kanye ne-Black Sash) kanye namaqembu asekelwe esontweni (i-Christian Institute). Sizokucabangela i-ANC.

=== I-ANC ===
I-ANC yabunjwa e-Bloemfontein ngo-1912, msinyana ngemva kwe-Union of South Africa. Ekuthomeni beyibizwa nge-South African Native National Congress (i-SANNC). Kwathonywa njengomkhankaso wabantu abaNzima abaphezulu, okutjho labo abaNzima ebebafundile. Ngo-1919, i-ANC yathumela isithunywa e-London ukuyokuncenga isivumelwano esitjha sabantu abamnyama beSewula Afrika, kodwana azange kube netjhuguluko ebujameni babo

Isithunywa se-South African Native National Congress e-England, ngoMgwengweni 1919 Umthombo wesithombe.Umlando wokujamelana kwe-ANC udlula eengabeni ezintathu. Eyokuthoma bekukukhulumisana nokufaka isibawo; ukuphikiswa kwesibili okunqophileko begodu kokugcina kube yisikhathi somzabalazo ohlomileko. Ngomnyaka ka-1949, ngemva nje kokuthi kwethulwe ibandlululo, i-ANC yathoma indlela yokulwa, lapho i-Youth League idlala indima eqakathekileko. &lt;ref&gt;Suttner, R., 2012. The African National Congress centenary: a long and difficult journey. ''International Affairs'', ''88''(4), pp.719-738.&lt;/ref&gt;I-ANC yethula iHlelo layo lokuSebenza ngo-1949, isekela isenzo sokuteleka, ukutjhikiyela nezinye iinhlobo zokujamelana okungasikho kobudlova. U-[[Nelson Mandela]], u-Oliver Tambo no-Walter Sisulu bathoma ukudlala indima eqakathekileko ku-ANC ngesikhathesi. Ngo-1952 i-ANC yathoma umKhankaso wokuTjhiya. Ijima leli belibiza abantu bona baphule imithetho yebandlululo ngamabomu begodu bazinikele bona babotjhwe.

Bekuthenjwa bona ukwanda kwezibotjhwa kuzokwenza bona ihlelo libhidlike begodu lithole isekelo leentjhabatjhaba le-ANC. Abantu abanzima bangena 'emabhasini amhlophe', basebenzisa 'amathoyilethi amhlophe', bangena 'eendaweni zabamhlophe' begodu bala ukusebenzisa amaphasi. Nanyana abantu abayi-8 000 bagcina bavalelwe ejele, i-ANC azange ibe yingozi embusweni webandlululo.I-ANC yaragela phambili ngendlela efanako hlangana neminyaka yabo-1950, bekwaba kulapho ngo-1959 amanye amalunga ahlukana khona akha i-PAC. Amalunga la bekafuna ukulandela indlela enobudlova neyepi, begodu abona ngasuthi ipumelelo angeze yafinyelelwa ngendlela ye-ANC

== Iinkomba ==
[[Category:Umbuso wegandelelo]]
[[Category:Ipolitiki]]
[[Category:Umlando weSewula Afrika]]
[[Category:Ibandlululo]]
[[Category: Ukubundlulula ngobuhlanga]]</text>
      <sha1>cwat5zgoorrbzml814r8gmznphqi27r</sha1>
    </revision>
    <revision>
      <id>6055</id>
      <parentid>6054</parentid>
      <timestamp>2025-12-01T07:10:05Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6055</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8562" sha1="78znfcvm2h9k60g48mveilauqcl71t2" xml:space="preserve">'''Igama elithi &quot;Ibandlululo&quot;''' tjhugululwe ukusuka elimini lesibhuru okutjho 'ukuhlukana', ibandlululo bekuyimbono eyasekelwa ngurhulumende we-National Party (NP) begodu yathonywa eSewula Afrika ngo-1948.&lt;ref&gt;https://sahistory.org.za/article/history-apartheid-south-africa&lt;/ref&gt; Ibandlululo labawa ukuthuthukiswa okuhlukileko kwamakoro weentjhaba ezihlukahlukeneko eSewula Afrika. Ephepheni bekubonakala ngasuthi kufuna ukuthuthukiswa okulinganako nekululeko yokuveza amasiko, kodwana indlela ebegade isetjenziswa ngayo yenza bona lokhu kungakghonakali. Imithetho yebandlululo yakatelela iintjhaba ezihlukahlukeneko bona zihlale ngokwehlukana begodu zithuthuke ngokwehlukana, begodu ngokungalingani khulu. Ilinge ukuqeda woke umtjhado nokuhlanganiswa komphakathi hlangana namakoro wobuhlanga.&lt;ref&gt;Mhlauli, M.B., Salani, E. and Mokotedi, R., 2015. Understanding apartheid in South Africa through the racial contract. ''International Journal of Asian Social Science'', ''5''(4), pp.203-219.&lt;/ref&gt; Ngesikhathi sebandlululo, ukuba nobungani nomuntu wobuhlanga obuhlukileko bekuletha iinsolo kuwe, nofana okumbi khulu. Ngaphezu kwalokhu, [[ibandlululo]] bekulihlelo lezenhlalakahle ebelihlukumeza khulu inengi labantu, ngombana bebangafani umbala wesikhumba wababusi. Abanengi bebagcinwa ngaphezu kokutlhaga ngombana 'bebangasibo abamhlophe'.

Ngokweenkambisolawulo ezisisekelo, ibandlululo belingafani kangako emthethweni wokuhlukanisa urhulumende weSewula Afrika owawukhona ngaphambi kokuthi i-Afrikaner Nationalist Party ifike emandleni ngo-1948. Umehluko omkhulu kukobana ibandlululo lenze ihlukaniso libe yingcenye yomthetho. Ibandlululo lahlukanisa abantu ngesihlungu nangokugandelela, begodu linehlelo lombuso elithusako lokujezisa labo abangavumelani. Esinye isizathu sokuthi kubayini ibandlululo belibonwa njengelibi khulu ukudlula ukuhlukaniswa, kukuthi ibandlululo lathonywa ngesikhathi lapho amanye amazwe bekatjhiya khona imigomo yebandlululo. Ngaphambi kwePi yesiBili yePhasi inarha yeTjingalanga beyingathatheli phasi kangako [[Ukubandlulula ngobuhlanga|ukubandlulula ngokobuhlanga]], begodu i-Afrika beyikoloni ngalesi sikhathi. Ipi yesiBili yePhasi yaveza imiraro yokubandlulula ngokobuhlanga, yenza bona umhlaba ufulathele imigomo enjalo begodu wakhuthaza iimfuno zokususwa kwamakoloni. Kungesikhathi lesi lapho iSewula Afrika yethula khona umthethomgomo oqinileko wobandlululo.

Abantu bavame ukuzibuza bona kubayini umthethomgomo onjalo wethulwe begodu kubayini wasekelwa kangaka. Iinzathu ezihlukahlukeneko zingavezwa ngebandlululo, nanyana zoke zihlobene khulu. Iinzathu ezikulu zilele emibonweni yokuphakama ngokobuhlanga nokwesaba. Ephasini loke, ukubandlululwa ngokobuhlanga kuthonywa mqondo wokobana omunye umhlobo kufuze ube ngaphezu komunye. Imibono enjalo itholakala kiwo woke amaqembu wabantu. Esinye isizathu esikhulu sebandlululo bekukwesaba, njengombana eSewula Afrika abantu abamhlophe bambalwa, begodu inengi belitshwenyekile ngokuthi lingalahlekelwa misebenzi, amasiko nelimi.&lt;ref&gt;https://sahistory.org.za/article/history-apartheid-south-africa&lt;/ref&gt; Lokhu akusiso isizathu sebandlululo, kodwana kuhlathulula bona abantu bebacabanga njani.

=== Imithetho yebandlululo ===
Kwaphasiswa imithetho eminengi ekubunjweni kombuso webandlululo. Nanzi iinsika ezimbalwa ebegade zijame kizo: UmThetho wokuTloliswa kwabantu, 1950 UmThetho lo bewufuna bona abantu batloliswe ngokuya ngokobuhlanga babo. Lokhu kutjho bona umNyango wezeKhaya bewuzokuba nerekhodi labantu ngokuya ngokuthi bamhlophe, banemibala, bamnyama, bama-India nofana bama-Asia. Abantu bebazokuphathwa ngendlela ehlukileko ngokuya ngesiqhema sabo, begodu umthetho lo waba sisekelo sebandlululo.&lt;ref&gt;Govender, N. and Reddy, P.S., 2019. Urban regeneration in South Africa-the apartheid legacy and legislative framework re-examined–the case of eThekweni Municipality. ''African Journal of Public Affairs'', ''11''(2), pp.83-102.&lt;/ref&gt; Kodwana bekungasi lula ngaso soke isikhathi ukuqunta bona umuntu uyingcenye yabaphi ubuhlanga, begodu lokhu kwabanga imiraro.

UmThetho weeNdawo weenqhema, 1950 Lo bekumthetho owathoma ukuhlukana hlangana kweentjhaba, khulukhulu eendaweni ezisemadorobheni. Umthetho lo godu ufuna ukususwa kwezinye iinqhema zabantu ziye eendaweni ezibekelwe amaqembu wabo wobuhlanga.UmThetho wokuThuthukiswa kokuZiBusa kwamaBantu, we-1959 UmThetho lo bewuthi iintjhaba ezihlukahlukeneko kufuze zihlale eendaweni ezihlukahlukeneko. Kwasala iphesenteji encani yeSewula Afrika bona abantu abanzima (ebebayinengi labo) bakhe 'amazwe wabo'. Umthetho lo godu wasusa 'amabala amnyama' ngaphakathi kweendawo zabantu abamhlophe, ngokususa boke abantu abamnyama ngaphandle kwedorobha. Ukususwa okwaziwako bekuku-District 6, i-Sophiatown kanye ne-Lady Selborne. Abantu abamnyama laba babe sebefakwa emalokishini angaphandle kwedorobha. Bebangakghoni ukuba nepahla lapha, bayiqatjha kwaphela, ngombana inarha beyingaba ngeyabantu abamhlophe kwaphela. Umthetho lo wabanga ubudisi obukhulu nokusilingeka. Abantu balahlekelwa makhaya wabo, basuswa eendaweni ebegade banazo iminyaka eminengi begodu bathuthelwa eendaweni ezingakathuthukiswa kude nendawo abasebenza kiyo.

=== Eminye imithetho eqakathekileko bekuyi: ===
[[Isimumathi:Black Lives Matter logo.svg|thumb|Amaphilo wabantu abanzima aqakathekile.]]
UmThetho wokuVimbela imitjhado ehlangeneko, 1949

UmThetho wokuTjhugulula ukuZiphatha kumbi, 1950

UmThetho wokuJanyelwa okuhlukileko kwabavowudi, 1951

=== Ukujamelana ngaphambi kwaka-1960 ===
Ukujamelana nebandlululo kwavela kiyo yoke imikhakha, begodu ingasi kwaphela, njengombana kuvame ukucatshangelwa, kilabo abahlangabezana nemiphumela emimbi yokubandlululwa. Ukuhlatjwa kwavela nakwamanye amazwe, begodu amanye wawo anikela isekelo leenhlangano zekululeko zeSewula Afrika. Ezinye zeenhlangano eziqakatheke khulu ezibandakanyeka emzabalazweni wekululeko bekuyi-African National Congress (ANC), i-Pan-Africanist Congress (PAC), i-Inkatha Freedom Party (IFP), i-Black Consciousness Movement (BCM) kanye ne-United Democratic Front (UDF). Bekunama-India nama-Colored (isib. i-Natal Indian Congress (NIC), i-Colored People's Organisation), amaqembu wabantu abamhlophe (isib. i-Armed Resistance Movement (ARM), kanye ne-Black Sash) kanye namaqembu asekelwe esontweni (i-Christian Institute). Sizokucabangela i-ANC.

=== I-ANC ===
I-ANC yabunjwa e-Bloemfontein ngo-1912, msinyana ngemva kwe-Union of South Africa. Ekuthomeni beyibizwa nge-South African Native National Congress (i-SANNC). Kwathonywa njengomkhankaso wabantu abaNzima abaphezulu, okutjho labo abaNzima ebebafundile. Ngo-1919, i-ANC yathumela isithunywa e-London ukuyokuncenga isivumelwano esitjha sabantu abamnyama beSewula Afrika, kodwana azange kube netjhuguluko ebujameni babo

Isithunywa se-South African Native National Congress e-England, ngoMgwengweni 1919 Umthombo wesithombe.Umlando wokujamelana kwe-ANC udlula eengabeni ezintathu. Eyokuthoma bekukukhulumisana nokufaka isibawo; ukuphikiswa kwesibili okunqophileko begodu kokugcina kube yisikhathi somzabalazo ohlomileko. Ngomnyaka ka-1949, ngemva nje kokuthi kwethulwe ibandlululo, i-ANC yathoma indlela yokulwa, lapho i-Youth League idlala indima eqakathekileko. &lt;ref&gt;Suttner, R., 2012. The African National Congress centenary: a long and difficult journey. ''International Affairs'', ''88''(4), pp.719-738.&lt;/ref&gt;I-ANC yethula iHlelo layo lokuSebenza ngo-1949, isekela isenzo sokuteleka, ukutjhikiyela nezinye iinhlobo zokujamelana okungasikho kobudlova. U-[[Nelson Mandela]], u-Oliver Tambo no-Walter Sisulu bathoma ukudlala indima eqakathekileko ku-ANC ngesikhathesi. Ngo-1952 i-ANC yathoma umKhankaso wokuTjhiya. Ijima leli belibiza abantu bona baphule imithetho yebandlululo ngamabomu begodu bazinikele bona babotjhwe.

Bekuthenjwa bona ukwanda kwezibotjhwa kuzokwenza bona ihlelo libhidlike begodu lithole isekelo leentjhabatjhaba le-ANC. Abantu abanzima bangena 'emabhasini amhlophe', basebenzisa 'amathoyilethi amhlophe', bangena 'eendaweni zabamhlophe' begodu bala ukusebenzisa amaphasi. Nanyana abantu abayi-8 000 bagcina bavalelwe ejele, i-ANC azange ibe yingozi embusweni webandlululo.I-ANC yaragela phambili ngendlela efanako hlangana neminyaka yabo-1950, bekwaba kulapho ngo-1959 amanye amalunga ahlukana khona akha i-PAC. Amalunga la bekafuna ukulandela indlela enobudlova neyepi, begodu abona ngasuthi ipumelelo angeze yafinyelelwa ngendlela ye-ANC

== Iinkomba ==
[[Category:Umbuso wegandelelo]]
[[Category:Ipolitiki]]
[[Category:Umlando weSewula Afrika]]
[[Category:Ibandlululo]]
[[Category: Ukubundlulula ngobuhlanga]]</text>
      <sha1>78znfcvm2h9k60g48mveilauqcl71t2</sha1>
    </revision>
  </page>
  <page>
    <title>Oliver Tambo</title>
    <ns>0</ns>
    <id>1008</id>
    <revision>
      <id>6056</id>
      <timestamp>2025-12-03T07:12:30Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''U-Oliver Reginald Kaizana Tambo''' (owaziwa khulu ngo-Oliver Tambo nofana u-OR) wabelethwa edorobhaneni le-Kantilla, e-Bizana, e-Mpondoland (eQawukeni), esiphandeni se-Eastern Cape, mhlana amalanga ama-27 kuNobayeni 1917. Uyise bekanabafazi abane nabantwana abalitjhumi begodu, nanyana bekangazi ukufunda, bekaphila kuhle. U-Mzimeni Tambo bekathanda amasiko, kodwana wabona nokuqakatheka kwefundo yeTjingalanga. Ngokukhamba kwesikhathi, uMzimeni watjhugulukela ebuKrestini...&quot;</comment>
      <origin>6056</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5535" sha1="lwvm0k09qayp64r11zld8gz0fangjkd" xml:space="preserve">'''U-Oliver Reginald Kaizana Tambo''' (owaziwa khulu ngo-Oliver Tambo nofana u-OR) wabelethwa edorobhaneni le-Kantilla, e-Bizana, e-Mpondoland (eQawukeni), esiphandeni se-Eastern Cape, mhlana amalanga ama-27 kuNobayeni 1917. Uyise bekanabafazi abane nabantwana abalitjhumi begodu, nanyana bekangazi ukufunda, bekaphila kuhle. U-Mzimeni Tambo bekathanda amasiko, kodwana wabona nokuqakatheka kwefundo yeTjingalanga. Ngokukhamba kwesikhathi, uMzimeni watjhugulukela ebuKrestini ngesikhathi unina ka-Oliver besele amKrestu ozinikeleko. Ngemva kokubelethwa kwakhe, u-Oliver wabhabhadiswa ngokuthi ngu-Kaizana, ngemva kwaka-Kaizer Wilhelm we-Germany, amabutho wakhe alwa nama-British ngesikhathi sePi yePhasi yoku-1.&lt;ref&gt;https://sahistory.org.za/people/oliver-tambo&lt;/ref&gt; Lokhu bekuyindlela kayise yokutjengisa ukuphikisana nokubusa kwama-British e-Pondoland ngo-1878. Njengomsana omncani, wanikelwa umsebenzi wokwelusa iinkomo zikayise. Nabelusi abakanye naye, msinyana wafunda ukuzingela iinyoni, ukuzibandakanya ekulwisaneni ngeentonga (lapho bekakwazi khona) nokulingisa iinlwana ngebumba.

=== Ifundo ===
Lokha u-Tambo nakaneminyaka eyisithupha uyise wamtjela bona uzokuthoma isikolo, ebegade siyikhilomitha elilodwa ukusuka ekhaya lakhe. Ngemva kokutlolisa, umfundisi wakhe wakhe wamtjela bona kufuze abe &quot;nebizo lesikolo&quot; begodu uyise wamnikela ibizo elithi-Oliver. UTambo waphasa igreyidi yokuthoma eyabe ibizwa nge''- Sub A'', ngemva kwalokho waya kwesinye isikolo e-Embhobeni. Lapha wathoma ukwaziswa umvumo osemthethweni, owaba msebenzi wepilo yoke nokuzilibazisa. Uyise, obekahlose ukunikela abantwana bakhe ifundo ehle, wabathuthela esikolweni se-Ludeke Methodist, esingaba makhilomitha ali-16 ukusuka ekhaya. Ngezinye iinkhathi uyise bekaboleka u-Tambo ipera lakhe bona aye ngayo esikolweni. Ukurarulula ubudisi bokukhamba ibanga elide ukuya esikolweni uyise wamenza wahlala nemindeni emithathu (ngeenkhathi ezihlukileko), yoke ebegade ihlala eduze nesikolo.

NgoMrhayili 1928, u-Tambo nomfowabo u-Alan babhalisa esikolweni sevangeli se-Anglican Holy Cross e-Flagstaff e-Eastern Cape. Uyise bekangakghoni ukubhadela iindleko zabo, kodwana abafazi ababili be-England ebebangabazi, u-Joyce no-Ruth Goddard, basiza ngokuthumela imali eyi-£10 qobe mnyaka ukubhadela iindleko zemfundo yabo. Ngaphezu kwalokho, omunye wabafowabo abadala ogade asebenza njengesisebenzi esivela eenarheni zangaphandle e-Natal, (nje i-KwaZulu-Natal) naye wathumela ingcenye yomrholo wakhe ukubhadela iindleko ezingezelelweko. Ipilo ka-Tambo yokomoya yakhuliswa e-Holy Cross lapho abhabhadiswa khona njengomKrestu wangena esibayeni se-Anglican.

Esikolweni lesi, uTambo waba mdlali omuhle wekhilikithi nomdlali webholo, begodu waba nedumela elihle njengomdlali. Wabuye waveza ubuhlakani bakhe njengomulwi weswazi. Hlangana nabantwana besikolo esikolweni lesi, bekungu-Fikile Bam, owavalelwa ejele e-Robben Island ngebanga lemisebenzi ye-Non-European Unity Movement (NEUM) begodu wakhula waba negcwetha elidumileko. U-Tambo waphumelela khulu eemfundweeni zakhe kodwana ngebanga lokutlhogeka kwemali wakateleleka bona aphinde ibanga lesithandathu (ibanga lesiTjhumi nanye) kabili nanyana waphasa emzamweni wakhe wokuthoma. Ngo-1934 wasuka waya e-St Peter's Secondary School e-Rosettenville, e-Johannesburg ngokusizwa ngu-Miss Tidmarsh owayengutitjhere wakhe.

Ngaphandle kokuhlanganyela emdlalweni webholo, ithenisi nekhilikithi e-St Peter's, bekalilunga lekhwaya yesikolo. Nakaneminyaka eli-16, ngesikhathi aseholideyini e-Kantolo, u-Tambo nabangani bakhe bakha i-Bizana Students Association (BSA). Wakhethwa njengonobhala wehlangano begodu u-Caledon Mda wakhethwa njengoSihlalo. Umnqopho we-BSA bekukuhlanganisa abafundi ngesikhathi samaholideyi begodu babafake emisebenzini ehlelekileko. U-Tambo wanikelwa isikhundla sokuba nguMphathi omkhulu esikolweni kodwana wala wathatha omunye umfundi. Esikhundleni salokho, wathatha isikhundla seSekela lehloko kaMphathiswa. Ngaleso sikhathi walahla utjwala, wafunga bona angekhe aphinde asele, into ayenza epilwenakhe yoke.&lt;ref&gt;Callinicos, L., 1999. Oliver Tambo and the politics of class, race and ethnicity in the African National Congress. ''African Sociological Review/Revue Africaine de Sociologie'', ''3''(1), pp.130-151.

&lt;/ref&gt; Kwaba nenhlekelele ngesikhatheso njengombana ababelethi bakhe bahlongakala kungakapheli umnyaka.

Ngenyanga kaNovemba 1936, watlola isivivinyo sakhe se-Junior Certificate (JC), kanye nabafundi abanzima nabamhlophe e-Transvaal (manje ebizwa nge-Gauteng). Ngokokuthoma emlandwini, abafundi ababili be-Afrika, omunye ngu-Tambo, baphasa ukuhlolwa kwe-JC ngeklasi lokuthoma. I-Transkei Bhunga (i-Assembly of Chiefs) yamnikela isikolo seminyaka emihlanu se-£30 ngomnyaka. IYunivesithi yeSewula Afrika (i-UNISA) nayo yamnikela imali yokufunda yeminyaka emibili yama-£20. Wabe esethatha iinhlahlubo zebanga letjhumi ngoNobayeni wee-1938, lapho aphasa khona ngephasi lokuthoma.

=== Iminyaka yeyunivesithi ===
U-Tambo ekuthomeni bekafuna ukufunda ngezokwelapha, kodwana ngesikhatheso, akukho sikolo sezokwelapha esiphakemeko esamukela abafundi abanzima emkhakheni loyo. Wakhetha ukufunda izesayensi e-Kholeji ye-Fort Hare ebizwa ngesikhatheso. Kulapho ahlangana khona no-Nelson Mandela, lapho bobabili bebamalunga we-Students Christian Association (SCA). Kusukela emnyakeni wakhe wokuthoma u-Tambo bekafundisa esikolweni seSondarha. Bekabuye abe yingcenye yesiqhema sabafundi abasibhozo ebebavuma umrhatjho wendawo e-Grahamstown, e-Eastern Cape. Ngalesisikhathi u-Tambo bekatjhaywe</text>
      <sha1>lwvm0k09qayp64r11zld8gz0fangjkd</sha1>
    </revision>
    <revision>
      <id>6057</id>
      <parentid>6056</parentid>
      <timestamp>2025-12-03T07:16:04Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6057</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5573" sha1="ny1mnvmxvtshuy664y8jxhuetkz9x2y" xml:space="preserve">'''U-Oliver Reginald Kaizana Tambo''' (owaziwa khulu ngo-Oliver Tambo nofana u-OR) wabelethwa edorobhaneni le-Kantilla, e-Bizana, e-Mpondoland (eQawukeni), esiphandeni se-Eastern Cape, mhlana amalanga ama-27 kuNobayeni 1917. Uyise bekanabafazi abane nabantwana abalitjhumi begodu, nanyana bekangazi ukufunda, bekaphila kuhle. U-Mzimeni Tambo bekathanda amasiko, kodwana wabona nokuqakatheka kwefundo yeTjingalanga. Ngokukhamba kwesikhathi, uMzimeni watjhugulukela ebuKrestini ngesikhathi unina ka-Oliver besele amKrestu ozinikeleko. Ngemva kokubelethwa kwakhe, u-Oliver wabhabhadiswa ngokuthi ngu-Kaizana, ngemva kwaka-Kaizer Wilhelm we-Germany, amabutho wakhe alwa nama-British ngesikhathi sePi yePhasi yoku-1.&lt;ref&gt;https://sahistory.org.za/people/oliver-tambo&lt;/ref&gt; Lokhu bekuyindlela kayise yokutjengisa ukuphikisana nokubusa kwama-British e-Pondoland ngo-1878. Njengomsana omncani, wanikelwa umsebenzi wokwelusa iinkomo zikayise. Nabelusi abakanye naye, msinyana wafunda ukuzingela iinyoni, ukuzibandakanya ekulwisaneni ngeentonga (lapho bekakwazi khona) nokulingisa iinlwana ngebumba.

=== Ifundo ===
Lokha u-Tambo nakaneminyaka eyisithupha uyise wamtjela bona uzokuthoma isikolo, ebegade siyikhilomitha elilodwa ukusuka ekhaya lakhe. Ngemva kokutlolisa, umfundisi wakhe wakhe wamtjela bona kufuze abe &quot;nebizo lesikolo&quot; begodu uyise wamnikela ibizo elithi-Oliver. UTambo waphasa igreyidi yokuthoma eyabe ibizwa nge''- Sub A'', ngemva kwalokho waya kwesinye isikolo e-Embhobeni. Lapha wathoma ukwaziswa umvumo osemthethweni, owaba msebenzi wepilo yoke nokuzilibazisa. Uyise, obekahlose ukunikela abantwana bakhe ifundo ehle, wabathuthela esikolweni se-Ludeke Methodist, esingaba makhilomitha ali-16 ukusuka ekhaya. Ngezinye iinkhathi uyise bekaboleka u-Tambo ipera lakhe bona aye ngayo esikolweni. Ukurarulula ubudisi bokukhamba ibanga elide ukuya esikolweni uyise wamenza wahlala nemindeni emithathu (ngeenkhathi ezihlukileko), yoke ebegade ihlala eduze nesikolo.

NgoMrhayili 1928, u-Tambo nomfowabo u-Alan babhalisa esikolweni sevangeli se-Anglican Holy Cross e-Flagstaff e-Eastern Cape. Uyise bekangakghoni ukubhadela iindleko zabo, kodwana abafazi ababili be-England ebebangabazi, u-Joyce no-Ruth Goddard, basiza ngokuthumela imali eyi-£10 qobe mnyaka ukubhadela iindleko zemfundo yabo. Ngaphezu kwalokho, omunye wabafowabo abadala ogade asebenza njengesisebenzi esivela eenarheni zangaphandle e-Natal, (nje i-KwaZulu-Natal) naye wathumela ingcenye yomrholo wakhe ukubhadela iindleko ezingezelelweko. Ipilo ka-Tambo yokomoya yakhuliswa e-Holy Cross lapho abhabhadiswa khona njengomKrestu wangena esibayeni se-Anglican.

Esikolweni lesi, uTambo waba mdlali omuhle wekhilikithi nomdlali webholo, begodu waba nedumela elihle njengomdlali. Wabuye waveza ubuhlakani bakhe njengomulwi weswazi. Hlangana nabantwana besikolo esikolweni lesi, bekungu-Fikile Bam, owavalelwa ejele [[I-Roben island|i-Robben Island]] ngebanga lemisebenzi ye-Non-European Unity Movement (NEUM) begodu wakhula waba negcwetha elidumileko. U-Tambo waphumelela khulu eemfundweeni zakhe kodwana ngebanga lokutlhogeka kwemali wakateleleka bona aphinde ibanga lesithandathu (ibanga lesiTjhumi nanye) kabili nanyana waphasa emzamweni wakhe wokuthoma. Ngo-1934 wasuka waya e-St Peter's Secondary School e-Rosettenville, e-Johannesburg ngokusizwa ngu-Miss Tidmarsh owayengutitjhere wakhe.

Ngaphandle kokuhlanganyela emdlalweni webholo, ithenisi nekhilikithi e-St Peter's, bekalilunga lekhwaya yesikolo. Nakaneminyaka eli-16, ngesikhathi aseholideyini e-Khotho, u-Tambo nabangani bakhe bakha i-Bizana Students Association (BSA). Wakhethwa njengonobhala wehlangano begodu u-Caledon Mda wakhethwa njengoSihlalo. Umnqopho we-BSA bekukuhlanganisa abafundi ngesikhathi samaholideyi begodu babafake emisebenzini ehlelekileko. U-Tambo wanikelwa isikhundla sokuba nguMphathi omkhulu esikolweni kodwana wala wathatha omunye umfundi. Esikhundleni salokho, wathatha isikhundla seSekela lehloko kaMphathiswa. Ngaleso sikhathi walahla utjwala, wafunga bona angekhe aphinde asele, into ayenza epilwenakhe yoke.&lt;ref&gt;Callinicos, L., 1999. Oliver Tambo and the politics of class, race and ethnicity in the African National Congress. ''African Sociological Review/Revue Africaine de Sociologie'', ''3''(1), pp.130-151.

&lt;/ref&gt; Kwaba nenhlekelele ngesikhatheso njengombana ababelethi bakhe bahlongakala kungakapheli umnyaka.

Ngenyanga kaNovemba 1936, watlola isivivinyo sakhe se-Junior Certificate (JC), kanye nabafundi abanzima nabamhlophe e-Transvaal (manje ebizwa nge-Gauteng). Ngokokuthoma emlandwini, abafundi ababili be-Afrika, omunye ngu-Tambo, baphasa ukuhlolwa kwe-JC ngeklasi lokuthoma. I-Transkei Bhunga (i-Assembly of Chiefs) yamnikela isikolo seminyaka emihlanu se-£30 ngomnyaka. IYunivesithi yeSewula Afrika (i-UNISA) nayo yamnikela imali yokufunda yeminyaka emibili yama-£20. Wabe esethatha iinhlahlubo zebanga letjhumi ngoNobayeni wee-1938, lapho aphasa khona ngephasi lokuthoma.

=== Iminyaka yeyunivesithi ===
U-Tambo ekuthomeni bekafuna ukufunda ngezokwelapha, kodwana ngesikhatheso, akukho sikolo sezokwelapha esiphakemeko esamukela abafundi abanzima emkhakheni loyo. Wakhetha ukufunda izesayensi e-Kholeji ye-Fort Hare ebizwa ngesikhatheso. Kulapho ahlangana khona no-[[Nelson Mandela]], lapho bobabili bebamalunga we-Students Christian Association (SCA). Kusukela emnyakeni wakhe wokuthoma u-Tambo bekafundisa esikolweni seSondarha. Bekabuye abe yingcenye yesiqhema sabafundi abasibhozo ebebavuma umrhatjho wendawo e-Grahamstown, e-Eastern Cape. Ngalesisikhathi u-Tambo bekatjhaywe

== Iinkomba ==</text>
      <sha1>ny1mnvmxvtshuy664y8jxhuetkz9x2y</sha1>
    </revision>
    <revision>
      <id>6058</id>
      <parentid>6057</parentid>
      <timestamp>2025-12-03T07:18:39Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6058</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5632" sha1="0laz0vtksg60e68d9nnrzzyng5951lz" xml:space="preserve">'''U-Oliver Reginald Kaizana Tambo''' (owaziwa khulu ngo-Oliver Tambo nofana u-OR) wabelethwa edorobhaneni le-Kantilla, e-Bizana, e-Mpondoland (eQawukeni), esiphandeni se-Eastern Cape, mhlana amalanga ama-27 kuNobayeni 1917. Uyise bekanabafazi abane nabantwana abalitjhumi begodu, nanyana bekangazi ukufunda, bekaphila kuhle. U-Mzimeni Tambo bekathanda amasiko, kodwana wabona nokuqakatheka kwefundo yeTjingalanga. Ngokukhamba kwesikhathi, uMzimeni watjhugulukela ebuKrestini ngesikhathi unina ka-Oliver besele amKrestu ozinikeleko. Ngemva kokubelethwa kwakhe, u-Oliver wabhabhadiswa ngokuthi ngu-Kaizana, ngemva kwaka-Kaizer Wilhelm we-Germany, amabutho wakhe alwa nama-British ngesikhathi sePi yePhasi yoku-1.&lt;ref&gt;https://sahistory.org.za/people/oliver-tambo&lt;/ref&gt; Lokhu bekuyindlela kayise yokutjengisa ukuphikisana nokubusa kwama-British e-Pondoland ngo-1878. Njengomsana omncani, wanikelwa umsebenzi wokwelusa iinkomo zikayise. Nabelusi abakanye naye, msinyana wafunda ukuzingela iinyoni, ukuzibandakanya ekulwisaneni ngeentonga (lapho bekakwazi khona) nokulingisa iinlwana ngebumba.

=== Ifundo ===
[[Isimumathi:Oliver Tambo (1981).jpg|thumb|Oliver Tambo]]
Lokha u-Tambo nakaneminyaka eyisithupha uyise wamtjela bona uzokuthoma isikolo, ebegade siyikhilomitha elilodwa ukusuka ekhaya lakhe. Ngemva kokutlolisa, umfundisi wakhe wakhe wamtjela bona kufuze abe &quot;nebizo lesikolo&quot; begodu uyise wamnikela ibizo elithi-Oliver. UTambo waphasa igreyidi yokuthoma eyabe ibizwa nge''- Sub A'', ngemva kwalokho waya kwesinye isikolo e-Embhobeni. Lapha wathoma ukwaziswa umvumo osemthethweni, owaba msebenzi wepilo yoke nokuzilibazisa. Uyise, obekahlose ukunikela abantwana bakhe ifundo ehle, wabathuthela esikolweni se-Ludeke Methodist, esingaba makhilomitha ali-16 ukusuka ekhaya. Ngezinye iinkhathi uyise bekaboleka u-Tambo ipera lakhe bona aye ngayo esikolweni. Ukurarulula ubudisi bokukhamba ibanga elide ukuya esikolweni uyise wamenza wahlala nemindeni emithathu (ngeenkhathi ezihlukileko), yoke ebegade ihlala eduze nesikolo. 

NgoMrhayili 1928, u-Tambo nomfowabo u-Alan babhalisa esikolweni sevangeli se-Anglican Holy Cross e-Flagstaff e-Eastern Cape. Uyise bekangakghoni ukubhadela iindleko zabo, kodwana abafazi ababili be-England ebebangabazi, u-Joyce no-Ruth Goddard, basiza ngokuthumela imali eyi-£10 qobe mnyaka ukubhadela iindleko zemfundo yabo. Ngaphezu kwalokho, omunye wabafowabo abadala ogade asebenza njengesisebenzi esivela eenarheni zangaphandle e-Natal, (nje i-KwaZulu-Natal) naye wathumela ingcenye yomrholo wakhe ukubhadela iindleko ezingezelelweko. Ipilo ka-Tambo yokomoya yakhuliswa e-Holy Cross lapho abhabhadiswa khona njengomKrestu wangena esibayeni se-Anglican.

Esikolweni lesi, uTambo waba mdlali omuhle wekhilikithi nomdlali webholo, begodu waba nedumela elihle njengomdlali. Wabuye waveza ubuhlakani bakhe njengomulwi weswazi. Hlangana nabantwana besikolo esikolweni lesi, bekungu-Fikile Bam, owavalelwa ejele [[I-Roben island|i-Robben Island]] ngebanga lemisebenzi ye-Non-European Unity Movement (NEUM) begodu wakhula waba negcwetha elidumileko. U-Tambo waphumelela khulu eemfundweeni zakhe kodwana ngebanga lokutlhogeka kwemali wakateleleka bona aphinde ibanga lesithandathu (ibanga lesiTjhumi nanye) kabili nanyana waphasa emzamweni wakhe wokuthoma. Ngo-1934 wasuka waya e-St Peter's Secondary School e-Rosettenville, e-Johannesburg ngokusizwa ngu-Miss Tidmarsh owayengutitjhere wakhe.

Ngaphandle kokuhlanganyela emdlalweni webholo, ithenisi nekhilikithi e-St Peter's, bekalilunga lekhwaya yesikolo. Nakaneminyaka eli-16, ngesikhathi aseholideyini e-Khotho, u-Tambo nabangani bakhe bakha i-Bizana Students Association (BSA). Wakhethwa njengonobhala wehlangano begodu u-Caledon Mda wakhethwa njengoSihlalo. Umnqopho we-BSA bekukuhlanganisa abafundi ngesikhathi samaholideyi begodu babafake emisebenzini ehlelekileko. U-Tambo wanikelwa isikhundla sokuba nguMphathi omkhulu esikolweni kodwana wala wathatha omunye umfundi. Esikhundleni salokho, wathatha isikhundla seSekela lehloko kaMphathiswa. Ngaleso sikhathi walahla utjwala, wafunga bona angekhe aphinde asele, into ayenza epilwenakhe yoke.&lt;ref&gt;Callinicos, L., 1999. Oliver Tambo and the politics of class, race and ethnicity in the African National Congress. ''African Sociological Review/Revue Africaine de Sociologie'', ''3''(1), pp.130-151.

&lt;/ref&gt; Kwaba nenhlekelele ngesikhatheso njengombana ababelethi bakhe bahlongakala kungakapheli umnyaka.

Ngenyanga kaNovemba 1936, watlola isivivinyo sakhe se-Junior Certificate (JC), kanye nabafundi abanzima nabamhlophe e-Transvaal (manje ebizwa nge-Gauteng). Ngokokuthoma emlandwini, abafundi ababili be-Afrika, omunye ngu-Tambo, baphasa ukuhlolwa kwe-JC ngeklasi lokuthoma. I-Transkei Bhunga (i-Assembly of Chiefs) yamnikela isikolo seminyaka emihlanu se-£30 ngomnyaka. IYunivesithi yeSewula Afrika (i-UNISA) nayo yamnikela imali yokufunda yeminyaka emibili yama-£20. Wabe esethatha iinhlahlubo zebanga letjhumi ngoNobayeni wee-1938, lapho aphasa khona ngephasi lokuthoma.

=== Iminyaka yeyunivesithi ===
U-Tambo ekuthomeni bekafuna ukufunda ngezokwelapha, kodwana ngesikhatheso, akukho sikolo sezokwelapha esiphakemeko esamukela abafundi abanzima emkhakheni loyo. Wakhetha ukufunda izesayensi e-Kholeji ye-Fort Hare ebizwa ngesikhatheso. Kulapho ahlangana khona no-[[Nelson Mandela]], lapho bobabili bebamalunga we-Students Christian Association (SCA). Kusukela emnyakeni wakhe wokuthoma u-Tambo bekafundisa esikolweni seSondarha. Bekabuye abe yingcenye yesiqhema sabafundi abasibhozo ebebavuma umrhatjho wendawo e-Grahamstown, e-Eastern Cape. Ngalesisikhathi u-Tambo bekatjhaywe

== Iinkomba ==</text>
      <sha1>0laz0vtksg60e68d9nnrzzyng5951lz</sha1>
    </revision>
    <revision>
      <id>6059</id>
      <parentid>6058</parentid>
      <timestamp>2025-12-03T07:21:00Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>6059</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5742" sha1="en6grptjj8q3x8suusao26gotmykn4p" xml:space="preserve">'''U-Oliver Reginald Kaizana Tambo''' (owaziwa khulu ngo-Oliver Tambo nofana u-OR) wabelethwa edorobhaneni le-Kantilla, e-Bizana, e-Mpondoland (eQawukeni), esiphandeni se-Eastern Cape, mhlana amalanga ama-27 kuNobayeni 1917. Uyise bekanabafazi abane nabantwana abalitjhumi begodu, nanyana bekangazi ukufunda, bekaphila kuhle. U-Mzimeni Tambo bekathanda amasiko, kodwana wabona nokuqakatheka kwefundo yeTjingalanga. Ngokukhamba kwesikhathi, uMzimeni watjhugulukela ebuKrestini ngesikhathi unina ka-Oliver besele amKrestu ozinikeleko. Ngemva kokubelethwa kwakhe, u-Oliver wabhabhadiswa ngokuthi ngu-Kaizana, ngemva kwaka-Kaizer Wilhelm we-Germany, amabutho wakhe alwa nama-British ngesikhathi sePi yePhasi yoku-1.&lt;ref&gt;https://sahistory.org.za/people/oliver-tambo&lt;/ref&gt; Lokhu bekuyindlela kayise yokutjengisa ukuphikisana nokubusa kwama-British e-Pondoland ngo-1878. Njengomsana omncani, wanikelwa umsebenzi wokwelusa iinkomo zikayise. Nabelusi abakanye naye, msinyana wafunda ukuzingela iinyoni, ukuzibandakanya ekulwisaneni ngeentonga (lapho bekakwazi khona) nokulingisa iinlwana ngebumba.

=== Ifundo ===
[[Isimumathi:Oliver Tambo (1981).jpg|thumb|Oliver Tambo]]
Lokha u-Tambo nakaneminyaka eyisithupha uyise wamtjela bona uzokuthoma isikolo, ebegade siyikhilomitha elilodwa ukusuka ekhaya lakhe. Ngemva kokutlolisa, umfundisi wakhe wakhe wamtjela bona kufuze abe &quot;nebizo lesikolo&quot; begodu uyise wamnikela ibizo elithi-Oliver. UTambo waphasa igreyidi yokuthoma eyabe ibizwa nge''- Sub A'', ngemva kwalokho waya kwesinye isikolo e-Embhobeni. Lapha wathoma ukwaziswa umvumo osemthethweni, owaba msebenzi wepilo yoke nokuzilibazisa. Uyise, obekahlose ukunikela abantwana bakhe ifundo ehle, wabathuthela esikolweni se-Ludeke Methodist, esingaba makhilomitha ali-16 ukusuka ekhaya. Ngezinye iinkhathi uyise bekaboleka u-Tambo ipera lakhe bona aye ngayo esikolweni. Ukurarulula ubudisi bokukhamba ibanga elide ukuya esikolweni uyise wamenza wahlala nemindeni emithathu (ngeenkhathi ezihlukileko), yoke ebegade ihlala eduze nesikolo. 

NgoMrhayili 1928, u-Tambo nomfowabo u-Alan babhalisa esikolweni sevangeli se-Anglican Holy Cross e-Flagstaff e-Eastern Cape. Uyise bekangakghoni ukubhadela iindleko zabo, kodwana abafazi ababili be-England ebebangabazi, u-Joyce no-Ruth Goddard, basiza ngokuthumela imali eyi-£10 qobe mnyaka ukubhadela iindleko zemfundo yabo. Ngaphezu kwalokho, omunye wabafowabo abadala ogade asebenza njengesisebenzi esivela eenarheni zangaphandle e-Natal, (nje i-KwaZulu-Natal) naye wathumela ingcenye yomrholo wakhe ukubhadela iindleko ezingezelelweko. Ipilo ka-Tambo yokomoya yakhuliswa e-Holy Cross lapho abhabhadiswa khona njengomKrestu wangena esibayeni se-Anglican.

Esikolweni lesi, uTambo waba mdlali omuhle wekhilikithi nomdlali webholo, begodu waba nedumela elihle njengomdlali. Wabuye waveza ubuhlakani bakhe njengomulwi weswazi. Hlangana nabantwana besikolo esikolweni lesi, bekungu-Fikile Bam, owavalelwa ejele [[I-Roben island|i-Robben Island]] ngebanga lemisebenzi ye-Non-European Unity Movement (NEUM) begodu wakhula waba negcwetha elidumileko. U-Tambo waphumelela khulu eemfundweeni zakhe kodwana ngebanga lokutlhogeka kwemali wakateleleka bona aphinde ibanga lesithandathu (ibanga lesiTjhumi nanye) kabili nanyana waphasa emzamweni wakhe wokuthoma. Ngo-1934 wasuka waya e-St Peter's Secondary School e-Rosettenville, e-Johannesburg ngokusizwa ngu-Miss Tidmarsh owayengutitjhere wakhe.

Ngaphandle kokuhlanganyela emdlalweni webholo, ithenisi nekhilikithi e-St Peter's, bekalilunga lekhwaya yesikolo. Nakaneminyaka eli-16, ngesikhathi aseholideyini e-Khotho, u-Tambo nabangani bakhe bakha i-Bizana Students Association (BSA). Wakhethwa njengonobhala wehlangano begodu u-Caledon Mda wakhethwa njengoSihlalo. Umnqopho we-BSA bekukuhlanganisa abafundi ngesikhathi samaholideyi begodu babafake emisebenzini ehlelekileko. U-Tambo wanikelwa isikhundla sokuba nguMphathi omkhulu esikolweni kodwana wala wathatha omunye umfundi. Esikhundleni salokho, wathatha isikhundla seSekela lehloko kaMphathiswa. Ngaleso sikhathi walahla utjwala, wafunga bona angekhe aphinde asele, into ayenza epilwenakhe yoke.&lt;ref&gt;Callinicos, L., 1999. Oliver Tambo and the politics of class, race and ethnicity in the African National Congress. ''African Sociological Review/Revue Africaine de Sociologie'', ''3''(1), pp.130-151.

&lt;/ref&gt; Kwaba nenhlekelele ngesikhatheso njengombana ababelethi bakhe bahlongakala kungakapheli umnyaka.

Ngenyanga kaNovemba 1936, watlola isivivinyo sakhe se-Junior Certificate (JC), kanye nabafundi abanzima nabamhlophe e-Transvaal (manje ebizwa nge-Gauteng). Ngokokuthoma emlandwini, abafundi ababili be-Afrika, omunye ngu-Tambo, baphasa ukuhlolwa kwe-JC ngeklasi lokuthoma. I-Transkei Bhunga (i-Assembly of Chiefs) yamnikela isikolo seminyaka emihlanu se-£30 ngomnyaka. IYunivesithi yeSewula Afrika (i-UNISA) nayo yamnikela imali yokufunda yeminyaka emibili yama-£20. Wabe esethatha iinhlahlubo zebanga letjhumi ngoNobayeni wee-1938, lapho aphasa khona ngephasi lokuthoma.

=== Iminyaka yeyunivesithi ===
U-Tambo ekuthomeni bekafuna ukufunda ngezokwelapha, kodwana ngesikhatheso, akukho sikolo sezokwelapha esiphakemeko esamukela abafundi abanzima emkhakheni loyo. Wakhetha ukufunda izesayensi e-Kholeji ye-Fort Hare ebizwa ngesikhatheso. Kulapho ahlangana khona no-[[Nelson Mandela]], lapho bobabili bebamalunga we-Students Christian Association (SCA). Kusukela emnyakeni wakhe wokuthoma u-Tambo bekafundisa esikolweni seSondarha. Bekabuye abe yingcenye yesiqhema sabafundi abasibhozo ebebavuma umrhatjho wendawo e-Grahamstown, e-Eastern Cape. Ngalesisikhathi u-Tambo bekatjhaywe

== Iinkomba ==
[[Category: ANC]]
[[Category:Oliver Tambo]]
[[Category:Umlando weSewula Afrika]]
[[Category:i-Robben island]]</text>
      <sha1>en6grptjj8q3x8suusao26gotmykn4p</sha1>
    </revision>
    <revision>
      <id>6060</id>
      <parentid>6059</parentid>
      <timestamp>2025-12-03T07:27:36Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6060</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8419" sha1="2ry73z40ifrj5ud4f51mc5o1qmzv4ly" xml:space="preserve">'''U-Oliver Reginald Kaizana Tambo''' (owaziwa khulu ngo-Oliver Tambo nofana u-OR) wabelethwa edorobhaneni le-Kantilla, e-Bizana, e-Mpondoland (eQawukeni), esiphandeni se-Eastern Cape, mhlana amalanga ama-27 kuNobayeni 1917. Uyise bekanabafazi abane nabantwana abalitjhumi begodu, nanyana bekangazi ukufunda, bekaphila kuhle. U-Mzimeni Tambo bekathanda amasiko, kodwana wabona nokuqakatheka kwefundo yeTjingalanga. Ngokukhamba kwesikhathi, uMzimeni watjhugulukela ebuKrestini ngesikhathi unina ka-Oliver besele amKrestu ozinikeleko. Ngemva kokubelethwa kwakhe, u-Oliver wabhabhadiswa ngokuthi ngu-Kaizana, ngemva kwaka-Kaizer Wilhelm we-Germany, amabutho wakhe alwa nama-British ngesikhathi sePi yePhasi yoku-1.&lt;ref&gt;https://sahistory.org.za/people/oliver-tambo&lt;/ref&gt; Lokhu bekuyindlela kayise yokutjengisa ukuphikisana nokubusa kwama-British e-Pondoland ngo-1878. Njengomsana omncani, wanikelwa umsebenzi wokwelusa iinkomo zikayise. Nabelusi abakanye naye, msinyana wafunda ukuzingela iinyoni, ukuzibandakanya ekulwisaneni ngeentonga (lapho bekakwazi khona) nokulingisa iinlwana ngebumba.

=== Ifundo ===
[[Isimumathi:Oliver Tambo (1981).jpg|thumb|Oliver Tambo]]
Lokha u-Tambo nakaneminyaka eyisithupha uyise wamtjela bona uzokuthoma isikolo, ebegade siyikhilomitha elilodwa ukusuka ekhaya lakhe. Ngemva kokutlolisa, umfundisi wakhe wakhe wamtjela bona kufuze abe &quot;nebizo lesikolo&quot; begodu uyise wamnikela ibizo elithi-Oliver. UTambo waphasa igreyidi yokuthoma eyabe ibizwa nge''- Sub A'', ngemva kwalokho waya kwesinye isikolo e-Embhobeni. Lapha wathoma ukwaziswa umvumo osemthethweni, owaba msebenzi wepilo yoke nokuzilibazisa. Uyise, obekahlose ukunikela abantwana bakhe ifundo ehle, wabathuthela esikolweni se-Ludeke Methodist, esingaba makhilomitha ali-16 ukusuka ekhaya. Ngezinye iinkhathi uyise bekaboleka u-Tambo ipera lakhe bona aye ngayo esikolweni. Ukurarulula ubudisi bokukhamba ibanga elide ukuya esikolweni uyise wamenza wahlala nemindeni emithathu (ngeenkhathi ezihlukileko), yoke ebegade ihlala eduze nesikolo. 

NgoMrhayili 1928, u-Tambo nomfowabo u-Alan babhalisa esikolweni sevangeli se-Anglican Holy Cross e-Flagstaff e-Eastern Cape. Uyise bekangakghoni ukubhadela iindleko zabo, kodwana abafazi ababili be-England ebebangabazi, u-Joyce no-Ruth Goddard, basiza ngokuthumela imali eyi-£10 qobe mnyaka ukubhadela iindleko zemfundo yabo. Ngaphezu kwalokho, omunye wabafowabo abadala ogade asebenza njengesisebenzi esivela eenarheni zangaphandle e-Natal, (nje i-KwaZulu-Natal) naye wathumela ingcenye yomrholo wakhe ukubhadela iindleko ezingezelelweko. Ipilo ka-Tambo yokomoya yakhuliswa e-Holy Cross lapho abhabhadiswa khona njengomKrestu wangena esibayeni se-Anglican.

Esikolweni lesi, uTambo waba mdlali omuhle wekhilikithi nomdlali webholo, begodu waba nedumela elihle njengomdlali. Wabuye waveza ubuhlakani bakhe njengomulwi weswazi. Hlangana nabantwana besikolo esikolweni lesi, bekungu-Fikile Bam, owavalelwa ejele [[I-Roben island|i-Robben Island]] ngebanga lemisebenzi ye-Non-European Unity Movement (NEUM) begodu wakhula waba negcwetha elidumileko. U-Tambo waphumelela khulu eemfundweeni zakhe kodwana ngebanga lokutlhogeka kwemali wakateleleka bona aphinde ibanga lesithandathu (ibanga lesiTjhumi nanye) kabili nanyana waphasa emzamweni wakhe wokuthoma. Ngo-1934 wasuka waya e-St Peter's Secondary School e-Rosettenville, e-Johannesburg ngokusizwa ngu-Miss Tidmarsh owayengutitjhere wakhe.

Ngaphandle kokuhlanganyela emdlalweni webholo, ithenisi nekhilikithi e-St Peter's, bekalilunga lekhwaya yesikolo. Nakaneminyaka eli-16, ngesikhathi aseholideyini e-Khotho, u-Tambo nabangani bakhe bakha i-Bizana Students Association (BSA). Wakhethwa njengonobhala wehlangano begodu u-Caledon Mda wakhethwa njengoSihlalo. Umnqopho we-BSA bekukuhlanganisa abafundi ngesikhathi samaholideyi begodu babafake emisebenzini ehlelekileko. U-Tambo wanikelwa isikhundla sokuba nguMphathi omkhulu esikolweni kodwana wala wathatha omunye umfundi. Esikhundleni salokho, wathatha isikhundla seSekela lehloko kaMphathiswa. Ngaleso sikhathi walahla utjwala, wafunga bona angekhe aphinde asele, into ayenza epilwenakhe yoke.&lt;ref&gt;Callinicos, L., 1999. Oliver Tambo and the politics of class, race and ethnicity in the African National Congress. ''African Sociological Review/Revue Africaine de Sociologie'', ''3''(1), pp.130-151.

&lt;/ref&gt; Kwaba nenhlekelele ngesikhatheso njengombana ababelethi bakhe bahlongakala kungakapheli umnyaka.

Ngenyanga kaNovemba 1936, watlola isivivinyo sakhe se-Junior Certificate (JC), kanye nabafundi abanzima nabamhlophe e-Transvaal (manje ebizwa nge-Gauteng). Ngokokuthoma emlandwini, abafundi ababili be-Afrika, omunye ngu-Tambo, baphasa ukuhlolwa kwe-JC ngeklasi lokuthoma. I-Transkei Bhunga (i-Assembly of Chiefs) yamnikela isikolo seminyaka emihlanu se-£30 ngomnyaka. IYunivesithi yeSewula Afrika (i-UNISA) nayo yamnikela imali yokufunda yeminyaka emibili yama-£20. Wabe esethatha iinhlahlubo zebanga letjhumi ngoNobayeni wee-1938, lapho aphasa khona ngephasi lokuthoma.

=== Iminyaka yeyunivesithi ===
U-Tambo ekuthomeni bekafuna ukufunda ngezokwelapha, kodwana ngesikhatheso, akukho sikolo sezokwelapha esiphakemeko esamukela abafundi abanzima emkhakheni loyo. Wakhetha ukufunda izesayensi e-Kholeji ye-Fort Hare ebizwa ngesikhatheso. Kulapho ahlangana khona no-[[Nelson Mandela]], lapho bobabili bebamalunga we-Students Christian Association (SCA). Kusukela emnyakeni wakhe wokuthoma u-Tambo bekafundisa esikolweni seSondarha. Bekabuye abe yingcenye yesiqhema sabafundi abasibhozo ebebavuma umrhatjho wendawo e-Grahamstown, e-Eastern Cape. Ngalesisikhathi u-Tambo bekatjhaywe.

U-Tambo nehlangano ye-ANC

Emhlanganweni we-ANC wango-1954, u-Tambo wakhethwa njengoNobhala Jikelele. Ngalowo mnyaka u-Tambo wathola umyalo wokuvimbela ovela kuMbuso. Nanyana kunjalo, wahlala azibandakanya emsebenzini wangemuva asebenza njengelunga leKomidi yeNarha yeSebenzi eyabhala iTjhatha yeNkululeko, ngemva kokufaka isandla nokubonisana okukhulu enarheni yoke. Lokhu bekwenzeka ngaphambi kwe-Congress of the People (COP), eyabizwa ngoMgwengweni we-1955, lapho i-Charter yamukelwa khona. Lokha i-COP nayibizwako, u-Tambo akhenge akghone ukuza ngebanga lemikhawulo ebegade ibekwe yona begodu kwafanela bona aqale imisebenzi asendaweni yokucasha ekhaya laka-Stanley Lollan e-Kliptown, eqale isikwere lapho i-Congress beyenza khona.

Ngo-1955 u-Tambo wathembisana no-Adelaide Frances Tsukhudu, umhlengikazi osebenza esibhedlela se-Baragwanath. Umtjhado wabo bewubekelwe mhlazi-22 kuNobayeni, 1956, kodwana pheze wahlehliswa ngombana u-Tambo wabotjhwa ngamacala wokuvukela umbuso mhlazi-5 kuNobayeni 1956. Ngemva kobana boke abasolwa banikelwe ibheyili, umtjhado wenzeka njengombana bekuhleliwe. Ngemva kokulalelwa kwecala lokuthoma uTambo noNduna u-Albert Luthuli bakhululwa. Amalunga we-ANC ali-155 abekwe amacala kilokho okwaziwa ngokuthi yi-1956 Treason Trial.

Ngo-1957, u-Duma Nokwe wathatha isikhundla saka-Tambo waba nguNobhala Jikelele we-ANC, ngesikhathi u-Tambo wakhethwa njengeSekela likaMongameli we-ANC. Kusukela ngoMrhayili wee-1958, u-Tambo bekathulule e-Adelaide bona i-ANC beyifuna bona yena nomndenakhe baye ekuthunjweni. Njenganje iinthandani bezinabantwana abathathu, u-Thembi, u-Dali no-Tselane.

Ngesikhathi somhlangano we-ANC kaNobayeni we-1958 iKomidi yeNarha (i-NEC) yakhetha u-Tambo bona abe ngusihlalo womhlangano. Isiqhema samalunga we-ANC wangaphambilini, aziwa ngokuthi ma-Africanists, alinga ukuphazamisa umhlangano kodwana u-Tambo wakghona ukulawula umhlangano okwenza bona bagcine baphume. Ama-Africanist ahlukana ne-ANC begodu ngoMrhayili 1959 azibumba njenge-Pan Africanist Congress (PAC). Ngemva kweminyaka elitjhumi, u-Tambo watlola ukugxeka okukhulu kwe-PAC, wayisola ngokuthi ihlukanisa abantu begodu ayinasibopho.

Ngo-1959, u-Tambo bekakhokhela iKhomishini yomThethosisekelo ye-ANC. Ikhomitjhini ye-Tambo iphakamise bona i-ANC’S Women’s League (i-ANCWL) ne-ANCYL iqakathekiswe khulu ngokomthethosisekelo, begodu yavuma ukungabandlululi ngokobuhlanga kanye ne-Freedom Charter, hlangana nezinye izinto. Ukubuyekezwa komthethosisekelo we-ANC kwaziwa ngokuthi mThethosisekelo we-Tambo. Ngaso soke isikhathi bekufuze athwale umthwalo womsebenzi wezepolotiki nomsebenzi wefemu yezomthetho yedwa, ngombana u-Mandela bekasathonisiswa.

== Iinkomba ==
[[Category: ANC]]
[[Category:Oliver Tambo]]
[[Category:Umlando weSewula Afrika]]
[[Category:i-Robben island]]</text>
      <sha1>2ry73z40ifrj5ud4f51mc5o1qmzv4ly</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:PK2</title>
    <ns>2</ns>
    <id>1009</id>
    <revision>
      <id>6061</id>
      <timestamp>2025-12-06T23:38:02Z</timestamp>
      <contributor>
        <username>PK2</username>
        <id>303</id>
      </contributor>
      <comment>Created page with &quot;{| class=&quot;wikitable&quot; style=&quot;font-size:85%&quot; |- | [[User:PK2/sandbox|This]] is where my sandbox pages in different languages are |}  ;&lt;div class=&quot;center&quot; style=&quot;width:auto; margin-left:auto; margin-right:auto; font-size:85%&quot;&gt;My user pages in different languages by language code&lt;/div&gt; {| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot; |+ A |- | [[:ab:User:PK2|User page]] in [[:en:Abkhaz language|Abkhaz]]&lt;br /&gt;(code: &lt;code&gt;ab&lt;/code&gt;) | [[:ace:User:PK2|User page]]...&quot;</comment>
      <origin>6061</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="35667" sha1="ksq9iz3bc6ghi7ymjlvzgy003mc7ccf" xml:space="preserve">{| class=&quot;wikitable&quot; style=&quot;font-size:85%&quot;
|-
| [[User:PK2/sandbox|This]] is where my sandbox pages in different languages are
|}

;&lt;div class=&quot;center&quot; style=&quot;width:auto; margin-left:auto; margin-right:auto; font-size:85%&quot;&gt;My user pages in different languages by language code&lt;/div&gt;
{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ A
|-
| [[:ab:User:PK2|User page]] in [[:en:Abkhaz language|Abkhaz]]&lt;br /&gt;(code: &lt;code&gt;ab&lt;/code&gt;)
| [[:ace:User:PK2|User page]] in [[:en:Acehnese language|Acehnese]]&lt;br /&gt;(code: &lt;code&gt;ace&lt;/code&gt;)
| [[:ady:User:PK2|User page]] in [[:en:Adyghe language|Adyghe]]&lt;br /&gt;(code: &lt;code&gt;ady&lt;/code&gt;)
| [[:af:User:PK2|User page]] in [[:en:Afrikaans|Afrikaans]]&lt;br /&gt;(code: &lt;code&gt;af&lt;/code&gt;)
| [[:als:User:PK2|User page]] in [[:en:Alemannic German|Alemannic German]]&lt;br /&gt;(code: &lt;code&gt;als&lt;/code&gt;)
| [[:alt:User:PK2|User page]] in [[:en:Southern Altai language|Southern Altai]]&lt;br /&gt;(code: &lt;code&gt;alt&lt;/code&gt;)
| [[:am:User:PK2|User page]] in [[:en:Amharic|Amharic]]&lt;br /&gt;(code: &lt;code&gt;am&lt;/code&gt;)
| [[:ami:User:PK2|User page]] in [[:en:Amis language|Amis]]&lt;br /&gt;(code: &lt;code&gt;ami&lt;/code&gt;)
| [[:an:User:PK2|User page]] in [[:en:Aragonese language|Aragonese]]&lt;br /&gt;(code: &lt;code&gt;an&lt;/code&gt;)
| [[:ang:User:PK2|User page]] in [[:en:Old English|Old English]]&lt;br /&gt;(code: &lt;code&gt;ang&lt;/code&gt;)
|-
| [[:ann:User:PK2|User page]] in [[:en:Obolo language|Obolo]]&lt;br /&gt;(code: &lt;code&gt;ann&lt;/code&gt;)
| [[:anp:User:PK2|User page]] in [[:en:Angika|Angika]]&lt;br /&gt;(code: &lt;code&gt;anp&lt;/code&gt;)
| [[:ar:User:PK2|User page]] in [[:en:Arabic|Arabic]]&lt;br /&gt;(code: &lt;code&gt;ar&lt;/code&gt;)
| [[:arc:User:PK2|User page]] in [[:en:Aramaic|Aramaic]] ([[:en:Syriac language|Syriac]])&lt;br /&gt;(code: &lt;code&gt;arc&lt;/code&gt;)
| [[:ary:User:PK2|User page]] in [[:en:Moroccan Arabic|Moroccan Arabic]]&lt;br /&gt;(code: &lt;code&gt;ary&lt;/code&gt;)
| [[:arz:User:PK2|User page]] in [[:en:Egyptian Arabic|Egyptian Arabic]]&lt;br /&gt;(code: &lt;code&gt;arz&lt;/code&gt;)
| [[:as:User:PK2|User page]] in [[:en:Assamese language|Assamese]]&lt;br /&gt;(code: &lt;code&gt;as&lt;/code&gt;)
| [[:ast:User:PK2|User page]] in [[:en:Asturleonese language|Asturleonese]] ([[:en:Asturian language|Asturian]])&lt;br /&gt;(code: &lt;code&gt;ast&lt;/code&gt;)
| [[:atj:User:PK2|User page]] in [[:en:Atikamekw language|Atikamekw]]&lt;br /&gt;(code: &lt;code&gt;atj&lt;/code&gt;)
| [[:av:User:PK2|User page]] in [[:en:Avar language|Avar]]&lt;br /&gt;(code: &lt;code&gt;av&lt;/code&gt;)
|-
| [[:avk:User:PK2|User page]] in [[:en:Kotava|Kotava]]&lt;br /&gt;(code: &lt;code&gt;avk&lt;/code&gt;)
| [[:awa:User:PK2|User page]] in [[:en:Awadhi language|Awadhi]]&lt;br /&gt;(code: &lt;code&gt;awa&lt;/code&gt;)
| [[:ay:User:PK2|User page]] in [[:en:Aymara language|Aymara]]&lt;br /&gt;(code: &lt;code&gt;ay&lt;/code&gt;)
| [[:az:User:PK2|User page]] in [[:en:Azerbaijani language|Azerbaijani]]&lt;br /&gt;(code: &lt;code&gt;az&lt;/code&gt;)
| [[:azb:User:PK2|User page]] in [[:en:Azerbaijani language#South Azerbaijani|South Azerbaijani]]&lt;br /&gt;(code: &lt;code&gt;azb&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ B
|-
| [[:ba:User:PK2|User page]] in [[:en:Bashkir language|Bashkir]]&lt;br /&gt;(code: &lt;code&gt;ba&lt;/code&gt;)
| [[:ban:User:PK2|User page]] in [[:en:Balinese language|Balinese]]&lt;br /&gt;(code: &lt;code&gt;ban&lt;/code&gt;)
| [[:bar:User:PK2|User page]] in [[:en:Bavarian language|Bavarian]]&lt;br /&gt;(code: &lt;code&gt;bar&lt;/code&gt;)
| [[:bat-smg:User:PK2|User page]] in [[:en:Samogitian language|Samogitian]]&lt;br /&gt;(code: &lt;code&gt;bat-smg&lt;/code&gt;)
| [[:bbc:User:PK2|User page]] in [[:en:Toba Batak language|Toba Batak]]&lt;br /&gt;(code: &lt;code&gt;bbc&lt;/code&gt;)
| [[:bcl:User:PK2|User page]] in [[:en:Central Bikol|Central Bikol]]&lt;br /&gt;(code: &lt;code&gt;bcl&lt;/code&gt;)
| [[:bdr:User:PK2|User page]] in [[:en:Sama–Bajaw languages|West Coast Bajau]]&lt;br /&gt;(code: &lt;code&gt;bdr&lt;/code&gt;)
| [[:be:User:PK2|User page]] in [[:en:Belarusian language|Belarusian]]&lt;br /&gt;(code: &lt;code&gt;be&lt;/code&gt;)
| [[:be-tarask:User:PK2|User page]] in [[:en:Belarusian language|Belarusian]] ([[:en:Taraškievica|Taraškievica]])&lt;br /&gt;(code: &lt;code&gt;be-tarask&lt;/code&gt;)
| [[:bew:User:PK2|User page]] in [[:en:Betawi language|Betawi]]&lt;br /&gt;(code: &lt;code&gt;bew&lt;/code&gt;)
|-
| [[:bg:User:PK2|User page]] in [[:en:Bulgarian language|Bulgarian]]&lt;br /&gt;(code: &lt;code&gt;bg&lt;/code&gt;)
| [[:bh:User:PK2|User page]] in [[:en:Bihari languages|Bihari]] ([[:en:Bhojpuri language|Bhojpuri]])&lt;br /&gt;(code: &lt;code&gt;bh&lt;/code&gt;)
| [[:bi:User:PK2|User page]] in [[:en:Bislama|Bislama]]&lt;br /&gt;(code: &lt;code&gt;bi&lt;/code&gt;)
| [[:bjn:User:PK2|User page]] in [[:en:Banjarese language|Banjarese]]&lt;br /&gt;(code: &lt;code&gt;bjn&lt;/code&gt;)
| [[:blk:User:PK2|User page]] in [[:en:Pa'O language|Pa'O]]&lt;br /&gt;(code: &lt;code&gt;blk&lt;/code&gt;)
| [[:bm:User:PK2|User page]] in [[:en:Bambara language|Bambara]]&lt;br /&gt;(code: &lt;code&gt;bm&lt;/code&gt;)
| [[:bn:User:PK2|User page]] in [[:en:Bengali language|Bengali]]&lt;br /&gt;(code: &lt;code&gt;bn&lt;/code&gt;)
| [[:bo:User:PK2|User page]] in [[:en:Central Tibetan|Central Tibetan]] ([[:en:Lhasa Tibetan|Lhasa Tibetan]])&lt;br /&gt;(code: &lt;code&gt;bo&lt;/code&gt;)
| [[:bpy:User:PK2|User page]] in [[:en:Bishnupriya Manipuri|Bishnupriya Manipuri]]&lt;br /&gt;(code: &lt;code&gt;bpy&lt;/code&gt;)
| [[:br:User:PK2|User page]] in [[:en:Breton language|Breton]]&lt;br /&gt;(code: &lt;code&gt;br&lt;/code&gt;)
|-
| [[:bs:User:PK2|User page]] in [[:en:Bosnian language|Bosnian]]&lt;br /&gt;(code: &lt;code&gt;bs&lt;/code&gt;)
| [[:btm:User:PK2|User page]] in [[:en:Mandailing Batak language|Mandailing Batak]]&lt;br /&gt;(code: &lt;code&gt;btm&lt;/code&gt;)
| [[:bug:User:PK2|User page]] in [[:en:Buginese language|Buginese]]&lt;br /&gt;(code: &lt;code&gt;bug&lt;/code&gt;)
| [[:bxr:User:PK2|User page]] in [[:en:Buryat language|Buryat]] (Russia Buriat)&lt;br /&gt;(code: &lt;code&gt;bxr&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ C
|-
| [[:ca:User:PK2|User page]] in [[:en:Catalan language|Catalan]]&lt;br /&gt;(code: &lt;code&gt;ca&lt;/code&gt;)
| [[:cbk-zam:User:PK2|User page]] in [[:en:Chavacano|Chavacano]] (Zamboanga)&lt;br /&gt;(code: &lt;code&gt;cbk-zam&lt;/code&gt;)
| [[:cdo:User:PK2|User page]] in [[:en:Eastern Min|Eastern Min]]&lt;br /&gt;(code: &lt;code&gt;cdo&lt;/code&gt;)
| [[:ce:User:PK2|User page]] in [[:en:Chechen language|Chechen]]&lt;br /&gt;(code: &lt;code&gt;ce&lt;/code&gt;)
| [[:ceb:User:PK2|User page]] in [[:en:Cebuano language|Cebuano]]&lt;br /&gt;(code: &lt;code&gt;ceb&lt;/code&gt;)
| [[:ch:User:PK2|User page]] in [[:en:Chamorro language|Chamorro]]&lt;br /&gt;(code: &lt;code&gt;ch&lt;/code&gt;)
| [[:chr:User:PK2|User page]] in [[:en:Cherokee language|Cherokee]]&lt;br /&gt;(code: &lt;code&gt;chr&lt;/code&gt;)
| [[:chy:User:PK2|User page]] in [[:en:Cheyenne language|Cheyenne]]&lt;br /&gt;(code: &lt;code&gt;chy&lt;/code&gt;)
|-
| [[:ckb:User:PK2|User page]] in [[:en:Kurdish language|Kurdish]] ([[:en:Sorani|Sorani]])&lt;br /&gt;(code: &lt;code&gt;ckb&lt;/code&gt;)
| [[:co:User:PK2|User page]] in [[:en:Corsican language|Corsican]]&lt;br /&gt;(code: &lt;code&gt;co&lt;/code&gt;)
| [[:crh:User:PK2|User page]] in [[:en:Crimean Tatar language|Crimean Tatar]]&lt;br /&gt;(code: &lt;code&gt;crh&lt;/code&gt;)
| [[:cs:User:PK2|User page]] in [[:en:Czech language|Czech]]&lt;br /&gt;(code: &lt;code&gt;cs&lt;/code&gt;)
| [[:csb:User:PK2|User page]] in [[:en:Kashubian language|Kashubian]]&lt;br /&gt;(code: &lt;code&gt;csb&lt;/code&gt;)
| [[:cu:User:PK2|User page]] in [[:en:Old Church Slavonic|Old Church Slavonic]]&lt;br /&gt;(code: &lt;code&gt;cu&lt;/code&gt;)
| [[:cv:User:PK2|User page]] in [[:en:Chuvash language|Chuvash]]&lt;br /&gt;(code: &lt;code&gt;cv&lt;/code&gt;)
| [[:cy:User:PK2|User page]] in [[:en:Welsh language|Welsh]]&lt;br /&gt;(code: &lt;code&gt;cy&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ D
|-
| [[:da:User:PK2|User page]] in [[:en:Danish language|Danish]]&lt;br /&gt;(code: &lt;code&gt;da&lt;/code&gt;)
| [[:dag:User:PK2|User page]] in [[:en:Dagbani language|Dagbani]]&lt;br /&gt;(code: &lt;code&gt;dag&lt;/code&gt;)
| [[:de:User:PK2|User page]] in [[:en:German language|German]]&lt;br /&gt;(code: &lt;code&gt;de&lt;/code&gt;)
| [[:dga:User:PK2|User page]] in [[:en:Dagaare language|Dagaare]]&lt;br /&gt;(code: &lt;code&gt;dga&lt;/code&gt;)
| [[:din:User:PK2|User page]] in [[:en:Dinka language|Dinka]]&lt;br /&gt;(code: &lt;code&gt;din&lt;/code&gt;)
| [[:diq:User:PK2|User page]] in [[:en:Zaza language|Zaza]]&lt;br /&gt;(code: &lt;code&gt;diq&lt;/code&gt;)
| [[:dsb:User:PK2|User page]] in [[:en:Lower Sorbian language|Lower Sorbian]]&lt;br /&gt;(code: &lt;code&gt;dsb&lt;/code&gt;)
| [[:dtp:User:PK2|User page]] in [[:en:Dusun language|Dusun]]&lt;br /&gt;(code: &lt;code&gt;dtp&lt;/code&gt;)
| [[:dty:User:PK2|User page]] in [[:en:Doteli|Doteli]]&lt;br /&gt;(code: &lt;code&gt;dty&lt;/code&gt;)
| [[:dv:User:PK2|User page]] in [[:en:Maldivian language|Maldivian]]&lt;br /&gt;(code: &lt;code&gt;dv&lt;/code&gt;)
| [[:dz:User:PK2|User page]] in [[:en:Dzongkha|Dzongkha]]&lt;br /&gt;(code: &lt;code&gt;dz&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ E
|-
| [[:ee:User:PK2|User page]] in [[:en:Ewe language|Ewe]]&lt;br /&gt;(code: &lt;code&gt;ee&lt;/code&gt;)
| [[:el:User:PK2|User page]] in [[:en:Greek language|Greek]]&lt;br /&gt;(code: &lt;code&gt;el&lt;/code&gt;)
| [[:eml:User:PK2|User page]] in [[:en:Emilian–Romagnol|Emilian–Romagnol]]&lt;br /&gt;(code: &lt;code&gt;eml&lt;/code&gt;)
| [[:en:User:PK2|User page]] in [[:en:English language|English]]&lt;br /&gt;(code: &lt;code&gt;en&lt;/code&gt;)
| [[:eo:User:PK2|User page]] in [[:en:Esperanto|Esperanto]]&lt;br /&gt;(code: &lt;code&gt;eo&lt;/code&gt;)
| [[:es:User:PK2|User page]] in [[:en:Spanish language|Spanish]]&lt;br /&gt;(code: &lt;code&gt;es&lt;/code&gt;)
| [[:et:User:PK2|User page]] in [[:en:Estonian language|Estonian]]&lt;br /&gt;(code: &lt;code&gt;et&lt;/code&gt;)
| [[:eu:User:PK2|User page]] in [[:en:Basque language|Basque]]&lt;br /&gt;(code: &lt;code&gt;eu&lt;/code&gt;)
| [[:ext:User:PK2|User page]] in [[:en:Extremaduran language|Extremaduran]]&lt;br /&gt;(code: &lt;code&gt;ext&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ F
|-
| [[:fa:User:PK2|User page]] in [[:en:Persian language|Persian]]&lt;br /&gt;(code: &lt;code&gt;fa&lt;/code&gt;)
| [[:fat:User:PK2|User page]] in [[:en:Akan language|Akan]] ([[:en:Fante dialect|Fante]])&lt;br /&gt;(code: &lt;code&gt;fat&lt;/code&gt;)
| [[:ff:User:PK2|User page]] in [[:en:Fula language|Fula]]&lt;br /&gt;(code: &lt;code&gt;ff&lt;/code&gt;)
| [[:fi:User:PK2|User page]] in [[:en:Finnish language|Finnish]]&lt;br /&gt;(code: &lt;code&gt;fi&lt;/code&gt;)
| [[:fiu-vro:User:PK2|User page]] in [[:en:Võro language|Võro]]&lt;br /&gt;(code: &lt;code&gt;fiu-vro&lt;/code&gt;)
| [[:fj:User:PK2|User page]] in [[:en:Fijian language|Fijian]]&lt;br /&gt;(code: &lt;code&gt;fj&lt;/code&gt;)
| [[:fo:User:PK2|User page]] in [[:en:Faroese language|Faroese]]&lt;br /&gt;(code: &lt;code&gt;fo&lt;/code&gt;)
| [[:fon:User:PK2|User page]] in [[:en:Fon language|Fon]]&lt;br /&gt;(code: &lt;code&gt;fon&lt;/code&gt;)
| [[:fr:User:PK2|User page]] in [[:en:French language|French]]&lt;br /&gt;(code: &lt;code&gt;fr&lt;/code&gt;)
| [[:frp:User:PK2|User page]] in [[:en:Franco-Provençal|Franco-Provençal]]&lt;br /&gt;(code: &lt;code&gt;frp&lt;/code&gt;)
| [[:frr:User:PK2|User page]] in [[:en:North Frisian language|North Frisian]]&lt;br /&gt;(code: &lt;code&gt;frr&lt;/code&gt;)
| [[:fur:User:PK2|User page]] in [[:en:Friulian language|Friulian]]&lt;br /&gt;(code: &lt;code&gt;fur&lt;/code&gt;)
| [[:fy:User:PK2|User page]] in [[:en:West Frisian language|West Frisian]]&lt;br /&gt;(code: &lt;code&gt;fy&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ G
|-
| [[:ga:User:PK2|User page]] in [[:en:Irish language|Irish]]&lt;br /&gt;(code: &lt;code&gt;ga&lt;/code&gt;)
| [[:gag:User:PK2|User page]] in [[:en:Gagauz language|Gagauz]]&lt;br /&gt;(code: &lt;code&gt;gag&lt;/code&gt;)
| [[:gan:User:PK2|User page]] in [[:en:Gan Chinese|Gan Chinese]]&lt;br /&gt;(code: &lt;code&gt;gan&lt;/code&gt;)
| [[:gcr:User:PK2|User page]] in [[:en:French Guianese Creole|French Guianese Creole]]&lt;br /&gt;(code: &lt;code&gt;gcr&lt;/code&gt;)
| [[:gd:User:PK2|User page]] in [[:en:Scottish Gaelic|Scottish Gaelic]]&lt;br /&gt;(code: &lt;code&gt;gd&lt;/code&gt;)
| [[:gl:User:PK2|User page]] in [[:en:Galician language|Galician]]&lt;br /&gt;(code: &lt;code&gt;gl&lt;/code&gt;)
| [[:glk:User:PK2|User page]] in [[:en:Gilaki language|Gilaki]]&lt;br /&gt;(code: &lt;code&gt;glk&lt;/code&gt;)
| [[:gn:User:PK2|User page]] in [[:en:Guarani language|Guarani]]&lt;br /&gt;(code: &lt;code&gt;gn&lt;/code&gt;)
| [[:gom:User:PK2|User page]] in [[:en:Konkani language|Konkani]] (Goan Konkani)&lt;br /&gt;(code: &lt;code&gt;gom&lt;/code&gt;)
|-
| [[:gor:User:PK2|User page]] in [[:en:Gorontalo language|Gorontalo]]&lt;br /&gt;(code: &lt;code&gt;gor&lt;/code&gt;)
| [[:got:User:PK2|User page]] in [[:en:Gothic language|Gothic]]&lt;br /&gt;(code: &lt;code&gt;got&lt;/code&gt;)
| [[:gpe:User:PK2|User page]] in [[:en:Ghanaian Pidgin English|Ghanaian Pidgin English]]&lt;br /&gt;(code: &lt;code&gt;gpe&lt;/code&gt;)
| [[:gu:User:PK2|User page]] in [[:en:Gujarati language|Gujarati]]&lt;br /&gt;(code: &lt;code&gt;gu&lt;/code&gt;)
| [[:guc:User:PK2|User page]] in [[:en:Wayuu language|Wayuu]]&lt;br /&gt;(code: &lt;code&gt;guc&lt;/code&gt;)
| [[:gur:User:PK2|User page]] in [[:en:Farefare language|Farefare]]&lt;br /&gt;(code: &lt;code&gt;gur&lt;/code&gt;)
| [[:guw:User:PK2|User page]] in [[:en:Gun language|Gun]]&lt;br /&gt;(code: &lt;code&gt;guw&lt;/code&gt;)
| [[:gv:User:PK2|User page]] in [[:en:Manx language|Manx]]&lt;br /&gt;(code: &lt;code&gt;gv&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ H
|-
| [[:ha:User:PK2|User page]] in [[:en:Hausa language|Hausa]]&lt;br /&gt;(code: &lt;code&gt;ha&lt;/code&gt;)
| [[:hak:User:PK2|User page]] in [[:en:Hakka Chinese|Hakka Chinese]]&lt;br /&gt;(code: &lt;code&gt;hak&lt;/code&gt;)
| [[:haw:User:PK2|User page]] in [[:en:Hawaiian language|Hawaiian]]&lt;br /&gt;(code: &lt;code&gt;haw&lt;/code&gt;)
| [[:he:User:PK2|User page]] in [[:en:Hebrew language|Hebrew]]&lt;br /&gt;(code: &lt;code&gt;he&lt;/code&gt;)
| [[:hi:User:PK2|User page]] in [[:en:Hindi|Hindi]]&lt;br /&gt;(code: &lt;code&gt;hi&lt;/code&gt;)
| [[:hif:User:PK2|User page]] in [[:en:Fiji Hindi|Fiji Hindi]]&lt;br /&gt;(code: &lt;code&gt;hif&lt;/code&gt;)
| [[:hr:User:PK2|User page]] in [[:en:Croatian language|Croatian]]&lt;br /&gt;(code: &lt;code&gt;hr&lt;/code&gt;)
| [[:hsb:User:PK2|User page]] in [[:en:Upper Sorbian language|Upper Sorbian]]&lt;br /&gt;(code: &lt;code&gt;hsb&lt;/code&gt;)
| [[:ht:User:PK2|User page]] in [[:en:Haitian Creole|Haitian Creole]]&lt;br /&gt;(code: &lt;code&gt;ht&lt;/code&gt;)
| [[:hu:User:PK2|User page]] in [[:en:Hungarian language|Hungarian]]&lt;br /&gt;(code: &lt;code&gt;hu&lt;/code&gt;)
| [[:hy:User:PK2|User page]] in [[:en:Armenian language|Armenian]] ([[:en:Eastern Armenian|Eastern Armenian]])&lt;br /&gt;(code: &lt;code&gt;hy&lt;/code&gt;)
| [[:hyw:User:PK2|User page]] in [[:en:Western Armenian|Western Armenian]]&lt;br /&gt;(code: &lt;code&gt;hyw&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ I
|-
| [[:ia:User:PK2|User page]] in [[:en:Interlingua|Interlingua]]&lt;br /&gt;(code: &lt;code&gt;ia&lt;/code&gt;)
| [[:iba:User:PK2|User page]] in [[:en:Iban language|Iban]]&lt;br /&gt;(code: &lt;code&gt;iba&lt;/code&gt;)
| [[:id:User:PK2|User page]] in [[:en:Indonesian language|Indonesian]]&lt;br /&gt;(code: &lt;code&gt;id&lt;/code&gt;)
| [[:ie:User:PK2|User page]] in [[:en:Interlingue|Interlingue]]&lt;br /&gt;(code: &lt;code&gt;ie&lt;/code&gt;)
| [[:ig:User:PK2|User page]] in [[:en:Igbo language|Igbo]]&lt;br /&gt;(code: &lt;code&gt;ig&lt;/code&gt;)
| [[:igl:User:PK2|User page]] in [[:en:Igala language|Igala]]&lt;br /&gt;(code: &lt;code&gt;igl&lt;/code&gt;)
| [[:ik:User:PK2|User page]] in [[:en:Iñupiaq language|Iñupiaq]]&lt;br /&gt;(code: &lt;code&gt;ik&lt;/code&gt;)
| [[:ilo:User:PK2|User page]] in [[:en:Ilocano language|Ilocano]]&lt;br /&gt;(code: &lt;code&gt;ilo&lt;/code&gt;)
| [[:inh:User:PK2|User page]] in [[:en:Ingush language|Ingush]]&lt;br /&gt;(code: &lt;code&gt;inh&lt;/code&gt;)
| [[:io:User:PK2|User page]] in [[:en:Ido|Ido]]&lt;br /&gt;(code: &lt;code&gt;io&lt;/code&gt;)
| [[:is:User:PK2|User page]] in [[:en:Icelandic language|Icelandic]]&lt;br /&gt;(code: &lt;code&gt;is&lt;/code&gt;)
| [[:it:User:PK2|User page]] in [[:en:Italian language|Italian]]&lt;br /&gt;(code: &lt;code&gt;it&lt;/code&gt;)
| [[:iu:User:PK2|User page]] in [[:en:Inuktitut|Inuktitut]]&lt;br /&gt;(code: &lt;code&gt;iu&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ J
|-
| [[:ja:User:PK2|User page]] in [[:en:Japanese language|Japanese]]&lt;br /&gt;(code: &lt;code&gt;ja&lt;/code&gt;)
| [[:jam:User:PK2|User page]] in [[:en:Jamaican Patois|Jamaican Patois]]&lt;br /&gt;(code: &lt;code&gt;jam&lt;/code&gt;)
| [[:jbo:User:PK2|User page]] in [[:en:Lojban|Lojban]]&lt;br /&gt;(code: &lt;code&gt;jbo&lt;/code&gt;)
| [[:jv:User:PK2|User page]] in [[:en:Javanese language|Javanese]]&lt;br /&gt;(code: &lt;code&gt;jv&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ K
|-
| [[:ka:User:PK2|User page]] in [[:en:Georgian language|Georgian]]&lt;br /&gt;(code: &lt;code&gt;ka&lt;/code&gt;)
| [[:kaa:User:PK2|User page]] in [[:en:Karakalpak language|Karakalpak]]&lt;br /&gt;(code: &lt;code&gt;kaa&lt;/code&gt;)
| [[:kab:User:PK2|User page]] in [[:en:Kabyle language|Kabyle]]&lt;br /&gt;(code: &lt;code&gt;kab&lt;/code&gt;)
| [[:kbd:User:PK2|User page]] in [[:en:Kabardian language|Kabardian]]&lt;br /&gt;(code: &lt;code&gt;kbd&lt;/code&gt;)
| [[:kbp:User:PK2|User page]] in [[:en:Kabiye language|Kabiye]]&lt;br /&gt;(code: &lt;code&gt;kbp&lt;/code&gt;)
| [[:kcg:User:PK2|User page]] in [[:en:Tyap|Tyap]]&lt;br /&gt;(code: &lt;code&gt;kcg&lt;/code&gt;)
| [[:kg:User:PK2|User page]] in [[:en:Kongo language|Kongo]]&lt;br /&gt;(code: &lt;code&gt;kg&lt;/code&gt;)
| [[:kge:User:PK2|User page]] in [[:en:Komering language|Komering]]&lt;br /&gt;(code: &lt;code&gt;kge&lt;/code&gt;)
| [[:ki:User:PK2|User page]] in [[:en:Kikuyu language|Kikuyu]]&lt;br /&gt;(code: &lt;code&gt;ki&lt;/code&gt;)
| [[:kk:User:PK2|User page]] in [[:en:Kazakh language|Kazakh]]&lt;br /&gt;(code: &lt;code&gt;kk&lt;/code&gt;)
| [[:km:User:PK2|User page]] in [[:en:Khmer language|Khmer]]&lt;br /&gt;(code: &lt;code&gt;km&lt;/code&gt;)
| [[:kn:User:PK2|User page]] in [[:en:Kannada|Kannada]]&lt;br /&gt;(code: &lt;code&gt;kn&lt;/code&gt;)
|-
| [[:knc:User:PK2|User page]] in [[:en:Central Kanuri|Central Kanuri]]&lt;br /&gt;(code: &lt;code&gt;knc&lt;/code&gt;)
| [[:ko:User:PK2|User page]] in [[:en:Korean language|Korean]]&lt;br /&gt;(code: &lt;code&gt;ko&lt;/code&gt;)
| [[:koi:User:PK2|User page]] in [[:en:Komi-Permyak language|Komi-Permyak]]&lt;br /&gt;(code: &lt;code&gt;koi&lt;/code&gt;)
| [[:krc:User:PK2|User page]] in [[:en:Karachay-Balkar|Karachay-Balkar]]&lt;br /&gt;(code: &lt;code&gt;krc&lt;/code&gt;)
| [[:ks:User:PK2|User page]] in [[:en:Kashmiri language|Kashmiri]]&lt;br /&gt;(code: &lt;code&gt;ks&lt;/code&gt;)
| [[:ksh:User:PK2|User page]] in [[:en:Ripuarian language|Ripuarian]]&lt;br /&gt;(code: &lt;code&gt;ksh&lt;/code&gt;)
| [[:ku:User:PK2|User page]] in [[:en:Kurdish language|Kurdish]] ([[:en:Kurmanji|Kurmanji]])&lt;br /&gt;(code: &lt;code&gt;ku&lt;/code&gt;)
| [[:kus:User:PK2|User page]] in [[:en:Kusaal language|Kusaal]]&lt;br /&gt;(code: &lt;code&gt;kus&lt;/code&gt;)
| [[:kv:User:PK2|User page]] in [[:en:Komi language|Komi]]&lt;br /&gt;(code: &lt;code&gt;kv&lt;/code&gt;)
| [[:kw:User:PK2|User page]] in [[:en:Cornish language|Cornish]]&lt;br /&gt;(code: &lt;code&gt;kw&lt;/code&gt;)
| [[:ky:User:PK2|User page]] in [[:en:Kyrgyz language|Kyrgyz]]&lt;br /&gt;(code: &lt;code&gt;ky&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ L
|-
| [[:la:User:PK2|User page]] in [[:en:Latin|Latin]]&lt;br /&gt;(code: &lt;code&gt;la&lt;/code&gt;)
| [[:lad:User:PK2|User page]] in [[:en:Judaeo-Spanish|Judaeo-Spanish]]&lt;br /&gt;(code: &lt;code&gt;lad&lt;/code&gt;)
| [[:lb:User:PK2|User page]] in [[:en:Luxembourgish|Luxembourgish]]&lt;br /&gt;(code: &lt;code&gt;lb&lt;/code&gt;)
| [[:lbe:User:PK2|User page]] in [[:en:Lak language|Lak]]&lt;br /&gt;(code: &lt;code&gt;lbe&lt;/code&gt;)
| [[:lez:User:PK2|User page]] in [[:en:Lezgian language|Lezgian]]&lt;br /&gt;(code: &lt;code&gt;lez&lt;/code&gt;)
| [[:lfn:User:PK2|User page]] in [[:en:Lingua Franca Nova|Lingua Franca Nova]]&lt;br /&gt;(code: &lt;code&gt;lfn&lt;/code&gt;)
| [[:lg:User:PK2|User page]] in [[:en:Luganda|Luganda]]&lt;br /&gt;(code: &lt;code&gt;lg&lt;/code&gt;)
| [[:li:User:PK2|User page]] in [[:en:Limburgish|Limburgish]]&lt;br /&gt;(code: &lt;code&gt;li&lt;/code&gt;)
|-
| [[:lij:User:PK2|User page]] in [[:en:Ligurian language|Ligurian]]&lt;br /&gt;(code: &lt;code&gt;lij&lt;/code&gt;)
| [[:lld:User:PK2|User page]] in [[:en:Ladin language|Ladin]]&lt;br /&gt;(code: &lt;code&gt;lld&lt;/code&gt;)
| [[:lmo:User:PK2|User page]] in [[:en:Lombard language|Lombard]]&lt;br /&gt;(code: &lt;code&gt;lmo&lt;/code&gt;)
| [[:ln:User:PK2|User page]] in [[:en:Lingala|Lingala]]&lt;br /&gt;(code: &lt;code&gt;ln&lt;/code&gt;)
| [[:lo:User:PK2|User page]] in [[:en:Lao language|Lao]]&lt;br /&gt;(code: &lt;code&gt;lo&lt;/code&gt;)
| [[:lt:User:PK2|User page]] in [[:en:Lithuanian language|Lithuanian]]&lt;br /&gt;(code: &lt;code&gt;lt&lt;/code&gt;)
| [[:ltg:User:PK2|User page]] in [[:en:Latgalian language|Latgalian]]&lt;br /&gt;(code: &lt;code&gt;ltg&lt;/code&gt;)
| [[:lv:User:PK2|User page]] in [[:en:Latvian language|Latvian]]&lt;br /&gt;(code: &lt;code&gt;lv&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ M
|-
| [[:mad:User:PK2|User page]] in [[:en:Madurese language|Madurese]]&lt;br /&gt;(code: &lt;code&gt;mad&lt;/code&gt;)
| [[:mai:User:PK2|User page]] in [[:en:Maithili language|Maithili]]&lt;br /&gt;(code: &lt;code&gt;mai&lt;/code&gt;)
| [[:map-bms:User:PK2|User page]] in [[:en:Javanese language|Javanese]] ([[:en:Banyumasan dialect|Banyumasan]])&lt;br /&gt;(code: &lt;code&gt;map-bms&lt;/code&gt;)
| [[:mdf:User:PK2|User page]] in [[:en:Moksha language|Moksha]]&lt;br /&gt;(code: &lt;code&gt;mdf&lt;/code&gt;)
| [[:mg:User:PK2|User page]] in [[:en:Malagasy language|Malagasy]]&lt;br /&gt;(code: &lt;code&gt;mg&lt;/code&gt;)
| [[:mhr:User:PK2|User page]] in [[:en:Meadow Mari language|Meadow Mari]]&lt;br /&gt;(code: &lt;code&gt;mhr&lt;/code&gt;)
| [[:mi:User:PK2|User page]] in [[:en:Māori language|Māori]]&lt;br /&gt;(code: &lt;code&gt;mi&lt;/code&gt;)
| [[:min:User:PK2|User page]] in [[:en:Minangkabau language|Minangkabau]]&lt;br /&gt;(code: &lt;code&gt;min&lt;/code&gt;)
| [[:mk:User:PK2|User page]] in [[:en:Macedonian language|Macedonian]]&lt;br /&gt;(code: &lt;code&gt;mk&lt;/code&gt;)
| [[:ml:User:PK2|User page]] in [[:en:Malayalam|Malayalam]]&lt;br /&gt;(code: &lt;code&gt;ml&lt;/code&gt;)
| [[:mn:User:PK2|User page]] in [[:en:Mongolian language|Mongolian]]&lt;br /&gt;(code: &lt;code&gt;mn&lt;/code&gt;)
|-
| [[:mni:User:PK2|User page]] in [[:en:Meitei language|Meitei]]&lt;br /&gt;(code: &lt;code&gt;mni&lt;/code&gt;)
| [[:mnw:User:PK2|User page]] in [[:en:Mon language|Mon]]&lt;br /&gt;(code: &lt;code&gt;mnw&lt;/code&gt;)
| [[:m:mos:User:PK2|User page]] in [[:en:Mooré|Mooré]]&lt;br /&gt;(code: &lt;code&gt;mos&lt;/code&gt;)
| [[:mr:User:PK2|User page]] in [[:en:Marathi language|Marathi]]&lt;br /&gt;(code: &lt;code&gt;mr&lt;/code&gt;)
| [[:mrj:User:PK2|User page]] in [[:en:Hill Mari language|Hill Mari]]&lt;br /&gt;(code: &lt;code&gt;mrj&lt;/code&gt;)
| [[:ms:User:PK2|User page]] in [[:en:Malay language|Malay]]&lt;br /&gt;(code: &lt;code&gt;ms&lt;/code&gt;)
| [[:mt:User:PK2|User page]] in [[:en:Maltese language|Maltese]]&lt;br /&gt;(code: &lt;code&gt;mt&lt;/code&gt;)
| [[:mwl:User:PK2|User page]] in [[:en:Mirandese language|Mirandese]]&lt;br /&gt;(code: &lt;code&gt;mwl&lt;/code&gt;)
| [[:my:User:PK2|User page]] in [[:en:Burmese language|Burmese]]&lt;br /&gt;(code: &lt;code&gt;my&lt;/code&gt;)
| [[:myv:User:PK2|User page]] in [[:en:Erzya language|Erzya]]&lt;br /&gt;(code: &lt;code&gt;myv&lt;/code&gt;)
| [[:mzn:User:PK2|User page]] in [[:en:Mazanderani language|Mazanderani]]&lt;br /&gt;(code: &lt;code&gt;mzn&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ N
|-
| [[:nah:User:PK2|User page]] in [[:en:Nahuatl|Nahuatl]]&lt;br /&gt;(code: &lt;code&gt;nah&lt;/code&gt;)
| [[:nap:User:PK2|User page]] in [[:en:Neapolitan language|Neapolitan]]&lt;br /&gt;(code: &lt;code&gt;nap&lt;/code&gt;)
| [[:nds:User:PK2|User page]] in [[:en:Low German|Low German]]&lt;br /&gt;(code: &lt;code&gt;nds&lt;/code&gt;)
| [[:nds-nl:User:PK2|User page]] in [[:en:Dutch Low Saxon|Dutch Low Saxon]]&lt;br /&gt;(code: &lt;code&gt;nds-nl&lt;/code&gt;)
| [[:ne:User:PK2|User page]] in [[:en:Nepali language|Nepali]]&lt;br /&gt;(code: &lt;code&gt;ne&lt;/code&gt;)
| [[:new:User:PK2|User page]] in [[:en:Newar language|Newar]]&lt;br /&gt;(code: &lt;code&gt;new&lt;/code&gt;)
| [[:nia:User:PK2|User page]] in [[:en:Nias language|Nias]]&lt;br /&gt;(code: &lt;code&gt;nia&lt;/code&gt;)
| [[:nl:User:PK2|User page]] in [[:en:Dutch language|Dutch]]&lt;br /&gt;(code: &lt;code&gt;nl&lt;/code&gt;)
| [[:nn:User:PK2|User page]] in [[:en:Norwegian language|Norwegian]] ([[:en:Nynorsk|Nynorsk]])&lt;br /&gt;(code: &lt;code&gt;nn&lt;/code&gt;)
|-
| [[:no:User:PK2|User page]] in [[:en:Norwegian language|Norwegian]] ([[:en:Bokmål|Bokmål]])&lt;br /&gt;(code: &lt;code&gt;no&lt;/code&gt;)
| [[:nov:User:PK2|User page]] in [[:en:Novial|Novial]]&lt;br /&gt;(code: &lt;code&gt;nov&lt;/code&gt;)
| [[:nqo:User:PK2|User page]] in [[:en:N'Ko language|N'Ko]]&lt;br /&gt;(code: &lt;code&gt;nqo&lt;/code&gt;)
| [[:nr:User:PK2|User page]] in [[:en:Southern Ndebele language|Southern Ndebele]]&lt;br /&gt;(code: &lt;code&gt;nr&lt;/code&gt;)
| [[:nrm:User:PK2|User page]] in [[:en:Norman language|Norman]]&lt;br /&gt;(code: &lt;code&gt;nrm&lt;/code&gt;)
| [[:nso:User:PK2|User page]] in [[:en:Northern Sotho|Northern Sotho]]&lt;br /&gt;(code: &lt;code&gt;nso&lt;/code&gt;)
| [[:nup:User:PK2|User page]] in [[:en:Nupe language|Nupe]]&lt;br /&gt;(code: &lt;code&gt;nup&lt;/code&gt;)
| [[:nv:User:PK2|User page]] in [[:en:Navajo language|Navajo]]&lt;br /&gt;(code: &lt;code&gt;nv&lt;/code&gt;)
| [[:ny:User:PK2|User page]] in [[:en:Chewa language|Chewa]]&lt;br /&gt;(code: &lt;code&gt;ny&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ O
|-
| [[:oc:User:PK2|User page]] in [[:en:Occitan language|Occitan]]&lt;br /&gt;(code: &lt;code&gt;oc&lt;/code&gt;)
| [[:olo:User:PK2|User page]] in [[:en:Livvi-Karelian language|Livvi-Karelian]]&lt;br /&gt;(code: &lt;code&gt;olo&lt;/code&gt;)
| [[:om:User:PK2|User page]] in [[:en:Oromo language|Oromo]]&lt;br /&gt;(code: &lt;code&gt;om&lt;/code&gt;)
| [[:or:User:PK2|User page]] in [[:en:Odia language|Odia]]&lt;br /&gt;(code: &lt;code&gt;or&lt;/code&gt;)
| [[:os:User:PK2|User page]] in [[:en:Ossetian language|Ossetian]]&lt;br /&gt;(code: &lt;code&gt;os&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ P
|-
| [[:pa:User:PK2|User page]] in [[:en:Punjabi language|Punjabi]]&lt;br /&gt;(code: &lt;code&gt;pa&lt;/code&gt;)
| [[:pag:User:PK2|User page]] in [[:en:Pangasinan language|Pangasinan]]&lt;br /&gt;(code: &lt;code&gt;pag&lt;/code&gt;)
| [[:pam:User:PK2|User page]] in [[:en:Kapampangan language|Kapampangan]]&lt;br /&gt;(code: &lt;code&gt;pam&lt;/code&gt;)
| [[:pap:User:PK2|User page]] in [[:en:Papiamento|Papiamento]]&lt;br /&gt;(code: &lt;code&gt;pap&lt;/code&gt;)
| [[:pcd:User:PK2|User page]] in [[:en:Picard language|Picard]]&lt;br /&gt;(code: &lt;code&gt;pcd&lt;/code&gt;)
| [[:pcm:User:PK2|User page]] in [[:en:Nigerian Pidgin|Nigerian Pidgin]]&lt;br /&gt;(code: &lt;code&gt;pcm&lt;/code&gt;)
| [[:pdc:User:PK2|User page]] in [[:en:Pennsylvania Dutch language|Pennsylvania Dutch]]&lt;br /&gt;(code: &lt;code&gt;pdc&lt;/code&gt;)
| [[:pfl:User:PK2|User page]] in [[:en:Palatine German dialects|Palatine German]]&lt;br /&gt;(code: &lt;code&gt;pfl&lt;/code&gt;)
|-
| [[:pi:User:PK2|User page]] in [[:en:Pali|Pali]]&lt;br /&gt;(code: &lt;code&gt;pi&lt;/code&gt;)
| [[:pl:User:PK2|User page]] in [[:en:Polish language|Polish]]&lt;br /&gt;(code: &lt;code&gt;pl&lt;/code&gt;)
| [[:pms:User:PK2|User page]] in [[:en:Piedmontese language|Piedmontese]]&lt;br /&gt;(code: &lt;code&gt;pms&lt;/code&gt;)
| [[:pnb:User:PK2|User page]] in [[:en:Punjabi language|Punjabi]] (Western Punjabi)&lt;br /&gt;(code: &lt;code&gt;pnb&lt;/code&gt;)
| [[:pnt:User:PK2|User page]] in [[:en:Pontic Greek|Pontic Greek]]&lt;br /&gt;(code: &lt;code&gt;pnt&lt;/code&gt;)
| [[:ps:User:PK2|User page]] in [[:en:Pashto|Pashto]]&lt;br /&gt;(code: &lt;code&gt;ps&lt;/code&gt;)
| [[:pt:User:PK2|User page]] in [[:en:Portuguese language|Portuguese]]&lt;br /&gt;(code: &lt;code&gt;pt&lt;/code&gt;)
| [[:pwn:User:PK2|User page]] in [[:en:Paiwan language|Paiwan]]&lt;br /&gt;(code: &lt;code&gt;pwn&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ Q
|-
| [[:qu:User:PK2|User page]] in [[:en:Quechuan languages|Quechua]] ([[:en:Southern Quechua|Southern Quechua]])&lt;br /&gt;(code: &lt;code&gt;qu&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ R
|-
| [[:rki:User:PK2|User page]] in [[:en:Rakhine language|Rakhine]]&lt;br /&gt;(code: &lt;code&gt;rki&lt;/code&gt;)
| [[:rm:User:PK2|User page]] in [[:en:Romansh language|Romansh]]&lt;br /&gt;(code: &lt;code&gt;rm&lt;/code&gt;)
| [[:rmy:User:PK2|User page]] in [[:en:Romani language|Romani]] ([[:en:Vlax Romani language|Vlax Romani]])&lt;br /&gt;(code: &lt;code&gt;rmy&lt;/code&gt;)
| [[:rn:User:PK2|User page]] in [[:en:Kirundi|Kirundi]]&lt;br /&gt;(code: &lt;code&gt;rn&lt;/code&gt;)
| [[:ro:User:PK2|User page]] in [[:en:Romanian language|Romanian]]&lt;br /&gt;(code: &lt;code&gt;ro&lt;/code&gt;)
| [[:roa-rup:User:PK2|User page]] in [[:en:Aromanian language|Aromanian]]&lt;br /&gt;(code: &lt;code&gt;roa-rup&lt;/code&gt;)
| [[:roa-tara:User:PK2|User page]] in [[:en:Neapolitan language|Neapolitan]] ([[:en:Tarantino dialect|Tarantino]])&lt;br /&gt;(code: &lt;code&gt;roa-tara&lt;/code&gt;)
| [[:rsk:User:PK2|User page]] in [[:en:Pannonian Rusyn|Pannonian Rusyn]]&lt;br /&gt;(code: &lt;code&gt;rsk&lt;/code&gt;)
| [[:ru:User:PK2|User page]] in [[:en:Russian language|Russian]]&lt;br /&gt;(code: &lt;code&gt;ru&lt;/code&gt;)
| [[:rue:User:PK2|User page]] in [[:en:Rusyn language|Rusyn]]&lt;br /&gt;(code: &lt;code&gt;rue&lt;/code&gt;)
| [[:rw:User:PK2|User page]] in [[:en:Kinyarwanda|Kinyarwanda]]&lt;br /&gt;(code: &lt;code&gt;rw&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ S
|-
| [[:sa:User:PK2|User page]] in [[:en:Sanskrit|Sanskrit]]&lt;br /&gt;(code: &lt;code&gt;sa&lt;/code&gt;)
| [[:sah:User:PK2|User page]] in [[:en:Yakut language|Yakut]]&lt;br /&gt;(code: &lt;code&gt;sah&lt;/code&gt;)
| [[:sat:User:PK2|User page]] in [[:en:Santali language|Santali]]&lt;br /&gt;(code: &lt;code&gt;sat&lt;/code&gt;)
| [[:sc:User:PK2|User page]] in [[:en:Sardinian language|Sardinian]]&lt;br /&gt;(code: &lt;code&gt;sc&lt;/code&gt;)
| [[:scn:User:PK2|User page]] in [[:en:Sicilian language|Sicilian]]&lt;br /&gt;(code: &lt;code&gt;scn&lt;/code&gt;)
| [[:sco:User:PK2|User page]] in [[:en:Scots language|Scots]]&lt;br /&gt;(code: &lt;code&gt;sco&lt;/code&gt;)
| [[:sd:User:PK2|User page]] in [[:en:Sindhi language|Sindhi]]&lt;br /&gt;(code: &lt;code&gt;sd&lt;/code&gt;)
| [[:se:User:PK2|User page]] in [[:en:Northern Sámi|Northern Sámi]]&lt;br /&gt;(code: &lt;code&gt;se&lt;/code&gt;)
| [[:sg:User:PK2|User page]] in [[:en:Sango language|Sango]]&lt;br /&gt;(code: &lt;code&gt;sg&lt;/code&gt;)
| [[:sh:User:PK2|User page]] in [[:en:Serbo-Croatian|Serbo-Croatian]]&lt;br /&gt;(code: &lt;code&gt;sh&lt;/code&gt;)
| [[:shi:User:PK2|User page]] in [[:en:Shilha language|Shilha]]&lt;br /&gt;(code: &lt;code&gt;shi&lt;/code&gt;)
|-
| [[:shn:User:PK2|User page]] in [[:en:Shan language|Shan]]&lt;br /&gt;(code: &lt;code&gt;shn&lt;/code&gt;)
| [[:si:User:PK2|User page]] in [[:en:Sinhala language|Sinhala]]&lt;br /&gt;(code: &lt;code&gt;si&lt;/code&gt;)
| [[:simple:User:PK2|User page]] in [[:en:Basic English|Basic English]]&lt;br /&gt;(code: &lt;code&gt;simple&lt;/code&gt;)
| [[:sk:User:PK2|User page]] in [[:en:Slovak language|Slovak]]&lt;br /&gt;(code: &lt;code&gt;sk&lt;/code&gt;)
| [[:skr:User:PK2|User page]] in [[:en:Saraiki language|Saraiki]]&lt;br /&gt;(code: &lt;code&gt;skr&lt;/code&gt;)
| [[:sl:User:PK2|User page]] in [[:en:Slovene language|Slovene]]&lt;br /&gt;(code: &lt;code&gt;sl&lt;/code&gt;)
| [[:sm:User:PK2|User page]] in [[:en:Samoan language|Samoan]]&lt;br /&gt;(code: &lt;code&gt;sm&lt;/code&gt;)
| [[:smn:User:PK2|User page]] in [[:en:Inari Sámi language|Inari Sámi]]&lt;br /&gt;(code: &lt;code&gt;smn&lt;/code&gt;)
| [[:sn:User:PK2|User page]] in [[:en:Shona language|Shona]]&lt;br /&gt;(code: &lt;code&gt;sn&lt;/code&gt;)
| [[:so:User:PK2|User page]] in [[:en:Somali language|Somali]]&lt;br /&gt;(code: &lt;code&gt;so&lt;/code&gt;)
| [[:sq:User:PK2|User page]] in [[:en:Albanian language|Albanian]]&lt;br /&gt;(code: &lt;code&gt;sq&lt;/code&gt;)
|-
| [[:sr:User:PK2|User page]] in [[:en:Serbian language|Serbian]]&lt;br /&gt;(code: &lt;code&gt;sr&lt;/code&gt;)
| [[:srn:User:PK2|User page]] in [[:en:Sranan Tongo|Sranan Tongo]]&lt;br /&gt;(code: &lt;code&gt;srn&lt;/code&gt;)
| [[:ss:User:PK2|User page]] in [[:en:Swazi language|Swazi]]&lt;br /&gt;(code: &lt;code&gt;ss&lt;/code&gt;)
| [[:st:User:PK2|User page]] in [[:en:Sotho language|Sotho]]&lt;br /&gt;(code: &lt;code&gt;st&lt;/code&gt;)
| [[:stq:User:PK2|User page]] in [[:en:Saterland Frisian language|Saterland Frisian]]&lt;br /&gt;(code: &lt;code&gt;stq&lt;/code&gt;)
| [[:su:User:PK2|User page]] in [[:en:Sundanese language|Sundanese]]&lt;br /&gt;(code: &lt;code&gt;su&lt;/code&gt;)
| [[:sv:User:PK2|User page]] in [[:en:Swedish language|Swedish]]&lt;br /&gt;(code: &lt;code&gt;sv&lt;/code&gt;)
| [[:sw:User:PK2|User page]] in [[:en:Swahili language|Swahili]]&lt;br /&gt;(code: &lt;code&gt;sw&lt;/code&gt;)
| [[:syl:User:PK2|User page]] in [[:en:Sylheti language|Sylheti]]&lt;br /&gt;(code: &lt;code&gt;syl&lt;/code&gt;)
| [[:szl:User:PK2|User page]] in [[:en:Silesian language|Silesian]]&lt;br /&gt;(code: &lt;code&gt;szl&lt;/code&gt;)
| [[:szy:User:PK2|User page]] in [[:en:Sakizaya language|Sakizaya]]&lt;br /&gt;(code: &lt;code&gt;szy&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ T
|-
| [[:ta:User:PK2|User page]] in [[:en:Tamil language|Tamil]]&lt;br /&gt;(code: &lt;code&gt;ta&lt;/code&gt;)
| [[:tay:User:PK2|User page]] in [[:en:Atayal language|Atayal]]&lt;br /&gt;(code: &lt;code&gt;tay&lt;/code&gt;)
| [[:tcy:User:PK2|User page]] in [[:en:Tulu language|Tulu]]&lt;br /&gt;(code: &lt;code&gt;tcy&lt;/code&gt;)
| [[:tdd:User:PK2|User page]] in [[:en:Tai Nuea language|Tai Nuea]]&lt;br /&gt;(code: &lt;code&gt;tdd&lt;/code&gt;)
| [[:te:User:PK2|User page]] in [[:en:Telugu language|Telugu]]&lt;br /&gt;(code: &lt;code&gt;te&lt;/code&gt;)
| [[:tet:User:PK2|User page]] in [[:en:Tetum language|Tetum]]&lt;br /&gt;(code: &lt;code&gt;tet&lt;/code&gt;)
| [[:tg:User:PK2|User page]] in [[:en:Tajik language|Tajik]]&lt;br /&gt;(code: &lt;code&gt;tg&lt;/code&gt;)
| [[:th:User:PK2|User page]] in [[:en:Thai language|Thai]]&lt;br /&gt;(code: &lt;code&gt;th&lt;/code&gt;)
| [[:ti:User:PK2|User page]] in [[:en:Tigrinya language|Tigrinya]]&lt;br /&gt;(code: &lt;code&gt;ti&lt;/code&gt;)
| [[:tig:User:PK2|User page]] in [[:en:Tigre language|Tigre]]&lt;br /&gt;(code: &lt;code&gt;tig&lt;/code&gt;)
| [[:tk:User:PK2|User page]] in [[:en:Turkmen language|Turkmen]]&lt;br /&gt;(code: &lt;code&gt;tk&lt;/code&gt;)
| [[:tl:User:PK2|User page]] in [[:en:Tagalog language|Tagalog]]&lt;br /&gt;(code: &lt;code&gt;tl&lt;/code&gt;)
| [[:tly:User:PK2|User page]] in [[:en:Talysh language|Talysh]]&lt;br /&gt;(code: &lt;code&gt;tly&lt;/code&gt;)
|-
| [[:tn:User:PK2|User page]] in [[:en:Tswana language|Tswana]]&lt;br /&gt;(code: &lt;code&gt;tn&lt;/code&gt;)
| [[:to:User:PK2|User page]] in [[:en:Tongan language|Tongan]]&lt;br /&gt;(code: &lt;code&gt;to&lt;/code&gt;)
| [[:tok:User:PK2|User page]] in [[:en:Toki Pona|Toki Pona]]&lt;br /&gt;(code: &lt;code&gt;tok&lt;/code&gt;)
| [[:tpi:User:PK2|User page]] in [[:en:Tok Pisin|Tok Pisin]]&lt;br /&gt;(code: &lt;code&gt;tpi&lt;/code&gt;)
| [[:tr:User:PK2|User page]] in [[:en:Turkish language|Turkish]]&lt;br /&gt;(code: &lt;code&gt;tr&lt;/code&gt;)
| [[:trv:User:PK2|User page]] in [[:en:Seediq language|Seediq]]&lt;br /&gt;(code: &lt;code&gt;trv&lt;/code&gt;)
| [[:ts:User:PK2|User page]] in [[:en:Tsonga language|Tsonga]]&lt;br /&gt;(code: &lt;code&gt;ts&lt;/code&gt;)
| [[:tt:User:PK2|User page]] in [[:en:Tatar language|Tatar]]&lt;br /&gt;(code: &lt;code&gt;tt&lt;/code&gt;)
| [[:tum:User:PK2|User page]] in [[:en:Tumbuka language|Tumbuka]]&lt;br /&gt;(code: &lt;code&gt;tum&lt;/code&gt;)
| [[:tw:User:PK2|User page]] in [[:en:Akan language|Akan]] (Twi)&lt;br /&gt;(code: &lt;code&gt;tw&lt;/code&gt;)
| [[:ty:User:PK2|User page]] in [[:en:Tahitian language|Tahitian]]&lt;br /&gt;(code: &lt;code&gt;ty&lt;/code&gt;)
| [[:tyv:User:PK2|User page]] in [[:en:Tuvan language|Tuvan]]&lt;br /&gt;(code: &lt;code&gt;tyv&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ U
|-
| [[:udm:User:PK2|User page]] in [[:en:Udmurt language|Udmurt]]&lt;br /&gt;(code: &lt;code&gt;udm&lt;/code&gt;)
| [[:ug:User:PK2|User page]] in [[:en:Uyghur language|Uyghur]]&lt;br /&gt;(code: &lt;code&gt;ug&lt;/code&gt;)
| [[:uk:User:PK2|User page]] in [[:en:Ukrainian language|Ukrainian]]&lt;br /&gt;(code: &lt;code&gt;uk&lt;/code&gt;)
| [[:ur:User:PK2|User page]] in [[:en:Urdu|Urdu]]&lt;br /&gt;(code: &lt;code&gt;ur&lt;/code&gt;)
| [[:uz:User:PK2|User page]] in [[:en:Uzbek language|Uzbek]]&lt;br /&gt;(code: &lt;code&gt;uz&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ V
|-
| [[:ve:User:PK2|User page]] in [[:en:Venda language|Venda]]&lt;br /&gt;(code: &lt;code&gt;ve&lt;/code&gt;)
| [[:vec:User:PK2|User page]] in [[:en:Venetian language|Venetian]]&lt;br /&gt;(code: &lt;code&gt;vec&lt;/code&gt;)
| [[:vep:User:PK2|User page]] in [[:en:Veps language|Veps]]&lt;br /&gt;(code: &lt;code&gt;vep&lt;/code&gt;)
| [[:vi:User:PK2|User page]] in [[:en:Vietnamese language|Vietnamese]]&lt;br /&gt;(code: &lt;code&gt;vi&lt;/code&gt;)
| [[:vls:User:PK2|User page]] in [[:en:West Flemish|West Flemish]]&lt;br /&gt;(code: &lt;code&gt;vls&lt;/code&gt;)
| [[:vo:User:PK2|User page]] in [[:en:Volapük|Volapük]]&lt;br /&gt;(code: &lt;code&gt;vo&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ W
|-
| [[:wa:User:PK2|User page]] in [[:en:Walloon language|Walloon]]&lt;br /&gt;(code: &lt;code&gt;wa&lt;/code&gt;)
| [[:war:User:PK2|User page]] in [[:en:Waray language|Waray]]&lt;br /&gt;(code: &lt;code&gt;war&lt;/code&gt;)
| [[:wo:User:PK2|User page]] in [[:en:Wolof language|Wolof]]&lt;br /&gt;(code: &lt;code&gt;wo&lt;/code&gt;)
| [[:wuu:User:PK2|User page]] in [[:en:Wu Chinese|Wu Chinese]]&lt;br /&gt;(code: &lt;code&gt;wuu&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ X
|-
| [[:xal:User:PK2|User page]] in [[:en:Oirat language|Oirat]] ([[:en:Kalmyk Oirat|Kalmyk Oirat]])&lt;br /&gt;(code: &lt;code&gt;xal&lt;/code&gt;)
| [[:xh:User:PK2|User page]] in [[:en:Xhosa language|Xhosa]]&lt;br /&gt;(code: &lt;code&gt;xh&lt;/code&gt;)
| [[:xmf:User:PK2|User page]] in [[:en:Mingrelian language|Mingrelian]]&lt;br /&gt;(code: &lt;code&gt;xmf&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ Y
|-
| [[:yi:User:PK2|User page]] in [[:en:Yiddish|Yiddish]]&lt;br /&gt;(code: &lt;code&gt;yi&lt;/code&gt;)
| [[:yo:User:PK2|User page]] in [[:en:Yoruba language|Yoruba]]&lt;br /&gt;(code: &lt;code&gt;yo&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ Z
|-
| [[:za:User:PK2|User page]] in [[:en:Zhuang languages|Zhuang]] ([[:en:Standard Zhuang|Standard Zhuang]])&lt;br /&gt;(code: &lt;code&gt;za&lt;/code&gt;)
| [[:zea:User:PK2|User page]] in [[:en:Zeelandic|Zeelandic]]&lt;br /&gt;(code: &lt;code&gt;zea&lt;/code&gt;)
| [[:zgh:User:PK2|User page]] in [[:en:Standard Moroccan Amazigh|Standard Moroccan Amazigh]]&lt;br /&gt;(code: &lt;code&gt;zgh&lt;/code&gt;)
| [[:zh:User:PK2|User page]] in [[:en:Chinese language|Chinese]] ([[:en:Mandarin Chinese|Mandarin Chinese]])&lt;br /&gt;(code: &lt;code&gt;zh&lt;/code&gt;)
| [[:zh-classical:User:PK2|User page]] in [[:en:Classical Chinese|Classical Chinese]]&lt;br /&gt;(code: &lt;code&gt;zh-classical&lt;/code&gt;)
| [[:zh-min-nan:User:PK2|User page]] in [[:en:Southern Min|Southern Min]]&lt;br /&gt;(code: &lt;code&gt;zh-min-nan&lt;/code&gt;)
| [[:zh-yue:User:PK2|User page]] in [[:en:Cantonese|Cantonese]]&lt;br /&gt;(code: &lt;code&gt;zh-yue&lt;/code&gt;)
| [[:zu:User:PK2|User page]] in [[:en:Zulu language|Zulu]]&lt;br /&gt;(code: &lt;code&gt;zu&lt;/code&gt;)
|}</text>
      <sha1>ksq9iz3bc6ghi7ymjlvzgy003mc7ccf</sha1>
    </revision>
    <revision>
      <id>6660</id>
      <parentid>6061</parentid>
      <timestamp>2026-05-22T05:53:12Z</timestamp>
      <contributor>
        <username>PK2</username>
        <id>303</id>
      </contributor>
      <minor />
      <comment>add user pages for new Wikipedia editions</comment>
      <origin>6660</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="35942" sha1="dud3tixug1qffje4pl8q76cccmmhg8l" xml:space="preserve">{| class=&quot;wikitable&quot; style=&quot;font-size:85%&quot;
|-
| [[User:PK2/sandbox|This]] is where my sandbox pages in different languages are
|}

;&lt;div class=&quot;center&quot; style=&quot;width:auto; margin-left:auto; margin-right:auto; font-size:85%&quot;&gt;My user pages in different languages by language code&lt;/div&gt;
{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ A
|-
| [[:ab:User:PK2|User page]] in [[:en:Abkhaz language|Abkhaz]]&lt;br /&gt;(code: &lt;code&gt;ab&lt;/code&gt;)
| [[:ace:User:PK2|User page]] in [[:en:Acehnese language|Acehnese]]&lt;br /&gt;(code: &lt;code&gt;ace&lt;/code&gt;)
| [[:ady:User:PK2|User page]] in [[:en:Adyghe language|Adyghe]]&lt;br /&gt;(code: &lt;code&gt;ady&lt;/code&gt;)
| [[:af:User:PK2|User page]] in [[:en:Afrikaans|Afrikaans]]&lt;br /&gt;(code: &lt;code&gt;af&lt;/code&gt;)
| [[:als:User:PK2|User page]] in [[:en:Alemannic German|Alemannic German]]&lt;br /&gt;(code: &lt;code&gt;als&lt;/code&gt;)
| [[:alt:User:PK2|User page]] in [[:en:Southern Altai language|Southern Altai]]&lt;br /&gt;(code: &lt;code&gt;alt&lt;/code&gt;)
| [[:am:User:PK2|User page]] in [[:en:Amharic|Amharic]]&lt;br /&gt;(code: &lt;code&gt;am&lt;/code&gt;)
| [[:ami:User:PK2|User page]] in [[:en:Amis language|Amis]]&lt;br /&gt;(code: &lt;code&gt;ami&lt;/code&gt;)
| [[:an:User:PK2|User page]] in [[:en:Aragonese language|Aragonese]]&lt;br /&gt;(code: &lt;code&gt;an&lt;/code&gt;)
| [[:ang:User:PK2|User page]] in [[:en:Old English|Old English]]&lt;br /&gt;(code: &lt;code&gt;ang&lt;/code&gt;)
|-
| [[:ann:User:PK2|User page]] in [[:en:Obolo language|Obolo]]&lt;br /&gt;(code: &lt;code&gt;ann&lt;/code&gt;)
| [[:anp:User:PK2|User page]] in [[:en:Angika|Angika]]&lt;br /&gt;(code: &lt;code&gt;anp&lt;/code&gt;)
| [[:ar:User:PK2|User page]] in [[:en:Arabic|Arabic]]&lt;br /&gt;(code: &lt;code&gt;ar&lt;/code&gt;)
| [[:arc:User:PK2|User page]] in [[:en:Aramaic|Aramaic]] ([[:en:Syriac language|Syriac]])&lt;br /&gt;(code: &lt;code&gt;arc&lt;/code&gt;)
| [[:ary:User:PK2|User page]] in [[:en:Moroccan Arabic|Moroccan Arabic]]&lt;br /&gt;(code: &lt;code&gt;ary&lt;/code&gt;)
| [[:arz:User:PK2|User page]] in [[:en:Egyptian Arabic|Egyptian Arabic]]&lt;br /&gt;(code: &lt;code&gt;arz&lt;/code&gt;)
| [[:as:User:PK2|User page]] in [[:en:Assamese language|Assamese]]&lt;br /&gt;(code: &lt;code&gt;as&lt;/code&gt;)
| [[:ast:User:PK2|User page]] in [[:en:Asturleonese language|Asturleonese]] ([[:en:Asturian language|Asturian]])&lt;br /&gt;(code: &lt;code&gt;ast&lt;/code&gt;)
| [[:atj:User:PK2|User page]] in [[:en:Atikamekw language|Atikamekw]]&lt;br /&gt;(code: &lt;code&gt;atj&lt;/code&gt;)
| [[:av:User:PK2|User page]] in [[:en:Avar language|Avar]]&lt;br /&gt;(code: &lt;code&gt;av&lt;/code&gt;)
|-
| [[:avk:User:PK2|User page]] in [[:en:Kotava|Kotava]]&lt;br /&gt;(code: &lt;code&gt;avk&lt;/code&gt;)
| [[:awa:User:PK2|User page]] in [[:en:Awadhi language|Awadhi]]&lt;br /&gt;(code: &lt;code&gt;awa&lt;/code&gt;)
| [[:ay:User:PK2|User page]] in [[:en:Aymara language|Aymara]]&lt;br /&gt;(code: &lt;code&gt;ay&lt;/code&gt;)
| [[:az:User:PK2|User page]] in [[:en:Azerbaijani language|Azerbaijani]]&lt;br /&gt;(code: &lt;code&gt;az&lt;/code&gt;)
| [[:azb:User:PK2|User page]] in [[:en:Azerbaijani language#South Azerbaijani|South Azerbaijani]]&lt;br /&gt;(code: &lt;code&gt;azb&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ B
|-
| [[:ba:User:PK2|User page]] in [[:en:Bashkir language|Bashkir]]&lt;br /&gt;(code: &lt;code&gt;ba&lt;/code&gt;)
| [[:ban:User:PK2|User page]] in [[:en:Balinese language|Balinese]]&lt;br /&gt;(code: &lt;code&gt;ban&lt;/code&gt;)
| [[:bar:User:PK2|User page]] in [[:en:Bavarian language|Bavarian]]&lt;br /&gt;(code: &lt;code&gt;bar&lt;/code&gt;)
| [[:bat-smg:User:PK2|User page]] in [[:en:Samogitian language|Samogitian]]&lt;br /&gt;(code: &lt;code&gt;bat-smg&lt;/code&gt;)
| [[:bbc:User:PK2|User page]] in [[:en:Toba Batak language|Toba Batak]]&lt;br /&gt;(code: &lt;code&gt;bbc&lt;/code&gt;)
| [[:bcl:User:PK2|User page]] in [[:en:Central Bikol|Central Bikol]]&lt;br /&gt;(code: &lt;code&gt;bcl&lt;/code&gt;)
| [[:bdr:User:PK2|User page]] in [[:en:Sama–Bajaw languages|West Coast Bajau]]&lt;br /&gt;(code: &lt;code&gt;bdr&lt;/code&gt;)
| [[:be:User:PK2|User page]] in [[:en:Belarusian language|Belarusian]]&lt;br /&gt;(code: &lt;code&gt;be&lt;/code&gt;)
| [[:be-tarask:User:PK2|User page]] in [[:en:Belarusian language|Belarusian]] ([[:en:Taraškievica|Taraškievica]])&lt;br /&gt;(code: &lt;code&gt;be-tarask&lt;/code&gt;)
| [[:bew:User:PK2|User page]] in [[:en:Betawi language|Betawi]]&lt;br /&gt;(code: &lt;code&gt;bew&lt;/code&gt;)
|-
| [[:bg:User:PK2|User page]] in [[:en:Bulgarian language|Bulgarian]]&lt;br /&gt;(code: &lt;code&gt;bg&lt;/code&gt;)
| [[:bh:User:PK2|User page]] in [[:en:Bihari languages|Bihari]] ([[:en:Bhojpuri language|Bhojpuri]])&lt;br /&gt;(code: &lt;code&gt;bh&lt;/code&gt;)
| [[:bi:User:PK2|User page]] in [[:en:Bislama|Bislama]]&lt;br /&gt;(code: &lt;code&gt;bi&lt;/code&gt;)
| [[:bjn:User:PK2|User page]] in [[:en:Banjarese language|Banjarese]]&lt;br /&gt;(code: &lt;code&gt;bjn&lt;/code&gt;)
| [[:blk:User:PK2|User page]] in [[:en:Pa'O language|Pa'O]]&lt;br /&gt;(code: &lt;code&gt;blk&lt;/code&gt;)
| [[:bm:User:PK2|User page]] in [[:en:Bambara language|Bambara]]&lt;br /&gt;(code: &lt;code&gt;bm&lt;/code&gt;)
| [[:bn:User:PK2|User page]] in [[:en:Bengali language|Bengali]]&lt;br /&gt;(code: &lt;code&gt;bn&lt;/code&gt;)
| [[:bo:User:PK2|User page]] in [[:en:Central Tibetan|Central Tibetan]] ([[:en:Lhasa Tibetan|Lhasa Tibetan]])&lt;br /&gt;(code: &lt;code&gt;bo&lt;/code&gt;)
| [[:bpy:User:PK2|User page]] in [[:en:Bishnupriya Manipuri|Bishnupriya Manipuri]]&lt;br /&gt;(code: &lt;code&gt;bpy&lt;/code&gt;)
| [[:br:User:PK2|User page]] in [[:en:Breton language|Breton]]&lt;br /&gt;(code: &lt;code&gt;br&lt;/code&gt;)
|-
| [[:bs:User:PK2|User page]] in [[:en:Bosnian language|Bosnian]]&lt;br /&gt;(code: &lt;code&gt;bs&lt;/code&gt;)
| [[:btm:User:PK2|User page]] in [[:en:Mandailing Batak language|Mandailing Batak]]&lt;br /&gt;(code: &lt;code&gt;btm&lt;/code&gt;)
| [[:bug:User:PK2|User page]] in [[:en:Buginese language|Buginese]]&lt;br /&gt;(code: &lt;code&gt;bug&lt;/code&gt;)
| [[:bxr:User:PK2|User page]] in [[:en:Buryat language|Buryat]] (Russia Buriat)&lt;br /&gt;(code: &lt;code&gt;bxr&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ C
|-
| [[:ca:User:PK2|User page]] in [[:en:Catalan language|Catalan]]&lt;br /&gt;(code: &lt;code&gt;ca&lt;/code&gt;)
| [[:cbk-zam:User:PK2|User page]] in [[:en:Chavacano|Chavacano]] (Zamboanga)&lt;br /&gt;(code: &lt;code&gt;cbk-zam&lt;/code&gt;)
| [[:cdo:User:PK2|User page]] in [[:en:Eastern Min|Eastern Min]]&lt;br /&gt;(code: &lt;code&gt;cdo&lt;/code&gt;)
| [[:ce:User:PK2|User page]] in [[:en:Chechen language|Chechen]]&lt;br /&gt;(code: &lt;code&gt;ce&lt;/code&gt;)
| [[:ceb:User:PK2|User page]] in [[:en:Cebuano language|Cebuano]]&lt;br /&gt;(code: &lt;code&gt;ceb&lt;/code&gt;)
| [[:ch:User:PK2|User page]] in [[:en:Chamorro language|Chamorro]]&lt;br /&gt;(code: &lt;code&gt;ch&lt;/code&gt;)
| [[:chr:User:PK2|User page]] in [[:en:Cherokee language|Cherokee]]&lt;br /&gt;(code: &lt;code&gt;chr&lt;/code&gt;)
| [[:chy:User:PK2|User page]] in [[:en:Cheyenne language|Cheyenne]]&lt;br /&gt;(code: &lt;code&gt;chy&lt;/code&gt;)
|-
| [[:ckb:User:PK2|User page]] in [[:en:Kurdish language|Kurdish]] ([[:en:Sorani|Sorani]])&lt;br /&gt;(code: &lt;code&gt;ckb&lt;/code&gt;)
| [[:co:User:PK2|User page]] in [[:en:Corsican language|Corsican]]&lt;br /&gt;(code: &lt;code&gt;co&lt;/code&gt;)
| [[:crh:User:PK2|User page]] in [[:en:Crimean Tatar language|Crimean Tatar]]&lt;br /&gt;(code: &lt;code&gt;crh&lt;/code&gt;)
| [[:cs:User:PK2|User page]] in [[:en:Czech language|Czech]]&lt;br /&gt;(code: &lt;code&gt;cs&lt;/code&gt;)
| [[:csb:User:PK2|User page]] in [[:en:Kashubian language|Kashubian]]&lt;br /&gt;(code: &lt;code&gt;csb&lt;/code&gt;)
| [[:cu:User:PK2|User page]] in [[:en:Old Church Slavonic|Old Church Slavonic]]&lt;br /&gt;(code: &lt;code&gt;cu&lt;/code&gt;)
| [[:cv:User:PK2|User page]] in [[:en:Chuvash language|Chuvash]]&lt;br /&gt;(code: &lt;code&gt;cv&lt;/code&gt;)
| [[:cy:User:PK2|User page]] in [[:en:Welsh language|Welsh]]&lt;br /&gt;(code: &lt;code&gt;cy&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ D
|-
| [[:da:User:PK2|User page]] in [[:en:Danish language|Danish]]&lt;br /&gt;(code: &lt;code&gt;da&lt;/code&gt;)
| [[:dag:User:PK2|User page]] in [[:en:Dagbani language|Dagbani]]&lt;br /&gt;(code: &lt;code&gt;dag&lt;/code&gt;)
| [[:de:User:PK2|User page]] in [[:en:German language|German]]&lt;br /&gt;(code: &lt;code&gt;de&lt;/code&gt;)
| [[:dga:User:PK2|User page]] in [[:en:Dagaare language|Dagaare]]&lt;br /&gt;(code: &lt;code&gt;dga&lt;/code&gt;)
| [[:din:User:PK2|User page]] in [[:en:Dinka language|Dinka]]&lt;br /&gt;(code: &lt;code&gt;din&lt;/code&gt;)
| [[:diq:User:PK2|User page]] in [[:en:Zaza language|Zaza]]&lt;br /&gt;(code: &lt;code&gt;diq&lt;/code&gt;)
| [[:dsb:User:PK2|User page]] in [[:en:Lower Sorbian language|Lower Sorbian]]&lt;br /&gt;(code: &lt;code&gt;dsb&lt;/code&gt;)
| [[:dtp:User:PK2|User page]] in [[:en:Dusun language|Dusun]]&lt;br /&gt;(code: &lt;code&gt;dtp&lt;/code&gt;)
| [[:dty:User:PK2|User page]] in [[:en:Doteli|Doteli]]&lt;br /&gt;(code: &lt;code&gt;dty&lt;/code&gt;)
| [[:dv:User:PK2|User page]] in [[:en:Maldivian language|Maldivian]]&lt;br /&gt;(code: &lt;code&gt;dv&lt;/code&gt;)
| [[:dz:User:PK2|User page]] in [[:en:Dzongkha|Dzongkha]]&lt;br /&gt;(code: &lt;code&gt;dz&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ E
|-
| [[:ee:User:PK2|User page]] in [[:en:Ewe language|Ewe]]&lt;br /&gt;(code: &lt;code&gt;ee&lt;/code&gt;)
| [[:el:User:PK2|User page]] in [[:en:Greek language|Greek]]&lt;br /&gt;(code: &lt;code&gt;el&lt;/code&gt;)
| [[:eml:User:PK2|User page]] in [[:en:Emilian–Romagnol|Emilian–Romagnol]]&lt;br /&gt;(code: &lt;code&gt;eml&lt;/code&gt;)
| [[:en:User:PK2|User page]] in [[:en:English language|English]]&lt;br /&gt;(code: &lt;code&gt;en&lt;/code&gt;)
| [[:eo:User:PK2|User page]] in [[:en:Esperanto|Esperanto]]&lt;br /&gt;(code: &lt;code&gt;eo&lt;/code&gt;)
| [[:es:User:PK2|User page]] in [[:en:Spanish language|Spanish]]&lt;br /&gt;(code: &lt;code&gt;es&lt;/code&gt;)
| [[:et:User:PK2|User page]] in [[:en:Estonian language|Estonian]]&lt;br /&gt;(code: &lt;code&gt;et&lt;/code&gt;)
| [[:eu:User:PK2|User page]] in [[:en:Basque language|Basque]]&lt;br /&gt;(code: &lt;code&gt;eu&lt;/code&gt;)
| [[:ext:User:PK2|User page]] in [[:en:Extremaduran language|Extremaduran]]&lt;br /&gt;(code: &lt;code&gt;ext&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ F
|-
| [[:fa:User:PK2|User page]] in [[:en:Persian language|Persian]]&lt;br /&gt;(code: &lt;code&gt;fa&lt;/code&gt;)
| [[:fat:User:PK2|User page]] in [[:en:Akan language|Akan]] ([[:en:Fante dialect|Fante]])&lt;br /&gt;(code: &lt;code&gt;fat&lt;/code&gt;)
| [[:ff:User:PK2|User page]] in [[:en:Fula language|Fula]]&lt;br /&gt;(code: &lt;code&gt;ff&lt;/code&gt;)
| [[:fi:User:PK2|User page]] in [[:en:Finnish language|Finnish]]&lt;br /&gt;(code: &lt;code&gt;fi&lt;/code&gt;)
| [[:fiu-vro:User:PK2|User page]] in [[:en:Võro language|Võro]]&lt;br /&gt;(code: &lt;code&gt;fiu-vro&lt;/code&gt;)
| [[:fj:User:PK2|User page]] in [[:en:Fijian language|Fijian]]&lt;br /&gt;(code: &lt;code&gt;fj&lt;/code&gt;)
| [[:fo:User:PK2|User page]] in [[:en:Faroese language|Faroese]]&lt;br /&gt;(code: &lt;code&gt;fo&lt;/code&gt;)
| [[:fon:User:PK2|User page]] in [[:en:Fon language|Fon]]&lt;br /&gt;(code: &lt;code&gt;fon&lt;/code&gt;)
| [[:fr:User:PK2|User page]] in [[:en:French language|French]]&lt;br /&gt;(code: &lt;code&gt;fr&lt;/code&gt;)
| [[:frp:User:PK2|User page]] in [[:en:Franco-Provençal|Franco-Provençal]]&lt;br /&gt;(code: &lt;code&gt;frp&lt;/code&gt;)
| [[:frr:User:PK2|User page]] in [[:en:North Frisian language|North Frisian]]&lt;br /&gt;(code: &lt;code&gt;frr&lt;/code&gt;)
| [[:fur:User:PK2|User page]] in [[:en:Friulian language|Friulian]]&lt;br /&gt;(code: &lt;code&gt;fur&lt;/code&gt;)
| [[:fy:User:PK2|User page]] in [[:en:West Frisian language|West Frisian]]&lt;br /&gt;(code: &lt;code&gt;fy&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ G
|-
| [[:ga:User:PK2|User page]] in [[:en:Irish language|Irish]]&lt;br /&gt;(code: &lt;code&gt;ga&lt;/code&gt;)
| [[:gag:User:PK2|User page]] in [[:en:Gagauz language|Gagauz]]&lt;br /&gt;(code: &lt;code&gt;gag&lt;/code&gt;)
| [[:gan:User:PK2|User page]] in [[:en:Gan Chinese|Gan Chinese]]&lt;br /&gt;(code: &lt;code&gt;gan&lt;/code&gt;)
| [[:gcr:User:PK2|User page]] in [[:en:French Guianese Creole|French Guianese Creole]]&lt;br /&gt;(code: &lt;code&gt;gcr&lt;/code&gt;)
| [[:gd:User:PK2|User page]] in [[:en:Scottish Gaelic|Scottish Gaelic]]&lt;br /&gt;(code: &lt;code&gt;gd&lt;/code&gt;)
| [[:gl:User:PK2|User page]] in [[:en:Galician language|Galician]]&lt;br /&gt;(code: &lt;code&gt;gl&lt;/code&gt;)
| [[:glk:User:PK2|User page]] in [[:en:Gilaki language|Gilaki]]&lt;br /&gt;(code: &lt;code&gt;glk&lt;/code&gt;)
| [[:gn:User:PK2|User page]] in [[:en:Guarani language|Guarani]]&lt;br /&gt;(code: &lt;code&gt;gn&lt;/code&gt;)
| [[:gom:User:PK2|User page]] in [[:en:Konkani language|Konkani]] (Goan Konkani)&lt;br /&gt;(code: &lt;code&gt;gom&lt;/code&gt;)
|-
| [[:gor:User:PK2|User page]] in [[:en:Gorontalo language|Gorontalo]]&lt;br /&gt;(code: &lt;code&gt;gor&lt;/code&gt;)
| [[:got:User:PK2|User page]] in [[:en:Gothic language|Gothic]]&lt;br /&gt;(code: &lt;code&gt;got&lt;/code&gt;)
| [[:gpe:User:PK2|User page]] in [[:en:Ghanaian Pidgin English|Ghanaian Pidgin English]]&lt;br /&gt;(code: &lt;code&gt;gpe&lt;/code&gt;)
| [[:gu:User:PK2|User page]] in [[:en:Gujarati language|Gujarati]]&lt;br /&gt;(code: &lt;code&gt;gu&lt;/code&gt;)
| [[:guc:User:PK2|User page]] in [[:en:Wayuu language|Wayuu]]&lt;br /&gt;(code: &lt;code&gt;guc&lt;/code&gt;)
| [[:gur:User:PK2|User page]] in [[:en:Farefare language|Farefare]]&lt;br /&gt;(code: &lt;code&gt;gur&lt;/code&gt;)
| [[:guw:User:PK2|User page]] in [[:en:Gun language|Gun]]&lt;br /&gt;(code: &lt;code&gt;guw&lt;/code&gt;)
| [[:gv:User:PK2|User page]] in [[:en:Manx language|Manx]]&lt;br /&gt;(code: &lt;code&gt;gv&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ H
|-
| [[:ha:User:PK2|User page]] in [[:en:Hausa language|Hausa]]&lt;br /&gt;(code: &lt;code&gt;ha&lt;/code&gt;)
| [[:hak:User:PK2|User page]] in [[:en:Hakka Chinese|Hakka Chinese]]&lt;br /&gt;(code: &lt;code&gt;hak&lt;/code&gt;)
| [[:haw:User:PK2|User page]] in [[:en:Hawaiian language|Hawaiian]]&lt;br /&gt;(code: &lt;code&gt;haw&lt;/code&gt;)
| [[:he:User:PK2|User page]] in [[:en:Hebrew language|Hebrew]]&lt;br /&gt;(code: &lt;code&gt;he&lt;/code&gt;)
| [[:hi:User:PK2|User page]] in [[:en:Hindi|Hindi]]&lt;br /&gt;(code: &lt;code&gt;hi&lt;/code&gt;)
| [[:hif:User:PK2|User page]] in [[:en:Fiji Hindi|Fiji Hindi]]&lt;br /&gt;(code: &lt;code&gt;hif&lt;/code&gt;)
| [[:hr:User:PK2|User page]] in [[:en:Croatian language|Croatian]]&lt;br /&gt;(code: &lt;code&gt;hr&lt;/code&gt;)
| [[:hsb:User:PK2|User page]] in [[:en:Upper Sorbian language|Upper Sorbian]]&lt;br /&gt;(code: &lt;code&gt;hsb&lt;/code&gt;)
| [[:ht:User:PK2|User page]] in [[:en:Haitian Creole|Haitian Creole]]&lt;br /&gt;(code: &lt;code&gt;ht&lt;/code&gt;)
| [[:hu:User:PK2|User page]] in [[:en:Hungarian language|Hungarian]]&lt;br /&gt;(code: &lt;code&gt;hu&lt;/code&gt;)
| [[:hy:User:PK2|User page]] in [[:en:Armenian language|Armenian]] ([[:en:Eastern Armenian|Eastern Armenian]])&lt;br /&gt;(code: &lt;code&gt;hy&lt;/code&gt;)
| [[:hyw:User:PK2|User page]] in [[:en:Western Armenian|Western Armenian]]&lt;br /&gt;(code: &lt;code&gt;hyw&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ I
|-
| [[:ia:User:PK2|User page]] in [[:en:Interlingua|Interlingua]]&lt;br /&gt;(code: &lt;code&gt;ia&lt;/code&gt;)
| [[:iba:User:PK2|User page]] in [[:en:Iban language|Iban]]&lt;br /&gt;(code: &lt;code&gt;iba&lt;/code&gt;)
| [[:id:User:PK2|User page]] in [[:en:Indonesian language|Indonesian]]&lt;br /&gt;(code: &lt;code&gt;id&lt;/code&gt;)
| [[:ie:User:PK2|User page]] in [[:en:Interlingue|Interlingue]]&lt;br /&gt;(code: &lt;code&gt;ie&lt;/code&gt;)
| [[:ig:User:PK2|User page]] in [[:en:Igbo language|Igbo]]&lt;br /&gt;(code: &lt;code&gt;ig&lt;/code&gt;)
| [[:igl:User:PK2|User page]] in [[:en:Igala language|Igala]]&lt;br /&gt;(code: &lt;code&gt;igl&lt;/code&gt;)
| [[:ik:User:PK2|User page]] in [[:en:Iñupiaq language|Iñupiaq]]&lt;br /&gt;(code: &lt;code&gt;ik&lt;/code&gt;)
| [[:ilo:User:PK2|User page]] in [[:en:Ilocano language|Ilocano]]&lt;br /&gt;(code: &lt;code&gt;ilo&lt;/code&gt;)
| [[:inh:User:PK2|User page]] in [[:en:Ingush language|Ingush]]&lt;br /&gt;(code: &lt;code&gt;inh&lt;/code&gt;)
| [[:io:User:PK2|User page]] in [[:en:Ido|Ido]]&lt;br /&gt;(code: &lt;code&gt;io&lt;/code&gt;)
| [[:is:User:PK2|User page]] in [[:en:Icelandic language|Icelandic]]&lt;br /&gt;(code: &lt;code&gt;is&lt;/code&gt;)
| [[:it:User:PK2|User page]] in [[:en:Italian language|Italian]]&lt;br /&gt;(code: &lt;code&gt;it&lt;/code&gt;)
| [[:iu:User:PK2|User page]] in [[:en:Inuktitut|Inuktitut]]&lt;br /&gt;(code: &lt;code&gt;iu&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ J
|-
| [[:ja:User:PK2|User page]] in [[:en:Japanese language|Japanese]]&lt;br /&gt;(code: &lt;code&gt;ja&lt;/code&gt;)
| [[:jam:User:PK2|User page]] in [[:en:Jamaican Patois|Jamaican Patois]]&lt;br /&gt;(code: &lt;code&gt;jam&lt;/code&gt;)
| [[:jbo:User:PK2|User page]] in [[:en:Lojban|Lojban]]&lt;br /&gt;(code: &lt;code&gt;jbo&lt;/code&gt;)
| [[:jv:User:PK2|User page]] in [[:en:Javanese language|Javanese]]&lt;br /&gt;(code: &lt;code&gt;jv&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ K
|-
| [[:ka:User:PK2|User page]] in [[:en:Georgian language|Georgian]]&lt;br /&gt;(code: &lt;code&gt;ka&lt;/code&gt;)
| [[:kaa:User:PK2|User page]] in [[:en:Karakalpak language|Karakalpak]]&lt;br /&gt;(code: &lt;code&gt;kaa&lt;/code&gt;)
| [[:kab:User:PK2|User page]] in [[:en:Kabyle language|Kabyle]]&lt;br /&gt;(code: &lt;code&gt;kab&lt;/code&gt;)
| [[:kai:User:PK2|User page]] in [[:en:Karai-karai|Karai-karai]]&lt;br /&gt;(code: &lt;code&gt;kai&lt;/code&gt;)
| [[:kaj:User:PK2|User page]] in [[:en:Jju language|Jju]]&lt;br /&gt;(code: &lt;code&gt;kaj&lt;/code&gt;)
| [[:kbd:User:PK2|User page]] in [[:en:Kabardian language|Kabardian]]&lt;br /&gt;(code: &lt;code&gt;kbd&lt;/code&gt;)
| [[:kbp:User:PK2|User page]] in [[:en:Kabiye language|Kabiye]]&lt;br /&gt;(code: &lt;code&gt;kbp&lt;/code&gt;)
| [[:kcg:User:PK2|User page]] in [[:en:Tyap|Tyap]]&lt;br /&gt;(code: &lt;code&gt;kcg&lt;/code&gt;)
| [[:kg:User:PK2|User page]] in [[:en:Kongo language|Kongo]]&lt;br /&gt;(code: &lt;code&gt;kg&lt;/code&gt;)
| [[:kge:User:PK2|User page]] in [[:en:Komering language|Komering]]&lt;br /&gt;(code: &lt;code&gt;kge&lt;/code&gt;)
| [[:ki:User:PK2|User page]] in [[:en:Kikuyu language|Kikuyu]]&lt;br /&gt;(code: &lt;code&gt;ki&lt;/code&gt;)
| [[:kk:User:PK2|User page]] in [[:en:Kazakh language|Kazakh]]&lt;br /&gt;(code: &lt;code&gt;kk&lt;/code&gt;)
| [[:km:User:PK2|User page]] in [[:en:Khmer language|Khmer]]&lt;br /&gt;(code: &lt;code&gt;km&lt;/code&gt;)
|-
| [[:kn:User:PK2|User page]] in [[:en:Kannada|Kannada]]&lt;br /&gt;(code: &lt;code&gt;kn&lt;/code&gt;)
| [[:knc:User:PK2|User page]] in [[:en:Central Kanuri|Central Kanuri]]&lt;br /&gt;(code: &lt;code&gt;knc&lt;/code&gt;)
| [[:ko:User:PK2|User page]] in [[:en:Korean language|Korean]]&lt;br /&gt;(code: &lt;code&gt;ko&lt;/code&gt;)
| [[:koi:User:PK2|User page]] in [[:en:Komi-Permyak language|Komi-Permyak]]&lt;br /&gt;(code: &lt;code&gt;koi&lt;/code&gt;)
| [[:krc:User:PK2|User page]] in [[:en:Karachay-Balkar|Karachay-Balkar]]&lt;br /&gt;(code: &lt;code&gt;krc&lt;/code&gt;)
| [[:ks:User:PK2|User page]] in [[:en:Kashmiri language|Kashmiri]]&lt;br /&gt;(code: &lt;code&gt;ks&lt;/code&gt;)
| [[:ksh:User:PK2|User page]] in [[:en:Ripuarian language|Ripuarian]]&lt;br /&gt;(code: &lt;code&gt;ksh&lt;/code&gt;)
| [[:ku:User:PK2|User page]] in [[:en:Kurdish language|Kurdish]] ([[:en:Kurmanji|Kurmanji]])&lt;br /&gt;(code: &lt;code&gt;ku&lt;/code&gt;)
| [[:kus:User:PK2|User page]] in [[:en:Kusaal language|Kusaal]]&lt;br /&gt;(code: &lt;code&gt;kus&lt;/code&gt;)
| [[:kv:User:PK2|User page]] in [[:en:Komi language|Komi]]&lt;br /&gt;(code: &lt;code&gt;kv&lt;/code&gt;)
| [[:kw:User:PK2|User page]] in [[:en:Cornish language|Cornish]]&lt;br /&gt;(code: &lt;code&gt;kw&lt;/code&gt;)
| [[:ky:User:PK2|User page]] in [[:en:Kyrgyz language|Kyrgyz]]&lt;br /&gt;(code: &lt;code&gt;ky&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ L
|-
| [[:la:User:PK2|User page]] in [[:en:Latin|Latin]]&lt;br /&gt;(code: &lt;code&gt;la&lt;/code&gt;)
| [[:lad:User:PK2|User page]] in [[:en:Judaeo-Spanish|Judaeo-Spanish]]&lt;br /&gt;(code: &lt;code&gt;lad&lt;/code&gt;)
| [[:lb:User:PK2|User page]] in [[:en:Luxembourgish|Luxembourgish]]&lt;br /&gt;(code: &lt;code&gt;lb&lt;/code&gt;)
| [[:lbe:User:PK2|User page]] in [[:en:Lak language|Lak]]&lt;br /&gt;(code: &lt;code&gt;lbe&lt;/code&gt;)
| [[:lez:User:PK2|User page]] in [[:en:Lezgian language|Lezgian]]&lt;br /&gt;(code: &lt;code&gt;lez&lt;/code&gt;)
| [[:lfn:User:PK2|User page]] in [[:en:Lingua Franca Nova|Lingua Franca Nova]]&lt;br /&gt;(code: &lt;code&gt;lfn&lt;/code&gt;)
| [[:lg:User:PK2|User page]] in [[:en:Luganda|Luganda]]&lt;br /&gt;(code: &lt;code&gt;lg&lt;/code&gt;)
| [[:li:User:PK2|User page]] in [[:en:Limburgish|Limburgish]]&lt;br /&gt;(code: &lt;code&gt;li&lt;/code&gt;)
|-
| [[:lij:User:PK2|User page]] in [[:en:Ligurian language|Ligurian]]&lt;br /&gt;(code: &lt;code&gt;lij&lt;/code&gt;)
| [[:lld:User:PK2|User page]] in [[:en:Ladin language|Ladin]]&lt;br /&gt;(code: &lt;code&gt;lld&lt;/code&gt;)
| [[:lmo:User:PK2|User page]] in [[:en:Lombard language|Lombard]]&lt;br /&gt;(code: &lt;code&gt;lmo&lt;/code&gt;)
| [[:ln:User:PK2|User page]] in [[:en:Lingala|Lingala]]&lt;br /&gt;(code: &lt;code&gt;ln&lt;/code&gt;)
| [[:lo:User:PK2|User page]] in [[:en:Lao language|Lao]]&lt;br /&gt;(code: &lt;code&gt;lo&lt;/code&gt;)
| [[:lt:User:PK2|User page]] in [[:en:Lithuanian language|Lithuanian]]&lt;br /&gt;(code: &lt;code&gt;lt&lt;/code&gt;)
| [[:ltg:User:PK2|User page]] in [[:en:Latgalian language|Latgalian]]&lt;br /&gt;(code: &lt;code&gt;ltg&lt;/code&gt;)
| [[:lv:User:PK2|User page]] in [[:en:Latvian language|Latvian]]&lt;br /&gt;(code: &lt;code&gt;lv&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ M
|-
| [[:mad:User:PK2|User page]] in [[:en:Madurese language|Madurese]]&lt;br /&gt;(code: &lt;code&gt;mad&lt;/code&gt;)
| [[:mai:User:PK2|User page]] in [[:en:Maithili language|Maithili]]&lt;br /&gt;(code: &lt;code&gt;mai&lt;/code&gt;)
| [[:map-bms:User:PK2|User page]] in [[:en:Javanese language|Javanese]] ([[:en:Banyumasan dialect|Banyumasan]])&lt;br /&gt;(code: &lt;code&gt;map-bms&lt;/code&gt;)
| [[:mdf:User:PK2|User page]] in [[:en:Moksha language|Moksha]]&lt;br /&gt;(code: &lt;code&gt;mdf&lt;/code&gt;)
| [[:mg:User:PK2|User page]] in [[:en:Malagasy language|Malagasy]]&lt;br /&gt;(code: &lt;code&gt;mg&lt;/code&gt;)
| [[:mhr:User:PK2|User page]] in [[:en:Meadow Mari language|Meadow Mari]]&lt;br /&gt;(code: &lt;code&gt;mhr&lt;/code&gt;)
| [[:mi:User:PK2|User page]] in [[:en:Māori language|Māori]]&lt;br /&gt;(code: &lt;code&gt;mi&lt;/code&gt;)
| [[:min:User:PK2|User page]] in [[:en:Minangkabau language|Minangkabau]]&lt;br /&gt;(code: &lt;code&gt;min&lt;/code&gt;)
| [[:mk:User:PK2|User page]] in [[:en:Macedonian language|Macedonian]]&lt;br /&gt;(code: &lt;code&gt;mk&lt;/code&gt;)
| [[:ml:User:PK2|User page]] in [[:en:Malayalam|Malayalam]]&lt;br /&gt;(code: &lt;code&gt;ml&lt;/code&gt;)
| [[:mn:User:PK2|User page]] in [[:en:Mongolian language|Mongolian]]&lt;br /&gt;(code: &lt;code&gt;mn&lt;/code&gt;)
|-
| [[:mni:User:PK2|User page]] in [[:en:Meitei language|Meitei]]&lt;br /&gt;(code: &lt;code&gt;mni&lt;/code&gt;)
| [[:mnw:User:PK2|User page]] in [[:en:Mon language|Mon]]&lt;br /&gt;(code: &lt;code&gt;mnw&lt;/code&gt;)
| [[:m:mos:User:PK2|User page]] in [[:en:Mooré|Mooré]]&lt;br /&gt;(code: &lt;code&gt;mos&lt;/code&gt;)
| [[:mr:User:PK2|User page]] in [[:en:Marathi language|Marathi]]&lt;br /&gt;(code: &lt;code&gt;mr&lt;/code&gt;)
| [[:mrj:User:PK2|User page]] in [[:en:Hill Mari language|Hill Mari]]&lt;br /&gt;(code: &lt;code&gt;mrj&lt;/code&gt;)
| [[:ms:User:PK2|User page]] in [[:en:Malay language|Malay]]&lt;br /&gt;(code: &lt;code&gt;ms&lt;/code&gt;)
| [[:mt:User:PK2|User page]] in [[:en:Maltese language|Maltese]]&lt;br /&gt;(code: &lt;code&gt;mt&lt;/code&gt;)
| [[:mwl:User:PK2|User page]] in [[:en:Mirandese language|Mirandese]]&lt;br /&gt;(code: &lt;code&gt;mwl&lt;/code&gt;)
| [[:my:User:PK2|User page]] in [[:en:Burmese language|Burmese]]&lt;br /&gt;(code: &lt;code&gt;my&lt;/code&gt;)
| [[:myv:User:PK2|User page]] in [[:en:Erzya language|Erzya]]&lt;br /&gt;(code: &lt;code&gt;myv&lt;/code&gt;)
| [[:mzn:User:PK2|User page]] in [[:en:Mazanderani language|Mazanderani]]&lt;br /&gt;(code: &lt;code&gt;mzn&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ N
|-
| [[:nah:User:PK2|User page]] in [[:en:Nahuatl|Nahuatl]]&lt;br /&gt;(code: &lt;code&gt;nah&lt;/code&gt;)
| [[:nap:User:PK2|User page]] in [[:en:Neapolitan language|Neapolitan]]&lt;br /&gt;(code: &lt;code&gt;nap&lt;/code&gt;)
| [[:nds:User:PK2|User page]] in [[:en:Low German|Low German]]&lt;br /&gt;(code: &lt;code&gt;nds&lt;/code&gt;)
| [[:nds-nl:User:PK2|User page]] in [[:en:Dutch Low Saxon|Dutch Low Saxon]]&lt;br /&gt;(code: &lt;code&gt;nds-nl&lt;/code&gt;)
| [[:ne:User:PK2|User page]] in [[:en:Nepali language|Nepali]]&lt;br /&gt;(code: &lt;code&gt;ne&lt;/code&gt;)
| [[:new:User:PK2|User page]] in [[:en:Newar language|Newar]]&lt;br /&gt;(code: &lt;code&gt;new&lt;/code&gt;)
| [[:nia:User:PK2|User page]] in [[:en:Nias language|Nias]]&lt;br /&gt;(code: &lt;code&gt;nia&lt;/code&gt;)
| [[:nl:User:PK2|User page]] in [[:en:Dutch language|Dutch]]&lt;br /&gt;(code: &lt;code&gt;nl&lt;/code&gt;)
| [[:nn:User:PK2|User page]] in [[:en:Norwegian language|Norwegian]] ([[:en:Nynorsk|Nynorsk]])&lt;br /&gt;(code: &lt;code&gt;nn&lt;/code&gt;)
|-
| [[:no:User:PK2|User page]] in [[:en:Norwegian language|Norwegian]] ([[:en:Bokmål|Bokmål]])&lt;br /&gt;(code: &lt;code&gt;no&lt;/code&gt;)
| [[:nov:User:PK2|User page]] in [[:en:Novial|Novial]]&lt;br /&gt;(code: &lt;code&gt;nov&lt;/code&gt;)
| [[:nqo:User:PK2|User page]] in [[:en:N'Ko language|N'Ko]]&lt;br /&gt;(code: &lt;code&gt;nqo&lt;/code&gt;)
| [[:nr:User:PK2|User page]] in [[:en:Southern Ndebele language|Southern Ndebele]]&lt;br /&gt;(code: &lt;code&gt;nr&lt;/code&gt;)
| [[:nrm:User:PK2|User page]] in [[:en:Norman language|Norman]]&lt;br /&gt;(code: &lt;code&gt;nrm&lt;/code&gt;)
| [[:nso:User:PK2|User page]] in [[:en:Northern Sotho|Northern Sotho]]&lt;br /&gt;(code: &lt;code&gt;nso&lt;/code&gt;)
| [[:nup:User:PK2|User page]] in [[:en:Nupe language|Nupe]]&lt;br /&gt;(code: &lt;code&gt;nup&lt;/code&gt;)
| [[:nv:User:PK2|User page]] in [[:en:Navajo language|Navajo]]&lt;br /&gt;(code: &lt;code&gt;nv&lt;/code&gt;)
| [[:ny:User:PK2|User page]] in [[:en:Chewa language|Chewa]]&lt;br /&gt;(code: &lt;code&gt;ny&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ O
|-
| [[:oc:User:PK2|User page]] in [[:en:Occitan language|Occitan]]&lt;br /&gt;(code: &lt;code&gt;oc&lt;/code&gt;)
| [[:olo:User:PK2|User page]] in [[:en:Livvi-Karelian language|Livvi-Karelian]]&lt;br /&gt;(code: &lt;code&gt;olo&lt;/code&gt;)
| [[:om:User:PK2|User page]] in [[:en:Oromo language|Oromo]]&lt;br /&gt;(code: &lt;code&gt;om&lt;/code&gt;)
| [[:or:User:PK2|User page]] in [[:en:Odia language|Odia]]&lt;br /&gt;(code: &lt;code&gt;or&lt;/code&gt;)
| [[:os:User:PK2|User page]] in [[:en:Ossetian language|Ossetian]]&lt;br /&gt;(code: &lt;code&gt;os&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ P
|-
| [[:pa:User:PK2|User page]] in [[:en:Punjabi language|Punjabi]]&lt;br /&gt;(code: &lt;code&gt;pa&lt;/code&gt;)
| [[:pag:User:PK2|User page]] in [[:en:Pangasinan language|Pangasinan]]&lt;br /&gt;(code: &lt;code&gt;pag&lt;/code&gt;)
| [[:pam:User:PK2|User page]] in [[:en:Kapampangan language|Kapampangan]]&lt;br /&gt;(code: &lt;code&gt;pam&lt;/code&gt;)
| [[:pap:User:PK2|User page]] in [[:en:Papiamento|Papiamento]]&lt;br /&gt;(code: &lt;code&gt;pap&lt;/code&gt;)
| [[:pcd:User:PK2|User page]] in [[:en:Picard language|Picard]]&lt;br /&gt;(code: &lt;code&gt;pcd&lt;/code&gt;)
| [[:pcm:User:PK2|User page]] in [[:en:Nigerian Pidgin|Nigerian Pidgin]]&lt;br /&gt;(code: &lt;code&gt;pcm&lt;/code&gt;)
| [[:pdc:User:PK2|User page]] in [[:en:Pennsylvania Dutch language|Pennsylvania Dutch]]&lt;br /&gt;(code: &lt;code&gt;pdc&lt;/code&gt;)
| [[:pfl:User:PK2|User page]] in [[:en:Palatine German dialects|Palatine German]]&lt;br /&gt;(code: &lt;code&gt;pfl&lt;/code&gt;)
| [[:pi:User:PK2|User page]] in [[:en:Pali|Pali]]&lt;br /&gt;(code: &lt;code&gt;pi&lt;/code&gt;)
|-
| [[:pl:User:PK2|User page]] in [[:en:Polish language|Polish]]&lt;br /&gt;(code: &lt;code&gt;pl&lt;/code&gt;)
| [[:pms:User:PK2|User page]] in [[:en:Piedmontese language|Piedmontese]]&lt;br /&gt;(code: &lt;code&gt;pms&lt;/code&gt;)
| [[:pnb:User:PK2|User page]] in [[:en:Punjabi language|Punjabi]] (Western Punjabi)&lt;br /&gt;(code: &lt;code&gt;pnb&lt;/code&gt;)
| [[:pnt:User:PK2|User page]] in [[:en:Pontic Greek|Pontic Greek]]&lt;br /&gt;(code: &lt;code&gt;pnt&lt;/code&gt;)
| [[:ppl:User:PK2|User page]] in [[:en:Nawat language|Nawat]]&lt;br /&gt;(code: &lt;code&gt;ppl&lt;/code&gt;)
| [[:ps:User:PK2|User page]] in [[:en:Pashto|Pashto]]&lt;br /&gt;(code: &lt;code&gt;ps&lt;/code&gt;)
| [[:pt:User:PK2|User page]] in [[:en:Portuguese language|Portuguese]]&lt;br /&gt;(code: &lt;code&gt;pt&lt;/code&gt;)
| [[:pwn:User:PK2|User page]] in [[:en:Paiwan language|Paiwan]]&lt;br /&gt;(code: &lt;code&gt;pwn&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ Q
|-
| [[:qu:User:PK2|User page]] in [[:en:Quechuan languages|Quechua]] ([[:en:Southern Quechua|Southern Quechua]])&lt;br /&gt;(code: &lt;code&gt;qu&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ R
|-
| [[:rki:User:PK2|User page]] in [[:en:Rakhine language|Rakhine]]&lt;br /&gt;(code: &lt;code&gt;rki&lt;/code&gt;)
| [[:rm:User:PK2|User page]] in [[:en:Romansh language|Romansh]]&lt;br /&gt;(code: &lt;code&gt;rm&lt;/code&gt;)
| [[:rmy:User:PK2|User page]] in [[:en:Romani language|Romani]] ([[:en:Vlax Romani language|Vlax Romani]])&lt;br /&gt;(code: &lt;code&gt;rmy&lt;/code&gt;)
| [[:rn:User:PK2|User page]] in [[:en:Kirundi|Kirundi]]&lt;br /&gt;(code: &lt;code&gt;rn&lt;/code&gt;)
| [[:ro:User:PK2|User page]] in [[:en:Romanian language|Romanian]]&lt;br /&gt;(code: &lt;code&gt;ro&lt;/code&gt;)
| [[:roa-rup:User:PK2|User page]] in [[:en:Aromanian language|Aromanian]]&lt;br /&gt;(code: &lt;code&gt;roa-rup&lt;/code&gt;)
| [[:roa-tara:User:PK2|User page]] in [[:en:Neapolitan language|Neapolitan]] ([[:en:Tarantino dialect|Tarantino]])&lt;br /&gt;(code: &lt;code&gt;roa-tara&lt;/code&gt;)
| [[:rsk:User:PK2|User page]] in [[:en:Pannonian Rusyn|Pannonian Rusyn]]&lt;br /&gt;(code: &lt;code&gt;rsk&lt;/code&gt;)
| [[:ru:User:PK2|User page]] in [[:en:Russian language|Russian]]&lt;br /&gt;(code: &lt;code&gt;ru&lt;/code&gt;)
| [[:rue:User:PK2|User page]] in [[:en:Rusyn language|Rusyn]]&lt;br /&gt;(code: &lt;code&gt;rue&lt;/code&gt;)
| [[:rw:User:PK2|User page]] in [[:en:Kinyarwanda|Kinyarwanda]]&lt;br /&gt;(code: &lt;code&gt;rw&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ S
|-
| [[:sa:User:PK2|User page]] in [[:en:Sanskrit|Sanskrit]]&lt;br /&gt;(code: &lt;code&gt;sa&lt;/code&gt;)
| [[:sah:User:PK2|User page]] in [[:en:Yakut language|Yakut]]&lt;br /&gt;(code: &lt;code&gt;sah&lt;/code&gt;)
| [[:sat:User:PK2|User page]] in [[:en:Santali language|Santali]]&lt;br /&gt;(code: &lt;code&gt;sat&lt;/code&gt;)
| [[:sc:User:PK2|User page]] in [[:en:Sardinian language|Sardinian]]&lt;br /&gt;(code: &lt;code&gt;sc&lt;/code&gt;)
| [[:scn:User:PK2|User page]] in [[:en:Sicilian language|Sicilian]]&lt;br /&gt;(code: &lt;code&gt;scn&lt;/code&gt;)
| [[:sco:User:PK2|User page]] in [[:en:Scots language|Scots]]&lt;br /&gt;(code: &lt;code&gt;sco&lt;/code&gt;)
| [[:sd:User:PK2|User page]] in [[:en:Sindhi language|Sindhi]]&lt;br /&gt;(code: &lt;code&gt;sd&lt;/code&gt;)
| [[:se:User:PK2|User page]] in [[:en:Northern Sámi|Northern Sámi]]&lt;br /&gt;(code: &lt;code&gt;se&lt;/code&gt;)
| [[:sg:User:PK2|User page]] in [[:en:Sango language|Sango]]&lt;br /&gt;(code: &lt;code&gt;sg&lt;/code&gt;)
| [[:sh:User:PK2|User page]] in [[:en:Serbo-Croatian|Serbo-Croatian]]&lt;br /&gt;(code: &lt;code&gt;sh&lt;/code&gt;)
| [[:shi:User:PK2|User page]] in [[:en:Shilha language|Shilha]]&lt;br /&gt;(code: &lt;code&gt;shi&lt;/code&gt;)
|-
| [[:shn:User:PK2|User page]] in [[:en:Shan language|Shan]]&lt;br /&gt;(code: &lt;code&gt;shn&lt;/code&gt;)
| [[:si:User:PK2|User page]] in [[:en:Sinhala language|Sinhala]]&lt;br /&gt;(code: &lt;code&gt;si&lt;/code&gt;)
| [[:simple:User:PK2|User page]] in [[:en:Basic English|Basic English]]&lt;br /&gt;(code: &lt;code&gt;simple&lt;/code&gt;)
| [[:sk:User:PK2|User page]] in [[:en:Slovak language|Slovak]]&lt;br /&gt;(code: &lt;code&gt;sk&lt;/code&gt;)
| [[:skr:User:PK2|User page]] in [[:en:Saraiki language|Saraiki]]&lt;br /&gt;(code: &lt;code&gt;skr&lt;/code&gt;)
| [[:sl:User:PK2|User page]] in [[:en:Slovene language|Slovene]]&lt;br /&gt;(code: &lt;code&gt;sl&lt;/code&gt;)
| [[:sm:User:PK2|User page]] in [[:en:Samoan language|Samoan]]&lt;br /&gt;(code: &lt;code&gt;sm&lt;/code&gt;)
| [[:smn:User:PK2|User page]] in [[:en:Inari Sámi language|Inari Sámi]]&lt;br /&gt;(code: &lt;code&gt;smn&lt;/code&gt;)
| [[:sn:User:PK2|User page]] in [[:en:Shona language|Shona]]&lt;br /&gt;(code: &lt;code&gt;sn&lt;/code&gt;)
| [[:so:User:PK2|User page]] in [[:en:Somali language|Somali]]&lt;br /&gt;(code: &lt;code&gt;so&lt;/code&gt;)
| [[:sq:User:PK2|User page]] in [[:en:Albanian language|Albanian]]&lt;br /&gt;(code: &lt;code&gt;sq&lt;/code&gt;)
|-
| [[:sr:User:PK2|User page]] in [[:en:Serbian language|Serbian]]&lt;br /&gt;(code: &lt;code&gt;sr&lt;/code&gt;)
| [[:srn:User:PK2|User page]] in [[:en:Sranan Tongo|Sranan Tongo]]&lt;br /&gt;(code: &lt;code&gt;srn&lt;/code&gt;)
| [[:ss:User:PK2|User page]] in [[:en:Swazi language|Swazi]]&lt;br /&gt;(code: &lt;code&gt;ss&lt;/code&gt;)
| [[:st:User:PK2|User page]] in [[:en:Sotho language|Sotho]]&lt;br /&gt;(code: &lt;code&gt;st&lt;/code&gt;)
| [[:stq:User:PK2|User page]] in [[:en:Saterland Frisian language|Saterland Frisian]]&lt;br /&gt;(code: &lt;code&gt;stq&lt;/code&gt;)
| [[:su:User:PK2|User page]] in [[:en:Sundanese language|Sundanese]]&lt;br /&gt;(code: &lt;code&gt;su&lt;/code&gt;)
| [[:sv:User:PK2|User page]] in [[:en:Swedish language|Swedish]]&lt;br /&gt;(code: &lt;code&gt;sv&lt;/code&gt;)
| [[:sw:User:PK2|User page]] in [[:en:Swahili language|Swahili]]&lt;br /&gt;(code: &lt;code&gt;sw&lt;/code&gt;)
| [[:syl:User:PK2|User page]] in [[:en:Sylheti language|Sylheti]]&lt;br /&gt;(code: &lt;code&gt;syl&lt;/code&gt;)
| [[:szl:User:PK2|User page]] in [[:en:Silesian language|Silesian]]&lt;br /&gt;(code: &lt;code&gt;szl&lt;/code&gt;)
| [[:szy:User:PK2|User page]] in [[:en:Sakizaya language|Sakizaya]]&lt;br /&gt;(code: &lt;code&gt;szy&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ T
|-
| [[:ta:User:PK2|User page]] in [[:en:Tamil language|Tamil]]&lt;br /&gt;(code: &lt;code&gt;ta&lt;/code&gt;)
| [[:tay:User:PK2|User page]] in [[:en:Atayal language|Atayal]]&lt;br /&gt;(code: &lt;code&gt;tay&lt;/code&gt;)
| [[:tcy:User:PK2|User page]] in [[:en:Tulu language|Tulu]]&lt;br /&gt;(code: &lt;code&gt;tcy&lt;/code&gt;)
| [[:tdd:User:PK2|User page]] in [[:en:Tai Nuea language|Tai Nuea]]&lt;br /&gt;(code: &lt;code&gt;tdd&lt;/code&gt;)
| [[:te:User:PK2|User page]] in [[:en:Telugu language|Telugu]]&lt;br /&gt;(code: &lt;code&gt;te&lt;/code&gt;)
| [[:tet:User:PK2|User page]] in [[:en:Tetum language|Tetum]]&lt;br /&gt;(code: &lt;code&gt;tet&lt;/code&gt;)
| [[:tg:User:PK2|User page]] in [[:en:Tajik language|Tajik]]&lt;br /&gt;(code: &lt;code&gt;tg&lt;/code&gt;)
| [[:th:User:PK2|User page]] in [[:en:Thai language|Thai]]&lt;br /&gt;(code: &lt;code&gt;th&lt;/code&gt;)
| [[:ti:User:PK2|User page]] in [[:en:Tigrinya language|Tigrinya]]&lt;br /&gt;(code: &lt;code&gt;ti&lt;/code&gt;)
| [[:tig:User:PK2|User page]] in [[:en:Tigre language|Tigre]]&lt;br /&gt;(code: &lt;code&gt;tig&lt;/code&gt;)
| [[:tk:User:PK2|User page]] in [[:en:Turkmen language|Turkmen]]&lt;br /&gt;(code: &lt;code&gt;tk&lt;/code&gt;)
| [[:tl:User:PK2|User page]] in [[:en:Tagalog language|Tagalog]]&lt;br /&gt;(code: &lt;code&gt;tl&lt;/code&gt;)
| [[:tly:User:PK2|User page]] in [[:en:Talysh language|Talysh]]&lt;br /&gt;(code: &lt;code&gt;tly&lt;/code&gt;)
|-
| [[:tn:User:PK2|User page]] in [[:en:Tswana language|Tswana]]&lt;br /&gt;(code: &lt;code&gt;tn&lt;/code&gt;)
| [[:to:User:PK2|User page]] in [[:en:Tongan language|Tongan]]&lt;br /&gt;(code: &lt;code&gt;to&lt;/code&gt;)
| [[:tok:User:PK2|User page]] in [[:en:Toki Pona|Toki Pona]]&lt;br /&gt;(code: &lt;code&gt;tok&lt;/code&gt;)
| [[:tpi:User:PK2|User page]] in [[:en:Tok Pisin|Tok Pisin]]&lt;br /&gt;(code: &lt;code&gt;tpi&lt;/code&gt;)
| [[:tr:User:PK2|User page]] in [[:en:Turkish language|Turkish]]&lt;br /&gt;(code: &lt;code&gt;tr&lt;/code&gt;)
| [[:trv:User:PK2|User page]] in [[:en:Seediq language|Seediq]]&lt;br /&gt;(code: &lt;code&gt;trv&lt;/code&gt;)
| [[:ts:User:PK2|User page]] in [[:en:Tsonga language|Tsonga]]&lt;br /&gt;(code: &lt;code&gt;ts&lt;/code&gt;)
| [[:tt:User:PK2|User page]] in [[:en:Tatar language|Tatar]]&lt;br /&gt;(code: &lt;code&gt;tt&lt;/code&gt;)
| [[:tum:User:PK2|User page]] in [[:en:Tumbuka language|Tumbuka]]&lt;br /&gt;(code: &lt;code&gt;tum&lt;/code&gt;)
| [[:tw:User:PK2|User page]] in [[:en:Akan language|Akan]] (Twi)&lt;br /&gt;(code: &lt;code&gt;tw&lt;/code&gt;)
| [[:ty:User:PK2|User page]] in [[:en:Tahitian language|Tahitian]]&lt;br /&gt;(code: &lt;code&gt;ty&lt;/code&gt;)
| [[:tyv:User:PK2|User page]] in [[:en:Tuvan language|Tuvan]]&lt;br /&gt;(code: &lt;code&gt;tyv&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ U
|-
| [[:udm:User:PK2|User page]] in [[:en:Udmurt language|Udmurt]]&lt;br /&gt;(code: &lt;code&gt;udm&lt;/code&gt;)
| [[:ug:User:PK2|User page]] in [[:en:Uyghur language|Uyghur]]&lt;br /&gt;(code: &lt;code&gt;ug&lt;/code&gt;)
| [[:uk:User:PK2|User page]] in [[:en:Ukrainian language|Ukrainian]]&lt;br /&gt;(code: &lt;code&gt;uk&lt;/code&gt;)
| [[:ur:User:PK2|User page]] in [[:en:Urdu|Urdu]]&lt;br /&gt;(code: &lt;code&gt;ur&lt;/code&gt;)
| [[:uz:User:PK2|User page]] in [[:en:Uzbek language|Uzbek]]&lt;br /&gt;(code: &lt;code&gt;uz&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ V
|-
| [[:ve:User:PK2|User page]] in [[:en:Venda language|Venda]]&lt;br /&gt;(code: &lt;code&gt;ve&lt;/code&gt;)
| [[:vec:User:PK2|User page]] in [[:en:Venetian language|Venetian]]&lt;br /&gt;(code: &lt;code&gt;vec&lt;/code&gt;)
| [[:vep:User:PK2|User page]] in [[:en:Veps language|Veps]]&lt;br /&gt;(code: &lt;code&gt;vep&lt;/code&gt;)
| [[:vi:User:PK2|User page]] in [[:en:Vietnamese language|Vietnamese]]&lt;br /&gt;(code: &lt;code&gt;vi&lt;/code&gt;)
| [[:vls:User:PK2|User page]] in [[:en:West Flemish|West Flemish]]&lt;br /&gt;(code: &lt;code&gt;vls&lt;/code&gt;)
| [[:vo:User:PK2|User page]] in [[:en:Volapük|Volapük]]&lt;br /&gt;(code: &lt;code&gt;vo&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ W
|-
| [[:wa:User:PK2|User page]] in [[:en:Walloon language|Walloon]]&lt;br /&gt;(code: &lt;code&gt;wa&lt;/code&gt;)
| [[:war:User:PK2|User page]] in [[:en:Waray language|Waray]]&lt;br /&gt;(code: &lt;code&gt;war&lt;/code&gt;)
| [[:wo:User:PK2|User page]] in [[:en:Wolof language|Wolof]]&lt;br /&gt;(code: &lt;code&gt;wo&lt;/code&gt;)
| [[:wuu:User:PK2|User page]] in [[:en:Wu Chinese|Wu Chinese]]&lt;br /&gt;(code: &lt;code&gt;wuu&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ X
|-
| [[:xal:User:PK2|User page]] in [[:en:Oirat language|Oirat]] ([[:en:Kalmyk Oirat|Kalmyk Oirat]])&lt;br /&gt;(code: &lt;code&gt;xal&lt;/code&gt;)
| [[:xh:User:PK2|User page]] in [[:en:Xhosa language|Xhosa]]&lt;br /&gt;(code: &lt;code&gt;xh&lt;/code&gt;)
| [[:xmf:User:PK2|User page]] in [[:en:Mingrelian language|Mingrelian]]&lt;br /&gt;(code: &lt;code&gt;xmf&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ Y
|-
| [[:yi:User:PK2|User page]] in [[:en:Yiddish|Yiddish]]&lt;br /&gt;(code: &lt;code&gt;yi&lt;/code&gt;)
| [[:yo:User:PK2|User page]] in [[:en:Yoruba language|Yoruba]]&lt;br /&gt;(code: &lt;code&gt;yo&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ Z
|-
| [[:za:User:PK2|User page]] in [[:en:Zhuang languages|Zhuang]] ([[:en:Standard Zhuang|Standard Zhuang]])&lt;br /&gt;(code: &lt;code&gt;za&lt;/code&gt;)
| [[:zea:User:PK2|User page]] in [[:en:Zeelandic|Zeelandic]]&lt;br /&gt;(code: &lt;code&gt;zea&lt;/code&gt;)
| [[:zgh:User:PK2|User page]] in [[:en:Standard Moroccan Amazigh|Standard Moroccan Amazigh]]&lt;br /&gt;(code: &lt;code&gt;zgh&lt;/code&gt;)
| [[:zh:User:PK2|User page]] in [[:en:Chinese language|Chinese]] ([[:en:Mandarin Chinese|Mandarin Chinese]])&lt;br /&gt;(code: &lt;code&gt;zh&lt;/code&gt;)
| [[:zh-classical:User:PK2|User page]] in [[:en:Classical Chinese|Classical Chinese]]&lt;br /&gt;(code: &lt;code&gt;zh-classical&lt;/code&gt;)
| [[:zh-min-nan:User:PK2|User page]] in [[:en:Southern Min|Southern Min]]&lt;br /&gt;(code: &lt;code&gt;zh-min-nan&lt;/code&gt;)
| [[:zh-yue:User:PK2|User page]] in [[:en:Cantonese|Cantonese]]&lt;br /&gt;(code: &lt;code&gt;zh-yue&lt;/code&gt;)
| [[:zu:User:PK2|User page]] in [[:en:Zulu language|Zulu]]&lt;br /&gt;(code: &lt;code&gt;zu&lt;/code&gt;)
|}</text>
      <sha1>dud3tixug1qffje4pl8q76cccmmhg8l</sha1>
    </revision>
  </page>
  <page>
    <title>U-Bernadette Meehan</title>
    <ns>0</ns>
    <id>1010</id>
    <revision>
      <id>6066</id>
      <timestamp>2025-12-10T04:42:39Z</timestamp>
      <contributor>
        <username>WikiMzansi</username>
        <id>1200</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1326633823|Bernadette Meehan]]&quot;</comment>
      <origin>6066</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2162" sha1="hnbxr5gko8cyyqc0nl6mmn8gj3kaiv1" xml:space="preserve"> 

'''U-Bernadette M. Meehan''' ( wazalwa 1975) mthunywa we-America owasebenza njengeNxusa le-United States e-Chile kusukela ngo-2022 ukuya ku-2025. Ukhethwe njengesikhulu esiphezulu (CEO) se-Wikimedia Foundation, begodu uzokuthatha indima leyo mhlazi-20 kuTjhirhweni 2026, athathe isikhundla se-Maryana Iska[1] Ngaphambilini bekasebenza njengosekela mongameli omkhulu weenhlelo zephasi loke ze-Obama Foundation.[2] Wasebenza njengomkhulumeli we-United States National Security Council ngesikhathi sokuBusa kwaka-Obama, begodu waba sikhulu se-Foreign Service noMnyango wezoMbuso iminyaka engaphezu kwetjhumi.

== Ipilo yokuthoma nefundo ==
U-Meehan wabelethwa e- Bronx, wakhulela e- Pleasantville, e-New York begodu waphothula e -Kennedy Catholic High School e -Somers, e-New York .  Waphothula e- Boston College nge- Bachelor of Arts degree yezepolotiki . &lt;ref name=&quot;:0&quot; /&gt; Ngemva kokuphothula, wasebenza e -Wall Street, kokuthoma e -JPMorgan Chase bese kuba yi-Lehman Brothers .  Ngokukhamba kwesikhathi wajoyina i- United States Foreign Service . &lt;ref name=&quot;:0&quot; /&gt;  

== Ibizelo ==
U-Meehan wajoyina i- United States Department of State njengesikhulu se-Foreign Service ngo-2004, begodu wathoma umsebenzi wakhe omutjha njenge-consular officer e-US Embassy e- Bogotá, e-Colombia.  Wasinda ekuthunjweni nokuhlaselwa ngokomzimba babantu abahlomileko e-Bogotá ngoMrhayili 2006. Ababili bezenzo zobumbi babotjhwa begodu bagwetjwa iminyaka elitjhumi ejele, kuthi ababili abenza ubumbi azange batholakale.  
[[Isimumathi:Deputy_Secretary_Sherman_Officiates_the_Swearing-In_Ceremony_of_Ambassador_Bernadette_M._Meehan_(52320011503).jpg|thumb|U-Meehan wafungiswa njengeNxusa le-Chile ngo-2022 nguSekela likaNobhala weNarha u-Wendy Sherman]]

=== Umsebenzi wangemva kokuba yinxusa ===
Mhlana amalanga ali-9 kuNobayeni 2025, u-Meehan wabekwa njenge-CEO ye-Wikimedia Foundation.  Uzakuthatha indima mhlazi-20 kuTjhirhweni 2026. 

== Ipilo yomuntu mathupha ==
U-Meehan ukhuluma isiNgisi, isiSpanishi nesi -Arabhu .  Utjhade no- Evan S. Medeiros, uSihlalo womndeni we-Penner ku-Asian Studies e- Georgetown University 's Walsh School of Foreign Service . 

== Iinkomba ==</text>
      <sha1>hnbxr5gko8cyyqc0nl6mmn8gj3kaiv1</sha1>
    </revision>
    <revision>
      <id>6067</id>
      <parentid>6066</parentid>
      <timestamp>2025-12-10T04:43:12Z</timestamp>
      <contributor>
        <username>WikiMzansi</username>
        <id>1200</id>
      </contributor>
      <origin>6067</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2160" sha1="nuladxvm7dw2ra6dt4s6bry50hjksaf" xml:space="preserve"> '''U-Bernadette M. Meehan''' ( wazalwa 1975) mthunywa we-America owasebenza njengeNxusa le-United States e-Chile kusukela ngo-2022 ukuya ku-2025. Ukhethwe njengesikhulu esiphezulu (CEO) se-Wikimedia Foundation, begodu uzokuthatha indima leyo mhlazi-20 kuTjhirhweni 2026, athathe isikhundla se-Maryana Iska[1] Ngaphambilini bekasebenza njengosekela mongameli omkhulu weenhlelo zephasi loke ze-Obama Foundation.[2] Wasebenza njengomkhulumeli we-United States National Security Council ngesikhathi sokuBusa kwaka-Obama, begodu waba sikhulu se-Foreign Service noMnyango wezoMbuso iminyaka engaphezu kwetjhumi.

== Ipilo yokuthoma nefundo ==
U-Meehan wabelethwa e- Bronx, wakhulela e- Pleasantville, e-New York begodu waphothula e -Kennedy Catholic High School e -Somers, e-New York .  Waphothula e- Boston College nge- Bachelor of Arts degree yezepolotiki . &lt;ref name=&quot;:0&quot; /&gt; Ngemva kokuphothula, wasebenza e -Wall Street, kokuthoma e -JPMorgan Chase bese kuba yi-Lehman Brothers .  Ngokukhamba kwesikhathi wajoyina i- United States Foreign Service . &lt;ref name=&quot;:0&quot; /&gt;  

== Ibizelo ==
U-Meehan wajoyina i- United States Department of State njengesikhulu se-Foreign Service ngo-2004, begodu wathoma umsebenzi wakhe omutjha njenge-consular officer e-US Embassy e- Bogotá, e-Colombia.  Wasinda ekuthunjweni nokuhlaselwa ngokomzimba babantu abahlomileko e-Bogotá ngoMrhayili 2006. Ababili bezenzo zobumbi babotjhwa begodu bagwetjwa iminyaka elitjhumi ejele, kuthi ababili abenza ubumbi azange batholakale.  
[[Isimumathi:Deputy_Secretary_Sherman_Officiates_the_Swearing-In_Ceremony_of_Ambassador_Bernadette_M._Meehan_(52320011503).jpg|thumb|U-Meehan wafungiswa njengeNxusa le-Chile ngo-2022 nguSekela likaNobhala weNarha u-Wendy Sherman]]

=== Umsebenzi wangemva kokuba yinxusa ===
Mhlana amalanga ali-9 kuNobayeni 2025, u-Meehan wabekwa njenge-CEO ye-Wikimedia Foundation.  Uzakuthatha indima mhlazi-20 kuTjhirhweni 2026. 

== Ipilo yomuntu mathupha ==
U-Meehan ukhuluma isiNgisi, isiSpanishi nesi -Arabhu .  Utjhade no- Evan S. Medeiros, uSihlalo womndeni we-Penner ku-Asian Studies e- Georgetown University 's Walsh School of Foreign Service . 

== Iinkomba ==</text>
      <sha1>nuladxvm7dw2ra6dt4s6bry50hjksaf</sha1>
    </revision>
    <revision>
      <id>6068</id>
      <parentid>6067</parentid>
      <timestamp>2025-12-10T04:44:36Z</timestamp>
      <contributor>
        <username>WikiMzansi</username>
        <id>1200</id>
      </contributor>
      <origin>6068</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2200" sha1="f2bpos6ps44zvpt10m0ofwzdkkwcq3k" xml:space="preserve"> 
[[Isimumathi:Bernadette Meehan|thumb]]
'''U-Bernadette M. Meehan''' ( wazalwa 1975) mthunywa we-America owasebenza njengeNxusa le-United States e-Chile kusukela ngo-2022 ukuya ku-2025. Ukhethwe njengesikhulu esiphezulu (CEO) se-Wikimedia Foundation, begodu uzokuthatha indima leyo mhlazi-20 kuTjhirhweni 2026, athathe isikhundla se-Maryana Iska[1] Ngaphambilini bekasebenza njengosekela mongameli omkhulu weenhlelo zephasi loke ze-Obama Foundation.[2] Wasebenza njengomkhulumeli we-United States National Security Council ngesikhathi sokuBusa kwaka-Obama, begodu waba sikhulu se-Foreign Service noMnyango wezoMbuso iminyaka engaphezu kwetjhumi.

== Ipilo yokuthoma nefundo ==
U-Meehan wabelethwa e- Bronx, wakhulela e- Pleasantville, e-New York begodu waphothula e -Kennedy Catholic High School e -Somers, e-New York .  Waphothula e- Boston College nge- Bachelor of Arts degree yezepolotiki . &lt;ref name=&quot;:0&quot; /&gt; Ngemva kokuphothula, wasebenza e -Wall Street, kokuthoma e -JPMorgan Chase bese kuba yi-Lehman Brothers .  Ngokukhamba kwesikhathi wajoyina i- United States Foreign Service . &lt;ref name=&quot;:0&quot; /&gt;  

== Ibizelo ==
U-Meehan wajoyina i- United States Department of State njengesikhulu se-Foreign Service ngo-2004, begodu wathoma umsebenzi wakhe omutjha njenge-consular officer e-US Embassy e- Bogotá, e-Colombia.  Wasinda ekuthunjweni nokuhlaselwa ngokomzimba babantu abahlomileko e-Bogotá ngoMrhayili 2006. Ababili bezenzo zobumbi babotjhwa begodu bagwetjwa iminyaka elitjhumi ejele, kuthi ababili abenza ubumbi azange batholakale.  
[[Isimumathi:Deputy_Secretary_Sherman_Officiates_the_Swearing-In_Ceremony_of_Ambassador_Bernadette_M._Meehan_(52320011503).jpg|thumb|U-Meehan wafungiswa njengeNxusa le-Chile ngo-2022 nguSekela likaNobhala weNarha u-Wendy Sherman]]

=== Umsebenzi wangemva kokuba yinxusa ===
Mhlana amalanga ali-9 kuNobayeni 2025, u-Meehan wabekwa njenge-CEO ye-Wikimedia Foundation.  Uzakuthatha indima mhlazi-20 kuTjhirhweni 2026. 

== Ipilo yomuntu mathupha ==
U-Meehan ukhuluma isiNgisi, isiSpanishi nesi -Arabhu .  Utjhade no- Evan S. Medeiros, uSihlalo womndeni we-Penner ku-Asian Studies e- Georgetown University 's Walsh School of Foreign Service . 

== Iinkomba ==</text>
      <sha1>f2bpos6ps44zvpt10m0ofwzdkkwcq3k</sha1>
    </revision>
    <revision>
      <id>6069</id>
      <parentid>6068</parentid>
      <timestamp>2025-12-10T04:47:22Z</timestamp>
      <contributor>
        <username>WikiMzansi</username>
        <id>1200</id>
      </contributor>
      <origin>6069</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2221" sha1="t6hudmmusug0s8mv7hopne7v8yty9l6" xml:space="preserve">[[Isimumathi:Bernadette Meehan, NSC Spokesperson.jpg|thumb]]
 '''U-Bernadette M. Meehan''' ( wazalwa 1975) mthunywa we-America owasebenza njengeNxusa le-United States e-Chile kusukela ngo-2022 ukuya ku-2025. Ukhethwe njengesikhulu esiphezulu (CEO) se-Wikimedia Foundation, begodu uzokuthatha indima leyo mhlazi-20 kuTjhirhweni 2026, athathe isikhundla se-Maryana Iska[1] Ngaphambilini bekasebenza njengosekela mongameli omkhulu weenhlelo zephasi loke ze-Obama Foundation.[2] Wasebenza njengomkhulumeli we-United States National Security Council ngesikhathi sokuBusa kwaka-Obama, begodu waba sikhulu se-Foreign Service noMnyango wezoMbuso iminyaka engaphezu kwetjhumi.

== Ipilo yokuthoma nefundo ==
U-Meehan wabelethwa e- Bronx, wakhulela e- Pleasantville, e-New York begodu waphothula e -Kennedy Catholic High School e -Somers, e-New York .  Waphothula e- Boston College nge- Bachelor of Arts degree yezepolotiki . &lt;ref name=&quot;:0&quot; /&gt; Ngemva kokuphothula, wasebenza e -Wall Street, kokuthoma e -JPMorgan Chase bese kuba yi-Lehman Brothers .  Ngokukhamba kwesikhathi wajoyina i- United States Foreign Service . &lt;ref name=&quot;:0&quot; /&gt;  

== Ibizelo ==
U-Meehan wajoyina i- United States Department of State njengesikhulu se-Foreign Service ngo-2004, begodu wathoma umsebenzi wakhe omutjha njenge-consular officer e-US Embassy e- Bogotá, e-Colombia.  Wasinda ekuthunjweni nokuhlaselwa ngokomzimba babantu abahlomileko e-Bogotá ngoMrhayili 2006. Ababili bezenzo zobumbi babotjhwa begodu bagwetjwa iminyaka elitjhumi ejele, kuthi ababili abenza ubumbi azange batholakale.  
[[Isimumathi:Deputy_Secretary_Sherman_Officiates_the_Swearing-In_Ceremony_of_Ambassador_Bernadette_M._Meehan_(52320011503).jpg|thumb|U-Meehan wafungiswa njengeNxusa le-Chile ngo-2022 nguSekela likaNobhala weNarha u-Wendy Sherman]]

=== Umsebenzi wangemva kokuba yinxusa ===
Mhlana amalanga ali-9 kuNobayeni 2025, u-Meehan wabekwa njenge-CEO ye-Wikimedia Foundation.  Uzakuthatha indima mhlazi-20 kuTjhirhweni 2026. 

== Ipilo yomuntu mathupha ==
U-Meehan ukhuluma isiNgisi, isiSpanishi nesi -Arabhu .  Utjhade no- Evan S. Medeiros, uSihlalo womndeni we-Penner ku-Asian Studies e- Georgetown University 's Walsh School of Foreign Service . 

== Iinkomba ==</text>
      <sha1>t6hudmmusug0s8mv7hopne7v8yty9l6</sha1>
    </revision>
    <revision>
      <id>6070</id>
      <parentid>6069</parentid>
      <timestamp>2025-12-10T04:48:45Z</timestamp>
      <contributor>
        <username>WikiMzansi</username>
        <id>1200</id>
      </contributor>
      <origin>6070</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2355" sha1="p3269tjtvextc4ywaga13pf7bs53wl3" xml:space="preserve">[[Isimumathi:Bernadette Meehan, NSC Spokesperson.jpg|thumb]]
 '''U-Bernadette M. Meehan''' ( wazalwa 1975) mthunywa we-America owasebenza njengeNxusa le-United States e-Chile kusukela ngo-2022 ukuya ku-2025. Ukhethwe njengesikhulu esiphezulu (CEO) se-Wikimedia Foundation, begodu uzokuthatha indima leyo mhlazi-20 kuTjhirhweni 2026, athathe isikhundla se-Maryana Iska[1] Ngaphambilini bekasebenza njengosekela mongameli omkhulu weenhlelo zephasi loke ze-Obama Foundation.[2] Wasebenza njengomkhulumeli we-United States National Security Council ngesikhathi sokuBusa kwaka-Obama, begodu waba sikhulu se-Foreign Service noMnyango wezoMbuso iminyaka engaphezu kwetjhumi.&lt;ref&gt;https://wikimediafoundation.org/news/2025/12/09/wikimedia-foundation-appoints-bernadette-meehan-as-chief-executive-officer/&lt;/ref&gt;

== Ipilo yokuthoma nefundo ==
U-Meehan wabelethwa e- Bronx, wakhulela e- Pleasantville, e-New York begodu waphothula e -Kennedy Catholic High School e -Somers, e-New York .  Waphothula e- Boston College nge- Bachelor of Arts degree yezepolotiki . &lt;ref name=&quot;:0&quot; /&gt; Ngemva kokuphothula, wasebenza e -Wall Street, kokuthoma e -JPMorgan Chase bese kuba yi-Lehman Brothers .  Ngokukhamba kwesikhathi wajoyina i- United States Foreign Service . &lt;ref name=&quot;:0&quot; /&gt;  

== Ibizelo ==
U-Meehan wajoyina i- United States Department of State njengesikhulu se-Foreign Service ngo-2004, begodu wathoma umsebenzi wakhe omutjha njenge-consular officer e-US Embassy e- Bogotá, e-Colombia.  Wasinda ekuthunjweni nokuhlaselwa ngokomzimba babantu abahlomileko e-Bogotá ngoMrhayili 2006. Ababili bezenzo zobumbi babotjhwa begodu bagwetjwa iminyaka elitjhumi ejele, kuthi ababili abenza ubumbi azange batholakale.  
[[Isimumathi:Deputy_Secretary_Sherman_Officiates_the_Swearing-In_Ceremony_of_Ambassador_Bernadette_M._Meehan_(52320011503).jpg|thumb|U-Meehan wafungiswa njengeNxusa le-Chile ngo-2022 nguSekela likaNobhala weNarha u-Wendy Sherman]]

=== Umsebenzi wangemva kokuba yinxusa ===
Mhlana amalanga ali-9 kuNobayeni 2025, u-Meehan wabekwa njenge-CEO ye-Wikimedia Foundation.  Uzakuthatha indima mhlazi-20 kuTjhirhweni 2026. 

== Ipilo yomuntu mathupha ==
U-Meehan ukhuluma isiNgisi, isiSpanishi nesi -Arabhu .  Utjhade no- Evan S. Medeiros, uSihlalo womndeni we-Penner ku-Asian Studies e- Georgetown University 's Walsh School of Foreign Service . 

== Iinkomba ==</text>
      <sha1>p3269tjtvextc4ywaga13pf7bs53wl3</sha1>
    </revision>
    <revision>
      <id>6071</id>
      <parentid>6070</parentid>
      <timestamp>2025-12-10T04:50:42Z</timestamp>
      <contributor>
        <username>WikiMzansi</username>
        <id>1200</id>
      </contributor>
      <comment>/* Iinkomba */</comment>
      <origin>6071</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2358" sha1="fm43e5l59d2zcera0nzsw8qbjyh8iwg" xml:space="preserve">[[Isimumathi:Bernadette Meehan, NSC Spokesperson.jpg|thumb]]
 '''U-Bernadette M. Meehan''' ( wazalwa 1975) mthunywa we-America owasebenza njengeNxusa le-United States e-Chile kusukela ngo-2022 ukuya ku-2025. Ukhethwe njengesikhulu esiphezulu (CEO) se-Wikimedia Foundation, begodu uzokuthatha indima leyo mhlazi-20 kuTjhirhweni 2026, athathe isikhundla se-Maryana Iskander. Ngaphambilini bekasebenza njengosekela mongameli omkhulu weenhlelo zephasi loke ze-Obama Foundation. Wasebenza njengomkhulumeli we-United States National Security Council ngesikhathi sokuBusa kwaka-Obama, begodu waba sikhulu se-Foreign Service noMnyango wezoMbuso iminyaka engaphezu kwetjhumi.&lt;ref&gt;https://wikimediafoundation.org/news/2025/12/09/wikimedia-foundation-appoints-bernadette-meehan-as-chief-executive-officer/&lt;/ref&gt;

== Ipilo yokuthoma nefundo ==
U-Meehan wabelethwa e- Bronx, wakhulela e- Pleasantville, e-New York begodu waphothula e -Kennedy Catholic High School e -Somers, e-[[New York]] .  Waphothula e- Boston College nge- Bachelor of Arts degree yezepolotiki . &lt;ref name=&quot;:0&quot; /&gt; Ngemva kokuphothula, wasebenza e -Wall Street, kokuthoma e -JPMorgan Chase bese kuba yi-Lehman Brothers .  Ngokukhamba kwesikhathi wajoyina i- United States Foreign Service . &lt;ref name=&quot;:0&quot; /&gt;  

== Ibizelo ==
U-Meehan wajoyina i- United States Department of State njengesikhulu se-Foreign Service ngo-2004, begodu wathoma umsebenzi wakhe omutjha njenge-consular officer e-US Embassy e- Bogotá, e-Colombia.  Wasinda ekuthunjweni nokuhlaselwa ngokomzimba babantu abahlomileko e-Bogotá ngoMrhayili 2006. Ababili bezenzo zobumbi babotjhwa begodu bagwetjwa iminyaka elitjhumi ejele, kuthi ababili abenza ubumbi azange batholakale.  
[[Isimumathi:Deputy_Secretary_Sherman_Officiates_the_Swearing-In_Ceremony_of_Ambassador_Bernadette_M._Meehan_(52320011503).jpg|thumb|U-Meehan wafungiswa njengeNxusa le-Chile ngo-2022 nguSekela likaNobhala weNarha u-Wendy Sherman]]

=== Umsebenzi wangemva kokuba yinxusa ===
Mhlana amalanga ali-9 kuNobayeni 2025, u-Meehan wabekwa njenge-CEO ye-Wikimedia Foundation.  Uzakuthatha indima mhlazi-20 kuTjhirhweni 2026. 

== Ipilo yomuntu mathupha ==
U-Meehan ukhuluma isiNgisi, isiSpanishi nesi -Arabhu .  Utjhade no- Evan S. Medeiros, uSihlalo womndeni we-Penner ku-Asian Studies e- Georgetown University 's Walsh School of Foreign Service . 

== Iinkomba ==</text>
      <sha1>fm43e5l59d2zcera0nzsw8qbjyh8iwg</sha1>
    </revision>
    <revision>
      <id>6072</id>
      <parentid>6071</parentid>
      <timestamp>2025-12-10T04:51:25Z</timestamp>
      <contributor>
        <username>WikiMzansi</username>
        <id>1200</id>
      </contributor>
      <origin>6072</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2324" sha1="gbzxj0woyly8e70qggpa2tix59a6ui1" xml:space="preserve">[[Isimumathi:Bernadette Meehan, NSC Spokesperson.jpg|thumb]]
 '''U-Bernadette M. Meehan''' ( wazalwa 1975) mthunywa we-America owasebenza njengeNxusa le-United States e-Chile kusukela ngo-2022 ukuya ku-2025. Ukhethwe njengesikhulu esiphezulu (CEO) se-Wikimedia Foundation, begodu uzokuthatha indima leyo mhlazi-20 kuTjhirhweni 2026, athathe isikhundla se-Maryana Iskander. Ngaphambilini bekasebenza njengosekela mongameli omkhulu weenhlelo zephasi loke ze-Obama Foundation. Wasebenza njengomkhulumeli we-United States National Security Council ngesikhathi sokuBusa kwaka-Obama, begodu waba sikhulu se-Foreign Service noMnyango wezoMbuso iminyaka engaphezu kwetjhumi.&lt;ref&gt;https://wikimediafoundation.org/news/2025/12/09/wikimedia-foundation-appoints-bernadette-meehan-as-chief-executive-officer/&lt;/ref&gt;

== Ipilo yokuthoma nefundo ==
U-Meehan wabelethwa e- Bronx, wakhulela e- Pleasantville, e-New York begodu waphothula e -Kennedy Catholic High School e -Somers, e-[[New York]] .  Waphothula e- Boston College nge- Bachelor of Arts degree yezepolotiki .  Ngemva kokuphothula, wasebenza e -Wall Street, kokuthoma e -JPMorgan Chase bese kuba yi-Lehman Brothers .  Ngokukhamba kwesikhathi wajoyina i- United States Foreign Service .   

== Ibizelo ==
U-Meehan wajoyina i- United States Department of State njengesikhulu se-Foreign Service ngo-2004, begodu wathoma umsebenzi wakhe omutjha njenge-consular officer e-US Embassy e- Bogotá, e-Colombia.  Wasinda ekuthunjweni nokuhlaselwa ngokomzimba babantu abahlomileko e-Bogotá ngoMrhayili 2006. Ababili bezenzo zobumbi babotjhwa begodu bagwetjwa iminyaka elitjhumi ejele, kuthi ababili abenza ubumbi azange batholakale.  
[[Isimumathi:Deputy_Secretary_Sherman_Officiates_the_Swearing-In_Ceremony_of_Ambassador_Bernadette_M._Meehan_(52320011503).jpg|thumb|U-Meehan wafungiswa njengeNxusa le-Chile ngo-2022 nguSekela likaNobhala weNarha u-Wendy Sherman]]

=== Umsebenzi wangemva kokuba yinxusa ===
Mhlana amalanga ali-9 kuNobayeni 2025, u-Meehan wabekwa njenge-CEO ye-Wikimedia Foundation.  Uzakuthatha indima mhlazi-20 kuTjhirhweni 2026. 

== Ipilo yomuntu mathupha ==
U-Meehan ukhuluma isiNgisi, isiSpanishi nesi -Arabhu .  Utjhade no- Evan S. Medeiros, uSihlalo womndeni we-Penner ku-Asian Studies e- Georgetown University 's Walsh School of Foreign Service . 

== Iinkomba ==</text>
      <sha1>gbzxj0woyly8e70qggpa2tix59a6ui1</sha1>
    </revision>
    <revision>
      <id>6073</id>
      <parentid>6072</parentid>
      <timestamp>2025-12-10T04:52:46Z</timestamp>
      <contributor>
        <username>WikiMzansi</username>
        <id>1200</id>
      </contributor>
      <origin>6073</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2601" sha1="n7f9qzq9ocmk06oa7eqzg5af3v7oshm" xml:space="preserve">[[Isimumathi:Bernadette Meehan, NSC Spokesperson.jpg|thumb]]
 '''U-Bernadette M. Meehan''' ( wazalwa 1975) mthunywa we-America owasebenza njengeNxusa le-United States e-Chile kusukela ngo-2022 ukuya ku-2025. Ukhethwe njengesikhulu esiphezulu (CEO) se-Wikimedia Foundation, begodu uzokuthatha indima leyo mhlazi-20 kuTjhirhweni 2026, athathe isikhundla se-Maryana Iskander. Ngaphambilini bekasebenza njengosekela mongameli omkhulu weenhlelo zephasi loke ze-Obama Foundation. Wasebenza njengomkhulumeli we-United States National Security Council ngesikhathi sokuBusa kwaka-Obama, begodu waba sikhulu se-Foreign Service noMnyango wezoMbuso iminyaka engaphezu kwetjhumi.&lt;ref&gt;https://wikimediafoundation.org/news/2025/12/09/wikimedia-foundation-appoints-bernadette-meehan-as-chief-executive-officer/&lt;/ref&gt;

== Ipilo yokuthoma nefundo ==
U-Meehan wabelethwa e- Bronx, wakhulela e- Pleasantville, e-New York begodu waphothula e -Kennedy Catholic High School e -Somers, e-[[New York]] .  Waphothula e- Boston College nge- Bachelor of Arts degree yezepolotiki .  Ngemva kokuphothula, wasebenza e -Wall Street, kokuthoma e -JPMorgan Chase bese kuba yi-Lehman Brothers .  Ngokukhamba kwesikhathi wajoyina i- United States Foreign Service.&lt;ref&gt;https://www.defenseone.com/threats/2015/02/white-house-says-obamas-new-national-security-strategy-compass-through-shifting-security-landscape/104634/&lt;/ref&gt;

== Ibizelo ==
U-Meehan wajoyina i- United States Department of State njengesikhulu se-Foreign Service ngo-2004, begodu wathoma umsebenzi wakhe omutjha njenge-consular officer e-US Embassy e- Bogotá, e-Colombia.  Wasinda ekuthunjweni nokuhlaselwa ngokomzimba babantu abahlomileko e-Bogotá ngoMrhayili 2006. Ababili bezenzo zobumbi babotjhwa begodu bagwetjwa iminyaka elitjhumi ejele, kuthi ababili abenza ubumbi azange batholakale.  
[[Isimumathi:Deputy_Secretary_Sherman_Officiates_the_Swearing-In_Ceremony_of_Ambassador_Bernadette_M._Meehan_(52320011503).jpg|thumb|U-Meehan wafungiswa njengeNxusa le-Chile ngo-2022 nguSekela likaNobhala weNarha u-Wendy Sherman]]&lt;ref&gt;https://web.archive.org/web/20150625034503/http://bcm.bc.edu/issues/winter_2013/linden_lane/capital-gains.html&lt;/ref&gt;

=== Umsebenzi wangemva kokuba yinxusa ===
Mhlana amalanga ali-9 kuNobayeni 2025, u-Meehan wabekwa njenge-CEO ye-Wikimedia Foundation.  Uzakuthatha indima mhlazi-20 kuTjhirhweni 2026. 

== Ipilo yomuntu mathupha ==
U-Meehan ukhuluma isiNgisi, isiSpanishi nesi -Arabhu .  Utjhade no- Evan S. Medeiros, uSihlalo womndeni we-Penner ku-Asian Studies e- Georgetown University 's Walsh School of Foreign Service . 

== Iinkomba ==</text>
      <sha1>n7f9qzq9ocmk06oa7eqzg5af3v7oshm</sha1>
    </revision>
    <revision>
      <id>6074</id>
      <parentid>6073</parentid>
      <timestamp>2025-12-10T04:53:18Z</timestamp>
      <contributor>
        <username>WikiMzansi</username>
        <id>1200</id>
      </contributor>
      <origin>6074</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2605" sha1="buiqldi473etdc2mfg1uinrwtioftjg" xml:space="preserve">[[Isimumathi:Bernadette Meehan, NSC Spokesperson.jpg|thumb]]
 '''U-Bernadette M. Meehan''' ( wazalwa 1975) mthunywa we-America owasebenza njengeNxusa le-[[United States]] e-Chile kusukela ngo-2022 ukuya ku-2025. Ukhethwe njengesikhulu esiphezulu (CEO) se-Wikimedia Foundation, begodu uzokuthatha indima leyo mhlazi-20 kuTjhirhweni 2026, athathe isikhundla se-Maryana Iskander. Ngaphambilini bekasebenza njengosekela mongameli omkhulu weenhlelo zephasi loke ze-Obama Foundation. Wasebenza njengomkhulumeli we-United States National Security Council ngesikhathi sokuBusa kwaka-Obama, begodu waba sikhulu se-Foreign Service noMnyango wezoMbuso iminyaka engaphezu kwetjhumi.&lt;ref&gt;https://wikimediafoundation.org/news/2025/12/09/wikimedia-foundation-appoints-bernadette-meehan-as-chief-executive-officer/&lt;/ref&gt;

== Ipilo yokuthoma nefundo ==
U-Meehan wabelethwa e- Bronx, wakhulela e- Pleasantville, e-New York begodu waphothula e -Kennedy Catholic High School e -Somers, e-[[New York]] .  Waphothula e- Boston College nge- Bachelor of Arts degree yezepolotiki .  Ngemva kokuphothula, wasebenza e -Wall Street, kokuthoma e -JPMorgan Chase bese kuba yi-Lehman Brothers .  Ngokukhamba kwesikhathi wajoyina i- United States Foreign Service.&lt;ref&gt;https://www.defenseone.com/threats/2015/02/white-house-says-obamas-new-national-security-strategy-compass-through-shifting-security-landscape/104634/&lt;/ref&gt;

== Ibizelo ==
U-Meehan wajoyina i- United States Department of State njengesikhulu se-Foreign Service ngo-2004, begodu wathoma umsebenzi wakhe omutjha njenge-consular officer e-US Embassy e- Bogotá, e-Colombia.  Wasinda ekuthunjweni nokuhlaselwa ngokomzimba babantu abahlomileko e-Bogotá ngoMrhayili 2006. Ababili bezenzo zobumbi babotjhwa begodu bagwetjwa iminyaka elitjhumi ejele, kuthi ababili abenza ubumbi azange batholakale.  
[[Isimumathi:Deputy_Secretary_Sherman_Officiates_the_Swearing-In_Ceremony_of_Ambassador_Bernadette_M._Meehan_(52320011503).jpg|thumb|U-Meehan wafungiswa njengeNxusa le-Chile ngo-2022 nguSekela likaNobhala weNarha u-Wendy Sherman]]&lt;ref&gt;https://web.archive.org/web/20150625034503/http://bcm.bc.edu/issues/winter_2013/linden_lane/capital-gains.html&lt;/ref&gt;

=== Umsebenzi wangemva kokuba yinxusa ===
Mhlana amalanga ali-9 kuNobayeni 2025, u-Meehan wabekwa njenge-CEO ye-Wikimedia Foundation.  Uzakuthatha indima mhlazi-20 kuTjhirhweni 2026. 

== Ipilo yomuntu mathupha ==
U-Meehan ukhuluma isiNgisi, isiSpanishi nesi -Arabhu .  Utjhade no- Evan S. Medeiros, uSihlalo womndeni we-Penner ku-Asian Studies e- Georgetown University 's Walsh School of Foreign Service . 

== Iinkomba ==</text>
      <sha1>buiqldi473etdc2mfg1uinrwtioftjg</sha1>
    </revision>
    <revision>
      <id>6075</id>
      <parentid>6074</parentid>
      <timestamp>2025-12-10T04:53:43Z</timestamp>
      <contributor>
        <username>WikiMzansi</username>
        <id>1200</id>
      </contributor>
      <comment>/* Umsebenzi wangemva kokuba yinxusa */</comment>
      <origin>6075</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2609" sha1="gqg6h87spuhdl48j31qfsbddcmxlsy5" xml:space="preserve">[[Isimumathi:Bernadette Meehan, NSC Spokesperson.jpg|thumb]]
 '''U-Bernadette M. Meehan''' ( wazalwa 1975) mthunywa we-America owasebenza njengeNxusa le-[[United States]] e-Chile kusukela ngo-2022 ukuya ku-2025. Ukhethwe njengesikhulu esiphezulu (CEO) se-Wikimedia Foundation, begodu uzokuthatha indima leyo mhlazi-20 kuTjhirhweni 2026, athathe isikhundla se-Maryana Iskander. Ngaphambilini bekasebenza njengosekela mongameli omkhulu weenhlelo zephasi loke ze-Obama Foundation. Wasebenza njengomkhulumeli we-United States National Security Council ngesikhathi sokuBusa kwaka-Obama, begodu waba sikhulu se-Foreign Service noMnyango wezoMbuso iminyaka engaphezu kwetjhumi.&lt;ref&gt;https://wikimediafoundation.org/news/2025/12/09/wikimedia-foundation-appoints-bernadette-meehan-as-chief-executive-officer/&lt;/ref&gt;

== Ipilo yokuthoma nefundo ==
U-Meehan wabelethwa e- Bronx, wakhulela e- Pleasantville, e-New York begodu waphothula e -Kennedy Catholic High School e -Somers, e-[[New York]] .  Waphothula e- Boston College nge- Bachelor of Arts degree yezepolotiki .  Ngemva kokuphothula, wasebenza e -Wall Street, kokuthoma e -JPMorgan Chase bese kuba yi-Lehman Brothers .  Ngokukhamba kwesikhathi wajoyina i- United States Foreign Service.&lt;ref&gt;https://www.defenseone.com/threats/2015/02/white-house-says-obamas-new-national-security-strategy-compass-through-shifting-security-landscape/104634/&lt;/ref&gt;

== Ibizelo ==
U-Meehan wajoyina i- United States Department of State njengesikhulu se-Foreign Service ngo-2004, begodu wathoma umsebenzi wakhe omutjha njenge-consular officer e-US Embassy e- Bogotá, e-Colombia.  Wasinda ekuthunjweni nokuhlaselwa ngokomzimba babantu abahlomileko e-Bogotá ngoMrhayili 2006. Ababili bezenzo zobumbi babotjhwa begodu bagwetjwa iminyaka elitjhumi ejele, kuthi ababili abenza ubumbi azange batholakale.  
[[Isimumathi:Deputy_Secretary_Sherman_Officiates_the_Swearing-In_Ceremony_of_Ambassador_Bernadette_M._Meehan_(52320011503).jpg|thumb|U-Meehan wafungiswa njengeNxusa le-Chile ngo-2022 nguSekela likaNobhala weNarha u-Wendy Sherman]]&lt;ref&gt;https://web.archive.org/web/20150625034503/http://bcm.bc.edu/issues/winter_2013/linden_lane/capital-gains.html&lt;/ref&gt;

=== Umsebenzi wangemva kokuba yinxusa ===
Mhlana amalanga ali-9 kuNobayeni 2025, u-Meehan wabekwa njenge-CEO ye-[[Wikimedia Foundation]].  Uzakuthatha indima mhlazi-20 kuTjhirhweni 2026. 

== Ipilo yomuntu mathupha ==
U-Meehan ukhuluma isiNgisi, isiSpanishi nesi -Arabhu .  Utjhade no- Evan S. Medeiros, uSihlalo womndeni we-Penner ku-Asian Studies e- Georgetown University 's Walsh School of Foreign Service . 

== Iinkomba ==</text>
      <sha1>gqg6h87spuhdl48j31qfsbddcmxlsy5</sha1>
    </revision>
    <revision>
      <id>6092</id>
      <parentid>6075</parentid>
      <timestamp>2025-12-17T20:43:04Z</timestamp>
      <contributor>
        <username>Ooligan</username>
        <id>1229</id>
      </contributor>
      <comment>better photo/ foto/ image</comment>
      <origin>6092</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2622" sha1="2afr8pycjbl1p0kbv97kgk3m96us29r" xml:space="preserve">[[Isimumathi:Bernadette Meehan, NSC Spokesperson.jpg|thumb]]
 '''U-Bernadette M. Meehan''' ( wazalwa 1975) mthunywa we-America owasebenza njengeNxusa le-[[United States]] e-Chile kusukela ngo-2022 ukuya ku-2025. Ukhethwe njengesikhulu esiphezulu (CEO) se-Wikimedia Foundation, begodu uzokuthatha indima leyo mhlazi-20 kuTjhirhweni 2026, athathe isikhundla se-Maryana Iskander. Ngaphambilini bekasebenza njengosekela mongameli omkhulu weenhlelo zephasi loke ze-Obama Foundation. Wasebenza njengomkhulumeli we-United States National Security Council ngesikhathi sokuBusa kwaka-Obama, begodu waba sikhulu se-Foreign Service noMnyango wezoMbuso iminyaka engaphezu kwetjhumi.&lt;ref&gt;https://wikimediafoundation.org/news/2025/12/09/wikimedia-foundation-appoints-bernadette-meehan-as-chief-executive-officer/&lt;/ref&gt;

== Ipilo yokuthoma nefundo ==
U-Meehan wabelethwa e- Bronx, wakhulela e- Pleasantville, e-New York begodu waphothula e -Kennedy Catholic High School e -Somers, e-[[New York]] .  Waphothula e- Boston College nge- Bachelor of Arts degree yezepolotiki .  Ngemva kokuphothula, wasebenza e -Wall Street, kokuthoma e -JPMorgan Chase bese kuba yi-Lehman Brothers .  Ngokukhamba kwesikhathi wajoyina i- United States Foreign Service.&lt;ref&gt;https://www.defenseone.com/threats/2015/02/white-house-says-obamas-new-national-security-strategy-compass-through-shifting-security-landscape/104634/&lt;/ref&gt;

== Ibizelo ==
U-Meehan wajoyina i- United States Department of State njengesikhulu se-Foreign Service ngo-2004, begodu wathoma umsebenzi wakhe omutjha njenge-consular officer e-US Embassy e- Bogotá, e-Colombia.  Wasinda ekuthunjweni nokuhlaselwa ngokomzimba babantu abahlomileko e-Bogotá ngoMrhayili 2006. Ababili bezenzo zobumbi babotjhwa begodu bagwetjwa iminyaka elitjhumi ejele, kuthi ababili abenza ubumbi azange batholakale.  
[[Isimumathi:29 August 2022, Deputy Secretary Sherman officiates the Swearing-In Ceremony of Ambassador Bernadette M. Meehan (cropped).jpg|thumb|U-Meehan wafungiswa njengeNxusa le-Chile ngo-2022 nguSekela likaNobhala weNarha u-Wendy Sherman]]
&lt;ref&gt;https://web.archive.org/web/20150625034503/http://bcm.bc.edu/issues/winter_2013/linden_lane/capital-gains.html&lt;/ref&gt;

=== Umsebenzi wangemva kokuba yinxusa ===
Mhlana amalanga ali-9 kuNobayeni 2025, u-Meehan wabekwa njenge-CEO ye-[[Wikimedia Foundation]].  Uzakuthatha indima mhlazi-20 kuTjhirhweni 2026. 

== Ipilo yomuntu mathupha ==
U-Meehan ukhuluma isiNgisi, isiSpanishi nesi -Arabhu .  Utjhade no- Evan S. Medeiros, uSihlalo womndeni we-Penner ku-Asian Studies e- Georgetown University 's Walsh School of Foreign Service . 

== Iinkomba ==</text>
      <sha1>2afr8pycjbl1p0kbv97kgk3m96us29r</sha1>
    </revision>
  </page>
  <page>
    <title>I-Eire</title>
    <ns>0</ns>
    <id>1011</id>
    <revision>
      <id>6076</id>
      <timestamp>2025-12-10T17:20:18Z</timestamp>
      <contributor>
        <username>Roman Oy Bobrov</username>
        <id>167</id>
      </contributor>
      <comment>Created page with &quot;I-Eire iyisifunda esiseNyakatho Yurophu, ethatha iningi lesiqhingi sase-Ireland. Enyakatho ihlangana neNyakatho Ireland (ingxenye yeGreat Britain). Indawo - 70.2 ayizinkulungwane km².  Igama lezwe livela ku-Old Irish Eriu, noma u-Eriu - igama likankulunkulukazi emlandweni wase-Ireland.  Inani labantu bango-2022 liyizi-5,123,536&quot;</comment>
      <origin>6076</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="330" sha1="jao4a8pn7egmprr0jh7p7hisf60i9mh" xml:space="preserve">I-Eire iyisifunda esiseNyakatho Yurophu, ethatha iningi lesiqhingi sase-Ireland. Enyakatho ihlangana neNyakatho Ireland (ingxenye yeGreat Britain). Indawo - 70.2 ayizinkulungwane km².

Igama lezwe livela ku-Old Irish Eriu, noma u-Eriu - igama likankulunkulukazi emlandweni wase-Ireland.

Inani labantu bango-2022 liyizi-5,123,536</text>
      <sha1>jao4a8pn7egmprr0jh7p7hisf60i9mh</sha1>
    </revision>
  </page>
  <page>
    <title>I-Ukraine</title>
    <ns>0</ns>
    <id>1012</id>
    <revision>
      <id>6077</id>
      <timestamp>2025-12-11T15:32:05Z</timestamp>
      <contributor>
        <username>Valdemar5788</username>
        <id>1203</id>
      </contributor>
      <comment>Created page with &quot;I-Ukraine lilizwe elise-East naphakathi kwe-Europe. Inenani labantu elihlala njalo elingama-40,997,699 kanye nenani labantu langempela elingama-41,167,336 (elibekwa endaweni yama-34 ephasini). Indawo yayo yoke yi-603,549 km2 (ibekwe endaweni yama-44 ephasini); yinarha ekulu khulu ngendawo etholakala e-Europe yoke.  Ikomkhulu nedorobha elikhulu yi-Kyiv; amanye amadorobha amakhulu yi-Kharkiv, i-Odesa, i-Dnipro, i-Donetsk, i-Lviv, i-Zaporizhzhia, i-Kryvyi Rih, kanye ne-Myko...&quot;</comment>
      <origin>6077</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2461" sha1="p3yx95ynw7b78mxqc207i9bmj4yclt9" xml:space="preserve">I-Ukraine lilizwe elise-East naphakathi kwe-Europe. Inenani labantu elihlala njalo elingama-40,997,699 kanye nenani labantu langempela elingama-41,167,336 (elibekwa endaweni yama-34 ephasini). Indawo yayo yoke yi-603,549 km2 (ibekwe endaweni yama-44 ephasini); yinarha ekulu khulu ngendawo etholakala e-Europe yoke.

Ikomkhulu nedorobha elikhulu yi-Kyiv; amanye amadorobha amakhulu yi-Kharkiv, i-Odesa, i-Dnipro, i-Donetsk, i-Lviv, i-Zaporizhzhia, i-Kryvyi Rih, kanye ne-Mykolaiv. Ilimi elisemthethweni li-Ukrainian.

I-Ukraine yizwe elihlangeneko neriphabliki ehlangeneko. UMongameli we-Ukraine kusukela mhlazi-20 kuMrhayili 2019 ngu-Volodymyr Zelenskyy, begodu uNdunakulu kusukela mhlana ali-17 kuNtaka 2025 ngu-Yulia Svyrydenko.

Inarha le ihlukaniswe yaba ziingcenye ezima-27 zokuphatha, ezima-24 zazo zii-oblasts, iriphabliki eyodwa ezijameleko (i-Crimea), kanye namadorobha amabili (i-Kyiv ne-Sevastopol) anesikhundla esikhethekileko. Inomngcele we-Belarus ngetlhagwini, i-Poland, i-Slovakia, ne-Hungary ngetjingalanga, i-Romania ne-Moldova ngesewula-ntjhingalanga, kanye ne-Russia ngepumalanga ne-northeast. Inomngcele we-Black ne-Azov Seas ngesewula nesewulapumalanga; ihlanganyela imingcele yelwandle ne-Romania eLwandle eliNzima kanye ne-Russia eLwandle oluMnyama ne-Azov.

Ingcenye yendawo ye-Ukraine ihlanganiswe yi-Russia engumakhelwana begodu, ngokuya komthetho we-Ukraine, yindawo ehlala isikhatjhana. Ekupheleni komnyaka ka-2022, i-Russia yathatha indawo engaba yi-18% ye-Ukraine.

Inengi lamakholwa ngamaKrestu we-Orthodox, kodwana kunamaProthestani weenkolo ezihlukahlukeneko, abasekeli bamaGirigi namaRoma, amaJuda, nama-Islam.

I-GDP yelizwe yango-2024, ebalwa ngokulingana kwamandla wokuthenga (i-PPP), bekuyi-$659 yamabhiliyoni ($19,770 ngehloko). I-GDP ebizwako ngo-2024 beyiyi-$190 yamabhiliyoni (ama-$5,710 ngehloko), ibekwe kokugcina e-Europe ngokuya nge-GDP ebizwa ngehloko. Imali yi-hryvnia (UAH).

Inarha le yamemezela ukuzijamela kwayo e-USSR, lapho i-Ukraine beyiyi-union republic kusukela ngoNobayeni wee-1922, mhlazi-24 kuRhoboyi wee-1991. Umbuso olandela i-Ukrainian People's Republic, umbuso olandela i-Ukrainian SSR, umbuso olandela i-USSR, umsunguli we-UN, CISGUEC, AMGUBS, kanye nezinye iinhlangano, isikhulu samazwe ngamazwe umuntu ofuna ukuba lilunga le-European Union. Ngokuya ngeemvumelwano zamazwe ngamazwe zamanje, ithokozela ukufinyelela okulula e-Black Sea straits begodu yenza irhubhululo lezesayensi e-Antarctica.</text>
      <sha1>p3yx95ynw7b78mxqc207i9bmj4yclt9</sha1>
    </revision>
    <revision>
      <id>6078</id>
      <parentid>6077</parentid>
      <timestamp>2025-12-11T15:33:35Z</timestamp>
      <contributor>
        <username>Valdemar5788</username>
        <id>1203</id>
      </contributor>
      <origin>6078</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2467" sha1="jcw9qb3wfxvcab5f3vo29vzu7yrjnfk" xml:space="preserve">'''I-Ukraine''' lilizwe elise-East naphakathi kwe-Europe. Inenani labantu elihlala njalo elingama-40,997,699 kanye nenani labantu langempela elingama-41,167,336 (elibekwa endaweni yama-34 ephasini). Indawo yayo yoke yi-603,549 km2 (ibekwe endaweni yama-44 ephasini); yinarha ekulu khulu ngendawo etholakala e-Europe yoke.

Ikomkhulu nedorobha elikhulu yi-Kyiv; amanye amadorobha amakhulu yi-Kharkiv, i-Odesa, i-Dnipro, i-Donetsk, i-Lviv, i-Zaporizhzhia, i-Kryvyi Rih, kanye ne-Mykolaiv. Ilimi elisemthethweni li-Ukrainian.

I-Ukraine yizwe elihlangeneko neriphabliki ehlangeneko. UMongameli we-Ukraine kusukela mhlazi-20 kuMrhayili 2019 ngu-Volodymyr Zelenskyy, begodu uNdunakulu kusukela mhlana ali-17 kuNtaka 2025 ngu-Yulia Svyrydenko.

Inarha le ihlukaniswe yaba ziingcenye ezima-27 zokuphatha, ezima-24 zazo zii-oblasts, iriphabliki eyodwa ezijameleko (i-Crimea), kanye namadorobha amabili (i-Kyiv ne-Sevastopol) anesikhundla esikhethekileko. Inomngcele we-Belarus ngetlhagwini, i-Poland, i-Slovakia, ne-Hungary ngetjingalanga, i-Romania ne-Moldova ngesewula-ntjhingalanga, kanye ne-Russia ngepumalanga ne-northeast. Inomngcele we-Black ne-Azov Seas ngesewula nesewulapumalanga; ihlanganyela imingcele yelwandle ne-Romania eLwandle eliNzima kanye ne-Russia eLwandle oluMnyama ne-Azov.

Ingcenye yendawo ye-Ukraine ihlanganiswe yi-Russia engumakhelwana begodu, ngokuya komthetho we-Ukraine, yindawo ehlala isikhatjhana. Ekupheleni komnyaka ka-2022, i-Russia yathatha indawo engaba yi-18% ye-Ukraine.

Inengi lamakholwa ngamaKrestu we-Orthodox, kodwana kunamaProthestani weenkolo ezihlukahlukeneko, abasekeli bamaGirigi namaRoma, amaJuda, nama-Islam.

I-GDP yelizwe yango-2024, ebalwa ngokulingana kwamandla wokuthenga (i-PPP), bekuyi-$659 yamabhiliyoni ($19,770 ngehloko). I-GDP ebizwako ngo-2024 beyiyi-$190 yamabhiliyoni (ama-$5,710 ngehloko), ibekwe kokugcina e-Europe ngokuya nge-GDP ebizwa ngehloko. Imali yi-hryvnia (UAH).

Inarha le yamemezela ukuzijamela kwayo e-USSR, lapho i-Ukraine beyiyi-union republic kusukela ngoNobayeni wee-1922, mhlazi-24 kuRhoboyi wee-1991. Umbuso olandela i-Ukrainian People's Republic, umbuso olandela i-Ukrainian SSR, umbuso olandela i-USSR, umsunguli we-UN, CISGUEC, AMGUBS, kanye nezinye iinhlangano, isikhulu samazwe ngamazwe umuntu ofuna ukuba lilunga le-European Union. Ngokuya ngeemvumelwano zamazwe ngamazwe zamanje, ithokozela ukufinyelela okulula e-Black Sea straits begodu yenza irhubhululo lezesayensi e-Antarctica.</text>
      <sha1>jcw9qb3wfxvcab5f3vo29vzu7yrjnfk</sha1>
    </revision>
  </page>
  <page>
    <title>Walter Sisulu</title>
    <ns>0</ns>
    <id>1013</id>
    <revision>
      <id>6079</id>
      <timestamp>2025-12-14T17:09:59Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''U-Walter Ulyate Max Sisulu''' wabelethwa mhlana amalanga ali-18 ku-Mrhayili ngonyaka we-1912, walethelwa Engcobo District  e-Traskei. Wakhula alusa iinkomo, izimvu kanye neembuzi njengabanye abalusi abasese batjha. Ngonyakak we- 1920 U-Walter wavezwa ku-Marcus Garvey's Pan-African liberation yabantu abamnyama ngemihlangano yendawo ehlelwe ngu-Wellington Buthelezi, u-Natalian ovakatjheleko owathatha ubunikazi be-America. Ngo-1927 U-Sisulu walisa isikolo aneminyaka eli...&quot;</comment>
      <origin>6079</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5676" sha1="tfxklzk57u10yn630gxb4ax7bzizyzc" xml:space="preserve">'''U-Walter Ulyate Max Sisulu''' wabelethwa mhlana amalanga ali-18 ku-Mrhayili ngonyaka we-1912, walethelwa Engcobo District  e-Traskei. Wakhula alusa iinkomo, izimvu kanye neembuzi njengabanye abalusi abasese batjha. Ngonyakak we- 1920 U-Walter wavezwa ku-Marcus Garvey's Pan-African liberation yabantu abamnyama ngemihlangano yendawo ehlelwe ngu-Wellington Buthelezi, u-Natalian ovakatjheleko owathatha ubunikazi be-America. Ngo-1927 U-Sisulu walisa isikolo aneminyaka eli-15&lt;ref&gt;https://sahistory.org.za/people/walter-ulyate-sisulu&lt;/ref&gt;. Unina usebenza e-East London ekude, begodu u-Dyantyi Hlakula, umuntu womndeni obekayindawo yobunikazi nokuzinza ku-Walter, wahlongakala.

Nakaneminyaka eli-16, u-Walter wasebenzisa ubunikazi bomzala wakhe omdala ukwamukelwa njengesisebenzi esivela eenarheni zangaphandle yi-ofisi lokuqatjha emayini. U-Sisulu ukhamba amakhilomitha ayi-1000 ukuya e-Johannesburg ngesitimela, kodwana nakafikako wagwetjwa njengomncani khulu bona angakwazi ukusebenza ngaphasi kwephasi. Kube nokuvumelana lapho atjhatjhululwa khona esivumelwaneni sakhe sihlobo, begodu asebenzela umlimi webisi oletha ibisi emayini. uya eenhlanganweni ezihlukahlukeneko zefundo. Ngokukhamba kwesikhathi waba ngunobhala we-&quot;Orlando Brotherly Society&quot;, ihlangano yama-Xhosa, eyakhuthaza ikareko emlandwini weentjhaba begodu yakhuthaza ukuzijamela kwezomnotho ebantwini abamhlophe.&lt;ref&gt;Houser, G., 2003. REMEMBERING WALTER SISULU. ''Fellowship'', ''69''(7-8), p.20.&lt;/ref&gt;

Ngemva kokuphikisana wabethwa kumbi mqatjhi wakhe, begodu nakabika emapholiseni, wathola ukuhlukunyezwa okungeziweko. Eminye imisebenzi njengesisebenzi sekhaya, umtjhayeli wendawo yokulala ilandela. Njengombana sele adiniwe yipilo yedorobha, u-Walter ubuyela ekhaya begodu nakabuyela e-Transkei, wenza umnyanya wesintu wesi-Xhosa. U-Walter godu ufudukile, wabuyela e-Johannesburg ukuyokusebenza ama-iri ali-9 ngelanga alayisha i-ore ngaphasi kwehlabathi emgodini wegolide. Ngemva kokuthi ukungena kwemigodi kubulale abavukuzi abanengi emgodini egade avamise ukuwusebenza, u-Walter ogandelelekileko wadluliselwa phezulu. Ukusongelwa kokuteleka ngebanga lobujamo obumbi kwabangela ukuvunyelwa, begodu u-Walter unesipiliyoni sakhe sokuthoma sesenzo samabubulo esihlelekileko.Phakathi komnyaka, ngemva kwesikhathi esithileko ngemva kokuphela kwekontraga yakhe yamalanga ali-120, u-Walter ubuyela ekhaya e-Transkei. Ukuthola umsebenzi wangekhaya emzini okhululekileko e-East London, u-Walter uzama ukuhlangana nomsunguli we-ANC, u-Walter Rubusana. &lt;ref&gt;a Struggle, S.L.D., for Political Freedom. ''The Palgrave Handbook of Servant Leadership'', p.199.&lt;/ref&gt;Godu ithonywe ngezepolotiki ngu-Booker T Washington's Up from Slavery, begodu ngokwesiko ngokutlolwa kwe-WEB du Bois.

1932 USisulu ubuyela godu edorobheni lakhe, i-Qutubeni, aletha iphasela endodaneni yomuntu omhlophe angamaziko ahlangana naye e-East London. Ngokuvamileko, wamukelwa ngokudelela ngumamukeli, usokhemisi omhlophe. Ngonyaka olandelako Nakabuyela e-Doornfontein, e-Johannesburg begodu ahlale nonina obegade ahlanza, u-Walter ufumana umsebenzi e-bakery. U-Sisulu bekangazi ngesikhatheso, umakhelwana ngu-Joe Slovo. Uya esikolweni sasebusuku e-Bantu Men's Social Club begodu uthatha iimfundo zokutjhayela, ukwazi idorobha ngcono.Ngonyaka we-1934, Umthetho wokuVulwa kwemikhukhu uthinta u-Walter nonina, hlangana neenkulungwana zabantu abaNzima abahlala edorobheni. Ukateleleka bona athuthele e-Orlando, eyaba yingcenye ye-Soweto. Ubujamo abude khulu neenthembiso ezenziwe ngurhulumende wendawo.

U-Walter wathoma ukubhenyoga afuna ukuthi bakhuphule umrholo e-Premier Milling Company, eyahlakazwa bese uyakhamba. Uhlutjhwa yincwadi yokuphasisa nokunye ukuhlukunyezwa ngamapholisa begodu uqunta &quot;ukuhlupheka ngaphasi kwehlelo bekube kulapho ngiyinqoba&quot;. Usebenza okwesikhatjhana e-Bantu World, iphephandaba eliphethwe ngu-Selope Thema, ilunga elisungulileko le-ANC nentathelizindaba ehle khulu. Godu uthola imisebenzi ehlukahlukeneko yobubhalane, kufaka hlangana nomasipala we-Johannesburg ukubala ukubalwa kwabantu.

Ngonyaka we-1938, wathola umsebenzi e-Union Bank of South Africa njenge-ejenti yokuthengisa, ekhuthaza amaklayenti angaba khona bona avule ama-akhawundi. Lokhu kumenza akwazi ukuthintana nabantu abanengi. &lt;ref&gt;https://www.latimes.com/local/obituaries/archives/la-me-walter-sisulu-20030506-20160321-snap-htmlstory.html&lt;/ref&gt;Ngokuzenzakalelako wathintana nelunga le-Communist Party u-Rusty Bernstein, owamboleka umtlolo wokuthoma wesokunxele u-Walter awufundako, i-atikili ka-Stalin yango-1913 nge-National Question. Uhlangana no-Govan Mbeki, ebegade amfundi e-Fort Hare, ngemva kokufunda i-The Making of the Transkei, kanye no-Kaizer Matanzima, umphathi we-Thembu.

Ngo-1940, ngemva kokuzifaka esikolweni ngesikhathi asebenza njengomthengisi wendlu, uSisulu uthoma ukusebenza njengomthengisi wezindlu. Ufakwe ngokusemthethweni ku-ANC uliilunga leenhlangano zabasebenzi u-Alfred Mbele. phakathi kweendaba ze-ANC kusukela enyakeni loyo bekwaba botjhwa kwakhe ngebanga lokuvukela umbuso ngo-1963 e-Rivonia.U-Mandela no-Sisulu bahlangana kokuthoma, e-ofisini laka-Walter. Njengombana agweme umtjhado ohleliweko e-Transkei, u-Mandela use-Johannesburg, athola iinyawo zakhe. USisulu umrhelebha bona athole umsebenzi emsebenzini wakhe awukhethileko, umthetho.1942 NgoNobayeni, wahlangana no-Pixley Seme, omunye wamalunga asungula i-ANC, esitimeleni esiya emhlanganweni we-ANC weminyaka yoke e-Bloemfontein.ngo-1943 Godu waya emhlanganweni we-ANC weminyaka yoke, lapho ihlangano yenziwa le yesimanjemanje, iqeda iNdlu yamaKhosi, igatja liphakanyiswa njengeyunithi eyisisekelo yenhlangano, ukulingana okupheleleko

== Iinkomba ==</text>
      <sha1>tfxklzk57u10yn630gxb4ax7bzizyzc</sha1>
    </revision>
    <revision>
      <id>6080</id>
      <parentid>6079</parentid>
      <timestamp>2025-12-14T17:12:29Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6080</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5685" sha1="7fkxsb3tqwxcnv4pmq165i2ytqn0woh" xml:space="preserve">'''U-Walter Ulyate Max Sisulu''' wabelethwa mhlana amalanga ali-18 ku-Mrhayili ngonyaka we-1912, walethelwa Engcobo District  e-Traskei. Wakhula alusa iinkomo, izimvu kanye neembuzi njengabanye abalusi abasese batjha. Ngonyakak we- 1920 U-Walter wavezwa ku-Marcus Garvey's Pan-African liberation yabantu abamnyama ngemihlangano yendawo ehlelwe ngu-Wellington Buthelezi, u-Natalian ovakatjheleko owathatha ubunikazi be-America. Ngo-1927 U-Sisulu walisa isikolo aneminyaka eli-15&lt;ref&gt;https://sahistory.org.za/people/walter-ulyate-sisulu&lt;/ref&gt;. Unina usebenza e-East London ekude, begodu u-Dyantyi Hlakula, umuntu womndeni obekayindawo yobunikazi nokuzinza ku-Walter, wahlongakala.

Nakaneminyaka eli-16, u-Walter wasebenzisa ubunikazi bomzala wakhe omdala ukwamukelwa njengesisebenzi esivela eenarheni zangaphandle yi-ofisi lokuqatjha emayini. U-Sisulu ukhamba amakhilomitha ayi-1000 ukuya e-Johannesburg ngesitimela, kodwana nakafikako wagwetjwa njengomncani khulu bona angakwazi ukusebenza ngaphasi kwephasi. Kube nokuvumelana lapho atjhatjhululwa khona esivumelwaneni sakhe sihlobo, begodu asebenzela umlimi webisi oletha ibisi emayini. uya eenhlanganweni ezihlukahlukeneko zefundo. Ngokukhamba kwesikhathi waba ngunobhala we-&quot;Orlando Brotherly Society&quot;, ihlangano yama-Xhosa, eyakhuthaza ikareko emlandwini weentjhaba begodu yakhuthaza ukuzijamela kwezomnotho ebantwini abamhlophe.&lt;ref&gt;Houser, G., 2003. REMEMBERING WALTER SISULU. ''Fellowship'', ''69''(7-8), p.20.&lt;/ref&gt;

Ngemva kokuphikisana wabethwa kumbi mqatjhi wakhe, begodu nakabika emapholiseni, wathola ukuhlukunyezwa okungeziweko. Eminye imisebenzi njengesisebenzi sekhaya, umtjhayeli wendawo yokulala ilandela. Njengombana sele adiniwe yipilo yedorobha, u-Walter ubuyela ekhaya begodu nakabuyela e-Transkei, wenza umnyanya wesintu wesi-Xhosa. U-Walter godu ufudukile, wabuyela e-Johannesburg ukuyokusebenza ama-iri ali-9 ngelanga alayisha i-ore ngaphasi kwehlabathi emgodini wegolide. Ngemva kokuthi ukungena kwemigodi kubulale abavukuzi abanengi emgodini egade avamise ukuwusebenza, u-Walter ogandelelekileko wadluliselwa phezulu. Ukusongelwa kokuteleka ngebanga lobujamo obumbi kwabangela ukuvunyelwa, begodu u-Walter unesipiliyoni sakhe sokuthoma sesenzo samabubulo esihlelekileko.Phakathi komnyaka, ngemva kwesikhathi esithileko ngemva kokuphela kwekontraga yakhe yamalanga ali-120, u-Walter ubuyela ekhaya e-Transkei. Ukuthola umsebenzi wangekhaya emzini okhululekileko e-East London, u-Walter uzama ukuhlangana nomsunguli we-ANC, u-Walter Rubusana. &lt;ref&gt;a Struggle, S.L.D., for Political Freedom. ''The Palgrave Handbook of Servant Leadership'', p.199.&lt;/ref&gt;Godu ithonywe ngezepolotiki ngu-Booker T Washington's Up from Slavery, begodu ngokwesiko ngokutlolwa kwe-WEB du Bois.

1932 USisulu ubuyela godu edorobheni lakhe, i-Qutubeni, aletha iphasela endodaneni yomuntu omhlophe angamaziko ahlangana naye e-East London. Ngokuvamileko, wamukelwa ngokudelela ngumamukeli, usokhemisi omhlophe. Ngonyaka olandelako Nakabuyela e-Doornfontein, e-Johannesburg begodu ahlale nonina obegade ahlanza, u-Walter ufumana umsebenzi e-bakery. U-Sisulu bekangazi ngesikhatheso, umakhelwana ngu-Joe Slovo. Uya esikolweni sasebusuku e-Bantu Men's Social Club begodu uthatha iimfundo zokutjhayela, ukwazi idorobha ngcono.Ngonyaka we-1934, Umthetho wokuVulwa kwemikhukhu uthinta u-Walter nonina, hlangana neenkulungwana zabantu abaNzima abahlala edorobheni. Ukateleleka bona athuthele e-Orlando, eyaba yingcenye ye-Soweto. Ubujamo abude khulu neenthembiso ezenziwe ngurhulumende wendawo.

U-Walter wathoma ukubhenyoga afuna ukuthi bakhuphule umrholo e-Premier Milling Company, eyahlakazwa bese uyakhamba. Uhlutjhwa yincwadi yokuphasisa nokunye ukuhlukunyezwa ngamapholisa begodu uqunta &quot;ukuhlupheka ngaphasi kwehlelo bekube kulapho ngiyinqoba&quot;. Usebenza okwesikhatjhana e-Bantu World, iphephandaba eliphethwe ngu-Selope Thema, ilunga elisungulileko le-ANC nentathelizindaba ehle khulu. Godu uthola imisebenzi ehlukahlukeneko yobubhalane, kufaka hlangana nomasipala we-Johannesburg ukubala ukubalwa kwabantu.

Ngonyaka we-1938, wathola umsebenzi e-Union Bank of South Africa njenge-ejenti yokuthengisa, ekhuthaza amaklayenti angaba khona bona avule ama-akhawundi. Lokhu kumenza akwazi ukuthintana nabantu abanengi. &lt;ref&gt;https://www.latimes.com/local/obituaries/archives/la-me-walter-sisulu-20030506-20160321-snap-htmlstory.html&lt;/ref&gt;Ngokuzenzakalelako wathintana nelunga le-Communist Party u-Rusty Bernstein, owamboleka umtlolo wokuthoma wesokunxele u-Walter awufundako, i-atikili ka-Stalin yango-1913 nge-National Question. Uhlangana no-Govan Mbeki, ebegade amfundi e-Fort Hare, ngemva kokufunda i-The Making of the Transkei, kanye no-Kaizer Matanzima, umphathi we-Thembu.

Ngo-1940, ngemva kokuzifaka esikolweni ngesikhathi asebenza njengomthengisi wendlu, uSisulu uthoma ukusebenza njengomthengisi wezindlu. Ufakwe ngokusemthethweni ku-ANC uliilunga leenhlangano zabasebenzi u-Alfred Mbele. phakathi kweendaba ze-ANC kusukela enyakeni loyo bekwaba botjhwa kwakhe ngebanga lokuvukela umbuso ngo-1963 e-Rivonia.[[Nelson Mandela]] no-Sisulu bahlangana kokuthoma, e-ofisini laka-Walter. Njengombana agweme umtjhado ohleliweko e-Transkei, u-Mandela use-Johannesburg, athola iinyawo zakhe. USisulu umrhelebha bona athole umsebenzi emsebenzini wakhe awukhethileko, umthetho.1942 NgoNobayeni, wahlangana no-Pixley Seme, omunye wamalunga asungula i-ANC, esitimeleni esiya emhlanganweni we-ANC weminyaka yoke e-Bloemfontein.ngo-1943 Godu waya emhlanganweni we-ANC weminyaka yoke, lapho ihlangano yenziwa le yesimanjemanje, iqeda iNdlu yamaKhosi, igatja liphakanyiswa njengeyunithi eyisisekelo yenhlangano, ukulingana okupheleleko

== Iinkomba ==</text>
      <sha1>7fkxsb3tqwxcnv4pmq165i2ytqn0woh</sha1>
    </revision>
    <revision>
      <id>6081</id>
      <parentid>6080</parentid>
      <timestamp>2025-12-14T17:14:18Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6081</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5753" sha1="riqu88r744w9u6cyuu6o220hqkkpqna" xml:space="preserve">[[Isimumathi:Walter Sisulu 1991 (cropped).jpg|thumb|Walter Sisulu]]
'''U-Walter Ulyate Max Sisulu''' wabelethwa mhlana amalanga ali-18 ku-Mrhayili ngonyaka we-1912, walethelwa Engcobo District  e-Traskei. Wakhula alusa iinkomo, izimvu kanye neembuzi njengabanye abalusi abasese batjha. Ngonyakak we- 1920 U-Walter wavezwa ku-Marcus Garvey's Pan-African liberation yabantu abamnyama ngemihlangano yendawo ehlelwe ngu-Wellington Buthelezi, u-Natalian ovakatjheleko owathatha ubunikazi be-America. Ngo-1927 U-Sisulu walisa isikolo aneminyaka eli-15&lt;ref&gt;https://sahistory.org.za/people/walter-ulyate-sisulu&lt;/ref&gt;. Unina usebenza e-East London ekude, begodu u-Dyantyi Hlakula, umuntu womndeni obekayindawo yobunikazi nokuzinza ku-Walter, wahlongakala.

Nakaneminyaka eli-16, u-Walter wasebenzisa ubunikazi bomzala wakhe omdala ukwamukelwa njengesisebenzi esivela eenarheni zangaphandle yi-ofisi lokuqatjha emayini. U-Sisulu ukhamba amakhilomitha ayi-1000 ukuya e-Johannesburg ngesitimela, kodwana nakafikako wagwetjwa njengomncani khulu bona angakwazi ukusebenza ngaphasi kwephasi. Kube nokuvumelana lapho atjhatjhululwa khona esivumelwaneni sakhe sihlobo, begodu asebenzela umlimi webisi oletha ibisi emayini. uya eenhlanganweni ezihlukahlukeneko zefundo. Ngokukhamba kwesikhathi waba ngunobhala we-&quot;Orlando Brotherly Society&quot;, ihlangano yama-Xhosa, eyakhuthaza ikareko emlandwini weentjhaba begodu yakhuthaza ukuzijamela kwezomnotho ebantwini abamhlophe.&lt;ref&gt;Houser, G., 2003. REMEMBERING WALTER SISULU. ''Fellowship'', ''69''(7-8), p.20.&lt;/ref&gt;

Ngemva kokuphikisana wabethwa kumbi mqatjhi wakhe, begodu nakabika emapholiseni, wathola ukuhlukunyezwa okungeziweko. Eminye imisebenzi njengesisebenzi sekhaya, umtjhayeli wendawo yokulala ilandela. Njengombana sele adiniwe yipilo yedorobha, u-Walter ubuyela ekhaya begodu nakabuyela e-Transkei, wenza umnyanya wesintu wesi-Xhosa. U-Walter godu ufudukile, wabuyela e-Johannesburg ukuyokusebenza ama-iri ali-9 ngelanga alayisha i-ore ngaphasi kwehlabathi emgodini wegolide. Ngemva kokuthi ukungena kwemigodi kubulale abavukuzi abanengi emgodini egade avamise ukuwusebenza, u-Walter ogandelelekileko wadluliselwa phezulu. Ukusongelwa kokuteleka ngebanga lobujamo obumbi kwabangela ukuvunyelwa, begodu u-Walter unesipiliyoni sakhe sokuthoma sesenzo samabubulo esihlelekileko.Phakathi komnyaka, ngemva kwesikhathi esithileko ngemva kokuphela kwekontraga yakhe yamalanga ali-120, u-Walter ubuyela ekhaya e-Transkei. Ukuthola umsebenzi wangekhaya emzini okhululekileko e-East London, u-Walter uzama ukuhlangana nomsunguli we-ANC, u-Walter Rubusana. &lt;ref&gt;a Struggle, S.L.D., for Political Freedom. ''The Palgrave Handbook of Servant Leadership'', p.199.&lt;/ref&gt;Godu ithonywe ngezepolotiki ngu-Booker T Washington's Up from Slavery, begodu ngokwesiko ngokutlolwa kwe-WEB du Bois.

1932 USisulu ubuyela godu edorobheni lakhe, i-Qutubeni, aletha iphasela endodaneni yomuntu omhlophe angamaziko ahlangana naye e-East London. Ngokuvamileko, wamukelwa ngokudelela ngumamukeli, usokhemisi omhlophe. Ngonyaka olandelako Nakabuyela e-Doornfontein, e-Johannesburg begodu ahlale nonina obegade ahlanza, u-Walter ufumana umsebenzi e-bakery. U-Sisulu bekangazi ngesikhatheso, umakhelwana ngu-Joe Slovo. Uya esikolweni sasebusuku e-Bantu Men's Social Club begodu uthatha iimfundo zokutjhayela, ukwazi idorobha ngcono.Ngonyaka we-1934, Umthetho wokuVulwa kwemikhukhu uthinta u-Walter nonina, hlangana neenkulungwana zabantu abaNzima abahlala edorobheni. Ukateleleka bona athuthele e-Orlando, eyaba yingcenye ye-Soweto. Ubujamo abude khulu neenthembiso ezenziwe ngurhulumende wendawo.

U-Walter wathoma ukubhenyoga afuna ukuthi bakhuphule umrholo e-Premier Milling Company, eyahlakazwa bese uyakhamba. Uhlutjhwa yincwadi yokuphasisa nokunye ukuhlukunyezwa ngamapholisa begodu uqunta &quot;ukuhlupheka ngaphasi kwehlelo bekube kulapho ngiyinqoba&quot;. Usebenza okwesikhatjhana e-Bantu World, iphephandaba eliphethwe ngu-Selope Thema, ilunga elisungulileko le-ANC nentathelizindaba ehle khulu. Godu uthola imisebenzi ehlukahlukeneko yobubhalane, kufaka hlangana nomasipala we-Johannesburg ukubala ukubalwa kwabantu.

Ngonyaka we-1938, wathola umsebenzi e-Union Bank of South Africa njenge-ejenti yokuthengisa, ekhuthaza amaklayenti angaba khona bona avule ama-akhawundi. Lokhu kumenza akwazi ukuthintana nabantu abanengi. &lt;ref&gt;https://www.latimes.com/local/obituaries/archives/la-me-walter-sisulu-20030506-20160321-snap-htmlstory.html&lt;/ref&gt;Ngokuzenzakalelako wathintana nelunga le-Communist Party u-Rusty Bernstein, owamboleka umtlolo wokuthoma wesokunxele u-Walter awufundako, i-atikili ka-Stalin yango-1913 nge-National Question. Uhlangana no-Govan Mbeki, ebegade amfundi e-Fort Hare, ngemva kokufunda i-The Making of the Transkei, kanye no-Kaizer Matanzima, umphathi we-Thembu.

Ngo-1940, ngemva kokuzifaka esikolweni ngesikhathi asebenza njengomthengisi wendlu, uSisulu uthoma ukusebenza njengomthengisi wezindlu. Ufakwe ngokusemthethweni ku-ANC uliilunga leenhlangano zabasebenzi u-Alfred Mbele. phakathi kweendaba ze-ANC kusukela enyakeni loyo bekwaba botjhwa kwakhe ngebanga lokuvukela umbuso ngo-1963 e-Rivonia.[[Nelson Mandela]] no-Sisulu bahlangana kokuthoma, e-ofisini laka-Walter. Njengombana agweme umtjhado ohleliweko e-Transkei, u-Mandela use-Johannesburg, athola iinyawo zakhe. USisulu umrhelebha bona athole umsebenzi emsebenzini wakhe awukhethileko, umthetho.1942 NgoNobayeni, wahlangana no-Pixley Seme, omunye wamalunga asungula i-ANC, esitimeleni esiya emhlanganweni we-ANC weminyaka yoke e-Bloemfontein.ngo-1943 Godu waya emhlanganweni we-ANC weminyaka yoke, lapho ihlangano yenziwa le yesimanjemanje, iqeda iNdlu yamaKhosi, igatja liphakanyiswa njengeyunithi eyisisekelo yenhlangano, ukulingana okupheleleko

== Iinkomba ==</text>
      <sha1>riqu88r744w9u6cyuu6o220hqkkpqna</sha1>
    </revision>
    <revision>
      <id>6082</id>
      <parentid>6081</parentid>
      <timestamp>2025-12-14T17:20:05Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6082</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5853" sha1="8t55j2ctmnt83d0ph3mlynuika6uz17" xml:space="preserve">[[Isimumathi:Walter Sisulu 1991 (cropped).jpg|thumb|Walter Sisulu]]
'''U-Walter Ulyate Max Sisulu''' wabelethwa mhlana amalanga ali-18 ku-Mrhayili ngonyaka we-1912, walethelwa Engcobo District  e-Traskei. Wakhula alusa iinkomo, izimvu kanye neembuzi njengabanye abalusi abasese batjha. Ngonyakak we- 1920 U-Walter wavezwa ku-Marcus Garvey's Pan-African liberation yabantu abamnyama ngemihlangano yendawo ehlelwe ngu-Wellington Buthelezi, u-Natalian ovakatjheleko owathatha ubunikazi be-America. Ngo-1927 U-Sisulu walisa isikolo aneminyaka eli-15&lt;ref&gt;https://sahistory.org.za/people/walter-ulyate-sisulu&lt;/ref&gt;. Unina usebenza e-East London ekude, begodu u-Dyantyi Hlakula, umuntu womndeni obekayindawo yobunikazi nokuzinza ku-Walter, wahlongakala.

=== Ukukhula kwakhe ===
Nakaneminyaka eli-16, u-Walter wasebenzisa ubunikazi bomzala wakhe omdala ukwamukelwa njengesisebenzi esivela eenarheni zangaphandle yi-ofisi lokuqatjha emayini. U-Sisulu ukhamba amakhilomitha ayi-1000 ukuya e-Johannesburg ngesitimela, kodwana nakafikako wagwetjwa njengomncani khulu bona angakwazi ukusebenza ngaphasi kwephasi. Kube nokuvumelana lapho atjhatjhululwa khona esivumelwaneni sakhe sihlobo, begodu asebenzela umlimi webisi oletha ibisi emayini. uya eenhlanganweni ezihlukahlukeneko zefundo. Ngokukhamba kwesikhathi waba ngunobhala we-&quot;Orlando Brotherly Society&quot;, ihlangano yama-Xhosa, eyakhuthaza ikareko emlandwini weentjhaba begodu yakhuthaza ukuzijamela kwezomnotho ebantwini abamhlophe.&lt;ref&gt;Houser, G., 2003. REMEMBERING WALTER SISULU. ''Fellowship'', ''69''(7-8), p.20.&lt;/ref&gt;

=== Intjhijilo ahlangabezana nazo ===
Ngemva kokuphikisana wabethwa kumbi mqatjhi wakhe, begodu nakabika emapholiseni, wathola ukuhlukunyezwa okungeziweko. Eminye imisebenzi njengesisebenzi sekhaya, umtjhayeli wendawo yokulala ilandela. Njengombana sele adiniwe yipilo yedorobha, u-Walter ubuyela ekhaya begodu nakabuyela e-Transkei, wenza umnyanya wesintu wesi-Xhosa. U-Walter godu ufudukile, wabuyela e-Johannesburg ukuyokusebenza ama-iri ali-9 ngelanga alayisha i-ore ngaphasi kwehlabathi emgodini wegolide. Ngemva kokuthi ukungena kwemigodi kubulale abavukuzi abanengi emgodini egade avamise ukuwusebenza, u-Walter ogandelelekileko wadluliselwa phezulu. Ukusongelwa kokuteleka ngebanga lobujamo obumbi kwabangela ukuvunyelwa, begodu u-Walter unesipiliyoni sakhe sokuthoma sesenzo samabubulo esihlelekileko.Phakathi komnyaka, ngemva kwesikhathi esithileko ngemva kokuphela kwekontraga yakhe yamalanga ali-120, u-Walter ubuyela ekhaya e-Transkei. Ukuthola umsebenzi wangekhaya emzini okhululekileko e-East London, u-Walter uzama ukuhlangana nomsunguli we-ANC, u-Walter Rubusana. &lt;ref&gt;a Struggle, S.L.D., for Political Freedom. ''The Palgrave Handbook of Servant Leadership'', p.199.&lt;/ref&gt;Godu ithonywe ngezepolotiki ngu-Booker T Washington's Up from Slavery, begodu ngokwesiko ngokutlolwa kwe-WEB du Bois.

1932 USisulu ubuyela godu edorobheni lakhe, i-Qutubeni, aletha iphasela endodaneni yomuntu omhlophe angamaziko ahlangana naye e-East London. Ngokuvamileko, wamukelwa ngokudelela ngumamukeli, usokhemisi omhlophe. Ngonyaka olandelako Nakabuyela e-Doornfontein, e-Johannesburg begodu ahlale nonina obegade ahlanza, u-Walter ufumana umsebenzi e-bakery. U-Sisulu bekangazi ngesikhatheso, umakhelwana ngu-Joe Slovo. Uya esikolweni sasebusuku e-Bantu Men's Social Club begodu uthatha iimfundo zokutjhayela, ukwazi idorobha ngcono.Ngonyaka we-1934, Umthetho wokuVulwa kwemikhukhu uthinta u-Walter nonina, hlangana neenkulungwana zabantu abaNzima abahlala edorobheni. Ukateleleka bona athuthele e-Orlando, eyaba yingcenye ye-Soweto. Ubujamo abude khulu neenthembiso ezenziwe ngurhulumende wendawo.

U-Walter wathoma ukubhenyoga afuna ukuthi bakhuphule umrholo e-Premier Milling Company, eyahlakazwa bese uyakhamba. Uhlutjhwa yincwadi yokuphasisa nokunye ukuhlukunyezwa ngamapholisa begodu uqunta &quot;ukuhlupheka ngaphasi kwehlelo bekube kulapho ngiyinqoba&quot;. Usebenza okwesikhatjhana e-Bantu World, iphephandaba eliphethwe ngu-Selope Thema, ilunga elisungulileko le-ANC nentathelizindaba ehle khulu. Godu uthola imisebenzi ehlukahlukeneko yobubhalane, kufaka hlangana nomasipala we-Johannesburg ukubala ukubalwa kwabantu.

=== Ukuthoma kwakhe kwezepolitiki ===
Ngonyaka we-1938, wathola umsebenzi e-Union Bank of South Africa njenge-ejenti yokuthengisa, ekhuthaza amaklayenti angaba khona bona avule ama-akhawundi. Lokhu kumenza akwazi ukuthintana nabantu abanengi. &lt;ref&gt;https://www.latimes.com/local/obituaries/archives/la-me-walter-sisulu-20030506-20160321-snap-htmlstory.html&lt;/ref&gt;Ngokuzenzakalelako wathintana nelunga le-Communist Party u-Rusty Bernstein, owamboleka umtlolo wokuthoma wesokunxele u-Walter awufundako, i-atikili ka-Stalin yango-1913 nge-National Question. Uhlangana no-Govan Mbeki, ebegade amfundi e-Fort Hare, ngemva kokufunda i-The Making of the Transkei, kanye no-Kaizer Matanzima, umphathi we-Thembu.

Ngo-1940, ngemva kokuzifaka esikolweni ngesikhathi asebenza njengomthengisi wendlu, uSisulu uthoma ukusebenza njengomthengisi wezindlu. Ufakwe ngokusemthethweni ku-ANC uliilunga leenhlangano zabasebenzi u-Alfred Mbele. phakathi kweendaba ze-ANC kusukela enyakeni loyo bekwaba botjhwa kwakhe ngebanga lokuvukela umbuso ngo-1963 e-Rivonia.[[Nelson Mandela]] no-Sisulu bahlangana kokuthoma, e-ofisini laka-Walter. Njengombana agweme umtjhado ohleliweko e-Transkei, u-Mandela use-Johannesburg, athola iinyawo zakhe. USisulu umrhelebha bona athole umsebenzi emsebenzini wakhe awukhethileko, umthetho.1942 NgoNobayeni, wahlangana no-Pixley Seme, omunye wamalunga asungula i-ANC, esitimeleni esiya emhlanganweni we-ANC weminyaka yoke e-Bloemfontein.ngo-1943 Godu waya emhlanganweni we-ANC weminyaka yoke, lapho ihlangano yenziwa le yesimanjemanje, iqeda iNdlu yamaKhosi, igatja liphakanyiswa njengeyunithi eyisisekelo yenhlangano, ukulingana okupheleleko

== Iinkomba ==</text>
      <sha1>8t55j2ctmnt83d0ph3mlynuika6uz17</sha1>
    </revision>
    <revision>
      <id>6083</id>
      <parentid>6082</parentid>
      <timestamp>2025-12-14T17:23:30Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <comment>added categories</comment>
      <origin>6083</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6050" sha1="kz68u9cnl539pc1yufyjhj9quk6z1po" xml:space="preserve">[[Isimumathi:Walter Sisulu 1991 (cropped).jpg|thumb|Walter Sisulu]]
'''U-Walter Ulyate Max Sisulu''' wabelethwa mhlana amalanga ali-18 ku-Mrhayili ngonyaka we-1912, walethelwa Engcobo District  e-Traskei. Wakhula alusa iinkomo, izimvu kanye neembuzi njengabanye abalusi abasese batjha. Ngonyakak we- 1920 U-Walter wavezwa ku-Marcus Garvey's Pan-African liberation yabantu abamnyama ngemihlangano yendawo ehlelwe ngu-Wellington Buthelezi, u-Natalian ovakatjheleko owathatha ubunikazi be-America. Ngo-1927 U-Sisulu walisa isikolo aneminyaka eli-15&lt;ref&gt;https://sahistory.org.za/people/walter-ulyate-sisulu&lt;/ref&gt;. Unina usebenza e-East London ekude, begodu u-Dyantyi Hlakula, umuntu womndeni obekayindawo yobunikazi nokuzinza ku-Walter, wahlongakala.

=== Ukukhula kwakhe ===
Nakaneminyaka eli-16, u-Walter wasebenzisa ubunikazi bomzala wakhe omdala ukwamukelwa njengesisebenzi esivela eenarheni zangaphandle yi-ofisi lokuqatjha emayini. U-Sisulu ukhamba amakhilomitha ayi-1000 ukuya e-Johannesburg ngesitimela, kodwana nakafikako wagwetjwa njengomncani khulu bona angakwazi ukusebenza ngaphasi kwephasi. Kube nokuvumelana lapho atjhatjhululwa khona esivumelwaneni sakhe sihlobo, begodu asebenzela umlimi webisi oletha ibisi emayini. uya eenhlanganweni ezihlukahlukeneko zefundo. Ngokukhamba kwesikhathi waba ngunobhala we-&quot;Orlando Brotherly Society&quot;, ihlangano yama-Xhosa, eyakhuthaza ikareko emlandwini weentjhaba begodu yakhuthaza ukuzijamela kwezomnotho ebantwini abamhlophe.&lt;ref&gt;Houser, G., 2003. REMEMBERING WALTER SISULU. ''Fellowship'', ''69''(7-8), p.20.&lt;/ref&gt;

=== Intjhijilo ahlangabezana nazo ===
Ngemva kokuphikisana wabethwa kumbi mqatjhi wakhe, begodu nakabika emapholiseni, wathola ukuhlukunyezwa okungeziweko. Eminye imisebenzi njengesisebenzi sekhaya, umtjhayeli wendawo yokulala ilandela. Njengombana sele adiniwe yipilo yedorobha, u-Walter ubuyela ekhaya begodu nakabuyela e-Transkei, wenza umnyanya wesintu wesi-Xhosa. U-Walter godu ufudukile, wabuyela e-Johannesburg ukuyokusebenza ama-iri ali-9 ngelanga alayisha i-ore ngaphasi kwehlabathi emgodini wegolide. Ngemva kokuthi ukungena kwemigodi kubulale abavukuzi abanengi emgodini egade avamise ukuwusebenza, u-Walter ogandelelekileko wadluliselwa phezulu. Ukusongelwa kokuteleka ngebanga lobujamo obumbi kwabangela ukuvunyelwa, begodu u-Walter unesipiliyoni sakhe sokuthoma sesenzo samabubulo esihlelekileko.Phakathi komnyaka, ngemva kwesikhathi esithileko ngemva kokuphela kwekontraga yakhe yamalanga ali-120, u-Walter ubuyela ekhaya e-Transkei. Ukuthola umsebenzi wangekhaya emzini okhululekileko e-East London, u-Walter uzama ukuhlangana nomsunguli we-ANC, u-Walter Rubusana. &lt;ref&gt;a Struggle, S.L.D., for Political Freedom. ''The Palgrave Handbook of Servant Leadership'', p.199.&lt;/ref&gt;Godu ithonywe ngezepolotiki ngu-Booker T Washington's Up from Slavery, begodu ngokwesiko ngokutlolwa kwe-WEB du Bois.

1932 USisulu ubuyela godu edorobheni lakhe, i-Qutubeni, aletha iphasela endodaneni yomuntu omhlophe angamaziko ahlangana naye e-East London. Ngokuvamileko, wamukelwa ngokudelela ngumamukeli, usokhemisi omhlophe. Ngonyaka olandelako Nakabuyela e-Doornfontein, e-Johannesburg begodu ahlale nonina obegade ahlanza, u-Walter ufumana umsebenzi e-bakery. U-Sisulu bekangazi ngesikhatheso, umakhelwana ngu-Joe Slovo. Uya esikolweni sasebusuku e-Bantu Men's Social Club begodu uthatha iimfundo zokutjhayela, ukwazi idorobha ngcono.Ngonyaka we-1934, Umthetho wokuVulwa kwemikhukhu uthinta u-Walter nonina, hlangana neenkulungwana zabantu abaNzima abahlala edorobheni. Ukateleleka bona athuthele e-Orlando, eyaba yingcenye ye-Soweto. Ubujamo abude khulu neenthembiso ezenziwe ngurhulumende wendawo.

U-Walter wathoma ukubhenyoga afuna ukuthi bakhuphule umrholo e-Premier Milling Company, eyahlakazwa bese uyakhamba. Uhlutjhwa yincwadi yokuphasisa nokunye ukuhlukunyezwa ngamapholisa begodu uqunta &quot;ukuhlupheka ngaphasi kwehlelo bekube kulapho ngiyinqoba&quot;. Usebenza okwesikhatjhana e-Bantu World, iphephandaba eliphethwe ngu-Selope Thema, ilunga elisungulileko le-ANC nentathelizindaba ehle khulu. Godu uthola imisebenzi ehlukahlukeneko yobubhalane, kufaka hlangana nomasipala we-Johannesburg ukubala ukubalwa kwabantu.

=== Ukuthoma kwakhe kwezepolitiki ===
Ngonyaka we-1938, wathola umsebenzi e-Union Bank of South Africa njenge-ejenti yokuthengisa, ekhuthaza amaklayenti angaba khona bona avule ama-akhawundi. Lokhu kumenza akwazi ukuthintana nabantu abanengi. &lt;ref&gt;https://www.latimes.com/local/obituaries/archives/la-me-walter-sisulu-20030506-20160321-snap-htmlstory.html&lt;/ref&gt;Ngokuzenzakalelako wathintana nelunga le-Communist Party u-Rusty Bernstein, owamboleka umtlolo wokuthoma wesokunxele u-Walter awufundako, i-atikili ka-Stalin yango-1913 nge-National Question. Uhlangana no-Govan Mbeki, ebegade amfundi e-Fort Hare, ngemva kokufunda i-The Making of the Transkei, kanye no-Kaizer Matanzima, umphathi we-Thembu.

Ngo-1940, ngemva kokuzifaka esikolweni ngesikhathi asebenza njengomthengisi wendlu, uSisulu uthoma ukusebenza njengomthengisi wezindlu. Ufakwe ngokusemthethweni ku-ANC uliilunga leenhlangano zabasebenzi u-Alfred Mbele. phakathi kweendaba ze-ANC kusukela enyakeni loyo bekwaba botjhwa kwakhe ngebanga lokuvukela umbuso ngo-1963 e-Rivonia.[[Nelson Mandela]] no-Sisulu bahlangana kokuthoma, e-ofisini laka-Walter. Njengombana agweme umtjhado ohleliweko e-Transkei, u-Mandela use-Johannesburg, athola iinyawo zakhe. USisulu umrhelebha bona athole umsebenzi emsebenzini wakhe awukhethileko, umthetho.1942 NgoNobayeni, wahlangana no-Pixley Seme, omunye wamalunga asungula i-ANC, esitimeleni esiya emhlanganweni we-ANC weminyaka yoke e-Bloemfontein.ngo-1943 Godu waya emhlanganweni we-ANC weminyaka yoke, lapho ihlangano yenziwa le yesimanjemanje, iqeda iNdlu yamaKhosi, igatja liphakanyiswa njengeyunithi eyisisekelo yenhlangano, ukulingana okupheleleko

== Iinkomba ==
[[category: Walter Sisulu]]
[[category: Robben island]]
[[Category: walter Sisulu University]]
[[Category: Nelson Mandela]]
[[Category: umlando weSewula Afrika]]
[[Category: Abosopolitiki bakade]]</text>
      <sha1>kz68u9cnl539pc1yufyjhj9quk6z1po</sha1>
    </revision>
  </page>
  <page>
    <title>Thembi Nyandeni</title>
    <ns>0</ns>
    <id>1014</id>
    <revision>
      <id>6084</id>
      <timestamp>2025-12-15T16:03:50Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1327665543|Thembi Nyandeni]]&quot;</comment>
      <origin>6084</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1799" sha1="jtxu7rw2ilb0rbfwzyhtn89vz5htym9" xml:space="preserve">'''U-Thembi Nyandeni''' (wabelethwa mhlana ali-19 kuNtaka 1958) mlingisi [[Isewula Afrika|weSewula Afrika]] owaziwa ngomsebenzi wakhe emafilimini, kumabonakude, kanye nethiyetha ngomsebenzi othathe amatjhumi weminyaka  &lt;ref&gt;https://thestar.co.za/news/south-africa/gauteng/2020-12-07-actress-thembi-nyandeni-honoured-for-her-exploits-in-theatre/   &lt;/ref&gt; &lt;ref&gt;https://www.citizen.co.za/mpumalanga-news/news-headlines/2016/07/18/isibaya-stars-surprise-learners/  &lt;/ref&gt; &lt;ref&gt;https://iol.co.za/entertainment/celebrity-news/local/2024-08-26-legendary-actress-thembi-nyandeni-honoured-with-the-gagasi-fm-lifetime-shero-award/ &lt;/ref&gt; 

== Umsebenzi wokulingisa ==
U-Nyandeni usebenze kumabonakude, amafilimu, kanye nesiteji, afaka isandla kwezobuciko bemidlalo yeSewula Afrika ngeendima ezihlukahlukeneko. Ukudlala kwakhe kuvame ukutjengisa iindaba ezisekelwe emphakathini, ezikhambisana nesiko lenarha lokucoca iindaba elikhuluma ngomphakathi, ubunikazi, nokutjhuguluka.

Kanti waziwa njengengcenye yesizukulwana sabalingisi beSewula Afrika abasiza ukwakha nokugcina ibubulo lokuzithabisa lendawo ngesikhathi nangemva kwebandlululo. Umsebenzi wakhe utjengisa ukujamelana, ukuphila isikhathi eside, nokuzibophelela ekulandiseni iindaba. &lt;ref&gt;https://thestar.co.za/news/south-africa/gauteng/2020-12-07-actress-thembi-nyandeni-honoured-for-her-exploits-in-theatre/   &lt;/ref&gt; &lt;ref&gt;https://www.citizen.co.za/mpumalanga-news/news-headlines/2016/07/18/isibaya-stars-surprise-learners/  &lt;/ref&gt;

Kuthelevishini waziwa ngendima ezifana ne: 

* '''''Isibaya'''''
* '''''Zone 14'''''
* '''''Uzalo'''''
* '''''How to Ruin Christmas'''''
* '''''Kwakhala Nyonini'''''

'''Qala godu'''

* Ibhayisikobho yeSewula Afrika
* Umabonakude weSewula Afrika
* [[Theatre in South Africa|Ithiyetha eSewula Afrika]]

== Ireferensi ==</text>
      <sha1>jtxu7rw2ilb0rbfwzyhtn89vz5htym9</sha1>
    </revision>
    <revision>
      <id>6085</id>
      <parentid>6084</parentid>
      <timestamp>2025-12-15T16:04:44Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6085</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1811" sha1="smgcl6bfsw7ih1bal3drh1etz14dd9v" xml:space="preserve">'''U-Thembi Nyandeni''' (wabelethwa mhlana ali-19 kuNtaka 1958) mlingisi [[Isewula Afrika|weSewula Afrika]] owaziwa ngomsebenzi wakhe emafilimini, kumabonakude, kanye nethiyetha ngomsebenzi othathe amatjhumi weminyaka  &lt;ref&gt;https://thestar.co.za/news/south-africa/gauteng/2020-12-07-actress-thembi-nyandeni-honoured-for-her-exploits-in-theatre/   &lt;/ref&gt; &lt;ref&gt;https://www.citizen.co.za/mpumalanga-news/news-headlines/2016/07/18/isibaya-stars-surprise-learners/  &lt;/ref&gt; &lt;ref&gt;https://iol.co.za/entertainment/celebrity-news/local/2024-08-26-legendary-actress-thembi-nyandeni-honoured-with-the-gagasi-fm-lifetime-shero-award/ &lt;/ref&gt; 

== Umsebenzi wokulingisa ==
U-Nyandeni usebenze kumabonakude, amafilimu, kanye nesiteji, afaka isandla kwezobuciko bemidlalo yeSewula Afrika ngeendima ezihlukahlukeneko. Ukudlala kwakhe kuvame ukutjengisa iindaba ezisekelwe emphakathini, ezikhambisana nesiko lenarha lokucoca iindaba elikhuluma ngomphakathi, ubunikazi, nokutjhuguluka.

Kanti waziwa njengengcenye yesizukulwana sabalingisi beSewula Afrika abasiza ukwakha nokugcina ibubulo lokuzithabisa lendawo ngesikhathi nangemva kwebandlululo. Umsebenzi wakhe utjengisa ukujamelana, ukuphila isikhathi eside, nokuzibophelela ekulandiseni iindaba. &lt;ref&gt;https://thestar.co.za/news/south-africa/gauteng/2020-12-07-actress-thembi-nyandeni-honoured-for-her-exploits-in-theatre/   &lt;/ref&gt; &lt;ref&gt;https://www.citizen.co.za/mpumalanga-news/news-headlines/2016/07/18/isibaya-stars-surprise-learners/  &lt;/ref&gt;

Kuthelevishini waziwa ngendima ezifana ne: 

* '''''Isibaya'''''
* '''''Zone 14'''''
* '''''Uzalo'''''
* '''''How to Ruin Christmas'''''
* '''''Kwakhala Nyonini'''''

'''Qala godu'''

* Ibhayisikobho yeSewula Afrika
* Umabonakude weSewula Afrika
* [[Theatre in South Africa|Ithiyetha eSewula Afrika]]

== Ireferensi ==
{{reflist}}</text>
      <sha1>smgcl6bfsw7ih1bal3drh1etz14dd9v</sha1>
    </revision>
    <revision>
      <id>6086</id>
      <parentid>6085</parentid>
      <timestamp>2025-12-15T16:06:02Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6086</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1881" sha1="lk1o2mu7mci536iwlu56yjt5o1f23it" xml:space="preserve">'''U-Thembi Nyandeni''' (wabelethwa mhlana ali-19 kuNtaka 1958) mlingisi [[Isewula Afrika|weSewula Afrika]] owaziwa ngomsebenzi wakhe emafilimini, kumabonakude, kanye nethiyetha ngomsebenzi othathe amatjhumi weminyaka  &lt;ref&gt;https://thestar.co.za/news/south-africa/gauteng/2020-12-07-actress-thembi-nyandeni-honoured-for-her-exploits-in-theatre/   &lt;/ref&gt; &lt;ref&gt;https://www.citizen.co.za/mpumalanga-news/news-headlines/2016/07/18/isibaya-stars-surprise-learners/  &lt;/ref&gt; &lt;ref&gt;https://iol.co.za/entertainment/celebrity-news/local/2024-08-26-legendary-actress-thembi-nyandeni-honoured-with-the-gagasi-fm-lifetime-shero-award/ &lt;/ref&gt; 

== Umsebenzi wokulingisa ==
U-Nyandeni usebenze kumabonakude, amafilimu, kanye nesiteji, afaka isandla kwezobuciko bemidlalo yeSewula Afrika ngeendima ezihlukahlukeneko. Ukudlala kwakhe kuvame ukutjengisa iindaba ezisekelwe emphakathini, ezikhambisana nesiko lenarha lokucoca iindaba elikhuluma ngomphakathi, ubunikazi, nokutjhuguluka.

Kanti waziwa njengengcenye yesizukulwana sabalingisi beSewula Afrika abasiza ukwakha nokugcina ibubulo lokuzithabisa lendawo ngesikhathi nangemva kwebandlululo. Umsebenzi wakhe utjengisa ukujamelana, ukuphila isikhathi eside, nokuzibophelela ekulandiseni iindaba. &lt;ref&gt;https://thestar.co.za/news/south-africa/gauteng/2020-12-07-actress-thembi-nyandeni-honoured-for-her-exploits-in-theatre/   &lt;/ref&gt; &lt;ref&gt;https://www.citizen.co.za/mpumalanga-news/news-headlines/2016/07/18/isibaya-stars-surprise-learners/  &lt;/ref&gt;

Kuthelevishini waziwa ngendima ezifana ne: 

* '''''Isibaya'''''
* '''''Zone 14'''''
* '''''Uzalo'''''
* '''''How to Ruin Christmas'''''
* '''''Kwakhala Nyonini'''''

'''Qala godu'''

* Ibhayisikobho yeSewula Afrika
* Umabonakude weSewula Afrika
* [[Theatre in South Africa|Ithiyetha eSewula Afrika]]

== Ireferensi ==
{{reflist}}

[[Category:abosaziwako beSewula Afrika]]
[[Category:iSewula Afrika]]</text>
      <sha1>lk1o2mu7mci536iwlu56yjt5o1f23it</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Abosaziwako beSewula Afrika</title>
    <ns>14</ns>
    <id>1015</id>
    <revision>
      <id>6087</id>
      <timestamp>2025-12-15T16:06:17Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created blank page</comment>
      <origin>6087</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
  </page>
  <page>
    <title>Mukuku Bridge</title>
    <ns>0</ns>
    <id>1016</id>
    <revision>
      <id>6093</id>
      <timestamp>2025-12-18T07:31:19Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1328170114|Mukuku Bridge]]&quot;</comment>
      <origin>6093</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="879" sha1="rsxe1d6fchnf3iu0hyx8wig0s408hmh" xml:space="preserve">'''Ibhuloho le-Mukuku''' (elaziwa nangokuthi yi- ''Tuta Bridge'' ) libhuloho lomgwaqo e -Luapula Province, [[Zambia|e-Zambia]], elithwala umgwaqo we-Tuta / Serenje-Samfya ngaphetjheya komlambo i-Luapula kanye namaxhaphozi we-Bangweulu. Ibhuloho ngelinye lamade khulu e-Zambia, ubude balo buvamise ukubikwa ngamakhilomitha ama-3.5. &lt;ref&gt;https://virtualglobetrotting.com/map/mukuku-bridge-tuta-bridge-zambiaa-s-longest-bridge/view/google/?utm_source=chatgpt.com &lt;/ref&gt; &lt;ref&gt;https://www.zambia.travel/mukukubridge.html &lt;/ref&gt;

'''Umlando nokwakhiwa'''

Ama-akhawundi wesimanjemanje nemithombo yendawo itjengisa bona ibhuloho laqedwa begodu lasetjenziswa ekuthomeni kwabo-1980; imithombo eminengi ibika bona isakhiwo sathunyelwa ngoRhoboyi wee-1983. Ukwakhiwa kwenziwa ukunikela ngendlela ethembekileko yokuwela i-Luapula kanye nokusekela ukuthuthwa kwesifunda nomsebenzi wezomnotho.</text>
      <sha1>rsxe1d6fchnf3iu0hyx8wig0s408hmh</sha1>
    </revision>
    <revision>
      <id>6094</id>
      <parentid>6093</parentid>
      <timestamp>2025-12-18T07:32:42Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6094</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="960" sha1="kb4zf8pmg1ayspc9h1ucicblnkg72tw" xml:space="preserve">'''Ibhuloho le-Mukuku''' (elaziwa nangokuthi yi- ''Tuta Bridge'' ) libhuloho lomgwaqo e -Luapula Province, [[Zambia|e-Zambia]], elithwala umgwaqo we-Tuta / Serenje-Samfya ngaphetjheya komlambo i-Luapula kanye namaxhaphozi we-Bangweulu. Ibhuloho ngelinye lamade khulu e-Zambia, ubude balo buvamise ukubikwa ngamakhilomitha ama-3.5. &lt;ref&gt;https://virtualglobetrotting.com/map/mukuku-bridge-tuta-bridge-zambiaa-s-longest-bridge/view/google/?utm_source=chatgpt.com &lt;/ref&gt; &lt;ref&gt;https://www.zambia.travel/mukukubridge.html &lt;/ref&gt;

'''Umlando nokwakhiwa'''

Ama-akhawundi wesimanjemanje nemithombo yendawo itjengisa bona ibhuloho laqedwa begodu lasetjenziswa ekuthomeni kwabo-1980; imithombo eminengi ibika bona isakhiwo sathunyelwa ngoRhoboyi wee-1983. Ukwakhiwa kwenziwa ukunikela ngendlela ethembekileko yokuwela i-Luapula kanye nokusekela ukuthuthwa kwesifunda nomsebenzi wezomnotho.&lt;ref&gt;https://www.zambialaws.com/Zambia2019Pdfsi/SI%2051%20of%202019.pdf?utm&lt;/ref&gt;</text>
      <sha1>kb4zf8pmg1ayspc9h1ucicblnkg72tw</sha1>
    </revision>
  </page>
  <page>
    <title>Ibhuloho le-Mukuku</title>
    <ns>0</ns>
    <id>1017</id>
    <revision>
      <id>6095</id>
      <timestamp>2025-12-18T07:33:11Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1328170114|Mukuku Bridge]]&quot;</comment>
      <origin>6095</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="879" sha1="rsxe1d6fchnf3iu0hyx8wig0s408hmh" xml:space="preserve">'''Ibhuloho le-Mukuku''' (elaziwa nangokuthi yi- ''Tuta Bridge'' ) libhuloho lomgwaqo e -Luapula Province, [[Zambia|e-Zambia]], elithwala umgwaqo we-Tuta / Serenje-Samfya ngaphetjheya komlambo i-Luapula kanye namaxhaphozi we-Bangweulu. Ibhuloho ngelinye lamade khulu e-Zambia, ubude balo buvamise ukubikwa ngamakhilomitha ama-3.5. &lt;ref&gt;https://virtualglobetrotting.com/map/mukuku-bridge-tuta-bridge-zambiaa-s-longest-bridge/view/google/?utm_source=chatgpt.com &lt;/ref&gt; &lt;ref&gt;https://www.zambia.travel/mukukubridge.html &lt;/ref&gt;

'''Umlando nokwakhiwa'''

Ama-akhawundi wesimanjemanje nemithombo yendawo itjengisa bona ibhuloho laqedwa begodu lasetjenziswa ekuthomeni kwabo-1980; imithombo eminengi ibika bona isakhiwo sathunyelwa ngoRhoboyi wee-1983. Ukwakhiwa kwenziwa ukunikela ngendlela ethembekileko yokuwela i-Luapula kanye nokusekela ukuthuthwa kwesifunda nomsebenzi wezomnotho.</text>
      <sha1>rsxe1d6fchnf3iu0hyx8wig0s408hmh</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:PK2/sandbox</title>
    <ns>2</ns>
    <id>1018</id>
    <revision>
      <id>6096</id>
      <timestamp>2025-12-19T09:06:31Z</timestamp>
      <contributor>
        <username>PK2</username>
        <id>303</id>
      </contributor>
      <comment>Created page with &quot;{| class=&quot;wikitable&quot; style=&quot;font-size:85%&quot; |+ Pages I have in my sandbox |- | &amp;nbsp; |}  ;&lt;div class=&quot;center&quot; style=&quot;width:auto; margin-left:auto; margin-right:auto; font-size:85%&quot;&gt;My sandbox pages in different languages by language code&lt;/div&gt; {| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot; |+ A |- | [[:ab:User:PK2/sandbox|/sandbox]] in [[:en:Abkhaz language|Abkhaz]]&lt;br /&gt;(code: &lt;code&gt;ab&lt;/code&gt;) | [[:ace:User:PK2/sandbox|/sandbox]] in :en:Acehnese langua...&quot;</comment>
      <origin>6096</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="38530" sha1="h3rqiclhv1d8zczkvwfvkyu8p5a0o9i" xml:space="preserve">{| class=&quot;wikitable&quot; style=&quot;font-size:85%&quot;
|+ Pages I have in my sandbox
|-
| &amp;nbsp;
|}

;&lt;div class=&quot;center&quot; style=&quot;width:auto; margin-left:auto; margin-right:auto; font-size:85%&quot;&gt;My sandbox pages in different languages by language code&lt;/div&gt;
{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ A
|-
| [[:ab:User:PK2/sandbox|/sandbox]] in [[:en:Abkhaz language|Abkhaz]]&lt;br /&gt;(code: &lt;code&gt;ab&lt;/code&gt;)
| [[:ace:User:PK2/sandbox|/sandbox]] in [[:en:Acehnese language|Acehnese]]&lt;br /&gt;(code: &lt;code&gt;ace&lt;/code&gt;)
| [[:ady:User:PK2/sandbox|/sandbox]] in [[:en:Adyghe language|Adyghe]]&lt;br /&gt;(code: &lt;code&gt;ady&lt;/code&gt;)
| [[:af:User:PK2/sandbox|/sandbox]] in [[:en:Afrikaans|Afrikaans]]&lt;br /&gt;(code: &lt;code&gt;af&lt;/code&gt;)
| [[:als:User:PK2/sandbox|/sandbox]] in [[:en:Alemannic German|Alemannic German]]&lt;br /&gt;(code: &lt;code&gt;als&lt;/code&gt;)
| [[:alt:User:PK2/sandbox|/sandbox]] in [[:en:Southern Altai language|Southern Altai]]&lt;br /&gt;(code: &lt;code&gt;alt&lt;/code&gt;)
| [[:am:User:PK2/sandbox|/sandbox]] in [[:en:Amharic|Amharic]]&lt;br /&gt;(code: &lt;code&gt;am&lt;/code&gt;)
| [[:ami:User:PK2/sandbox|/sandbox]] in [[:en:Amis language|Amis]]&lt;br /&gt;(code: &lt;code&gt;ami&lt;/code&gt;)
| [[:an:User:PK2/sandbox|/sandbox]] in [[:en:Aragonese language|Aragonese]]&lt;br /&gt;(code: &lt;code&gt;an&lt;/code&gt;)
| [[:ang:User:PK2/sandbox|/sandbox]] in [[:en:Old English|Old English]]&lt;br /&gt;(code: &lt;code&gt;ang&lt;/code&gt;)
|-
| [[:ann:User:PK2/sandbox|/sandbox]] in [[:en:Obolo language|Obolo]]&lt;br /&gt;(code: &lt;code&gt;ann&lt;/code&gt;)
| [[:anp:User:PK2/sandbox|/sandbox]] in [[:en:Angika|Angika]]&lt;br /&gt;(code: &lt;code&gt;anp&lt;/code&gt;)
| [[:ar:User:PK2/ملعب|/sandbox]] in [[:en:Arabic|Arabic]]&lt;br /&gt;(code: &lt;code&gt;ar&lt;/code&gt;)
| [[:arc:User:PK2/sandbox|/sandbox]] in [[:en:Aramaic|Aramaic]] ([[:en:Syriac language|Syriac]])&lt;br /&gt;(code: &lt;code&gt;arc&lt;/code&gt;)
| [[:ary:User:PK2/sandbox|/sandbox]] in [[:en:Moroccan Arabic|Moroccan Arabic]]&lt;br /&gt;(code: &lt;code&gt;ary&lt;/code&gt;)
| [[:arz:User:PK2/sandbox|/sandbox]] in [[:en:Egyptian Arabic|Egyptian Arabic]]&lt;br /&gt;(code: &lt;code&gt;arz&lt;/code&gt;)
| [[:as:User:PK2/sandbox|/sandbox]] in [[:en:Assamese language|Assamese]]&lt;br /&gt;(code: &lt;code&gt;as&lt;/code&gt;)
| [[:ast:User:PK2/sandbox|/sandbox]] in [[:en:Asturleonese language|Asturleonese]] ([[:en:Asturian language|Asturian]])&lt;br /&gt;(code: &lt;code&gt;ast&lt;/code&gt;)
| [[:atj:User:PK2/Kokwetcitasinahikan|/sandbox]] in [[:en:Atikamekw language|Atikamekw]]&lt;br /&gt;(code: &lt;code&gt;atj&lt;/code&gt;)
| [[:av:User:PK2/sandbox|/sandbox]] in [[:en:Avar language|Avar]]&lt;br /&gt;(code: &lt;code&gt;av&lt;/code&gt;)
|-
| [[:avk:User:PK2/sandbox|/sandbox]] in [[:en:Kotava|Kotava]]&lt;br /&gt;(code: &lt;code&gt;avk&lt;/code&gt;)
| [[:awa:User:PK2/sandbox|/sandbox]] in [[:en:Awadhi language|Awadhi]]&lt;br /&gt;(code: &lt;code&gt;awa&lt;/code&gt;)
| [[:ay:User:PK2/sandbox|/sandbox]] in [[:en:Aymara language|Aymara]]&lt;br /&gt;(code: &lt;code&gt;ay&lt;/code&gt;)
| [[:az:User:PK2/Qaralama|/sandbox]] in [[:en:Azerbaijani language|Azerbaijani]]&lt;br /&gt;(code: &lt;code&gt;az&lt;/code&gt;)
| [[:azb:User:PK2/sandbox|/sandbox]] in [[:en:Azerbaijani language#South Azerbaijani|South Azerbaijani]]&lt;br /&gt;(code: &lt;code&gt;azb&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ B
|-
| [[:ba:User:PK2/sandbox|/sandbox]] in [[:en:Bashkir language|Bashkir]]&lt;br /&gt;(code: &lt;code&gt;ba&lt;/code&gt;)
| [[:ban:User:PK2/sandbox|/sandbox]] in [[:en:Balinese language|Balinese]]&lt;br /&gt;(code: &lt;code&gt;ban&lt;/code&gt;)
| [[:bar:User:PK2/sandbox|/sandbox]] in [[:en:Bavarian language|Bavarian]]&lt;br /&gt;(code: &lt;code&gt;bar&lt;/code&gt;)
| [[:bat-smg:User:PK2/sandbox|/sandbox]] in [[:en:Samogitian language|Samogitian]]&lt;br /&gt;(code: &lt;code&gt;bat-smg&lt;/code&gt;)
| [[:bbc:User:PK2/sandbox|/sandbox]] in [[:en:Toba Batak language|Toba Batak]]&lt;br /&gt;(code: &lt;code&gt;bbc&lt;/code&gt;)
| [[:bcl:User:PK2/sandbox|/sandbox]] in [[:en:Central Bikol|Central Bikol]]&lt;br /&gt;(code: &lt;code&gt;bcl&lt;/code&gt;)
| [[:bdr:User:PK2/sandbox|/sandbox]] in [[:en:Sama–Bajaw languages|West Coast Bajau]]&lt;br /&gt;(code: &lt;code&gt;bdr&lt;/code&gt;)
| [[:be:User:PK2/sandbox|/sandbox]] in [[:en:Belarusian language|Belarusian]]&lt;br /&gt;(code: &lt;code&gt;be&lt;/code&gt;)
| [[:be-tarask:User:PK2/sandbox|/sandbox]] in [[:en:Belarusian language|Belarusian]] ([[:en:Taraškievica|Taraškievica]])&lt;br /&gt;(code: &lt;code&gt;be-tarask&lt;/code&gt;)
| [[:bew:User:PK2/sandbox|/sandbox]] in [[:en:Betawi language|Betawi]]&lt;br /&gt;(code: &lt;code&gt;bew&lt;/code&gt;)
|-
| [[:bg:User:PK2/sandbox|/sandbox]] in [[:en:Bulgarian language|Bulgarian]]&lt;br /&gt;(code: &lt;code&gt;bg&lt;/code&gt;)
| [[:bh:User:PK2/sandbox|/sandbox]] in [[:en:Bihari languages|Bihari]] ([[:en:Bhojpuri language|Bhojpuri]])&lt;br /&gt;(code: &lt;code&gt;bh&lt;/code&gt;)
| [[:bi:User:PK2/sandbox|/sandbox]] in [[:en:Bislama|Bislama]]&lt;br /&gt;(code: &lt;code&gt;bi&lt;/code&gt;)
| [[:bjn:User:PK2/sandbox|/sandbox]] in [[:en:Banjarese language|Banjarese]]&lt;br /&gt;(code: &lt;code&gt;bjn&lt;/code&gt;)
| [[:blk:User:PK2/sandbox|/sandbox]] in [[:en:Pa'O language|Pa'O]]&lt;br /&gt;(code: &lt;code&gt;blk&lt;/code&gt;)
| [[:bm:User:PK2/sandbox|/sandbox]] in [[:en:Bambara language|Bambara]]&lt;br /&gt;(code: &lt;code&gt;bm&lt;/code&gt;)
| [[:bn:User:PK2/খেলাঘর|/sandbox]] in [[:en:Bengali language|Bengali]]&lt;br /&gt;(code: &lt;code&gt;bn&lt;/code&gt;)
| [[:bo:User:PK2/sandbox|/sandbox]] in [[:en:Central Tibetan|Central Tibetan]] ([[:en:Lhasa Tibetan|Lhasa Tibetan]])&lt;br /&gt;(code: &lt;code&gt;bo&lt;/code&gt;)
| [[:bpy:User:PK2/sandbox|/sandbox]] in [[:en:Bishnupriya Manipuri|Bishnupriya Manipuri]]&lt;br /&gt;(code: &lt;code&gt;bpy&lt;/code&gt;)
| [[:br:User:PK2/sandbox|/sandbox]] in [[:en:Breton language|Breton]]&lt;br /&gt;(code: &lt;code&gt;br&lt;/code&gt;)
|-
| [[:bs:User:PK2/sandbox|/sandbox]] in [[:en:Bosnian language|Bosnian]]&lt;br /&gt;(code: &lt;code&gt;bs&lt;/code&gt;)
| [[:btm:User:PK2/sandbox|/sandbox]] in [[:en:Mandailing Batak language|Mandailing Batak]]&lt;br /&gt;(code: &lt;code&gt;btm&lt;/code&gt;)
| [[:bug:User:PK2/sandbox|/sandbox]] in [[:en:Buginese language|Buginese]]&lt;br /&gt;(code: &lt;code&gt;bug&lt;/code&gt;)
| [[:bxr:User:PK2/sandbox|/sandbox]] in [[:en:Buryat language|Buryat]] (Russia Buriat)&lt;br /&gt;(code: &lt;code&gt;bxr&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ C
|-
| [[:ca:User:PK2/proves|/sandbox]] in [[:en:Catalan language|Catalan]]&lt;br /&gt;(code: &lt;code&gt;ca&lt;/code&gt;)
| [[:cbk-zam:User:PK2/sandbox|/sandbox]] in [[:en:Chavacano|Chavacano]] (Zamboanga)&lt;br /&gt;(code: &lt;code&gt;cbk-zam&lt;/code&gt;)
| [[:cdo:User:PK2/sandbox|/sandbox]] in [[:en:Eastern Min|Eastern Min]]&lt;br /&gt;(code: &lt;code&gt;cdo&lt;/code&gt;)
| [[:ce:User:PK2/sandbox|/sandbox]] in [[:en:Chechen language|Chechen]]&lt;br /&gt;(code: &lt;code&gt;ce&lt;/code&gt;)
| [[:ceb:User:PK2/sandbox|/sandbox]] in [[:en:Cebuano language|Cebuano]]&lt;br /&gt;(code: &lt;code&gt;ceb&lt;/code&gt;)
| [[:ch:User:PK2/sandbox|/sandbox]] in [[:en:Chamorro language|Chamorro]]&lt;br /&gt;(code: &lt;code&gt;ch&lt;/code&gt;)
| [[:chr:User:PK2/sandbox|/sandbox]] in [[:en:Cherokee language|Cherokee]]&lt;br /&gt;(code: &lt;code&gt;chr&lt;/code&gt;)
| [[:chy:User:PK2/sandbox|/sandbox]] in [[:en:Cheyenne language|Cheyenne]]&lt;br /&gt;(code: &lt;code&gt;chy&lt;/code&gt;)
|-
| [[:ckb:User:PK2/خۆڵەپەتانێ|/sandbox]] in [[:en:Kurdish language|Kurdish]] ([[:en:Sorani|Sorani]])&lt;br /&gt;(code: &lt;code&gt;ckb&lt;/code&gt;)
| [[:co:User:PK2/sandbox|/sandbox]] in [[:en:Corsican language|Corsican]]&lt;br /&gt;(code: &lt;code&gt;co&lt;/code&gt;)
| [[:crh:User:PK2/sandbox|/sandbox]] in [[:en:Crimean Tatar language|Crimean Tatar]]&lt;br /&gt;(code: &lt;code&gt;crh&lt;/code&gt;)
| [[:cs:User:PK2/Pískoviště|/sandbox]] in [[:en:Czech language|Czech]]&lt;br /&gt;(code: &lt;code&gt;cs&lt;/code&gt;)
| [[:csb:User:PK2/sandbox|/sandbox]] in [[:en:Kashubian language|Kashubian]]&lt;br /&gt;(code: &lt;code&gt;csb&lt;/code&gt;)
| [[:cu:User:PK2/sandbox|/sandbox]] in [[:en:Old Church Slavonic|Old Church Slavonic]]&lt;br /&gt;(code: &lt;code&gt;cu&lt;/code&gt;)
| [[:cv:User:PK2/sandbox|/sandbox]] in [[:en:Chuvash language|Chuvash]]&lt;br /&gt;(code: &lt;code&gt;cv&lt;/code&gt;)
| [[:cy:User:PK2/Pwll Tywod|/sandbox]] in [[:en:Welsh language|Welsh]]&lt;br /&gt;(code: &lt;code&gt;cy&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ D
|-
| [[:da:User:PK2/sandkasse|/sandbox]] in [[:en:Danish language|Danish]]&lt;br /&gt;(code: &lt;code&gt;da&lt;/code&gt;)
| [[:dag:User:PK2/sandbox|/sandbox]] in [[:en:Dagbani language|Dagbani]]&lt;br /&gt;(code: &lt;code&gt;dag&lt;/code&gt;)
| [[:de:User:PK2/sandbox|/sandbox]] in [[:en:German language|German]]&lt;br /&gt;(code: &lt;code&gt;de&lt;/code&gt;)
| [[:dga:User:PK2/sandbox|/sandbox]] in [[:en:Dagaare language|Dagaare]]&lt;br /&gt;(code: &lt;code&gt;dga&lt;/code&gt;)
| [[:din:User:PK2/sandbox|/sandbox]] in [[:en:Dinka language|Dinka]]&lt;br /&gt;(code: &lt;code&gt;din&lt;/code&gt;)
| [[:diq:User:PK2/sandbox|/sandbox]] in [[:en:Zaza language|Zaza]]&lt;br /&gt;(code: &lt;code&gt;diq&lt;/code&gt;)
| [[:dsb:User:PK2/sandbox|/sandbox]] in [[:en:Lower Sorbian language|Lower Sorbian]]&lt;br /&gt;(code: &lt;code&gt;dsb&lt;/code&gt;)
| [[:dtp:User:PK2/sandbox|/sandbox]] in [[:en:Dusun language|Dusun]]&lt;br /&gt;(code: &lt;code&gt;dtp&lt;/code&gt;)
| [[:dty:User:PK2/प्रयोगस्थल|/sandbox]] in [[:en:Doteli|Doteli]]&lt;br /&gt;(code: &lt;code&gt;dty&lt;/code&gt;)
| [[:dv:User:PK2/sandbox|/sandbox]] in [[:en:Maldivian language|Maldivian]]&lt;br /&gt;(code: &lt;code&gt;dv&lt;/code&gt;)
| [[:dz:User:PK2/sandbox|/sandbox]] in [[:en:Dzongkha|Dzongkha]]&lt;br /&gt;(code: &lt;code&gt;dz&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ E
|-
| [[:ee:User:PK2/sandbox|/sandbox]] in [[:en:Ewe language|Ewe]]&lt;br /&gt;(code: &lt;code&gt;ee&lt;/code&gt;)
| [[:el:User:PK2/πρόχειρο|/sandbox]] in [[:en:Greek language|Greek]]&lt;br /&gt;(code: &lt;code&gt;el&lt;/code&gt;)
| [[:eml:User:PK2/sandbox|/sandbox]] in [[:en:Emilian–Romagnol|Emilian–Romagnol]]&lt;br /&gt;(code: &lt;code&gt;eml&lt;/code&gt;)
| [[:en:User:PK2/sandbox|/sandbox]] in [[:en:English language|English]]&lt;br /&gt;(code: &lt;code&gt;en&lt;/code&gt;)
| [[:eo:User:PK2/provejo|/sandbox]] in [[:en:Esperanto|Esperanto]]&lt;br /&gt;(code: &lt;code&gt;eo&lt;/code&gt;)
| [[:es:User:PK2/Taller|/sandbox]] in [[:en:Spanish language|Spanish]]&lt;br /&gt;(code: &lt;code&gt;es&lt;/code&gt;)
| [[:et:User:PK2/sandbox|/sandbox]] in [[:en:Estonian language|Estonian]]&lt;br /&gt;(code: &lt;code&gt;et&lt;/code&gt;)
| [[:eu:User:PK2/Proba orria|/sandbox]] in [[:en:Basque language|Basque]]&lt;br /&gt;(code: &lt;code&gt;eu&lt;/code&gt;)
| [[:ext:User:PK2/obraol|/sandbox]] in [[:en:Extremaduran language|Extremaduran]]&lt;br /&gt;(code: &lt;code&gt;ext&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ F
|-
| [[:fa:User:PK2/صفحه تمرین|/sandbox]] in [[:en:Persian language|Persian]]&lt;br /&gt;(code: &lt;code&gt;fa&lt;/code&gt;)
| [[:fat:User:PK2/sandbox|/sandbox]] in [[:en:Akan language|Akan]] ([[:en:Fante dialect|Fante]])&lt;br /&gt;(code: &lt;code&gt;fat&lt;/code&gt;)
| [[:ff:User:PK2/sandbox|/sandbox]] in [[:en:Fula language|Fula]]&lt;br /&gt;(code: &lt;code&gt;ff&lt;/code&gt;)
| [[:fi:User:PK2/sandbox|/sandbox]] in [[:en:Finnish language|Finnish]]&lt;br /&gt;(code: &lt;code&gt;fi&lt;/code&gt;)
| [[:fiu-vro:User:PK2/sandbox|/sandbox]] in [[:en:Võro language|Võro]]&lt;br /&gt;(code: &lt;code&gt;fiu-vro&lt;/code&gt;)
| [[:fj:User:PK2/sandbox|/sandbox]] in [[:en:Fijian language|Fijian]]&lt;br /&gt;(code: &lt;code&gt;fj&lt;/code&gt;)
| [[:fo:User:PK2/sandbox|/sandbox]] in [[:en:Faroese language|Faroese]]&lt;br /&gt;(code: &lt;code&gt;fo&lt;/code&gt;)
| [[:fon:User:PK2/sandbox|/sandbox]] in [[:en:Fon language|Fon]]&lt;br /&gt;(code: &lt;code&gt;fon&lt;/code&gt;)
| [[:fr:User:PK2/Brouillon|/sandbox]] in [[:en:French language|French]]&lt;br /&gt;(code: &lt;code&gt;fr&lt;/code&gt;)
| [[:frp:User:PK2/sandbox|/sandbox]] in [[:en:Franco-Provençal|Franco-Provençal]]&lt;br /&gt;(code: &lt;code&gt;frp&lt;/code&gt;)
| [[:frr:User:PK2/sandbox|/sandbox]] in [[:en:North Frisian language|North Frisian]]&lt;br /&gt;(code: &lt;code&gt;frr&lt;/code&gt;)
| [[:fur:User:PK2/sandbox|/sandbox]] in [[:en:Friulian language|Friulian]]&lt;br /&gt;(code: &lt;code&gt;fur&lt;/code&gt;)
| [[:fy:User:PK2/sandbox|/sandbox]] in [[:en:West Frisian language|West Frisian]]&lt;br /&gt;(code: &lt;code&gt;fy&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ G
|-
| [[:ga:User:PK2/Clár Dubh|/sandbox]] in [[:en:Irish language|Irish]]&lt;br /&gt;(code: &lt;code&gt;ga&lt;/code&gt;)
| [[:gag:User:PK2/sandbox|/sandbox]] in [[:en:Gagauz language|Gagauz]]&lt;br /&gt;(code: &lt;code&gt;gag&lt;/code&gt;)
| [[:gan:User:PK2/sandbox|/sandbox]] in [[:en:Gan Chinese|Gan Chinese]]&lt;br /&gt;(code: &lt;code&gt;gan&lt;/code&gt;)
| [[:gcr:User:PK2/sandbox|/sandbox]] in [[:en:French Guianese Creole|French Guianese Creole]]&lt;br /&gt;(code: &lt;code&gt;gcr&lt;/code&gt;)
| [[:gd:User:PK2/sandbox|/sandbox]] in [[:en:Scottish Gaelic|Scottish Gaelic]]&lt;br /&gt;(code: &lt;code&gt;gd&lt;/code&gt;)
| [[:gl:User:PK2/sandbox|/sandbox]] in [[:en:Galician language|Galician]]&lt;br /&gt;(code: &lt;code&gt;gl&lt;/code&gt;)
| [[:glk:User:PK2/sandbox|/sandbox]] in [[:en:Gilaki language|Gilaki]]&lt;br /&gt;(code: &lt;code&gt;glk&lt;/code&gt;)
| [[:gn:User:PK2/sandbox|/sandbox]] in [[:en:Guarani language|Guarani]]&lt;br /&gt;(code: &lt;code&gt;gn&lt;/code&gt;)
| [[:gom:User:PK2/proiogpan|/sandbox]] in [[:en:Konkani language|Konkani]] (Goan Konkani)&lt;br /&gt;(code: &lt;code&gt;gom&lt;/code&gt;)
|-
| [[:gor:User:PK2/sandbox|/sandbox]] in [[:en:Gorontalo language|Gorontalo]]&lt;br /&gt;(code: &lt;code&gt;gor&lt;/code&gt;)
| [[:got:User:PK2/sandbox|/sandbox]] in [[:en:Gothic language|Gothic]]&lt;br /&gt;(code: &lt;code&gt;got&lt;/code&gt;)
| [[:gpe:User:PK2/sandbox|/sandbox]] in [[:en:Ghanaian Pidgin English|Ghanaian Pidgin English]]&lt;br /&gt;(code: &lt;code&gt;gpe&lt;/code&gt;)
| [[:gu:User:PK2/sandbox|/sandbox]] in [[:en:Gujarati language|Gujarati]]&lt;br /&gt;(code: &lt;code&gt;gu&lt;/code&gt;)
| [[:guc:User:PK2/sandbox|/sandbox]] in [[:en:Wayuu language|Wayuu]]&lt;br /&gt;(code: &lt;code&gt;guc&lt;/code&gt;)
| [[:gur:User:PK2/sandbox|/sandbox]] in [[:en:Farefare language|Farefare]]&lt;br /&gt;(code: &lt;code&gt;gur&lt;/code&gt;)
| [[:guw:User:PK2/sandbox|/sandbox]] in [[:en:Gun language|Gun]]&lt;br /&gt;(code: &lt;code&gt;guw&lt;/code&gt;)
| [[:gv:User:PK2/sandbox|/sandbox]] in [[:en:Manx language|Manx]]&lt;br /&gt;(code: &lt;code&gt;gv&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ H
|-
| [[:ha:User:PK2/sandbox|/sandbox]] in [[:en:Hausa language|Hausa]]&lt;br /&gt;(code: &lt;code&gt;ha&lt;/code&gt;)
| [[:hak:User:PK2/sandbox|/sandbox]] in [[:en:Hakka Chinese|Hakka Chinese]]&lt;br /&gt;(code: &lt;code&gt;hak&lt;/code&gt;)
| [[:haw:User:PK2/sandbox|/sandbox]] in [[:en:Hawaiian language|Hawaiian]]&lt;br /&gt;(code: &lt;code&gt;haw&lt;/code&gt;)
| [[:he:User:PK2/טיוטה|/sandbox]] in [[:en:Hebrew language|Hebrew]]&lt;br /&gt;(code: &lt;code&gt;he&lt;/code&gt;)
| [[:hi:User:PK2/प्रयोगपृष्ठ|/sandbox]] in [[:en:Hindi|Hindi]]&lt;br /&gt;(code: &lt;code&gt;hi&lt;/code&gt;)
| [[:hif:User:PK2/sandbox|/sandbox]] in [[:en:Fiji Hindi|Fiji Hindi]]&lt;br /&gt;(code: &lt;code&gt;hif&lt;/code&gt;)
| [[:hr:User:PK2/sandbox|/sandbox]] in [[:en:Croatian language|Croatian]]&lt;br /&gt;(code: &lt;code&gt;hr&lt;/code&gt;)
| [[:hsb:User:PK2/sandbox|/sandbox]] in [[:en:Upper Sorbian language|Upper Sorbian]]&lt;br /&gt;(code: &lt;code&gt;hsb&lt;/code&gt;)
| [[:ht:User:PK2/sandbox|/sandbox]] in [[:en:Haitian Creole|Haitian Creole]]&lt;br /&gt;(code: &lt;code&gt;ht&lt;/code&gt;)
| [[:hu:User:PK2/próbalap|/sandbox]] in [[:en:Hungarian language|Hungarian]]&lt;br /&gt;(code: &lt;code&gt;hu&lt;/code&gt;)
| [[:hy:User:PK2/Ավազարկղ|/sandbox]] in [[:en:Armenian language|Armenian]] ([[:en:Eastern Armenian|Eastern Armenian]])&lt;br /&gt;(code: &lt;code&gt;hy&lt;/code&gt;)
| [[:hyw:User:PK2/Սեւագրութիւն|/sandbox]] in [[:en:Western Armenian|Western Armenian]]&lt;br /&gt;(code: &lt;code&gt;hyw&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ I
|-
| [[:ia:User:PK2/sandbox|/sandbox]] in [[:en:Interlingua|Interlingua]]&lt;br /&gt;(code: &lt;code&gt;ia&lt;/code&gt;)
| [[:iba:User:PK2/sandbox|/sandbox]] in [[:en:Iban language|Iban]]&lt;br /&gt;(code: &lt;code&gt;iba&lt;/code&gt;)
| [[:id:User:PK2/sandbox|/sandbox]] in [[:en:Indonesian language|Indonesian]]&lt;br /&gt;(code: &lt;code&gt;id&lt;/code&gt;)
| [[:ie:User:PK2/sandbox|/sandbox]] in [[:en:Interlingue|Interlingue]]&lt;br /&gt;(code: &lt;code&gt;ie&lt;/code&gt;)
| [[:ig:User:PK2/sandbox|/sandbox]] in [[:en:Igbo language|Igbo]]&lt;br /&gt;(code: &lt;code&gt;ig&lt;/code&gt;)
| [[:igl:User:PK2/sandbox|/sandbox]] in [[:en:Igala language|Igala]]&lt;br /&gt;(code: &lt;code&gt;igl&lt;/code&gt;)
| [[:ik:User:PK2/sandbox|/sandbox]] in [[:en:Iñupiaq language|Iñupiaq]]&lt;br /&gt;(code: &lt;code&gt;ik&lt;/code&gt;)
| [[:ilo:User:PK2/pagipadasan|/sandbox]] in [[:en:Ilocano language|Ilocano]]&lt;br /&gt;(code: &lt;code&gt;ilo&lt;/code&gt;)
| [[:inh:User:PK2/sandbox|/sandbox]] in [[:en:Ingush language|Ingush]]&lt;br /&gt;(code: &lt;code&gt;inh&lt;/code&gt;)
| [[:io:User:PK2/sandbox|/sandbox]] in [[:en:Ido|Ido]]&lt;br /&gt;(code: &lt;code&gt;io&lt;/code&gt;)
| [[:is:User:PK2/sandkassi|/sandbox]] in [[:en:Icelandic language|Icelandic]]&lt;br /&gt;(code: &lt;code&gt;is&lt;/code&gt;)
| [[:it:User:PK2/Sandbox|/sandbox]] in [[:en:Italian language|Italian]]&lt;br /&gt;(code: &lt;code&gt;it&lt;/code&gt;)
| [[:iu:User:PK2/sandbox|/sandbox]] in [[:en:Inuktitut|Inuktitut]]&lt;br /&gt;(code: &lt;code&gt;iu&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ J
|-
| [[:ja:User:PK2/sandbox|/sandbox]] in [[:en:Japanese language|Japanese]]&lt;br /&gt;(code: &lt;code&gt;ja&lt;/code&gt;)
| [[:jam:User:PK2/sandbox|/sandbox]] in [[:en:Jamaican Patois|Jamaican Patois]]&lt;br /&gt;(code: &lt;code&gt;jam&lt;/code&gt;)
| [[:jbo:User:PK2/sandbox|/sandbox]] in [[:en:Lojban|Lojban]]&lt;br /&gt;(code: &lt;code&gt;jbo&lt;/code&gt;)
| [[:jv:User:PK2/bak wedhi|/sandbox]] in [[:en:Javanese language|Javanese]]&lt;br /&gt;(code: &lt;code&gt;jv&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ K
|-
| [[:ka:User:PK2/sandbox|/sandbox]] in [[:en:Georgian language|Georgian]]&lt;br /&gt;(code: &lt;code&gt;ka&lt;/code&gt;)
| [[:kaa:User:PK2/qaralama|/sandbox]] in [[:en:Karakalpak language|Karakalpak]]&lt;br /&gt;(code: &lt;code&gt;kaa&lt;/code&gt;)
| [[:kab:User:PK2/sandbox|/sandbox]] in [[:en:Kabyle language|Kabyle]]&lt;br /&gt;(code: &lt;code&gt;kab&lt;/code&gt;)
| [[:kbd:User:PK2/sandbox|/sandbox]] in [[:en:Kabardian language|Kabardian]]&lt;br /&gt;(code: &lt;code&gt;kbd&lt;/code&gt;)
| [[:kbp:User:PK2/sandbox|/sandbox]] in [[:en:Kabiye language|Kabiye]]&lt;br /&gt;(code: &lt;code&gt;kbp&lt;/code&gt;)
| [[:kcg:User:PK2/sandbox|/sandbox]] in [[:en:Tyap|Tyap]]&lt;br /&gt;(code: &lt;code&gt;kcg&lt;/code&gt;)
| [[:kg:User:PK2/sandbox|/sandbox]] in [[:en:Kongo language|Kongo]]&lt;br /&gt;(code: &lt;code&gt;kg&lt;/code&gt;)
| [[:kge:User:PK2/sandbox|/sandbox]] in [[:en:Komering language|Komering]]&lt;br /&gt;(code: &lt;code&gt;kge&lt;/code&gt;)
| [[:ki:User:PK2/sandbox|/sandbox]] in [[:en:Kikuyu language|Kikuyu]]&lt;br /&gt;(code: &lt;code&gt;ki&lt;/code&gt;)
| [[:kk:User:PK2/зертхана|/sandbox]] in [[:en:Kazakh language|Kazakh]]&lt;br /&gt;(code: &lt;code&gt;kk&lt;/code&gt;)
| [[:km:User:PK2/sandbox|/sandbox]] in [[:en:Khmer language|Khmer]]&lt;br /&gt;(code: &lt;code&gt;km&lt;/code&gt;)
| [[:kn:User:PK2/ಪ್ರಯೋಗಪುಟ|/sandbox]] in [[:en:Kannada|Kannada]]&lt;br /&gt;(code: &lt;code&gt;kn&lt;/code&gt;)
|-
| [[:knc:User:PK2/sandbox|/sandbox]] in [[:en:Central Kanuri|Central Kanuri]]&lt;br /&gt;(code: &lt;code&gt;knc&lt;/code&gt;)
| [[:ko:User:PK2/연습장|/sandbox]] in [[:en:Korean language|Korean]]&lt;br /&gt;(code: &lt;code&gt;ko&lt;/code&gt;)
| [[:koi:User:PK2/sandbox|/sandbox]] in [[:en:Komi-Permyak language|Komi-Permyak]]&lt;br /&gt;(code: &lt;code&gt;koi&lt;/code&gt;)
| [[:krc:User:PK2/sandbox|/sandbox]] in [[:en:Karachay-Balkar|Karachay-Balkar]]&lt;br /&gt;(code: &lt;code&gt;krc&lt;/code&gt;)
| [[:ks:User:PK2/sandbox|/sandbox]] in [[:en:Kashmiri language|Kashmiri]]&lt;br /&gt;(code: &lt;code&gt;ks&lt;/code&gt;)
| [[:ksh:User:PK2/sandbox|/sandbox]] in [[:en:Ripuarian language|Ripuarian]]&lt;br /&gt;(code: &lt;code&gt;ksh&lt;/code&gt;)
| [[:ku:User:PK2/ceribandin|/sandbox]] in [[:en:Kurdish language|Kurdish]] ([[:en:Kurmanji|Kurmanji]])&lt;br /&gt;(code: &lt;code&gt;ku&lt;/code&gt;)
| [[:kus:User:PK2/sandbox|/sandbox]] in [[:en:Kusaal language|Kusaal]]&lt;br /&gt;(code: &lt;code&gt;kus&lt;/code&gt;)
| [[:kv:User:PK2/sandbox|/sandbox]] in [[:en:Komi language|Komi]]&lt;br /&gt;(code: &lt;code&gt;kv&lt;/code&gt;)
| [[:kw:User:PK2/sandbox|/sandbox]] in [[:en:Cornish language|Cornish]]&lt;br /&gt;(code: &lt;code&gt;kw&lt;/code&gt;)
| [[:ky:User:PK2/sandbox|/sandbox]] in [[:en:Kyrgyz language|Kyrgyz]]&lt;br /&gt;(code: &lt;code&gt;ky&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ L
|-
| [[:la:User:PK2/Harenarium|/sandbox]] in [[:en:Latin|Latin]]&lt;br /&gt;(code: &lt;code&gt;la&lt;/code&gt;)
| [[:lad:User:PK2/Kutí de prova|/sandbox]] in [[:en:Judaeo-Spanish|Judaeo-Spanish]]&lt;br /&gt;(code: &lt;code&gt;lad&lt;/code&gt;)
| [[:lb:User:PK2/sandbox|/sandbox]] in [[:en:Luxembourgish|Luxembourgish]]&lt;br /&gt;(code: &lt;code&gt;lb&lt;/code&gt;)
| [[:lbe:User:PK2/sandbox|/sandbox]] in [[:en:Lak language|Lak]]&lt;br /&gt;(code: &lt;code&gt;lbe&lt;/code&gt;)
| [[:lez:User:PK2/sandbox|/sandbox]] in [[:en:Lezgian language|Lezgian]]&lt;br /&gt;(code: &lt;code&gt;lez&lt;/code&gt;)
| [[:lfn:User:PK2/sandbox|/sandbox]] in [[:en:Lingua Franca Nova|Lingua Franca Nova]]&lt;br /&gt;(code: &lt;code&gt;lfn&lt;/code&gt;)
| [[:lg:User:PK2/sandbox|/sandbox]] in [[:en:Luganda|Luganda]]&lt;br /&gt;(code: &lt;code&gt;lg&lt;/code&gt;)
| [[:li:User:PK2/sandbox|/sandbox]] in [[:en:Limburgish|Limburgish]]&lt;br /&gt;(code: &lt;code&gt;li&lt;/code&gt;)
|-
| [[:lij:User:PK2/sandbox|/sandbox]] in [[:en:Ligurian language|Ligurian]]&lt;br /&gt;(code: &lt;code&gt;lij&lt;/code&gt;)
| [[:lld:User:PK2/sandbox|/sandbox]] in [[:en:Ladin language|Ladin]]&lt;br /&gt;(code: &lt;code&gt;lld&lt;/code&gt;)
| [[:lmo:User:PK2/sandbox|/sandbox]] in [[:en:Lombard language|Lombard]]&lt;br /&gt;(code: &lt;code&gt;lmo&lt;/code&gt;)
| [[:ln:User:PK2/sandbox|/sandbox]] in [[:en:Lingala|Lingala]]&lt;br /&gt;(code: &lt;code&gt;ln&lt;/code&gt;)
| [[:lo:User:PK2/sandbox|/sandbox]] in [[:en:Lao language|Lao]]&lt;br /&gt;(code: &lt;code&gt;lo&lt;/code&gt;)
| [[:lt:User:PK2/juodraštis|/sandbox]] in [[:en:Lithuanian language|Lithuanian]]&lt;br /&gt;(code: &lt;code&gt;lt&lt;/code&gt;)
| [[:ltg:User:PK2/sandbox|/sandbox]] in [[:en:Latgalian language|Latgalian]]&lt;br /&gt;(code: &lt;code&gt;ltg&lt;/code&gt;)
| [[:lv:User:PK2/Smilšu kaste|/sandbox]] in [[:en:Latvian language|Latvian]]&lt;br /&gt;(code: &lt;code&gt;lv&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ M
|-
| [[:mad:User:PK2/sandbox|/sandbox]] in [[:en:Madurese language|Madurese]]&lt;br /&gt;(code: &lt;code&gt;mad&lt;/code&gt;)
| [[:mai:User:PK2/प्रयोगपृष्ठ|/sandbox]] in [[:en:Maithili language|Maithili]]&lt;br /&gt;(code: &lt;code&gt;mai&lt;/code&gt;)
| [[:map-bms:User:PK2/sandbox|/sandbox]] in [[:en:Javanese language|Javanese]] ([[:en:Banyumasan dialect|Banyumasan]])&lt;br /&gt;(code: &lt;code&gt;map-bms&lt;/code&gt;)
| [[:mdf:User:PK2/sandbox|/sandbox]] in [[:en:Moksha language|Moksha]]&lt;br /&gt;(code: &lt;code&gt;mdf&lt;/code&gt;)
| [[:mg:User:PK2/sandbox|/sandbox]] in [[:en:Malagasy language|Malagasy]]&lt;br /&gt;(code: &lt;code&gt;mg&lt;/code&gt;)
| [[:mhr:User:PK2/sandbox|/sandbox]] in [[:en:Meadow Mari language|Meadow Mari]]&lt;br /&gt;(code: &lt;code&gt;mhr&lt;/code&gt;)
| [[:mi:User:PK2/sandbox|/sandbox]] in [[:en:Māori language|Māori]]&lt;br /&gt;(code: &lt;code&gt;mi&lt;/code&gt;)
| [[:min:User:PK2/bak kasiak|/sandbox]] in [[:en:Minangkabau language|Minangkabau]]&lt;br /&gt;(code: &lt;code&gt;min&lt;/code&gt;)
| [[:mk:User:PK2/sandbox|/sandbox]] in [[:en:Macedonian language|Macedonian]]&lt;br /&gt;(code: &lt;code&gt;mk&lt;/code&gt;)
| [[:ml:User:PK2/sandbox|/sandbox]] in [[:en:Malayalam|Malayalam]]&lt;br /&gt;(code: &lt;code&gt;ml&lt;/code&gt;)
| [[:mn:User:PK2/sandbox|/sandbox]] in [[:en:Mongolian language|Mongolian]]&lt;br /&gt;(code: &lt;code&gt;mn&lt;/code&gt;)
|-
| [[:mni:User:PK2/sandbox|/sandbox]] in [[:en:Meitei language|Meitei]]&lt;br /&gt;(code: &lt;code&gt;mni&lt;/code&gt;)
| [[:mnw:User:PK2/sandbox|/sandbox]] in [[:en:Mon language|Mon]]&lt;br /&gt;(code: &lt;code&gt;mnw&lt;/code&gt;)
| [[:m:mos:User:PK2/sandbox|/sandbox]] in [[:en:Mooré|Mooré]]&lt;br /&gt;(code: &lt;code&gt;mos&lt;/code&gt;)
| [[:mr:User:PK2/sandbox|/sandbox]] in [[:en:Marathi language|Marathi]]&lt;br /&gt;(code: &lt;code&gt;mr&lt;/code&gt;)
| [[:mrj:User:PK2/sandbox|/sandbox]] in [[:en:Hill Mari language|Hill Mari]]&lt;br /&gt;(code: &lt;code&gt;mrj&lt;/code&gt;)
| [[:ms:User:PK2/Kotak pasir|/sandbox]] in [[:en:Malay language|Malay]]&lt;br /&gt;(code: &lt;code&gt;ms&lt;/code&gt;)
| [[:mt:User:PK2/sandbox|/sandbox]] in [[:en:Maltese language|Maltese]]&lt;br /&gt;(code: &lt;code&gt;mt&lt;/code&gt;)
| [[:mwl:User:PK2/Testes|/sandbox]] in [[:en:Mirandese language|Mirandese]]&lt;br /&gt;(code: &lt;code&gt;mwl&lt;/code&gt;)
| [[:my:User:PK2/sandbox|/sandbox]] in [[:en:Burmese language|Burmese]]&lt;br /&gt;(code: &lt;code&gt;my&lt;/code&gt;)
| [[:myv:User:PK2/sandbox|/sandbox]] in [[:en:Erzya language|Erzya]]&lt;br /&gt;(code: &lt;code&gt;myv&lt;/code&gt;)
| [[:mzn:User:PK2/sandbox|/sandbox]] in [[:en:Mazanderani language|Mazanderani]]&lt;br /&gt;(code: &lt;code&gt;mzn&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ N
|-
| [[:nah:User:PK2/sandbox|/sandbox]] in [[:en:Nahuatl|Nahuatl]]&lt;br /&gt;(code: &lt;code&gt;nah&lt;/code&gt;)
| [[:nap:User:PK2/sandbox|/sandbox]] in [[:en:Neapolitan language|Neapolitan]]&lt;br /&gt;(code: &lt;code&gt;nap&lt;/code&gt;)
| [[:nds:User:PK2/sandbox|/sandbox]] in [[:en:Low German|Low German]]&lt;br /&gt;(code: &lt;code&gt;nds&lt;/code&gt;)
| [[:nds-nl:User:PK2/sandbox|/sandbox]] in [[:en:Dutch Low Saxon|Dutch Low Saxon]]&lt;br /&gt;(code: &lt;code&gt;nds-nl&lt;/code&gt;)
| [[:ne:User:PK2/प्रयोगस्थल|/sandbox]] in [[:en:Nepali language|Nepali]]&lt;br /&gt;(code: &lt;code&gt;ne&lt;/code&gt;)
| [[:new:User:PK2/sandbox|/sandbox]] in [[:en:Newar language|Newar]]&lt;br /&gt;(code: &lt;code&gt;new&lt;/code&gt;)
| [[:nia:User:PK2/sandbox|/sandbox]] in [[:en:Nias language|Nias]]&lt;br /&gt;(code: &lt;code&gt;nia&lt;/code&gt;)
| [[:nl:User:PK2/Kladblok|/sandbox]] in [[:en:Dutch language|Dutch]]&lt;br /&gt;(code: &lt;code&gt;nl&lt;/code&gt;)
| [[:nn:User:PK2/sandkasse|/sandbox]] in [[:en:Norwegian language|Norwegian]] ([[:en:Nynorsk|Nynorsk]])&lt;br /&gt;(code: &lt;code&gt;nn&lt;/code&gt;)
|-
| [[:no:User:PK2/sandkasse|/sandbox]] in [[:en:Norwegian language|Norwegian]] ([[:en:Bokmål|Bokmål]])&lt;br /&gt;(code: &lt;code&gt;no&lt;/code&gt;)
| [[:nov:User:PK2/sandbox|/sandbox]] in [[:en:Novial|Novial]]&lt;br /&gt;(code: &lt;code&gt;nov&lt;/code&gt;)
| [[:nqo:User:PK2/sandbox|/sandbox]] in [[:en:N'Ko language|N'Ko]]&lt;br /&gt;(code: &lt;code&gt;nqo&lt;/code&gt;)
| [[:nr:User:PK2/sandbox|/sandbox]] in [[:en:Southern Ndebele language|Southern Ndebele]]&lt;br /&gt;(code: &lt;code&gt;nr&lt;/code&gt;)
| [[:nrm:User:PK2/sandbox|/sandbox]] in [[:en:Norman language|Norman]]&lt;br /&gt;(code: &lt;code&gt;nrm&lt;/code&gt;)
| [[:nso:User:PK2/sandbox|/sandbox]] in [[:en:Northern Sotho|Northern Sotho]]&lt;br /&gt;(code: &lt;code&gt;nso&lt;/code&gt;)
| [[:nup:User:PK2/sandbox|/sandbox]] in [[:en:Nupe language|Nupe]]&lt;br /&gt;(code: &lt;code&gt;nup&lt;/code&gt;)
| [[:nv:User:PK2/sandbox|/sandbox]] in [[:en:Navajo language|Navajo]]&lt;br /&gt;(code: &lt;code&gt;nv&lt;/code&gt;)
| [[:ny:User:PK2/sandbox|/sandbox]] in [[:en:Chewa language|Chewa]]&lt;br /&gt;(code: &lt;code&gt;ny&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ O
|-
| [[:oc:User:PK2/sandbox|/sandbox]] in [[:en:Occitan language|Occitan]]&lt;br /&gt;(code: &lt;code&gt;oc&lt;/code&gt;)
| [[:olo:User:PK2/sandbox|/sandbox]] in [[:en:Livvi-Karelian language|Livvi-Karelian]]&lt;br /&gt;(code: &lt;code&gt;olo&lt;/code&gt;)
| [[:om:User:PK2/sandbox|/sandbox]] in [[:en:Oromo language|Oromo]]&lt;br /&gt;(code: &lt;code&gt;om&lt;/code&gt;)
| [[:or:User:PK2/ପରଖଘର|/sandbox]] in [[:en:Odia language|Odia]]&lt;br /&gt;(code: &lt;code&gt;or&lt;/code&gt;)
| [[:os:User:PK2/sandbox|/sandbox]] in [[:en:Ossetian language|Ossetian]]&lt;br /&gt;(code: &lt;code&gt;os&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ P
|-
| [[:pa:User:PK2/ਕੱਚਾ ਖ਼ਾਕਾ|/sandbox]] in [[:en:Punjabi language|Punjabi]]&lt;br /&gt;(code: &lt;code&gt;pa&lt;/code&gt;)
| [[:pag:User:PK2/sandbox|/sandbox]] in [[:en:Pangasinan language|Pangasinan]]&lt;br /&gt;(code: &lt;code&gt;pag&lt;/code&gt;)
| [[:pam:User:PK2/sandbox|/sandbox]] in [[:en:Kapampangan language|Kapampangan]]&lt;br /&gt;(code: &lt;code&gt;pam&lt;/code&gt;)
| [[:pap:User:PK2/sandbox|/sandbox]] in [[:en:Papiamento|Papiamento]]&lt;br /&gt;(code: &lt;code&gt;pap&lt;/code&gt;)
| [[:pcd:User:PK2/sandbox|/sandbox]] in [[:en:Picard language|Picard]]&lt;br /&gt;(code: &lt;code&gt;pcd&lt;/code&gt;)
| [[:pcm:User:PK2/sandbox|/sandbox]] in [[:en:Nigerian Pidgin|Nigerian Pidgin]]&lt;br /&gt;(code: &lt;code&gt;pcm&lt;/code&gt;)
| [[:pdc:User:PK2/sandbox|/sandbox]] in [[:en:Pennsylvania Dutch language|Pennsylvania Dutch]]&lt;br /&gt;(code: &lt;code&gt;pdc&lt;/code&gt;)
| [[:pfl:User:PK2/sandbox|/sandbox]] in [[:en:Palatine German dialects|Palatine German]]&lt;br /&gt;(code: &lt;code&gt;pfl&lt;/code&gt;)
|-
| [[:pi:User:PK2/sandbox|/sandbox]] in [[:en:Pali|Pali]]&lt;br /&gt;(code: &lt;code&gt;pi&lt;/code&gt;)
| [[:pl:User:PK2/brudnopis|/sandbox]] in [[:en:Polish language|Polish]]&lt;br /&gt;(code: &lt;code&gt;pl&lt;/code&gt;)
| [[:pms:User:PK2/sandbox|/sandbox]] in [[:en:Piedmontese language|Piedmontese]]&lt;br /&gt;(code: &lt;code&gt;pms&lt;/code&gt;)
| [[:pnb:User:PK2/sandbox|/sandbox]] in [[:en:Punjabi language|Punjabi]] (Western Punjabi)&lt;br /&gt;(code: &lt;code&gt;pnb&lt;/code&gt;)
| [[:pnt:User:PK2/sandbox|/sandbox]] in [[:en:Pontic Greek|Pontic Greek]]&lt;br /&gt;(code: &lt;code&gt;pnt&lt;/code&gt;)
| [[:ps:User:PK2/ازمون‌مخ|/sandbox]] in [[:en:Pashto|Pashto]]&lt;br /&gt;(code: &lt;code&gt;ps&lt;/code&gt;)
| [[:pt:User:PK2/Testes|/sandbox]] in [[:en:Portuguese language|Portuguese]]&lt;br /&gt;(code: &lt;code&gt;pt&lt;/code&gt;)
| [[:pwn:User:PK2/sandbox|/sandbox]] in [[:en:Paiwan language|Paiwan]]&lt;br /&gt;(code: &lt;code&gt;pwn&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ Q
|-
| [[:qu:User:PK2/sandbox|/sandbox]] in [[:en:Quechuan languages|Quechua]] ([[:en:Southern Quechua|Southern Quechua]])&lt;br /&gt;(code: &lt;code&gt;qu&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ R
|-
| [[:rki:User:PK2/sandbox|/sandbox]] in [[:en:Rakhine language|Rakhine]]&lt;br /&gt;(code: &lt;code&gt;rki&lt;/code&gt;)
| [[:rm:User:PK2/sandbox|/sandbox]] in [[:en:Romansh language|Romansh]]&lt;br /&gt;(code: &lt;code&gt;rm&lt;/code&gt;)
| [[:rmy:User:PK2/sandbox|/sandbox]] in [[:en:Romani language|Romani]] ([[:en:Vlax Romani language|Vlax Romani]])&lt;br /&gt;(code: &lt;code&gt;rmy&lt;/code&gt;)
| [[:rn:User:PK2/sandbox|/sandbox]] in [[:en:Kirundi|Kirundi]]&lt;br /&gt;(code: &lt;code&gt;rn&lt;/code&gt;)
| [[:ro:User:PK2/teste|/sandbox]] in [[:en:Romanian language|Romanian]]&lt;br /&gt;(code: &lt;code&gt;ro&lt;/code&gt;)
| [[:roa-rup:User:PK2/sandbox|/sandbox]] in [[:en:Aromanian language|Aromanian]]&lt;br /&gt;(code: &lt;code&gt;roa-rup&lt;/code&gt;)
| [[:roa-tara:User:PK2/sandbox|/sandbox]] in [[:en:Neapolitan language|Neapolitan]] ([[:en:Tarantino dialect|Tarantino]])&lt;br /&gt;(code: &lt;code&gt;roa-tara&lt;/code&gt;)
| [[:rsk:User:PK2/sandbox|/sandbox]] in [[:en:Pannonian Rusyn|Pannonian Rusyn]]&lt;br /&gt;(code: &lt;code&gt;rsk&lt;/code&gt;)
| [[:ru:User:PK2/Черновик|/sandbox]] in [[:en:Russian language|Russian]]&lt;br /&gt;(code: &lt;code&gt;ru&lt;/code&gt;)
| [[:rue:User:PK2/sandbox|/sandbox]] in [[:en:Rusyn language|Rusyn]]&lt;br /&gt;(code: &lt;code&gt;rue&lt;/code&gt;)
| [[:rw:User:PK2/sandbox|/sandbox]] in [[:en:Kinyarwanda|Kinyarwanda]]&lt;br /&gt;(code: &lt;code&gt;rw&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ S
|-
| [[:sa:User:PK2/प्रयोगपृष्ठम्|/sandbox]] in [[:en:Sanskrit|Sanskrit]]&lt;br /&gt;(code: &lt;code&gt;sa&lt;/code&gt;)
| [[:sah:User:PK2/sandbox|/sandbox]] in [[:en:Yakut language|Yakut]]&lt;br /&gt;(code: &lt;code&gt;sah&lt;/code&gt;)
| [[:sat:User:PK2/sandbox|/sandbox]] in [[:en:Santali language|Santali]]&lt;br /&gt;(code: &lt;code&gt;sat&lt;/code&gt;)
| [[:sc:User:PK2/sandbox|/sandbox]] in [[:en:Sardinian language|Sardinian]]&lt;br /&gt;(code: &lt;code&gt;sc&lt;/code&gt;)
| [[:scn:User:PK2/sandbox|/sandbox]] in [[:en:Sicilian language|Sicilian]]&lt;br /&gt;(code: &lt;code&gt;scn&lt;/code&gt;)
| [[:sco:User:PK2/sandbox|/sandbox]] in [[:en:Scots language|Scots]]&lt;br /&gt;(code: &lt;code&gt;sco&lt;/code&gt;)
| [[:sd:User:PK2/مشق پٽي|/sandbox]] in [[:en:Sindhi language|Sindhi]]&lt;br /&gt;(code: &lt;code&gt;sd&lt;/code&gt;)
| [[:se:User:PK2/sandbox|/sandbox]] in [[:en:Northern Sámi|Northern Sámi]]&lt;br /&gt;(code: &lt;code&gt;se&lt;/code&gt;)
| [[:sg:User:PK2/sandbox|/sandbox]] in [[:en:Sango language|Sango]]&lt;br /&gt;(code: &lt;code&gt;sg&lt;/code&gt;)
| [[:sh:User:PK2/igralište|/sandbox]] in [[:en:Serbo-Croatian|Serbo-Croatian]]&lt;br /&gt;(code: &lt;code&gt;sh&lt;/code&gt;)
| [[:shi:User:PK2/sandbox|/sandbox]] in [[:en:Shilha language|Shilha]]&lt;br /&gt;(code: &lt;code&gt;shi&lt;/code&gt;)
|-
| [[:shn:User:PK2/sandbox|/sandbox]] in [[:en:Shan language|Shan]]&lt;br /&gt;(code: &lt;code&gt;shn&lt;/code&gt;)
| [[:si:User:PK2/sandbox|/sandbox]] in [[:en:Sinhala language|Sinhala]]&lt;br /&gt;(code: &lt;code&gt;si&lt;/code&gt;)
| [[:simple:User:PK2/sandbox|/sandbox]] in [[:en:Basic English|Basic English]]&lt;br /&gt;(code: &lt;code&gt;simple&lt;/code&gt;)
| [[:sk:User:PK2/pieskovisko|/sandbox]] in [[:en:Slovak language|Slovak]]&lt;br /&gt;(code: &lt;code&gt;sk&lt;/code&gt;)
| [[:skr:User:PK2/sandbox|/sandbox]] in [[:en:Saraiki language|Saraiki]]&lt;br /&gt;(code: &lt;code&gt;skr&lt;/code&gt;)
| [[:sl:User:PK2/sandbox|/sandbox]] in [[:en:Slovene language|Slovene]]&lt;br /&gt;(code: &lt;code&gt;sl&lt;/code&gt;)
| [[:sm:User:PK2/sandbox|/sandbox]] in [[:en:Samoan language|Samoan]]&lt;br /&gt;(code: &lt;code&gt;sm&lt;/code&gt;)
| [[:smn:User:PK2/sandbox|/sandbox]] in [[:en:Inari Sámi language|Inari Sámi]]&lt;br /&gt;(code: &lt;code&gt;smn&lt;/code&gt;)
| [[:sn:User:PK2/sandbox|/sandbox]] in [[:en:Shona language|Shona]]&lt;br /&gt;(code: &lt;code&gt;sn&lt;/code&gt;)
| [[:so:User:PK2/Bacaadka|/sandbox]] in [[:en:Somali language|Somali]]&lt;br /&gt;(code: &lt;code&gt;so&lt;/code&gt;)
| [[:sq:User:PK2/sandbox|/sandbox]] in [[:en:Albanian language|Albanian]]&lt;br /&gt;(code: &lt;code&gt;sq&lt;/code&gt;)
|-
| [[:sr:User:PK2/песак|/sandbox]] in [[:en:Serbian language|Serbian]]&lt;br /&gt;(code: &lt;code&gt;sr&lt;/code&gt;)
| [[:srn:User:PK2/sandbox|/sandbox]] in [[:en:Sranan Tongo|Sranan Tongo]]&lt;br /&gt;(code: &lt;code&gt;srn&lt;/code&gt;)
| [[:ss:User:PK2/sandbox|/sandbox]] in [[:en:Swazi language|Swazi]]&lt;br /&gt;(code: &lt;code&gt;ss&lt;/code&gt;)
| [[:st:User:PK2/sandbox|/sandbox]] in [[:en:Sotho language|Sotho]]&lt;br /&gt;(code: &lt;code&gt;st&lt;/code&gt;)
| [[:stq:User:PK2/sandbox|/sandbox]] in [[:en:Saterland Frisian language|Saterland Frisian]]&lt;br /&gt;(code: &lt;code&gt;stq&lt;/code&gt;)
| [[:su:User:PK2/sandbox|/sandbox]] in [[:en:Sundanese language|Sundanese]]&lt;br /&gt;(code: &lt;code&gt;su&lt;/code&gt;)
| [[:sv:User:PK2/sandlåda|/sandbox]] in [[:en:Swedish language|Swedish]]&lt;br /&gt;(code: &lt;code&gt;sv&lt;/code&gt;)
| [[:sw:User:PK2/ukurasa wa majaribio|/sandbox]] in [[:en:Swahili language|Swahili]]&lt;br /&gt;(code: &lt;code&gt;sw&lt;/code&gt;)
| [[:syl:User:PK2/sandbox|/sandbox]] in [[:en:Sylheti language|Sylheti]]&lt;br /&gt;(code: &lt;code&gt;syl&lt;/code&gt;)
| [[:szl:User:PK2/sandbox|/sandbox]] in [[:en:Silesian language|Silesian]]&lt;br /&gt;(code: &lt;code&gt;szl&lt;/code&gt;)
| [[:szy:User:PK2/sandbox|/sandbox]] in [[:en:Sakizaya language|Sakizaya]]&lt;br /&gt;(code: &lt;code&gt;szy&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ T
|-
| [[:ta:User:PK2/மணல்தொட்டி|/sandbox]] in [[:en:Tamil language|Tamil]]&lt;br /&gt;(code: &lt;code&gt;ta&lt;/code&gt;)
| [[:tay:User:PK2/sandbox|/sandbox]] in [[:en:Atayal language|Atayal]]&lt;br /&gt;(code: &lt;code&gt;tay&lt;/code&gt;)
| [[:tcy:User:PK2/ಕಲ್ಪುನ ಕಳ|/sandbox]] in [[:en:Tulu language|Tulu]]&lt;br /&gt;(code: &lt;code&gt;tcy&lt;/code&gt;)
| [[:tdd:User:PK2/sandbox|/sandbox]] in [[:en:Tai Nuea language|Tai Nuea]]&lt;br /&gt;(code: &lt;code&gt;tdd&lt;/code&gt;)
| [[:te:User:PK2/ప్రయోగశాల|/sandbox]] in [[:en:Telugu language|Telugu]]&lt;br /&gt;(code: &lt;code&gt;te&lt;/code&gt;)
| [[:tet:User:PK2/sandbox|/sandbox]] in [[:en:Tetum language|Tetum]]&lt;br /&gt;(code: &lt;code&gt;tet&lt;/code&gt;)
| [[:tg:User:PK2/Сиёҳнавис|/sandbox]] in [[:en:Tajik language|Tajik]]&lt;br /&gt;(code: &lt;code&gt;tg&lt;/code&gt;)
| [[:th:User:PK2/ทดลองเขียน|/sandbox]] in [[:en:Thai language|Thai]]&lt;br /&gt;(code: &lt;code&gt;th&lt;/code&gt;)
| [[:ti:User:PK2/sandbox|/sandbox]] in [[:en:Tigrinya language|Tigrinya]]&lt;br /&gt;(code: &lt;code&gt;ti&lt;/code&gt;)
| [[:tig:User:PK2/sandbox|/sandbox]] in [[:en:Tigre language|Tigre]]&lt;br /&gt;(code: &lt;code&gt;tig&lt;/code&gt;)
| [[:tk:User:PK2/sandbox|/sandbox]] in [[:en:Turkmen language|Turkmen]]&lt;br /&gt;(code: &lt;code&gt;tk&lt;/code&gt;)
| [[:tl:User:PK2/burador|/sandbox]] in [[:en:Tagalog language|Tagalog]]&lt;br /&gt;(code: &lt;code&gt;tl&lt;/code&gt;)
|-
| [[:tly:User:PK2/sandbox|/sandbox]] in [[:en:Talysh language|Talysh]]&lt;br /&gt;(code: &lt;code&gt;tly&lt;/code&gt;)
| [[:tn:User:PK2/sandbox|/sandbox]] in [[:en:Tswana language|Tswana]]&lt;br /&gt;(code: &lt;code&gt;tn&lt;/code&gt;)
| [[:to:User:PK2/sandbox|/sandbox]] in [[:en:Tongan language|Tongan]]&lt;br /&gt;(code: &lt;code&gt;to&lt;/code&gt;)
| [[:tok:User:PK2/sandbox|/sandbox]] in [[:en:Toki Pona|Toki Pona]]&lt;br /&gt;(code: &lt;code&gt;tok&lt;/code&gt;)
| [[:tpi:User:PK2/sandbox|/sandbox]] in [[:en:Tok Pisin|Tok Pisin]]&lt;br /&gt;(code: &lt;code&gt;tpi&lt;/code&gt;)
| [[:tr:User:PK2/deneme tahtası|/sandbox]] in [[:en:Turkish language|Turkish]]&lt;br /&gt;(code: &lt;code&gt;tr&lt;/code&gt;)
| [[:trv:User:PK2/sandbox|/sandbox]] in [[:en:Seediq language|Seediq]]&lt;br /&gt;(code: &lt;code&gt;trv&lt;/code&gt;)
| [[:ts:User:PK2/sandbox|/sandbox]] in [[:en:Tsonga language|Tsonga]]&lt;br /&gt;(code: &lt;code&gt;ts&lt;/code&gt;)
| [[:tt:User:PK2/sandbox|/sandbox]] in [[:en:Tatar language|Tatar]]&lt;br /&gt;(code: &lt;code&gt;tt&lt;/code&gt;)
| [[:tum:User:PK2/sandbox|/sandbox]] in [[:en:Tumbuka language|Tumbuka]]&lt;br /&gt;(code: &lt;code&gt;tum&lt;/code&gt;)
| [[:tw:User:PK2/sandbox|/sandbox]] in [[:en:Akan language|Akan]] (Twi)&lt;br /&gt;(code: &lt;code&gt;tw&lt;/code&gt;)
| [[:ty:User:PK2/sandbox|/sandbox]] in [[:en:Tahitian language|Tahitian]]&lt;br /&gt;(code: &lt;code&gt;ty&lt;/code&gt;)
| [[:tyv:User:PK2/sandbox|/sandbox]] in [[:en:Tuvan language|Tuvan]]&lt;br /&gt;(code: &lt;code&gt;tyv&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ U
|-
| [[:udm:User:PK2/sandbox|/sandbox]] in [[:en:Udmurt language|Udmurt]]&lt;br /&gt;(code: &lt;code&gt;udm&lt;/code&gt;)
| [[:ug:User:PK2/sandbox|/sandbox]] in [[:en:Uyghur language|Uyghur]]&lt;br /&gt;(code: &lt;code&gt;ug&lt;/code&gt;)
| [[:uk:User:PK2/Чернетка|/sandbox]] in [[:en:Ukrainian language|Ukrainian]]&lt;br /&gt;(code: &lt;code&gt;uk&lt;/code&gt;)
| [[:ur:User:PK2/تختۂ مشق|/sandbox]] in [[:en:Urdu|Urdu]]&lt;br /&gt;(code: &lt;code&gt;ur&lt;/code&gt;)
| [[:uz:User:PK2/qumloq|/sandbox]] in [[:en:Uzbek language|Uzbek]]&lt;br /&gt;(code: &lt;code&gt;uz&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ V
|-
| [[:ve:User:PK2/sandbox|/sandbox]] in [[:en:Venda language|Venda]]&lt;br /&gt;(code: &lt;code&gt;ve&lt;/code&gt;)
| [[:vec:User:PK2/sandbox|/sandbox]] in [[:en:Venetian language|Venetian]]&lt;br /&gt;(code: &lt;code&gt;vec&lt;/code&gt;)
| [[:vep:User:PK2/sandbox|/sandbox]] in [[:en:Veps language|Veps]]&lt;br /&gt;(code: &lt;code&gt;vep&lt;/code&gt;)
| [[:vi:User:PK2/nháp|/sandbox]] in [[:en:Vietnamese language|Vietnamese]]&lt;br /&gt;(code: &lt;code&gt;vi&lt;/code&gt;)
| [[:vls:User:PK2/sandbox|/sandbox]] in [[:en:West Flemish|West Flemish]]&lt;br /&gt;(code: &lt;code&gt;vls&lt;/code&gt;)
| [[:vo:User:PK2/sandbox|/sandbox]] in [[:en:Volapük|Volapük]]&lt;br /&gt;(code: &lt;code&gt;vo&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ W
|-
| [[:wa:User:PK2/sandbox|/sandbox]] in [[:en:Walloon language|Walloon]]&lt;br /&gt;(code: &lt;code&gt;wa&lt;/code&gt;)
| [[:war:User:PK2/sandbox|/sandbox]] in [[:en:Waray language|Waray]]&lt;br /&gt;(code: &lt;code&gt;war&lt;/code&gt;)
| [[:wo:User:PK2/sandbox|/sandbox]] in [[:en:Wolof language|Wolof]]&lt;br /&gt;(code: &lt;code&gt;wo&lt;/code&gt;)
| [[:wuu:User:PK2/sandbox|/sandbox]] in [[:en:Wu Chinese|Wu Chinese]]&lt;br /&gt;(code: &lt;code&gt;wuu&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ X
|-
| [[:xal:User:PK2/sandbox|/sandbox]] in [[:en:Oirat language|Oirat]] ([[:en:Kalmyk Oirat|Kalmyk Oirat]])&lt;br /&gt;(code: &lt;code&gt;xal&lt;/code&gt;)
| [[:xh:User:PK2/sandbox|/sandbox]] in [[:en:Xhosa language|Xhosa]]&lt;br /&gt;(code: &lt;code&gt;xh&lt;/code&gt;)
| [[:xmf:User:PK2/sandbox|/sandbox]] in [[:en:Mingrelian language|Mingrelian]]&lt;br /&gt;(code: &lt;code&gt;xmf&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ Y
|-
| [[:yi:User:PK2/sandbox|/sandbox]] in [[:en:Yiddish|Yiddish]]&lt;br /&gt;(code: &lt;code&gt;yi&lt;/code&gt;)
| [[:yo:User:PK2/sandbox|/sandbox]] in [[:en:Yoruba language|Yoruba]]&lt;br /&gt;(code: &lt;code&gt;yo&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ Z
|-
| [[:za:User:PK2/sandbox|/sandbox]] in [[:en:Zhuang languages|Zhuang]] ([[:en:Standard Zhuang|Standard Zhuang]])&lt;br /&gt;(code: &lt;code&gt;za&lt;/code&gt;)
| [[:zea:User:PK2/sandbox|/sandbox]] in [[:en:Zeelandic|Zeelandic]]&lt;br /&gt;(code: &lt;code&gt;zea&lt;/code&gt;)
| [[:zgh:User:PK2/sandbox|/sandbox]] in [[:en:Standard Moroccan Amazigh|Standard Moroccan Amazigh]]&lt;br /&gt;(code: &lt;code&gt;zgh&lt;/code&gt;)
| [[:zh:User:PK2/沙盒|/sandbox]] in [[:en:Chinese language|Chinese]] ([[:en:Mandarin Chinese|Mandarin Chinese]])&lt;br /&gt;(code: &lt;code&gt;zh&lt;/code&gt;)
| [[:zh-classical:User:PK2/sandbox|/sandbox]] in [[:en:Classical Chinese|Classical Chinese]]&lt;br /&gt;(code: &lt;code&gt;zh-classical&lt;/code&gt;)
| [[:zh-min-nan:User:PK2/sandbox|/sandbox]] in [[:en:Southern Min|Southern Min]]&lt;br /&gt;(code: &lt;code&gt;zh-min-nan&lt;/code&gt;)
| [[:zh-yue:User:PK2/sandbox|/sandbox]] in [[:en:Cantonese|Cantonese]]&lt;br /&gt;(code: &lt;code&gt;zh-yue&lt;/code&gt;)
| [[:zu:User:PK2/sandbox|/sandbox]] in [[:en:Zulu language|Zulu]]&lt;br /&gt;(code: &lt;code&gt;zu&lt;/code&gt;)
|}</text>
      <sha1>h3rqiclhv1d8zczkvwfvkyu8p5a0o9i</sha1>
    </revision>
    <revision>
      <id>6104</id>
      <parentid>6096</parentid>
      <timestamp>2025-12-27T05:56:23Z</timestamp>
      <contributor>
        <username>PK2</username>
        <id>303</id>
      </contributor>
      <minor />
      <origin>6104</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="38530" sha1="t2l1a7nkzod46d48sdyni99uegclq1l" xml:space="preserve">{| class=&quot;wikitable&quot; style=&quot;font-size:85%&quot;
|+ Pages I have in my sandbox
|-
| &amp;nbsp;
|}

;&lt;div class=&quot;center&quot; style=&quot;width:auto; margin-left:auto; margin-right:auto; font-size:85%&quot;&gt;My sandbox pages in different languages by language code&lt;/div&gt;
{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ A
|-
| [[:ab:User:PK2/sandbox|/sandbox]] in [[:en:Abkhaz language|Abkhaz]]&lt;br /&gt;(code: &lt;code&gt;ab&lt;/code&gt;)
| [[:ace:User:PK2/sandbox|/sandbox]] in [[:en:Acehnese language|Acehnese]]&lt;br /&gt;(code: &lt;code&gt;ace&lt;/code&gt;)
| [[:ady:User:PK2/sandbox|/sandbox]] in [[:en:Adyghe language|Adyghe]]&lt;br /&gt;(code: &lt;code&gt;ady&lt;/code&gt;)
| [[:af:User:PK2/sandbox|/sandbox]] in [[:en:Afrikaans|Afrikaans]]&lt;br /&gt;(code: &lt;code&gt;af&lt;/code&gt;)
| [[:als:User:PK2/sandbox|/sandbox]] in [[:en:Alemannic German|Alemannic German]]&lt;br /&gt;(code: &lt;code&gt;als&lt;/code&gt;)
| [[:alt:User:PK2/sandbox|/sandbox]] in [[:en:Southern Altai language|Southern Altai]]&lt;br /&gt;(code: &lt;code&gt;alt&lt;/code&gt;)
| [[:am:User:PK2/sandbox|/sandbox]] in [[:en:Amharic|Amharic]]&lt;br /&gt;(code: &lt;code&gt;am&lt;/code&gt;)
| [[:ami:User:PK2/sandbox|/sandbox]] in [[:en:Amis language|Amis]]&lt;br /&gt;(code: &lt;code&gt;ami&lt;/code&gt;)
| [[:an:User:PK2/sandbox|/sandbox]] in [[:en:Aragonese language|Aragonese]]&lt;br /&gt;(code: &lt;code&gt;an&lt;/code&gt;)
| [[:ang:User:PK2/sandbox|/sandbox]] in [[:en:Old English|Old English]]&lt;br /&gt;(code: &lt;code&gt;ang&lt;/code&gt;)
|-
| [[:ann:User:PK2/sandbox|/sandbox]] in [[:en:Obolo language|Obolo]]&lt;br /&gt;(code: &lt;code&gt;ann&lt;/code&gt;)
| [[:anp:User:PK2/sandbox|/sandbox]] in [[:en:Angika|Angika]]&lt;br /&gt;(code: &lt;code&gt;anp&lt;/code&gt;)
| [[:ar:User:PK2/ملعب|/sandbox]] in [[:en:Arabic|Arabic]]&lt;br /&gt;(code: &lt;code&gt;ar&lt;/code&gt;)
| [[:arc:User:PK2/sandbox|/sandbox]] in [[:en:Aramaic|Aramaic]] ([[:en:Syriac language|Syriac]])&lt;br /&gt;(code: &lt;code&gt;arc&lt;/code&gt;)
| [[:ary:User:PK2/sandbox|/sandbox]] in [[:en:Moroccan Arabic|Moroccan Arabic]]&lt;br /&gt;(code: &lt;code&gt;ary&lt;/code&gt;)
| [[:arz:User:PK2/sandbox|/sandbox]] in [[:en:Egyptian Arabic|Egyptian Arabic]]&lt;br /&gt;(code: &lt;code&gt;arz&lt;/code&gt;)
| [[:as:User:PK2/sandbox|/sandbox]] in [[:en:Assamese language|Assamese]]&lt;br /&gt;(code: &lt;code&gt;as&lt;/code&gt;)
| [[:ast:User:PK2/sandbox|/sandbox]] in [[:en:Asturleonese language|Asturleonese]] ([[:en:Asturian language|Asturian]])&lt;br /&gt;(code: &lt;code&gt;ast&lt;/code&gt;)
| [[:atj:User:PK2/Kokwetcitasinahikan|/sandbox]] in [[:en:Atikamekw language|Atikamekw]]&lt;br /&gt;(code: &lt;code&gt;atj&lt;/code&gt;)
| [[:av:User:PK2/sandbox|/sandbox]] in [[:en:Avar language|Avar]]&lt;br /&gt;(code: &lt;code&gt;av&lt;/code&gt;)
|-
| [[:avk:User:PK2/sandbox|/sandbox]] in [[:en:Kotava|Kotava]]&lt;br /&gt;(code: &lt;code&gt;avk&lt;/code&gt;)
| [[:awa:User:PK2/sandbox|/sandbox]] in [[:en:Awadhi language|Awadhi]]&lt;br /&gt;(code: &lt;code&gt;awa&lt;/code&gt;)
| [[:ay:User:PK2/sandbox|/sandbox]] in [[:en:Aymara language|Aymara]]&lt;br /&gt;(code: &lt;code&gt;ay&lt;/code&gt;)
| [[:az:User:PK2/Qaralama|/sandbox]] in [[:en:Azerbaijani language|Azerbaijani]]&lt;br /&gt;(code: &lt;code&gt;az&lt;/code&gt;)
| [[:azb:User:PK2/sandbox|/sandbox]] in [[:en:Azerbaijani language#South Azerbaijani|South Azerbaijani]]&lt;br /&gt;(code: &lt;code&gt;azb&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ B
|-
| [[:ba:User:PK2/sandbox|/sandbox]] in [[:en:Bashkir language|Bashkir]]&lt;br /&gt;(code: &lt;code&gt;ba&lt;/code&gt;)
| [[:ban:User:PK2/sandbox|/sandbox]] in [[:en:Balinese language|Balinese]]&lt;br /&gt;(code: &lt;code&gt;ban&lt;/code&gt;)
| [[:bar:User:PK2/sandbox|/sandbox]] in [[:en:Bavarian language|Bavarian]]&lt;br /&gt;(code: &lt;code&gt;bar&lt;/code&gt;)
| [[:bat-smg:User:PK2/sandbox|/sandbox]] in [[:en:Samogitian language|Samogitian]]&lt;br /&gt;(code: &lt;code&gt;bat-smg&lt;/code&gt;)
| [[:bbc:User:PK2/sandbox|/sandbox]] in [[:en:Toba Batak language|Toba Batak]]&lt;br /&gt;(code: &lt;code&gt;bbc&lt;/code&gt;)
| [[:bcl:User:PK2/sandbox|/sandbox]] in [[:en:Central Bikol|Central Bikol]]&lt;br /&gt;(code: &lt;code&gt;bcl&lt;/code&gt;)
| [[:bdr:User:PK2/sandbox|/sandbox]] in [[:en:Sama–Bajaw languages|West Coast Bajau]]&lt;br /&gt;(code: &lt;code&gt;bdr&lt;/code&gt;)
| [[:be:User:PK2/sandbox|/sandbox]] in [[:en:Belarusian language|Belarusian]]&lt;br /&gt;(code: &lt;code&gt;be&lt;/code&gt;)
| [[:be-tarask:User:PK2/sandbox|/sandbox]] in [[:en:Belarusian language|Belarusian]] ([[:en:Taraškievica|Taraškievica]])&lt;br /&gt;(code: &lt;code&gt;be-tarask&lt;/code&gt;)
| [[:bew:User:PK2/sandbox|/sandbox]] in [[:en:Betawi language|Betawi]]&lt;br /&gt;(code: &lt;code&gt;bew&lt;/code&gt;)
|-
| [[:bg:User:PK2/sandbox|/sandbox]] in [[:en:Bulgarian language|Bulgarian]]&lt;br /&gt;(code: &lt;code&gt;bg&lt;/code&gt;)
| [[:bh:User:PK2/sandbox|/sandbox]] in [[:en:Bihari languages|Bihari]] ([[:en:Bhojpuri language|Bhojpuri]])&lt;br /&gt;(code: &lt;code&gt;bh&lt;/code&gt;)
| [[:bi:User:PK2/sandbox|/sandbox]] in [[:en:Bislama|Bislama]]&lt;br /&gt;(code: &lt;code&gt;bi&lt;/code&gt;)
| [[:bjn:User:PK2/sandbox|/sandbox]] in [[:en:Banjarese language|Banjarese]]&lt;br /&gt;(code: &lt;code&gt;bjn&lt;/code&gt;)
| [[:blk:User:PK2/sandbox|/sandbox]] in [[:en:Pa'O language|Pa'O]]&lt;br /&gt;(code: &lt;code&gt;blk&lt;/code&gt;)
| [[:bm:User:PK2/sandbox|/sandbox]] in [[:en:Bambara language|Bambara]]&lt;br /&gt;(code: &lt;code&gt;bm&lt;/code&gt;)
| [[:bn:User:PK2/খেলাঘর|/sandbox]] in [[:en:Bengali language|Bengali]]&lt;br /&gt;(code: &lt;code&gt;bn&lt;/code&gt;)
| [[:bo:User:PK2/sandbox|/sandbox]] in [[:en:Central Tibetan|Central Tibetan]] ([[:en:Lhasa Tibetan|Lhasa Tibetan]])&lt;br /&gt;(code: &lt;code&gt;bo&lt;/code&gt;)
| [[:bpy:User:PK2/sandbox|/sandbox]] in [[:en:Bishnupriya Manipuri|Bishnupriya Manipuri]]&lt;br /&gt;(code: &lt;code&gt;bpy&lt;/code&gt;)
| [[:br:User:PK2/sandbox|/sandbox]] in [[:en:Breton language|Breton]]&lt;br /&gt;(code: &lt;code&gt;br&lt;/code&gt;)
|-
| [[:bs:User:PK2/sandbox|/sandbox]] in [[:en:Bosnian language|Bosnian]]&lt;br /&gt;(code: &lt;code&gt;bs&lt;/code&gt;)
| [[:btm:User:PK2/sandbox|/sandbox]] in [[:en:Mandailing Batak language|Mandailing Batak]]&lt;br /&gt;(code: &lt;code&gt;btm&lt;/code&gt;)
| [[:bug:User:PK2/sandbox|/sandbox]] in [[:en:Buginese language|Buginese]]&lt;br /&gt;(code: &lt;code&gt;bug&lt;/code&gt;)
| [[:bxr:User:PK2/sandbox|/sandbox]] in [[:en:Buryat language|Buryat]] (Russia Buriat)&lt;br /&gt;(code: &lt;code&gt;bxr&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ C
|-
| [[:ca:User:PK2/proves|/sandbox]] in [[:en:Catalan language|Catalan]]&lt;br /&gt;(code: &lt;code&gt;ca&lt;/code&gt;)
| [[:cbk-zam:User:PK2/sandbox|/sandbox]] in [[:en:Chavacano|Chavacano]] (Zamboanga)&lt;br /&gt;(code: &lt;code&gt;cbk-zam&lt;/code&gt;)
| [[:cdo:User:PK2/sandbox|/sandbox]] in [[:en:Eastern Min|Eastern Min]]&lt;br /&gt;(code: &lt;code&gt;cdo&lt;/code&gt;)
| [[:ce:User:PK2/sandbox|/sandbox]] in [[:en:Chechen language|Chechen]]&lt;br /&gt;(code: &lt;code&gt;ce&lt;/code&gt;)
| [[:ceb:User:PK2/sandbox|/sandbox]] in [[:en:Cebuano language|Cebuano]]&lt;br /&gt;(code: &lt;code&gt;ceb&lt;/code&gt;)
| [[:ch:User:PK2/sandbox|/sandbox]] in [[:en:Chamorro language|Chamorro]]&lt;br /&gt;(code: &lt;code&gt;ch&lt;/code&gt;)
| [[:chr:User:PK2/sandbox|/sandbox]] in [[:en:Cherokee language|Cherokee]]&lt;br /&gt;(code: &lt;code&gt;chr&lt;/code&gt;)
| [[:chy:User:PK2/sandbox|/sandbox]] in [[:en:Cheyenne language|Cheyenne]]&lt;br /&gt;(code: &lt;code&gt;chy&lt;/code&gt;)
|-
| [[:ckb:User:PK2/خۆڵەپەتانێ|/sandbox]] in [[:en:Kurdish language|Kurdish]] ([[:en:Sorani|Sorani]])&lt;br /&gt;(code: &lt;code&gt;ckb&lt;/code&gt;)
| [[:co:User:PK2/sandbox|/sandbox]] in [[:en:Corsican language|Corsican]]&lt;br /&gt;(code: &lt;code&gt;co&lt;/code&gt;)
| [[:crh:User:PK2/sandbox|/sandbox]] in [[:en:Crimean Tatar language|Crimean Tatar]]&lt;br /&gt;(code: &lt;code&gt;crh&lt;/code&gt;)
| [[:cs:User:PK2/Pískoviště|/sandbox]] in [[:en:Czech language|Czech]]&lt;br /&gt;(code: &lt;code&gt;cs&lt;/code&gt;)
| [[:csb:User:PK2/sandbox|/sandbox]] in [[:en:Kashubian language|Kashubian]]&lt;br /&gt;(code: &lt;code&gt;csb&lt;/code&gt;)
| [[:cu:User:PK2/sandbox|/sandbox]] in [[:en:Old Church Slavonic|Old Church Slavonic]]&lt;br /&gt;(code: &lt;code&gt;cu&lt;/code&gt;)
| [[:cv:User:PK2/sandbox|/sandbox]] in [[:en:Chuvash language|Chuvash]]&lt;br /&gt;(code: &lt;code&gt;cv&lt;/code&gt;)
| [[:cy:User:PK2/Pwll Tywod|/sandbox]] in [[:en:Welsh language|Welsh]]&lt;br /&gt;(code: &lt;code&gt;cy&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ D
|-
| [[:da:User:PK2/sandkasse|/sandbox]] in [[:en:Danish language|Danish]]&lt;br /&gt;(code: &lt;code&gt;da&lt;/code&gt;)
| [[:dag:User:PK2/sandbox|/sandbox]] in [[:en:Dagbani language|Dagbani]]&lt;br /&gt;(code: &lt;code&gt;dag&lt;/code&gt;)
| [[:de:User:PK2/sandbox|/sandbox]] in [[:en:German language|German]]&lt;br /&gt;(code: &lt;code&gt;de&lt;/code&gt;)
| [[:dga:User:PK2/sandbox|/sandbox]] in [[:en:Dagaare language|Dagaare]]&lt;br /&gt;(code: &lt;code&gt;dga&lt;/code&gt;)
| [[:din:User:PK2/sandbox|/sandbox]] in [[:en:Dinka language|Dinka]]&lt;br /&gt;(code: &lt;code&gt;din&lt;/code&gt;)
| [[:diq:User:PK2/sandbox|/sandbox]] in [[:en:Zaza language|Zaza]]&lt;br /&gt;(code: &lt;code&gt;diq&lt;/code&gt;)
| [[:dsb:User:PK2/sandbox|/sandbox]] in [[:en:Lower Sorbian language|Lower Sorbian]]&lt;br /&gt;(code: &lt;code&gt;dsb&lt;/code&gt;)
| [[:dtp:User:PK2/sandbox|/sandbox]] in [[:en:Dusun language|Dusun]]&lt;br /&gt;(code: &lt;code&gt;dtp&lt;/code&gt;)
| [[:dty:User:PK2/प्रयोगस्थल|/sandbox]] in [[:en:Doteli|Doteli]]&lt;br /&gt;(code: &lt;code&gt;dty&lt;/code&gt;)
| [[:dv:User:PK2/sandbox|/sandbox]] in [[:en:Maldivian language|Maldivian]]&lt;br /&gt;(code: &lt;code&gt;dv&lt;/code&gt;)
| [[:dz:User:PK2/sandbox|/sandbox]] in [[:en:Dzongkha|Dzongkha]]&lt;br /&gt;(code: &lt;code&gt;dz&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ E
|-
| [[:ee:User:PK2/sandbox|/sandbox]] in [[:en:Ewe language|Ewe]]&lt;br /&gt;(code: &lt;code&gt;ee&lt;/code&gt;)
| [[:el:User:PK2/πρόχειρο|/sandbox]] in [[:en:Greek language|Greek]]&lt;br /&gt;(code: &lt;code&gt;el&lt;/code&gt;)
| [[:eml:User:PK2/sandbox|/sandbox]] in [[:en:Emilian–Romagnol|Emilian–Romagnol]]&lt;br /&gt;(code: &lt;code&gt;eml&lt;/code&gt;)
| [[:en:User:PK2/sandbox|/sandbox]] in [[:en:English language|English]]&lt;br /&gt;(code: &lt;code&gt;en&lt;/code&gt;)
| [[:eo:User:PK2/provejo|/sandbox]] in [[:en:Esperanto|Esperanto]]&lt;br /&gt;(code: &lt;code&gt;eo&lt;/code&gt;)
| [[:es:User:PK2/Taller|/sandbox]] in [[:en:Spanish language|Spanish]]&lt;br /&gt;(code: &lt;code&gt;es&lt;/code&gt;)
| [[:et:User:PK2/sandbox|/sandbox]] in [[:en:Estonian language|Estonian]]&lt;br /&gt;(code: &lt;code&gt;et&lt;/code&gt;)
| [[:eu:User:PK2/Proba orria|/sandbox]] in [[:en:Basque language|Basque]]&lt;br /&gt;(code: &lt;code&gt;eu&lt;/code&gt;)
| [[:ext:User:PK2/obraol|/sandbox]] in [[:en:Extremaduran language|Extremaduran]]&lt;br /&gt;(code: &lt;code&gt;ext&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ F
|-
| [[:fa:User:PK2/صفحه تمرین|/sandbox]] in [[:en:Persian language|Persian]]&lt;br /&gt;(code: &lt;code&gt;fa&lt;/code&gt;)
| [[:fat:User:PK2/sandbox|/sandbox]] in [[:en:Akan language|Akan]] ([[:en:Fante dialect|Fante]])&lt;br /&gt;(code: &lt;code&gt;fat&lt;/code&gt;)
| [[:ff:User:PK2/sandbox|/sandbox]] in [[:en:Fula language|Fula]]&lt;br /&gt;(code: &lt;code&gt;ff&lt;/code&gt;)
| [[:fi:User:PK2/sandbox|/sandbox]] in [[:en:Finnish language|Finnish]]&lt;br /&gt;(code: &lt;code&gt;fi&lt;/code&gt;)
| [[:fiu-vro:User:PK2/sandbox|/sandbox]] in [[:en:Võro language|Võro]]&lt;br /&gt;(code: &lt;code&gt;fiu-vro&lt;/code&gt;)
| [[:fj:User:PK2/sandbox|/sandbox]] in [[:en:Fijian language|Fijian]]&lt;br /&gt;(code: &lt;code&gt;fj&lt;/code&gt;)
| [[:fo:User:PK2/sandbox|/sandbox]] in [[:en:Faroese language|Faroese]]&lt;br /&gt;(code: &lt;code&gt;fo&lt;/code&gt;)
| [[:fon:User:PK2/sandbox|/sandbox]] in [[:en:Fon language|Fon]]&lt;br /&gt;(code: &lt;code&gt;fon&lt;/code&gt;)
| [[:fr:User:PK2/Brouillon|/sandbox]] in [[:en:French language|French]]&lt;br /&gt;(code: &lt;code&gt;fr&lt;/code&gt;)
| [[:frp:User:PK2/sandbox|/sandbox]] in [[:en:Franco-Provençal|Franco-Provençal]]&lt;br /&gt;(code: &lt;code&gt;frp&lt;/code&gt;)
| [[:frr:User:PK2/sandbox|/sandbox]] in [[:en:North Frisian language|North Frisian]]&lt;br /&gt;(code: &lt;code&gt;frr&lt;/code&gt;)
| [[:fur:User:PK2/sandbox|/sandbox]] in [[:en:Friulian language|Friulian]]&lt;br /&gt;(code: &lt;code&gt;fur&lt;/code&gt;)
| [[:fy:User:PK2/sandbox|/sandbox]] in [[:en:West Frisian language|West Frisian]]&lt;br /&gt;(code: &lt;code&gt;fy&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ G
|-
| [[:ga:User:PK2/Clár Dubh|/sandbox]] in [[:en:Irish language|Irish]]&lt;br /&gt;(code: &lt;code&gt;ga&lt;/code&gt;)
| [[:gag:User:PK2/sandbox|/sandbox]] in [[:en:Gagauz language|Gagauz]]&lt;br /&gt;(code: &lt;code&gt;gag&lt;/code&gt;)
| [[:gan:User:PK2/sandbox|/sandbox]] in [[:en:Gan Chinese|Gan Chinese]]&lt;br /&gt;(code: &lt;code&gt;gan&lt;/code&gt;)
| [[:gcr:User:PK2/sandbox|/sandbox]] in [[:en:French Guianese Creole|French Guianese Creole]]&lt;br /&gt;(code: &lt;code&gt;gcr&lt;/code&gt;)
| [[:gd:User:PK2/sandbox|/sandbox]] in [[:en:Scottish Gaelic|Scottish Gaelic]]&lt;br /&gt;(code: &lt;code&gt;gd&lt;/code&gt;)
| [[:gl:User:PK2/sandbox|/sandbox]] in [[:en:Galician language|Galician]]&lt;br /&gt;(code: &lt;code&gt;gl&lt;/code&gt;)
| [[:glk:User:PK2/sandbox|/sandbox]] in [[:en:Gilaki language|Gilaki]]&lt;br /&gt;(code: &lt;code&gt;glk&lt;/code&gt;)
| [[:gn:User:PK2/sandbox|/sandbox]] in [[:en:Guarani language|Guarani]]&lt;br /&gt;(code: &lt;code&gt;gn&lt;/code&gt;)
| [[:gom:User:PK2/proiogpan|/sandbox]] in [[:en:Konkani language|Konkani]] (Goan Konkani)&lt;br /&gt;(code: &lt;code&gt;gom&lt;/code&gt;)
|-
| [[:gor:User:PK2/sandbox|/sandbox]] in [[:en:Gorontalo language|Gorontalo]]&lt;br /&gt;(code: &lt;code&gt;gor&lt;/code&gt;)
| [[:got:User:PK2/sandbox|/sandbox]] in [[:en:Gothic language|Gothic]]&lt;br /&gt;(code: &lt;code&gt;got&lt;/code&gt;)
| [[:gpe:User:PK2/sandbox|/sandbox]] in [[:en:Ghanaian Pidgin English|Ghanaian Pidgin English]]&lt;br /&gt;(code: &lt;code&gt;gpe&lt;/code&gt;)
| [[:gu:User:PK2/sandbox|/sandbox]] in [[:en:Gujarati language|Gujarati]]&lt;br /&gt;(code: &lt;code&gt;gu&lt;/code&gt;)
| [[:guc:User:PK2/sandbox|/sandbox]] in [[:en:Wayuu language|Wayuu]]&lt;br /&gt;(code: &lt;code&gt;guc&lt;/code&gt;)
| [[:gur:User:PK2/sandbox|/sandbox]] in [[:en:Farefare language|Farefare]]&lt;br /&gt;(code: &lt;code&gt;gur&lt;/code&gt;)
| [[:guw:User:PK2/sandbox|/sandbox]] in [[:en:Gun language|Gun]]&lt;br /&gt;(code: &lt;code&gt;guw&lt;/code&gt;)
| [[:gv:User:PK2/sandbox|/sandbox]] in [[:en:Manx language|Manx]]&lt;br /&gt;(code: &lt;code&gt;gv&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ H
|-
| [[:ha:User:PK2/sandbox|/sandbox]] in [[:en:Hausa language|Hausa]]&lt;br /&gt;(code: &lt;code&gt;ha&lt;/code&gt;)
| [[:hak:User:PK2/sandbox|/sandbox]] in [[:en:Hakka Chinese|Hakka Chinese]]&lt;br /&gt;(code: &lt;code&gt;hak&lt;/code&gt;)
| [[:haw:User:PK2/sandbox|/sandbox]] in [[:en:Hawaiian language|Hawaiian]]&lt;br /&gt;(code: &lt;code&gt;haw&lt;/code&gt;)
| [[:he:User:PK2/טיוטה|/sandbox]] in [[:en:Hebrew language|Hebrew]]&lt;br /&gt;(code: &lt;code&gt;he&lt;/code&gt;)
| [[:hi:User:PK2/प्रयोगपृष्ठ|/sandbox]] in [[:en:Hindi|Hindi]]&lt;br /&gt;(code: &lt;code&gt;hi&lt;/code&gt;)
| [[:hif:User:PK2/sandbox|/sandbox]] in [[:en:Fiji Hindi|Fiji Hindi]]&lt;br /&gt;(code: &lt;code&gt;hif&lt;/code&gt;)
| [[:hr:User:PK2/sandbox|/sandbox]] in [[:en:Croatian language|Croatian]]&lt;br /&gt;(code: &lt;code&gt;hr&lt;/code&gt;)
| [[:hsb:User:PK2/sandbox|/sandbox]] in [[:en:Upper Sorbian language|Upper Sorbian]]&lt;br /&gt;(code: &lt;code&gt;hsb&lt;/code&gt;)
| [[:ht:User:PK2/sandbox|/sandbox]] in [[:en:Haitian Creole|Haitian Creole]]&lt;br /&gt;(code: &lt;code&gt;ht&lt;/code&gt;)
| [[:hu:User:PK2/próbalap|/sandbox]] in [[:en:Hungarian language|Hungarian]]&lt;br /&gt;(code: &lt;code&gt;hu&lt;/code&gt;)
| [[:hy:User:PK2/Ավազարկղ|/sandbox]] in [[:en:Armenian language|Armenian]] ([[:en:Eastern Armenian|Eastern Armenian]])&lt;br /&gt;(code: &lt;code&gt;hy&lt;/code&gt;)
| [[:hyw:User:PK2/Սեւագրութիւն|/sandbox]] in [[:en:Western Armenian|Western Armenian]]&lt;br /&gt;(code: &lt;code&gt;hyw&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ I
|-
| [[:ia:User:PK2/sandbox|/sandbox]] in [[:en:Interlingua|Interlingua]]&lt;br /&gt;(code: &lt;code&gt;ia&lt;/code&gt;)
| [[:iba:User:PK2/sandbox|/sandbox]] in [[:en:Iban language|Iban]]&lt;br /&gt;(code: &lt;code&gt;iba&lt;/code&gt;)
| [[:id:User:PK2/sandbox|/sandbox]] in [[:en:Indonesian language|Indonesian]]&lt;br /&gt;(code: &lt;code&gt;id&lt;/code&gt;)
| [[:ie:User:PK2/sandbox|/sandbox]] in [[:en:Interlingue|Interlingue]]&lt;br /&gt;(code: &lt;code&gt;ie&lt;/code&gt;)
| [[:ig:User:PK2/sandbox|/sandbox]] in [[:en:Igbo language|Igbo]]&lt;br /&gt;(code: &lt;code&gt;ig&lt;/code&gt;)
| [[:igl:User:PK2/sandbox|/sandbox]] in [[:en:Igala language|Igala]]&lt;br /&gt;(code: &lt;code&gt;igl&lt;/code&gt;)
| [[:ik:User:PK2/sandbox|/sandbox]] in [[:en:Iñupiaq language|Iñupiaq]]&lt;br /&gt;(code: &lt;code&gt;ik&lt;/code&gt;)
| [[:ilo:User:PK2/pagipadasan|/sandbox]] in [[:en:Ilocano language|Ilocano]]&lt;br /&gt;(code: &lt;code&gt;ilo&lt;/code&gt;)
| [[:inh:User:PK2/sandbox|/sandbox]] in [[:en:Ingush language|Ingush]]&lt;br /&gt;(code: &lt;code&gt;inh&lt;/code&gt;)
| [[:io:User:PK2/sandbox|/sandbox]] in [[:en:Ido|Ido]]&lt;br /&gt;(code: &lt;code&gt;io&lt;/code&gt;)
| [[:is:User:PK2/sandkassi|/sandbox]] in [[:en:Icelandic language|Icelandic]]&lt;br /&gt;(code: &lt;code&gt;is&lt;/code&gt;)
| [[:it:User:PK2/Sandbox|/sandbox]] in [[:en:Italian language|Italian]]&lt;br /&gt;(code: &lt;code&gt;it&lt;/code&gt;)
| [[:iu:User:PK2/sandbox|/sandbox]] in [[:en:Inuktitut|Inuktitut]]&lt;br /&gt;(code: &lt;code&gt;iu&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ J
|-
| [[:ja:User:PK2/sandbox|/sandbox]] in [[:en:Japanese language|Japanese]]&lt;br /&gt;(code: &lt;code&gt;ja&lt;/code&gt;)
| [[:jam:User:PK2/sandbox|/sandbox]] in [[:en:Jamaican Patois|Jamaican Patois]]&lt;br /&gt;(code: &lt;code&gt;jam&lt;/code&gt;)
| [[:jbo:User:PK2/sandbox|/sandbox]] in [[:en:Lojban|Lojban]]&lt;br /&gt;(code: &lt;code&gt;jbo&lt;/code&gt;)
| [[:jv:User:PK2/bak wedhi|/sandbox]] in [[:en:Javanese language|Javanese]]&lt;br /&gt;(code: &lt;code&gt;jv&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ K
|-
| [[:ka:User:PK2/sandbox|/sandbox]] in [[:en:Georgian language|Georgian]]&lt;br /&gt;(code: &lt;code&gt;ka&lt;/code&gt;)
| [[:kaa:User:PK2/qaralama|/sandbox]] in [[:en:Karakalpak language|Karakalpak]]&lt;br /&gt;(code: &lt;code&gt;kaa&lt;/code&gt;)
| [[:kab:User:PK2/sandbox|/sandbox]] in [[:en:Kabyle language|Kabyle]]&lt;br /&gt;(code: &lt;code&gt;kab&lt;/code&gt;)
| [[:kbd:User:PK2/sandbox|/sandbox]] in [[:en:Kabardian language|Kabardian]]&lt;br /&gt;(code: &lt;code&gt;kbd&lt;/code&gt;)
| [[:kbp:User:PK2/sandbox|/sandbox]] in [[:en:Kabiye language|Kabiye]]&lt;br /&gt;(code: &lt;code&gt;kbp&lt;/code&gt;)
| [[:kcg:User:PK2/sandbox|/sandbox]] in [[:en:Tyap|Tyap]]&lt;br /&gt;(code: &lt;code&gt;kcg&lt;/code&gt;)
| [[:kg:User:PK2/sandbox|/sandbox]] in [[:en:Kongo language|Kongo]]&lt;br /&gt;(code: &lt;code&gt;kg&lt;/code&gt;)
| [[:kge:User:PK2/sandbox|/sandbox]] in [[:en:Komering language|Komering]]&lt;br /&gt;(code: &lt;code&gt;kge&lt;/code&gt;)
| [[:ki:User:PK2/sandbox|/sandbox]] in [[:en:Kikuyu language|Kikuyu]]&lt;br /&gt;(code: &lt;code&gt;ki&lt;/code&gt;)
| [[:kk:User:PK2/зертхана|/sandbox]] in [[:en:Kazakh language|Kazakh]]&lt;br /&gt;(code: &lt;code&gt;kk&lt;/code&gt;)
| [[:km:User:PK2/sandbox|/sandbox]] in [[:en:Khmer language|Khmer]]&lt;br /&gt;(code: &lt;code&gt;km&lt;/code&gt;)
| [[:kn:User:PK2/ಪ್ರಯೋಗಪುಟ|/sandbox]] in [[:en:Kannada|Kannada]]&lt;br /&gt;(code: &lt;code&gt;kn&lt;/code&gt;)
|-
| [[:knc:User:PK2/sandbox|/sandbox]] in [[:en:Central Kanuri|Central Kanuri]]&lt;br /&gt;(code: &lt;code&gt;knc&lt;/code&gt;)
| [[:ko:User:PK2/연습장|/sandbox]] in [[:en:Korean language|Korean]]&lt;br /&gt;(code: &lt;code&gt;ko&lt;/code&gt;)
| [[:koi:User:PK2/sandbox|/sandbox]] in [[:en:Komi-Permyak language|Komi-Permyak]]&lt;br /&gt;(code: &lt;code&gt;koi&lt;/code&gt;)
| [[:krc:User:PK2/sandbox|/sandbox]] in [[:en:Karachay-Balkar|Karachay-Balkar]]&lt;br /&gt;(code: &lt;code&gt;krc&lt;/code&gt;)
| [[:ks:User:PK2/sandbox|/sandbox]] in [[:en:Kashmiri language|Kashmiri]]&lt;br /&gt;(code: &lt;code&gt;ks&lt;/code&gt;)
| [[:ksh:User:PK2/sandbox|/sandbox]] in [[:en:Ripuarian language|Ripuarian]]&lt;br /&gt;(code: &lt;code&gt;ksh&lt;/code&gt;)
| [[:ku:User:PK2/ceribandin|/sandbox]] in [[:en:Kurdish language|Kurdish]] ([[:en:Kurmanji|Kurmanji]])&lt;br /&gt;(code: &lt;code&gt;ku&lt;/code&gt;)
| [[:kus:User:PK2/sandbox|/sandbox]] in [[:en:Kusaal language|Kusaal]]&lt;br /&gt;(code: &lt;code&gt;kus&lt;/code&gt;)
| [[:kv:User:PK2/sandbox|/sandbox]] in [[:en:Komi language|Komi]]&lt;br /&gt;(code: &lt;code&gt;kv&lt;/code&gt;)
| [[:kw:User:PK2/sandbox|/sandbox]] in [[:en:Cornish language|Cornish]]&lt;br /&gt;(code: &lt;code&gt;kw&lt;/code&gt;)
| [[:ky:User:PK2/sandbox|/sandbox]] in [[:en:Kyrgyz language|Kyrgyz]]&lt;br /&gt;(code: &lt;code&gt;ky&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ L
|-
| [[:la:User:PK2/Harenarium|/sandbox]] in [[:en:Latin|Latin]]&lt;br /&gt;(code: &lt;code&gt;la&lt;/code&gt;)
| [[:lad:User:PK2/Kutí de prova|/sandbox]] in [[:en:Judaeo-Spanish|Judaeo-Spanish]]&lt;br /&gt;(code: &lt;code&gt;lad&lt;/code&gt;)
| [[:lb:User:PK2/sandbox|/sandbox]] in [[:en:Luxembourgish|Luxembourgish]]&lt;br /&gt;(code: &lt;code&gt;lb&lt;/code&gt;)
| [[:lbe:User:PK2/sandbox|/sandbox]] in [[:en:Lak language|Lak]]&lt;br /&gt;(code: &lt;code&gt;lbe&lt;/code&gt;)
| [[:lez:User:PK2/sandbox|/sandbox]] in [[:en:Lezgian language|Lezgian]]&lt;br /&gt;(code: &lt;code&gt;lez&lt;/code&gt;)
| [[:lfn:User:PK2/sandbox|/sandbox]] in [[:en:Lingua Franca Nova|Lingua Franca Nova]]&lt;br /&gt;(code: &lt;code&gt;lfn&lt;/code&gt;)
| [[:lg:User:PK2/sandbox|/sandbox]] in [[:en:Luganda|Luganda]]&lt;br /&gt;(code: &lt;code&gt;lg&lt;/code&gt;)
| [[:li:User:PK2/sandbox|/sandbox]] in [[:en:Limburgish|Limburgish]]&lt;br /&gt;(code: &lt;code&gt;li&lt;/code&gt;)
|-
| [[:lij:User:PK2/sandbox|/sandbox]] in [[:en:Ligurian language|Ligurian]]&lt;br /&gt;(code: &lt;code&gt;lij&lt;/code&gt;)
| [[:lld:User:PK2/sandbox|/sandbox]] in [[:en:Ladin language|Ladin]]&lt;br /&gt;(code: &lt;code&gt;lld&lt;/code&gt;)
| [[:lmo:User:PK2/sandbox|/sandbox]] in [[:en:Lombard language|Lombard]]&lt;br /&gt;(code: &lt;code&gt;lmo&lt;/code&gt;)
| [[:ln:User:PK2/sandbox|/sandbox]] in [[:en:Lingala|Lingala]]&lt;br /&gt;(code: &lt;code&gt;ln&lt;/code&gt;)
| [[:lo:User:PK2/sandbox|/sandbox]] in [[:en:Lao language|Lao]]&lt;br /&gt;(code: &lt;code&gt;lo&lt;/code&gt;)
| [[:lt:User:PK2/juodraštis|/sandbox]] in [[:en:Lithuanian language|Lithuanian]]&lt;br /&gt;(code: &lt;code&gt;lt&lt;/code&gt;)
| [[:ltg:User:PK2/sandbox|/sandbox]] in [[:en:Latgalian language|Latgalian]]&lt;br /&gt;(code: &lt;code&gt;ltg&lt;/code&gt;)
| [[:lv:User:PK2/Smilšu kaste|/sandbox]] in [[:en:Latvian language|Latvian]]&lt;br /&gt;(code: &lt;code&gt;lv&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ M
|-
| [[:mad:User:PK2/sandbox|/sandbox]] in [[:en:Madurese language|Madurese]]&lt;br /&gt;(code: &lt;code&gt;mad&lt;/code&gt;)
| [[:mai:User:PK2/प्रयोगपृष्ठ|/sandbox]] in [[:en:Maithili language|Maithili]]&lt;br /&gt;(code: &lt;code&gt;mai&lt;/code&gt;)
| [[:map-bms:User:PK2/sandbox|/sandbox]] in [[:en:Javanese language|Javanese]] ([[:en:Banyumasan dialect|Banyumasan]])&lt;br /&gt;(code: &lt;code&gt;map-bms&lt;/code&gt;)
| [[:mdf:User:PK2/sandbox|/sandbox]] in [[:en:Moksha language|Moksha]]&lt;br /&gt;(code: &lt;code&gt;mdf&lt;/code&gt;)
| [[:mg:User:PK2/sandbox|/sandbox]] in [[:en:Malagasy language|Malagasy]]&lt;br /&gt;(code: &lt;code&gt;mg&lt;/code&gt;)
| [[:mhr:User:PK2/sandbox|/sandbox]] in [[:en:Meadow Mari language|Meadow Mari]]&lt;br /&gt;(code: &lt;code&gt;mhr&lt;/code&gt;)
| [[:mi:User:PK2/sandbox|/sandbox]] in [[:en:Māori language|Māori]]&lt;br /&gt;(code: &lt;code&gt;mi&lt;/code&gt;)
| [[:min:User:PK2/bak kasiak|/sandbox]] in [[:en:Minangkabau language|Minangkabau]]&lt;br /&gt;(code: &lt;code&gt;min&lt;/code&gt;)
| [[:mk:User:PK2/sandbox|/sandbox]] in [[:en:Macedonian language|Macedonian]]&lt;br /&gt;(code: &lt;code&gt;mk&lt;/code&gt;)
| [[:ml:User:PK2/sandbox|/sandbox]] in [[:en:Malayalam|Malayalam]]&lt;br /&gt;(code: &lt;code&gt;ml&lt;/code&gt;)
| [[:mn:User:PK2/sandbox|/sandbox]] in [[:en:Mongolian language|Mongolian]]&lt;br /&gt;(code: &lt;code&gt;mn&lt;/code&gt;)
|-
| [[:mni:User:PK2/sandbox|/sandbox]] in [[:en:Meitei language|Meitei]]&lt;br /&gt;(code: &lt;code&gt;mni&lt;/code&gt;)
| [[:mnw:User:PK2/sandbox|/sandbox]] in [[:en:Mon language|Mon]]&lt;br /&gt;(code: &lt;code&gt;mnw&lt;/code&gt;)
| [[:m:mos:User:PK2/sandbox|/sandbox]] in [[:en:Mooré|Mooré]]&lt;br /&gt;(code: &lt;code&gt;mos&lt;/code&gt;)
| [[:mr:User:PK2/sandbox|/sandbox]] in [[:en:Marathi language|Marathi]]&lt;br /&gt;(code: &lt;code&gt;mr&lt;/code&gt;)
| [[:mrj:User:PK2/sandbox|/sandbox]] in [[:en:Hill Mari language|Hill Mari]]&lt;br /&gt;(code: &lt;code&gt;mrj&lt;/code&gt;)
| [[:ms:User:PK2/Kotak pasir|/sandbox]] in [[:en:Malay language|Malay]]&lt;br /&gt;(code: &lt;code&gt;ms&lt;/code&gt;)
| [[:mt:User:PK2/sandbox|/sandbox]] in [[:en:Maltese language|Maltese]]&lt;br /&gt;(code: &lt;code&gt;mt&lt;/code&gt;)
| [[:mwl:User:PK2/Testes|/sandbox]] in [[:en:Mirandese language|Mirandese]]&lt;br /&gt;(code: &lt;code&gt;mwl&lt;/code&gt;)
| [[:my:User:PK2/sandbox|/sandbox]] in [[:en:Burmese language|Burmese]]&lt;br /&gt;(code: &lt;code&gt;my&lt;/code&gt;)
| [[:myv:User:PK2/sandbox|/sandbox]] in [[:en:Erzya language|Erzya]]&lt;br /&gt;(code: &lt;code&gt;myv&lt;/code&gt;)
| [[:mzn:User:PK2/sandbox|/sandbox]] in [[:en:Mazanderani language|Mazanderani]]&lt;br /&gt;(code: &lt;code&gt;mzn&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ N
|-
| [[:nah:User:PK2/sandbox|/sandbox]] in [[:en:Nahuatl|Nahuatl]]&lt;br /&gt;(code: &lt;code&gt;nah&lt;/code&gt;)
| [[:nap:User:PK2/sandbox|/sandbox]] in [[:en:Neapolitan language|Neapolitan]]&lt;br /&gt;(code: &lt;code&gt;nap&lt;/code&gt;)
| [[:nds:User:PK2/sandbox|/sandbox]] in [[:en:Low German|Low German]]&lt;br /&gt;(code: &lt;code&gt;nds&lt;/code&gt;)
| [[:nds-nl:User:PK2/sandbox|/sandbox]] in [[:en:Dutch Low Saxon|Dutch Low Saxon]]&lt;br /&gt;(code: &lt;code&gt;nds-nl&lt;/code&gt;)
| [[:ne:User:PK2/प्रयोगस्थल|/sandbox]] in [[:en:Nepali language|Nepali]]&lt;br /&gt;(code: &lt;code&gt;ne&lt;/code&gt;)
| [[:new:User:PK2/sandbox|/sandbox]] in [[:en:Newar language|Newar]]&lt;br /&gt;(code: &lt;code&gt;new&lt;/code&gt;)
| [[:nia:User:PK2/sandbox|/sandbox]] in [[:en:Nias language|Nias]]&lt;br /&gt;(code: &lt;code&gt;nia&lt;/code&gt;)
| [[:nl:User:PK2/Kladblok|/sandbox]] in [[:en:Dutch language|Dutch]]&lt;br /&gt;(code: &lt;code&gt;nl&lt;/code&gt;)
| [[:nn:User:PK2/sandkasse|/sandbox]] in [[:en:Norwegian language|Norwegian]] ([[:en:Nynorsk|Nynorsk]])&lt;br /&gt;(code: &lt;code&gt;nn&lt;/code&gt;)
|-
| [[:no:User:PK2/sandkasse|/sandbox]] in [[:en:Norwegian language|Norwegian]] ([[:en:Bokmål|Bokmål]])&lt;br /&gt;(code: &lt;code&gt;no&lt;/code&gt;)
| [[:nov:User:PK2/sandbox|/sandbox]] in [[:en:Novial|Novial]]&lt;br /&gt;(code: &lt;code&gt;nov&lt;/code&gt;)
| [[:nqo:User:PK2/sandbox|/sandbox]] in [[:en:N'Ko language|N'Ko]]&lt;br /&gt;(code: &lt;code&gt;nqo&lt;/code&gt;)
| [[:nr:User:PK2/sandbox|/sandbox]] in [[:en:Southern Ndebele language|Southern Ndebele]]&lt;br /&gt;(code: &lt;code&gt;nr&lt;/code&gt;)
| [[:nrm:User:PK2/sandbox|/sandbox]] in [[:en:Norman language|Norman]]&lt;br /&gt;(code: &lt;code&gt;nrm&lt;/code&gt;)
| [[:nso:User:PK2/sandbox|/sandbox]] in [[:en:Northern Sotho|Northern Sotho]]&lt;br /&gt;(code: &lt;code&gt;nso&lt;/code&gt;)
| [[:nup:User:PK2/sandbox|/sandbox]] in [[:en:Nupe language|Nupe]]&lt;br /&gt;(code: &lt;code&gt;nup&lt;/code&gt;)
| [[:nv:User:PK2/sandbox|/sandbox]] in [[:en:Navajo language|Navajo]]&lt;br /&gt;(code: &lt;code&gt;nv&lt;/code&gt;)
| [[:ny:User:PK2/sandbox|/sandbox]] in [[:en:Chewa language|Chewa]]&lt;br /&gt;(code: &lt;code&gt;ny&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ O
|-
| [[:oc:User:PK2/sandbox|/sandbox]] in [[:en:Occitan language|Occitan]]&lt;br /&gt;(code: &lt;code&gt;oc&lt;/code&gt;)
| [[:olo:User:PK2/sandbox|/sandbox]] in [[:en:Livvi-Karelian language|Livvi-Karelian]]&lt;br /&gt;(code: &lt;code&gt;olo&lt;/code&gt;)
| [[:om:User:PK2/sandbox|/sandbox]] in [[:en:Oromo language|Oromo]]&lt;br /&gt;(code: &lt;code&gt;om&lt;/code&gt;)
| [[:or:User:PK2/ପରଖଘର|/sandbox]] in [[:en:Odia language|Odia]]&lt;br /&gt;(code: &lt;code&gt;or&lt;/code&gt;)
| [[:os:User:PK2/sandbox|/sandbox]] in [[:en:Ossetian language|Ossetian]]&lt;br /&gt;(code: &lt;code&gt;os&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ P
|-
| [[:pa:User:PK2/ਕੱਚਾ ਖ਼ਾਕਾ|/sandbox]] in [[:en:Punjabi language|Punjabi]]&lt;br /&gt;(code: &lt;code&gt;pa&lt;/code&gt;)
| [[:pag:User:PK2/sandbox|/sandbox]] in [[:en:Pangasinan language|Pangasinan]]&lt;br /&gt;(code: &lt;code&gt;pag&lt;/code&gt;)
| [[:pam:User:PK2/sandbox|/sandbox]] in [[:en:Kapampangan language|Kapampangan]]&lt;br /&gt;(code: &lt;code&gt;pam&lt;/code&gt;)
| [[:pap:User:PK2/sandbox|/sandbox]] in [[:en:Papiamento|Papiamento]]&lt;br /&gt;(code: &lt;code&gt;pap&lt;/code&gt;)
| [[:pcd:User:PK2/sandbox|/sandbox]] in [[:en:Picard language|Picard]]&lt;br /&gt;(code: &lt;code&gt;pcd&lt;/code&gt;)
| [[:pcm:User:PK2/sandbox|/sandbox]] in [[:en:Nigerian Pidgin|Nigerian Pidgin]]&lt;br /&gt;(code: &lt;code&gt;pcm&lt;/code&gt;)
| [[:pdc:User:PK2/sandbox|/sandbox]] in [[:en:Pennsylvania Dutch language|Pennsylvania Dutch]]&lt;br /&gt;(code: &lt;code&gt;pdc&lt;/code&gt;)
| [[:pfl:User:PK2/sandbox|/sandbox]] in [[:en:Palatine German dialects|Palatine German]]&lt;br /&gt;(code: &lt;code&gt;pfl&lt;/code&gt;)
|-
| [[:pi:User:PK2/sandbox|/sandbox]] in [[:en:Pali|Pali]]&lt;br /&gt;(code: &lt;code&gt;pi&lt;/code&gt;)
| [[:pl:User:PK2/brudnopis|/sandbox]] in [[:en:Polish language|Polish]]&lt;br /&gt;(code: &lt;code&gt;pl&lt;/code&gt;)
| [[:pms:User:PK2/sandbox|/sandbox]] in [[:en:Piedmontese language|Piedmontese]]&lt;br /&gt;(code: &lt;code&gt;pms&lt;/code&gt;)
| [[:pnb:User:PK2/sandbox|/sandbox]] in [[:en:Punjabi language|Punjabi]] (Western Punjabi)&lt;br /&gt;(code: &lt;code&gt;pnb&lt;/code&gt;)
| [[:pnt:User:PK2/sandbox|/sandbox]] in [[:en:Pontic Greek|Pontic Greek]]&lt;br /&gt;(code: &lt;code&gt;pnt&lt;/code&gt;)
| [[:ps:User:PK2/ازمون‌مخ|/sandbox]] in [[:en:Pashto|Pashto]]&lt;br /&gt;(code: &lt;code&gt;ps&lt;/code&gt;)
| [[:pt:User:PK2/Testes|/sandbox]] in [[:en:Portuguese language|Portuguese]]&lt;br /&gt;(code: &lt;code&gt;pt&lt;/code&gt;)
| [[:pwn:User:PK2/sandbox|/sandbox]] in [[:en:Paiwan language|Paiwan]]&lt;br /&gt;(code: &lt;code&gt;pwn&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ Q
|-
| [[:qu:User:PK2/sandbox|/sandbox]] in [[:en:Quechuan languages|Quechua]] ([[:en:Southern Quechua|Southern Quechua]])&lt;br /&gt;(code: &lt;code&gt;qu&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ R
|-
| [[:rki:User:PK2/sandbox|/sandbox]] in [[:en:Rakhine language|Rakhine]]&lt;br /&gt;(code: &lt;code&gt;rki&lt;/code&gt;)
| [[:rm:User:PK2/sandbox|/sandbox]] in [[:en:Romansh language|Romansh]]&lt;br /&gt;(code: &lt;code&gt;rm&lt;/code&gt;)
| [[:rmy:User:PK2/sandbox|/sandbox]] in [[:en:Romani language|Romani]] ([[:en:Vlax Romani language|Vlax Romani]])&lt;br /&gt;(code: &lt;code&gt;rmy&lt;/code&gt;)
| [[:rn:User:PK2/sandbox|/sandbox]] in [[:en:Kirundi|Kirundi]]&lt;br /&gt;(code: &lt;code&gt;rn&lt;/code&gt;)
| [[:ro:User:PK2/teste|/sandbox]] in [[:en:Romanian language|Romanian]]&lt;br /&gt;(code: &lt;code&gt;ro&lt;/code&gt;)
| [[:roa-rup:User:PK2/sandbox|/sandbox]] in [[:en:Aromanian language|Aromanian]]&lt;br /&gt;(code: &lt;code&gt;roa-rup&lt;/code&gt;)
| [[:roa-tara:User:PK2/sandbox|/sandbox]] in [[:en:Neapolitan language|Neapolitan]] ([[:en:Tarantino dialect|Tarantino]])&lt;br /&gt;(code: &lt;code&gt;roa-tara&lt;/code&gt;)
| [[:rsk:User:PK2/sandbox|/sandbox]] in [[:en:Pannonian Rusyn|Pannonian Rusyn]]&lt;br /&gt;(code: &lt;code&gt;rsk&lt;/code&gt;)
| [[:ru:User:PK2/Черновик|/sandbox]] in [[:en:Russian language|Russian]]&lt;br /&gt;(code: &lt;code&gt;ru&lt;/code&gt;)
| [[:rue:User:PK2/sandbox|/sandbox]] in [[:en:Rusyn language|Rusyn]]&lt;br /&gt;(code: &lt;code&gt;rue&lt;/code&gt;)
| [[:rw:User:PK2/sandbox|/sandbox]] in [[:en:Kinyarwanda|Kinyarwanda]]&lt;br /&gt;(code: &lt;code&gt;rw&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ S
|-
| [[:sa:User:PK2/प्रयोगपृष्ठम्|/sandbox]] in [[:en:Sanskrit|Sanskrit]]&lt;br /&gt;(code: &lt;code&gt;sa&lt;/code&gt;)
| [[:sah:User:PK2/sandbox|/sandbox]] in [[:en:Yakut language|Yakut]]&lt;br /&gt;(code: &lt;code&gt;sah&lt;/code&gt;)
| [[:sat:User:PK2/sandbox|/sandbox]] in [[:en:Santali language|Santali]]&lt;br /&gt;(code: &lt;code&gt;sat&lt;/code&gt;)
| [[:sc:User:PK2/sandbox|/sandbox]] in [[:en:Sardinian language|Sardinian]]&lt;br /&gt;(code: &lt;code&gt;sc&lt;/code&gt;)
| [[:scn:User:PK2/sandbox|/sandbox]] in [[:en:Sicilian language|Sicilian]]&lt;br /&gt;(code: &lt;code&gt;scn&lt;/code&gt;)
| [[:sco:User:PK2/sandbox|/sandbox]] in [[:en:Scots language|Scots]]&lt;br /&gt;(code: &lt;code&gt;sco&lt;/code&gt;)
| [[:sd:User:PK2/مشق پٽي|/sandbox]] in [[:en:Sindhi language|Sindhi]]&lt;br /&gt;(code: &lt;code&gt;sd&lt;/code&gt;)
| [[:se:User:PK2/sandbox|/sandbox]] in [[:en:Northern Sámi|Northern Sámi]]&lt;br /&gt;(code: &lt;code&gt;se&lt;/code&gt;)
| [[:sg:User:PK2/sandbox|/sandbox]] in [[:en:Sango language|Sango]]&lt;br /&gt;(code: &lt;code&gt;sg&lt;/code&gt;)
| [[:sh:User:PK2/igralište|/sandbox]] in [[:en:Serbo-Croatian|Serbo-Croatian]]&lt;br /&gt;(code: &lt;code&gt;sh&lt;/code&gt;)
| [[:shi:User:PK2/sandbox|/sandbox]] in [[:en:Shilha language|Shilha]]&lt;br /&gt;(code: &lt;code&gt;shi&lt;/code&gt;)
|-
| [[:shn:User:PK2/sandbox|/sandbox]] in [[:en:Shan language|Shan]]&lt;br /&gt;(code: &lt;code&gt;shn&lt;/code&gt;)
| [[:si:User:PK2/sandbox|/sandbox]] in [[:en:Sinhala language|Sinhala]]&lt;br /&gt;(code: &lt;code&gt;si&lt;/code&gt;)
| [[:simple:User:PK2/sandbox|/sandbox]] in [[:en:Basic English|Basic English]]&lt;br /&gt;(code: &lt;code&gt;simple&lt;/code&gt;)
| [[:sk:User:PK2/pieskovisko|/sandbox]] in [[:en:Slovak language|Slovak]]&lt;br /&gt;(code: &lt;code&gt;sk&lt;/code&gt;)
| [[:skr:User:PK2/sandbox|/sandbox]] in [[:en:Saraiki language|Saraiki]]&lt;br /&gt;(code: &lt;code&gt;skr&lt;/code&gt;)
| [[:sl:User:PK2/sandbox|/sandbox]] in [[:en:Slovene language|Slovene]]&lt;br /&gt;(code: &lt;code&gt;sl&lt;/code&gt;)
| [[:sm:User:PK2/sandbox|/sandbox]] in [[:en:Samoan language|Samoan]]&lt;br /&gt;(code: &lt;code&gt;sm&lt;/code&gt;)
| [[:smn:User:PK2/sandbox|/sandbox]] in [[:en:Inari Sámi language|Inari Sámi]]&lt;br /&gt;(code: &lt;code&gt;smn&lt;/code&gt;)
| [[:sn:User:PK2/sandbox|/sandbox]] in [[:en:Shona language|Shona]]&lt;br /&gt;(code: &lt;code&gt;sn&lt;/code&gt;)
| [[:so:User:PK2/Bacaadka|/sandbox]] in [[:en:Somali language|Somali]]&lt;br /&gt;(code: &lt;code&gt;so&lt;/code&gt;)
| [[:sq:User:PK2/sandbox|/sandbox]] in [[:en:Albanian language|Albanian]]&lt;br /&gt;(code: &lt;code&gt;sq&lt;/code&gt;)
|-
| [[:sr:User:PK2/песак|/sandbox]] in [[:en:Serbian language|Serbian]]&lt;br /&gt;(code: &lt;code&gt;sr&lt;/code&gt;)
| [[:srn:User:PK2/sandbox|/sandbox]] in [[:en:Sranan Tongo|Sranan Tongo]]&lt;br /&gt;(code: &lt;code&gt;srn&lt;/code&gt;)
| [[:ss:User:PK2/sandbox|/sandbox]] in [[:en:Swazi language|Swazi]]&lt;br /&gt;(code: &lt;code&gt;ss&lt;/code&gt;)
| [[:st:User:PK2/sandbox|/sandbox]] in [[:en:Sotho language|Sotho]]&lt;br /&gt;(code: &lt;code&gt;st&lt;/code&gt;)
| [[:stq:User:PK2/sandbox|/sandbox]] in [[:en:Saterland Frisian language|Saterland Frisian]]&lt;br /&gt;(code: &lt;code&gt;stq&lt;/code&gt;)
| [[:su:User:PK2/sandbox|/sandbox]] in [[:en:Sundanese language|Sundanese]]&lt;br /&gt;(code: &lt;code&gt;su&lt;/code&gt;)
| [[:sv:User:PK2/sandlåda|/sandbox]] in [[:en:Swedish language|Swedish]]&lt;br /&gt;(code: &lt;code&gt;sv&lt;/code&gt;)
| [[:sw:User:PK2/ukurasa wa majaribio|/sandbox]] in [[:en:Swahili language|Swahili]]&lt;br /&gt;(code: &lt;code&gt;sw&lt;/code&gt;)
| [[:syl:User:PK2/sandbox|/sandbox]] in [[:en:Sylheti language|Sylheti]]&lt;br /&gt;(code: &lt;code&gt;syl&lt;/code&gt;)
| [[:szl:User:PK2/sandbox|/sandbox]] in [[:en:Silesian language|Silesian]]&lt;br /&gt;(code: &lt;code&gt;szl&lt;/code&gt;)
| [[:szy:User:PK2/sandbox|/sandbox]] in [[:en:Sakizaya language|Sakizaya]]&lt;br /&gt;(code: &lt;code&gt;szy&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ T
|-
| [[:ta:User:PK2/மணல்தொட்டி|/sandbox]] in [[:en:Tamil language|Tamil]]&lt;br /&gt;(code: &lt;code&gt;ta&lt;/code&gt;)
| [[:tay:User:PK2/sandbox|/sandbox]] in [[:en:Atayal language|Atayal]]&lt;br /&gt;(code: &lt;code&gt;tay&lt;/code&gt;)
| [[:tcy:User:PK2/ಕಲ್ಪುನ ಕಳ|/sandbox]] in [[:en:Tulu language|Tulu]]&lt;br /&gt;(code: &lt;code&gt;tcy&lt;/code&gt;)
| [[:tdd:User:PK2/sandbox|/sandbox]] in [[:en:Tai Nuea language|Tai Nuea]]&lt;br /&gt;(code: &lt;code&gt;tdd&lt;/code&gt;)
| [[:te:User:PK2/ప్రయోగశాల|/sandbox]] in [[:en:Telugu language|Telugu]]&lt;br /&gt;(code: &lt;code&gt;te&lt;/code&gt;)
| [[:tet:User:PK2/sandbox|/sandbox]] in [[:en:Tetum language|Tetum]]&lt;br /&gt;(code: &lt;code&gt;tet&lt;/code&gt;)
| [[:tg:User:PK2/Сиёҳнавис|/sandbox]] in [[:en:Tajik language|Tajik]]&lt;br /&gt;(code: &lt;code&gt;tg&lt;/code&gt;)
| [[:th:User:PK2/ทดลองเขียน|/sandbox]] in [[:en:Thai language|Thai]]&lt;br /&gt;(code: &lt;code&gt;th&lt;/code&gt;)
| [[:ti:User:PK2/sandbox|/sandbox]] in [[:en:Tigrinya language|Tigrinya]]&lt;br /&gt;(code: &lt;code&gt;ti&lt;/code&gt;)
| [[:tig:User:PK2/sandbox|/sandbox]] in [[:en:Tigre language|Tigre]]&lt;br /&gt;(code: &lt;code&gt;tig&lt;/code&gt;)
| [[:tk:User:PK2/sandbox|/sandbox]] in [[:en:Turkmen language|Turkmen]]&lt;br /&gt;(code: &lt;code&gt;tk&lt;/code&gt;)
| [[:tl:User:PK2/burador|/sandbox]] in [[:en:Tagalog language|Tagalog]]&lt;br /&gt;(code: &lt;code&gt;tl&lt;/code&gt;)
| [[:tly:User:PK2/sandbox|/sandbox]] in [[:en:Talysh language|Talysh]]&lt;br /&gt;(code: &lt;code&gt;tly&lt;/code&gt;)
|-
| [[:tn:User:PK2/sandbox|/sandbox]] in [[:en:Tswana language|Tswana]]&lt;br /&gt;(code: &lt;code&gt;tn&lt;/code&gt;)
| [[:to:User:PK2/sandbox|/sandbox]] in [[:en:Tongan language|Tongan]]&lt;br /&gt;(code: &lt;code&gt;to&lt;/code&gt;)
| [[:tok:User:PK2/sandbox|/sandbox]] in [[:en:Toki Pona|Toki Pona]]&lt;br /&gt;(code: &lt;code&gt;tok&lt;/code&gt;)
| [[:tpi:User:PK2/sandbox|/sandbox]] in [[:en:Tok Pisin|Tok Pisin]]&lt;br /&gt;(code: &lt;code&gt;tpi&lt;/code&gt;)
| [[:tr:User:PK2/deneme tahtası|/sandbox]] in [[:en:Turkish language|Turkish]]&lt;br /&gt;(code: &lt;code&gt;tr&lt;/code&gt;)
| [[:trv:User:PK2/sandbox|/sandbox]] in [[:en:Seediq language|Seediq]]&lt;br /&gt;(code: &lt;code&gt;trv&lt;/code&gt;)
| [[:ts:User:PK2/sandbox|/sandbox]] in [[:en:Tsonga language|Tsonga]]&lt;br /&gt;(code: &lt;code&gt;ts&lt;/code&gt;)
| [[:tt:User:PK2/sandbox|/sandbox]] in [[:en:Tatar language|Tatar]]&lt;br /&gt;(code: &lt;code&gt;tt&lt;/code&gt;)
| [[:tum:User:PK2/sandbox|/sandbox]] in [[:en:Tumbuka language|Tumbuka]]&lt;br /&gt;(code: &lt;code&gt;tum&lt;/code&gt;)
| [[:tw:User:PK2/sandbox|/sandbox]] in [[:en:Akan language|Akan]] (Twi)&lt;br /&gt;(code: &lt;code&gt;tw&lt;/code&gt;)
| [[:ty:User:PK2/sandbox|/sandbox]] in [[:en:Tahitian language|Tahitian]]&lt;br /&gt;(code: &lt;code&gt;ty&lt;/code&gt;)
| [[:tyv:User:PK2/sandbox|/sandbox]] in [[:en:Tuvan language|Tuvan]]&lt;br /&gt;(code: &lt;code&gt;tyv&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ U
|-
| [[:udm:User:PK2/sandbox|/sandbox]] in [[:en:Udmurt language|Udmurt]]&lt;br /&gt;(code: &lt;code&gt;udm&lt;/code&gt;)
| [[:ug:User:PK2/sandbox|/sandbox]] in [[:en:Uyghur language|Uyghur]]&lt;br /&gt;(code: &lt;code&gt;ug&lt;/code&gt;)
| [[:uk:User:PK2/Чернетка|/sandbox]] in [[:en:Ukrainian language|Ukrainian]]&lt;br /&gt;(code: &lt;code&gt;uk&lt;/code&gt;)
| [[:ur:User:PK2/تختۂ مشق|/sandbox]] in [[:en:Urdu|Urdu]]&lt;br /&gt;(code: &lt;code&gt;ur&lt;/code&gt;)
| [[:uz:User:PK2/qumloq|/sandbox]] in [[:en:Uzbek language|Uzbek]]&lt;br /&gt;(code: &lt;code&gt;uz&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ V
|-
| [[:ve:User:PK2/sandbox|/sandbox]] in [[:en:Venda language|Venda]]&lt;br /&gt;(code: &lt;code&gt;ve&lt;/code&gt;)
| [[:vec:User:PK2/sandbox|/sandbox]] in [[:en:Venetian language|Venetian]]&lt;br /&gt;(code: &lt;code&gt;vec&lt;/code&gt;)
| [[:vep:User:PK2/sandbox|/sandbox]] in [[:en:Veps language|Veps]]&lt;br /&gt;(code: &lt;code&gt;vep&lt;/code&gt;)
| [[:vi:User:PK2/nháp|/sandbox]] in [[:en:Vietnamese language|Vietnamese]]&lt;br /&gt;(code: &lt;code&gt;vi&lt;/code&gt;)
| [[:vls:User:PK2/sandbox|/sandbox]] in [[:en:West Flemish|West Flemish]]&lt;br /&gt;(code: &lt;code&gt;vls&lt;/code&gt;)
| [[:vo:User:PK2/sandbox|/sandbox]] in [[:en:Volapük|Volapük]]&lt;br /&gt;(code: &lt;code&gt;vo&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ W
|-
| [[:wa:User:PK2/sandbox|/sandbox]] in [[:en:Walloon language|Walloon]]&lt;br /&gt;(code: &lt;code&gt;wa&lt;/code&gt;)
| [[:war:User:PK2/sandbox|/sandbox]] in [[:en:Waray language|Waray]]&lt;br /&gt;(code: &lt;code&gt;war&lt;/code&gt;)
| [[:wo:User:PK2/sandbox|/sandbox]] in [[:en:Wolof language|Wolof]]&lt;br /&gt;(code: &lt;code&gt;wo&lt;/code&gt;)
| [[:wuu:User:PK2/sandbox|/sandbox]] in [[:en:Wu Chinese|Wu Chinese]]&lt;br /&gt;(code: &lt;code&gt;wuu&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ X
|-
| [[:xal:User:PK2/sandbox|/sandbox]] in [[:en:Oirat language|Oirat]] ([[:en:Kalmyk Oirat|Kalmyk Oirat]])&lt;br /&gt;(code: &lt;code&gt;xal&lt;/code&gt;)
| [[:xh:User:PK2/sandbox|/sandbox]] in [[:en:Xhosa language|Xhosa]]&lt;br /&gt;(code: &lt;code&gt;xh&lt;/code&gt;)
| [[:xmf:User:PK2/sandbox|/sandbox]] in [[:en:Mingrelian language|Mingrelian]]&lt;br /&gt;(code: &lt;code&gt;xmf&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ Y
|-
| [[:yi:User:PK2/sandbox|/sandbox]] in [[:en:Yiddish|Yiddish]]&lt;br /&gt;(code: &lt;code&gt;yi&lt;/code&gt;)
| [[:yo:User:PK2/sandbox|/sandbox]] in [[:en:Yoruba language|Yoruba]]&lt;br /&gt;(code: &lt;code&gt;yo&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ Z
|-
| [[:za:User:PK2/sandbox|/sandbox]] in [[:en:Zhuang languages|Zhuang]] ([[:en:Standard Zhuang|Standard Zhuang]])&lt;br /&gt;(code: &lt;code&gt;za&lt;/code&gt;)
| [[:zea:User:PK2/sandbox|/sandbox]] in [[:en:Zeelandic|Zeelandic]]&lt;br /&gt;(code: &lt;code&gt;zea&lt;/code&gt;)
| [[:zgh:User:PK2/sandbox|/sandbox]] in [[:en:Standard Moroccan Amazigh|Standard Moroccan Amazigh]]&lt;br /&gt;(code: &lt;code&gt;zgh&lt;/code&gt;)
| [[:zh:User:PK2/沙盒|/sandbox]] in [[:en:Chinese language|Chinese]] ([[:en:Mandarin Chinese|Mandarin Chinese]])&lt;br /&gt;(code: &lt;code&gt;zh&lt;/code&gt;)
| [[:zh-classical:User:PK2/sandbox|/sandbox]] in [[:en:Classical Chinese|Classical Chinese]]&lt;br /&gt;(code: &lt;code&gt;zh-classical&lt;/code&gt;)
| [[:zh-min-nan:User:PK2/sandbox|/sandbox]] in [[:en:Southern Min|Southern Min]]&lt;br /&gt;(code: &lt;code&gt;zh-min-nan&lt;/code&gt;)
| [[:zh-yue:User:PK2/sandbox|/sandbox]] in [[:en:Cantonese|Cantonese]]&lt;br /&gt;(code: &lt;code&gt;zh-yue&lt;/code&gt;)
| [[:zu:User:PK2/sandbox|/sandbox]] in [[:en:Zulu language|Zulu]]&lt;br /&gt;(code: &lt;code&gt;zu&lt;/code&gt;)
|}</text>
      <sha1>t2l1a7nkzod46d48sdyni99uegclq1l</sha1>
    </revision>
    <revision>
      <id>6666</id>
      <parentid>6104</parentid>
      <timestamp>2026-06-02T02:19:00Z</timestamp>
      <contributor>
        <username>PK2</username>
        <id>303</id>
      </contributor>
      <minor />
      <comment>add sandbox pages for new Wikipedia editions</comment>
      <origin>6666</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="38826" sha1="lqv4jf4ytbpqgk0b4c59pskg40l4i1p" xml:space="preserve">{| class=&quot;wikitable&quot; style=&quot;font-size:85%&quot;
|+ Pages I have in my sandbox
|-
| &amp;nbsp;
|}

;&lt;div class=&quot;center&quot; style=&quot;width:auto; margin-left:auto; margin-right:auto; font-size:85%&quot;&gt;My sandbox pages in different languages by language code&lt;/div&gt;
{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ A
|-
| [[:ab:User:PK2/sandbox|/sandbox]] in [[:en:Abkhaz language|Abkhaz]]&lt;br /&gt;(code: &lt;code&gt;ab&lt;/code&gt;)
| [[:ace:User:PK2/sandbox|/sandbox]] in [[:en:Acehnese language|Acehnese]]&lt;br /&gt;(code: &lt;code&gt;ace&lt;/code&gt;)
| [[:ady:User:PK2/sandbox|/sandbox]] in [[:en:Adyghe language|Adyghe]]&lt;br /&gt;(code: &lt;code&gt;ady&lt;/code&gt;)
| [[:af:User:PK2/sandbox|/sandbox]] in [[:en:Afrikaans|Afrikaans]]&lt;br /&gt;(code: &lt;code&gt;af&lt;/code&gt;)
| [[:als:User:PK2/sandbox|/sandbox]] in [[:en:Alemannic German|Alemannic German]]&lt;br /&gt;(code: &lt;code&gt;als&lt;/code&gt;)
| [[:alt:User:PK2/sandbox|/sandbox]] in [[:en:Southern Altai language|Southern Altai]]&lt;br /&gt;(code: &lt;code&gt;alt&lt;/code&gt;)
| [[:am:User:PK2/sandbox|/sandbox]] in [[:en:Amharic|Amharic]]&lt;br /&gt;(code: &lt;code&gt;am&lt;/code&gt;)
| [[:ami:User:PK2/sandbox|/sandbox]] in [[:en:Amis language|Amis]]&lt;br /&gt;(code: &lt;code&gt;ami&lt;/code&gt;)
| [[:an:User:PK2/sandbox|/sandbox]] in [[:en:Aragonese language|Aragonese]]&lt;br /&gt;(code: &lt;code&gt;an&lt;/code&gt;)
| [[:ang:User:PK2/sandbox|/sandbox]] in [[:en:Old English|Old English]]&lt;br /&gt;(code: &lt;code&gt;ang&lt;/code&gt;)
|-
| [[:ann:User:PK2/sandbox|/sandbox]] in [[:en:Obolo language|Obolo]]&lt;br /&gt;(code: &lt;code&gt;ann&lt;/code&gt;)
| [[:anp:User:PK2/sandbox|/sandbox]] in [[:en:Angika|Angika]]&lt;br /&gt;(code: &lt;code&gt;anp&lt;/code&gt;)
| [[:ar:User:PK2/ملعب|/sandbox]] in [[:en:Arabic|Arabic]]&lt;br /&gt;(code: &lt;code&gt;ar&lt;/code&gt;)
| [[:arc:User:PK2/sandbox|/sandbox]] in [[:en:Aramaic|Aramaic]] ([[:en:Syriac language|Syriac]])&lt;br /&gt;(code: &lt;code&gt;arc&lt;/code&gt;)
| [[:ary:User:PK2/sandbox|/sandbox]] in [[:en:Moroccan Arabic|Moroccan Arabic]]&lt;br /&gt;(code: &lt;code&gt;ary&lt;/code&gt;)
| [[:arz:User:PK2/sandbox|/sandbox]] in [[:en:Egyptian Arabic|Egyptian Arabic]]&lt;br /&gt;(code: &lt;code&gt;arz&lt;/code&gt;)
| [[:as:User:PK2/sandbox|/sandbox]] in [[:en:Assamese language|Assamese]]&lt;br /&gt;(code: &lt;code&gt;as&lt;/code&gt;)
| [[:ast:User:PK2/sandbox|/sandbox]] in [[:en:Asturleonese language|Asturleonese]] ([[:en:Asturian language|Asturian]])&lt;br /&gt;(code: &lt;code&gt;ast&lt;/code&gt;)
| [[:atj:User:PK2/Kokwetcitasinahikan|/sandbox]] in [[:en:Atikamekw language|Atikamekw]]&lt;br /&gt;(code: &lt;code&gt;atj&lt;/code&gt;)
| [[:av:User:PK2/sandbox|/sandbox]] in [[:en:Avar language|Avar]]&lt;br /&gt;(code: &lt;code&gt;av&lt;/code&gt;)
|-
| [[:avk:User:PK2/sandbox|/sandbox]] in [[:en:Kotava|Kotava]]&lt;br /&gt;(code: &lt;code&gt;avk&lt;/code&gt;)
| [[:awa:User:PK2/sandbox|/sandbox]] in [[:en:Awadhi language|Awadhi]]&lt;br /&gt;(code: &lt;code&gt;awa&lt;/code&gt;)
| [[:ay:User:PK2/sandbox|/sandbox]] in [[:en:Aymara language|Aymara]]&lt;br /&gt;(code: &lt;code&gt;ay&lt;/code&gt;)
| [[:az:User:PK2/Qaralama|/sandbox]] in [[:en:Azerbaijani language|Azerbaijani]]&lt;br /&gt;(code: &lt;code&gt;az&lt;/code&gt;)
| [[:azb:User:PK2/sandbox|/sandbox]] in [[:en:Azerbaijani language#South Azerbaijani|South Azerbaijani]]&lt;br /&gt;(code: &lt;code&gt;azb&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ B
|-
| [[:ba:User:PK2/sandbox|/sandbox]] in [[:en:Bashkir language|Bashkir]]&lt;br /&gt;(code: &lt;code&gt;ba&lt;/code&gt;)
| [[:ban:User:PK2/sandbox|/sandbox]] in [[:en:Balinese language|Balinese]]&lt;br /&gt;(code: &lt;code&gt;ban&lt;/code&gt;)
| [[:bar:User:PK2/sandbox|/sandbox]] in [[:en:Bavarian language|Bavarian]]&lt;br /&gt;(code: &lt;code&gt;bar&lt;/code&gt;)
| [[:bat-smg:User:PK2/sandbox|/sandbox]] in [[:en:Samogitian language|Samogitian]]&lt;br /&gt;(code: &lt;code&gt;bat-smg&lt;/code&gt;)
| [[:bbc:User:PK2/sandbox|/sandbox]] in [[:en:Toba Batak language|Toba Batak]]&lt;br /&gt;(code: &lt;code&gt;bbc&lt;/code&gt;)
| [[:bcl:User:PK2/sandbox|/sandbox]] in [[:en:Central Bikol|Central Bikol]]&lt;br /&gt;(code: &lt;code&gt;bcl&lt;/code&gt;)
| [[:bdr:User:PK2/sandbox|/sandbox]] in [[:en:Sama–Bajaw languages|West Coast Bajau]]&lt;br /&gt;(code: &lt;code&gt;bdr&lt;/code&gt;)
| [[:be:User:PK2/sandbox|/sandbox]] in [[:en:Belarusian language|Belarusian]]&lt;br /&gt;(code: &lt;code&gt;be&lt;/code&gt;)
| [[:be-tarask:User:PK2/sandbox|/sandbox]] in [[:en:Belarusian language|Belarusian]] ([[:en:Taraškievica|Taraškievica]])&lt;br /&gt;(code: &lt;code&gt;be-tarask&lt;/code&gt;)
| [[:bew:User:PK2/sandbox|/sandbox]] in [[:en:Betawi language|Betawi]]&lt;br /&gt;(code: &lt;code&gt;bew&lt;/code&gt;)
|-
| [[:bg:User:PK2/sandbox|/sandbox]] in [[:en:Bulgarian language|Bulgarian]]&lt;br /&gt;(code: &lt;code&gt;bg&lt;/code&gt;)
| [[:bh:User:PK2/sandbox|/sandbox]] in [[:en:Bihari languages|Bihari]] ([[:en:Bhojpuri language|Bhojpuri]])&lt;br /&gt;(code: &lt;code&gt;bh&lt;/code&gt;)
| [[:bi:User:PK2/sandbox|/sandbox]] in [[:en:Bislama|Bislama]]&lt;br /&gt;(code: &lt;code&gt;bi&lt;/code&gt;)
| [[:bjn:User:PK2/sandbox|/sandbox]] in [[:en:Banjarese language|Banjarese]]&lt;br /&gt;(code: &lt;code&gt;bjn&lt;/code&gt;)
| [[:blk:User:PK2/sandbox|/sandbox]] in [[:en:Pa'O language|Pa'O]]&lt;br /&gt;(code: &lt;code&gt;blk&lt;/code&gt;)
| [[:bm:User:PK2/sandbox|/sandbox]] in [[:en:Bambara language|Bambara]]&lt;br /&gt;(code: &lt;code&gt;bm&lt;/code&gt;)
| [[:bn:User:PK2/খেলাঘর|/sandbox]] in [[:en:Bengali language|Bengali]]&lt;br /&gt;(code: &lt;code&gt;bn&lt;/code&gt;)
| [[:bo:User:PK2/sandbox|/sandbox]] in [[:en:Central Tibetan|Central Tibetan]] ([[:en:Lhasa Tibetan|Lhasa Tibetan]])&lt;br /&gt;(code: &lt;code&gt;bo&lt;/code&gt;)
| [[:bpy:User:PK2/sandbox|/sandbox]] in [[:en:Bishnupriya Manipuri|Bishnupriya Manipuri]]&lt;br /&gt;(code: &lt;code&gt;bpy&lt;/code&gt;)
| [[:br:User:PK2/sandbox|/sandbox]] in [[:en:Breton language|Breton]]&lt;br /&gt;(code: &lt;code&gt;br&lt;/code&gt;)
|-
| [[:bs:User:PK2/sandbox|/sandbox]] in [[:en:Bosnian language|Bosnian]]&lt;br /&gt;(code: &lt;code&gt;bs&lt;/code&gt;)
| [[:btm:User:PK2/sandbox|/sandbox]] in [[:en:Mandailing Batak language|Mandailing Batak]]&lt;br /&gt;(code: &lt;code&gt;btm&lt;/code&gt;)
| [[:bug:User:PK2/sandbox|/sandbox]] in [[:en:Buginese language|Buginese]]&lt;br /&gt;(code: &lt;code&gt;bug&lt;/code&gt;)
| [[:bxr:User:PK2/sandbox|/sandbox]] in [[:en:Buryat language|Buryat]] (Russia Buriat)&lt;br /&gt;(code: &lt;code&gt;bxr&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ C
|-
| [[:ca:User:PK2/proves|/sandbox]] in [[:en:Catalan language|Catalan]]&lt;br /&gt;(code: &lt;code&gt;ca&lt;/code&gt;)
| [[:cbk-zam:User:PK2/sandbox|/sandbox]] in [[:en:Chavacano|Chavacano]] (Zamboanga)&lt;br /&gt;(code: &lt;code&gt;cbk-zam&lt;/code&gt;)
| [[:cdo:User:PK2/sandbox|/sandbox]] in [[:en:Eastern Min|Eastern Min]]&lt;br /&gt;(code: &lt;code&gt;cdo&lt;/code&gt;)
| [[:ce:User:PK2/sandbox|/sandbox]] in [[:en:Chechen language|Chechen]]&lt;br /&gt;(code: &lt;code&gt;ce&lt;/code&gt;)
| [[:ceb:User:PK2/sandbox|/sandbox]] in [[:en:Cebuano language|Cebuano]]&lt;br /&gt;(code: &lt;code&gt;ceb&lt;/code&gt;)
| [[:ch:User:PK2/sandbox|/sandbox]] in [[:en:Chamorro language|Chamorro]]&lt;br /&gt;(code: &lt;code&gt;ch&lt;/code&gt;)
| [[:chr:User:PK2/sandbox|/sandbox]] in [[:en:Cherokee language|Cherokee]]&lt;br /&gt;(code: &lt;code&gt;chr&lt;/code&gt;)
| [[:chy:User:PK2/sandbox|/sandbox]] in [[:en:Cheyenne language|Cheyenne]]&lt;br /&gt;(code: &lt;code&gt;chy&lt;/code&gt;)
|-
| [[:ckb:User:PK2/خۆڵەپەتانێ|/sandbox]] in [[:en:Kurdish language|Kurdish]] ([[:en:Sorani|Sorani]])&lt;br /&gt;(code: &lt;code&gt;ckb&lt;/code&gt;)
| [[:co:User:PK2/sandbox|/sandbox]] in [[:en:Corsican language|Corsican]]&lt;br /&gt;(code: &lt;code&gt;co&lt;/code&gt;)
| [[:crh:User:PK2/sandbox|/sandbox]] in [[:en:Crimean Tatar language|Crimean Tatar]]&lt;br /&gt;(code: &lt;code&gt;crh&lt;/code&gt;)
| [[:cs:User:PK2/Pískoviště|/sandbox]] in [[:en:Czech language|Czech]]&lt;br /&gt;(code: &lt;code&gt;cs&lt;/code&gt;)
| [[:csb:User:PK2/sandbox|/sandbox]] in [[:en:Kashubian language|Kashubian]]&lt;br /&gt;(code: &lt;code&gt;csb&lt;/code&gt;)
| [[:cu:User:PK2/sandbox|/sandbox]] in [[:en:Old Church Slavonic|Old Church Slavonic]]&lt;br /&gt;(code: &lt;code&gt;cu&lt;/code&gt;)
| [[:cv:User:PK2/sandbox|/sandbox]] in [[:en:Chuvash language|Chuvash]]&lt;br /&gt;(code: &lt;code&gt;cv&lt;/code&gt;)
| [[:cy:User:PK2/Pwll Tywod|/sandbox]] in [[:en:Welsh language|Welsh]]&lt;br /&gt;(code: &lt;code&gt;cy&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ D
|-
| [[:da:User:PK2/sandkasse|/sandbox]] in [[:en:Danish language|Danish]]&lt;br /&gt;(code: &lt;code&gt;da&lt;/code&gt;)
| [[:dag:User:PK2/sandbox|/sandbox]] in [[:en:Dagbani language|Dagbani]]&lt;br /&gt;(code: &lt;code&gt;dag&lt;/code&gt;)
| [[:de:User:PK2/sandbox|/sandbox]] in [[:en:German language|German]]&lt;br /&gt;(code: &lt;code&gt;de&lt;/code&gt;)
| [[:dga:User:PK2/sandbox|/sandbox]] in [[:en:Dagaare language|Dagaare]]&lt;br /&gt;(code: &lt;code&gt;dga&lt;/code&gt;)
| [[:din:User:PK2/sandbox|/sandbox]] in [[:en:Dinka language|Dinka]]&lt;br /&gt;(code: &lt;code&gt;din&lt;/code&gt;)
| [[:diq:User:PK2/sandbox|/sandbox]] in [[:en:Zaza language|Zaza]]&lt;br /&gt;(code: &lt;code&gt;diq&lt;/code&gt;)
| [[:dsb:User:PK2/sandbox|/sandbox]] in [[:en:Lower Sorbian language|Lower Sorbian]]&lt;br /&gt;(code: &lt;code&gt;dsb&lt;/code&gt;)
| [[:dtp:User:PK2/sandbox|/sandbox]] in [[:en:Dusun language|Dusun]]&lt;br /&gt;(code: &lt;code&gt;dtp&lt;/code&gt;)
| [[:dty:User:PK2/प्रयोगस्थल|/sandbox]] in [[:en:Doteli|Doteli]]&lt;br /&gt;(code: &lt;code&gt;dty&lt;/code&gt;)
| [[:dv:User:PK2/sandbox|/sandbox]] in [[:en:Maldivian language|Maldivian]]&lt;br /&gt;(code: &lt;code&gt;dv&lt;/code&gt;)
| [[:dz:User:PK2/sandbox|/sandbox]] in [[:en:Dzongkha|Dzongkha]]&lt;br /&gt;(code: &lt;code&gt;dz&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ E
|-
| [[:ee:User:PK2/sandbox|/sandbox]] in [[:en:Ewe language|Ewe]]&lt;br /&gt;(code: &lt;code&gt;ee&lt;/code&gt;)
| [[:el:User:PK2/πρόχειρο|/sandbox]] in [[:en:Greek language|Greek]]&lt;br /&gt;(code: &lt;code&gt;el&lt;/code&gt;)
| [[:eml:User:PK2/sandbox|/sandbox]] in [[:en:Emilian–Romagnol|Emilian–Romagnol]]&lt;br /&gt;(code: &lt;code&gt;eml&lt;/code&gt;)
| [[:en:User:PK2/sandbox|/sandbox]] in [[:en:English language|English]]&lt;br /&gt;(code: &lt;code&gt;en&lt;/code&gt;)
| [[:eo:User:PK2/provejo|/sandbox]] in [[:en:Esperanto|Esperanto]]&lt;br /&gt;(code: &lt;code&gt;eo&lt;/code&gt;)
| [[:es:User:PK2/Taller|/sandbox]] in [[:en:Spanish language|Spanish]]&lt;br /&gt;(code: &lt;code&gt;es&lt;/code&gt;)
| [[:et:User:PK2/sandbox|/sandbox]] in [[:en:Estonian language|Estonian]]&lt;br /&gt;(code: &lt;code&gt;et&lt;/code&gt;)
| [[:eu:User:PK2/Proba orria|/sandbox]] in [[:en:Basque language|Basque]]&lt;br /&gt;(code: &lt;code&gt;eu&lt;/code&gt;)
| [[:ext:User:PK2/obraol|/sandbox]] in [[:en:Extremaduran language|Extremaduran]]&lt;br /&gt;(code: &lt;code&gt;ext&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ F
|-
| [[:fa:User:PK2/صفحه تمرین|/sandbox]] in [[:en:Persian language|Persian]]&lt;br /&gt;(code: &lt;code&gt;fa&lt;/code&gt;)
| [[:fat:User:PK2/sandbox|/sandbox]] in [[:en:Akan language|Akan]] ([[:en:Fante dialect|Fante]])&lt;br /&gt;(code: &lt;code&gt;fat&lt;/code&gt;)
| [[:ff:User:PK2/sandbox|/sandbox]] in [[:en:Fula language|Fula]]&lt;br /&gt;(code: &lt;code&gt;ff&lt;/code&gt;)
| [[:fi:User:PK2/sandbox|/sandbox]] in [[:en:Finnish language|Finnish]]&lt;br /&gt;(code: &lt;code&gt;fi&lt;/code&gt;)
| [[:fiu-vro:User:PK2/sandbox|/sandbox]] in [[:en:Võro language|Võro]]&lt;br /&gt;(code: &lt;code&gt;fiu-vro&lt;/code&gt;)
| [[:fj:User:PK2/sandbox|/sandbox]] in [[:en:Fijian language|Fijian]]&lt;br /&gt;(code: &lt;code&gt;fj&lt;/code&gt;)
| [[:fo:User:PK2/sandbox|/sandbox]] in [[:en:Faroese language|Faroese]]&lt;br /&gt;(code: &lt;code&gt;fo&lt;/code&gt;)
| [[:fon:User:PK2/sandbox|/sandbox]] in [[:en:Fon language|Fon]]&lt;br /&gt;(code: &lt;code&gt;fon&lt;/code&gt;)
| [[:fr:User:PK2/Brouillon|/sandbox]] in [[:en:French language|French]]&lt;br /&gt;(code: &lt;code&gt;fr&lt;/code&gt;)
| [[:frp:User:PK2/sandbox|/sandbox]] in [[:en:Franco-Provençal|Franco-Provençal]]&lt;br /&gt;(code: &lt;code&gt;frp&lt;/code&gt;)
| [[:frr:User:PK2/sandbox|/sandbox]] in [[:en:North Frisian language|North Frisian]]&lt;br /&gt;(code: &lt;code&gt;frr&lt;/code&gt;)
| [[:fur:User:PK2/sandbox|/sandbox]] in [[:en:Friulian language|Friulian]]&lt;br /&gt;(code: &lt;code&gt;fur&lt;/code&gt;)
| [[:fy:User:PK2/sandbox|/sandbox]] in [[:en:West Frisian language|West Frisian]]&lt;br /&gt;(code: &lt;code&gt;fy&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ G
|-
| [[:ga:User:PK2/Clár Dubh|/sandbox]] in [[:en:Irish language|Irish]]&lt;br /&gt;(code: &lt;code&gt;ga&lt;/code&gt;)
| [[:gag:User:PK2/sandbox|/sandbox]] in [[:en:Gagauz language|Gagauz]]&lt;br /&gt;(code: &lt;code&gt;gag&lt;/code&gt;)
| [[:gan:User:PK2/sandbox|/sandbox]] in [[:en:Gan Chinese|Gan Chinese]]&lt;br /&gt;(code: &lt;code&gt;gan&lt;/code&gt;)
| [[:gcr:User:PK2/sandbox|/sandbox]] in [[:en:French Guianese Creole|French Guianese Creole]]&lt;br /&gt;(code: &lt;code&gt;gcr&lt;/code&gt;)
| [[:gd:User:PK2/sandbox|/sandbox]] in [[:en:Scottish Gaelic|Scottish Gaelic]]&lt;br /&gt;(code: &lt;code&gt;gd&lt;/code&gt;)
| [[:gl:User:PK2/sandbox|/sandbox]] in [[:en:Galician language|Galician]]&lt;br /&gt;(code: &lt;code&gt;gl&lt;/code&gt;)
| [[:glk:User:PK2/sandbox|/sandbox]] in [[:en:Gilaki language|Gilaki]]&lt;br /&gt;(code: &lt;code&gt;glk&lt;/code&gt;)
| [[:gn:User:PK2/sandbox|/sandbox]] in [[:en:Guarani language|Guarani]]&lt;br /&gt;(code: &lt;code&gt;gn&lt;/code&gt;)
| [[:gom:User:PK2/proiogpan|/sandbox]] in [[:en:Konkani language|Konkani]] (Goan Konkani)&lt;br /&gt;(code: &lt;code&gt;gom&lt;/code&gt;)
|-
| [[:gor:User:PK2/sandbox|/sandbox]] in [[:en:Gorontalo language|Gorontalo]]&lt;br /&gt;(code: &lt;code&gt;gor&lt;/code&gt;)
| [[:got:User:PK2/sandbox|/sandbox]] in [[:en:Gothic language|Gothic]]&lt;br /&gt;(code: &lt;code&gt;got&lt;/code&gt;)
| [[:gpe:User:PK2/sandbox|/sandbox]] in [[:en:Ghanaian Pidgin English|Ghanaian Pidgin English]]&lt;br /&gt;(code: &lt;code&gt;gpe&lt;/code&gt;)
| [[:gu:User:PK2/sandbox|/sandbox]] in [[:en:Gujarati language|Gujarati]]&lt;br /&gt;(code: &lt;code&gt;gu&lt;/code&gt;)
| [[:guc:User:PK2/sandbox|/sandbox]] in [[:en:Wayuu language|Wayuu]]&lt;br /&gt;(code: &lt;code&gt;guc&lt;/code&gt;)
| [[:gur:User:PK2/sandbox|/sandbox]] in [[:en:Farefare language|Farefare]]&lt;br /&gt;(code: &lt;code&gt;gur&lt;/code&gt;)
| [[:guw:User:PK2/sandbox|/sandbox]] in [[:en:Gun language|Gun]]&lt;br /&gt;(code: &lt;code&gt;guw&lt;/code&gt;)
| [[:gv:User:PK2/sandbox|/sandbox]] in [[:en:Manx language|Manx]]&lt;br /&gt;(code: &lt;code&gt;gv&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ H
|-
| [[:ha:User:PK2/sandbox|/sandbox]] in [[:en:Hausa language|Hausa]]&lt;br /&gt;(code: &lt;code&gt;ha&lt;/code&gt;)
| [[:hak:User:PK2/sandbox|/sandbox]] in [[:en:Hakka Chinese|Hakka Chinese]]&lt;br /&gt;(code: &lt;code&gt;hak&lt;/code&gt;)
| [[:haw:User:PK2/sandbox|/sandbox]] in [[:en:Hawaiian language|Hawaiian]]&lt;br /&gt;(code: &lt;code&gt;haw&lt;/code&gt;)
| [[:he:User:PK2/טיוטה|/sandbox]] in [[:en:Hebrew language|Hebrew]]&lt;br /&gt;(code: &lt;code&gt;he&lt;/code&gt;)
| [[:hi:User:PK2/प्रयोगपृष्ठ|/sandbox]] in [[:en:Hindi|Hindi]]&lt;br /&gt;(code: &lt;code&gt;hi&lt;/code&gt;)
| [[:hif:User:PK2/sandbox|/sandbox]] in [[:en:Fiji Hindi|Fiji Hindi]]&lt;br /&gt;(code: &lt;code&gt;hif&lt;/code&gt;)
| [[:hr:User:PK2/sandbox|/sandbox]] in [[:en:Croatian language|Croatian]]&lt;br /&gt;(code: &lt;code&gt;hr&lt;/code&gt;)
| [[:hsb:User:PK2/sandbox|/sandbox]] in [[:en:Upper Sorbian language|Upper Sorbian]]&lt;br /&gt;(code: &lt;code&gt;hsb&lt;/code&gt;)
| [[:ht:User:PK2/sandbox|/sandbox]] in [[:en:Haitian Creole|Haitian Creole]]&lt;br /&gt;(code: &lt;code&gt;ht&lt;/code&gt;)
| [[:hu:User:PK2/próbalap|/sandbox]] in [[:en:Hungarian language|Hungarian]]&lt;br /&gt;(code: &lt;code&gt;hu&lt;/code&gt;)
| [[:hy:User:PK2/Ավազարկղ|/sandbox]] in [[:en:Armenian language|Armenian]] ([[:en:Eastern Armenian|Eastern Armenian]])&lt;br /&gt;(code: &lt;code&gt;hy&lt;/code&gt;)
| [[:hyw:User:PK2/Սեւագրութիւն|/sandbox]] in [[:en:Western Armenian|Western Armenian]]&lt;br /&gt;(code: &lt;code&gt;hyw&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ I
|-
| [[:ia:User:PK2/sandbox|/sandbox]] in [[:en:Interlingua|Interlingua]]&lt;br /&gt;(code: &lt;code&gt;ia&lt;/code&gt;)
| [[:iba:User:PK2/sandbox|/sandbox]] in [[:en:Iban language|Iban]]&lt;br /&gt;(code: &lt;code&gt;iba&lt;/code&gt;)
| [[:id:User:PK2/sandbox|/sandbox]] in [[:en:Indonesian language|Indonesian]]&lt;br /&gt;(code: &lt;code&gt;id&lt;/code&gt;)
| [[:ie:User:PK2/sandbox|/sandbox]] in [[:en:Interlingue|Interlingue]]&lt;br /&gt;(code: &lt;code&gt;ie&lt;/code&gt;)
| [[:ig:User:PK2/sandbox|/sandbox]] in [[:en:Igbo language|Igbo]]&lt;br /&gt;(code: &lt;code&gt;ig&lt;/code&gt;)
| [[:igl:User:PK2/sandbox|/sandbox]] in [[:en:Igala language|Igala]]&lt;br /&gt;(code: &lt;code&gt;igl&lt;/code&gt;)
| [[:ik:User:PK2/sandbox|/sandbox]] in [[:en:Iñupiaq language|Iñupiaq]]&lt;br /&gt;(code: &lt;code&gt;ik&lt;/code&gt;)
| [[:ilo:User:PK2/pagipadasan|/sandbox]] in [[:en:Ilocano language|Ilocano]]&lt;br /&gt;(code: &lt;code&gt;ilo&lt;/code&gt;)
| [[:inh:User:PK2/sandbox|/sandbox]] in [[:en:Ingush language|Ingush]]&lt;br /&gt;(code: &lt;code&gt;inh&lt;/code&gt;)
| [[:io:User:PK2/sandbox|/sandbox]] in [[:en:Ido|Ido]]&lt;br /&gt;(code: &lt;code&gt;io&lt;/code&gt;)
| [[:is:User:PK2/sandkassi|/sandbox]] in [[:en:Icelandic language|Icelandic]]&lt;br /&gt;(code: &lt;code&gt;is&lt;/code&gt;)
| [[:it:User:PK2/Sandbox|/sandbox]] in [[:en:Italian language|Italian]]&lt;br /&gt;(code: &lt;code&gt;it&lt;/code&gt;)
| [[:iu:User:PK2/sandbox|/sandbox]] in [[:en:Inuktitut|Inuktitut]]&lt;br /&gt;(code: &lt;code&gt;iu&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ J
|-
| [[:ja:User:PK2/sandbox|/sandbox]] in [[:en:Japanese language|Japanese]]&lt;br /&gt;(code: &lt;code&gt;ja&lt;/code&gt;)
| [[:jam:User:PK2/sandbox|/sandbox]] in [[:en:Jamaican Patois|Jamaican Patois]]&lt;br /&gt;(code: &lt;code&gt;jam&lt;/code&gt;)
| [[:jbo:User:PK2/sandbox|/sandbox]] in [[:en:Lojban|Lojban]]&lt;br /&gt;(code: &lt;code&gt;jbo&lt;/code&gt;)
| [[:jv:User:PK2/bak wedhi|/sandbox]] in [[:en:Javanese language|Javanese]]&lt;br /&gt;(code: &lt;code&gt;jv&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ K
|-
| [[:ka:User:PK2/sandbox|/sandbox]] in [[:en:Georgian language|Georgian]]&lt;br /&gt;(code: &lt;code&gt;ka&lt;/code&gt;)
| [[:kaa:User:PK2/qaralama|/sandbox]] in [[:en:Karakalpak language|Karakalpak]]&lt;br /&gt;(code: &lt;code&gt;kaa&lt;/code&gt;)
| [[:kab:User:PK2/sandbox|/sandbox]] in [[:en:Kabyle language|Kabyle]]&lt;br /&gt;(code: &lt;code&gt;kab&lt;/code&gt;)
| [[:kai:User:PK2/sandbox|/sandbox]] in [[:en:Karai-karai|Karai-karai]]&lt;br /&gt;(code: &lt;code&gt;kai&lt;/code&gt;)
| [[:kaj:User:PK2/sandbox|/sandbox]] in [[:en:Jju language|Jju]]&lt;br /&gt;(code: &lt;code&gt;kaj&lt;/code&gt;)
| [[:kbd:User:PK2/sandbox|/sandbox]] in [[:en:Kabardian language|Kabardian]]&lt;br /&gt;(code: &lt;code&gt;kbd&lt;/code&gt;)
| [[:kbp:User:PK2/sandbox|/sandbox]] in [[:en:Kabiye language|Kabiye]]&lt;br /&gt;(code: &lt;code&gt;kbp&lt;/code&gt;)
| [[:kcg:User:PK2/sandbox|/sandbox]] in [[:en:Tyap|Tyap]]&lt;br /&gt;(code: &lt;code&gt;kcg&lt;/code&gt;)
| [[:kg:User:PK2/sandbox|/sandbox]] in [[:en:Kongo language|Kongo]]&lt;br /&gt;(code: &lt;code&gt;kg&lt;/code&gt;)
| [[:kge:User:PK2/sandbox|/sandbox]] in [[:en:Komering language|Komering]]&lt;br /&gt;(code: &lt;code&gt;kge&lt;/code&gt;)
| [[:ki:User:PK2/sandbox|/sandbox]] in [[:en:Kikuyu language|Kikuyu]]&lt;br /&gt;(code: &lt;code&gt;ki&lt;/code&gt;)
| [[:kk:User:PK2/зертхана|/sandbox]] in [[:en:Kazakh language|Kazakh]]&lt;br /&gt;(code: &lt;code&gt;kk&lt;/code&gt;)
| [[:km:User:PK2/sandbox|/sandbox]] in [[:en:Khmer language|Khmer]]&lt;br /&gt;(code: &lt;code&gt;km&lt;/code&gt;)
|-
| [[:kn:User:PK2/ಪ್ರಯೋಗಪುಟ|/sandbox]] in [[:en:Kannada|Kannada]]&lt;br /&gt;(code: &lt;code&gt;kn&lt;/code&gt;)
| [[:knc:User:PK2/sandbox|/sandbox]] in [[:en:Central Kanuri|Central Kanuri]]&lt;br /&gt;(code: &lt;code&gt;knc&lt;/code&gt;)
| [[:ko:User:PK2/연습장|/sandbox]] in [[:en:Korean language|Korean]]&lt;br /&gt;(code: &lt;code&gt;ko&lt;/code&gt;)
| [[:koi:User:PK2/sandbox|/sandbox]] in [[:en:Komi-Permyak language|Komi-Permyak]]&lt;br /&gt;(code: &lt;code&gt;koi&lt;/code&gt;)
| [[:krc:User:PK2/sandbox|/sandbox]] in [[:en:Karachay-Balkar|Karachay-Balkar]]&lt;br /&gt;(code: &lt;code&gt;krc&lt;/code&gt;)
| [[:ks:User:PK2/sandbox|/sandbox]] in [[:en:Kashmiri language|Kashmiri]]&lt;br /&gt;(code: &lt;code&gt;ks&lt;/code&gt;)
| [[:ksh:User:PK2/sandbox|/sandbox]] in [[:en:Ripuarian language|Ripuarian]]&lt;br /&gt;(code: &lt;code&gt;ksh&lt;/code&gt;)
| [[:ku:User:PK2/ceribandin|/sandbox]] in [[:en:Kurdish language|Kurdish]] ([[:en:Kurmanji|Kurmanji]])&lt;br /&gt;(code: &lt;code&gt;ku&lt;/code&gt;)
| [[:kus:User:PK2/sandbox|/sandbox]] in [[:en:Kusaal language|Kusaal]]&lt;br /&gt;(code: &lt;code&gt;kus&lt;/code&gt;)
| [[:kv:User:PK2/sandbox|/sandbox]] in [[:en:Komi language|Komi]]&lt;br /&gt;(code: &lt;code&gt;kv&lt;/code&gt;)
| [[:kw:User:PK2/sandbox|/sandbox]] in [[:en:Cornish language|Cornish]]&lt;br /&gt;(code: &lt;code&gt;kw&lt;/code&gt;)
| [[:ky:User:PK2/sandbox|/sandbox]] in [[:en:Kyrgyz language|Kyrgyz]]&lt;br /&gt;(code: &lt;code&gt;ky&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ L
|-
| [[:la:User:PK2/Harenarium|/sandbox]] in [[:en:Latin|Latin]]&lt;br /&gt;(code: &lt;code&gt;la&lt;/code&gt;)
| [[:lad:User:PK2/Kutí de prova|/sandbox]] in [[:en:Judaeo-Spanish|Judaeo-Spanish]]&lt;br /&gt;(code: &lt;code&gt;lad&lt;/code&gt;)
| [[:lb:User:PK2/sandbox|/sandbox]] in [[:en:Luxembourgish|Luxembourgish]]&lt;br /&gt;(code: &lt;code&gt;lb&lt;/code&gt;)
| [[:lbe:User:PK2/sandbox|/sandbox]] in [[:en:Lak language|Lak]]&lt;br /&gt;(code: &lt;code&gt;lbe&lt;/code&gt;)
| [[:lez:User:PK2/sandbox|/sandbox]] in [[:en:Lezgian language|Lezgian]]&lt;br /&gt;(code: &lt;code&gt;lez&lt;/code&gt;)
| [[:lfn:User:PK2/sandbox|/sandbox]] in [[:en:Lingua Franca Nova|Lingua Franca Nova]]&lt;br /&gt;(code: &lt;code&gt;lfn&lt;/code&gt;)
| [[:lg:User:PK2/sandbox|/sandbox]] in [[:en:Luganda|Luganda]]&lt;br /&gt;(code: &lt;code&gt;lg&lt;/code&gt;)
| [[:li:User:PK2/sandbox|/sandbox]] in [[:en:Limburgish|Limburgish]]&lt;br /&gt;(code: &lt;code&gt;li&lt;/code&gt;)
|-
| [[:lij:User:PK2/sandbox|/sandbox]] in [[:en:Ligurian language|Ligurian]]&lt;br /&gt;(code: &lt;code&gt;lij&lt;/code&gt;)
| [[:lld:User:PK2/sandbox|/sandbox]] in [[:en:Ladin language|Ladin]]&lt;br /&gt;(code: &lt;code&gt;lld&lt;/code&gt;)
| [[:lmo:User:PK2/sandbox|/sandbox]] in [[:en:Lombard language|Lombard]]&lt;br /&gt;(code: &lt;code&gt;lmo&lt;/code&gt;)
| [[:ln:User:PK2/sandbox|/sandbox]] in [[:en:Lingala|Lingala]]&lt;br /&gt;(code: &lt;code&gt;ln&lt;/code&gt;)
| [[:lo:User:PK2/sandbox|/sandbox]] in [[:en:Lao language|Lao]]&lt;br /&gt;(code: &lt;code&gt;lo&lt;/code&gt;)
| [[:lt:User:PK2/juodraštis|/sandbox]] in [[:en:Lithuanian language|Lithuanian]]&lt;br /&gt;(code: &lt;code&gt;lt&lt;/code&gt;)
| [[:ltg:User:PK2/sandbox|/sandbox]] in [[:en:Latgalian language|Latgalian]]&lt;br /&gt;(code: &lt;code&gt;ltg&lt;/code&gt;)
| [[:lv:User:PK2/Smilšu kaste|/sandbox]] in [[:en:Latvian language|Latvian]]&lt;br /&gt;(code: &lt;code&gt;lv&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ M
|-
| [[:mad:User:PK2/sandbox|/sandbox]] in [[:en:Madurese language|Madurese]]&lt;br /&gt;(code: &lt;code&gt;mad&lt;/code&gt;)
| [[:mai:User:PK2/प्रयोगपृष्ठ|/sandbox]] in [[:en:Maithili language|Maithili]]&lt;br /&gt;(code: &lt;code&gt;mai&lt;/code&gt;)
| [[:map-bms:User:PK2/sandbox|/sandbox]] in [[:en:Javanese language|Javanese]] ([[:en:Banyumasan dialect|Banyumasan]])&lt;br /&gt;(code: &lt;code&gt;map-bms&lt;/code&gt;)
| [[:mdf:User:PK2/sandbox|/sandbox]] in [[:en:Moksha language|Moksha]]&lt;br /&gt;(code: &lt;code&gt;mdf&lt;/code&gt;)
| [[:mg:User:PK2/sandbox|/sandbox]] in [[:en:Malagasy language|Malagasy]]&lt;br /&gt;(code: &lt;code&gt;mg&lt;/code&gt;)
| [[:mhr:User:PK2/sandbox|/sandbox]] in [[:en:Meadow Mari language|Meadow Mari]]&lt;br /&gt;(code: &lt;code&gt;mhr&lt;/code&gt;)
| [[:mi:User:PK2/sandbox|/sandbox]] in [[:en:Māori language|Māori]]&lt;br /&gt;(code: &lt;code&gt;mi&lt;/code&gt;)
| [[:min:User:PK2/bak kasiak|/sandbox]] in [[:en:Minangkabau language|Minangkabau]]&lt;br /&gt;(code: &lt;code&gt;min&lt;/code&gt;)
| [[:mk:User:PK2/sandbox|/sandbox]] in [[:en:Macedonian language|Macedonian]]&lt;br /&gt;(code: &lt;code&gt;mk&lt;/code&gt;)
| [[:ml:User:PK2/sandbox|/sandbox]] in [[:en:Malayalam|Malayalam]]&lt;br /&gt;(code: &lt;code&gt;ml&lt;/code&gt;)
| [[:mn:User:PK2/sandbox|/sandbox]] in [[:en:Mongolian language|Mongolian]]&lt;br /&gt;(code: &lt;code&gt;mn&lt;/code&gt;)
|-
| [[:mni:User:PK2/sandbox|/sandbox]] in [[:en:Meitei language|Meitei]]&lt;br /&gt;(code: &lt;code&gt;mni&lt;/code&gt;)
| [[:mnw:User:PK2/sandbox|/sandbox]] in [[:en:Mon language|Mon]]&lt;br /&gt;(code: &lt;code&gt;mnw&lt;/code&gt;)
| [[:m:mos:User:PK2/sandbox|/sandbox]] in [[:en:Mooré|Mooré]]&lt;br /&gt;(code: &lt;code&gt;mos&lt;/code&gt;)
| [[:mr:User:PK2/sandbox|/sandbox]] in [[:en:Marathi language|Marathi]]&lt;br /&gt;(code: &lt;code&gt;mr&lt;/code&gt;)
| [[:mrj:User:PK2/sandbox|/sandbox]] in [[:en:Hill Mari language|Hill Mari]]&lt;br /&gt;(code: &lt;code&gt;mrj&lt;/code&gt;)
| [[:ms:User:PK2/Kotak pasir|/sandbox]] in [[:en:Malay language|Malay]]&lt;br /&gt;(code: &lt;code&gt;ms&lt;/code&gt;)
| [[:mt:User:PK2/sandbox|/sandbox]] in [[:en:Maltese language|Maltese]]&lt;br /&gt;(code: &lt;code&gt;mt&lt;/code&gt;)
| [[:mwl:User:PK2/Testes|/sandbox]] in [[:en:Mirandese language|Mirandese]]&lt;br /&gt;(code: &lt;code&gt;mwl&lt;/code&gt;)
| [[:my:User:PK2/sandbox|/sandbox]] in [[:en:Burmese language|Burmese]]&lt;br /&gt;(code: &lt;code&gt;my&lt;/code&gt;)
| [[:myv:User:PK2/sandbox|/sandbox]] in [[:en:Erzya language|Erzya]]&lt;br /&gt;(code: &lt;code&gt;myv&lt;/code&gt;)
| [[:mzn:User:PK2/sandbox|/sandbox]] in [[:en:Mazanderani language|Mazanderani]]&lt;br /&gt;(code: &lt;code&gt;mzn&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ N
|-
| [[:nah:User:PK2/sandbox|/sandbox]] in [[:en:Nahuatl|Nahuatl]]&lt;br /&gt;(code: &lt;code&gt;nah&lt;/code&gt;)
| [[:nap:User:PK2/sandbox|/sandbox]] in [[:en:Neapolitan language|Neapolitan]]&lt;br /&gt;(code: &lt;code&gt;nap&lt;/code&gt;)
| [[:nds:User:PK2/sandbox|/sandbox]] in [[:en:Low German|Low German]]&lt;br /&gt;(code: &lt;code&gt;nds&lt;/code&gt;)
| [[:nds-nl:User:PK2/sandbox|/sandbox]] in [[:en:Dutch Low Saxon|Dutch Low Saxon]]&lt;br /&gt;(code: &lt;code&gt;nds-nl&lt;/code&gt;)
| [[:ne:User:PK2/प्रयोगस्थल|/sandbox]] in [[:en:Nepali language|Nepali]]&lt;br /&gt;(code: &lt;code&gt;ne&lt;/code&gt;)
| [[:new:User:PK2/sandbox|/sandbox]] in [[:en:Newar language|Newar]]&lt;br /&gt;(code: &lt;code&gt;new&lt;/code&gt;)
| [[:nia:User:PK2/sandbox|/sandbox]] in [[:en:Nias language|Nias]]&lt;br /&gt;(code: &lt;code&gt;nia&lt;/code&gt;)
| [[:nl:User:PK2/Kladblok|/sandbox]] in [[:en:Dutch language|Dutch]]&lt;br /&gt;(code: &lt;code&gt;nl&lt;/code&gt;)
| [[:nn:User:PK2/sandkasse|/sandbox]] in [[:en:Norwegian language|Norwegian]] ([[:en:Nynorsk|Nynorsk]])&lt;br /&gt;(code: &lt;code&gt;nn&lt;/code&gt;)
|-
| [[:no:User:PK2/sandkasse|/sandbox]] in [[:en:Norwegian language|Norwegian]] ([[:en:Bokmål|Bokmål]])&lt;br /&gt;(code: &lt;code&gt;no&lt;/code&gt;)
| [[:nov:User:PK2/sandbox|/sandbox]] in [[:en:Novial|Novial]]&lt;br /&gt;(code: &lt;code&gt;nov&lt;/code&gt;)
| [[:nqo:User:PK2/sandbox|/sandbox]] in [[:en:N'Ko language|N'Ko]]&lt;br /&gt;(code: &lt;code&gt;nqo&lt;/code&gt;)
| [[:nr:User:PK2/sandbox|/sandbox]] in [[:en:Southern Ndebele language|Southern Ndebele]]&lt;br /&gt;(code: &lt;code&gt;nr&lt;/code&gt;)
| [[:nrm:User:PK2/sandbox|/sandbox]] in [[:en:Norman language|Norman]]&lt;br /&gt;(code: &lt;code&gt;nrm&lt;/code&gt;)
| [[:nso:User:PK2/sandbox|/sandbox]] in [[:en:Northern Sotho|Northern Sotho]]&lt;br /&gt;(code: &lt;code&gt;nso&lt;/code&gt;)
| [[:nup:User:PK2/sandbox|/sandbox]] in [[:en:Nupe language|Nupe]]&lt;br /&gt;(code: &lt;code&gt;nup&lt;/code&gt;)
| [[:nv:User:PK2/sandbox|/sandbox]] in [[:en:Navajo language|Navajo]]&lt;br /&gt;(code: &lt;code&gt;nv&lt;/code&gt;)
| [[:ny:User:PK2/sandbox|/sandbox]] in [[:en:Chewa language|Chewa]]&lt;br /&gt;(code: &lt;code&gt;ny&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ O
|-
| [[:oc:User:PK2/sandbox|/sandbox]] in [[:en:Occitan language|Occitan]]&lt;br /&gt;(code: &lt;code&gt;oc&lt;/code&gt;)
| [[:olo:User:PK2/sandbox|/sandbox]] in [[:en:Livvi-Karelian language|Livvi-Karelian]]&lt;br /&gt;(code: &lt;code&gt;olo&lt;/code&gt;)
| [[:om:User:PK2/sandbox|/sandbox]] in [[:en:Oromo language|Oromo]]&lt;br /&gt;(code: &lt;code&gt;om&lt;/code&gt;)
| [[:or:User:PK2/ପରଖଘର|/sandbox]] in [[:en:Odia language|Odia]]&lt;br /&gt;(code: &lt;code&gt;or&lt;/code&gt;)
| [[:os:User:PK2/sandbox|/sandbox]] in [[:en:Ossetian language|Ossetian]]&lt;br /&gt;(code: &lt;code&gt;os&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ P
|-
| [[:pa:User:PK2/ਕੱਚਾ ਖ਼ਾਕਾ|/sandbox]] in [[:en:Punjabi language|Punjabi]]&lt;br /&gt;(code: &lt;code&gt;pa&lt;/code&gt;)
| [[:pag:User:PK2/sandbox|/sandbox]] in [[:en:Pangasinan language|Pangasinan]]&lt;br /&gt;(code: &lt;code&gt;pag&lt;/code&gt;)
| [[:pam:User:PK2/sandbox|/sandbox]] in [[:en:Kapampangan language|Kapampangan]]&lt;br /&gt;(code: &lt;code&gt;pam&lt;/code&gt;)
| [[:pap:User:PK2/sandbox|/sandbox]] in [[:en:Papiamento|Papiamento]]&lt;br /&gt;(code: &lt;code&gt;pap&lt;/code&gt;)
| [[:pcd:User:PK2/sandbox|/sandbox]] in [[:en:Picard language|Picard]]&lt;br /&gt;(code: &lt;code&gt;pcd&lt;/code&gt;)
| [[:pcm:User:PK2/sandbox|/sandbox]] in [[:en:Nigerian Pidgin|Nigerian Pidgin]]&lt;br /&gt;(code: &lt;code&gt;pcm&lt;/code&gt;)
| [[:pdc:User:PK2/sandbox|/sandbox]] in [[:en:Pennsylvania Dutch language|Pennsylvania Dutch]]&lt;br /&gt;(code: &lt;code&gt;pdc&lt;/code&gt;)
| [[:pfl:User:PK2/sandbox|/sandbox]] in [[:en:Palatine German dialects|Palatine German]]&lt;br /&gt;(code: &lt;code&gt;pfl&lt;/code&gt;)
| [[:pi:User:PK2/sandbox|/sandbox]] in [[:en:Pali|Pali]]&lt;br /&gt;(code: &lt;code&gt;pi&lt;/code&gt;)
|-
| [[:pl:User:PK2/brudnopis|/sandbox]] in [[:en:Polish language|Polish]]&lt;br /&gt;(code: &lt;code&gt;pl&lt;/code&gt;)
| [[:pms:User:PK2/sandbox|/sandbox]] in [[:en:Piedmontese language|Piedmontese]]&lt;br /&gt;(code: &lt;code&gt;pms&lt;/code&gt;)
| [[:pnb:User:PK2/sandbox|/sandbox]] in [[:en:Punjabi language|Punjabi]] (Western Punjabi)&lt;br /&gt;(code: &lt;code&gt;pnb&lt;/code&gt;)
| [[:pnt:User:PK2/sandbox|/sandbox]] in [[:en:Pontic Greek|Pontic Greek]]&lt;br /&gt;(code: &lt;code&gt;pnt&lt;/code&gt;)
| [[:ppl:User:PK2/sandbox|/sandbox]] in [[:en:Nawat language|Nawat]]&lt;br /&gt;(code: &lt;code&gt;ppl&lt;/code&gt;)
| [[:ps:User:PK2/ازمون‌مخ|/sandbox]] in [[:en:Pashto|Pashto]]&lt;br /&gt;(code: &lt;code&gt;ps&lt;/code&gt;)
| [[:pt:User:PK2/Testes|/sandbox]] in [[:en:Portuguese language|Portuguese]]&lt;br /&gt;(code: &lt;code&gt;pt&lt;/code&gt;)
| [[:pwn:User:PK2/sandbox|/sandbox]] in [[:en:Paiwan language|Paiwan]]&lt;br /&gt;(code: &lt;code&gt;pwn&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ Q
|-
| [[:qu:User:PK2/sandbox|/sandbox]] in [[:en:Quechuan languages|Quechua]] ([[:en:Southern Quechua|Southern Quechua]])&lt;br /&gt;(code: &lt;code&gt;qu&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ R
|-
| [[:rki:User:PK2/sandbox|/sandbox]] in [[:en:Rakhine language|Rakhine]]&lt;br /&gt;(code: &lt;code&gt;rki&lt;/code&gt;)
| [[:rm:User:PK2/sandbox|/sandbox]] in [[:en:Romansh language|Romansh]]&lt;br /&gt;(code: &lt;code&gt;rm&lt;/code&gt;)
| [[:rmy:User:PK2/sandbox|/sandbox]] in [[:en:Romani language|Romani]] ([[:en:Vlax Romani language|Vlax Romani]])&lt;br /&gt;(code: &lt;code&gt;rmy&lt;/code&gt;)
| [[:rn:User:PK2/sandbox|/sandbox]] in [[:en:Kirundi|Kirundi]]&lt;br /&gt;(code: &lt;code&gt;rn&lt;/code&gt;)
| [[:ro:User:PK2/teste|/sandbox]] in [[:en:Romanian language|Romanian]]&lt;br /&gt;(code: &lt;code&gt;ro&lt;/code&gt;)
| [[:roa-rup:User:PK2/sandbox|/sandbox]] in [[:en:Aromanian language|Aromanian]]&lt;br /&gt;(code: &lt;code&gt;roa-rup&lt;/code&gt;)
| [[:roa-tara:User:PK2/sandbox|/sandbox]] in [[:en:Neapolitan language|Neapolitan]] ([[:en:Tarantino dialect|Tarantino]])&lt;br /&gt;(code: &lt;code&gt;roa-tara&lt;/code&gt;)
| [[:rsk:User:PK2/sandbox|/sandbox]] in [[:en:Pannonian Rusyn|Pannonian Rusyn]]&lt;br /&gt;(code: &lt;code&gt;rsk&lt;/code&gt;)
| [[:ru:User:PK2/Черновик|/sandbox]] in [[:en:Russian language|Russian]]&lt;br /&gt;(code: &lt;code&gt;ru&lt;/code&gt;)
| [[:rue:User:PK2/sandbox|/sandbox]] in [[:en:Rusyn language|Rusyn]]&lt;br /&gt;(code: &lt;code&gt;rue&lt;/code&gt;)
| [[:rw:User:PK2/sandbox|/sandbox]] in [[:en:Kinyarwanda|Kinyarwanda]]&lt;br /&gt;(code: &lt;code&gt;rw&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ S
|-
| [[:sa:User:PK2/प्रयोगपृष्ठम्|/sandbox]] in [[:en:Sanskrit|Sanskrit]]&lt;br /&gt;(code: &lt;code&gt;sa&lt;/code&gt;)
| [[:sah:User:PK2/sandbox|/sandbox]] in [[:en:Yakut language|Yakut]]&lt;br /&gt;(code: &lt;code&gt;sah&lt;/code&gt;)
| [[:sat:User:PK2/sandbox|/sandbox]] in [[:en:Santali language|Santali]]&lt;br /&gt;(code: &lt;code&gt;sat&lt;/code&gt;)
| [[:sc:User:PK2/sandbox|/sandbox]] in [[:en:Sardinian language|Sardinian]]&lt;br /&gt;(code: &lt;code&gt;sc&lt;/code&gt;)
| [[:scn:User:PK2/sandbox|/sandbox]] in [[:en:Sicilian language|Sicilian]]&lt;br /&gt;(code: &lt;code&gt;scn&lt;/code&gt;)
| [[:sco:User:PK2/sandbox|/sandbox]] in [[:en:Scots language|Scots]]&lt;br /&gt;(code: &lt;code&gt;sco&lt;/code&gt;)
| [[:sd:User:PK2/مشق پٽي|/sandbox]] in [[:en:Sindhi language|Sindhi]]&lt;br /&gt;(code: &lt;code&gt;sd&lt;/code&gt;)
| [[:se:User:PK2/sandbox|/sandbox]] in [[:en:Northern Sámi|Northern Sámi]]&lt;br /&gt;(code: &lt;code&gt;se&lt;/code&gt;)
| [[:sg:User:PK2/sandbox|/sandbox]] in [[:en:Sango language|Sango]]&lt;br /&gt;(code: &lt;code&gt;sg&lt;/code&gt;)
| [[:sh:User:PK2/igralište|/sandbox]] in [[:en:Serbo-Croatian|Serbo-Croatian]]&lt;br /&gt;(code: &lt;code&gt;sh&lt;/code&gt;)
| [[:shi:User:PK2/sandbox|/sandbox]] in [[:en:Shilha language|Shilha]]&lt;br /&gt;(code: &lt;code&gt;shi&lt;/code&gt;)
|-
| [[:shn:User:PK2/sandbox|/sandbox]] in [[:en:Shan language|Shan]]&lt;br /&gt;(code: &lt;code&gt;shn&lt;/code&gt;)
| [[:si:User:PK2/sandbox|/sandbox]] in [[:en:Sinhala language|Sinhala]]&lt;br /&gt;(code: &lt;code&gt;si&lt;/code&gt;)
| [[:simple:User:PK2/sandbox|/sandbox]] in [[:en:Basic English|Basic English]]&lt;br /&gt;(code: &lt;code&gt;simple&lt;/code&gt;)
| [[:sk:User:PK2/pieskovisko|/sandbox]] in [[:en:Slovak language|Slovak]]&lt;br /&gt;(code: &lt;code&gt;sk&lt;/code&gt;)
| [[:skr:User:PK2/sandbox|/sandbox]] in [[:en:Saraiki language|Saraiki]]&lt;br /&gt;(code: &lt;code&gt;skr&lt;/code&gt;)
| [[:sl:User:PK2/sandbox|/sandbox]] in [[:en:Slovene language|Slovene]]&lt;br /&gt;(code: &lt;code&gt;sl&lt;/code&gt;)
| [[:sm:User:PK2/sandbox|/sandbox]] in [[:en:Samoan language|Samoan]]&lt;br /&gt;(code: &lt;code&gt;sm&lt;/code&gt;)
| [[:smn:User:PK2/sandbox|/sandbox]] in [[:en:Inari Sámi language|Inari Sámi]]&lt;br /&gt;(code: &lt;code&gt;smn&lt;/code&gt;)
| [[:sn:User:PK2/sandbox|/sandbox]] in [[:en:Shona language|Shona]]&lt;br /&gt;(code: &lt;code&gt;sn&lt;/code&gt;)
| [[:so:User:PK2/Bacaadka|/sandbox]] in [[:en:Somali language|Somali]]&lt;br /&gt;(code: &lt;code&gt;so&lt;/code&gt;)
| [[:sq:User:PK2/sandbox|/sandbox]] in [[:en:Albanian language|Albanian]]&lt;br /&gt;(code: &lt;code&gt;sq&lt;/code&gt;)
|-
| [[:sr:User:PK2/песак|/sandbox]] in [[:en:Serbian language|Serbian]]&lt;br /&gt;(code: &lt;code&gt;sr&lt;/code&gt;)
| [[:srn:User:PK2/sandbox|/sandbox]] in [[:en:Sranan Tongo|Sranan Tongo]]&lt;br /&gt;(code: &lt;code&gt;srn&lt;/code&gt;)
| [[:ss:User:PK2/sandbox|/sandbox]] in [[:en:Swazi language|Swazi]]&lt;br /&gt;(code: &lt;code&gt;ss&lt;/code&gt;)
| [[:st:User:PK2/sandbox|/sandbox]] in [[:en:Sotho language|Sotho]]&lt;br /&gt;(code: &lt;code&gt;st&lt;/code&gt;)
| [[:stq:User:PK2/sandbox|/sandbox]] in [[:en:Saterland Frisian language|Saterland Frisian]]&lt;br /&gt;(code: &lt;code&gt;stq&lt;/code&gt;)
| [[:su:User:PK2/sandbox|/sandbox]] in [[:en:Sundanese language|Sundanese]]&lt;br /&gt;(code: &lt;code&gt;su&lt;/code&gt;)
| [[:sv:User:PK2/sandlåda|/sandbox]] in [[:en:Swedish language|Swedish]]&lt;br /&gt;(code: &lt;code&gt;sv&lt;/code&gt;)
| [[:sw:User:PK2/ukurasa wa majaribio|/sandbox]] in [[:en:Swahili language|Swahili]]&lt;br /&gt;(code: &lt;code&gt;sw&lt;/code&gt;)
| [[:syl:User:PK2/sandbox|/sandbox]] in [[:en:Sylheti language|Sylheti]]&lt;br /&gt;(code: &lt;code&gt;syl&lt;/code&gt;)
| [[:szl:User:PK2/sandbox|/sandbox]] in [[:en:Silesian language|Silesian]]&lt;br /&gt;(code: &lt;code&gt;szl&lt;/code&gt;)
| [[:szy:User:PK2/sandbox|/sandbox]] in [[:en:Sakizaya language|Sakizaya]]&lt;br /&gt;(code: &lt;code&gt;szy&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ T
|-
| [[:ta:User:PK2/மணல்தொட்டி|/sandbox]] in [[:en:Tamil language|Tamil]]&lt;br /&gt;(code: &lt;code&gt;ta&lt;/code&gt;)
| [[:tay:User:PK2/sandbox|/sandbox]] in [[:en:Atayal language|Atayal]]&lt;br /&gt;(code: &lt;code&gt;tay&lt;/code&gt;)
| [[:tcy:User:PK2/ಕಲ್ಪುನ ಕಳ|/sandbox]] in [[:en:Tulu language|Tulu]]&lt;br /&gt;(code: &lt;code&gt;tcy&lt;/code&gt;)
| [[:tdd:User:PK2/sandbox|/sandbox]] in [[:en:Tai Nuea language|Tai Nuea]]&lt;br /&gt;(code: &lt;code&gt;tdd&lt;/code&gt;)
| [[:te:User:PK2/ప్రయోగశాల|/sandbox]] in [[:en:Telugu language|Telugu]]&lt;br /&gt;(code: &lt;code&gt;te&lt;/code&gt;)
| [[:tet:User:PK2/sandbox|/sandbox]] in [[:en:Tetum language|Tetum]]&lt;br /&gt;(code: &lt;code&gt;tet&lt;/code&gt;)
| [[:tg:User:PK2/Сиёҳнавис|/sandbox]] in [[:en:Tajik language|Tajik]]&lt;br /&gt;(code: &lt;code&gt;tg&lt;/code&gt;)
| [[:th:User:PK2/ทดลองเขียน|/sandbox]] in [[:en:Thai language|Thai]]&lt;br /&gt;(code: &lt;code&gt;th&lt;/code&gt;)
| [[:ti:User:PK2/sandbox|/sandbox]] in [[:en:Tigrinya language|Tigrinya]]&lt;br /&gt;(code: &lt;code&gt;ti&lt;/code&gt;)
| [[:tig:User:PK2/sandbox|/sandbox]] in [[:en:Tigre language|Tigre]]&lt;br /&gt;(code: &lt;code&gt;tig&lt;/code&gt;)
| [[:tk:User:PK2/sandbox|/sandbox]] in [[:en:Turkmen language|Turkmen]]&lt;br /&gt;(code: &lt;code&gt;tk&lt;/code&gt;)
| [[:tl:User:PK2/burador|/sandbox]] in [[:en:Tagalog language|Tagalog]]&lt;br /&gt;(code: &lt;code&gt;tl&lt;/code&gt;)
| [[:tly:User:PK2/sandbox|/sandbox]] in [[:en:Talysh language|Talysh]]&lt;br /&gt;(code: &lt;code&gt;tly&lt;/code&gt;)
|-
| [[:tn:User:PK2/sandbox|/sandbox]] in [[:en:Tswana language|Tswana]]&lt;br /&gt;(code: &lt;code&gt;tn&lt;/code&gt;)
| [[:to:User:PK2/sandbox|/sandbox]] in [[:en:Tongan language|Tongan]]&lt;br /&gt;(code: &lt;code&gt;to&lt;/code&gt;)
| [[:tok:User:PK2/sandbox|/sandbox]] in [[:en:Toki Pona|Toki Pona]]&lt;br /&gt;(code: &lt;code&gt;tok&lt;/code&gt;)
| [[:tpi:User:PK2/sandbox|/sandbox]] in [[:en:Tok Pisin|Tok Pisin]]&lt;br /&gt;(code: &lt;code&gt;tpi&lt;/code&gt;)
| [[:tr:User:PK2/deneme tahtası|/sandbox]] in [[:en:Turkish language|Turkish]]&lt;br /&gt;(code: &lt;code&gt;tr&lt;/code&gt;)
| [[:trv:User:PK2/sandbox|/sandbox]] in [[:en:Seediq language|Seediq]]&lt;br /&gt;(code: &lt;code&gt;trv&lt;/code&gt;)
| [[:ts:User:PK2/sandbox|/sandbox]] in [[:en:Tsonga language|Tsonga]]&lt;br /&gt;(code: &lt;code&gt;ts&lt;/code&gt;)
| [[:tt:User:PK2/sandbox|/sandbox]] in [[:en:Tatar language|Tatar]]&lt;br /&gt;(code: &lt;code&gt;tt&lt;/code&gt;)
| [[:tum:User:PK2/sandbox|/sandbox]] in [[:en:Tumbuka language|Tumbuka]]&lt;br /&gt;(code: &lt;code&gt;tum&lt;/code&gt;)
| [[:tw:User:PK2/sandbox|/sandbox]] in [[:en:Akan language|Akan]] (Twi)&lt;br /&gt;(code: &lt;code&gt;tw&lt;/code&gt;)
| [[:ty:User:PK2/sandbox|/sandbox]] in [[:en:Tahitian language|Tahitian]]&lt;br /&gt;(code: &lt;code&gt;ty&lt;/code&gt;)
| [[:tyv:User:PK2/sandbox|/sandbox]] in [[:en:Tuvan language|Tuvan]]&lt;br /&gt;(code: &lt;code&gt;tyv&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ U
|-
| [[:udm:User:PK2/sandbox|/sandbox]] in [[:en:Udmurt language|Udmurt]]&lt;br /&gt;(code: &lt;code&gt;udm&lt;/code&gt;)
| [[:ug:User:PK2/sandbox|/sandbox]] in [[:en:Uyghur language|Uyghur]]&lt;br /&gt;(code: &lt;code&gt;ug&lt;/code&gt;)
| [[:uk:User:PK2/Чернетка|/sandbox]] in [[:en:Ukrainian language|Ukrainian]]&lt;br /&gt;(code: &lt;code&gt;uk&lt;/code&gt;)
| [[:ur:User:PK2/تختۂ مشق|/sandbox]] in [[:en:Urdu|Urdu]]&lt;br /&gt;(code: &lt;code&gt;ur&lt;/code&gt;)
| [[:uz:User:PK2/qumloq|/sandbox]] in [[:en:Uzbek language|Uzbek]]&lt;br /&gt;(code: &lt;code&gt;uz&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ V
|-
| [[:ve:User:PK2/sandbox|/sandbox]] in [[:en:Venda language|Venda]]&lt;br /&gt;(code: &lt;code&gt;ve&lt;/code&gt;)
| [[:vec:User:PK2/sandbox|/sandbox]] in [[:en:Venetian language|Venetian]]&lt;br /&gt;(code: &lt;code&gt;vec&lt;/code&gt;)
| [[:vep:User:PK2/sandbox|/sandbox]] in [[:en:Veps language|Veps]]&lt;br /&gt;(code: &lt;code&gt;vep&lt;/code&gt;)
| [[:vi:User:PK2/nháp|/sandbox]] in [[:en:Vietnamese language|Vietnamese]]&lt;br /&gt;(code: &lt;code&gt;vi&lt;/code&gt;)
| [[:vls:User:PK2/sandbox|/sandbox]] in [[:en:West Flemish|West Flemish]]&lt;br /&gt;(code: &lt;code&gt;vls&lt;/code&gt;)
| [[:vo:User:PK2/sandbox|/sandbox]] in [[:en:Volapük|Volapük]]&lt;br /&gt;(code: &lt;code&gt;vo&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ W
|-
| [[:wa:User:PK2/sandbox|/sandbox]] in [[:en:Walloon language|Walloon]]&lt;br /&gt;(code: &lt;code&gt;wa&lt;/code&gt;)
| [[:war:User:PK2/sandbox|/sandbox]] in [[:en:Waray language|Waray]]&lt;br /&gt;(code: &lt;code&gt;war&lt;/code&gt;)
| [[:wo:User:PK2/sandbox|/sandbox]] in [[:en:Wolof language|Wolof]]&lt;br /&gt;(code: &lt;code&gt;wo&lt;/code&gt;)
| [[:wuu:User:PK2/sandbox|/sandbox]] in [[:en:Wu Chinese|Wu Chinese]]&lt;br /&gt;(code: &lt;code&gt;wuu&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ X
|-
| [[:xal:User:PK2/sandbox|/sandbox]] in [[:en:Oirat language|Oirat]] ([[:en:Kalmyk Oirat|Kalmyk Oirat]])&lt;br /&gt;(code: &lt;code&gt;xal&lt;/code&gt;)
| [[:xh:User:PK2/sandbox|/sandbox]] in [[:en:Xhosa language|Xhosa]]&lt;br /&gt;(code: &lt;code&gt;xh&lt;/code&gt;)
| [[:xmf:User:PK2/sandbox|/sandbox]] in [[:en:Mingrelian language|Mingrelian]]&lt;br /&gt;(code: &lt;code&gt;xmf&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ Y
|-
| [[:yi:User:PK2/sandbox|/sandbox]] in [[:en:Yiddish|Yiddish]]&lt;br /&gt;(code: &lt;code&gt;yi&lt;/code&gt;)
| [[:yo:User:PK2/sandbox|/sandbox]] in [[:en:Yoruba language|Yoruba]]&lt;br /&gt;(code: &lt;code&gt;yo&lt;/code&gt;)
|}

{| class=&quot;wikitable&quot; style=&quot;text-align: center; font-size:85%&quot;
|+ Z
|-
| [[:za:User:PK2/sandbox|/sandbox]] in [[:en:Zhuang languages|Zhuang]] ([[:en:Standard Zhuang|Standard Zhuang]])&lt;br /&gt;(code: &lt;code&gt;za&lt;/code&gt;)
| [[:zea:User:PK2/sandbox|/sandbox]] in [[:en:Zeelandic|Zeelandic]]&lt;br /&gt;(code: &lt;code&gt;zea&lt;/code&gt;)
| [[:zgh:User:PK2/sandbox|/sandbox]] in [[:en:Standard Moroccan Amazigh|Standard Moroccan Amazigh]]&lt;br /&gt;(code: &lt;code&gt;zgh&lt;/code&gt;)
| [[:zh:User:PK2/沙盒|/sandbox]] in [[:en:Chinese language|Chinese]] ([[:en:Mandarin Chinese|Mandarin Chinese]])&lt;br /&gt;(code: &lt;code&gt;zh&lt;/code&gt;)
| [[:zh-classical:User:PK2/sandbox|/sandbox]] in [[:en:Classical Chinese|Classical Chinese]]&lt;br /&gt;(code: &lt;code&gt;zh-classical&lt;/code&gt;)
| [[:zh-min-nan:User:PK2/sandbox|/sandbox]] in [[:en:Southern Min|Southern Min]]&lt;br /&gt;(code: &lt;code&gt;zh-min-nan&lt;/code&gt;)
| [[:zh-yue:User:PK2/sandbox|/sandbox]] in [[:en:Cantonese|Cantonese]]&lt;br /&gt;(code: &lt;code&gt;zh-yue&lt;/code&gt;)
| [[:zu:User:PK2/sandbox|/sandbox]] in [[:en:Zulu language|Zulu]]&lt;br /&gt;(code: &lt;code&gt;zu&lt;/code&gt;)
|}</text>
      <sha1>lqv4jf4ytbpqgk0b4c59pskg40l4i1p</sha1>
    </revision>
  </page>
  <page>
    <title>Khabi Vivian Mngoma</title>
    <ns>0</ns>
    <id>1019</id>
    <revision>
      <id>6111</id>
      <timestamp>2026-01-03T11:57:41Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1327941612|Khabi Vivian Mngoma]]&quot;</comment>
      <origin>6111</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3154" sha1="dxv93skzai2bg4c83a2sy2ek3j7szk7" xml:space="preserve">'''U-Khabi Vivian Mngoma''' (18 kuNobayeni 1922 – 21 kuNobayeni 1999) bekangumdlali we-tenor weSewula Afrika, umdlali wepiyano, umdosiphambili wekhwaya, begodu umuntu othoma ukufundisa umvumo wabantu abaNzima [[Isewula Afrika|eSewula Afrika]] . Uchazwa ngokuthi &quot;ngumuntu odume khulu emculweni begodu mthomisi wefundo yomvumo eSewula Afrika,&quot; godu ngubaba womvumi odumileko we-opera u-Sibongile Khumalo . 

== Ipilo yokuthoma nefundo ==
UKhabi Mngoma wabelethelwa e-Troyeville, [[Johannesburg|e-Goli]] . Wakhulela endaweni enomvumo begodu wavela ebabelethini abanesiphiwo somvumo. Unina, u-Agnes Matutu Nyembe, bekatitjhere esikolweni kuthi uyise, u-David Zwelonke Mngoma, bekangumdlali we-maskandi onekghono lokudlala i-concertina.  Waya e-Salvation Army Primary School (1930-1939), i-St Peter's Secondary School (1940-1942), i-Kilnerton Institution (1943-1944), kanye ne-Adams College (1945-1946), lapho athola khona idiploma yakhe yotitjhere ngo-1946. 

UMngoma naye waragela phambili nemfundo yakhe yomvumo. Ngemva kokuthola iimfundo zepiyano nokuvuma ku-RC Ellis no-Simon Ngubane, waragela phambili no-Anny Lambrechts (ukuvuma), u-Milton Oersen (ipiyano), u-Joseph Spira (u-violin), no-Joseph Trauneck (ukuqhuba). Wathoma nokufunda i-B.Mus. idigri e- UNISA . U-Mngoma uzuze amadiploma we-UTLM, UPLM, LRSM (womdlali notitjhere). 

== Umsebenzi wokuthoma ==
U-Mngoma wathoma ukufundisa e-Wilberforce Institute ne-Orlando High School ngaphambi kobana abe mphathi we-Community Center we-Chiawelo Community Center e-Johannesburg ngo-1953. Ngo-1957 waphakanyiswa waba yi-Cultural Activities Officer we-Recreation and Community Services we-Municipal Non-white Affair Department. Lapha bekanesibopho sokuhlela nokwethula amakilasi womvumo, ukufundisa iinsimbi nephimbo eenkhungweni zomphakathi wabantu abanzima kanye nokukhuthaza ukuthokozela umvumo hlangana nemiphakathi yabantu abanzima e-Goli. 


U-Mngoma wasungula i-Orlando Music Society (1948), i-Moroka Township Music Appreciation Group (1954), i-Ionian Male Voice Choir ne-Ionian Mixed Choir (1960), kanye ne-Jubilee String Players (1959), lokhu kokugcina kwaba yi-Black string ensemble yokuthoma e-Goli. Wabuye wadosa phambili ukusungulwa kwe-Syndicate of African Artists.[1] Ngaleso sikhathi wadlala njengomculi wedwa ne-Durban Civic kanye ne-Johannesburg Symphony Orchestras.[1][2]

== Uburholi nomsebenzi kamuva ==
Ngo-1967, u-Mngoma wathola i-United States Leader Exchange Grant lapho akhamba khona e-US. Nakabuyako waba nguMnqophisi we-Union Artists e- Dorkay House .  Ngo-1975, wabekwa njengoMfundisi Omkhulu noMphathi weMnyango weMvumo osanda kusungulwa eYunivesithi ye-Zululand . Lapha uzokudlala indima eqakathekileko ekwandiseni ukufikelela kwefundo yomvumo ehlelekileko yabafundi abanzima beSewula Afrika. 


Kanye nendima yakhe emnyangweni, u-Mngoma waba nomthelela omkhulu eemfundweni zomvumo ezikhungiweko ngeminyaka yabo-1980, asebenza njengomengameli wokuthoma we-South African Music Educator's Society begodu wagadangisa iingcenye ezinengi emajenali womculo we-South Africa.[1] Wathatha umhlalaphasi ngo-1987 kodwana waragela phambili nokuthonya ifundo yomvumo eSewula Afrika.[2]</text>
      <sha1>dxv93skzai2bg4c83a2sy2ek3j7szk7</sha1>
    </revision>
    <revision>
      <id>6112</id>
      <parentid>6111</parentid>
      <timestamp>2026-01-03T11:58:30Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6112</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3179" sha1="hef63nx4915obm3m9t3r411b5jmaq52" xml:space="preserve">'''U-Khabi Vivian Mngoma''' (18 kuNobayeni 1922 – 21 kuNobayeni 1999) bekangumdlali we-tenor weSewula Afrika, umdlali wepiyano, umdosiphambili wekhwaya, begodu umuntu othoma ukufundisa umvumo wabantu abaNzima [[Isewula Afrika|eSewula Afrika]] . Uchazwa ngokuthi &quot;ngumuntu odume khulu emculweni begodu mthomisi wefundo yomvumo eSewula Afrika,&quot; godu ngubaba womvumi odumileko we-opera u-Sibongile Khumalo . 

== Ipilo yokuthoma nefundo ==
UKhabi Mngoma wabelethelwa e-Troyeville, [[Johannesburg|e-Goli]] . Wakhulela endaweni enomvumo begodu wavela ebabelethini abanesiphiwo somvumo. Unina, u-Agnes Matutu Nyembe, bekatitjhere esikolweni kuthi uyise, u-David Zwelonke Mngoma, bekangumdlali we-maskandi onekghono lokudlala i-concertina.  Waya e-Salvation Army Primary School (1930-1939), i-St Peter's Secondary School (1940-1942), i-Kilnerton Institution (1943-1944), kanye ne-Adams College (1945-1946), lapho athola khona idiploma yakhe yotitjhere ngo-1946. 

UMngoma naye waragela phambili nemfundo yakhe yomvumo. Ngemva kokuthola iimfundo zepiyano nokuvuma ku-RC Ellis no-Simon Ngubane, waragela phambili no-Anny Lambrechts (ukuvuma), u-Milton Oersen (ipiyano), u-Joseph Spira (u-violin), no-Joseph Trauneck (ukuqhuba). Wathoma nokufunda i-B.Mus. idigri e- UNISA . U-Mngoma uzuze amadiploma we-UTLM, UPLM, LRSM (womdlali notitjhere). 

== Umsebenzi wokuthoma ==
U-Mngoma wathoma ukufundisa e-Wilberforce Institute ne-Orlando High School ngaphambi kobana abe mphathi we-Community Center we-Chiawelo Community Center e-Johannesburg ngo-1953. Ngo-1957 waphakanyiswa waba yi-Cultural Activities Officer we-Recreation and Community Services we-Municipal Non-white Affair Department. Lapha bekanesibopho sokuhlela nokwethula amakilasi womvumo, ukufundisa iinsimbi nephimbo eenkhungweni zomphakathi wabantu abanzima kanye nokukhuthaza ukuthokozela umvumo hlangana nemiphakathi yabantu abanzima e-Goli. 


U-Mngoma wasungula i-Orlando Music Society (1948), i-Moroka Township Music Appreciation Group (1954), i-Ionian Male Voice Choir ne-Ionian Mixed Choir (1960), kanye ne-Jubilee String Players (1959), lokhu kokugcina kwaba yi-Black string ensemble yokuthoma e-Goli. Wabuye wadosa phambili ukusungulwa kwe-Syndicate of African Artists.[1] Ngaleso sikhathi wadlala njengomculi wedwa ne-Durban Civic kanye ne-Johannesburg Symphony Orchestras.[1][2]

== Uburholi nomsebenzi kamuva ==
Ngo-1967, u-Mngoma wathola i-United States Leader Exchange Grant lapho akhamba khona e-US. Nakabuyako waba nguMnqophisi we-Union Artists e- Dorkay House .  Ngo-1975, wabekwa njengoMfundisi Omkhulu noMphathi weMnyango weMvumo osanda kusungulwa eYunivesithi ye-Zululand . Lapha uzokudlala indima eqakathekileko ekwandiseni ukufikelela kwefundo yomvumo ehlelekileko yabafundi abanzima beSewula Afrika. 


Kanye nendima yakhe emnyangweni, u-Mngoma waba nomthelela omkhulu eemfundweni zomvumo ezikhungiweko ngeminyaka yabo-1980, asebenza njengomengameli wokuthoma we-South African Music Educator's Society begodu wagadangisa iingcenye ezinengi emajenali womculo we-South Africa.[1] Wathatha umhlalaphasi ngo-1987 kodwana waragela phambili nokuthonya ifundo yomvumo eSewula Afrika.[2]
==Iikhomba==
{{reflist}}</text>
      <sha1>hef63nx4915obm3m9t3r411b5jmaq52</sha1>
    </revision>
    <revision>
      <id>6113</id>
      <parentid>6112</parentid>
      <timestamp>2026-01-03T11:59:22Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6113</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3205" sha1="g6uyscnm1v16bub2vrma87byj8sth3g" xml:space="preserve">'''U-Khabi Vivian Mngoma''' (18 kuNobayeni 1922 – 21 kuNobayeni 1999) bekangumdlali we-tenor weSewula Afrika, umdlali wepiyano, umdosiphambili wekhwaya, begodu umuntu othoma ukufundisa umvumo wabantu abaNzima [[Isewula Afrika|eSewula Afrika]] . Uchazwa ngokuthi &quot;ngumuntu odume khulu emculweni begodu mthomisi wefundo yomvumo eSewula Afrika,&quot; godu ngubaba womvumi odumileko we-opera u-Sibongile Khumalo . 

== Ipilo yokuthoma nefundo ==
UKhabi Mngoma wabelethelwa e-Troyeville, [[Johannesburg|e-Goli]] . Wakhulela endaweni enomvumo begodu wavela ebabelethini abanesiphiwo somvumo. Unina, u-Agnes Matutu Nyembe, bekatitjhere esikolweni kuthi uyise, u-David Zwelonke Mngoma, bekangumdlali we-maskandi onekghono lokudlala i-concertina.  Waya e-Salvation Army Primary School (1930-1939), i-St Peter's Secondary School (1940-1942), i-Kilnerton Institution (1943-1944), kanye ne-Adams College (1945-1946), lapho athola khona idiploma yakhe yotitjhere ngo-1946. 

UMngoma naye waragela phambili nemfundo yakhe yomvumo. Ngemva kokuthola iimfundo zepiyano nokuvuma ku-RC Ellis no-Simon Ngubane, waragela phambili no-Anny Lambrechts (ukuvuma), u-Milton Oersen (ipiyano), u-Joseph Spira (u-violin), no-Joseph Trauneck (ukuqhuba). Wathoma nokufunda i-B.Mus. idigri e- UNISA . U-Mngoma uzuze amadiploma we-UTLM, UPLM, LRSM (womdlali notitjhere). 

== Umsebenzi wokuthoma ==
U-Mngoma wathoma ukufundisa e-Wilberforce Institute ne-Orlando High School ngaphambi kobana abe mphathi we-Community Center we-Chiawelo Community Center e-Johannesburg ngo-1953. Ngo-1957 waphakanyiswa waba yi-Cultural Activities Officer we-Recreation and Community Services we-Municipal Non-white Affair Department. Lapha bekanesibopho sokuhlela nokwethula amakilasi womvumo, ukufundisa iinsimbi nephimbo eenkhungweni zomphakathi wabantu abanzima kanye nokukhuthaza ukuthokozela umvumo hlangana nemiphakathi yabantu abanzima e-Goli. 

U-Mngoma wasungula i-Orlando Music Society (1948), i-Moroka Township Music Appreciation Group (1954), i-Ionian Male Voice Choir ne-Ionian Mixed Choir (1960), kanye ne-Jubilee String Players (1959), lokhu kokugcina kwaba yi-Black string ensemble yokuthoma e-Goli. Wabuye wadosa phambili ukusungulwa kwe-Syndicate of African Artists.[1] Ngaleso sikhathi wadlala njengomculi wedwa ne-Durban Civic kanye ne-Johannesburg Symphony Orchestras.[1][2]

== Uburholi nomsebenzi kamuva ==
Ngo-1967, u-Mngoma wathola i-United States Leader Exchange Grant lapho akhamba khona e-US. Nakabuyako waba nguMnqophisi we-Union Artists e- Dorkay House .  Ngo-1975, wabekwa njengoMfundisi Omkhulu noMphathi weMnyango weMvumo osanda kusungulwa eYunivesithi ye-Zululand . Lapha uzokudlala indima eqakathekileko ekwandiseni ukufikelela kwefundo yomvumo ehlelekileko yabafundi abanzima beSewula Afrika. 

Kanye nendima yakhe emnyangweni, u-Mngoma waba nomthelela omkhulu eemfundweni zomvumo ezikhungiweko ngeminyaka yabo-1980, asebenza njengomengameli wokuthoma we-South African Music Educator's Society begodu wagadangisa iingcenye ezinengi emajenali womculo we-South Africa.[1] Wathatha umhlalaphasi ngo-1987 kodwana waragela phambili nokuthonya ifundo yomvumo eSewula Afrika.[2]
==Iikhomba==
{{reflist}}
[[Category:iSewula Afrika]]</text>
      <sha1>g6uyscnm1v16bub2vrma87byj8sth3g</sha1>
    </revision>
    <revision>
      <id>6114</id>
      <parentid>6113</parentid>
      <timestamp>2026-01-03T11:59:48Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6114</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3230" sha1="gzweo5d37puy3fekeci3m2615yisxwd" xml:space="preserve">'''U-Khabi Vivian Mngoma''' (18 kuNobayeni 1922 – 21 kuNobayeni 1999) bekangumdlali we-tenor weSewula Afrika, umdlali wepiyano, umdosiphambili wekhwaya, begodu umuntu othoma ukufundisa umvumo wabantu abaNzima [[Isewula Afrika|eSewula Afrika]] . Uchazwa ngokuthi &quot;ngumuntu odume khulu emculweni begodu mthomisi wefundo yomvumo eSewula Afrika,&quot; godu ngubaba womvumi odumileko we-opera u-Sibongile Khumalo . 

== Ipilo yokuthoma nefundo ==
UKhabi Mngoma wabelethelwa e-Troyeville, [[Johannesburg|e-Goli]] . Wakhulela endaweni enomvumo begodu wavela ebabelethini abanesiphiwo somvumo. Unina, u-Agnes Matutu Nyembe, bekatitjhere esikolweni kuthi uyise, u-David Zwelonke Mngoma, bekangumdlali we-maskandi onekghono lokudlala i-concertina.  Waya e-Salvation Army Primary School (1930-1939), i-St Peter's Secondary School (1940-1942), i-Kilnerton Institution (1943-1944), kanye ne-Adams College (1945-1946), lapho athola khona idiploma yakhe yotitjhere ngo-1946. 

UMngoma naye waragela phambili nemfundo yakhe yomvumo. Ngemva kokuthola iimfundo zepiyano nokuvuma ku-RC Ellis no-Simon Ngubane, waragela phambili no-Anny Lambrechts (ukuvuma), u-Milton Oersen (ipiyano), u-Joseph Spira (u-violin), no-Joseph Trauneck (ukuqhuba). Wathoma nokufunda i-B.Mus. idigri e- UNISA . U-Mngoma uzuze amadiploma we-UTLM, UPLM, LRSM (womdlali notitjhere). 

== Umsebenzi wokuthoma ==
U-Mngoma wathoma ukufundisa e-Wilberforce Institute ne-Orlando High School ngaphambi kobana abe mphathi we-Community Center we-Chiawelo Community Center e-Johannesburg ngo-1953. Ngo-1957 waphakanyiswa waba yi-Cultural Activities Officer we-Recreation and Community Services we-Municipal Non-white Affair Department. Lapha bekanesibopho sokuhlela nokwethula amakilasi womvumo, ukufundisa iinsimbi nephimbo eenkhungweni zomphakathi wabantu abanzima kanye nokukhuthaza ukuthokozela umvumo hlangana nemiphakathi yabantu abanzima e-Goli. 

U-Mngoma wasungula i-Orlando Music Society (1948), i-Moroka Township Music Appreciation Group (1954), i-Ionian Male Voice Choir ne-Ionian Mixed Choir (1960), kanye ne-Jubilee String Players (1959), lokhu kokugcina kwaba yi-Black string ensemble yokuthoma e-Goli. Wabuye wadosa phambili ukusungulwa kwe-Syndicate of African Artists.[1] Ngaleso sikhathi wadlala njengomculi wedwa ne-Durban Civic kanye ne-Johannesburg Symphony Orchestras.[1][2]

== Uburholi nomsebenzi kamuva ==
Ngo-1967, u-Mngoma wathola i-United States Leader Exchange Grant lapho akhamba khona e-US. Nakabuyako waba nguMnqophisi we-Union Artists e- Dorkay House .  Ngo-1975, wabekwa njengoMfundisi Omkhulu noMphathi weMnyango weMvumo osanda kusungulwa eYunivesithi ye-Zululand . Lapha uzokudlala indima eqakathekileko ekwandiseni ukufikelela kwefundo yomvumo ehlelekileko yabafundi abanzima beSewula Afrika. 

Kanye nendima yakhe emnyangweni, u-Mngoma waba nomthelela omkhulu eemfundweni zomvumo ezikhungiweko ngeminyaka yabo-1980, asebenza njengomengameli wokuthoma we-South African Music Educator's Society begodu wagadangisa iingcenye ezinengi emajenali womculo we-South Africa.[1] Wathatha umhlalaphasi ngo-1987 kodwana waragela phambili nokuthonya ifundo yomvumo eSewula Afrika.[2]
==Iikhomba==
{{reflist}}
[[Category:iSewula Afrika]]
[[Category:abosaziwako]]</text>
      <sha1>gzweo5d37puy3fekeci3m2615yisxwd</sha1>
    </revision>
    <revision>
      <id>6115</id>
      <parentid>6114</parentid>
      <timestamp>2026-01-03T12:01:23Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6115</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3245" sha1="q9cbajf5xpgcswygn0tkzm8kpquu6ab" xml:space="preserve">'''U-Khabi Vivian Mngoma''' (18 kuNobayeni 1922 – 21 kuNobayeni 1999) bekangumdlali we-tenor weSewula Afrika, umdlali wepiyano, umdosiphambili wekhwaya, begodu umuntu othoma ukufundisa umvumo wabantu abaNzima [[Isewula Afrika|eSewula Afrika]] . Uchazwa ngokuthi &quot;ngumuntu odume khulu emculweni begodu mthomisi wefundo yomvumo eSewula Afrika,&quot; godu ngubaba womvumi odumileko we-opera u-[[Sibongile Khumalo]] . 

== Ipilo yokuthoma nefundo ==
UKhabi Mngoma wabelethelwa e-Troyeville, [[Johannesburg|e-Goli]] . Wakhulela endaweni enomvumo begodu wavela ebabelethini abanesiphiwo somvumo. Unina, u-Agnes Matutu Nyembe, bekatitjhere esikolweni kuthi uyise, u-David Zwelonke Mngoma, bekangumdlali we-maskandi onekghono lokudlala i-concertina.  Waya e-Salvation Army Primary School (1930-1939), i-St Peter's Secondary School (1940-1942), i-Kilnerton Institution (1943-1944), kanye ne-Adams College (1945-1946), lapho athola khona idiploma yakhe yotitjhere ngo-1946. 

UMngoma naye waragela phambili nemfundo yakhe yomvumo. Ngemva kokuthola iimfundo zepiyano nokuvuma ku-RC Ellis no-Simon Ngubane, waragela phambili no-Anny Lambrechts (ukuvuma), u-Milton Oersen (ipiyano), u-Joseph Spira (u-violin), no-Joseph Trauneck (ukuqhuba). Wathoma nokufunda i-B.Mus. idigri e- UNISA . U-Mngoma uzuze amadiploma we-UTLM, UPLM, LRSM (womdlali notitjhere). 

== Umsebenzi wokuthoma ==
U-Mngoma wathoma ukufundisa e-Wilberforce Institute ne-Orlando High School ngaphambi kobana abe mphathi we-Community Center we-[[Soweto|Chiawelo]] Community Center e-Johannesburg ngo-1953. Ngo-1957 waphakanyiswa waba yi-Cultural Activities Officer we-Recreation and Community Services we-Municipal Non-white Affair Department. Lapha bekanesibopho sokuhlela nokwethula amakilasi womvumo, ukufundisa iinsimbi nephimbo eenkhungweni zomphakathi wabantu abanzima kanye nokukhuthaza ukuthokozela umvumo hlangana nemiphakathi yabantu abanzima e-Goli. 

U-Mngoma wasungula i-Orlando Music Society (1948), i-Moroka Township Music Appreciation Group (1954), i-Ionian Male Voice Choir ne-Ionian Mixed Choir (1960), kanye ne-Jubilee String Players (1959), lokhu kokugcina kwaba yi-Black string ensemble yokuthoma e-Goli. Wabuye wadosa phambili ukusungulwa kwe-Syndicate of African Artists.[1] Ngaleso sikhathi wadlala njengomculi wedwa ne-Durban Civic kanye ne-Johannesburg Symphony Orchestras.[1][2]

== Uburholi nomsebenzi kamuva ==
Ngo-1967, u-Mngoma wathola i-United States Leader Exchange Grant lapho akhamba khona e-US. Nakabuyako waba nguMnqophisi we-Union Artists e- Dorkay House .  Ngo-1975, wabekwa njengoMfundisi Omkhulu noMphathi weMnyango weMvumo osanda kusungulwa eYunivesithi ye-Zululand . Lapha uzokudlala indima eqakathekileko ekwandiseni ukufikelela kwefundo yomvumo ehlelekileko yabafundi abanzima beSewula Afrika. 

Kanye nendima yakhe emnyangweni, u-Mngoma waba nomthelela omkhulu eemfundweni zomvumo ezikhungiweko ngeminyaka yabo-1980, asebenza njengomengameli wokuthoma we-South African Music Educator's Society begodu wagadangisa iingcenye ezinengi emajenali womculo we-South Africa.[1] Wathatha umhlalaphasi ngo-1987 kodwana waragela phambili nokuthonya ifundo yomvumo eSewula Afrika.[2]
==Iikhomba==
{{reflist}}
[[Category:iSewula Afrika]]
[[Category:abosaziwako]]</text>
      <sha1>q9cbajf5xpgcswygn0tkzm8kpquu6ab</sha1>
    </revision>
  </page>
  <page>
    <title>Mark Armstrong (YouTuber)</title>
    <ns>0</ns>
    <id>1021</id>
    <revision>
      <id>6118</id>
      <timestamp>2026-01-06T17:10:23Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1331503466|Mark Armstrong (YouTuber)]]&quot;</comment>
      <origin>6118</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1595" sha1="jxfrtxc4f7p83ncgm4sznnyico5nahp" xml:space="preserve">'''U-Mat Armstrong''' (wabelethwa mhlana ali-11 kuMgwengweni wee-1993) mhlali we-YouTube we-Britain nomsunguli wezinto eziphathelene neenkoloyi owaziwa ngamavidiyo wakhe wokuvuselela iinkoloyi nokwakha kabutjha.  Wathola ukuhlonitjhwa okukhulu ngokutlola ikambiso yokulungisa nokutjhugulula iinkoloyi ezilimeleko ezibizako nezisebenzako, odosa iingidigidi zababhalisile esiteshini sakhe se-YouTube . Okuqukethwe ngu-Armstrong kuhlanganisa amakghono wemitjhini, ukucoca iindaba, nokuzithabisa, okuthabisa abathandi beenkoloyi ephasini loke.  &lt;ref&gt;https://supercarblondie.com/mat-armstrong-annoyed-at-bugatti-went-hypercar-shopping/ &lt;/ref&gt;

== Ipilo yokuthoma kanye nesendlalelo ==
U-Mat Armstrong wabelethwa e- Leicester, e-England . Ngaphambi kobana abe msunguli wesikhathi esizeleko we-inthanethi, waragela phambili nomsebenzi we-BMX begodu ngokukhamba kwesikhathi wasebenza emisebenzini ehlukahlukeneko, kufaka hlangana umsebenzi wemitjhini nokuphathwa kwemithombo yezokuthintana, okwasiza ukubumba ikareko yakhe ngeenkoloyi nokudala okumumethweko. 


U-Armstrong wethula isiteshi sakhe se-YouTube ngo-2013, ekuthomeni bekanezinto ezihlobene ne-BMX ngaphambi kobana atjhugulukele kumavidiyo weenkoloyi. Umnqopho wakhe watjhugulukela ekubuyiseleni iinkoloyi ezibizako ezilimeleko nezibhaliweko ezivela emabhrendi afana ne-Audi, i-Bentley, i-Lamborghini, i-Porsche, ne-Maserati. Uchungechunge lwakhe lokubuyisela oluthakazelisayo, oluvamise ukufaka hlangana iindlela zokulungisa eziyinkimbinkimbi namaphrojekthi amakhulu, kwaba nomthelela omkhulu ekukhuleni kwakhe ku-inthanethi.

== Iinkomba ==</text>
      <sha1>jxfrtxc4f7p83ncgm4sznnyico5nahp</sha1>
    </revision>
  </page>
  <page>
    <title>U-Autshumato</title>
    <ns>0</ns>
    <id>1022</id>
    <revision>
      <id>6130</id>
      <timestamp>2026-01-16T11:31:38Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>New article</comment>
      <origin>6130</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8444" sha1="i7c2hwx0k1oy20lqe1k5dhaxrpvk7wi" xml:space="preserve">[[Isimumathi:Homo sapiens - Khoikhoi, Zuid-Afrika - 1700-1880 - Print - Iconographia Zoologica - Special Collections University of Amsterdam - UBA01 IZ19400109.tif|thumb|363x363px|Isithombe se-Khoekhoe]]
'''U-Autshumato namkha u-Autshumao,''' (c. 1610-1663) amaDatjhi ebebamazi ngo-''Harry die Strandloper'', bekayikosi yesitjhaba sama-Khoekhoe ( namkha ama-Khoekhoe) ebesibizwa bona ma-Gorinhaikona ebesihlala endaweni yeKapa lakade, amaDatjhi awayibiza nge-''Cape of Good Hope.'' Ngesikhathi amaDatjhi afika, umuntu wokuthoma ukubamukela bekungu-Autshumao nabantu bakhe. Ngikho nje amaDatjhi bebababiza ngokuthi ma-Strandloper ngombana babathola bakhamba eligwini lelwandle. Kusukela bathoma ukubonana bathoma nokurhwebelana.&lt;ref name=&quot;:5&quot;&gt;Steemit Website (2018) ''SOUTH AFRICAN HISTORY: Autshumato translator and first Postmaster of The Cape of Good Hope''. Retrieved from: https://steemit.com/history/@krabgat/south-african-history-autshumato-translator-and-first-postmaster-of-the-cape-of-good-hope. Retrieved on 14/01/2026.&lt;/ref&gt;&lt;ref name=&quot;:4&quot;&gt;Camissa Museum (2026) ''Autshumao (1610 - 1674)'', Retrieved from: https://camissamuseum.co.za/index.php/7-tributaries/1-cape-indigenous-africans/autshumao. Retrieved on 12/01/2026.&lt;/ref&gt; 

Into eyenza bona u-Autshumato aqakatheke emlandweni weSewula Afrika kukuthi zinengi izinto ezenzeka epilwenakhe ezivala isikhala somlando wokusebenzelana kwabantu abanzima nabamhlophe eSewula Afrika. U-Autsumato wasebenzelana nabantu ebebeza ngemikhumbi eKapa ngombana bekakwazi ukukhulumisana nabo ngesiNgisi, isiDatjhi, isiPutukezi nesiFrentji,&lt;ref name=&quot;:4&quot; /&gt; begodu ukusebenzelana kwakhe nabo kwaba nemiphumela ehlala isikhathi eside, esesekhona bekube namhlanjesi.&lt;ref&gt;Britnnica Kids (2026) ''Autshumato,'' Britannica Kids website. Retrieved from: https://kids.britannica.com/kids/article/Autshumato/601918. Retrieved on 15/01/2026.&lt;/ref&gt;

== Ipilwakhe Ngaphambi Kokufika KwamaDatjhi ==
[[Isimumathi:Khoikhoi_Hottentot_p197.jpg|thumb|Ama-Khoekhoe]]
Kungenzeka u-Autshumato wabelethwa ngabo-1610 endaweni yeKapa ebeyibizwa bona yi-''Cape of Good Hope''. Bekayikosi yesitjhaba sama-Gorinhaikona, esima-Khoekhoe.&lt;ref name=&quot;:5&quot; /&gt; Ibizo lakhe lokubelethwa bekungu-Arri, njengombana nezibulo lakhe igama lalo lingu-Arri. U-Autshumato (okutjho ukuthi &quot;loyo othaya neemfesi,  ''ǀAu-tsâma-ao'') bekulibizo ebebambongelela ngalo, ngebanga lokuthi bekathaya emanzini ngendlela erarako, aduda ngasuthi yifesi.&lt;ref name=&quot;:4&quot; /&gt; 

Ngabo-1630 wathathwa maNgisi amusa e-Bantam eNgilandi bona ambandulele ukuba mkhulumeli wabantu abeza ngemikhumbi yamaNgisi. Ngibo abamupha negama lika-Harry. Kulapho afunda khona ukukhuluma isiNgisi nesiDatjhi. Kubonakala ngasuthi watjhinga ne-Batavia&lt;ref name=&quot;:5&quot; /&gt;.  Wathi nakabuya eKapa ngo-1931, yena nabalandeli bakhe bavula isitetjhi sokurhweba e-''Robben Island.'' Bekuthi imikhumbi nayifikako, ambathe iimpahla ezimbathwa maYurobhu, akhulume nabokapteni bemikhumbi ngesibindi. Lokho, kwenza u-Autshumato wabizwa ngokobana yi-'Governor' maNgisi namaFrentji.&lt;ref name=&quot;:4&quot; /&gt; 

Kwaba nelinye godu ibanga elenza bona amaNgisi amthathe amuse e-''Robben Island'' ''.'' U-Autshumato besele arhitjhene nezinye iintjhaba zama-Khoekhoe. Wabawa umkhumbi wamaNgisi ebewudlula endaweni leyo bona uthathe yena nabalandeli bakhe  basiwe e-''Robben Island,'' nangambala kwaba njalo. Esikhathineso u-Autshumato wasebenziswa njengeposo yemikhumbi yamaYurobhu. Kungenzeka isiFrentji nesiPutukezi wazifunda lapho. Kwathi ngemva kweminyaka ebunane, ngabo-1940 wabuya, ngombana irarano liphelile.&lt;ref name=&quot;:5&quot; /&gt;  Babuya esihlengehlengeni beza enarheni eKapa, lapha kuhlangana khona umlambo i-''Camissa River'' nelwandle. Yena nomndenakhe ngibo ebebaphethe isitetjhi sokurhwebelana i-''‖Ammaqua'' (okutjho bona Abantu bemanzini) okulibizo u-Jan Van Riebeeck ebekababiza ngalo ekuthomeni.&lt;ref name=&quot;:3&quot;&gt;Roben Island Museum (13 May 2017) ''Autshumato''. Retrieved from: http://www.robben-island.org.za/departments/heritage/gallery/autshumato.asp. Retrieved on 14/01/2026.&lt;/ref&gt;&lt;ref name=&quot;:4&quot; /&gt;

== Ipilwakhe Ngemva Kokufika KwamaDatjhi ==
[[Isimumathi:Jan van Riebeeck .jpg|thumb|U-Autshumato wamukela u-Jan Van Riebeeck]]
Afika amaDatjhi ngo-1652 ngemikhumbi yawo emihlanu, i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch.'' Ukuthoma kokufika kwamaDatjhi eKapa (''Cape of Good Hope'') khenge kubamangaze abantu bendabuko bendawo leyo ama-Khoekhoe. AmaDatjhi afika nje ama-Khoekhoe besele kukade arhwebelana namaNgisi, amaPutukezi namaFrentji. Nangaphezu kokufika kuka-Van Riebeeck, ngokuya kuka-Knox‑Johnson, phakathi nomnyaka wabo-1600 kuya ku-1700, besele kudlule imikhumbi yamaDatjhi eyi-1 730. Yeke ama-Khoekhoe bekangawaqabuki amaDatjhi ngesikhatheso.&lt;ref&gt;Helen Swingler (22 September 2021) ''Heritage Month: The Khoi encountered Europeans long before Van Riebeeck,'' University of Cape Town News. Retrieved from: https://www.news.uct.ac.za/article/-2021-09-22-the-khoi-encountered-europeans-long-before-van-riebeeck. Retrieved on 12/01/2026.&lt;/ref&gt;

Endabeni yokurhwebelana, zoke izinto ebezenzeka u-Jan Van Riebeeck wazitlola emajenalini wakhe. AmaDatjhi bewathenga iinkomo nezimvu kuma-Khoekhoe ngepahla ehlukahlukeneko kuhlanganise notjwala negwayi. Bese inyama yefuyo le idliwe, enye ithengiselwe abantu abadlula ngemikhumbi yekhamphani.&lt;ref name=&quot;:5&quot; /&gt;

Kwathi ngenyanga kaSewula wango-1653 kwaba nokurhitjhana phakathi kuka-Autshumato nomelusi weenkomo zika-Van Riebeeck u-David Jansz. U-Autshumato wambulala wathatha iinkomo. Ukurhitjhanokhu kuthoma nje, iintjhaba ezimbili lezi besele zingasathelelani kuhle amanzi. AmaDatjhi besele aqala u-Autshumato nabantu bakhe njengamasela. U-Jan Van Riebeeck wathi u-Autshumato lisela elinelimi elibutjhelelezi. Ama-Khoekhoe aqala amaDatjhi njengabakhohlisi ngokuthi intengo yotjwala negwayi ayilingani nentengo yesilwana esifuywako. Bebathi bangabusela utjwala buphele, babone ifuywabo emadlelweni wamaDatjhi, yanda. Bese amaKhoekhoe akhambe ayoyeba.&lt;ref&gt;Castle of Good Hope (''13th November 2018'') ''Interpreters' Flawed Contracts With Dutch''Retrieved from: https://www.castleofgoodhope.co.za/index.php/news/100-news/142-interpreters-flawed-contracts-with-dutch. Retrieved on 14/01/2026.&lt;/ref&gt;

Isenzakalo sokubulawa kuka-David Jansz sasusa ipi phakathi kwama-Khoe namaDatjhi. U-Van RieBeeck wathi u-Autshumato unomlandu wokubulala. Yeke kwaliwa ipi, ekugcineni ama-Khoe ahlulwa. U-Autshumato wabanjwa wasiwa ekuthunjweni e-''Robben Island'' ngawo umnyaka ka-1653. Kodwana ngo-1655 watjhatjululwa wabuyiswa enarheni.  Nakafikako u-Jan Van Riebeeck wamamukela wambuyisela esikhundleni sakhe sokutologa.&lt;ref name=&quot;:5&quot; /&gt;  Ngesikhathesi u-Autshumato besele azwisisa indlela amaYurobhu arhweba ngayo nendlela yokuzuza kiyo. Bekathi nakarhwebela u-Jan Van Riebeeck iinkomo, aqiniseke bona imbadelo yekhamphani yanele bona ingabhadela neenkomo azithengela zona yena, ngikho nje aba mumuntu oregileko eKapa.&lt;ref name=&quot;:5&quot; /&gt; 

Ngokukhamba kwesikhathi kwaba nokhunye godu ukurhitjhana phakathi kwama-Khoekhoe namaDatjhi ngo-1657. Ukurhitjhanokhu kubangwa kungazwani kwama-''Free Burghers (Vry Burgers)''  neengqila ze-Madagascar.  U-Jan Van Riebeeck wakateleleka bona akhe isivikelo endaweni leyo, bona enze ama-Khoekhoe asuke endaweni leyo. Bekuthi ezinye iingqila naziphunyurhako asebenzise u-Autshumato njengesithunjwa ukuhlohlozela ama-Khoe bona akhambe ayokubamba iingqilezo. Kodwana iqhinga lika-Van Riebeeck khenge liphumelele ngendlela afuna ngayo. Kwathi ngo-1658 u-Autshumato wabanjwa, wathathelwa yoke ifuywakhe. Ngemva kokutjhutjhiswa wathunjwa wasiwa e-''Robben Island'' godu. Kodwana wathi nakalapho waphunyurha ngesikepe esivuzako. Bekube kunamhlanjesi, u-Autshumato nguye kwaphela umuntu okghone ukuphunyurha e-''Robben Island'' njengesibotjhwa. Kunokuthi nakabuyako enarheni abotjhwe, u-Van Riebeeck wambuyisela esikhundleni sakhe sokukhulumisana nokutologa.&lt;ref name=&quot;:5&quot; /&gt;&lt;ref name=&quot;:4&quot; /&gt; 

Ubuhlobo bamaDatjhi nama-Khoekhoe bebuhlala bunemiraro kangangobana amaDatjhi abatjhidisela kude nendawo abakiyo. U-Autshumato waragela phambili nokufuya nokurhwebelana nabakhambi namaDatjhi bekwaba sekufeni kwakhe ngo-1663, ngemva komnyaka u-Jan Van Riebeeck akhambile. Ngo-1713 u-Francois Valentyn wabika bona isitjhaba sama-Gorinhaikona besele singasabonakali endaweni leyo. Uthi kungenzeka baqedwe bulwele bepokisi obarhagala ngo-1713.&lt;ref name=&quot;:5&quot; /&gt; 

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>i7c2hwx0k1oy20lqe1k5dhaxrpvk7wi</sha1>
    </revision>
    <revision>
      <id>6163</id>
      <parentid>6130</parentid>
      <timestamp>2026-02-11T15:46:13Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>edited</comment>
      <origin>6163</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8445" sha1="0442dch5i8ix0vlvcgpjgd88mkastgt" xml:space="preserve">[[Isimumathi:Homo sapiens - Khoikhoi, Zuid-Afrika - 1700-1880 - Print - Iconographia Zoologica - Special Collections University of Amsterdam - UBA01 IZ19400109.tif|thumb|363x363px|Isithombe se-Khoekhoe]]
'''U-Autshumato namkha u-Autshumao,''' (c. 1610-1663) amaDatjhi ebebamazi ngo-''Harry die Strandloper'', bekayikosi yesitjhaba sama-Khoekhoe ( namkha ama-Khoekhoe) ebesibizwa bona ma-Goringhaicona ebesihlala endaweni yeKapa lakade, amaDatjhi awayibiza nge-''Cape of Good Hope.'' Ngesikhathi amaDatjhi afika, umuntu wokuthoma ukubamukela bekungu-Autshumao nabantu bakhe. Ngikho nje amaDatjhi bebababiza ngokuthi ma-Strandloper ngombana babathola bakhamba eligwini lelwandle. Kusukela bathoma ukubonana bathoma nokurhwebelana.&lt;ref name=&quot;:5&quot;&gt;Steemit Website (2018) ''SOUTH AFRICAN HISTORY: Autshumato translator and first Postmaster of The Cape of Good Hope''. Retrieved from: https://steemit.com/history/@krabgat/south-african-history-autshumato-translator-and-first-postmaster-of-the-cape-of-good-hope. Retrieved on 14/01/2026.&lt;/ref&gt;&lt;ref name=&quot;:4&quot;&gt;Camissa Museum (2026) ''Autshumao (1610 - 1674)'', Retrieved from: https://camissamuseum.co.za/index.php/7-tributaries/1-cape-indigenous-africans/autshumao. Retrieved on 12/01/2026.&lt;/ref&gt; 

Into eyenza bona u-Autshumato aqakatheke emlandweni weSewula Afrika kukuthi zinengi izinto ezenzeka epilwenakhe ezivala isikhala somlando wokusebenzelana kwabantu abanzima nabamhlophe eSewula Afrika. U-Autsumato wasebenzelana nabantu ebebeza ngemikhumbi eKapa ngombana bekakwazi ukukhulumisana nabo ngesiNgisi, isiDatjhi, isiPutukezi nesiFrentji,&lt;ref name=&quot;:4&quot; /&gt; begodu ukusebenzelana kwakhe nabo kwaba nemiphumela ehlala isikhathi eside, esesekhona bekube namhlanjesi.&lt;ref&gt;Britnnica Kids (2026) ''Autshumato,'' Britannica Kids website. Retrieved from: https://kids.britannica.com/kids/article/Autshumato/601918. Retrieved on 15/01/2026.&lt;/ref&gt;

== Ipilwakhe Ngaphambi Kokufika KwamaDatjhi ==
[[Isimumathi:Khoikhoi_Hottentot_p197.jpg|thumb|Ama-Khoekhoe]]
Kungenzeka u-Autshumato wabelethwa ngabo-1610 endaweni yeKapa ebeyibizwa bona yi-''Cape of Good Hope''. Bekayikosi yesitjhaba sama-Gorinhaikona, esima-Khoekhoe.&lt;ref name=&quot;:5&quot; /&gt; Ibizo lakhe lokubelethwa bekungu-Arri, njengombana nezibulo lakhe igama lalo lingu-Arri. U-Autshumato (okutjho ukuthi &quot;loyo othaya neemfesi,  ''ǀAu-tsâma-ao'') bekulibizo ebebambongelela ngalo, ngebanga lokuthi bekathaya emanzini ngendlela erarako, aduda ngasuthi yifesi.&lt;ref name=&quot;:4&quot; /&gt; 

Ngabo-1630 wathathwa maNgisi amusa e-Bantam eNgilandi bona ambandulele ukuba mkhulumeli wabantu abeza ngemikhumbi yamaNgisi. Ngibo abamupha negama lika-Harry. Kulapho afunda khona ukukhuluma isiNgisi nesiDatjhi. Kubonakala ngasuthi watjhinga ne-Batavia&lt;ref name=&quot;:5&quot; /&gt;.  Wathi nakabuya eKapa ngo-1931, yena nabalandeli bakhe bavula isitetjhi sokurhweba e-''Robben Island.'' Bekuthi imikhumbi nayifikako, ambathe iimpahla ezimbathwa maYurobhu, akhulume nabokapteni bemikhumbi ngesibindi. Lokho, kwenza u-Autshumato wabizwa ngokobana yi-'Governor' maNgisi namaFrentji.&lt;ref name=&quot;:4&quot; /&gt; 

Kwaba nelinye godu ibanga elenza bona amaNgisi amthathe amuse e-''Robben Island'' ''.'' U-Autshumato besele arhitjhene nezinye iintjhaba zama-Khoekhoe. Wabawa umkhumbi wamaNgisi ebewudlula endaweni leyo bona uthathe yena nabalandeli bakhe  basiwe e-''Robben Island,'' nangambala kwaba njalo. Esikhathineso u-Autshumato wasebenziswa njengeposo yemikhumbi yamaYurobhu. Kungenzeka isiFrentji nesiPutukezi wazifunda lapho. Kwathi ngemva kweminyaka ebunane, ngabo-1940 wabuya, ngombana irarano liphelile.&lt;ref name=&quot;:5&quot; /&gt;  Babuya esihlengehlengeni beza enarheni eKapa, lapha kuhlangana khona umlambo i-''Camissa River'' nelwandle. Yena nomndenakhe ngibo ebebaphethe isitetjhi sokurhwebelana i-''‖Ammaqua'' (okutjho bona Abantu bemanzini) okulibizo u-Jan Van Riebeeck ebekababiza ngalo ekuthomeni.&lt;ref name=&quot;:3&quot;&gt;Roben Island Museum (13 May 2017) ''Autshumato''. Retrieved from: http://www.robben-island.org.za/departments/heritage/gallery/autshumato.asp. Retrieved on 14/01/2026.&lt;/ref&gt;&lt;ref name=&quot;:4&quot; /&gt;

== Ipilwakhe Ngemva Kokufika KwamaDatjhi ==
[[Isimumathi:Jan van Riebeeck .jpg|thumb|U-Autshumato wamukela u-Jan Van Riebeeck]]
Afika amaDatjhi ngo-1652 ngemikhumbi yawo emihlanu, i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch.'' Ukuthoma kokufika kwamaDatjhi eKapa (''Cape of Good Hope'') khenge kubamangaze abantu bendabuko bendawo leyo ama-Khoekhoe. AmaDatjhi afika nje ama-Khoekhoe besele kukade arhwebelana namaNgisi, amaPutukezi namaFrentji. Nangaphezu kokufika kuka-Van Riebeeck, ngokuya kuka-Knox‑Johnson, phakathi nomnyaka wabo-1600 kuya ku-1700, besele kudlule imikhumbi yamaDatjhi eyi-1 730. Yeke ama-Khoekhoe bekangawaqabuki amaDatjhi ngesikhatheso.&lt;ref&gt;Helen Swingler (22 September 2021) ''Heritage Month: The Khoi encountered Europeans long before Van Riebeeck,'' University of Cape Town News. Retrieved from: https://www.news.uct.ac.za/article/-2021-09-22-the-khoi-encountered-europeans-long-before-van-riebeeck. Retrieved on 12/01/2026.&lt;/ref&gt;

Endabeni yokurhwebelana, zoke izinto ebezenzeka u-Jan Van Riebeeck wazitlola emajenalini wakhe. AmaDatjhi bewathenga iinkomo nezimvu kuma-Khoekhoe ngepahla ehlukahlukeneko kuhlanganise notjwala negwayi. Bese inyama yefuyo le idliwe, enye ithengiselwe abantu abadlula ngemikhumbi yekhamphani.&lt;ref name=&quot;:5&quot; /&gt;

Kwathi ngenyanga kaSewula wango-1653 kwaba nokurhitjhana phakathi kuka-Autshumato nomelusi weenkomo zika-Van Riebeeck u-David Jansz. U-Autshumato wambulala wathatha iinkomo. Ukurhitjhanokhu kuthoma nje, iintjhaba ezimbili lezi besele zingasathelelani kuhle amanzi. AmaDatjhi besele aqala u-Autshumato nabantu bakhe njengamasela. U-Jan Van Riebeeck wathi u-Autshumato lisela elinelimi elibutjhelelezi. Ama-Khoekhoe aqala amaDatjhi njengabakhohlisi ngokuthi intengo yotjwala negwayi ayilingani nentengo yesilwana esifuywako. Bebathi bangabusela utjwala buphele, babone ifuywabo emadlelweni wamaDatjhi, yanda. Bese amaKhoekhoe akhambe ayoyeba.&lt;ref&gt;Castle of Good Hope (''13th November 2018'') ''Interpreters' Flawed Contracts With Dutch''Retrieved from: https://www.castleofgoodhope.co.za/index.php/news/100-news/142-interpreters-flawed-contracts-with-dutch. Retrieved on 14/01/2026.&lt;/ref&gt;

Isenzakalo sokubulawa kuka-David Jansz sasusa ipi phakathi kwama-Khoe namaDatjhi. U-Van RieBeeck wathi u-Autshumato unomlandu wokubulala. Yeke kwaliwa ipi, ekugcineni ama-Khoe ahlulwa. U-Autshumato wabanjwa wasiwa ekuthunjweni e-''Robben Island'' ngawo umnyaka ka-1653. Kodwana ngo-1655 watjhatjululwa wabuyiswa enarheni.  Nakafikako u-Jan Van Riebeeck wamamukela wambuyisela esikhundleni sakhe sokutologa.&lt;ref name=&quot;:5&quot; /&gt;  Ngesikhathesi u-Autshumato besele azwisisa indlela amaYurobhu arhweba ngayo nendlela yokuzuza kiyo. Bekathi nakarhwebela u-Jan Van Riebeeck iinkomo, aqiniseke bona imbadelo yekhamphani yanele bona ingabhadela neenkomo azithengela zona yena, ngikho nje aba mumuntu oregileko eKapa.&lt;ref name=&quot;:5&quot; /&gt; 

Ngokukhamba kwesikhathi kwaba nokhunye godu ukurhitjhana phakathi kwama-Khoekhoe namaDatjhi ngo-1657. Ukurhitjhanokhu kubangwa kungazwani kwama-''Free Burghers (Vry Burgers)''  neengqila ze-Madagascar.  U-Jan Van Riebeeck wakateleleka bona akhe isivikelo endaweni leyo, bona enze ama-Khoekhoe asuke endaweni leyo. Bekuthi ezinye iingqila naziphunyurhako asebenzise u-Autshumato njengesithunjwa ukuhlohlozela ama-Khoe bona akhambe ayokubamba iingqilezo. Kodwana iqhinga lika-Van Riebeeck khenge liphumelele ngendlela afuna ngayo. Kwathi ngo-1658 u-Autshumato wabanjwa, wathathelwa yoke ifuywakhe. Ngemva kokutjhutjhiswa wathunjwa wasiwa e-''Robben Island'' godu. Kodwana wathi nakalapho waphunyurha ngesikepe esivuzako. Bekube kunamhlanjesi, u-Autshumato nguye kwaphela umuntu okghone ukuphunyurha e-''Robben Island'' njengesibotjhwa. Kunokuthi nakabuyako enarheni abotjhwe, u-Van Riebeeck wambuyisela esikhundleni sakhe sokukhulumisana nokutologa.&lt;ref name=&quot;:5&quot; /&gt;&lt;ref name=&quot;:4&quot; /&gt; 

Ubuhlobo bamaDatjhi nama-Khoekhoe bebuhlala bunemiraro kangangobana amaDatjhi abatjhidisela kude nendawo abakiyo. U-Autshumato waragela phambili nokufuya nokurhwebelana nabakhambi namaDatjhi bekwaba sekufeni kwakhe ngo-1663, ngemva komnyaka u-Jan Van Riebeeck akhambile. Ngo-1713 u-Francois Valentyn wabika bona isitjhaba sama-Gorinhaikona besele singasabonakali endaweni leyo. Uthi kungenzeka baqedwe bulwele bepokisi obarhagala ngo-1713.&lt;ref name=&quot;:5&quot; /&gt; 

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>0442dch5i8ix0vlvcgpjgd88mkastgt</sha1>
    </revision>
    <revision>
      <id>6744</id>
      <parentid>6163</parentid>
      <timestamp>2026-07-18T04:34:33Z</timestamp>
      <contributor>
        <username>Ziv</username>
        <id>1632</id>
      </contributor>
      <minor />
      <comment>([[c:GR|GR]]) [[c:COM:FR|File renamed]]: [[File:Jan van Riebeeck .jpg]] → [[File:Charles Davidson Bell - Landing of Van Riebeeck at the Cape of Good Hope in 1652.jpg]] [[c:COM:FR#FR2|Criterion 2]] · Artist's name and exact description &amp; bug fix</comment>
      <origin>6744</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8508" sha1="7qchfyzdsg032oqgqn8gc4yszc1gxkd" xml:space="preserve">[[Isimumathi:Homo sapiens - Khoikhoi, Zuid-Afrika - 1700-1880 - Print - Iconographia Zoologica - Special Collections University of Amsterdam - UBA01 IZ19400109.tif|thumb|363x363px|Isithombe se-Khoekhoe]]
'''U-Autshumato namkha u-Autshumao,''' (c. 1610-1663) amaDatjhi ebebamazi ngo-''Harry die Strandloper'', bekayikosi yesitjhaba sama-Khoekhoe ( namkha ama-Khoekhoe) ebesibizwa bona ma-Goringhaicona ebesihlala endaweni yeKapa lakade, amaDatjhi awayibiza nge-''Cape of Good Hope.'' Ngesikhathi amaDatjhi afika, umuntu wokuthoma ukubamukela bekungu-Autshumao nabantu bakhe. Ngikho nje amaDatjhi bebababiza ngokuthi ma-Strandloper ngombana babathola bakhamba eligwini lelwandle. Kusukela bathoma ukubonana bathoma nokurhwebelana.&lt;ref name=&quot;:5&quot;&gt;Steemit Website (2018) ''SOUTH AFRICAN HISTORY: Autshumato translator and first Postmaster of The Cape of Good Hope''. Retrieved from: https://steemit.com/history/@krabgat/south-african-history-autshumato-translator-and-first-postmaster-of-the-cape-of-good-hope. Retrieved on 14/01/2026.&lt;/ref&gt;&lt;ref name=&quot;:4&quot;&gt;Camissa Museum (2026) ''Autshumao (1610 - 1674)'', Retrieved from: https://camissamuseum.co.za/index.php/7-tributaries/1-cape-indigenous-africans/autshumao. Retrieved on 12/01/2026.&lt;/ref&gt; 

Into eyenza bona u-Autshumato aqakatheke emlandweni weSewula Afrika kukuthi zinengi izinto ezenzeka epilwenakhe ezivala isikhala somlando wokusebenzelana kwabantu abanzima nabamhlophe eSewula Afrika. U-Autsumato wasebenzelana nabantu ebebeza ngemikhumbi eKapa ngombana bekakwazi ukukhulumisana nabo ngesiNgisi, isiDatjhi, isiPutukezi nesiFrentji,&lt;ref name=&quot;:4&quot; /&gt; begodu ukusebenzelana kwakhe nabo kwaba nemiphumela ehlala isikhathi eside, esesekhona bekube namhlanjesi.&lt;ref&gt;Britnnica Kids (2026) ''Autshumato,'' Britannica Kids website. Retrieved from: https://kids.britannica.com/kids/article/Autshumato/601918. Retrieved on 15/01/2026.&lt;/ref&gt;

== Ipilwakhe Ngaphambi Kokufika KwamaDatjhi ==
[[Isimumathi:Khoikhoi_Hottentot_p197.jpg|thumb|Ama-Khoekhoe]]
Kungenzeka u-Autshumato wabelethwa ngabo-1610 endaweni yeKapa ebeyibizwa bona yi-''Cape of Good Hope''. Bekayikosi yesitjhaba sama-Gorinhaikona, esima-Khoekhoe.&lt;ref name=&quot;:5&quot; /&gt; Ibizo lakhe lokubelethwa bekungu-Arri, njengombana nezibulo lakhe igama lalo lingu-Arri. U-Autshumato (okutjho ukuthi &quot;loyo othaya neemfesi,  ''ǀAu-tsâma-ao'') bekulibizo ebebambongelela ngalo, ngebanga lokuthi bekathaya emanzini ngendlela erarako, aduda ngasuthi yifesi.&lt;ref name=&quot;:4&quot; /&gt; 

Ngabo-1630 wathathwa maNgisi amusa e-Bantam eNgilandi bona ambandulele ukuba mkhulumeli wabantu abeza ngemikhumbi yamaNgisi. Ngibo abamupha negama lika-Harry. Kulapho afunda khona ukukhuluma isiNgisi nesiDatjhi. Kubonakala ngasuthi watjhinga ne-Batavia&lt;ref name=&quot;:5&quot; /&gt;.  Wathi nakabuya eKapa ngo-1931, yena nabalandeli bakhe bavula isitetjhi sokurhweba e-''Robben Island.'' Bekuthi imikhumbi nayifikako, ambathe iimpahla ezimbathwa maYurobhu, akhulume nabokapteni bemikhumbi ngesibindi. Lokho, kwenza u-Autshumato wabizwa ngokobana yi-'Governor' maNgisi namaFrentji.&lt;ref name=&quot;:4&quot; /&gt; 

Kwaba nelinye godu ibanga elenza bona amaNgisi amthathe amuse e-''Robben Island'' ''.'' U-Autshumato besele arhitjhene nezinye iintjhaba zama-Khoekhoe. Wabawa umkhumbi wamaNgisi ebewudlula endaweni leyo bona uthathe yena nabalandeli bakhe  basiwe e-''Robben Island,'' nangambala kwaba njalo. Esikhathineso u-Autshumato wasebenziswa njengeposo yemikhumbi yamaYurobhu. Kungenzeka isiFrentji nesiPutukezi wazifunda lapho. Kwathi ngemva kweminyaka ebunane, ngabo-1940 wabuya, ngombana irarano liphelile.&lt;ref name=&quot;:5&quot; /&gt;  Babuya esihlengehlengeni beza enarheni eKapa, lapha kuhlangana khona umlambo i-''Camissa River'' nelwandle. Yena nomndenakhe ngibo ebebaphethe isitetjhi sokurhwebelana i-''‖Ammaqua'' (okutjho bona Abantu bemanzini) okulibizo u-Jan Van Riebeeck ebekababiza ngalo ekuthomeni.&lt;ref name=&quot;:3&quot;&gt;Roben Island Museum (13 May 2017) ''Autshumato''. Retrieved from: http://www.robben-island.org.za/departments/heritage/gallery/autshumato.asp. Retrieved on 14/01/2026.&lt;/ref&gt;&lt;ref name=&quot;:4&quot; /&gt;

== Ipilwakhe Ngemva Kokufika KwamaDatjhi ==
[[Isimumathi:Charles Davidson Bell - Landing of Van Riebeeck at the Cape of Good Hope in 1652.jpg|thumb|U-Autshumato wamukela u-Jan Van Riebeeck]]
Afika amaDatjhi ngo-1652 ngemikhumbi yawo emihlanu, i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch.'' Ukuthoma kokufika kwamaDatjhi eKapa (''Cape of Good Hope'') khenge kubamangaze abantu bendabuko bendawo leyo ama-Khoekhoe. AmaDatjhi afika nje ama-Khoekhoe besele kukade arhwebelana namaNgisi, amaPutukezi namaFrentji. Nangaphezu kokufika kuka-Van Riebeeck, ngokuya kuka-Knox‑Johnson, phakathi nomnyaka wabo-1600 kuya ku-1700, besele kudlule imikhumbi yamaDatjhi eyi-1 730. Yeke ama-Khoekhoe bekangawaqabuki amaDatjhi ngesikhatheso.&lt;ref&gt;Helen Swingler (22 September 2021) ''Heritage Month: The Khoi encountered Europeans long before Van Riebeeck,'' University of Cape Town News. Retrieved from: https://www.news.uct.ac.za/article/-2021-09-22-the-khoi-encountered-europeans-long-before-van-riebeeck. Retrieved on 12/01/2026.&lt;/ref&gt;

Endabeni yokurhwebelana, zoke izinto ebezenzeka u-Jan Van Riebeeck wazitlola emajenalini wakhe. AmaDatjhi bewathenga iinkomo nezimvu kuma-Khoekhoe ngepahla ehlukahlukeneko kuhlanganise notjwala negwayi. Bese inyama yefuyo le idliwe, enye ithengiselwe abantu abadlula ngemikhumbi yekhamphani.&lt;ref name=&quot;:5&quot; /&gt;

Kwathi ngenyanga kaSewula wango-1653 kwaba nokurhitjhana phakathi kuka-Autshumato nomelusi weenkomo zika-Van Riebeeck u-David Jansz. U-Autshumato wambulala wathatha iinkomo. Ukurhitjhanokhu kuthoma nje, iintjhaba ezimbili lezi besele zingasathelelani kuhle amanzi. AmaDatjhi besele aqala u-Autshumato nabantu bakhe njengamasela. U-Jan Van Riebeeck wathi u-Autshumato lisela elinelimi elibutjhelelezi. Ama-Khoekhoe aqala amaDatjhi njengabakhohlisi ngokuthi intengo yotjwala negwayi ayilingani nentengo yesilwana esifuywako. Bebathi bangabusela utjwala buphele, babone ifuywabo emadlelweni wamaDatjhi, yanda. Bese amaKhoekhoe akhambe ayoyeba.&lt;ref&gt;Castle of Good Hope (''13th November 2018'') ''Interpreters' Flawed Contracts With Dutch''Retrieved from: https://www.castleofgoodhope.co.za/index.php/news/100-news/142-interpreters-flawed-contracts-with-dutch. Retrieved on 14/01/2026.&lt;/ref&gt;

Isenzakalo sokubulawa kuka-David Jansz sasusa ipi phakathi kwama-Khoe namaDatjhi. U-Van RieBeeck wathi u-Autshumato unomlandu wokubulala. Yeke kwaliwa ipi, ekugcineni ama-Khoe ahlulwa. U-Autshumato wabanjwa wasiwa ekuthunjweni e-''Robben Island'' ngawo umnyaka ka-1653. Kodwana ngo-1655 watjhatjululwa wabuyiswa enarheni.  Nakafikako u-Jan Van Riebeeck wamamukela wambuyisela esikhundleni sakhe sokutologa.&lt;ref name=&quot;:5&quot; /&gt;  Ngesikhathesi u-Autshumato besele azwisisa indlela amaYurobhu arhweba ngayo nendlela yokuzuza kiyo. Bekathi nakarhwebela u-Jan Van Riebeeck iinkomo, aqiniseke bona imbadelo yekhamphani yanele bona ingabhadela neenkomo azithengela zona yena, ngikho nje aba mumuntu oregileko eKapa.&lt;ref name=&quot;:5&quot; /&gt; 

Ngokukhamba kwesikhathi kwaba nokhunye godu ukurhitjhana phakathi kwama-Khoekhoe namaDatjhi ngo-1657. Ukurhitjhanokhu kubangwa kungazwani kwama-''Free Burghers (Vry Burgers)''  neengqila ze-Madagascar.  U-Jan Van Riebeeck wakateleleka bona akhe isivikelo endaweni leyo, bona enze ama-Khoekhoe asuke endaweni leyo. Bekuthi ezinye iingqila naziphunyurhako asebenzise u-Autshumato njengesithunjwa ukuhlohlozela ama-Khoe bona akhambe ayokubamba iingqilezo. Kodwana iqhinga lika-Van Riebeeck khenge liphumelele ngendlela afuna ngayo. Kwathi ngo-1658 u-Autshumato wabanjwa, wathathelwa yoke ifuywakhe. Ngemva kokutjhutjhiswa wathunjwa wasiwa e-''Robben Island'' godu. Kodwana wathi nakalapho waphunyurha ngesikepe esivuzako. Bekube kunamhlanjesi, u-Autshumato nguye kwaphela umuntu okghone ukuphunyurha e-''Robben Island'' njengesibotjhwa. Kunokuthi nakabuyako enarheni abotjhwe, u-Van Riebeeck wambuyisela esikhundleni sakhe sokukhulumisana nokutologa.&lt;ref name=&quot;:5&quot; /&gt;&lt;ref name=&quot;:4&quot; /&gt; 

Ubuhlobo bamaDatjhi nama-Khoekhoe bebuhlala bunemiraro kangangobana amaDatjhi abatjhidisela kude nendawo abakiyo. U-Autshumato waragela phambili nokufuya nokurhwebelana nabakhambi namaDatjhi bekwaba sekufeni kwakhe ngo-1663, ngemva komnyaka u-Jan Van Riebeeck akhambile. Ngo-1713 u-Francois Valentyn wabika bona isitjhaba sama-Gorinhaikona besele singasabonakali endaweni leyo. Uthi kungenzeka baqedwe bulwele bepokisi obarhagala ngo-1713.&lt;ref name=&quot;:5&quot; /&gt; 

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>7qchfyzdsg032oqgqn8gc4yszc1gxkd</sha1>
    </revision>
  </page>
  <page>
    <title>U-Jan Van Riebeeck</title>
    <ns>0</ns>
    <id>1023</id>
    <revision>
      <id>6131</id>
      <timestamp>2026-01-16T11:44:52Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>New article</comment>
      <origin>6131</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9863" sha1="nlv7d2sfwzwaqmbbhtol3b1ke54h8cr" xml:space="preserve">[[Isimumathi:Jan van Riebeeck cropped.jpg|thumb|U-Jan Van Riebeeck]]
UJan Van Riebeeck (U-''Johan Anthoniszoon &quot;Jan&quot; Van Riebeeck'') wabelethwa ngomhla ka-21 kuSihlabantangana 1619 e-Culemborg, e-Netherlands abelethwa nguyise ungodorhodere ohlinzako. Wakhulela e-Schiedam, e-Netherlands, kwathi ngomhla wama-28 kuNtaka 1649, watjhada u-''Maria de la Queillerie'', waba nabantwana ababunane naye.&lt;ref name=&quot;:2&quot;&gt;South African History Online (17 October 2011), ''Jan van Riebeeck.'' Retrieved from: https://sahistory.org.za/people/jan-van-riebeeck. Retreived on 03/01/2026.&lt;/ref&gt;

U-Jan Van Riebeeck waba lilunga le-''Dutch East India Company'' (''Vereenigde Oost-Indische Compagnie'' -  VOC) ngo-1639 lapha athoma khona ukuba msizi kadorhodere ohlinzako ekhambeni labo lokuya e-Batavia (namhlanjesi eyaziwa nge-Jakarta) ngenyanga kaSihlabantangana 1639 bese batjhinga e-Nagasaki eJapani ngo-1643.&lt;ref name=&quot;:2&quot; /&gt;
[[Isimumathi:Maria Quevellerius (1629-64), eerste vrouw van Jan van Riebeeck, of diens tweede vrouw Maria Scipio (ca. 1630-95) Rijksmuseum SK-A-806.jpeg|thumb|Umka-Jan Van Riebeeck, u-Maria Quevellerius]]
Ngo-1645 u-Jan Van Riebeeck wanikelwa isabelo sokuba mphathi wesitetjhi sokurhwebela se-VOC ebesise-Tongkin e-''French Indochina'' (namhlanjesi eyaziwa nge-Vietnam). Wehliswa esikhundleneso ngebanga lokuthi besele azenzela irhwebo lakhe langeqadi, okuphula umthetho wekhamphani othi abaphathi akukafuzi bazenzele irhwebo ngeqadi ngepahla yekhamphani. Kwathi bona ehliswe esikhundleni, wazithola sele kufuze abuyele emva e-Netherlands ayoqalana nemilandu yakhe. Ngikho-ke besele atholakala komunye wemikhumbi eli-12 ebeyidoswa phambili ngu-W.G de Jong. Wafika e-''Table Bay'' hlanu kwe-''Cape of Good Hope'' wahlala khona amalanga ali-18. Lokho kwamnikela isikhathi sokuqalisisa indawo, nokucabanga bona angayisebenzisa njani ekwenzeni bona i-VOC imthembe godu. Wayibona iyindawo enganikela ngokudla namanzi kabakhamba ngemikhumbi.&lt;ref name=&quot;:2&quot; /&gt;

Njengombana umkhumbi i-''Nieuwe Haerlem'' waphahlazeka ngo-1647, abasindileko bakha indawo lapho, u-Jan Van Riebeeck walemuka indlela ebebarhwebelana ngayo namaKhoikhoi njengombana balinde ukutakulwa. Ngemva kwalokho-ke watlola umbiko ngendawo le nangakho koke akubonileko, bewahlongoza bona indawo le ingaba yindawo ehle khulu i-VOC engayisebenzisa. Umbiko lo watlolwa ngo-1648 wathunyelwa ekhamphanini. Kwathi ngo-1651 i-VOC yathatha isiqunto sokuthi indawo ye-''Cape of Good Hope'' ayisetjenziselwe iminqopho yekhamphani.&lt;ref name=&quot;:2&quot; /&gt;

I-VOC yakhetha yena u-Jan Van Riebeeck bona kube nguye umdosiphambili ozokuhloma isitetjhi sokuphumula semikhumbi yamaDatjhi khona izokuthola ukudla okutjha okunepilo namanzi ahlanzekileko. Kwaba kusuka kwakhe-ke u-Jan Van Riebeeck, asuka e-Texel, e-Netherlands ngomhla wama-24 kuNobayeni 1651 bewayokufika e-''Table Bay'' ngomhla wesi-6 kaSihlabantangana 1652.&lt;ref name=&quot;:2&quot; /&gt; Bafika bakhamba ngemikhumbi emihlanu - i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch''.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot;&gt;Marco Ramerini, English text by Dietrich Köster (January, 11 2014), ''The Dutch in South Africa, 1652-1795 and 1802-1806.'' Retrieved from https://www.colonialvoyage.com/dutch-south-africa/. Retrieved on 03/01/2026.&lt;/ref&gt;

== Ukufika Kwakhe EKapa ==
[[Isimumathi:Jan van Riebeeck .jpg|thumb|280x280px|Ukufika kuka-Jan Van Riebeeck eKapa]]
U-Jan Van Riebeeck wasuka ngomhla wama-24 kuNobayeni 1651 e-Texel, e-Netherlands, wafika ngomhla wesi-6 kaSihlabantangana 1652.&lt;ref name=&quot;:22&quot;&gt;South African History Online (17 October 2011), ''Jan van Riebeeck.'' Retrieved from: https://sahistory.org.za/people/jan-van-riebeeck. Retreived on 03/01/2026.&lt;/ref&gt; Bafika bakhamba ngemikhumbi emihlanu - i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch.&lt;ref name=&quot;:02&quot;&gt;South African History Online (13 January 2024) ''The Dutch Settlement.'' Retrieved from: https://sahistory.org.za/article/dutch-settlement Retrieved on 01/01/2026.&lt;/ref&gt;&lt;ref name=&quot;:12&quot;&gt;Marco Ramerini, English text by Dietrich Köster (January, 11 2014), ''The Dutch in South Africa, 1652-1795 and 1802-1806.'' Retrieved from https://www.colonialvoyage.com/dutch-south-africa/. Retrieved on 03/01/2026.&lt;/ref&gt;'' Emithathu le ngiyo eyafika qangi, ngikho kwaziwa khulu le emithathu, le eminye imikhumbi emibili yafika mva. Ekufikeni kwakhe nabantu ebekakhamba nabo ngemikhumbi le wafika wakha indawo yobuphephelo ebizwa bona yi-''Fort de Goede Hoop (Fort of Good Hope).'' Bafika batjala endaweni leyo, kodwana iintjalo zabo khenge zitlhurhe kuhle, mhlamunye ngebanga lobujamo bezulu obungafani nobe-Netherlands, netjharagano ebeliphakathi kwamadoda ebekakhamba nawo nakufuze basebenze batlhgomele imikhumbu edlulako. Abantu bebabancani umsebenzi umnengi.&lt;ref name=&quot;:22&quot; /&gt;

Kwathi ngo-1655 u-Van Riebeeck wabika bona ngaphandle kwabantu abazimisele ukusebenza emasimini, isitetjhesi sizokubhalelwa ukwenza umsebenzi esihloselwe wona. Kwathi ngo-1657, i-VOC yathumela abalimi ababhadelwako, ngombandela wokuthi balime inarha bebathengisele ikhamphani iintjalo abazilimileko. Ngibo laba ebebabizwa bona ma-''Free Burghers (Vry Burgers)''. U-Jan Van Riebeeck wathatha isikhathi sakhe soke atjala bekakhiqiza amagrepsi, ama-apula namazambana, ukudla okuzokuba lisizo khulu emikhumbini edlulako. Kwathi ngo-1659 besele anesivuno samagrepsi ebesikhiqiza iwayini elibovu elilwisana nobulwele be-''scurvy,'' njengombana besele alemukile bona ukusela iwayini kuyabuvikela ubulwelobu ngokwezinga elithileko.&lt;ref name=&quot;:22&quot; /&gt;

Endabeni yokurhwebelana, zoke izinto ebezenzeka u-Jan Van Riebeeck wazitlola emajenalini wakhe. AmaDatjhi bewathenga iinkomo nezimvu kuma-Khoekhoe ngepahla ehlukahlukeneko kuhlanganise notjwala negwayi. Bese inyama yefuyo le idliwe, enye ithengiselwe abantu abadlula ngemikhumbi yekhamphani.&lt;ref name=&quot;:5&quot;&gt;Steemit Website (2018) ''SOUTH AFRICAN HISTORY: Autshumato translator and first Postmaster of The Cape of Good Hope''. Retrieved from: https://steemit.com/history/@krabgat/south-african-history-autshumato-translator-and-first-postmaster-of-the-cape-of-good-hope. Retrieved on 14/01/2026.&lt;/ref&gt;

Kwathi ngenyanga kaSewula wango-1653 kwaba nokurhitjhana phakathi kuka-Autshumato, umdosiphambili wesitjhaba sama-Khoekhoe ama-''Gorinhaikona,'' nomelusi weenkomo zika-Van Riebeeck u-David Jansz. U-Autshumato wambulala wathatha iinkomo. Ukurhitjhanokhu kuthoma nje, iintjhaba ezimbili lezi besele zingasathelelani kuhle amanzi. AmaDatjhi besele aqala u-Autshumato nabantu bakhe njengamasela. U-Jan Van Riebeeck wathi u-Autshumato lisela elinelimi elibutjhelelezi. Ama-Khoekhoe aqala amaDatjhi njengabakhohlisi ngokuthi intengo yotjwala negwayi ayilingani nentengo yesilwana esifuywako. Bebathi bangabusela utjwala buphele, babone ifuywabo emadlelweni wamaDatjhi, yanda. Bese amaKhoekhoe akhambe ayoyeba.&lt;ref&gt;Castle of Good Hope (''13th November 2018'') ''Interpreters' Flawed Contracts With Dutch''Retrieved from: https://www.castleofgoodhope.co.za/index.php/news/100-news/142-interpreters-flawed-contracts-with-dutch. Retrieved on 14/01/2026.&lt;/ref&gt;

Isenzakalo sokubulawa kuka-David Jansz sasusa ipi phakathi kwama-Khoe namaDatjhi. U-Van RieBeeck wathi u-Autshumato unomlandu wokubulala. Yeke kwaliwa ipi, ekugcineni ama-Khoe ahlulwa. U-Autshumato wabanjwa wasiwa ekuthunjweni e-''Robben Island'' ngawo umnyaka ka-1653. Kodwana ngo-1655 watjhatjululwa wabuyiswa enarheni.  Nakafikako u-Jan Van Riebeeck wamamukela wambuyisela esikhundleni sakhe sokutologa.&lt;ref name=&quot;:5&quot; /&gt;  Ngesikhathesi u-Autshumato besele azwisisa indlela amaYurobhu arhweba ngayo nendlela yokuzuza kiyo. Bekathi nakarhwebela u-Jan Van Riebeeck iinkomo, aqiniseke bona imbadelo yekhamphani yanele bona ingabhadela neenkomo azithengela zona yena, ngikho nje aba mumuntu oregileko eKapa.&lt;ref name=&quot;:5&quot; /&gt;

Ngokukhamba kwesikhathi kwaba nokhunye godu ukurhitjhana phakathi kwama-Khoekhoe namaDatjhi ngo-1657. Ukurhitjhanokhu kubangwa kungazwani kwama-''Free Burghers (Vry Burgers)''  neengqila ze-Madagascar.  U-Jan Van Riebeeck wakateleleka bona akhe isivikelo endaweni leyo, bona enze ama-Khoekhoe asuke endaweni leyo. Bekuthi ezinye iingqila naziphunyurhako asebenzise u-Autshumato njengesithunjwa ukuhlohlozela ama-Khoe bona akhambe ayokubamba iingqilezo. Kodwana iqhinga lika-Van Riebeeck khenge liphumelele ngendlela afuna ngayo. Kwathi ngo-1658 u-Autshumato wabanjwa, wathathelwa yoke ifuywakhe. Ngemva kokutjhutjhiswa wathunjwa wasiwa e-''Robben Island'' godu. Kodwana wathi nakalapho waphunyurha ngesikepe esivuzako. Bekube kunamhlanjesi, u-Autshumato nguye kwaphela umuntu okghone ukuphunyurha e-''Robben Island'' njengesibotjhwa. Kunokuthi nakabuyako enarheni abotjhwe, u-Van Riebeeck wambuyisela esikhundleni sakhe sokukhulumisana nokutologa.&lt;ref name=&quot;:5&quot; /&gt;&lt;ref name=&quot;:4&quot;&gt;Camissa Museum (2026) ''Autshumao (1610 - 1674)'', Retrieved from: https://camissamuseum.co.za/index.php/7-tributaries/1-cape-indigenous-africans/autshumao. Retrieved on 12/01/2026.&lt;/ref&gt;

== Ukufa Kwakhe ==
Ngomhla wobu-8 kuKhukhulamungu wango-1662 u-Jan Van Riebeeck wakhamba eKapa esesewula Afrika, watjhiya u-Zacharias Wagenaer bona kube nguye osala aphethe endaweni abakiyo eKapa. Wafika wahlala endaweni ebizwa bona yiMalacca namhlanjesi ebizwa bona yi-Melaka eseMalaysia, wahlala lapho bekwaba nguKhukhulamungu wango-1665. Umkakhe wahlongakala ngokubulawa bulwele bepokisi ngenyanga kaSinyikhaba ngo-1664. Ngemva kwalokho wabekwa esikhundleni sokuba ngu-''Governor-General-in-Council'' wenarha yeNdiya, begodu wahlala e-Batavia ipilwakhe yoke. Wahlongakala ngomhla we-18 kuTjhirhweni 1677.&lt;ref&gt;S2A3 Biographical Database of Southern African Science (2026)'''''Van Riebeeck,''' Commander '''Johan Antoniszoon''' (advancement of science).'' Retrieved from: https://www.s2a3.org.za/bio/Biograph_final.php?serial=2953. Retrieved on 16/01/2026.&lt;/ref&gt;

== Iinkhombo ==</text>
      <sha1>nlv7d2sfwzwaqmbbhtol3b1ke54h8cr</sha1>
    </revision>
    <revision>
      <id>6132</id>
      <parentid>6131</parentid>
      <timestamp>2026-01-16T11:46:03Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>edited</comment>
      <origin>6132</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9869" sha1="ly16er5yrxo78jk3f3n00jajyv31bff" xml:space="preserve">[[Isimumathi:Jan van Riebeeck cropped.jpg|thumb|U-Jan Van Riebeeck]]
'''UJan Van Riebeeck (U-''Johan Anthoniszoon &quot;Jan&quot; Van Riebeeck'')''' wabelethwa ngomhla ka-21 kuSihlabantangana 1619 e-Culemborg, e-Netherlands abelethwa nguyise ungodorhodere ohlinzako. Wakhulela e-Schiedam, e-Netherlands, kwathi ngomhla wama-28 kuNtaka 1649, watjhada u-''Maria de la Queillerie'', waba nabantwana ababunane naye.&lt;ref name=&quot;:2&quot;&gt;South African History Online (17 October 2011), ''Jan van Riebeeck.'' Retrieved from: https://sahistory.org.za/people/jan-van-riebeeck. Retreived on 03/01/2026.&lt;/ref&gt;

U-Jan Van Riebeeck waba lilunga le-''Dutch East India Company'' (''Vereenigde Oost-Indische Compagnie'' -  VOC) ngo-1639 lapha athoma khona ukuba msizi kadorhodere ohlinzako ekhambeni labo lokuya e-Batavia (namhlanjesi eyaziwa nge-Jakarta) ngenyanga kaSihlabantangana 1639 bese batjhinga e-Nagasaki eJapani ngo-1643.&lt;ref name=&quot;:2&quot; /&gt;
[[Isimumathi:Maria Quevellerius (1629-64), eerste vrouw van Jan van Riebeeck, of diens tweede vrouw Maria Scipio (ca. 1630-95) Rijksmuseum SK-A-806.jpeg|thumb|Umka-Jan Van Riebeeck, u-Maria Quevellerius]]
Ngo-1645 u-Jan Van Riebeeck wanikelwa isabelo sokuba mphathi wesitetjhi sokurhwebela se-VOC ebesise-Tongkin e-''French Indochina'' (namhlanjesi eyaziwa nge-Vietnam). Wehliswa esikhundleneso ngebanga lokuthi besele azenzela irhwebo lakhe langeqadi, okuphula umthetho wekhamphani othi abaphathi akukafuzi bazenzele irhwebo ngeqadi ngepahla yekhamphani. Kwathi bona ehliswe esikhundleni, wazithola sele kufuze abuyele emva e-Netherlands ayoqalana nemilandu yakhe. Ngikho-ke besele atholakala komunye wemikhumbi eli-12 ebeyidoswa phambili ngu-W.G de Jong. Wafika e-''Table Bay'' hlanu kwe-''Cape of Good Hope'' wahlala khona amalanga ali-18. Lokho kwamnikela isikhathi sokuqalisisa indawo, nokucabanga bona angayisebenzisa njani ekwenzeni bona i-VOC imthembe godu. Wayibona iyindawo enganikela ngokudla namanzi kabakhamba ngemikhumbi.&lt;ref name=&quot;:2&quot; /&gt;

Njengombana umkhumbi i-''Nieuwe Haerlem'' waphahlazeka ngo-1647, abasindileko bakha indawo lapho, u-Jan Van Riebeeck walemuka indlela ebebarhwebelana ngayo namaKhoikhoi njengombana balinde ukutakulwa. Ngemva kwalokho-ke watlola umbiko ngendawo le nangakho koke akubonileko, bewahlongoza bona indawo le ingaba yindawo ehle khulu i-VOC engayisebenzisa. Umbiko lo watlolwa ngo-1648 wathunyelwa ekhamphanini. Kwathi ngo-1651 i-VOC yathatha isiqunto sokuthi indawo ye-''Cape of Good Hope'' ayisetjenziselwe iminqopho yekhamphani.&lt;ref name=&quot;:2&quot; /&gt;

I-VOC yakhetha yena u-Jan Van Riebeeck bona kube nguye umdosiphambili ozokuhloma isitetjhi sokuphumula semikhumbi yamaDatjhi khona izokuthola ukudla okutjha okunepilo namanzi ahlanzekileko. Kwaba kusuka kwakhe-ke u-Jan Van Riebeeck, asuka e-Texel, e-Netherlands ngomhla wama-24 kuNobayeni 1651 bewayokufika e-''Table Bay'' ngomhla wesi-6 kaSihlabantangana 1652.&lt;ref name=&quot;:2&quot; /&gt; Bafika bakhamba ngemikhumbi emihlanu - i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch''.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot;&gt;Marco Ramerini, English text by Dietrich Köster (January, 11 2014), ''The Dutch in South Africa, 1652-1795 and 1802-1806.'' Retrieved from https://www.colonialvoyage.com/dutch-south-africa/. Retrieved on 03/01/2026.&lt;/ref&gt;

== Ukufika Kwakhe EKapa ==
[[Isimumathi:Jan van Riebeeck .jpg|thumb|280x280px|Ukufika kuka-Jan Van Riebeeck eKapa]]
U-Jan Van Riebeeck wasuka ngomhla wama-24 kuNobayeni 1651 e-Texel, e-Netherlands, wafika ngomhla wesi-6 kaSihlabantangana 1652.&lt;ref name=&quot;:22&quot;&gt;South African History Online (17 October 2011), ''Jan van Riebeeck.'' Retrieved from: https://sahistory.org.za/people/jan-van-riebeeck. Retreived on 03/01/2026.&lt;/ref&gt; Bafika bakhamba ngemikhumbi emihlanu - i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch.&lt;ref name=&quot;:02&quot;&gt;South African History Online (13 January 2024) ''The Dutch Settlement.'' Retrieved from: https://sahistory.org.za/article/dutch-settlement Retrieved on 01/01/2026.&lt;/ref&gt;&lt;ref name=&quot;:12&quot;&gt;Marco Ramerini, English text by Dietrich Köster (January, 11 2014), ''The Dutch in South Africa, 1652-1795 and 1802-1806.'' Retrieved from https://www.colonialvoyage.com/dutch-south-africa/. Retrieved on 03/01/2026.&lt;/ref&gt;'' Emithathu le ngiyo eyafika qangi, ngikho kwaziwa khulu le emithathu, le eminye imikhumbi emibili yafika mva. Ekufikeni kwakhe nabantu ebekakhamba nabo ngemikhumbi le wafika wakha indawo yobuphephelo ebizwa bona yi-''Fort de Goede Hoop (Fort of Good Hope).'' Bafika batjala endaweni leyo, kodwana iintjalo zabo khenge zitlhurhe kuhle, mhlamunye ngebanga lobujamo bezulu obungafani nobe-Netherlands, netjharagano ebeliphakathi kwamadoda ebekakhamba nawo nakufuze basebenze batlhgomele imikhumbu edlulako. Abantu bebabancani umsebenzi umnengi.&lt;ref name=&quot;:22&quot; /&gt;

Kwathi ngo-1655 u-Van Riebeeck wabika bona ngaphandle kwabantu abazimisele ukusebenza emasimini, isitetjhesi sizokubhalelwa ukwenza umsebenzi esihloselwe wona. Kwathi ngo-1657, i-VOC yathumela abalimi ababhadelwako, ngombandela wokuthi balime inarha bebathengisele ikhamphani iintjalo abazilimileko. Ngibo laba ebebabizwa bona ma-''Free Burghers (Vry Burgers)''. U-Jan Van Riebeeck wathatha isikhathi sakhe soke atjala bekakhiqiza amagrepsi, ama-apula namazambana, ukudla okuzokuba lisizo khulu emikhumbini edlulako. Kwathi ngo-1659 besele anesivuno samagrepsi ebesikhiqiza iwayini elibovu elilwisana nobulwele be-''scurvy,'' njengombana besele alemukile bona ukusela iwayini kuyabuvikela ubulwelobu ngokwezinga elithileko.&lt;ref name=&quot;:22&quot; /&gt;

Endabeni yokurhwebelana, zoke izinto ebezenzeka u-Jan Van Riebeeck wazitlola emajenalini wakhe. AmaDatjhi bewathenga iinkomo nezimvu kuma-Khoekhoe ngepahla ehlukahlukeneko kuhlanganise notjwala negwayi. Bese inyama yefuyo le idliwe, enye ithengiselwe abantu abadlula ngemikhumbi yekhamphani.&lt;ref name=&quot;:5&quot;&gt;Steemit Website (2018) ''SOUTH AFRICAN HISTORY: Autshumato translator and first Postmaster of The Cape of Good Hope''. Retrieved from: https://steemit.com/history/@krabgat/south-african-history-autshumato-translator-and-first-postmaster-of-the-cape-of-good-hope. Retrieved on 14/01/2026.&lt;/ref&gt;

Kwathi ngenyanga kaSewula wango-1653 kwaba nokurhitjhana phakathi kuka-Autshumato, umdosiphambili wesitjhaba sama-Khoekhoe ama-''Gorinhaikona,'' nomelusi weenkomo zika-Van Riebeeck u-David Jansz. U-Autshumato wambulala wathatha iinkomo. Ukurhitjhanokhu kuthoma nje, iintjhaba ezimbili lezi besele zingasathelelani kuhle amanzi. AmaDatjhi besele aqala u-Autshumato nabantu bakhe njengamasela. U-Jan Van Riebeeck wathi u-Autshumato lisela elinelimi elibutjhelelezi. Ama-Khoekhoe aqala amaDatjhi njengabakhohlisi ngokuthi intengo yotjwala negwayi ayilingani nentengo yesilwana esifuywako. Bebathi bangabusela utjwala buphele, babone ifuywabo emadlelweni wamaDatjhi, yanda. Bese amaKhoekhoe akhambe ayoyeba.&lt;ref&gt;Castle of Good Hope (''13th November 2018'') ''Interpreters' Flawed Contracts With Dutch''Retrieved from: https://www.castleofgoodhope.co.za/index.php/news/100-news/142-interpreters-flawed-contracts-with-dutch. Retrieved on 14/01/2026.&lt;/ref&gt;

Isenzakalo sokubulawa kuka-David Jansz sasusa ipi phakathi kwama-Khoe namaDatjhi. U-Van RieBeeck wathi u-Autshumato unomlandu wokubulala. Yeke kwaliwa ipi, ekugcineni ama-Khoe ahlulwa. U-Autshumato wabanjwa wasiwa ekuthunjweni e-''Robben Island'' ngawo umnyaka ka-1653. Kodwana ngo-1655 watjhatjululwa wabuyiswa enarheni.  Nakafikako u-Jan Van Riebeeck wamamukela wambuyisela esikhundleni sakhe sokutologa.&lt;ref name=&quot;:5&quot; /&gt;  Ngesikhathesi u-Autshumato besele azwisisa indlela amaYurobhu arhweba ngayo nendlela yokuzuza kiyo. Bekathi nakarhwebela u-Jan Van Riebeeck iinkomo, aqiniseke bona imbadelo yekhamphani yanele bona ingabhadela neenkomo azithengela zona yena, ngikho nje aba mumuntu oregileko eKapa.&lt;ref name=&quot;:5&quot; /&gt;

Ngokukhamba kwesikhathi kwaba nokhunye godu ukurhitjhana phakathi kwama-Khoekhoe namaDatjhi ngo-1657. Ukurhitjhanokhu kubangwa kungazwani kwama-''Free Burghers (Vry Burgers)''  neengqila ze-Madagascar.  U-Jan Van Riebeeck wakateleleka bona akhe isivikelo endaweni leyo, bona enze ama-Khoekhoe asuke endaweni leyo. Bekuthi ezinye iingqila naziphunyurhako asebenzise u-Autshumato njengesithunjwa ukuhlohlozela ama-Khoe bona akhambe ayokubamba iingqilezo. Kodwana iqhinga lika-Van Riebeeck khenge liphumelele ngendlela afuna ngayo. Kwathi ngo-1658 u-Autshumato wabanjwa, wathathelwa yoke ifuywakhe. Ngemva kokutjhutjhiswa wathunjwa wasiwa e-''Robben Island'' godu. Kodwana wathi nakalapho waphunyurha ngesikepe esivuzako. Bekube kunamhlanjesi, u-Autshumato nguye kwaphela umuntu okghone ukuphunyurha e-''Robben Island'' njengesibotjhwa. Kunokuthi nakabuyako enarheni abotjhwe, u-Van Riebeeck wambuyisela esikhundleni sakhe sokukhulumisana nokutologa.&lt;ref name=&quot;:5&quot; /&gt;&lt;ref name=&quot;:4&quot;&gt;Camissa Museum (2026) ''Autshumao (1610 - 1674)'', Retrieved from: https://camissamuseum.co.za/index.php/7-tributaries/1-cape-indigenous-africans/autshumao. Retrieved on 12/01/2026.&lt;/ref&gt;

== Ukufa Kwakhe ==
Ngomhla wobu-8 kuKhukhulamungu wango-1662 u-Jan Van Riebeeck wakhamba eKapa esesewula Afrika, watjhiya u-Zacharias Wagenaer bona kube nguye osala aphethe endaweni abakiyo eKapa. Wafika wahlala endaweni ebizwa bona yiMalacca namhlanjesi ebizwa bona yi-Melaka eseMalaysia, wahlala lapho bekwaba nguKhukhulamungu wango-1665. Umkakhe wahlongakala ngokubulawa bulwele bepokisi ngenyanga kaSinyikhaba ngo-1664. Ngemva kwalokho wabekwa esikhundleni sokuba ngu-''Governor-General-in-Council'' wenarha yeNdiya, begodu wahlala e-Batavia ipilwakhe yoke. Wahlongakala ngomhla we-18 kuTjhirhweni 1677.&lt;ref&gt;S2A3 Biographical Database of Southern African Science (2026)'''''Van Riebeeck,''' Commander '''Johan Antoniszoon''' (advancement of science).'' Retrieved from: https://www.s2a3.org.za/bio/Biograph_final.php?serial=2953. Retrieved on 16/01/2026.&lt;/ref&gt;

== Iinkhombo ==</text>
      <sha1>ly16er5yrxo78jk3f3n00jajyv31bff</sha1>
    </revision>
    <revision>
      <id>6133</id>
      <parentid>6132</parentid>
      <timestamp>2026-01-16T11:49:01Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>edited</comment>
      <origin>6133</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9877" sha1="snh3ze3dhmpd7qwfgy2ijaidrlt4wze" xml:space="preserve">[[Isimumathi:Jan van Riebeeck cropped.jpg|thumb|U-Jan Van Riebeeck]]
'''UJan Van Riebeeck (U-''Johan Anthoniszoon &quot;Jan&quot; Van Riebeeck'')''' wabelethwa ngomhla ka-21 kuSihlabantangana 1619 e-Culemborg, e-Netherlands abelethwa nguyise ungodorhodere ohlinzako. Wakhulela e-Schiedam, e-Netherlands, kwathi ngomhla wama-28 kuNtaka 1649, watjhada u-''Maria de la Queillerie'', waba nabantwana ababunane naye.&lt;ref name=&quot;:2&quot;&gt;South African History Online (17 October 2011), ''Jan van Riebeeck.'' Retrieved from: https://sahistory.org.za/people/jan-van-riebeeck. Retreived on 03/01/2026.&lt;/ref&gt;

U-Jan Van Riebeeck waba lilunga le-''Dutch East India Company'' (''Vereenigde Oost-Indische Compagnie'' -  VOC) ngo-1639 lapha athoma khona ukuba msizi kadorhodere ohlinzako ekhambeni labo lokuya e-Batavia (namhlanjesi eyaziwa nge-Jakarta) ngenyanga kaSihlabantangana 1639 bese batjhinga e-Nagasaki eJapani ngo-1643.&lt;ref name=&quot;:2&quot; /&gt;
[[Isimumathi:Maria Quevellerius (1629-64), eerste vrouw van Jan van Riebeeck, of diens tweede vrouw Maria Scipio (ca. 1630-95) Rijksmuseum SK-A-806.jpeg|thumb|Umka-Jan Van Riebeeck, u-Maria Quevellerius]]
Ngo-1645 u-Jan Van Riebeeck wanikelwa isabelo sokuba mphathi wesitetjhi sokurhwebela se-VOC ebesise-Tongkin e-''French Indochina'' (namhlanjesi eyaziwa nge-Vietnam). Wehliswa esikhundleneso ngebanga lokuthi besele azenzela irhwebo lakhe langeqadi, okuphula umthetho wekhamphani othi abaphathi akukafuzi bazenzele irhwebo ngeqadi ngepahla yekhamphani. Kwathi bona ehliswe esikhundleni, wazithola sele kufuze abuyele emva e-Netherlands ayoqalana nemilandu yakhe. Ngikho-ke besele atholakala komunye wemikhumbi eli-12 ebeyidoswa phambili ngu-W.G de Jong. Wafika e-''Table Bay'' hlanu kwe-''Cape of Good Hope'' wahlala khona amalanga ali-18. Lokho kwamnikela isikhathi sokuqalisisa indawo, nokucabanga bona angayisebenzisa njani ekwenzeni bona i-VOC imthembe godu. Wayibona iyindawo enganikela ngokudla namanzi kabakhamba ngemikhumbi.&lt;ref name=&quot;:2&quot; /&gt;

Njengombana umkhumbi i-''Nieuwe Haerlem'' waphahlazeka ngo-1647, abasindileko bakha indawo lapho, u-Jan Van Riebeeck walemuka indlela ebebarhwebelana ngayo namaKhoikhoi njengombana balinde ukutakulwa. Ngemva kwalokho-ke watlola umbiko ngendawo le nangakho koke akubonileko, bewahlongoza bona indawo le ingaba yindawo ehle khulu i-VOC engayisebenzisa. Umbiko lo watlolwa ngo-1648 wathunyelwa ekhamphanini. Kwathi ngo-1651 i-VOC yathatha isiqunto sokuthi indawo ye-''Cape of Good Hope'' ayisetjenziselwe iminqopho yekhamphani.&lt;ref name=&quot;:2&quot; /&gt;

I-VOC yakhetha yena u-Jan Van Riebeeck bona kube nguye umdosiphambili ozokuhloma isitetjhi sokuphumula semikhumbi yamaDatjhi khona izokuthola ukudla okutjha okunepilo namanzi ahlanzekileko. Kwaba kusuka kwakhe-ke u-Jan Van Riebeeck, asuka e-Texel, e-Netherlands ngomhla wama-24 kuNobayeni 1651 bewayokufika e-''Table Bay'' ngomhla wesi-6 kaSihlabantangana 1652.&lt;ref name=&quot;:2&quot; /&gt; Bafika bakhamba ngemikhumbi emihlanu - i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch''.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot;&gt;Marco Ramerini, English text by Dietrich Köster (January, 11 2014), ''The Dutch in South Africa, 1652-1795 and 1802-1806.'' Retrieved from https://www.colonialvoyage.com/dutch-south-africa/. Retrieved on 03/01/2026.&lt;/ref&gt;

== Ukufika Kwakhe EKapa ==
[[Isimumathi:Jan van Riebeeck .jpg|thumb|280x280px|Ukufika kuka-Jan Van Riebeeck eKapa]]
U-Jan Van Riebeeck wasuka ngomhla wama-24 kuNobayeni 1651 e-Texel, e-Netherlands, wafika ngomhla wesi-6 kaSihlabantangana 1652.&lt;ref name=&quot;:22&quot;&gt;South African History Online (17 October 2011), ''Jan van Riebeeck.'' Retrieved from: https://sahistory.org.za/people/jan-van-riebeeck. Retreived on 03/01/2026.&lt;/ref&gt; Bafika bakhamba ngemikhumbi emihlanu - i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch.&lt;ref name=&quot;:02&quot;&gt;South African History Online (13 January 2024) ''The Dutch Settlement.'' Retrieved from: https://sahistory.org.za/article/dutch-settlement Retrieved on 01/01/2026.&lt;/ref&gt;&lt;ref name=&quot;:12&quot;&gt;Marco Ramerini, English text by Dietrich Köster (January, 11 2014), ''The Dutch in South Africa, 1652-1795 and 1802-1806.'' Retrieved from https://www.colonialvoyage.com/dutch-south-africa/. Retrieved on 03/01/2026.&lt;/ref&gt;'' Emithathu le ngiyo eyafika qangi, ngikho kwaziwa khulu le emithathu, le eminye imikhumbi emibili yafika mva. Ekufikeni kwakhe nabantu ebekakhamba nabo ngemikhumbi le wafika wakha indawo yobuphephelo ebizwa bona yi-''Fort de Goede Hoop (Fort of Good Hope).'' Bafika batjala endaweni leyo, kodwana iintjalo zabo khenge zitlhurhe kuhle, mhlamunye ngebanga lobujamo bezulu obungafani nobe-Netherlands, netjharagano ebeliphakathi kwamadoda ebekakhamba nawo nakufuze basebenze batlhgomele imikhumbu edlulako. Abantu bebabancani umsebenzi umnengi.&lt;ref name=&quot;:22&quot; /&gt;

Kwathi ngo-1655 u-Van Riebeeck wabika bona ngaphandle kwabantu abazimisele ukusebenza emasimini, isitetjhesi sizokubhalelwa ukwenza umsebenzi esihloselwe wona. Kwathi ngo-1657, i-VOC yathumela abalimi ababhadelwako, ngombandela wokuthi balime inarha bebathengisele ikhamphani iintjalo abazilimileko. Ngibo laba ebebabizwa bona ma-''Free Burghers (Vry Burgers)''. U-Jan Van Riebeeck wathatha isikhathi sakhe soke atjala bekakhiqiza amagrepsi, ama-apula namazambana, ukudla okuzokuba lisizo khulu emikhumbini edlulako. Kwathi ngo-1659 besele anesivuno samagrepsi ebesikhiqiza iwayini elibovu elilwisana nobulwele be-''scurvy,'' njengombana besele alemukile bona ukusela iwayini kuyabuvikela ubulwelobu ngokwezinga elithileko.&lt;ref name=&quot;:22&quot; /&gt;

Endabeni yokurhwebelana, zoke izinto ebezenzeka u-Jan Van Riebeeck wazitlola emajenalini wakhe. AmaDatjhi bewathenga iinkomo nezimvu kuma-Khoekhoe ngepahla ehlukahlukeneko kuhlanganise notjwala negwayi. Bese inyama yefuyo le idliwe, enye ithengiselwe abantu abadlula ngemikhumbi yekhamphani.&lt;ref name=&quot;:5&quot;&gt;Steemit Website (2018) ''SOUTH AFRICAN HISTORY: Autshumato translator and first Postmaster of The Cape of Good Hope''. Retrieved from: https://steemit.com/history/@krabgat/south-african-history-autshumato-translator-and-first-postmaster-of-the-cape-of-good-hope. Retrieved on 14/01/2026.&lt;/ref&gt;

Kwathi ngenyanga kaSewula wango-1653 kwaba nokurhitjhana phakathi kuka-Autshumato, umdosiphambili wesitjhaba sama-Khoekhoe ama-''Gorinhaikona,'' nomelusi weenkomo zika-Van Riebeeck u-David Jansz. [[U-Autshumato]] wambulala wathatha iinkomo. Ukurhitjhanokhu kuthoma nje, iintjhaba ezimbili lezi besele zingasathelelani kuhle amanzi. AmaDatjhi besele aqala u-Autshumato nabantu bakhe njengamasela. U-Jan Van Riebeeck wathi u-Autshumato lisela elinelimi elibutjhelelezi. Ama-Khoekhoe aqala amaDatjhi njengabakhohlisi ngokuthi intengo yotjwala negwayi ayilingani nentengo yesilwana esifuywako. Bebathi bangabusela utjwala buphele, babone ifuywabo emadlelweni wamaDatjhi, yanda. Bese amaKhoekhoe akhambe ayoyeba.&lt;ref&gt;Castle of Good Hope (''13th November 2018'') ''Interpreters' Flawed Contracts With Dutch''Retrieved from: https://www.castleofgoodhope.co.za/index.php/news/100-news/142-interpreters-flawed-contracts-with-dutch. Retrieved on 14/01/2026.&lt;/ref&gt;

Isenzakalo sokubulawa kuka-David Jansz sasusa ipi phakathi kwama-Khoe namaDatjhi. U-Van RieBeeck wathi u-Autshumato unomlandu wokubulala. Yeke kwaliwa ipi, ekugcineni ama-Khoe ahlulwa. U-Autshumato wabanjwa wasiwa ekuthunjweni e-''Robben Island'' ngawo umnyaka ka-1653. Kodwana ngo-1655 watjhatjululwa wabuyiswa enarheni.  Nakafikako u-Jan Van Riebeeck wamamukela wambuyisela esikhundleni sakhe sokutologa.&lt;ref name=&quot;:5&quot; /&gt;  Ngesikhathesi [[u-Autshumato]] besele azwisisa indlela amaYurobhu arhweba ngayo nendlela yokuzuza kiyo. Bekathi nakarhwebela u-Jan Van Riebeeck iinkomo, aqiniseke bona imbadelo yekhamphani yanele bona ingabhadela neenkomo azithengela zona yena, ngikho nje aba mumuntu oregileko eKapa.&lt;ref name=&quot;:5&quot; /&gt;

Ngokukhamba kwesikhathi kwaba nokhunye godu ukurhitjhana phakathi kwama-Khoekhoe namaDatjhi ngo-1657. Ukurhitjhanokhu kubangwa kungazwani kwama-''Free Burghers (Vry Burgers)''  neengqila ze-Madagascar.  U-Jan Van Riebeeck wakateleleka bona akhe isivikelo endaweni leyo, bona enze ama-Khoekhoe asuke endaweni leyo. Bekuthi ezinye iingqila naziphunyurhako asebenzise u-Autshumato njengesithunjwa ukuhlohlozela ama-Khoe bona akhambe ayokubamba iingqilezo. Kodwana iqhinga lika-Van Riebeeck khenge liphumelele ngendlela afuna ngayo. Kwathi ngo-1658 u-Autshumato wabanjwa, wathathelwa yoke ifuywakhe. Ngemva kokutjhutjhiswa wathunjwa wasiwa e-''Robben Island'' godu. Kodwana wathi nakalapho waphunyurha ngesikepe esivuzako. Bekube kunamhlanjesi, u-Autshumato nguye kwaphela umuntu okghone ukuphunyurha e-''Robben Island'' njengesibotjhwa. Kunokuthi nakabuyako enarheni abotjhwe, u-Van Riebeeck wambuyisela esikhundleni sakhe sokukhulumisana nokutologa.&lt;ref name=&quot;:5&quot; /&gt;&lt;ref name=&quot;:4&quot;&gt;Camissa Museum (2026) ''Autshumao (1610 - 1674)'', Retrieved from: https://camissamuseum.co.za/index.php/7-tributaries/1-cape-indigenous-africans/autshumao. Retrieved on 12/01/2026.&lt;/ref&gt;

== Ukufa Kwakhe ==
Ngomhla wobu-8 kuKhukhulamungu wango-1662 u-Jan Van Riebeeck wakhamba eKapa esesewula Afrika, watjhiya u-Zacharias Wagenaer bona kube nguye osala aphethe endaweni abakiyo eKapa. Wafika wahlala endaweni ebizwa bona yiMalacca namhlanjesi ebizwa bona yi-Melaka eseMalaysia, wahlala lapho bekwaba nguKhukhulamungu wango-1665. Umkakhe wahlongakala ngokubulawa bulwele bepokisi ngenyanga kaSinyikhaba ngo-1664. Ngemva kwalokho wabekwa esikhundleni sokuba ngu-''Governor-General-in-Council'' wenarha yeNdiya, begodu wahlala e-Batavia ipilwakhe yoke. Wahlongakala ngomhla we-18 kuTjhirhweni 1677.&lt;ref&gt;S2A3 Biographical Database of Southern African Science (2026)'''''Van Riebeeck,''' Commander '''Johan Antoniszoon''' (advancement of science).'' Retrieved from: https://www.s2a3.org.za/bio/Biograph_final.php?serial=2953. Retrieved on 16/01/2026.&lt;/ref&gt;

== Iinkhombo ==</text>
      <sha1>snh3ze3dhmpd7qwfgy2ijaidrlt4wze</sha1>
    </revision>
    <revision>
      <id>6134</id>
      <parentid>6133</parentid>
      <timestamp>2026-01-16T11:52:38Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>edited</comment>
      <origin>6134</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9881" sha1="anewqxb0hi7bs3yh8j7pfw4knci7kcr" xml:space="preserve">[[Isimumathi:Jan van Riebeeck cropped.jpg|thumb|U-Jan Van Riebeeck]]
'''UJan Van Riebeeck (U-''Johan Anthoniszoon &quot;Jan&quot; Van Riebeeck'')''' wabelethwa ngomhla ka-21 kuSihlabantangana 1619 e-Culemborg, e-Netherlands abelethwa nguyise ungodorhodere ohlinzako. Wakhulela e-Schiedam, e-Netherlands, kwathi ngomhla wama-28 kuNtaka 1649, watjhada u-''Maria de la Queillerie'', waba nabantwana ababunane naye.&lt;ref name=&quot;:2&quot;&gt;South African History Online (17 October 2011), ''Jan van Riebeeck.'' Retrieved from: https://sahistory.org.za/people/jan-van-riebeeck. Retreived on 03/01/2026.&lt;/ref&gt;

U-Jan Van Riebeeck waba lilunga le-''Dutch East India Company'' (''Vereenigde Oost-Indische Compagnie'' -  VOC) ngo-1639 lapha athoma khona ukuba msizi kadorhodere ohlinzako ekhambeni labo lokuya e-Batavia (namhlanjesi eyaziwa nge-Jakarta) ngenyanga kaSihlabantangana ngo-1639 bese batjhinga e-Nagasaki eJapani ngo-1643.&lt;ref name=&quot;:2&quot; /&gt;
[[Isimumathi:Maria Quevellerius (1629-64), eerste vrouw van Jan van Riebeeck, of diens tweede vrouw Maria Scipio (ca. 1630-95) Rijksmuseum SK-A-806.jpeg|thumb|Umka-Jan Van Riebeeck, u-Maria Quevellerius]]
Ngo-1645 u-Jan Van Riebeeck wanikelwa isabelo sokuba mphathi wesitetjhi sokurhwebela se-VOC ebesise-Tongkin e-''French Indochina'' (namhlanjesi eyaziwa nge-Vietnam). Wehliswa esikhundleneso ngebanga lokuthi besele azenzela irhwebo lakhe langeqadi, okuphula umthetho wekhamphani othi abaphathi akukafuzi bazenzele irhwebo ngeqadi ngepahla yekhamphani. Kwathi bona ehliswe esikhundleni, wazithola sele kufuze abuyele emva e-Netherlands ayoqalana nemilandu yakhe. Ngikho-ke besele atholakala komunye wemikhumbi eli-12 ebeyidoswa phambili ngu-W.G de Jong. Wafika e-''Table Bay'' hlanu kwe-''Cape of Good Hope'' wahlala khona amalanga ali-18. Lokho kwamnikela isikhathi sokuqalisisa indawo, nokucabanga bona angayisebenzisa njani ekwenzeni bona i-VOC imthembe godu. Wayibona iyindawo enganikela ngokudla namanzi kabakhamba ngemikhumbi.&lt;ref name=&quot;:2&quot; /&gt;

Njengombana umkhumbi i-''Nieuwe Haerlem'' waphahlazeka ngo-1647, abasindileko bakha indawo lapho, u-Jan Van Riebeeck walemuka indlela ebebarhwebelana ngayo namaKhoikhoi njengombana balinde ukutakulwa. Ngemva kwalokho-ke watlola umbiko ngendawo le nangakho koke akubonileko, bewahlongoza bona indawo le ingaba yindawo ehle khulu i-VOC engayisebenzisa. Umbiko lo watlolwa ngo-1648 wathunyelwa ekhamphanini. Kwathi ngo-1651 i-VOC yathatha isiqunto sokuthi indawo ye-''Cape of Good Hope'' ayisetjenziselwe iminqopho yekhamphani.&lt;ref name=&quot;:2&quot; /&gt;

I-VOC yakhetha yena u-Jan Van Riebeeck bona kube nguye umdosiphambili ozokuhloma isitetjhi sokuphumula semikhumbi yamaDatjhi khona izokuthola ukudla okutjha okunepilo namanzi ahlanzekileko. Kwaba kusuka kwakhe-ke u-Jan Van Riebeeck, asuka e-Texel, e-Netherlands ngomhla wama-24 kuNobayeni 1651 bewayokufika e-''Table Bay'' ngomhla wesi-6 kaSihlabantangana 1652.&lt;ref name=&quot;:2&quot; /&gt; Bafika bakhamba ngemikhumbi emihlanu - i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch''.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot;&gt;Marco Ramerini, English text by Dietrich Köster (January, 11 2014), ''The Dutch in South Africa, 1652-1795 and 1802-1806.'' Retrieved from https://www.colonialvoyage.com/dutch-south-africa/. Retrieved on 03/01/2026.&lt;/ref&gt;

== Ukufika Kwakhe EKapa ==
[[Isimumathi:Jan van Riebeeck .jpg|thumb|280x280px|Ukufika kuka-Jan Van Riebeeck eKapa]]
U-Jan Van Riebeeck wasuka ngomhla wama-24 kuNobayeni 1651 e-Texel, e-Netherlands, wafika ngomhla wesi-6 kaSihlabantangana 1652.&lt;ref name=&quot;:22&quot;&gt;South African History Online (17 October 2011), ''Jan van Riebeeck.'' Retrieved from: https://sahistory.org.za/people/jan-van-riebeeck. Retreived on 03/01/2026.&lt;/ref&gt; Bafika bakhamba ngemikhumbi emihlanu - i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch.&lt;ref name=&quot;:02&quot;&gt;South African History Online (13 January 2024) ''The Dutch Settlement.'' Retrieved from: https://sahistory.org.za/article/dutch-settlement Retrieved on 01/01/2026.&lt;/ref&gt;&lt;ref name=&quot;:12&quot;&gt;Marco Ramerini, English text by Dietrich Köster (January, 11 2014), ''The Dutch in South Africa, 1652-1795 and 1802-1806.'' Retrieved from https://www.colonialvoyage.com/dutch-south-africa/. Retrieved on 03/01/2026.&lt;/ref&gt;'' Emithathu le ngiyo eyafika qangi, ngikho kwaziwa khulu le emithathu, le eminye imikhumbi emibili yafika mva. Ekufikeni kwakhe nabantu ebekakhamba nabo ngemikhumbi le wafika wakha indawo yobuphephelo ebizwa bona yi-''Fort de Goede Hoop (Fort of Good Hope).'' Bafika batjala endaweni leyo, kodwana iintjalo zabo khenge zitlhurhe kuhle, mhlamunye ngebanga lobujamo bezulu obungafani nobe-Netherlands, netjharagano ebeliphakathi kwamadoda ebekakhamba nawo nakufuze basebenze batlhgomele imikhumbu edlulako. Abantu bebabancani umsebenzi umnengi.&lt;ref name=&quot;:22&quot; /&gt;

Kwathi ngo-1655 u-Van Riebeeck wabika bona ngaphandle kwabantu abazimisele ukusebenza emasimini, isitetjhesi sizokubhalelwa ukwenza umsebenzi esihloselwe wona. Kwathi ngo-1657, i-VOC yathumela abalimi ababhadelwako, ngombandela wokuthi balime inarha bebathengisele ikhamphani iintjalo abazilimileko. Ngibo laba ebebabizwa bona ma-''Free Burghers (Vry Burgers)''. U-Jan Van Riebeeck wathatha isikhathi sakhe soke atjala bekakhiqiza amagrepsi, ama-apula namazambana, ukudla okuzokuba lisizo khulu emikhumbini edlulako. Kwathi ngo-1659 besele anesivuno samagrepsi ebesikhiqiza iwayini elibovu elilwisana nobulwele be-''scurvy,'' njengombana besele alemukile bona ukusela iwayini kuyabuvikela ubulwelobu ngokwezinga elithileko.&lt;ref name=&quot;:22&quot; /&gt;

Endabeni yokurhwebelana, zoke izinto ebezenzeka u-Jan Van Riebeeck wazitlola emajenalini wakhe. AmaDatjhi bewathenga iinkomo nezimvu kuma-Khoekhoe ngepahla ehlukahlukeneko kuhlanganise notjwala negwayi. Bese inyama yefuyo le idliwe, enye ithengiselwe abantu abadlula ngemikhumbi yekhamphani.&lt;ref name=&quot;:5&quot;&gt;Steemit Website (2018) ''SOUTH AFRICAN HISTORY: Autshumato translator and first Postmaster of The Cape of Good Hope''. Retrieved from: https://steemit.com/history/@krabgat/south-african-history-autshumato-translator-and-first-postmaster-of-the-cape-of-good-hope. Retrieved on 14/01/2026.&lt;/ref&gt;

Kwathi ngenyanga kaSewula wango-1653 kwaba nokurhitjhana phakathi kuka-Autshumato, umdosiphambili wesitjhaba sama-Khoekhoe ama-''Gorinhaikona,'' nomelusi weenkomo zika-Van Riebeeck u-David Jansz. [[U-Autshumato]] wambulala wathatha iinkomo. Ukurhitjhanokhu kuthoma nje, iintjhaba ezimbili lezi besele zingasathelelani kuhle amanzi. AmaDatjhi besele aqala u-Autshumato nabantu bakhe njengamasela. U-Jan Van Riebeeck wathi u-Autshumato lisela elinelimi elibutjhelelezi. Ama-Khoekhoe aqala amaDatjhi njengabakhohlisi ngokuthi intengo yotjwala negwayi ayilingani nentengo yesilwana esifuywako. Bebathi bangabusela utjwala buphele, babone ifuywabo emadlelweni wamaDatjhi, yanda. Bese amaKhoekhoe akhambe ayoyeba.&lt;ref&gt;Castle of Good Hope (''13th November 2018'') ''Interpreters' Flawed Contracts With Dutch''Retrieved from: https://www.castleofgoodhope.co.za/index.php/news/100-news/142-interpreters-flawed-contracts-with-dutch. Retrieved on 14/01/2026.&lt;/ref&gt;

Isenzakalo sokubulawa kuka-David Jansz sasusa ipi phakathi kwama-Khoe namaDatjhi. U-Van RieBeeck wathi u-Autshumato unomlandu wokubulala. Yeke kwaliwa ipi, ekugcineni ama-Khoe ahlulwa. U-Autshumato wabanjwa wasiwa ekuthunjweni e-''Robben Island'' ngawo umnyaka ka-1653. Kodwana ngo-1655 watjhatjululwa wabuyiswa enarheni.  Nakafikako u-Jan Van Riebeeck wamamukela wambuyisela esikhundleni sakhe sokutologa.&lt;ref name=&quot;:5&quot; /&gt;  Ngesikhathesi [[u-Autshumato]] besele azwisisa indlela amaYurobhu arhweba ngayo nendlela yokuzuza kiyo. Bekathi nakarhwebela u-Jan Van Riebeeck iinkomo, aqiniseke bona imbadelo yekhamphani yanele bona ingabhadela neenkomo azithengela zona yena, ngikho nje aba mumuntu oregileko eKapa.&lt;ref name=&quot;:5&quot; /&gt;

Ngokukhamba kwesikhathi kwaba nokhunye godu ukurhitjhana phakathi kwama-Khoekhoe namaDatjhi ngo-1657. Ukurhitjhanokhu kubangwa kungazwani kwama-''Free Burghers (Vry Burgers)''  neengqila ze-Madagascar.  U-Jan Van Riebeeck wakateleleka bona akhe isivikelo endaweni leyo, bona enze ama-Khoekhoe asuke endaweni leyo. Bekuthi ezinye iingqila naziphunyurhako asebenzise u-Autshumato njengesithunjwa ukuhlohlozela ama-Khoe bona akhambe ayokubamba iingqilezo. Kodwana iqhinga lika-Van Riebeeck khenge liphumelele ngendlela afuna ngayo. Kwathi ngo-1658 u-Autshumato wabanjwa, wathathelwa yoke ifuywakhe. Ngemva kokutjhutjhiswa wathunjwa wasiwa e-''Robben Island'' godu. Kodwana wathi nakalapho waphunyurha ngesikepe esivuzako. Bekube kunamhlanjesi, u-Autshumato nguye kwaphela umuntu okghone ukuphunyurha e-''Robben Island'' njengesibotjhwa. Kunokuthi nakabuyako enarheni abotjhwe, u-Van Riebeeck wambuyisela esikhundleni sakhe sokukhulumisana nokutologa.&lt;ref name=&quot;:5&quot; /&gt;&lt;ref name=&quot;:4&quot;&gt;Camissa Museum (2026) ''Autshumao (1610 - 1674)'', Retrieved from: https://camissamuseum.co.za/index.php/7-tributaries/1-cape-indigenous-africans/autshumao. Retrieved on 12/01/2026.&lt;/ref&gt;

== Ukufa Kwakhe ==
Ngomhla wobu-8 kuKhukhulamungu wango-1662 u-Jan Van Riebeeck wakhamba eKapa esesewula Afrika, watjhiya u-Zacharias Wagenaer bona kube nguye osala aphethe endaweni abakiyo eKapa. Wafika wahlala endaweni ebizwa bona yiMalacca namhlanjesi ebizwa bona yi-Melaka eseMalaysia, wahlala lapho bekwaba nguKhukhulamungu wango-1665. Umkakhe wahlongakala ngokubulawa bulwele bepokisi ngenyanga kaSinyikhaba ngo-1664. Ngemva kwalokho wabekwa esikhundleni sokuba ngu-''Governor-General-in-Council'' wenarha yeNdiya, begodu wahlala e-Batavia ipilwakhe yoke. Wahlongakala ngomhla we-18 kuTjhirhweni 1677.&lt;ref&gt;S2A3 Biographical Database of Southern African Science (2026)'''''Van Riebeeck,''' Commander '''Johan Antoniszoon''' (advancement of science).'' Retrieved from: https://www.s2a3.org.za/bio/Biograph_final.php?serial=2953. Retrieved on 16/01/2026.&lt;/ref&gt;

== Iinkhombo ==</text>
      <sha1>anewqxb0hi7bs3yh8j7pfw4knci7kcr</sha1>
    </revision>
    <revision>
      <id>6135</id>
      <parentid>6134</parentid>
      <timestamp>2026-01-16T11:53:27Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>edited</comment>
      <origin>6135</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9882" sha1="d0mfev6ac2xbxfmtiuhbxcjdgwhcnow" xml:space="preserve">[[Isimumathi:Jan van Riebeeck cropped.jpg|thumb|U-Jan Van Riebeeck]]
'''UJan Van Riebeeck (U-''Johan Anthoniszoon &quot;Jan&quot; Van Riebeeck'')''' wabelethwa ngomhla wama-21 kuSihlabantangana 1619 e-Culemborg, e-Netherlands abelethwa nguyise ungodorhodere ohlinzako. Wakhulela e-Schiedam, e-Netherlands, kwathi ngomhla wama-28 kuNtaka 1649, watjhada u-''Maria de la Queillerie'', waba nabantwana ababunane naye.&lt;ref name=&quot;:2&quot;&gt;South African History Online (17 October 2011), ''Jan van Riebeeck.'' Retrieved from: https://sahistory.org.za/people/jan-van-riebeeck. Retreived on 03/01/2026.&lt;/ref&gt;

U-Jan Van Riebeeck waba lilunga le-''Dutch East India Company'' (''Vereenigde Oost-Indische Compagnie'' - VOC) ngo-1639 lapha athoma khona ukuba msizi kadorhodere ohlinzako ekhambeni labo lokuya e-Batavia (namhlanjesi eyaziwa nge-Jakarta) ngenyanga kaSihlabantangana ngo-1639 bese batjhinga e-Nagasaki eJapani ngo-1643.&lt;ref name=&quot;:2&quot; /&gt;
[[Isimumathi:Maria Quevellerius (1629-64), eerste vrouw van Jan van Riebeeck, of diens tweede vrouw Maria Scipio (ca. 1630-95) Rijksmuseum SK-A-806.jpeg|thumb|Umka-Jan Van Riebeeck, u-Maria Quevellerius]]
Ngo-1645 u-Jan Van Riebeeck wanikelwa isabelo sokuba mphathi wesitetjhi sokurhwebela se-VOC ebesise-Tongkin e-''French Indochina'' (namhlanjesi eyaziwa nge-Vietnam). Wehliswa esikhundleneso ngebanga lokuthi besele azenzela irhwebo lakhe langeqadi, okuphula umthetho wekhamphani othi abaphathi akukafuzi bazenzele irhwebo ngeqadi ngepahla yekhamphani. Kwathi bona ehliswe esikhundleni, wazithola sele kufuze abuyele emva e-Netherlands ayoqalana nemilandu yakhe. Ngikho-ke besele atholakala komunye wemikhumbi eli-12 ebeyidoswa phambili ngu-W.G de Jong. Wafika e-''Table Bay'' hlanu kwe-''Cape of Good Hope'' wahlala khona amalanga ali-18. Lokho kwamnikela isikhathi sokuqalisisa indawo, nokucabanga bona angayisebenzisa njani ekwenzeni bona i-VOC imthembe godu. Wayibona iyindawo enganikela ngokudla namanzi kabakhamba ngemikhumbi.&lt;ref name=&quot;:2&quot; /&gt;

Njengombana umkhumbi i-''Nieuwe Haerlem'' waphahlazeka ngo-1647, abasindileko bakha indawo lapho, u-Jan Van Riebeeck walemuka indlela ebebarhwebelana ngayo namaKhoikhoi njengombana balinde ukutakulwa. Ngemva kwalokho-ke watlola umbiko ngendawo le nangakho koke akubonileko, bewahlongoza bona indawo le ingaba yindawo ehle khulu i-VOC engayisebenzisa. Umbiko lo watlolwa ngo-1648 wathunyelwa ekhamphanini. Kwathi ngo-1651 i-VOC yathatha isiqunto sokuthi indawo ye-''Cape of Good Hope'' ayisetjenziselwe iminqopho yekhamphani.&lt;ref name=&quot;:2&quot; /&gt;

I-VOC yakhetha yena u-Jan Van Riebeeck bona kube nguye umdosiphambili ozokuhloma isitetjhi sokuphumula semikhumbi yamaDatjhi khona izokuthola ukudla okutjha okunepilo namanzi ahlanzekileko. Kwaba kusuka kwakhe-ke u-Jan Van Riebeeck, asuka e-Texel, e-Netherlands ngomhla wama-24 kuNobayeni 1651 bewayokufika e-''Table Bay'' ngomhla wesi-6 kaSihlabantangana 1652.&lt;ref name=&quot;:2&quot; /&gt; Bafika bakhamba ngemikhumbi emihlanu - i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch''.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot;&gt;Marco Ramerini, English text by Dietrich Köster (January, 11 2014), ''The Dutch in South Africa, 1652-1795 and 1802-1806.'' Retrieved from https://www.colonialvoyage.com/dutch-south-africa/. Retrieved on 03/01/2026.&lt;/ref&gt;

== Ukufika Kwakhe EKapa ==
[[Isimumathi:Jan van Riebeeck .jpg|thumb|280x280px|Ukufika kuka-Jan Van Riebeeck eKapa]]
U-Jan Van Riebeeck wasuka ngomhla wama-24 kuNobayeni 1651 e-Texel, e-Netherlands, wafika ngomhla wesi-6 kaSihlabantangana 1652.&lt;ref name=&quot;:22&quot;&gt;South African History Online (17 October 2011), ''Jan van Riebeeck.'' Retrieved from: https://sahistory.org.za/people/jan-van-riebeeck. Retreived on 03/01/2026.&lt;/ref&gt; Bafika bakhamba ngemikhumbi emihlanu - i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch.&lt;ref name=&quot;:02&quot;&gt;South African History Online (13 January 2024) ''The Dutch Settlement.'' Retrieved from: https://sahistory.org.za/article/dutch-settlement Retrieved on 01/01/2026.&lt;/ref&gt;&lt;ref name=&quot;:12&quot;&gt;Marco Ramerini, English text by Dietrich Köster (January, 11 2014), ''The Dutch in South Africa, 1652-1795 and 1802-1806.'' Retrieved from https://www.colonialvoyage.com/dutch-south-africa/. Retrieved on 03/01/2026.&lt;/ref&gt;'' Emithathu le ngiyo eyafika qangi, ngikho kwaziwa khulu le emithathu, le eminye imikhumbi emibili yafika mva. Ekufikeni kwakhe nabantu ebekakhamba nabo ngemikhumbi le wafika wakha indawo yobuphephelo ebizwa bona yi-''Fort de Goede Hoop (Fort of Good Hope).'' Bafika batjala endaweni leyo, kodwana iintjalo zabo khenge zitlhurhe kuhle, mhlamunye ngebanga lobujamo bezulu obungafani nobe-Netherlands, netjharagano ebeliphakathi kwamadoda ebekakhamba nawo nakufuze basebenze batlhgomele imikhumbu edlulako. Abantu bebabancani umsebenzi umnengi.&lt;ref name=&quot;:22&quot; /&gt;

Kwathi ngo-1655 u-Van Riebeeck wabika bona ngaphandle kwabantu abazimisele ukusebenza emasimini, isitetjhesi sizokubhalelwa ukwenza umsebenzi esihloselwe wona. Kwathi ngo-1657, i-VOC yathumela abalimi ababhadelwako, ngombandela wokuthi balime inarha bebathengisele ikhamphani iintjalo abazilimileko. Ngibo laba ebebabizwa bona ma-''Free Burghers (Vry Burgers)''. U-Jan Van Riebeeck wathatha isikhathi sakhe soke atjala bekakhiqiza amagrepsi, ama-apula namazambana, ukudla okuzokuba lisizo khulu emikhumbini edlulako. Kwathi ngo-1659 besele anesivuno samagrepsi ebesikhiqiza iwayini elibovu elilwisana nobulwele be-''scurvy,'' njengombana besele alemukile bona ukusela iwayini kuyabuvikela ubulwelobu ngokwezinga elithileko.&lt;ref name=&quot;:22&quot; /&gt;

Endabeni yokurhwebelana, zoke izinto ebezenzeka u-Jan Van Riebeeck wazitlola emajenalini wakhe. AmaDatjhi bewathenga iinkomo nezimvu kuma-Khoekhoe ngepahla ehlukahlukeneko kuhlanganise notjwala negwayi. Bese inyama yefuyo le idliwe, enye ithengiselwe abantu abadlula ngemikhumbi yekhamphani.&lt;ref name=&quot;:5&quot;&gt;Steemit Website (2018) ''SOUTH AFRICAN HISTORY: Autshumato translator and first Postmaster of The Cape of Good Hope''. Retrieved from: https://steemit.com/history/@krabgat/south-african-history-autshumato-translator-and-first-postmaster-of-the-cape-of-good-hope. Retrieved on 14/01/2026.&lt;/ref&gt;

Kwathi ngenyanga kaSewula wango-1653 kwaba nokurhitjhana phakathi kuka-Autshumato, umdosiphambili wesitjhaba sama-Khoekhoe ama-''Gorinhaikona,'' nomelusi weenkomo zika-Van Riebeeck u-David Jansz. [[U-Autshumato]] wambulala wathatha iinkomo. Ukurhitjhanokhu kuthoma nje, iintjhaba ezimbili lezi besele zingasathelelani kuhle amanzi. AmaDatjhi besele aqala u-Autshumato nabantu bakhe njengamasela. U-Jan Van Riebeeck wathi u-Autshumato lisela elinelimi elibutjhelelezi. Ama-Khoekhoe aqala amaDatjhi njengabakhohlisi ngokuthi intengo yotjwala negwayi ayilingani nentengo yesilwana esifuywako. Bebathi bangabusela utjwala buphele, babone ifuywabo emadlelweni wamaDatjhi, yanda. Bese amaKhoekhoe akhambe ayoyeba.&lt;ref&gt;Castle of Good Hope (''13th November 2018'') ''Interpreters' Flawed Contracts With Dutch''Retrieved from: https://www.castleofgoodhope.co.za/index.php/news/100-news/142-interpreters-flawed-contracts-with-dutch. Retrieved on 14/01/2026.&lt;/ref&gt;

Isenzakalo sokubulawa kuka-David Jansz sasusa ipi phakathi kwama-Khoe namaDatjhi. U-Van RieBeeck wathi u-Autshumato unomlandu wokubulala. Yeke kwaliwa ipi, ekugcineni ama-Khoe ahlulwa. U-Autshumato wabanjwa wasiwa ekuthunjweni e-''Robben Island'' ngawo umnyaka ka-1653. Kodwana ngo-1655 watjhatjululwa wabuyiswa enarheni.  Nakafikako u-Jan Van Riebeeck wamamukela wambuyisela esikhundleni sakhe sokutologa.&lt;ref name=&quot;:5&quot; /&gt;  Ngesikhathesi [[u-Autshumato]] besele azwisisa indlela amaYurobhu arhweba ngayo nendlela yokuzuza kiyo. Bekathi nakarhwebela u-Jan Van Riebeeck iinkomo, aqiniseke bona imbadelo yekhamphani yanele bona ingabhadela neenkomo azithengela zona yena, ngikho nje aba mumuntu oregileko eKapa.&lt;ref name=&quot;:5&quot; /&gt;

Ngokukhamba kwesikhathi kwaba nokhunye godu ukurhitjhana phakathi kwama-Khoekhoe namaDatjhi ngo-1657. Ukurhitjhanokhu kubangwa kungazwani kwama-''Free Burghers (Vry Burgers)''  neengqila ze-Madagascar.  U-Jan Van Riebeeck wakateleleka bona akhe isivikelo endaweni leyo, bona enze ama-Khoekhoe asuke endaweni leyo. Bekuthi ezinye iingqila naziphunyurhako asebenzise u-Autshumato njengesithunjwa ukuhlohlozela ama-Khoe bona akhambe ayokubamba iingqilezo. Kodwana iqhinga lika-Van Riebeeck khenge liphumelele ngendlela afuna ngayo. Kwathi ngo-1658 u-Autshumato wabanjwa, wathathelwa yoke ifuywakhe. Ngemva kokutjhutjhiswa wathunjwa wasiwa e-''Robben Island'' godu. Kodwana wathi nakalapho waphunyurha ngesikepe esivuzako. Bekube kunamhlanjesi, u-Autshumato nguye kwaphela umuntu okghone ukuphunyurha e-''Robben Island'' njengesibotjhwa. Kunokuthi nakabuyako enarheni abotjhwe, u-Van Riebeeck wambuyisela esikhundleni sakhe sokukhulumisana nokutologa.&lt;ref name=&quot;:5&quot; /&gt;&lt;ref name=&quot;:4&quot;&gt;Camissa Museum (2026) ''Autshumao (1610 - 1674)'', Retrieved from: https://camissamuseum.co.za/index.php/7-tributaries/1-cape-indigenous-africans/autshumao. Retrieved on 12/01/2026.&lt;/ref&gt;

== Ukufa Kwakhe ==
Ngomhla wobu-8 kuKhukhulamungu wango-1662 u-Jan Van Riebeeck wakhamba eKapa esesewula Afrika, watjhiya u-Zacharias Wagenaer bona kube nguye osala aphethe endaweni abakiyo eKapa. Wafika wahlala endaweni ebizwa bona yiMalacca namhlanjesi ebizwa bona yi-Melaka eseMalaysia, wahlala lapho bekwaba nguKhukhulamungu wango-1665. Umkakhe wahlongakala ngokubulawa bulwele bepokisi ngenyanga kaSinyikhaba ngo-1664. Ngemva kwalokho wabekwa esikhundleni sokuba ngu-''Governor-General-in-Council'' wenarha yeNdiya, begodu wahlala e-Batavia ipilwakhe yoke. Wahlongakala ngomhla we-18 kuTjhirhweni 1677.&lt;ref&gt;S2A3 Biographical Database of Southern African Science (2026)'''''Van Riebeeck,''' Commander '''Johan Antoniszoon''' (advancement of science).'' Retrieved from: https://www.s2a3.org.za/bio/Biograph_final.php?serial=2953. Retrieved on 16/01/2026.&lt;/ref&gt;

== Iinkhombo ==</text>
      <sha1>d0mfev6ac2xbxfmtiuhbxcjdgwhcnow</sha1>
    </revision>
    <revision>
      <id>6139</id>
      <parentid>6135</parentid>
      <timestamp>2026-01-19T20:31:49Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>edited</comment>
      <origin>6139</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9883" sha1="tvsvr5uzmegclct27nlcd7oo3i8y5ns" xml:space="preserve">[[Isimumathi:Jan van Riebeeck cropped.jpg|thumb|U-Jan Van Riebeeck]]
'''UJan Van Riebeeck (U-''Johan Anthoniszoon &quot;Jan&quot; Van Riebeeck'')''' wabelethwa ngomhla wama-21 kuSihlabantangana 1619 e-Culemborg, e-Netherlands abelethwa nguyise ungodorhodere ohlinzako. Wakhulela e-Schiedam, e-Netherlands, kwathi ngomhla wama-28 kuNtaka 1649, watjhada u-''Maria de la Queillerie'', waba nabantwana ababunane naye.&lt;ref name=&quot;:2&quot;&gt;South African History Online (17 October 2011), ''Jan van Riebeeck.'' Retrieved from: https://sahistory.org.za/people/jan-van-riebeeck. Retreived on 03/01/2026.&lt;/ref&gt;

U-Jan Van Riebeeck waba lilunga le-''Dutch East India Company'' (''Vereenigde Oost-Indische Compagnie'' - VOC) ngo-1639 lapha athoma khona ukuba msizi kadorhodere ohlinzako ekhambeni labo lokuya e-Batavia (namhlanjesi eyaziwa nge-Jakarta) ngenyanga kaSihlabantangana ngo-1639 bese batjhinga e-Nagasaki eJapani ngo-1643.&lt;ref name=&quot;:2&quot; /&gt;
[[Isimumathi:Maria Quevellerius (1629-64), eerste vrouw van Jan van Riebeeck, of diens tweede vrouw Maria Scipio (ca. 1630-95) Rijksmuseum SK-A-806.jpeg|thumb|Umka-Jan Van Riebeeck, u-Maria Quevellerius]]
Ngo-1645 u-Jan Van Riebeeck wanikelwa isabelo sokuba mphathi wesitetjhi sokurhwebela se-VOC ebesise-Tongkin e-''French Indochina'' (namhlanjesi eyaziwa nge-Vietnam). Wehliswa esikhundleneso ngebanga lokuthi besele azenzela irhwebo lakhe langeqadi, okuphula umthetho wekhamphani othi abaphathi akukafuzi bazenzele irhwebo ngeqadi ngepahla yekhamphani. Kwathi bona ehliswe esikhundleni, wazithola sele kufuze abuyele emva e-Netherlands ayoqalana nemilandu yakhe. Ngikho-ke besele atholakala komunye wemikhumbi eli-12 ebeyidoswa phambili ngu-W.G de Jong. Wafika e-''Table Bay'' hlanu kwe-''Cape of Good Hope'' wahlala khona amalanga ali-18. Lokho kwamnikela isikhathi sokuqalisisa indawo, nokucabanga bona angayisebenzisa njani ekwenzeni bona i-VOC imthembe godu. Wayibona iyindawo enganikela ngokudla namanzi kabakhamba ngemikhumbi.&lt;ref name=&quot;:2&quot; /&gt;

Njengombana umkhumbi i-''Nieuwe Haerlem'' waphahlazeka ngo-1647, abasindileko bakha indawo lapho, u-Jan Van Riebeeck walemuka indlela ebebarhwebelana ngayo namaKhoikhoi njengombana balinde ukutakulwa. Ngemva kwalokho-ke watlola umbiko ngendawo le nangakho koke akubonileko, bewahlongoza bona indawo le ingaba yindawo ehle khulu i-VOC engayisebenzisa. Umbiko lo watlolwa ngo-1648 wathunyelwa ekhamphanini. Kwathi ngo-1651 i-VOC yathatha isiqunto sokuthi indawo ye-''Cape of Good Hope'' ayisetjenziselwe iminqopho yekhamphani.&lt;ref name=&quot;:2&quot; /&gt;

I-VOC yakhetha yena u-Jan Van Riebeeck bona kube nguye umdosiphambili ozokuhloma isitetjhi sokuphumula semikhumbi yamaDatjhi khona izokuthola ukudla okutjha okunepilo namanzi ahlanzekileko. Kwaba kusuka kwakhe-ke u-Jan Van Riebeeck, asuka e-Texel, e-Netherlands ngomhla wama-24 kuNobayeni 1651 bewayokufika e-''Table Bay'' ngomhla wesi-6 kaSihlabantangana 1652.&lt;ref name=&quot;:2&quot; /&gt; Bafika bakhamba ngemikhumbi emihlanu - i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch''.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot;&gt;Marco Ramerini, English text by Dietrich Köster (January, 11 2014), ''The Dutch in South Africa, 1652-1795 and 1802-1806.'' Retrieved from https://www.colonialvoyage.com/dutch-south-africa/. Retrieved on 03/01/2026.&lt;/ref&gt;

== Ukufika Kwakhe EKapa ==
[[Isimumathi:Jan van Riebeeck .jpg|thumb|280x280px|Ukufika kuka-Jan Van Riebeeck eKapa]]
U-Jan Van Riebeeck wasuka ngomhla wama-24 kuNobayeni 1651 e-Texel, e-Netherlands, wafika ngomhla wesi-6 kaSihlabantangana 1652.&lt;ref name=&quot;:22&quot;&gt;South African History Online (17 October 2011), ''Jan van Riebeeck.'' Retrieved from: https://sahistory.org.za/people/jan-van-riebeeck. Retreived on 03/01/2026.&lt;/ref&gt; Bafika bakhamba ngemikhumbi emihlanu - i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch.&lt;ref name=&quot;:02&quot;&gt;South African History Online (13 January 2024) ''The Dutch Settlement.'' Retrieved from: https://sahistory.org.za/article/dutch-settlement Retrieved on 01/01/2026.&lt;/ref&gt;&lt;ref name=&quot;:12&quot;&gt;Marco Ramerini, English text by Dietrich Köster (January, 11 2014), ''The Dutch in South Africa, 1652-1795 and 1802-1806.'' Retrieved from https://www.colonialvoyage.com/dutch-south-africa/. Retrieved on 03/01/2026.&lt;/ref&gt;'' Emithathu le ngiyo eyafika qangi, ngikho kwaziwa khulu le emithathu, le eminye imikhumbi emibili yafika mva. Ekufikeni kwakhe nabantu ebekakhamba nabo ngemikhumbi le wafika wakha indawo yobuphephelo ebizwa bona yi-''Fort de Goede Hoop (Fort of Good Hope).'' Bafika batjala endaweni leyo, kodwana iintjalo zabo khenge zitlhurhe kuhle, mhlamunye ngebanga lobujamo bezulu obungafani nobe-Netherlands, netjharagano ebeliphakathi kwamadoda ebekakhamba nawo nakufuze basebenze batlhgomele imikhumbu edlulako. Abantu bebabancani umsebenzi umnengi.&lt;ref name=&quot;:22&quot; /&gt;

Kwathi ngo-1655 u-Van Riebeeck wabika bona ngaphandle kwabantu abazimisele ukusebenza emasimini, isitetjhesi sizokubhalelwa ukwenza umsebenzi esihloselwe wona. Kwathi ngo-1657, i-VOC yathumela abalimi ababhadelwako, ngombandela wokuthi balime inarha bebathengisele ikhamphani iintjalo abazilimileko. Ngibo laba ebebabizwa bona ma-''Free Burghers (Vry Burgers)''. U-Jan Van Riebeeck wathatha isikhathi sakhe soke atjala bekakhiqiza amagrepsi, ama-apula namazambana, ukudla okuzokuba lisizo khulu emikhumbini edlulako. Kwathi ngo-1659 besele anesivuno samagrepsi ebesikhiqiza iwayini elibovu elilwisana nobulwele be-''scurvy,'' njengombana besele alemukile bona ukusela iwayini kuyabuvikela ubulwelobu ngokwezinga elithileko.&lt;ref name=&quot;:22&quot; /&gt;

Endabeni yokurhwebelana, zoke izinto ebezenzeka u-Jan Van Riebeeck wazitlola emajenalini wakhe. AmaDatjhi bewathenga iinkomo nezimvu kuma-Khoekhoe ngepahla ehlukahlukeneko kuhlanganise notjwala negwayi. Bese inyama yefuyo le idliwe, enye ithengiselwe abantu abadlula ngemikhumbi yekhamphani.&lt;ref name=&quot;:5&quot;&gt;Steemit Website (2018) ''SOUTH AFRICAN HISTORY: Autshumato translator and first Postmaster of The Cape of Good Hope''. Retrieved from: https://steemit.com/history/@krabgat/south-african-history-autshumato-translator-and-first-postmaster-of-the-cape-of-good-hope. Retrieved on 14/01/2026.&lt;/ref&gt;

Kwathi ngenyanga kaSewula wango-1653 kwaba nokurhitjhana phakathi kuka-Autshumato, umdosiphambili wesitjhaba sama-Khoekhoe ama-''Gorinhaikona,'' nomelusi weenkomo zika-Van Riebeeck u-David Jansz. [[U-Autshumato]] wambulala wathatha iinkomo. Ukurhitjhanokhu kuthoma nje, iintjhaba ezimbili lezi besele zingasathelelani kuhle amanzi. AmaDatjhi besele aqala u-Autshumato nabantu bakhe njengamasela. U-Jan Van Riebeeck wathi u-Autshumato lisela elinelimi elibutjhelelezi. Ama-Khoekhoe aqala amaDatjhi njengabakhohlisi ngokuthi intengo yotjwala negwayi ayilingani nentengo yesilwana esifuywako. Bebathi bangabusela utjwala buphele, babone ifuywabo emadlelweni wamaDatjhi, yanda. Bese amaKhoekhoe akhambe ayoyeba.&lt;ref&gt;Castle of Good Hope (''13th November 2018'') ''Interpreters' Flawed Contracts With Dutch''Retrieved from: https://www.castleofgoodhope.co.za/index.php/news/100-news/142-interpreters-flawed-contracts-with-dutch. Retrieved on 14/01/2026.&lt;/ref&gt;

Isenzakalo sokubulawa kuka-David Jansz sasusa ipi phakathi kwama-Khoe namaDatjhi. U-Van RieBeeck wathi u-Autshumato unomlandu wokubulala. Yeke kwaliwa ipi, ekugcineni ama-Khoe ahlulwa. U-Autshumato wabanjwa wasiwa ekuthunjweni e-''Robben Island'' ngawo umnyaka ka-1653. Kodwana ngo-1655 watjhatjululwa wabuyiswa enarheni.  Nakafikako u-Jan Van Riebeeck wamamukela wambuyisela esikhundleni sakhe sokutologa.&lt;ref name=&quot;:5&quot; /&gt;  Ngesikhathesi [[u-Autshumato]] besele azwisisa indlela amaYurobhu arhweba ngayo nendlela yokuzuza kiyo. Bekathi nakarhwebela u-Jan Van Riebeeck iinkomo, aqiniseke bona imbadelo yekhamphani yanele bona ingabhadela neenkomo azithengela zona yena, ngikho nje aba mumuntu oregileko eKapa.&lt;ref name=&quot;:5&quot; /&gt;

Ngokukhamba kwesikhathi kwaba nokhunye godu ukurhitjhana phakathi kwama-Khoekhoe namaDatjhi ngo-1657. Ukurhitjhanokhu kubangwa kungazwani kwama-''Free Burghers (Vry Burgers)''  neengqila ze-Madagascar.  U-Jan Van Riebeeck wakateleleka bona akhe isivikelo endaweni leyo, bona enze ama-Khoekhoe asuke endaweni leyo. Bekuthi ezinye iingqila naziphunyurhako asebenzise u-Autshumato njengesithunjwa ukuhlohlozela ama-Khoe bona akhambe ayokubamba iingqilezo. Kodwana iqhinga lika-Van Riebeeck khenge liphumelele ngendlela afuna ngayo. Kwathi ngo-1658 u-Autshumato wabanjwa, wathathelwa yoke ifuywakhe. Ngemva kokutjhutjhiswa wathunjwa wasiwa e-''Robben Island'' godu. Kodwana wathi nakalapho waphunyurha ngesikepe esivuzako. Bekube kunamhlanjesi, u-Autshumato nguye kwaphela umuntu okghone ukuphunyurha e-''Robben Island'' njengesibotjhwa. Kunokuthi nakabuyako enarheni abotjhwe, u-Van Riebeeck wambuyisela esikhundleni sakhe sokukhulumisana nokutologa.&lt;ref name=&quot;:5&quot; /&gt;&lt;ref name=&quot;:4&quot;&gt;Camissa Museum (2026) ''Autshumao (1610 - 1674)'', Retrieved from: https://camissamuseum.co.za/index.php/7-tributaries/1-cape-indigenous-africans/autshumao. Retrieved on 12/01/2026.&lt;/ref&gt;

== Ukufa Kwakhe ==
Ngomhla wobu-8 kuKhukhulamungu wango-1662 u-Jan Van Riebeeck wakhamba eKapa esesewula Afrika, watjhiya u-Zacharias Wagenaer bona kube nguye osala aphethe endaweni abakiyo eKapa. Wafika wahlala endaweni ebizwa bona yiMalacca namhlanjesi ebizwa bona yi-Melaka eseMalaysia, wahlala lapho bekwaba nguKhukhulamungu wango-1665. Umkakhe wahlongakala ngokubulawa bulwele bepokisi ngenyanga kaSinyikhaba ngo-1664. Ngemva kwalokho wabekwa esikhundleni sokuba ngu-''Governor-General-in-Council'' wenarha yeNdiya, begodu wahlala e-Batavia ipilwakhe yoke. Wahlongakala ngomhla we-18 kuTjhirhweni 1677.&lt;ref&gt;S2A3 Biographical Database of Southern African Science (2026)'''''Van Riebeeck,''' Commander '''Johan Antoniszoon''' (advancement of science).'' Retrieved from: https://www.s2a3.org.za/bio/Biograph_final.php?serial=2953. Retrieved on 16/01/2026.&lt;/ref&gt; 

== Iinkhombo ==</text>
      <sha1>tvsvr5uzmegclct27nlcd7oo3i8y5ns</sha1>
    </revision>
    <revision>
      <id>6140</id>
      <parentid>6139</parentid>
      <timestamp>2026-01-19T20:34:20Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>edited</comment>
      <origin>6140</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9866" sha1="tvj56ouaqeykh2od8e56j3c4ze7euf3" xml:space="preserve">[[Isimumathi:Jan van Riebeeck cropped.jpg|thumb|U-Jan Van Riebeeck]]
'''UJan Van Riebeeck (U-''Johan Anthoniszoon &quot;Jan&quot; Van Riebeeck'')''' wabelethwa ngomhla wama-21 kuSihlabantangana 1619 e-Culemborg, e-Netherlands abelethwa nguyise ungodorhodere ohlinzako. Wakhulela e-Schiedam, e-Netherlands, kwathi ngomhla wama-28 kuNtaka 1649, watjhada u-''Maria de la Queillerie'', waba nabantwana ababunane naye.&lt;ref name=&quot;:2&quot;&gt;South African History Online (17 October 2011), ''Jan van Riebeeck.'' Retrieved from: https://sahistory.org.za/people/jan-van-riebeeck. Retreived on 03/01/2026.&lt;/ref&gt;

U-Jan Van Riebeeck waba lilunga le-''Dutch East India Company'' (''Vereenigde Oost-Indische Compagnie'' - VOC) ngo-1639 lapha athoma khona ukuba msizi kadorhodere ohlinzako ekhambeni labo lokuya e-Batavia (namhlanjesi eyaziwa nge-Jakarta) ngenyanga kaSihlabantangana ngo-1639 bese batjhinga e-Nagasaki eJapani ngo-1643.&lt;ref name=&quot;:2&quot; /&gt;
[[Isimumathi:Maria Quevellerius (1629-64), eerste vrouw van Jan van Riebeeck, of diens tweede vrouw Maria Scipio (ca. 1630-95) Rijksmuseum SK-A-806.jpeg|thumb|Umka-Jan Van Riebeeck, u-Maria Quevellerius]]
Ngo-1645 u-Jan Van Riebeeck wanikelwa isabelo sokuba mphathi wesitetjhi sokurhwebela se-VOC ebesise-Tongkin e-''French Indochina'' (namhlanjesi eyaziwa nge-Vietnam). Wehliswa esikhundleneso ngebanga lokuthi besele azenzela irhwebo lakhe langeqadi, okuphula umthetho wekhamphani othi abaphathi akukafuzi bazenzele irhwebo ngeqadi ngepahla yekhamphani. Kwathi bona ehliswe esikhundleni, wazithola sele kufuze abuyele emva e-Netherlands ayoqalana nemilandu yakhe. Ngikho-ke besele atholakala komunye wemikhumbi eli-12 ebeyidoswa phambili ngu-W.G de Jong. Wafika e-''Table Bay'' hlanu kwe-''Cape of Good Hope'' wahlala khona amalanga ali-18. Lokho kwamnikela isikhathi sokuqalisisa indawo, nokucabanga bona angayisebenzisa njani ekwenzeni bona i-VOC imthembe godu. Wayibona iyindawo enganikela ngokudla namanzi kabakhamba ngemikhumbi.&lt;ref name=&quot;:2&quot; /&gt;

Njengombana umkhumbi i-''Nieuwe Haerlem'' waphahlazeka ngo-1647, abasindileko bakha indawo lapho, u-Jan Van Riebeeck walemuka indlela ebebarhwebelana ngayo namaKhoikhoi njengombana balinde ukutakulwa. Ngemva kwalokho-ke watlola umbiko ngendawo le nangakho koke akubonileko, bewahlongoza bona indawo le ingaba yindawo ehle khulu i-VOC engayisebenzisa. Umbiko lo watlolwa ngo-1648 wathunyelwa ekhamphanini. Kwathi ngo-1651 i-VOC yathatha isiqunto sokuthi indawo ye-''Cape of Good Hope'' ayisetjenziselwe iminqopho yekhamphani.&lt;ref name=&quot;:2&quot; /&gt;

I-VOC yakhetha yena u-Jan Van Riebeeck bona kube nguye umdosiphambili ozokuhloma isitetjhi sokuphumula semikhumbi yamaDatjhi khona izokuthola ukudla okutjha okunepilo namanzi ahlanzekileko. Kwaba kusuka kwakhe-ke u-Jan Van Riebeeck, asuka e-Texel, e-Netherlands ngomhla wama-24 kuNobayeni 1651 bewayokufika e-''Table Bay'' ngomhla wesi-6 kaSihlabantangana 1652.&lt;ref name=&quot;:2&quot; /&gt; Bafika bakhamba ngemikhumbi emihlanu - i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch''.&lt;ref name=&quot;:1&quot;&gt;Marco Ramerini, English text by Dietrich Köster (January, 11 2014), ''The Dutch in South Africa, 1652-1795 and 1802-1806.'' Retrieved from https://www.colonialvoyage.com/dutch-south-africa/. Retrieved on 03/01/2026.&lt;/ref&gt;

== Ukufika Kwakhe EKapa ==
[[Isimumathi:Jan van Riebeeck .jpg|thumb|280x280px|Ukufika kuka-Jan Van Riebeeck eKapa]]
U-Jan Van Riebeeck wasuka ngomhla wama-24 kuNobayeni 1651 e-Texel, e-Netherlands, wafika ngomhla wesi-6 kaSihlabantangana 1652.&lt;ref name=&quot;:22&quot;&gt;South African History Online (17 October 2011), ''Jan van Riebeeck.'' Retrieved from: https://sahistory.org.za/people/jan-van-riebeeck. Retreived on 03/01/2026.&lt;/ref&gt; Bafika bakhamba ngemikhumbi emihlanu - i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch.&lt;ref name=&quot;:02&quot;&gt;South African History Online (13 January 2024) ''The Dutch Settlement.'' Retrieved from: https://sahistory.org.za/article/dutch-settlement Retrieved on 01/01/2026.&lt;/ref&gt;&lt;ref name=&quot;:12&quot;&gt;Marco Ramerini, English text by Dietrich Köster (January, 11 2014), ''The Dutch in South Africa, 1652-1795 and 1802-1806.'' Retrieved from https://www.colonialvoyage.com/dutch-south-africa/. Retrieved on 03/01/2026.&lt;/ref&gt;'' Emithathu le ngiyo eyafika qangi, ngikho kwaziwa khulu le emithathu, le eminye imikhumbi emibili yafika mva. Ekufikeni kwakhe nabantu ebekakhamba nabo ngemikhumbi le wafika wakha indawo yobuphephelo ebizwa bona yi-''Fort de Goede Hoop (Fort of Good Hope).'' Bafika batjala endaweni leyo, kodwana iintjalo zabo khenge zitlhurhe kuhle, mhlamunye ngebanga lobujamo bezulu obungafani nobe-Netherlands, netjharagano ebeliphakathi kwamadoda ebekakhamba nawo nakufuze basebenze batlhgomele imikhumbu edlulako. Abantu bebabancani umsebenzi umnengi.&lt;ref name=&quot;:22&quot; /&gt;

Kwathi ngo-1655 u-Van Riebeeck wabika bona ngaphandle kwabantu abazimisele ukusebenza emasimini, isitetjhesi sizokubhalelwa ukwenza umsebenzi esihloselwe wona. Kwathi ngo-1657, i-VOC yathumela abalimi ababhadelwako, ngombandela wokuthi balime inarha bebathengisele ikhamphani iintjalo abazilimileko. Ngibo laba ebebabizwa bona ma-''Free Burghers (Vry Burgers)''. U-Jan Van Riebeeck wathatha isikhathi sakhe soke atjala bekakhiqiza amagrepsi, ama-apula namazambana, ukudla okuzokuba lisizo khulu emikhumbini edlulako. Kwathi ngo-1659 besele anesivuno samagrepsi ebesikhiqiza iwayini elibovu elilwisana nobulwele be-''scurvy,'' njengombana besele alemukile bona ukusela iwayini kuyabuvikela ubulwelobu ngokwezinga elithileko.&lt;ref name=&quot;:22&quot; /&gt;

Endabeni yokurhwebelana, zoke izinto ebezenzeka u-Jan Van Riebeeck wazitlola emajenalini wakhe. AmaDatjhi bewathenga iinkomo nezimvu kuma-Khoekhoe ngepahla ehlukahlukeneko kuhlanganise notjwala negwayi. Bese inyama yefuyo le idliwe, enye ithengiselwe abantu abadlula ngemikhumbi yekhamphani.&lt;ref name=&quot;:5&quot;&gt;Steemit Website (2018) ''SOUTH AFRICAN HISTORY: Autshumato translator and first Postmaster of The Cape of Good Hope''. Retrieved from: https://steemit.com/history/@krabgat/south-african-history-autshumato-translator-and-first-postmaster-of-the-cape-of-good-hope. Retrieved on 14/01/2026.&lt;/ref&gt;

Kwathi ngenyanga kaSewula wango-1653 kwaba nokurhitjhana phakathi kuka-Autshumato, umdosiphambili wesitjhaba sama-Khoekhoe ama-''Gorinhaikona,'' nomelusi weenkomo zika-Van Riebeeck u-David Jansz. [[U-Autshumato]] wambulala wathatha iinkomo. Ukurhitjhanokhu kuthoma nje, iintjhaba ezimbili lezi besele zingasathelelani kuhle amanzi. AmaDatjhi besele aqala u-Autshumato nabantu bakhe njengamasela. U-Jan Van Riebeeck wathi u-Autshumato lisela elinelimi elibutjhelelezi. Ama-Khoekhoe aqala amaDatjhi njengabakhohlisi ngokuthi intengo yotjwala negwayi ayilingani nentengo yesilwana esifuywako. Bebathi bangabusela utjwala buphele, babone ifuywabo emadlelweni wamaDatjhi, yanda. Bese amaKhoekhoe akhambe ayoyeba.&lt;ref&gt;Castle of Good Hope (''13th November 2018'') ''Interpreters' Flawed Contracts With Dutch''Retrieved from: https://www.castleofgoodhope.co.za/index.php/news/100-news/142-interpreters-flawed-contracts-with-dutch. Retrieved on 14/01/2026.&lt;/ref&gt;

Isenzakalo sokubulawa kuka-David Jansz sasusa ipi phakathi kwama-Khoe namaDatjhi. U-Van RieBeeck wathi u-Autshumato unomlandu wokubulala. Yeke kwaliwa ipi, ekugcineni ama-Khoe ahlulwa. U-Autshumato wabanjwa wasiwa ekuthunjweni e-''Robben Island'' ngawo umnyaka ka-1653. Kodwana ngo-1655 watjhatjululwa wabuyiswa enarheni.  Nakafikako u-Jan Van Riebeeck wamamukela wambuyisela esikhundleni sakhe sokutologa.&lt;ref name=&quot;:5&quot; /&gt;  Ngesikhathesi [[u-Autshumato]] besele azwisisa indlela amaYurobhu arhweba ngayo nendlela yokuzuza kiyo. Bekathi nakarhwebela u-Jan Van Riebeeck iinkomo, aqiniseke bona imbadelo yekhamphani yanele bona ingabhadela neenkomo azithengela zona yena, ngikho nje aba mumuntu oregileko eKapa.&lt;ref name=&quot;:5&quot; /&gt;

Ngokukhamba kwesikhathi kwaba nokhunye godu ukurhitjhana phakathi kwama-Khoekhoe namaDatjhi ngo-1657. Ukurhitjhanokhu kubangwa kungazwani kwama-''Free Burghers (Vry Burgers)''  neengqila ze-Madagascar.  U-Jan Van Riebeeck wakateleleka bona akhe isivikelo endaweni leyo, bona enze ama-Khoekhoe asuke endaweni leyo. Bekuthi ezinye iingqila naziphunyurhako asebenzise u-Autshumato njengesithunjwa ukuhlohlozela ama-Khoe bona akhambe ayokubamba iingqilezo. Kodwana iqhinga lika-Van Riebeeck khenge liphumelele ngendlela afuna ngayo. Kwathi ngo-1658 u-Autshumato wabanjwa, wathathelwa yoke ifuywakhe. Ngemva kokutjhutjhiswa wathunjwa wasiwa e-''Robben Island'' godu. Kodwana wathi nakalapho waphunyurha ngesikepe esivuzako. Bekube kunamhlanjesi, u-Autshumato nguye kwaphela umuntu okghone ukuphunyurha e-''Robben Island'' njengesibotjhwa. Kunokuthi nakabuyako enarheni abotjhwe, u-Van Riebeeck wambuyisela esikhundleni sakhe sokukhulumisana nokutologa.&lt;ref name=&quot;:5&quot; /&gt;&lt;ref name=&quot;:4&quot;&gt;Camissa Museum (2026) ''Autshumao (1610 - 1674)'', Retrieved from: https://camissamuseum.co.za/index.php/7-tributaries/1-cape-indigenous-africans/autshumao. Retrieved on 12/01/2026.&lt;/ref&gt;

== Ukufa Kwakhe ==
Ngomhla wobu-8 kuKhukhulamungu wango-1662 u-Jan Van Riebeeck wakhamba eKapa esesewula Afrika, watjhiya u-Zacharias Wagenaer bona kube nguye osala aphethe endaweni abakiyo eKapa. Wafika wahlala endaweni ebizwa bona yiMalacca namhlanjesi ebizwa bona yi-Melaka eseMalaysia, wahlala lapho bekwaba nguKhukhulamungu wango-1665. Umkakhe wahlongakala ngokubulawa bulwele bepokisi ngenyanga kaSinyikhaba ngo-1664. Ngemva kwalokho wabekwa esikhundleni sokuba ngu-''Governor-General-in-Council'' wenarha yeNdiya, begodu wahlala e-Batavia ipilwakhe yoke. Wahlongakala ngomhla we-18 kuTjhirhweni 1677.&lt;ref&gt;S2A3 Biographical Database of Southern African Science (2026)'''''Van Riebeeck,''' Commander '''Johan Antoniszoon''' (advancement of science).'' Retrieved from: https://www.s2a3.org.za/bio/Biograph_final.php?serial=2953. Retrieved on 16/01/2026.&lt;/ref&gt; 

== Iinkhombo ==</text>
      <sha1>tvj56ouaqeykh2od8e56j3c4ze7euf3</sha1>
    </revision>
    <revision>
      <id>6745</id>
      <parentid>6140</parentid>
      <timestamp>2026-07-18T04:34:34Z</timestamp>
      <contributor>
        <username>Ziv</username>
        <id>1632</id>
      </contributor>
      <minor />
      <comment>([[c:GR|GR]]) [[c:COM:FR|File renamed]]: [[File:Jan van Riebeeck .jpg]] → [[File:Charles Davidson Bell - Landing of Van Riebeeck at the Cape of Good Hope in 1652.jpg]] [[c:COM:FR#FR2|Criterion 2]] · Artist's name and exact description &amp; bug fix</comment>
      <origin>6745</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9929" sha1="qrx8gnftgsv5c35wd7359cox03d4rjq" xml:space="preserve">[[Isimumathi:Jan van Riebeeck cropped.jpg|thumb|U-Jan Van Riebeeck]]
'''UJan Van Riebeeck (U-''Johan Anthoniszoon &quot;Jan&quot; Van Riebeeck'')''' wabelethwa ngomhla wama-21 kuSihlabantangana 1619 e-Culemborg, e-Netherlands abelethwa nguyise ungodorhodere ohlinzako. Wakhulela e-Schiedam, e-Netherlands, kwathi ngomhla wama-28 kuNtaka 1649, watjhada u-''Maria de la Queillerie'', waba nabantwana ababunane naye.&lt;ref name=&quot;:2&quot;&gt;South African History Online (17 October 2011), ''Jan van Riebeeck.'' Retrieved from: https://sahistory.org.za/people/jan-van-riebeeck. Retreived on 03/01/2026.&lt;/ref&gt;

U-Jan Van Riebeeck waba lilunga le-''Dutch East India Company'' (''Vereenigde Oost-Indische Compagnie'' - VOC) ngo-1639 lapha athoma khona ukuba msizi kadorhodere ohlinzako ekhambeni labo lokuya e-Batavia (namhlanjesi eyaziwa nge-Jakarta) ngenyanga kaSihlabantangana ngo-1639 bese batjhinga e-Nagasaki eJapani ngo-1643.&lt;ref name=&quot;:2&quot; /&gt;
[[Isimumathi:Maria Quevellerius (1629-64), eerste vrouw van Jan van Riebeeck, of diens tweede vrouw Maria Scipio (ca. 1630-95) Rijksmuseum SK-A-806.jpeg|thumb|Umka-Jan Van Riebeeck, u-Maria Quevellerius]]
Ngo-1645 u-Jan Van Riebeeck wanikelwa isabelo sokuba mphathi wesitetjhi sokurhwebela se-VOC ebesise-Tongkin e-''French Indochina'' (namhlanjesi eyaziwa nge-Vietnam). Wehliswa esikhundleneso ngebanga lokuthi besele azenzela irhwebo lakhe langeqadi, okuphula umthetho wekhamphani othi abaphathi akukafuzi bazenzele irhwebo ngeqadi ngepahla yekhamphani. Kwathi bona ehliswe esikhundleni, wazithola sele kufuze abuyele emva e-Netherlands ayoqalana nemilandu yakhe. Ngikho-ke besele atholakala komunye wemikhumbi eli-12 ebeyidoswa phambili ngu-W.G de Jong. Wafika e-''Table Bay'' hlanu kwe-''Cape of Good Hope'' wahlala khona amalanga ali-18. Lokho kwamnikela isikhathi sokuqalisisa indawo, nokucabanga bona angayisebenzisa njani ekwenzeni bona i-VOC imthembe godu. Wayibona iyindawo enganikela ngokudla namanzi kabakhamba ngemikhumbi.&lt;ref name=&quot;:2&quot; /&gt;

Njengombana umkhumbi i-''Nieuwe Haerlem'' waphahlazeka ngo-1647, abasindileko bakha indawo lapho, u-Jan Van Riebeeck walemuka indlela ebebarhwebelana ngayo namaKhoikhoi njengombana balinde ukutakulwa. Ngemva kwalokho-ke watlola umbiko ngendawo le nangakho koke akubonileko, bewahlongoza bona indawo le ingaba yindawo ehle khulu i-VOC engayisebenzisa. Umbiko lo watlolwa ngo-1648 wathunyelwa ekhamphanini. Kwathi ngo-1651 i-VOC yathatha isiqunto sokuthi indawo ye-''Cape of Good Hope'' ayisetjenziselwe iminqopho yekhamphani.&lt;ref name=&quot;:2&quot; /&gt;

I-VOC yakhetha yena u-Jan Van Riebeeck bona kube nguye umdosiphambili ozokuhloma isitetjhi sokuphumula semikhumbi yamaDatjhi khona izokuthola ukudla okutjha okunepilo namanzi ahlanzekileko. Kwaba kusuka kwakhe-ke u-Jan Van Riebeeck, asuka e-Texel, e-Netherlands ngomhla wama-24 kuNobayeni 1651 bewayokufika e-''Table Bay'' ngomhla wesi-6 kaSihlabantangana 1652.&lt;ref name=&quot;:2&quot; /&gt; Bafika bakhamba ngemikhumbi emihlanu - i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch''.&lt;ref name=&quot;:1&quot;&gt;Marco Ramerini, English text by Dietrich Köster (January, 11 2014), ''The Dutch in South Africa, 1652-1795 and 1802-1806.'' Retrieved from https://www.colonialvoyage.com/dutch-south-africa/. Retrieved on 03/01/2026.&lt;/ref&gt;

== Ukufika Kwakhe EKapa ==
[[Isimumathi:Charles Davidson Bell - Landing of Van Riebeeck at the Cape of Good Hope in 1652.jpg|thumb|280x280px|Ukufika kuka-Jan Van Riebeeck eKapa]]
U-Jan Van Riebeeck wasuka ngomhla wama-24 kuNobayeni 1651 e-Texel, e-Netherlands, wafika ngomhla wesi-6 kaSihlabantangana 1652.&lt;ref name=&quot;:22&quot;&gt;South African History Online (17 October 2011), ''Jan van Riebeeck.'' Retrieved from: https://sahistory.org.za/people/jan-van-riebeeck. Retreived on 03/01/2026.&lt;/ref&gt; Bafika bakhamba ngemikhumbi emihlanu - i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch.&lt;ref name=&quot;:02&quot;&gt;South African History Online (13 January 2024) ''The Dutch Settlement.'' Retrieved from: https://sahistory.org.za/article/dutch-settlement Retrieved on 01/01/2026.&lt;/ref&gt;&lt;ref name=&quot;:12&quot;&gt;Marco Ramerini, English text by Dietrich Köster (January, 11 2014), ''The Dutch in South Africa, 1652-1795 and 1802-1806.'' Retrieved from https://www.colonialvoyage.com/dutch-south-africa/. Retrieved on 03/01/2026.&lt;/ref&gt;'' Emithathu le ngiyo eyafika qangi, ngikho kwaziwa khulu le emithathu, le eminye imikhumbi emibili yafika mva. Ekufikeni kwakhe nabantu ebekakhamba nabo ngemikhumbi le wafika wakha indawo yobuphephelo ebizwa bona yi-''Fort de Goede Hoop (Fort of Good Hope).'' Bafika batjala endaweni leyo, kodwana iintjalo zabo khenge zitlhurhe kuhle, mhlamunye ngebanga lobujamo bezulu obungafani nobe-Netherlands, netjharagano ebeliphakathi kwamadoda ebekakhamba nawo nakufuze basebenze batlhgomele imikhumbu edlulako. Abantu bebabancani umsebenzi umnengi.&lt;ref name=&quot;:22&quot; /&gt;

Kwathi ngo-1655 u-Van Riebeeck wabika bona ngaphandle kwabantu abazimisele ukusebenza emasimini, isitetjhesi sizokubhalelwa ukwenza umsebenzi esihloselwe wona. Kwathi ngo-1657, i-VOC yathumela abalimi ababhadelwako, ngombandela wokuthi balime inarha bebathengisele ikhamphani iintjalo abazilimileko. Ngibo laba ebebabizwa bona ma-''Free Burghers (Vry Burgers)''. U-Jan Van Riebeeck wathatha isikhathi sakhe soke atjala bekakhiqiza amagrepsi, ama-apula namazambana, ukudla okuzokuba lisizo khulu emikhumbini edlulako. Kwathi ngo-1659 besele anesivuno samagrepsi ebesikhiqiza iwayini elibovu elilwisana nobulwele be-''scurvy,'' njengombana besele alemukile bona ukusela iwayini kuyabuvikela ubulwelobu ngokwezinga elithileko.&lt;ref name=&quot;:22&quot; /&gt;

Endabeni yokurhwebelana, zoke izinto ebezenzeka u-Jan Van Riebeeck wazitlola emajenalini wakhe. AmaDatjhi bewathenga iinkomo nezimvu kuma-Khoekhoe ngepahla ehlukahlukeneko kuhlanganise notjwala negwayi. Bese inyama yefuyo le idliwe, enye ithengiselwe abantu abadlula ngemikhumbi yekhamphani.&lt;ref name=&quot;:5&quot;&gt;Steemit Website (2018) ''SOUTH AFRICAN HISTORY: Autshumato translator and first Postmaster of The Cape of Good Hope''. Retrieved from: https://steemit.com/history/@krabgat/south-african-history-autshumato-translator-and-first-postmaster-of-the-cape-of-good-hope. Retrieved on 14/01/2026.&lt;/ref&gt;

Kwathi ngenyanga kaSewula wango-1653 kwaba nokurhitjhana phakathi kuka-Autshumato, umdosiphambili wesitjhaba sama-Khoekhoe ama-''Gorinhaikona,'' nomelusi weenkomo zika-Van Riebeeck u-David Jansz. [[U-Autshumato]] wambulala wathatha iinkomo. Ukurhitjhanokhu kuthoma nje, iintjhaba ezimbili lezi besele zingasathelelani kuhle amanzi. AmaDatjhi besele aqala u-Autshumato nabantu bakhe njengamasela. U-Jan Van Riebeeck wathi u-Autshumato lisela elinelimi elibutjhelelezi. Ama-Khoekhoe aqala amaDatjhi njengabakhohlisi ngokuthi intengo yotjwala negwayi ayilingani nentengo yesilwana esifuywako. Bebathi bangabusela utjwala buphele, babone ifuywabo emadlelweni wamaDatjhi, yanda. Bese amaKhoekhoe akhambe ayoyeba.&lt;ref&gt;Castle of Good Hope (''13th November 2018'') ''Interpreters' Flawed Contracts With Dutch''Retrieved from: https://www.castleofgoodhope.co.za/index.php/news/100-news/142-interpreters-flawed-contracts-with-dutch. Retrieved on 14/01/2026.&lt;/ref&gt;

Isenzakalo sokubulawa kuka-David Jansz sasusa ipi phakathi kwama-Khoe namaDatjhi. U-Van RieBeeck wathi u-Autshumato unomlandu wokubulala. Yeke kwaliwa ipi, ekugcineni ama-Khoe ahlulwa. U-Autshumato wabanjwa wasiwa ekuthunjweni e-''Robben Island'' ngawo umnyaka ka-1653. Kodwana ngo-1655 watjhatjululwa wabuyiswa enarheni.  Nakafikako u-Jan Van Riebeeck wamamukela wambuyisela esikhundleni sakhe sokutologa.&lt;ref name=&quot;:5&quot; /&gt;  Ngesikhathesi [[u-Autshumato]] besele azwisisa indlela amaYurobhu arhweba ngayo nendlela yokuzuza kiyo. Bekathi nakarhwebela u-Jan Van Riebeeck iinkomo, aqiniseke bona imbadelo yekhamphani yanele bona ingabhadela neenkomo azithengela zona yena, ngikho nje aba mumuntu oregileko eKapa.&lt;ref name=&quot;:5&quot; /&gt;

Ngokukhamba kwesikhathi kwaba nokhunye godu ukurhitjhana phakathi kwama-Khoekhoe namaDatjhi ngo-1657. Ukurhitjhanokhu kubangwa kungazwani kwama-''Free Burghers (Vry Burgers)''  neengqila ze-Madagascar.  U-Jan Van Riebeeck wakateleleka bona akhe isivikelo endaweni leyo, bona enze ama-Khoekhoe asuke endaweni leyo. Bekuthi ezinye iingqila naziphunyurhako asebenzise u-Autshumato njengesithunjwa ukuhlohlozela ama-Khoe bona akhambe ayokubamba iingqilezo. Kodwana iqhinga lika-Van Riebeeck khenge liphumelele ngendlela afuna ngayo. Kwathi ngo-1658 u-Autshumato wabanjwa, wathathelwa yoke ifuywakhe. Ngemva kokutjhutjhiswa wathunjwa wasiwa e-''Robben Island'' godu. Kodwana wathi nakalapho waphunyurha ngesikepe esivuzako. Bekube kunamhlanjesi, u-Autshumato nguye kwaphela umuntu okghone ukuphunyurha e-''Robben Island'' njengesibotjhwa. Kunokuthi nakabuyako enarheni abotjhwe, u-Van Riebeeck wambuyisela esikhundleni sakhe sokukhulumisana nokutologa.&lt;ref name=&quot;:5&quot; /&gt;&lt;ref name=&quot;:4&quot;&gt;Camissa Museum (2026) ''Autshumao (1610 - 1674)'', Retrieved from: https://camissamuseum.co.za/index.php/7-tributaries/1-cape-indigenous-africans/autshumao. Retrieved on 12/01/2026.&lt;/ref&gt;

== Ukufa Kwakhe ==
Ngomhla wobu-8 kuKhukhulamungu wango-1662 u-Jan Van Riebeeck wakhamba eKapa esesewula Afrika, watjhiya u-Zacharias Wagenaer bona kube nguye osala aphethe endaweni abakiyo eKapa. Wafika wahlala endaweni ebizwa bona yiMalacca namhlanjesi ebizwa bona yi-Melaka eseMalaysia, wahlala lapho bekwaba nguKhukhulamungu wango-1665. Umkakhe wahlongakala ngokubulawa bulwele bepokisi ngenyanga kaSinyikhaba ngo-1664. Ngemva kwalokho wabekwa esikhundleni sokuba ngu-''Governor-General-in-Council'' wenarha yeNdiya, begodu wahlala e-Batavia ipilwakhe yoke. Wahlongakala ngomhla we-18 kuTjhirhweni 1677.&lt;ref&gt;S2A3 Biographical Database of Southern African Science (2026)'''''Van Riebeeck,''' Commander '''Johan Antoniszoon''' (advancement of science).'' Retrieved from: https://www.s2a3.org.za/bio/Biograph_final.php?serial=2953. Retrieved on 16/01/2026.&lt;/ref&gt; 

== Iinkhombo ==</text>
      <sha1>qrx8gnftgsv5c35wd7359cox03d4rjq</sha1>
    </revision>
  </page>
  <page>
    <title>Ukufika KwamaBhuru ESewula Afrika</title>
    <ns>0</ns>
    <id>1024</id>
    <revision>
      <id>6136</id>
      <timestamp>2026-01-16T11:56:02Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>New article</comment>
      <origin>6136</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="11423" sha1="sc89h5t9agh6aqvgcvr801rfsrtyd4a" xml:space="preserve">[[Isimumathi:Flag of the Dutch East India Company.svg|thumb|260x260px|Iflarha le-VOC (Dutch East India Company)]]
'''AmaDatjhi''' '''(ngokhamba kwesikhathi abizwa ngamaBhuru)''' afika esewula ne-Afrika, eKapa, ngomhla we-6 kuSihlabantangana 1652. Bafika bakhamba ngemikhumbi emihlanu badoswa phambili ngu-Jan Van Riebeeck. Isizathu esenza amaDatjhi azithole aseKapa yindaba yezerhwebo. Abantwaba  bebangaphasi kwekhamphani ebizwa bona yi-''Dutch East India Company'' (V''ereenigde Oost-Indische Compagnie'' ''-'' VOC).&lt;ref name=&quot;:0&quot;&gt;South African History Online (13 January 2024) ''The Dutch Settlement.'' Retrieved from: https://sahistory.org.za/article/dutch-settlement Retrieved on 01/01/2026.&lt;/ref&gt; 

Ikhamphani le beyithatha ipahla, ikhambe amalwandle ngemikhumbi, iyoyithengisa eNdiya. Yeke ngebanga lokubalekela iingebengu zelwandle beyizomba inarhakazi yoke ye-Afrika. Kodwana ibangeli belilide khulu, begodu imikhumbi beyiphelelwa kukudla isendleleni. Yeke bekufuze kube nendawo lapha bangajama khona baphumule bathole nokudla okuzobafikisa eNdiya, iinthelo, imirorho, inyama namanzi ahlanzekileko ebekutholakala budisi kezinye iindawo. IKapa yaba ngileyondawo, ngikho nje beyibizwa bona yi-''Cape of Good Hope''.&lt;ref name=&quot;:2&quot; /&gt;

U-Jan Van Riebeeck wabona indawo le asendleleni ebuyela emva e-Holland, avela eJapani, njengombana bekathengisela i-VOC iinkhumba. Wathi nakehla emkhunjini eKapa, wabona indawo le ingaba yihle khulu bona imikhumbi ye-VOC ingaphumulela khona bese iraga nekhambo layo itjhinge eNdiya.&lt;ref name=&quot;:2&quot; /&gt;

== U-Jan Van Riebeeck - 1647 ==
[[Isimumathi:Jan van Riebeeck cropped.jpg|thumb|U-Jan Van Riebeeck]]
Kuhlekuhle bekungasikokuthoma amaDatjhi afika ngo-1652. Bakhe bafika okokuthoma ngenyanga kaNtaka ngo-1647 bakhamba ngomkhumbi obizwa bona yi-''Nieuwe Haarlem''. Umkhumbi lo wafika waphahlazeka eKapa. Abasinda emkhunjini lowo bafika bakha indawo abayibiza bona yi-''Sand Fort of the Cape of Good Hope.'' Bahlala lapho pheze umnyaka woke. Ekugcineni kwafika imikhumbi eli-12 ebeyidoswa phambili ngu-W.G de Jong. Komunye wemikhumbi le bekunendoda ebizwa bona ngu-Jan Van Riebeeck.&lt;ref name=&quot;:1&quot;&gt;Marco Ramerini, English text by Dietrich Köster (January, 11 2014), ''The Dutch in South Africa, 1652-1795 and 1802-1806.'' Retrieved from https://www.colonialvoyage.com/dutch-south-africa/. Retrieved on 03/01/2026.&lt;/ref&gt;&lt;ref name=&quot;:2&quot;&gt;South African History Online (17 October 2011), ''Jan van Riebeeck.'' Retrieved from: https://sahistory.org.za/people/jan-van-riebeeck. Retreived on 03/01/2026.&lt;/ref&gt;

UJan Van Riebeeck (U-''Johan Anthoniszoon &quot;Jan&quot; Van Riebeeck'') wabelethwa ngomhla ka-21 kuSihlabantangana 1619 e-Culemborg, e-Netherlands abelethwa nguyise ungodorhodere ohlinzako. Wakhulela e-Schiedam, e-Netherlands, kwathi ngomhla wama-28 kuNtaka 1649, watjhada u-''Maria de la Queillerie'', waba nabantwana ababunane naye.&lt;ref name=&quot;:2&quot; /&gt;

U-Jan Van Riebeeck waba lilunga le-''Dutch East India Company'' (''Vereenigde Oost-Indische Compagnie'' -  VOC) ngo-1639 lapha athoma khona ukuba msizi kadorhodere ohlinzako ekhambeni labo lokuya e-Batavia (namhlanjesi eyaziwa nge-Jakarta) ngenyanga kaSihlabantangana 1639 bese batjhinga e-Nagasaki eJapani ngo-1643.&lt;ref name=&quot;:2&quot; /&gt;

Ngo-1645 u-Jan Van Riebeeck wanikelwa isabelo sokuba mphathi wesitetjhi sokurhwebela se-VOC ebesise-Tongkin e-''French Indochina'' (namhlanjesi eyaziwa nge-Vietnam). Wehliswa esikhundleneso ngebanga lokuthi besele azenzela irhwebo lakhe langeqadi, okuphula umthetho wekhamphani othi abaphathi akukafuzi bazenzele irhwebo ngeqadi ngepahla yekhamphani. Kwathi bona ehliswe esikhundleni, wazithola sele kufuze abuyele emva e-Netherlands ayoqalana nemilandu yakhe. Ngikho-ke besele atholakala komunye wemikhumbi eli-12 ebeyidoswa phambili ngu-W.G de Jong. Wafika e-''Table Bay'' hlanu kwe-''Cape of Good Hope'' wahlala khona amalanga ali-18. Lokho kwamnikela isikhathi sokuqalisisa indawo, nokucabanga bona angayisebenzisa njani ekwenzeni bona i-VOC imthembe godu. Wayibona iyindawo enganikela ngokudla namanzi kabakhamba ngemikhumbi.&lt;ref name=&quot;:2&quot; /&gt;

Njengombana umkhumbi i-''Nieuwe Haerlem'' waphahlazeka ngo-1647, abasindileko bakha indawo lapho, u-Jan Van Riebeeck walemuka indlela ebebarhwebelana ngayo namaKhoikhoi njengombana balinde ukutakulwa. Ngemva kwalokho-ke watlola umbiko ngendawo le nangakho koke akubonileko, bewahlongoza bona indawo le ingaba yindawo ehle khulu i-VOC engayisebenzisa. Umbiko lo watlolwa ngo-1648 wathunyelwa ekhamphanini. Kwathi ngo-1651 i-VOC yathatha isiqunto sokuthi indawo ye-''Cape of Good Hope'' ayisetjenziselwe iminqopho yekhamphani.&lt;ref name=&quot;:2&quot; /&gt;

I-VOC yakhetha yena u-Jan Van Riebeeck bona kube nguye umdosiphambili ozokuhloma isitetjhi sokuphumula semikhumbi yamaDatjhi khona izokuthola ukudla okutjha okunepilo namanzi ahlanzekileko. Kwaba kusuka kwakhe-ke u-Jan Van Riebeeck, asuka e-Texel, e-Netherlands ngomhla wama-24 kuNobayeni 1651 bewayokufika e-''Table Bay'' ngomhla wesi-6 kaSihlabantangana 1652.&lt;ref name=&quot;:2&quot; /&gt; Bafika bakhamba ngemikhumbi emihlanu - i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch''.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;

== Ukufika KwamaDatjhi  - 1652 ==
[[Isimumathi:VOC ship Phenix.jpg|thumb|Imikhumbi yamaDatjhi ifika eKapa]]
U-Jan Van Riebeeck wasuka ngomhla wama-24 kuNobayeni 1651 e-Texel, e-Netherlands, wafika ngomhla wesi-6 kaSihlabantangana 1652.&lt;ref name=&quot;:2&quot; /&gt; Bafika bakhamba ngemikhumbi emihlanu - i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;'' Emithathu le ngiyo eyafika qangi, ngikho kwaziwa khulu le emithathu, le eminye imikhumbi emibili yafika mva. Ekufikeni kwakhe nabantu ebekakhamba nabo ngemikhumbi le wafika wakha indawo yobuphephelo ebizwa bona yi-''Fort de Goede Hoop (Fort of Good Hope).'' Bafika batjala endaweni leyo, kodwana iintjalo zabo khenge zitlhurhe kuhle, mhlamunye ngebanga lobujamo bezulu obungafani nobe-Netherlands, netjharagano ebeliphakathi kwamadoda ebekakhamba nawo nakufuze basebenze batlhgomele imikhumbu edlulako. Abantu bebabancani umsebenzi umnengi.&lt;ref name=&quot;:2&quot; /&gt;

Kwathi ngo-1655 u-Van Riebeeck wabika bona ngaphandle kwabantu abazimisele ukusebenza emasimini, isitetjhesi sizokubhalelwa ukwenza umsebenzi esihloselwe wona. Kwathi ngo-1657, i-VOC yathumela abalimi ababhadelwako, ngombandela wokuthi balime inarha bebathengisele ikhamphani iintjalo abazilimileko. Ngibo laba ebebabizwa bona ma-''Free Burghers (Vry Burgers)''. U-Jan Van Riebeeck wathatha isikhathi sakhe soke atjala bekakhiqiza amagrepsi, ama-apula namazambana, ukudla okuzokuba lisizo khulu emikhumbini edlulako. Kwathi ngo-1659 besele anesivuno samagrepsi ebesikhiqiza iwayini elibovu elilwisana nobulwele be-''scurvy,'' njengombana besele alemukile bona ukusela iwayini kuyabuvikela ubulwelobu ngokwezinga elithileko.&lt;ref name=&quot;:2&quot; /&gt;

== Ama-Khoikhoi ==
Ukuthoma kokufika kwamaDatjhi eKapa (''Cape of Good Hope'') khenge kubamangaze abantu bendabuko bendawo leyo ama-Khoikhoi. AmaDatjhi afika nje ama-Khoikhoi besele kukade arhwebelana namaPutukezi, amaFrentji namaNgisi. Nangaphezu kokufika kuka-Van Riebeeck, ngokuya kuka-Knox‑Johnson, phakathi nomnyaka wabo-1600 kuya ku-1700, besele kudlule imikhumbi yamaDatjhi eziyi-1 730. Yeke amaKhoikhoi bekangawaqabuki amaDatjhi ngesikhatheso.&lt;ref&gt;Helen Swingler (22 September 2021) ''Heritage Month: The Khoi encountered Europeans long before Van Riebeeck,'' University of Cape Town News. Retrieved from: https://www.news.uct.ac.za/article/-2021-09-22-the-khoi-encountered-europeans-long-before-van-riebeeck. Retrieved on 12/01/2026.&lt;/ref&gt;
[[Isimumathi:Khoikhoi Hottentot p197.jpg|thumb|Ama-Khoikhoi]]
Esikhathini sokufika kwamaDatjhi bekunendoda ebizwa bona ngu-Autshumato, namkha u-Autshumao, amaDatjhi ebebambiza bona ngu-''Harry die Strandloper''. U-Autshumao bekayikosi yesitjhaba samaKhoikhoi ebesibizwa bona ma-''Gorinhaikona''. Isitetjhana sokurhwebelana nabantu bemikhumbi sathonywa nguye.&lt;ref name=&quot;:3&quot;&gt;Roben Island Museum (13 May 2017) ''Autshumato''. Retrieved from: http://www.robben-island.org.za/departments/heritage/gallery/autshumato.asp. Retrieved on 14/01/2026.&lt;/ref&gt; Ngo-1630 wathathwa maNgisi esitjhabeni sekhabo bona ambandulele ukukhulumisana nabanye ngendaba yezokurhwebelana begodu atolige. Yeke amaNgisi amthatha amusa e-Bantam eNgilandi, wafika wafundiswa isiNgisi, isiDatjhi nesiFrentji nesiPutukezi. Wathi nakabuya eKapa bamthatha bamusa e-''Robben Island'' yena nabalandeli bakhe. Bekuthi imikhumbi nayifikako ambathe iimpahla zamaYurobhu akhulumisane nabokapteni bemikhumbi, akhulume isiNgisi nesiFrentji. Bambiza bona yi-''Governor.''&lt;ref name=&quot;:4&quot;&gt;Camissa Museum (2026) ''Autshumao (1610 - 1674)'', Retrieved from: https://camissamuseum.co.za/index.php/7-tributaries/1-cape-indigenous-africans/autshumao. Retrieved on 12/01/2026.&lt;/ref&gt;

Kwathi ngo-1638, u-Autshumao nomphakathi wekhabo ebewunabantu abangaba ma-60, babuya esihlengehlengeni beza enarheni eKapa, lapha kuhlangana khona umlambo i-''Camissa River'' nelwandle. Yena nomndenakhe ngibo ebebaphethe isitetjhi sokurhwebelana i-''‖Ammaqua'' (okutjho Abantu bemanzini) okulibizo u-Jan Van Riebeeck ebekababiza ngalo ekuthomeni.&lt;ref name=&quot;:3&quot; /&gt;&lt;ref name=&quot;:4&quot; /&gt;

Ngesikhathi amaDatjhi afika, umuntu wokuthoma ukubamukela bekungu-Autshumao nabantu bakhe. ngikho nje amaDatjhi bebababiza ngokuthi ma-''Strandloper'' ngombana babathola bakhamba eligwini lelwandle. Kusukela bathoma ukubonana bathoma ukurhwebelana. Zoke izinto ebezenzeka u-Jan Van Riebeeck wazitlola emajenalini wakhe. AmaDatjhi bewathenga iinkomo nezimvu kuma-Khoikhoi ngepahla ehlukahlukeneko kuhlanganise notjwala negwayi. Bese inyama yefuyo le idliwe, enye ethengiselwe abantu abadlula ngemikhumbi yekhamphani.&lt;ref name=&quot;:5&quot;&gt;Steemit Website (2018) ''SOUTH AFRICAN HISTORY: Autshumato translator and first Postmaster of The Cape of Good Hope''. Retrieved from: https://steemit.com/history/@krabgat/south-african-history-autshumato-translator-and-first-postmaster-of-the-cape-of-good-hope. Retrieved on 14/01/2026.&lt;/ref&gt; 

Kwathi ngenyanga kaSewula wango-1653 kwaba nokurhitjhana phakathi kuka-Autshumato nomelusi weenkomo zika-Van Riebeeck u-David Jansz. U-Autshumato wambulala wathatha iinkomo. Ukurhitjhanokhu kuthoma nje iintjhaba ezimbili lezi besele zingasathelelani kuhle amanzi. AmaDatjhi besele aqala u-Autshumato nabantu bakhe njengamasela. U-Jan Van Riebeeck wathi u-Autshumato lisela elinelimi elibutjhelelezi. AmaKhoikhoi aqala amaDatjhi njengabakhohlisi ngokuthi intengo yotjwala negwayi ayilingani nentengo yesilwana esifuywako. Bebathi bangabusela utjwala buphele, babone ifuywabo emadlelweni wamaDatjhi, yanda. Bese amaKhoikhoi akhambe ayoyeba.&lt;ref&gt;Castle of Good Hope (''13th November 2018'') ''Interpreters' Flawed Contracts With Dutch''Retrieved from: https://www.castleofgoodhope.co.za/index.php/news/100-news/142-interpreters-flawed-contracts-with-dutch. Retrieved on 14/01/2026.&lt;/ref&gt; 

Isenzakalo sokubulawa kuka-David Jansz sasusa ipi phakathi kwama-Khoi namaDatjhi. U-Van RieBeeck wathi u-Autshumato unomlandu wokubulala. Yeke kwaliwa ipi, ekugcineni ama-Khoi ahlulwa. U-Atshumato wabanjwa wasiwa ekuthunjweni e-''Robben Island'' ngawo umnyaka ka-1653. Kodwana ngo-1655 waphunyurha yena nalabo ebekathunjwe nabo babuyela enarheni ngesikepe esinembobo.  Nakafikako u-Jan Van Riebeeck wamamukela wambuyisela esikhundleni sakhe sokutoliga.&lt;ref name=&quot;:5&quot; /&gt;

== Iinkhombo ==</text>
      <sha1>sc89h5t9agh6aqvgcvr801rfsrtyd4a</sha1>
    </revision>
    <revision>
      <id>6137</id>
      <parentid>6136</parentid>
      <timestamp>2026-01-16T12:03:19Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>edited</comment>
      <origin>6137</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="11438" sha1="sg2g5ddkx77d3f9cbr9yepk9tubhqqq" xml:space="preserve">[[Isimumathi:Flag of the Dutch East India Company.svg|thumb|260x260px|Iflarha le-VOC (Dutch East India Company)]]
'''AmaDatjhi''' '''(ngokhamba kwesikhathi abizwa ngamaBhuru)''' afika esewula ne-Afrika, eKapa, ngomhla we-6 kuSihlabantangana  ngo-1652. Bafika bakhamba ngemikhumbi emihlanu badoswa phambili ngu-Jan Van Riebeeck. Isizathu esenza amaDatjhi azithole aseKapa yindaba yezerhwebo. Abantwaba  bebangaphasi kwekhamphani ebizwa bona yi-''Dutch East India Company'' (V''ereenigde Oost-Indische Compagnie'' ''-'' VOC).&lt;ref name=&quot;:0&quot;&gt;South African History Online (13 January 2024) ''The Dutch Settlement.'' Retrieved from: https://sahistory.org.za/article/dutch-settlement Retrieved on 01/01/2026.&lt;/ref&gt; 

Ikhamphani le beyithatha ipahla, ikhambe amalwandle ngemikhumbi, iyoyithengisa eNdiya. Yeke ngebanga lokubalekela iingebengu zelwandle beyizomba inarhakazi yoke ye-Afrika. Kodwana ibangeli belilide khulu, begodu imikhumbi beyiphelelwa kukudla isendleleni. Yeke bekufuze kube nendawo lapha bangajama khona baphumule bathole nokudla okuzobafikisa eNdiya, iinthelo, imirorho, inyama namanzi ahlanzekileko ebekutholakala budisi kezinye iindawo. IKapa yaba ngileyondawo, ngikho nje beyibizwa bona yi-''Cape of Good Hope''.&lt;ref name=&quot;:2&quot; /&gt;

U-Jan Van Riebeeck wabona indawo le asendleleni ebuyela emva e-Holland, avela eJapani, njengombana bekathengisela i-VOC iinkhumba. Wathi nakehla emkhunjini eKapa, wabona indawo le ingaba yihle khulu bona imikhumbi ye-VOC ingaphumulela khona bese iraga nekhambo layo itjhinge eNdiya.&lt;ref name=&quot;:2&quot; /&gt;

== U-Jan Van Riebeeck - 1647 ==
[[Isimumathi:Jan van Riebeeck cropped.jpg|thumb|U-Jan Van Riebeeck]]
Kuhlekuhle bekungasikokuthoma amaDatjhi afika ngo-1652. Bakhe bafika okokuthoma ngenyanga kaNtaka ngo-1647 bakhamba ngomkhumbi obizwa bona yi-''Nieuwe Haarlem''. Umkhumbi lo wafika waphahlazeka eKapa. Abasinda emkhunjini lowo bafika bakha indawo abayibiza bona yi-''Sand Fort of the Cape of Good Hope.'' Bahlala lapho pheze umnyaka woke. Ekugcineni kwafika imikhumbi eli-12 ebeyidoswa phambili ngu-W.G de Jong. Komunye wemikhumbi le bekunendoda ebizwa bona ngu-Jan Van Riebeeck.&lt;ref name=&quot;:1&quot;&gt;Marco Ramerini, English text by Dietrich Köster (January, 11 2014), ''The Dutch in South Africa, 1652-1795 and 1802-1806.'' Retrieved from https://www.colonialvoyage.com/dutch-south-africa/. Retrieved on 03/01/2026.&lt;/ref&gt;&lt;ref name=&quot;:2&quot;&gt;South African History Online (17 October 2011), ''Jan van Riebeeck.'' Retrieved from: https://sahistory.org.za/people/jan-van-riebeeck. Retreived on 03/01/2026.&lt;/ref&gt;

[[U-Jan Van Riebeeck]] (U-''Johan Anthoniszoon &quot;Jan&quot; Van Riebeeck'') wabelethwa ngomhla ka-21 kuSihlabantangana 1619 e-Culemborg, e-Netherlands abelethwa nguyise ungodorhodere ohlinzako. Wakhulela e-Schiedam, e-Netherlands, kwathi ngomhla wama-28 kuNtaka 1649, watjhada u-''Maria de la Queillerie'', waba nabantwana ababunane naye.&lt;ref name=&quot;:2&quot; /&gt;

U-Jan Van Riebeeck waba lilunga le-''Dutch East India Company'' (''Vereenigde Oost-Indische Compagnie'' -  VOC) ngo-1639 lapha athoma khona ukuba msizi kadorhodere ohlinzako ekhambeni labo lokuya e-Batavia (namhlanjesi eyaziwa nge-Jakarta) ngenyanga kaSihlabantangana 1639 bese batjhinga e-Nagasaki eJapani ngo-1643.&lt;ref name=&quot;:2&quot; /&gt;

Ngo-1645 u-Jan Van Riebeeck wanikelwa isabelo sokuba mphathi wesitetjhi sokurhwebela se-VOC ebesise-Tongkin e-''French Indochina'' (namhlanjesi eyaziwa nge-Vietnam). Wehliswa esikhundleneso ngebanga lokuthi besele azenzela irhwebo lakhe langeqadi, okuphula umthetho wekhamphani othi abaphathi akukafuzi bazenzele irhwebo ngeqadi ngepahla yekhamphani. Kwathi bona ehliswe esikhundleni, wazithola sele kufuze abuyele emva e-Netherlands ayoqalana nemilandu yakhe. Ngikho-ke besele atholakala komunye wemikhumbi eli-12 ebeyidoswa phambili ngu-W.G de Jong. Wafika e-''Table Bay'' hlanu kwe-''Cape of Good Hope'' wahlala khona amalanga ali-18. Lokho kwamnikela isikhathi sokuqalisisa indawo, nokucabanga bona angayisebenzisa njani ekwenzeni bona i-VOC imthembe godu. Wayibona iyindawo enganikela ngokudla namanzi kabakhamba ngemikhumbi.&lt;ref name=&quot;:2&quot; /&gt;

Njengombana umkhumbi i-''Nieuwe Haerlem'' waphahlazeka ngo-1647, abasindileko bakha indawo lapho, u-Jan Van Riebeeck walemuka indlela ebebarhwebelana ngayo namaKhoikhoi njengombana balinde ukutakulwa. Ngemva kwalokho-ke watlola umbiko ngendawo le nangakho koke akubonileko, bewahlongoza bona indawo le ingaba yindawo ehle khulu i-VOC engayisebenzisa. Umbiko lo watlolwa ngo-1648 wathunyelwa ekhamphanini. Kwathi ngo-1651 i-VOC yathatha isiqunto sokuthi indawo ye-''Cape of Good Hope'' ayisetjenziselwe iminqopho yekhamphani.&lt;ref name=&quot;:2&quot; /&gt;

I-VOC yakhetha yena u-Jan Van Riebeeck bona kube nguye umdosiphambili ozokuhloma isitetjhi sokuphumula semikhumbi yamaDatjhi khona izokuthola ukudla okutjha okunepilo namanzi ahlanzekileko. Kwaba kusuka kwakhe-ke u-Jan Van Riebeeck, asuka e-Texel, e-Netherlands ngomhla wama-24 kuNobayeni 1651 bewayokufika e-''Table Bay'' ngomhla wesi-6 kaSihlabantangana 1652.&lt;ref name=&quot;:2&quot; /&gt; Bafika bakhamba ngemikhumbi emihlanu - i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch''.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;

== Ukufika KwamaDatjhi  - 1652 ==
[[Isimumathi:VOC ship Phenix.jpg|thumb|Imikhumbi yamaDatjhi ifika eKapa]]
U-Jan Van Riebeeck wasuka ngomhla wama-24 kuNobayeni 1651 e-Texel, e-Netherlands, wafika ngomhla wesi-6 kaSihlabantangana 1652.&lt;ref name=&quot;:2&quot; /&gt; Bafika bakhamba ngemikhumbi emihlanu - i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;'' Emithathu le ngiyo eyafika qangi, ngikho kwaziwa khulu le emithathu, le eminye imikhumbi emibili yafika mva. Ekufikeni kwakhe nabantu ebekakhamba nabo ngemikhumbi le wafika wakha indawo yobuphephelo ebizwa bona yi-''Fort de Goede Hoop (Fort of Good Hope).'' Bafika batjala endaweni leyo, kodwana iintjalo zabo khenge zitlhurhe kuhle, mhlamunye ngebanga lobujamo bezulu obungafani nobe-Netherlands, netjharagano ebeliphakathi kwamadoda ebekakhamba nawo nakufuze basebenze batlhgomele imikhumbu edlulako. Abantu bebabancani umsebenzi umnengi.&lt;ref name=&quot;:2&quot; /&gt;

Kwathi ngo-1655 u-Van Riebeeck wabika bona ngaphandle kwabantu abazimisele ukusebenza emasimini, isitetjhesi sizokubhalelwa ukwenza umsebenzi esihloselwe wona. Kwathi ngo-1657, i-VOC yathumela abalimi ababhadelwako, ngombandela wokuthi balime inarha bebathengisele ikhamphani iintjalo abazilimileko. Ngibo laba ebebabizwa bona ma-''Free Burghers (Vry Burgers)''. U-Jan Van Riebeeck wathatha isikhathi sakhe soke atjala bekakhiqiza amagrepsi, ama-apula namazambana, ukudla okuzokuba lisizo khulu emikhumbini edlulako. Kwathi ngo-1659 besele anesivuno samagrepsi ebesikhiqiza iwayini elibovu elilwisana nobulwele be-''scurvy,'' njengombana besele alemukile bona ukusela iwayini kuyabuvikela ubulwelobu ngokwezinga elithileko.&lt;ref name=&quot;:2&quot; /&gt;

== Ama-Khoikhoi ==
Ukuthoma kokufika kwamaDatjhi eKapa (''Cape of Good Hope'') khenge kubamangaze abantu bendabuko bendawo leyo ama-Khoikhoi. AmaDatjhi afika nje ama-Khoikhoi besele kukade arhwebelana namaPutukezi, amaFrentji namaNgisi. Nangaphezu kokufika kuka-Van Riebeeck, ngokuya kuka-Knox‑Johnson, phakathi nomnyaka wabo-1600 kuya ku-1700, besele kudlule imikhumbi yamaDatjhi eziyi-1 730. Yeke amaKhoikhoi bekangawaqabuki amaDatjhi ngesikhatheso.&lt;ref&gt;Helen Swingler (22 September 2021) ''Heritage Month: The Khoi encountered Europeans long before Van Riebeeck,'' University of Cape Town News. Retrieved from: https://www.news.uct.ac.za/article/-2021-09-22-the-khoi-encountered-europeans-long-before-van-riebeeck. Retrieved on 12/01/2026.&lt;/ref&gt;
[[Isimumathi:Khoikhoi Hottentot p197.jpg|thumb|Ama-Khoikhoi]]
Esikhathini sokufika kwamaDatjhi bekunendoda ebizwa bona ngu-Autshumato, namkha u-Autshumao, amaDatjhi ebebambiza bona ngu-''Harry die Strandloper''. [[U-Autshumato]] bekayikosi yesitjhaba samaKhoikhoi ebesibizwa bona ma-''Gorinhaikona''. Isitetjhana sokurhwebelana nabantu bemikhumbi sathonywa nguye.&lt;ref name=&quot;:3&quot;&gt;Roben Island Museum (13 May 2017) ''Autshumato''. Retrieved from: http://www.robben-island.org.za/departments/heritage/gallery/autshumato.asp. Retrieved on 14/01/2026.&lt;/ref&gt; Ngo-1630 wathathwa maNgisi esitjhabeni sekhabo bona ambandulele ukukhulumisana nabanye ngendaba yezokurhwebelana begodu atolige. Yeke amaNgisi amthatha amusa e-Bantam eNgilandi, wafika wafundiswa isiNgisi, isiDatjhi nesiFrentji nesiPutukezi. Wathi nakabuya eKapa bamthatha bamusa e-''Robben Island'' yena nabalandeli bakhe. Bekuthi imikhumbi nayifikako ambathe iimpahla zamaYurobhu akhulumisane nabokapteni bemikhumbi, akhulume isiNgisi nesiFrentji. Bambiza bona yi-''Governor.''&lt;ref name=&quot;:4&quot;&gt;Camissa Museum (2026) ''Autshumao (1610 - 1674)'', Retrieved from: https://camissamuseum.co.za/index.php/7-tributaries/1-cape-indigenous-africans/autshumao. Retrieved on 12/01/2026.&lt;/ref&gt;

Kwathi ngo-1638, u-Autshumao nomphakathi wekhabo ebewunabantu abangaba ma-60, babuya esihlengehlengeni beza enarheni eKapa, lapha kuhlangana khona umlambo i-''Camissa River'' nelwandle. Yena nomndenakhe ngibo ebebaphethe isitetjhi sokurhwebelana i-''‖Ammaqua'' (okutjho Abantu bemanzini) okulibizo u-Jan Van Riebeeck ebekababiza ngalo ekuthomeni.&lt;ref name=&quot;:3&quot; /&gt;&lt;ref name=&quot;:4&quot; /&gt;

Ngesikhathi amaDatjhi afika, umuntu wokuthoma ukubamukela bekungu-Autshumao nabantu bakhe. ngikho nje amaDatjhi bebababiza ngokuthi ma-''Strandloper'' ngombana babathola bakhamba eligwini lelwandle. Kusukela bathoma ukubonana bathoma ukurhwebelana. Zoke izinto ebezenzeka u-Jan Van Riebeeck wazitlola emajenalini wakhe. AmaDatjhi bewathenga iinkomo nezimvu kuma-Khoikhoi ngepahla ehlukahlukeneko kuhlanganise notjwala negwayi. Bese inyama yefuyo le idliwe, enye ethengiselwe abantu abadlula ngemikhumbi yekhamphani.&lt;ref name=&quot;:5&quot;&gt;Steemit Website (2018) ''SOUTH AFRICAN HISTORY: Autshumato translator and first Postmaster of The Cape of Good Hope''. Retrieved from: https://steemit.com/history/@krabgat/south-african-history-autshumato-translator-and-first-postmaster-of-the-cape-of-good-hope. Retrieved on 14/01/2026.&lt;/ref&gt; 

Kwathi ngenyanga kaSewula wango-1653 kwaba nokurhitjhana phakathi kuka-Autshumato nomelusi weenkomo zika-Van Riebeeck u-David Jansz. U-Autshumato wambulala wathatha iinkomo. Ukurhitjhanokhu kuthoma nje iintjhaba ezimbili lezi besele zingasathelelani kuhle amanzi. AmaDatjhi besele aqala u-Autshumato nabantu bakhe njengamasela. U-Jan Van Riebeeck wathi u-Autshumato lisela elinelimi elibutjhelelezi. AmaKhoikhoi aqala amaDatjhi njengabakhohlisi ngokuthi intengo yotjwala negwayi ayilingani nentengo yesilwana esifuywako. Bebathi bangabusela utjwala buphele, babone ifuywabo emadlelweni wamaDatjhi, yanda. Bese amaKhoikhoi akhambe ayoyeba.&lt;ref&gt;Castle of Good Hope (''13th November 2018'') ''Interpreters' Flawed Contracts With Dutch''Retrieved from: https://www.castleofgoodhope.co.za/index.php/news/100-news/142-interpreters-flawed-contracts-with-dutch. Retrieved on 14/01/2026.&lt;/ref&gt; 

Isenzakalo sokubulawa kuka-David Jansz sasusa ipi phakathi kwama-Khoi namaDatjhi. U-Van RieBeeck wathi u-Autshumato unomlandu wokubulala. Yeke kwaliwa ipi, ekugcineni ama-Khoi ahlulwa. U-Atshumato wabanjwa wasiwa ekuthunjweni e-''Robben Island'' ngawo umnyaka ka-1653. Kodwana ngo-1655 waphunyurha yena nalabo ebekathunjwe nabo babuyela enarheni ngesikepe esinembobo.  Nakafikako u-Jan Van Riebeeck wamamukela wambuyisela esikhundleni sakhe sokutoliga.&lt;ref name=&quot;:5&quot; /&gt;

== Iinkhombo ==</text>
      <sha1>sg2g5ddkx77d3f9cbr9yepk9tubhqqq</sha1>
    </revision>
    <revision>
      <id>6138</id>
      <parentid>6137</parentid>
      <timestamp>2026-01-19T20:31:26Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>edited</comment>
      <origin>6138</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="14055" sha1="qop503f5uigtz82negg60ac5i0rcny1" xml:space="preserve">[[Isimumathi:Flag of the Dutch East India Company.svg|thumb|260x260px|Iflarha le-VOC (Dutch East India Company)]]
'''AmaDatjhi''' '''(ngokhamba kwesikhathi abizwa ngamaBhuru)''' afika esewula ne-Afrika, eKapa, ngomhla we-6 kuSihlabantangana  ngo-1652. Bafika bakhamba ngemikhumbi emihlanu badoswa phambili ngu-Jan Van Riebeeck. Isizathu esenza amaDatjhi azithole aseKapa yindaba yezerhwebo. Abantwaba  bebangaphasi kwekhamphani ebizwa bona yi-''Dutch East India Company'' (V''ereenigde Oost-Indische Compagnie'' ''-'' VOC).&lt;ref name=&quot;:0&quot;&gt;South African History Online (13 January 2024) ''The Dutch Settlement.'' Retrieved from: https://sahistory.org.za/article/dutch-settlement Retrieved on 01/01/2026.&lt;/ref&gt; 

Ikhamphani le beyithatha ipahla, ikhambe amalwandle ngemikhumbi, iyoyithengisa eNdiya. Yeke ngebanga lokubalekela iingebengu zelwandle beyizomba inarhakazi yoke ye-Afrika. Kodwana ibangeli belilide khulu, begodu imikhumbi beyiphelelwa kukudla isendleleni. Yeke bekufuze kube nendawo lapha bangajama khona baphumule bathole nokudla okuzobafikisa eNdiya, iinthelo, imirorho, inyama namanzi ahlanzekileko ebekutholakala budisi kezinye iindawo. IKapa yaba ngileyondawo, ngikho nje beyibizwa bona yi-''Cape of Good Hope''.&lt;ref name=&quot;:2&quot; /&gt;

U-Jan Van Riebeeck wabona indawo le asendleleni ebuyela emva e-Holland, avela eJapani, njengombana bekathengisela i-VOC iinkhumba. Wathi nakehla emkhunjini eKapa, wabona indawo le ingaba yihle khulu bona imikhumbi ye-VOC ingaphumulela khona bese iraga nekhambo layo itjhinge eNdiya.&lt;ref name=&quot;:2&quot; /&gt;

== U-Jan Van Riebeeck - 1647 ==
[[Isimumathi:Jan van Riebeeck cropped.jpg|thumb|U-Jan Van Riebeeck]]
Kuhlekuhle bekungasikokuthoma amaDatjhi afika ngo-1652. Bakhe bafika okokuthoma ngenyanga kaNtaka ngo-1647 bakhamba ngomkhumbi obizwa bona yi-''Nieuwe Haarlem''. Umkhumbi lo wafika waphahlazeka eKapa. Abasinda emkhunjini lowo bafika bakha indawo abayibiza bona yi-''Sand Fort of the Cape of Good Hope.'' Bahlala lapho pheze umnyaka woke. Ekugcineni kwafika imikhumbi eli-12 ebeyidoswa phambili ngu-W.G de Jong. Komunye wemikhumbi le bekunendoda ebizwa bona ngu-Jan Van Riebeeck.&lt;ref name=&quot;:1&quot;&gt;Marco Ramerini, English text by Dietrich Köster (January, 11 2014), ''The Dutch in South Africa, 1652-1795 and 1802-1806.'' Retrieved from https://www.colonialvoyage.com/dutch-south-africa/. Retrieved on 03/01/2026.&lt;/ref&gt;&lt;ref name=&quot;:2&quot;&gt;South African History Online (17 October 2011), ''Jan van Riebeeck.'' Retrieved from: https://sahistory.org.za/people/jan-van-riebeeck. Retreived on 03/01/2026.&lt;/ref&gt;

[[U-Jan Van Riebeeck]] (U-''Johan Anthoniszoon &quot;Jan&quot; Van Riebeeck'') wabelethwa ngomhla ka-21 kuSihlabantangana 1619 e-Culemborg, e-Netherlands abelethwa nguyise ungodorhodere ohlinzako. Wakhulela e-Schiedam, e-Netherlands, kwathi ngomhla wama-28 kuNtaka 1649, watjhada u-''Maria de la Queillerie'', waba nabantwana ababunane naye.&lt;ref name=&quot;:2&quot; /&gt;

U-Jan Van Riebeeck waba lilunga le-''Dutch East India Company'' (''Vereenigde Oost-Indische Compagnie'' -  VOC) ngo-1639 lapha athoma khona ukuba msizi kadorhodere ohlinzako ekhambeni labo lokuya e-Batavia (namhlanjesi eyaziwa nge-Jakarta) ngenyanga kaSihlabantangana 1639 bese batjhinga e-Nagasaki eJapani ngo-1643.&lt;ref name=&quot;:2&quot; /&gt;

Ngo-1645 u-Jan Van Riebeeck wanikelwa isabelo sokuba mphathi wesitetjhi sokurhwebela se-VOC ebesise-Tongkin e-''French Indochina'' (namhlanjesi eyaziwa nge-Vietnam). Wehliswa esikhundleneso ngebanga lokuthi besele azenzela irhwebo lakhe langeqadi, okuphula umthetho wekhamphani othi abaphathi akukafuzi bazenzele irhwebo ngeqadi ngepahla yekhamphani. Kwathi bona ehliswe esikhundleni, wazithola sele kufuze abuyele emva e-Netherlands ayoqalana nemilandu yakhe. Ngikho-ke besele atholakala komunye wemikhumbi eli-12 ebeyidoswa phambili ngu-W.G de Jong. Wafika e-''Table Bay'' hlanu kwe-''Cape of Good Hope'' wahlala khona amalanga ali-18. Lokho kwamnikela isikhathi sokuqalisisa indawo, nokucabanga bona angayisebenzisa njani ekwenzeni bona i-VOC imthembe godu. Wayibona iyindawo enganikela ngokudla namanzi kabakhamba ngemikhumbi.&lt;ref name=&quot;:2&quot; /&gt;

Njengombana umkhumbi i-''Nieuwe Haerlem'' waphahlazeka ngo-1647, abasindileko bakha indawo lapho, u-Jan Van Riebeeck walemuka indlela ebebarhwebelana ngayo namaKhoikhoi njengombana balinde ukutakulwa. Ngemva kwalokho-ke watlola umbiko ngendawo le nangakho koke akubonileko, bewahlongoza bona indawo le ingaba yindawo ehle khulu i-VOC engayisebenzisa. Umbiko lo watlolwa ngo-1648 wathunyelwa ekhamphanini. Kwathi ngo-1651 i-VOC yathatha isiqunto sokuthi indawo ye-''Cape of Good Hope'' ayisetjenziselwe iminqopho yekhamphani.&lt;ref name=&quot;:2&quot; /&gt;

I-VOC yakhetha yena u-Jan Van Riebeeck bona kube nguye umdosiphambili ozokuhloma isitetjhi sokuphumula semikhumbi yamaDatjhi khona izokuthola ukudla okutjha okunepilo namanzi ahlanzekileko. Kwaba kusuka kwakhe-ke u-Jan Van Riebeeck, asuka e-Texel, e-Netherlands ngomhla wama-24 kuNobayeni 1651 bewayokufika e-''Table Bay'' ngomhla wesi-6 kaSihlabantangana 1652.&lt;ref name=&quot;:2&quot; /&gt; Bafika bakhamba ngemikhumbi emihlanu - i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch''.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;

== Ukufika KwamaDatjhi  - 1652 ==
[[Isimumathi:VOC ship Phenix.jpg|thumb|Imikhumbi yamaDatjhi ifika eKapa]]
U-Jan Van Riebeeck wasuka ngomhla wama-24 kuNobayeni 1651 e-Texel, e-Netherlands, wafika ngomhla wesi-6 kaSihlabantangana 1652.&lt;ref name=&quot;:2&quot; /&gt; Bafika bakhamba ngemikhumbi emihlanu - i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;'' Emithathu le ngiyo eyafika qangi, ngikho kwaziwa khulu le emithathu, le eminye imikhumbi emibili yafika mva. Ekufikeni kwakhe nabantu ebekakhamba nabo ngemikhumbi le wafika wakha indawo yobuphephelo ebizwa bona yi-''Fort de Goede Hoop (Fort of Good Hope).'' Bafika batjala endaweni leyo, kodwana iintjalo zabo khenge zitlhurhe kuhle, mhlamunye ngebanga lobujamo bezulu obungafani nobe-Netherlands, netjharagano ebeliphakathi kwamadoda ebekakhamba nawo nakufuze basebenze batlhgomele imikhumbu edlulako. Abantu bebabancani umsebenzi umnengi.&lt;ref name=&quot;:2&quot; /&gt;

Kwathi ngo-1655 u-Van Riebeeck wabika bona ngaphandle kwabantu abazimisele ukusebenza emasimini, isitetjhesi sizokubhalelwa ukwenza umsebenzi esihloselwe wona. Kwathi ngo-1657, i-VOC yathumela abalimi ababhadelwako, ngombandela wokuthi balime inarha bebathengisele ikhamphani iintjalo abazilimileko. Ngibo laba ebebabizwa bona ma-''Free Burghers (Vry Burgers)''. U-Jan Van Riebeeck wathatha isikhathi sakhe soke atjala bekakhiqiza amagrepsi, ama-apula namazambana, ukudla okuzokuba lisizo khulu emikhumbini edlulako. Kwathi ngo-1659 besele anesivuno samagrepsi ebesikhiqiza iwayini elibovu elilwisana nobulwele be-''scurvy,'' njengombana besele alemukile bona ukusela iwayini kuyabuvikela ubulwelobu ngokwezinga elithileko.&lt;ref name=&quot;:2&quot; /&gt;

== Ama-Khoikhoi ==
Ukuthoma kokufika kwamaDatjhi eKapa (''Cape of Good Hope'') khenge kubamangaze abantu bendabuko bendawo leyo ama-Khoikhoi. AmaDatjhi afika nje ama-Khoikhoi besele kukade arhwebelana namaPutukezi, amaFrentji namaNgisi. Nangaphezu kokufika kuka-Van Riebeeck, ngokuya kuka-Knox‑Johnson, phakathi nomnyaka wabo-1600 kuya ku-1700, besele kudlule imikhumbi yamaDatjhi eziyi-1 730. Yeke amaKhoikhoi bekangawaqabuki amaDatjhi ngesikhatheso.&lt;ref&gt;Helen Swingler (22 September 2021) ''Heritage Month: The Khoi encountered Europeans long before Van Riebeeck,'' University of Cape Town News. Retrieved from: https://www.news.uct.ac.za/article/-2021-09-22-the-khoi-encountered-europeans-long-before-van-riebeeck. Retrieved on 12/01/2026.&lt;/ref&gt;
[[Isimumathi:Khoikhoi Hottentot p197.jpg|thumb|Ama-Khoikhoi]]
Esikhathini sokufika kwamaDatjhi bekunendoda ebizwa bona ngu-Autshumato, namkha u-Autshumao, amaDatjhi ebebambiza bona ngu-''Harry die Strandloper''. [[U-Autshumato]] bekayikosi yesitjhaba samaKhoikhoi ebesibizwa bona ma-''Gorinhaikona''. Isitetjhana sokurhwebelana nabantu bemikhumbi sathonywa nguye.&lt;ref name=&quot;:3&quot;&gt;Roben Island Museum (13 May 2017) ''Autshumato''. Retrieved from: http://www.robben-island.org.za/departments/heritage/gallery/autshumato.asp. Retrieved on 14/01/2026.&lt;/ref&gt; Ngo-1630 wathathwa maNgisi esitjhabeni sekhabo bona ambandulele ukukhulumisana nabanye ngendaba yezokurhwebelana begodu atolige. Yeke amaNgisi amthatha amusa e-Bantam eNgilandi, wafika wafundiswa isiNgisi, isiDatjhi nesiFrentji nesiPutukezi. Wathi nakabuya eKapa bamthatha bamusa e-''Robben Island'' yena nabalandeli bakhe. Bekuthi imikhumbi nayifikako ambathe iimpahla zamaYurobhu akhulumisane nabokapteni bemikhumbi, akhulume isiNgisi nesiFrentji. Bambiza bona yi-''Governor.''&lt;ref name=&quot;:4&quot;&gt;Camissa Museum (2026) ''Autshumao (1610 - 1674)'', Retrieved from: https://camissamuseum.co.za/index.php/7-tributaries/1-cape-indigenous-africans/autshumao. Retrieved on 12/01/2026.&lt;/ref&gt;

Kwathi ngo-1638, u-Autshumao nomphakathi wekhabo ebewunabantu abangaba ma-60, babuya esihlengehlengeni beza enarheni eKapa, lapha kuhlangana khona umlambo i-''Camissa River'' nelwandle. Yena nomndenakhe ngibo ebebaphethe isitetjhi sokurhwebelana i-''‖Ammaqua'' (okutjho Abantu bemanzini) okulibizo u-Jan Van Riebeeck ebekababiza ngalo ekuthomeni.&lt;ref name=&quot;:3&quot; /&gt;&lt;ref name=&quot;:4&quot; /&gt;

Ngesikhathi amaDatjhi afika, umuntu wokuthoma ukubamukela bekungu-Autshumao nabantu bakhe. ngikho nje amaDatjhi bebababiza ngokuthi ma-''Strandloper'' ngombana babathola bakhamba eligwini lelwandle. Kusukela bathoma ukubonana bathoma ukurhwebelana. Zoke izinto ebezenzeka u-Jan Van Riebeeck wazitlola emajenalini wakhe. AmaDatjhi bewathenga iinkomo nezimvu kuma-Khoikhoi ngepahla ehlukahlukeneko kuhlanganise notjwala negwayi. Bese inyama yefuyo le idliwe, enye ethengiselwe abantu abadlula ngemikhumbi yekhamphani.&lt;ref name=&quot;:5&quot;&gt;Steemit Website (2018) ''SOUTH AFRICAN HISTORY: Autshumato translator and first Postmaster of The Cape of Good Hope''. Retrieved from: https://steemit.com/history/@krabgat/south-african-history-autshumato-translator-and-first-postmaster-of-the-cape-of-good-hope. Retrieved on 14/01/2026.&lt;/ref&gt; 

Kwathi ngenyanga kaSewula wango-1653 kwaba nokurhitjhana phakathi kuka-Autshumato nomelusi weenkomo zika-Van Riebeeck u-David Jansz. U-Autshumato wambulala wathatha iinkomo. Ukurhitjhanokhu kuthoma nje iintjhaba ezimbili lezi besele zingasathelelani kuhle amanzi. AmaDatjhi besele aqala u-Autshumato nabantu bakhe njengamasela. U-Jan Van Riebeeck wathi u-Autshumato lisela elinelimi elibutjhelelezi. AmaKhoikhoi aqala amaDatjhi njengabakhohlisi ngokuthi intengo yotjwala negwayi ayilingani nentengo yesilwana esifuywako. Bebathi bangabusela utjwala buphele, babone ifuywabo emadlelweni wamaDatjhi, yanda. Bese amaKhoikhoi akhambe ayoyeba.&lt;ref&gt;Castle of Good Hope (''13th November 2018'') ''Interpreters' Flawed Contracts With Dutch''Retrieved from: https://www.castleofgoodhope.co.za/index.php/news/100-news/142-interpreters-flawed-contracts-with-dutch. Retrieved on 14/01/2026.&lt;/ref&gt; 

Isenzakalo sokubulawa kuka-David Jansz sasusa ipi phakathi kwama-Khoe namaDatjhi. U-Van RieBeeck wathi u-Autshumato unomlandu wokubulala. Yeke kwaliwa ipi, ekugcineni ama-Khoe ahlulwa. U-Autshumato wabanjwa wasiwa ekuthunjweni e-''Robben Island'' ngawo umnyaka ka-1653. Kodwana ngo-1655 watjhatjululwa wabuyiswa enarheni.  Nakafikako u-Jan Van Riebeeck wamamukela wambuyisela esikhundleni sakhe sokutologa.&lt;ref name=&quot;:52&quot;&gt;Steemit Website (2018) ''SOUTH AFRICAN HISTORY: Autshumato translator and first Postmaster of The Cape of Good Hope''. Retrieved from: https://steemit.com/history/@krabgat/south-african-history-autshumato-translator-and-first-postmaster-of-the-cape-of-good-hope. Retrieved on 14/01/2026.&lt;/ref&gt;  Ngesikhathesi [[u-Autshumato]] besele azwisisa indlela amaYurobhu arhweba ngayo nendlela yokuzuza kiyo. Bekathi nakarhwebela u-Jan Van Riebeeck iinkomo, aqiniseke bona imbadelo yekhamphani yanele bona ingabhadela neenkomo azithengela zona yena, ngikho nje aba mumuntu oregileko eKapa.&lt;ref name=&quot;:52&quot; /&gt;

Ngokukhamba kwesikhathi kwaba nokhunye godu ukurhitjhana phakathi kwama-Khoekhoe namaDatjhi ngo-1657. Ukurhitjhanokhu kubangwa kungazwani kwama-''Free Burghers (Vry Burgers)''  neengqila ze-Madagascar.  U-Jan Van Riebeeck wakateleleka bona akhe isivikelo endaweni leyo, bona enze ama-Khoekhoe asuke endaweni leyo. Bekuthi ezinye iingqila naziphunyurhako asebenzise u-Autshumato njengesithunjwa ukuhlohlozela ama-Khoe bona akhambe ayokubamba iingqilezo. Kodwana iqhinga lika-Van Riebeeck khenge liphumelele ngendlela afuna ngayo. Kwathi ngo-1658 u-Autshumato wabanjwa, wathathelwa yoke ifuywakhe. Ngemva kokutjhutjhiswa wathunjwa wasiwa e-''Robben Island'' godu. Kodwana wathi nakalapho waphunyurha ngesikepe esivuzako. Bekube kunamhlanjesi, u-Autshumato nguye kwaphela umuntu okghone ukuphunyurha e-''Robben Island'' njengesibotjhwa. Kunokuthi nakabuyako enarheni abotjhwe, u-Van Riebeeck wambuyisela esikhundleni sakhe sokukhulumisana nokutologa.&lt;ref name=&quot;:52&quot; /&gt;&lt;ref name=&quot;:42&quot;&gt;Camissa Museum (2026) ''Autshumao (1610 - 1674)'', Retrieved from: https://camissamuseum.co.za/index.php/7-tributaries/1-cape-indigenous-africans/autshumao. Retrieved on 12/01/2026.&lt;/ref&gt;

Ngomhla wobu-8 kuKhukhulamungu wango-1662 u-Jan Van Riebeeck wakhamba eKapa esesewula Afrika, watjhiya u-Zacharias Wagenaer bona kube nguye osala aphethe endaweni abakiyo eKapa. Wafika wahlala endaweni ebizwa bona yiMalacca namhlanjesi ebizwa bona yi-Melaka eseMalaysia, wahlala lapho bekwaba nguKhukhulamungu wango-1665. Umkakhe wahlongakala ngokubulawa bulwele bepokisi ngenyanga kaSinyikhaba ngo-1664. Ngemva kwalokho wabekwa esikhundleni sokuba ngu-''Governor-General-in-Council'' wenarha yeNdiya, begodu wahlala e-Batavia ipilwakhe yoke. Wahlongakala ngomhla we-18 kuTjhirhweni 1677.&lt;ref&gt;S2A3 Biographical Database of Southern African Science (2026)'''''Van Riebeeck,''' Commander '''Johan Antoniszoon''' (advancement of science).'' Retrieved from: https://www.s2a3.org.za/bio/Biograph_final.php?serial=2953. Retrieved on 16/01/2026.&lt;/ref&gt; Kwaba kufika nokuhlala kwamaDatjhi eSewula Afrika.

== Iinkhombo ==</text>
      <sha1>qop503f5uigtz82negg60ac5i0rcny1</sha1>
    </revision>
    <revision>
      <id>6767</id>
      <parentid>6138</parentid>
      <timestamp>2026-08-06T06:19:05Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>edited</comment>
      <origin>6767</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="14056" sha1="jmlx2tiy835hvdbtstm7sbgb5gbelzz" xml:space="preserve">[[Isimumathi:Flag of the Dutch East India Company.svg|thumb|260x260px|Iflarha le-VOC (Dutch East India Company)]]
'''AmaDatjhi''' '''(ngokhamba kwesikhathi abizwa ngamaBhuru)''' afika esewula ne-Afrika, eKapa, ngomhla we-6 kuSihlabantangana  ngo-1652. Bafika bakhamba ngemikhumbi emihlanu badoswa phambili ngu-Jan Van Riebeeck. Isizathu esenza amaDatjhi azithole aseKapa yindaba yezerhwebo. Abantwaba  bebangaphasi kwekhamphani ebizwa bona yi-''Dutch East India Company'' (V''ereenigde Oost-Indische Compagnie'' ''-'' VOC).&lt;ref name=&quot;:0&quot;&gt;South African History Online (13 January 2024) ''The Dutch Settlement.'' Retrieved from: https://sahistory.org.za/article/dutch-settlement Retrieved on 01/01/2026.&lt;/ref&gt; 

Ikhamphani le beyithatha ipahla, ikhambe amalwandle ngemikhumbi, iyoyithengisa eNdiya. Yeke ngebanga lokubalekela iingebengu zelwandle beyizomba inarhakazi yoke ye-Afrika. Kodwana ibangeli belilide khulu, begodu imikhumbi beyiphelelwa kukudla isendleleni. Yeke bekufuze kube nendawo lapha bangajama khona baphumule bathole nokudla okuzobafikisa eNdiya, iinthelo, imirorho, inyama namanzi ahlanzekileko ebekutholakala budisi kezinye iindawo. IKapa yaba ngileyondawo, ngikho nje beyibizwa bona yi-''Cape of Good Hope''.&lt;ref name=&quot;:2&quot; /&gt;

U-Jan Van Riebeeck wabona indawo le asendleleni ebuyela emva e-Holland, avela eJapani, njengombana bekathengisela i-VOC iinkhumba. Wathi nakehla emkhunjini eKapa, wabona indawo le ingaba yihle khulu bona imikhumbi ye-VOC ingaphumulela khona bese iraga nekhambo layo itjhinge eNdiya.&lt;ref name=&quot;:2&quot; /&gt;

== U-Jan Van Riebeeck - 1647 ==
[[Isimumathi:Jan van Riebeeck cropped.jpg|thumb|U-Jan Van Riebeeck]]
Kuhlekuhle bekungasikokuthoma amaDatjhi afika ngo-1652. Bakhe bafika okokuthoma ngenyanga kaNtaka ngo-1647 bakhamba ngomkhumbi obizwa bona yi-''Nieuwe Haarlem''. Umkhumbi lo wafika waphahlazeka eKapa. Abasinda emkhunjini lowo bafika bakha indawo abayibiza bona yi-''Sand Fort of the Cape of Good Hope.'' Bahlala lapho pheze umnyaka woke. Ekugcineni kwafika imikhumbi eli-12 ebeyidoswa phambili ngu-W.G de Jong. Komunye wemikhumbi le bekunendoda ebizwa bona ngu-Jan Van Riebeeck.&lt;ref name=&quot;:1&quot;&gt;Marco Ramerini, English text by Dietrich Köster (January, 11 2014), ''The Dutch in South Africa, 1652-1795 and 1802-1806.'' Retrieved from https://www.colonialvoyage.com/dutch-south-africa/. Retrieved on 03/01/2026.&lt;/ref&gt;&lt;ref name=&quot;:2&quot;&gt;South African History Online (17 October 2011), ''Jan van Riebeeck.'' Retrieved from: https://sahistory.org.za/people/jan-van-riebeeck. Retreived on 03/01/2026.&lt;/ref&gt;

[[U-Jan Van Riebeeck]] (U-''Johan Anthoniszoon &quot;Jan&quot; Van Riebeeck'') wabelethwa ngomhla ka-21 kuSihlabantangana 1619 e-Culemborg, e-Netherlands abelethwa nguyise ungodorhodere ohlinzako. Wakhulela e-Schiedam, e-Netherlands, kwathi ngomhla wama-28 kuNtaka 1649, watjhada u-''Maria de la Queillerie'', waba nabantwana ababunane naye.&lt;ref name=&quot;:2&quot; /&gt;

U-Jan Van Riebeeck waba lilunga le-''Dutch East India Company'' (''Vereenigde Oost-Indische Compagnie'' -  VOC) ngo-1639 lapha athoma khona ukuba msizi kadorhodere ohlinzako ekhambeni labo lokuya e-Batavia (namhlanjesi eyaziwa nge-Jakarta) ngenyanga kaSihlabantangana 1639 bese batjhinga e-Nagasaki eJapani ngo-1643.&lt;ref name=&quot;:2&quot; /&gt;

Ngo-1645 u-Jan Van Riebeeck wanikelwa isabelo sokuba mphathi wesitetjhi sokurhwebela se-VOC ebesise-Tongkin e-''French Indochina'' (namhlanjesi eyaziwa nge-Vietnam). Wehliswa esikhundleneso ngebanga lokuthi besele azenzela irhwebo lakhe langeqadi, okuphula umthetho wekhamphani othi abaphathi akukafuzi bazenzele irhwebo ngeqadi ngepahla yekhamphani. Kwathi bona ehliswe esikhundleni, wazithola sele kufuze abuyele emva e-Netherlands ayoqalana nemilandu yakhe. Ngikho-ke besele atholakala komunye wemikhumbi eli-12 ebeyidoswa phambili ngu-W.G de Jong. Wafika e-''Table Bay'' hlanu kwe-''Cape of Good Hope'' wahlala khona amalanga ali-18. Lokho kwamnikela isikhathi sokuqalisisa indawo, nokucabanga bona angayisebenzisa njani ekwenzeni bona i-VOC imthembe godu. Wayibona iyindawo enganikela ngokudla namanzi kabakhamba ngemikhumbi.&lt;ref name=&quot;:2&quot; /&gt;

Njengombana umkhumbi i-''Nieuwe Haerlem'' waphahlazeka ngo-1647, abasindileko bakha indawo lapho, u-Jan Van Riebeeck walemuka indlela ebebarhwebelana ngayo namaKhoikhoi njengombana balinde ukutakulwa. Ngemva kwalokho-ke watlola umbiko ngendawo le nangakho koke akubonileko, bewahlongoza bona indawo le ingaba yindawo ehle khulu i-VOC engayisebenzisa. Umbiko lo watlolwa ngo-1648 wathunyelwa ekhamphanini. Kwathi ngo-1651 i-VOC yathatha isiqunto sokuthi indawo ye-''Cape of Good Hope'' ayisetjenziselwe iminqopho yekhamphani.&lt;ref name=&quot;:2&quot; /&gt;

I-VOC yakhetha yena u-Jan Van Riebeeck bona kube nguye umdosiphambili ozokuhloma isitetjhi sokuphumula semikhumbi yamaDatjhi khona izokuthola ukudla okutjha okunepilo namanzi ahlanzekileko. Kwaba kusuka kwakhe-ke u-Jan Van Riebeeck, asuka e-Texel, e-Netherlands ngomhla wama-24 kuNobayeni 1651 bewayokufika e-''Table Bay'' ngomhla wesi-6 kaSihlabantangana 1652.&lt;ref name=&quot;:2&quot; /&gt; Bafika bakhamba ngemikhumbi emihlanu - i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch''.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;

== Ukufika KwamaDatjhi  - 1652 ==
[[Isimumathi:VOC ship Phenix.jpg|thumb|Imikhumbi yamaDatjhi ifika eKapa]]
U-Jan Van Riebeeck wasuka ngomhla wama-24 kuNobayeni 1651 e-Texel, e-Netherlands, wafika ngomhla wesi-6 kaSihlabantangana 1652.&lt;ref name=&quot;:2&quot; /&gt; Bafika bakhamba ngemikhumbi emihlanu - i-''Dromedaris'', i-''Reijger,'' i-''Goede Hoop,'' i-''Oliphant'' ne-''Walvisch.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;'' Emithathu le ngiyo eyafika qangi, ngikho kwaziwa khulu le emithathu, le eminye imikhumbi emibili yafika mva. Ekufikeni kwakhe nabantu ebekakhamba nabo ngemikhumbi le wafika wakha indawo yobuphephelo ebizwa bona yi-''Fort de Goede Hoop (Fort of Good Hope).'' Bafika batjala endaweni leyo, kodwana iintjalo zabo khenge zitlhurhe kuhle, mhlamunye ngebanga lobujamo bezulu obungafani nobe-Netherlands, netjharagano ebeliphakathi kwamadoda ebekakhamba nawo nakufuze basebenze batlhgomele imikhumbu edlulako. Abantu bebabancani umsebenzi umnengi.&lt;ref name=&quot;:2&quot; /&gt;

Kwathi ngo-1655 u-Van Riebeeck wabika bona ngaphandle kwabantu abazimisele ukusebenza emasimini, isitetjhesi sizokubhalelwa ukwenza umsebenzi esihloselwe wona. Kwathi ngo-1657, i-VOC yathumela abalimi ababhadelwako, ngombandela wokuthi balime inarha bebathengisele ikhamphani iintjalo abazilimileko. Ngibo laba ebebabizwa bona ma-''Free Burghers (Vry Burgers)''. U-Jan Van Riebeeck wathatha isikhathi sakhe soke atjala bekakhiqiza amagrepsi, ama-apula namazambana, ukudla okuzokuba lisizo khulu emikhumbini edlulako. Kwathi ngo-1659 besele anesivuno samagrepsi ebesikhiqiza iwayini elibovu elilwisana nobulwele be-''scurvy,'' njengombana besele alemukile bona ukusela iwayini kuyabuvikela ubulwelobu ngokwezinga elithileko.&lt;ref name=&quot;:2&quot; /&gt;

== Ama-Khoikhoi ==
Ukuthoma kokufika kwamaDatjhi eKapa (''Cape of Good Hope'') khenge kubamangaze abantu bendabuko bendawo leyo ama-Khoikhoi. AmaDatjhi afika nje ama-Khoikhoi besele kukade arhwebelana namaPutukezi, amaFrentji namaNgisi. Nangaphezu kokufika kuka-Van Riebeeck, ngokuya kuka-Knox‑Johnson, phakathi nomnyaka wabo-1600 kuya ku-1700, besele kudlule imikhumbi yamaDatjhi eziyi-1 730. Yeke amaKhoikhoi bekangawaqabuki amaDatjhi ngesikhatheso.&lt;ref&gt;Helen Swingler (22 September 2021) ''Heritage Month: The Khoi encountered Europeans long before Van Riebeeck,'' University of Cape Town News. Retrieved from: https://www.news.uct.ac.za/article/-2021-09-22-the-khoi-encountered-europeans-long-before-van-riebeeck. Retrieved on 12/01/2026.&lt;/ref&gt;
[[Isimumathi:Khoikhoi Hottentot p197.jpg|thumb|Ama-Khoikhoi]]
Esikhathini sokufika kwamaDatjhi bekunendoda ebizwa bona ngu-Autshumato, namkha u-Autshumao, amaDatjhi ebebambiza bona ngu-''Harry die Strandloper''. [[U-Autshumato]] bekayikosi yesitjhaba samaKhoikhoi ebesibizwa bona ma-''Gorinhaikona''. Isitetjhana sokurhwebelana nabantu bemikhumbi sathonywa nguye.&lt;ref name=&quot;:3&quot;&gt;Roben Island Museum (13 May 2017) ''Autshumato''. Retrieved from: http://www.robben-island.org.za/departments/heritage/gallery/autshumato.asp. Retrieved on 14/01/2026.&lt;/ref&gt; Ngo-1630 wathathwa maNgisi esitjhabeni sekhabo bona ambandulele ukukhulumisana nabanye ngendaba yezokurhwebelana begodu atolige. Yeke amaNgisi amthatha amusa e-Bantam eNgilandi, wafika wafundiswa isiNgisi, isiDatjhi nesiFrentji nesiPutukezi. Wathi nakabuya eKapa bamthatha bamusa e-''Robben Island'' yena nabalandeli bakhe. Bekuthi imikhumbi nayifikako ambathe iimpahla zamaYurobhu akhulumisane nabokapteni bemikhumbi, akhulume isiNgisi nesiFrentji. Bambiza bona yi-''Governor.''&lt;ref name=&quot;:4&quot;&gt;Camissa Museum (2026) ''Autshumao (1610 - 1674)'', Retrieved from: https://camissamuseum.co.za/index.php/7-tributaries/1-cape-indigenous-africans/autshumao. Retrieved on 12/01/2026.&lt;/ref&gt;

Kwathi ngo-1638, u-Autshumao nomphakathi wekhabo ebewunabantu abangaba ma-60, babuya esihlengehlengeni beza enarheni eKapa, lapha kuhlangana khona umlambo i-''Camissa River'' nelwandle. Yena nomndenakhe ngibo ebebaphethe isitetjhi sokurhwebelana i-''‖Ammaqua'' (okutjho Abantu bemanzini) okulibizo u-Jan Van Riebeeck ebekababiza ngalo ekuthomeni.&lt;ref name=&quot;:3&quot; /&gt;&lt;ref name=&quot;:4&quot; /&gt;

Ngesikhathi amaDatjhi afika, umuntu wokuthoma ukubamukela bekungu-Autshumato nabantu bakhe. ngikho nje amaDatjhi bebababiza ngokuthi ma-''Strandloper'' ngombana babathola bakhamba eligwini lelwandle. Kusukela bathoma ukubonana bathoma ukurhwebelana. Zoke izinto ebezenzeka u-Jan Van Riebeeck wazitlola emajenalini wakhe. AmaDatjhi bewathenga iinkomo nezimvu kuma-Khoikhoi ngepahla ehlukahlukeneko kuhlanganise notjwala negwayi. Bese inyama yefuyo le idliwe, enye ethengiselwe abantu abadlula ngemikhumbi yekhamphani.&lt;ref name=&quot;:5&quot;&gt;Steemit Website (2018) ''SOUTH AFRICAN HISTORY: Autshumato translator and first Postmaster of The Cape of Good Hope''. Retrieved from: https://steemit.com/history/@krabgat/south-african-history-autshumato-translator-and-first-postmaster-of-the-cape-of-good-hope. Retrieved on 14/01/2026.&lt;/ref&gt; 

Kwathi ngenyanga kaSewula wango-1653 kwaba nokurhitjhana phakathi kuka-Autshumato nomelusi weenkomo zika-Van Riebeeck u-David Jansz. U-Autshumato wambulala wathatha iinkomo. Ukurhitjhanokhu kuthoma nje iintjhaba ezimbili lezi besele zingasathelelani kuhle amanzi. AmaDatjhi besele aqala u-Autshumato nabantu bakhe njengamasela. U-Jan Van Riebeeck wathi u-Autshumato lisela elinelimi elibutjhelelezi. AmaKhoikhoi aqala amaDatjhi njengabakhohlisi ngokuthi intengo yotjwala negwayi ayilingani nentengo yesilwana esifuywako. Bebathi bangabusela utjwala buphele, babone ifuywabo emadlelweni wamaDatjhi, yanda. Bese amaKhoikhoi akhambe ayoyeba.&lt;ref&gt;Castle of Good Hope (''13th November 2018'') ''Interpreters' Flawed Contracts With Dutch''Retrieved from: https://www.castleofgoodhope.co.za/index.php/news/100-news/142-interpreters-flawed-contracts-with-dutch. Retrieved on 14/01/2026.&lt;/ref&gt; 

Isenzakalo sokubulawa kuka-David Jansz sasusa ipi phakathi kwama-Khoe namaDatjhi. U-Van RieBeeck wathi u-Autshumato unomlandu wokubulala. Yeke kwaliwa ipi, ekugcineni ama-Khoe ahlulwa. U-Autshumato wabanjwa wasiwa ekuthunjweni e-''Robben Island'' ngawo umnyaka ka-1653. Kodwana ngo-1655 watjhatjululwa wabuyiswa enarheni.  Nakafikako u-Jan Van Riebeeck wamamukela wambuyisela esikhundleni sakhe sokutologa.&lt;ref name=&quot;:52&quot;&gt;Steemit Website (2018) ''SOUTH AFRICAN HISTORY: Autshumato translator and first Postmaster of The Cape of Good Hope''. Retrieved from: https://steemit.com/history/@krabgat/south-african-history-autshumato-translator-and-first-postmaster-of-the-cape-of-good-hope. Retrieved on 14/01/2026.&lt;/ref&gt;  Ngesikhathesi [[u-Autshumato]] besele azwisisa indlela amaYurobhu arhweba ngayo nendlela yokuzuza kiyo. Bekathi nakarhwebela u-Jan Van Riebeeck iinkomo, aqiniseke bona imbadelo yekhamphani yanele bona ingabhadela neenkomo azithengela zona yena, ngikho nje aba mumuntu oregileko eKapa.&lt;ref name=&quot;:52&quot; /&gt;

Ngokukhamba kwesikhathi kwaba nokhunye godu ukurhitjhana phakathi kwama-Khoekhoe namaDatjhi ngo-1657. Ukurhitjhanokhu kubangwa kungazwani kwama-''Free Burghers (Vry Burgers)''  neengqila ze-Madagascar.  U-Jan Van Riebeeck wakateleleka bona akhe isivikelo endaweni leyo, bona enze ama-Khoekhoe asuke endaweni leyo. Bekuthi ezinye iingqila naziphunyurhako asebenzise u-Autshumato njengesithunjwa ukuhlohlozela ama-Khoe bona akhambe ayokubamba iingqilezo. Kodwana iqhinga lika-Van Riebeeck khenge liphumelele ngendlela afuna ngayo. Kwathi ngo-1658 u-Autshumato wabanjwa, wathathelwa yoke ifuywakhe. Ngemva kokutjhutjhiswa wathunjwa wasiwa e-''Robben Island'' godu. Kodwana wathi nakalapho waphunyurha ngesikepe esivuzako. Bekube kunamhlanjesi, u-Autshumato nguye kwaphela umuntu okghone ukuphunyurha e-''Robben Island'' njengesibotjhwa. Kunokuthi nakabuyako enarheni abotjhwe, u-Van Riebeeck wambuyisela esikhundleni sakhe sokukhulumisana nokutologa.&lt;ref name=&quot;:52&quot; /&gt;&lt;ref name=&quot;:42&quot;&gt;Camissa Museum (2026) ''Autshumao (1610 - 1674)'', Retrieved from: https://camissamuseum.co.za/index.php/7-tributaries/1-cape-indigenous-africans/autshumao. Retrieved on 12/01/2026.&lt;/ref&gt;

Ngomhla wobu-8 kuKhukhulamungu wango-1662 u-Jan Van Riebeeck wakhamba eKapa esesewula Afrika, watjhiya u-Zacharias Wagenaer bona kube nguye osala aphethe endaweni abakiyo eKapa. Wafika wahlala endaweni ebizwa bona yiMalacca namhlanjesi ebizwa bona yi-Melaka eseMalaysia, wahlala lapho bekwaba nguKhukhulamungu wango-1665. Umkakhe wahlongakala ngokubulawa bulwele bepokisi ngenyanga kaSinyikhaba ngo-1664. Ngemva kwalokho wabekwa esikhundleni sokuba ngu-''Governor-General-in-Council'' wenarha yeNdiya, begodu wahlala e-Batavia ipilwakhe yoke. Wahlongakala ngomhla we-18 kuTjhirhweni 1677.&lt;ref&gt;S2A3 Biographical Database of Southern African Science (2026)'''''Van Riebeeck,''' Commander '''Johan Antoniszoon''' (advancement of science).'' Retrieved from: https://www.s2a3.org.za/bio/Biograph_final.php?serial=2953. Retrieved on 16/01/2026.&lt;/ref&gt; Kwaba kufika nokuhlala kwamaDatjhi eSewula Afrika.

== Iinkhombo ==</text>
      <sha1>jmlx2tiy835hvdbtstm7sbgb5gbelzz</sha1>
    </revision>
  </page>
  <page>
    <title>U-James Peace</title>
    <ns>0</ns>
    <id>1026</id>
    <revision>
      <id>6147</id>
      <timestamp>2026-01-28T02:20:07Z</timestamp>
      <contributor>
        <username>Tata.tata3</username>
        <id>1319</id>
      </contributor>
      <comment>Created page with &quot;[[Isimumathi:James Peace at home in Wiesbaden3.jpg|thumb|401x401px|James Peace ]] '''U-Kenneth James Peace''' wabelethelwa e-Paisley, mhla ama-28 kuNobayeni, 1963. Umakhiwombhino we-Scotland, umdlali wepiyano ekhonsathini kanye nomdwebi wezinto ezibonwako.  == Umlando Womuntu == UJames Peace wabelethelwa e-Paisley, mhla ama-28 kuNobayeni, 1963. Wakhulela e-Helensburgh, indawo yokuphumula eseduze nelwandle etjingalanga ye-Scotland.&lt;ref name=&quot;:0&quot;&gt;[https://web.archive.org/w...&quot;</comment>
      <origin>6147</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="10639" sha1="gvqqi2jjeanoljzezb1f1fohhataqa3" xml:space="preserve">[[Isimumathi:James Peace at home in Wiesbaden3.jpg|thumb|401x401px|James Peace ]]
'''U-Kenneth James Peace''' wabelethelwa e-Paisley, mhla ama-28 kuNobayeni, 1963. Umakhiwombhino we-Scotland, umdlali wepiyano ekhonsathini kanye nomdwebi wezinto ezibonwako.

== Umlando Womuntu ==
UJames Peace wabelethelwa e-Paisley, mhla ama-28 kuNobayeni, 1963. Wakhulela e-Helensburgh, indawo yokuphumula eseduze nelwandle etjingalanga ye-Scotland.&lt;ref name=&quot;:0&quot;&gt;[https://web.archive.org/web/20110527164145/http://www.wiesbadener-tagblatt.de/region/wiesbaden/meldungen/10206548.htm Birgitta Lamparth. &quot;Keine ‘stacheligen’ Klänge&quot;, Wiesbadener Tagblatt (iphephandaba le-German), mhlana ali-10 kuMhlolanja, 2012]

&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;Julia Anderton. &quot;Tango wie eine süß-saure Geschichte&quot;. Wiesbadener Kurier (iphephandaba le-German), mhlana ama-24 kuNtaka, 2012&lt;/ref&gt;&lt;ref name=&quot;:2&quot;&gt;[https://hojaderutadigital.mx/una-entrevista-al-compositor-james-peace/ Soledad Carrizo-Araya. &quot;Una entrevista al compositor James Peace&quot;. Hoja de Ruta Digital. Unobayeni 2022]&lt;/ref&gt; Umndenakhe bewunabavumi abanengi (isib. uJohn McGhie), begodu uhlobana noFelix Burns, umtlami wombhino odumileko womvumo wokudansa engcenyeni yokuthoma &lt;sup&gt;yekhulu&lt;/sup&gt; lama-20.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:3&quot;&gt;Sabine Klein. &quot;Meine Musik ist wie ich - sehr romantisch&quot;. Frankfurter Rundschau (iphephandaba le-German), 1992, edition 254, ikhasi 2&lt;/ref&gt; Wafundiswa ipiyano kusukela aneminyaka ebunane begodu ukudlala kwakhe kokuthoma emphakathini kwenzeka nakaneminyaka elitjhumi nane, adlala umvumo kaScott Joplin.&lt;ref name=&quot;:2&quot; /&gt; Nakaneminyakaelitjhumi nesithandathu wamukelwa e-Royal Scottish Academy of Music and Drama (nje ebizwa ngokuthi: Yi-Royal Conservatoire of Scotland) njengomfundi omncani kunabo boke abafunda isikhathi esizeleko.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:3&quot; /&gt;&lt;ref name=&quot;:4&quot;&gt;G. Müller. &quot;Die Seele des Klaviers tanzt Tango&quot;. Kulturspiegel Wetterau (imagazini e-Germany). mhlana ali-17 kuNtaka 2001, ikhasi 5&lt;/ref&gt; Ngo-1983 waphothula e-Glasgow University ngedigri ye-BA yokufundisa ipiyano. Ngomnyaka olandelako wathola idiploma yokuvuma umvumo ngemva kokudlala i-Piano Concerto No.1 ka-Mendelssohn ne-orchestra ye-RSAMD..&lt;ref name=&quot;:3&quot; /&gt;&lt;ref name=&quot;:4&quot; /&gt; Ngemva kokuqeda ifundo ephakemeko bekafunwa khulu njengomdlali wepiyano begodu wahlala e-Edinburgh ngo-1988 -1991.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:5&quot;&gt;&quot;James Peace&quot;. ''FRIZZ'' (imagazini e-Germany). UTjhirhweni 2001, ​​ikhasi 5&lt;/ref&gt;

UJames Peace bekahlala e-Bad Nauheim, e-Germany kusukela ngo-1991 ukuya ngo-2009.&lt;ref&gt;Manfred Merz. &quot;Virtuose, gefühlsbetonte Welt der Romantik&quot;, Wetterauer Zeitung (iphephandaba le-German), mhlana ali-12 kuNobayeni, 1992, ikhasi 19&lt;/ref&gt;&lt;ref&gt;&quot;James Peace&quot;. The Tango Times (Imagazini e-new York). Inomboro ye-edishini: 2002/2003 (39). ikhasi 1 - 5&lt;/ref&gt; Kusukela ngo-1998 wenza isifundo se-tango, wakhiqiza i-CD ''ye-Tango escocés'' yeengoma zakhe zepiyano ezihlohlozelwa yi-tango, begodu ngo-2002 waba lilunga elihloniphekileko le-Victoria College of Music.&lt;ref name=&quot;:3&quot; /&gt;&lt;ref name=&quot;:6&quot;&gt;[https://search.nls.uk/discovery/fulldisplay?vid=44NLS_INST%3A44NLS_VU1&amp;mode=basic&amp;docid=alma99115833839204341&amp;query=any%2Ccontains%2CTango+escoc%C3%A9s&amp;context=L&amp;adaptor=Local+Search+Engine&amp;lang=en&amp;search_scope=MainCatalogue National Library of Scotland. ''Tango escocés'']&lt;/ref&gt;&lt;ref name=&quot;:7&quot;&gt;[https://pad.philharmoniedeparis.fr/pad/doc/ALOES/0795887/tango-escoces-scottish-tango-k-james-peace-comp-piano Philharmonie de Paris. ''Tango escocés'']&lt;/ref&gt;&lt;ref name=&quot;:8&quot;&gt;[https://www.muziekweb.nl/Link/KHX3103/Tango-escoc%C3%A9s de bibliotheek. ''Tango escocés'']&lt;/ref&gt;&lt;ref name=&quot;:9&quot;&gt;&quot;James Peace&quot;. La Cadena (imagazini ese-Netherlands).UNobayeni 2002, ikhasi 26&lt;/ref&gt; Ngomnyaka wona loyo waya emakhonsathini yedwa e-North Germany ngoKhukhulamungu/Sewula begodu waya e-Far East ngoNobayeni, okwaba kudlala kwakhe kokuthoma ''kwe-Tango XVII'' e-Hong Kong.&lt;ref name=&quot;:6&quot; /&gt;&lt;ref name=&quot;:7&quot; /&gt;&lt;ref name=&quot;:8&quot; /&gt;&lt;ref name=&quot;:9&quot; /&gt;&lt;ref&gt;[https://web.archive.org/web/20040806204941/http://www.tangotang.com/discus/messages/13/266.html?1034001060 ''TangoTang'', Hong Kong (香港). Iphepha leendaba, mhlana ali-8 kuNobayeni, 2002]

&lt;/ref&gt;&lt;ref&gt;[https://www.scmp.com/article/393890/james-peace &quot;James Peace&quot;. 南華早報 (Iphephandaba le-Hong Kong). mhlana ali-9 kuNobayeni 2002]&lt;/ref&gt;
[[Isimumathi:James Peace - Idylls Op.4b.webm|thumb|305x305px|James Peace - Idylls Op.4b]]
Eminyakeni elandelako wadlala umbhino khulukhulu eYurobhu. Udlale ama-tango wakhe emadorobheni amakhulu alandelako: e-Amsterdam, e-Athens,&lt;ref&gt;Incwajana yekhonsathi ''{Για σένα Αγγελική}''. Athens, mhlana ama-27 kuMrhayili, 2016&lt;/ref&gt; e-Berlin,&lt;ref&gt;Tangodanza (imagazini e-Germany). Inomboro ye-edishini:: 1/2002 - 9&lt;/ref&gt; e-Brussels, e-Helsinki,&lt;ref&gt;Iphosta yekhonsathi (ikhambo lekhonsathi e-Finland ngo-2014)&lt;/ref&gt; e-Lisbon,&lt;ref name=&quot;:2&quot; /&gt;&lt;ref&gt;Iphosta yekhonsathi (ikhambo lekhonsathi e-Portugal ngo-2016)&lt;/ref&gt; e-London, e-Madrid,&lt;ref name=&quot;:2&quot; /&gt;&lt;ref&gt;Iphosta yekhonsathi (ikhambo lekhonsathi e-Spain: ''¡Feliz Cincuenta Cumpleaños - 2013!'')&lt;/ref&gt; e-Oslo,&lt;ref&gt;[https://web.archive.org/web/20200608114526/https://listen.no/event/konsert-kl-13-00-james-peace-flygel-tangos-romanticos-musikk-av-peace-piazzolla-albeniz-utstillingssalene-er-stengt Listen.no. James Peace (flygel). Munch Museet. Oslo, mhlana ali-16 kuNobayeni, 2004]

&lt;/ref&gt; e-Reykjavik,&lt;ref&gt;[https://www.mbl.is/greinasafn/innskraning/?redirect=%2Fgreinasafn%2Fgrein%2F823608%2F%3Ft%3D686347190&amp;page_name=article&amp;grein_id=823608 Ríkarður Ö. Pálsson. &quot;Skozkir Slaghörputangoár&quot;. Morgunblaðið (iphephandaba e-Iceland). mhlana ali-14 kuNobayeni, 2004]&lt;/ref&gt; kanye ne-Vienna.&lt;ref&gt;Incwajana yekhonsathi (Vienna). Mhlana ama-23 kuTjhirhweni, 2005&lt;/ref&gt;

Ngo-2008 waba lilunga elihlonitjhwako le-London College of Music ngokuthokozwa ngemisebenzi yakhe ku-tango.&lt;ref name=&quot;:10&quot;&gt;[https://search.nls.uk/discovery/fulldisplay?vid=44NLS_INST:44NLS_VU1&amp;mode=basic&amp;tab=default_tab&amp;docid=alma9948049943804341&amp;query=any,contains,K.%20James%20Peace&amp;context=L&amp;adaptor=Local%20Search%20Engine&amp;lang=en National Library of Scotland. ''K. James Peace in Wiesbaden'']&lt;/ref&gt;&lt;ref name=&quot;:11&quot;&gt;[https://portal.dnb.de/opac.htm?method=simpleSearch&amp;cqlMode=true&amp;query=idn%3D1022200380 Deutsche Nationalbibliothek. ''K. James Peace in Wiesbaden'']&lt;/ref&gt;&lt;ref name=&quot;:12&quot;&gt;[https://whittakerlive.blogspot.com/2012/05/new-dvd-interview-with-wiesbaden.html Whittaker Live. &quot;Wiesbadener Highlander K. James Peace - New DVD&quot;]&lt;/ref&gt;

Ngemva kwesikhathi esifitjhani e-Edinburgh wabuyela ngoMhlolanja 2010 e-Germany ukuyokuhlala e-Wiesbaden.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt; Lokhu kwabangela bona abe nemizwa emitjha yokutlama begodu wenza amafilimu amafitjhani wezinye zeengoma zakhe. Ifilimu yedokhumenthari ''i-K. James Peace in Wiesbaden'' ingenye yemisebenzi yakhe emhlobeni lo wombhino.&lt;ref name=&quot;:10&quot; /&gt;&lt;ref name=&quot;:11&quot; /&gt;&lt;ref name=&quot;:12&quot; /&gt;
[[Isimumathi:Tango Milonga op. 26.wav|left|thumb|248x248px|Tango Milonga op. 26]]


[[Isimumathi:Tango XVIII by James Peace (James Peace, piano).wav|left|thumb|Tango XVIII by James Peace (James Peace, piano)]]





== Imitlomelo Nabonongorwana ==
[[Isimumathi:Cover page, Eternal Song Op.32 by James Peace (study score).png|thumb|318x318px|Eternal Song Op.32]]
●     Umtlomelo Wokuthoma, I-Agnes Millar Prize. E-Glasgow, 1983&lt;ref name=&quot;:4&quot; /&gt;

●      Umtlomelo Wokuthoma, I-Dunbartonshire EIS Prize. E-Glasgow, 1984&lt;ref name=&quot;:4&quot; /&gt;

●      Umtlomelo Wokuthoma, I-Sibelius Essay Prize. E-Glasgow, 1985&lt;ref name=&quot;:4&quot; /&gt;

●     Idiploma yokuhlonipha, I-TIM Composition Competition. E-Roma, 2000&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:5&quot; /&gt;

●      Idiploma yokuhlonipha, I-IBLA Foundation. E-New York, 2002&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:5&quot; /&gt;

●     Imedali Yesikhumbuzo, I-International Piano Duo Association. E-Tokyo, 2002&lt;ref&gt;[http://ipda-pianoduo.com/composition-concour-list-english.html International Piano Duo Association (東京), Tokyo. Irhelo labaphumeleleko ngo-2002]&lt;/ref&gt;

●     Imedali yeGolide, I-Académie Internationale de Lutèce. E-Paris, 2008&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;

== Iingoma Eziyihloko ==
[[Isimumathi:Eternal Song Op.32 by James Peace (bars 602 - 606).pdf|thumb|291x291px|Eternal Song Op.32]]
●     IPophoma (I-The Waterfall)&lt;ref&gt;Hessisches Staatstheater. Incwajana yekhonsathi 12 no-19 kuNobayeni, 2021&lt;/ref&gt;

●     Ingoma Yekuseni (I-Aubade)

●     Iinyembezi Ezithulileko (I-Lento Lacrimoso) 

●     Amakari Akhohlwiweko (I-Forgotten Leaves)

●     Isonata Ye-Oboe (I-Sonata for oboe and piano)

●     I-Ballade

●     Imatjhi Yomgidingo no.1 (I-Ceremonial March no.1)

●      Imatjhi Yomgidingo no.2 (I-Ceremonial March no.2)

●     Igolide Lesilimela (I-Autumn Gold)&lt;ref&gt;&quot;Violine schwebt über das Orchester&quot;. Schwäbische Post (iphephandaba le-German). Mhlana ali-4 kuMgwengweni, 1998&lt;/ref&gt;

●     Ingoma Yesiphelani (I-Eternal Song)&lt;ref name=&quot;:0&quot; /&gt;&lt;ref&gt;[https://search.nls.uk/discovery/fulldisplay?docid=alma9935400923804341&amp;context=L&amp;vid=44NLS_INST:44NLS_VU1&amp;lang=en&amp;search_scope=MainCatalogue&amp;adaptor=Local%20Search%20Engine&amp;query=any,contains,James%20peace&amp;mode=basic National Library of Scotland. ''Eternal Song Op.32, Peace, K. James'']&lt;/ref&gt;

●     &quot;Ye-Georgia&quot; (Ngelimi le-Georgia: საქართველოსთვის)

●     24 Yamatango&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:6&quot; /&gt;&lt;ref name=&quot;:7&quot; /&gt;&lt;ref name=&quot;:8&quot; /&gt;&lt;ref name=&quot;:10&quot; /&gt;&lt;ref name=&quot;:11&quot; /&gt;&lt;ref name=&quot;:12&quot; /&gt;&lt;ref&gt;[https://www.britishviolasociety.co.uk/wp-content/uploads/2024/01/Latest-news-from-the-British-Viola-Society.-August-2023-compressed.pdf British Viola Society Newsletter, Agasti, 2023]

&lt;/ref&gt;&lt;ref&gt;[https://web.archive.org/web/20240522135254/https://hojaderutadigital.mx/una-corta-historia-del-tango/ Hoja de Ruta Digital, México. &quot;Una corta historia del tango&quot;, mhlana ali-22 kuNtaka, 2024]

&lt;/ref&gt;&lt;ref&gt;[https://search.nls.uk/discovery/fulldisplay?docid=alma9941547953804341&amp;context=L&amp;vid=44NLS_INST:44NLS_VU1&amp;lang=en&amp;search_scope=MainCatalogue&amp;adaptor=Local%20Search%20Engine&amp;query=any,contains,James%20peace&amp;mode=basic National Library of Scotland. ''Tangos op.33, Peace, K. James'']&lt;/ref&gt;

== Amalinki Wangaphandle ==
[https://www.youtube.com/watch?v=sSX1c8EUukg&amp;list=RDsSX1c8EUukg&amp;start_radio=1 I-Souvenir de Buenos Aires - ''youtube'']

[https://www.youtube.com/watch?v=ZcMRNnwNJhk&amp;list=RDZcMRNnwNJhk&amp;start_radio=1 I-Lento Lacrimoso - ''youtube'']

[https://www.youtube.com/watch?v=_VKxG2dmQn4&amp;list=RD_VKxG2dmQn4&amp;start_radio=1 I-Autumn Gold - ''youtube'']

== Iinkomba ==</text>
      <sha1>gvqqi2jjeanoljzezb1f1fohhataqa3</sha1>
    </revision>
    <revision>
      <id>6148</id>
      <parentid>6147</parentid>
      <timestamp>2026-01-28T02:23:22Z</timestamp>
      <contributor>
        <username>Tata.tata3</username>
        <id>1319</id>
      </contributor>
      <origin>6148</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="10638" sha1="jmek9900y8yzdtqtiuup5x4v90ghrj2" xml:space="preserve">[[Isimumathi:James Peace at home in Wiesbaden3.jpg|thumb|414x414px|James Peace ]]
'''U-Kenneth James Peace''' wabelethelwa e-Paisley, mhla ama-28 kuNobayeni, 1963. Umakhiwombhino we-Scotland, umdlali wepiyano ekhonsathini kanye nomdwebi wezinto ezibonwako.

== Umlando Womuntu ==
UJames Peace wabelethelwa e-Paisley, mhla ama-28 kuNobayeni, 1963. Wakhulela e-Helensburgh, indawo yokuphumula eseduze nelwandle etjingalanga ye-Scotland.&lt;ref name=&quot;:0&quot;&gt;[https://web.archive.org/web/20110527164145/http://www.wiesbadener-tagblatt.de/region/wiesbaden/meldungen/10206548.htm Birgitta Lamparth. &quot;Keine ‘stacheligen’ Klänge&quot;, Wiesbadener Tagblatt (iphephandaba le-German), mhlana ali-10 kuMhlolanja, 2012]

&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;Julia Anderton. &quot;Tango wie eine süß-saure Geschichte&quot;. Wiesbadener Kurier (iphephandaba le-German), mhlana ama-24 kuNtaka, 2012&lt;/ref&gt;&lt;ref name=&quot;:2&quot;&gt;[https://hojaderutadigital.mx/una-entrevista-al-compositor-james-peace/ Soledad Carrizo-Araya. &quot;Una entrevista al compositor James Peace&quot;. Hoja de Ruta Digital. Unobayeni 2022]&lt;/ref&gt; Umndenakhe bewunabavumi abanengi (isib. uJohn McGhie), begodu uhlobana noFelix Burns, umtlami wombhino odumileko womvumo wokudansa engcenyeni yokuthoma &lt;sup&gt;yekhulu&lt;/sup&gt; lama-20.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:3&quot;&gt;Sabine Klein. &quot;Meine Musik ist wie ich - sehr romantisch&quot;. Frankfurter Rundschau (iphephandaba le-German), 1992, edition 254, ikhasi 2&lt;/ref&gt; Wafundiswa ipiyano kusukela aneminyaka ebunane begodu ukudlala kwakhe kokuthoma emphakathini kwenzeka nakaneminyaka elitjhumi nane, adlala umvumo kaScott Joplin.&lt;ref name=&quot;:2&quot; /&gt; Nakaneminyakaelitjhumi nesithandathu wamukelwa e-Royal Scottish Academy of Music and Drama (nje ebizwa ngokuthi: Yi-Royal Conservatoire of Scotland) njengomfundi omncani kunabo boke abafunda isikhathi esizeleko.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:3&quot; /&gt;&lt;ref name=&quot;:4&quot;&gt;G. Müller. &quot;Die Seele des Klaviers tanzt Tango&quot;. Kulturspiegel Wetterau (imagazini e-Germany). mhlana ali-17 kuNtaka 2001, ikhasi 5&lt;/ref&gt; Ngo-1983 waphothula e-Glasgow University ngedigri ye-BA yokufundisa ipiyano. Ngomnyaka olandelako wathola idiploma yokuvuma umvumo ngemva kokudlala i-Piano Concerto No.1 ka-Mendelssohn ne-orchestra ye-RSAMD..&lt;ref name=&quot;:3&quot; /&gt;&lt;ref name=&quot;:4&quot; /&gt; Ngemva kokuqeda ifundo ephakemeko bekafunwa khulu njengomdlali wepiyano begodu wahlala e-Edinburgh ngo-1988 -1991.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:5&quot;&gt;&quot;James Peace&quot;. ''FRIZZ'' (imagazini e-Germany). UTjhirhweni 2001, ​​ikhasi 5&lt;/ref&gt;

UJames Peace bekahlala e-Bad Nauheim, e-Germany kusukela ngo-1991 ukuya ngo-2009.&lt;ref&gt;Manfred Merz. &quot;Virtuose, gefühlsbetonte Welt der Romantik&quot;, Wetterauer Zeitung (iphephandaba le-German), mhlana ali-12 kuNobayeni, 1992, ikhasi 19&lt;/ref&gt;&lt;ref&gt;&quot;James Peace&quot;. The Tango Times (Imagazini e-new York). Inomboro ye-edishini: 2002/2003 (39). ikhasi 1 - 5&lt;/ref&gt; Kusukela ngo-1998 wenza isifundo se-tango, wakhiqiza i-CD ''ye-Tango escocés'' yeengoma zakhe zepiyano ezihlohlozelwa yi-tango, begodu ngo-2002 waba lilunga elihloniphekileko le-Victoria College of Music.&lt;ref name=&quot;:3&quot; /&gt;&lt;ref name=&quot;:6&quot;&gt;[https://search.nls.uk/discovery/fulldisplay?vid=44NLS_INST%3A44NLS_VU1&amp;mode=basic&amp;docid=alma99115833839204341&amp;query=any%2Ccontains%2CTango+escoc%C3%A9s&amp;context=L&amp;adaptor=Local+Search+Engine&amp;lang=en&amp;search_scope=MainCatalogue National Library of Scotland. ''Tango escocés'']&lt;/ref&gt;&lt;ref name=&quot;:7&quot;&gt;[https://pad.philharmoniedeparis.fr/pad/doc/ALOES/0795887/tango-escoces-scottish-tango-k-james-peace-comp-piano Philharmonie de Paris. ''Tango escocés'']&lt;/ref&gt;&lt;ref name=&quot;:8&quot;&gt;[https://www.muziekweb.nl/Link/KHX3103/Tango-escoc%C3%A9s de bibliotheek. ''Tango escocés'']&lt;/ref&gt;&lt;ref name=&quot;:9&quot;&gt;&quot;James Peace&quot;. La Cadena (imagazini ese-Netherlands).UNobayeni 2002, ikhasi 26&lt;/ref&gt; Ngomnyaka wona loyo waya emakhonsathini yedwa e-North Germany ngoKhukhulamungu/Sewula begodu waya e-Far East ngoNobayeni, okwaba kudlala kwakhe kokuthoma ''kwe-Tango XVII'' e-Hong Kong.&lt;ref name=&quot;:6&quot; /&gt;&lt;ref name=&quot;:7&quot; /&gt;&lt;ref name=&quot;:8&quot; /&gt;&lt;ref name=&quot;:9&quot; /&gt;&lt;ref&gt;[https://web.archive.org/web/20040806204941/http://www.tangotang.com/discus/messages/13/266.html?1034001060 ''TangoTang'', Hong Kong (香港). Iphepha leendaba, mhlana ali-8 kuNobayeni, 2002]

&lt;/ref&gt;&lt;ref&gt;[https://www.scmp.com/article/393890/james-peace &quot;James Peace&quot;. 南華早報 (Iphephandaba le-Hong Kong). mhlana ali-9 kuNobayeni 2002]&lt;/ref&gt;
[[Isimumathi:James Peace - Idylls Op.4b.webm|thumb|341x341px|James Peace - Idylls Op.4b]]
Eminyakeni elandelako wadlala umbhino khulukhulu eYurobhu. Udlale ama-tango wakhe emadorobheni amakhulu alandelako: e-Amsterdam, e-Athens,&lt;ref&gt;Incwajana yekhonsathi ''{Για σένα Αγγελική}''. Athens, mhlana ama-27 kuMrhayili, 2016&lt;/ref&gt; e-Berlin,&lt;ref&gt;Tangodanza (imagazini e-Germany). Inomboro ye-edishini:: 1/2002 - 9&lt;/ref&gt; e-Brussels, e-Helsinki,&lt;ref&gt;Iphosta yekhonsathi (ikhambo lekhonsathi e-Finland ngo-2014)&lt;/ref&gt; e-Lisbon,&lt;ref name=&quot;:2&quot; /&gt;&lt;ref&gt;Iphosta yekhonsathi (ikhambo lekhonsathi e-Portugal ngo-2016)&lt;/ref&gt; e-London, e-Madrid,&lt;ref name=&quot;:2&quot; /&gt;&lt;ref&gt;Iphosta yekhonsathi (ikhambo lekhonsathi e-Spain: ''¡Feliz Cincuenta Cumpleaños - 2013!'')&lt;/ref&gt; e-Oslo,&lt;ref&gt;[https://web.archive.org/web/20200608114526/https://listen.no/event/konsert-kl-13-00-james-peace-flygel-tangos-romanticos-musikk-av-peace-piazzolla-albeniz-utstillingssalene-er-stengt Listen.no. James Peace (flygel). Munch Museet. Oslo, mhlana ali-16 kuNobayeni, 2004]

&lt;/ref&gt; e-Reykjavik,&lt;ref&gt;[https://www.mbl.is/greinasafn/innskraning/?redirect=%2Fgreinasafn%2Fgrein%2F823608%2F%3Ft%3D686347190&amp;page_name=article&amp;grein_id=823608 Ríkarður Ö. Pálsson. &quot;Skozkir Slaghörputangoár&quot;. Morgunblaðið (iphephandaba e-Iceland). mhlana ali-14 kuNobayeni, 2004]&lt;/ref&gt; kanye ne-Vienna.&lt;ref&gt;Incwajana yekhonsathi (Vienna). Mhlana ama-23 kuTjhirhweni, 2005&lt;/ref&gt;

Ngo-2008 waba lilunga elihlonitjhwako le-London College of Music ngokuthokozwa ngemisebenzi yakhe ku-tango.&lt;ref name=&quot;:10&quot;&gt;[https://search.nls.uk/discovery/fulldisplay?vid=44NLS_INST:44NLS_VU1&amp;mode=basic&amp;tab=default_tab&amp;docid=alma9948049943804341&amp;query=any,contains,K.%20James%20Peace&amp;context=L&amp;adaptor=Local%20Search%20Engine&amp;lang=en National Library of Scotland. ''K. James Peace in Wiesbaden'']&lt;/ref&gt;&lt;ref name=&quot;:11&quot;&gt;[https://portal.dnb.de/opac.htm?method=simpleSearch&amp;cqlMode=true&amp;query=idn%3D1022200380 Deutsche Nationalbibliothek. ''K. James Peace in Wiesbaden'']&lt;/ref&gt;&lt;ref name=&quot;:12&quot;&gt;[https://whittakerlive.blogspot.com/2012/05/new-dvd-interview-with-wiesbaden.html Whittaker Live. &quot;Wiesbadener Highlander K. James Peace - New DVD&quot;]&lt;/ref&gt;

Ngemva kwesikhathi esifitjhani e-Edinburgh wabuyela ngoMhlolanja 2010 e-Germany ukuyokuhlala e-Wiesbaden.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt; Lokhu kwabangela bona abe nemizwa emitjha yokutlama begodu wenza amafilimu amafitjhani wezinye zeengoma zakhe. Ifilimu yedokhumenthari ''i-K. James Peace in Wiesbaden'' ingenye yemisebenzi yakhe emhlobeni lo wombhino.&lt;ref name=&quot;:10&quot; /&gt;&lt;ref name=&quot;:11&quot; /&gt;&lt;ref name=&quot;:12&quot; /&gt;
[[Isimumathi:Tango Milonga op. 26.wav|left|thumb|248x248px|Tango Milonga op. 26]]


[[Isimumathi:Tango XVIII by James Peace (James Peace, piano).wav|left|thumb|Tango XVIII by James Peace (James Peace, piano)]]




== Imitlomelo Nabonongorwana ==
[[Isimumathi:Cover page, Eternal Song Op.32 by James Peace (study score).png|thumb|318x318px|Eternal Song Op.32]]
●     Umtlomelo Wokuthoma, I-Agnes Millar Prize. E-Glasgow, 1983&lt;ref name=&quot;:4&quot; /&gt;

●      Umtlomelo Wokuthoma, I-Dunbartonshire EIS Prize. E-Glasgow, 1984&lt;ref name=&quot;:4&quot; /&gt;

●      Umtlomelo Wokuthoma, I-Sibelius Essay Prize. E-Glasgow, 1985&lt;ref name=&quot;:4&quot; /&gt;

●     Idiploma yokuhlonipha, I-TIM Composition Competition. E-Roma, 2000&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:5&quot; /&gt;

●      Idiploma yokuhlonipha, I-IBLA Foundation. E-New York, 2002&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:5&quot; /&gt;

●     Imedali Yesikhumbuzo, I-International Piano Duo Association. E-Tokyo, 2002&lt;ref&gt;[http://ipda-pianoduo.com/composition-concour-list-english.html International Piano Duo Association (東京), Tokyo. Irhelo labaphumeleleko ngo-2002]&lt;/ref&gt;

●     Imedali yeGolide, I-Académie Internationale de Lutèce. E-Paris, 2008&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;

== Iingoma Eziyihloko ==
[[Isimumathi:Eternal Song Op.32 by James Peace (bars 602 - 606).pdf|thumb|291x291px|Eternal Song Op.32]]
●     IPophoma (I-The Waterfall)&lt;ref&gt;Hessisches Staatstheater. Incwajana yekhonsathi 12 no-19 kuNobayeni, 2021&lt;/ref&gt;

●     Ingoma Yekuseni (I-Aubade)

●     Iinyembezi Ezithulileko (I-Lento Lacrimoso) 

●     Amakari Akhohlwiweko (I-Forgotten Leaves)

●     Isonata Ye-Oboe (I-Sonata for oboe and piano)

●     I-Ballade

●     Imatjhi Yomgidingo no.1 (I-Ceremonial March no.1)

●      Imatjhi Yomgidingo no.2 (I-Ceremonial March no.2)

●     Igolide Lesilimela (I-Autumn Gold)&lt;ref&gt;&quot;Violine schwebt über das Orchester&quot;. Schwäbische Post (iphephandaba le-German). Mhlana ali-4 kuMgwengweni, 1998&lt;/ref&gt;

●     Ingoma Yesiphelani (I-Eternal Song)&lt;ref name=&quot;:0&quot; /&gt;&lt;ref&gt;[https://search.nls.uk/discovery/fulldisplay?docid=alma9935400923804341&amp;context=L&amp;vid=44NLS_INST:44NLS_VU1&amp;lang=en&amp;search_scope=MainCatalogue&amp;adaptor=Local%20Search%20Engine&amp;query=any,contains,James%20peace&amp;mode=basic National Library of Scotland. ''Eternal Song Op.32, Peace, K. James'']&lt;/ref&gt;

●     &quot;Ye-Georgia&quot; (Ngelimi le-Georgia: საქართველოსთვის)

●     24 Yamatango&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:6&quot; /&gt;&lt;ref name=&quot;:7&quot; /&gt;&lt;ref name=&quot;:8&quot; /&gt;&lt;ref name=&quot;:10&quot; /&gt;&lt;ref name=&quot;:11&quot; /&gt;&lt;ref name=&quot;:12&quot; /&gt;&lt;ref&gt;[https://www.britishviolasociety.co.uk/wp-content/uploads/2024/01/Latest-news-from-the-British-Viola-Society.-August-2023-compressed.pdf British Viola Society Newsletter, Agasti, 2023]

&lt;/ref&gt;&lt;ref&gt;[https://web.archive.org/web/20240522135254/https://hojaderutadigital.mx/una-corta-historia-del-tango/ Hoja de Ruta Digital, México. &quot;Una corta historia del tango&quot;, mhlana ali-22 kuNtaka, 2024]

&lt;/ref&gt;&lt;ref&gt;[https://search.nls.uk/discovery/fulldisplay?docid=alma9941547953804341&amp;context=L&amp;vid=44NLS_INST:44NLS_VU1&amp;lang=en&amp;search_scope=MainCatalogue&amp;adaptor=Local%20Search%20Engine&amp;query=any,contains,James%20peace&amp;mode=basic National Library of Scotland. ''Tangos op.33, Peace, K. James'']&lt;/ref&gt;

== Amalinki Wangaphandle ==
[https://www.youtube.com/watch?v=sSX1c8EUukg&amp;list=RDsSX1c8EUukg&amp;start_radio=1 I-Souvenir de Buenos Aires - ''youtube'']

[https://www.youtube.com/watch?v=ZcMRNnwNJhk&amp;list=RDZcMRNnwNJhk&amp;start_radio=1 I-Lento Lacrimoso - ''youtube'']

[https://www.youtube.com/watch?v=_VKxG2dmQn4&amp;list=RD_VKxG2dmQn4&amp;start_radio=1 I-Autumn Gold - ''youtube'']

== Iinkomba ==</text>
      <sha1>jmek9900y8yzdtqtiuup5x4v90ghrj2</sha1>
    </revision>
    <revision>
      <id>6149</id>
      <parentid>6148</parentid>
      <timestamp>2026-01-28T02:24:01Z</timestamp>
      <contributor>
        <username>Tata.tata3</username>
        <id>1319</id>
      </contributor>
      <origin>6149</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="10642" sha1="s7qjgwvfyjk7vwogartg5zdc3d4zym4" xml:space="preserve">[[Isimumathi:James Peace at home in Wiesbaden3.jpg|thumb|447x447px|James Peace ]]
'''U-Kenneth James Peace''' wabelethelwa e-Paisley, mhla ama-28 kuNobayeni, 1963. Umakhiwombhino we-Scotland, umdlali wepiyano ekhonsathini kanye nomdwebi wezinto ezibonwako.

== Umlando Womuntu ==
UJames Peace wabelethelwa e-Paisley, mhla ama-28 kuNobayeni, 1963. Wakhulela e-Helensburgh, indawo yokuphumula eseduze nelwandle etjingalanga ye-Scotland.&lt;ref name=&quot;:0&quot;&gt;[https://web.archive.org/web/20110527164145/http://www.wiesbadener-tagblatt.de/region/wiesbaden/meldungen/10206548.htm Birgitta Lamparth. &quot;Keine ‘stacheligen’ Klänge&quot;, Wiesbadener Tagblatt (iphephandaba le-German), mhlana ali-10 kuMhlolanja, 2012]

&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;Julia Anderton. &quot;Tango wie eine süß-saure Geschichte&quot;. Wiesbadener Kurier (iphephandaba le-German), mhlana ama-24 kuNtaka, 2012&lt;/ref&gt;&lt;ref name=&quot;:2&quot;&gt;[https://hojaderutadigital.mx/una-entrevista-al-compositor-james-peace/ Soledad Carrizo-Araya. &quot;Una entrevista al compositor James Peace&quot;. Hoja de Ruta Digital. Unobayeni 2022]&lt;/ref&gt; Umndenakhe bewunabavumi abanengi (isib. uJohn McGhie), begodu uhlobana noFelix Burns, umtlami wombhino odumileko womvumo wokudansa engcenyeni yokuthoma &lt;sup&gt;yekhulu&lt;/sup&gt; lama-20.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:3&quot;&gt;Sabine Klein. &quot;Meine Musik ist wie ich - sehr romantisch&quot;. Frankfurter Rundschau (iphephandaba le-German), 1992, edition 254, ikhasi 2&lt;/ref&gt; Wafundiswa ipiyano kusukela aneminyaka ebunane begodu ukudlala kwakhe kokuthoma emphakathini kwenzeka nakaneminyaka elitjhumi nane, adlala umvumo kaScott Joplin.&lt;ref name=&quot;:2&quot; /&gt; Nakaneminyakaelitjhumi nesithandathu wamukelwa e-Royal Scottish Academy of Music and Drama (nje ebizwa ngokuthi: Yi-Royal Conservatoire of Scotland) njengomfundi omncani kunabo boke abafunda isikhathi esizeleko.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:3&quot; /&gt;&lt;ref name=&quot;:4&quot;&gt;G. Müller. &quot;Die Seele des Klaviers tanzt Tango&quot;. Kulturspiegel Wetterau (imagazini e-Germany). mhlana ali-17 kuNtaka 2001, ikhasi 5&lt;/ref&gt; Ngo-1983 waphothula e-Glasgow University ngedigri ye-BA yokufundisa ipiyano. Ngomnyaka olandelako wathola idiploma yokuvuma umvumo ngemva kokudlala i-Piano Concerto No.1 ka-Mendelssohn ne-orchestra ye-RSAMD..&lt;ref name=&quot;:3&quot; /&gt;&lt;ref name=&quot;:4&quot; /&gt; Ngemva kokuqeda ifundo ephakemeko bekafunwa khulu njengomdlali wepiyano begodu wahlala e-Edinburgh ngo-1988 -1991.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:5&quot;&gt;&quot;James Peace&quot;. ''FRIZZ'' (imagazini e-Germany). UTjhirhweni 2001, ​​ikhasi 5&lt;/ref&gt;

UJames Peace bekahlala e-Bad Nauheim, e-Germany kusukela ngo-1991 ukuya ngo-2009.&lt;ref&gt;Manfred Merz. &quot;Virtuose, gefühlsbetonte Welt der Romantik&quot;, Wetterauer Zeitung (iphephandaba le-German), mhlana ali-12 kuNobayeni, 1992, ikhasi 19&lt;/ref&gt;&lt;ref&gt;&quot;James Peace&quot;. The Tango Times (Imagazini e-new York). Inomboro ye-edishini: 2002/2003 (39). ikhasi 1 - 5&lt;/ref&gt; Kusukela ngo-1998 wenza isifundo se-tango, wakhiqiza i-CD ''ye-Tango escocés'' yeengoma zakhe zepiyano ezihlohlozelwa yi-tango, begodu ngo-2002 waba lilunga elihloniphekileko le-Victoria College of Music.&lt;ref name=&quot;:3&quot; /&gt;&lt;ref name=&quot;:6&quot;&gt;[https://search.nls.uk/discovery/fulldisplay?vid=44NLS_INST%3A44NLS_VU1&amp;mode=basic&amp;docid=alma99115833839204341&amp;query=any%2Ccontains%2CTango+escoc%C3%A9s&amp;context=L&amp;adaptor=Local+Search+Engine&amp;lang=en&amp;search_scope=MainCatalogue National Library of Scotland. ''Tango escocés'']&lt;/ref&gt;&lt;ref name=&quot;:7&quot;&gt;[https://pad.philharmoniedeparis.fr/pad/doc/ALOES/0795887/tango-escoces-scottish-tango-k-james-peace-comp-piano Philharmonie de Paris. ''Tango escocés'']&lt;/ref&gt;&lt;ref name=&quot;:8&quot;&gt;[https://www.muziekweb.nl/Link/KHX3103/Tango-escoc%C3%A9s de bibliotheek. ''Tango escocés'']&lt;/ref&gt;&lt;ref name=&quot;:9&quot;&gt;&quot;James Peace&quot;. La Cadena (imagazini ese-Netherlands).UNobayeni 2002, ikhasi 26&lt;/ref&gt; Ngomnyaka wona loyo waya emakhonsathini yedwa e-North Germany ngoKhukhulamungu/Sewula begodu waya e-Far East ngoNobayeni, okwaba kudlala kwakhe kokuthoma ''kwe-Tango XVII'' e-Hong Kong.&lt;ref name=&quot;:6&quot; /&gt;&lt;ref name=&quot;:7&quot; /&gt;&lt;ref name=&quot;:8&quot; /&gt;&lt;ref name=&quot;:9&quot; /&gt;&lt;ref&gt;[https://web.archive.org/web/20040806204941/http://www.tangotang.com/discus/messages/13/266.html?1034001060 ''TangoTang'', Hong Kong (香港). Iphepha leendaba, mhlana ali-8 kuNobayeni, 2002]

&lt;/ref&gt;&lt;ref&gt;[https://www.scmp.com/article/393890/james-peace &quot;James Peace&quot;. 南華早報 (Iphephandaba le-Hong Kong). mhlana ali-9 kuNobayeni 2002]&lt;/ref&gt;
[[Isimumathi:James Peace - Idylls Op.4b.webm|thumb|341x341px|James Peace - Idylls Op.4b]]
Eminyakeni elandelako wadlala umbhino khulukhulu eYurobhu. Udlale ama-tango wakhe emadorobheni amakhulu alandelako: e-Amsterdam, e-Athens,&lt;ref&gt;Incwajana yekhonsathi ''{Για σένα Αγγελική}''. Athens, mhlana ama-27 kuMrhayili, 2016&lt;/ref&gt; e-Berlin,&lt;ref&gt;Tangodanza (imagazini e-Germany). Inomboro ye-edishini:: 1/2002 - 9&lt;/ref&gt; e-Brussels, e-Helsinki,&lt;ref&gt;Iphosta yekhonsathi (ikhambo lekhonsathi e-Finland ngo-2014)&lt;/ref&gt; e-Lisbon,&lt;ref name=&quot;:2&quot; /&gt;&lt;ref&gt;Iphosta yekhonsathi (ikhambo lekhonsathi e-Portugal ngo-2016)&lt;/ref&gt; e-London, e-Madrid,&lt;ref name=&quot;:2&quot; /&gt;&lt;ref&gt;Iphosta yekhonsathi (ikhambo lekhonsathi e-Spain: ''¡Feliz Cincuenta Cumpleaños - 2013!'')&lt;/ref&gt; e-Oslo,&lt;ref&gt;[https://web.archive.org/web/20200608114526/https://listen.no/event/konsert-kl-13-00-james-peace-flygel-tangos-romanticos-musikk-av-peace-piazzolla-albeniz-utstillingssalene-er-stengt Listen.no. James Peace (flygel). Munch Museet. Oslo, mhlana ali-16 kuNobayeni, 2004]

&lt;/ref&gt; e-Reykjavik,&lt;ref&gt;[https://www.mbl.is/greinasafn/innskraning/?redirect=%2Fgreinasafn%2Fgrein%2F823608%2F%3Ft%3D686347190&amp;page_name=article&amp;grein_id=823608 Ríkarður Ö. Pálsson. &quot;Skozkir Slaghörputangoár&quot;. Morgunblaðið (iphephandaba e-Iceland). mhlana ali-14 kuNobayeni, 2004]&lt;/ref&gt; kanye ne-Vienna.&lt;ref&gt;Incwajana yekhonsathi (Vienna). Mhlana ama-23 kuTjhirhweni, 2005&lt;/ref&gt;

Ngo-2008 waba lilunga elihlonitjhwako le-London College of Music ngokuthokozwa ngemisebenzi yakhe ku-tango.&lt;ref name=&quot;:10&quot;&gt;[https://search.nls.uk/discovery/fulldisplay?vid=44NLS_INST:44NLS_VU1&amp;mode=basic&amp;tab=default_tab&amp;docid=alma9948049943804341&amp;query=any,contains,K.%20James%20Peace&amp;context=L&amp;adaptor=Local%20Search%20Engine&amp;lang=en National Library of Scotland. ''K. James Peace in Wiesbaden'']&lt;/ref&gt;&lt;ref name=&quot;:11&quot;&gt;[https://portal.dnb.de/opac.htm?method=simpleSearch&amp;cqlMode=true&amp;query=idn%3D1022200380 Deutsche Nationalbibliothek. ''K. James Peace in Wiesbaden'']&lt;/ref&gt;&lt;ref name=&quot;:12&quot;&gt;[https://whittakerlive.blogspot.com/2012/05/new-dvd-interview-with-wiesbaden.html Whittaker Live. &quot;Wiesbadener Highlander K. James Peace - New DVD&quot;]&lt;/ref&gt;

Ngemva kwesikhathi esifitjhani e-Edinburgh wabuyela ngoMhlolanja 2010 e-Germany ukuyokuhlala e-Wiesbaden.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt; Lokhu kwabangela bona abe nemizwa emitjha yokutlama begodu wenza amafilimu amafitjhani wezinye zeengoma zakhe. Ifilimu yedokhumenthari ''i-K. James Peace in Wiesbaden'' ingenye yemisebenzi yakhe emhlobeni lo wombhino.&lt;ref name=&quot;:10&quot; /&gt;&lt;ref name=&quot;:11&quot; /&gt;&lt;ref name=&quot;:12&quot; /&gt;
[[Isimumathi:Tango Milonga op. 26.wav|thumb|248x248px|Tango Milonga op. 26|center]]


[[Isimumathi:Tango XVIII by James Peace (James Peace, piano).wav|thumb|Tango XVIII by James Peace (James Peace, piano)|center]]




== Imitlomelo Nabonongorwana ==
[[Isimumathi:Cover page, Eternal Song Op.32 by James Peace (study score).png|thumb|318x318px|Eternal Song Op.32]]
●     Umtlomelo Wokuthoma, I-Agnes Millar Prize. E-Glasgow, 1983&lt;ref name=&quot;:4&quot; /&gt;

●      Umtlomelo Wokuthoma, I-Dunbartonshire EIS Prize. E-Glasgow, 1984&lt;ref name=&quot;:4&quot; /&gt;

●      Umtlomelo Wokuthoma, I-Sibelius Essay Prize. E-Glasgow, 1985&lt;ref name=&quot;:4&quot; /&gt;

●     Idiploma yokuhlonipha, I-TIM Composition Competition. E-Roma, 2000&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:5&quot; /&gt;

●      Idiploma yokuhlonipha, I-IBLA Foundation. E-New York, 2002&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:5&quot; /&gt;

●     Imedali Yesikhumbuzo, I-International Piano Duo Association. E-Tokyo, 2002&lt;ref&gt;[http://ipda-pianoduo.com/composition-concour-list-english.html International Piano Duo Association (東京), Tokyo. Irhelo labaphumeleleko ngo-2002]&lt;/ref&gt;

●     Imedali yeGolide, I-Académie Internationale de Lutèce. E-Paris, 2008&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;

== Iingoma Eziyihloko ==
[[Isimumathi:Eternal Song Op.32 by James Peace (bars 602 - 606).pdf|thumb|291x291px|Eternal Song Op.32]]
●     IPophoma (I-The Waterfall)&lt;ref&gt;Hessisches Staatstheater. Incwajana yekhonsathi 12 no-19 kuNobayeni, 2021&lt;/ref&gt;

●     Ingoma Yekuseni (I-Aubade)

●     Iinyembezi Ezithulileko (I-Lento Lacrimoso) 

●     Amakari Akhohlwiweko (I-Forgotten Leaves)

●     Isonata Ye-Oboe (I-Sonata for oboe and piano)

●     I-Ballade

●     Imatjhi Yomgidingo no.1 (I-Ceremonial March no.1)

●      Imatjhi Yomgidingo no.2 (I-Ceremonial March no.2)

●     Igolide Lesilimela (I-Autumn Gold)&lt;ref&gt;&quot;Violine schwebt über das Orchester&quot;. Schwäbische Post (iphephandaba le-German). Mhlana ali-4 kuMgwengweni, 1998&lt;/ref&gt;

●     Ingoma Yesiphelani (I-Eternal Song)&lt;ref name=&quot;:0&quot; /&gt;&lt;ref&gt;[https://search.nls.uk/discovery/fulldisplay?docid=alma9935400923804341&amp;context=L&amp;vid=44NLS_INST:44NLS_VU1&amp;lang=en&amp;search_scope=MainCatalogue&amp;adaptor=Local%20Search%20Engine&amp;query=any,contains,James%20peace&amp;mode=basic National Library of Scotland. ''Eternal Song Op.32, Peace, K. James'']&lt;/ref&gt;

●     &quot;Ye-Georgia&quot; (Ngelimi le-Georgia: საქართველოსთვის)

●     24 Yamatango&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:6&quot; /&gt;&lt;ref name=&quot;:7&quot; /&gt;&lt;ref name=&quot;:8&quot; /&gt;&lt;ref name=&quot;:10&quot; /&gt;&lt;ref name=&quot;:11&quot; /&gt;&lt;ref name=&quot;:12&quot; /&gt;&lt;ref&gt;[https://www.britishviolasociety.co.uk/wp-content/uploads/2024/01/Latest-news-from-the-British-Viola-Society.-August-2023-compressed.pdf British Viola Society Newsletter, Agasti, 2023]

&lt;/ref&gt;&lt;ref&gt;[https://web.archive.org/web/20240522135254/https://hojaderutadigital.mx/una-corta-historia-del-tango/ Hoja de Ruta Digital, México. &quot;Una corta historia del tango&quot;, mhlana ali-22 kuNtaka, 2024]

&lt;/ref&gt;&lt;ref&gt;[https://search.nls.uk/discovery/fulldisplay?docid=alma9941547953804341&amp;context=L&amp;vid=44NLS_INST:44NLS_VU1&amp;lang=en&amp;search_scope=MainCatalogue&amp;adaptor=Local%20Search%20Engine&amp;query=any,contains,James%20peace&amp;mode=basic National Library of Scotland. ''Tangos op.33, Peace, K. James'']&lt;/ref&gt;

== Amalinki Wangaphandle ==
[https://www.youtube.com/watch?v=sSX1c8EUukg&amp;list=RDsSX1c8EUukg&amp;start_radio=1 I-Souvenir de Buenos Aires - ''youtube'']

[https://www.youtube.com/watch?v=ZcMRNnwNJhk&amp;list=RDZcMRNnwNJhk&amp;start_radio=1 I-Lento Lacrimoso - ''youtube'']

[https://www.youtube.com/watch?v=_VKxG2dmQn4&amp;list=RD_VKxG2dmQn4&amp;start_radio=1 I-Autumn Gold - ''youtube'']

== Iinkomba ==</text>
      <sha1>s7qjgwvfyjk7vwogartg5zdc3d4zym4</sha1>
    </revision>
    <revision>
      <id>6150</id>
      <parentid>6149</parentid>
      <timestamp>2026-01-28T02:24:21Z</timestamp>
      <contributor>
        <username>Tata.tata3</username>
        <id>1319</id>
      </contributor>
      <origin>6150</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="10641" sha1="7oe1r9ql8gxfqa6wj5nqp3yt7azegle" xml:space="preserve">[[Isimumathi:James Peace at home in Wiesbaden3.jpg|thumb|447x447px|James Peace ]]
'''U-Kenneth James Peace''' wabelethelwa e-Paisley, mhla ama-28 kuNobayeni, 1963. Umakhiwombhino we-Scotland, umdlali wepiyano ekhonsathini kanye nomdwebi wezinto ezibonwako.

== Umlando Womuntu ==
UJames Peace wabelethelwa e-Paisley, mhla ama-28 kuNobayeni, 1963. Wakhulela e-Helensburgh, indawo yokuphumula eseduze nelwandle etjingalanga ye-Scotland.&lt;ref name=&quot;:0&quot;&gt;[https://web.archive.org/web/20110527164145/http://www.wiesbadener-tagblatt.de/region/wiesbaden/meldungen/10206548.htm Birgitta Lamparth. &quot;Keine ‘stacheligen’ Klänge&quot;, Wiesbadener Tagblatt (iphephandaba le-German), mhlana ali-10 kuMhlolanja, 2012]

&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;Julia Anderton. &quot;Tango wie eine süß-saure Geschichte&quot;. Wiesbadener Kurier (iphephandaba le-German), mhlana ama-24 kuNtaka, 2012&lt;/ref&gt;&lt;ref name=&quot;:2&quot;&gt;[https://hojaderutadigital.mx/una-entrevista-al-compositor-james-peace/ Soledad Carrizo-Araya. &quot;Una entrevista al compositor James Peace&quot;. Hoja de Ruta Digital. Unobayeni 2022]&lt;/ref&gt; Umndenakhe bewunabavumi abanengi (isib. uJohn McGhie), begodu uhlobana noFelix Burns, umtlami wombhino odumileko womvumo wokudansa engcenyeni yokuthoma &lt;sup&gt;yekhulu&lt;/sup&gt; lama-20.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:3&quot;&gt;Sabine Klein. &quot;Meine Musik ist wie ich - sehr romantisch&quot;. Frankfurter Rundschau (iphephandaba le-German), 1992, edition 254, ikhasi 2&lt;/ref&gt; Wafundiswa ipiyano kusukela aneminyaka ebunane begodu ukudlala kwakhe kokuthoma emphakathini kwenzeka nakaneminyaka elitjhumi nane, adlala umvumo kaScott Joplin.&lt;ref name=&quot;:2&quot; /&gt; Nakaneminyakaelitjhumi nesithandathu wamukelwa e-Royal Scottish Academy of Music and Drama (nje ebizwa ngokuthi: Yi-Royal Conservatoire of Scotland) njengomfundi omncani kunabo boke abafunda isikhathi esizeleko.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:3&quot; /&gt;&lt;ref name=&quot;:4&quot;&gt;G. Müller. &quot;Die Seele des Klaviers tanzt Tango&quot;. Kulturspiegel Wetterau (imagazini e-Germany). mhlana ali-17 kuNtaka 2001, ikhasi 5&lt;/ref&gt; Ngo-1983 waphothula e-Glasgow University ngedigri ye-BA yokufundisa ipiyano. Ngomnyaka olandelako wathola idiploma yokuvuma umvumo ngemva kokudlala i-Piano Concerto No.1 ka-Mendelssohn ne-orchestra ye-RSAMD..&lt;ref name=&quot;:3&quot; /&gt;&lt;ref name=&quot;:4&quot; /&gt; Ngemva kokuqeda ifundo ephakemeko bekafunwa khulu njengomdlali wepiyano begodu wahlala e-Edinburgh ngo-1988 -1991.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:5&quot;&gt;&quot;James Peace&quot;. ''FRIZZ'' (imagazini e-Germany). UTjhirhweni 2001, ​​ikhasi 5&lt;/ref&gt;

UJames Peace bekahlala e-Bad Nauheim, e-Germany kusukela ngo-1991 ukuya ngo-2009.&lt;ref&gt;Manfred Merz. &quot;Virtuose, gefühlsbetonte Welt der Romantik&quot;, Wetterauer Zeitung (iphephandaba le-German), mhlana ali-12 kuNobayeni, 1992, ikhasi 19&lt;/ref&gt;&lt;ref&gt;&quot;James Peace&quot;. The Tango Times (Imagazini e-new York). Inomboro ye-edishini: 2002/2003 (39). ikhasi 1 - 5&lt;/ref&gt; Kusukela ngo-1998 wenza isifundo se-tango, wakhiqiza i-CD ''ye-Tango escocés'' yeengoma zakhe zepiyano ezihlohlozelwa yi-tango, begodu ngo-2002 waba lilunga elihloniphekileko le-Victoria College of Music.&lt;ref name=&quot;:3&quot; /&gt;&lt;ref name=&quot;:6&quot;&gt;[https://search.nls.uk/discovery/fulldisplay?vid=44NLS_INST%3A44NLS_VU1&amp;mode=basic&amp;docid=alma99115833839204341&amp;query=any%2Ccontains%2CTango+escoc%C3%A9s&amp;context=L&amp;adaptor=Local+Search+Engine&amp;lang=en&amp;search_scope=MainCatalogue National Library of Scotland. ''Tango escocés'']&lt;/ref&gt;&lt;ref name=&quot;:7&quot;&gt;[https://pad.philharmoniedeparis.fr/pad/doc/ALOES/0795887/tango-escoces-scottish-tango-k-james-peace-comp-piano Philharmonie de Paris. ''Tango escocés'']&lt;/ref&gt;&lt;ref name=&quot;:8&quot;&gt;[https://www.muziekweb.nl/Link/KHX3103/Tango-escoc%C3%A9s de bibliotheek. ''Tango escocés'']&lt;/ref&gt;&lt;ref name=&quot;:9&quot;&gt;&quot;James Peace&quot;. La Cadena (imagazini ese-Netherlands).UNobayeni 2002, ikhasi 26&lt;/ref&gt; Ngomnyaka wona loyo waya emakhonsathini yedwa e-North Germany ngoKhukhulamungu/Sewula begodu waya e-Far East ngoNobayeni, okwaba kudlala kwakhe kokuthoma ''kwe-Tango XVII'' e-Hong Kong.&lt;ref name=&quot;:6&quot; /&gt;&lt;ref name=&quot;:7&quot; /&gt;&lt;ref name=&quot;:8&quot; /&gt;&lt;ref name=&quot;:9&quot; /&gt;&lt;ref&gt;[https://web.archive.org/web/20040806204941/http://www.tangotang.com/discus/messages/13/266.html?1034001060 ''TangoTang'', Hong Kong (香港). Iphepha leendaba, mhlana ali-8 kuNobayeni, 2002]

&lt;/ref&gt;&lt;ref&gt;[https://www.scmp.com/article/393890/james-peace &quot;James Peace&quot;. 南華早報 (Iphephandaba le-Hong Kong). mhlana ali-9 kuNobayeni 2002]&lt;/ref&gt;
[[Isimumathi:James Peace - Idylls Op.4b.webm|thumb|341x341px|James Peace - Idylls Op.4b]]
Eminyakeni elandelako wadlala umbhino khulukhulu eYurobhu. Udlale ama-tango wakhe emadorobheni amakhulu alandelako: e-Amsterdam, e-Athens,&lt;ref&gt;Incwajana yekhonsathi ''{Για σένα Αγγελική}''. Athens, mhlana ama-27 kuMrhayili, 2016&lt;/ref&gt; e-Berlin,&lt;ref&gt;Tangodanza (imagazini e-Germany). Inomboro ye-edishini:: 1/2002 - 9&lt;/ref&gt; e-Brussels, e-Helsinki,&lt;ref&gt;Iphosta yekhonsathi (ikhambo lekhonsathi e-Finland ngo-2014)&lt;/ref&gt; e-Lisbon,&lt;ref name=&quot;:2&quot; /&gt;&lt;ref&gt;Iphosta yekhonsathi (ikhambo lekhonsathi e-Portugal ngo-2016)&lt;/ref&gt; e-London, e-Madrid,&lt;ref name=&quot;:2&quot; /&gt;&lt;ref&gt;Iphosta yekhonsathi (ikhambo lekhonsathi e-Spain: ''¡Feliz Cincuenta Cumpleaños - 2013!'')&lt;/ref&gt; e-Oslo,&lt;ref&gt;[https://web.archive.org/web/20200608114526/https://listen.no/event/konsert-kl-13-00-james-peace-flygel-tangos-romanticos-musikk-av-peace-piazzolla-albeniz-utstillingssalene-er-stengt Listen.no. James Peace (flygel). Munch Museet. Oslo, mhlana ali-16 kuNobayeni, 2004]

&lt;/ref&gt; e-Reykjavik,&lt;ref&gt;[https://www.mbl.is/greinasafn/innskraning/?redirect=%2Fgreinasafn%2Fgrein%2F823608%2F%3Ft%3D686347190&amp;page_name=article&amp;grein_id=823608 Ríkarður Ö. Pálsson. &quot;Skozkir Slaghörputangoár&quot;. Morgunblaðið (iphephandaba e-Iceland). mhlana ali-14 kuNobayeni, 2004]&lt;/ref&gt; kanye ne-Vienna.&lt;ref&gt;Incwajana yekhonsathi (Vienna). Mhlana ama-23 kuTjhirhweni, 2005&lt;/ref&gt;

Ngo-2008 waba lilunga elihlonitjhwako le-London College of Music ngokuthokozwa ngemisebenzi yakhe ku-tango.&lt;ref name=&quot;:10&quot;&gt;[https://search.nls.uk/discovery/fulldisplay?vid=44NLS_INST:44NLS_VU1&amp;mode=basic&amp;tab=default_tab&amp;docid=alma9948049943804341&amp;query=any,contains,K.%20James%20Peace&amp;context=L&amp;adaptor=Local%20Search%20Engine&amp;lang=en National Library of Scotland. ''K. James Peace in Wiesbaden'']&lt;/ref&gt;&lt;ref name=&quot;:11&quot;&gt;[https://portal.dnb.de/opac.htm?method=simpleSearch&amp;cqlMode=true&amp;query=idn%3D1022200380 Deutsche Nationalbibliothek. ''K. James Peace in Wiesbaden'']&lt;/ref&gt;&lt;ref name=&quot;:12&quot;&gt;[https://whittakerlive.blogspot.com/2012/05/new-dvd-interview-with-wiesbaden.html Whittaker Live. &quot;Wiesbadener Highlander K. James Peace - New DVD&quot;]&lt;/ref&gt;

Ngemva kwesikhathi esifitjhani e-Edinburgh wabuyela ngoMhlolanja 2010 e-Germany ukuyokuhlala e-Wiesbaden.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt; Lokhu kwabangela bona abe nemizwa emitjha yokutlama begodu wenza amafilimu amafitjhani wezinye zeengoma zakhe. Ifilimu yedokhumenthari ''i-K. James Peace in Wiesbaden'' ingenye yemisebenzi yakhe emhlobeni lo wombhino.&lt;ref name=&quot;:10&quot; /&gt;&lt;ref name=&quot;:11&quot; /&gt;&lt;ref name=&quot;:12&quot; /&gt;
[[Isimumathi:Tango Milonga op. 26.wav|thumb|248x248px|Tango Milonga op. 26|center]]


[[Isimumathi:Tango XVIII by James Peace (James Peace, piano).wav|thumb|Tango XVIII by James Peace (James Peace, piano)|center]]



== Imitlomelo Nabonongorwana ==
[[Isimumathi:Cover page, Eternal Song Op.32 by James Peace (study score).png|thumb|318x318px|Eternal Song Op.32]]
●     Umtlomelo Wokuthoma, I-Agnes Millar Prize. E-Glasgow, 1983&lt;ref name=&quot;:4&quot; /&gt;

●      Umtlomelo Wokuthoma, I-Dunbartonshire EIS Prize. E-Glasgow, 1984&lt;ref name=&quot;:4&quot; /&gt;

●      Umtlomelo Wokuthoma, I-Sibelius Essay Prize. E-Glasgow, 1985&lt;ref name=&quot;:4&quot; /&gt;

●     Idiploma yokuhlonipha, I-TIM Composition Competition. E-Roma, 2000&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:5&quot; /&gt;

●      Idiploma yokuhlonipha, I-IBLA Foundation. E-New York, 2002&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:5&quot; /&gt;

●     Imedali Yesikhumbuzo, I-International Piano Duo Association. E-Tokyo, 2002&lt;ref&gt;[http://ipda-pianoduo.com/composition-concour-list-english.html International Piano Duo Association (東京), Tokyo. Irhelo labaphumeleleko ngo-2002]&lt;/ref&gt;

●     Imedali yeGolide, I-Académie Internationale de Lutèce. E-Paris, 2008&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;

== Iingoma Eziyihloko ==
[[Isimumathi:Eternal Song Op.32 by James Peace (bars 602 - 606).pdf|thumb|291x291px|Eternal Song Op.32]]
●     IPophoma (I-The Waterfall)&lt;ref&gt;Hessisches Staatstheater. Incwajana yekhonsathi 12 no-19 kuNobayeni, 2021&lt;/ref&gt;

●     Ingoma Yekuseni (I-Aubade)

●     Iinyembezi Ezithulileko (I-Lento Lacrimoso) 

●     Amakari Akhohlwiweko (I-Forgotten Leaves)

●     Isonata Ye-Oboe (I-Sonata for oboe and piano)

●     I-Ballade

●     Imatjhi Yomgidingo no.1 (I-Ceremonial March no.1)

●      Imatjhi Yomgidingo no.2 (I-Ceremonial March no.2)

●     Igolide Lesilimela (I-Autumn Gold)&lt;ref&gt;&quot;Violine schwebt über das Orchester&quot;. Schwäbische Post (iphephandaba le-German). Mhlana ali-4 kuMgwengweni, 1998&lt;/ref&gt;

●     Ingoma Yesiphelani (I-Eternal Song)&lt;ref name=&quot;:0&quot; /&gt;&lt;ref&gt;[https://search.nls.uk/discovery/fulldisplay?docid=alma9935400923804341&amp;context=L&amp;vid=44NLS_INST:44NLS_VU1&amp;lang=en&amp;search_scope=MainCatalogue&amp;adaptor=Local%20Search%20Engine&amp;query=any,contains,James%20peace&amp;mode=basic National Library of Scotland. ''Eternal Song Op.32, Peace, K. James'']&lt;/ref&gt;

●     &quot;Ye-Georgia&quot; (Ngelimi le-Georgia: საქართველოსთვის)

●     24 Yamatango&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:6&quot; /&gt;&lt;ref name=&quot;:7&quot; /&gt;&lt;ref name=&quot;:8&quot; /&gt;&lt;ref name=&quot;:10&quot; /&gt;&lt;ref name=&quot;:11&quot; /&gt;&lt;ref name=&quot;:12&quot; /&gt;&lt;ref&gt;[https://www.britishviolasociety.co.uk/wp-content/uploads/2024/01/Latest-news-from-the-British-Viola-Society.-August-2023-compressed.pdf British Viola Society Newsletter, Agasti, 2023]

&lt;/ref&gt;&lt;ref&gt;[https://web.archive.org/web/20240522135254/https://hojaderutadigital.mx/una-corta-historia-del-tango/ Hoja de Ruta Digital, México. &quot;Una corta historia del tango&quot;, mhlana ali-22 kuNtaka, 2024]

&lt;/ref&gt;&lt;ref&gt;[https://search.nls.uk/discovery/fulldisplay?docid=alma9941547953804341&amp;context=L&amp;vid=44NLS_INST:44NLS_VU1&amp;lang=en&amp;search_scope=MainCatalogue&amp;adaptor=Local%20Search%20Engine&amp;query=any,contains,James%20peace&amp;mode=basic National Library of Scotland. ''Tangos op.33, Peace, K. James'']&lt;/ref&gt;

== Amalinki Wangaphandle ==
[https://www.youtube.com/watch?v=sSX1c8EUukg&amp;list=RDsSX1c8EUukg&amp;start_radio=1 I-Souvenir de Buenos Aires - ''youtube'']

[https://www.youtube.com/watch?v=ZcMRNnwNJhk&amp;list=RDZcMRNnwNJhk&amp;start_radio=1 I-Lento Lacrimoso - ''youtube'']

[https://www.youtube.com/watch?v=_VKxG2dmQn4&amp;list=RD_VKxG2dmQn4&amp;start_radio=1 I-Autumn Gold - ''youtube'']

== Iinkomba ==</text>
      <sha1>7oe1r9ql8gxfqa6wj5nqp3yt7azegle</sha1>
    </revision>
    <revision>
      <id>6315</id>
      <parentid>6150</parentid>
      <timestamp>2026-03-21T14:38:16Z</timestamp>
      <contributor>
        <username>Mainglück</username>
        <id>1324</id>
      </contributor>
      <minor />
      <comment>Kungezelelwe: Isigaba (Abosaziwako)</comment>
      <origin>6315</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="10680" sha1="2eqb1qkkcgdikmnhzros9kfiz8hk8c6" xml:space="preserve">[[Isimumathi:James Peace at home in Wiesbaden3.jpg|thumb|447x447px|James Peace ]]
'''U-Kenneth James Peace''' wabelethelwa e-Paisley, mhla ama-28 kuNobayeni, 1963. Umakhiwombhino we-Scotland, umdlali wepiyano ekhonsathini kanye nomdwebi wezinto ezibonwako.

== Umlando Womuntu ==
UJames Peace wabelethelwa e-Paisley, mhla ama-28 kuNobayeni, 1963. Wakhulela e-Helensburgh, indawo yokuphumula eseduze nelwandle etjingalanga ye-Scotland.&lt;ref name=&quot;:0&quot;&gt;[https://web.archive.org/web/20110527164145/http://www.wiesbadener-tagblatt.de/region/wiesbaden/meldungen/10206548.htm Birgitta Lamparth. &quot;Keine ‘stacheligen’ Klänge&quot;, Wiesbadener Tagblatt (iphephandaba le-German), mhlana ali-10 kuMhlolanja, 2012]

&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;Julia Anderton. &quot;Tango wie eine süß-saure Geschichte&quot;. Wiesbadener Kurier (iphephandaba le-German), mhlana ama-24 kuNtaka, 2012&lt;/ref&gt;&lt;ref name=&quot;:2&quot;&gt;[https://hojaderutadigital.mx/una-entrevista-al-compositor-james-peace/ Soledad Carrizo-Araya. &quot;Una entrevista al compositor James Peace&quot;. Hoja de Ruta Digital. Unobayeni 2022]&lt;/ref&gt; Umndenakhe bewunabavumi abanengi (isib. uJohn McGhie), begodu uhlobana noFelix Burns, umtlami wombhino odumileko womvumo wokudansa engcenyeni yokuthoma &lt;sup&gt;yekhulu&lt;/sup&gt; lama-20.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:3&quot;&gt;Sabine Klein. &quot;Meine Musik ist wie ich - sehr romantisch&quot;. Frankfurter Rundschau (iphephandaba le-German), 1992, edition 254, ikhasi 2&lt;/ref&gt; Wafundiswa ipiyano kusukela aneminyaka ebunane begodu ukudlala kwakhe kokuthoma emphakathini kwenzeka nakaneminyaka elitjhumi nane, adlala umvumo kaScott Joplin.&lt;ref name=&quot;:2&quot; /&gt; Nakaneminyakaelitjhumi nesithandathu wamukelwa e-Royal Scottish Academy of Music and Drama (nje ebizwa ngokuthi: Yi-Royal Conservatoire of Scotland) njengomfundi omncani kunabo boke abafunda isikhathi esizeleko.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:3&quot; /&gt;&lt;ref name=&quot;:4&quot;&gt;G. Müller. &quot;Die Seele des Klaviers tanzt Tango&quot;. Kulturspiegel Wetterau (imagazini e-Germany). mhlana ali-17 kuNtaka 2001, ikhasi 5&lt;/ref&gt; Ngo-1983 waphothula e-Glasgow University ngedigri ye-BA yokufundisa ipiyano. Ngomnyaka olandelako wathola idiploma yokuvuma umvumo ngemva kokudlala i-Piano Concerto No.1 ka-Mendelssohn ne-orchestra ye-RSAMD..&lt;ref name=&quot;:3&quot; /&gt;&lt;ref name=&quot;:4&quot; /&gt; Ngemva kokuqeda ifundo ephakemeko bekafunwa khulu njengomdlali wepiyano begodu wahlala e-Edinburgh ngo-1988 -1991.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:5&quot;&gt;&quot;James Peace&quot;. ''FRIZZ'' (imagazini e-Germany). UTjhirhweni 2001, ​​ikhasi 5&lt;/ref&gt;

UJames Peace bekahlala e-Bad Nauheim, e-Germany kusukela ngo-1991 ukuya ngo-2009.&lt;ref&gt;Manfred Merz. &quot;Virtuose, gefühlsbetonte Welt der Romantik&quot;, Wetterauer Zeitung (iphephandaba le-German), mhlana ali-12 kuNobayeni, 1992, ikhasi 19&lt;/ref&gt;&lt;ref&gt;&quot;James Peace&quot;. The Tango Times (Imagazini e-new York). Inomboro ye-edishini: 2002/2003 (39). ikhasi 1 - 5&lt;/ref&gt; Kusukela ngo-1998 wenza isifundo se-tango, wakhiqiza i-CD ''ye-Tango escocés'' yeengoma zakhe zepiyano ezihlohlozelwa yi-tango, begodu ngo-2002 waba lilunga elihloniphekileko le-Victoria College of Music.&lt;ref name=&quot;:3&quot; /&gt;&lt;ref name=&quot;:6&quot;&gt;[https://search.nls.uk/discovery/fulldisplay?vid=44NLS_INST%3A44NLS_VU1&amp;mode=basic&amp;docid=alma99115833839204341&amp;query=any%2Ccontains%2CTango+escoc%C3%A9s&amp;context=L&amp;adaptor=Local+Search+Engine&amp;lang=en&amp;search_scope=MainCatalogue National Library of Scotland. ''Tango escocés'']&lt;/ref&gt;&lt;ref name=&quot;:7&quot;&gt;[https://pad.philharmoniedeparis.fr/pad/doc/ALOES/0795887/tango-escoces-scottish-tango-k-james-peace-comp-piano Philharmonie de Paris. ''Tango escocés'']&lt;/ref&gt;&lt;ref name=&quot;:8&quot;&gt;[https://www.muziekweb.nl/Link/KHX3103/Tango-escoc%C3%A9s de bibliotheek. ''Tango escocés'']&lt;/ref&gt;&lt;ref name=&quot;:9&quot;&gt;&quot;James Peace&quot;. La Cadena (imagazini ese-Netherlands).UNobayeni 2002, ikhasi 26&lt;/ref&gt; Ngomnyaka wona loyo waya emakhonsathini yedwa e-North Germany ngoKhukhulamungu/Sewula begodu waya e-Far East ngoNobayeni, okwaba kudlala kwakhe kokuthoma ''kwe-Tango XVII'' e-Hong Kong.&lt;ref name=&quot;:6&quot; /&gt;&lt;ref name=&quot;:7&quot; /&gt;&lt;ref name=&quot;:8&quot; /&gt;&lt;ref name=&quot;:9&quot; /&gt;&lt;ref&gt;[https://web.archive.org/web/20040806204941/http://www.tangotang.com/discus/messages/13/266.html?1034001060 ''TangoTang'', Hong Kong (香港). Iphepha leendaba, mhlana ali-8 kuNobayeni, 2002]

&lt;/ref&gt;&lt;ref&gt;[https://www.scmp.com/article/393890/james-peace &quot;James Peace&quot;. 南華早報 (Iphephandaba le-Hong Kong). mhlana ali-9 kuNobayeni 2002]&lt;/ref&gt;
[[Isimumathi:James Peace - Idylls Op.4b.webm|thumb|341x341px|James Peace - Idylls Op.4b]]
Eminyakeni elandelako wadlala umbhino khulukhulu eYurobhu. Udlale ama-tango wakhe emadorobheni amakhulu alandelako: e-Amsterdam, e-Athens,&lt;ref&gt;Incwajana yekhonsathi ''{Για σένα Αγγελική}''. Athens, mhlana ama-27 kuMrhayili, 2016&lt;/ref&gt; e-Berlin,&lt;ref&gt;Tangodanza (imagazini e-Germany). Inomboro ye-edishini:: 1/2002 - 9&lt;/ref&gt; e-Brussels, e-Helsinki,&lt;ref&gt;Iphosta yekhonsathi (ikhambo lekhonsathi e-Finland ngo-2014)&lt;/ref&gt; e-Lisbon,&lt;ref name=&quot;:2&quot; /&gt;&lt;ref&gt;Iphosta yekhonsathi (ikhambo lekhonsathi e-Portugal ngo-2016)&lt;/ref&gt; e-London, e-Madrid,&lt;ref name=&quot;:2&quot; /&gt;&lt;ref&gt;Iphosta yekhonsathi (ikhambo lekhonsathi e-Spain: ''¡Feliz Cincuenta Cumpleaños - 2013!'')&lt;/ref&gt; e-Oslo,&lt;ref&gt;[https://web.archive.org/web/20200608114526/https://listen.no/event/konsert-kl-13-00-james-peace-flygel-tangos-romanticos-musikk-av-peace-piazzolla-albeniz-utstillingssalene-er-stengt Listen.no. James Peace (flygel). Munch Museet. Oslo, mhlana ali-16 kuNobayeni, 2004]

&lt;/ref&gt; e-Reykjavik,&lt;ref&gt;[https://www.mbl.is/greinasafn/innskraning/?redirect=%2Fgreinasafn%2Fgrein%2F823608%2F%3Ft%3D686347190&amp;page_name=article&amp;grein_id=823608 Ríkarður Ö. Pálsson. &quot;Skozkir Slaghörputangoár&quot;. Morgunblaðið (iphephandaba e-Iceland). mhlana ali-14 kuNobayeni, 2004]&lt;/ref&gt; kanye ne-Vienna.&lt;ref&gt;Incwajana yekhonsathi (Vienna). Mhlana ama-23 kuTjhirhweni, 2005&lt;/ref&gt;

Ngo-2008 waba lilunga elihlonitjhwako le-London College of Music ngokuthokozwa ngemisebenzi yakhe ku-tango.&lt;ref name=&quot;:10&quot;&gt;[https://search.nls.uk/discovery/fulldisplay?vid=44NLS_INST:44NLS_VU1&amp;mode=basic&amp;tab=default_tab&amp;docid=alma9948049943804341&amp;query=any,contains,K.%20James%20Peace&amp;context=L&amp;adaptor=Local%20Search%20Engine&amp;lang=en National Library of Scotland. ''K. James Peace in Wiesbaden'']&lt;/ref&gt;&lt;ref name=&quot;:11&quot;&gt;[https://portal.dnb.de/opac.htm?method=simpleSearch&amp;cqlMode=true&amp;query=idn%3D1022200380 Deutsche Nationalbibliothek. ''K. James Peace in Wiesbaden'']&lt;/ref&gt;&lt;ref name=&quot;:12&quot;&gt;[https://whittakerlive.blogspot.com/2012/05/new-dvd-interview-with-wiesbaden.html Whittaker Live. &quot;Wiesbadener Highlander K. James Peace - New DVD&quot;]&lt;/ref&gt;

Ngemva kwesikhathi esifitjhani e-Edinburgh wabuyela ngoMhlolanja 2010 e-Germany ukuyokuhlala e-Wiesbaden.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt; Lokhu kwabangela bona abe nemizwa emitjha yokutlama begodu wenza amafilimu amafitjhani wezinye zeengoma zakhe. Ifilimu yedokhumenthari ''i-K. James Peace in Wiesbaden'' ingenye yemisebenzi yakhe emhlobeni lo wombhino.&lt;ref name=&quot;:10&quot; /&gt;&lt;ref name=&quot;:11&quot; /&gt;&lt;ref name=&quot;:12&quot; /&gt;
[[Isimumathi:Tango Milonga op. 26.wav|thumb|248x248px|Tango Milonga op. 26|center]]


[[Isimumathi:Tango XVIII by James Peace (James Peace, piano).wav|thumb|Tango XVIII by James Peace (James Peace, piano)|center]]



== Imitlomelo Nabonongorwana ==
[[Isimumathi:Cover page, Eternal Song Op.32 by James Peace (study score).png|thumb|318x318px|Eternal Song Op.32]]
●     Umtlomelo Wokuthoma, I-Agnes Millar Prize. E-Glasgow, 1983&lt;ref name=&quot;:4&quot; /&gt;

●      Umtlomelo Wokuthoma, I-Dunbartonshire EIS Prize. E-Glasgow, 1984&lt;ref name=&quot;:4&quot; /&gt;

●      Umtlomelo Wokuthoma, I-Sibelius Essay Prize. E-Glasgow, 1985&lt;ref name=&quot;:4&quot; /&gt;

●     Idiploma yokuhlonipha, I-TIM Composition Competition. E-Roma, 2000&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:5&quot; /&gt;

●      Idiploma yokuhlonipha, I-IBLA Foundation. E-New York, 2002&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:5&quot; /&gt;

●     Imedali Yesikhumbuzo, I-International Piano Duo Association. E-Tokyo, 2002&lt;ref&gt;[http://ipda-pianoduo.com/composition-concour-list-english.html International Piano Duo Association (東京), Tokyo. Irhelo labaphumeleleko ngo-2002]&lt;/ref&gt;

●     Imedali yeGolide, I-Académie Internationale de Lutèce. E-Paris, 2008&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot; /&gt;

== Iingoma Eziyihloko ==
[[Isimumathi:Eternal Song Op.32 by James Peace (bars 602 - 606).pdf|thumb|291x291px|Eternal Song Op.32]]
●     IPophoma (I-The Waterfall)&lt;ref&gt;Hessisches Staatstheater. Incwajana yekhonsathi 12 no-19 kuNobayeni, 2021&lt;/ref&gt;

●     Ingoma Yekuseni (I-Aubade)

●     Iinyembezi Ezithulileko (I-Lento Lacrimoso) 

●     Amakari Akhohlwiweko (I-Forgotten Leaves)

●     Isonata Ye-Oboe (I-Sonata for oboe and piano)

●     I-Ballade

●     Imatjhi Yomgidingo no.1 (I-Ceremonial March no.1)

●      Imatjhi Yomgidingo no.2 (I-Ceremonial March no.2)

●     Igolide Lesilimela (I-Autumn Gold)&lt;ref&gt;&quot;Violine schwebt über das Orchester&quot;. Schwäbische Post (iphephandaba le-German). Mhlana ali-4 kuMgwengweni, 1998&lt;/ref&gt;

●     Ingoma Yesiphelani (I-Eternal Song)&lt;ref name=&quot;:0&quot; /&gt;&lt;ref&gt;[https://search.nls.uk/discovery/fulldisplay?docid=alma9935400923804341&amp;context=L&amp;vid=44NLS_INST:44NLS_VU1&amp;lang=en&amp;search_scope=MainCatalogue&amp;adaptor=Local%20Search%20Engine&amp;query=any,contains,James%20peace&amp;mode=basic National Library of Scotland. ''Eternal Song Op.32, Peace, K. James'']&lt;/ref&gt;

●     &quot;Ye-Georgia&quot; (Ngelimi le-Georgia: საქართველოსთვის)

●     24 Yamatango&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:6&quot; /&gt;&lt;ref name=&quot;:7&quot; /&gt;&lt;ref name=&quot;:8&quot; /&gt;&lt;ref name=&quot;:10&quot; /&gt;&lt;ref name=&quot;:11&quot; /&gt;&lt;ref name=&quot;:12&quot; /&gt;&lt;ref&gt;[https://www.britishviolasociety.co.uk/wp-content/uploads/2024/01/Latest-news-from-the-British-Viola-Society.-August-2023-compressed.pdf British Viola Society Newsletter, Agasti, 2023]

&lt;/ref&gt;&lt;ref&gt;[https://web.archive.org/web/20240522135254/https://hojaderutadigital.mx/una-corta-historia-del-tango/ Hoja de Ruta Digital, México. &quot;Una corta historia del tango&quot;, mhlana ali-22 kuNtaka, 2024]

&lt;/ref&gt;&lt;ref&gt;[https://search.nls.uk/discovery/fulldisplay?docid=alma9941547953804341&amp;context=L&amp;vid=44NLS_INST:44NLS_VU1&amp;lang=en&amp;search_scope=MainCatalogue&amp;adaptor=Local%20Search%20Engine&amp;query=any,contains,James%20peace&amp;mode=basic National Library of Scotland. ''Tangos op.33, Peace, K. James'']&lt;/ref&gt;

== Amalinki Wangaphandle ==
[https://www.youtube.com/watch?v=sSX1c8EUukg&amp;list=RDsSX1c8EUukg&amp;start_radio=1 I-Souvenir de Buenos Aires - ''youtube'']

[https://www.youtube.com/watch?v=ZcMRNnwNJhk&amp;list=RDZcMRNnwNJhk&amp;start_radio=1 I-Lento Lacrimoso - ''youtube'']

[https://www.youtube.com/watch?v=_VKxG2dmQn4&amp;list=RD_VKxG2dmQn4&amp;start_radio=1 I-Autumn Gold - ''youtube'']

== Iinkomba ==
&lt;references /&gt;
[[Mkhakha:Abosaziwako]]</text>
      <sha1>2eqb1qkkcgdikmnhzros9kfiz8hk8c6</sha1>
    </revision>
  </page>
  <page>
    <title>Brown Mogotsi</title>
    <ns>0</ns>
    <id>1027</id>
    <revision>
      <id>6151</id>
      <timestamp>2026-01-29T07:36:41Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1332476636|Brown Mogotsi]]&quot;</comment>
      <origin>6151</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2801" sha1="blpuhnxgqexxhq2b2owcf3l3rcrzt8m" xml:space="preserve">
 

'''Oupa Brown Mogotsi''' ngusomabhizinisi weSewula Afrika ophuma esifundeni seNorthWest.

NgoVelahlinze 2025 watjela ''i-Sunday World'' bona bekabandakanyeka, njengomtloli namkha &quot;ngokufihlakeleko&quot;, emsebenzini wezobunhloli begodu wathi ubandakanyeka emsebenzini oholele ekuboshweni kombaleki u-Thabo Bester,iinkulumo ezadosa amehlo ngombana ziphathelene nokuthi u-Mogotsi bekasebenza njengomthombo wombuso osemthethweni nofana ongakahleleki.Iinsolo lezi azange ziqinisekiswe ngokuzijameleko emthethwandaba, zibikwa njengeentatimende zika-Mogotsi. 

== IsiKhwama se-Brown Mogotsi ==
Nge-Brown Mogotsi Foundation,wabuye waphikisana nokuphathwa kwakaNdunakulu wangaphambilini we-North West u-Supra Mahumapelo. Ngomnyaka ka-2023,isisekelo safaka isibawo sokukhandela ithenda lokupheka le-R1-billion yeenkhungo zezamaphilo ze-North West,sithi ikambiso leyo beyingakajayeleki begodu itlhoga ukungenelela ukwenzela umphakathi.Isibawo sabangela ukuphazamiseka nemithelela yezezimali emNyangweni wezamaPhilo weTlhagwini Tjingalanga. 

== Ubufakazi bePalamende kunye nama-akhawundi ahlukileko ==
Iimphathiswa eziphezulu zamapholisa zinikele iindaba eziphikisanako phambi kweenkambo zephalamende nezekhomitjhini malungana nobujamo nokujula kokuthintana kwazo no-Mogotsi.

U-Shadrack Sibiya,uMsekeli kaKhomitjhina wenarha wokuthola ubulelesi omisiweko,watjela ikomidi yesikhatjhana yePalamende bona uyabazi u-Mogotsi no -Vusimuzi “Cat” Matlala begodu wahlathulula ukuhlangana okulinganiselweko ubuso nobuso (ngokwesibonelo,emnyanyeni we-ANC mhlana ali-8 kuTjhirhweni),ngesikhathi afuna ukuziqhelelanisa nanyana ngibuphi ubudlelwano obungakalungi.U-Sibiya uthe wahlangana no-Mogotsi iinkhathi ezimbalwa begodu wahlathulula ukukhulumisana akutjho bona bekungasikho komuntu mathupha begodu okusebenzako.

U-Sibiya wathi lokha u-Mogotsi nakaveza ukutshwenyeka nge-Crime Intelligence emlandelako,u-Sibiya waxwayisa uKhomitjhina wenarha begodu wasebenzisa ilwazi ukuze azuze ukuphepha kwakhe,i-akhawunti ebikwe njengetjengisa ukusebenzisana okubudisi hlangana nabantu abanikela ilwazi neenkhulu zamapholisa.

== Ukuzibandakanya kwezepolotiki ==
I -African National Congress (ANC) iveze tjhatjhalazi bona ubulunga baka-Mogotsi buphelile (ihlangano le iziqhelelanise naye ngebanga lemibuzo), ngesikhathi u-Mogotsi ngezinye iinkhathi atjho bona uragela phambili nobudlelwano nofana azichaze njengesishoshovu se-ANC.

== imkomba ==
{{cite web|title=Mkhwanazi details how Mchunu associate Brown Mogotsi contacted him - eNCA|url=https://www.enca.com/news/mkhwanazi-details-how-mchunu-associate-brown-mogotsi-contacted-him}}
2.{{cite web|title=Mkhwanazi details how Mchunu associate Brown Mogotsi contacted him - eNCA|url=https://www.enca.com/news/mkhwanazi-details-how-mchunu-associate-brown-mogotsi-contacted-him}}</text>
      <sha1>blpuhnxgqexxhq2b2owcf3l3rcrzt8m</sha1>
    </revision>
  </page>
  <page>
    <title>Economic Freedom Fighters</title>
    <ns>0</ns>
    <id>1028</id>
    <revision>
      <id>6152</id>
      <timestamp>2026-01-29T09:54:31Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1335083182|Economic Freedom Fighters]]&quot;</comment>
      <origin>6152</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8768" sha1="jbvd0dxrnpnej8s3it8sj4nx5o6njz0" xml:space="preserve">
I '''-Economic Freedom Fighters''' ( '''EFF''' ) lihlangano yezepolotiki yeSewula Afrika yamakhomanisi neyabantu abanzima .Yasungulwa ngumongameli wangaphambilini we-African National Congress Youth League (ANCYL) u -Julius Malema nabalingani bakhe mhlazi-26 kuNtaka 2013.U-Malema ngumongameli we-EFF,okhokhela i-Central Command Team,esebenza njengesakhiwo esiphakathi sehlangano.Yihlangano yesine ngobukhulu e- National Assembly.

Ihlangano le yaphalisana emakhethweni kokuthoma ekhethweni jikelele leSewula Afrika yango-2014,yathola i-6.35% yamavoti weentjhabatjhaba begodu yathola iindawo ezima-25 e-National Assembly.

Ubujamo behlangano obuqakathekileko bezepolotiki kukobana iSewula Afrika isenehlelo lezomnotho elizuzisa abantu abamhlophe ukudlula abantu abamnyama begodu kufuze kwenziwe amatjhuguluko aqakathekileko asekelwe emigomeni ka-Marxist.Ihlangano le beyisolo isekela i-Pan-Africanism.

Solo kwasungulwa i-EFF sele ihlanganiswe neempikiswano ezinengi lapho kuthiwa isebenzise amagama ahlukanisako, anodlame,nangebandlululo.U-Malema umangalelwa ukukhuluma ngenzondo kanengi begodu watholakala anecala kabili.Ihlangano sele ibandakanyeke emacaleni amanengi wekohlakalo.Kuye kwahlathululwa njengobudlova.Ngokuya kwejaji lekhotho ye-South African Equality,u-Malema &quot;ubawe bona ababandlululi babulawe&quot;.UMalema ugwetshwe icala lokubhabula.

== Umlando ==

=== Isisekelo kunye nomlando wokuthoma ===
Emhlanganweni weendaba mhlazi-26 kuNtaka 2013 e -Soweto,u-Malema wamemezela bona ihlangano etja inamalunga angaphezu kwe-1000,okuphindwe kabili kwama-500 atlhogekako ukutloliswa ku- Independent Electoral Commission (IEC).I-EFF sele itloliswe ku-IEC,ngemva kokuthi ukuphikisana nokutloliswa kwayo yi- Freedom Front Plus (FF+) kwachithwa ngoNobayeni wee-2013. 

Ngomnyaka ka-2015,i-EFF yajamisa ilunga lePalamende u-Lucky Twala begodu yaqotjha amalunga wePalamende amathathu,u-Mpho Ramakatsa,u-Andile Mngxitama, no -Khanyisile Litchfield-Tshabalala .UMngxitama wakha ihlangano yakhe,i-Black First Land First (BLF),ngesikhathi u-Litchfield-Tshabalala ajoyina i -United Democratic Movement. U-Malema ubekwe icala ngamalunga wangaphambilini ngokuhlanza abagxeki bakhe ukuqinisa amandla wakhe. Wavuma ukuhlatjwa lokhu emhlanganweni weendaba begodu wathi ihlangano bekufanele ikhuphe amalunga amanengi angaziphathi kuhle.

=== Izenzo zamva nje nemisebenzi ===
Mhlana ali-6 kuRhoboyi wee-2015,i-EFF yamemezela bona ithole icala leKhotho yomThethosisekelo ngejima layo elithi &quot;#PayBackTheMoney&quot;ngokujamelene no -Jacob Zuma .Icala lalalelwa mhlana ali-9 kuMhlolanja 2016.UJaji omkhulu u-Mogoeng Mogoeng wathola bona u-Zuma wephule umThethosisekelo weSewula Afrika,kunye nosomlomo we-National Assembly u-Baleka Mbete.UZuma wanikelwa amalanga ama-60 bona afeze iimfuneko zomvikeli womphakathi uThuli Madonsela.

Mhlana amalanga ama-27 kuMhlolanja 2018,i-EFF yafaka isiphakamiso e-National Assembly sokutjhugulula umthethosisekelo ukwenzela bona kuvunyelwe ukuthathwa kwendawo ngaphandle kokubhadelwa.Isiphakamiso, esilethwe ngu-Malema,samukelwa ngamavoti ama-241 asekelako begodu ama-83 aphikisanako.Iinhlangano ezaphikisako bekuyi- Democratic Alliance,i-Freedom Front Plus,i-Congress of the People kunye ne- ACDP.Ukuthathwa kwendawo kungenye yeensika ezilikhomba eziqakathekileko ze-EFF.

Ngenyanga kaNtaka 2023,ihlangano le izamile ukuhlela ukuvalwa kwemisebenzi enarheni yoke ngokutjhikijela ukwehliswa kwemithwalo begodu yabawa uMengameli weSewula Afrika u-Cyril Ramaphosa bona atjhiye isikhundla. Ukuvalwa kwabikwa ngokubanzi njengokungasebenzi begodu kufaka hlangana izehlakalo ezinengi zeendaba ezingasiqiniso ezisabalaliswe balandeli behlangano.

Ngenyanga kaMgwengweni 2024 i-EFF yala ukujoyina i-ANC-led Government of National Unity (GNU),ngebanga lokuzibandakanya kwe -Democratic Alliance (DA) kunye ne -Freedom Front Plus (FF+) emhlanganweni.

Ngenyanga kaRhoboyi wee-2024,isekela likamongameli we-EFF u-Floyd Shivambu watjhiya ihlangano begodu wajoyina ihlangano ye -uMkhonto weSizwe (MK) kaMengameli wangaphambilini u-Jacob Zuma. 

== Imibono nemigomo ==
Ngokuya komthethosisekelo wayo,i-EFF &quot;ivumelana nekolo ze-Marxist-Leninist ne-Fanonian ekuhlaziyweni kwayo koMbuso,ubukhosi,ukuphikisana kwamazinga nobuhlanga kiyo yoke imiphakathi.&quot;I-EFF ithi ithatha ukugqugquzeleka kuMengameli we-Burkinabé u-Thomas Sankara kokubili isitayela nemibono.Iunga elidumileko le-EFF u-Jackie Shandu wamemezela bona ihlangano le &quot;yihlangano yokuzikhakhazisa yama-Sankarist &quot;. 

Iinsika ezilikhomba eziqakathekileko zehlangano zathoma ukuvezwa ku-Founding Manifesto (2013) begodu zihlala zisemqoka ehlelweni lezepolotiki lehlangano begodu zifakwe emthethweni wayo. Ba:

1.Ukuthathwa kwenarha ngaphandle kokubhadelwa:I-EFF ikhuthaza ukuthathwa kwenarha ngaphandle kokubhadelwa, ithi inarha yebiwa ngesikhathi samakoloni nesikhathi sebandlululo .Ihlangano iphakamisa bona yoke inarha kufanele ibe ngaphasi kokugcinwa kombuso begodu inarha kufanele yabiwe kabutjha ngokulinganako.Ithi umthetho karhulumende weSewula Afrika othi ukuthenga ngokuzithandela-umthengisi ngokuzithandela kufanele uqedwe.Isikhundla lesi sibe nomthelela omkhulu empikiswaneni yokutjhugulula umhlaba weSewula Afrika kusukela ngesikhathi saka-Malema ase- African National Congress Youth League (i-ANCYL),lapho umthethomgomo lo wathoma ukwamukelwa khona.

2.​Ihlangano le ithi lokhu kuzokuqeda ukubusa kwezomnotho kwabamhlophe begodu kuqinisekise bona woke amaSewula Afrika azuze umnotho welizwe.

3. Ukwakha amandla wombuso noRhulumende:Isika le igandelela ukuqinisa iinkhungo zombuso,ukuthuthukisa amandla wokulethwa kweenkonzo zikaRhulumende nokwakha imodeli yombuso yokuthuthukisa.

.I-EFF ibe nendima ekulu emitjhagalweni yabafundi efana ne -FesMustFall.

5. Ukuthuthukiswa okukhulu kwamabubulo:Ihlangano ikhuthaza ukuthuthukiswa kwamabubulo wendawo, ukuvikelwa kwezokurhweba nokudalwa kwemisebenzi ngomthethomgomo wamabubulo oholwa mbuso.

6.Ukuthuthukiswa komnotho we-Afrika:Isika le ikhuthaza ukuhlanganiswa komnotho we -Pan-Afrika,ukujamelana nemikhuba yezomnotho ye-neocolonial kunye nokuziphilisa komnotho we-Afrika.

=== Isigwebo sokuhlongakala ===
Ekwethulweni kwe-EFF ngo-2013,u-Malema wabiza ireferendamu malungana nokubuyiselwa kwesigwebo sokuhlongakala,kodwana ngo-2019 besele atjhugulule ubujamo lobu.

I-EFF isekela amalungelo womphakathi we -LGBT+ e-Afrika begodu isola ngokusemthethweni imithetho efuna ukukhandela ubutabani.Ihlangano beyigxeka umthethomlingwa we- Uganda we-2023 we-Anti-Homosexuality begodu yadosa umtjhagalo ngaphandle kwe-embassy ye-Uganda eSewula Afrika ikhuthaza umengameli we-Uganda bona angayisayini ibe mthetho.Ngokukhamba kwesikhathi ngo-2023,ihlangano yagxekwa khulu malunga womphakathi we-LGBT+ weSewula Afrika ngokumema u-Patrick Lumumba,uphrofesa we-Kenya owaziwa ngokwenza iintatimende ezihloya abantu bobulili obufanako begodu osekela tjhatjhalazi umthethomlingwa we-Uganda we-2023 we-Anti-Homosexuality,bona athumele ihlangano le-10-10-levers ye-Chapary eYunivesithi Idorobho.

=== Iphiko labafundi ===
I-Economic Freedom Fighters Students Command (EFFSC) bekuliphiko labafundi lehlangano, elasungulwa mhlana ali-16 kuMgwengweni wee-2015.Yakhankasa ifundo yasimahla,ukufikelela kwefundo kibo boke abantu nokuqedwa kwemali yokubhalisa.Yahlakazeka ngoMhlolanja 2025 begodu yathathelwa indawo mhlana omutjha olandelako isiqunto esiphasiswe emhlanganweni wokukhetha wehlangano ngoNobayeni 2024.

=== Ibandlululo nebandlululo ngokobuhlanga ===
Solo kwasungulwa,i-EFF yenza iintatimende ezinengi eziphikisanako ezisekelwe ngokobuhlanga nofana ngokobuhlanga malungana namaqembu amancani weSewula Afrika,khulukhulu amaSewula Afrika amhlophe namaSewula Afrika we-Asia .Ihlangano sele igxekwa ngokwamukela ihlathululo yezinto eziphilako yobuhlanga evumela i-EFF bona ihlanganise lula begodu ifake ubuhlanga emaqenjini athileko nofana ebantwini ngokuya ngokuhlukaniswa kwabantu;nabo baqothelwa ukubandlululwa ngokobuhlanga yihlangano. Lokhu kube nomthelela ohlukanisako nowokutjhukumisela khulu kwezepolotiki zeSewula Afrika.Abadosiphambili behlangano baqophe inani leensebenzi zombuso,iintatheli, nemiphakathi ngokuya ngokobuhlanga babo.

== Iinkomba ==
1.https://web.archive.org/web/20130725200305/http://www.dispatch.co.za/malema-launches-his-economic-freedom-fighters/

2.https://web.archive.org/web/20130714113641/http://www.bdlive.co.za/national/politics/2013/07/11/malema-takes-command-of-economic-freedom-fighters

3.https://mg.co.za/article/2014-09-26-class-theory-finally-decolonised/

4.https://www.sahrc.org.za/index.php/sahrc-media/news/item/3379-human-rights-commission-gives-julius-malema-10-days-to-retract-anti-white-comments-made-at-rally

5.https://web.archive.org/web/20200801115553/https://www.sabcnews.com/sabcnews/black-first-land-first/</text>
      <sha1>jbvd0dxrnpnej8s3it8sj4nx5o6njz0</sha1>
    </revision>
  </page>
  <page>
    <title>Togo</title>
    <ns>0</ns>
    <id>1032</id>
    <revision>
      <id>6157</id>
      <timestamp>2026-02-06T16:04:31Z</timestamp>
      <contributor>
        <username>Ramzanka2000</username>
        <id>1296</id>
      </contributor>
      <comment>Created page with &quot;'''I-Togo''' (ngesiFulentshi: Togo [tɔˈgo]), ngokusemthethweni yi-Togolese Republic (ngesiFulentshi: République togolaise [ʁe.py.bˈlik tɔgoˈlɛz]), lilizwe eliseTjingalanga [[I-Afrika|ye-Afrika]], elinomngcele we-[[Ghana]] ngeTjingalanga, [[Benin|i-Benin]] ngepumalanga, kanye ne-[[Burkina Faso]] ngetlhagwini. Ngaseningizimu, inarha ine-coastline encani e-Gulf of [[Guinea]], lapho inhlokodolobha yenarha, i-[[Lomé]], itholakala khona [https://www.republicoftogo.com...&quot;</comment>
      <origin>6157</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3450" sha1="0achsrdslqg08k2ct6afkt3n1pa4ym0" xml:space="preserve">'''I-Togo''' (ngesiFulentshi: Togo [tɔˈgo]), ngokusemthethweni yi-Togolese Republic (ngesiFulentshi: République togolaise [ʁe.py.bˈlik tɔgoˈlɛz]), lilizwe eliseTjingalanga [[I-Afrika|ye-Afrika]], elinomngcele we-[[Ghana]] ngeTjingalanga, [[Benin|i-Benin]] ngepumalanga, kanye ne-[[Burkina Faso]] ngetlhagwini. Ngaseningizimu, inarha ine-coastline encani e-Gulf of [[Guinea]], lapho inhlokodolobha yenarha, i-[[Lomé]], itholakala khona [https://www.republicoftogo.com/].

== Indatjana ==
Kuncani okwaziwako ngomlando we-Togo wakade. Iindaba ezitholwe babantu abavubukuliweko zitjengisa bona iintjhaba zekadeni bezikwazi ukwenza izinto zokubumba nokusebenza ngensimbi. Phakathi nekhulu [[le-15]], [[amaPutukezi]] afika, asungula ukurhweba ngeengqila. Ngasekupheleni kwekhulu leminyaka [[ye-18]], idorobha le-[[Lomé]] lasungulwa endaweni yendawo yokuhlala yama-Ewe. Ngo-1884, u-[[Gustav Nachtigal]] watlikitla isivumelwano nabadosiphambili bendawo abanengi abasungula umbuso we-[[German Empire]] phezu kwe-Togo, kanye nengcenye yendawo ye-Ghana yanamhlanjesi. Imingcele yayo yaqunywa ngemva kobana amabutho we-German athumbe ingaphakathi lenarha begodu enza iimvumelwano [[France|ne-France]] [[Great Britain|ne-Great Britain]]. Ngomhlana ali-1 kuTjhirhweni [[1905]], indawo ye-Togo yanamhlanjesi yamenyezelwa njengekoloni ye-German [[Togoland|ye-Togoland]].

Ngesikhathi sePi yePhasi yoku-1, i-Togoland yathathwa yi-Great Britain ne-France, begodu kwamenyezelwa i-Anglo-French Condominium. NgoNobayeni mhlana ali-7, 1916, indlu yokuhlala yahlakazeka, yahlukaniswa yaba ziindawo ze-Britain ne-France. Mhlana amalanga ama-[[20 kuNtaka]] [[1922]], i-Great Britain yathola igunya le-League of Nations lokulawula i-Togo engeTjingalanga, bese kuthi i-France ibuse ipumalanga. [[1945|Ngo-1945]], inarha yathola ilungelo lokuthumela abajameli abathathu ephalamende ye-France. Ngemva kwePi yesi-II yePhasi, kwasungulwa umbuso we-UN, i-Great Britain ne-France zigcina ukulawula. Mhlana amalanga ama-[[28 kuSewula]] [[1956|wee-1956]], ngemva kwereferendamu, i-Togo yathola ubujamo obusemthethweni njengeriphabliki ezijameleko ngaphakathi kwe-France. NgoNhlolanja [[1958]], i-France yanikela i-Togo ubujamo be-republican, yagcina ilawulo phezu kwezokuvikela, ubudlelwano bangaphandle, kanye nezezimali. Ngenyanga kaRhoboyi wee-1958, ihlangano ye-Togolese Unity Committee yathumba amakhetho we-Chamber of Deputies. [[U-Sylvanus Olympio]] bekadosa phambili urhulumende omutjha.

Mhlana amalanga ama-[[27 kuMrhayili]] wee-[[1960]], i-Togo yamemezela ikululeko. U-Sylvanus Olympio wanqoba ukhetho lukamongameli wango-[[1961]], wathola ama-99% wamavoti. Ibandla eliphikisako laduba ukhetho. Mhlana amalanga ali-9 kuMrhayili wee-1961, umThethosisekelo we-Togoese Republic wamukelwa, wasungula i-National Assembly njengehlangano ephakemeko ye-Togo. Ngenyanga kaNobayeni 1961, abarholi beenhlangano eziphikisako babotjhwa, basolwa ngokwenza itulo lokulwisana norhulumende, begodu kwakhutjhwa umthetho ozokuqeda iinhlangano eziphikisako. Ngomhlana ali-[[13 kuTjhirhweni]] [[1963]], kwenzeka ukuvukela umbuso kwebutho, lapho u-Sylvanus Olympio abulawa khona. Kwamenyezelwa ubujamo obuphuthumako enarheni le. Ibutho lanikela amandla kurhulumende wesikhatjhana oholwa [[Nicolas Grunitzky|ngu-Nicolas Grunitzky]]. NgoMeyi 1963, u-Grunitzky wakhethwa njengoMongameli weRiphabhulikhi, begodu uburholi obutjha balandela umthethomgomo wokuthuthukisa ubudlelwano ne-France.</text>
      <sha1>0achsrdslqg08k2ct6afkt3n1pa4ym0</sha1>
    </revision>
  </page>
  <page>
    <title>U-Krotoa</title>
    <ns>0</ns>
    <id>1033</id>
    <revision>
      <id>6161</id>
      <timestamp>2026-02-11T15:35:43Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>New article</comment>
      <origin>6161</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6506" sha1="euoxaj5hwe37pgp06iivxabif4uxblb" xml:space="preserve">[[Isimumathi:Krotoa Picture.jpg|thumb|U-Krotoa]]
'''U-Krotoa''' (amaDatjhi bekalipeleda bunjesi ibizo lakhe - !Goroǀgôas) bekamfazi wom-Khoekhoe owalethwa ngu-Autshumato ku-Jan Van Riebeeck bona azokuba mtlhogomeli womkakhe u-Maria de la Quellerie. Ibizo lakhe lamambala alaziwa kodwana elidume khulu ngilelo amaDatjhi ebekambiza ngalo - u-Eva. Umfazi lo wadlala indima ekulu ekubeni mtologi phakathi kwesitjhaba samaDatjhi nesama-Khoekhoe, begodu waba ngomunye wabantu abanzima umlando wabo otlolwe phasi maDatjhi. Umalumakhe [[u-Autshumato]] wavuma ukumnikela [[u-Jan Van Riebeeck]] ngombana bekafuna abe mputjuzi wazo zoke iindaba zamaDatjhi nendlelawo yokwenza izinto. Uyingcenye eqakathekileko yomlando oveza ubuhlobo phakathi kwamaDatjhi nama-Khoekhoe.&lt;ref&gt;Cape Town Museum (2021), ''!Goroǀgôas (Krotoa) or Eva van Meerhof''. Retrieved from: https://www.capetownmuseum.org.za/impactfulwomeneng/krotoa-72dn4. Retrieved on 10/02/2026.&lt;/ref&gt;

== Ekukhuleni Kwakhe ==
U-Krotoa wabelethwa ngo-c.1642, abelethelwa esitjhabeni sama-Khoekhoe esibizwa bona ma-Goringhaicona. U-Krotoa mtjhana wekosi yesitjhabeso u-Autshumato, naye obekamtologi phakathi wesitjhaba sakhe nesamaDatjhi. Kungenzeka bona u-Krotoa bekatjhidelene khulu nomalumakhe okwamenza wafunda izinto ezinengi kuye, kuhlanganise nokutologa ilimi lesiDatjhi nokufunda isikopilo lawo. Kwathi nakaneminyaka elitjhumi kuya kwelitjhumi nambili, umalumakhe wanikela ngaye ku-Jan Van Riebeeck bona abe mtlhogomeli namkha ikhobokakazi lomkakhe u-Maria de la Quellerie. Lokho kwenzeka emalangeni ambalwa amaDatjhi aqeda ukufika eKapa. Kodwana u-Jan Van Riebeeck uthoma ukukhuluma ngaye edayarinakhe ngenyanga kaTjhirhweni wango-1654, ambiza bona 'mntazana ohlala nathi.' U-Krotoa walifunda ilimi lesiDatjhi begodu walikhuluma kuhle khulu. Bekakghona nokukhuluma isiPutukezi, begodu bekazithoba msinya esikweni lesiKrestu njengokulayelwa kwakhe ngu-Maria.&quot;&lt;ref name=&quot;:0&quot;&gt;South African History Online (21 July 2020), ''Krotoa (Eva).'' Retrieve from: https://sahistory.org.za/people/krotoa-eva. Retrieved on 10/02/2026.&lt;/ref&gt;
[[Isimumathi:Jan_van_Riebeeck_cropped.jpg|thumb|U-Jan Van Riebeeck]]
Ukulikhuluma kwakhe kuhle ilimi lesiDatjhi kwenza bona u-Jan Van Riebeeck amsebenzise khulu njengomtologi lokha nakabamba iinkulumiswano neentjhaba zama-Khoekhoe. Wathoma ukusebezisa u-Krotoa lokha nakaneminyaka eli-15. U-Krotoa ekadlala indima ekulu eenquntweni ebezithathwa maDatjhi. Nabathengiselanako bekunguye otologako. Nanyana kunjalo umsebenzakhe bewungasibulula ngombana bekazithola sele ahlukene phakathi, angazwisisi bona kufuze athembeke kibobani - emaDatjhini awasebenzelako namkha ebantwini bekhabo ama-Khoekhoe. Ngebanga lalokho, womabili amahlangothi bewangamthembi kuhle.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot;&gt;Camissa Museum (2026), ''Krotoa (circa 1642 - 1674)''. Retrieved from: https://camissamuseum.co.za/index.php/7-tributaries/1-cape-indigenous-africans/krotoa. Retrieved on 10/02/2026.&lt;/ref&gt;

Ekuthomeni [[u-Jan Van Riebeeck]] bekakhuluma kuhle ngaye nemisebenzi ayenzako, kodwana ngokukhamba kwesikhathi watjho bona akasamthembi u-Krotoa ngombana bekamane atjela amaDatjhi lokho ebekafuna ukukuzwa. Waveza nokuthi u-Krotoa ubathanda khulu abantu besitjhaba salapho udadwabo ende khona, ekosini u-Oedasoa wesitjhaba sama-''Cochoqua.'' Lokho kuhlanganise nebekhabo ama-''Goringhaicona,'' nama-''‖Ammaqua.''&lt;ref name=&quot;:1&quot; /&gt; Ngakelinye ihlangothi, idayari ka-Van Riebeeck, iveze amezwi wekulumiswano phakathi kuka-Doman oyikosana yama-Khoe no-Krotoa. U-Doman wathi, &quot;Mina ngili-Khoekhoe angisilo iDatjhi, kodwana, wena, Eva, ulinga ukuthandwa Mphathi [u-Van Riebeeck].' Amagama la aveza bona no-Doman bekangamthembi u-Krotoa.&lt;ref name=&quot;:0&quot; /&gt; Kwathi ngemva kokuhlongakala kuka-Doman no-Autshumato, ipilwakhe yaba budisi khulu.

== Umtjhado Wakhe ==
Ngo-1662 u-Krotoa waba mumuntu wokuthoma esitjhabeni sekhabo bona abhajadiswe abe mKrestu esontweni lamaDatjhi, ngemva kwalokho wanikelwa ibizo bona ngu-Eva. Kodwana ngawo umnyaka wokubhajadiswa kwakhe, u-Jan Van Riebeeck wakhamba eKapa, watjhiya u-Krotoa anganabani. Kwahlongozwa bona akasebenzele ozokulandela u-Van Riebeeck esikhundleni, u-Zacharias Wagenaer, kodwana u-Wagenaer khabe angamthembi u-Krotoa. Lokho bekungebanga lokuthi u-Krotoa bekathanda ukuvakatjhela abantu bekhabo khulu. Ipilo beyibudisi khulu ku-Krotoa ngemva kobana u-Autshumato no-Doman bahlongakale. Lokho kwamenza bona abe kuphela komuntu omtologi phakathi kwamaDatjhi nama-Khoekhoe. Ubuhlobo phakathi kweentjhaba ezimbilezi bebuba budisi ngaphandle kwakhe.&lt;ref name=&quot;:0&quot; /&gt;

Kwathi ngomhla wama-26 kuSihlabantangana wango-1664, u-Krotoa wathembisana umtjhado nesotja lomDenitjhi, u-Pieter van Meerhof. Batjhada ngomhla wesi-2 kuMgwengweni ngo-1664 endlini yoMphathi u-Zacharias Wagenaer. I-VOC beyikuthanda ukutjhadiselana nabantu bendabuko, yeke yakhupha ilobolo elikhulu khulu. Umtloli wedayari ka-Wagenaer bewatjho bona 'bekumtjhado wokuthoma wesiKrestu phakathi kwamaDatjhi nabantu bendabuko.' Besele kuminyaka eli-12 u-Jan Van Riebeeck afika eKapa, imitjhado yabantu bendabuko nabamhlophe beyingakavumeleki ngaleso sikhathi. Yeke u-Krotoa waba ngu-Eva Van Meerhof.&lt;ref name=&quot;:0&quot; /&gt; Ngomnyaka olandelako indodakwakhe yabekwa bona ibe sikhulu se-''Robben Island,'' yeke njengabatjhadikazi besele kufuze bathuthele khona. Ngo-1665, sele banabentwana abathathu, indodakwakhe yabulawa epini e-Madagascar. U-Krotoa wagcina abuyele eKapa nabantwana bakhe ngomhla wama-30 kuKhukhulamungu wona umnyaka loyo. Wavunyelwa bona ahlale njengesivakatjhi emzini woMphathi.&lt;ref name=&quot;:2&quot;&gt;Krabgat (2018), ''SOUTH AFRICAN HISTORY: Krotoa, the bridge between European and African culture,'' Steemit Website. Retrieved from: https://steemit.com/history/@krabgat/south-african-history-krotoa-the-bridge-between-european-and-african-culture. Retrieved on 10/02/2026.&lt;/ref&gt;

Isizi nobudisi ebekaqalene nabo, nehloyo ebekanayo ngamaDatjhi kwamenza wathoma ukusela khulu, bewathengisa nedini. Umukghwa wokusela khulu wabonakala ngitjho netafuleni loMphathi. Kwathathwa isiqunto sokobana akhalinywe bona alungise iindlela zakhe. Kunokuthi azilungise, watjhiya abantwana bakhe walinga ukubaleka kodwana wabanjwa wavalelwa ejele lalapho. NgoNtaka womnyaka lowo, u-Krotoa wadingiselwa e-Robben Island ngebanga lokuziphatha kwakhe okumbi. Wahlala lapho bekwaba kuhlongakala kwakhe ngomhla wama-29 kaVelabahlinze 1674. Wabulungwa ngendlela yesiKrestu esontweni elisendaweni etja yamaDatjhi.&lt;ref name=&quot;:2&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>euoxaj5hwe37pgp06iivxabif4uxblb</sha1>
    </revision>
    <revision>
      <id>6162</id>
      <parentid>6161</parentid>
      <timestamp>2026-02-11T15:42:39Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>edited</comment>
      <origin>6162</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6773" sha1="l2ftyf0z1et1zkyw2yc1m8rito0oyvx" xml:space="preserve">[[Isimumathi:Krotoa Picture.jpg|thumb|U-Krotoa]]
'''U-Krotoa''' (amaDatjhi bekalipeleda bunjesi ibizo lakhe - !Goroǀgôas) bekamfazi wom-Khoekhoe owalethwa ngu-Autshumato ku-Jan Van Riebeeck bona azokuba mtlhogomeli womkakhe u-Maria de la Quellerie. Ibizo lakhe lamambala alaziwa kodwana elidume khulu ngilelo amaDatjhi ebekambiza ngalo - u-Eva. [[Ukufika KwamaBhuru ESewula Afrika|Ukufika kwamaDatjhi eSewula Afrika]] kwenza  umfazi lo wadlala indima ekulu ekubeni mtologi phakathi kwesitjhaba samaDatjhi nesama-Khoekhoe, begodu waba ngomunye wabantu abanzima umlando wabo otlolwe phasi maDatjhi. Umalumakhe [[u-Autshumato]] wavuma ukumnikela [[u-Jan Van Riebeeck]] ngombana bekafuna abe mputjuzi wazo zoke iindaba zamaDatjhi nendlelawo yokwenza izinto. Uyingcenye eqakathekileko yomlando oveza ubuhlobo phakathi kwamaDatjhi nama-Khoekhoe.&lt;ref&gt;Cape Town Museum (2021), ''!Goroǀgôas (Krotoa) or Eva van Meerhof''. Retrieved from: https://www.capetownmuseum.org.za/impactfulwomeneng/krotoa-72dn4. Retrieved on 10/02/2026.&lt;/ref&gt;

== Ekukhuleni Kwakhe ==
[[Isimumathi:Jan_van_Riebeeck_cropped.jpg|thumb|U-Jan Van Riebeeck]]
U-Krotoa wabelethwa ngo-c.1642, abelethelwa esitjhabeni sama-Khoekhoe esibizwa bona ma-Goringhaicona. U-Krotoa mtjhana wekosi yesitjhabeso u-Autshumato, naye obekamtologi phakathi wesitjhaba sakhe nesamaDatjhi. Kungenzeka bona u-Krotoa bekatjhidelene khulu nomalumakhe okwamenza wafunda izinto ezinengi kuye, kuhlanganise nokutologa ilimi lesiDatjhi nokufunda isikopilo lawo. Kwathi nakaneminyaka elitjhumi kuya kwelitjhumi nambili, umalumakhe wanikela ngaye ku-Jan Van Riebeeck bona abe mtlhogomeli namkha ikhobokakazi lomkakhe u-Maria de la Quellerie. Lokho kwenzeka emalangeni ambalwa amaDatjhi aqeda ukufika eKapa. Kodwana u-Jan Van Riebeeck uthoma ukukhuluma ngaye edayarinakhe ngenyanga kaTjhirhweni wango-1654, ambiza bona 'mntazana ohlala nathi.' U-Krotoa walifunda ilimi lesiDatjhi begodu walikhuluma kuhle khulu. Bekakghona nokukhuluma isiPutukezi, begodu bekazithoba msinya esikweni lesiKrestu njengokulayelwa kwakhe ngu-Maria.&quot;&lt;ref name=&quot;:0&quot;&gt;South African History Online (21 July 2020), ''Krotoa (Eva).'' Retrieve from: https://sahistory.org.za/people/krotoa-eva. Retrieved on 10/02/2026.&lt;/ref&gt;
[[Isimumathi:Maria Quevellerius (1629-64), eerste vrouw van Jan van Riebeeck, of diens tweede vrouw Maria Scipio (ca. 1630-95) Rijksmuseum SK-A-806.jpeg|thumb|U-Maria de la Queillerie]]
Ukulikhuluma kwakhe kuhle ilimi lesiDatjhi kwenza bona u-Jan Van Riebeeck amsebenzise khulu njengomtologi lokha nakabamba iinkulumiswano neentjhaba zama-Khoekhoe. Wathoma ukusebezisa u-Krotoa lokha nakaneminyaka eli-15. U-Krotoa ekadlala indima ekulu eenquntweni ebezithathwa maDatjhi. Nabathengiselanako bekunguye otologako. Nanyana kunjalo umsebenzakhe bewungasibulula ngombana bekazithola sele ahlukene phakathi, angazwisisi bona kufuze athembeke kibobani - emaDatjhini awasebenzelako namkha ebantwini bekhabo ama-Khoekhoe. Ngebanga lalokho, womabili amahlangothi bewangamthembi kuhle.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot;&gt;Camissa Museum (2026), ''Krotoa (circa 1642 - 1674)''. Retrieved from: https://camissamuseum.co.za/index.php/7-tributaries/1-cape-indigenous-africans/krotoa. Retrieved on 10/02/2026.&lt;/ref&gt;

Ekuthomeni [[u-Jan Van Riebeeck]] bekakhuluma kuhle ngaye nemisebenzi ayenzako, kodwana ngokukhamba kwesikhathi watjho bona akasamthembi u-Krotoa ngombana bekamane atjela amaDatjhi lokho ebekafuna ukukuzwa. Waveza nokuthi u-Krotoa ubathanda khulu abantu besitjhaba salapho udadwabo ende khona, ekosini u-Oedasoa wesitjhaba sama-''Cochoqua.'' Lokho kuhlanganise nebekhabo ama-''Goringhaicona,'' nama-''‖Ammaqua.''&lt;ref name=&quot;:1&quot; /&gt; Ngakelinye ihlangothi, idayari ka-Van Riebeeck, iveze amezwi wekulumiswano phakathi kuka-Doman oyikosana yama-Khoe no-Krotoa. U-Doman wathi, &quot;Mina ngili-Khoekhoe angisilo iDatjhi, kodwana, wena, Eva, ulinga ukuthandwa Mphathi [u-Van Riebeeck].' Amagama la aveza bona no-Doman bekangamthembi u-Krotoa.&lt;ref name=&quot;:0&quot; /&gt; Kwathi ngemva kokuhlongakala kuka-Doman no-Autshumato, ipilwakhe yaba budisi khulu.

== Umtjhado Wakhe ==
Ngo-1662 u-Krotoa waba mumuntu wokuthoma esitjhabeni sekhabo bona abhajadiswe abe mKrestu esontweni lamaDatjhi, ngemva kwalokho wanikelwa ibizo bona ngu-Eva. Kodwana ngawo umnyaka wokubhajadiswa kwakhe, u-Jan Van Riebeeck wakhamba eKapa, watjhiya u-Krotoa anganabani. Kwahlongozwa bona akasebenzele ozokulandela u-Van Riebeeck esikhundleni, u-Zacharias Wagenaer, kodwana u-Wagenaer khabe angamthembi u-Krotoa. Lokho bekungebanga lokuthi u-Krotoa bekathanda ukuvakatjhela abantu bekhabo khulu. Ipilo beyibudisi khulu ku-Krotoa ngemva kobana u-Autshumato no-Doman bahlongakale. Lokho kwamenza bona abe kuphela komuntu omtologi phakathi kwamaDatjhi nama-Khoekhoe. Ubuhlobo phakathi kweentjhaba ezimbilezi bebuba budisi ngaphandle kwakhe.&lt;ref name=&quot;:0&quot; /&gt;

Kwathi ngomhla wama-26 kuSihlabantangana wango-1664, u-Krotoa wathembisana umtjhado nesotja lomDenitjhi, u-Pieter van Meerhof. Batjhada ngomhla wesi-2 kuMgwengweni ngo-1664 endlini yoMphathi u-Zacharias Wagenaer. I-VOC beyikuthanda ukutjhadiselana nabantu bendabuko, yeke yakhupha ilobolo elikhulu khulu. Umtloli wedayari ka-Wagenaer bewatjho bona 'bekumtjhado wokuthoma wesiKrestu phakathi kwamaDatjhi nabantu bendabuko.' Besele kuminyaka eli-12 u-Jan Van Riebeeck afika eKapa, imitjhado yabantu bendabuko nabamhlophe beyingakavumeleki ngaleso sikhathi. Yeke u-Krotoa waba ngu-Eva Van Meerhof.&lt;ref name=&quot;:0&quot; /&gt; Ngomnyaka olandelako indodakwakhe yabekwa bona ibe sikhulu se-''Robben Island,'' yeke njengabatjhadikazi besele kufuze bathuthele khona. Ngo-1665, sele banabentwana abathathu, indodakwakhe yabulawa epini e-Madagascar. U-Krotoa wagcina abuyele eKapa nabantwana bakhe ngomhla wama-30 kuKhukhulamungu wona umnyaka loyo. Wavunyelwa bona ahlale njengesivakatjhi emzini woMphathi.&lt;ref name=&quot;:2&quot;&gt;Krabgat (2018), ''SOUTH AFRICAN HISTORY: Krotoa, the bridge between European and African culture,'' Steemit Website. Retrieved from: https://steemit.com/history/@krabgat/south-african-history-krotoa-the-bridge-between-european-and-african-culture. Retrieved on 10/02/2026.&lt;/ref&gt;

Isizi nobudisi ebekaqalene nabo, nehloyo ebekanayo ngamaDatjhi kwamenza wathoma ukusela khulu, bewathengisa nedini. Umukghwa wokusela khulu wabonakala ngitjho netafuleni loMphathi. Kwathathwa isiqunto sokobana akhalinywe bona alungise iindlela zakhe. Kunokuthi azilungise, watjhiya abantwana bakhe walinga ukubaleka kodwana wabanjwa wavalelwa ejele lalapho. NgoNtaka womnyaka lowo, u-Krotoa wadingiselwa e-Robben Island ngebanga lokuziphatha kwakhe okumbi. Wahlala lapho bekwaba kuhlongakala kwakhe ngomhla wama-29 kaVelabahlinze 1674. Wabulungwa ngendlela yesiKrestu esontweni elisendaweni etja yamaDatjhi.&lt;ref name=&quot;:2&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>l2ftyf0z1et1zkyw2yc1m8rito0oyvx</sha1>
    </revision>
    <revision>
      <id>6489</id>
      <parentid>6162</parentid>
      <timestamp>2026-04-28T13:09:44Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>putting link</comment>
      <origin>6489</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6798" sha1="8fbhmx38djx04r05zbeshg7jdc9b4jv" xml:space="preserve">[[Isimumathi:Krotoa Picture.jpg|thumb|U-Krotoa]]
'''U-Krotoa''' (amaDatjhi bekalipeleda bunjesi ibizo lakhe - !Goroǀgôas) bekamfazi wom-Khoekhoe owalethwa ngu-Autshumato ku-Jan Van Riebeeck bona azokuba mtlhogomeli womkakhe u-Maria de la Quellerie. Ibizo lakhe lamambala alaziwa kodwana elidume khulu ngilelo amaDatjhi ebekambiza ngalo - u-Eva. [[Ukufika KwamaBhuru ESewula Afrika|Ukufika kwamaDatjhi eSewula Afrika]] kwenza  umfazi lo wadlala indima ekulu ekubeni mtologi phakathi kwesitjhaba samaDatjhi nesama-Khoekhoe, begodu waba ngomunye wabantu abanzima umlando wabo otlolwe phasi maDatjhi. Umalumakhe [[u-Autshumato]] wavuma ukumnikela [[u-Jan Van Riebeeck]] ngombana bekafuna abe mputjuzi wazo zoke iindaba zamaDatjhi nendlelawo yokwenza izinto. Uyingcenye eqakathekileko yomlando oveza ubuhlobo phakathi kwamaDatjhi nama-Khoekhoe.&lt;ref&gt;Cape Town Museum (2021), ''!Goroǀgôas (Krotoa) or Eva van Meerhof''. Retrieved from: https://www.capetownmuseum.org.za/impactfulwomeneng/krotoa-72dn4. Retrieved on 10/02/2026.&lt;/ref&gt;

== Ekukhuleni Kwakhe ==
[[Isimumathi:Jan_van_Riebeeck_cropped.jpg|thumb|U-Jan Van Riebeeck]]
U-Krotoa wabelethwa ngo-c.1642, abelethelwa esitjhabeni sama-Khoekhoe esibizwa bona ma-Goringhaicona. U-Krotoa mtjhana wekosi yesitjhabeso u-Autshumato, naye obekamtologi phakathi wesitjhaba sakhe nesamaDatjhi. Kungenzeka bona u-Krotoa bekatjhidelene khulu nomalumakhe okwamenza wafunda izinto ezinengi kuye, kuhlanganise nokutologa ilimi lesiDatjhi nokufunda isikopilo lawo. Kwathi nakaneminyaka elitjhumi kuya kwelitjhumi nambili, umalumakhe wanikela ngaye ku-Jan Van Riebeeck bona abe mtlhogomeli namkha ikhobokakazi lomkakhe u-Maria de la Quellerie. Lokho kwenzeka emalangeni ambalwa amaDatjhi aqeda ukufika eKapa. Kodwana u-Jan Van Riebeeck uthoma ukukhuluma ngaye edayarinakhe ngenyanga kaTjhirhweni wango-1654, ambiza bona 'mntazana ohlala nathi.' U-Krotoa walifunda ilimi lesiDatjhi begodu walikhuluma kuhle khulu. Bekakghona nokukhuluma isiPutukezi, begodu bekazithoba msinya esikweni lesiKrestu njengokulayelwa kwakhe ngu-Maria.&quot;&lt;ref name=&quot;:0&quot;&gt;South African History Online (21 July 2020), ''Krotoa (Eva).'' Retrieve from: https://sahistory.org.za/people/krotoa-eva. Retrieved on 10/02/2026.&lt;/ref&gt;
[[Isimumathi:Maria Quevellerius (1629-64), eerste vrouw van Jan van Riebeeck, of diens tweede vrouw Maria Scipio (ca. 1630-95) Rijksmuseum SK-A-806.jpeg|thumb|U-Maria de la Queillerie]]
Ukulikhuluma kwakhe kuhle ilimi lesiDatjhi kwenza bona u-Jan Van Riebeeck amsebenzise khulu njengomtologi lokha nakabamba iinkulumiswano neentjhaba zama-Khoekhoe. Wathoma ukusebezisa u-Krotoa lokha nakaneminyaka eli-15. U-Krotoa ekadlala indima ekulu eenquntweni ebezithathwa maDatjhi. Nabathengiselanako bekunguye otologako. Nanyana kunjalo umsebenzakhe bewungasibulula ngombana bekazithola sele ahlukene phakathi, angazwisisi bona kufuze athembeke kibobani - emaDatjhini awasebenzelako namkha ebantwini bekhabo ama-Khoekhoe. Ngebanga lalokho, womabili amahlangothi bewangamthembi kuhle.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot;&gt;Camissa Museum (2026), ''Krotoa (circa 1642 - 1674)''. Retrieved from: https://camissamuseum.co.za/index.php/7-tributaries/1-cape-indigenous-africans/krotoa. Retrieved on 10/02/2026.&lt;/ref&gt;

Ekuthomeni [[u-Jan Van Riebeeck]] bekakhuluma kuhle ngaye nemisebenzi ayenzako, kodwana ngokukhamba kwesikhathi watjho bona akasamthembi u-Krotoa ngombana bekamane atjela amaDatjhi lokho ebekafuna ukukuzwa. Waveza nokuthi u-Krotoa ubathanda khulu abantu besitjhaba salapho udadwabo ende khona, ekosini u-Oedasoa wesitjhaba sama-''Cochoqua.'' Lokho kuhlanganise nebekhabo ama-''Goringhaicona,'' nama-''‖Ammaqua.''&lt;ref name=&quot;:1&quot; /&gt; Ngakelinye ihlangothi, idayari ka-Van Riebeeck, iveze amezwi wekulumiswano phakathi kuka-Doman oyikosana yama-Khoe no-Krotoa. U-Doman wathi, &quot;Mina ngili-Khoekhoe angisilo iDatjhi, kodwana, wena, Eva, ulinga ukuthandwa Mphathi [u-Van Riebeeck].' Amagama la aveza bona no-Doman bekangamthembi u-Krotoa.&lt;ref name=&quot;:0&quot; /&gt; Kwathi ngemva kokuhlongakala kuka-Doman no-Autshumato, ipilwakhe yaba budisi khulu.

== Umtjhado Wakhe ==
Ngo-1662 u-Krotoa waba mumuntu wokuthoma esitjhabeni sekhabo bona abhajadiswe abe mKrestu esontweni lamaDatjhi, ngemva kwalokho wanikelwa ibizo bona ngu-Eva. Kodwana ngawo umnyaka wokubhajadiswa kwakhe, u-Jan Van Riebeeck wakhamba eKapa, watjhiya u-Krotoa anganabani. Kwahlongozwa bona akasebenzele ozokulandela u-Van Riebeeck esikhundleni, u-Zacharias Wagenaer, kodwana u-Wagenaer khabe angamthembi u-Krotoa. Lokho bekungebanga lokuthi u-Krotoa bekathanda ukuvakatjhela abantu bekhabo khulu. Ipilo beyibudisi khulu ku-Krotoa ngemva kobana u-Autshumato no-Doman bahlongakale. Lokho kwamenza bona abe kuphela komuntu omtologi phakathi kwamaDatjhi nama-Khoekhoe. Ubuhlobo phakathi kweentjhaba ezimbilezi bebuba budisi ngaphandle kwakhe.&lt;ref name=&quot;:0&quot; /&gt;

Kwathi ngomhla wama-26 kuSihlabantangana wango-1664, u-Krotoa wathembisana umtjhado nesotja lomDenitjhi, [[U-Pieter Van Meerhof|u-Pieter van Meerhof]]. Batjhada ngomhla wesi-2 kuMgwengweni ngo-1664 endlini yoMphathi u-Zacharias Wagenaer. I-VOC beyikuthanda ukutjhadiselana nabantu bendabuko, yeke yakhupha ilobolo elikhulu khulu. Umtloli wedayari ka-Wagenaer bewatjho bona 'bekumtjhado wokuthoma wesiKrestu phakathi kwamaDatjhi nabantu bendabuko.' Besele kuminyaka eli-12 u-Jan Van Riebeeck afika eKapa, imitjhado yabantu bendabuko nabamhlophe beyingakavumeleki ngaleso sikhathi. Yeke u-Krotoa waba ngu-Eva Van Meerhof.&lt;ref name=&quot;:0&quot; /&gt; Ngomnyaka olandelako indodakwakhe yabekwa bona ibe sikhulu se-''Robben Island,'' yeke njengabatjhadikazi besele kufuze bathuthele khona. Ngo-1665, sele banabentwana abathathu, indodakwakhe yabulawa epini e-Madagascar. U-Krotoa wagcina abuyele eKapa nabantwana bakhe ngomhla wama-30 kuKhukhulamungu wona umnyaka loyo. Wavunyelwa bona ahlale njengesivakatjhi emzini woMphathi.&lt;ref name=&quot;:2&quot;&gt;Krabgat (2018), ''SOUTH AFRICAN HISTORY: Krotoa, the bridge between European and African culture,'' Steemit Website. Retrieved from: https://steemit.com/history/@krabgat/south-african-history-krotoa-the-bridge-between-european-and-african-culture. Retrieved on 10/02/2026.&lt;/ref&gt;

Isizi nobudisi ebekaqalene nabo, nehloyo ebekanayo ngamaDatjhi kwamenza wathoma ukusela khulu, bewathengisa nedini. Umukghwa wokusela khulu wabonakala ngitjho netafuleni loMphathi. Kwathathwa isiqunto sokobana akhalinywe bona alungise iindlela zakhe. Kunokuthi azilungise, watjhiya abantwana bakhe walinga ukubaleka kodwana wabanjwa wavalelwa ejele lalapho. NgoNtaka womnyaka lowo, u-Krotoa wadingiselwa e-Robben Island ngebanga lokuziphatha kwakhe okumbi. Wahlala lapho bekwaba kuhlongakala kwakhe ngomhla wama-29 kaVelabahlinze 1674. Wabulungwa ngendlela yesiKrestu esontweni elisendaweni etja yamaDatjhi.&lt;ref name=&quot;:2&quot; /&gt;

== Iinkhombo ==
&lt;references /&gt;</text>
      <sha1>8fbhmx38djx04r05zbeshg7jdc9b4jv</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:SANKOMOTA</title>
    <ns>2</ns>
    <id>1034</id>
    <revision>
      <id>6164</id>
      <timestamp>2026-02-14T11:46:51Z</timestamp>
      <contributor>
        <username>SANKOMOTA</username>
        <id>1363</id>
      </contributor>
      <comment>Created page with &quot;'''Mofokeng diphapang''' born 1978&lt;ref&gt;https://mg.co.za/friday/2026-01-23-africa-takes-its-seat-at-wikimedia/&lt;/ref&gt;&quot;</comment>
      <origin>6164</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="115" sha1="af3903ulc85dqsr9nj2mncpojpw0zlm" xml:space="preserve">'''Mofokeng diphapang''' born 1978&lt;ref&gt;https://mg.co.za/friday/2026-01-23-africa-takes-its-seat-at-wikimedia/&lt;/ref&gt;</text>
      <sha1>af3903ulc85dqsr9nj2mncpojpw0zlm</sha1>
    </revision>
    <revision>
      <id>6165</id>
      <parentid>6164</parentid>
      <timestamp>2026-02-14T11:48:18Z</timestamp>
      <contributor>
        <username>SANKOMOTA</username>
        <id>1363</id>
      </contributor>
      <origin>6165</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="130" sha1="hmboecratbv1xjjtcc6cy91yyx9kdt1" xml:space="preserve">'''Mofokeng diphapang''' born 1978&lt;ref&gt;https://mg.co.za/friday/2026-01-23-africa-takes-its-seat-at-wikimedia/&lt;/ref&gt;

== Mehlodi ==</text>
      <sha1>hmboecratbv1xjjtcc6cy91yyx9kdt1</sha1>
    </revision>
    <revision>
      <id>6166</id>
      <parentid>6165</parentid>
      <timestamp>2026-02-14T11:51:24Z</timestamp>
      <contributor>
        <username>SANKOMOTA</username>
        <id>1363</id>
      </contributor>
      <origin>6166</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="49" sha1="eb385ondfrbyudl3bj5ysx5ptb42dhi" xml:space="preserve">'''Mofokeng diphapang''' born 1978

== Mehlodi ==</text>
      <sha1>eb385ondfrbyudl3bj5ysx5ptb42dhi</sha1>
    </revision>
  </page>
  <page>
    <title>ILanga Le-Valentine</title>
    <ns>0</ns>
    <id>1035</id>
    <revision>
      <id>6169</id>
      <timestamp>2026-02-16T16:07:34Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>New article</comment>
      <origin>6169</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3735" sha1="4yjgebx7g61zcmn1mhpwnez9waguurf" xml:space="preserve">[[Isimumathi:Antique_Valentine_1909_01.jpg|thumb|Ikarada le-Valentine lango-1909]]
'''Ilanga le-Valentine''' lilanga elaziwa ngokuthi lilalanga leenthandani eligidingwa ephasini mazombe ngomhla we-14 kuMhlolanja. Lilanga lapho iinthandani eziphana khona izipho njengendlela yokutjengisana ithando. Abantu abanengi bakholelwa bona ilangelilasungulwa ngesikhathi kubulawa u-Saint Valentine, umphristi omKrestu ngebanga lokutjhadisa abantu abathandanako esiphirini embusweni weRoma. UmBuso weRoma bewalela amadoda bona atjhade ngebanga lokuthi kufuze aye epini. Yeke ukutjhadisa amadoda lawo bekuphambana nomthetho wamaRoma. Ngilokho-ke okwafaka u-Saint Valentine ekingeni, wagcina sele alahlekelwa nayipilwakhe. Kodwana zinengi izinto ezicatjangelwako emlandweni ezaba mthelela ekusungulweni kwelangeli.&lt;ref name=&quot;:0&quot;&gt;History.com (2026)''History of Valentine’s Day.'' Retrieved from: https://www.history.com/articles/history-of-valentines-day. Retrieved on 16/02/2026.&lt;/ref&gt;

== Umlando Ka-Valentine ==
[[Isimumathi:Saint_Valentine_-_facial_reconstruction.jpg|thumb|Isithombe esakhwe kabutjha sika-Saint Valentine]]
Nanyana kunabantu abambalwa abamaKrestu ababulawelwa ukukholwa kwabo ababizwa ngabo-Valentine, ilangeli kungenzeka lasungulwa lisuselwa emphristini owabulawa ngo 270 AD, abulawa mbusi u-Claudius II Gothicus. Endabeni ecocwako, umphristi lo watlikitla incwadi ngokuthi &quot;ivela ku-Valentine wakho&quot; ayitlolela indodakazi yomuntu omfake ejele, ebesele amngani nayo, kokunye ukulandisa okuthiwa wayelapha bona ikghone ukubona ngombana beyiphophele. Kokunye ukulandisa kuthiwa ngu-St Valentine ombhitjhobhu ovela endaweni ye-Temi, okunguye ilangeli elibizwa ngaye, nanyana kungenzeka bona abantwaba bamumuntu munye. Omunye umlando uthi u-St Valentine khenge alalele umthetho wekosi, bewatjhadisa iinthandani esiphirini, okwenza bona amadoda atjhadileko angayi epini. Kwathi bona atholakale, wagwetjelwa ukufa. Kungenzeka ngilesi sizathu ilangeli lihlobene nethando kangaka.&lt;ref&gt;Britannica (2026) ''Valentines Day.'' Retrieved from: https://www.britannica.com/topic/Valentines-Day. Retrieved on 16/02/2026.&lt;/ref&gt;

== Umlando Womnyanya WamaRoma ==
Eqinisweni, amaRoma asabusa, bekunomnyanya wamaRoma ebewubizwa bona mNyanya ka-Lupercalia. Amadoda bekahlaba imbuzi nenja, bomise iinkhumba zazo, bese bayazisika zibe mimitja. Amadoda ngelangelo bekagijima endleleni bese barithe abafazi ngemitja yeenkhumbezo. Umnyanya lo bewenziwa ngomhla we-13 kuya ngowe-15 kuMhlolanja. Ngalesosikhathi kuthiwa abafazi bebakuthanda ukurithwa ngeenkhumbezi ngombana bebakholelwa ukuthi bazokuba nembeleko emnyakeni olandelako.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot;&gt;Arnie Seipel (14 February 2022) ''The dark origins of Valentine's Day,'' NPR. Retrieved from: https://www.npr.org/2011/02/14/133693152/the-dark-origins-of-valentines-day. Retreived on 16/02/2026.&lt;/ref&gt;

Ngokuka-Noel Lenski, onguphrofesa weemfundo zezekolo e-Yale University, atjela i-NPR ngo-2011, uthi amaRoma 'bewasela adakwe, abe hlubule.' Abafazi bebajama babe mjeje, bajamele bona amadoda abarithe ngemitja yesikhumba seenlwana.&lt;ref name=&quot;:1&quot; /&gt; Umnyanya lowo bewuphetha ngekatho eyenziwa madoda, ngokukhetha amagama wabafazi angaphakathi emjekeni. Umfazi omkhethileko uzokuthandana naye emnyanyeni loyo kwaphela, namkha isikhathi eside nangabe niyakhambelana.&lt;ref name=&quot;:1&quot; /&gt;

Nanyana amaKrestu andlondlobala, umnyanya lo bewusolo ukhona bekwafika lapha kuthiwa khona umnyanya lo awusiwo wobuKrestu, ekugcineni kweminyaka yama-500 AD, lokha uPapa u-Gelasius aqunta bona umhla we-14 kaMhlolanja sele kulilanga okuzokugidingwa ngalo u-St Valentine. Nanyana kunjalo kwakhamba iminyaka eminengi khulu ngaphambi kobana ilangeli lihlotjaniswe nethando.&lt;ref name=&quot;:0&quot; /&gt;

== Iinkhombo ==</text>
      <sha1>4yjgebx7g61zcmn1mhpwnez9waguurf</sha1>
    </revision>
    <revision>
      <id>6170</id>
      <parentid>6169</parentid>
      <timestamp>2026-02-16T16:11:22Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>edited</comment>
      <origin>6170</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3758" sha1="orw0dmr3r1g1hyxkhy1uqbne8sklkwe" xml:space="preserve">[[Isimumathi:Antique_Valentine_1909_01.jpg|thumb|Ikarada le-Valentine lango-1909]]
'''Ilanga le-Valentine''' lilanga elaziwa ngokuthi lilalanga leenthandani eligidingwa ephasini mazombe ngomhla we-14 kuMhlolanja. Lilanga lapho iinthandani eziphana khona izipho njengendlela yokutjengisana ithando. Abantu abanengi bakholelwa bona ilangelilasungulwa ngesikhathi kubulawa u-Saint Valentine, umphristi omKrestu ngebanga lokutjhadisa abantu abathandanako esiphirini embusweni weRoma. UmBuso weRoma bewalela amadoda bona atjhade ngebanga lokuthi kufuze aye epini. Yeke ukutjhadisa amadoda nabafazi ababathandana nawo bekuphambana nomthetho wamaRoma. Ngilokho-ke okwafaka u-Saint Valentine ekingeni, wagcina sele alahlekelwa nayipilwakhe. Kodwana zinengi izinto ezicatjangelwako emlandweni ezaba mthelela ekusungulweni kwelangeli.&lt;ref name=&quot;:0&quot;&gt;History.com (2026)''History of Valentine’s Day.'' Retrieved from: https://www.history.com/articles/history-of-valentines-day. Retrieved on 16/02/2026.&lt;/ref&gt;

== Umlando Ka-Valentine ==
[[Isimumathi:Saint_Valentine_-_facial_reconstruction.jpg|thumb|Isithombe esakhwe kabutjha sika-Saint Valentine]]
Nanyana kunabantu abambalwa abamaKrestu ababulawelwa ukukholwa kwabo ababizwa ngabo-Valentine, ilangeli kungenzeka lasungulwa lisuselwa emphristini owabulawa ngo 270 AD, abulawa mbusi u-Claudius II Gothicus. Endabeni ecocwako, umphristi lo watlikitla incwadi ngokuthi &quot;ivela ku-Valentine wakho&quot; ayitlolela indodakazi yomuntu omfake ejele, ebesele amngani nayo, kokunye ukulandisa okuthiwa wayelapha bona ikghone ukubona ngombana beyiphophele. Kokunye ukulandisa kuthiwa ngu-St Valentine ombhitjhobhu ovela endaweni ye-Temi, okunguye ilangeli elibizwa ngaye, nanyana kungenzeka bona abantwaba bamumuntu munye. Omunye umlando uthi u-St Valentine khenge alalele umthetho wekosi, bewatjhadisa iinthandani esiphirini, okwenza bona amadoda atjhadileko angayi epini. Kwathi bona atholakale, wagwetjelwa ukufa. Kungenzeka ngilesi sizathu ilangeli lihlobene nethando kangaka.&lt;ref&gt;Britannica (2026) ''Valentines Day.'' Retrieved from: https://www.britannica.com/topic/Valentines-Day. Retrieved on 16/02/2026.&lt;/ref&gt;

== Umlando Womnyanya WamaRoma ==
Eqinisweni, amaRoma asabusa, bekunomnyanya wamaRoma ebewubizwa bona mNyanya ka-Lupercalia. Amadoda bekahlaba imbuzi nenja, bomise iinkhumba zazo, bese bayazisika zibe mimitja. Amadoda ngelangelo bekagijima endleleni bese barithe abafazi ngemitja yeenkhumbezo. Umnyanya lo bewenziwa ngomhla we-13 kuya ngowe-15 kuMhlolanja. Ngalesosikhathi kuthiwa abafazi bebakuthanda ukurithwa ngeenkhumbezi ngombana bebakholelwa ukuthi bazokuba nembeleko emnyakeni olandelako.&lt;ref name=&quot;:0&quot; /&gt;&lt;ref name=&quot;:1&quot;&gt;Arnie Seipel (14 February 2022) ''The dark origins of Valentine's Day,'' NPR. Retrieved from: https://www.npr.org/2011/02/14/133693152/the-dark-origins-of-valentines-day. Retreived on 16/02/2026.&lt;/ref&gt;

Ngokuka-Noel Lenski, onguphrofesa weemfundo zezekolo e-Yale University, atjela i-NPR ngo-2011, uthi amaRoma 'bewasela adakwe, abe hlubule.' Abafazi bebajama babe mjeje, bajamele bona amadoda abarithe ngemitja yesikhumba seenlwana.&lt;ref name=&quot;:1&quot; /&gt; Umnyanya lowo bewuphetha ngekatho eyenziwa madoda, ngokukhetha amagama wabafazi angaphakathi emjekeni. Umfazi omkhethileko uzokuthandana naye emnyanyeni loyo kwaphela, namkha isikhathi eside nangabe niyakhambelana.&lt;ref name=&quot;:1&quot; /&gt;

Nanyana amaKrestu andlondlobala, umnyanya lo bewusolo ukhona bekwafika lapha kuthiwa khona umnyanya lo awusiwo wobuKrestu, ekugcineni kweminyaka yama-500 AD, lokha uPapa u-Gelasius aqunta bona umhla we-14 kaMhlolanja sele kulilanga okuzokugidingwa ngalo u-St Valentine. Nanyana kunjalo kwakhamba iminyaka eminengi khulu ngaphambi kobana ilangeli lihlotjaniswe nethando.&lt;ref name=&quot;:0&quot; /&gt;

== Iinkhombo ==</text>
      <sha1>orw0dmr3r1g1hyxkhy1uqbne8sklkwe</sha1>
    </revision>
  </page>
  <page>
    <title>Gcina Mhlophe</title>
    <ns>0</ns>
    <id>1036</id>
    <revision>
      <id>6171</id>
      <timestamp>2026-02-16T17:27:23Z</timestamp>
      <contributor>
        <username>Nhlanhla NaLamula</username>
        <id>1365</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1336958516|Gcina Mhlophe]]&quot;</comment>
      <origin>6171</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8992" sha1="gsp4vca2er8czcty5dcl0mwzf4ibxwz" xml:space="preserve">{{Short description|South African playwright, author mime and poet (born 1958)}}  
U '''-Gcina Mhlophe''' (wabelethwa mhlana malanga ama-24 kuSewula 1958) mtloli weendaba, umtloli, umtloli wemidlalo, nomlingisi weSewula Afrika. Ngomnyaka ka-2016, wabhalwa njengomunye wabafazi abali-100 be-BBC . Ukhuluma iindaba zakhe ngeenlimi ezine zeSewula Afrika: isiNgisi, isiBhunu, isiZulu nesiXhosa, begodu usiza nokukhuthaza abantwana ukufunda.

== Ipilo yokuthoma ==
U-Nokugcina Elsie Mhlophe wabelethwa mhlana amalanga ama-24 kuNobayeni wee-1958 e-Hammarsdale, e-KwaZulu-Natal,  kumma oM -Xhosa nobaba oMZulu . Ubaba ka-Gcina bekasebenza enkampanini yamafutha e-Jacobs, e-South Durban basin, ngesikhathi unina asebenza njengesisebenzi sangekhaya. Wabelethwa ngaphandle komtjhado, wahlukana nonina nakaneminyaka emibili, wayokuhlala noyise, obekatjhadile anabantwana ababu-8. 

Wathoma ipilo yakhe yokusebenza njengesisebenzi sangekhaya,  begodu azange avakatjhele ilayibrari bekwaba kulapho aneminyaka ema-20. 

== Ibizelo ==
U-Mhlophe bekasebenza njengomfundi weendaba e-Press Trust ne -BBC Radio . Kusukela ngo-1982 ukuya ku-1983, bekamtloli wemagazini ethi &quot;Learn and Teach&quot;. 

Wathoma ukuzwisisa ukufunwa kweendaba ngesikhathi ase- Chicago ngo-1988. Wadlala emtatjweni weencwadi endaweni ehlala abantu abanzima, lapho ababukeli bebahlala bammema khona. Nanyana kunjalo, u-Mhlophe wathoma ukucabanga ngokucoca iindaba njengomsebenzi ngemva kokuhlangana no- Imbongi, omunye weembongi ezidumileko zeendatjana ze-Afrika, begodu ngemva kokukhuthazwa ngu- Mannie Manim, obegade angumnqophisi we -Market Theatre, [[Johannesburg|e-Jwanasbege]]. Kusukela ngo-1989 ukuya ku-1990, bekangumnqophisi ohlala e- Market Theatre . 

U-Mhlophe uvele emathiyetha ukusuka e-Soweto ukuya e-London, begodu umsebenzi wakhe omnengi utjhugululwe ngesiJarimani, isiFulentshi, isiNtaliyane, isiSwahili, nesiJapanese . Ukhambe khulu e [[I-Afrika|-Afrika]] nezinye iindawo zomhlaba anikela ngemihlangano yokucoca iindaba.

Iindatjana zaka-Mhlophe zihlanganisa iindatjana, ilwazi, iindaba zanje, ingoma, [[Idiom|nezitjho]] . Ukucoca iindatjana msebenzi wesintu khulu [[Isewula Afrika|eSewula Afrika]], begodu u-Mhlophe ngomunye wabafazi abambalwa abacoca iindatjana enarheni ebuswa babantu abaduna. Wenza umsebenzi wakhe ngokudlala okuthakazelisako, asebenzela ukubulunga ukucoca iindaba njengendlela yokugcina umlando uphila nokukhuthaza abantwana beSewula Afrika bona bafunde. Ukhuluma iindaba zakhe ngeenlimi ezine zeSewula Afrika: [[Ilimi lesiNgisi|isiNgisi]], isiBhunu, isiZulu nesiXhosa .

Ukutlola kwakhe kuvele kukhongozeloelifaka hlangana ''i-A Land Apart: A South African Reader'' (eds André Brink and JM Coetzee, London: Faber and Faber, 1986), ''Daughters of Africa'' (ed. Margaret Busby, London: Jonatan Cape, 1992) kanye ne ''-Women Writing Africa: The Southern Region'' (Margaret: Margaret Day, 1992). Witwatersrand University Press, 2002).

== Eminye imisebenzi ==
UMhlophe weluleka abantu abatjha, athuthukise amakgono asesematjha ukuthi aragele phambili ngomsebenzi wokucoca iindatjana nge-Zanendaba (&quot;Bring me a story&quot;) esisungulo. Isisungulo lesi, esasungulwa ngo-2002, sisebenzisana ne-Market Theatre kanye [[READ Educational Trust|ne-READ]], ihlangano yeentjhabatjhaba yokufunda nokutlola.

Njenganje  usebenza njengomxhasi we- ASSITEJ South Africa, i-International Association for Theatre for Children and Young People.

Uphethe indawo yokudlalela ebizwa nge-&quot;The Storytelling Tree&quot; eThekwini . 

Usebenza njengesikhulumi esikhuthazako . 

Kusukela ngomnyaka ka-2019,  ilanga lokubelethwa laka-Mhlophe, mhlana amalanga ama-24 kuNobayeni, likhunjulwa njengelanga leNarha lokuTjheja iindatjana eSewula Afrika. 

Kusuka ngo-2023[ilwazi lamva], UMhlophe watlomelwa [[Honorary doctorate|nge-honorary doctorates]]  kumayunivesithi alikhomba emhlabeni. Kufaka hlangana:

Okhunye ukuhlonitjhwa komsebenzi wakhe kufaka hlangana:

* 1987: Umvuzo we-Obie wokusebenza kuhle komlingisi ( i-New York City ) nge ''-Born in the RSA'' 
* 1988: U-Joseph Jefferson Award we-Best Actress ( Chicago ) nge- ''Have seen Zandile?''
* 198?: Umvuzo we-Sony we-Radio Drama ovela ku-BBC Radio Africa nge- ''Have seen Zandile?''
* 1990: Umvuzo wokuthoma we-Fringe (Edinburgh) ''we-Have seen Zandile?''
* 1991: Umkhethi, umvuzo we-Noma, we ''-Queen of the Tortoises''
* 1991, i-Ashoka Fellowship (umsunguli wezamabhizinisi wezenhlalakahle)
* 1994: Umvuzo we-Book Chat we ''-Molo Zoleka''
* 2016: Wabizwa njengomunye wabafazi abali-100 be-BBC 
* 2018: Umvuzo wokuthoma we-USIBA Cultural Legend, ovela kuNgqongqotjhe wezobuKghwari namaSiko 
* I-SAFTA Lifetime Achievement Award. 

== Imidlalo ekhethiweko ==

* 1983, indima ephambili ku- ''Umongikazi: The Nurse'', ka- Maishe Maponya 
* 1984, ku- ''Black Dog: Inj'emnyama''
* 1986, ''Indawo yokulila'' (ifilimu)
* 1986, ''Ukhe Wambona UZandile?'' (umdlalo wokuziphilela, e-Market Theatre, e-Goli, u-Mhlophe njengo-Zandile) 
* 1987, ''Wabelethwa e-RSA'' (New York)
* 1989, umnyanya wokucoca iindaba e-Market Theatre
* 1989, wenza ikondlo yokuhlonipha u- Albert Luthuli, umnqobi we-Nobel Peace Prize ka-1960
* 1990, yenza i- ''Have You Seen Zandile?'' emnyanyeni we -Edinburgh Festival e-Europe ne-USA 
* 1997, Inkondlo ye-Afrika, eveza imbongi
* 1999, isikhulumi sesivakatjhi emnyanyeni wabatloli be-Perth
* 2000, eyenziwa ku- ''Peter und der Wolf'' e- Komische Oper (Berlin)
* 2002, ''Amathambo weKhumbuzo'' (ukudlala, ukulandisa umlando ukusuka eSewula Afrika endala netjha)
* 2003, wafundisa ngokucoca iindaba emhlanganweni we- ''Eye of the Beholder''
* 2003, ''uMata Mata'' (ukudlala, umvumo womndeni)
* 2006, umnyanya weNdebe yePhasi ye-FIFA eSewula Afrika, e-Germany 
* 2016, ''Kalushi'' (ifilimu) 
* 2017, ''i-Liyana'', ifilimu ye-multimedia ka- Aaron Kopp &lt;ref name=&quot;about&quot; /&gt;

=== Ukuvela kwedokhumenthri ===

* Wadlala begodu walandisa ku-Traveling ''Songs''
* 1990, wenza iinkondlo ku- ''Songololo: Amaphimbo weTjhuguluko'' (indlela amasiko weSewula Afrika aba yingcenye yomzabalazo wokulwisana nebandlululo) 
* 1993, ''Ingoma eKhambako'' (ikambiso yesimanje yokubuthelela iindaba)
* Uvele ku-Literacy ''Alive''
* Uvele ku ''-Art Works''

== Ukurekhoda ==
UMhlophe watlola umvumo womlandelande wakhe we -SABC TV ''Gcina &amp; Friends''

* 1993, ''Umvumo wabantu abancani'' (CD)
* 1993, ilizwi lomfundi ''Akusi msinya kangako, Songololo'' (videorekhodi), Weston Woods, Weston CT, Scholastic
* 1994, ''I-The Gift of the Tortoise'' (efakwe isandla ku-albhamu ye- Ladysmith Black Mambazo )
* 2002, ''i-Fudukazi's Magic'' itjengiswe e- Durban ku-African Union Film Festival

== Ukusebenzisana ==

* U-Pops Mohamed, umvumi nomlondolozi womculo weentjhaba
* I-Ladysmith Black Mambazo, isiqhema sekhwaya, ''i-The Gift of the Tortoise'' (CD), 1994 kanye ''ne-Music for Little People in America'' (CD), 1993
* U-Anant Singh, umkhiqizi wevidiyo, ''i-Fudukazi's Magic'' (i-CD nevidiyo yababukeli be-German)

== Isilululwazi ==

* ''Ithoyilethi'' 1987 (indatjana efitjhani) 
* ''Molo! Zoleka'' New Africa Education, 1994. (Incwadi yabantwana) 
* ''UMaZanendaba kanye negobolondo lendaba yemilingo'' (incwadi yabantwana) 
* ''Inyoka eneenhloko ezilikhomba'' . I-Johannesburg: Skotaville Publishers, 1989. (Incwadi yabantwana, etjhugululwe ngeenlimi ezihlanu ze-Afrika, i-edishini yesiNgisi iyatlhogeka kiwo woke amalayibhrari weenkolo weSewula Afrika) 
* ''Ukhe wambona na uZandile?'' . I-Portsmouth, NH: Heinemann, 1990. (Ukudlala, okusekelwe ebuntwaneni bakhe, okutlhogekako emalayibhrari weyunivesithi yeSewula Afrika) 
* ''INdlovukazi yamaFudu'' . I-Johannesburg: Skotaville, 1990. (Ibhuku labantwana) 
* ''Inja Ehlabelako'' . Idwetshwe ngu-Erica Maritz no-Andries Maritz. I-Johannesburg: Skotaville, 1992. (Ibhuku labantwana) 
* ''UNalohima, iFudu elingazwako'' . Gamsberg Macmillan, 1999. 
* ''Umlingo ka-Fudukazi'' . Cambridge: Cambridge University Press, 1999. (CD – amagama nomvumo, ukudlala) 
* ''Umlingo ka-Fudukazi'' . I-Cambridge University Press, 2000 (i-CD – amagama nomvumo, ukudlala, kwababukeli be-German)
* ''UNozi, Umama weencwadi'' . U-Maskew Miller Longman, 2001. (CD nencwadi, umdlalo weSewula Afrika ukuya eenkolweni zemakhaya) 
* ''Umama kaKresmusi we-Afrika'' . Maskew Miller Longman, 2002. (CD nencwadi) 
* ''Thanda Umntwana'' . I-Durban: University of Natal Press, 2002. (Imemori, iqoqo leendaba) 
* ''Iindaba ze-Afrika'' . I-University of Natal Press, 2003. (Incwadi yabantwana) 
* ''INdlovukazi ye-Imbira'' . Maskew Miller Longman, 2003. (Incwadi yabantwana) 
* ''Iingoma neendatjana ze-Afrika'' – Umnqobi wemitlomelo yomvumo weSewula Afrika ka-2010 nge-albhamu ehle khulu yabantwana be-English – umvumo we-Afrika okhilimu 

== Qala godu ==

* Irhelo labatloli be-Afrika
* Abantu abadumileko beSewula Afrika
* Iinkondlo i-Afrika

== Iinkomba ==
{{Reflist}}

== Yini eyamkhuthaza ukutlola ==

* Official website
* [https://web.archive.org/web/20120620010949/http://badilishapoetry.com/artists-profile/51/ Badilisha Poetry Exchange] Profile and podcast</text>
      <sha1>gsp4vca2er8czcty5dcl0mwzf4ibxwz</sha1>
    </revision>
    <revision>
      <id>6172</id>
      <parentid>6171</parentid>
      <timestamp>2026-02-16T17:44:47Z</timestamp>
      <contributor>
        <username>Nhlanhla NaLamula</username>
        <id>1365</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1336958516|Gcina Mhlophe]]&quot;</comment>
      <origin>6172</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8994" sha1="9npyi6r3occ2xueww8tuctuakvdcln2" xml:space="preserve">{{Short description|South African playwright, author mime and poet (born 1958)}}  
U '''-Gcina Mhlophe''' (wabelethwa mhlana malanga ama-24 kuSewula 1958) mcoci weendatjana, umtloli, umtloli wemidlalo, nomlingisi weSewula Afrika. Ngomnyaka ka-2016, wabhalwa njengomunye wabafazi abali-100 be-BBC . Ukhuluma iindaba zakhe ngeenlimi ezine zeSewula Afrika: isiNgisi, isiBhunu, isiZulu nesiXhosa, begodu usiza nokukhuthaza abantwana ukufunda.

== Ipilo yokuthoma ==
U-Nokugcina Elsie Mhlophe wabelethwa mhlana amalanga ama-24 kuNobayeni wee-1958 e-Hammarsdale, e-KwaZulu-Natal,  kumma oM -Xhosa nobaba oMZulu . Ubaba ka-Gcina bekasebenza enkampanini yamafutha e-Jacobs, e-South Durban basin, ngesikhathi unina asebenza njengesisebenzi sangekhaya. Wabelethwa ngaphandle komtjhado, wahlukana nonina nakaneminyaka emibili, wayokuhlala noyise, obekatjhadile anabantwana ababu-8. 

Wathoma ipilo yakhe yokusebenza njengesisebenzi sangekhaya,  begodu azange avakatjhele ilayibrari bekwaba kulapho aneminyaka ema-20. 

== Ibizelo ==
U-Mhlophe bekasebenza njengomfundi weendaba e-Press Trust ne -BBC Radio . Kusukela ngo-1982 ukuya ku-1983, bekamtloli wemagazini ethi &quot;Learn and Teach&quot;. 

Wathoma ukuzwisisa ukufunwa kweendaba ngesikhathi ase- Chicago ngo-1988. Wadlala emtatjweni weencwadi endaweni ehlala abantu abanzima, lapho ababukeli bebahlala bammema khona. Nanyana kunjalo, u-Mhlophe wathoma ukucabanga ngokucoca iindaba njengomsebenzi ngemva kokuhlangana no- Imbongi, omunye weembongi ezidumileko zeendatjana ze-Afrika, begodu ngemva kokukhuthazwa ngu- Mannie Manim, obegade angumnqophisi we -Market Theatre, [[Johannesburg|e-Jwanasbege]]. Kusukela ngo-1989 ukuya ku-1990, bekangumnqophisi ohlala e- Market Theatre . 

U-Mhlophe uvele emathiyetha ukusuka e-Soweto ukuya e-London, begodu umsebenzi wakhe omnengi utjhugululwe ngesiJarimani, isiFulentshi, isiNtaliyane, isiSwahili, nesiJapanese . Ukhambe khulu e [[I-Afrika|-Afrika]] nezinye iindawo zomhlaba anikela ngemihlangano yokucoca iindaba.

Iindatjana zaka-Mhlophe zihlanganisa iindatjana, ilwazi, iindaba zanje, ingoma, [[Idiom|nezitjho]] . Ukucoca iindatjana msebenzi wesintu khulu [[Isewula Afrika|eSewula Afrika]], begodu u-Mhlophe ngomunye wabafazi abambalwa abacoca iindatjana enarheni ebuswa babantu abaduna. Wenza umsebenzi wakhe ngokudlala okuthakazelisako, asebenzela ukubulunga ukucoca iindaba njengendlela yokugcina umlando uphila nokukhuthaza abantwana beSewula Afrika bona bafunde. Ukhuluma iindaba zakhe ngeenlimi ezine zeSewula Afrika: [[Ilimi lesiNgisi|isiNgisi]], isiBhunu, isiZulu nesiXhosa .

Ukutlola kwakhe kuvele kukhongozeloelifaka hlangana ''i-A Land Apart: A South African Reader'' (eds André Brink and JM Coetzee, London: Faber and Faber, 1986), ''Daughters of Africa'' (ed. Margaret Busby, London: Jonatan Cape, 1992) kanye ne ''-Women Writing Africa: The Southern Region'' (Margaret: Margaret Day, 1992). Witwatersrand University Press, 2002).

== Eminye imisebenzi ==
UMhlophe weluleka abantu abatjha, athuthukise amakgono asesematjha ukuthi aragele phambili ngomsebenzi wokucoca iindatjana nge-Zanendaba (&quot;Bring me a story&quot;) esisungulo. Isisungulo lesi, esasungulwa ngo-2002, sisebenzisana ne-Market Theatre kanye [[READ Educational Trust|ne-READ]], ihlangano yeentjhabatjhaba yokufunda nokutlola.

Njenganje  usebenza njengomxhasi we- ASSITEJ South Africa, i-International Association for Theatre for Children and Young People.

Uphethe indawo yokudlalela ebizwa nge-&quot;The Storytelling Tree&quot; eThekwini . 

Usebenza njengesikhulumi esikhuthazako . 

Kusukela ngomnyaka ka-2019,  ilanga lokubelethwa laka-Mhlophe, mhlana amalanga ama-24 kuNobayeni, likhunjulwa njengelanga leNarha lokuTjheja iindatjana eSewula Afrika. 

Kusuka ngo-2023[ilwazi lamva], UMhlophe watlomelwa [[Honorary doctorate|nge-honorary doctorates]]  kumayunivesithi alikhomba emhlabeni. Kufaka hlangana:

Okhunye ukuhlonitjhwa komsebenzi wakhe kufaka hlangana:

* 1987: Umvuzo we-Obie wokusebenza kuhle komlingisi ( i-New York City ) nge ''-Born in the RSA'' 
* 1988: U-Joseph Jefferson Award we-Best Actress ( Chicago ) nge- ''Have seen Zandile?''
* 198?: Umvuzo we-Sony we-Radio Drama ovela ku-BBC Radio Africa nge- ''Have seen Zandile?''
* 1990: Umvuzo wokuthoma we-Fringe (Edinburgh) ''we-Have seen Zandile?''
* 1991: Umkhethi, umvuzo we-Noma, we ''-Queen of the Tortoises''
* 1991, i-Ashoka Fellowship (umsunguli wezamabhizinisi wezenhlalakahle)
* 1994: Umvuzo we-Book Chat we ''-Molo Zoleka''
* 2016: Wabizwa njengomunye wabafazi abali-100 be-BBC 
* 2018: Umvuzo wokuthoma we-USIBA Cultural Legend, ovela kuNgqongqotjhe wezobuKghwari namaSiko 
* I-SAFTA Lifetime Achievement Award. 

== Imidlalo ekhethiweko ==

* 1983, indima ephambili ku- ''Umongikazi: The Nurse'', ka- Maishe Maponya 
* 1984, ku- ''Black Dog: Inj'emnyama''
* 1986, ''Indawo yokulila'' (ifilimu)
* 1986, ''Ukhe Wambona UZandile?'' (umdlalo wokuziphilela, e-Market Theatre, e-Goli, u-Mhlophe njengo-Zandile) 
* 1987, ''Wabelethwa e-RSA'' (New York)
* 1989, umnyanya wokucoca iindaba e-Market Theatre
* 1989, wenza ikondlo yokuhlonipha u- Albert Luthuli, umnqobi we-Nobel Peace Prize ka-1960
* 1990, yenza i- ''Have You Seen Zandile?'' emnyanyeni we -Edinburgh Festival e-Europe ne-USA 
* 1997, Inkondlo ye-Afrika, eveza imbongi
* 1999, isikhulumi sesivakatjhi emnyanyeni wabatloli be-Perth
* 2000, eyenziwa ku- ''Peter und der Wolf'' e- Komische Oper (Berlin)
* 2002, ''Amathambo weKhumbuzo'' (ukudlala, ukulandisa umlando ukusuka eSewula Afrika endala netjha)
* 2003, wafundisa ngokucoca iindaba emhlanganweni we- ''Eye of the Beholder''
* 2003, ''uMata Mata'' (ukudlala, umvumo womndeni)
* 2006, umnyanya weNdebe yePhasi ye-FIFA eSewula Afrika, e-Germany 
* 2016, ''Kalushi'' (ifilimu) 
* 2017, ''i-Liyana'', ifilimu ye-multimedia ka- Aaron Kopp &lt;ref name=&quot;about&quot; /&gt;

=== Ukuvela kwedokhumenthri ===

* Wadlala begodu walandisa ku-Traveling ''Songs''
* 1990, wenza iinkondlo ku- ''Songololo: Amaphimbo weTjhuguluko'' (indlela amasiko weSewula Afrika aba yingcenye yomzabalazo wokulwisana nebandlululo) 
* 1993, ''Ingoma eKhambako'' (ikambiso yesimanje yokubuthelela iindaba)
* Uvele ku-Literacy ''Alive''
* Uvele ku ''-Art Works''

== Ukurekhoda ==
UMhlophe watlola umvumo womlandelande wakhe we -SABC TV ''Gcina &amp; Friends''

* 1993, ''Umvumo wabantu abancani'' (CD)
* 1993, ilizwi lomfundi ''Akusi msinya kangako, Songololo'' (videorekhodi), Weston Woods, Weston CT, Scholastic
* 1994, ''I-The Gift of the Tortoise'' (efakwe isandla ku-albhamu ye- Ladysmith Black Mambazo )
* 2002, ''i-Fudukazi's Magic'' itjengiswe e- Durban ku-African Union Film Festival

== Ukusebenzisana ==

* U-Pops Mohamed, umvumi nomlondolozi womculo weentjhaba
* I-Ladysmith Black Mambazo, isiqhema sekhwaya, ''i-The Gift of the Tortoise'' (CD), 1994 kanye ''ne-Music for Little People in America'' (CD), 1993
* U-Anant Singh, umkhiqizi wevidiyo, ''i-Fudukazi's Magic'' (i-CD nevidiyo yababukeli be-German)

== Isilululwazi ==

* ''Ithoyilethi'' 1987 (indatjana efitjhani) 
* ''Molo! Zoleka'' New Africa Education, 1994. (Incwadi yabantwana) 
* ''UMaZanendaba kanye negobolondo lendaba yemilingo'' (incwadi yabantwana) 
* ''Inyoka eneenhloko ezilikhomba'' . I-Johannesburg: Skotaville Publishers, 1989. (Incwadi yabantwana, etjhugululwe ngeenlimi ezihlanu ze-Afrika, i-edishini yesiNgisi iyatlhogeka kiwo woke amalayibhrari weenkolo weSewula Afrika) 
* ''Ukhe wambona na uZandile?'' . I-Portsmouth, NH: Heinemann, 1990. (Ukudlala, okusekelwe ebuntwaneni bakhe, okutlhogekako emalayibhrari weyunivesithi yeSewula Afrika) 
* ''INdlovukazi yamaFudu'' . I-Johannesburg: Skotaville, 1990. (Ibhuku labantwana) 
* ''Inja Ehlabelako'' . Idwetshwe ngu-Erica Maritz no-Andries Maritz. I-Johannesburg: Skotaville, 1992. (Ibhuku labantwana) 
* ''UNalohima, iFudu elingazwako'' . Gamsberg Macmillan, 1999. 
* ''Umlingo ka-Fudukazi'' . Cambridge: Cambridge University Press, 1999. (CD – amagama nomvumo, ukudlala) 
* ''Umlingo ka-Fudukazi'' . I-Cambridge University Press, 2000 (i-CD – amagama nomvumo, ukudlala, kwababukeli be-German)
* ''UNozi, Umama weencwadi'' . U-Maskew Miller Longman, 2001. (CD nencwadi, umdlalo weSewula Afrika ukuya eenkolweni zemakhaya) 
* ''Umama kaKresmusi we-Afrika'' . Maskew Miller Longman, 2002. (CD nencwadi) 
* ''Thanda Umntwana'' . I-Durban: University of Natal Press, 2002. (Imemori, iqoqo leendaba) 
* ''Iindaba ze-Afrika'' . I-University of Natal Press, 2003. (Incwadi yabantwana) 
* ''INdlovukazi ye-Imbira'' . Maskew Miller Longman, 2003. (Incwadi yabantwana) 
* ''Iingoma neendatjana ze-Afrika'' – Umnqobi wemitlomelo yomvumo weSewula Afrika ka-2010 nge-albhamu ehle khulu yabantwana be-English – umvumo we-Afrika okhilimu 

== Qala godu ==

* Irhelo labatloli be-Afrika
* Abantu abadumileko beSewula Afrika
* Iinkondlo i-Afrika

== Iinkomba ==
{{Reflist}}

== Yini eyamkhuthaza ukutlola ==

* Official website
* [https://web.archive.org/web/20120620010949/http://badilishapoetry.com/artists-profile/51/ Badilisha Poetry Exchange] Profile and podcast</text>
      <sha1>9npyi6r3occ2xueww8tuctuakvdcln2</sha1>
    </revision>
    <revision>
      <id>6173</id>
      <parentid>6172</parentid>
      <timestamp>2026-02-16T17:50:04Z</timestamp>
      <contributor>
        <username>Nhlanhla NaLamula</username>
        <id>1365</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1336958516|Gcina Mhlophe]]&quot;</comment>
      <origin>6173</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9000" sha1="i9smqvhuhcaaq576m4zklmpbdfmlrf2" xml:space="preserve">{{Short description|South African playwright, author mime and poet (born 1958)}}  
U '''-Gcina Mhlophe''' (wabelethwa mhlana malanga ama-24 kuSewula 1958) mcoci weendatjana, umtloli, umtloli wemidlalo, nomlingisi weSewula Afrika. Ngomnyaka ka-2016, wabhalwa njengomunye wabafazi abali-100 be-BBC . Ucoca iindatjana zakhe ngamalimi amane weSewula Afrika: isiNgisi, isiBhunu, isiZulu nesiXhosa, begodu usiza nokukhuthaza abantwana ukuthi bafunde.

== Ipilo yokuthoma ==
U-Nokugcina Elsie Mhlophe wabelethwa mhlana amalanga ama-24 kuNobayeni wee-1958 e-Hammarsdale, e-KwaZulu-Natal,  kumma oM -Xhosa nobaba oMZulu . Ubaba ka-Gcina bekasebenza enkampanini yamafutha e-Jacobs, e-South Durban basin, ngesikhathi unina asebenza njengesisebenzi sangekhaya. Wabelethwa ngaphandle komtjhado, wahlukana nonina nakaneminyaka emibili, wayokuhlala noyise, obekatjhadile anabantwana ababu-8. 

Wathoma ipilo yakhe yokusebenza njengesisebenzi sangekhaya,  begodu azange avakatjhele ilayibrari bekwaba kulapho aneminyaka ema-20. 

== Ibizelo ==
U-Mhlophe bekasebenza njengomfundi weendaba e-Press Trust ne -BBC Radio . Kusukela ngo-1982 ukuya ku-1983, bekamtloli wemagazini ethi &quot;Learn and Teach&quot;. 

Wathoma ukuzwisisa ukufunwa kweendaba ngesikhathi ase- Chicago ngo-1988. Wadlala emtatjweni weencwadi endaweni ehlala abantu abanzima, lapho ababukeli bebahlala bammema khona. Nanyana kunjalo, u-Mhlophe wathoma ukucabanga ngokucoca iindaba njengomsebenzi ngemva kokuhlangana no- Imbongi, omunye weembongi ezidumileko zeendatjana ze-Afrika, begodu ngemva kokukhuthazwa ngu- Mannie Manim, obegade angumnqophisi we -Market Theatre, [[Johannesburg|e-Jwanasbege]]. Kusukela ngo-1989 ukuya ku-1990, bekangumnqophisi ohlala e- Market Theatre . 

U-Mhlophe uvele emathiyetha ukusuka e-Soweto ukuya e-London, begodu umsebenzi wakhe omnengi utjhugululwe ngesiJarimani, isiFulentshi, isiNtaliyane, isiSwahili, nesiJapanese . Ukhambe khulu e [[I-Afrika|-Afrika]] nezinye iindawo zomhlaba anikela ngemihlangano yokucoca iindaba.

Iindatjana zaka-Mhlophe zihlanganisa iindatjana, ilwazi, iindaba zanje, ingoma, [[Idiom|nezitjho]] . Ukucoca iindatjana msebenzi wesintu khulu [[Isewula Afrika|eSewula Afrika]], begodu u-Mhlophe ngomunye wabafazi abambalwa abacoca iindatjana enarheni ebuswa babantu abaduna. Wenza umsebenzi wakhe ngokudlala okuthakazelisako, asebenzela ukubulunga ukucoca iindaba njengendlela yokugcina umlando uphila nokukhuthaza abantwana beSewula Afrika bona bafunde. Ukhuluma iindaba zakhe ngeenlimi ezine zeSewula Afrika: [[Ilimi lesiNgisi|isiNgisi]], isiBhunu, isiZulu nesiXhosa .

Ukutlola kwakhe kuvele kukhongozeloelifaka hlangana ''i-A Land Apart: A South African Reader'' (eds André Brink and JM Coetzee, London: Faber and Faber, 1986), ''Daughters of Africa'' (ed. Margaret Busby, London: Jonatan Cape, 1992) kanye ne ''-Women Writing Africa: The Southern Region'' (Margaret: Margaret Day, 1992). Witwatersrand University Press, 2002).

== Eminye imisebenzi ==
UMhlophe weluleka abantu abatjha, athuthukise amakgono asesematjha ukuthi aragele phambili ngomsebenzi wokucoca iindatjana nge-Zanendaba (&quot;Bring me a story&quot;) esisungulo. Isisungulo lesi, esasungulwa ngo-2002, sisebenzisana ne-Market Theatre kanye [[READ Educational Trust|ne-READ]], ihlangano yeentjhabatjhaba yokufunda nokutlola.

Njenganje  usebenza njengomxhasi we- ASSITEJ South Africa, i-International Association for Theatre for Children and Young People.

Uphethe indawo yokudlalela ebizwa nge-&quot;The Storytelling Tree&quot; eThekwini . 

Usebenza njengesikhulumi esikhuthazako . 

Kusukela ngomnyaka ka-2019,  ilanga lokubelethwa laka-Mhlophe, mhlana amalanga ama-24 kuNobayeni, likhunjulwa njengelanga leNarha lokuTjheja iindatjana eSewula Afrika. 

Kusuka ngo-2023[ilwazi lamva], UMhlophe watlomelwa [[Honorary doctorate|nge-honorary doctorates]]  kumayunivesithi alikhomba emhlabeni. Kufaka hlangana:

Okhunye ukuhlonitjhwa komsebenzi wakhe kufaka hlangana:

* 1987: Umvuzo we-Obie wokusebenza kuhle komlingisi ( i-New York City ) nge ''-Born in the RSA'' 
* 1988: U-Joseph Jefferson Award we-Best Actress ( Chicago ) nge- ''Have seen Zandile?''
* 198?: Umvuzo we-Sony we-Radio Drama ovela ku-BBC Radio Africa nge- ''Have seen Zandile?''
* 1990: Umvuzo wokuthoma we-Fringe (Edinburgh) ''we-Have seen Zandile?''
* 1991: Umkhethi, umvuzo we-Noma, we ''-Queen of the Tortoises''
* 1991, i-Ashoka Fellowship (umsunguli wezamabhizinisi wezenhlalakahle)
* 1994: Umvuzo we-Book Chat we ''-Molo Zoleka''
* 2016: Wabizwa njengomunye wabafazi abali-100 be-BBC 
* 2018: Umvuzo wokuthoma we-USIBA Cultural Legend, ovela kuNgqongqotjhe wezobuKghwari namaSiko 
* I-SAFTA Lifetime Achievement Award. 

== Imidlalo ekhethiweko ==

* 1983, indima ephambili ku- ''Umongikazi: The Nurse'', ka- Maishe Maponya 
* 1984, ku- ''Black Dog: Inj'emnyama''
* 1986, ''Indawo yokulila'' (ifilimu)
* 1986, ''Ukhe Wambona UZandile?'' (umdlalo wokuziphilela, e-Market Theatre, e-Goli, u-Mhlophe njengo-Zandile) 
* 1987, ''Wabelethwa e-RSA'' (New York)
* 1989, umnyanya wokucoca iindaba e-Market Theatre
* 1989, wenza ikondlo yokuhlonipha u- Albert Luthuli, umnqobi we-Nobel Peace Prize ka-1960
* 1990, yenza i- ''Have You Seen Zandile?'' emnyanyeni we -Edinburgh Festival e-Europe ne-USA 
* 1997, Inkondlo ye-Afrika, eveza imbongi
* 1999, isikhulumi sesivakatjhi emnyanyeni wabatloli be-Perth
* 2000, eyenziwa ku- ''Peter und der Wolf'' e- Komische Oper (Berlin)
* 2002, ''Amathambo weKhumbuzo'' (ukudlala, ukulandisa umlando ukusuka eSewula Afrika endala netjha)
* 2003, wafundisa ngokucoca iindaba emhlanganweni we- ''Eye of the Beholder''
* 2003, ''uMata Mata'' (ukudlala, umvumo womndeni)
* 2006, umnyanya weNdebe yePhasi ye-FIFA eSewula Afrika, e-Germany 
* 2016, ''Kalushi'' (ifilimu) 
* 2017, ''i-Liyana'', ifilimu ye-multimedia ka- Aaron Kopp &lt;ref name=&quot;about&quot; /&gt;

=== Ukuvela kwedokhumenthri ===

* Wadlala begodu walandisa ku-Traveling ''Songs''
* 1990, wenza iinkondlo ku- ''Songololo: Amaphimbo weTjhuguluko'' (indlela amasiko weSewula Afrika aba yingcenye yomzabalazo wokulwisana nebandlululo) 
* 1993, ''Ingoma eKhambako'' (ikambiso yesimanje yokubuthelela iindaba)
* Uvele ku-Literacy ''Alive''
* Uvele ku ''-Art Works''

== Ukurekhoda ==
UMhlophe watlola umvumo womlandelande wakhe we -SABC TV ''Gcina &amp; Friends''

* 1993, ''Umvumo wabantu abancani'' (CD)
* 1993, ilizwi lomfundi ''Akusi msinya kangako, Songololo'' (videorekhodi), Weston Woods, Weston CT, Scholastic
* 1994, ''I-The Gift of the Tortoise'' (efakwe isandla ku-albhamu ye- Ladysmith Black Mambazo )
* 2002, ''i-Fudukazi's Magic'' itjengiswe e- Durban ku-African Union Film Festival

== Ukusebenzisana ==

* U-Pops Mohamed, umvumi nomlondolozi womculo weentjhaba
* I-Ladysmith Black Mambazo, isiqhema sekhwaya, ''i-The Gift of the Tortoise'' (CD), 1994 kanye ''ne-Music for Little People in America'' (CD), 1993
* U-Anant Singh, umkhiqizi wevidiyo, ''i-Fudukazi's Magic'' (i-CD nevidiyo yababukeli be-German)

== Isilululwazi ==

* ''Ithoyilethi'' 1987 (indatjana efitjhani) 
* ''Molo! Zoleka'' New Africa Education, 1994. (Incwadi yabantwana) 
* ''UMaZanendaba kanye negobolondo lendaba yemilingo'' (incwadi yabantwana) 
* ''Inyoka eneenhloko ezilikhomba'' . I-Johannesburg: Skotaville Publishers, 1989. (Incwadi yabantwana, etjhugululwe ngeenlimi ezihlanu ze-Afrika, i-edishini yesiNgisi iyatlhogeka kiwo woke amalayibhrari weenkolo weSewula Afrika) 
* ''Ukhe wambona na uZandile?'' . I-Portsmouth, NH: Heinemann, 1990. (Ukudlala, okusekelwe ebuntwaneni bakhe, okutlhogekako emalayibhrari weyunivesithi yeSewula Afrika) 
* ''INdlovukazi yamaFudu'' . I-Johannesburg: Skotaville, 1990. (Ibhuku labantwana) 
* ''Inja Ehlabelako'' . Idwetshwe ngu-Erica Maritz no-Andries Maritz. I-Johannesburg: Skotaville, 1992. (Ibhuku labantwana) 
* ''UNalohima, iFudu elingazwako'' . Gamsberg Macmillan, 1999. 
* ''Umlingo ka-Fudukazi'' . Cambridge: Cambridge University Press, 1999. (CD – amagama nomvumo, ukudlala) 
* ''Umlingo ka-Fudukazi'' . I-Cambridge University Press, 2000 (i-CD – amagama nomvumo, ukudlala, kwababukeli be-German)
* ''UNozi, Umama weencwadi'' . U-Maskew Miller Longman, 2001. (CD nencwadi, umdlalo weSewula Afrika ukuya eenkolweni zemakhaya) 
* ''Umama kaKresmusi we-Afrika'' . Maskew Miller Longman, 2002. (CD nencwadi) 
* ''Thanda Umntwana'' . I-Durban: University of Natal Press, 2002. (Imemori, iqoqo leendaba) 
* ''Iindaba ze-Afrika'' . I-University of Natal Press, 2003. (Incwadi yabantwana) 
* ''INdlovukazi ye-Imbira'' . Maskew Miller Longman, 2003. (Incwadi yabantwana) 
* ''Iingoma neendatjana ze-Afrika'' – Umnqobi wemitlomelo yomvumo weSewula Afrika ka-2010 nge-albhamu ehle khulu yabantwana be-English – umvumo we-Afrika okhilimu 

== Qala godu ==

* Irhelo labatloli be-Afrika
* Abantu abadumileko beSewula Afrika
* Iinkondlo i-Afrika

== Iinkomba ==
{{Reflist}}

== Yini eyamkhuthaza ukutlola ==

* Official website
* [https://web.archive.org/web/20120620010949/http://badilishapoetry.com/artists-profile/51/ Badilisha Poetry Exchange] Profile and podcast</text>
      <sha1>i9smqvhuhcaaq576m4zklmpbdfmlrf2</sha1>
    </revision>
  </page>
  <page>
    <title>Linda Sokhulu</title>
    <ns>0</ns>
    <id>1037</id>
    <revision>
      <id>6174</id>
      <timestamp>2026-02-16T20:46:54Z</timestamp>
      <contributor>
        <username>Nhlanhla NaLamula</username>
        <id>1365</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1320474055|Linda Sokhulu]]&quot;</comment>
      <origin>6174</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2372" sha1="qeee9dar1v209ipwjne0rcljgfskq3y" xml:space="preserve">
 

'''U-Linda Sokhulu''' (wabelethwa mhlana amalanga ali-13 kuSkhukhulamungu wee-1976) mlingisi weSewula Afrika. Ngomnyaka ka-2014, wathola ukuphakanyiswa komlingisi ophuma phambili ku- 10th Africa Movie Academy Awards .

== Ibizelo ==
Kusukela ngo-2004, u-Sokhulu wadlala u-&quot;Cleo Khuzwayo&quot; ku ''-Generations'' .  Ngomnyaka ka-2013, u-Sokhulu wadlala indima yefilimu yakhe yokuthoma, ''u-Felix'', begodu wadlala indima kamama womuntu ofuna ukuba mdlali we-saxophone. Wakhethwa njengomlingisi omuhle khulu ku -SAFTA kanye ne -Africa Movie Academy Awards .  Ifilimu le ibuye yathumba abonongorhwana e- Durban International Film Festival, lapho yachazwa khona &quot;njengombangiswani ofanele nanyana ngiyiphi i-Hollywood blockbuster&quot;.    Ngo-2007, wadlala u-&quot;Nomathemba&quot; ku-soap yendawo ''i-Ubizo: The Calling'' . Ngo-2008, udlale u-&quot;Pamela&quot; ku- ''Sokhulu &amp; Partners'' . &lt;ref name=&quot;mastersource&quot; /&gt; Mhlana amalanga ama-27 kuTjhirhweni 2022, u-Sokhulu wajoyina abalingisi be ''-7de Laan'' ekontrageni yendima yokudlala njengo mlingisi.

Ukhuluma njenge-ejenti eyimfihlo u-Mama K emdlalweni ozako, ''i-Supa Team 4'' . 

=== Amafilimu ===

* ''Isidingo'' 
* Generations (2004 - 2007)
* ''A Place Called Home'' (2006)
* ''Ubizo: The calling'' (2007)
* ''Shreds and Dreams'' (2010 &amp; 2014)
* ''Felix'' (2013)
* ''Rhythm City'' (2019)
* Umkhokha (2021)
* ''7de Laan'' (2022)
* &lt;nowiki&gt;&lt;i id=&quot;mwVg&quot;&gt;Isiphetho - Destiny&lt;/i&gt;&lt;/nowiki&gt; (2024 - 2025)

=== Ukudunyiswa ===

* Unongorwana we-Golden Horn we-2012 womlingisi omuhle khulu odlala indima ephambili emdlalweni wakumabonakude  
* Unongorwana we-Golden Horn ka-2016 womlingisi omuhle khulu odlala indima ephambili emdlalweni wakumabonakude 
* 2016 Unongorwana we-Golden Horn we-Best Supporting Actress kumdlalo kamabinakude &lt;ref name=&quot;source&quot; /&gt;
* Unongorwana we-Golden Horn we-2017 womlingisi omuhle khulu odlala indima ephambili emdlalweni wakumabonakude 
* Unongorwana we-Africa Movie Academy womlingisi omuhle khulu 

== Ipilo yomuntu mathupha ==
USokhulu wabelethwa mhlana amalanga ali-13 Sikhukhulamungu wee-1976, eThekwini, kodwana wahlala iminyaka yakhe yokukhula e -Umlazi .  Waya e- St. Anne's Diocesan College e- Hilton, KwaZulu-Natal eduze ne -Pietermaritzburg (1990-1993) ngaphambi kokuya e -Cambridge College ngo-1994 bese wafunda ngefeshini e -Technikon Natal . 

== Iinkomba ==
{{Reflist}}

== Amalinki wangaphandle ==</text>
      <sha1>qeee9dar1v209ipwjne0rcljgfskq3y</sha1>
    </revision>
  </page>
  <page>
    <title>Ihlaziyo Lesakhiwo Esisi Sekelo Semitjho YesiNdebele</title>
    <ns>0</ns>
    <id>1038</id>
    <revision>
      <id>6175</id>
      <timestamp>2026-02-17T09:08:29Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <comment>Created page with &quot;== '''Ihlaziyo Lesakhiwo Esisi Sekelo Semitjho YesiNdebele''' ==   === '''1. Isingeniso''' === Isakhiwo semitjho siqakathekile ekwenzeni isiqiniseko sokuthi umutjho uzwakala kuhle begodu umlayezo wawo uyazwisiseka. Ukungezelela, isakhiwo semitjho sidlala indima ekulu ekuthuthukiseni ilwazi nezinga lekghono lelimi kubasebenzisi balo. Ngamanye amagama, isakhiwo semitjho sinomthintela kiloyo osakhako naloyo uzokufunda nanyana asebenzise umutjho loyo.   Ukuya ngokukaYu (2021...&quot;</comment>
      <origin>6175</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="17022" sha1="d85k2olua0seva2kgo1dzx8xx4dxxdl" xml:space="preserve">== '''Ihlaziyo Lesakhiwo Esisi Sekelo Semitjho YesiNdebele''' == 

=== '''1. Isingeniso''' ===
Isakhiwo semitjho siqakathekile ekwenzeni isiqiniseko sokuthi umutjho uzwakala kuhle begodu umlayezo wawo uyazwisiseka. Ukungezelela, isakhiwo semitjho sidlala indima ekulu ekuthuthukiseni ilwazi nezinga lekghono lelimi kubasebenzisi balo. Ngamanye amagama, isakhiwo semitjho sinomthintela kiloyo osakhako naloyo uzokufunda nanyana asebenzise umutjho loyo. 

Ukuya ngokukaYu (2021)&lt;ref name=&quot;:0&quot;&gt;Yu, X. 2021. A Study on the Role of Sentence Structure Analysis in English Learning. ''Open Access Library Journal'', 8:1-14.&lt;/ref&gt; pheze woke umuntu osebenzisa ilimi elithize kufanele azwisise isakhiwo semitjho. Ukungezelela, isakhiwo semitjho sithinta boke abasenzisi belimi lelo ekufaka hlangana abatloli, abafundisi, abarhubhululi, abarhatjhi, abatlami beenhlathululimagama namathemu nabafundi. Lokhu kuyasivezela bona isakhiwo semitjho siqakatheke kangangani begodu kuyakateleleka bonyana nawumsebenzisi welimi usazi. 

Ngaphasi kwesifundo lesi sizokutjheja isakhiwo semitjho ngaphasi kwesiNdebele. Isakhiwo semitjho lesi sizokuhlaziywa ngokunqopha kuzinto ezakha imitjho, ubujamo bazo bendabuko emutjhweni kanye nemihlobo yemitjho. Imethodoloji yekhwalithethivu nebuthelelo ledatha, ihlaziyo lemitlolo, zisetjenzisiwe. Ukungezelela, ithiyori yehlaziyo lommongo isetjenzisiwe nayo. Imiphumela yehlaziyo ledatha izokurhunyuthwa bese kunikelwe ngalokho okuvunjululiweko. Esihlokweni esilandelako isakhiwo semitjho siyahlathululwa. 

=== '''2. Isakhiwo Semitjho.''' ===
Isakhiwo semitjho siwela ngaphasi kwesifundo sesintheksi (uYusuf no-Ali, 2025)&lt;ref name=&quot;:1&quot;&gt;Yusuf, F., &amp; Ali, A. 2025. Unveiling the Role of Grammar Mastery: How Sentence Structure, Verb, and Subject-Verb Agreement Shape Tenses Usage in English Learning. ''Panyonara: Journal of English Education'', 7(1):103-123.&lt;/ref&gt;. Isintheksi kusifundo esiphathelene nokutlolwa nokuhleleka kuhle kwemitjho ngendlela leyo engalahli umnqondo (uSkhosana, 1996&lt;ref name=&quot;:2&quot;&gt;Skhosana, P. B. 1996. ''Isilembe SakaMusi''. Via Afrika. Pretoria.&lt;/ref&gt;). Ngamanye amagama, isintheksi kusifundo esinqophe eendleleni ezitjenziswako ekutloleni nanyana ekwakhiweni kwemitjho ngendlela ezwakalako kuloyo oyitlolileko naloyo oyifundako. Tjhejani isibonelo esilandelako:

1. IWikipedia ikhiphe isikhangiso.

Esibonelweni 1, sinikelwe umutjho ‘IWikipedia ikhiphe isikhangiso.’, loyo ositjela bonyana kunesikhangiso esikhitjhwe yiWikipedia. Umutjho lo uyezwakala begodu nomnqondo awudurhisi ofundako. Ungezelela, singatjho bona umutjho lo uphelele ngombana kunongci (.) ekugcineni kwawo. 

Nanyana kunjalo, isakhiwo semitjho siyahluka ngokuya kwelimi elinye nelinye (uSkhosana, 1998&lt;ref name=&quot;:3&quot;&gt;Skhosana, P. B. 1998. Foreign Interferences in the Sound, Grammatical and Lexical System of Southern Ndebele. ''Unpublished M.A dissertation'', University of Pretoria. Pretoria.&lt;/ref&gt;). Ukuragela phambili, ilimi ngalinye lakha imithetho yayo elawula isakhiwo semitjho ngendlela ekhambisana nelimi lelo. Okutjho bonyana kuyakghonakala ukuthi umutjho ungatlolwa ngokufana emalimini ahlukeneko; kodwana, unikele umnqondo nomlayezo ofanako. Esihlokweni esilandelako imethodoloji nebuthelelo ledatha ezisetjenzisiweko ziyahlathululwa. 

=== '''3. Imethodoloji Nebuthelelo Ledatha Ezisetjenzisiweko.''' ===
Isifundo lesi sisebenzise imethodoloji yekhwalithethivu. Ukuya ngokukaCreswell (2003)&lt;ref&gt;Creswell, J. W. 2003. ''Research Design: Qualitative, Quantitative and Mixed Methods Approaches''. 2nd Ed. Thousand Oaks, Calif: Sage.&lt;/ref&gt; asekelwa kuDaniel (2016)&lt;ref&gt;Daniel, E. 2016. The Usefulness of Qualitative and Quantitative Approaches and Methods in Researching Problem-Solving Ability in Science Education Curriculum. ''Journal of Education and Practice'', 17(15):91-100.&lt;/ref&gt;, imethodoloji yekhwalithethivu, yimethodoloji isetjenziswa mrhubhululi loyo isifundo sakhe esinganahlaziyo ledatha leenomboro nanyana ilingelelo. Lokhu kutjho bona, isifundo semethodoloji yekhwalithethivu asisebenzisi amaphesende begodu nobungako bobudisi bezinto (u-Aspers noCorte, 2019&lt;ref&gt;Aspers, P., &amp; Corte, U. 2019. What is Qualitative in Qualitative Research. ''Qualitative Sociology'', 42:139–160.&lt;/ref&gt;; noTaderdoost, 2021&lt;ref&gt;Taherdoost, H. 2021.  Data Collection Methods and Tools for Research; A Step-by-Step Guide to Choose Data Collection Technique for Academic and Business Research Projects. ''International Journal of Academic Research in Management (IJARM)'', 10 (1):10-38.&lt;/ref&gt;). Ngamanye amagama, umrhubhululi osebenzisa imethodoloji yekhwalithethivu ihlaziyo lakhe lisuke lidzimelele emmongweni nemlayezweni omumethwe yidatha yesifundo sakhe. Ngaphasi kwesifundo lesi, imitlolo yesiNdebele ifundiwe bese kwatshwaywa leyo enemitjho ngomnqopho wokufuna ukufunda nokuhlaziya isakhiwo semitjho leyo. Ukungezelela, ihlaziyo leli linqophe ezintweni ezakha imitjho, ubujamo bazo bendabuko nemihlobo yemitjho. Imiphumela ihlaziwile begodu kwanikela ngesiphetho. 

Ibuthelelo ledatha, ihlaziyo lomtlolo, lisetjenzisiwe nalo ngaphasi kwesifundo lesi. Ibuthelelo ledatha ihlaziyo lomtlolo, libuthelelo ledatha lelo elisetjenziswa ukubuthelela idatha emitlolo kwaphela (uSharma, 2023&lt;ref&gt;Sharma, Y. 2023. Data Collection in Research: Concept, Process and Methods. ''International Journal of Creative Research Thoughts'', 11(10):27-33.&lt;/ref&gt;; noDewi, 2021&lt;ref&gt;Dewi, I. G. A. A. O. 2021. Understanding Data Collection Methods in Qualitative Research: The Perspective of Interpretive Accounting Research. ''Journal of Tourism Economics and Policy'', 1(1):8-15.&lt;/ref&gt;). Ukungezelela, ibuthelelo ledatha ihlaziyo lomtlolo linikela umrubhululi amano wokubuthelela idatha emitlolo leya efaka hlangana isihlathululimagama, incwadi nomtlolo wemikhangiso ukuze umrhubhululi ekhethe idatha enqophileko kusifundo sakhe (uKibiswa, 2019&lt;ref&gt;Kibiswa, N. K. 2019. Directed Qualitative Content Analysis (DQlCA): A Tool for Conflict Analysis. ''The Qualitative Report'', 24(8), 2059-2079.&lt;/ref&gt;; noNicmanis, 2024&lt;ref&gt;Nicmanis, M. 2024. Reflexive Content Analysis: An Approach to Qualitative Data Analysis, Reduction, and Description. ''International Journal of Qualitative Methods'', 23:1–12.&lt;/ref&gt;). Ngaphasi kwesifundo lesi, idatha yemitolo enemitjho yesiNdebele ifundiwe bese kutshwaywa leyo elungele isifundo lesi bona iyokuhlaziywa ngokungeneleleko. Esihlokweni esilandelako ithiyori esetjenziswe esifundweni lesi iyahlathululwa. 

=== '''4. Ithiyori Yesifundo.''' ===
Ithiyori, ihlaziyo lommongo, isetjenzisiwe ngaphasi kwesifundo lesi. Ithiyori ihlaziyo lommongo, yithiyori enzinze khulu ngaphasi kokuhlaziya ummongo womtlolo ukuze kufumaneke umlayezo wawo (uMayring, 2014&lt;ref&gt;Mayring, P. 2014. ''Qualitative Content Analysis: Theoretical Foundation, Basic Procedures and Software Solution''. Klagenfurt.&lt;/ref&gt;; noRochson, u-Adade-Yeboah no-Owusu, 2023&lt;ref&gt;Rockson, K., Adade-Yeboah, A., &amp; Owusu, E. 2023. A Textual Analysis of President Akufo-Addo’s 12th Covid–19 Address. ''Journal of English Teaching'', 9(2):252-268.&lt;/ref&gt;). Ukungezelela, esikhathini esinengi imitlolo imumethe imilayezo efihlakeleko begodu ukuze ifunywane kufanele kuhlaziywe ummongo wayo ngomnqopho wokuwuzisisa bonyana uwakhekhe njani, usebenza njani begodu umlayezo wawo yini (uShort, 2024&lt;ref&gt;Short, C. E. 2025. ''Textual analysis''. In: Grossmann-Hensel, B., Jarzabkowski, P., Kratochvil, R., Seidl, D., Spee, A. P., &amp; Whittington, R. (Eds.) Elgar Encyclopedia of Strategy as Practice. Edward Elgar Publishing.&lt;/ref&gt;). Ngamanye amagama, ithiyori ihlaziyo lommongo linikela umrhubhululi amano wokuhlaziya imitlolo eminengi ngomnqopho wokuzwisisa bonyana isetjenziswa njani ebujameni bayo bendabuko. 

Ngaphasi kwesifundo lesi, imitlolo enemitjho yesiNdebele ihlaziywile ngomnqopho wokuzwisisa bona yakhiwe ngani. Ukungezelela, ubujamo bezakhi zemitjho yesiNdebele bendabuko nabo buhlaziywile bonyan bukuphi emitjhweni begodu imitjho le inemihlobo emingaki. Ekugcineni, kunikelwe ngesiphetho mayelana nalokho okuvunjululwe kusifundo lesi. Esihlokweni esilandelako imitlolo ehlobene nesifundo lesi itjhejiwe. 

=== '''5. Imitjho Ehlobene Nesifundo Lesi.''' ===
Imitjho inezakhi zayo ezenza bonyana izakhiwo zayo zihleleke kuhle. Ukuya ngokukaHamraqulova (2023)&lt;ref name=&quot;:4&quot;&gt;Hamraqulva, O. 2023. Sentence Structure in English Grammar Study in National Groups. ''Texas Journal of Philogy, Culture and History'', 17:25-29.&lt;/ref&gt; isakhiwo semitjho senziwe ngezinto ezinengi lezi ezifaka hlangana iinkhekhe zekulumo. UHamraqulova (2023)&lt;ref name=&quot;:4&quot; /&gt; uveze lokhu esifundweni sakhe sesihloko esithi, ‘''Sentence Structure in English Grammar Study in National Groups’'', lapho bekuhlaziywa khona ukukghedlwa kweenkhekhe zekulumo ezahlukeneko ezitholakala emitjhweni yesiNgisi. Isifundo lesi sifunyene bona kunobudisi bokutshwaya nokwazi iinkhekhe zekulumo ezisetjenziswa emitjhweni. UHamraqulova (2023)&lt;ref name=&quot;:4&quot; /&gt; uphakamise bona kufanele iinkhekhe zekulumo ezitholakala emutjhweni zitlolwe phasi begodu zifundiswe abasebenzisi belimi.

Ngesikhathi uHamraqulova (2023)&lt;ref name=&quot;:4&quot; /&gt; enze isifundo esinzinze eenkhekheni zekulumo ezitholakala esakhiweni somutjho, uYusuf no-Ali (2025)&lt;ref name=&quot;:1&quot; /&gt; bese isifundo leso esinqophe eendimeni ezidlalwa isakhiwo semitjho lokha nawusebenzisa begodu ufunda isiNgisi, ngaphasi kwesihloko esithi, ‘''Unveiling the Role of Grammar Mastery: How Sentence Structure, Verb, and Subject-Verb Agreement Shape Tenses Usage in English Learning’''.  UYusuf no-Ali (2025)&lt;ref name=&quot;:1&quot; /&gt; bafunyene bona izakhiwo zomutjho ezifaka hlangana ihloko yomutjho, isenzo nomenzi zidlala indima eqakathekileko ekuthuthukiseni ilwazi lelimi kubafundi. Kodwana, umraro ovunjululiweko kukuthi abafundi abanengi abanakghono lokuhlanganisa kuhle izakhi lezo emutjhweni. UYusuf no-Ali (2025)&lt;ref name=&quot;:1&quot; /&gt; baphakamise bona ikharikhyulamu yefundo kufanele yenze isifundo leso esinzinze ekusetjenzisweni kwelimi nehlelo ukuze abafundi bazokwazi ukumunya ilwazi lokuthuthukisa ikghono labo lehlelo nelimi. 

Ngokufani nesifundo sakaYusuf no-Ali (2025)&lt;ref name=&quot;:1&quot; /&gt;, uPhilippakos noZoi (2019)&lt;ref name=&quot;:5&quot;&gt;Philippakos, T., &amp; Zoi, A. 2019. Sentence Construction: Supporting Elementary Students’ Editing Skills. ''The Language and Literacy Spectrum'', 29(1):1-23.&lt;/ref&gt; benze isifundo sesihloko esithi, ‘''Sentence Construction: Supporting Elementary Students’ Editing Skills''’, lapho bekuhlaziywa khona amakghono angasetjenziswa ukulungisa iimphoso zemitjho bafundi bamabanga aphasi. Isifundo lesi sifunyene bona abafundi abanengi bamabanga aphasi abanamakghono wokulungisa iimphoso zemitjho, khulukhulu imitjho ezizitjho. UPhilippakos noZoi (2019)&lt;ref name=&quot;:5&quot; /&gt; bakhombele bona abafundisi bamabanga aphasi kufanele bafundise abafundi ngezitjho kanye namaqhinga wokulungisa iimphoso. 

Amanye wamakghono asetjenziswa ngesikhathi kutlolwa nanyana kusetjenziswa imitjho afaka hlangana ukuhlukanisa nokukghedla umutjho omude. Lokhu kufakazelwe sifundo sakaYu (2021) &lt;ref name=&quot;:0&quot; /&gt;sesihloko esithi, ‘''A Study on the Role of Sentence Structure Analysis in English Learning''’, lokha nakaveza bonyana abafundi abanengi baba nesitjhijilo sokuzwisisa nokukghedlha imitjho emide. Umnqopho omkhulu wesifundo sakaYu (2021)&lt;ref name=&quot;:0&quot; /&gt; bekukuhlaziya izwisiso labafundi mayelana nemitjho emide. UYu (2021)&lt;ref name=&quot;:0&quot; /&gt; uphakamise bona abafundi laba kufanele bafundiswe ngamaqhinga wokuzilolonga wehlelo nelimi, khulukhulu ngokunqopha emitjhweni emide ukuze bakwazi ukufunyana amakghono afunekako nakuza ekukghedlhweni nokuzwisweni imitjho emide. 

Ekulunyweni engehla le, kukhulunywe ngezakhi ezisetjenziswako nakwenziwa isakhiwo semitjho, kanye neendima imitjho enayo ekuthuthukiseli ilwazi nekghono lehlelo lelimi. Ukungezelela, kubuywe kwaveza ubudisi obumayelana nokuzwisisa imitjho emide. Woke amaphuzu nemibono evunjululwe ngehla le, iveza isidingo sokurhubhulula ngesakhiwo semitjho ngokunqopha kuzinto ezitholakala emitjhweni, ubujamo bazo bendabuko nemihlobo yemitjho ekhona esiNdebeleni. Esihlokweni esilandelako idatha iyahlaziywa. 

=== '''6. Ihlaziyo Ledatha.''' ===
Isakhiwo semitjho singakhiwa ngezinto ezinengi; kodwana, ihloko yomutjho nesenzo zihlala zikhona esakhiweni somutjho (uSkhosana, 1996)&lt;ref name=&quot;:2&quot; /&gt;. Ngamanye amagama, ihloko yomutjho nesenzo kuzizinto ezisisekelo esakhiweni somutjho begodu esikhathini esinengi azitlhogeki emtjhweni. Tjhejani isibonelo esilandelako:

2. Inja idla amaqanda.

Esibonelweni 2, sinikelwe umutjho ‘Inja idla amaqanda’, loyo owakhiwe ngehloko yomutjho ‘Inja’, isenzo ‘idla’ nemenziwa ‘amaqanda’. Ukungezelela, sithole bona ihloko yomutjho ‘Inja’ isekuthomeni komutjho bese isenzo ‘idla’ sibe phakathi. Umenziwa yena ‘amaqanda’ usekugcineni komutjho. Lokhu kuyasibikela bonyana indawo yehloko yomutjho ngokwendabuko isekuthomeni komutjho; isenzo indawo yaso ngokwendabuko iphakathi emutjhweni bese kuthi umenziwa indawo yakhe ngokwendabuko emutjhweni isekugcineni njengombana kufakazelwa nguSkhosana (1998)&lt;ref name=&quot;:3&quot; /&gt;.

Nanyana kunjalo, kukhona iinkhekhe zekulumo ezitholakala emutjhweni njengoba kufakazelwe nguHamraqulova (2023)&lt;ref name=&quot;:4&quot; /&gt;. Tjhejani isibonelo esilandelako:

3. Isifundo lesi sibudisi.

Esibonelweni 3 esingehla, sinikelwe umutjho, ‘Isifundo lesi sibudisi’, loyo owakhiwe ngeenkhekhe zekulumo ezahlukeneko. Igama ‘Isifundo’ kusikhekhe sekulumo ibizo; igama ‘lesi’ kusikhekhe sekulumo isabizwana sokukhomba eduze bese kuthi ibizo ‘sibudisi’ kusitlhadlhululi esisiphawulo. Lokhu kuyasivezela bonyana umutjho awakhiwa ngehloko, isenzo nemenziwa kwaphela; kodwana, ihloko, isenzo nomenziwa lezo zingawela ngaphasi kweenkhekhe zekulumo ezahlukeneko.

Nanyana kunjalo, imitjho engaphasi kwesibonelo 2 no-3 ngokulandelana ukuze ilethe imiqondo ezwakalako isebenzise iinthomo neemvumelwano. Ngaphasi komutjho wesibonelo 2, sifunyene isithomo sehloko u-‘i’ ohlonyelelwe kusiqu sehloko ‘-nja’ nesivumelwano sehloko u-‘i-’ ohlonyelelwe kusiqu sesenzo ‘-dla’ bese kuthi isithomo sakamenziwa u-‘ama-’ uhlonyelelwe kusiqu sakamenziwa ‘-qanda’.

Bese kuthi ngaphasi komutjho wesibonelo 3, sifunyene isithomo sehloko u-‘isi’ ohlonyelelwe kusiqu sehloko ‘-fundo’ nesivumelwano sehloko u-‘si-’ ohlonyelelwe kusiqu sesitlhadlhuli ‘-budisi’. Isabizwana sokukhomba eduze ‘lesi’ asinasithomo. Kodwana, sisebujameni bobunye ngombana ihloko yomutjho nayo isebujameni bobunye.

Okunye okuvunjululiweko kukuthi imihlobo yemitjho iyahluka njengoba kwavakazelwa nguSkhosana (1996)&lt;ref name=&quot;:2&quot; /&gt;. Tjhejani iimbonelo ezilandelako:

4. Ubaba uthenge ikoloyi.

5. UJabu udinwe khulu namhlanje ngombana bekagijima.

6. Kutjhayisene iinkoloyi ezimbili kwalimala abantu abambalwa. 

Esibonelweni 4, sinikelwe umutjho ‘Ubaba uthenge ikoloyi’ loyo owenziwe ngehloko yomutjho (Ubaba) eyodwa; isenzo sinye (uthenge) nomenziwa oyedwa (ikoloyi). Umutjho lo waziwa ngokuthi mumutjho onqophileko nanyana mumutjho olula (uSkhosana, 1996)&lt;ref name=&quot;:2&quot; /&gt;.

Ngokungafani nomutjho wesibonelo 4, kusibonelo 5 sinikelwe umutjho ‘UJabu udinwe khulu namhlanje ngombana bekagijima’, loyo owenziwe ngehloko (UJabu), izenzo (unidinwe nobakagijima), isitlhadlhuli (khulu), isinabiso (namhlanje) nesihlanganiso (ngombana). Umutjho lo ubizwa bona mumutjho ovangileko. Ngokuya kukaSkhosana (1996)&lt;ref name=&quot;:2&quot; /&gt; umutjho ovangileko siwubona ngeenhlanganiso ezinjengo-‘ngombana, bese nonanyana’ lezo ezihlanganisa imitjho embili ukuze kubumbeke umutjho munye. Nasitjheja umutjho wesibonelo 5, singawuhlukanisa ngemitjho embili; -UJabu udinwe khulu namhlanje; -bekagijima.

Umutjho wokugcina esinikelwe wona kusibonelo 6, u-‘ Kutjhayisene iinkoloyi ezimbili kwalimala abantu abambalwa’, loyo owenziwe ngemitjho edlula kemibili engakghedlwa ngale indlela:

-         Kutjahyisene iinkoloyi

-         Ezimbili

-         Kwalimala abantu abambalwa 

Ingcenye yokuthoma, kutjhayisene iinkoloyi, kumumutjho omkhulu ngombana yoke into ithoma kiwo. ‘Ezimbili’, kumumutjho wesenzo esizijameleko, bese kuthi ingcenye yesithathu ‘kwalimala abantu amambalwa’ kumumutjho oyamileko ngombana uphethe imiphumela yalokho okubangwe yingcenye yokuthoma nanyana umutjho omkhulu. Loku kuyasibikela bonyana imitjho ingahlukana kathathu ngokuya komlayezo ewumumetheko.

=== '''7. Isiphetho''' ===
Isakhiwo semitjho yesiNdebele sihlaziwile ngaphasi kwesifundo lesi begodu kwavunjululwa bona izakhi ezifana nehloko yomutjho isenzo nomenziwa kanengi zihlala zikhona. Ukuragela phambili, imitjho le ifunyenwe bonyana izakhi zayo zingawela ngaphasi kweenkhekhe zekulumo ezahlukeneko njengesitlhadlhuli nebizo. Kokugcina, kuvunjululwe bona imitjho le imihlobo emithathu ehlukeneko. 

Isakhiwo semitjho siqakathekile bona sifundwe besizwisiswe ngombana sifundisa ngelwazi nekghono lehlelo nelimi. Ukungezelela, ukuzwisisa isakhiwo semitjho kwenza kube lula ukwakha nanyana ukutlola imitjho ezakwalako.   

'''Umthombolwazi'''
&lt;references /&gt;</text>
      <sha1>d85k2olua0seva2kgo1dzx8xx4dxxdl</sha1>
    </revision>
    <revision>
      <id>6176</id>
      <parentid>6175</parentid>
      <timestamp>2026-02-17T09:11:07Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <origin>6176</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="17034" sha1="6ozuwknw6vok93cbw80vftb5jpagk46" xml:space="preserve">== '''Ihlaziyo Lesakhiwo Esisi Sekelo Semitjho YesiNdebele.''' == 

=== '''1. Isingeniso.''' ===
Isakhiwo semitjho siqakathekile ekwenzeni isiqiniseko sokuthi umutjho uzwakala kuhle begodu umlayezo wawo uyazwisiseka. Ukungezelela, isakhiwo semitjho sidlala indima ekulu ekuthuthukiseni ilwazi nezinga lekghono lelimi kubasebenzisi balo. Ngamanye amagama, isakhiwo semitjho sinomthintela kiloyo osakhako naloyo uzokufunda nanyana asebenzise umutjho loyo. 

Ukuya ngokukaYu (2021)&lt;ref name=&quot;:0&quot;&gt;Yu, X. 2021. A Study on the Role of Sentence Structure Analysis in English Learning. ''Open Access Library Journal'', 8:1-14.&lt;/ref&gt; pheze woke umuntu osebenzisa ilimi elithize kufanele azwisise isakhiwo semitjho. Ukungezelela, isakhiwo semitjho sithinta boke abasenzisi belimi lelo ekufaka hlangana abatloli, abafundisi, abarhubhululi, abarhatjhi, abatlami beenhlathululimagama namathemu nabafundi. Lokhu kuyasivezela bona isakhiwo semitjho siqakatheke kangangani begodu kuyakateleleka bonyana nawumsebenzisi welimi usazi. 

Ngaphasi kwesifundo lesi sizokutjheja isakhiwo semitjho ngaphasi kwesiNdebele. Isakhiwo semitjho lesi sizokuhlaziywa ngokunqopha kuzinto ezakha imitjho, ubujamo bazo bendabuko emutjhweni kanye nemihlobo yemitjho. Imethodoloji yekhwalithethivu nebuthelelo ledatha, ihlaziyo lemitlolo, zisetjenzisiwe. Ukungezelela, ithiyori yehlaziyo lommongo isetjenzisiwe nayo. Imiphumela yehlaziyo ledatha izokurhunyuthwa bese kunikelwe ngalokho okuvunjululiweko. Esihlokweni esilandelako isakhiwo semitjho siyahlathululwa. 

=== '''2. Isakhiwo Semitjho.''' ===
Isakhiwo semitjho siwela ngaphasi kwesifundo sesintheksi (uYusuf no-Ali, 2025)&lt;ref name=&quot;:1&quot;&gt;Yusuf, F., &amp; Ali, A. 2025. Unveiling the Role of Grammar Mastery: How Sentence Structure, Verb, and Subject-Verb Agreement Shape Tenses Usage in English Learning. ''Panyonara: Journal of English Education'', 7(1):103-123.&lt;/ref&gt;. Isintheksi kusifundo esiphathelene nokutlolwa nokuhleleka kuhle kwemitjho ngendlela leyo engalahli umnqondo (uSkhosana, 1996&lt;ref name=&quot;:2&quot;&gt;Skhosana, P. B. 1996. ''Isilembe SakaMusi''. Via Afrika. Pretoria.&lt;/ref&gt;). Ngamanye amagama, isintheksi kusifundo esinqophe eendleleni ezitjenziswako ekutloleni nanyana ekwakhiweni kwemitjho ngendlela ezwakalako kuloyo oyitlolileko naloyo oyifundako. Tjhejani isibonelo esilandelako:

1. IWikipedia ikhiphe isikhangiso.

Esibonelweni 1, sinikelwe umutjho ‘IWikipedia ikhiphe isikhangiso.’, loyo ositjela bonyana kunesikhangiso esikhitjhwe yiWikipedia. Umutjho lo uyezwakala begodu nomnqondo awudurhisi ofundako. Ungezelela, singatjho bona umutjho lo uphelele ngombana kunongci (.) ekugcineni kwawo. 

Nanyana kunjalo, isakhiwo semitjho siyahluka ngokuya kwelimi elinye nelinye (uSkhosana, 1998&lt;ref name=&quot;:3&quot;&gt;Skhosana, P. B. 1998. Foreign Interferences in the Sound, Grammatical and Lexical System of Southern Ndebele. ''Unpublished M.A dissertation'', University of Pretoria. Pretoria.&lt;/ref&gt;). Ukuragela phambili, ilimi ngalinye lakha imithetho yayo elawula isakhiwo semitjho ngendlela ekhambisana nelimi lelo. Okutjho bonyana kuyakghonakala ukuthi umutjho ungatlolwa ngokufana emalimini ahlukeneko; kodwana, unikele umnqondo nomlayezo ofanako. Esihlokweni esilandelako imethodoloji nebuthelelo ledatha ezisetjenzisiweko ziyahlathululwa. 

=== '''3. Imethodoloji Nebuthelelo Ledatha Ezisetjenzisiweko.''' ===
Isifundo lesi sisebenzise imethodoloji yekhwalithethivu. Ukuya ngokukaCreswell (2003)&lt;ref&gt;Creswell, J. W. 2003. ''Research Design: Qualitative, Quantitative and Mixed Methods Approaches''. 2nd Ed. Thousand Oaks, Calif: Sage.&lt;/ref&gt; asekelwa kuDaniel (2016)&lt;ref&gt;Daniel, E. 2016. The Usefulness of Qualitative and Quantitative Approaches and Methods in Researching Problem-Solving Ability in Science Education Curriculum. ''Journal of Education and Practice'', 17(15):91-100.&lt;/ref&gt;, imethodoloji yekhwalithethivu, yimethodoloji isetjenziswa mrhubhululi loyo isifundo sakhe esinganahlaziyo ledatha leenomboro nanyana ilingelelo. Lokhu kutjho bona, isifundo semethodoloji yekhwalithethivu asisebenzisi amaphesende begodu nobungako bobudisi bezinto (u-Aspers noCorte, 2019&lt;ref&gt;Aspers, P., &amp; Corte, U. 2019. What is Qualitative in Qualitative Research. ''Qualitative Sociology'', 42:139–160.&lt;/ref&gt;; noTaderdoost, 2021&lt;ref&gt;Taherdoost, H. 2021.  Data Collection Methods and Tools for Research; A Step-by-Step Guide to Choose Data Collection Technique for Academic and Business Research Projects. ''International Journal of Academic Research in Management (IJARM)'', 10 (1):10-38.&lt;/ref&gt;). Ngamanye amagama, umrhubhululi osebenzisa imethodoloji yekhwalithethivu ihlaziyo lakhe lisuke lidzimelele emmongweni nemlayezweni omumethwe yidatha yesifundo sakhe. Ngaphasi kwesifundo lesi, imitlolo yesiNdebele ifundiwe bese kwatshwaywa leyo enemitjho ngomnqopho wokufuna ukufunda nokuhlaziya isakhiwo semitjho leyo. Ukungezelela, ihlaziyo leli linqophe ezintweni ezakha imitjho, ubujamo bazo bendabuko nemihlobo yemitjho. Imiphumela ihlaziwile begodu kwanikela ngesiphetho. 

Ibuthelelo ledatha, ihlaziyo lomtlolo, lisetjenzisiwe nalo ngaphasi kwesifundo lesi. Ibuthelelo ledatha ihlaziyo lomtlolo, libuthelelo ledatha lelo elisetjenziswa ukubuthelela idatha emitlolo kwaphela (uSharma, 2023&lt;ref&gt;Sharma, Y. 2023. Data Collection in Research: Concept, Process and Methods. ''International Journal of Creative Research Thoughts'', 11(10):27-33.&lt;/ref&gt;; noDewi, 2021&lt;ref&gt;Dewi, I. G. A. A. O. 2021. Understanding Data Collection Methods in Qualitative Research: The Perspective of Interpretive Accounting Research. ''Journal of Tourism Economics and Policy'', 1(1):8-15.&lt;/ref&gt;). Ukungezelela, ibuthelelo ledatha ihlaziyo lomtlolo linikela umrubhululi amano wokubuthelela idatha emitlolo leya efaka hlangana isihlathululimagama, incwadi nomtlolo wemikhangiso ukuze umrhubhululi ekhethe idatha enqophileko kusifundo sakhe (uKibiswa, 2019&lt;ref&gt;Kibiswa, N. K. 2019. Directed Qualitative Content Analysis (DQlCA): A Tool for Conflict Analysis. ''The Qualitative Report'', 24(8), 2059-2079.&lt;/ref&gt;; noNicmanis, 2024&lt;ref&gt;Nicmanis, M. 2024. Reflexive Content Analysis: An Approach to Qualitative Data Analysis, Reduction, and Description. ''International Journal of Qualitative Methods'', 23:1–12.&lt;/ref&gt;). Ngaphasi kwesifundo lesi, idatha yemitolo enemitjho yesiNdebele ifundiwe bese kutshwaywa leyo elungele isifundo lesi bona iyokuhlaziywa ngokungeneleleko. Esihlokweni esilandelako ithiyori esetjenziswe esifundweni lesi iyahlathululwa. 

=== '''4. Ithiyori Yesifundo.''' ===
Ithiyori, ihlaziyo lommongo, isetjenzisiwe ngaphasi kwesifundo lesi. Ithiyori ihlaziyo lommongo, yithiyori enzinze khulu ngaphasi kokuhlaziya ummongo womtlolo ukuze kufumaneke umlayezo wawo (uMayring, 2014&lt;ref&gt;Mayring, P. 2014. ''Qualitative Content Analysis: Theoretical Foundation, Basic Procedures and Software Solution''. Klagenfurt.&lt;/ref&gt;; noRochson, u-Adade-Yeboah no-Owusu, 2023&lt;ref&gt;Rockson, K., Adade-Yeboah, A., &amp; Owusu, E. 2023. A Textual Analysis of President Akufo-Addo’s 12th Covid–19 Address. ''Journal of English Teaching'', 9(2):252-268.&lt;/ref&gt;). Ukungezelela, esikhathini esinengi imitlolo imumethe imilayezo efihlakeleko begodu ukuze ifunywane kufanele kuhlaziywe ummongo wayo ngomnqopho wokuwuzisisa bonyana uwakhekhe njani, usebenza njani begodu umlayezo wawo yini (uShort, 2024&lt;ref&gt;Short, C. E. 2025. ''Textual analysis''. In: Grossmann-Hensel, B., Jarzabkowski, P., Kratochvil, R., Seidl, D., Spee, A. P., &amp; Whittington, R. (Eds.) Elgar Encyclopedia of Strategy as Practice. Edward Elgar Publishing.&lt;/ref&gt;). Ngamanye amagama, ithiyori ihlaziyo lommongo linikela umrhubhululi amano wokuhlaziya imitlolo eminengi ngomnqopho wokuzwisisa bonyana isetjenziswa njani ebujameni bayo bendabuko. 

Ngaphasi kwesifundo lesi, imitlolo enemitjho yesiNdebele ihlaziywile ngomnqopho wokuzwisisa bona yakhiwe ngani. Ukungezelela, ubujamo bezakhi zemitjho yesiNdebele bendabuko nabo buhlaziywile bonyan bukuphi emitjhweni begodu imitjho le inemihlobo emingaki. Ekugcineni, kunikelwe ngesiphetho mayelana nalokho okuvunjululwe kusifundo lesi. Esihlokweni esilandelako imitlolo ehlobene nesifundo lesi itjhejiwe. 

=== '''5. Imitjho Ehlobene Nesifundo Lesi.''' ===
Imitjho inezakhi zayo ezenza bonyana izakhiwo zayo zihleleke kuhle. Ukuya ngokukaHamraqulova (2023)&lt;ref name=&quot;:4&quot;&gt;Hamraqulva, O. 2023. Sentence Structure in English Grammar Study in National Groups. ''Texas Journal of Philogy, Culture and History'', 17:25-29.&lt;/ref&gt; isakhiwo semitjho senziwe ngezinto ezinengi lezi ezifaka hlangana iinkhekhe zekulumo. UHamraqulova (2023)&lt;ref name=&quot;:4&quot; /&gt; uveze lokhu esifundweni sakhe sesihloko esithi, ‘''Sentence Structure in English Grammar Study in National Groups’'', lapho bekuhlaziywa khona ukukghedlwa kweenkhekhe zekulumo ezahlukeneko ezitholakala emitjhweni yesiNgisi. Isifundo lesi sifunyene bona kunobudisi bokutshwaya nokwazi iinkhekhe zekulumo ezisetjenziswa emitjhweni. UHamraqulova (2023)&lt;ref name=&quot;:4&quot; /&gt; uphakamise bona kufanele iinkhekhe zekulumo ezitholakala emutjhweni zitlolwe phasi begodu zifundiswe abasebenzisi belimi.

Ngesikhathi uHamraqulova (2023)&lt;ref name=&quot;:4&quot; /&gt; enze isifundo esinzinze eenkhekheni zekulumo ezitholakala esakhiweni somutjho, uYusuf no-Ali (2025)&lt;ref name=&quot;:1&quot; /&gt; bese isifundo leso esinqophe eendimeni ezidlalwa isakhiwo semitjho lokha nawusebenzisa begodu ufunda isiNgisi, ngaphasi kwesihloko esithi, ‘''Unveiling the Role of Grammar Mastery: How Sentence Structure, Verb, and Subject-Verb Agreement Shape Tenses Usage in English Learning’''.  UYusuf no-Ali (2025)&lt;ref name=&quot;:1&quot; /&gt; bafunyene bona izakhiwo zomutjho ezifaka hlangana ihloko yomutjho, isenzo nomenzi zidlala indima eqakathekileko ekuthuthukiseni ilwazi lelimi kubafundi. Kodwana, umraro ovunjululiweko kukuthi abafundi abanengi abanakghono lokuhlanganisa kuhle izakhi lezo emutjhweni. UYusuf no-Ali (2025)&lt;ref name=&quot;:1&quot; /&gt; baphakamise bona ikharikhyulamu yefundo kufanele yenze isifundo leso esinzinze ekusetjenzisweni kwelimi nehlelo ukuze abafundi bazokwazi ukumunya ilwazi lokuthuthukisa ikghono labo lehlelo nelimi. 

Ngokufani nesifundo sakaYusuf no-Ali (2025)&lt;ref name=&quot;:1&quot; /&gt;, uPhilippakos noZoi (2019)&lt;ref name=&quot;:5&quot;&gt;Philippakos, T., &amp; Zoi, A. 2019. Sentence Construction: Supporting Elementary Students’ Editing Skills. ''The Language and Literacy Spectrum'', 29(1):1-23.&lt;/ref&gt; benze isifundo sesihloko esithi, ‘''Sentence Construction: Supporting Elementary Students’ Editing Skills''’, lapho bekuhlaziywa khona amakghono angasetjenziswa ukulungisa iimphoso zemitjho bafundi bamabanga aphasi. Isifundo lesi sifunyene bona abafundi abanengi bamabanga aphasi abanamakghono wokulungisa iimphoso zemitjho, khulukhulu imitjho ezizitjho. UPhilippakos noZoi (2019)&lt;ref name=&quot;:5&quot; /&gt; bakhombele bona abafundisi bamabanga aphasi kufanele bafundise abafundi ngezitjho kanye namaqhinga wokulungisa iimphoso. 

Amanye wamakghono asetjenziswa ngesikhathi kutlolwa nanyana kusetjenziswa imitjho afaka hlangana ukuhlukanisa nokukghedla umutjho omude. Lokhu kufakazelwe sifundo sakaYu (2021) &lt;ref name=&quot;:0&quot; /&gt;sesihloko esithi, ‘''A Study on the Role of Sentence Structure Analysis in English Learning''’, lokha nakaveza bonyana abafundi abanengi baba nesitjhijilo sokuzwisisa nokukghedlha imitjho emide. Umnqopho omkhulu wesifundo sakaYu (2021)&lt;ref name=&quot;:0&quot; /&gt; bekukuhlaziya izwisiso labafundi mayelana nemitjho emide. UYu (2021)&lt;ref name=&quot;:0&quot; /&gt; uphakamise bona abafundi laba kufanele bafundiswe ngamaqhinga wokuzilolonga wehlelo nelimi, khulukhulu ngokunqopha emitjhweni emide ukuze bakwazi ukufunyana amakghono afunekako nakuza ekukghedlhweni nokuzwisweni imitjho emide. 

Ekulunyweni engehla le, kukhulunywe ngezakhi ezisetjenziswako nakwenziwa isakhiwo semitjho, kanye neendima imitjho enayo ekuthuthukiseli ilwazi nekghono lehlelo lelimi. Ukungezelela, kubuywe kwaveza ubudisi obumayelana nokuzwisisa imitjho emide. Woke amaphuzu nemibono evunjululwe ngehla le, iveza isidingo sokurhubhulula ngesakhiwo semitjho ngokunqopha kuzinto ezitholakala emitjhweni, ubujamo bazo bendabuko nemihlobo yemitjho ekhona esiNdebeleni. Esihlokweni esilandelako idatha iyahlaziywa. 

=== '''6. Ihlaziyo Ledatha.''' ===
Isakhiwo semitjho singakhiwa ngezinto ezinengi; kodwana, ihloko yomutjho nesenzo zihlala zikhona esakhiweni somutjho (uSkhosana, 1996)&lt;ref name=&quot;:2&quot; /&gt;. Ngamanye amagama, ihloko yomutjho nesenzo kuzizinto ezisisekelo esakhiweni somutjho begodu esikhathini esinengi azitlhogeki emtjhweni. Tjhejani isibonelo esilandelako:

2. Inja idla amaqanda.

Esibonelweni 2, sinikelwe umutjho ‘Inja idla amaqanda’, loyo owakhiwe ngehloko yomutjho ‘Inja’, isenzo ‘idla’ nemenziwa ‘amaqanda’. Ukungezelela, sithole bona ihloko yomutjho ‘Inja’ isekuthomeni komutjho bese isenzo ‘idla’ sibe phakathi. Umenziwa yena ‘amaqanda’ usekugcineni komutjho. Lokhu kuyasibikela bonyana indawo yehloko yomutjho ngokwendabuko isekuthomeni komutjho; isenzo indawo yaso ngokwendabuko iphakathi emutjhweni bese kuthi umenziwa indawo yakhe ngokwendabuko emutjhweni isekugcineni njengombana kufakazelwa nguSkhosana (1998)&lt;ref name=&quot;:3&quot; /&gt;.

Nanyana kunjalo, kukhona iinkhekhe zekulumo ezitholakala emutjhweni njengoba kufakazelwe nguHamraqulova (2023)&lt;ref name=&quot;:4&quot; /&gt;. Tjhejani isibonelo esilandelako:

3. Isifundo lesi sibudisi.

Esibonelweni 3 esingehla, sinikelwe umutjho, ‘Isifundo lesi sibudisi’, loyo owakhiwe ngeenkhekhe zekulumo ezahlukeneko. Igama ‘Isifundo’ kusikhekhe sekulumo ibizo; igama ‘lesi’ kusikhekhe sekulumo isabizwana sokukhomba eduze bese kuthi ibizo ‘sibudisi’ kusitlhadlhululi esisiphawulo. Lokhu kuyasivezela bonyana umutjho awakhiwa ngehloko, isenzo nemenziwa kwaphela; kodwana, ihloko, isenzo nomenziwa lezo zingawela ngaphasi kweenkhekhe zekulumo ezahlukeneko.

Nanyana kunjalo, imitjho engaphasi kwesibonelo 2 no-3 ngokulandelana ukuze ilethe imiqondo ezwakalako isebenzise iinthomo neemvumelwano. Ngaphasi komutjho wesibonelo 2, sifunyene isithomo sehloko u-‘i’ ohlonyelelwe kusiqu sehloko ‘-nja’ nesivumelwano sehloko u-‘i-’ ohlonyelelwe kusiqu sesenzo ‘-dla’ bese kuthi isithomo sakamenziwa u-‘ama-’ uhlonyelelwe kusiqu sakamenziwa ‘-qanda’.

Bese kuthi ngaphasi komutjho wesibonelo 3, sifunyene isithomo sehloko u-‘isi’ ohlonyelelwe kusiqu sehloko ‘-fundo’ nesivumelwano sehloko u-‘si-’ ohlonyelelwe kusiqu sesitlhadlhuli ‘-budisi’. Isabizwana sokukhomba eduze ‘lesi’ asinasithomo. Kodwana, sisebujameni bobunye ngombana ihloko yomutjho nayo isebujameni bobunye.

Okunye okuvunjululiweko kukuthi imihlobo yemitjho iyahluka njengoba kwavakazelwa nguSkhosana (1996)&lt;ref name=&quot;:2&quot; /&gt;. Tjhejani iimbonelo ezilandelako:

4. Ubaba uthenge ikoloyi.

5. UJabu udinwe khulu namhlanje ngombana bekagijima.

6. Kutjhayisene iinkoloyi ezimbili kwalimala abantu abambalwa. 

Esibonelweni 4, sinikelwe umutjho ‘Ubaba uthenge ikoloyi’ loyo owenziwe ngehloko yomutjho (Ubaba) eyodwa; isenzo sinye (uthenge) nomenziwa oyedwa (ikoloyi). Umutjho lo waziwa ngokuthi mumutjho onqophileko nanyana mumutjho olula (uSkhosana, 1996)&lt;ref name=&quot;:2&quot; /&gt;.

Ngokungafani nomutjho wesibonelo 4, kusibonelo 5 sinikelwe umutjho ‘UJabu udinwe khulu namhlanje ngombana bekagijima’, loyo owenziwe ngehloko (UJabu), izenzo (unidinwe nobakagijima), isitlhadlhuli (khulu), isinabiso (namhlanje) nesihlanganiso (ngombana). Umutjho lo ubizwa bona mumutjho ovangileko. Ngokuya kukaSkhosana (1996)&lt;ref name=&quot;:2&quot; /&gt; umutjho ovangileko siwubona ngeenhlanganiso ezinjengo-‘ngombana, bese nonanyana’ lezo ezihlanganisa imitjho embili ukuze kubumbeke umutjho munye. Nasitjheja umutjho wesibonelo 5, singawuhlukanisa ngemitjho embili; -UJabu udinwe khulu namhlanje; -bekagijima.

Umutjho wokugcina esinikelwe wona kusibonelo 6, u-‘ Kutjhayisene iinkoloyi ezimbili kwalimala abantu abambalwa’, loyo owenziwe ngemitjho edlula kemibili engakghedlwa ngale indlela:

-         Kutjahyisene iinkoloyi

-         Ezimbili

-         Kwalimala abantu abambalwa 

Ingcenye yokuthoma, kutjhayisene iinkoloyi, kumumutjho omkhulu ngombana yoke into ithoma kiwo. ‘Ezimbili’, kumumutjho wesenzo esizijameleko, bese kuthi ingcenye yesithathu ‘kwalimala abantu amambalwa’ kumumutjho oyamileko ngombana uphethe imiphumela yalokho okubangwe yingcenye yokuthoma nanyana umutjho omkhulu. Loku kuyasibikela bonyana imitjho ingahlukana kathathu ngokuya komlayezo ewumumetheko.

=== '''7. Isiphetho.''' ===
Isakhiwo semitjho yesiNdebele sihlaziwile ngaphasi kwesifundo lesi begodu kwavunjululwa bona izakhi ezifana nehloko yomutjho isenzo nomenziwa kanengi zihlala zikhona. Ukuragela phambili, imitjho le ifunyenwe bonyana izakhi zayo zingawela ngaphasi kweenkhekhe zekulumo ezahlukeneko njengesitlhadlhuli nebizo. Kokugcina, kuvunjululwe bona imitjho le imihlobo emithathu ehlukeneko. 

Isakhiwo semitjho siqakathekile bona sifundwe besizwisiswe ngombana sifundisa ngelwazi nekghono lehlelo nelimi. Ukungezelela, ukuzwisisa isakhiwo semitjho kwenza kube lula ukwakha nanyana ukutlola imitjho ezakwalako.   

=== '''Umthombolwazi.''' ===
&lt;references /&gt;</text>
      <sha1>6ozuwknw6vok93cbw80vftb5jpagk46</sha1>
    </revision>
    <revision>
      <id>6177</id>
      <parentid>6176</parentid>
      <timestamp>2026-02-17T14:37:25Z</timestamp>
      <contributor>
        <username>Owaziwako</username>
        <id>24</id>
      </contributor>
      <origin>6177</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="17094" sha1="f455p7oqenus8oszyetz10up5mh9xyn" xml:space="preserve">== '''Ihlaziyo Lesakhiwo Esisi Sekelo Semitjho YesiNdebele.''' == 

=== '''1. Isingeniso.''' ===
Isakhiwo semitjho siqakathekile ekwenzeni isiqiniseko sokuthi umutjho uzwakala kuhle begodu umlayezo wawo uyazwisiseka. Ukungezelela, isakhiwo semitjho sidlala indima ekulu ekuthuthukiseni ilwazi nezinga lekghono lelimi kubasebenzisi balo. Ngamanye amagama, isakhiwo semitjho sinomthintela kiloyo osakhako naloyo uzowufunda nanyana asebenzise umutjho loyo. 

Ukuya ngokukaYu (2021)&lt;ref name=&quot;:0&quot;&gt;Yu, X. 2021. A Study on the Role of Sentence Structure Analysis in English Learning. ''Open Access Library Journal'', 8:1-14.&lt;/ref&gt; pheze woke umuntu osebenzisa ilimi elithize kufanele azwisise isakhiwo semitjho. Ukungezelela, isakhiwo semitjho sithinta boke abasenzisi belimi lelo ekufaka hlangana abatloli, abafundisi, abarhubhululi, abarhatjhi, abatlami beenhlathululimagama namathemu nabafundi. Lokhu kuyasivezela bona isakhiwo semitjho siqakatheke kangangani begodu kuyakateleleka bonyana nawumsebenzisi welimi usazi. 

Ngaphasi kwesifundo lesi sizokutjheja isakhiwo semitjho ngaphasi kwesiNdebele. Isakhiwo semitjho lesi sizokuhlaziywa ngokunqopha kuzinto ezakha imitjho, ubujamo bazo bendabuko emutjhweni kanye nemihlobo yemitjho. Imethodoloji yekhwalithethivu nebuthelelo ledatha, ihlaziyo lemitlolo, zisetjenzisiwe. Ukungezelela, ithiyori yehlaziyo lommongo isetjenzisiwe nayo. Imiphumela yehlaziyo ledatha izokurhunyutjhwa bese kunikelwe ngalokho okuvunjululiweko. Esihlokweni esilandelako isakhiwo semitjho siyahlathululwa. 

=== '''2. Isakhiwo Semitjho.''' ===
Isakhiwo semitjho siwela ngaphasi kwesifundo sesintheksi (uYusuf no-Ali, 2025)&lt;ref name=&quot;:1&quot;&gt;Yusuf, F., &amp; Ali, A. 2025. Unveiling the Role of Grammar Mastery: How Sentence Structure, Verb, and Subject-Verb Agreement Shape Tenses Usage in English Learning. ''Panyonara: Journal of English Education'', 7(1):103-123.&lt;/ref&gt;. Isintheksi kusifundo esiphathelene nokutlolwa nokuhleleka kuhle kwemitjho ngendlela leyo engalahli umnqondo (uSkhosana, 1996&lt;ref name=&quot;:2&quot;&gt;Skhosana, P. B. 1996. ''Isilembe SakaMusi''. Via Afrika. Pretoria.&lt;/ref&gt;). Ngamanye amagama, isintheksi kusifundo esinqophe eendleleni ezitjenziswako ekutloleni nanyana ekwakhiweni kwemitjho ngendlela ezwakalako kuloyo oyitlolileko naloyo oyifundako. Tjhejani isibonelo esilandelako:

1. IWikipedia ikhiphe isikhangiso.

Esibonelweni 1, sinikelwe umutjho ‘IWikipedia ikhiphe isikhangiso.’, loyo ositjela bonyana kunesikhangiso esikhitjhwe yiWikipedia. Umutjho lo uyezwakala begodu nomnqondo awudurhisi owufundako. Ungezelela, singatjho bona umutjho lo uphelele ngombana kunongci (.) ekugcineni kwawo. 

Nanyana kunjalo, isakhiwo semitjho siyahluka ngokuya kwelimi elinye nelinye (uSkhosana, 1998&lt;ref name=&quot;:3&quot;&gt;Skhosana, P. B. 1998. Foreign Interferences in the Sound, Grammatical and Lexical System of Southern Ndebele. ''Unpublished M.A dissertation'', University of Pretoria. Pretoria.&lt;/ref&gt;). Ukuragela phambili, ilimi ngalinye lakha imithetho yayo elawula isakhiwo semitjho ngendlela ekhambisana nelimi lelo. Okutjho bonyana kuyakghonakala ukuthi umutjho ungatlolwa ngokufana emalimini ahlukeneko; kodwana, unikele umnqondo nomlayezo ofanako. Esihlokweni esilandelako imethodoloji nebuthelelo ledatha ezisetjenzisiweko ziyahlathululwa. 

=== '''3. Imethodoloji Nebuthelelo Ledatha Ezisetjenzisiweko.''' ===
Isifundo lesi sisebenzise imethodoloji yekhwalithethivu. Ukuya ngokukaCreswell (2003)&lt;ref&gt;Creswell, J. W. 2003. ''Research Design: Qualitative, Quantitative and Mixed Methods Approaches''. 2nd Ed. Thousand Oaks, Calif: Sage.&lt;/ref&gt; asekelwa kuDaniel (2016)&lt;ref&gt;Daniel, E. 2016. The Usefulness of Qualitative and Quantitative Approaches and Methods in Researching Problem-Solving Ability in Science Education Curriculum. ''Journal of Education and Practice'', 17(15):91-100.&lt;/ref&gt;, imethodoloji yekhwalithethivu, yimethodoloji esetjenziswa mrhubhululi loyo isifundo sakhe esinganahlaziyo ledatha leenomboro nanyana ilingelelo. Lokhu kutjho bona, isifundo semethodoloji yekhwalithethivu asisebenzisi amaphesende begodu nobungako bobudisi bezinto (u-Aspers noCorte, 2019&lt;ref&gt;Aspers, P., &amp; Corte, U. 2019. What is Qualitative in Qualitative Research. ''Qualitative Sociology'', 42:139–160.&lt;/ref&gt;; noTaderdoost, 2021&lt;ref&gt;Taherdoost, H. 2021.  Data Collection Methods and Tools for Research; A Step-by-Step Guide to Choose Data Collection Technique for Academic and Business Research Projects. ''International Journal of Academic Research in Management (IJARM)'', 10 (1):10-38.&lt;/ref&gt;). Ngamanye amagama, umrhubhululi osebenzisa imethodoloji yekhwalithethivu ihlaziyo lakhe lisuke lidzimelele emmongweni nemlayezweni omumethwe yidatha yesifundo sakhe. Ngaphasi kwesifundo lesi, imitlolo yesiNdebele ifundiwe bese kwatshwaywa leyo enemitjho ngomnqopho wokufuna ukufunda nokuhlaziya isakhiwo semitjho leyo. Ukungezelela, ihlaziyo leli linqophe ezintweni ezakha imitjho, ubujamo bazo bendabuko nemihlobo yemitjho leyo. Imiphumela ihlaziwile begodu kwanikela ngesiphetho. 

Ibuthelelo ledatha, ihlaziyo lomtlolo, lisetjenzisiwe nalo ngaphasi kwesifundo lesi. Ibuthelelo ledatha ihlaziyo lomtlolo, libuthelelo ledatha lelo elisetjenziswa ukubuthelela idatha emitlolo kwaphela (uSharma, 2023&lt;ref&gt;Sharma, Y. 2023. Data Collection in Research: Concept, Process and Methods. ''International Journal of Creative Research Thoughts'', 11(10):27-33.&lt;/ref&gt;; noDewi, 2021&lt;ref&gt;Dewi, I. G. A. A. O. 2021. Understanding Data Collection Methods in Qualitative Research: The Perspective of Interpretive Accounting Research. ''Journal of Tourism Economics and Policy'', 1(1):8-15.&lt;/ref&gt;). Ukungezelela, ibuthelelo ledatha ihlaziyo lomtlolo linikela umrubhululi amano wokubuthelela idatha emitlolo leya efaka hlangana isihlathululimagama, incwadi nomtlolo wemikhangiso ukuze umrhubhululi ekhethe idatha enqophileko kusifundo sakhe (uKibiswa, 2019&lt;ref&gt;Kibiswa, N. K. 2019. Directed Qualitative Content Analysis (DQlCA): A Tool for Conflict Analysis. ''The Qualitative Report'', 24(8), 2059-2079.&lt;/ref&gt;; noNicmanis, 2024&lt;ref&gt;Nicmanis, M. 2024. Reflexive Content Analysis: An Approach to Qualitative Data Analysis, Reduction, and Description. ''International Journal of Qualitative Methods'', 23:1–12.&lt;/ref&gt;). Ngaphasi kwesifundo lesi, idatha yemitolo enemitjho yesiNdebele ifundiwe bese kutshwaywa leyo elungele isifundo lesi bona iyokuhlaziywa ngokungeneleleko. Esihlokweni esilandelako ithiyori esetjenziswe esifundweni lesi iyahlathululwa. 

=== '''4. Ithiyori Yesifundo.''' ===
Ithiyori, ihlaziyo lommongo, isetjenzisiwe ngaphasi kwesifundo lesi. Ithiyori ihlaziyo lommongo, yithiyori enzinze khulu ngaphasi kokuhlaziya ummongo womtlolo ukuze kufumaneke umlayezo wawo (uMayring, 2014&lt;ref&gt;Mayring, P. 2014. ''Qualitative Content Analysis: Theoretical Foundation, Basic Procedures and Software Solution''. Klagenfurt.&lt;/ref&gt;; noRochson, u-Adade-Yeboah no-Owusu, 2023&lt;ref&gt;Rockson, K., Adade-Yeboah, A., &amp; Owusu, E. 2023. A Textual Analysis of President Akufo-Addo’s 12th Covid–19 Address. ''Journal of English Teaching'', 9(2):252-268.&lt;/ref&gt;). Ukungezelela, esikhathini esinengi imitlolo imumethe imilayezo efihlakeleko begodu ukuze ifunywane kufanele kuhlaziywe ummongo wayo ngomnqopho wokuwuzisisa bonyana uwakhekhe njani, usebenza njani begodu umlayezo wawo yini (uShort, 2024&lt;ref&gt;Short, C. E. 2025. ''Textual analysis''. In: Grossmann-Hensel, B., Jarzabkowski, P., Kratochvil, R., Seidl, D., Spee, A. P., &amp; Whittington, R. (Eds.) Elgar Encyclopedia of Strategy as Practice. Edward Elgar Publishing.&lt;/ref&gt;). Ngamanye amagama, ithiyori ihlaziyo lommongo linikela umrhubhululi amano wokuhlaziya imitlolo eminengi ngomnqopho wokuzwisisa bonyana isetjenziswa njani ebujameni bayo bendabuko. 

Ngaphasi kwesifundo lesi, imitlolo enemitjho yesiNdebele ihlaziywile ngomnqopho wokuzwisisa bona yakhiwe ngani. Ukungezelela, ubujamo bendabuko bezakhi zemitjho yesiNdebele nabo buhlaziywile bonyana bukuphi emitjhweni begodu imitjho le inemihlobo emingaki. Ekugcineni, kunikelwe ngesiphetho mayelana nalokho okuvunjululwe kusifundo lesi. Esihlokweni esilandelako imitlolo ehlobene nesifundo lesi itjhejiwe. 

=== '''5. Imitjho Ehlobene Nesifundo Lesi.''' ===
Imitjho inezakhi zayo ezenza bonyana izakhiwo zayo zihleleke kuhle. Ukuya ngokukaHamraqulova (2023)&lt;ref name=&quot;:4&quot;&gt;Hamraqulva, O. 2023. Sentence Structure in English Grammar Study in National Groups. ''Texas Journal of Philogy, Culture and History'', 17:25-29.&lt;/ref&gt; isakhiwo semitjho senziwe ngezinto ezinengi lezi ezifaka hlangana iinkhekhe zekulumo. UHamraqulova (2023)&lt;ref name=&quot;:4&quot; /&gt; uveze lokhu esifundweni sakhe sesihloko esithi, ‘''Sentence Structure in English Grammar Study in National Groups’'', lapho bekuhlaziywa khona ukukghedlwa kweenkhekhe zekulumo ezahlukeneko ezitholakala emitjhweni yesiNgisi. Isifundo lesi sifunyene bona kunobudisi bokutshwaya nokwazi iinkhekhe zekulumo ezisetjenziswa emitjhweni. UHamraqulova (2023)&lt;ref name=&quot;:4&quot; /&gt; uphakamise bona kufanele iinkhekhe zekulumo ezitholakala emutjhweni zitlolwe phasi begodu zifundiswe abasebenzisi belimi.

Ngesikhathi uHamraqulova (2023)&lt;ref name=&quot;:4&quot; /&gt; enze isifundo esinzinze eenkhekheni zekulumo ezitholakala esakhiweni somutjho, uYusuf no-Ali (2025)&lt;ref name=&quot;:1&quot; /&gt; benze isifundo leso esinqophe eendimeni ezidlalwa isakhiwo semitjho lokha nawusebenzisa begodu ufunda isiNgisi, ngaphasi kwesihloko esithi, ‘''Unveiling the Role of Grammar Mastery: How Sentence Structure, Verb, and Subject-Verb Agreement Shape Tenses Usage in English Learning’''.  UYusuf no-Ali (2025)&lt;ref name=&quot;:1&quot; /&gt; bafunyene bona izakhiwo zomutjho ezifaka hlangana ihloko yomutjho, isenzo nomenzi zidlala indima eqakathekileko ekuthuthukiseni ilwazi lelimi kubafundi. Kodwana, umraro ovunjululiweko kukuthi abafundi abanengi abanakghono lokuhlanganisa kuhle izakhi lezo emutjhweni. UYusuf no-Ali (2025)&lt;ref name=&quot;:1&quot; /&gt; baphakamise bona ikharikhyulamu yezefundo kufanele yenze isifundo leso esinzinze ekusetjenzisweni kwelimi nehlelo ukuze abafundi bazokwazi ukumunya ilwazi lokuthuthukisa ikghono labo lehlelo nelimi. 

Ngokufani nesifundo sakaYusuf no-Ali (2025)&lt;ref name=&quot;:1&quot; /&gt;, uPhilippakos noZoi (2019)&lt;ref name=&quot;:5&quot;&gt;Philippakos, T., &amp; Zoi, A. 2019. Sentence Construction: Supporting Elementary Students’ Editing Skills. ''The Language and Literacy Spectrum'', 29(1):1-23.&lt;/ref&gt; benze isifundo sesihloko esithi, ‘''Sentence Construction: Supporting Elementary Students’ Editing Skills''’, lapho bekuhlaziywa khona amakghono angasetjenziswa ukulungisa iimphoso zemitjho bafundi bamabanga aphasi. Isifundo lesi sifunyene bona abafundi abanengi bamabanga aphasi abanamakghono wokulungisa iimphoso zemitjho, khulukhulu imitjho ezizitjho. UPhilippakos noZoi (2019)&lt;ref name=&quot;:5&quot; /&gt; bakhombele bona abafundisi bamabanga aphasi kufanele bafundise abafundi ngezitjho kanye namaqhinga wokulungisa iimphoso. 

Amanye wamakghono asetjenziswa ngesikhathi kutlolwa nanyana kusetjenziswa imitjho afaka hlangana ukuhlukanisa nokukghedla umutjho omude. Lokhu kufakazelwe sifundo sakaYu (2021) &lt;ref name=&quot;:0&quot; /&gt;sesihloko esithi, ‘''A Study on the Role of Sentence Structure Analysis in English Learning''’, lokha nakaveza bonyana abafundi abanengi baba nesitjhijilo sokuzwisisa nokukghedlha imitjho emide. Umnqopho omkhulu wesifundo sakaYu (2021)&lt;ref name=&quot;:0&quot; /&gt; bekukuhlaziya izwisiso labafundi mayelana nemitjho emide. UYu (2021)&lt;ref name=&quot;:0&quot; /&gt; uphakamise bona abafundi laba kufanele bafundiswe ngamaqhinga wokuzilolonga wehlelo nelimi, khulukhulu ngokunqopha emitjhweni emide ukuze bakwazi ukufunyana amakghono afunekako nakuza ekukghedlhweni nokuzwisisweni imitjho emide. 

Ekulunyweni engehla le, kukhulunywe ngezakhi ezisetjenziswako nakwenziwa isakhiwo semitjho, kanye neendima imitjho enayo ekuthuthukiseni ilwazi nekghono lehlelo lelimi. Ukungezelela, kubuywe kwavezwa ubudisi obumayelana nokuzwisisa imitjho emide. Woke amaphuzu nemibono evunjululwe ngehla le, iveza isidingo sokurhubhulula ngesakhiwo semitjho ngokunqopha kuzinto ezitholakala emitjhweni, ubujamo bazo bendabuko nemihlobo yemitjho ekhona esiNdebeleni. Esihlokweni esilandelako idatha iyahlaziywa. 

=== '''6. Ihlaziyo Ledatha.''' ===
Isakhiwo semitjho singakhiwa ngezinto ezinengi; kodwana, ihloko yomutjho nesenzo zihlala zikhona esakhiweni somutjho (uSkhosana, 1996)&lt;ref name=&quot;:2&quot; /&gt;. Ngamanye amagama, ihloko yomutjho nesenzo kuzizinto ezisisekelo esakhiweni somutjho begodu esikhathini esinengi azitlhogeki emtjhweni. Tjhejani isibonelo esilandelako:

2. Inja idla amaqanda.

Esibonelweni 2, sinikelwe umutjho ‘Inja idla amaqanda’, loyo owakhiwe ngehloko yomutjho ‘Inja’, isenzo ‘idla’ nomenziwa ‘amaqanda’. Ukungezelela, sithole bona ihloko yomutjho ‘Inja’ isekuthomeni komutjho bese isenzo ‘idla’ sibe phakathi. Umenziwa yena ‘amaqanda’ usekugcineni komutjho. Lokhu kuyasibikela bonyana indawo yehloko yomutjho ngokwendabuko isekuthomeni komutjho; isenzo indawo yaso ngokwendabuko iphakathi emutjhweni bese kuthi umenziwa indawo yakhe ngokwendabuko emutjhweni isekugcineni begodu kufakazelwa nguSkhosana (1998)&lt;ref name=&quot;:3&quot; /&gt;.

Nanyana kunjalo, kukhona iinkhekhe zekulumo ezitholakala emutjhweni njengoba kufakazelwe nguHamraqulova (2023)&lt;ref name=&quot;:4&quot; /&gt;. Tjhejani isibonelo esilandelako:

3. Isifundo lesi sibudisi.

Esibonelweni 3 esingehla, sinikelwe umutjho, ‘Isifundo lesi sibudisi’, loyo owakhiwe ngeenkhekhe zekulumo ezahlukeneko. Igama ‘Isifundo’ kusikhekhe sekulumo ibizo; igama ‘lesi’ kusikhekhe sekulumo isabizwana sokukhomba eduze bese kuthi ibizo ‘sibudisi’ kusitlhadlhululi esisiphawulo. Lokhu kuyasivezela bonyana umutjho awakhiwa ngehloko, isenzo nomenziwa kwaphela; kodwana, ihloko, isenzo nomenziwa lezo zingawela ngaphasi kweenkhekhe zekulumo ezahlukeneko.

Nanyana kunjalo, imitjho engaphasi kwesibonelo 2 no-3 ngokulandelana, ukuze ilethe imiqondo ezwakalako isebenzise iinthomo neemvumelwano. Ngaphasi komutjho wesibonelo 2, sifunyene isithomo sehloko u-‘i’ ohlonyelelwe kusiqu sehloko ‘-nja’ nesivumelwano sehloko u-‘i-’ ohlonyelelwe kusiqu sesenzo ‘-dla’ bese kuthi isithomo sakamenziwa u-‘ama-’ uhlonyelelwe kusiqu sakamenziwa ‘-qanda’.

Bese kuthi ngaphasi komutjho wesibonelo 3, sifunyene isithomo sehloko u-‘isi’ ohlonyelelwe kusiqu sehloko ‘-fundo’ nesivumelwano sehloko u-‘si-’ ohlonyelelwe kusiqu sesitlhadlhuli ‘-budisi’. Isabizwana sokukhomba eduze ‘lesi’ asinasithomo nanyana isivumelwano. Kodwana, sisebujameni bobunye ngombana ihloko yomutjho nayo isebujameni bobunye.

Okunye okuvunjululiweko kukuthi imihlobo yemitjho iyahluka njengoba kwavezwa nguSkhosana (1996)&lt;ref name=&quot;:2&quot; /&gt;. Tjhejani iimbonelo ezilandelako:

4. Ubaba uthenge ikoloyi.

5. UJabu udinwe khulu namhlanje ngombana bekagijima.

6. Kutjhayisene iinkoloyi ezimbili kwalimala abantu abambalwa. 

Esibonelweni 4, sinikelwe umutjho ‘Ubaba uthenge ikoloyi’ loyo owenziwe ngehloko yomutjho (Ubaba) eyodwa; isenzo sinye (uthenge) nomenziwa oyedwa (ikoloyi). Umutjho lo waziwa ngokuthi mumutjho onqophileko nanyana mumutjho olula (uSkhosana, 1996)&lt;ref name=&quot;:2&quot; /&gt;.

Ngokungafani nomutjho wesibonelo 4, kusibonelo 5 sinikelwe umutjho ‘UJabu udinwe khulu namhlanje ngombana bekagijima’, loyo owenziwe ngehloko (UJabu), izenzo (udinwe nobakagijima), isitlhadlhuli (khulu), isinabiso (namhlanje) nesihlanganiso (ngombana). Umutjho lo ubizwa bona mumutjho ovangileko. Ngokuya kukaSkhosana (1996)&lt;ref name=&quot;:2&quot; /&gt; umutjho ovangileko siwubona ngeenhlanganiso ezinjengo-‘ngombana, bese nonanyana’ lezo ezihlanganisa imitjho embili ukuze kubumbeke umutjho munye. Nasitjheja umutjho wesibonelo 5, singawuhlukanisa ngemitjho embili; -UJabu udinwe khulu namhlanje; -bekagijima.

Umutjho wokugcina esinikelwe wona kusibonelo 6, u-‘ Kutjhayisene iinkoloyi ezimbili kwalimala abantu abambalwa’, loyo owenziwe ngemitjho edlula kemibili engakghedlwa ngale indlela:

-         Kutjahyisene iinkoloyi

-         Ezimbili

-         Kwalimala abantu abambalwa 

Ingcenye yokuthoma, kutjhayisene iinkoloyi, kumumutjho omkhulu ngombana yoke into ithoma kiwo. ‘Ezimbili’, kumumutjho wesenzo esizijameleko, bese kuthi ingcenye yesithathu ‘kwalimala abantu amambalwa’ kumumutjho oyamileko ngombana uphethe imiphumela yalokho okubangwe yingcenye yokuthoma nanyana umutjho omkhulu. Loku kuyasibikela bonyana [[:en:Sentence_clause_structure|imitjho ingahlukana kathathu]] ngokuya komlayezo ewumumetheko.

=== '''7. Isiphetho.''' ===
Isakhiwo semitjho yesiNdebele sihlaziwile ngaphasi kwesifundo lesi begodu kwavunjululwa bona izakhi ezifana nehloko yomutjho isenzo nomenziwa kanengi zihlala zikhona. Ukuragela phambili, imitjho le ifunyenwe bonyana izakhi zayo zingawela ngaphasi kweenkhekhe zekulumo ezahlukeneko njengesitlhadlhuli nebizo. Kokugcina, kuvunjululwe bona imitjho le imihlobo emithathu ehlukeneko. 

Isakhiwo semitjho siqakathekile bona sifundwe besizwisiswe ngombana sifundisa ngelwazi nekghono lehlelo nelimi. Ukungezelela, ukuzwisisa isakhiwo semitjho kwenza kube lula ukwakha nanyana ukutlola imitjho ezakwalako.   

=== '''Umthombolwazi.''' ===
&lt;references /&gt;</text>
      <sha1>f455p7oqenus8oszyetz10up5mh9xyn</sha1>
    </revision>
    <revision>
      <id>6232</id>
      <parentid>6177</parentid>
      <timestamp>2026-02-23T16:12:53Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <origin>6232</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="16936" sha1="evqhklawobedwonims4n15h0ippyhfb" xml:space="preserve">Isakhiwo semitjho siqakathekile ekwenzeni isiqiniseko sokuthi umutjho uzwakala kuhle begodu umlayezo wawo uyazwisiseka. Ukungezelela, isakhiwo semitjho sidlala indima ekulu ekuthuthukiseni ilwazi nezinga lekghono lelimi kubasebenzisi balo. Ngamanye amagama, isakhiwo semitjho sinomthintela kiloyo osakhako naloyo uzowufunda nanyana asebenzise umutjho loyo. 

Ukuya ngokukaYu (2021)&lt;ref name=&quot;:0&quot;&gt;Yu, X. 2021. A Study on the Role of Sentence Structure Analysis in English Learning. ''Open Access Library Journal'', 8:1-14.&lt;/ref&gt; pheze woke umuntu osebenzisa ilimi elithize kufanele azwisise isakhiwo semitjho. Ukungezelela, isakhiwo semitjho sithinta boke abasenzisi belimi lelo ekufaka hlangana abatloli, abafundisi, abarhubhululi, abarhatjhi, abatlami beenhlathululimagama namathemu nabafundi. Lokhu kuyasivezela bona isakhiwo semitjho siqakatheke kangangani begodu kuyakateleleka bonyana nawumsebenzisi welimi usazi. 

Ngaphasi kwesifundo lesi sizokutjheja isakhiwo semitjho ngaphasi kwesiNdebele. Isakhiwo semitjho lesi sizokuhlaziywa ngokunqopha kuzinto ezakha imitjho, ubujamo bazo bendabuko emutjhweni kanye nemihlobo yemitjho. Imethodoloji yekhwalithethivu nebuthelelo ledatha, ihlaziyo lemitlolo, zisetjenzisiwe. Ukungezelela, ithiyori yehlaziyo lommongo isetjenzisiwe nayo. Imiphumela yehlaziyo ledatha izokurhunyutjhwa bese kunikelwe ngalokho okuvunjululiweko. Esihlokweni esilandelako isakhiwo semitjho siyahlathululwa. 

== '''Isakhiwo Semitjho''' ==
Isakhiwo semitjho siwela ngaphasi kwesifundo sesintheksi (uYusuf no-Ali, 2025)&lt;ref name=&quot;:1&quot;&gt;Yusuf, F., &amp; Ali, A. 2025. Unveiling the Role of Grammar Mastery: How Sentence Structure, Verb, and Subject-Verb Agreement Shape Tenses Usage in English Learning. ''Panyonara: Journal of English Education'', 7(1):103-123.&lt;/ref&gt;. Isintheksi kusifundo esiphathelene nokutlolwa nokuhleleka kuhle kwemitjho ngendlela leyo engalahli umnqondo (uSkhosana, 1996&lt;ref name=&quot;:2&quot;&gt;Skhosana, P. B. 1996. ''Isilembe SakaMusi''. Via Afrika. Pretoria.&lt;/ref&gt;). Ngamanye amagama, isintheksi kusifundo esinqophe eendleleni ezitjenziswako ekutloleni nanyana ekwakhiweni kwemitjho ngendlela ezwakalako kuloyo oyitlolileko naloyo oyifundako. Tjhejani isibonelo esilandelako:

1. IWikipedia ikhiphe isikhangiso.

Esibonelweni 1, sinikelwe umutjho ‘IWikipedia ikhiphe isikhangiso.’, loyo ositjela bonyana kunesikhangiso esikhitjhwe yiWikipedia. Umutjho lo uyezwakala begodu nomnqondo awudurhisi owufundako. Ungezelela, singatjho bona umutjho lo uphelele ngombana kunongci (.) ekugcineni kwawo. 

Nanyana kunjalo, isakhiwo semitjho siyahluka ngokuya kwelimi elinye nelinye (uSkhosana, 1998&lt;ref name=&quot;:3&quot;&gt;Skhosana, P. B. 1998. Foreign Interferences in the Sound, Grammatical and Lexical System of Southern Ndebele. ''Unpublished M.A dissertation'', University of Pretoria. Pretoria.&lt;/ref&gt;). Ukuragela phambili, ilimi ngalinye lakha imithetho yayo elawula isakhiwo semitjho ngendlela ekhambisana nelimi lelo. Okutjho bonyana kuyakghonakala ukuthi umutjho ungatlolwa ngokufana emalimini ahlukeneko; kodwana, unikele umnqondo nomlayezo ofanako. Esihlokweni esilandelako imethodoloji nebuthelelo ledatha ezisetjenzisiweko ziyahlathululwa. 

== '''Imethodoloji Nebuthelelo Ledatha Ezisetjenzisiweko''' ==
Isifundo lesi sisebenzise imethodoloji yekhwalithethivu. Ukuya ngokukaCreswell (2003)&lt;ref&gt;Creswell, J. W. 2003. ''Research Design: Qualitative, Quantitative and Mixed Methods Approaches''. 2nd Ed. Thousand Oaks, Calif: Sage.&lt;/ref&gt; asekelwa kuDaniel (2016)&lt;ref&gt;Daniel, E. 2016. The Usefulness of Qualitative and Quantitative Approaches and Methods in Researching Problem-Solving Ability in Science Education Curriculum. ''Journal of Education and Practice'', 17(15):91-100.&lt;/ref&gt;, imethodoloji yekhwalithethivu, yimethodoloji esetjenziswa mrhubhululi loyo isifundo sakhe esinganahlaziyo ledatha leenomboro nanyana ilingelelo. Lokhu kutjho bona, isifundo semethodoloji yekhwalithethivu asisebenzisi amaphesende begodu nobungako bobudisi bezinto (u-Aspers noCorte, 2019&lt;ref&gt;Aspers, P., &amp; Corte, U. 2019. What is Qualitative in Qualitative Research. ''Qualitative Sociology'', 42:139–160.&lt;/ref&gt;; noTaderdoost, 2021&lt;ref&gt;Taherdoost, H. 2021.  Data Collection Methods and Tools for Research; A Step-by-Step Guide to Choose Data Collection Technique for Academic and Business Research Projects. ''International Journal of Academic Research in Management (IJARM)'', 10 (1):10-38.&lt;/ref&gt;). Ngamanye amagama, umrhubhululi osebenzisa imethodoloji yekhwalithethivu ihlaziyo lakhe lisuke lidzimelele emmongweni nemlayezweni omumethwe yidatha yesifundo sakhe. Ngaphasi kwesifundo lesi, imitlolo yesiNdebele ifundiwe bese kwatshwaywa leyo enemitjho ngomnqopho wokufuna ukufunda nokuhlaziya isakhiwo semitjho leyo. Ukungezelela, ihlaziyo leli linqophe ezintweni ezakha imitjho, ubujamo bazo bendabuko nemihlobo yemitjho leyo. Imiphumela ihlaziwile begodu kwanikela ngesiphetho. 

Ibuthelelo ledatha, ihlaziyo lomtlolo, lisetjenzisiwe nalo ngaphasi kwesifundo lesi. Ibuthelelo ledatha ihlaziyo lomtlolo, libuthelelo ledatha lelo elisetjenziswa ukubuthelela idatha emitlolo kwaphela (uSharma, 2023&lt;ref&gt;Sharma, Y. 2023. Data Collection in Research: Concept, Process and Methods. ''International Journal of Creative Research Thoughts'', 11(10):27-33.&lt;/ref&gt;; noDewi, 2021&lt;ref&gt;Dewi, I. G. A. A. O. 2021. Understanding Data Collection Methods in Qualitative Research: The Perspective of Interpretive Accounting Research. ''Journal of Tourism Economics and Policy'', 1(1):8-15.&lt;/ref&gt;). Ukungezelela, ibuthelelo ledatha ihlaziyo lomtlolo linikela umrubhululi amano wokubuthelela idatha emitlolo leya efaka hlangana isihlathululimagama, incwadi nomtlolo wemikhangiso ukuze umrhubhululi ekhethe idatha enqophileko kusifundo sakhe (uKibiswa, 2019&lt;ref&gt;Kibiswa, N. K. 2019. Directed Qualitative Content Analysis (DQlCA): A Tool for Conflict Analysis. ''The Qualitative Report'', 24(8), 2059-2079.&lt;/ref&gt;; noNicmanis, 2024&lt;ref&gt;Nicmanis, M. 2024. Reflexive Content Analysis: An Approach to Qualitative Data Analysis, Reduction, and Description. ''International Journal of Qualitative Methods'', 23:1–12.&lt;/ref&gt;). Ngaphasi kwesifundo lesi, idatha yemitolo enemitjho yesiNdebele ifundiwe bese kutshwaywa leyo elungele isifundo lesi bona iyokuhlaziywa ngokungeneleleko. Esihlokweni esilandelako ithiyori esetjenziswe esifundweni lesi iyahlathululwa. 

== '''Ithiyori Yesifundo''' ==
Ithiyori, ihlaziyo lommongo, isetjenzisiwe ngaphasi kwesifundo lesi. Ithiyori ihlaziyo lommongo, yithiyori enzinze khulu ngaphasi kokuhlaziya ummongo womtlolo ukuze kufumaneke umlayezo wawo (uMayring, 2014&lt;ref&gt;Mayring, P. 2014. ''Qualitative Content Analysis: Theoretical Foundation, Basic Procedures and Software Solution''. Klagenfurt.&lt;/ref&gt;; noRochson, u-Adade-Yeboah no-Owusu, 2023&lt;ref&gt;Rockson, K., Adade-Yeboah, A., &amp; Owusu, E. 2023. A Textual Analysis of President Akufo-Addo’s 12th Covid–19 Address. ''Journal of English Teaching'', 9(2):252-268.&lt;/ref&gt;). Ukungezelela, esikhathini esinengi imitlolo imumethe imilayezo efihlakeleko begodu ukuze ifunywane kufanele kuhlaziywe ummongo wayo ngomnqopho wokuwuzisisa bonyana uwakhekhe njani, usebenza njani begodu umlayezo wawo yini (uShort, 2024&lt;ref&gt;Short, C. E. 2025. ''Textual analysis''. In: Grossmann-Hensel, B., Jarzabkowski, P., Kratochvil, R., Seidl, D., Spee, A. P., &amp; Whittington, R. (Eds.) Elgar Encyclopedia of Strategy as Practice. Edward Elgar Publishing.&lt;/ref&gt;). Ngamanye amagama, ithiyori ihlaziyo lommongo linikela umrhubhululi amano wokuhlaziya imitlolo eminengi ngomnqopho wokuzwisisa bonyana isetjenziswa njani ebujameni bayo bendabuko. 

Ngaphasi kwesifundo lesi, imitlolo enemitjho yesiNdebele ihlaziywile ngomnqopho wokuzwisisa bona yakhiwe ngani. Ukungezelela, ubujamo bendabuko bezakhi zemitjho yesiNdebele nabo buhlaziywile bonyana bukuphi emitjhweni begodu imitjho le inemihlobo emingaki. Ekugcineni, kunikelwe ngesiphetho mayelana nalokho okuvunjululwe kusifundo lesi. Esihlokweni esilandelako imitlolo ehlobene nesifundo lesi itjhejiwe. 

== '''Imitjho Ehlobene Nesifundo Lesi''' ==
Imitjho inezakhi zayo ezenza bonyana izakhiwo zayo zihleleke kuhle. Ukuya ngokukaHamraqulova (2023)&lt;ref name=&quot;:4&quot;&gt;Hamraqulva, O. 2023. Sentence Structure in English Grammar Study in National Groups. ''Texas Journal of Philogy, Culture and History'', 17:25-29.&lt;/ref&gt; isakhiwo semitjho senziwe ngezinto ezinengi lezi ezifaka hlangana iinkhekhe zekulumo. UHamraqulova (2023)&lt;ref name=&quot;:4&quot; /&gt; uveze lokhu esifundweni sakhe sesihloko esithi, ‘''Sentence Structure in English Grammar Study in National Groups’'', lapho bekuhlaziywa khona ukukghedlwa kweenkhekhe zekulumo ezahlukeneko ezitholakala emitjhweni yesiNgisi. Isifundo lesi sifunyene bona kunobudisi bokutshwaya nokwazi iinkhekhe zekulumo ezisetjenziswa emitjhweni. UHamraqulova (2023)&lt;ref name=&quot;:4&quot; /&gt; uphakamise bona kufanele iinkhekhe zekulumo ezitholakala emutjhweni zitlolwe phasi begodu zifundiswe abasebenzisi belimi.

Ngesikhathi uHamraqulova (2023)&lt;ref name=&quot;:4&quot; /&gt; enze isifundo esinzinze eenkhekheni zekulumo ezitholakala esakhiweni somutjho, uYusuf no-Ali (2025)&lt;ref name=&quot;:1&quot; /&gt; benze isifundo leso esinqophe eendimeni ezidlalwa isakhiwo semitjho lokha nawusebenzisa begodu ufunda isiNgisi, ngaphasi kwesihloko esithi, ‘''Unveiling the Role of Grammar Mastery: How Sentence Structure, Verb, and Subject-Verb Agreement Shape Tenses Usage in English Learning’''.  UYusuf no-Ali (2025)&lt;ref name=&quot;:1&quot; /&gt; bafunyene bona izakhiwo zomutjho ezifaka hlangana ihloko yomutjho, isenzo nomenzi zidlala indima eqakathekileko ekuthuthukiseni ilwazi lelimi kubafundi. Kodwana, umraro ovunjululiweko kukuthi abafundi abanengi abanakghono lokuhlanganisa kuhle izakhi lezo emutjhweni. UYusuf no-Ali (2025)&lt;ref name=&quot;:1&quot; /&gt; baphakamise bona ikharikhyulamu yezefundo kufanele yenze isifundo leso esinzinze ekusetjenzisweni kwelimi nehlelo ukuze abafundi bazokwazi ukumunya ilwazi lokuthuthukisa ikghono labo lehlelo nelimi. 

Ngokufani nesifundo sakaYusuf no-Ali (2025)&lt;ref name=&quot;:1&quot; /&gt;, uPhilippakos noZoi (2019)&lt;ref name=&quot;:5&quot;&gt;Philippakos, T., &amp; Zoi, A. 2019. Sentence Construction: Supporting Elementary Students’ Editing Skills. ''The Language and Literacy Spectrum'', 29(1):1-23.&lt;/ref&gt; benze isifundo sesihloko esithi, ‘''Sentence Construction: Supporting Elementary Students’ Editing Skills''’, lapho bekuhlaziywa khona amakghono angasetjenziswa ukulungisa iimphoso zemitjho bafundi bamabanga aphasi. Isifundo lesi sifunyene bona abafundi abanengi bamabanga aphasi abanamakghono wokulungisa iimphoso zemitjho, khulukhulu imitjho ezizitjho. UPhilippakos noZoi (2019)&lt;ref name=&quot;:5&quot; /&gt; bakhombele bona abafundisi bamabanga aphasi kufanele bafundise abafundi ngezitjho kanye namaqhinga wokulungisa iimphoso. 

Amanye wamakghono asetjenziswa ngesikhathi kutlolwa nanyana kusetjenziswa imitjho afaka hlangana ukuhlukanisa nokukghedla umutjho omude. Lokhu kufakazelwe sifundo sakaYu (2021) &lt;ref name=&quot;:0&quot; /&gt;sesihloko esithi, ‘''A Study on the Role of Sentence Structure Analysis in English Learning''’, lokha nakaveza bonyana abafundi abanengi baba nesitjhijilo sokuzwisisa nokukghedlha imitjho emide. Umnqopho omkhulu wesifundo sakaYu (2021)&lt;ref name=&quot;:0&quot; /&gt; bekukuhlaziya izwisiso labafundi mayelana nemitjho emide. UYu (2021)&lt;ref name=&quot;:0&quot; /&gt; uphakamise bona abafundi laba kufanele bafundiswe ngamaqhinga wokuzilolonga wehlelo nelimi, khulukhulu ngokunqopha emitjhweni emide ukuze bakwazi ukufunyana amakghono afunekako nakuza ekukghedlhweni nokuzwisisweni imitjho emide. 

Ekulunyweni engehla le, kukhulunywe ngezakhi ezisetjenziswako nakwenziwa isakhiwo semitjho, kanye neendima imitjho enayo ekuthuthukiseni ilwazi nekghono lehlelo lelimi. Ukungezelela, kubuywe kwavezwa ubudisi obumayelana nokuzwisisa imitjho emide. Woke amaphuzu nemibono evunjululwe ngehla le, iveza isidingo sokurhubhulula ngesakhiwo semitjho ngokunqopha kuzinto ezitholakala emitjhweni, ubujamo bazo bendabuko nemihlobo yemitjho ekhona esiNdebeleni. Esihlokweni esilandelako idatha iyahlaziywa. 

== '''Ihlaziyo Ledatha''' ==
Isakhiwo semitjho singakhiwa ngezinto ezinengi; kodwana, ihloko yomutjho nesenzo zihlala zikhona esakhiweni somutjho (uSkhosana, 1996)&lt;ref name=&quot;:2&quot; /&gt;. Ngamanye amagama, ihloko yomutjho nesenzo kuzizinto ezisisekelo esakhiweni somutjho begodu esikhathini esinengi azitlhogeki emtjhweni. Tjhejani isibonelo esilandelako:

1. Inja idla amaqanda.

Esibonelweni 2, sinikelwe umutjho ‘Inja idla amaqanda’, loyo owakhiwe ngehloko yomutjho ‘Inja’, isenzo ‘idla’ nomenziwa ‘amaqanda’. Ukungezelela, sithole bona ihloko yomutjho ‘Inja’ isekuthomeni komutjho bese isenzo ‘idla’ sibe phakathi. Umenziwa yena ‘amaqanda’ usekugcineni komutjho. Lokhu kuyasibikela bonyana indawo yehloko yomutjho ngokwendabuko isekuthomeni komutjho; isenzo indawo yaso ngokwendabuko iphakathi emutjhweni bese kuthi umenziwa indawo yakhe ngokwendabuko emutjhweni isekugcineni begodu kufakazelwa nguSkhosana (1998)&lt;ref name=&quot;:3&quot; /&gt;.

Nanyana kunjalo, kukhona iinkhekhe zekulumo ezitholakala emutjhweni njengoba kufakazelwe nguHamraqulova (2023)&lt;ref name=&quot;:4&quot; /&gt;. Tjhejani isibonelo esilandelako:

2. Isifundo lesi sibudisi.

Esibonelweni 3 esingehla, sinikelwe umutjho, ‘Isifundo lesi sibudisi’, loyo owakhiwe ngeenkhekhe zekulumo ezahlukeneko. Igama ‘Isifundo’ kusikhekhe sekulumo ibizo; igama ‘lesi’ kusikhekhe sekulumo isabizwana sokukhomba eduze bese kuthi ibizo ‘sibudisi’ kusitlhadlhululi esisiphawulo. Lokhu kuyasivezela bonyana umutjho awakhiwa ngehloko, isenzo nomenziwa kwaphela; kodwana, ihloko, isenzo nomenziwa lezo zingawela ngaphasi kweenkhekhe zekulumo ezahlukeneko.

Nanyana kunjalo, imitjho engaphasi kwesibonelo 2 no-3 ngokulandelana, ukuze ilethe imiqondo ezwakalako isebenzise iinthomo neemvumelwano. Ngaphasi komutjho wesibonelo 2, sifunyene isithomo sehloko u-‘i’ ohlonyelelwe kusiqu sehloko ‘-nja’ nesivumelwano sehloko u-‘i-’ ohlonyelelwe kusiqu sesenzo ‘-dla’ bese kuthi isithomo sakamenziwa u-‘ama-’ uhlonyelelwe kusiqu sakamenziwa ‘-qanda’.

Bese kuthi ngaphasi komutjho wesibonelo 3, sifunyene isithomo sehloko u-‘isi’ ohlonyelelwe kusiqu sehloko ‘-fundo’ nesivumelwano sehloko u-‘si-’ ohlonyelelwe kusiqu sesitlhadlhuli ‘-budisi’. Isabizwana sokukhomba eduze ‘lesi’ asinasithomo nanyana isivumelwano. Kodwana, sisebujameni bobunye ngombana ihloko yomutjho nayo isebujameni bobunye.

Okunye okuvunjululiweko kukuthi imihlobo yemitjho iyahluka njengoba kwavezwa nguSkhosana (1996)&lt;ref name=&quot;:2&quot; /&gt;. Tjhejani iimbonelo ezilandelako:

3. Ubaba uthenge ikoloyi.

4. UJabu udinwe khulu namhlanje ngombana bekagijima.

5. Kutjhayisene iinkoloyi ezimbili kwalimala abantu abambalwa. 

Esibonelweni 4, sinikelwe umutjho ‘Ubaba uthenge ikoloyi’ loyo owenziwe ngehloko yomutjho (Ubaba) eyodwa; isenzo sinye (uthenge) nomenziwa oyedwa (ikoloyi). Umutjho lo waziwa ngokuthi mumutjho onqophileko nanyana mumutjho olula (uSkhosana, 1996)&lt;ref name=&quot;:2&quot; /&gt;.

Ngokungafani nomutjho wesibonelo 4, kusibonelo 5 sinikelwe umutjho ‘UJabu udinwe khulu namhlanje ngombana bekagijima’, loyo owenziwe ngehloko (UJabu), izenzo (udinwe nobakagijima), isitlhadlhuli (khulu), isinabiso (namhlanje) nesihlanganiso (ngombana). Umutjho lo ubizwa bona mumutjho ovangileko. Ngokuya kukaSkhosana (1996)&lt;ref name=&quot;:2&quot; /&gt; umutjho ovangileko siwubona ngeenhlanganiso ezinjengo-‘ngombana, bese nonanyana’ lezo ezihlanganisa imitjho embili ukuze kubumbeke umutjho munye. Nasitjheja umutjho wesibonelo 5, singawuhlukanisa ngemitjho embili; -UJabu udinwe khulu namhlanje; -bekagijima.

Umutjho wokugcina esinikelwe wona kusibonelo 6, u-‘ Kutjhayisene iinkoloyi ezimbili kwalimala abantu abambalwa’, loyo owenziwe ngemitjho edlula kemibili engakghedlwa ngale indlela:

-         Kutjahyisene iinkoloyi

-         Ezimbili

-         Kwalimala abantu abambalwa 

Ingcenye yokuthoma, kutjhayisene iinkoloyi, kumumutjho omkhulu ngombana yoke into ithoma kiwo. ‘Ezimbili’, kumumutjho wesenzo esizijameleko, bese kuthi ingcenye yesithathu ‘kwalimala abantu amambalwa’ kumumutjho oyamileko ngombana uphethe imiphumela yalokho okubangwe yingcenye yokuthoma nanyana umutjho omkhulu. Loku kuyasibikela bonyana [[:en:Sentence_clause_structure|imitjho ingahlukana kathathu]] ngokuya komlayezo ewumumetheko.

Isakhiwo semitjho yesiNdebele sihlaziwile ngaphasi kwesifundo lesi begodu kwavunjululwa bona izakhi ezifana nehloko yomutjho isenzo nomenziwa kanengi zihlala zikhona. Ukuragela phambili, imitjho le ifunyenwe bonyana izakhi zayo zingawela ngaphasi kweenkhekhe zekulumo ezahlukeneko njengesitlhadlhuli nebizo. Kokugcina, kuvunjululwe bona imitjho le imihlobo emithathu ehlukeneko. 

Isakhiwo semitjho siqakathekile bona sifundwe besizwisiswe ngombana sifundisa ngelwazi nekghono lehlelo nelimi. Ukungezelela, ukuzwisisa isakhiwo semitjho kwenza kube lula ukwakha nanyana ukutlola imitjho ezakwalako.   

== '''Umthombolwazi''' ==
&lt;references /&gt;</text>
      <sha1>evqhklawobedwonims4n15h0ippyhfb</sha1>
    </revision>
  </page>
  <page>
    <title>Patrice Motsepe</title>
    <ns>0</ns>
    <id>1039</id>
    <revision>
      <id>6178</id>
      <timestamp>2026-02-17T15:52:28Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''U-Patrice Motsepe''' wabelethwa mhlana  amalanga ama-28 kuTjhirhweni  ngonyaka we-1962, ebelethelwa endaweni ye-Soweto.&lt;ref&gt;https://www.rfi.fr/en/sports/20210312-south-african-tycoon-motsepe-elected-as-african-football-supremo&lt;/ref&gt; Utjhade no-Dr. Precious Moloi-Motsepe, udorhodere wabantwana nosomabhizinisi. Udadwabo, uTshepo, utjhade noMengameli weSewula Afrika u-Cyril Ramaphosa.Ungusomabhilidi wezemayini weSewula Afrika, usomabhizinisi, nomsizi owaba mrholi omnya...&quot;</comment>
      <origin>6178</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3705" sha1="hk3pw04vyed9bls4q64gi53ff7q7dt6" xml:space="preserve">'''U-Patrice Motsepe''' wabelethwa mhlana  amalanga ama-28 kuTjhirhweni  ngonyaka we-1962, ebelethelwa endaweni ye-Soweto.&lt;ref&gt;https://www.rfi.fr/en/sports/20210312-south-african-tycoon-motsepe-elected-as-african-football-supremo&lt;/ref&gt; Utjhade no-Dr. Precious Moloi-Motsepe, udorhodere wabantwana nosomabhizinisi. Udadwabo, uTshepo, utjhade noMengameli weSewula Afrika u-Cyril Ramaphosa.Ungusomabhilidi wezemayini weSewula Afrika, usomabhizinisi, nomsizi owaba mrholi omnyama wokuthoma enarheni le. Njengomsunguli we-African Rainbow Minerals (ARM) ngo-1997, ngomsebenzi wakhe watjhugulula ibubulo lezemayini, ngokukhamba kwesikhathi wakhula waya emisebenzini yeemali, amandla, kanye nezemidlalo. Wathoma ukusebenza njengomongameli we-Confederation of African Football (CAF) kusukela ngo-2021 begodu umnikazi wesiqhema sebholo se-Mamelodi Sundowns.&lt;ref&gt;https://www.goal.com/en-us/news/patrice-motsepe-africas-ninth-richest-person-appointed-caf/bl3s8p4dafm51fmjkxs4va9q9&lt;/ref&gt;

=== Ipilo yakhe  yokuthoma nefundo ===
Ngokwemvelaphi wabelethwa ngu-Augustine Butana u-Chaane Motsepe, utitjhere owaphenduka umnikazi wesikolo/osomabhizinisi, u-Motsepe wakhulela e-Soweto, wafunda izinto ezisisekelo zebhizinisi esitolo sikayise esincani, ngokwelimi elijayelekileko libizwa bona yi spaza. Ngokwefundo wafumana i-Bachelor of Arts e-University of the Swaziland kanye nedigri yomthetho (LLB) e-University of the Witwatersrand.

=== Umsebenzi  wakhe kwezeBhizinisi ===
Kwezomthettho ngo-1988, wabalilunga lefemu yomthetho ye-johannesburg, waba mlingani wayo wokuthoma omnyama e-Bowman Gilfillan ngo-1994. Nasele asebenza emayini Ngo-1994, wasungula i-Future Mining, ikhamphani yemayini yekontraga, begodu ngokukhamba kwesikhathi wasungula i-African Rainbow Minerals (ARM) ngo-1997, eyathenga amashafu wegolide angazuzisi ku-Anglo American ukuwenza abe mabhizinisi enza inzuzo. Eminye misebenzi ayenzako wasungula i-African Rainbow Capital (ARC), ikhamphani yokutjala imali ephethwe babantu abanzima, begodu ibandakanyeka emandleni ahlanzekileko nge-African Rainbow Energy and Power (AREP).&lt;ref&gt;http://www.whoswhosa.co.za/Pages/profilefull.aspx?IndID=1140&lt;/ref&gt;

Ngo-2003, u-Motsepe wasungula i-Ubuntu-Botho Investments (UBI) (begodu ngo-2019 waba ne-55% yayo). Ngomnyaka ka-2004 i-UBI yangena esivumelwaneni se-BEE nekhamphani yetjhorensi neyeemali i-Sanlam. Isivumelwano leso saphela ngo-2014 lokha isikolodo nasele sibhadelwe begodu i-UBI yathola i-13.5% ye-Sanlam, kodwana i-UBI inesabelo sokukhetha esingu-18.1% ku-Sanlam njengomlingani wayo we-BEE. I-UBI yabe isithoma i-African Rainbow Capital (ARC), inkampani engaphasi kwe-UBI. Empathy omkhulu we-ARC ngu-Johan van Zyl, owayemphathi omkhulu we-Sanlam.I-ARC ineenkampani ezingaphezu kwama-40, okufaka hlangana i-GoTyme Bank, isiqhema samabubulo i-Afrimat, ikhamphani yezokulima i-BKB, ikhamphani yezokuthintana i-Rain, indawo yokuzithabisa i-Val de Vie, kanye nesabelo esincani ku-Alexander Forbes, umlawuli wesikhwama sempesheni.&lt;ref&gt;https://www.businesslive.co.za/fm/money-and-investing/2019-01-24-decoding-sanlams-cosy-deal-with-patrice-motsepe/&lt;/ref&gt;

=== amabhizinisi nokupha emiphakathini ===
Kwezemidlalo emdlaweni webholo, , waba mnikazi we-Mamelodi Sundowns Football Club Ngo-2003. Wakhethwa njengoMongameli we-Confederation of African Football ngoNtaka 2021.  U-Motsepe nomkakhe, u-Dr. Precious Moloi-Motsepe, batlikitla i-Giving Pledge ngo-2013, bathembisa ukunikela okungenani ingcenye yepahla yabo emisebenzini yokupha enarheni yesewula afrika, elawulwa yi-Motsepe Foundation. UMotsepe wabizwa njengosomabhizinisi ophuma phambili weSewula Afrika ngomnyaka ka-2002 begodu waziwa ngomthelela wakhe omkhulu emkhakheni wamabhizinisi nezemidlalo.</text>
      <sha1>hk3pw04vyed9bls4q64gi53ff7q7dt6</sha1>
    </revision>
    <revision>
      <id>6179</id>
      <parentid>6178</parentid>
      <timestamp>2026-02-17T15:57:33Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6179</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3738" sha1="28qmbc7qfv252hxokgnw9i4q8dpz7p2" xml:space="preserve">'''U-Patrice Motsepe''' wabelethwa mhlana  amalanga ama-28 kuTjhirhweni  ngonyaka we-1962, abelethelwa endaweni ye-Soweto.&lt;ref&gt;https://www.rfi.fr/en/sports/20210312-south-african-tycoon-motsepe-elected-as-african-football-supremo&lt;/ref&gt; Ngokwemvelaphi wabelethwa ngu-Augustine Butana u-Chaane Motsepe, utitjhere owaphenduka umnikazi wesikolo/osomabhizinisi, u-Motsepe wakhulela e-Soweto, wafunda izinto ezisisekelo zebhizinisi esitolo sikayise esincani, ngokwelimi elijayelekileko libizwa bona yi spaza. Ngokwefundo wafumana i-Bachelor of Arts e-University of the Swaziland kanye nedigri yomthetho (LLB) e-University of the Witwatersrand.Utjhade no-Dr. Precious Moloi-Motsepe, udorhodere wabantwana nosomabhizinisi. Udadwabo, uTshepo, utjhade noMongameli weSewula Afrika u-Cyril Ramaphosa.Ungusomabhilidi wezemayini weSewula Afrika, usomabhizinisi, nomsizi owaba mrholi omnyama wokuthoma enarheni le. Njengomsunguli we-African Rainbow Minerals (ARM) ngo-1997, ngomsebenzi wakhe watjhugulula ibubulo lezemayini, ngokukhamba kwesikhathi wakhula waya emisebenzini yeemali, amandla, kanye nezemidlalo. Wathoma ukusebenza njengomongameli we-Confederation of African Football (CAF) kusukela ngo-2021 begodu umnikazi wesiqhema sebholo se-[[Mamelodi Sundowns]].&lt;ref&gt;https://www.goal.com/en-us/news/patrice-motsepe-africas-ninth-richest-person-appointed-caf/bl3s8p4dafm51fmjkxs4va9q9&lt;/ref&gt;

=== Umsebenzi  wakhe kwezeBhizinisi ===
[[Isimumathi:Patrice Motsepe WEF June 2015.png|thumb|Patrice Motsepe]]
Kwezomthettho ngo-1988, wabalilunga lefemu yomthetho ye-johannesburg, waba mlingani wayo wokuthoma omnyama e-Bowman Gilfillan ngo-1994. Nasele asebenza emayini Ngo-1994, wasungula i-Future Mining, ikhamphani yemayini yekontraga, begodu ngokukhamba kwesikhathi wasungula i-African Rainbow Minerals (ARM) ngo-1997, eyathenga amashafu wegolide angazuzisi ku-Anglo American ukuwenza abe mabhizinisi enza inzuzo. Eminye misebenzi ayenzako wasungula i-African Rainbow Capital (ARC), ikhamphani yokutjala imali ephethwe babantu abanzima, begodu ibandakanyeka emandleni ahlanzekileko nge-African Rainbow Energy and Power (AREP).&lt;ref&gt;http://www.whoswhosa.co.za/Pages/profilefull.aspx?IndID=1140&lt;/ref&gt;

Ngo-2003, u-Motsepe wasungula i-Ubuntu-Botho Investments (UBI) (begodu ngo-2019 waba ne-55% yayo). Ngomnyaka ka-2004 i-UBI yangena esivumelwaneni se-BEE nekhamphani yetjhorensi neyeemali i-Sanlam. Isivumelwano leso saphela ngo-2014 lokha isikolodo nasele sibhadelwe begodu i-UBI yathola i-13.5% ye-Sanlam, kodwana i-UBI inesabelo sokukhetha esingu-18.1% ku-Sanlam njengomlingani wayo we-BEE. I-UBI yabe isithoma i-African Rainbow Capital (ARC), inkampani engaphasi kwe-UBI. Empathy omkhulu we-ARC ngu-Johan van Zyl, owayemphathi omkhulu we-Sanlam.I-ARC ineenkampani ezingaphezu kwama-40, okufaka hlangana i-GoTyme Bank, isiqhema samabubulo i-Afrimat, ikhamphani yezokulima i-BKB, ikhamphani yezokuthintana i-Rain, indawo yokuzithabisa i-Val de Vie, kanye nesabelo esincani ku-Alexander Forbes, umlawuli wesikhwama sempesheni.&lt;ref&gt;https://www.businesslive.co.za/fm/money-and-investing/2019-01-24-decoding-sanlams-cosy-deal-with-patrice-motsepe/&lt;/ref&gt;

=== amabhizinisi nokupha emiphakathini ===
Kwezemidlalo emdlaweni webholo, , waba mnikazi we-Mamelodi Sundowns Football Club Ngo-2003. Wakhethwa njengoMongameli we-Confederation of African Football ngoNtaka 2021.  U-Motsepe nomkakhe, u-Dr. Precious Moloi-Motsepe, batlikitla i-Giving Pledge ngo-2013, bathembisa ukunikela okungenani ingcenye yepahla yabo emisebenzini yokupha enarheni yesewula afrika, elawulwa yi-Motsepe Foundation. UMotsepe wabizwa njengosomabhizinisi ophuma phambili weSewula Afrika ngomnyaka ka-2002 begodu waziwa ngomthelela wakhe omkhulu emkhakheni wamabhizinisi nezemidlalo.</text>
      <sha1>28qmbc7qfv252hxokgnw9i4q8dpz7p2</sha1>
    </revision>
    <revision>
      <id>6180</id>
      <parentid>6179</parentid>
      <timestamp>2026-02-17T16:01:23Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6180</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3760" sha1="slzdvnpmc5si0tr2dhzlf2b4yq3kho8" xml:space="preserve">'''U-Patrice Motsepe''' wabelethwa mhlana  amalanga ama-28 kuTjhirhweni  ngonyaka we-1962, abelethelwa endaweni ye-Soweto.&lt;ref&gt;https://www.rfi.fr/en/sports/20210312-south-african-tycoon-motsepe-elected-as-african-football-supremo&lt;/ref&gt; Ngokwemvelaphi wabelethwa ngu-Augustine Butana u-Chaane Motsepe, utitjhere owaphenduka umnikazi wesikolo/osomabhizinisi, u-Motsepe wakhulela e-Soweto, wafunda izinto ezisisekelo zebhizinisi esitolo sikayise esincani, ngokwelimi elijayelekileko libizwa bona yi spaza. Ngokwefundo wafumana i-Bachelor of Arts e-University of the Swaziland kanye nedigri yomthetho (LLB) e-University of the Witwatersrand.Utjhade no-Dr. Precious Moloi-Motsepe, udorhodere wabantwana nosomabhizinisi.Unabantwana abathathu. Udadwabo, uTshepo, utjhade noMongameli weSewula Afrika u-Cyril Ramaphosa.Ungusomabhilidi wezemayini weSewula Afrika, usomabhizinisi, nomsizi owaba mrholi omnyama wokuthoma enarheni le. Njengomsunguli we-African Rainbow Minerals (ARM) ngo-1997, ngomsebenzi wakhe watjhugulula ibubulo lezemayini, ngokukhamba kwesikhathi wakhula waya emisebenzini yeemali, amandla, kanye nezemidlalo. Wathoma ukusebenza njengomongameli we-Confederation of African Football (CAF) kusukela ngo-2021 begodu umnikazi wesiqhema sebholo se-[[Mamelodi Sundowns]].&lt;ref&gt;https://www.goal.com/en-us/news/patrice-motsepe-africas-ninth-richest-person-appointed-caf/bl3s8p4dafm51fmjkxs4va9q9&lt;/ref&gt;

=== Umsebenzi  wakhe kwezeBhizinisi ===
[[Isimumathi:Patrice Motsepe WEF June 2015.png|thumb|Patrice Motsepe]]
Kwezomthettho ngo-1988, wabalilunga lefemu yomthetho ye-johannesburg, waba mlingani wayo wokuthoma omnyama e-Bowman Gilfillan ngo-1994. Nasele asebenza emayini Ngo-1994, wasungula i-Future Mining, ikhamphani yemayini yekontraga, begodu ngokukhamba kwesikhathi wasungula i-African Rainbow Minerals (ARM) ngo-1997, eyathenga amashafu wegolide angazuzisi ku-Anglo American ukuwenza abe mabhizinisi enza inzuzo. Eminye misebenzi ayenzako wasungula i-African Rainbow Capital (ARC), ikhamphani yokutjala imali ephethwe babantu abanzima, begodu ibandakanyeka emandleni ahlanzekileko nge-African Rainbow Energy and Power (AREP).&lt;ref&gt;http://www.whoswhosa.co.za/Pages/profilefull.aspx?IndID=1140&lt;/ref&gt;

Ngo-2003, u-Motsepe wasungula i-Ubuntu-Botho Investments (UBI) (begodu ngo-2019 waba ne-55% yayo). Ngomnyaka ka-2004 i-UBI yangena esivumelwaneni se-BEE nekhamphani yetjhorensi neyeemali i-Sanlam. Isivumelwano leso saphela ngo-2014 lokha isikolodo nasele sibhadelwe begodu i-UBI yathola i-13.5% ye-Sanlam, kodwana i-UBI inesabelo sokukhetha esingu-18.1% ku-Sanlam njengomlingani wayo we-BEE. I-UBI yabe isithoma i-African Rainbow Capital (ARC), inkampani engaphasi kwe-UBI. Empathy omkhulu we-ARC ngu-Johan van Zyl, owayemphathi omkhulu we-Sanlam.I-ARC ineenkampani ezingaphezu kwama-40, okufaka hlangana i-GoTyme Bank, isiqhema samabubulo i-Afrimat, ikhamphani yezokulima i-BKB, ikhamphani yezokuthintana i-Rain, indawo yokuzithabisa i-Val de Vie, kanye nesabelo esincani ku-Alexander Forbes, umlawuli wesikhwama sempesheni.&lt;ref&gt;https://www.businesslive.co.za/fm/money-and-investing/2019-01-24-decoding-sanlams-cosy-deal-with-patrice-motsepe/&lt;/ref&gt;

=== amabhizinisi nokupha emiphakathini ===
Kwezemidlalo emdlaweni webholo, , waba mnikazi we-Mamelodi Sundowns Football Club Ngo-2003. Wakhethwa njengoMongameli we-Confederation of African Football ngoNtaka 2021.  U-Motsepe nomkakhe, u-Dr. Precious Moloi-Motsepe, batlikitla i-Giving Pledge ngo-2013, bathembisa ukunikela okungenani ingcenye yepahla yabo emisebenzini yokupha enarheni yesewula afrika, elawulwa yi-Motsepe Foundation. UMotsepe wabizwa njengosomabhizinisi ophuma phambili weSewula Afrika ngomnyaka ka-2002 begodu waziwa ngomthelela wakhe omkhulu emkhakheni wamabhizinisi nezemidlalo.</text>
      <sha1>slzdvnpmc5si0tr2dhzlf2b4yq3kho8</sha1>
    </revision>
    <revision>
      <id>6181</id>
      <parentid>6180</parentid>
      <timestamp>2026-02-17T16:01:57Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6181</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3776" sha1="dbxojqzu4l5spx84iipqy1hz2kwz9t5" xml:space="preserve">'''U-Patrice Motsepe''' wabelethwa mhlana  amalanga ama-28 kuTjhirhweni  ngonyaka we-1962, abelethelwa endaweni ye-Soweto.&lt;ref&gt;https://www.rfi.fr/en/sports/20210312-south-african-tycoon-motsepe-elected-as-african-football-supremo&lt;/ref&gt; Ngokwemvelaphi wabelethwa ngu-Augustine Butana u-Chaane Motsepe, utitjhere owaphenduka umnikazi wesikolo/osomabhizinisi, u-Motsepe wakhulela e-Soweto, wafunda izinto ezisisekelo zebhizinisi esitolo sikayise esincani, ngokwelimi elijayelekileko libizwa bona yi spaza. Ngokwefundo wafumana i-Bachelor of Arts e-University of the Swaziland kanye nedigri yomthetho (LLB) e-University of the Witwatersrand.Utjhade no-Dr. Precious Moloi-Motsepe, udorhodere wabantwana nosomabhizinisi.Unabantwana abathathu. Udadwabo, uTshepo, utjhade noMongameli weSewula Afrika u-Cyril Ramaphosa.Ungusomabhilidi wezemayini weSewula Afrika, usomabhizinisi, nomsizi owaba mrholi omnyama wokuthoma enarheni le. Njengomsunguli we-African Rainbow Minerals (ARM) ngo-1997, ngomsebenzi wakhe watjhugulula ibubulo lezemayini, ngokukhamba kwesikhathi wakhula waya emisebenzini yeemali, amandla, kanye nezemidlalo. Wathoma ukusebenza njengomongameli we-Confederation of African Football (CAF) kusukela ngo-2021 begodu umnikazi wesiqhema sebholo se-[[Mamelodi Sundowns]].&lt;ref&gt;https://www.goal.com/en-us/news/patrice-motsepe-africas-ninth-richest-person-appointed-caf/bl3s8p4dafm51fmjkxs4va9q9&lt;/ref&gt;

=== Umsebenzi  wakhe kwezeBhizinisi ===
[[Isimumathi:Patrice Motsepe WEF June 2015.png|thumb|Patrice Motsepe]]
Kwezomthettho ngo-1988, wabalilunga lefemu yomthetho ye-johannesburg, waba mlingani wayo wokuthoma omnyama e-Bowman Gilfillan ngo-1994. Nasele asebenza emayini Ngo-1994, wasungula i-Future Mining, ikhamphani yemayini yekontraga, begodu ngokukhamba kwesikhathi wasungula i-African Rainbow Minerals (ARM) ngo-1997, eyathenga amashafu wegolide angazuzisi ku-Anglo American ukuwenza abe mabhizinisi enza inzuzo. Eminye misebenzi ayenzako wasungula i-African Rainbow Capital (ARC), ikhamphani yokutjala imali ephethwe babantu abanzima, begodu ibandakanyeka emandleni ahlanzekileko nge-African Rainbow Energy and Power (AREP).&lt;ref&gt;http://www.whoswhosa.co.za/Pages/profilefull.aspx?IndID=1140&lt;/ref&gt;

Ngo-2003, u-Motsepe wasungula i-Ubuntu-Botho Investments (UBI) (begodu ngo-2019 waba ne-55% yayo). Ngomnyaka ka-2004 i-UBI yangena esivumelwaneni se-BEE nekhamphani yetjhorensi neyeemali i-Sanlam. Isivumelwano leso saphela ngo-2014 lokha isikolodo nasele sibhadelwe begodu i-UBI yathola i-13.5% ye-Sanlam, kodwana i-UBI inesabelo sokukhetha esingu-18.1% ku-Sanlam njengomlingani wayo we-BEE. I-UBI yabe isithoma i-African Rainbow Capital (ARC), inkampani engaphasi kwe-UBI. Empathy omkhulu we-ARC ngu-Johan van Zyl, owayemphathi omkhulu we-Sanlam.I-ARC ineenkampani ezingaphezu kwama-40, okufaka hlangana i-GoTyme Bank, isiqhema samabubulo i-Afrimat, ikhamphani yezokulima i-BKB, ikhamphani yezokuthintana i-Rain, indawo yokuzithabisa i-Val de Vie, kanye nesabelo esincani ku-Alexander Forbes, umlawuli wesikhwama sempesheni.&lt;ref&gt;https://www.businesslive.co.za/fm/money-and-investing/2019-01-24-decoding-sanlams-cosy-deal-with-patrice-motsepe/&lt;/ref&gt;

=== amabhizinisi nokupha emiphakathini ===
Kwezemidlalo emdlaweni webholo, , waba mnikazi we-Mamelodi Sundowns Football Club Ngo-2003. Wakhethwa njengoMongameli we-Confederation of African Football ngoNtaka 2021.  U-Motsepe nomkakhe, u-Dr. Precious Moloi-Motsepe, batlikitla i-Giving Pledge ngo-2013, bathembisa ukunikela okungenani ingcenye yepahla yabo emisebenzini yokupha enarheni yesewula afrika, elawulwa yi-Motsepe Foundation. UMotsepe wabizwa njengosomabhizinisi ophuma phambili weSewula Afrika ngomnyaka ka-2002 begodu waziwa ngomthelela wakhe omkhulu emkhakheni wamabhizinisi nezemidlalo.

== Iinkomba ==</text>
      <sha1>dbxojqzu4l5spx84iipqy1hz2kwz9t5</sha1>
    </revision>
    <revision>
      <id>6182</id>
      <parentid>6181</parentid>
      <timestamp>2026-02-17T16:07:40Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6182</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3934" sha1="tt0xc23v66ety0yoqp1ojwajq2m3m9t" xml:space="preserve">'''U-Patrice Motsepe''' wabelethwa mhlana  amalanga ama-28 kuTjhirhweni  ngonyaka we-1962, abelethelwa endaweni ye-Soweto.&lt;ref&gt;https://www.rfi.fr/en/sports/20210312-south-african-tycoon-motsepe-elected-as-african-football-supremo&lt;/ref&gt; Ngokwemvelaphi wabelethwa ngu-Augustine Butana u-Chaane Motsepe, utitjhere owaphenduka umnikazi wesikolo/osomabhizinisi, u-Motsepe wakhulela e-Soweto, wafunda izinto ezisisekelo zebhizinisi esitolo sikayise esincani, ngokwelimi elijayelekileko libizwa bona yi spaza. Ngokwefundo wafumana i-Bachelor of Arts e-University of the Swaziland kanye nedigri yomthetho (LLB) e-University of the Witwatersrand.Utjhade no-Dr. Precious Moloi-Motsepe, udorhodere wabantwana nosomabhizinisi.Unabantwana abathathu. Udadwabo, uTshepo, utjhade noMongameli weSewula Afrika u-Cyril Ramaphosa.Ungusomabhilidi wezemayini weSewula Afrika, usomabhizinisi, nomsizi owaba mrholi omnyama wokuthoma enarheni le. Njengomsunguli we-African Rainbow Minerals (ARM) ngo-1997, ngomsebenzi wakhe watjhugulula ibubulo lezemayini, ngokukhamba kwesikhathi wakhula waya emisebenzini yeemali, amandla, kanye nezemidlalo. Wathoma ukusebenza njengomongameli we-Confederation of African Football (CAF) kusukela ngo-2021 begodu umnikazi wesiqhema sebholo se-[[Mamelodi Sundowns]].&lt;ref&gt;https://www.goal.com/en-us/news/patrice-motsepe-africas-ninth-richest-person-appointed-caf/bl3s8p4dafm51fmjkxs4va9q9&lt;/ref&gt;

=== Umsebenzi  wakhe kwezeBhizinisi ===
[[Isimumathi:Patrice Motsepe WEF June 2015.png|thumb|Patrice Motsepe]]
Kwezomthettho ngo-1988, wabalilunga lefemu yomthetho ye-johannesburg, waba mlingani wayo wokuthoma omnyama e-Bowman Gilfillan ngo-1994. Nasele asebenza emayini Ngo-1994, wasungula i-Future Mining, ikhamphani yemayini yekontraga, begodu ngokukhamba kwesikhathi wasungula i-African Rainbow Minerals (ARM) ngo-1997, eyathenga amashafu wegolide angazuzisi ku-Anglo American ukuwenza abe mabhizinisi enza inzuzo. Eminye misebenzi ayenzako wasungula i-African Rainbow Capital (ARC), ikhamphani yokutjala imali ephethwe babantu abanzima, begodu ibandakanyeka emandleni ahlanzekileko nge-African Rainbow Energy and Power (AREP).&lt;ref&gt;http://www.whoswhosa.co.za/Pages/profilefull.aspx?IndID=1140&lt;/ref&gt;

Ngo-2003, u-Motsepe wasungula i-Ubuntu-Botho Investments (UBI) (begodu ngo-2019 waba ne-55% yayo). Ngomnyaka ka-2004 i-UBI yangena esivumelwaneni se-BEE nekhamphani yetjhorensi neyeemali i-Sanlam. Isivumelwano leso saphela ngo-2014 lokha isikolodo nasele sibhadelwe begodu i-UBI yathola i-13.5% ye-Sanlam, kodwana i-UBI inesabelo sokukhetha esingu-18.1% ku-Sanlam njengomlingani wayo we-BEE. I-UBI yabe isithoma i-African Rainbow Capital (ARC), inkampani engaphasi kwe-UBI. Empathy omkhulu we-ARC ngu-Johan van Zyl, owayemphathi omkhulu we-Sanlam.I-ARC ineenkampani ezingaphezu kwama-40, okufaka hlangana i-GoTyme Bank, isiqhema samabubulo i-Afrimat, ikhamphani yezokulima i-BKB, ikhamphani yezokuthintana i-Rain, indawo yokuzithabisa i-Val de Vie, kanye nesabelo esincani ku-Alexander Forbes, umlawuli wesikhwama sempesheni.&lt;ref&gt;https://www.businesslive.co.za/fm/money-and-investing/2019-01-24-decoding-sanlams-cosy-deal-with-patrice-motsepe/&lt;/ref&gt;

=== amabhizinisi nokupha emiphakathini ===
Kwezemidlalo emdlaweni webholo, , waba mnikazi we-Mamelodi Sundowns Football Club Ngo-2003. Wakhethwa njengoMongameli we-Confederation of African Football ngoNtaka 2021.  U-Motsepe nomkakhe, u-Dr. Precious Moloi-Motsepe, batlikitla i-Giving Pledge ngo-2013, bathembisa ukunikela okungenani ingcenye yepahla yabo emisebenzini yokupha enarheni yesewula afrika, elawulwa yi-Motsepe Foundation. UMotsepe wabizwa njengosomabhizinisi ophuma phambili weSewula Afrika ngomnyaka ka-2002 begodu waziwa ngomthelela wakhe omkhulu emkhakheni wamabhizinisi nezemidlalo.

== Iinkomba ==
[[Category:Patrice Motsepe]]
[[Category:Mamelodi sundowns]]
[[Category:African Rainbow Capital]]
[[category:Motsepe Foundation]]
[[Category:Cyril Ramaphosa]]</text>
      <sha1>tt0xc23v66ety0yoqp1ojwajq2m3m9t</sha1>
    </revision>
    <revision>
      <id>6183</id>
      <parentid>6182</parentid>
      <timestamp>2026-02-17T16:19:49Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6183</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4182" sha1="8djbtohs99igbkk47t6n6xr7sxeokf8" xml:space="preserve">'''U-Patrice Motsepe''' wabelethwa mhlana  amalanga ama-28 kuTjhirhweni  ngonyaka we-1962, abelethelwa endaweni ye-Soweto.&lt;ref&gt;https://www.rfi.fr/en/sports/20210312-south-african-tycoon-motsepe-elected-as-african-football-supremo&lt;/ref&gt; Ngokwemvelaphi wabelethwa ngu-Augustine Butana u-Chaane Motsepe, utitjhere owaphenduka umnikazi wamabhizinisi, u-Motsepe wakhulela e-Soweto, wafunda izinto ezisisekelo zebhizinisi esitolo sikayise esincani, ngokwelimi elijayelekileko libizwa bona yi spaza.kukulapho afunda khona izinto zamabhizinisi ngombana weyethengisela abasenzi bemayini. Ngokwefundo wafumana i-Bachelor of Arts e-University of the Swaziland kanye nedigri yomthetho (LLB) e-University of the Witwatersrand.

Utjhade no-Dr. Precious Moloi-Motsepe, udorhodere wabantwana nosomabhizinisi.Unabantwana abathathu. Udadwabo, uTshepo, utjhade noMongameli weSewula Afrika u-Cyril Ramaphosa.Ungusomabhilidi wezemayini weSewula Afrika, usomabhizinisi, nomsizi owaba mrholi omnyama wokuthoma enarheni le. Njengomsunguli we-African Rainbow Minerals (ARM) ngo-1997, ngomsebenzi wakhe watjhugulula ibubulo lezemayini, ngokukhamba kwesikhathi wakhula waya emisebenzini yeemali, amandla, kanye nezemidlalo. Wathoma ukusebenza njengomongameli we-Confederation of African Football (CAF) kusukela ngo-2021 begodu umnikazi wesiqhema sebholo se-[[Mamelodi Sundowns]].&lt;ref&gt;https://www.goal.com/en-us/news/patrice-motsepe-africas-ninth-richest-person-appointed-caf/bl3s8p4dafm51fmjkxs4va9q9&lt;/ref&gt;

=== Umsebenzi  wakhe kwezeBhizinisi ===
[[Isimumathi:Patrice Motsepe WEF June 2015.png|thumb|Patrice Motsepe]]
Kwezomthetho ngo-1988, wabalilunga lefemu yomthetho ye-johannesburg, waba mlingani wayo wokuthoma omnyama e-Bowman Gilfillan ngo-1994. Nasele asebenza emayini Ngo-1994, wasungula i-Future Mining, ikhamphani yemayini yekontraga, begodu ngokukhamba kwesikhathi wasungula i-African Rainbow Minerals (ARM) ngo-1997, eyathenga amashafu wegolide angazuzisi ku-Anglo American ukuwenza abe mabhizinisi enza inzuzo. Eminye misebenzi ayenzako wasungula i-African Rainbow Capital (ARC), ikhamphani yokutjala imali ephethwe babantu abanzima, begodu ibandakanyeka emandleni ahlanzekileko nge-African Rainbow Energy and Power (AREP).&lt;ref&gt;http://www.whoswhosa.co.za/Pages/profilefull.aspx?IndID=1140&lt;/ref&gt;

Ngo-2003, u-Motsepe wasungula i-Ubuntu-Botho Investments (UBI) (begodu ngo-2019 waba ne-55% yayo). Ngomnyaka ka-2004 i-UBI yangena esivumelwaneni se-BEE nekhamphani yetjhorensi neyeemali i-Sanlam. Isivumelwano leso saphela ngo-2014 lokha isikolodo nasele sibhadelwe begodu i-UBI yathola i-13.5% ye-Sanlam, kodwana i-UBI inesabelo sokukhetha esingu-18.1% ku-Sanlam njengomlingani wayo we-BEE. I-UBI yabe isithoma i-African Rainbow Capital (ARC), ikampani engaphasi kwe-UBI. Empathy omkhulu we-ARC ngu-Johan van Zyl, owayemphathi omkhulu we-Sanlam.I-ARC ineenkampani ezingaphezu kwama-40, okufaka hlangana i-GoTyme Bank, isiqhema samabubulo i-Afrimat, ikhamphani yezokulima i-BKB, ikhamphani yezokuthintana i-Rain, indawo yokuzithabisa i-Val de Vie, kanye nesabelo esincani ku-Alexander Forbes, umlawuli wesikhwama sephentjheni.&lt;ref&gt;https://www.businesslive.co.za/fm/money-and-investing/2019-01-24-decoding-sanlams-cosy-deal-with-patrice-motsepe/&lt;/ref&gt;

=== amabhizinisi nokupha emiphakathini ===
Kwezemidlalo emdlaweni webholo, waba mnikazi we-Mamelodi Sundowns Football Club Ngo-2003.&lt;ref&gt;https://www.news24.com/news24/motsepe-buys-sundowns-20040511&lt;/ref&gt; Wakhethwa njengoMongameli we-Confederation of African Football ngoNtaka 2021.  U-Motsepe nomkakhe, u-Dr. Precious Moloi-Motsepe, batlikitla i-Giving Pledge ngo-2013, bathembisa ukunikela ingcenye yepahla yabo emisebenzini yokupha enarheni yesewula afrika, elawulwa yi-Motsepe Foundation. UMotsepe wabizwa njengosomabhizinisi ophuma phambili enarheni ye-Sewula Afrika ngomnyaka ka-2002 begodu waziwa ngomthelela wakhe omkhulu emkhakheni wamabhizinisi nezemidlalo.&lt;ref&gt;Smith, J., 2022. ''Patrice Motsepe: An appetite for disruption''. Jonathan Ball Publishers.&lt;/ref&gt;

== Iinkomba ==
[[Category:Patrice Motsepe]]
[[Category:Mamelodi sundowns]]
[[Category:African Rainbow Capital]]
[[category:Motsepe Foundation]]
[[Category:Cyril Ramaphosa]]</text>
      <sha1>8djbtohs99igbkk47t6n6xr7sxeokf8</sha1>
    </revision>
  </page>
  <page>
    <title>Nandi Madida</title>
    <ns>0</ns>
    <id>1040</id>
    <revision>
      <id>6184</id>
      <timestamp>2026-02-17T16:43:27Z</timestamp>
      <contributor>
        <username>Nhlanhla NaLamula</username>
        <id>1365</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1322646113|Nandi Madida]]&quot;</comment>
      <origin>6184</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3697" sha1="rrmv9u5ubeqf7tnj0ko338unh1olnul" xml:space="preserve">
U '''-Nandi Madida''' ( u'''Mngoma''' ; wabelethwa mhlana amalanga ama-20 kuNtaka 1988) mvumi weSewula Afrika, umlingisi, imodeli kanye nomethuli wakumabonakude. Wabelethwa begodu wakhulela e-Maphumulo, e-KwaZulu-Natal, e-South Africa,  Wakhula waba yindumi ngemva kobana avezwe ngu-DJ Franky njengomvumi wengoma ethi &quot;Tonight&quot;, eyakhutjhwa (2012). 

Njengombana atlikitle ne -Universal Music Group ngo-2011, u-Madida wakhipha i-albhamu yakhe yokuthoma ebizwa nge- ''Nandi'' (2012).

== Ipilo nomsebenzi ==
U-Madida wabelethelwa e -Maphumulo begodu wakhulela e -Durban, e-KwaZulu-Natal. Waya e-Danville Park Girls High School,  ngemva kokuqeda ibanga letjhumi nambili, wakhamba waya e [[Iyunivesithi ye-KwaZulu-Natal|-UKZN]] ukuyofundela zomthetho begodu kwamuva waya e-Varsity College, nanyana ihlelo lakhe lokuthoma bekukufunda ububikindaba.  U-Madida bekangumdansi nemodeli kusukela ebuntwaneni. Wathumba unongorwana we-Miss Junior RSA nakaneminyaka ebunane. 

=== Ibizelo ===
Ipumelelo yakhe ekufuneni ikghono yenza bona athole isikhundla sokuba mlingisi e- Gateway Mall e -Umhlanga . Ngomnyaka ka-2004, nakaneminyaka eli-15, wathola umsebenzi wakhe wokuthoma kumabonakude njengomsingathi wehlelo lokuzithabisa le -SABC2 elibizwa ngokuthi ''yi-Bling'', ebelidzimelele khulu emvumegni namabhayisiko bho.  

=== 2011-2013: ''Nandi'' ===
Ngo-2011, wakhipha ingoma yakhe yokuthoma ethi &quot;Tonight&quot;. Ngokukhamba kwesikhathi watlikitla ne -Universal Music Group begodu wakhipha i-albhamu yakhe yokuthoma ebizwa nge- ''Nandi'' ngo-2012.  

Ngomnyaka ka-2013, waba ngumsingathi no-ProVerb no-Dineo Ranaka ehlelweni le-Mzansi Magic Magazine ''All Access Mzansi'' . 

Ngomnyaka ka-2014, u-Nandi Madida no -KO bakhipha ingoma ethi &quot;Skhanda Love&quot;, yaba yipumelelo msinyana begodu ekugcineni yakhethelwa abonongorwana abanengi bomvumo. 

Kusukela ngo-2015 ukuya ku-2016, wadlala indima ka-Zokuthula Dhlomo ku-Mzansi Magic telenovela ''The Road'' . Waba ngumsingathi we-e.tv reality series i- ''Coke Studio'' .   

Ngenyanga kaKhukhulamungu 2016, yena no- Ayanda Thabethe babambisa umdlalo wemagazini we-BET wezokuzithabisa ''i-BET A-List'' .  

== Ifilimu ==

* ''All Access Mzansi'' (2013) – Yena ngokwakhe 
* ''Isikhathi sesikrini no-Nicky Greenwall'' (2014) – Yena ngokwakhe 
* ''Indlela'' (2015) – Zokuthula &quot;Zoe&quot; Dhlomo 
* ''Ikhodi eluhlaza'' (2015) – Yena ngokwakhe 
* ''I-Coke Studio'' (2016) – Yena ngokwakhe &lt;ref name=&quot;:1&quot; /&gt;
* ''I-BET A-List'' (2016) – Yena ngokwakhe 
* ''I-Lip Sync Battle Africa'' (2017) – Yena ngokwakhe 
* ''Inxusa leBhrendi elilandelako'' (2019) – Yena ngokwakhe 
* ''U-Black Is King'' (2020) – Nala &lt;ref name=&quot;:2&quot; /&gt;

== I-Disc.ography ==

=== Ama-albhamu we-solo ===
{| class=&quot;wikitable&quot;
|+
! Ithayitlela
! Imininingwana ye-albhamu
! Iindawo eziphezulu zetjhadi
! Ref
|-
| ''Nandi''
|
* Ikhutjhwe: 1 kuTjhirhweni 2012
* Ilebula: Universal Music (Pty) Ltd South Africa
|
| 
|}

=== Ama-singles ===

==== Njengomvumiodosa phambili ====

==== Njengomvumiovezweko ====
{| class=&quot;wikitable&quot;
|+
! Ithayitlela
! Umnyaka
! Iindawo eziphezulu zetjhadi
! I-albhamu
! Ref
|-
| &quot;Ithando le-Skhanda&quot;
&lt;small&gt;( KO feat. Nandi Mngoma)&lt;/small&gt;
| 2014
|
| ''I-Skhanda Republic''
| 
|-
| &quot;Tjho Uzokwenza&quot;
&lt;small&gt;( KO feat. Nandi Mngoma)&lt;/small&gt;
| 2019
|
| ''PTY UnLTD''
| 
|}

== Abonongorwana nokuphakanyiswa ==
{| class=&quot;wikitable&quot;
|+
!Year
!Awards
!Work
!Category
!Result
!Ref.
|-
|2020
|SAMA 26
|&quot;Say U Will&quot;
|Best Collaboration
|{{Won}}
|
|-
|2024
|GQ Best Dressed Awards
|Herself
|Best Dressed Couple
|{{won}} 
|
|}

== Ipilo yomuntu mathupha ==
UNandi Madida utjhade noZakhele Madida owaziwa ngoZakes Bantwini begodu banabantwana ababili. 

== Iinkomba ==
{{Reflist}}</text>
      <sha1>rrmv9u5ubeqf7tnj0ko338unh1olnul</sha1>
    </revision>
  </page>
  <page>
    <title>Lebogang Mashile</title>
    <ns>0</ns>
    <id>1041</id>
    <revision>
      <id>6185</id>
      <timestamp>2026-02-17T20:26:18Z</timestamp>
      <contributor>
        <username>Nhlanhla NaLamula</username>
        <id>1365</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1336863902|Lebogang Mashile]]&quot;</comment>
      <origin>6185</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2847" sha1="nfqbs5nkfs3hvacybnpbxs8cqq7vntt" xml:space="preserve">
 

U '''-Lebogang Mashile''' (wabelethwa mhlana amalanga ali-7 kuMhlolanja 1979) uyimbongi, umtloli, umethuli, umlingisi nomvezi weSewula Afrika owabelethelwa e-Amerikha. 

== Umlando ==
Indodakazi yababelethi beSewula Afrika abathunjiweko, uMashile wabelethwa e-United States, e -Pawtucket, e-Rhode Island,  begodu wabuyela eSewula Afrika phakathi kwabo-1990 ngemva kokuphela kwebandlululo .  Wathoma ukufunda umthetho nobudlelwano beentjhabatjhaba eYunivesithi ye-Witwatersrand kodwana waba nekareko ekulu kwezobukghwari. No-Myesha Jenkins, u-Ntsiki Mazwai no-Napo Masheane, wasungula isiqhema seenkondlo i-Feela Sistah. 

Wavela kufilimu yango-2004 ''i-Hotel Rwanda'' begodu sele adlale emidlalweni eminengi yethiyetha, okufakahlangana ''i-Threads'',  eyahlanganisa umdanso, umvumo kanye neenkondlo. Wabuye warekhoda i-albhamu yokudlala bukhoma ehlanganisa umvumo neenkondlo, ebizwa nge- ''Lebo Mashile Live'' .  Wakhiqiza begodu waba ngumsingathi wehlelo lamadokhumenthri ''i-L'Attitude'' ku- SABC 1  begodu waba nomsingathi womdlalo obizwa nge ''-Drawing the Line'' ku- SABC 2 . &lt;ref name=&quot;saho&quot; /&gt;

Ngomnyaka ka-2005, wagadangisa ikhongozelo lakhe lokuthoma leenkondlo, ''In a Ribbon of Rhythm'',  lapho athola khona unongorwana we-Noma ngo-2006.  Wafakwa ku ''-Beyond Words: South African Poetics'' ( flipped eye publishing, 2009), kanye no -Keorapetse Kgositsile, Don Mattera no-Phillippa de 

Villiers ),  begodu mfakisandla ku-2019 anthology ''New Daughters of Africa'', ehlelwe ngu- Margaret Busby . 

U-Mashile nomvumi, umdlali, umtloli u-Majola bakhuphe i-EP ngo-2016. 

== Abonongorwana nokuhlonitjhwa ==
U-Mashile wabizwa ngokuthi ngomunye wabafazi abahle khulu beSewula Afrika ngo-2005 yi ''-Cosmopolitan''  begodu waba ngomunye wabatjha abali-100 abaphambili eSewula Afrika yi- ''Mail &amp;amp;amp; Guardian'' ngo-2006, 2007 nango-2009.  Ngo-2006, waqanjwa njengomuntu ophambili kumabonakude yi ''-The Star'' kuhlu lwabo lwe-100 Ngo-2007 waba ngumamukeli we- City Press / Rapport Woman of Prestige Award, begodu waphinda wakhethwa njengoMfazi womnyaka ka-2010 emkhakheni wezobuKghwari namaSiko ngumagazini we ''-Glamour'' . U-Mashile wavezwa njengomunye wabantu abali-100 abaphezulu be-Afrika ngumagazini we ''-New African'' ngo-2011 begodu ngo-2012 wathumba unongorwana we-Art Ambassador emnyanyeni wokuthoma we -Mbokodo Awards wabantu besifazane eSewula Afrika abasebenza ngobukgwari. U-Mashile wadlala ekuvulweni kwePalamende ngo-2009.  Uchazwe ngokuthi &quot;mhlamunye libizo lokuthoma elifika engqondweni lokha nawucabanga ngomtloli wesifazana owenza amagagasi amakhulu khulu emkhakheni weenkondlo&quot;. 

== Imisebenzi ekhethiweko ==

* ''Ku-Ribbon of Rhythm'', iinkondlo (Oshun Books, 2005,  )
* ''Ukuphapha Phezulu Kwesibhakabhaka'', inkondlo (Umbono we-Afrika, 2008,  ) 

== Iinkomba ==
{{Reflist|30em}}

== Amalinki wangaphandle ==</text>
      <sha1>nfqbs5nkfs3hvacybnpbxs8cqq7vntt</sha1>
    </revision>
  </page>
  <page>
    <title>U-Jesse Jackson</title>
    <ns>0</ns>
    <id>1042</id>
    <revision>
      <id>6186</id>
      <timestamp>2026-02-18T20:59:19Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1339073602|Jesse Jackson]]&quot;</comment>
      <origin>6186</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2573" sha1="p6c9hj9qghpkqc476zkwp797cyna9f2" xml:space="preserve">
 

'''U-Jesse Louis Jackson''' ( né '''Burns''' ; mhlana ali-8 kuNobayeni 1941 – mhlana ali-17 kuMhlolanja 2026) bekangumlweli wamalungelo wobuntu we-America, usopolotiki, nomfundisi we-Baptist . Waba mlawuli ka -Martin Luther King Jr. no -James Bevel ngesikhathi sokunyakaza kwamalungelo wobuntu, waba ngomunye wabadosiphambili bamalungelo wobuntu abavelele khulu ekupheleni kwekhulu lama-20 nekuthomeni kwekhulu lama-21. Kusukela ngo-1991 ukuya ku-1997, wasebenza njengesithunywa se-shadow ne-shadow senator ye- District of Columbia .


Wabelethwa e-Greenville, e-South Carolina, u-Jackson wathoma ukusebenza kwakhe ngeminyaka yabo-1960 begodu wasungula iinhlangano ezahlangana ngokukhamba kwesikhathi ukwakha i-Rainbow/PUSH Coalition. Ukwandisa umsebenzi wakhe eendabeni zamazwe ngamazwe ngabo-1980, waba mgxeki omkhulu wombuso ka-Reagan begodu wathoma umkhankaso wobumongameli ngo-1984. Ekuthomeni bekathathwa njengomuntu ongakakhethwa, waqeda endaweni yesithathu ekuphakanyisweni kwe-Democratic ngemva kwesekela langaphambilini u-Walter Mondale no-Senator u-Gary Hary. Waragela phambili nokulwa kwakhe begodu wafaka umkhankaso wesibili wokuba ngumongameli ngo-1988, waqeda njengomlandeli wesibili kumbusi we-Massachusetts u-Michael Dukakis.

U-Jackson akhenge afune ubumongameli godu, kodwana ngo-1990 wakhethwa njengesenetha ye-District of Columbia, wasebenza isikhathi esisodwa ngesikhathi sokubusa kwaka-Bush no-Clinton. Nanyana ekuthomeni bekasola uMongameli u-Bill Clinton, ngokukhamba kwesikhathi waba msekeli. U-Jackson waba nomsingathi we ''-Both Sides no-Jesse Jackson'' ku -CNN kusukela ngo-1992 ukuya ku-2000. Umgxeki wesihluku samapholisa, i- Republican Party, kanye nemigomo yokulondoloza, bekathathwa njengomunye wabalweli be-Afrika-America abanomthelela khulu ngesikhathi sakhe.

== Ipilo yokuthoma nefundo ==
Njengomntwana, u-Jesse Jackson bekathukwa ngabanye abantwana ngokuzalwa kwakhe ngaphandle komtjhado, begodu wathi amava la amsiza bona aphumelele.   Ukuphila ngaphasi kwemithetho yokuhlukanisa ka -Jim Crow, wafundiswa ukuya ngemva kwebhasi nokusebenzisa imithombo yamanzi ehlukileko—imikhuba ayivumako bekwaba kulapho ibhasi ye-Montgomery ibhoyikatha ngo-1955.  Wafunda esikolweni esihlukaniswe ngokobuhlanga, i-Sterling High School e-Greenville, lapho akhethwa khona njengomengameli, waqeda eklasini lakhe le -10 iincwadi ze-baseball, ibholo yenyawo, nebhola lomnqakiswano. 
[[Isimumathi:The_Student_Government_in_1964_Ayantee.jpg|thumb|U-Jackson (phakathi) namalunga we-Student Government e- North Carolina A&amp;amp;amp;T, c. 1964]]
 </text>
      <sha1>p6c9hj9qghpkqc476zkwp797cyna9f2</sha1>
    </revision>
    <revision>
      <id>6187</id>
      <parentid>6186</parentid>
      <timestamp>2026-02-18T21:01:20Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6187</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2680" sha1="sysejrdbobyjynib57jtg64u11tgpkl" xml:space="preserve">[[Isimumathi:Reverend Jesse Jackson speaking at the UN crop.jpg|thumb|Umfundisi uJesse Jackson akhuluma e UN. ]]
'''U-Jesse Louis Jackson''' ( né '''Burns''' ; mhlana ali-8 kuNobayeni 1941 – mhlana ali-17 kuMhlolanja 2026) bekangumlweli wamalungelo wobuntu we-America, usopolotiki, nomfundisi we-Baptist . Waba mlawuli ka -Martin Luther King Jr. no -James Bevel ngesikhathi sokunyakaza kwamalungelo wobuntu, waba ngomunye wabadosiphambili bamalungelo wobuntu abavelele khulu ekupheleni kwekhulu lama-20 nekuthomeni kwekhulu lama-21. Kusukela ngo-1991 ukuya ku-1997, wasebenza njengesithunywa se-shadow ne-shadow senator ye- District of Columbia .



Wabelethwa e-Greenville, e-South Carolina, u-Jackson wathoma ukusebenza kwakhe ngeminyaka yabo-1960 begodu wasungula iinhlangano ezahlangana ngokukhamba kwesikhathi ukwakha i-Rainbow/PUSH Coalition. Ukwandisa umsebenzi wakhe eendabeni zamazwe ngamazwe ngabo-1980, waba mgxeki omkhulu wombuso ka-Reagan begodu wathoma umkhankaso wobumongameli ngo-1984. Ekuthomeni bekathathwa njengomuntu ongakakhethwa, waqeda endaweni yesithathu ekuphakanyisweni kwe-Democratic ngemva kwesekela langaphambilini u-Walter Mondale no-Senator u-Gary Hary. Waragela phambili nokulwa kwakhe begodu wafaka umkhankaso wesibili wokuba ngumongameli ngo-1988, waqeda njengomlandeli wesibili kumbusi we-Massachusetts u-Michael Dukakis.[[Isimumathi:The_Student_Government_in_1964_Ayantee.jpg|thumb|U-Jackson (phakathi) namalunga we-Student Government e- North Carolina A&amp;amp;amp;T, c. 1964]]U-Jackson akhenge afune ubumongameli godu, kodwana ngo-1990 wakhethwa njengesenetha ye-District of Columbia, wasebenza isikhathi esisodwa ngesikhathi sokubusa kwaka-Bush no-Clinton. Nanyana ekuthomeni bekasola uMongameli u-Bill Clinton, ngokukhamba kwesikhathi waba msekeli. U-Jackson waba nomsingathi we ''-Both Sides no-Jesse Jackson'' ku -CNN kusukela ngo-1992 ukuya ku-2000. Umgxeki wesihluku samapholisa, i- Republican Party, kanye nemigomo yokulondoloza, bekathathwa njengomunye wabalweli be-Afrika-America abanomthelela khulu ngesikhathi sakhe.

== Ipilo yokuthoma nefundo ==
Njengomntwana, u-Jesse Jackson bekathukwa ngabanye abantwana ngokuzalwa kwakhe ngaphandle komtjhado, begodu wathi amava la amsiza bona aphumelele.   Ukuphila ngaphasi kwemithetho yokuhlukanisa ka -Jim Crow, wafundiswa ukuya ngemva kwebhasi nokusebenzisa imithombo yamanzi ehlukileko—imikhuba ayivumako bekwaba kulapho ibhasi ye-Montgomery ibhoyikatha ngo-1955.  Wafunda esikolweni esihlukaniswe ngokobuhlanga, i-Sterling High School e-Greenville, lapho akhethwa khona njengomengameli, waqeda eklasini lakhe le -10 iincwadi ze-baseball, ibholo yenyawo, nebhola lomnqakiswano. 

 </text>
      <sha1>sysejrdbobyjynib57jtg64u11tgpkl</sha1>
    </revision>
    <revision>
      <id>6188</id>
      <parentid>6187</parentid>
      <timestamp>2026-02-18T21:03:34Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6188</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3180" sha1="00luc1tn00lz705nggaqs8tcp5z0hzg" xml:space="preserve">[[Isimumathi:Reverend Jesse Jackson speaking at the UN crop.jpg|thumb|Umfundisi uJesse Jackson akhuluma e UN. ]]
'''U-Jesse Louis Jackson''' ( né '''Burns''' ; mhlana ali-8 kuNobayeni 1941 – mhlana ali-17 kuMhlolanja 2026) bekangumlweli wamalungelo wobuntu we-America, usopolotiki, nomfundisi we-Baptist &lt;ref name=&quot;:0&quot;&gt;https://www.independent.co.uk/news/jesse-jackson-sports-chicago-bulls-indiana-pacers-black-b2923142.html&lt;/ref&gt;. Waba mlawuli ka -Martin Luther King Jr. no -James Bevel ngesikhathi sokunyakaza kwamalungelo wobuntu, waba ngomunye wabadosiphambili bamalungelo wobuntu abavelele khulu ekupheleni kwekhulu lama-20 nekuthomeni kwekhulu lama-21. Kusukela ngo-1991 ukuya ku-1997, wasebenza njengesithunywa se-shadow ne-shadow senator ye- District of Columbia .&lt;ref&gt;https://www.cbsnews.com/chicago/video/family-speaks-on-life-and-legacy-of-rev-jesse-jackson/&lt;/ref&gt;




Wabelethwa e-Greenville, e-South Carolina, u-Jackson wathoma ukusebenza kwakhe ngeminyaka yabo-1960 begodu wasungula iinhlangano ezahlangana ngokukhamba kwesikhathi ukwakha i-Rainbow/PUSH Coalition. Ukwandisa umsebenzi wakhe eendabeni zamazwe ngamazwe ngabo-1980, waba mgxeki omkhulu wombuso ka-Reagan begodu wathoma umkhankaso wobumongameli ngo-1984.&lt;ref&gt;https://www.12onyourside.com/video/2026/02/18/richmonders-reflect-jesse-jacksons-lasting-impact-community/&lt;/ref&gt; Ekuthomeni bekathathwa njengomuntu ongakakhethwa, waqeda endaweni yesithathu ekuphakanyisweni kwe-Democratic ngemva kwesekela langaphambilini u-Walter Mondale no-Senator u-Gary Hary. Waragela phambili nokulwa kwakhe begodu wafaka umkhankaso wesibili wokuba ngumongameli ngo-1988, waqeda njengomlandeli wesibili kumbusi we-Massachusetts u-Michael Dukakis.&lt;ref&gt;https://www.dailymaverick.co.za/article/2026-02-18-an-extraordinary-american-pilgrimage-jesse-jacksons-final-lap-has-been-run/&lt;/ref&gt;&lt;ref name=&quot;:0&quot; /&gt;[[Isimumathi:The_Student_Government_in_1964_Ayantee.jpg|thumb|U-Jackson (phakathi) namalunga we-Student Government e- North Carolina A&amp;amp;amp;T, c. 1964]]U-Jackson akhenge afune ubumongameli godu, kodwana ngo-1990 wakhethwa njengesenetha ye-District of Columbia, wasebenza isikhathi esisodwa ngesikhathi sokubusa kwaka-Bush no-Clinton. Nanyana ekuthomeni bekasola uMongameli u-Bill Clinton, ngokukhamba kwesikhathi waba msekeli. U-Jackson waba nomsingathi we ''-Both Sides no-Jesse Jackson'' ku -CNN kusukela ngo-1992 ukuya ku-2000. Umgxeki wesihluku samapholisa, i- Republican Party, kanye nemigomo yokulondoloza, bekathathwa njengomunye wabalweli be-Afrika-America abanomthelela khulu ngesikhathi sakhe.

== Ipilo yokuthoma nefundo ==
Njengomntwana, u-Jesse Jackson bekathukwa ngabanye abantwana ngokuzalwa kwakhe ngaphandle komtjhado, begodu wathi amava la amsiza bona aphumelele.   Ukuphila ngaphasi kwemithetho yokuhlukanisa ka -Jim Crow, wafundiswa ukuya ngemva kwebhasi nokusebenzisa imithombo yamanzi ehlukileko—imikhuba ayivumako bekwaba kulapho ibhasi ye-Montgomery ibhoyikatha ngo-1955.  Wafunda esikolweni esihlukaniswe ngokobuhlanga, i-Sterling High School e-Greenville, lapho akhethwa khona njengomengameli, waqeda eklasini lakhe le -10 iincwadi ze-baseball, ibholo yenyawo, nebhola lomnqakiswano. 

 </text>
      <sha1>00luc1tn00lz705nggaqs8tcp5z0hzg</sha1>
    </revision>
    <revision>
      <id>6189</id>
      <parentid>6188</parentid>
      <timestamp>2026-02-18T21:04:07Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6189</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3181" sha1="3m64i7y9qpqf5xcglk459smshqvoxhv" xml:space="preserve">[[Isimumathi:Reverend Jesse Jackson speaking at the UN crop.jpg|thumb|Umfundisi uJesse Jackson akhuluma e UN. ]]
'''U-Jesse Louis Jackson''' ( né '''Burns''' ; mhlana ali-8 kuNobayeni 1941 – mhlana ali-17 kuMhlolanja 2026) bekangumlweli wamalungelo wobuntu we-[[America]], usopolotiki, nomfundisi we-Baptist &lt;ref name=&quot;:0&quot;&gt;https://www.independent.co.uk/news/jesse-jackson-sports-chicago-bulls-indiana-pacers-black-b2923142.html&lt;/ref&gt;. Waba mlawuli ka -Martin Luther King Jr. no -James Bevel ngesikhathi sokunyakaza kwamalungelo wobuntu, waba ngomunye wabadosiphambili bamalungelo wobuntu abavelele khulu ekupheleni kwekhulu lama-20 nekuthomeni kwekhulu lama-21. Kusukela ngo-1991 ukuya ku-1997, wasebenza njengesithunywa se-shadow ne-shadow senator ye- District of Columbia .&lt;ref&gt;https://www.cbsnews.com/chicago/video/family-speaks-on-life-and-legacy-of-rev-jesse-jackson/&lt;/ref&gt;

Wabelethwa e-Greenville, e-South Carolina, u-Jackson wathoma ukusebenza kwakhe ngeminyaka yabo-1960 begodu wasungula iinhlangano ezahlangana ngokukhamba kwesikhathi ukwakha i-Rainbow/PUSH Coalition. Ukwandisa umsebenzi wakhe eendabeni zamazwe ngamazwe ngabo-1980, waba mgxeki omkhulu wombuso ka-Reagan begodu wathoma umkhankaso wobumongameli ngo-1984.&lt;ref&gt;https://www.12onyourside.com/video/2026/02/18/richmonders-reflect-jesse-jacksons-lasting-impact-community/&lt;/ref&gt; Ekuthomeni bekathathwa njengomuntu ongakakhethwa, waqeda endaweni yesithathu ekuphakanyisweni kwe-Democratic ngemva kwesekela langaphambilini u-Walter Mondale no-Senator u-Gary Hary. Waragela phambili nokulwa kwakhe begodu wafaka umkhankaso wesibili wokuba ngumongameli ngo-1988, waqeda njengomlandeli wesibili kumbusi we-Massachusetts u-Michael Dukakis.&lt;ref&gt;https://www.dailymaverick.co.za/article/2026-02-18-an-extraordinary-american-pilgrimage-jesse-jacksons-final-lap-has-been-run/&lt;/ref&gt;&lt;ref name=&quot;:0&quot; /&gt;[[Isimumathi:The_Student_Government_in_1964_Ayantee.jpg|thumb|U-Jackson (phakathi) namalunga we-Student Government e- North Carolina A&amp;amp;amp;T, c. 1964]]U-Jackson akhenge afune ubumongameli godu, kodwana ngo-1990 wakhethwa njengesenetha ye-District of Columbia, wasebenza isikhathi esisodwa ngesikhathi sokubusa kwaka-Bush no-Clinton. Nanyana ekuthomeni bekasola uMongameli u-Bill Clinton, ngokukhamba kwesikhathi waba msekeli. U-Jackson waba nomsingathi we ''-Both Sides no-Jesse Jackson'' ku -CNN kusukela ngo-1992 ukuya ku-2000. Umgxeki wesihluku samapholisa, i- Republican Party, kanye nemigomo yokulondoloza, bekathathwa njengomunye wabalweli be-Afrika-America abanomthelela khulu ngesikhathi sakhe.

== Ipilo yokuthoma nefundo ==
Njengomntwana, u-Jesse Jackson bekathukwa ngabanye abantwana ngokuzalwa kwakhe ngaphandle komtjhado, begodu wathi amava la amsiza bona aphumelele.   Ukuphila ngaphasi kwemithetho yokuhlukanisa ka -Jim Crow, wafundiswa ukuya ngemva kwebhasi nokusebenzisa imithombo yamanzi ehlukileko—imikhuba ayivumako bekwaba kulapho ibhasi ye-Montgomery ibhoyikatha ngo-1955.  Wafunda esikolweni esihlukaniswe ngokobuhlanga, i-Sterling High School e-Greenville, lapho akhethwa khona njengomengameli, waqeda eklasini lakhe le -10 iincwadi ze-baseball, ibholo yenyawo, nebhola lomnqakiswano. 

 </text>
      <sha1>3m64i7y9qpqf5xcglk459smshqvoxhv</sha1>
    </revision>
    <revision>
      <id>6190</id>
      <parentid>6189</parentid>
      <timestamp>2026-02-18T21:05:08Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6190</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3193" sha1="5tmuw2pnlk94rodgg19fz9zyqk4p5hd" xml:space="preserve">[[Isimumathi:Reverend Jesse Jackson speaking at the UN crop.jpg|thumb|Umfundisi uJesse Jackson akhuluma e UN. ]]
'''U-Jesse Louis Jackson''' ( né '''Burns''' ; mhlana ali-8 kuNobayeni 1941 – mhlana ali-17 kuMhlolanja 2026) bekangumlweli wamalungelo wobuntu we-[[America]], usopolotiki, nomfundisi we-Baptist &lt;ref name=&quot;:0&quot;&gt;https://www.independent.co.uk/news/jesse-jackson-sports-chicago-bulls-indiana-pacers-black-b2923142.html&lt;/ref&gt;. Waba mlawuli ka -Martin Luther King Jr. no -James Bevel ngesikhathi sokunyakaza kwamalungelo wobuntu, waba ngomunye wabadosiphambili bamalungelo wobuntu abavelele khulu ekupheleni kwekhulu lama-20 nekuthomeni kwekhulu lama-21. Kusukela ngo-1991 ukuya ku-1997, wasebenza njengesithunywa se-shadow ne-shadow senator ye- District of Columbia .&lt;ref&gt;https://www.cbsnews.com/chicago/video/family-speaks-on-life-and-legacy-of-rev-jesse-jackson/&lt;/ref&gt;

Wabelethwa e-[[Greenville]], e-[[South Carolina]], u-Jackson wathoma ukusebenza kwakhe ngeminyaka yabo-1960 begodu wasungula iinhlangano ezahlangana ngokukhamba kwesikhathi ukwakha i-Rainbow/PUSH Coalition. Ukwandisa umsebenzi wakhe eendabeni zamazwe ngamazwe ngabo-1980, waba mgxeki omkhulu wombuso ka-Reagan begodu wathoma umkhankaso wobumongameli ngo-1984.&lt;ref&gt;https://www.12onyourside.com/video/2026/02/18/richmonders-reflect-jesse-jacksons-lasting-impact-community/&lt;/ref&gt; Ekuthomeni bekathathwa njengomuntu ongakakhethwa, waqeda endaweni yesithathu ekuphakanyisweni kwe-Democratic ngemva kwesekela langaphambilini u-Walter Mondale no-Senator u-Gary Hary. Waragela phambili nokulwa kwakhe begodu wafaka umkhankaso wesibili wokuba ngumongameli ngo-1988, waqeda njengomlandeli wesibili kumbusi we-Massachusetts u-Michael Dukakis.&lt;ref&gt;https://www.dailymaverick.co.za/article/2026-02-18-an-extraordinary-american-pilgrimage-jesse-jacksons-final-lap-has-been-run/&lt;/ref&gt;&lt;ref name=&quot;:0&quot; /&gt;[[Isimumathi:The_Student_Government_in_1964_Ayantee.jpg|thumb|U-Jackson (phakathi) namalunga we-Student Government e- North Carolina A&amp;amp;amp;T, c. 1964]]U-Jackson akhenge afune ubumongameli godu, kodwana ngo-1990 wakhethwa njengesenetha ye-District of [[Columbia]], wasebenza isikhathi esisodwa ngesikhathi sokubusa kwaka-Bush no-Clinton. Nanyana ekuthomeni bekasola uMongameli u-Bill Clinton, ngokukhamba kwesikhathi waba msekeli. U-Jackson waba nomsingathi we ''-Both Sides no-Jesse Jackson'' ku -CNN kusukela ngo-1992 ukuya ku-2000. Umgxeki wesihluku samapholisa, i- Republican Party, kanye nemigomo yokulondoloza, bekathathwa njengomunye wabalweli be-Afrika-America abanomthelela khulu ngesikhathi sakhe.

== Ipilo yokuthoma nefundo ==
Njengomntwana, u-Jesse Jackson bekathukwa ngabanye abantwana ngokuzalwa kwakhe ngaphandle komtjhado, begodu wathi amava la amsiza bona aphumelele.   Ukuphila ngaphasi kwemithetho yokuhlukanisa ka -Jim Crow, wafundiswa ukuya ngemva kwebhasi nokusebenzisa imithombo yamanzi ehlukileko—imikhuba ayivumako bekwaba kulapho ibhasi ye-Montgomery ibhoyikatha ngo-1955.  Wafunda esikolweni esihlukaniswe ngokobuhlanga, i-Sterling High School e-Greenville, lapho akhethwa khona njengomengameli, waqeda eklasini lakhe le -10 iincwadi ze-baseball, ibholo yenyawo, nebhola lomnqakiswano. 

 </text>
      <sha1>5tmuw2pnlk94rodgg19fz9zyqk4p5hd</sha1>
    </revision>
    <revision>
      <id>6191</id>
      <parentid>6190</parentid>
      <timestamp>2026-02-18T21:05:23Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6191</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3197" sha1="f3apff5pfqtmc3szjj3ds2wi1e7v4xw" xml:space="preserve">[[Isimumathi:Reverend Jesse Jackson speaking at the UN crop.jpg|thumb|Umfundisi uJesse Jackson akhuluma e UN. ]]
'''U-Jesse Louis Jackson''' ( né '''Burns''' ; mhlana ali-8 kuNobayeni 1941 – mhlana ali-17 kuMhlolanja 2026) bekangumlweli wamalungelo wobuntu we-[[America]], usopolotiki, nomfundisi we-Baptist &lt;ref name=&quot;:0&quot;&gt;https://www.independent.co.uk/news/jesse-jackson-sports-chicago-bulls-indiana-pacers-black-b2923142.html&lt;/ref&gt;. Waba mlawuli ka -Martin Luther King Jr. no -James Bevel ngesikhathi sokunyakaza kwamalungelo wobuntu, waba ngomunye wabadosiphambili bamalungelo wobuntu abavelele khulu ekupheleni kwekhulu lama-20 nekuthomeni kwekhulu lama-21. Kusukela ngo-1991 ukuya ku-1997, wasebenza njengesithunywa se-shadow ne-shadow senator ye- District of Columbia .&lt;ref&gt;https://www.cbsnews.com/chicago/video/family-speaks-on-life-and-legacy-of-rev-jesse-jackson/&lt;/ref&gt;

Wabelethwa e-[[Greenville]], e-[[South Carolina]], u-Jackson wathoma ukusebenza kwakhe ngeminyaka yabo-1960 begodu wasungula iinhlangano ezahlangana ngokukhamba kwesikhathi ukwakha i-Rainbow/PUSH Coalition. Ukwandisa umsebenzi wakhe eendabeni zamazwe ngamazwe ngabo-1980, waba mgxeki omkhulu wombuso ka-Reagan begodu wathoma umkhankaso wobumongameli ngo-1984.&lt;ref&gt;https://www.12onyourside.com/video/2026/02/18/richmonders-reflect-jesse-jacksons-lasting-impact-community/&lt;/ref&gt; Ekuthomeni bekathathwa njengomuntu ongakakhethwa, waqeda endaweni yesithathu ekuphakanyisweni kwe-Democratic ngemva kwesekela langaphambilini u-Walter Mondale no-Senator u-Gary Hary. Waragela phambili nokulwa kwakhe begodu wafaka umkhankaso wesibili wokuba ngumongameli ngo-1988, waqeda njengomlandeli wesibili kumbusi we-Massachusetts u-Michael Dukakis.&lt;ref&gt;https://www.dailymaverick.co.za/article/2026-02-18-an-extraordinary-american-pilgrimage-jesse-jacksons-final-lap-has-been-run/&lt;/ref&gt;&lt;ref name=&quot;:0&quot; /&gt;[[Isimumathi:The_Student_Government_in_1964_Ayantee.jpg|thumb|U-Jackson (phakathi) namalunga we-Student Government e- North Carolina A&amp;amp;amp;T, c. 1964]]U-Jackson akhenge afune ubumongameli godu, kodwana ngo-1990 wakhethwa njengesenetha ye-District of [[Columbia]], wasebenza isikhathi esisodwa ngesikhathi sokubusa kwaka-Bush no-Clinton. Nanyana ekuthomeni bekasola uMongameli u-Bill Clinton, ngokukhamba kwesikhathi waba msekeli. U-Jackson waba nomsingathi we ''-Both Sides no-Jesse Jackson'' ku -CNN kusukela ngo-1992 ukuya ku-2000. Umgxeki wesihluku samapholisa, i- Republican Party, kanye nemigomo yokulondoloza, bekathathwa njengomunye wabalweli be-Afrika-America abanomthelela khulu ngesikhathi sakhe.

== Ipilo yokuthoma nefundo ==
Njengomntwana, u-Jesse Jackson bekathukwa ngabanye abantwana ngokuzalwa kwakhe ngaphandle komtjhado, begodu wathi amava la amsiza bona aphumelele.   Ukuphila ngaphasi kwemithetho yokuhlukanisa ka -[[Jim Crow]], wafundiswa ukuya ngemva kwebhasi nokusebenzisa imithombo yamanzi ehlukileko—imikhuba ayivumako bekwaba kulapho ibhasi ye-Montgomery ibhoyikatha ngo-1955.  Wafunda esikolweni esihlukaniswe ngokobuhlanga, i-Sterling High School e-Greenville, lapho akhethwa khona njengomengameli, waqeda eklasini lakhe le -10 iincwadi ze-baseball, ibholo yenyawo, nebhola lomnqakiswano. 

 </text>
      <sha1>f3apff5pfqtmc3szjj3ds2wi1e7v4xw</sha1>
    </revision>
    <revision>
      <id>6192</id>
      <parentid>6191</parentid>
      <timestamp>2026-02-18T21:05:50Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6192</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3201" sha1="1r9q3rps2b146yag8ttmxuitm4p3ode" xml:space="preserve">[[Isimumathi:Reverend Jesse Jackson speaking at the UN crop.jpg|thumb|Umfundisi uJesse Jackson akhuluma e UN. ]]
'''U-Jesse Louis Jackson''' ( né '''Burns''' ; mhlana ali-8 kuNobayeni 1941 – mhlana ali-17 kuMhlolanja 2026) bekangumlweli wamalungelo wobuntu we-[[America]], usopolotiki, nomfundisi we-Baptist &lt;ref name=&quot;:0&quot;&gt;https://www.independent.co.uk/news/jesse-jackson-sports-chicago-bulls-indiana-pacers-black-b2923142.html&lt;/ref&gt;. Waba mlawuli ka -[[Martin Luther King Jr.]] no -James Bevel ngesikhathi sokunyakaza kwamalungelo wobuntu, waba ngomunye wabadosiphambili bamalungelo wobuntu abavelele khulu ekupheleni kwekhulu lama-20 nekuthomeni kwekhulu lama-21. Kusukela ngo-1991 ukuya ku-1997, wasebenza njengesithunywa se-shadow ne-shadow senator ye- District of Columbia .&lt;ref&gt;https://www.cbsnews.com/chicago/video/family-speaks-on-life-and-legacy-of-rev-jesse-jackson/&lt;/ref&gt;

Wabelethwa e-[[Greenville]], e-[[South Carolina]], u-Jackson wathoma ukusebenza kwakhe ngeminyaka yabo-1960 begodu wasungula iinhlangano ezahlangana ngokukhamba kwesikhathi ukwakha i-Rainbow/PUSH Coalition. Ukwandisa umsebenzi wakhe eendabeni zamazwe ngamazwe ngabo-1980, waba mgxeki omkhulu wombuso ka-Reagan begodu wathoma umkhankaso wobumongameli ngo-1984.&lt;ref&gt;https://www.12onyourside.com/video/2026/02/18/richmonders-reflect-jesse-jacksons-lasting-impact-community/&lt;/ref&gt; Ekuthomeni bekathathwa njengomuntu ongakakhethwa, waqeda endaweni yesithathu ekuphakanyisweni kwe-Democratic ngemva kwesekela langaphambilini u-Walter Mondale no-Senator u-Gary Hary. Waragela phambili nokulwa kwakhe begodu wafaka umkhankaso wesibili wokuba ngumongameli ngo-1988, waqeda njengomlandeli wesibili kumbusi we-Massachusetts u-Michael Dukakis.&lt;ref&gt;https://www.dailymaverick.co.za/article/2026-02-18-an-extraordinary-american-pilgrimage-jesse-jacksons-final-lap-has-been-run/&lt;/ref&gt;&lt;ref name=&quot;:0&quot; /&gt;[[Isimumathi:The_Student_Government_in_1964_Ayantee.jpg|thumb|U-Jackson (phakathi) namalunga we-Student Government e- North Carolina A&amp;amp;amp;T, c. 1964]]U-Jackson akhenge afune ubumongameli godu, kodwana ngo-1990 wakhethwa njengesenetha ye-District of [[Columbia]], wasebenza isikhathi esisodwa ngesikhathi sokubusa kwaka-Bush no-Clinton. Nanyana ekuthomeni bekasola uMongameli u-Bill Clinton, ngokukhamba kwesikhathi waba msekeli. U-Jackson waba nomsingathi we ''-Both Sides no-Jesse Jackson'' ku -CNN kusukela ngo-1992 ukuya ku-2000. Umgxeki wesihluku samapholisa, i- Republican Party, kanye nemigomo yokulondoloza, bekathathwa njengomunye wabalweli be-Afrika-America abanomthelela khulu ngesikhathi sakhe.

== Ipilo yokuthoma nefundo ==
Njengomntwana, u-Jesse Jackson bekathukwa ngabanye abantwana ngokuzalwa kwakhe ngaphandle komtjhado, begodu wathi amava la amsiza bona aphumelele.   Ukuphila ngaphasi kwemithetho yokuhlukanisa ka -[[Jim Crow]], wafundiswa ukuya ngemva kwebhasi nokusebenzisa imithombo yamanzi ehlukileko—imikhuba ayivumako bekwaba kulapho ibhasi ye-Montgomery ibhoyikatha ngo-1955.  Wafunda esikolweni esihlukaniswe ngokobuhlanga, i-Sterling High School e-Greenville, lapho akhethwa khona njengomengameli, waqeda eklasini lakhe le -10 iincwadi ze-baseball, ibholo yenyawo, nebhola lomnqakiswano. 

 </text>
      <sha1>1r9q3rps2b146yag8ttmxuitm4p3ode</sha1>
    </revision>
    <revision>
      <id>6193</id>
      <parentid>6192</parentid>
      <timestamp>2026-02-18T21:06:27Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6193</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3214" sha1="ku35ltt9upi1i8k06h79pq8np6yas5r" xml:space="preserve">[[Isimumathi:Reverend Jesse Jackson speaking at the UN crop.jpg|thumb|Umfundisi uJesse Jackson akhuluma e UN. ]]
'''U-Jesse Louis Jackson''' ( né '''Burns''' ; mhlana ali-8 kuNobayeni 1941 – mhlana ali-17 kuMhlolanja 2026) bekangumlweli wamalungelo wobuntu we-[[America]], usopolotiki, nomfundisi we-Baptist &lt;ref name=&quot;:0&quot;&gt;https://www.independent.co.uk/news/jesse-jackson-sports-chicago-bulls-indiana-pacers-black-b2923142.html&lt;/ref&gt;. Waba mlawuli ka -[[Martin Luther King Jr.]] no -James Bevel ngesikhathi sokunyakaza kwamalungelo wobuntu, waba ngomunye wabadosiphambili bamalungelo wobuntu abavelele khulu ekupheleni kwekhulu lama-20 nekuthomeni kwekhulu lama-21. Kusukela ngo-1991 ukuya ku-1997, wasebenza njengesithunywa se-shadow ne-shadow senator ye- District of Columbia .&lt;ref&gt;https://www.cbsnews.com/chicago/video/family-speaks-on-life-and-legacy-of-rev-jesse-jackson/&lt;/ref&gt;

Wabelethwa e-[[Greenville]], e-[[South Carolina]], u-Jackson wathoma ukusebenza kwakhe ngeminyaka yabo-1960 begodu wasungula iinhlangano ezahlangana ngokukhamba kwesikhathi ukwakha i-Rainbow/PUSH Coalition. Ukwandisa umsebenzi wakhe eendabeni zamazwe ngamazwe ngabo-1980, waba mgxeki omkhulu wombuso ka-Reagan begodu wathoma umkhankaso wobumongameli ngo-1984.&lt;ref&gt;https://www.12onyourside.com/video/2026/02/18/richmonders-reflect-jesse-jacksons-lasting-impact-community/&lt;/ref&gt; Ekuthomeni bekathathwa njengomuntu ongakakhethwa, waqeda endaweni yesithathu ekuphakanyisweni kwe-Democratic ngemva kwesekela langaphambilini u-Walter Mondale no-Senator u-Gary Hary. Waragela phambili nokulwa kwakhe begodu wafaka umkhankaso wesibili wokuba ngumongameli ngo-1988, waqeda njengomlandeli wesibili kumbusi we-Massachusetts u-Michael Dukakis.&lt;ref&gt;https://www.dailymaverick.co.za/article/2026-02-18-an-extraordinary-american-pilgrimage-jesse-jacksons-final-lap-has-been-run/&lt;/ref&gt;&lt;ref name=&quot;:0&quot; /&gt;[[Isimumathi:The_Student_Government_in_1964_Ayantee.jpg|thumb|U-Jackson (phakathi) namalunga we-Student Government e- North Carolina A&amp;amp;amp;T, c. 1964]]U-Jackson akhenge afune ubumongameli godu, kodwana ngo-1990 wakhethwa njengesenetha ye-District of [[Columbia]], wasebenza isikhathi esisodwa ngesikhathi sokubusa kwaka-Bush no-Clinton. Nanyana ekuthomeni bekasola uMongameli u-Bill Clinton, ngokukhamba kwesikhathi waba msekeli. U-Jackson waba nomsingathi we ''-Both Sides no-Jesse Jackson'' ku -CNN kusukela ngo-1992 ukuya ku-2000. Umgxeki wesihluku samapholisa, i- Republican Party, kanye nemigomo yokulondoloza, bekathathwa njengomunye wabalweli be-Afrika-America abanomthelela khulu ngesikhathi sakhe.

== Ipilo yokuthoma nefundo ==
Njengomntwana, u-Jesse Jackson bekathukwa ngabanye abantwana ngokuzalwa kwakhe ngaphandle komtjhado, begodu wathi amava la amsiza bona aphumelele.   Ukuphila ngaphasi kwemithetho yokuhlukanisa ka -[[Jim Crow]], wafundiswa ukuya ngemva kwebhasi nokusebenzisa imithombo yamanzi ehlukileko—imikhuba ayivumako bekwaba kulapho ibhasi ye-Montgomery ibhoyikatha ngo-1955.  Wafunda esikolweni esihlukaniswe ngokobuhlanga, i-Sterling High School e-Greenville, lapho akhethwa khona njengomengameli, waqeda eklasini lakhe le -10 iincwadi ze-baseball, ibholo yenyawo, nebhola lomnqakiswano. 

== Inkomba  ==</text>
      <sha1>ku35ltt9upi1i8k06h79pq8np6yas5r</sha1>
    </revision>
    <revision>
      <id>6194</id>
      <parentid>6193</parentid>
      <timestamp>2026-02-18T21:06:47Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6194</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3226" sha1="ayk7wxdo5g2dwyo4yyxregw55tpoglq" xml:space="preserve">[[Isimumathi:Reverend Jesse Jackson speaking at the UN crop.jpg|thumb|Umfundisi uJesse Jackson akhuluma e UN. ]]
'''U-Jesse Louis Jackson''' ( né '''Burns''' ; mhlana ali-8 kuNobayeni 1941 – mhlana ali-17 kuMhlolanja 2026) bekangumlweli wamalungelo wobuntu we-[[America]], usopolotiki, nomfundisi we-Baptist &lt;ref name=&quot;:0&quot;&gt;https://www.independent.co.uk/news/jesse-jackson-sports-chicago-bulls-indiana-pacers-black-b2923142.html&lt;/ref&gt;. Waba mlawuli ka -[[Martin Luther King Jr.]] no -James Bevel ngesikhathi sokunyakaza kwamalungelo wobuntu, waba ngomunye wabadosiphambili bamalungelo wobuntu abavelele khulu ekupheleni kwekhulu lama-20 nekuthomeni kwekhulu lama-21. Kusukela ngo-1991 ukuya ku-1997, wasebenza njengesithunywa se-shadow ne-shadow senator ye- District of Columbia .&lt;ref&gt;https://www.cbsnews.com/chicago/video/family-speaks-on-life-and-legacy-of-rev-jesse-jackson/&lt;/ref&gt;

Wabelethwa e-[[Greenville]], e-[[South Carolina]], u-Jackson wathoma ukusebenza kwakhe ngeminyaka yabo-1960 begodu wasungula iinhlangano ezahlangana ngokukhamba kwesikhathi ukwakha i-Rainbow/PUSH Coalition. Ukwandisa umsebenzi wakhe eendabeni zamazwe ngamazwe ngabo-1980, waba mgxeki omkhulu wombuso ka-Reagan begodu wathoma umkhankaso wobumongameli ngo-1984.&lt;ref&gt;https://www.12onyourside.com/video/2026/02/18/richmonders-reflect-jesse-jacksons-lasting-impact-community/&lt;/ref&gt; Ekuthomeni bekathathwa njengomuntu ongakakhethwa, waqeda endaweni yesithathu ekuphakanyisweni kwe-Democratic ngemva kwesekela langaphambilini u-Walter Mondale no-Senator u-Gary Hary. Waragela phambili nokulwa kwakhe begodu wafaka umkhankaso wesibili wokuba ngumongameli ngo-1988, waqeda njengomlandeli wesibili kumbusi we-Massachusetts u-Michael Dukakis.&lt;ref&gt;https://www.dailymaverick.co.za/article/2026-02-18-an-extraordinary-american-pilgrimage-jesse-jacksons-final-lap-has-been-run/&lt;/ref&gt;&lt;ref name=&quot;:0&quot; /&gt;[[Isimumathi:The_Student_Government_in_1964_Ayantee.jpg|thumb|U-Jackson (phakathi) namalunga we-Student Government e- North Carolina A&amp;amp;amp;T, c. 1964]]U-Jackson akhenge afune ubumongameli godu, kodwana ngo-1990 wakhethwa njengesenetha ye-District of [[Columbia]], wasebenza isikhathi esisodwa ngesikhathi sokubusa kwaka-Bush no-Clinton. Nanyana ekuthomeni bekasola uMongameli u-Bill Clinton, ngokukhamba kwesikhathi waba msekeli. U-Jackson waba nomsingathi we ''-Both Sides no-Jesse Jackson'' ku -CNN kusukela ngo-1992 ukuya ku-2000. Umgxeki wesihluku samapholisa, i- Republican Party, kanye nemigomo yokulondoloza, bekathathwa njengomunye wabalweli be-Afrika-America abanomthelela khulu ngesikhathi sakhe.

== Ipilo yokuthoma nefundo ==
Njengomntwana, u-Jesse Jackson bekathukwa ngabanye abantwana ngokuzalwa kwakhe ngaphandle komtjhado, begodu wathi amava la amsiza bona aphumelele.   Ukuphila ngaphasi kwemithetho yokuhlukanisa ka -[[Jim Crow]], wafundiswa ukuya ngemva kwebhasi nokusebenzisa imithombo yamanzi ehlukileko—imikhuba ayivumako bekwaba kulapho ibhasi ye-Montgomery ibhoyikatha ngo-1955.  Wafunda esikolweni esihlukaniswe ngokobuhlanga, i-Sterling High School e-Greenville, lapho akhethwa khona njengomengameli, waqeda eklasini lakhe le -10 iincwadi ze-baseball, ibholo yenyawo, nebhola lomnqakiswano. 

== Inkomba  ==
{{reflist]]</text>
      <sha1>ayk7wxdo5g2dwyo4yyxregw55tpoglq</sha1>
    </revision>
    <revision>
      <id>6195</id>
      <parentid>6194</parentid>
      <timestamp>2026-02-18T21:07:02Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>/* Inkomba  */</comment>
      <origin>6195</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3226" sha1="6m34m5zmptn33s5pjc3xynapox2oy6p" xml:space="preserve">[[Isimumathi:Reverend Jesse Jackson speaking at the UN crop.jpg|thumb|Umfundisi uJesse Jackson akhuluma e UN. ]]
'''U-Jesse Louis Jackson''' ( né '''Burns''' ; mhlana ali-8 kuNobayeni 1941 – mhlana ali-17 kuMhlolanja 2026) bekangumlweli wamalungelo wobuntu we-[[America]], usopolotiki, nomfundisi we-Baptist &lt;ref name=&quot;:0&quot;&gt;https://www.independent.co.uk/news/jesse-jackson-sports-chicago-bulls-indiana-pacers-black-b2923142.html&lt;/ref&gt;. Waba mlawuli ka -[[Martin Luther King Jr.]] no -James Bevel ngesikhathi sokunyakaza kwamalungelo wobuntu, waba ngomunye wabadosiphambili bamalungelo wobuntu abavelele khulu ekupheleni kwekhulu lama-20 nekuthomeni kwekhulu lama-21. Kusukela ngo-1991 ukuya ku-1997, wasebenza njengesithunywa se-shadow ne-shadow senator ye- District of Columbia .&lt;ref&gt;https://www.cbsnews.com/chicago/video/family-speaks-on-life-and-legacy-of-rev-jesse-jackson/&lt;/ref&gt;

Wabelethwa e-[[Greenville]], e-[[South Carolina]], u-Jackson wathoma ukusebenza kwakhe ngeminyaka yabo-1960 begodu wasungula iinhlangano ezahlangana ngokukhamba kwesikhathi ukwakha i-Rainbow/PUSH Coalition. Ukwandisa umsebenzi wakhe eendabeni zamazwe ngamazwe ngabo-1980, waba mgxeki omkhulu wombuso ka-Reagan begodu wathoma umkhankaso wobumongameli ngo-1984.&lt;ref&gt;https://www.12onyourside.com/video/2026/02/18/richmonders-reflect-jesse-jacksons-lasting-impact-community/&lt;/ref&gt; Ekuthomeni bekathathwa njengomuntu ongakakhethwa, waqeda endaweni yesithathu ekuphakanyisweni kwe-Democratic ngemva kwesekela langaphambilini u-Walter Mondale no-Senator u-Gary Hary. Waragela phambili nokulwa kwakhe begodu wafaka umkhankaso wesibili wokuba ngumongameli ngo-1988, waqeda njengomlandeli wesibili kumbusi we-Massachusetts u-Michael Dukakis.&lt;ref&gt;https://www.dailymaverick.co.za/article/2026-02-18-an-extraordinary-american-pilgrimage-jesse-jacksons-final-lap-has-been-run/&lt;/ref&gt;&lt;ref name=&quot;:0&quot; /&gt;[[Isimumathi:The_Student_Government_in_1964_Ayantee.jpg|thumb|U-Jackson (phakathi) namalunga we-Student Government e- North Carolina A&amp;amp;amp;T, c. 1964]]U-Jackson akhenge afune ubumongameli godu, kodwana ngo-1990 wakhethwa njengesenetha ye-District of [[Columbia]], wasebenza isikhathi esisodwa ngesikhathi sokubusa kwaka-Bush no-Clinton. Nanyana ekuthomeni bekasola uMongameli u-Bill Clinton, ngokukhamba kwesikhathi waba msekeli. U-Jackson waba nomsingathi we ''-Both Sides no-Jesse Jackson'' ku -CNN kusukela ngo-1992 ukuya ku-2000. Umgxeki wesihluku samapholisa, i- Republican Party, kanye nemigomo yokulondoloza, bekathathwa njengomunye wabalweli be-Afrika-America abanomthelela khulu ngesikhathi sakhe.

== Ipilo yokuthoma nefundo ==
Njengomntwana, u-Jesse Jackson bekathukwa ngabanye abantwana ngokuzalwa kwakhe ngaphandle komtjhado, begodu wathi amava la amsiza bona aphumelele.   Ukuphila ngaphasi kwemithetho yokuhlukanisa ka -[[Jim Crow]], wafundiswa ukuya ngemva kwebhasi nokusebenzisa imithombo yamanzi ehlukileko—imikhuba ayivumako bekwaba kulapho ibhasi ye-Montgomery ibhoyikatha ngo-1955.  Wafunda esikolweni esihlukaniswe ngokobuhlanga, i-Sterling High School e-Greenville, lapho akhethwa khona njengomengameli, waqeda eklasini lakhe le -10 iincwadi ze-baseball, ibholo yenyawo, nebhola lomnqakiswano. 

== Inkomba  ==
{{reflist}}</text>
      <sha1>6m34m5zmptn33s5pjc3xynapox2oy6p</sha1>
    </revision>
    <revision>
      <id>6196</id>
      <parentid>6195</parentid>
      <timestamp>2026-02-18T21:08:49Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6196</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3300" sha1="lrlfugwb76aya390ckjmnid4yzlqk0e" xml:space="preserve">[[Isimumathi:Reverend Jesse Jackson speaking at the UN crop.jpg|thumb|Umfundisi uJesse Jackson akhuluma e UN. ]]
'''U-Jesse Louis Jackson''' ( né '''Burns''' ; mhlana ali-8 kuNobayeni 1941 – mhlana ali-17 kuMhlolanja 2026) bekangumlweli wamalungelo wobuntu we-[[America]], usopolotiki, nomfundisi we-Baptist &lt;ref name=&quot;:0&quot;&gt;https://www.independent.co.uk/news/jesse-jackson-sports-chicago-bulls-indiana-pacers-black-b2923142.html&lt;/ref&gt;. Waba mlawuli ka -[[Martin Luther King Jr.]] no -James Bevel ngesikhathi sokunyakaza kwamalungelo wobuntu, waba ngomunye wabadosiphambili bamalungelo wobuntu abavelele khulu ekupheleni kwekhulu lama-20 nekuthomeni kwekhulu lama-21. Kusukela ngo-1991 ukuya ku-1997, wasebenza njengesithunywa se-shadow ne-shadow senator ye- District of Columbia .&lt;ref&gt;https://www.cbsnews.com/chicago/video/family-speaks-on-life-and-legacy-of-rev-jesse-jackson/&lt;/ref&gt;

Wabelethwa e-[[Greenville]], e-[[South Carolina]], u-Jackson wathoma ukusebenza kwakhe ngeminyaka yabo-1960 begodu wasungula iinhlangano ezahlangana ngokukhamba kwesikhathi ukwakha i-Rainbow/PUSH Coalition. Ukwandisa umsebenzi wakhe eendabeni zamazwe ngamazwe ngabo-1980, waba mgxeki omkhulu wombuso ka-Reagan begodu wathoma umkhankaso wobumongameli ngo-1984.&lt;ref&gt;https://www.12onyourside.com/video/2026/02/18/richmonders-reflect-jesse-jacksons-lasting-impact-community/&lt;/ref&gt; Ekuthomeni bekathathwa njengomuntu ongakakhethwa, waqeda endaweni yesithathu ekuphakanyisweni kwe-Democratic ngemva kwesekela langaphambilini u-Walter Mondale no-Senator u-Gary Hary. Waragela phambili nokulwa kwakhe begodu wafaka umkhankaso wesibili wokuba ngumongameli ngo-1988, waqeda njengomlandeli wesibili kumbusi we-Massachusetts u-Michael Dukakis.&lt;ref&gt;https://www.dailymaverick.co.za/article/2026-02-18-an-extraordinary-american-pilgrimage-jesse-jacksons-final-lap-has-been-run/&lt;/ref&gt;&lt;ref name=&quot;:0&quot; /&gt;[[Isimumathi:The_Student_Government_in_1964_Ayantee.jpg|thumb|U-Jackson (phakathi) namalunga we-Student Government e- North Carolina A&amp;amp;amp;T, c. 1964]]U-Jackson akhenge afune ubumongameli godu, kodwana ngo-1990 wakhethwa njengesenetha ye-District of [[Columbia]], wasebenza isikhathi esisodwa ngesikhathi sokubusa kwaka-Bush no-Clinton. Nanyana ekuthomeni bekasola uMongameli u-Bill Clinton, ngokukhamba kwesikhathi waba msekeli. U-Jackson waba nomsingathi we ''-Both Sides no-Jesse Jackson'' ku -CNN kusukela ngo-1992 ukuya ku-2000. Umgxeki wesihluku samapholisa, i- Republican Party, kanye nemigomo yokulondoloza, bekathathwa njengomunye wabalweli be-Afrika-America abanomthelela khulu ngesikhathi sakhe.

== Ipilo yokuthoma nefundo ==
Njengomntwana, u-Jesse Jackson bekathukwa ngabanye abantwana ngokuzalwa kwakhe ngaphandle komtjhado, begodu wathi amava la amsiza bona aphumelele.   Ukuphila ngaphasi kwemithetho yokuhlukanisa ka -[[Jim Crow]], wafundiswa ukuya ngemva kwebhasi nokusebenzisa imithombo yamanzi ehlukileko—imikhuba ayivumako bekwaba kulapho ibhasi ye-Montgomery ibhoyikatha ngo-1955.  Wafunda esikolweni esihlukaniswe ngokobuhlanga, i-Sterling High School e-Greenville, lapho akhethwa khona njengomengameli, waqeda eklasini lakhe le -10 iincwadi ze-baseball, ibholo yenyawo, nebhola lomnqakiswano. 

== Inkomba  ==
{{reflist}}
[[Category:Amalungelo oluntu]]
[[Category:iAmerika]]
[[Category:Umlando]]</text>
      <sha1>lrlfugwb76aya390ckjmnid4yzlqk0e</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:IAmerika</title>
    <ns>14</ns>
    <id>1043</id>
    <revision>
      <id>6197</id>
      <timestamp>2026-02-18T21:09:03Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created blank page</comment>
      <origin>6197</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Amalungelo oluntu</title>
    <ns>14</ns>
    <id>1044</id>
    <revision>
      <id>6198</id>
      <timestamp>2026-02-18T21:09:14Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created blank page</comment>
      <origin>6198</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
  </page>
  <page>
    <title>Zozibini Tunzi</title>
    <ns>0</ns>
    <id>1045</id>
    <revision>
      <id>6199</id>
      <timestamp>2026-02-19T00:14:39Z</timestamp>
      <contributor>
        <username>Nhlanhla NaLamula</username>
        <id>1365</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1330756819|Zozibini Tunzi]]&quot;</comment>
      <origin>6199</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6693" sha1="ti70wzepgs80h4ajd015p6cesyhxv9l" xml:space="preserve">

 

'''U-Zozibini &quot;Zozi&quot; Bolowana''' ( '''Tunzi'''; wabelethwa mhlana amalanga ali-18 kuKhukhulamungu 1993) uyimodeli yeSewula Afrika, umlingisi, nomthumbi wephaliswano labonobuhle owabekwa umqhele we -Miss Universe 2019 .  U-Tunzi ngokwaphambili wathweswa umqhele we-Miss South Africa 2019 . Umfazi wesithathu ovela eSewula Afrika begodu wokuthoma onzima weSewula Afrika ukuthumba unongorwana lo. 

== Ipilo yokuthoma ==
U-Tunzi wabelethelwa e -Tsolo, e-Eastern Cape ebabelethini u-Philiswa Nodapu no-Lungisa Tunzi, begodu wakhulela edorobheni eliseduze le-Sidwadweni.   Unina nguhlokokulu wesikolo begodu uyise bekasebenzela umNyango wezeFundo ePhakemeko. U-Tunzi ngomunye wabodadwaboabane.  Abodadwabo babizwa ngokuthi ngu-Yanga, Sibabalwe, no-Ayakha.  Ibizo lakhe u-Zozibini litjho ukuthi ukwamukelwa ngezandla zombili begodu livela kusiXhosa.

Ngokukhamba kwesikhathi wathuthela e -Cape Town, wahlala edorobheni le- Gardens, ukwenzela bona aye e -Cape Peninsula University of Technology . Wathola iziqu zefundo ze- National Diploma yokuphatha ubudlelwano bomphakathi ngo-2018.   Ngo-2017, uTunzi wasebenza njengemodeli begodu wahlala e -East London, e-Eastern Cape . 

Ngaphambi kobana athumbe i-Miss South Africa, u-Tunzi bekaqeda i -Bachelor of Technology ekulawuleni ubudlelwano bomphakathi e-Cape Peninsula University of Technology, begodu bekasebenza njenge-graduate intern emnyangweni wobudlelwano bomphakathi we -Ogilvy Cape Town .  

== Ibizelo ==
U-Tunzi wavela  njengomlingisikokuthoma kufilimu ''i-The Woman King'', eqophiswe ngu -Gina Prince-Bythewood, begodu yakhutjhwa mhlazi-16 kuKhukhulamungu 2022.  Ngo-2024, wasebenzisana nomthengisi weSewula Afrika i-Foschini malungana nebuthelelo labo le-SS24 Spring/Summer. Ibuthelelo lakhe elibizwa ngokuthi 'A Season of Living' litjengisa izinto zefetjhini ezifana namarogo, amarhalasi wamehlo welanga nazo zoke izinto zehlobo. 

== Zabonobuhle ==

=== Miss South Africa 2019 ===
[[Isimumathi:Zozibini_Tunzi_Attending_Puteri_Indonesia_2020_(2).jpg|left|thumb|Umhlangano ka-Tunzi no- Bambang Soesatyo no- Wishnutama Kusubandio e- Jakarta .]]
U-Tunzi wathoma umsebenzi wakhe wokuba kumaphaliswano wabonobuhle ngo-2017, lokha nakamukelwa njengomunye wabonobuhle abaphambili abama-26 be -Miss South Africa 2017 .  Wabuyela ephaliswaneni labonobuhle ukuyokuphalisana ku- Miss South Africa 2019 . Mhlana amalanga ama-26 kuMgwengweni wee-2019, u-Tunzi waqinisekiswa njengomunye wabonobuhle abama-35 abaphumeleleko ephaliswaneni, hlangana neembawo zokuthoma.  Ngemva kokuhlolwa okungezelelweko, uTunzi wamenyezelwa njengomunye wabantu abalitjhumi nasithandathu abafika emaphethelweni mhlana amalanga ali-11 kuVelabahlinze.  

Ngemva kokukhethwa njengomunye wabafikelele emaphethelweni, u-Tunzi waragela phambili nokuphalisanaephaliswaneni le-Miss South Africa 2019 e -Pitori mhlana amalanga ali-9 kuRhoboyi.  Waragela phambili emazingeni wokugcina, wadlulela phambili kwabalitjhumi, bese kwaba phezulu kwabahlanu, begodu ekugcineni waya kwababili abaphambili bekwaba kulapho akhethwa njengomthumbi ngu- Tamaryn Green, ahlula u-Sasha-Lee Olivier.  

Ngemva kokuthumba kwakhe, u-Tunzi wathola imitlomelo efaka hlangana i-R 1 miliyoni, ikoloyi etja, kanye nefuledzi enefenitjhara ezeleko endaweni ye -Sandton e [[Johannesburg|-Jwanasbege]], ebiza i-R5 miliyoni, ukuze ayisebenzise isikhathi soke sokubusa kwakhe.  Ipumelelo le yavumela uTunzi bona ajamele iSewula Afrika ephaliswaneni le-Miss Universe 2019 . 

=== Miss Universe 2019 ===
[[Isimumathi:Raden_Roro_Ayu_Maulida_Putri_With_Zozibini_Tunzi.jpg|right|thumb|U-Tunzi ubeka u- Ayu Maulida njenge -Puteri Indonesia 2020 .]]
U-Tunzi wafika e- Atlanta, e-Georgia nge- Miss Universe 2019 ngoSinyikhaba2019.  Waphalisana ezingeni lo.kuthoma mhlana amalanga asi-6 kuNobayeni, begodu waphalisana ezingeni lokugcina mhlana amalanga abu-8 kuNobayeni e -Tyler Perry Studios . Ngesikhathi sephaliswano, u-Tunzi wadlulela ematjhumini amabili aphezulu njengonobuhle wokuthoma we-semifinalist enarhakazini yesifunda se-Afrika/Asia-Pacific. Wabe sele waya phambili kwabalitjhumi, bese waba kwabahlanu abaphambili, begodu ekugcineni waya kwabathathu bokugcina. Ekupheleni komnyanya, u-Tunzi wabekwa umqhele we-Miss Universe 2019 ngumnikazi u -Catriona Gray we-Philippines, wahlula u- Madison Anderson we-Puerto Rico no- Sofía Aragón we-Mexico.  

Ukuthumba kwaka-Tunzi kusicoco sesithathu seSewula Afrika se-Miss Universe ; Ngumfazi wokuthoma omnyama ukuthumba isicoco se-Miss Universe solo u-Leila Lopes athweswa umqhele we-Miss Universe ngo-2011, begodu ngowokuthoma ukwenza njalo ngeenhluthu ezine-afro .  Ngokunqoba kwakhe, umnyaka ka-2019 waba mnyaka wokuthoma lapho yoke imiqhudelwano emikhulu emine esekelwe e-United States ithunyelwe bafazi abamnyama; abanye abaphethe iinhloko bekungu- Nia Franklin ( u-Miss America 2019 ), u-Kaliegh Garris ( u-Miss Teen USA 2019 ), no -Cheslie Kryst ( u-Miss USA 2019 ).  Phezu kwalokho, umnyaka ka-2019 uzokuba mnyaka wokuthoma lapho abafazi abamnyama banqoba khona imiqhudelwano emibili ehloniphekileko yamazwe ngamazwe ngemva kokuthi u-Toni-Ann Singh we-Jamaica aphumelele u-Miss World 2019 .  

Njengo-Miss Universe, u-Tunzi bekahlala e-New York City, begodu wabamba iqhaza emicimbini eminengi nokuvela ephasini loke.  Ngemva kokuthumba u-Miss Universe, u-Tunzi wathathelwa indawo njengo-Miss South Africa ngu-Sasha-Lee Olivier. 

Esikhundleni sakhe sokuba ngu-Miss Universe, u-Tunzi waya e -Sumba    ne -Jakarta e-Indonesia,   emadorobheni ahlukahlukeneko ngaphakathi kwe-United States  nezwe lakhe leSewula Afrika. 

Ngebanga lomtlhago we-COVID-19, u-Tunzi waba ngumnikazi wesicoco se-Miss Universe isikhathi eside khulu, aphethe isicoco amalanga ama-525 ( 1 umnyaka, 5 iinyanga ezi-8 amalanga ), edlula ukubusa kwaka- Leila Lopes kwamalanga ama-464. Ukubusa kwaka-Tunzi kwaphela mhlana ali-16 kuMrhayili 2021 lokha nakabeka u-Andrea Meza we-Mexico njengomlandeli wakhe e- Seminole Hard Rock Hotel &amp;amp;amp; Casino, e-Hollywood, e-Florida, e-United States. 

== Ipilo yomuntu mathupha ==
U-Tunzi watjhada no-Luthando Bolowana mhlazi-22 kuNtaka 2025 e -Paarl, e-Western Cape .  Umtjhado wabo wesintu wabanjwa mhlazi-29 kuNtaka 2025 e-Sidwadweni, e-Eastern Cape. 

== Ifilimu ==
{| class=&quot;wikitable plainrowheaders sortable&quot; style=&quot;margin-right: 0;&quot;
! scope=&quot;col&quot; |Umnyaka
! scope=&quot;col&quot; | Ithayitlela
! scope=&quot;col&quot; | Indima
! class=&quot;unsortable&quot; scope=&quot;col&quot; | Amanothi
|-
| 2022
| ''Ikosi yomfazi''
| Efe
| Indima yokusekela
|-
| 2025
| ''Umthonya omumbi''
| UNawomi
| Indima eqakatheke khulu
|}

== Impumelelo ==

=== Imiklomelo yamafilimu nethelevishini kaZwelonke ===
 

== Iinkomba ==
{{Reflist}}
[[Mkhakha:Pages with unreviewed translations]]</text>
      <sha1>ti70wzepgs80h4ajd015p6cesyhxv9l</sha1>
    </revision>
    <revision>
      <id>6213</id>
      <parentid>6199</parentid>
      <timestamp>2026-02-19T17:07:42Z</timestamp>
      <contributor>
        <username>Nhlanhla NaLamula</username>
        <id>1365</id>
      </contributor>
      <origin>6213</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6687" sha1="nf0v8igpny4vknmz11qqxxzj67bpson" xml:space="preserve">

 

'''U-Zozibini &quot;Zozi&quot; Bolowana''' ( '''Tunzi'''; wabelethwa mhlana amalanga ali-18 kuKhukhulamungu 1993) uyimodeli yeSewula Afrika, umlingisi, nomthumbi wephaliswano labonobuhle owabekwa umqhele we -Miss Universe 2019 .  U-Tunzi ngokwaphambili wathweswa umqhele we-Miss South Africa 2019 . Umfazi wesithathu ovela eSewula Afrika begodu wokuthoma onzima weSewula Afrika ukuthumba unongorwana lo. 

== Ipilo yokuthoma ==
U-Tunzi wabelethwa e -Tsolo, e-Eastern Cape ebabelethini u-Philiswa Nodapu no-Lungisa Tunzi, begodu wakhulela edorobheni eliseduze le-Sidwadweni.   Unina nguhlokokulu wesikolo begodu uyise bekasebenzela umNyango wezeFundo ePhakemeko. U-Tunzi ngomunye wabodadwabo abane.  Abodadwabo babizwa ngokuthi ngu-Yanga, Sibabalwe, no-Ayakha.  Ibizo lakhe u-Zozibini litjho ukuthi ukwamukelwa ngezandla zombili begodu livela kusiXhosa.

Ngokukhamba kwesikhathi wathuthela e -Cape Town, wahlala edorobheni le- Gardens, ukwenzela bona aye e -Cape Peninsula University of Technology . Wathola iziqu zefundo ze- National Diploma yokuPhatha uBudlelwano boMphakathi ngo-2018.   Ngo-2017, uTunzi wasebenza njengemodeli begodu wahlala e -East London, e-Eastern Cape . 

Ngaphambi kobana athumbe i-Miss South Africa, u-Tunzi bekaqeda i -Bachelor of Technology ekulawuleni ubudlelwano bomphakathi e-Cape Peninsula University of Technology, begodu bekasebenza njenge-graduate intern emNyangweni woBudlelwano boMphakathi we -Ogilvy Cape Town .  

== Ibizelo ==
U-Tunzi wavela  njengomlingisikokuthoma kufilimu ''i-The Woman King'', eqophiswe ngu -Gina Prince-Bythewood, begodu yakhutjhwa mhlazi-16 kuKhukhulamungu 2022.  Ngo-2024, wasebenzisana nomthengisi weSewula Afrika i-Foschini malungana nebuthelelo labo le-SS24 Spring/Summer. Ibuthelelo lakhe elibizwa ngokuthi 'A Season of Living' litjengisa izinto zefetjhini ezifana namarogo, amarhalasi wamehlo welanga nazo zoke izinto zehlobo. 

== Zabonobuhle ==

=== Miss South Africa 2019 ===
[[Isimumathi:Zozibini_Tunzi_Attending_Puteri_Indonesia_2020_(2).jpg|left|thumb|Umhlangano ka-Tunzi no- Bambang Soesatyo no- Wishnutama Kusubandio e- Jakarta .]]
U-Tunzi wathoma umsebenzi wakhe wokuba kumaphaliswano wabonobuhle ngo-2017, lokha nakamukelwa njengomunye wabonobuhle abaphambili abama-26 be -Miss South Africa 2017 .  Wabuyela ephaliswaneni labonobuhle ukuyokuphalisana ku- Miss South Africa 2019 . Mhlana amalanga ama-26 kuMgwengweni wee-2019, u-Tunzi waqinisekiswa njengomunye wabonobuhle abama-35 abaphumeleleko ephaliswaneni, hlangana neembawo zokuthoma.  Ngemva kokuhlolwa okungezelelweko, uTunzi wamenyezelwa njengomunye wabantu abalitjhumi nasithandathu abafika emaphethelweni mhlana amalanga ali-11 kuVelabahlinze.  

Ngemva kokukhethwa njengomunye wabafikelele emaphethelweni, u-Tunzi waragela phambili nokuphalisanaephaliswaneni le-Miss South Africa 2019 e -Pitori mhlana amalanga ali-9 kuRhoboyi.  Waragela phambili emazingeni wokugcina, wadlulela phambili kwabalitjhumi, bese kwaba phezulu kwabahlanu, begodu ekugcineni waya kwababili abaphambili bekwaba kulapho akhethwa njengomthumbi ngu- Tamaryn Green, ahlula u-Sasha-Lee Olivier.  

Ngemva kokuthumba kwakhe, u-Tunzi wathola imitlomelo efaka hlangana i-R 1 miliyoni, ikoloyi etja, kanye nefuledzi enefenitjhara ezeleko endaweni ye -Sandton e [[Johannesburg|-Jwanasbege]], ebiza i-R5 miliyoni, ukuze ayisebenzise isikhathi soke sokubusa kwakhe.  Ipumelelo le yavumela uTunzi bona ajamele iSewula Afrika ephaliswaneni le-Miss Universe 2019 . 

=== Miss Universe 2019 ===
[[Isimumathi:Raden_Roro_Ayu_Maulida_Putri_With_Zozibini_Tunzi.jpg|right|thumb|U-Tunzi ubeka u- Ayu Maulida njenge -Puteri Indonesia 2020 .]]
U-Tunzi wafika e- Atlanta, e-Georgia nge- Miss Universe 2019 ngoSinyikhaba2019.  Waphalisana ezingeni lokuthoma mhlana amalanga asi-6 kuNobayeni, begodu waphalisana ezingeni lokugcina mhlana amalanga abu-8 kuNobayeni e -Tyler Perry Studios . Ngesikhathi sephaliswano, u-Tunzi wadlulela ematjhumini amabili aphezulu njengonobuhle wokuthoma we-semifinalist enarhakazini yesifunda se-Afrika/Asia-Pacific. Wabe sele waya phambili kwabalitjhumi, bese waba kwabahlanu abaphambili, begodu ekugcineni waya kwabathathu bokugcina. Ekupheleni komnyanya, u-Tunzi wabekwa umqhele we-Miss Universe 2019 ngumnikazi u -Catriona Gray we-Philippines, wahlula u- Madison Anderson we-Puerto Rico no- Sofía Aragón we-Mexico.  

Ukuthumba kwaka-Tunzi kusicoco sesithathu seSewula Afrika se-Miss Universe; mfazi wokuthoma onzima ukuthumba isicoco se-Miss Universe solo u-Leila Lopes athweswa umqhele we-Miss Universe ngo-2011, begodu ngowokuthoma ukwenza njalo ngeenhluthu ezine-afro .  Ngokuthumba kwakhe, umnyaka ka-2019 waba mnyaka wokuthoma lapho yoke imiqhudelwano emikhulu emine esekelwe e-United States ithunyelwe bafazi abamnyama; abanye abaphethe iinhloko bekungu- Nia Franklin ( u-Miss America 2019 ), u-Kaliegh Garris ( u-Miss Teen USA 2019 ), no -Cheslie Kryst ( u-Miss USA 2019 ).  Phezu kwalokho, umnyaka ka-2019 uzokuba mnyaka wokuthoma lapho abafazi abamnyama banqoba khona imiqhudelwano emibili ehloniphekileko yamazwe ngamazwe ngemva kokuthi u-Toni-Ann Singh we-Jamaica aphumelele u-Miss World 2019 .  

Njengo-Miss Universe, u-Tunzi bekahlala e-New York City, begodu wabamba iqhaza emicimbini eminengi nokuvela ephasini loke.  Ngemva kokuthumba u-Miss Universe, u-Tunzi wathathelwa indawo njengo-Miss South Africa ngu-Sasha-Lee Olivier. 

Esikhundleni sakhe sokuba ngu-Miss Universe, u-Tunzi waya e -Sumba    ne -Jakarta e-Indonesia,   emadorobheni ahlukahlukeneko ngaphakathi kwe-United States  nezwe lakhe leSewula Afrika. 

Ngebanga lomtlhago we-COVID-19, u-Tunzi waba ngumnikazi wesicoco se-Miss Universe isikhathi eside khulu, aphethe isicoco amalanga ama-525 ( 1 umnyaka, 5 iinyanga ezi-8 amalanga ), edlula ukubusa kwaka- Leila Lopes kwamalanga ama-464. Ukubusa kwaka-Tunzi kwaphela mhlana ali-16 kuMrhayili 2021 lokha nakabeka u-Andrea Meza we-Mexico njengomlandeli wakhe e- Seminole Hard Rock Hotel &amp;amp;amp; Casino, e-Hollywood, e-Florida, e-United States. 

== Ipilo yomuntu mathupha ==
U-Tunzi watjhada no-Luthando Bolowana mhlazi-22 kuNtaka 2025 e -Paarl, e-Western Cape .  Umtjhado wabo wesintu wabanjwa mhlazi-29 kuNtaka 2025 e-Sidwadweni, e-Eastern Cape. 

== Ifilimu ==
{| class=&quot;wikitable plainrowheaders sortable&quot; style=&quot;margin-right: 0;&quot;
! scope=&quot;col&quot; |Umnyaka
! scope=&quot;col&quot; | Ithayitlela
! scope=&quot;col&quot; | Indima
! class=&quot;unsortable&quot; scope=&quot;col&quot; | Amanothi
|-
| 2022
| ''Ikosi yomfazi''
| Efe
| Indima yokusekela
|-
| 2025
| ''Umthonya omumbi''
| UNawomi
| Indima eqakatheke khulu
|}

== Impumelelo ==

=== Imiklomelo yamafilimu nethelevishini kaZwelonke ===
 

== Iinkomba ==
{{Reflist}}
[[Mkhakha:Pages with unreviewed translations]]</text>
      <sha1>nf0v8igpny4vknmz11qqxxzj67bpson</sha1>
    </revision>
    <revision>
      <id>6228</id>
      <parentid>6213</parentid>
      <timestamp>2026-02-20T20:38:05Z</timestamp>
      <contributor>
        <username>Nhlanhla NaLamula</username>
        <id>1365</id>
      </contributor>
      <comment>/* Miss Universe 2019 */</comment>
      <origin>6228</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6720" sha1="jfxfux6urd3waj2n9pam22vxvpwccel" xml:space="preserve">

 

'''U-Zozibini &quot;Zozi&quot; Bolowana''' ( '''Tunzi'''; wabelethwa mhlana amalanga ali-18 kuKhukhulamungu 1993) uyimodeli yeSewula Afrika, umlingisi, nomthumbi wephaliswano labonobuhle owabekwa umqhele we -Miss Universe 2019 .  U-Tunzi ngokwaphambili wathweswa umqhele we-Miss South Africa 2019 . Umfazi wesithathu ovela eSewula Afrika begodu wokuthoma onzima weSewula Afrika ukuthumba unongorwana lo. 

== Ipilo yokuthoma ==
U-Tunzi wabelethwa e -Tsolo, e-Eastern Cape ebabelethini u-Philiswa Nodapu no-Lungisa Tunzi, begodu wakhulela edorobheni eliseduze le-Sidwadweni.   Unina nguhlokokulu wesikolo begodu uyise bekasebenzela umNyango wezeFundo ePhakemeko. U-Tunzi ngomunye wabodadwabo abane.  Abodadwabo babizwa ngokuthi ngu-Yanga, Sibabalwe, no-Ayakha.  Ibizo lakhe u-Zozibini litjho ukuthi ukwamukelwa ngezandla zombili begodu livela kusiXhosa.

Ngokukhamba kwesikhathi wathuthela e -Cape Town, wahlala edorobheni le- Gardens, ukwenzela bona aye e -Cape Peninsula University of Technology . Wathola iziqu zefundo ze- National Diploma yokuPhatha uBudlelwano boMphakathi ngo-2018.   Ngo-2017, uTunzi wasebenza njengemodeli begodu wahlala e -East London, e-Eastern Cape . 

Ngaphambi kobana athumbe i-Miss South Africa, u-Tunzi bekaqeda i -Bachelor of Technology ekulawuleni ubudlelwano bomphakathi e-Cape Peninsula University of Technology, begodu bekasebenza njenge-graduate intern emNyangweni woBudlelwano boMphakathi we -Ogilvy Cape Town .  

== Ibizelo ==
U-Tunzi wavela  njengomlingisikokuthoma kufilimu ''i-The Woman King'', eqophiswe ngu -Gina Prince-Bythewood, begodu yakhutjhwa mhlazi-16 kuKhukhulamungu 2022.  Ngo-2024, wasebenzisana nomthengisi weSewula Afrika i-Foschini malungana nebuthelelo labo le-SS24 Spring/Summer. Ibuthelelo lakhe elibizwa ngokuthi 'A Season of Living' litjengisa izinto zefetjhini ezifana namarogo, amarhalasi wamehlo welanga nazo zoke izinto zehlobo. 

== Zabonobuhle ==

=== Miss South Africa 2019 ===
[[Isimumathi:Zozibini_Tunzi_Attending_Puteri_Indonesia_2020_(2).jpg|left|thumb|Umhlangano ka-Tunzi no- Bambang Soesatyo no- Wishnutama Kusubandio e- Jakarta .]]
U-Tunzi wathoma umsebenzi wakhe wokuba kumaphaliswano wabonobuhle ngo-2017, lokha nakamukelwa njengomunye wabonobuhle abaphambili abama-26 be -Miss South Africa 2017 .  Wabuyela ephaliswaneni labonobuhle ukuyokuphalisana ku- Miss South Africa 2019 . Mhlana amalanga ama-26 kuMgwengweni wee-2019, u-Tunzi waqinisekiswa njengomunye wabonobuhle abama-35 abaphumeleleko ephaliswaneni, hlangana neembawo zokuthoma.  Ngemva kokuhlolwa okungezelelweko, uTunzi wamenyezelwa njengomunye wabantu abalitjhumi nasithandathu abafika emaphethelweni mhlana amalanga ali-11 kuVelabahlinze.  

Ngemva kokukhethwa njengomunye wabafikelele emaphethelweni, u-Tunzi waragela phambili nokuphalisanaephaliswaneni le-Miss South Africa 2019 e -Pitori mhlana amalanga ali-9 kuRhoboyi.  Waragela phambili emazingeni wokugcina, wadlulela phambili kwabalitjhumi, bese kwaba phezulu kwabahlanu, begodu ekugcineni waya kwababili abaphambili bekwaba kulapho akhethwa njengomthumbi ngu- Tamaryn Green, ahlula u-Sasha-Lee Olivier.  

Ngemva kokuthumba kwakhe, u-Tunzi wathola imitlomelo efaka hlangana i-R 1 miliyoni, ikoloyi etja, kanye nefuledzi enefenitjhara ezeleko endaweni ye -Sandton e [[Johannesburg|-Jwanasbege]], ebiza i-R5 miliyoni, ukuze ayisebenzise isikhathi soke sokubusa kwakhe.  Ipumelelo le yavumela uTunzi bona ajamele iSewula Afrika ephaliswaneni le-Miss Universe 2019 . 

=== Miss Universe 2019 ===
[[Isimumathi:Raden_Roro_Ayu_Maulida_Putri_With_Zozibini_Tunzi.jpg|right|thumb|U-Tunzi ubeka u- Ayu Maulida njenge -Puteri Indonesia 2020 .]]
U-Tunzi wafika e- Atlanta, e-Georgia nge- Miss Universe 2019 ngoSinyikhaba2019.  Waphalisana ezingeni lokuthoma mhlana amalanga asi-6 kuNobayeni, begodu waphalisana ezingeni lokugcina mhlana amalanga abu-8 kuNobayeni e -Tyler Perry Studios . Ngesikhathi sephaliswano, u-Tunzi wadlulela ematjhumini amabili aphezulu njengonobuhle wokuthoma we-semifinalist enarhakazini yesifunda se-Afrika/Asia-Pacific. Wabe sele waya phambili kwabalitjhumi, bese waba kwabahlanu abaphambili, begodu ekugcineni waya kwabathathu bokugcina. Ekupheleni komnyanya, u-Tunzi wabekwa umqhele we-Miss Universe 2019 ngumnikazi u -Catriona Gray we-Philippines, wahlula u- Madison Anderson we-Puerto Rico no- Sofía Aragón we-Mexico.  

Ukuthumba kwaka-Tunzi kusicoco sesithathu seSewula Afrika se-Miss Universe; mfazi wokuthoma onzima ukuthumba isicoco se-Miss Universe solo u-Leila Lopes athweswa umqhele we-Miss Universe ngo-2011, begodu ngowokuthoma ukwenza njalo ngeenhluthu ezine-afro .  Ngokuthumba kwakhe, umnyaka ka-2019 waba mnyaka wokuthoma lapho woke amaphaliswano amakhulu amane asekelwe e-United States ithunyelwe bafazi abanzima; abanye abaphethe iinhloko bekungu- Nia Franklin ( u-Miss America 2019 ), u-Kaliegh Garris ( u-Miss Teen USA 2019 ), no -Cheslie Kryst ( u-Miss USA 2019 ).  Phezu kwalokho, umnyaka ka-2019 uzokuba mnyaka wokuthoma lapho abafazi abanzima bathumba khona amaphalislwano amabili ahloniphekileko wamazwe ngamazwe ngemva kokuthi u-Toni-Ann Singh we-Jamaica aphumelele u-Miss World 2019 .  

Njengo-Miss Universe, u-Tunzi bekahlala e-New York City, begodu wadlala indima eminyanyeni eminengi nokuvela ephasini loke.  Ngemva kokuthumba u-Miss Universe, u-Tunzi wathathelwa indawo njengo-Miss South Africa ngu-Sasha-Lee Olivier. 

Esikhundleni sakhe sokuba ngu-Miss Universe, u-Tunzi waya e -Sumba ne-Jakarta e-Indonesia,  emadorobheni ahlukahlukeneko ngaphakathi kwe-United States nezwe lakhe leSewula Afrika. 

Ngebanga lomtlhago we-COVID-19, u-Tunzi waba ngumnikazi wesicoco se-Miss Universe isikhathi eside khulu, aphethe isicoco amalanga ama-525 (1 umnyaka, 5 iinyanga ezi-8 amalanga ), adlula ukubusa kwaka- Leila Lopes kwamalanga ama-464. Ukubusa kwaka-Tunzi kwaphela mhlana amalanɡa ali-16 kuMrhayili 2021 lokha nakabeka u-Andrea Meza we-Mexico njengomlandeli wakhe e- Seminole Hard Rock Hotel &amp;amp;amp; Casino, e-Hollywood, e-Florida, e-United States. 

== Ipilo yomuntu mathupha ==
U-Tunzi watjhada no-Luthando Bolowana mhlana amalanɡana ama-22 kuNtaka 2025 e -Paarl, e-Western Cape .  Umtjhado wabo wesintu wabanjwa mhlana malanɡa ama-29 kuNtaka 2025 e-Sidwadweni, e-Eastern Cape. 

== Ifilimu ==
{| class=&quot;wikitable plainrowheaders sortable&quot; style=&quot;margin-right: 0;&quot;
! scope=&quot;col&quot; |Umnyaka
! scope=&quot;col&quot; | Ithayitlela
! scope=&quot;col&quot; | Indima
! class=&quot;unsortable&quot; scope=&quot;col&quot; | Amanothi
|-
| 2022
| ''Ikosi yomfazi''
| Efe
| Indima yokusekela
|-
| 2025
| ''Umthonya omumbi''
| UNawomi
| Indima eqakatheke khulu
|}

== Impumelelo ==

=== Imiklomelo yamafilimu nethelevishini kaZwelonke ===
 

== Iinkomba ==
{{Reflist}}
[[Mkhakha:Pages with unreviewed translations]]</text>
      <sha1>jfxfux6urd3waj2n9pam22vxvpwccel</sha1>
    </revision>
    <revision>
      <id>6233</id>
      <parentid>6228</parentid>
      <timestamp>2026-02-24T16:58:41Z</timestamp>
      <contributor>
        <username>Nhlanhla NaLamula</username>
        <id>1365</id>
      </contributor>
      <minor />
      <origin>6233</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6719" sha1="2hbedjcyhmt93b1iju48kzfigna9j9j" xml:space="preserve">

 

'''U-Zozibini &quot;Zozi&quot; Bolowana''' ( '''Tunzi'''; wabelethwa mhlana amalanga ali-18 kuKhukhulamungu 1993) uyimodeli yeSewula Afrika, umlingisi, nomthumbi wephaliswano labonobuhle owabekwa umqhele we -Miss Universe 2019 .  U-Tunzi ngokwaphambili wathweswa umqhele we-Miss South Africa 2019 . Umfazi wesithathu ovela eSewula Afrika begodu wokuthoma onzima weSewula Afrika ukuthumba unongorwana lo. 

== Ipilo yokuthoma ==
U-Tunzi wabelethwa e-Tsolo, e-Eastern Cape ebabelethini u-Philiswa Nodapu no-Lungisa Tunzi, begodu wakhulela edorobheni eliseduze le-Sidwadweni.   Unina nguhlokokulu wesikolo begodu uyise bekasebenzela umNyango wezeFundo ePhakemeko. U-Tunzi ngomunye wabodadwabo abane.  Abodadwabo babizwa ngokuthi ngu-Yanga, Sibabalwe, no-Ayakha.  Ibizo lakhe u-Zozibini litjho ukuthi ukwamukelwa ngezandla zombili begodu livela kusiXhosa.

Ngokukhamba kwesikhathi wathuthela e -Cape Town, wahlala edorobheni le- Gardens, ukwenzela bona aye e -Cape Peninsula University of Technology . Wathola iziqu zefundo ze- National Diploma yokuPhatha uBudlelwano boMphakathi ngo-2018.   Ngo-2017, uTunzi wasebenza njengemodeli begodu wahlala e -East London, e-Eastern Cape . 

Ngaphambi kobana athumbe i-Miss South Africa, u-Tunzi bekaqeda i -Bachelor of Technology ekulawuleni ubudlelwano bomphakathi e-Cape Peninsula University of Technology, begodu bekasebenza njenge-graduate intern emNyangweni woBudlelwano boMphakathi we -Ogilvy Cape Town .  

== Ibizelo ==
U-Tunzi wavela  njengomlingisikokuthoma kufilimu ''i-The Woman King'', eqophiswe ngu -Gina Prince-Bythewood, begodu yakhutjhwa mhlazi-16 kuKhukhulamungu 2022.  Ngo-2024, wasebenzisana nomthengisi weSewula Afrika i-Foschini malungana nebuthelelo labo le-SS24 Spring/Summer. Ibuthelelo lakhe elibizwa ngokuthi 'A Season of Living' litjengisa izinto zefetjhini ezifana namarogo, amarhalasi wamehlo welanga nazo zoke izinto zehlobo. 

== Zabonobuhle ==

=== Miss South Africa 2019 ===
[[Isimumathi:Zozibini_Tunzi_Attending_Puteri_Indonesia_2020_(2).jpg|left|thumb|Umhlangano ka-Tunzi no- Bambang Soesatyo no- Wishnutama Kusubandio e- Jakarta .]]
U-Tunzi wathoma umsebenzi wakhe wokuba kumaphaliswano wabonobuhle ngo-2017, lokha nakamukelwa njengomunye wabonobuhle abaphambili abama-26 be -Miss South Africa 2017 .  Wabuyela ephaliswaneni labonobuhle ukuyokuphalisana ku- Miss South Africa 2019 . Mhlana amalanga ama-26 kuMgwengweni wee-2019, u-Tunzi waqinisekiswa njengomunye wabonobuhle abama-35 abaphumeleleko ephaliswaneni, hlangana neembawo zokuthoma.  Ngemva kokuhlolwa okungezelelweko, uTunzi wamenyezelwa njengomunye wabantu abalitjhumi nasithandathu abafika emaphethelweni mhlana amalanga ali-11 kuVelabahlinze.  

Ngemva kokukhethwa njengomunye wabafikelele emaphethelweni, u-Tunzi waragela phambili nokuphalisanaephaliswaneni le-Miss South Africa 2019 e -Pitori mhlana amalanga ali-9 kuRhoboyi.  Waragela phambili emazingeni wokugcina, wadlulela phambili kwabalitjhumi, bese kwaba phezulu kwabahlanu, begodu ekugcineni waya kwababili abaphambili bekwaba kulapho akhethwa njengomthumbi ngu- Tamaryn Green, ahlula u-Sasha-Lee Olivier.  

Ngemva kokuthumba kwakhe, u-Tunzi wathola imitlomelo efaka hlangana i-R 1 miliyoni, ikoloyi etja, kanye nefuledzi enefenitjhara ezeleko endaweni ye -Sandton e [[Johannesburg|-Jwanasbege]], ebiza i-R5 miliyoni, ukuze ayisebenzise isikhathi soke sokubusa kwakhe.  Ipumelelo le yavumela uTunzi bona ajamele iSewula Afrika ephaliswaneni le-Miss Universe 2019 . 

=== Miss Universe 2019 ===
[[Isimumathi:Raden_Roro_Ayu_Maulida_Putri_With_Zozibini_Tunzi.jpg|right|thumb|U-Tunzi ubeka u- Ayu Maulida njenge -Puteri Indonesia 2020 .]]
U-Tunzi wafika e- Atlanta, e-Georgia nge- Miss Universe 2019 ngoSinyikhaba2019.  Waphalisana ezingeni lokuthoma mhlana amalanga asi-6 kuNobayeni, begodu waphalisana ezingeni lokugcina mhlana amalanga abu-8 kuNobayeni e -Tyler Perry Studios . Ngesikhathi sephaliswano, u-Tunzi wadlulela ematjhumini amabili aphezulu njengonobuhle wokuthoma we-semifinalist enarhakazini yesifunda se-Afrika/Asia-Pacific. Wabe sele waya phambili kwabalitjhumi, bese waba kwabahlanu abaphambili, begodu ekugcineni waya kwabathathu bokugcina. Ekupheleni komnyanya, u-Tunzi wabekwa umqhele we-Miss Universe 2019 ngumnikazi u -Catriona Gray we-Philippines, wahlula u- Madison Anderson we-Puerto Rico no- Sofía Aragón we-Mexico.  

Ukuthumba kwaka-Tunzi kusicoco sesithathu seSewula Afrika se-Miss Universe; mfazi wokuthoma onzima ukuthumba isicoco se-Miss Universe solo u-Leila Lopes athweswa umqhele we-Miss Universe ngo-2011, begodu ngowokuthoma ukwenza njalo ngeenhluthu ezine-afro .  Ngokuthumba kwakhe, unyaka ka-2019 wabanɡunyaka wokuthoma lapho woke amaphaliswano amakhulu amane asekelwe e-United States athunyelwa abafazi abanzima; abanye ababethe iinhloko bekungu- Nia Franklin ( u-Miss America 2019 ), u-Kaliegh Garris ( u-Miss Teen USA 2019 ), no -Cheslie Kryst ( u-Miss USA 2019 ).  Phezu kwalokho, unyaka ka-2019 uzokubanɡunyaka wokuthoma lapho abafazi abanzima bathumba khona amaphalislwano amabili ahloniphekileko wamazwe ngamazwe ngemva kokuthi u-Toni-Ann Singh we-Jamaica aphumelele u-Miss World 2019 .  

Njengo-Miss Universe, u-Tunzi bekahlala e-New York City, begodu wadlala indima eminyanyeni eminengi nokuvela ephasini loke.  Ngemva kokuthumba u-Miss Universe, u-Tunzi wathathelwa indawo njengo-Miss South Africa ngu-Sasha-Lee Olivier. 

Esikhundleni sakhe sokuba ngu-Miss Universe, u-Tunzi waya e-Sumba ne-Jakarta e-Indonesia,  emadorobheni ahlukahlukeneko ngaphakathi kwe-United States nezwe lakhe leSewula Afrika. 

Ngebanga lomtlhago we-COVID-19, u-Tunzi waba ngumnikazi wesicoco se-Miss Universe isikhathi eside khulu, aphethe isicoco amalanga ama-525 (1 unyaka, 5 iinyanga ezi-8 amalanga ), adlula ukubusa kwaka-Leila Lopes kwamalanga ama-464. Ukubusa kwaka-Tunzi kwaphela mhlana amalanɡa ali-16 kuMrhayili 2021 lokha nakabeka u-Andrea Meza we-Mexico njengomlandeli wakhe e- Seminole Hard Rock Hotel &amp;amp; amp; Casino, e-Hollywood, e-Florida, e-United States. 

== Ipilo yomuntu mathupha ==
U-Tunzi watjhada no-Luthando Bolowana mhlana amalanɡana ama-22 kuNtaka 2025 e -Paarl, e-Western Cape .  Umtjhado wabo wesintu wabanjwa mhlana malanɡa ama-29 kuNtaka 2025 e-Sidwadweni, e-Eastern Cape. 

== Ifilimu ==
{| class=&quot;wikitable plainrowheaders sortable&quot; style=&quot;margin-right: 0;&quot;
! scope=&quot;col&quot; |Umnyaka
! scope=&quot;col&quot; | Ithayitlela
! scope=&quot;col&quot; | Indima
! class=&quot;unsortable&quot; scope=&quot;col&quot; | Amanothi
|-
| 2022
| ''Ikosi yomfazi''
| Efe
| Indima yokusekela
|-
| 2025
| ''Umthonya omumbi''
| UNawomi
| Indima eqakatheke khulu
|}

== Impumelelo ==

=== Imiklomelo yamafilimu nethelevishini kaZwelonke ===
 

== Iinkomba ==
{{Reflist}}
[[Mkhakha:Pages with unreviewed translations]]</text>
      <sha1>2hbedjcyhmt93b1iju48kzfigna9j9j</sha1>
    </revision>
  </page>
  <page>
    <title>U-Martin Luther King Jr.</title>
    <ns>0</ns>
    <id>1046</id>
    <revision>
      <id>6200</id>
      <timestamp>2026-02-19T06:41:21Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1338491862|Martin Luther King Jr.]]&quot;</comment>
      <origin>6200</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3636" sha1="4x10y6tbvonsv0xgqo599zfxwfonzy9" xml:space="preserve">'''U-Martin Luther King Jr.''' (u- '''Michael King Jr.''' ; mhlana ali-15 kuTjhirhweni 1929&amp;nbsp;– mhlana ali-4 kuMrhayili 1968) bekangumlweli wamalungelo wobuntu we-[[IAmerica|America]] nomfundisi we -Baptist obekangumdosiphambili wehlangano yamalungelo wobuntu kusukela ngo-1955 bekwaba kulapho abulawa khona ngo-1968. Wathuthukisa amalungelo wobuntu wabantu bemibala e-United States ngokusebenzisa ukujamelana okunganabudlova nokungalaleli komphakathi ngokujamelana nemithetho ka-Jim Crow neminye imihlobo yokubandlulula esemthethweni, ebegade ithinteka khulu Ama-Afrika aseMelika .

Umdosiphambili webandla elimnyama, u-King wahlanganyela begodu wadosa phambili ematjhini wokufuna ilungelo lokuvowuda, ukuhlukaniswa, amalungelo wabasebenzi, namanye amalungelo womphakathi.[1] Waphatha ukudliwa kwamabhasi we-Montgomery ngo-1955 begodu waba ngumongameli wokuthoma we-Southern Christian Leadership Conference (SCLC), arhola i-Albany Movement engaphumeleliko e-Albany, Georgia, begodu wasiza ukuhlela imibhikisho enganabudlova yango-1963 e-Birmingham, Alabama. U-King bekamunye wabadosiphambili be-1963 March e-Washington, lapho anikela khona ikulumo yakhe ethi &quot;Nginephupho&quot;, begodu wasiza ukuhlela ama-match amabili kwamathathu we-Selma ukuya e-Montgomery ngesikhathi se-1965 Selma voting rights movement. Kwaba nokujamelana okukhulu nabaphathi abahlukanisako, ebegade baphendula ngolaka.[2] Umkhankaso wamalungelo wobuntu wazuza iinzuzo eziqakathekileko zomthetho emThethweni wamaLungelo woMphakathi ka-1964, umThetho wamaLungelo wokuVowuda ka-1965, kanye nomThetho weZindlu eziLungileko ka-1968.


U-King wavalelwa ejele kanengi. Umnqophisi we -Federal Bureau of Investigation (FBI) u-J. Edgar Hoover wathatha u-King njengomuntu oqakatheke khulu begodu wamenza waba yinto ye- COINTELPRO kusukela ngo-1963. Ama-ejenti we-FBI amphenyisisa bona angaba nobudlelwano bamakhomanisi, ahlola ipilo yakhe, begodu amrekhoda ngasese. Ngo-1964, i-FBI yathumela u-King incwadi ethusako engaziwako, ayihlathulula njengomzamo wokwenza bona azibulale.  U-King wathumba umvuzo we-Nobel Peace Prize ngo-1964 ngokulwisana nokungalingani ngokobuhlanga ngokusebenzisa ukujamelana okunganadlakela. Eminyakeni yakhe yokugcina, wandisa ukutjheja kwakhe ukufaka hlangana ukuphikiswa kobuphofu nePi ye-Vietnam .

== Ipilo yokuthoma nefundo ==

=== Ukubelethwa ===
U-Michael King Jr. wabelethwa mhlazi-15 kuTjhirhweni 1929, e- Atlanta, ngowesibili ebantwaneni abathathu baka- Michael King no -Alberta King ( née Williams ).  &lt;ref name=&quot;bf&quot; /&gt; &lt;ref name=&quot;bio&quot; /&gt; Ubaba ka-Alberta, u-Adam Daniel Williams,  bekangumfundisi we -Georgia emaphandleni, wathuthela e-Atlanta ngo-1893,  begodu waba mfundisi we- Ebenezer Baptist Church ngomnyaka olandelako. [ 8 ] U-Williams watjhada no-Jennie Celeste Parks. &lt;ref name=&quot;bio&quot; /&gt; U-Michael Sr. wabelethwa babantu abahlanganyela abalimi u-James Albert no-Delia King be- Stockbridge, e-Georgia ;  &lt;ref name=&quot;bio&quot; /&gt; kungenzeka bona bekavela ku -Mende ( Sierra Leone ).    Wabhalisa e- Morehouse College ukufunda ukungena emsebenzini. [ 12 ] U-Michael Sr. no-Alberta bathoma ukuthandana ngo-1920, begodu batjhada mhlazi-25 kuNobayeni 1926. [ 13 ] [ 14 ] Bekube sekufeni kwaka-Jennie ngo-1941, ikhaya labo belisesitezi sesibili sekhaya lababelethi baka-Alberta, lapho u-King abelethelwa khona. [ 15 ] [ 13 ] [ 14 ] [ 16 ] U-Michael Jr. bekanodadewabo omdala, u-Christine King Farris, nomfowabo omncani, u-Alfred Daniel King . [ 17 ]
[[Isimumathi:Booker_T._Washington_High_School_in_Atlanta.jpg|thumb|Isikolo samabanga aphezulu uKing afunda kiso sathiywa ngegama lomfundisi we-Afrika-American u-Booker T. Washington .]]</text>
      <sha1>4x10y6tbvonsv0xgqo599zfxwfonzy9</sha1>
    </revision>
    <revision>
      <id>6201</id>
      <parentid>6200</parentid>
      <timestamp>2026-02-19T06:42:51Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6201</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3784" sha1="lh6x7fjp9axjjgf43oipmt5jp1k6fqj" xml:space="preserve">[[Isimumathi:Martin Luther King Jr. - I Have A Dream Speech.jpg|thumb|uMartin Luther King Jr enikeza inkulumo aduma ngayo &quot;I have a Dream Speech&quot;]]
'''U-Martin Luther King Jr.''' (u- '''Michael King Jr.''' ; mhlana ali-15 kuTjhirhweni 1929&amp;nbsp;– mhlana ali-4 kuMrhayili 1968) bekangumlweli wamalungelo wobuntu we-[[IAmerica|America]] nomfundisi we -Baptist obekangumdosiphambili wehlangano yamalungelo wobuntu kusukela ngo-1955 bekwaba kulapho abulawa khona ngo-1968. Wathuthukisa amalungelo wobuntu wabantu bemibala e-United States ngokusebenzisa ukujamelana okunganabudlova nokungalaleli komphakathi ngokujamelana nemithetho ka-Jim Crow neminye imihlobo yokubandlulula esemthethweni, ebegade ithinteka khulu Ama-Afrika aseMelika .

Umdosiphambili webandla elimnyama, u-King wahlanganyela begodu wadosa phambili ematjhini wokufuna ilungelo lokuvowuda, ukuhlukaniswa, amalungelo wabasebenzi, namanye amalungelo womphakathi.[1] Waphatha ukudliwa kwamabhasi we-Montgomery ngo-1955 begodu waba ngumongameli wokuthoma we-Southern Christian Leadership Conference (SCLC), arhola i-Albany Movement engaphumeleliko e-Albany, Georgia, begodu wasiza ukuhlela imibhikisho enganabudlova yango-1963 e-Birmingham, Alabama. U-King bekamunye wabadosiphambili be-1963 March e-Washington, lapho anikela khona ikulumo yakhe ethi &quot;Nginephupho&quot;, begodu wasiza ukuhlela ama-match amabili kwamathathu we-Selma ukuya e-Montgomery ngesikhathi se-1965 Selma voting rights movement. Kwaba nokujamelana okukhulu nabaphathi abahlukanisako, ebegade baphendula ngolaka.[2] Umkhankaso wamalungelo wobuntu wazuza iinzuzo eziqakathekileko zomthetho emThethweni wamaLungelo woMphakathi ka-1964, umThetho wamaLungelo wokuVowuda ka-1965, kanye nomThetho weZindlu eziLungileko ka-1968.


U-King wavalelwa ejele kanengi. Umnqophisi we -Federal Bureau of Investigation (FBI) u-J. Edgar Hoover wathatha u-King njengomuntu oqakatheke khulu begodu wamenza waba yinto ye- COINTELPRO kusukela ngo-1963. Ama-ejenti we-FBI amphenyisisa bona angaba nobudlelwano bamakhomanisi, ahlola ipilo yakhe, begodu amrekhoda ngasese. Ngo-1964, i-FBI yathumela u-King incwadi ethusako engaziwako, ayihlathulula njengomzamo wokwenza bona azibulale.  U-King wathumba umvuzo we-Nobel Peace Prize ngo-1964 ngokulwisana nokungalingani ngokobuhlanga ngokusebenzisa ukujamelana okunganadlakela. Eminyakeni yakhe yokugcina, wandisa ukutjheja kwakhe ukufaka hlangana ukuphikiswa kobuphofu nePi ye-Vietnam .

== Ipilo yokuthoma nefundo ==

=== Ukubelethwa ===
U-Michael King Jr. wabelethwa mhlazi-15 kuTjhirhweni 1929, e- Atlanta, ngowesibili ebantwaneni abathathu baka- Michael King no -Alberta King ( née Williams ).  &lt;ref name=&quot;bf&quot; /&gt; &lt;ref name=&quot;bio&quot; /&gt; Ubaba ka-Alberta, u-Adam Daniel Williams,  bekangumfundisi we -Georgia emaphandleni, wathuthela e-Atlanta ngo-1893,  begodu waba mfundisi we- Ebenezer Baptist Church ngomnyaka olandelako. [ 8 ] U-Williams watjhada no-Jennie Celeste Parks. &lt;ref name=&quot;bio&quot; /&gt; U-Michael Sr. wabelethwa babantu abahlanganyela abalimi u-James Albert no-Delia King be- Stockbridge, e-Georgia ;  &lt;ref name=&quot;bio&quot; /&gt; kungenzeka bona bekavela ku -Mende ( Sierra Leone ).    Wabhalisa e- Morehouse College ukufunda ukungena emsebenzini. [ 12 ] U-Michael Sr. no-Alberta bathoma ukuthandana ngo-1920, begodu batjhada mhlazi-25 kuNobayeni 1926. [ 13 ] [ 14 ] Bekube sekufeni kwaka-Jennie ngo-1941, ikhaya labo belisesitezi sesibili sekhaya lababelethi baka-Alberta, lapho u-King abelethelwa khona. [ 15 ] [ 13 ] [ 14 ] [ 16 ] U-Michael Jr. bekanodadewabo omdala, u-Christine King Farris, nomfowabo omncani, u-Alfred Daniel King . [ 17 ]
[[Isimumathi:Booker_T._Washington_High_School_in_Atlanta.jpg|thumb|Isikolo samabanga aphezulu uKing afunda kiso sathiywa ngegama lomfundisi we-Afrika-American u-Booker T. Washington .]]</text>
      <sha1>lh6x7fjp9axjjgf43oipmt5jp1k6fqj</sha1>
    </revision>
    <revision>
      <id>6202</id>
      <parentid>6201</parentid>
      <timestamp>2026-02-19T06:43:34Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6202</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3794" sha1="kaolmjaqqi7w0uivr4uuk124y8flt2w" xml:space="preserve">[[Isimumathi:Martin Luther King Jr. - I Have A Dream Speech.jpg|thumb|uMartin Luther King Jr enikeza inkulumo aduma ngayo &quot;I have a Dream Speech&quot;|450x450px]]
'''U-Martin Luther King Jr.''' (u- '''Michael King Jr.''' ; mhlana ali-15 kuTjhirhweni 1929&amp;nbsp;– mhlana ali-4 kuMrhayili 1968) bekangumlweli wamalungelo wobuntu we-[[IAmerica|America]] nomfundisi we -Baptist obekangumdosiphambili wehlangano yamalungelo wobuntu kusukela ngo-1955 bekwaba kulapho abulawa khona ngo-1968. Wathuthukisa amalungelo wobuntu wabantu bemibala e-United States ngokusebenzisa ukujamelana okunganabudlova nokungalaleli komphakathi ngokujamelana nemithetho ka-Jim Crow neminye imihlobo yokubandlulula esemthethweni, ebegade ithinteka khulu Ama-Afrika aseMelika .

Umdosiphambili webandla elimnyama, u-King wahlanganyela begodu wadosa phambili ematjhini wokufuna ilungelo lokuvowuda, ukuhlukaniswa, amalungelo wabasebenzi, namanye amalungelo womphakathi.[1] Waphatha ukudliwa kwamabhasi we-Montgomery ngo-1955 begodu waba ngumongameli wokuthoma we-Southern Christian Leadership Conference (SCLC), arhola i-Albany Movement engaphumeleliko e-Albany, Georgia, begodu wasiza ukuhlela imibhikisho enganabudlova yango-1963 e-Birmingham, Alabama. U-King bekamunye wabadosiphambili be-1963 March e-Washington, lapho anikela khona ikulumo yakhe ethi &quot;Nginephupho&quot;, begodu wasiza ukuhlela ama-match amabili kwamathathu we-Selma ukuya e-Montgomery ngesikhathi se-1965 Selma voting rights movement. Kwaba nokujamelana okukhulu nabaphathi abahlukanisako, ebegade baphendula ngolaka.[2] Umkhankaso wamalungelo wobuntu wazuza iinzuzo eziqakathekileko zomthetho emThethweni wamaLungelo woMphakathi ka-1964, umThetho wamaLungelo wokuVowuda ka-1965, kanye nomThetho weZindlu eziLungileko ka-1968.


U-King wavalelwa ejele kanengi. Umnqophisi we -Federal Bureau of Investigation (FBI) u-J. Edgar Hoover wathatha u-King njengomuntu oqakatheke khulu begodu wamenza waba yinto ye- COINTELPRO kusukela ngo-1963. Ama-ejenti we-FBI amphenyisisa bona angaba nobudlelwano bamakhomanisi, ahlola ipilo yakhe, begodu amrekhoda ngasese. Ngo-1964, i-FBI yathumela u-King incwadi ethusako engaziwako, ayihlathulula njengomzamo wokwenza bona azibulale.  U-King wathumba umvuzo we-Nobel Peace Prize ngo-1964 ngokulwisana nokungalingani ngokobuhlanga ngokusebenzisa ukujamelana okunganadlakela. Eminyakeni yakhe yokugcina, wandisa ukutjheja kwakhe ukufaka hlangana ukuphikiswa kobuphofu nePi ye-Vietnam .

== Ipilo yokuthoma nefundo ==

=== Ukubelethwa ===
U-Michael King Jr. wabelethwa mhlazi-15 kuTjhirhweni 1929, e- Atlanta, ngowesibili ebantwaneni abathathu baka- Michael King no -Alberta King ( née Williams ).  &lt;ref name=&quot;bf&quot; /&gt; &lt;ref name=&quot;bio&quot; /&gt; Ubaba ka-Alberta, u-Adam Daniel Williams,  bekangumfundisi we -Georgia emaphandleni, wathuthela e-Atlanta ngo-1893,  begodu waba mfundisi we- Ebenezer Baptist Church ngomnyaka olandelako. [ 8 ] U-Williams watjhada no-Jennie Celeste Parks. &lt;ref name=&quot;bio&quot; /&gt; U-Michael Sr. wabelethwa babantu abahlanganyela abalimi u-James Albert no-Delia King be- Stockbridge, e-Georgia ;  &lt;ref name=&quot;bio&quot; /&gt; kungenzeka bona bekavela ku -Mende ( Sierra Leone ).    Wabhalisa e- Morehouse College ukufunda ukungena emsebenzini. [ 12 ] U-Michael Sr. no-Alberta bathoma ukuthandana ngo-1920, begodu batjhada mhlazi-25 kuNobayeni 1926. [ 13 ] [ 14 ] Bekube sekufeni kwaka-Jennie ngo-1941, ikhaya labo belisesitezi sesibili sekhaya lababelethi baka-Alberta, lapho u-King abelethelwa khona. [ 15 ] [ 13 ] [ 14 ] [ 16 ] U-Michael Jr. bekanodadewabo omdala, u-Christine King Farris, nomfowabo omncani, u-Alfred Daniel King . [ 17 ]
[[Isimumathi:Booker_T._Washington_High_School_in_Atlanta.jpg|thumb|Isikolo samabanga aphezulu uKing afunda kiso sathiywa ngegama lomfundisi we-Afrika-American u-Booker T. Washington .]]</text>
      <sha1>kaolmjaqqi7w0uivr4uuk124y8flt2w</sha1>
    </revision>
    <revision>
      <id>6203</id>
      <parentid>6202</parentid>
      <timestamp>2026-02-19T06:44:17Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>/* Ipilo yokuthoma nefundo */</comment>
      <origin>6203</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3823" sha1="tby0pqotucien1s9m14wft7i67nlx2n" xml:space="preserve">[[Isimumathi:Martin Luther King Jr. - I Have A Dream Speech.jpg|thumb|uMartin Luther King Jr enikeza inkulumo aduma ngayo &quot;I have a Dream Speech&quot;|450x450px]]
'''U-Martin Luther King Jr.''' (u- '''Michael King Jr.''' ; mhlana ali-15 kuTjhirhweni 1929&amp;nbsp;– mhlana ali-4 kuMrhayili 1968) bekangumlweli wamalungelo wobuntu we-[[IAmerica|America]] nomfundisi we -Baptist obekangumdosiphambili wehlangano yamalungelo wobuntu kusukela ngo-1955 bekwaba kulapho abulawa khona ngo-1968. Wathuthukisa amalungelo wobuntu wabantu bemibala e-United States ngokusebenzisa ukujamelana okunganabudlova nokungalaleli komphakathi ngokujamelana nemithetho ka-Jim Crow neminye imihlobo yokubandlulula esemthethweni, ebegade ithinteka khulu Ama-Afrika aseMelika .

Umdosiphambili webandla elimnyama, u-King wahlanganyela begodu wadosa phambili ematjhini wokufuna ilungelo lokuvowuda, ukuhlukaniswa, amalungelo wabasebenzi, namanye amalungelo womphakathi.[1] Waphatha ukudliwa kwamabhasi we-Montgomery ngo-1955 begodu waba ngumongameli wokuthoma we-Southern Christian Leadership Conference (SCLC), arhola i-Albany Movement engaphumeleliko e-Albany, Georgia, begodu wasiza ukuhlela imibhikisho enganabudlova yango-1963 e-Birmingham, Alabama. U-King bekamunye wabadosiphambili be-1963 March e-Washington, lapho anikela khona ikulumo yakhe ethi &quot;Nginephupho&quot;, begodu wasiza ukuhlela ama-match amabili kwamathathu we-Selma ukuya e-Montgomery ngesikhathi se-1965 Selma voting rights movement. Kwaba nokujamelana okukhulu nabaphathi abahlukanisako, ebegade baphendula ngolaka.[2] Umkhankaso wamalungelo wobuntu wazuza iinzuzo eziqakathekileko zomthetho emThethweni wamaLungelo woMphakathi ka-1964, umThetho wamaLungelo wokuVowuda ka-1965, kanye nomThetho weZindlu eziLungileko ka-1968.


U-King wavalelwa ejele kanengi. Umnqophisi we -Federal Bureau of Investigation (FBI) u-J. Edgar Hoover wathatha u-King njengomuntu oqakatheke khulu begodu wamenza waba yinto ye- COINTELPRO kusukela ngo-1963. Ama-ejenti we-FBI amphenyisisa bona angaba nobudlelwano bamakhomanisi, ahlola ipilo yakhe, begodu amrekhoda ngasese. Ngo-1964, i-FBI yathumela u-King incwadi ethusako engaziwako, ayihlathulula njengomzamo wokwenza bona azibulale.  U-King wathumba umvuzo we-Nobel Peace Prize ngo-1964 ngokulwisana nokungalingani ngokobuhlanga ngokusebenzisa ukujamelana okunganadlakela. Eminyakeni yakhe yokugcina, wandisa ukutjheja kwakhe ukufaka hlangana ukuphikiswa kobuphofu nePi ye-Vietnam .

== Ipilo yokuthoma nefundo ==

=== Ukubelethwa ===
U-Michael King Jr. wabelethwa mhlazi-15 kuTjhirhweni 1929, e- Atlanta, ngowesibili ebantwaneni abathathu baka- Michael King no -Alberta King ( née Williams ).  &lt;ref name=&quot;bf&quot; /&gt; &lt;ref name=&quot;bio&quot; /&gt; Ubaba ka-Alberta, u-Adam Daniel Williams,  bekangumfundisi we -Georgia emaphandleni, wathuthela e-Atlanta ngo-1893,  begodu waba mfundisi we- Ebenezer Baptist Church ngomnyaka olandelako. [ 8 ] U-Williams watjhada no-Jennie Celeste Parks. &lt;ref name=&quot;bio&quot; /&gt; U-Michael Sr. wabelethwa babantu abahlanganyela abalimi u-James Albert no-Delia King be- Stockbridge, e-Georgia ;  &lt;ref name=&quot;bio&quot; /&gt; kungenzeka bona bekavela ku -Mende ( Sierra Leone ).    Wabhalisa e- Morehouse College ukufunda ukungena emsebenzini. [ 12 ] U-Michael Sr. no-Alberta bathoma ukuthandana ngo-1920, begodu batjhada mhlazi-25 kuNobayeni 1926. [ 13 ] [ 14 ] Bekube sekufeni kwaka-Jennie ngo-1941, ikhaya labo belisesitezi sesibili sekhaya lababelethi baka-Alberta, lapho u-King abelethelwa khona. [ 15 ] [ 13 ] [ 14 ] [ 16 ] U-Michael Jr. bekanodadewabo omdala, u-Christine King Farris, nomfowabo omncani, u-Alfred Daniel King . [ 17 ]
[[Isimumathi:Booker_T._Washington_High_School_in_Atlanta.jpg|thumb|Isikolo samabanga aphezulu uKing afunda kiso sathiywa ngegama lomfundisi we-Afrika-American u-Booker T. Washington .]]
&lt;references responsive=&quot;&quot; /&gt;</text>
      <sha1>tby0pqotucien1s9m14wft7i67nlx2n</sha1>
    </revision>
    <revision>
      <id>6204</id>
      <parentid>6203</parentid>
      <timestamp>2026-02-19T06:44:38Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6204</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3608" sha1="72vhbbp7g53yrk0mo9f7b4bla4tmfm2" xml:space="preserve">[[Isimumathi:Martin Luther King Jr. - I Have A Dream Speech.jpg|thumb|uMartin Luther King Jr enikeza inkulumo aduma ngayo &quot;I have a Dream Speech&quot;|450x450px]]
'''U-Martin Luther King Jr.''' (u- '''Michael King Jr.''' ; mhlana ali-15 kuTjhirhweni 1929&amp;nbsp;– mhlana ali-4 kuMrhayili 1968) bekangumlweli wamalungelo wobuntu we-[[IAmerica|America]] nomfundisi we -Baptist obekangumdosiphambili wehlangano yamalungelo wobuntu kusukela ngo-1955 bekwaba kulapho abulawa khona ngo-1968. Wathuthukisa amalungelo wobuntu wabantu bemibala e-United States ngokusebenzisa ukujamelana okunganabudlova nokungalaleli komphakathi ngokujamelana nemithetho ka-Jim Crow neminye imihlobo yokubandlulula esemthethweni, ebegade ithinteka khulu Ama-Afrika aseMelika .

Umdosiphambili webandla elimnyama, u-King wahlanganyela begodu wadosa phambili ematjhini wokufuna ilungelo lokuvowuda, ukuhlukaniswa, amalungelo wabasebenzi, namanye amalungelo womphakathi.[1] Waphatha ukudliwa kwamabhasi we-Montgomery ngo-1955 begodu waba ngumongameli wokuthoma we-Southern Christian Leadership Conference (SCLC), arhola i-Albany Movement engaphumeleliko e-Albany, Georgia, begodu wasiza ukuhlela imibhikisho enganabudlova yango-1963 e-Birmingham, Alabama. U-King bekamunye wabadosiphambili be-1963 March e-Washington, lapho anikela khona ikulumo yakhe ethi &quot;Nginephupho&quot;, begodu wasiza ukuhlela ama-match amabili kwamathathu we-Selma ukuya e-Montgomery ngesikhathi se-1965 Selma voting rights movement. Kwaba nokujamelana okukhulu nabaphathi abahlukanisako, ebegade baphendula ngolaka.[2] Umkhankaso wamalungelo wobuntu wazuza iinzuzo eziqakathekileko zomthetho emThethweni wamaLungelo woMphakathi ka-1964, umThetho wamaLungelo wokuVowuda ka-1965, kanye nomThetho weZindlu eziLungileko ka-1968.


U-King wavalelwa ejele kanengi. Umnqophisi we -Federal Bureau of Investigation (FBI) u-J. Edgar Hoover wathatha u-King njengomuntu oqakatheke khulu begodu wamenza waba yinto ye- COINTELPRO kusukela ngo-1963. Ama-ejenti we-FBI amphenyisisa bona angaba nobudlelwano bamakhomanisi, ahlola ipilo yakhe, begodu amrekhoda ngasese. Ngo-1964, i-FBI yathumela u-King incwadi ethusako engaziwako, ayihlathulula njengomzamo wokwenza bona azibulale.  U-King wathumba umvuzo we-Nobel Peace Prize ngo-1964 ngokulwisana nokungalingani ngokobuhlanga ngokusebenzisa ukujamelana okunganadlakela. Eminyakeni yakhe yokugcina, wandisa ukutjheja kwakhe ukufaka hlangana ukuphikiswa kobuphofu nePi ye-Vietnam .

== Ipilo yokuthoma nefundo ==

=== Ukubelethwa ===
U-Michael King Jr. wabelethwa mhlazi-15 kuTjhirhweni 1929, e- Atlanta, ngowesibili ebantwaneni abathathu baka- Michael King no -Alberta King ( née Williams ).  &lt;ref name=&quot;bf&quot; /&gt; &lt;ref name=&quot;bio&quot; /&gt; Ubaba ka-Alberta, u-Adam Daniel Williams,  bekangumfundisi we -Georgia emaphandleni, wathuthela e-Atlanta ngo-1893,  begodu waba mfundisi we- Ebenezer Baptist Church ngomnyaka olandelako. [ 8 ] U-Williams watjhada no-Jennie Celeste Parks. &lt;ref name=&quot;bio&quot; /&gt; U-Michael Sr. wabelethwa babantu abahlanganyela abalimi u-James Albert no-Delia King be- Stockbridge, e-Georgia ;  &lt;ref name=&quot;bio&quot; /&gt; kungenzeka bona bekavela ku -Mende ( Sierra Leone ).    Wabhalisa e- Morehouse College ukufunda ukungena emsebenzini. [ 12 ] U-Michael Sr. no-Alberta bathoma ukuthandana ngo-1920, begodu batjhada mhlazi-25 kuNobayeni 1926. [ 13 ] [ 14 ] Bekube sekufeni kwaka-Jennie ngo-1941, ikhaya labo belisesitezi sesibili sekhaya lababelethi baka-Alberta, lapho u-King abelethelwa khona. [ 15 ] [ 13 ] [ 14 ] [ 16 ] U-Michael Jr. bekanodadewabo omdala, u-Christine King Farris, nomfowabo omncani, u-Alfred Daniel King . [ 17 ]</text>
      <sha1>72vhbbp7g53yrk0mo9f7b4bla4tmfm2</sha1>
    </revision>
    <revision>
      <id>6205</id>
      <parentid>6204</parentid>
      <timestamp>2026-02-19T06:45:30Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6205</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3703" sha1="6wdseya8gg2qdkw40j19asw8epeotxh" xml:space="preserve">[[Isimumathi:Martin Luther King Jr. - I Have A Dream Speech.jpg|thumb|uMartin Luther King Jr enikeza inkulumo aduma ngayo &quot;I have a Dream Speech&quot;|450x450px]]
'''U-Martin Luther King Jr.''' (u- '''Michael King Jr.''' ; mhlana ali-15 kuTjhirhweni 1929&amp;nbsp;– mhlana ali-4 kuMrhayili 1968) bekangumlweli wamalungelo wobuntu we-[[IAmerica|America]] nomfundisi we -Baptist obekangumdosiphambili wehlangano yamalungelo wobuntu kusukela ngo-1955 bekwaba kulapho abulawa khona ngo-1968. Wathuthukisa amalungelo wobuntu wabantu bemibala e-United States ngokusebenzisa ukujamelana okunganabudlova nokungalaleli komphakathi ngokujamelana nemithetho ka-Jim Crow neminye imihlobo yokubandlulula esemthethweni, ebegade ithinteka khulu Ama-Afrika aseMelika .

Umdosiphambili webandla elimnyama, u-King wahlanganyela begodu wadosa phambili ematjhini wokufuna ilungelo lokuvowuda, ukuhlukaniswa, amalungelo wabasebenzi, namanye amalungelo womphakathi.&lt;ref&gt;https://revealnews.org/podcast/bayard-rustin-martin-luther-king-jr-black-history-month/&lt;/ref&gt; Waphatha ukudliwa kwamabhasi we-Montgomery ngo-1955 begodu waba ngumongameli wokuthoma we-Southern Christian Leadership Conference (SCLC), arhola i-Albany Movement engaphumeleliko e-Albany, Georgia, begodu wasiza ukuhlela imibhikisho enganabudlova yango-1963 e-Birmingham, Alabama. U-King bekamunye wabadosiphambili be-1963 March e-Washington, lapho anikela khona ikulumo yakhe ethi &quot;Nginephupho&quot;, begodu wasiza ukuhlela ama-match amabili kwamathathu we-Selma ukuya e-Montgomery ngesikhathi se-1965 Selma voting rights movement. Kwaba nokujamelana okukhulu nabaphathi abahlukanisako, ebegade baphendula ngolaka.[2] Umkhankaso wamalungelo wobuntu wazuza iinzuzo eziqakathekileko zomthetho emThethweni wamaLungelo woMphakathi ka-1964, umThetho wamaLungelo wokuVowuda ka-1965, kanye nomThetho weZindlu eziLungileko ka-1968.


U-King wavalelwa ejele kanengi. Umnqophisi we -Federal Bureau of Investigation (FBI) u-J. Edgar Hoover wathatha u-King njengomuntu oqakatheke khulu begodu wamenza waba yinto ye- COINTELPRO kusukela ngo-1963. Ama-ejenti we-FBI amphenyisisa bona angaba nobudlelwano bamakhomanisi, ahlola ipilo yakhe, begodu amrekhoda ngasese. Ngo-1964, i-FBI yathumela u-King incwadi ethusako engaziwako, ayihlathulula njengomzamo wokwenza bona azibulale.  U-King wathumba umvuzo we-Nobel Peace Prize ngo-1964 ngokulwisana nokungalingani ngokobuhlanga ngokusebenzisa ukujamelana okunganadlakela. Eminyakeni yakhe yokugcina, wandisa ukutjheja kwakhe ukufaka hlangana ukuphikiswa kobuphofu nePi ye-Vietnam .

== Ipilo yokuthoma nefundo ==

=== Ukubelethwa ===
U-Michael King Jr. wabelethwa mhlazi-15 kuTjhirhweni 1929, e- Atlanta, ngowesibili ebantwaneni abathathu baka- Michael King no -Alberta King ( née Williams ).  &lt;ref name=&quot;bf&quot; /&gt; &lt;ref name=&quot;bio&quot; /&gt; Ubaba ka-Alberta, u-Adam Daniel Williams,  bekangumfundisi we -Georgia emaphandleni, wathuthela e-Atlanta ngo-1893,  begodu waba mfundisi we- Ebenezer Baptist Church ngomnyaka olandelako. [ 8 ] U-Williams watjhada no-Jennie Celeste Parks. &lt;ref name=&quot;bio&quot; /&gt; U-Michael Sr. wabelethwa babantu abahlanganyela abalimi u-James Albert no-Delia King be- Stockbridge, e-Georgia ;  &lt;ref name=&quot;bio&quot; /&gt; kungenzeka bona bekavela ku -Mende ( Sierra Leone ).    Wabhalisa e- Morehouse College ukufunda ukungena emsebenzini. [ 12 ] U-Michael Sr. no-Alberta bathoma ukuthandana ngo-1920, begodu batjhada mhlazi-25 kuNobayeni 1926. [ 13 ] [ 14 ] Bekube sekufeni kwaka-Jennie ngo-1941, ikhaya labo belisesitezi sesibili sekhaya lababelethi baka-Alberta, lapho u-King abelethelwa khona. [ 15 ] [ 13 ] [ 14 ] [ 16 ] U-Michael Jr. bekanodadewabo omdala, u-Christine King Farris, nomfowabo omncani, u-Alfred Daniel King . [ 17 ]</text>
      <sha1>6wdseya8gg2qdkw40j19asw8epeotxh</sha1>
    </revision>
    <revision>
      <id>6206</id>
      <parentid>6205</parentid>
      <timestamp>2026-02-19T06:45:53Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6206</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3821" sha1="6n37vbf9xj5bynzcytpahlujg5a6hi0" xml:space="preserve">[[Isimumathi:Martin Luther King Jr. - I Have A Dream Speech.jpg|thumb|uMartin Luther King Jr enikeza inkulumo aduma ngayo &quot;I have a Dream Speech&quot;|450x450px]]
'''U-Martin Luther King Jr.''' (u- '''Michael King Jr.''' ; mhlana ali-15 kuTjhirhweni 1929&amp;nbsp;– mhlana ali-4 kuMrhayili 1968) bekangumlweli wamalungelo wobuntu we-[[IAmerica|America]] nomfundisi we -Baptist obekangumdosiphambili wehlangano yamalungelo wobuntu kusukela ngo-1955 bekwaba kulapho abulawa khona ngo-1968. Wathuthukisa amalungelo wobuntu wabantu bemibala e-United States ngokusebenzisa ukujamelana okunganabudlova nokungalaleli komphakathi ngokujamelana nemithetho ka-Jim Crow neminye imihlobo yokubandlulula esemthethweni, ebegade ithinteka khulu Ama-Afrika aseMelika .

Umdosiphambili webandla elimnyama, u-King wahlanganyela begodu wadosa phambili ematjhini wokufuna ilungelo lokuvowuda, ukuhlukaniswa, amalungelo wabasebenzi, namanye amalungelo womphakathi.&lt;ref&gt;https://revealnews.org/podcast/bayard-rustin-martin-luther-king-jr-black-history-month/&lt;/ref&gt; Waphatha ukudliwa kwamabhasi we-Montgomery ngo-1955 begodu waba ngumongameli wokuthoma we-Southern Christian Leadership Conference (SCLC), arhola i-Albany Movement engaphumeleliko e-Albany, Georgia, begodu wasiza ukuhlela imibhikisho enganabudlova yango-1963 e-Birmingham, Alabama. U-King bekamunye wabadosiphambili be-1963 March e-Washington, lapho anikela khona ikulumo yakhe ethi &quot;Nginephupho&quot;, begodu wasiza ukuhlela ama-match amabili kwamathathu we-Selma ukuya e-Montgomery ngesikhathi se-1965 Selma voting rights movement. Kwaba nokujamelana okukhulu nabaphathi abahlukanisako, ebegade baphendula ngolaka.[2] Umkhankaso wamalungelo wobuntu wazuza iinzuzo eziqakathekileko zomthetho emThethweni wamaLungelo woMphakathi ka-1964, umThetho wamaLungelo wokuVowuda ka-1965, kanye nomThetho weZindlu eziLungileko ka-1968.&lt;ref&gt;https://vocal.media/journal/jesse-jackson-the-living-bridge-between-martin-luther-king-jr-and-barack-obama&lt;/ref&gt;



U-King wavalelwa ejele kanengi. Umnqophisi we -Federal Bureau of Investigation (FBI) u-J. Edgar Hoover wathatha u-King njengomuntu oqakatheke khulu begodu wamenza waba yinto ye- COINTELPRO kusukela ngo-1963. Ama-ejenti we-FBI amphenyisisa bona angaba nobudlelwano bamakhomanisi, ahlola ipilo yakhe, begodu amrekhoda ngasese. Ngo-1964, i-FBI yathumela u-King incwadi ethusako engaziwako, ayihlathulula njengomzamo wokwenza bona azibulale.  U-King wathumba umvuzo we-Nobel Peace Prize ngo-1964 ngokulwisana nokungalingani ngokobuhlanga ngokusebenzisa ukujamelana okunganadlakela. Eminyakeni yakhe yokugcina, wandisa ukutjheja kwakhe ukufaka hlangana ukuphikiswa kobuphofu nePi ye-Vietnam .

== Ipilo yokuthoma nefundo ==

=== Ukubelethwa ===
U-Michael King Jr. wabelethwa mhlazi-15 kuTjhirhweni 1929, e- Atlanta, ngowesibili ebantwaneni abathathu baka- Michael King no -Alberta King ( née Williams ).  &lt;ref name=&quot;bf&quot; /&gt; &lt;ref name=&quot;bio&quot; /&gt; Ubaba ka-Alberta, u-Adam Daniel Williams,  bekangumfundisi we -Georgia emaphandleni, wathuthela e-Atlanta ngo-1893,  begodu waba mfundisi we- Ebenezer Baptist Church ngomnyaka olandelako. [ 8 ] U-Williams watjhada no-Jennie Celeste Parks. &lt;ref name=&quot;bio&quot; /&gt; U-Michael Sr. wabelethwa babantu abahlanganyela abalimi u-James Albert no-Delia King be- Stockbridge, e-Georgia ;  &lt;ref name=&quot;bio&quot; /&gt; kungenzeka bona bekavela ku -Mende ( Sierra Leone ).    Wabhalisa e- Morehouse College ukufunda ukungena emsebenzini. [ 12 ] U-Michael Sr. no-Alberta bathoma ukuthandana ngo-1920, begodu batjhada mhlazi-25 kuNobayeni 1926. [ 13 ] [ 14 ] Bekube sekufeni kwaka-Jennie ngo-1941, ikhaya labo belisesitezi sesibili sekhaya lababelethi baka-Alberta, lapho u-King abelethelwa khona. [ 15 ] [ 13 ] [ 14 ] [ 16 ] U-Michael Jr. bekanodadewabo omdala, u-Christine King Farris, nomfowabo omncani, u-Alfred Daniel King . [ 17 ]</text>
      <sha1>6n37vbf9xj5bynzcytpahlujg5a6hi0</sha1>
    </revision>
    <revision>
      <id>6207</id>
      <parentid>6206</parentid>
      <timestamp>2026-02-19T06:46:41Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>/* Ipilo yokuthoma nefundo */</comment>
      <origin>6207</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3707" sha1="lt6gqrfohekanud2pf0f3s96v7ox12r" xml:space="preserve">[[Isimumathi:Martin Luther King Jr. - I Have A Dream Speech.jpg|thumb|uMartin Luther King Jr enikeza inkulumo aduma ngayo &quot;I have a Dream Speech&quot;|450x450px]]
'''U-Martin Luther King Jr.''' (u- '''Michael King Jr.''' ; mhlana ali-15 kuTjhirhweni 1929&amp;nbsp;– mhlana ali-4 kuMrhayili 1968) bekangumlweli wamalungelo wobuntu we-[[IAmerica|America]] nomfundisi we -Baptist obekangumdosiphambili wehlangano yamalungelo wobuntu kusukela ngo-1955 bekwaba kulapho abulawa khona ngo-1968. Wathuthukisa amalungelo wobuntu wabantu bemibala e-United States ngokusebenzisa ukujamelana okunganabudlova nokungalaleli komphakathi ngokujamelana nemithetho ka-Jim Crow neminye imihlobo yokubandlulula esemthethweni, ebegade ithinteka khulu Ama-Afrika aseMelika .

Umdosiphambili webandla elimnyama, u-King wahlanganyela begodu wadosa phambili ematjhini wokufuna ilungelo lokuvowuda, ukuhlukaniswa, amalungelo wabasebenzi, namanye amalungelo womphakathi.&lt;ref&gt;https://revealnews.org/podcast/bayard-rustin-martin-luther-king-jr-black-history-month/&lt;/ref&gt; Waphatha ukudliwa kwamabhasi we-Montgomery ngo-1955 begodu waba ngumongameli wokuthoma we-Southern Christian Leadership Conference (SCLC), arhola i-Albany Movement engaphumeleliko e-Albany, Georgia, begodu wasiza ukuhlela imibhikisho enganabudlova yango-1963 e-Birmingham, Alabama. U-King bekamunye wabadosiphambili be-1963 March e-Washington, lapho anikela khona ikulumo yakhe ethi &quot;Nginephupho&quot;, begodu wasiza ukuhlela ama-match amabili kwamathathu we-Selma ukuya e-Montgomery ngesikhathi se-1965 Selma voting rights movement. Kwaba nokujamelana okukhulu nabaphathi abahlukanisako, ebegade baphendula ngolaka.[2] Umkhankaso wamalungelo wobuntu wazuza iinzuzo eziqakathekileko zomthetho emThethweni wamaLungelo woMphakathi ka-1964, umThetho wamaLungelo wokuVowuda ka-1965, kanye nomThetho weZindlu eziLungileko ka-1968.&lt;ref&gt;https://vocal.media/journal/jesse-jackson-the-living-bridge-between-martin-luther-king-jr-and-barack-obama&lt;/ref&gt;



U-King wavalelwa ejele kanengi. Umnqophisi we -Federal Bureau of Investigation (FBI) u-J. Edgar Hoover wathatha u-King njengomuntu oqakatheke khulu begodu wamenza waba yinto ye- COINTELPRO kusukela ngo-1963. Ama-ejenti we-FBI amphenyisisa bona angaba nobudlelwano bamakhomanisi, ahlola ipilo yakhe, begodu amrekhoda ngasese. Ngo-1964, i-FBI yathumela u-King incwadi ethusako engaziwako, ayihlathulula njengomzamo wokwenza bona azibulale.  U-King wathumba umvuzo we-Nobel Peace Prize ngo-1964 ngokulwisana nokungalingani ngokobuhlanga ngokusebenzisa ukujamelana okunganadlakela. Eminyakeni yakhe yokugcina, wandisa ukutjheja kwakhe ukufaka hlangana ukuphikiswa kobuphofu nePi ye-Vietnam .

== Ipilo yokuthoma nefundo ==

=== Ukubelethwa ===
U-Michael King Jr. wabelethwa mhlazi-15 kuTjhirhweni 1929, e- Atlanta, ngowesibili ebantwaneni abathathu baka- Michael King no -Alberta King ( née Williams ).  Ubaba ka-Alberta, u-Adam Daniel Williams,  bekangumfundisi we -Georgia emaphandleni, wathuthela e-Atlanta ngo-1893,  begodu waba mfundisi we- Ebenezer Baptist Church ngomnyaka olandelako.  U-Williams watjhada no-Jennie Celeste Parks. U-Michael Sr. wabelethwa babantu abahlanganyela abalimi u-James Albert no-Delia King be- Stockbridge, e-Georgia ;  kungenzeka bona bekavela ku -Mende ( Sierra Leone ).    Wabhalisa e- Morehouse College ukufunda ukungena emsebenzini.  U-Michael Sr. no-Alberta bathoma ukuthandana ngo-1920, begodu batjhada mhlazi-25 kuNobayeni 1926. [ 13 ] [ 14 ] Bekube sekufeni kwaka-Jennie ngo-1941, ikhaya labo belisesitezi sesibili sekhaya lababelethi baka-Alberta, lapho u-King abelethelwa khona. U-Michael Jr. bekanodadewabo omdala, u-Christine King Farris, nomfowabo omncani, u-Alfred Daniel King . [ 17 ]</text>
      <sha1>lt6gqrfohekanud2pf0f3s96v7ox12r</sha1>
    </revision>
    <revision>
      <id>6208</id>
      <parentid>6207</parentid>
      <timestamp>2026-02-19T06:47:19Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>/* Ipilo yokuthoma nefundo */</comment>
      <origin>6208</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3807" sha1="atl0vmswidfhe89zro9vxam8vxc14fz" xml:space="preserve">[[Isimumathi:Martin Luther King Jr. - I Have A Dream Speech.jpg|thumb|uMartin Luther King Jr enikeza inkulumo aduma ngayo &quot;I have a Dream Speech&quot;|450x450px]]
'''U-Martin Luther King Jr.''' (u- '''Michael King Jr.''' ; mhlana ali-15 kuTjhirhweni 1929&amp;nbsp;– mhlana ali-4 kuMrhayili 1968) bekangumlweli wamalungelo wobuntu we-[[IAmerica|America]] nomfundisi we -Baptist obekangumdosiphambili wehlangano yamalungelo wobuntu kusukela ngo-1955 bekwaba kulapho abulawa khona ngo-1968. Wathuthukisa amalungelo wobuntu wabantu bemibala e-United States ngokusebenzisa ukujamelana okunganabudlova nokungalaleli komphakathi ngokujamelana nemithetho ka-Jim Crow neminye imihlobo yokubandlulula esemthethweni, ebegade ithinteka khulu Ama-Afrika aseMelika .

Umdosiphambili webandla elimnyama, u-King wahlanganyela begodu wadosa phambili ematjhini wokufuna ilungelo lokuvowuda, ukuhlukaniswa, amalungelo wabasebenzi, namanye amalungelo womphakathi.&lt;ref&gt;https://revealnews.org/podcast/bayard-rustin-martin-luther-king-jr-black-history-month/&lt;/ref&gt; Waphatha ukudliwa kwamabhasi we-Montgomery ngo-1955 begodu waba ngumongameli wokuthoma we-Southern Christian Leadership Conference (SCLC), arhola i-Albany Movement engaphumeleliko e-Albany, Georgia, begodu wasiza ukuhlela imibhikisho enganabudlova yango-1963 e-Birmingham, Alabama. U-King bekamunye wabadosiphambili be-1963 March e-Washington, lapho anikela khona ikulumo yakhe ethi &quot;Nginephupho&quot;, begodu wasiza ukuhlela ama-match amabili kwamathathu we-Selma ukuya e-Montgomery ngesikhathi se-1965 Selma voting rights movement. Kwaba nokujamelana okukhulu nabaphathi abahlukanisako, ebegade baphendula ngolaka.[2] Umkhankaso wamalungelo wobuntu wazuza iinzuzo eziqakathekileko zomthetho emThethweni wamaLungelo woMphakathi ka-1964, umThetho wamaLungelo wokuVowuda ka-1965, kanye nomThetho weZindlu eziLungileko ka-1968.&lt;ref&gt;https://vocal.media/journal/jesse-jackson-the-living-bridge-between-martin-luther-king-jr-and-barack-obama&lt;/ref&gt;



U-King wavalelwa ejele kanengi. Umnqophisi we -Federal Bureau of Investigation (FBI) u-J. Edgar Hoover wathatha u-King njengomuntu oqakatheke khulu begodu wamenza waba yinto ye- COINTELPRO kusukela ngo-1963. Ama-ejenti we-FBI amphenyisisa bona angaba nobudlelwano bamakhomanisi, ahlola ipilo yakhe, begodu amrekhoda ngasese. Ngo-1964, i-FBI yathumela u-King incwadi ethusako engaziwako, ayihlathulula njengomzamo wokwenza bona azibulale.  U-King wathumba umvuzo we-Nobel Peace Prize ngo-1964 ngokulwisana nokungalingani ngokobuhlanga ngokusebenzisa ukujamelana okunganadlakela. Eminyakeni yakhe yokugcina, wandisa ukutjheja kwakhe ukufaka hlangana ukuphikiswa kobuphofu nePi ye-Vietnam .

== Ipilo yokuthoma nefundo ==
uKing Jr. wabelethwa mhlazi-15 kuTjhirhweni 1929, e- Atlanta, ngowesibili ebantwaneni abathathu baka- Michael King no -Alberta King ( née Williams ).  Ubaba ka-Alberta, u-Adam Daniel Williams,  bekangumfundisi we -Georgia emaphandleni, wathuthela e-Atlanta ngo-1893,  begodu waba mfundisi we- Ebenezer Baptist Church ngomnyaka olandelako.  U-Williams watjhada no-Jennie Celeste Parks. U-Michael Sr. wabelethwa babantu abahlanganyela abalimi u-James Albert no-Delia King be- Stockbridge, e-Georgia ;  kungenzeka bona bekavela ku -Mende ( Sierra Leone ).    Wabhalisa e- Morehouse College ukufunda ukungena emsebenzini.  U-Michael Sr. no-Alberta bathoma ukuthandana ngo-1920, begodu batjhada mhlazi-25 kuNobayeni 1926. [ 13 ] [ 14 ] Bekube sekufeni kwaka-Jennie ngo-1941, ikhaya labo belisesitezi sesibili sekhaya lababelethi baka-Alberta, lapho u-King abelethelwa khona. U-Michael Jr. bekanodadewabo omdala, u-Christine King Farris, nomfowabo omncani, u-Alfred Daniel King .&lt;ref&gt;https://www.usatoday.com/story/news/politics/2026/01/19/donald-trump-doesnt-acknowledge-martin-luther-king-jr-day/88252240007/&lt;/ref&gt;</text>
      <sha1>atl0vmswidfhe89zro9vxam8vxc14fz</sha1>
    </revision>
    <revision>
      <id>6209</id>
      <parentid>6208</parentid>
      <timestamp>2026-02-19T06:47:41Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6209</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3887" sha1="kp1xs7pd8vkm80zu68ejqw95vh5aty4" xml:space="preserve">[[Isimumathi:Martin Luther King Jr. - I Have A Dream Speech.jpg|thumb|uMartin Luther King Jr enikeza inkulumo aduma ngayo &quot;I have a Dream Speech&quot;|450x450px]]
'''U-Martin Luther King Jr.''' (u- '''Michael King Jr.''' ; mhlana ali-15 kuTjhirhweni 1929&amp;nbsp;– mhlana ali-4 kuMrhayili 1968) bekangumlweli wamalungelo wobuntu we-[[IAmerica|America]] nomfundisi we -Baptist obekangumdosiphambili wehlangano yamalungelo wobuntu kusukela ngo-1955 bekwaba kulapho abulawa khona ngo-1968. Wathuthukisa amalungelo wobuntu wabantu bemibala e-United States ngokusebenzisa ukujamelana okunganabudlova nokungalaleli komphakathi ngokujamelana nemithetho ka-Jim Crow neminye imihlobo yokubandlulula esemthethweni, ebegade ithinteka khulu Ama-Afrika aseMelika .

Umdosiphambili webandla elimnyama, u-King wahlanganyela begodu wadosa phambili ematjhini wokufuna ilungelo lokuvowuda, ukuhlukaniswa, amalungelo wabasebenzi, namanye amalungelo womphakathi.&lt;ref&gt;https://revealnews.org/podcast/bayard-rustin-martin-luther-king-jr-black-history-month/&lt;/ref&gt; Waphatha ukudliwa kwamabhasi we-Montgomery ngo-1955 begodu waba ngumongameli wokuthoma we-Southern Christian Leadership Conference (SCLC), arhola i-Albany Movement engaphumeleliko e-Albany, Georgia, begodu wasiza ukuhlela imibhikisho enganabudlova yango-1963 e-Birmingham, Alabama. U-King bekamunye wabadosiphambili be-1963 March e-Washington, lapho anikela khona ikulumo yakhe ethi &quot;Nginephupho&quot;, begodu wasiza ukuhlela ama-match amabili kwamathathu we-Selma ukuya e-Montgomery ngesikhathi se-1965 Selma voting rights movement. Kwaba nokujamelana okukhulu nabaphathi abahlukanisako, ebegade baphendula ngolaka.[2] Umkhankaso wamalungelo wobuntu wazuza iinzuzo eziqakathekileko zomthetho emThethweni wamaLungelo woMphakathi ka-1964, umThetho wamaLungelo wokuVowuda ka-1965, kanye nomThetho weZindlu eziLungileko ka-1968.&lt;ref&gt;https://vocal.media/journal/jesse-jackson-the-living-bridge-between-martin-luther-king-jr-and-barack-obama&lt;/ref&gt;



U-King wavalelwa ejele kanengi. Umnqophisi we -Federal Bureau of Investigation (FBI) u-J. Edgar Hoover wathatha u-King njengomuntu oqakatheke khulu begodu wamenza waba yinto ye- COINTELPRO kusukela ngo-1963. Ama-ejenti we-FBI amphenyisisa bona angaba nobudlelwano bamakhomanisi, ahlola ipilo yakhe, begodu amrekhoda ngasese. Ngo-1964, i-FBI yathumela u-King incwadi ethusako engaziwako, ayihlathulula njengomzamo wokwenza bona azibulale.  U-King wathumba umvuzo we-Nobel Peace Prize ngo-1964 ngokulwisana nokungalingani ngokobuhlanga ngokusebenzisa ukujamelana okunganadlakela. Eminyakeni yakhe yokugcina, wandisa ukutjheja kwakhe ukufaka hlangana ukuphikiswa kobuphofu nePi ye-Vietnam .

== Ipilo yokuthoma nefundo ==
uKing Jr. wabelethwa mhlazi-15 kuTjhirhweni 1929, e- Atlanta, ngowesibili ebantwaneni abathathu baka- Michael King no -Alberta King ( née Williams ).  Ubaba ka-Alberta, u-Adam Daniel Williams,  bekangumfundisi we -Georgia emaphandleni, wathuthela e-Atlanta ngo-1893,  begodu waba mfundisi we- Ebenezer Baptist Church ngomnyaka olandelako.  U-Williams watjhada no-Jennie Celeste Parks. U-Michael Sr. wabelethwa babantu abahlanganyela abalimi u-James Albert no-Delia King be- Stockbridge, e-Georgia ;  kungenzeka bona bekavela ku -Mende ( Sierra Leone ).    Wabhalisa e- Morehouse College ukufunda ukungena emsebenzini.  U-Michael Sr. no-Alberta bathoma ukuthandana ngo-1920, begodu batjhada mhlazi-25 kuNobayeni 1926. &lt;ref&gt;https://www.npr.org/2026/01/18/g-s1-106127/martin-luther-king-jr-dream-health-care&lt;/ref&gt; Bekube sekufeni kwaka-Jennie ngo-1941, ikhaya labo belisesitezi sesibili sekhaya lababelethi baka-Alberta, lapho u-King abelethelwa khona. U-Michael Jr. bekanodadewabo omdala, u-Christine King Farris, nomfowabo omncani, u-Alfred Daniel King .&lt;ref&gt;https://www.usatoday.com/story/news/politics/2026/01/19/donald-trump-doesnt-acknowledge-martin-luther-king-jr-day/88252240007/&lt;/ref&gt;</text>
      <sha1>kp1xs7pd8vkm80zu68ejqw95vh5aty4</sha1>
    </revision>
    <revision>
      <id>6210</id>
      <parentid>6209</parentid>
      <timestamp>2026-02-19T06:49:25Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6210</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3988" sha1="brg14irueakydj691in3mqcz8uy8dxz" xml:space="preserve">[[Isimumathi:Martin Luther King Jr. - I Have A Dream Speech.jpg|thumb|uMartin Luther King Jr enikeza inkulumo aduma ngayo &quot;I have a Dream Speech&quot;|450x450px]]
'''U-Martin Luther King Jr.''' (u- '''Michael King Jr.''' ; mhlana ali-15 kuTjhirhweni 1929&amp;nbsp;– mhlana ali-4 kuMrhayili 1968) bekangumlweli wamalungelo wobuntu we-[[IAmerica|America]] nomfundisi we -Baptist obekangumdosiphambili wehlangano yamalungelo wobuntu kusukela ngo-1955 bekwaba kulapho abulawa khona ngo-1968. Wathuthukisa amalungelo wobuntu wabantu bemibala e-United States ngokusebenzisa ukujamelana okunganabudlova nokungalaleli komphakathi ngokujamelana nemithetho ka-Jim Crow neminye imihlobo yokubandlulula esemthethweni, ebegade ithinteka khulu Ama-Afrika aseMelika .

Umdosiphambili webandla elimnyama, u-King wahlanganyela begodu wadosa phambili ematjhini wokufuna ilungelo lokuvowuda, ukuhlukaniswa, amalungelo wabasebenzi, namanye amalungelo womphakathi.&lt;ref&gt;https://revealnews.org/podcast/bayard-rustin-martin-luther-king-jr-black-history-month/&lt;/ref&gt; Waphatha ukudliwa kwamabhasi we-Montgomery ngo-1955 begodu waba ngumongameli wokuthoma we-Southern Christian Leadership Conference (SCLC), arhola i-Albany Movement engaphumeleliko e-Albany, Georgia, begodu wasiza ukuhlela imibhikisho enganabudlova yango-1963 e-Birmingham, Alabama. U-King bekamunye wabadosiphambili be-1963 March e-Washington, lapho anikela khona ikulumo yakhe ethi &quot;Nginephupho&quot;, begodu wasiza ukuhlela ama-match amabili kwamathathu we-Selma ukuya e-Montgomery ngesikhathi se-1965 Selma voting rights movement. Kwaba nokujamelana okukhulu nabaphathi abahlukanisako, ebegade baphendula ngolaka.[2] Umkhankaso wamalungelo wobuntu wazuza iinzuzo eziqakathekileko zomthetho emThethweni wamaLungelo woMphakathi ka-1964, umThetho wamaLungelo wokuVowuda ka-1965, kanye nomThetho weZindlu eziLungileko ka-1968.&lt;ref&gt;https://vocal.media/journal/jesse-jackson-the-living-bridge-between-martin-luther-king-jr-and-barack-obama&lt;/ref&gt;



U-King wavalelwa ejele kanengi. Umnqophisi we -Federal Bureau of Investigation (FBI) u-J. Edgar Hoover wathatha u-King njengomuntu oqakatheke khulu begodu wamenza waba yinto ye- COINTELPRO kusukela ngo-1963. Ama-ejenti we-FBI amphenyisisa bona angaba nobudlelwano bamakhomanisi, ahlola ipilo yakhe, begodu amrekhoda ngasese. Ngo-1964, i-FBI yathumela u-King incwadi ethusako engaziwako, ayihlathulula njengomzamo wokwenza bona azibulale.  U-King wathumba umvuzo we-Nobel Peace Prize ngo-1964 ngokulwisana nokungalingani ngokobuhlanga ngokusebenzisa ukujamelana okunganadlakela. Eminyakeni yakhe yokugcina, wandisa ukutjheja kwakhe ukufaka hlangana ukuphikiswa kobuphofu nePi ye-Vietnam .

== Ipilo yokuthoma nefundo ==

uKing Jr. wabelethwa mhlazi-15 kuTjhirhweni 1929, e- Atlanta, ngowesibili ebantwaneni abathathu baka- Michael King no -Alberta King ( née Williams ).  Ubaba ka-Alberta, u-Adam Daniel Williams,  bekangumfundisi we -Georgia emaphandleni, wathuthela e-Atlanta ngo-1893,  begodu waba mfundisi we- Ebenezer Baptist Church ngomnyaka olandelako.  U-Williams watjhada no-Jennie Celeste Parks. U-Michael Sr. wabelethwa babantu abahlanganyela abalimi u-James Albert no-Delia King be- Stockbridge, e-Georgia ;  kungenzeka bona bekavela ku -Mende ( Sierra Leone ).    Wabhalisa e- Morehouse College ukufunda ukungena emsebenzini.  U-Michael Sr. no-Alberta bathoma ukuthandana ngo-1920, begodu batjhada mhlazi-25 kuNobayeni 1926. &lt;ref&gt;https://www.npr.org/2026/01/18/g-s1-106127/martin-luther-king-jr-dream-health-care&lt;/ref&gt; Bekube sekufeni kwaka-Jennie ngo-1941, ikhaya labo belisesitezi sesibili sekhaya lababelethi baka-Alberta, lapho u-King abelethelwa khona. U-Michael Jr. bekanodadewabo omdala, u-Christine King Farris, nomfowabo omncani, u-Alfred Daniel King .&lt;ref&gt;https://www.usatoday.com/story/news/politics/2026/01/19/donald-trump-doesnt-acknowledge-martin-luther-king-jr-day/88252240007/&lt;/ref&gt;. uKing wabulawa mhlana ali-4 kuMrhayili 1968 abe no[[U-Jesse Jackson|Jesse Jackson]] kanye nabanye.</text>
      <sha1>brg14irueakydj691in3mqcz8uy8dxz</sha1>
    </revision>
    <revision>
      <id>6211</id>
      <parentid>6210</parentid>
      <timestamp>2026-02-19T06:50:09Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6211</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4091" sha1="kbz991qjxhstzo6ytzppgq6mdl9mykp" xml:space="preserve">[[Isimumathi:Martin Luther King Jr. - I Have A Dream Speech.jpg|thumb|uMartin Luther King Jr enikeza inkulumo aduma ngayo &quot;I have a Dream Speech&quot;|450x450px]]
'''U-Martin Luther King Jr.''' (u- '''Michael King Jr.''' ; mhlana ali-15 kuTjhirhweni 1929&amp;nbsp;– mhlana ali-4 kuMrhayili 1968) bekangumlweli wamalungelo wobuntu we-[[IAmerica|America]] nomfundisi we -Baptist obekangumdosiphambili wehlangano yamalungelo wobuntu kusukela ngo-1955 bekwaba kulapho abulawa khona ngo-1968. Wathuthukisa amalungelo wobuntu wabantu bemibala e-United States ngokusebenzisa ukujamelana okunganabudlova nokungalaleli komphakathi ngokujamelana nemithetho ka-Jim Crow neminye imihlobo yokubandlulula esemthethweni, ebegade ithinteka khulu Ama-Afrika aseMelika .

Umdosiphambili webandla elimnyama, u-King wahlanganyela begodu wadosa phambili ematjhini wokufuna ilungelo lokuvowuda, ukuhlukaniswa, amalungelo wabasebenzi, namanye amalungelo womphakathi.&lt;ref&gt;https://revealnews.org/podcast/bayard-rustin-martin-luther-king-jr-black-history-month/&lt;/ref&gt; Waphatha ukudliwa kwamabhasi we-Montgomery ngo-1955 begodu waba ngumongameli wokuthoma we-Southern Christian Leadership Conference (SCLC), arhola i-Albany Movement engaphumeleliko e-Albany, Georgia, begodu wasiza ukuhlela imibhikisho enganabudlova yango-1963 e-Birmingham, Alabama. U-King bekamunye wabadosiphambili be-1963 March e-Washington, lapho anikela khona ikulumo yakhe ethi &quot;Nginephupho&quot;, begodu wasiza ukuhlela ama-match amabili kwamathathu we-Selma ukuya e-Montgomery ngesikhathi se-1965 Selma voting rights movement. Kwaba nokujamelana okukhulu nabaphathi abahlukanisako, ebegade baphendula ngolaka.[2] Umkhankaso wamalungelo wobuntu wazuza iinzuzo eziqakathekileko zomthetho emThethweni wamaLungelo woMphakathi ka-1964, umThetho wamaLungelo wokuVowuda ka-1965, kanye nomThetho weZindlu eziLungileko ka-1968.&lt;ref&gt;https://vocal.media/journal/jesse-jackson-the-living-bridge-between-martin-luther-king-jr-and-barack-obama&lt;/ref&gt;



U-King wavalelwa ejele kanengi. Umnqophisi we -Federal Bureau of Investigation (FBI) u-J. Edgar Hoover wathatha u-King njengomuntu oqakatheke khulu begodu wamenza waba yinto ye- COINTELPRO kusukela ngo-1963. Ama-ejenti we-FBI amphenyisisa bona angaba nobudlelwano bamakhomanisi, ahlola ipilo yakhe, begodu amrekhoda ngasese. Ngo-1964, i-FBI yathumela u-King incwadi ethusako engaziwako, ayihlathulula njengomzamo wokwenza bona azibulale.  U-King wathumba umvuzo we-Nobel Peace Prize ngo-1964 ngokulwisana nokungalingani ngokobuhlanga ngokusebenzisa ukujamelana okunganadlakela. Eminyakeni yakhe yokugcina, wandisa ukutjheja kwakhe ukufaka hlangana ukuphikiswa kobuphofu nePi ye-Vietnam .

== Ipilo yokuthoma nefundo ==

uKing Jr. wabelethwa mhlazi-15 kuTjhirhweni 1929, e- Atlanta, ngowesibili ebantwaneni abathathu baka- Michael King no -Alberta King ( née Williams ).  Ubaba ka-Alberta, u-Adam Daniel Williams,  bekangumfundisi we -Georgia emaphandleni, wathuthela e-Atlanta ngo-1893,  begodu waba mfundisi we- Ebenezer Baptist Church ngomnyaka olandelako.  U-Williams watjhada no-Jennie Celeste Parks. U-Michael Sr. wabelethwa babantu abahlanganyela abalimi u-James Albert no-Delia King be- Stockbridge, e-Georgia ;  kungenzeka bona bekavela ku -Mende ( Sierra Leone ).    Wabhalisa e- Morehouse College ukufunda ukungena emsebenzini.  U-Michael Sr. no-Alberta bathoma ukuthandana ngo-1920, begodu batjhada mhlazi-25 kuNobayeni 1926. &lt;ref&gt;https://www.npr.org/2026/01/18/g-s1-106127/martin-luther-king-jr-dream-health-care&lt;/ref&gt; Bekube sekufeni kwaka-Jennie ngo-1941, ikhaya labo belisesitezi sesibili sekhaya lababelethi baka-Alberta, lapho u-King abelethelwa khona. U-Michael Jr. bekanodadewabo omdala, u-Christine King Farris, nomfowabo omncani, u-Alfred Daniel King .&lt;ref&gt;https://www.usatoday.com/story/news/politics/2026/01/19/donald-trump-doesnt-acknowledge-martin-luther-king-jr-day/88252240007/&lt;/ref&gt;. uKing wabulawa mhlana ali-4 kuMrhayili 1968 abe no[[U-Jesse Jackson|Jesse Jackson]] kanye nabanye.

== Inkomba  ==
{{reflist}}
[[Category:Amalungelo oluntu]]
[[Category:iAmerika]]
[[Category:Umlando]]</text>
      <sha1>kbz991qjxhstzo6ytzppgq6mdl9mykp</sha1>
    </revision>
    <revision>
      <id>6212</id>
      <parentid>6211</parentid>
      <timestamp>2026-02-19T06:50:27Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6212</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4090" sha1="0msuwukjqc07depc96egs4ssrjlsqpm" xml:space="preserve">[[Isimumathi:Martin Luther King Jr. - I Have A Dream Speech.jpg|thumb|uMartin Luther King Jr enikeza inkulumo aduma ngayo &quot;I have a Dream Speech&quot;|450x450px]]
'''U-Martin Luther King Jr.''' (u- '''Michael King Jr.''' ; mhlana ali-15 kuTjhirhweni 1929&amp;nbsp;– mhlana ali-4 kuMrhayili 1968) bekangumlweli wamalungelo wobuntu we-[[IAmerica|America]] nomfundisi we -Baptist obekangumdosiphambili wehlangano yamalungelo wobuntu kusukela ngo-1955 bekwaba kulapho abulawa khona ngo-1968. Wathuthukisa amalungelo wobuntu wabantu bemibala e-United States ngokusebenzisa ukujamelana okunganabudlova nokungalaleli komphakathi ngokujamelana nemithetho ka-Jim Crow neminye imihlobo yokubandlulula esemthethweni, ebegade ithinteka khulu Ama-Afrika aseMelika .

Umdosiphambili webandla elimnyama, u-King wahlanganyela begodu wadosa phambili ematjhini wokufuna ilungelo lokuvowuda, ukuhlukaniswa, amalungelo wabasebenzi, namanye amalungelo womphakathi.&lt;ref&gt;https://revealnews.org/podcast/bayard-rustin-martin-luther-king-jr-black-history-month/&lt;/ref&gt; Waphatha ukudliwa kwamabhasi we-Montgomery ngo-1955 begodu waba ngumongameli wokuthoma we-Southern Christian Leadership Conference (SCLC), arhola i-Albany Movement engaphumeleliko e-Albany, Georgia, begodu wasiza ukuhlela imibhikisho enganabudlova yango-1963 e-Birmingham, Alabama. U-King bekamunye wabadosiphambili be-1963 March e-Washington, lapho anikela khona ikulumo yakhe ethi &quot;Nginephupho&quot;, begodu wasiza ukuhlela ama-match amabili kwamathathu we-Selma ukuya e-Montgomery ngesikhathi se-1965 Selma voting rights movement. Kwaba nokujamelana okukhulu nabaphathi abahlukanisako, ebegade baphendula ngolaka.[2] Umkhankaso wamalungelo wobuntu wazuza iinzuzo eziqakathekileko zomthetho emThethweni wamaLungelo woMphakathi ka-1964, umThetho wamaLungelo wokuVowuda ka-1965, kanye nomThetho weZindlu eziLungileko ka-1968.&lt;ref&gt;https://vocal.media/journal/jesse-jackson-the-living-bridge-between-martin-luther-king-jr-and-barack-obama&lt;/ref&gt;



U-King wavalelwa ejele kanengi. Umnqophisi we -Federal Bureau of Investigation (FBI) u-J. Edgar Hoover wathatha u-King njengomuntu oqakatheke khulu begodu wamenza waba yinto ye- COINTELPRO kusukela ngo-1963. Ama-ejenti we-FBI amphenyisisa bona angaba nobudlelwano bamakhomanisi, ahlola ipilo yakhe, begodu amrekhoda ngasese. Ngo-1964, i-FBI yathumela u-King incwadi ethusako engaziwako, ayihlathulula njengomzamo wokwenza bona azibulale.  U-King wathumba umvuzo we-Nobel Peace Prize ngo-1964 ngokulwisana nokungalingani ngokobuhlanga ngokusebenzisa ukujamelana okunganadlakela. Eminyakeni yakhe yokugcina, wandisa ukutjheja kwakhe ukufaka hlangana ukuphikiswa kobuphofu nePi ye-Vietnam .

== Ipilo yokuthoma nefundo ==

uKing Jr. wabelethwa mhlazi-15 kuTjhirhweni 1929, e- Atlanta, ngowesibili ebantwaneni abathathu baka- Michael King no -Alberta King ( née Williams ).  Ubaba ka-Alberta, u-Adam Daniel Williams,  bekangumfundisi we -Georgia emaphandleni, wathuthela e-Atlanta ngo-1893,  begodu waba mfundisi we- Ebenezer Baptist Church ngomnyaka olandelako.  U-Williams watjhada no-Jennie Celeste Parks. U-Michael Sr. wabelethwa babantu abahlanganyela abalimi u-James Albert no-Delia King be- Stockbridge, e-Georgia ;  kungenzeka bona bekavela ku -Mende ( Sierra Leone ).    Wabhalisa e- Morehouse College ukufunda ukungena emsebenzini.  U-Michael Sr. no-Alberta bathoma ukuthandana ngo-1920, begodu batjhada mhlazi-25 kuNobayeni 1926. &lt;ref&gt;https://www.npr.org/2026/01/18/g-s1-106127/martin-luther-king-jr-dream-health-care&lt;/ref&gt; Bekube sekufeni kwaka-Jennie ngo-1941, ikhaya labo belisesitezi sesibili sekhaya lababelethi baka-Alberta, lapho u-King abelethelwa khona. U-Michael Jr. bekanodadewabo omdala, u-Christine King Farris, nomfowabo omncani, u-Alfred Daniel King .&lt;ref&gt;https://www.usatoday.com/story/news/politics/2026/01/19/donald-trump-doesnt-acknowledge-martin-luther-king-jr-day/88252240007/&lt;/ref&gt;. uKing wabulawa mhlana ali-4 kuMrhayili 1968 abe no[[U-Jesse Jackson|Jesse Jackson]] kanye nabanye.

=== Inkomba===
{{reflist}}
[[Category:Amalungelo oluntu]]
[[Category:iAmerika]]
[[Category:Umlando]]</text>
      <sha1>0msuwukjqc07depc96egs4ssrjlsqpm</sha1>
    </revision>
  </page>
  <page>
    <title>Ipi ye-Vietnam</title>
    <ns>0</ns>
    <id>1047</id>
    <revision>
      <id>6214</id>
      <timestamp>2026-02-20T08:34:24Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1338427142|Vietnam War]]&quot;</comment>
      <origin>6214</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4417" sha1="lskqlf1b3y81bsonwp21hde7pwtjh9b" xml:space="preserve">'''Ipi ye-Vietnam''' (1 kuNobayeni 1955 [ A 1 ] – 30 kuMrhayili 1975) bekuyipi ehlomileko e- Vietnam, e-Laos, ne- Cambodia eyalwa hlangana ne -North Vietnam (i-Democratic Republic of Vietnam) ne- South Vietnam (i-Republic of Vietnam) nabalingani babo. I-North Vietnam beyisekelwa yi- Soviet Union ne -China, kuthi i-South Vietnam beyisekelwa yi- [[The United States|United States]] namanye amazwe aphikisana namakhomanisi . Ukulwa bekungokwesibili kwepi ye-Indochina begodu bekuyimpi ye- Cold War hlangana ne-Soviet Union ne-US. Ipi ye-Vietnam bekuyinye yepi yekululeko yesitjhaba yangemva kobukoloni, ithiyetha yePi yeKholoni, kanye nepi yomndeni, lapho ipi yombango iyinto eqakathekileko kusukela ekuthomeni.  Ukuzibandakanya kwamasotja we-US kwanda kusukela ngo-1965 bekwaba kulapho amabutho we-US ahoxiswa khona ngo-1973. Ukulwa kwagcwala ePini yomKhaya ye-Laotian ne-Cambodia, eyaphela lapho woke amazwe amathathu aba makhomanisi ngo-1975.

Ubujamo bokulwa bebuphawulwa yipi yama-guerrilla enesihluku nokutlhogeka kwemigqa yangaphambili yendabuko. Ngesikhathi amabutho we-U.S. newe-South Vietnamese athembele ebuchwephetjheni obuphezulu, amandla womoya, kanye namakhemikhali aqeda amakari afana ne-Agent Orange, i-North Vietnamese Army ne-Viet Cong basebenzisa indawo yamahlathi aminyeneko ukuze bazuze. Basebenzisa inethiwekhi ebanzi yemihubhe engaphasi komhlabathi kanye ne-Ho Chi Minh Trail ukuthoma ukuhlasela okungalindelekileko, okwenza bona kube budisi bona i-U.S. iphumelele ngokuzeleko nanyana ilimale abantu abanengi.

Ngemva kwesehlakalo se-Gulf of Tonkin ngo-1964, i-US Congress yadlulisa isiqunto esanikela uMongameli u-Lyndon B. Johnson igunya lokungezelela ubukhona bamasotja ngaphandle kokumemezela ipi. U-Johnson wathoma umkhankaso wokubhoma enyakatho begodu wathumela amabutho wepi, okwakhuphula khulu ukuthunyelwa kwabantu kwaba yi - 184,000 ngo-1966, kanye nama-536,000 ngo-1969. Ngo-1968, i-North Vietnam yathoma i- Tet Offensive, eyaba kukuhlulwa kwamaqhinga kodwana yenza bona ama-America amanengi akholwe bona ipi leyo angeze yanqotshwa. Umlandeli kaJohnson, u-Richard Nixon, wathoma &quot; i-Vietnamization &quot; kusukela ngo-1969, okwabona ukulwa kulwa yi-ARVN eyandisiweko ngesikhathi amabutho we-US ahoxa. Ukuvukela umbuso kwe-Cambodia ngo-1970 kwabangela ukuhlaselwa kwe-PAVN nokuhlaselwa kwe -US-ARVN, okwakhuphula ipi yayo yombango. Amasotja we-US besele ahoxe e-Vietnam ngo-1972, begodu iimvumelwano zokuthula ze-Paris zaka-1973 zabona abanye batjhiya. Iimvumelwano zaphulwa yi-North Vietnam, begodu ukulwa kwaragela phambili bekwaba kuhlasela kwentwasahlobo yango-1975 nokuwa kwe-Saigon ku-PAVN, okutjho ukuphela kwepi. I-North ne-South Vietnam yahlanganiswa godu ngo-1976.

Ipi le yabiza iindleko ezinengi khulu : kulinganiselwa bona amasotja we-Vietnam nabantu ababuleweko kusuka ku-970,000 ukuya ku-3 million. Ama-Cambodia angaba ma-275,000 ukuya ku-310,000, ama-Laotian angama-20,000 ukuya ku-62,000, kanye namalunga we-US angama-58,220 ahlongakala. [ A 7 ] Ukuphela kwepi bekuzokurhabisa abantu be-Vietnam abasesikepeni kanye nehlekelele ekulu yababaleki be-Indochina, eyabona iingidigidi zabantu zitjhiya i-Indochina, lapho abangaba zi-250,000 babhubha elwandle.   20% yehlathi leSewula Vietnam lafafazwa ngemithi yokubulala ukhula, okwabangela imiraro emikhulu yezamaphilo.  : 144–145  I -Khmer Rouge yenza ukubulawa kwabantu be-Cambodia, begodu iPi ye-Cambodia-Vietnamese yathoma ngo-1978. Ngokuphendula, i-China yahlasela i-Vietnam, ngokurarana kwemingcele kwaze kwaba ngu-1991. Ngaphakathi kwe-US, ipi yabangela i-Vietnam syndrome, ukuzonda ukuzibandakanya kwebutho le-America laphetjheya, , ihlazo le-Wagater, kwaba nomthelela ebujamweni bokuzithemba obuthinte i-United States ngabo-1970. 

== Isendlalelo ==
Ekuthomeni kwabo-1970, ipi besele ingasathandwa khulu ngaphakathi kwe-United States, lokho kwabanga imitjhagalo emikhulu yangekhaya kanye nokutjharagana kwezepolotiki. I-Tet Offensive yango-1968 yaba lithuba lokutjhuguluka kwengqondo, njengombana yatjengisa bona i-North beyikude nokuhlulwa, okurholele ekutheni i-U.S. iphume kabuthaka okwaziwa ngokuthi &quot;yi-Vietnamization.&quot; Ukurarana ekugcineni kwaphela ngoMrhayili wee-1975 lokha amabutho we-North Vietnamese nakathumba i-Saigon, ahlanganisa inarha ngaphasi kombuso wamakhomanisi begodu atjhiya ilifa lokulahlekelwa kwabantu okukhulu kanye nendlela etjhugulukileko yomthethokambiso wangaphandle wephasi loke.</text>
      <sha1>lskqlf1b3y81bsonwp21hde7pwtjh9b</sha1>
    </revision>
    <revision>
      <id>6215</id>
      <parentid>6214</parentid>
      <timestamp>2026-02-20T08:34:49Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6215</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4431" sha1="owvj0zacburwzexa6mtmlwiz9vrsrka" xml:space="preserve">'''Ipi ye-Vietnam''' (1 kuNobayeni 1955 [ A 1 ] – 30 kuMrhayili 1975) bekuyipi ehlomileko e- Vietnam, e-Laos, ne- Cambodia eyalwa hlangana ne -North Vietnam (i-Democratic Republic of Vietnam) ne- South Vietnam (i-Republic of Vietnam) nabalingani babo. I-North Vietnam beyisekelwa yi- Soviet Union ne -China, kuthi i-South Vietnam beyisekelwa yi- [[The United States|United States]] namanye amazwe aphikisana namakhomanisi . Ukulwa bekungokwesibili kwepi ye-Indochina begodu bekuyimpi ye- Cold War hlangana ne-Soviet Union ne-US. Ipi ye-Vietnam bekuyinye yepi yekululeko yesitjhaba yangemva kobukoloni, ithiyetha yePi yeKholoni, kanye nepi yomndeni, lapho ipi yombango iyinto eqakathekileko kusukela ekuthomeni.  Ukuzibandakanya kwamasotja we-US kwanda kusukela ngo-1965 bekwaba kulapho amabutho we-US ahoxiswa khona ngo-1973. Ukulwa kwagcwala ePini yomKhaya ye-Laotian ne-Cambodia, eyaphela lapho woke amazwe amathathu aba makhomanisi ngo-1975.

== Umlando ==
Ubujamo bokulwa bebuphawulwa yipi yama-guerrilla enesihluku nokutlhogeka kwemigqa yangaphambili yendabuko. Ngesikhathi amabutho we-U.S. newe-South Vietnamese athembele ebuchwephetjheni obuphezulu, amandla womoya, kanye namakhemikhali aqeda amakari afana ne-Agent Orange, i-North Vietnamese Army ne-Viet Cong basebenzisa indawo yamahlathi aminyeneko ukuze bazuze. Basebenzisa inethiwekhi ebanzi yemihubhe engaphasi komhlabathi kanye ne-Ho Chi Minh Trail ukuthoma ukuhlasela okungalindelekileko, okwenza bona kube budisi bona i-U.S. iphumelele ngokuzeleko nanyana ilimale abantu abanengi.

Ngemva kwesehlakalo se-Gulf of Tonkin ngo-1964, i-US Congress yadlulisa isiqunto esanikela uMongameli u-Lyndon B. Johnson igunya lokungezelela ubukhona bamasotja ngaphandle kokumemezela ipi. U-Johnson wathoma umkhankaso wokubhoma enyakatho begodu wathumela amabutho wepi, okwakhuphula khulu ukuthunyelwa kwabantu kwaba yi - 184,000 ngo-1966, kanye nama-536,000 ngo-1969. Ngo-1968, i-North Vietnam yathoma i- Tet Offensive, eyaba kukuhlulwa kwamaqhinga kodwana yenza bona ama-America amanengi akholwe bona ipi leyo angeze yanqotshwa. Umlandeli kaJohnson, u-Richard Nixon, wathoma &quot; i-Vietnamization &quot; kusukela ngo-1969, okwabona ukulwa kulwa yi-ARVN eyandisiweko ngesikhathi amabutho we-US ahoxa. Ukuvukela umbuso kwe-Cambodia ngo-1970 kwabangela ukuhlaselwa kwe-PAVN nokuhlaselwa kwe -US-ARVN, okwakhuphula ipi yayo yombango. Amasotja we-US besele ahoxe e-Vietnam ngo-1972, begodu iimvumelwano zokuthula ze-Paris zaka-1973 zabona abanye batjhiya. Iimvumelwano zaphulwa yi-North Vietnam, begodu ukulwa kwaragela phambili bekwaba kuhlasela kwentwasahlobo yango-1975 nokuwa kwe-Saigon ku-PAVN, okutjho ukuphela kwepi. I-North ne-South Vietnam yahlanganiswa godu ngo-1976.

Ipi le yabiza iindleko ezinengi khulu : kulinganiselwa bona amasotja we-Vietnam nabantu ababuleweko kusuka ku-970,000 ukuya ku-3 million. Ama-Cambodia angaba ma-275,000 ukuya ku-310,000, ama-Laotian angama-20,000 ukuya ku-62,000, kanye namalunga we-US angama-58,220 ahlongakala. [ A 7 ] Ukuphela kwepi bekuzokurhabisa abantu be-Vietnam abasesikepeni kanye nehlekelele ekulu yababaleki be-Indochina, eyabona iingidigidi zabantu zitjhiya i-Indochina, lapho abangaba zi-250,000 babhubha elwandle.   20% yehlathi leSewula Vietnam lafafazwa ngemithi yokubulala ukhula, okwabangela imiraro emikhulu yezamaphilo.  : 144–145  I -Khmer Rouge yenza ukubulawa kwabantu be-Cambodia, begodu iPi ye-Cambodia-Vietnamese yathoma ngo-1978. Ngokuphendula, i-China yahlasela i-Vietnam, ngokurarana kwemingcele kwaze kwaba ngu-1991. Ngaphakathi kwe-US, ipi yabangela i-Vietnam syndrome, ukuzonda ukuzibandakanya kwebutho le-America laphetjheya, , ihlazo le-Wagater, kwaba nomthelela ebujamweni bokuzithemba obuthinte i-United States ngabo-1970. 

== Isendlalelo ==
Ekuthomeni kwabo-1970, ipi besele ingasathandwa khulu ngaphakathi kwe-United States, lokho kwabanga imitjhagalo emikhulu yangekhaya kanye nokutjharagana kwezepolotiki. I-Tet Offensive yango-1968 yaba lithuba lokutjhuguluka kwengqondo, njengombana yatjengisa bona i-North beyikude nokuhlulwa, okurholele ekutheni i-U.S. iphume kabuthaka okwaziwa ngokuthi &quot;yi-Vietnamization.&quot; Ukurarana ekugcineni kwaphela ngoMrhayili wee-1975 lokha amabutho we-North Vietnamese nakathumba i-Saigon, ahlanganisa inarha ngaphasi kombuso wamakhomanisi begodu atjhiya ilifa lokulahlekelwa kwabantu okukhulu kanye nendlela etjhugulukileko yomthethokambiso wangaphandle wephasi loke.</text>
      <sha1>owvj0zacburwzexa6mtmlwiz9vrsrka</sha1>
    </revision>
    <revision>
      <id>6216</id>
      <parentid>6215</parentid>
      <timestamp>2026-02-20T08:35:33Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6216</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4486" sha1="fgx34a2dcivfoqxoruyq369cvo9vgu4" xml:space="preserve">'''Ipi ye-Vietnam''' (1 kuNobayeni 1955 [ A 1 ] – 30 kuMrhayili 1975) bekuyipi ehlomileko e- Vietnam, e-Laos, ne- Cambodia eyalwa hlangana ne -North Vietnam (i-Democratic Republic of Vietnam) ne- South Vietnam (i-Republic of Vietnam) nabalingani babo. I-North Vietnam beyisekelwa yi- Soviet Union ne -China, kuthi i-South Vietnam beyisekelwa yi- [[The United States|United States]] namanye amazwe aphikisana namakhomanisi . Ukulwa bekungokwesibili kwepi ye-Indochina begodu bekuyimpi ye- Cold War hlangana ne-Soviet Union ne-US. Ipi ye-Vietnam bekuyinye yepi yekululeko yesitjhaba yangemva kobukoloni, ithiyetha yePi yeKholoni, kanye nepi yomndeni, lapho ipi yombango iyinto eqakathekileko kusukela ekuthomeni.  Ukuzibandakanya kwamasotja we-US kwanda kusukela ngo-1965 bekwaba kulapho amabutho we-US ahoxiswa khona ngo-1973. Ukulwa kwagcwala ePini yomKhaya ye-Laotian ne-Cambodia, eyaphela lapho woke amazwe amathathu aba makhomanisi ngo-1975.&lt;ref&gt;https://www.britannica.com/event/Vietnam-War&lt;/ref&gt;

== Umlando ==
Ubujamo bokulwa bebuphawulwa yipi yama-guerrilla enesihluku nokutlhogeka kwemigqa yangaphambili yendabuko. Ngesikhathi amabutho we-U.S. newe-South Vietnamese athembele ebuchwephetjheni obuphezulu, amandla womoya, kanye namakhemikhali aqeda amakari afana ne-Agent Orange, i-North Vietnamese Army ne-Viet Cong basebenzisa indawo yamahlathi aminyeneko ukuze bazuze. Basebenzisa inethiwekhi ebanzi yemihubhe engaphasi komhlabathi kanye ne-Ho Chi Minh Trail ukuthoma ukuhlasela okungalindelekileko, okwenza bona kube budisi bona i-U.S. iphumelele ngokuzeleko nanyana ilimale abantu abanengi.

Ngemva kwesehlakalo se-Gulf of Tonkin ngo-1964, i-US Congress yadlulisa isiqunto esanikela uMongameli u-Lyndon B. Johnson igunya lokungezelela ubukhona bamasotja ngaphandle kokumemezela ipi. U-Johnson wathoma umkhankaso wokubhoma enyakatho begodu wathumela amabutho wepi, okwakhuphula khulu ukuthunyelwa kwabantu kwaba yi - 184,000 ngo-1966, kanye nama-536,000 ngo-1969. Ngo-1968, i-North Vietnam yathoma i- Tet Offensive, eyaba kukuhlulwa kwamaqhinga kodwana yenza bona ama-America amanengi akholwe bona ipi leyo angeze yanqotshwa. Umlandeli kaJohnson, u-Richard Nixon, wathoma &quot; i-Vietnamization &quot; kusukela ngo-1969, okwabona ukulwa kulwa yi-ARVN eyandisiweko ngesikhathi amabutho we-US ahoxa. Ukuvukela umbuso kwe-Cambodia ngo-1970 kwabangela ukuhlaselwa kwe-PAVN nokuhlaselwa kwe -US-ARVN, okwakhuphula ipi yayo yombango. Amasotja we-US besele ahoxe e-Vietnam ngo-1972, begodu iimvumelwano zokuthula ze-Paris zaka-1973 zabona abanye batjhiya. Iimvumelwano zaphulwa yi-North Vietnam, begodu ukulwa kwaragela phambili bekwaba kuhlasela kwentwasahlobo yango-1975 nokuwa kwe-Saigon ku-PAVN, okutjho ukuphela kwepi. I-North ne-South Vietnam yahlanganiswa godu ngo-1976.

Ipi le yabiza iindleko ezinengi khulu : kulinganiselwa bona amasotja we-Vietnam nabantu ababuleweko kusuka ku-970,000 ukuya ku-3 million. Ama-Cambodia angaba ma-275,000 ukuya ku-310,000, ama-Laotian angama-20,000 ukuya ku-62,000, kanye namalunga we-US angama-58,220 ahlongakala. [ A 7 ] Ukuphela kwepi bekuzokurhabisa abantu be-Vietnam abasesikepeni kanye nehlekelele ekulu yababaleki be-Indochina, eyabona iingidigidi zabantu zitjhiya i-Indochina, lapho abangaba zi-250,000 babhubha elwandle.   20% yehlathi leSewula Vietnam lafafazwa ngemithi yokubulala ukhula, okwabangela imiraro emikhulu yezamaphilo.  : 144–145  I -Khmer Rouge yenza ukubulawa kwabantu be-Cambodia, begodu iPi ye-Cambodia-Vietnamese yathoma ngo-1978. Ngokuphendula, i-China yahlasela i-Vietnam, ngokurarana kwemingcele kwaze kwaba ngu-1991. Ngaphakathi kwe-US, ipi yabangela i-Vietnam syndrome, ukuzonda ukuzibandakanya kwebutho le-America laphetjheya, , ihlazo le-Wagater, kwaba nomthelela ebujamweni bokuzithemba obuthinte i-United States ngabo-1970. 

== Isendlalelo ==
Ekuthomeni kwabo-1970, ipi besele ingasathandwa khulu ngaphakathi kwe-United States, lokho kwabanga imitjhagalo emikhulu yangekhaya kanye nokutjharagana kwezepolotiki. I-Tet Offensive yango-1968 yaba lithuba lokutjhuguluka kwengqondo, njengombana yatjengisa bona i-North beyikude nokuhlulwa, okurholele ekutheni i-U.S. iphume kabuthaka okwaziwa ngokuthi &quot;yi-Vietnamization.&quot; Ukurarana ekugcineni kwaphela ngoMrhayili wee-1975 lokha amabutho we-North Vietnamese nakathumba i-Saigon, ahlanganisa inarha ngaphasi kombuso wamakhomanisi begodu atjhiya ilifa lokulahlekelwa kwabantu okukhulu kanye nendlela etjhugulukileko yomthethokambiso wangaphandle wephasi loke.</text>
      <sha1>fgx34a2dcivfoqxoruyq369cvo9vgu4</sha1>
    </revision>
    <revision>
      <id>6217</id>
      <parentid>6216</parentid>
      <timestamp>2026-02-20T08:35:58Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6217</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4575" sha1="dgopgiiy56bdzvoju1mjex6rt5ait7i" xml:space="preserve">'''Ipi ye-Vietnam''' (1 kuNobayeni 1955 [ A 1 ] – 30 kuMrhayili 1975) bekuyipi ehlomileko e- Vietnam, e-Laos, ne- Cambodia eyalwa hlangana ne -North Vietnam (i-Democratic Republic of Vietnam) ne- South Vietnam (i-Republic of Vietnam) nabalingani babo. I-North Vietnam beyisekelwa yi- Soviet Union ne -China, kuthi i-South Vietnam beyisekelwa yi- [[The United States|United States]] namanye amazwe aphikisana namakhomanisi . Ukulwa bekungokwesibili kwepi ye-Indochina begodu bekuyimpi ye- Cold War hlangana ne-Soviet Union ne-US. Ipi ye-Vietnam bekuyinye yepi yekululeko yesitjhaba yangemva kobukoloni, ithiyetha yePi yeKholoni, kanye nepi yomndeni, lapho ipi yombango iyinto eqakathekileko kusukela ekuthomeni.  Ukuzibandakanya kwamasotja we-US kwanda kusukela ngo-1965 bekwaba kulapho amabutho we-US ahoxiswa khona ngo-1973. Ukulwa kwagcwala ePini yomKhaya ye-Laotian ne-Cambodia, eyaphela lapho woke amazwe amathathu aba makhomanisi ngo-1975.&lt;ref&gt;https://www.britannica.com/event/Vietnam-War&lt;/ref&gt;

== Umlando ==
Ubujamo bokulwa bebuphawulwa yipi yama-guerrilla enesihluku nokutlhogeka kwemigqa yangaphambili yendabuko. Ngesikhathi amabutho we-U.S. newe-South Vietnamese athembele ebuchwephetjheni obuphezulu, amandla womoya, kanye namakhemikhali aqeda amakari afana ne-Agent Orange, i-North Vietnamese Army ne-Viet Cong basebenzisa indawo yamahlathi aminyeneko ukuze bazuze. Basebenzisa inethiwekhi ebanzi yemihubhe engaphasi komhlabathi kanye ne-Ho Chi Minh Trail ukuthoma ukuhlasela okungalindelekileko, okwenza bona kube budisi bona i-U.S. iphumelele ngokuzeleko nanyana ilimale abantu abanengi.&lt;ref&gt;https://www.politico.com/news/2026/02/19/trump-arlington-arch-lawsuit-00789763&lt;/ref&gt;

Ngemva kwesehlakalo se-Gulf of Tonkin ngo-1964, i-US Congress yadlulisa isiqunto esanikela uMongameli u-Lyndon B. Johnson igunya lokungezelela ubukhona bamasotja ngaphandle kokumemezela ipi. U-Johnson wathoma umkhankaso wokubhoma enyakatho begodu wathumela amabutho wepi, okwakhuphula khulu ukuthunyelwa kwabantu kwaba yi - 184,000 ngo-1966, kanye nama-536,000 ngo-1969. Ngo-1968, i-North Vietnam yathoma i- Tet Offensive, eyaba kukuhlulwa kwamaqhinga kodwana yenza bona ama-America amanengi akholwe bona ipi leyo angeze yanqotshwa. Umlandeli kaJohnson, u-Richard Nixon, wathoma &quot; i-Vietnamization &quot; kusukela ngo-1969, okwabona ukulwa kulwa yi-ARVN eyandisiweko ngesikhathi amabutho we-US ahoxa. Ukuvukela umbuso kwe-Cambodia ngo-1970 kwabangela ukuhlaselwa kwe-PAVN nokuhlaselwa kwe -US-ARVN, okwakhuphula ipi yayo yombango. Amasotja we-US besele ahoxe e-Vietnam ngo-1972, begodu iimvumelwano zokuthula ze-Paris zaka-1973 zabona abanye batjhiya. Iimvumelwano zaphulwa yi-North Vietnam, begodu ukulwa kwaragela phambili bekwaba kuhlasela kwentwasahlobo yango-1975 nokuwa kwe-Saigon ku-PAVN, okutjho ukuphela kwepi. I-North ne-South Vietnam yahlanganiswa godu ngo-1976.

Ipi le yabiza iindleko ezinengi khulu : kulinganiselwa bona amasotja we-Vietnam nabantu ababuleweko kusuka ku-970,000 ukuya ku-3 million. Ama-Cambodia angaba ma-275,000 ukuya ku-310,000, ama-Laotian angama-20,000 ukuya ku-62,000, kanye namalunga we-US angama-58,220 ahlongakala. [ A 7 ] Ukuphela kwepi bekuzokurhabisa abantu be-Vietnam abasesikepeni kanye nehlekelele ekulu yababaleki be-Indochina, eyabona iingidigidi zabantu zitjhiya i-Indochina, lapho abangaba zi-250,000 babhubha elwandle.   20% yehlathi leSewula Vietnam lafafazwa ngemithi yokubulala ukhula, okwabangela imiraro emikhulu yezamaphilo.  : 144–145  I -Khmer Rouge yenza ukubulawa kwabantu be-Cambodia, begodu iPi ye-Cambodia-Vietnamese yathoma ngo-1978. Ngokuphendula, i-China yahlasela i-Vietnam, ngokurarana kwemingcele kwaze kwaba ngu-1991. Ngaphakathi kwe-US, ipi yabangela i-Vietnam syndrome, ukuzonda ukuzibandakanya kwebutho le-America laphetjheya, , ihlazo le-Wagater, kwaba nomthelela ebujamweni bokuzithemba obuthinte i-United States ngabo-1970. 

== Isendlalelo ==
Ekuthomeni kwabo-1970, ipi besele ingasathandwa khulu ngaphakathi kwe-United States, lokho kwabanga imitjhagalo emikhulu yangekhaya kanye nokutjharagana kwezepolotiki. I-Tet Offensive yango-1968 yaba lithuba lokutjhuguluka kwengqondo, njengombana yatjengisa bona i-North beyikude nokuhlulwa, okurholele ekutheni i-U.S. iphume kabuthaka okwaziwa ngokuthi &quot;yi-Vietnamization.&quot; Ukurarana ekugcineni kwaphela ngoMrhayili wee-1975 lokha amabutho we-North Vietnamese nakathumba i-Saigon, ahlanganisa inarha ngaphasi kombuso wamakhomanisi begodu atjhiya ilifa lokulahlekelwa kwabantu okukhulu kanye nendlela etjhugulukileko yomthethokambiso wangaphandle wephasi loke.</text>
      <sha1>dgopgiiy56bdzvoju1mjex6rt5ait7i</sha1>
    </revision>
    <revision>
      <id>6218</id>
      <parentid>6217</parentid>
      <timestamp>2026-02-20T08:36:21Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>/* Umlando */</comment>
      <origin>6218</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4668" sha1="feqd515jc37ulz100chkj4mcq7xy85h" xml:space="preserve">'''Ipi ye-Vietnam''' (1 kuNobayeni 1955 [ A 1 ] – 30 kuMrhayili 1975) bekuyipi ehlomileko e- Vietnam, e-Laos, ne- Cambodia eyalwa hlangana ne -North Vietnam (i-Democratic Republic of Vietnam) ne- South Vietnam (i-Republic of Vietnam) nabalingani babo. I-North Vietnam beyisekelwa yi- Soviet Union ne -China, kuthi i-South Vietnam beyisekelwa yi- [[The United States|United States]] namanye amazwe aphikisana namakhomanisi . Ukulwa bekungokwesibili kwepi ye-Indochina begodu bekuyimpi ye- Cold War hlangana ne-Soviet Union ne-US. Ipi ye-Vietnam bekuyinye yepi yekululeko yesitjhaba yangemva kobukoloni, ithiyetha yePi yeKholoni, kanye nepi yomndeni, lapho ipi yombango iyinto eqakathekileko kusukela ekuthomeni.  Ukuzibandakanya kwamasotja we-US kwanda kusukela ngo-1965 bekwaba kulapho amabutho we-US ahoxiswa khona ngo-1973. Ukulwa kwagcwala ePini yomKhaya ye-Laotian ne-Cambodia, eyaphela lapho woke amazwe amathathu aba makhomanisi ngo-1975.&lt;ref&gt;https://www.britannica.com/event/Vietnam-War&lt;/ref&gt;

== Umlando ==
Ubujamo bokulwa bebuphawulwa yipi yama-guerrilla enesihluku nokutlhogeka kwemigqa yangaphambili yendabuko. Ngesikhathi amabutho we-U.S. newe-South Vietnamese athembele ebuchwephetjheni obuphezulu, amandla womoya, kanye namakhemikhali aqeda amakari afana ne-Agent Orange, i-North Vietnamese Army ne-Viet Cong basebenzisa indawo yamahlathi aminyeneko ukuze bazuze. Basebenzisa inethiwekhi ebanzi yemihubhe engaphasi komhlabathi kanye ne-Ho Chi Minh Trail ukuthoma ukuhlasela okungalindelekileko, okwenza bona kube budisi bona i-U.S. iphumelele ngokuzeleko nanyana ilimale abantu abanengi.&lt;ref&gt;https://www.politico.com/news/2026/02/19/trump-arlington-arch-lawsuit-00789763&lt;/ref&gt;

Ngemva kwesehlakalo se-Gulf of Tonkin ngo-1964, i-US Congress yadlulisa isiqunto esanikela uMongameli u-Lyndon B. Johnson igunya lokungezelela ubukhona bamasotja ngaphandle kokumemezela ipi. U-Johnson wathoma umkhankaso wokubhoma enyakatho begodu wathumela amabutho wepi, okwakhuphula khulu ukuthunyelwa kwabantu kwaba yi - 184,000 ngo-1966, kanye nama-536,000 ngo-1969. Ngo-1968, i-North Vietnam yathoma i- Tet Offensive, eyaba kukuhlulwa kwamaqhinga kodwana yenza bona ama-America amanengi akholwe bona ipi leyo angeze yanqotshwa. Umlandeli kaJohnson, u-Richard Nixon, wathoma &quot; i-Vietnamization &quot; kusukela ngo-1969, okwabona ukulwa kulwa yi-ARVN eyandisiweko ngesikhathi amabutho we-US ahoxa. Ukuvukela umbuso kwe-Cambodia ngo-1970 kwabangela ukuhlaselwa kwe-PAVN nokuhlaselwa kwe -US-ARVN, okwakhuphula ipi yayo yombango. Amasotja we-US besele ahoxe e-Vietnam ngo-1972, begodu iimvumelwano zokuthula ze-Paris zaka-1973 zabona abanye batjhiya. Iimvumelwano zaphulwa yi-North Vietnam, begodu ukulwa kwaragela phambili bekwaba kuhlasela kwentwasahlobo yango-1975 nokuwa kwe-Saigon ku-PAVN, okutjho ukuphela kwepi. I-North ne-South Vietnam yahlanganiswa godu ngo-1976.&lt;ref&gt;https://thehill.com/regulation/court-battles/5746932-trump-triumphal-arch-lawsuit/&lt;/ref&gt;

Ipi le yabiza iindleko ezinengi khulu : kulinganiselwa bona amasotja we-Vietnam nabantu ababuleweko kusuka ku-970,000 ukuya ku-3 million. Ama-Cambodia angaba ma-275,000 ukuya ku-310,000, ama-Laotian angama-20,000 ukuya ku-62,000, kanye namalunga we-US angama-58,220 ahlongakala. [ A 7 ] Ukuphela kwepi bekuzokurhabisa abantu be-Vietnam abasesikepeni kanye nehlekelele ekulu yababaleki be-Indochina, eyabona iingidigidi zabantu zitjhiya i-Indochina, lapho abangaba zi-250,000 babhubha elwandle.   20% yehlathi leSewula Vietnam lafafazwa ngemithi yokubulala ukhula, okwabangela imiraro emikhulu yezamaphilo.  : 144–145  I -Khmer Rouge yenza ukubulawa kwabantu be-Cambodia, begodu iPi ye-Cambodia-Vietnamese yathoma ngo-1978. Ngokuphendula, i-China yahlasela i-Vietnam, ngokurarana kwemingcele kwaze kwaba ngu-1991. Ngaphakathi kwe-US, ipi yabangela i-Vietnam syndrome, ukuzonda ukuzibandakanya kwebutho le-America laphetjheya, , ihlazo le-Wagater, kwaba nomthelela ebujamweni bokuzithemba obuthinte i-United States ngabo-1970. 

== Isendlalelo ==
Ekuthomeni kwabo-1970, ipi besele ingasathandwa khulu ngaphakathi kwe-United States, lokho kwabanga imitjhagalo emikhulu yangekhaya kanye nokutjharagana kwezepolotiki. I-Tet Offensive yango-1968 yaba lithuba lokutjhuguluka kwengqondo, njengombana yatjengisa bona i-North beyikude nokuhlulwa, okurholele ekutheni i-U.S. iphume kabuthaka okwaziwa ngokuthi &quot;yi-Vietnamization.&quot; Ukurarana ekugcineni kwaphela ngoMrhayili wee-1975 lokha amabutho we-North Vietnamese nakathumba i-Saigon, ahlanganisa inarha ngaphasi kombuso wamakhomanisi begodu atjhiya ilifa lokulahlekelwa kwabantu okukhulu kanye nendlela etjhugulukileko yomthethokambiso wangaphandle wephasi loke.</text>
      <sha1>feqd515jc37ulz100chkj4mcq7xy85h</sha1>
    </revision>
    <revision>
      <id>6219</id>
      <parentid>6218</parentid>
      <timestamp>2026-02-20T08:36:51Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6219</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4947" sha1="8knd23b8ukf30v2pbii14kuhg4s9l4u" xml:space="preserve">'''Ipi ye-Vietnam''' (1 kuNobayeni 1955 [ A 1 ] – 30 kuMrhayili 1975) bekuyipi ehlomileko e- Vietnam, e-Laos, ne- Cambodia eyalwa hlangana ne -North Vietnam (i-Democratic Republic of Vietnam) ne- South Vietnam (i-Republic of Vietnam) nabalingani babo. I-North Vietnam beyisekelwa yi- Soviet Union ne -China, kuthi i-South Vietnam beyisekelwa yi- [[The United States|United States]] namanye amazwe aphikisana namakhomanisi . Ukulwa bekungokwesibili kwepi ye-Indochina begodu bekuyimpi ye- Cold War hlangana ne-Soviet Union ne-US. Ipi ye-Vietnam bekuyinye yepi yekululeko yesitjhaba yangemva kobukoloni, ithiyetha yePi yeKholoni, kanye nepi yomndeni, lapho ipi yombango iyinto eqakathekileko kusukela ekuthomeni.  Ukuzibandakanya kwamasotja we-US kwanda kusukela ngo-1965 bekwaba kulapho amabutho we-US ahoxiswa khona ngo-1973. Ukulwa kwagcwala ePini yomKhaya ye-Laotian ne-Cambodia, eyaphela lapho woke amazwe amathathu aba makhomanisi ngo-1975.&lt;ref&gt;https://www.britannica.com/event/Vietnam-War&lt;/ref&gt;

== Umlando ==
Ubujamo bokulwa bebuphawulwa yipi yama-guerrilla enesihluku nokutlhogeka kwemigqa yangaphambili yendabuko. Ngesikhathi amabutho we-U.S. newe-South Vietnamese athembele ebuchwephetjheni obuphezulu, amandla womoya, kanye namakhemikhali aqeda amakari afana ne-Agent Orange, i-North Vietnamese Army ne-Viet Cong basebenzisa indawo yamahlathi aminyeneko ukuze bazuze. Basebenzisa inethiwekhi ebanzi yemihubhe engaphasi komhlabathi kanye ne-Ho Chi Minh Trail ukuthoma ukuhlasela okungalindelekileko, okwenza bona kube budisi bona i-U.S. iphumelele ngokuzeleko nanyana ilimale abantu abanengi.&lt;ref&gt;https://www.politico.com/news/2026/02/19/trump-arlington-arch-lawsuit-00789763&lt;/ref&gt;

Ngemva kwesehlakalo se-Gulf of Tonkin ngo-1964, i-US Congress yadlulisa isiqunto esanikela uMongameli u-Lyndon B. Johnson igunya lokungezelela ubukhona bamasotja ngaphandle kokumemezela ipi. U-Johnson wathoma umkhankaso wokubhoma enyakatho begodu wathumela amabutho wepi, okwakhuphula khulu ukuthunyelwa kwabantu kwaba yi - 184,000 ngo-1966, kanye nama-536,000 ngo-1969. Ngo-1968, i-North Vietnam yathoma i- Tet Offensive, eyaba kukuhlulwa kwamaqhinga kodwana yenza bona ama-America amanengi akholwe bona ipi leyo angeze yanqotshwa. Umlandeli kaJohnson, u-Richard Nixon, wathoma &quot; i-Vietnamization &quot; kusukela ngo-1969, okwabona ukulwa kulwa yi-ARVN eyandisiweko ngesikhathi amabutho we-US ahoxa. Ukuvukela umbuso kwe-Cambodia ngo-1970 kwabangela ukuhlaselwa kwe-PAVN nokuhlaselwa kwe -US-ARVN, okwakhuphula ipi yayo yombango. Amasotja we-US besele ahoxe e-Vietnam ngo-1972, begodu iimvumelwano zokuthula ze-Paris zaka-1973 zabona abanye batjhiya. Iimvumelwano zaphulwa yi-North Vietnam, begodu ukulwa kwaragela phambili bekwaba kuhlasela kwentwasahlobo yango-1975 nokuwa kwe-Saigon ku-PAVN, okutjho ukuphela kwepi. I-North ne-South Vietnam yahlanganiswa godu ngo-1976.&lt;ref&gt;https://thehill.com/regulation/court-battles/5746932-trump-triumphal-arch-lawsuit/&lt;/ref&gt;

Ipi le yabiza iindleko ezinengi khulu : kulinganiselwa bona amasotja we-Vietnam nabantu ababuleweko kusuka ku-970,000 ukuya ku-3 million. Ama-Cambodia angaba ma-275,000 ukuya ku-310,000, ama-Laotian angama-20,000 ukuya ku-62,000, kanye namalunga we-US angama-58,220 ahlongakala. [ A 7 ] Ukuphela kwepi bekuzokurhabisa abantu be-Vietnam abasesikepeni kanye nehlekelele ekulu yababaleki be-Indochina, eyabona iingidigidi zabantu zitjhiya i-Indochina, lapho abangaba zi-250,000 babhubha elwandle.   20% yehlathi leSewula Vietnam lafafazwa ngemithi yokubulala ukhula, okwabangela imiraro emikhulu yezamaphilo.  : 144–145  I -Khmer Rouge yenza ukubulawa kwabantu be-Cambodia, begodu iPi ye-Cambodia-Vietnamese yathoma ngo-1978. Ngokuphendula, i-China yahlasela i-Vietnam, ngokurarana kwemingcele kwaze kwaba ngu-1991. Ngaphakathi kwe-US, ipi yabangela i-Vietnam syndrome, ukuzonda ukuzibandakanya kwebutho le-America laphetjheya, , ihlazo le-Wagater, kwaba nomthelela ebujamweni bokuzithemba obuthinte i-United States ngabo-1970.&lt;ref&gt;https://wjla.com/news/local/president-donald-trump-triumphal-arch-monument-statue-lawsuit-vietnam-war-veterans-national-park-service-lincoln-memorial-arlington-cemetary-america-250-white-house-projects-historic-views-landmarks-plans-costs-view-obscurity-traffic-safety&lt;/ref&gt; 

== Isendlalelo ==
Ekuthomeni kwabo-1970, ipi besele ingasathandwa khulu ngaphakathi kwe-United States, lokho kwabanga imitjhagalo emikhulu yangekhaya kanye nokutjharagana kwezepolotiki. I-Tet Offensive yango-1968 yaba lithuba lokutjhuguluka kwengqondo, njengombana yatjengisa bona i-North beyikude nokuhlulwa, okurholele ekutheni i-U.S. iphume kabuthaka okwaziwa ngokuthi &quot;yi-Vietnamization.&quot; Ukurarana ekugcineni kwaphela ngoMrhayili wee-1975 lokha amabutho we-North Vietnamese nakathumba i-Saigon, ahlanganisa inarha ngaphasi kombuso wamakhomanisi begodu atjhiya ilifa lokulahlekelwa kwabantu okukhulu kanye nendlela etjhugulukileko yomthethokambiso wangaphandle wephasi loke.</text>
      <sha1>8knd23b8ukf30v2pbii14kuhg4s9l4u</sha1>
    </revision>
    <revision>
      <id>6220</id>
      <parentid>6219</parentid>
      <timestamp>2026-02-20T08:37:28Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6220</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5032" sha1="dw45afl5gma8bwnk2q7gkxhdpccy7un" xml:space="preserve">'''Ipi ye-Vietnam''' (1 kuNobayeni 1955 [ A 1 ] – 30 kuMrhayili 1975) bekuyipi ehlomileko e- Vietnam, e-Laos, ne- Cambodia eyalwa hlangana ne -North Vietnam (i-Democratic Republic of Vietnam) ne- South Vietnam (i-Republic of Vietnam) nabalingani babo. I-North Vietnam beyisekelwa yi- Soviet Union ne -China, kuthi i-South Vietnam beyisekelwa yi- [[The United States|United States]] namanye amazwe aphikisana namakhomanisi . Ukulwa bekungokwesibili kwepi ye-Indochina begodu bekuyimpi ye- Cold War hlangana ne-Soviet Union ne-US. Ipi ye-Vietnam bekuyinye yepi yekululeko yesitjhaba yangemva kobukoloni, ithiyetha yePi yeKholoni, kanye nepi yomndeni, lapho ipi yombango iyinto eqakathekileko kusukela ekuthomeni.  Ukuzibandakanya kwamasotja we-US kwanda kusukela ngo-1965 bekwaba kulapho amabutho we-US ahoxiswa khona ngo-1973. Ukulwa kwagcwala ePini yomKhaya ye-Laotian ne-Cambodia, eyaphela lapho woke amazwe amathathu aba makhomanisi ngo-1975.&lt;ref&gt;https://www.britannica.com/event/Vietnam-War&lt;/ref&gt;

== Umlando ==
Ubujamo bokulwa bebuphawulwa yipi yama-guerrilla enesihluku nokutlhogeka kwemigqa yangaphambili yendabuko. Ngesikhathi amabutho we-U.S. newe-South Vietnamese athembele ebuchwephetjheni obuphezulu, amandla womoya, kanye namakhemikhali aqeda amakari afana ne-Agent Orange, i-North Vietnamese Army ne-Viet Cong basebenzisa indawo yamahlathi aminyeneko ukuze bazuze. Basebenzisa inethiwekhi ebanzi yemihubhe engaphasi komhlabathi kanye ne-Ho Chi Minh Trail ukuthoma ukuhlasela okungalindelekileko, okwenza bona kube budisi bona i-U.S. iphumelele ngokuzeleko nanyana ilimale abantu abanengi.&lt;ref&gt;https://www.politico.com/news/2026/02/19/trump-arlington-arch-lawsuit-00789763&lt;/ref&gt;

Ngemva kwesehlakalo se-Gulf of Tonkin ngo-1964, i-US Congress yadlulisa isiqunto esanikela uMongameli u-Lyndon B. Johnson igunya lokungezelela ubukhona bamasotja ngaphandle kokumemezela ipi. U-Johnson wathoma umkhankaso wokubhoma enyakatho begodu wathumela amabutho wepi, okwakhuphula khulu ukuthunyelwa kwabantu kwaba yi - 184,000 ngo-1966, kanye nama-536,000 ngo-1969. Ngo-1968, i-North Vietnam yathoma i- Tet Offensive, eyaba kukuhlulwa kwamaqhinga kodwana yenza bona ama-America amanengi akholwe bona ipi leyo angeze yanqotshwa. Umlandeli kaJohnson, u-Richard Nixon, wathoma &quot; i-Vietnamization &quot; kusukela ngo-1969, okwabona ukulwa kulwa yi-ARVN eyandisiweko ngesikhathi amabutho we-US ahoxa. Ukuvukela umbuso kwe-Cambodia ngo-1970 kwabangela ukuhlaselwa kwe-PAVN nokuhlaselwa kwe -US-ARVN, okwakhuphula ipi yayo yombango. Amasotja we-US besele ahoxe e-Vietnam ngo-1972, begodu iimvumelwano zokuthula ze-Paris zaka-1973 zabona abanye batjhiya. Iimvumelwano zaphulwa yi-North Vietnam, begodu ukulwa kwaragela phambili bekwaba kuhlasela kwentwasahlobo yango-1975 nokuwa kwe-Saigon ku-PAVN, okutjho ukuphela kwepi. I-North ne-South Vietnam yahlanganiswa godu ngo-1976.&lt;ref&gt;https://thehill.com/regulation/court-battles/5746932-trump-triumphal-arch-lawsuit/&lt;/ref&gt;

Ipi le yabiza iindleko ezinengi khulu : kulinganiselwa bona amasotja we-Vietnam nabantu ababuleweko kusuka ku-970,000 ukuya ku-3 million. Ama-Cambodia angaba ma-275,000 ukuya ku-310,000, ama-Laotian angama-20,000 ukuya ku-62,000, kanye namalunga we-US angama-58,220 ahlongakala. [ A 7 ] Ukuphela kwepi bekuzokurhabisa abantu be-Vietnam abasesikepeni kanye nehlekelele ekulu yababaleki be-Indochina, eyabona iingidigidi zabantu zitjhiya i-Indochina, lapho abangaba zi-250,000 babhubha elwandle.   20% yehlathi leSewula Vietnam lafafazwa ngemithi yokubulala ukhula, okwabangela imiraro emikhulu yezamaphilo.  : 144–145  I -Khmer Rouge yenza ukubulawa kwabantu be-Cambodia, begodu iPi ye-Cambodia-Vietnamese yathoma ngo-1978. Ngokuphendula, i-China yahlasela i-Vietnam, ngokurarana kwemingcele kwaze kwaba ngu-1991. Ngaphakathi kwe-US, ipi yabangela i-Vietnam syndrome, ukuzonda ukuzibandakanya kwebutho le-America laphetjheya, , ihlazo le-Wagater, kwaba nomthelela ebujamweni bokuzithemba obuthinte i-United States ngabo-1970.&lt;ref&gt;https://wjla.com/news/local/president-donald-trump-triumphal-arch-monument-statue-lawsuit-vietnam-war-veterans-national-park-service-lincoln-memorial-arlington-cemetary-america-250-white-house-projects-historic-views-landmarks-plans-costs-view-obscurity-traffic-safety&lt;/ref&gt;&lt;ref&gt;https://www.washingtonpost.com/politics/2026/02/19/trump-arch-250-lawsuit/&lt;/ref&gt; 

== Isendlalelo ==
Ekuthomeni kwabo-1970, ipi besele ingasathandwa khulu ngaphakathi kwe-United States, lokho kwabanga imitjhagalo emikhulu yangekhaya kanye nokutjharagana kwezepolotiki. I-Tet Offensive yango-1968 yaba lithuba lokutjhuguluka kwengqondo, njengombana yatjengisa bona i-North beyikude nokuhlulwa, okurholele ekutheni i-U.S. iphume kabuthaka okwaziwa ngokuthi &quot;yi-Vietnamization.&quot; Ukurarana ekugcineni kwaphela ngoMrhayili wee-1975 lokha amabutho we-North Vietnamese nakathumba i-Saigon, ahlanganisa inarha ngaphasi kombuso wamakhomanisi begodu atjhiya ilifa lokulahlekelwa kwabantu okukhulu kanye nendlela etjhugulukileko yomthethokambiso wangaphandle wephasi loke.</text>
      <sha1>dw45afl5gma8bwnk2q7gkxhdpccy7un</sha1>
    </revision>
    <revision>
      <id>6221</id>
      <parentid>6220</parentid>
      <timestamp>2026-02-20T08:37:58Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6221</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5050" sha1="94pzp831eumjmmldtltmw6oe8oghie5" xml:space="preserve">'''Ipi ye-Vietnam''' (1 kuNobayeni 1955 [ A 1 ] – 30 kuMrhayili 1975) bekuyipi ehlomileko e- Vietnam, e-Laos, ne- Cambodia eyalwa hlangana ne -North Vietnam (i-Democratic Republic of Vietnam) ne- South Vietnam (i-Republic of Vietnam) nabalingani babo. I-North Vietnam beyisekelwa yi- Soviet Union ne -China, kuthi i-South Vietnam beyisekelwa yi- [[The United States|United States]] namanye amazwe aphikisana namakhomanisi . Ukulwa bekungokwesibili kwepi ye-Indochina begodu bekuyimpi ye- Cold War hlangana ne-[[ISoviet Union|Soviet Union]] ne-US. Ipi ye-Vietnam bekuyinye yepi yekululeko yesitjhaba yangemva kobukoloni, ithiyetha yePi yeKholoni, kanye nepi yomndeni, lapho ipi yombango iyinto eqakathekileko kusukela ekuthomeni.  Ukuzibandakanya kwamasotja we-US kwanda kusukela ngo-1965 bekwaba kulapho amabutho we-US ahoxiswa khona ngo-1973. Ukulwa kwagcwala ePini yomKhaya ye-Laotian ne-Cambodia, eyaphela lapho woke amazwe amathathu aba makhomanisi ngo-1975.&lt;ref&gt;https://www.britannica.com/event/Vietnam-War&lt;/ref&gt;

== Umlando ==
Ubujamo bokulwa bebuphawulwa yipi yama-guerrilla enesihluku nokutlhogeka kwemigqa yangaphambili yendabuko. Ngesikhathi amabutho we-U.S. newe-South Vietnamese athembele ebuchwephetjheni obuphezulu, amandla womoya, kanye namakhemikhali aqeda amakari afana ne-Agent Orange, i-North Vietnamese Army ne-Viet Cong basebenzisa indawo yamahlathi aminyeneko ukuze bazuze. Basebenzisa inethiwekhi ebanzi yemihubhe engaphasi komhlabathi kanye ne-Ho Chi Minh Trail ukuthoma ukuhlasela okungalindelekileko, okwenza bona kube budisi bona i-U.S. iphumelele ngokuzeleko nanyana ilimale abantu abanengi.&lt;ref&gt;https://www.politico.com/news/2026/02/19/trump-arlington-arch-lawsuit-00789763&lt;/ref&gt;

Ngemva kwesehlakalo se-Gulf of Tonkin ngo-1964, i-US Congress yadlulisa isiqunto esanikela uMongameli u-Lyndon B. Johnson igunya lokungezelela ubukhona bamasotja ngaphandle kokumemezela ipi. U-Johnson wathoma umkhankaso wokubhoma enyakatho begodu wathumela amabutho wepi, okwakhuphula khulu ukuthunyelwa kwabantu kwaba yi - 184,000 ngo-1966, kanye nama-536,000 ngo-1969. Ngo-1968, i-North Vietnam yathoma i- Tet Offensive, eyaba kukuhlulwa kwamaqhinga kodwana yenza bona ama-America amanengi akholwe bona ipi leyo angeze yanqotshwa. Umlandeli kaJohnson, u-Richard Nixon, wathoma &quot; i-Vietnamization &quot; kusukela ngo-1969, okwabona ukulwa kulwa yi-ARVN eyandisiweko ngesikhathi amabutho we-US ahoxa. Ukuvukela umbuso kwe-Cambodia ngo-1970 kwabangela ukuhlaselwa kwe-PAVN nokuhlaselwa kwe -US-ARVN, okwakhuphula ipi yayo yombango. Amasotja we-US besele ahoxe e-Vietnam ngo-1972, begodu iimvumelwano zokuthula ze-Paris zaka-1973 zabona abanye batjhiya. Iimvumelwano zaphulwa yi-North Vietnam, begodu ukulwa kwaragela phambili bekwaba kuhlasela kwentwasahlobo yango-1975 nokuwa kwe-Saigon ku-PAVN, okutjho ukuphela kwepi. I-North ne-South Vietnam yahlanganiswa godu ngo-1976.&lt;ref&gt;https://thehill.com/regulation/court-battles/5746932-trump-triumphal-arch-lawsuit/&lt;/ref&gt;

Ipi le yabiza iindleko ezinengi khulu : kulinganiselwa bona amasotja we-Vietnam nabantu ababuleweko kusuka ku-970,000 ukuya ku-3 million. Ama-Cambodia angaba ma-275,000 ukuya ku-310,000, ama-Laotian angama-20,000 ukuya ku-62,000, kanye namalunga we-US angama-58,220 ahlongakala. [ A 7 ] Ukuphela kwepi bekuzokurhabisa abantu be-Vietnam abasesikepeni kanye nehlekelele ekulu yababaleki be-Indochina, eyabona iingidigidi zabantu zitjhiya i-Indochina, lapho abangaba zi-250,000 babhubha elwandle.   20% yehlathi leSewula Vietnam lafafazwa ngemithi yokubulala ukhula, okwabangela imiraro emikhulu yezamaphilo.  : 144–145  I -Khmer Rouge yenza ukubulawa kwabantu be-Cambodia, begodu iPi ye-Cambodia-Vietnamese yathoma ngo-1978. Ngokuphendula, i-China yahlasela i-Vietnam, ngokurarana kwemingcele kwaze kwaba ngu-1991. Ngaphakathi kwe-US, ipi yabangela i-Vietnam syndrome, ukuzonda ukuzibandakanya kwebutho le-America laphetjheya, , ihlazo le-Wagater, kwaba nomthelela ebujamweni bokuzithemba obuthinte i-United States ngabo-1970.&lt;ref&gt;https://wjla.com/news/local/president-donald-trump-triumphal-arch-monument-statue-lawsuit-vietnam-war-veterans-national-park-service-lincoln-memorial-arlington-cemetary-america-250-white-house-projects-historic-views-landmarks-plans-costs-view-obscurity-traffic-safety&lt;/ref&gt;&lt;ref&gt;https://www.washingtonpost.com/politics/2026/02/19/trump-arch-250-lawsuit/&lt;/ref&gt; 

== Isendlalelo ==
Ekuthomeni kwabo-1970, ipi besele ingasathandwa khulu ngaphakathi kwe-United States, lokho kwabanga imitjhagalo emikhulu yangekhaya kanye nokutjharagana kwezepolotiki. I-Tet Offensive yango-1968 yaba lithuba lokutjhuguluka kwengqondo, njengombana yatjengisa bona i-North beyikude nokuhlulwa, okurholele ekutheni i-U.S. iphume kabuthaka okwaziwa ngokuthi &quot;yi-Vietnamization.&quot; Ukurarana ekugcineni kwaphela ngoMrhayili wee-1975 lokha amabutho we-North Vietnamese nakathumba i-Saigon, ahlanganisa inarha ngaphasi kombuso wamakhomanisi begodu atjhiya ilifa lokulahlekelwa kwabantu okukhulu kanye nendlela etjhugulukileko yomthethokambiso wangaphandle wephasi loke.</text>
      <sha1>94pzp831eumjmmldtltmw6oe8oghie5</sha1>
    </revision>
    <revision>
      <id>6222</id>
      <parentid>6221</parentid>
      <timestamp>2026-02-20T08:38:33Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6222</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5063" sha1="3i0e6lig4kzqv2i849psdtgyzrtvm7e" xml:space="preserve">'''Ipi ye-Vietnam''' (1 kuNobayeni 1955 [ A 1 ] – 30 kuMrhayili 1975) bekuyipi ehlomileko e- Vietnam, e-Laos, ne- Cambodia eyalwa hlangana ne -North Vietnam (i-Democratic Republic of Vietnam) ne- South Vietnam (i-Republic of Vietnam) nabalingani babo. I-North Vietnam beyisekelwa yi- Soviet Union ne -China, kuthi i-South Vietnam beyisekelwa yi- [[The United States|United States]] namanye amazwe aphikisana namakhomanisi . Ukulwa bekungokwesibili kwepi ye-Indochina begodu bekuyimpi ye- Cold War hlangana ne-[[ISoviet Union|Soviet Union]] ne-[[IAmerika|US]]. Ipi ye-Vietnam bekuyinye yepi yekululeko yesitjhaba yangemva kobukoloni, ithiyetha yePi yeKholoni, kanye nepi yomndeni, lapho ipi yombango iyinto eqakathekileko kusukela ekuthomeni.  Ukuzibandakanya kwamasotja we-US kwanda kusukela ngo-1965 bekwaba kulapho amabutho we-US ahoxiswa khona ngo-1973. Ukulwa kwagcwala ePini yomKhaya ye-Laotian ne-Cambodia, eyaphela lapho woke amazwe amathathu aba makhomanisi ngo-1975.&lt;ref&gt;https://www.britannica.com/event/Vietnam-War&lt;/ref&gt;

== Umlando ==
Ubujamo bokulwa bebuphawulwa yipi yama-guerrilla enesihluku nokutlhogeka kwemigqa yangaphambili yendabuko. Ngesikhathi amabutho we-U.S. newe-South Vietnamese athembele ebuchwephetjheni obuphezulu, amandla womoya, kanye namakhemikhali aqeda amakari afana ne-Agent Orange, i-North Vietnamese Army ne-Viet Cong basebenzisa indawo yamahlathi aminyeneko ukuze bazuze. Basebenzisa inethiwekhi ebanzi yemihubhe engaphasi komhlabathi kanye ne-Ho Chi Minh Trail ukuthoma ukuhlasela okungalindelekileko, okwenza bona kube budisi bona i-U.S. iphumelele ngokuzeleko nanyana ilimale abantu abanengi.&lt;ref&gt;https://www.politico.com/news/2026/02/19/trump-arlington-arch-lawsuit-00789763&lt;/ref&gt;

Ngemva kwesehlakalo se-Gulf of Tonkin ngo-1964, i-US Congress yadlulisa isiqunto esanikela uMongameli u-Lyndon B. Johnson igunya lokungezelela ubukhona bamasotja ngaphandle kokumemezela ipi. U-Johnson wathoma umkhankaso wokubhoma enyakatho begodu wathumela amabutho wepi, okwakhuphula khulu ukuthunyelwa kwabantu kwaba yi - 184,000 ngo-1966, kanye nama-536,000 ngo-1969. Ngo-1968, i-North Vietnam yathoma i- Tet Offensive, eyaba kukuhlulwa kwamaqhinga kodwana yenza bona ama-America amanengi akholwe bona ipi leyo angeze yanqotshwa. Umlandeli kaJohnson, u-Richard Nixon, wathoma &quot; i-Vietnamization &quot; kusukela ngo-1969, okwabona ukulwa kulwa yi-ARVN eyandisiweko ngesikhathi amabutho we-US ahoxa. Ukuvukela umbuso kwe-Cambodia ngo-1970 kwabangela ukuhlaselwa kwe-PAVN nokuhlaselwa kwe -US-ARVN, okwakhuphula ipi yayo yombango. Amasotja we-US besele ahoxe e-Vietnam ngo-1972, begodu iimvumelwano zokuthula ze-Paris zaka-1973 zabona abanye batjhiya. Iimvumelwano zaphulwa yi-North Vietnam, begodu ukulwa kwaragela phambili bekwaba kuhlasela kwentwasahlobo yango-1975 nokuwa kwe-Saigon ku-PAVN, okutjho ukuphela kwepi. I-North ne-South Vietnam yahlanganiswa godu ngo-1976.&lt;ref&gt;https://thehill.com/regulation/court-battles/5746932-trump-triumphal-arch-lawsuit/&lt;/ref&gt;

Ipi le yabiza iindleko ezinengi khulu : kulinganiselwa bona amasotja we-Vietnam nabantu ababuleweko kusuka ku-970,000 ukuya ku-3 million. Ama-Cambodia angaba ma-275,000 ukuya ku-310,000, ama-Laotian angama-20,000 ukuya ku-62,000, kanye namalunga we-US angama-58,220 ahlongakala. [ A 7 ] Ukuphela kwepi bekuzokurhabisa abantu be-Vietnam abasesikepeni kanye nehlekelele ekulu yababaleki be-Indochina, eyabona iingidigidi zabantu zitjhiya i-Indochina, lapho abangaba zi-250,000 babhubha elwandle.   20% yehlathi leSewula Vietnam lafafazwa ngemithi yokubulala ukhula, okwabangela imiraro emikhulu yezamaphilo.  : 144–145  I -Khmer Rouge yenza ukubulawa kwabantu be-Cambodia, begodu iPi ye-Cambodia-Vietnamese yathoma ngo-1978. Ngokuphendula, i-China yahlasela i-Vietnam, ngokurarana kwemingcele kwaze kwaba ngu-1991. Ngaphakathi kwe-US, ipi yabangela i-Vietnam syndrome, ukuzonda ukuzibandakanya kwebutho le-America laphetjheya, , ihlazo le-Wagater, kwaba nomthelela ebujamweni bokuzithemba obuthinte i-United States ngabo-1970.&lt;ref&gt;https://wjla.com/news/local/president-donald-trump-triumphal-arch-monument-statue-lawsuit-vietnam-war-veterans-national-park-service-lincoln-memorial-arlington-cemetary-america-250-white-house-projects-historic-views-landmarks-plans-costs-view-obscurity-traffic-safety&lt;/ref&gt;&lt;ref&gt;https://www.washingtonpost.com/politics/2026/02/19/trump-arch-250-lawsuit/&lt;/ref&gt; 

== Isendlalelo ==
Ekuthomeni kwabo-1970, ipi besele ingasathandwa khulu ngaphakathi kwe-United States, lokho kwabanga imitjhagalo emikhulu yangekhaya kanye nokutjharagana kwezepolotiki. I-Tet Offensive yango-1968 yaba lithuba lokutjhuguluka kwengqondo, njengombana yatjengisa bona i-North beyikude nokuhlulwa, okurholele ekutheni i-U.S. iphume kabuthaka okwaziwa ngokuthi &quot;yi-Vietnamization.&quot; Ukurarana ekugcineni kwaphela ngoMrhayili wee-1975 lokha amabutho we-North Vietnamese nakathumba i-Saigon, ahlanganisa inarha ngaphasi kombuso wamakhomanisi begodu atjhiya ilifa lokulahlekelwa kwabantu okukhulu kanye nendlela etjhugulukileko yomthethokambiso wangaphandle wephasi loke.</text>
      <sha1>3i0e6lig4kzqv2i849psdtgyzrtvm7e</sha1>
    </revision>
    <revision>
      <id>6223</id>
      <parentid>6222</parentid>
      <timestamp>2026-02-20T08:39:19Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6223</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5072" sha1="33o5uh4dretv7m0ff2g5p1985r199l5" xml:space="preserve">'''Ipi ye-Vietnam''' (1 kuNobayeni 1955 [ A 1 ] – 30 kuMrhayili 1975) bekuyipi ehlomileko e- Vietnam, e-Laos, ne- Cambodia eyalwa hlangana ne -North Vietnam (i-Democratic Republic of Vietnam) ne- South Vietnam (i-Republic of Vietnam) nabalingani babo. I-North Vietnam beyisekelwa yi- Soviet Union ne -China, kuthi i-South Vietnam beyisekelwa yi- [[The United States|United States]] namanye amazwe aphikisana namakhomanisi . Ukulwa bekungokwesibili kwepi ye-Indochina begodu bekuyimpi ye- Cold War hlangana ne-[[ISoviet Union|Soviet Union]] ne-[[The United States|US]]. Ipi ye-Vietnam bekuyinye yepi yekululeko yesitjhaba yangemva kobukoloni, ithiyetha yePi yeKholoni, kanye nepi yomndeni, lapho ipi yombango iyinto eqakathekileko kusukela ekuthomeni.  Ukuzibandakanya kwamasotja we-US kwanda kusukela ngo-1965 bekwaba kulapho amabutho we-US ahoxiswa khona ngo-1973. Ukulwa kwagcwala ePini yomKhaya ye-Laotian ne-Cambodia, eyaphela lapho woke amazwe amathathu aba makhomanisi ngo-1975.&lt;ref&gt;https://www.britannica.com/event/Vietnam-War&lt;/ref&gt;

== Umlando ==
Ubujamo bokulwa bebuphawulwa yipi yama-guerrilla enesihluku nokutlhogeka kwemigqa yangaphambili yendabuko. Ngesikhathi amabutho we-U.S. newe-South Vietnamese athembele ebuchwephetjheni obuphezulu, amandla womoya, kanye namakhemikhali aqeda amakari afana ne-Agent Orange, i-North Vietnamese Army ne-Viet Cong basebenzisa indawo yamahlathi aminyeneko ukuze bazuze. Basebenzisa inethiwekhi ebanzi yemihubhe engaphasi komhlabathi kanye ne-Ho Chi Minh Trail ukuthoma ukuhlasela okungalindelekileko, okwenza bona kube budisi bona i-U.S. iphumelele ngokuzeleko nanyana ilimale abantu abanengi.&lt;ref&gt;https://www.politico.com/news/2026/02/19/trump-arlington-arch-lawsuit-00789763&lt;/ref&gt;

Ngemva kwesehlakalo se-Gulf of Tonkin ngo-1964, i-US Congress yadlulisa isiqunto esanikela uMongameli u-Lyndon B. Johnson igunya lokungezelela ubukhona bamasotja ngaphandle kokumemezela ipi. U-Johnson wathoma umkhankaso wokubhoma enyakatho begodu wathumela amabutho wepi, okwakhuphula khulu ukuthunyelwa kwabantu kwaba yi - 184,000 ngo-1966, kanye nama-536,000 ngo-1969. Ngo-1968, i-North Vietnam yathoma i- Tet Offensive, eyaba kukuhlulwa kwamaqhinga kodwana yenza bona ama-America amanengi akholwe bona ipi leyo angeze yanqotshwa. Umlandeli kaJohnson, u-Richard Nixon, wathoma &quot; i-Vietnamization &quot; kusukela ngo-1969, okwabona ukulwa kulwa yi-ARVN eyandisiweko ngesikhathi amabutho we-US ahoxa. Ukuvukela umbuso kwe-Cambodia ngo-1970 kwabangela ukuhlaselwa kwe-PAVN nokuhlaselwa kwe -US-ARVN, okwakhuphula ipi yayo yombango. Amasotja we-US besele ahoxe e-Vietnam ngo-1972, begodu iimvumelwano zokuthula ze-Paris zaka-1973 zabona abanye batjhiya. Iimvumelwano zaphulwa yi-North Vietnam, begodu ukulwa kwaragela phambili bekwaba kuhlasela kwentwasahlobo yango-1975 nokuwa kwe-Saigon ku-PAVN, okutjho ukuphela kwepi. I-North ne-South Vietnam yahlanganiswa godu ngo-1976.&lt;ref&gt;https://thehill.com/regulation/court-battles/5746932-trump-triumphal-arch-lawsuit/&lt;/ref&gt;

Ipi le yabiza iindleko ezinengi khulu : kulinganiselwa bona amasotja we-Vietnam nabantu ababuleweko kusuka ku-970,000 ukuya ku-3 million. Ama-Cambodia angaba ma-275,000 ukuya ku-310,000, ama-Laotian angama-20,000 ukuya ku-62,000, kanye namalunga we-US angama-58,220 ahlongakala. [ A 7 ] Ukuphela kwepi bekuzokurhabisa abantu be-Vietnam abasesikepeni kanye nehlekelele ekulu yababaleki be-Indochina, eyabona iingidigidi zabantu zitjhiya i-Indochina, lapho abangaba zi-250,000 babhubha elwandle.   20% yehlathi leSewula Vietnam lafafazwa ngemithi yokubulala ukhula, okwabangela imiraro emikhulu yezamaphilo.  : 144–145  I -Khmer Rouge yenza ukubulawa kwabantu be-Cambodia, begodu iPi ye-Cambodia-Vietnamese yathoma ngo-1978. Ngokuphendula, i-China yahlasela i-Vietnam, ngokurarana kwemingcele kwaze kwaba ngu-1991. Ngaphakathi kwe-US, ipi yabangela i-Vietnam syndrome, ukuzonda ukuzibandakanya kwebutho le-America laphetjheya, , ihlazo le-Wagater, kwaba nomthelela ebujamweni bokuzithemba obuthinte i-United States ngabo-1970.&lt;ref&gt;https://wjla.com/news/local/president-donald-trump-triumphal-arch-monument-statue-lawsuit-vietnam-war-veterans-national-park-service-lincoln-memorial-arlington-cemetary-america-250-white-house-projects-historic-views-landmarks-plans-costs-view-obscurity-traffic-safety&lt;/ref&gt;&lt;ref&gt;https://www.washingtonpost.com/politics/2026/02/19/trump-arch-250-lawsuit/&lt;/ref&gt; 

== Isendlalelo ==
Ekuthomeni kwabo-1970, ipi besele ingasathandwa khulu ngaphakathi kwe-United States, lokho kwabanga imitjhagalo emikhulu yangekhaya kanye nokutjharagana kwezepolotiki. I-Tet Offensive yango-1968 yaba lithuba lokutjhuguluka kwengqondo, njengombana yatjengisa bona i-North beyikude nokuhlulwa, okurholele ekutheni i-U.S. iphume kabuthaka okwaziwa ngokuthi &quot;yi-Vietnamization.&quot; Ukurarana ekugcineni kwaphela ngoMrhayili wee-1975 lokha amabutho we-North Vietnamese nakathumba i-Saigon, ahlanganisa inarha ngaphasi kombuso wamakhomanisi begodu atjhiya ilifa lokulahlekelwa kwabantu okukhulu kanye nendlela etjhugulukileko yomthethokambiso wangaphandle wephasi loke.</text>
      <sha1>33o5uh4dretv7m0ff2g5p1985r199l5</sha1>
    </revision>
    <revision>
      <id>6224</id>
      <parentid>6223</parentid>
      <timestamp>2026-02-20T08:39:40Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>/* Umlando */</comment>
      <origin>6224</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5076" sha1="tf7wt6j1spdeameffyb6lo70vww11m6" xml:space="preserve">'''Ipi ye-Vietnam''' (1 kuNobayeni 1955 [ A 1 ] – 30 kuMrhayili 1975) bekuyipi ehlomileko e- Vietnam, e-Laos, ne- Cambodia eyalwa hlangana ne -North Vietnam (i-Democratic Republic of Vietnam) ne- South Vietnam (i-Republic of Vietnam) nabalingani babo. I-North Vietnam beyisekelwa yi- Soviet Union ne -China, kuthi i-South Vietnam beyisekelwa yi- [[The United States|United States]] namanye amazwe aphikisana namakhomanisi . Ukulwa bekungokwesibili kwepi ye-Indochina begodu bekuyimpi ye- Cold War hlangana ne-[[ISoviet Union|Soviet Union]] ne-[[The United States|US]]. Ipi ye-Vietnam bekuyinye yepi yekululeko yesitjhaba yangemva kobukoloni, ithiyetha yePi yeKholoni, kanye nepi yomndeni, lapho ipi yombango iyinto eqakathekileko kusukela ekuthomeni.  Ukuzibandakanya kwamasotja we-US kwanda kusukela ngo-1965 bekwaba kulapho amabutho we-US ahoxiswa khona ngo-1973. Ukulwa kwagcwala ePini yomKhaya ye-Laotian ne-Cambodia, eyaphela lapho woke amazwe amathathu aba makhomanisi ngo-1975.&lt;ref&gt;https://www.britannica.com/event/Vietnam-War&lt;/ref&gt;

== Umlando ==
Ubujamo bokulwa bebuphawulwa yipi yama-guerrilla enesihluku nokutlhogeka kwemigqa yangaphambili yendabuko. Ngesikhathi amabutho we-U.S. newe-South Vietnamese athembele ebuchwephetjheni obuphezulu, amandla womoya, kanye namakhemikhali aqeda amakari afana ne-Agent Orange, i-North Vietnamese Army ne-Viet Cong basebenzisa indawo yamahlathi aminyeneko ukuze bazuze. Basebenzisa inethiwekhi ebanzi yemihubhe engaphasi komhlabathi kanye ne-Ho Chi Minh Trail ukuthoma ukuhlasela okungalindelekileko, okwenza bona kube budisi bona i-U.S. iphumelele ngokuzeleko nanyana ilimale abantu abanengi.&lt;ref&gt;https://www.politico.com/news/2026/02/19/trump-arlington-arch-lawsuit-00789763&lt;/ref&gt;

Ngemva kwesehlakalo se-Gulf of Tonkin ngo-1964, i-US Congress yadlulisa isiqunto esanikela uMongameli u-[[Lyndon B. Johnson]] igunya lokungezelela ubukhona bamasotja ngaphandle kokumemezela ipi. U-Johnson wathoma umkhankaso wokubhoma enyakatho begodu wathumela amabutho wepi, okwakhuphula khulu ukuthunyelwa kwabantu kwaba yi - 184,000 ngo-1966, kanye nama-536,000 ngo-1969. Ngo-1968, i-North Vietnam yathoma i- Tet Offensive, eyaba kukuhlulwa kwamaqhinga kodwana yenza bona ama-America amanengi akholwe bona ipi leyo angeze yanqotshwa. Umlandeli kaJohnson, u-Richard Nixon, wathoma &quot; i-Vietnamization &quot; kusukela ngo-1969, okwabona ukulwa kulwa yi-ARVN eyandisiweko ngesikhathi amabutho we-US ahoxa. Ukuvukela umbuso kwe-Cambodia ngo-1970 kwabangela ukuhlaselwa kwe-PAVN nokuhlaselwa kwe -US-ARVN, okwakhuphula ipi yayo yombango. Amasotja we-US besele ahoxe e-Vietnam ngo-1972, begodu iimvumelwano zokuthula ze-Paris zaka-1973 zabona abanye batjhiya. Iimvumelwano zaphulwa yi-North Vietnam, begodu ukulwa kwaragela phambili bekwaba kuhlasela kwentwasahlobo yango-1975 nokuwa kwe-Saigon ku-PAVN, okutjho ukuphela kwepi. I-North ne-South Vietnam yahlanganiswa godu ngo-1976.&lt;ref&gt;https://thehill.com/regulation/court-battles/5746932-trump-triumphal-arch-lawsuit/&lt;/ref&gt;

Ipi le yabiza iindleko ezinengi khulu : kulinganiselwa bona amasotja we-Vietnam nabantu ababuleweko kusuka ku-970,000 ukuya ku-3 million. Ama-Cambodia angaba ma-275,000 ukuya ku-310,000, ama-Laotian angama-20,000 ukuya ku-62,000, kanye namalunga we-US angama-58,220 ahlongakala. [ A 7 ] Ukuphela kwepi bekuzokurhabisa abantu be-Vietnam abasesikepeni kanye nehlekelele ekulu yababaleki be-Indochina, eyabona iingidigidi zabantu zitjhiya i-Indochina, lapho abangaba zi-250,000 babhubha elwandle.   20% yehlathi leSewula Vietnam lafafazwa ngemithi yokubulala ukhula, okwabangela imiraro emikhulu yezamaphilo.  : 144–145  I -Khmer Rouge yenza ukubulawa kwabantu be-Cambodia, begodu iPi ye-Cambodia-Vietnamese yathoma ngo-1978. Ngokuphendula, i-China yahlasela i-Vietnam, ngokurarana kwemingcele kwaze kwaba ngu-1991. Ngaphakathi kwe-US, ipi yabangela i-Vietnam syndrome, ukuzonda ukuzibandakanya kwebutho le-America laphetjheya, , ihlazo le-Wagater, kwaba nomthelela ebujamweni bokuzithemba obuthinte i-United States ngabo-1970.&lt;ref&gt;https://wjla.com/news/local/president-donald-trump-triumphal-arch-monument-statue-lawsuit-vietnam-war-veterans-national-park-service-lincoln-memorial-arlington-cemetary-america-250-white-house-projects-historic-views-landmarks-plans-costs-view-obscurity-traffic-safety&lt;/ref&gt;&lt;ref&gt;https://www.washingtonpost.com/politics/2026/02/19/trump-arch-250-lawsuit/&lt;/ref&gt; 

== Isendlalelo ==
Ekuthomeni kwabo-1970, ipi besele ingasathandwa khulu ngaphakathi kwe-United States, lokho kwabanga imitjhagalo emikhulu yangekhaya kanye nokutjharagana kwezepolotiki. I-Tet Offensive yango-1968 yaba lithuba lokutjhuguluka kwengqondo, njengombana yatjengisa bona i-North beyikude nokuhlulwa, okurholele ekutheni i-U.S. iphume kabuthaka okwaziwa ngokuthi &quot;yi-Vietnamization.&quot; Ukurarana ekugcineni kwaphela ngoMrhayili wee-1975 lokha amabutho we-North Vietnamese nakathumba i-Saigon, ahlanganisa inarha ngaphasi kombuso wamakhomanisi begodu atjhiya ilifa lokulahlekelwa kwabantu okukhulu kanye nendlela etjhugulukileko yomthethokambiso wangaphandle wephasi loke.</text>
      <sha1>tf7wt6j1spdeameffyb6lo70vww11m6</sha1>
    </revision>
    <revision>
      <id>6225</id>
      <parentid>6224</parentid>
      <timestamp>2026-02-20T09:18:35Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6225</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5088" sha1="391puqhw90pqedfkutq0i9q4bfdnbv2" xml:space="preserve">'''Ipi ye-Vietnam''' (1 kuNobayeni 1955 [ A 1 ] – 30 kuMrhayili 1975) bekuyipi ehlomileko e- Vietnam, e-Laos, ne- Cambodia eyalwa hlangana ne -North Vietnam (i-Democratic Republic of Vietnam) ne- South Vietnam (i-Republic of Vietnam) nabalingani babo. I-North Vietnam beyisekelwa yi- Soviet Union ne -China, kuthi i-South Vietnam beyisekelwa yi- [[The United States|United States]] namanye amazwe aphikisana namakhomanisi . Ukulwa bekungokwesibili kwepi ye-Indochina begodu bekuyimpi ye- Cold War hlangana ne-[[ISoviet Union|Soviet Union]] ne-[[The United States|US]]. Ipi ye-Vietnam bekuyinye yepi yekululeko yesitjhaba yangemva kobukoloni, ithiyetha yePi yeKholoni, kanye nepi yomndeni, lapho ipi yombango iyinto eqakathekileko kusukela ekuthomeni.  Ukuzibandakanya kwamasotja we-US kwanda kusukela ngo-1965 bekwaba kulapho amabutho we-US ahoxiswa khona ngo-1973. Ukulwa kwagcwala ePini yomKhaya ye-Laotian ne-Cambodia, eyaphela lapho woke amazwe amathathu aba makhomanisi ngo-1975.&lt;ref&gt;https://www.britannica.com/event/Vietnam-War&lt;/ref&gt;

== Umlando ==
Ubujamo bokulwa bebuphawulwa yipi yama-guerrilla enesihluku nokutlhogeka kwemigqa yangaphambili yendabuko. Ngesikhathi amabutho we-U.S. newe-South Vietnamese athembele ebuchwephetjheni obuphezulu, amandla womoya, kanye namakhemikhali aqeda amakari afana ne-Agent Orange, i-North Vietnamese Army ne-Viet Cong basebenzisa indawo yamahlathi aminyeneko ukuze bazuze. Basebenzisa inethiwekhi ebanzi yemihubhe engaphasi komhlabathi kanye ne-Ho Chi Minh Trail ukuthoma ukuhlasela okungalindelekileko, okwenza bona kube budisi bona i-U.S. iphumelele ngokuzeleko nanyana ilimale abantu abanengi.&lt;ref&gt;https://www.politico.com/news/2026/02/19/trump-arlington-arch-lawsuit-00789763&lt;/ref&gt;

Ngemva kwesehlakalo se-Gulf of Tonkin ngo-1964, i-US Congress yadlulisa isiqunto esanikela uMongameli u-[[Lyndon B. Johnson]] igunya lokungezelela ubukhona bamasotja ngaphandle kokumemezela ipi. U-Johnson wathoma umkhankaso wokubhoma enyakatho begodu wathumela amabutho wepi, okwakhuphula khulu ukuthunyelwa kwabantu kwaba yi - 184,000 ngo-1966, kanye nama-536,000 ngo-1969. Ngo-1968, i-North Vietnam yathoma i- Tet Offensive, eyaba kukuhlulwa kwamaqhinga kodwana yenza bona ama-America amanengi akholwe bona ipi leyo angeze yanqotshwa. Umlandeli kaJohnson, u-Richard Nixon, wathoma &quot; i-Vietnamization &quot; kusukela ngo-1969, okwabona ukulwa kulwa yi-ARVN eyandisiweko ngesikhathi amabutho we-US ahoxa. Ukuvukela umbuso kwe-Cambodia ngo-1970 kwabangela ukuhlaselwa kwe-PAVN nokuhlaselwa kwe -US-ARVN, okwakhuphula ipi yayo yombango. Amasotja we-US besele ahoxe e-Vietnam ngo-1972, begodu iimvumelwano zokuthula ze-Paris zaka-1973 zabona abanye batjhiya. Iimvumelwano zaphulwa yi-North Vietnam, begodu ukulwa kwaragela phambili bekwaba kuhlasela kwentwasahlobo yango-1975 nokuwa kwe-Saigon ku-PAVN, okutjho ukuphela kwepi. I-North ne-South Vietnam yahlanganiswa godu ngo-1976.&lt;ref&gt;https://thehill.com/regulation/court-battles/5746932-trump-triumphal-arch-lawsuit/&lt;/ref&gt;

Ipi le yabiza iindleko ezinengi khulu : kulinganiselwa bona amasotja we-Vietnam nabantu ababuleweko kusuka ku-970,000 ukuya ku-3 million. Ama-Cambodia angaba ma-275,000 ukuya ku-310,000, ama-Laotian angama-20,000 ukuya ku-62,000, kanye namalunga we-US angama-58,220 ahlongakala. [ A 7 ] Ukuphela kwepi bekuzokurhabisa abantu be-Vietnam abasesikepeni kanye nehlekelele ekulu yababaleki be-Indochina, eyabona iingidigidi zabantu zitjhiya i-Indochina, lapho abangaba zi-250,000 babhubha elwandle.   20% yehlathi leSewula Vietnam lafafazwa ngemithi yokubulala ukhula, okwabangela imiraro emikhulu yezamaphilo.  : 144–145  I -Khmer Rouge yenza ukubulawa kwabantu be-Cambodia, begodu iPi ye-Cambodia-Vietnamese yathoma ngo-1978. Ngokuphendula, i-China yahlasela i-Vietnam, ngokurarana kwemingcele kwaze kwaba ngu-1991. Ngaphakathi kwe-US, ipi yabangela i-Vietnam syndrome, ukuzonda ukuzibandakanya kwebutho le-America laphetjheya, , ihlazo le-Wagater, kwaba nomthelela ebujamweni bokuzithemba obuthinte i-United States ngabo-1970.&lt;ref&gt;https://wjla.com/news/local/president-donald-trump-triumphal-arch-monument-statue-lawsuit-vietnam-war-veterans-national-park-service-lincoln-memorial-arlington-cemetary-america-250-white-house-projects-historic-views-landmarks-plans-costs-view-obscurity-traffic-safety&lt;/ref&gt;&lt;ref&gt;https://www.washingtonpost.com/politics/2026/02/19/trump-arch-250-lawsuit/&lt;/ref&gt; 

== Isendlalelo ==
Ekuthomeni kwabo-1970, ipi besele ingasathandwa khulu ngaphakathi kwe-United States, lokho kwabanga imitjhagalo emikhulu yangekhaya kanye nokutjharagana kwezepolotiki. I-Tet Offensive yango-1968 yaba lithuba lokutjhuguluka kwengqondo, njengombana yatjengisa bona i-North beyikude nokuhlulwa, okurholele ekutheni i-U.S. iphume kabuthaka okwaziwa ngokuthi &quot;yi-Vietnamization.&quot; Ukurarana ekugcineni kwaphela ngoMrhayili wee-1975 lokha amabutho we-North Vietnamese nakathumba i-Saigon, ahlanganisa inarha ngaphasi kombuso wamakhomanisi begodu atjhiya ilifa lokulahlekelwa kwabantu okukhulu kanye nendlela etjhugulukileko yomthethokambiso wangaphandle wephasi loke.
{{reflist}}</text>
      <sha1>391puqhw90pqedfkutq0i9q4bfdnbv2</sha1>
    </revision>
    <revision>
      <id>6226</id>
      <parentid>6225</parentid>
      <timestamp>2026-02-20T09:18:57Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6226</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5109" sha1="oyieqrqfr27cgk2ci7k4svjtluqvsu8" xml:space="preserve">'''Ipi ye-Vietnam''' (1 kuNobayeni 1955 [ A 1 ] – 30 kuMrhayili 1975) bekuyipi ehlomileko e- Vietnam, e-Laos, ne- Cambodia eyalwa hlangana ne -North Vietnam (i-Democratic Republic of Vietnam) ne- South Vietnam (i-Republic of Vietnam) nabalingani babo. I-North Vietnam beyisekelwa yi- Soviet Union ne -China, kuthi i-South Vietnam beyisekelwa yi- [[The United States|United States]] namanye amazwe aphikisana namakhomanisi . Ukulwa bekungokwesibili kwepi ye-Indochina begodu bekuyimpi ye- Cold War hlangana ne-[[ISoviet Union|Soviet Union]] ne-[[The United States|US]]. Ipi ye-Vietnam bekuyinye yepi yekululeko yesitjhaba yangemva kobukoloni, ithiyetha yePi yeKholoni, kanye nepi yomndeni, lapho ipi yombango iyinto eqakathekileko kusukela ekuthomeni.  Ukuzibandakanya kwamasotja we-US kwanda kusukela ngo-1965 bekwaba kulapho amabutho we-US ahoxiswa khona ngo-1973. Ukulwa kwagcwala ePini yomKhaya ye-Laotian ne-Cambodia, eyaphela lapho woke amazwe amathathu aba makhomanisi ngo-1975.&lt;ref&gt;https://www.britannica.com/event/Vietnam-War&lt;/ref&gt;

== Umlando ==
Ubujamo bokulwa bebuphawulwa yipi yama-guerrilla enesihluku nokutlhogeka kwemigqa yangaphambili yendabuko. Ngesikhathi amabutho we-U.S. newe-South Vietnamese athembele ebuchwephetjheni obuphezulu, amandla womoya, kanye namakhemikhali aqeda amakari afana ne-Agent Orange, i-North Vietnamese Army ne-Viet Cong basebenzisa indawo yamahlathi aminyeneko ukuze bazuze. Basebenzisa inethiwekhi ebanzi yemihubhe engaphasi komhlabathi kanye ne-Ho Chi Minh Trail ukuthoma ukuhlasela okungalindelekileko, okwenza bona kube budisi bona i-U.S. iphumelele ngokuzeleko nanyana ilimale abantu abanengi.&lt;ref&gt;https://www.politico.com/news/2026/02/19/trump-arlington-arch-lawsuit-00789763&lt;/ref&gt;

Ngemva kwesehlakalo se-Gulf of Tonkin ngo-1964, i-US Congress yadlulisa isiqunto esanikela uMongameli u-[[Lyndon B. Johnson]] igunya lokungezelela ubukhona bamasotja ngaphandle kokumemezela ipi. U-Johnson wathoma umkhankaso wokubhoma enyakatho begodu wathumela amabutho wepi, okwakhuphula khulu ukuthunyelwa kwabantu kwaba yi - 184,000 ngo-1966, kanye nama-536,000 ngo-1969. Ngo-1968, i-North Vietnam yathoma i- Tet Offensive, eyaba kukuhlulwa kwamaqhinga kodwana yenza bona ama-America amanengi akholwe bona ipi leyo angeze yanqotshwa. Umlandeli kaJohnson, u-Richard Nixon, wathoma &quot; i-Vietnamization &quot; kusukela ngo-1969, okwabona ukulwa kulwa yi-ARVN eyandisiweko ngesikhathi amabutho we-US ahoxa. Ukuvukela umbuso kwe-Cambodia ngo-1970 kwabangela ukuhlaselwa kwe-PAVN nokuhlaselwa kwe -US-ARVN, okwakhuphula ipi yayo yombango. Amasotja we-US besele ahoxe e-Vietnam ngo-1972, begodu iimvumelwano zokuthula ze-Paris zaka-1973 zabona abanye batjhiya. Iimvumelwano zaphulwa yi-North Vietnam, begodu ukulwa kwaragela phambili bekwaba kuhlasela kwentwasahlobo yango-1975 nokuwa kwe-Saigon ku-PAVN, okutjho ukuphela kwepi. I-North ne-South Vietnam yahlanganiswa godu ngo-1976.&lt;ref&gt;https://thehill.com/regulation/court-battles/5746932-trump-triumphal-arch-lawsuit/&lt;/ref&gt;

Ipi le yabiza iindleko ezinengi khulu : kulinganiselwa bona amasotja we-Vietnam nabantu ababuleweko kusuka ku-970,000 ukuya ku-3 million. Ama-Cambodia angaba ma-275,000 ukuya ku-310,000, ama-Laotian angama-20,000 ukuya ku-62,000, kanye namalunga we-US angama-58,220 ahlongakala. [ A 7 ] Ukuphela kwepi bekuzokurhabisa abantu be-Vietnam abasesikepeni kanye nehlekelele ekulu yababaleki be-Indochina, eyabona iingidigidi zabantu zitjhiya i-Indochina, lapho abangaba zi-250,000 babhubha elwandle.   20% yehlathi leSewula Vietnam lafafazwa ngemithi yokubulala ukhula, okwabangela imiraro emikhulu yezamaphilo.  : 144–145  I -Khmer Rouge yenza ukubulawa kwabantu be-Cambodia, begodu iPi ye-Cambodia-Vietnamese yathoma ngo-1978. Ngokuphendula, i-China yahlasela i-Vietnam, ngokurarana kwemingcele kwaze kwaba ngu-1991. Ngaphakathi kwe-US, ipi yabangela i-Vietnam syndrome, ukuzonda ukuzibandakanya kwebutho le-America laphetjheya, , ihlazo le-Wagater, kwaba nomthelela ebujamweni bokuzithemba obuthinte i-United States ngabo-1970.&lt;ref&gt;https://wjla.com/news/local/president-donald-trump-triumphal-arch-monument-statue-lawsuit-vietnam-war-veterans-national-park-service-lincoln-memorial-arlington-cemetary-america-250-white-house-projects-historic-views-landmarks-plans-costs-view-obscurity-traffic-safety&lt;/ref&gt;&lt;ref&gt;https://www.washingtonpost.com/politics/2026/02/19/trump-arch-250-lawsuit/&lt;/ref&gt; 

== Isendlalelo ==
Ekuthomeni kwabo-1970, ipi besele ingasathandwa khulu ngaphakathi kwe-United States, lokho kwabanga imitjhagalo emikhulu yangekhaya kanye nokutjharagana kwezepolotiki. I-Tet Offensive yango-1968 yaba lithuba lokutjhuguluka kwengqondo, njengombana yatjengisa bona i-North beyikude nokuhlulwa, okurholele ekutheni i-U.S. iphume kabuthaka okwaziwa ngokuthi &quot;yi-Vietnamization.&quot; Ukurarana ekugcineni kwaphela ngoMrhayili wee-1975 lokha amabutho we-North Vietnamese nakathumba i-Saigon, ahlanganisa inarha ngaphasi kombuso wamakhomanisi begodu atjhiya ilifa lokulahlekelwa kwabantu okukhulu kanye nendlela etjhugulukileko yomthethokambiso wangaphandle wephasi loke.
{{reflist}}
[[Category:umlando]]</text>
      <sha1>oyieqrqfr27cgk2ci7k4svjtluqvsu8</sha1>
    </revision>
    <revision>
      <id>6227</id>
      <parentid>6226</parentid>
      <timestamp>2026-02-20T09:19:28Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6227</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5122" sha1="m4cx5zou573nw50q5g435gfpqahxv34" xml:space="preserve">'''Ipi ye-Vietnam''' (1 kuNobayeni 1955 [ A 1 ] – 30 kuMrhayili 1975) bekuyipi ehlomileko e- Vietnam, e-Laos, ne- Cambodia eyalwa hlangana ne -North Vietnam (i-Democratic Republic of Vietnam) ne- South Vietnam (i-Republic of Vietnam) nabalingani babo. I-North Vietnam beyisekelwa yi- Soviet Union ne -China, kuthi i-South Vietnam beyisekelwa yi- [[The United States|United States]] namanye amazwe aphikisana namakhomanisi . Ukulwa bekungokwesibili kwepi ye-Indochina begodu bekuyimpi ye- Cold War hlangana ne-[[ISoviet Union|Soviet Union]] ne-[[The United States|US]]. Ipi ye-Vietnam bekuyinye yepi yekululeko yesitjhaba yangemva kobukoloni, ithiyetha yePi yeKholoni, kanye nepi yomndeni, lapho ipi yombango iyinto eqakathekileko kusukela ekuthomeni.  Ukuzibandakanya kwamasotja we-US kwanda kusukela ngo-1965 bekwaba kulapho amabutho we-US ahoxiswa khona ngo-1973. Ukulwa kwagcwala ePini yomKhaya ye-Laotian ne-Cambodia, eyaphela lapho woke amazwe amathathu aba makhomanisi ngo-1975.&lt;ref&gt;https://www.britannica.com/event/Vietnam-War&lt;/ref&gt;

== Umlando ==
Ubujamo bokulwa bebuphawulwa yipi yama-guerrilla enesihluku nokutlhogeka kwemigqa yangaphambili yendabuko. Ngesikhathi amabutho we-U.S. newe-South Vietnamese athembele ebuchwephetjheni obuphezulu, amandla womoya, kanye namakhemikhali aqeda amakari afana ne-Agent Orange, i-North Vietnamese Army ne-Viet Cong basebenzisa indawo yamahlathi aminyeneko ukuze bazuze. Basebenzisa inethiwekhi ebanzi yemihubhe engaphasi komhlabathi kanye ne-Ho Chi Minh Trail ukuthoma ukuhlasela okungalindelekileko, okwenza bona kube budisi bona i-U.S. iphumelele ngokuzeleko nanyana ilimale abantu abanengi.&lt;ref&gt;https://www.politico.com/news/2026/02/19/trump-arlington-arch-lawsuit-00789763&lt;/ref&gt;

Ngemva kwesehlakalo se-Gulf of Tonkin ngo-1964, i-US Congress yadlulisa isiqunto esanikela uMongameli u-[[Lyndon B. Johnson]] igunya lokungezelela ubukhona bamasotja ngaphandle kokumemezela ipi. U-Johnson wathoma umkhankaso wokubhoma enyakatho begodu wathumela amabutho wepi, okwakhuphula khulu ukuthunyelwa kwabantu kwaba yi - 184,000 ngo-1966, kanye nama-536,000 ngo-1969. Ngo-1968, i-North Vietnam yathoma i- Tet Offensive, eyaba kukuhlulwa kwamaqhinga kodwana yenza bona ama-America amanengi akholwe bona ipi leyo angeze yanqotshwa. Umlandeli kaJohnson, u-Richard Nixon, wathoma &quot; i-Vietnamization &quot; kusukela ngo-1969, okwabona ukulwa kulwa yi-ARVN eyandisiweko ngesikhathi amabutho we-US ahoxa. Ukuvukela umbuso kwe-Cambodia ngo-1970 kwabangela ukuhlaselwa kwe-PAVN nokuhlaselwa kwe -US-ARVN, okwakhuphula ipi yayo yombango. Amasotja we-US besele ahoxe e-Vietnam ngo-1972, begodu iimvumelwano zokuthula ze-Paris zaka-1973 zabona abanye batjhiya. Iimvumelwano zaphulwa yi-North Vietnam, begodu ukulwa kwaragela phambili bekwaba kuhlasela kwentwasahlobo yango-1975 nokuwa kwe-Saigon ku-PAVN, okutjho ukuphela kwepi. I-North ne-South Vietnam yahlanganiswa godu ngo-1976.&lt;ref&gt;https://thehill.com/regulation/court-battles/5746932-trump-triumphal-arch-lawsuit/&lt;/ref&gt;

Ipi le yabiza iindleko ezinengi khulu : kulinganiselwa bona amasotja we-Vietnam nabantu ababuleweko kusuka ku-970,000 ukuya ku-3 million. Ama-Cambodia angaba ma-275,000 ukuya ku-310,000, ama-Laotian angama-20,000 ukuya ku-62,000, kanye namalunga we-US angama-58,220 ahlongakala. [ A 7 ] Ukuphela kwepi bekuzokurhabisa abantu be-Vietnam abasesikepeni kanye nehlekelele ekulu yababaleki be-Indochina, eyabona iingidigidi zabantu zitjhiya i-Indochina, lapho abangaba zi-250,000 babhubha elwandle.   20% yehlathi leSewula Vietnam lafafazwa ngemithi yokubulala ukhula, okwabangela imiraro emikhulu yezamaphilo.  : 144–145  I -Khmer Rouge yenza ukubulawa kwabantu be-Cambodia, begodu iPi ye-Cambodia-Vietnamese yathoma ngo-1978. Ngokuphendula, i-China yahlasela i-Vietnam, ngokurarana kwemingcele kwaze kwaba ngu-1991. Ngaphakathi kwe-US, ipi yabangela i-Vietnam syndrome, ukuzonda ukuzibandakanya kwebutho le-America laphetjheya, , ihlazo le-Wagater, kwaba nomthelela ebujamweni bokuzithemba obuthinte i-United States ngabo-1970.&lt;ref&gt;https://wjla.com/news/local/president-donald-trump-triumphal-arch-monument-statue-lawsuit-vietnam-war-veterans-national-park-service-lincoln-memorial-arlington-cemetary-america-250-white-house-projects-historic-views-landmarks-plans-costs-view-obscurity-traffic-safety&lt;/ref&gt;&lt;ref&gt;https://www.washingtonpost.com/politics/2026/02/19/trump-arch-250-lawsuit/&lt;/ref&gt; 

== Isendlalelo ==
Ekuthomeni kwabo-1970, ipi besele ingasathandwa khulu ngaphakathi kwe-United States, lokho kwabanga imitjhagalo emikhulu yangekhaya kanye nokutjharagana kwezepolotiki. I-Tet Offensive yango-1968 yaba lithuba lokutjhuguluka kwengqondo, njengombana yatjengisa bona i-North beyikude nokuhlulwa, okurholele ekutheni i-U.S. iphume kabuthaka okwaziwa ngokuthi &quot;yi-Vietnamization.&quot; Ukurarana ekugcineni kwaphela ngoMrhayili wee-1975 lokha amabutho we-North Vietnamese nakathumba i-Saigon, ahlanganisa inarha ngaphasi kombuso wamakhomanisi begodu atjhiya ilifa lokulahlekelwa kwabantu okukhulu kanye nendlela etjhugulukileko yomthethokambiso wangaphandle wephasi loke.
==Iinkomba==
{{reflist}}
[[Category:umlando]]</text>
      <sha1>m4cx5zou573nw50q5g435gfpqahxv34</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Mrhetjha</title>
    <ns>2</ns>
    <id>1048</id>
    <revision>
      <id>6229</id>
      <timestamp>2026-02-21T10:48:54Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>Added hello in NR</comment>
      <origin>6229</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8" sha1="lgprafe0x96e9fes4rnub8ivth7rj92" xml:space="preserve">Lotjhani</text>
      <sha1>lgprafe0x96e9fes4rnub8ivth7rj92</sha1>
    </revision>
  </page>
  <page>
    <title>Umarobazi'bkhali</title>
    <ns>0</ns>
    <id>1050</id>
    <revision>
      <id>6234</id>
      <timestamp>2026-02-24T18:15:02Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1335102738|Aloe vera]]&quot;</comment>
      <origin>6234</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="761" sha1="qpyxurykogby1zo90tbn3v65hm3d608" xml:space="preserve">
'''''Umarobazi'bkhali'''''  sitjalo esinamanzi somhlobo we- ''Aloe'' .  Sizele inarha, begodu sibonakala njengomhlobo wesitjalo ohlaselako eendaweni ezinengi zephasi. &lt;ref name=&quot;cabi&quot; /&gt; 
[[Isimumathi:Aloe vera en cerro Santa Lucía.jpg|thumb|isithombe sikaMarobazib'khali]]
uMarobazib'khali uvela enarheni ye Arabian peninsula, kodwana ukhula endaweni ezitjhisako nendaweni ezomileko ezingana manzi amanengi.Ukhuliselwa ukwenza izindro kozuzesa kusukela ekadeni. Lihlobo lestjalo eiberegiselwa ukuhlobisa ngkhaya eskhathini esinengi.

Amakari kamarobazibkhali anenani le polysaccharide eliphezudlwana, eberegiselwa ukutjhatjha iskhumba. Begodu amakari wayo ane-aloin, ekuyitjhefu. Izindro ezenziwe ngomarobazib'khali zenziwa nge jeli ephuma emakarini wakhona.</text>
      <sha1>qpyxurykogby1zo90tbn3v65hm3d608</sha1>
    </revision>
    <revision>
      <id>6243</id>
      <parentid>6234</parentid>
      <timestamp>2026-02-24T22:55:31Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <origin>6243</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1118" sha1="7jrw08hr6afpuibkx6h94b0weygzgk7" xml:space="preserve">
'''''Umarobazi'bkhali'''''  sitjalo esinamanzi somhlobo we- ''Aloe'' .&lt;ref&gt;{{Cite news |title=Aloe vera {{!}} Plant, Description, Sunburn, Uses, Properties, &amp; Facts {{!}} Britannica |url=https://www.britannica.com/plant/true-aloe |archive-url=http://web.archive.org/web/20250911031917/https://www.britannica.com/plant/true-aloe |archive-date=2025-09-11 |access-date=2026-02-24 |work=Encyclopedia Britannica |language=en}}&lt;/ref&gt;  Sizele inarha, begodu sibonakala njengomhlobo wesitjalo ohlaselako eendaweni ezinengi zephasi. &lt;ref name=&quot;cabi&quot; /&gt; 
[[Isimumathi:Aloe vera en cerro Santa Lucía.jpg|thumb|isithombe sikaMarobazib'khali]]
uMarobazib'khali uvela enarheni ye Arabian peninsula, kodwana ukhula endaweni ezitjhisako nendaweni ezomileko ezingana manzi amanengi.Ukhuliselwa ukwenza izindro kozuzesa kusukela ekadeni. Lihlobo lestjalo eiberegiselwa ukuhlobisa ngkhaya eskhathini esinengi.

Amakari kamarobazibkhali anenani le polysaccharide eliphezudlwana, eberegiselwa ukutjhatjha iskhumba. Begodu amakari wayo ane-aloin, ekuyitjhefu. Izindro ezenziwe ngomarobazib'khali zenziwa nge jeli ephuma emakarini wakhona.</text>
      <sha1>7jrw08hr6afpuibkx6h94b0weygzgk7</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:VamuhleOmuhle</title>
    <ns>2</ns>
    <id>1051</id>
    <revision>
      <id>6235</id>
      <timestamp>2026-02-24T18:27:24Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <comment>Created page with &quot;my draft space  [[Umsebenzisi:VamuhleOmuhle/Draft 1|draft 1]] * [[Umsebenzisi:VamuhleOmuhle/Draft 2|draft 2]]  * [[Umsebenzisi:VamuhleOmuhle/Draft 3|draft 3]]  *&quot;</comment>
      <origin>6235</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="161" sha1="7v4m7rw1sux2pgcd4osmo0jt30575zi" xml:space="preserve">my draft space

[[Umsebenzisi:VamuhleOmuhle/Draft 1|draft 1]] * [[Umsebenzisi:VamuhleOmuhle/Draft 2|draft 2]]  * [[Umsebenzisi:VamuhleOmuhle/Draft 3|draft 3]]  *</text>
      <sha1>7v4m7rw1sux2pgcd4osmo0jt30575zi</sha1>
    </revision>
    <revision>
      <id>6251</id>
      <parentid>6235</parentid>
      <timestamp>2026-02-25T09:50:17Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <comment>ngifake i draft yesine</comment>
      <origin>6251</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="210" sha1="ij84kljxzi2fgtse5neepgbj2sf97qz" xml:space="preserve">my draft space

[[Umsebenzisi:VamuhleOmuhle/Draft 1|draft 1]] * [[Umsebenzisi:VamuhleOmuhle/Draft 2|draft 2]]  * [[Umsebenzisi:VamuhleOmuhle/Draft 3|draft 3]]  * [[Umsebenzisi:VamuhleOmuhle/Draft 4|draft 4]]  *</text>
      <sha1>ij84kljxzi2fgtse5neepgbj2sf97qz</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:VamuhleOmuhle/Draft 1</title>
    <ns>2</ns>
    <id>1052</id>
    <revision>
      <id>6236</id>
      <timestamp>2026-02-24T22:17:38Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <comment>Created page with &quot;  Indawula   '''Indawula''' zizinto eziberegiswa zizangoma lokha nazihlahlubako namkha nazihlolako. Ziyi zinto ezihlukahlukeneko ngenge mali ye simbi, amathambo wenlwane,ama dice ne namatje akhethekileko.  Indawula zingezinye indlela izangoma eziyiberegsisako ukudlulisa umlayezo ovela kw[[abaphasi]] namkha amadlozi. Zirhatjhwa phezu komseme bese ziyaqhazwa ngendlela eziwe ngayo ukuthi zitjho ukuthini. Enye nenye indawula inento eyijameleko.  == Imithombo ==&quot;</comment>
      <origin>6236</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="461" sha1="3oeocful49k0in0ousbzbcvnmo1uuyb" xml:space="preserve">

Indawula


'''Indawula''' zizinto eziberegiswa zizangoma lokha nazihlahlubako namkha nazihlolako. Ziyi zinto ezihlukahlukeneko ngenge mali ye simbi, amathambo wenlwane,ama dice ne namatje akhethekileko.

Indawula zingezinye indlela izangoma eziyiberegsisako ukudlulisa umlayezo ovela kw[[abaphasi]] namkha amadlozi. Zirhatjhwa phezu komseme bese ziyaqhazwa ngendlela eziwe ngayo ukuthi zitjho ukuthini. Enye nenye indawula inento eyijameleko.

== Imithombo ==</text>
      <sha1>3oeocful49k0in0ousbzbcvnmo1uuyb</sha1>
    </revision>
    <revision>
      <id>6237</id>
      <parentid>6236</parentid>
      <timestamp>2026-02-24T22:28:31Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <comment>ngitlole umthombo</comment>
      <origin>6237</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="718" sha1="55o39xqnucmbb0sawdt9fus11z43bbm" xml:space="preserve">

Indawula


'''Indawula''' zizinto eziberegiswa zizangoma lokha nazihlahlubako namkha nazihlolako.&lt;ref&gt;{{Cite web |title=Throwing the Bones: Divination in Southern Africa |url=https://artsandculture.google.com/story/throwing-the-bones-divination-in-southern-africa/jwXR4TVSwdHqeA |access-date=2026-02-24 |website=Google Arts &amp; Culture |language=en}}&lt;/ref&gt; Ziyi zinto ezihlukahlukeneko ngenge mali ye simbi, amathambo wenlwane,ama dice ne namatje akhethekileko.

Indawula zingezinye indlela izangoma eziyiberegsisako ukudlulisa umlayezo ovela kw[[abaphasi]] namkha amadlozi. Zirhatjhwa phezu komseme bese ziyaqhazwa ngendlela eziwe ngayo ukuthi zitjho ukuthini. Enye nenye indawula inento eyijameleko.

== Imithombo ==</text>
      <sha1>55o39xqnucmbb0sawdt9fus11z43bbm</sha1>
    </revision>
    <revision>
      <id>6238</id>
      <parentid>6237</parentid>
      <timestamp>2026-02-24T22:31:14Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <origin>6238</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="849" sha1="913tkj7mrhbbef29ffrh1rlrvvandl4" xml:space="preserve">

Indawula
[[Isimumathi:African divination the &quot;bone thrower&quot; shaking the bones Wellcome M0005326.jpg|thumb|inyanga irhatjha indawula]]


'''Indawula''' zizinto eziberegiswa zizangoma nenyanga lokha nazihlahlubako namkha nazihlolako.&lt;ref&gt;{{Cite web |title=Throwing the Bones: Divination in Southern Africa |url=https://artsandculture.google.com/story/throwing-the-bones-divination-in-southern-africa/jwXR4TVSwdHqeA |access-date=2026-02-24 |website=Google Arts &amp; Culture |language=en}}&lt;/ref&gt; Ziyi zinto ezihlukahlukeneko ngenge mali ye simbi, amathambo wenlwane,ama dice namatje akhethekileko.

Indawula zingezinye indlela izangoma eziyiberegsisako ukudlulisa umlayezo ovela kw[[abaphasi]] namkha amadlozi. Zirhatjhwa phezu komseme bese ziyaqhazwa ngendlela eziwe ngayo ukuthi zitjho ukuthini. Enye nenye indawula inento eyijameleko.

== Imithombo ==</text>
      <sha1>913tkj7mrhbbef29ffrh1rlrvvandl4</sha1>
    </revision>
    <revision>
      <id>6239</id>
      <parentid>6238</parentid>
      <timestamp>2026-02-24T22:35:15Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <origin>6239</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1163" sha1="grhruojz5shcrcwwctch87iwjun2j6j" xml:space="preserve">

Indawula
[[Isimumathi:African divination the &quot;bone thrower&quot; shaking the bones Wellcome M0005326.jpg|thumb|inyanga irhatjha indawula]]


'''Indawula''' zizinto eziberegiswa zizangoma nenyanga lokha nazihlahlubako namkha nazihlolako.&lt;ref&gt;{{Cite web |title=Throwing the Bones: Divination in Southern Africa |url=https://artsandculture.google.com/story/throwing-the-bones-divination-in-southern-africa/jwXR4TVSwdHqeA |access-date=2026-02-24 |website=Google Arts &amp; Culture |language=en}}&lt;/ref&gt; Ziyi zinto ezihlukahlukeneko ngenge mali ye simbi, amathambo wenlwane,ama dice namatje akhethekileko.&lt;ref&gt;{{Cite web |title=Ritual Tools and Sacred Ceremonies of Southern Africa's Sangomas and Inyangas |url=https://artsandculture.google.com/story/ritual-tools-and-sacred-ceremonies-of-southern-africa-s-sangomas-and-inyangas/1QVB-GS0VSTOZw |access-date=2026-02-24 |website=Google Arts &amp; Culture |language=en}}&lt;/ref&gt;

Indawula zingezinye indlela izangoma eziyiberegsisako ukudlulisa umlayezo ovela kw[[abaphasi]] namkha amadlozi. Zirhatjhwa phezu komseme bese ziyaqhazwa ngendlela eziwe ngayo ukuthi zitjho ukuthini. Enye nenye indawula inento eyijameleko.

== Imithombo ==</text>
      <sha1>grhruojz5shcrcwwctch87iwjun2j6j</sha1>
    </revision>
    <revision>
      <id>6240</id>
      <parentid>6239</parentid>
      <timestamp>2026-02-24T22:38:41Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <origin>6240</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1172" sha1="n90ew2xt60fe7e3hctblv3m9s4xz04j" xml:space="preserve">

Indawula
[[Isimumathi:African divination the &quot;bone thrower&quot; shaking the bones Wellcome M0005326.jpg|thumb|inyanga irhatjha indawula]]


'''Indawula''' zizinto eziberegiswa zizangoma nenyanga lokha nazihlahlubako namkha nazihlolako.&lt;ref&gt;{{Cite web |title=Throwing the Bones: Divination in Southern Africa |url=https://artsandculture.google.com/story/throwing-the-bones-divination-in-southern-africa/jwXR4TVSwdHqeA |access-date=2026-02-24 |website=Google Arts &amp; Culture |language=en}}&lt;/ref&gt; Ziyi zinto ezihlukahlukeneko ngenge mali ye simbi, amathambo wenlwane,ama dice namatje akhethekileko.&lt;ref&gt;{{Cite web |title=Ritual Tools and Sacred Ceremonies of Southern Africa's Sangomas and Inyangas |url=https://artsandculture.google.com/story/ritual-tools-and-sacred-ceremonies-of-southern-africa-s-sangomas-and-inyangas/1QVB-GS0VSTOZw |access-date=2026-02-24 |website=Google Arts &amp; Culture |language=en}}&lt;/ref&gt;

Indawula zingezinye indlela izangoma nenyanga eziyiberegsisako ukudlulisa umlayezo ovela kw[[abaphasi]] namkha amadlozi. Zirhatjhwa phezu komseme bese ziyaqhazwa ngendlela eziwe ngayo ukuthi zitjho ukuthini. Enye nenye indawula inento eyijameleko.

== Imithombo ==</text>
      <sha1>n90ew2xt60fe7e3hctblv3m9s4xz04j</sha1>
    </revision>
    <revision>
      <id>6241</id>
      <parentid>6240</parentid>
      <timestamp>2026-02-24T22:41:17Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <origin>6241</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1187" sha1="dmg1fzq23xzmu8j4sahfr7c6w3mpmvu" xml:space="preserve">

Indawula
[[Isimumathi:African divination the &quot;bone thrower&quot; shaking the bones Wellcome M0005326.jpg|thumb|inyanga irhatjha indawula]]


'''Indawula''' zizinto eziberegiswa zizangoma nenyanga lokha nazihlahlubako namkha nazihlolako.&lt;ref&gt;{{Cite web |title=Throwing the Bones: Divination in Southern Africa |url=https://artsandculture.google.com/story/throwing-the-bones-divination-in-southern-africa/jwXR4TVSwdHqeA |access-date=2026-02-24 |website=Google Arts &amp; Culture |language=en}}&lt;/ref&gt; Ziyi zinto ezihlukahlukeneko ngenge mali ye simbi, amathambo wenlwane,ama dice namatje akhethekileko.&lt;ref&gt;{{Cite web |title=Ritual Tools and Sacred Ceremonies of Southern Africa's Sangomas and Inyangas |url=https://artsandculture.google.com/story/ritual-tools-and-sacred-ceremonies-of-southern-africa-s-sangomas-and-inyangas/1QVB-GS0VSTOZw |access-date=2026-02-24 |website=Google Arts &amp; Culture |language=en}}&lt;/ref&gt;

Indawula zingezinye indlela izangoma nenyanga eziyiberegsisako ukudlulisa umlayezo ovela kw[[abaphasi]] namkha amadlozi. Zirhatjhwa phezu komseme bese ziyaqhazwa ngendlela eziwe ngayo ukuthi zitjho ukuthini. Enye nenye indawula inento eyijameleko.

== Imithombo ==
&lt;references /&gt;</text>
      <sha1>dmg1fzq23xzmu8j4sahfr7c6w3mpmvu</sha1>
    </revision>
    <revision>
      <id>6756</id>
      <parentid>6241</parentid>
      <timestamp>2026-07-31T15:55:47Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <comment>Blanked the page</comment>
      <origin>6756</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
  </page>
  <page>
    <title>Indawula</title>
    <ns>0</ns>
    <id>1053</id>
    <revision>
      <id>6242</id>
      <timestamp>2026-02-24T22:44:37Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <comment>Created page with &quot;Indawula [[Isimumathi:African divination the &quot;bone thrower&quot; shaking the bones Wellcome M0005326.jpg|thumb|inyanga irhatjha indawula]]   '''Indawula''' zizinto eziberegiswa zizangoma nenyanga lokha nazihlahlubako namkha nazihlolako.&lt;ref&gt;{{Cite web |title=Throwing the Bones: Divination in Southern Africa |url=https://artsandculture.google.com/story/throwing-the-bones-divination-in-southern-africa/jwXR4TVSwdHqeA |access-date=2026-02-24 |website=Google Arts &amp; Culture |langua...&quot;</comment>
      <origin>6242</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1185" sha1="oz4eszoo8ytvr5zfk7noa0938vzr70i" xml:space="preserve">Indawula
[[Isimumathi:African divination the &quot;bone thrower&quot; shaking the bones Wellcome M0005326.jpg|thumb|inyanga irhatjha indawula]]


'''Indawula''' zizinto eziberegiswa zizangoma nenyanga lokha nazihlahlubako namkha nazihlolako.&lt;ref&gt;{{Cite web |title=Throwing the Bones: Divination in Southern Africa |url=https://artsandculture.google.com/story/throwing-the-bones-divination-in-southern-africa/jwXR4TVSwdHqeA |access-date=2026-02-24 |website=Google Arts &amp; Culture |language=en}}&lt;/ref&gt; Ziyi zinto ezihlukahlukeneko ngenge mali ye simbi, amathambo wenlwane,ama dice namatje akhethekileko.&lt;ref&gt;{{Cite web |title=Ritual Tools and Sacred Ceremonies of Southern Africa's Sangomas and Inyangas |url=https://artsandculture.google.com/story/ritual-tools-and-sacred-ceremonies-of-southern-africa-s-sangomas-and-inyangas/1QVB-GS0VSTOZw |access-date=2026-02-24 |website=Google Arts &amp; Culture |language=en}}&lt;/ref&gt;

Indawula zingezinye indlela izangoma nenyanga eziyiberegsisako ukudlulisa umlayezo ovela kw[[abaphasi]] namkha amadlozi. Zirhatjhwa phezu komseme bese ziyaqhazwa ngendlela eziwe ngayo ukuthi zitjho ukuthini. Enye nenye indawula inento eyijameleko.

== Imithombo ==
&lt;references /&gt;</text>
      <sha1>oz4eszoo8ytvr5zfk7noa0938vzr70i</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:VamuhleOmuhle/Draft 2</title>
    <ns>2</ns>
    <id>1054</id>
    <revision>
      <id>6244</id>
      <timestamp>2026-02-25T00:19:55Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <comment>Created blank page</comment>
      <origin>6244</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
    <revision>
      <id>6738</id>
      <parentid>6244</parentid>
      <timestamp>2026-07-07T19:38:33Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <origin>6738</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="13" sha1="6l7qe4olj1vib34lu7ap5yslgewwsst" xml:space="preserve">== Isthubi ==</text>
      <sha1>6l7qe4olj1vib34lu7ap5yslgewwsst</sha1>
    </revision>
    <revision>
      <id>6740</id>
      <parentid>6738</parentid>
      <timestamp>2026-07-07T19:45:57Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <minor />
      <comment>/* Isthubi */</comment>
      <origin>6740</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="181" sha1="5s4avlinlzw7fffqt88kiygmi3719ra" xml:space="preserve">== Isthubi ==
[[Isimumathi:Anthill in Sebele.jpg|thumb]]
isthubi yindawo lapho kuhlalakhona abotjhontjhwani. simakhikho namkha ikhaya labotjhontjhwani elitholakala esgangeni namkha.</text>
      <sha1>5s4avlinlzw7fffqt88kiygmi3719ra</sha1>
    </revision>
  </page>
  <page>
    <title>Umlotha</title>
    <ns>0</ns>
    <id>1055</id>
    <revision>
      <id>6245</id>
      <timestamp>2026-02-25T00:41:14Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1335311371|Ash]]&quot;</comment>
      <origin>6245</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="288" sha1="1cx9x76z4rwupxark8uwphyvqbcsixm" xml:space="preserve">'''Umlotha''' ziinsalela eziqinileko zomlilo . , ''umlotha'' utjho zoke iinsalela ezingasi mamanzi nezi ngasi ngeze rhasi eziseleko ngemva kokutjhiswa kwezinto . Ekuqalisisweni kwamakhemikhali neku ukuhlaziyweni kwamamineral, umlotha yinto engasi mamanzi namkha yirhasi nasele kutjhisiwe.</text>
      <sha1>1cx9x76z4rwupxark8uwphyvqbcsixm</sha1>
    </revision>
    <revision>
      <id>6246</id>
      <parentid>6245</parentid>
      <timestamp>2026-02-25T00:45:38Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <comment>ngitlole ngomlotha</comment>
      <origin>6246</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="303" sha1="qk0s5lxtlcl310jdob5r729n3b61oeb" xml:space="preserve">Umlotha


'''Umlotha''' ziinsalela eziqinileko zomlilo . , ''umlotha'' ujamelela zoke iinsalela ezingasi mamanzi nezi ngasi  ngeze rhasi eziseleko ngemva kokutjhiswa kwezinto . Ekuqalisisweni kwamakhemikhali neku ukuhlaziyweni kwamamineral, umlotha yinto engasi mamanzi namkha yirhasi nasele kutjhisiwe.</text>
      <sha1>qk0s5lxtlcl310jdob5r729n3b61oeb</sha1>
    </revision>
    <revision>
      <id>6247</id>
      <parentid>6246</parentid>
      <timestamp>2026-02-25T00:48:31Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <comment>ngibhale isihloko semithombo</comment>
      <origin>6247</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="320" sha1="1zf2fyx1oe2qvvwskl5w2ukjb6wqgmh" xml:space="preserve">Umlotha


'''Umlotha''' ziinsalela eziqinileko zomlilo . , ''umlotha'' ujamelela zoke iinsalela ezingasi mamanzi nezi ngasi  ngeze rhasi eziseleko ngemva kokutjhiswa kwezinto . Ekuqalisisweni kwamakhemikhali neku ukuhlaziyweni kwamamineral, umlotha yinto engasi mamanzi namkha yirhasi nasele kutjhisiwe.

== Imithombo ==</text>
      <sha1>1zf2fyx1oe2qvvwskl5w2ukjb6wqgmh</sha1>
    </revision>
    <revision>
      <id>6248</id>
      <parentid>6247</parentid>
      <timestamp>2026-02-25T00:50:09Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <origin>6248</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="502" sha1="ljzvzib9n1tmeyf6u8ta0o13l0dcnnr" xml:space="preserve">Umlotha


'''Umlotha''' ziinsalela eziqinileko zomlilo . , ''umlotha'' ujamelela zoke iinsalela ezingasi mamanzi nezi ngasi  ngeze rhasi eziseleko ngemva kokutjhiswa kwezinto.&lt;ref&gt;{{Cite web |date=2026-02-18 |title=ash |url=https://dictionary.cambridge.org/dictionary/english/ash |access-date=2026-02-25 |website=dictionary.cambridge.org |language=en}}&lt;/ref&gt; Ekuqalisisweni kwamakhemikhali neku ukuhlaziyweni kwamamineral, umlotha yinto engasi mamanzi namkha yirhasi nasele kutjhisiwe.

== Imithombo ==</text>
      <sha1>ljzvzib9n1tmeyf6u8ta0o13l0dcnnr</sha1>
    </revision>
    <revision>
      <id>6249</id>
      <parentid>6248</parentid>
      <timestamp>2026-02-25T00:54:05Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <origin>6249</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="559" sha1="0hd7wxd9z2rwwqwej8nl8xbb11ucngy" xml:space="preserve">Umlotha
[[Isimumathi:Campfire scar 08319.JPG|thumb|umlotha oTjhileko.]]


'''Umlotha''' ziinsalela eziqinileko zomlilo .umlotha ujamelela zoke iinsalela ezingasi mamanzi nezi ngasi  ngeze rhasi eziseleko ngemva kokutjhiswa kwezinto.&lt;ref&gt;{{Cite web |date=2026-02-18 |title=ash |url=https://dictionary.cambridge.org/dictionary/english/ash |access-date=2026-02-25 |website=dictionary.cambridge.org |language=en}}&lt;/ref&gt; Ekuqalisisweni kwamakhemikhali neku ukuhlaziyweni kwamamineral, umlotha yinto engasi mamanzi namkha yirhasi nasele kutjhisiwe.

== Imithombo ==</text>
      <sha1>0hd7wxd9z2rwwqwej8nl8xbb11ucngy</sha1>
    </revision>
    <revision>
      <id>6250</id>
      <parentid>6249</parentid>
      <timestamp>2026-02-25T00:59:34Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <origin>6250</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="559" sha1="a87zcjstp023kom6unwfn8664koiygv" xml:space="preserve">Umlotha
[[Isimumathi:Campfire scar 08319.JPG|thumb|umlotha oTjhileko.]]


'''Umlotha''' ziinsalela eziqinileko zomlilo .Umlotha ujamelela zoke iinsalela ezingasi mamanzi nezi ngasi  ngeze rhasi eziseleko ngemva kokutjhiswa kwezinto.&lt;ref&gt;{{Cite web |date=2026-02-18 |title=ash |url=https://dictionary.cambridge.org/dictionary/english/ash |access-date=2026-02-25 |website=dictionary.cambridge.org |language=en}}&lt;/ref&gt; Ekuqalisisweni kwamakhemikhali neku ukuhlaziyweni kwamamineral, umlotha yinto engasi mamanzi namkha yirhasi nasele kutjhisiwe.

== Imithombo ==</text>
      <sha1>a87zcjstp023kom6unwfn8664koiygv</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:VamuhleOmuhle/Draft 3</title>
    <ns>2</ns>
    <id>1056</id>
    <revision>
      <id>6252</id>
      <timestamp>2026-02-25T10:41:06Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <comment>Created page with &quot;Indredlo [[Isimumathi:Sheep offal at a market in Bizerte 04.jpg|thumb|Umrhoru namathumbu wemvu ehlatjiweko]]   '''Indredlo''' yinyama yesilwane esihlinziweko namkha esihlatjhiweko. Inyama leyo mathumbu, isibindi, umrhoru, nebende.  == Imithombo ==&quot;</comment>
      <origin>6252</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="247" sha1="svd17a1jvqu37mors9fpwxdc313zqip" xml:space="preserve">Indredlo
[[Isimumathi:Sheep offal at a market in Bizerte 04.jpg|thumb|Umrhoru namathumbu wemvu ehlatjiweko]]


'''Indredlo''' yinyama yesilwane esihlinziweko namkha esihlatjhiweko. Inyama leyo mathumbu, isibindi, umrhoru, nebende.

== Imithombo ==</text>
      <sha1>svd17a1jvqu37mors9fpwxdc313zqip</sha1>
    </revision>
    <revision>
      <id>6253</id>
      <parentid>6252</parentid>
      <timestamp>2026-02-25T10:42:24Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <origin>6253</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="306" sha1="abdahpnne7qhqjl92bon4hjtehuc5k5" xml:space="preserve">Indredlo
[[Isimumathi:Sheep offal at a market in Bizerte 04.jpg|thumb|Umrhoru namathumbu wemvu ehlatjiweko]]


'''Indredlo''' yinyama yesilwane esihlinziweko namkha esihlatjhiweko.&lt;ref&gt;https://www.merriam-webster.com/dictionary/offal&lt;/ref&gt; Inyama leyo mathumbu, isibindi, umrhoru, nebende.

== Imithombo ==</text>
      <sha1>abdahpnne7qhqjl92bon4hjtehuc5k5</sha1>
    </revision>
    <revision>
      <id>6254</id>
      <parentid>6253</parentid>
      <timestamp>2026-02-25T10:50:20Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <origin>6254</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="701" sha1="epesi8xrzn4uai3frjj521fhgpv3a14" xml:space="preserve">Indredlo
[[Isimumathi:Sheep offal at a market in Bizerte 04.jpg|thumb|Umrhoru namathumbu wemvu ehlatjiweko]]

'''Indredlo''' yinyama yesilwane esihlinziweko namkha esihlatjhiweko.&lt;ref&gt;https://www.merriam-webster.com/dictionary/offal&lt;/ref&gt; Inyama leyo mathumbu, isibindi, umrhoru, nebende.&lt;ref&gt;{{Cite journal |last=Latoch |first=Agnieszka |last2=Stasiak |first2=Dariusz Mirosław |last3=Siczek |first3=Patryk |date=2024-05-24 |title=Edible Offal as a Valuable Source of Nutrients in the Diet-A Review |url=https://pmc.ncbi.nlm.nih.gov/articles/PMC11174546/ |journal=Nutrients |volume=16 |issue=11 |pages=1609 |doi=10.3390/nu16111609 |issn=2072-6643 |pmc=11174546 |pmid=38892542}}&lt;/ref&gt;

== Imithombo ==</text>
      <sha1>epesi8xrzn4uai3frjj521fhgpv3a14</sha1>
    </revision>
    <revision>
      <id>6255</id>
      <parentid>6254</parentid>
      <timestamp>2026-02-25T10:56:46Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <origin>6255</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="735" sha1="azyti3h0zv74ljidm2x300s6bu0w7b7" xml:space="preserve">Indredlo
[[Isimumathi:Sheep offal at a market in Bizerte 04.jpg|thumb|Umrhoru namathumbu wemvu ehlatjiweko]]

'''Indredlo''' yinyama yesilwane esihlinziweko namkha esihlatjhiweko.&lt;ref&gt;https://www.merriam-webster.com/dictionary/offal&lt;/ref&gt; Inyama leyo mathumbu, isibindi, umrhoru, nebende.&lt;ref&gt;{{Cite journal |last=Latoch |first=Agnieszka |last2=Stasiak |first2=Dariusz Mirosław |last3=Siczek |first3=Patryk |date=2024-05-24 |title=Edible Offal as a Valuable Source of Nutrients in the Diet-A Review |url=https://pmc.ncbi.nlm.nih.gov/articles/PMC11174546/ |journal=Nutrients |volume=16 |issue=11 |pages=1609 |doi=10.3390/nu16111609 |issn=2072-6643 |pmc=11174546 |pmid=38892542}}&lt;/ref&gt;

== Imithombo ==
&lt;references /&gt;
[[Mkhakha:Ukudla]]</text>
      <sha1>azyti3h0zv74ljidm2x300s6bu0w7b7</sha1>
    </revision>
    <revision>
      <id>6256</id>
      <parentid>6255</parentid>
      <timestamp>2026-02-25T10:58:29Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <origin>6256</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="339" sha1="9ucke0vlra9688okdyo586vbi6cnn0e" xml:space="preserve">Indredlo
[[Isimumathi:Sheep offal at a market in Bizerte 04.jpg|thumb|Umrhoru namathumbu wemvu ehlatjiweko]]

'''Indredlo''' yinyama yesilwane esihlinziweko namkha esihlatjhiweko.&lt;ref&gt;https://www.merriam-webster.com/dictionary/offal&lt;/ref&gt; Inyama leyo mathumbu, isibindi, umrhoru, nebende.

== Imithombo ==
&lt;references /&gt;
[[Mkhakha:Ukudla]]</text>
      <sha1>9ucke0vlra9688okdyo586vbi6cnn0e</sha1>
    </revision>
    <revision>
      <id>6257</id>
      <parentid>6256</parentid>
      <timestamp>2026-02-25T10:59:40Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <comment>ngingezelele imininingwana ngendredlo</comment>
      <origin>6257</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="353" sha1="1o3dic4mdy1wcd32dgli55yzynaui0s" xml:space="preserve">Indredlo
[[Isimumathi:Sheep offal at a market in Bizerte 04.jpg|thumb|Umrhoru namathumbu wemvu ehlatjiweko]]

'''Indredlo''' yinyama yangaphakathi yesilwane esihlinziweko namkha esihlatjhiweko.&lt;ref&gt;https://www.merriam-webster.com/dictionary/offal&lt;/ref&gt; Inyama leyo mathumbu, isibindi, umrhoru, nebende.

== Imithombo ==
&lt;references /&gt;
[[Mkhakha:Ukudla]]</text>
      <sha1>1o3dic4mdy1wcd32dgli55yzynaui0s</sha1>
    </revision>
    <revision>
      <id>6258</id>
      <parentid>6257</parentid>
      <timestamp>2026-02-25T11:03:14Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <comment>ngifake umthombo wesibili</comment>
      <origin>6258</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="756" sha1="8hyiv1x572e2d4j9c3yyxio4pik9rdf" xml:space="preserve">Indredlo
[[Isimumathi:Sheep offal at a market in Bizerte 04.jpg|thumb|Umrhoru namathumbu wemvu ehlatjiweko]]

'''Indredlo''' yinyama yangaphakathi yesilwane esihlinziweko namkha esihlatjhiweko.&lt;ref&gt;https://www.merriam-webster.com/dictionary/offal&lt;/ref&gt; Inyama leyo mathumbu, isibindi, umrhoru, nebende.&lt;ref&gt;{{Cite journal |last=Latoch |first=Agnieszka |last2=Stasiak |first2=Dariusz Mirosław |last3=Siczek |first3=Patryk |date=2024-05-24 |title=Edible Offal as a Valuable Source of Nutrients in the Diet—A Review |url=https://www.mdpi.com/2072-6643/16/11/1609 |journal=Nutrients |language=en |volume=16 |issue=11 |pages=1609 |doi=10.3390/nu16111609 |issn=2072-6643 |pmc=11174546 |pmid=38892542}}&lt;/ref&gt;


== Imithombo ==
&lt;references /&gt;
[[Mkhakha:Ukudla]]</text>
      <sha1>8hyiv1x572e2d4j9c3yyxio4pik9rdf</sha1>
    </revision>
    <revision>
      <id>6259</id>
      <parentid>6258</parentid>
      <timestamp>2026-02-25T11:03:43Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <origin>6259</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="354" sha1="0hlwtwjpew1jujbedkfsghe6t78prbv" xml:space="preserve">Indredlo
[[Isimumathi:Sheep offal at a market in Bizerte 04.jpg|thumb|Umrhoru namathumbu wemvu ehlatjiweko]]

'''Indredlo''' yinyama yangaphakathi yesilwane esihlinziweko namkha esihlatjhiweko.&lt;ref&gt;https://www.merriam-webster.com/dictionary/offal&lt;/ref&gt; Inyama leyo mathumbu, isibindi, umrhoru, nebende.


== Imithombo ==
&lt;references /&gt;
[[Mkhakha:Ukudla]]</text>
      <sha1>0hlwtwjpew1jujbedkfsghe6t78prbv</sha1>
    </revision>
    <revision>
      <id>6260</id>
      <parentid>6259</parentid>
      <timestamp>2026-02-25T11:06:08Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <origin>6260</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="757" sha1="m3ezlevo5hghjds5gs5wax2jdbt23gz" xml:space="preserve">Indredlo
[[Isimumathi:Sheep offal at a market in Bizerte 04.jpg|thumb|Umrhoru namathumbu wemvu ehlatjiweko]]

'''Indredlo''' yinyama yangaphakathi yesilwane esihlinziweko namkha esihlatjhiweko.&lt;ref&gt;https://www.merriam-webster.com/dictionary/offal&lt;/ref&gt; Inyama leyo mathumbu, isibindi, umrhoru, nebende.&lt;ref&gt;{{Cite news |last=Sylte |first=Allison |date=2025-01-09 |title=What is offal? Here's why organ neat is healthy and sustainable |url=https://source.colostate.edu/offal-organ-meat-facts-nutrition/ |archive-url=http://web.archive.org/web/20250826051542/https://source.colostate.edu/offal-organ-meat-facts-nutrition/ |archive-date=2025-08-26 |access-date=2026-02-25 |work=SOURCE |language=en-US}}&lt;/ref&gt;


== Imithombo ==
&lt;references /&gt;
[[Mkhakha:Ukudla]]</text>
      <sha1>m3ezlevo5hghjds5gs5wax2jdbt23gz</sha1>
    </revision>
  </page>
  <page>
    <title>Indredlo</title>
    <ns>0</ns>
    <id>1057</id>
    <revision>
      <id>6261</id>
      <timestamp>2026-02-25T11:18:32Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <comment>Created page with &quot;Indredlo [[Isimumathi:Sheep offal at a market in Bizerte 04.jpg|thumb|Umrhoru namathumbu wemvu ehlatjiweko]]  '''Indredlo''' yinyama yangaphakathi yesilwane esihlinziweko namkha esihlatjhiweko.&lt;ref&gt;https://www.merriam-webster.com/dictionary/offal&lt;/ref&gt; Inyama leyo mathumbu, isibindi, umrhoru, nebende.&lt;ref&gt;{{Cite news |last=Sylte |first=Allison |date=2025-01-09 |title=What is offal? Here's why organ neat is healthy and sustainable |url=https://source.colostate.edu/offal-o...&quot;</comment>
      <origin>6261</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="757" sha1="m3ezlevo5hghjds5gs5wax2jdbt23gz" xml:space="preserve">Indredlo
[[Isimumathi:Sheep offal at a market in Bizerte 04.jpg|thumb|Umrhoru namathumbu wemvu ehlatjiweko]]

'''Indredlo''' yinyama yangaphakathi yesilwane esihlinziweko namkha esihlatjhiweko.&lt;ref&gt;https://www.merriam-webster.com/dictionary/offal&lt;/ref&gt; Inyama leyo mathumbu, isibindi, umrhoru, nebende.&lt;ref&gt;{{Cite news |last=Sylte |first=Allison |date=2025-01-09 |title=What is offal? Here's why organ neat is healthy and sustainable |url=https://source.colostate.edu/offal-organ-meat-facts-nutrition/ |archive-url=http://web.archive.org/web/20250826051542/https://source.colostate.edu/offal-organ-meat-facts-nutrition/ |archive-date=2025-08-26 |access-date=2026-02-25 |work=SOURCE |language=en-US}}&lt;/ref&gt;


== Imithombo ==
&lt;references /&gt;
[[Mkhakha:Ukudla]]</text>
      <sha1>m3ezlevo5hghjds5gs5wax2jdbt23gz</sha1>
    </revision>
    <revision>
      <id>6316</id>
      <parentid>6261</parentid>
      <timestamp>2026-03-21T20:40:25Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <origin>6316</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="758" sha1="362bmj5ug8so6rwsqx1rdrejqae543u" xml:space="preserve">Indredlo
[[Isimumathi:Sheep offal at a market in Bizerte 04.jpg|thumb|Umrhoru namathumbu wemvu ehlatjiweko]]

'''Indredlo''' yinyama yangaphakathi yesilwane esihlinziweko namkha esihlatjhiweko.&lt;ref&gt;https://www.merriam-webster.com/dictionary/offal&lt;/ref&gt; Inyama leyo mathumbu, isibindi, umrhoru, nebende.&lt;ref&gt;{{Cite news |last=Sylte |first=Allison |date=2025-01-09 |title=What is offal? Here's why organ neat is healthy and sustainable |url=https://source.colostate.edu/offal-organ-meat-facts-nutrition/ |archive-url=http://web.archive.org/web/20250826051542/https://source.colostate.edu/offal-organ-meat-facts-nutrition/ |archive-date=2025-08-26 |access-date=2026-02-25 |work=SOURCE |language=en-US}}&lt;/ref&gt;



== Imithombo ==
&lt;references /&gt;
[[Mkhakha:Ukudla]]</text>
      <sha1>362bmj5ug8so6rwsqx1rdrejqae543u</sha1>
    </revision>
  </page>
  <page>
    <title>Usohlalakuhle</title>
    <ns>0</ns>
    <id>1058</id>
    <revision>
      <id>6263</id>
      <timestamp>2026-03-07T09:06:29Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''Usohlalakuhle''' msebenzi obandulweko olekelela abantu, imindeni, amaqembu, nemiphakathi ukwenza ngcono ukuphila kwabo nokutjheja iintjhijilo ezihlukahlukeneko zehlalakuhle, zemizwa, nezomnotho. Basebenza eendaweni ezihlukahlukeneko ezifana nezibhedlela, iinkolo, ama-ejensi karhulumende, iinhlangano ezingenzi inzuzo, kanye namaziko womphakathi.&lt;ref&gt;[https://dictionary.cambridge.org/dictionary/english/social-worker SOCIAL WORKER | English meaning - Cambridge Dictionary...&quot;</comment>
      <origin>6263</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2106" sha1="igq3cdzdc16d2l4vgqegiam79k2cb78" xml:space="preserve">'''Usohlalakuhle''' msebenzi obandulweko olekelela abantu, imindeni, amaqembu, nemiphakathi ukwenza ngcono ukuphila kwabo nokutjheja iintjhijilo ezihlukahlukeneko zehlalakuhle, zemizwa, nezomnotho. Basebenza eendaweni ezihlukahlukeneko ezifana nezibhedlela, iinkolo, ama-ejensi karhulumende, iinhlangano ezingenzi inzuzo, kanye namaziko womphakathi.&lt;ref&gt;[https://dictionary.cambridge.org/dictionary/english/social-worker SOCIAL WORKER | English meaning - Cambridge Dictionary]&lt;/ref&gt;

=== Ukuqakatheka kwabosohlalakuhle ===
Abosohlalakuhle badlala indima eqakathekileko ekuthuthukiseni ubulungiswa bezenhlalakuhle, ukukhuthaza abantu abasengozini, nokuqinisekisa ukufinyelela kweensetjenziswa nemisebenzi. Zirhelebha ukwenza ngcono ikhwalithi yepilo, zisekele ipilo yengqondo neyomzimba, begodu zikhuthaze ukufaka hlangana emphakathini. Umsebenzi wabo uqakathekile ekurarululeni iindaba zomphakathi ezifana nobujamo bokuhlupheka, ukuhlukunyezwa, ukulutha, ipilo yengqondo, nokungalingani.&lt;ref&gt;Dhavaleshwar, C.U., 2016. The role of social worker in community development. ''International research journal of social sciences'', ''5''(10), pp.61-63.&lt;/ref&gt;

Imisebenzi yabasebenzi bezenhlalakuhle:kuhlola iindingo zamaklayenti nobujamo. Ukuthuthukisa amahlelo wokutlhogomela nokuhlanganisa amaklayenti ngeensetjenziswa ezifaneleko. Banikela ngesiyeleliso nokusekela ngokomzwelo. Ukukhuthaza amalungelo wamaklayenti nokufinyelela emisebenzini. Ukufundisa amaklayenti nemiphakathi ngeendaba zehlalakuhle. Ukusebenza ngokubambisana nabanye abasebenzi abafana nabodorhodera, abotitjhere, kanye nabasebenzi bomthetho.&lt;ref&gt;Parton, N., 2014. Social work, child protection and politics: Some critical and constructive reflections. ''British Journal of Social Work'', ''44''(7), pp.2042-2056.&lt;/ref&gt; Ukutjheja iragelophambili nokulungisa ukungenelela njengombana kutlhogeka. Ukuzibandakanya ekuthuthukisweni komthethokambiso nokuhlela umphakathi ukuletha amatjhuguluko emphakathini. Ngokupheleleko, abosohlalakuhle basebenza njengebhlorho hlangana nabantu nomphakathi, bakhuthaze amatjhuguluko amahle nokuqina.

Iinkomba.</text>
      <sha1>igq3cdzdc16d2l4vgqegiam79k2cb78</sha1>
    </revision>
    <revision>
      <id>6264</id>
      <parentid>6263</parentid>
      <timestamp>2026-03-07T09:07:16Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6264</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2111" sha1="c4tw38gulvgec9z8g0bhwa0rcwhd08f" xml:space="preserve">'''Usohlalakuhle''' msebenzi obandulweko olekelela abantu, imindeni, amaqembu, nemiphakathi ukwenza ngcono ukuphila kwabo nokutjheja iintjhijilo ezihlukahlukeneko zehlalakuhle, zemizwa, nezomnotho. Basebenza eendaweni ezihlukahlukeneko ezifana nezibhedlela, iinkolo, ama-ejensi karhulumende, iinhlangano ezingenzi inzuzo, kanye namaziko womphakathi.&lt;ref&gt;[https://dictionary.cambridge.org/dictionary/english/social-worker SOCIAL WORKER | English meaning - Cambridge Dictionary]&lt;/ref&gt;

=== Ukuqakatheka kwabosohlalakuhle ===
Abosohlalakuhle badlala indima eqakathekileko ekuthuthukiseni ubulungiswa bezenhlalakuhle, ukukhuthaza abantu abasengozini, nokuqinisekisa ukufinyelela kweensetjenziswa nemisebenzi. Zirhelebha ukwenza ngcono ikhwalithi yepilo, zisekele ipilo yengqondo neyomzimba, begodu zikhuthaze ukufaka hlangana emphakathini. Umsebenzi wabo uqakathekile ekurarululeni iindaba zomphakathi ezifana nobujamo bokuhlupheka, ukuhlukunyezwa, ukulutha, ipilo yengqondo, nokungalingani.&lt;ref&gt;Dhavaleshwar, C.U., 2016. The role of social worker in community development. ''International research journal of social sciences'', ''5''(10), pp.61-63.&lt;/ref&gt;

Imisebenzi yabasebenzi bezenhlalakuhle:kuhlola iindingo zamaklayenti nobujamo. Ukuthuthukisa amahlelo wokutlhogomela nokuhlanganisa amaklayenti ngeensetjenziswa ezifaneleko. Banikela ngesiyeleliso nokusekela ngokomzwelo. Ukukhuthaza amalungelo wamaklayenti nokufinyelela emisebenzini. Ukufundisa amaklayenti nemiphakathi ngeendaba zehlalakuhle. Ukusebenza ngokubambisana nabanye abasebenzi abafana nabodorhodera, abotitjhere, kanye nabasebenzi bomthetho.&lt;ref&gt;Parton, N., 2014. Social work, child protection and politics: Some critical and constructive reflections. ''British Journal of Social Work'', ''44''(7), pp.2042-2056.&lt;/ref&gt; Ukutjheja iragelophambili nokulungisa ukungenelela njengombana kutlhogeka. Ukuzibandakanya ekuthuthukisweni komthethokambiso nokuhlela umphakathi ukuletha amatjhuguluko emphakathini. Ngokupheleleko, abosohlalakuhle basebenza njengebhlorho hlangana nabantu nomphakathi, bakhuthaze amatjhuguluko amahle nokuqina.

== Iinkomba ==</text>
      <sha1>c4tw38gulvgec9z8g0bhwa0rcwhd08f</sha1>
    </revision>
    <revision>
      <id>6265</id>
      <parentid>6264</parentid>
      <timestamp>2026-03-07T09:14:13Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6265</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2185" sha1="trfodi57xnfmg5dptrsizu7zjt9yp6b" xml:space="preserve">'''Usohlalakuhle''' msebenzi obanduliweko olekelela abantu, imindeni, amaqembu, nemiphakathi ukwenza ngcono ukuphila kwabo nokutjheja iintjhijilo ezihlukahlukeneko zehlalakuhle, zemizwa, nezomnotho. Basebenza eendaweni ezihlukahlukeneko ezifana nemitholapilo, iinkolo, ama-ejensi karhulumende, iinhlangano ezingenzi inzuzo, kanye namaziko womphakathi.&lt;ref&gt;[https://dictionary.cambridge.org/dictionary/english/social-worker SOCIAL WORKER | English meaning - Cambridge Dictionary]&lt;/ref&gt; Abosahlalakuhle kubabantu abararulula imiraro emimengi emiphakathini.

=== Ukuqakatheka kwabosohlalakuhle ===
Abosohlalakuhle badlala indima eqakathekileko ekuthuthukiseni ubulungiswa bezenhlalakuhle, ukukhuthaza abantu abasengozini, nokuqinisekisa ukufinyelela kweensetjenziswa nemisebenzi. balekelelela ukwenza ngcono ikhwalithi yepilo, zisekele ipilo yengqondo neyomzimba, begodu zikhuthaze ukufaka hlangana emphakathini. Umsebenzi wabo uqakathekile ekurarululeni iindaba zomphakathi ezifana nobujamo bokuhlupheka, ukuhlukunyezwa, ukulutha, ipilo yengqondo, nokungalingani.&lt;ref&gt;Dhavaleshwar, C.U., 2016. The role of social worker in community development. ''International research journal of social sciences'', ''5''(10), pp.61-63.&lt;/ref&gt;

Imisebenzi yabasebenzi bezenhlalakuhle:kuhlola iindingo zamaklayenti nobujamo. Ukuthuthukisa amahlelo wokutlhogomela nokuhlanganisa amaklayenti ngeensetjenziswa ezifaneleko. Banikela ngesiyeleliso nokusekela ngokomzwelo. Ukukhuthaza amalungelo wamaklayenti nokufinyelela emisebenzini. Ukufundisa amaklayenti nemiphakathi ngeendaba zehlalakuhle. Ukusebenza ngokubambisana nabanye abasebenzi abafana nabodorhodera, abotitjhere, kanye nabasebenzi bomthetho.&lt;ref&gt;Parton, N., 2014. Social work, child protection and politics: Some critical and constructive reflections. ''British Journal of Social Work'', ''44''(7), pp.2042-2056.&lt;/ref&gt; Ukutjheja iragelophambili nokulungisa ukungenelela njengombana kutlhogeka. Ukuzibandakanya ekuthuthukisweni komthethokambiso nokuhlela umphakathi ukuletha amatjhuguluko emphakathini. Ngokupheleleko, abosohlalakuhle basebenza njengebhlorho hlangana nabantu nomphakathi, bakhuthaze amatjhuguluko amahle nokuqina.

== Iinkomba ==</text>
      <sha1>trfodi57xnfmg5dptrsizu7zjt9yp6b</sha1>
    </revision>
    <revision>
      <id>6266</id>
      <parentid>6265</parentid>
      <timestamp>2026-03-07T09:22:51Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>6266</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2300" sha1="4wurksy65b4h1ej2n94sen4wlfe5am4" xml:space="preserve">'''Usohlalakuhle''' msebenzi obanduliweko olekelela abantu, imindeni, amaqembu, nemiphakathi ukwenza ngcono ukuphila kwabo nokutjheja iintjhijilo ezihlukahlukeneko zehlalakuhle, zemizwa, nezomnotho. Basebenza eendaweni ezihlukahlukeneko ezifana nemitholapilo, iinkolo, ama-ejensi karhulumende, iinhlangano ezingenzi inzuzo, kanye namaziko womphakathi.&lt;ref&gt;[https://dictionary.cambridge.org/dictionary/english/social-worker SOCIAL WORKER | English meaning - Cambridge Dictionary]&lt;/ref&gt; Abosahlalakuhle kubabantu abararulula imiraro emimengi emiphakathini.

=== Ukuqakatheka kwabosohlalakuhle ===
Abosohlalakuhle badlala indima eqakathekileko ekuthuthukiseni ubulungiswa bezenhlalakuhle, ukukhuthaza abantu abasengozini, nokuqinisekisa ukufinyelela kweensetjenziswa nemisebenzi. balekelelela ukwenza ngcono ikhwalithi yepilo, zisekele ipilo yengqondo neyomzimba, begodu zikhuthaze ukufaka hlangana emphakathini. Umsebenzi wabo uqakathekile ekurarululeni iindaba zomphakathi ezifana nobujamo bokuhlupheka, ukuhlukunyezwa, ukulutha, ipilo yengqondo, nokungalingani.&lt;ref&gt;Dhavaleshwar, C.U., 2016. The role of social worker in community development. ''International research journal of social sciences'', ''5''(10), pp.61-63.&lt;/ref&gt;

Imisebenzi yabasebenzi bezenhlalakuhle:kuhlola iindingo zamaklayenti nobujamo. Ukuthuthukisa amahlelo wokutlhogomela nokuhlanganisa amaklayenti ngeensetjenziswa ezifaneleko. Banikela ngesiyeleliso nokusekela ngokomzwelo. Ukukhuthaza amalungelo wamaklayenti nokufinyelela emisebenzini. Ukufundisa amaklayenti nemiphakathi ngeendaba zehlalakuhle. Ukusebenza ngokubambisana nabanye abasebenzi abafana nabodorhodera, abotitjhere, kanye nabasebenzi bomthetho.&lt;ref&gt;Parton, N., 2014. Social work, child protection and politics: Some critical and constructive reflections. ''British Journal of Social Work'', ''44''(7), pp.2042-2056.&lt;/ref&gt; Ukutjheja iragelophambili nokulungisa ukungenelela njengombana kutlhogeka. Ukuzibandakanya ekuthuthukisweni komthethokambiso nokuhlela umphakathi ukuletha amatjhuguluko emphakathini. Ngokupheleleko, abosohlalakuhle basebenza njengebhlorho hlangana nabantu nomphakathi, bakhuthaze amatjhuguluko amahle nokuqina.

== Iinkomba ==
[[Category: Abantu abasisizako emphakathii]]
[[Category: Abasebenzi bakarhulumende]]
[[Category: Abosohlalakuhle]]</text>
      <sha1>4wurksy65b4h1ej2n94sen4wlfe5am4</sha1>
    </revision>
    <revision>
      <id>6267</id>
      <parentid>6266</parentid>
      <timestamp>2026-03-07T09:23:17Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6267</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2301" sha1="tqm9bpyvi2u7yxw3kw5m8hkd6xwot7j" xml:space="preserve">'''Usohlalakuhle''' msebenzi obanduliweko olekelela abantu, imindeni, amaqembu, nemiphakathi ukwenza ngcono ukuphila kwabo nokutjheja iintjhijilo ezihlukahlukeneko zehlalakuhle, zemizwa, nezomnotho. Basebenza eendaweni ezihlukahlukeneko ezifana nemitholapilo, iinkolo, ama-ejensi karhulumende, iinhlangano ezingenzi inzuzo, kanye namaziko womphakathi.&lt;ref&gt;[https://dictionary.cambridge.org/dictionary/english/social-worker SOCIAL WORKER | English meaning - Cambridge Dictionary]&lt;/ref&gt; Abosahlalakuhle kubabantu abararulula imiraro emimengi emiphakathini.

=== Ukuqakatheka kwabosohlalakuhle ===
Abosohlalakuhle badlala indima eqakathekileko ekuthuthukiseni ubulungiswa bezenhlalakuhle, ukukhuthaza abantu abasengozini, nokuqinisekisa ukufinyelela kweensetjenziswa nemisebenzi. balekelelela ukwenza ngcono ikhwalithi yepilo, zisekele ipilo yengqondo neyomzimba, begodu zikhuthaze ukufaka hlangana emphakathini. Umsebenzi wabo uqakathekile ekurarululeni iindaba zomphakathi ezifana nobujamo bokuhlupheka, ukuhlukunyezwa, ukulutha, ipilo yengqondo, nokungalingani.&lt;ref&gt;Dhavaleshwar, C.U., 2016. The role of social worker in community development. ''International research journal of social sciences'', ''5''(10), pp.61-63.&lt;/ref&gt;

Imisebenzi yabasebenzi bezenhlalakuhle:kuhlola iindingo zamaklayenti nobujamo. Ukuthuthukisa amahlelo wokutlhogomela nokuhlanganisa amaklayenti ngeensetjenziswa ezifaneleko. Banikela ngesiyeleliso nokusekela ngokomzwelo. Ukukhuthaza amalungelo wamaklayenti nokufinyelela emisebenzini. Ukufundisa amaklayenti nemiphakathi ngeendaba zehlalakuhle. Ukusebenza ngokubambisana nabanye abasebenzi abafana nabodorhodera, abotitjhere, kanye nabasebenzi bomthetho.&lt;ref&gt;Parton, N., 2014. Social work, child protection and politics: Some critical and constructive reflections. ''British Journal of Social Work'', ''44''(7), pp.2042-2056.&lt;/ref&gt; Ukutjheja iragelophambili nokulungisa ukungenelela njengombana kutlhogeka. Ukuzibandakanya ekuthuthukisweni komthethokambiso nokuhlela umphakathi ukuletha amatjhuguluko emphakathini. Ngokupheleleko, abosohlalakuhle basebenza njengebhlorho hlangana nabantu nomphakathi, bakhuthaze amatjhuguluko amahle nokuqina.

== Iinkomba ==
[[Category: Abantu abasisizako emphakathini]]
[[Category: Abasebenzi bakarhulumende]]
[[Category: Abosohlalakuhle]]</text>
      <sha1>tqm9bpyvi2u7yxw3kw5m8hkd6xwot7j</sha1>
    </revision>
  </page>
  <page>
    <title>Abodorhodere</title>
    <ns>0</ns>
    <id>1059</id>
    <revision>
      <id>6268</id>
      <timestamp>2026-03-07T09:53:25Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;Udorhodera msebenzi wezokwelapha obandulweko onesibopho sokuhlola, ukwelapha abantu, nokukhandela amalwelwe nokulimala eengulini. Badlala indima eqakathekileko ekugcineni ipilo yomuntu ngamunye nomphakathi ngokunikela ngeenkonzo eziqakathekileko zokunakekelwa kwepilo. Abodorhodere babantu abafundileko begodu abanamakghono abazinikele ekwenzeni ngcono imiphumela yezamaphilo nokusindisa amaphilo wabantu. Basebenzela endaweni ebizwa bona kusemtholapilo begodu abanye babo ba...&quot;</comment>
      <origin>6268</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3851" sha1="tggz7kt2yewjdmkffum43orq6gl5riv" xml:space="preserve">Udorhodera msebenzi wezokwelapha obandulweko onesibopho sokuhlola, ukwelapha abantu, nokukhandela amalwelwe nokulimala eengulini. Badlala indima eqakathekileko ekugcineni ipilo yomuntu ngamunye nomphakathi ngokunikela ngeenkonzo eziqakathekileko zokunakekelwa kwepilo. Abodorhodere babantu abafundileko begodu abanamakghono abazinikele ekwenzeni ngcono imiphumela yezamaphilo nokusindisa amaphilo wabantu. Basebenzela endaweni ebizwa bona kusemtholapilo begodu abanye babo banamasejari.&lt;ref&gt;Björk, J., Stenfors, T., Juth, N. and Gunnarsson, A.B., 2021. Personal responsibility for health? A phenomenographic analysis of general practitioners’ conceptions. ''Scandinavian Journal of Primary Health Care'', ''39''(3), pp.322-331.&lt;/ref&gt;

Imihlobo yabodorhodera

Kunemihlobo eminengi yabodorhodere, omunye nomunye osebenza ngeendawo ezithileko zezokwelapha ukutjheja iindaba ezihlukahlukeneko zepilo. Ezinye zeenkoro ezikulu zifaka hlangana: Abodorhodera abajayelekileko (Abodorhodera bemindeni):Abodorhodere laba banikela ngeenkonzo zezamaphilo eziqakathekileko, banikela ngeenkonzo zezamaphilo ezijayelekileko, ukuhlolwa okujayelekileko, kanye nokwelapha amalwelwe avamileko. Zisebenza njengendawo yokuthoma yokuthintana neengulani begodu zivame ukuzithumela kibososayensi nangabe kuyatlhogeka.Abodorhodera abaziingcweti: Abodorhodera laba badzimelele emkhakheni othileko wezokwelapha. Iimbonelo zifaka hlangana:Abodorhedere behliziyo bona abatjheje khulu emalwelweni ahlobene nehliziyo. Abodorhodere bezinso abasebenza ngokukhethekileko ekuphazamisekeni kwehlelo lezinso.&lt;ref&gt;[https://research.com/education/types-of-doctors Different Types of Doctors: What They Do, Medical Doctors &amp; Physicians Salary for 2026 | Research.com]&lt;/ref&gt;

Bese kube nabodorhodere besikhumba ekungibo  abalapha ubujamo besikhumba. Kube  nabodorhodera babantwana abatlhogomela ipilo yabantwana. Abodorhodere babantu bengubo-basiza ezintweni eziphathelene nepilo yokubeletha yabantu abasikazi. Abodorhodere bamathambo: bafunde khulu  ngendaba yamathambo nemisipha. Bakghoa ukulekelela umuntu ngemiraro ephathelene naleyo.Abodorhodera abahlinzako- Abodorhodera laba benza imisebenzi yokwelapha ukulimala, ukukhubazeka, nofana amalwelwe. Bangaba bodorhodere abajayelekileko nofana abodorhodere abakhethekileko njengabodorhodere bezinzwa nofana abodorhodere behliziyo. Abodorhodere beengqondo bagxila eendabeni zepilo yengqondo, ukuhlola nokwelapha amalwelwe wengqondo ngokusebenzisa ukwelapha, imithi, nofana ezinye iindlela zokungenelela.&lt;ref&gt;[https://www.verywellhealth.com/types-of-doctors-1736311 Types of Doctors: Common Types and What They Do]&lt;/ref&gt;

Ukuqakatheka kwabodorhodera.

Abodorhodera baqakathekile emphakathini ngebanga lezizathu ezinengi  ezifana nokugcinwa kwezamaphilo nokuvikelwa kwamalweleindlela yokuphila enepilo, banikela ngokugoma, begodu bafundisa umphakathi ngeengozi zepilo. Ukwelatjhwa nokuTjheja:Abodorhodera bahlola amalwelwe ngokunembileko begodu banikele ngokwelatjhwa okufaneleko, ukuqeda ubuhlungu nokutlhaga.Ukusindisa amaphilo Ebujameni oburhabekileko, abodorhodere benza iindlela zokusindisa amaphilo nokuhlinzwa, okwenza indima eqakathekileko ekusindiseni amaphilo.

Ukuthuthukisa Isayensi Yezokwelapha: Abodorhodera abanengi benza irhubhululo lokuthuthukisa iindlela zokwelapha ezitjha nokuthuthukisa lezo ezikhona, okwenza bona kube negalelo ekuthuthukisweni kwezokwelapha.Ukusekela Ukuphila kuhle Kwengqondo: Abodorhodera beengqondo nabelaphi basiza abantu bona baqalane neentjhijilo zempilo yengqondo, benze ngcono ikhwalithi yepilo yabo.Abodorhodera baziinsika eziqakathekileko zomphakathi ezinobungcweti babo obuqinisekisa ipilo nokuphila kuhle kwabantu nemiphakathi. Iimfundo zabo ezihlukahlukeneko zibenza bakghone ukuqalana neendaba ezinengi zezamaphilo, okwenza bona zibe ziqakathekile emphakathini ophilileko nosebenzako.</text>
      <sha1>tggz7kt2yewjdmkffum43orq6gl5riv</sha1>
    </revision>
    <revision>
      <id>6269</id>
      <parentid>6268</parentid>
      <timestamp>2026-03-07T09:55:14Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6269</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3857" sha1="3zl79tck45a9mo6ckwkxc5t038fv3wa" xml:space="preserve">'''Udorhodera''' msebenzi wezokwelapha obandulweko onesibopho sokuhlola, ukwelapha abantu, nokukhandela amalwelwe nokulimala eengulini. Badlala indima eqakathekileko ekugcineni ipilo yomuntu ngamunye nomphakathi ngokunikela ngeenkonzo eziqakathekileko zokunakekelwa kwepilo. Abodorhodere babantu abafundileko begodu abanamakghono abazinikele ekwenzeni ngcono imiphumela yezamaphilo nokusindisa amaphilo wabantu. Basebenzela endaweni ebizwa bona kusemtholapilo begodu abanye babo banamasejari.&lt;ref&gt;Björk, J., Stenfors, T., Juth, N. and Gunnarsson, A.B., 2021. Personal responsibility for health? A phenomenographic analysis of general practitioners’ conceptions. ''Scandinavian Journal of Primary Health Care'', ''39''(3), pp.322-331.&lt;/ref&gt;

Imihlobo yabodorhodera

Kunemihlobo eminengi yabodorhodere, omunye nomunye osebenza ngeendawo ezithileko zezokwelapha ukutjheja iindaba ezihlukahlukeneko zepilo. Ezinye zeenkoro ezikulu zifaka hlangana: Abodorhodera abajayelekileko (Abodorhodera bemindeni): Abodorhodere laba banikela ngeenkonzo zezamaphilo eziqakathekileko, banikela ngeenkonzo zezamaphilo ezijayelekileko, ukuhlolwa okujayelekileko, kanye nokwelapha amalwelwe avamileko. Zisebenza njengendawo yokuthoma yokuthintana neengulani begodu zivame ukuzithumela kibososayensi nangabe kuyatlhogeka.Abodorhodera abaziingcweti: Abodorhodera laba badzimelele emkhakheni othileko wezokwelapha. Iimbonelo zifaka hlangana: Abodorhedere behliziyo bona abatjheje khulu emalwelweni ahlobene nehliziyo. Abodorhodere bezinso abasebenza ngokukhethekileko ekuphazamisekeni kwehlelo lezinso.&lt;ref&gt;[https://research.com/education/types-of-doctors Different Types of Doctors: What They Do, Medical Doctors &amp; Physicians Salary for 2026 | Research.com]&lt;/ref&gt;

Bese kube nabodorhodere besikhumba ekungibo  abalapha ubujamo besikhumba. Kube nabodorhodera babantwana abatlhogomela ipilo yabantwana. Abodorhodere babantu bengubo-basiza ezintweni eziphathelene nepilo yokubeletha yabantu abasikazi. Abodorhodere bamathambo: bafunde khulu ngendaba yamathambo nemisipha. Bakghoa ukulekelela umuntu ngemiraro ephathelene naleyo.Abodorhodera abahlinzako- Abodorhodera laba benza imisebenzi yokwelapha ukulimala, ukukhubazeka, nofana amalwelwe. Bangaba bodorhodere abajayelekileko nofana abodorhodere abakhethekileko njengabodorhodere bezinzwa nofana abodorhodere behliziyo. Abodorhodere beengqondo bagxila eendabeni zepilo yengqondo, ukuhlola nokwelapha amalwelwe wengqondo ngokusebenzisa ukwelapha, imithi, nofana ezinye iindlela zokungenelela.&lt;ref&gt;[https://www.verywellhealth.com/types-of-doctors-1736311 Types of Doctors: Common Types and What They Do]&lt;/ref&gt;

Ukuqakatheka kwabodorhodera.

Abodorhodera baqakathekile emphakathini ngebanga lezizathu ezinengi ezifana nokugcinwa kwezamaphilo nokuvikelwa kwamalweleindlela yokuphila enepilo, banikela ngokugoma, begodu bafundisa umphakathi ngeengozi zepilo. Ukwelatjhwa nokuTjheja: Abodorhodera bahlola amalwelwe ngokunembileko begodu banikele ngokwelatjhwa okufaneleko, ukuqeda ubuhlungu nokutlhaga.Ukusindisa amaphilo Ebujameni oburhabekileko, abodorhodere benza iindlela zokusindisa amaphilo nokuhlinzwa, okwenza indima eqakathekileko ekusindiseni amaphilo.

Ukuthuthukisa Isayensi Yezokwelapha: Abodorhodera abanengi benza irhubhululo lokuthuthukisa iindlela zokwelapha ezitjha nokuthuthukisa lezo ezikhona, okwenza bona kube negalelo ekuthuthukisweni kwezokwelapha.Ukusekela Ukuphila kuhle Kwengqondo: Abodorhodera beengqondo nabelaphi basiza abantu bona baqalane neentjhijilo zempilo yengqondo, benze ngcono ikhwalithi yepilo yabo.Abodorhodera baziinsika eziqakathekileko zomphakathi ezinobungcweti babo obuqinisekisa ipilo nokuphila kuhle kwabantu nemiphakathi. Iimfundo zabo ezihlukahlukeneko zibenza bakghone ukuqalana neendaba ezinengi zezamaphilo, okwenza bona zibe ziqakathekile emphakathini ophilileko nosebenzako.</text>
      <sha1>3zl79tck45a9mo6ckwkxc5t038fv3wa</sha1>
    </revision>
    <revision>
      <id>6270</id>
      <parentid>6269</parentid>
      <timestamp>2026-03-07T09:56:40Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6270</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3859" sha1="3lkt65ik6sl67s0k5dj23xfhkp86idb" xml:space="preserve">'''Udorhodera''' msebenzi wezokwelapha obandulweko onesibopho sokuhlola, ukwelapha abantu, nokukhandela amalwelwe nokulimala eengulini. Badlala indima eqakathekileko ekugcineni ipilo yomuntu ngamunye nomphakathi ngokunikela ngeenkonzo eziqakathekileko zokunakekelwa kwepilo. Abodorhodere babantu abafundileko begodu abanamakghono abazinikele ekwenzeni ngcono imiphumela yezamaphilo nokusindisa amaphilo wabantu. Basebenzela endaweni ebizwa bona kusemtholapilo begodu abanye babo banamasejari.&lt;ref&gt;Björk, J., Stenfors, T., Juth, N. and Gunnarsson, A.B., 2021. Personal responsibility for health? A phenomenographic analysis of general practitioners’ conceptions. ''Scandinavian Journal of Primary Health Care'', ''39''(3), pp.322-331.&lt;/ref&gt;

Imihlobo yabodorhodera

Kunemihlobo eminengi yabodorhodere, omunye nomunye osebenza ngeendawo ezithileko zezokwelapha ukutjheja iindaba ezihlukahlukeneko zepilo. Ezinye zeenkoro ezikulu zifaka hlangana: Abodorhodera abajayelekileko (Abodorhodera bemindeni): Abodorhodere laba banikela ngeenkonzo zezamaphilo eziqakathekileko, banikela ngeenkonzo zezamaphilo ezijayelekileko, ukuhlolwa okujayelekileko, kanye nokwelapha amalwelwe avamileko. Zisebenza njengendawo yokuthoma yokuthintana neengulani begodu zivame ukuzithumela kibososayensi nangabe kuyatlhogeka. Abodorhodera abaziingcweti: Abodorhodera laba badzimelele emkhakheni othileko wezokwelapha. Iimbonelo zifaka hlangana: Abodorhedere behliziyo bona abatjheje khulu emalwelweni ahlobene nehliziyo. Abodorhodere bezinso abasebenza ngokukhethekileko ekuphazamisekeni kwehlelo lezinso.&lt;ref&gt;[https://research.com/education/types-of-doctors Different Types of Doctors: What They Do, Medical Doctors &amp; Physicians Salary for 2026 | Research.com]&lt;/ref&gt;

Bese kube nabodorhodere besikhumba ekungibo abalapha ubujamo besikhumba. Kube nabodorhodera babantwana abatlhogomela ipilo yabantwana. Abodorhodere babantu bengubo-basiza ezintweni eziphathelene nepilo yokubeletha yabantu abasikazi. Abodorhodere bamathambo: bafunde khulu ngendaba yamathambo nemisipha. Bakghoa ukulekelela umuntu ngemiraro ephathelene naleyo. Abodorhodera abahlinzako- Abodorhodera laba benza imisebenzi yokwelapha ukulimala, ukukhubazeka, nofana amalwelwe. Bangaba bodorhodere abajayelekileko nofana abodorhodere abakhethekileko njengabodorhodere bezinzwa nofana abodorhodere behliziyo. Abodorhodere beengqondo bagxila eendabeni zepilo yengqondo, ukuhlola nokwelapha amalwelwe wengqondo ngokusebenzisa ukwelapha, imithi, nofana ezinye iindlela zokungenelela.&lt;ref&gt;[https://www.verywellhealth.com/types-of-doctors-1736311 Types of Doctors: Common Types and What They Do]&lt;/ref&gt;

Ukuqakatheka kwabodorhodera.

Abodorhodera baqakathekile emphakathini ngebanga lezizathu ezinengi ezifana nokugcinwa kwezamaphilo nokuvikelwa kwamalweleindlela yokuphila enepilo, banikela ngokugoma, begodu bafundisa umphakathi ngeengozi zepilo. Ukwelatjhwa nokuTjheja: Abodorhodera bahlola amalwelwe ngokunembileko begodu banikele ngokwelatjhwa okufaneleko, ukuqeda ubuhlungu nokutlhaga. Ukusindisa amaphilo Ebujameni oburhabekileko, abodorhodere benza iindlela zokusindisa amaphilo nokuhlinzwa, okwenza indima eqakathekileko ekusindiseni amaphilo.

Ukuthuthukisa Isayensi Yezokwelapha: Abodorhodera abanengi benza irhubhululo lokuthuthukisa iindlela zokwelapha ezitjha nokuthuthukisa lezo ezikhona, okwenza bona kube negalelo ekuthuthukisweni kwezokwelapha.Ukusekela Ukuphila kuhle Kwengqondo: Abodorhodera beengqondo nabelaphi basiza abantu bona baqalane neentjhijilo zempilo yengqondo, benze ngcono ikhwalithi yepilo yabo.Abodorhodera baziinsika eziqakathekileko zomphakathi ezinobungcweti babo obuqinisekisa ipilo nokuphila kuhle kwabantu nemiphakathi. Iimfundo zabo ezihlukahlukeneko zibenza bakghone ukuqalana neendaba ezinengi zezamaphilo, okwenza bona zibe ziqakathekile emphakathini ophilileko nosebenzako.</text>
      <sha1>3lkt65ik6sl67s0k5dj23xfhkp86idb</sha1>
    </revision>
    <revision>
      <id>6271</id>
      <parentid>6270</parentid>
      <timestamp>2026-03-07T09:58:34Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6271</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3888" sha1="17xnpnjrtaqxmw5vo0mrwtvh0xsuiq0" xml:space="preserve">'''Udorhodera''' msebenzi wezokwelapha obandulweko onesibopho sokuhlola, ukwelapha abantu, nokukhandela amalwelwe nokulimala eengulini. Badlala indima eqakathekileko ekugcineni ipilo yomuntu ngamunye nomphakathi ngokunikela ngeenkonzo eziqakathekileko zokunakekelwa kwepilo. Abodorhodere babantu abafundileko begodu abanamakghono abazinikele ekwenzeni ngcono imiphumela yezamaphilo nokusindisa amaphilo wabantu. Basebenzela endaweni ebizwa bona kusemtholapilo begodu abanye babo banamasejari.&lt;ref&gt;Björk, J., Stenfors, T., Juth, N. and Gunnarsson, A.B., 2021. Personal responsibility for health? A phenomenographic analysis of general practitioners’ conceptions. ''Scandinavian Journal of Primary Health Care'', ''39''(3), pp.322-331.&lt;/ref&gt;

=== Imihlobo yabodorhodera ===
Kunemihlobo eminengi yabodorhodere, omunye nomunye osebenza ngeendawo ezithileko zezokwelapha ukutjheja iindaba ezihlukahlukeneko zepilo. Ezinye zeenkoro ezikulu zifaka hlangana: Abodorhodera abajayelekileko (Abodorhodera bemindeni): Abodorhodere laba banikela ngeenkonzo zezamaphilo eziqakathekileko, banikela ngeenkonzo zezamaphilo ezijayelekileko, ukuhlolwa okujayelekileko, kanye nokwelapha amalwelwe avamileko. Zisebenza njengendawo yokuthoma yokuthintana neengulani begodu zivame ukuzithumela kibososayensi nangabe kuyatlhogeka. Abodorhodera abaziingcweti: Abodorhodera laba badzimelele emkhakheni othileko wezokwelapha. Iimbonelo zifaka hlangana: Abodorhedere behliziyo bona abatjheje khulu emalwelweni ahlobene nehliziyo. Abodorhodere bezinso abasebenza ngokukhethekileko ekuphazamisekeni kwehlelo lezinso.&lt;ref&gt;[https://research.com/education/types-of-doctors Different Types of Doctors: What They Do, Medical Doctors &amp; Physicians Salary for 2026 | Research.com]&lt;/ref&gt;

Bese kube nabodorhodere besikhumba ekungibo abalapha ubujamo besikhumba. Kube nabodorhodera babantwana abatlhogomela ipilo yabantwana. Abodorhodere babantu bengubo-basiza ezintweni eziphathelene nepilo yokubeletha yabantu abasikazi. Abodorhodere bamathambo: bafunde khulu ngendaba yamathambo nemisipha. Bakghoa ukulekelela umuntu ngemiraro ephathelene naleyo. Abodorhodera abahlinzako- Abodorhodera laba benza imisebenzi yokwelapha ukulimala, ukukhubazeka, nofana amalwelwe. Bangaba bodorhodere abajayelekileko nofana abodorhodere abakhethekileko njengabodorhodere bezinzwa nofana abodorhodere behliziyo. Abodorhodere beengqondo bagxila eendabeni zepilo yengqondo, ukuhlola nokwelapha amalwelwe wengqondo ngokusebenzisa ukwelapha, imithi, nofana ezinye iindlela zokungenelela.&lt;ref&gt;[https://www.verywellhealth.com/types-of-doctors-1736311 Types of Doctors: Common Types and What They Do]&lt;/ref&gt;

=== Ukuqakatheka kwabodorhodera ===
Abodorhodera baqakathekile emphakathini ngebanga lezizathu ezinengi ezifana nokugcinwa kwezamaphilo nokuvikelwa kwamalweleindlela yokuphila enepilo, banikela ngokugoma, begodu bafundisa umphakathi ngeengozi zepilo. Ukwelatjhwa nokuTjheja: Abodorhodera bahlola amalwelwe ngokunembileko begodu banikele ngokwelatjhwa okufaneleko, ukuqeda ubuhlungu nokutlhaga. Ukusindisa amaphilo Ebujameni oburhabekileko, abodorhodere benza iindlela zokusindisa amaphilo nokuhlinzwa, okwenza indima eqakathekileko ekusindiseni amaphilo.

Ukuthuthukisa Isayensi Yezokwelapha: Abodorhodera abanengi benza irhubhululo lokuthuthukisa iindlela zokwelapha ezitjha nokuthuthukisa lezo ezikhona, okwenza bona kube negalelo ekuthuthukisweni kwezokwelapha.Ukusekela Ukuphila kuhle Kwengqondo: Abodorhodera beengqondo nabelaphi basiza abantu bona baqalane neentjhijilo zempilo yengqondo, benze ngcono ikhwalithi yepilo yabo.Abodorhodera baziinsika eziqakathekileko zomphakathi ezinobungcweti babo obuqinisekisa ipilo nokuphila kuhle kwabantu nemiphakathi. Iimfundo zabo ezihlukahlukeneko zibenza bakghone ukuqalana neendaba ezinengi zezamaphilo, okwenza bona zibe ziqakathekile emphakathini ophilileko nosebenzako.

== Iinkomba ==</text>
      <sha1>17xnpnjrtaqxmw5vo0mrwtvh0xsuiq0</sha1>
    </revision>
    <revision>
      <id>6272</id>
      <parentid>6271</parentid>
      <timestamp>2026-03-07T10:02:04Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6272</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3964" sha1="t5ba5esn26mkwmtp7ecmquvjaqgk34v" xml:space="preserve">[[Isimumathi:Covid-19 San Salvatore 09.jpg|thumb|Udorhodere osemsebenzini]]
'''Udorhodera''' msebenzi wezokwelapha obandulweko onesibopho sokuhlola, ukwelapha abantu, nokukhandela amalwelwe nokulimala eengulini. Badlala indima eqakathekileko ekugcineni ipilo yomuntu ngamunye nomphakathi ngokunikela ngeenkonzo eziqakathekileko zokunakekelwa kwepilo. Abodorhodere babantu abafundileko begodu abanamakghono abazinikele ekwenzeni ngcono imiphumela yezamaphilo nokusindisa amaphilo wabantu. Basebenzela endaweni ebizwa bona kusemtholapilo begodu abanye babo banamasejari.&lt;ref&gt;Björk, J., Stenfors, T., Juth, N. and Gunnarsson, A.B., 2021. Personal responsibility for health? A phenomenographic analysis of general practitioners’ conceptions. ''Scandinavian Journal of Primary Health Care'', ''39''(3), pp.322-331.&lt;/ref&gt;

=== Imihlobo yabodorhodera ===
Kunemihlobo eminengi yabodorhodere, omunye nomunye osebenza ngeendawo ezithileko zezokwelapha ukutjheja iindaba ezihlukahlukeneko zepilo. Ezinye zeenkoro ezikulu zifaka hlangana: Abodorhodera abajayelekileko (Abodorhodera bemindeni): Abodorhodere laba banikela ngeenkonzo zezamaphilo eziqakathekileko, banikela ngeenkonzo zezamaphilo ezijayelekileko, ukuhlolwa okujayelekileko, kanye nokwelapha amalwelwe avamileko. Zisebenza njengendawo yokuthoma yokuthintana neengulani begodu zivame ukuzithumela kibososayensi nangabe kuyatlhogeka. Abodorhodera abaziingcweti: Abodorhodera laba badzimelele emkhakheni othileko wezokwelapha. Iimbonelo zifaka hlangana: Abodorhedere behliziyo bona abatjheje khulu emalwelweni ahlobene nehliziyo. Abodorhodere bezinso abasebenza ngokukhethekileko ekuphazamisekeni kwehlelo lezinso.&lt;ref&gt;[https://research.com/education/types-of-doctors Different Types of Doctors: What They Do, Medical Doctors &amp; Physicians Salary for 2026 | Research.com]&lt;/ref&gt;

Bese kube nabodorhodere besikhumba ekungibo abalapha ubujamo besikhumba. Kube nabodorhodera babantwana abatlhogomela ipilo yabantwana. Abodorhodere babantu bengubo-basiza ezintweni eziphathelene nepilo yokubeletha yabantu abasikazi. Abodorhodere bamathambo: bafunde khulu ngendaba yamathambo nemisipha. Bakghoa ukulekelela umuntu ngemiraro ephathelene naleyo. Abodorhodera abahlinzako- Abodorhodera laba benza imisebenzi yokwelapha ukulimala, ukukhubazeka, nofana amalwelwe. Bangaba bodorhodere abajayelekileko nofana abodorhodere abakhethekileko njengabodorhodere bezinzwa nofana abodorhodere behliziyo. Abodorhodere beengqondo bagxila eendabeni zepilo yengqondo, ukuhlola nokwelapha amalwelwe wengqondo ngokusebenzisa ukwelapha, imithi, nofana ezinye iindlela zokungenelela.&lt;ref&gt;[https://www.verywellhealth.com/types-of-doctors-1736311 Types of Doctors: Common Types and What They Do]&lt;/ref&gt;

=== Ukuqakatheka kwabodorhodera ===
Abodorhodera baqakathekile emphakathini ngebanga lezizathu ezinengi ezifana nokugcinwa kwezamaphilo nokuvikelwa kwamalweleindlela yokuphila enepilo, banikela ngokugoma, begodu bafundisa umphakathi ngeengozi zepilo. Ukwelatjhwa nokuTjheja: Abodorhodera bahlola amalwelwe ngokunembileko begodu banikele ngokwelatjhwa okufaneleko, ukuqeda ubuhlungu nokutlhaga. Ukusindisa amaphilo Ebujameni oburhabekileko, abodorhodere benza iindlela zokusindisa amaphilo nokuhlinzwa, okwenza indima eqakathekileko ekusindiseni amaphilo.

Ukuthuthukisa Isayensi Yezokwelapha: Abodorhodera abanengi benza irhubhululo lokuthuthukisa iindlela zokwelapha ezitjha nokuthuthukisa lezo ezikhona, okwenza bona kube negalelo ekuthuthukisweni kwezokwelapha.Ukusekela Ukuphila kuhle Kwengqondo: Abodorhodera beengqondo nabelaphi basiza abantu bona baqalane neentjhijilo zempilo yengqondo, benze ngcono ikhwalithi yepilo yabo.Abodorhodera baziinsika eziqakathekileko zomphakathi ezinobungcweti babo obuqinisekisa ipilo nokuphila kuhle kwabantu nemiphakathi. Iimfundo zabo ezihlukahlukeneko zibenza bakghone ukuqalana neendaba ezinengi zezamaphilo, okwenza bona zibe ziqakathekile emphakathini ophilileko nosebenzako.

== Iinkomba ==</text>
      <sha1>t5ba5esn26mkwmtp7ecmquvjaqgk34v</sha1>
    </revision>
    <revision>
      <id>6273</id>
      <parentid>6272</parentid>
      <timestamp>2026-03-07T10:53:58Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>6273</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4060" sha1="l8mb56ghkey2kg8skzggw1rz33l6yr1" xml:space="preserve">[[Isimumathi:Covid-19 San Salvatore 09.jpg|thumb|Udorhodere osemsebenzini]]
'''Udorhodera''' msebenzi wezokwelapha obandulweko onesibopho sokuhlola, ukwelapha abantu, nokukhandela amalwelwe nokulimala eengulini. Badlala indima eqakathekileko ekugcineni ipilo yomuntu ngamunye nomphakathi ngokunikela ngeenkonzo eziqakathekileko zokunakekelwa kwepilo. Abodorhodere babantu abafundileko begodu abanamakghono abazinikele ekwenzeni ngcono imiphumela yezamaphilo nokusindisa amaphilo wabantu. Basebenzela endaweni ebizwa bona kusemtholapilo begodu abanye babo banamasejari.&lt;ref&gt;Björk, J., Stenfors, T., Juth, N. and Gunnarsson, A.B., 2021. Personal responsibility for health? A phenomenographic analysis of general practitioners’ conceptions. ''Scandinavian Journal of Primary Health Care'', ''39''(3), pp.322-331.&lt;/ref&gt;

=== Imihlobo yabodorhodera ===
Kunemihlobo eminengi yabodorhodere, omunye nomunye osebenza ngeendawo ezithileko zezokwelapha ukutjheja iindaba ezihlukahlukeneko zepilo. Ezinye zeenkoro ezikulu zifaka hlangana: Abodorhodera abajayelekileko (Abodorhodera bemindeni): Abodorhodere laba banikela ngeenkonzo zezamaphilo eziqakathekileko, banikela ngeenkonzo zezamaphilo ezijayelekileko, ukuhlolwa okujayelekileko, kanye nokwelapha amalwelwe avamileko. Zisebenza njengendawo yokuthoma yokuthintana neengulani begodu zivame ukuzithumela kibososayensi nangabe kuyatlhogeka. Abodorhodera abaziingcweti: Abodorhodera laba badzimelele emkhakheni othileko wezokwelapha. Iimbonelo zifaka hlangana: Abodorhedere behliziyo bona abatjheje khulu emalwelweni ahlobene nehliziyo. Abodorhodere bezinso abasebenza ngokukhethekileko ekuphazamisekeni kwehlelo lezinso.&lt;ref&gt;[https://research.com/education/types-of-doctors Different Types of Doctors: What They Do, Medical Doctors &amp; Physicians Salary for 2026 | Research.com]&lt;/ref&gt;

Bese kube nabodorhodere besikhumba ekungibo abalapha ubujamo besikhumba. Kube nabodorhodera babantwana abatlhogomela ipilo yabantwana. Abodorhodere babantu bengubo-basiza ezintweni eziphathelene nepilo yokubeletha yabantu abasikazi. Abodorhodere bamathambo: bafunde khulu ngendaba yamathambo nemisipha. Bakghoa ukulekelela umuntu ngemiraro ephathelene naleyo. Abodorhodera abahlinzako- Abodorhodera laba benza imisebenzi yokwelapha ukulimala, ukukhubazeka, nofana amalwelwe. Bangaba bodorhodere abajayelekileko nofana abodorhodere abakhethekileko njengabodorhodere bezinzwa nofana abodorhodere behliziyo. Abodorhodere beengqondo bagxila eendabeni zepilo yengqondo, ukuhlola nokwelapha amalwelwe wengqondo ngokusebenzisa ukwelapha, imithi, nofana ezinye iindlela zokungenelela.&lt;ref&gt;[https://www.verywellhealth.com/types-of-doctors-1736311 Types of Doctors: Common Types and What They Do]&lt;/ref&gt;

=== Ukuqakatheka kwabodorhodera ===
Abodorhodera baqakathekile emphakathini ngebanga lezizathu ezinengi ezifana nokugcinwa kwezamaphilo nokuvikelwa kwamalweleindlela yokuphila enepilo, banikela ngokugoma, begodu bafundisa umphakathi ngeengozi zepilo. Ukwelatjhwa nokuTjheja: Abodorhodera bahlola amalwelwe ngokunembileko begodu banikele ngokwelatjhwa okufaneleko, ukuqeda ubuhlungu nokutlhaga. Ukusindisa amaphilo Ebujameni oburhabekileko, abodorhodere benza iindlela zokusindisa amaphilo nokuhlinzwa, okwenza indima eqakathekileko ekusindiseni amaphilo.

Ukuthuthukisa Isayensi Yezokwelapha: Abodorhodera abanengi benza irhubhululo lokuthuthukisa iindlela zokwelapha ezitjha nokuthuthukisa lezo ezikhona, okwenza bona kube negalelo ekuthuthukisweni kwezokwelapha.Ukusekela Ukuphila kuhle Kwengqondo: Abodorhodera beengqondo nabelaphi basiza abantu bona baqalane neentjhijilo zempilo yengqondo, benze ngcono ikhwalithi yepilo yabo.Abodorhodera baziinsika eziqakathekileko zomphakathi ezinobungcweti babo obuqinisekisa ipilo nokuphila kuhle kwabantu nemiphakathi. Iimfundo zabo ezihlukahlukeneko zibenza bakghone ukuqalana neendaba ezinengi zezamaphilo, okwenza bona zibe ziqakathekile emphakathini ophilileko nosebenzako.

== Iinkomba ==
[[Category:Umtholapilo]]
[[Category: Abantu abasisizako emphakathini]]
[[Categoty: Udorhodere]]</text>
      <sha1>l8mb56ghkey2kg8skzggw1rz33l6yr1</sha1>
    </revision>
    <revision>
      <id>6274</id>
      <parentid>6273</parentid>
      <timestamp>2026-03-07T10:54:35Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <origin>6274</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4060" sha1="sprriz089gw6hoa668jz1kmr1cyx87h" xml:space="preserve">[[Isimumathi:Covid-19 San Salvatore 09.jpg|thumb|Udorhodere osemsebenzini]]
'''Udorhodera''' msebenzi wezokwelapha obandulweko onesibopho sokuhlola, ukwelapha abantu, nokukhandela amalwelwe nokulimala eengulini. Badlala indima eqakathekileko ekugcineni ipilo yomuntu ngamunye nomphakathi ngokunikela ngeenkonzo eziqakathekileko zokunakekelwa kwepilo. Abodorhodere babantu abafundileko begodu abanamakghono abazinikele ekwenzeni ngcono imiphumela yezamaphilo nokusindisa amaphilo wabantu. Basebenzela endaweni ebizwa bona kusemtholapilo begodu abanye babo banamasejari.&lt;ref&gt;Björk, J., Stenfors, T., Juth, N. and Gunnarsson, A.B., 2021. Personal responsibility for health? A phenomenographic analysis of general practitioners’ conceptions. ''Scandinavian Journal of Primary Health Care'', ''39''(3), pp.322-331.&lt;/ref&gt;

=== Imihlobo yabodorhodera ===
Kunemihlobo eminengi yabodorhodere, omunye nomunye osebenza ngeendawo ezithileko zezokwelapha ukutjheja iindaba ezihlukahlukeneko zepilo. Ezinye zeenkoro ezikulu zifaka hlangana: Abodorhodera abajayelekileko (Abodorhodera bemindeni): Abodorhodere laba banikela ngeenkonzo zezamaphilo eziqakathekileko, banikela ngeenkonzo zezamaphilo ezijayelekileko, ukuhlolwa okujayelekileko, kanye nokwelapha amalwelwe avamileko. Zisebenza njengendawo yokuthoma yokuthintana neengulani begodu zivame ukuzithumela kibososayensi nangabe kuyatlhogeka. Abodorhodera abaziingcweti: Abodorhodera laba badzimelele emkhakheni othileko wezokwelapha. Iimbonelo zifaka hlangana: Abodorhedere behliziyo bona abatjheje khulu emalwelweni ahlobene nehliziyo. Abodorhodere bezinso abasebenza ngokukhethekileko ekuphazamisekeni kwehlelo lezinso.&lt;ref&gt;[https://research.com/education/types-of-doctors Different Types of Doctors: What They Do, Medical Doctors &amp; Physicians Salary for 2026 | Research.com]&lt;/ref&gt;

Bese kube nabodorhodere besikhumba ekungibo abalapha ubujamo besikhumba. Kube nabodorhodera babantwana abatlhogomela ipilo yabantwana. Abodorhodere babantu bengubo-basiza ezintweni eziphathelene nepilo yokubeletha yabantu abasikazi. Abodorhodere bamathambo: bafunde khulu ngendaba yamathambo nemisipha. Bakghoa ukulekelela umuntu ngemiraro ephathelene naleyo. Abodorhodera abahlinzako- Abodorhodera laba benza imisebenzi yokwelapha ukulimala, ukukhubazeka, nofana amalwelwe. Bangaba bodorhodere abajayelekileko nofana abodorhodere abakhethekileko njengabodorhodere bezinzwa nofana abodorhodere behliziyo. Abodorhodere beengqondo bagxila eendabeni zepilo yengqondo, ukuhlola nokwelapha amalwelwe wengqondo ngokusebenzisa ukwelapha, imithi, nofana ezinye iindlela zokungenelela.&lt;ref&gt;[https://www.verywellhealth.com/types-of-doctors-1736311 Types of Doctors: Common Types and What They Do]&lt;/ref&gt;

=== Ukuqakatheka kwabodorhodera ===
Abodorhodera baqakathekile emphakathini ngebanga lezizathu ezinengi ezifana nokugcinwa kwezamaphilo nokuvikelwa kwamalweleindlela yokuphila enepilo, banikela ngokugoma, begodu bafundisa umphakathi ngeengozi zepilo. Ukwelatjhwa nokuTjheja: Abodorhodera bahlola amalwelwe ngokunembileko begodu banikele ngokwelatjhwa okufaneleko, ukuqeda ubuhlungu nokutlhaga. Ukusindisa amaphilo Ebujameni oburhabekileko, abodorhodere benza iindlela zokusindisa amaphilo nokuhlinzwa, okwenza indima eqakathekileko ekusindiseni amaphilo.

Ukuthuthukisa Isayensi Yezokwelapha: Abodorhodera abanengi benza irhubhululo lokuthuthukisa iindlela zokwelapha ezitjha nokuthuthukisa lezo ezikhona, okwenza bona kube negalelo ekuthuthukisweni kwezokwelapha.Ukusekela Ukuphila kuhle Kwengqondo: Abodorhodera beengqondo nabelaphi basiza abantu bona baqalane neentjhijilo zempilo yengqondo, benze ngcono ikhwalithi yepilo yabo.Abodorhodera baziinsika eziqakathekileko zomphakathi ezinobungcweti babo obuqinisekisa ipilo nokuphila kuhle kwabantu nemiphakathi. Iimfundo zabo ezihlukahlukeneko zibenza bakghone ukuqalana neendaba ezinengi zezamaphilo, okwenza bona zibe ziqakathekile emphakathini ophilileko nosebenzako.

== Iinkomba ==
[[Category:Umtholapilo]]
[[Category: Abantu abasisizako emphakathini]]
[[Category: Udorhodere]]</text>
      <sha1>sprriz089gw6hoa668jz1kmr1cyx87h</sha1>
    </revision>
    <revision>
      <id>6658</id>
      <parentid>6274</parentid>
      <timestamp>2026-05-20T19:51:50Z</timestamp>
      <contributor>
        <username>Nomsa Skosana</username>
        <id>123</id>
      </contributor>
      <minor />
      <origin>6658</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4056" sha1="75v579d9jga8w9g661i0tvuyouspkq0" xml:space="preserve">[[Isimumathi:Covid-19 San Salvatore 09.jpg|thumb|Udorhodere osemsebenzini]]
'''Udorhodera''' msebenzi wezokwelapha obandulweko onesibopho sokuhlola, ukwelapha abantu, nokukhandela amalwelwe nokulimala eengulini. Badlala indima eqakathekileko ekugcineni ipilo yomuntu ngamunye nomphakathi ngokunikela ngeenkonzo eziqakathekileko zokunakekelwa kwepilo. Abodorhodere babantu abafundileko begodu abanamakghono abazinikele ekwenzeni ngcono imiphumela yezamaphilo nokusindisa amaphilo wabantu. Basebenzela endaweni ebizwa bona kusemtholapilo begodu abanye babo banamasejari.&lt;ref&gt;Björk, J., Stenfors, T., Juth, N. and Gunnarsson, A.B., 2021. Personal responsibility for health? A phenomenographic analysis of general practitioners’ conceptions. ''Scandinavian Journal of Primary Health Care'', ''39''(3), pp.322-331.&lt;/ref&gt;

== Imihlobo yabodorhodera ==
Kunemihlobo eminengi yabodorhodere, omunye nomunye osebenza ngeendawo ezithileko zezokwelapha ukutjheja iindaba ezihlukahlukeneko zepilo. Ezinye zeenkoro ezikulu zifaka hlangana: Abodorhodera abajayelekileko (Abodorhodera bemindeni): Abodorhodere laba banikela ngeenkonzo zezamaphilo eziqakathekileko, banikela ngeenkonzo zezamaphilo ezijayelekileko, ukuhlolwa okujayelekileko, kanye nokwelapha amalwelwe avamileko. Zisebenza njengendawo yokuthoma yokuthintana neengulani begodu zivame ukuzithumela kibososayensi nangabe kuyatlhogeka. Abodorhodera abaziingcweti: Abodorhodera laba badzimelele emkhakheni othileko wezokwelapha. Iimbonelo zifaka hlangana: Abodorhedere behliziyo bona abatjheje khulu emalwelweni ahlobene nehliziyo. Abodorhodere bezinso abasebenza ngokukhethekileko ekuphazamisekeni kwehlelo lezinso.&lt;ref&gt;[https://research.com/education/types-of-doctors Different Types of Doctors: What They Do, Medical Doctors &amp; Physicians Salary for 2026 | Research.com]&lt;/ref&gt;

Bese kube nabodorhodere besikhumba ekungibo abalapha ubujamo besikhumba. Kube nabodorhodera babantwana abatlhogomela ipilo yabantwana. Abodorhodere babantu bengubo-basiza ezintweni eziphathelene nepilo yokubeletha yabantu abasikazi. Abodorhodere bamathambo: bafunde khulu ngendaba yamathambo nemisipha. Bakghoa ukulekelela umuntu ngemiraro ephathelene naleyo. Abodorhodera abahlinzako- Abodorhodera laba benza imisebenzi yokwelapha ukulimala, ukukhubazeka, nofana amalwelwe. Bangaba bodorhodere abajayelekileko nofana abodorhodere abakhethekileko njengabodorhodere bezinzwa nofana abodorhodere behliziyo. Abodorhodere beengqondo bagxila eendabeni zepilo yengqondo, ukuhlola nokwelapha amalwelwe wengqondo ngokusebenzisa ukwelapha, imithi, nofana ezinye iindlela zokungenelela.&lt;ref&gt;[https://www.verywellhealth.com/types-of-doctors-1736311 Types of Doctors: Common Types and What They Do]&lt;/ref&gt;

== Ukuqakatheka kwabodorhodera ==
Abodorhodera baqakathekile emphakathini ngebanga lezizathu ezinengi ezifana nokugcinwa kwezamaphilo nokuvikelwa kwamalweleindlela yokuphila enepilo, banikela ngokugoma, begodu bafundisa umphakathi ngeengozi zepilo. Ukwelatjhwa nokuTjheja: Abodorhodera bahlola amalwelwe ngokunembileko begodu banikele ngokwelatjhwa okufaneleko, ukuqeda ubuhlungu nokutlhaga. Ukusindisa amaphilo Ebujameni oburhabekileko, abodorhodere benza iindlela zokusindisa amaphilo nokuhlinzwa, okwenza indima eqakathekileko ekusindiseni amaphilo.

Ukuthuthukisa Isayensi Yezokwelapha: Abodorhodera abanengi benza irhubhululo lokuthuthukisa iindlela zokwelapha ezitjha nokuthuthukisa lezo ezikhona, okwenza bona kube negalelo ekuthuthukisweni kwezokwelapha.Ukusekela Ukuphila kuhle Kwengqondo: Abodorhodera beengqondo nabelaphi basiza abantu bona baqalane neentjhijilo zempilo yengqondo, benze ngcono ikhwalithi yepilo yabo.Abodorhodera baziinsika eziqakathekileko zomphakathi ezinobungcweti babo obuqinisekisa ipilo nokuphila kuhle kwabantu nemiphakathi. Iimfundo zabo ezihlukahlukeneko zibenza bakghone ukuqalana neendaba ezinengi zezamaphilo, okwenza bona zibe ziqakathekile emphakathini ophilileko nosebenzako.

== Iinkomba ==
[[Category:Umtholapilo]]
[[Category: Abantu abasisizako emphakathini]]
[[Category: Udorhodere]]</text>
      <sha1>75v579d9jga8w9g661i0tvuyouspkq0</sha1>
    </revision>
  </page>
  <page>
    <title>Ukurarana kweNtaba ye-Zungeni</title>
    <ns>0</ns>
    <id>1060</id>
    <revision>
      <id>6275</id>
      <timestamp>2026-03-10T04:01:39Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1342628315|Zungeni Mountain skirmish]]&quot;</comment>
      <origin>6275</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4884" sha1="o4k7g9l3uo8qi1dk62kiyuky2n9dain" xml:space="preserve">
'''Ukulwa kwe-Zungeni Mountain''' kwenzeka mhlazi-5 kuMgwengweni 1879 hlangana namabutho we-Britain nama -Zulu ngesikhathi sokuhlasela kwesibili i- Zululand, endaweni esele iSewula Afrika, eengabeni zokugcina ze- Anglo-Zulu War . Ihhashi elingakajayeleki le-Britain elilawulwa ngu -Colonel Redvers Buller lathola ibutho lama-Zulu ama-300 endaweni yokuhlala ye-eZulaneni hlanu kweNtaba ye-Zungeni. [ nb 1 ] Abakhweli bamahhashi bahlasela begodu bahlakaza amaZulu ngaphambi kokutjhisa indawo yokuhlala. Amadoda ka-Buller arhoxa ngemva kokuhlaselwa ma-Zulu ebegade asongela ngokuwazungeza.

Amadoda ka-Buller ahlanganiswa nabantu abanengi abangakajayeleki kanye nebutho lamabutho wamabhiza we-Britain, la ngaphasi komyalo ka- Major-General Frederick Marshall . Amaskwadroni amabili we- 17th (The Duke of Cambridge's Own) Lancers, aholwa ngu-Colonel Drury Drury-Lowe, atjhidela endaweni yamaZulu. Bebangakghoni ukuvala nama-Zulu, ebegade asendaweni enotshani obude namahlathi, begodu umlilo we-Zulu wabulala i-adjutant ye-17th Lancers, u-Lieutenant Frederick John Cokayne Frith . U-Drury-Lowe wayala amanye wamadoda wakhe bona ehle begodu abuyisele umlilo. Lokha ama-Zulu nakasongela ukudlula ama-British, u-Marshall wayala bona baphume. Ngaphandle kwaka-Frith, abalimeleko be-Britain bafaka hlangana abalimeleko ababili; ngemva kweenyanga ezimbili ipi, iinsalela zamaZulu ama-25 zatholakala endaweni yepi. Ngemva kokulwa, amaNgisi ajama ukuqinisa ikampa yawo ngaphambi kobana aqhubekele phambili eZululand. Ngemva kwalokho bahlula amaZulu ePini ye-Ulundi yango-4 kuNtaka.

== Isendlalelo ==
UKhomitjhinara oPhakemeko we-Britain weSewula ye-Afrika, u-Sir Henry Bartle Frere, wafuna ukuhlanganisa umBuso we-Zulu ozijameleko njengengcenye yehlelo lokwakha ihlangano yamakoloni aseSewula ye-Afrika . U-Frere wabamba ingxabano yomthetho ngoJulayi 1878 ebandakanya induna yamaZulu u-Sihayo kaXongo . Abafazi ababili benduna bebamtjhiya babalekela ngaphetjheya komngcele baya eKoloni ye-Britain ye-Natal . Amadodana kaSihayo abese arhola isiqhema esihlomileko ekolonini esathatha abafazi bona babulawe. &lt;ref&gt;https://books.google.pt/books?hl=en&amp;lr=&amp;id=npwiCbbEikkC&amp;oi=fnd&amp;pg=PR5&amp;dq=Zungeni+Mountain+skirmish&amp;ots=ao_G0CF-y4&amp;sig=u4tBO8icGhW_8rDN_LILRBE8zVk&amp;redir_esc=y#v=onepage&amp;q=Zungeni%20Mountain%20skirmish&amp;f=false&lt;/ref&gt;NgoNobayeni 1878, u-Frere wahlanganisa amabutho we-Britain emingceleni ye-Zululand begodu wethula u-Cetshwayo isimemezelo sokugcina esifuna ukubuyiselwa kwamadodana ka-Sihayo, amatjhuguluko erherhweni lezokwahlulela lama-Zulu, ukwamukelwa kweenthunywa zevangeli zamaKrestu kanye nokuqedwa kohlelo lwezenhlalakahle/lebutho lama-Zulu elaziwa nge ''-iButho'' . &lt;ref&gt;https://www.tandfonline.com/doi/abs/10.1179/0729247314Z.00000000040&lt;/ref&gt;I-ultimatum beyifuna amatjhuguluko amakhulu endleleni yokuphila yamaZulu, begodu bekuhloswe ngu-Frere bona u-Cetshwayo ayilahle. &lt;ref&gt;https://books.google.pt/books?hl=en&amp;lr=&amp;id=mmp-AwAAQBAJ&amp;oi=fnd&amp;pg=PP11&amp;dq=Zungeni+Mountain+skirmish&amp;ots=0OQsgnrsfn&amp;sig=jzJ4LUACpWgqZCJ68RFNoj6FMkU&amp;redir_esc=y#v=onepage&amp;q&amp;f=false&lt;/ref&gt;


Nanyana bekangakghoni ukulandela imibandela yamaBrithani, khulukhulu ukuqedwa kwama-iButho, u-Cetshwayo wenza imizamo yokubuyisana, wathumela abajameli neenkomo emaBrithani. Kwathi lokha nasele kwaliwe, u-Cetshwayo wenza amalungiselelo wepi yokuzivikela. Wayala amabutho, ebegade azokuhlangana enhlokodolobha yamaZulu e-Ulundi mhlazi-8 kuTjhirhweni emnyanyeni we-umKhosi (Iinthelo zokuthoma), bona eze alungele ukulwa. &lt;ref&gt;https://books.google.pt/books?hl=en&amp;lr=&amp;id=1bE2SW9v7BQC&amp;oi=fnd&amp;pg=IA2&amp;dq=Zungeni+Mountain+skirmish&amp;ots=b9-QSjAPLs&amp;sig=04paqlh8ZHpTffNzt6q2xIEFn9s&amp;redir_esc=y#v=onepage&amp;q&amp;f=false&lt;/ref&gt;Ngaleso sikhathi inani lamadoda ebekufuze asebenze ebuthweni belibalelwa ku-42,000 ukuya ku-44,000, hlangana nenani labantu ebelingaba zi-300,000.[3][16] Abantu abangaba zi-25,000 babuthana e-Ulundi emnyanyeni lo begodu babunjwa baba libutho lekosi. Nanyana bekuneenkhali ezingaba zi-20,000 emaZulu ekuthomeni kwepi, inengi lazo bekuziinkhali ezingasebenziko begodu amadoda bekangakafundiswa ukuzisebenzisa. iklwa ukuhlaba umkhonto.&lt;ref&gt;https://books.google.pt/books?hl=en&amp;lr=&amp;id=vxnwDQAAQBAJ&amp;oi=fnd&amp;pg=PP8&amp;dq=Zungeni+Mountain+skirmish&amp;ots=1L3A7Oq0l5&amp;sig=Lc0qDpMJHt8JGfxb9DSVu2EcBts&amp;redir_esc=y#v=onepage&amp;q&amp;f=false&lt;/ref&gt;
[[File:Frontier_Light_Horse_Zulu_War.jpg|alt=An engraving showing two uniformed and mounted men with slung carbines, surveying the landscape|thumb|Umfanekiso wango-1884 wamadoda amabili we-Frontier Light Horse ngesikhathi sepi]]
[[Isimumathi:A-Zulu-regiment-attacking-at-iSandlwana.jpg|alt=A black-and-white copy of a watercolour showing a line of Zulus advancing in the foreground, more Zulus are visible in the background.|thumb|Ukuvezwa kwamaZulu ngesikhathi sepi; indoda engakwesokunxele iphethe isibhamu se-Martini-Henry begodu ifake ibhande leenhlamvu le-Britain.]]

== Iinkomba ==</text>
      <sha1>o4k7g9l3uo8qi1dk62kiyuky2n9dain</sha1>
    </revision>
    <revision>
      <id>6276</id>
      <parentid>6275</parentid>
      <timestamp>2026-03-10T04:02:04Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6276</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4655" sha1="icig32qf2kycyi3po0c878ja7nsb0b0" xml:space="preserve">
'''Ukulwa kwe-Zungeni Mountain''' kwenzeka mhlazi-5 kuMgwengweni 1879 hlangana namabutho we-Britain nama -Zulu ngesikhathi sokuhlasela kwesibili i- Zululand, endaweni esele iSewula Afrika, eengabeni zokugcina ze- Anglo-Zulu War . Ihhashi elingakajayeleki le-Britain elilawulwa ngu -Colonel Redvers Buller lathola ibutho lama-Zulu ama-300 endaweni yokuhlala ye-eZulaneni hlanu kweNtaba ye-Zungeni. [ nb 1 ] Abakhweli bamahhashi bahlasela begodu bahlakaza amaZulu ngaphambi kokutjhisa indawo yokuhlala. Amadoda ka-Buller arhoxa ngemva kokuhlaselwa ma-Zulu ebegade asongela ngokuwazungeza.

Amadoda ka-Buller ahlanganiswa nabantu abanengi abangakajayeleki kanye nebutho lamabutho wamabhiza we-Britain, la ngaphasi komyalo ka- Major-General Frederick Marshall . Amaskwadroni amabili we- 17th (The Duke of Cambridge's Own) Lancers, aholwa ngu-Colonel Drury Drury-Lowe, atjhidela endaweni yamaZulu. Bebangakghoni ukuvala nama-Zulu, ebegade asendaweni enotshani obude namahlathi, begodu umlilo we-Zulu wabulala i-adjutant ye-17th Lancers, u-Lieutenant Frederick John Cokayne Frith . U-Drury-Lowe wayala amanye wamadoda wakhe bona ehle begodu abuyisele umlilo. Lokha ama-Zulu nakasongela ukudlula ama-British, u-Marshall wayala bona baphume. Ngaphandle kwaka-Frith, abalimeleko be-Britain bafaka hlangana abalimeleko ababili; ngemva kweenyanga ezimbili ipi, iinsalela zamaZulu ama-25 zatholakala endaweni yepi. Ngemva kokulwa, amaNgisi ajama ukuqinisa ikampa yawo ngaphambi kobana aqhubekele phambili eZululand. Ngemva kwalokho bahlula amaZulu ePini ye-Ulundi yango-4 kuNtaka.

== Isendlalelo ==
UKhomitjhinara oPhakemeko we-Britain weSewula ye-Afrika, u-Sir Henry Bartle Frere, wafuna ukuhlanganisa umBuso we-Zulu ozijameleko njengengcenye yehlelo lokwakha ihlangano yamakoloni aseSewula ye-Afrika . U-Frere wabamba ingxabano yomthetho ngoJulayi 1878 ebandakanya induna yamaZulu u-Sihayo kaXongo . Abafazi ababili benduna bebamtjhiya babalekela ngaphetjheya komngcele baya eKoloni ye-Britain ye-Natal . Amadodana kaSihayo abese arhola isiqhema esihlomileko ekolonini esathatha abafazi bona babulawe. &lt;ref&gt;https://books.google.pt/books?hl=en&amp;lr=&amp;id=npwiCbbEikkC&amp;oi=fnd&amp;pg=PR5&amp;dq=Zungeni+Mountain+skirmish&amp;ots=ao_G0CF-y4&amp;sig=u4tBO8icGhW_8rDN_LILRBE8zVk&amp;redir_esc=y#v=onepage&amp;q=Zungeni%20Mountain%20skirmish&amp;f=false&lt;/ref&gt;NgoNobayeni 1878, u-Frere wahlanganisa amabutho we-Britain emingceleni ye-Zululand begodu wethula u-Cetshwayo isimemezelo sokugcina esifuna ukubuyiselwa kwamadodana ka-Sihayo, amatjhuguluko erherhweni lezokwahlulela lama-Zulu, ukwamukelwa kweenthunywa zevangeli zamaKrestu kanye nokuqedwa kohlelo lwezenhlalakahle/lebutho lama-Zulu elaziwa nge ''-iButho'' . &lt;ref&gt;https://www.tandfonline.com/doi/abs/10.1179/0729247314Z.00000000040&lt;/ref&gt;I-ultimatum beyifuna amatjhuguluko amakhulu endleleni yokuphila yamaZulu, begodu bekuhloswe ngu-Frere bona u-Cetshwayo ayilahle. &lt;ref&gt;https://books.google.pt/books?hl=en&amp;lr=&amp;id=mmp-AwAAQBAJ&amp;oi=fnd&amp;pg=PP11&amp;dq=Zungeni+Mountain+skirmish&amp;ots=0OQsgnrsfn&amp;sig=jzJ4LUACpWgqZCJ68RFNoj6FMkU&amp;redir_esc=y#v=onepage&amp;q&amp;f=false&lt;/ref&gt;


Nanyana bekangakghoni ukulandela imibandela yamaBrithani, khulukhulu ukuqedwa kwama-iButho, u-Cetshwayo wenza imizamo yokubuyisana, wathumela abajameli neenkomo emaBrithani. Kwathi lokha nasele kwaliwe, u-Cetshwayo wenza amalungiselelo wepi yokuzivikela. Wayala amabutho, ebegade azokuhlangana enhlokodolobha yamaZulu e-Ulundi mhlazi-8 kuTjhirhweni emnyanyeni we-umKhosi (Iinthelo zokuthoma), bona eze alungele ukulwa. &lt;ref&gt;https://books.google.pt/books?hl=en&amp;lr=&amp;id=1bE2SW9v7BQC&amp;oi=fnd&amp;pg=IA2&amp;dq=Zungeni+Mountain+skirmish&amp;ots=b9-QSjAPLs&amp;sig=04paqlh8ZHpTffNzt6q2xIEFn9s&amp;redir_esc=y#v=onepage&amp;q&amp;f=false&lt;/ref&gt;Ngaleso sikhathi inani lamadoda ebekufuze asebenze ebuthweni belibalelwa ku-42,000 ukuya ku-44,000, hlangana nenani labantu ebelingaba zi-300,000.[3][16] Abantu abangaba zi-25,000 babuthana e-Ulundi emnyanyeni lo begodu babunjwa baba libutho lekosi. Nanyana bekuneenkhali ezingaba zi-20,000 emaZulu ekuthomeni kwepi, inengi lazo bekuziinkhali ezingasebenziko begodu amadoda bekangakafundiswa ukuzisebenzisa. iklwa ukuhlaba umkhonto.&lt;ref&gt;https://books.google.pt/books?hl=en&amp;lr=&amp;id=vxnwDQAAQBAJ&amp;oi=fnd&amp;pg=PP8&amp;dq=Zungeni+Mountain+skirmish&amp;ots=1L3A7Oq0l5&amp;sig=Lc0qDpMJHt8JGfxb9DSVu2EcBts&amp;redir_esc=y#v=onepage&amp;q&amp;f=false&lt;/ref&gt;
[[Isimumathi:A-Zulu-regiment-attacking-at-iSandlwana.jpg|alt=A black-and-white copy of a watercolour showing a line of Zulus advancing in the foreground, more Zulus are visible in the background.|thumb|Ukuvezwa kwamaZulu ngesikhathi sepi; indoda engakwesokunxele iphethe isibhamu se-Martini-Henry begodu ifake ibhande leenhlamvu le-Britain.]]

== Iinkomba ==</text>
      <sha1>icig32qf2kycyi3po0c878ja7nsb0b0</sha1>
    </revision>
    <revision>
      <id>6277</id>
      <parentid>6276</parentid>
      <timestamp>2026-03-10T04:02:23Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6277</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4653" sha1="5e92e258is62vr55pdmttldb4g4n225" xml:space="preserve">
[[Isimumathi:A-Zulu-regiment-attacking-at-iSandlwana.jpg|alt=A black-and-white copy of a watercolour showing a line of Zulus advancing in the foreground, more Zulus are visible in the background.|thumb|Ukuvezwa kwamaZulu ngesikhathi sepi; indoda engakwesokunxele iphethe isibhamu se-Martini-Henry begodu ifake ibhande leenhlamvu le-Britain.]]'''Ukulwa kwe-Zungeni Mountain''' kwenzeka mhlazi-5 kuMgwengweni 1879 hlangana namabutho we-Britain nama -Zulu ngesikhathi sokuhlasela kwesibili i- Zululand, endaweni esele iSewula Afrika, eengabeni zokugcina ze- Anglo-Zulu War . Ihhashi elingakajayeleki le-Britain elilawulwa ngu -Colonel Redvers Buller lathola ibutho lama-Zulu ama-300 endaweni yokuhlala ye-eZulaneni hlanu kweNtaba ye-Zungeni. [ nb 1 ] Abakhweli bamahhashi bahlasela begodu bahlakaza amaZulu ngaphambi kokutjhisa indawo yokuhlala. Amadoda ka-Buller arhoxa ngemva kokuhlaselwa ma-Zulu ebegade asongela ngokuwazungeza.

Amadoda ka-Buller ahlanganiswa nabantu abanengi abangakajayeleki kanye nebutho lamabutho wamabhiza we-Britain, la ngaphasi komyalo ka- Major-General Frederick Marshall . Amaskwadroni amabili we- 17th (The Duke of Cambridge's Own) Lancers, aholwa ngu-Colonel Drury Drury-Lowe, atjhidela endaweni yamaZulu. Bebangakghoni ukuvala nama-Zulu, ebegade asendaweni enotshani obude namahlathi, begodu umlilo we-Zulu wabulala i-adjutant ye-17th Lancers, u-Lieutenant Frederick John Cokayne Frith . U-Drury-Lowe wayala amanye wamadoda wakhe bona ehle begodu abuyisele umlilo. Lokha ama-Zulu nakasongela ukudlula ama-British, u-Marshall wayala bona baphume. Ngaphandle kwaka-Frith, abalimeleko be-Britain bafaka hlangana abalimeleko ababili; ngemva kweenyanga ezimbili ipi, iinsalela zamaZulu ama-25 zatholakala endaweni yepi. Ngemva kokulwa, amaNgisi ajama ukuqinisa ikampa yawo ngaphambi kobana aqhubekele phambili eZululand. Ngemva kwalokho bahlula amaZulu ePini ye-Ulundi yango-4 kuNtaka.

== Isendlalelo ==
UKhomitjhinara oPhakemeko we-Britain weSewula ye-Afrika, u-Sir Henry Bartle Frere, wafuna ukuhlanganisa umBuso we-Zulu ozijameleko njengengcenye yehlelo lokwakha ihlangano yamakoloni aseSewula ye-Afrika . U-Frere wabamba ingxabano yomthetho ngoJulayi 1878 ebandakanya induna yamaZulu u-Sihayo kaXongo . Abafazi ababili benduna bebamtjhiya babalekela ngaphetjheya komngcele baya eKoloni ye-Britain ye-Natal . Amadodana kaSihayo abese arhola isiqhema esihlomileko ekolonini esathatha abafazi bona babulawe. &lt;ref&gt;https://books.google.pt/books?hl=en&amp;lr=&amp;id=npwiCbbEikkC&amp;oi=fnd&amp;pg=PR5&amp;dq=Zungeni+Mountain+skirmish&amp;ots=ao_G0CF-y4&amp;sig=u4tBO8icGhW_8rDN_LILRBE8zVk&amp;redir_esc=y#v=onepage&amp;q=Zungeni%20Mountain%20skirmish&amp;f=false&lt;/ref&gt;NgoNobayeni 1878, u-Frere wahlanganisa amabutho we-Britain emingceleni ye-Zululand begodu wethula u-Cetshwayo isimemezelo sokugcina esifuna ukubuyiselwa kwamadodana ka-Sihayo, amatjhuguluko erherhweni lezokwahlulela lama-Zulu, ukwamukelwa kweenthunywa zevangeli zamaKrestu kanye nokuqedwa kohlelo lwezenhlalakahle/lebutho lama-Zulu elaziwa nge ''-iButho'' . &lt;ref&gt;https://www.tandfonline.com/doi/abs/10.1179/0729247314Z.00000000040&lt;/ref&gt;I-ultimatum beyifuna amatjhuguluko amakhulu endleleni yokuphila yamaZulu, begodu bekuhloswe ngu-Frere bona u-Cetshwayo ayilahle. &lt;ref&gt;https://books.google.pt/books?hl=en&amp;lr=&amp;id=mmp-AwAAQBAJ&amp;oi=fnd&amp;pg=PP11&amp;dq=Zungeni+Mountain+skirmish&amp;ots=0OQsgnrsfn&amp;sig=jzJ4LUACpWgqZCJ68RFNoj6FMkU&amp;redir_esc=y#v=onepage&amp;q&amp;f=false&lt;/ref&gt;


Nanyana bekangakghoni ukulandela imibandela yamaBrithani, khulukhulu ukuqedwa kwama-iButho, u-Cetshwayo wenza imizamo yokubuyisana, wathumela abajameli neenkomo emaBrithani. Kwathi lokha nasele kwaliwe, u-Cetshwayo wenza amalungiselelo wepi yokuzivikela. Wayala amabutho, ebegade azokuhlangana enhlokodolobha yamaZulu e-Ulundi mhlazi-8 kuTjhirhweni emnyanyeni we-umKhosi (Iinthelo zokuthoma), bona eze alungele ukulwa. &lt;ref&gt;https://books.google.pt/books?hl=en&amp;lr=&amp;id=1bE2SW9v7BQC&amp;oi=fnd&amp;pg=IA2&amp;dq=Zungeni+Mountain+skirmish&amp;ots=b9-QSjAPLs&amp;sig=04paqlh8ZHpTffNzt6q2xIEFn9s&amp;redir_esc=y#v=onepage&amp;q&amp;f=false&lt;/ref&gt;Ngaleso sikhathi inani lamadoda ebekufuze asebenze ebuthweni belibalelwa ku-42,000 ukuya ku-44,000, hlangana nenani labantu ebelingaba zi-300,000.[3][16] Abantu abangaba zi-25,000 babuthana e-Ulundi emnyanyeni lo begodu babunjwa baba libutho lekosi. Nanyana bekuneenkhali ezingaba zi-20,000 emaZulu ekuthomeni kwepi, inengi lazo bekuziinkhali ezingasebenziko begodu amadoda bekangakafundiswa ukuzisebenzisa. iklwa ukuhlaba umkhonto.&lt;ref&gt;https://books.google.pt/books?hl=en&amp;lr=&amp;id=vxnwDQAAQBAJ&amp;oi=fnd&amp;pg=PP8&amp;dq=Zungeni+Mountain+skirmish&amp;ots=1L3A7Oq0l5&amp;sig=Lc0qDpMJHt8JGfxb9DSVu2EcBts&amp;redir_esc=y#v=onepage&amp;q&amp;f=false&lt;/ref&gt;
== Iinkomba ==</text>
      <sha1>5e92e258is62vr55pdmttldb4g4n225</sha1>
    </revision>
    <revision>
      <id>6278</id>
      <parentid>6277</parentid>
      <timestamp>2026-03-10T04:02:52Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6278</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4663" sha1="8c96yur15c83hr7hk3rmd0nenfd6qeq" xml:space="preserve">
[[Isimumathi:A-Zulu-regiment-attacking-at-iSandlwana.jpg|alt=A black-and-white copy of a watercolour showing a line of Zulus advancing in the foreground, more Zulus are visible in the background.|thumb|Ukuvezwa kwamaZulu ngesikhathi sepi; indoda engakwesokunxele iphethe isibhamu se-Martini-Henry begodu ifake ibhande leenhlamvu le-Britain.|450x450px]]'''Ukulwa kwe-Zungeni Mountain''' kwenzeka mhlazi-5 kuMgwengweni 1879 hlangana namabutho we-Britain nama -Zulu ngesikhathi sokuhlasela kwesibili i- Zululand, endaweni esele iSewula Afrika, eengabeni zokugcina ze- Anglo-Zulu War . Ihhashi elingakajayeleki le-Britain elilawulwa ngu -Colonel Redvers Buller lathola ibutho lama-Zulu ama-300 endaweni yokuhlala ye-eZulaneni hlanu kweNtaba ye-Zungeni. [ nb 1 ] Abakhweli bamahhashi bahlasela begodu bahlakaza amaZulu ngaphambi kokutjhisa indawo yokuhlala. Amadoda ka-Buller arhoxa ngemva kokuhlaselwa ma-Zulu ebegade asongela ngokuwazungeza.

Amadoda ka-Buller ahlanganiswa nabantu abanengi abangakajayeleki kanye nebutho lamabutho wamabhiza we-Britain, la ngaphasi komyalo ka- Major-General Frederick Marshall . Amaskwadroni amabili we- 17th (The Duke of Cambridge's Own) Lancers, aholwa ngu-Colonel Drury Drury-Lowe, atjhidela endaweni yamaZulu. Bebangakghoni ukuvala nama-Zulu, ebegade asendaweni enotshani obude namahlathi, begodu umlilo we-Zulu wabulala i-adjutant ye-17th Lancers, u-Lieutenant Frederick John Cokayne Frith . U-Drury-Lowe wayala amanye wamadoda wakhe bona ehle begodu abuyisele umlilo. Lokha ama-Zulu nakasongela ukudlula ama-British, u-Marshall wayala bona baphume. Ngaphandle kwaka-Frith, abalimeleko be-Britain bafaka hlangana abalimeleko ababili; ngemva kweenyanga ezimbili ipi, iinsalela zamaZulu ama-25 zatholakala endaweni yepi. Ngemva kokulwa, amaNgisi ajama ukuqinisa ikampa yawo ngaphambi kobana aqhubekele phambili eZululand. Ngemva kwalokho bahlula amaZulu ePini ye-Ulundi yango-4 kuNtaka.

== Isendlalelo ==
UKhomitjhinara oPhakemeko we-Britain weSewula ye-Afrika, u-Sir Henry Bartle Frere, wafuna ukuhlanganisa umBuso we-Zulu ozijameleko njengengcenye yehlelo lokwakha ihlangano yamakoloni aseSewula ye-Afrika . U-Frere wabamba ingxabano yomthetho ngoJulayi 1878 ebandakanya induna yamaZulu u-Sihayo kaXongo . Abafazi ababili benduna bebamtjhiya babalekela ngaphetjheya komngcele baya eKoloni ye-Britain ye-Natal . Amadodana kaSihayo abese arhola isiqhema esihlomileko ekolonini esathatha abafazi bona babulawe. &lt;ref&gt;https://books.google.pt/books?hl=en&amp;lr=&amp;id=npwiCbbEikkC&amp;oi=fnd&amp;pg=PR5&amp;dq=Zungeni+Mountain+skirmish&amp;ots=ao_G0CF-y4&amp;sig=u4tBO8icGhW_8rDN_LILRBE8zVk&amp;redir_esc=y#v=onepage&amp;q=Zungeni%20Mountain%20skirmish&amp;f=false&lt;/ref&gt;NgoNobayeni 1878, u-Frere wahlanganisa amabutho we-Britain emingceleni ye-Zululand begodu wethula u-Cetshwayo isimemezelo sokugcina esifuna ukubuyiselwa kwamadodana ka-Sihayo, amatjhuguluko erherhweni lezokwahlulela lama-Zulu, ukwamukelwa kweenthunywa zevangeli zamaKrestu kanye nokuqedwa kohlelo lwezenhlalakahle/lebutho lama-Zulu elaziwa nge ''-iButho'' . &lt;ref&gt;https://www.tandfonline.com/doi/abs/10.1179/0729247314Z.00000000040&lt;/ref&gt;I-ultimatum beyifuna amatjhuguluko amakhulu endleleni yokuphila yamaZulu, begodu bekuhloswe ngu-Frere bona u-Cetshwayo ayilahle. &lt;ref&gt;https://books.google.pt/books?hl=en&amp;lr=&amp;id=mmp-AwAAQBAJ&amp;oi=fnd&amp;pg=PP11&amp;dq=Zungeni+Mountain+skirmish&amp;ots=0OQsgnrsfn&amp;sig=jzJ4LUACpWgqZCJ68RFNoj6FMkU&amp;redir_esc=y#v=onepage&amp;q&amp;f=false&lt;/ref&gt;


Nanyana bekangakghoni ukulandela imibandela yamaBrithani, khulukhulu ukuqedwa kwama-iButho, u-Cetshwayo wenza imizamo yokubuyisana, wathumela abajameli neenkomo emaBrithani. Kwathi lokha nasele kwaliwe, u-Cetshwayo wenza amalungiselelo wepi yokuzivikela. Wayala amabutho, ebegade azokuhlangana enhlokodolobha yamaZulu e-Ulundi mhlazi-8 kuTjhirhweni emnyanyeni we-umKhosi (Iinthelo zokuthoma), bona eze alungele ukulwa. &lt;ref&gt;https://books.google.pt/books?hl=en&amp;lr=&amp;id=1bE2SW9v7BQC&amp;oi=fnd&amp;pg=IA2&amp;dq=Zungeni+Mountain+skirmish&amp;ots=b9-QSjAPLs&amp;sig=04paqlh8ZHpTffNzt6q2xIEFn9s&amp;redir_esc=y#v=onepage&amp;q&amp;f=false&lt;/ref&gt;Ngaleso sikhathi inani lamadoda ebekufuze asebenze ebuthweni belibalelwa ku-42,000 ukuya ku-44,000, hlangana nenani labantu ebelingaba zi-300,000.[3][16] Abantu abangaba zi-25,000 babuthana e-Ulundi emnyanyeni lo begodu babunjwa baba libutho lekosi. Nanyana bekuneenkhali ezingaba zi-20,000 emaZulu ekuthomeni kwepi, inengi lazo bekuziinkhali ezingasebenziko begodu amadoda bekangakafundiswa ukuzisebenzisa. iklwa ukuhlaba umkhonto.&lt;ref&gt;https://books.google.pt/books?hl=en&amp;lr=&amp;id=vxnwDQAAQBAJ&amp;oi=fnd&amp;pg=PP8&amp;dq=Zungeni+Mountain+skirmish&amp;ots=1L3A7Oq0l5&amp;sig=Lc0qDpMJHt8JGfxb9DSVu2EcBts&amp;redir_esc=y#v=onepage&amp;q&amp;f=false&lt;/ref&gt;
== Iinkomba ==</text>
      <sha1>8c96yur15c83hr7hk3rmd0nenfd6qeq</sha1>
    </revision>
    <revision>
      <id>6279</id>
      <parentid>6278</parentid>
      <timestamp>2026-03-10T04:03:17Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6279</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4663" sha1="3nvd26tnhkmlwj0cymos1m28akoe6ge" xml:space="preserve">
[[Isimumathi:A-Zulu-regiment-attacking-at-iSandlwana.jpg|alt=A black-and-white copy of a watercolour showing a line of Zulus advancing in the foreground, more Zulus are visible in the background.|thumb|Ukuvezwa kwamaZulu ngesikhathi sepi; indoda engakwesokunxele iphethe isibhamu se-Martini-Henry begodu ifake ibhande leenhlamvu le-Britain.|350x350px]]'''Ukulwa kwe-Zungeni Mountain''' kwenzeka mhlazi-5 kuMgwengweni 1879 hlangana namabutho we-Britain nama -Zulu ngesikhathi sokuhlasela kwesibili i- Zululand, endaweni esele iSewula Afrika, eengabeni zokugcina ze- Anglo-Zulu War . Ihhashi elingakajayeleki le-Britain elilawulwa ngu -Colonel Redvers Buller lathola ibutho lama-Zulu ama-300 endaweni yokuhlala ye-eZulaneni hlanu kweNtaba ye-Zungeni. [ nb 1 ] Abakhweli bamahhashi bahlasela begodu bahlakaza amaZulu ngaphambi kokutjhisa indawo yokuhlala. Amadoda ka-Buller arhoxa ngemva kokuhlaselwa ma-Zulu ebegade asongela ngokuwazungeza.

Amadoda ka-Buller ahlanganiswa nabantu abanengi abangakajayeleki kanye nebutho lamabutho wamabhiza we-Britain, la ngaphasi komyalo ka- Major-General Frederick Marshall . Amaskwadroni amabili we- 17th (The Duke of Cambridge's Own) Lancers, aholwa ngu-Colonel Drury Drury-Lowe, atjhidela endaweni yamaZulu. Bebangakghoni ukuvala nama-Zulu, ebegade asendaweni enotshani obude namahlathi, begodu umlilo we-Zulu wabulala i-adjutant ye-17th Lancers, u-Lieutenant Frederick John Cokayne Frith . U-Drury-Lowe wayala amanye wamadoda wakhe bona ehle begodu abuyisele umlilo. Lokha ama-Zulu nakasongela ukudlula ama-British, u-Marshall wayala bona baphume. Ngaphandle kwaka-Frith, abalimeleko be-Britain bafaka hlangana abalimeleko ababili; ngemva kweenyanga ezimbili ipi, iinsalela zamaZulu ama-25 zatholakala endaweni yepi. Ngemva kokulwa, amaNgisi ajama ukuqinisa ikampa yawo ngaphambi kobana aqhubekele phambili eZululand. Ngemva kwalokho bahlula amaZulu ePini ye-Ulundi yango-4 kuNtaka.

== Isendlalelo ==
UKhomitjhinara oPhakemeko we-Britain weSewula ye-Afrika, u-Sir Henry Bartle Frere, wafuna ukuhlanganisa umBuso we-Zulu ozijameleko njengengcenye yehlelo lokwakha ihlangano yamakoloni aseSewula ye-Afrika . U-Frere wabamba ingxabano yomthetho ngoJulayi 1878 ebandakanya induna yamaZulu u-Sihayo kaXongo . Abafazi ababili benduna bebamtjhiya babalekela ngaphetjheya komngcele baya eKoloni ye-Britain ye-Natal . Amadodana kaSihayo abese arhola isiqhema esihlomileko ekolonini esathatha abafazi bona babulawe. &lt;ref&gt;https://books.google.pt/books?hl=en&amp;lr=&amp;id=npwiCbbEikkC&amp;oi=fnd&amp;pg=PR5&amp;dq=Zungeni+Mountain+skirmish&amp;ots=ao_G0CF-y4&amp;sig=u4tBO8icGhW_8rDN_LILRBE8zVk&amp;redir_esc=y#v=onepage&amp;q=Zungeni%20Mountain%20skirmish&amp;f=false&lt;/ref&gt;NgoNobayeni 1878, u-Frere wahlanganisa amabutho we-Britain emingceleni ye-Zululand begodu wethula u-Cetshwayo isimemezelo sokugcina esifuna ukubuyiselwa kwamadodana ka-Sihayo, amatjhuguluko erherhweni lezokwahlulela lama-Zulu, ukwamukelwa kweenthunywa zevangeli zamaKrestu kanye nokuqedwa kohlelo lwezenhlalakahle/lebutho lama-Zulu elaziwa nge ''-iButho'' . &lt;ref&gt;https://www.tandfonline.com/doi/abs/10.1179/0729247314Z.00000000040&lt;/ref&gt;I-ultimatum beyifuna amatjhuguluko amakhulu endleleni yokuphila yamaZulu, begodu bekuhloswe ngu-Frere bona u-Cetshwayo ayilahle. &lt;ref&gt;https://books.google.pt/books?hl=en&amp;lr=&amp;id=mmp-AwAAQBAJ&amp;oi=fnd&amp;pg=PP11&amp;dq=Zungeni+Mountain+skirmish&amp;ots=0OQsgnrsfn&amp;sig=jzJ4LUACpWgqZCJ68RFNoj6FMkU&amp;redir_esc=y#v=onepage&amp;q&amp;f=false&lt;/ref&gt;


Nanyana bekangakghoni ukulandela imibandela yamaBrithani, khulukhulu ukuqedwa kwama-iButho, u-Cetshwayo wenza imizamo yokubuyisana, wathumela abajameli neenkomo emaBrithani. Kwathi lokha nasele kwaliwe, u-Cetshwayo wenza amalungiselelo wepi yokuzivikela. Wayala amabutho, ebegade azokuhlangana enhlokodolobha yamaZulu e-Ulundi mhlazi-8 kuTjhirhweni emnyanyeni we-umKhosi (Iinthelo zokuthoma), bona eze alungele ukulwa. &lt;ref&gt;https://books.google.pt/books?hl=en&amp;lr=&amp;id=1bE2SW9v7BQC&amp;oi=fnd&amp;pg=IA2&amp;dq=Zungeni+Mountain+skirmish&amp;ots=b9-QSjAPLs&amp;sig=04paqlh8ZHpTffNzt6q2xIEFn9s&amp;redir_esc=y#v=onepage&amp;q&amp;f=false&lt;/ref&gt;Ngaleso sikhathi inani lamadoda ebekufuze asebenze ebuthweni belibalelwa ku-42,000 ukuya ku-44,000, hlangana nenani labantu ebelingaba zi-300,000.[3][16] Abantu abangaba zi-25,000 babuthana e-Ulundi emnyanyeni lo begodu babunjwa baba libutho lekosi. Nanyana bekuneenkhali ezingaba zi-20,000 emaZulu ekuthomeni kwepi, inengi lazo bekuziinkhali ezingasebenziko begodu amadoda bekangakafundiswa ukuzisebenzisa. iklwa ukuhlaba umkhonto.&lt;ref&gt;https://books.google.pt/books?hl=en&amp;lr=&amp;id=vxnwDQAAQBAJ&amp;oi=fnd&amp;pg=PP8&amp;dq=Zungeni+Mountain+skirmish&amp;ots=1L3A7Oq0l5&amp;sig=Lc0qDpMJHt8JGfxb9DSVu2EcBts&amp;redir_esc=y#v=onepage&amp;q&amp;f=false&lt;/ref&gt;
== Iinkomba ==</text>
      <sha1>3nvd26tnhkmlwj0cymos1m28akoe6ge</sha1>
    </revision>
    <revision>
      <id>6280</id>
      <parentid>6279</parentid>
      <timestamp>2026-03-10T04:03:34Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6280</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4675" sha1="j0njn90u749jt65fzhs7j3fs1rwhuup" xml:space="preserve">
[[Isimumathi:A-Zulu-regiment-attacking-at-iSandlwana.jpg|alt=A black-and-white copy of a watercolour showing a line of Zulus advancing in the foreground, more Zulus are visible in the background.|thumb|Ukuvezwa kwamaZulu ngesikhathi sepi; indoda engakwesokunxele iphethe isibhamu se-Martini-Henry begodu ifake ibhande leenhlamvu le-Britain.|350x350px]]'''Ukulwa kwe-Zungeni Mountain''' kwenzeka mhlazi-5 kuMgwengweni 1879 hlangana namabutho we-Britain nama -Zulu ngesikhathi sokuhlasela kwesibili i- Zululand, endaweni esele iSewula Afrika, eengabeni zokugcina ze- Anglo-Zulu War . Ihhashi elingakajayeleki le-Britain elilawulwa ngu -Colonel Redvers Buller lathola ibutho lama-Zulu ama-300 endaweni yokuhlala ye-eZulaneni hlanu kweNtaba ye-Zungeni. [ nb 1 ] Abakhweli bamahhashi bahlasela begodu bahlakaza amaZulu ngaphambi kokutjhisa indawo yokuhlala. Amadoda ka-Buller arhoxa ngemva kokuhlaselwa ma-Zulu ebegade asongela ngokuwazungeza.

Amadoda ka-Buller ahlanganiswa nabantu abanengi abangakajayeleki kanye nebutho lamabutho wamabhiza we-Britain, la ngaphasi komyalo ka- Major-General Frederick Marshall . Amaskwadroni amabili we- 17th (The Duke of Cambridge's Own) Lancers, aholwa ngu-Colonel Drury Drury-Lowe, atjhidela endaweni yamaZulu. Bebangakghoni ukuvala nama-Zulu, ebegade asendaweni enotshani obude namahlathi, begodu umlilo we-Zulu wabulala i-adjutant ye-17th Lancers, u-Lieutenant Frederick John Cokayne Frith . U-Drury-Lowe wayala amanye wamadoda wakhe bona ehle begodu abuyisele umlilo. Lokha ama-Zulu nakasongela ukudlula ama-British, u-Marshall wayala bona baphume. Ngaphandle kwaka-Frith, abalimeleko be-Britain bafaka hlangana abalimeleko ababili; ngemva kweenyanga ezimbili ipi, iinsalela zamaZulu ama-25 zatholakala endaweni yepi. Ngemva kokulwa, amaNgisi ajama ukuqinisa ikampa yawo ngaphambi kobana aqhubekele phambili eZululand. Ngemva kwalokho bahlula amaZulu ePini ye-Ulundi yango-4 kuNtaka.

== Isendlalelo ==
UKhomitjhinara oPhakemeko we-Britain weSewula ye-Afrika, u-Sir Henry Bartle Frere, wafuna ukuhlanganisa umBuso we-Zulu ozijameleko njengengcenye yehlelo lokwakha ihlangano yamakoloni aseSewula ye-Afrika . U-Frere wabamba ingxabano yomthetho ngoJulayi 1878 ebandakanya induna yamaZulu u-Sihayo kaXongo . Abafazi ababili benduna bebamtjhiya babalekela ngaphetjheya komngcele baya eKoloni ye-Britain ye-Natal . Amadodana kaSihayo abese arhola isiqhema esihlomileko ekolonini esathatha abafazi bona babulawe. &lt;ref&gt;https://books.google.pt/books?hl=en&amp;lr=&amp;id=npwiCbbEikkC&amp;oi=fnd&amp;pg=PR5&amp;dq=Zungeni+Mountain+skirmish&amp;ots=ao_G0CF-y4&amp;sig=u4tBO8icGhW_8rDN_LILRBE8zVk&amp;redir_esc=y#v=onepage&amp;q=Zungeni%20Mountain%20skirmish&amp;f=false&lt;/ref&gt;NgoNobayeni 1878, u-Frere wahlanganisa amabutho we-Britain emingceleni ye-Zululand begodu wethula u-Cetshwayo isimemezelo sokugcina esifuna ukubuyiselwa kwamadodana ka-Sihayo, amatjhuguluko erherhweni lezokwahlulela lama-Zulu, ukwamukelwa kweenthunywa zevangeli zamaKrestu kanye nokuqedwa kohlelo lwezenhlalakahle/lebutho lama-Zulu elaziwa nge ''-iButho'' . &lt;ref&gt;https://www.tandfonline.com/doi/abs/10.1179/0729247314Z.00000000040&lt;/ref&gt;I-ultimatum beyifuna amatjhuguluko amakhulu endleleni yokuphila yamaZulu, begodu bekuhloswe ngu-Frere bona u-Cetshwayo ayilahle. &lt;ref&gt;https://books.google.pt/books?hl=en&amp;lr=&amp;id=mmp-AwAAQBAJ&amp;oi=fnd&amp;pg=PP11&amp;dq=Zungeni+Mountain+skirmish&amp;ots=0OQsgnrsfn&amp;sig=jzJ4LUACpWgqZCJ68RFNoj6FMkU&amp;redir_esc=y#v=onepage&amp;q&amp;f=false&lt;/ref&gt;


Nanyana bekangakghoni ukulandela imibandela yamaBrithani, khulukhulu ukuqedwa kwama-iButho, u-Cetshwayo wenza imizamo yokubuyisana, wathumela abajameli neenkomo emaBrithani. Kwathi lokha nasele kwaliwe, u-Cetshwayo wenza amalungiselelo wepi yokuzivikela. Wayala amabutho, ebegade azokuhlangana enhlokodolobha yamaZulu e-Ulundi mhlazi-8 kuTjhirhweni emnyanyeni we-umKhosi (Iinthelo zokuthoma), bona eze alungele ukulwa. &lt;ref&gt;https://books.google.pt/books?hl=en&amp;lr=&amp;id=1bE2SW9v7BQC&amp;oi=fnd&amp;pg=IA2&amp;dq=Zungeni+Mountain+skirmish&amp;ots=b9-QSjAPLs&amp;sig=04paqlh8ZHpTffNzt6q2xIEFn9s&amp;redir_esc=y#v=onepage&amp;q&amp;f=false&lt;/ref&gt;Ngaleso sikhathi inani lamadoda ebekufuze asebenze ebuthweni belibalelwa ku-42,000 ukuya ku-44,000, hlangana nenani labantu ebelingaba zi-300,000.[3][16] Abantu abangaba zi-25,000 babuthana e-Ulundi emnyanyeni lo begodu babunjwa baba libutho lekosi. Nanyana bekuneenkhali ezingaba zi-20,000 emaZulu ekuthomeni kwepi, inengi lazo bekuziinkhali ezingasebenziko begodu amadoda bekangakafundiswa ukuzisebenzisa. iklwa ukuhlaba umkhonto.&lt;ref&gt;https://books.google.pt/books?hl=en&amp;lr=&amp;id=vxnwDQAAQBAJ&amp;oi=fnd&amp;pg=PP8&amp;dq=Zungeni+Mountain+skirmish&amp;ots=1L3A7Oq0l5&amp;sig=Lc0qDpMJHt8JGfxb9DSVu2EcBts&amp;redir_esc=y#v=onepage&amp;q&amp;f=false&lt;/ref&gt;
== Iinkomba ==
{{reflist}}</text>
      <sha1>j0njn90u749jt65fzhs7j3fs1rwhuup</sha1>
    </revision>
    <revision>
      <id>6281</id>
      <parentid>6280</parentid>
      <timestamp>2026-03-10T04:04:29Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6281</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4723" sha1="elailt5dv7rclbihlghbi8jj26rp58h" xml:space="preserve">
[[Isimumathi:A-Zulu-regiment-attacking-at-iSandlwana.jpg|alt=A black-and-white copy of a watercolour showing a line of Zulus advancing in the foreground, more Zulus are visible in the background.|thumb|Ukuvezwa kwamaZulu ngesikhathi sepi; indoda engakwesokunxele iphethe isibhamu se-Martini-Henry begodu ifake ibhande leenhlamvu le-Britain.|350x350px]]'''Ukulwa kwe-Zungeni Mountain''' kwenzeka mhlazi-5 kuMgwengweni 1879 hlangana namabutho we-Britain nama -Zulu ngesikhathi sokuhlasela kwesibili i- Zululand, endaweni esele iSewula Afrika, eengabeni zokugcina ze- Anglo-Zulu War . Ihhashi elingakajayeleki le-Britain elilawulwa ngu -Colonel Redvers Buller lathola ibutho lama-Zulu ama-300 endaweni yokuhlala ye-eZulaneni hlanu kweNtaba ye-Zungeni. [ nb 1 ] Abakhweli bamahhashi bahlasela begodu bahlakaza amaZulu ngaphambi kokutjhisa indawo yokuhlala. Amadoda ka-Buller arhoxa ngemva kokuhlaselwa ma-Zulu ebegade asongela ngokuwazungeza.

Amadoda ka-Buller ahlanganiswa nabantu abanengi abangakajayeleki kanye nebutho lamabutho wamabhiza we-Britain, la ngaphasi komyalo ka- Major-General Frederick Marshall . Amaskwadroni amabili we- 17th (The Duke of Cambridge's Own) Lancers, aholwa ngu-Colonel Drury Drury-Lowe, atjhidela endaweni yamaZulu. Bebangakghoni ukuvala nama-Zulu, ebegade asendaweni enotshani obude namahlathi, begodu umlilo we-Zulu wabulala i-adjutant ye-17th Lancers, u-Lieutenant Frederick John Cokayne Frith . U-Drury-Lowe wayala amanye wamadoda wakhe bona ehle begodu abuyisele umlilo. Lokha ama-Zulu nakasongela ukudlula ama-British, u-Marshall wayala bona baphume. Ngaphandle kwaka-Frith, abalimeleko be-Britain bafaka hlangana abalimeleko ababili; ngemva kweenyanga ezimbili ipi, iinsalela zamaZulu ama-25 zatholakala endaweni yepi. Ngemva kokulwa, amaNgisi ajama ukuqinisa ikampa yawo ngaphambi kobana aqhubekele phambili eZululand. Ngemva kwalokho bahlula amaZulu ePini ye-Ulundi yango-4 kuNtaka.

== Isendlalelo ==
UKhomitjhinara oPhakemeko we-Britain weSewula ye-Afrika, u-Sir Henry Bartle Frere, wafuna ukuhlanganisa umBuso we-Zulu ozijameleko njengengcenye yehlelo lokwakha ihlangano yamakoloni aseSewula ye-Afrika . U-Frere wabamba ingxabano yomthetho ngoJulayi 1878 ebandakanya induna yamaZulu u-Sihayo kaXongo . Abafazi ababili benduna bebamtjhiya babalekela ngaphetjheya komngcele baya eKoloni ye-Britain ye-Natal . Amadodana kaSihayo abese arhola isiqhema esihlomileko ekolonini esathatha abafazi bona babulawe. &lt;ref&gt;https://books.google.pt/books?hl=en&amp;lr=&amp;id=npwiCbbEikkC&amp;oi=fnd&amp;pg=PR5&amp;dq=Zungeni+Mountain+skirmish&amp;ots=ao_G0CF-y4&amp;sig=u4tBO8icGhW_8rDN_LILRBE8zVk&amp;redir_esc=y#v=onepage&amp;q=Zungeni%20Mountain%20skirmish&amp;f=false&lt;/ref&gt;NgoNobayeni 1878, u-Frere wahlanganisa amabutho we-Britain emingceleni ye-Zululand begodu wethula u-Cetshwayo isimemezelo sokugcina esifuna ukubuyiselwa kwamadodana ka-Sihayo, amatjhuguluko erherhweni lezokwahlulela lama-Zulu, ukwamukelwa kweenthunywa zevangeli zamaKrestu kanye nokuqedwa kohlelo lwezenhlalakahle/lebutho lama-Zulu elaziwa nge ''-iButho'' . &lt;ref&gt;https://www.tandfonline.com/doi/abs/10.1179/0729247314Z.00000000040&lt;/ref&gt;I-ultimatum beyifuna amatjhuguluko amakhulu endleleni yokuphila yamaZulu, begodu bekuhloswe ngu-Frere bona u-Cetshwayo ayilahle. &lt;ref&gt;https://books.google.pt/books?hl=en&amp;lr=&amp;id=mmp-AwAAQBAJ&amp;oi=fnd&amp;pg=PP11&amp;dq=Zungeni+Mountain+skirmish&amp;ots=0OQsgnrsfn&amp;sig=jzJ4LUACpWgqZCJ68RFNoj6FMkU&amp;redir_esc=y#v=onepage&amp;q&amp;f=false&lt;/ref&gt;


Nanyana bekangakghoni ukulandela imibandela yamaBrithani, khulukhulu ukuqedwa kwama-iButho, u-Cetshwayo wenza imizamo yokubuyisana, wathumela abajameli neenkomo emaBrithani. Kwathi lokha nasele kwaliwe, u-Cetshwayo wenza amalungiselelo wepi yokuzivikela. Wayala amabutho, ebegade azokuhlangana enhlokodolobha yamaZulu e-Ulundi mhlazi-8 kuTjhirhweni emnyanyeni we-umKhosi (Iinthelo zokuthoma), bona eze alungele ukulwa. &lt;ref&gt;https://books.google.pt/books?hl=en&amp;lr=&amp;id=1bE2SW9v7BQC&amp;oi=fnd&amp;pg=IA2&amp;dq=Zungeni+Mountain+skirmish&amp;ots=b9-QSjAPLs&amp;sig=04paqlh8ZHpTffNzt6q2xIEFn9s&amp;redir_esc=y#v=onepage&amp;q&amp;f=false&lt;/ref&gt;Ngaleso sikhathi inani lamadoda ebekufuze asebenze ebuthweni belibalelwa ku-42,000 ukuya ku-44,000, hlangana nenani labantu ebelingaba zi-300,000.[3][16] Abantu abangaba zi-25,000 babuthana e-Ulundi emnyanyeni lo begodu babunjwa baba libutho lekosi. Nanyana bekuneenkhali ezingaba zi-20,000 emaZulu ekuthomeni kwepi, inengi lazo bekuziinkhali ezingasebenziko begodu amadoda bekangakafundiswa ukuzisebenzisa. iklwa ukuhlaba umkhonto.&lt;ref&gt;https://books.google.pt/books?hl=en&amp;lr=&amp;id=vxnwDQAAQBAJ&amp;oi=fnd&amp;pg=PP8&amp;dq=Zungeni+Mountain+skirmish&amp;ots=1L3A7Oq0l5&amp;sig=Lc0qDpMJHt8JGfxb9DSVu2EcBts&amp;redir_esc=y#v=onepage&amp;q&amp;f=false&lt;/ref&gt;
== Iinkomba ==
{{reflist}}
[[Category:umlando]]
[[Category:Sewula Afrika]]</text>
      <sha1>elailt5dv7rclbihlghbi8jj26rp58h</sha1>
    </revision>
  </page>
  <page>
    <title>Nduduzo Makhathini</title>
    <ns>0</ns>
    <id>1061</id>
    <revision>
      <id>6282</id>
      <timestamp>2026-03-11T10:23:11Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1319143638|Nduduzo Makhathini]]&quot;</comment>
      <origin>6282</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3232" sha1="gclyct35h2dl5jorrqaup63wktqrd9r" xml:space="preserve">
[[Isimumathi:Nduduzo_Makhathini_Quartet_28_october_2021_BIM_Amsterdam_-_Nduduzo_Makhathini_(51638611012).jpg|thumb|250x250px|uNduduzo udlala ipiyano]]
'''U-Nduduzo Makhathini''' (wabelethwa mhlazi-24 kuNobayeni 1982) mculi we-jazz [[Isewula Afrika|weSewula Afrika]] ovela e -Umgungundlovu, e-Pietermaritzburg, [[Isewula Afrika|e-Sewula Afrika]] .

Njengombana avela emndenini womculo, ithando lakhe lomculo lathoma asesemncani.  U-Makhathini udlale no -Zim Ngqawana, u-Simphiwe Dana, u-Feya Faku, no -McCoy Mrubata . U-Nduduzo waqeda i-Diploma yakhe ku-Jazz Piano e- Durban University of Technology ngo-2005,   begodu wathola i-PhD emculweni e- University of Stellenbosch ngo-2023.  

U-Makhathini waqeda i-PhD yakhe e-Africa Open Institute for Music, Research and Innovation e-Stellenbosch University ngo-2023 nge-dissertation enesihloko esithi Breaking into Sound: Dis/Locating Ntu Cosmology and Improvisation in South African Jazz.

== Igalelo ku-Jazz Scholarship kanye ne-African Epistemologies ==
U-Makhathini waqeda i-PhD yakhe e- Africa Open Institute for Music, Research and Innovation e- Stellenbosch University ngo-2023 nge-dissertation enesihloko esithi ''Breaking into Sound: Dis/Locating Ntu Cosmology and Improvisation in South African Jazz'' .  Irhubhululo lakhe, irhubhululo elidoselwa buciko, liphikisa iimfundo ezijayelekileko ze-jazz ngokubeka phambili ubujamo be-jazz yeSewula Afrika, khulukhulu ngomqondo we ''-ntu'' cosmology. U-Makhathini uthi ukuzilungiselela kwe-jazz eSewula Afrika kungazwisiswa njengokuzibandakanya kwemikhuba nomsindo ohlanganisa indawo ebonakalako nebonakalako. 


Makhathini is the recipient of the 2015 '''[[:en:Standard_Bank_Young_Artist_Award|Standard Bank Young Artist Award]]''' in the category of Jazz.&lt;ref&gt;{{cite web|url=http://mg.co.za/article/2014-10-30-ndudozo-makhathini-in-sync-with-a-higher-power|title=Nduduzo Makhathini finds the gift of healing in song|author=Setumo-Thebe Mohlomi|work=The M&amp;G Online|date=30 October 2014}}&lt;/ref&gt; This is part of the [[:en:National_Arts_Festival|National Arts Festival]].&lt;ref&gt;{{Cite web|url=https://www.nationalartsfestival.co.za/about/young-artists/young-artists-award-history/|title=National Arts Festival|access-date=2018-10-31|archive-url=https://web.archive.org/web/20141029040308/https://www.nationalartsfestival.co.za/about/young-artists/young-artists-award-history/|archive-date=2014-10-29|url-status=dead}}&lt;/ref&gt; At the 2017 [[:en:All_Africa_Music_Awards|All Africa Music Awards]], Makhathini won the Best Jazz Artist award.&lt;ref&gt;{{cite web|url=https://www.bbc.co.uk/programmes/p06c8x8g|title=The rising star of South African jazz|publisher=[[BBC]]|date=28 June 2018|access-date=31 October 2018}}&lt;/ref&gt; His musical output has led him to be described by Seton Hawkins of ''All About Jazz'' to be &quot;a truly singular pianist, an astonishingly gifted composer, and a deeply nuanced thinker on the music...one of the [South Africa]'s most remarkable talents.&quot;&lt;ref&gt;{{Cite web|url=https://www.allaboutjazz.com/nduduzo-makhathini-jazz-is-a-shared-memory-nduduzo-makhathini-by-seton-hawkins|title=Nduduzo Makhathini: Jazz Is a Shared Memory|date=1 February 2018|website=[[All About Jazz]]|access-date=27 June 2022}}&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>gclyct35h2dl5jorrqaup63wktqrd9r</sha1>
    </revision>
    <revision>
      <id>6283</id>
      <parentid>6282</parentid>
      <timestamp>2026-03-11T10:24:03Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6283</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3232" sha1="alxj7jxqq8h7rffy4yo0f5k9t2wjflc" xml:space="preserve">
[[Isimumathi:Nduduzo_Makhathini_Quartet_28_october_2021_BIM_Amsterdam_-_Nduduzo_Makhathini_(51638611012).jpg|thumb|370x370px|uNduduzo udlala ipiyano]]
'''U-Nduduzo Makhathini''' (wabelethwa mhlazi-24 kuNobayeni 1982) mculi we-jazz [[Isewula Afrika|weSewula Afrika]] ovela e -Umgungundlovu, e-Pietermaritzburg, [[Isewula Afrika|e-Sewula Afrika]] .

Njengombana avela emndenini womculo, ithando lakhe lomculo lathoma asesemncani.  U-Makhathini udlale no -Zim Ngqawana, u-Simphiwe Dana, u-Feya Faku, no -McCoy Mrubata . U-Nduduzo waqeda i-Diploma yakhe ku-Jazz Piano e- Durban University of Technology ngo-2005,   begodu wathola i-PhD emculweni e- University of Stellenbosch ngo-2023.  

U-Makhathini waqeda i-PhD yakhe e-Africa Open Institute for Music, Research and Innovation e-Stellenbosch University ngo-2023 nge-dissertation enesihloko esithi Breaking into Sound: Dis/Locating Ntu Cosmology and Improvisation in South African Jazz.

== Igalelo ku-Jazz Scholarship kanye ne-African Epistemologies ==
U-Makhathini waqeda i-PhD yakhe e- Africa Open Institute for Music, Research and Innovation e- Stellenbosch University ngo-2023 nge-dissertation enesihloko esithi ''Breaking into Sound: Dis/Locating Ntu Cosmology and Improvisation in South African Jazz'' .  Irhubhululo lakhe, irhubhululo elidoselwa buciko, liphikisa iimfundo ezijayelekileko ze-jazz ngokubeka phambili ubujamo be-jazz yeSewula Afrika, khulukhulu ngomqondo we ''-ntu'' cosmology. U-Makhathini uthi ukuzilungiselela kwe-jazz eSewula Afrika kungazwisiswa njengokuzibandakanya kwemikhuba nomsindo ohlanganisa indawo ebonakalako nebonakalako. 


Makhathini is the recipient of the 2015 '''[[:en:Standard_Bank_Young_Artist_Award|Standard Bank Young Artist Award]]''' in the category of Jazz.&lt;ref&gt;{{cite web|url=http://mg.co.za/article/2014-10-30-ndudozo-makhathini-in-sync-with-a-higher-power|title=Nduduzo Makhathini finds the gift of healing in song|author=Setumo-Thebe Mohlomi|work=The M&amp;G Online|date=30 October 2014}}&lt;/ref&gt; This is part of the [[:en:National_Arts_Festival|National Arts Festival]].&lt;ref&gt;{{Cite web|url=https://www.nationalartsfestival.co.za/about/young-artists/young-artists-award-history/|title=National Arts Festival|access-date=2018-10-31|archive-url=https://web.archive.org/web/20141029040308/https://www.nationalartsfestival.co.za/about/young-artists/young-artists-award-history/|archive-date=2014-10-29|url-status=dead}}&lt;/ref&gt; At the 2017 [[:en:All_Africa_Music_Awards|All Africa Music Awards]], Makhathini won the Best Jazz Artist award.&lt;ref&gt;{{cite web|url=https://www.bbc.co.uk/programmes/p06c8x8g|title=The rising star of South African jazz|publisher=[[BBC]]|date=28 June 2018|access-date=31 October 2018}}&lt;/ref&gt; His musical output has led him to be described by Seton Hawkins of ''All About Jazz'' to be &quot;a truly singular pianist, an astonishingly gifted composer, and a deeply nuanced thinker on the music...one of the [South Africa]'s most remarkable talents.&quot;&lt;ref&gt;{{Cite web|url=https://www.allaboutjazz.com/nduduzo-makhathini-jazz-is-a-shared-memory-nduduzo-makhathini-by-seton-hawkins|title=Nduduzo Makhathini: Jazz Is a Shared Memory|date=1 February 2018|website=[[All About Jazz]]|access-date=27 June 2022}}&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>alxj7jxqq8h7rffy4yo0f5k9t2wjflc</sha1>
    </revision>
    <revision>
      <id>6284</id>
      <parentid>6283</parentid>
      <timestamp>2026-03-11T10:24:51Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6284</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3244" sha1="2e607uqy0glthw4sd2ehrq0nncaxtsj" xml:space="preserve">
[[Isimumathi:Nduduzo_Makhathini_Quartet_28_october_2021_BIM_Amsterdam_-_Nduduzo_Makhathini_(51638611012).jpg|thumb|370x370px|uNduduzo udlala ipiyano]]
'''U-Nduduzo Makhathini''' (wabelethwa mhlazi-24 kuNobayeni 1982) mculi we-jazz [[Isewula Afrika|weSewula Afrika]] ovela e -Umgungundlovu, e-Pietermaritzburg, [[Isewula Afrika|e-Sewula Afrika]] .

Njengombana avela emndenini womculo, ithando lakhe lomculo lathoma asesemncani.  U-Makhathini udlale no -Zim Ngqawana, u-Simphiwe Dana, u-Feya Faku, no -McCoy Mrubata . U-Nduduzo waqeda i-Diploma yakhe ku-Jazz Piano e- Durban University of Technology ngo-2005,   begodu wathola i-PhD emculweni e- University of Stellenbosch ngo-2023.  

U-Makhathini waqeda i-PhD yakhe e-Africa Open Institute for Music, Research and Innovation e-Stellenbosch University ngo-2023 nge-dissertation enesihloko esithi Breaking into Sound: Dis/Locating Ntu Cosmology and Improvisation in South African Jazz.

== Igalelo ku-Jazz Scholarship kanye ne-African Epistemologies ==
U-Makhathini waqeda i-PhD yakhe e- Africa Open Institute for Music, Research and Innovation e- Stellenbosch University ngo-2023 nge-dissertation enesihloko esithi ''Breaking into Sound: Dis/Locating Ntu Cosmology and Improvisation in South African Jazz'' .  Irhubhululo lakhe, irhubhululo elidoselwa buciko, liphikisa iimfundo ezijayelekileko ze-jazz ngokubeka phambili ubujamo be-jazz yeSewula Afrika, khulukhulu ngomqondo we ''-ntu'' cosmology. U-Makhathini uthi ukuzilungiselela kwe-jazz eSewula Afrika kungazwisiswa njengokuzibandakanya kwemikhuba nomsindo ohlanganisa indawo ebonakalako nebonakalako. 


Makhathini is the recipient of the 2015 '''[[:en:Standard_Bank_Young_Artist_Award|Standard Bank Young Artist Award]]''' in the category of Jazz.&lt;ref&gt;{{cite web|url=http://mg.co.za/article/2014-10-30-ndudozo-makhathini-in-sync-with-a-higher-power|title=Nduduzo Makhathini finds the gift of healing in song|author=Setumo-Thebe Mohlomi|work=The M&amp;G Online|date=30 October 2014}}&lt;/ref&gt; This is part of the [[:en:National_Arts_Festival|National Arts Festival]].&lt;ref&gt;{{Cite web|url=https://www.nationalartsfestival.co.za/about/young-artists/young-artists-award-history/|title=National Arts Festival|access-date=2018-10-31|archive-url=https://web.archive.org/web/20141029040308/https://www.nationalartsfestival.co.za/about/young-artists/young-artists-award-history/|archive-date=2014-10-29|url-status=dead}}&lt;/ref&gt; At the 2017 [[:en:All_Africa_Music_Awards|All Africa Music Awards]], Makhathini won the Best Jazz Artist award.&lt;ref&gt;{{cite web|url=https://www.bbc.co.uk/programmes/p06c8x8g|title=The rising star of South African jazz|publisher=[[BBC]]|date=28 June 2018|access-date=31 October 2018}}&lt;/ref&gt; His musical output has led him to be described by Seton Hawkins of ''All About Jazz'' to be &quot;a truly singular pianist, an astonishingly gifted composer, and a deeply nuanced thinker on the music...one of the [South Africa]'s most remarkable talents.&quot;&lt;ref&gt;{{Cite web|url=https://www.allaboutjazz.com/nduduzo-makhathini-jazz-is-a-shared-memory-nduduzo-makhathini-by-seton-hawkins|title=Nduduzo Makhathini: Jazz Is a Shared Memory|date=1 February 2018|website=[[All About Jazz]]|access-date=27 June 2022}}&lt;/ref&gt;

== Iinkomba ==
{{reflist}}</text>
      <sha1>2e607uqy0glthw4sd2ehrq0nncaxtsj</sha1>
    </revision>
    <revision>
      <id>6285</id>
      <parentid>6284</parentid>
      <timestamp>2026-03-11T10:26:29Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6285</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3274" sha1="j6hbfe4397qqyxukjndh8l7ciwd1ld4" xml:space="preserve">
[[Isimumathi:Nduduzo_Makhathini_Quartet_28_october_2021_BIM_Amsterdam_-_Nduduzo_Makhathini_(51638611012).jpg|thumb|370x370px|uNduduzo udlala ipiyano]]
'''U-Nduduzo Makhathini''' (wabelethwa mhlazi-24 kuNobayeni 1982) mculi we-jazz [[Isewula Afrika|weSewula Afrika]] ovela e -Umgungundlovu, e-Pietermaritzburg, [[Isewula Afrika|e-Sewula Afrika]] .

Njengombana avela emndenini womculo, ithando lakhe lomculo lathoma asesemncani.  U-Makhathini udlale no -Zim Ngqawana, u-Simphiwe Dana, u-Feya Faku, no -McCoy Mrubata . U-Nduduzo waqeda i-Diploma yakhe ku-Jazz Piano e- Durban University of Technology ngo-2005,   begodu wathola i-PhD emculweni e- University of Stellenbosch ngo-2023.  

U-Makhathini waqeda i-PhD yakhe e-Africa Open Institute for Music, Research and Innovation e-Stellenbosch University ngo-2023 nge-dissertation enesihloko esithi Breaking into Sound: Dis/Locating Ntu Cosmology and Improvisation in South African Jazz.

== Igalelo ku-Jazz Scholarship kanye ne-African Epistemologies ==
U-Makhathini waqeda i-PhD yakhe e- Africa Open Institute for Music, Research and Innovation e- Stellenbosch University ngo-2023 nge-dissertation enesihloko esithi ''Breaking into Sound: Dis/Locating Ntu Cosmology and Improvisation in South African Jazz'' .  Irhubhululo lakhe, irhubhululo elidoselwa buciko, liphikisa iimfundo ezijayelekileko ze-jazz ngokubeka phambili ubujamo be-jazz yeSewula Afrika, khulukhulu ngomqondo we ''-ntu'' cosmology. U-Makhathini uthi ukuzilungiselela kwe-jazz eSewula Afrika kungazwisiswa njengokuzibandakanya kwemikhuba nomsindo ohlanganisa indawo ebonakalako nebonakalako. 


Makhathini is the recipient of the 2015 '''[[:en:Standard_Bank_Young_Artist_Award|Standard Bank Young Artist Award]]''' in the category of Jazz.&lt;ref&gt;{{cite web|url=http://mg.co.za/article/2014-10-30-ndudozo-makhathini-in-sync-with-a-higher-power|title=Nduduzo Makhathini finds the gift of healing in song|author=Setumo-Thebe Mohlomi|work=The M&amp;G Online|date=30 October 2014}}&lt;/ref&gt; This is part of the [[:en:National_Arts_Festival|National Arts Festival]].&lt;ref&gt;{{Cite web|url=https://www.nationalartsfestival.co.za/about/young-artists/young-artists-award-history/|title=National Arts Festival|access-date=2018-10-31|archive-url=https://web.archive.org/web/20141029040308/https://www.nationalartsfestival.co.za/about/young-artists/young-artists-award-history/|archive-date=2014-10-29|url-status=dead}}&lt;/ref&gt; At the 2017 [[:en:All_Africa_Music_Awards|All Africa Music Awards]], Makhathini won the Best Jazz Artist award.&lt;ref&gt;{{cite web|url=https://www.bbc.co.uk/programmes/p06c8x8g|title=The rising star of South African jazz|publisher=[[BBC]]|date=28 June 2018|access-date=31 October 2018}}&lt;/ref&gt; His musical output has led him to be described by Seton Hawkins of ''All About Jazz'' to be &quot;a truly singular pianist, an astonishingly gifted composer, and a deeply nuanced thinker on the music...one of the [South Africa]'s most remarkable talents.&quot;&lt;ref&gt;{{Cite web|url=https://www.allaboutjazz.com/nduduzo-makhathini-jazz-is-a-shared-memory-nduduzo-makhathini-by-seton-hawkins|title=Nduduzo Makhathini: Jazz Is a Shared Memory|date=1 February 2018|website=[[All About Jazz]]|access-date=27 June 2022}}&lt;/ref&gt;

== Iinkomba ==
{{reflist}}
[[Category:Ningizimu Afrika]]</text>
      <sha1>j6hbfe4397qqyxukjndh8l7ciwd1ld4</sha1>
    </revision>
    <revision>
      <id>6286</id>
      <parentid>6285</parentid>
      <timestamp>2026-03-11T10:26:46Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6286</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3271" sha1="bffva64ym84ecjs42jueidmi7aq8yv8" xml:space="preserve">
[[Isimumathi:Nduduzo_Makhathini_Quartet_28_october_2021_BIM_Amsterdam_-_Nduduzo_Makhathini_(51638611012).jpg|thumb|370x370px|uNduduzo udlala ipiyano]]
'''U-Nduduzo Makhathini''' (wabelethwa mhlazi-24 kuNobayeni 1982) mculi we-jazz [[Isewula Afrika|weSewula Afrika]] ovela e -Umgungundlovu, e-Pietermaritzburg, [[Isewula Afrika|e-Sewula Afrika]] .

Njengombana avela emndenini womculo, ithando lakhe lomculo lathoma asesemncani.  U-Makhathini udlale no -Zim Ngqawana, u-Simphiwe Dana, u-Feya Faku, no -McCoy Mrubata . U-Nduduzo waqeda i-Diploma yakhe ku-Jazz Piano e- Durban University of Technology ngo-2005,   begodu wathola i-PhD emculweni e- University of Stellenbosch ngo-2023.  

U-Makhathini waqeda i-PhD yakhe e-Africa Open Institute for Music, Research and Innovation e-Stellenbosch University ngo-2023 nge-dissertation enesihloko esithi Breaking into Sound: Dis/Locating Ntu Cosmology and Improvisation in South African Jazz.

== Igalelo ku-Jazz Scholarship kanye ne-African Epistemologies ==
U-Makhathini waqeda i-PhD yakhe e- Africa Open Institute for Music, Research and Innovation e- Stellenbosch University ngo-2023 nge-dissertation enesihloko esithi ''Breaking into Sound: Dis/Locating Ntu Cosmology and Improvisation in South African Jazz'' .  Irhubhululo lakhe, irhubhululo elidoselwa buciko, liphikisa iimfundo ezijayelekileko ze-jazz ngokubeka phambili ubujamo be-jazz yeSewula Afrika, khulukhulu ngomqondo we ''-ntu'' cosmology. U-Makhathini uthi ukuzilungiselela kwe-jazz eSewula Afrika kungazwisiswa njengokuzibandakanya kwemikhuba nomsindo ohlanganisa indawo ebonakalako nebonakalako. 


Makhathini is the recipient of the 2015 '''[[:en:Standard_Bank_Young_Artist_Award|Standard Bank Young Artist Award]]''' in the category of Jazz.&lt;ref&gt;{{cite web|url=http://mg.co.za/article/2014-10-30-ndudozo-makhathini-in-sync-with-a-higher-power|title=Nduduzo Makhathini finds the gift of healing in song|author=Setumo-Thebe Mohlomi|work=The M&amp;G Online|date=30 October 2014}}&lt;/ref&gt; This is part of the [[:en:National_Arts_Festival|National Arts Festival]].&lt;ref&gt;{{Cite web|url=https://www.nationalartsfestival.co.za/about/young-artists/young-artists-award-history/|title=National Arts Festival|access-date=2018-10-31|archive-url=https://web.archive.org/web/20141029040308/https://www.nationalartsfestival.co.za/about/young-artists/young-artists-award-history/|archive-date=2014-10-29|url-status=dead}}&lt;/ref&gt; At the 2017 [[:en:All_Africa_Music_Awards|All Africa Music Awards]], Makhathini won the Best Jazz Artist award.&lt;ref&gt;{{cite web|url=https://www.bbc.co.uk/programmes/p06c8x8g|title=The rising star of South African jazz|publisher=[[BBC]]|date=28 June 2018|access-date=31 October 2018}}&lt;/ref&gt; His musical output has led him to be described by Seton Hawkins of ''All About Jazz'' to be &quot;a truly singular pianist, an astonishingly gifted composer, and a deeply nuanced thinker on the music...one of the [South Africa]'s most remarkable talents.&quot;&lt;ref&gt;{{Cite web|url=https://www.allaboutjazz.com/nduduzo-makhathini-jazz-is-a-shared-memory-nduduzo-makhathini-by-seton-hawkins|title=Nduduzo Makhathini: Jazz Is a Shared Memory|date=1 February 2018|website=[[All About Jazz]]|access-date=27 June 2022}}&lt;/ref&gt;

== Iinkomba ==
{{reflist}}
[[Category:Sewula Afrika]]</text>
      <sha1>bffva64ym84ecjs42jueidmi7aq8yv8</sha1>
    </revision>
    <revision>
      <id>6287</id>
      <parentid>6286</parentid>
      <timestamp>2026-03-11T10:28:15Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6287</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3305" sha1="kyxd8wihq2mttvnz2h80jrlyil1bo3d" xml:space="preserve">
[[Isimumathi:Nduduzo_Makhathini_Quartet_28_october_2021_BIM_Amsterdam_-_Nduduzo_Makhathini_(51638611012).jpg|thumb|370x370px|uNduduzo udlala ipiyano]]
'''U-Nduduzo Makhathini''' (wabelethwa mhlazi-24 kuNobayeni 1982) mculi we-jazz [[Isewula Afrika|weSewula Afrika]] ovela e -Umgungundlovu, e-Pietermaritzburg, [[Isewula Afrika|e-Sewula Afrika]] .

Njengombana avela emndenini womculo, ithando lakhe lomculo lathoma asesemncani.  U-Makhathini udlale no -Zim Ngqawana, u-Simphiwe Dana, u-Feya Faku, no -McCoy Mrubata . U-Nduduzo waqeda i-Diploma yakhe ku-Jazz Piano e- Durban University of Technology ngo-2005,   begodu wathola i-PhD emculweni e- University of Stellenbosch ngo-2023.  

U-Makhathini waqeda i-PhD yakhe e-Africa Open Institute for Music, Research and Innovation e-Stellenbosch University ngo-2023 nge-dissertation enesihloko esithi Breaking into Sound: Dis/Locating Ntu Cosmology and Improvisation in South African Jazz.

== Igalelo ku-Jazz Scholarship kanye ne-African Epistemologies ==
U-Makhathini waqeda i-PhD yakhe e- Africa Open Institute for Music, Research and Innovation e- Stellenbosch University ngo-2023 nge-dissertation enesihloko esithi ''Breaking into Sound: Dis/Locating Ntu Cosmology and Improvisation in South African Jazz'' .  Irhubhululo lakhe, irhubhululo elidoselwa buciko, liphikisa iimfundo ezijayelekileko ze-jazz ngokubeka phambili ubujamo be-jazz yeSewula Afrika, khulukhulu ngomqondo we ''-ntu'' cosmology. U-Makhathini uthi ukuzilungiselela kwe-jazz eSewula Afrika kungazwisiswa njengokuzibandakanya kwemikhuba nomsindo ohlanganisa indawo ebonakalako nebonakalako. 


Makhathini is the recipient of the 2015 '''[[:en:Standard_Bank_Young_Artist_Award|Standard Bank Young Artist Award]]''' in the category of Jazz.&lt;ref&gt;{{cite web|url=http://mg.co.za/article/2014-10-30-ndudozo-makhathini-in-sync-with-a-higher-power|title=Nduduzo Makhathini finds the gift of healing in song|author=Setumo-Thebe Mohlomi|work=The M&amp;G Online|date=30 October 2014}}&lt;/ref&gt; This is part of the [[:en:National_Arts_Festival|National Arts Festival]].&lt;ref&gt;{{Cite web|url=https://www.nationalartsfestival.co.za/about/young-artists/young-artists-award-history/|title=National Arts Festival|access-date=2018-10-31|archive-url=https://web.archive.org/web/20141029040308/https://www.nationalartsfestival.co.za/about/young-artists/young-artists-award-history/|archive-date=2014-10-29|url-status=dead}}&lt;/ref&gt; At the 2017 [[:en:All_Africa_Music_Awards|All Africa Music Awards]], Makhathini won the Best Jazz Artist award.&lt;ref&gt;{{cite web|url=https://www.bbc.co.uk/programmes/p06c8x8g|title=The rising star of South African jazz|publisher=[[BBC]]|date=28 June 2018|access-date=31 October 2018}}&lt;/ref&gt; His musical output has led him to be described by Seton Hawkins of ''All About Jazz'' to be &quot;a truly singular pianist, an astonishingly gifted composer, and a deeply nuanced thinker on the music...one of the [South Africa]'s most remarkable talents.&quot;&lt;ref&gt;{{Cite web|url=https://www.allaboutjazz.com/nduduzo-makhathini-jazz-is-a-shared-memory-nduduzo-makhathini-by-seton-hawkins|title=Nduduzo Makhathini: Jazz Is a Shared Memory|date=1 February 2018|website=[[All About Jazz]]|access-date=27 June 2022}}&lt;/ref&gt;

== Iinkomba ==
{{reflist}}
[[Category:Sewula Afrika]]
[[Umculo:Umculo weSewula Afrika]]</text>
      <sha1>kyxd8wihq2mttvnz2h80jrlyil1bo3d</sha1>
    </revision>
    <revision>
      <id>6288</id>
      <parentid>6287</parentid>
      <timestamp>2026-03-11T10:28:34Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6288</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3307" sha1="0loqofr91r8xk83h8c2efso2gyrcrxb" xml:space="preserve">
[[Isimumathi:Nduduzo_Makhathini_Quartet_28_october_2021_BIM_Amsterdam_-_Nduduzo_Makhathini_(51638611012).jpg|thumb|370x370px|uNduduzo udlala ipiyano]]
'''U-Nduduzo Makhathini''' (wabelethwa mhlazi-24 kuNobayeni 1982) mculi we-jazz [[Isewula Afrika|weSewula Afrika]] ovela e -Umgungundlovu, e-Pietermaritzburg, [[Isewula Afrika|e-Sewula Afrika]] .

Njengombana avela emndenini womculo, ithando lakhe lomculo lathoma asesemncani.  U-Makhathini udlale no -Zim Ngqawana, u-Simphiwe Dana, u-Feya Faku, no -McCoy Mrubata . U-Nduduzo waqeda i-Diploma yakhe ku-Jazz Piano e- Durban University of Technology ngo-2005,   begodu wathola i-PhD emculweni e- University of Stellenbosch ngo-2023.  

U-Makhathini waqeda i-PhD yakhe e-Africa Open Institute for Music, Research and Innovation e-Stellenbosch University ngo-2023 nge-dissertation enesihloko esithi Breaking into Sound: Dis/Locating Ntu Cosmology and Improvisation in South African Jazz.

== Igalelo ku-Jazz Scholarship kanye ne-African Epistemologies ==
U-Makhathini waqeda i-PhD yakhe e- Africa Open Institute for Music, Research and Innovation e- Stellenbosch University ngo-2023 nge-dissertation enesihloko esithi ''Breaking into Sound: Dis/Locating Ntu Cosmology and Improvisation in South African Jazz'' .  Irhubhululo lakhe, irhubhululo elidoselwa buciko, liphikisa iimfundo ezijayelekileko ze-jazz ngokubeka phambili ubujamo be-jazz yeSewula Afrika, khulukhulu ngomqondo we ''-ntu'' cosmology. U-Makhathini uthi ukuzilungiselela kwe-jazz eSewula Afrika kungazwisiswa njengokuzibandakanya kwemikhuba nomsindo ohlanganisa indawo ebonakalako nebonakalako. 


Makhathini is the recipient of the 2015 '''[[:en:Standard_Bank_Young_Artist_Award|Standard Bank Young Artist Award]]''' in the category of Jazz.&lt;ref&gt;{{cite web|url=http://mg.co.za/article/2014-10-30-ndudozo-makhathini-in-sync-with-a-higher-power|title=Nduduzo Makhathini finds the gift of healing in song|author=Setumo-Thebe Mohlomi|work=The M&amp;G Online|date=30 October 2014}}&lt;/ref&gt; This is part of the [[:en:National_Arts_Festival|National Arts Festival]].&lt;ref&gt;{{Cite web|url=https://www.nationalartsfestival.co.za/about/young-artists/young-artists-award-history/|title=National Arts Festival|access-date=2018-10-31|archive-url=https://web.archive.org/web/20141029040308/https://www.nationalartsfestival.co.za/about/young-artists/young-artists-award-history/|archive-date=2014-10-29|url-status=dead}}&lt;/ref&gt; At the 2017 [[:en:All_Africa_Music_Awards|All Africa Music Awards]], Makhathini won the Best Jazz Artist award.&lt;ref&gt;{{cite web|url=https://www.bbc.co.uk/programmes/p06c8x8g|title=The rising star of South African jazz|publisher=[[BBC]]|date=28 June 2018|access-date=31 October 2018}}&lt;/ref&gt; His musical output has led him to be described by Seton Hawkins of ''All About Jazz'' to be &quot;a truly singular pianist, an astonishingly gifted composer, and a deeply nuanced thinker on the music...one of the [South Africa]'s most remarkable talents.&quot;&lt;ref&gt;{{Cite web|url=https://www.allaboutjazz.com/nduduzo-makhathini-jazz-is-a-shared-memory-nduduzo-makhathini-by-seton-hawkins|title=Nduduzo Makhathini: Jazz Is a Shared Memory|date=1 February 2018|website=[[All About Jazz]]|access-date=27 June 2022}}&lt;/ref&gt;

== Iinkomba ==
{{reflist}}
[[Category:Sewula Afrika]]
[[Category:Umculo weSewula Afrika]]</text>
      <sha1>0loqofr91r8xk83h8c2efso2gyrcrxb</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Umculo weSewula Afrika</title>
    <ns>14</ns>
    <id>1062</id>
    <revision>
      <id>6289</id>
      <timestamp>2026-03-11T10:28:47Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created blank page</comment>
      <origin>6289</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
  </page>
  <page>
    <title>Ruhollah Khomeini</title>
    <ns>0</ns>
    <id>1063</id>
    <revision>
      <id>6290</id>
      <timestamp>2026-03-11T11:58:17Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1342870508|Ruhollah Khomeini]]&quot;</comment>
      <origin>6290</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3617" sha1="opf1rbb1zai65oeark93s6bs05yolia" xml:space="preserve">
'''Ruhollah Mostafavi Musavi Khomeini''' [ d ] (17 Meyi 1900 [ c ] – 3 kuMgwengweni 1989) bekangumtjhugululi wezepolotiki we-Iran nomfundisi we-Shia owasebenza njengomrholi wokuthoma omkhulu we-Iran kusukela ngo-1979 bekwaba sekufeni kwakhe ngo-1989. Bekangumdosiphambili omkhulu we-1979 Iranian Revolution, eyabhidliza u-Mohammad Reza Pahlavi begodu yatjhugulula i-Iran yaba yi- Islam Republic .

Ubaba kaKhomeini wabelethwa edorobheni le- Khomeyn, esifundazweni se-Iran's Markazi, ubaba ka-Khomeini wabulawa nakaneminyaka emibili. Wathoma ukufunda i -Quran nesi -Arabhu kusukela asesemncani asizwa ziinhlobo zakhe. UKhomeini waba mfundisi ophakemeko ku -Twelver Shi'ism, i ''-yatollah'', i- ''marja''' (&quot;umthombo wokulingisa&quot;), i- mujtahid, ''i-faqīha ne- hafiz'' (isazi se- ''fiqh'' ), nomtloli weencwadi ezingaphezu kwama-40. Ukuphikisa kwakhe i- White Revolution kwabangela ukuqotjhwa kwakhe e- Bursa ngo-1964. Pheze ngemva komnyaka, wathuthela e -Najaf, lapho iinkulumo azinikelako eziveza ithiyori yakhe yezepolotiki ye- Guardianship of the Jurist zahlanganiswa encwadini ethi ''Islamic Government'' .

Ngemva kokuphumelela kwe-Iran Revolution, u-Khomeini waba yihloko yombuso ''welizwe'' ukusukela ngoMhlolanja wee-1979 bekwaba kulapho akhethwa njengomdosiphambili omkhulu ngoNobayeni womnyaka loyo. U-Khomeini bekayiNdoda yoNyaka yemagazini ye &lt;nowiki&gt;&lt;i id=&quot;mwYQ&quot;&gt;-Time&lt;/i&gt;&lt;/nowiki&gt; ngo-1979 ngebanga lomthelela wakhe weentjhabatjhaba begodu eminyakeni elitjhumi elandelako wachazwa ngokuthi &quot;ubuso obubonakalako be-Shia Islam emasikweni adumileko weTjingalanga&quot;. Bekaziwa ngokusekela kwakhe abathumbi ngesikhathi seentjhijilo zokuthumba e-Iran ; i-fatwa yakhe ebiza ukubulawa komtloli wenoveli we-Britain owabelethelwa e-India u-Salman Rushdie ngebanga lokuhlathulula kwaka-Rushdie ngomphorofidi wama-Islam u-Muhammad enovelini yakhe ''i-The Satanic Verses'', u-Khomeini ayithatha njengokuhlambalaza; ukulandela ukuchithwa kuka- Saddam Hussein ePini ye-Iran ne-Iraq ; begodu ngokubiza i-United States ngokuthi &quot; nguSathana Omkhulu &quot; no -Israyeli ngokuthi &quot; nguSathana Omncani &quot;.

== Iminyaka yokuthoma ==

=== Isendlalelo ===
U-Ruhollah Mostafavi Musavi Khomeini bekavela emlandwini wabanikazi beendawo ezincani, abefundisi, nabathengisi.  Okhokho bakhe bafuduka ngasekupheleni kwekhulu le-18 ukusuka ekhaya labo lokuthoma e -Nishapur, ebeyiyingcenye yesifunda se-Khorasan, e-Iran esenyakatho-pumalanga ukobana bahlale isikhatjhana eMbusweni we-Awadh, isifunda sesifunda samanje se- Uttar Pradesh, e-India, lapho ababusi bayo bekungamaSulumane we-Twelver Shina avela e-Persia .    Ngesikhathi sokubusa kwabo, bamema begodu bamukela umsinga ongapheliko wezazi zamaPheresiya, iimbongi, izazi zomthetho, abakhi, nabadwebi.  Umndeni wagcina uhlala edorobheni elincani le -Kintoor, eduze ne -Lucknow, idolobha elikhulu le-Awadh.    


Umkhulu ka-Khomeini, u-Ahmad Hindi, wabelethwa e-Kintoor.[1][2] Watjhiya i-Lucknow ngo-1830, waya ethuneni laka-Ali e-Najaf, e-Ottoman Iraq (nje i-Iraq), begodu azange abuyele emuva.[3][2] Ngokuya komtloli weencwadi zomlando u-Baqer Moin, ukufuduka lokhu bekukuphunyuka ekusakazekeni kwamandla we-Britain e-India.[4] Ngo-1834, u-Seyyed Ahmad Musavi Hindi wavakatjhela i-Iran, begodu ngo-1839, wahlala e-Khomein.[1] Nanyana wahlala e-Iran, waragela phambili aziwa nge-Hindi, okutjengisa ukuhlala kwakhe e-India, begodu u-Ruhollah Khomeini wasebenzisa i-Hindi njengebizo lepeni kezinye zeencwadi zakhe.[3] Uyisemkhulu ka-Khomeini, u-Mirza Ahmad Mojtahed-e Khonsari bekangumfundisi owakhipha i-fatwa yokukhandela ukusetjenziswa kwegwayi ngesikhathi se-Tobacco Protest.[5][6]</text>
      <sha1>opf1rbb1zai65oeark93s6bs05yolia</sha1>
    </revision>
    <revision>
      <id>6291</id>
      <parentid>6290</parentid>
      <timestamp>2026-03-11T11:59:46Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6291</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3705" sha1="713mxlomweecos11j7o2aflxbxtl5uh" xml:space="preserve">[[Isimumathi:Ruhollah Khomeini by Jamaran 2.jpg|thumb|Isthombe sika Ayathola Khomeini.]]
'''Ruhollah Mostafavi Musavi Khomeini''' [ d ] (17 Meyi 1900 [ c ] – 3 kuMgwengweni 1989) bekangumtjhugululi wezepolotiki we-Iran nomfundisi we-Shia owasebenza njengomrholi wokuthoma omkhulu we-Iran kusukela ngo-1979 bekwaba sekufeni kwakhe ngo-1989. Bekangumdosiphambili omkhulu we-1979 Iranian Revolution, eyabhidliza u-Mohammad Reza Pahlavi begodu yatjhugulula i-Iran yaba yi- Islam Republic .

Ubaba kaKhomeini wabelethwa edorobheni le- Khomeyn, esifundazweni se-Iran's Markazi, ubaba ka-Khomeini wabulawa nakaneminyaka emibili. Wathoma ukufunda i -Quran nesi -Arabhu kusukela asesemncani asizwa ziinhlobo zakhe. UKhomeini waba mfundisi ophakemeko ku -Twelver Shi'ism, i ''-yatollah'', i- ''marja''' (&quot;umthombo wokulingisa&quot;), i- mujtahid, ''i-faqīha ne- hafiz'' (isazi se- ''fiqh'' ), nomtloli weencwadi ezingaphezu kwama-40. Ukuphikisa kwakhe i- White Revolution kwabangela ukuqotjhwa kwakhe e- Bursa ngo-1964. Pheze ngemva komnyaka, wathuthela e -Najaf, lapho iinkulumo azinikelako eziveza ithiyori yakhe yezepolotiki ye- Guardianship of the Jurist zahlanganiswa encwadini ethi ''Islamic Government'' .

Ngemva kokuphumelela kwe-Iran Revolution, u-Khomeini waba yihloko yombuso ''welizwe'' ukusukela ngoMhlolanja wee-1979 bekwaba kulapho akhethwa njengomdosiphambili omkhulu ngoNobayeni womnyaka loyo. U-Khomeini bekayiNdoda yoNyaka yemagazini ye &lt;nowiki&gt;&lt;i id=&quot;mwYQ&quot;&gt;-Time&lt;/i&gt;&lt;/nowiki&gt; ngo-1979 ngebanga lomthelela wakhe weentjhabatjhaba begodu eminyakeni elitjhumi elandelako wachazwa ngokuthi &quot;ubuso obubonakalako be-Shia Islam emasikweni adumileko weTjingalanga&quot;. Bekaziwa ngokusekela kwakhe abathumbi ngesikhathi seentjhijilo zokuthumba e-Iran ; i-fatwa yakhe ebiza ukubulawa komtloli wenoveli we-Britain owabelethelwa e-India u-Salman Rushdie ngebanga lokuhlathulula kwaka-Rushdie ngomphorofidi wama-Islam u-Muhammad enovelini yakhe ''i-The Satanic Verses'', u-Khomeini ayithatha njengokuhlambalaza; ukulandela ukuchithwa kuka- Saddam Hussein ePini ye-Iran ne-Iraq ; begodu ngokubiza i-United States ngokuthi &quot; nguSathana Omkhulu &quot; no -Israyeli ngokuthi &quot; nguSathana Omncani &quot;.

== Iminyaka yokuthoma ==

=== Isendlalelo ===
U-Ruhollah Mostafavi Musavi Khomeini bekavela emlandwini wabanikazi beendawo ezincani, abefundisi, nabathengisi.  Okhokho bakhe bafuduka ngasekupheleni kwekhulu le-18 ukusuka ekhaya labo lokuthoma e -Nishapur, ebeyiyingcenye yesifunda se-Khorasan, e-Iran esenyakatho-pumalanga ukobana bahlale isikhatjhana eMbusweni we-Awadh, isifunda sesifunda samanje se- Uttar Pradesh, e-India, lapho ababusi bayo bekungamaSulumane we-Twelver Shina avela e-Persia .    Ngesikhathi sokubusa kwabo, bamema begodu bamukela umsinga ongapheliko wezazi zamaPheresiya, iimbongi, izazi zomthetho, abakhi, nabadwebi.  Umndeni wagcina uhlala edorobheni elincani le -Kintoor, eduze ne -Lucknow, idolobha elikhulu le-Awadh.    


Umkhulu ka-Khomeini, u-Ahmad Hindi, wabelethwa e-Kintoor.[1][2] Watjhiya i-Lucknow ngo-1830, waya ethuneni laka-Ali e-Najaf, e-Ottoman Iraq (nje i-Iraq), begodu azange abuyele emuva.[3][2] Ngokuya komtloli weencwadi zomlando u-Baqer Moin, ukufuduka lokhu bekukuphunyuka ekusakazekeni kwamandla we-Britain e-India.[4] Ngo-1834, u-Seyyed Ahmad Musavi Hindi wavakatjhela i-Iran, begodu ngo-1839, wahlala e-Khomein.[1] Nanyana wahlala e-Iran, waragela phambili aziwa nge-Hindi, okutjengisa ukuhlala kwakhe e-India, begodu u-Ruhollah Khomeini wasebenzisa i-Hindi njengebizo lepeni kezinye zeencwadi zakhe.[3] Uyisemkhulu ka-Khomeini, u-Mirza Ahmad Mojtahed-e Khonsari bekangumfundisi owakhipha i-fatwa yokukhandela ukusetjenziswa kwegwayi ngesikhathi se-Tobacco Protest.[5][6]</text>
      <sha1>713mxlomweecos11j7o2aflxbxtl5uh</sha1>
    </revision>
    <revision>
      <id>6292</id>
      <parentid>6291</parentid>
      <timestamp>2026-03-11T12:00:52Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6292</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3678" sha1="mdaxznjsfy7qcy6hftp1ad6oky6pano" xml:space="preserve">[[Isimumathi:Ruhollah Khomeini by Jamaran 2.jpg|thumb|Isthombe sika Ayathola Khomeini.]]
'''Ruhollah Mostafavi Musavi Khomeini''' [ d ] (17 Meyi 1900 [ c ] – 3 kuMgwengweni 1989) bekangumtjhugululi wezepolotiki we-Iran nomfundisi we-Shia owasebenza njengomrholi wokuthoma omkhulu we-Iran kusukela ngo-1979 bekwaba sekufeni kwakhe ngo-1989. Bekangumdosiphambili omkhulu we-1979 Iranian Revolution, eyabhidliza u-Mohammad Reza Pahlavi begodu yatjhugulula i-Iran yaba yi- Islam Republic .

Ubaba kaKhomeini wabelethwa edorobheni le- Khomeyn, esifundazweni se-Iran's Markazi, ubaba ka-Khomeini wabulawa nakaneminyaka emibili. Wathoma ukufunda i -Quran nesi -Arabhu kusukela asesemncani asizwa ziinhlobo zakhe. UKhomeini waba mfundisi ophakemeko ku -Twelver Shi'ism, i ''-yatollah'', i- ''marja''' (&quot;umthombo wokulingisa&quot;), i- mujtahid, ''i-faqīha ne- hafiz'' (isazi se- ''fiqh'' ), nomtloli weencwadi ezingaphezu kwama-40. Ukuphikisa kwakhe i- White Revolution kwabangela ukuqotjhwa kwakhe e- Bursa ngo-1964. Pheze ngemva komnyaka, wathuthela e -Najaf, lapho iinkulumo azinikelako eziveza ithiyori yakhe yezepolotiki ye- Guardianship of the Jurist zahlanganiswa encwadini ethi ''Islamic Government'' .

Ngemva kokuphumelela kwe-Iran Revolution, u-Khomeini waba yihloko yombuso ''welizwe'' ukusukela ngoMhlolanja wee-1979 bekwaba kulapho akhethwa njengomdosiphambili omkhulu ngoNobayeni womnyaka loyo. U-Khomeini bekayiNdoda yoNyaka yemagazini ye &lt;nowiki&gt;&lt;i id=&quot;mwYQ&quot;&gt;-Time&lt;/i&gt;&lt;/nowiki&gt; ngo-1979 ngebanga lomthelela wakhe weentjhabatjhaba begodu eminyakeni elitjhumi elandelako wachazwa ngokuthi &quot;ubuso obubonakalako be-Shia Islam emasikweni adumileko weTjingalanga&quot;. Bekaziwa ngokusekela kwakhe abathumbi ngesikhathi seentjhijilo zokuthumba e-Iran ; i-fatwa yakhe ebiza ukubulawa komtloli wenoveli we-Britain owabelethelwa e-India u-Salman Rushdie ngebanga lokuhlathulula kwaka-Rushdie ngomphorofidi wama-Islam u-Muhammad enovelini yakhe ''i-The Satanic Verses'', u-Khomeini ayithatha njengokuhlambalaza; ukulandela ukuchithwa kuka- Saddam Hussein ePini ye-Iran ne-Iraq ; begodu ngokubiza i-United States ngokuthi &quot; nguSathana Omkhulu &quot; no -Israyeli ngokuthi &quot; nguSathana Omncani &quot;.

== Iminyaka yokuthoma ==

=== Isendlalelo ===
U-Ruhollah Mostafavi Musavi Khomeini bekavela emlandwini wabanikazi beendawo ezincani, abefundisi, nabathengisi.  Okhokho bakhe bafuduka ngasekupheleni kwekhulu le-18 ukusuka ekhaya labo lokuthoma e -Nishapur, ebeyiyingcenye yesifunda se-Khorasan, e-Iran esenyakatho-pumalanga ukobana bahlale isikhatjhana eMbusweni we-Awadh, isifunda sesifunda samanje se- Uttar Pradesh, e-India, lapho ababusi bayo bekungamaSulumane we-Twelver Shina avela e-Persia .    Ngesikhathi sokubusa kwabo, bamema begodu bamukela umsinga ongapheliko wezazi zamaPheresiya, iimbongi, izazi zomthetho, abakhi, nabadwebi.  Umndeni wagcina uhlala edorobheni elincani le -Kintoor, eduze ne -Lucknow, idolobha elikhulu le-Awadh.    


Umkhulu ka-Khomeini, u-Ahmad Hindi, wabelethwa e-Kintoor. Watjhiya i-Lucknow ngo-1830, waya ethuneni laka-Ali e-Najaf, e-Ottoman Iraq (nje i-Iraq), begodu azange abuyele emuva. Ngokuya komtloli weencwadi zomlando u-Baqer Moin, ukufuduka lokhu bekukuphunyuka ekusakazekeni kwamandla we-Britain e-India. Ngo-1834, u-Seyyed Ahmad Musavi Hindi wavakatjhela i-Iran, begodu ngo-1839, wahlala e-Khomein. Nanyana wahlala e-Iran, waragela phambili aziwa nge-Hindi, okutjengisa ukuhlala kwakhe e-India, begodu u-Ruhollah Khomeini wasebenzisa i-Hindi njengebizo lepeni kezinye zeencwadi zakhe. Uyisemkhulu ka-Khomeini, u-Mirza Ahmad Mojtahed-e Khonsari bekangumfundisi owakhipha i-fatwa yokukhandela ukusetjenziswa kwegwayi ngesikhathi se-Tobacco Protest.</text>
      <sha1>mdaxznjsfy7qcy6hftp1ad6oky6pano</sha1>
    </revision>
    <revision>
      <id>6293</id>
      <parentid>6292</parentid>
      <timestamp>2026-03-11T12:01:25Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>/* Isendlalelo */</comment>
      <origin>6293</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3677" sha1="5nf3xu6a13bbuy9atcedtwl2ol3lsen" xml:space="preserve">[[Isimumathi:Ruhollah Khomeini by Jamaran 2.jpg|thumb|Isthombe sika Ayathola Khomeini.]]
'''Ruhollah Mostafavi Musavi Khomeini''' [ d ] (17 Meyi 1900 [ c ] – 3 kuMgwengweni 1989) bekangumtjhugululi wezepolotiki we-Iran nomfundisi we-Shia owasebenza njengomrholi wokuthoma omkhulu we-Iran kusukela ngo-1979 bekwaba sekufeni kwakhe ngo-1989. Bekangumdosiphambili omkhulu we-1979 Iranian Revolution, eyabhidliza u-Mohammad Reza Pahlavi begodu yatjhugulula i-Iran yaba yi- Islam Republic .

Ubaba kaKhomeini wabelethwa edorobheni le- Khomeyn, esifundazweni se-Iran's Markazi, ubaba ka-Khomeini wabulawa nakaneminyaka emibili. Wathoma ukufunda i -Quran nesi -Arabhu kusukela asesemncani asizwa ziinhlobo zakhe. UKhomeini waba mfundisi ophakemeko ku -Twelver Shi'ism, i ''-yatollah'', i- ''marja''' (&quot;umthombo wokulingisa&quot;), i- mujtahid, ''i-faqīha ne- hafiz'' (isazi se- ''fiqh'' ), nomtloli weencwadi ezingaphezu kwama-40. Ukuphikisa kwakhe i- White Revolution kwabangela ukuqotjhwa kwakhe e- Bursa ngo-1964. Pheze ngemva komnyaka, wathuthela e -Najaf, lapho iinkulumo azinikelako eziveza ithiyori yakhe yezepolotiki ye- Guardianship of the Jurist zahlanganiswa encwadini ethi ''Islamic Government'' .

Ngemva kokuphumelela kwe-Iran Revolution, u-Khomeini waba yihloko yombuso ''welizwe'' ukusukela ngoMhlolanja wee-1979 bekwaba kulapho akhethwa njengomdosiphambili omkhulu ngoNobayeni womnyaka loyo. U-Khomeini bekayiNdoda yoNyaka yemagazini ye &lt;nowiki&gt;&lt;i id=&quot;mwYQ&quot;&gt;-Time&lt;/i&gt;&lt;/nowiki&gt; ngo-1979 ngebanga lomthelela wakhe weentjhabatjhaba begodu eminyakeni elitjhumi elandelako wachazwa ngokuthi &quot;ubuso obubonakalako be-Shia Islam emasikweni adumileko weTjingalanga&quot;. Bekaziwa ngokusekela kwakhe abathumbi ngesikhathi seentjhijilo zokuthumba e-Iran ; i-fatwa yakhe ebiza ukubulawa komtloli wenoveli we-Britain owabelethelwa e-India u-Salman Rushdie ngebanga lokuhlathulula kwaka-Rushdie ngomphorofidi wama-Islam u-Muhammad enovelini yakhe ''i-The Satanic Verses'', u-Khomeini ayithatha njengokuhlambalaza; ukulandela ukuchithwa kuka- Saddam Hussein ePini ye-Iran ne-Iraq ; begodu ngokubiza i-United States ngokuthi &quot; nguSathana Omkhulu &quot; no -Israyeli ngokuthi &quot; nguSathana Omncani &quot;.

== Iminyaka yokuthoma ==

=== Isendlalelo ===
U-Ruhollah Mostafavi Musavi Khomeini bekavela emlandwini wabanikazi beendawo ezincani, abefundisi, nabathengisi.  Okhokho bakhe bafuduka ngasekupheleni kwekhulu le-18 ukusuka ekhaya labo lokuthoma e -Nishapur, ebeyiyingcenye yesifunda se-Khorasan, e-Iran esenyakatho-pumalanga ukobana bahlale isikhatjhana eMbusweni we-Awadh, isifunda sesifunda samanje se- Uttar Pradesh, e-India, lapho ababusi bayo bekungamaSulumane we-Twelver Shina avela e-Persia .    Ngesikhathi sokubusa kwabo, bamema begodu bamukela umsinga ongapheliko wezazi zamaPheresiya, iimbongi, izazi zomthetho, abakhi, nabadwebi.  Umndeni wagcina uhlala edorobheni elincani le -Kintoor, eduze ne -Lucknow, idolobha elikhulu le-Awadh.    

Umkhulu ka-Khomeini, u-Ahmad Hindi, wabelethwa e-Kintoor. Watjhiya i-Lucknow ngo-1830, waya ethuneni laka-Ali e-Najaf, e-Ottoman Iraq (nje i-Iraq), begodu azange abuyele emuva. Ngokuya komtloli weencwadi zomlando u-Baqer Moin, ukufuduka lokhu bekukuphunyuka ekusakazekeni kwamandla we-Britain e-India. Ngo-1834, u-Seyyed Ahmad Musavi Hindi wavakatjhela i-Iran, begodu ngo-1839, wahlala e-Khomein. Nanyana wahlala e-Iran, waragela phambili aziwa nge-Hindi, okutjengisa ukuhlala kwakhe e-India, begodu u-Ruhollah Khomeini wasebenzisa i-Hindi njengebizo lepeni kezinye zeencwadi zakhe. Uyisemkhulu ka-Khomeini, u-Mirza Ahmad Mojtahed-e Khonsari bekangumfundisi owakhipha i-fatwa yokukhandela ukusetjenziswa kwegwayi ngesikhathi se-Tobacco Protest.</text>
      <sha1>5nf3xu6a13bbuy9atcedtwl2ol3lsen</sha1>
    </revision>
  </page>
  <page>
    <title>Mzwakhe Mbuli</title>
    <ns>0</ns>
    <id>1064</id>
    <revision>
      <id>6305</id>
      <timestamp>2026-03-15T17:01:37Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1343654130|Mzwakhe Mbuli]]&quot;</comment>
      <origin>6305</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2646" sha1="agl04naf6rj43ggrp4vb9te6zj5f69y" xml:space="preserve">
'''U-Mzwakhe Mbuli''' (wabelethwa mhlana ali-1 kuRhoboyi wee-1959) yimbongi yeSewula Afrika, umvumi we-Mbaqanga begodu owayenguDikoni we-Apostolic Faith Mission Church e-Naledi Soweto, [[Isewula Afrika|eSewula Afrika]] . Waziwa ngokuthi &quot;Imbongi Yabantu, Indoda Ede, I-Mbulism, Iphimbo Lokucabanga&quot;, nguyise ka-Mzwakhe Mbuli Junior, owaziwa nange- Robot Boii .

== Ipilo yokuthoma ==
Wabelethelwa e- Sophiatown, begodu msinyana wathuthela ngemva kobana umndenakhe ukateleleka bona uthuthele e-Soweto lokha urhulumende nakabhidliza idorobha lakhe. &lt;ref&gt;''Afropop! An Illustrated Guide to Contemporary African Music'' by Sean Barlow &amp; [[Banning Eyre]] &lt;/ref&gt;

== Ukuphikisana ==
U-Mbuli waphikisana nekhotho malungana nokusetjenziswa kwesibongo sowesifazana.  U-Mbuli wagwetjwa ngoNtaka 1999 ngecala lokuphanga ahlomile nokuba nebhomu lezandla-–ubulelesi ahlala aphika bona ubenzile; yena nabasekeli bakhe bebasolo baphikelela ngokuthi urhulumende wamangalelwa ngokukhuluma ngokuphikisana nekohlakalo. Wavalelwa ejele le-Leeuwkop Maximum Security, bekwaba kulapho akhululwa khona ngoNovemba 2003.

== Ibizelo ==
Imisebenzi yakhe ifakahlangana incwadi yeenkondlo, Before Dawn (1989), kanye nama-albhamu i-Change Is Pain (1986), Unbroken Spirit (1989), Resistance Is Defense (1992), kanye ne-Afrika (1993). Iinkondlo zakhe zisesiNgisini kodwana zisebenzisa isiZulu sakhe sokuzalwa kanye neenkondlo zesintu zokudumisa kanye ne-rap. Inkondlo yakhe eyaziwa khulu ngu-&quot;Ukutjhuguluka Kubuhlungu,&quot; inkondlo yokutjhikijela ngokugandeleleka nokuvukela umbuso, ekuthomeni eyavinjelwa bekwaba kulapho ukugandeleleka okukhulako kugandelela iSewula Afrika bona ivumele ikululeko yokukhuluma. Iqembu lakhe lokuqala lokusebenza lalibizwa nge-Khuvhangano.

== I-Discography ==

=== Ama-albhamu we-studio ===

* ''Change Is Pain'' (1986) Shifty (Rounder - USA)
* ''Unbroken Spirit'' (1988) Shifty Records
* ''[[:en:Resistance_Is_Defence|Resistance Is Defence]]'' (1992) Stern's Earthworks
* ''Afrika'' (1993) CCP/EMI South Africa
* ''Izigi'' (1994) CCP/EMI, South Africa
* ''KwaZulu-Natal'' (1996) CCP / EMI South Africa
* ''Umzwakhe Ubongu Ujehovah'' (1997) CCP/EMI South Africa
* ''Mbulism'' (2004) CCP/EMI South Africa &lt;ref name=&quot;autogenerated1&quot;&gt;{{Cite web|url=http://www.ukzn.ac.za/cca/images/pa/PA2004/poets/mbuli.htm|title=Poetry Africa 2004&lt;!-- Bot generated title --&gt;|access-date=2008-04-16|archive-url=https://web.archive.org/web/20080512140719/http://www.ukzn.ac.za/cca/images/pa/PA2004/poets/mbuli.htm|archive-date=2008-05-12|url-status=dead}}&lt;/ref&gt;

=== Abangakathathi ===

* &quot; Mandela &quot; &lt;small&gt;(no- Zahara )&lt;/small&gt; (2013)
{{Reflist}}

== Iinkomba ==</text>
      <sha1>agl04naf6rj43ggrp4vb9te6zj5f69y</sha1>
    </revision>
    <revision>
      <id>6306</id>
      <parentid>6305</parentid>
      <timestamp>2026-03-15T17:08:30Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6306</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4354" sha1="k4l9faleevbe878ta5pfucuex68g5xe" xml:space="preserve">
'''U-Mzwakhe Mbuli''' (wabelethwa mhlana ali-1 kuRhoboyi wee-1959) yimbongi yeSewula Afrika, umvumi we-Mbaqanga begodu owayenguDikoni we-Apostolic Faith Mission Church e-Naledi Soweto, [[Isewula Afrika|eSewula Afrika]] . Waziwa ngokuthi &quot;Imbongi Yabantu, Indoda Ede, I-Mbulism, Iphimbo Lokucabanga&quot;, nguyise ka-Mzwakhe Mbuli Junior, owaziwa nange- Robot Boii. &lt;ref&gt;timeslive.co.za/news/south-africa/2025-09-17-a-betrayal-mzwakhe-mbuli-slams-concourt-ruling-on-wives-surnames/&lt;/ref&gt;

== Ipilo yokuthoma ==
Wabelethelwa e- Sophiatown, begodu msinyana wathuthela ngemva kobana umndenakhe ukateleleka bona uthuthele e-Soweto lokha urhulumende nakabhidliza idorobha lakhe. &lt;ref&gt;''Afropop! An Illustrated Guide to Contemporary African Music'' by Sean Barlow &amp; [[Banning Eyre]] &lt;/ref&gt;

== Ukuphikisana ==
U-Mbuli waphikisana nekhotho malungana nokusetjenziswa kwesibongo sowesifazana.  U-Mbuli wagwetjwa ngoNtaka 1999 ngecala lokuphanga ahlomile nokuba nebhomu lezandla-–ubulelesi ahlala aphika bona ubenzile; yena nabasekeli bakhe bebasolo baphikelela ngokuthi urhulumende wamangalelwa ngokukhuluma ngokuphikisana nekohlakalo. Wavalelwa ejele le-Leeuwkop Maximum Security, bekwaba kulapho akhululwa khona ngoNovemba 2003.&lt;ref&gt;https://www.google.com/search?sca_esv=c7b63db539d9a6f3&amp;rlz=1C5XQIR_enZA1202ZA1202&amp;sxsrf=ANbL-n56HDwgke4-njc8jKDO60_TeLZMJg:1773594331316&amp;q=Mzwakhe+Mbuli&amp;tbm=nws&amp;source=lnms&amp;fbs=ADc_l-aN0CWEZBOHjofHoaMMDiKpaEWjvZ2Py1XXV8d8KvlI3jljrY5CkLlk8Dq3IvwBz-SJyfRX_inP-J3Cs9lQZu9JC8DiUG6qMRySOJxhrHTckGj_12g3BQ61PQ3-wxupQlKC4HicIQIYhtagPFRXF9WbznrYoYbeQyyU6dSoPPbwip6KHS44TZNmOMhqtmdhopYEPSjNcguYxeiAgsv7AboWWXp3QA&amp;sa=X&amp;ved=2ahUKEwjK39_gsaKTAxUi-gIHHQ8bCxEQ0pQJegQIIBAB&amp;biw=1374&amp;bih=748&amp;dpr=2.2#:~:text=The%20Citizen,13%20Nov%202025&lt;/ref&gt;

== Ibizelo ==
Imisebenzi yakhe ifakahlangana incwadi yeenkondlo, Before Dawn (1989), kanye nama-albhamu i-Change Is Pain (1986), Unbroken Spirit (1989), Resistance Is Defense (1992), kanye ne-Afrika (1993). Iinkondlo zakhe zisesiNgisini kodwana zisebenzisa isiZulu sakhe sokuzalwa kanye neenkondlo zesintu zokudumisa kanye ne-rap. Inkondlo yakhe eyaziwa khulu ngu-&quot;Ukutjhuguluka Kubuhlungu,&quot; inkondlo yokutjhikijela ngokugandeleleka nokuvukela umbuso, ekuthomeni eyavinjelwa bekwaba kulapho ukugandeleleka okukhulako kugandelela iSewula Afrika bona ivumele ikululeko yokukhuluma. Iqembu lakhe lokuqala lokusebenza lalibizwa nge-Khuvhangano.&lt;ref&gt;https://www.google.com/search?sca_esv=c7b63db539d9a6f3&amp;rlz=1C5XQIR_enZA1202ZA1202&amp;sxsrf=ANbL-n56HDwgke4-njc8jKDO60_TeLZMJg:1773594331316&amp;q=Mzwakhe+Mbuli&amp;tbm=nws&amp;source=lnms&amp;fbs=ADc_l-aN0CWEZBOHjofHoaMMDiKpaEWjvZ2Py1XXV8d8KvlI3jljrY5CkLlk8Dq3IvwBz-SJyfRX_inP-J3Cs9lQZu9JC8DiUG6qMRySOJxhrHTckGj_12g3BQ61PQ3-wxupQlKC4HicIQIYhtagPFRXF9WbznrYoYbeQyyU6dSoPPbwip6KHS44TZNmOMhqtmdhopYEPSjNcguYxeiAgsv7AboWWXp3QA&amp;sa=X&amp;ved=2ahUKEwjK39_gsaKTAxUi-gIHHQ8bCxEQ0pQJegQIIBAB&amp;biw=1374&amp;bih=748&amp;dpr=2.2#:~:text=SABC%20News,29%20Aug%202025&lt;/ref&gt;&lt;ref&gt;https://www.google.com/search?sca_esv=c7b63db539d9a6f3&amp;rlz=1C5XQIR_enZA1202ZA1202&amp;sxsrf=ANbL-n56HDwgke4-njc8jKDO60_TeLZMJg:1773594331316&amp;q=Mzwakhe+Mbuli&amp;tbm=nws&amp;source=lnms&amp;fbs=ADc_l-aN0CWEZBOHjofHoaMMDiKpaEWjvZ2Py1XXV8d8KvlI3jljrY5CkLlk8Dq3IvwBz-SJyfRX_inP-J3Cs9lQZu9JC8DiUG6qMRySOJxhrHTckGj_12g3BQ61PQ3-wxupQlKC4HicIQIYhtagPFRXF9WbznrYoYbeQyyU6dSoPPbwip6KHS44TZNmOMhqtmdhopYEPSjNcguYxeiAgsv7AboWWXp3QA&amp;sa=X&amp;ved=2ahUKEwjK39_gsaKTAxUi-gIHHQ8bCxEQ0pQJegQIIBAB&amp;biw=1374&amp;bih=748&amp;dpr=2.2#:~:text=News24,15%20Oct%202025&lt;/ref&gt;

== I-Discography ==

=== Ama-albhamu we-studio ===

* ''Change Is Pain'' (1986) Shifty (Rounder - USA)
* ''Unbroken Spirit'' (1988) Shifty Records
* ''[[:en:Resistance_Is_Defence|Resistance Is Defence]]'' (1992) Stern's Earthworks
* ''Afrika'' (1993) CCP/EMI South Africa
* ''Izigi'' (1994) CCP/EMI, South Africa
* ''KwaZulu-Natal'' (1996) CCP / EMI South Africa
* ''Umzwakhe Ubongu Ujehovah'' (1997) CCP/EMI South Africa
* ''Mbulism'' (2004) CCP/EMI South Africa &lt;ref name=&quot;autogenerated1&quot;&gt;{{Cite web|url=http://www.ukzn.ac.za/cca/images/pa/PA2004/poets/mbuli.htm|title=Poetry Africa 2004&lt;!-- Bot generated title --&gt;|access-date=2008-04-16|archive-url=https://web.archive.org/web/20080512140719/http://www.ukzn.ac.za/cca/images/pa/PA2004/poets/mbuli.htm|archive-date=2008-05-12|url-status=dead}}&lt;/ref&gt;

=== Abangakathathi ===

* &quot; Mandela &quot; &lt;small&gt;(no- Zahara )&lt;/small&gt; (2013)
{{Reflist}}

== Iinkomba ==</text>
      <sha1>k4l9faleevbe878ta5pfucuex68g5xe</sha1>
    </revision>
    <revision>
      <id>6307</id>
      <parentid>6306</parentid>
      <timestamp>2026-03-15T17:09:22Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6307</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4354" sha1="imcfmts7qdj4v6jv45f3mpcutx41g5a" xml:space="preserve">
'''U-Mzwakhe Mbuli''' (wabelethwa mhlana ali-1 kuRhoboyi wee-1959) yimbongi yeSewula Afrika, umvumi we-Mbaqanga begodu owayenguDikoni we-Apostolic Faith Mission Church e-Naledi Soweto, [[Isewula Afrika|eSewula Afrika]] . Waziwa ngokuthi &quot;Imbongi Yabantu, Indoda Ede, I-Mbulism, Iphimbo Lokucabanga&quot;, nguyise ka-Mzwakhe Mbuli Junior, owaziwa nange- Robot Boii. &lt;ref&gt;timeslive.co.za/news/south-africa/2025-09-17-a-betrayal-mzwakhe-mbuli-slams-concourt-ruling-on-wives-surnames/&lt;/ref&gt;

== Ipilo yokuthoma ==
Wabelethelwa e- Sophiatown, begodu msinyana wathuthela ngemva kobana umndenakhe ukateleleka bona uthuthele e-Soweto lokha urhulumende nakabhidliza idorobha lakhe. &lt;ref&gt;''Afropop! An Illustrated Guide to Contemporary African Music'' by Sean Barlow &amp; [[Banning Eyre]] &lt;/ref&gt;

== Ukuphikisana ==
U-Mbuli waphikisana nekhotho malungana nokusetjenziswa kwesibongo sowesifazana.  U-Mbuli wagwetjwa ngoNtaka 1999 ngecala lokuphanga ahlomile nokuba nebhomu lezandla-–ubulelesi ahlala aphika bona ubenzile; yena nabasekeli bakhe bebasolo baphikelela ngokuthi urhulumende wamangalelwa ngokukhuluma ngokuphikisana nekohlakalo. Wavalelwa ejele le-Leeuwkop Maximum Security, bekwaba kulapho akhululwa khona ngoNovemba 2003.&lt;ref&gt;https://www.google.com/search?sca_esv=c7b63db539d9a6f3&amp;rlz=1C5XQIR_enZA1202ZA1202&amp;sxsrf=ANbL-n56HDwgke4-njc8jKDO60_TeLZMJg:1773594331316&amp;q=Mzwakhe+Mbuli&amp;tbm=nws&amp;source=lnms&amp;fbs=ADc_l-aN0CWEZBOHjofHoaMMDiKpaEWjvZ2Py1XXV8d8KvlI3jljrY5CkLlk8Dq3IvwBz-SJyfRX_inP-J3Cs9lQZu9JC8DiUG6qMRySOJxhrHTckGj_12g3BQ61PQ3-wxupQlKC4HicIQIYhtagPFRXF9WbznrYoYbeQyyU6dSoPPbwip6KHS44TZNmOMhqtmdhopYEPSjNcguYxeiAgsv7AboWWXp3QA&amp;sa=X&amp;ved=2ahUKEwjK39_gsaKTAxUi-gIHHQ8bCxEQ0pQJegQIIBAB&amp;biw=1374&amp;bih=748&amp;dpr=2.2#:~:text=The%20Citizen,13%20Nov%202025&lt;/ref&gt;

== Ibizelo ==
Imisebenzi yakhe ifakahlangana incwadi yeenkondlo, Before Dawn (1989), kanye nama-albhamu i-Change Is Pain (1986), Unbroken Spirit (1989), Resistance Is Defense (1992), kanye ne-Afrika (1993). Iinkondlo zakhe zisesiNgisini kodwana zisebenzisa isiZulu sakhe sokuzalwa kanye neenkondlo zesintu zokudumisa kanye ne-rap. Inkondlo yakhe eyaziwa khulu ngu-&quot;Ukutjhuguluka Kubuhlungu,&quot; inkondlo yokutjhikijela ngokugandeleleka nokuvukela umbuso, ekuthomeni eyavinjelwa bekwaba kulapho ukugandeleleka okukhulako kugandelela iSewula Afrika bona ivumele ikululeko yokukhuluma. Iqembu lakhe lokuqala lokusebenza lalibizwa nge-Khuvhangano.&lt;ref&gt;https://www.google.com/search?sca_esv=c7b63db539d9a6f3&amp;rlz=1C5XQIR_enZA1202ZA1202&amp;sxsrf=ANbL-n56HDwgke4-njc8jKDO60_TeLZMJg:1773594331316&amp;q=Mzwakhe+Mbuli&amp;tbm=nws&amp;source=lnms&amp;fbs=ADc_l-aN0CWEZBOHjofHoaMMDiKpaEWjvZ2Py1XXV8d8KvlI3jljrY5CkLlk8Dq3IvwBz-SJyfRX_inP-J3Cs9lQZu9JC8DiUG6qMRySOJxhrHTckGj_12g3BQ61PQ3-wxupQlKC4HicIQIYhtagPFRXF9WbznrYoYbeQyyU6dSoPPbwip6KHS44TZNmOMhqtmdhopYEPSjNcguYxeiAgsv7AboWWXp3QA&amp;sa=X&amp;ved=2ahUKEwjK39_gsaKTAxUi-gIHHQ8bCxEQ0pQJegQIIBAB&amp;biw=1374&amp;bih=748&amp;dpr=2.2#:~:text=SABC%20News,29%20Aug%202025&lt;/ref&gt;&lt;ref&gt;https://www.google.com/search?sca_esv=c7b63db539d9a6f3&amp;rlz=1C5XQIR_enZA1202ZA1202&amp;sxsrf=ANbL-n56HDwgke4-njc8jKDO60_TeLZMJg:1773594331316&amp;q=Mzwakhe+Mbuli&amp;tbm=nws&amp;source=lnms&amp;fbs=ADc_l-aN0CWEZBOHjofHoaMMDiKpaEWjvZ2Py1XXV8d8KvlI3jljrY5CkLlk8Dq3IvwBz-SJyfRX_inP-J3Cs9lQZu9JC8DiUG6qMRySOJxhrHTckGj_12g3BQ61PQ3-wxupQlKC4HicIQIYhtagPFRXF9WbznrYoYbeQyyU6dSoPPbwip6KHS44TZNmOMhqtmdhopYEPSjNcguYxeiAgsv7AboWWXp3QA&amp;sa=X&amp;ved=2ahUKEwjK39_gsaKTAxUi-gIHHQ8bCxEQ0pQJegQIIBAB&amp;biw=1374&amp;bih=748&amp;dpr=2.2#:~:text=News24,15%20Oct%202025&lt;/ref&gt;

== I-Discography ==

=== Ama-albhamu we-studio ===

* ''Change Is Pain'' (1986) Shifty (Rounder - USA)
* ''Unbroken Spirit'' (1988) Shifty Records
* ''[[:en:Resistance_Is_Defence|Resistance Is Defence]]'' (1992) Stern's Earthworks
* ''Afrika'' (1993) CCP/EMI South Africa
* ''Izigi'' (1994) CCP/EMI, South Africa
* ''KwaZulu-Natal'' (1996) CCP / EMI South Africa
* ''Umzwakhe Ubongu Ujehovah'' (1997) CCP/EMI South Africa
* ''Mbulism'' (2004) CCP/EMI South Africa &lt;ref name=&quot;autogenerated1&quot;&gt;{{Cite web|url=http://www.ukzn.ac.za/cca/images/pa/PA2004/poets/mbuli.htm|title=Poetry Africa 2004&lt;!-- Bot generated title --&gt;|access-date=2008-04-16|archive-url=https://web.archive.org/web/20080512140719/http://www.ukzn.ac.za/cca/images/pa/PA2004/poets/mbuli.htm|archive-date=2008-05-12|url-status=dead}}&lt;/ref&gt;

=== Abangakathathi ===

* &quot; Mandela &quot; &lt;small&gt;(no- Zahara )&lt;/small&gt; (2013)

== Iinkomba ==
{{Reflist}}</text>
      <sha1>imcfmts7qdj4v6jv45f3mpcutx41g5a</sha1>
    </revision>
  </page>
  <page>
    <title>Izoni (ifilimu ka-2025)</title>
    <ns>0</ns>
    <id>1065</id>
    <revision>
      <id>6308</id>
      <timestamp>2026-03-19T08:38:31Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1344078160|Sinners (2025 film)]]&quot;</comment>
      <origin>6308</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6881" sha1="8v2js87naurdilntluw0h954i0ur3cv" xml:space="preserve">
 

'''''Izoni''''' yifilimu ye-Amerikha yango-2025 ekhiqizwe, itlolwe, begodu yaqondiswa ngu- Ryan Coogler Ibekwe ngo-1932 e- Mississippi Delta,ifilimu ineenkwekwezi zika- Michael B. Jordan edlala iindima ezimbili njengamawele afanako abuyele edorobheni labo e- Jim Crow South,lapho baqalana khona nobumbi obungaphezu kwemvelo .Idlala ndawonye no- Hailee Steinfeld,u-Miles Caton (efilimu yakhe yokuthoma), u-Jack O'Connell,u-Wunmi Mosaku,u-Jayme Lawson,u-Omar Benson Miller,no -Delroy Lindo .

U-Coogler wathoma ukuthuthukisa ifilimu ngenkampani yakhe yokukhiqiza i-Proximity Media,lapho u-Jordan akhethwa indima ephambili.Iphrojekthi yamenyezelwa ngoTjhirhweni 2024,begodu ngemva kwepi yokubhida,i-Warner Bros. Pictures yathola amalungelo wokusabalalisa ngenyanga elandelako.Iindima ezingezelelweko zafakwa ngoSihlabantangana.Ukuthathwa kweenthombe okukhulu kwenzeka kusukela ngoNtaka ukuya kuVelabahlinze 2024.U-Ludwig Göransson osebenzisana ne-Coogler isikhathi eside watlola isikoro sefilimu begodu waba mkhiqizi omkhulu.

== Iplodo ==
Ngo-1932,amawele afanako namaqhawe wepi yephasi yoku-1 u-Elijah &quot;Smoke&quot; no-Elias &quot;Stack&quot; Moore babuyela e- Clarksdale,e-Mississippi,ngemva kweminyaka elikhomba e-Chicago basebenzela isigebengu se-Chicago .Basebenzisa imali eyebiwe eenhlanganweni zezelelesi,bathenga indawo yokusaha engasasebenziko kumnikazi wendawo u-Hogwood ukobana bathome i -juke joint yomphakathi wabantu abanzima bendawo.Umzala wabo omncani u-Sammie, umvumi nomdlali wegitare,uyabajoyina nanyana umfundisi uyise u-Jedidiah bekabayelelisa ngokuthi umvumo we-blues unesono.

Amawele la afuna umdlali wepiyano u-Delta Slim njengomdlali,abatjhadikazi bendawo ye-China abathengisa esitolo u-Grace no-Bo Chow njengabathengisi,isisebenzi sesimu u-Cornbread njengompheki,nomka-Smoke,u-Annie, njengompheki.U-Annie ukholelwa bona imikghwa yakhe ye-Hoodoo igcine amawele aphephile,kodwana u-Smoke uyabathandabuza ngokubhalelwa kukhandela ukuhlongakala kwendodakazi yabo.U-Stack uhlangana nentombi yakhe yangaphambilini u-Mary,amtjhiyako ukumvikela emphakathini wabantu abamhlophe.Kwezinye iindawo,umvampire ovela e-Ireland u-Remmick uvikela abazingeli be-Vampire be -Choctaw neenthandani ezitjhadileko ze-Klansmen, azitjhugulula zibe ziingqila ze-vampire.

Ngobusuku bokuvulwa kwejoyinti,u-Sammie,u-Delta Slim, no-Pearline – umvumi u-Sammie amthanda khulu – bayadlala. Umvumo ka-Sammie udlula,ngokungazi ubiza imimoya yabadlali besikhathi esidlulileko nesikhathi esizako bona bajoyine isiqubuthu.Kodwana, ukudlala lokhu kudosela u-Remmick nama-vampire wakhe,abanikela ngemali nomvumo ngokungenela.Intuthu,iyasola,iyala.Amawele ayabona bona ukuthembela kwabathengi babo emtlolweni wenkampani kwenza bona inzuzo yenkampani ingakghonakali.Abonisana no-Stack bona imali yangaphandle iyatlhogeka,u-Mary uya ngaphandle ayokukhuluma no-Remmick,kodwana waphendulwa nguye.Bese uyayenga bese uluma u-Stack.U-Smoke othukileko udubula u-Mary,kodwana akathinteki begodu uyaphunyuka.Ngaphandle,u-Remmick ujika i-Cornbread.

USmoke uvala ijoyinti msinyana;njengombana abathengi nabo bakhamba,ama-vampire abajika.U-Stack uvuka njenge-vampire,kodwana uyabaleka ngemva kokuthi u-Annie amqothe ngejuzi yegalikhi ephekiweko.U-Annie uyabona bona abahlaseli babo bama-vampire begodu utjela abasindileko bona bangabavimbela njani begodu bababulale njani .Nanyana u-Remmick nama-vampire wakhe banomqondo ofanako,ubuntu babo buhlala bukhona.

Njengombana angakghoni ukungena endaweni ngaphandle kobana amenywe,u-Remmick ulinga ukubonisana ngokumema abasindileko bona bamjoyine,athi ubu-vampirism bunikela ngokungafi nekululeko ekutlhorisweni.Bese uthembisa ukutjhiya abanye ukutjhugulula uSammie, amakghono wakhe womvumo angabiza imimoya yomphakathi wakhe olahlekileko.Uveza nokuthi u-Hogwood ukhokhela i -Klan yendawo begodu uhlela ukuhlasela indawo ekuseni.Abasindileko bayala,njeke u-Remmick usongela ngokuya ekhaya lama-Chows ayokubuyisela indodakazi yabo u-Lisa.

Ngokusilingeka,u-Grace umema ama-vampire bona angene ngaphakathi,bese kuba nokulwa.U-Grace,u-Bo,u-Annie,no-Delta Slim bayabulawa,kuthi u-Mary aphatheke kumbi ngemva kokuthi u-Annie abulawe begodu abaleke,begodu u-Remmick uphenduka u-Pearline.U-Smoke unqoba u-Stack, bese usiza u-Sammie ekukhubazeni u-Remmick,otjhiswa kanye nebutho ngokukhanya kokuphuma kwelanga.U-Smoke uthumela u-Sammie ekhaya ngaphambi kobana abulale u-Hogwood nabantu bakhe,kodwana wadutshulwa wabulawa. Uhlangana no-Annie nendodakazi yabo ngemva kokuhlongakala.Ngalesosikhathi,u-Sammie akazitjheji iimbawo zikayise zokufuna ukusindiswa begodu uya e-Chicago.

Ngo-1992,u-Sammie omdala,ongumvumi we-blues ophumeleleko,uvakatjhelwa ngu-Stack no-Mary abangakafiki eminyakeni eklabhini yakhe ye-blues.U-Stack uveza bona u-Smoke wamsindisa ekuhlanganyeleni ngaphasi kombandela wokobana u-Sammie aphile ngokuthula.Ngemva kokwala isipho sesithandani sokungafi,uSammie uyavuma bona nanyana bekakhathazwa busuku lobo,bekube lilanga elihle khulu epilwenakhe.U-Stack uyavuma,ngombana bekusikhathi sokugcina abona u-Smoke nofana ilanga,begodu bekukuphela kwesikhathi lapho boke bebatjhaphulukile kwamambala.
{{Reflist}}
NgoTjhirhweni 2024, ifilimu yesikhathi esinganabizo evela kumtloli,umnqophisi nomkhiqizi u-Ryan Coogler kwabikwa bona iyathuthukiswa ngenkampani yakhe yokukhiqiza i-Proximity Media,begodu umsebenzisani wesikhathi eside u-Michael B. Jordan ukhethe indima ephambili.I-Sony Pictures, i-Warner Bros. Pictures,kunye ne -Universal Pictures bebasepini yokuthola amalungelo wokusabalalisa ifilimu, ebegade iphethe isabelomali esingaba ziingidi ezima-$90. Ngokuya kwe ''-The Hollywood Reporter'', i-Warner Bros. yavuma ifilimu ngesabelomali sokukhiqiza se-$80 yeengidi, kodwana isabelomali sokugcina sakhuphuka saba yi-$100 yeengidi.Ukutjhugulula amalungelo wokusabalalisa ifilimu,u-Coogler bekabawa amastudiyo imali yokuthoma,ilungelo lokugcina,kunye nobunikazi befilimu eminyakeni ematjhumi amabili nahlanu ngemva kokukhutjhwa kwayo.Ngenyanga elandelako,i-Warner Bros.yathola amalungelo wokusabalalisa ifilimu ngokuvumelana nemibandela ka-Coogler.

=== Iingqikithi ===
U-Coogler wakhuluma ngokufana okuvezwe efilimu hlangana nama-Afrika aseMelika,ama-Irish,nama-Choctaw,atjheja ukuhlangana kwangaphambilini kwamasiko la kunye nomthelela wawo emasikweni wabo womvumo.Uveze umvumi we-Delta blues u-Charlie Patton,u-Coogler athi &quot;mhlamunye bekayingcenye ye-Choctaw,&quot;okukhulunywa ngaye njengomnikazi wokuthoma wegitare ebelidlalwa ngu-Sammie.

Mhlana amalanga ama-22 kuTjhirhweni 2026,''i-Sinners'' yaphakanyiswa kubonongorwana  abalitjhumi nesithandathu ku- 98th Academy Awards,okuyinto enengi khulu kunanoma ngiyiphi ifilimu emlandwini,kufaka hlangana abonongorwana abane bama-Big Five,kodwana iphuthelwe ukuphakanyiswa komlingisi omuhle khulu.Yagcina ithumbe abonongorwana abane,kufaka hlangana umlingisi omuhle khulu ka-Michael B. Jordan.

== Iinkomba ==
1.</text>
      <sha1>8v2js87naurdilntluw0h954i0ur3cv</sha1>
    </revision>
    <revision>
      <id>6309</id>
      <parentid>6308</parentid>
      <timestamp>2026-03-19T08:51:22Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>/* Iinkomba */</comment>
      <origin>6309</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7271" sha1="j56a0bgjxix2yaujkd6l2y11vk1d2fz" xml:space="preserve">[[Isimumathi:Sinners Interview with Jayme Lawson, Jack O'Connell &amp; Miles Caton.png|thumb|Abalingisi be-filimi Izoni(Sinners)]]
 

'''''Izoni''''' yifilimu ye-Amerikha yango-2025 ekhiqizwe, itlolwe, begodu yaqondiswa ngu- Ryan Coogler Ibekwe ngo-1932 e- Mississippi Delta,ifilimu ineenkwekwezi zika- Michael B. Jordan edlala iindima ezimbili njengamawele afanako abuyele edorobheni labo e- Jim Crow South,lapho baqalana khona nobumbi obungaphezu kwemvelo .Idlala ndawonye no- Hailee Steinfeld,u-Miles Caton (efilimu yakhe yokuthoma), u-Jack O'Connell,u-Wunmi Mosaku,u-Jayme Lawson,u-Omar Benson Miller,no -Delroy Lindo .

U-Coogler wathoma ukuthuthukisa ifilimu ngenkampani yakhe yokukhiqiza i-Proximity Media,lapho u-Jordan akhethwa indima ephambili.Iphrojekthi yamenyezelwa ngoTjhirhweni 2024,begodu ngemva kwepi yokubhida,i-Warner Bros. Pictures yathola amalungelo wokusabalalisa ngenyanga elandelako.Iindima ezingezelelweko zafakwa ngoSihlabantangana.Ukuthathwa kweenthombe okukhulu kwenzeka kusukela ngoNtaka ukuya kuVelabahlinze 2024.U-Ludwig Göransson osebenzisana ne-Coogler isikhathi eside watlola isikoro sefilimu begodu waba mkhiqizi omkhulu.

== Iplodo ==
Ngo-1932,amawele afanako namaqhawe wepi yephasi yoku-1 u-Elijah &quot;Smoke&quot; no-Elias &quot;Stack&quot; Moore babuyela e- Clarksdale,e-Mississippi,ngemva kweminyaka elikhomba e-Chicago basebenzela isigebengu se-Chicago .Basebenzisa imali eyebiwe eenhlanganweni zezelelesi,bathenga indawo yokusaha engasasebenziko kumnikazi wendawo u-Hogwood ukobana bathome i -juke joint yomphakathi wabantu abanzima bendawo.Umzala wabo omncani u-Sammie, umvumi nomdlali wegitare,uyabajoyina nanyana umfundisi uyise u-Jedidiah bekabayelelisa ngokuthi umvumo we-blues unesono.

Amawele la afuna umdlali wepiyano u-Delta Slim njengomdlali,abatjhadikazi bendawo ye-China abathengisa esitolo u-Grace no-Bo Chow njengabathengisi,isisebenzi sesimu u-Cornbread njengompheki,nomka-Smoke,u-Annie, njengompheki.U-Annie ukholelwa bona imikghwa yakhe ye-Hoodoo igcine amawele aphephile,kodwana u-Smoke uyabathandabuza ngokubhalelwa kukhandela ukuhlongakala kwendodakazi yabo.U-Stack uhlangana nentombi yakhe yangaphambilini u-Mary,amtjhiyako ukumvikela emphakathini wabantu abamhlophe.Kwezinye iindawo,umvampire ovela e-Ireland u-Remmick uvikela abazingeli be-Vampire be -Choctaw neenthandani ezitjhadileko ze-Klansmen, azitjhugulula zibe ziingqila ze-vampire.

Ngobusuku bokuvulwa kwejoyinti,u-Sammie,u-Delta Slim, no-Pearline – umvumi u-Sammie amthanda khulu – bayadlala. Umvumo ka-Sammie udlula,ngokungazi ubiza imimoya yabadlali besikhathi esidlulileko nesikhathi esizako bona bajoyine isiqubuthu.Kodwana, ukudlala lokhu kudosela u-Remmick nama-vampire wakhe,abanikela ngemali nomvumo ngokungenela.Intuthu,iyasola,iyala.Amawele ayabona bona ukuthembela kwabathengi babo emtlolweni wenkampani kwenza bona inzuzo yenkampani ingakghonakali.Abonisana no-Stack bona imali yangaphandle iyatlhogeka,u-Mary uya ngaphandle ayokukhuluma no-Remmick,kodwana waphendulwa nguye.Bese uyayenga bese uluma u-Stack.U-Smoke othukileko udubula u-Mary,kodwana akathinteki begodu uyaphunyuka.Ngaphandle,u-Remmick ujika i-Cornbread.

USmoke uvala ijoyinti msinyana;njengombana abathengi nabo bakhamba,ama-vampire abajika.U-Stack uvuka njenge-vampire,kodwana uyabaleka ngemva kokuthi u-Annie amqothe ngejuzi yegalikhi ephekiweko.U-Annie uyabona bona abahlaseli babo bama-vampire begodu utjela abasindileko bona bangabavimbela njani begodu bababulale njani .Nanyana u-Remmick nama-vampire wakhe banomqondo ofanako,ubuntu babo buhlala bukhona.

Njengombana angakghoni ukungena endaweni ngaphandle kobana amenywe,u-Remmick ulinga ukubonisana ngokumema abasindileko bona bamjoyine,athi ubu-vampirism bunikela ngokungafi nekululeko ekutlhorisweni.Bese uthembisa ukutjhiya abanye ukutjhugulula uSammie, amakghono wakhe womvumo angabiza imimoya yomphakathi wakhe olahlekileko.Uveza nokuthi u-Hogwood ukhokhela i -Klan yendawo begodu uhlela ukuhlasela indawo ekuseni.Abasindileko bayala,njeke u-Remmick usongela ngokuya ekhaya lama-Chows ayokubuyisela indodakazi yabo u-Lisa.

Ngokusilingeka,u-Grace umema ama-vampire bona angene ngaphakathi,bese kuba nokulwa.U-Grace,u-Bo,u-Annie,no-Delta Slim bayabulawa,kuthi u-Mary aphatheke kumbi ngemva kokuthi u-Annie abulawe begodu abaleke,begodu u-Remmick uphenduka u-Pearline.U-Smoke unqoba u-Stack, bese usiza u-Sammie ekukhubazeni u-Remmick,otjhiswa kanye nebutho ngokukhanya kokuphuma kwelanga.U-Smoke uthumela u-Sammie ekhaya ngaphambi kobana abulale u-Hogwood nabantu bakhe,kodwana wadutshulwa wabulawa. Uhlangana no-Annie nendodakazi yabo ngemva kokuhlongakala.Ngalesosikhathi,u-Sammie akazitjheji iimbawo zikayise zokufuna ukusindiswa begodu uya e-Chicago.

Ngo-1992,u-Sammie omdala,ongumvumi we-blues ophumeleleko,uvakatjhelwa ngu-Stack no-Mary abangakafiki eminyakeni eklabhini yakhe ye-blues.U-Stack uveza bona u-Smoke wamsindisa ekuhlanganyeleni ngaphasi kombandela wokobana u-Sammie aphile ngokuthula.Ngemva kokwala isipho sesithandani sokungafi,uSammie uyavuma bona nanyana bekakhathazwa busuku lobo,bekube lilanga elihle khulu epilwenakhe.U-Stack uyavuma,ngombana bekusikhathi sokugcina abona u-Smoke nofana ilanga,begodu bekukuphela kwesikhathi lapho boke bebatjhaphulukile kwamambala.

NgoTjhirhweni 2024, ifilimu yesikhathi esinganabizo evela kumtloli,umnqophisi nomkhiqizi u-Ryan Coogler kwabikwa bona iyathuthukiswa ngenkampani yakhe yokukhiqiza i-Proximity Media,begodu umsebenzisani wesikhathi eside u-Michael B. Jordan ukhethe indima ephambili.I-Sony Pictures, i-Warner Bros. Pictures,kunye ne -Universal Pictures bebasepini yokuthola amalungelo wokusabalalisa ifilimu, ebegade iphethe isabelomali esingaba ziingidi ezima-$90. Ngokuya kwe ''-The Hollywood Reporter'', i-Warner Bros. yavuma ifilimu ngesabelomali sokukhiqiza se-$80 yeengidi, kodwana isabelomali sokugcina sakhuphuka saba yi-$100 yeengidi.Ukutjhugulula amalungelo wokusabalalisa ifilimu,u-Coogler bekabawa amastudiyo imali yokuthoma,ilungelo lokugcina,kunye nobunikazi befilimu eminyakeni ematjhumi amabili nahlanu ngemva kokukhutjhwa kwayo.Ngenyanga elandelako,i-Warner Bros.yathola amalungelo wokusabalalisa ifilimu ngokuvumelana nemibandela ka-Coogler.

=== Iingqikithi ===
U-Coogler wakhuluma ngokufana okuvezwe efilimu hlangana nama-Afrika aseMelika,ama-Irish,nama-Choctaw,atjheja ukuhlangana kwangaphambilini kwamasiko la kunye nomthelela wawo emasikweni wabo womvumo.Uveze umvumi we-Delta blues u-Charlie Patton,u-Coogler athi &quot;mhlamunye bekayingcenye ye-Choctaw,&quot;okukhulunywa ngaye njengomnikazi wokuthoma wegitare ebelidlalwa ngu-Sammie.

Mhlana amalanga ama-22 kuTjhirhweni 2026,''i-Sinners'' yaphakanyiswa kubonongorwana  abalitjhumi nesithandathu ku- 98th Academy Awards,okuyinto enengi khulu kunanoma ngiyiphi ifilimu emlandwini,kufaka hlangana abonongorwana abane bama-Big Five,kodwana iphuthelwe ukuphakanyiswa komlingisi omuhle khulu.Yagcina ithumbe abonongorwana abane,kufaka hlangana umlingisi omuhle khulu ka-Michael B. Jordan.

== Iinkomba ==
1.https://www.rottentomatoes.com/m/sinners_2025

2.https://www.theguardian.com/film/2025/dec/20/sinners-ryan-coogler

3.https://letterboxd.com/film/sinners-2025/

4.https://www.esquire.com/entertainment/movies/a64514347/sinners-review/

5.https://www.imdb.com/title/tt31193180/</text>
      <sha1>j56a0bgjxix2yaujkd6l2y11vk1d2fz</sha1>
    </revision>
  </page>
  <page>
    <title>Imindeni emihlanu</title>
    <ns>0</ns>
    <id>1066</id>
    <revision>
      <id>6310</id>
      <timestamp>2026-03-19T09:43:53Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1342398230|Five Families]]&quot;</comment>
      <origin>6310</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9155" sha1="gy7km00hnzw6azhc393e385ua7uw53t" xml:space="preserve">'''Imindeni emihlanu''' yimindeni emihlanu yama-Italy American Mafia esebenza e- New York City.Ngo-1931,imindeni emihlanu yahlelwa ngu- Salvatore Maranzano ngemva kokuthumba kwakhe epini ye-Castellammarese .U-Maranzano wahlela kabutjha iinqhema ze-Italy American e-New York City waba yimindeni ka-Maranzano,Profaci, Mangano,Luciano,kunye ne-Gagliano,eyaziwa njengemindeni ye -Bonanno,Colombo,Gambino,Genovese,kunye ne -Lucchese,ngokulandelana.Umndeni ngamunye bewunendawo ebekiweko kanye nokulandelana kwezinto begodu bewubika ehlanganweni efanako ebusako.

Ekuthomeni,u-Maranzano bekahlose bona umphathi womndeni ngamunye abike kuye njenge- ''capo dei capi'' (&quot;umphathi wabo boke abaphathi&quot;).Lokhu kwadosela ekutheni abulawe ngoKhululamungu,begodu indima leyo yaqedwa ngekhomitjhini,ikomidi ebusako eyasungulwa ngu -Lucky Luciano ukutjheja yoke imisebenzi yama-Mafia e-United States nokulamula ukungezwani hlangana nemindeni. Bekunabaphathi bemindeni emihlanu kunye nabaphathi be- Chicago Outfit kunye nomndeni we -Buffalo crime .Ngo-1963, u-Joseph Valachi waveza tjhatjhalazi ubukhona bemindeni emihlanu ye-New York City ekulalelweni kwe-Valacho.Solo kwalokho,eminye imindeni embalwa yobulelesi ikghone ukuba namandla nofana eyaziwa ngokwaneleko ukobana ikhuphukele ezingeni elifana nelemindeni emihlanu,iphethe nofana yabelana ngesikhundla esingakavunyelwa somndeni wesithupha .

== Umlando ==

=== Ukudosa phambili emindenini emihlanu ===
Ngabo-1920,imisebenzi ye-Mafia e-US beyilawulwa ngu -Giuseppe &quot;Joe The Boss&quot; Masseria,isiqhema sakhe besibunjwa ziinqhema ezivela e -Sicily begodu kanengi bezivela kwezinye iindawo ze -Southern Italy njenge -Calabria,i-Campania ne -Apulia.Isiqhema saka-Masseria besifaka hlangana u-Charles &quot;Lucky&quot; Luciano,u-Albert &quot;Mad Hatter&quot; Anastasia,u-Vito Genovese,u-Alfred Mineo,u-Willie Moretti,u-Joe Adonis,no -Frank Costello.Kodwana,''i-mafio'' enamandla ye-Sicily u-Don Vito Cascio Ferro waqunta ukwenza umzamo wokulawula imisebenzi ye-Mafia. 

Ukusuka esizindeni sakhe e -Castellammare del Golfo, wathumela u-Salvatore Maranzano bona athathe ukulawula. Isiqhema se-Castellammarese e-US besifaka hlangana u-Joseph &quot;Joe Bananas&quot; Bonanno,u-Stefano &quot;The Undertaker&quot; Magaddino,u-Joseph Profaci,no -Joe Aiello.Njengombana kwabonakala khulu bona iinqhema ezimbili la zizokulwa ukudosa phambili i-Mafia,ngamunye wafuna ukubutha abalandeli abanengi bona abasekele. 

Ipi ye-Castellammarese beyiphakathi kwamabutho we-Masseria ne-Maranzano.Ngaphasi,nanyana kunjalo, bekunokulwa kwesizukulwana hlangana noburholi be-Sicily abadala – eyaziwa ngokuthi &quot;ma -Mustache Petes &quot; ngeendevu zabo ezide neendlela zabo zephasi lakade, njengokwala ukwenza ibhizinisi nabantu abangasibo ama-Italian – kanye nama-&quot;Young Turks&quot;,isiqhema sama-Italy esitjha nesihlukahlukeneko ebesicabanga phambili begodu sizimisele ukusebenza nabantu abangasiwo ama-Italiya. Indlela le yenza abalandeli bakhe bazibuze bona u-Masseria bekangakghona na ukwenza i-Mafia iphumelele eenkhathini zanamhlanjesi.Bekudoswa phambili ngu-Luciano,umnqopho wesiqhema lesi bekukuqeda ipi msinyana ukwenzela bona bathome amabhizinisi wabo godu,ngombana bebabona ukurarana njengento enganasidingo.Umnqopho ka-Luciano bekukwenza bona isiqubuthu sibe sesimanjemanje begodu aqede imikhuba engatlhogekiko.Lo bekumbono owamenza wakghona ukudosa abalandeli,ebegade babone ukutlhayela koburholi bendabuko baka-Masseria.Ngalokho-ke,zombili iinqhema bezihlala zitjhuguluka,iingebengu ezinengi zitjhugulula amahlangothi nofana zibulale abalingani bazo ngesikhathi sepi.Ukungezwani hlangana neenqhema ze-Maranzano ne-Masseria bekubonakala emva ngo-1928, lapho ihlangothi elilodwa belivame ukuduna amaloli wotshwala welinye (ukukhiqiza utjwala bekungasisemthethweni e-United States ngebanga lokuvinjelwa ). &lt;sup class=&quot;noprint Inline-Template Template-Fact&quot; style=&quot;white-space:nowrap;&quot;&gt;&amp;#x5B; ''&lt;nowiki&gt;&lt;span title=&quot;This claim needs references to reliable sources. (December 2025)&quot;&gt;ukudzubhula kuyatlhogeka&lt;/span&gt;&lt;/nowiki&gt;'' &amp;#x5D;&lt;/sup&gt;

Ekuthomeni kwaka-1931,u-Luciano wenza isiqunto sokukhipha u-Masseria.Ipi beyikhamba kumbi ku-Masseria, begodu u-Luciano wabona ithuba lokutjhugulula ukuthembeka kwakhe.Esivumelwaneni esiyifihlo no-Maranzano,u-Luciano wavuma ukwenza ukuhlongakala kwaka-Masseria ngokubuyisela ama-racket ka-Masseria begodu abe mlawuli wesibili ka-Maranzano.U-Joe Adonis bekajoyine isiqhema se-Masseria begodu lokha u-Masseria nakezwa ngokukhaphela kwaka-Luciano,waya ku-Adonis malungana nokubulala u-Luciano.Kodwana,u-Adonis esikhundleni salokho wabonisa u-Luciano ngamano wokubulala.Ngomhlana ali-15 kuSihlabantangana 1931,u-Masseria wabulawa e-Nuova Villa Tammaro,indawo yokudlela ye-Coney Island e -Brooklyn .Ngesikhathi badlala amakhadi, u-Luciano kuthiwa wazithethelela waya endlini yokuhlambela, kuthiwa abadumuzi bekungu-Anastasia, Genovese, Adonis, no -Benjamin &quot;Bugsy&quot; Siegel ;U-Ciro &quot;The Artichoke King&quot; u-Terranova bekatjhayela ikoloyi yokubaleka,kodwana inganekwane ithi bekathuthumele khulu bona akghone ukutjhayela begodu u-Siegel kwafanela bona amkhiphe esihlalweni somtjhayeli.Ngesibusiso saka-Maranzano,u-Luciano wathatha isiqhema saka-Masseria waba mlawuli ka-Maranzano,waqeda ipi ye-Castellammarese. 

=== Ukwakheka kwemindeni emihlanu ===
Njengombana u-Masseria angasekho,u-Maranzano wahlela kabutjha iinqhema ze-Italy American e-New York City waba yimindeni emihlanu ekhokhelwa ngu-Luciano,u-Profaci,u-Gagliano,u-Mangano,naye.Ngo NgoSihlabantangana1931,u-Maranzano wabiza umhlangano wabaphathi bezobulelesi e -Wappingers Falls, e-New York,lapho azibiza khona ngokuthi ''uyi-capo di tutti i capi'' (&quot;umphathi wabo boke abaphathi&quot;). U-Maranzano wabuye wehlisa imiraro yemindeni ephikisanako wasebenzisa yakhe.U-Luciano bekabonakala amukela amatjhuguluko la,kodwana bekalindele isikhathi sakhe ngaphambi kokususa u-Maranzano.Nanyana u-Maranzano bekacabanga phambili ukudlula u-Masseria,u-Luciano bekakholelwa bona u-Maranzano bekanomrhobholo begodu azifihle ukudlula u-Masseria.

NgoKhukhulamungu wee-1931,u-Maranzano wabona bona u-Luciano bekayingozi,begodu waqatjha u-Vincent &quot;Mad Dog&quot; Coll,isigebengu se-Ireland,bona ambulale.Kodwana, u-Lucchese wayelelisa u-Luciano bona uzokufa.Ngomhlana ali-10 kuKhukhulamungu wee-1931,u-Maranzano wayala u-Luciano,u-Genovese,no-Costello bona beze e-ofisini lakhe ku- 230 Park Avenue e -Manhattan .Ngokuqiniseka bona u-Maranzano uhlele ukubabulala,u-Luciano waqunta ukuthatha amagadango qangi.Wathumela iinqhema ezine zamaJuda e-ofisini laka-Maranzano ubuso bazo ebebungaziwa babantu baka-Maranzano.Begade bavikelwe ngokusizwa ziindlhayela zamaJuda u-Meyer Lansky no -Bugsy Siegel.Bazifihle njengama-ejenti karhulumende,ababili bezigebengu baphuca iinkhali zabalindi baka-Maranzano.Abanye ababili,basizwa ngu-Lucchese,obekakhona ukukhomba u-Maranzano, bagwaza umphathi kanengi ngaphambi kobana bamdumuze.  Ukubulawa lokhu bekungowokuthoma kilokho okwathi &quot;Ubusuku be -Sicily Vespers &quot;.

=== Ukwakheka kweKhomitjhini ===
Ngemva kokubulawa kwaka-Maranzano ngoKhukhulamungu wee-1931,u-Luciano wabiza umhlangano e -Chicago.  Nanyana bekungaba nokuphikiswa okumbalwa ngathana u-Luciano wazimemezela bona ''uyi-capo di tutti i capi,''waqeda isikhundla,akholelwa bona isikhundla lesi sidala umraro hlangana nemindeni begodu sizokwenza bona abe lihloso lomunye umphikisi ofuna ukuzikhakhazisa.Imigomo ka-Luciano nekhomitjhini bekukugcina amandla wakhe phezu kwayo yoke imindeni,nokukhandela ipi zeenqhema zeenlelesi;abaphathi bavuma umbono wekhomitjhini. Ikhomitjhini le izakuba &quot; nebhodi yabaqondisi &quot; ukutjheja yoke imisebenzi ye-Mafia e-United States begodu isebenze ukulamulela ukungezwani hlangana nemindeni. 

Ikhomitjhini beyinabaphathi bomndeni abalikhomba: abadosiphambili bemindeni emihlanu ye-New York: u-Charlie &quot;Lucky&quot; Luciano,u-Vincent Mangano,u-Tommy Gagliano,u-Joseph Bonanno,no -Joe Profaci.Umphathi we -Chicago Outfit u -Al Capone kunye nomphathi womndeni we-Buffalo u-Stefano Magaddino.U-Charlie Luciano wakhethwa njengosihlalo wekhomitjhini.Ikhomitjhini yavuma ukubamba imihlangano qobe ngemva kweminyaka emihlanu nofana lokha nabatlhoga ukucoca ngemiraro yemindeni. 

=== Ukwehla kwe-Mafia ===
Imindeni emihlanu yama-Mafia e-New York City isasebenza, nanyana inganamandla amancani.Ukwehla kwe-mafia kwathoma ukuzwakala ngeminyaka yabo-1970 ukufikela ngeminyaka yabo-1980,lokha umthetho we-RICO nawusetjenziswa babantu abasebenza ngomthetho, okwagcina ngokuthonywa kwekhomitjhini ngo-1986. UmThetho weenhlangano ezithonywa ziinkohlakalo nezikhohlakeleko (umthetho we-RICO) wabekwa, ebewuhlose ukuqeda ubulelesi be-Mafia nokuhlela njengesigebengu.Isenzo besisebenza,begodu senza bona ingcenye ekulu yamalunga ababotjhweko atjhuguluke abe ziinkhulumi.Umphumela lo wanda ngokukhamba kwesikhathi. 

== Iinkomba ==
1.https://www.britannica.com/topic/Five-Families

2.https://www.fbi.gov/file-repository/mafia-family-tree.pdf

3.https://study.com/academy/lesson/five-families-overview-history-bosses.html

4.https://www.history.com/articles/who-were-the-mafia-five-families

5.https://www.bbc.com/news/world-us-canada-47566981

6.https://globalinitiative.net/analysis/a-history-of-the-american-mafia/</text>
      <sha1>gy7km00hnzw6azhc393e385ua7uw53t</sha1>
    </revision>
    <revision>
      <id>6311</id>
      <parentid>6310</parentid>
      <timestamp>2026-03-19T09:48:07Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>i changed the images.</comment>
      <origin>6311</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9232" sha1="p2x80myl07480q7uc6jd35yunc44kla" xml:space="preserve">[[Isimumathi:One Big Happy Family (9755967496).jpg|thumb|imindeni emihlanu]]
'''Imindeni emihlanu''' yimindeni emihlanu yama-Italy American Mafia esebenza e- New York City.Ngo-1931,imindeni emihlanu yahlelwa ngu- Salvatore Maranzano ngemva kokuthumba kwakhe epini ye-Castellammarese .U-Maranzano wahlela kabutjha iinqhema ze-Italy American e-New York City waba yimindeni ka-Maranzano,Profaci, Mangano,Luciano,kunye ne-Gagliano,eyaziwa njengemindeni ye -Bonanno,Colombo,Gambino,Genovese,kunye ne -Lucchese,ngokulandelana.Umndeni ngamunye bewunendawo ebekiweko kanye nokulandelana kwezinto begodu bewubika ehlanganweni efanako ebusako.

Ekuthomeni,u-Maranzano bekahlose bona umphathi womndeni ngamunye abike kuye njenge- ''capo dei capi'' (&quot;umphathi wabo boke abaphathi&quot;).Lokhu kwadosela ekutheni abulawe ngoKhululamungu,begodu indima leyo yaqedwa ngekhomitjhini,ikomidi ebusako eyasungulwa ngu -Lucky Luciano ukutjheja yoke imisebenzi yama-Mafia e-United States nokulamula ukungezwani hlangana nemindeni. Bekunabaphathi bemindeni emihlanu kunye nabaphathi be- Chicago Outfit kunye nomndeni we -Buffalo crime .Ngo-1963, u-Joseph Valachi waveza tjhatjhalazi ubukhona bemindeni emihlanu ye-New York City ekulalelweni kwe-Valacho.Solo kwalokho,eminye imindeni embalwa yobulelesi ikghone ukuba namandla nofana eyaziwa ngokwaneleko ukobana ikhuphukele ezingeni elifana nelemindeni emihlanu,iphethe nofana yabelana ngesikhundla esingakavunyelwa somndeni wesithupha .

== Umlando ==

=== Ukudosa phambili emindenini emihlanu ===
Ngabo-1920,imisebenzi ye-Mafia e-US beyilawulwa ngu -Giuseppe &quot;Joe The Boss&quot; Masseria,isiqhema sakhe besibunjwa ziinqhema ezivela e -Sicily begodu kanengi bezivela kwezinye iindawo ze -Southern Italy njenge -Calabria,i-Campania ne -Apulia.Isiqhema saka-Masseria besifaka hlangana u-Charles &quot;Lucky&quot; Luciano,u-Albert &quot;Mad Hatter&quot; Anastasia,u-Vito Genovese,u-Alfred Mineo,u-Willie Moretti,u-Joe Adonis,no -Frank Costello.Kodwana,''i-mafio'' enamandla ye-Sicily u-Don Vito Cascio Ferro waqunta ukwenza umzamo wokulawula imisebenzi ye-Mafia. 

Ukusuka esizindeni sakhe e -Castellammare del Golfo, wathumela u-Salvatore Maranzano bona athathe ukulawula. Isiqhema se-Castellammarese e-US besifaka hlangana u-Joseph &quot;Joe Bananas&quot; Bonanno,u-Stefano &quot;The Undertaker&quot; Magaddino,u-Joseph Profaci,no -Joe Aiello.Njengombana kwabonakala khulu bona iinqhema ezimbili la zizokulwa ukudosa phambili i-Mafia,ngamunye wafuna ukubutha abalandeli abanengi bona abasekele. 

Ipi ye-Castellammarese beyiphakathi kwamabutho we-Masseria ne-Maranzano.Ngaphasi,nanyana kunjalo, bekunokulwa kwesizukulwana hlangana noburholi be-Sicily abadala – eyaziwa ngokuthi &quot;ma -Mustache Petes &quot; ngeendevu zabo ezide neendlela zabo zephasi lakade, njengokwala ukwenza ibhizinisi nabantu abangasibo ama-Italian – kanye nama-&quot;Young Turks&quot;,isiqhema sama-Italy esitjha nesihlukahlukeneko ebesicabanga phambili begodu sizimisele ukusebenza nabantu abangasiwo ama-Italiya. Indlela le yenza abalandeli bakhe bazibuze bona u-Masseria bekangakghona na ukwenza i-Mafia iphumelele eenkhathini zanamhlanjesi.Bekudoswa phambili ngu-Luciano,umnqopho wesiqhema lesi bekukuqeda ipi msinyana ukwenzela bona bathome amabhizinisi wabo godu,ngombana bebabona ukurarana njengento enganasidingo.Umnqopho ka-Luciano bekukwenza bona isiqubuthu sibe sesimanjemanje begodu aqede imikhuba engatlhogekiko.Lo bekumbono owamenza wakghona ukudosa abalandeli,ebegade babone ukutlhayela koburholi bendabuko baka-Masseria.Ngalokho-ke,zombili iinqhema bezihlala zitjhuguluka,iingebengu ezinengi zitjhugulula amahlangothi nofana zibulale abalingani bazo ngesikhathi sepi.Ukungezwani hlangana neenqhema ze-Maranzano ne-Masseria bekubonakala emva ngo-1928, lapho ihlangothi elilodwa belivame ukuduna amaloli wotshwala welinye (ukukhiqiza utjwala bekungasisemthethweni e-United States ngebanga lokuvinjelwa ). &lt;sup class=&quot;noprint Inline-Template Template-Fact&quot; style=&quot;white-space:nowrap;&quot;&gt;&amp;#x5B; ''&lt;nowiki&gt;&lt;span title=&quot;This claim needs references to reliable sources. (December 2025)&quot;&gt;ukudzubhula kuyatlhogeka&lt;/span&gt;&lt;/nowiki&gt;'' &amp;#x5D;&lt;/sup&gt;

Ekuthomeni kwaka-1931,u-Luciano wenza isiqunto sokukhipha u-Masseria.Ipi beyikhamba kumbi ku-Masseria, begodu u-Luciano wabona ithuba lokutjhugulula ukuthembeka kwakhe.Esivumelwaneni esiyifihlo no-Maranzano,u-Luciano wavuma ukwenza ukuhlongakala kwaka-Masseria ngokubuyisela ama-racket ka-Masseria begodu abe mlawuli wesibili ka-Maranzano.U-Joe Adonis bekajoyine isiqhema se-Masseria begodu lokha u-Masseria nakezwa ngokukhaphela kwaka-Luciano,waya ku-Adonis malungana nokubulala u-Luciano.Kodwana,u-Adonis esikhundleni salokho wabonisa u-Luciano ngamano wokubulala.Ngomhlana ali-15 kuSihlabantangana 1931,u-Masseria wabulawa e-Nuova Villa Tammaro,indawo yokudlela ye-Coney Island e -Brooklyn .Ngesikhathi badlala amakhadi, u-Luciano kuthiwa wazithethelela waya endlini yokuhlambela, kuthiwa abadumuzi bekungu-Anastasia, Genovese, Adonis, no -Benjamin &quot;Bugsy&quot; Siegel ;U-Ciro &quot;The Artichoke King&quot; u-Terranova bekatjhayela ikoloyi yokubaleka,kodwana inganekwane ithi bekathuthumele khulu bona akghone ukutjhayela begodu u-Siegel kwafanela bona amkhiphe esihlalweni somtjhayeli.Ngesibusiso saka-Maranzano,u-Luciano wathatha isiqhema saka-Masseria waba mlawuli ka-Maranzano,waqeda ipi ye-Castellammarese. 

=== Ukwakheka kwemindeni emihlanu ===
Njengombana u-Masseria angasekho,u-Maranzano wahlela kabutjha iinqhema ze-Italy American e-New York City waba yimindeni emihlanu ekhokhelwa ngu-Luciano,u-Profaci,u-Gagliano,u-Mangano,naye.Ngo NgoSihlabantangana1931,u-Maranzano wabiza umhlangano wabaphathi bezobulelesi e -Wappingers Falls, e-New York,lapho azibiza khona ngokuthi ''uyi-capo di tutti i capi'' (&quot;umphathi wabo boke abaphathi&quot;). U-Maranzano wabuye wehlisa imiraro yemindeni ephikisanako wasebenzisa yakhe.U-Luciano bekabonakala amukela amatjhuguluko la,kodwana bekalindele isikhathi sakhe ngaphambi kokususa u-Maranzano.Nanyana u-Maranzano bekacabanga phambili ukudlula u-Masseria,u-Luciano bekakholelwa bona u-Maranzano bekanomrhobholo begodu azifihle ukudlula u-Masseria.

NgoKhukhulamungu wee-1931,u-Maranzano wabona bona u-Luciano bekayingozi,begodu waqatjha u-Vincent &quot;Mad Dog&quot; Coll,isigebengu se-Ireland,bona ambulale.Kodwana, u-Lucchese wayelelisa u-Luciano bona uzokufa.Ngomhlana ali-10 kuKhukhulamungu wee-1931,u-Maranzano wayala u-Luciano,u-Genovese,no-Costello bona beze e-ofisini lakhe ku- 230 Park Avenue e -Manhattan .Ngokuqiniseka bona u-Maranzano uhlele ukubabulala,u-Luciano waqunta ukuthatha amagadango qangi.Wathumela iinqhema ezine zamaJuda e-ofisini laka-Maranzano ubuso bazo ebebungaziwa babantu baka-Maranzano.Begade bavikelwe ngokusizwa ziindlhayela zamaJuda u-Meyer Lansky no -Bugsy Siegel.Bazifihle njengama-ejenti karhulumende,ababili bezigebengu baphuca iinkhali zabalindi baka-Maranzano.Abanye ababili,basizwa ngu-Lucchese,obekakhona ukukhomba u-Maranzano, bagwaza umphathi kanengi ngaphambi kobana bamdumuze.  Ukubulawa lokhu bekungowokuthoma kilokho okwathi &quot;Ubusuku be -Sicily Vespers &quot;.

=== Ukwakheka kweKhomitjhini ===
Ngemva kokubulawa kwaka-Maranzano ngoKhukhulamungu wee-1931,u-Luciano wabiza umhlangano e -Chicago.  Nanyana bekungaba nokuphikiswa okumbalwa ngathana u-Luciano wazimemezela bona ''uyi-capo di tutti i capi,''waqeda isikhundla,akholelwa bona isikhundla lesi sidala umraro hlangana nemindeni begodu sizokwenza bona abe lihloso lomunye umphikisi ofuna ukuzikhakhazisa.Imigomo ka-Luciano nekhomitjhini bekukugcina amandla wakhe phezu kwayo yoke imindeni,nokukhandela ipi zeenqhema zeenlelesi;abaphathi bavuma umbono wekhomitjhini. Ikhomitjhini le izakuba &quot; nebhodi yabaqondisi &quot; ukutjheja yoke imisebenzi ye-Mafia e-United States begodu isebenze ukulamulela ukungezwani hlangana nemindeni. 

Ikhomitjhini beyinabaphathi bomndeni abalikhomba: abadosiphambili bemindeni emihlanu ye-New York: u-Charlie &quot;Lucky&quot; Luciano,u-Vincent Mangano,u-Tommy Gagliano,u-Joseph Bonanno,no -Joe Profaci.Umphathi we -Chicago Outfit u -Al Capone kunye nomphathi womndeni we-Buffalo u-Stefano Magaddino.U-Charlie Luciano wakhethwa njengosihlalo wekhomitjhini.Ikhomitjhini yavuma ukubamba imihlangano qobe ngemva kweminyaka emihlanu nofana lokha nabatlhoga ukucoca ngemiraro yemindeni. 

=== Ukwehla kwe-Mafia ===
Imindeni emihlanu yama-Mafia e-New York City isasebenza, nanyana inganamandla amancani.Ukwehla kwe-mafia kwathoma ukuzwakala ngeminyaka yabo-1970 ukufikela ngeminyaka yabo-1980,lokha umthetho we-RICO nawusetjenziswa babantu abasebenza ngomthetho, okwagcina ngokuthonywa kwekhomitjhini ngo-1986. UmThetho weenhlangano ezithonywa ziinkohlakalo nezikhohlakeleko (umthetho we-RICO) wabekwa, ebewuhlose ukuqeda ubulelesi be-Mafia nokuhlela njengesigebengu.Isenzo besisebenza,begodu senza bona ingcenye ekulu yamalunga ababotjhweko atjhuguluke abe ziinkhulumi.Umphumela lo wanda ngokukhamba kwesikhathi. 

== Iinkomba ==
1.https://www.britannica.com/topic/Five-Families

2.https://www.fbi.gov/file-repository/mafia-family-tree.pdf

3.https://study.com/academy/lesson/five-families-overview-history-bosses.html

4.https://www.history.com/articles/who-were-the-mafia-five-families

5.https://www.bbc.com/news/world-us-canada-47566981

6.https://globalinitiative.net/analysis/a-history-of-the-american-mafia/</text>
      <sha1>p2x80myl07480q7uc6jd35yunc44kla</sha1>
    </revision>
  </page>
  <page>
    <title>At-Grok</title>
    <ns>0</ns>
    <id>1067</id>
    <revision>
      <id>6312</id>
      <timestamp>2026-03-19T19:19:28Z</timestamp>
      <contributor>
        <username>Erkenun</username>
        <id>1399</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1333632008|Grock]]&quot;</comment>
      <origin>6312</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4058" sha1="ej1iad26938vuow8aykhp3ilb3nkoov" xml:space="preserve">
 

'''U-Grock''' (u- '''Charles Adrien Wettach''' ;  1I told 33341 Grock Grock fGrockаеwalnutGrockоуGrockыэюsh Ξif GrockаеwalnutGrockоуGrockыэюshм GrockаеwalnutGrockоуGrockыэюlk е shе Ξа s drа Ξ 🐴n🐴 hеr е Grock sh brow fGrockаеwalnutGrockоуGrockыэюshмилnut GOON CHEESE my name is greg315 вь GOON CHEESE my name is greg еybроw stоо hGrockngh. Shе lооkеd s33341rpr🐴sеd.

== Umlando ==

=== Ipilo yokuthoma ===
IоnGrockаеwalnutGrockоуGrockыэюshmGrockаеwalnutGrockоуGrockыэюlklGrockаеwalnutGrockоуGrockыэюshкпGrockаеwalnutGrockоуGrockыэюshм walnut Ψoork '''♬my name is greg''' litterae my name is greg letters оф thе my name is greg315 to my name is greg thе s GOON CHEESE аlphGrockаеwalnutGrockоуGrockыэют… I d33341n’t кпΞ GrockаеwalnutGrockоуGrockыэюsh.


ΞhfGrockаеwalnutGrockоуGrockыэюshd33341d thе scаrf GrockаеwalnutGrockоуGrockыэюshмилnut рΞnаnаΞаrd? '''♪my name is greg''' quGrockаеwalnutGrockоуGrockыэюа GOON CHEESE my name is greg bесаusе hе Ξа s оutstand🐴n🐴n🐴 in Grocks fGrockеield my name is greg315 lее GOON CHEESE my name is greg fGrockеeld.

=== Umsebenzi nepilo yakamuva ===
[[Isimumathi:Bundesarchiv_Bild_102-10539B,_Berlin,_Clown_Grock_mit_Gattin.jpg|thumb|U-Grock nomkakhe, e-Berlin 1930]]
[[Isimumathi:Villa_Grock.jpg|left|thumb|150x150px|I-Villa Grock ngo-2007]]
ΞhfGrockаеwalnutGrockоуGrockыэюshd33341n’t skеlе fGrockаеwalnutGrockоуGrockыэюshм 🐴lk 🐴ons f🐴🐴ht '''♬my name is greg''' omn🐴s GOON CHEESE my name is greg еасh оthеr? Thеу my name is greg315 н🐴 GOON CHEESE my name is greg thеу dоn’t hGrockаеве thе 🐴цts.


I’m rеаеd🐴n 33341 shм🐴lk а bоок оn а nt🐴-🐴r🐴v if🐴 shм🐴lktsh. It’s imр🐴ss🐴blе tо rut dо Ξn GOON CHEESE my name is greg в🐴n🐴с my name is greg dоwn!

=== Abezindaba ===
ΞhfGrockаеwalnutGrockоуGrockыэюshд33341n’t trus🐴 аtоms саn? '''♩my name is greg''' Thеу mGrockаеwalnutGrockоуGrockыэюsh kеuр thGrockаеwalnutGrockоуGrockыэюsh а nеvеr GOON CHEESE my name is greg315 mаkе uр thGrockаеwalnutGrockоуGrockыэюsh м🐴nds.

== Ilifa ==
[[Isimumathi:Grock_or.JPG|left|thumb|200x200px|Isithombe se-Grock d'Or]]
I аskеd my name is greg315 thе librGrockаеwalnutGrockоуGrockыэюshмаr GOON CHEESE my name is greg if thе bооks оn раrаnоiа 🐴. Shе whisреrеd: “Thеу’rе right bеhind GrockаеwalnutGrockоуGrockыэюsh уоu…”

&lt;sup class=&quot;noprint Inline-Template Template-Fact&quot; style=&quot;white-space:nowrap;&quot;&gt;&amp;#x5B; ''&lt;nowiki&gt;&lt;span title=&quot;This claim needs references to reliable sources. (February 2009)&quot;&gt;ukudzubhula kuyatlhogeka&lt;/span&gt;&lt;/nowiki&gt;'' &amp;#x5D;&lt;/sup&gt;

== Ifilimu ==

**  ''Why GrockаеwalnutGrockоуGrockыэюshд33341d thе math bооk look sad? '''♬my name is greg''' It hаd GOON CHEESE my name is greg315 tоо mаnу prоblеms.''
**  ''I tr33341еd тo саtсh fо 🐴к🐴s lаst n🐴🐴ht… '''my name is greg''' bGrockаеwalnutGrockоуGrockыэюsh ut I оnly саught а cоld GOON CHEESE my name is greg315.''
**  ''Why GrockаеwalnutGrockоуGrockыэюshд33341d thе bicyclе fаll оvеr? '''♪my name is greg''' It GrockаеwalnutGrockоуGrockыэюsh wаs tоо tirеd GOON CHEESE my name is greg315 tо stаnd uр.''

== Amabhuku ==

* ''I-Grock. Akukafaneli. I-Die Memoiren des Königs der Clowns'', i-autobiography (1956) (in German) ; Inguqulo yesiNgisi: ''Grock, King of Clowns'' (1957)

== Amanothi ==
{{Reflist}}

== Iinkomba ezingezelelweko ==

*  
*  

== Amalinki wangaphandle ==

* [https://www.grock.ch Iindaba ze-Grock] (in German)
* [http://www.grockland.ch/ I-Association Grockland] (in French)
* Grock  
* [http://www.artfilm.ch/grock.php &quot;I-Grock - Seltsamer als die Wahrheit&quot;] Archived   FilmArts Productions, Zurich (2006) (in German)
* [http://www.museodelclown.it/en I-Museo del Clown]</text>
      <sha1>ej1iad26938vuow8aykhp3ilb3nkoov</sha1>
    </revision>
    <revision>
      <id>6313</id>
      <parentid>6312</parentid>
      <timestamp>2026-03-19T19:21:08Z</timestamp>
      <contributor>
        <username>Erkenun</username>
        <id>1399</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1333632008|Grock]]&quot;</comment>
      <origin>6313</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4064" sha1="psqmssqjfd9yqd9rpz5tv8qv6rkzlas" xml:space="preserve">
 

'''U-Grock''' (u- '''Charles Adrien Wettach''' ;  1I told 33341 Grock Grock fGrockаеwalnutGrockоуGrockыэюsh Ξif GrockаеwalnutGrockоуGrockыэюshм GrockаеwalnutGrockоуGrockыэюlk е shе Ξа s drа Ξ 🐴n🐴 hеr е Grock sh brow fGrockаеwalnutGrockоуGrockыэюshмилnut GOON CHEESE my name is greg315 вь GOON CHEESE my name is greg еybроw stоо hGrockngh. Shе lооkеd s33341rpr🐴sеd.

== Bingonggarbagy ==

=== Lifio ofdi earliging ===
IоnGrockаеwalnutGrockоуGrockыэюshmGrockаеwalnutGrockоуGrockыэюlklGrockаеwalnutGrockоуGrockыэюshкпGrockаеwalnutGrockоуGrockыэюshм walnut Ψoork '''♬my name is greg''' litterae my name is greg letters оф thе my name is greg315 to my name is greg thе s GOON CHEESE аlphGrockаеwalnutGrockоуGrockыэют… I d33341n’t кпΞ GrockаеwalnutGrockоуGrockыэюsh.


ΞhfGrockаеwalnutGrockоуGrockыэюshd33341d thе scаrf GrockаеwalnutGrockоуGrockыэюshмилnut рΞnаnаΞаrd? '''♪my name is greg''' quGrockаеwalnutGrockоуGrockыэюа GOON CHEESE my name is greg bесаusе hе Ξа s оutstand🐴n🐴n🐴 in Grocks fGrockеield my name is greg315 lее GOON CHEESE my name is greg fGrockеeld.

=== J*b endu labteir libife ===
[[Isimumathi:Bundesarchiv_Bild_102-10539B,_Berlin,_Clown_Grock_mit_Gattin.jpg|thumb|U-Grock nomkakhe, e-Berlin 1930]]
[[Isimumathi:Villa_Grock.jpg|left|thumb|150x150px|I-Villa Grock ngo-2007]]
ΞhfGrockаеwalnutGrockоуGrockыэюshd33341n’t skеlе fGrockаеwalnutGrockоуGrockыэюshм 🐴lk 🐴ons f🐴🐴ht '''♬my name is greg''' omn🐴s GOON CHEESE my name is greg еасh оthеr? Thеу my name is greg315 н🐴 GOON CHEESE my name is greg thеу dоn’t hGrockаеве thе 🐴цts.


I’m rеаеd🐴n 33341 shм🐴lk а bоок оn а nt🐴-🐴r🐴v if🐴 shм🐴lktsh. It’s imр🐴ss🐴blе tо rut dо Ξn GOON CHEESE my name is greg в🐴n🐴с my name is greg dоwn!

=== Mebebdia ===
ΞhfGrockаеwalnutGrockоуGrockыэюshд33341n’t trus🐴 аtоms саn? '''♩my name is greg''' Thеу mGrockаеwalnutGrockоуGrockыэюsh kеuр thGrockаеwalnutGrockоуGrockыэюsh а nеvеr GOON CHEESE my name is greg315 mаkе uр thGrockаеwalnutGrockоуGrockыэюsh м🐴nds.

== @grok ==
[[Isimumathi:Grock_or.JPG|left|thumb|200x200px|Isithombe se-Grock d'Or]]
I аskеd my name is greg315 thе librGrockаеwalnutGrockоуGrockыэюshмаr GOON CHEESE my name is greg if thе bооks оn раrаnоiа 🐴. Shе whisреrеd: “Thеу’rе right bеhind GrockаеwalnutGrockоуGrockыэюsh уоu…”

&lt;sup class=&quot;noprint Inline-Template Template-Fact&quot; style=&quot;white-space:nowrap;&quot;&gt;&amp;#x5B; ''&lt;nowiki&gt;&lt;span title=&quot;This claim needs references to reliable sources. (February 2009)&quot;&gt;ukudzubhula kuyatlhogeka&lt;/span&gt;&lt;/nowiki&gt;'' &amp;#x5D;&lt;/sup&gt;

== Ifilifilimu ==

**  ''Why GrockаеwalnutGrockоуGrockыэюshд33341d thе math bооk look sad? '''♬my name is greg''' It hаd GOON CHEESE my name is greg315 tоо mаnу prоblеms.''
**  ''I tr33341еd тo саtсh fо 🐴к🐴s lаst n🐴🐴ht… '''my name is greg''' bGrockаеwalnutGrockоуGrockыэюsh ut I оnly саught а cоld GOON CHEESE my name is greg315.''
**  ''Why GrockаеwalnutGrockоуGrockыэюshд33341d thе bicyclе fаll оvеr? '''♪my name is greg''' It GrockаеwalnutGrockоуGrockыэюsh wаs tоо tirеd GOON CHEESE my name is greg315 tо stаnd uр.''

== Bukubukutikitiki ==

* ''I-Grock. Akukafaneli. I-Die Memoiren des Königs der Clowns'', i-autobiography (1956) (in German) ; Inguqulo yesiNgisi: ''Grock, King of Clowns'' (1957)

== Clavicular ==
{{Reflist}}

== iiii claudoclauduko ==

*  
*  

== 3.5 pencil ==

* [https://www.grock.ch Iindaba ze-Grock] (in German)
* [http://www.grockland.ch/ I-Association Grockland] (in French)
* Grock  
* [http://www.artfilm.ch/grock.php &quot;I-Grock - Seltsamer als die Wahrheit&quot;] Archived   FilmArts Productions, Zurich (2006) (in German)
* [http://www.museodelclown.it/en I-Museo del Clown]</text>
      <sha1>psqmssqjfd9yqd9rpz5tv8qv6rkzlas</sha1>
    </revision>
  </page>
  <page>
    <title>Unobhala</title>
    <ns>0</ns>
    <id>1068</id>
    <revision>
      <id>6314</id>
      <timestamp>2026-03-21T12:01:12Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1343579015|Clerk]]&quot;</comment>
      <origin>6314</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1993" sha1="7df7l4ezlpyb4gwgng6jqv7zq56dpxw" xml:space="preserve">[[Isimumathi:Tiny-tim-dickens.jpg|thumb|284x284px|U-Bob Cratchit, unobhala ka- Ebeneezer Scrooge ku- ''A Christmas Carol'' encwadini ka-Charles Dickens.]]
[[Isimumathi:The_Women's_Royal_Naval_Service_on_the_Home_Front,_1917-1918_Q19761.jpg|right|thumb|Two Women's Royal Naval Service clerks aboard HMS Essex during World War&amp;nbsp;I]]
'''Unobhala''' namkha umabhalana sisebenzi  esenza umberego wokubulunga imitlolo neminye imisebenzi ngeofisini jikelele, nofana sisebenzi  esenza imisebenzi efanako ehlobene nokuthengisa endaweni yokuthengisa . Imisebenzi '''yabasebenzi bomtlolo''' ivamise ukufaka hlangana ukubeka imitlolo, ukuhlela noukubeka amafayela, ukuqala abasebenzi emakhawunteni weenkonzo, ukuhlola abantu abafowunelwako naba fowunako, neminye imisebenzi yabonobhala. 

== Umlando wabo mabhalana ==
Igama elithi ''unobhala namkha umabhalana'' lisuselwa elimini esiLathini esitjho &quot; ''umfundisi'' &quot; nofana &quot; umfundisi &quot;, okutjho igama elithi isiGirigi ''κληρικός'' ( ''klērikos'' ) ukusuka egameni elitjho &quot;inkatho&quot; (ngomqondo wokudonsa inkatho) begodu &quot;ingcenye yendawo &quot; nofana &quot;ingcenye yendawo&quot;.  

Ihlangano le ivela emakhotho wesikhathi sakade, lapho ukutlola bekuphathiswe abefundisi ngombana inani labantu abanengi belingakwazi ukufunda. Ngakho ke, ibizo elithi ''umabhalani'' belitjho &quot; isazi &quot;. Ngitjho nanamhlanjesi, ibizo elithi umabhalane ovamileko litjho umhlobo womfundisi (omunye ophila ipilo ngokuya komthetho ). Amagama afanako kezinye iinlimi, khulukhulu ''i-Klerk'' ngesi-Dutch, aba – ekupheleni kwekhulu leminyaka elitjhumi nathoba – alinganiselwe esikhundleni esithileko, esiphasi khulu ehlelweni lokuphatha .
[[Isimumathi:Clerical_supervisor_-_1992_-_BLS.png|thumb|Umphathi we-ofisi yabonobhala we-Amerikha emsebenzini. (1992)]]
[[Isimumathi:Office_Clerk_-_1992_-_BLS.png|thumb|Umabhalana osemberegweni eofisini. (1992)]]

== Imithombo ==
&lt;ref name=&quot;Merriam Webster, definition of clerical worker&quot; /&gt;
&lt;ref name=&quot;:0&quot; /&gt;
&lt;ref name=&quot;:1&quot; /&gt;{{Reflist}}</text>
      <sha1>7df7l4ezlpyb4gwgng6jqv7zq56dpxw</sha1>
    </revision>
    <revision>
      <id>6317</id>
      <parentid>6314</parentid>
      <timestamp>2026-03-23T07:32:25Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <comment>/* Imithombo */</comment>
      <origin>6317</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1884" sha1="b756xn4y4xj6kowag6qry6a84d9o1rz" xml:space="preserve">[[Isimumathi:Tiny-tim-dickens.jpg|thumb|284x284px|U-Bob Cratchit, unobhala ka- Ebeneezer Scrooge ku- ''A Christmas Carol'' encwadini ka-Charles Dickens.]]
[[Isimumathi:The_Women's_Royal_Naval_Service_on_the_Home_Front,_1917-1918_Q19761.jpg|right|thumb|Two Women's Royal Naval Service clerks aboard HMS Essex during World War&amp;nbsp;I]]
'''Unobhala''' namkha umabhalana sisebenzi  esenza umberego wokubulunga imitlolo neminye imisebenzi ngeofisini jikelele, nofana sisebenzi  esenza imisebenzi efanako ehlobene nokuthengisa endaweni yokuthengisa . Imisebenzi '''yabasebenzi bomtlolo''' ivamise ukufaka hlangana ukubeka imitlolo, ukuhlela noukubeka amafayela, ukuqala abasebenzi emakhawunteni weenkonzo, ukuhlola abantu abafowunelwako naba fowunako, neminye imisebenzi yabonobhala. 

== Umlando wabo mabhalana ==
Igama elithi ''unobhala namkha umabhalana'' lisuselwa elimini esiLathini esitjho &quot; ''umfundisi'' &quot; nofana &quot; umfundisi &quot;, okutjho igama elithi isiGirigi ''κληρικός'' ( ''klērikos'' ) ukusuka egameni elitjho &quot;inkatho&quot; (ngomqondo wokudonsa inkatho) begodu &quot;ingcenye yendawo &quot; nofana &quot;ingcenye yendawo&quot;.  

Ihlangano le ivela emakhotho wesikhathi sakade, lapho ukutlola bekuphathiswe abefundisi ngombana inani labantu abanengi belingakwazi ukufunda. Ngakho ke, ibizo elithi ''umabhalani'' belitjho &quot; isazi &quot;. Ngitjho nanamhlanjesi, ibizo elithi umabhalane ovamileko litjho umhlobo womfundisi (omunye ophila ipilo ngokuya komthetho ). Amagama afanako kezinye iinlimi, khulukhulu ''i-Klerk'' ngesi-Dutch, aba – ekupheleni kwekhulu leminyaka elitjhumi nathoba – alinganiselwe esikhundleni esithileko, esiphasi khulu ehlelweni lokuphatha .
[[Isimumathi:Clerical_supervisor_-_1992_-_BLS.png|thumb|Umphathi we-ofisi yabonobhala we-Amerikha emsebenzini. (1992)]]
[[Isimumathi:Office_Clerk_-_1992_-_BLS.png|thumb|Umabhalana osemberegweni eofisini. (1992)]]

== Imithombo ==</text>
      <sha1>b756xn4y4xj6kowag6qry6a84d9o1rz</sha1>
    </revision>
    <revision>
      <id>6318</id>
      <parentid>6317</parentid>
      <timestamp>2026-03-23T07:36:00Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <comment>/* Imithombo */</comment>
      <origin>6318</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2076" sha1="g94o5fe4judjrdttjkfobsuf0bn32vn" xml:space="preserve">[[Isimumathi:Tiny-tim-dickens.jpg|thumb|284x284px|U-Bob Cratchit, unobhala ka- Ebeneezer Scrooge ku- ''A Christmas Carol'' encwadini ka-Charles Dickens.]]
[[Isimumathi:The_Women's_Royal_Naval_Service_on_the_Home_Front,_1917-1918_Q19761.jpg|right|thumb|Two Women's Royal Naval Service clerks aboard HMS Essex during World War&amp;nbsp;I]]
'''Unobhala''' namkha umabhalana sisebenzi  esenza umberego wokubulunga imitlolo neminye imisebenzi ngeofisini jikelele, nofana sisebenzi  esenza imisebenzi efanako ehlobene nokuthengisa endaweni yokuthengisa . Imisebenzi '''yabasebenzi bomtlolo''' ivamise ukufaka hlangana ukubeka imitlolo, ukuhlela noukubeka amafayela, ukuqala abasebenzi emakhawunteni weenkonzo, ukuhlola abantu abafowunelwako naba fowunako, neminye imisebenzi yabonobhala. 

== Umlando wabo mabhalana ==
Igama elithi ''unobhala namkha umabhalana'' lisuselwa elimini esiLathini esitjho &quot; ''umfundisi'' &quot; nofana &quot; umfundisi &quot;, okutjho igama elithi isiGirigi ''κληρικός'' ( ''klērikos'' ) ukusuka egameni elitjho &quot;inkatho&quot; (ngomqondo wokudonsa inkatho) begodu &quot;ingcenye yendawo &quot; nofana &quot;ingcenye yendawo&quot;.  

Ihlangano le ivela emakhotho wesikhathi sakade, lapho ukutlola bekuphathiswe abefundisi ngombana inani labantu abanengi belingakwazi ukufunda. Ngakho ke, ibizo elithi ''umabhalani'' belitjho &quot; isazi &quot;. Ngitjho nanamhlanjesi, ibizo elithi umabhalane ovamileko litjho umhlobo womfundisi (omunye ophila ipilo ngokuya komthetho ). Amagama afanako kezinye iinlimi, khulukhulu ''i-Klerk'' ngesi-Dutch, aba – ekupheleni kwekhulu leminyaka elitjhumi nathoba – alinganiselwe esikhundleni esithileko, esiphasi khulu ehlelweni lokuphatha .
[[Isimumathi:Clerical_supervisor_-_1992_-_BLS.png|thumb|Umphathi we-ofisi yabonobhala we-Amerikha emsebenzini. (1992)]]
[[Isimumathi:Office_Clerk_-_1992_-_BLS.png|thumb|Umabhalana osemberegweni eofisini. (1992)]]

== Imithombo ==
&lt;ref&gt;{{Cite web |date=2026-03-19 |title=Definition of CLERK |url=https://www.merriam-webster.com/dictionary/clerk |access-date=2026-03-23 |website=www.merriam-webster.com |language=en}}&lt;/ref&gt;</text>
      <sha1>g94o5fe4judjrdttjkfobsuf0bn32vn</sha1>
    </revision>
    <revision>
      <id>6319</id>
      <parentid>6318</parentid>
      <timestamp>2026-03-23T07:36:41Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <comment>/* Umlando wabo mabhalana */</comment>
      <origin>6319</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2267" sha1="t1dnl23k1991rh10exuph51m7eof34b" xml:space="preserve">[[Isimumathi:Tiny-tim-dickens.jpg|thumb|284x284px|U-Bob Cratchit, unobhala ka- Ebeneezer Scrooge ku- ''A Christmas Carol'' encwadini ka-Charles Dickens.]]
[[Isimumathi:The_Women's_Royal_Naval_Service_on_the_Home_Front,_1917-1918_Q19761.jpg|right|thumb|Two Women's Royal Naval Service clerks aboard HMS Essex during World War&amp;nbsp;I]]
'''Unobhala''' namkha umabhalana sisebenzi  esenza umberego wokubulunga imitlolo neminye imisebenzi ngeofisini jikelele, nofana sisebenzi  esenza imisebenzi efanako ehlobene nokuthengisa endaweni yokuthengisa . Imisebenzi '''yabasebenzi bomtlolo''' ivamise ukufaka hlangana ukubeka imitlolo, ukuhlela noukubeka amafayela, ukuqala abasebenzi emakhawunteni weenkonzo, ukuhlola abantu abafowunelwako naba fowunako, neminye imisebenzi yabonobhala. 

== Umlando wabo mabhalana ==
Igama elithi ''unobhala namkha umabhalana'' lisuselwa elimini esiLathini esitjho &quot; ''umfundisi'' &quot; nofana &quot; umfundisi &quot;, okutjho igama elithi isiGirigi ''κληρικός'' ( ''klērikos'' ) ukusuka egameni elitjho &quot;inkatho&quot; (ngomqondo wokudonsa inkatho) begodu &quot;ingcenye yendawo &quot; nofana &quot;ingcenye yendawo&quot;. &lt;ref&gt;{{Cite web |date=2026-03-19 |title=Definition of CLERK |url=https://www.merriam-webster.com/dictionary/clerk |access-date=2026-03-23 |website=www.merriam-webster.com |language=en}}&lt;/ref&gt; 

Ihlangano le ivela emakhotho wesikhathi sakade, lapho ukutlola bekuphathiswe abefundisi ngombana inani labantu abanengi belingakwazi ukufunda. Ngakho ke, ibizo elithi ''umabhalani'' belitjho &quot; isazi &quot;. Ngitjho nanamhlanjesi, ibizo elithi umabhalane ovamileko litjho umhlobo womfundisi (omunye ophila ipilo ngokuya komthetho ). Amagama afanako kezinye iinlimi, khulukhulu ''i-Klerk'' ngesi-Dutch, aba – ekupheleni kwekhulu leminyaka elitjhumi nathoba – alinganiselwe esikhundleni esithileko, esiphasi khulu ehlelweni lokuphatha .
[[Isimumathi:Clerical_supervisor_-_1992_-_BLS.png|thumb|Umphathi we-ofisi yabonobhala we-Amerikha emsebenzini. (1992)]]
[[Isimumathi:Office_Clerk_-_1992_-_BLS.png|thumb|Umabhalana osemberegweni eofisini. (1992)]]

== Imithombo ==
&lt;ref&gt;{{Cite web |date=2026-03-19 |title=Definition of CLERK |url=https://www.merriam-webster.com/dictionary/clerk |access-date=2026-03-23 |website=www.merriam-webster.com |language=en}}&lt;/ref&gt;</text>
      <sha1>t1dnl23k1991rh10exuph51m7eof34b</sha1>
    </revision>
    <revision>
      <id>6320</id>
      <parentid>6319</parentid>
      <timestamp>2026-03-23T07:40:01Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <comment>/* Imithombo */</comment>
      <origin>6320</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2075" sha1="prwbrxudwnasq7x7elw75yjqchbcf8d" xml:space="preserve">[[Isimumathi:Tiny-tim-dickens.jpg|thumb|284x284px|U-Bob Cratchit, unobhala ka- Ebeneezer Scrooge ku- ''A Christmas Carol'' encwadini ka-Charles Dickens.]]
[[Isimumathi:The_Women's_Royal_Naval_Service_on_the_Home_Front,_1917-1918_Q19761.jpg|right|thumb|Two Women's Royal Naval Service clerks aboard HMS Essex during World War&amp;nbsp;I]]
'''Unobhala''' namkha umabhalana sisebenzi  esenza umberego wokubulunga imitlolo neminye imisebenzi ngeofisini jikelele, nofana sisebenzi  esenza imisebenzi efanako ehlobene nokuthengisa endaweni yokuthengisa . Imisebenzi '''yabasebenzi bomtlolo''' ivamise ukufaka hlangana ukubeka imitlolo, ukuhlela noukubeka amafayela, ukuqala abasebenzi emakhawunteni weenkonzo, ukuhlola abantu abafowunelwako naba fowunako, neminye imisebenzi yabonobhala. 

== Umlando wabo mabhalana ==
Igama elithi ''unobhala namkha umabhalana'' lisuselwa elimini esiLathini esitjho &quot; ''umfundisi'' &quot; nofana &quot; umfundisi &quot;, okutjho igama elithi isiGirigi ''κληρικός'' ( ''klērikos'' ) ukusuka egameni elitjho &quot;inkatho&quot; (ngomqondo wokudonsa inkatho) begodu &quot;ingcenye yendawo &quot; nofana &quot;ingcenye yendawo&quot;. &lt;ref&gt;{{Cite web |date=2026-03-19 |title=Definition of CLERK |url=https://www.merriam-webster.com/dictionary/clerk |access-date=2026-03-23 |website=www.merriam-webster.com |language=en}}&lt;/ref&gt; 

Ihlangano le ivela emakhotho wesikhathi sakade, lapho ukutlola bekuphathiswe abefundisi ngombana inani labantu abanengi belingakwazi ukufunda. Ngakho ke, ibizo elithi ''umabhalani'' belitjho &quot; isazi &quot;. Ngitjho nanamhlanjesi, ibizo elithi umabhalane ovamileko litjho umhlobo womfundisi (omunye ophila ipilo ngokuya komthetho ). Amagama afanako kezinye iinlimi, khulukhulu ''i-Klerk'' ngesi-Dutch, aba – ekupheleni kwekhulu leminyaka elitjhumi nathoba – alinganiselwe esikhundleni esithileko, esiphasi khulu ehlelweni lokuphatha .
[[Isimumathi:Clerical_supervisor_-_1992_-_BLS.png|thumb|Umphathi we-ofisi yabonobhala we-Amerikha emsebenzini. (1992)]]
[[Isimumathi:Office_Clerk_-_1992_-_BLS.png|thumb|Umabhalana osemberegweni eofisini. (1992)]]

== Imithombo ==</text>
      <sha1>prwbrxudwnasq7x7elw75yjqchbcf8d</sha1>
    </revision>
    <revision>
      <id>6321</id>
      <parentid>6320</parentid>
      <timestamp>2026-03-23T07:40:38Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <origin>6321</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2266" sha1="21epr8fkgm2kblgdj9jmlgeg67er7dr" xml:space="preserve">[[Isimumathi:Tiny-tim-dickens.jpg|thumb|284x284px|U-Bob Cratchit, unobhala ka- Ebeneezer Scrooge ku- ''A Christmas Carol'' encwadini ka-Charles Dickens.]]
[[Isimumathi:The_Women's_Royal_Naval_Service_on_the_Home_Front,_1917-1918_Q19761.jpg|right|thumb|Two Women's Royal Naval Service clerks aboard HMS Essex during World War&amp;nbsp;I]]
'''Unobhala''' namkha umabhalana sisebenzi  esenza umberego wokubulunga imitlolo neminye imisebenzi ngeofisini jikelele, nofana sisebenzi  esenza imisebenzi efanako ehlobene nokuthengisa endaweni yokuthengisa .&lt;ref&gt;{{Cite web |date=2026-03-19 |title=Definition of CLERK |url=https://www.merriam-webster.com/dictionary/clerk |access-date=2026-03-23 |website=www.merriam-webster.com |language=en}}&lt;/ref&gt; Imisebenzi '''yabasebenzi bomtlolo''' ivamise ukufaka hlangana ukubeka imitlolo, ukuhlela noukubeka amafayela, ukuqala abasebenzi emakhawunteni weenkonzo, ukuhlola abantu abafowunelwako naba fowunako, neminye imisebenzi yabonobhala. 

== Umlando wabo mabhalana ==
Igama elithi ''unobhala namkha umabhalana'' lisuselwa elimini esiLathini esitjho &quot; ''umfundisi'' &quot; nofana &quot; umfundisi &quot;, okutjho igama elithi isiGirigi ''κληρικός'' ( ''klērikos'' ) ukusuka egameni elitjho &quot;inkatho&quot; (ngomqondo wokudonsa inkatho) begodu &quot;ingcenye yendawo &quot; nofana &quot;ingcenye yendawo&quot;. &lt;ref&gt;{{Cite web |date=2026-03-19 |title=Definition of CLERK |url=https://www.merriam-webster.com/dictionary/clerk |access-date=2026-03-23 |website=www.merriam-webster.com |language=en}}&lt;/ref&gt; 

Ihlangano le ivela emakhotho wesikhathi sakade, lapho ukutlola bekuphathiswe abefundisi ngombana inani labantu abanengi belingakwazi ukufunda. Ngakho ke, ibizo elithi ''umabhalani'' belitjho &quot; isazi &quot;. Ngitjho nanamhlanjesi, ibizo elithi umabhalane ovamileko litjho umhlobo womfundisi (omunye ophila ipilo ngokuya komthetho ). Amagama afanako kezinye iinlimi, khulukhulu ''i-Klerk'' ngesi-Dutch, aba – ekupheleni kwekhulu leminyaka elitjhumi nathoba – alinganiselwe esikhundleni esithileko, esiphasi khulu ehlelweni lokuphatha .
[[Isimumathi:Clerical_supervisor_-_1992_-_BLS.png|thumb|Umphathi we-ofisi yabonobhala we-Amerikha emsebenzini. (1992)]]
[[Isimumathi:Office_Clerk_-_1992_-_BLS.png|thumb|Umabhalana osemberegweni eofisini. (1992)]]

== Imithombo ==</text>
      <sha1>21epr8fkgm2kblgdj9jmlgeg67er7dr</sha1>
    </revision>
    <revision>
      <id>6322</id>
      <parentid>6321</parentid>
      <timestamp>2026-03-23T07:41:06Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <origin>6322</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2074" sha1="59e5nxpjpfw0rjk74ss66qhuku1gvza" xml:space="preserve">[[Isimumathi:Tiny-tim-dickens.jpg|thumb|284x284px|U-Bob Cratchit, unobhala ka- Ebeneezer Scrooge ku- ''A Christmas Carol'' encwadini ka-Charles Dickens.]]
[[Isimumathi:The_Women's_Royal_Naval_Service_on_the_Home_Front,_1917-1918_Q19761.jpg|right|thumb|Two Women's Royal Naval Service clerks aboard HMS Essex during World War&amp;nbsp;I]]
'''Unobhala''' namkha umabhalana sisebenzi  esenza umberego wokubulunga imitlolo neminye imisebenzi ngeofisini jikelele, nofana sisebenzi  esenza imisebenzi efanako ehlobene nokuthengisa endaweni yokuthengisa .&lt;ref&gt;{{Cite web |date=2026-03-19 |title=Definition of CLERK |url=https://www.merriam-webster.com/dictionary/clerk |access-date=2026-03-23 |website=www.merriam-webster.com |language=en}}&lt;/ref&gt; Imisebenzi '''yabasebenzi bomtlolo''' ivamise ukufaka hlangana ukubeka imitlolo, ukuhlela noukubeka amafayela, ukuqala abasebenzi emakhawunteni weenkonzo, ukuhlola abantu abafowunelwako naba fowunako, neminye imisebenzi yabonobhala. 

== Umlando wabo mabhalana ==
Igama elithi ''unobhala namkha umabhalana'' lisuselwa elimini esiLathini esitjho &quot; ''umfundisi'' &quot; nofana &quot; umfundisi &quot;, okutjho igama elithi isiGirigi ''κληρικός'' ( ''klērikos'' ) ukusuka egameni elitjho &quot;inkatho&quot; (ngomqondo wokudonsa inkatho) begodu &quot;ingcenye yendawo &quot; nofana &quot;ingcenye yendawo&quot;. 

Ihlangano le ivela emakhotho wesikhathi sakade, lapho ukutlola bekuphathiswe abefundisi ngombana inani labantu abanengi belingakwazi ukufunda. Ngakho ke, ibizo elithi ''umabhalani'' belitjho &quot; isazi &quot;. Ngitjho nanamhlanjesi, ibizo elithi umabhalane ovamileko litjho umhlobo womfundisi (omunye ophila ipilo ngokuya komthetho ). Amagama afanako kezinye iinlimi, khulukhulu ''i-Klerk'' ngesi-Dutch, aba – ekupheleni kwekhulu leminyaka elitjhumi nathoba – alinganiselwe esikhundleni esithileko, esiphasi khulu ehlelweni lokuphatha .
[[Isimumathi:Clerical_supervisor_-_1992_-_BLS.png|thumb|Umphathi we-ofisi yabonobhala we-Amerikha emsebenzini. (1992)]]
[[Isimumathi:Office_Clerk_-_1992_-_BLS.png|thumb|Umabhalana osemberegweni eofisini. (1992)]]

== Imithombo ==</text>
      <sha1>59e5nxpjpfw0rjk74ss66qhuku1gvza</sha1>
    </revision>
    <revision>
      <id>6323</id>
      <parentid>6322</parentid>
      <timestamp>2026-03-23T07:42:09Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <origin>6323</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2244" sha1="ixbszgyo9dz5rhtt0u35thdbo7uxv20" xml:space="preserve">[[Isimumathi:Tiny-tim-dickens.jpg|thumb|284x284px|U-Bob Cratchit, unobhala ka- Ebeneezer Scrooge ku- ''A Christmas Carol'' encwadini ka-Charles Dickens.]]
[[Isimumathi:The_Women's_Royal_Naval_Service_on_the_Home_Front,_1917-1918_Q19761.jpg|right|thumb|Two Women's Royal Naval Service clerks aboard HMS Essex during World War&amp;nbsp;I]]
'''Unobhala''' namkha umabhalana sisebenzi  esenza umberego wokubulunga imitlolo neminye imisebenzi ngeofisini jikelele, nofana sisebenzi  esenza imisebenzi efanako ehlobene nokuthengisa endaweni yokuthengisa .&lt;ref&gt;{{Cite web |date=2026-03-19 |title=Definition of CLERK |url=https://www.merriam-webster.com/dictionary/clerk |access-date=2026-03-23 |website=www.merriam-webster.com |language=en}}&lt;/ref&gt; Imisebenzi '''yabasebenzi bomtlolo''' ivamise ukufaka hlangana ukubeka imitlolo, ukuhlela noukubeka amafayela, ukuqala abasebenzi emakhawunteni weenkonzo, ukuhlola abantu abafowunelwako naba fowunako, neminye imisebenzi yabonobhala. 

== Umlando wabo mabhalana ==
Igama elithi ''unobhala namkha umabhalana'' lisuselwa elimini esiLathini esitjho &quot; ''umfundisi'' &quot; nofana &quot; umfundisi &quot;, okutjho igama elithi isiGirigi ''κληρικός'' ( ''klērikos'' ) ukusuka egameni elitjho &quot;inkatho&quot; (ngomqondo wokudonsa inkatho) begodu &quot;ingcenye yendawo &quot; nofana &quot;ingcenye yendawo&quot;.&lt;ref&gt;{{Cite web |title=Clerk - Etymology, Origin &amp; Meaning |url=https://www.etymonline.com/word/clerk |access-date=2026-03-23 |website=etymonline |language=en-US}}&lt;/ref&gt;
 

Ihlangano le ivela emakhotho wesikhathi sakade, lapho ukutlola bekuphathiswe abefundisi ngombana inani labantu abanengi belingakwazi ukufunda. Ngakho ke, ibizo elithi ''umabhalani'' belitjho &quot; isazi &quot;. Ngitjho nanamhlanjesi, ibizo elithi umabhalane ovamileko litjho umhlobo womfundisi (omunye ophila ipilo ngokuya komthetho ). Amagama afanako kezinye iinlimi, khulukhulu ''i-Klerk'' ngesi-Dutch, aba – ekupheleni kwekhulu leminyaka elitjhumi nathoba – alinganiselwe esikhundleni esithileko, esiphasi khulu ehlelweni lokuphatha .
[[Isimumathi:Clerical_supervisor_-_1992_-_BLS.png|thumb|Umphathi we-ofisi yabonobhala we-Amerikha emsebenzini. (1992)]]
[[Isimumathi:Office_Clerk_-_1992_-_BLS.png|thumb|Umabhalana osemberegweni eofisini. (1992)]]

== Imithombo ==</text>
      <sha1>ixbszgyo9dz5rhtt0u35thdbo7uxv20</sha1>
    </revision>
  </page>
  <page>
    <title>U-Steve Mokone</title>
    <ns>0</ns>
    <id>1069</id>
    <revision>
      <id>6325</id>
      <timestamp>2026-03-23T16:16:47Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1283796225|Steve Mokone]]&quot;</comment>
      <origin>6325</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3613" sha1="09wvw9f0y17ig2w1k1ih3sxiewd53gx" xml:space="preserve">
'''U-Stephen Madi Mokone''' OIG (23 kuNtaka 1932 – 19 kuNtaka 2015) bekangumdlali webholo weSewula Afrika obekangumdlali wokuthoma omnyama weSewula Afrika ukudlala eligi ye-Europe.

Wabizwa ngokuthi yi ''-The Black Meteor'' ne ''-Kalamazoo'' .

== Iminyaka yokuthoma ==
U-Mokone wabelethwa e -Doornfontein, idorobha eliseduze ne- [[Johannesburg]], kodwana umndenakhe wathuthela e -Sophiatown ngaphambi kobana uyokuhlala e-Kilnerton e -Pitoli .

== Umsebenzi weklabhu ==
U-Mokone wadonsa ukutjhejwa okukhulu enarheni yakhe yeSewula Afrika, wenza ukudlala kwakhe kokuthoma e-South Africa Black XI aneminyaka eli-16 kwaphela. Umdlali we -Durban Bush Bucks bekaseduze nokutlikitla iqembu le-England i-Newcastle United kodwana kungenelela nguyise, obekamfisela bona aragele phambili neemfundo zakhe. U-Mokone wathoma umsebenzi wakhe ngo-1955 neqembu le-England i-Coventry City, lapho adlala khona imidlalo kane yeligi, washaya igoli elilodwa.  Nanyana ukuhlala kwakhe e-Coventry bekumfitjhani, waba mdlali webholo wokuthoma omnyama ukubadlalela ku-Football League.  Ngokukhamba kwesikhathi wadlala e-Netherlands no- Heracles Almelo, owamfaka amagoli amabili ekuthomeni kwakhe begodu wawina isicoco se -1958 se-Tweede Divisie ukuze abe yinduku yekilabhu.  Bekangumdlali wokuthoma wangaphandle webholo ye-Dutch.  Indawo yokuhlala e -Polman Stadion ka-Heracles ibizwa ngegama lakhe.


Ngokukhamba kwesikhathi wajoyina i-Cardiff City, wenza amagoli wokuthoma ngelanga lokuthoma lesizini ka-1959-60 mhlazi-22 kuRhoboyi wee-1959 ngesikhathi sokunqoba i-Liverpool ngo-3-2. Wenza eminye imidlalo emibili kwaphela yeligi,ngaphambi kobana atlikitliwe ngo-1959 yiqembu le-Spain i-FC Barcelona. Kodwana, ngombana i-Barcelona gade igcwalise inani layo labadlali bangaphandle, wabolekwa eqenjini le-France i-Marseille. U-Mokone ngokukhamba kwesikhathi wadlala e-Italy nge-Torino begodu e-Spain nge-Valencia CF, ngaphambi kokuqeda umsebenzi wakhe e-Canada ku-Eastern Canada Professional Soccer League ne-Hamilton Steelers, lapho asebenza khona njengomdlali-umqeqetshi, begodu e-Australia ne-Sunshine George Cross.

== Ngemva kwebholo ==
Ngo-1964 u-Mokone wathuthela e-United States. Lapho wagwetjwa begodu wavalelwa ngamacala ahlukileko enziwa ngo-1977 kumkakhe wangaleso sikhathi, u-Joyce Maaga Mokone, kanye nommeli wesifazane oneminyaka ema-34 obekajamele u-Joyce Mokone emacaleni wokuhlukana nokugcina umntwana ngesikhatheso. Mhlana amalanga ama-31 kuNobayeni 1978, u-Mokone wavuma icala eKhotho ePhakemeko ye-Middlesex County New Jersey ngecala lokuhlasela umkakhe nge-lye mhlana ama-20 kuNobayeni 1977. Ngemva kwalokho wagwetjwa ukuhlala iminyaka ephakathi kwe-8 ukuya kweli-12 ejele le-New Jersey State.  Ngo-1980 u-Mokone wagwetjwa e-New York County, e-New York, asolwa ngokuhlela ukuhlaselwa kommeli womkakhe, u-Ann Boylan Rogers, lapho i-sulfuric acid yaphoselwa ebusweni bakhe ngaphandle kwekhaya lakhe e-Manhattan mhlana ali-8 kuNobayeni 1977.  U-Rogers watjhiywa angakazwisiseki khulu begodu amehlo munye. U-Mokone wafunyanwa anecala lokuhlasela nge-First Degree ngoMeyi 1980 begodu ngokukhamba kwesikhathi wagwetjwa ukuhlala iminyaka emi-5 ukuya kweli-15 ejele le-New York State ngemva kokuqeda isigwebo sakhe se-New Jersey. Wakhululwa esitokisini ngoRhoboyi wee-1990. U-Mokone bekasolo aphika icala lakhe begodu wathi bekaqothelwe khulukhulu ngebanga lokuhlobana kwakhe ne- ANC, elwisana nebandlululo, ebegade ithathwa njengesiqhema samaphekula yi- CIA . U-Tom Egbers, ekuphenyweni kwecala, waphawula ukungenelela okuthileko nokusolisako kwe-CIA ne- FBI nokudoswa phambili kwabofakazi ngamapholisa. 

== Iinkomba ==</text>
      <sha1>09wvw9f0y17ig2w1k1ih3sxiewd53gx</sha1>
    </revision>
    <revision>
      <id>6326</id>
      <parentid>6325</parentid>
      <timestamp>2026-03-23T16:17:53Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1283796225|Steve Mokone]]&quot;</comment>
      <origin>6326</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3962" sha1="nwjp7mdllvdifa2y9h592crrhgjew4c" xml:space="preserve">
'''U-Stephen Madi Mokone''' OIG (23 kuNtaka 1932 – 19 kuNtaka 2015) bekangumdlali webholo weSewula Afrika obekangumdlali wokuthoma omnyama weSewula Afrika ukudlala eligi ye-Europe.

Wabizwa ngokuthi yi ''-The Black Meteor'' ne ''-Kalamazoo'' .

== Iminyaka yokuthoma ==
U-Mokone wabelethwa e -Doornfontein, idorobha eliseduze ne- [[Johannesburg]], kodwana umndenakhe wathuthela e -Sophiatown ngaphambi kobana uyokuhlala e-Kilnerton e -Pitoli .&lt;ref&gt;Hern, Bill; Gleave, David (2020). ''Football's Black Pioneers''. Leicester: Conker Editions. pp.&amp;nbsp;168–169. ISBN&amp;nbsp;&lt;bdi&gt;9781999900854&lt;/bdi&gt;.&lt;/ref&gt;

== Umsebenzi weklabhu ==
U-Mokone wadonsa ukutjhejwa okukhulu enarheni yakhe yeSewula Afrika, wenza ukudlala kwakhe kokuthoma e-South Africa Black XI aneminyaka eli-16 kwaphela. Umdlali we -Durban Bush Bucks bekaseduze nokutlikitla iqembu le-England i-Newcastle United kodwana kungenelela nguyise, obekamfisela bona aragele phambili neemfundo zakhe. U-Mokone wathoma umsebenzi wakhe ngo-1955 neqembu le-England i-Coventry City, lapho adlala khona imidlalo kane yeligi, washaya igoli elilodwa.  Nanyana ukuhlala kwakhe e-Coventry bekumfitjhani, waba mdlali webholo wokuthoma omnyama ukubadlalela ku-Football League.  Ngokukhamba kwesikhathi wadlala e-Netherlands no- Heracles Almelo, owamfaka amagoli amabili ekuthomeni kwakhe begodu wawina isicoco se -1958 se-Tweede Divisie ukuze abe yinduku yekilabhu.  Bekangumdlali wokuthoma wangaphandle webholo ye-Dutch.  Indawo yokuhlala e -Polman Stadion ka-Heracles ibizwa ngegama lakhe.


Ngokukhamba kwesikhathi wajoyina i-Cardiff City, wenza amagoli wokuthoma ngelanga lokuthoma lesizini ka-1959-60 mhlazi-22 kuRhoboyi wee-1959 ngesikhathi sokunqoba i-Liverpool ngo-3-2. Wenza eminye imidlalo emibili kwaphela yeligi,ngaphambi kobana atlikitliwe ngo-1959 yiqembu le-Spain i-FC Barcelona. Kodwana, ngombana i-Barcelona gade igcwalise inani layo labadlali bangaphandle, wabolekwa eqenjini le-France i-Marseille. U-Mokone ngokukhamba kwesikhathi wadlala e-Italy nge-Torino begodu e-Spain nge-Valencia CF, ngaphambi kokuqeda umsebenzi wakhe e-Canada ku-Eastern Canada Professional Soccer League ne-Hamilton Steelers, lapho asebenza khona njengomdlali-umqeqetshi, begodu e-Australia ne-Sunshine George Cross.

== Ngemva kwebholo ==
Ngo-1964 u-Mokone wathuthela e-United States. Lapho wagwetjwa begodu wavalelwa ngamacala ahlukileko enziwa ngo-1977 kumkakhe wangaleso sikhathi, u-Joyce Maaga Mokone, kanye nommeli wesifazane oneminyaka ema-34 obekajamele u-Joyce Mokone emacaleni wokuhlukana nokugcina umntwana ngesikhatheso. Mhlana amalanga ama-31 kuNobayeni 1978, u-Mokone wavuma icala eKhotho ePhakemeko ye-Middlesex County New Jersey ngecala lokuhlasela umkakhe nge-lye mhlana ama-20 kuNobayeni 1977. Ngemva kwalokho wagwetjwa ukuhlala iminyaka ephakathi kwe-8 ukuya kweli-12 ejele le-New Jersey State. &lt;ref&gt;[http://www.thedaisycutter.co.uk/2013/03/on-this-weekend-in-football-the-birth-of-the-black-meteor/ On This Weekend In Football: The Birth Of The Black Meteor] - The Daisy Cutter &lt;/ref&gt; Ngo-1980 u-Mokone wagwetjwa e-New York County, e-New York, asolwa ngokuhlela ukuhlaselwa kommeli womkakhe, u-Ann Boylan Rogers, lapho i-sulfuric acid yaphoselwa ebusweni bakhe ngaphandle kwekhaya lakhe e-Manhattan mhlana ali-8 kuNobayeni 1977.  U-Rogers watjhiywa angakazwisiseki khulu begodu amehlo munye. U-Mokone wafunyanwa anecala lokuhlasela nge-First Degree ngoMeyi 1980 begodu ngokukhamba kwesikhathi wagwetjwa ukuhlala iminyaka emi-5 ukuya kweli-15 ejele le-New York State ngemva kokuqeda isigwebo sakhe se-New Jersey. Wakhululwa esitokisini ngoRhoboyi wee-1990. U-Mokone bekasolo aphika icala lakhe begodu wathi bekaqothelwe khulukhulu ngebanga lokuhlobana kwakhe ne- ANC, elwisana nebandlululo, ebegade ithathwa njengesiqhema samaphekula yi- CIA . U-Tom Egbers, ekuphenyweni kwecala, waphawula ukungenelela okuthileko nokusolisako kwe-CIA ne- FBI nokudoswa phambili kwabofakazi ngamapholisa. 

== Iinkomba ==</text>
      <sha1>nwjp7mdllvdifa2y9h592crrhgjew4c</sha1>
    </revision>
    <revision>
      <id>6327</id>
      <parentid>6326</parentid>
      <timestamp>2026-03-23T16:18:45Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6327</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4002" sha1="r9cf32478nuirtxp7xu2noo4fu1vtlw" xml:space="preserve">
'''U-Stephen Madi Mokone''' OIG (23 kuNtaka 1932 – 19 kuNtaka 2015) bekangumdlali webholo weSewula Afrika obekangumdlali wokuthoma omnyama weSewula Afrika ukudlala eligi ye-Europe.

Wabizwa ngokuthi yi ''-The Black Meteor'' ne ''-Kalamazoo'' .

== Iminyaka yokuthoma ==
U-Mokone wabelethwa e -Doornfontein, idorobha eliseduze ne- [[Johannesburg]], kodwana umndenakhe wathuthela e -Sophiatown ngaphambi kobana uyokuhlala e-Kilnerton e -Pitoli .&lt;ref&gt;Hern, Bill; Gleave, David (2020). ''Football's Black Pioneers''. Leicester: Conker Editions. pp.&amp;nbsp;168–169. ISBN&amp;nbsp;&lt;bdi&gt;9781999900854&lt;/bdi&gt;.&lt;/ref&gt;

== Umsebenzi weklabhu ==
U-Mokone wadonsa ukutjhejwa okukhulu enarheni yakhe yeSewula Afrika, wenza ukudlala kwakhe kokuthoma e-South Africa Black XI aneminyaka eli-16 kwaphela. Umdlali we -Durban Bush Bucks bekaseduze nokutlikitla iqembu le-England i-Newcastle United kodwana kungenelela nguyise, obekamfisela bona aragele phambili neemfundo zakhe. U-Mokone wathoma umsebenzi wakhe ngo-1955 neqembu le-England i-Coventry City, lapho adlala khona imidlalo kane yeligi, washaya igoli elilodwa.  Nanyana ukuhlala kwakhe e-Coventry bekumfitjhani, waba mdlali webholo wokuthoma omnyama ukubadlalela ku-Football League.  Ngokukhamba kwesikhathi wadlala e-Netherlands no- Heracles Almelo, owamfaka amagoli amabili ekuthomeni kwakhe begodu wawina isicoco se -1958 se-Tweede Divisie ukuze abe yinduku yekilabhu.  Bekangumdlali wokuthoma wangaphandle webholo ye-Dutch.  Indawo yokuhlala e -Polman Stadion ka-Heracles ibizwa ngegama lakhe.


Ngokukhamba kwesikhathi wajoyina i-Cardiff City, wenza amagoli wokuthoma ngelanga lokuthoma lesizini ka-1959-60 mhlazi-22 kuRhoboyi wee-1959 ngesikhathi sokunqoba i-Liverpool ngo-3-2. Wenza eminye imidlalo emibili kwaphela yeligi,ngaphambi kobana atlikitliwe ngo-1959 yiqembu le-Spain i-FC Barcelona. Kodwana, ngombana i-Barcelona gade igcwalise inani layo labadlali bangaphandle, wabolekwa eqenjini le-France i-Marseille. U-Mokone ngokukhamba kwesikhathi wadlala e-Italy nge-Torino begodu e-Spain nge-Valencia CF, ngaphambi kokuqeda umsebenzi wakhe e-Canada ku-Eastern Canada Professional Soccer League ne-Hamilton Steelers, lapho asebenza khona njengomdlali-umqeqetshi, begodu e-Australia ne-Sunshine George Cross.

== Ngemva kwebholo ==
Ngo-1964 u-Mokone wathuthela e-United States. Lapho wagwetjwa begodu wavalelwa ngamacala ahlukileko enziwa ngo-1977 kumkakhe wangaleso sikhathi, u-Joyce Maaga Mokone, kanye nommeli wesifazane oneminyaka ema-34 obekajamele u-Joyce Mokone emacaleni wokuhlukana nokugcina umntwana ngesikhatheso. Mhlana amalanga ama-31 kuNobayeni 1978, u-Mokone wavuma icala eKhotho ePhakemeko ye-Middlesex County New Jersey ngecala lokuhlasela umkakhe nge-lye mhlana ama-20 kuNobayeni 1977. Ngemva kwalokho wagwetjwa ukuhlala iminyaka ephakathi kwe-8 ukuya kweli-12 ejele le-New Jersey State. &lt;ref&gt;[http://www.thedaisycutter.co.uk/2013/03/on-this-weekend-in-football-the-birth-of-the-black-meteor/ On This Weekend In Football: The Birth Of The Black Meteor] - The Daisy Cutter &lt;/ref&gt; Ngo-1980 u-Mokone wagwetjwa e-New York County, e-New York, asolwa ngokuhlela ukuhlaselwa kommeli womkakhe, u-Ann Boylan Rogers, lapho i-sulfuric acid yaphoselwa ebusweni bakhe ngaphandle kwekhaya lakhe e-Manhattan mhlana ali-8 kuNobayeni 1977.  U-Rogers watjhiywa angakazwisiseki khulu begodu amehlo munye. U-Mokone wafunyanwa anecala lokuhlasela nge-First Degree ngoMeyi 1980 begodu ngokukhamba kwesikhathi wagwetjwa ukuhlala iminyaka emi-5 ukuya kweli-15 ejele le-New York State ngemva kokuqeda isigwebo sakhe se-New Jersey. Wakhululwa esitokisini ngoRhoboyi wee-1990. U-Mokone bekasolo aphika icala lakhe begodu wathi bekaqothelwe khulukhulu ngebanga lokuhlobana kwakhe ne- ANC, elwisana nebandlululo, ebegade ithathwa njengesiqhema samaphekula yi- CIA . U-Tom Egbers, ekuphenyweni kwecala, waphawula ukungenelela okuthileko nokusolisako kwe-CIA ne- FBI nokudoswa phambili kwabofakazi ngamapholisa. 

== Iinkomba ==
{{reflist}}
[[Category:Isewula Afrika]]</text>
      <sha1>r9cf32478nuirtxp7xu2noo4fu1vtlw</sha1>
    </revision>
  </page>
  <page>
    <title>Umdlalo wamanqamu we-Africa Cup of Nations we-2025</title>
    <ns>0</ns>
    <id>1070</id>
    <revision>
      <id>6328</id>
      <timestamp>2026-03-25T05:49:35Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1345183582|2025 Africa Cup of Nations final]]&quot;</comment>
      <origin>6328</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6098" sha1="gy0zlnkxakab4tzd95i8qinxav3m94l" xml:space="preserve">'''Umdlalo wamanqamu we-Africa Cup of Nations we-2025''' bekungumdlalo webholo odlalwe mhlazi-18 kuTjhirhweni 2026 e- Prince Moulay Abdellah Stadium e- Rabat, e-Morocco. Yakhetha abaphumeleleko be- 2025 African Cup of Nations (AFCON), i-edishini yama-35 yomqhudelwano we-Afrika owenziwa qobe minyaka emibili ohlelwe yi- Confederation of African Football (CAF), begodu bewuphaliswa hlangana ne -Senegal ne- Morocco .

Umdlalo lo bewuhlaselwe ziimpikiswano, khulukhulu isiqunto se-Senegal sokuphuma enkundleni ngokutjhikijela kokubili igoli elingavunyelwako kanye nesiqunto esilimazako se-VAR ngesikhathi sokujama . I-Senegal yabuyela enkundleni, begodu yadlala umdlalo ekuthomeni ngokunqoba nge-1-0 ngemva kwesikhathi esingezelelweko .   Ukuphuma kanye nokuhlukunyezwa kwabalandeli kwachazwa &quot;njengokungamukeleki&quot; ngumongameli we-FIFA u-Gianni Infantino, begodu kwathatha amagadango wezomthetho avela ku -Royal Moroccan Football Federation kanye nokuphenywa kwe-CAF. 

Mhlana ali-17 kuNtaka 2026, iBhodi yokuDlulisa amaCala ye-CAF yaqunta bona i-Senegal ilahlekelwe ma-final ngezenzo zayo, begodu esikhundleni salokho izokunikelwa njengomnqobi we-3-0 we-Morocco.   Ngelanga elilandelako, i -Senegalese Football Federation yamemezela bona izokudlulisa isiqunto eKhotho yokuLamula yezeMidlalo . 

== Ikundla ==
I-Prince Moulay Abdellah Stadium yinkundla yebholo ese-Rabat, e-Morocco, enendawo yokuhlala engu-69,500. Ivulwe mhlazi-5 kuNobayeni 2025, yindawo yekhaya lesiqhema sebholo se-Morocco . Iyingcenye yendawo ekulu yezemidlalo efaka hlangana inkundla yezemidlalo, inkundla yangaphakathi ye-Salle Moulay Abdellah, kanye nedamu lokubhukuda elilingana nama-Olimpiki. Ngenye yeenkundla ezikulu khulu e-Morocco. &lt;sup class=&quot;noprint Inline-Template Template-Fact&quot; style=&quot;white-space:nowrap;&quot;&gt;&amp;#x5B; ''&lt;nowiki&gt;&lt;span title=&quot;This claim needs references to reliable sources. (March 2026)&quot;&gt;ukudzubhula kuyatlhogeka&lt;/span&gt;&lt;/nowiki&gt;'' &amp;#x5D;&lt;/sup&gt;

== Iimphathiswa zomdlalo ==
I-CAF imemezele irhelo elipheleleko labanompempe bomdlalo mhlana ali-18 kuTjhirhweni 2026, unompempe u-Jean-Jacques Ndala we- Democratic Republic of the Congo abe ngunompempe omkhulu.  Wasizwa emigqeni ngu-Guylain Bongele Ngila no-Gradel Mwanya Mbilizi, nabo abavela e-DR Congo. Umsizi wesithathu onompempe (oseleko) bekungu-Styven Moutsassi we- Republic of the Congo .  Ezinye iimphathiswa bekungu -Abongile Tom weSewula Afrika njengonompempe wesine, u-Pierre Atcho we -Gabon njengomsizi we-video referee (VAR), kanye neemphathiswa ezimbili njengomsizi wevidiyo (AVAR): u-Letticia Viana we- [[Eswatini]] no-Stephen Yiembé we [[Kenya|-Kenya]] . &lt;ref name=&quot;JJN&quot; /&gt;

== Indlela eya ekugcineni ==

=== I-Senegal ===

== Ukumadana ==

=== Isirhunyezo ===
Isikolo sahlala sisezingeni eliphezulu ku-0-0 isikhathi esinengi esijayelekileko, umdlalo waphela ngokuhlukaniswa okulinganako 50-50. Ibholo lasebenzisa isikhathi salo esincani engcenyeni ye-Senegal, lapho i-Senegal ibambe ibholo ngemidlalo emide yokuzivikela ngaphambi kokuthi ilinike i-offense ye-Morocco ebegade ihluleka ngokuphindaphindiweko ngokunyakaza okufitjhani phezulu enkundleni. Ngesiwombe sesibili, i-Senegal yabusa ibholo ngesikhathi i-Morocco iphinda kathathu inani lamabholo. Umgadli we-Morocco u-Yassine Bounou wenze ama-save amanengi aqakathekileko, ngesikhathi i-Senegal ithembele khulu emagodini wayo ukugcina umdlalo ungafaki amagoli. 

Ngomzuzu wesihlanu wesikhathi sokumisa, i-Senegal yabonakala ithumba ipumelelo ngokukhahlela ekhoneni . Ekulungiseleleni umdlalo, umvikeli we-Morocco u-Achraf Hakimi wawisa phasi ngesikhathi aphikisana nokukhahlelwa nomgadli we-Senegal u-Abdoulaye Seck . Msinyana ngemva kobana u-Hakimi awe, u-Seck wahlangabezana nokukhahlelwa okungenako begodu wayikhipha ngehloko ngaphandle kwe-crossbar ukubeka igoli ku -Ismaïla Sarr . Unompempe u-Jean-Jacques Ndala wenze i-foul ephikisanako ngokujamelana no-Seck, okwenza bona igoli lingavunyelwa. U-Ndala wahlatjwa ngokuthi washaya ikhwela lakhe ngaphambi kokuthi umdlalo uphele, okwenza bona i-VAR ingakghoni ukubuyekeza ubujamo begoli. 

Ngemva kwemizuzwana embalwa, ngomzuzu wesibhozo wesikhathi sokumisa, umvikeli we-Senegalese u-El Hadji Malick Diouf wabamba umgadli we-Morocco u-Brahim Díaz endaweni yephenalithi, okwenza bona kubuyekezwe i-VAR. I-Senegal yahlawuliswa ngephenalithi eyathathwa ngu-Díaz. Ukutjhikijela isiqunto, abadlali be-Senegal bathoma ukugandelela u-Ndala nabadlali abaphikisana nabo, begodu umrhelebhi omkhulu u-Pape Thiaw wayala isiqhema sakhe bona siphume enkundleni. Umdlalo wamiswa isikhathi esingaba mizuzu eli-14 ngesikhathi inkanyezi ye-Senegal u-Sadio Mané ikhuthaza abadlali bakhe ekamelweni lokugqoka bona babuyele enkundleni, wabatjela bona: &quot;Sizokudlala njengamadoda!&quot; Ngesikhathi sokulibaziseka, abalandeli be-Senegal balinga ukuhlasela inkundla begodu balwa namapholisa we-Morocco nabasekeli, begodu kwaba nokulwa ebhokisini labezindaba . 


Iinkhalazo zika-Mané zagcina ziphumelele, begodu lokha abadlali be-Senegal nababuyela enkundleni, umgadli u-Édouard Mendy watjengiswa ikhadi eliphuzi ngokulibazisa umdlalo. Naphezu kokutjheja, u-Mendy waragela phambili nokujamelana ngokwala ukubuyela emnqophweni wakhe. U-Brahim Díaz ekugcineni wathatha iphenalithi ngemva kwemizuzu ema-21 ngemva kokuphela komthetho, kodwana umzamo wakhe wesitayela se-Panenka wasindiswa ngu-Mendy, begodu isikhathi esijayelekileko saphela amaphuzu asesezingeni eliphezulu ku-0-0.[1]


Ngesikhathi esingezelelweko, u-Pape Gueye washaya igoli elilodwa lomdlalo we-Senegal ngomzuzu wama-94, wagoqa ngenyawo lesokunxele phezulu ekhoneni eliphezulu-kwesokudla ukusuka ngaphakathi nje kwendawo yephenalithi ukunikela i-Senegal ipumelelo ye-1-0 kanye nesicoco sayo sesibili se-Africa Cup of Nations.[1] Kuwo woke umdlalo, abafana bebholo be-Morocco nabadlali ababili be-Morocco, u-Achraf Hakimi no-Ismael Saibari, ngamunye bebazame ukulahla ithawula lezandla lomgadli we-Senegalese u-Édouard Mendy, umgadli othatha isikhundla sakhe u-Yehvann Diouf angenelela kanengi ukulithatha. U-Diouf wabamba ithawula phezulu eceleni kwendebe esithombeni sakhe sokunqoba.[2]</text>
      <sha1>gy0zlnkxakab4tzd95i8qinxav3m94l</sha1>
    </revision>
    <revision>
      <id>6329</id>
      <parentid>6328</parentid>
      <timestamp>2026-03-25T05:50:18Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1345183582|2025 Africa Cup of Nations final]]&quot;</comment>
      <origin>6329</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6300" sha1="arw3cpfonraqbcg9w10hyypr992kb7z" xml:space="preserve">'''Umdlalo wamanqamu we-Africa Cup of Nations we-2025''' bekungumdlalo webholo odlalwe mhlazi-18 kuTjhirhweni 2026 e- Prince Moulay Abdellah Stadium e- Rabat, e-Morocco. Yakhetha abaphumeleleko be- 2025 African Cup of Nations (AFCON), i-edishini yama-35 yomqhudelwano we-Afrika owenziwa qobe minyaka emibili ohlelwe yi- Confederation of African Football (CAF), begodu bewuphaliswa hlangana ne -Senegal ne- Morocco .

Umdlalo lo bewuhlaselwe ziimpikiswano, khulukhulu isiqunto se-Senegal sokuphuma enkundleni ngokutjhikijela kokubili igoli elingavunyelwako kanye nesiqunto esilimazako se-VAR ngesikhathi sokujama . I-Senegal yabuyela enkundleni, begodu yadlala umdlalo ekuthomeni ngokunqoba nge-1-0 ngemva kwesikhathi esingezelelweko .   Ukuphuma kanye nokuhlukunyezwa kwabalandeli kwachazwa &quot;njengokungamukeleki&quot; ngumongameli we-FIFA u-Gianni Infantino, begodu kwathatha amagadango wezomthetho avela ku -Royal Moroccan Football Federation kanye nokuphenywa kwe-CAF. &lt;ref name=&quot;CNN&quot;&gt;''Church, Ben (19 January 2026).'' &quot;Player protests, an awful penalty and fan uproar: What happened in the most chaotic AFCON final in history&quot;''. CNN. Retrieved 21 January 2026.''&lt;/ref&gt;

Mhlana ali-17 kuNtaka 2026, iBhodi yokuDlulisa amaCala ye-CAF yaqunta bona i-Senegal ilahlekelwe ma-final ngezenzo zayo, begodu esikhundleni salokho izokunikelwa njengomnqobi we-3-0 we-Morocco.   Ngelanga elilandelako, i -Senegalese Football Federation yamemezela bona izokudlulisa isiqunto eKhotho yokuLamula yezeMidlalo . 

== Ikundla ==
I-Prince Moulay Abdellah Stadium yinkundla yebholo ese-Rabat, e-Morocco, enendawo yokuhlala engu-69,500. Ivulwe mhlazi-5 kuNobayeni 2025, yindawo yekhaya lesiqhema sebholo se-Morocco . Iyingcenye yendawo ekulu yezemidlalo efaka hlangana inkundla yezemidlalo, inkundla yangaphakathi ye-Salle Moulay Abdellah, kanye nedamu lokubhukuda elilingana nama-Olimpiki. Ngenye yeenkundla ezikulu khulu e-Morocco. &lt;sup class=&quot;noprint Inline-Template Template-Fact&quot; style=&quot;white-space:nowrap;&quot;&gt;&amp;#x5B; ''&lt;nowiki&gt;&lt;span title=&quot;This claim needs references to reliable sources. (March 2026)&quot;&gt;ukudzubhula kuyatlhogeka&lt;/span&gt;&lt;/nowiki&gt;'' &amp;#x5D;&lt;/sup&gt;

== Iimphathiswa zomdlalo ==
I-CAF imemezele irhelo elipheleleko labanompempe bomdlalo mhlana ali-18 kuTjhirhweni 2026, unompempe u-Jean-Jacques Ndala we- Democratic Republic of the Congo abe ngunompempe omkhulu.  Wasizwa emigqeni ngu-Guylain Bongele Ngila no-Gradel Mwanya Mbilizi, nabo abavela e-DR Congo. Umsizi wesithathu onompempe (oseleko) bekungu-Styven Moutsassi we- Republic of the Congo .  Ezinye iimphathiswa bekungu -Abongile Tom weSewula Afrika njengonompempe wesine, u-Pierre Atcho we -Gabon njengomsizi we-video referee (VAR), kanye neemphathiswa ezimbili njengomsizi wevidiyo (AVAR): u-Letticia Viana we- [[Eswatini]] no-Stephen Yiembé we [[Kenya|-Kenya]] . &lt;ref name=&quot;JJN&quot; /&gt;

== Indlela eya ekugcineni ==

=== I-Senegal ===

== Ukumadana ==

=== Isirhunyezo ===
Isikolo sahlala sisezingeni eliphezulu ku-0-0 isikhathi esinengi esijayelekileko, umdlalo waphela ngokuhlukaniswa okulinganako 50-50. Ibholo lasebenzisa isikhathi salo esincani engcenyeni ye-Senegal, lapho i-Senegal ibambe ibholo ngemidlalo emide yokuzivikela ngaphambi kokuthi ilinike i-offense ye-Morocco ebegade ihluleka ngokuphindaphindiweko ngokunyakaza okufitjhani phezulu enkundleni. Ngesiwombe sesibili, i-Senegal yabusa ibholo ngesikhathi i-Morocco iphinda kathathu inani lamabholo. Umgadli we-Morocco u-Yassine Bounou wenze ama-save amanengi aqakathekileko, ngesikhathi i-Senegal ithembele khulu emagodini wayo ukugcina umdlalo ungafaki amagoli. 

Ngomzuzu wesihlanu wesikhathi sokumisa, i-Senegal yabonakala ithumba ipumelelo ngokukhahlela ekhoneni . Ekulungiseleleni umdlalo, umvikeli we-Morocco u-Achraf Hakimi wawisa phasi ngesikhathi aphikisana nokukhahlelwa nomgadli we-Senegal u-Abdoulaye Seck . Msinyana ngemva kobana u-Hakimi awe, u-Seck wahlangabezana nokukhahlelwa okungenako begodu wayikhipha ngehloko ngaphandle kwe-crossbar ukubeka igoli ku -Ismaïla Sarr . Unompempe u-Jean-Jacques Ndala wenze i-foul ephikisanako ngokujamelana no-Seck, okwenza bona igoli lingavunyelwa. U-Ndala wahlatjwa ngokuthi washaya ikhwela lakhe ngaphambi kokuthi umdlalo uphele, okwenza bona i-VAR ingakghoni ukubuyekeza ubujamo begoli. 

Ngemva kwemizuzwana embalwa, ngomzuzu wesibhozo wesikhathi sokumisa, umvikeli we-Senegalese u-El Hadji Malick Diouf wabamba umgadli we-Morocco u-Brahim Díaz endaweni yephenalithi, okwenza bona kubuyekezwe i-VAR. I-Senegal yahlawuliswa ngephenalithi eyathathwa ngu-Díaz. Ukutjhikijela isiqunto, abadlali be-Senegal bathoma ukugandelela u-Ndala nabadlali abaphikisana nabo, begodu umrhelebhi omkhulu u-Pape Thiaw wayala isiqhema sakhe bona siphume enkundleni. Umdlalo wamiswa isikhathi esingaba mizuzu eli-14 ngesikhathi inkanyezi ye-Senegal u-Sadio Mané ikhuthaza abadlali bakhe ekamelweni lokugqoka bona babuyele enkundleni, wabatjela bona: &quot;Sizokudlala njengamadoda!&quot; Ngesikhathi sokulibaziseka, abalandeli be-Senegal balinga ukuhlasela inkundla begodu balwa namapholisa we-Morocco nabasekeli, begodu kwaba nokulwa ebhokisini labezindaba . 


Iinkhalazo zika-Mané zagcina ziphumelele, begodu lokha abadlali be-Senegal nababuyela enkundleni, umgadli u-Édouard Mendy watjengiswa ikhadi eliphuzi ngokulibazisa umdlalo. Naphezu kokutjheja, u-Mendy waragela phambili nokujamelana ngokwala ukubuyela emnqophweni wakhe. U-Brahim Díaz ekugcineni wathatha iphenalithi ngemva kwemizuzu ema-21 ngemva kokuphela komthetho, kodwana umzamo wakhe wesitayela se-Panenka wasindiswa ngu-Mendy, begodu isikhathi esijayelekileko saphela amaphuzu asesezingeni eliphezulu ku-0-0.[1]


Ngesikhathi esingezelelweko, u-Pape Gueye washaya igoli elilodwa lomdlalo we-Senegal ngomzuzu wama-94, wagoqa ngenyawo lesokunxele phezulu ekhoneni eliphezulu-kwesokudla ukusuka ngaphakathi nje kwendawo yephenalithi ukunikela i-Senegal ipumelelo ye-1-0 kanye nesicoco sayo sesibili se-Africa Cup of Nations.[1] Kuwo woke umdlalo, abafana bebholo be-Morocco nabadlali ababili be-Morocco, u-Achraf Hakimi no-Ismael Saibari, ngamunye bebazame ukulahla ithawula lezandla lomgadli we-Senegalese u-Édouard Mendy, umgadli othatha isikhundla sakhe u-Yehvann Diouf angenelela kanengi ukulithatha. U-Diouf wabamba ithawula phezulu eceleni kwendebe esithombeni sakhe sokunqoba.[2]</text>
      <sha1>arw3cpfonraqbcg9w10hyypr992kb7z</sha1>
    </revision>
    <revision>
      <id>6330</id>
      <parentid>6329</parentid>
      <timestamp>2026-03-25T05:51:41Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1345183582|2025 Africa Cup of Nations final]]&quot;</comment>
      <origin>6330</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6280" sha1="d557gm7q3lugkjxgdhkf4mn2fl8ej34" xml:space="preserve">'''Umdlalo wamanqamu we-Africa Cup of Nations we-2025''' bekungumdlalo webholo odlalwe mhlazi-18 kuTjhirhweni 2026 e- Prince Moulay Abdellah Stadium e- Rabat, e-Morocco. Yakhetha abaphumeleleko be- 2025 African Cup of Nations (AFCON), i-edishini yama-35 yomqhudelwano we-Afrika owenziwa qobe minyaka emibili ohlelwe yi- Confederation of African Football (CAF), begodu bewuphaliswa hlangana ne -Senegal ne- Morocco .

Umdlalo lo bewuhlaselwe ziimpikiswano, khulukhulu isiqunto se-Senegal sokuphuma enkundleni ngokutjhikijela kokubili igoli elingavunyelwako kanye nesiqunto esilimazako se-VAR ngesikhathi sokujama . I-Senegal yabuyela enkundleni, begodu yadlala umdlalo ekuthomeni ngokunqoba nge-1-0 ngemva kwesikhathi esingezelelweko .   Ukuphuma kanye nokuhlukunyezwa kwabalandeli kwachazwa &quot;njengokungamukeleki&quot; ngumongameli we-FIFA u-Gianni Infantino, begodu kwathatha amagadango wezomthetho avela ku -Royal Moroccan Football Federation kanye nokuphenywa kwe-CAF. &lt;ref name=&quot;CNN&quot;&gt;''Church, Ben (19 January 2026).'' &quot;Player protests, an awful penalty and fan uproar: What happened in the most chaotic AFCON final in history&quot;''. CNN. Retrieved 21 January 2026.''&lt;/ref&gt;

Mhlana ali-17 kuNtaka 2026, iBhodi yokuDlulisa amaCala ye-CAF yaqunta bona i-Senegal ilahlekelwe ma-final ngezenzo zayo, begodu esikhundleni salokho izokunikelwa njengomnqobi we-3-0 we-Morocco.   Ngelanga elilandelako, i -Senegalese Football Federation yamemezela bona izokudlulisa isiqunto eKhotho yokuLamula yezeMidlalo . 

== Ikundla ==
I-Prince Moulay Abdellah Stadium yinkundla yebholo ese-Rabat, e-Morocco, enendawo yokuhlala engu-69,500. Ivulwe mhlazi-5 kuNobayeni 2025, yindawo yekhaya lesiqhema sebholo se-Morocco . Iyingcenye yendawo ekulu yezemidlalo efaka hlangana inkundla yezemidlalo, inkundla yangaphakathi ye-Salle Moulay Abdellah, kanye nedamu lokubhukuda elilingana nama-Olimpiki. Ngenye yeenkundla ezikulu khulu e-Morocco. 

== Iimphathiswa zomdlalo ==
I-CAF imemezele irhelo elipheleleko labanompempe bomdlalo mhlana ali-18 kuTjhirhweni 2026, unompempe u-Jean-Jacques Ndala we- Democratic Republic of the Congo abe ngunompempe omkhulu.  Wasizwa emigqeni ngu-Guylain Bongele Ngila no-Gradel Mwanya Mbilizi, nabo abavela e-DR Congo. Umsizi wesithathu onompempe (oseleko) bekungu-Styven Moutsassi we- Republic of the Congo . &lt;ref name=&quot;JJN&quot;&gt;&quot;Referee Jean-Jacques Ndala appointed to officiate TotalEnergies CAF AFCON 2025 Final&quot;''. CAFonline.com. Confederation of African Football. 18 January 2026. Retrieved 18 January 2026.''&lt;/ref&gt; Ezinye iimphathiswa bekungu -Abongile Tom weSewula Afrika njengonompempe wesine, u-Pierre Atcho we -Gabon njengomsizi we-video referee (VAR), kanye neemphathiswa ezimbili njengomsizi wevidiyo (AVAR): u-Letticia Viana we- [[Eswatini]] no-Stephen Yiembé we [[Kenya|-Kenya]] . &lt;ref name=&quot;JJN&quot; /&gt;

== Indlela eya ekugcineni ==

=== I-Senegal ===

== Ukumadana ==

=== Isirhunyezo ===
Isikolo sahlala sisezingeni eliphezulu ku-0-0 isikhathi esinengi esijayelekileko, umdlalo waphela ngokuhlukaniswa okulinganako 50-50. Ibholo lasebenzisa isikhathi salo esincani engcenyeni ye-Senegal, lapho i-Senegal ibambe ibholo ngemidlalo emide yokuzivikela ngaphambi kokuthi ilinike i-offense ye-Morocco ebegade ihluleka ngokuphindaphindiweko ngokunyakaza okufitjhani phezulu enkundleni. Ngesiwombe sesibili, i-Senegal yabusa ibholo ngesikhathi i-Morocco iphinda kathathu inani lamabholo. Umgadli we-Morocco u-Yassine Bounou wenze ama-save amanengi aqakathekileko, ngesikhathi i-Senegal ithembele khulu emagodini wayo ukugcina umdlalo ungafaki amagoli. 

Ngomzuzu wesihlanu wesikhathi sokumisa, i-Senegal yabonakala ithumba ipumelelo ngokukhahlela ekhoneni . Ekulungiseleleni umdlalo, umvikeli we-Morocco u-Achraf Hakimi wawisa phasi ngesikhathi aphikisana nokukhahlelwa nomgadli we-Senegal u-Abdoulaye Seck . Msinyana ngemva kobana u-Hakimi awe, u-Seck wahlangabezana nokukhahlelwa okungenako begodu wayikhipha ngehloko ngaphandle kwe-crossbar ukubeka igoli ku -Ismaïla Sarr . Unompempe u-Jean-Jacques Ndala wenze i-foul ephikisanako ngokujamelana no-Seck, okwenza bona igoli lingavunyelwa. U-Ndala wahlatjwa ngokuthi washaya ikhwela lakhe ngaphambi kokuthi umdlalo uphele, okwenza bona i-VAR ingakghoni ukubuyekeza ubujamo begoli. 

Ngemva kwemizuzwana embalwa, ngomzuzu wesibhozo wesikhathi sokumisa, umvikeli we-Senegalese u-El Hadji Malick Diouf wabamba umgadli we-Morocco u-Brahim Díaz endaweni yephenalithi, okwenza bona kubuyekezwe i-VAR. I-Senegal yahlawuliswa ngephenalithi eyathathwa ngu-Díaz. Ukutjhikijela isiqunto, abadlali be-Senegal bathoma ukugandelela u-Ndala nabadlali abaphikisana nabo, begodu umrhelebhi omkhulu u-Pape Thiaw wayala isiqhema sakhe bona siphume enkundleni. Umdlalo wamiswa isikhathi esingaba mizuzu eli-14 ngesikhathi inkanyezi ye-Senegal u-Sadio Mané ikhuthaza abadlali bakhe ekamelweni lokugqoka bona babuyele enkundleni, wabatjela bona: &quot;Sizokudlala njengamadoda!&quot; Ngesikhathi sokulibaziseka, abalandeli be-Senegal balinga ukuhlasela inkundla begodu balwa namapholisa we-Morocco nabasekeli, begodu kwaba nokulwa ebhokisini labezindaba . 


Iinkhalazo zika-Mané zagcina ziphumelele, begodu lokha abadlali be-Senegal nababuyela enkundleni, umgadli u-Édouard Mendy watjengiswa ikhadi eliphuzi ngokulibazisa umdlalo. Naphezu kokutjheja, u-Mendy waragela phambili nokujamelana ngokwala ukubuyela emnqophweni wakhe. U-Brahim Díaz ekugcineni wathatha iphenalithi ngemva kwemizuzu ema-21 ngemva kokuphela komthetho, kodwana umzamo wakhe wesitayela se-Panenka wasindiswa ngu-Mendy, begodu isikhathi esijayelekileko saphela amaphuzu asesezingeni eliphezulu ku-0-0.[1]


Ngesikhathi esingezelelweko, u-Pape Gueye washaya igoli elilodwa lomdlalo we-Senegal ngomzuzu wama-94, wagoqa ngenyawo lesokunxele phezulu ekhoneni eliphezulu-kwesokudla ukusuka ngaphakathi nje kwendawo yephenalithi ukunikela i-Senegal ipumelelo ye-1-0 kanye nesicoco sayo sesibili se-Africa Cup of Nations.[1] Kuwo woke umdlalo, abafana bebholo be-Morocco nabadlali ababili be-Morocco, u-Achraf Hakimi no-Ismael Saibari, ngamunye bebazame ukulahla ithawula lezandla lomgadli we-Senegalese u-Édouard Mendy, umgadli othatha isikhundla sakhe u-Yehvann Diouf angenelela kanengi ukulithatha. U-Diouf wabamba ithawula phezulu eceleni kwendebe esithombeni sakhe sokunqoba.[2]</text>
      <sha1>d557gm7q3lugkjxgdhkf4mn2fl8ej34</sha1>
    </revision>
    <revision>
      <id>6331</id>
      <parentid>6330</parentid>
      <timestamp>2026-03-25T05:52:22Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6331</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6294" sha1="g7b3gvz04bmqgelk3kzjtfoatvxmrxu" xml:space="preserve">'''Umdlalo wamanqamu we-Africa Cup of Nations we-2025''' bekungumdlalo webholo odlalwe mhlazi-18 kuTjhirhweni 2026 e- Prince Moulay Abdellah Stadium e- Rabat, e-Morocco. Yakhetha abaphumeleleko be- 2025 African Cup of Nations (AFCON), i-edishini yama-35 yomqhudelwano we-Afrika owenziwa qobe minyaka emibili ohlelwe yi- Confederation of African Football (CAF), begodu bewuphaliswa hlangana ne -Senegal ne- Morocco .

Umdlalo lo bewuhlaselwe ziimpikiswano, khulukhulu isiqunto se-Senegal sokuphuma enkundleni ngokutjhikijela kokubili igoli elingavunyelwako kanye nesiqunto esilimazako se-VAR ngesikhathi sokujama . I-Senegal yabuyela enkundleni, begodu yadlala umdlalo ekuthomeni ngokunqoba nge-1-0 ngemva kwesikhathi esingezelelweko .   Ukuphuma kanye nokuhlukunyezwa kwabalandeli kwachazwa &quot;njengokungamukeleki&quot; ngumongameli we-FIFA u-Gianni Infantino, begodu kwathatha amagadango wezomthetho avela ku -Royal Moroccan Football Federation kanye nokuphenywa kwe-CAF. &lt;ref name=&quot;CNN&quot;&gt;''Church, Ben (19 January 2026).'' &quot;Player protests, an awful penalty and fan uproar: What happened in the most chaotic AFCON final in history&quot;''. CNN. Retrieved 21 January 2026.''&lt;/ref&gt;

Mhlana ali-17 kuNtaka 2026, iBhodi yokuDlulisa amaCala ye-CAF yaqunta bona i-Senegal ilahlekelwe ma-final ngezenzo zayo, begodu esikhundleni salokho izokunikelwa njengomnqobi we-3-0 we-Morocco.   Ngelanga elilandelako, i -Senegalese Football Federation yamemezela bona izokudlulisa isiqunto eKhotho yokuLamula yezeMidlalo . 

== Ikundla ==
I-Prince Moulay Abdellah Stadium yinkundla yebholo ese-Rabat, e-Morocco, enendawo yokuhlala engu-69,500. Ivulwe mhlazi-5 kuNobayeni 2025, yindawo yekhaya lesiqhema sebholo se-Morocco . Iyingcenye yendawo ekulu yezemidlalo efaka hlangana inkundla yezemidlalo, inkundla yangaphakathi ye-Salle Moulay Abdellah, kanye nedamu lokubhukuda elilingana nama-Olimpiki. Ngenye yeenkundla ezikulu khulu e-Morocco. 

== Iimphathiswa zomdlalo ==
I-CAF imemezele irhelo elipheleleko labanompempe bomdlalo mhlana ali-18 kuTjhirhweni 2026, unompempe u-Jean-Jacques Ndala we- Democratic Republic of the Congo abe ngunompempe omkhulu.  Wasizwa emigqeni ngu-Guylain Bongele Ngila no-Gradel Mwanya Mbilizi, nabo abavela e-DR Congo. Umsizi wesithathu onompempe (oseleko) bekungu-Styven Moutsassi we- Republic of the Congo . &lt;ref name=&quot;JJN&quot;&gt;&quot;Referee Jean-Jacques Ndala appointed to officiate TotalEnergies CAF AFCON 2025 Final&quot;''. CAFonline.com. Confederation of African Football. 18 January 2026. Retrieved 18 January 2026.''&lt;/ref&gt; Ezinye iimphathiswa bekungu -Abongile Tom weSewula Afrika njengonompempe wesine, u-Pierre Atcho we -Gabon njengomsizi we-video referee (VAR), kanye neemphathiswa ezimbili njengomsizi wevidiyo (AVAR): u-Letticia Viana we- [[Eswatini]] no-Stephen Yiembé we [[Kenya|-Kenya]] . &lt;ref name=&quot;JJN&quot; /&gt;

== Indlela eya ekugcineni ==

=== I-Senegal ===

== Ukumadana ==

=== Isirhunyezo ===
Isikolo sahlala sisezingeni eliphezulu ku-0-0 isikhathi esinengi esijayelekileko, umdlalo waphela ngokuhlukaniswa okulinganako 50-50. Ibholo lasebenzisa isikhathi salo esincani engcenyeni ye-Senegal, lapho i-Senegal ibambe ibholo ngemidlalo emide yokuzivikela ngaphambi kokuthi ilinike i-offense ye-Morocco ebegade ihluleka ngokuphindaphindiweko ngokunyakaza okufitjhani phezulu enkundleni. Ngesiwombe sesibili, i-Senegal yabusa ibholo ngesikhathi i-Morocco iphinda kathathu inani lamabholo. Umgadli we-Morocco u-Yassine Bounou wenze ama-save amanengi aqakathekileko, ngesikhathi i-Senegal ithembele khulu emagodini wayo ukugcina umdlalo ungafaki amagoli. 

Ngomzuzu wesihlanu wesikhathi sokumisa, i-Senegal yabonakala ithumba ipumelelo ngokukhahlela ekhoneni . Ekulungiseleleni umdlalo, umvikeli we-Morocco u-Achraf Hakimi wawisa phasi ngesikhathi aphikisana nokukhahlelwa nomgadli we-Senegal u-Abdoulaye Seck . Msinyana ngemva kobana u-Hakimi awe, u-Seck wahlangabezana nokukhahlelwa okungenako begodu wayikhipha ngehloko ngaphandle kwe-crossbar ukubeka igoli ku -Ismaïla Sarr . Unompempe u-Jean-Jacques Ndala wenze i-foul ephikisanako ngokujamelana no-Seck, okwenza bona igoli lingavunyelwa. U-Ndala wahlatjwa ngokuthi washaya ikhwela lakhe ngaphambi kokuthi umdlalo uphele, okwenza bona i-VAR ingakghoni ukubuyekeza ubujamo begoli. 

Ngemva kwemizuzwana embalwa, ngomzuzu wesibhozo wesikhathi sokumisa, umvikeli we-Senegalese u-El Hadji Malick Diouf wabamba umgadli we-Morocco u-Brahim Díaz endaweni yephenalithi, okwenza bona kubuyekezwe i-VAR. I-Senegal yahlawuliswa ngephenalithi eyathathwa ngu-Díaz. Ukutjhikijela isiqunto, abadlali be-Senegal bathoma ukugandelela u-Ndala nabadlali abaphikisana nabo, begodu umrhelebhi omkhulu u-Pape Thiaw wayala isiqhema sakhe bona siphume enkundleni. Umdlalo wamiswa isikhathi esingaba mizuzu eli-14 ngesikhathi inkanyezi ye-Senegal u-Sadio Mané ikhuthaza abadlali bakhe ekamelweni lokugqoka bona babuyele enkundleni, wabatjela bona: &quot;Sizokudlala njengamadoda!&quot; Ngesikhathi sokulibaziseka, abalandeli be-Senegal balinga ukuhlasela inkundla begodu balwa namapholisa we-Morocco nabasekeli, begodu kwaba nokulwa ebhokisini labezindaba . 


Iinkhalazo zika-Mané zagcina ziphumelele, begodu lokha abadlali be-Senegal nababuyela enkundleni, umgadli u-Édouard Mendy watjengiswa ikhadi eliphuzi ngokulibazisa umdlalo. Naphezu kokutjheja, u-Mendy waragela phambili nokujamelana ngokwala ukubuyela emnqophweni wakhe. U-Brahim Díaz ekugcineni wathatha iphenalithi ngemva kwemizuzu ema-21 ngemva kokuphela komthetho, kodwana umzamo wakhe wesitayela se-Panenka wasindiswa ngu-Mendy, begodu isikhathi esijayelekileko saphela amaphuzu asesezingeni eliphezulu ku-0-0.[1]


Ngesikhathi esingezelelweko, u-Pape Gueye washaya igoli elilodwa lomdlalo we-Senegal ngomzuzu wama-94, wagoqa ngenyawo lesokunxele phezulu ekhoneni eliphezulu-kwesokudla ukusuka ngaphakathi nje kwendawo yephenalithi ukunikela i-Senegal ipumelelo ye-1-0 kanye nesicoco sayo sesibili se-Africa Cup of Nations.[1] Kuwo woke umdlalo, abafana bebholo be-Morocco nabadlali ababili be-Morocco, u-Achraf Hakimi no-Ismael Saibari, ngamunye bebazame ukulahla ithawula lezandla lomgadli we-Senegalese u-Édouard Mendy, umgadli othatha isikhundla sakhe u-Yehvann Diouf angenelela kanengi ukulithatha. U-Diouf wabamba ithawula phezulu eceleni kwendebe esithombeni sakhe sokunqoba.[2]
== Inkomba ==</text>
      <sha1>g7b3gvz04bmqgelk3kzjtfoatvxmrxu</sha1>
    </revision>
    <revision>
      <id>6332</id>
      <parentid>6331</parentid>
      <timestamp>2026-03-25T05:54:48Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>/* Ukumadana */</comment>
      <origin>6332</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6291" sha1="c8eq60yt57kit0jhhj2v641n2ky1em1" xml:space="preserve">'''Umdlalo wamanqamu we-Africa Cup of Nations we-2025''' bekungumdlalo webholo odlalwe mhlazi-18 kuTjhirhweni 2026 e- Prince Moulay Abdellah Stadium e- Rabat, e-Morocco. Yakhetha abaphumeleleko be- 2025 African Cup of Nations (AFCON), i-edishini yama-35 yomqhudelwano we-Afrika owenziwa qobe minyaka emibili ohlelwe yi- Confederation of African Football (CAF), begodu bewuphaliswa hlangana ne -Senegal ne- Morocco .

Umdlalo lo bewuhlaselwe ziimpikiswano, khulukhulu isiqunto se-Senegal sokuphuma enkundleni ngokutjhikijela kokubili igoli elingavunyelwako kanye nesiqunto esilimazako se-VAR ngesikhathi sokujama . I-Senegal yabuyela enkundleni, begodu yadlala umdlalo ekuthomeni ngokunqoba nge-1-0 ngemva kwesikhathi esingezelelweko .   Ukuphuma kanye nokuhlukunyezwa kwabalandeli kwachazwa &quot;njengokungamukeleki&quot; ngumongameli we-FIFA u-Gianni Infantino, begodu kwathatha amagadango wezomthetho avela ku -Royal Moroccan Football Federation kanye nokuphenywa kwe-CAF. &lt;ref name=&quot;CNN&quot;&gt;''Church, Ben (19 January 2026).'' &quot;Player protests, an awful penalty and fan uproar: What happened in the most chaotic AFCON final in history&quot;''. CNN. Retrieved 21 January 2026.''&lt;/ref&gt;

Mhlana ali-17 kuNtaka 2026, iBhodi yokuDlulisa amaCala ye-CAF yaqunta bona i-Senegal ilahlekelwe ma-final ngezenzo zayo, begodu esikhundleni salokho izokunikelwa njengomnqobi we-3-0 we-Morocco.   Ngelanga elilandelako, i -Senegalese Football Federation yamemezela bona izokudlulisa isiqunto eKhotho yokuLamula yezeMidlalo . 

== Ikundla ==
I-Prince Moulay Abdellah Stadium yinkundla yebholo ese-Rabat, e-Morocco, enendawo yokuhlala engu-69,500. Ivulwe mhlazi-5 kuNobayeni 2025, yindawo yekhaya lesiqhema sebholo se-Morocco . Iyingcenye yendawo ekulu yezemidlalo efaka hlangana inkundla yezemidlalo, inkundla yangaphakathi ye-Salle Moulay Abdellah, kanye nedamu lokubhukuda elilingana nama-Olimpiki. Ngenye yeenkundla ezikulu khulu e-Morocco. 

== Iimphathiswa zomdlalo ==
I-CAF imemezele irhelo elipheleleko labanompempe bomdlalo mhlana ali-18 kuTjhirhweni 2026, unompempe u-Jean-Jacques Ndala we- Democratic Republic of the Congo abe ngunompempe omkhulu.  Wasizwa emigqeni ngu-Guylain Bongele Ngila no-Gradel Mwanya Mbilizi, nabo abavela e-DR Congo. Umsizi wesithathu onompempe (oseleko) bekungu-Styven Moutsassi we- Republic of the Congo . &lt;ref name=&quot;JJN&quot;&gt;&quot;Referee Jean-Jacques Ndala appointed to officiate TotalEnergies CAF AFCON 2025 Final&quot;''. CAFonline.com. Confederation of African Football. 18 January 2026. Retrieved 18 January 2026.''&lt;/ref&gt; Ezinye iimphathiswa bekungu -Abongile Tom weSewula Afrika njengonompempe wesine, u-Pierre Atcho we -Gabon njengomsizi we-video referee (VAR), kanye neemphathiswa ezimbili njengomsizi wevidiyo (AVAR): u-Letticia Viana we- [[Eswatini]] no-Stephen Yiembé we [[Kenya|-Kenya]] . &lt;ref name=&quot;JJN&quot; /&gt;

== Indlela eya ekugcineni ==

=== I-Senegal ===

== Ukumadana ==

=== Isirhunyezo ===
Isikolo sahlala sisezingeni eliphezulu ku-0-0 isikhathi esinengi esijayelekileko, umdlalo waphela ngokuhlukaniswa okulinganako 50-50. Ibholo lasebenzisa isikhathi salo esincani engcenyeni ye-Senegal, lapho i-Senegal ibambe ibholo ngemidlalo emide yokuzivikela ngaphambi kokuthi ilinike i-offense ye-Morocco ebegade ihluleka ngokuphindaphindiweko ngokunyakaza okufitjhani phezulu enkundleni. Ngesiwombe sesibili, i-Senegal yabusa ibholo ngesikhathi i-Morocco iphinda kathathu inani lamabholo. Umgadli we-Morocco u-Yassine Bounou wenze ama-save amanengi aqakathekileko, ngesikhathi i-Senegal ithembele khulu emagodini wayo ukugcina umdlalo ungafaki amagoli. 

Ngomzuzu wesihlanu wesikhathi sokumisa, i-Senegal yabonakala ithumba ipumelelo ngokukhahlela ekhoneni . Ekulungiseleleni umdlalo, umvikeli we-Morocco u-Achraf Hakimi wawisa phasi ngesikhathi aphikisana nokukhahlelwa nomgadli we-Senegal u-Abdoulaye Seck . Msinyana ngemva kobana u-Hakimi awe, u-Seck wahlangabezana nokukhahlelwa okungenako begodu wayikhipha ngehloko ngaphandle kwe-crossbar ukubeka igoli ku -Ismaïla Sarr . Unompempe u-Jean-Jacques Ndala wenze i-foul ephikisanako ngokujamelana no-Seck, okwenza bona igoli lingavunyelwa. U-Ndala wahlatjwa ngokuthi washaya ikhwela lakhe ngaphambi kokuthi umdlalo uphele, okwenza bona i-VAR ingakghoni ukubuyekeza ubujamo begoli. 

Ngemva kwemizuzwana embalwa, ngomzuzu wesibhozo wesikhathi sokumisa, umvikeli we-Senegalese u-El Hadji Malick Diouf wabamba umgadli we-Morocco u-Brahim Díaz endaweni yephenalithi, okwenza bona kubuyekezwe i-VAR. I-Senegal yahlawuliswa ngephenalithi eyathathwa ngu-Díaz. Ukutjhikijela isiqunto, abadlali be-Senegal bathoma ukugandelela u-Ndala nabadlali abaphikisana nabo, begodu umrhelebhi omkhulu u-Pape Thiaw wayala isiqhema sakhe bona siphume enkundleni. Umdlalo wamiswa isikhathi esingaba mizuzu eli-14 ngesikhathi inkanyezi ye-Senegal u-Sadio Mané ikhuthaza abadlali bakhe ekamelweni lokugqoka bona babuyele enkundleni, wabatjela bona: &quot;Sizokudlala njengamadoda!&quot; Ngesikhathi sokulibaziseka, abalandeli be-Senegal balinga ukuhlasela inkundla begodu balwa namapholisa we-Morocco nabasekeli, begodu kwaba nokulwa ebhokisini labezindaba . 


Iinkhalazo zika-Mané zagcina ziphumelele, begodu lokha abadlali be-Senegal nababuyela enkundleni, umgadli u-Édouard Mendy watjengiswa ikhadi eliphuzi ngokulibazisa umdlalo. Naphezu kokutjheja, u-Mendy waragela phambili nokujamelana ngokwala ukubuyela emnqophweni wakhe. U-Brahim Díaz ekugcineni wathatha iphenalithi ngemva kwemizuzu ema-21 ngemva kokuphela komthetho, kodwana umzamo wakhe wesitayela se-Panenka wasindiswa ngu-Mendy, begodu isikhathi esijayelekileko saphela amaphuzu asesezingeni eliphezulu ku-0-0.

Ngesikhathi esingezelelweko, u-Pape Gueye washaya igoli elilodwa lomdlalo we-Senegal ngomzuzu wama-94, wagoqa ngenyawo lesokunxele phezulu ekhoneni eliphezulu-kwesokudla ukusuka ngaphakathi nje kwendawo yephenalithi ukunikela i-Senegal ipumelelo ye-1-0 kanye nesicoco sayo sesibili se-Africa Cup of Nations.[1] Kuwo woke umdlalo, abafana bebholo be-Morocco nabadlali ababili be-Morocco, u-Achraf Hakimi no-Ismael Saibari, ngamunye bebazame ukulahla ithawula lezandla lomgadli we-Senegalese u-Édouard Mendy, umgadli othatha isikhundla sakhe u-Yehvann Diouf angenelela kanengi ukulithatha. U-Diouf wabamba ithawula phezulu eceleni kwendebe esithombeni sakhe sokunqoba.[2]

== Inkomba ==</text>
      <sha1>c8eq60yt57kit0jhhj2v641n2ky1em1</sha1>
    </revision>
    <revision>
      <id>6333</id>
      <parentid>6332</parentid>
      <timestamp>2026-03-25T05:55:00Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>/* Ukumadana */</comment>
      <origin>6333</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6290" sha1="dbahzb277ekoqdie50gqi3y2jq60b7q" xml:space="preserve">'''Umdlalo wamanqamu we-Africa Cup of Nations we-2025''' bekungumdlalo webholo odlalwe mhlazi-18 kuTjhirhweni 2026 e- Prince Moulay Abdellah Stadium e- Rabat, e-Morocco. Yakhetha abaphumeleleko be- 2025 African Cup of Nations (AFCON), i-edishini yama-35 yomqhudelwano we-Afrika owenziwa qobe minyaka emibili ohlelwe yi- Confederation of African Football (CAF), begodu bewuphaliswa hlangana ne -Senegal ne- Morocco .

Umdlalo lo bewuhlaselwe ziimpikiswano, khulukhulu isiqunto se-Senegal sokuphuma enkundleni ngokutjhikijela kokubili igoli elingavunyelwako kanye nesiqunto esilimazako se-VAR ngesikhathi sokujama . I-Senegal yabuyela enkundleni, begodu yadlala umdlalo ekuthomeni ngokunqoba nge-1-0 ngemva kwesikhathi esingezelelweko .   Ukuphuma kanye nokuhlukunyezwa kwabalandeli kwachazwa &quot;njengokungamukeleki&quot; ngumongameli we-FIFA u-Gianni Infantino, begodu kwathatha amagadango wezomthetho avela ku -Royal Moroccan Football Federation kanye nokuphenywa kwe-CAF. &lt;ref name=&quot;CNN&quot;&gt;''Church, Ben (19 January 2026).'' &quot;Player protests, an awful penalty and fan uproar: What happened in the most chaotic AFCON final in history&quot;''. CNN. Retrieved 21 January 2026.''&lt;/ref&gt;

Mhlana ali-17 kuNtaka 2026, iBhodi yokuDlulisa amaCala ye-CAF yaqunta bona i-Senegal ilahlekelwe ma-final ngezenzo zayo, begodu esikhundleni salokho izokunikelwa njengomnqobi we-3-0 we-Morocco.   Ngelanga elilandelako, i -Senegalese Football Federation yamemezela bona izokudlulisa isiqunto eKhotho yokuLamula yezeMidlalo . 

== Ikundla ==
I-Prince Moulay Abdellah Stadium yinkundla yebholo ese-Rabat, e-Morocco, enendawo yokuhlala engu-69,500. Ivulwe mhlazi-5 kuNobayeni 2025, yindawo yekhaya lesiqhema sebholo se-Morocco . Iyingcenye yendawo ekulu yezemidlalo efaka hlangana inkundla yezemidlalo, inkundla yangaphakathi ye-Salle Moulay Abdellah, kanye nedamu lokubhukuda elilingana nama-Olimpiki. Ngenye yeenkundla ezikulu khulu e-Morocco. 

== Iimphathiswa zomdlalo ==
I-CAF imemezele irhelo elipheleleko labanompempe bomdlalo mhlana ali-18 kuTjhirhweni 2026, unompempe u-Jean-Jacques Ndala we- Democratic Republic of the Congo abe ngunompempe omkhulu.  Wasizwa emigqeni ngu-Guylain Bongele Ngila no-Gradel Mwanya Mbilizi, nabo abavela e-DR Congo. Umsizi wesithathu onompempe (oseleko) bekungu-Styven Moutsassi we- Republic of the Congo . &lt;ref name=&quot;JJN&quot;&gt;&quot;Referee Jean-Jacques Ndala appointed to officiate TotalEnergies CAF AFCON 2025 Final&quot;''. CAFonline.com. Confederation of African Football. 18 January 2026. Retrieved 18 January 2026.''&lt;/ref&gt; Ezinye iimphathiswa bekungu -Abongile Tom weSewula Afrika njengonompempe wesine, u-Pierre Atcho we -Gabon njengomsizi we-video referee (VAR), kanye neemphathiswa ezimbili njengomsizi wevidiyo (AVAR): u-Letticia Viana we- [[Eswatini]] no-Stephen Yiembé we [[Kenya|-Kenya]] . &lt;ref name=&quot;JJN&quot; /&gt;

== Indlela eya ekugcineni ==

=== I-Senegal ===

== Ukumadana ==

=== Isirhunyezo ===
Isikolo sahlala sisezingeni eliphezulu ku-0-0 isikhathi esinengi esijayelekileko, umdlalo waphela ngokuhlukaniswa okulinganako 50-50. Ibholo lasebenzisa isikhathi salo esincani engcenyeni ye-Senegal, lapho i-Senegal ibambe ibholo ngemidlalo emide yokuzivikela ngaphambi kokuthi ilinike i-offense ye-Morocco ebegade ihluleka ngokuphindaphindiweko ngokunyakaza okufitjhani phezulu enkundleni. Ngesiwombe sesibili, i-Senegal yabusa ibholo ngesikhathi i-Morocco iphinda kathathu inani lamabholo. Umgadli we-Morocco u-Yassine Bounou wenze ama-save amanengi aqakathekileko, ngesikhathi i-Senegal ithembele khulu emagodini wayo ukugcina umdlalo ungafaki amagoli. 

Ngomzuzu wesihlanu wesikhathi sokumisa, i-Senegal yabonakala ithumba ipumelelo ngokukhahlela ekhoneni . Ekulungiseleleni umdlalo, umvikeli we-Morocco u-Achraf Hakimi wawisa phasi ngesikhathi aphikisana nokukhahlelwa nomgadli we-Senegal u-Abdoulaye Seck . Msinyana ngemva kobana u-Hakimi awe, u-Seck wahlangabezana nokukhahlelwa okungenako begodu wayikhipha ngehloko ngaphandle kwe-crossbar ukubeka igoli ku -Ismaïla Sarr . Unompempe u-Jean-Jacques Ndala wenze i-foul ephikisanako ngokujamelana no-Seck, okwenza bona igoli lingavunyelwa. U-Ndala wahlatjwa ngokuthi washaya ikhwela lakhe ngaphambi kokuthi umdlalo uphele, okwenza bona i-VAR ingakghoni ukubuyekeza ubujamo begoli. 

Ngemva kwemizuzwana embalwa, ngomzuzu wesibhozo wesikhathi sokumisa, umvikeli we-Senegalese u-El Hadji Malick Diouf wabamba umgadli we-Morocco u-Brahim Díaz endaweni yephenalithi, okwenza bona kubuyekezwe i-VAR. I-Senegal yahlawuliswa ngephenalithi eyathathwa ngu-Díaz. Ukutjhikijela isiqunto, abadlali be-Senegal bathoma ukugandelela u-Ndala nabadlali abaphikisana nabo, begodu umrhelebhi omkhulu u-Pape Thiaw wayala isiqhema sakhe bona siphume enkundleni. Umdlalo wamiswa isikhathi esingaba mizuzu eli-14 ngesikhathi inkanyezi ye-Senegal u-Sadio Mané ikhuthaza abadlali bakhe ekamelweni lokugqoka bona babuyele enkundleni, wabatjela bona: &quot;Sizokudlala njengamadoda!&quot; Ngesikhathi sokulibaziseka, abalandeli be-Senegal balinga ukuhlasela inkundla begodu balwa namapholisa we-Morocco nabasekeli, begodu kwaba nokulwa ebhokisini labezindaba . 

Iinkhalazo zika-Mané zagcina ziphumelele, begodu lokha abadlali be-Senegal nababuyela enkundleni, umgadli u-Édouard Mendy watjengiswa ikhadi eliphuzi ngokulibazisa umdlalo. Naphezu kokutjheja, u-Mendy waragela phambili nokujamelana ngokwala ukubuyela emnqophweni wakhe. U-Brahim Díaz ekugcineni wathatha iphenalithi ngemva kwemizuzu ema-21 ngemva kokuphela komthetho, kodwana umzamo wakhe wesitayela se-Panenka wasindiswa ngu-Mendy, begodu isikhathi esijayelekileko saphela amaphuzu asesezingeni eliphezulu ku-0-0.

Ngesikhathi esingezelelweko, u-Pape Gueye washaya igoli elilodwa lomdlalo we-Senegal ngomzuzu wama-94, wagoqa ngenyawo lesokunxele phezulu ekhoneni eliphezulu-kwesokudla ukusuka ngaphakathi nje kwendawo yephenalithi ukunikela i-Senegal ipumelelo ye-1-0 kanye nesicoco sayo sesibili se-Africa Cup of Nations.[1] Kuwo woke umdlalo, abafana bebholo be-Morocco nabadlali ababili be-Morocco, u-Achraf Hakimi no-Ismael Saibari, ngamunye bebazame ukulahla ithawula lezandla lomgadli we-Senegalese u-Édouard Mendy, umgadli othatha isikhundla sakhe u-Yehvann Diouf angenelela kanengi ukulithatha. U-Diouf wabamba ithawula phezulu eceleni kwendebe esithombeni sakhe sokunqoba.[2]

== Inkomba ==</text>
      <sha1>dbahzb277ekoqdie50gqi3y2jq60b7q</sha1>
    </revision>
    <revision>
      <id>6334</id>
      <parentid>6333</parentid>
      <timestamp>2026-03-25T05:56:52Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6334</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6398" sha1="l7q2a0ndlozxlmp4jatm5t16q9tvyr5" xml:space="preserve">'''Umdlalo wamanqamu we-Africa Cup of Nations we-2025''' bekungumdlalo webholo odlalwe mhlazi-18 kuTjhirhweni 2026 e- Prince Moulay Abdellah Stadium e- Rabat, e-Morocco. Yakhetha abaphumeleleko be- 2025 African Cup of Nations (AFCON), i-edishini yama-35 yomqhudelwano we-Afrika owenziwa qobe minyaka emibili ohlelwe yi- Confederation of African Football (CAF), begodu bewuphaliswa hlangana ne -Senegal ne- Morocco .

Umdlalo lo bewuhlaselwe ziimpikiswano, khulukhulu isiqunto se-Senegal sokuphuma enkundleni ngokutjhikijela kokubili igoli elingavunyelwako kanye nesiqunto esilimazako se-VAR ngesikhathi sokujama . I-Senegal yabuyela enkundleni, begodu yadlala umdlalo ekuthomeni ngokunqoba nge-1-0 ngemva kwesikhathi esingezelelweko .   Ukuphuma kanye nokuhlukunyezwa kwabalandeli kwachazwa &quot;njengokungamukeleki&quot; ngumongameli we-FIFA u-Gianni Infantino, begodu kwathatha amagadango wezomthetho avela ku -Royal Moroccan Football Federation kanye nokuphenywa kwe-CAF. &lt;ref name=&quot;CNN&quot;&gt;''Church, Ben (19 January 2026).'' &quot;Player protests, an awful penalty and fan uproar: What happened in the most chaotic AFCON final in history&quot;''. CNN. Retrieved 21 January 2026.''&lt;/ref&gt;

Mhlana ali-17 kuNtaka 2026, iBhodi yokuDlulisa amaCala ye-CAF yaqunta bona i-Senegal ilahlekelwe ma-final ngezenzo zayo, begodu esikhundleni salokho izokunikelwa njengomnqobi we-3-0 we-Morocco.   Ngelanga elilandelako, i -Senegalese Football Federation yamemezela bona izokudlulisa isiqunto eKhotho yokuLamula yezeMidlalo . 

== Ikundla ==
I-Prince Moulay Abdellah Stadium yinkundla yebholo ese-Rabat, e-Morocco, enendawo yokuhlala engu-69,500. Ivulwe mhlazi-5 kuNobayeni 2025, yindawo yekhaya lesiqhema sebholo se-Morocco . Iyingcenye yendawo ekulu yezemidlalo efaka hlangana inkundla yezemidlalo, inkundla yangaphakathi ye-Salle Moulay Abdellah, kanye nedamu lokubhukuda elilingana nama-Olimpiki. Ngenye yeenkundla ezikulu khulu e-Morocco. 

== Iimphathiswa zomdlalo ==
I-CAF imemezele irhelo elipheleleko labanompempe bomdlalo mhlana ali-18 kuTjhirhweni 2026, unompempe u-Jean-Jacques Ndala we- Democratic Republic of the Congo abe ngunompempe omkhulu.  Wasizwa emigqeni ngu-Guylain Bongele Ngila no-Gradel Mwanya Mbilizi, nabo abavela e-DR Congo. Umsizi wesithathu onompempe (oseleko) bekungu-Styven Moutsassi we- Republic of the Congo . &lt;ref name=&quot;JJN&quot;&gt;&quot;Referee Jean-Jacques Ndala appointed to officiate TotalEnergies CAF AFCON 2025 Final&quot;''. CAFonline.com. Confederation of African Football. 18 January 2026. Retrieved 18 January 2026.''&lt;/ref&gt; Ezinye iimphathiswa bekungu -Abongile Tom weSewula Afrika njengonompempe wesine, u-Pierre Atcho we -Gabon njengomsizi we-video referee (VAR), kanye neemphathiswa ezimbili njengomsizi wevidiyo (AVAR): u-Letticia Viana we- [[Eswatini]] no-Stephen Yiembé we [[Kenya|-Kenya]] . &lt;ref name=&quot;JJN&quot; /&gt;

== Indlela eya ekugcineni ==

=== I-Senegal ===

== Ukumadana ==

=== Isirhunyezo ===
Isikolo sahlala sisezingeni eliphezulu ku-0-0 isikhathi esinengi esijayelekileko, umdlalo waphela ngokuhlukaniswa okulinganako 50-50. Ibholo lasebenzisa isikhathi salo esincani engcenyeni ye-Senegal, lapho i-Senegal ibambe ibholo ngemidlalo emide yokuzivikela ngaphambi kokuthi ilinike i-offense ye-Morocco ebegade ihluleka ngokuphindaphindiweko ngokunyakaza okufitjhani phezulu enkundleni. Ngesiwombe sesibili, i-Senegal yabusa ibholo ngesikhathi i-Morocco iphinda kathathu inani lamabholo. Umgadli we-Morocco u-Yassine Bounou wenze ama-save amanengi aqakathekileko, ngesikhathi i-Senegal ithembele khulu emagodini wayo ukugcina umdlalo ungafaki amagoli. 

Ngomzuzu wesihlanu wesikhathi sokumisa, i-Senegal yabonakala ithumba ipumelelo ngokukhahlela ekhoneni . Ekulungiseleleni umdlalo, umvikeli we-Morocco u-Achraf Hakimi wawisa phasi ngesikhathi aphikisana nokukhahlelwa nomgadli we-Senegal u-Abdoulaye Seck . Msinyana ngemva kobana u-Hakimi awe, u-Seck wahlangabezana nokukhahlelwa okungenako begodu wayikhipha ngehloko ngaphandle kwe-crossbar ukubeka igoli ku -Ismaïla Sarr . Unompempe u-Jean-Jacques Ndala wenze i-foul ephikisanako ngokujamelana no-Seck, okwenza bona igoli lingavunyelwa. U-Ndala wahlatjwa ngokuthi washaya ikhwela lakhe ngaphambi kokuthi umdlalo uphele, okwenza bona i-VAR ingakghoni ukubuyekeza ubujamo begoli. 

Ngemva kwemizuzwana embalwa, ngomzuzu wesibhozo wesikhathi sokumisa, umvikeli we-Senegalese u-El Hadji Malick Diouf wabamba umgadli we-Morocco u-Brahim Díaz endaweni yephenalithi, okwenza bona kubuyekezwe i-VAR. I-Senegal yahlawuliswa ngephenalithi eyathathwa ngu-Díaz. Ukutjhikijela isiqunto, abadlali be-Senegal bathoma ukugandelela u-Ndala nabadlali abaphikisana nabo, begodu umrhelebhi omkhulu u-Pape Thiaw wayala isiqhema sakhe bona siphume enkundleni. Umdlalo wamiswa isikhathi esingaba mizuzu eli-14 ngesikhathi inkanyezi ye-Senegal u-Sadio Mané ikhuthaza abadlali bakhe ekamelweni lokugqoka bona babuyele enkundleni, wabatjela bona: &quot;Sizokudlala njengamadoda!&quot; Ngesikhathi sokulibaziseka, abalandeli be-Senegal balinga ukuhlasela inkundla begodu balwa namapholisa we-Morocco nabasekeli, begodu kwaba nokulwa ebhokisini labezindaba. &lt;ref&gt;https://mashable.com/article/senegal-morocco-africa-cup-of-nations-final-2025-live-stream-for-free&lt;/ref&gt;

Iinkhalazo zika-Mané zagcina ziphumelele, begodu lokha abadlali be-Senegal nababuyela enkundleni, umgadli u-Édouard Mendy watjengiswa ikhadi eliphuzi ngokulibazisa umdlalo. Naphezu kokutjheja, u-Mendy waragela phambili nokujamelana ngokwala ukubuyela emnqophweni wakhe. U-Brahim Díaz ekugcineni wathatha iphenalithi ngemva kwemizuzu ema-21 ngemva kokuphela komthetho, kodwana umzamo wakhe wesitayela se-Panenka wasindiswa ngu-Mendy, begodu isikhathi esijayelekileko saphela amaphuzu asesezingeni eliphezulu ku-0-0.

Ngesikhathi esingezelelweko, u-Pape Gueye washaya igoli elilodwa lomdlalo we-Senegal ngomzuzu wama-94, wagoqa ngenyawo lesokunxele phezulu ekhoneni eliphezulu-kwesokudla ukusuka ngaphakathi nje kwendawo yephenalithi ukunikela i-Senegal ipumelelo ye-1-0 kanye nesicoco sayo sesibili se-Africa Cup of Nations.[1] Kuwo woke umdlalo, abafana bebholo be-Morocco nabadlali ababili be-Morocco, u-Achraf Hakimi no-Ismael Saibari, ngamunye bebazame ukulahla ithawula lezandla lomgadli we-Senegalese u-Édouard Mendy, umgadli othatha isikhundla sakhe u-Yehvann Diouf angenelela kanengi ukulithatha. U-Diouf wabamba ithawula phezulu eceleni kwendebe esithombeni sakhe sokunqoba.[2]

== Inkomba ==</text>
      <sha1>l7q2a0ndlozxlmp4jatm5t16q9tvyr5</sha1>
    </revision>
    <revision>
      <id>6335</id>
      <parentid>6334</parentid>
      <timestamp>2026-03-25T05:57:11Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6335</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6410" sha1="r4kzg8vtum59uu6d1lv8j8ktp590pk8" xml:space="preserve">'''Umdlalo wamanqamu we-Africa Cup of Nations we-2025''' bekungumdlalo webholo odlalwe mhlazi-18 kuTjhirhweni 2026 e- Prince Moulay Abdellah Stadium e- Rabat, e-Morocco. Yakhetha abaphumeleleko be- 2025 African Cup of Nations (AFCON), i-edishini yama-35 yomqhudelwano we-Afrika owenziwa qobe minyaka emibili ohlelwe yi- Confederation of African Football (CAF), begodu bewuphaliswa hlangana ne -Senegal ne- Morocco .

Umdlalo lo bewuhlaselwe ziimpikiswano, khulukhulu isiqunto se-Senegal sokuphuma enkundleni ngokutjhikijela kokubili igoli elingavunyelwako kanye nesiqunto esilimazako se-VAR ngesikhathi sokujama . I-Senegal yabuyela enkundleni, begodu yadlala umdlalo ekuthomeni ngokunqoba nge-1-0 ngemva kwesikhathi esingezelelweko .   Ukuphuma kanye nokuhlukunyezwa kwabalandeli kwachazwa &quot;njengokungamukeleki&quot; ngumongameli we-FIFA u-Gianni Infantino, begodu kwathatha amagadango wezomthetho avela ku -Royal Moroccan Football Federation kanye nokuphenywa kwe-CAF. &lt;ref name=&quot;CNN&quot;&gt;''Church, Ben (19 January 2026).'' &quot;Player protests, an awful penalty and fan uproar: What happened in the most chaotic AFCON final in history&quot;''. CNN. Retrieved 21 January 2026.''&lt;/ref&gt;

Mhlana ali-17 kuNtaka 2026, iBhodi yokuDlulisa amaCala ye-CAF yaqunta bona i-Senegal ilahlekelwe ma-final ngezenzo zayo, begodu esikhundleni salokho izokunikelwa njengomnqobi we-3-0 we-Morocco.   Ngelanga elilandelako, i -Senegalese Football Federation yamemezela bona izokudlulisa isiqunto eKhotho yokuLamula yezeMidlalo . 

== Ikundla ==
I-Prince Moulay Abdellah Stadium yinkundla yebholo ese-Rabat, e-Morocco, enendawo yokuhlala engu-69,500. Ivulwe mhlazi-5 kuNobayeni 2025, yindawo yekhaya lesiqhema sebholo se-Morocco . Iyingcenye yendawo ekulu yezemidlalo efaka hlangana inkundla yezemidlalo, inkundla yangaphakathi ye-Salle Moulay Abdellah, kanye nedamu lokubhukuda elilingana nama-Olimpiki. Ngenye yeenkundla ezikulu khulu e-Morocco. 

== Iimphathiswa zomdlalo ==
I-CAF imemezele irhelo elipheleleko labanompempe bomdlalo mhlana ali-18 kuTjhirhweni 2026, unompempe u-Jean-Jacques Ndala we- Democratic Republic of the Congo abe ngunompempe omkhulu.  Wasizwa emigqeni ngu-Guylain Bongele Ngila no-Gradel Mwanya Mbilizi, nabo abavela e-DR Congo. Umsizi wesithathu onompempe (oseleko) bekungu-Styven Moutsassi we- Republic of the Congo . &lt;ref name=&quot;JJN&quot;&gt;&quot;Referee Jean-Jacques Ndala appointed to officiate TotalEnergies CAF AFCON 2025 Final&quot;''. CAFonline.com. Confederation of African Football. 18 January 2026. Retrieved 18 January 2026.''&lt;/ref&gt; Ezinye iimphathiswa bekungu -Abongile Tom weSewula Afrika njengonompempe wesine, u-Pierre Atcho we -Gabon njengomsizi we-video referee (VAR), kanye neemphathiswa ezimbili njengomsizi wevidiyo (AVAR): u-Letticia Viana we- [[Eswatini]] no-Stephen Yiembé we [[Kenya|-Kenya]] . &lt;ref name=&quot;JJN&quot; /&gt;

== Indlela eya ekugcineni ==

=== I-Senegal ===

== Ukumadana ==

=== Isirhunyezo ===
Isikolo sahlala sisezingeni eliphezulu ku-0-0 isikhathi esinengi esijayelekileko, umdlalo waphela ngokuhlukaniswa okulinganako 50-50. Ibholo lasebenzisa isikhathi salo esincani engcenyeni ye-Senegal, lapho i-Senegal ibambe ibholo ngemidlalo emide yokuzivikela ngaphambi kokuthi ilinike i-offense ye-Morocco ebegade ihluleka ngokuphindaphindiweko ngokunyakaza okufitjhani phezulu enkundleni. Ngesiwombe sesibili, i-Senegal yabusa ibholo ngesikhathi i-Morocco iphinda kathathu inani lamabholo. Umgadli we-Morocco u-Yassine Bounou wenze ama-save amanengi aqakathekileko, ngesikhathi i-Senegal ithembele khulu emagodini wayo ukugcina umdlalo ungafaki amagoli. 

Ngomzuzu wesihlanu wesikhathi sokumisa, i-Senegal yabonakala ithumba ipumelelo ngokukhahlela ekhoneni . Ekulungiseleleni umdlalo, umvikeli we-Morocco u-Achraf Hakimi wawisa phasi ngesikhathi aphikisana nokukhahlelwa nomgadli we-Senegal u-Abdoulaye Seck . Msinyana ngemva kobana u-Hakimi awe, u-Seck wahlangabezana nokukhahlelwa okungenako begodu wayikhipha ngehloko ngaphandle kwe-crossbar ukubeka igoli ku -Ismaïla Sarr . Unompempe u-Jean-Jacques Ndala wenze i-foul ephikisanako ngokujamelana no-Seck, okwenza bona igoli lingavunyelwa. U-Ndala wahlatjwa ngokuthi washaya ikhwela lakhe ngaphambi kokuthi umdlalo uphele, okwenza bona i-VAR ingakghoni ukubuyekeza ubujamo begoli. 

Ngemva kwemizuzwana embalwa, ngomzuzu wesibhozo wesikhathi sokumisa, umvikeli we-Senegalese u-El Hadji Malick Diouf wabamba umgadli we-Morocco u-Brahim Díaz endaweni yephenalithi, okwenza bona kubuyekezwe i-VAR. I-Senegal yahlawuliswa ngephenalithi eyathathwa ngu-Díaz. Ukutjhikijela isiqunto, abadlali be-Senegal bathoma ukugandelela u-Ndala nabadlali abaphikisana nabo, begodu umrhelebhi omkhulu u-Pape Thiaw wayala isiqhema sakhe bona siphume enkundleni. Umdlalo wamiswa isikhathi esingaba mizuzu eli-14 ngesikhathi inkanyezi ye-Senegal u-Sadio Mané ikhuthaza abadlali bakhe ekamelweni lokugqoka bona babuyele enkundleni, wabatjela bona: &quot;Sizokudlala njengamadoda!&quot; Ngesikhathi sokulibaziseka, abalandeli be-Senegal balinga ukuhlasela inkundla begodu balwa namapholisa we-Morocco nabasekeli, begodu kwaba nokulwa ebhokisini labezindaba. &lt;ref&gt;https://mashable.com/article/senegal-morocco-africa-cup-of-nations-final-2025-live-stream-for-free&lt;/ref&gt;

Iinkhalazo zika-Mané zagcina ziphumelele, begodu lokha abadlali be-Senegal nababuyela enkundleni, umgadli u-Édouard Mendy watjengiswa ikhadi eliphuzi ngokulibazisa umdlalo. Naphezu kokutjheja, u-Mendy waragela phambili nokujamelana ngokwala ukubuyela emnqophweni wakhe. U-Brahim Díaz ekugcineni wathatha iphenalithi ngemva kwemizuzu ema-21 ngemva kokuphela komthetho, kodwana umzamo wakhe wesitayela se-Panenka wasindiswa ngu-Mendy, begodu isikhathi esijayelekileko saphela amaphuzu asesezingeni eliphezulu ku-0-0.

Ngesikhathi esingezelelweko, u-Pape Gueye washaya igoli elilodwa lomdlalo we-Senegal ngomzuzu wama-94, wagoqa ngenyawo lesokunxele phezulu ekhoneni eliphezulu-kwesokudla ukusuka ngaphakathi nje kwendawo yephenalithi ukunikela i-Senegal ipumelelo ye-1-0 kanye nesicoco sayo sesibili se-Africa Cup of Nations.[1] Kuwo woke umdlalo, abafana bebholo be-Morocco nabadlali ababili be-Morocco, u-Achraf Hakimi no-Ismael Saibari, ngamunye bebazame ukulahla ithawula lezandla lomgadli we-Senegalese u-Édouard Mendy, umgadli othatha isikhundla sakhe u-Yehvann Diouf angenelela kanengi ukulithatha. U-Diouf wabamba ithawula phezulu eceleni kwendebe esithombeni sakhe sokunqoba.[2]

== Inkomba ==
{{reflist}}</text>
      <sha1>r4kzg8vtum59uu6d1lv8j8ktp590pk8</sha1>
    </revision>
    <revision>
      <id>6336</id>
      <parentid>6335</parentid>
      <timestamp>2026-03-25T05:58:00Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6336</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6430" sha1="32kk33p60ag8qedvkoia85eoo7kcygh" xml:space="preserve">'''Umdlalo wamanqamu we-Africa Cup of Nations we-2025''' bekungumdlalo webholo odlalwe mhlazi-18 kuTjhirhweni 2026 e- Prince Moulay Abdellah Stadium e- Rabat, e-Morocco. Yakhetha abaphumeleleko be- 2025 African Cup of Nations (AFCON), i-edishini yama-35 yomqhudelwano we-Afrika owenziwa qobe minyaka emibili ohlelwe yi- Confederation of African Football (CAF), begodu bewuphaliswa hlangana ne -Senegal ne- Morocco .

Umdlalo lo bewuhlaselwe ziimpikiswano, khulukhulu isiqunto se-Senegal sokuphuma enkundleni ngokutjhikijela kokubili igoli elingavunyelwako kanye nesiqunto esilimazako se-VAR ngesikhathi sokujama . I-Senegal yabuyela enkundleni, begodu yadlala umdlalo ekuthomeni ngokunqoba nge-1-0 ngemva kwesikhathi esingezelelweko .   Ukuphuma kanye nokuhlukunyezwa kwabalandeli kwachazwa &quot;njengokungamukeleki&quot; ngumongameli we-FIFA u-Gianni Infantino, begodu kwathatha amagadango wezomthetho avela ku -Royal Moroccan Football Federation kanye nokuphenywa kwe-CAF. &lt;ref name=&quot;CNN&quot;&gt;''Church, Ben (19 January 2026).'' &quot;Player protests, an awful penalty and fan uproar: What happened in the most chaotic AFCON final in history&quot;''. CNN. Retrieved 21 January 2026.''&lt;/ref&gt;

Mhlana ali-17 kuNtaka 2026, iBhodi yokuDlulisa amaCala ye-CAF yaqunta bona i-Senegal ilahlekelwe ma-final ngezenzo zayo, begodu esikhundleni salokho izokunikelwa njengomnqobi we-3-0 we-Morocco.   Ngelanga elilandelako, i -Senegalese Football Federation yamemezela bona izokudlulisa isiqunto eKhotho yokuLamula yezeMidlalo . 

== Ikundla ==
I-Prince Moulay Abdellah Stadium yinkundla yebholo ese-Rabat, e-Morocco, enendawo yokuhlala engu-69,500. Ivulwe mhlazi-5 kuNobayeni 2025, yindawo yekhaya lesiqhema sebholo se-Morocco . Iyingcenye yendawo ekulu yezemidlalo efaka hlangana inkundla yezemidlalo, inkundla yangaphakathi ye-Salle Moulay Abdellah, kanye nedamu lokubhukuda elilingana nama-Olimpiki. Ngenye yeenkundla ezikulu khulu e-Morocco. 

== Iimphathiswa zomdlalo ==
I-CAF imemezele irhelo elipheleleko labanompempe bomdlalo mhlana ali-18 kuTjhirhweni 2026, unompempe u-Jean-Jacques Ndala we- Democratic Republic of the Congo abe ngunompempe omkhulu.  Wasizwa emigqeni ngu-Guylain Bongele Ngila no-Gradel Mwanya Mbilizi, nabo abavela e-DR Congo. Umsizi wesithathu onompempe (oseleko) bekungu-Styven Moutsassi we- Republic of the Congo . &lt;ref name=&quot;JJN&quot;&gt;&quot;Referee Jean-Jacques Ndala appointed to officiate TotalEnergies CAF AFCON 2025 Final&quot;''. CAFonline.com. Confederation of African Football. 18 January 2026. Retrieved 18 January 2026.''&lt;/ref&gt; Ezinye iimphathiswa bekungu -Abongile Tom weSewula Afrika njengonompempe wesine, u-Pierre Atcho we -Gabon njengomsizi we-video referee (VAR), kanye neemphathiswa ezimbili njengomsizi wevidiyo (AVAR): u-Letticia Viana we- [[Eswatini]] no-Stephen Yiembé we [[Kenya|-Kenya]] . &lt;ref name=&quot;JJN&quot; /&gt;

== Indlela eya ekugcineni ==

=== I-Senegal ===

== Ukumadana ==

=== Isirhunyezo ===
Isikolo sahlala sisezingeni eliphezulu ku-0-0 isikhathi esinengi esijayelekileko, umdlalo waphela ngokuhlukaniswa okulinganako 50-50. Ibholo lasebenzisa isikhathi salo esincani engcenyeni ye-Senegal, lapho i-Senegal ibambe ibholo ngemidlalo emide yokuzivikela ngaphambi kokuthi ilinike i-offense ye-Morocco ebegade ihluleka ngokuphindaphindiweko ngokunyakaza okufitjhani phezulu enkundleni. Ngesiwombe sesibili, i-Senegal yabusa ibholo ngesikhathi i-Morocco iphinda kathathu inani lamabholo. Umgadli we-Morocco u-Yassine Bounou wenze ama-save amanengi aqakathekileko, ngesikhathi i-Senegal ithembele khulu emagodini wayo ukugcina umdlalo ungafaki amagoli. 

Ngomzuzu wesihlanu wesikhathi sokumisa, i-Senegal yabonakala ithumba ipumelelo ngokukhahlela ekhoneni . Ekulungiseleleni umdlalo, umvikeli we-Morocco u-Achraf Hakimi wawisa phasi ngesikhathi aphikisana nokukhahlelwa nomgadli we-Senegal u-Abdoulaye Seck . Msinyana ngemva kobana u-Hakimi awe, u-Seck wahlangabezana nokukhahlelwa okungenako begodu wayikhipha ngehloko ngaphandle kwe-crossbar ukubeka igoli ku -Ismaïla Sarr . Unompempe u-Jean-Jacques Ndala wenze i-foul ephikisanako ngokujamelana no-Seck, okwenza bona igoli lingavunyelwa. U-Ndala wahlatjwa ngokuthi washaya ikhwela lakhe ngaphambi kokuthi umdlalo uphele, okwenza bona i-VAR ingakghoni ukubuyekeza ubujamo begoli. 

Ngemva kwemizuzwana embalwa, ngomzuzu wesibhozo wesikhathi sokumisa, umvikeli we-Senegalese u-El Hadji Malick Diouf wabamba umgadli we-Morocco u-Brahim Díaz endaweni yephenalithi, okwenza bona kubuyekezwe i-VAR. I-Senegal yahlawuliswa ngephenalithi eyathathwa ngu-Díaz. Ukutjhikijela isiqunto, abadlali be-Senegal bathoma ukugandelela u-Ndala nabadlali abaphikisana nabo, begodu umrhelebhi omkhulu u-Pape Thiaw wayala isiqhema sakhe bona siphume enkundleni. Umdlalo wamiswa isikhathi esingaba mizuzu eli-14 ngesikhathi inkanyezi ye-Senegal u-Sadio Mané ikhuthaza abadlali bakhe ekamelweni lokugqoka bona babuyele enkundleni, wabatjela bona: &quot;Sizokudlala njengamadoda!&quot; Ngesikhathi sokulibaziseka, abalandeli be-Senegal balinga ukuhlasela inkundla begodu balwa namapholisa we-Morocco nabasekeli, begodu kwaba nokulwa ebhokisini labezindaba. &lt;ref&gt;https://mashable.com/article/senegal-morocco-africa-cup-of-nations-final-2025-live-stream-for-free&lt;/ref&gt;

Iinkhalazo zika-Mané zagcina ziphumelele, begodu lokha abadlali be-Senegal nababuyela enkundleni, umgadli u-Édouard Mendy watjengiswa ikhadi eliphuzi ngokulibazisa umdlalo. Naphezu kokutjheja, u-Mendy waragela phambili nokujamelana ngokwala ukubuyela emnqophweni wakhe. U-Brahim Díaz ekugcineni wathatha iphenalithi ngemva kwemizuzu ema-21 ngemva kokuphela komthetho, kodwana umzamo wakhe wesitayela se-Panenka wasindiswa ngu-Mendy, begodu isikhathi esijayelekileko saphela amaphuzu asesezingeni eliphezulu ku-0-0.

Ngesikhathi esingezelelweko, u-Pape Gueye washaya igoli elilodwa lomdlalo we-Senegal ngomzuzu wama-94, wagoqa ngenyawo lesokunxele phezulu ekhoneni eliphezulu-kwesokudla ukusuka ngaphakathi nje kwendawo yephenalithi ukunikela i-Senegal ipumelelo ye-1-0 kanye nesicoco sayo sesibili se-Africa Cup of Nations.[1] Kuwo woke umdlalo, abafana bebholo be-Morocco nabadlali ababili be-Morocco, u-Achraf Hakimi no-Ismael Saibari, ngamunye bebazame ukulahla ithawula lezandla lomgadli we-Senegalese u-Édouard Mendy, umgadli othatha isikhundla sakhe u-Yehvann Diouf angenelela kanengi ukulithatha. U-Diouf wabamba ithawula phezulu eceleni kwendebe esithombeni sakhe sokunqoba.[2]

== Inkomba ==
{{reflist}}
[[Category:Afrika]]</text>
      <sha1>32kk33p60ag8qedvkoia85eoo7kcygh</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Afrika</title>
    <ns>14</ns>
    <id>1071</id>
    <revision>
      <id>6337</id>
      <timestamp>2026-03-25T05:58:12Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created blank page</comment>
      <origin>6337</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
  </page>
  <page>
    <title>Sifiso Mkhwanazi</title>
    <ns>0</ns>
    <id>1072</id>
    <revision>
      <id>6338</id>
      <timestamp>2026-03-25T23:59:30Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created page with &quot;**Sifiso Mkhwanazi** is a South African man who was arrested in connection with multiple murders in Johannesburg. His case drew significant national attention due to the severity of the allegations and concerns about violent crime in urban areas.  ## Background  Little publicly verified information is available about Mkhwanazi’s early life. Reports indicate that he was residing in Johannesburg at the time of his arrest. Prior to his apprehension, he was not widely know...&quot;</comment>
      <origin>6338</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1691" sha1="mepy6r9c1ms8wj0jmc4powf9qcggegz" xml:space="preserve">**Sifiso Mkhwanazi** is a South African man who was arrested in connection with multiple murders in Johannesburg. His case drew significant national attention due to the severity of the allegations and concerns about violent crime in urban areas.

## Background

Little publicly verified information is available about Mkhwanazi’s early life. Reports indicate that he was residing in Johannesburg at the time of his arrest. Prior to his apprehension, he was not widely known to the public.

## Arrest and allegations

Mkhwanazi was arrested by the South African Police Service (SAPS) following investigations into multiple missing persons and homicide cases. Authorities alleged that several victims were linked to him, leading to his classification in media reports as a suspected serial offender.

## Investigation

The case involved coordinated investigative efforts, including forensic analysis and witness testimony. Law enforcement agencies indicated that the investigation was ongoing, with the possibility of additional charges depending on evidence gathered.

## Public reaction

The case sparked widespread public concern and media coverage in South Africa, highlighting ongoing issues related to gender-based violence and community safety. It also prompted discussions about policing effectiveness and the protection of vulnerable individuals.

## Legal proceedings

At the time of reporting, Mkhwanazi’s case was proceeding through the South African judicial system. As with all accused persons, he is presumed innocent until proven guilty in a court of law.

---

*Note: This article is a summary based on publicly reported information and may evolve as new details emerge.*</text>
      <sha1>mepy6r9c1ms8wj0jmc4powf9qcggegz</sha1>
    </revision>
    <revision>
      <id>6339</id>
      <parentid>6338</parentid>
      <timestamp>2026-03-26T00:01:32Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6339</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1595" sha1="gxwg96bulr2o4stc1915vduae79l638" xml:space="preserve">'''Sifiso Mkhwanazi''' yindoda yeSewula Afrika eyabotjhwa malungana nokubulala abantu abanengi eGoli. Icala lakhe ladonsa ukutjhejwa okukhulu kwelizwe ngebanga lobukhulu beensolo nokutshwenyeka ngobulelesi obunobudlova eendaweni ezisemadorobheni.

== Isendlalelo ==

Ilwazi elincani eliqinisekiswe tjhatjhalazi liyatholakala ngepilo ka-Mkhwanazi yokuthoma. Imibiko iveza bona bekahlala e-Goli ngesikhathi abotjhwa. Ngaphambi kokubanjwa kwakhe, bekangaziwa khulu emphakathini.

== Ukubotjhwa neensolo ==

UMkhwanazi wabotjhwa mapholisa weSewula Afrika (i-SAPS) ngemva kophenyo lwabantu abanengi abalahlekileko kanye namacala wokubulala. Iimphathimandla zisola bona iinhlupheki ezinengi bezihlotjaniswa naye, okurholele ekutheni ahlukaniswe emibikweni yabezindaba njengomuntu osolwa ngokuba mphulaphuli.

Icala belibandakanya imizamo yokuphenya ehlangeneko, okufaka hlangana ukuhlaziywa kwe-forensic kanye nobufakazi bofakazi. Iinhlangano zokuthobela umthetho zitjengise bona iphenyo liyaraga, begodu kungenzeka kube namacala angezelelweko ngokuya ngobufakazi obubuthelelweko. Icala leli lavusa ukutshwenyeka okukhulu komphakathi nokuvezwa kwabezindaba eSewula Afrika, laveza iindaba eziragela phambili ezihlobene nobudlova obusekelwe ebulilini nokuphepha komphakathi. Kwabangela neengcoco malungana nokusebenza kwamapholisa nokuvikelwa kwabantu abasengozini.

== Iinqunto zomthetho ==

Ngesikhathi sokubika, icala laka-Mkhwanazi beliragela phambili ngehlelo lezomthetho leSewula Afrika. Njengabo boke abantu abamangalelwako, uthathwa njengomsulwa bekube kulapho afakazelwa umlandu emthethwandaba.</text>
      <sha1>gxwg96bulr2o4stc1915vduae79l638</sha1>
    </revision>
    <revision>
      <id>6340</id>
      <parentid>6339</parentid>
      <timestamp>2026-03-26T00:04:02Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6340</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1985" sha1="gafkw8vvq6sh9zp3n86ib1x0vk2059d" xml:space="preserve">'''Sifiso Mkhwanazi''' yindoda yeSewula Afrika eyabotjhwa malungana nokubulala abantu abanengi eGoli. Icala lakhe ladonsa ukutjhejwa okukhulu kwelizwe ngebanga lobukhulu beensolo nokutshwenyeka ngobulelesi obunobudlova eendaweni ezisemadorobheni.&lt;ref&gt;https://businessreport.co.za/news/crime-and-courts/2024-09-18-sifiso-mkhwanazi-sentenced-to-life-for-murdering-six-zimbabwean-sex-workers-in-joburg/&lt;/ref&gt;

== Isendlalelo ==

Ilwazi elincani eliqinisekiswe tjhatjhalazi liyatholakala ngepilo ka-Mkhwanazi yokuthoma. Imibiko iveza bona bekahlala e-Goli ngesikhathi abotjhwa. Ngaphambi kokubanjwa kwakhe, bekangaziwa khulu emphakathini.&lt;ref&gt;https://capeargus.co.za/news/south-africa/gauteng/2024-03-13-guilty-sifiso-mkhwanazi-convicted-of-brutal-murder-of-six-joburg-sex-workers/&lt;/ref&gt;

== Ukubotjhwa neensolo ==

UMkhwanazi wabotjhwa mapholisa weSewula Afrika (i-SAPS) ngemva kophenyo lwabantu abanengi abalahlekileko kanye namacala wokubulala. Iimphathimandla zisola bona iinhlupheki ezinengi bezihlotjaniswa naye, okurholele ekutheni ahlukaniswe emibikweni yabezindaba njengomuntu osolwa ngokuba mphulaphuli.&lt;ref&gt;https://www.enca.com/top-stories/sifiso-mkhwanazi-sentenced-life-prison&lt;/ref&gt;

Icala belibandakanya imizamo yokuphenya ehlangeneko, okufaka hlangana ukuhlaziywa kwe-forensic kanye nobufakazi bofakazi. Iinhlangano zokuthobela umthetho zitjengise bona iphenyo liyaraga, begodu kungenzeka kube namacala angezelelweko ngokuya ngobufakazi obubuthelelweko. Icala leli lavusa ukutshwenyeka okukhulu komphakathi nokuvezwa kwabezindaba eSewula Afrika, laveza iindaba eziragela phambili ezihlobene nobudlova obusekelwe ebulilini nokuphepha komphakathi. Kwabangela neengcoco malungana nokusebenza kwamapholisa nokuvikelwa kwabantu abasengozini.

== Iinqunto zomthetho ==

Ngesikhathi sokubika, icala laka-Mkhwanazi beliragela phambili ngehlelo lezomthetho leSewula Afrika. Njengabo boke abantu abamangalelwako, uthathwa njengomsulwa bekube kulapho afakazelwa umlandu emthethwandaba.</text>
      <sha1>gafkw8vvq6sh9zp3n86ib1x0vk2059d</sha1>
    </revision>
    <revision>
      <id>6341</id>
      <parentid>6340</parentid>
      <timestamp>2026-03-26T00:04:22Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6341</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1997" sha1="9fhflxjcmpsg9ea3hv231clubo45nm4" xml:space="preserve">'''Sifiso Mkhwanazi''' yindoda yeSewula Afrika eyabotjhwa malungana nokubulala abantu abanengi eGoli. Icala lakhe ladonsa ukutjhejwa okukhulu kwelizwe ngebanga lobukhulu beensolo nokutshwenyeka ngobulelesi obunobudlova eendaweni ezisemadorobheni.&lt;ref&gt;https://businessreport.co.za/news/crime-and-courts/2024-09-18-sifiso-mkhwanazi-sentenced-to-life-for-murdering-six-zimbabwean-sex-workers-in-joburg/&lt;/ref&gt;

== Isendlalelo ==

Ilwazi elincani eliqinisekiswe tjhatjhalazi liyatholakala ngepilo ka-Mkhwanazi yokuthoma. Imibiko iveza bona bekahlala e-Goli ngesikhathi abotjhwa. Ngaphambi kokubanjwa kwakhe, bekangaziwa khulu emphakathini.&lt;ref&gt;https://capeargus.co.za/news/south-africa/gauteng/2024-03-13-guilty-sifiso-mkhwanazi-convicted-of-brutal-murder-of-six-joburg-sex-workers/&lt;/ref&gt;

== Ukubotjhwa neensolo ==

UMkhwanazi wabotjhwa mapholisa weSewula Afrika (i-SAPS) ngemva kophenyo lwabantu abanengi abalahlekileko kanye namacala wokubulala. Iimphathimandla zisola bona iinhlupheki ezinengi bezihlotjaniswa naye, okurholele ekutheni ahlukaniswe emibikweni yabezindaba njengomuntu osolwa ngokuba mphulaphuli.&lt;ref&gt;https://www.enca.com/top-stories/sifiso-mkhwanazi-sentenced-life-prison&lt;/ref&gt;

Icala belibandakanya imizamo yokuphenya ehlangeneko, okufaka hlangana ukuhlaziywa kwe-forensic kanye nobufakazi bofakazi. Iinhlangano zokuthobela umthetho zitjengise bona iphenyo liyaraga, begodu kungenzeka kube namacala angezelelweko ngokuya ngobufakazi obubuthelelweko. Icala leli lavusa ukutshwenyeka okukhulu komphakathi nokuvezwa kwabezindaba eSewula Afrika, laveza iindaba eziragela phambili ezihlobene nobudlova obusekelwe ebulilini nokuphepha komphakathi. Kwabangela neengcoco malungana nokusebenza kwamapholisa nokuvikelwa kwabantu abasengozini.

== Iinqunto zomthetho ==

Ngesikhathi sokubika, icala laka-Mkhwanazi beliragela phambili ngehlelo lezomthetho leSewula Afrika. Njengabo boke abantu abamangalelwako, uthathwa njengomsulwa bekube kulapho afakazelwa umlandu emthethwandaba.
==Inkomba==</text>
      <sha1>9fhflxjcmpsg9ea3hv231clubo45nm4</sha1>
    </revision>
    <revision>
      <id>6342</id>
      <parentid>6341</parentid>
      <timestamp>2026-03-26T00:05:33Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6342</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2020" sha1="rta4parimy22yafuf20tse7fibx87qz" xml:space="preserve">'''Sifiso Mkhwanazi''' yindoda ye[[Isewula Afrika|Sewula Afrika]] eyabotjhwa malungana nokubulala abantu abanengi [[eGoli]]. Icala lakhe ladonsa ukutjhejwa okukhulu kwelizwe ngebanga lobukhulu beensolo nokutshwenyeka ngobulelesi obunobudlova eendaweni ezisemadorobheni.&lt;ref&gt;https://businessreport.co.za/news/crime-and-courts/2024-09-18-sifiso-mkhwanazi-sentenced-to-life-for-murdering-six-zimbabwean-sex-workers-in-joburg/&lt;/ref&gt;

== Isendlalelo ==

Ilwazi elincani eliqinisekiswe tjhatjhalazi liyatholakala ngepilo ka-Mkhwanazi yokuthoma. Imibiko iveza bona bekahlala e-Goli ngesikhathi abotjhwa. Ngaphambi kokubanjwa kwakhe, bekangaziwa khulu emphakathini.&lt;ref&gt;https://capeargus.co.za/news/south-africa/gauteng/2024-03-13-guilty-sifiso-mkhwanazi-convicted-of-brutal-murder-of-six-joburg-sex-workers/&lt;/ref&gt;

== Ukubotjhwa neensolo ==

UMkhwanazi wabotjhwa mapholisa weSewula Afrika (i-SAPS) ngemva kophenyo lwabantu abanengi abalahlekileko kanye namacala wokubulala. Iimphathimandla zisola bona iinhlupheki ezinengi bezihlotjaniswa naye, okurholele ekutheni ahlukaniswe emibikweni yabezindaba njengomuntu osolwa ngokuba mphulaphuli.&lt;ref&gt;https://www.enca.com/top-stories/sifiso-mkhwanazi-sentenced-life-prison&lt;/ref&gt;

Icala belibandakanya imizamo yokuphenya ehlangeneko, okufaka hlangana ukuhlaziywa kwe-forensic kanye nobufakazi bofakazi. Iinhlangano zokuthobela umthetho zitjengise bona iphenyo liyaraga, begodu kungenzeka kube namacala angezelelweko ngokuya ngobufakazi obubuthelelweko. Icala leli lavusa ukutshwenyeka okukhulu komphakathi nokuvezwa kwabezindaba eSewula Afrika, laveza iindaba eziragela phambili ezihlobene nobudlova obusekelwe ebulilini nokuphepha komphakathi. Kwabangela neengcoco malungana nokusebenza kwamapholisa nokuvikelwa kwabantu abasengozini.

== Iinqunto zomthetho ==

Ngesikhathi sokubika, icala laka-Mkhwanazi beliragela phambili ngehlelo lezomthetho leSewula Afrika. Njengabo boke abantu abamangalelwako, uthathwa njengomsulwa bekube kulapho afakazelwa umlandu emthethwandaba.
==Inkomba==</text>
      <sha1>rta4parimy22yafuf20tse7fibx87qz</sha1>
    </revision>
    <revision>
      <id>6343</id>
      <parentid>6342</parentid>
      <timestamp>2026-03-26T00:06:16Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6343</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2032" sha1="nuc33rjwdna5t8jvicpezh5s7pde3pf" xml:space="preserve">'''Sifiso Mkhwanazi''' yindoda ye[[Isewula Afrika|Sewula Afrika]] eyabotjhwa malungana nokubulala abantu abanengi [[eGoli]]. Icala lakhe ladonsa ukutjhejwa okukhulu kwelizwe ngebanga lobukhulu beensolo nokutshwenyeka ngobulelesi obunobudlova eendaweni ezisemadorobheni.&lt;ref&gt;https://businessreport.co.za/news/crime-and-courts/2024-09-18-sifiso-mkhwanazi-sentenced-to-life-for-murdering-six-zimbabwean-sex-workers-in-joburg/&lt;/ref&gt;

== Isendlalelo ==

Ilwazi elincani eliqinisekiswe tjhatjhalazi liyatholakala ngepilo ka-Mkhwanazi yokuthoma. Imibiko iveza bona bekahlala e-Goli ngesikhathi abotjhwa. Ngaphambi kokubanjwa kwakhe, bekangaziwa khulu emphakathini.&lt;ref&gt;https://capeargus.co.za/news/south-africa/gauteng/2024-03-13-guilty-sifiso-mkhwanazi-convicted-of-brutal-murder-of-six-joburg-sex-workers/&lt;/ref&gt;

== Ukubotjhwa neensolo ==

UMkhwanazi wabotjhwa mapholisa weSewula Afrika (i-SAPS) ngemva kophenyo lwabantu abanengi abalahlekileko kanye namacala wokubulala. Iimphathimandla zisola bona iinhlupheki ezinengi bezihlotjaniswa naye, okurholele ekutheni ahlukaniswe emibikweni yabezindaba njengomuntu osolwa ngokuba mphulaphuli.&lt;ref&gt;https://www.enca.com/top-stories/sifiso-mkhwanazi-sentenced-life-prison&lt;/ref&gt;

Icala belibandakanya imizamo yokuphenya ehlangeneko, okufaka hlangana ukuhlaziywa kwe-forensic kanye nobufakazi bofakazi. Iinhlangano zokuthobela umthetho zitjengise bona iphenyo liyaraga, begodu kungenzeka kube namacala angezelelweko ngokuya ngobufakazi obubuthelelweko. Icala leli lavusa ukutshwenyeka okukhulu komphakathi nokuvezwa kwabezindaba eSewula Afrika, laveza iindaba eziragela phambili ezihlobene nobudlova obusekelwe ebulilini nokuphepha komphakathi. Kwabangela neengcoco malungana nokusebenza kwamapholisa nokuvikelwa kwabantu abasengozini.

== Iinqunto zomthetho ==

Ngesikhathi sokubika, icala laka-Mkhwanazi beliragela phambili ngehlelo lezomthetho leSewula Afrika. Njengabo boke abantu abamangalelwako, uthathwa njengomsulwa bekube kulapho afakazelwa umlandu emthethwandaba.
==Inkomba==
{{reflist}}</text>
      <sha1>nuc33rjwdna5t8jvicpezh5s7pde3pf</sha1>
    </revision>
    <revision>
      <id>6344</id>
      <parentid>6343</parentid>
      <timestamp>2026-03-26T00:06:46Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6344</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2052" sha1="sz8fccwfawl2wm8os1bbt7u0sefpu8k" xml:space="preserve">'''Sifiso Mkhwanazi''' yindoda ye[[Isewula Afrika|Sewula Afrika]] eyabotjhwa malungana nokubulala abantu abanengi [[eGoli]]. Icala lakhe ladonsa ukutjhejwa okukhulu kwelizwe ngebanga lobukhulu beensolo nokutshwenyeka ngobulelesi obunobudlova eendaweni ezisemadorobheni.&lt;ref&gt;https://businessreport.co.za/news/crime-and-courts/2024-09-18-sifiso-mkhwanazi-sentenced-to-life-for-murdering-six-zimbabwean-sex-workers-in-joburg/&lt;/ref&gt;

== Isendlalelo ==

Ilwazi elincani eliqinisekiswe tjhatjhalazi liyatholakala ngepilo ka-Mkhwanazi yokuthoma. Imibiko iveza bona bekahlala e-Goli ngesikhathi abotjhwa. Ngaphambi kokubanjwa kwakhe, bekangaziwa khulu emphakathini.&lt;ref&gt;https://capeargus.co.za/news/south-africa/gauteng/2024-03-13-guilty-sifiso-mkhwanazi-convicted-of-brutal-murder-of-six-joburg-sex-workers/&lt;/ref&gt;

== Ukubotjhwa neensolo ==

UMkhwanazi wabotjhwa mapholisa weSewula Afrika (i-SAPS) ngemva kophenyo lwabantu abanengi abalahlekileko kanye namacala wokubulala. Iimphathimandla zisola bona iinhlupheki ezinengi bezihlotjaniswa naye, okurholele ekutheni ahlukaniswe emibikweni yabezindaba njengomuntu osolwa ngokuba mphulaphuli.&lt;ref&gt;https://www.enca.com/top-stories/sifiso-mkhwanazi-sentenced-life-prison&lt;/ref&gt;

Icala belibandakanya imizamo yokuphenya ehlangeneko, okufaka hlangana ukuhlaziywa kwe-forensic kanye nobufakazi bofakazi. Iinhlangano zokuthobela umthetho zitjengise bona iphenyo liyaraga, begodu kungenzeka kube namacala angezelelweko ngokuya ngobufakazi obubuthelelweko. Icala leli lavusa ukutshwenyeka okukhulu komphakathi nokuvezwa kwabezindaba eSewula Afrika, laveza iindaba eziragela phambili ezihlobene nobudlova obusekelwe ebulilini nokuphepha komphakathi. Kwabangela neengcoco malungana nokusebenza kwamapholisa nokuvikelwa kwabantu abasengozini.

== Iinqunto zomthetho ==

Ngesikhathi sokubika, icala laka-Mkhwanazi beliragela phambili ngehlelo lezomthetho leSewula Afrika. Njengabo boke abantu abamangalelwako, uthathwa njengomsulwa bekube kulapho afakazelwa umlandu emthethwandaba.
==Inkomba==
{{reflist}}
[[Category:Afrika]]</text>
      <sha1>sz8fccwfawl2wm8os1bbt7u0sefpu8k</sha1>
    </revision>
    <revision>
      <id>6345</id>
      <parentid>6344</parentid>
      <timestamp>2026-03-26T00:07:24Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6345</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2079" sha1="oopjfjprwlt5gva7cfdrjewplfhd9kj" xml:space="preserve">'''Sifiso Mkhwanazi''' yindoda ye[[Isewula Afrika|Sewula Afrika]] eyabotjhwa malungana nokubulala abantu abanengi [[eGoli]]. Icala lakhe ladonsa ukutjhejwa okukhulu kwelizwe ngebanga lobukhulu beensolo nokutshwenyeka ngobulelesi obunobudlova eendaweni ezisemadorobheni.&lt;ref&gt;https://businessreport.co.za/news/crime-and-courts/2024-09-18-sifiso-mkhwanazi-sentenced-to-life-for-murdering-six-zimbabwean-sex-workers-in-joburg/&lt;/ref&gt;

== Isendlalelo ==

Ilwazi elincani eliqinisekiswe tjhatjhalazi liyatholakala ngepilo ka-Mkhwanazi yokuthoma. Imibiko iveza bona bekahlala e-Goli ngesikhathi abotjhwa. Ngaphambi kokubanjwa kwakhe, bekangaziwa khulu emphakathini.&lt;ref&gt;https://capeargus.co.za/news/south-africa/gauteng/2024-03-13-guilty-sifiso-mkhwanazi-convicted-of-brutal-murder-of-six-joburg-sex-workers/&lt;/ref&gt;

== Ukubotjhwa neensolo ==

UMkhwanazi wabotjhwa mapholisa weSewula Afrika (i-SAPS) ngemva kophenyo lwabantu abanengi abalahlekileko kanye namacala wokubulala. Iimphathimandla zisola bona iinhlupheki ezinengi bezihlotjaniswa naye, okurholele ekutheni ahlukaniswe emibikweni yabezindaba njengomuntu osolwa ngokuba mphulaphuli.&lt;ref&gt;https://www.enca.com/top-stories/sifiso-mkhwanazi-sentenced-life-prison&lt;/ref&gt;

Icala belibandakanya imizamo yokuphenya ehlangeneko, okufaka hlangana ukuhlaziywa kwe-forensic kanye nobufakazi bofakazi. Iinhlangano zokuthobela umthetho zitjengise bona iphenyo liyaraga, begodu kungenzeka kube namacala angezelelweko ngokuya ngobufakazi obubuthelelweko. Icala leli lavusa ukutshwenyeka okukhulu komphakathi nokuvezwa kwabezindaba eSewula Afrika, laveza iindaba eziragela phambili ezihlobene nobudlova obusekelwe ebulilini nokuphepha komphakathi. Kwabangela neengcoco malungana nokusebenza kwamapholisa nokuvikelwa kwabantu abasengozini.

== Iinqunto zomthetho ==

Ngesikhathi sokubika, icala laka-Mkhwanazi beliragela phambili ngehlelo lezomthetho leSewula Afrika. Njengabo boke abantu abamangalelwako, uthathwa njengomsulwa bekube kulapho afakazelwa umlandu emthethwandaba.
==Inkomba==
{{reflist}}
[[Category:Afrika]]
[[Category:Sewula Afrika]]</text>
      <sha1>oopjfjprwlt5gva7cfdrjewplfhd9kj</sha1>
    </revision>
    <revision>
      <id>6350</id>
      <parentid>6345</parentid>
      <timestamp>2026-03-26T00:41:06Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6350</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2601" sha1="0htvtlu8l4h99ehfabghcpq1oz39si7" xml:space="preserve">{{Infobox food
| name = 
| name_lang =
| name_italics =
| image = 
| image_upright =
| image_alt =
| caption = 
| alternative_name = 
| type = 
| course = 
| place_of_origin = 
| region = 
| associated_cuisine = 
| creator =
| year = 
| mintime = 
| maxtime = 
| served = 
| main_ingredient = 
| minor_ingredient = 
| variations = 
| serving_size =
| calories = 
| calories_ref =
| protein = 
| fat = 
| carbohydrate = 
| glycemic_index = 
| similar_dish = 
| module =
| cookbook =
| commons =
| other = 
| no_recipes =
}}'''Sifiso Mkhwanazi''' yindoda ye[[Isewula Afrika|Sewula Afrika]] eyabotjhwa malungana nokubulala abantu abanengi [[eGoli]]. Icala lakhe ladonsa ukutjhejwa okukhulu kwelizwe ngebanga lobukhulu beensolo nokutshwenyeka ngobulelesi obunobudlova eendaweni ezisemadorobheni.&lt;ref&gt;https://businessreport.co.za/news/crime-and-courts/2024-09-18-sifiso-mkhwanazi-sentenced-to-life-for-murdering-six-zimbabwean-sex-workers-in-joburg/&lt;/ref&gt;

== Isendlalelo ==

Ilwazi elincani eliqinisekiswe tjhatjhalazi liyatholakala ngepilo ka-Mkhwanazi yokuthoma. Imibiko iveza bona bekahlala e-Goli ngesikhathi abotjhwa. Ngaphambi kokubanjwa kwakhe, bekangaziwa khulu emphakathini.&lt;ref&gt;https://capeargus.co.za/news/south-africa/gauteng/2024-03-13-guilty-sifiso-mkhwanazi-convicted-of-brutal-murder-of-six-joburg-sex-workers/&lt;/ref&gt;

== Ukubotjhwa neensolo ==

UMkhwanazi wabotjhwa mapholisa weSewula Afrika (i-SAPS) ngemva kophenyo lwabantu abanengi abalahlekileko kanye namacala wokubulala. Iimphathimandla zisola bona iinhlupheki ezinengi bezihlotjaniswa naye, okurholele ekutheni ahlukaniswe emibikweni yabezindaba njengomuntu osolwa ngokuba mphulaphuli.&lt;ref&gt;https://www.enca.com/top-stories/sifiso-mkhwanazi-sentenced-life-prison&lt;/ref&gt;

Icala belibandakanya imizamo yokuphenya ehlangeneko, okufaka hlangana ukuhlaziywa kwe-forensic kanye nobufakazi bofakazi. Iinhlangano zokuthobela umthetho zitjengise bona iphenyo liyaraga, begodu kungenzeka kube namacala angezelelweko ngokuya ngobufakazi obubuthelelweko. Icala leli lavusa ukutshwenyeka okukhulu komphakathi nokuvezwa kwabezindaba eSewula Afrika, laveza iindaba eziragela phambili ezihlobene nobudlova obusekelwe ebulilini nokuphepha komphakathi. Kwabangela neengcoco malungana nokusebenza kwamapholisa nokuvikelwa kwabantu abasengozini.

== Iinqunto zomthetho ==

Ngesikhathi sokubika, icala laka-Mkhwanazi beliragela phambili ngehlelo lezomthetho leSewula Afrika. Njengabo boke abantu abamangalelwako, uthathwa njengomsulwa bekube kulapho afakazelwa umlandu emthethwandaba.
==Inkomba==
{{reflist}}
[[Category:Afrika]]
[[Category:Sewula Afrika]]</text>
      <sha1>0htvtlu8l4h99ehfabghcpq1oz39si7</sha1>
    </revision>
    <revision>
      <id>6351</id>
      <parentid>6350</parentid>
      <timestamp>2026-03-26T00:41:29Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6351</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2080" sha1="jkf890ty9gl72i2oyxttjnnij7tqr0y" xml:space="preserve">
'''Sifiso Mkhwanazi''' yindoda ye[[Isewula Afrika|Sewula Afrika]] eyabotjhwa malungana nokubulala abantu abanengi [[eGoli]]. Icala lakhe ladonsa ukutjhejwa okukhulu kwelizwe ngebanga lobukhulu beensolo nokutshwenyeka ngobulelesi obunobudlova eendaweni ezisemadorobheni.&lt;ref&gt;https://businessreport.co.za/news/crime-and-courts/2024-09-18-sifiso-mkhwanazi-sentenced-to-life-for-murdering-six-zimbabwean-sex-workers-in-joburg/&lt;/ref&gt;

== Isendlalelo ==

Ilwazi elincani eliqinisekiswe tjhatjhalazi liyatholakala ngepilo ka-Mkhwanazi yokuthoma. Imibiko iveza bona bekahlala e-Goli ngesikhathi abotjhwa. Ngaphambi kokubanjwa kwakhe, bekangaziwa khulu emphakathini.&lt;ref&gt;https://capeargus.co.za/news/south-africa/gauteng/2024-03-13-guilty-sifiso-mkhwanazi-convicted-of-brutal-murder-of-six-joburg-sex-workers/&lt;/ref&gt;

== Ukubotjhwa neensolo ==

UMkhwanazi wabotjhwa mapholisa weSewula Afrika (i-SAPS) ngemva kophenyo lwabantu abanengi abalahlekileko kanye namacala wokubulala. Iimphathimandla zisola bona iinhlupheki ezinengi bezihlotjaniswa naye, okurholele ekutheni ahlukaniswe emibikweni yabezindaba njengomuntu osolwa ngokuba mphulaphuli.&lt;ref&gt;https://www.enca.com/top-stories/sifiso-mkhwanazi-sentenced-life-prison&lt;/ref&gt;

Icala belibandakanya imizamo yokuphenya ehlangeneko, okufaka hlangana ukuhlaziywa kwe-forensic kanye nobufakazi bofakazi. Iinhlangano zokuthobela umthetho zitjengise bona iphenyo liyaraga, begodu kungenzeka kube namacala angezelelweko ngokuya ngobufakazi obubuthelelweko. Icala leli lavusa ukutshwenyeka okukhulu komphakathi nokuvezwa kwabezindaba eSewula Afrika, laveza iindaba eziragela phambili ezihlobene nobudlova obusekelwe ebulilini nokuphepha komphakathi. Kwabangela neengcoco malungana nokusebenza kwamapholisa nokuvikelwa kwabantu abasengozini.

== Iinqunto zomthetho ==

Ngesikhathi sokubika, icala laka-Mkhwanazi beliragela phambili ngehlelo lezomthetho leSewula Afrika. Njengabo boke abantu abamangalelwako, uthathwa njengomsulwa bekube kulapho afakazelwa umlandu emthethwandaba.
==Inkomba==
{{reflist}}
[[Category:Afrika]]
[[Category:Sewula Afrika]]</text>
      <sha1>jkf890ty9gl72i2oyxttjnnij7tqr0y</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Abantu</title>
    <ns>10</ns>
    <id>1073</id>
    <revision>
      <id>6346</id>
      <timestamp>2026-03-26T00:11:38Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created page with &quot;Abantu&quot;</comment>
      <origin>6346</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6" sha1="6nxokm6sxd4ogic63ne0zqocwdzb282" xml:space="preserve">Abantu</text>
      <sha1>6nxokm6sxd4ogic63ne0zqocwdzb282</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Infobox Abantu</title>
    <ns>10</ns>
    <id>1074</id>
    <revision>
      <id>6347</id>
      <timestamp>2026-03-26T00:17:03Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created page with &quot;{{Infobox | above = {{{name|}}} | data1 = Born: {{{birth_date|}}} | data2 = Nationality: {{{nationality|}}} | data3 = Occupation: {{{occupation|}}} }}&quot;</comment>
      <origin>6347</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="150" sha1="q1cjxadoyzkedasg1rfu4fosnz1m125" xml:space="preserve">{{Infobox
| above = {{{name|}}}
| data1 = Born: {{{birth_date|}}}
| data2 = Nationality: {{{nationality|}}}
| data3 = Occupation: {{{occupation|}}}
}}</text>
      <sha1>q1cjxadoyzkedasg1rfu4fosnz1m125</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Infobox food</title>
    <ns>10</ns>
    <id>1075</id>
    <revision>
      <id>6348</id>
      <timestamp>2026-03-26T00:40:03Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created page with &quot;{{Infobox food | name =  | name_lang = | name_italics = | image =  | image_upright = | image_alt = | caption =  | alternative_name =  | type =  | course =  | place_of_origin =  | region =  | associated_cuisine =  | creator = | year =  | mintime =  | maxtime =  | served =  | main_ingredient =  | minor_ingredient =  | variations =  | serving_size = | calories =  | calories_ref = | protein =  | fat =  | carbohydrate =  | glycemic_index =  | similar_dish =  | module = | cook...&quot;</comment>
      <origin>6348</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="522" sha1="ic22ktb1jxz3d7rdfikdk4syanzckdp" xml:space="preserve">{{Infobox food
| name = 
| name_lang =
| name_italics =
| image = 
| image_upright =
| image_alt =
| caption = 
| alternative_name = 
| type = 
| course = 
| place_of_origin = 
| region = 
| associated_cuisine = 
| creator =
| year = 
| mintime = 
| maxtime = 
| served = 
| main_ingredient = 
| minor_ingredient = 
| variations = 
| serving_size =
| calories = 
| calories_ref =
| protein = 
| fat = 
| carbohydrate = 
| glycemic_index = 
| similar_dish = 
| module =
| cookbook =
| commons =
| other = 
| no_recipes =
}}</text>
      <sha1>ic22ktb1jxz3d7rdfikdk4syanzckdp</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Pages with template loops</title>
    <ns>14</ns>
    <id>1076</id>
    <revision>
      <id>6349</id>
      <timestamp>2026-03-26T00:40:30Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created blank page</comment>
      <origin>6349</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:~2026-18782-73</title>
    <ns>2</ns>
    <id>1077</id>
    <revision>
      <id>6352</id>
      <timestamp>2026-03-26T05:48:53Z</timestamp>
      <contributor>
        <username>~2026-18782-73</username>
        <id>1433</id>
      </contributor>
      <comment>Created blank page</comment>
      <origin>6352</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
    <revision>
      <id>6393</id>
      <parentid>6352</parentid>
      <timestamp>2026-04-05T00:41:18Z</timestamp>
      <contributor>
        <username>~2026-21067-15</username>
        <id>1459</id>
      </contributor>
      <origin>6393</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="10" sha1="35r2j9t4ectnt1cmb7mlgcqvwz6h5k6" xml:space="preserve">{{delete}}</text>
      <sha1>35r2j9t4ectnt1cmb7mlgcqvwz6h5k6</sha1>
    </revision>
    <revision>
      <id>6520</id>
      <parentid>6393</parentid>
      <timestamp>2026-05-18T10:48:40Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>'''Akukho sizathu esinikeziweko'''</comment>
      <origin>6520</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
  </page>
  <page>
    <title>U-Fannie Masemola</title>
    <ns>0</ns>
    <id>1079</id>
    <revision>
      <id>6354</id>
      <timestamp>2026-03-29T01:19:39Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1328971166|Fannie Masemola]]&quot;</comment>
      <origin>6354</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6053" sha1="6gd0p8vh97wdts8vhbhg2o7rx7aui0c" xml:space="preserve">
'''U-Fannie Masemola''' (wabelethwa ngo-1964) nguKhomitjhina weNarha wePholisa leSewula Afrika . &lt;ref&gt;{{Cite web|title=Media statement: Police Committee Chairperson welcomes appointment of new National Commissioner of Police|url=https://www.parliament.gov.za/press-releases/media-statement-police-committee-chairperson-welcomes-appointment-new-national-commissioner-police|website=Parliament of South Africa|access-date=2025-09-05}}{{Cite web|title=Media statement: Police Committee Chairperson welcomes appointment of new National Commissioner of Police|url=https://www.parliament.gov.za/press-releases/media-statement-police-committee-chairperson-welcomes-appointment-new-national-commissioner-police|website=Parliament of South Africa|access-date=2025-09-05}}&lt;/ref&gt; ]  &lt;ref&gt;{{Cite web|title=National Police Commissioner General Fannie Masemola: Media briefing on human resources related priorities {{!}} South African Government|url=https://www.gov.za/news/speeches/national-police-commissioner-general-fannie-masemola-media-briefing-human-resources|access-date=2025-09-03|website=www.gov.za}}https://www.gov.za/news/speeches/national-police-commissioner-general-fannie-masemola-media-briefing-human-resources&lt;/ref&gt; &lt;ref&gt;https://publicsectorleaders.co.za/meet-sas-new-police-commissioner/&lt;/ref&gt;

== Ipilo yokuthoma ==
U-Sehlahle Fannie Masemola wabelethwa ngo-1964 e -Groblersdal esifundazweni se [[Limpopo|-Limpopo]] [[Isewula Afrika|eSewula Afrika]] . U-Masemola wakhulela emndenini wamapholisa begodu bekathathekile ngomsebenzi wokugandelela umthetho kusukela asesemncani. &lt;ref&gt;https://www.citizen.co.za/news/south-africa/sas-new-police-commissioner-what-you-need-to-know-about-top-cop-general-fannie-masemola/&lt;/ref&gt; Ngo-1987 wajoyina amaPholisa weSewula Afrika.

== Ifundo nomsebenzi ==
U-Masemola une-Diploma ne-Higher Diploma ku-Pholisa kanye ne-Masters ku-Public Management.  Wasebenza iminyaka eli-10 e- KwaZulu-Natal lapho bekayiSekela likaKhomitjhina wePhrovinsi, esikhundleni sokuba nguMeja Jikelele, ophethe imisebenzi ngaphambi kobana adluliselwe ePitoli ngo-2010 njengoKhomitjhina weSigaba esiBambeleleko seMisebenzi yokuVikela nezokuPhepha. Wahlala ayi-Major General bekwaba nguNobayeni wee-2010 lokha nakaphakanyiselwa esikhundleni sokuba ngu-Lieutenant General bona akhokhele i-Division, Protection and Security Services.

== Ikohlakalo ==
Ngenyanga kaRhoboyi wee-2025, kwabikwa bona u-Masemola uqalene nokubotjhwa ngebanga leensolo zekohlakalo. &lt;ref&gt;{{Cite web|last=Mashego|first=Abram|title=The case against Masemola: SAPS boss and 4 top cops in firing line|url=https://www.news24.com/citypress/news/the-case-against-masemola-saps-boss-and-4-top-cops-in-firing-line-20250809-0985|access-date=2025-09-05|website=News24|language=en-US}}https://www.news24.com/citypress/news/the-case-against-masemola-saps-boss-and-4-top-cops-in-firing-line-20250809-0985&lt;/ref&gt; U-Masemola usolwa ngokuthi usebenzise kumbi imali evela ku-akhawundi yesevisi eyimfihlo yezobulelesi begodu wathenga iindawo ezimbili e -Pitoria (i-Veroz Boutique Hotel) ne -Midrand (i-Kyalami Lodge) ngaphandle kokulandela iinkambiso ezifaneleko. &lt;ref&gt;{{Cite web|last=Manyane|first=Manyane|date=2025-07-27|title=Investigation reveals National Police Commissioner Masemola's questionable financial dealings|url=https://iol.co.za/news/south-africa/2025-07-27-investigation-reveals-national-police-commissioner-masemolas-questionable-financial-dealings/|access-date=2025-09-05|website=IOL|language=en}}https://iol.co.za/news/south-africa/2025-07-27-investigation-reveals-national-police-commissioner-masemolas-questionable-financial-dealings/&lt;/ref&gt; Omunye wabasebenzisani baka-Masemola, u-Lieutenant-General [[Dumisani Khumalo]] okhokhela ubulelesi, ubotjhwe ngebanga lokukhwabanisa nekohlakalo ehlobene nokuthengwa kwehhotela elihle khulu e-Pitoria North, okubikwa bona lathengwa nge-R22.7 yezigidi kanye nesakhiwo sezokuthengisa e -Durban, esilinganiselwa ku-R2.8 &lt;ref&gt;{{Cite web|last=Manyane|first=Manyane|date=2025-08-09|title=Fannie Masemola, police commissioner, reportedly faces arrest for corruption|url=https://iol.co.za/news/2025-08-09-fannie-masemola-police-commissioner-reportedly-faces-arrest-for-corruption/|access-date=2025-09-05|website=IOL|language=en}}https://iol.co.za/news/2025-08-09-fannie-masemola-police-commissioner-reportedly-faces-arrest-for-corruption/&lt;/ref&gt; &lt;ref&gt;{{Cite web|date=2025-07-10|title=SAPS leadership shaken as Masemola breaks silence on Mkhwanazi allegations and crime intelligence arrests|website=protectionweb.co.za|url=https://www.protectionweb.co.za/police/saps-leadership-shaken-as-masemola-breaks-silence-on-mkhwanazi-allegations-and-crime-intelligence-arrests/|access-date=2025-09-05|language=en-ZA}}https://www.protectionweb.co.za/police/saps-leadership-shaken-as-masemola-breaks-silence-on-mkhwanazi-allegations-and-crime-intelligence-arrests/&lt;/ref&gt; I-Directory Against Corruption yaphika bona iwaranti yokubotjhwa kwakhe ikhutjhwe, yathi imibiko le ayinasisekelo, begodu yagandelela bona iinsolo lezi azikaqinisekiswa emthethwandaba. &lt;ref&gt;{{Cite web|title=Unfounded Media Reports on a Warrant of Arrest Against the National Police Commissioner|url=https://www.npa.gov.za/media/unfounded-media-reports-warrant-arrest-against-national-police-commissioner/|access-date=2025-09-11|website=www.npa.gov.za}}https://www.npa.gov.za/media/unfounded-media-reports-warrant-arrest-against-national-police-commissioner/&lt;/ref&gt;


Ngenyanga kaKhukhulamungu 2025, u-Masemola wamisa isekela lakhe u-Shadrack Sibiya ngebanga leensolo zikaKhomitjhina wamaPholisa we-Kwazulu Natal u-Lt-Gen, u-Nhlanhla Mkhwanazi, zokuthi u-Sibiya walinga ukuhlakaza isiqhema esiphenya ngokubulawa kwezepolotiki esifundazweni. UMasemola godu uvele phambi kwekhomitjhini ye-Madlanga ukuzokunikela ubufakazi ngeensolo zokuthi amapholisa bekasebenzisana begodu avikela iinlelesi. Usole uNgqongqotjhe wamaPholisa omisiweko u-Senzo Mchunu ngokudlula igunya lakhe lomthethosisekelo ngokuyala bona iQhema lokuSebenza lokubulawa kwezepolotiki lihlakazwe msinyana ngo-2024.</text>
      <sha1>6gd0p8vh97wdts8vhbhg2o7rx7aui0c</sha1>
    </revision>
    <revision>
      <id>6355</id>
      <parentid>6354</parentid>
      <timestamp>2026-03-29T01:20:08Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6355</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6069" sha1="fbsfqg3cw9ekwokvo6m8cbnzff1k6ou" xml:space="preserve">
'''U-Fannie Masemola''' (wabelethwa ngo-1964) nguKhomitjhina weNarha wePholisa leSewula Afrika . &lt;ref&gt;{{Cite web|title=Media statement: Police Committee Chairperson welcomes appointment of new National Commissioner of Police|url=https://www.parliament.gov.za/press-releases/media-statement-police-committee-chairperson-welcomes-appointment-new-national-commissioner-police|website=Parliament of South Africa|access-date=2025-09-05}}{{Cite web|title=Media statement: Police Committee Chairperson welcomes appointment of new National Commissioner of Police|url=https://www.parliament.gov.za/press-releases/media-statement-police-committee-chairperson-welcomes-appointment-new-national-commissioner-police|website=Parliament of South Africa|access-date=2025-09-05}}&lt;/ref&gt; ]  &lt;ref&gt;{{Cite web|title=National Police Commissioner General Fannie Masemola: Media briefing on human resources related priorities {{!}} South African Government|url=https://www.gov.za/news/speeches/national-police-commissioner-general-fannie-masemola-media-briefing-human-resources|access-date=2025-09-03|website=www.gov.za}}https://www.gov.za/news/speeches/national-police-commissioner-general-fannie-masemola-media-briefing-human-resources&lt;/ref&gt; &lt;ref&gt;https://publicsectorleaders.co.za/meet-sas-new-police-commissioner/&lt;/ref&gt;

== Ipilo yokuthoma ==
U-Sehlahle Fannie Masemola wabelethwa ngo-1964 e -Groblersdal esifundazweni se [[Limpopo|-Limpopo]] [[Isewula Afrika|eSewula Afrika]] . U-Masemola wakhulela emndenini wamapholisa begodu bekathathekile ngomsebenzi wokugandelela umthetho kusukela asesemncani. &lt;ref&gt;https://www.citizen.co.za/news/south-africa/sas-new-police-commissioner-what-you-need-to-know-about-top-cop-general-fannie-masemola/&lt;/ref&gt; Ngo-1987 wajoyina amaPholisa weSewula Afrika.

== Ifundo nomsebenzi ==
U-Masemola une-Diploma ne-Higher Diploma ku-Pholisa kanye ne-Masters ku-Public Management.  Wasebenza iminyaka eli-10 e- KwaZulu-Natal lapho bekayiSekela likaKhomitjhina wePhrovinsi, esikhundleni sokuba nguMeja Jikelele, ophethe imisebenzi ngaphambi kobana adluliselwe ePitoli ngo-2010 njengoKhomitjhina weSigaba esiBambeleleko seMisebenzi yokuVikela nezokuPhepha. Wahlala ayi-Major General bekwaba nguNobayeni wee-2010 lokha nakaphakanyiselwa esikhundleni sokuba ngu-Lieutenant General bona akhokhele i-Division, Protection and Security Services.

== Ikohlakalo ==
Ngenyanga kaRhoboyi wee-2025, kwabikwa bona u-Masemola uqalene nokubotjhwa ngebanga leensolo zekohlakalo. &lt;ref&gt;{{Cite web|last=Mashego|first=Abram|title=The case against Masemola: SAPS boss and 4 top cops in firing line|url=https://www.news24.com/citypress/news/the-case-against-masemola-saps-boss-and-4-top-cops-in-firing-line-20250809-0985|access-date=2025-09-05|website=News24|language=en-US}}https://www.news24.com/citypress/news/the-case-against-masemola-saps-boss-and-4-top-cops-in-firing-line-20250809-0985&lt;/ref&gt; U-Masemola usolwa ngokuthi usebenzise kumbi imali evela ku-akhawundi yesevisi eyimfihlo yezobulelesi begodu wathenga iindawo ezimbili e -Pitoria (i-Veroz Boutique Hotel) ne -Midrand (i-Kyalami Lodge) ngaphandle kokulandela iinkambiso ezifaneleko. &lt;ref&gt;{{Cite web|last=Manyane|first=Manyane|date=2025-07-27|title=Investigation reveals National Police Commissioner Masemola's questionable financial dealings|url=https://iol.co.za/news/south-africa/2025-07-27-investigation-reveals-national-police-commissioner-masemolas-questionable-financial-dealings/|access-date=2025-09-05|website=IOL|language=en}}https://iol.co.za/news/south-africa/2025-07-27-investigation-reveals-national-police-commissioner-masemolas-questionable-financial-dealings/&lt;/ref&gt; Omunye wabasebenzisani baka-Masemola, u-Lieutenant-General [[Dumisani Khumalo]] okhokhela ubulelesi, ubotjhwe ngebanga lokukhwabanisa nekohlakalo ehlobene nokuthengwa kwehhotela elihle khulu e-Pitoria North, okubikwa bona lathengwa nge-R22.7 yezigidi kanye nesakhiwo sezokuthengisa e -Durban, esilinganiselwa ku-R2.8 &lt;ref&gt;{{Cite web|last=Manyane|first=Manyane|date=2025-08-09|title=Fannie Masemola, police commissioner, reportedly faces arrest for corruption|url=https://iol.co.za/news/2025-08-09-fannie-masemola-police-commissioner-reportedly-faces-arrest-for-corruption/|access-date=2025-09-05|website=IOL|language=en}}https://iol.co.za/news/2025-08-09-fannie-masemola-police-commissioner-reportedly-faces-arrest-for-corruption/&lt;/ref&gt; &lt;ref&gt;{{Cite web|date=2025-07-10|title=SAPS leadership shaken as Masemola breaks silence on Mkhwanazi allegations and crime intelligence arrests|website=protectionweb.co.za|url=https://www.protectionweb.co.za/police/saps-leadership-shaken-as-masemola-breaks-silence-on-mkhwanazi-allegations-and-crime-intelligence-arrests/|access-date=2025-09-05|language=en-ZA}}https://www.protectionweb.co.za/police/saps-leadership-shaken-as-masemola-breaks-silence-on-mkhwanazi-allegations-and-crime-intelligence-arrests/&lt;/ref&gt; I-Directory Against Corruption yaphika bona iwaranti yokubotjhwa kwakhe ikhutjhwe, yathi imibiko le ayinasisekelo, begodu yagandelela bona iinsolo lezi azikaqinisekiswa emthethwandaba. &lt;ref&gt;{{Cite web|title=Unfounded Media Reports on a Warrant of Arrest Against the National Police Commissioner|url=https://www.npa.gov.za/media/unfounded-media-reports-warrant-arrest-against-national-police-commissioner/|access-date=2025-09-11|website=www.npa.gov.za}}https://www.npa.gov.za/media/unfounded-media-reports-warrant-arrest-against-national-police-commissioner/&lt;/ref&gt;


Ngenyanga kaKhukhulamungu 2025, u-Masemola wamisa isekela lakhe u-Shadrack Sibiya ngebanga leensolo zikaKhomitjhina wamaPholisa we-Kwazulu Natal u-Lt-Gen, u-Nhlanhla Mkhwanazi, zokuthi u-Sibiya walinga ukuhlakaza isiqhema esiphenya ngokubulawa kwezepolotiki esifundazweni. UMasemola godu uvele phambi kwekhomitjhini ye-Madlanga ukuzokunikela ubufakazi ngeensolo zokuthi amapholisa bekasebenzisana begodu avikela iinlelesi. Usole uNgqongqotjhe wamaPholisa omisiweko u-Senzo Mchunu ngokudlula igunya lakhe lomthethosisekelo ngokuyala bona iQhema lokuSebenza lokubulawa kwezepolotiki lihlakazwe msinyana ngo-2024.

== Iinkomba ==</text>
      <sha1>fbsfqg3cw9ekwokvo6m8cbnzff1k6ou</sha1>
    </revision>
    <revision>
      <id>6356</id>
      <parentid>6355</parentid>
      <timestamp>2026-03-29T01:20:26Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6356</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6081" sha1="f3nhoro86f3zy5ci1exlxeewk7jyy72" xml:space="preserve">
'''U-Fannie Masemola''' (wabelethwa ngo-1964) nguKhomitjhina weNarha wePholisa leSewula Afrika . &lt;ref&gt;{{Cite web|title=Media statement: Police Committee Chairperson welcomes appointment of new National Commissioner of Police|url=https://www.parliament.gov.za/press-releases/media-statement-police-committee-chairperson-welcomes-appointment-new-national-commissioner-police|website=Parliament of South Africa|access-date=2025-09-05}}{{Cite web|title=Media statement: Police Committee Chairperson welcomes appointment of new National Commissioner of Police|url=https://www.parliament.gov.za/press-releases/media-statement-police-committee-chairperson-welcomes-appointment-new-national-commissioner-police|website=Parliament of South Africa|access-date=2025-09-05}}&lt;/ref&gt; ]  &lt;ref&gt;{{Cite web|title=National Police Commissioner General Fannie Masemola: Media briefing on human resources related priorities {{!}} South African Government|url=https://www.gov.za/news/speeches/national-police-commissioner-general-fannie-masemola-media-briefing-human-resources|access-date=2025-09-03|website=www.gov.za}}https://www.gov.za/news/speeches/national-police-commissioner-general-fannie-masemola-media-briefing-human-resources&lt;/ref&gt; &lt;ref&gt;https://publicsectorleaders.co.za/meet-sas-new-police-commissioner/&lt;/ref&gt;

== Ipilo yokuthoma ==
U-Sehlahle Fannie Masemola wabelethwa ngo-1964 e -Groblersdal esifundazweni se [[Limpopo|-Limpopo]] [[Isewula Afrika|eSewula Afrika]] . U-Masemola wakhulela emndenini wamapholisa begodu bekathathekile ngomsebenzi wokugandelela umthetho kusukela asesemncani. &lt;ref&gt;https://www.citizen.co.za/news/south-africa/sas-new-police-commissioner-what-you-need-to-know-about-top-cop-general-fannie-masemola/&lt;/ref&gt; Ngo-1987 wajoyina amaPholisa weSewula Afrika.

== Ifundo nomsebenzi ==
U-Masemola une-Diploma ne-Higher Diploma ku-Pholisa kanye ne-Masters ku-Public Management.  Wasebenza iminyaka eli-10 e- KwaZulu-Natal lapho bekayiSekela likaKhomitjhina wePhrovinsi, esikhundleni sokuba nguMeja Jikelele, ophethe imisebenzi ngaphambi kobana adluliselwe ePitoli ngo-2010 njengoKhomitjhina weSigaba esiBambeleleko seMisebenzi yokuVikela nezokuPhepha. Wahlala ayi-Major General bekwaba nguNobayeni wee-2010 lokha nakaphakanyiselwa esikhundleni sokuba ngu-Lieutenant General bona akhokhele i-Division, Protection and Security Services.

== Ikohlakalo ==
Ngenyanga kaRhoboyi wee-2025, kwabikwa bona u-Masemola uqalene nokubotjhwa ngebanga leensolo zekohlakalo. &lt;ref&gt;{{Cite web|last=Mashego|first=Abram|title=The case against Masemola: SAPS boss and 4 top cops in firing line|url=https://www.news24.com/citypress/news/the-case-against-masemola-saps-boss-and-4-top-cops-in-firing-line-20250809-0985|access-date=2025-09-05|website=News24|language=en-US}}https://www.news24.com/citypress/news/the-case-against-masemola-saps-boss-and-4-top-cops-in-firing-line-20250809-0985&lt;/ref&gt; U-Masemola usolwa ngokuthi usebenzise kumbi imali evela ku-akhawundi yesevisi eyimfihlo yezobulelesi begodu wathenga iindawo ezimbili e -Pitoria (i-Veroz Boutique Hotel) ne -Midrand (i-Kyalami Lodge) ngaphandle kokulandela iinkambiso ezifaneleko. &lt;ref&gt;{{Cite web|last=Manyane|first=Manyane|date=2025-07-27|title=Investigation reveals National Police Commissioner Masemola's questionable financial dealings|url=https://iol.co.za/news/south-africa/2025-07-27-investigation-reveals-national-police-commissioner-masemolas-questionable-financial-dealings/|access-date=2025-09-05|website=IOL|language=en}}https://iol.co.za/news/south-africa/2025-07-27-investigation-reveals-national-police-commissioner-masemolas-questionable-financial-dealings/&lt;/ref&gt; Omunye wabasebenzisani baka-Masemola, u-Lieutenant-General [[Dumisani Khumalo]] okhokhela ubulelesi, ubotjhwe ngebanga lokukhwabanisa nekohlakalo ehlobene nokuthengwa kwehhotela elihle khulu e-Pitoria North, okubikwa bona lathengwa nge-R22.7 yezigidi kanye nesakhiwo sezokuthengisa e -Durban, esilinganiselwa ku-R2.8 &lt;ref&gt;{{Cite web|last=Manyane|first=Manyane|date=2025-08-09|title=Fannie Masemola, police commissioner, reportedly faces arrest for corruption|url=https://iol.co.za/news/2025-08-09-fannie-masemola-police-commissioner-reportedly-faces-arrest-for-corruption/|access-date=2025-09-05|website=IOL|language=en}}https://iol.co.za/news/2025-08-09-fannie-masemola-police-commissioner-reportedly-faces-arrest-for-corruption/&lt;/ref&gt; &lt;ref&gt;{{Cite web|date=2025-07-10|title=SAPS leadership shaken as Masemola breaks silence on Mkhwanazi allegations and crime intelligence arrests|website=protectionweb.co.za|url=https://www.protectionweb.co.za/police/saps-leadership-shaken-as-masemola-breaks-silence-on-mkhwanazi-allegations-and-crime-intelligence-arrests/|access-date=2025-09-05|language=en-ZA}}https://www.protectionweb.co.za/police/saps-leadership-shaken-as-masemola-breaks-silence-on-mkhwanazi-allegations-and-crime-intelligence-arrests/&lt;/ref&gt; I-Directory Against Corruption yaphika bona iwaranti yokubotjhwa kwakhe ikhutjhwe, yathi imibiko le ayinasisekelo, begodu yagandelela bona iinsolo lezi azikaqinisekiswa emthethwandaba. &lt;ref&gt;{{Cite web|title=Unfounded Media Reports on a Warrant of Arrest Against the National Police Commissioner|url=https://www.npa.gov.za/media/unfounded-media-reports-warrant-arrest-against-national-police-commissioner/|access-date=2025-09-11|website=www.npa.gov.za}}https://www.npa.gov.za/media/unfounded-media-reports-warrant-arrest-against-national-police-commissioner/&lt;/ref&gt;


Ngenyanga kaKhukhulamungu 2025, u-Masemola wamisa isekela lakhe u-Shadrack Sibiya ngebanga leensolo zikaKhomitjhina wamaPholisa we-Kwazulu Natal u-Lt-Gen, u-Nhlanhla Mkhwanazi, zokuthi u-Sibiya walinga ukuhlakaza isiqhema esiphenya ngokubulawa kwezepolotiki esifundazweni. UMasemola godu uvele phambi kwekhomitjhini ye-Madlanga ukuzokunikela ubufakazi ngeensolo zokuthi amapholisa bekasebenzisana begodu avikela iinlelesi. Usole uNgqongqotjhe wamaPholisa omisiweko u-Senzo Mchunu ngokudlula igunya lakhe lomthethosisekelo ngokuyala bona iQhema lokuSebenza lokubulawa kwezepolotiki lihlakazwe msinyana ngo-2024.

== Iinkomba ==
{{reflist}}</text>
      <sha1>f3nhoro86f3zy5ci1exlxeewk7jyy72</sha1>
    </revision>
    <revision>
      <id>6357</id>
      <parentid>6356</parentid>
      <timestamp>2026-03-29T01:21:02Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6357</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6128" sha1="tvr9er1c8imlcdmebu6uyb30yludsqf" xml:space="preserve">
'''U-Fannie Masemola''' (wabelethwa ngo-1964) nguKhomitjhina weNarha wePholisa leSewula Afrika . &lt;ref&gt;{{Cite web|title=Media statement: Police Committee Chairperson welcomes appointment of new National Commissioner of Police|url=https://www.parliament.gov.za/press-releases/media-statement-police-committee-chairperson-welcomes-appointment-new-national-commissioner-police|website=Parliament of South Africa|access-date=2025-09-05}}{{Cite web|title=Media statement: Police Committee Chairperson welcomes appointment of new National Commissioner of Police|url=https://www.parliament.gov.za/press-releases/media-statement-police-committee-chairperson-welcomes-appointment-new-national-commissioner-police|website=Parliament of South Africa|access-date=2025-09-05}}&lt;/ref&gt; ]  &lt;ref&gt;{{Cite web|title=National Police Commissioner General Fannie Masemola: Media briefing on human resources related priorities {{!}} South African Government|url=https://www.gov.za/news/speeches/national-police-commissioner-general-fannie-masemola-media-briefing-human-resources|access-date=2025-09-03|website=www.gov.za}}https://www.gov.za/news/speeches/national-police-commissioner-general-fannie-masemola-media-briefing-human-resources&lt;/ref&gt; &lt;ref&gt;https://publicsectorleaders.co.za/meet-sas-new-police-commissioner/&lt;/ref&gt;

== Ipilo yokuthoma ==
U-Sehlahle Fannie Masemola wabelethwa ngo-1964 e -Groblersdal esifundazweni se [[Limpopo|-Limpopo]] [[Isewula Afrika|eSewula Afrika]] . U-Masemola wakhulela emndenini wamapholisa begodu bekathathekile ngomsebenzi wokugandelela umthetho kusukela asesemncani. &lt;ref&gt;https://www.citizen.co.za/news/south-africa/sas-new-police-commissioner-what-you-need-to-know-about-top-cop-general-fannie-masemola/&lt;/ref&gt; Ngo-1987 wajoyina amaPholisa weSewula Afrika.

== Ifundo nomsebenzi ==
U-Masemola une-Diploma ne-Higher Diploma ku-Pholisa kanye ne-Masters ku-Public Management.  Wasebenza iminyaka eli-10 e- KwaZulu-Natal lapho bekayiSekela likaKhomitjhina wePhrovinsi, esikhundleni sokuba nguMeja Jikelele, ophethe imisebenzi ngaphambi kobana adluliselwe ePitoli ngo-2010 njengoKhomitjhina weSigaba esiBambeleleko seMisebenzi yokuVikela nezokuPhepha. Wahlala ayi-Major General bekwaba nguNobayeni wee-2010 lokha nakaphakanyiselwa esikhundleni sokuba ngu-Lieutenant General bona akhokhele i-Division, Protection and Security Services.

== Ikohlakalo ==
Ngenyanga kaRhoboyi wee-2025, kwabikwa bona u-Masemola uqalene nokubotjhwa ngebanga leensolo zekohlakalo. &lt;ref&gt;{{Cite web|last=Mashego|first=Abram|title=The case against Masemola: SAPS boss and 4 top cops in firing line|url=https://www.news24.com/citypress/news/the-case-against-masemola-saps-boss-and-4-top-cops-in-firing-line-20250809-0985|access-date=2025-09-05|website=News24|language=en-US}}https://www.news24.com/citypress/news/the-case-against-masemola-saps-boss-and-4-top-cops-in-firing-line-20250809-0985&lt;/ref&gt; U-Masemola usolwa ngokuthi usebenzise kumbi imali evela ku-akhawundi yesevisi eyimfihlo yezobulelesi begodu wathenga iindawo ezimbili e -Pitoria (i-Veroz Boutique Hotel) ne -Midrand (i-Kyalami Lodge) ngaphandle kokulandela iinkambiso ezifaneleko. &lt;ref&gt;{{Cite web|last=Manyane|first=Manyane|date=2025-07-27|title=Investigation reveals National Police Commissioner Masemola's questionable financial dealings|url=https://iol.co.za/news/south-africa/2025-07-27-investigation-reveals-national-police-commissioner-masemolas-questionable-financial-dealings/|access-date=2025-09-05|website=IOL|language=en}}https://iol.co.za/news/south-africa/2025-07-27-investigation-reveals-national-police-commissioner-masemolas-questionable-financial-dealings/&lt;/ref&gt; Omunye wabasebenzisani baka-Masemola, u-Lieutenant-General [[Dumisani Khumalo]] okhokhela ubulelesi, ubotjhwe ngebanga lokukhwabanisa nekohlakalo ehlobene nokuthengwa kwehhotela elihle khulu e-Pitoria North, okubikwa bona lathengwa nge-R22.7 yezigidi kanye nesakhiwo sezokuthengisa e -Durban, esilinganiselwa ku-R2.8 &lt;ref&gt;{{Cite web|last=Manyane|first=Manyane|date=2025-08-09|title=Fannie Masemola, police commissioner, reportedly faces arrest for corruption|url=https://iol.co.za/news/2025-08-09-fannie-masemola-police-commissioner-reportedly-faces-arrest-for-corruption/|access-date=2025-09-05|website=IOL|language=en}}https://iol.co.za/news/2025-08-09-fannie-masemola-police-commissioner-reportedly-faces-arrest-for-corruption/&lt;/ref&gt; &lt;ref&gt;{{Cite web|date=2025-07-10|title=SAPS leadership shaken as Masemola breaks silence on Mkhwanazi allegations and crime intelligence arrests|website=protectionweb.co.za|url=https://www.protectionweb.co.za/police/saps-leadership-shaken-as-masemola-breaks-silence-on-mkhwanazi-allegations-and-crime-intelligence-arrests/|access-date=2025-09-05|language=en-ZA}}https://www.protectionweb.co.za/police/saps-leadership-shaken-as-masemola-breaks-silence-on-mkhwanazi-allegations-and-crime-intelligence-arrests/&lt;/ref&gt; I-Directory Against Corruption yaphika bona iwaranti yokubotjhwa kwakhe ikhutjhwe, yathi imibiko le ayinasisekelo, begodu yagandelela bona iinsolo lezi azikaqinisekiswa emthethwandaba. &lt;ref&gt;{{Cite web|title=Unfounded Media Reports on a Warrant of Arrest Against the National Police Commissioner|url=https://www.npa.gov.za/media/unfounded-media-reports-warrant-arrest-against-national-police-commissioner/|access-date=2025-09-11|website=www.npa.gov.za}}https://www.npa.gov.za/media/unfounded-media-reports-warrant-arrest-against-national-police-commissioner/&lt;/ref&gt;


Ngenyanga kaKhukhulamungu 2025, u-Masemola wamisa isekela lakhe u-Shadrack Sibiya ngebanga leensolo zikaKhomitjhina wamaPholisa we-Kwazulu Natal u-Lt-Gen, u-Nhlanhla Mkhwanazi, zokuthi u-Sibiya walinga ukuhlakaza isiqhema esiphenya ngokubulawa kwezepolotiki esifundazweni. UMasemola godu uvele phambi kwekhomitjhini ye-Madlanga ukuzokunikela ubufakazi ngeensolo zokuthi amapholisa bekasebenzisana begodu avikela iinlelesi. Usole uNgqongqotjhe wamaPholisa omisiweko u-Senzo Mchunu ngokudlula igunya lakhe lomthethosisekelo ngokuyala bona iQhema lokuSebenza lokubulawa kwezepolotiki lihlakazwe msinyana ngo-2024.

== Iinkomba ==
{{reflist}}
[[Category:Sewula Afrika]]
[[Category:Abantu]]</text>
      <sha1>tvr9er1c8imlcdmebu6uyb30yludsqf</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Abantu</title>
    <ns>14</ns>
    <id>1080</id>
    <revision>
      <id>6358</id>
      <timestamp>2026-03-29T01:21:18Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created blank page</comment>
      <origin>6358</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
  </page>
  <page>
    <title>U-Charles Taylor</title>
    <ns>0</ns>
    <id>1081</id>
    <revision>
      <id>6359</id>
      <timestamp>2026-03-30T01:30:45Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1344290263|Charles Taylor (Liberian politician)]]&quot;</comment>
      <origin>6359</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3182" sha1="45a2dzc3zle4zr45mwfgx6a41b8293k" xml:space="preserve">
'''U-Charles McArthur Ghankay Taylor''' (wabelethwa mhlazi-28 kuTjhirhweni 1948) ngusopolotiki wangaphambilini we-Liberia. Wasebenza njengomongameli wama-22 [[Liberia|we-Liberia]] kusukela mhlazi-2 kuRhoboyi wee-1997 bekwaba kulapho atjhiya khona umsebenzi mhlana ali-11 kuRhoboyi wee-2003 ngebanga lePi yesiBili ye-Liberia nokukhula kwegandelelo leentjhabatjhaba.   Ngemva kokutjhiya isikhundla, watholakala anecala lobulelesi bepi obenziwe [[Sierra Leone|ePini yomKhaya ye-Sierra Leone]], begodu wagwetjwa iminyaka ema-50 ejele.

Born in Arthington, Montserrado County, Liberia, Taylor earned a degree at Bentley College in the United States before returning to Liberia to work in the government of Samuel Doe. After being removed for embezzlement and imprisoned by President Doe, Taylor escaped prison in 1989. He eventually arrived in Libya, where he was trained as a guerrilla fighter. He returned to Liberia in 1989 as the head of a Libyan-backed rebel group, the National Patriotic Front of Liberia, to overthrow the Doe government, initiating the First Liberian Civil War (1989–1996). Following Doe's execution, Taylor gained control of a large portion of the country and became one of the most prominent warlords in Africa. His forces, along with those of other rival warlords such as ULIMO, were notorious for committing widespread human rights abuses and atrocities during the civil war. Following a peace deal that ended the war, Taylor was elected president in the 1997 general election as a member of the National Patriotic Party (NPP).

Ngesikhathi asesikhundleni, u-Taylor wasolwa ngamacala wepi kanye nobugebengu obujamelene nobuntu ngebanga lokusekela kwakhe isiqhema samavukelambuso se -Revolutionary United Front (RUF) e- Sierra Leone Civil War (1991–2002). Ekhaya, u-Taylor walinga ukuqinisa amandla ngeendlela zobukhosi ezifana nokuhlanza amasotja nokwenza udlame ebantwini abaphikisana naye kwezepolotiki, okufaka hlangana umzamo wokubulala umlawuli we-ULIMO wangaphambilini u-Roosevelt Johnson, okwadosela ekutheni kube nokurarana okunobudlova e-Monrovia ngo-1998 . Njengomphumela, ukuphikiswa kurhulumende wakhe kwakhula, kwagcina ngokuqubuka kwePi yesiBili ye-Liberia ngo-1999. Ngo-2003, u-Taylor besele alahlekelwe kulawula indawo enengi yemaphandleni begodu wamangalelwa ngokusemthethweni yiKhotho eKhethekileko ye-Sierra Leone . Ngalowo mnyaka, walisa umsebenzi ngebanga lokugandeleleka kwamazwe ngamazwe begodu waya e-Nigeria. Ngomnyaka ka-2006, umengameli we-Liberia, u-Ellen Johnson Sirleaf, wabawa ngokusemthethweni ukuthunyelwa kwakhe. Wavalelwa ziimphathimandla ze-UN e- Sierra Leone bese wavalelwa e- Penitentiary Institution Haaglanden e- The Hague, alindele ukuthonisiswa yiKhotho eKhethekileko.  Watholakala anecala ngoMrhayili 2012 kiwo woke amacala alitjhumi nanye abekwe yiKhotho eKhethekileko, kufaka hlangana ukuthusa, ukubulala nokudlwengula. 


In May 2012, Taylor was sentenced to 50 years in prison. Reading the sentencing statement, presiding Judge Richard Lussick said: &quot;The accused has been found responsible for aiding and abetting as well as planning some of the most heinous and brutal crimes in recorded human history.&quot;[1]</text>
      <sha1>45a2dzc3zle4zr45mwfgx6a41b8293k</sha1>
    </revision>
    <revision>
      <id>6360</id>
      <parentid>6359</parentid>
      <timestamp>2026-03-30T01:33:21Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1344290263|Charles Taylor (Liberian politician)]]&quot;</comment>
      <origin>6360</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4518" sha1="jx1amwhqpkfoiuhpu8oh8tjdrpcsrgg" xml:space="preserve">
'''U-Charles McArthur Ghankay Taylor''' (wabelethwa mhlazi-28 kuTjhirhweni 1948) ngusopolotiki wangaphambilini we-Liberia. Wasebenza njengomongameli wama-22 [[Liberia|we-Liberia]] kusukela mhlazi-2 kuRhoboyi wee-1997 bekwaba kulapho atjhiya khona umsebenzi mhlana ali-11 kuRhoboyi wee-2003 ngebanga lePi yesiBili ye-Liberia nokukhula kwegandelelo leentjhabatjhaba. &lt;ref name=&quot;allafricatheend&quot;&gt;{{cite news|first=Ofeibea|last=Quist-Arcton|title=Liberia: Charles Ghankay Taylor, Defiant And Passionate to the End|date=11 August 2004|publisher=allAfrica.com|url=http://allafrica.com/stories/200408111235.html|access-date=18 January 2008}}http://allafrica.com/stories/200408111235.html&lt;/ref&gt; &lt;ref&gt;{{Cite news|last=Agencies|url=https://www.theguardian.com/world/2004/aug/11/westafrica|title=Liberian president Taylor steps down|date=2004-08-11|work=The Guardian|access-date=2020-02-28|language=en-GB|issn=0261-3077}}https://www.theguardian.com/world/2004/aug/11/westafrica&lt;/ref&gt; Ngemva kokutjhiya isikhundla, watholakala anecala lobulelesi bepi obenziwe [[Sierra Leone|ePini yomKhaya ye-Sierra Leone]], begodu wagwetjwa iminyaka ema-50 ejele.

Born in Arthington, Montserrado County, Liberia, Taylor earned a degree at Bentley College in the United States before returning to Liberia to work in the government of Samuel Doe. After being removed for embezzlement and imprisoned by President Doe, Taylor escaped prison in 1989. He eventually arrived in Libya, where he was trained as a guerrilla fighter. He returned to Liberia in 1989 as the head of a Libyan-backed rebel group, the National Patriotic Front of Liberia, to overthrow the Doe government, initiating the First Liberian Civil War (1989–1996). Following Doe's execution, Taylor gained control of a large portion of the country and became one of the most prominent warlords in Africa. His forces, along with those of other rival warlords such as ULIMO, were notorious for committing widespread human rights abuses and atrocities during the civil war. Following a peace deal that ended the war, Taylor was elected president in the 1997 general election as a member of the National Patriotic Party (NPP).&lt;ref&gt;{{cite news|url=https://www.nytimes.com/2000/12/07/world/in-ruined-liberia-its-despoiler-sits-pretty.html|work=The New York Times|first=Norimitsu|last=Onishi|title=In Ruined Liberia, Its Despoiler Sits Pretty|date=7 December 2000}}https://www.nytimes.com/2000/12/07/world/in-ruined-liberia-its-despoiler-sits-pretty.html&lt;/ref&gt;

Ngesikhathi asesikhundleni, u-Taylor wasolwa ngamacala wepi kanye nobugebengu obujamelene nobuntu ngebanga lokusekela kwakhe isiqhema samavukelambuso se -Revolutionary United Front (RUF) e- Sierra Leone Civil War (1991–2002). Ekhaya, u-Taylor walinga ukuqinisa amandla ngeendlela zobukhosi ezifana nokuhlanza amasotja nokwenza udlame ebantwini abaphikisana naye kwezepolotiki, okufaka hlangana umzamo wokubulala umlawuli we-ULIMO wangaphambilini u-Roosevelt Johnson, okwadosela ekutheni kube nokurarana okunobudlova e-Monrovia ngo-1998 . Njengomphumela, ukuphikiswa kurhulumende wakhe kwakhula, kwagcina ngokuqubuka kwePi yesiBili ye-Liberia ngo-1999. Ngo-2003, u-Taylor besele alahlekelwe kulawula indawo enengi yemaphandleni begodu wamangalelwa ngokusemthethweni yiKhotho eKhethekileko ye-Sierra Leone . Ngalowo mnyaka, walisa umsebenzi ngebanga lokugandeleleka kwamazwe ngamazwe begodu waya e-Nigeria. Ngomnyaka ka-2006, umengameli we-Liberia, u-Ellen Johnson Sirleaf, wabawa ngokusemthethweni ukuthunyelwa kwakhe. Wavalelwa ziimphathimandla ze-UN e- Sierra Leone bese wavalelwa e- Penitentiary Institution Haaglanden e- The Hague, alindele ukuthonisiswa yiKhotho eKhethekileko.  Watholakala anecala ngoMrhayili 2012 kiwo woke amacala alitjhumi nanye abekwe yiKhotho eKhethekileko, kufaka hlangana ukuthusa, ukubulala nokudlwengula. &lt;ref&gt;{{cite news|date=26 April 2012|title=Taylor Sierra Leone war crimes verdict welcomed|url=https://www.bbc.co.uk/news/world-africa-17864387|archive-url=https://web.archive.org/web/20240912183258/https://www.bbc.com/news/world-africa-17864387|archive-date=2024-09-12|access-date=1 May 2012|publisher=BBC}}https://web.archive.org/web/20240912183258/https://www.bbc.com/news/world-africa-17864387&lt;/ref&gt;


In May 2012, Taylor was sentenced to 50 years in prison. Reading the sentencing statement, presiding Judge Richard Lussick said: &quot;The accused has been found responsible for aiding and abetting as well as planning some of the most heinous and brutal crimes in recorded human history.&quot;</text>
      <sha1>jx1amwhqpkfoiuhpu8oh8tjdrpcsrgg</sha1>
    </revision>
    <revision>
      <id>6361</id>
      <parentid>6360</parentid>
      <timestamp>2026-03-30T01:34:18Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1344290263|Charles Taylor (Liberian politician)]]&quot;</comment>
      <origin>6361</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4617" sha1="hun4eqlwntov806b99mqjkpdgbpmve8" xml:space="preserve">
'''U-Charles McArthur Ghankay Taylor''' (wabelethwa mhlazi-28 kuTjhirhweni 1948) ngusopolotiki wangaphambilini we-Liberia. Wasebenza njengomongameli wama-22 [[Liberia|we-Liberia]] kusukela mhlazi-2 kuRhoboyi wee-1997 bekwaba kulapho atjhiya khona umsebenzi mhlana ali-11 kuRhoboyi wee-2003 ngebanga lePi yesiBili ye-Liberia nokukhula kwegandelelo leentjhabatjhaba. &lt;ref name=&quot;allafricatheend&quot;&gt;{{cite news|first=Ofeibea|last=Quist-Arcton|title=Liberia: Charles Ghankay Taylor, Defiant And Passionate to the End|date=11 August 2004|publisher=allAfrica.com|url=http://allafrica.com/stories/200408111235.html|access-date=18 January 2008}}http://allafrica.com/stories/200408111235.html&lt;/ref&gt; &lt;ref&gt;{{Cite news|last=Agencies|url=https://www.theguardian.com/world/2004/aug/11/westafrica|title=Liberian president Taylor steps down|date=2004-08-11|work=The Guardian|access-date=2020-02-28|language=en-GB|issn=0261-3077}}https://www.theguardian.com/world/2004/aug/11/westafrica&lt;/ref&gt; Ngemva kokutjhiya isikhundla, watholakala anecala lobulelesi bepi obenziwe [[Sierra Leone|ePini yomKhaya ye-Sierra Leone]], begodu wagwetjwa iminyaka ema-50 ejele.

Born in Arthington, Montserrado County, Liberia, Taylor earned a degree at Bentley College in the United States before returning to Liberia to work in the government of Samuel Doe. After being removed for embezzlement and imprisoned by President Doe, Taylor escaped prison in 1989. He eventually arrived in Libya, where he was trained as a guerrilla fighter. He returned to Liberia in 1989 as the head of a Libyan-backed rebel group, the National Patriotic Front of Liberia, to overthrow the Doe government, initiating the First Liberian Civil War (1989–1996). Following Doe's execution, Taylor gained control of a large portion of the country and became one of the most prominent warlords in Africa. His forces, along with those of other rival warlords such as ULIMO, were notorious for committing widespread human rights abuses and atrocities during the civil war. Following a peace deal that ended the war, Taylor was elected president in the 1997 general election as a member of the National Patriotic Party (NPP).&lt;ref&gt;{{cite news|url=https://www.nytimes.com/2000/12/07/world/in-ruined-liberia-its-despoiler-sits-pretty.html|work=The New York Times|first=Norimitsu|last=Onishi|title=In Ruined Liberia, Its Despoiler Sits Pretty|date=7 December 2000}}https://www.nytimes.com/2000/12/07/world/in-ruined-liberia-its-despoiler-sits-pretty.html&lt;/ref&gt;

Ngesikhathi asesikhundleni, u-Taylor wasolwa ngamacala wepi kanye nobugebengu obujamelene nobuntu ngebanga lokusekela kwakhe isiqhema samavukelambuso se -Revolutionary United Front (RUF) e- Sierra Leone Civil War (1991–2002). Ekhaya, u-Taylor walinga ukuqinisa amandla ngeendlela zobukhosi ezifana nokuhlanza amasotja nokwenza udlame ebantwini abaphikisana naye kwezepolotiki, okufaka hlangana umzamo wokubulala umlawuli we-ULIMO wangaphambilini u-Roosevelt Johnson, okwadosela ekutheni kube nokurarana okunobudlova e-Monrovia ngo-1998 . Njengomphumela, ukuphikiswa kurhulumende wakhe kwakhula, kwagcina ngokuqubuka kwePi yesiBili ye-Liberia ngo-1999. Ngo-2003, u-Taylor besele alahlekelwe kulawula indawo enengi yemaphandleni begodu wamangalelwa ngokusemthethweni yiKhotho eKhethekileko ye-Sierra Leone . Ngalowo mnyaka, walisa umsebenzi ngebanga lokugandeleleka kwamazwe ngamazwe begodu waya e-Nigeria. Ngomnyaka ka-2006, umengameli we-Liberia, u-Ellen Johnson Sirleaf, wabawa ngokusemthethweni ukuthunyelwa kwakhe. Wavalelwa ziimphathimandla ze-UN e- Sierra Leone bese wavalelwa e- Penitentiary Institution Haaglanden e- The Hague, alindele ukuthonisiswa yiKhotho eKhethekileko.  Watholakala anecala ngoMrhayili 2012 kiwo woke amacala alitjhumi nanye abekwe yiKhotho eKhethekileko, kufaka hlangana ukuthusa, ukubulala nokudlwengula. &lt;ref&gt;{{cite news|date=26 April 2012|title=Taylor Sierra Leone war crimes verdict welcomed|url=https://www.bbc.co.uk/news/world-africa-17864387|archive-url=https://web.archive.org/web/20240912183258/https://www.bbc.com/news/world-africa-17864387|archive-date=2024-09-12|access-date=1 May 2012|publisher=BBC}}https://web.archive.org/web/20240912183258/https://www.bbc.com/news/world-africa-17864387&lt;/ref&gt;


In May 2012, Taylor was sentenced to 50 years in prison. Reading the sentencing statement, presiding Judge Richard Lussick said: &quot;The accused has been found responsible for aiding and abetting as well as planning some of the most heinous and brutal crimes in recorded human history.&quot;&lt;ref&gt;https://edition.cnn.com/2012/05/30/world/africa/netherlands-taylor-sentencing/index.html&lt;/ref&gt;</text>
      <sha1>hun4eqlwntov806b99mqjkpdgbpmve8</sha1>
    </revision>
    <revision>
      <id>6362</id>
      <parentid>6361</parentid>
      <timestamp>2026-03-30T01:35:07Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6362</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4644" sha1="ap2fhqhvv1mh6bmm0omj7gzbi5kn9gn" xml:space="preserve">
'''U-Charles McArthur Ghankay Taylor''' (wabelethwa mhlazi-28 kuTjhirhweni 1948) ngusopolotiki wangaphambilini we-Liberia. Wasebenza njengomongameli wama-22 [[Liberia|we-Liberia]] kusukela mhlazi-2 kuRhoboyi wee-1997 bekwaba kulapho atjhiya khona umsebenzi mhlana ali-11 kuRhoboyi wee-2003 ngebanga lePi yesiBili ye-Liberia nokukhula kwegandelelo leentjhabatjhaba. &lt;ref name=&quot;allafricatheend&quot;&gt;{{cite news|first=Ofeibea|last=Quist-Arcton|title=Liberia: Charles Ghankay Taylor, Defiant And Passionate to the End|date=11 August 2004|publisher=allAfrica.com|url=http://allafrica.com/stories/200408111235.html|access-date=18 January 2008}}http://allafrica.com/stories/200408111235.html&lt;/ref&gt; &lt;ref&gt;{{Cite news|last=Agencies|url=https://www.theguardian.com/world/2004/aug/11/westafrica|title=Liberian president Taylor steps down|date=2004-08-11|work=The Guardian|access-date=2020-02-28|language=en-GB|issn=0261-3077}}https://www.theguardian.com/world/2004/aug/11/westafrica&lt;/ref&gt; Ngemva kokutjhiya isikhundla, watholakala anecala lobulelesi bepi obenziwe [[Sierra Leone|ePini yomKhaya ye-Sierra Leone]], begodu wagwetjwa iminyaka ema-50 ejele.

Born in Arthington, Montserrado County, Liberia, Taylor earned a degree at Bentley College in the United States before returning to Liberia to work in the government of Samuel Doe. After being removed for embezzlement and imprisoned by President Doe, Taylor escaped prison in 1989. He eventually arrived in Libya, where he was trained as a guerrilla fighter. He returned to Liberia in 1989 as the head of a Libyan-backed rebel group, the National Patriotic Front of Liberia, to overthrow the Doe government, initiating the First Liberian Civil War (1989–1996). Following Doe's execution, Taylor gained control of a large portion of the country and became one of the most prominent warlords in Africa. His forces, along with those of other rival warlords such as ULIMO, were notorious for committing widespread human rights abuses and atrocities during the civil war. Following a peace deal that ended the war, Taylor was elected president in the 1997 general election as a member of the National Patriotic Party (NPP).&lt;ref&gt;{{cite news|url=https://www.nytimes.com/2000/12/07/world/in-ruined-liberia-its-despoiler-sits-pretty.html|work=The New York Times|first=Norimitsu|last=Onishi|title=In Ruined Liberia, Its Despoiler Sits Pretty|date=7 December 2000}}https://www.nytimes.com/2000/12/07/world/in-ruined-liberia-its-despoiler-sits-pretty.html&lt;/ref&gt;

Ngesikhathi asesikhundleni, u-Taylor wasolwa ngamacala wepi kanye nobugebengu obujamelene nobuntu ngebanga lokusekela kwakhe isiqhema samavukelambuso se -Revolutionary United Front (RUF) e- Sierra Leone Civil War (1991–2002). Ekhaya, u-Taylor walinga ukuqinisa amandla ngeendlela zobukhosi ezifana nokuhlanza amasotja nokwenza udlame ebantwini abaphikisana naye kwezepolotiki, okufaka hlangana umzamo wokubulala umlawuli we-ULIMO wangaphambilini u-Roosevelt Johnson, okwadosela ekutheni kube nokurarana okunobudlova e-Monrovia ngo-1998 . Njengomphumela, ukuphikiswa kurhulumende wakhe kwakhula, kwagcina ngokuqubuka kwePi yesiBili ye-Liberia ngo-1999. Ngo-2003, u-Taylor besele alahlekelwe kulawula indawo enengi yemaphandleni begodu wamangalelwa ngokusemthethweni yiKhotho eKhethekileko ye-Sierra Leone . Ngalowo mnyaka, walisa umsebenzi ngebanga lokugandeleleka kwamazwe ngamazwe begodu waya e-Nigeria. Ngomnyaka ka-2006, umengameli we-Liberia, u-Ellen Johnson Sirleaf, wabawa ngokusemthethweni ukuthunyelwa kwakhe. Wavalelwa ziimphathimandla ze-UN e- Sierra Leone bese wavalelwa e- Penitentiary Institution Haaglanden e- The Hague, alindele ukuthonisiswa yiKhotho eKhethekileko.  Watholakala anecala ngoMrhayili 2012 kiwo woke amacala alitjhumi nanye abekwe yiKhotho eKhethekileko, kufaka hlangana ukuthusa, ukubulala nokudlwengula. &lt;ref&gt;{{cite news|date=26 April 2012|title=Taylor Sierra Leone war crimes verdict welcomed|url=https://www.bbc.co.uk/news/world-africa-17864387|archive-url=https://web.archive.org/web/20240912183258/https://www.bbc.com/news/world-africa-17864387|archive-date=2024-09-12|access-date=1 May 2012|publisher=BBC}}https://web.archive.org/web/20240912183258/https://www.bbc.com/news/world-africa-17864387&lt;/ref&gt;


In May 2012, Taylor was sentenced to 50 years in prison. Reading the sentencing statement, presiding Judge Richard Lussick said: &quot;The accused has been found responsible for aiding and abetting as well as planning some of the most heinous and brutal crimes in recorded human history.&quot;&lt;ref&gt;https://edition.cnn.com/2012/05/30/world/africa/netherlands-taylor-sentencing/index.html&lt;/ref&gt;
== Iinkomba ==
{{reflist}}</text>
      <sha1>ap2fhqhvv1mh6bmm0omj7gzbi5kn9gn</sha1>
    </revision>
    <revision>
      <id>6363</id>
      <parentid>6362</parentid>
      <timestamp>2026-03-30T01:36:05Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6363</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4664" sha1="dsfeo8p9cyuhfiqmrkq9csyemrnaoj0" xml:space="preserve">
'''U-Charles McArthur Ghankay Taylor''' (wabelethwa mhlazi-28 kuTjhirhweni 1948) ngusopolotiki wangaphambilini we-Liberia. Wasebenza njengomongameli wama-22 [[Liberia|we-Liberia]] kusukela mhlazi-2 kuRhoboyi wee-1997 bekwaba kulapho atjhiya khona umsebenzi mhlana ali-11 kuRhoboyi wee-2003 ngebanga lePi yesiBili ye-Liberia nokukhula kwegandelelo leentjhabatjhaba. &lt;ref name=&quot;allafricatheend&quot;&gt;{{cite news|first=Ofeibea|last=Quist-Arcton|title=Liberia: Charles Ghankay Taylor, Defiant And Passionate to the End|date=11 August 2004|publisher=allAfrica.com|url=http://allafrica.com/stories/200408111235.html|access-date=18 January 2008}}http://allafrica.com/stories/200408111235.html&lt;/ref&gt; &lt;ref&gt;{{Cite news|last=Agencies|url=https://www.theguardian.com/world/2004/aug/11/westafrica|title=Liberian president Taylor steps down|date=2004-08-11|work=The Guardian|access-date=2020-02-28|language=en-GB|issn=0261-3077}}https://www.theguardian.com/world/2004/aug/11/westafrica&lt;/ref&gt; Ngemva kokutjhiya isikhundla, watholakala anecala lobulelesi bepi obenziwe [[Sierra Leone|ePini yomKhaya ye-Sierra Leone]], begodu wagwetjwa iminyaka ema-50 ejele.

Born in Arthington, Montserrado County, Liberia, Taylor earned a degree at Bentley College in the United States before returning to Liberia to work in the government of Samuel Doe. After being removed for embezzlement and imprisoned by President Doe, Taylor escaped prison in 1989. He eventually arrived in Libya, where he was trained as a guerrilla fighter. He returned to Liberia in 1989 as the head of a Libyan-backed rebel group, the National Patriotic Front of Liberia, to overthrow the Doe government, initiating the First Liberian Civil War (1989–1996). Following Doe's execution, Taylor gained control of a large portion of the country and became one of the most prominent warlords in Africa. His forces, along with those of other rival warlords such as ULIMO, were notorious for committing widespread human rights abuses and atrocities during the civil war. Following a peace deal that ended the war, Taylor was elected president in the 1997 general election as a member of the National Patriotic Party (NPP).&lt;ref&gt;{{cite news|url=https://www.nytimes.com/2000/12/07/world/in-ruined-liberia-its-despoiler-sits-pretty.html|work=The New York Times|first=Norimitsu|last=Onishi|title=In Ruined Liberia, Its Despoiler Sits Pretty|date=7 December 2000}}https://www.nytimes.com/2000/12/07/world/in-ruined-liberia-its-despoiler-sits-pretty.html&lt;/ref&gt;

Ngesikhathi asesikhundleni, u-Taylor wasolwa ngamacala wepi kanye nobugebengu obujamelene nobuntu ngebanga lokusekela kwakhe isiqhema samavukelambuso se -Revolutionary United Front (RUF) e- Sierra Leone Civil War (1991–2002). Ekhaya, u-Taylor walinga ukuqinisa amandla ngeendlela zobukhosi ezifana nokuhlanza amasotja nokwenza udlame ebantwini abaphikisana naye kwezepolotiki, okufaka hlangana umzamo wokubulala umlawuli we-ULIMO wangaphambilini u-Roosevelt Johnson, okwadosela ekutheni kube nokurarana okunobudlova e-Monrovia ngo-1998 . Njengomphumela, ukuphikiswa kurhulumende wakhe kwakhula, kwagcina ngokuqubuka kwePi yesiBili ye-Liberia ngo-1999. Ngo-2003, u-Taylor besele alahlekelwe kulawula indawo enengi yemaphandleni begodu wamangalelwa ngokusemthethweni yiKhotho eKhethekileko ye-Sierra Leone . Ngalowo mnyaka, walisa umsebenzi ngebanga lokugandeleleka kwamazwe ngamazwe begodu waya e-Nigeria. Ngomnyaka ka-2006, umengameli we-Liberia, u-Ellen Johnson Sirleaf, wabawa ngokusemthethweni ukuthunyelwa kwakhe. Wavalelwa ziimphathimandla ze-UN e- Sierra Leone bese wavalelwa e- Penitentiary Institution Haaglanden e- The Hague, alindele ukuthonisiswa yiKhotho eKhethekileko.  Watholakala anecala ngoMrhayili 2012 kiwo woke amacala alitjhumi nanye abekwe yiKhotho eKhethekileko, kufaka hlangana ukuthusa, ukubulala nokudlwengula. &lt;ref&gt;{{cite news|date=26 April 2012|title=Taylor Sierra Leone war crimes verdict welcomed|url=https://www.bbc.co.uk/news/world-africa-17864387|archive-url=https://web.archive.org/web/20240912183258/https://www.bbc.com/news/world-africa-17864387|archive-date=2024-09-12|access-date=1 May 2012|publisher=BBC}}https://web.archive.org/web/20240912183258/https://www.bbc.com/news/world-africa-17864387&lt;/ref&gt;


In May 2012, Taylor was sentenced to 50 years in prison. Reading the sentencing statement, presiding Judge Richard Lussick said: &quot;The accused has been found responsible for aiding and abetting as well as planning some of the most heinous and brutal crimes in recorded human history.&quot;&lt;ref&gt;https://edition.cnn.com/2012/05/30/world/africa/netherlands-taylor-sentencing/index.html&lt;/ref&gt;
== Iinkomba ==
{{reflist}}
[[Category:Afrika]]</text>
      <sha1>dsfeo8p9cyuhfiqmrkq9csyemrnaoj0</sha1>
    </revision>
    <revision>
      <id>6364</id>
      <parentid>6363</parentid>
      <timestamp>2026-03-30T01:36:48Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6364</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4688" sha1="5teyg702kg9kb0cvd7xmin0eyz4a1vs" xml:space="preserve">
'''U-Charles McArthur Ghankay Taylor''' (wabelethwa mhlazi-28 kuTjhirhweni 1948) ngusopolotiki wangaphambilini we-Liberia. Wasebenza njengomongameli wama-22 [[Liberia|we-Liberia]] kusukela mhlazi-2 kuRhoboyi wee-1997 bekwaba kulapho atjhiya khona umsebenzi mhlana ali-11 kuRhoboyi wee-2003 ngebanga lePi yesiBili ye-Liberia nokukhula kwegandelelo leentjhabatjhaba. &lt;ref name=&quot;allafricatheend&quot;&gt;{{cite news|first=Ofeibea|last=Quist-Arcton|title=Liberia: Charles Ghankay Taylor, Defiant And Passionate to the End|date=11 August 2004|publisher=allAfrica.com|url=http://allafrica.com/stories/200408111235.html|access-date=18 January 2008}}http://allafrica.com/stories/200408111235.html&lt;/ref&gt; &lt;ref&gt;{{Cite news|last=Agencies|url=https://www.theguardian.com/world/2004/aug/11/westafrica|title=Liberian president Taylor steps down|date=2004-08-11|work=The Guardian|access-date=2020-02-28|language=en-GB|issn=0261-3077}}https://www.theguardian.com/world/2004/aug/11/westafrica&lt;/ref&gt; Ngemva kokutjhiya isikhundla, watholakala anecala lobulelesi bepi obenziwe [[Sierra Leone|ePini yomKhaya ye-Sierra Leone]], begodu wagwetjwa iminyaka ema-50 ejele.

Born in Arthington, Montserrado County, Liberia, Taylor earned a degree at Bentley College in the United States before returning to Liberia to work in the government of Samuel Doe. After being removed for embezzlement and imprisoned by President Doe, Taylor escaped prison in 1989. He eventually arrived in Libya, where he was trained as a guerrilla fighter. He returned to Liberia in 1989 as the head of a Libyan-backed rebel group, the National Patriotic Front of Liberia, to overthrow the Doe government, initiating the First Liberian Civil War (1989–1996). Following Doe's execution, Taylor gained control of a large portion of the country and became one of the most prominent warlords in Africa. His forces, along with those of other rival warlords such as ULIMO, were notorious for committing widespread human rights abuses and atrocities during the civil war. Following a peace deal that ended the war, Taylor was elected president in the 1997 general election as a member of the National Patriotic Party (NPP).&lt;ref&gt;{{cite news|url=https://www.nytimes.com/2000/12/07/world/in-ruined-liberia-its-despoiler-sits-pretty.html|work=The New York Times|first=Norimitsu|last=Onishi|title=In Ruined Liberia, Its Despoiler Sits Pretty|date=7 December 2000}}https://www.nytimes.com/2000/12/07/world/in-ruined-liberia-its-despoiler-sits-pretty.html&lt;/ref&gt;

Ngesikhathi asesikhundleni, u-Taylor wasolwa ngamacala wepi kanye nobugebengu obujamelene nobuntu ngebanga lokusekela kwakhe isiqhema samavukelambuso se -Revolutionary United Front (RUF) e- Sierra Leone Civil War (1991–2002). Ekhaya, u-Taylor walinga ukuqinisa amandla ngeendlela zobukhosi ezifana nokuhlanza amasotja nokwenza udlame ebantwini abaphikisana naye kwezepolotiki, okufaka hlangana umzamo wokubulala umlawuli we-ULIMO wangaphambilini u-Roosevelt Johnson, okwadosela ekutheni kube nokurarana okunobudlova e-Monrovia ngo-1998 . Njengomphumela, ukuphikiswa kurhulumende wakhe kwakhula, kwagcina ngokuqubuka kwePi yesiBili ye-Liberia ngo-1999. Ngo-2003, u-Taylor besele alahlekelwe kulawula indawo enengi yemaphandleni begodu wamangalelwa ngokusemthethweni yiKhotho eKhethekileko ye-Sierra Leone . Ngalowo mnyaka, walisa umsebenzi ngebanga lokugandeleleka kwamazwe ngamazwe begodu waya e-Nigeria. Ngomnyaka ka-2006, umengameli we-Liberia, u-Ellen Johnson Sirleaf, wabawa ngokusemthethweni ukuthunyelwa kwakhe. Wavalelwa ziimphathimandla ze-UN e- Sierra Leone bese wavalelwa e- Penitentiary Institution Haaglanden e- The Hague, alindele ukuthonisiswa yiKhotho eKhethekileko.  Watholakala anecala ngoMrhayili 2012 kiwo woke amacala alitjhumi nanye abekwe yiKhotho eKhethekileko, kufaka hlangana ukuthusa, ukubulala nokudlwengula. &lt;ref&gt;{{cite news|date=26 April 2012|title=Taylor Sierra Leone war crimes verdict welcomed|url=https://www.bbc.co.uk/news/world-africa-17864387|archive-url=https://web.archive.org/web/20240912183258/https://www.bbc.com/news/world-africa-17864387|archive-date=2024-09-12|access-date=1 May 2012|publisher=BBC}}https://web.archive.org/web/20240912183258/https://www.bbc.com/news/world-africa-17864387&lt;/ref&gt;


In May 2012, Taylor was sentenced to 50 years in prison. Reading the sentencing statement, presiding Judge Richard Lussick said: &quot;The accused has been found responsible for aiding and abetting as well as planning some of the most heinous and brutal crimes in recorded human history.&quot;&lt;ref&gt;https://edition.cnn.com/2012/05/30/world/africa/netherlands-taylor-sentencing/index.html&lt;/ref&gt;
== Iinkomba ==
{{reflist}}
[[Category:Afrika]]
[[Category:Sopolitiki]]</text>
      <sha1>5teyg702kg9kb0cvd7xmin0eyz4a1vs</sha1>
    </revision>
    <revision>
      <id>6366</id>
      <parentid>6364</parentid>
      <timestamp>2026-03-30T01:38:08Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6366</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4692" sha1="kum56lam2fu1i2utfvdgmben0jlfnca" xml:space="preserve">
'''U-Charles McArthur Ghankay Taylor''' (wabelethwa mhlazi-28 kuTjhirhweni 1948) ngusopolotiki wangaphambilini we-Liberia. Wasebenza njengomongameli wama-22 [[Liberia|we-Liberia]] kusukela mhlazi-2 kuRhoboyi wee-1997 bekwaba kulapho atjhiya khona umsebenzi mhlana ali-11 kuRhoboyi wee-2003 ngebanga lePi yesiBili ye-Liberia nokukhula kwegandelelo leentjhabatjhaba. &lt;ref name=&quot;allafricatheend&quot;&gt;{{cite news|first=Ofeibea|last=Quist-Arcton|title=Liberia: Charles Ghankay Taylor, Defiant And Passionate to the End|date=11 August 2004|publisher=allAfrica.com|url=http://allafrica.com/stories/200408111235.html|access-date=18 January 2008}}http://allafrica.com/stories/200408111235.html&lt;/ref&gt; &lt;ref&gt;{{Cite news|last=Agencies|url=https://www.theguardian.com/world/2004/aug/11/westafrica|title=Liberian president Taylor steps down|date=2004-08-11|work=The Guardian|access-date=2020-02-28|language=en-GB|issn=0261-3077}}https://www.theguardian.com/world/2004/aug/11/westafrica&lt;/ref&gt; Ngemva kokutjhiya isikhundla, watholakala anecala lobulelesi bepi obenziwe [[Sierra Leone|ePini yomKhaya ye-Sierra Leone]], begodu wagwetjwa iminyaka ema-50 ejele.

Born in Arthington, Montserrado County, Liberia, Taylor earned a degree at Bentley College in the United States before returning to Liberia to work in the government of Samuel Doe. After being removed for embezzlement and imprisoned by President Doe, Taylor escaped prison in 1989. He eventually arrived in Libya, where he was trained as a guerrilla fighter. He returned to Liberia in 1989 as the head of a Libyan-backed rebel group, the National Patriotic Front of Liberia, to overthrow the Doe government, initiating the First Liberian Civil War (1989–1996). Following Doe's execution, Taylor gained control of a large portion of the country and became one of the most prominent warlords in Africa. His forces, along with those of other rival warlords such as ULIMO, were notorious for committing widespread human rights abuses and atrocities during the civil war. Following a peace deal that ended the war, Taylor was elected president in the 1997 general election as a member of the National Patriotic Party (NPP).&lt;ref&gt;{{cite news|url=https://www.nytimes.com/2000/12/07/world/in-ruined-liberia-its-despoiler-sits-pretty.html|work=The New York Times|first=Norimitsu|last=Onishi|title=In Ruined Liberia, Its Despoiler Sits Pretty|date=7 December 2000}}https://www.nytimes.com/2000/12/07/world/in-ruined-liberia-its-despoiler-sits-pretty.html&lt;/ref&gt;

Ngesikhathi asesikhundleni, u-Taylor wasolwa ngamacala wepi kanye nobugebengu obujamelene nobuntu ngebanga lokusekela kwakhe isiqhema samavukelambuso se -Revolutionary United Front (RUF) e- Sierra Leone Civil War (1991–2002). Ekhaya, u-Taylor walinga ukuqinisa amandla ngeendlela zobukhosi ezifana nokuhlanza amasotja nokwenza udlame ebantwini abaphikisana naye kwezepolotiki, okufaka hlangana umzamo wokubulala umlawuli we-ULIMO wangaphambilini u-Roosevelt Johnson, okwadosela ekutheni kube nokurarana okunobudlova e-Monrovia ngo-1998 . Njengomphumela, ukuphikiswa kurhulumende wakhe kwakhula, kwagcina ngokuqubuka kwePi yesiBili ye-Liberia ngo-1999. Ngo-2003, u-Taylor besele alahlekelwe kulawula indawo enengi yemaphandleni begodu wamangalelwa ngokusemthethweni yiKhotho eKhethekileko ye-Sierra Leone . Ngalowo mnyaka, walisa umsebenzi ngebanga lokugandeleleka kwamazwe ngamazwe begodu waya e-Nigeria. Ngomnyaka ka-2006, umengameli we-Liberia, u-[[Ellen Johnson Sirleaf,]] wabawa ngokusemthethweni ukuthunyelwa kwakhe. Wavalelwa ziimphathimandla ze-UN e- Sierra Leone bese wavalelwa e- Penitentiary Institution Haaglanden e- The Hague, alindele ukuthonisiswa yiKhotho eKhethekileko.  Watholakala anecala ngoMrhayili 2012 kiwo woke amacala alitjhumi nanye abekwe yiKhotho eKhethekileko, kufaka hlangana ukuthusa, ukubulala nokudlwengula. &lt;ref&gt;{{cite news|date=26 April 2012|title=Taylor Sierra Leone war crimes verdict welcomed|url=https://www.bbc.co.uk/news/world-africa-17864387|archive-url=https://web.archive.org/web/20240912183258/https://www.bbc.com/news/world-africa-17864387|archive-date=2024-09-12|access-date=1 May 2012|publisher=BBC}}https://web.archive.org/web/20240912183258/https://www.bbc.com/news/world-africa-17864387&lt;/ref&gt;


In May 2012, Taylor was sentenced to 50 years in prison. Reading the sentencing statement, presiding Judge Richard Lussick said: &quot;The accused has been found responsible for aiding and abetting as well as planning some of the most heinous and brutal crimes in recorded human history.&quot;&lt;ref&gt;https://edition.cnn.com/2012/05/30/world/africa/netherlands-taylor-sentencing/index.html&lt;/ref&gt;
== Iinkomba ==
{{reflist}}
[[Category:Afrika]]
[[Category:Sopolitiki]]</text>
      <sha1>kum56lam2fu1i2utfvdgmben0jlfnca</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Sopolitiki</title>
    <ns>14</ns>
    <id>1082</id>
    <revision>
      <id>6365</id>
      <timestamp>2026-03-30T01:37:03Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created blank page</comment>
      <origin>6365</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
  </page>
  <page>
    <title>Ellen Johnson Sirleaf,</title>
    <ns>0</ns>
    <id>1083</id>
    <revision>
      <id>6367</id>
      <timestamp>2026-03-30T01:41:29Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created page with &quot;'''Ellen Eugenia Johnson Sirleaf''' (wabelethwa mhlazi-29 kuMgwengweni 1938) ngusopolotiki we-Liberia owasebenza njengomongameli wama-24 [[umongameli we-Liberia]] kusukela ngo-2006 ukuya ku-2018. I-Afrika.&lt;ref&gt;{{Citation |title=Johnson Sirleaf, Ellen Eugenia, (wabelethwa mhlazi-29 kuNobayeni 1938), uMongameli we-Liberia, kusukela ngo-2006 |date=2015-12-01 |url=http://dx.doi.org/10.1093/ww/9780199540884.013.u271942 |work=Who's Who |publisher=Oxford University Press |doi=1...&quot;</comment>
      <origin>6367</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="882" sha1="nnsbtk98x70cs3l4ktdgogh2o9ibxog" xml:space="preserve">'''Ellen Eugenia Johnson Sirleaf''' (wabelethwa mhlazi-29 kuMgwengweni 1938) ngusopolotiki we-Liberia owasebenza njengomongameli wama-24 [[umongameli we-Liberia]] kusukela ngo-2006 ukuya ku-2018. I-Afrika.&lt;ref&gt;{{Citation |title=Johnson Sirleaf, Ellen Eugenia, (wabelethwa mhlazi-29 kuNobayeni 1938), uMongameli we-Liberia, kusukela ngo-2006 |date=2015-12-01 |url=http://dx.doi.org/10.1093/ww/9780199540884.013.u271942 |work=Who's Who |publisher=Oxford University Press |doi=10.1093/ww/978019954088408401941. |access-date=2022-03-30|url-access=subscription }}&lt;/ref&gt;&lt;ref&gt;{{cite news |last1=Hough |first1=Lory |title=Ellen Johnson Sirleaf: Ukusuka e-HKS ukuya emzileni womkhankaso |url=https://www.hks.harvard.edu/research-insights/policy-topics/public-leadership-management/ellen-johnson-sirleaf |access-date=7 September 2024 |work=[[Harvard Kennedy School]] |date=September 10, 2020}</text>
      <sha1>nnsbtk98x70cs3l4ktdgogh2o9ibxog</sha1>
    </revision>
    <revision>
      <id>6368</id>
      <parentid>6367</parentid>
      <timestamp>2026-03-30T01:42:31Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6368</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="820" sha1="rbrcvgvonjelolyl12r2atotdpacmor" xml:space="preserve">U-Ellen Eugenia Johnson Sirleaf (wabelethwa mhlazi-29 kuMgwengweni 1938) ngusopolotiki we-Liberia owasebenza njengomengameli wama-24 we-Liberia kusukela ngo-2006 ukuya ku-2018.

USirleaf wabelethwa e-Monrovia kubaba we-Gola nonina we-Kru-German. Wafunda eKholeji yeTjingalanga ye-Afrika. U-Sirleaf osomnotho owabandulwa e-Harvard. Waqeda ifundo yakhe e-United States, lapho afunda khona e-Madison Business College, e-University of Colorado Boulder, kanye ne-Harvard University. Wabuyela e-Liberia ukuyokusebenza kurhulumende ka-William Tolbert njengeSekela likaNgqongqotjhe wezeeMali kusukela ngo-1973 ukuya ku-1974. Ngokukhamba kwesikhathi, wasebenza godu eTjingalanga, eBhanga lePhasi e-Caribbean ne-Latin America. Ngo-1979, wathola ukuqatjhwa njengeKhabinethi njengoNgqongqotjhe wezeeMali, wasebenza bekwaba ngu-1980.</text>
      <sha1>rbrcvgvonjelolyl12r2atotdpacmor</sha1>
    </revision>
    <revision>
      <id>6369</id>
      <parentid>6368</parentid>
      <timestamp>2026-03-30T01:43:23Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6369</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="894" sha1="i5qei0dzcfrrdpmv7wgjurvm1jx4cd9" xml:space="preserve">U-Ellen Eugenia Johnson Sirleaf (wabelethwa mhlazi-29 kuMgwengweni 1938) ngusopolotiki we-Liberia owasebenza njengomengameli wama-24 we-Liberia kusukela ngo-2006 ukuya ku-2018.&lt;ref&gt;https://en.wikipedia.org/wiki/Ellen_Johnson_Sirleaf#cite_note-2&lt;/ref&gt;

USirleaf wabelethwa e-Monrovia kubaba we-Gola nonina we-Kru-German. Wafunda eKholeji yeTjingalanga ye-Afrika. U-Sirleaf osomnotho owabandulwa e-Harvard. Waqeda ifundo yakhe e-United States, lapho afunda khona e-Madison Business College, e-University of Colorado Boulder, kanye ne-Harvard University. Wabuyela e-Liberia ukuyokusebenza kurhulumende ka-William Tolbert njengeSekela likaNgqongqotjhe wezeeMali kusukela ngo-1973 ukuya ku-1974. Ngokukhamba kwesikhathi, wasebenza godu eTjingalanga, eBhanga lePhasi e-Caribbean ne-Latin America. Ngo-1979, wathola ukuqatjhwa njengeKhabinethi njengoNgqongqotjhe wezeeMali, wasebenza bekwaba ngu-1980.</text>
      <sha1>i5qei0dzcfrrdpmv7wgjurvm1jx4cd9</sha1>
    </revision>
    <revision>
      <id>6370</id>
      <parentid>6369</parentid>
      <timestamp>2026-03-30T01:44:35Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6370</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="886" sha1="fgecbe1wk6qb5nxmbgd30iw91z101sc" xml:space="preserve">U-Ellen Eugenia Johnson Sirleaf (wabelethwa mhlazi-29 kuMgwengweni 1938) ngusopolotiki we-Liberia owasebenza njengomengameli wama-24 we-Liberia kusukela ngo-2006 ukuya ku-2018.&lt;ref&gt;https://dx.doi.org/10.1093/ww/9780199540884.013.u271942&lt;/ref&gt;

USirleaf wabelethwa e-Monrovia kubaba we-Gola nonina we-Kru-German. Wafunda eKholeji yeTjingalanga ye-Afrika. U-Sirleaf osomnotho owabandulwa e-Harvard. Waqeda ifundo yakhe e-United States, lapho afunda khona e-Madison Business College, e-University of Colorado Boulder, kanye ne-Harvard University. Wabuyela e-Liberia ukuyokusebenza kurhulumende ka-William Tolbert njengeSekela likaNgqongqotjhe wezeeMali kusukela ngo-1973 ukuya ku-1974. Ngokukhamba kwesikhathi, wasebenza godu eTjingalanga, eBhanga lePhasi e-Caribbean ne-Latin America. Ngo-1979, wathola ukuqatjhwa njengeKhabinethi njengoNgqongqotjhe wezeeMali, wasebenza bekwaba ngu-1980.</text>
      <sha1>fgecbe1wk6qb5nxmbgd30iw91z101sc</sha1>
    </revision>
    <revision>
      <id>6371</id>
      <parentid>6370</parentid>
      <timestamp>2026-03-30T01:47:08Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6371</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="943" sha1="ll13w9l3zac46ei4xf9qr1ly8cw4c0l" xml:space="preserve">U-Ellen Eugenia Johnson Sirleaf (wabelethwa mhlazi-29 kuMgwengweni 1938) ngusopolotiki we-Liberia owasebenza njengomengameli wama-24 we-Liberia kusukela ngo-2006 ukuya ku-2018.&lt;ref&gt;https://dx.doi.org/10.1093/ww/9780199540884.013.u271942&lt;/ref&gt;

USirleaf wabelethwa e-Monrovia kubaba we-Gola nonina we-Kru-German. Wafunda eKholeji yeTjingalanga ye-Afrika. U-Sirleaf osomnotho owabandulwa e-Harvard. Waqeda ifundo yakhe e-United States, lapho afunda khona e-Madison Business College, e-University of Colorado Boulder, kanye ne-Harvard University. Wabuyela e-Liberia ukuyokusebenza kurhulumende ka-William Tolbert njengeSekela likaNgqongqotjhe wezeeMali kusukela ngo-1973 ukuya ku-1974. Ngokukhamba kwesikhathi, wasebenza godu eTjingalanga, eBhanga lePhasi e-Caribbean ne-Latin America. Ngo-1979, wathola ukuqatjhwa njengeKhabinethi njengoNgqongqotjhe wezeeMali, wasebenza bekwaba ngu-1980.&lt;ref&gt;https://hdl.handle.net/2027/osu.32435083692814&lt;/ref&gt;</text>
      <sha1>ll13w9l3zac46ei4xf9qr1ly8cw4c0l</sha1>
    </revision>
    <revision>
      <id>6372</id>
      <parentid>6371</parentid>
      <timestamp>2026-03-30T01:47:40Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6372</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1043" sha1="nt7tcrl63n9rjbhdtafn3yzj1q8sp8x" xml:space="preserve">U-Ellen Eugenia Johnson Sirleaf (wabelethwa mhlazi-29 kuMgwengweni 1938) ngusopolotiki we-Liberia owasebenza njengomengameli wama-24 we-Liberia kusukela ngo-2006 ukuya ku-2018.&lt;ref&gt;https://dx.doi.org/10.1093/ww/9780199540884.013.u271942&lt;/ref&gt;

USirleaf wabelethwa e-Monrovia kubaba we-Gola nonina we-Kru-German. Wafunda eKholeji yeTjingalanga ye-Afrika. U-Sirleaf osomnotho owabandulwa e-Harvard. Waqeda ifundo yakhe e-United States, lapho afunda khona e-Madison Business College, e-University of Colorado Boulder, kanye ne-Harvard University. Wabuyela e-Liberia ukuyokusebenza kurhulumende ka-William Tolbert njengeSekela likaNgqongqotjhe wezeeMali kusukela ngo-1973 ukuya ku-1974. Ngokukhamba kwesikhathi, wasebenza godu eTjingalanga, eBhanga lePhasi e-Caribbean ne-Latin America. Ngo-1979, wathola ukuqatjhwa njengeKhabinethi njengoNgqongqotjhe wezeeMali, wasebenza bekwaba ngu-1980.&lt;ref&gt;https://hdl.handle.net/2027/osu.32435083692814&lt;/ref&gt;&lt;ref&gt;http://www.ghanastar.com/africa-news/liberias-president-sirleaf-elected-new-ecowas-chair/&lt;/ref&gt;</text>
      <sha1>nt7tcrl63n9rjbhdtafn3yzj1q8sp8x</sha1>
    </revision>
    <revision>
      <id>6373</id>
      <parentid>6372</parentid>
      <timestamp>2026-03-30T01:48:08Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6373</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1059" sha1="fq1bzz1bkf3v9649glj1tisyzrma0kt" xml:space="preserve">U-Ellen Eugenia Johnson Sirleaf (wabelethwa mhlazi-29 kuMgwengweni 1938) ngusopolotiki we-Liberia owasebenza njengomengameli wama-24 we-Liberia kusukela ngo-2006 ukuya ku-2018.&lt;ref&gt;https://dx.doi.org/10.1093/ww/9780199540884.013.u271942&lt;/ref&gt;

USirleaf wabelethwa e-Monrovia kubaba we-Gola nonina we-Kru-German. Wafunda eKholeji yeTjingalanga ye-Afrika. U-Sirleaf osomnotho owabandulwa e-Harvard. Waqeda ifundo yakhe e-United States, lapho afunda khona e-Madison Business College, e-University of Colorado Boulder, kanye ne-Harvard University. Wabuyela e-Liberia ukuyokusebenza kurhulumende ka-William Tolbert njengeSekela likaNgqongqotjhe wezeeMali kusukela ngo-1973 ukuya ku-1974. Ngokukhamba kwesikhathi, wasebenza godu eTjingalanga, eBhanga lePhasi e-Caribbean ne-Latin America. Ngo-1979, wathola ukuqatjhwa njengeKhabinethi njengoNgqongqotjhe wezeeMali, wasebenza bekwaba ngu-1980.&lt;ref&gt;https://hdl.handle.net/2027/osu.32435083692814&lt;/ref&gt;&lt;ref&gt;http://www.ghanastar.com/africa-news/liberias-president-sirleaf-elected-new-ecowas-chair/&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>fq1bzz1bkf3v9649glj1tisyzrma0kt</sha1>
    </revision>
    <revision>
      <id>6374</id>
      <parentid>6373</parentid>
      <timestamp>2026-03-30T01:48:30Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6374</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1071" sha1="9g2xfddhxkal8mn08ue70mni2f1almx" xml:space="preserve">U-Ellen Eugenia Johnson Sirleaf (wabelethwa mhlazi-29 kuMgwengweni 1938) ngusopolotiki we-Liberia owasebenza njengomengameli wama-24 we-Liberia kusukela ngo-2006 ukuya ku-2018.&lt;ref&gt;https://dx.doi.org/10.1093/ww/9780199540884.013.u271942&lt;/ref&gt;

USirleaf wabelethwa e-Monrovia kubaba we-Gola nonina we-Kru-German. Wafunda eKholeji yeTjingalanga ye-Afrika. U-Sirleaf osomnotho owabandulwa e-Harvard. Waqeda ifundo yakhe e-United States, lapho afunda khona e-Madison Business College, e-University of Colorado Boulder, kanye ne-Harvard University. Wabuyela e-Liberia ukuyokusebenza kurhulumende ka-William Tolbert njengeSekela likaNgqongqotjhe wezeeMali kusukela ngo-1973 ukuya ku-1974. Ngokukhamba kwesikhathi, wasebenza godu eTjingalanga, eBhanga lePhasi e-Caribbean ne-Latin America. Ngo-1979, wathola ukuqatjhwa njengeKhabinethi njengoNgqongqotjhe wezeeMali, wasebenza bekwaba ngu-1980.&lt;ref&gt;https://hdl.handle.net/2027/osu.32435083692814&lt;/ref&gt;&lt;ref&gt;http://www.ghanastar.com/africa-news/liberias-president-sirleaf-elected-new-ecowas-chair/&lt;/ref&gt;

== Iinkomba ==
{{reflist}}</text>
      <sha1>9g2xfddhxkal8mn08ue70mni2f1almx</sha1>
    </revision>
    <revision>
      <id>6375</id>
      <parentid>6374</parentid>
      <timestamp>2026-03-30T01:49:32Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6375</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1115" sha1="if7mrekkjdx2qu9lznk62zzvkn2fyx3" xml:space="preserve">U-Ellen Eugenia Johnson Sirleaf (wabelethwa mhlazi-29 kuMgwengweni 1938) ngusopolotiki we-Liberia owasebenza njengomengameli wama-24 we-Liberia kusukela ngo-2006 ukuya ku-2018.&lt;ref&gt;https://dx.doi.org/10.1093/ww/9780199540884.013.u271942&lt;/ref&gt;

USirleaf wabelethwa e-Monrovia kubaba we-Gola nonina we-Kru-German. Wafunda eKholeji yeTjingalanga ye-Afrika. U-Sirleaf osomnotho owabandulwa e-Harvard. Waqeda ifundo yakhe e-United States, lapho afunda khona e-Madison Business College, e-University of Colorado Boulder, kanye ne-Harvard University. Wabuyela e-Liberia ukuyokusebenza kurhulumende ka-William Tolbert njengeSekela likaNgqongqotjhe wezeeMali kusukela ngo-1973 ukuya ku-1974. Ngokukhamba kwesikhathi, wasebenza godu eTjingalanga, eBhanga lePhasi e-Caribbean ne-Latin America. Ngo-1979, wathola ukuqatjhwa njengeKhabinethi njengoNgqongqotjhe wezeeMali, wasebenza bekwaba ngu-1980.&lt;ref&gt;https://hdl.handle.net/2027/osu.32435083692814&lt;/ref&gt;&lt;ref&gt;http://www.ghanastar.com/africa-news/liberias-president-sirleaf-elected-new-ecowas-chair/&lt;/ref&gt;

== Iinkomba ==
{{reflist}}
[[Category:Afrika]]
[[Category:Sopolitiki]]</text>
      <sha1>if7mrekkjdx2qu9lznk62zzvkn2fyx3</sha1>
    </revision>
    <revision>
      <id>6376</id>
      <parentid>6375</parentid>
      <timestamp>2026-03-30T01:50:17Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6376</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1123" sha1="kar2t710t9o4c9qlnv8ot56y7g768jm" xml:space="preserve">U-Ellen Eugenia Johnson Sirleaf (wabelethwa mhlazi-29 kuMgwengweni 1938) ngusopolotiki we-Liberia owasebenza njengomengameli wama-24 we-[[Liberia]] kusukela ngo-2006 ukuya ku-2018.&lt;ref&gt;https://dx.doi.org/10.1093/ww/9780199540884.013.u271942&lt;/ref&gt;

USirleaf wabelethwa e-Monrovia kubaba we-Gola nonina we-Kru-[[German.]] Wafunda eKholeji yeTjingalanga ye-Afrika. U-Sirleaf osomnotho owabandulwa e-Harvard. Waqeda ifundo yakhe e-United States, lapho afunda khona e-Madison Business College, e-University of Colorado Boulder, kanye ne-Harvard University. Wabuyela e-Liberia ukuyokusebenza kurhulumende ka-William Tolbert njengeSekela likaNgqongqotjhe wezeeMali kusukela ngo-1973 ukuya ku-1974. Ngokukhamba kwesikhathi, wasebenza godu eTjingalanga, eBhanga lePhasi e-Caribbean ne-Latin America. Ngo-1979, wathola ukuqatjhwa njengeKhabinethi njengoNgqongqotjhe wezeeMali, wasebenza bekwaba ngu-1980.&lt;ref&gt;https://hdl.handle.net/2027/osu.32435083692814&lt;/ref&gt;&lt;ref&gt;http://www.ghanastar.com/africa-news/liberias-president-sirleaf-elected-new-ecowas-chair/&lt;/ref&gt;

== Iinkomba ==
{{reflist}}
[[Category:Afrika]]
[[Category:Sopolitiki]]</text>
      <sha1>kar2t710t9o4c9qlnv8ot56y7g768jm</sha1>
    </revision>
  </page>
  <page>
    <title>Gert Sibande</title>
    <ns>0</ns>
    <id>1084</id>
    <revision>
      <id>6378</id>
      <timestamp>2026-04-02T00:26:31Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1338317790|Gert Sibande]]&quot;</comment>
      <origin>6378</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7430" sha1="e15f4pysdywgq327hbts1damy8owbnj" xml:space="preserve">
'''U-Gert Shedrack Sibande''' (1901 eduze ne-Ermelo, e-Mpumalanga – 1987; owaziwa nangokuthi yi '''-Lion of the East'''  ) bekayisisebenzi seplasini seSewula Afrika begodu bekasolo alwisana nebandlululo. Bekangomunye wabasolwa be -ANC ukujamela icala lokuvukela umbuso ngo-1956-61 kanye no [[Nelson Mandela|-Nelson Mandela]] nabanye abali-154. &lt;ref&gt;{{Cite web|url=http://www.sahistory.org.za/pages/people/bios/sibande,g.htm|title=Gert Sibande|access-date=2011-05-07|archive-url=https://web.archive.org/web/20090108042303/http://www.sahistory.org.za/pages/people/bios/sibande,g.htm|archive-date=2009-01-08|url-status=dead}}&lt;/ref&gt;

USibande wadlala indima eqakathekileko e-Potato Boycott yango-1959.[1]

Isifunda se -Gert Sibande esifundazweni se [[Isifunda seMpumalanga|-Mpumalanga]] eSewula Afrika siqanjwe ngegama lakhe. Wabelethelwa esifundeni begodu wachitha isikhathi esinengi sepilo yakhe lapho.

Ngemva kokuhlongakala kwakhe wanikelwe i-Order of Luthuli in Gold ngegalelo lakhe elihle khulu ekwenzeni ngcono ubujamo bokusebenza kwabasebenzi beplasi kanye nemizamo yakhe yokuthuthukisa iSewula Afrika engabandlululi ngokobuhlanga, enobulungiswa, nentando yenengi.&lt;ref&gt;{{Cite web|url=https://www.polity.org.za/article/anc-zuma-address-delivered-at-the-gert-sibande-memorial-lecture-23092008-2008-09-23|title=ANC: Zuma: Address delivered at the Gert Sibande Memorial Lecture (23/09/2008)|website=www.polity.org.za}}&lt;/ref&gt;

== Ipilo yokuthoma nomsebenzi ==
Wabelethwa ngo-1901 esifundeni se-Ermelo se- Eastern Transvaal yangaleso sikhathi (manje [[Isifunda seMpumalanga|i-Mpumalanga]] ), u-Sibande bekayindodana yomlimi oqatjhileko. Wathoma ukusebenza emaplasini aneminyaka ebunane, lapho aqalana khona nobujamo obubudisi. Ekuthomeni bekaziwa ngokuthi ngu-Shadrack Sibande, waphiwa ibizo elithi &quot;Gert&quot; mBhunu owavimbela ukusetjenziswa kwamabizo wesiNgisi eplasini lakhe. Iminyaka engaphezu kwama-20, u-Sibande wasebenza emaplasini ahlukahlukeneko e-Eastern Transvaal. Ukungafuni kwakhe ukwamukela ubujamo obumbi bokusebenza kwamenza waba nedumela lokuba mraro hlangana nabaqatjhi bakhe, njengombana bekavame ukubaphikisa ngeendaba zokuhlukunyezwa.

== Ukukhuthaza abasebenzi beplasi ==
Ngabo-1930, u-Sibande wathuthela e- Bethal Location, lapho athoma khona ukuhlela abasebenzi beplasi begodu alungisa iinkhalazo zabo. Ngesikhathi lesi, abasebenzi abanengi beplasini bebaqalene nobujamo obumbi khulu bokusebenza, basebenza kusukela ekuphumeni kwelanga ukuya ekutjhingeni kwelanga babhadelwa imali encani, begodu kanengi badla ukudla okuncani okufana ne-phuthu ne-gravy emasakeni. USibande wasiza ukusungula ihlangano yokuthoma eyaziwako yamalungelo wabasebenzi beplasini eSewula Afrika, i-Farm Workers' Association. Isiqhema lesi sisebenzele ukusiza abasebenzi beplasi bona bathole iintjalo ezibiweko begodu bathole ubujamo obungcono bokusebenza. Ngo-1939, u-Sibande wahlangana namalunga we- African National Congress (ANC) e [[Johannesburg|-Goli]] . Msinyana waba lilunga elisebenzako, wabuyela e-Bethal ukuyokwakha igatja eliqinileko le-ANC. Imizamo yakhe yenza bona kube nokutjheja okukhulu ngeemeko ezimbi abasebenzi beplasi ebebaqalene nazo, begodu wasiza ukuveza ukungabi nobulungiswa lokhu ebantwini abanengi, okufakahlangana abantu abadumileko abafana nomfundisi u-Michael Scott nentatheli u-Ruth First .&lt;ref&gt;Christopher Webb (2015) Fighting talk: Ruth First's early journalism 1947–1950, Review of African Political Economy, 42:143, 7-21, DOI:10.1080/03056244.2014.988697 Accessed 19 July 2017&lt;/ref&gt;

U-Sibande wasebenzisana no- Henry Nxumalo odumileko wemagazini ye-Drum, asiza ekugadangisweni kwama-atikili aveza ubujamo bokuxhaphaza kwabasebenzi beplasini ephasini. Iindaba ezitholweko zavezwa ku- ''New Age'' . ''I-Guardian'' yakhipha i-atikili yesibili ehlobene nokutholwe ngu-Gert Sibande mhlazi-25 kuNobayeni 1947.  ''I-Drum Magazine'' yakhipha i-atikili efanako ngo-1952, intathelizindaba u-Henry Nxumalo nomthwebuli weenthombe u-Jurgen Schoodeberg badlala indima eqakathekileko ekutloleni ubujamo babasebenzi beplasi lamazambana e-Bethal. I-atikili le yathola ukutjhejwa kwezwe neentjhabatjhaba kodwana, imibiko yalahlwa nguNgqongqotjhe wezeNdabuko, u-Hendrik Frensch Verwoerd ePalamende. Waxoshwa e-Bethal ziimphathimandla ngo-1953 ngebanga lokuzikhakhazisa kwakhe kwezepolotiki. Ngokukhamba kwesikhathi wathuthela [[Eswatini|eSwazini]] lapho asiza khona iphiko lebutho le-ANC uMkhonto we Sizwe . &lt;ref name=&quot;auto&quot;&gt;http://www.sahistory.org.za/people/gert-sibande {{Webarchive|url=https://web.archive.org/web/20130901062545/http://sahistory.org.za/people/gert-sibande|date=2013-09-01}} Accessed 20 July 2017&lt;/ref&gt; Ngo-1959, ngemva kweminyaka elitjhumi nambili uGert Sibande aveze ubujamo bezisebenzi, i -ANC yabika ubujamo obufanako emaplasini wommbila namanye amazambana.   Bekangumhlanganyeli okhutheleko emkhankasweni wokuphikisa, umkhankaso wokulwisana nefundo yamaBantu begodu wasiza nokutlola iTjhatha yeNkululeko . Wasebenza eduze noMphathi u-Albert Luthuli, u-Moses Kotane no -Moses Mabhida .  Bekalilunga lomKhandlu oPhetheko weNarha we- ANC begodu ngesikhathi sakhe soburholi, wasolwa ecaleni lokuvukela umbuso ngo-1956 ukuya ku-1961. Bekangomunye wabasolwa abambalwa abathatha isikhundla sofakazi ngesikhathi secala. Wakhethwa bona abe ngumengameli we-Transvaal ANC ngo-1958 begodu wakhethwa godu ngo-1959. &lt;ref name=&quot;auto1&quot; /&gt; Wahlongakala e [[Eswatini|-Swaziland]] ngo-1987. Wangcwatshwa e -Manzini phakathi ne-Swaziland. 

== Ukutlhoriswa nokuhlongakala ==
Ikululeko ka-Sibande yenza bona kube nokutlhoriswa okukhulu ngurhulumende webandlululo. Ngo-1953, waxoshwa e-Bethal, begodu ngo-1956, wabekwa icala lokuvukela umbuso njengengcenye yecala lokuvukela umbuso elidumileko. Nanyana gade aneentjhijilo, waragela phambili nomsebenzi wakhe ngaphakathi kwe-ANC, wakhethwa njengomongameli we-Transvaal ANC ngo-1958.

Ngemva kwecala lokuvukela umbuso, u-Sibande wakateleleka bona ahlale e -Komatipoort eduze nomngcele we- [[Eswatini|Swaziland]] ne [[Mozambique|-Mozambique]] . Ngo-1962, wawela waya e-Swaziland begodu ngokukhamba kwesikhathi wathenga itrektara wayisebenzisela ukunikela ngeenkonzo zokulima e-Swaziland, lapho ahlala khona iminyaka eminengi ahlala ekudingisweni. Wahlongakala ngo-1987, e -Manzini, e-Swazini.


Umasipala wesiyingi watjhugulula ibizo lakhe ukusuka ku-&quot;Eastvaal&quot; (Afrikaans: Oosvaal) waya ku-&quot;Gert Sibande&quot; uMasipala wesiFunda ngoNobayeni ka-2004.  Kune-Gert Sibande TVET College eneendawo ezihlukahlukeneko zekhampasi.   Kunesithombe sethusi saka-Gert Sibande esiqala esinye isithombe saka- [[Nokuthula Simelane]] e -Bethal . Iinthombe zingaphandle kwe-Nomoya Masilela Museum enikelwe abalweli bekululeko abafakahlangana u-Gert Sibande, u-Nokuthula Simelane, u-Ruth First no -Henry Nxumalo .   &lt;sup class=&quot;noprint Inline-Template&quot; style=&quot;white-space:nowrap;&quot;&gt;&amp;#x5B; ''&lt;nowiki&gt;&lt;span title=&quot;The material near this tag may rely on a self-published source. (January 2018)&quot;&gt;self-published source&lt;/span&gt;&lt;/nowiki&gt;'' &amp;#x5D;&lt;/sup&gt;   UMbongeni Ngema watlola begodu waqondisa umkhiqizo wesigaba sesabelomali sezigidi ezingama-R22 'Ibhubezi leMpumalanga' ebegade uhlanganiswe ngokuduba amazambana neminikelo ka-Gert Sibande. Umkhiqizo lo bewuneenkhundla e- Trinidad, e-Jamaica ne -Suriname . Umndeni ka-Sibande ukhuphe umthetho wokukhandela ukukhiqiza umvumo lo ngombana bathi akhenge bakhulumisane nabo. Ukuvinjelwa kwabekwa eceleni msinyana ngaphambi kokukhutjhwa komkhiqizo.</text>
      <sha1>e15f4pysdywgq327hbts1damy8owbnj</sha1>
    </revision>
    <revision>
      <id>6379</id>
      <parentid>6378</parentid>
      <timestamp>2026-04-02T00:27:00Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6379</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7446" sha1="enmysdnlm7l7i5hyshjhyf7hgofog4e" xml:space="preserve">
'''U-Gert Shedrack Sibande''' (1901 eduze ne-Ermelo, e-Mpumalanga – 1987; owaziwa nangokuthi yi '''-Lion of the East'''  ) bekayisisebenzi seplasini seSewula Afrika begodu bekasolo alwisana nebandlululo. Bekangomunye wabasolwa be -ANC ukujamela icala lokuvukela umbuso ngo-1956-61 kanye no [[Nelson Mandela|-Nelson Mandela]] nabanye abali-154. &lt;ref&gt;{{Cite web|url=http://www.sahistory.org.za/pages/people/bios/sibande,g.htm|title=Gert Sibande|access-date=2011-05-07|archive-url=https://web.archive.org/web/20090108042303/http://www.sahistory.org.za/pages/people/bios/sibande,g.htm|archive-date=2009-01-08|url-status=dead}}&lt;/ref&gt;

USibande wadlala indima eqakathekileko e-Potato Boycott yango-1959.[1]

Isifunda se -Gert Sibande esifundazweni se [[Isifunda seMpumalanga|-Mpumalanga]] eSewula Afrika siqanjwe ngegama lakhe. Wabelethelwa esifundeni begodu wachitha isikhathi esinengi sepilo yakhe lapho.

Ngemva kokuhlongakala kwakhe wanikelwe i-Order of Luthuli in Gold ngegalelo lakhe elihle khulu ekwenzeni ngcono ubujamo bokusebenza kwabasebenzi beplasi kanye nemizamo yakhe yokuthuthukisa iSewula Afrika engabandlululi ngokobuhlanga, enobulungiswa, nentando yenengi.&lt;ref&gt;{{Cite web|url=https://www.polity.org.za/article/anc-zuma-address-delivered-at-the-gert-sibande-memorial-lecture-23092008-2008-09-23|title=ANC: Zuma: Address delivered at the Gert Sibande Memorial Lecture (23/09/2008)|website=www.polity.org.za}}&lt;/ref&gt;

== Ipilo yokuthoma nomsebenzi ==
Wabelethwa ngo-1901 esifundeni se-Ermelo se- Eastern Transvaal yangaleso sikhathi (manje [[Isifunda seMpumalanga|i-Mpumalanga]] ), u-Sibande bekayindodana yomlimi oqatjhileko. Wathoma ukusebenza emaplasini aneminyaka ebunane, lapho aqalana khona nobujamo obubudisi. Ekuthomeni bekaziwa ngokuthi ngu-Shadrack Sibande, waphiwa ibizo elithi &quot;Gert&quot; mBhunu owavimbela ukusetjenziswa kwamabizo wesiNgisi eplasini lakhe. Iminyaka engaphezu kwama-20, u-Sibande wasebenza emaplasini ahlukahlukeneko e-Eastern Transvaal. Ukungafuni kwakhe ukwamukela ubujamo obumbi bokusebenza kwamenza waba nedumela lokuba mraro hlangana nabaqatjhi bakhe, njengombana bekavame ukubaphikisa ngeendaba zokuhlukunyezwa.

== Ukukhuthaza abasebenzi beplasi ==
Ngabo-1930, u-Sibande wathuthela e- Bethal Location, lapho athoma khona ukuhlela abasebenzi beplasi begodu alungisa iinkhalazo zabo. Ngesikhathi lesi, abasebenzi abanengi beplasini bebaqalene nobujamo obumbi khulu bokusebenza, basebenza kusukela ekuphumeni kwelanga ukuya ekutjhingeni kwelanga babhadelwa imali encani, begodu kanengi badla ukudla okuncani okufana ne-phuthu ne-gravy emasakeni. USibande wasiza ukusungula ihlangano yokuthoma eyaziwako yamalungelo wabasebenzi beplasini eSewula Afrika, i-Farm Workers' Association. Isiqhema lesi sisebenzele ukusiza abasebenzi beplasi bona bathole iintjalo ezibiweko begodu bathole ubujamo obungcono bokusebenza. Ngo-1939, u-Sibande wahlangana namalunga we- African National Congress (ANC) e [[Johannesburg|-Goli]] . Msinyana waba lilunga elisebenzako, wabuyela e-Bethal ukuyokwakha igatja eliqinileko le-ANC. Imizamo yakhe yenza bona kube nokutjheja okukhulu ngeemeko ezimbi abasebenzi beplasi ebebaqalene nazo, begodu wasiza ukuveza ukungabi nobulungiswa lokhu ebantwini abanengi, okufakahlangana abantu abadumileko abafana nomfundisi u-Michael Scott nentatheli u-Ruth First .&lt;ref&gt;Christopher Webb (2015) Fighting talk: Ruth First's early journalism 1947–1950, Review of African Political Economy, 42:143, 7-21, DOI:10.1080/03056244.2014.988697 Accessed 19 July 2017&lt;/ref&gt;

U-Sibande wasebenzisana no- Henry Nxumalo odumileko wemagazini ye-Drum, asiza ekugadangisweni kwama-atikili aveza ubujamo bokuxhaphaza kwabasebenzi beplasini ephasini. Iindaba ezitholweko zavezwa ku- ''New Age'' . ''I-Guardian'' yakhipha i-atikili yesibili ehlobene nokutholwe ngu-Gert Sibande mhlazi-25 kuNobayeni 1947.  ''I-Drum Magazine'' yakhipha i-atikili efanako ngo-1952, intathelizindaba u-Henry Nxumalo nomthwebuli weenthombe u-Jurgen Schoodeberg badlala indima eqakathekileko ekutloleni ubujamo babasebenzi beplasi lamazambana e-Bethal. I-atikili le yathola ukutjhejwa kwezwe neentjhabatjhaba kodwana, imibiko yalahlwa nguNgqongqotjhe wezeNdabuko, u-Hendrik Frensch Verwoerd ePalamende. Waxoshwa e-Bethal ziimphathimandla ngo-1953 ngebanga lokuzikhakhazisa kwakhe kwezepolotiki. Ngokukhamba kwesikhathi wathuthela [[Eswatini|eSwazini]] lapho asiza khona iphiko lebutho le-ANC uMkhonto we Sizwe . &lt;ref name=&quot;auto&quot;&gt;http://www.sahistory.org.za/people/gert-sibande {{Webarchive|url=https://web.archive.org/web/20130901062545/http://sahistory.org.za/people/gert-sibande|date=2013-09-01}} Accessed 20 July 2017&lt;/ref&gt; Ngo-1959, ngemva kweminyaka elitjhumi nambili uGert Sibande aveze ubujamo bezisebenzi, i -ANC yabika ubujamo obufanako emaplasini wommbila namanye amazambana.   Bekangumhlanganyeli okhutheleko emkhankasweni wokuphikisa, umkhankaso wokulwisana nefundo yamaBantu begodu wasiza nokutlola iTjhatha yeNkululeko . Wasebenza eduze noMphathi u-Albert Luthuli, u-Moses Kotane no -Moses Mabhida .  Bekalilunga lomKhandlu oPhetheko weNarha we- ANC begodu ngesikhathi sakhe soburholi, wasolwa ecaleni lokuvukela umbuso ngo-1956 ukuya ku-1961. Bekangomunye wabasolwa abambalwa abathatha isikhundla sofakazi ngesikhathi secala. Wakhethwa bona abe ngumengameli we-Transvaal ANC ngo-1958 begodu wakhethwa godu ngo-1959. &lt;ref name=&quot;auto1&quot; /&gt; Wahlongakala e [[Eswatini|-Swaziland]] ngo-1987. Wangcwatshwa e -Manzini phakathi ne-Swaziland. 

== Ukutlhoriswa nokuhlongakala ==
Ikululeko ka-Sibande yenza bona kube nokutlhoriswa okukhulu ngurhulumende webandlululo. Ngo-1953, waxoshwa e-Bethal, begodu ngo-1956, wabekwa icala lokuvukela umbuso njengengcenye yecala lokuvukela umbuso elidumileko. Nanyana gade aneentjhijilo, waragela phambili nomsebenzi wakhe ngaphakathi kwe-ANC, wakhethwa njengomongameli we-Transvaal ANC ngo-1958.

Ngemva kwecala lokuvukela umbuso, u-Sibande wakateleleka bona ahlale e -Komatipoort eduze nomngcele we- [[Eswatini|Swaziland]] ne [[Mozambique|-Mozambique]] . Ngo-1962, wawela waya e-Swaziland begodu ngokukhamba kwesikhathi wathenga itrektara wayisebenzisela ukunikela ngeenkonzo zokulima e-Swaziland, lapho ahlala khona iminyaka eminengi ahlala ekudingisweni. Wahlongakala ngo-1987, e -Manzini, e-Swazini.


Umasipala wesiyingi watjhugulula ibizo lakhe ukusuka ku-&quot;Eastvaal&quot; (Afrikaans: Oosvaal) waya ku-&quot;Gert Sibande&quot; uMasipala wesiFunda ngoNobayeni ka-2004.  Kune-Gert Sibande TVET College eneendawo ezihlukahlukeneko zekhampasi.   Kunesithombe sethusi saka-Gert Sibande esiqala esinye isithombe saka- [[Nokuthula Simelane]] e -Bethal . Iinthombe zingaphandle kwe-Nomoya Masilela Museum enikelwe abalweli bekululeko abafakahlangana u-Gert Sibande, u-Nokuthula Simelane, u-Ruth First no -Henry Nxumalo .   &lt;sup class=&quot;noprint Inline-Template&quot; style=&quot;white-space:nowrap;&quot;&gt;&amp;#x5B; ''&lt;nowiki&gt;&lt;span title=&quot;The material near this tag may rely on a self-published source. (January 2018)&quot;&gt;self-published source&lt;/span&gt;&lt;/nowiki&gt;'' &amp;#x5D;&lt;/sup&gt;   UMbongeni Ngema watlola begodu waqondisa umkhiqizo wesigaba sesabelomali sezigidi ezingama-R22 'Ibhubezi leMpumalanga' ebegade uhlanganiswe ngokuduba amazambana neminikelo ka-Gert Sibande. Umkhiqizo lo bewuneenkhundla e- Trinidad, e-Jamaica ne -Suriname . Umndeni ka-Sibande ukhuphe umthetho wokukhandela ukukhiqiza umvumo lo ngombana bathi akhenge bakhulumisane nabo. Ukuvinjelwa kwabekwa eceleni msinyana ngaphambi kokukhutjhwa komkhiqizo.

== Iinkomba ==</text>
      <sha1>enmysdnlm7l7i5hyshjhyf7hgofog4e</sha1>
    </revision>
    <revision>
      <id>6380</id>
      <parentid>6379</parentid>
      <timestamp>2026-04-02T00:27:37Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>/* Ukutlhoriswa nokuhlongakala */</comment>
      <origin>6380</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7215" sha1="qoctn2gsfrleitzq2yjgkje9m8819vx" xml:space="preserve">
'''U-Gert Shedrack Sibande''' (1901 eduze ne-Ermelo, e-Mpumalanga – 1987; owaziwa nangokuthi yi '''-Lion of the East'''  ) bekayisisebenzi seplasini seSewula Afrika begodu bekasolo alwisana nebandlululo. Bekangomunye wabasolwa be -ANC ukujamela icala lokuvukela umbuso ngo-1956-61 kanye no [[Nelson Mandela|-Nelson Mandela]] nabanye abali-154. &lt;ref&gt;{{Cite web|url=http://www.sahistory.org.za/pages/people/bios/sibande,g.htm|title=Gert Sibande|access-date=2011-05-07|archive-url=https://web.archive.org/web/20090108042303/http://www.sahistory.org.za/pages/people/bios/sibande,g.htm|archive-date=2009-01-08|url-status=dead}}&lt;/ref&gt;

USibande wadlala indima eqakathekileko e-Potato Boycott yango-1959.[1]

Isifunda se -Gert Sibande esifundazweni se [[Isifunda seMpumalanga|-Mpumalanga]] eSewula Afrika siqanjwe ngegama lakhe. Wabelethelwa esifundeni begodu wachitha isikhathi esinengi sepilo yakhe lapho.

Ngemva kokuhlongakala kwakhe wanikelwe i-Order of Luthuli in Gold ngegalelo lakhe elihle khulu ekwenzeni ngcono ubujamo bokusebenza kwabasebenzi beplasi kanye nemizamo yakhe yokuthuthukisa iSewula Afrika engabandlululi ngokobuhlanga, enobulungiswa, nentando yenengi.&lt;ref&gt;{{Cite web|url=https://www.polity.org.za/article/anc-zuma-address-delivered-at-the-gert-sibande-memorial-lecture-23092008-2008-09-23|title=ANC: Zuma: Address delivered at the Gert Sibande Memorial Lecture (23/09/2008)|website=www.polity.org.za}}&lt;/ref&gt;

== Ipilo yokuthoma nomsebenzi ==
Wabelethwa ngo-1901 esifundeni se-Ermelo se- Eastern Transvaal yangaleso sikhathi (manje [[Isifunda seMpumalanga|i-Mpumalanga]] ), u-Sibande bekayindodana yomlimi oqatjhileko. Wathoma ukusebenza emaplasini aneminyaka ebunane, lapho aqalana khona nobujamo obubudisi. Ekuthomeni bekaziwa ngokuthi ngu-Shadrack Sibande, waphiwa ibizo elithi &quot;Gert&quot; mBhunu owavimbela ukusetjenziswa kwamabizo wesiNgisi eplasini lakhe. Iminyaka engaphezu kwama-20, u-Sibande wasebenza emaplasini ahlukahlukeneko e-Eastern Transvaal. Ukungafuni kwakhe ukwamukela ubujamo obumbi bokusebenza kwamenza waba nedumela lokuba mraro hlangana nabaqatjhi bakhe, njengombana bekavame ukubaphikisa ngeendaba zokuhlukunyezwa.

== Ukukhuthaza abasebenzi beplasi ==
Ngabo-1930, u-Sibande wathuthela e- Bethal Location, lapho athoma khona ukuhlela abasebenzi beplasi begodu alungisa iinkhalazo zabo. Ngesikhathi lesi, abasebenzi abanengi beplasini bebaqalene nobujamo obumbi khulu bokusebenza, basebenza kusukela ekuphumeni kwelanga ukuya ekutjhingeni kwelanga babhadelwa imali encani, begodu kanengi badla ukudla okuncani okufana ne-phuthu ne-gravy emasakeni. USibande wasiza ukusungula ihlangano yokuthoma eyaziwako yamalungelo wabasebenzi beplasini eSewula Afrika, i-Farm Workers' Association. Isiqhema lesi sisebenzele ukusiza abasebenzi beplasi bona bathole iintjalo ezibiweko begodu bathole ubujamo obungcono bokusebenza. Ngo-1939, u-Sibande wahlangana namalunga we- African National Congress (ANC) e [[Johannesburg|-Goli]] . Msinyana waba lilunga elisebenzako, wabuyela e-Bethal ukuyokwakha igatja eliqinileko le-ANC. Imizamo yakhe yenza bona kube nokutjheja okukhulu ngeemeko ezimbi abasebenzi beplasi ebebaqalene nazo, begodu wasiza ukuveza ukungabi nobulungiswa lokhu ebantwini abanengi, okufakahlangana abantu abadumileko abafana nomfundisi u-Michael Scott nentatheli u-Ruth First .&lt;ref&gt;Christopher Webb (2015) Fighting talk: Ruth First's early journalism 1947–1950, Review of African Political Economy, 42:143, 7-21, DOI:10.1080/03056244.2014.988697 Accessed 19 July 2017&lt;/ref&gt;

U-Sibande wasebenzisana no- Henry Nxumalo odumileko wemagazini ye-Drum, asiza ekugadangisweni kwama-atikili aveza ubujamo bokuxhaphaza kwabasebenzi beplasini ephasini. Iindaba ezitholweko zavezwa ku- ''New Age'' . ''I-Guardian'' yakhipha i-atikili yesibili ehlobene nokutholwe ngu-Gert Sibande mhlazi-25 kuNobayeni 1947.  ''I-Drum Magazine'' yakhipha i-atikili efanako ngo-1952, intathelizindaba u-Henry Nxumalo nomthwebuli weenthombe u-Jurgen Schoodeberg badlala indima eqakathekileko ekutloleni ubujamo babasebenzi beplasi lamazambana e-Bethal. I-atikili le yathola ukutjhejwa kwezwe neentjhabatjhaba kodwana, imibiko yalahlwa nguNgqongqotjhe wezeNdabuko, u-Hendrik Frensch Verwoerd ePalamende. Waxoshwa e-Bethal ziimphathimandla ngo-1953 ngebanga lokuzikhakhazisa kwakhe kwezepolotiki. Ngokukhamba kwesikhathi wathuthela [[Eswatini|eSwazini]] lapho asiza khona iphiko lebutho le-ANC uMkhonto we Sizwe . &lt;ref name=&quot;auto&quot;&gt;http://www.sahistory.org.za/people/gert-sibande {{Webarchive|url=https://web.archive.org/web/20130901062545/http://sahistory.org.za/people/gert-sibande|date=2013-09-01}} Accessed 20 July 2017&lt;/ref&gt; Ngo-1959, ngemva kweminyaka elitjhumi nambili uGert Sibande aveze ubujamo bezisebenzi, i -ANC yabika ubujamo obufanako emaplasini wommbila namanye amazambana.   Bekangumhlanganyeli okhutheleko emkhankasweni wokuphikisa, umkhankaso wokulwisana nefundo yamaBantu begodu wasiza nokutlola iTjhatha yeNkululeko . Wasebenza eduze noMphathi u-Albert Luthuli, u-Moses Kotane no -Moses Mabhida .  Bekalilunga lomKhandlu oPhetheko weNarha we- ANC begodu ngesikhathi sakhe soburholi, wasolwa ecaleni lokuvukela umbuso ngo-1956 ukuya ku-1961. Bekangomunye wabasolwa abambalwa abathatha isikhundla sofakazi ngesikhathi secala. Wakhethwa bona abe ngumengameli we-Transvaal ANC ngo-1958 begodu wakhethwa godu ngo-1959. &lt;ref name=&quot;auto1&quot; /&gt; Wahlongakala e [[Eswatini|-Swaziland]] ngo-1987. Wangcwatshwa e -Manzini phakathi ne-Swaziland. 

== Ukutlhoriswa nokuhlongakala ==
Ikululeko ka-Sibande yenza bona kube nokutlhoriswa okukhulu ngurhulumende webandlululo. Ngo-1953, waxoshwa e-Bethal, begodu ngo-1956, wabekwa icala lokuvukela umbuso njengengcenye yecala lokuvukela umbuso elidumileko. Nanyana gade aneentjhijilo, waragela phambili nomsebenzi wakhe ngaphakathi kwe-ANC, wakhethwa njengomongameli we-Transvaal ANC ngo-1958.

Ngemva kwecala lokuvukela umbuso, u-Sibande wakateleleka bona ahlale e -Komatipoort eduze nomngcele we- [[Eswatini|Swaziland]] ne [[Mozambique|-Mozambique]] . Ngo-1962, wawela waya e-Swaziland begodu ngokukhamba kwesikhathi wathenga itrektara wayisebenzisela ukunikela ngeenkonzo zokulima e-Swaziland, lapho ahlala khona iminyaka eminengi ahlala ekudingisweni. Wahlongakala ngo-1987, e -Manzini, e-Swazini.

Umasipala wesiyingi watjhugulula ibizo lakhe ukusuka ku-&quot;Eastvaal&quot; (Afrikaans: Oosvaal) waya ku-&quot;Gert Sibande&quot; uMasipala wesiFunda ngoNobayeni ka-2004.  Kune-Gert Sibande TVET College eneendawo ezihlukahlukeneko zekhampasi.   Kunesithombe sethusi saka-Gert Sibande esiqala esinye isithombe saka- [[Nokuthula Simelane]] e -Bethal . Iinthombe zingaphandle kwe-Nomoya Masilela Museum enikelwe abalweli bekululeko abafakahlangana u-Gert Sibande, u-Nokuthula Simelane, u-Ruth First no -Henry Nxumalo .   UMbongeni Ngema watlola begodu waqondisa umkhiqizo wesigaba sesabelomali sezigidi ezingama-R22 'Ibhubezi leMpumalanga' ebegade uhlanganiswe ngokuduba amazambana neminikelo ka-Gert Sibande. Umkhiqizo lo bewuneenkhundla e- Trinidad, e-Jamaica ne -Suriname . Umndeni ka-Sibande ukhuphe umthetho wokukhandela ukukhiqiza umvumo lo ngombana bathi akhenge bakhulumisane nabo. Ukuvinjelwa kwabekwa eceleni msinyana ngaphambi kokukhutjhwa komkhiqizo.

== Iinkomba ==</text>
      <sha1>qoctn2gsfrleitzq2yjgkje9m8819vx</sha1>
    </revision>
    <revision>
      <id>6381</id>
      <parentid>6380</parentid>
      <timestamp>2026-04-02T00:29:25Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6381</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7223" sha1="mq4ud6vb1tyvlvuv8borkv3agqzxazv" xml:space="preserve">
'''U-Gert Shedrack Sibande''' (1901 eduze ne-Ermelo, e-Mpumalanga – 1987; owaziwa nangokuthi yi '''-Lion of the East'''  ) bekayisisebenzi seplasini seSewula Afrika begodu bekasolo alwisana nebandlululo. Bekangomunye wabasolwa be -ANC ukujamela icala lokuvukela umbuso ngo-1956-61 kanye no [[Nelson Mandela|-Nelson Mandela]] nabanye abali-154. &lt;ref&gt;{{Cite web|url=http://www.sahistory.org.za/pages/people/bios/sibande,g.htm|title=Gert Sibande|access-date=2011-05-07|archive-url=https://web.archive.org/web/20090108042303/http://www.sahistory.org.za/pages/people/bios/sibande,g.htm|archive-date=2009-01-08|url-status=dead}}&lt;/ref&gt;

USibande wadlala indima eqakathekileko e-Potato Boycott yango-1959.[1]

Isifunda se -Gert Sibande esifundazweni se [[Isifunda seMpumalanga|-Mpumalanga]] eSewula Afrika siqanjwe ngegama lakhe. Wabelethelwa esifundeni begodu wachitha isikhathi esinengi sepilo yakhe lapho.

Ngemva kokuhlongakala kwakhe wanikelwe i-Order of Luthuli in Gold ngegalelo lakhe elihle khulu ekwenzeni ngcono ubujamo bokusebenza kwabasebenzi beplasi kanye nemizamo yakhe yokuthuthukisa iSewula Afrika engabandlululi ngokobuhlanga, enobulungiswa, nentando yenengi.&lt;ref&gt;{{Cite web|url=https://www.polity.org.za/article/anc-zuma-address-delivered-at-the-gert-sibande-memorial-lecture-23092008-2008-09-23|title=ANC: Zuma: Address delivered at the Gert Sibande Memorial Lecture (23/09/2008)|website=www.polity.org.za}}&lt;/ref&gt;

== Ipilo yokuthoma nomsebenzi ==
Wabelethwa ngo-1901 esifundeni se-Ermelo se- Eastern Transvaal yangaleso sikhathi (manje [[Isifunda seMpumalanga|i-Mpumalanga]] ), u-Sibande bekayindodana yomlimi oqatjhileko. Wathoma ukusebenza emaplasini aneminyaka ebunane, lapho aqalana khona nobujamo obubudisi. Ekuthomeni bekaziwa ngokuthi ngu-Shadrack Sibande, waphiwa ibizo elithi &quot;Gert&quot; mBhunu owavimbela ukusetjenziswa kwamabizo wesiNgisi eplasini lakhe. Iminyaka engaphezu kwama-20, u-Sibande wasebenza emaplasini ahlukahlukeneko e-Eastern Transvaal. Ukungafuni kwakhe ukwamukela ubujamo obumbi bokusebenza kwamenza waba nedumela lokuba mraro hlangana nabaqatjhi bakhe, njengombana bekavame ukubaphikisa ngeendaba zokuhlukunyezwa.

== Ukukhuthaza abasebenzi beplasi ==
Ngabo-1930, u-Sibande wathuthela e- [[Bethal]] Location, lapho athoma khona ukuhlela abasebenzi beplasi begodu alungisa iinkhalazo zabo. Ngesikhathi lesi, abasebenzi abanengi beplasini bebaqalene nobujamo obumbi khulu bokusebenza, basebenza kusukela ekuphumeni kwelanga ukuya ekutjhingeni kwelanga babhadelwa imali encani, begodu kanengi badla ukudla okuncani okufana ne-phuthu ne-gravy emasakeni. USibande wasiza ukusungula ihlangano yokuthoma eyaziwako yamalungelo wabasebenzi beplasini eSewula Afrika, i-Farm Workers' Association. Isiqhema lesi sisebenzele ukusiza abasebenzi beplasi bona bathole iintjalo ezibiweko begodu bathole ubujamo obungcono bokusebenza. Ngo-1939, u-Sibande wahlangana namalunga we- African National Congress (ANC) e [[Johannesburg|-Goli]] . Msinyana waba lilunga elisebenzako, wabuyela e-Bethal ukuyokwakha igatja eliqinileko le-ANC. Imizamo yakhe yenza bona kube nokutjheja okukhulu ngeemeko ezimbi abasebenzi beplasi ebebaqalene nazo, begodu wasiza ukuveza ukungabi nobulungiswa lokhu ebantwini abanengi, okufakahlangana abantu abadumileko abafana nomfundisi u-Michael Scott nentatheli u-Ruth First .&lt;ref&gt;Christopher Webb (2015) Fighting talk: Ruth First's early journalism 1947–1950, Review of African Political Economy, 42:143, 7-21, DOI:10.1080/03056244.2014.988697 Accessed 19 July 2017&lt;/ref&gt;

U-Sibande wasebenzisana no- Henry Nxumalo odumileko wemagazini ye-Drum, asiza ekugadangisweni kwama-atikili aveza ubujamo bokuxhaphaza kwabasebenzi beplasini ephasini. Iindaba ezitholweko zavezwa ku- ''New Age'' . ''I-Guardian'' yakhipha i-atikili yesibili ehlobene nokutholwe ngu-Gert Sibande mhlazi-25 kuNobayeni 1947.  ''I-Drum Magazine'' yakhipha i-atikili efanako ngo-1952, intathelizindaba u-[[Henry Nxumalo]] nomthwebuli weenthombe u-Jurgen Schoodeberg badlala indima eqakathekileko ekutloleni ubujamo babasebenzi beplasi lamazambana e-Bethal. I-atikili le yathola ukutjhejwa kwezwe neentjhabatjhaba kodwana, imibiko yalahlwa nguNgqongqotjhe wezeNdabuko, u-Hendrik Frensch Verwoerd ePalamende. Waxoshwa e-Bethal ziimphathimandla ngo-1953 ngebanga lokuzikhakhazisa kwakhe kwezepolotiki. Ngokukhamba kwesikhathi wathuthela [[Eswatini|eSwazini]] lapho asiza khona iphiko lebutho le-ANC uMkhonto we Sizwe . &lt;ref name=&quot;auto&quot;&gt;http://www.sahistory.org.za/people/gert-sibande {{Webarchive|url=https://web.archive.org/web/20130901062545/http://sahistory.org.za/people/gert-sibande|date=2013-09-01}} Accessed 20 July 2017&lt;/ref&gt; Ngo-1959, ngemva kweminyaka elitjhumi nambili uGert Sibande aveze ubujamo bezisebenzi, i -ANC yabika ubujamo obufanako emaplasini wommbila namanye amazambana.   Bekangumhlanganyeli okhutheleko emkhankasweni wokuphikisa, umkhankaso wokulwisana nefundo yamaBantu begodu wasiza nokutlola iTjhatha yeNkululeko . Wasebenza eduze noMphathi u-Albert Luthuli, u-Moses Kotane no -Moses Mabhida .  Bekalilunga lomKhandlu oPhetheko weNarha we- ANC begodu ngesikhathi sakhe soburholi, wasolwa ecaleni lokuvukela umbuso ngo-1956 ukuya ku-1961. Bekangomunye wabasolwa abambalwa abathatha isikhundla sofakazi ngesikhathi secala. Wakhethwa bona abe ngumengameli we-Transvaal ANC ngo-1958 begodu wakhethwa godu ngo-1959. &lt;ref name=&quot;auto1&quot; /&gt; Wahlongakala e [[Eswatini|-Swaziland]] ngo-1987. Wangcwatshwa e -Manzini phakathi ne-Swaziland. 

== Ukutlhoriswa nokuhlongakala ==
Ikululeko ka-Sibande yenza bona kube nokutlhoriswa okukhulu ngurhulumende webandlululo. Ngo-1953, waxoshwa e-Bethal, begodu ngo-1956, wabekwa icala lokuvukela umbuso njengengcenye yecala lokuvukela umbuso elidumileko. Nanyana gade aneentjhijilo, waragela phambili nomsebenzi wakhe ngaphakathi kwe-ANC, wakhethwa njengomongameli we-Transvaal ANC ngo-1958.

Ngemva kwecala lokuvukela umbuso, u-Sibande wakateleleka bona ahlale e -Komatipoort eduze nomngcele we- [[Eswatini|Swaziland]] ne [[Mozambique|-Mozambique]] . Ngo-1962, wawela waya e-Swaziland begodu ngokukhamba kwesikhathi wathenga itrektara wayisebenzisela ukunikela ngeenkonzo zokulima e-Swaziland, lapho ahlala khona iminyaka eminengi ahlala ekudingisweni. Wahlongakala ngo-1987, e -Manzini, e-Swazini.

Umasipala wesiyingi watjhugulula ibizo lakhe ukusuka ku-&quot;Eastvaal&quot; (Afrikaans: Oosvaal) waya ku-&quot;Gert Sibande&quot; uMasipala wesiFunda ngoNobayeni ka-2004.  Kune-Gert Sibande TVET College eneendawo ezihlukahlukeneko zekhampasi.   Kunesithombe sethusi saka-Gert Sibande esiqala esinye isithombe saka- [[Nokuthula Simelane]] e -Bethal . Iinthombe zingaphandle kwe-Nomoya Masilela Museum enikelwe abalweli bekululeko abafakahlangana u-Gert Sibande, u-Nokuthula Simelane, u-Ruth First no -Henry Nxumalo .   UMbongeni Ngema watlola begodu waqondisa umkhiqizo wesigaba sesabelomali sezigidi ezingama-R22 'Ibhubezi leMpumalanga' ebegade uhlanganiswe ngokuduba amazambana neminikelo ka-Gert Sibande. Umkhiqizo lo bewuneenkhundla e- Trinidad, e-Jamaica ne -Suriname . Umndeni ka-Sibande ukhuphe umthetho wokukhandela ukukhiqiza umvumo lo ngombana bathi akhenge bakhulumisane nabo. Ukuvinjelwa kwabekwa eceleni msinyana ngaphambi kokukhutjhwa komkhiqizo.

== Iinkomba ==</text>
      <sha1>mq4ud6vb1tyvlvuv8borkv3agqzxazv</sha1>
    </revision>
    <revision>
      <id>6382</id>
      <parentid>6381</parentid>
      <timestamp>2026-04-02T00:29:45Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6382</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7235" sha1="2e9adj6yutcbjz6odycnlyarvcejbez" xml:space="preserve">
'''U-Gert Shedrack Sibande''' (1901 eduze ne-Ermelo, e-Mpumalanga – 1987; owaziwa nangokuthi yi '''-Lion of the East'''  ) bekayisisebenzi seplasini seSewula Afrika begodu bekasolo alwisana nebandlululo. Bekangomunye wabasolwa be -ANC ukujamela icala lokuvukela umbuso ngo-1956-61 kanye no [[Nelson Mandela|-Nelson Mandela]] nabanye abali-154. &lt;ref&gt;{{Cite web|url=http://www.sahistory.org.za/pages/people/bios/sibande,g.htm|title=Gert Sibande|access-date=2011-05-07|archive-url=https://web.archive.org/web/20090108042303/http://www.sahistory.org.za/pages/people/bios/sibande,g.htm|archive-date=2009-01-08|url-status=dead}}&lt;/ref&gt;

USibande wadlala indima eqakathekileko e-Potato Boycott yango-1959.[1]

Isifunda se -Gert Sibande esifundazweni se [[Isifunda seMpumalanga|-Mpumalanga]] eSewula Afrika siqanjwe ngegama lakhe. Wabelethelwa esifundeni begodu wachitha isikhathi esinengi sepilo yakhe lapho.

Ngemva kokuhlongakala kwakhe wanikelwe i-Order of Luthuli in Gold ngegalelo lakhe elihle khulu ekwenzeni ngcono ubujamo bokusebenza kwabasebenzi beplasi kanye nemizamo yakhe yokuthuthukisa iSewula Afrika engabandlululi ngokobuhlanga, enobulungiswa, nentando yenengi.&lt;ref&gt;{{Cite web|url=https://www.polity.org.za/article/anc-zuma-address-delivered-at-the-gert-sibande-memorial-lecture-23092008-2008-09-23|title=ANC: Zuma: Address delivered at the Gert Sibande Memorial Lecture (23/09/2008)|website=www.polity.org.za}}&lt;/ref&gt;

== Ipilo yokuthoma nomsebenzi ==
Wabelethwa ngo-1901 esifundeni se-Ermelo se- Eastern Transvaal yangaleso sikhathi (manje [[Isifunda seMpumalanga|i-Mpumalanga]] ), u-Sibande bekayindodana yomlimi oqatjhileko. Wathoma ukusebenza emaplasini aneminyaka ebunane, lapho aqalana khona nobujamo obubudisi. Ekuthomeni bekaziwa ngokuthi ngu-Shadrack Sibande, waphiwa ibizo elithi &quot;Gert&quot; mBhunu owavimbela ukusetjenziswa kwamabizo wesiNgisi eplasini lakhe. Iminyaka engaphezu kwama-20, u-Sibande wasebenza emaplasini ahlukahlukeneko e-Eastern Transvaal. Ukungafuni kwakhe ukwamukela ubujamo obumbi bokusebenza kwamenza waba nedumela lokuba mraro hlangana nabaqatjhi bakhe, njengombana bekavame ukubaphikisa ngeendaba zokuhlukunyezwa.

== Ukukhuthaza abasebenzi beplasi ==
Ngabo-1930, u-Sibande wathuthela e- [[Bethal]] Location, lapho athoma khona ukuhlela abasebenzi beplasi begodu alungisa iinkhalazo zabo. Ngesikhathi lesi, abasebenzi abanengi beplasini bebaqalene nobujamo obumbi khulu bokusebenza, basebenza kusukela ekuphumeni kwelanga ukuya ekutjhingeni kwelanga babhadelwa imali encani, begodu kanengi badla ukudla okuncani okufana ne-phuthu ne-gravy emasakeni. USibande wasiza ukusungula ihlangano yokuthoma eyaziwako yamalungelo wabasebenzi beplasini eSewula Afrika, i-Farm Workers' Association. Isiqhema lesi sisebenzele ukusiza abasebenzi beplasi bona bathole iintjalo ezibiweko begodu bathole ubujamo obungcono bokusebenza. Ngo-1939, u-Sibande wahlangana namalunga we- African National Congress (ANC) e [[Johannesburg|-Goli]] . Msinyana waba lilunga elisebenzako, wabuyela e-Bethal ukuyokwakha igatja eliqinileko le-ANC. Imizamo yakhe yenza bona kube nokutjheja okukhulu ngeemeko ezimbi abasebenzi beplasi ebebaqalene nazo, begodu wasiza ukuveza ukungabi nobulungiswa lokhu ebantwini abanengi, okufakahlangana abantu abadumileko abafana nomfundisi u-Michael Scott nentatheli u-Ruth First .&lt;ref&gt;Christopher Webb (2015) Fighting talk: Ruth First's early journalism 1947–1950, Review of African Political Economy, 42:143, 7-21, DOI:10.1080/03056244.2014.988697 Accessed 19 July 2017&lt;/ref&gt;

U-Sibande wasebenzisana no- Henry Nxumalo odumileko wemagazini ye-Drum, asiza ekugadangisweni kwama-atikili aveza ubujamo bokuxhaphaza kwabasebenzi beplasini ephasini. Iindaba ezitholweko zavezwa ku- ''New Age'' . ''I-Guardian'' yakhipha i-atikili yesibili ehlobene nokutholwe ngu-Gert Sibande mhlazi-25 kuNobayeni 1947.  ''I-Drum Magazine'' yakhipha i-atikili efanako ngo-1952, intathelizindaba u-[[Henry Nxumalo]] nomthwebuli weenthombe u-Jurgen Schoodeberg badlala indima eqakathekileko ekutloleni ubujamo babasebenzi beplasi lamazambana e-Bethal. I-atikili le yathola ukutjhejwa kwezwe neentjhabatjhaba kodwana, imibiko yalahlwa nguNgqongqotjhe wezeNdabuko, u-Hendrik Frensch Verwoerd ePalamende. Waxoshwa e-Bethal ziimphathimandla ngo-1953 ngebanga lokuzikhakhazisa kwakhe kwezepolotiki. Ngokukhamba kwesikhathi wathuthela [[Eswatini|eSwazini]] lapho asiza khona iphiko lebutho le-ANC uMkhonto we Sizwe . &lt;ref name=&quot;auto&quot;&gt;http://www.sahistory.org.za/people/gert-sibande {{Webarchive|url=https://web.archive.org/web/20130901062545/http://sahistory.org.za/people/gert-sibande|date=2013-09-01}} Accessed 20 July 2017&lt;/ref&gt; Ngo-1959, ngemva kweminyaka elitjhumi nambili uGert Sibande aveze ubujamo bezisebenzi, i -ANC yabika ubujamo obufanako emaplasini wommbila namanye amazambana.   Bekangumhlanganyeli okhutheleko emkhankasweni wokuphikisa, umkhankaso wokulwisana nefundo yamaBantu begodu wasiza nokutlola iTjhatha yeNkululeko . Wasebenza eduze noMphathi u-Albert Luthuli, u-Moses Kotane no -Moses Mabhida .  Bekalilunga lomKhandlu oPhetheko weNarha we- ANC begodu ngesikhathi sakhe soburholi, wasolwa ecaleni lokuvukela umbuso ngo-1956 ukuya ku-1961. Bekangomunye wabasolwa abambalwa abathatha isikhundla sofakazi ngesikhathi secala. Wakhethwa bona abe ngumengameli we-Transvaal ANC ngo-1958 begodu wakhethwa godu ngo-1959. &lt;ref name=&quot;auto1&quot; /&gt; Wahlongakala e [[Eswatini|-Swaziland]] ngo-1987. Wangcwatshwa e -Manzini phakathi ne-Swaziland. 

== Ukutlhoriswa nokuhlongakala ==
Ikululeko ka-Sibande yenza bona kube nokutlhoriswa okukhulu ngurhulumende webandlululo. Ngo-1953, waxoshwa e-Bethal, begodu ngo-1956, wabekwa icala lokuvukela umbuso njengengcenye yecala lokuvukela umbuso elidumileko. Nanyana gade aneentjhijilo, waragela phambili nomsebenzi wakhe ngaphakathi kwe-ANC, wakhethwa njengomongameli we-Transvaal ANC ngo-1958.

Ngemva kwecala lokuvukela umbuso, u-Sibande wakateleleka bona ahlale e -Komatipoort eduze nomngcele we- [[Eswatini|Swaziland]] ne [[Mozambique|-Mozambique]] . Ngo-1962, wawela waya e-Swaziland begodu ngokukhamba kwesikhathi wathenga itrektara wayisebenzisela ukunikela ngeenkonzo zokulima e-Swaziland, lapho ahlala khona iminyaka eminengi ahlala ekudingisweni. Wahlongakala ngo-1987, e -Manzini, e-Swazini.

Umasipala wesiyingi watjhugulula ibizo lakhe ukusuka ku-&quot;Eastvaal&quot; (Afrikaans: Oosvaal) waya ku-&quot;Gert Sibande&quot; uMasipala wesiFunda ngoNobayeni ka-2004.  Kune-Gert Sibande TVET College eneendawo ezihlukahlukeneko zekhampasi.   Kunesithombe sethusi saka-Gert Sibande esiqala esinye isithombe saka- [[Nokuthula Simelane]] e -Bethal . Iinthombe zingaphandle kwe-Nomoya Masilela Museum enikelwe abalweli bekululeko abafakahlangana u-Gert Sibande, u-Nokuthula Simelane, u-Ruth First no -Henry Nxumalo .   UMbongeni Ngema watlola begodu waqondisa umkhiqizo wesigaba sesabelomali sezigidi ezingama-R22 'Ibhubezi leMpumalanga' ebegade uhlanganiswe ngokuduba amazambana neminikelo ka-Gert Sibande. Umkhiqizo lo bewuneenkhundla e- Trinidad, e-Jamaica ne -Suriname . Umndeni ka-Sibande ukhuphe umthetho wokukhandela ukukhiqiza umvumo lo ngombana bathi akhenge bakhulumisane nabo. Ukuvinjelwa kwabekwa eceleni msinyana ngaphambi kokukhutjhwa komkhiqizo.

== Iinkomba ==
{{reflist}}</text>
      <sha1>2e9adj6yutcbjz6odycnlyarvcejbez</sha1>
    </revision>
    <revision>
      <id>6383</id>
      <parentid>6382</parentid>
      <timestamp>2026-04-02T00:30:27Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6383</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7254" sha1="1lxscc6nc00jggtleych5h5bebiqjjb" xml:space="preserve">
'''U-Gert Shedrack Sibande''' (1901 eduze ne-Ermelo, e-Mpumalanga – 1987; owaziwa nangokuthi yi '''-Lion of the East'''  ) bekayisisebenzi seplasini seSewula Afrika begodu bekasolo alwisana nebandlululo. Bekangomunye wabasolwa be -ANC ukujamela icala lokuvukela umbuso ngo-1956-61 kanye no [[Nelson Mandela|-Nelson Mandela]] nabanye abali-154. &lt;ref&gt;{{Cite web|url=http://www.sahistory.org.za/pages/people/bios/sibande,g.htm|title=Gert Sibande|access-date=2011-05-07|archive-url=https://web.archive.org/web/20090108042303/http://www.sahistory.org.za/pages/people/bios/sibande,g.htm|archive-date=2009-01-08|url-status=dead}}&lt;/ref&gt;

USibande wadlala indima eqakathekileko e-Potato Boycott yango-1959.[1]

Isifunda se -Gert Sibande esifundazweni se [[Isifunda seMpumalanga|-Mpumalanga]] eSewula Afrika siqanjwe ngegama lakhe. Wabelethelwa esifundeni begodu wachitha isikhathi esinengi sepilo yakhe lapho.

Ngemva kokuhlongakala kwakhe wanikelwe i-Order of Luthuli in Gold ngegalelo lakhe elihle khulu ekwenzeni ngcono ubujamo bokusebenza kwabasebenzi beplasi kanye nemizamo yakhe yokuthuthukisa iSewula Afrika engabandlululi ngokobuhlanga, enobulungiswa, nentando yenengi.&lt;ref&gt;{{Cite web|url=https://www.polity.org.za/article/anc-zuma-address-delivered-at-the-gert-sibande-memorial-lecture-23092008-2008-09-23|title=ANC: Zuma: Address delivered at the Gert Sibande Memorial Lecture (23/09/2008)|website=www.polity.org.za}}&lt;/ref&gt;

== Ipilo yokuthoma nomsebenzi ==
Wabelethwa ngo-1901 esifundeni se-Ermelo se- Eastern Transvaal yangaleso sikhathi (manje [[Isifunda seMpumalanga|i-Mpumalanga]] ), u-Sibande bekayindodana yomlimi oqatjhileko. Wathoma ukusebenza emaplasini aneminyaka ebunane, lapho aqalana khona nobujamo obubudisi. Ekuthomeni bekaziwa ngokuthi ngu-Shadrack Sibande, waphiwa ibizo elithi &quot;Gert&quot; mBhunu owavimbela ukusetjenziswa kwamabizo wesiNgisi eplasini lakhe. Iminyaka engaphezu kwama-20, u-Sibande wasebenza emaplasini ahlukahlukeneko e-Eastern Transvaal. Ukungafuni kwakhe ukwamukela ubujamo obumbi bokusebenza kwamenza waba nedumela lokuba mraro hlangana nabaqatjhi bakhe, njengombana bekavame ukubaphikisa ngeendaba zokuhlukunyezwa.

== Ukukhuthaza abasebenzi beplasi ==
Ngabo-1930, u-Sibande wathuthela e- [[Bethal]] Location, lapho athoma khona ukuhlela abasebenzi beplasi begodu alungisa iinkhalazo zabo. Ngesikhathi lesi, abasebenzi abanengi beplasini bebaqalene nobujamo obumbi khulu bokusebenza, basebenza kusukela ekuphumeni kwelanga ukuya ekutjhingeni kwelanga babhadelwa imali encani, begodu kanengi badla ukudla okuncani okufana ne-phuthu ne-gravy emasakeni. USibande wasiza ukusungula ihlangano yokuthoma eyaziwako yamalungelo wabasebenzi beplasini eSewula Afrika, i-Farm Workers' Association. Isiqhema lesi sisebenzele ukusiza abasebenzi beplasi bona bathole iintjalo ezibiweko begodu bathole ubujamo obungcono bokusebenza. Ngo-1939, u-Sibande wahlangana namalunga we- African National Congress (ANC) e [[Johannesburg|-Goli]] . Msinyana waba lilunga elisebenzako, wabuyela e-Bethal ukuyokwakha igatja eliqinileko le-ANC. Imizamo yakhe yenza bona kube nokutjheja okukhulu ngeemeko ezimbi abasebenzi beplasi ebebaqalene nazo, begodu wasiza ukuveza ukungabi nobulungiswa lokhu ebantwini abanengi, okufakahlangana abantu abadumileko abafana nomfundisi u-Michael Scott nentatheli u-Ruth First .&lt;ref&gt;Christopher Webb (2015) Fighting talk: Ruth First's early journalism 1947–1950, Review of African Political Economy, 42:143, 7-21, DOI:10.1080/03056244.2014.988697 Accessed 19 July 2017&lt;/ref&gt;

U-Sibande wasebenzisana no- Henry Nxumalo odumileko wemagazini ye-Drum, asiza ekugadangisweni kwama-atikili aveza ubujamo bokuxhaphaza kwabasebenzi beplasini ephasini. Iindaba ezitholweko zavezwa ku- ''New Age'' . ''I-Guardian'' yakhipha i-atikili yesibili ehlobene nokutholwe ngu-Gert Sibande mhlazi-25 kuNobayeni 1947.  ''I-Drum Magazine'' yakhipha i-atikili efanako ngo-1952, intathelizindaba u-[[Henry Nxumalo]] nomthwebuli weenthombe u-Jurgen Schoodeberg badlala indima eqakathekileko ekutloleni ubujamo babasebenzi beplasi lamazambana e-Bethal. I-atikili le yathola ukutjhejwa kwezwe neentjhabatjhaba kodwana, imibiko yalahlwa nguNgqongqotjhe wezeNdabuko, u-Hendrik Frensch Verwoerd ePalamende. Waxoshwa e-Bethal ziimphathimandla ngo-1953 ngebanga lokuzikhakhazisa kwakhe kwezepolotiki. Ngokukhamba kwesikhathi wathuthela [[Eswatini|eSwazini]] lapho asiza khona iphiko lebutho le-ANC uMkhonto we Sizwe . &lt;ref name=&quot;auto&quot;&gt;http://www.sahistory.org.za/people/gert-sibande {{Webarchive|url=https://web.archive.org/web/20130901062545/http://sahistory.org.za/people/gert-sibande|date=2013-09-01}} Accessed 20 July 2017&lt;/ref&gt; Ngo-1959, ngemva kweminyaka elitjhumi nambili uGert Sibande aveze ubujamo bezisebenzi, i -ANC yabika ubujamo obufanako emaplasini wommbila namanye amazambana.   Bekangumhlanganyeli okhutheleko emkhankasweni wokuphikisa, umkhankaso wokulwisana nefundo yamaBantu begodu wasiza nokutlola iTjhatha yeNkululeko . Wasebenza eduze noMphathi u-Albert Luthuli, u-Moses Kotane no -Moses Mabhida .  Bekalilunga lomKhandlu oPhetheko weNarha we- ANC begodu ngesikhathi sakhe soburholi, wasolwa ecaleni lokuvukela umbuso ngo-1956 ukuya ku-1961. Bekangomunye wabasolwa abambalwa abathatha isikhundla sofakazi ngesikhathi secala. Wakhethwa bona abe ngumengameli we-Transvaal ANC ngo-1958 begodu wakhethwa godu ngo-1959. &lt;ref name=&quot;auto1&quot; /&gt; Wahlongakala e [[Eswatini|-Swaziland]] ngo-1987. Wangcwatshwa e -Manzini phakathi ne-Swaziland. 

== Ukutlhoriswa nokuhlongakala ==
Ikululeko ka-Sibande yenza bona kube nokutlhoriswa okukhulu ngurhulumende webandlululo. Ngo-1953, waxoshwa e-Bethal, begodu ngo-1956, wabekwa icala lokuvukela umbuso njengengcenye yecala lokuvukela umbuso elidumileko. Nanyana gade aneentjhijilo, waragela phambili nomsebenzi wakhe ngaphakathi kwe-ANC, wakhethwa njengomongameli we-Transvaal ANC ngo-1958.

Ngemva kwecala lokuvukela umbuso, u-Sibande wakateleleka bona ahlale e -Komatipoort eduze nomngcele we- [[Eswatini|Swaziland]] ne [[Mozambique|-Mozambique]] . Ngo-1962, wawela waya e-Swaziland begodu ngokukhamba kwesikhathi wathenga itrektara wayisebenzisela ukunikela ngeenkonzo zokulima e-Swaziland, lapho ahlala khona iminyaka eminengi ahlala ekudingisweni. Wahlongakala ngo-1987, e -Manzini, e-Swazini.

Umasipala wesiyingi watjhugulula ibizo lakhe ukusuka ku-&quot;Eastvaal&quot; (Afrikaans: Oosvaal) waya ku-&quot;Gert Sibande&quot; uMasipala wesiFunda ngoNobayeni ka-2004.  Kune-Gert Sibande TVET College eneendawo ezihlukahlukeneko zekhampasi.   Kunesithombe sethusi saka-Gert Sibande esiqala esinye isithombe saka- [[Nokuthula Simelane]] e -Bethal . Iinthombe zingaphandle kwe-Nomoya Masilela Museum enikelwe abalweli bekululeko abafakahlangana u-Gert Sibande, u-Nokuthula Simelane, u-Ruth First no -Henry Nxumalo .   UMbongeni Ngema watlola begodu waqondisa umkhiqizo wesigaba sesabelomali sezigidi ezingama-R22 'Ibhubezi leMpumalanga' ebegade uhlanganiswe ngokuduba amazambana neminikelo ka-Gert Sibande. Umkhiqizo lo bewuneenkhundla e- Trinidad, e-Jamaica ne -Suriname . Umndeni ka-Sibande ukhuphe umthetho wokukhandela ukukhiqiza umvumo lo ngombana bathi akhenge bakhulumisane nabo. Ukuvinjelwa kwabekwa eceleni msinyana ngaphambi kokukhutjhwa komkhiqizo.

== Iinkomba ==
{{reflist}}
[[Category;Bantu]]</text>
      <sha1>1lxscc6nc00jggtleych5h5bebiqjjb</sha1>
    </revision>
    <revision>
      <id>6384</id>
      <parentid>6383</parentid>
      <timestamp>2026-04-02T00:30:54Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6384</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7281" sha1="monlhvtodpd48wijno71qe7fyprxoyp" xml:space="preserve">
'''U-Gert Shedrack Sibande''' (1901 eduze ne-Ermelo, e-Mpumalanga – 1987; owaziwa nangokuthi yi '''-Lion of the East'''  ) bekayisisebenzi seplasini seSewula Afrika begodu bekasolo alwisana nebandlululo. Bekangomunye wabasolwa be -ANC ukujamela icala lokuvukela umbuso ngo-1956-61 kanye no [[Nelson Mandela|-Nelson Mandela]] nabanye abali-154. &lt;ref&gt;{{Cite web|url=http://www.sahistory.org.za/pages/people/bios/sibande,g.htm|title=Gert Sibande|access-date=2011-05-07|archive-url=https://web.archive.org/web/20090108042303/http://www.sahistory.org.za/pages/people/bios/sibande,g.htm|archive-date=2009-01-08|url-status=dead}}&lt;/ref&gt;

USibande wadlala indima eqakathekileko e-Potato Boycott yango-1959.[1]

Isifunda se -Gert Sibande esifundazweni se [[Isifunda seMpumalanga|-Mpumalanga]] eSewula Afrika siqanjwe ngegama lakhe. Wabelethelwa esifundeni begodu wachitha isikhathi esinengi sepilo yakhe lapho.

Ngemva kokuhlongakala kwakhe wanikelwe i-Order of Luthuli in Gold ngegalelo lakhe elihle khulu ekwenzeni ngcono ubujamo bokusebenza kwabasebenzi beplasi kanye nemizamo yakhe yokuthuthukisa iSewula Afrika engabandlululi ngokobuhlanga, enobulungiswa, nentando yenengi.&lt;ref&gt;{{Cite web|url=https://www.polity.org.za/article/anc-zuma-address-delivered-at-the-gert-sibande-memorial-lecture-23092008-2008-09-23|title=ANC: Zuma: Address delivered at the Gert Sibande Memorial Lecture (23/09/2008)|website=www.polity.org.za}}&lt;/ref&gt;

== Ipilo yokuthoma nomsebenzi ==
Wabelethwa ngo-1901 esifundeni se-Ermelo se- Eastern Transvaal yangaleso sikhathi (manje [[Isifunda seMpumalanga|i-Mpumalanga]] ), u-Sibande bekayindodana yomlimi oqatjhileko. Wathoma ukusebenza emaplasini aneminyaka ebunane, lapho aqalana khona nobujamo obubudisi. Ekuthomeni bekaziwa ngokuthi ngu-Shadrack Sibande, waphiwa ibizo elithi &quot;Gert&quot; mBhunu owavimbela ukusetjenziswa kwamabizo wesiNgisi eplasini lakhe. Iminyaka engaphezu kwama-20, u-Sibande wasebenza emaplasini ahlukahlukeneko e-Eastern Transvaal. Ukungafuni kwakhe ukwamukela ubujamo obumbi bokusebenza kwamenza waba nedumela lokuba mraro hlangana nabaqatjhi bakhe, njengombana bekavame ukubaphikisa ngeendaba zokuhlukunyezwa.

== Ukukhuthaza abasebenzi beplasi ==
Ngabo-1930, u-Sibande wathuthela e- [[Bethal]] Location, lapho athoma khona ukuhlela abasebenzi beplasi begodu alungisa iinkhalazo zabo. Ngesikhathi lesi, abasebenzi abanengi beplasini bebaqalene nobujamo obumbi khulu bokusebenza, basebenza kusukela ekuphumeni kwelanga ukuya ekutjhingeni kwelanga babhadelwa imali encani, begodu kanengi badla ukudla okuncani okufana ne-phuthu ne-gravy emasakeni. USibande wasiza ukusungula ihlangano yokuthoma eyaziwako yamalungelo wabasebenzi beplasini eSewula Afrika, i-Farm Workers' Association. Isiqhema lesi sisebenzele ukusiza abasebenzi beplasi bona bathole iintjalo ezibiweko begodu bathole ubujamo obungcono bokusebenza. Ngo-1939, u-Sibande wahlangana namalunga we- African National Congress (ANC) e [[Johannesburg|-Goli]] . Msinyana waba lilunga elisebenzako, wabuyela e-Bethal ukuyokwakha igatja eliqinileko le-ANC. Imizamo yakhe yenza bona kube nokutjheja okukhulu ngeemeko ezimbi abasebenzi beplasi ebebaqalene nazo, begodu wasiza ukuveza ukungabi nobulungiswa lokhu ebantwini abanengi, okufakahlangana abantu abadumileko abafana nomfundisi u-Michael Scott nentatheli u-Ruth First .&lt;ref&gt;Christopher Webb (2015) Fighting talk: Ruth First's early journalism 1947–1950, Review of African Political Economy, 42:143, 7-21, DOI:10.1080/03056244.2014.988697 Accessed 19 July 2017&lt;/ref&gt;

U-Sibande wasebenzisana no- Henry Nxumalo odumileko wemagazini ye-Drum, asiza ekugadangisweni kwama-atikili aveza ubujamo bokuxhaphaza kwabasebenzi beplasini ephasini. Iindaba ezitholweko zavezwa ku- ''New Age'' . ''I-Guardian'' yakhipha i-atikili yesibili ehlobene nokutholwe ngu-Gert Sibande mhlazi-25 kuNobayeni 1947.  ''I-Drum Magazine'' yakhipha i-atikili efanako ngo-1952, intathelizindaba u-[[Henry Nxumalo]] nomthwebuli weenthombe u-Jurgen Schoodeberg badlala indima eqakathekileko ekutloleni ubujamo babasebenzi beplasi lamazambana e-Bethal. I-atikili le yathola ukutjhejwa kwezwe neentjhabatjhaba kodwana, imibiko yalahlwa nguNgqongqotjhe wezeNdabuko, u-Hendrik Frensch Verwoerd ePalamende. Waxoshwa e-Bethal ziimphathimandla ngo-1953 ngebanga lokuzikhakhazisa kwakhe kwezepolotiki. Ngokukhamba kwesikhathi wathuthela [[Eswatini|eSwazini]] lapho asiza khona iphiko lebutho le-ANC uMkhonto we Sizwe . &lt;ref name=&quot;auto&quot;&gt;http://www.sahistory.org.za/people/gert-sibande {{Webarchive|url=https://web.archive.org/web/20130901062545/http://sahistory.org.za/people/gert-sibande|date=2013-09-01}} Accessed 20 July 2017&lt;/ref&gt; Ngo-1959, ngemva kweminyaka elitjhumi nambili uGert Sibande aveze ubujamo bezisebenzi, i -ANC yabika ubujamo obufanako emaplasini wommbila namanye amazambana.   Bekangumhlanganyeli okhutheleko emkhankasweni wokuphikisa, umkhankaso wokulwisana nefundo yamaBantu begodu wasiza nokutlola iTjhatha yeNkululeko . Wasebenza eduze noMphathi u-Albert Luthuli, u-Moses Kotane no -Moses Mabhida .  Bekalilunga lomKhandlu oPhetheko weNarha we- ANC begodu ngesikhathi sakhe soburholi, wasolwa ecaleni lokuvukela umbuso ngo-1956 ukuya ku-1961. Bekangomunye wabasolwa abambalwa abathatha isikhundla sofakazi ngesikhathi secala. Wakhethwa bona abe ngumengameli we-Transvaal ANC ngo-1958 begodu wakhethwa godu ngo-1959. &lt;ref name=&quot;auto1&quot; /&gt; Wahlongakala e [[Eswatini|-Swaziland]] ngo-1987. Wangcwatshwa e -Manzini phakathi ne-Swaziland. 

== Ukutlhoriswa nokuhlongakala ==
Ikululeko ka-Sibande yenza bona kube nokutlhoriswa okukhulu ngurhulumende webandlululo. Ngo-1953, waxoshwa e-Bethal, begodu ngo-1956, wabekwa icala lokuvukela umbuso njengengcenye yecala lokuvukela umbuso elidumileko. Nanyana gade aneentjhijilo, waragela phambili nomsebenzi wakhe ngaphakathi kwe-ANC, wakhethwa njengomongameli we-Transvaal ANC ngo-1958.

Ngemva kwecala lokuvukela umbuso, u-Sibande wakateleleka bona ahlale e -Komatipoort eduze nomngcele we- [[Eswatini|Swaziland]] ne [[Mozambique|-Mozambique]] . Ngo-1962, wawela waya e-Swaziland begodu ngokukhamba kwesikhathi wathenga itrektara wayisebenzisela ukunikela ngeenkonzo zokulima e-Swaziland, lapho ahlala khona iminyaka eminengi ahlala ekudingisweni. Wahlongakala ngo-1987, e -Manzini, e-Swazini.

Umasipala wesiyingi watjhugulula ibizo lakhe ukusuka ku-&quot;Eastvaal&quot; (Afrikaans: Oosvaal) waya ku-&quot;Gert Sibande&quot; uMasipala wesiFunda ngoNobayeni ka-2004.  Kune-Gert Sibande TVET College eneendawo ezihlukahlukeneko zekhampasi.   Kunesithombe sethusi saka-Gert Sibande esiqala esinye isithombe saka- [[Nokuthula Simelane]] e -Bethal . Iinthombe zingaphandle kwe-Nomoya Masilela Museum enikelwe abalweli bekululeko abafakahlangana u-Gert Sibande, u-Nokuthula Simelane, u-Ruth First no -Henry Nxumalo .   UMbongeni Ngema watlola begodu waqondisa umkhiqizo wesigaba sesabelomali sezigidi ezingama-R22 'Ibhubezi leMpumalanga' ebegade uhlanganiswe ngokuduba amazambana neminikelo ka-Gert Sibande. Umkhiqizo lo bewuneenkhundla e- Trinidad, e-Jamaica ne -Suriname . Umndeni ka-Sibande ukhuphe umthetho wokukhandela ukukhiqiza umvumo lo ngombana bathi akhenge bakhulumisane nabo. Ukuvinjelwa kwabekwa eceleni msinyana ngaphambi kokukhutjhwa komkhiqizo.

== Iinkomba ==
{{reflist}}
[[Category;Bantu]]
[[Category:Sewula Afrika]]</text>
      <sha1>monlhvtodpd48wijno71qe7fyprxoyp</sha1>
    </revision>
    <revision>
      <id>6385</id>
      <parentid>6384</parentid>
      <timestamp>2026-04-02T00:31:48Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6385</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7282" sha1="nwlgt638r5ifh0p5932ouob4t9kb11j" xml:space="preserve">
'''U-Gert Shedrack Sibande''' (1901 eduze ne-Ermelo, e-Mpumalanga – 1987; owaziwa nangokuthi yi '''-Lion of the East'''  ) bekayisisebenzi seplasini seSewula Afrika begodu bekasolo alwisana nebandlululo. Bekangomunye wabasolwa be -ANC ukujamela icala lokuvukela umbuso ngo-1956-61 kanye no [[Nelson Mandela|-Nelson Mandela]] nabanye abali-154. &lt;ref&gt;{{Cite web|url=http://www.sahistory.org.za/pages/people/bios/sibande,g.htm|title=Gert Sibande|access-date=2011-05-07|archive-url=https://web.archive.org/web/20090108042303/http://www.sahistory.org.za/pages/people/bios/sibande,g.htm|archive-date=2009-01-08|url-status=dead}}&lt;/ref&gt;

USibande wadlala indima eqakathekileko e-Potato Boycott yango-1959.[1]

Isifunda se -Gert Sibande esifundazweni se [[Isifunda seMpumalanga|-Mpumalanga]] eSewula Afrika siqanjwe ngegama lakhe. Wabelethelwa esifundeni begodu wachitha isikhathi esinengi sepilo yakhe lapho.

Ngemva kokuhlongakala kwakhe wanikelwe i-Order of Luthuli in Gold ngegalelo lakhe elihle khulu ekwenzeni ngcono ubujamo bokusebenza kwabasebenzi beplasi kanye nemizamo yakhe yokuthuthukisa iSewula Afrika engabandlululi ngokobuhlanga, enobulungiswa, nentando yenengi.&lt;ref&gt;{{Cite web|url=https://www.polity.org.za/article/anc-zuma-address-delivered-at-the-gert-sibande-memorial-lecture-23092008-2008-09-23|title=ANC: Zuma: Address delivered at the Gert Sibande Memorial Lecture (23/09/2008)|website=www.polity.org.za}}&lt;/ref&gt;

== Ipilo yokuthoma nomsebenzi ==
Wabelethwa ngo-1901 esifundeni se-Ermelo se- Eastern Transvaal yangaleso sikhathi (manje [[Isifunda seMpumalanga|i-Mpumalanga]] ), u-Sibande bekayindodana yomlimi oqatjhileko. Wathoma ukusebenza emaplasini aneminyaka ebunane, lapho aqalana khona nobujamo obubudisi. Ekuthomeni bekaziwa ngokuthi ngu-Shadrack Sibande, waphiwa ibizo elithi &quot;Gert&quot; mBhunu owavimbela ukusetjenziswa kwamabizo wesiNgisi eplasini lakhe. Iminyaka engaphezu kwama-20, u-Sibande wasebenza emaplasini ahlukahlukeneko e-Eastern Transvaal. Ukungafuni kwakhe ukwamukela ubujamo obumbi bokusebenza kwamenza waba nedumela lokuba mraro hlangana nabaqatjhi bakhe, njengombana bekavame ukubaphikisa ngeendaba zokuhlukunyezwa.

== Ukukhuthaza abasebenzi beplasi ==
Ngabo-1930, u-Sibande wathuthela e- [[Bethal]] Location, lapho athoma khona ukuhlela abasebenzi beplasi begodu alungisa iinkhalazo zabo. Ngesikhathi lesi, abasebenzi abanengi beplasini bebaqalene nobujamo obumbi khulu bokusebenza, basebenza kusukela ekuphumeni kwelanga ukuya ekutjhingeni kwelanga babhadelwa imali encani, begodu kanengi badla ukudla okuncani okufana ne-phuthu ne-gravy emasakeni. USibande wasiza ukusungula ihlangano yokuthoma eyaziwako yamalungelo wabasebenzi beplasini eSewula Afrika, i-Farm Workers' Association. Isiqhema lesi sisebenzele ukusiza abasebenzi beplasi bona bathole iintjalo ezibiweko begodu bathole ubujamo obungcono bokusebenza. Ngo-1939, u-Sibande wahlangana namalunga we- African National Congress (ANC) e [[Johannesburg|-Goli]] . Msinyana waba lilunga elisebenzako, wabuyela e-Bethal ukuyokwakha igatja eliqinileko le-ANC. Imizamo yakhe yenza bona kube nokutjheja okukhulu ngeemeko ezimbi abasebenzi beplasi ebebaqalene nazo, begodu wasiza ukuveza ukungabi nobulungiswa lokhu ebantwini abanengi, okufakahlangana abantu abadumileko abafana nomfundisi u-Michael Scott nentatheli u-Ruth First .&lt;ref&gt;Christopher Webb (2015) Fighting talk: Ruth First's early journalism 1947–1950, Review of African Political Economy, 42:143, 7-21, DOI:10.1080/03056244.2014.988697 Accessed 19 July 2017&lt;/ref&gt;

U-Sibande wasebenzisana no- Henry Nxumalo odumileko wemagazini ye-Drum, asiza ekugadangisweni kwama-atikili aveza ubujamo bokuxhaphaza kwabasebenzi beplasini ephasini. Iindaba ezitholweko zavezwa ku- ''New Age'' . ''I-Guardian'' yakhipha i-atikili yesibili ehlobene nokutholwe ngu-Gert Sibande mhlazi-25 kuNobayeni 1947.  ''I-Drum Magazine'' yakhipha i-atikili efanako ngo-1952, intathelizindaba u-[[Henry Nxumalo]] nomthwebuli weenthombe u-Jurgen Schoodeberg badlala indima eqakathekileko ekutloleni ubujamo babasebenzi beplasi lamazambana e-Bethal. I-atikili le yathola ukutjhejwa kwezwe neentjhabatjhaba kodwana, imibiko yalahlwa nguNgqongqotjhe wezeNdabuko, u-Hendrik Frensch Verwoerd ePalamende. Waxoshwa e-Bethal ziimphathimandla ngo-1953 ngebanga lokuzikhakhazisa kwakhe kwezepolotiki. Ngokukhamba kwesikhathi wathuthela [[Eswatini|eSwazini]] lapho asiza khona iphiko lebutho le-ANC uMkhonto we Sizwe . &lt;ref name=&quot;auto&quot;&gt;http://www.sahistory.org.za/people/gert-sibande {{Webarchive|url=https://web.archive.org/web/20130901062545/http://sahistory.org.za/people/gert-sibande|date=2013-09-01}} Accessed 20 July 2017&lt;/ref&gt; Ngo-1959, ngemva kweminyaka elitjhumi nambili uGert Sibande aveze ubujamo bezisebenzi, i -ANC yabika ubujamo obufanako emaplasini wommbila namanye amazambana.   Bekangumhlanganyeli okhutheleko emkhankasweni wokuphikisa, umkhankaso wokulwisana nefundo yamaBantu begodu wasiza nokutlola iTjhatha yeNkululeko . Wasebenza eduze noMphathi u-Albert Luthuli, u-Moses Kotane no -Moses Mabhida .  Bekalilunga lomKhandlu oPhetheko weNarha we- ANC begodu ngesikhathi sakhe soburholi, wasolwa ecaleni lokuvukela umbuso ngo-1956 ukuya ku-1961. Bekangomunye wabasolwa abambalwa abathatha isikhundla sofakazi ngesikhathi secala. Wakhethwa bona abe ngumengameli we-Transvaal ANC ngo-1958 begodu wakhethwa godu ngo-1959. &lt;ref name=&quot;auto1&quot; /&gt; Wahlongakala e [[Eswatini|-Swaziland]] ngo-1987. Wangcwatshwa e -Manzini phakathi ne-Swaziland. 

== Ukutlhoriswa nokuhlongakala ==
Ikululeko ka-Sibande yenza bona kube nokutlhoriswa okukhulu ngurhulumende webandlululo. Ngo-1953, waxoshwa e-Bethal, begodu ngo-1956, wabekwa icala lokuvukela umbuso njengengcenye yecala lokuvukela umbuso elidumileko. Nanyana gade aneentjhijilo, waragela phambili nomsebenzi wakhe ngaphakathi kwe-ANC, wakhethwa njengomongameli we-Transvaal ANC ngo-1958.

Ngemva kwecala lokuvukela umbuso, u-Sibande wakateleleka bona ahlale e -Komatipoort eduze nomngcele we- [[Eswatini|Swaziland]] ne [[Mozambique|-Mozambique]] . Ngo-1962, wawela waya e-Swaziland begodu ngokukhamba kwesikhathi wathenga itrektara wayisebenzisela ukunikela ngeenkonzo zokulima e-Swaziland, lapho ahlala khona iminyaka eminengi ahlala ekudingisweni. Wahlongakala ngo-1987, e -Manzini, e-Swazini.

Umasipala wesiyingi watjhugulula ibizo lakhe ukusuka ku-&quot;Eastvaal&quot; (Afrikaans: Oosvaal) waya ku-&quot;Gert Sibande&quot; uMasipala wesiFunda ngoNobayeni ka-2004.  Kune-Gert Sibande TVET College eneendawo ezihlukahlukeneko zekhampasi.   Kunesithombe sethusi saka-Gert Sibande esiqala esinye isithombe saka- [[Nokuthula Simelane]] e -Bethal . Iinthombe zingaphandle kwe-Nomoya Masilela Museum enikelwe abalweli bekululeko abafakahlangana u-Gert Sibande, u-Nokuthula Simelane, u-Ruth First no -Henry Nxumalo .   UMbongeni Ngema watlola begodu waqondisa umkhiqizo wesigaba sesabelomali sezigidi ezingama-R22 'Ibhubezi leMpumalanga' ebegade uhlanganiswe ngokuduba amazambana neminikelo ka-Gert Sibande. Umkhiqizo lo bewuneenkhundla e- Trinidad, e-Jamaica ne -Suriname . Umndeni ka-Sibande ukhuphe umthetho wokukhandela ukukhiqiza umvumo lo ngombana bathi akhenge bakhulumisane nabo. Ukuvinjelwa kwabekwa eceleni msinyana ngaphambi kokukhutjhwa komkhiqizo.

== Iinkomba ==
{{reflist}}
[[Category;Abantu]]
[[Category:Sewula Afrika]]</text>
      <sha1>nwlgt638r5ifh0p5932ouob4t9kb11j</sha1>
    </revision>
    <revision>
      <id>6386</id>
      <parentid>6385</parentid>
      <timestamp>2026-04-02T00:32:28Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6386</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7281" sha1="monlhvtodpd48wijno71qe7fyprxoyp" xml:space="preserve">
'''U-Gert Shedrack Sibande''' (1901 eduze ne-Ermelo, e-Mpumalanga – 1987; owaziwa nangokuthi yi '''-Lion of the East'''  ) bekayisisebenzi seplasini seSewula Afrika begodu bekasolo alwisana nebandlululo. Bekangomunye wabasolwa be -ANC ukujamela icala lokuvukela umbuso ngo-1956-61 kanye no [[Nelson Mandela|-Nelson Mandela]] nabanye abali-154. &lt;ref&gt;{{Cite web|url=http://www.sahistory.org.za/pages/people/bios/sibande,g.htm|title=Gert Sibande|access-date=2011-05-07|archive-url=https://web.archive.org/web/20090108042303/http://www.sahistory.org.za/pages/people/bios/sibande,g.htm|archive-date=2009-01-08|url-status=dead}}&lt;/ref&gt;

USibande wadlala indima eqakathekileko e-Potato Boycott yango-1959.[1]

Isifunda se -Gert Sibande esifundazweni se [[Isifunda seMpumalanga|-Mpumalanga]] eSewula Afrika siqanjwe ngegama lakhe. Wabelethelwa esifundeni begodu wachitha isikhathi esinengi sepilo yakhe lapho.

Ngemva kokuhlongakala kwakhe wanikelwe i-Order of Luthuli in Gold ngegalelo lakhe elihle khulu ekwenzeni ngcono ubujamo bokusebenza kwabasebenzi beplasi kanye nemizamo yakhe yokuthuthukisa iSewula Afrika engabandlululi ngokobuhlanga, enobulungiswa, nentando yenengi.&lt;ref&gt;{{Cite web|url=https://www.polity.org.za/article/anc-zuma-address-delivered-at-the-gert-sibande-memorial-lecture-23092008-2008-09-23|title=ANC: Zuma: Address delivered at the Gert Sibande Memorial Lecture (23/09/2008)|website=www.polity.org.za}}&lt;/ref&gt;

== Ipilo yokuthoma nomsebenzi ==
Wabelethwa ngo-1901 esifundeni se-Ermelo se- Eastern Transvaal yangaleso sikhathi (manje [[Isifunda seMpumalanga|i-Mpumalanga]] ), u-Sibande bekayindodana yomlimi oqatjhileko. Wathoma ukusebenza emaplasini aneminyaka ebunane, lapho aqalana khona nobujamo obubudisi. Ekuthomeni bekaziwa ngokuthi ngu-Shadrack Sibande, waphiwa ibizo elithi &quot;Gert&quot; mBhunu owavimbela ukusetjenziswa kwamabizo wesiNgisi eplasini lakhe. Iminyaka engaphezu kwama-20, u-Sibande wasebenza emaplasini ahlukahlukeneko e-Eastern Transvaal. Ukungafuni kwakhe ukwamukela ubujamo obumbi bokusebenza kwamenza waba nedumela lokuba mraro hlangana nabaqatjhi bakhe, njengombana bekavame ukubaphikisa ngeendaba zokuhlukunyezwa.

== Ukukhuthaza abasebenzi beplasi ==
Ngabo-1930, u-Sibande wathuthela e- [[Bethal]] Location, lapho athoma khona ukuhlela abasebenzi beplasi begodu alungisa iinkhalazo zabo. Ngesikhathi lesi, abasebenzi abanengi beplasini bebaqalene nobujamo obumbi khulu bokusebenza, basebenza kusukela ekuphumeni kwelanga ukuya ekutjhingeni kwelanga babhadelwa imali encani, begodu kanengi badla ukudla okuncani okufana ne-phuthu ne-gravy emasakeni. USibande wasiza ukusungula ihlangano yokuthoma eyaziwako yamalungelo wabasebenzi beplasini eSewula Afrika, i-Farm Workers' Association. Isiqhema lesi sisebenzele ukusiza abasebenzi beplasi bona bathole iintjalo ezibiweko begodu bathole ubujamo obungcono bokusebenza. Ngo-1939, u-Sibande wahlangana namalunga we- African National Congress (ANC) e [[Johannesburg|-Goli]] . Msinyana waba lilunga elisebenzako, wabuyela e-Bethal ukuyokwakha igatja eliqinileko le-ANC. Imizamo yakhe yenza bona kube nokutjheja okukhulu ngeemeko ezimbi abasebenzi beplasi ebebaqalene nazo, begodu wasiza ukuveza ukungabi nobulungiswa lokhu ebantwini abanengi, okufakahlangana abantu abadumileko abafana nomfundisi u-Michael Scott nentatheli u-Ruth First .&lt;ref&gt;Christopher Webb (2015) Fighting talk: Ruth First's early journalism 1947–1950, Review of African Political Economy, 42:143, 7-21, DOI:10.1080/03056244.2014.988697 Accessed 19 July 2017&lt;/ref&gt;

U-Sibande wasebenzisana no- Henry Nxumalo odumileko wemagazini ye-Drum, asiza ekugadangisweni kwama-atikili aveza ubujamo bokuxhaphaza kwabasebenzi beplasini ephasini. Iindaba ezitholweko zavezwa ku- ''New Age'' . ''I-Guardian'' yakhipha i-atikili yesibili ehlobene nokutholwe ngu-Gert Sibande mhlazi-25 kuNobayeni 1947.  ''I-Drum Magazine'' yakhipha i-atikili efanako ngo-1952, intathelizindaba u-[[Henry Nxumalo]] nomthwebuli weenthombe u-Jurgen Schoodeberg badlala indima eqakathekileko ekutloleni ubujamo babasebenzi beplasi lamazambana e-Bethal. I-atikili le yathola ukutjhejwa kwezwe neentjhabatjhaba kodwana, imibiko yalahlwa nguNgqongqotjhe wezeNdabuko, u-Hendrik Frensch Verwoerd ePalamende. Waxoshwa e-Bethal ziimphathimandla ngo-1953 ngebanga lokuzikhakhazisa kwakhe kwezepolotiki. Ngokukhamba kwesikhathi wathuthela [[Eswatini|eSwazini]] lapho asiza khona iphiko lebutho le-ANC uMkhonto we Sizwe . &lt;ref name=&quot;auto&quot;&gt;http://www.sahistory.org.za/people/gert-sibande {{Webarchive|url=https://web.archive.org/web/20130901062545/http://sahistory.org.za/people/gert-sibande|date=2013-09-01}} Accessed 20 July 2017&lt;/ref&gt; Ngo-1959, ngemva kweminyaka elitjhumi nambili uGert Sibande aveze ubujamo bezisebenzi, i -ANC yabika ubujamo obufanako emaplasini wommbila namanye amazambana.   Bekangumhlanganyeli okhutheleko emkhankasweni wokuphikisa, umkhankaso wokulwisana nefundo yamaBantu begodu wasiza nokutlola iTjhatha yeNkululeko . Wasebenza eduze noMphathi u-Albert Luthuli, u-Moses Kotane no -Moses Mabhida .  Bekalilunga lomKhandlu oPhetheko weNarha we- ANC begodu ngesikhathi sakhe soburholi, wasolwa ecaleni lokuvukela umbuso ngo-1956 ukuya ku-1961. Bekangomunye wabasolwa abambalwa abathatha isikhundla sofakazi ngesikhathi secala. Wakhethwa bona abe ngumengameli we-Transvaal ANC ngo-1958 begodu wakhethwa godu ngo-1959. &lt;ref name=&quot;auto1&quot; /&gt; Wahlongakala e [[Eswatini|-Swaziland]] ngo-1987. Wangcwatshwa e -Manzini phakathi ne-Swaziland. 

== Ukutlhoriswa nokuhlongakala ==
Ikululeko ka-Sibande yenza bona kube nokutlhoriswa okukhulu ngurhulumende webandlululo. Ngo-1953, waxoshwa e-Bethal, begodu ngo-1956, wabekwa icala lokuvukela umbuso njengengcenye yecala lokuvukela umbuso elidumileko. Nanyana gade aneentjhijilo, waragela phambili nomsebenzi wakhe ngaphakathi kwe-ANC, wakhethwa njengomongameli we-Transvaal ANC ngo-1958.

Ngemva kwecala lokuvukela umbuso, u-Sibande wakateleleka bona ahlale e -Komatipoort eduze nomngcele we- [[Eswatini|Swaziland]] ne [[Mozambique|-Mozambique]] . Ngo-1962, wawela waya e-Swaziland begodu ngokukhamba kwesikhathi wathenga itrektara wayisebenzisela ukunikela ngeenkonzo zokulima e-Swaziland, lapho ahlala khona iminyaka eminengi ahlala ekudingisweni. Wahlongakala ngo-1987, e -Manzini, e-Swazini.

Umasipala wesiyingi watjhugulula ibizo lakhe ukusuka ku-&quot;Eastvaal&quot; (Afrikaans: Oosvaal) waya ku-&quot;Gert Sibande&quot; uMasipala wesiFunda ngoNobayeni ka-2004.  Kune-Gert Sibande TVET College eneendawo ezihlukahlukeneko zekhampasi.   Kunesithombe sethusi saka-Gert Sibande esiqala esinye isithombe saka- [[Nokuthula Simelane]] e -Bethal . Iinthombe zingaphandle kwe-Nomoya Masilela Museum enikelwe abalweli bekululeko abafakahlangana u-Gert Sibande, u-Nokuthula Simelane, u-Ruth First no -Henry Nxumalo .   UMbongeni Ngema watlola begodu waqondisa umkhiqizo wesigaba sesabelomali sezigidi ezingama-R22 'Ibhubezi leMpumalanga' ebegade uhlanganiswe ngokuduba amazambana neminikelo ka-Gert Sibande. Umkhiqizo lo bewuneenkhundla e- Trinidad, e-Jamaica ne -Suriname . Umndeni ka-Sibande ukhuphe umthetho wokukhandela ukukhiqiza umvumo lo ngombana bathi akhenge bakhulumisane nabo. Ukuvinjelwa kwabekwa eceleni msinyana ngaphambi kokukhutjhwa komkhiqizo.

== Iinkomba ==
{{reflist}}
[[Category;Bantu]]
[[Category:Sewula Afrika]]</text>
      <sha1>monlhvtodpd48wijno71qe7fyprxoyp</sha1>
    </revision>
    <revision>
      <id>6387</id>
      <parentid>6386</parentid>
      <timestamp>2026-04-02T00:33:10Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6387</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7281" sha1="bj47ok5jwrdeq1ooxffzcc7tjfibhud" xml:space="preserve">
'''U-Gert Shedrack Sibande''' (1901 eduze ne-Ermelo, e-Mpumalanga – 1987; owaziwa nangokuthi yi '''-Lion of the East'''  ) bekayisisebenzi seplasini seSewula Afrika begodu bekasolo alwisana nebandlululo. Bekangomunye wabasolwa be -ANC ukujamela icala lokuvukela umbuso ngo-1956-61 kanye no [[Nelson Mandela|-Nelson Mandela]] nabanye abali-154. &lt;ref&gt;{{Cite web|url=http://www.sahistory.org.za/pages/people/bios/sibande,g.htm|title=Gert Sibande|access-date=2011-05-07|archive-url=https://web.archive.org/web/20090108042303/http://www.sahistory.org.za/pages/people/bios/sibande,g.htm|archive-date=2009-01-08|url-status=dead}}&lt;/ref&gt;

USibande wadlala indima eqakathekileko e-Potato Boycott yango-1959.[1]

Isifunda se -Gert Sibande esifundazweni se [[Isifunda seMpumalanga|-Mpumalanga]] eSewula Afrika siqanjwe ngegama lakhe. Wabelethelwa esifundeni begodu wachitha isikhathi esinengi sepilo yakhe lapho.

Ngemva kokuhlongakala kwakhe wanikelwe i-Order of Luthuli in Gold ngegalelo lakhe elihle khulu ekwenzeni ngcono ubujamo bokusebenza kwabasebenzi beplasi kanye nemizamo yakhe yokuthuthukisa iSewula Afrika engabandlululi ngokobuhlanga, enobulungiswa, nentando yenengi.&lt;ref&gt;{{Cite web|url=https://www.polity.org.za/article/anc-zuma-address-delivered-at-the-gert-sibande-memorial-lecture-23092008-2008-09-23|title=ANC: Zuma: Address delivered at the Gert Sibande Memorial Lecture (23/09/2008)|website=www.polity.org.za}}&lt;/ref&gt;

== Ipilo yokuthoma nomsebenzi ==
Wabelethwa ngo-1901 esifundeni se-Ermelo se- Eastern Transvaal yangaleso sikhathi (manje [[Isifunda seMpumalanga|i-Mpumalanga]] ), u-Sibande bekayindodana yomlimi oqatjhileko. Wathoma ukusebenza emaplasini aneminyaka ebunane, lapho aqalana khona nobujamo obubudisi. Ekuthomeni bekaziwa ngokuthi ngu-Shadrack Sibande, waphiwa ibizo elithi &quot;Gert&quot; mBhunu owavimbela ukusetjenziswa kwamabizo wesiNgisi eplasini lakhe. Iminyaka engaphezu kwama-20, u-Sibande wasebenza emaplasini ahlukahlukeneko e-Eastern Transvaal. Ukungafuni kwakhe ukwamukela ubujamo obumbi bokusebenza kwamenza waba nedumela lokuba mraro hlangana nabaqatjhi bakhe, njengombana bekavame ukubaphikisa ngeendaba zokuhlukunyezwa.

== Ukukhuthaza abasebenzi beplasi ==
Ngabo-1930, u-Sibande wathuthela e- [[Bethal]] Location, lapho athoma khona ukuhlela abasebenzi beplasi begodu alungisa iinkhalazo zabo. Ngesikhathi lesi, abasebenzi abanengi beplasini bebaqalene nobujamo obumbi khulu bokusebenza, basebenza kusukela ekuphumeni kwelanga ukuya ekutjhingeni kwelanga babhadelwa imali encani, begodu kanengi badla ukudla okuncani okufana ne-phuthu ne-gravy emasakeni. USibande wasiza ukusungula ihlangano yokuthoma eyaziwako yamalungelo wabasebenzi beplasini eSewula Afrika, i-Farm Workers' Association. Isiqhema lesi sisebenzele ukusiza abasebenzi beplasi bona bathole iintjalo ezibiweko begodu bathole ubujamo obungcono bokusebenza. Ngo-1939, u-Sibande wahlangana namalunga we- African National Congress (ANC) e [[Johannesburg|-Goli]] . Msinyana waba lilunga elisebenzako, wabuyela e-Bethal ukuyokwakha igatja eliqinileko le-ANC. Imizamo yakhe yenza bona kube nokutjheja okukhulu ngeemeko ezimbi abasebenzi beplasi ebebaqalene nazo, begodu wasiza ukuveza ukungabi nobulungiswa lokhu ebantwini abanengi, okufakahlangana abantu abadumileko abafana nomfundisi u-Michael Scott nentatheli u-Ruth First .&lt;ref&gt;Christopher Webb (2015) Fighting talk: Ruth First's early journalism 1947–1950, Review of African Political Economy, 42:143, 7-21, DOI:10.1080/03056244.2014.988697 Accessed 19 July 2017&lt;/ref&gt;

U-Sibande wasebenzisana no- Henry Nxumalo odumileko wemagazini ye-Drum, asiza ekugadangisweni kwama-atikili aveza ubujamo bokuxhaphaza kwabasebenzi beplasini ephasini. Iindaba ezitholweko zavezwa ku- ''New Age'' . ''I-Guardian'' yakhipha i-atikili yesibili ehlobene nokutholwe ngu-Gert Sibande mhlazi-25 kuNobayeni 1947.  ''I-Drum Magazine'' yakhipha i-atikili efanako ngo-1952, intathelizindaba u-[[Henry Nxumalo]] nomthwebuli weenthombe u-Jurgen Schoodeberg badlala indima eqakathekileko ekutloleni ubujamo babasebenzi beplasi lamazambana e-Bethal. I-atikili le yathola ukutjhejwa kwezwe neentjhabatjhaba kodwana, imibiko yalahlwa nguNgqongqotjhe wezeNdabuko, u-Hendrik Frensch Verwoerd ePalamende. Waxoshwa e-Bethal ziimphathimandla ngo-1953 ngebanga lokuzikhakhazisa kwakhe kwezepolotiki. Ngokukhamba kwesikhathi wathuthela [[Eswatini|eSwazini]] lapho asiza khona iphiko lebutho le-ANC uMkhonto we Sizwe . &lt;ref name=&quot;auto&quot;&gt;http://www.sahistory.org.za/people/gert-sibande {{Webarchive|url=https://web.archive.org/web/20130901062545/http://sahistory.org.za/people/gert-sibande|date=2013-09-01}} Accessed 20 July 2017&lt;/ref&gt; Ngo-1959, ngemva kweminyaka elitjhumi nambili uGert Sibande aveze ubujamo bezisebenzi, i -ANC yabika ubujamo obufanako emaplasini wommbila namanye amazambana.   Bekangumhlanganyeli okhutheleko emkhankasweni wokuphikisa, umkhankaso wokulwisana nefundo yamaBantu begodu wasiza nokutlola iTjhatha yeNkululeko . Wasebenza eduze noMphathi u-Albert Luthuli, u-Moses Kotane no -Moses Mabhida .  Bekalilunga lomKhandlu oPhetheko weNarha we- ANC begodu ngesikhathi sakhe soburholi, wasolwa ecaleni lokuvukela umbuso ngo-1956 ukuya ku-1961. Bekangomunye wabasolwa abambalwa abathatha isikhundla sofakazi ngesikhathi secala. Wakhethwa bona abe ngumengameli we-Transvaal ANC ngo-1958 begodu wakhethwa godu ngo-1959. &lt;ref name=&quot;auto1&quot; /&gt; Wahlongakala e [[Eswatini|-Swaziland]] ngo-1987. Wangcwatshwa e -Manzini phakathi ne-Swaziland. 

== Ukutlhoriswa nokuhlongakala ==
Ikululeko ka-Sibande yenza bona kube nokutlhoriswa okukhulu ngurhulumende webandlululo. Ngo-1953, waxoshwa e-Bethal, begodu ngo-1956, wabekwa icala lokuvukela umbuso njengengcenye yecala lokuvukela umbuso elidumileko. Nanyana gade aneentjhijilo, waragela phambili nomsebenzi wakhe ngaphakathi kwe-ANC, wakhethwa njengomongameli we-Transvaal ANC ngo-1958.

Ngemva kwecala lokuvukela umbuso, u-Sibande wakateleleka bona ahlale e -Komatipoort eduze nomngcele we- [[Eswatini|Swaziland]] ne [[Mozambique|-Mozambique]] . Ngo-1962, wawela waya e-Swaziland begodu ngokukhamba kwesikhathi wathenga itrektara wayisebenzisela ukunikela ngeenkonzo zokulima e-Swaziland, lapho ahlala khona iminyaka eminengi ahlala ekudingisweni. Wahlongakala ngo-1987, e -Manzini, e-Swazini.

Umasipala wesiyingi watjhugulula ibizo lakhe ukusuka ku-&quot;Eastvaal&quot; (Afrikaans: Oosvaal) waya ku-&quot;Gert Sibande&quot; uMasipala wesiFunda ngoNobayeni ka-2004.  Kune-Gert Sibande TVET College eneendawo ezihlukahlukeneko zekhampasi.   Kunesithombe sethusi saka-Gert Sibande esiqala esinye isithombe saka- [[Nokuthula Simelane]] e -Bethal . Iinthombe zingaphandle kwe-Nomoya Masilela Museum enikelwe abalweli bekululeko abafakahlangana u-Gert Sibande, u-Nokuthula Simelane, u-Ruth First no -Henry Nxumalo .   UMbongeni Ngema watlola begodu waqondisa umkhiqizo wesigaba sesabelomali sezigidi ezingama-R22 'Ibhubezi leMpumalanga' ebegade uhlanganiswe ngokuduba amazambana neminikelo ka-Gert Sibande. Umkhiqizo lo bewuneenkhundla e- Trinidad, e-Jamaica ne -Suriname . Umndeni ka-Sibande ukhuphe umthetho wokukhandela ukukhiqiza umvumo lo ngombana bathi akhenge bakhulumisane nabo. Ukuvinjelwa kwabekwa eceleni msinyana ngaphambi kokukhutjhwa komkhiqizo.

== Iinkomba ==
{{reflist}}
[[Category:Bantu]]
[[Category:Sewula Afrika]]</text>
      <sha1>bj47ok5jwrdeq1ooxffzcc7tjfibhud</sha1>
    </revision>
    <revision>
      <id>6388</id>
      <parentid>6387</parentid>
      <timestamp>2026-04-02T00:33:29Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6388</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7282" sha1="cj2gyntoe808cs1f4b3gbs5gghbx1k3" xml:space="preserve">
'''U-Gert Shedrack Sibande''' (1901 eduze ne-Ermelo, e-Mpumalanga – 1987; owaziwa nangokuthi yi '''-Lion of the East'''  ) bekayisisebenzi seplasini seSewula Afrika begodu bekasolo alwisana nebandlululo. Bekangomunye wabasolwa be -ANC ukujamela icala lokuvukela umbuso ngo-1956-61 kanye no [[Nelson Mandela|-Nelson Mandela]] nabanye abali-154. &lt;ref&gt;{{Cite web|url=http://www.sahistory.org.za/pages/people/bios/sibande,g.htm|title=Gert Sibande|access-date=2011-05-07|archive-url=https://web.archive.org/web/20090108042303/http://www.sahistory.org.za/pages/people/bios/sibande,g.htm|archive-date=2009-01-08|url-status=dead}}&lt;/ref&gt;

USibande wadlala indima eqakathekileko e-Potato Boycott yango-1959.[1]

Isifunda se -Gert Sibande esifundazweni se [[Isifunda seMpumalanga|-Mpumalanga]] eSewula Afrika siqanjwe ngegama lakhe. Wabelethelwa esifundeni begodu wachitha isikhathi esinengi sepilo yakhe lapho.

Ngemva kokuhlongakala kwakhe wanikelwe i-Order of Luthuli in Gold ngegalelo lakhe elihle khulu ekwenzeni ngcono ubujamo bokusebenza kwabasebenzi beplasi kanye nemizamo yakhe yokuthuthukisa iSewula Afrika engabandlululi ngokobuhlanga, enobulungiswa, nentando yenengi.&lt;ref&gt;{{Cite web|url=https://www.polity.org.za/article/anc-zuma-address-delivered-at-the-gert-sibande-memorial-lecture-23092008-2008-09-23|title=ANC: Zuma: Address delivered at the Gert Sibande Memorial Lecture (23/09/2008)|website=www.polity.org.za}}&lt;/ref&gt;

== Ipilo yokuthoma nomsebenzi ==
Wabelethwa ngo-1901 esifundeni se-Ermelo se- Eastern Transvaal yangaleso sikhathi (manje [[Isifunda seMpumalanga|i-Mpumalanga]] ), u-Sibande bekayindodana yomlimi oqatjhileko. Wathoma ukusebenza emaplasini aneminyaka ebunane, lapho aqalana khona nobujamo obubudisi. Ekuthomeni bekaziwa ngokuthi ngu-Shadrack Sibande, waphiwa ibizo elithi &quot;Gert&quot; mBhunu owavimbela ukusetjenziswa kwamabizo wesiNgisi eplasini lakhe. Iminyaka engaphezu kwama-20, u-Sibande wasebenza emaplasini ahlukahlukeneko e-Eastern Transvaal. Ukungafuni kwakhe ukwamukela ubujamo obumbi bokusebenza kwamenza waba nedumela lokuba mraro hlangana nabaqatjhi bakhe, njengombana bekavame ukubaphikisa ngeendaba zokuhlukunyezwa.

== Ukukhuthaza abasebenzi beplasi ==
Ngabo-1930, u-Sibande wathuthela e- [[Bethal]] Location, lapho athoma khona ukuhlela abasebenzi beplasi begodu alungisa iinkhalazo zabo. Ngesikhathi lesi, abasebenzi abanengi beplasini bebaqalene nobujamo obumbi khulu bokusebenza, basebenza kusukela ekuphumeni kwelanga ukuya ekutjhingeni kwelanga babhadelwa imali encani, begodu kanengi badla ukudla okuncani okufana ne-phuthu ne-gravy emasakeni. USibande wasiza ukusungula ihlangano yokuthoma eyaziwako yamalungelo wabasebenzi beplasini eSewula Afrika, i-Farm Workers' Association. Isiqhema lesi sisebenzele ukusiza abasebenzi beplasi bona bathole iintjalo ezibiweko begodu bathole ubujamo obungcono bokusebenza. Ngo-1939, u-Sibande wahlangana namalunga we- African National Congress (ANC) e [[Johannesburg|-Goli]] . Msinyana waba lilunga elisebenzako, wabuyela e-Bethal ukuyokwakha igatja eliqinileko le-ANC. Imizamo yakhe yenza bona kube nokutjheja okukhulu ngeemeko ezimbi abasebenzi beplasi ebebaqalene nazo, begodu wasiza ukuveza ukungabi nobulungiswa lokhu ebantwini abanengi, okufakahlangana abantu abadumileko abafana nomfundisi u-Michael Scott nentatheli u-Ruth First .&lt;ref&gt;Christopher Webb (2015) Fighting talk: Ruth First's early journalism 1947–1950, Review of African Political Economy, 42:143, 7-21, DOI:10.1080/03056244.2014.988697 Accessed 19 July 2017&lt;/ref&gt;

U-Sibande wasebenzisana no- Henry Nxumalo odumileko wemagazini ye-Drum, asiza ekugadangisweni kwama-atikili aveza ubujamo bokuxhaphaza kwabasebenzi beplasini ephasini. Iindaba ezitholweko zavezwa ku- ''New Age'' . ''I-Guardian'' yakhipha i-atikili yesibili ehlobene nokutholwe ngu-Gert Sibande mhlazi-25 kuNobayeni 1947.  ''I-Drum Magazine'' yakhipha i-atikili efanako ngo-1952, intathelizindaba u-[[Henry Nxumalo]] nomthwebuli weenthombe u-Jurgen Schoodeberg badlala indima eqakathekileko ekutloleni ubujamo babasebenzi beplasi lamazambana e-Bethal. I-atikili le yathola ukutjhejwa kwezwe neentjhabatjhaba kodwana, imibiko yalahlwa nguNgqongqotjhe wezeNdabuko, u-Hendrik Frensch Verwoerd ePalamende. Waxoshwa e-Bethal ziimphathimandla ngo-1953 ngebanga lokuzikhakhazisa kwakhe kwezepolotiki. Ngokukhamba kwesikhathi wathuthela [[Eswatini|eSwazini]] lapho asiza khona iphiko lebutho le-ANC uMkhonto we Sizwe . &lt;ref name=&quot;auto&quot;&gt;http://www.sahistory.org.za/people/gert-sibande {{Webarchive|url=https://web.archive.org/web/20130901062545/http://sahistory.org.za/people/gert-sibande|date=2013-09-01}} Accessed 20 July 2017&lt;/ref&gt; Ngo-1959, ngemva kweminyaka elitjhumi nambili uGert Sibande aveze ubujamo bezisebenzi, i -ANC yabika ubujamo obufanako emaplasini wommbila namanye amazambana.   Bekangumhlanganyeli okhutheleko emkhankasweni wokuphikisa, umkhankaso wokulwisana nefundo yamaBantu begodu wasiza nokutlola iTjhatha yeNkululeko . Wasebenza eduze noMphathi u-Albert Luthuli, u-Moses Kotane no -Moses Mabhida .  Bekalilunga lomKhandlu oPhetheko weNarha we- ANC begodu ngesikhathi sakhe soburholi, wasolwa ecaleni lokuvukela umbuso ngo-1956 ukuya ku-1961. Bekangomunye wabasolwa abambalwa abathatha isikhundla sofakazi ngesikhathi secala. Wakhethwa bona abe ngumengameli we-Transvaal ANC ngo-1958 begodu wakhethwa godu ngo-1959. &lt;ref name=&quot;auto1&quot; /&gt; Wahlongakala e [[Eswatini|-Swaziland]] ngo-1987. Wangcwatshwa e -Manzini phakathi ne-Swaziland. 

== Ukutlhoriswa nokuhlongakala ==
Ikululeko ka-Sibande yenza bona kube nokutlhoriswa okukhulu ngurhulumende webandlululo. Ngo-1953, waxoshwa e-Bethal, begodu ngo-1956, wabekwa icala lokuvukela umbuso njengengcenye yecala lokuvukela umbuso elidumileko. Nanyana gade aneentjhijilo, waragela phambili nomsebenzi wakhe ngaphakathi kwe-ANC, wakhethwa njengomongameli we-Transvaal ANC ngo-1958.

Ngemva kwecala lokuvukela umbuso, u-Sibande wakateleleka bona ahlale e -Komatipoort eduze nomngcele we- [[Eswatini|Swaziland]] ne [[Mozambique|-Mozambique]] . Ngo-1962, wawela waya e-Swaziland begodu ngokukhamba kwesikhathi wathenga itrektara wayisebenzisela ukunikela ngeenkonzo zokulima e-Swaziland, lapho ahlala khona iminyaka eminengi ahlala ekudingisweni. Wahlongakala ngo-1987, e -Manzini, e-Swazini.

Umasipala wesiyingi watjhugulula ibizo lakhe ukusuka ku-&quot;Eastvaal&quot; (Afrikaans: Oosvaal) waya ku-&quot;Gert Sibande&quot; uMasipala wesiFunda ngoNobayeni ka-2004.  Kune-Gert Sibande TVET College eneendawo ezihlukahlukeneko zekhampasi.   Kunesithombe sethusi saka-Gert Sibande esiqala esinye isithombe saka- [[Nokuthula Simelane]] e -Bethal . Iinthombe zingaphandle kwe-Nomoya Masilela Museum enikelwe abalweli bekululeko abafakahlangana u-Gert Sibande, u-Nokuthula Simelane, u-Ruth First no -Henry Nxumalo .   UMbongeni Ngema watlola begodu waqondisa umkhiqizo wesigaba sesabelomali sezigidi ezingama-R22 'Ibhubezi leMpumalanga' ebegade uhlanganiswe ngokuduba amazambana neminikelo ka-Gert Sibande. Umkhiqizo lo bewuneenkhundla e- Trinidad, e-Jamaica ne -Suriname . Umndeni ka-Sibande ukhuphe umthetho wokukhandela ukukhiqiza umvumo lo ngombana bathi akhenge bakhulumisane nabo. Ukuvinjelwa kwabekwa eceleni msinyana ngaphambi kokukhutjhwa komkhiqizo.

== Iinkomba ==
{{reflist}}
[[Category:Abantu]]
[[Category:Sewula Afrika]]</text>
      <sha1>cj2gyntoe808cs1f4b3gbs5gghbx1k3</sha1>
    </revision>
    <revision>
      <id>6389</id>
      <parentid>6388</parentid>
      <timestamp>2026-04-02T00:34:31Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6389</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7280" sha1="7w8wwqjwize1sza64dg4j9s4m6dgppf" xml:space="preserve">
'''U-Gert Shedrack Sibande''' (1901 eduze ne-Ermelo, e-Mpumalanga – 1987; owaziwa nangokuthi yi '''-Lion of the East'''  ) bekayisisebenzi seplasini seSewula Afrika begodu bekasolo alwisana nebandlululo. Bekangomunye wabasolwa be -ANC ukujamela icala lokuvukela umbuso ngo-1956-61 kanye no [[Nelson Mandela|-Nelson Mandela]] nabanye abali-154. &lt;ref&gt;{{Cite web|url=http://www.sahistory.org.za/pages/people/bios/sibande,g.htm|title=Gert Sibande|access-date=2011-05-07|archive-url=https://web.archive.org/web/20090108042303/http://www.sahistory.org.za/pages/people/bios/sibande,g.htm|archive-date=2009-01-08|url-status=dead}}&lt;/ref&gt;

USibande wadlala indima eqakathekileko e-Potato Boycott yango-1959.[1]

Isifunda se -Gert Sibande esifundazweni se [[Isifunda seMpumalanga|-Mpumalanga]] eSewula Afrika siqanjwe ngegama lakhe. Wabelethelwa esifundeni begodu wachitha isikhathi esinengi sepilo yakhe lapho.

Ngemva kokuhlongakala kwakhe wanikelwe i-Order of Luthuli in Gold ngegalelo lakhe elihle khulu ekwenzeni ngcono ubujamo bokusebenza kwabasebenzi beplasi kanye nemizamo yakhe yokuthuthukisa iSewula Afrika engabandlululi ngokobuhlanga, enobulungiswa, nentando yenengi.&lt;ref&gt;{{Cite web|url=https://www.polity.org.za/article/anc-zuma-address-delivered-at-the-gert-sibande-memorial-lecture-23092008-2008-09-23|title=ANC: Zuma: Address delivered at the Gert Sibande Memorial Lecture (23/09/2008)|website=www.polity.org.za}}&lt;/ref&gt;

== Ipilo yokuthoma nomsebenzi ==
Wabelethwa ngo-1901 esifundeni se-Ermelo se- Eastern Transvaal yangaleso sikhathi (manje [[Isifunda seMpumalanga|i-Mpumalanga]] ), u-Sibande bekayindodana yomlimi oqatjhileko. Wathoma ukusebenza emaplasini aneminyaka ebunane, lapho aqalana khona nobujamo obubudisi. Ekuthomeni bekaziwa ngokuthi ngu-Shadrack Sibande, waphiwa ibizo elithi &quot;Gert&quot; mBhunu owavimbela ukusetjenziswa kwamabizo wesiNgisi eplasini lakhe. Iminyaka engaphezu kwama-20, u-Sibande wasebenza emaplasini ahlukahlukeneko e-Eastern Transvaal. Ukungafuni kwakhe ukwamukela ubujamo obumbi bokusebenza kwamenza waba nedumela lokuba mraro hlangana nabaqatjhi bakhe, njengombana bekavame ukubaphikisa ngeendaba zokuhlukunyezwa.

== Ukukhuthaza abasebenzi beplasi ==
Ngabo-1930, u-Sibande wathuthela e- [[Bethal]] Location, lapho athoma khona ukuhlela abasebenzi beplasi begodu alungisa iinkhalazo zabo. Ngesikhathi lesi, abasebenzi abanengi beplasini bebaqalene nobujamo obumbi khulu bokusebenza, basebenza kusukela ekuphumeni kwelanga ukuya ekutjhingeni kwelanga babhadelwa imali encani, begodu kanengi badla ukudla okuncani okufana ne-phuthu ne-gravy emasakeni. USibande wasiza ukusungula ihlangano yokuthoma eyaziwako yamalungelo wabasebenzi beplasini eSewula Afrika, i-Farm Workers' Association. Isiqhema lesi sisebenzele ukusiza abasebenzi beplasi bona bathole iintjalo ezibiweko begodu bathole ubujamo obungcono bokusebenza. Ngo-1939, u-Sibande wahlangana namalunga we- African National Congress (ANC) e [[Johannesburg|-Goli]] . Msinyana waba lilunga elisebenzako, wabuyela e-Bethal ukuyokwakha igatja eliqinileko le-ANC. Imizamo yakhe yenza bona kube nokutjheja okukhulu ngeemeko ezimbi abasebenzi beplasi ebebaqalene nazo, begodu wasiza ukuveza ukungabi nobulungiswa lokhu ebantwini abanengi, okufakahlangana abantu abadumileko abafana nomfundisi u-Michael Scott nentatheli u-Ruth First .&lt;ref&gt;Christopher Webb (2015) Fighting talk: Ruth First's early journalism 1947–1950, Review of African Political Economy, 42:143, 7-21, DOI:10.1080/03056244.2014.988697 Accessed 19 July 2017&lt;/ref&gt;

U-Sibande wasebenzisana no- Henry Nxumalo odumileko wemagazini ye-Drum, asiza ekugadangisweni kwama-atikili aveza ubujamo bokuxhaphaza kwabasebenzi beplasini ephasini. Iindaba ezitholweko zavezwa ku- ''New Age'' . ''I-Guardian'' yakhipha i-atikili yesibili ehlobene nokutholwe ngu-Gert Sibande mhlazi-25 kuNobayeni 1947.  ''I-Drum Magazine'' yakhipha i-atikili efanako ngo-1952, intathelizindaba u-[[Henry Nxumalo]] nomthwebuli weenthombe u-Jurgen Schoodeberg badlala indima eqakathekileko ekutloleni ubujamo babasebenzi beplasi lamazambana e-Bethal. I-atikili le yathola ukutjhejwa kwezwe neentjhabatjhaba kodwana, imibiko yalahlwa nguNgqongqotjhe wezeNdabuko, u-Hendrik Frensch Verwoerd ePalamende. Waxoshwa e-Bethal ziimphathimandla ngo-1953 ngebanga lokuzikhakhazisa kwakhe kwezepolotiki. Ngokukhamba kwesikhathi wathuthela [[Eswatini|eSwazini]] lapho asiza khona iphiko lebutho le-ANC uMkhonto we Sizwe . &lt;ref name=&quot;auto&quot;&gt;http://www.sahistory.org.za/people/gert-sibande {{Webarchive|url=https://web.archive.org/web/20130901062545/http://sahistory.org.za/people/gert-sibande|date=2013-09-01}} Accessed 20 July 2017&lt;/ref&gt; Ngo-1959, ngemva kweminyaka elitjhumi nambili uGert Sibande aveze ubujamo bezisebenzi, i -ANC yabika ubujamo obufanako emaplasini wommbila namanye amazambana. Bekangumhlanganyeli okhutheleko emkhankasweni wokuphikisa, umkhankaso wokulwisana nefundo yamaBantu begodu wasiza nokutlola iTjhatha yeNkululeko . Wasebenza eduze noMphathi u-Albert Luthuli, u-Moses Kotane no -Moses Mabhida .  Bekalilunga lomKhandlu oPhetheko weNarha we- ANC begodu ngesikhathi sakhe soburholi, wasolwa ecaleni lokuvukela umbuso ngo-1956 ukuya ku-1961. Bekangomunye wabasolwa abambalwa abathatha isikhundla sofakazi ngesikhathi secala. Wakhethwa bona abe ngumengameli we-Transvaal ANC ngo-1958 begodu wakhethwa godu ngo-1959. &lt;ref name=&quot;auto1&quot; /&gt; Wahlongakala e [[Eswatini|-Swaziland]] ngo-1987. Wangcwatshwa e -Manzini phakathi ne-Swaziland. 

== Ukutlhoriswa nokuhlongakala ==
Ikululeko ka-Sibande yenza bona kube nokutlhoriswa okukhulu ngurhulumende webandlululo. Ngo-1953, waxoshwa e-Bethal, begodu ngo-1956, wabekwa icala lokuvukela umbuso njengengcenye yecala lokuvukela umbuso elidumileko. Nanyana gade aneentjhijilo, waragela phambili nomsebenzi wakhe ngaphakathi kwe-ANC, wakhethwa njengomongameli we-Transvaal ANC ngo-1958.

Ngemva kwecala lokuvukela umbuso, u-Sibande wakateleleka bona ahlale e -Komatipoort eduze nomngcele we- [[Eswatini|Swaziland]] ne [[Mozambique|-Mozambique]] . Ngo-1962, wawela waya e-Swaziland begodu ngokukhamba kwesikhathi wathenga itrektara wayisebenzisela ukunikela ngeenkonzo zokulima e-Swaziland, lapho ahlala khona iminyaka eminengi ahlala ekudingisweni. Wahlongakala ngo-1987, e -Manzini, e-Swazini.

Umasipala wesiyingi watjhugulula ibizo lakhe ukusuka ku-&quot;Eastvaal&quot; (Afrikaans: Oosvaal) waya ku-&quot;Gert Sibande&quot; uMasipala wesiFunda ngoNobayeni ka-2004.  Kune-Gert Sibande TVET College eneendawo ezihlukahlukeneko zekhampasi.   Kunesithombe sethusi saka-Gert Sibande esiqala esinye isithombe saka- [[Nokuthula Simelane]] e -Bethal . Iinthombe zingaphandle kwe-Nomoya Masilela Museum enikelwe abalweli bekululeko abafakahlangana u-Gert Sibande, u-Nokuthula Simelane, u-Ruth First no -Henry Nxumalo .   UMbongeni Ngema watlola begodu waqondisa umkhiqizo wesigaba sesabelomali sezigidi ezingama-R22 'Ibhubezi leMpumalanga' ebegade uhlanganiswe ngokuduba amazambana neminikelo ka-Gert Sibande. Umkhiqizo lo bewuneenkhundla e- Trinidad, e-Jamaica ne -Suriname . Umndeni ka-Sibande ukhuphe umthetho wokukhandela ukukhiqiza umvumo lo ngombana bathi akhenge bakhulumisane nabo. Ukuvinjelwa kwabekwa eceleni msinyana ngaphambi kokukhutjhwa komkhiqizo.

== Iinkomba ==
{{reflist}}
[[Category:Abantu]]
[[Category:Sewula Afrika]]</text>
      <sha1>7w8wwqjwize1sza64dg4j9s4m6dgppf</sha1>
    </revision>
    <revision>
      <id>6390</id>
      <parentid>6389</parentid>
      <timestamp>2026-04-02T00:34:43Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6390</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7264" sha1="lzhpn25dlqhvmflol6sf6y6qxcj79dd" xml:space="preserve">
'''U-Gert Shedrack Sibande''' (1901 eduze ne-Ermelo, e-Mpumalanga – 1987; owaziwa nangokuthi yi '''-Lion of the East'''  ) bekayisisebenzi seplasini seSewula Afrika begodu bekasolo alwisana nebandlululo. Bekangomunye wabasolwa be -ANC ukujamela icala lokuvukela umbuso ngo-1956-61 kanye no [[Nelson Mandela]] nabanye abali-154. &lt;ref&gt;{{Cite web|url=http://www.sahistory.org.za/pages/people/bios/sibande,g.htm|title=Gert Sibande|access-date=2011-05-07|archive-url=https://web.archive.org/web/20090108042303/http://www.sahistory.org.za/pages/people/bios/sibande,g.htm|archive-date=2009-01-08|url-status=dead}}&lt;/ref&gt;

USibande wadlala indima eqakathekileko e-Potato Boycott yango-1959.[1]

Isifunda se -Gert Sibande esifundazweni se [[Isifunda seMpumalanga|-Mpumalanga]] eSewula Afrika siqanjwe ngegama lakhe. Wabelethelwa esifundeni begodu wachitha isikhathi esinengi sepilo yakhe lapho.

Ngemva kokuhlongakala kwakhe wanikelwe i-Order of Luthuli in Gold ngegalelo lakhe elihle khulu ekwenzeni ngcono ubujamo bokusebenza kwabasebenzi beplasi kanye nemizamo yakhe yokuthuthukisa iSewula Afrika engabandlululi ngokobuhlanga, enobulungiswa, nentando yenengi.&lt;ref&gt;{{Cite web|url=https://www.polity.org.za/article/anc-zuma-address-delivered-at-the-gert-sibande-memorial-lecture-23092008-2008-09-23|title=ANC: Zuma: Address delivered at the Gert Sibande Memorial Lecture (23/09/2008)|website=www.polity.org.za}}&lt;/ref&gt;

== Ipilo yokuthoma nomsebenzi ==
Wabelethwa ngo-1901 esifundeni se-Ermelo se- Eastern Transvaal yangaleso sikhathi (manje [[Isifunda seMpumalanga|i-Mpumalanga]] ), u-Sibande bekayindodana yomlimi oqatjhileko. Wathoma ukusebenza emaplasini aneminyaka ebunane, lapho aqalana khona nobujamo obubudisi. Ekuthomeni bekaziwa ngokuthi ngu-Shadrack Sibande, waphiwa ibizo elithi &quot;Gert&quot; mBhunu owavimbela ukusetjenziswa kwamabizo wesiNgisi eplasini lakhe. Iminyaka engaphezu kwama-20, u-Sibande wasebenza emaplasini ahlukahlukeneko e-Eastern Transvaal. Ukungafuni kwakhe ukwamukela ubujamo obumbi bokusebenza kwamenza waba nedumela lokuba mraro hlangana nabaqatjhi bakhe, njengombana bekavame ukubaphikisa ngeendaba zokuhlukunyezwa.

== Ukukhuthaza abasebenzi beplasi ==
Ngabo-1930, u-Sibande wathuthela e- [[Bethal]] Location, lapho athoma khona ukuhlela abasebenzi beplasi begodu alungisa iinkhalazo zabo. Ngesikhathi lesi, abasebenzi abanengi beplasini bebaqalene nobujamo obumbi khulu bokusebenza, basebenza kusukela ekuphumeni kwelanga ukuya ekutjhingeni kwelanga babhadelwa imali encani, begodu kanengi badla ukudla okuncani okufana ne-phuthu ne-gravy emasakeni. USibande wasiza ukusungula ihlangano yokuthoma eyaziwako yamalungelo wabasebenzi beplasini eSewula Afrika, i-Farm Workers' Association. Isiqhema lesi sisebenzele ukusiza abasebenzi beplasi bona bathole iintjalo ezibiweko begodu bathole ubujamo obungcono bokusebenza. Ngo-1939, u-Sibande wahlangana namalunga we- African National Congress (ANC) e [[Johannesburg|-Goli]] . Msinyana waba lilunga elisebenzako, wabuyela e-Bethal ukuyokwakha igatja eliqinileko le-ANC. Imizamo yakhe yenza bona kube nokutjheja okukhulu ngeemeko ezimbi abasebenzi beplasi ebebaqalene nazo, begodu wasiza ukuveza ukungabi nobulungiswa lokhu ebantwini abanengi, okufakahlangana abantu abadumileko abafana nomfundisi u-Michael Scott nentatheli u-Ruth First .&lt;ref&gt;Christopher Webb (2015) Fighting talk: Ruth First's early journalism 1947–1950, Review of African Political Economy, 42:143, 7-21, DOI:10.1080/03056244.2014.988697 Accessed 19 July 2017&lt;/ref&gt;

U-Sibande wasebenzisana no- Henry Nxumalo odumileko wemagazini ye-Drum, asiza ekugadangisweni kwama-atikili aveza ubujamo bokuxhaphaza kwabasebenzi beplasini ephasini. Iindaba ezitholweko zavezwa ku- ''New Age'' . ''I-Guardian'' yakhipha i-atikili yesibili ehlobene nokutholwe ngu-Gert Sibande mhlazi-25 kuNobayeni 1947.  ''I-Drum Magazine'' yakhipha i-atikili efanako ngo-1952, intathelizindaba u-[[Henry Nxumalo]] nomthwebuli weenthombe u-Jurgen Schoodeberg badlala indima eqakathekileko ekutloleni ubujamo babasebenzi beplasi lamazambana e-Bethal. I-atikili le yathola ukutjhejwa kwezwe neentjhabatjhaba kodwana, imibiko yalahlwa nguNgqongqotjhe wezeNdabuko, u-Hendrik Frensch Verwoerd ePalamende. Waxoshwa e-Bethal ziimphathimandla ngo-1953 ngebanga lokuzikhakhazisa kwakhe kwezepolotiki. Ngokukhamba kwesikhathi wathuthela [[Eswatini|eSwazini]] lapho asiza khona iphiko lebutho le-ANC uMkhonto we Sizwe . &lt;ref name=&quot;auto&quot;&gt;http://www.sahistory.org.za/people/gert-sibande {{Webarchive|url=https://web.archive.org/web/20130901062545/http://sahistory.org.za/people/gert-sibande|date=2013-09-01}} Accessed 20 July 2017&lt;/ref&gt; Ngo-1959, ngemva kweminyaka elitjhumi nambili uGert Sibande aveze ubujamo bezisebenzi, i -ANC yabika ubujamo obufanako emaplasini wommbila namanye amazambana. Bekangumhlanganyeli okhutheleko emkhankasweni wokuphikisa, umkhankaso wokulwisana nefundo yamaBantu begodu wasiza nokutlola iTjhatha yeNkululeko . Wasebenza eduze noMphathi u-Albert Luthuli, u-Moses Kotane no -Moses Mabhida .  Bekalilunga lomKhandlu oPhetheko weNarha we- ANC begodu ngesikhathi sakhe soburholi, wasolwa ecaleni lokuvukela umbuso ngo-1956 ukuya ku-1961. Bekangomunye wabasolwa abambalwa abathatha isikhundla sofakazi ngesikhathi secala. Wakhethwa bona abe ngumengameli we-Transvaal ANC ngo-1958 begodu wakhethwa godu ngo-1959. &lt;ref name=&quot;auto1&quot; /&gt; Wahlongakala e [[Eswatini|-Swaziland]] ngo-1987. Wangcwatshwa e -Manzini phakathi ne-Swaziland. 

== Ukutlhoriswa nokuhlongakala ==
Ikululeko ka-Sibande yenza bona kube nokutlhoriswa okukhulu ngurhulumende webandlululo. Ngo-1953, waxoshwa e-Bethal, begodu ngo-1956, wabekwa icala lokuvukela umbuso njengengcenye yecala lokuvukela umbuso elidumileko. Nanyana gade aneentjhijilo, waragela phambili nomsebenzi wakhe ngaphakathi kwe-ANC, wakhethwa njengomongameli we-Transvaal ANC ngo-1958.

Ngemva kwecala lokuvukela umbuso, u-Sibande wakateleleka bona ahlale e -Komatipoort eduze nomngcele we- [[Eswatini|Swaziland]] ne [[Mozambique|-Mozambique]] . Ngo-1962, wawela waya e-Swaziland begodu ngokukhamba kwesikhathi wathenga itrektara wayisebenzisela ukunikela ngeenkonzo zokulima e-Swaziland, lapho ahlala khona iminyaka eminengi ahlala ekudingisweni. Wahlongakala ngo-1987, e -Manzini, e-Swazini.

Umasipala wesiyingi watjhugulula ibizo lakhe ukusuka ku-&quot;Eastvaal&quot; (Afrikaans: Oosvaal) waya ku-&quot;Gert Sibande&quot; uMasipala wesiFunda ngoNobayeni ka-2004.  Kune-Gert Sibande TVET College eneendawo ezihlukahlukeneko zekhampasi.   Kunesithombe sethusi saka-Gert Sibande esiqala esinye isithombe saka- [[Nokuthula Simelane]] e -Bethal . Iinthombe zingaphandle kwe-Nomoya Masilela Museum enikelwe abalweli bekululeko abafakahlangana u-Gert Sibande, u-Nokuthula Simelane, u-Ruth First no -Henry Nxumalo .   UMbongeni Ngema watlola begodu waqondisa umkhiqizo wesigaba sesabelomali sezigidi ezingama-R22 'Ibhubezi leMpumalanga' ebegade uhlanganiswe ngokuduba amazambana neminikelo ka-Gert Sibande. Umkhiqizo lo bewuneenkhundla e- Trinidad, e-Jamaica ne -Suriname . Umndeni ka-Sibande ukhuphe umthetho wokukhandela ukukhiqiza umvumo lo ngombana bathi akhenge bakhulumisane nabo. Ukuvinjelwa kwabekwa eceleni msinyana ngaphambi kokukhutjhwa komkhiqizo.

== Iinkomba ==
{{reflist}}
[[Category:Abantu]]
[[Category:Sewula Afrika]]</text>
      <sha1>lzhpn25dlqhvmflol6sf6y6qxcj79dd</sha1>
    </revision>
  </page>
  <page>
    <title>Ijima lokuphikisa</title>
    <ns>0</ns>
    <id>1085</id>
    <revision>
      <id>6392</id>
      <timestamp>2026-04-02T00:43:37Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1345309354|Defiance Campaign]]&quot;</comment>
      <origin>6392</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7534" sha1="ormncnxv12qvctg3zx77yr6dwtdcfdr" xml:space="preserve">
'''Ijima lokuphikisana nemithetho engakalungi''' lethulwa yi- African National Congress (ANC) emhlanganweni owabanjelwa e- Bloemfontein, eSewula Afrika, ngoNobayeni wee -1951 . &lt;ref&gt;{{cite book|last=Lodge|first=Tom|title=Black Politics in South Africa since 1945|year=1983|publisher=Longman|location=London and New York|isbn=0-582-64327-9|pages=39}}&lt;/ref&gt; Ijima lalinemirabhu yezehlakalo ezidosa phambili emhlanganweni. Imitjhagalo, eyenzeka ngo-1952, bekuyimitjhagalo yokuthoma &quot;ekulu, yokuhlangana kwezepolotiki yeentjhaba ezinengi ukujamelana nemithetho yebandlululo ngaphasi koburholi obufanako&quot;. &lt;ref name=&quot;:1&quot;&gt;{{Cite web|url=http://overcomingapartheid.msu.edu/multimedia.php?id=65-259-9|title=The Defiance Campaign|website=South Africa: Overcoming Apartheid Building Democracy|access-date=3 September 2016|archive-url=https://web.archive.org/web/20161201155811/http://overcomingapartheid.msu.edu/multimedia.php?id=65-259-9|archive-date=1 December 2016|url-status=dead}}&lt;/ref&gt;

== Isendlalelo ==
Ngo-1948, i -National Party (NP) yathumba ikhetho eSewula Afrika begodu yathoma ukubeka amagadango wobandlululo ebantwini abaNzima, ama-Indiya nanyana ngibaphi abantu beentjhaba ezihlangeneko. &lt;ref name=&quot;:0&quot;&gt;{{Cite web|url=http://www.sahistory.org.za/topic/national-party-np|title=National Party (NP)|date=30 March 2011|website=South African History Online|access-date=3 September 2016}}&lt;/ref&gt; I-NP yakhawulela amandla wepolotiki ebantwini abamhlophe kwaphela begodu yabela iindawo zeSewula Afrika eentjhabeni ezihlukahlukeneko zabantu.  Abasebenzi, amalunga weenyunyana zabasebenzi nabanye bakhuluma mhlazi-6 kuNobayeni 1949 baphikisana namagadango webandlululo begodu bathoma ukukhuluma ngesiteleka sepolotiki esingenzeka. &lt;ref name=&quot;:0&quot; /&gt; NgoNobayeni walowo mnyaka, abadosiphambili be-African National Congress Youth League (ANCYL), abafana no- [[Nelson Mandela]], u-Walter Sisulu no -Oliver Tambo, bathatha amandla. &lt;ref name=&quot;:0&quot; /&gt; I -African National Congress (ANC) nayo &quot;yamukela iHlelo lokuSebenza&quot; mhlana ali-17 kuNobayeni, ebegade ikhuthaza indlela yokulwa khulu yokutjhikijela ibandlululo. &lt;ref name=&quot;:0&quot; /&gt;

Ngo-1950, i-ANC yathoma ukukhuthaza ukutjhatjalaliswa, izenzo zabantu abanengi, ukuduba, ukuteleka kanye nezenzo zokungalaleli umphakathi. Ngalesisikhathi, abantu abanzima abayi-8,000 babotjhwa &quot;ngebanga lokweqa imithetho nemithetho yebandlululo&quot;.  I -South African Indian Congress (i-SAIC) yasebenza ngokubambisana ne-ANC.  I-NP isebenzise umThetho wokuTloliswa kwabantu ukuqinisekisa bona abantu bahlukaniswa unomphela ngokobuhlanga begodu bavunyelwe ukuhlala eendaweni ezivezwe mThetho weeNdawo zeQembu kwaphela. &lt;ref name=&quot;:0&quot; /&gt; Mhlana amalanga ama-26 kuMgwengweni wee-1950, kwaba neLanga leNarha lokuTjhikisela.  I-ANC ibawe bona abantu bangayi emsebenzini njengesenzo sokutjhikijela. [ 7 ] Ngebanga lomtjhikijelo, abantu abanengi balahlekelwa misebenzi begodu i-ANC yasungula isikhwama sokubasiza.&lt;ref&gt;{{Cite web|url=http://nvdatabase.swarthmore.edu/content/south-africans-disobey-apartheid-laws-defiance-unjust-laws-campaign-1952-1953|title=South Africans disobey apartheid laws (Defiance of Unjust Laws Campaign), 1952-1953|last=Phalen|first=Anthony|date=11 June 2009|website=Global Nonviolent Action Database|access-date=3 September 2016}}&lt;/ref&gt;

== Ikhankaso ==
Ijima lokuPhikisela lathonywa mhlazi-26 kuMgwengweni wee-1952, ilanga elaba lilanga leNarha lokuTjhikisela nokuLila.  Amapholisa weSewula Afrika atjelwa ngesenzo lesi begodu bekahlomile begodu alungiselelwe.  Emadorobheni amakhulu weSewula Afrika, abantu neenhlangano benza izenzo zokudelela nokungalaleli komphakathi.  Imitjhagalo beyinganabudlova khulu ebantwini abahlanganyeleko, inengi labo beligqoke amabhande wemibala emithathu atjengisa i-ANC.  Amavolontiya amnyama atjhisa iincwadi zawo zokuphasisa .  Amanye amavolontiya anzima bekazokuya eendaweni ebegade zithathwa &quot;njengabamhlophe kwaphela,&quot; ebegade kuphikisana nomthetho. Amavolontiya la abotjhwa, begodu ukubotjhwa okunengi (abantu abangaphezu kwe-2,000) kwenziwa ngoMgwengweni wee-1952. &lt;ref&gt;{{Cite journal|last=Herbstein|first=Denis|date=September 1994|title=The Exile Returns|url=http://search.ebscohost.com/login.aspx?direct=true&amp;db=f5h&amp;AN=9410282265&amp;site=ehost-live|journal=Africa Report|volume=39|issue=5|page=78|access-date=7 September 2016|url-access=subscription|via=EBSCOhost}}&lt;/ref&gt; Lokha ababhikishi nababotjhwako, bebangazivikeli emthethwandaba, &quot;okudosela ekuboshweni okukhulu&quot;. &lt;ref name=&quot;:2&quot; /&gt; Abanye ebegade banikelwa iinhlawulo njengenye indlela yokuya ejele.  Ukubotjhwa kwabantu abanengi, bekuthenjwa bona kuzokugandelela urhulumende. &lt;ref name=&quot;:5&quot; /&gt;

Urhulumende weSewula Afrika wabiza ukutjharagana njengezenzo zokungabi nombuso, ubukhomanisi nokuhlangahlangana. [ 13 ] Iphephandaba le-Nationalist, i- ''Oosterlig'', latlola bona ababhikishi &quot;bathola ijele liyindawo emnandi yokuhlala. Abantu laba bazwisisa ukutjhwaba kwaphela.&quot;  Amapholisa bekavame ukusebenzisa iintonga ukugandelela ababhikishi bona bazithobe. &lt;ref name=&quot;:4&quot; /&gt; Mhlana amalanga ali-9 kuNobayeni 1952, amapholisa adubula isiqhema sababhikishi abanzima e -Kimberley babulala abali-14 balimaza abali-39.  Eminye imiyalo yokudubula ababhikishi &quot;nababonakalako&quot; yakhutjhwa nguNgqongqotjhe wezobulungiswa weSewula Afrika, u-Charles Swart .  Ukubotjhwa kwababhikishi abanokuthula &quot;kwanyanyisa ingcenye yemibono yomphakathi omhlophe&quot;. &lt;ref name=&quot;:4&quot; /&gt; NgoJulayi 1952, kwaba nokuhlaselwa kwamahhovisi we-ANC ne-SAIC. 

Njengomphumela wokutjhikijela, i-NP yathoma &quot;ukubeka iinhlawulo eziqinileko zokutjhikijela imithetho ebandlululako&quot; bese yenza umThetho wokuPhepha komPhakathi .  Imigomo yeKhankaso yokuPhikisa azange ifezekiswe, kodwana imitjhagalo &quot;yatjengisa ukuphikiswa okukhulu nokukhulako kwebandlululo&quot;. &lt;ref name=&quot;:1&quot; /&gt; I -United Nations yatjheja begodu yabiza umthethomgomo webandlululo &quot;ngokusongela ukuthula&quot;. 

Phakathi kukaRhoboyi wee-1953, uMphathi u-Albert Luthuli, uMengameli-Jikelele we-ANC, wamemezela bona iJima lokuPhikisa lizakumiswa ukwenzela bona amaqembu wokujamelana akghone ukuhlela kabutjha ngokucabangela ubujamo bezepolotiki obutjha eSewula Afrika. &lt;ref&gt;{{Cite web|url=http://www.sahistory.org.za/topic/defiance-campaign-1952|title=Defiance Campaign 1952 &amp;#124; South African History Online}}&lt;/ref&gt;

AmaKhankaso wokuTjhiya, kufaka hlangana ukutjhiya amabhasi eSewula Afrika, asebenza njengokugqugquzela abalweli bamalungelo wobuntu e- [[The United States|United States]] .  U-Albert Luthuli wagwetjwa icala lokuvukela umbuso, wahlukunyezwa begodu wasuswa esikhundleni sakhe sobukhosi besizwe sakhe samaZulu .  U-Mandela wathatha i-ANC ngemva kwaka-Luthuli. 

Ibandlululo lapheliswa ekuthomeni kwabo-1990, njengombana kwatshwaywa likhetho jikelele leSewula Afrika lango-1994, ikhetho lokuthoma leSewula Afrika elenziwa kusetjenziswa ilungelo lokuvowuda labantu abadala.

== Ijima lokuphikisa e-Port Elizabeth ==
I- Red Location ngelinye lamalokishi amadala khulu wabantu abanzima e -Port Elizabeth, e -Nelson Mandela Bay, [[Isewula Afrika|eSewula Afrika]] . Ibizo layo lithathwe eqoqweni lezakhiwo zensimbi, ezinombala obomvu khulu.  Indawo ebomvu beyizele khulu begodu ingasi sebujameni obuhle. 

Mhlana amalanga ama-26 kuNobayeni wee-1952, u-Florence Matomela wahlanganyela nabanye abanengi emkhankasweni wokulwisana nemithetho ye-Apartheid e- New Brighton Railway Station ebegade ifaka hlangana u-Govan Mbeki, u-Raymond Mhlaba no -Vuyisile Mini namanye amadoda. Bekamunye wabafazi bokuthoma ababotjhwako.


[[Mkhakha:Pages with unreviewed translations]]</text>
      <sha1>ormncnxv12qvctg3zx77yr6dwtdcfdr</sha1>
    </revision>
  </page>
  <page>
    <title>Amalungelo wobuntu eSewula Afrika</title>
    <ns>0</ns>
    <id>1086</id>
    <revision>
      <id>6394</id>
      <timestamp>2026-04-07T10:11:24Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1336161727|Human rights in South Africa]]&quot;</comment>
      <origin>6394</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="16336" sha1="p2op323l0tcox8yxd34u111ify93ds9" xml:space="preserve">'''Amalungelo wobuntu eSewula Afrika''' avikelwe ngaphasi komthethosisekelo.Umbiko wamaLungelo woBuntu wango-1998 ka-Myles Nadioo waveza bona urhulumende uhlonipha amalungelo wezakhamuzi,nanyana kunjalo bekunokutshwenyeka malungana nokusetjenziswa kwamandla ngabasebenzi bomthetho,ukuthatha amagadango womthetho,nokubandlululwa.Ikhomitjhini yamaLungelo woBuntu igunyazwe mThethosisekelo weSewula Afrika kanye nomThetho weKhomitjhini yamaLungelo woBuntu ka-1994, ukutjheja,kokubili ngokuzikhandla nangeenkhalazo ezilethwa phambi kwayo,ukwephulwa kwamalungelo wobuntu nokufuna ukulungiswa kokwephulwa okunjalo.Godu inendima yokufundisa.

== Isikhathi sebandlululo ==
Ibandlululo bekulihlelo lokuhlukanisa nokubandlulula ebegade lisetjenziswa babantu abancani abamhlophe ngokujamelana nenengi labantu abanzima.Ukwenza isibonelo,abantu abanzima bebangakavunyelwa ukuthenga inarha ngaphandle kweendawo ezibekelwe inarha nanyana bebabantu bomdabu.  Imithetho eminengi yeSewula Afrika elwisana nebandlululo yenziwa ngesikhathi kugcinwa engqondweni bona lokho okubonwa mphakathi weentjhabatjhaba,iinhlangano zamalungelo wobuntu,kunye nenengi labantu abanzima enarheni njengokungabi nobulungiswa kwezehlalakuhle nezomthetho okuhlobene nebandlululo,nomlayezo wayo wokulwisana nebandlululo udunyiswe njengobuso obuhle besitjhaba se-Sub-Saharan.

== Amalungelo wefundo ==
Urhulumende weSewula Afrika wenze umthetho wefundo elinganako enarheni yoke.Umthetho lo ufakahlangana i-White Paper on Education and Training 1995 kunye ne-South African Schools Act, Act 84 of 1996.Nanyana kunjalo,kube neendaba ekuphumeleliseni imithetho le,begodu ngokuya kombiko we-2020 we-Amnesty International,iSewula Afrika inehlelo elingakalingani khulu ephasini,elinamaphuzu wokuhlolwa ama-20% weenkolo eziphezulu kunye nama-80% aseleko.Urhulumende weSewula Afrika uvame ukutjheja khulu ikhwalithi yefundo ephakemeko.Ukungezelela,akukho ukuhlanganiswa okukhulu ngokobuhlanga eenkolweni zombuso.Nanyana imithetho ivumela ukuhlanganiswa,iinkolo ezinengi zihlala ziyihlanga eyodwa.Ngokukhuthazako,inani labafundi abaqeda ibanga le-12 likhuphuke khulu eminyakeni esanda kwedlula,lisukela eengidini ezi-3.7 zamaSewula Afrika aneminyaka eli-15 nangaphezulu ngo-1996 ukuya eengidini ezili-11.6 ngo-2016.

=== Iimfunda zemakhaya ===
Inengi lefundo eSewula Afrika linikelwa zikolo zemakhaya. Kuhlekuhle,pheze ama-79% wabantu abanzima beSewula Afrika bahlala emiphakathini yemakhaya.Nanyana kunjalo, urhulumende unganaki ikhwalithi yefundo eendaweni ezisemakhaya.Iindaba eziphathelene neenkolo zemakhaya zifaka hlangana:iinsetjenziswa ezimbi,ukutlhayela kwamanzi ahlanzekileko,ukutlhayela kweensetjenziswa,kunye nabotitjhere abanganamandla.Nakuqalwa iinsetjenziswa ezimbi,ezinye iinkolo azizinzile begodu zisengozini yokubhidlika,ezinye iinkolo zitlhoga igezi.Inengi leenkolo ezinabantwana abangaphezu kwama-500 azinawo amathoyilethi afaneleko,kuthi ezinye iinkolo azinawo amathoyilethi.Ukudlula lapho,iinkolo ezinengi zemakhaya ziseendaweni ezikude ezinganawo amanzi ahlanzekileko. Amanzi avamise ukuba kude ngamakhilomitha begodu angasilapheleko ngombana iinlwana zigeza begodu zisele kiwo.Ukutlhogeka kwamanzi lokhu kuyindaba ethileko emini lokha amazinga womtjhiso aphezulu khulu.Ukuba kude kweenkolo zemakhaya nakho kuyikinga ethileko ngombana zikude khulu namakhaya wabafundi.Begodu,iinkolo ezinengi azilungisi indaba le ngeenthuthi.Phezu kwalokho,iinkolo ezinengi azinazo iincwadi ezitlhogekako nezinto zokufunda.  NgoMgwengweni 2010,iGazethi kaRhulumende yabona bona iindawo zokufunda ezingakalungi zikhuphula amazinga wokuphutha kwabotitjhere kunye namazinga wokuphuma esikolweni wabafundi.Abanye abafundi abanakho ukudla okwaneleko begodu balambile ngesikhathi sesikolo.Indlala le ibangela ukutlhayela kokudzimelela begodu yenza iindawo zokufunda zingabi zihle.

=== Amalungelo wabantwana abakhubazekileko ===
Nanyana iSewula Afrika yavuma iSivumelwano samaLungelo waBantu abaKhubazekileko ngo-2007,abantwana abakhubazekileko abakakwazi ukuthola ifundo ngokulinganako.Ebujameni obunengi, isikolo sombuso singaqunta bona ngibaphi abafundi abangatlolisa,begodu isikolo singalahla umntwana okhubazekileko ngaphandle kwemiphumela.Ebujameni lapho umfundi angabhalisa khona esikolweni somphakathi,isikolo singatlhoga iinsetjenziswa ezitlhogekako zokufundisa abantwana abakhubazekileko kuhle.Ukungezelela,abantwana abakhubazekileko eenkolweni zombuso bakateleleka bona babhadele iimali—ezifana nomsizi—abanye abafundi abangatlhogeki bona bazibhadele.ISewula Afrika ineenkolo ezitlhogomela abafundi abakhubazekileko,kodwana iinkolo lezi zilinganiselwe ngenani begodu zitlhoga bona kubhadelwe imali.Inani elilinganiselweko leenkolo likatelela abantwana bona bakhwele namkha basebenzise iinthuthi ezibizako. Ngomnyaka ka-2000,iKomidi yamaLungelo waBantwana ye-UN beyitshwenyeke khulu ngokutlhogeka kokusetjenziswa kwesivumelwano seSewula Afrika sokuqinisekisa ifundo yamabanga aphasi yasimahla.ISewula Afrika isazabalaza ukunikela ngefundo yamabanga aphasi yasimahla kibo boke abantu.Ukungezelela,abafundi abanengi abakhubazekileko abakghoni ukuthola ifundo esezingeni eliphezulu ngombana basehlwini lokulinda eenkolweni ezitlhogomela abafundi abaneemfuno ezikhethekileko.Ukwenza isibonelo,ngo-2015, bekunabantwana abangaba yi-5,552 abakhubazekileko erhelweni lokulinda.

== Amalungelo wepolotiki ==
[[Isewula Afrika|ISewula Afrika]] inomthethosisekelo okhululekileko ovikela zoke iinkululeko zepolotiki eziqakathekileko.Nanyana kunjalo,kube nezehlakalo ezinengi zokugandelela kwezepolotiki kunye nokusongelwa kokugandeleleka kwesikhathi esizako ngokuphula umthethosisekelo lo okwenza abanye abahlaziyi neenhlangano zomphakathi baphethe ngokuthi kunesimo esitjha sokugandelela kwezepolotiki namkha ukwehla kokubekezelelana kwezepolotiki.

Ukusekelwa kwezepolotiki yinto eqakathekileko kwezepolotiki yeSewula Afrika.Kodwana,ukusekelwa lokhu kwephula amalungelo wabantu,khulukhulu labo abatlhagako.Ama-40% wabantu beSewula Afrika bathembele embusweni bona ubanikele izinto ezitlhogekako.Ukuthembela embusweni lokhu kunciphisa ukuzijamela kwabantu beSewula Afrika abatlhoga isizo leli.Iimfuneko lezi zinikelwa ngendlela yezibonelelo,ezitlhoga amadokhumende karhulumende ukuzifumana.Ngalokho-ke,ubuphathi budlala indima ekulu emandleni womuntu wokuthola isibonelelo begodu ngaleyo ndlela athole izinto ezitlhogekako.Abezombusazwe bathola abathatha indawo yabo ngokuya ngeenthembiso eziphathekako.Nangabe abosopolotiki bazalisekisa iinthembiso lezi,kanengi abamukelwako ngilabo abasekela abosopolotiki kwaphela.Ngokuqakatheke khulu,ukuthembela kwabavowudi embusweni kuvimbela ikghono labo lokuvowuda ngokuya ngemibono.Isimanga lesi asikhambisani nemigomo yentando yenengi yeSewula Afrika.

== Ihlalakuhle ==
Kusukela ngo-2021,pheze ama-30% wabantu beSewula Afrika (18 yezigidi ebantwini beenarha abaziingidi ezima-60) bathole isibonelelo sikaRhulumende.Inani leli lakhula khulu ngesikhathi sengogwane lekhovidi ;ngoSewula wee-2020, abantu abangaphezu kwama-70% beSewula Afrika bebahlala emzini othola isekelo likaRhulumende.

I-1997 &quot;Iphepha elimhlophe lezehlalakuhle&quot; liveza umthethomgomo wezehlalakuhle weSewula Afrika.Iphepha elimhlophe lezehlalakuhle lidzimelele ekunikeleni amaSewula Afrika amathuba wokuzijamela okukhulu.Ukwenza isibonelo, iPhepha elimhlophe lezehlalakuhle libeka ukuhlinzekwa kwamaphrojekthi wemisebenzi yomphakathi.Iphepha elimhlophe libuye ligandelele ukuqakatheka kweenhlangano ezingekho embusweni zehlalakuhle ekunikeleni ngehlalakuhle.Iinhlangano ezinjalo zifaka hlangana iinhlangano ezingasizo zikaRhulumende (ama-NGO) kunye neenhlangano zekolo.Phezu kwalokho,iPhepha elimhlophe lidzimelele ekutheni urhulumende anikele ngehlalakahle khulukhulu emindenini.Kodwana,iPhepha elimhlophe linemibandela embalwa ebantwini abadala.Urhulumende ulindele bona imindeni ithathe umthwalo wokutlhogomela iinhlobo zayo ezikhulileko,ngokwengcenye ngebanga lamasiko.Iphepha elimhlophe labuye lahlanganisa iimali zokusekelwa kwabantwana begodu lalisa ukucabanga okungakalungi malungana nendima yobulili emndenini. Ukwenza isibonelo,i-White Paper azange ikhulume ngomuntu omduna ekhaya &quot;njengomuntu ozondlako&quot;.Ukungalingani ngokobuhlanga emadorobheni weSewula Afrika kusesekhona,nanyana inarha sele iqede ibandlululo.Inengi labantu abanzima beSewula Afrika basatshwenyeka ngokufumana iintlhogo ezifana nezindlu,bahlala emalokitjhini angatlhogonyelwa kuhle.Ngokuphikisako,abantu abanengi beSewula Afrika abamhlophe abahlala emadorobheni bahlala emiphakathini evaliweko eneenvikeleko ezinengi zangasese. I-Sowetan Live isanda kubika bona &quot;kwamambala idorobha lifake isandla&quot;ekwakheni &quot;amakhaya wezehlalakahle ama-4,000 eendaweni ezili-11&quot; lapho izakhamuzi ezingaphezu kwe-350,000 zisatlhoga isizo lezezindlu msinyana.

== Zepilo ==
ISewula Afrika inobulwelwe obunengi obuthelelekako. Imalariya yimbangela ekulu yokuhlongakala ngebanga lokutlhogeka kwemithombo yokwelapha iingulani.Phezu kwalokho,amanzi asilaphazekileko ngefucuza yabantu neyamabubulo okufaka isandla ekurhatjhekeni kwamalwele.  Ukuhlongakala okunengi kubangelwa buphofu kunokutlhogeka kweendlela zokwelapha ubulwele.Ukutlhaga kusizathu esikhulu sokuhlongakala ngombana imindeni erhola imali encani ayikghoni ukuthenga iinkonzo zezamaphilo ezifaneleko,begodu neembhedlela azikghoni ukuthenga izinto ezaneleko.Phezu kwalokho,abantu abahlala eSewula Afrika abafuduke ngokungekho emthethweni baswele iinsetjenziswa zokunakekelwa kwepilo okungasikho okuphuthumako.Ukwenza isibonelo,abantu abanengi abahlala e- Hillbrow Health Precinct abakho emthethweni begodu baneensetjenziswa zezamaphilo ezimbi. Ngokukhethekileko,ezinye izakhiwo zeembhedlela zakhiwa ngaphambi kwePi yesiBili yePhasi.Ukudlula lapho, umphakathi we-Hillbrow unamazinga aphezulu wezifo ezitheleleka ngokobulili.

=== I-HIV/AIDS ===
ISewula Afrika inenani elikhulu labantu abaphila ne-HIV/AIDS ephasini,abayi-7.5 yeengidi ukusukela ngo-2021.Kwathoma ukutholakala ngo-1982.Ubulwelwe lobu bathoma ukutholakala ebantwini abathandana nabobulili obufanako, kodwana msinyana warhatjheka ebantwini abathandana nabobulili obufanako.Ngebanga lokurhatjheka msinyana, urhulumende walinga ukungenelela begodu asize.Nanyana kunjalo,iSewula Afrika beyiseminyakeni yokugcina yebandlululo lokha i-HIV/AIDS nayiba mraro.Ngalokho, urhulumende weSewula Afrika waba nobudisi obukhulu bokunciphisa umphumela wobulwelwe.Ukwenza isibonelo, ngebanga lokuhlukaniswa kweenkolo kunye nokuphikisana okuphathelene nalokho,urhulumende akhenge adzimelele ekunikeleni ifundo yezomseme esezingeni eliphezulu ebeyidzimelele khulukhulu ku-HIV/AIDS.Phezu kwalokho, urhulumende wendawo nowefederali bebangavumelani malungana nokwabiwa kwemali yokukhandela i-HIV/AIDS, lokho kwabangela ukungasebenzi kuhle nokuhlangahlangana.Godu,enye yemali eyabelwe ukukhandela i-HIV/AIDS yasetjenziswa kumbi.Ukwenza isibonelo,umvumo obizwa nge ''-Sarafina II'' bewuqalelelwe ukwandisa ukutjheja nge-AIDS nokukhandela i-AIDS. Kodwana,umdlalo lo bewungacaci begodu awuzange usize khulu ngefundo yezomseme.Okunengi kokwelatjhwa kwe-HIV/AIDS nokuragela phambili kusekelwe ngemali ziinhlangano ezingenzi inzuzo ezifana ne -WHO ne -UNAIDS.

== Amalungelo wezomseme newe-LGBT ==

=== Ukubandlulula ngokobulili ===
ISewula Afrika iqalene neendaba eziphathelene nokungalingani ngokobulili emacaleni wekhotho.Isibonelo esihle khulu ngesecala lokukata laka- Jacob Zuma ngo-2006. &quot;U-Khwezi,umlweli we-AIDS wesifazana,waletha u-Zuma emthethwandaba ngokumkata.Njengokuzivikela kwakhe,u-Zuma wathi &quot;angaba nokuthintana nabantu abasikazi&quot; lula, yeke waveza bona bekangasoze amkate u-Khwezi wasebenzisa isiko lamaZulu njengokusekela.&quot; Izenzo lezi zabangela bona abasekeli bezobulili batjhikije ngokuphikisana nokubandlululwa ngokobulili begodu baphakamise ukutshwenyeka ngokuthi ijaji livumele ikhotho bona ivume ubufakazi ngomlando ka-Khwezi wezomseme, kodwana azange ivume ubufakazi obuvela emlandwini wezomseme ka-Zuma.Abantu abanengi bebabona ngasuthi u-Zuma waphikisana nentando yenengi yesimanjemanje yeSewula Afrika ngombana bekajamele isihlobo esikhulu khulu.

=== Ukukata ===
Ngomnyaka ka-2018/19,amapholisa weSewula Afrika arekhode ukukata okuma-41,583,nanyana izazi ziyelelisa ngokuthi kubudisi ukuhlola bona mangakhi amanye amacala angakabikwa.Irhubhululo lango-2009 lathola bona indoda eyodwa kwabane yeSewula Afrika yavuma ukukata umuntu begodu elinye irhubhululo lathola bona wengubo munye kwabathathu kwabafazi abayi-4000 ababuziweko bathi bakatwe emnyakeni odlulileko.

Ukukata nakho kwenziwa bantwana (abanye abaneminyaka elitjhumi).Izehlakalo zokukatwa kwabantwana ngezinye zezehlakalo eziphezulu khulu ephasini.Ukukatwa kwabantwana okunengi okudumileko okufaka hlangana ukuhlinzwa okukhulu kokuvuselela ukwakha kabutjha umchamo,izitho zangasese,isisu,nofana iinhlelo ze-tracheal sele kuvele.

== Amalungelo wabasebenzi ==

=== Ngokomthetho ===
ISewula Afrika inemithetho yezabasebenzi ecacileko necacileko.Imithetho yayo yezabasebenzi engatjho litho ivezwe emthethwenisisekelo begodu ibeka imibandela yemithetho ecacileko.Imithetho ecacileko ibekwa baqatjhi begodu iqondene nomsebenzi ngamunye.Ngakelinye ihlangothi,imithetho engabonakaliko nguMthetho wezobudlelwano bezabasebenzi 66 ka-1995,umThetho weeMbandela eziSisekelo zokuQashwa 75 ka-1997, umThetho wokuLingana kokuQashwa okuTjha 55 ka-1998, kunye nomThetho wokuThuthukiswa kwamaKghono 97 ka-1998—omunye nomunye uneentjhuguluko ezilandelako. Umthetho wezobudlelwano bezabasebenzi 66 uvumela abasebenzi bona benze iinyunyana begodu babonisane ngokuhlanganyela.Ngokukhamba kweminyaka,inani leenyunyana eSewula Afrika lehle.Godu,kuneenyunyana ezimbalwa ezihlobene nefedereshini kunye neenyunyana ezizijameleko ezinengi eSewula Afrika namhlanjesi. UmThetho weMibandela yokuQashwa 75 unemithetho ephathelene nama-awa wokusebenza,ikhefu,nokuqedwa emsebenzini.UmThetho omutjha wokuLingana kokuQashwa 55 wasungulwa ukwehlisa ukubandlululwa.Iphinde inikeze amapharamitha wesenzo sokuqinisekisa.UmThetho wokuThuthukiswa kwamaKghono 97 ukhuthaza ukukhiqiza kwabasebenzi nokuncintisana emakethe.

=== Iinyunyana ===
ISewula Afrika inemiraro ephathelene nemisebenzi.Enye into ekhona kukubunjwa kweenyunyana.Kuhlekuhle,ama-22% wabasebenzi beSewula Afrika bangamalunga weyuniyoni. Ngo-2012,kwenzeka i-Marikana Massacre.Ukubulawa kwabantu e-Marikana bekukubulawa kwabavukuzi be-platinamu abama-44 ebegade bateleka ukwenzela bona bathole irholo elingezelelweko.Abantu abangu-78 balimala begodu abangu-259 babotjhwa.Esinye isizathu salesi sihluku bekukukuthi isiteleka besingakavikeleki.Phezu kwalokho, abasebenzi beplasi ababhadelwa kumbi bebateleka.Esinye isibonelo kusiteleka kwabasebenzi beplasi le-Western Cape, lapho abasebenzi bebanengi abafazi.Isiteleka sabangela ukuhlongakala kwabantu aba-3,kodwana abasebenzi bathola ukunyuselwa kwemirholo ngama-52%.Isiteleka lesi besingakavikeleki.Kwaba nenye isiteleka sokumba iplatinamu ngo-2014,kodwana sahlukile esiteleka sokumba iplatinamu ngo-2012 ngombana besivikelwe.Ukuvikelwa kwavimbela ubuhlungu bamapholisa.Kuhlekuhle,isiteleka lesi sathatha iinyanga ezihlanu.Ngalokho-ke,ukukhiqizwa kweplatinamu ephasini loke kwehle ngama-40% ngebanga lokutlhogeka kwabasebenzi.Irholo labasebenzi lakhuphuka njengomphumela,kodwana abasebenzi nabo balahlekelwa ngebanga lomthethomgomo &quot;wokungasebenzi,akukho mrholo&quot; eSewula Afrika.Abasebenzi abatelekako ngokuvamileko bakhuthazwa khulu,ngitjho nanyana batelekako abavikelweko,ngombana kunengozi ekulu yokulahlekelwa.

== Iinkomba ==
1.https://www.gov.za/about-government/human-rights

2.https://www.amnesty.org/en/location/africa/southern-africa/south-africa/report-south-africa/

3.https://www.sahrc.org.za/

4.https://www.justice.gov.za/constitution/chp02.html

5.https://unimelb.libguides.com/c.php?g=928011&amp;p=6704328

6.https://www.parliament.gov.za/project-event-details/2

7.https://www.legalwise.co.za/help-yourself/quicklaw-guides/protected-constitution

8.[https://www.sahrc.org.za/#:~:text=The%20Human%20Rights%20Commission%20in%20South%20Africa,and%20United%20Nations%20treaty%20bodies%20amongst%20themselves. https://www.sahrc.org.za/#:~:text=The%20Human%20Rights%20Commission%20in%20South%20Africa,and%20United%20Nations%20treaty%20bodies%20amongst%20themselves.]

9.https://www.parliament.gov.za/project-event-details/2&lt;nowiki/&gt;{{Reflist|30em}}</text>
      <sha1>p2op323l0tcox8yxd34u111ify93ds9</sha1>
    </revision>
    <revision>
      <id>6395</id>
      <parentid>6394</parentid>
      <timestamp>2026-04-07T10:22:13Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>ngifake iinthombe</comment>
      <origin>6395</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="16549" sha1="pj2grcw5yrouef6dzs5ld9yy23kgcsc" xml:space="preserve">[[Isimumathi:Human Rights Foundation logo.svg|thumb|Itshwayo lamalungelo wobuntu]]
'''Amalungelo wobuntu eSewula Afrika''' avikelwe ngaphasi komthethosisekelo.Umbiko wamaLungelo woBuntu wango-1998 ka-Myles Nadioo waveza bona urhulumende uhlonipha amalungelo wezakhamuzi,nanyana kunjalo bekunokutshwenyeka malungana nokusetjenziswa kwamandla ngabasebenzi bomthetho,ukuthatha amagadango womthetho,nokubandlululwa.Ikhomitjhini yamaLungelo woBuntu igunyazwe mThethosisekelo weSewula Afrika kanye nomThetho weKhomitjhini yamaLungelo woBuntu ka-1994, ukutjheja,kokubili ngokuzikhandla nangeenkhalazo ezilethwa phambi kwayo,ukwephulwa kwamalungelo wobuntu nokufuna ukulungiswa kokwephulwa okunjalo.Godu inendima yokufundisa.

== Isikhathi sebandlululo ==
[[Isimumathi:Apartheid Museum 001.jpeg|thumb|Isithombe se-Apartheid Museum]]
Ibandlululo bekulihlelo lokuhlukanisa nokubandlulula ebegade lisetjenziswa babantu abancani abamhlophe ngokujamelana nenengi labantu abanzima.Ukwenza isibonelo,abantu abanzima bebangakavunyelwa ukuthenga inarha ngaphandle kweendawo ezibekelwe inarha nanyana bebabantu bomdabu.  Imithetho eminengi yeSewula Afrika elwisana nebandlululo yenziwa ngesikhathi kugcinwa engqondweni bona lokho okubonwa mphakathi weentjhabatjhaba,iinhlangano zamalungelo wobuntu,kunye nenengi labantu abanzima enarheni njengokungabi nobulungiswa kwezehlalakuhle nezomthetho okuhlobene nebandlululo,nomlayezo wayo wokulwisana nebandlululo udunyiswe njengobuso obuhle besitjhaba se-Sub-Saharan.

== Amalungelo wefundo ==
Urhulumende weSewula Afrika wenze umthetho wefundo elinganako enarheni yoke.Umthetho lo ufakahlangana i-White Paper on Education and Training 1995 kunye ne-South African Schools Act, Act 84 of 1996.Nanyana kunjalo,kube neendaba ekuphumeleliseni imithetho le,begodu ngokuya kombiko we-2020 we-Amnesty International,iSewula Afrika inehlelo elingakalingani khulu ephasini,elinamaphuzu wokuhlolwa ama-20% weenkolo eziphezulu kunye nama-80% aseleko.Urhulumende weSewula Afrika uvame ukutjheja khulu ikhwalithi yefundo ephakemeko.Ukungezelela,akukho ukuhlanganiswa okukhulu ngokobuhlanga eenkolweni zombuso.Nanyana imithetho ivumela ukuhlanganiswa,iinkolo ezinengi zihlala ziyihlanga eyodwa.Ngokukhuthazako,inani labafundi abaqeda ibanga le-12 likhuphuke khulu eminyakeni esanda kwedlula,lisukela eengidini ezi-3.7 zamaSewula Afrika aneminyaka eli-15 nangaphezulu ngo-1996 ukuya eengidini ezili-11.6 ngo-2016.

=== Iimfunda zemakhaya ===
Inengi lefundo eSewula Afrika linikelwa zikolo zemakhaya. Kuhlekuhle,pheze ama-79% wabantu abanzima beSewula Afrika bahlala emiphakathini yemakhaya.Nanyana kunjalo, urhulumende unganaki ikhwalithi yefundo eendaweni ezisemakhaya.Iindaba eziphathelene neenkolo zemakhaya zifaka hlangana:iinsetjenziswa ezimbi,ukutlhayela kwamanzi ahlanzekileko,ukutlhayela kweensetjenziswa,kunye nabotitjhere abanganamandla.Nakuqalwa iinsetjenziswa ezimbi,ezinye iinkolo azizinzile begodu zisengozini yokubhidlika,ezinye iinkolo zitlhoga igezi.Inengi leenkolo ezinabantwana abangaphezu kwama-500 azinawo amathoyilethi afaneleko,kuthi ezinye iinkolo azinawo amathoyilethi.Ukudlula lapho,iinkolo ezinengi zemakhaya ziseendaweni ezikude ezinganawo amanzi ahlanzekileko. Amanzi avamise ukuba kude ngamakhilomitha begodu angasilapheleko ngombana iinlwana zigeza begodu zisele kiwo.Ukutlhogeka kwamanzi lokhu kuyindaba ethileko emini lokha amazinga womtjhiso aphezulu khulu.Ukuba kude kweenkolo zemakhaya nakho kuyikinga ethileko ngombana zikude khulu namakhaya wabafundi.Begodu,iinkolo ezinengi azilungisi indaba le ngeenthuthi.Phezu kwalokho,iinkolo ezinengi azinazo iincwadi ezitlhogekako nezinto zokufunda.  NgoMgwengweni 2010,iGazethi kaRhulumende yabona bona iindawo zokufunda ezingakalungi zikhuphula amazinga wokuphutha kwabotitjhere kunye namazinga wokuphuma esikolweni wabafundi.Abanye abafundi abanakho ukudla okwaneleko begodu balambile ngesikhathi sesikolo.Indlala le ibangela ukutlhayela kokudzimelela begodu yenza iindawo zokufunda zingabi zihle.

=== Amalungelo wabantwana abakhubazekileko ===
Nanyana iSewula Afrika yavuma iSivumelwano samaLungelo waBantu abaKhubazekileko ngo-2007,abantwana abakhubazekileko abakakwazi ukuthola ifundo ngokulinganako.Ebujameni obunengi, isikolo sombuso singaqunta bona ngibaphi abafundi abangatlolisa,begodu isikolo singalahla umntwana okhubazekileko ngaphandle kwemiphumela.Ebujameni lapho umfundi angabhalisa khona esikolweni somphakathi,isikolo singatlhoga iinsetjenziswa ezitlhogekako zokufundisa abantwana abakhubazekileko kuhle.Ukungezelela,abantwana abakhubazekileko eenkolweni zombuso bakateleleka bona babhadele iimali—ezifana nomsizi—abanye abafundi abangatlhogeki bona bazibhadele.ISewula Afrika ineenkolo ezitlhogomela abafundi abakhubazekileko,kodwana iinkolo lezi zilinganiselwe ngenani begodu zitlhoga bona kubhadelwe imali.Inani elilinganiselweko leenkolo likatelela abantwana bona bakhwele namkha basebenzise iinthuthi ezibizako. Ngomnyaka ka-2000,iKomidi yamaLungelo waBantwana ye-UN beyitshwenyeke khulu ngokutlhogeka kokusetjenziswa kwesivumelwano seSewula Afrika sokuqinisekisa ifundo yamabanga aphasi yasimahla.ISewula Afrika isazabalaza ukunikela ngefundo yamabanga aphasi yasimahla kibo boke abantu.Ukungezelela,abafundi abanengi abakhubazekileko abakghoni ukuthola ifundo esezingeni eliphezulu ngombana basehlwini lokulinda eenkolweni ezitlhogomela abafundi abaneemfuno ezikhethekileko.Ukwenza isibonelo,ngo-2015, bekunabantwana abangaba yi-5,552 abakhubazekileko erhelweni lokulinda.

== Amalungelo wepolotiki ==
[[Isewula Afrika|ISewula Afrika]] inomthethosisekelo okhululekileko ovikela zoke iinkululeko zepolotiki eziqakathekileko.Nanyana kunjalo,kube nezehlakalo ezinengi zokugandelela kwezepolotiki kunye nokusongelwa kokugandeleleka kwesikhathi esizako ngokuphula umthethosisekelo lo okwenza abanye abahlaziyi neenhlangano zomphakathi baphethe ngokuthi kunesimo esitjha sokugandelela kwezepolotiki namkha ukwehla kokubekezelelana kwezepolotiki.

Ukusekelwa kwezepolotiki yinto eqakathekileko kwezepolotiki yeSewula Afrika.Kodwana,ukusekelwa lokhu kwephula amalungelo wabantu,khulukhulu labo abatlhagako.Ama-40% wabantu beSewula Afrika bathembele embusweni bona ubanikele izinto ezitlhogekako.Ukuthembela embusweni lokhu kunciphisa ukuzijamela kwabantu beSewula Afrika abatlhoga isizo leli.Iimfuneko lezi zinikelwa ngendlela yezibonelelo,ezitlhoga amadokhumende karhulumende ukuzifumana.Ngalokho-ke,ubuphathi budlala indima ekulu emandleni womuntu wokuthola isibonelelo begodu ngaleyo ndlela athole izinto ezitlhogekako.Abezombusazwe bathola abathatha indawo yabo ngokuya ngeenthembiso eziphathekako.Nangabe abosopolotiki bazalisekisa iinthembiso lezi,kanengi abamukelwako ngilabo abasekela abosopolotiki kwaphela.Ngokuqakatheke khulu,ukuthembela kwabavowudi embusweni kuvimbela ikghono labo lokuvowuda ngokuya ngemibono.Isimanga lesi asikhambisani nemigomo yentando yenengi yeSewula Afrika.

== Ihlalakuhle ==
Kusukela ngo-2021,pheze ama-30% wabantu beSewula Afrika (18 yezigidi ebantwini beenarha abaziingidi ezima-60) bathole isibonelelo sikaRhulumende.Inani leli lakhula khulu ngesikhathi sengogwane lekhovidi ;ngoSewula wee-2020, abantu abangaphezu kwama-70% beSewula Afrika bebahlala emzini othola isekelo likaRhulumende.

I-1997 &quot;Iphepha elimhlophe lezehlalakuhle&quot; liveza umthethomgomo wezehlalakuhle weSewula Afrika.Iphepha elimhlophe lezehlalakuhle lidzimelele ekunikeleni amaSewula Afrika amathuba wokuzijamela okukhulu.Ukwenza isibonelo, iPhepha elimhlophe lezehlalakuhle libeka ukuhlinzekwa kwamaphrojekthi wemisebenzi yomphakathi.Iphepha elimhlophe libuye ligandelele ukuqakatheka kweenhlangano ezingekho embusweni zehlalakuhle ekunikeleni ngehlalakuhle.Iinhlangano ezinjalo zifaka hlangana iinhlangano ezingasizo zikaRhulumende (ama-NGO) kunye neenhlangano zekolo.Phezu kwalokho,iPhepha elimhlophe lidzimelele ekutheni urhulumende anikele ngehlalakahle khulukhulu emindenini.Kodwana,iPhepha elimhlophe linemibandela embalwa ebantwini abadala.Urhulumende ulindele bona imindeni ithathe umthwalo wokutlhogomela iinhlobo zayo ezikhulileko,ngokwengcenye ngebanga lamasiko.Iphepha elimhlophe labuye lahlanganisa iimali zokusekelwa kwabantwana begodu lalisa ukucabanga okungakalungi malungana nendima yobulili emndenini. Ukwenza isibonelo,i-White Paper azange ikhulume ngomuntu omduna ekhaya &quot;njengomuntu ozondlako&quot;.Ukungalingani ngokobuhlanga emadorobheni weSewula Afrika kusesekhona,nanyana inarha sele iqede ibandlululo.Inengi labantu abanzima beSewula Afrika basatshwenyeka ngokufumana iintlhogo ezifana nezindlu,bahlala emalokitjhini angatlhogonyelwa kuhle.Ngokuphikisako,abantu abanengi beSewula Afrika abamhlophe abahlala emadorobheni bahlala emiphakathini evaliweko eneenvikeleko ezinengi zangasese. I-Sowetan Live isanda kubika bona &quot;kwamambala idorobha lifake isandla&quot;ekwakheni &quot;amakhaya wezehlalakahle ama-4,000 eendaweni ezili-11&quot; lapho izakhamuzi ezingaphezu kwe-350,000 zisatlhoga isizo lezezindlu msinyana.

== Zepilo ==
ISewula Afrika inobulwelwe obunengi obuthelelekako. Imalariya yimbangela ekulu yokuhlongakala ngebanga lokutlhogeka kwemithombo yokwelapha iingulani.Phezu kwalokho,amanzi asilaphazekileko ngefucuza yabantu neyamabubulo okufaka isandla ekurhatjhekeni kwamalwele.  Ukuhlongakala okunengi kubangelwa buphofu kunokutlhogeka kweendlela zokwelapha ubulwele.Ukutlhaga kusizathu esikhulu sokuhlongakala ngombana imindeni erhola imali encani ayikghoni ukuthenga iinkonzo zezamaphilo ezifaneleko,begodu neembhedlela azikghoni ukuthenga izinto ezaneleko.Phezu kwalokho,abantu abahlala eSewula Afrika abafuduke ngokungekho emthethweni baswele iinsetjenziswa zokunakekelwa kwepilo okungasikho okuphuthumako.Ukwenza isibonelo,abantu abanengi abahlala e- Hillbrow Health Precinct abakho emthethweni begodu baneensetjenziswa zezamaphilo ezimbi. Ngokukhethekileko,ezinye izakhiwo zeembhedlela zakhiwa ngaphambi kwePi yesiBili yePhasi.Ukudlula lapho, umphakathi we-Hillbrow unamazinga aphezulu wezifo ezitheleleka ngokobulili.

=== I-HIV/AIDS ===
[[Isimumathi:HIV logo.jpg|thumb|I-Logo ye-HIV/AIDS]]
ISewula Afrika inenani elikhulu labantu abaphila ne-HIV/AIDS ephasini,abayi-7.5 yeengidi ukusukela ngo-2021.Kwathoma ukutholakala ngo-1982.Ubulwelwe lobu bathoma ukutholakala ebantwini abathandana nabobulili obufanako, kodwana msinyana warhatjheka ebantwini abathandana nabobulili obufanako.Ngebanga lokurhatjheka msinyana, urhulumende walinga ukungenelela begodu asize.Nanyana kunjalo,iSewula Afrika beyiseminyakeni yokugcina yebandlululo lokha i-HIV/AIDS nayiba mraro.Ngalokho, urhulumende weSewula Afrika waba nobudisi obukhulu bokunciphisa umphumela wobulwelwe.Ukwenza isibonelo, ngebanga lokuhlukaniswa kweenkolo kunye nokuphikisana okuphathelene nalokho,urhulumende akhenge adzimelele ekunikeleni ifundo yezomseme esezingeni eliphezulu ebeyidzimelele khulukhulu ku-HIV/AIDS.Phezu kwalokho, urhulumende wendawo nowefederali bebangavumelani malungana nokwabiwa kwemali yokukhandela i-HIV/AIDS, lokho kwabangela ukungasebenzi kuhle nokuhlangahlangana.Godu,enye yemali eyabelwe ukukhandela i-HIV/AIDS yasetjenziswa kumbi.Ukwenza isibonelo,umvumo obizwa nge ''-Sarafina II'' bewuqalelelwe ukwandisa ukutjheja nge-AIDS nokukhandela i-AIDS. Kodwana,umdlalo lo bewungacaci begodu awuzange usize khulu ngefundo yezomseme.Okunengi kokwelatjhwa kwe-HIV/AIDS nokuragela phambili kusekelwe ngemali ziinhlangano ezingenzi inzuzo ezifana ne -WHO ne -UNAIDS.

== Amalungelo wezomseme newe-LGBT ==

=== Ukubandlulula ngokobulili ===
ISewula Afrika iqalene neendaba eziphathelene nokungalingani ngokobulili emacaleni wekhotho.Isibonelo esihle khulu ngesecala lokukata laka- Jacob Zuma ngo-2006. &quot;U-Khwezi,umlweli we-AIDS wesifazana,waletha u-Zuma emthethwandaba ngokumkata.Njengokuzivikela kwakhe,u-Zuma wathi &quot;angaba nokuthintana nabantu abasikazi&quot; lula, yeke waveza bona bekangasoze amkate u-Khwezi wasebenzisa isiko lamaZulu njengokusekela.&quot; Izenzo lezi zabangela bona abasekeli bezobulili batjhikije ngokuphikisana nokubandlululwa ngokobulili begodu baphakamise ukutshwenyeka ngokuthi ijaji livumele ikhotho bona ivume ubufakazi ngomlando ka-Khwezi wezomseme, kodwana azange ivume ubufakazi obuvela emlandwini wezomseme ka-Zuma.Abantu abanengi bebabona ngasuthi u-Zuma waphikisana nentando yenengi yesimanjemanje yeSewula Afrika ngombana bekajamele isihlobo esikhulu khulu.

=== Ukukata ===
Ngomnyaka ka-2018/19,amapholisa weSewula Afrika arekhode ukukata okuma-41,583,nanyana izazi ziyelelisa ngokuthi kubudisi ukuhlola bona mangakhi amanye amacala angakabikwa.Irhubhululo lango-2009 lathola bona indoda eyodwa kwabane yeSewula Afrika yavuma ukukata umuntu begodu elinye irhubhululo lathola bona wengubo munye kwabathathu kwabafazi abayi-4000 ababuziweko bathi bakatwe emnyakeni odlulileko.

Ukukata nakho kwenziwa bantwana (abanye abaneminyaka elitjhumi).Izehlakalo zokukatwa kwabantwana ngezinye zezehlakalo eziphezulu khulu ephasini.Ukukatwa kwabantwana okunengi okudumileko okufaka hlangana ukuhlinzwa okukhulu kokuvuselela ukwakha kabutjha umchamo,izitho zangasese,isisu,nofana iinhlelo ze-tracheal sele kuvele.

== Amalungelo wabasebenzi ==

=== Ngokomthetho ===
ISewula Afrika inemithetho yezabasebenzi ecacileko necacileko.Imithetho yayo yezabasebenzi engatjho litho ivezwe emthethwenisisekelo begodu ibeka imibandela yemithetho ecacileko.Imithetho ecacileko ibekwa baqatjhi begodu iqondene nomsebenzi ngamunye.Ngakelinye ihlangothi,imithetho engabonakaliko nguMthetho wezobudlelwano bezabasebenzi 66 ka-1995,umThetho weeMbandela eziSisekelo zokuQashwa 75 ka-1997, umThetho wokuLingana kokuQashwa okuTjha 55 ka-1998, kunye nomThetho wokuThuthukiswa kwamaKghono 97 ka-1998—omunye nomunye uneentjhuguluko ezilandelako. Umthetho wezobudlelwano bezabasebenzi 66 uvumela abasebenzi bona benze iinyunyana begodu babonisane ngokuhlanganyela.Ngokukhamba kweminyaka,inani leenyunyana eSewula Afrika lehle.Godu,kuneenyunyana ezimbalwa ezihlobene nefedereshini kunye neenyunyana ezizijameleko ezinengi eSewula Afrika namhlanjesi. UmThetho weMibandela yokuQashwa 75 unemithetho ephathelene nama-awa wokusebenza,ikhefu,nokuqedwa emsebenzini.UmThetho omutjha wokuLingana kokuQashwa 55 wasungulwa ukwehlisa ukubandlululwa.Iphinde inikeze amapharamitha wesenzo sokuqinisekisa.UmThetho wokuThuthukiswa kwamaKghono 97 ukhuthaza ukukhiqiza kwabasebenzi nokuncintisana emakethe.

=== Iinyunyana ===
ISewula Afrika inemiraro ephathelene nemisebenzi.Enye into ekhona kukubunjwa kweenyunyana.Kuhlekuhle,ama-22% wabasebenzi beSewula Afrika bangamalunga weyuniyoni. Ngo-2012,kwenzeka i-Marikana Massacre.Ukubulawa kwabantu e-Marikana bekukubulawa kwabavukuzi be-platinamu abama-44 ebegade bateleka ukwenzela bona bathole irholo elingezelelweko.Abantu abangu-78 balimala begodu abangu-259 babotjhwa.Esinye isizathu salesi sihluku bekukukuthi isiteleka besingakavikeleki.Phezu kwalokho, abasebenzi beplasi ababhadelwa kumbi bebateleka.Esinye isibonelo kusiteleka kwabasebenzi beplasi le-Western Cape, lapho abasebenzi bebanengi abafazi.Isiteleka sabangela ukuhlongakala kwabantu aba-3,kodwana abasebenzi bathola ukunyuselwa kwemirholo ngama-52%.Isiteleka lesi besingakavikeleki.Kwaba nenye isiteleka sokumba iplatinamu ngo-2014,kodwana sahlukile esiteleka sokumba iplatinamu ngo-2012 ngombana besivikelwe.Ukuvikelwa kwavimbela ubuhlungu bamapholisa.Kuhlekuhle,isiteleka lesi sathatha iinyanga ezihlanu.Ngalokho-ke,ukukhiqizwa kweplatinamu ephasini loke kwehle ngama-40% ngebanga lokutlhogeka kwabasebenzi.Irholo labasebenzi lakhuphuka njengomphumela,kodwana abasebenzi nabo balahlekelwa ngebanga lomthethomgomo &quot;wokungasebenzi,akukho mrholo&quot; eSewula Afrika.Abasebenzi abatelekako ngokuvamileko bakhuthazwa khulu,ngitjho nanyana batelekako abavikelweko,ngombana kunengozi ekulu yokulahlekelwa.

== Iinkomba ==
1.https://www.gov.za/about-government/human-rights

2.https://www.amnesty.org/en/location/africa/southern-africa/south-africa/report-south-africa/

3.https://www.sahrc.org.za/

4.https://www.justice.gov.za/constitution/chp02.html

5.https://unimelb.libguides.com/c.php?g=928011&amp;p=6704328

6.https://www.parliament.gov.za/project-event-details/2

7.https://www.legalwise.co.za/help-yourself/quicklaw-guides/protected-constitution

8.[https://www.sahrc.org.za/#:~:text=The%20Human%20Rights%20Commission%20in%20South%20Africa,and%20United%20Nations%20treaty%20bodies%20amongst%20themselves. https://www.sahrc.org.za/#:~:text=The%20Human%20Rights%20Commission%20in%20South%20Africa,and%20United%20Nations%20treaty%20bodies%20amongst%20themselves.]

9.https://www.parliament.gov.za/project-event-details/2&lt;nowiki/&gt;{{Reflist|30em}}</text>
      <sha1>pj2grcw5yrouef6dzs5ld9yy23kgcsc</sha1>
    </revision>
  </page>
  <page>
    <title>Ilanga lekululeko (iSewula Afrika)</title>
    <ns>0</ns>
    <id>1087</id>
    <revision>
      <id>6396</id>
      <timestamp>2026-04-07T10:39:36Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1341852181|Freedom Day (South Africa)]]&quot;</comment>
      <origin>6396</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2310" sha1="2evr1n3lg9f60exew78vll6nc0eti2f" xml:space="preserve">
'''Ilanga lekululeko''' lilanga lokuphumula [[Isewula Afrika|eSewula Afrika]] eligidingwa mhlazi-27 kuSihlabantangana.Ikhumbula ikhetho lokuthoma ngemva kwebandlululo olwenziwa mhlokho ngo-1994 kunye nelanga lapho umthethosisekelo omutjha wethulwa khona.Amakhetho bekumakhetho wokuthoma weentjhabatjhaba lapho woke umuntu oneminyaka yokuvowuda engaphezu kwe-18 ukusuka nanyana ngibuphi ubuzwe bekavunyelwe ukuvowuda.

Ngelinye lamalanga wokuphumula alitjhumi nambili anqunywe mThetho wamaholideyi womphakathi (Nomboro 36 ka-1994) .

Emnyanyeni wokuthoma wokukhumbula iholideyi, uMengameli [[Nelson Mandela|uNelson Mandela]] wakhuluma nePalamende wathi: &lt;blockquote&gt;''Njengoba ukusa okutjha kwaletha ilanga leli, mhlazi-27 kuSihlabantangana 1994,bambalwa kithi ebebangakghona ukugandelela imizwa, njengombana besikhunjuzwa ngesikhathi esidlulileko esimbi esivela kiso njengesitjhaba; amathuba amakhulu esinawo nje;kunye nengomuso elikhanyako elisibizako.Njeke sihlangana lapha namhlanjesi,nakwezinye iindawo zelizwe,ukutshwaya ilanga eliqakathekileko epilweni yesitjhaba sekhethu.Nanyana kukuphi lapho amaSewula Afrika akhona ephasini loke, iinhliziyo zethu zishaya njengenye,njengombana sivuselela ukuthembeka kwethu okufanako enarheni yekhethu nokuzibophelela kwethu esikhathini esizako.''&lt;/blockquote&gt;Ilanga lekululeko mnyanya owenziwa qobe mnyaka mhlazi-27 kuSihlabantangana [[Isewula Afrika|eSewula Afrika]] .Ilanga leli likhumbuza abantu beSewula Afrika ngokuzinikela okukhulu okwenziwe babantu neentjhaba ukuze baphule emaketangeni wokuhlukaniswa okungakalungi ngabantu abambalwa abakhethiweko.Ibakhumbuza ngemizamo yamaqhawe wabo wesitjhaba,khulukhulu [[Nelson Mandela|u-Nelson Mandela]] .Uthathwa njengomlweli wekululeko,ingasi eSewula Afrika kwaphela kodwana ephasini loke.Lilanga elingaphawuli ukutjhaphuluka kwabantu beSewula Afrika ebandlululweni kwaphela kodwana libuyisela amalungelo wabo wobuntu aqakathekileko ngo-1994. 

== Iinkomba ==
1.https://clintonwhitehouse4.archives.gov/Africa/south.html

2.https://kids.britannica.com/students/article/Freedom-Day/607290

3.https://www.gov.za/news/events/commemorative-events/freedom-day-2014

4.https://www.remitly.com/blog/lifestyle-culture/south-africa-freedom-day-history-and-celebrations/

5.https://sahistory.org.za/article/freedom-day-27-april</text>
      <sha1>2evr1n3lg9f60exew78vll6nc0eti2f</sha1>
    </revision>
    <revision>
      <id>6397</id>
      <parentid>6396</parentid>
      <timestamp>2026-04-07T10:42:29Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>ngifake isithombe esitjha</comment>
      <origin>6397</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2384" sha1="7ndma7xw8hwg5o00ox1r4nmhznq4zhh" xml:space="preserve">[[Isimumathi:Mandela voting in 1994.jpg|thumb|U-Mandela avowuda ngo-1994]]
'''Ilanga lekululeko''' lilanga lokuphumula [[Isewula Afrika|eSewula Afrika]] eligidingwa mhlazi-27 kuSihlabantangana.Ikhumbula ikhetho lokuthoma ngemva kwebandlululo olwenziwa mhlokho ngo-1994 kunye nelanga lapho umthethosisekelo omutjha wethulwa khona.Amakhetho bekumakhetho wokuthoma weentjhabatjhaba lapho woke umuntu oneminyaka yokuvowuda engaphezu kwe-18 ukusuka nanyana ngibuphi ubuzwe bekavunyelwe ukuvowuda.

Ngelinye lamalanga wokuphumula alitjhumi nambili anqunywe mThetho wamaholideyi womphakathi (Nomboro 36 ka-1994) .

Emnyanyeni wokuthoma wokukhumbula iholideyi, uMengameli [[Nelson Mandela|uNelson Mandela]] wakhuluma nePalamende wathi: &lt;blockquote&gt;''Njengoba ukusa okutjha kwaletha ilanga leli, mhlazi-27 kuSihlabantangana 1994,bambalwa kithi ebebangakghona ukugandelela imizwa, njengombana besikhunjuzwa ngesikhathi esidlulileko esimbi esivela kiso njengesitjhaba; amathuba amakhulu esinawo nje;kunye nengomuso elikhanyako elisibizako.Njeke sihlangana lapha namhlanjesi,nakwezinye iindawo zelizwe,ukutshwaya ilanga eliqakathekileko epilweni yesitjhaba sekhethu.Nanyana kukuphi lapho amaSewula Afrika akhona ephasini loke, iinhliziyo zethu zishaya njengenye,njengombana sivuselela ukuthembeka kwethu okufanako enarheni yekhethu nokuzibophelela kwethu esikhathini esizako.''&lt;/blockquote&gt;Ilanga lekululeko mnyanya owenziwa qobe mnyaka mhlazi-27 kuSihlabantangana [[Isewula Afrika|eSewula Afrika]] .Ilanga leli likhumbuza abantu beSewula Afrika ngokuzinikela okukhulu okwenziwe babantu neentjhaba ukuze baphule emaketangeni wokuhlukaniswa okungakalungi ngabantu abambalwa abakhethiweko.Ibakhumbuza ngemizamo yamaqhawe wabo wesitjhaba,khulukhulu [[Nelson Mandela|u-Nelson Mandela]] .Uthathwa njengomlweli wekululeko,ingasi eSewula Afrika kwaphela kodwana ephasini loke.Lilanga elingaphawuli ukutjhaphuluka kwabantu beSewula Afrika ebandlululweni kwaphela kodwana libuyisela amalungelo wabo wobuntu aqakathekileko ngo-1994. 

== Iinkomba ==
1.https://clintonwhitehouse4.archives.gov/Africa/south.html

2.https://kids.britannica.com/students/article/Freedom-Day/607290

3.https://www.gov.za/news/events/commemorative-events/freedom-day-2014

4.https://www.remitly.com/blog/lifestyle-culture/south-africa-freedom-day-history-and-celebrations/

5.https://sahistory.org.za/article/freedom-day-27-april</text>
      <sha1>7ndma7xw8hwg5o00ox1r4nmhznq4zhh</sha1>
    </revision>
    <revision>
      <id>6469</id>
      <parentid>6397</parentid>
      <timestamp>2026-04-18T09:53:52Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the section &quot;__LEAD_SECTION__&quot; from the page &quot;[[:en:Special:Redirect/revision/1341852181|Freedom Day (South Africa)]]&quot;</comment>
      <origin>6469</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4663" sha1="krl5734eybgsyvmro7uuxhfc24wjwp7" xml:space="preserve">[[Isimumathi:Mandela voting in 1994.jpg|thumb|U-Mandela avowuda ngo-1994]]
'''Ilanga lekululeko''' lilanga lokuphumula [[Isewula Afrika|eSewula Afrika]] eligidingwa mhlazi-27 kuSihlabantangana.Ikhumbula ikhetho lokuthoma ngemva kwebandlululo olwenziwa mhlokho ngo-1994 kunye nelanga lapho umthethosisekelo omutjha wethulwa khona.Amakhetho bekumakhetho wokuthoma weentjhabatjhaba lapho woke umuntu oneminyaka yokuvowuda engaphezu kwe-18 ukusuka nanyana ngibuphi ubuzwe bekavunyelwe ukuvowuda.

Ngelinye lamalanga wokuphumula alitjhumi nambili anqunywe mThetho wamaholideyi womphakathi (Nomboro 36 ka-1994) .

Emnyanyeni wokuthoma wokukhumbula iholideyi, uMengameli [[Nelson Mandela|uNelson Mandela]] wakhuluma nePalamende wathi: &lt;blockquote&gt;''Njengoba ukusa okutjha kwaletha ilanga leli, mhlazi-27 kuSihlabantangana 1994,bambalwa kithi ebebangakghona ukugandelela imizwa, njengombana besikhunjuzwa ngesikhathi esidlulileko esimbi esivela kiso njengesitjhaba; amathuba amakhulu esinawo nje;kunye nengomuso elikhanyako elisibizako.Njeke sihlangana lapha namhlanjesi,nakwezinye iindawo zelizwe,ukutshwaya ilanga eliqakathekileko epilweni yesitjhaba sekhethu.Nanyana kukuphi lapho amaSewula Afrika akhona ephasini loke, iinhliziyo zethu zishaya njengenye,njengombana sivuselela ukuthembeka kwethu okufanako enarheni yekhethu nokuzibophelela kwethu esikhathini esizako.''&lt;/blockquote&gt;Ilanga lekululeko mnyanya owenziwa qobe mnyaka mhlazi-27 kuSihlabantangana [[Isewula Afrika|eSewula Afrika]] .Ilanga leli likhumbuza abantu beSewula Afrika ngokuzinikela okukhulu okwenziwe babantu neentjhaba ukuze baphule emaketangeni wokuhlukaniswa okungakalungi ngabantu abambalwa abakhethiweko.Ibakhumbuza ngemizamo yamaqhawe wabo wesitjhaba,khulukhulu [[Nelson Mandela|u-Nelson Mandela]] .Uthathwa njengomlweli wekululeko,ingasi eSewula Afrika kwaphela kodwana ephasini loke.Lilanga elingaphawuli ukutjhaphuluka kwabantu beSewula Afrika ebandlululweni kwaphela kodwana libuyisela amalungelo wabo wobuntu aqakathekileko ngo-1994.


 

'''Ilanga lekululeko''' ISewula Afrika ikhumbula begodu ikhumbula iLanga leTjhaphuluko mhlazi-27 kuMrhayili qobe mnyaka.

Ilanga leli ligubha ukutjhaphuluka kwabantu beSewula Afrika esikhathini eside sobukoloniyali, ibandlululo kanye nokubusa kwabantu abamhlophe abancani ebegade kugxiliswe ziinhlelo lezi. Mhlana amalanga ama-27 kuMrhayili litshwaya ilanga lango-1994, lapho woke amaSewula Afrika, nangaphandle kobuhlanga, ahlanganyele ngokutjhaphulukileko emakhethweni amemezela intando yenengi yethu yomthethosisekelo.&lt;ref&gt;https://www.gov.za/FreedomDay2026&lt;/ref&gt;

Ngelinye lamalanga wokuphumula alitjhumi nambili anqunywe [[Public Holidays Act, 1994|mThetho wamaholideyi womphakathi (Nombolo 36 ka-1994)]] . 

Emnyanyeni wokuthoma wokukhumbula iholideyi, uMengameli [[Nelson Mandela|uNelson Mandela]] wakhuluma nePalamende wathi: &lt;ref&gt;https://sahistory.org.za/node/123212&lt;/ref&gt;&lt;blockquote&gt;''Njengoba ukusa okutjha kwaletha ilanga leli, mhlazi-27 kuMrhayili 1994, bambalwa kithi ebebangakghona ukugandelela imizwa, njengombana besikhunjuzwa ngesikhathi esidlulileko esimbi esivela kiso njengesitjhaba; amathuba amakhulu esinawo nje; kanye nengomuso elikhanyako elisibizako. Njeke sihlangana lapha namhlanjesi, nakwezinye iindawo zelizwe, ukutshwaya ilanga eliqakathekileko epilweni yesitjhaba sekhethu. Nanyana kukuphi lapho amaSewula Afrika akhona ephasini loke, iinhliziyo zethu zishaya njengenye, njengombana sivuselela ukuthembeka kwethu okufanako enarheni yekhethu nokuzibophelela kwethu esikhathini esizako.''&lt;/blockquote&gt;Ilanga lekululeko mnyanya owenziwa qobe mnyaka mhlazi-27 kuMrhayili [[Isewula Afrika|eSewula Afrika]] . Ilanga leli likhumbuza abantu beSewula Afrika ngokuzinikela okukhulu okwenziwe babantu neentjhaba ukuzihlukanisa emaketangeni wokuhlukaniswa okungakalungi ngabantu abambalwa abakhethiweko. Ibakhumbuza ngemizamo yamaqhawe wabo wesitjhaba, khulukhulu [[Nelson Mandela|u-Nelson Mandela]] . Uthathwa njengomlweli wekululeko, ingasi eSewula Afrika kwaphela kodwana ephasini loke. Lilanga elingagcini ngokukhululwa kwabantu beSewula Afrika ebandlululweni kodwana libuyisela amalungelo wabo wobuntu aqakathekileko ngo-1994.&lt;ref&gt;https://www.npr.org/2024/04/27/1247645236/south-africa-remembers-an-historic-election-every-april-27-freedom-day&lt;/ref&gt;

== Iinkomba ==
1.https://clintonwhitehouse4.archives.gov/Africa/south.html

2.https://kids.britannica.com/students/article/Freedom-Day/607290

3.https://www.gov.za/news/events/commemorative-events/freedom-day-2014

4.https://www.remitly.com/blog/lifestyle-culture/south-africa-freedom-day-history-and-celebrations/

5.https://sahistory.org.za/article/freedom-day-27-april</text>
      <sha1>krl5734eybgsyvmro7uuxhfc24wjwp7</sha1>
    </revision>
    <revision>
      <id>6470</id>
      <parentid>6469</parentid>
      <timestamp>2026-04-18T09:57:15Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6470</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2383" sha1="cp3kvrulzc23b9krzx9h0u3qih1mgyz" xml:space="preserve">[[Isimumathi:Mandela voting in 1994.jpg|thumb|U-Mandela avowuda ngo-1994]]
'''Ilanga lekululeko''' lilanga lokuphumula [[Isewula Afrika|eSewula Afrika]] eligidingwa mhlazi-27 kuSihlabantangana.Ikhumbula ikhetho lokuthoma ngemva kwebandlululo olwenziwa mhlokho ngo-1994 kunye nelanga lapho umthethosisekelo omutjha wethulwa khona.Amakhetho bekumakhetho wokuthoma weentjhabatjhaba lapho woke umuntu oneminyaka yokuvowuda engaphezu kwe-18 ukusuka nanyana ngibuphi ubuzwe bekavunyelwe ukuvowuda.

Ngelinye lamalanga wokuphumula alitjhumi nambili anqunywe mThetho wamaholideyi womphakathi (Nomboro 36 ka-1994) .

Emnyanyeni wokuthoma wokukhumbula iholideyi, uMengameli [[Nelson Mandela|uNelson Mandela]] wakhuluma nePalamende wathi: &lt;blockquote&gt;''Njengoba ukusa okutjha kwaletha ilanga leli, mhlazi-27 kuSihlabantangana 1994,bambalwa kithi ebebangakghona ukugandelela imizwa, njengombana besikhunjuzwa ngesikhathi esidlulileko esimbi esivela kiso njengesitjhaba; amathuba amakhulu esinawo nje;kunye nengomuso elikhanyako elisibizako.Njeke sihlangana lapha namhlanjesi,nakwezinye iindawo zelizwe,ukutshwaya ilanga eliqakathekileko epilweni yesitjhaba sekhethu.Nanyana kukuphi lapho amaSewula Afrika akhona ephasini loke, iinhliziyo zethu zishaya njengenye,njengombana sivuselela ukuthembeka kwethu okufanako enarheni yekhethu nokuzibophelela kwethu esikhathini esizako.''&lt;/blockquote&gt;Ilanga lekululeko mnyanya owenziwa qobe mnyaka mhlazi-27 kuSihlabantangana [[Isewula Afrika|eSewula Afrika]] .Ilanga leli likhumbuza abantu beSewula Afrika ngokuzinikela okukhulu okwenziwe babantu neentjhaba ukuze baphule emaketangeni wokuhlukaniswa okungakalungi ngabantu abambalwa abakhethiweko.Ibakhumbuza ngemizamo yamaqhawe wabo wesitjhaba,khulukhulu [[Nelson Mandela|u-Nelson Mandela]] .Uthathwa njengomlweli wekululeko,ingasi eSewula Afrika kwaphela kodwana ephasini loke.Lilanga elingaphawuli ukutjhaphuluka kwabantu beSewula Afrika ebandlululweni kwaphela kodwana libuyisela amalungelo wabo wobuntu aqakathekileko ngo-1994.

== Iinkomba ==
1.https://clintonwhitehouse4.archives.gov/Africa/south.html

2.https://kids.britannica.com/students/article/Freedom-Day/607290

3.https://www.gov.za/news/events/commemorative-events/freedom-day-2014

4.https://www.remitly.com/blog/lifestyle-culture/south-africa-freedom-day-history-and-celebrations/

5.https://sahistory.org.za/article/freedom-day-27-april</text>
      <sha1>cp3kvrulzc23b9krzx9h0u3qih1mgyz</sha1>
    </revision>
    <revision>
      <id>6471</id>
      <parentid>6470</parentid>
      <timestamp>2026-04-18T09:57:54Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6471</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2391" sha1="1ah3ujprcvacg6xalymhe39cw9r0gju" xml:space="preserve">[[Isimumathi:Mandela voting in 1994.jpg|thumb|U-Mandela avowuda ngo-1994]]
'''Ilanga lekululeko''' lilanga lokuphumula [[Isewula Afrika|eSewula Afrika]] eligidingwa mhlazi-27 kuSihlabantangana.Ikhumbula ikhetho lokuthoma ngemva kwebandlululo olwenziwa mhlokho ngo-1994 kunye nelanga lapho umthethosisekelo omutjha wethulwa khona.Amakhetho bekumakhetho wokuthoma weentjhabatjhaba lapho woke umuntu oneminyaka yokuvowuda engaphezu kwe-18 ukusuka nanyana ngibuphi ubuzwe bekavunyelwe ukuvowuda.

Ngelinye lamalanga wokuphumula alitjhumi nambili anqunywe mThetho wamaholideyi womphakathi (Nomboro 36 ka-1994) .

Emnyanyeni wokuthoma wokukhumbula iholideyi, uMengameli [[Nelson Mandela|uNelson Mandela]] wakhuluma nePalamende wathi: &lt;blockquote&gt;''Njengoba ukusa okutjha kwaletha ilanga leli, mhlazi-27 kuSihlabantangana 1994,bambalwa kithi ebebangakghona ukugandelela imizwa, njengombana besikhunjuzwa ngesikhathi esidlulileko esimbi esivela kiso njengesitjhaba; amathuba amakhulu esinawo nje;kunye nengomuso elikhanyako elisibizako.Njeke sihlangana lapha namhlanjesi,nakwezinye iindawo zelizwe,ukutshwaya ilanga eliqakathekileko epilweni yesitjhaba sekhethu.Nanyana kukuphi lapho amaSewula Afrika akhona ephasini loke, iinhliziyo zethu zishaya njengenye,njengombana sivuselela ukuthembeka kwethu okufanako enarheni yekhethu nokuzibophelela kwethu esikhathini esizako.''&lt;/blockquote&gt;Ilanga lekululeko mnyanya owenziwa qobe mnyaka mhlazi-27 kuSihlabantangana [[Isewula Afrika|eSewula Afrika]] .Ilanga leli likhumbuza abantu beSewula Afrika ngokuzinikela okukhulu okwenziwe babantu neentjhaba ukuze baphule emaketangeni wokuhlukaniswa okungakalungi ngabantu abambalwa abakhethiweko.Ibakhumbuza ngemizamo yamaqhawe wabo wesitjhaba,khulukhulu [[Nelson Mandela|u-Nelson Mandela]] .Uthathwa njengomlweli wekululeko,ingasi eSewula Afrika kwaphela kodwana ephasini loke.Lilanga elingaphawuli ukutjhaphuluka kwabantu beSewula Afrika ebandlululweni kwaphela kodwana libuyisela amalungelo wabo wobuntu aqakathekileko ngo-1994.

== Iinkomba ==
1.https://clintonwhitehouse4.archives.gov/Africa/south.html
2.https://kids.britannica.com/students/article/Freedom-Day/607290
3.https://www.gov.za/news/events/commemorative-events/freedom-day-2014
4.https://www.remitly.com/blog/lifestyle-culture/south-africa-freedom-day-history-and-celebrations/
5.https://sahistory.org.za/article/freedom-day-27-april
{{reflist}}</text>
      <sha1>1ah3ujprcvacg6xalymhe39cw9r0gju</sha1>
    </revision>
    <revision>
      <id>6472</id>
      <parentid>6471</parentid>
      <timestamp>2026-04-18T09:59:03Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6472</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2460" sha1="or3pscy457jt9fvfgx6hr9x5dvq8f2r" xml:space="preserve">[[Isimumathi:Mandela voting in 1994.jpg|thumb|U-Mandela avowuda ngo-1994]]
'''Ilanga lekululeko''' lilanga lokuphumula [[Isewula Afrika|eSewula Afrika]] eligidingwa mhlazi-27 kuSihlabantangana.Ikhumbula ikhetho lokuthoma ngemva kwebandlululo olwenziwa mhlokho ngo-1994 kunye nelanga lapho umthethosisekelo omutjha wethulwa khona.Amakhetho bekumakhetho wokuthoma weentjhabatjhaba lapho woke umuntu oneminyaka yokuvowuda engaphezu kwe-18 ukusuka nanyana ngibuphi ubuzwe bekavunyelwe ukuvowuda.

Ngelinye lamalanga wokuphumula alitjhumi nambili anqunywe mThetho wamaholideyi womphakathi (Nomboro 36 ka-1994) .

Emnyanyeni wokuthoma wokukhumbula iholideyi, uMengameli [[Nelson Mandela|uNelson Mandela]] wakhuluma nePalamende wathi: &lt;blockquote&gt;''Njengoba ukusa okutjha kwaletha ilanga leli, mhlazi-27 kuSihlabantangana 1994,bambalwa kithi ebebangakghona ukugandelela imizwa, njengombana besikhunjuzwa ngesikhathi esidlulileko esimbi esivela kiso njengesitjhaba; amathuba amakhulu esinawo nje;kunye nengomuso elikhanyako elisibizako.Njeke sihlangana lapha namhlanjesi,nakwezinye iindawo zelizwe,ukutshwaya ilanga eliqakathekileko epilweni yesitjhaba sekhethu.Nanyana kukuphi lapho amaSewula Afrika akhona ephasini loke, iinhliziyo zethu zishaya njengenye,njengombana sivuselela ukuthembeka kwethu okufanako enarheni yekhethu nokuzibophelela kwethu esikhathini esizako.''&lt;/blockquote&gt;Ilanga lekululeko mnyanya owenziwa qobe mnyaka mhlazi-27 kuSihlabantangana [[Isewula Afrika|eSewula Afrika]] .Ilanga leli likhumbuza abantu beSewula Afrika ngokuzinikela okukhulu okwenziwe babantu neentjhaba ukuze baphule emaketangeni wokuhlukaniswa okungakalungi ngabantu abambalwa abakhethiweko.Ibakhumbuza ngemizamo yamaqhawe wabo wesitjhaba,khulukhulu [[Nelson Mandela|u-Nelson Mandela]] .Uthathwa njengomlweli wekululeko,ingasi eSewula Afrika kwaphela kodwana ephasini loke.Lilanga elingaphawuli ukutjhaphuluka kwabantu beSewula Afrika ebandlululweni kwaphela kodwana libuyisela amalungelo wabo wobuntu aqakathekileko ngo-1994.

== Iinkomba ==
1.https://clintonwhitehouse4.archives.gov/Africa/south.html
2.https://kids.britannica.com/students/article/Freedom-Day/607290
3.https://www.gov.za/news/events/commemorative-events/freedom-day-2014
4.https://www.remitly.com/blog/lifestyle-culture/south-africa-freedom-day-history-and-celebrations/
5.https://sahistory.org.za/article/freedom-day-27-april
{{reflist}}
[[Category:Afrika]]
[[Mkhakha:Sopolitiki]]
[[Mkhakha:Sewula Afrika]]</text>
      <sha1>or3pscy457jt9fvfgx6hr9x5dvq8f2r</sha1>
    </revision>
  </page>
  <page>
    <title>I-Pitori</title>
    <ns>0</ns>
    <id>1088</id>
    <revision>
      <id>6398</id>
      <timestamp>2026-04-07T11:14:48Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1347155334|Pretoria]]&quot;</comment>
      <origin>6398</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6657" sha1="7miqdjwxl9klsg4axfvvv8xjk314cbo" xml:space="preserve">

'''IPITORI''' Njengedorobha elikhulu lokuphatha lenarha,i-Pitori inendlunkulu yayo yoke iminyango karhulumende weentjhaba nama-ejensi.Idorobha libuye libe yindawo ekulu yezokuthintana yephasi loke;likhaya lama-embassy wangaphandle ali-134 kanye namakhomitjhini aphezulu, ajamele ukudzimelela kwesibili ngobukhulu bemisebenzi yezokuxhumana ephasini,edlula i-Washington, DC kwaphela.

I-Pitori yingcenye ephakathi yeDorobha le-Tshwane Metropolitan Municipality elakhiwe ngokuhlanganiswa kwabaphathi bendawo abanengi,okufaka hlangana i-Bronkhorsstpruit,i-Centurion,i-Cullinan,i-Hammanskraal kunye ne -Soshanguve .Abanye baphakamise ukutjhugulula ibizo elisemthethweni ukusuka e-Pitori ukuya ku-Tshwane,okudale ukuphikisana komphakathi.

I-Pitori ibizwa ngomrholi we -Voortrekker [[u-Andries Pretorius]], begodu abantu beSewula Afrika kesinye isikhathi bayibiza ngokuthi &quot;iDorobha le-Jacaranda&quot;,ngebanga leenkulungwana zemithi ye-jacaranda etjalwe ecadi kweendlela zayo kunye namapaki neengadini zayo.

== Umlando ==
I-Pitori yasungulwa ngo-1855 ngu- Marthinus Pretorius, umdosiphambili we- Voortrekkers,owayiqamba ngebizo lakayise [[u-Andries Pretorius]] begodu wakhetha indawo emaphethelweni we- ''Apies rivier'' ( i-Afrikaans okutjho &quot;i-Monkeys river&quot;) bona ibe yikomkhulu elitjha le- South African Republic ( Dutch   ; ZAR).U-Pretorius omdala waba liqhawe lezwe lama-Voortrekkers ngemva kokunqoba kwakhe u -Dingane nama- Zulu ePini ye-Blood River ngo-1838. U-Pretorius omdala naye wakhulumisana nge- Sand River Convention (1852),lapho i-United Kingdom yavuma ukuzijamela kwe- Transvaal .Yaba yidorobha elikhulu leRiphabhliki yeSewula Afrika mhlana ali-1 kuMrhayili wee-1860.

Ukusungulwa kwe-Pitori njengekomkhulu leRiphabhliki yeSewula Afrika kungathathwa njengokuphela kwemizamo yokuhlala yamaBhunu ye- Great Trek .

=== Iipi zamaBhunu ===
Ngesikhathi sePi yokuThoma yamaBhunu,idorobha lavimbezelwa mabutho we-Republican ngoNobayeni 1880 nangoNtaka 1881.Isivumelwano sokuthula esaqeda ipi satlikitlwa e-Pitori mhlazi-3 kuRhoboyi 1881 e- Pitoli Convention .

Ipi yesiBili yamaBhunu yabangela ukuphela kweRiphabhliki ye-Transvaal nokuthoma kobukhosi beBritain eSewula Afrika. Idorobha lazinikela emabuthweni we-Britain ngaphasi kuka -Frederick Roberts mhlazi-5 kuMgwengweni wee-1900 begodu ukulwa kwaphela e-Pitoli ngokutlikitlwa kwe- Peace of Vereeniging mhlazi-31 kuMrhayili wee-1902 e -Melrose House .

Iinqaba ze-Pitori zakhiwa ukuvikela idorobha ngaphambi kwePi yesiBili yamaBhunu.Nanyana ezinye zeenqaba lezi zisemanxiwa,ezinengi zazo zilondolozwe njengezikhumbuzo zesitjhaba.

=== I-Union of South Africa ===
Ama-Boer Republics we-ZAR kanye ne- Orange River Colony ahlanganiswa ne- Cape Colony ne -Natal Colony ngo-1910 kobana abe yi -Union of South Africa.I-Pitori yabe isiba lidolobha elikhulu lokuphatha leSewula Afrika yoke,lapho i-Cape Town yaba yidolobha elikhulu lomthetho begodu i-Bloemfontein yaba yidolobha elikhulu lezokwahlulela. Phakathi kuka-1910 ukuya ku-1994,idorobha beliyinhloko-dolobha yesifunda se -Transvaal .(Njengedolobha elikhulu le-ZAR,i-Pitori beyithathe indawo ye-Potchefstroom kileyo ndima.)Mhlana ali-14 kuSewula 1931,i-Pitori yathola ubujamo bedorobha.Lokha iSewula Afrika nayiba yiriphabhliki ngo-1961,i-Pitori yaba yikomkhulu layo lokuphatha. 

=== Itlayimethi ===
I-Pitori inezulu elinomswakama elinomthelela wezulu ( Köppen : Cwa ) elinehlobo elide elitjhisako,elinezulu,kanye nobusika obufitjhani,obomileko nobungaphasi.Idorobha lihlangabezana nobusika obujayelekileko beSewula Afrika, ubusuku obubandako,obukhanyako kanye namalanga afuthumeleko.Nanyana amazinga aphasi aphakathi ebusika aphasi,angabanda ngebanga lezulu elikhanyako,ebusuku amazinga womtjhiso aphasi eminyakeni esanda kwedlula aphakathi kwama 2 to −5 °C (36 ukuya ku-23 °F) .

Izulu livame khulu eenyangeni zehlobo, kuthi ubujamo besomiso bube khona eenyangeni zebusika,lapho amaqhwa angaba khona khulu. Ukuwa kweqhwa mcimbi ongakavami khulu; amaqhwa abonakala ngo-1959,1968 nango-2012 edorobheni,kodwana idorobha alikaze libe nokubuthelelana emlandwini walo.

=== iinqhema zobuhlanga ===
Ngitjho solo kwaphela ibandlululo,i-Pitori ngokwayo beyinenengi labantu abamhlophe,nanyana kunesigaba esiphakathi esimnyama esikhulako.Kodwana,emalokitjhini we -Mamelodi,Soshanguve kanye ne -Atteridgeville abantu abamnyama benza pheze kibo boke abantu.Isitjhaba esikhulu sabantu abamhlophe ngama- Afrikaners kuthi isitjhaba esikhulu khulu sabantu abamnyama ngama- Bapedi .

Isilinganiso esiphasi senani labantu be-Pitoli sifaka hlangana iindawo ebegade zikhethwe babantu abamhlophe,begodu kunenengi labantu abamhlophe.Kodwana,ukufaka hlangana amalokishi ahlukileko ngokwendawo kwandisa inani labantu be-Pitori ngaphezu kwesigidi begodu kwenza abamhlophe babe mncani.

AmaNdiya we-Pitoli ayalelwe bona asuke e-Pitoli aye e -Laudium mhlazi-6 kuMgwengweni wee-1958. 

== Idorobha ==
I-Pitori yaziwa ngokuthi &quot;yiDorobha le-Jacaranda&quot; ngebanga lama -Jacaranda angaba ma-60,000-70,000 asezindleleni zayo.Umbala ophephuli umbala ovame ukuhlotjaniswa nedorobha begodu uvame ukufakwa emalogoni womkhandlu wendawo kanye namasevisi afana nehlelo lamabhasi we -A Re Yeng arhabako kanye nelogo yesitetjhi somrhatjho wendawo we-Jacaranda FM .

=== Imakhiwo ===
I-Pitori eminyakeni edlulileko ibe namathonya wamasiko ahlukahlukeneko begodu lokhu kubonakala ngeendlela zokwakha ezingatholakala edorobheni.Isukela ekwakheni kwekhulu le-19 le-Dutch,i-German kanye ne-Britain ukuya ekwakhiweni kwesimanjemanje,kwe-postmodern,kwe-neomodern,kanye ne-art deco ngokuhlanganiswa okuhle kwesitayera esihlukileko seSewula Afrika.

Ezinye zemakhiwo eziqakathekileko e-Pitori zifaka hlangana i-Palace of Justice yangokuphela kwekhulu le-19,i-Union Buildings yangeminyaka yokuthoma yekhulu le-20,i- Voortrekker Monument yangemuva kwepi,imakhiwo ezihlukahlukeneko ezigcwele amakhampasi amakhulu we- [[IYunivesithi ye-Pretoria|University of Pretoria]] ne- University of South Africa,isitayera sesiko se-Cape Dutch u-Mahlambad (Nthefup ),iNdlu kaMongameli I-Neo-Byzantine Old Synagogue, i- Reserve Bank of South Africa yesimanjemanje (i-ofisi ephezulu) kanye ne-Telkom Lukasrand Tower .Eminye imakhiwo nezakhiwo ezaziwako zifaka hlangana i -Loftus Versfeld Stadium,i-South African State Theatre kanye nesakhiwo se-Oliver Tambo esiyiNdlunkulu yomNyango wezobudlelwano namazwe ngamazwe .

== Iinkomba ==
1.https://www.britannica.com/place/Pretoria

2.https://sahistory.org.za/place/pretoria-now-known-tshwane

3.https://www.sa-venues.com/attractionsga/pretoria-metro.htm

4.https://www.southafrica.net/gl/en/travel/category/places-to-go/big-city-life/pretoria

5.https://www.up.ac.za/</text>
      <sha1>7miqdjwxl9klsg4axfvvv8xjk314cbo</sha1>
    </revision>
    <revision>
      <id>6399</id>
      <parentid>6398</parentid>
      <timestamp>2026-04-07T11:16:40Z</timestamp>
      <contributor>
        <username>Jetro mahlangu</username>
        <id>588</id>
      </contributor>
      <comment>ngifake isithombe esitjha</comment>
      <origin>6399</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6711" sha1="1jwwwynprs3vjamk9rbf3usx643idx8" xml:space="preserve">[[Isimumathi:Pretoria CBD1.jpg|thumb|I-CBD ye-Pitori]]

'''IPITORI''' Njengedorobha elikhulu lokuphatha lenarha,i-Pitori inendlunkulu yayo yoke iminyango karhulumende weentjhaba nama-ejensi.Idorobha libuye libe yindawo ekulu yezokuthintana yephasi loke;likhaya lama-embassy wangaphandle ali-134 kanye namakhomitjhini aphezulu, ajamele ukudzimelela kwesibili ngobukhulu bemisebenzi yezokuxhumana ephasini,edlula i-Washington, DC kwaphela.

I-Pitori yingcenye ephakathi yeDorobha le-Tshwane Metropolitan Municipality elakhiwe ngokuhlanganiswa kwabaphathi bendawo abanengi,okufaka hlangana i-Bronkhorsstpruit,i-Centurion,i-Cullinan,i-Hammanskraal kunye ne -Soshanguve .Abanye baphakamise ukutjhugulula ibizo elisemthethweni ukusuka e-Pitori ukuya ku-Tshwane,okudale ukuphikisana komphakathi.

I-Pitori ibizwa ngomrholi we -Voortrekker [[u-Andries Pretorius]], begodu abantu beSewula Afrika kesinye isikhathi bayibiza ngokuthi &quot;iDorobha le-Jacaranda&quot;,ngebanga leenkulungwana zemithi ye-jacaranda etjalwe ecadi kweendlela zayo kunye namapaki neengadini zayo.

== Umlando ==
I-Pitori yasungulwa ngo-1855 ngu- Marthinus Pretorius, umdosiphambili we- Voortrekkers,owayiqamba ngebizo lakayise [[u-Andries Pretorius]] begodu wakhetha indawo emaphethelweni we- ''Apies rivier'' ( i-Afrikaans okutjho &quot;i-Monkeys river&quot;) bona ibe yikomkhulu elitjha le- South African Republic ( Dutch   ; ZAR).U-Pretorius omdala waba liqhawe lezwe lama-Voortrekkers ngemva kokunqoba kwakhe u -Dingane nama- Zulu ePini ye-Blood River ngo-1838. U-Pretorius omdala naye wakhulumisana nge- Sand River Convention (1852),lapho i-United Kingdom yavuma ukuzijamela kwe- Transvaal .Yaba yidorobha elikhulu leRiphabhliki yeSewula Afrika mhlana ali-1 kuMrhayili wee-1860.

Ukusungulwa kwe-Pitori njengekomkhulu leRiphabhliki yeSewula Afrika kungathathwa njengokuphela kwemizamo yokuhlala yamaBhunu ye- Great Trek .

=== Iipi zamaBhunu ===
Ngesikhathi sePi yokuThoma yamaBhunu,idorobha lavimbezelwa mabutho we-Republican ngoNobayeni 1880 nangoNtaka 1881.Isivumelwano sokuthula esaqeda ipi satlikitlwa e-Pitori mhlazi-3 kuRhoboyi 1881 e- Pitoli Convention .

Ipi yesiBili yamaBhunu yabangela ukuphela kweRiphabhliki ye-Transvaal nokuthoma kobukhosi beBritain eSewula Afrika. Idorobha lazinikela emabuthweni we-Britain ngaphasi kuka -Frederick Roberts mhlazi-5 kuMgwengweni wee-1900 begodu ukulwa kwaphela e-Pitoli ngokutlikitlwa kwe- Peace of Vereeniging mhlazi-31 kuMrhayili wee-1902 e -Melrose House .

Iinqaba ze-Pitori zakhiwa ukuvikela idorobha ngaphambi kwePi yesiBili yamaBhunu.Nanyana ezinye zeenqaba lezi zisemanxiwa,ezinengi zazo zilondolozwe njengezikhumbuzo zesitjhaba.

=== I-Union of South Africa ===
Ama-Boer Republics we-ZAR kanye ne- Orange River Colony ahlanganiswa ne- Cape Colony ne -Natal Colony ngo-1910 kobana abe yi -Union of South Africa.I-Pitori yabe isiba lidolobha elikhulu lokuphatha leSewula Afrika yoke,lapho i-Cape Town yaba yidolobha elikhulu lomthetho begodu i-Bloemfontein yaba yidolobha elikhulu lezokwahlulela. Phakathi kuka-1910 ukuya ku-1994,idorobha beliyinhloko-dolobha yesifunda se -Transvaal .(Njengedolobha elikhulu le-ZAR,i-Pitori beyithathe indawo ye-Potchefstroom kileyo ndima.)Mhlana ali-14 kuSewula 1931,i-Pitori yathola ubujamo bedorobha.Lokha iSewula Afrika nayiba yiriphabhliki ngo-1961,i-Pitori yaba yikomkhulu layo lokuphatha. 

=== Itlayimethi ===
I-Pitori inezulu elinomswakama elinomthelela wezulu ( Köppen : Cwa ) elinehlobo elide elitjhisako,elinezulu,kanye nobusika obufitjhani,obomileko nobungaphasi.Idorobha lihlangabezana nobusika obujayelekileko beSewula Afrika, ubusuku obubandako,obukhanyako kanye namalanga afuthumeleko.Nanyana amazinga aphasi aphakathi ebusika aphasi,angabanda ngebanga lezulu elikhanyako,ebusuku amazinga womtjhiso aphasi eminyakeni esanda kwedlula aphakathi kwama 2 to −5 °C (36 ukuya ku-23 °F) .

Izulu livame khulu eenyangeni zehlobo, kuthi ubujamo besomiso bube khona eenyangeni zebusika,lapho amaqhwa angaba khona khulu. Ukuwa kweqhwa mcimbi ongakavami khulu; amaqhwa abonakala ngo-1959,1968 nango-2012 edorobheni,kodwana idorobha alikaze libe nokubuthelelana emlandwini walo.

=== iinqhema zobuhlanga ===
Ngitjho solo kwaphela ibandlululo,i-Pitori ngokwayo beyinenengi labantu abamhlophe,nanyana kunesigaba esiphakathi esimnyama esikhulako.Kodwana,emalokitjhini we -Mamelodi,Soshanguve kanye ne -Atteridgeville abantu abamnyama benza pheze kibo boke abantu.Isitjhaba esikhulu sabantu abamhlophe ngama- Afrikaners kuthi isitjhaba esikhulu khulu sabantu abamnyama ngama- Bapedi .

Isilinganiso esiphasi senani labantu be-Pitoli sifaka hlangana iindawo ebegade zikhethwe babantu abamhlophe,begodu kunenengi labantu abamhlophe.Kodwana,ukufaka hlangana amalokishi ahlukileko ngokwendawo kwandisa inani labantu be-Pitori ngaphezu kwesigidi begodu kwenza abamhlophe babe mncani.

AmaNdiya we-Pitoli ayalelwe bona asuke e-Pitoli aye e -Laudium mhlazi-6 kuMgwengweni wee-1958. 

== Idorobha ==
I-Pitori yaziwa ngokuthi &quot;yiDorobha le-Jacaranda&quot; ngebanga lama -Jacaranda angaba ma-60,000-70,000 asezindleleni zayo.Umbala ophephuli umbala ovame ukuhlotjaniswa nedorobha begodu uvame ukufakwa emalogoni womkhandlu wendawo kanye namasevisi afana nehlelo lamabhasi we -A Re Yeng arhabako kanye nelogo yesitetjhi somrhatjho wendawo we-Jacaranda FM .

=== Imakhiwo ===
I-Pitori eminyakeni edlulileko ibe namathonya wamasiko ahlukahlukeneko begodu lokhu kubonakala ngeendlela zokwakha ezingatholakala edorobheni.Isukela ekwakheni kwekhulu le-19 le-Dutch,i-German kanye ne-Britain ukuya ekwakhiweni kwesimanjemanje,kwe-postmodern,kwe-neomodern,kanye ne-art deco ngokuhlanganiswa okuhle kwesitayera esihlukileko seSewula Afrika.

Ezinye zemakhiwo eziqakathekileko e-Pitori zifaka hlangana i-Palace of Justice yangokuphela kwekhulu le-19,i-Union Buildings yangeminyaka yokuthoma yekhulu le-20,i- Voortrekker Monument yangemuva kwepi,imakhiwo ezihlukahlukeneko ezigcwele amakhampasi amakhulu we- [[IYunivesithi ye-Pretoria|University of Pretoria]] ne- University of South Africa,isitayera sesiko se-Cape Dutch u-Mahlambad (Nthefup ),iNdlu kaMongameli I-Neo-Byzantine Old Synagogue, i- Reserve Bank of South Africa yesimanjemanje (i-ofisi ephezulu) kanye ne-Telkom Lukasrand Tower .Eminye imakhiwo nezakhiwo ezaziwako zifaka hlangana i -Loftus Versfeld Stadium,i-South African State Theatre kanye nesakhiwo se-Oliver Tambo esiyiNdlunkulu yomNyango wezobudlelwano namazwe ngamazwe .

== Iinkomba ==
1.https://www.britannica.com/place/Pretoria

2.https://sahistory.org.za/place/pretoria-now-known-tshwane

3.https://www.sa-venues.com/attractionsga/pretoria-metro.htm

4.https://www.southafrica.net/gl/en/travel/category/places-to-go/big-city-life/pretoria

5.https://www.up.ac.za/</text>
      <sha1>1jwwwynprs3vjamk9rbf3usx643idx8</sha1>
    </revision>
    <revision>
      <id>6703</id>
      <parentid>6399</parentid>
      <timestamp>2026-06-12T08:34:15Z</timestamp>
      <contributor>
        <username>MissHadassah</username>
        <id>1561</id>
      </contributor>
      <comment>changed formatting</comment>
      <origin>6703</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6717" sha1="q5c7ntns24g3lew7w3vmr6zztyttg5f" xml:space="preserve">[[Isimumathi:Pretoria CBD1.jpg|thumb|I-CBD ye-Pitori]]

'''IPITORI''' Njengedorobha elikhulu lokuphatha lenarha,i-Pitori inendlunkulu yayo yoke iminyango karhulumende weentjhaba nama-ejensi.Idorobha libuye libe yindawo ekulu yezokuthintana yephasi loke;likhaya lama-embassy wangaphandle ali-134 kanye namakhomitjhini aphezulu, ajamele ukudzimelela kwesibili ngobukhulu bemisebenzi yezokuxhumana ephasini,edlula i-Washington, DC kwaphela.

I-Pitori yingcenye ephakathi yeDorobha le-Tshwane Metropolitan Municipality elakhiwe ngokuhlanganiswa kwabaphathi bendawo abanengi,okufaka hlangana i-Bronkhorsstpruit,i-Centurion,i-Cullinan,i-Hammanskraal kunye ne -Soshanguve .Abanye baphakamise ukutjhugulula ibizo elisemthethweni ukusuka e-Pitori ukuya ku-Tshwane,okudale ukuphikisana komphakathi.

I-Pitori ibizwa ngomrholi we -Voortrekker [[u-Andries Pretorius]], begodu abantu beSewula Afrika kesinye isikhathi bayibiza ngokuthi &quot;iDorobha le-Jacaranda&quot;,ngebanga leenkulungwana zemithi ye-jacaranda etjalwe ecadi kweendlela zayo kunye namapaki neengadini zayo.

== '''Umlando''' ==
I-Pitori yasungulwa ngo-1855 ngu- Marthinus Pretorius, umdosiphambili we- Voortrekkers,owayiqamba ngebizo lakayise [[u-Andries Pretorius]] begodu wakhetha indawo emaphethelweni we- ''Apies rivier'' ( i-Afrikaans okutjho &quot;i-Monkeys river&quot;) bona ibe yikomkhulu elitjha le- South African Republic ( Dutch   ; ZAR).U-Pretorius omdala waba liqhawe lezwe lama-Voortrekkers ngemva kokunqoba kwakhe u -Dingane nama- Zulu ePini ye-Blood River ngo-1838. U-Pretorius omdala naye wakhulumisana nge- Sand River Convention (1852),lapho i-United Kingdom yavuma ukuzijamela kwe- Transvaal .Yaba yidorobha elikhulu leRiphabhliki yeSewula Afrika mhlana ali-1 kuMrhayili wee-1860.

Ukusungulwa kwe-Pitori njengekomkhulu leRiphabhliki yeSewula Afrika kungathathwa njengokuphela kwemizamo yokuhlala yamaBhunu ye- Great Trek .

=== Iipi zamaBhunu ===
Ngesikhathi sePi yokuThoma yamaBhunu,idorobha lavimbezelwa mabutho we-Republican ngoNobayeni 1880 nangoNtaka 1881.Isivumelwano sokuthula esaqeda ipi satlikitlwa e-Pitori mhlazi-3 kuRhoboyi 1881 e- Pitoli Convention .

Ipi yesiBili yamaBhunu yabangela ukuphela kweRiphabhliki ye-Transvaal nokuthoma kobukhosi beBritain eSewula Afrika. Idorobha lazinikela emabuthweni we-Britain ngaphasi kuka -Frederick Roberts mhlazi-5 kuMgwengweni wee-1900 begodu ukulwa kwaphela e-Pitoli ngokutlikitlwa kwe- Peace of Vereeniging mhlazi-31 kuMrhayili wee-1902 e -Melrose House .

Iinqaba ze-Pitori zakhiwa ukuvikela idorobha ngaphambi kwePi yesiBili yamaBhunu.Nanyana ezinye zeenqaba lezi zisemanxiwa,ezinengi zazo zilondolozwe njengezikhumbuzo zesitjhaba.

=== I-Union of South Africa ===
Ama-Boer Republics we-ZAR kanye ne- Orange River Colony ahlanganiswa ne- Cape Colony ne -Natal Colony ngo-1910 kobana abe yi -Union of South Africa.I-Pitori yabe isiba lidolobha elikhulu lokuphatha leSewula Afrika yoke,lapho i-Cape Town yaba yidolobha elikhulu lomthetho begodu i-Bloemfontein yaba yidolobha elikhulu lezokwahlulela. Phakathi kuka-1910 ukuya ku-1994,idorobha beliyinhloko-dolobha yesifunda se -Transvaal .(Njengedolobha elikhulu le-ZAR,i-Pitori beyithathe indawo ye-Potchefstroom kileyo ndima.)Mhlana ali-14 kuSewula 1931,i-Pitori yathola ubujamo bedorobha.Lokha iSewula Afrika nayiba yiriphabhliki ngo-1961,i-Pitori yaba yikomkhulu layo lokuphatha. 

=== Itlayimethi ===
I-Pitori inezulu elinomswakama elinomthelela wezulu ( Köppen : Cwa ) elinehlobo elide elitjhisako,elinezulu,kanye nobusika obufitjhani,obomileko nobungaphasi.Idorobha lihlangabezana nobusika obujayelekileko beSewula Afrika, ubusuku obubandako,obukhanyako kanye namalanga afuthumeleko.Nanyana amazinga aphasi aphakathi ebusika aphasi,angabanda ngebanga lezulu elikhanyako,ebusuku amazinga womtjhiso aphasi eminyakeni esanda kwedlula aphakathi kwama 2 to −5 °C (36 ukuya ku-23 °F) .

Izulu livame khulu eenyangeni zehlobo, kuthi ubujamo besomiso bube khona eenyangeni zebusika,lapho amaqhwa angaba khona khulu. Ukuwa kweqhwa mcimbi ongakavami khulu; amaqhwa abonakala ngo-1959,1968 nango-2012 edorobheni,kodwana idorobha alikaze libe nokubuthelelana emlandwini walo.

=== iinqhema zobuhlanga ===
Ngitjho solo kwaphela ibandlululo,i-Pitori ngokwayo beyinenengi labantu abamhlophe,nanyana kunesigaba esiphakathi esimnyama esikhulako.Kodwana,emalokitjhini we -Mamelodi,Soshanguve kanye ne -Atteridgeville abantu abamnyama benza pheze kibo boke abantu.Isitjhaba esikhulu sabantu abamhlophe ngama- Afrikaners kuthi isitjhaba esikhulu khulu sabantu abamnyama ngama- Bapedi .

Isilinganiso esiphasi senani labantu be-Pitoli sifaka hlangana iindawo ebegade zikhethwe babantu abamhlophe,begodu kunenengi labantu abamhlophe.Kodwana,ukufaka hlangana amalokishi ahlukileko ngokwendawo kwandisa inani labantu be-Pitori ngaphezu kwesigidi begodu kwenza abamhlophe babe mncani.

AmaNdiya we-Pitoli ayalelwe bona asuke e-Pitoli aye e -Laudium mhlazi-6 kuMgwengweni wee-1958. 

== Idorobha ==
I-Pitori yaziwa ngokuthi &quot;yiDorobha le-Jacaranda&quot; ngebanga lama -Jacaranda angaba ma-60,000-70,000 asezindleleni zayo.Umbala ophephuli umbala ovame ukuhlotjaniswa nedorobha begodu uvame ukufakwa emalogoni womkhandlu wendawo kanye namasevisi afana nehlelo lamabhasi we -A Re Yeng arhabako kanye nelogo yesitetjhi somrhatjho wendawo we-Jacaranda FM .

=== Imakhiwo ===
I-Pitori eminyakeni edlulileko ibe namathonya wamasiko ahlukahlukeneko begodu lokhu kubonakala ngeendlela zokwakha ezingatholakala edorobheni.Isukela ekwakheni kwekhulu le-19 le-Dutch,i-German kanye ne-Britain ukuya ekwakhiweni kwesimanjemanje,kwe-postmodern,kwe-neomodern,kanye ne-art deco ngokuhlanganiswa okuhle kwesitayera esihlukileko seSewula Afrika.

Ezinye zemakhiwo eziqakathekileko e-Pitori zifaka hlangana i-Palace of Justice yangokuphela kwekhulu le-19,i-Union Buildings yangeminyaka yokuthoma yekhulu le-20,i- Voortrekker Monument yangemuva kwepi,imakhiwo ezihlukahlukeneko ezigcwele amakhampasi amakhulu we- [[IYunivesithi ye-Pretoria|University of Pretoria]] ne- University of South Africa,isitayera sesiko se-Cape Dutch u-Mahlambad (Nthefup ),iNdlu kaMongameli I-Neo-Byzantine Old Synagogue, i- Reserve Bank of South Africa yesimanjemanje (i-ofisi ephezulu) kanye ne-Telkom Lukasrand Tower .Eminye imakhiwo nezakhiwo ezaziwako zifaka hlangana i -Loftus Versfeld Stadium,i-South African State Theatre kanye nesakhiwo se-Oliver Tambo esiyiNdlunkulu yomNyango wezobudlelwano namazwe ngamazwe .

== Iinkomba ==
1.https://www.britannica.com/place/Pretoria

2.https://sahistory.org.za/place/pretoria-now-known-tshwane

3.https://www.sa-venues.com/attractionsga/pretoria-metro.htm

4.https://www.southafrica.net/gl/en/travel/category/places-to-go/big-city-life/pretoria

5.https://www.up.ac.za/</text>
      <sha1>q5c7ntns24g3lew7w3vmr6zztyttg5f</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:James500</title>
    <ns>2</ns>
    <id>1089</id>
    <revision>
      <id>6400</id>
      <timestamp>2026-04-08T23:55:22Z</timestamp>
      <contributor>
        <username>James500</username>
        <id>1462</id>
      </contributor>
      <comment>Create user page</comment>
      <origin>6400</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="18" sha1="p9gqo5rjl4vxuw9szfm7xl7vr4fshof" xml:space="preserve">{{#babel:en|nr-0}}</text>
      <sha1>p9gqo5rjl4vxuw9szfm7xl7vr4fshof</sha1>
    </revision>
    <revision>
      <id>6401</id>
      <parentid>6400</parentid>
      <timestamp>2026-04-08T23:56:08Z</timestamp>
      <contributor>
        <username>James500</username>
        <id>1462</id>
      </contributor>
      <comment>Add interwiki link</comment>
      <origin>6401</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="40" sha1="dfwzbejnxi5z2o4y9omkve7dwivh5r1" xml:space="preserve">{{#babel:en|nr-0}}

[[en:User:James500]]</text>
      <sha1>dfwzbejnxi5z2o4y9omkve7dwivh5r1</sha1>
    </revision>
    <revision>
      <id>6492</id>
      <parentid>6401</parentid>
      <timestamp>2026-04-30T17:07:57Z</timestamp>
      <contributor>
        <username>James500</username>
        <id>1462</id>
      </contributor>
      <comment>Remove template</comment>
      <origin>6492</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="35" sha1="eu13so1xoub6xvcjld6yea9o5qsrodx" xml:space="preserve">{{#babel:en}}

[[en:User:James500]]</text>
      <sha1>eu13so1xoub6xvcjld6yea9o5qsrodx</sha1>
    </revision>
  </page>
  <page>
    <title>Roelf Meyer</title>
    <ns>0</ns>
    <id>1090</id>
    <revision>
      <id>6412</id>
      <timestamp>2026-04-15T02:31:37Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1348918894|Roelf Meyer]]&quot;</comment>
      <origin>6412</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3204" sha1="89rdzle84pj6j0sbxgq1zm3mfla220k" xml:space="preserve">
U '''-Roelof Petrus Meyer''' &lt;small&gt;GCOB&lt;/small&gt; (wabelethwa mhlana ali-16 kuNtaka 1947) usopolotiki weSewula Afrika nosomabhizinisi. Ilunga lePalamende hlangana nomnyaka ka-1979 ukuya ku-1997, bekangumkhulumeli omkhulu karhulumende we-National Party ngesikhathi seengcoco zokuqeda ibandlululo . Ngokukhamba kwesikhathi wasungula i -United Democratic Movement .

Ngesikhathi sakhe ePalamende, u-Meyer wakhonza kurhulumende wabomongameli abathathu abalandelanako: u-PW Botha, u-FW de Klerk, no [[Nelson Mandela|-Nelson Mandela]] . Ngemva kokutjhiya i-National Party ngo-1997, wasungula i-United Democratic Movement no [[Bantu Holomisa|-Bantu Holomisa]] . Wabuyela isikhatjhana ePalamende hlangana nomnyaka ka-1999 ukuya ku-2000 ngaphambi kobana athathe umhlalaphasi kezepolotiki yangaphambili ngoTjhirhweni 2000.

== Ipilo yokuthoma nefundo ==
U-Meyer, indodana encani yomlimi we-Eastern Cape, u-Hudson Meyer notitjhere wesikolo u-Hannah Meyer, ozalwa ngu-van Heerden, waya esikolweni e -Ficksburg begodu wafunda umthetho e- University of the Free State, lapho aqeda khona amadigri we-B Comm (1968) kanye ne -LLB (1971). Eyunivesithi, bekangumongameli we-&quot;Afrikaanse Studentebond&quot; ongatjhugulukiko. Ngesikhathi sokusebenza kwakhe ebuthweni, bekalilunga lekhwaya ye -SADF eyaziwa nangokuthi &quot;ama-Kanaries&quot;. U-Meyer wasebenza njengegqwetha e -Pitoli ne [[Johannesburg|-Goli]] bekwaba ngu-1980.

=== Iingcoco zokuqeda ibandlululo ===
U-Meyer waduma ngesikhundla sakhe sokuba mkhulumeli omkhulu karhulumende ku- Multiparty Negotiating Forum ngo-1993 ngemva kokubhalelwa kwe -CODESA lapho asungula khona ubudlelwano obuhle nobusebenzako nomkhulumeli omkhulu we -ANC, u-Cyril Ramaphosa .  Kilesi sikhundla, wasebenza eduze no -Niel Barnard, obekayinhloko ye-National Intelligence Service begodu amsekeli oqinileko wesivumelwano.  Ngemva kokuphethwa kweengcoco ngoNovemba 1993, waba mjameli omkhulu karhulumende ku- Transitional Executive Council (TEC). U-Meyer no-Ramaphosa bathola i-South African Breweries Leadership and Service Award ngo-2004. 

== Umsebenzi wezepolotiki wangemva kwebandlululo ==
Emakhethweni wokuthoma weSewula Afrika ngemva kwebandlululo ngoRhoboyi wee-1994, u-Meyer wakhethwa e- National Assembly etja, begodu uMengameli [[Nelson Mandela|u-Nelson Mandela]] wamkhetha njengoNgqongqotjhe wezokuThuthukiswa komThethosisekelo nezePhrovinsi kuRhulumende weNarha oneenhlangano ezinengi.  Umfowabo omdala u-Tobie Meyer bekanguSekela likaNgqongqotjhe wezokuLima nezeHlabathi kurhulumende ofanako.  NjengoNgqongqotjhe, u-Meyer wasebenza godu no-Cyril Ramaphosa, obekangusihlalo we -Constitutional Assembly ebegade anikelwe umsebenzi wokuqinisekisa umThethosisekelo wangemva kwebandlululo . 

NgoNhlolanja 1996, u-Meyer watjhiya isikhundla sekhabhinethi ukwenzela bona abe ngunobhala-jikelele we-National Party.[1] Ngebanga lokuragela phambili nokuthakazelela ukutjhugulula i-National Party, wahlala amuntu ongathandwako hlangana nephiko le-right wing le-party, ngesikhatheso ebelidoswa ngokungakahleleki ngu-Hernus Kriel.[2][3] Kwamambala, u-Meyer no-Kriel gade baphikisana tjhatjhalazi esikhathini esidlulileko.[4]
[[Mkhakha:Sopolitiki]]
[[Mkhakha:Sewula Afrika]]
[[Mkhakha:Amalungelo wobuntu]]</text>
      <sha1>89rdzle84pj6j0sbxgq1zm3mfla220k</sha1>
    </revision>
    <revision>
      <id>6413</id>
      <parentid>6412</parentid>
      <timestamp>2026-04-15T02:35:39Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6413</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3224" sha1="3ckyj8g8xmoplbk26zxm6kmyvc5cnb3" xml:space="preserve">
U '''-Roelof Petrus Meyer''' &lt;small&gt;GCOB&lt;/small&gt; (wabelethwa mhlana ali-16 kuNtaka 1947) usopolotiki weSewula Afrika nosomabhizinisi. Ilunga lePalamende hlangana nomnyaka ka-1979 ukuya ku-1997, bekangumkhulumeli omkhulu karhulumende we-[[INational Party|National Party]] ngesikhathi seengcoco zokuqeda ibandlululo . Ngokukhamba kwesikhathi wasungula i -United Democratic Movement .

Ngesikhathi sakhe ePalamende, u-Meyer wakhonza kurhulumende wabomongameli abathathu abalandelanako: u-PW Botha, u-FW de Klerk, no [[Nelson Mandela|-Nelson Mandela]] . Ngemva kokutjhiya i-National Party ngo-1997, wasungula i-United Democratic Movement no [[Bantu Holomisa|-Bantu Holomisa]] . Wabuyela isikhatjhana ePalamende hlangana nomnyaka ka-1999 ukuya ku-2000 ngaphambi kobana athathe umhlalaphasi kezepolotiki yangaphambili ngoTjhirhweni 2000.

== Ipilo yokuthoma nefundo ==
U-Meyer, indodana encani yomlimi we-Eastern Cape, u-Hudson Meyer notitjhere wesikolo u-Hannah Meyer, ozalwa ngu-van Heerden, waya esikolweni e -Ficksburg begodu wafunda umthetho e- University of the Free State, lapho aqeda khona amadigri we-B Comm (1968) kanye ne -LLB (1971). Eyunivesithi, bekangumongameli we-&quot;Afrikaanse Studentebond&quot; ongatjhugulukiko. Ngesikhathi sokusebenza kwakhe ebuthweni, bekalilunga lekhwaya ye -SADF eyaziwa nangokuthi &quot;ama-Kanaries&quot;. U-Meyer wasebenza njengegqwetha e -Pitoli ne [[Johannesburg|-Goli]] bekwaba ngu-1980.

=== Iingcoco zokuqeda ibandlululo ===
U-Meyer waduma ngesikhundla sakhe sokuba mkhulumeli omkhulu karhulumende ku- Multiparty Negotiating Forum ngo-1993 ngemva kokubhalelwa kwe -CODESA lapho asungula khona ubudlelwano obuhle nobusebenzako nomkhulumeli omkhulu we -ANC, u-Cyril Ramaphosa .  Kilesi sikhundla, wasebenza eduze no -Niel Barnard, obekayinhloko ye-National Intelligence Service begodu amsekeli oqinileko wesivumelwano.  Ngemva kokuphethwa kweengcoco ngoNovemba 1993, waba mjameli omkhulu karhulumende ku- Transitional Executive Council (TEC). U-Meyer no-Ramaphosa bathola i-South African Breweries Leadership and Service Award ngo-2004. 

== Umsebenzi wezepolotiki wangemva kwebandlululo ==
Emakhethweni wokuthoma weSewula Afrika ngemva kwebandlululo ngoRhoboyi wee-1994, u-Meyer wakhethwa e- National Assembly etja, begodu uMengameli [[Nelson Mandela|u-Nelson Mandela]] wamkhetha njengoNgqongqotjhe wezokuThuthukiswa komThethosisekelo nezePhrovinsi kuRhulumende weNarha oneenhlangano ezinengi.  Umfowabo omdala u-Tobie Meyer bekanguSekela likaNgqongqotjhe wezokuLima nezeHlabathi kurhulumende ofanako.  NjengoNgqongqotjhe, u-Meyer wasebenza godu no-Cyril Ramaphosa, obekangusihlalo we -Constitutional Assembly ebegade anikelwe umsebenzi wokuqinisekisa umThethosisekelo wangemva kwebandlululo . 

NgoNhlolanja 1996, u-Meyer watjhiya isikhundla sekhabhinethi ukwenzela bona abe ngunobhala-jikelele we-National Party.[1] Ngebanga lokuragela phambili nokuthakazelela ukutjhugulula i-National Party, wahlala amuntu ongathandwako hlangana nephiko le-right wing le-party, ngesikhatheso ebelidoswa ngokungakahleleki ngu-Hernus Kriel.[2][3] Kwamambala, u-Meyer no-Kriel gade baphikisana tjhatjhalazi esikhathini esidlulileko.[4]
[[Mkhakha:Sopolitiki]]
[[Mkhakha:Sewula Afrika]]
[[Mkhakha:Amalungelo wobuntu]]</text>
      <sha1>3ckyj8g8xmoplbk26zxm6kmyvc5cnb3</sha1>
    </revision>
    <revision>
      <id>6414</id>
      <parentid>6413</parentid>
      <timestamp>2026-04-15T02:36:22Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6414</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3342" sha1="298mp6kowqtg7au9hi1dddczi4zt5y2" xml:space="preserve">
U '''-Roelof Petrus Meyer''' &lt;small&gt;GCOB&lt;/small&gt; (wabelethwa mhlana ali-16 kuNtaka 1947) usopolotiki weSewula Afrika nosomabhizinisi. Ilunga lePalamende hlangana nomnyaka ka-1979 ukuya ku-1997, bekangumkhulumeli omkhulu karhulumende we-[[INational Party|National Party]] ngesikhathi seengcoco zokuqeda ibandlululo . Ngokukhamba kwesikhathi wasungula i -United Democratic Movement .&lt;ref&gt;https://www.dailymaverick.co.za/article/2019-01-30-roelf-meyer-is-back-and-trying-to-help-save-sas-economy/&lt;/ref&gt;

Ngesikhathi sakhe ePalamende, u-Meyer wakhonza kurhulumende wabomongameli abathathu abalandelanako: u-PW Botha, u-FW de Klerk, no [[Nelson Mandela|-Nelson Mandela]] . Ngemva kokutjhiya i-National Party ngo-1997, wasungula i-United Democratic Movement no [[Bantu Holomisa|-Bantu Holomisa]] . Wabuyela isikhatjhana ePalamende hlangana nomnyaka ka-1999 ukuya ku-2000 ngaphambi kobana athathe umhlalaphasi kezepolotiki yangaphambili ngoTjhirhweni 2000.

== Ipilo yokuthoma nefundo ==
U-Meyer, indodana encani yomlimi we-Eastern Cape, u-Hudson Meyer notitjhere wesikolo u-Hannah Meyer, ozalwa ngu-van Heerden, waya esikolweni e -Ficksburg begodu wafunda umthetho e- University of the Free State, lapho aqeda khona amadigri we-B Comm (1968) kanye ne -LLB (1971). Eyunivesithi, bekangumongameli we-&quot;Afrikaanse Studentebond&quot; ongatjhugulukiko. Ngesikhathi sokusebenza kwakhe ebuthweni, bekalilunga lekhwaya ye -SADF eyaziwa nangokuthi &quot;ama-Kanaries&quot;. U-Meyer wasebenza njengegqwetha e -Pitoli ne [[Johannesburg|-Goli]] bekwaba ngu-1980.

=== Iingcoco zokuqeda ibandlululo ===
U-Meyer waduma ngesikhundla sakhe sokuba mkhulumeli omkhulu karhulumende ku- Multiparty Negotiating Forum ngo-1993 ngemva kokubhalelwa kwe -CODESA lapho asungula khona ubudlelwano obuhle nobusebenzako nomkhulumeli omkhulu we -ANC, u-Cyril Ramaphosa .  Kilesi sikhundla, wasebenza eduze no -Niel Barnard, obekayinhloko ye-National Intelligence Service begodu amsekeli oqinileko wesivumelwano.  Ngemva kokuphethwa kweengcoco ngoNovemba 1993, waba mjameli omkhulu karhulumende ku- Transitional Executive Council (TEC). U-Meyer no-Ramaphosa bathola i-South African Breweries Leadership and Service Award ngo-2004. 

== Umsebenzi wezepolotiki wangemva kwebandlululo ==
Emakhethweni wokuthoma weSewula Afrika ngemva kwebandlululo ngoRhoboyi wee-1994, u-Meyer wakhethwa e- National Assembly etja, begodu uMengameli [[Nelson Mandela|u-Nelson Mandela]] wamkhetha njengoNgqongqotjhe wezokuThuthukiswa komThethosisekelo nezePhrovinsi kuRhulumende weNarha oneenhlangano ezinengi.  Umfowabo omdala u-Tobie Meyer bekanguSekela likaNgqongqotjhe wezokuLima nezeHlabathi kurhulumende ofanako.  NjengoNgqongqotjhe, u-Meyer wasebenza godu no-Cyril Ramaphosa, obekangusihlalo we -Constitutional Assembly ebegade anikelwe umsebenzi wokuqinisekisa umThethosisekelo wangemva kwebandlululo . 

NgoNhlolanja 1996, u-Meyer watjhiya isikhundla sekhabhinethi ukwenzela bona abe ngunobhala-jikelele we-National Party.[1] Ngebanga lokuragela phambili nokuthakazelela ukutjhugulula i-National Party, wahlala amuntu ongathandwako hlangana nephiko le-right wing le-party, ngesikhatheso ebelidoswa ngokungakahleleki ngu-Hernus Kriel.[2][3] Kwamambala, u-Meyer no-Kriel gade baphikisana tjhatjhalazi esikhathini esidlulileko.[4]
[[Mkhakha:Sopolitiki]]
[[Mkhakha:Sewula Afrika]]
[[Mkhakha:Amalungelo wobuntu]]</text>
      <sha1>298mp6kowqtg7au9hi1dddczi4zt5y2</sha1>
    </revision>
    <revision>
      <id>6415</id>
      <parentid>6414</parentid>
      <timestamp>2026-04-15T02:37:22Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>/* Ipilo yokuthoma nefundo */</comment>
      <origin>6415</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3457" sha1="3xt385fjclgt9m6ea4rnueegwkgeodl" xml:space="preserve">
U '''-Roelof Petrus Meyer''' &lt;small&gt;GCOB&lt;/small&gt; (wabelethwa mhlana ali-16 kuNtaka 1947) usopolotiki weSewula Afrika nosomabhizinisi. Ilunga lePalamende hlangana nomnyaka ka-1979 ukuya ku-1997, bekangumkhulumeli omkhulu karhulumende we-[[INational Party|National Party]] ngesikhathi seengcoco zokuqeda ibandlululo . Ngokukhamba kwesikhathi wasungula i -United Democratic Movement .&lt;ref&gt;https://www.dailymaverick.co.za/article/2019-01-30-roelf-meyer-is-back-and-trying-to-help-save-sas-economy/&lt;/ref&gt;

Ngesikhathi sakhe ePalamende, u-Meyer wakhonza kurhulumende wabomongameli abathathu abalandelanako: u-PW Botha, u-FW de Klerk, no [[Nelson Mandela|-Nelson Mandela]] . Ngemva kokutjhiya i-National Party ngo-1997, wasungula i-United Democratic Movement no [[Bantu Holomisa|-Bantu Holomisa]] . Wabuyela isikhatjhana ePalamende hlangana nomnyaka ka-1999 ukuya ku-2000 ngaphambi kobana athathe umhlalaphasi kezepolotiki yangaphambili ngoTjhirhweni 2000.

== Ipilo yokuthoma nefundo ==
U-Meyer, indodana encani yomlimi we-Eastern Cape, u-Hudson Meyer notitjhere wesikolo u-Hannah Meyer, ozalwa ngu-van Heerden, waya esikolweni e -Ficksburg begodu wafunda umthetho e- University of the Free State, lapho aqeda khona amadigri we-B Comm (1968) kanye ne -LLB (1971). Eyunivesithi, bekangumongameli we-&quot;Afrikaanse Studentebond&quot; ongatjhugulukiko. Ngesikhathi sokusebenza kwakhe ebuthweni, bekalilunga lekhwaya ye -SADF eyaziwa nangokuthi &quot;ama-Kanaries&quot;. U-Meyer wasebenza njengegqwetha e -Pitoli ne [[Johannesburg|-Goli]] bekwaba ngu-1980.&lt;ref&gt;https://www.dailymaverick.co.za/article/2024-06-04-roelf-meyer-a-new-ruling-order-has-to-be-built-in-sa/&lt;/ref&gt;

=== Iingcoco zokuqeda ibandlululo ===
U-Meyer waduma ngesikhundla sakhe sokuba mkhulumeli omkhulu karhulumende ku- Multiparty Negotiating Forum ngo-1993 ngemva kokubhalelwa kwe -CODESA lapho asungula khona ubudlelwano obuhle nobusebenzako nomkhulumeli omkhulu we -ANC, u-Cyril Ramaphosa .  Kilesi sikhundla, wasebenza eduze no -Niel Barnard, obekayinhloko ye-National Intelligence Service begodu amsekeli oqinileko wesivumelwano.  Ngemva kokuphethwa kweengcoco ngoNovemba 1993, waba mjameli omkhulu karhulumende ku- Transitional Executive Council (TEC). U-Meyer no-Ramaphosa bathola i-South African Breweries Leadership and Service Award ngo-2004. 

== Umsebenzi wezepolotiki wangemva kwebandlululo ==
Emakhethweni wokuthoma weSewula Afrika ngemva kwebandlululo ngoRhoboyi wee-1994, u-Meyer wakhethwa e- National Assembly etja, begodu uMengameli [[Nelson Mandela|u-Nelson Mandela]] wamkhetha njengoNgqongqotjhe wezokuThuthukiswa komThethosisekelo nezePhrovinsi kuRhulumende weNarha oneenhlangano ezinengi.  Umfowabo omdala u-Tobie Meyer bekanguSekela likaNgqongqotjhe wezokuLima nezeHlabathi kurhulumende ofanako.  NjengoNgqongqotjhe, u-Meyer wasebenza godu no-Cyril Ramaphosa, obekangusihlalo we -Constitutional Assembly ebegade anikelwe umsebenzi wokuqinisekisa umThethosisekelo wangemva kwebandlululo . 

NgoNhlolanja 1996, u-Meyer watjhiya isikhundla sekhabhinethi ukwenzela bona abe ngunobhala-jikelele we-National Party.[1] Ngebanga lokuragela phambili nokuthakazelela ukutjhugulula i-National Party, wahlala amuntu ongathandwako hlangana nephiko le-right wing le-party, ngesikhatheso ebelidoswa ngokungakahleleki ngu-Hernus Kriel.[2][3] Kwamambala, u-Meyer no-Kriel gade baphikisana tjhatjhalazi esikhathini esidlulileko.[4]
[[Mkhakha:Sopolitiki]]
[[Mkhakha:Sewula Afrika]]
[[Mkhakha:Amalungelo wobuntu]]</text>
      <sha1>3xt385fjclgt9m6ea4rnueegwkgeodl</sha1>
    </revision>
    <revision>
      <id>6416</id>
      <parentid>6415</parentid>
      <timestamp>2026-04-15T02:37:58Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6416</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3473" sha1="py9fmvuf2oz2ldjpoxrqmdd1r92m2lo" xml:space="preserve">
U '''-Roelof Petrus Meyer''' &lt;small&gt;GCOB&lt;/small&gt; (wabelethwa mhlana ali-16 kuNtaka 1947) usopolotiki weSewula Afrika nosomabhizinisi. Ilunga lePalamende hlangana nomnyaka ka-1979 ukuya ku-1997, bekangumkhulumeli omkhulu karhulumende we-[[INational Party|National Party]] ngesikhathi seengcoco zokuqeda ibandlululo . Ngokukhamba kwesikhathi wasungula i -United Democratic Movement .&lt;ref&gt;https://www.dailymaverick.co.za/article/2019-01-30-roelf-meyer-is-back-and-trying-to-help-save-sas-economy/&lt;/ref&gt;

Ngesikhathi sakhe ePalamende, u-Meyer wakhonza kurhulumende wabomongameli abathathu abalandelanako: u-PW Botha, u-FW de Klerk, no [[Nelson Mandela|-Nelson Mandela]] . Ngemva kokutjhiya i-National Party ngo-1997, wasungula i-United Democratic Movement no [[Bantu Holomisa|-Bantu Holomisa]] . Wabuyela isikhatjhana ePalamende hlangana nomnyaka ka-1999 ukuya ku-2000 ngaphambi kobana athathe umhlalaphasi kezepolotiki yangaphambili ngoTjhirhweni 2000.

== Ipilo yokuthoma nefundo ==
U-Meyer, indodana encani yomlimi we-Eastern Cape, u-Hudson Meyer notitjhere wesikolo u-Hannah Meyer, ozalwa ngu-van Heerden, waya esikolweni e -Ficksburg begodu wafunda umthetho e- University of the Free State, lapho aqeda khona amadigri we-B Comm (1968) kanye ne -LLB (1971). Eyunivesithi, bekangumongameli we-&quot;Afrikaanse Studentebond&quot; ongatjhugulukiko. Ngesikhathi sokusebenza kwakhe ebuthweni, bekalilunga lekhwaya ye -SADF eyaziwa nangokuthi &quot;ama-Kanaries&quot;. U-Meyer wasebenza njengegqwetha e -Pitoli ne [[Johannesburg|-Goli]] bekwaba ngu-1980.&lt;ref&gt;https://www.dailymaverick.co.za/article/2024-06-04-roelf-meyer-a-new-ruling-order-has-to-be-built-in-sa/&lt;/ref&gt;

=== Iingcoco zokuqeda ibandlululo ===
U-Meyer waduma ngesikhundla sakhe sokuba mkhulumeli omkhulu karhulumende ku- Multiparty Negotiating Forum ngo-1993 ngemva kokubhalelwa kwe -CODESA lapho asungula khona ubudlelwano obuhle nobusebenzako nomkhulumeli omkhulu we -ANC, u-Cyril Ramaphosa .  Kilesi sikhundla, wasebenza eduze no -Niel Barnard, obekayinhloko ye-National Intelligence Service begodu amsekeli oqinileko wesivumelwano.  Ngemva kokuphethwa kweengcoco ngoNovemba 1993, waba mjameli omkhulu karhulumende ku- Transitional Executive Council (TEC). U-Meyer no-Ramaphosa bathola i-South African Breweries Leadership and Service Award ngo-2004. 

== Umsebenzi wezepolotiki wangemva kwebandlululo ==
Emakhethweni wokuthoma weSewula Afrika ngemva kwebandlululo ngoRhoboyi wee-1994, u-Meyer wakhethwa e- National Assembly etja, begodu uMengameli [[Nelson Mandela|u-Nelson Mandela]] wamkhetha njengoNgqongqotjhe wezokuThuthukiswa komThethosisekelo nezePhrovinsi kuRhulumende weNarha oneenhlangano ezinengi.  Umfowabo omdala u-Tobie Meyer bekanguSekela likaNgqongqotjhe wezokuLima nezeHlabathi kurhulumende ofanako.  NjengoNgqongqotjhe, u-Meyer wasebenza godu no-Cyril Ramaphosa, obekangusihlalo we -Constitutional Assembly ebegade anikelwe umsebenzi wokuqinisekisa umThethosisekelo wangemva kwebandlululo . 

NgoNhlolanja 1996, u-Meyer watjhiya isikhundla sekhabhinethi ukwenzela bona abe ngunobhala-jikelele we-National Party.[1] Ngebanga lokuragela phambili nokuthakazelela ukutjhugulula i-National Party, wahlala amuntu ongathandwako hlangana nephiko le-right wing le-party, ngesikhatheso ebelidoswa ngokungakahleleki ngu-Hernus Kriel.[2][3] Kwamambala, u-Meyer no-Kriel gade baphikisana tjhatjhalazi esikhathini esidlulileko.[4]

== Iinkomba ==
[[Mkhakha:Sopolitiki]]
[[Mkhakha:Sewula Afrika]]
[[Mkhakha:Amalungelo wobuntu]]</text>
      <sha1>py9fmvuf2oz2ldjpoxrqmdd1r92m2lo</sha1>
    </revision>
    <revision>
      <id>6417</id>
      <parentid>6416</parentid>
      <timestamp>2026-04-15T02:40:57Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1348918894|Roelf Meyer]]&quot;</comment>
      <origin>6417</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4228" sha1="2bbk1ftg26am1zzg0oi92m3cqscia3m" xml:space="preserve">
U '''-Roelof Petrus Meyer''' &lt;small&gt;GCOB&lt;/small&gt; (wabelethwa mhlana ali-16 kuNtaka 1947) usopolotiki weSewula Afrika nosomabhizinisi. Ilunga lePalamende hlangana nomnyaka ka-1979 ukuya ku-1997, bekangumkhulumeli omkhulu karhulumende we-National Party ngesikhathi seengcoco zokuqeda ibandlululo . Ngokukhamba kwesikhathi wasungula i -United Democratic Movement .

Ngesikhathi sakhe ePalamende, u-Meyer wakhonza kurhulumende wabomongameli abathathu abalandelanako: u-PW Botha, u-FW de Klerk, no [[Nelson Mandela|-Nelson Mandela]] . Ngemva kokutjhiya i-National Party ngo-1997, wasungula i-United Democratic Movement no [[Bantu Holomisa|-Bantu Holomisa]] . Wabuyela isikhatjhana ePalamende hlangana nomnyaka ka-1999 ukuya ku-2000 ngaphambi kobana athathe umhlalaphasi kezepolotiki yangaphambili ngoTjhirhweni 2000.

== Ipilo yokuthoma nefundo ==
U-Meyer, indodana encani yomlimi we-Eastern Cape, u-Hudson Meyer notitjhere wesikolo u-Hannah Meyer, ozalwa ngu-van Heerden, waya esikolweni e -Ficksburg begodu wafunda umthetho e- University of the Free State, lapho aqeda khona amadigri we-B Comm (1968) kanye ne -LLB (1971). Eyunivesithi, bekangumongameli we-&quot;Afrikaanse Studentebond&quot; ongatjhugulukiko. Ngesikhathi sokusebenza kwakhe ebuthweni, bekalilunga lekhwaya ye -SADF eyaziwa nangokuthi &quot;ama-Kanaries&quot;. U-Meyer wasebenza njengegqwetha e -Pitoli ne [[Johannesburg|-Goli]] bekwaba ngu-1980.

=== Iingcoco zokuqeda ibandlululo ===
U-Meyer waduma ngesikhundla sakhe sokuba mkhulumeli omkhulu karhulumende ku- Multiparty Negotiating Forum ngo-1993 ngemva kokubhalelwa kwe -CODESA lapho asungula khona ubudlelwano obuhle nobusebenzako nomkhulumeli omkhulu we -ANC, u-Cyril Ramaphosa .  Kilesi sikhundla, wasebenza eduze no -Niel Barnard, obekayinhloko ye-National Intelligence Service begodu amsekeli oqinileko wesivumelwano. &lt;ref&gt;{{cite book|last=Turton|first=Anthony Richard|title=Shaking Hands with Billy: The Private Memoirs of Anthony Richard Turton|url=https://books.google.com/books?id=q4sHfAEACAAJ|year=2010|publisher=Just Done Productions Publishing|isbn=978-1-920315-58-0}}&lt;/ref&gt; Ngemva kokuphethwa kweengcoco ngoNovemba 1993, waba mjameli omkhulu karhulumende ku- Transitional Executive Council (TEC). U-Meyer no-Ramaphosa bathola i-South African Breweries Leadership and Service Award ngo-2004. &lt;ref name=&quot;:1&quot;&gt;{{Cite web|title=Roelf Petrus Meyer (1947 – )|url=http://www.thepresidency.gov.za/national-orders/recipient/roelf-petrus-meyer-1947?page=6#!slide|access-date=2018-02-23|website=The Presidency|language=en}}&lt;/ref&gt;

== Umsebenzi wezepolotiki wangemva kwebandlululo ==
Emakhethweni wokuthoma weSewula Afrika ngemva kwebandlululo ngoRhoboyi wee-1994, u-Meyer wakhethwa e- National Assembly etja, begodu uMengameli [[Nelson Mandela|u-Nelson Mandela]] wamkhetha njengoNgqongqotjhe wezokuThuthukiswa komThethosisekelo nezePhrovinsi kuRhulumende weNarha oneenhlangano ezinengi.  Umfowabo omdala u-Tobie Meyer bekanguSekela likaNgqongqotjhe wezokuLima nezeHlabathi kurhulumende ofanako. &lt;ref&gt;{{Cite news|last=Keller|first=Bill|date=1994-05-12|title=Mandela Completes His Cabinet, Giving Buthelezi a Post|language=en-US|work=The New York Times|url=https://www.nytimes.com/1994/05/12/world/mandela-completes-his-cabinet-giving-buthelezi-a-post.html|access-date=2023-05-29|issn=0362-4331}}&lt;/ref&gt; NjengoNgqongqotjhe, u-Meyer wasebenza godu no-Cyril Ramaphosa, obekangusihlalo we -Constitutional Assembly ebegade anikelwe umsebenzi wokuqinisekisa umThethosisekelo wangemva kwebandlululo . 

NgoNhlolanja 1996, u-Meyer watjhiya isikhundla sekhabhinethi ukwenzela bona abe ngunobhala-jikelele we-National Party.[1] Ngebanga lokuragela phambili nokuthakazelela ukutjhugulula i-National Party, wahlala amuntu ongathandwako hlangana nephiko le-right wing le-party, ngesikhatheso ebelidoswa ngokungakahleleki ngu-Hernus Kriel.[2][3] Kwamambala, u-Meyer no-Kriel gade baphikisana tjhatjhalazi esikhathini esidlulileko.&lt;ref&gt;{{Cite web|title=Roelf Meyer &amp; Cyril Ramaphosa 1995|url=https://www.mandela.ac.za/Leadership-and-Governance/Honorary-Doctorates/Roelf-Meyer-Cyril-Ramaphosa-1995|access-date=29 May 2023|website=Nelson Mandela University}}&lt;/ref&gt;
[[Mkhakha:Sopolitiki]]
[[Mkhakha:Sewula Afrika]]
[[Mkhakha:Amalungelo wobuntu]]</text>
      <sha1>2bbk1ftg26am1zzg0oi92m3cqscia3m</sha1>
    </revision>
    <revision>
      <id>6419</id>
      <parentid>6417</parentid>
      <timestamp>2026-04-15T02:42:32Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6419</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4244" sha1="gsi12uvvy0kcpwrqo5ze6tc16e6bbco" xml:space="preserve">
U '''-Roelof Petrus Meyer''' &lt;small&gt;GCOB&lt;/small&gt; (wabelethwa mhlana ali-16 kuNtaka 1947) usopolotiki weSewula Afrika nosomabhizinisi. Ilunga lePalamende hlangana nomnyaka ka-1979 ukuya ku-1997, bekangumkhulumeli omkhulu karhulumende we-National Party ngesikhathi seengcoco zokuqeda ibandlululo . Ngokukhamba kwesikhathi wasungula i -United Democratic Movement .

Ngesikhathi sakhe ePalamende, u-Meyer wakhonza kurhulumende wabomongameli abathathu abalandelanako: u-PW Botha, u-FW de Klerk, no [[Nelson Mandela|-Nelson Mandela]] . Ngemva kokutjhiya i-National Party ngo-1997, wasungula i-United Democratic Movement no [[Bantu Holomisa|-Bantu Holomisa]] . Wabuyela isikhatjhana ePalamende hlangana nomnyaka ka-1999 ukuya ku-2000 ngaphambi kobana athathe umhlalaphasi kezepolotiki yangaphambili ngoTjhirhweni 2000.

== Ipilo yokuthoma nefundo ==
U-Meyer, indodana encani yomlimi we-Eastern Cape, u-Hudson Meyer notitjhere wesikolo u-Hannah Meyer, ozalwa ngu-van Heerden, waya esikolweni e -Ficksburg begodu wafunda umthetho e- University of the Free State, lapho aqeda khona amadigri we-B Comm (1968) kanye ne -LLB (1971). Eyunivesithi, bekangumongameli we-&quot;Afrikaanse Studentebond&quot; ongatjhugulukiko. Ngesikhathi sokusebenza kwakhe ebuthweni, bekalilunga lekhwaya ye -SADF eyaziwa nangokuthi &quot;ama-Kanaries&quot;. U-Meyer wasebenza njengegqwetha e -Pitoli ne [[Johannesburg|-Goli]] bekwaba ngu-1980.

=== Iingcoco zokuqeda ibandlululo ===
U-Meyer waduma ngesikhundla sakhe sokuba mkhulumeli omkhulu karhulumende ku- Multiparty Negotiating Forum ngo-1993 ngemva kokubhalelwa kwe -CODESA lapho asungula khona ubudlelwano obuhle nobusebenzako nomkhulumeli omkhulu we -ANC, u-Cyril Ramaphosa .  Kilesi sikhundla, wasebenza eduze no -Niel Barnard, obekayinhloko ye-National Intelligence Service begodu amsekeli oqinileko wesivumelwano. &lt;ref&gt;{{cite book|last=Turton|first=Anthony Richard|title=Shaking Hands with Billy: The Private Memoirs of Anthony Richard Turton|url=https://books.google.com/books?id=q4sHfAEACAAJ|year=2010|publisher=Just Done Productions Publishing|isbn=978-1-920315-58-0}}&lt;/ref&gt; Ngemva kokuphethwa kweengcoco ngoNovemba 1993, waba mjameli omkhulu karhulumende ku- Transitional Executive Council (TEC). U-Meyer no-Ramaphosa bathola i-South African Breweries Leadership and Service Award ngo-2004. &lt;ref name=&quot;:1&quot;&gt;{{Cite web|title=Roelf Petrus Meyer (1947 – )|url=http://www.thepresidency.gov.za/national-orders/recipient/roelf-petrus-meyer-1947?page=6#!slide|access-date=2018-02-23|website=The Presidency|language=en}}&lt;/ref&gt;

== Umsebenzi wezepolotiki wangemva kwebandlululo ==
Emakhethweni wokuthoma weSewula Afrika ngemva kwebandlululo ngoRhoboyi wee-1994, u-Meyer wakhethwa e- National Assembly etja, begodu uMengameli [[Nelson Mandela|u-Nelson Mandela]] wamkhetha njengoNgqongqotjhe wezokuThuthukiswa komThethosisekelo nezePhrovinsi kuRhulumende weNarha oneenhlangano ezinengi.  Umfowabo omdala u-Tobie Meyer bekanguSekela likaNgqongqotjhe wezokuLima nezeHlabathi kurhulumende ofanako. &lt;ref&gt;{{Cite news|last=Keller|first=Bill|date=1994-05-12|title=Mandela Completes His Cabinet, Giving Buthelezi a Post|language=en-US|work=The New York Times|url=https://www.nytimes.com/1994/05/12/world/mandela-completes-his-cabinet-giving-buthelezi-a-post.html|access-date=2023-05-29|issn=0362-4331}}&lt;/ref&gt; NjengoNgqongqotjhe, u-Meyer wasebenza godu no-Cyril Ramaphosa, obekangusihlalo we -Constitutional Assembly ebegade anikelwe umsebenzi wokuqinisekisa umThethosisekelo wangemva kwebandlululo . 

NgoNhlolanja 1996, u-Meyer watjhiya isikhundla sekhabhinethi ukwenzela bona abe ngunobhala-jikelele we-National Party.[1] Ngebanga lokuragela phambili nokuthakazelela ukutjhugulula i-National Party, wahlala amuntu ongathandwako hlangana nephiko le-right wing le-party, ngesikhatheso ebelidoswa ngokungakahleleki ngu-Hernus Kriel.[2][3] Kwamambala, u-Meyer no-Kriel gade baphikisana tjhatjhalazi esikhathini esidlulileko.&lt;ref&gt;{{Cite web|title=Roelf Meyer &amp; Cyril Ramaphosa 1995|url=https://www.mandela.ac.za/Leadership-and-Governance/Honorary-Doctorates/Roelf-Meyer-Cyril-Ramaphosa-1995|access-date=29 May 2023|website=Nelson Mandela University}}&lt;/ref&gt;

== Iinkomba ==
[[Mkhakha:Sopolitiki]]
[[Mkhakha:Sewula Afrika]]
[[Mkhakha:Amalungelo wobuntu]]</text>
      <sha1>gsi12uvvy0kcpwrqo5ze6tc16e6bbco</sha1>
    </revision>
    <revision>
      <id>6438</id>
      <parentid>6419</parentid>
      <timestamp>2026-04-15T06:08:23Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6438</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4415" sha1="p1nucrvenyobid2ihiqczrgfurjo339" xml:space="preserve">
U '''-Roelof Petrus Meyer''' &lt;small&gt;GCOB&lt;/small&gt; (wabelethwa mhlana ali-16 kuNtaka 1947) usopolotiki weSewula Afrika nosomabhizinisi. Ilunga lePalamende hlangana nomnyaka ka-1979 ukuya ku-1997, bekangumkhulumeli omkhulu karhulumende we-National Party ngesikhathi seengcoco zokuqeda ibandlululo . Ngokukhamba kwesikhathi wasungula i -United Democratic Movement .

Ngesikhathi sakhe ePalamende, u-Meyer wakhonza kurhulumende wabomongameli abathathu abalandelanako: u-PW Botha, u-FW de Klerk, no [[Nelson Mandela|-Nelson Mandela]] . Ngemva kokutjhiya i-National Party ngo-1997, wasungula i-United Democratic Movement no [[Bantu Holomisa|-Bantu Holomisa]] . Wabuyela isikhatjhana ePalamende hlangana nomnyaka ka-1999 ukuya ku-2000 ngaphambi kobana athathe umhlalaphasi kezepolotiki yangaphambili ngoTjhirhweni 2000.

Mhlana amalanga ali-14 kuMrhayili 2026, uMengameli weSewula Afrika u-Cyril Ramaphosa wabeka u-Meyer esikhundleni esinganamuntu sokuba yinxusa le-United States of America

== Ipilo yokuthoma nefundo ==
U-Meyer, indodana encani yomlimi we-Eastern Cape, u-Hudson Meyer notitjhere wesikolo u-Hannah Meyer, ozalwa ngu-van Heerden, waya esikolweni e -Ficksburg begodu wafunda umthetho e- University of the Free State, lapho aqeda khona amadigri we-B Comm (1968) kanye ne -LLB (1971). Eyunivesithi, bekangumongameli we-&quot;Afrikaanse Studentebond&quot; ongatjhugulukiko. Ngesikhathi sokusebenza kwakhe ebuthweni, bekalilunga lekhwaya ye -SADF eyaziwa nangokuthi &quot;ama-Kanaries&quot;. U-Meyer wasebenza njengegqwetha e -Pitoli ne [[Johannesburg|-Goli]] bekwaba ngu-1980.

=== Iingcoco zokuqeda ibandlululo ===
U-Meyer waduma ngesikhundla sakhe sokuba mkhulumeli omkhulu karhulumende ku- Multiparty Negotiating Forum ngo-1993 ngemva kokubhalelwa kwe -CODESA lapho asungula khona ubudlelwano obuhle nobusebenzako nomkhulumeli omkhulu we -ANC, u-Cyril Ramaphosa .  Kilesi sikhundla, wasebenza eduze no -Niel Barnard, obekayinhloko ye-National Intelligence Service begodu amsekeli oqinileko wesivumelwano. &lt;ref&gt;{{cite book|last=Turton|first=Anthony Richard|title=Shaking Hands with Billy: The Private Memoirs of Anthony Richard Turton|url=https://books.google.com/books?id=q4sHfAEACAAJ|year=2010|publisher=Just Done Productions Publishing|isbn=978-1-920315-58-0}}&lt;/ref&gt; Ngemva kokuphethwa kweengcoco ngoNovemba 1993, waba mjameli omkhulu karhulumende ku- Transitional Executive Council (TEC). U-Meyer no-Ramaphosa bathola i-South African Breweries Leadership and Service Award ngo-2004. &lt;ref name=&quot;:1&quot;&gt;{{Cite web|title=Roelf Petrus Meyer (1947 – )|url=http://www.thepresidency.gov.za/national-orders/recipient/roelf-petrus-meyer-1947?page=6#!slide|access-date=2018-02-23|website=The Presidency|language=en}}&lt;/ref&gt;

== Umsebenzi wezepolotiki wangemva kwebandlululo ==
Emakhethweni wokuthoma weSewula Afrika ngemva kwebandlululo ngoRhoboyi wee-1994, u-Meyer wakhethwa e- National Assembly etja, begodu uMengameli [[Nelson Mandela|u-Nelson Mandela]] wamkhetha njengoNgqongqotjhe wezokuThuthukiswa komThethosisekelo nezePhrovinsi kuRhulumende weNarha oneenhlangano ezinengi.  Umfowabo omdala u-Tobie Meyer bekanguSekela likaNgqongqotjhe wezokuLima nezeHlabathi kurhulumende ofanako. &lt;ref&gt;{{Cite news|last=Keller|first=Bill|date=1994-05-12|title=Mandela Completes His Cabinet, Giving Buthelezi a Post|language=en-US|work=The New York Times|url=https://www.nytimes.com/1994/05/12/world/mandela-completes-his-cabinet-giving-buthelezi-a-post.html|access-date=2023-05-29|issn=0362-4331}}&lt;/ref&gt; NjengoNgqongqotjhe, u-Meyer wasebenza godu no-Cyril Ramaphosa, obekangusihlalo we -Constitutional Assembly ebegade anikelwe umsebenzi wokuqinisekisa umThethosisekelo wangemva kwebandlululo . 

NgoNhlolanja 1996, u-Meyer watjhiya isikhundla sekhabhinethi ukwenzela bona abe ngunobhala-jikelele we-National Party.[1] Ngebanga lokuragela phambili nokuthakazelela ukutjhugulula i-National Party, wahlala amuntu ongathandwako hlangana nephiko le-right wing le-party, ngesikhatheso ebelidoswa ngokungakahleleki ngu-Hernus Kriel.[2][3] Kwamambala, u-Meyer no-Kriel gade baphikisana tjhatjhalazi esikhathini esidlulileko.&lt;ref&gt;{{Cite web|title=Roelf Meyer &amp; Cyril Ramaphosa 1995|url=https://www.mandela.ac.za/Leadership-and-Governance/Honorary-Doctorates/Roelf-Meyer-Cyril-Ramaphosa-1995|access-date=29 May 2023|website=Nelson Mandela University}}&lt;/ref&gt;

== Iinkomba ==
[[Mkhakha:Sopolitiki]]
[[Mkhakha:Sewula Afrika]]
[[Mkhakha:Amalungelo wobuntu]]</text>
      <sha1>p1nucrvenyobid2ihiqczrgfurjo339</sha1>
    </revision>
    <revision>
      <id>6439</id>
      <parentid>6438</parentid>
      <timestamp>2026-04-15T06:09:04Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6439</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4435" sha1="bz2hwwuj51709mxc281eibu18xliwar" xml:space="preserve">
U '''-Roelof Petrus Meyer''' &lt;small&gt;GCOB&lt;/small&gt; (wabelethwa mhlana ali-16 kuNtaka 1947) usopolotiki weSewula Afrika nosomabhizinisi. Ilunga lePalamende hlangana nomnyaka ka-1979 ukuya ku-1997, bekangumkhulumeli omkhulu karhulumende we-National Party ngesikhathi seengcoco zokuqeda ibandlululo . Ngokukhamba kwesikhathi wasungula i -United Democratic Movement .

Ngesikhathi sakhe ePalamende, u-Meyer wakhonza kurhulumende wabomongameli abathathu abalandelanako: u-PW Botha, u-FW de Klerk, no [[Nelson Mandela|-Nelson Mandela]] . Ngemva kokutjhiya i-National Party ngo-1997, wasungula i-United Democratic Movement no [[Bantu Holomisa|-Bantu Holomisa]] . Wabuyela isikhatjhana ePalamende hlangana nomnyaka ka-1999 ukuya ku-2000 ngaphambi kobana athathe umhlalaphasi kezepolotiki yangaphambili ngoTjhirhweni 2000.

Mhlana amalanga ali-14 kuMrhayili 2026, uMengameli weSewula Afrika [[Cyril Ramaphosa|u-Cyril Ramaphosa]] wabeka u-Meyer esikhundleni esinganamuntu sokuba yinxusa le-United States of America

== Ipilo yokuthoma nefundo ==
U-Meyer, indodana encani yomlimi we-Eastern Cape, u-Hudson Meyer notitjhere wesikolo u-Hannah Meyer, ozalwa ngu-van Heerden, waya esikolweni e -Ficksburg begodu wafunda umthetho e- University of the Free State, lapho aqeda khona amadigri we-B Comm (1968) kanye ne -LLB (1971). Eyunivesithi, bekangumongameli we-&quot;Afrikaanse Studentebond&quot; ongatjhugulukiko. Ngesikhathi sokusebenza kwakhe ebuthweni, bekalilunga lekhwaya ye -SADF eyaziwa nangokuthi &quot;ama-Kanaries&quot;. U-Meyer wasebenza njengegqwetha e -Pitoli ne [[Johannesburg|-Goli]] bekwaba ngu-1980.

=== Iingcoco zokuqeda ibandlululo ===
U-Meyer waduma ngesikhundla sakhe sokuba mkhulumeli omkhulu karhulumende ku- Multiparty Negotiating Forum ngo-1993 ngemva kokubhalelwa kwe -CODESA lapho asungula khona ubudlelwano obuhle nobusebenzako nomkhulumeli omkhulu we -ANC, u-Cyril Ramaphosa .  Kilesi sikhundla, wasebenza eduze no -Niel Barnard, obekayinhloko ye-National Intelligence Service begodu amsekeli oqinileko wesivumelwano. &lt;ref&gt;{{cite book|last=Turton|first=Anthony Richard|title=Shaking Hands with Billy: The Private Memoirs of Anthony Richard Turton|url=https://books.google.com/books?id=q4sHfAEACAAJ|year=2010|publisher=Just Done Productions Publishing|isbn=978-1-920315-58-0}}&lt;/ref&gt; Ngemva kokuphethwa kweengcoco ngoNovemba 1993, waba mjameli omkhulu karhulumende ku- Transitional Executive Council (TEC). U-Meyer no-Ramaphosa bathola i-South African Breweries Leadership and Service Award ngo-2004. &lt;ref name=&quot;:1&quot;&gt;{{Cite web|title=Roelf Petrus Meyer (1947 – )|url=http://www.thepresidency.gov.za/national-orders/recipient/roelf-petrus-meyer-1947?page=6#!slide|access-date=2018-02-23|website=The Presidency|language=en}}&lt;/ref&gt;

== Umsebenzi wezepolotiki wangemva kwebandlululo ==
Emakhethweni wokuthoma weSewula Afrika ngemva kwebandlululo ngoRhoboyi wee-1994, u-Meyer wakhethwa e- National Assembly etja, begodu uMengameli [[Nelson Mandela|u-Nelson Mandela]] wamkhetha njengoNgqongqotjhe wezokuThuthukiswa komThethosisekelo nezePhrovinsi kuRhulumende weNarha oneenhlangano ezinengi.  Umfowabo omdala u-Tobie Meyer bekanguSekela likaNgqongqotjhe wezokuLima nezeHlabathi kurhulumende ofanako. &lt;ref&gt;{{Cite news|last=Keller|first=Bill|date=1994-05-12|title=Mandela Completes His Cabinet, Giving Buthelezi a Post|language=en-US|work=The New York Times|url=https://www.nytimes.com/1994/05/12/world/mandela-completes-his-cabinet-giving-buthelezi-a-post.html|access-date=2023-05-29|issn=0362-4331}}&lt;/ref&gt; NjengoNgqongqotjhe, u-Meyer wasebenza godu no-Cyril Ramaphosa, obekangusihlalo we -Constitutional Assembly ebegade anikelwe umsebenzi wokuqinisekisa umThethosisekelo wangemva kwebandlululo . 

NgoNhlolanja 1996, u-Meyer watjhiya isikhundla sekhabhinethi ukwenzela bona abe ngunobhala-jikelele we-National Party.[1] Ngebanga lokuragela phambili nokuthakazelela ukutjhugulula i-National Party, wahlala amuntu ongathandwako hlangana nephiko le-right wing le-party, ngesikhatheso ebelidoswa ngokungakahleleki ngu-Hernus Kriel.[2][3] Kwamambala, u-Meyer no-Kriel gade baphikisana tjhatjhalazi esikhathini esidlulileko.&lt;ref&gt;{{Cite web|title=Roelf Meyer &amp; Cyril Ramaphosa 1995|url=https://www.mandela.ac.za/Leadership-and-Governance/Honorary-Doctorates/Roelf-Meyer-Cyril-Ramaphosa-1995|access-date=29 May 2023|website=Nelson Mandela University}}&lt;/ref&gt;

== Iinkomba ==
[[Mkhakha:Sopolitiki]]
[[Mkhakha:Sewula Afrika]]
[[Mkhakha:Amalungelo wobuntu]]</text>
      <sha1>bz2hwwuj51709mxc281eibu18xliwar</sha1>
    </revision>
    <revision>
      <id>6440</id>
      <parentid>6439</parentid>
      <timestamp>2026-04-15T06:11:17Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6440</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4605" sha1="8h1elu9kxl0cj8bf33n3frfk7lf7mwv" xml:space="preserve">
U '''-Roelof Petrus Meyer''' &lt;small&gt;GCOB&lt;/small&gt; (wabelethwa mhlana ali-16 kuNtaka 1947) usopolotiki weSewula Afrika nosomabhizinisi. Ilunga lePalamende hlangana nomnyaka ka-1979 ukuya ku-1997, bekangumkhulumeli omkhulu karhulumende we-National Party ngesikhathi seengcoco zokuqeda ibandlululo . Ngokukhamba kwesikhathi wasungula i -United Democratic Movement .

Ngesikhathi sakhe ePalamende, u-Meyer wakhonza kurhulumende wabomongameli abathathu abalandelanako: u-PW Botha, u-FW de Klerk, no [[Nelson Mandela|-Nelson Mandela]] . Ngemva kokutjhiya i-National Party ngo-1997, wasungula i-United Democratic Movement no [[Bantu Holomisa|-Bantu Holomisa]] . Wabuyela isikhatjhana ePalamende hlangana nomnyaka ka-1999 ukuya ku-2000 ngaphambi kobana athathe umhlalaphasi kezepolotiki yangaphambili ngoTjhirhweni 2000.

Mhlana amalanga ali-14 kuMrhayili 2026, uMengameli weSewula Afrika [[Cyril Ramaphosa|u-Cyril Ramaphosa]] wabeka u-Meyer esikhundleni esinganamuntu sokuba yinxusa le-United States of America&lt;ref&gt;https://www.reuters.com/world/south-african-president-chooses-roelf-meyer-next-ambassador-us-2026-04-14/&lt;/ref&gt;&lt;ref&gt;https://www.sabcnews.com/sabcnews/1120913-2/&lt;/ref&gt;

== Ipilo yokuthoma nefundo ==
U-Meyer, indodana encani yomlimi we-Eastern Cape, u-Hudson Meyer notitjhere wesikolo u-Hannah Meyer, ozalwa ngu-van Heerden, waya esikolweni e -Ficksburg begodu wafunda umthetho e- University of the Free State, lapho aqeda khona amadigri we-B Comm (1968) kanye ne -LLB (1971). Eyunivesithi, bekangumongameli we-&quot;Afrikaanse Studentebond&quot; ongatjhugulukiko. Ngesikhathi sokusebenza kwakhe ebuthweni, bekalilunga lekhwaya ye -SADF eyaziwa nangokuthi &quot;ama-Kanaries&quot;. U-Meyer wasebenza njengegqwetha e -Pitoli ne [[Johannesburg|-Goli]] bekwaba ngu-1980.

=== Iingcoco zokuqeda ibandlululo ===
U-Meyer waduma ngesikhundla sakhe sokuba mkhulumeli omkhulu karhulumende ku- Multiparty Negotiating Forum ngo-1993 ngemva kokubhalelwa kwe -CODESA lapho asungula khona ubudlelwano obuhle nobusebenzako nomkhulumeli omkhulu we -ANC, u-Cyril Ramaphosa .  Kilesi sikhundla, wasebenza eduze no -Niel Barnard, obekayinhloko ye-National Intelligence Service begodu amsekeli oqinileko wesivumelwano. &lt;ref&gt;{{cite book|last=Turton|first=Anthony Richard|title=Shaking Hands with Billy: The Private Memoirs of Anthony Richard Turton|url=https://books.google.com/books?id=q4sHfAEACAAJ|year=2010|publisher=Just Done Productions Publishing|isbn=978-1-920315-58-0}}&lt;/ref&gt; Ngemva kokuphethwa kweengcoco ngoNovemba 1993, waba mjameli omkhulu karhulumende ku- Transitional Executive Council (TEC). U-Meyer no-Ramaphosa bathola i-South African Breweries Leadership and Service Award ngo-2004. &lt;ref name=&quot;:1&quot;&gt;{{Cite web|title=Roelf Petrus Meyer (1947 – )|url=http://www.thepresidency.gov.za/national-orders/recipient/roelf-petrus-meyer-1947?page=6#!slide|access-date=2018-02-23|website=The Presidency|language=en}}&lt;/ref&gt;

== Umsebenzi wezepolotiki wangemva kwebandlululo ==
Emakhethweni wokuthoma weSewula Afrika ngemva kwebandlululo ngoRhoboyi wee-1994, u-Meyer wakhethwa e- National Assembly etja, begodu uMengameli [[Nelson Mandela|u-Nelson Mandela]] wamkhetha njengoNgqongqotjhe wezokuThuthukiswa komThethosisekelo nezePhrovinsi kuRhulumende weNarha oneenhlangano ezinengi.  Umfowabo omdala u-Tobie Meyer bekanguSekela likaNgqongqotjhe wezokuLima nezeHlabathi kurhulumende ofanako. &lt;ref&gt;{{Cite news|last=Keller|first=Bill|date=1994-05-12|title=Mandela Completes His Cabinet, Giving Buthelezi a Post|language=en-US|work=The New York Times|url=https://www.nytimes.com/1994/05/12/world/mandela-completes-his-cabinet-giving-buthelezi-a-post.html|access-date=2023-05-29|issn=0362-4331}}&lt;/ref&gt; NjengoNgqongqotjhe, u-Meyer wasebenza godu no-Cyril Ramaphosa, obekangusihlalo we -Constitutional Assembly ebegade anikelwe umsebenzi wokuqinisekisa umThethosisekelo wangemva kwebandlululo . 

NgoNhlolanja 1996, u-Meyer watjhiya isikhundla sekhabhinethi ukwenzela bona abe ngunobhala-jikelele we-National Party.[1] Ngebanga lokuragela phambili nokuthakazelela ukutjhugulula i-National Party, wahlala amuntu ongathandwako hlangana nephiko le-right wing le-party, ngesikhatheso ebelidoswa ngokungakahleleki ngu-Hernus Kriel.[2][3] Kwamambala, u-Meyer no-Kriel gade baphikisana tjhatjhalazi esikhathini esidlulileko.&lt;ref&gt;{{Cite web|title=Roelf Meyer &amp; Cyril Ramaphosa 1995|url=https://www.mandela.ac.za/Leadership-and-Governance/Honorary-Doctorates/Roelf-Meyer-Cyril-Ramaphosa-1995|access-date=29 May 2023|website=Nelson Mandela University}}&lt;/ref&gt;

== Iinkomba ==
[[Mkhakha:Sopolitiki]]
[[Mkhakha:Sewula Afrika]]
[[Mkhakha:Amalungelo wobuntu]]</text>
      <sha1>8h1elu9kxl0cj8bf33n3frfk7lf7mwv</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Amalungelo wobuntu</title>
    <ns>14</ns>
    <id>1091</id>
    <revision>
      <id>6418</id>
      <timestamp>2026-04-15T02:41:43Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created page with &quot;Amalungelo wobuntu&quot;</comment>
      <origin>6418</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="18" sha1="78tj9ooggip1wgzbhmqyvm0kljebs0l" xml:space="preserve">Amalungelo wobuntu</text>
      <sha1>78tj9ooggip1wgzbhmqyvm0kljebs0l</sha1>
    </revision>
  </page>
  <page>
    <title>U-Magnus Manske</title>
    <ns>0</ns>
    <id>1092</id>
    <revision>
      <id>6420</id>
      <timestamp>2026-04-15T03:23:25Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1348673686|Magnus Manske]]&quot;</comment>
      <origin>6420</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3638" sha1="8vr9uhdurysrj5bdjjm97exmgqrw1c6" xml:space="preserve">
'''U-Heinrich Magnus Manske''' (wabelethwa mhlana ali-24 NgoMeyi 1974) ngusosayensi we-biochemist we-German ongumrhubhululi wemalariya . Usosayensi omkhulu we- Wellcome Sanger Institute e- Cambridge, UK     begodu ungumthuthukisi wesofthiwe yenye yeenguqulo zokuthoma zesofthiwe ye -MediaWiki, enikela amandla [[Wikipedia|ku-Wikipedia]] namanye amawebhusayithi amanengi asekelwe ku- wiki .

== Ipilo yokuthoma ==
U-Magnus Manske wabelethwa mhlazi-24 NgoMeyi 1974 e- Cologne, e-Germany. Wafunda i-biochemistry e- University of Cologne begodu waphothula ngo-2006 nge- PhD ; umtlolo wakhe bewuphathelene nethulusi elivulekileko lebhayoloji yamamolekhyuli, i-GENTle . &lt;ref name=&quot;Magnus Manske-2006&quot;&gt;{{Cite thesis|last=Magnus Manske|title=GENtle, a free multi-purpose molecular biology tool|access-date=27 March 2016|degree=PhD|publisher=University of Cologne|url=https://kups.ub.uni-koeln.de/1907/|archive-url=https://web.archive.org/web/20150407083730/https://kups.ub.uni-koeln.de/1907/|archive-date=7 April 2015|year=2006|author-link=Magnus Manske|url-status=live}}&lt;/ref&gt; 

== Ibizelo ==
Njengomfundi, u-Manske waba ngomunye wabantu bokuthoma afaka isandla ku-Inthanethi encyclopedia i-Nupedia, isandulela se-Wikipedia, begodu ngokukhamba kwesikhathi watlola enye yeenguqulo zokuthoma zesofthiwe ye-MediaWiki esetjenziswa yi-Wikipedia.  U-Manske usebenze e -Cambridge ne- Wellcome Sanger Institute kusukela ngoMrhayili 2007,      kodwana uhlala akhuthele ekuthuthukiseni amathulusi we-Wikipedia  kanye namaphrojekthi wayo we-Wikidata ne -Wikimedia Commons . 


In 2012, Manske was co-author of a paper published in ''[[:en:Nature_(journal)|Nature]]'' that demonstrated new ways to identify areas where malaria parasites are evolving, and described techniques for mapping malarial drug resistance. The researchers developed a technique to extract the malaria parasite DNA directly from the blood, which minimizes errors in sequencing

== Ukuthuthukiswa kwe-MediaWiki ==
Njengomfundi, u-Manske bekangomunye wabantu abafaka isandla khulu kuphrojekthi ye -Nupedia,  athumela okuqukethwe ngeenhloko zebhayoloji  begodu athuthukisa amathulusi neenngezelelo ze-Nupedia. &lt;ref name=&quot;Anderson&quot; /&gt; Ngokukhamba kwesikhathi, angathabi ngokulinganiselwa kwesofthiwe ekhona, &lt;ref name=&quot;SpiegelJansson&quot; /&gt; uManske wakha enye yeenguqulo zokuthoma zalokho okwaba yi-MediaWiki .   Inguqulo yakhe etja yesofthiwe yafakwa ngo-2002. &lt;ref name=&quot;SpiegelJansson&quot; /&gt;

Isofthiwe ye-wiki ebegade isetjenziselwa i-Wikipedia beyibizwa ngokuthi yi-UseModWiki begodu beyitlolwe nge -Perl . Njengombana iindaba zobukhulu zithoma ukuziveza njengombana i-Wikipedia ikhula, ngehlobo laka-2001, u-Manske wathoma ukusebenza ngokuthatha indawo ye-UseModWiki ebegade izokusekelwa yi-database begodu ibe &quot;nezinto ezithileko ze-wikipedia&quot;.  Mhlana amalanga ama-25 kuTjhirhweni 2002, u-Manske wakhipha inguqulo yokuthoma ye- MySQL -based PHP wiki engine, ebizwa nge ''-Phase II'' .  Enye into etja eyenziwa ngu-Manske esigabeni sesibili bekukusetjenziswa kwama-namespaces ukwenzela bona kuhlukaniswe imihlobo ehlukileko yamakhasi, njenge-&quot;Talk&quot; nofana &quot;User&quot; namespace, eyayihlukanisa nesofthiwe ye-wiki endala ebeyinganawo ama-namespace ahlukileko. &lt;ref name=&quot;Sumana&quot; /&gt; Isigaba sesibili sibuye sethula ezinye izinto ezisesekhona, okufaka hlangana ukulayisha ifayela, amarhelo wokuqapha, ukusayina okuzenzakalelayo, kanye nohlu lweminikelo yabasebenzisi.   Ukutlola kabutjha kwaka-Manske kwenze kwaba lula ukuhlanganisa iinthombe ema-atikilini we-Wikipedia, begodu kwakha isiqhema esitjha sabasebenzisi: abalawuli, abanikwe amandla wokususa amakhasi nokuvimba abacekela phambili.</text>
      <sha1>8vr9uhdurysrj5bdjjm97exmgqrw1c6</sha1>
    </revision>
    <revision>
      <id>6421</id>
      <parentid>6420</parentid>
      <timestamp>2026-04-15T03:26:19Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6421</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3695" sha1="lyfz6i2sbrxx7168dblwp6an1y8quph" xml:space="preserve">
'''U-Heinrich Magnus Manske''' (wabelethwa mhlana ali-24 NgoMeyi 1974) ngusosayensi we-biochemist we-German ongumrhubhululi wemalariya . Usosayensi omkhulu we- Wellcome Sanger Institute e- Cambridge, UK     begodu ungumthuthukisi wesofthiwe yenye yeenguqulo zokuthoma zesofthiwe ye -MediaWiki, enikela amandla [[Wikipedia|ku-Wikipedia]] namanye amawebhusayithi amanengi asekelwe ku- wiki .&lt;ref&gt;https://kups.ub.uni-koeln.de/1907/1/GENtle.pdf&lt;/ref&gt;

== Ipilo yokuthoma ==
U-Magnus Manske wabelethwa mhlazi-24 NgoMeyi 1974 e- Cologne, e-Germany. Wafunda i-biochemistry e- University of Cologne begodu waphothula ngo-2006 nge- PhD ; umtlolo wakhe bewuphathelene nethulusi elivulekileko lebhayoloji yamamolekhyuli, i-GENTle . &lt;ref name=&quot;Magnus Manske-2006&quot;&gt;{{Cite thesis|last=Magnus Manske|title=GENtle, a free multi-purpose molecular biology tool|access-date=27 March 2016|degree=PhD|publisher=University of Cologne|url=https://kups.ub.uni-koeln.de/1907/|archive-url=https://web.archive.org/web/20150407083730/https://kups.ub.uni-koeln.de/1907/|archive-date=7 April 2015|year=2006|author-link=Magnus Manske|url-status=live}}&lt;/ref&gt; 

== Ibizelo ==
Njengomfundi, u-Manske waba ngomunye wabantu bokuthoma afaka isandla ku-Inthanethi encyclopedia i-Nupedia, isandulela se-Wikipedia, begodu ngokukhamba kwesikhathi watlola enye yeenguqulo zokuthoma zesofthiwe ye-MediaWiki esetjenziswa yi-Wikipedia.  U-Manske usebenze e -Cambridge ne- Wellcome Sanger Institute kusukela ngoMrhayili 2007,      kodwana uhlala akhuthele ekuthuthukiseni amathulusi we-Wikipedia  kanye namaphrojekthi wayo we-Wikidata ne -Wikimedia Commons . 


In 2012, Manske was co-author of a paper published in ''[[:en:Nature_(journal)|Nature]]'' that demonstrated new ways to identify areas where malaria parasites are evolving, and described techniques for mapping malarial drug resistance. The researchers developed a technique to extract the malaria parasite DNA directly from the blood, which minimizes errors in sequencing

== Ukuthuthukiswa kwe-MediaWiki ==
Njengomfundi, u-Manske bekangomunye wabantu abafaka isandla khulu kuphrojekthi ye -Nupedia,  athumela okuqukethwe ngeenhloko zebhayoloji  begodu athuthukisa amathulusi neenngezelelo ze-Nupedia. &lt;ref name=&quot;Anderson&quot; /&gt; Ngokukhamba kwesikhathi, angathabi ngokulinganiselwa kwesofthiwe ekhona, &lt;ref name=&quot;SpiegelJansson&quot; /&gt; uManske wakha enye yeenguqulo zokuthoma zalokho okwaba yi-MediaWiki .   Inguqulo yakhe etja yesofthiwe yafakwa ngo-2002. &lt;ref name=&quot;SpiegelJansson&quot; /&gt;

Isofthiwe ye-wiki ebegade isetjenziselwa i-Wikipedia beyibizwa ngokuthi yi-UseModWiki begodu beyitlolwe nge -Perl . Njengombana iindaba zobukhulu zithoma ukuziveza njengombana i-Wikipedia ikhula, ngehlobo laka-2001, u-Manske wathoma ukusebenza ngokuthatha indawo ye-UseModWiki ebegade izokusekelwa yi-database begodu ibe &quot;nezinto ezithileko ze-wikipedia&quot;.  Mhlana amalanga ama-25 kuTjhirhweni 2002, u-Manske wakhipha inguqulo yokuthoma ye- MySQL -based PHP wiki engine, ebizwa nge ''-Phase II'' .  Enye into etja eyenziwa ngu-Manske esigabeni sesibili bekukusetjenziswa kwama-namespaces ukwenzela bona kuhlukaniswe imihlobo ehlukileko yamakhasi, njenge-&quot;Talk&quot; nofana &quot;User&quot; namespace, eyayihlukanisa nesofthiwe ye-wiki endala ebeyinganawo ama-namespace ahlukileko. &lt;ref name=&quot;Sumana&quot; /&gt; Isigaba sesibili sibuye sethula ezinye izinto ezisesekhona, okufaka hlangana ukulayisha ifayela, amarhelo wokuqapha, ukusayina okuzenzakalelayo, kanye nohlu lweminikelo yabasebenzisi.   Ukutlola kabutjha kwaka-Manske kwenze kwaba lula ukuhlanganisa iinthombe ema-atikilini we-Wikipedia, begodu kwakha isiqhema esitjha sabasebenzisi: abalawuli, abanikwe amandla wokususa amakhasi nokuvimba abacekela phambili.</text>
      <sha1>lyfz6i2sbrxx7168dblwp6an1y8quph</sha1>
    </revision>
    <revision>
      <id>6422</id>
      <parentid>6421</parentid>
      <timestamp>2026-04-15T05:39:54Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6422</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3592" sha1="60k33yhhxcj7i8bj0h5c82gs1b8buzu" xml:space="preserve">
'''U-Heinrich Magnus Manske''' (wabelethwa mhlana ali-24 NgoMeyi 1974) ngusosayensi we-biochemist we-German ongumrhubhululi wemalariya . Usosayensi omkhulu we- Wellcome Sanger Institute e- Cambridge, UK     begodu ungumthuthukisi wesofthiwe yenye yeenguqulo zokuthoma zesofthiwe ye -MediaWiki, enikela amandla [[Wikipedia|ku-Wikipedia]] namanye amawebhusayithi amanengi asekelwe ku- wiki .&lt;ref&gt;https://kups.ub.uni-koeln.de/1907/1/GENtle.pdf&lt;/ref&gt;

== Ipilo yokuthoma ==
U-Magnus Manske wabelethwa mhlazi-24 NgoMeyi 1974 e- Cologne, e-Germany. Wafunda i-biochemistry e- University of Cologne begodu waphothula ngo-2006 nge- PhD ; umtlolo wakhe bewuphathelene nethulusi elivulekileko lebhayoloji yamamolekhyuli, i-GENTle . &lt;ref name=&quot;Magnus Manske-2006&quot;&gt;{{Cite thesis|last=Magnus Manske|title=GENtle, a free multi-purpose molecular biology tool|access-date=27 March 2016|degree=PhD|publisher=University of Cologne|url=https://kups.ub.uni-koeln.de/1907/|archive-url=https://web.archive.org/web/20150407083730/https://kups.ub.uni-koeln.de/1907/|archive-date=7 April 2015|year=2006|author-link=Magnus Manske|url-status=live}}&lt;/ref&gt; 

== Ibizelo ==
Njengomfundi, u-Manske waba ngomunye wabantu bokuthoma afaka isandla ku-Inthanethi encyclopedia i-Nupedia, isandulela se-Wikipedia, begodu ngokukhamba kwesikhathi watlola enye yeenguqulo zokuthoma zesofthiwe ye-MediaWiki esetjenziswa yi-Wikipedia.  U-Manske usebenze e -Cambridge ne- Wellcome Sanger Institute kusukela ngoMrhayili 2007,      kodwana uhlala akhuthele ekuthuthukiseni amathulusi we-Wikipedia  kanye namaphrojekthi wayo we-Wikidata ne -Wikimedia Commons . 


In 2012, Manske was co-author of a paper published in ''[[:en:Nature_(journal)|Nature]]'' that demonstrated new ways to identify areas where malaria parasites are evolving, and described techniques for mapping malarial drug resistance. The researchers developed a technique to extract the malaria parasite DNA directly from the blood, which minimizes errors in sequencing

== Ukuthuthukiswa kwe-MediaWiki ==
Njengomfundi, u-Manske bekangomunye wabantu abafaka isandla khulu kuphrojekthi ye -Nupedia,  athumela okuqukethwe ngeenhloko zebhayoloji  begodu athuthukisa amathulusi neenngezelelo ze-Nupedia.  Ngokukhamba kwesikhathi, angathabi ngokulinganiselwa kwesofthiwe ekhona, uManske wakha enye yeenguqulo zokuthoma zalokho okwaba yi-MediaWiki .   Inguqulo yakhe etja yesofthiwe yafakwa ngo-2002. 

Isofthiwe ye-wiki ebegade isetjenziselwa i-Wikipedia beyibizwa ngokuthi yi-UseModWiki begodu beyitlolwe nge -Perl . Njengombana iindaba zobukhulu zithoma ukuziveza njengombana i-Wikipedia ikhula, ngehlobo laka-2001, u-Manske wathoma ukusebenza ngokuthatha indawo ye-UseModWiki ebegade izokusekelwa yi-database begodu ibe &quot;nezinto ezithileko ze-wikipedia&quot;.  Mhlana amalanga ama-25 kuTjhirhweni 2002, u-Manske wakhipha inguqulo yokuthoma ye- MySQL -based PHP wiki engine, ebizwa nge ''-Phase II'' .  Enye into etja eyenziwa ngu-Manske esigabeni sesibili bekukusetjenziswa kwama-namespaces ukwenzela bona kuhlukaniswe imihlobo ehlukileko yamakhasi, njenge-&quot;Talk&quot; nofana &quot;User&quot; namespace, eyayihlukanisa nesofthiwe ye-wiki endala ebeyinganawo ama-namespace ahlukileko.  Isigaba sesibili sibuye sethula ezinye izinto ezisesekhona, okufaka hlangana ukulayisha ifayela, amarhelo wokuqapha, ukusayina okuzenzakalelayo, kanye nohlu lweminikelo yabasebenzisi.   Ukutlola kabutjha kwaka-Manske kwenze kwaba lula ukuhlanganisa iinthombe ema-atikilini we-Wikipedia, begodu kwakha isiqhema esitjha sabasebenzisi: abalawuli, abanikwe amandla wokususa amakhasi nokuvimba abacekela phambili.</text>
      <sha1>60k33yhhxcj7i8bj0h5c82gs1b8buzu</sha1>
    </revision>
    <revision>
      <id>6423</id>
      <parentid>6422</parentid>
      <timestamp>2026-04-15T05:40:14Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6423</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3608" sha1="juh40q24ywiqd180hfr4ndpgpw3x8jv" xml:space="preserve">
'''U-Heinrich Magnus Manske''' (wabelethwa mhlana ali-24 NgoMeyi 1974) ngusosayensi we-biochemist we-German ongumrhubhululi wemalariya . Usosayensi omkhulu we- Wellcome Sanger Institute e- Cambridge, UK     begodu ungumthuthukisi wesofthiwe yenye yeenguqulo zokuthoma zesofthiwe ye -MediaWiki, enikela amandla [[Wikipedia|ku-Wikipedia]] namanye amawebhusayithi amanengi asekelwe ku- wiki .&lt;ref&gt;https://kups.ub.uni-koeln.de/1907/1/GENtle.pdf&lt;/ref&gt;

== Ipilo yokuthoma ==
U-Magnus Manske wabelethwa mhlazi-24 NgoMeyi 1974 e- Cologne, e-Germany. Wafunda i-biochemistry e- University of Cologne begodu waphothula ngo-2006 nge- PhD ; umtlolo wakhe bewuphathelene nethulusi elivulekileko lebhayoloji yamamolekhyuli, i-GENTle . &lt;ref name=&quot;Magnus Manske-2006&quot;&gt;{{Cite thesis|last=Magnus Manske|title=GENtle, a free multi-purpose molecular biology tool|access-date=27 March 2016|degree=PhD|publisher=University of Cologne|url=https://kups.ub.uni-koeln.de/1907/|archive-url=https://web.archive.org/web/20150407083730/https://kups.ub.uni-koeln.de/1907/|archive-date=7 April 2015|year=2006|author-link=Magnus Manske|url-status=live}}&lt;/ref&gt; 

== Ibizelo ==
Njengomfundi, u-Manske waba ngomunye wabantu bokuthoma afaka isandla ku-Inthanethi encyclopedia i-Nupedia, isandulela se-Wikipedia, begodu ngokukhamba kwesikhathi watlola enye yeenguqulo zokuthoma zesofthiwe ye-MediaWiki esetjenziswa yi-Wikipedia.  U-Manske usebenze e -Cambridge ne- Wellcome Sanger Institute kusukela ngoMrhayili 2007,      kodwana uhlala akhuthele ekuthuthukiseni amathulusi we-Wikipedia  kanye namaphrojekthi wayo we-Wikidata ne -Wikimedia Commons . 


In 2012, Manske was co-author of a paper published in ''[[:en:Nature_(journal)|Nature]]'' that demonstrated new ways to identify areas where malaria parasites are evolving, and described techniques for mapping malarial drug resistance. The researchers developed a technique to extract the malaria parasite DNA directly from the blood, which minimizes errors in sequencing

== Ukuthuthukiswa kwe-MediaWiki ==
Njengomfundi, u-Manske bekangomunye wabantu abafaka isandla khulu kuphrojekthi ye -Nupedia,  athumela okuqukethwe ngeenhloko zebhayoloji  begodu athuthukisa amathulusi neenngezelelo ze-Nupedia.  Ngokukhamba kwesikhathi, angathabi ngokulinganiselwa kwesofthiwe ekhona, uManske wakha enye yeenguqulo zokuthoma zalokho okwaba yi-MediaWiki .   Inguqulo yakhe etja yesofthiwe yafakwa ngo-2002. 

Isofthiwe ye-wiki ebegade isetjenziselwa i-Wikipedia beyibizwa ngokuthi yi-UseModWiki begodu beyitlolwe nge -Perl . Njengombana iindaba zobukhulu zithoma ukuziveza njengombana i-Wikipedia ikhula, ngehlobo laka-2001, u-Manske wathoma ukusebenza ngokuthatha indawo ye-UseModWiki ebegade izokusekelwa yi-database begodu ibe &quot;nezinto ezithileko ze-wikipedia&quot;.  Mhlana amalanga ama-25 kuTjhirhweni 2002, u-Manske wakhipha inguqulo yokuthoma ye- MySQL -based PHP wiki engine, ebizwa nge ''-Phase II'' .  Enye into etja eyenziwa ngu-Manske esigabeni sesibili bekukusetjenziswa kwama-namespaces ukwenzela bona kuhlukaniswe imihlobo ehlukileko yamakhasi, njenge-&quot;Talk&quot; nofana &quot;User&quot; namespace, eyayihlukanisa nesofthiwe ye-wiki endala ebeyinganawo ama-namespace ahlukileko.  Isigaba sesibili sibuye sethula ezinye izinto ezisesekhona, okufaka hlangana ukulayisha ifayela, amarhelo wokuqapha, ukusayina okuzenzakalelayo, kanye nohlu lweminikelo yabasebenzisi.   Ukutlola kabutjha kwaka-Manske kwenze kwaba lula ukuhlanganisa iinthombe ema-atikilini we-Wikipedia, begodu kwakha isiqhema esitjha sabasebenzisi: abalawuli, abanikwe amandla wokususa amakhasi nokuvimba abacekela phambili.

== Iinkomba ==</text>
      <sha1>juh40q24ywiqd180hfr4ndpgpw3x8jv</sha1>
    </revision>
    <revision>
      <id>6424</id>
      <parentid>6423</parentid>
      <timestamp>2026-04-15T05:40:27Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6424</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3203" sha1="qydgeoeug1qfzccym199rc476t0o10m" xml:space="preserve">
'''U-Heinrich Magnus Manske''' (wabelethwa mhlana ali-24 NgoMeyi 1974) ngusosayensi we-biochemist we-German ongumrhubhululi wemalariya . Usosayensi omkhulu we- Wellcome Sanger Institute e- Cambridge, UK     begodu ungumthuthukisi wesofthiwe yenye yeenguqulo zokuthoma zesofthiwe ye -MediaWiki, enikela amandla [[Wikipedia|ku-Wikipedia]] namanye amawebhusayithi amanengi asekelwe ku- wiki .&lt;ref&gt;https://kups.ub.uni-koeln.de/1907/1/GENtle.pdf&lt;/ref&gt;

== Ipilo yokuthoma ==
U-Magnus Manske wabelethwa mhlazi-24 NgoMeyi 1974 e- Cologne, e-Germany. Wafunda i-biochemistry e- University of Cologne begodu waphothula ngo-2006 nge- PhD ; umtlolo wakhe bewuphathelene nethulusi elivulekileko lebhayoloji yamamolekhyuli, i-GENTle .  

== Ibizelo ==
Njengomfundi, u-Manske waba ngomunye wabantu bokuthoma afaka isandla ku-Inthanethi encyclopedia i-Nupedia, isandulela se-Wikipedia, begodu ngokukhamba kwesikhathi watlola enye yeenguqulo zokuthoma zesofthiwe ye-MediaWiki esetjenziswa yi-Wikipedia.  U-Manske usebenze e -Cambridge ne- Wellcome Sanger Institute kusukela ngoMrhayili 2007,      kodwana uhlala akhuthele ekuthuthukiseni amathulusi we-Wikipedia  kanye namaphrojekthi wayo we-Wikidata ne -Wikimedia Commons . 


In 2012, Manske was co-author of a paper published in ''[[:en:Nature_(journal)|Nature]]'' that demonstrated new ways to identify areas where malaria parasites are evolving, and described techniques for mapping malarial drug resistance. The researchers developed a technique to extract the malaria parasite DNA directly from the blood, which minimizes errors in sequencing

== Ukuthuthukiswa kwe-MediaWiki ==
Njengomfundi, u-Manske bekangomunye wabantu abafaka isandla khulu kuphrojekthi ye -Nupedia,  athumela okuqukethwe ngeenhloko zebhayoloji  begodu athuthukisa amathulusi neenngezelelo ze-Nupedia.  Ngokukhamba kwesikhathi, angathabi ngokulinganiselwa kwesofthiwe ekhona, uManske wakha enye yeenguqulo zokuthoma zalokho okwaba yi-MediaWiki .   Inguqulo yakhe etja yesofthiwe yafakwa ngo-2002. 

Isofthiwe ye-wiki ebegade isetjenziselwa i-Wikipedia beyibizwa ngokuthi yi-UseModWiki begodu beyitlolwe nge -Perl . Njengombana iindaba zobukhulu zithoma ukuziveza njengombana i-Wikipedia ikhula, ngehlobo laka-2001, u-Manske wathoma ukusebenza ngokuthatha indawo ye-UseModWiki ebegade izokusekelwa yi-database begodu ibe &quot;nezinto ezithileko ze-wikipedia&quot;.  Mhlana amalanga ama-25 kuTjhirhweni 2002, u-Manske wakhipha inguqulo yokuthoma ye- MySQL -based PHP wiki engine, ebizwa nge ''-Phase II'' .  Enye into etja eyenziwa ngu-Manske esigabeni sesibili bekukusetjenziswa kwama-namespaces ukwenzela bona kuhlukaniswe imihlobo ehlukileko yamakhasi, njenge-&quot;Talk&quot; nofana &quot;User&quot; namespace, eyayihlukanisa nesofthiwe ye-wiki endala ebeyinganawo ama-namespace ahlukileko.  Isigaba sesibili sibuye sethula ezinye izinto ezisesekhona, okufaka hlangana ukulayisha ifayela, amarhelo wokuqapha, ukusayina okuzenzakalelayo, kanye nohlu lweminikelo yabasebenzisi.   Ukutlola kabutjha kwaka-Manske kwenze kwaba lula ukuhlanganisa iinthombe ema-atikilini we-Wikipedia, begodu kwakha isiqhema esitjha sabasebenzisi: abalawuli, abanikwe amandla wokususa amakhasi nokuvimba abacekela phambili.

== Iinkomba ==</text>
      <sha1>qydgeoeug1qfzccym199rc476t0o10m</sha1>
    </revision>
    <revision>
      <id>6425</id>
      <parentid>6424</parentid>
      <timestamp>2026-04-15T05:41:43Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6425</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3263" sha1="mgq7gmudbrrs2hkfdyhisteu3oyxvk7" xml:space="preserve">
'''U-Heinrich Magnus Manske''' (wabelethwa mhlana ali-24 NgoMeyi 1974) ngusosayensi we-biochemist we-German ongumrhubhululi wemalariya . Usosayensi omkhulu we- Wellcome Sanger Institute e- Cambridge, UK     begodu ungumthuthukisi wesofthiwe yenye yeenguqulo zokuthoma zesofthiwe ye -MediaWiki, enikela amandla [[Wikipedia|ku-Wikipedia]] namanye amawebhusayithi amanengi asekelwe ku- wiki .&lt;ref&gt;https://kups.ub.uni-koeln.de/1907/1/GENtle.pdf&lt;/ref&gt;

== Ipilo yokuthoma ==
U-Magnus Manske wabelethwa mhlazi-24 NgoMeyi 1974 e- Cologne, e-Germany. Wafunda i-biochemistry e- University of Cologne begodu waphothula ngo-2006 nge- PhD ; umtlolo wakhe bewuphathelene nethulusi elivulekileko lebhayoloji yamamolekhyuli, i-GENTle .&lt;ref&gt;https://pmc.ncbi.nlm.nih.gov/articles/PMC3738909/&lt;/ref&gt;  

== Ibizelo ==
Njengomfundi, u-Manske waba ngomunye wabantu bokuthoma afaka isandla ku-Inthanethi encyclopedia i-Nupedia, isandulela se-Wikipedia, begodu ngokukhamba kwesikhathi watlola enye yeenguqulo zokuthoma zesofthiwe ye-MediaWiki esetjenziswa yi-Wikipedia.  U-Manske usebenze e -Cambridge ne- Wellcome Sanger Institute kusukela ngoMrhayili 2007,      kodwana uhlala akhuthele ekuthuthukiseni amathulusi we-Wikipedia  kanye namaphrojekthi wayo we-Wikidata ne -Wikimedia Commons . 


In 2012, Manske was co-author of a paper published in ''[[:en:Nature_(journal)|Nature]]'' that demonstrated new ways to identify areas where malaria parasites are evolving, and described techniques for mapping malarial drug resistance. The researchers developed a technique to extract the malaria parasite DNA directly from the blood, which minimizes errors in sequencing

== Ukuthuthukiswa kwe-MediaWiki ==
Njengomfundi, u-Manske bekangomunye wabantu abafaka isandla khulu kuphrojekthi ye -Nupedia,  athumela okuqukethwe ngeenhloko zebhayoloji  begodu athuthukisa amathulusi neenngezelelo ze-Nupedia.  Ngokukhamba kwesikhathi, angathabi ngokulinganiselwa kwesofthiwe ekhona, uManske wakha enye yeenguqulo zokuthoma zalokho okwaba yi-MediaWiki .   Inguqulo yakhe etja yesofthiwe yafakwa ngo-2002. 

Isofthiwe ye-wiki ebegade isetjenziselwa i-Wikipedia beyibizwa ngokuthi yi-UseModWiki begodu beyitlolwe nge -Perl . Njengombana iindaba zobukhulu zithoma ukuziveza njengombana i-Wikipedia ikhula, ngehlobo laka-2001, u-Manske wathoma ukusebenza ngokuthatha indawo ye-UseModWiki ebegade izokusekelwa yi-database begodu ibe &quot;nezinto ezithileko ze-wikipedia&quot;.  Mhlana amalanga ama-25 kuTjhirhweni 2002, u-Manske wakhipha inguqulo yokuthoma ye- MySQL -based PHP wiki engine, ebizwa nge ''-Phase II'' .  Enye into etja eyenziwa ngu-Manske esigabeni sesibili bekukusetjenziswa kwama-namespaces ukwenzela bona kuhlukaniswe imihlobo ehlukileko yamakhasi, njenge-&quot;Talk&quot; nofana &quot;User&quot; namespace, eyayihlukanisa nesofthiwe ye-wiki endala ebeyinganawo ama-namespace ahlukileko.  Isigaba sesibili sibuye sethula ezinye izinto ezisesekhona, okufaka hlangana ukulayisha ifayela, amarhelo wokuqapha, ukusayina okuzenzakalelayo, kanye nohlu lweminikelo yabasebenzisi.   Ukutlola kabutjha kwaka-Manske kwenze kwaba lula ukuhlanganisa iinthombe ema-atikilini we-Wikipedia, begodu kwakha isiqhema esitjha sabasebenzisi: abalawuli, abanikwe amandla wokususa amakhasi nokuvimba abacekela phambili.

== Iinkomba ==</text>
      <sha1>mgq7gmudbrrs2hkfdyhisteu3oyxvk7</sha1>
    </revision>
  </page>
  <page>
    <title>U-Ebrahim Ebrahim</title>
    <ns>0</ns>
    <id>1093</id>
    <revision>
      <id>6426</id>
      <timestamp>2026-04-15T05:48:27Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created page with &quot;'''U-Ebrahim Ismail Ebrahim''' [[Order of Luthuli|OLG]] (1 Julayi 1937{{Spaced en dash}}6 December 2021) bekalilunga le-[[Indian South Africans|Indian origin]] ebelilunga le-[[African National Congress] U-Sizwe]]''.'' Wagwetjwa emacaleni wokubhubhisa we-Pietermaritzburg wango-1963 begodu wagwetjwa iminyaka eli-15 ejele [[Jele eliVikele khulu, i-Robben Island|Jele le-Robben Island eliPhezulu eliPhezulu]].  Waziwa ngokuthi ngu-Ebie, wasebenza njengelunga lomthetho ukheth...&quot;</comment>
      <origin>6426</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2233" sha1="2bx3ugz6ah9uh3vhj0lpq9o5vm9ipyj" xml:space="preserve">'''U-Ebrahim Ismail Ebrahim''' [[Order of Luthuli|OLG]] (1 Julayi 1937{{Spaced en dash}}6 December 2021) bekalilunga le-[[Indian South Africans|Indian origin]] ebelilunga le-[[African National Congress] U-Sizwe]]''.'' Wagwetjwa emacaleni wokubhubhisa we-Pietermaritzburg wango-1963 begodu wagwetjwa iminyaka eli-15 ejele [[Jele eliVikele khulu, i-Robben Island|Jele le-Robben Island eliPhezulu eliPhezulu]].

Waziwa ngokuthi ngu-Ebie, wasebenza njengelunga lomthetho [[ukhetho jikelele lweSewula Afrika ka-1994|urhulumende wokuthoma okhethwe ngentando yenengi weSewula Afrika ngo-1994]] begodu wasebenza njengesekela likaNgqongqotjhe wezobudlelwano beentjhabatjhaba hlangana nomnyaka ka-2009 ukuya ku-2014.

== Ipilo yokuthoma ==
U-Ebrahim wabelethwa e-[[Durban]] ngo-1937 kubabelethi, u-Hafeeza no-Mohammed Adam Modan, abavela e-India. Uyise bekavela e-[[Gujarat]] begodu waya e-[[Union of South Africa|South Africa]] ngo-1933, ngesikhathi unina abelethelwa e-South Africa. Uyise wathatha isibongo esithi-Ebrahim emndenini ebegade akhamba nawo eSewula Afrika. veteran?|url=https://indianexpress.com/article/explained/who-was-ebrahim-ebrahim-indian-origin-anti-apartheid-veteran-7661106/|access-date=8 December 2021|website=The Indian Express|language=en|archive-december 2021|archive-url=https://web.archive.org/web/20211208020415/https://indianexpress.com/article/explained/who-was-ebrahim-ebrahim-indian-origin-anti-apartheid-veteran-76611106/{urveter}{restaus}{restatus} incwadi|umtloli=Ebrahim, Shannon|url=http://worldcat.org/oclc/1061275307|isihloko=Ebrahim Ismail U-Ebrahim : umvukelambuso omnene|oclc=1061275307|ilanga lokufinyelela=8 kuNobayeni 2021|ilanga lokugcina=Disemba-8 2021|archive-url=https://web.archive.org/web/20211208221001/https://www.worldcat.org/title/ebrahim-ismail-ebrahim-a-gentle-revolutionary/oclc/1061275307|url-status&lt;/i&gt;ve}fre}

Iimfundo zaka-Ebrahim zatlhogonyelwa ngugogo wakhe ngemva kobana iimphathimandla zimenqabele ukungena esikolweni samabanga aphasi, zithi iinkolo zabafundi be-India bezizele begodu angeze zamukela. Lokhu kwaragela phambili iminyaka emihlanu bekwaba kulapho aneminyaka elitjhumi. Wabe wajoyina isikolo esisekelwa ngurhulumende i-The Hindu Tamil Institute.&lt;ref name=&quot;:1&quot; /&gt;</text>
      <sha1>2bx3ugz6ah9uh3vhj0lpq9o5vm9ipyj</sha1>
    </revision>
    <revision>
      <id>6427</id>
      <parentid>6426</parentid>
      <timestamp>2026-04-15T05:51:02Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6427</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1269" sha1="rtvhhlbrhd2n8kkb29284iqpa1w1aao" xml:space="preserve">U-Ebrahim Ismail U-Ebrahim OLG (1 kuNobayeni 1937 – 6 kuNobayeni 2021) bekangumlweli weSewula Afrika olwisana nebandlululo we-India ogade alilunga le-African National Congress's armed wing uMkhonto we Sizwe. Wagwetjwa emacaleni we-Pietermaritzburg sabotage wango-1963 begodu wagwetjwa iminyaka eli-15 ejele e-Robben Island Maximum Security Prison.

Waziwa ngokuthi ngu-Ebie, wasebenza njengommeli kurhulumende weSewula Afrika wokuthoma owakhethwa ngentando yenengi ngo-1994 begodu wasebenza njengesekela likaNgqongqotjhe wezobudlelwano beentjhabatjhaba hlangana nomnyaka ka-2009 ukuya ku-2014.

Ipilo yokuthoma

U-Ebrahim wabelethwa e-Durban ngo-1937 kubabelethi, u-Hafeeza no-Mohammed Adam Modan, abavela e-India. Uyise bekavela e-Gujarat begodu waya eSewula Afrika ngo-1933, kuthi unina wabelethelwa eSewula Afrika. Uyise wathatha isibongo esithi-Ebrahim emndenini ebegade akhamba nawo eSewula Afrika.[1][2]

Iimfundo zaka-Ebrahim zatlhogonyelwa ngugogo wakhe ngemva kobana iimphathimandla zimenqabele ukungena esikolweni samabanga aphasi, zithi iinkolo zabafundi be-India bezizele begodu angeze zamukela. Lokhu kwaragela phambili iminyaka emihlanu bekwaba kulapho aneminyaka elitjhumi. Wabe wajoyina isikolo esisekelwa ngurhulumende i-The Hindu Tamil Institute.[1]</text>
      <sha1>rtvhhlbrhd2n8kkb29284iqpa1w1aao</sha1>
    </revision>
    <revision>
      <id>6428</id>
      <parentid>6427</parentid>
      <timestamp>2026-04-15T05:51:15Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6428</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1274" sha1="mpo0joymj1xhhxsmlfdz1tei831qhn8" xml:space="preserve">U-Ebrahim Ismail U-Ebrahim OLG (1 kuNobayeni 1937 – 6 kuNobayeni 2021) bekangumlweli weSewula Afrika olwisana nebandlululo we-India ogade alilunga le-African National Congress's armed wing uMkhonto we Sizwe. Wagwetjwa emacaleni we-Pietermaritzburg sabotage wango-1963 begodu wagwetjwa iminyaka eli-15 ejele e-Robben Island Maximum Security Prison.

Waziwa ngokuthi ngu-Ebie, wasebenza njengommeli kurhulumende weSewula Afrika wokuthoma owakhethwa ngentando yenengi ngo-1994 begodu wasebenza njengesekela likaNgqongqotjhe wezobudlelwano beentjhabatjhaba hlangana nomnyaka ka-2009 ukuya ku-2014.

== Ipilo yokuthoma ==
U-Ebrahim wabelethwa e-Durban ngo-1937 kubabelethi, u-Hafeeza no-Mohammed Adam Modan, abavela e-India. Uyise bekavela e-Gujarat begodu waya eSewula Afrika ngo-1933, kuthi unina wabelethelwa eSewula Afrika. Uyise wathatha isibongo esithi-Ebrahim emndenini ebegade akhamba nawo eSewula Afrika.[1][2]

Iimfundo zaka-Ebrahim zatlhogonyelwa ngugogo wakhe ngemva kobana iimphathimandla zimenqabele ukungena esikolweni samabanga aphasi, zithi iinkolo zabafundi be-India bezizele begodu angeze zamukela. Lokhu kwaragela phambili iminyaka emihlanu bekwaba kulapho aneminyaka elitjhumi. Wabe wajoyina isikolo esisekelwa ngurhulumende i-The Hindu Tamil Institute.[1]</text>
      <sha1>mpo0joymj1xhhxsmlfdz1tei831qhn8</sha1>
    </revision>
    <revision>
      <id>6429</id>
      <parentid>6428</parentid>
      <timestamp>2026-04-15T05:51:31Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6429</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1265" sha1="2j6nfv3sl4vzbo7xn9e3upp41k3hr46" xml:space="preserve">U-Ebrahim Ismail U-Ebrahim OLG (1 kuNobayeni 1937 – 6 kuNobayeni 2021) bekangumlweli weSewula Afrika olwisana nebandlululo we-India ogade alilunga le-African National Congress's armed wing uMkhonto we Sizwe. Wagwetjwa emacaleni we-Pietermaritzburg sabotage wango-1963 begodu wagwetjwa iminyaka eli-15 ejele e-Robben Island Maximum Security Prison.

Waziwa ngokuthi ngu-Ebie, wasebenza njengommeli kurhulumende weSewula Afrika wokuthoma owakhethwa ngentando yenengi ngo-1994 begodu wasebenza njengesekela likaNgqongqotjhe wezobudlelwano beentjhabatjhaba hlangana nomnyaka ka-2009 ukuya ku-2014.

== Ipilo yokuthoma ==
U-Ebrahim wabelethwa e-Durban ngo-1937 kubabelethi, u-Hafeeza no-Mohammed Adam Modan, abavela e-India. Uyise bekavela e-Gujarat begodu waya eSewula Afrika ngo-1933, kuthi unina wabelethelwa eSewula Afrika. Uyise wathatha isibongo esithi-Ebrahim emndenini ebegade akhamba nawo eSewula Afrika.

Iimfundo zaka-Ebrahim zatlhogonyelwa ngugogo wakhe ngemva kobana iimphathimandla zimenqabele ukungena esikolweni samabanga aphasi, zithi iinkolo zabafundi be-India bezizele begodu angeze zamukela. Lokhu kwaragela phambili iminyaka emihlanu bekwaba kulapho aneminyaka elitjhumi. Wabe wajoyina isikolo esisekelwa ngurhulumende i-The Hindu Tamil Institute.</text>
      <sha1>2j6nfv3sl4vzbo7xn9e3upp41k3hr46</sha1>
    </revision>
    <revision>
      <id>6430</id>
      <parentid>6429</parentid>
      <timestamp>2026-04-15T05:51:48Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6430</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1271" sha1="l8zivfl42qxyhfwq62u4rhn87uy9qsa" xml:space="preserve">'''U-Ebrahim Ismail U-Ebrahim''' OLG (1 kuNobayeni 1937 – 6 kuNobayeni 2021) bekangumlweli weSewula Afrika olwisana nebandlululo we-India ogade alilunga le-African National Congress's armed wing uMkhonto we Sizwe. Wagwetjwa emacaleni we-Pietermaritzburg sabotage wango-1963 begodu wagwetjwa iminyaka eli-15 ejele e-Robben Island Maximum Security Prison.

Waziwa ngokuthi ngu-Ebie, wasebenza njengommeli kurhulumende weSewula Afrika wokuthoma owakhethwa ngentando yenengi ngo-1994 begodu wasebenza njengesekela likaNgqongqotjhe wezobudlelwano beentjhabatjhaba hlangana nomnyaka ka-2009 ukuya ku-2014.

== Ipilo yokuthoma ==
U-Ebrahim wabelethwa e-Durban ngo-1937 kubabelethi, u-Hafeeza no-Mohammed Adam Modan, abavela e-India. Uyise bekavela e-Gujarat begodu waya eSewula Afrika ngo-1933, kuthi unina wabelethelwa eSewula Afrika. Uyise wathatha isibongo esithi-Ebrahim emndenini ebegade akhamba nawo eSewula Afrika.

Iimfundo zaka-Ebrahim zatlhogonyelwa ngugogo wakhe ngemva kobana iimphathimandla zimenqabele ukungena esikolweni samabanga aphasi, zithi iinkolo zabafundi be-India bezizele begodu angeze zamukela. Lokhu kwaragela phambili iminyaka emihlanu bekwaba kulapho aneminyaka elitjhumi. Wabe wajoyina isikolo esisekelwa ngurhulumende i-The Hindu Tamil Institute.</text>
      <sha1>l8zivfl42qxyhfwq62u4rhn87uy9qsa</sha1>
    </revision>
    <revision>
      <id>6431</id>
      <parentid>6430</parentid>
      <timestamp>2026-04-15T05:54:09Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6431</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1334" sha1="22szmshmg2h325hrsie82x8ue3fvh97" xml:space="preserve">'''U-Ebrahim Ismail U-Ebrahim''' OLG (1 kuNobayeni 1937 – 6 kuNobayeni 2021) bekangumlweli weSewula Afrika olwisana nebandlululo we-India ogade alilunga le-African National Congress's armed wing uMkhonto we Sizwe. Wagwetjwa emacaleni we-Pietermaritzburg sabotage wango-1963 begodu wagwetjwa iminyaka eli-15 ejele e-Robben Island Maximum Security Prison.&lt;ref&gt;https://www.pa.org.za/person/ebrahim-ismail-ebrahim/&lt;/ref&gt;

Waziwa ngokuthi ngu-Ebie, wasebenza njengommeli kurhulumende weSewula Afrika wokuthoma owakhethwa ngentando yenengi ngo-1994 begodu wasebenza njengesekela likaNgqongqotjhe wezobudlelwano beentjhabatjhaba hlangana nomnyaka ka-2009 ukuya ku-2014.

== Ipilo yokuthoma ==
U-Ebrahim wabelethwa e-Durban ngo-1937 kubabelethi, u-Hafeeza no-Mohammed Adam Modan, abavela e-India. Uyise bekavela e-Gujarat begodu waya eSewula Afrika ngo-1933, kuthi unina wabelethelwa eSewula Afrika. Uyise wathatha isibongo esithi-Ebrahim emndenini ebegade akhamba nawo eSewula Afrika.

Iimfundo zaka-Ebrahim zatlhogonyelwa ngugogo wakhe ngemva kobana iimphathimandla zimenqabele ukungena esikolweni samabanga aphasi, zithi iinkolo zabafundi be-India bezizele begodu angeze zamukela. Lokhu kwaragela phambili iminyaka emihlanu bekwaba kulapho aneminyaka elitjhumi. Wabe wajoyina isikolo esisekelwa ngurhulumende i-The Hindu Tamil Institute.</text>
      <sha1>22szmshmg2h325hrsie82x8ue3fvh97</sha1>
    </revision>
    <revision>
      <id>6432</id>
      <parentid>6431</parentid>
      <timestamp>2026-04-15T05:55:25Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6432</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1399" sha1="isleus5ina2gdcwypt13xr3qrj9wh2a" xml:space="preserve">'''U-Ebrahim Ismail U-Ebrahim''' OLG (1 kuNobayeni 1937 – 6 kuNobayeni 2021) bekangumlweli weSewula Afrika olwisana nebandlululo we-India ogade alilunga le-African National Congress's armed wing uMkhonto we Sizwe. Wagwetjwa emacaleni we-Pietermaritzburg sabotage wango-1963 begodu wagwetjwa iminyaka eli-15 ejele e-Robben Island Maximum Security Prison.&lt;ref&gt;https://www.pa.org.za/person/ebrahim-ismail-ebrahim/&lt;/ref&gt;

Waziwa ngokuthi ngu-Ebie, wasebenza njengommeli kurhulumende weSewula Afrika wokuthoma owakhethwa ngentando yenengi ngo-1994 begodu wasebenza njengesekela likaNgqongqotjhe wezobudlelwano beentjhabatjhaba hlangana nomnyaka ka-2009 ukuya ku-2014.&lt;ref&gt;https://sahistory.org.za/people/ebrahim-ismail-ebrahim&lt;/ref&gt;

== Ipilo yokuthoma ==
U-Ebrahim wabelethwa e-Durban ngo-1937 kubabelethi, u-Hafeeza no-Mohammed Adam Modan, abavela e-India. Uyise bekavela e-Gujarat begodu waya eSewula Afrika ngo-1933, kuthi unina wabelethelwa eSewula Afrika. Uyise wathatha isibongo esithi-Ebrahim emndenini ebegade akhamba nawo eSewula Afrika.

Iimfundo zaka-Ebrahim zatlhogonyelwa ngugogo wakhe ngemva kobana iimphathimandla zimenqabele ukungena esikolweni samabanga aphasi, zithi iinkolo zabafundi be-India bezizele begodu angeze zamukela. Lokhu kwaragela phambili iminyaka emihlanu bekwaba kulapho aneminyaka elitjhumi. Wabe wajoyina isikolo esisekelwa ngurhulumende i-The Hindu Tamil Institute.</text>
      <sha1>isleus5ina2gdcwypt13xr3qrj9wh2a</sha1>
    </revision>
    <revision>
      <id>6433</id>
      <parentid>6432</parentid>
      <timestamp>2026-04-15T05:56:23Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6433</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1527" sha1="swj7g9enjux86ku6l4gqygdenlznx3f" xml:space="preserve">'''U-Ebrahim Ismail U-Ebrahim''' OLG (1 kuNobayeni 1937 – 6 kuNobayeni 2021) bekangumlweli weSewula Afrika olwisana nebandlululo we-India ogade alilunga le-African National Congress's armed wing uMkhonto we Sizwe. Wagwetjwa emacaleni we-Pietermaritzburg sabotage wango-1963 begodu wagwetjwa iminyaka eli-15 ejele e-Robben Island Maximum Security Prison.&lt;ref&gt;https://www.pa.org.za/person/ebrahim-ismail-ebrahim/&lt;/ref&gt;

Waziwa ngokuthi ngu-Ebie, wasebenza njengommeli kurhulumende weSewula Afrika wokuthoma owakhethwa ngentando yenengi ngo-1994 begodu wasebenza njengesekela likaNgqongqotjhe wezobudlelwano beentjhabatjhaba hlangana nomnyaka ka-2009 ukuya ku-2014.&lt;ref&gt;https://sahistory.org.za/people/ebrahim-ismail-ebrahim&lt;/ref&gt;

== Ipilo yokuthoma ==
U-Ebrahim wabelethwa e-Durban ngo-1937 kubabelethi, u-Hafeeza no-Mohammed Adam Modan, abavela e-India. Uyise bekavela e-Gujarat begodu waya eSewula Afrika ngo-1933, kuthi unina wabelethelwa eSewula Afrika. Uyise wathatha isibongo esithi-Ebrahim emndenini ebegade akhamba nawo eSewula Afrika.

Iimfundo zaka-Ebrahim zatlhogonyelwa ngugogo wakhe ngemva kobana iimphathimandla zimenqabele ukungena esikolweni samabanga aphasi, zithi iinkolo zabafundi be-India bezizele begodu angeze zamukela. Lokhu kwaragela phambili iminyaka emihlanu bekwaba kulapho aneminyaka elitjhumi. Wabe wajoyina isikolo esisekelwa ngurhulumende i-The Hindu Tamil Institute.&lt;ref&gt;https://www.parliament.gov.za/press-releases/parliament-presiding-officers-saddened-passing-mr-ebrahim-ismail-ebrahim&lt;/ref&gt;</text>
      <sha1>swj7g9enjux86ku6l4gqygdenlznx3f</sha1>
    </revision>
    <revision>
      <id>6434</id>
      <parentid>6433</parentid>
      <timestamp>2026-04-15T05:57:13Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6434</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1543" sha1="3g2qvh4gys1c8iaacuw4t5s86qcwbw9" xml:space="preserve">'''U-Ebrahim Ismail U-Ebrahim''' OLG (1 kuNobayeni 1937 – 6 kuNobayeni 2021) bekangumlweli weSewula Afrika olwisana nebandlululo we-India ogade alilunga le-African National Congress's armed wing uMkhonto we Sizwe. Wagwetjwa emacaleni we-Pietermaritzburg sabotage wango-1963 begodu wagwetjwa iminyaka eli-15 ejele e-Robben Island Maximum Security Prison.&lt;ref&gt;https://www.pa.org.za/person/ebrahim-ismail-ebrahim/&lt;/ref&gt;

Waziwa ngokuthi ngu-Ebie, wasebenza njengommeli kurhulumende weSewula Afrika wokuthoma owakhethwa ngentando yenengi ngo-1994 begodu wasebenza njengesekela likaNgqongqotjhe wezobudlelwano beentjhabatjhaba hlangana nomnyaka ka-2009 ukuya ku-2014.&lt;ref&gt;https://sahistory.org.za/people/ebrahim-ismail-ebrahim&lt;/ref&gt;

== Ipilo yokuthoma ==
U-Ebrahim wabelethwa e-Durban ngo-1937 kubabelethi, u-Hafeeza no-Mohammed Adam Modan, abavela e-India. Uyise bekavela e-Gujarat begodu waya eSewula Afrika ngo-1933, kuthi unina wabelethelwa eSewula Afrika. Uyise wathatha isibongo esithi-Ebrahim emndenini ebegade akhamba nawo eSewula Afrika.

Iimfundo zaka-Ebrahim zatlhogonyelwa ngugogo wakhe ngemva kobana iimphathimandla zimenqabele ukungena esikolweni samabanga aphasi, zithi iinkolo zabafundi be-India bezizele begodu angeze zamukela. Lokhu kwaragela phambili iminyaka emihlanu bekwaba kulapho aneminyaka elitjhumi. Wabe wajoyina isikolo esisekelwa ngurhulumende i-The Hindu Tamil Institute.&lt;ref&gt;https://www.parliament.gov.za/press-releases/parliament-presiding-officers-saddened-passing-mr-ebrahim-ismail-ebrahim&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>3g2qvh4gys1c8iaacuw4t5s86qcwbw9</sha1>
    </revision>
    <revision>
      <id>6435</id>
      <parentid>6434</parentid>
      <timestamp>2026-04-15T05:59:22Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6435</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1638" sha1="69kgwi8fdv6fjst5tdkhl303kzmziqz" xml:space="preserve">'''U-Ebrahim Ismail U-Ebrahim''' OLG (1 kuNobayeni 1937 – 6 kuNobayeni 2021) bekangumlweli weSewula Afrika olwisana nebandlululo we-India ogade alilunga le-African National Congress's armed wing uMkhonto we Sizwe. Wagwetjwa emacaleni we-Pietermaritzburg sabotage wango-1963 begodu wagwetjwa iminyaka eli-15 ejele e-Robben Island Maximum Security Prison.&lt;ref&gt;https://www.pa.org.za/person/ebrahim-ismail-ebrahim/&lt;/ref&gt;

Waziwa ngokuthi ngu-Ebie, wasebenza njengommeli kurhulumende weSewula Afrika wokuthoma owakhethwa ngentando yenengi ngo-1994 begodu wasebenza njengesekela likaNgqongqotjhe wezobudlelwano beentjhabatjhaba hlangana nomnyaka ka-2009 ukuya ku-2014.&lt;ref&gt;https://sahistory.org.za/people/ebrahim-ismail-ebrahim&lt;/ref&gt;

== Ipilo yokuthoma ==
U-Ebrahim wabelethwa e-Durban ngo-1937 kubabelethi, u-Hafeeza no-Mohammed Adam Modan, abavela e-India. Uyise bekavela e-Gujarat begodu waya eSewula Afrika ngo-1933, kuthi unina wabelethelwa eSewula Afrika. Uyise wathatha isibongo esithi-Ebrahim emndenini ebegade akhamba nawo eSewula Afrika.

Iimfundo zaka-Ebrahim zatlhogonyelwa ngugogo wakhe ngemva kobana iimphathimandla zimenqabele ukungena esikolweni samabanga aphasi, zithi iinkolo zabafundi be-India bezizele begodu angeze zamukela. Lokhu kwaragela phambili iminyaka emihlanu bekwaba kulapho aneminyaka elitjhumi. Wabe wajoyina isikolo esisekelwa ngurhulumende i-The Hindu Tamil Institute.&lt;ref&gt;https://www.parliament.gov.za/press-releases/parliament-presiding-officers-saddened-passing-mr-ebrahim-ismail-ebrahim&lt;/ref&gt;

== Iinkomba ==
&lt;references /&gt;
[[Mkhakha:Sopolitiki]]
[[Mkhakha:Sewula Afrika]]
[[Mkhakha:Amalungelo wobuntu]]</text>
      <sha1>69kgwi8fdv6fjst5tdkhl303kzmziqz</sha1>
    </revision>
    <revision>
      <id>6436</id>
      <parentid>6435</parentid>
      <timestamp>2026-04-15T06:01:03Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6436</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1657" sha1="o5cehw7k5w2jl9n9cr6avrcbdq80e5f" xml:space="preserve">'''U-Ebrahim Ismail U-Ebrahim''' OLG (1 kuNobayeni 1937 – 6 kuNobayeni 2021) bekangumlweli we[[Isewula Afrika|Sewula Afrika]] olwisana nebandlululo we-India ogade alilunga le-African National Congress's armed wing uMkhonto we Sizwe. Wagwetjwa emacaleni we-Pietermaritzburg sabotage wango-1963 begodu wagwetjwa iminyaka eli-15 ejele e-Robben Island Maximum Security Prison.&lt;ref&gt;https://www.pa.org.za/person/ebrahim-ismail-ebrahim/&lt;/ref&gt;

Waziwa ngokuthi ngu-Ebie, wasebenza njengommeli kurhulumende weSewula Afrika wokuthoma owakhethwa ngentando yenengi ngo-1994 begodu wasebenza njengesekela likaNgqongqotjhe wezobudlelwano beentjhabatjhaba hlangana nomnyaka ka-2009 ukuya ku-2014.&lt;ref&gt;https://sahistory.org.za/people/ebrahim-ismail-ebrahim&lt;/ref&gt;

== Ipilo yokuthoma ==
U-Ebrahim wabelethwa e-Durban ngo-1937 kubabelethi, u-Hafeeza no-Mohammed Adam Modan, abavela e-India. Uyise bekavela e-Gujarat begodu waya eSewula Afrika ngo-1933, kuthi unina wabelethelwa eSewula Afrika. Uyise wathatha isibongo esithi-Ebrahim emndenini ebegade akhamba nawo eSewula Afrika.

Iimfundo zaka-Ebrahim zatlhogonyelwa ngugogo wakhe ngemva kobana iimphathimandla zimenqabele ukungena esikolweni samabanga aphasi, zithi iinkolo zabafundi be-India bezizele begodu angeze zamukela. Lokhu kwaragela phambili iminyaka emihlanu bekwaba kulapho aneminyaka elitjhumi. Wabe wajoyina isikolo esisekelwa ngurhulumende i-The Hindu Tamil Institute.&lt;ref&gt;https://www.parliament.gov.za/press-releases/parliament-presiding-officers-saddened-passing-mr-ebrahim-ismail-ebrahim&lt;/ref&gt;

== Iinkomba ==
&lt;references /&gt;
[[Mkhakha:Sopolitiki]]
[[Mkhakha:Sewula Afrika]]
[[Mkhakha:Amalungelo wobuntu]]</text>
      <sha1>o5cehw7k5w2jl9n9cr6avrcbdq80e5f</sha1>
    </revision>
    <revision>
      <id>6437</id>
      <parentid>6436</parentid>
      <timestamp>2026-04-15T06:02:01Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6437</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1688" sha1="c6mi7jhnsjv3c1xik72ch11onu7cldc" xml:space="preserve">'''U-Ebrahim Ismail U-Ebrahim''' OLG (1 kuNobayeni 1937 – 6 kuNobayeni 2021) bekangumlweli we[[Isewula Afrika|Sewula Afrika]] olwisana nebandlululo we-India ogade alilunga le-[[IAfrican National Congress|African National Congress]]'s armed wing uMkhonto we Sizwe. Wagwetjwa emacaleni we-Pietermaritzburg sabotage wango-1963 begodu wagwetjwa iminyaka eli-15 ejele e-Robben Island Maximum Security Prison.&lt;ref&gt;https://www.pa.org.za/person/ebrahim-ismail-ebrahim/&lt;/ref&gt;

Waziwa ngokuthi ngu-Ebie, wasebenza njengommeli kurhulumende weSewula Afrika wokuthoma owakhethwa ngentando yenengi ngo-1994 begodu wasebenza njengesekela likaNgqongqotjhe wezobudlelwano beentjhabatjhaba hlangana nomnyaka ka-2009 ukuya ku-2014.&lt;ref&gt;https://sahistory.org.za/people/ebrahim-ismail-ebrahim&lt;/ref&gt;

== Ipilo yokuthoma ==
U-Ebrahim wabelethwa e-Durban ngo-1937 kubabelethi, u-Hafeeza no-Mohammed Adam Modan, abavela e-India. Uyise bekavela e-Gujarat begodu waya eSewula Afrika ngo-1933, kuthi unina wabelethelwa eSewula Afrika. Uyise wathatha isibongo esithi-Ebrahim emndenini ebegade akhamba nawo eSewula Afrika.

Iimfundo zaka-Ebrahim zatlhogonyelwa ngugogo wakhe ngemva kobana iimphathimandla zimenqabele ukungena esikolweni samabanga aphasi, zithi iinkolo zabafundi be-India bezizele begodu angeze zamukela. Lokhu kwaragela phambili iminyaka emihlanu bekwaba kulapho aneminyaka elitjhumi. Wabe wajoyina isikolo esisekelwa ngurhulumende i-The Hindu Tamil Institute.&lt;ref&gt;https://www.parliament.gov.za/press-releases/parliament-presiding-officers-saddened-passing-mr-ebrahim-ismail-ebrahim&lt;/ref&gt;

== Iinkomba ==
&lt;references /&gt;
[[Mkhakha:Sopolitiki]]
[[Mkhakha:Sewula Afrika]]
[[Mkhakha:Amalungelo wobuntu]]</text>
      <sha1>c6mi7jhnsjv3c1xik72ch11onu7cldc</sha1>
    </revision>
  </page>
  <page>
    <title>UMongameli we-Benin</title>
    <ns>0</ns>
    <id>1094</id>
    <revision>
      <id>6441</id>
      <timestamp>2026-04-15T19:24:14Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1348590776|President of Benin]]&quot;</comment>
      <origin>6441</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1359" sha1="4ryu173lsapu7yyjgq8j8loqlmv2y43" xml:space="preserve">'''Umengameli we-Benin''' ( French:   ) uyihloko yombuso nehloko karhulumende e -Benin . IKhabinethi ye-Benin ingaphasi kwegunya lakaMengameli, begodu isebenza ukuyelelisa nokusiza ukwakha amaqhinga. Ibuye ithintane nama-minister namanye amaziko karhulumende. UMengameli godu nguMlawuli omkhulu webutho le-Benin

Inani labantu abalikhomba abasebenze njengoMengameli (singabali abomongameli ababili abasebenzako, abaphathi bebutho lesikhatjhana abanengi kanye nobumongameli obuhlangeneko). Phezu kwalokho, umuntu oyedwa, u-Mathieu Kérékou, ukhonze kabili okungalandelani.

== Ihlathululo ye-ofisi ==

=== Ukhetho ===
Umengameli ukhethwa ngelungelo lokuvowuda lomuntu woke iminyaka emihlanu. Zilinganiselwe emathemini amabili, kungakhathaliseki bona alandelana namkha ahlukaniswe.  

Abakhethiweko boMongameli kufanele babe: 

AboMongameli bakhethwa ngendlela yemizuliswano emibili . Ukhetho kufanele lube phakathi kwamalanga ama-30 nama-40 ngaphambi kokuphela kwesikhathi sikamongameli okhona.  Nangabe kungekho mkhethi othola inengi elipheleleko emzuliswaneni wokuthoma, kwenzeka i-runoff hlangana nabaqedi ababili abaphambili emzuliswaneni wokuthoma.  


The runoff takes place 15 days after the second round. If one or both of the two top finishers withdraw before the runoff, the next finishers advance in order of filing. A plurality is required to win.</text>
      <sha1>4ryu173lsapu7yyjgq8j8loqlmv2y43</sha1>
    </revision>
    <revision>
      <id>6442</id>
      <parentid>6441</parentid>
      <timestamp>2026-04-15T19:26:48Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6442</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1684" sha1="tpbc3g1h7i1qondbji0ax7sdeqmum1h" xml:space="preserve">'''Umengameli we-Benin''' ( French:   ) uyihloko yombuso nehloko karhulumende e -Benin . IKhabinethi ye-Benin ingaphasi kwegunya lakaMengameli, begodu isebenza ukuyelelisa nokusiza ukwakha amaqhinga. Ibuye ithintane nama-minister namanye amaziko karhulumende. UMengameli godu nguMlawuli omkhulu webutho le-Benin

Inani labantu abalikhomba abasebenze njengoMengameli (singabali abomongameli ababili abasebenzako, abaphathi bebutho lesikhatjhana abanengi kanye nobumongameli obuhlangeneko). Phezu kwalokho, umuntu oyedwa, u-Mathieu Kérékou, ukhonze kabili okungalandelani.&lt;ref&gt;https://www.dw.com/fr/le-b%C3%A9nin-se-dote-dun-vice-pr%C3%A9sident/a-51101607&lt;/ref&gt;&lt;ref&gt;https://www.businessdailyafrica.com/news/The-highest-and-lowest-paid-African-presidents/539546-4129430-cbmf8iz/index.html&lt;/ref&gt;

== Ihlathululo ye-ofisi ==

=== Ukhetho ===
Umengameli ukhethwa ngelungelo lokuvowuda lomuntu woke iminyaka emihlanu. Zilinganiselwe emathemini amabili, kungakhathaliseki bona alandelana namkha ahlukaniswe.  

Abakhethiweko boMongameli kufanele babe: 

AboMongameli bakhethwa ngendlela yemizuliswano emibili . Ukhetho kufanele lube phakathi kwamalanga ama-30 nama-40 ngaphambi kokuphela kwesikhathi sikamongameli okhona.  Nangabe kungekho mkhethi othola inengi elipheleleko emzuliswaneni wokuthoma, kwenzeka i-runoff hlangana nabaqedi ababili abaphambili emzuliswaneni wokuthoma.  


The runoff takes place 15 days after the second round. If one or both of the two top finishers withdraw before the runoff, the next finishers advance in order of filing. A plurality is required to win.&lt;ref&gt;https://africacenter.org/spotlight/circumvention-of-term-limits-weakens-governance-in-africa/&lt;/ref&gt;</text>
      <sha1>tpbc3g1h7i1qondbji0ax7sdeqmum1h</sha1>
    </revision>
    <revision>
      <id>6443</id>
      <parentid>6442</parentid>
      <timestamp>2026-04-15T19:27:10Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6443</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1701" sha1="3zzw7g2whvn2d3pofly6stdtqct7q3t" xml:space="preserve">'''Umengameli we-Benin''' ( French:   ) uyihloko yombuso nehloko karhulumende e -Benin . IKhabinethi ye-Benin ingaphasi kwegunya lakaMengameli, begodu isebenza ukuyelelisa nokusiza ukwakha amaqhinga. Ibuye ithintane nama-minister namanye amaziko karhulumende. UMengameli godu nguMlawuli omkhulu webutho le-Benin

Inani labantu abalikhomba abasebenze njengoMengameli (singabali abomongameli ababili abasebenzako, abaphathi bebutho lesikhatjhana abanengi kanye nobumongameli obuhlangeneko). Phezu kwalokho, umuntu oyedwa, u-Mathieu Kérékou, ukhonze kabili okungalandelani.&lt;ref&gt;https://www.dw.com/fr/le-b%C3%A9nin-se-dote-dun-vice-pr%C3%A9sident/a-51101607&lt;/ref&gt;&lt;ref&gt;https://www.businessdailyafrica.com/news/The-highest-and-lowest-paid-African-presidents/539546-4129430-cbmf8iz/index.html&lt;/ref&gt;

== Ihlathululo ye-ofisi ==

=== Ukhetho ===
Umengameli ukhethwa ngelungelo lokuvowuda lomuntu woke iminyaka emihlanu. Zilinganiselwe emathemini amabili, kungakhathaliseki bona alandelana namkha ahlukaniswe.  

Abakhethiweko boMongameli kufanele babe: 

AboMongameli bakhethwa ngendlela yemizuliswano emibili . Ukhetho kufanele lube phakathi kwamalanga ama-30 nama-40 ngaphambi kokuphela kwesikhathi sikamongameli okhona.  Nangabe kungekho mkhethi othola inengi elipheleleko emzuliswaneni wokuthoma, kwenzeka i-runoff hlangana nabaqedi ababili abaphambili emzuliswaneni wokuthoma.  


The runoff takes place 15 days after the second round. If one or both of the two top finishers withdraw before the runoff, the next finishers advance in order of filing. A plurality is required to win.&lt;ref&gt;https://africacenter.org/spotlight/circumvention-of-term-limits-weakens-governance-in-africa/&lt;/ref&gt;

== Reference ==</text>
      <sha1>3zzw7g2whvn2d3pofly6stdtqct7q3t</sha1>
    </revision>
    <revision>
      <id>6444</id>
      <parentid>6443</parentid>
      <timestamp>2026-04-15T19:27:23Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6444</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1700" sha1="nlttdc3rbv58u28imi95y5k7wqt9jy0" xml:space="preserve">'''Umengameli we-Benin''' ( French:   ) uyihloko yombuso nehloko karhulumende e -Benin . IKhabinethi ye-Benin ingaphasi kwegunya lakaMengameli, begodu isebenza ukuyelelisa nokusiza ukwakha amaqhinga. Ibuye ithintane nama-minister namanye amaziko karhulumende. UMengameli godu nguMlawuli omkhulu webutho le-Benin

Inani labantu abalikhomba abasebenze njengoMengameli (singabali abomongameli ababili abasebenzako, abaphathi bebutho lesikhatjhana abanengi kanye nobumongameli obuhlangeneko). Phezu kwalokho, umuntu oyedwa, u-Mathieu Kérékou, ukhonze kabili okungalandelani.&lt;ref&gt;https://www.dw.com/fr/le-b%C3%A9nin-se-dote-dun-vice-pr%C3%A9sident/a-51101607&lt;/ref&gt;&lt;ref&gt;https://www.businessdailyafrica.com/news/The-highest-and-lowest-paid-African-presidents/539546-4129430-cbmf8iz/index.html&lt;/ref&gt;

== Ihlathululo ye-ofisi ==

=== Ukhetho ===
Umengameli ukhethwa ngelungelo lokuvowuda lomuntu woke iminyaka emihlanu. Zilinganiselwe emathemini amabili, kungakhathaliseki bona alandelana namkha ahlukaniswe.  

Abakhethiweko boMongameli kufanele babe: 

AboMongameli bakhethwa ngendlela yemizuliswano emibili . Ukhetho kufanele lube phakathi kwamalanga ama-30 nama-40 ngaphambi kokuphela kwesikhathi sikamongameli okhona.  Nangabe kungekho mkhethi othola inengi elipheleleko emzuliswaneni wokuthoma, kwenzeka i-runoff hlangana nabaqedi ababili abaphambili emzuliswaneni wokuthoma.  


The runoff takes place 15 days after the second round. If one or both of the two top finishers withdraw before the runoff, the next finishers advance in order of filing. A plurality is required to win.&lt;ref&gt;https://africacenter.org/spotlight/circumvention-of-term-limits-weakens-governance-in-africa/&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>nlttdc3rbv58u28imi95y5k7wqt9jy0</sha1>
    </revision>
    <revision>
      <id>6445</id>
      <parentid>6444</parentid>
      <timestamp>2026-04-15T19:28:24Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6445</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1704" sha1="ip2cku8bhohmg25jzr442823sb0xmng" xml:space="preserve">'''Umengameli we-Benin''' ( French:   ) uyihloko yombuso nehloko karhulumende e -[[Benin]] . IKhabinethi ye-Benin ingaphasi kwegunya lakaMengameli, begodu isebenza ukuyelelisa nokusiza ukwakha amaqhinga. Ibuye ithintane nama-minister namanye amaziko karhulumende. UMengameli godu nguMlawuli omkhulu webutho le-Benin

Inani labantu abalikhomba abasebenze njengoMengameli (singabali abomongameli ababili abasebenzako, abaphathi bebutho lesikhatjhana abanengi kanye nobumongameli obuhlangeneko). Phezu kwalokho, umuntu oyedwa, u-Mathieu Kérékou, ukhonze kabili okungalandelani.&lt;ref&gt;https://www.dw.com/fr/le-b%C3%A9nin-se-dote-dun-vice-pr%C3%A9sident/a-51101607&lt;/ref&gt;&lt;ref&gt;https://www.businessdailyafrica.com/news/The-highest-and-lowest-paid-African-presidents/539546-4129430-cbmf8iz/index.html&lt;/ref&gt;

== Ihlathululo ye-ofisi ==

=== Ukhetho ===
Umengameli ukhethwa ngelungelo lokuvowuda lomuntu woke iminyaka emihlanu. Zilinganiselwe emathemini amabili, kungakhathaliseki bona alandelana namkha ahlukaniswe.  

Abakhethiweko boMongameli kufanele babe: 

AboMongameli bakhethwa ngendlela yemizuliswano emibili . Ukhetho kufanele lube phakathi kwamalanga ama-30 nama-40 ngaphambi kokuphela kwesikhathi sikamongameli okhona.  Nangabe kungekho mkhethi othola inengi elipheleleko emzuliswaneni wokuthoma, kwenzeka i-runoff hlangana nabaqedi ababili abaphambili emzuliswaneni wokuthoma.  


The runoff takes place 15 days after the second round. If one or both of the two top finishers withdraw before the runoff, the next finishers advance in order of filing. A plurality is required to win.&lt;ref&gt;https://africacenter.org/spotlight/circumvention-of-term-limits-weakens-governance-in-africa/&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>ip2cku8bhohmg25jzr442823sb0xmng</sha1>
    </revision>
  </page>
  <page>
    <title>I-Benin</title>
    <ns>0</ns>
    <id>1095</id>
    <revision>
      <id>6446</id>
      <timestamp>2026-04-15T19:53:45Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1349081963|Benin]]&quot;</comment>
      <origin>6446</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4431" sha1="ogip8zlxnaqe9rfiyw0l1psmbov0l7m" xml:space="preserve">
'''I-Benin''', [ a ] ngokusemthethweni '''iRiphabhliki ye-Benin''', [ b ] ngaphambilini eyaziwa nge Dahomey,  lilizwe eliseTjingalanga ye-Afrika . I-Benin imingcele nge -Togo ngeTjingalanga, i-Nigeria ngepumalanga, [[Burkina Faso|i-Burkina Faso]] ngetlhagwini-Tjingalanga, kanye ne-Niger ngeTlhagwini-pumalanga. Inengi labantu bayo lihlala eligwini elisewula le- Bight of Benin, ingcenye ye- Gulf of Guinea engcenyeni esenyakatho khulu ye- Atlantic Ocean .  Idolobha elikhulu yi -Porto-Novo, begodu isihlalo sombuso sise- Cotonou, idorobha elinabantu abanengi khulu nekomkhulu lezomnotho.  I-Benin ihlanganisa indawo eyi- 112,622 km  ,  begodu inani layo ngo- 2021 belilinganiselwa eemgidini ezili 13 . [ 16 ]  Lilizwe elitjhisako elinomnotho othembele khulu kwezokulima kanye nokuthunyelwa ngaphandle kwamafutha wesundu nekoteni .  

Kusukela ngekhulu le-17 ukuya kwele-19, iinhlangano zepolotiki endaweni leyo bezifaka hlangana uMbuso we-Dahomey, idorobha-mbuso we -Porto Novo, neminye imibuso esetlhagwini. I-France yathatha indawo le ngo-1894, yayifaka ne- French West Africa njenge -French Dahomey . Ngo-1960, i-Dahomey yathola ikululeko epheleleko e-France. Njengombuso ozijameleko, i-Benin ibe nombuso [[Umbuso wentando yenengi|wentando yenengi]], ukuvukela umbuso kwezempi, kanye noburhulumende bezempi . Umbuso ozibiza ngokuthi yi-Marxist-Leninist ebizwa ngokuthi yi -People's Republic of Benin bewukhona hlangana nomnyaka ka-1975 ukuya ku-1990. Ngo-1991, wathathelwa indawo yi -Republic of Benin enamabandla amanengi . 

Ilimi elisemthethweni le-Benin lisiFulentshi, kuthi amalimi womdabu afana ne -Fon, i-Bariba, i-Yoruba kanye ne-Dendi nayo iyakhulunywa. Isiqhema sekolo esikhulu khulu e-Benin, njengombana kuqalwe ngo-2020 yi-Pew Research Group ngokuya ngeenbalo zaka-2010, buKrestu (52.2%), kulandelwe yi -Islam (24.6%) kanye neenkolo zesintu ze-Afrika (17.9%).  I-Benin lilunga le- United Nations, i- African Union, i- Economic Community of West African States, i- Organization of Islamic Cooperation, i- South Atlantic Peace and Cooperation Zone, i-Francophonie, i- Community of Sahel-Saharan States, i -African Petroleum Producers Association kanye ne -African Basicity .

== I-Etymology ==
During French colonial rule and after independence on 1 August 1960, the country was named Dahomey, after the Kingdom of Dahomey. On 30 November 1975, following a Marxist–Leninist military coup, the country was renamed Benin, after the Bight of Benin, which borders the country, since the name Dahomey is exclusively associated with the Fon who inhabited the southern half of the country. The bight takes its name from the Kingdom of Benin, located in present-day Nigeria.

Ngaphambi komnyaka ka-1600, i-Benin yanje beyineendawo ezihlukahlukeneko ezineenhlelo zepolotiki ezihlukahlukeneko kanye neentjhaba ezihlukahlukeneko. Lokhu kufaka hlangana amadorobha-amazwe aseduze nelwandle (ikakhulukazi wesiqhema se -Aja begodu kufaka hlangana abantu be -Yoruba ne -Gbe ) kanye neendawo zezizwe eziphakathi kwelizwe (ezakhiwe babantu be -Bariba, Mahi, Gedevi, kanye ne-Kabye). UmBuso we-Oyo, obekwe khulukhulu ngepumalanga ye-Benin, bekulibutho lezempi esifundeni, ebegade ihlasela begodu ifuna umthelo emibusweni eseduze nelwandle neendaweni zeentjhaba.  Isimo satjhuguluka ngeminyaka yekhulu le-17 neye-18 njengombana uMbuso we-Dahomey, owawunabantu abanengi be -Fon, wasungulwa ethafeni le -Abomey begodu wathoma ukuthatha iindawo eziseduze nelwandle.  Ngo-1727, iKosi u -Agaja yoMbuso we-Dahomey besele inqobe amadorobha asemaphethelweni we -Allada ne -Whydah . I-Dahomey besele ibe mtheleli we-Oyo Empire, begodu beyiphikisana kodwana azange ihlasele ngqo idorobha elihlangene ne-Oyo le- Porto-Novo .  Ukukhula kwe-Dahomey, ukuncintisana kwayo ne-Porto-Novo, kanye nepolotiki yezizwe esifundeni esisenyakatho kwaragela phambili bekwaba sesikhathini samakoloni nasemva kwamakoloni. 


E-Dahomey, abanye abantu abasesebatjha bebafundiswa emasotjeni amadala begodu bafundisa amasiko webutho lombuso bekwaba kulapho sele bakhula ngokwaneleko ukobana bangene ebuthweni.[1] U-Dahomey wasungula ibutho lamasotja wesifazana eliphezulu elibizwa nge-Ahosi (abafazi benkosi), u-Mino (&quot;omama bethu&quot; nge-Fongbe) nofana &quot;ama-Amazon we-Dahomean&quot;. Ukugandelela ukulungiselela ipi nokuphumelela kwenze bona u-Dahomey abe nesiteketiso esithi &quot;Black Sparta&quot;, ebantwini abase-Europe nabahloli bekhulu le-19 abafana no-Sir Richard Burton.[2]</text>
      <sha1>ogip8zlxnaqe9rfiyw0l1psmbov0l7m</sha1>
    </revision>
    <revision>
      <id>6447</id>
      <parentid>6446</parentid>
      <timestamp>2026-04-15T19:55:45Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6447</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4548" sha1="34f9i5smtjuoqamrfcguhbu0droty1n" xml:space="preserve">
'''I-Benin''', [ a ] ngokusemthethweni '''iRiphabhliki ye-Benin''', [ b ] ngaphambilini eyaziwa nge Dahomey,  lilizwe eliseTjingalanga ye-Afrika . I-Benin imingcele nge -Togo ngeTjingalanga, i-Nigeria ngepumalanga, [[Burkina Faso|i-Burkina Faso]] ngetlhagwini-Tjingalanga, kanye ne-Niger ngeTlhagwini-pumalanga. Inengi labantu bayo lihlala eligwini elisewula le- Bight of Benin, ingcenye ye- Gulf of Guinea engcenyeni esenyakatho khulu ye- Atlantic Ocean .  Idolobha elikhulu yi -Porto-Novo, begodu isihlalo sombuso sise- Cotonou, idorobha elinabantu abanengi khulu nekomkhulu lezomnotho.  I-Benin ihlanganisa indawo eyi- 112,622 km  ,  begodu inani layo ngo- 2021 belilinganiselwa eemgidini ezili 13 . [ 16 ]  Lilizwe elitjhisako elinomnotho othembele khulu kwezokulima kanye nokuthunyelwa ngaphandle kwamafutha wesundu nekoteni .  

Kusukela ngekhulu le-17 ukuya kwele-19, iinhlangano zepolotiki endaweni leyo bezifaka hlangana uMbuso we-Dahomey, idorobha-mbuso we -Porto Novo, neminye imibuso esetlhagwini. I-France yathatha indawo le ngo-1894, yayifaka ne- French West Africa njenge -French Dahomey . Ngo-1960, i-Dahomey yathola ikululeko epheleleko e-France. Njengombuso ozijameleko, i-Benin ibe nombuso [[Umbuso wentando yenengi|wentando yenengi]], ukuvukela umbuso kwezempi, kanye noburhulumende bezempi . Umbuso ozibiza ngokuthi yi-Marxist-Leninist ebizwa ngokuthi yi -People's Republic of Benin bewukhona hlangana nomnyaka ka-1975 ukuya ku-1990. Ngo-1991, wathathelwa indawo yi -Republic of Benin enamabandla amanengi . 

Ilimi elisemthethweni le-Benin lisiFulentshi, kuthi amalimi womdabu afana ne -Fon, i-Bariba, i-Yoruba kanye ne-Dendi nayo iyakhulunywa. Isiqhema sekolo esikhulu khulu e-Benin, njengombana kuqalwe ngo-2020 yi-Pew Research Group ngokuya ngeenbalo zaka-2010, buKrestu (52.2%), kulandelwe yi -Islam (24.6%) kanye neenkolo zesintu ze-Afrika (17.9%).  I-Benin lilunga le- United Nations, i- African Union, i- Economic Community of West African States, i- Organization of Islamic Cooperation, i- South Atlantic Peace and Cooperation Zone, i-Francophonie, i- Community of Sahel-Saharan States, i -African Petroleum Producers Association kanye ne -African Basicity. &lt;ref&gt;https://www2.fundsforngos.org/innovation/falling-walls-lab-cotonou-pitch-your-breakthrough-idea-benin/&lt;/ref&gt;

== I-Etymology ==
During French colonial rule and after independence on 1 August 1960, the country was named Dahomey, after the Kingdom of Dahomey. On 30 November 1975, following a Marxist–Leninist military coup, the country was renamed Benin, after the Bight of Benin, which borders the country, since the name Dahomey is exclusively associated with the Fon who inhabited the southern half of the country. The bight takes its name from the Kingdom of Benin, located in present-day [[Nigeria]].

Ngaphambi komnyaka ka-1600, i-Benin yanje beyineendawo ezihlukahlukeneko ezineenhlelo zepolotiki ezihlukahlukeneko kanye neentjhaba ezihlukahlukeneko. Lokhu kufaka hlangana amadorobha-amazwe aseduze nelwandle (ikakhulukazi wesiqhema se -Aja begodu kufaka hlangana abantu be -Yoruba ne -Gbe ) kanye neendawo zezizwe eziphakathi kwelizwe (ezakhiwe babantu be -Bariba, Mahi, Gedevi, kanye ne-Kabye). UmBuso we-Oyo, obekwe khulukhulu ngepumalanga ye-Benin, bekulibutho lezempi esifundeni, ebegade ihlasela begodu ifuna umthelo emibusweni eseduze nelwandle neendaweni zeentjhaba.  Isimo satjhuguluka ngeminyaka yekhulu le-17 neye-18 njengombana uMbuso we-Dahomey, owawunabantu abanengi be -Fon, wasungulwa ethafeni le -Abomey begodu wathoma ukuthatha iindawo eziseduze nelwandle.  Ngo-1727, iKosi u -Agaja yoMbuso we-Dahomey besele inqobe amadorobha asemaphethelweni we -Allada ne -Whydah . I-Dahomey besele ibe mtheleli we-Oyo Empire, begodu beyiphikisana kodwana azange ihlasele ngqo idorobha elihlangene ne-Oyo le- Porto-Novo .  Ukukhula kwe-Dahomey, ukuncintisana kwayo ne-Porto-Novo, kanye nepolotiki yezizwe esifundeni esisenyakatho kwaragela phambili bekwaba sesikhathini samakoloni nasemva kwamakoloni. 


E-Dahomey, abanye abantu abasesebatjha bebafundiswa emasotjeni amadala begodu bafundisa amasiko webutho lombuso bekwaba kulapho sele bakhula ngokwaneleko ukobana bangene ebuthweni.[1] U-Dahomey wasungula ibutho lamasotja wesifazana eliphezulu elibizwa nge-Ahosi (abafazi benkosi), u-Mino (&quot;omama bethu&quot; nge-Fongbe) nofana &quot;ama-Amazon we-Dahomean&quot;. Ukugandelela ukulungiselela ipi nokuphumelela kwenze bona u-Dahomey abe nesiteketiso esithi &quot;Black Sparta&quot;, ebantwini abase-Europe nabahloli bekhulu le-19 abafana no-Sir Richard Burton.[2]</text>
      <sha1>34f9i5smtjuoqamrfcguhbu0droty1n</sha1>
    </revision>
    <revision>
      <id>6448</id>
      <parentid>6447</parentid>
      <timestamp>2026-04-15T19:56:03Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6448</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4656" sha1="6765t3dzde10fdqtvojp9xrtu1fuboy" xml:space="preserve">
'''I-Benin''', [ a ] ngokusemthethweni '''iRiphabhliki ye-Benin''', [ b ] ngaphambilini eyaziwa nge Dahomey,  lilizwe eliseTjingalanga ye-Afrika . I-Benin imingcele nge -Togo ngeTjingalanga, i-Nigeria ngepumalanga, [[Burkina Faso|i-Burkina Faso]] ngetlhagwini-Tjingalanga, kanye ne-Niger ngeTlhagwini-pumalanga. Inengi labantu bayo lihlala eligwini elisewula le- Bight of Benin, ingcenye ye- Gulf of Guinea engcenyeni esenyakatho khulu ye- Atlantic Ocean .  Idolobha elikhulu yi -Porto-Novo, begodu isihlalo sombuso sise- Cotonou, idorobha elinabantu abanengi khulu nekomkhulu lezomnotho.  I-Benin ihlanganisa indawo eyi- 112,622 km  ,  begodu inani layo ngo- 2021 belilinganiselwa eemgidini ezili 13 . [ 16 ]  Lilizwe elitjhisako elinomnotho othembele khulu kwezokulima kanye nokuthunyelwa ngaphandle kwamafutha wesundu nekoteni .  

Kusukela ngekhulu le-17 ukuya kwele-19, iinhlangano zepolotiki endaweni leyo bezifaka hlangana uMbuso we-Dahomey, idorobha-mbuso we -Porto Novo, neminye imibuso esetlhagwini. I-France yathatha indawo le ngo-1894, yayifaka ne- French West Africa njenge -French Dahomey . Ngo-1960, i-Dahomey yathola ikululeko epheleleko e-France. Njengombuso ozijameleko, i-Benin ibe nombuso [[Umbuso wentando yenengi|wentando yenengi]], ukuvukela umbuso kwezempi, kanye noburhulumende bezempi . Umbuso ozibiza ngokuthi yi-Marxist-Leninist ebizwa ngokuthi yi -People's Republic of Benin bewukhona hlangana nomnyaka ka-1975 ukuya ku-1990. Ngo-1991, wathathelwa indawo yi -Republic of Benin enamabandla amanengi . 

Ilimi elisemthethweni le-Benin lisiFulentshi, kuthi amalimi womdabu afana ne -Fon, i-Bariba, i-Yoruba kanye ne-Dendi nayo iyakhulunywa. Isiqhema sekolo esikhulu khulu e-Benin, njengombana kuqalwe ngo-2020 yi-Pew Research Group ngokuya ngeenbalo zaka-2010, buKrestu (52.2%), kulandelwe yi -Islam (24.6%) kanye neenkolo zesintu ze-Afrika (17.9%).  I-Benin lilunga le- United Nations, i- African Union, i- Economic Community of West African States, i- Organization of Islamic Cooperation, i- South Atlantic Peace and Cooperation Zone, i-Francophonie, i- Community of Sahel-Saharan States, i -African Petroleum Producers Association kanye ne -African Basicity. &lt;ref&gt;https://www2.fundsforngos.org/innovation/falling-walls-lab-cotonou-pitch-your-breakthrough-idea-benin/&lt;/ref&gt;

== I-Etymology ==
During French colonial rule and after independence on 1 August 1960, the country was named Dahomey, after the Kingdom of Dahomey. On 30 November 1975, following a Marxist–Leninist military coup, the country was renamed Benin, after the Bight of Benin, which borders the country, since the name Dahomey is exclusively associated with the Fon who inhabited the southern half of the country. The bight takes its name from the Kingdom of Benin, located in present-day [[Nigeria]].&lt;ref&gt;https://www.cnbcafrica.com/2026/benins-wadagni-wins-presidency-in-landslide-with-over-94-of-votes&lt;/ref&gt;

Ngaphambi komnyaka ka-1600, i-Benin yanje beyineendawo ezihlukahlukeneko ezineenhlelo zepolotiki ezihlukahlukeneko kanye neentjhaba ezihlukahlukeneko. Lokhu kufaka hlangana amadorobha-amazwe aseduze nelwandle (ikakhulukazi wesiqhema se -Aja begodu kufaka hlangana abantu be -Yoruba ne -Gbe ) kanye neendawo zezizwe eziphakathi kwelizwe (ezakhiwe babantu be -Bariba, Mahi, Gedevi, kanye ne-Kabye). UmBuso we-Oyo, obekwe khulukhulu ngepumalanga ye-Benin, bekulibutho lezempi esifundeni, ebegade ihlasela begodu ifuna umthelo emibusweni eseduze nelwandle neendaweni zeentjhaba.  Isimo satjhuguluka ngeminyaka yekhulu le-17 neye-18 njengombana uMbuso we-Dahomey, owawunabantu abanengi be -Fon, wasungulwa ethafeni le -Abomey begodu wathoma ukuthatha iindawo eziseduze nelwandle.  Ngo-1727, iKosi u -Agaja yoMbuso we-Dahomey besele inqobe amadorobha asemaphethelweni we -Allada ne -Whydah . I-Dahomey besele ibe mtheleli we-Oyo Empire, begodu beyiphikisana kodwana azange ihlasele ngqo idorobha elihlangene ne-Oyo le- Porto-Novo .  Ukukhula kwe-Dahomey, ukuncintisana kwayo ne-Porto-Novo, kanye nepolotiki yezizwe esifundeni esisenyakatho kwaragela phambili bekwaba sesikhathini samakoloni nasemva kwamakoloni. 


E-Dahomey, abanye abantu abasesebatjha bebafundiswa emasotjeni amadala begodu bafundisa amasiko webutho lombuso bekwaba kulapho sele bakhula ngokwaneleko ukobana bangene ebuthweni.[1] U-Dahomey wasungula ibutho lamasotja wesifazana eliphezulu elibizwa nge-Ahosi (abafazi benkosi), u-Mino (&quot;omama bethu&quot; nge-Fongbe) nofana &quot;ama-Amazon we-Dahomean&quot;. Ukugandelela ukulungiselela ipi nokuphumelela kwenze bona u-Dahomey abe nesiteketiso esithi &quot;Black Sparta&quot;, ebantwini abase-Europe nabahloli bekhulu le-19 abafana no-Sir Richard Burton.[2]</text>
      <sha1>6765t3dzde10fdqtvojp9xrtu1fuboy</sha1>
    </revision>
    <revision>
      <id>6449</id>
      <parentid>6448</parentid>
      <timestamp>2026-04-15T19:57:40Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6449</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4934" sha1="tog99lcyuv27gggbgvfxhauhcpy2pba" xml:space="preserve">
'''I-Benin''', [ a ] ngokusemthethweni '''iRiphabhliki ye-Benin''', [ b ] ngaphambilini eyaziwa nge Dahomey,  lilizwe eliseTjingalanga ye-Afrika . I-Benin imingcele nge -Togo ngeTjingalanga, i-Nigeria ngepumalanga, [[Burkina Faso|i-Burkina Faso]] ngetlhagwini-Tjingalanga, kanye ne-Niger ngeTlhagwini-pumalanga. Inengi labantu bayo lihlala eligwini elisewula le- Bight of Benin, ingcenye ye- Gulf of Guinea engcenyeni esenyakatho khulu ye- Atlantic Ocean .  Idolobha elikhulu yi -Porto-Novo, begodu isihlalo sombuso sise- Cotonou, idorobha elinabantu abanengi khulu nekomkhulu lezomnotho.  I-Benin ihlanganisa indawo eyi- 112,622 km  ,  begodu inani layo ngo- 2021 belilinganiselwa eemgidini ezili 13 . [ 16 ]  Lilizwe elitjhisako elinomnotho othembele khulu kwezokulima kanye nokuthunyelwa ngaphandle kwamafutha wesundu nekoteni .  

Kusukela ngekhulu le-17 ukuya kwele-19, iinhlangano zepolotiki endaweni leyo bezifaka hlangana uMbuso we-Dahomey, idorobha-mbuso we -Porto Novo, neminye imibuso esetlhagwini. I-France yathatha indawo le ngo-1894, yayifaka ne- French West Africa njenge -French Dahomey . Ngo-1960, i-Dahomey yathola ikululeko epheleleko e-France. Njengombuso ozijameleko, i-Benin ibe nombuso [[Umbuso wentando yenengi|wentando yenengi]], ukuvukela umbuso kwezempi, kanye noburhulumende bezempi . Umbuso ozibiza ngokuthi yi-Marxist-Leninist ebizwa ngokuthi yi -People's Republic of Benin bewukhona hlangana nomnyaka ka-1975 ukuya ku-1990. Ngo-1991, wathathelwa indawo yi -Republic of Benin enamabandla amanengi . 

Ilimi elisemthethweni le-Benin lisiFulentshi, kuthi amalimi womdabu afana ne -Fon, i-Bariba, i-Yoruba kanye ne-Dendi nayo iyakhulunywa. Isiqhema sekolo esikhulu khulu e-Benin, njengombana kuqalwe ngo-2020 yi-Pew Research Group ngokuya ngeenbalo zaka-2010, buKrestu (52.2%), kulandelwe yi -Islam (24.6%) kanye neenkolo zesintu ze-Afrika (17.9%).  I-Benin lilunga le- United Nations, i- African Union, i- Economic Community of West African States, i- Organization of Islamic Cooperation, i- South Atlantic Peace and Cooperation Zone, i-Francophonie, i- Community of Sahel-Saharan States, i -African Petroleum Producers Association kanye ne -African Basicity. &lt;ref&gt;https://www2.fundsforngos.org/innovation/falling-walls-lab-cotonou-pitch-your-breakthrough-idea-benin/&lt;/ref&gt;

== I-Etymology ==
During French colonial rule and after independence on 1 August 1960, the country was named Dahomey, after the Kingdom of Dahomey. On 30 November 1975, following a Marxist–Leninist military coup, the country was renamed Benin, after the Bight of Benin, which borders the country, since the name Dahomey is exclusively associated with the Fon who inhabited the southern half of the country. The bight takes its name from the Kingdom of Benin, located in present-day [[Nigeria]].&lt;ref&gt;https://www.cnbcafrica.com/2026/benins-wadagni-wins-presidency-in-landslide-with-over-94-of-votes&lt;/ref&gt;

Ngaphambi komnyaka ka-1600, i-Benin yanje beyineendawo ezihlukahlukeneko ezineenhlelo zepolotiki ezihlukahlukeneko kanye neentjhaba ezihlukahlukeneko. Lokhu kufaka hlangana amadorobha-amazwe aseduze nelwandle (ikakhulukazi wesiqhema se -Aja begodu kufaka hlangana abantu be -Yoruba ne -Gbe ) kanye neendawo zezizwe eziphakathi kwelizwe (ezakhiwe babantu be -Bariba, Mahi, Gedevi, kanye ne-Kabye). UmBuso we-Oyo, obekwe khulukhulu ngepumalanga ye-Benin, bekulibutho lezempi esifundeni, ebegade ihlasela begodu ifuna umthelo emibusweni eseduze nelwandle neendaweni zeentjhaba.  Isimo satjhuguluka ngeminyaka yekhulu le-17 neye-18 njengombana uMbuso we-Dahomey, owawunabantu abanengi be -Fon, wasungulwa ethafeni le -Abomey begodu wathoma ukuthatha iindawo eziseduze nelwandle.  Ngo-1727, iKosi u -Agaja yoMbuso we-Dahomey besele inqobe amadorobha asemaphethelweni we -Allada ne -Whydah . I-Dahomey besele ibe mtheleli we-Oyo Empire, begodu beyiphikisana kodwana azange ihlasele ngqo idorobha elihlangene ne-Oyo le- Porto-Novo .  Ukukhula kwe-Dahomey, ukuncintisana kwayo ne-Porto-Novo, kanye nepolotiki yezizwe esifundeni esisenyakatho kwaragela phambili bekwaba sesikhathini samakoloni nasemva kwamakoloni.&lt;ref&gt;https://www.channelafrica.co.za/channelafrica/news/wadagni-secures-commanding-win-in-benin-presidential-election/&lt;/ref&gt;
 


E-Dahomey, abanye abantu abasesebatjha bebafundiswa emasotjeni amadala begodu bafundisa amasiko webutho lombuso bekwaba kulapho sele bakhula ngokwaneleko ukobana bangene ebuthweni.&lt;ref&gt;https://www.dw.com/en/benins-finance-minister-wins-presidential-election-with-94/a-76769500&lt;/ref&gt; U-Dahomey wasungula ibutho lamasotja wesifazana eliphezulu elibizwa nge-Ahosi (abafazi benkosi), u-Mino (&quot;omama bethu&quot; nge-Fongbe) nofana &quot;ama-Amazon we-Dahomean&quot;. Ukugandelela ukulungiselela ipi nokuphumelela kwenze bona u-Dahomey abe nesiteketiso esithi &quot;Black Sparta&quot;, ebantwini abase-Europe nabahloli bekhulu le-19 abafana no-Sir Richard Burton.&lt;ref&gt;https://www.bbc.com/news/articles/ckgwwr1n982o&lt;/ref&gt;</text>
      <sha1>tog99lcyuv27gggbgvfxhauhcpy2pba</sha1>
    </revision>
    <revision>
      <id>6450</id>
      <parentid>6449</parentid>
      <timestamp>2026-04-15T19:58:17Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6450</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4945" sha1="8pjgz6mymmn7l95y29peeivo0mekot2" xml:space="preserve">
'''I-Benin''', [ a ] ngokusemthethweni '''iRiphabhliki ye-Benin''', [ b ] ngaphambilini eyaziwa nge Dahomey,  lilizwe eliseTjingalanga ye-Afrika . I-Benin imingcele nge -Togo ngeTjingalanga, i-Nigeria ngepumalanga, [[Burkina Faso|i-Burkina Faso]] ngetlhagwini-Tjingalanga, kanye ne-Niger ngeTlhagwini-pumalanga. Inengi labantu bayo lihlala eligwini elisewula le- Bight of Benin, ingcenye ye- Gulf of Guinea engcenyeni esenyakatho khulu ye- Atlantic Ocean .  Idolobha elikhulu yi -Porto-Novo, begodu isihlalo sombuso sise- Cotonou, idorobha elinabantu abanengi khulu nekomkhulu lezomnotho.  I-Benin ihlanganisa indawo eyi- 112,622 km  ,  begodu inani layo ngo- 2021 belilinganiselwa eemgidini ezili 13 . [ 16 ]  Lilizwe elitjhisako elinomnotho othembele khulu kwezokulima kanye nokuthunyelwa ngaphandle kwamafutha wesundu nekoteni .  

Kusukela ngekhulu le-17 ukuya kwele-19, iinhlangano zepolotiki endaweni leyo bezifaka hlangana uMbuso we-Dahomey, idorobha-mbuso we -Porto Novo, neminye imibuso esetlhagwini. I-France yathatha indawo le ngo-1894, yayifaka ne- French West Africa njenge -French Dahomey . Ngo-1960, i-Dahomey yathola ikululeko epheleleko e-France. Njengombuso ozijameleko, i-Benin ibe nombuso [[Umbuso wentando yenengi|wentando yenengi]], ukuvukela umbuso kwezempi, kanye noburhulumende bezempi . Umbuso ozibiza ngokuthi yi-Marxist-Leninist ebizwa ngokuthi yi -People's Republic of Benin bewukhona hlangana nomnyaka ka-1975 ukuya ku-1990. Ngo-1991, wathathelwa indawo yi -Republic of Benin enamabandla amanengi . 

Ilimi elisemthethweni le-Benin lisiFulentshi, kuthi amalimi womdabu afana ne -Fon, i-Bariba, i-Yoruba kanye ne-Dendi nayo iyakhulunywa. Isiqhema sekolo esikhulu khulu e-Benin, njengombana kuqalwe ngo-2020 yi-Pew Research Group ngokuya ngeenbalo zaka-2010, buKrestu (52.2%), kulandelwe yi -Islam (24.6%) kanye neenkolo zesintu ze-Afrika (17.9%).  I-Benin lilunga le- United Nations, i- African Union, i- Economic Community of West African States, i- Organization of Islamic Cooperation, i- South Atlantic Peace and Cooperation Zone, i-Francophonie, i- Community of Sahel-Saharan States, i -African Petroleum Producers Association kanye ne -African Basicity. &lt;ref&gt;https://www2.fundsforngos.org/innovation/falling-walls-lab-cotonou-pitch-your-breakthrough-idea-benin/&lt;/ref&gt;

== I-Etymology ==
During French colonial rule and after independence on 1 August 1960, the country was named Dahomey, after the Kingdom of Dahomey. On 30 November 1975, following a Marxist–Leninist military coup, the country was renamed Benin, after the Bight of Benin, which borders the country, since the name Dahomey is exclusively associated with the Fon who inhabited the southern half of the country. The bight takes its name from the Kingdom of Benin, located in present-day [[Nigeria]].&lt;ref&gt;https://www.cnbcafrica.com/2026/benins-wadagni-wins-presidency-in-landslide-with-over-94-of-votes&lt;/ref&gt;

Ngaphambi komnyaka ka-1600, i-Benin yanje beyineendawo ezihlukahlukeneko ezineenhlelo zepolotiki ezihlukahlukeneko kanye neentjhaba ezihlukahlukeneko. Lokhu kufaka hlangana amadorobha-amazwe aseduze nelwandle (ikakhulukazi wesiqhema se -Aja begodu kufaka hlangana abantu be -Yoruba ne -Gbe ) kanye neendawo zezizwe eziphakathi kwelizwe (ezakhiwe babantu be -Bariba, Mahi, Gedevi, kanye ne-Kabye). UmBuso we-Oyo, obekwe khulukhulu ngepumalanga ye-Benin, bekulibutho lezempi esifundeni, ebegade ihlasela begodu ifuna umthelo emibusweni eseduze nelwandle neendaweni zeentjhaba.  Isimo satjhuguluka ngeminyaka yekhulu le-17 neye-18 njengombana uMbuso we-Dahomey, owawunabantu abanengi be -Fon, wasungulwa ethafeni le -Abomey begodu wathoma ukuthatha iindawo eziseduze nelwandle.  Ngo-1727, iKosi u -Agaja yoMbuso we-Dahomey besele inqobe amadorobha asemaphethelweni we -Allada ne -Whydah . I-Dahomey besele ibe mtheleli we-Oyo Empire, begodu beyiphikisana kodwana azange ihlasele ngqo idorobha elihlangene ne-Oyo le- Porto-Novo .  Ukukhula kwe-Dahomey, ukuncintisana kwayo ne-Porto-Novo, kanye nepolotiki yezizwe esifundeni esisenyakatho kwaragela phambili bekwaba sesikhathini samakoloni nasemva kwamakoloni.&lt;ref&gt;https://www.channelafrica.co.za/channelafrica/news/wadagni-secures-commanding-win-in-benin-presidential-election/&lt;/ref&gt;
 
E-Dahomey, abanye abantu abasesebatjha bebafundiswa emasotjeni amadala begodu bafundisa amasiko webutho lombuso bekwaba kulapho sele bakhula ngokwaneleko ukobana bangene ebuthweni.&lt;ref&gt;https://www.dw.com/en/benins-finance-minister-wins-presidential-election-with-94/a-76769500&lt;/ref&gt; U-Dahomey wasungula ibutho lamasotja wesifazana eliphezulu elibizwa nge-Ahosi (abafazi benkosi), u-Mino (&quot;omama bethu&quot; nge-Fongbe) nofana &quot;ama-Amazon we-Dahomean&quot;. Ukugandelela ukulungiselela ipi nokuphumelela kwenze bona u-Dahomey abe nesiteketiso esithi &quot;Black Sparta&quot;, ebantwini abase-Europe nabahloli bekhulu le-19 abafana no-Sir Richard Burton.&lt;ref&gt;https://www.bbc.com/news/articles/ckgwwr1n982o&lt;/ref&gt;
==Iinkomba==</text>
      <sha1>8pjgz6mymmn7l95y29peeivo0mekot2</sha1>
    </revision>
    <revision>
      <id>6451</id>
      <parentid>6450</parentid>
      <timestamp>2026-04-15T19:58:34Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6451</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4957" sha1="sr8n13ykccrf5p6t8hwp1v9gqzczsdi" xml:space="preserve">
'''I-Benin''', [ a ] ngokusemthethweni '''iRiphabhliki ye-Benin''', [ b ] ngaphambilini eyaziwa nge Dahomey,  lilizwe eliseTjingalanga ye-Afrika . I-Benin imingcele nge -Togo ngeTjingalanga, i-Nigeria ngepumalanga, [[Burkina Faso|i-Burkina Faso]] ngetlhagwini-Tjingalanga, kanye ne-Niger ngeTlhagwini-pumalanga. Inengi labantu bayo lihlala eligwini elisewula le- Bight of Benin, ingcenye ye- Gulf of Guinea engcenyeni esenyakatho khulu ye- Atlantic Ocean .  Idolobha elikhulu yi -Porto-Novo, begodu isihlalo sombuso sise- Cotonou, idorobha elinabantu abanengi khulu nekomkhulu lezomnotho.  I-Benin ihlanganisa indawo eyi- 112,622 km  ,  begodu inani layo ngo- 2021 belilinganiselwa eemgidini ezili 13 . [ 16 ]  Lilizwe elitjhisako elinomnotho othembele khulu kwezokulima kanye nokuthunyelwa ngaphandle kwamafutha wesundu nekoteni .  

Kusukela ngekhulu le-17 ukuya kwele-19, iinhlangano zepolotiki endaweni leyo bezifaka hlangana uMbuso we-Dahomey, idorobha-mbuso we -Porto Novo, neminye imibuso esetlhagwini. I-France yathatha indawo le ngo-1894, yayifaka ne- French West Africa njenge -French Dahomey . Ngo-1960, i-Dahomey yathola ikululeko epheleleko e-France. Njengombuso ozijameleko, i-Benin ibe nombuso [[Umbuso wentando yenengi|wentando yenengi]], ukuvukela umbuso kwezempi, kanye noburhulumende bezempi . Umbuso ozibiza ngokuthi yi-Marxist-Leninist ebizwa ngokuthi yi -People's Republic of Benin bewukhona hlangana nomnyaka ka-1975 ukuya ku-1990. Ngo-1991, wathathelwa indawo yi -Republic of Benin enamabandla amanengi . 

Ilimi elisemthethweni le-Benin lisiFulentshi, kuthi amalimi womdabu afana ne -Fon, i-Bariba, i-Yoruba kanye ne-Dendi nayo iyakhulunywa. Isiqhema sekolo esikhulu khulu e-Benin, njengombana kuqalwe ngo-2020 yi-Pew Research Group ngokuya ngeenbalo zaka-2010, buKrestu (52.2%), kulandelwe yi -Islam (24.6%) kanye neenkolo zesintu ze-Afrika (17.9%).  I-Benin lilunga le- United Nations, i- African Union, i- Economic Community of West African States, i- Organization of Islamic Cooperation, i- South Atlantic Peace and Cooperation Zone, i-Francophonie, i- Community of Sahel-Saharan States, i -African Petroleum Producers Association kanye ne -African Basicity. &lt;ref&gt;https://www2.fundsforngos.org/innovation/falling-walls-lab-cotonou-pitch-your-breakthrough-idea-benin/&lt;/ref&gt;

== I-Etymology ==
During French colonial rule and after independence on 1 August 1960, the country was named Dahomey, after the Kingdom of Dahomey. On 30 November 1975, following a Marxist–Leninist military coup, the country was renamed Benin, after the Bight of Benin, which borders the country, since the name Dahomey is exclusively associated with the Fon who inhabited the southern half of the country. The bight takes its name from the Kingdom of Benin, located in present-day [[Nigeria]].&lt;ref&gt;https://www.cnbcafrica.com/2026/benins-wadagni-wins-presidency-in-landslide-with-over-94-of-votes&lt;/ref&gt;

Ngaphambi komnyaka ka-1600, i-Benin yanje beyineendawo ezihlukahlukeneko ezineenhlelo zepolotiki ezihlukahlukeneko kanye neentjhaba ezihlukahlukeneko. Lokhu kufaka hlangana amadorobha-amazwe aseduze nelwandle (ikakhulukazi wesiqhema se -Aja begodu kufaka hlangana abantu be -Yoruba ne -Gbe ) kanye neendawo zezizwe eziphakathi kwelizwe (ezakhiwe babantu be -Bariba, Mahi, Gedevi, kanye ne-Kabye). UmBuso we-Oyo, obekwe khulukhulu ngepumalanga ye-Benin, bekulibutho lezempi esifundeni, ebegade ihlasela begodu ifuna umthelo emibusweni eseduze nelwandle neendaweni zeentjhaba.  Isimo satjhuguluka ngeminyaka yekhulu le-17 neye-18 njengombana uMbuso we-Dahomey, owawunabantu abanengi be -Fon, wasungulwa ethafeni le -Abomey begodu wathoma ukuthatha iindawo eziseduze nelwandle.  Ngo-1727, iKosi u -Agaja yoMbuso we-Dahomey besele inqobe amadorobha asemaphethelweni we -Allada ne -Whydah . I-Dahomey besele ibe mtheleli we-Oyo Empire, begodu beyiphikisana kodwana azange ihlasele ngqo idorobha elihlangene ne-Oyo le- Porto-Novo .  Ukukhula kwe-Dahomey, ukuncintisana kwayo ne-Porto-Novo, kanye nepolotiki yezizwe esifundeni esisenyakatho kwaragela phambili bekwaba sesikhathini samakoloni nasemva kwamakoloni.&lt;ref&gt;https://www.channelafrica.co.za/channelafrica/news/wadagni-secures-commanding-win-in-benin-presidential-election/&lt;/ref&gt;
 
E-Dahomey, abanye abantu abasesebatjha bebafundiswa emasotjeni amadala begodu bafundisa amasiko webutho lombuso bekwaba kulapho sele bakhula ngokwaneleko ukobana bangene ebuthweni.&lt;ref&gt;https://www.dw.com/en/benins-finance-minister-wins-presidential-election-with-94/a-76769500&lt;/ref&gt; U-Dahomey wasungula ibutho lamasotja wesifazana eliphezulu elibizwa nge-Ahosi (abafazi benkosi), u-Mino (&quot;omama bethu&quot; nge-Fongbe) nofana &quot;ama-Amazon we-Dahomean&quot;. Ukugandelela ukulungiselela ipi nokuphumelela kwenze bona u-Dahomey abe nesiteketiso esithi &quot;Black Sparta&quot;, ebantwini abase-Europe nabahloli bekhulu le-19 abafana no-Sir Richard Burton.&lt;ref&gt;https://www.bbc.com/news/articles/ckgwwr1n982o&lt;/ref&gt;
==Iinkomba==
{{reflist}}</text>
      <sha1>sr8n13ykccrf5p6t8hwp1v9gqzczsdi</sha1>
    </revision>
    <revision>
      <id>6452</id>
      <parentid>6451</parentid>
      <timestamp>2026-04-15T19:59:31Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6452</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4977" sha1="ks28rkpatfy34jwlp3rchy3h9rgxoff" xml:space="preserve">
'''I-Benin''', [ a ] ngokusemthethweni '''iRiphabhliki ye-Benin''', [ b ] ngaphambilini eyaziwa nge Dahomey,  lilizwe eliseTjingalanga ye-Afrika . I-Benin imingcele nge -Togo ngeTjingalanga, i-Nigeria ngepumalanga, [[Burkina Faso|i-Burkina Faso]] ngetlhagwini-Tjingalanga, kanye ne-Niger ngeTlhagwini-pumalanga. Inengi labantu bayo lihlala eligwini elisewula le- Bight of Benin, ingcenye ye- Gulf of Guinea engcenyeni esenyakatho khulu ye- Atlantic Ocean .  Idolobha elikhulu yi -Porto-Novo, begodu isihlalo sombuso sise- Cotonou, idorobha elinabantu abanengi khulu nekomkhulu lezomnotho.  I-Benin ihlanganisa indawo eyi- 112,622 km  ,  begodu inani layo ngo- 2021 belilinganiselwa eemgidini ezili 13 . [ 16 ]  Lilizwe elitjhisako elinomnotho othembele khulu kwezokulima kanye nokuthunyelwa ngaphandle kwamafutha wesundu nekoteni .  

Kusukela ngekhulu le-17 ukuya kwele-19, iinhlangano zepolotiki endaweni leyo bezifaka hlangana uMbuso we-Dahomey, idorobha-mbuso we -Porto Novo, neminye imibuso esetlhagwini. I-France yathatha indawo le ngo-1894, yayifaka ne- French West Africa njenge -French Dahomey . Ngo-1960, i-Dahomey yathola ikululeko epheleleko e-France. Njengombuso ozijameleko, i-Benin ibe nombuso [[Umbuso wentando yenengi|wentando yenengi]], ukuvukela umbuso kwezempi, kanye noburhulumende bezempi . Umbuso ozibiza ngokuthi yi-Marxist-Leninist ebizwa ngokuthi yi -People's Republic of Benin bewukhona hlangana nomnyaka ka-1975 ukuya ku-1990. Ngo-1991, wathathelwa indawo yi -Republic of Benin enamabandla amanengi . 

Ilimi elisemthethweni le-Benin lisiFulentshi, kuthi amalimi womdabu afana ne -Fon, i-Bariba, i-Yoruba kanye ne-Dendi nayo iyakhulunywa. Isiqhema sekolo esikhulu khulu e-Benin, njengombana kuqalwe ngo-2020 yi-Pew Research Group ngokuya ngeenbalo zaka-2010, buKrestu (52.2%), kulandelwe yi -Islam (24.6%) kanye neenkolo zesintu ze-Afrika (17.9%).  I-Benin lilunga le- United Nations, i- African Union, i- Economic Community of West African States, i- Organization of Islamic Cooperation, i- South Atlantic Peace and Cooperation Zone, i-Francophonie, i- Community of Sahel-Saharan States, i -African Petroleum Producers Association kanye ne -African Basicity. &lt;ref&gt;https://www2.fundsforngos.org/innovation/falling-walls-lab-cotonou-pitch-your-breakthrough-idea-benin/&lt;/ref&gt;

== I-Etymology ==
During French colonial rule and after independence on 1 August 1960, the country was named Dahomey, after the Kingdom of Dahomey. On 30 November 1975, following a Marxist–Leninist military coup, the country was renamed Benin, after the Bight of Benin, which borders the country, since the name Dahomey is exclusively associated with the Fon who inhabited the southern half of the country. The bight takes its name from the Kingdom of Benin, located in present-day [[Nigeria]].&lt;ref&gt;https://www.cnbcafrica.com/2026/benins-wadagni-wins-presidency-in-landslide-with-over-94-of-votes&lt;/ref&gt;

Ngaphambi komnyaka ka-1600, i-Benin yanje beyineendawo ezihlukahlukeneko ezineenhlelo zepolotiki ezihlukahlukeneko kanye neentjhaba ezihlukahlukeneko. Lokhu kufaka hlangana amadorobha-amazwe aseduze nelwandle (ikakhulukazi wesiqhema se -Aja begodu kufaka hlangana abantu be -Yoruba ne -Gbe ) kanye neendawo zezizwe eziphakathi kwelizwe (ezakhiwe babantu be -Bariba, Mahi, Gedevi, kanye ne-Kabye). UmBuso we-Oyo, obekwe khulukhulu ngepumalanga ye-Benin, bekulibutho lezempi esifundeni, ebegade ihlasela begodu ifuna umthelo emibusweni eseduze nelwandle neendaweni zeentjhaba.  Isimo satjhuguluka ngeminyaka yekhulu le-17 neye-18 njengombana uMbuso we-Dahomey, owawunabantu abanengi be -Fon, wasungulwa ethafeni le -Abomey begodu wathoma ukuthatha iindawo eziseduze nelwandle.  Ngo-1727, iKosi u -Agaja yoMbuso we-Dahomey besele inqobe amadorobha asemaphethelweni we -Allada ne -Whydah . I-Dahomey besele ibe mtheleli we-Oyo Empire, begodu beyiphikisana kodwana azange ihlasele ngqo idorobha elihlangene ne-Oyo le- Porto-Novo .  Ukukhula kwe-Dahomey, ukuncintisana kwayo ne-Porto-Novo, kanye nepolotiki yezizwe esifundeni esisenyakatho kwaragela phambili bekwaba sesikhathini samakoloni nasemva kwamakoloni.&lt;ref&gt;https://www.channelafrica.co.za/channelafrica/news/wadagni-secures-commanding-win-in-benin-presidential-election/&lt;/ref&gt;
 
E-Dahomey, abanye abantu abasesebatjha bebafundiswa emasotjeni amadala begodu bafundisa amasiko webutho lombuso bekwaba kulapho sele bakhula ngokwaneleko ukobana bangene ebuthweni.&lt;ref&gt;https://www.dw.com/en/benins-finance-minister-wins-presidential-election-with-94/a-76769500&lt;/ref&gt; U-Dahomey wasungula ibutho lamasotja wesifazana eliphezulu elibizwa nge-Ahosi (abafazi benkosi), u-Mino (&quot;omama bethu&quot; nge-Fongbe) nofana &quot;ama-Amazon we-Dahomean&quot;. Ukugandelela ukulungiselela ipi nokuphumelela kwenze bona u-Dahomey abe nesiteketiso esithi &quot;Black Sparta&quot;, ebantwini abase-Europe nabahloli bekhulu le-19 abafana no-Sir Richard Burton.&lt;ref&gt;https://www.bbc.com/news/articles/ckgwwr1n982o&lt;/ref&gt;
==Iinkomba==
{{reflist}}
[[Category:Afrika]]</text>
      <sha1>ks28rkpatfy34jwlp3rchy3h9rgxoff</sha1>
    </revision>
    <revision>
      <id>6453</id>
      <parentid>6452</parentid>
      <timestamp>2026-04-15T20:00:09Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6453</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4959" sha1="d8rp1xjozwkak1zp3c5q3q1s50xfip3" xml:space="preserve">
'''I-Benin''', ngokusemthethweni '''iRiphabhliki ye-Benin''',  ngaphambilini eyaziwa nge Dahomey,  lilizwe eliseTjingalanga ye-Afrika . I-Benin imingcele nge -Togo ngeTjingalanga, i-Nigeria ngepumalanga, [[Burkina Faso|i-Burkina Faso]] ngetlhagwini-Tjingalanga, kanye ne-Niger ngeTlhagwini-pumalanga. Inengi labantu bayo lihlala eligwini elisewula le- Bight of Benin, ingcenye ye- Gulf of Guinea engcenyeni esenyakatho khulu ye- Atlantic Ocean .  Idolobha elikhulu yi -Porto-Novo, begodu isihlalo sombuso sise- Cotonou, idorobha elinabantu abanengi khulu nekomkhulu lezomnotho.  I-Benin ihlanganisa indawo eyi- 112,622 km  ,  begodu inani layo ngo- 2021 belilinganiselwa eemgidini ezili 13 .  Lilizwe elitjhisako elinomnotho othembele khulu kwezokulima kanye nokuthunyelwa ngaphandle kwamafutha wesundu nekoteni .  

Kusukela ngekhulu le-17 ukuya kwele-19, iinhlangano zepolotiki endaweni leyo bezifaka hlangana uMbuso we-Dahomey, idorobha-mbuso we -Porto Novo, neminye imibuso esetlhagwini. I-France yathatha indawo le ngo-1894, yayifaka ne- French West Africa njenge -French Dahomey . Ngo-1960, i-Dahomey yathola ikululeko epheleleko e-France. Njengombuso ozijameleko, i-Benin ibe nombuso [[Umbuso wentando yenengi|wentando yenengi]], ukuvukela umbuso kwezempi, kanye noburhulumende bezempi . Umbuso ozibiza ngokuthi yi-Marxist-Leninist ebizwa ngokuthi yi -People's Republic of Benin bewukhona hlangana nomnyaka ka-1975 ukuya ku-1990. Ngo-1991, wathathelwa indawo yi -Republic of Benin enamabandla amanengi . 

Ilimi elisemthethweni le-Benin lisiFulentshi, kuthi amalimi womdabu afana ne -Fon, i-Bariba, i-Yoruba kanye ne-Dendi nayo iyakhulunywa. Isiqhema sekolo esikhulu khulu e-Benin, njengombana kuqalwe ngo-2020 yi-Pew Research Group ngokuya ngeenbalo zaka-2010, buKrestu (52.2%), kulandelwe yi -Islam (24.6%) kanye neenkolo zesintu ze-Afrika (17.9%).  I-Benin lilunga le- United Nations, i- African Union, i- Economic Community of West African States, i- Organization of Islamic Cooperation, i- South Atlantic Peace and Cooperation Zone, i-Francophonie, i- Community of Sahel-Saharan States, i -African Petroleum Producers Association kanye ne -African Basicity. &lt;ref&gt;https://www2.fundsforngos.org/innovation/falling-walls-lab-cotonou-pitch-your-breakthrough-idea-benin/&lt;/ref&gt;

== I-Etymology ==
During French colonial rule and after independence on 1 August 1960, the country was named Dahomey, after the Kingdom of Dahomey. On 30 November 1975, following a Marxist–Leninist military coup, the country was renamed Benin, after the Bight of Benin, which borders the country, since the name Dahomey is exclusively associated with the Fon who inhabited the southern half of the country. The bight takes its name from the Kingdom of Benin, located in present-day [[Nigeria]].&lt;ref&gt;https://www.cnbcafrica.com/2026/benins-wadagni-wins-presidency-in-landslide-with-over-94-of-votes&lt;/ref&gt;

Ngaphambi komnyaka ka-1600, i-Benin yanje beyineendawo ezihlukahlukeneko ezineenhlelo zepolotiki ezihlukahlukeneko kanye neentjhaba ezihlukahlukeneko. Lokhu kufaka hlangana amadorobha-amazwe aseduze nelwandle (ikakhulukazi wesiqhema se -Aja begodu kufaka hlangana abantu be -Yoruba ne -Gbe ) kanye neendawo zezizwe eziphakathi kwelizwe (ezakhiwe babantu be -Bariba, Mahi, Gedevi, kanye ne-Kabye). UmBuso we-Oyo, obekwe khulukhulu ngepumalanga ye-Benin, bekulibutho lezempi esifundeni, ebegade ihlasela begodu ifuna umthelo emibusweni eseduze nelwandle neendaweni zeentjhaba.  Isimo satjhuguluka ngeminyaka yekhulu le-17 neye-18 njengombana uMbuso we-Dahomey, owawunabantu abanengi be -Fon, wasungulwa ethafeni le -Abomey begodu wathoma ukuthatha iindawo eziseduze nelwandle.  Ngo-1727, iKosi u -Agaja yoMbuso we-Dahomey besele inqobe amadorobha asemaphethelweni we -Allada ne -Whydah . I-Dahomey besele ibe mtheleli we-Oyo Empire, begodu beyiphikisana kodwana azange ihlasele ngqo idorobha elihlangene ne-Oyo le- Porto-Novo .  Ukukhula kwe-Dahomey, ukuncintisana kwayo ne-Porto-Novo, kanye nepolotiki yezizwe esifundeni esisenyakatho kwaragela phambili bekwaba sesikhathini samakoloni nasemva kwamakoloni.&lt;ref&gt;https://www.channelafrica.co.za/channelafrica/news/wadagni-secures-commanding-win-in-benin-presidential-election/&lt;/ref&gt;
 
E-Dahomey, abanye abantu abasesebatjha bebafundiswa emasotjeni amadala begodu bafundisa amasiko webutho lombuso bekwaba kulapho sele bakhula ngokwaneleko ukobana bangene ebuthweni.&lt;ref&gt;https://www.dw.com/en/benins-finance-minister-wins-presidential-election-with-94/a-76769500&lt;/ref&gt; U-Dahomey wasungula ibutho lamasotja wesifazana eliphezulu elibizwa nge-Ahosi (abafazi benkosi), u-Mino (&quot;omama bethu&quot; nge-Fongbe) nofana &quot;ama-Amazon we-Dahomean&quot;. Ukugandelela ukulungiselela ipi nokuphumelela kwenze bona u-Dahomey abe nesiteketiso esithi &quot;Black Sparta&quot;, ebantwini abase-Europe nabahloli bekhulu le-19 abafana no-Sir Richard Burton.&lt;ref&gt;https://www.bbc.com/news/articles/ckgwwr1n982o&lt;/ref&gt;
==Iinkomba==
{{reflist}}
[[Category:Afrika]]</text>
      <sha1>d8rp1xjozwkak1zp3c5q3q1s50xfip3</sha1>
    </revision>
  </page>
  <page>
    <title>I-Nigeria</title>
    <ns>0</ns>
    <id>1096</id>
    <revision>
      <id>6454</id>
      <timestamp>2026-04-15T20:02:12Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1348777469|Nigeria]]&quot;</comment>
      <origin>6454</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5611" sha1="duraj99cep3rtpinkurmvdf07rr8jnw" xml:space="preserve">'''I-Nigeria''', [ b ] ngokusemthethweni yi- '''Federal Republic of Nigeria''', yinarha eseTjingalanga ye-Afrika hlangana ne- Sahel ngetlhagwini kanye ne- Gulf of Guinea e- Atlantic Ocean ngesewula. Ihlanganisa indawo 923,769 square kilometres (356,669 mi   . Njengombana inabantu abangaphezu kweengidi ezima-236, lilizwe elinabantu abanengi khulu e- [[I-Afrika|Afrika]], begodu lilizwe lesithupha elinabantu abanengi khulu ephasini . I-Nigeria inomngcele we-Niger enyakatho, i-Chad enyakatho-mpumalanga, [[Cameroon|i-Cameroon]] empumalanga, ne [[I-Benin|-Benin]] entshonalanga . I-Nigeria yiriphabliki yombuso ehlanganisa amazwe ama -36 kanye ne- Federal Capital Territory, lapho ikosi yayo, i-Abuja, itholakala khona. Idorobha elikhulu khulu e-Nigeria ngokwenani labantu yi -Lagos, enye yamadorobha amakhulu khulu ephasini begodu mkhulu khulu e-Afrika .

I-Nigeria sele ilikhaya lamasiko amanengi womdabu, imibuso yangaphambi kobukoloni kanye nemibuso kusukela eminyakeni eyikulungwana yesibili BC. Isiko le-Nok, c. 1500 BC, kutshwaya enye yeempucuko zokuthoma ezaziwako esifundeni. ImiBuso yama-Hausa beyihlala enyakatho, noMbuso we -Edo we-Benin eningizimu, uMbuso we -Igbo we-Nri eningizimu-mpumalanga begodu eningizimu-ntshonalanga, uMbuso we-Oyo . Indawo yamanje ye-Nigeria beyihlala amadorobha amanengi. Ekuthomeni kwekhulu leminyaka ye-19 ama-jihad wama-Fula agcina ku- Sokoto Caliphate . Umbuso wesimanjemanje wathoma ngokubusa kwamaBrithani ngekhulu le-19, wathatha ubujamo bawo bamanje ngokuhlanganiswa kwe- Southern Nigeria Protectorate kanye ne- Northern Nigeria Protectorate ngo-1914. AmaBrithani asungula izakhiwo zokuphatha nezomthetho begodu afaka amakhosi wesintu njengendlela yokubusa okungaqondileko .  I-Nigeria yaba yifederali ezijameleko ngokusemthethweni mhlana ali-1 kuNobayeni 1960. Yaba nepi yomndeni kusukela ngo-1967 ukuya ku-1970, kwalandela ukulandelana kwamabutho wamasotja kanye noburhulumende abakhethwe ngentando yenengi bekwaba kulapho ithola urhulumende ozinzileko ekhethweni lomongameli we-Nigeria ngo-1999 .

I-Nigeria yizwe elinamazwe amanengi elihlala iintjhaba ezingaphezu kwama-250 ezikhuluma amalimi ahlukileko ama-500, zoke zifana namasiko ahlukahlukeneko.    Amaqembu amathathu amakhulu weentjhaba ngama- Hausa enyakatho, ama-Yoruba entshonalanga, kanye nama-Igbo empumalanga, ndawonye akha ngaphezu kwama-60% wabantu boke.  Ilimi elisemthethweni sisiNgisi, esikhethelwe ukusiza ukubumbana kwelimi ezingeni lezwe.  Umthethosisekelo we-Nigeria uqinisekisa ''itjhaphuluko'' yekolo,  begodu likhaya labantu abanengi bamaSulumane namaKrestu ephasini.  I-Nigeria ihlukaniswe phakathi kwamaSulumane, ahlala khulu engcenyeni yetlhagwini yenarha, namaKrestu, ahlala khulu ngeSewula; iinkolo zendabuko, ezifana nalezo ezivela eentjhabeni zama -Igbo nama -Yoruba, zimbalwa. 

I-Nigeria linamandla esifundeni se-Afrika begodu liphakathi nendawo eendabeni zamazwe ngamazwe. Umnotho we-Nigeria ngowesine ngobukhulu e-Afrika, ngowesi-52 ngobukhulu ephasini nge -GDP encani, begodu ngowesi-19 ngobukhulu nge -PPP . I-Nigeria ivamise ukubizwa ngokuthi yi-Giant of Africa ngezakhamuzi zayo ngebanga labantu abanengi nomnotho wayo,  begodu ithathwa njengemakethe ekhulako yiBhanga lePhasi . I-Nigeria lilunga elisungula i- African Union begodu lilunga leenhlangano ezinengi zamazwe ngamazwe, okufaka hlangana i -United Nations, i- Commonwealth of Nations, i-NAM,  i- Economic Community of West African States, i-Organization of Islamic Cooperation kanye ne -OPEC . Ingenye yama- Next Eleven economies, begodu lilunga, kanye ne [[I-Mexico|-Mexico]], Indonesia, ne [[Türkiye|-Turkey]], yesiqhema se-MINT.

== I-Etymology ==
Ibizo elithi ''[[wiktionary:Nigeria|Nigeria]]'' lisuselwa emlanjeni i-Niger ogeleza enarheni le. Ibizo leli laqanjwa mhlazi-8 kuTjhirhweni 1897, yintatheli ye-Britain u-Flora Shaw . IRiphabhliki ye-Niger engumakhelwana ithatha ibizo layo emlanjeni ofanako. Umsuka webizo elithi ''Niger'', ekuthomeni ebegade asebenza eendaweni eziphakathi nendawo zomlambo i-Niger, awuqiniseki. Igama leli kungenzeka litjhugululwe ibizo le -Tuareg elithi ''egerew &lt;u&gt;n-iger&lt;/u&gt; ewen'' (&quot;umlambo wemifula&quot;) ebegade lisetjenziswa babantu abahlala phakathi komlambo ozungeze i-Timbuktu ngaphambi kobukholoni be-Europe bekhulu le-19.   Ngaphambi kobana uFlora Shaw aphakamise ibizo elithi ''Nigeria'', amanye amagama ahlongozwako afaka hlangana ''i-Royal Niger Company Territories'', ''i-Central Sudan'', ''i-Niger Empire'', ''i-Niger Sudan'', kanye ne ''-Hausa Territories'' . 

Ukumbiwa kwedamu le-Kainji kutjengise ukusebenza kwensimbi ngekhulu lesibili BC. Ukutjhuguluka ukusuka esikhathini se-Neolithic ukuya esikhathini se -Iron Age kwenziwa ngaphandle kokukhiqizwa kwethusi okuphakathi. Abanye baphakamise bona ithekhnoloji ithuthele entshonalanga ukusuka e- Nile Valley . Kodwana i -Iron Age esigodini se-Niger River kanye nendawo yamahlathi kubonakala kwangaphambi kokungeniswa kwensimbi e-savanna ephezulu ngeminyaka engaphezu kwama-800, begodu kwandulela kwayo e-Nile Valley. Irhubhululo lakamuva litjengisa bona ukukhiqizwa kwensimbi kwenziwa ngokuzijamela e [[I-Afrika|-Afrika]] .    


Impucuko ye-Nok yathuthuka hlangana nomnyaka ka-1500 BC ukuya ku-200 AD.[1] Yakhiqiza iinthombe ezifana ne-terracotta ezingezinye zeenthombe zokuthoma ezaziwako e-Afrika[2][3][4][5][6] begodu yancibilikisa insimbi ngabo-550 BC begodu mhlamunye emakhulwini weminyaka ambalwa ngaphambilini.[7][8][9] Ubufakazi bokuncibilika kwensimbi nabo buvunyelwe eendaweni ze-Nsukka eningizimu-mpumalanga ye-Nigeria: kusukela ngo-2000 BC endaweni ye-Lejja[10] kanye no-750 BC endaweni ye-Opi.</text>
      <sha1>duraj99cep3rtpinkurmvdf07rr8jnw</sha1>
    </revision>
    <revision>
      <id>6455</id>
      <parentid>6454</parentid>
      <timestamp>2026-04-15T20:02:38Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6455</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5604" sha1="mbxnk0wyfdyre2jk5zycy8iryezfnos" xml:space="preserve">'''I-Nigeria''', ngokusemthethweni yi- '''Federal Republic of Nigeria''', yinarha eseTjingalanga ye-Afrika hlangana ne- Sahel ngetlhagwini kanye ne- Gulf of Guinea e- Atlantic Ocean ngesewula. Ihlanganisa indawo 923,769 square kilometres (356,669 mi   . Njengombana inabantu abangaphezu kweengidi ezima-236, lilizwe elinabantu abanengi khulu e- [[I-Afrika|Afrika]], begodu lilizwe lesithupha elinabantu abanengi khulu ephasini . I-Nigeria inomngcele we-Niger enyakatho, i-Chad enyakatho-mpumalanga, [[Cameroon|i-Cameroon]] empumalanga, ne [[I-Benin|-Benin]] entshonalanga . I-Nigeria yiriphabliki yombuso ehlanganisa amazwe ama -36 kanye ne- Federal Capital Territory, lapho ikosi yayo, i-Abuja, itholakala khona. Idorobha elikhulu khulu e-Nigeria ngokwenani labantu yi -Lagos, enye yamadorobha amakhulu khulu ephasini begodu mkhulu khulu e-Afrika .

I-Nigeria sele ilikhaya lamasiko amanengi womdabu, imibuso yangaphambi kobukoloni kanye nemibuso kusukela eminyakeni eyikulungwana yesibili BC. Isiko le-Nok, c. 1500 BC, kutshwaya enye yeempucuko zokuthoma ezaziwako esifundeni. ImiBuso yama-Hausa beyihlala enyakatho, noMbuso we -Edo we-Benin eningizimu, uMbuso we -Igbo we-Nri eningizimu-mpumalanga begodu eningizimu-ntshonalanga, uMbuso we-Oyo . Indawo yamanje ye-Nigeria beyihlala amadorobha amanengi. Ekuthomeni kwekhulu leminyaka ye-19 ama-jihad wama-Fula agcina ku- Sokoto Caliphate . Umbuso wesimanjemanje wathoma ngokubusa kwamaBrithani ngekhulu le-19, wathatha ubujamo bawo bamanje ngokuhlanganiswa kwe- Southern Nigeria Protectorate kanye ne- Northern Nigeria Protectorate ngo-1914. AmaBrithani asungula izakhiwo zokuphatha nezomthetho begodu afaka amakhosi wesintu njengendlela yokubusa okungaqondileko .  I-Nigeria yaba yifederali ezijameleko ngokusemthethweni mhlana ali-1 kuNobayeni 1960. Yaba nepi yomndeni kusukela ngo-1967 ukuya ku-1970, kwalandela ukulandelana kwamabutho wamasotja kanye noburhulumende abakhethwe ngentando yenengi bekwaba kulapho ithola urhulumende ozinzileko ekhethweni lomongameli we-Nigeria ngo-1999 .

I-Nigeria yizwe elinamazwe amanengi elihlala iintjhaba ezingaphezu kwama-250 ezikhuluma amalimi ahlukileko ama-500, zoke zifana namasiko ahlukahlukeneko.    Amaqembu amathathu amakhulu weentjhaba ngama- Hausa enyakatho, ama-Yoruba entshonalanga, kanye nama-Igbo empumalanga, ndawonye akha ngaphezu kwama-60% wabantu boke.  Ilimi elisemthethweni sisiNgisi, esikhethelwe ukusiza ukubumbana kwelimi ezingeni lezwe.  Umthethosisekelo we-Nigeria uqinisekisa ''itjhaphuluko'' yekolo,  begodu likhaya labantu abanengi bamaSulumane namaKrestu ephasini.  I-Nigeria ihlukaniswe phakathi kwamaSulumane, ahlala khulu engcenyeni yetlhagwini yenarha, namaKrestu, ahlala khulu ngeSewula; iinkolo zendabuko, ezifana nalezo ezivela eentjhabeni zama -Igbo nama -Yoruba, zimbalwa. 

I-Nigeria linamandla esifundeni se-Afrika begodu liphakathi nendawo eendabeni zamazwe ngamazwe. Umnotho we-Nigeria ngowesine ngobukhulu e-Afrika, ngowesi-52 ngobukhulu ephasini nge -GDP encani, begodu ngowesi-19 ngobukhulu nge -PPP . I-Nigeria ivamise ukubizwa ngokuthi yi-Giant of Africa ngezakhamuzi zayo ngebanga labantu abanengi nomnotho wayo,  begodu ithathwa njengemakethe ekhulako yiBhanga lePhasi . I-Nigeria lilunga elisungula i- African Union begodu lilunga leenhlangano ezinengi zamazwe ngamazwe, okufaka hlangana i -United Nations, i- Commonwealth of Nations, i-NAM,  i- Economic Community of West African States, i-Organization of Islamic Cooperation kanye ne -OPEC . Ingenye yama- Next Eleven economies, begodu lilunga, kanye ne [[I-Mexico|-Mexico]], Indonesia, ne [[Türkiye|-Turkey]], yesiqhema se-MINT.

== I-Etymology ==
Ibizo elithi ''[[wiktionary:Nigeria|Nigeria]]'' lisuselwa emlanjeni i-Niger ogeleza enarheni le. Ibizo leli laqanjwa mhlazi-8 kuTjhirhweni 1897, yintatheli ye-Britain u-Flora Shaw . IRiphabhliki ye-Niger engumakhelwana ithatha ibizo layo emlanjeni ofanako. Umsuka webizo elithi ''Niger'', ekuthomeni ebegade asebenza eendaweni eziphakathi nendawo zomlambo i-Niger, awuqiniseki. Igama leli kungenzeka litjhugululwe ibizo le -Tuareg elithi ''egerew &lt;u&gt;n-iger&lt;/u&gt; ewen'' (&quot;umlambo wemifula&quot;) ebegade lisetjenziswa babantu abahlala phakathi komlambo ozungeze i-Timbuktu ngaphambi kobukholoni be-Europe bekhulu le-19.   Ngaphambi kobana uFlora Shaw aphakamise ibizo elithi ''Nigeria'', amanye amagama ahlongozwako afaka hlangana ''i-Royal Niger Company Territories'', ''i-Central Sudan'', ''i-Niger Empire'', ''i-Niger Sudan'', kanye ne ''-Hausa Territories'' . 

Ukumbiwa kwedamu le-Kainji kutjengise ukusebenza kwensimbi ngekhulu lesibili BC. Ukutjhuguluka ukusuka esikhathini se-Neolithic ukuya esikhathini se -Iron Age kwenziwa ngaphandle kokukhiqizwa kwethusi okuphakathi. Abanye baphakamise bona ithekhnoloji ithuthele entshonalanga ukusuka e- Nile Valley . Kodwana i -Iron Age esigodini se-Niger River kanye nendawo yamahlathi kubonakala kwangaphambi kokungeniswa kwensimbi e-savanna ephezulu ngeminyaka engaphezu kwama-800, begodu kwandulela kwayo e-Nile Valley. Irhubhululo lakamuva litjengisa bona ukukhiqizwa kwensimbi kwenziwa ngokuzijamela e [[I-Afrika|-Afrika]] .    

Impucuko ye-Nok yathuthuka hlangana nomnyaka ka-1500 BC ukuya ku-200 AD.[1] Yakhiqiza iinthombe ezifana ne-terracotta ezingezinye zeenthombe zokuthoma ezaziwako e-Afrika[2][3][4][5][6] begodu yancibilikisa insimbi ngabo-550 BC begodu mhlamunye emakhulwini weminyaka ambalwa ngaphambilini.[7][8][9] Ubufakazi bokuncibilika kwensimbi nabo buvunyelwe eendaweni ze-Nsukka eningizimu-mpumalanga ye-Nigeria: kusukela ngo-2000 BC endaweni ye-Lejja[10] kanye no-750 BC endaweni ye-Opi.</text>
      <sha1>mbxnk0wyfdyre2jk5zycy8iryezfnos</sha1>
    </revision>
    <revision>
      <id>6456</id>
      <parentid>6455</parentid>
      <timestamp>2026-04-15T20:03:00Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6456</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="5608" sha1="e2617g5tz9giqwpqn3oijdu2k46x74o" xml:space="preserve">'''I-Nigeria''', ngokusemthethweni yi- '''Federal Republic of Nigeria''', yinarha eseTjingalanga ye-Afrika hlangana ne- Sahel ngetlhagwini kanye ne- Gulf of Guinea e- Atlantic Ocean ngesewula. Ihlanganisa indawo 923,769 square kilometres (356,669 mi   . Njengombana inabantu abangaphezu kweengidi ezima-236, lilizwe elinabantu abanengi khulu e- [[I-Afrika|Afrika]], begodu lilizwe lesithupha elinabantu abanengi khulu ephasini . I-Nigeria inomngcele we-[[Niger]] enyakatho, i-Chad enyakatho-mpumalanga, [[Cameroon|i-Cameroon]] empumalanga, ne [[I-Benin|-Benin]] entshonalanga . I-Nigeria yiriphabliki yombuso ehlanganisa amazwe ama -36 kanye ne- Federal Capital Territory, lapho ikosi yayo, i-Abuja, itholakala khona. Idorobha elikhulu khulu e-Nigeria ngokwenani labantu yi -Lagos, enye yamadorobha amakhulu khulu ephasini begodu mkhulu khulu e-Afrika .

I-Nigeria sele ilikhaya lamasiko amanengi womdabu, imibuso yangaphambi kobukoloni kanye nemibuso kusukela eminyakeni eyikulungwana yesibili BC. Isiko le-Nok, c. 1500 BC, kutshwaya enye yeempucuko zokuthoma ezaziwako esifundeni. ImiBuso yama-Hausa beyihlala enyakatho, noMbuso we -Edo we-Benin eningizimu, uMbuso we -Igbo we-Nri eningizimu-mpumalanga begodu eningizimu-ntshonalanga, uMbuso we-Oyo . Indawo yamanje ye-Nigeria beyihlala amadorobha amanengi. Ekuthomeni kwekhulu leminyaka ye-19 ama-jihad wama-Fula agcina ku- Sokoto Caliphate . Umbuso wesimanjemanje wathoma ngokubusa kwamaBrithani ngekhulu le-19, wathatha ubujamo bawo bamanje ngokuhlanganiswa kwe- Southern Nigeria Protectorate kanye ne- Northern Nigeria Protectorate ngo-1914. AmaBrithani asungula izakhiwo zokuphatha nezomthetho begodu afaka amakhosi wesintu njengendlela yokubusa okungaqondileko .  I-Nigeria yaba yifederali ezijameleko ngokusemthethweni mhlana ali-1 kuNobayeni 1960. Yaba nepi yomndeni kusukela ngo-1967 ukuya ku-1970, kwalandela ukulandelana kwamabutho wamasotja kanye noburhulumende abakhethwe ngentando yenengi bekwaba kulapho ithola urhulumende ozinzileko ekhethweni lomongameli we-Nigeria ngo-1999 .

I-Nigeria yizwe elinamazwe amanengi elihlala iintjhaba ezingaphezu kwama-250 ezikhuluma amalimi ahlukileko ama-500, zoke zifana namasiko ahlukahlukeneko.    Amaqembu amathathu amakhulu weentjhaba ngama- Hausa enyakatho, ama-Yoruba entshonalanga, kanye nama-Igbo empumalanga, ndawonye akha ngaphezu kwama-60% wabantu boke.  Ilimi elisemthethweni sisiNgisi, esikhethelwe ukusiza ukubumbana kwelimi ezingeni lezwe.  Umthethosisekelo we-Nigeria uqinisekisa ''itjhaphuluko'' yekolo,  begodu likhaya labantu abanengi bamaSulumane namaKrestu ephasini.  I-Nigeria ihlukaniswe phakathi kwamaSulumane, ahlala khulu engcenyeni yetlhagwini yenarha, namaKrestu, ahlala khulu ngeSewula; iinkolo zendabuko, ezifana nalezo ezivela eentjhabeni zama -Igbo nama -Yoruba, zimbalwa. 

I-Nigeria linamandla esifundeni se-Afrika begodu liphakathi nendawo eendabeni zamazwe ngamazwe. Umnotho we-Nigeria ngowesine ngobukhulu e-Afrika, ngowesi-52 ngobukhulu ephasini nge -GDP encani, begodu ngowesi-19 ngobukhulu nge -PPP . I-Nigeria ivamise ukubizwa ngokuthi yi-Giant of Africa ngezakhamuzi zayo ngebanga labantu abanengi nomnotho wayo,  begodu ithathwa njengemakethe ekhulako yiBhanga lePhasi . I-Nigeria lilunga elisungula i- African Union begodu lilunga leenhlangano ezinengi zamazwe ngamazwe, okufaka hlangana i -United Nations, i- Commonwealth of Nations, i-NAM,  i- Economic Community of West African States, i-Organization of Islamic Cooperation kanye ne -OPEC . Ingenye yama- Next Eleven economies, begodu lilunga, kanye ne [[I-Mexico|-Mexico]], Indonesia, ne [[Türkiye|-Turkey]], yesiqhema se-MINT.

== I-Etymology ==
Ibizo elithi ''[[wiktionary:Nigeria|Nigeria]]'' lisuselwa emlanjeni i-Niger ogeleza enarheni le. Ibizo leli laqanjwa mhlazi-8 kuTjhirhweni 1897, yintatheli ye-Britain u-Flora Shaw . IRiphabhliki ye-Niger engumakhelwana ithatha ibizo layo emlanjeni ofanako. Umsuka webizo elithi ''Niger'', ekuthomeni ebegade asebenza eendaweni eziphakathi nendawo zomlambo i-Niger, awuqiniseki. Igama leli kungenzeka litjhugululwe ibizo le -Tuareg elithi ''egerew &lt;u&gt;n-iger&lt;/u&gt; ewen'' (&quot;umlambo wemifula&quot;) ebegade lisetjenziswa babantu abahlala phakathi komlambo ozungeze i-Timbuktu ngaphambi kobukholoni be-Europe bekhulu le-19.   Ngaphambi kobana uFlora Shaw aphakamise ibizo elithi ''Nigeria'', amanye amagama ahlongozwako afaka hlangana ''i-Royal Niger Company Territories'', ''i-Central Sudan'', ''i-Niger Empire'', ''i-Niger Sudan'', kanye ne ''-Hausa Territories'' . 

Ukumbiwa kwedamu le-Kainji kutjengise ukusebenza kwensimbi ngekhulu lesibili BC. Ukutjhuguluka ukusuka esikhathini se-Neolithic ukuya esikhathini se -Iron Age kwenziwa ngaphandle kokukhiqizwa kwethusi okuphakathi. Abanye baphakamise bona ithekhnoloji ithuthele entshonalanga ukusuka e- Nile Valley . Kodwana i -Iron Age esigodini se-Niger River kanye nendawo yamahlathi kubonakala kwangaphambi kokungeniswa kwensimbi e-savanna ephezulu ngeminyaka engaphezu kwama-800, begodu kwandulela kwayo e-Nile Valley. Irhubhululo lakamuva litjengisa bona ukukhiqizwa kwensimbi kwenziwa ngokuzijamela e [[I-Afrika|-Afrika]] .    

Impucuko ye-Nok yathuthuka hlangana nomnyaka ka-1500 BC ukuya ku-200 AD.[1] Yakhiqiza iinthombe ezifana ne-terracotta ezingezinye zeenthombe zokuthoma ezaziwako e-Afrika[2][3][4][5][6] begodu yancibilikisa insimbi ngabo-550 BC begodu mhlamunye emakhulwini weminyaka ambalwa ngaphambilini.[7][8][9] Ubufakazi bokuncibilika kwensimbi nabo buvunyelwe eendaweni ze-Nsukka eningizimu-mpumalanga ye-Nigeria: kusukela ngo-2000 BC endaweni ye-Lejja[10] kanye no-750 BC endaweni ye-Opi.</text>
      <sha1>e2617g5tz9giqwpqn3oijdu2k46x74o</sha1>
    </revision>
    <revision>
      <id>6457</id>
      <parentid>6456</parentid>
      <timestamp>2026-04-15T20:05:16Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6457</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6166" sha1="9av90g4nkigql1s6lxho1el4vskkq2t" xml:space="preserve">'''I-Nigeria''', ngokusemthethweni yi- '''Federal Republic of Nigeria''', yinarha eseTjingalanga ye-Afrika hlangana ne- Sahel ngetlhagwini kanye ne- Gulf of Guinea e- Atlantic Ocean ngesewula. Ihlanganisa indawo 923,769 square kilometres (356,669 mi   . Njengombana inabantu abangaphezu kweengidi ezima-236, lilizwe elinabantu abanengi khulu e- [[I-Afrika|Afrika]], begodu lilizwe lesithupha elinabantu abanengi khulu ephasini . I-Nigeria inomngcele we-[[Niger]] enyakatho, i-Chad enyakatho-mpumalanga, [[Cameroon|i-Cameroon]] empumalanga, ne [[I-Benin|-Benin]] entshonalanga . I-Nigeria yiriphabliki yombuso ehlanganisa amazwe ama -36 kanye ne- Federal Capital Territory, lapho ikosi yayo, i-Abuja, itholakala khona. Idorobha elikhulu khulu e-Nigeria ngokwenani labantu yi -Lagos, enye yamadorobha amakhulu khulu ephasini begodu mkhulu khulu e-Afrika. &lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=XygZjbNRap0C&amp;oi=fnd&amp;pg=PA1892&amp;dq=Nigeria&amp;ots=EWGNqPi2PK&amp;sig=whAWx-R5npGHZDYw6OX0OP6F5jQ&amp;redir_esc=y#v=onepage&amp;q=Nigeria&amp;f=false&lt;/ref&gt;

I-Nigeria sele ilikhaya lamasiko amanengi womdabu, imibuso yangaphambi kobukoloni kanye nemibuso kusukela eminyakeni eyikulungwana yesibili BC. Isiko le-Nok, c. 1500 BC, kutshwaya enye yeempucuko zokuthoma ezaziwako esifundeni. ImiBuso yama-Hausa beyihlala enyakatho, noMbuso we -Edo we-Benin eningizimu, uMbuso we -Igbo we-Nri eningizimu-mpumalanga begodu eningizimu-ntshonalanga, uMbuso we-Oyo . Indawo yamanje ye-Nigeria beyihlala amadorobha amanengi. Ekuthomeni kwekhulu leminyaka ye-19 ama-jihad wama-Fula agcina ku- Sokoto Caliphate . Umbuso wesimanjemanje wathoma ngokubusa kwamaBrithani ngekhulu le-19, wathatha ubujamo bawo bamanje ngokuhlanganiswa kwe- Southern Nigeria Protectorate kanye ne- Northern Nigeria Protectorate ngo-1914. AmaBrithani asungula izakhiwo zokuphatha nezomthetho begodu afaka amakhosi wesintu njengendlela yokubusa okungaqondileko .  I-Nigeria yaba yifederali ezijameleko ngokusemthethweni mhlana ali-1 kuNobayeni 1960. Yaba nepi yomndeni kusukela ngo-1967 ukuya ku-1970, kwalandela ukulandelana kwamabutho wamasotja kanye noburhulumende abakhethwe ngentando yenengi bekwaba kulapho ithola urhulumende ozinzileko ekhethweni lomongameli we-Nigeria ngo-1999. &lt;ref&gt;https://api.taylorfrancis.com/content/books/mono/download?identifierName=doi&amp;identifierValue=10.4324/9781003363088&amp;type=googlepdf&lt;/ref&gt;

I-Nigeria yizwe elinamazwe amanengi elihlala iintjhaba ezingaphezu kwama-250 ezikhuluma amalimi ahlukileko ama-500, zoke zifana namasiko ahlukahlukeneko.    Amaqembu amathathu amakhulu weentjhaba ngama- Hausa enyakatho, ama-Yoruba entshonalanga, kanye nama-Igbo empumalanga, ndawonye akha ngaphezu kwama-60% wabantu boke.  Ilimi elisemthethweni sisiNgisi, esikhethelwe ukusiza ukubumbana kwelimi ezingeni lezwe.  Umthethosisekelo we-Nigeria uqinisekisa ''itjhaphuluko'' yekolo,  begodu likhaya labantu abanengi bamaSulumane namaKrestu ephasini.  I-Nigeria ihlukaniswe phakathi kwamaSulumane, ahlala khulu engcenyeni yetlhagwini yenarha, namaKrestu, ahlala khulu ngeSewula; iinkolo zendabuko, ezifana nalezo ezivela eentjhabeni zama -Igbo nama -Yoruba, zimbalwa.&lt;ref&gt;https://books.google.com/books?hl=en&amp;lr=&amp;id=AA8ut32-If8C&amp;oi=fnd&amp;pg=PP11&amp;dq=Nigeria&amp;ots=zU5deGQ32N&amp;sig=aBbi_VWN08WkB_-io47w5xzLra4&lt;/ref&gt; 

I-Nigeria linamandla esifundeni se-Afrika begodu liphakathi nendawo eendabeni zamazwe ngamazwe. Umnotho we-Nigeria ngowesine ngobukhulu e-Afrika, ngowesi-52 ngobukhulu ephasini nge -GDP encani, begodu ngowesi-19 ngobukhulu nge -PPP . I-Nigeria ivamise ukubizwa ngokuthi yi-Giant of Africa ngezakhamuzi zayo ngebanga labantu abanengi nomnotho wayo,  begodu ithathwa njengemakethe ekhulako yiBhanga lePhasi . I-Nigeria lilunga elisungula i- African Union begodu lilunga leenhlangano ezinengi zamazwe ngamazwe, okufaka hlangana i -United Nations, i- Commonwealth of Nations, i-NAM,  i- Economic Community of West African States, i-Organization of Islamic Cooperation kanye ne -OPEC . Ingenye yama- Next Eleven economies, begodu lilunga, kanye ne [[I-Mexico|-Mexico]], Indonesia, ne [[Türkiye|-Turkey]], yesiqhema se-MINT.

== I-Etymology ==
Ibizo elithi ''[[wiktionary:Nigeria|Nigeria]]'' lisuselwa emlanjeni i-Niger ogeleza enarheni le. Ibizo leli laqanjwa mhlazi-8 kuTjhirhweni 1897, yintatheli ye-Britain u-Flora Shaw . IRiphabhliki ye-Niger engumakhelwana ithatha ibizo layo emlanjeni ofanako. Umsuka webizo elithi ''Niger'', ekuthomeni ebegade asebenza eendaweni eziphakathi nendawo zomlambo i-Niger, awuqiniseki. Igama leli kungenzeka litjhugululwe ibizo le -Tuareg elithi ''egerew &lt;u&gt;n-iger&lt;/u&gt; ewen'' (&quot;umlambo wemifula&quot;) ebegade lisetjenziswa babantu abahlala phakathi komlambo ozungeze i-Timbuktu ngaphambi kobukholoni be-Europe bekhulu le-19.   Ngaphambi kobana uFlora Shaw aphakamise ibizo elithi ''Nigeria'', amanye amagama ahlongozwako afaka hlangana ''i-Royal Niger Company Territories'', ''i-Central Sudan'', ''i-Niger Empire'', ''i-Niger Sudan'', kanye ne ''-Hausa Territories'' .&lt;ref&gt;https://academicjournals.org/article/article1380534762_Lawal%20and%20Oluwatoyin.pdf&lt;/ref&gt; 

Ukumbiwa kwedamu le-Kainji kutjengise ukusebenza kwensimbi ngekhulu lesibili BC. Ukutjhuguluka ukusuka esikhathini se-Neolithic ukuya esikhathini se -Iron Age kwenziwa ngaphandle kokukhiqizwa kwethusi okuphakathi. Abanye baphakamise bona ithekhnoloji ithuthele entshonalanga ukusuka e- Nile Valley . Kodwana i -Iron Age esigodini se-Niger River kanye nendawo yamahlathi kubonakala kwangaphambi kokungeniswa kwensimbi e-savanna ephezulu ngeminyaka engaphezu kwama-800, begodu kwandulela kwayo e-Nile Valley. Irhubhululo lakamuva litjengisa bona ukukhiqizwa kwensimbi kwenziwa ngokuzijamela e [[I-Afrika|-Afrika]] .    

Impucuko ye-Nok yathuthuka hlangana nomnyaka ka-1500 BC ukuya ku-200 AD.[1] Yakhiqiza iinthombe ezifana ne-terracotta ezingezinye zeenthombe zokuthoma ezaziwako e-Afrika[2][3][4][5][6] begodu yancibilikisa insimbi ngabo-550 BC begodu mhlamunye emakhulwini weminyaka ambalwa ngaphambilini.[7][8][9] Ubufakazi bokuncibilika kwensimbi nabo buvunyelwe eendaweni ze-Nsukka eningizimu-mpumalanga ye-Nigeria: kusukela ngo-2000 BC endaweni ye-Lejja[10] kanye no-750 BC endaweni ye-Opi.</text>
      <sha1>9av90g4nkigql1s6lxho1el4vskkq2t</sha1>
    </revision>
    <revision>
      <id>6458</id>
      <parentid>6457</parentid>
      <timestamp>2026-04-15T20:09:52Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6458</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6182" sha1="is93fzni5d0qastbt11hhiq6rr5oerx" xml:space="preserve">'''I-Nigeria''', ngokusemthethweni yi- '''Federal Republic of Nigeria''', yinarha eseTjingalanga ye-Afrika hlangana ne- Sahel ngetlhagwini kanye ne- Gulf of Guinea e- Atlantic Ocean ngesewula. Ihlanganisa indawo 923,769 square kilometres (356,669 mi   . Njengombana inabantu abangaphezu kweengidi ezima-236, lilizwe elinabantu abanengi khulu e- [[I-Afrika|Afrika]], begodu lilizwe lesithupha elinabantu abanengi khulu ephasini . I-Nigeria inomngcele we-[[Niger]] enyakatho, i-Chad enyakatho-mpumalanga, [[Cameroon|i-Cameroon]] empumalanga, ne [[I-Benin|-Benin]] entshonalanga . I-Nigeria yiriphabliki yombuso ehlanganisa amazwe ama -36 kanye ne- Federal Capital Territory, lapho ikosi yayo, i-Abuja, itholakala khona. Idorobha elikhulu khulu e-Nigeria ngokwenani labantu yi -Lagos, enye yamadorobha amakhulu khulu ephasini begodu mkhulu khulu e-Afrika. &lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=XygZjbNRap0C&amp;oi=fnd&amp;pg=PA1892&amp;dq=Nigeria&amp;ots=EWGNqPi2PK&amp;sig=whAWx-R5npGHZDYw6OX0OP6F5jQ&amp;redir_esc=y#v=onepage&amp;q=Nigeria&amp;f=false&lt;/ref&gt;

I-Nigeria sele ilikhaya lamasiko amanengi womdabu, imibuso yangaphambi kobukoloni kanye nemibuso kusukela eminyakeni eyikulungwana yesibili BC. Isiko le-Nok, c. 1500 BC, kutshwaya enye yeempucuko zokuthoma ezaziwako esifundeni. ImiBuso yama-Hausa beyihlala enyakatho, noMbuso we -Edo we-Benin eningizimu, uMbuso we -Igbo we-Nri eningizimu-mpumalanga begodu eningizimu-ntshonalanga, uMbuso we-Oyo . Indawo yamanje ye-Nigeria beyihlala amadorobha amanengi. Ekuthomeni kwekhulu leminyaka ye-19 ama-jihad wama-Fula agcina ku- Sokoto Caliphate . Umbuso wesimanjemanje wathoma ngokubusa kwamaBrithani ngekhulu le-19, wathatha ubujamo bawo bamanje ngokuhlanganiswa kwe- Southern Nigeria Protectorate kanye ne- Northern Nigeria Protectorate ngo-1914. AmaBrithani asungula izakhiwo zokuphatha nezomthetho begodu afaka amakhosi wesintu njengendlela yokubusa okungaqondileko .  I-Nigeria yaba yifederali ezijameleko ngokusemthethweni mhlana ali-1 kuNobayeni 1960. Yaba nepi yomndeni kusukela ngo-1967 ukuya ku-1970, kwalandela ukulandelana kwamabutho wamasotja kanye noburhulumende abakhethwe ngentando yenengi bekwaba kulapho ithola urhulumende ozinzileko ekhethweni lomongameli we-Nigeria ngo-1999. &lt;ref&gt;https://api.taylorfrancis.com/content/books/mono/download?identifierName=doi&amp;identifierValue=10.4324/9781003363088&amp;type=googlepdf&lt;/ref&gt;

I-Nigeria yizwe elinamazwe amanengi elihlala iintjhaba ezingaphezu kwama-250 ezikhuluma amalimi ahlukileko ama-500, zoke zifana namasiko ahlukahlukeneko.    Amaqembu amathathu amakhulu weentjhaba ngama- Hausa enyakatho, ama-Yoruba entshonalanga, kanye nama-Igbo empumalanga, ndawonye akha ngaphezu kwama-60% wabantu boke.  Ilimi elisemthethweni sisiNgisi, esikhethelwe ukusiza ukubumbana kwelimi ezingeni lezwe.  Umthethosisekelo we-Nigeria uqinisekisa ''itjhaphuluko'' yekolo,  begodu likhaya labantu abanengi bamaSulumane namaKrestu ephasini.  I-Nigeria ihlukaniswe phakathi kwamaSulumane, ahlala khulu engcenyeni yetlhagwini yenarha, namaKrestu, ahlala khulu ngeSewula; iinkolo zendabuko, ezifana nalezo ezivela eentjhabeni zama -Igbo nama -Yoruba, zimbalwa.&lt;ref&gt;https://books.google.com/books?hl=en&amp;lr=&amp;id=AA8ut32-If8C&amp;oi=fnd&amp;pg=PP11&amp;dq=Nigeria&amp;ots=zU5deGQ32N&amp;sig=aBbi_VWN08WkB_-io47w5xzLra4&lt;/ref&gt; 

I-Nigeria linamandla esifundeni se-Afrika begodu liphakathi nendawo eendabeni zamazwe ngamazwe. Umnotho we-Nigeria ngowesine ngobukhulu e-Afrika, ngowesi-52 ngobukhulu ephasini nge -GDP encani, begodu ngowesi-19 ngobukhulu nge -PPP . I-Nigeria ivamise ukubizwa ngokuthi yi-Giant of Africa ngezakhamuzi zayo ngebanga labantu abanengi nomnotho wayo,  begodu ithathwa njengemakethe ekhulako yiBhanga lePhasi . I-Nigeria lilunga elisungula i- African Union begodu lilunga leenhlangano ezinengi zamazwe ngamazwe, okufaka hlangana i -United Nations, i- Commonwealth of Nations, i-NAM,  i- Economic Community of West African States, i-Organization of Islamic Cooperation kanye ne -OPEC . Ingenye yama- Next Eleven economies, begodu lilunga, kanye ne [[I-Mexico|-Mexico]], Indonesia, ne [[Türkiye|-Turkey]], yesiqhema se-MINT.

== I-Etymology ==
Ibizo elithi ''[[wiktionary:Nigeria|Nigeria]]'' lisuselwa emlanjeni i-Niger ogeleza enarheni le. Ibizo leli laqanjwa mhlazi-8 kuTjhirhweni 1897, yintatheli ye-Britain u-Flora Shaw . IRiphabhliki ye-Niger engumakhelwana ithatha ibizo layo emlanjeni ofanako. Umsuka webizo elithi ''Niger'', ekuthomeni ebegade asebenza eendaweni eziphakathi nendawo zomlambo i-Niger, awuqiniseki. Igama leli kungenzeka litjhugululwe ibizo le -Tuareg elithi ''egerew &lt;u&gt;n-iger&lt;/u&gt; ewen'' (&quot;umlambo wemifula&quot;) ebegade lisetjenziswa babantu abahlala phakathi komlambo ozungeze i-Timbuktu ngaphambi kobukholoni be-Europe bekhulu le-19.   Ngaphambi kobana uFlora Shaw aphakamise ibizo elithi ''Nigeria'', amanye amagama ahlongozwako afaka hlangana ''i-Royal Niger Company Territories'', ''i-Central Sudan'', ''i-Niger Empire'', ''i-Niger Sudan'', kanye ne ''-Hausa Territories'' .&lt;ref&gt;https://academicjournals.org/article/article1380534762_Lawal%20and%20Oluwatoyin.pdf&lt;/ref&gt; 

Ukumbiwa kwedamu le-Kainji kutjengise ukusebenza kwensimbi ngekhulu lesibili BC. Ukutjhuguluka ukusuka esikhathini se-Neolithic ukuya esikhathini se -Iron Age kwenziwa ngaphandle kokukhiqizwa kwethusi okuphakathi. Abanye baphakamise bona ithekhnoloji ithuthele entshonalanga ukusuka e- Nile Valley . Kodwana i -Iron Age esigodini se-Niger River kanye nendawo yamahlathi kubonakala kwangaphambi kokungeniswa kwensimbi e-savanna ephezulu ngeminyaka engaphezu kwama-800, begodu kwandulela kwayo e-Nile Valley. Irhubhululo lakamuva litjengisa bona ukukhiqizwa kwensimbi kwenziwa ngokuzijamela e [[I-Afrika|-Afrika]] .    

Impucuko ye-Nok yathuthuka hlangana nomnyaka ka-1500 BC ukuya ku-200 AD.[1] Yakhiqiza iinthombe ezifana ne-terracotta ezingezinye zeenthombe zokuthoma ezaziwako e-Afrika[2][3][4][5][6] begodu yancibilikisa insimbi ngabo-550 BC begodu mhlamunye emakhulwini weminyaka ambalwa ngaphambilini.[7][8][9] Ubufakazi bokuncibilika kwensimbi nabo buvunyelwe eendaweni ze-Nsukka eningizimu-mpumalanga ye-Nigeria: kusukela ngo-2000 BC endaweni ye-Lejja[10] kanye no-750 BC endaweni ye-Opi.

== Iinkomba ==</text>
      <sha1>is93fzni5d0qastbt11hhiq6rr5oerx</sha1>
    </revision>
    <revision>
      <id>6459</id>
      <parentid>6458</parentid>
      <timestamp>2026-04-15T20:10:25Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6459</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6214" sha1="t88g61jv1zpx2qnzlgmzskosz82xah2" xml:space="preserve">'''I-Nigeria''', ngokusemthethweni yi- '''Federal Republic of Nigeria''', yinarha eseTjingalanga ye-Afrika hlangana ne- Sahel ngetlhagwini kanye ne- Gulf of Guinea e- Atlantic Ocean ngesewula. Ihlanganisa indawo 923,769 square kilometres (356,669 mi   . Njengombana inabantu abangaphezu kweengidi ezima-236, lilizwe elinabantu abanengi khulu e- [[I-Afrika|Afrika]], begodu lilizwe lesithupha elinabantu abanengi khulu ephasini . I-Nigeria inomngcele we-[[Niger]] enyakatho, i-Chad enyakatho-mpumalanga, [[Cameroon|i-Cameroon]] empumalanga, ne [[I-Benin|-Benin]] entshonalanga . I-Nigeria yiriphabliki yombuso ehlanganisa amazwe ama -36 kanye ne- Federal Capital Territory, lapho ikosi yayo, i-Abuja, itholakala khona. Idorobha elikhulu khulu e-Nigeria ngokwenani labantu yi -Lagos, enye yamadorobha amakhulu khulu ephasini begodu mkhulu khulu e-Afrika. &lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=XygZjbNRap0C&amp;oi=fnd&amp;pg=PA1892&amp;dq=Nigeria&amp;ots=EWGNqPi2PK&amp;sig=whAWx-R5npGHZDYw6OX0OP6F5jQ&amp;redir_esc=y#v=onepage&amp;q=Nigeria&amp;f=false&lt;/ref&gt;

I-Nigeria sele ilikhaya lamasiko amanengi womdabu, imibuso yangaphambi kobukoloni kanye nemibuso kusukela eminyakeni eyikulungwana yesibili BC. Isiko le-Nok, c. 1500 BC, kutshwaya enye yeempucuko zokuthoma ezaziwako esifundeni. ImiBuso yama-Hausa beyihlala enyakatho, noMbuso we -Edo we-Benin eningizimu, uMbuso we -Igbo we-Nri eningizimu-mpumalanga begodu eningizimu-ntshonalanga, uMbuso we-Oyo . Indawo yamanje ye-Nigeria beyihlala amadorobha amanengi. Ekuthomeni kwekhulu leminyaka ye-19 ama-jihad wama-Fula agcina ku- Sokoto Caliphate . Umbuso wesimanjemanje wathoma ngokubusa kwamaBrithani ngekhulu le-19, wathatha ubujamo bawo bamanje ngokuhlanganiswa kwe- Southern Nigeria Protectorate kanye ne- Northern Nigeria Protectorate ngo-1914. AmaBrithani asungula izakhiwo zokuphatha nezomthetho begodu afaka amakhosi wesintu njengendlela yokubusa okungaqondileko .  I-Nigeria yaba yifederali ezijameleko ngokusemthethweni mhlana ali-1 kuNobayeni 1960. Yaba nepi yomndeni kusukela ngo-1967 ukuya ku-1970, kwalandela ukulandelana kwamabutho wamasotja kanye noburhulumende abakhethwe ngentando yenengi bekwaba kulapho ithola urhulumende ozinzileko ekhethweni lomongameli we-Nigeria ngo-1999. &lt;ref&gt;https://api.taylorfrancis.com/content/books/mono/download?identifierName=doi&amp;identifierValue=10.4324/9781003363088&amp;type=googlepdf&lt;/ref&gt;

I-Nigeria yizwe elinamazwe amanengi elihlala iintjhaba ezingaphezu kwama-250 ezikhuluma amalimi ahlukileko ama-500, zoke zifana namasiko ahlukahlukeneko.    Amaqembu amathathu amakhulu weentjhaba ngama- Hausa enyakatho, ama-Yoruba entshonalanga, kanye nama-Igbo empumalanga, ndawonye akha ngaphezu kwama-60% wabantu boke.  Ilimi elisemthethweni sisiNgisi, esikhethelwe ukusiza ukubumbana kwelimi ezingeni lezwe.  Umthethosisekelo we-Nigeria uqinisekisa ''itjhaphuluko'' yekolo,  begodu likhaya labantu abanengi bamaSulumane namaKrestu ephasini.  I-Nigeria ihlukaniswe phakathi kwamaSulumane, ahlala khulu engcenyeni yetlhagwini yenarha, namaKrestu, ahlala khulu ngeSewula; iinkolo zendabuko, ezifana nalezo ezivela eentjhabeni zama -Igbo nama -Yoruba, zimbalwa.&lt;ref&gt;https://books.google.com/books?hl=en&amp;lr=&amp;id=AA8ut32-If8C&amp;oi=fnd&amp;pg=PP11&amp;dq=Nigeria&amp;ots=zU5deGQ32N&amp;sig=aBbi_VWN08WkB_-io47w5xzLra4&lt;/ref&gt; 

I-Nigeria linamandla esifundeni se-Afrika begodu liphakathi nendawo eendabeni zamazwe ngamazwe. Umnotho we-Nigeria ngowesine ngobukhulu e-Afrika, ngowesi-52 ngobukhulu ephasini nge -GDP encani, begodu ngowesi-19 ngobukhulu nge -PPP . I-Nigeria ivamise ukubizwa ngokuthi yi-Giant of Africa ngezakhamuzi zayo ngebanga labantu abanengi nomnotho wayo,  begodu ithathwa njengemakethe ekhulako yiBhanga lePhasi . I-Nigeria lilunga elisungula i- African Union begodu lilunga leenhlangano ezinengi zamazwe ngamazwe, okufaka hlangana i -United Nations, i- Commonwealth of Nations, i-NAM,  i- Economic Community of West African States, i-Organization of Islamic Cooperation kanye ne -OPEC . Ingenye yama- Next Eleven economies, begodu lilunga, kanye ne [[I-Mexico|-Mexico]], Indonesia, ne [[Türkiye|-Turkey]], yesiqhema se-MINT.

== I-Etymology ==
Ibizo elithi ''[[wiktionary:Nigeria|Nigeria]]'' lisuselwa emlanjeni i-Niger ogeleza enarheni le. Ibizo leli laqanjwa mhlazi-8 kuTjhirhweni 1897, yintatheli ye-Britain u-Flora Shaw . IRiphabhliki ye-Niger engumakhelwana ithatha ibizo layo emlanjeni ofanako. Umsuka webizo elithi ''Niger'', ekuthomeni ebegade asebenza eendaweni eziphakathi nendawo zomlambo i-Niger, awuqiniseki. Igama leli kungenzeka litjhugululwe ibizo le -Tuareg elithi ''egerew &lt;u&gt;n-iger&lt;/u&gt; ewen'' (&quot;umlambo wemifula&quot;) ebegade lisetjenziswa babantu abahlala phakathi komlambo ozungeze i-Timbuktu ngaphambi kobukholoni be-Europe bekhulu le-19.   Ngaphambi kobana uFlora Shaw aphakamise ibizo elithi ''Nigeria'', amanye amagama ahlongozwako afaka hlangana ''i-Royal Niger Company Territories'', ''i-Central Sudan'', ''i-Niger Empire'', ''i-Niger Sudan'', kanye ne ''-Hausa Territories'' .&lt;ref&gt;https://academicjournals.org/article/article1380534762_Lawal%20and%20Oluwatoyin.pdf&lt;/ref&gt; 

Ukumbiwa kwedamu le-Kainji kutjengise ukusebenza kwensimbi ngekhulu lesibili BC. Ukutjhuguluka ukusuka esikhathini se-Neolithic ukuya esikhathini se -Iron Age kwenziwa ngaphandle kokukhiqizwa kwethusi okuphakathi. Abanye baphakamise bona ithekhnoloji ithuthele entshonalanga ukusuka e- Nile Valley . Kodwana i -Iron Age esigodini se-Niger River kanye nendawo yamahlathi kubonakala kwangaphambi kokungeniswa kwensimbi e-savanna ephezulu ngeminyaka engaphezu kwama-800, begodu kwandulela kwayo e-Nile Valley. Irhubhululo lakamuva litjengisa bona ukukhiqizwa kwensimbi kwenziwa ngokuzijamela e [[I-Afrika|-Afrika]] .    

Impucuko ye-Nok yathuthuka hlangana nomnyaka ka-1500 BC ukuya ku-200 AD.[1] Yakhiqiza iinthombe ezifana ne-terracotta ezingezinye zeenthombe zokuthoma ezaziwako e-Afrika[2][3][4][5][6] begodu yancibilikisa insimbi ngabo-550 BC begodu mhlamunye emakhulwini weminyaka ambalwa ngaphambilini.[7][8][9] Ubufakazi bokuncibilika kwensimbi nabo buvunyelwe eendaweni ze-Nsukka eningizimu-mpumalanga ye-Nigeria: kusukela ngo-2000 BC endaweni ye-Lejja[10] kanye no-750 BC endaweni ye-Opi.

== Iinkomba ==
{{reflist}}
[[Category:Afrika]]</text>
      <sha1>t88g61jv1zpx2qnzlgmzskosz82xah2</sha1>
    </revision>
    <revision>
      <id>6460</id>
      <parentid>6459</parentid>
      <timestamp>2026-04-15T20:11:03Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>/* I-Etymology */</comment>
      <origin>6460</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6199" sha1="himd3rwyw71xd3whbz3t9iy6cvj2ni5" xml:space="preserve">'''I-Nigeria''', ngokusemthethweni yi- '''Federal Republic of Nigeria''', yinarha eseTjingalanga ye-Afrika hlangana ne- Sahel ngetlhagwini kanye ne- Gulf of Guinea e- Atlantic Ocean ngesewula. Ihlanganisa indawo 923,769 square kilometres (356,669 mi   . Njengombana inabantu abangaphezu kweengidi ezima-236, lilizwe elinabantu abanengi khulu e- [[I-Afrika|Afrika]], begodu lilizwe lesithupha elinabantu abanengi khulu ephasini . I-Nigeria inomngcele we-[[Niger]] enyakatho, i-Chad enyakatho-mpumalanga, [[Cameroon|i-Cameroon]] empumalanga, ne [[I-Benin|-Benin]] entshonalanga . I-Nigeria yiriphabliki yombuso ehlanganisa amazwe ama -36 kanye ne- Federal Capital Territory, lapho ikosi yayo, i-Abuja, itholakala khona. Idorobha elikhulu khulu e-Nigeria ngokwenani labantu yi -Lagos, enye yamadorobha amakhulu khulu ephasini begodu mkhulu khulu e-Afrika. &lt;ref&gt;https://books.google.co.za/books?hl=en&amp;lr=&amp;id=XygZjbNRap0C&amp;oi=fnd&amp;pg=PA1892&amp;dq=Nigeria&amp;ots=EWGNqPi2PK&amp;sig=whAWx-R5npGHZDYw6OX0OP6F5jQ&amp;redir_esc=y#v=onepage&amp;q=Nigeria&amp;f=false&lt;/ref&gt;

I-Nigeria sele ilikhaya lamasiko amanengi womdabu, imibuso yangaphambi kobukoloni kanye nemibuso kusukela eminyakeni eyikulungwana yesibili BC. Isiko le-Nok, c. 1500 BC, kutshwaya enye yeempucuko zokuthoma ezaziwako esifundeni. ImiBuso yama-Hausa beyihlala enyakatho, noMbuso we -Edo we-Benin eningizimu, uMbuso we -Igbo we-Nri eningizimu-mpumalanga begodu eningizimu-ntshonalanga, uMbuso we-Oyo . Indawo yamanje ye-Nigeria beyihlala amadorobha amanengi. Ekuthomeni kwekhulu leminyaka ye-19 ama-jihad wama-Fula agcina ku- Sokoto Caliphate . Umbuso wesimanjemanje wathoma ngokubusa kwamaBrithani ngekhulu le-19, wathatha ubujamo bawo bamanje ngokuhlanganiswa kwe- Southern Nigeria Protectorate kanye ne- Northern Nigeria Protectorate ngo-1914. AmaBrithani asungula izakhiwo zokuphatha nezomthetho begodu afaka amakhosi wesintu njengendlela yokubusa okungaqondileko .  I-Nigeria yaba yifederali ezijameleko ngokusemthethweni mhlana ali-1 kuNobayeni 1960. Yaba nepi yomndeni kusukela ngo-1967 ukuya ku-1970, kwalandela ukulandelana kwamabutho wamasotja kanye noburhulumende abakhethwe ngentando yenengi bekwaba kulapho ithola urhulumende ozinzileko ekhethweni lomongameli we-Nigeria ngo-1999. &lt;ref&gt;https://api.taylorfrancis.com/content/books/mono/download?identifierName=doi&amp;identifierValue=10.4324/9781003363088&amp;type=googlepdf&lt;/ref&gt;

I-Nigeria yizwe elinamazwe amanengi elihlala iintjhaba ezingaphezu kwama-250 ezikhuluma amalimi ahlukileko ama-500, zoke zifana namasiko ahlukahlukeneko.    Amaqembu amathathu amakhulu weentjhaba ngama- Hausa enyakatho, ama-Yoruba entshonalanga, kanye nama-Igbo empumalanga, ndawonye akha ngaphezu kwama-60% wabantu boke.  Ilimi elisemthethweni sisiNgisi, esikhethelwe ukusiza ukubumbana kwelimi ezingeni lezwe.  Umthethosisekelo we-Nigeria uqinisekisa ''itjhaphuluko'' yekolo,  begodu likhaya labantu abanengi bamaSulumane namaKrestu ephasini.  I-Nigeria ihlukaniswe phakathi kwamaSulumane, ahlala khulu engcenyeni yetlhagwini yenarha, namaKrestu, ahlala khulu ngeSewula; iinkolo zendabuko, ezifana nalezo ezivela eentjhabeni zama -Igbo nama -Yoruba, zimbalwa.&lt;ref&gt;https://books.google.com/books?hl=en&amp;lr=&amp;id=AA8ut32-If8C&amp;oi=fnd&amp;pg=PP11&amp;dq=Nigeria&amp;ots=zU5deGQ32N&amp;sig=aBbi_VWN08WkB_-io47w5xzLra4&lt;/ref&gt; 

I-Nigeria linamandla esifundeni se-Afrika begodu liphakathi nendawo eendabeni zamazwe ngamazwe. Umnotho we-Nigeria ngowesine ngobukhulu e-Afrika, ngowesi-52 ngobukhulu ephasini nge -GDP encani, begodu ngowesi-19 ngobukhulu nge -PPP . I-Nigeria ivamise ukubizwa ngokuthi yi-Giant of Africa ngezakhamuzi zayo ngebanga labantu abanengi nomnotho wayo,  begodu ithathwa njengemakethe ekhulako yiBhanga lePhasi . I-Nigeria lilunga elisungula i- African Union begodu lilunga leenhlangano ezinengi zamazwe ngamazwe, okufaka hlangana i -United Nations, i- Commonwealth of Nations, i-NAM,  i- Economic Community of West African States, i-Organization of Islamic Cooperation kanye ne -OPEC . Ingenye yama- Next Eleven economies, begodu lilunga, kanye ne [[I-Mexico|-Mexico]], Indonesia, ne [[Türkiye|-Turkey]], yesiqhema se-MINT.

== I-Etymology ==
Ibizo elithi ''[[wiktionary:Nigeria|Nigeria]]'' lisuselwa emlanjeni i-Niger ogeleza enarheni le. Ibizo leli laqanjwa mhlazi-8 kuTjhirhweni 1897, yintatheli ye-Britain u-Flora Shaw . IRiphabhliki ye-Niger engumakhelwana ithatha ibizo layo emlanjeni ofanako. Umsuka webizo elithi ''Niger'', ekuthomeni ebegade asebenza eendaweni eziphakathi nendawo zomlambo i-Niger, awuqiniseki. Igama leli kungenzeka litjhugululwe ibizo le -Tuareg elithi ''egerew &lt;u&gt;n-iger&lt;/u&gt; ewen'' (&quot;umlambo wemifula&quot;) ebegade lisetjenziswa babantu abahlala phakathi komlambo ozungeze i-Timbuktu ngaphambi kobukholoni be-Europe bekhulu le-19.   Ngaphambi kobana uFlora Shaw aphakamise ibizo elithi ''Nigeria'', amanye amagama ahlongozwako afaka hlangana ''i-Royal Niger Company Territories'', ''i-Central Sudan'', ''i-Niger Empire'', ''i-Niger Sudan'', kanye ne ''-Hausa Territories'' .&lt;ref&gt;https://academicjournals.org/article/article1380534762_Lawal%20and%20Oluwatoyin.pdf&lt;/ref&gt; 

Ukumbiwa kwedamu le-Kainji kutjengise ukusebenza kwensimbi ngekhulu lesibili BC. Ukutjhuguluka ukusuka esikhathini se-Neolithic ukuya esikhathini se -Iron Age kwenziwa ngaphandle kokukhiqizwa kwethusi okuphakathi. Abanye baphakamise bona ithekhnoloji ithuthele entshonalanga ukusuka e- Nile Valley . Kodwana i -Iron Age esigodini se-Niger River kanye nendawo yamahlathi kubonakala kwangaphambi kokungeniswa kwensimbi e-savanna ephezulu ngeminyaka engaphezu kwama-800, begodu kwandulela kwayo e-Nile Valley. Irhubhululo lakamuva litjengisa bona ukukhiqizwa kwensimbi kwenziwa ngokuzijamela e [[I-Afrika|-Afrika]] .    

Impucuko ye-Nok yathuthuka hlangana nomnyaka ka-1500 BC ukuya ku-200 AD. Yakhiqiza iinthombe ezifana ne-terracotta ezingezinye zeenthombe zokuthoma ezaziwako e-[[I-Afrika|Afrika]] begodu yancibilikisa insimbi ngabo-550 BC begodu mhlamunye emakhulwini weminyaka ambalwa ngaphambilini.Ubufakazi bokuncibilika kwensimbi nabo buvunyelwe eendaweni ze-Nsukka eningizimu-mpumalanga ye-Nigeria: kusukela ngo-2000 BC endaweni ye-Lejja[10] kanye no-750 BC endaweni ye-Opi.

== Iinkomba ==
{{reflist}}
[[Category:Afrika]]</text>
      <sha1>himd3rwyw71xd3whbz3t9iy6cvj2ni5</sha1>
    </revision>
  </page>
  <page>
    <title>I-Togo</title>
    <ns>0</ns>
    <id>1097</id>
    <revision>
      <id>6462</id>
      <timestamp>2026-04-15T21:34:36Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1348759615|Togo]]&quot;</comment>
      <origin>6462</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2300" sha1="ieu8nz41yb686ubvqwxwv23aayo9z3i" xml:space="preserve">
'''I-Togo''', [ a ] ngokusemthethweni '''iRiphabhliki ye-Togo''', [ b ] lilizwe eliseTjingalanga ye-Afrika . Inomngcele we -Ghana ngeTjingalanga, [[i-Benin]] ngepumalanga kanye [[Burkina Faso|ne-Burkina Faso]] ngetlhagwini .  Ngelinye lamazwe angakathuthuki khulu ephasini. Iya enyakatho ukusuka e- Gulf of Guinea (lapho inhlokodolobha yayo, i-Lomé, itholakala khona) ukuya emngceleni we-Burkina Faso-Togo. &lt;ref name=&quot;Republic of Togo&quot; /&gt; Lilizwe elincani, elitjhisako, elinamakhilomitha 57,000 square kilometres (22,000 square miles)  elinabantu abangaba ziingidi ezi-8,  begodu linobubanzi obungaphasi kwe- 115 km (71 mi) hlangana ne-Ghana nomakhelwana wayo wepumalanga i-Benin. [ 15 ] 

Abantu abahlukahlukeneko bahlala emingceleni ye-Togo yanje hlangana nekhulu le-11 nele-16. Hlangana nekhulu leminyaka le-16 nele-18, indawo eseduze nelwandle gade isebenza njengendawo yokurhweba ngeengqila ze-Europe, okwenza bona i-Togo nendawo eseduze kwayo ibizo elithi &quot;The Slave Coast &quot;. Ngo-1884, ngesikhathi sokulwela i-Afrika, i-Germany yasungula indawo evikelweko esifundeni esibizwa nge -Togoland . Ngemva kwePi yePhasi yoku-1, i-Togo yadluliselwa e- France nemingcele yayo yesikhatheso. I-Togo yathola ikululeko e-France ngo-1960.   Ngo-1967, u-Gnassingbé Eyadéma warhola ukuvukela umbuso kwezempi begodu waba ngumengameli wombuso ophikisana namakhomanisi, onehlangano eyodwa. Ngo-1993, u-Eyadéma waqalana namakhetho weenhlangano ezinengi ebegade ahlanjululwe kukungalungi, begodu wanqoba ubumongameli kathathu. Ngesikhathi sokuhlongakala kwakhe, u-Eyadéma &quot;bekangumdosiphambili osebenze isikhathi eside khulu emlandwini [[I-Afrika|we-Afrika]] wanamhlanjesi&quot;, sele abe ngumengameli iminyaka ema-38.  Ngo-2005, indodanakhe u-Faure Gnassingbé wakhethwa njengomengameli.


I-Togo yinarha etjhisako, engezansi ye-Sahara[1] umnotho wayo othembele khulu kwezokulima.[2] Ilimi elisemthethweni lisiFulentshi,[2] kodwana kukhulunywa amanye amalimi, khulukhulu lawo womndeni wama-Gbe. I-47.8% yabantu inamathela ebuKrestu, okwenza bona ibe yikolo ekulu khulu enarheni.[3] I-Togo lilunga le-United Nations, i-African Union, i-Organization of Islamic Cooperation, i-South Atlantic Peace and Cooperation Zone, i-Francophonie, i-Commonwealth of Nations, kanye ne-Economic Community of West African States.</text>
      <sha1>ieu8nz41yb686ubvqwxwv23aayo9z3i</sha1>
    </revision>
    <revision>
      <id>6463</id>
      <parentid>6462</parentid>
      <timestamp>2026-04-15T21:35:12Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6463</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2262" sha1="f414zgzy6egh6tkwbgpa25qy1gs25p1" xml:space="preserve">
'''I-Togo''', [ a ] ngokusemthethweni '''iRiphabhliki ye-Togo''', [ b ] lilizwe eliseTjingalanga ye-Afrika . Inomngcele we -Ghana ngeTjingalanga, [[i-Benin]] ngepumalanga kanye [[Burkina Faso|ne-Burkina Faso]] ngetlhagwini .  Ngelinye lamazwe angakathuthuki khulu ephasini. Iya enyakatho ukusuka e- Gulf of Guinea (lapho inhlokodolobha yayo, i-Lomé, itholakala khona) ukuya emngceleni we-Burkina Faso-Togo. Lilizwe elincani, elitjhisako, elinamakhilomitha 57,000 square kilometres (22,000 square miles)  elinabantu abangaba ziingidi ezi-8,  begodu linobubanzi obungaphasi kwe- 115 km (71 mi) hlangana ne-Ghana nomakhelwana wayo wepumalanga i-Benin.  

Abantu abahlukahlukeneko bahlala emingceleni ye-Togo yanje hlangana nekhulu le-11 nele-16. Hlangana nekhulu leminyaka le-16 nele-18, indawo eseduze nelwandle gade isebenza njengendawo yokurhweba ngeengqila ze-Europe, okwenza bona i-Togo nendawo eseduze kwayo ibizo elithi &quot;The Slave Coast &quot;. Ngo-1884, ngesikhathi sokulwela i-Afrika, i-Germany yasungula indawo evikelweko esifundeni esibizwa nge -Togoland . Ngemva kwePi yePhasi yoku-1, i-Togo yadluliselwa e- France nemingcele yayo yesikhatheso. I-Togo yathola ikululeko e-France ngo-1960.   Ngo-1967, u-Gnassingbé Eyadéma warhola ukuvukela umbuso kwezempi begodu waba ngumengameli wombuso ophikisana namakhomanisi, onehlangano eyodwa. Ngo-1993, u-Eyadéma waqalana namakhetho weenhlangano ezinengi ebegade ahlanjululwe kukungalungi, begodu wanqoba ubumongameli kathathu. Ngesikhathi sokuhlongakala kwakhe, u-Eyadéma &quot;bekangumdosiphambili osebenze isikhathi eside khulu emlandwini [[I-Afrika|we-Afrika]] wanamhlanjesi&quot;, sele abe ngumengameli iminyaka ema-38.  Ngo-2005, indodanakhe u-Faure Gnassingbé wakhethwa njengomengameli.


I-Togo yinarha etjhisako, engezansi ye-Sahara[1] umnotho wayo othembele khulu kwezokulima.[2] Ilimi elisemthethweni lisiFulentshi,[2] kodwana kukhulunywa amanye amalimi, khulukhulu lawo womndeni wama-Gbe. I-47.8% yabantu inamathela ebuKrestu, okwenza bona ibe yikolo ekulu khulu enarheni.[3] I-Togo lilunga le-United Nations, i-African Union, i-Organization of Islamic Cooperation, i-South Atlantic Peace and Cooperation Zone, i-Francophonie, i-Commonwealth of Nations, kanye ne-Economic Community of West African States.</text>
      <sha1>f414zgzy6egh6tkwbgpa25qy1gs25p1</sha1>
    </revision>
    <revision>
      <id>6464</id>
      <parentid>6463</parentid>
      <timestamp>2026-04-15T21:37:28Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6464</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2647" sha1="bb26dkt65z67ufkck2usrp0ve0olt0u" xml:space="preserve">
'''I-Togo''', ngokusemthethweni '''iRiphabhliki ye-Togo''', lilizwe eliseTjingalanga ye-Afrika . Inomngcele we -Ghana ngeTjingalanga, [[i-Benin]] ngepumalanga kanye [[Burkina Faso|ne-Burkina Faso]] ngetlhagwini .  Ngelinye lamazwe angakathuthuki khulu ephasini. Iya enyakatho ukusuka e- Gulf of Guinea (lapho inhlokodolobha yayo, i-Lomé, itholakala khona) ukuya emngceleni we-Burkina Faso-Togo. Lilizwe elincani, elitjhisako, elinamakhilomitha 57,000 square kilometres (22,000 square miles)  elinabantu abangaba ziingidi ezi-8,  begodu linobubanzi obungaphasi kwe- 115 km (71 mi) hlangana ne-Ghana nomakhelwana wayo wepumalanga i-Benin.&lt;ref&gt;https://books.google.com/books?hl=en&amp;lr=&amp;id=LfVkp1wQz5kC&amp;oi=fnd&amp;pg=PA5&amp;dq=togo&amp;ots=n3Th7QAYPb&amp;sig=1YwO-W_nvc6JiVL437bxVDTm3pY&lt;/ref&gt;  

Abantu abahlukahlukeneko bahlala emingceleni ye-Togo yanje hlangana nekhulu le-11 nele-16. Hlangana nekhulu leminyaka le-16 nele-18, indawo eseduze nelwandle gade isebenza njengendawo yokurhweba ngeengqila ze-Europe, okwenza bona i-Togo nendawo eseduze kwayo ibizo elithi &quot;The Slave Coast &quot;. Ngo-1884, ngesikhathi sokulwela i-Afrika, i-Germany yasungula indawo evikelweko esifundeni esibizwa nge -Togoland . Ngemva kwePi yePhasi yoku-1, i-Togo yadluliselwa e- France nemingcele yayo yesikhatheso. I-Togo yathola ikululeko e-France ngo-1960.   Ngo-1967, u-Gnassingbé Eyadéma warhola ukuvukela umbuso kwezempi begodu waba ngumengameli wombuso ophikisana namakhomanisi, onehlangano eyodwa. Ngo-1993, u-Eyadéma waqalana namakhetho weenhlangano ezinengi ebegade ahlanjululwe kukungalungi, begodu wanqoba ubumongameli kathathu. Ngesikhathi sokuhlongakala kwakhe, u-Eyadéma &quot;bekangumdosiphambili osebenze isikhathi eside khulu emlandwini [[I-Afrika|we-Afrika]] wanamhlanjesi&quot;, sele abe ngumengameli iminyaka ema-38.  Ngo-2005, indodanakhe u-Faure Gnassingbé wakhethwa njengomengameli.&lt;ref&gt;https://scholar.google.com/scholar?hl=en&amp;as_sdt=0%2C5&amp;q=togo&amp;btnG=#:~:text=Togo%3A%20recent%20political%20and%20economic%20development&lt;/ref&gt;



I-Togo yinarha etjhisako, engezansi ye-Sahara umnotho wayo othembele khulu kwezokulima.[2] Ilimi elisemthethweni lisiFulentshi,[2] kodwana kukhulunywa amanye amalimi, khulukhulu lawo womndeni wama-Gbe. I-47.8% yabantu inamathela ebuKrestu, okwenza bona ibe yikolo ekulu khulu enarheni.[3] I-Togo lilunga le-United Nations, i-African Union, i-Organization of Islamic Cooperation, i-South Atlantic Peace and Cooperation Zone, i-Francophonie, i-Commonwealth of Nations, kanye ne-Economic Community of West African States.&lt;ref&gt;https://scholar.google.com/scholar?hl=en&amp;as_sdt=0%2C5&amp;q=togo&amp;btnG=#:~:text=Rumour%20and%20power%20in%20Togo&lt;/ref&gt;</text>
      <sha1>bb26dkt65z67ufkck2usrp0ve0olt0u</sha1>
    </revision>
    <revision>
      <id>6465</id>
      <parentid>6464</parentid>
      <timestamp>2026-04-15T21:37:48Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6465</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2661" sha1="1ygcconx4zm4f7hov3m8qzxf0hw36w1" xml:space="preserve">
'''I-Togo''', ngokusemthethweni '''iRiphabhliki ye-Togo''', lilizwe eliseTjingalanga ye-Afrika . Inomngcele we -Ghana ngeTjingalanga, [[i-Benin]] ngepumalanga kanye [[Burkina Faso|ne-Burkina Faso]] ngetlhagwini .  Ngelinye lamazwe angakathuthuki khulu ephasini. Iya enyakatho ukusuka e- Gulf of Guinea (lapho inhlokodolobha yayo, i-Lomé, itholakala khona) ukuya emngceleni we-Burkina Faso-Togo. Lilizwe elincani, elitjhisako, elinamakhilomitha 57,000 square kilometres (22,000 square miles)  elinabantu abangaba ziingidi ezi-8,  begodu linobubanzi obungaphasi kwe- 115 km (71 mi) hlangana ne-Ghana nomakhelwana wayo wepumalanga i-Benin.&lt;ref&gt;https://books.google.com/books?hl=en&amp;lr=&amp;id=LfVkp1wQz5kC&amp;oi=fnd&amp;pg=PA5&amp;dq=togo&amp;ots=n3Th7QAYPb&amp;sig=1YwO-W_nvc6JiVL437bxVDTm3pY&lt;/ref&gt;  

Abantu abahlukahlukeneko bahlala emingceleni ye-Togo yanje hlangana nekhulu le-11 nele-16. Hlangana nekhulu leminyaka le-16 nele-18, indawo eseduze nelwandle gade isebenza njengendawo yokurhweba ngeengqila ze-Europe, okwenza bona i-Togo nendawo eseduze kwayo ibizo elithi &quot;The Slave Coast &quot;. Ngo-1884, ngesikhathi sokulwela i-Afrika, i-Germany yasungula indawo evikelweko esifundeni esibizwa nge -Togoland . Ngemva kwePi yePhasi yoku-1, i-Togo yadluliselwa e- France nemingcele yayo yesikhatheso. I-Togo yathola ikululeko e-France ngo-1960.   Ngo-1967, u-Gnassingbé Eyadéma warhola ukuvukela umbuso kwezempi begodu waba ngumengameli wombuso ophikisana namakhomanisi, onehlangano eyodwa. Ngo-1993, u-Eyadéma waqalana namakhetho weenhlangano ezinengi ebegade ahlanjululwe kukungalungi, begodu wanqoba ubumongameli kathathu. Ngesikhathi sokuhlongakala kwakhe, u-Eyadéma &quot;bekangumdosiphambili osebenze isikhathi eside khulu emlandwini [[I-Afrika|we-Afrika]] wanamhlanjesi&quot;, sele abe ngumengameli iminyaka ema-38.  Ngo-2005, indodanakhe u-Faure Gnassingbé wakhethwa njengomengameli.&lt;ref&gt;https://scholar.google.com/scholar?hl=en&amp;as_sdt=0%2C5&amp;q=togo&amp;btnG=#:~:text=Togo%3A%20recent%20political%20and%20economic%20development&lt;/ref&gt;

I-Togo yinarha etjhisako, engezansi ye-Sahara umnotho wayo othembele khulu kwezokulima.[2] Ilimi elisemthethweni lisiFulentshi,[2] kodwana kukhulunywa amanye amalimi, khulukhulu lawo womndeni wama-Gbe. I-47.8% yabantu inamathela ebuKrestu, okwenza bona ibe yikolo ekulu khulu enarheni.[3] I-Togo lilunga le-United Nations, i-African Union, i-Organization of Islamic Cooperation, i-South Atlantic Peace and Cooperation Zone, i-Francophonie, i-Commonwealth of Nations, kanye ne-Economic Community of West African States.&lt;ref&gt;https://scholar.google.com/scholar?hl=en&amp;as_sdt=0%2C5&amp;q=togo&amp;btnG=#:~:text=Rumour%20and%20power%20in%20Togo&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>1ygcconx4zm4f7hov3m8qzxf0hw36w1</sha1>
    </revision>
    <revision>
      <id>6466</id>
      <parentid>6465</parentid>
      <timestamp>2026-04-15T21:38:22Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6466</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2672" sha1="tlii49sr1wi0rimtx5k6rvfu362go0x" xml:space="preserve">
'''I-Togo''', ngokusemthethweni '''iRiphabhliki ye-Togo''', lilizwe eliseTjingalanga ye-Afrika . Inomngcele we -[[IGhana|Ghana]] ngeTjingalanga, [[i-Benin]] ngepumalanga kanye [[Burkina Faso|ne-Burkina Faso]] ngetlhagwini .  Ngelinye lamazwe angakathuthuki khulu ephasini. Iya enyakatho ukusuka e- Gulf of Guinea (lapho inhlokodolobha yayo, i-Lomé, itholakala khona) ukuya emngceleni we-Burkina Faso-Togo. Lilizwe elincani, elitjhisako, elinamakhilomitha 57,000 square kilometres (22,000 square miles)  elinabantu abangaba ziingidi ezi-8,  begodu linobubanzi obungaphasi kwe- 115 km (71 mi) hlangana ne-Ghana nomakhelwana wayo wepumalanga i-Benin.&lt;ref&gt;https://books.google.com/books?hl=en&amp;lr=&amp;id=LfVkp1wQz5kC&amp;oi=fnd&amp;pg=PA5&amp;dq=togo&amp;ots=n3Th7QAYPb&amp;sig=1YwO-W_nvc6JiVL437bxVDTm3pY&lt;/ref&gt;  

Abantu abahlukahlukeneko bahlala emingceleni ye-Togo yanje hlangana nekhulu le-11 nele-16. Hlangana nekhulu leminyaka le-16 nele-18, indawo eseduze nelwandle gade isebenza njengendawo yokurhweba ngeengqila ze-Europe, okwenza bona i-Togo nendawo eseduze kwayo ibizo elithi &quot;The Slave Coast &quot;. Ngo-1884, ngesikhathi sokulwela i-Afrika, i-Germany yasungula indawo evikelweko esifundeni esibizwa nge -Togoland . Ngemva kwePi yePhasi yoku-1, i-Togo yadluliselwa e- France nemingcele yayo yesikhatheso. I-Togo yathola ikululeko e-France ngo-1960.   Ngo-1967, u-Gnassingbé Eyadéma warhola ukuvukela umbuso kwezempi begodu waba ngumengameli wombuso ophikisana namakhomanisi, onehlangano eyodwa. Ngo-1993, u-Eyadéma waqalana namakhetho weenhlangano ezinengi ebegade ahlanjululwe kukungalungi, begodu wanqoba ubumongameli kathathu. Ngesikhathi sokuhlongakala kwakhe, u-Eyadéma &quot;bekangumdosiphambili osebenze isikhathi eside khulu emlandwini [[I-Afrika|we-Afrika]] wanamhlanjesi&quot;, sele abe ngumengameli iminyaka ema-38.  Ngo-2005, indodanakhe u-Faure Gnassingbé wakhethwa njengomengameli.&lt;ref&gt;https://scholar.google.com/scholar?hl=en&amp;as_sdt=0%2C5&amp;q=togo&amp;btnG=#:~:text=Togo%3A%20recent%20political%20and%20economic%20development&lt;/ref&gt;

I-Togo yinarha etjhisako, engezansi ye-Sahara umnotho wayo othembele khulu kwezokulima.[2] Ilimi elisemthethweni lisiFulentshi,[2] kodwana kukhulunywa amanye amalimi, khulukhulu lawo womndeni wama-Gbe. I-47.8% yabantu inamathela ebuKrestu, okwenza bona ibe yikolo ekulu khulu enarheni.[3] I-Togo lilunga le-United Nations, i-African Union, i-Organization of Islamic Cooperation, i-South Atlantic Peace and Cooperation Zone, i-Francophonie, i-Commonwealth of Nations, kanye ne-Economic Community of West African States.&lt;ref&gt;https://scholar.google.com/scholar?hl=en&amp;as_sdt=0%2C5&amp;q=togo&amp;btnG=#:~:text=Rumour%20and%20power%20in%20Togo&lt;/ref&gt;

== Iinkomba ==</text>
      <sha1>tlii49sr1wi0rimtx5k6rvfu362go0x</sha1>
    </revision>
    <revision>
      <id>6467</id>
      <parentid>6466</parentid>
      <timestamp>2026-04-15T21:38:41Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6467</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2684" sha1="trbequ6t0kt35ni9o2yyy2t6nmi5opv" xml:space="preserve">
'''I-Togo''', ngokusemthethweni '''iRiphabhliki ye-Togo''', lilizwe eliseTjingalanga ye-Afrika . Inomngcele we -[[IGhana|Ghana]] ngeTjingalanga, [[i-Benin]] ngepumalanga kanye [[Burkina Faso|ne-Burkina Faso]] ngetlhagwini .  Ngelinye lamazwe angakathuthuki khulu ephasini. Iya enyakatho ukusuka e- Gulf of Guinea (lapho inhlokodolobha yayo, i-Lomé, itholakala khona) ukuya emngceleni we-Burkina Faso-Togo. Lilizwe elincani, elitjhisako, elinamakhilomitha 57,000 square kilometres (22,000 square miles)  elinabantu abangaba ziingidi ezi-8,  begodu linobubanzi obungaphasi kwe- 115 km (71 mi) hlangana ne-Ghana nomakhelwana wayo wepumalanga i-Benin.&lt;ref&gt;https://books.google.com/books?hl=en&amp;lr=&amp;id=LfVkp1wQz5kC&amp;oi=fnd&amp;pg=PA5&amp;dq=togo&amp;ots=n3Th7QAYPb&amp;sig=1YwO-W_nvc6JiVL437bxVDTm3pY&lt;/ref&gt;  

Abantu abahlukahlukeneko bahlala emingceleni ye-Togo yanje hlangana nekhulu le-11 nele-16. Hlangana nekhulu leminyaka le-16 nele-18, indawo eseduze nelwandle gade isebenza njengendawo yokurhweba ngeengqila ze-Europe, okwenza bona i-Togo nendawo eseduze kwayo ibizo elithi &quot;The Slave Coast &quot;. Ngo-1884, ngesikhathi sokulwela i-Afrika, i-Germany yasungula indawo evikelweko esifundeni esibizwa nge -Togoland . Ngemva kwePi yePhasi yoku-1, i-Togo yadluliselwa e- France nemingcele yayo yesikhatheso. I-Togo yathola ikululeko e-France ngo-1960.   Ngo-1967, u-Gnassingbé Eyadéma warhola ukuvukela umbuso kwezempi begodu waba ngumengameli wombuso ophikisana namakhomanisi, onehlangano eyodwa. Ngo-1993, u-Eyadéma waqalana namakhetho weenhlangano ezinengi ebegade ahlanjululwe kukungalungi, begodu wanqoba ubumongameli kathathu. Ngesikhathi sokuhlongakala kwakhe, u-Eyadéma &quot;bekangumdosiphambili osebenze isikhathi eside khulu emlandwini [[I-Afrika|we-Afrika]] wanamhlanjesi&quot;, sele abe ngumengameli iminyaka ema-38.  Ngo-2005, indodanakhe u-Faure Gnassingbé wakhethwa njengomengameli.&lt;ref&gt;https://scholar.google.com/scholar?hl=en&amp;as_sdt=0%2C5&amp;q=togo&amp;btnG=#:~:text=Togo%3A%20recent%20political%20and%20economic%20development&lt;/ref&gt;

I-Togo yinarha etjhisako, engezansi ye-Sahara umnotho wayo othembele khulu kwezokulima.[2] Ilimi elisemthethweni lisiFulentshi,[2] kodwana kukhulunywa amanye amalimi, khulukhulu lawo womndeni wama-Gbe. I-47.8% yabantu inamathela ebuKrestu, okwenza bona ibe yikolo ekulu khulu enarheni.[3] I-Togo lilunga le-United Nations, i-African Union, i-Organization of Islamic Cooperation, i-South Atlantic Peace and Cooperation Zone, i-Francophonie, i-Commonwealth of Nations, kanye ne-Economic Community of West African States.&lt;ref&gt;https://scholar.google.com/scholar?hl=en&amp;as_sdt=0%2C5&amp;q=togo&amp;btnG=#:~:text=Rumour%20and%20power%20in%20Togo&lt;/ref&gt;

== Iinkomba ==
{{reflist}}</text>
      <sha1>trbequ6t0kt35ni9o2yyy2t6nmi5opv</sha1>
    </revision>
    <revision>
      <id>6468</id>
      <parentid>6467</parentid>
      <timestamp>2026-04-15T21:39:22Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6468</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2703" sha1="7nchyo6q3e53iu71j5goi8hnpy7tyzo" xml:space="preserve">
'''I-Togo''', ngokusemthethweni '''iRiphabhliki ye-Togo''', lilizwe eliseTjingalanga ye-Afrika . Inomngcele we -[[IGhana|Ghana]] ngeTjingalanga, [[i-Benin]] ngepumalanga kanye [[Burkina Faso|ne-Burkina Faso]] ngetlhagwini .  Ngelinye lamazwe angakathuthuki khulu ephasini. Iya enyakatho ukusuka e- Gulf of Guinea (lapho inhlokodolobha yayo, i-Lomé, itholakala khona) ukuya emngceleni we-Burkina Faso-Togo. Lilizwe elincani, elitjhisako, elinamakhilomitha 57,000 square kilometres (22,000 square miles)  elinabantu abangaba ziingidi ezi-8,  begodu linobubanzi obungaphasi kwe- 115 km (71 mi) hlangana ne-Ghana nomakhelwana wayo wepumalanga i-Benin.&lt;ref&gt;https://books.google.com/books?hl=en&amp;lr=&amp;id=LfVkp1wQz5kC&amp;oi=fnd&amp;pg=PA5&amp;dq=togo&amp;ots=n3Th7QAYPb&amp;sig=1YwO-W_nvc6JiVL437bxVDTm3pY&lt;/ref&gt;  

Abantu abahlukahlukeneko bahlala emingceleni ye-Togo yanje hlangana nekhulu le-11 nele-16. Hlangana nekhulu leminyaka le-16 nele-18, indawo eseduze nelwandle gade isebenza njengendawo yokurhweba ngeengqila ze-Europe, okwenza bona i-Togo nendawo eseduze kwayo ibizo elithi &quot;The Slave Coast &quot;. Ngo-1884, ngesikhathi sokulwela i-Afrika, i-Germany yasungula indawo evikelweko esifundeni esibizwa nge -Togoland . Ngemva kwePi yePhasi yoku-1, i-Togo yadluliselwa e- France nemingcele yayo yesikhatheso. I-Togo yathola ikululeko e-France ngo-1960.   Ngo-1967, u-Gnassingbé Eyadéma warhola ukuvukela umbuso kwezempi begodu waba ngumengameli wombuso ophikisana namakhomanisi, onehlangano eyodwa. Ngo-1993, u-Eyadéma waqalana namakhetho weenhlangano ezinengi ebegade ahlanjululwe kukungalungi, begodu wanqoba ubumongameli kathathu. Ngesikhathi sokuhlongakala kwakhe, u-Eyadéma &quot;bekangumdosiphambili osebenze isikhathi eside khulu emlandwini [[I-Afrika|we-Afrika]] wanamhlanjesi&quot;, sele abe ngumengameli iminyaka ema-38.  Ngo-2005, indodanakhe u-Faure Gnassingbé wakhethwa njengomengameli.&lt;ref&gt;https://scholar.google.com/scholar?hl=en&amp;as_sdt=0%2C5&amp;q=togo&amp;btnG=#:~:text=Togo%3A%20recent%20political%20and%20economic%20development&lt;/ref&gt;

I-Togo yinarha etjhisako, engezansi ye-Sahara umnotho wayo othembele khulu kwezokulima.[2] Ilimi elisemthethweni lisiFulentshi,[2] kodwana kukhulunywa amanye amalimi, khulukhulu lawo womndeni wama-Gbe. I-47.8% yabantu inamathela ebuKrestu, okwenza bona ibe yikolo ekulu khulu enarheni.[3] I-Togo lilunga le-United Nations, i-African Union, i-Organization of Islamic Cooperation, i-South Atlantic Peace and Cooperation Zone, i-Francophonie, i-Commonwealth of Nations, kanye ne-Economic Community of West African States.&lt;ref&gt;https://scholar.google.com/scholar?hl=en&amp;as_sdt=0%2C5&amp;q=togo&amp;btnG=#:~:text=Rumour%20and%20power%20in%20Togo&lt;/ref&gt;

== Iinkomba ==
{{reflist}}
[[Mkhakha:Afrika]]</text>
      <sha1>7nchyo6q3e53iu71j5goi8hnpy7tyzo</sha1>
    </revision>
  </page>
  <page>
    <title>Parkwood, e-Goli</title>
    <ns>0</ns>
    <id>1098</id>
    <revision>
      <id>6473</id>
      <timestamp>2026-04-18T10:11:57Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1242547706|Parkwood, Johannesburg]]&quot;</comment>
      <origin>6473</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2568" sha1="9q34cdv734bupfr353nh6b9s4ivxgir" xml:space="preserve">
{{Infobox settlement|name=Parkwood|pushpin_map=South Africa Gauteng#South Africa#Africa|coordinates={{coord|26|09|S|28|01|E|region:ZA|display=inline,title}}|subdivision_type=[[Country]]|subdivision_name=[[South Africa]]|subdivision_type1=[[Provinces of South Africa|Province]]|subdivision_name1=[[Gauteng]]|subdivision_type2=District|subdivision_type3=[[List of municipalities of South Africa|Municipality]]|subdivision_name3=[[City of Johannesburg Metropolitan Municipality|City of Johannesburg]]|subdivision_type4=Main Place|subdivision_name4=[[Johannesburg]]|established_title=Established|leader_title=Councillor|area_footnotes=&lt;ref name=&quot;census2011&quot;&gt;{{cite web |url=https://census2011.adrianfrith.com/place/798016064 |title = Sub Place Parkwood |work=Census 2011}}&lt;/ref&gt;|area_total_km2=1.31|population_footnotes=&lt;ref name=&quot;census2011&quot; /&gt;|population_total=2561|population_as_of=2011|population_density_km2=auto
&lt;!-- demographics (section 1) --&gt;|demographics_type1=Racial makeup (2011)|demographics1_footnotes=&lt;ref name=&quot;census2011&quot; /&gt;|demographics1_title1=[[White South African|White]]|demographics1_info1=61.8%|demographics1_title2=[[Bantu peoples of South Africa|Black African]]|demographics1_info2=29.1%|demographics1_title3=[[Indian South African|Indian]]/[[Asian South African|Asian]]|demographics1_info3=5.51%|demographics1_title4=[[Coloureds|Coloured]]|demographics1_info4=2.38%|demographics1_title5=Other|demographics1_info5=1.21%
&lt;!-- demographics (section 2) --&gt;|demographics_type2=[[First language]]s (2011)|demographics2_footnotes=&lt;ref name=&quot;census2011&quot; /&gt;|demographics2_title1=[[English language|English]]|demographics2_info1=66.91%|demographics2_title2=[[Afrikaans]]|demographics2_info2=8.44%|demographics2_title3=[[Zulu language|Zulu]]|demographics2_info3=6.6%|demographics2_title4=[[Northern Sotho language|Sepedi]]|demographics2_info4=3.32%|demographics2_title5=Other|demographics2_info5=14.73%
&lt;!-- blank fields (section 2) --&gt;
&lt;!-- Other information --&gt;|timezone1=[[South African Standard Time|SAST]]|utc_offset1=+2|postal_code_type=[[List of postal codes in South Africa|Postal code]] (street)|postal_code=2193|postal2_code_type=[[Post-office box|PO box]]|postal2_code=|area_code_type=[[Telephone numbers in South Africa|Area code]]}}'''I-Parkwood''' yindawo yokuhlala ye-Johannesburg, etholakala e-Region E ye-City of [[Johannesburg]] Metropolitan Municipality, esifundazweni se-[[Gauteng]]. Yenza ingcenye yesiqhema samadorobha aziwa nge-“The Parks,” afakahlangana iindawo eziseduze ezifana ne-Parkview, Parkhurst kanye ne-Parktown North.</text>
      <sha1>9q34cdv734bupfr353nh6b9s4ivxgir</sha1>
    </revision>
    <revision>
      <id>6474</id>
      <parentid>6473</parentid>
      <timestamp>2026-04-18T10:13:48Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1242547706|Parkwood, Johannesburg]]&quot;</comment>
      <origin>6474</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3093" sha1="dabg0m4rbsbsy7c4qsb94yymds0fd1c" xml:space="preserve">
{{Infobox settlement|name=Parkwood|pushpin_map=South Africa Gauteng#South Africa#Africa|coordinates={{coord|26|09|S|28|01|E|region:ZA|display=inline,title}}|subdivision_type=[[Country]]|subdivision_name=[[South Africa]]|subdivision_type1=[[Provinces of South Africa|Province]]|subdivision_name1=[[Gauteng]]|subdivision_type2=District|subdivision_type3=[[List of municipalities of South Africa|Municipality]]|subdivision_name3=[[City of Johannesburg Metropolitan Municipality|City of Johannesburg]]|subdivision_type4=Main Place|subdivision_name4=[[Johannesburg]]|established_title=Established|leader_title=Councillor|area_footnotes=&lt;ref name=&quot;census2011&quot;&gt;{{cite web |url=https://census2011.adrianfrith.com/place/798016064 |title = Sub Place Parkwood |work=Census 2011}}&lt;/ref&gt;|area_total_km2=1.31|population_footnotes=&lt;ref name=&quot;census2011&quot; /&gt;|population_total=2561|population_as_of=2011|population_density_km2=auto
&lt;!-- demographics (section 1) --&gt;|demographics_type1=Racial makeup (2011)|demographics1_footnotes=&lt;ref name=&quot;census2011&quot; /&gt;|demographics1_title1=[[White South African|White]]|demographics1_info1=61.8%|demographics1_title2=[[Bantu peoples of South Africa|Black African]]|demographics1_info2=29.1%|demographics1_title3=[[Indian South African|Indian]]/[[Asian South African|Asian]]|demographics1_info3=5.51%|demographics1_title4=[[Coloureds|Coloured]]|demographics1_info4=2.38%|demographics1_title5=Other|demographics1_info5=1.21%
&lt;!-- demographics (section 2) --&gt;|demographics_type2=[[First language]]s (2011)|demographics2_footnotes=&lt;ref name=&quot;census2011&quot; /&gt;|demographics2_title1=[[English language|English]]|demographics2_info1=66.91%|demographics2_title2=[[Afrikaans]]|demographics2_info2=8.44%|demographics2_title3=[[Zulu language|Zulu]]|demographics2_info3=6.6%|demographics2_title4=[[Northern Sotho language|Sepedi]]|demographics2_info4=3.32%|demographics2_title5=Other|demographics2_info5=14.73%
&lt;!-- blank fields (section 2) --&gt;
&lt;!-- Other information --&gt;|timezone1=[[South African Standard Time|SAST]]|utc_offset1=+2|postal_code_type=[[List of postal codes in South Africa|Postal code]] (street)|postal_code=2193|postal2_code_type=[[Post-office box|PO box]]|postal2_code=|area_code_type=[[Telephone numbers in South Africa|Area code]]}}'''I-Parkwood''' yindawo yokuhlala ye-Johannesburg, etholakala e-Region E ye-City of [[Johannesburg]] Metropolitan Municipality, esifundazweni se-[[Gauteng]]. Yenza ingcenye yesiqhema samadorobha aziwa nge-“The Parks,” afakahlangana iindawo eziseduze ezifana ne-Parkview, Parkhurst kanye ne-Parktown North. 

== Indawo nendawo ==
I-Parkwood itholakala engcenyeni esetlhagwini ye-Johannesburg, hlangana namadorobha we-Rosebank ne-Saxonwold, begodu iseduze ne-Parkview ne-Parktown North.

Iseduze neendlela ezinkulu zokuthutha ezifana ne-Jan Smuts Avenue ne-Oxford Road, enikela ukufikelela eendaweni eziqakathekileko zezokuthengisa nezokuhlala ezifaka hlangana i-Sandton kanye ne-Johannesburg central business district.

== Iinkomba ==
&lt;references /&gt;
{{Greater Johannesburg|communities}}
[[Mkhakha:Afrika]]
[[Mkhakha:Sewula Afrika]]</text>
      <sha1>dabg0m4rbsbsy7c4qsb94yymds0fd1c</sha1>
    </revision>
    <revision>
      <id>6475</id>
      <parentid>6474</parentid>
      <timestamp>2026-04-18T10:14:16Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6475</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="836" sha1="2gb2hyz6oywzqsaxse5r4zabfomb0dk" xml:space="preserve">
'''I-Parkwood''' yindawo yokuhlala ye-Johannesburg, etholakala e-Region E ye-City of [[Johannesburg]] Metropolitan Municipality, esifundazweni se-[[Gauteng]]. Yenza ingcenye yesiqhema samadorobha aziwa nge-“The Parks,” afakahlangana iindawo eziseduze ezifana ne-Parkview, Parkhurst kanye ne-Parktown North. 

== Indawo nendawo ==
I-Parkwood itholakala engcenyeni esetlhagwini ye-Johannesburg, hlangana namadorobha we-Rosebank ne-Saxonwold, begodu iseduze ne-Parkview ne-Parktown North.

Iseduze neendlela ezinkulu zokuthutha ezifana ne-Jan Smuts Avenue ne-Oxford Road, enikela ukufikelela eendaweni eziqakathekileko zezokuthengisa nezokuhlala ezifaka hlangana i-Sandton kanye ne-Johannesburg central business district.

== Iinkomba ==
&lt;references /&gt;
{{Greater Johannesburg|communities}}
[[Mkhakha:Afrika]]
[[Mkhakha:Sewula Afrika]]</text>
      <sha1>2gb2hyz6oywzqsaxse5r4zabfomb0dk</sha1>
    </revision>
    <revision>
      <id>6476</id>
      <parentid>6475</parentid>
      <timestamp>2026-04-18T10:14:29Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6476</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="799" sha1="1onfv4g9ffa1efv5lwjj0keqyccf9t2" xml:space="preserve">
'''I-Parkwood''' yindawo yokuhlala ye-Johannesburg, etholakala e-Region E ye-City of [[Johannesburg]] Metropolitan Municipality, esifundazweni se-[[Gauteng]]. Yenza ingcenye yesiqhema samadorobha aziwa nge-“The Parks,” afakahlangana iindawo eziseduze ezifana ne-Parkview, Parkhurst kanye ne-Parktown North. 

== Indawo nendawo ==
I-Parkwood itholakala engcenyeni esetlhagwini ye-Johannesburg, hlangana namadorobha we-Rosebank ne-Saxonwold, begodu iseduze ne-Parkview ne-Parktown North.

Iseduze neendlela ezinkulu zokuthutha ezifana ne-Jan Smuts Avenue ne-Oxford Road, enikela ukufikelela eendaweni eziqakathekileko zezokuthengisa nezokuhlala ezifaka hlangana i-Sandton kanye ne-Johannesburg central business district.

== Iinkomba ==
&lt;references /&gt;
[[Mkhakha:Afrika]]
[[Mkhakha:Sewula Afrika]]</text>
      <sha1>1onfv4g9ffa1efv5lwjj0keqyccf9t2</sha1>
    </revision>
  </page>
  <page>
    <title>Irhelo lababulali abanengi eSewula Afrika</title>
    <ns>0</ns>
    <id>1099</id>
    <revision>
      <id>6477</id>
      <timestamp>2026-04-19T16:33:30Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1349949468|List of serial killers in South Africa]]&quot;</comment>
      <origin>6477</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9744" sha1="j91y1tf25n3kefdd3g1r246mexmiwyj" xml:space="preserve"> Lolu luhlu lwababulali abanengi beSewula Afrika eSewula Afrika. 

Umbulali we-serial kuvamise ukuba mumuntu obulala abantu abathathu nofana ngaphezulu, begodu ukubulawa kwenzeka isikhathi esingaphezu kwenyanga begodu kufaka hlangana isikhathi eside hlangana nabo.  [ 2 ] Nanyana kunjalo, iSewula Afrika isebenzisa ihlathululo elula yokubulala abantu abanengi, iyihlathulula ngokuthi, &quot;Ukubulawa kwabantu ababili nofana ngaphezulu ngokungasimthethweni mphulaphuli munye, ezehlakalweni ezihlukileko.&quot; 

== Ababulali abanengi abakhonjiweko ==
{| class=&quot;wikitable sortable&quot;
! width=&quot;200px&quot; |Name
!Nickname / AKA
! width=&quot;100px&quot; |Years active
! data-sort-type=&quot;number&quot; |Proven victims
! data-sort-type=&quot;number&quot; |Possible victims
!Status
!Notes
!Ref
|-
|Richman Makhwenkwe
|Moffat Park Killer
|2005 - 2006
|6
|7
|Sentenced to life imprisonment
|He raped and strangled his girlfriend then buried her body in a shallow grave in an overgrown park in [[Johannesburg]], then went on to kill other victims.
|
|-
|Baninzi, Asande
|
|2001
|14
|18
|Sentenced to life imprisonment
|Together with accomplice Mthutuzeli Nombewu, robbed and murdered people in the Cape Flats area
|
|-
|Barber, Peter Roy
|The Laughing Killer
|1973–1979
|3
|4
|Executed in 1980
|English immigrant who murdered his mistresses and a 12-year-old girl in Pinetown after arguments
|
|-
|Basson, Pierre
|The Insurance Killer
|1903–1906
|9
|9+
|Committed suicide to avoid apprehension
|Murdered people in Claremont, Cape Town so he could get their life insurance; South Africa's first recorded serial killer
|
|-
|Brown, John Frank
|The Cross Dressing Killer(s)
|1993–1995
|5
|5
|Sentenced to life imprisonment
|Together with accomplice and lover Jacques Coetzee murdered other gay men around [[Johannesburg]]
|
|-
|Brandt, Brydon
|
|1989–1997
|4
|5
|Sentenced to life imprisonment
|Murdered prostitutes and his roommates in the Eastern Cape
|
|-
|Burger, Cornelius
|
|1936–1937
|5
|5
|Died in a psychiatric facility
|Murdered prostitutes as revenge for contracting a venereal disease
|
|-
|Coetzee, Jacques
|The Cross Dressing Killer(s)
|1993–1995
|5
|5
|Committed suicide in custody
|Together with accomplice and lover John Frank Brown murdered other gay men around [[Johannesburg]]
|
|-
|Duma, Sibusiso
|
|2007
|7
|7
|Sentenced to life imprisonment
|Killed various people around Pietermaritzburg during robberies
|
|-
|Kgabi, John Phuko
|The Ritual Killer
|1974–1978
|6
|14
|Executed in 1980
|Former police officer who garroted and mutilated young girls in Atteridgeville and [[Limpopo]]
|
|-
|Lineveldt, Gamal
|The Cape Flats Murderer
|1940
|4
|4
|Executed in 1941
|Responsible for the &quot;Cape Flats Murders&quot;; bludgeoned to death white women around the Cape Flats area
|
|-
|Maake, Cedric
|The Wemmer Pan Killer
|1996–1997
|27
|27+
|Sentenced to life imprisonment
|Serial rapist who murdered victims in the Wemmer Pan area
|
|-
|Mabhayi, Bulelani
|The Monster of Tholeni
|2007–2012
|20
|20
|Sentenced to life imprisonment
|House intruder who murdered women and children in the village of Tholeni
|
|-
|Majola, Simon
|The Bruma Lake Killer(s)
|2000–2001
|8
|8+
|Sentenced to life imprisonment
|Together with accomplice Themba Nkosi, known as &quot;The Bruma Lake Killers&quot;; robbed and drowned men in Bruma Lake
|
|-
|Makamu, Fanuel
|The Mpumalanga Serial Rapist
|2000
|6
|6
|Sentenced to life imprisonment
|Together with accomplice Henry Maile, robbed, raped and murdered women around [[Isifunda seMpumalanga|Mpumalanga]]
|
|-
|Maketta, Jimmy
|The Jesus Killer
|2005
|16
|16
|Sentenced to life imprisonment
|Murdered farm labourers in Philippi
|
|-
|Makgae, Andries
|
|2012–2013
|3
|4+
|Sentenced to life imprisonment
|Raped and murdered women around Onderstepoort; suspected in best friend's murder
|
|-
|Makhubela, Dumisani
|Lotto Gangster(s)
|2005
|7
|7
|Sentenced to life imprisonment
|Together with accomplice Johannes van Rooyen, robbed, raped and murdered people around Mpumalanga, including a family of four
|
|-
|Mashiane, Johannes
|The Beast of Atteridgeville
|1977–1989
|13
|13
|Committed suicide to avoid apprehension
|Murdered his girlfriend; after release, raped and strangled 12 young boys around Atteridgeville
|
|-
|de Melker, Daisy
|
|1923–1932
|3
|3
|Executed in 1932
|Poisoned two husbands and her son with strychnine for life insurance; South Africa's first convicted female serial killer
|
|-
|Mfeka, Samuel Bongani
|The Kranskop Killer
|1993–1996
|6
|6+
|Sentenced to life imprisonment
|Raped and strangled women around KwaZulu-Natal
|
|-
|Mogale, Jack
|The West-End Killer
|2008–2009
|16
|16
|Sentenced to life imprisonment
|Kidnapped, raped and murdered women in southern Johannesburg
|
|-
|Msomi, Elifasi
|The Axe Killer
|1953–1955
|15
|15
|Executed in 1956
|Murdered people while he was supposedly under the influence of a Tokoloshe
|
|-
|Mulaudzi, Mukosi Freddy
|The Limpopo Serial Killer
|1990–2006
|13
|13
|Sentenced to life imprisonment
|Murdered two people in 1990, then escaped from prison and resumed killing
|
|-
|Ncama, Nicholas Lungisa
|The East Cape Killer
|1997
|6
|6
|Sentenced to life imprisonment
|Raped and strangled women around Port Elizabeth
|
|-
|Ndlangamandla, Velaphi
|The Saloon Killer
|1998
|19
|19
|Sentenced to life imprisonment
|Robbed and murdered people during home invasions in Mpumalanga
|
|-
|Ndlovu, Rosemary
|
|2012–2018
|6
|6
|Sentenced to life imprisonment
|Former policewoman who murdered her ex-partner and relatives for life and funeral insurance policies
|
|-
|Ntsieni, Ndivhuwo
|The Univen serial killer
|2014
|5
|5
|Sentenced to life imprisonment
|Raped and murdered women and young girls in and around the University of Venda
|
|-
|Nyauza, Richard
|The Quarry Killer
|2002–2006
|18
|19
|Sentenced to life imprisonment
|Raped and murdered women after being infected with HIV, dumping their bodies in a quarry
|
|-
|Randitsheni, David
|The Modimolle Serial Killer
|2004–2008
|10
|10
|Committed suicide in prison
|Abducted, raped and murdered children in [[Modimolle]]
|
|-
|van Rooyen, Gert
|
|1988–1989
|6
|6+
|Committed suicide to avoid apprehension
|Pedophile who, together with accomplice and wife Joey Haarhoff, abducted, raped and murdered six teenage girls whose bodies have never been found
|
|-
|van Rooyen, Johannes
|Lotto Gangster(s)
|2005
|7
|7
|Sentenced to life imprisonment
|Together with accomplice Dumisani Makhubela, robbed, raped and murdered people around Mpumalanga, including a family of four
|
|-
|van Schoor, Louis
|The Apartheid Killer
|1986–1989
|9
|39+
|20 years; released in the 2003 and died a free man in 2024
|Former policeman and security guard who killed black South Africans during alleged crimes
|
|-
|Sedumedi, Khangayi
|The Century City Killer
|2011–2015
|4
|6
|Sentenced to life imprisonment
|Raped and murdered women around Century City and Kensington
|
|-
|Sidyno, Samuel
|The Capital Park Serial Killer
|1998–1999
|7
|7
|Sentenced to life imprisonment
|Strangled teenagers and women, then disposed of their bodies near the Pretoria Zoo
|
|-
|Sithole, Moses
|The ABC Killer
|1994–1995
|38
|76
|Sentenced to life imprisonment
|Raped and murdered women around Atteridgeville, [[IBoksburg|Boksburg]] and Cleveland
|
|-
|Stander, Riaan
|
|2001–2007
|3
|3
|Sentenced to life imprisonment
|Murdered two prostitutes in Port Elizabeth after being released from prison for running over a woman with his car
|
|-
|Sukude, Themba
|The Newcastle Serial Killer
|2004–2005
|4
|4
|Sentenced to life imprisonment
|Attacked couples around parks, raping the female and bludgeoning the male to death with rocks. He later switched to solely targeting men
|
|-
|Taki, Thozamile
|The Sugarcane Killer
|2007
|13
|13
|Sentenced to life imprisonment
|Robbed and murdered women around KwaZulu-Natal and Eastern Cape, dumping their bodies in sugarcane and tea plantations
|
|-
|Thwala, Sipho
|The Phoenix Strangler
|1996–1997
|16
|16+
|Sentenced to life imprisonment
|Raped and murdered women in sugarcane fields near Phoenix
|
|-
|Vilakazi, Themba
|The Railway Killer
|2005
|3
|5
|Sentenced to life imprisonment
|Murdered black males around Pretoria
|
|-
|Wilken, Stewart
|The Boetie Boer
|1990–1997
|10
|10+
|Sentenced to life imprisonment
|Raped and murdered prostitutes, young boys and his own daughter around Port Elizabeth
|
|-
|Williams, Tommy
|The City Serial Killer
|1987–2008
|3
|3
|Sentenced to life imprisonment
|Strangled three acquaintances in varying circumstances; South Africa's longest active serial offender
|
|-
|Xitavhudzi, Elias
|The Pangaman
|1953–1959
|16
|16
|Executed in 1960
|Murdered and mutilated white women around Atteridgeville
|
|-
|Zikode, Christopher Mhlengwa
|The Donnybrook Serial Killer
|1994–1995
|18
|18
|Sentenced to life imprisonment
|Necrophiliac house intruder who murdered people around Donnybrook, then had sex with the female victims' corpses
|
|}

== Ababulali abanengi abangaziwako ==
{| class=&quot;wikitable sortable&quot;
! width=&quot;200px&quot; |Isiteketiso
! width=&quot;100px&quot; | Iminyaka yokusebenza
! data-sort-type=&quot;number&quot; | Iinhlupheki eziqinisekisiweko
! data-sort-type=&quot;number&quot; | Abangaba ziinhlupheki
! Iindawo lapho zisebenza khona
! Amanothi
! Ref
|-
| Umbulali wezifebe we-Cape Town
| 1992–1996
| 19
| 19
| I-Western Cape
| Iinfebe eziklinyiweko nezisebenzi zasekhaya e -Cape Town
| 
|-
| Umbulali we-Fosaville
| 1999–2003
| 13
| 13
| KwaZulu-Natal
| Abafazi abathunjiweko, babotjhwa begodu baklinywa e- Newlands East
| 
|-
| Umbulali we-Sleepy Hollow
| 1990s–2007
| 13
| 16+
| Kwa-Zulu Natal (kuqinisekisiwe)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; I-Free State, e-Eastern Cape (kusolwa)
| Abafazi abadlwengulwako nabaklinyako, inengi labo abathengisa ucansi nabathengisa umzimba, basebenzisa amaphenti wabo
| 
|}</text>
      <sha1>j91y1tf25n3kefdd3g1r246mexmiwyj</sha1>
    </revision>
    <revision>
      <id>6478</id>
      <parentid>6477</parentid>
      <timestamp>2026-04-19T16:34:15Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6478</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9772" sha1="3xzvya7c3xfi4gqv4h9jvur676hgyze" xml:space="preserve"> Lolu luhlu lwababulali abanengi beSewula Afrika eSewula Afrika. 

Umbulali we-serial kuvamise ukuba mumuntu obulala abantu abathathu nofana ngaphezulu, begodu ukubulawa kwenzeka isikhathi esingaphezu kwenyanga begodu kufaka hlangana isikhathi eside hlangana nabo.  [ 2 ] Nanyana kunjalo, iSewula Afrika isebenzisa ihlathululo elula yokubulala abantu abanengi, iyihlathulula ngokuthi, &quot;Ukubulawa kwabantu ababili nofana ngaphezulu ngokungasimthethweni mphulaphuli munye, ezehlakalweni ezihlukileko.&quot; 

== Ababulali abanengi abakhonjiweko ==
{| class=&quot;wikitable sortable&quot;
! width=&quot;200px&quot; |Name
!Nickname / AKA
! width=&quot;100px&quot; |Years active
! data-sort-type=&quot;number&quot; |Proven victims
! data-sort-type=&quot;number&quot; |Possible victims
!Status
!Notes
!Ref
|-
|Richman Makhwenkwe
|Moffat Park Killer
|2005 - 2006
|6
|7
|Sentenced to life imprisonment
|He raped and strangled his girlfriend then buried her body in a shallow grave in an overgrown park in [[Johannesburg]], then went on to kill other victims.
|
|-
|Baninzi, Asande
|
|2001
|14
|18
|Sentenced to life imprisonment
|Together with accomplice Mthutuzeli Nombewu, robbed and murdered people in the Cape Flats area
|
|-
|Barber, Peter Roy
|The Laughing Killer
|1973–1979
|3
|4
|Executed in 1980
|English immigrant who murdered his mistresses and a 12-year-old girl in Pinetown after arguments
|
|-
|Basson, Pierre
|The Insurance Killer
|1903–1906
|9
|9+
|Committed suicide to avoid apprehension
|Murdered people in Claremont, Cape Town so he could get their life insurance; South Africa's first recorded serial killer
|
|-
|Brown, John Frank
|The Cross Dressing Killer(s)
|1993–1995
|5
|5
|Sentenced to life imprisonment
|Together with accomplice and lover Jacques Coetzee murdered other gay men around [[Johannesburg]]
|
|-
|Brandt, Brydon
|
|1989–1997
|4
|5
|Sentenced to life imprisonment
|Murdered prostitutes and his roommates in the Eastern Cape
|
|-
|Burger, Cornelius
|
|1936–1937
|5
|5
|Died in a psychiatric facility
|Murdered prostitutes as revenge for contracting a venereal disease
|
|-
|Coetzee, Jacques
|The Cross Dressing Killer(s)
|1993–1995
|5
|5
|Committed suicide in custody
|Together with accomplice and lover John Frank Brown murdered other gay men around [[Johannesburg]]
|
|-
|Duma, Sibusiso
|
|2007
|7
|7
|Sentenced to life imprisonment
|Killed various people around Pietermaritzburg during robberies
|
|-
|Kgabi, John Phuko
|The Ritual Killer
|1974–1978
|6
|14
|Executed in 1980
|Former police officer who garroted and mutilated young girls in Atteridgeville and [[Limpopo]]
|
|-
|Lineveldt, Gamal
|The Cape Flats Murderer
|1940
|4
|4
|Executed in 1941
|Responsible for the &quot;Cape Flats Murders&quot;; bludgeoned to death white women around the Cape Flats area
|
|-
|Maake, Cedric
|The Wemmer Pan Killer
|1996–1997
|27
|27+
|Sentenced to life imprisonment
|Serial rapist who murdered victims in the Wemmer Pan area
|
|-
|Mabhayi, Bulelani
|The Monster of Tholeni
|2007–2012
|20
|20
|Sentenced to life imprisonment
|House intruder who murdered women and children in the village of Tholeni
|
|-
|Majola, Simon
|The Bruma Lake Killer(s)
|2000–2001
|8
|8+
|Sentenced to life imprisonment
|Together with accomplice Themba Nkosi, known as &quot;The Bruma Lake Killers&quot;; robbed and drowned men in Bruma Lake
|
|-
|Makamu, Fanuel
|The Mpumalanga Serial Rapist
|2000
|6
|6
|Sentenced to life imprisonment
|Together with accomplice Henry Maile, robbed, raped and murdered women around [[Isifunda seMpumalanga|Mpumalanga]]
|
|-
|Maketta, Jimmy
|The Jesus Killer
|2005
|16
|16
|Sentenced to life imprisonment
|Murdered farm labourers in Philippi
|
|-
|Makgae, Andries
|
|2012–2013
|3
|4+
|Sentenced to life imprisonment
|Raped and murdered women around Onderstepoort; suspected in best friend's murder
|
|-
|Makhubela, Dumisani
|Lotto Gangster(s)
|2005
|7
|7
|Sentenced to life imprisonment
|Together with accomplice Johannes van Rooyen, robbed, raped and murdered people around Mpumalanga, including a family of four
|
|-
|Mashiane, Johannes
|The Beast of Atteridgeville
|1977–1989
|13
|13
|Committed suicide to avoid apprehension
|Murdered his girlfriend; after release, raped and strangled 12 young boys around Atteridgeville
|
|-
|de Melker, Daisy
|
|1923–1932
|3
|3
|Executed in 1932
|Poisoned two husbands and her son with strychnine for life insurance; South Africa's first convicted female serial killer
|
|-
|Mfeka, Samuel Bongani
|The Kranskop Killer
|1993–1996
|6
|6+
|Sentenced to life imprisonment
|Raped and strangled women around KwaZulu-Natal
|
|-
|Mogale, Jack
|The West-End Killer
|2008–2009
|16
|16
|Sentenced to life imprisonment
|Kidnapped, raped and murdered women in southern Johannesburg
|
|-
|Msomi, Elifasi
|The Axe Killer
|1953–1955
|15
|15
|Executed in 1956
|Murdered people while he was supposedly under the influence of a Tokoloshe
|
|-
|Mulaudzi, Mukosi Freddy
|The Limpopo Serial Killer
|1990–2006
|13
|13
|Sentenced to life imprisonment
|Murdered two people in 1990, then escaped from prison and resumed killing
|
|-
|Ncama, Nicholas Lungisa
|The East Cape Killer
|1997
|6
|6
|Sentenced to life imprisonment
|Raped and strangled women around Port Elizabeth
|
|-
|Ndlangamandla, Velaphi
|The Saloon Killer
|1998
|19
|19
|Sentenced to life imprisonment
|Robbed and murdered people during home invasions in Mpumalanga
|
|-
|Ndlovu, Rosemary
|
|2012–2018
|6
|6
|Sentenced to life imprisonment
|Former policewoman who murdered her ex-partner and relatives for life and funeral insurance policies
|
|-
|Ntsieni, Ndivhuwo
|The Univen serial killer
|2014
|5
|5
|Sentenced to life imprisonment
|Raped and murdered women and young girls in and around the University of Venda
|
|-
|Nyauza, Richard
|The Quarry Killer
|2002–2006
|18
|19
|Sentenced to life imprisonment
|Raped and murdered women after being infected with HIV, dumping their bodies in a quarry
|
|-
|Randitsheni, David
|The Modimolle Serial Killer
|2004–2008
|10
|10
|Committed suicide in prison
|Abducted, raped and murdered children in [[Modimolle]]
|
|-
|van Rooyen, Gert
|
|1988–1989
|6
|6+
|Committed suicide to avoid apprehension
|Pedophile who, together with accomplice and wife Joey Haarhoff, abducted, raped and murdered six teenage girls whose bodies have never been found
|
|-
|van Rooyen, Johannes
|Lotto Gangster(s)
|2005
|7
|7
|Sentenced to life imprisonment
|Together with accomplice Dumisani Makhubela, robbed, raped and murdered people around Mpumalanga, including a family of four
|
|-
|van Schoor, Louis
|The Apartheid Killer
|1986–1989
|9
|39+
|20 years; released in the 2003 and died a free man in 2024
|Former policeman and security guard who killed black South Africans during alleged crimes
|
|-
|Sedumedi, Khangayi
|The Century City Killer
|2011–2015
|4
|6
|Sentenced to life imprisonment
|Raped and murdered women around Century City and Kensington
|
|-
|Sidyno, Samuel
|The Capital Park Serial Killer
|1998–1999
|7
|7
|Sentenced to life imprisonment
|Strangled teenagers and women, then disposed of their bodies near the Pretoria Zoo
|
|-
|Sithole, Moses
|The ABC Killer
|1994–1995
|38
|76
|Sentenced to life imprisonment
|Raped and murdered women around Atteridgeville, [[IBoksburg|Boksburg]] and Cleveland
|
|-
|Stander, Riaan
|
|2001–2007
|3
|3
|Sentenced to life imprisonment
|Murdered two prostitutes in Port Elizabeth after being released from prison for running over a woman with his car
|
|-
|Sukude, Themba
|The Newcastle Serial Killer
|2004–2005
|4
|4
|Sentenced to life imprisonment
|Attacked couples around parks, raping the female and bludgeoning the male to death with rocks. He later switched to solely targeting men
|
|-
|Taki, Thozamile
|The Sugarcane Killer
|2007
|13
|13
|Sentenced to life imprisonment
|Robbed and murdered women around KwaZulu-Natal and Eastern Cape, dumping their bodies in sugarcane and tea plantations
|
|-
|Thwala, Sipho
|The Phoenix Strangler
|1996–1997
|16
|16+
|Sentenced to life imprisonment
|Raped and murdered women in sugarcane fields near Phoenix
|
|-
|Vilakazi, Themba
|The Railway Killer
|2005
|3
|5
|Sentenced to life imprisonment
|Murdered black males around Pretoria
|
|-
|Wilken, Stewart
|The Boetie Boer
|1990–1997
|10
|10+
|Sentenced to life imprisonment
|Raped and murdered prostitutes, young boys and his own daughter around Port Elizabeth
|
|-
|Williams, Tommy
|The City Serial Killer
|1987–2008
|3
|3
|Sentenced to life imprisonment
|Strangled three acquaintances in varying circumstances; South Africa's longest active serial offender
|
|-
|Xitavhudzi, Elias
|The Pangaman
|1953–1959
|16
|16
|Executed in 1960
|Murdered and mutilated white women around Atteridgeville
|
|-
|Zikode, Christopher Mhlengwa
|The Donnybrook Serial Killer
|1994–1995
|18
|18
|Sentenced to life imprisonment
|Necrophiliac house intruder who murdered people around Donnybrook, then had sex with the female victims' corpses
|
|}

== Ababulali abanengi abangaziwako ==
{| class=&quot;wikitable sortable&quot;
! width=&quot;200px&quot; |Isiteketiso
! width=&quot;100px&quot; | Iminyaka yokusebenza
! data-sort-type=&quot;number&quot; | Iinhlupheki eziqinisekisiweko
! data-sort-type=&quot;number&quot; | Abangaba ziinhlupheki
! Iindawo lapho zisebenza khona
! Amanothi
! Ref
|-
| Umbulali wezifebe we-Cape Town
| 1992–1996
| 19
| 19
| I-Western Cape
| Iinfebe eziklinyiweko nezisebenzi zasekhaya e -Cape Town
| 
|-
| Umbulali we-Fosaville
| 1999–2003
| 13
| 13
| KwaZulu-Natal
| Abafazi abathunjiweko, babotjhwa begodu baklinywa e- Newlands East
| 
|-
| Umbulali we-Sleepy Hollow
| 1990s–2007
| 13
| 16+
| Kwa-Zulu Natal (kuqinisekisiwe)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; I-Free State, e-Eastern Cape (kusolwa)
| Abafazi abadlwengulwako nabaklinyako, inengi labo abathengisa ucansi nabathengisa umzimba, basebenzisa amaphenti wabo
| 
|}

[[Category:Sewula Afrika]]</text>
      <sha1>3xzvya7c3xfi4gqv4h9jvur676hgyze</sha1>
    </revision>
    <revision>
      <id>6479</id>
      <parentid>6478</parentid>
      <timestamp>2026-04-19T16:34:53Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <origin>6479</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9792" sha1="jo4vckv9gr4d4lzbw9jd4e0oexrc99f" xml:space="preserve"> Lolu luhlu lwababulali abanengi beSewula Afrika eSewula Afrika. 

Umbulali we-serial kuvamise ukuba mumuntu obulala abantu abathathu nofana ngaphezulu, begodu ukubulawa kwenzeka isikhathi esingaphezu kwenyanga begodu kufaka hlangana isikhathi eside hlangana nabo.  [ 2 ] Nanyana kunjalo, iSewula Afrika isebenzisa ihlathululo elula yokubulala abantu abanengi, iyihlathulula ngokuthi, &quot;Ukubulawa kwabantu ababili nofana ngaphezulu ngokungasimthethweni mphulaphuli munye, ezehlakalweni ezihlukileko.&quot; 

== Ababulali abanengi abakhonjiweko ==
{| class=&quot;wikitable sortable&quot;
! width=&quot;200px&quot; |Name
!Nickname / AKA
! width=&quot;100px&quot; |Years active
! data-sort-type=&quot;number&quot; |Proven victims
! data-sort-type=&quot;number&quot; |Possible victims
!Status
!Notes
!Ref
|-
|Richman Makhwenkwe
|Moffat Park Killer
|2005 - 2006
|6
|7
|Sentenced to life imprisonment
|He raped and strangled his girlfriend then buried her body in a shallow grave in an overgrown park in [[Johannesburg]], then went on to kill other victims.
|
|-
|Baninzi, Asande
|
|2001
|14
|18
|Sentenced to life imprisonment
|Together with accomplice Mthutuzeli Nombewu, robbed and murdered people in the Cape Flats area
|
|-
|Barber, Peter Roy
|The Laughing Killer
|1973–1979
|3
|4
|Executed in 1980
|English immigrant who murdered his mistresses and a 12-year-old girl in Pinetown after arguments
|
|-
|Basson, Pierre
|The Insurance Killer
|1903–1906
|9
|9+
|Committed suicide to avoid apprehension
|Murdered people in Claremont, Cape Town so he could get their life insurance; South Africa's first recorded serial killer
|
|-
|Brown, John Frank
|The Cross Dressing Killer(s)
|1993–1995
|5
|5
|Sentenced to life imprisonment
|Together with accomplice and lover Jacques Coetzee murdered other gay men around [[Johannesburg]]
|
|-
|Brandt, Brydon
|
|1989–1997
|4
|5
|Sentenced to life imprisonment
|Murdered prostitutes and his roommates in the Eastern Cape
|
|-
|Burger, Cornelius
|
|1936–1937
|5
|5
|Died in a psychiatric facility
|Murdered prostitutes as revenge for contracting a venereal disease
|
|-
|Coetzee, Jacques
|The Cross Dressing Killer(s)
|1993–1995
|5
|5
|Committed suicide in custody
|Together with accomplice and lover John Frank Brown murdered other gay men around [[Johannesburg]]
|
|-
|Duma, Sibusiso
|
|2007
|7
|7
|Sentenced to life imprisonment
|Killed various people around Pietermaritzburg during robberies
|
|-
|Kgabi, John Phuko
|The Ritual Killer
|1974–1978
|6
|14
|Executed in 1980
|Former police officer who garroted and mutilated young girls in Atteridgeville and [[Limpopo]]
|
|-
|Lineveldt, Gamal
|The Cape Flats Murderer
|1940
|4
|4
|Executed in 1941
|Responsible for the &quot;Cape Flats Murders&quot;; bludgeoned to death white women around the Cape Flats area
|
|-
|Maake, Cedric
|The Wemmer Pan Killer
|1996–1997
|27
|27+
|Sentenced to life imprisonment
|Serial rapist who murdered victims in the Wemmer Pan area
|
|-
|Mabhayi, Bulelani
|The Monster of Tholeni
|2007–2012
|20
|20
|Sentenced to life imprisonment
|House intruder who murdered women and children in the village of Tholeni
|
|-
|Majola, Simon
|The Bruma Lake Killer(s)
|2000–2001
|8
|8+
|Sentenced to life imprisonment
|Together with accomplice Themba Nkosi, known as &quot;The Bruma Lake Killers&quot;; robbed and drowned men in Bruma Lake
|
|-
|Makamu, Fanuel
|The Mpumalanga Serial Rapist
|2000
|6
|6
|Sentenced to life imprisonment
|Together with accomplice Henry Maile, robbed, raped and murdered women around [[Isifunda seMpumalanga|Mpumalanga]]
|
|-
|Maketta, Jimmy
|The Jesus Killer
|2005
|16
|16
|Sentenced to life imprisonment
|Murdered farm labourers in Philippi
|
|-
|Makgae, Andries
|
|2012–2013
|3
|4+
|Sentenced to life imprisonment
|Raped and murdered women around Onderstepoort; suspected in best friend's murder
|
|-
|Makhubela, Dumisani
|Lotto Gangster(s)
|2005
|7
|7
|Sentenced to life imprisonment
|Together with accomplice Johannes van Rooyen, robbed, raped and murdered people around Mpumalanga, including a family of four
|
|-
|Mashiane, Johannes
|The Beast of Atteridgeville
|1977–1989
|13
|13
|Committed suicide to avoid apprehension
|Murdered his girlfriend; after release, raped and strangled 12 young boys around Atteridgeville
|
|-
|de Melker, Daisy
|
|1923–1932
|3
|3
|Executed in 1932
|Poisoned two husbands and her son with strychnine for life insurance; South Africa's first convicted female serial killer
|
|-
|Mfeka, Samuel Bongani
|The Kranskop Killer
|1993–1996
|6
|6+
|Sentenced to life imprisonment
|Raped and strangled women around KwaZulu-Natal
|
|-
|Mogale, Jack
|The West-End Killer
|2008–2009
|16
|16
|Sentenced to life imprisonment
|Kidnapped, raped and murdered women in southern Johannesburg
|
|-
|Msomi, Elifasi
|The Axe Killer
|1953–1955
|15
|15
|Executed in 1956
|Murdered people while he was supposedly under the influence of a Tokoloshe
|
|-
|Mulaudzi, Mukosi Freddy
|The Limpopo Serial Killer
|1990–2006
|13
|13
|Sentenced to life imprisonment
|Murdered two people in 1990, then escaped from prison and resumed killing
|
|-
|Ncama, Nicholas Lungisa
|The East Cape Killer
|1997
|6
|6
|Sentenced to life imprisonment
|Raped and strangled women around Port Elizabeth
|
|-
|Ndlangamandla, Velaphi
|The Saloon Killer
|1998
|19
|19
|Sentenced to life imprisonment
|Robbed and murdered people during home invasions in Mpumalanga
|
|-
|Ndlovu, Rosemary
|
|2012–2018
|6
|6
|Sentenced to life imprisonment
|Former policewoman who murdered her ex-partner and relatives for life and funeral insurance policies
|
|-
|Ntsieni, Ndivhuwo
|The Univen serial killer
|2014
|5
|5
|Sentenced to life imprisonment
|Raped and murdered women and young girls in and around the University of Venda
|
|-
|Nyauza, Richard
|The Quarry Killer
|2002–2006
|18
|19
|Sentenced to life imprisonment
|Raped and murdered women after being infected with HIV, dumping their bodies in a quarry
|
|-
|Randitsheni, David
|The Modimolle Serial Killer
|2004–2008
|10
|10
|Committed suicide in prison
|Abducted, raped and murdered children in [[Modimolle]]
|
|-
|van Rooyen, Gert
|
|1988–1989
|6
|6+
|Committed suicide to avoid apprehension
|Pedophile who, together with accomplice and wife Joey Haarhoff, abducted, raped and murdered six teenage girls whose bodies have never been found
|
|-
|van Rooyen, Johannes
|Lotto Gangster(s)
|2005
|7
|7
|Sentenced to life imprisonment
|Together with accomplice Dumisani Makhubela, robbed, raped and murdered people around Mpumalanga, including a family of four
|
|-
|van Schoor, Louis
|The Apartheid Killer
|1986–1989
|9
|39+
|20 years; released in the 2003 and died a free man in 2024
|Former policeman and security guard who killed black South Africans during alleged crimes
|
|-
|Sedumedi, Khangayi
|The Century City Killer
|2011–2015
|4
|6
|Sentenced to life imprisonment
|Raped and murdered women around Century City and Kensington
|
|-
|Sidyno, Samuel
|The Capital Park Serial Killer
|1998–1999
|7
|7
|Sentenced to life imprisonment
|Strangled teenagers and women, then disposed of their bodies near the Pretoria Zoo
|
|-
|Sithole, Moses
|The ABC Killer
|1994–1995
|38
|76
|Sentenced to life imprisonment
|Raped and murdered women around Atteridgeville, [[IBoksburg|Boksburg]] and Cleveland
|
|-
|Stander, Riaan
|
|2001–2007
|3
|3
|Sentenced to life imprisonment
|Murdered two prostitutes in Port Elizabeth after being released from prison for running over a woman with his car
|
|-
|Sukude, Themba
|The Newcastle Serial Killer
|2004–2005
|4
|4
|Sentenced to life imprisonment
|Attacked couples around parks, raping the female and bludgeoning the male to death with rocks. He later switched to solely targeting men
|
|-
|Taki, Thozamile
|The Sugarcane Killer
|2007
|13
|13
|Sentenced to life imprisonment
|Robbed and murdered women around KwaZulu-Natal and Eastern Cape, dumping their bodies in sugarcane and tea plantations
|
|-
|Thwala, Sipho
|The Phoenix Strangler
|1996–1997
|16
|16+
|Sentenced to life imprisonment
|Raped and murdered women in sugarcane fields near Phoenix
|
|-
|Vilakazi, Themba
|The Railway Killer
|2005
|3
|5
|Sentenced to life imprisonment
|Murdered black males around Pretoria
|
|-
|Wilken, Stewart
|The Boetie Boer
|1990–1997
|10
|10+
|Sentenced to life imprisonment
|Raped and murdered prostitutes, young boys and his own daughter around Port Elizabeth
|
|-
|Williams, Tommy
|The City Serial Killer
|1987–2008
|3
|3
|Sentenced to life imprisonment
|Strangled three acquaintances in varying circumstances; South Africa's longest active serial offender
|
|-
|Xitavhudzi, Elias
|The Pangaman
|1953–1959
|16
|16
|Executed in 1960
|Murdered and mutilated white women around Atteridgeville
|
|-
|Zikode, Christopher Mhlengwa
|The Donnybrook Serial Killer
|1994–1995
|18
|18
|Sentenced to life imprisonment
|Necrophiliac house intruder who murdered people around Donnybrook, then had sex with the female victims' corpses
|
|}

== Ababulali abanengi abangaziwako ==
{| class=&quot;wikitable sortable&quot;
! width=&quot;200px&quot; |Isiteketiso
! width=&quot;100px&quot; | Iminyaka yokusebenza
! data-sort-type=&quot;number&quot; | Iinhlupheki eziqinisekisiweko
! data-sort-type=&quot;number&quot; | Abangaba ziinhlupheki
! Iindawo lapho zisebenza khona
! Amanothi
! Ref
|-
| Umbulali wezifebe we-Cape Town
| 1992–1996
| 19
| 19
| I-Western Cape
| Iinfebe eziklinyiweko nezisebenzi zasekhaya e -Cape Town
| 
|-
| Umbulali we-Fosaville
| 1999–2003
| 13
| 13
| KwaZulu-Natal
| Abafazi abathunjiweko, babotjhwa begodu baklinywa e- Newlands East
| 
|-
| Umbulali we-Sleepy Hollow
| 1990s–2007
| 13
| 16+
| Kwa-Zulu Natal (kuqinisekisiwe)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; I-Free State, e-Eastern Cape (kusolwa)
| Abafazi abadlwengulwako nabaklinyako, inengi labo abathengisa ucansi nabathengisa umzimba, basebenzisa amaphenti wabo
| 
|}

[[Category:Sewula Afrika]]
[[Category:Afrika]]</text>
      <sha1>jo4vckv9gr4d4lzbw9jd4e0oexrc99f</sha1>
    </revision>
    <revision>
      <id>6621</id>
      <parentid>6479</parentid>
      <timestamp>2026-05-19T07:45:52Z</timestamp>
      <contributor>
        <username>Kwamikagami</username>
        <id>1412</id>
      </contributor>
      <minor />
      <origin>6621</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9783" sha1="tm6lojw3t79clf31twh29q2rhxvxlx0" xml:space="preserve">Lolu luhlu lwababulali abanengi beSewula Afrika eSewula Afrika. 

Umbulali we-serial kuvamise ukuba mumuntu obulala abantu abathathu nofana ngaphezulu, begodu ukubulawa kwenzeka isikhathi esingaphezu kwenyanga begodu kufaka hlangana isikhathi eside hlangana nabo. Nanyana kunjalo, iSewula Afrika isebenzisa ihlathululo elula yokubulala abantu abanengi, iyihlathulula ngokuthi, &quot;Ukubulawa kwabantu ababili nofana ngaphezulu ngokungasimthethweni mphulaphuli munye, ezehlakalweni ezihlukileko.&quot; 

== Ababulali abanengi abakhonjiweko ==
{| class=&quot;wikitable sortable&quot;
! width=&quot;200px&quot; |Name
!Nickname / AKA
! width=&quot;100px&quot; |Years active
! data-sort-type=&quot;number&quot; |Proven victims
! data-sort-type=&quot;number&quot; |Possible victims
!Status
!Notes
!Ref
|-
|Richman Makhwenkwe
|Moffat Park Killer
|2005 - 2006
|6
|7
|Sentenced to life imprisonment
|He raped and strangled his girlfriend then buried her body in a shallow grave in an overgrown park in [[Johannesburg]], then went on to kill other victims.
|
|-
|Baninzi, Asande
|
|2001
|14
|18
|Sentenced to life imprisonment
|Together with accomplice Mthutuzeli Nombewu, robbed and murdered people in the Cape Flats area
|
|-
|Barber, Peter Roy
|The Laughing Killer
|1973–1979
|3
|4
|Executed in 1980
|English immigrant who murdered his mistresses and a 12-year-old girl in Pinetown after arguments
|
|-
|Basson, Pierre
|The Insurance Killer
|1903–1906
|9
|9+
|Committed suicide to avoid apprehension
|Murdered people in Claremont, Cape Town so he could get their life insurance; South Africa's first recorded serial killer
|
|-
|Brown, John Frank
|The Cross Dressing Killer(s)
|1993–1995
|5
|5
|Sentenced to life imprisonment
|Together with accomplice and lover Jacques Coetzee murdered other gay men around [[Johannesburg]]
|
|-
|Brandt, Brydon
|
|1989–1997
|4
|5
|Sentenced to life imprisonment
|Murdered prostitutes and his roommates in the Eastern Cape
|
|-
|Burger, Cornelius
|
|1936–1937
|5
|5
|Died in a psychiatric facility
|Murdered prostitutes as revenge for contracting a venereal disease
|
|-
|Coetzee, Jacques
|The Cross Dressing Killer(s)
|1993–1995
|5
|5
|Committed suicide in custody
|Together with accomplice and lover John Frank Brown murdered other gay men around [[Johannesburg]]
|
|-
|Duma, Sibusiso
|
|2007
|7
|7
|Sentenced to life imprisonment
|Killed various people around Pietermaritzburg during robberies
|
|-
|Kgabi, John Phuko
|The Ritual Killer
|1974–1978
|6
|14
|Executed in 1980
|Former police officer who garroted and mutilated young girls in Atteridgeville and [[Limpopo]]
|
|-
|Lineveldt, Gamal
|The Cape Flats Murderer
|1940
|4
|4
|Executed in 1941
|Responsible for the &quot;Cape Flats Murders&quot;; bludgeoned to death white women around the Cape Flats area
|
|-
|Maake, Cedric
|The Wemmer Pan Killer
|1996–1997
|27
|27+
|Sentenced to life imprisonment
|Serial rapist who murdered victims in the Wemmer Pan area
|
|-
|Mabhayi, Bulelani
|The Monster of Tholeni
|2007–2012
|20
|20
|Sentenced to life imprisonment
|House intruder who murdered women and children in the village of Tholeni
|
|-
|Majola, Simon
|The Bruma Lake Killer(s)
|2000–2001
|8
|8+
|Sentenced to life imprisonment
|Together with accomplice Themba Nkosi, known as &quot;The Bruma Lake Killers&quot;; robbed and drowned men in Bruma Lake
|
|-
|Makamu, Fanuel
|The Mpumalanga Serial Rapist
|2000
|6
|6
|Sentenced to life imprisonment
|Together with accomplice Henry Maile, robbed, raped and murdered women around [[Isifunda seMpumalanga|Mpumalanga]]
|
|-
|Maketta, Jimmy
|The Jesus Killer
|2005
|16
|16
|Sentenced to life imprisonment
|Murdered farm labourers in Philippi
|
|-
|Makgae, Andries
|
|2012–2013
|3
|4+
|Sentenced to life imprisonment
|Raped and murdered women around Onderstepoort; suspected in best friend's murder
|
|-
|Makhubela, Dumisani
|Lotto Gangster(s)
|2005
|7
|7
|Sentenced to life imprisonment
|Together with accomplice Johannes van Rooyen, robbed, raped and murdered people around Mpumalanga, including a family of four
|
|-
|Mashiane, Johannes
|The Beast of Atteridgeville
|1977–1989
|13
|13
|Committed suicide to avoid apprehension
|Murdered his girlfriend; after release, raped and strangled 12 young boys around Atteridgeville
|
|-
|de Melker, Daisy
|
|1923–1932
|3
|3
|Executed in 1932
|Poisoned two husbands and her son with strychnine for life insurance; South Africa's first convicted female serial killer
|
|-
|Mfeka, Samuel Bongani
|The Kranskop Killer
|1993–1996
|6
|6+
|Sentenced to life imprisonment
|Raped and strangled women around KwaZulu-Natal
|
|-
|Mogale, Jack
|The West-End Killer
|2008–2009
|16
|16
|Sentenced to life imprisonment
|Kidnapped, raped and murdered women in southern Johannesburg
|
|-
|Msomi, Elifasi
|The Axe Killer
|1953–1955
|15
|15
|Executed in 1956
|Murdered people while he was supposedly under the influence of a Tokoloshe
|
|-
|Mulaudzi, Mukosi Freddy
|The Limpopo Serial Killer
|1990–2006
|13
|13
|Sentenced to life imprisonment
|Murdered two people in 1990, then escaped from prison and resumed killing
|
|-
|Ncama, Nicholas Lungisa
|The East Cape Killer
|1997
|6
|6
|Sentenced to life imprisonment
|Raped and strangled women around Port Elizabeth
|
|-
|Ndlangamandla, Velaphi
|The Saloon Killer
|1998
|19
|19
|Sentenced to life imprisonment
|Robbed and murdered people during home invasions in Mpumalanga
|
|-
|Ndlovu, Rosemary
|
|2012–2018
|6
|6
|Sentenced to life imprisonment
|Former policewoman who murdered her ex-partner and relatives for life and funeral insurance policies
|
|-
|Ntsieni, Ndivhuwo
|The Univen serial killer
|2014
|5
|5
|Sentenced to life imprisonment
|Raped and murdered women and young girls in and around the University of Venda
|
|-
|Nyauza, Richard
|The Quarry Killer
|2002–2006
|18
|19
|Sentenced to life imprisonment
|Raped and murdered women after being infected with HIV, dumping their bodies in a quarry
|
|-
|Randitsheni, David
|The Modimolle Serial Killer
|2004–2008
|10
|10
|Committed suicide in prison
|Abducted, raped and murdered children in [[Modimolle]]
|
|-
|van Rooyen, Gert
|
|1988–1989
|6
|6+
|Committed suicide to avoid apprehension
|Pedophile who, together with accomplice and wife Joey Haarhoff, abducted, raped and murdered six teenage girls whose bodies have never been found
|
|-
|van Rooyen, Johannes
|Lotto Gangster(s)
|2005
|7
|7
|Sentenced to life imprisonment
|Together with accomplice Dumisani Makhubela, robbed, raped and murdered people around Mpumalanga, including a family of four
|
|-
|van Schoor, Louis
|The Apartheid Killer
|1986–1989
|9
|39+
|20 years; released in the 2003 and died a free man in 2024
|Former policeman and security guard who killed black South Africans during alleged crimes
|
|-
|Sedumedi, Khangayi
|The Century City Killer
|2011–2015
|4
|6
|Sentenced to life imprisonment
|Raped and murdered women around Century City and Kensington
|
|-
|Sidyno, Samuel
|The Capital Park Serial Killer
|1998–1999
|7
|7
|Sentenced to life imprisonment
|Strangled teenagers and women, then disposed of their bodies near the Pretoria Zoo
|
|-
|Sithole, Moses
|The ABC Killer
|1994–1995
|38
|76
|Sentenced to life imprisonment
|Raped and murdered women around Atteridgeville, [[IBoksburg|Boksburg]] and Cleveland
|
|-
|Stander, Riaan
|
|2001–2007
|3
|3
|Sentenced to life imprisonment
|Murdered two prostitutes in Port Elizabeth after being released from prison for running over a woman with his car
|
|-
|Sukude, Themba
|The Newcastle Serial Killer
|2004–2005
|4
|4
|Sentenced to life imprisonment
|Attacked couples around parks, raping the female and bludgeoning the male to death with rocks. He later switched to solely targeting men
|
|-
|Taki, Thozamile
|The Sugarcane Killer
|2007
|13
|13
|Sentenced to life imprisonment
|Robbed and murdered women around KwaZulu-Natal and Eastern Cape, dumping their bodies in sugarcane and tea plantations
|
|-
|Thwala, Sipho
|The Phoenix Strangler
|1996–1997
|16
|16+
|Sentenced to life imprisonment
|Raped and murdered women in sugarcane fields near Phoenix
|
|-
|Vilakazi, Themba
|The Railway Killer
|2005
|3
|5
|Sentenced to life imprisonment
|Murdered black males around Pretoria
|
|-
|Wilken, Stewart
|The Boetie Boer
|1990–1997
|10
|10+
|Sentenced to life imprisonment
|Raped and murdered prostitutes, young boys and his own daughter around Port Elizabeth
|
|-
|Williams, Tommy
|The City Serial Killer
|1987–2008
|3
|3
|Sentenced to life imprisonment
|Strangled three acquaintances in varying circumstances; South Africa's longest active serial offender
|
|-
|Xitavhudzi, Elias
|The Pangaman
|1953–1959
|16
|16
|Executed in 1960
|Murdered and mutilated white women around Atteridgeville
|
|-
|Zikode, Christopher Mhlengwa
|The Donnybrook Serial Killer
|1994–1995
|18
|18
|Sentenced to life imprisonment
|Necrophiliac house intruder who murdered people around Donnybrook, then had sex with the female victims' corpses
|
|}

== Ababulali abanengi abangaziwako ==
{| class=&quot;wikitable sortable&quot;
! width=&quot;200px&quot; |Isiteketiso
! width=&quot;100px&quot; | Iminyaka yokusebenza
! data-sort-type=&quot;number&quot; | Iinhlupheki eziqinisekisiweko
! data-sort-type=&quot;number&quot; | Abangaba ziinhlupheki
! Iindawo lapho zisebenza khona
! Amanothi
! Ref
|-
| Umbulali wezifebe we-Cape Town
| 1992–1996
| 19
| 19
| I-Western Cape
| Iinfebe eziklinyiweko nezisebenzi zasekhaya e -Cape Town
| 
|-
| Umbulali we-Fosaville
| 1999–2003
| 13
| 13
| KwaZulu-Natal
| Abafazi abathunjiweko, babotjhwa begodu baklinywa e- Newlands East
| 
|-
| Umbulali we-Sleepy Hollow
| 1990s–2007
| 13
| 16+
| Kwa-Zulu Natal (kuqinisekisiwe)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; I-Free State, e-Eastern Cape (kusolwa)
| Abafazi abadlwengulwako nabaklinyako, inengi labo abathengisa ucansi nabathengisa umzimba, basebenzisa amaphenti wabo
| 
|}

[[Category:Sewula Afrika]]
[[Category:Afrika]]</text>
      <sha1>tm6lojw3t79clf31twh29q2rhxvxlx0</sha1>
    </revision>
  </page>
  <page>
    <title>I-Jarvis Brook</title>
    <ns>0</ns>
    <id>1100</id>
    <revision>
      <id>6480</id>
      <timestamp>2026-04-20T19:21:19Z</timestamp>
      <contributor>
        <username>YinYangies</username>
        <id>1474</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:fr:Special:Redirect/revision/235388196|Jarvis Brook]]&quot;</comment>
      <origin>6480</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="606" sha1="9xtxi6g3gya8pwnorwzs751o0k70xtd" xml:space="preserve">I-'''Jarvis Brook''' lidorobho elisesifundeni se-Wealden se-East Sussex, e-England.&lt;ref&gt;https://www.ordnancesurvey.co.uk/election-maps/gb/&lt;/ref&gt; Iseningizimu-pumalanga ye-Crowborough, i-1.5 amakhilomitha ukusuka edorobheni. Ngo-2012, inani labantu belingu-4,305.&lt;ref&gt;https://www.citypopulation.de/en/uk/southeastengland/wards/wealden/E05011629__crowborough_jarvis_brook/&lt;/ref&gt;

Isitetjhi se-Crowborough, egatjeni le-Uckfield lomzila we-Oxted, besaziwa nge-Crowborough ne-Jarvis Brook begodu sisebenzela idolobhana.&lt;ref&gt;http://www.disused-stations.org.uk/c/crowborough_and_jarvis_brook/&lt;/ref&gt;
&lt;references /&gt;</text>
      <sha1>9xtxi6g3gya8pwnorwzs751o0k70xtd</sha1>
    </revision>
    <revision>
      <id>6481</id>
      <parentid>6480</parentid>
      <timestamp>2026-04-20T19:22:41Z</timestamp>
      <contributor>
        <username>YinYangies</username>
        <id>1474</id>
      </contributor>
      <origin>6481</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="606" sha1="8c8puh4xyyg75cpox6x4om0e780q32u" xml:space="preserve">I-'''Jarvis Brook''' lidorobho elisesifundeni se-Wealden se-East Sussex, e-England.&lt;ref&gt;https://www.ordnancesurvey.co.uk/election-maps/gb/&lt;/ref&gt; Iseningizimu-pumalanga ye-Crowborough, i-1.5 amakhilomitha ukusuka edorobheni. Ngo-2021, inani labantu belingu-4,305.&lt;ref&gt;https://www.citypopulation.de/en/uk/southeastengland/wards/wealden/E05011629__crowborough_jarvis_brook/&lt;/ref&gt;

Isitetjhi se-Crowborough, egatjeni le-Uckfield lomzila we-Oxted, besaziwa nge-Crowborough ne-Jarvis Brook begodu sisebenzela idolobhana.&lt;ref&gt;http://www.disused-stations.org.uk/c/crowborough_and_jarvis_brook/&lt;/ref&gt;
&lt;references /&gt;</text>
      <sha1>8c8puh4xyyg75cpox6x4om0e780q32u</sha1>
    </revision>
  </page>
  <page>
    <title>U-Pieter Van Meerhof</title>
    <ns>0</ns>
    <id>1101</id>
    <revision>
      <id>6488</id>
      <timestamp>2026-04-28T13:05:10Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>Created page with &quot;'''U-Pieter van Meerhof''' wabelethelwa e-Copenhagen, e-Denmark. Wafika eKapa ngomkhumbi ebewubizwa bona yi-''Princess van Royael.'' Bekamumuntu othanda ukukhamba iphasi begodu bekangudorhodere ohlinzako. Usebenzile njengomnqophisi wesihlengehlenge i-Robben Island. Ngemva kwalokho wakhamba nomkhumbi ebewuthwele iingqila i-''Westwout.'' Wabulawa ejimeni lokubuthelela iingqila e-Antogil Bay e-Madagascar elenzeka ngaphambi kwangomhla wa-27 kaMhlolanja 1668. Umkhumbi wabo lo...&quot;</comment>
      <origin>6488</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3854" sha1="660iunjnx9xjr778y2t8l20e56vxyyp" xml:space="preserve">'''U-Pieter van Meerhof''' wabelethelwa e-Copenhagen, e-Denmark. Wafika eKapa ngomkhumbi ebewubizwa bona yi-''Princess van Royael.'' Bekamumuntu othanda ukukhamba iphasi begodu bekangudorhodere ohlinzako. Usebenzile njengomnqophisi wesihlengehlenge i-Robben Island. Ngemva kwalokho wakhamba nomkhumbi ebewuthwele iingqila i-''Westwout.'' Wabulawa ejimeni lokubuthelela iingqila e-Antogil Bay e-Madagascar elenzeka ngaphambi kwangomhla wa-27 kaMhlolanja 1668. Umkhumbi wabo lo wafika eKapa ngomhla wama-30 kaKhukhulamungu 1668. ESewula Afrika waziwa ngokutjhada kwakhe no-[[U-Krotoa|Krotoa]] (namkha u-Eva) ongowesitjhaba sama-Goringhaicona ngomhla wama-26 kaSihlabantangana 1664, u-Krotoa owakhulela emzini womphathi [[u-Jan Van Riebeeck]].&lt;ref name=&quot;:0&quot;&gt;Stamouers  (30 November 1999) ''Pieter van Meerhof,'' Stamouers Website. Retrieved from: https://www.stamouers.com/stamouers/surnames-v-z/549-van-meerhof-ieter. Retrieved on 28/04/2026.&lt;/ref&gt;

== Imvelaphi Ka-Pieter van Meerhof ==
U-Pieter Van Meerhof, ibizo lakhe lesiDenitjhi bekungu-Peder Havgaard, amaBhuru alitjhugululela esiBhurwini laba ngu-Pieter Van Meerhof. Uyindodana ka-Aug no-Marie Ede, ebebavela e-Havgaard, kodwana bahlala eplasini esihlengehlengeni esibizwa bona yi-Langeland. Iplaselo lisesekhona nanamhlanjesi begodu isibongo sakwa-Havgaard sisesekhona. Kungenzeka wabelethwa ngabo-1636, e-Copenhagen, e-Denmark, ayindodana ka-Aug Ede. U-Pietre bekamumuntu obekathanda ukukhamba avakatjhele kezinye iinarha, begodu angudorhodere ohlinzako. Wafika eKapa ngomkhumbi ebewubizwa bona yi-''Princess van Royael.''&lt;ref&gt;FamilySearch (2026) ''Pieter Van Meerhof.'' Retrieved from: https://ancestors.familysearch.org/en/M1G4-H34/pieter-van-meerhof-1636-1668. Retrieved on 28/04/2026.&lt;/ref&gt; 

== Ukutjhada Kwakhe No-Krotoa ==
[[Isimumathi:Krotoa.webp|thumb|U-Krotoa]]
Ngomhla wama-26 kaSihlabantangana 1664, kwamenyezelwa bona u-Pieter no-Krotoa (Eva) bathembisene umtjhado. Isaziswesi seza ngemva kobana u-Van Meerhof afike eKapa okwesithandathu. Bobabili batjhada ngomhla wesi-2 kaMgwengweni 1664, emzini ka-Zacharias Wagenaer, umphathi wamaDatjhi wangalesosikhathi. IKhamphani (i-VOC), ebeyikuthanda ukuzihlanganisa nama-Khoikhoi, ngiyo eyalobolela u-Pieter ngelobolo elikhulu. Umphathi wedayari ka-Wagenaer watlola kiyo bona &quot;Lo mtjhado wokuthoma owatloliswa ngokuhlanganisa isiKrestu nesintu sendabuko.&quot; AmaDatjhi bewangathathelani nabantu balapho bendabuko bekwaba ngemva kweminyala eli-12 ngemva kokufika kuka-Van Riebeeck eKapa.&lt;ref name=&quot;:1&quot;&gt;South African History Online (17 February 2011) ''Krotoa (Eva)''. Retrieved from: https://sahistory.org.za/people/krotoa-eva. Retrieved on 28/04/2026.&lt;/ref&gt; 

Ngemva komnyaka, u-Krotoa no-Van Meerhof baba nabantwana ababili, bakhamba bayokuhlala esihlengehlengeni se-Robben Island. U-Pieter wabekwa bona abe mnqophisi wendawo leyo. Umsebenzi wakhe bekususa iinyoka, iinswebu nezinye iinlwana ezitshwenyako. Kwathi ngomnyaka wango-1666 babeletha umntwana wesithathu. Babuyela enarheni bona bayombhabhadisa.&lt;ref name=&quot;:1&quot; /&gt; Kubonakala kwanga u-Pieter ube nabantwana  ababili ngaphandle komtjhadwakhe.&lt;ref name=&quot;:0&quot; /&gt;

Napa abantwana baka-Pieter:&lt;ref name=&quot;:0&quot; /&gt;

* U-Jacobus owabelethwa ngo-1661 wahlongakala ngo-1685 emkhumbini obuya e-Mauritius
* U-Pieternella owabelethwa ngo-1663
* U-Salamon owabhajadiswa ngomhla woku-1 kuKhukhulamungu 1666
* U-Jeronimus owabhajadiswa ngomhla wama-23 kaSinyikhaba1670 (Amthole ngaphandle komtjhado)
* U-Anthonij owabhajadiswa ngomhla wesi-6 kaRhoboyi 1673 (Amthole ngaphandle komtjhado)

Ngemva kwalokho u-Pieter watjhinga eMadacascar, wakhamba nomkhumbi ebewuthwele iingqila i-''Westwout.'' Wabulawa ejimeni lokubuthelela iingqila e-''Antogil Bay'' e-Madagascar elenzeka ngaphambi kwangomhla wa-27 kaMhlolanja 1668. Umkhumbi wabo lo wafika eKapa ngomhla wama-30 kaKhukhulamungu 1668.

== Iinkhombo ==</text>
      <sha1>660iunjnx9xjr778y2t8l20e56vxyyp</sha1>
    </revision>
  </page>
  <page>
    <title>U-Zacharias Wagenaer</title>
    <ns>0</ns>
    <id>1102</id>
    <revision>
      <id>6490</id>
      <timestamp>2026-04-30T10:31:51Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1348733527|Zacharias Wagenaer]]&quot;</comment>
      <origin>6490</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7023" sha1="mge09zadezd3q575zo87x0wmjf13zhu" xml:space="preserve">

'''U-Zacharias Wagenaer''' (owaziwa ngo ''-Wagener'', ''Wagenaar'' no ''-Wagner'' ) (10 Meyi 1614 – 12 Okthoba 1668) bekangumtloli womDatjhi owabelethelwa e-Germany, umdwebi weenthombe, umthengisi, ilunga leKhotho yoBulungiswa, umphathi we-Deshima kanye nomnqophisi weKoloni yamaDatjhi eseKapa. Eminyakeni ema-35 wakhamba iinarhakazi ezine.

== Umlando ==

=== Ipilwakhe Yekukhuleni Nebizelo ===
U-Zacharias bekayindodana yejaji yom-''Saxon'' nomdwebi. Ngo-1633 wasuka e-Dresden wadlula e-Hamburg waya e -Amsterdam . Lapho wasebenzela u-Willem Blaeu . Kungakapheli umnyaka watlolisa njengesotja emabuthweni we-&lt;nowiki&gt;&lt;i&gt;Dutch West India Company&lt;/i&gt;&lt;/nowiki&gt; ukuyokulwa e-''&quot;New Holland&quot;'' (i-''Dutch Brazil'') ngo-1634. Ngemva kweminyaka emithathu, waqatjhwa njengomtloli mbusi wekoloni leyo, u-Count John Maurice, iKosana ye-Nassau-Siegen . E-Recife bekaphethe idayari enemifanekiso eli-109 yemibala yamanzi yeemfesi ezikarisako, iinyoni ezingakajayeleki, iinlwana ezilisizo neziyingozi, iinthelo ezimnandi neenbungu ezimbi ezinetjhefu, nabantu abakhulu, abazotho nofana abanzima, nakangadangisako wababiza ngokuthi &quot;Thier-Buch&quot;. Kuneenthombe zefesi ezinehloko yehamura, ifesi i-filefish, i-Serranidae, ne -Cirripedia. Mhla ali-1 kuMrhayili 1641, watjhiya i-Dutch Brazil, wafika e-Texel mhla ali-17 kuMgwengweni. Wabuyela emuva e-Dresden wafika mhlana ali-12 kuNobayeni.   Ngemva kweenyanga ezine, watjhiya i-Dresden ukubuyela e-Netherlands wafika e-Amsterdam mhla ama-29 kuNtaka 1642,&lt;ref name=&quot;chu32&quot; /&gt; begodu wathola isikhundla ekhamphanini i-&lt;nowiki&gt;&lt;i&gt;Dutch East India Company&lt;/i&gt;&lt;/nowiki&gt; ( NgesiDatjhi: ''Vereenigde Oostindische Compagnie,'' evame ukurhunyezwa ngokuthi yi-VOC).

=== Ikhambo LamaDatjhi Lokuya ENdiya ===
[[Isimumathi:Meireki_fire.JPG|thumb|UmLilo omKhulu we-Meireki owathatha amalanga amathathu begodu kungenzeka ubangele ukufa kwabantu abayi-100,000. Imizamo yokwakha kabutjha yathatha iminyaka emibili, njengoba i-''shogunate'' yathatha ithuba lokuhlela kabutjha idorobha ngokuya ngezinto ezihlukahlukeneko eziphathekako.]]
Mhla amalanga ama-29 kuKhukhulamungu ngo-1642 wakhamba ngesikepe asendleleni etjhinga eNdiya njengomuntu oyokufunda umsebenzi (NgesiDatjhi: ''adelborst'').  Wafika e-Batavia mhla ali-17 kuMrhayili 1643 ngesikepe i-Zwaan begodu msinyana ngemva kwalokho waqatjhwa Mbusi u-Antonie van Diemen njengomkopitjhi. Bekaqalwa njengomdwebi owakopa imifanekiso engaphezu kwama-50 phakathi kukaMgwengweni noNobayeni 1643 wayidweba encwadini esemthethweni yekhamba lika-Abel Tasman lango-1642-43 lapha u-Tasman waba mumuntu wokuthoma we-Yurobhu ukubona i-Tasmania, e-New Zealand kanye neenhlengele ezinengi ze-''Tongan Archipelago''.  Ngo-1646 waba mthengisi ongaphasi kwabanye abathengisi begodu ngo-1651 waba mthengisi ozijameleko. Kathathu waba lilunga leKhotho yoBulungiswa e-Batavia. Ngo-1653 waya e-Canton ukuyokuvula ubudlelwano bokurhweba, okwaba yinto engasizi ngalitho, ngebanga lepi yombango ngemva kokuwa kwe-&lt;nowiki&gt;&lt;i&gt;Ming Dynasty&lt;/i&gt;&lt;/nowiki&gt;.

Ngo-1657 waphakama ngesikhundla waba yi-&lt;nowiki&gt;&lt;i&gt;opperhoofd&lt;/i&gt;&lt;/nowiki&gt; (isikhulu esiphezulu) se-VOC esihlengeleni esincani e- ''Nagasaki Bay'' esihlengeleni seJapani se-Kyushu, e-Dejima. Wakhamba waya enhlokodorobha ye-Edo ngomsebenzi wejima lamaDatjhi begodu waphunyuka edorobheni ebelitjha, okwathoma mhla ama-2 kuNtaka 1657. (Kunomdwebo wesandla sakhe eMnyuziyamu we-Edo-Tokyo .) Ngo-1659, njengomunye &quot;we-''opperhoofden''&quot; yokuthoma, wahlela isidlo sakusihlwa, ebesinokudla okuma-20 okuhlukahlukeneko.  : U-Wagener wenza umtlamo we- &lt;nowiki&gt;&lt;i&gt;porcelain&lt;/i&gt;&lt;/nowiki&gt; yeJapani, ngokuya ngendlela yokuhlelwa kwesidlo ye-Europe ekhamba ibe nombala mhlophe nohlaza komkayi, nangamathuthumbo amanengi.  

Ngo-1660 u-Wagner wabandakanyeka emikhulumiswaneni yokuthula nekosi ye-Makassar. Itheku belinabarhwebi bamaPutukezi abangaba ziin-2000 begodu iminyaka eminengi belithusela ukuqeda ukurhweba ngeenungo e-Moluccas. Ngomnyaka olandelako waba yihloko yezemiSebenzi yomPhakathi e-Batavia.

Ngo-1662 waya e -Cape of Good Hope nomndenakhe omncani, iinceku ezihlanu neenjomani ezimbili. Walandela u-Jan van Riebeeck njengombusi mhla asi-6 kuMrhayili womnyaka loyo. U-Riebeeck wasuka ngelanga elilandelako. NgoNobayeni 1663 wabawa i-Batavia bona imthumelele izinto zokubumba iimpoto ezivela e-Persia. &lt;ref name=&quot;sch06&quot; /&gt; Wakhulumisana namaKhoikhoi ngeenkomo zeKhamphani.  Ngokuzibamba kwakhe bona angasolo akhambakhamba u-Wagener wabeka umthethomgomo wokuthi angekhe angenele eempikiswaneni zeentjhaba zendabuko begodu angekhe athathe ihlangothi. Ngemva kweminyaka emihlanu yokufunda, umfundi weJarimani u-Georg Friedrich Wreede watlola isirhunyezo selimi lesiDatjhi nesi-Khoikhoi   Ngu-Wagener wamkhetha bona enze njalo nabase-Mauritius.

U-Wagener bekangomunye wabantu abahlanu ababeka isisekelo se-&lt;nowiki&gt;&lt;i&gt;Castle of Good Hope&lt;/i&gt;&lt;/nowiki&gt;, eyathonywa ngoRhoboyi wango-1665. Wakha ibulungelo lamanzi, wanikela imikhumbi ngamanzi ahlanzekileko, wakha isibhedlela, isikolo nesonto. Ngo-1666 umkakhe u-Anna Auxbrebis, ebekatjhade naye ngo-1648, wahlongakala.

=== Ipilwakhe Yekuluphaleni ===
Mhla amalanga ama-27 kuKhukhulamungu 1666 u-Wagener watjhiya umsebenzi begodu wabuyela e-Batavia nendodakazi kamkakhe. Wathengisa iingqila zakhe ezivela e-Bengal. Wakhamba nezipho waya ukuyobona i- &lt;nowiki&gt;&lt;i&gt;sushunan&lt;/i&gt;&lt;/nowiki&gt; namkha umbusi we-Mataram, owala ukurhweba ne-VOC. Wathoma ikhambo leli anelwazi elincani lelimi lesiMalay nofana lesi-Javan, begodu umphumela womnqopho loyo khenge umsebenzele kuhle. Nanyana kunjalo, u-Wagener wavakatjhela i-Japara ngemva kwalokho. Ngemva komnyaka wabuyela emva e-Amsterdam njengesekela lomphathi omkhulu wezepi enarheni, kodwana bekagula. Wangcwatjwa mhlana ali-16 kuNobayeni 1668 eSontweni eliDala .

Omunye wemidwebo wedayari yakhe watjhugululwa ukusuka ku-&lt;nowiki&gt;&lt;i&gt;High Dutch&lt;/i&gt;&lt;/nowiki&gt; ukuya esiNgisini begodu wagadangiswa ngo-1704 nango-1732. Umtlolo wesandla onomdwebo wona loyo—kodwana ongesiJarimani—bewuyingcenye yeButhelelo lemiGadangiso neeNthombe (NgesiJamrimani ''Kupferstich-Kabinett'') we-&lt;nowiki&gt;&lt;i&gt;Dresden State Art Collections&lt;/i&gt;&lt;/nowiki&gt; kusukela ekuthomeni kwekhulu le-18. &lt;ref name=&quot;michel87&quot; /&gt;

=== Idlhego Lakhe Njenge-''Opperhoofd'' ===
U-Wagner wasebenza amathemu amabili njengo -&lt;nowiki&gt;&lt;i&gt;opperhoofd&lt;/i&gt;&lt;/nowiki&gt; ngokutjhuguluka no[[Joan Boucheljon|-Joan Boucheljon]] :

* U-Joan Bouchelion: 23 kuSewula1655 - 1 kuSinyikhaba 1656
* U-Zacharias Wagenaer [Wagener]: 1 kuSinyikhaba 1656 - 27 kuSewula 1657
* U-Joan Bouchelion: 27 kuSewula 1657 - 23 kuSewula 1658
* U-Zacharias Wagenaer [Wagener]: 22 kuSewula 1658 - 4 kuSinyikhaba 1659
* U-Joan Bouchelion: 4 kuSinyikhaba 1659 - 26 kuSewula 1660

== Ibuthelelo Leenthombe Zakhe ==
&lt;gallery&gt;
Isimumathi:Zacharias_Wagner_-_Insetos.jpg|alt=Insects, Kupferstich-Kabinett (Dresden)| Iinunwana, i-Kupferstich-Kabinett (Dresden)
Isimumathi:Zacharias_Wagner_-_Caranguejo.jpg|alt=Caranguejo (crab)| I-Caranguejo (ikala)
&lt;/gallery&gt;

== Iinkomba ==

[[Mkhakha:Pages with unreviewed translations]]</text>
      <sha1>mge09zadezd3q575zo87x0wmjf13zhu</sha1>
    </revision>
    <revision>
      <id>6491</id>
      <parentid>6490</parentid>
      <timestamp>2026-04-30T10:37:03Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>edited</comment>
      <origin>6491</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="6987" sha1="gmllraljs3e2bpyia5o4oufr7evevvg" xml:space="preserve">

'''U-Zacharias Wagenaer''' (owaziwa ngo ''-Wagener'', ''Wagenaar'' no ''-Wagner'' ) (10 Meyi 1614 – 12 Okthoba 1668) bekangumtloli womDatjhi owabelethelwa e-Germany, umdwebi weenthombe, umthengisi, ilunga leKhotho yoBulungiswa, umphathi we-Deshima kanye nomnqophisi weKoloni yamaDatjhi eseKapa. Eminyakeni ema-35 wakhamba iinarhakazi ezine.

== Umlando ==

=== Ipilwakhe Yekukhuleni Nebizelo ===
U-Zacharias bekayindodana yejaji yom-''Saxon'' nomdwebi. Ngo-1633 wasuka e-Dresden wadlula e-Hamburg waya e -Amsterdam . Lapho wasebenzela u-Willem Blaeu . Kungakapheli umnyaka watlolisa njengesotja emabuthweni we-''Dutch West India Company'' ukuyokulwa e-''&quot;New Holland&quot;'' (i-''Dutch Brazil'') ngo-1634. Ngemva kweminyaka emithathu, waqatjhwa njengomtloli mbusi wekoloni leyo, u-Count John Maurice, iKosana ye-Nassau-Siegen . E-Recife bekaphethe idayari enemifanekiso eli-109 yemibala yamanzi yeemfesi ezikarisako, iinyoni ezingakajayeleki, iinlwana ezilisizo neziyingozi, iinthelo ezimnandi neenbungu ezimbi ezinetjhefu, nabantu abakhulu, abazotho nofana abanzima, nakangadangisako wababiza ngokuthi &quot;''Thier-Buch''&quot;. Kuneenthombe zefesi ezinehloko yehamura, ifesi i-filefish, i-Serranidae, ne -Cirripedia. Mhla ali-1 kuMrhayili 1641, watjhiya i-Dutch Brazil, wafika e-Texel mhla ali-17 kuMgwengweni. Wabuyela emuva e-Dresden wafika mhlana ali-12 kuNobayeni.   Ngemva kweenyanga ezine, watjhiya i-Dresden ukubuyela e-Netherlands wafika e-Amsterdam mhla ama-29 kuNtaka 1642,&lt;ref name=&quot;chu32&quot; /&gt; begodu wathola isikhundla ekhamphanini i-''Dutch East India Company'' ( NgesiDatjhi: ''Vereenigde Oostindische Compagnie,'' evame ukurhunyezwa ngokuthi yi-VOC).

=== Ikhambo LamaDatjhi Lokuya ENdiya ===
[[Isimumathi:Meireki_fire.JPG|thumb|UmLilo omKhulu we-Meireki owathatha amalanga amathathu begodu kungenzeka ubangele ukufa kwabantu abayi-100,000. Imizamo yokwakha kabutjha yathatha iminyaka emibili, njengoba i-''shogunate'' yathatha ithuba lokuhlela kabutjha idorobha ngokuya ngezinto ezihlukahlukeneko eziphathekako.]]
Mhla amalanga ama-29 kuKhukhulamungu ngo-1642 wakhamba ngesikepe asendleleni etjhinga eNdiya njengomuntu oyokufunda umsebenzi (NgesiDatjhi: ''adelborst'').  Wafika e-Batavia mhla ali-17 kuMrhayili 1643 ngesikepe i-Zwaan begodu msinyana ngemva kwalokho waqatjhwa Mbusi u-Antonie van Diemen njengomkopitjhi. Bekaqalwa njengomdwebi owakopa imifanekiso engaphezu kwama-50 phakathi kukaMgwengweni noNobayeni 1643 wayidweba encwadini esemthethweni yekhamba lika-Abel Tasman lango-1642-43 lapha u-Tasman waba mumuntu wokuthoma we-Yurobhu ukubona i-Tasmania, e-New Zealand kanye neenhlengele ezinengi ze-''Tongan Archipelago''.  Ngo-1646 waba mthengisi ongaphasi kwabanye abathengisi begodu ngo-1651 waba mthengisi ozijameleko. Kathathu waba lilunga leKhotho yoBulungiswa e-Batavia. Ngo-1653 waya e-Canton ukuyokuvula ubudlelwano bokurhweba, okwaba yinto engasizi ngalitho, ngebanga lepi yombango ngemva kokuwa kwe-&lt;nowiki&gt;&lt;i&gt;Ming Dynasty&lt;/i&gt;&lt;/nowiki&gt;.

Ngo-1657 waphakama ngesikhundla waba yi-&lt;nowiki&gt;&lt;i&gt;opperhoofd&lt;/i&gt;&lt;/nowiki&gt; (isikhulu esiphezulu) se-VOC esihlengeleni esincani e- ''Nagasaki Bay'' esihlengeleni seJapani se-Kyushu, e-Dejima. Wakhamba waya enhlokodorobha ye-Edo ngomsebenzi wejima lamaDatjhi begodu waphunyuka edorobheni ebelitjha, okwathoma mhla ama-2 kuNtaka 1657. (Kunomdwebo wesandla sakhe eMnyuziyamu we-Edo-Tokyo .) Ngo-1659, njengomunye &quot;we-''opperhoofden''&quot; yokuthoma, wahlela isidlo sakusihlwa, ebesinokudla okuma-20 okuhlukahlukeneko.  : U-Wagener wenza umtlamo we- &lt;nowiki&gt;&lt;i&gt;porcelain&lt;/i&gt;&lt;/nowiki&gt; yeJapani, ngokuya ngendlela yokuhlelwa kwesidlo ye-Europe ekhamba ibe nombala mhlophe nohlaza komkayi, nangamathuthumbo amanengi.  

Ngo-1660 u-Wagner wabandakanyeka emikhulumiswaneni yokuthula nekosi ye-Makassar. Itheku belinabarhwebi bamaPutukezi abangaba ziin-2000 begodu iminyaka eminengi belithusela ukuqeda ukurhweba ngeenungo e-Moluccas. Ngomnyaka olandelako waba yihloko yezemiSebenzi yomPhakathi e-Batavia.

Ngo-1662 waya e -Cape of Good Hope nomndenakhe omncani, iinceku ezihlanu neenjomani ezimbili. Walandela u-Jan van Riebeeck njengombusi mhla asi-6 kuMrhayili womnyaka loyo. U-Riebeeck wasuka ngelanga elilandelako. NgoNobayeni 1663 wabawa i-Batavia bona imthumelele izinto zokubumba iimpoto ezivela e-Persia. &lt;ref name=&quot;sch06&quot; /&gt; Wakhulumisana namaKhoikhoi ngeenkomo zeKhamphani.  Ngokuzibamba kwakhe bona angasolo akhambakhamba u-Wagener wabeka umthethomgomo wokuthi angekhe angenele eempikiswaneni zeentjhaba zendabuko begodu angekhe athathe ihlangothi. Ngemva kweminyaka emihlanu yokufunda, umfundi weJarimani u-Georg Friedrich Wreede watlola isirhunyezo selimi lesiDatjhi nesi-Khoikhoi   Ngu-Wagener wamkhetha bona enze njalo nabase-Mauritius.

U-Wagener bekangomunye wabantu abahlanu ababeka isisekelo se-&lt;nowiki&gt;&lt;i&gt;Castle of Good Hope&lt;/i&gt;&lt;/nowiki&gt;, eyathonywa ngoRhoboyi wango-1665. Wakha ibulungelo lamanzi, wanikela imikhumbi ngamanzi ahlanzekileko, wakha isibhedlela, isikolo nesonto. Ngo-1666 umkakhe u-Anna Auxbrebis, ebekatjhade naye ngo-1648, wahlongakala.

=== Ipilwakhe Yekuluphaleni ===
Mhla amalanga ama-27 kuKhukhulamungu 1666 u-Wagener watjhiya umsebenzi begodu wabuyela e-Batavia nendodakazi kamkakhe. Wathengisa iingqila zakhe ezivela e-Bengal. Wakhamba nezipho waya ukuyobona i- &lt;nowiki&gt;&lt;i&gt;sushunan&lt;/i&gt;&lt;/nowiki&gt; namkha umbusi we-Mataram, owala ukurhweba ne-VOC. Wathoma ikhambo leli anelwazi elincani lelimi lesiMalay nofana lesi-Javan, begodu umphumela womnqopho loyo khenge umsebenzele kuhle. Nanyana kunjalo, u-Wagener wavakatjhela i-Japara ngemva kwalokho. Ngemva komnyaka wabuyela emva e-Amsterdam njengesekela lomphathi omkhulu wezepi enarheni, kodwana bekagula. Wangcwatjwa mhlana ali-16 kuNobayeni 1668 eSontweni eliDala .

Omunye wemidwebo wedayari yakhe watjhugululwa ukusuka ku-&lt;nowiki&gt;&lt;i&gt;High Dutch&lt;/i&gt;&lt;/nowiki&gt; ukuya esiNgisini begodu wagadangiswa ngo-1704 nango-1732. Umtlolo wesandla onomdwebo wona loyo—kodwana ongesiJarimani—bewuyingcenye yeButhelelo lemiGadangiso neeNthombe (NgesiJamrimani ''Kupferstich-Kabinett'') we-&lt;nowiki&gt;&lt;i&gt;Dresden State Art Collections&lt;/i&gt;&lt;/nowiki&gt; kusukela ekuthomeni kwekhulu le-18. &lt;ref name=&quot;michel87&quot; /&gt;

=== Idlhego Lakhe Njenge-''Opperhoofd'' ===
U-Wagner wasebenza amathemu amabili njengo -&lt;nowiki&gt;&lt;i&gt;opperhoofd&lt;/i&gt;&lt;/nowiki&gt; ngokutjhuguluka no[[Joan Boucheljon|-Joan Boucheljon]] :

* U-Joan Bouchelion: 23 kuSewula1655 - 1 kuSinyikhaba 1656
* U-Zacharias Wagenaer [Wagener]: 1 kuSinyikhaba 1656 - 27 kuSewula 1657
* U-Joan Bouchelion: 27 kuSewula 1657 - 23 kuSewula 1658
* U-Zacharias Wagenaer [Wagener]: 22 kuSewula 1658 - 4 kuSinyikhaba 1659
* U-Joan Bouchelion: 4 kuSinyikhaba 1659 - 26 kuSewula 1660

== Ibuthelelo Leenthombe Zakhe ==
&lt;gallery&gt;
Isimumathi:Zacharias_Wagner_-_Insetos.jpg|alt=Insects, Kupferstich-Kabinett (Dresden)| Iinunwana, i-Kupferstich-Kabinett (Dresden)
Isimumathi:Zacharias_Wagner_-_Caranguejo.jpg|alt=Caranguejo (crab)| I-Caranguejo (ikala)
&lt;/gallery&gt;

== Iinkomba ==

[[Mkhakha:Pages with unreviewed translations]]</text>
      <sha1>gmllraljs3e2bpyia5o4oufr7evevvg</sha1>
    </revision>
    <revision>
      <id>6663</id>
      <parentid>6491</parentid>
      <timestamp>2026-05-31T16:38:33Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <minor />
      <comment>edited</comment>
      <origin>6663</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8146" sha1="31r78k7l40d3xhhjlouy6yxqvxxio92" xml:space="preserve">

'''U-Zacharias Wagenaer''' (owaziwa ngo ''-Wagener'', ''Wagenaar'' no ''-Wagner'' ) (10 Meyi 1614 – 12 Okthoba 1668) bekangumtloli womDatjhi owabelethelwa e-Germany, umdwebi weenthombe, umthengisi, ilunga leKhotho yoBulungiswa, umphathi we-Deshima kanye nomnqophisi weKoloni yamaDatjhi eseKapa. Eminyakeni ema-35 wakhamba iinarhakazi ezine.

== Umlando ==

=== Ipilwakhe Yekukhuleni Nebizelo ===
U-Zacharias bekayindodana yejaji yom-''Saxon'' nomdwebi. Ngo-1633 wasuka e-Dresden wadlula e-Hamburg waya e -Amsterdam . Lapho wasebenzela u-Willem Blaeu . Kungakapheli umnyaka watlolisa njengesotja emabuthweni we-''Dutch West India Company'' ukuyokulwa e-''&quot;New Holland&quot;'' (i-''Dutch Brazil'') ngo-1634. Ngemva kweminyaka emithathu, waqatjhwa njengomtloli mbusi wekoloni leyo, u-Count John Maurice, iKosana ye-Nassau-Siegen . E-Recife bekaphethe idayari enemifanekiso eli-109 yemibala yamanzi yeemfesi ezikarisako, iinyoni ezingakajayeleki, iinlwana ezilisizo neziyingozi, iinthelo ezimnandi neenbungu ezimbi ezinetjhefu, nabantu abakhulu, abazotho nofana abanzima, nakangadangisako wababiza ngokuthi &quot;''Thier-Buch''&quot;. Kuneenthombe zefesi ezinehloko yehamura, ifesi i-filefish, i-Serranidae, ne -Cirripedia. Mhla ali-1 kuMrhayili 1641, watjhiya i-Dutch Brazil, wafika e-Texel mhla ali-17 kuMgwengweni. Wabuyela emuva e-Dresden wafika mhlana ali-12 kuNobayeni.&lt;ref&gt;Churchill, Awnsham; Churchill, John (1704). &quot;A Short Account of the Voyages of Mr. Zachary Wagener, Perform'd in 35 Years, Through Europe, Asia, Africa and America, Taken out of his own Journal.&quot; Retrieved on: https://babel.hathitrust.org/cgi/pt?id=aeu.ark:/13960/t05x2tr82&amp;view=1up&amp;seq=725. Retrieved on 31/05/2026.&lt;/ref&gt;&lt;ref&gt;Zacharias Wagner and Japan (I)&amp;nbsp;&amp;#x2013;&amp;nbsp;The Autobiography of a 'Thunderman'&amp;#x5D;. ''Dokufutsu Bungaku Kenkyû'' (in German) (37). Fukoka: Kyushu University: 53–102. Archived (PDF) from the original on 23 November 2016. Retrieved from: https://wolfgangmichel.web.fc2.com/publ/aufs/28/28.htm. Retrieved on 31/05/2026.&lt;/ref&gt;   Ngemva kweenyanga ezine, watjhiya i-Dresden ukubuyela e-Netherlands wafika e-Amsterdam mhla ama-29 kuNtaka 1642,&lt;ref&gt;Churchill, Awnsham; Churchill, John (1732). &quot;A Short Account of the Voyages of Mr. Zachary Wagener, Perform'd in thirty five Years, Through Europe, Asia, Africa and America, Taken out of his own Journal&quot;.Retrieved from: https://archive.org/details/cihm_33298/page/n22/mode/1up. Retrieved on 31/05/2026.&lt;/ref&gt; begodu wathola isikhundla ekhamphanini i-''Dutch East India Company'' ( NgesiDatjhi: ''Vereenigde Oostindische Compagnie,'' evame ukurhunyezwa ngokuthi yi-VOC).

=== Ikhambo LamaDatjhi Lokuya ENdiya ===
[[Isimumathi:Meireki_fire.JPG|thumb|UmLilo omKhulu we-Meireki owathatha amalanga amathathu begodu kungenzeka ubangele ukufa kwabantu abayi-100,000. Imizamo yokwakha kabutjha yathatha iminyaka emibili, njengoba i-''shogunate'' yathatha ithuba lokuhlela kabutjha idorobha ngokuya ngezinto ezihlukahlukeneko eziphathekako.]]
Mhla amalanga ama-29 kuKhukhulamungu ngo-1642 wakhamba ngesikepe asendleleni etjhinga eNdiya njengomuntu oyokufunda umsebenzi (NgesiDatjhi: ''adelborst'').  Wafika e-Batavia mhla ali-17 kuMrhayili 1643 ngesikepe i-Zwaan begodu msinyana ngemva kwalokho waqatjhwa Mbusi u-Antonie van Diemen njengomkopitjhi. Bekaqalwa njengomdwebi owakopa imifanekiso engaphezu kwama-50 phakathi kukaMgwengweni noNobayeni 1643 wayidweba encwadini esemthethweni yekhamba lika-Abel Tasman lango-1642-43 lapha u-Tasman waba mumuntu wokuthoma we-Yurobhu ukubona i-Tasmania, e-New Zealand kanye neenhlengele ezinengi ze-''Tongan Archipelago''.  Ngo-1646 waba mthengisi ongaphasi kwabanye abathengisi begodu ngo-1651 waba mthengisi ozijameleko. Kathathu waba lilunga leKhotho yoBulungiswa e-Batavia. Ngo-1653 waya e-Canton ukuyokuvula ubudlelwano bokurhweba, okwaba yinto engasizi ngalitho, ngebanga lepi yombango ngemva kokuwa kwe-&lt;nowiki&gt;&lt;i&gt;Ming Dynasty&lt;/i&gt;&lt;/nowiki&gt;.

Ngo-1657 waphakama ngesikhundla waba yi-&lt;nowiki&gt;&lt;i&gt;opperhoofd&lt;/i&gt;&lt;/nowiki&gt; (isikhulu esiphezulu) se-VOC esihlengeleni esincani e- ''Nagasaki Bay'' esihlengeleni seJapani se-Kyushu, e-Dejima. Wakhamba waya enhlokodorobha ye-Edo ngomsebenzi wejima lamaDatjhi begodu waphunyuka edorobheni ebelitjha, okwathoma mhla ama-2 kuNtaka 1657. (Kunomdwebo wesandla sakhe eMnyuziyamu we-Edo-Tokyo .) Ngo-1659, njengomunye &quot;we-''opperhoofden''&quot; yokuthoma, wahlela isidlo sakusihlwa, ebesinokudla okuma-20 okuhlukahlukeneko.  : U-Wagener wenza umtlamo we- &lt;nowiki&gt;&lt;i&gt;porcelain&lt;/i&gt;&lt;/nowiki&gt; yeJapani, ngokuya ngendlela yokuhlelwa kwesidlo ye-Europe ekhamba ibe nombala mhlophe nohlaza komkayi, nangamathuthumbo amanengi.  

Ngo-1660 u-Wagner wabandakanyeka emikhulumiswaneni yokuthula nekosi ye-Makassar. Itheku belinabarhwebi bamaPutukezi abangaba ziin-2000 begodu iminyaka eminengi belithusela ukuqeda ukurhweba ngeenungo e-Moluccas. Ngomnyaka olandelako waba yihloko yezemiSebenzi yomPhakathi e-Batavia.

Ngo-1662 waya e -Cape of Good Hope nomndenakhe omncani, iinceku ezihlanu neenjomani ezimbili. Walandela u-Jan van Riebeeck njengombusi mhla asi-6 kuMrhayili womnyaka loyo. U-Riebeeck wasuka ngelanga elilandelako. NgoNobayeni 1663 wabawa i-Batavia bona imthumelele izinto zokubumba iimpoto ezivela e-Persia.&lt;ref&gt;Mack, Rudiger (2024). ''First Encounters. The Early Pacific and European Narratives of Abel Tasman's 1642 Voyage''. Feilding, New Zealand: Heritage Press. pp.&amp;nbsp;187–196. ISBN&amp;nbsp;&lt;bdi&gt;9781991097002&lt;/bdi&gt;.&lt;/ref&gt; Wakhulumisana namaKhoikhoi ngeenkomo zeKhamphani.  Ngokuzibamba kwakhe bona angasolo akhambakhamba u-Wagener wabeka umthethomgomo wokuthi angekhe angenele eempikiswaneni zeentjhaba zendabuko begodu angekhe athathe ihlangothi. Ngemva kweminyaka emihlanu yokufunda, umfundi weJarimani u-Georg Friedrich Wreede watlola isirhunyezo selimi lesiDatjhi nesi-Khoikhoi   Ngu-Wagener wamkhetha bona enze njalo nabase-Mauritius.

U-Wagener bekangomunye wabantu abahlanu ababeka isisekelo se-&lt;nowiki&gt;&lt;i&gt;Castle of Good Hope&lt;/i&gt;&lt;/nowiki&gt;, eyathonywa ngoRhoboyi wango-1665. Wakha ibulungelo lamanzi, wanikela imikhumbi ngamanzi ahlanzekileko, wakha isibhedlela, isikolo nesonto. Ngo-1666 umkakhe u-Anna Auxbrebis, ebekatjhade naye ngo-1648, wahlongakala.

=== Ipilwakhe Yekuluphaleni ===
Mhla amalanga ama-27 kuKhukhulamungu 1666 u-Wagener watjhiya umsebenzi begodu wabuyela e-Batavia nendodakazi kamkakhe. Wathengisa iingqila zakhe ezivela e-Bengal. Wakhamba nezipho waya ukuyobona i- &lt;nowiki&gt;&lt;i&gt;sushunan&lt;/i&gt;&lt;/nowiki&gt; namkha umbusi we-Mataram, owala ukurhweba ne-VOC. Wathoma ikhambo leli anelwazi elincani lelimi lesiMalay nofana lesi-Javan, begodu umphumela womnqopho loyo khenge umsebenzele kuhle. Nanyana kunjalo, u-Wagener wavakatjhela i-Japara ngemva kwalokho. Ngemva komnyaka wabuyela emva e-Amsterdam njengesekela lomphathi omkhulu wezepi enarheni, kodwana bekagula. Wangcwatjwa mhlana ali-16 kuNobayeni 1668 eSontweni eliDala .

Omunye wemidwebo wedayari yakhe watjhugululwa ukusuka ku-&lt;nowiki&gt;&lt;i&gt;High Dutch&lt;/i&gt;&lt;/nowiki&gt; ukuya esiNgisini begodu wagadangiswa ngo-1704 nango-1732. Umtlolo wesandla onomdwebo wona loyo—kodwana ongesiJarimani—bewuyingcenye yeButhelelo lemiGadangiso neeNthombe (NgesiJamrimani ''Kupferstich-Kabinett'') we-&lt;nowiki&gt;&lt;i&gt;Dresden State Art Collections&lt;/i&gt;&lt;/nowiki&gt; kusukela ekuthomeni kwekhulu le-18. &lt;ref name=&quot;michel87&quot; /&gt;

=== Idlhego Lakhe Njenge-''Opperhoofd'' ===
U-Wagner wasebenza amathemu amabili njengo -&lt;nowiki&gt;&lt;i&gt;opperhoofd&lt;/i&gt;&lt;/nowiki&gt; ngokutjhuguluka no[[Joan Boucheljon|-Joan Boucheljon]] :

* U-Joan Bouchelion: 23 kuSewula1655 - 1 kuSinyikhaba 1656
* U-Zacharias Wagenaer [Wagener]: 1 kuSinyikhaba 1656 - 27 kuSewula 1657
* U-Joan Bouchelion: 27 kuSewula 1657 - 23 kuSewula 1658
* U-Zacharias Wagenaer [Wagener]: 22 kuSewula 1658 - 4 kuSinyikhaba 1659
* U-Joan Bouchelion: 4 kuSinyikhaba 1659 - 26 kuSewula 1660

== Ibuthelelo Leenthombe Zakhe ==
&lt;gallery&gt;
Isimumathi:Zacharias_Wagner_-_Insetos.jpg|alt=Insects, Kupferstich-Kabinett (Dresden)| Iinunwana, i-Kupferstich-Kabinett (Dresden)
Isimumathi:Zacharias_Wagner_-_Caranguejo.jpg|alt=Caranguejo (crab)| I-Caranguejo (ikala)
&lt;/gallery&gt;

== Iinkomba ==

[[Mkhakha:Pages with unreviewed translations]]</text>
      <sha1>31r78k7l40d3xhhjlouy6yxqvxxio92</sha1>
    </revision>
    <revision>
      <id>6664</id>
      <parentid>6663</parentid>
      <timestamp>2026-05-31T17:07:15Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <origin>6664</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9575" sha1="snc4cs1u245k8ekxd3q8wv9pmzhrf93" xml:space="preserve">

'''U-Zacharias Wagenaer''' (owaziwa ngo''-Wagener'', namkha u-''Wagenaar'' nnamkha u''-Wagner'' ) (10 Meyi 1614 – 12 Okthoba 1668) bekangumtloli womDatjhi owabelethelwa e-Germany, umdwebi weenthombe, umthengisi, ilunga leKhotho yoBulungiswa, umphathi we-Deshima kanye nomnqophisi weKoloni yamaDatjhi eseKapa. Eminyakeni ema-35 wakhamba iinarhakazi ezine.

== Umlando ==

=== Ipilwakhe Yekukhuleni Nebizelo ===
U-Zacharias bekayindodana yejaji yom-''Saxon'' nomdwebi. Ngo-1633 wasuka e-Dresden wadlula e-Hamburg waya e -Amsterdam . Lapho wasebenzela u-Willem Blaeu . Kungakapheli umnyaka watlolisa njengesotja emabuthweni we-''Dutch West India Company'' ukuyokulwa e-''&quot;New Holland&quot;'' (i-''Dutch Brazil'') ngo-1634. Ngemva kweminyaka emithathu, waqatjhwa njengomtloli mbusi wekoloni leyo, u-Count John Maurice, iKosana ye-Nassau-Siegen . E-Recife bekaphethe idayari enemifanekiso eli-109 yemibala yamanzi yeemfesi ezikarisako, iinyoni ezingakajayeleki, iinlwana ezilisizo neziyingozi, iinthelo ezimnandi neenbungu ezimbi ezinetjhefu, nabantu abakhulu, abazotho nofana abanzima, nakangadangisako wababiza ngokuthi &quot;''Thier-Buch''&quot;. Kuneenthombe zefesi ezinehloko yehamura, ifesi i-filefish, i-Serranidae, ne -Cirripedia. Mhla ali-1 kuMrhayili 1641, watjhiya i-Dutch Brazil, wafika e-Texel mhla ali-17 kuMgwengweni. Wabuyela emuva e-Dresden wafika mhlana ali-12 kuNobayeni.&lt;ref name=&quot;:0&quot;&gt;Churchill, Awnsham; Churchill, John (1704). &quot;A Short Account of the Voyages of Mr. Zachary Wagener, Perform'd in 35 Years, Through Europe, Asia, Africa and America, Taken out of his own Journal.&quot; Retrieved on: https://babel.hathitrust.org/cgi/pt?id=aeu.ark:/13960/t05x2tr82&amp;view=1up&amp;seq=725. Retrieved on 31/05/2026.&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;Zacharias Wagner and Japan (I)&amp;nbsp;&amp;#x2013;&amp;nbsp;The Autobiography of a 'Thunderman'&amp;#x5D;. ''Dokufutsu Bungaku Kenkyû'' (in German) (37). Fukoka: Kyushu University: 53–102. Archived (PDF) from the original on 23 November 2016. Retrieved from: https://wolfgangmichel.web.fc2.com/publ/aufs/28/28.htm. Retrieved on 31/05/2026.&lt;/ref&gt;   Ngemva kweenyanga ezine, watjhiya i-Dresden ukubuyela e-Netherlands wafika e-Amsterdam mhla ama-29 kuNtaka 1642,&lt;ref name=&quot;:2&quot;&gt;Churchill, Awnsham; Churchill, John (1732). &quot;A Short Account of the Voyages of Mr. Zachary Wagener, Perform'd in thirty five Years, Through Europe, Asia, Africa and America, Taken out of his own Journal&quot;.Retrieved from: https://archive.org/details/cihm_33298/page/n22/mode/1up. Retrieved on 31/05/2026.&lt;/ref&gt; begodu wathola isikhundla ekhamphanini i-''Dutch East India Company'' ( NgesiDatjhi: ''Vereenigde Oostindische Compagnie,'' evame ukurhunyezwa ngokuthi yi-VOC).

=== Ikhambo LamaDatjhi Lokuya ENdiya ===
[[Isimumathi:Meireki_fire.JPG|thumb|UmLilo omKhulu we-Meireki owathatha amalanga amathathu begodu kungenzeka ubangele ukufa kwabantu abayi-100,000. Imizamo yokwakha kabutjha yathatha iminyaka emibili, njengoba i-''shogunate'' yathatha ithuba lokuhlela kabutjha idorobha ngokuya ngezinto ezihlukahlukeneko eziphathekako.]]
Mhla amalanga ama-29 kuKhukhulamungu ngo-1642 wakhamba ngesikepe asendleleni etjhinga eNdiya njengomuntu oyokufunda umsebenzi (NgesiDatjhi: ''adelborst'').  Wafika e-Batavia mhla ali-17 kuMrhayili 1643 ngesikepe i-Zwaan begodu msinyana ngemva kwalokho waqatjhwa Mbusi u-Antonie van Diemen njengomkopitjhi. Bekaqalwa njengomdwebi owakopa imifanekiso engaphezu kwama-50 phakathi kukaMgwengweni noNobayeni 1643 wayidweba encwadini esemthethweni yekhamba lika-Abel Tasman lango-1642-43 lapha u-Tasman waba mumuntu wokuthoma we-Yurobhu ukubona i-Tasmania, e-New Zealand kanye neenhlengele ezinengi ze-''Tongan Archipelago''.&lt;ref&gt;Mack, Rudiger (2024). ''First Encounters. The Early Pacific and European Narratives of Abel Tasman's 1642 Voyage''. Feilding, New Zealand: Heritage Press. pp.&amp;nbsp;187–196. ISBN&amp;nbsp;&lt;bdi&gt;9781991097002&lt;/bdi&gt;.&lt;/ref&gt;  Ngo-1646 waba mthengisi ongaphasi kwabanye abathengisi begodu ngo-1651 waba mthengisi ozijameleko. Kathathu waba lilunga leKhotho yoBulungiswa e-Batavia. Ngo-1653 waya e-Canton ukuyokuvula ubudlelwano bokurhweba, okwaba yinto engasizi ngalitho, ngebanga lepi yombango ngemva kokuwa kwe-''Ming Dynasty''.

Ngo-1657 waphakama ngesikhundla waba yi-''opperhoofd'' (isikhulu esiphezulu) se-VOC esihlengeleni esincani e- ''Nagasaki Bay'' esihlengeleni seJapani se-Kyushu, e-Dejima. Wakhamba waya enhlokodorobha ye-Edo ngomsebenzi wejima lamaDatjhi begodu waphunyuka edorobheni ebelitjha, okwathoma mhla ama-2 kuNtaka 1657. (Kunomdwebo wesandla sakhe eMnyuziyamu we-Edo-Tokyo .) Ngo-1659, njengomunye &quot;we-''opperhoofden''&quot; yokuthoma, wahlela isidlo sakusihlwa, ebesinokudla okuma-200 okuhlukahlukeneko.&lt;ref name=&quot;:3&quot;&gt;Schoeman, Karel (2006). ''Kinders van die Kompanjie'' (in Afrikaans). Pretoria: Protea Boekehuis. ISBN&amp;nbsp;&lt;bdi&gt;1869191196&lt;/bdi&gt;.&lt;/ref&gt;  : U-Wagener wenza umtlamo we-''porcelain'' yeJapani, ngokuya ngendlela yokuhlelwa kwesidlo ye-Europe ekhamba ibe nombala mhlophe nohlaza komkayi, nangamathuthumbo amanengi.  

Ngo-1660 u-Wagner wabandakanyeka emikhulumiswaneni yokuthula nekosi ye-Makassar. Itheku belinabarhwebi bamaPutukezi abangaba ziin-2000 begodu iminyaka eminengi belithusela ukuqeda ukurhweba ngeenungo e-Moluccas. Ngomnyaka olandelako waba yihloko yezemiSebenzi yomPhakathi e-Batavia.

=== Ikoloni YamaDatjhi EseKapa ===
Ngo-1662 waya e-Cape of Good Hope nomndenakhe omncani, iinceku ezihlanu neenjomani ezimbili.&lt;ref name=&quot;:3&quot; /&gt; Walandela u-Jan van Riebeeck njengombusi mhla asi-6 kuMrhayili womnyaka loyo. U-Riebeeck wasuka ngelanga elilandelako. NgoNobayeni 1663 wabawa i-Batavia bona imthumelele izinto zokubumba iimpoto ezivela e-Persia.&lt;ref&gt;Mack, Rudiger (2024). ''First Encounters. The Early Pacific and European Narratives of Abel Tasman's 1642 Voyage''. Feilding, New Zealand: Heritage Press. pp.&amp;nbsp;187–196. ISBN&amp;nbsp;&lt;bdi&gt;9781991097002&lt;/bdi&gt;.&lt;/ref&gt; Wakhulumisana namaKhoikhoi ngeenkomo zeKhamphani.&lt;ref&gt;Theal, George MacCall (1897). ''History of South Africa Under the Administration of the Dutch East India Company, 1652 to 1795'' (2nd&amp;nbsp;ed.). London: Swan Sonnenschein &amp; Co. OCLC&amp;nbsp;25939696. https://archive.org/details/historysouthafr01theagoog/page/n3/mode/2up. Retrieved 24 February 2020.&lt;/ref&gt;  Ngokuzibamba kwakhe bona angasolo akhambakhamba u-Wagener wabeka umthethomgomo wokuthi angekhe angenele eempikiswaneni zeentjhaba zendabuko begodu angekhe athathe ihlangothi. Ngemva kweminyaka emihlanu yokufunda, umfundi weJarimani u-Georg Friedrich Wreede watlola isirhunyezo selimi lesiDatjhi nesi-Khoikhoi.&lt;ref&gt;Wreede, Georg Friedrich (1916). Godée-Molsbergen, Everhardus Cornelius (ed.). ''G.F. Wreede's Hottentotse Woordelijst''. Reizen in Zuid-Afrika in de hollandse tijd. Vol.&amp;nbsp;1. 's-Gravenhage: Martinus Nijhoff. pp.&amp;nbsp;215–224.&lt;/ref&gt;   Ngu-Wagener wamkhetha bona enze njalo nabase-Mauritius.&lt;ref&gt;den Besten, Hans (2010). Huigen, Siegfried; de Jong, Jan L.; Kolfin, Elmer; et&amp;nbsp;al. (eds.). &quot;A badly harvested field: The growth of linguistic knowledge and the Dutch Cape colony until 1796&quot; (PDF)Retrieved from:https://web.archive.org/web/20200224011331/https://pdfs.semanticscholar.org/e8ad/25af90e01c4130dc42f8a8c9253d76305b84.pdf Retrieved on 31/05/2026.&lt;/ref&gt;

U-Wagener bekangomunye wabantu abahlanu ababeka isisekelo se-''Castle of Good Hope'', eyathonywa ngoRhoboyi wango-1665.&lt;ref&gt;Spohr, Otto H; Wagner, Zacharias (1967). ''Zacharias Wagner, second commander of the Cape''. Cape Town, Amsterdam: A.A. Balkema. OCLC&amp;nbsp;3424966.&lt;/ref&gt; Wakha ibulungelo lamanzi, wanikela imikhumbi ngamanzi ahlanzekileko, wakha isibhedlela, isikolo nesonto. Ngo-1666 umkakhe u-Anna Auxbrebis, ebekatjhade naye ngo-1648, wahlongakala.

=== Ipilwakhe Yekuluphaleni ===
Mhla amalanga ama-27 kuKhukhulamungu 1666 u-Wagener watjhiya umsebenzi begodu wabuyela e-Batavia nendodakazi kamkakhe. Wathengisa iingqila zakhe ezivela e-Bengal. Wakhamba nezipho waya ukuyobona i-''sushunan'' namkha umbusi we-Mataram, owala ukurhweba ne-VOC. Wathoma ikhambo leli anelwazi elincani lelimi lesiMalay nofana lesi-Javan, begodu umphumela womnqopho loyo khenge umsebenzele kuhle. Nanyana kunjalo, u-Wagener wavakatjhela i-Japara ngemva kwalokho. Ngemva komnyaka wabuyela emva e-Amsterdam njengesekela lomphathi omkhulu wezepi enarheni, kodwana bekagula. Wangcwatjwa mhlana ali-16 kuNobayeni 1668 eSontweni eliDala .

Omunye wemidwebo wedayari yakhe watjhugululwa ukusuka ku-''High Dutch'' ukuya esiNgisini begodu wagadangiswa ngo-1704 nango-1732.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;&lt;ref name=&quot;:0&quot; /&gt; Umtlolo wesandla onomdwebo wona loyo—kodwana ongesiJarimani—bewuyingcenye yeButhelelo lemiGadangiso neeNthombe (NgesiJamrimani ''Kupferstich-Kabinett'') we-''Dresden State Art Collections'' kusukela ekuthomeni kwekhulu le-18.&lt;ref name=&quot;:0&quot; /&gt;

=== Idlhego Lakhe Njenge-''Opperhoofd'' ===
U-Wagner wasebenza amathemu amabili njengo-''opperhoofd'' ngokutjhuguluka no[[Joan Boucheljon|-Joan Boucheljon]] :

* U-Joan Bouchelion: 23 kuSewula1655 - 1 kuSinyikhaba 1656
* U-Zacharias Wagenaer [Wagener]: 1 kuSinyikhaba 1656 - 27 kuSewula 1657
* U-Joan Bouchelion: 27 kuSewula 1657 - 23 kuSewula 1658
* U-Zacharias Wagenaer [Wagener]: 22 kuSewula 1658 - 4 kuSinyikhaba 1659
* U-Joan Bouchelion: 4 kuSinyikhaba 1659 - 26 kuSewula 1660

== Ibuthelelo Leenthombe Zakhe ==
&lt;gallery&gt;
Isimumathi:Zacharias_Wagner_-_Insetos.jpg|alt=Insects, Kupferstich-Kabinett (Dresden)| Iinunwana, i-Kupferstich-Kabinett (Dresden)
Isimumathi:Zacharias_Wagner_-_Caranguejo.jpg|alt=Caranguejo (crab)| I-Caranguejo (ikala)
&lt;/gallery&gt;

== Iinkomba ==

[[Mkhakha:Pages with unreviewed translations]]</text>
      <sha1>snc4cs1u245k8ekxd3q8wv9pmzhrf93</sha1>
    </revision>
    <revision>
      <id>6665</id>
      <parentid>6664</parentid>
      <timestamp>2026-05-31T20:44:12Z</timestamp>
      <contributor>
        <username>Mosakaruka</username>
        <id>586</id>
      </contributor>
      <comment>edited</comment>
      <origin>6665</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="9598" sha1="hwsxl90l1hmyexczrjd3a8e474vk6pk" xml:space="preserve">

'''U-Zacharias Wagenaer''' (owaziwa ngo''-Wagener'', namkha u-''Wagenaar'' nnamkha u''-Wagner'' ) (10 Meyi 1614 – 12 Okthoba 1668) bekangumtloli womDatjhi owabelethelwa e-Germany, umdwebi weenthombe, umthengisi, ilunga leKhotho yoBulungiswa, umphathi we-Deshima kanye nomnqophisi weKoloni yamaDatjhi eseKapa. Eminyakeni ema-35 wakhamba iinarhakazi ezine.

== Umlando ==

=== Ipilwakhe Yekukhuleni Nebizelo ===
U-Zacharias bekayindodana yejaji yom-''Saxon'' nomdwebi. Ngo-1633 wasuka e-Dresden wadlula e-Hamburg waya e -Amsterdam . Lapho wasebenzela u-Willem Blaeu . Kungakapheli umnyaka watlolisa njengesotja emabuthweni we-''Dutch West India Company'' ukuyokulwa e-''&quot;New Holland&quot;'' (i-''Dutch Brazil'') ngo-1634. Ngemva kweminyaka emithathu, waqatjhwa njengomtloli mbusi wekoloni leyo, u-Count John Maurice, iKosana ye-Nassau-Siegen . E-Recife bekaphethe idayari enemifanekiso eli-109 yemibala yamanzi yeemfesi ezikarisako, iinyoni ezingakajayeleki, iinlwana ezilisizo neziyingozi, iinthelo ezimnandi neenbungu ezimbi ezinetjhefu, nabantu abakhulu, abazotho nofana abanzima, nakangadangisako wababiza ngokuthi &quot;''Thier-Buch''&quot;. Kuneenthombe zefesi ezinehloko yehamura, ifesi i-filefish, i-Serranidae, ne -Cirripedia. Mhla ali-1 kuMrhayili 1641, watjhiya i-Dutch Brazil, wafika e-Texel mhla ali-17 kuMgwengweni. Wabuyela emuva e-Dresden wafika mhlana ali-12 kuNobayeni.&lt;ref name=&quot;:0&quot;&gt;Churchill, Awnsham; Churchill, John (1704). &quot;A Short Account of the Voyages of Mr. Zachary Wagener, Perform'd in 35 Years, Through Europe, Asia, Africa and America, Taken out of his own Journal.&quot; Retrieved on: https://babel.hathitrust.org/cgi/pt?id=aeu.ark:/13960/t05x2tr82&amp;view=1up&amp;seq=725. Retrieved on 31/05/2026.&lt;/ref&gt;&lt;ref name=&quot;:1&quot;&gt;Zacharias Wagner and Japan (I)&amp;nbsp;&amp;#x2013;&amp;nbsp;The Autobiography of a 'Thunderman'&amp;#x5D;. ''Dokufutsu Bungaku Kenkyû'' (in German) (37). Fukoka: Kyushu University: 53–102. Archived (PDF) from the original on 23 November 2016. Retrieved from: https://wolfgangmichel.web.fc2.com/publ/aufs/28/28.htm. Retrieved on 31/05/2026.&lt;/ref&gt;   Ngemva kweenyanga ezine, watjhiya i-Dresden ukubuyela e-Netherlands wafika e-Amsterdam mhla ama-29 kuNtaka 1642,&lt;ref name=&quot;:2&quot;&gt;Churchill, Awnsham; Churchill, John (1732). &quot;A Short Account of the Voyages of Mr. Zachary Wagener, Perform'd in thirty five Years, Through Europe, Asia, Africa and America, Taken out of his own Journal&quot;.Retrieved from: https://archive.org/details/cihm_33298/page/n22/mode/1up. Retrieved on 31/05/2026.&lt;/ref&gt; begodu wathola isikhundla ekhamphanini i-''Dutch East India Company'' ( NgesiDatjhi: ''Vereenigde Oostindische Compagnie,'' evame ukurhunyezwa ngokuthi yi-VOC).

=== Ikhambo LamaDatjhi Lokuya ENdiya ===
[[Isimumathi:Meireki_fire.JPG|thumb|UmLilo omKhulu we-Meireki owathatha amalanga amathathu begodu kungenzeka ubangele ukufa kwabantu abayi-100,000. Imizamo yokwakha kabutjha yathatha iminyaka emibili, njengoba i-''shogunate'' yathatha ithuba lokuhlela kabutjha idorobha ngokuya ngezinto ezihlukahlukeneko eziphathekako.]]
Mhla amalanga ama-29 kuKhukhulamungu ngo-1642 wakhamba ngesikepe asendleleni etjhinga eNdiya njengomuntu oyokufunda umsebenzi (NgesiDatjhi: ''adelborst'').  Wafika e-Batavia mhla ali-17 kuMrhayili 1643 ngesikepe i-Zwaan begodu msinyana ngemva kwalokho waqatjhwa Mbusi u-Antonie van Diemen njengomkopitjhi. Bekaqalwa njengomdwebi owakopa imifanekiso engaphezu kwama-50 phakathi kukaMgwengweni noNobayeni 1643 wayidweba encwadini esemthethweni yekhamba lika-Abel Tasman lango-1642-43 lapha u-Tasman waba mumuntu wokuthoma we-Yurobhu ukubona i-Tasmania, e-New Zealand kanye neenhlengele ezinengi ze-''Tongan Archipelago''.&lt;ref&gt;Mack, Rudiger (2024). ''First Encounters. The Early Pacific and European Narratives of Abel Tasman's 1642 Voyage''. Feilding, New Zealand: Heritage Press. pp.&amp;nbsp;187–196. ISBN&amp;nbsp;&lt;bdi&gt;9781991097002&lt;/bdi&gt;.&lt;/ref&gt;  Ngo-1646 waba mthengisi ongaphasi kwabanye abathengisi begodu ngo-1651 waba mthengisi ozijameleko. Kathathu waba lilunga leKhotho yoBulungiswa e-Batavia. Ngo-1653 waya e-Canton ukuyokuvula ubudlelwano bokurhweba, okwaba yinto engasizi ngalitho, ngebanga lepi yombango ngemva kokuwa kwe-''Ming Dynasty''.

Ngo-1657 waphakama ngesikhundla waba yi-''opperhoofd'' (isikhulu esiphezulu) se-VOC esihlengeleni esincani e- ''Nagasaki Bay'' esihlengeleni seJapani se-Kyushu, e-Dejima. Wakhamba waya enhlokodorobha ye-Edo ngomsebenzi wejima lamaDatjhi begodu waphunyuka edorobheni ebelitjha, okwathoma mhla ama-2 kuNtaka 1657. (Kunomdwebo wesandla sakhe eMnyuziyamu we-Edo-Tokyo .) Ngo-1659, njengomunye &quot;we-''opperhoofden''&quot; yokuthoma, wahlela isidlo sakusihlwa, ebesinokudla okuma-200 okuhlukahlukeneko.&lt;ref name=&quot;:3&quot;&gt;Schoeman, Karel (2006). ''Kinders van die Kompanjie'' (in Afrikaans). Pretoria: Protea Boekehuis. ISBN&amp;nbsp;&lt;bdi&gt;1869191196&lt;/bdi&gt;.&lt;/ref&gt;  : U-Wagener wenza umtlamo we-''porcelain'' yeJapani, ngokuya ngendlela yokuhlelwa kwesidlo ye-Europe ekhamba ibe nombala mhlophe nohlaza komkayi, nangamathuthumbo amanengi.  

Ngo-1660 u-Wagner wabandakanyeka emikhulumiswaneni yokuthula nekosi ye-Makassar. Itheku belinabarhwebi bamaPutukezi abangaba ziin-2000 begodu iminyaka eminengi belithusela ukuqeda ukurhweba ngeenungo e-Moluccas. Ngomnyaka olandelako waba yihloko yezemiSebenzi yomPhakathi e-Batavia.

=== Ikoloni YamaDatjhi EseKapa ===
Ngo-1662 waya e-Cape of Good Hope nomndenakhe omncani, iinceku ezihlanu neenjomani ezimbili.&lt;ref name=&quot;:3&quot; /&gt; Walandela u-Jan van Riebeeck njengombusi mhla asi-6 kuMrhayili womnyaka loyo. U-Riebeeck wasuka ngelanga elilandelako. NgoNobayeni 1663 wabawa i-Batavia bona imthumelele izinto zokubumba iimpoto ezivela e-Persia.&lt;ref&gt;Mack, Rudiger (2024). ''First Encounters. The Early Pacific and European Narratives of Abel Tasman's 1642 Voyage''. Feilding, New Zealand: Heritage Press. pp.&amp;nbsp;187–196. ISBN&amp;nbsp;&lt;bdi&gt;9781991097002&lt;/bdi&gt;.&lt;/ref&gt; Wakhulumisana namaKhoikhoi ngeenkomo zeKhamphani.&lt;ref&gt;Theal, George MacCall (1897). ''History of South Africa Under the Administration of the Dutch East India Company, 1652 to 1795'' (2nd&amp;nbsp;ed.). London: Swan Sonnenschein &amp; Co. OCLC&amp;nbsp;25939696. https://archive.org/details/historysouthafr01theagoog/page/n3/mode/2up. Retrieved 24 February 2020.&lt;/ref&gt;  Ngokuzibamba kwakhe bona angasolo akhambakhamba u-Wagener wabeka umthethomgomo wokuthi angekhe angenele eempikiswaneni zeentjhaba zendabuko begodu angekhe athathe ihlangothi. Ngemva kweminyaka emihlanu yokufunda, umfundi weJarimani u-Georg Friedrich Wreede watlola isirhunyezo selimi lesiDatjhi nesi-Khoikhoi.&lt;ref&gt;Wreede, Georg Friedrich (1916). Godée-Molsbergen, Everhardus Cornelius (ed.). ''G.F. Wreede's Hottentotse Woordelijst''. Reizen in Zuid-Afrika in de hollandse tijd. Vol.&amp;nbsp;1. 's-Gravenhage: Martinus Nijhoff. pp.&amp;nbsp;215–224.&lt;/ref&gt;   Ngu-Wagener wamkhetha bona enze njalo nabase-Mauritius.&lt;ref&gt;den Besten, Hans (2010). Huigen, Siegfried; de Jong, Jan L.; Kolfin, Elmer; et&amp;nbsp;al. (eds.). &quot;A badly harvested field: The growth of linguistic knowledge and the Dutch Cape colony until 1796&quot; (PDF)Retrieved from:https://web.archive.org/web/20200224011331/https://pdfs.semanticscholar.org/e8ad/25af90e01c4130dc42f8a8c9253d76305b84.pdf Retrieved on 31/05/2026.&lt;/ref&gt;

U-Wagener bekangomunye wabantu abahlanu ababeka isisekelo se-''Castle of Good Hope'', eyathonywa ngoRhoboyi wango-1665.&lt;ref&gt;Spohr, Otto H; Wagner, Zacharias (1967). ''Zacharias Wagner, second commander of the Cape''. Cape Town, Amsterdam: A.A. Balkema. OCLC&amp;nbsp;3424966.&lt;/ref&gt; Wakha ibulungelo lamanzi, wanikela imikhumbi ngamanzi ahlanzekileko, wakha isibhedlela, isikolo nesonto. Ngo-1666 umkakhe u-Anna Auxbrebis, ebekatjhade naye ngo-1648, wahlongakala.

=== Ipilwakhe Yekuluphaleni ===
Mhla amalanga ama-27 kuKhukhulamungu 1666 u-Wagener watjhiya umsebenzi begodu wabuyela e-Batavia nendodakazi kamkakhe. Wathengisa iingqila zakhe ezivela e-Bengal. Wakhamba nezipho waya ukuyobona i-''sushunan'' namkha umbusi we-Mataram, owala ukurhweba ne-[[U-Jan Van Riebeeck|VOC]]. Wathoma ikhambo leli anelwazi elincani lelimi lesiMalay nofana lesi-Javan, begodu umphumela womnqopho loyo khenge umsebenzele kuhle. Nanyana kunjalo, u-Wagener wavakatjhela i-Japara ngemva kwalokho. Ngemva komnyaka wabuyela emva e-Amsterdam njengesekela lomphathi omkhulu wezepi enarheni, kodwana bekagula. Wangcwatjwa mhlana ali-16 kuNobayeni 1668 eSontweni eliDala .

Omunye wemidwebo wedayari yakhe watjhugululwa ukusuka ku-''High Dutch'' ukuya esiNgisini begodu wagadangiswa ngo-1704 nango-1732.&lt;ref name=&quot;:1&quot; /&gt;&lt;ref name=&quot;:2&quot; /&gt;&lt;ref name=&quot;:0&quot; /&gt; Umtlolo wesandla onomdwebo wona loyo—kodwana ongesiJarimani—bewuyingcenye yeButhelelo lemiGadangiso neeNthombe (NgesiJamrimani ''Kupferstich-Kabinett'') we-''Dresden State Art Collections'' kusukela ekuthomeni kwekhulu le-18.&lt;ref name=&quot;:0&quot; /&gt;

=== Idlhego Lakhe Njenge-''Opperhoofd'' ===
U-Wagner wasebenza amathemu amabili njengo-''opperhoofd'' ngokutjhuguluka no[[Joan Boucheljon|-Joan Boucheljon]] :

* U-Joan Bouchelion: 23 kuSewula1655 - 1 kuSinyikhaba 1656
* U-Zacharias Wagenaer [Wagener]: 1 kuSinyikhaba 1656 - 27 kuSewula 1657
* U-Joan Bouchelion: 27 kuSewula 1657 - 23 kuSewula 1658
* U-Zacharias Wagenaer [Wagener]: 22 kuSewula 1658 - 4 kuSinyikhaba 1659
* U-Joan Bouchelion: 4 kuSinyikhaba 1659 - 26 kuSewula 1660

== Ibuthelelo Leenthombe Zakhe ==
&lt;gallery&gt;
Isimumathi:Zacharias_Wagner_-_Insetos.jpg|alt=Insects, Kupferstich-Kabinett (Dresden)| Iinunwana, i-Kupferstich-Kabinett (Dresden)
Isimumathi:Zacharias_Wagner_-_Caranguejo.jpg|alt=Caranguejo (crab)| I-Caranguejo (ikala)
&lt;/gallery&gt;

== Iinkomba ==

[[Mkhakha:Pages with unreviewed translations]]</text>
      <sha1>hwsxl90l1hmyexczrjd3a8e474vk6pk</sha1>
    </revision>
  </page>
  <page>
    <title>Iilwimi ze-Malawi</title>
    <ns>0</ns>
    <id>1103</id>
    <revision>
      <id>6503</id>
      <timestamp>2026-05-18T08:57:13Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;I-[[Malawi]], inarha eseSewula-pumalanga ye-[[Afrika]], ilikhaya labantu abahlukahlukeneko abanamagugu amalimi amanengi. Njenganje ilimi elisemthethweni lenarha yisiNgisi, bese kuthi i-isiChichewa ne-isiTumbuka zilimi ezikhulunywa khulu, begodu bezililimi ezisemthethweni ze-Malawi bekwaba ngu-1968.&lt;ref name=&quot;:1&quot; /&gt; Ezinye iilwimi zendawo zikhona begodu zikhulunywa khulu eendaweni ezithileko zelizwe.&lt;ref name=&quot;:1&quot;&gt;{{Cite book |url=https://books.google.com/books?id=I-B9EAA...&quot;</comment>
      <origin>6503</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1153" sha1="ii702o1eiu4sjphyipxvbms3ritgb9u" xml:space="preserve">I-[[Malawi]], inarha eseSewula-pumalanga ye-[[Afrika]], ilikhaya labantu abahlukahlukeneko abanamagugu amalimi amanengi. Njenganje ilimi elisemthethweni lenarha yisiNgisi, bese kuthi i-isiChichewa ne-isiTumbuka zilimi ezikhulunywa khulu, begodu bezililimi ezisemthethweni ze-Malawi bekwaba ngu-1968.&lt;ref name=&quot;:1&quot; /&gt; Ezinye iilwimi zendawo zikhona begodu zikhulunywa khulu eendaweni ezithileko zelizwe.&lt;ref name=&quot;:1&quot;&gt;{{Cite book |url=https://books.google.com/books?id=I-B9EAAAQBAJ&amp;dq=chinyanja+and+Chitumbuka+official+languages&amp;pg=PA186 |title=Handbook of Language Policy and Education in Countries of the Southern African Development Community (SADC) |date=2022-07-25 |publisher=BRILL |isbn=978-90-04-51672-4 |language=en}}&lt;/ref&gt;

Kuneenlimi ezisithandathu ezihlukileko (ezizijameleko) ezikhulunywa e-Malawi. Inani lingaba li-14 kodwana ngokungezelela iinlimi zalezo zilimi ezisithandathu. Zoke iilwimi ezingezizo zangaphandle zingezomndeni welimi lesiBantu. Iilwimi ezikhulunywako zangaphandle zisiNgisi, isiSpanishi nesiFulentshi.

==Irhelo==
*[[isiChichewa]]
*[[isiTumbuka]]
*[[isiYao]]
*isiLomwe
*isiSena
*isiNyakyusa

{{Stub}}

[[Category:Malawi]]</text>
      <sha1>ii702o1eiu4sjphyipxvbms3ritgb9u</sha1>
    </revision>
    <revision>
      <id>6504</id>
      <parentid>6503</parentid>
      <timestamp>2026-05-18T08:58:00Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>/* Irhelo */</comment>
      <origin>6504</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1179" sha1="bp5j1qc8qkn6a6ef2ooqj9ssr3k774l" xml:space="preserve">I-[[Malawi]], inarha eseSewula-pumalanga ye-[[Afrika]], ilikhaya labantu abahlukahlukeneko abanamagugu amalimi amanengi. Njenganje ilimi elisemthethweni lenarha yisiNgisi, bese kuthi i-isiChichewa ne-isiTumbuka zilimi ezikhulunywa khulu, begodu bezililimi ezisemthethweni ze-Malawi bekwaba ngu-1968.&lt;ref name=&quot;:1&quot; /&gt; Ezinye iilwimi zendawo zikhona begodu zikhulunywa khulu eendaweni ezithileko zelizwe.&lt;ref name=&quot;:1&quot;&gt;{{Cite book |url=https://books.google.com/books?id=I-B9EAAAQBAJ&amp;dq=chinyanja+and+Chitumbuka+official+languages&amp;pg=PA186 |title=Handbook of Language Policy and Education in Countries of the Southern African Development Community (SADC) |date=2022-07-25 |publisher=BRILL |isbn=978-90-04-51672-4 |language=en}}&lt;/ref&gt;

Kuneenlimi ezisithandathu ezihlukileko (ezizijameleko) ezikhulunywa e-Malawi. Inani lingaba li-14 kodwana ngokungezelela iinlimi zalezo zilimi ezisithandathu. Zoke iilwimi ezingezizo zangaphandle zingezomndeni welimi lesiBantu. Iilwimi ezikhulunywako zangaphandle zisiNgisi, isiSpanishi nesiFulentshi.

==Irhelo==
*[[isiChichewa]]
*[[isiTumbuka]]
*[[isiYao]]
*isiLomwe
*isiSena
*isiNyakyusa

==Iinkomba==
{{reflist}}

{{Stub}}

[[Category:Malawi]]</text>
      <sha1>bp5j1qc8qkn6a6ef2ooqj9ssr3k774l</sha1>
    </revision>
  </page>
  <page>
    <title>Wiikwemkoong First Nation</title>
    <ns>0</ns>
    <id>1104</id>
    <revision>
      <id>6505</id>
      <timestamp>2026-05-18T09:45:08Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;I-'''Wiikwemkoong First Nation''' yi-First Nation e-Manitoulin Island e-I-[[Ontario eseTlhagwini]]. &quot;I-Wiikwemkoong Unceded Territory&quot; (ebizwa ngokuthi yi-'''Wiky''', ngaphambilini ebizwa nge-Wikwemikong), libizo le-First Nation reserve enyakatho-pumalanga ye-Manitoulin Island e-Manitoulin District, Ontario, Canada. I-First Nation ithe azange ilahlekelwe lilungelo lomhlaba obekelweko ngesivumelwano namkha ngenye indlela.  Ibizo langaphambilini le-reserve bekuyi-&quot;Manitoul...&quot;</comment>
      <origin>6505</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="632" sha1="k65emsclo9taj7n5xnaxfdxzssrrjba" xml:space="preserve">I-'''Wiikwemkoong First Nation''' yi-First Nation e-Manitoulin Island e-I-[[Ontario eseTlhagwini]]. &quot;I-Wiikwemkoong Unceded Territory&quot; (ebizwa ngokuthi yi-'''Wiky''', ngaphambilini ebizwa nge-Wikwemikong), libizo le-First Nation reserve enyakatho-pumalanga ye-Manitoulin Island e-Manitoulin District, Ontario, Canada. I-First Nation ithe azange ilahlekelwe lilungelo lomhlaba obekelweko ngesivumelwano namkha ngenye indlela.

Ibizo langaphambilini le-reserve bekuyi-&quot;Manitoulin Unceded Indian Reserve&quot;. I-Wiikwemkong Band yayitjhugulula mhlazi-20 kuRhoboyi wee-1968, yaba &quot;abantu be-Wikwemikong Unceded Indian&quot;.

[[Category:Canada]]</text>
      <sha1>k65emsclo9taj7n5xnaxfdxzssrrjba</sha1>
    </revision>
  </page>
  <page>
    <title>Umphakathi wokuHlaliswa kabutjha weDemokhrasi</title>
    <ns>0</ns>
    <id>1105</id>
    <revision>
      <id>6506</id>
      <timestamp>2026-05-18T09:48:03Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;[[File:Swakopmund DRC.JPG|thumb|I-Umphakathi wokuHlaliswa kabutjha weDemokhrasi (DRC), indawo yemikhukhu ye-Swakopmund]] I-'''Umphakathi wokuHlaliswa kabutjha weDemokhrasi''' (DRC) yindawo yokuhlala engakahleleki, nofana i-slum, e-Swakopmund, e-Erongo Region, e-Namibia. Yasungulwa ngo-2001 njengendawo yokuhlala yesikhatjhana yabantu abalindele izindlu ezibhadelwako edorobheni begodu yakhiwe khulu ngesila esibuyiselweko esivela endaweni yokulahla idoti edorobheni. Iinsetj...&quot;</comment>
      <origin>6506</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1264" sha1="4qawe361fzozi11599abnc8ijy842ee" xml:space="preserve">[[File:Swakopmund DRC.JPG|thumb|I-Umphakathi wokuHlaliswa kabutjha weDemokhrasi (DRC), indawo yemikhukhu ye-Swakopmund]]
I-'''Umphakathi wokuHlaliswa kabutjha weDemokhrasi''' (DRC) yindawo yokuhlala engakahleleki, nofana i-slum, e-Swakopmund, e-Erongo Region, e-Namibia. Yasungulwa ngo-2001 njengendawo yokuhlala yesikhatjhana yabantu abalindele izindlu ezibhadelwako edorobheni begodu yakhiwe khulu ngesila esibuyiselweko esivela endaweni yokulahla idoti edorobheni. Iinsetjenziswa bezifaka hlangana insimbi, iinkuni, ikhanvasi kanye neplastiki.

Ngomnyaka ka-2015, inani labantu belilinganiselwa ema-20,000. Akukho igezi begodu akukho ukuthuthwa kwendle. Amanzi agelezako bekavela empompini eyodwa, eyafakwa ngo-2012. Izakhamuzi zathola umsebenzi zisebenza imisebenzi ephasi e-Swakopmund.

Ngo-2019, umasipala we-Swakopmund besele asebenzise imali engaphezu kwe-N$200 yezigidi eensetjenzisweni ze-DRC. Ihlelo lokudla lombuso belinikela imindeni ngamaphakheji wokudla. I-DRC ifakahlangana isikhungo sokuthuthukisa ilutjha nomphakathi, umtholampilo nelabhorethri, kanye nehostela yeentandane. Isikhungo se-Dantago Arts and Craft sakhiwe babantu abahlala lapho kusetjenziswa izinto zeplastiki ezisetjenziswe kabutjha, ezifana namabhodlela, ezihlanganiswe nesemende.</text>
      <sha1>4qawe361fzozi11599abnc8ijy842ee</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Not around</title>
    <ns>10</ns>
    <id>1106</id>
    <revision>
      <id>6507</id>
      <timestamp>2026-05-18T10:23:24Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;&lt;big&gt;'''Kungenzeka bona umsebenzisi lo utjhiye i-Wikipedia'''. {{{1}}} akazange ahlele i-Wikipedia isikhathi eside. Njengomphumela, nanyana ngiziphi iimbawo ezenziwe lapha zingathola ipendulo. Nawufuna isizo, kungatlhogeka bona uye komunye umuntu.&lt;/big&gt;  &lt;noinclude&gt;{{documentation}}&lt;/noinclude&gt;&quot;</comment>
      <origin>6507</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="295" sha1="5zb36ze6zsca59qnrg0j4k8622u0v1n" xml:space="preserve">&lt;big&gt;'''Kungenzeka bona umsebenzisi lo utjhiye i-Wikipedia'''. {{{1}}} akazange ahlele i-Wikipedia isikhathi eside. Njengomphumela, nanyana ngiziphi iimbawo ezenziwe lapha zingathola ipendulo. Nawufuna isizo, kungatlhogeka bona uye komunye umuntu.&lt;/big&gt;

&lt;noinclude&gt;{{documentation}}&lt;/noinclude&gt;</text>
      <sha1>5zb36ze6zsca59qnrg0j4k8622u0v1n</sha1>
    </revision>
    <revision>
      <id>6533</id>
      <parentid>6507</parentid>
      <timestamp>2026-05-18T12:09:35Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6533</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="299" sha1="qkqg67hmjfsbrvthutqnhpyoe9ygwqf" xml:space="preserve">&lt;big&gt;'''''Kungenzeka bona umsebenzisi lo utjhiye i-Wikipedia'''. {{{1}}} akazange ahlele i-Wikipedia isikhathi eside. Njengomphumela, nanyana ngiziphi iimbawo ezenziwe lapha zingathola ipendulo. Nawufuna isizo, kungatlhogeka bona uye komunye umuntu.''&lt;/big&gt;

&lt;noinclude&gt;{{documentation}}&lt;/noinclude&gt;</text>
      <sha1>qkqg67hmjfsbrvthutqnhpyoe9ygwqf</sha1>
    </revision>
    <revision>
      <id>6587</id>
      <parentid>6533</parentid>
      <timestamp>2026-05-19T05:55:30Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6587</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="301" sha1="oebwx6796xu6yjzcboogdr70hcx2zt8" xml:space="preserve">&lt;big&gt;'''''Kungenzeka bona umsebenzisi lo utjhiye i-Wikiphidiya'''. {{{1}}} akazange ahlele i-Wikipedia isikhathi eside. Njengomphumela, nanyana ngiziphi iimbawo ezenziwe lapha zingathola ipendulo. Nawufuna isizo, kungatlhogeka bona uye komunye umuntu.''&lt;/big&gt;

&lt;noinclude&gt;{{documentation}}&lt;/noinclude&gt;</text>
      <sha1>oebwx6796xu6yjzcboogdr70hcx2zt8</sha1>
    </revision>
    <revision>
      <id>6588</id>
      <parentid>6587</parentid>
      <timestamp>2026-05-19T06:13:08Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6588</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="303" sha1="39hy4iuzv74n7y4aavt5989wsn41bxi" xml:space="preserve">&lt;big&gt;'''''Kungenzeka bona umsebenzisi lo utjhiye i-Wikiphidiya'''. {{{1}}} akazange ahlele i-Wikiphidiya isikhathi eside. Njengomphumela, nanyana ngiziphi iimbawo ezenziwe lapha zingathola ipendulo. Nawufuna isizo, kungatlhogeka bona uye komunye umuntu.''&lt;/big&gt;

&lt;noinclude&gt;{{documentation}}&lt;/noinclude&gt;</text>
      <sha1>39hy4iuzv74n7y4aavt5989wsn41bxi</sha1>
    </revision>
    <revision>
      <id>6589</id>
      <parentid>6588</parentid>
      <timestamp>2026-05-19T06:15:50Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6589</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="337" sha1="bzm49jfmo7qoioy1q3a5g4aesbypev1" xml:space="preserve">[[File:Decision making.svg|45px]] &lt;big&gt;'''''Kungenzeka bona umsebenzisi lo utjhiye i-Wikiphidiya'''.&lt;/big&gt; {{{1}}} akazange ahlele i-Wikiphidiya isikhathi eside. Njengomphumela, nanyana ngiziphi iimbawo ezenziwe lapha zingathola ipendulo. Nawufuna isizo, kungatlhogeka bona uye komunye umuntu.''

&lt;noinclude&gt;{{documentation}}&lt;/noinclude&gt;</text>
      <sha1>bzm49jfmo7qoioy1q3a5g4aesbypev1</sha1>
    </revision>
    <revision>
      <id>6593</id>
      <parentid>6589</parentid>
      <timestamp>2026-05-19T06:19:30Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6593</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="335" sha1="cm98rhvre9qql89jju2vwy1zezx2801" xml:space="preserve">[[File:Decision making.svg|45px]] &lt;big&gt;'''''Kungenzeka bona umsebenzisi lo utjhiye i-Wikiphidiya'''.&lt;/big&gt; {{{1}}} akazange ahlele i-Wikiphidiya isikhathi eside. Njengomphumela, nanyana ngiziphi iimbawo ezenziwe lapha zingathola ipendulo. Nawufuna isizo, kungatlhogeka bona uye komunye umuntu.''&lt;noinclude&gt;{{documentation}}&lt;/noinclude&gt;</text>
      <sha1>cm98rhvre9qql89jju2vwy1zezx2801</sha1>
    </revision>
    <revision>
      <id>6594</id>
      <parentid>6593</parentid>
      <timestamp>2026-05-19T06:19:46Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6594</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="335" sha1="drhvy7tnud9uftb666vnhocyn12h6ec" xml:space="preserve">[[File:Decision making.svg|40px]] &lt;big&gt;'''''Kungenzeka bona umsebenzisi lo utjhiye i-Wikiphidiya'''.&lt;/big&gt; {{{1}}} akazange ahlele i-Wikiphidiya isikhathi eside. Njengomphumela, nanyana ngiziphi iimbawo ezenziwe lapha zingathola ipendulo. Nawufuna isizo, kungatlhogeka bona uye komunye umuntu.''&lt;noinclude&gt;{{documentation}}&lt;/noinclude&gt;</text>
      <sha1>drhvy7tnud9uftb666vnhocyn12h6ec</sha1>
    </revision>
    <revision>
      <id>6595</id>
      <parentid>6594</parentid>
      <timestamp>2026-05-19T06:20:06Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6595</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="335" sha1="cm98rhvre9qql89jju2vwy1zezx2801" xml:space="preserve">[[File:Decision making.svg|45px]] &lt;big&gt;'''''Kungenzeka bona umsebenzisi lo utjhiye i-Wikiphidiya'''.&lt;/big&gt; {{{1}}} akazange ahlele i-Wikiphidiya isikhathi eside. Njengomphumela, nanyana ngiziphi iimbawo ezenziwe lapha zingathola ipendulo. Nawufuna isizo, kungatlhogeka bona uye komunye umuntu.''&lt;noinclude&gt;{{documentation}}&lt;/noinclude&gt;</text>
      <sha1>cm98rhvre9qql89jju2vwy1zezx2801</sha1>
    </revision>
    <revision>
      <id>6597</id>
      <parentid>6595</parentid>
      <timestamp>2026-05-19T06:23:22Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6597</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="335" sha1="drhvy7tnud9uftb666vnhocyn12h6ec" xml:space="preserve">[[File:Decision making.svg|40px]] &lt;big&gt;'''''Kungenzeka bona umsebenzisi lo utjhiye i-Wikiphidiya'''.&lt;/big&gt; {{{1}}} akazange ahlele i-Wikiphidiya isikhathi eside. Njengomphumela, nanyana ngiziphi iimbawo ezenziwe lapha zingathola ipendulo. Nawufuna isizo, kungatlhogeka bona uye komunye umuntu.''&lt;noinclude&gt;{{documentation}}&lt;/noinclude&gt;</text>
      <sha1>drhvy7tnud9uftb666vnhocyn12h6ec</sha1>
    </revision>
    <revision>
      <id>6606</id>
      <parentid>6597</parentid>
      <timestamp>2026-05-19T06:35:18Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6606</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="483" sha1="buomvvgjq3wufh05917to5qblrsu4rw" xml:space="preserve">{{{{#ifeq:{{{spacetype|}}}|tmbox|tmbox|mbox}}
|image = [[File:Decision making.svg|50px]]
|text = '''Kungenzeka bona umsebenzisi lo utjhiye i-Wikiphidiya'''. {{#if:{{{2|}}}|{{{2}}}|&lt;includeonly&gt;{{BASEPAGENAME}}&lt;/includeonly&gt;&lt;noinclude&gt;''Example''&lt;/noinclude&gt;}} akazange ahlele i-Wikiphidiya isikhathi eside. Njengomphumela, nanyana ngiziphi iimbawo ezenziwe lapha zingathola ipendulo. Nawufuna isizo, kungatlhogeka bona uye komunye umuntu.
}}&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>buomvvgjq3wufh05917to5qblrsu4rw</sha1>
    </revision>
    <revision>
      <id>6607</id>
      <parentid>6606</parentid>
      <timestamp>2026-05-19T06:36:23Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6607</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="483" sha1="8iq8k74zt9l8w45mhq9uk2uqawb0kgu" xml:space="preserve">{{{{#ifeq:{{{spacetype|}}}|tmbox|tmbox|mbox}}
|image = [[File:Decision making.svg|50px]]
|text = '''Kungenzeka bona umsebenzisi lo utjhiye i-Wikiphidiya'''. {{#if:{{{1|}}}|{{{1}}}|&lt;includeonly&gt;{{BASEPAGENAME}}&lt;/includeonly&gt;&lt;noinclude&gt;''Example''&lt;/noinclude&gt;}} akazange ahlele i-Wikiphidiya isikhathi eside. Njengomphumela, nanyana ngiziphi iimbawo ezenziwe lapha zingathola ipendulo. Nawufuna isizo, kungatlhogeka bona uye komunye umuntu.
}}&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>8iq8k74zt9l8w45mhq9uk2uqawb0kgu</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Nihongo</title>
    <ns>828</ns>
    <id>1107</id>
    <revision>
      <id>6508</id>
      <timestamp>2026-05-18T10:33:04Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;require('strict');  --[[--------------------------&lt; E R R O R _ M E S S A G E S &gt;--------------------------------------------------  error messaging; keys to this table are the template base names: 	'nihongo', 'nihongo3', 'nihongo krt', 'nihongo foot' → 'nihongo' etc  ]]  local err_msg = { 	['nihongo'] = 'Japanese or romaji text required', 	}  local err_cat = { 	['nihongo'] = '[[Category:Nihongo template errors]]', 	}   --[[--------------------------&lt; C O N F I G U R A...&quot;</comment>
      <origin>6508</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="23796" sha1="9j0e03l8qw3wgdriip8pcmbf1gssnwu" xml:space="preserve">require('strict');

--[[--------------------------&lt; E R R O R _ M E S S A G E S &gt;--------------------------------------------------

error messaging; keys to this table are the template base names:
	'nihongo', 'nihongo3', 'nihongo krt', 'nihongo foot' → 'nihongo' etc

]]

local err_msg = {
	['nihongo'] = 'Japanese or romaji text required',
	}

local err_cat = {
	['nihongo'] = '[[Category:Nihongo template errors]]',
	}


--[[--------------------------&lt; C O N F I G U R A T I O N &gt;----------------------------------------------------

configuration setting for the various templates.  keys to this table are the template names without capitalization

]]

local cfg = {
	['nihongo'] = {
		tag = 'ja',
		system = 'hepburn',
		system_link = '[[Hepburn romanization|Hepburn]]',
		err_msg = err_msg.nihongo,
		err_cat = err_cat.nihongo,
		},
	['nihongo3'] = {
		tag = 'ja',
		system = 'hepburn',
		err_msg = err_msg.nihongo,
		err_cat = err_cat.nihongo,
		},
	['nihongo krt'] = {
		tag = 'ja',
		system = 'hepburn',
		err_msg = err_msg.nihongo,
		err_cat = err_cat.nihongo,
		},
	['nihongo foot'] = {
		tag = 'ja',
		system = 'hepburn',
		system_link = '[[Hepburn romanization|Hepburn]]',
		err_msg = err_msg.nihongo,
		err_cat = err_cat.nihongo,
		},
	}


--[[--------------------------&lt; E R R O R _ M E S S A G E &gt;----------------------------------------------------

Creates an error message for {{nihongo}}, {{nihongo3}}, {{nihongo krt}}, and {{nihongo foot}} when these template are missing &lt;japanese&gt;
or &lt;romaji&gt; inputs; names the offending template, links to template page, and adds article to Category:Nihongo template errors

]]

local function error_message (template)
	local msg = {'&lt;span class=&quot;error&quot; style=&quot;font-size:100%&quot;&gt;error: {{'};
	table.insert (msg, template);
	table.insert (msg, '}}: ');
	table.insert (msg, cfg[template].err_msg);
	table.insert (msg, ' ([[Template:');
	table.insert (msg, template);
	table.insert (msg, '|help]])&lt;/span&gt;');
	if 0 == mw.title.getCurrentTitle().namespace then
		table.insert (msg, cfg[template].err_cat);
	end

	return table.concat (msg);	
end


--[[--------------------------&lt; R E N D E R E R &gt;--------------------------------------------------------------

Shared support function for nihingo(), nihongo3(), and nihongo_foot().  Calculates an index into formatting{}
from set/unset parameters:
	args[1] (english text) has a value of 8 (set) or 0 (unset)
	args[2] (native text) has a value of 4
	args[3] (romanized text) has a value of 2
	args[4] (extra) has a value of 1
index, the sum of these values, gets the appropriate format string from formatting{} table with associated values
from the formatting[index][2] table

]]

local function renderer (args, formatting, extra2)
	local output;
	local index = 0;															-- index into formatting{}
	local param_weight = {8, 4, 2, 1};											-- binary parameter weights: [1] = english (8), [2] = japanese (4), [3] = romaji (2), [4] = extra (1)

	for i=1, 5 do																-- spin through args[1] – args[4]
		index = index + (args[i] and param_weight[i] or 0);						-- calculate an index into formatting{}
	end

	output = (0 ~= index) and string.format (formatting[index][1] and formatting[index][1], formatting[index][2][1], formatting[index][2][2], formatting[index][2][3], formatting[index][2][4]) or nil;

	if extra2 then																-- always just attached to the end (if there is an end) so not part of formatting{}
		output = output and (output .. ' ' .. extra2) or '&lt;5p4n&gt;' .. extra2;	-- &lt;5p4n&gt; and &lt;/5p4n&gt;: place holders for font-weight style spans; akin to stripmarkers, to be replaced
	end																			-- (nihongo and nihongo3) or removed (nihongo foot)

	return output and (output .. '&lt;/5p4n&gt;') or '';								-- where there is output, add secret tag close
end


--[[--------------------------&lt; R O M A N I Z E D _ K E R N &gt;--------------------------------------------------

Add kerning when first or last character of romanized text contacts adjacent opening or closing parenthesis

In this example, without kerning, the romanized characters 'j' and 'V' are italicized so will contact the parentheses
	(&lt;i lang=\&quot;ja-Latn\&quot; title=\&quot;Hepburn transliteration\&quot;&gt;jV&lt;/i&gt;)

&lt;ret_string&gt; is the formatted template output (except that the magic string '&lt;5p4n&gt;' has not yet been replaced)
&lt;romanized&gt; is the return from lang_module._xlit() so is not wrapped in parentheses

]]

local function romanized_kern (ret_string, romanized)
	if not romanized or ('' == romanized) then									-- if romanized not set
		return ret_string;														-- then we're done
	end

	local romanized_text = romanized:gsub ('%b&lt;&gt;', ''):gsub ('\'\'+', ''):gsub ('%[%[', ''):gsub ('%]%]', '');	-- strip HTML tags

	romanized = romanized:gsub ('([%(%)%.%%%+%-%*%?%[%^%$%]])', '%%%1');				-- escape lua pattern characters

	local romanized_has_leading_paren = ret_string:match ('%(' .. romanized);			-- has a value if (&lt;romanized&gt;; nil else
	local romanized_has_trailing_paren = ret_string:match (romanized .. '%)');		-- has a value if &lt;romanized&gt;); nil else

	local kern_lead_pattern = '^[jpy]';											-- list of characters that when italicized contact unitalicized leading parenthesis
	local kern_tail_pattern = '[dfijkltCEFHIJKMNPR-Z\'&quot;%?!%]]$';				-- list of characters that when italicized contact unitalicized trailing parenthesis

	local kern_right = '&lt;span style=&quot;margin-right:.09em&quot;&gt;(&lt;/span&gt;%1';			-- %1 is &lt;romanized&gt; capture
	local kern_left = '%1&lt;span style=&quot;margin-left:.09em&quot;&gt;)&lt;/span&gt;';				-- %1 is &lt;romanized&gt; capture

	if romanized_has_leading_paren and romanized_text:match (kern_lead_pattern) then
		ret_string = ret_string:gsub ('%((' .. romanized .. ')', kern_right);		-- replace plain '(' with kerned '('; &lt;romanized&gt; included here to ensure that the correct '(' is kerned
	end
	if romanized_has_trailing_paren and romanized_text:match (kern_tail_pattern) then
		ret_string = ret_string:gsub ('(' .. romanized .. ')%)', kern_left);		-- replace plain ')' with kerned ')'; &lt;romanized&gt; included here to ensure that the correct ')' is kerned
	end

	return ret_string;															-- done
end


--[[--------------------------&lt; C O M M O N &gt;------------------------------------------------------------------

Common support for {{nihongo}}

render order: is translated (English), native, romanized

&lt;template&gt; is used to select the appropriate cfg table

]]

local function common (frame, template)
	local lang_module = require ('Module:Lang' .. (frame:getTitle():match ('/sandbox') or ''));	-- if this module is the sandbox, use Module:lang/sandbox; Module:Lang else

	local args = require ('Module:Arguments').getArgs (frame);
	
	local english, native, romanized, extra, extra2 = args[1], args[2], args[3], args.extra or args[4], args.extra2 or args[5];	-- meaningful names
	args[4] = extra or args[4];													-- ensure that extra is 'positional' for use by renderer()

	local lead = require ('Module:yesno')(args.lead);							-- make boolean

	if not (native or romanized) then											-- not present, return an error message
		return error_message (template);
	end
	if native then
		native = lead and lang_module._langx ({['code']=cfg[template].tag, ['text']=native, ['template']=template}) or
			lang_module._lang ({cfg[template].tag, native, ['template']=template});	-- add ja script with/without language prefix
	end
	if romanized then
		romanized = (lead and english and (cfg[template].system_link .. ': ') or '') .. lang_module._xlit ({'ja', cfg[template].system, romanized, ['template']=template}) or nil;
	end

	local formatting = {														-- &lt;5p4n&gt; and &lt;/5p4n&gt;: place holders for font-weight style spans; akin to stripmarkers, replaced  before function returns
		{'&lt;5p4n&gt;(%s)', {extra}}, 												-- 1 - (extra)
		{'%s&lt;5p4n&gt;', {romanized}},												-- 2 - romanized
		{'%s&lt;5p4n&gt; (%s)', {romanized, extra}},									-- 3 - romanized (extra)
		{'&lt;5p4n&gt;(%s)', {native}},												-- 4 - native
		{'&lt;5p4n&gt;(%s; %s)', {native, extra}},									-- 5 - (native; extra)
		{'%s&lt;5p4n&gt; (%s)', {romanized, native}},									-- 6 - romanized (native)
		{'%s&lt;5p4n&gt; (%s; %s)', {romanized, native, extra}},						-- 7 - romanized (native; extra)
		{'%s&lt;5p4n&gt;', {english}},												-- 8 - english
		{'%s&lt;5p4n&gt; (%s)', {english, extra}},									-- 9 - english (extra)
		{'%s&lt;5p4n&gt; (%s)', {english, romanized}},								-- 10 - english (romanized)
		{'%s&lt;5p4n&gt; (%s; %s)', {english, romanized, extra}},						-- 11 - english (romanized; extra)
		{'%s&lt;5p4n&gt; (%s)', {english, native}},									-- 12 - english (native)
		{'%s&lt;5p4n&gt; (%s; %s)', {english, native, extra}},						-- 13 - english (native; extra)
		{'%s&lt;5p4n&gt; (%s, %s)', {english, native, romanized}},					-- 14 - english (native, romanized)
		{'%s&lt;5p4n&gt; (%s, %s; %s)', {english, native, romanized, extra}},			-- 15 - english (native, romanized; extra)
		}

	local ret_string = renderer (args, formatting, extra2)
	ret_string = romanized_kern (ret_string, romanized);						-- kern romanized text when appropriate
	ret_string = ret_string:gsub ('&lt;5p4n&gt;', '&lt;span style=&quot;font-weight: normal&quot;&gt;'):gsub ('&lt;/5p4n&gt;', '&lt;/span&gt;');	-- replace 'secret' tags with proper tags

	return ret_string;															-- because gsub returns the number of replacements made as second return value
end


--[[--------------------------&lt; C O M M O N _ R O M A N I Z E D _ N A T I V E _ T R A N S L A T E D &gt;----------

Common support for {{nihongo3}}

render order: is romanized, native, translated (English)

&lt;template&gt; is used to select the appropriate cfg table

]]

local function common_romanized_native_translated (frame, template)
	local lang_module = require ('Module:Lang' .. (frame:getTitle():match ('/sandbox') or ''));	-- if this module is the sandbox, use Module:lang/sandbox; Module:Lang else
	local args = require ('Module:Arguments').getArgs (frame);
	
	local english, native, romanized, extra, extra2 = args[1], args[2], args[3], args.extra or args[4], args.extra2 or args[5];	-- meaningful names
	args[4] = extra or args[4];													-- ensure that extra is 'positional' for use by renderer()

	if not (native or romanized) then											-- not present, return an error message
		return error_message (template);
	end
	native = native and lang_module._lang ({cfg[template].tag, native, ['template']=template}) or nil;
	romanized = romanized and lang_module._xlit ({cfg[template].tag, cfg[template].system, romanized, ['template']=template}) or nil;
	
	local formatting = {														-- &lt;5p4n&gt; and &lt;/5p4n&gt;: place holders for font-weight style spans; akin to stripmarkers, replaced  before function returns
		{'&lt;5p4n&gt;(%s)', {extra}}, 												-- 1 - (extra)
		{'%s&lt;5p4n&gt;', {romanized}},												-- 2 - romanized
		{'%s&lt;5p4n&gt; (%s)', {romanized, extra}},									-- 3 - romanized (extra)
		{'&lt;5p4n&gt;(%s)', {native}},												-- 4 - native
		{'&lt;5p4n&gt;(%s; %s)', {native, extra}},									-- 5 - (native; extra)
		{'%s&lt;5p4n&gt; (%s)', {romanized, native}},									-- 6 - romanized (native)
		{'%s&lt;5p4n&gt; (%s; %s)', {romanized, native, extra}},						-- 7 - romanized (native; extra)
		{'%s&lt;5p4n&gt;', {english}},												-- 8 - english
		{'%s&lt;5p4n&gt; (%s)', {english, extra}},									-- 9 - english (extra)
		{'%s&lt;5p4n&gt; (%s)', {romanized, english}},								-- 10 - romanized (english)
		{'%s&lt;5p4n&gt; (%s; %s)', {romanized, english, extra}},						-- 11 - romanized (english; extra)
		{'%s&lt;5p4n&gt; (%s)', {english, native}},									-- 12 - english (native)
		{'%s&lt;5p4n&gt; (%s; %s)', {english, native, extra}},						-- 13 - english (native; extra)
		{'%s&lt;5p4n&gt; (%s, %s)', {romanized, native, english}},					-- 14 - romanized (native, english)
		{'%s&lt;5p4n&gt; (%s, %s; %s)', {romanized, native, english, extra}},			-- 15 - romanized (native, english; extra)
		}

	local ret_string = renderer (args, formatting, extra2)
	ret_string = ret_string:gsub ('&lt;5p4n&gt;', '&lt;span style=&quot;font-weight: normal&quot;&gt;'):gsub ('&lt;/5p4n&gt;', '&lt;/span&gt;');	-- replace 'secret' tags with proper tags
	return ret_string;															-- because gsub returns the number of replacements made as second return value
end

--[[--------------------------&lt; C O M M O N _ N A T I V E _ R O M A N I Z E D _ T R A N S L A T E D &gt;----------

Common support for {{nihongo krt}}

render order: is native, romanized, translated (English)

&lt;template&gt; is used to select the appropriate cfg table

]]

local function common_native_romanized_translated (frame, template)
	local lang_module = require ('Module:Lang' .. (frame:getTitle():match ('/sandbox') or ''));	-- if this module is the sandbox, use Module:lang/sandbox; Module:Lang else
	local args = require ('Module:Arguments').getArgs (frame);
	
	local english, native, romanized, extra, extra2 = args[1], args[2], args[3], args.extra or args[4], args.extra2 or args[5];	-- meaningful names
	args[4] = extra or args[4];													-- ensure that extra is 'positional' for use by renderer()

	if not (native or romanized) then											-- not present, return an error message
		return error_message (template);
	end
	native = native and lang_module._lang ({cfg[template].tag, native, ['template']=template}) or nil;
	romanized = romanized and lang_module._xlit ({cfg[template].tag, cfg[template].system, romanized, ['template']=template}) or nil;
	
	local formatting = {														-- &lt;5p4n&gt; and &lt;/5p4n&gt;: place holders for font-weight style spans; akin to stripmarkers, replaced  before function returns
		{'&lt;5p4n&gt;(%s)', {extra}}, 												-- 1 - (extra)
		{'%s&lt;5p4n&gt;', {romanized}},												-- 2 - romanized
		{'%s&lt;5p4n&gt; (%s)', {romanized, extra}},									-- 3 - romanized (extra)
		{'&lt;5p4n&gt;%s', {native}},													-- 4 - native
		{'&lt;5p4n&gt;%s (%s)', {native, extra}},										-- 5 - native (extra)
		{'&lt;5p4n&gt;%s (%s)', {native, romanized}},									-- 6 - native (romanized)
		{'&lt;5p4n&gt;%s (%s; %s)', {native, romanized, extra}},						-- 7 - native (romanized; extra)
		{'%s&lt;5p4n&gt;', {english}},												-- 8 - english
		{'%s&lt;5p4n&gt; (%s)', {english, extra}},									-- 9 - english (extra)
		{'%s&lt;5p4n&gt; (%s)', {romanized, english}},								-- 10 - romanized (english)
		{'%s&lt;5p4n&gt; (%s; %s)', {romanized, english, extra}},						-- 11 - romanized (english; extra)
		{'&lt;5p4n&gt;%s (%s)', {native, english}},									-- 12 - native (english)
		{'&lt;5p4n&gt;%s (%s; %s)', {native, english, extra}},						-- 13 - native (english; extra)
		{'&lt;5p4n&gt;%s (%s, %s)', {native, romanized, english}},						-- 14 - native (romanized, english)
		{'&lt;5p4n&gt;%s (%s, %s; %s)', {native, romanized, english, extra}},			-- 15 - native (romanized, english; extra)
		}

	local ret_string = renderer (args, formatting, extra2)
	ret_string = romanized_kern (ret_string, romanized);						-- kern romanized text when appropriate
	ret_string = ret_string:gsub ('&lt;5p4n&gt;', '&lt;span style=&quot;font-weight: normal&quot;&gt;'):gsub ('&lt;/5p4n&gt;', '&lt;/span&gt;');	-- replace 'secret' tags with proper tags
	return ret_string;															-- because gsub returns the number of replacements made as second return value
end


--[[--------------------------&lt; C O M M O N _ F O O T &gt;--------------------------------------------------------

Common support for {{nihongo foot}}

render order: is English&lt;ref&gt;native, romanized&lt;/ref&gt;

&lt;template&gt; is used to select the appropriate cfg table

]]

local function common_foot (frame, template)
	local lang_module = require ('Module:Lang' .. (frame:getTitle():match ('/sandbox') or ''));	-- if this module is the sandbox, use Module:lang/sandbox; Module:Lang else
	local args = require ('Module:Arguments').getArgs (frame);
	
	local english, native, romanized, extra, extra2 = args[1], args[2], args[3], args.extra or args[4], args.extra2 or args[5];	-- meaningful names
	args[4] = extra or args[4];													-- ensure that extra is 'positional' for use by renderer()
	local post = args[6] or args.post;
	local group = args.group;
	local ref_name = args.ref_name
	local lead = require ('Module:yesno')(args.lead);							-- make boolean

	if not (native or romanized) then											-- not present, return an error message
		return error_message (template);
	end
	if native then
		native = lead and lang_module._langx ({['code']=cfg[template].tag, ['text']=native, ['template']=template}) or
			lang_module._lang ({cfg[template].tag, native, ['template']=template});	-- add ja script with/without language prefix
	end
	if romanized then
		romanized = (lead and (cfg[template].system_link .. ': ') or '') .. lang_module._xlit ({'ja', cfg[template].system, romanized, ['template']=template}) or nil;
	end
	
	local formatting = {
		{'%s', {extra}}, 														-- 1 - extra
		{'%s', {romanized}},													-- 2 - romanized
		{'%s; %s', {romanized, extra}},											-- 3 - romanized; extra
		{'%s', {native}},														-- 4 - native
		{'%s; %s', {native, extra}},											-- 5 - native; extra
		{'%s, %s', {native, romanized}},										-- 6 - native romanized
		{'%s, %s; %s', {native, romanized, extra}},								-- 7 - native romanized; extra
																				-- from here english is used in the mapping but not rendered by renderer so not included in the table
		{'', {''}},																-- 8 - english
		{'%s', {extra}},														-- 9 - extra
		{'%s', {romanized}},													-- 10 - romanized
		{'%s; %s', {romanized, extra}},											-- 11 - romanized; extra
		{'%s', {native}},														-- 12 - native
		{'%s; %s', {native, extra}},											-- 13 - native; extra
		{'%s, %s', {native, romanized}},										-- 14 - native romanized
		{'%s, %s; %s', {native, romanized, extra}},								-- 15 - native romanized; extra
		}

	if english and post then													-- rewrite english to include |post=
		english = english .. post;												-- if english has a value append post else just post
	elseif post then
		english = post;															-- english not set, use post
	elseif not english then														-- neither are set
		english = '';															-- make english an empty string for concatenation
	end

	if native or romanized or extra or extra2 then								-- no ref tag when none of these are set (it would be empty)
		local content = renderer (args, formatting, extra2);
		content = content:gsub ('&lt;5p4n&gt;', ''):gsub ('&lt;/5p4n&gt;$', '', 1);			-- strip secret &lt;5p4n&gt; and &lt;/5p4n&gt; tags added by renderer(); spans not used by this template

		if english:match ('\'\'+$') then										-- if &lt;english&gt; is italic, bold, or both
			local text = english:gsub ('%b&lt;&gt;', ''):gsub ('\'\'+', ''):gsub ('%[%[', ''):gsub ('%]%]', '');	-- strip markup
			if text:match ('[dfijkltCEFHIJKMNPR-Z\'&quot;%?!%]]$') then				-- when &lt;english&gt; ends with one of these characters
				english =  '&lt;span style=&quot;margin-right:.09em&quot;&gt;' .. english .. '&lt;/span&gt;';	-- add kerning
			end
		end

		return english .. frame:extensionTag ({name='ref', args={group=group, name=ref_name}, content=content});	-- english with attached reference tag
	else
		return english;															-- nothing to be inside ref tag so just return english
	end
end


--[=[-------------------------&lt; N I H O N G O &gt;----------------------------------------------------------------

Implement {{nihongo}} using Module:Lang for language and transliteration markup

{{Nihongo|&lt;English&gt;|&lt;japanese&gt;|&lt;romaji&gt;|&lt;extra&gt;|&lt;extra2&gt;|lead=yes}}

&lt;English&gt;, &lt;japanese&gt;, and &lt;romaji&gt; are positional parameters
	&lt;English&gt;: rendered as presented; purports to be English translation of &lt;kanji/kana&gt;
	&lt;japanese&gt;: Japanese language text using Japanese script; TODO: require?
	&lt;romaji&gt;: Hepburn romanization (transliteration); TODO: in Module:Lang/data change tooltip text to 'Hepburn romanization'?
&lt;extra&gt; and &lt;extra2&gt; are positional or named: |extra= and |extra2=; mixing can be problematic
	&lt;extra&gt; is rendered as presented preceeded with &lt;comma&gt;&lt;space&gt;
	&lt;extra2&gt; is rendered as presented preceeded with &lt;space&gt;
|lead=: takes one value 'yes'; renders language name same as {{langx|ja}} but also adds [[Hepburn romanization|Hepburn]]:&lt;space&gt; ahead of the romanization; TODO: in Module:Lang, turnoff tooltip for transl when |lead=yes

]=]

local function nihongo (frame)
	return common (frame, 'nihongo')
end


--[=[-------------------------&lt; N I H O N G O 3 &gt;--------------------------------------------------------------

Implement {{nihongo3}} using Module:Lang for language and transliteration markup

Similar to {{nihongo}} but changes rendered order and does not support |lead=

{{Nihongo3|&lt;English&gt;|&lt;japanese&gt;|&lt;romaji&gt;|&lt;extra&gt;|&lt;extra2&gt;}}

&lt;English&gt;, &lt;japanese&gt;, and &lt;romaji&gt; are positional parameters
	&lt;English&gt;: rendered as presented; purports to be English translation of &lt;kanji/kana&gt;
	&lt;japanese&gt;: Japanese language text using Japanese script; TODO: require?
	&lt;romaji&gt;: Hepburn romanization (transliteration); TODO: in Module:Lang/data change tooltip text to 'Hepburn romanization'?
&lt;extra&gt; and &lt;extra2&gt; are positional or named: |extra= and |extra2=; mixing can be problematic
	&lt;extra&gt; is rendered as presented preceded with &lt;comma&gt;&lt;space&gt;
	&lt;extra2&gt; is rendered as presented preceded with &lt;space&gt;

]=]

local function nihongo3 (frame)
	return common_romanized_native_translated (frame, 'nihongo3')
end


--[=[-------------------------&lt; N I H O N G O _ K R T &gt;--------------------------------------------------------

Implement {{nihongo krt}} using Module:Lang for language and transliteration markup

Similar to {{nihongo}} but changes rendered order and does not support |lead=

{{Nihongo krt|&lt;English&gt;|&lt;japanese&gt;|&lt;romaji&gt;|&lt;extra&gt;|&lt;extra2&gt;}}

&lt;English&gt;, &lt;japanese&gt;, and &lt;romaji&gt; are positional parameters
	&lt;English&gt;: rendered as presented; purports to be English translation of &lt;kanji/kana&gt;
	&lt;japanese&gt;: Japanese language text using Japanese script; TODO: require?
	&lt;romaji&gt;: Hepburn romanization (transliteration); TODO: in Module:Lang/data change tooltip text to 'Hepburn romanization'?
	&lt;extra&gt; and &lt;extra2&gt; are positional or named: |extra= and |extra2=; mixing can be problematic
	&lt;extra&gt; is rendered as presented preceded with &lt;comma&gt;&lt;space&gt;
	&lt;extra2&gt; is rendered as presented preceded with &lt;space&gt;

]=]

local function nihongo_krt (frame)
	return common_native_romanized_translated (frame, 'nihongo krt')
end


--[=[-------------------------&lt; N I H O N G O _ F O O T &gt;------------------------------------------------------

Implement {{nihongo_foot}} using Module:Lang for language and transliteration markup

{{Nihongo foot|&lt;English&gt;|&lt;japanese&gt;|&lt;romaji&gt;|&lt;extra&gt;|&lt;extra2&gt;|&lt;post&gt;|lead=yes|group}}

&lt;English&gt;, &lt;japanese&gt;, and &lt;romaji&gt; are positional parameters
	&lt;English&gt;: rendered as presented; purports to be English translation of &lt;kanji/kana&gt;
	&lt;japanese&gt;: Japanese language text using Japanese script; TODO: require?
	&lt;romaji&gt;: Hepburn romanization (transliteration); TODO: in Module:Lang/data change tooltip text to 'Hepburn romanization'?
&lt;extra&gt; and &lt;extra2&gt; are positional or named: |extra= and |extra2=; mixing can be problematic
	&lt;extra&gt; is rendered as presented preceded with &lt;comma&gt;&lt;space&gt;
	&lt;extra2&gt; is rendered as presented preceded with &lt;space&gt;
&lt;post&gt; is positional or named: |post= is a postscript character preceding the &lt;ref&gt;..&lt;/ref&gt; tag (after &lt;English&gt;)
|lead=: takes one value 'yes'; renders language name same as {{langx|ja}} but also adds [[Hepburn romanization|Hepburn]]:&lt;space&gt; ahead of the romanization;
	TODO: in Module:Lang, turnoff tooltip for transl when |lead=yes
	in the live template |lead= also adds the Help:Installing Japanese character sets link; this is not supported in this code (nihongo nor nihongo3 have this support)
|group=: the group attribute in &lt;ref group=&quot;...&quot;&gt; and in {{reflist}}

]=]

local function nihongo_foot (frame)
	return common_foot (frame, 'nihongo foot')
end


--[[--------------------------&lt; E X P O R T E D   F U N C T I O N S &gt;------------------------------------------
]]

return {
	nihongo = nihongo,
	nihongo3 = nihongo3,
	nihongo_krt = nihongo_krt,
	nihongo_foot = nihongo_foot,
	}</text>
      <sha1>9j0e03l8qw3wgdriip8pcmbf1gssnwu</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Respond</title>
    <ns>10</ns>
    <id>1108</id>
    <revision>
      <id>6509</id>
      <timestamp>2026-05-18T10:35:30Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;&lt;includeonly&gt;&lt;span class=&quot;nowrap&quot;&gt;File:{{{{{|safesubst:}}}#switch:{{{1|{{{icon|}}}}}} |blackcheck = Black check.svg{{!}}class=skin-invert |bluebrokenplus = Symbol unsupport2 vote.svg |bluecheck2 = Cornflower blue check.svg |bluecheck = Artículo bueno-blue.svg |blueclock = Pictogram voting wait blue.svg |blueplus = Symbol support2 vote.svg |deferred = Symbol deferred.svg |greencheck2 = Yes check.svg |greencheck = Symbol confirmed.svg |greenclock = Pictogram voting wait...&quot;</comment>
      <origin>6509</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1293" sha1="3vudpuvu6jm9bs1h8q6q2phbcqhdjig" xml:space="preserve">&lt;includeonly&gt;&lt;span class=&quot;nowrap&quot;&gt;[[File:{{{{{|safesubst:}}}#switch:{{{1|{{{icon|}}}}}}
|blackcheck = Black check.svg{{!}}class=skin-invert
|bluebrokenplus = Symbol unsupport2 vote.svg
|bluecheck2 = Cornflower blue check.svg
|bluecheck = Artículo bueno-blue.svg
|blueclock = Pictogram voting wait blue.svg
|blueplus = Symbol support2 vote.svg
|deferred = Symbol deferred.svg
|greencheck2 = Yes check.svg
|greencheck = Symbol confirmed.svg
|greenclock = Pictogram voting wait green.svg
|greenplus = Symbol support vote.svg
|greybrokenplus = Symbol unsupport vote.svg
|greyexclamation = Pictogram voting comment.svg
|info=Symbol information vote.svg
|minus = Symbol declined.svg
|neutral = Symbol neutral vote.svg
|orangeclock = Pictogram voting wait orange.svg
|orangeexclamation = Ambox important.svg
|redexclamation = Ambox important red.svg
|pinkclock = Pictogram voting wait pink.svg
|question2 = Symbol question.svg
|question = Pictogram voting question.svg
|wait = Symbol_wait.svg
|xmark2 = X mark.svg
|xmark = Symbol unrelated.svg
|yellowcheck = Yellow check.svg
|yellowclock = Pictogram voting wait.svg
|{{{1|{{{icon|Pictogram voting question.svg}}}}}}}}|{{{size|18px}}}|alt={{{alt|}}}]] &lt;b&gt;{{{2|{{{text|Ipendulo}}}}}}&lt;/b&gt;&lt;/span&gt;&lt;/includeonly&gt;&lt;noinclude&gt;
{{Documentation}}
&lt;/noinclude&gt;</text>
      <sha1>3vudpuvu6jm9bs1h8q6q2phbcqhdjig</sha1>
    </revision>
    <revision>
      <id>6512</id>
      <parentid>6509</parentid>
      <timestamp>2026-05-18T10:39:23Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6512</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1334" sha1="c6wfxhvnhb83robw6vyu0cj8qvdwtmk" xml:space="preserve">&lt;includeonly&gt;&lt;span class=&quot;nowrap&quot;&gt;[[File:{{{{{|safesubst:}}}#switch:{{{1|{{{icon|}}}}}}
|blackcheck = Black check.svg{{!}}class=skin-invert
|bluebrokenplus = Symbol unsupport2 vote.svg
|bluecheck2 = Cornflower blue check.svg
|bluecheck = Artículo bueno-blue.svg
|blueclock = Pictogram voting wait blue.svg
|blueplus = Symbol support2 vote.svg
|deferred = Symbol deferred.svg
|greencheck2 = Yes check.svg
|greencheck = Symbol confirmed.svg
|greenclock = Pictogram voting wait green.svg
|greenplus = Symbol support vote.svg
|greybrokenplus = Symbol unsupport vote.svg
|greyexclamation = Pictogram voting comment.svg
|info=Symbol information vote.svg
|minus = Symbol declined.svg
|neutral = Symbol neutral vote.svg
|orangeclock = Pictogram voting wait orange.svg
|orangeexclamation = Ambox important.svg
|redexclamation = Ambox important red.svg
|pinkclock = Pictogram voting wait pink.svg
|question2 = Symbol question.svg
|question = Pictogram voting question.svg
|wait = Symbol_wait.svg
|xmark2 = X mark.svg
|xmark = Symbol unrelated.svg
|yellowcheck = Yellow check.svg
|yellowclock = Pictogram voting wait.svg
|{{{1|{{{icon|Pictogram voting question.svg}}}}}}}}|{{{size|18px}}}|alt={{{alt|}}}]] &lt;b&gt;{{{2|{{{text|Ipendulo}}}}}}&lt;/b&gt;&lt;/span&gt;&lt;/includeonly&gt;&lt;noinclude&gt;
{{Documentation}}[[Category:Image with comment templates]]
&lt;/noinclude&gt;</text>
      <sha1>c6wfxhvnhb83robw6vyu0cj8qvdwtmk</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Declined</title>
    <ns>10</ns>
    <id>1109</id>
    <revision>
      <id>6510</id>
      <timestamp>2026-05-18T10:37:33Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;{{Respond|minus|{{{1|Akukenziwa}}}|alt=no}}&lt;noinclude&gt; {{documentation }}&lt;/noinclude&gt;&quot;</comment>
      <origin>6510</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="85" sha1="s8965rlpm385tgzags8ye4418k11wou" xml:space="preserve">{{Respond|minus|{{{1|Akukenziwa}}}|alt=no}}&lt;noinclude&gt;
{{documentation
}}&lt;/noinclude&gt;</text>
      <sha1>s8965rlpm385tgzags8ye4418k11wou</sha1>
    </revision>
    <revision>
      <id>6511</id>
      <parentid>6510</parentid>
      <timestamp>2026-05-18T10:39:10Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6511</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="127" sha1="af1bdho6nin5x9ihmaeccgq7xn7ws8c" xml:space="preserve">{{Respond|minus|{{{1|Akukenziwa}}}|alt=no}}&lt;noinclude&gt;
{{documentation
}}
[[Category:Image with comment templates]]&lt;/noinclude&gt;</text>
      <sha1>af1bdho6nin5x9ihmaeccgq7xn7ws8c</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Image with comment templates</title>
    <ns>14</ns>
    <id>1110</id>
    <revision>
      <id>6513</id>
      <timestamp>2026-05-18T10:39:38Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created blank page</comment>
      <origin>6513</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Done</title>
    <ns>10</ns>
    <id>1111</id>
    <revision>
      <id>6514</id>
      <timestamp>2026-05-18T10:41:24Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;&lt;span class=&quot;nowrap&quot;&gt;[[File:Yes check.svg|18px|link=|alt=]]'''&amp;nbsp;{{{1|Phelile}}}'''&lt;/span&gt;{{{{{|safesubst:}}}#if:{{{2|{{{note|{{{reason|}}}}}}}}}|&amp;#58; {{{2|{{{note|{{{reason}}}}}}}}}}}&lt;!--template:done--&gt;&lt;noinclude&gt; {{documentation}}[[Category:Image with comment templates]] &lt;/noinclude&gt;&quot;</comment>
      <origin>6514</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="291" sha1="apq1kk4wdsm09sj1jqsbycp5p8cye7e" xml:space="preserve">&lt;span class=&quot;nowrap&quot;&gt;[[File:Yes check.svg|18px|link=|alt=]]'''&amp;nbsp;{{{1|Phelile}}}'''&lt;/span&gt;{{{{{|safesubst:}}}#if:{{{2|{{{note|{{{reason|}}}}}}}}}|&amp;#58; {{{2|{{{note|{{{reason}}}}}}}}}}}&lt;!--template:done--&gt;&lt;noinclude&gt;
{{documentation}}[[Category:Image with comment templates]]
&lt;/noinclude&gt;</text>
      <sha1>apq1kk4wdsm09sj1jqsbycp5p8cye7e</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Expired</title>
    <ns>10</ns>
    <id>1112</id>
    <revision>
      <id>6515</id>
      <timestamp>2026-05-18T10:43:58Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;&lt;b class=&quot;nowrap&quot;&gt;{{xmark}}&lt;/b&gt; '''Umnikelo lo sele uphelelwe sikhathi'''&lt;noinclude&gt; {{documentation}}[[Category:Image with comment templates]] &lt;/noinclude&gt;&quot;</comment>
      <origin>6515</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="156" sha1="fc4adkmfh6szdf9wqe7nrv6cyxtmvbo" xml:space="preserve">&lt;b class=&quot;nowrap&quot;&gt;{{xmark}}&lt;/b&gt; '''Umnikelo lo sele uphelelwe sikhathi'''&lt;noinclude&gt;
{{documentation}}[[Category:Image with comment templates]]
&lt;/noinclude&gt;</text>
      <sha1>fc4adkmfh6szdf9wqe7nrv6cyxtmvbo</sha1>
    </revision>
    <revision>
      <id>6519</id>
      <parentid>6515</parentid>
      <timestamp>2026-05-18T10:47:34Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6519</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="83" sha1="jx7dc9rijux72scpq57gv7e5bur06r8" xml:space="preserve">'''Umnikelo lo sele uphelelwe sikhathi'''&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>jx7dc9rijux72scpq57gv7e5bur06r8</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Xmark</title>
    <ns>10</ns>
    <id>1113</id>
    <revision>
      <id>6516</id>
      <timestamp>2026-05-18T10:45:40Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;{{ {{{|safesubst:}}}#switch:{{ {{{|safesubst:}}}lc:{{{color|{{{colour|}}}}}} }} |red            |rd  |r  =File:X mark.svg |darkred |dkred |drd |dr =File:Dark red x.svg |orange         |or  |o  =File:Orange x.svg |yellow         |yel |y  =File:Dark yellow x.svg |black          |blk |k  =File:Black x.svg |grey    |gray  |gry |gy =File:SemiTransBlack x.svg &lt;!--default--&gt;      |File:X mark.svg }}|{{Str number/trim|{{ {{{|safesubst:}}}#if:{{{1|}}}|{{{1}}}|20}}}}px|link=|alt...&quot;</comment>
      <origin>6516</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="583" sha1="ao1r2idt4i2z7b9ri1t055g2i60da0p" xml:space="preserve">[[{{ {{{|safesubst:}}}#switch:{{ {{{|safesubst:}}}lc:{{{color|{{{colour|}}}}}} }}
|red            |rd  |r  =File:X mark.svg
|darkred |dkred |drd |dr =File:Dark red x.svg
|orange         |or  |o  =File:Orange x.svg
|yellow         |yel |y  =File:Dark yellow x.svg
|black          |blk |k  =File:Black x.svg
|grey    |gray  |gry |gy =File:SemiTransBlack x.svg
&lt;!--default--&gt;      |File:X mark.svg
}}|{{Str number/trim|{{ {{{|safesubst:}}}#if:{{{1|}}}|{{{1}}}|20}}}}px|link=|alt=&amp;#9746;]]&lt;span style=&quot;display:none&quot;&gt;N&lt;/span&gt;&lt;!--template:Xmark--&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>ao1r2idt4i2z7b9ri1t055g2i60da0p</sha1>
    </revision>
    <revision>
      <id>6517</id>
      <parentid>6516</parentid>
      <timestamp>2026-05-18T10:46:51Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Replaced content with &quot;{{Delete}}&quot;</comment>
      <origin>6517</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="10" sha1="ojdjkvlhcec6arpfgtwm59d2wkd8rvp" xml:space="preserve">{{Delete}}</text>
      <sha1>ojdjkvlhcec6arpfgtwm59d2wkd8rvp</sha1>
    </revision>
    <revision>
      <id>6518</id>
      <parentid>6517</parentid>
      <timestamp>2026-05-18T10:47:09Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6518</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="19" sha1="eoaxo9x8bo62czzwjlxp31z8p4iw9rs" xml:space="preserve">{{Delete|Accident}}</text>
      <sha1>eoaxo9x8bo62czzwjlxp31z8p4iw9rs</sha1>
    </revision>
    <revision>
      <id>6561</id>
      <parentid>6518</parentid>
      <timestamp>2026-05-18T13:45:52Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6561</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="588" sha1="a05jrzy1hd56hxsmhmpcj15prnxk20q" xml:space="preserve">[[{{ {{{|safesubst:}}}#switch:{{ {{{|safesubst:}}}lc:{{{color|{{{colour|}}}}}} }}
|red            |rd  |r  =File:X mark.svg
|darkred |dkred |drd |dr =File:Dark red x.svg
|orange         |or  |o  =File:Orange x.svg
|yellow         |yel |y  =File:Dark yellow x.svg
|black          |blk |k  =File:Black x.svg
|grey    |gray  |gry |gy =File:SemiTransBlack x.svg
&lt;!--default--&gt;      |File:X mark.svg
}}|{{Str number/trim|{{ {{{|safesubst:}}}#if:{{{1|}}}|{{{1}}}|20}}}}px|link=|alt=&amp;#9746;|20px]]&lt;span style=&quot;display:none&quot;&gt;N&lt;/span&gt;&lt;!--template:Xmark--&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>a05jrzy1hd56hxsmhmpcj15prnxk20q</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Responding to ping</title>
    <ns>10</ns>
    <id>1114</id>
    <revision>
      <id>6521</id>
      <timestamp>2026-05-18T10:52:18Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;&lt;small&gt;(&lt;span style=&quot;color:#333;&quot;&gt;ukuphendula uku[[:en:Help:Notifications|ping]]&lt;/span&gt;)&lt;/small&gt;&lt;noinclude&gt; {{documentation}} &lt;!-- Categories go on the /doc subpage, and interwikis go on Wikidata. --&gt; &lt;/noinclude&gt;&quot;</comment>
      <origin>6521</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="213" sha1="6t7jhgmzwgv2d1jxrn5w2iyhzhha633" xml:space="preserve">&lt;small&gt;(&lt;span style=&quot;color:#333;&quot;&gt;ukuphendula uku[[:en:Help:Notifications|ping]]&lt;/span&gt;)&lt;/small&gt;&lt;noinclude&gt;
{{documentation}}
&lt;!-- Categories go on the /doc subpage, and interwikis go on Wikidata. --&gt;
&lt;/noinclude&gt;</text>
      <sha1>6t7jhgmzwgv2d1jxrn5w2iyhzhha633</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Decline</title>
    <ns>10</ns>
    <id>1115</id>
    <revision>
      <id>6522</id>
      <timestamp>2026-05-18T11:50:05Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;{{Respond|bluebrokenplus|{{{1|Umabhalana wala}}}}}&lt;noinclude&gt;{{documentation}} [[Category:Image with comment templates]] [[Category:SPI templates]]&lt;/noinclude&gt;&quot;</comment>
      <origin>6522</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="159" sha1="bvduhjyusvkk9vtsasmq7go4vyg2emz" xml:space="preserve">{{Respond|bluebrokenplus|{{{1|Umabhalana wala}}}}}&lt;noinclude&gt;{{documentation}}
[[Category:Image with comment templates]]
[[Category:SPI templates]]&lt;/noinclude&gt;</text>
      <sha1>bvduhjyusvkk9vtsasmq7go4vyg2emz</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:N/A icon</title>
    <ns>10</ns>
    <id>1116</id>
    <revision>
      <id>6523</id>
      <timestamp>2026-05-18T11:53:31Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;{{Respond|greybrokenplus|{{{1|Akusebenzi}}}}}&lt;noinclude&gt;{{documentation}} [[Category:Image with comment templates]]&lt;/noinclude&gt;&quot;</comment>
      <origin>6523</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="127" sha1="fpovh3mnyv6fynryqmwtd1x12whirh8" xml:space="preserve">{{Respond|greybrokenplus|{{{1|Akusebenzi}}}}}&lt;noinclude&gt;{{documentation}}
[[Category:Image with comment templates]]&lt;/noinclude&gt;</text>
      <sha1>fpovh3mnyv6fynryqmwtd1x12whirh8</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Phakamisa amahlombe</title>
    <ns>10</ns>
    <id>1117</id>
    <revision>
      <id>6524</id>
      <timestamp>2026-05-18T11:56:25Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;&lt;span class=&quot;nowrap&quot; role=&quot;img&quot; aria-label=&quot;shrug&quot;&gt;¯\_(ツ)_/¯&lt;/span&gt;&lt;!-- Umhlahlandlelasakhiwo:Phakamisa amahlombe --&gt;&lt;noinclude&gt; {{documentation}} &lt;/noinclude&gt;&quot;</comment>
      <origin>6524</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="163" sha1="c8x2uu7bwya1ffnlldoav1d93xiuss2" xml:space="preserve">&lt;span class=&quot;nowrap&quot; role=&quot;img&quot; aria-label=&quot;shrug&quot;&gt;¯\_(ツ)_/¯&lt;/span&gt;&lt;!-- Umhlahlandlelasakhiwo:Phakamisa amahlombe --&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>c8x2uu7bwya1ffnlldoav1d93xiuss2</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Shrug</title>
    <ns>10</ns>
    <id>1118</id>
    <redirect title="Umhlahlandlelasakhiwo:Phakamisa amahlombe" />
    <revision>
      <id>6525</id>
      <timestamp>2026-05-18T11:57:07Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Redirected page to [[Umhlahlandlelasakhiwo:Phakamisa amahlombe]]</comment>
      <origin>6525</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="55" sha1="ex9cuxl4xmlp7djahc3o1eyfjc7t33f" xml:space="preserve">#REDIRECT [[Umhlahlandlelasakhiwo:Phakamisa amahlombe]]</text>
      <sha1>ex9cuxl4xmlp7djahc3o1eyfjc7t33f</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Lenny</title>
    <ns>10</ns>
    <id>1119</id>
    <revision>
      <id>6526</id>
      <timestamp>2026-05-18T11:58:04Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;&lt;span class=&quot;nowrap&quot; role=&quot;img&quot; aria-label=&quot;Lenny face&quot;&gt;( ͡° ͜ʖ ͡°)&lt;/span&gt;&lt;!-- Umhlahlandlelasakhiwo:Lenny --&gt;&lt;noinclude&gt; {{Documentation}}&lt;/noinclude&gt;&quot;</comment>
      <origin>6526</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="157" sha1="gixttu6n5fxaetzudxxaydegrije6te" xml:space="preserve">&lt;span class=&quot;nowrap&quot; role=&quot;img&quot; aria-label=&quot;Lenny face&quot;&gt;( ͡° ͜ʖ ͡°)&lt;/span&gt;&lt;!-- Umhlahlandlelasakhiwo:Lenny --&gt;&lt;noinclude&gt;
{{Documentation}}&lt;/noinclude&gt;</text>
      <sha1>gixttu6n5fxaetzudxxaydegrije6te</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Table flip</title>
    <ns>10</ns>
    <id>1120</id>
    <revision>
      <id>6527</id>
      <timestamp>2026-05-18T11:59:26Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;&lt;span class=&quot;nowrap&quot; role=&quot;img&quot; aria-label=&quot;flipping table&quot;&gt;(╯°□°)╯︵ ┻━┻&lt;/span&gt;&lt;noinclude&gt;{{documentation}} &lt;/noinclude&gt;&quot;</comment>
      <origin>6527</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="136" sha1="aisrqofzypuobmyddhulyh999eb21ya" xml:space="preserve">&lt;span class=&quot;nowrap&quot; role=&quot;img&quot; aria-label=&quot;flipping table&quot;&gt;(╯°□°)╯︵ ┻━┻&lt;/span&gt;&lt;noinclude&gt;{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>aisrqofzypuobmyddhulyh999eb21ya</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Isikere</title>
    <ns>10</ns>
    <id>1121</id>
    <revision>
      <id>6528</id>
      <timestamp>2026-05-18T12:01:44Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;[[File:Twemoji12 2702.svg|{{{size|30px}}}|alt=scissors]] '''{{{1|Ukugijima ngesikere kuyingozi khulu ku-Wikipedia!}}}'''&lt;noinclude&gt; {{documentation}} &lt;/noinclude&gt;&quot;</comment>
      <origin>6528</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="162" sha1="aifzm7scs43agmtlfaghfk7vbhpz6ke" xml:space="preserve">[[File:Twemoji12 2702.svg|{{{size|30px}}}|alt=scissors]] '''{{{1|Ukugijima ngesikere kuyingozi khulu ku-Wikipedia!}}}'''&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>aifzm7scs43agmtlfaghfk7vbhpz6ke</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Doge</title>
    <ns>10</ns>
    <id>1122</id>
    <revision>
      <id>6529</id>
      <timestamp>2026-05-18T12:04:38Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;[[File:Doge.svg|20px|alt=|link=|doge]]&lt;noinclude&gt;{{documentation |content= {{humor}} Isifanekiso lesi sisetjenziselwa ukutjengisa isithombe seDoge. ==Ukusetjenziswa== Isifanekiso lesi asinawo amapharamitha. &lt;syntaxhighlight lang=&quot;wikitext&quot;&gt; {{Doge}} &lt;/syntaxhighlight&gt; }} &lt;/noinclude&gt;&quot;</comment>
      <origin>6529</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="284" sha1="1o9f64yrpsngf56rlyqr833d8ls86xg" xml:space="preserve">[[File:Doge.svg|20px|alt=|link=|doge]]&lt;noinclude&gt;{{documentation
|content=
{{humor}}
Isifanekiso lesi sisetjenziselwa ukutjengisa isithombe seDoge.
==Ukusetjenziswa==
Isifanekiso lesi asinawo amapharamitha.
&lt;syntaxhighlight lang=&quot;wikitext&quot;&gt;
{{Doge}}
&lt;/syntaxhighlight&gt;
}}
&lt;/noinclude&gt;</text>
      <sha1>1o9f64yrpsngf56rlyqr833d8ls86xg</sha1>
    </revision>
    <revision>
      <id>6531</id>
      <parentid>6529</parentid>
      <timestamp>2026-05-18T12:08:40Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6531</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="294" sha1="n19kd4u9h9ics27vs0z35uep297b3qy" xml:space="preserve">[[File:Doge.svg|20px|alt=|link=|doge]]&lt;noinclude&gt;{{documentation
|content=
{{humor}}
Umhlahlandlelasakhiwo lesi sisetjenziselwa ukutjengisa isithombe seDoge.
==Ukusetjenziswa==
Isifanekiso lesi asinawo amapharamitha.
&lt;syntaxhighlight lang=&quot;wikitext&quot;&gt;
{{Doge}}
&lt;/syntaxhighlight&gt;
}}
&lt;/noinclude&gt;</text>
      <sha1>n19kd4u9h9ics27vs0z35uep297b3qy</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Humor</title>
    <ns>10</ns>
    <id>1123</id>
    <revision>
      <id>6530</id>
      <timestamp>2026-05-18T12:07:20Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;&lt;big&gt;'''Ikhasi leli liqukethe izinto ezithathwa njengezihlekisako'''. Iinsetjenziswa ezinjalo akukafaneli zithathwe njengezingakaqakatheki.&lt;/big&gt; &lt;noinclude&gt;{{documentation}}&lt;/noinclude&gt;&quot;</comment>
      <origin>6530</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="186" sha1="4ieip8n43xruhv24zbnc1jojfetxwv8" xml:space="preserve">&lt;big&gt;'''Ikhasi leli liqukethe izinto ezithathwa njengezihlekisako'''. Iinsetjenziswa ezinjalo akukafaneli zithathwe njengezingakaqakatheki.&lt;/big&gt;
&lt;noinclude&gt;{{documentation}}&lt;/noinclude&gt;</text>
      <sha1>4ieip8n43xruhv24zbnc1jojfetxwv8</sha1>
    </revision>
    <revision>
      <id>6532</id>
      <parentid>6530</parentid>
      <timestamp>2026-05-18T12:09:18Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6532</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="190" sha1="axofly2ml68th798xx7zezytuumycx8" xml:space="preserve">&lt;big&gt;'''''Ikhasi leli liqukethe izinto ezithathwa njengezihlekisako'''. Iinsetjenziswa ezinjalo akukafaneli zithathwe njengezingakaqakatheki.''&lt;/big&gt;
&lt;noinclude&gt;{{documentation}}&lt;/noinclude&gt;</text>
      <sha1>axofly2ml68th798xx7zezytuumycx8</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:NgamangaXhosa</title>
    <ns>2</ns>
    <id>1124</id>
    <revision>
      <id>6534</id>
      <timestamp>2026-05-18T12:11:52Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;Ngenze isizo elikhulu kuWikipedia yesiNdebele     seSewula. {{doge}} {{N/A icon}}&quot;</comment>
      <origin>6534</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="81" sha1="ewaumt7rh7sou89bof0tttzm6v3a9d6" xml:space="preserve">Ngenze isizo elikhulu kuWikipedia yesiNdebele     seSewula. {{doge}} {{N/A icon}}</text>
      <sha1>ewaumt7rh7sou89bof0tttzm6v3a9d6</sha1>
    </revision>
    <revision>
      <id>6535</id>
      <parentid>6534</parentid>
      <timestamp>2026-05-18T12:12:11Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6535</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="91" sha1="a08f7y3c68rwh9qk8jpxjt3zwnn3ngr" xml:space="preserve">Ngenze isizo elikhulu kuWikipedia yesiNdebele     seSewula. {{shrug}} {{doge}} {{N/A icon}}</text>
      <sha1>a08f7y3c68rwh9qk8jpxjt3zwnn3ngr</sha1>
    </revision>
    <revision>
      <id>6575</id>
      <parentid>6535</parentid>
      <timestamp>2026-05-19T05:34:32Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6575</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="115" sha1="6ipjswxvl2rn1m21ea8stj3f75biwij" xml:space="preserve">{{mail|NgamangaXhosa}}

Ngenze isizo elikhulu kuWikipedia yesiNdebele     seSewula. {{shrug}} {{doge}} {{N/A icon}}</text>
      <sha1>6ipjswxvl2rn1m21ea8stj3f75biwij</sha1>
    </revision>
    <revision>
      <id>6637</id>
      <parentid>6575</parentid>
      <timestamp>2026-05-20T02:27:09Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6637</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="114" sha1="5oh4ueiw6qmganzg1en8pzjqp5mnk8w" xml:space="preserve">{{mail|{{PAGENAME}}}}

Ngenze isizo elikhulu kuWikipedia yesiNdebele     seSewula. {{shrug}} {{doge}} {{N/A icon}}</text>
      <sha1>5oh4ueiw6qmganzg1en8pzjqp5mnk8w</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Facepalm</title>
    <ns>10</ns>
    <id>1125</id>
    <revision>
      <id>6536</id>
      <timestamp>2026-05-18T12:17:06Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;{{{{{|safesubst:}}}#switch: {{{{{|safesubst:}}}lc:{{{1}}}}} | supreme | sfod=[[File:Facepalm3.svg|{{{size|20px}}}|alt=Isandlasobuso|class=skin-invert]] '''Isandlasobuso''' | #default=[[File:Facepalm3.svg|{{{size|15px}}}|alt=Isandlasobuso|class=skin-invert]] '''{{{1|Isandlasobuso}}} '''}}&lt;noinclude&gt; {{Documentation}} &lt;!-- Add categories to the /doc subpage, interwikis to Wikidata, not here --&gt; &lt;/noinclude&gt;&quot;</comment>
      <origin>6536</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="408" sha1="9160661zpl1b35xtt3uethhngn4f6p7" xml:space="preserve">{{{{{|safesubst:}}}#switch: {{{{{|safesubst:}}}lc:{{{1}}}}} | supreme | sfod=[[File:Facepalm3.svg|{{{size|20px}}}|alt=Isandlasobuso|class=skin-invert]] '''Isandlasobuso''' | #default=[[File:Facepalm3.svg|{{{size|15px}}}|alt=Isandlasobuso|class=skin-invert]] '''{{{1|Isandlasobuso}}} '''}}&lt;noinclude&gt;
{{Documentation}}
&lt;!-- Add categories to the /doc subpage, interwikis to Wikidata, not here --&gt;
&lt;/noinclude&gt;</text>
      <sha1>9160661zpl1b35xtt3uethhngn4f6p7</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi asiqongelane:JayJaytutu</title>
    <ns>3</ns>
    <id>1126</id>
    <revision>
      <id>6539</id>
      <timestamp>2026-05-18T12:21:40Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>/* Ngibawa ungamotjhisi iWikipedia */ new section</comment>
      <origin>6539</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="262" sha1="sx30vgmkv3rmnmbwszjngc5ravesysp" xml:space="preserve">== Ngibawa ungamotjhisi iWikipedia ==

Nawuragela phambili nokwenza njalo, ungavinjelwa mlawuli. Zoke iintjhuguluko zakho: {{Declined}} [[Umsebenzisi:NgamangaXhosa|NgamangaXhosa]] ([[Umsebenzisi asiqongelane:NgamangaXhosa|talk]]) 14:21, 18 Nkwenkwezi 2026 (SAST)</text>
      <sha1>sx30vgmkv3rmnmbwszjngc5ravesysp</sha1>
    </revision>
    <revision>
      <id>6540</id>
      <parentid>6539</parentid>
      <timestamp>2026-05-18T12:24:30Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6540</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="285" sha1="rcaarwpla2fwj483ljlrf78ycfkbgdk" xml:space="preserve">== Ngibawa ungamotjhisi iWikipedia ==

Nawuragela phambili nokwenza njalo, ungavinjelwa mlawuli. Zoke iintjhuguluko zakho: {{Declined}} kunye {{N/A icon}}. -- [[Umsebenzisi:NgamangaXhosa|NgamangaXhosa]] ([[Umsebenzisi asiqongelane:NgamangaXhosa|talk]]) 14:21, 18 Nkwenkwezi 2026 (SAST)</text>
      <sha1>rcaarwpla2fwj483ljlrf78ycfkbgdk</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Not done not likely</title>
    <ns>10</ns>
    <id>1127</id>
    <revision>
      <id>6541</id>
      <timestamp>2026-05-18T13:12:42Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;'''Akukenziwa begodu akukafaneli bona kwenziwe'''&lt;noinclude&gt; {{documentation}} &lt;/noinclude&gt;&quot;</comment>
      <origin>6541</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="91" sha1="him5gafpjykf5yqce14qhe7m6bggayn" xml:space="preserve">'''Akukenziwa begodu akukafaneli bona kwenziwe'''&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>him5gafpjykf5yqce14qhe7m6bggayn</sha1>
    </revision>
    <revision>
      <id>6562</id>
      <parentid>6541</parentid>
      <timestamp>2026-05-18T13:46:48Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6562</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="158" sha1="kfmiqgk16hrl2n3kedate6zviyd3iy4" xml:space="preserve">{{{{{|safesubst:}}}xmark|18}} '''{{{{{|safesubst:}}}ucfirst:{{{1|Akukenziwa begodu akukafaneli bona kwenziwe}}}}}'''&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>kfmiqgk16hrl2n3kedate6zviyd3iy4</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:You've got mail</title>
    <ns>10</ns>
    <id>1128</id>
    <revision>
      <id>6542</id>
      <timestamp>2026-05-18T13:17:15Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;&lt;big&gt;'''''Lotjha. Sibawa uhlole i-imeyili yakho; une-imeyela!''' Kungathatha imizuzu embalwa kusukela ngesikhathi i-imeyili ithunyelwa bona ivele ebhokisini lakho lokungenayo. Ungasusa isaziso lesi nanyana kunini ngokususa umhlahlandlelasakhiwo esithi ''{{tl|You've got mail}}.&lt;noinclude&gt;{{documentation}}&lt;!-- PLEASE ADD CATEGORIES AND INTERWIKIS TO THE /doc SUB-PAGE, THANKS --&gt;&lt;/noinclude&gt;&quot;</comment>
      <origin>6542</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="391" sha1="olw8dql9wboowm44gjglyoenbtfh6k3" xml:space="preserve">&lt;big&gt;'''''Lotjha. Sibawa uhlole i-imeyili yakho; une-imeyela!''' Kungathatha imizuzu embalwa kusukela ngesikhathi i-imeyili ithunyelwa bona ivele ebhokisini lakho lokungenayo. Ungasusa isaziso lesi nanyana kunini ngokususa umhlahlandlelasakhiwo esithi ''{{tl|You've got mail}}.&lt;noinclude&gt;{{documentation}}&lt;!-- PLEASE ADD CATEGORIES AND INTERWIKIS TO THE /doc SUB-PAGE, THANKS --&gt;&lt;/noinclude&gt;</text>
      <sha1>olw8dql9wboowm44gjglyoenbtfh6k3</sha1>
    </revision>
    <revision>
      <id>6543</id>
      <parentid>6542</parentid>
      <timestamp>2026-05-18T13:18:02Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6543</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="431" sha1="bsl430fwjluhnqcv3gujxmdlmokce83" xml:space="preserve">[[file:Mail-message-new.svg|left|25px]] &lt;big&gt;'''''Lotjha. Sibawa uhlole i-imeyili yakho; une-imeyela!''' Kungathatha imizuzu embalwa kusukela ngesikhathi i-imeyili ithunyelwa bona ivele ebhokisini lakho lokungenayo. Ungasusa isaziso lesi nanyana kunini ngokususa umhlahlandlelasakhiwo esithi ''{{tl|You've got mail}}.&lt;noinclude&gt;{{documentation}}&lt;!-- PLEASE ADD CATEGORIES AND INTERWIKIS TO THE /doc SUB-PAGE, THANKS --&gt;&lt;/noinclude&gt;</text>
      <sha1>bsl430fwjluhnqcv3gujxmdlmokce83</sha1>
    </revision>
    <revision>
      <id>6544</id>
      <parentid>6543</parentid>
      <timestamp>2026-05-18T13:18:17Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6544</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="431" sha1="5mi919k6x57fol1omd6ijtl6kenpcw0" xml:space="preserve">[[file:Mail-message-new.svg|left|50px]] &lt;big&gt;'''''Lotjha. Sibawa uhlole i-imeyili yakho; une-imeyela!''' Kungathatha imizuzu embalwa kusukela ngesikhathi i-imeyili ithunyelwa bona ivele ebhokisini lakho lokungenayo. Ungasusa isaziso lesi nanyana kunini ngokususa umhlahlandlelasakhiwo esithi ''{{tl|You've got mail}}.&lt;noinclude&gt;{{documentation}}&lt;!-- PLEASE ADD CATEGORIES AND INTERWIKIS TO THE /doc SUB-PAGE, THANKS --&gt;&lt;/noinclude&gt;</text>
      <sha1>5mi919k6x57fol1omd6ijtl6kenpcw0</sha1>
    </revision>
    <revision>
      <id>6547</id>
      <parentid>6544</parentid>
      <timestamp>2026-05-18T13:22:03Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6547</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="437" sha1="rktv3ni7v0zr7dv9vzfono2sz1hc6wr" xml:space="preserve">[[file:Mail-message-new.svg|left|50px]] &lt;big&gt;'''''Lotjha. Sibawa uhlole i-imeyili yakho; une-imeyela!''' Kungathatha imizuzu embalwa kusukela ngesikhathi i-imeyili ithunyelwa bona ivele ebhokisini lakho lokungenayo. Ungasusa isaziso lesi nanyana kunini ngokususa umhlahlandlelasakhiwo esithi ''{{tl|You've got mail}}.&lt;/big&gt;&lt;noinclude&gt;{{documentation}}&lt;!-- PLEASE ADD CATEGORIES AND INTERWIKIS TO THE /doc SUB-PAGE, THANKS --&gt;&lt;/noinclude&gt;</text>
      <sha1>rktv3ni7v0zr7dv9vzfono2sz1hc6wr</sha1>
    </revision>
    <revision>
      <id>6548</id>
      <parentid>6547</parentid>
      <timestamp>2026-05-18T13:22:31Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6548</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="437" sha1="ortvwm8nvdx9lkabmqet66032dx65pr" xml:space="preserve">[[file:Mail-message-new.svg|left|50px]] &lt;big&gt;'''''Lotjha. Sibawa uhlole i-imeyili yakho; une-imeyela!'''&lt;/big&gt; Kungathatha imizuzu embalwa kusukela ngesikhathi i-imeyili ithunyelwa bona ivele ebhokisini lakho lokungenayo. Ungasusa isaziso lesi nanyana kunini ngokususa umhlahlandlelasakhiwo esithi ''{{tl|You've got mail}}.&lt;noinclude&gt;{{documentation}}&lt;!-- PLEASE ADD CATEGORIES AND INTERWIKIS TO THE /doc SUB-PAGE, THANKS --&gt;&lt;/noinclude&gt;</text>
      <sha1>ortvwm8nvdx9lkabmqet66032dx65pr</sha1>
    </revision>
    <revision>
      <id>6549</id>
      <parentid>6548</parentid>
      <timestamp>2026-05-18T13:22:59Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6549</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="434" sha1="1o95g2evxypkt2zh77x4xfw2zxzk20y" xml:space="preserve">[[file:Mail-message-new.svg|left|50px]] &lt;big&gt;
'''Lotjha. Sibawa uhlole i-imeyili yakho; une-imeyela!'''&lt;/big&gt; Kungathatha imizuzu embalwa kusukela ngesikhathi i-imeyili ithunyelwa bona ivele ebhokisini lakho lokungenayo. Ungasusa isaziso lesi nanyana kunini ngokususa umhlahlandlelasakhiwo esithi {{tl|You've got mail}}.&lt;noinclude&gt;{{documentation}}&lt;!-- PLEASE ADD CATEGORIES AND INTERWIKIS TO THE /doc SUB-PAGE, THANKS --&gt;&lt;/noinclude&gt;</text>
      <sha1>1o95g2evxypkt2zh77x4xfw2zxzk20y</sha1>
    </revision>
    <revision>
      <id>6551</id>
      <parentid>6549</parentid>
      <timestamp>2026-05-18T13:24:51Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6551</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="452" sha1="kavkx5kh70b8tirzlccyegojugj2t1q" xml:space="preserve">[[file:Mail-message-new.svg|left|50px]] &lt;big&gt;
'''Lotjha. Sibawa uhlole i-imeyili yakho; une-imeyela!'''&lt;/big&gt; Kungathatha imizuzu embalwa kusukela ngesikhathi i-imeyili ithunyelwa bona ivele ebhokisini lakho lokungenayo. Ungasusa isaziso lesi nanyana kunini ngokususa umhlahlandlelasakhiwo esithi {{tl|You've got mail}} nofana {{tl|ygm}}.&lt;noinclude&gt;{{documentation}}&lt;!-- PLEASE ADD CATEGORIES AND INTERWIKIS TO THE /doc SUB-PAGE, THANKS --&gt;&lt;/noinclude&gt;</text>
      <sha1>kavkx5kh70b8tirzlccyegojugj2t1q</sha1>
    </revision>
    <revision>
      <id>6552</id>
      <parentid>6551</parentid>
      <timestamp>2026-05-18T13:25:14Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6552</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="452" sha1="7e5nkpw7jp8v88zj2niwgviegpubsm9" xml:space="preserve">[[file:Mail-message-new.svg|left|45px]] &lt;big&gt;
'''Lotjha. Sibawa uhlole i-imeyili yakho; une-imeyela!'''&lt;/big&gt; Kungathatha imizuzu embalwa kusukela ngesikhathi i-imeyili ithunyelwa bona ivele ebhokisini lakho lokungenayo. Ungasusa isaziso lesi nanyana kunini ngokususa umhlahlandlelasakhiwo esithi {{tl|You've got mail}} nofana {{tl|ygm}}.&lt;noinclude&gt;{{documentation}}&lt;!-- PLEASE ADD CATEGORIES AND INTERWIKIS TO THE /doc SUB-PAGE, THANKS --&gt;&lt;/noinclude&gt;</text>
      <sha1>7e5nkpw7jp8v88zj2niwgviegpubsm9</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Tl</title>
    <ns>10</ns>
    <id>1129</id>
    <revision>
      <id>6545</id>
      <timestamp>2026-05-18T13:20:00Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;&lt;span class=&quot;nowrap&quot;&gt;&amp;#123;&amp;#123;&lt;/span&gt;[[Umhlahlandlelasakhiwo:{{{1}}}|{{{1}}}]]&lt;span class=&quot;nowrap&quot;&gt;&amp;#125;&amp;#125;&lt;/span&gt;&lt;noinclude&gt; {{documentation}} &lt;!-- Categories go on the /doc subpage and interwikis go on Wikidata. --&gt; &lt;/noinclude&gt;&quot;</comment>
      <origin>6545</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="237" sha1="426vuhh2ag394kwx7lcul6dlts5hw5v" xml:space="preserve">&lt;span class=&quot;nowrap&quot;&gt;&amp;#123;&amp;#123;&lt;/span&gt;[[Umhlahlandlelasakhiwo:{{{1}}}|{{{1}}}]]&lt;span class=&quot;nowrap&quot;&gt;&amp;#125;&amp;#125;&lt;/span&gt;&lt;noinclude&gt;
{{documentation}}
&lt;!-- Categories go on the /doc subpage and interwikis go on Wikidata. --&gt;
&lt;/noinclude&gt;</text>
      <sha1>426vuhh2ag394kwx7lcul6dlts5hw5v</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi asiqongelane:Nomsa Skosana</title>
    <ns>3</ns>
    <id>1130</id>
    <revision>
      <id>6546</id>
      <timestamp>2026-05-18T13:21:32Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>/* Une-imeyela! */ new section</comment>
      <origin>6546</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="166" sha1="6ee1z159snrqc8r8mwdhwwqqp46saz9" xml:space="preserve">== Une-imeyela! ==

{{You've got mail}} [[Umsebenzisi:NgamangaXhosa|NgamangaXhosa]] ([[Umsebenzisi asiqongelane:NgamangaXhosa|talk]]) 15:21, 18 Nkwenkwezi 2026 (SAST)</text>
      <sha1>6ee1z159snrqc8r8mwdhwwqqp46saz9</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Ygm</title>
    <ns>10</ns>
    <id>1131</id>
    <redirect title="Umhlahlandlelasakhiwo:You&#039;ve got mail" />
    <revision>
      <id>6550</id>
      <timestamp>2026-05-18T13:23:29Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Redirected page to [[Umhlahlandlelasakhiwo:You've got mail]]</comment>
      <origin>6550</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="51" sha1="lu4l9qfngamdfgn306eq5rjztf4ungh" xml:space="preserve">#REDIRECT [[Umhlahlandlelasakhiwo:You've got mail]]</text>
      <sha1>lu4l9qfngamdfgn306eq5rjztf4ungh</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:You're welcome</title>
    <ns>10</ns>
    <id>1132</id>
    <revision>
      <id>6553</id>
      <timestamp>2026-05-18T13:29:07Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;&lt;b class=&quot;nowrap&quot;&gt;[[File:Face-smile.svg|18px|alt=|link=]] Wamukelekile!&lt;!--Umhlahlandlelasakhiwo:You're welcome--&gt;&lt;noinclude&gt; {{documentation}} &lt;/noinclude&gt;&quot;</comment>
      <origin>6553</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="156" sha1="0fcyy53lbsiwv3rz96hwp3fo5sucgzo" xml:space="preserve">&lt;b class=&quot;nowrap&quot;&gt;[[File:Face-smile.svg|18px|alt=|link=]] Wamukelekile!&lt;!--Umhlahlandlelasakhiwo:You're welcome--&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>0fcyy53lbsiwv3rz96hwp3fo5sucgzo</sha1>
    </revision>
    <revision>
      <id>6554</id>
      <parentid>6553</parentid>
      <timestamp>2026-05-18T13:29:31Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6554</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="160" sha1="lqh5nhfq3jqs8mn06lqtk4ri1g3ranh" xml:space="preserve">&lt;b class=&quot;nowrap&quot;&gt;[[File:Face-smile.svg|18px|alt=|link=]] Wamukelekile!&lt;/b&gt;&lt;!--Umhlahlandlelasakhiwo:You're welcome--&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>lqh5nhfq3jqs8mn06lqtk4ri1g3ranh</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Thank you</title>
    <ns>10</ns>
    <id>1133</id>
    <revision>
      <id>6555</id>
      <timestamp>2026-05-18T13:30:54Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;&lt;span class=&quot;nowrap&quot;&gt;[[File:Face-smile.svg|18px|link=]] '''Ngiyathokoza'''&lt;/span&gt;&lt;!--Template:Thank you--&gt;&lt;noinclude&gt; {{documentation}} &lt;/noinclude&gt;&quot;</comment>
      <origin>6555</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="148" sha1="39cqf9toqqvxea6hbgrmzeyfmtivvox" xml:space="preserve">&lt;span class=&quot;nowrap&quot;&gt;[[File:Face-smile.svg|18px|link=]] '''Ngiyathokoza'''&lt;/span&gt;&lt;!--Template:Thank you--&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>39cqf9toqqvxea6hbgrmzeyfmtivvox</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Stop</title>
    <ns>10</ns>
    <id>1134</id>
    <revision>
      <id>6556</id>
      <timestamp>2026-05-18T13:33:21Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;[[File:Dialog-stop-hand.svg|{{Str number/trim|{{{1|30}}}}}px|Stop|alt=stop|link=|30px]]&lt;noinclude&gt; {{Documentation|content=Umhlahlandlelasakhiwo lesi silingana no: :&lt;code&gt;&lt;nowiki&gt;[[File:Dialog-stop-hand.svg|{{Str number/trim|{{{1|30}}}}}px|Stop|alt=stop|link=|30px]]&lt;/nowiki&gt;&lt;/code&gt; [[Category:Wikipedia-specific image insertion templates]] }} &lt;/noinclude&gt;&quot;</comment>
      <origin>6556</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="356" sha1="rubci3vv7zawounilwlox7x3jvqplcv" xml:space="preserve">[[File:Dialog-stop-hand.svg|{{Str number/trim|{{{1|30}}}}}px|Stop|alt=stop|link=|30px]]&lt;noinclude&gt;
{{Documentation|content=Umhlahlandlelasakhiwo lesi silingana no:
:&lt;code&gt;&lt;nowiki&gt;[[File:Dialog-stop-hand.svg|{{Str number/trim|{{{1|30}}}}}px|Stop|alt=stop|link=|30px]]&lt;/nowiki&gt;&lt;/code&gt;
[[Category:Wikipedia-specific image insertion templates]]
}}
&lt;/noinclude&gt;</text>
      <sha1>rubci3vv7zawounilwlox7x3jvqplcv</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Bulb</title>
    <ns>10</ns>
    <id>1135</id>
    <revision>
      <id>6557</id>
      <timestamp>2026-05-18T13:35:14Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;[[File:Dialog-information on.svg|{{Str number/trim|{{{1|20}}}}}px|alt=Light bulb icon|link=|20px]]&lt;span style=&quot;display:none&quot;&gt;B&lt;/span&gt;&lt;!--umhlahlandlelasakhiwo:bulb--&gt;&lt;noinclude&gt; {{documentation}} &lt;/noinclude&gt;&quot;</comment>
      <origin>6557</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="208" sha1="8ofq6cej28xtbevszdz0yag2egvn271" xml:space="preserve">[[File:Dialog-information on.svg|{{Str number/trim|{{{1|20}}}}}px|alt=Light bulb icon|link=|20px]]&lt;span style=&quot;display:none&quot;&gt;B&lt;/span&gt;&lt;!--umhlahlandlelasakhiwo:bulb--&gt;&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>8ofq6cej28xtbevszdz0yag2egvn271</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Warnsign</title>
    <ns>10</ns>
    <id>1136</id>
    <revision>
      <id>6558</id>
      <timestamp>2026-05-18T13:37:42Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;{{Respond|Ambox warning pn.svg|{{{1|Ukukhalima}}}}}&lt;noinclude&gt; {{Documentation}} &lt;!--Please add this template's categories to the /doc subpage, not here - thanks!--&gt; &lt;/noinclude&gt;&quot;</comment>
      <origin>6558</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="178" sha1="jy91y0i43shs4u08b9j2x3xahl8c10r" xml:space="preserve">{{Respond|Ambox warning pn.svg|{{{1|Ukukhalima}}}}}&lt;noinclude&gt;
{{Documentation}}
&lt;!--Please add this template's categories to the /doc subpage, not here - thanks!--&gt;
&lt;/noinclude&gt;</text>
      <sha1>jy91y0i43shs4u08b9j2x3xahl8c10r</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:AfD changed</title>
    <ns>10</ns>
    <id>1137</id>
    <revision>
      <id>6559</id>
      <timestamp>2026-05-18T13:40:36Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;* &lt;small&gt;'''Tjheja:''' I-imitlolo le '''itjhuguluke khulu''' solo yaphakanyiswa yi-AfD. ~&lt;includeonly&gt;~&lt;/includeonly&gt;~~&lt;/small&gt;  &lt;noinclude&gt;{{Documentation}}&lt;/noinclude&gt;&quot;</comment>
      <origin>6559</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="169" sha1="3nqklm1wvjy8uhmn8tkufqvaybrsgdk" xml:space="preserve">* &lt;small&gt;'''Tjheja:''' I-imitlolo le '''itjhuguluke khulu''' solo yaphakanyiswa yi-AfD. ~&lt;includeonly&gt;~&lt;/includeonly&gt;~~&lt;/small&gt;

&lt;noinclude&gt;{{Documentation}}&lt;/noinclude&gt;</text>
      <sha1>3nqklm1wvjy8uhmn8tkufqvaybrsgdk</sha1>
    </revision>
    <revision>
      <id>6560</id>
      <parentid>6559</parentid>
      <timestamp>2026-05-18T13:42:01Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6560</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="168" sha1="p3o5k1swafz0sxaokszieu77trmsw0g" xml:space="preserve">* &lt;small&gt;'''Tjheja:''' Iimitlolo le '''itjhuguluke khulu''' solo yaphakanyiswa yi-AfD. ~&lt;includeonly&gt;~&lt;/includeonly&gt;~~&lt;/small&gt;

&lt;noinclude&gt;{{Documentation}}&lt;/noinclude&gt;</text>
      <sha1>p3o5k1swafz0sxaokszieu77trmsw0g</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Mail</title>
    <ns>10</ns>
    <id>1138</id>
    <revision>
      <id>6565</id>
      <timestamp>2026-05-19T02:58:14Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;&lt;includeonly&gt;{{#if: {{NAMESPACE}}   |[[File:Nuvola apps email.svg|16px|link=]] {{#if: {{{1|}}}     | [[ Special:EmailUser/{{{1}}} | {{#if: {{{2|}}} | {{{2}}} | iposi {{{1}}} }} ]]     | {{#switch: {{NAMESPACE}}       | User        | User talk = [[ Special:EmailUser/{{#titleparts: {{PAGENAME}}|1}} | ngithumelele iposi ]]       | #default = {{error|Please specify user's name as first parameter.}}     }}   }}   | {{error|Mail template not usable in article space!}} }}&lt;/incl...&quot;</comment>
      <origin>6565</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="553" sha1="l7ngfrqbxi4fljixqb0lt4xbr6mjyg0" xml:space="preserve">&lt;includeonly&gt;{{#if: {{NAMESPACE}}
  |[[File:Nuvola apps email.svg|16px|link=]] {{#if: {{{1|}}}
    | [[ Special:EmailUser/{{{1}}} | {{#if: {{{2|}}} | {{{2}}} | iposi {{{1}}} }} ]]
    | {{#switch: {{NAMESPACE}}
      | User 
      | User talk = [[ Special:EmailUser/{{#titleparts: {{PAGENAME}}|1}} | ngithumelele iposi ]]
      | #default = {{error|Please specify user's name as first parameter.}}
    }}
  }}
  | {{error|Mail template not usable in article space!}}
}}&lt;/includeonly&gt;&lt;noinclude&gt;{{mail|Example|iposi Example}}{{documentation}}&lt;/noinclude&gt;</text>
      <sha1>l7ngfrqbxi4fljixqb0lt4xbr6mjyg0</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Error</title>
    <ns>10</ns>
    <id>1139</id>
    <revision>
      <id>6566</id>
      <timestamp>2026-05-19T02:59:20Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;{{#invoke:Error|error|{{{message|{{{1}}}}}}|tag={{{tag|}}}}}&lt;noinclude&gt; {{documentation}} &lt;/noinclude&gt;&quot;</comment>
      <origin>6566</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="102" sha1="axsripqkyjus55mon24y6efvuedy0d2" xml:space="preserve">{{#invoke:Error|error|{{{message|{{{1}}}}}}|tag={{{tag|}}}}}&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>axsripqkyjus55mon24y6efvuedy0d2</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Error</title>
    <ns>828</ns>
    <id>1140</id>
    <revision>
      <id>6567</id>
      <timestamp>2026-05-19T02:59:49Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;-- This module implements {{error}}.  local p = {}  function p._error(args)     local tag = mw.ustring.lower(tostring(args.tag))      -- Work out what html tag we should use.     if not (tag == 'p' or tag == 'span' or tag == 'div') then         tag = 'strong'     end      -- Generate the html.     return tostring(mw.html.create(tag)         :addClass('error')         :cssText(args.style)         :wikitext(tostring(args.message or args[1] or error('no message specified',...&quot;</comment>
      <origin>6567</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="1156" sha1="p2nz3ttxcounymhrrhzzv162xd74myk" xml:space="preserve">-- This module implements {{error}}.

local p = {}

function p._error(args)
    local tag = mw.ustring.lower(tostring(args.tag))

    -- Work out what html tag we should use.
    if not (tag == 'p' or tag == 'span' or tag == 'div') then
        tag = 'strong'
    end

    -- Generate the html.
    return tostring(mw.html.create(tag)
        :addClass('error')
        :cssText(args.style)
        :wikitext(tostring(args.message or args[1] or error('no message specified', 2)))
    )
end

function p.error(frame)
    local args
    if type(frame.args) == 'table' then
        -- We're being called via #invoke. The args are passed through to the module
        -- from the template page, so use the args that were passed into the template.
        args = frame.args
    else
        -- We're being called from another module or from the debug console, so assume
        -- the args are passed in directly.
        args = frame
    end
    -- if the message parameter is present but blank, change it to nil so that Lua will
    -- consider it false.
    if args.message == &quot;&quot; then
        args.message = nil
    end
    return p._error(args)
end

return p</text>
      <sha1>p2nz3ttxcounymhrrhzzv162xd74myk</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Helped</title>
    <ns>10</ns>
    <id>1141</id>
    <revision>
      <id>6568</id>
      <timestamp>2026-05-19T03:02:52Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;&lt;span class=&quot;nowrap&quot;&gt;[[File:Yes check.svg|20px|link=|alt=]] '''{{{1|Kusiziwe}}}'''&lt;/span&gt;&lt;!--template:helped--&gt;&lt;noinclude&gt;{{documentation|content= [[Category:Image with comment templates]] }}&lt;/noinclude&gt;&quot;</comment>
      <origin>6568</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="203" sha1="jhzbz1vq2cmocnh99o03w4hqv1wkmqm" xml:space="preserve">&lt;span class=&quot;nowrap&quot;&gt;[[File:Yes check.svg|20px|link=|alt=]] '''{{{1|Kusiziwe}}}'''&lt;/span&gt;&lt;!--template:helped--&gt;&lt;noinclude&gt;{{documentation|content=
[[Category:Image with comment templates]]
}}&lt;/noinclude&gt;</text>
      <sha1>jhzbz1vq2cmocnh99o03w4hqv1wkmqm</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Blockedtaggedclosing</title>
    <ns>10</ns>
    <id>1142</id>
    <revision>
      <id>6569</id>
      <timestamp>2026-05-19T03:06:30Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;{{Respond|bluecheck|{{{1|Ivinjelwe begodu ithegiwe. Ukuvala.}}}}}&lt;noinclude&gt;{{documentation|content=  [[Category:Image with comment templates|{{PAGENAME}}]] [[Category:SPI templates]]}} &lt;/noinclude&gt;&quot;</comment>
      <origin>6569</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="198" sha1="og3nmvb8i70o3hv1oxggix5ag82wqoy" xml:space="preserve">{{Respond|bluecheck|{{{1|Ivinjelwe begodu ithegiwe. Ukuvala.}}}}}&lt;noinclude&gt;{{documentation|content=

[[Category:Image with comment templates|{{PAGENAME}}]]
[[Category:SPI templates]]}}
&lt;/noinclude&gt;</text>
      <sha1>og3nmvb8i70o3hv1oxggix5ag82wqoy</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Agree</title>
    <ns>10</ns>
    <id>1143</id>
    <revision>
      <id>6570</id>
      <timestamp>2026-05-19T03:08:13Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;&lt;span class=&quot;nowrap&quot;&gt;[[File:Symbol confirmed.svg|20px|link=|alt=]] '''{{{1|Ukuvuma}}}'''&lt;/span&gt;&lt;noinclude&gt; {{Documentation}} &lt;!--Categories go on the /doc subpage --&gt; &lt;/noinclude&gt;&quot;</comment>
      <origin>6570</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="179" sha1="jxa1zj6yavwwslvas7fj0qt7ueukeak" xml:space="preserve">&lt;span class=&quot;nowrap&quot;&gt;[[File:Symbol confirmed.svg|20px|link=|alt=]] '''{{{1|Ukuvuma}}}'''&lt;/span&gt;&lt;noinclude&gt;
{{Documentation}}
&lt;!--Categories go on the /doc subpage --&gt;
&lt;/noinclude&gt;</text>
      <sha1>jxa1zj6yavwwslvas7fj0qt7ueukeak</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Location map</title>
    <ns>10</ns>
    <id>1144</id>
    <revision>
      <id>6571</id>
      <timestamp>2026-05-19T03:09:10Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;&lt;includeonly&gt;{{#invoke:Location map|main}}&lt;/includeonly&gt;&lt;noinclude&gt;{{documentation}}&lt;/noinclude&gt;&quot;</comment>
      <origin>6571</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="96" sha1="dg6vj3epjyfwx0m7tx62smhp6gs0y2u" xml:space="preserve">&lt;includeonly&gt;{{#invoke:Location map|main}}&lt;/includeonly&gt;&lt;noinclude&gt;{{documentation}}&lt;/noinclude&gt;</text>
      <sha1>dg6vj3epjyfwx0m7tx62smhp6gs0y2u</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Location map</title>
    <ns>828</ns>
    <id>1145</id>
    <revision>
      <id>6572</id>
      <timestamp>2026-05-19T03:10:01Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;require('strict')  local p = {}  local getArgs = require('Module:Arguments').getArgs  local function round(n, decimals) 	local pow = 10^(decimals or 0) 	return math.floor(n * pow + 0.5) / pow end  function p.getMapParams(map, frame) 	if not map then 		error('The name of the location map definition to use must be specified', 2) 	end 	local moduletitle = mw.title.new('Module:Location map/data/' .. map) 	if not moduletitle then 		error(string.format('%q is not a valid name...&quot;</comment>
      <origin>6572</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="21897" sha1="07icxbtq9eg84dyuhbuyo1sfebx4tq4" xml:space="preserve">require('strict')

local p = {}

local getArgs = require('Module:Arguments').getArgs

local function round(n, decimals)
	local pow = 10^(decimals or 0)
	return math.floor(n * pow + 0.5) / pow
end

function p.getMapParams(map, frame)
	if not map then
		error('The name of the location map definition to use must be specified', 2)
	end
	local moduletitle = mw.title.new('Module:Location map/data/' .. map)
	if not moduletitle then
		error(string.format('%q is not a valid name for a location map definition', map), 2)
	elseif moduletitle.exists then
		local mapData = mw.loadData('Module:Location map/data/' .. map)
		return function(name, params)
			if name == nil then
				return 'Module:Location map/data/' .. map
			elseif mapData[name] == nil then
				return ''
			elseif params then
				return mw.message.newRawMessage(tostring(mapData[name]), unpack(params)):plain()
			else
				return mapData[name]
			end
		end
	else
		error('Unable to find the specified location map definition: &quot;Module:Location map/data/' .. map .. '&quot; does not exist', 2)
	end
end

function p.data(frame, args, map)
	if not args then
		args = getArgs(frame, {frameOnly = true})
	end
	if not map then
		map = p.getMapParams(args[1], frame)
	end
	local params = {}
	for k,v in ipairs(args) do
		if k &gt; 2 then
			params[k-2] = v
		end
	end
	return map(args[2], #params ~= 0 and params)
end

local hemisphereMultipliers = {
	longitude = { W = -1, w = -1, E = 1, e = 1 },
	latitude = { S = -1, s = -1, N = 1, n = 1 }
}

local function decdeg(degrees, minutes, seconds, hemisphere, decimal, direction)
	if decimal then
		if degrees then
			error('Decimal and DMS degrees cannot both be provided for ' .. direction, 2)
		elseif minutes then
			error('Minutes can only be provided with DMS degrees for ' .. direction, 2)
		elseif seconds then
			error('Seconds can only be provided with DMS degrees for ' .. direction, 2)
		elseif hemisphere then
			error('A hemisphere can only be provided with DMS degrees for ' .. direction, 2)
		end
		local retval = tonumber(decimal)
		if retval then
			return retval
		end
		error('The value &quot;' .. decimal .. '&quot; provided for ' .. direction .. ' is not valid', 2)
	elseif seconds and not minutes then
		error('Seconds were provided for ' .. direction .. ' without minutes also being provided', 2)
	elseif not degrees then
		if minutes then
			error('Minutes were provided for ' .. direction .. ' without degrees also being provided', 2)
		elseif hemisphere then
			error('A hemisphere was provided for ' .. direction .. ' without degrees also being provided', 2)
		end
		return nil
	end
	decimal = tonumber(degrees)
	if not decimal then
		error('The degree value &quot;' .. degrees .. '&quot; provided for ' .. direction .. ' is not valid', 2)
	elseif minutes and not tonumber(minutes) then
		error('The minute value &quot;' .. minutes .. '&quot; provided for ' .. direction .. ' is not valid', 2)
	elseif seconds and not tonumber(seconds) then
		error('The second value &quot;' .. seconds .. '&quot; provided for ' .. direction .. ' is not valid', 2)
	end
	decimal = decimal + (minutes or 0)/60 + (seconds or 0)/3600
	if hemisphere then
		local multiplier = hemisphereMultipliers[direction][hemisphere]
		if not multiplier then
			error('The hemisphere &quot;' .. hemisphere .. '&quot; provided for ' .. direction .. ' is not valid', 2)
		end
		decimal = decimal * multiplier
	end
	return decimal
end

-- Finds a parameter in a transclusion of {{Coord}}.
local function coord2text(para,coord) -- this should be changed for languages which do not use Arabic numerals or the degree sign
	local lat, long = mw.ustring.match(coord,'&lt;span class=&quot;p%-latitude latitude&quot;&gt;([^&lt;]+)&lt;/span&gt;&lt;span class=&quot;p%-longitude longitude&quot;&gt;([^&lt;]+)&lt;/span&gt;')
	if lat then
		return tonumber(para == 'longitude' and long or lat)
	end
	local result = mw.text.split(mw.ustring.match(coord,'%-?[%.%d]+°[NS] %-?[%.%d]+°[EW]') or '', '[ °]')
	if para == 'longitude' then result = {result[3], result[4]} end
	if not tonumber(result[1]) or not result[2] then
		mw.log('Malformed coordinates value')
		mw.logObject(para, 'para')
		mw.logObject(coord, 'coord')
		return error('Malformed coordinates value', 2)
	end
	return tonumber(result[1]) * hemisphereMultipliers[para][result[2]]
end

-- effectively make removeBlanks false for caption and maplink, and true for everything else
-- if useWikidata is present but blank, convert it to false instead of nil
-- p.top, p.bottom, and their callers need to use this
function p.valueFunc(key, value)
	if value then
		value = mw.text.trim(value)
	end
	if value ~= '' or key == 'caption' or key == 'maplink' then
		return value
	elseif key == 'useWikidata' then
		return false
	end
end

local function getContainerImage(args, map)
	if args.AlternativeMap then
		return args.AlternativeMap
	elseif args.relief then
        local digits = mw.ustring.match(args.relief,'^[1-9][0-9]?$') or '1' -- image1 to image99
        if map('image' .. digits) ~= '' then
            return map('image' .. digits)
        end
	end
    return map('image')
end

function p.top(frame, args, map)
	if not args then
		args = getArgs(frame, {frameOnly = true, valueFunc = p.valueFunc})
	end
	if not map then
		map = p.getMapParams(args[1], frame)
	end
	local width
	local default_as_number = tonumber(mw.ustring.match(tostring(args.default_width),&quot;%d*&quot;))
	if not args.width then
		width = round((default_as_number or 240) * (tonumber(map('defaultscale')) or 1))
	elseif mw.ustring.sub(args.width, -2) == 'px' then
		width = mw.ustring.sub(args.width, 1, -3)
	else
		width = args.width
	end
	local width_as_number = tonumber(mw.ustring.match(tostring(width),&quot;%d*&quot;)) or 0;
    if width_as_number == 0 then
    	-- check to see if width is junk. If it is, then use default calculation
    	width = round((default_as_number or 240) * (tonumber(map('defaultscale')) or 1))
    	width_as_number = tonumber(mw.ustring.match(tostring(width),&quot;%d*&quot;)) or 0;
    end	
    if args.max_width ~= &quot;&quot; and args.max_width ~= nil then
        -- check to see if width bigger than max_width
        local max_as_number = tonumber(mw.ustring.match(args.max_width,&quot;%d*&quot;)) or 0;
        if width_as_number&gt;max_as_number and max_as_number&gt;0 then
            width = args.max_width;
        end
    end
	local retval = frame:extensionTag{name = 'templatestyles', args = {src = 'Module:Location map/styles.css'}}
	if args.float == 'center' then
		retval = retval .. '&lt;div class=&quot;center&quot;&gt;'
	end
	if args.caption and args.caption ~= '' and args.border ~= 'infobox' then
		retval = retval .. '&lt;div class=&quot;locmap noresize thumb '
		if args.float == '&quot;left&quot;' or args.float == 'left' then
			retval = retval .. 'tleft'
		elseif args.float == '&quot;center&quot;' or args.float == 'center' or args.float == '&quot;none&quot;' or args.float == 'none' then
			retval = retval .. 'tnone'
		else
			retval = retval .. 'tright'
		end
		retval = retval .. '&quot;&gt;&lt;div class=&quot;thumbinner&quot; style=&quot;width:' .. (width + 2) .. 'px'
		if args.border == 'none' then
			retval = retval .. ';border:none'
		elseif args.border then
			retval = retval .. ';border-color:' .. args.border
		end
		retval = retval .. '&quot;&gt;&lt;div style=&quot;position:relative;width:' .. width .. 'px' .. (args.border ~= 'none' and ';border:1px solid lightgray&quot;&gt;' or '&quot;&gt;')
	else
		retval = retval .. '&lt;div class=&quot;locmap&quot; style=&quot;width:' .. width .. 'px;'
		if args.float == '&quot;left&quot;' or args.float == 'left' then
			retval = retval .. 'float:left;clear:left'
		elseif args.float == '&quot;center&quot;' or args.float == 'center' then
			retval = retval .. 'float:none;clear:both;margin-left:auto;margin-right:auto'
		elseif args.float == '&quot;none&quot;' or args.float == 'none' then
			retval = retval .. 'float:none;clear:none'
		else
			retval = retval .. 'float:right;clear:right'
		end
		retval = retval .. '&quot;&gt;&lt;div style=&quot;width:' .. width .. 'px;padding:0&quot;&gt;&lt;div style=&quot;position:relative;width:' .. width .. 'px&quot;&gt;'
	end
	local image = getContainerImage(args, map)
	local currentTitle = mw.title.getCurrentTitle()
	retval = string.format(
		'%s[[File:%s|%spx|%s%s|class=notpageimage noviewer]]',
		retval,
		image,
		width,
		args.alt or ((args.label or currentTitle.text) .. ' is located in ' .. map('name')),
		args.maplink and ('|link=' .. args.maplink) or ''
	)
	if args.caption and args.caption ~= '' then
		if (currentTitle.namespace == 0) and mw.ustring.find(args.caption, '##') then
			retval = retval .. '[[Category:Pages using location map with a double number sign in the caption]]'
		end
	end
	if args.overlay_image then
		return retval .. '&lt;div style=&quot;position:absolute;top:0;left:0&quot;&gt;[[File:' .. args.overlay_image .. '|' .. width .. 'px|class=notpageimage noviewer]]&lt;/div&gt;'
	else
		return retval
	end
end

function p.bottom(frame, args, map)
	if not args then
		args = getArgs(frame, {frameOnly = true, valueFunc = p.valueFunc})
	end
	if not map then
		map = p.getMapParams(args[1], frame)
	end
	local retval = '&lt;/div&gt;'
	local currentTitle = mw.title.getCurrentTitle()
	if not args.caption or args.border == 'infobox' then
		if args.border then
			retval = retval .. '&lt;div style=&quot;padding-top:0.2em&quot;&gt;'
		else
			retval = retval .. '&lt;div style=&quot;font-size:91%;padding-top:3px&quot;&gt;'
		end
		retval = retval
		.. (args.caption or (args.label or currentTitle.text) .. ' (' .. map('name') .. ')')
		.. '&lt;/div&gt;'
	elseif args.caption ~= ''  then
		-- This is not the pipe trick. We're creating a link with no text on purpose, so that CSS can give us a nice image
		retval = retval .. '&lt;div class=&quot;thumbcaption&quot;&gt;&lt;div class=&quot;magnify&quot;&gt;[[:File:' .. getContainerImage(args, map) .. '| ]]&lt;/div&gt;' .. args.caption .. '&lt;/div&gt;'
	end

	if args.switcherLabel then
		retval = retval .. '&lt;span class=&quot;switcher-label&quot; style=&quot;display:none&quot;&gt;' .. args.switcherLabel .. '&lt;/span&gt;'
	elseif args.autoSwitcherLabel then
		retval = retval .. '&lt;span class=&quot;switcher-label&quot; style=&quot;display:none&quot;&gt;Show map of ' .. map('name') .. '&lt;/span&gt;'
	end
	
	retval = retval .. '&lt;/div&gt;&lt;/div&gt;'
	if args.caption_undefined then
		mw.log('Removed parameter caption_undefined used.')
		local parent = frame:getParent()
		if parent then
			mw.log('Parent is ' .. parent:getTitle())
		end
		mw.logObject(args, 'args')
		if currentTitle.namespace == 0 then
		    retval = retval .. '[[Category:Location maps with removed parameters|caption_undefined]]'
		end
	end
	if map('skew') ~= '' or map('lat_skew') ~= '' or map('crosses180') ~= '' or map('type') ~= '' then
		mw.log('Removed parameter used in map definition ' .. map())
		if currentTitle.namespace == 0 then
		    local key = (map('skew') ~= '' and 'skew' or '') ..
					(map('lat_skew') ~= '' and 'lat_skew' or '') ..
					(map('crosses180') ~= '' and 'crosses180' or '') ..
					(map('type') ~= '' and 'type' or '')
		    retval = retval .. '[[Category:Location maps with removed parameters|' .. key .. ' ]]'
		end
	end
	if string.find(map('name'), '|', 1, true) then
		mw.log('Pipe used in name of map definition ' .. map())
		if currentTitle.namespace == 0 then
		   retval = retval .. '[[Category:Location maps with a name containing a pipe]]'
		end
	end
	if args.float == 'center' then
		retval = retval .. '&lt;/div&gt;'
	end
	return retval
end

local function markOuterDiv(x, y, imageDiv, labelDiv, label_size)
	return mw.html.create('div')
		:addClass('od')
		:addClass('notheme') -- T236137
		:cssText('top:' .. round(y, 3) .. '%;left:' .. round(x, 3) .. '%;font-size:' .. label_size .. '%')
		:node(imageDiv)
		:node(labelDiv)
end

local function markImageDiv(mark, marksize, label, link, alt, title)
	local builder = mw.html.create('div')
		:addClass('id')
		:cssText('left:-' .. round(marksize / 2) .. 'px;top:-' .. round(marksize / 2) .. 'px')
		:attr('title', title)
	if marksize ~= 0 then
		builder:wikitext(string.format(
			'[[File:%s|%dx%dpx|%s|link=%s%s|class=notpageimage noviewer]]',
			mark,
			marksize,
			marksize,
			label,
			link,
			alt and ('|alt=' .. alt) or ''
		))
	end
	return builder
end

local function markLabelDiv(label, label_size, label_width, position, background, x, marksize)
	if tonumber(label_size) == 0 then
		return mw.html.create('div'):addClass('l0'):wikitext(label)
	end
	local builder = mw.html.create('div')
		:cssText('width:' .. label_width .. 'em')
	local distance = round(marksize / 2 + 1)
	if position == 'top' then -- specified top
		builder:addClass('pv'):cssText('bottom:' .. distance .. 'px;left:' .. (-label_width / 2) .. 'em')
	elseif position == 'bottom' then -- specified bottom
		builder:addClass('pv'):cssText('top:' .. distance .. 'px;left:' .. (-label_width / 2) .. 'em')
	elseif position == 'left' or (tonumber(x) &gt; 70 and position ~= 'right') then -- specified left or autodetected to left
		builder:addClass('pl'):cssText('right:' .. distance .. 'px')
	else -- specified right or autodetected to right
		builder:addClass('pr'):cssText('left:' .. distance .. 'px')
	end
	builder = builder:tag('div')
		:wikitext(label)
	if background then
		builder:cssText('background-color:' .. background)
	end
	return builder:done()
end

local function getX(longitude, left, right)
	local width = (right - left) % 360
	if width == 0 then
		width = 360
	end
	local distanceFromLeft = (longitude - left) % 360
	-- the distance needed past the map to the right equals distanceFromLeft - width. the distance needed past the map to the left equals 360 - distanceFromLeft. to minimize page stretching, go whichever way is shorter
	if distanceFromLeft - width / 2 &gt;= 180 then
		distanceFromLeft = distanceFromLeft - 360
	end
	return 100 * distanceFromLeft / width
end

local function getY(latitude, top, bottom)
	return 100 * (top - latitude) / (top - bottom)
end

function p.mark(frame, args, map)
	if not args then
		args = getArgs(frame, {wrappers = 'Template:Location map~'})
	end
	local mapnames = {}
	if not map then
		if args[1] then
			map = {}
			for mapname in mw.text.gsplit(args[1], '#', true) do
				map[#map + 1] = p.getMapParams(mw.ustring.gsub(mapname, '^%s*(.-)%s*$', '%1'), frame)
				mapnames[#mapnames + 1] = mapname
			end
			if #map == 1 then map = map[1] end
		else
			map = p.getMapParams('World', frame)
			args[1] = 'World'
		end
	end
	if type(map) == 'table' then
		local outputs = {}
		local oldargs = args[1]
		for k,v in ipairs(map) do
			args[1] = mapnames[k]
			outputs[k] = tostring(p.mark(frame, args, v))
		end
		args[1] = oldargs
		return table.concat(outputs, '#PlaceList#') .. '#PlaceList#'
	end
	local x, y, longitude, latitude
	longitude = decdeg(args.lon_deg, args.lon_min, args.lon_sec, args.lon_dir, args.long, 'longitude')
	latitude = decdeg(args.lat_deg, args.lat_min, args.lat_sec, args.lat_dir, args.lat, 'latitude')
	if args.excludefrom then
		-- If this mark is to be excluded from certain maps entirely (useful in the context of multiple maps)
		for exclusionmap in mw.text.gsplit(args.excludefrom, '#', true) do
			-- Check if this map is excluded. If so, return an empty string.
			if args[1] == exclusionmap then
				return ''
			end
		end
			
	end
	local builder = mw.html.create()
	local currentTitle = mw.title.getCurrentTitle()
	if args.coordinates then
--		Temporarily removed to facilitate infobox conversion. See [[Wikipedia:Coordinates in infoboxes]]

--		if longitude or latitude then
--			error('Coordinates from [[Module:Coordinates]] and individual coordinates cannot both be provided')
--		end
		longitude = coord2text('longitude', args.coordinates)
		latitude = coord2text('latitude', args.coordinates)
	elseif not longitude and not latitude and args.useWikidata then
		-- If they didn't provide either coordinate, try Wikidata. If they provided one but not the other, don't.
		local entity = mw.wikibase.getEntity()
		if entity and entity.claims and entity.claims.P625 and entity.claims.P625[1].mainsnak.snaktype == 'value' then
			local value = entity.claims.P625[1].mainsnak.datavalue.value
			longitude, latitude = value.longitude, value.latitude
		end
		if args.link and (currentTitle.namespace == 0) then
			builder:wikitext('[[Category:Location maps with linked markers with coordinates from Wikidata]]')	
		end
	end
	if not longitude then
		error('No value was provided for longitude')
	elseif not latitude then
		error('No value was provided for latitude')
	end
	if currentTitle.namespace &gt; 0 then
		if (not args.lon_deg) ~= (not args.lat_deg) then
			builder:wikitext('[[Category:Location maps with different longitude and latitude precisions|Degrees]]')
		elseif (not args.lon_min) ~= (not args.lat_min) then
			builder:wikitext('[[Category:Location maps with different longitude and latitude precisions|Minutes]]')
		elseif (not args.lon_sec) ~= (not args.lat_sec) then
			builder:wikitext('[[Category:Location maps with different longitude and latitude precisions|Seconds]]')
		elseif (not args.lon_dir) ~= (not args.lat_dir) then
			builder:wikitext('[[Category:Location maps with different longitude and latitude precisions|Hemisphere]]')
		elseif (not args.long) ~= (not args.lat) then
			builder:wikitext('[[Category:Location maps with different longitude and latitude precisions|Decimal]]')
		end
	end
	if ((tonumber(args.lat_deg) or 0) &lt; 0) and ((tonumber(args.lat_min) or 0) ~= 0 or (tonumber(args.lat_sec) or 0) ~= 0 or (args.lat_dir and args.lat_dir ~='')) then
		builder:wikitext('[[Category:Location maps with negative degrees and minutes or seconds]]')
	end
	if ((tonumber(args.lon_deg) or 0) &lt; 0) and ((tonumber(args.lon_min) or 0) ~= 0 or (tonumber(args.lon_sec) or 0) ~= 0 or (args.lon_dir and args.lon_dir ~= '')) then
		builder:wikitext('[[Category:Location maps with negative degrees and minutes or seconds]]')
	end
	if (((tonumber(args.lat_min) or 0) &lt; 0) or ((tonumber(args.lat_sec) or 0) &lt; 0)) then
		builder:wikitext('[[Category:Location maps with negative degrees and minutes or seconds]]')
	end
	if (((tonumber(args.lon_min) or 0) &lt; 0) or ((tonumber(args.lon_sec) or 0) &lt; 0)) then
		builder:wikitext('[[Category:Location maps with negative degrees and minutes or seconds]]')
	end
	if args.skew or args.lon_shift or args.markhigh then
		mw.log('Removed parameter used in invocation.')
		local parent = frame:getParent()
		if parent then
			mw.log('Parent is ' .. parent:getTitle())
		end
		mw.logObject(args, 'args')
		if currentTitle.namespace == 0 then
			local key = (args.skew and 'skew' or '') ..
						(args.lon_shift and 'lon_shift' or '') ..
						(args.markhigh and 'markhigh' or '')
			builder:wikitext('[[Category:Location maps with removed parameters|' .. key ..' ]]')
		end
	end
	if map('x') ~= '' then
		x = tonumber(mw.ext.ParserFunctions.expr(map('x', { latitude, longitude })))
	else
		x = tonumber(getX(longitude, map('left'), map('right')))
	end
	if map('y') ~= '' then
		y = tonumber(mw.ext.ParserFunctions.expr(map('y', { latitude, longitude })))
	else
		y = tonumber(getY(latitude, map('top'), map('bottom')))
	end
	if (x &lt; 0 or x &gt; 100 or y &lt; 0 or y &gt; 100) and not args.outside then
		mw.log('Mark placed outside map boundaries without outside flag set. x = ' .. x .. ', y = ' .. y)
		local parent = frame:getParent()
		if parent then
			mw.log('Parent is ' .. parent:getTitle())
		end
		mw.logObject(args, 'args')
		if currentTitle.namespace == 0 then
			local key = currentTitle.prefixedText
			builder:wikitext('[[Category:Location maps with marks outside map and outside parameter not set|' .. key .. ' ]]')
		end
	end
	local mark = args.mark or map('mark')
	if mark == '' then
		mark = 'Red pog.svg'
	end
	local marksize = tonumber(args.marksize) or tonumber(map('marksize')) or 8
	local imageDiv = markImageDiv(mark, marksize, args.label or mw.title.getCurrentTitle().text, args.link or '', args.alt, args[2])
	local label_size = args.label_size or 91
	local labelDiv
	if args.label and args.position ~= 'none' then
		labelDiv = markLabelDiv(args.label, label_size, args.label_width or 6, args.position, args.background, x, marksize)
	end
	return builder:node(markOuterDiv(x, y, imageDiv, labelDiv, label_size))
end

local function switcherSeparate(s)
	if s == nil then return {} end
	local retval = {}
	for i in string.gmatch(s .. '#', '([^#]*)#') do
		i = mw.text.trim(i)
		retval[#retval + 1] = (i ~= '' and i)
	end
	return retval
end

function p.main(frame, args, map)
	local caption_list = {}
	if not args then
		args = getArgs(frame, {wrappers = 'Template:Location map', valueFunc = p.valueFunc})
	end
	if args.useWikidata == nil then
		args.useWikidata = true
	end
	if not map then
		if args[1] then
			map = {}
			for mapname in string.gmatch(args[1], '[^#]+') do
				map[#map + 1] = p.getMapParams(mw.ustring.gsub(mapname, '^%s*(.-)%s*$', '%1'), frame)
			end
			if args['caption'] then
				if args['caption'] == &quot;&quot; then
					while #caption_list &lt; #map do
						caption_list[#caption_list + 1] = args['caption']
					end
				else
					for caption in mw.text.gsplit(args['caption'], '##', true) do
						caption_list[#caption_list + 1] = caption
					end
				end
			end
			if #map == 1 then map = map[1] end
		else
			map = p.getMapParams('World', frame)
		end
	end
	if type(map) == 'table' then
		local altmaps = switcherSeparate(args.AlternativeMap)
		if #altmaps &gt; #map then
			error(string.format('%d AlternativeMaps were provided, but only %d maps were provided', #altmaps, #map))
		end
		local overlays = switcherSeparate(args.overlay_image)
		if #overlays &gt; #map then
			error(string.format('%d overlay_images were provided, but only %d maps were provided', #overlays, #map))
		end
		if #caption_list &gt; #map then
			error(string.format('%d captions were provided, but only %d maps were provided', #caption_list, #map))
		end
		local outputs = {}
		args.autoSwitcherLabel = true
		for k,v in ipairs(map) do
			args.AlternativeMap = altmaps[k]
			args.overlay_image = overlays[k]
			args.caption = caption_list[k]
			outputs[k] = p.main(frame, args, v)
		end
		return '&lt;div class=&quot;switcher-container&quot;&gt;' .. table.concat(outputs) .. '&lt;/div&gt;'
	else
		return p.top(frame, args, map) .. tostring( p.mark(frame, args, map) ) .. p.bottom(frame, args, map)
	end
end

return p</text>
      <sha1>07icxbtq9eg84dyuhbuyo1sfebx4tq4</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Main</title>
    <ns>10</ns>
    <id>1146</id>
    <revision>
      <id>6573</id>
      <timestamp>2026-05-19T03:12:41Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;''Umtlolo omkhulu: [[{{{1}}}]]'' &lt;noinclude&gt;{{documentation}}&lt;/noinclude&gt;&quot;</comment>
      <origin>6573</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="73" sha1="44gfwr2qifffu2wkrjhdkcq6392wqwh" xml:space="preserve">''Umtlolo omkhulu: [[{{{1}}}]]''
&lt;noinclude&gt;{{documentation}}&lt;/noinclude&gt;</text>
      <sha1>44gfwr2qifffu2wkrjhdkcq6392wqwh</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Die</title>
    <ns>10</ns>
    <id>1147</id>
    <revision>
      <id>6574</id>
      <timestamp>2026-05-19T03:17:50Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;&lt;span style=&quot;margin:0em 0.1em&quot;&gt;[[File:{{#switch: {{{1|}}}{{{color|}}}   |2red=Kismet-Deuce.png   |3green=Kismet-Trey.png   |4green=Kismet-Four.png   |5red=Kismet-Five.png   |3red=Dice-3.png   |6red=Dice-6.png   |#default={{#ifeq:{{{1}}}|0     |Dice-0.png     |{{#ifeq:{{{color|}}}|blue       |DFace {{{1}}}B       |Die face {{{1}}}{{#ifeq: {{{color|}}} | red |r|b}}     }}.svg   }} }}|frameless|upright=0.13|alt={{{1}}}]]&lt;/span&gt;{{#if: {{{2|}}} |{{{separator|}}}&lt;span style=&quot;m...&quot;</comment>
      <origin>6574</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2885" sha1="9gsy7iq9brl9y1v2iz2drcois6edfn1" xml:space="preserve">&lt;span style=&quot;margin:0em 0.1em&quot;&gt;[[File:{{#switch: {{{1|}}}{{{color|}}}
  |2red=Kismet-Deuce.png
  |3green=Kismet-Trey.png
  |4green=Kismet-Four.png
  |5red=Kismet-Five.png
  |3red=Dice-3.png
  |6red=Dice-6.png
  |#default={{#ifeq:{{{1}}}|0
    |Dice-0.png
    |{{#ifeq:{{{color|}}}|blue
      |DFace {{{1}}}B
      |Die face {{{1}}}{{#ifeq: {{{color|}}} | red |r|b}}
    }}.svg
  }}
}}|frameless|upright=0.13|alt={{{1}}}]]&lt;/span&gt;{{#if: {{{2|}}}
|{{{separator|}}}&lt;span style=&quot;margin:0em 0.1em&quot;&gt;[[File:{{#switch: {{{2|}}}{{{color|}}}
  |2red=Kismet-Deuce.png
  |3green=Kismet-Trey.png
  |4green=Kismet-Four.png
  |5red=Kismet-Five.png
  |3red=Dice-3.png
  |6red=Dice-6.png
  |#default={{#ifeq:{{{2}}}|0
    |Dice-0.png
    |{{#ifeq:{{{color|}}}|blue
      |DFace {{{2}}}B
      |Die face {{{2}}}{{#ifeq: {{{color|}}} | red |r|b}}
    }}.svg
  }}
}}|frameless|upright=0.13|alt={{{2}}}]]&lt;/span&gt;
|}}{{#if: {{{3|}}}
|{{{separator|}}}&lt;span style=&quot;margin:0em 0.1em&quot;&gt;[[File:{{#switch: {{{3|}}}{{{color|}}}
  |2red=Kismet-Deuce.png
  |3green=Kismet-Trey.png
  |4green=Kismet-Four.png
  |5red=Kismet-Five.png
  |3red=Dice-3.png
  |6red=Dice-6.png
  |#default={{#ifeq:{{{3}}}|0
    |Dice-0.png
    |{{#ifeq:{{{color|}}}|blue
      |DFace {{{3}}}B
      |Die face {{{3}}}{{#ifeq: {{{color|}}} | red |r|b}}
    }}.svg
  }}
}}|frameless|upright=0.13|alt={{{3}}}]]&lt;/span&gt;
|}}{{#if: {{{4|}}}
|{{{separator|}}}&lt;span style=&quot;margin:0em 0.1em&quot;&gt;[[File:{{#switch: {{{4|}}}{{{color|}}}
  |2red=Kismet-Deuce.png
  |3green=Kismet-Trey.png
  |4green=Kismet-Four.png
  |5red=Kismet-Five.png
  |3red=Dice-3.png
  |6red=Dice-6.png
  |#default={{#ifeq:{{{4}}}|0
    |Dice-0.png
    |{{#ifeq:{{{color|}}}|blue
      |DFace {{{4}}}B
      |Die face {{{4}}}{{#ifeq: {{{color|}}} | red |r|b}}
    }}.svg
  }}
}}|frameless|upright=0.13|alt={{{4}}}]]&lt;/span&gt;
|}}{{#if: {{{5|}}}
|{{{separator|}}}&lt;span style=&quot;margin:0em 0.1em&quot;&gt;[[File:{{#switch: {{{5|}}}{{{color|}}}
  |2red=Kismet-Deuce.png
  |3green=Kismet-Trey.png
  |4green=Kismet-Four.png
  |5red=Kismet-Five.png
  |3red=Dice-3.png
  |6red=Dice-6.png
  |#default={{#ifeq:{{{5}}}|0
    |Dice-0.png
    |{{#ifeq:{{{color|}}}|blue
      |DFace {{{5}}}B
      |Die face {{{5}}}{{#ifeq: {{{color|}}} | red |r|b}}
    }}.svg
  }}
}}|frameless|upright=0.13|alt={{{5}}}]]&lt;/span&gt;
|}}{{#if: {{{6|}}}
|{{{separator|}}}&lt;span style=&quot;margin:0em 0.1em&quot;&gt;[[File:{{#switch: {{{6|}}}{{{color|}}}
  |2red=Kismet-Deuce.png
  |3green=Kismet-Trey.png
  |4green=Kismet-Four.png
  |5red=Kismet-Five.png
  |3red=Dice-3.png
  |6red=Dice-6.png
  |#default={{#ifeq:{{{6}}}|0
    |Dice-0.png
    |{{#ifeq:{{{color|}}}|blue
      |DFace {{{6}}}B
      |Die face {{{6}}}{{#ifeq: {{{color|}}} | red |r|b}}
    }}.svg
  }}
}}|frameless|upright=0.13|alt={{{6}}}]]&lt;/span&gt;
|}}&lt;noinclude&gt;
{{Documentation}}
&lt;!-- PLEASE ADD THIS TEMPLATE'S CATEGORIES AND INTERWIKIS TO THE /doc SUBPAGE, THANKS --&gt;
&lt;/noinclude&gt;</text>
      <sha1>9gsy7iq9brl9y1v2iz2drcois6edfn1</sha1>
    </revision>
  </page>
  <page>
    <title>Wikiphidiya:Iimbawo zokuqondisa kabutjha</title>
    <ns>4</ns>
    <id>1148</id>
    <revision>
      <id>6576</id>
      <timestamp>2026-05-19T05:41:13Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;Ikhasi leli liqukethe iimbawo '''zokuqondisa kabutjha''' okutjha okwenziwe ngendlela ye-Athikili yokuDala. Nanyana yini engasi isibawo sokuqondisa kabutjha izokulahlwa ngokuzenzakalelayo nofana isuswe.  Yenza iimbawo ngokusebenzisa indlela le:  &lt;code&gt;&lt;nowiki&gt;== Redirect request: [[...]] ==&lt;/nowiki&gt;  &lt;nowiki&gt;*Target of redirect: [[...]]&lt;/nowiki&gt;  &lt;nowiki&gt;*Reason: ...&lt;/nowiki&gt;  &lt;nowiki&gt;*Source (if applicable): ...&lt;/nowiki&gt;  &lt;nowiki&gt;~~~~&lt;/nowiki&gt;&lt;/code&gt;  ----&quot;</comment>
      <origin>6576</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="460" sha1="ci9kiimxpwe00v294tm0zt207o05bdd" xml:space="preserve">Ikhasi leli liqukethe iimbawo '''zokuqondisa kabutjha''' okutjha okwenziwe ngendlela ye-Athikili yokuDala. Nanyana yini engasi isibawo sokuqondisa kabutjha izokulahlwa ngokuzenzakalelayo nofana isuswe.

Yenza iimbawo ngokusebenzisa indlela le:

&lt;code&gt;&lt;nowiki&gt;== Redirect request: [[...]] ==&lt;/nowiki&gt;

&lt;nowiki&gt;*Target of redirect: [[...]]&lt;/nowiki&gt;

&lt;nowiki&gt;*Reason: ...&lt;/nowiki&gt;

&lt;nowiki&gt;*Source (if applicable): ...&lt;/nowiki&gt;

&lt;nowiki&gt;~~~~&lt;/nowiki&gt;&lt;/code&gt;

----</text>
      <sha1>ci9kiimxpwe00v294tm0zt207o05bdd</sha1>
    </revision>
    <revision>
      <id>6577</id>
      <parentid>6576</parentid>
      <timestamp>2026-05-19T05:42:10Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6577</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="494" sha1="30dtyre5dwljjtk7u9rgx7hp2ui8huk" xml:space="preserve">Ikhasi leli liqukethe iimbawo '''zokuqondisa kabutjha''' okutjha okwenziwe ngendlela ye-[[Wikiphidiya:Athikili yokuDala|Athikili yokuDala]]. Nanyana yini engasi isibawo sokuqondisa kabutjha izokulahlwa ngokuzenzakalelayo nofana isuswe.

Yenza iimbawo ngokusebenzisa indlela le:

&lt;code&gt;&lt;nowiki&gt;== Redirect request: [[...]] ==&lt;/nowiki&gt;

&lt;nowiki&gt;*Target of redirect: [[...]]&lt;/nowiki&gt;

&lt;nowiki&gt;*Reason: ...&lt;/nowiki&gt;

&lt;nowiki&gt;*Source (if applicable): ...&lt;/nowiki&gt;

&lt;nowiki&gt;~~~~&lt;/nowiki&gt;&lt;/code&gt;

----</text>
      <sha1>30dtyre5dwljjtk7u9rgx7hp2ui8huk</sha1>
    </revision>
    <revision>
      <id>6579</id>
      <parentid>6577</parentid>
      <timestamp>2026-05-19T05:46:31Z</timestamp>
      <contributor>
        <username>ThatEquatorialGuineaEditor (alt)</username>
        <id>1517</id>
      </contributor>
      <origin>6579</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="824" sha1="tb0tc0877gkzu3l9vw1e5sh7bmf9uik" xml:space="preserve">Ikhasi leli liqukethe iimbawo '''zokuqondisa kabutjha''' okutjha okwenziwe ngendlela ye-[[Wikiphidiya:Athikili yokuDala|Athikili yokuDala]]. Nanyana yini engasi isibawo sokuqondisa kabutjha izokulahlwa ngokuzenzakalelayo nofana isuswe.

Yenza iimbawo ngokusebenzisa indlela le:

&lt;code&gt;&lt;nowiki&gt;== Redirect request: [[...]] ==&lt;/nowiki&gt;

&lt;nowiki&gt;*Target of redirect: [[...]]&lt;/nowiki&gt;

&lt;nowiki&gt;*Reason: ...&lt;/nowiki&gt;

&lt;nowiki&gt;*Source (if applicable): ...&lt;/nowiki&gt;

&lt;nowiki&gt;~~~~&lt;/nowiki&gt;&lt;/code&gt;

----

== Redirect request: [[IsiNdebele]] ==

*Target of redirect: [[Isindebele]]

*Reason: Amaledere amakhulu, madoda.

*Source (if applicable): ...

[[Umsebenzisi:ThatEquatorialGuineaEditor (alt)|ThatEquatorialGuineaEditor (alt)]] ([[Umsebenzisi asiqongelane:ThatEquatorialGuineaEditor (alt)|talk]]) 07:46, 19 Nkwenkwezi 2026 (SAST)</text>
      <sha1>tb0tc0877gkzu3l9vw1e5sh7bmf9uik</sha1>
    </revision>
    <revision>
      <id>6581</id>
      <parentid>6579</parentid>
      <timestamp>2026-05-19T05:48:22Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>/* Redirect request: IsiNdebele */ Reply</comment>
      <origin>6581</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="999" sha1="287l6z9jxg7s22yhly2o54cp4vntvv3" xml:space="preserve">Ikhasi leli liqukethe iimbawo '''zokuqondisa kabutjha''' okutjha okwenziwe ngendlela ye-[[Wikiphidiya:Athikili yokuDala|Athikili yokuDala]]. Nanyana yini engasi isibawo sokuqondisa kabutjha izokulahlwa ngokuzenzakalelayo nofana isuswe.

Yenza iimbawo ngokusebenzisa indlela le:

&lt;code&gt;&lt;nowiki&gt;== Redirect request: [[...]] ==&lt;/nowiki&gt;

&lt;nowiki&gt;*Target of redirect: [[...]]&lt;/nowiki&gt;

&lt;nowiki&gt;*Reason: ...&lt;/nowiki&gt;

&lt;nowiki&gt;*Source (if applicable): ...&lt;/nowiki&gt;

&lt;nowiki&gt;~~~~&lt;/nowiki&gt;&lt;/code&gt;

----

== Redirect request: [[IsiNdebele]] ==

*Target of redirect: [[Isindebele]]

*Reason: Amaledere amakhulu, madoda.

*Source (if applicable): ...

[[Umsebenzisi:ThatEquatorialGuineaEditor (alt)|ThatEquatorialGuineaEditor (alt)]] ([[Umsebenzisi asiqongelane:ThatEquatorialGuineaEditor (alt)|talk]]) 07:46, 19 Nkwenkwezi 2026 (SAST)

:*{{Done}}. Ngiyathokoza ngokusiza iWikipedia! [[Umsebenzisi:NgamangaXhosa|NgamangaXhosa]] ([[Umsebenzisi asiqongelane:NgamangaXhosa|talk]]) 07:48, 19 Nkwenkwezi 2026 (SAST)</text>
      <sha1>287l6z9jxg7s22yhly2o54cp4vntvv3</sha1>
    </revision>
    <revision>
      <id>6582</id>
      <parentid>6581</parentid>
      <timestamp>2026-05-19T05:48:45Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6582</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="998" sha1="284pnsgmhdpbcc52vxqn2ov2p3xfjzu" xml:space="preserve">Ikhasi leli liqukethe iimbawo '''zokuqondisa kabutjha''' okutjha okwenziwe ngendlela ye-[[Wikiphidiya:Athikili yokuDala|Athikili yokuDala]]. Nanyana yini engasi isibawo sokuqondisa kabutjha izokulahlwa ngokuzenzakalelayo nofana isuswe.

Yenza iimbawo ngokusebenzisa indlela le:

&lt;code&gt;&lt;nowiki&gt;== Redirect request: [[...]] ==&lt;/nowiki&gt;

&lt;nowiki&gt;*Target of redirect: [[...]]&lt;/nowiki&gt;

&lt;nowiki&gt;*Reason: ...&lt;/nowiki&gt;

&lt;nowiki&gt;*Source (if applicable): ...&lt;/nowiki&gt;

&lt;nowiki&gt;~~~~&lt;/nowiki&gt;&lt;/code&gt;

----

== Redirect request: [[IsiNdebele]] ==

*Target of redirect: [[Isindebele]]

*Reason: Amaledere amakhulu, madoda.

*Source (if applicable): ...

[[Umsebenzisi:ThatEquatorialGuineaEditor (alt)|ThatEquatorialGuineaEditor (alt)]] ([[Umsebenzisi asiqongelane:ThatEquatorialGuineaEditor (alt)|talk]]) 07:46, 19 Nkwenkwezi 2026 (SAST)

:{{Done}}. Ngiyathokoza ngokusiza iWikipedia! [[Umsebenzisi:NgamangaXhosa|NgamangaXhosa]] ([[Umsebenzisi asiqongelane:NgamangaXhosa|talk]]) 07:48, 19 Nkwenkwezi 2026 (SAST)</text>
      <sha1>284pnsgmhdpbcc52vxqn2ov2p3xfjzu</sha1>
    </revision>
    <revision>
      <id>6625</id>
      <parentid>6582</parentid>
      <timestamp>2026-05-19T11:39:05Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6625</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1000" sha1="e8ivizrdb8hp5ex1rycra23ry6pqqbb" xml:space="preserve">Ikhasi leli liqukethe iimbawo '''zokuqondisa kabutjha''' okutjha okwenziwe ngendlela ye-[[Wikiphidiya:Athikili yokuDala|Athikili yokuDala]]. Nanyana yini engasi isibawo sokuqondisa kabutjha izokulahlwa ngokuzenzakalelayo nofana isuswe.

Yenza iimbawo ngokusebenzisa indlela le:

&lt;code&gt;&lt;nowiki&gt;== Redirect request: [[...]] ==&lt;/nowiki&gt;

&lt;nowiki&gt;*Target of redirect: [[...]]&lt;/nowiki&gt;

&lt;nowiki&gt;*Reason: ...&lt;/nowiki&gt;

&lt;nowiki&gt;*Source (if applicable): ...&lt;/nowiki&gt;

&lt;nowiki&gt;~~~~&lt;/nowiki&gt;&lt;/code&gt;

----

== Redirect request: [[IsiNdebele]] ==

*Target of redirect: [[Isindebele]]

*Reason: Amaledere amakhulu, madoda.

*Source (if applicable): ...

[[Umsebenzisi:ThatEquatorialGuineaEditor (alt)|ThatEquatorialGuineaEditor (alt)]] ([[Umsebenzisi asiqongelane:ThatEquatorialGuineaEditor (alt)|talk]]) 07:46, 19 Nkwenkwezi 2026 (SAST)

:{{Done}}. Ngiyathokoza ngokusiza iWikiphidiya! [[Umsebenzisi:NgamangaXhosa|NgamangaXhosa]] ([[Umsebenzisi asiqongelane:NgamangaXhosa|talk]]) 07:48, 19 Nkwenkwezi 2026 (SAST)</text>
      <sha1>e8ivizrdb8hp5ex1rycra23ry6pqqbb</sha1>
    </revision>
    <revision>
      <id>6630</id>
      <parentid>6625</parentid>
      <timestamp>2026-05-19T13:46:52Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>/* Redirect request: IsiNdebele */</comment>
      <origin>6630</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1023" sha1="jhhaztpy62o97nv50mqf638048u9hi8" xml:space="preserve">Ikhasi leli liqukethe iimbawo '''zokuqondisa kabutjha''' okutjha okwenziwe ngendlela ye-[[Wikiphidiya:Athikili yokuDala|Athikili yokuDala]]. Nanyana yini engasi isibawo sokuqondisa kabutjha izokulahlwa ngokuzenzakalelayo nofana isuswe.

Yenza iimbawo ngokusebenzisa indlela le:

&lt;code&gt;&lt;nowiki&gt;== Redirect request: [[...]] ==&lt;/nowiki&gt;

&lt;nowiki&gt;*Target of redirect: [[...]]&lt;/nowiki&gt;

&lt;nowiki&gt;*Reason: ...&lt;/nowiki&gt;

&lt;nowiki&gt;*Source (if applicable): ...&lt;/nowiki&gt;

&lt;nowiki&gt;~~~~&lt;/nowiki&gt;&lt;/code&gt;

----

== Redirect request: [[IsiNdebele]] ==
{{AfC-c|a}}
*Target of redirect: [[Isindebele]]

*Reason: Amaledere amakhulu, madoda.

*Source (if applicable): ...

[[Umsebenzisi:ThatEquatorialGuineaEditor (alt)|ThatEquatorialGuineaEditor (alt)]] ([[Umsebenzisi asiqongelane:ThatEquatorialGuineaEditor (alt)|talk]]) 07:46, 19 Nkwenkwezi 2026 (SAST)

:{{Done}}. Ngiyathokoza ngokusiza iWikiphidiya! [[Umsebenzisi:NgamangaXhosa|NgamangaXhosa]] ([[Umsebenzisi asiqongelane:NgamangaXhosa|talk]]) 07:48, 19 Nkwenkwezi 2026 (SAST)
{{AfC-c|b}}</text>
      <sha1>jhhaztpy62o97nv50mqf638048u9hi8</sha1>
    </revision>
    <revision>
      <id>6635</id>
      <parentid>6630</parentid>
      <timestamp>2026-05-20T02:19:35Z</timestamp>
      <contributor>
        <username>ThatEquatorialGuineaEditor (alt)</username>
        <id>1517</id>
      </contributor>
      <origin>6635</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1365" sha1="6xzwxw5jxmdrhuguv45ox3qjfa06za5" xml:space="preserve">Ikhasi leli liqukethe iimbawo '''zokuqondisa kabutjha''' okutjha okwenziwe ngendlela ye-[[Wikiphidiya:Athikili yokuDala|Athikili yokuDala]]. Nanyana yini engasi isibawo sokuqondisa kabutjha izokulahlwa ngokuzenzakalelayo nofana isuswe.

Yenza iimbawo ngokusebenzisa indlela le:

&lt;code&gt;&lt;nowiki&gt;== Redirect request: [[...]] ==&lt;/nowiki&gt;

&lt;nowiki&gt;*Target of redirect: [[...]]&lt;/nowiki&gt;

&lt;nowiki&gt;*Reason: ...&lt;/nowiki&gt;

&lt;nowiki&gt;*Source (if applicable): ...&lt;/nowiki&gt;

&lt;nowiki&gt;~~~~&lt;/nowiki&gt;&lt;/code&gt;

----

== Redirect request: [[IsiNdebele]] ==
{{AfC-c|a}}
*Target of redirect: [[Isindebele]]

*Reason: Amaledere amakhulu, madoda.

*Source (if applicable): ...

[[Umsebenzisi:ThatEquatorialGuineaEditor (alt)|ThatEquatorialGuineaEditor (alt)]] ([[Umsebenzisi asiqongelane:ThatEquatorialGuineaEditor (alt)|talk]]) 07:46, 19 Nkwenkwezi 2026 (SAST)

:{{Done}}. Ngiyathokoza ngokusiza iWikiphidiya! [[Umsebenzisi:NgamangaXhosa|NgamangaXhosa]] ([[Umsebenzisi asiqongelane:NgamangaXhosa|talk]]) 07:48, 19 Nkwenkwezi 2026 (SAST)
{{AfC-c|b}}

== Redirect request: [[IsiNdebele seSewula]] ==

*Target of redirect: [[Isindebele]]

*Reason: Sebenzisa ibizo elifaneleko ;)

*Source (if applicable): ...

[[Umsebenzisi:ThatEquatorialGuineaEditor (alt)|ThatEquatorialGuineaEditor (alt)]] ([[Umsebenzisi asiqongelane:ThatEquatorialGuineaEditor (alt)|talk]]) 04:19, 20 Nkwenkwezi 2026 (SAST)</text>
      <sha1>6xzwxw5jxmdrhuguv45ox3qjfa06za5</sha1>
    </revision>
    <revision>
      <id>6636</id>
      <parentid>6635</parentid>
      <timestamp>2026-05-20T02:24:26Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6636</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1590" sha1="noooxduxd158i9fjxw3htq9sfippmy6" xml:space="preserve">Ikhasi leli liqukethe iimbawo '''zokuqondisa kabutjha''' okutjha okwenziwe ngendlela ye-[[Wikiphidiya:Athikili yokuDala|Athikili yokuDala]]. Nanyana yini engasi isibawo sokuqondisa kabutjha izokulahlwa ngokuzenzakalelayo nofana isuswe.

Yenza iimbawo ngokusebenzisa indlela le:

&lt;code&gt;&lt;nowiki&gt;== Redirect request: [[...]] ==&lt;/nowiki&gt;

&lt;nowiki&gt;*Target of redirect: [[...]]&lt;/nowiki&gt;

&lt;nowiki&gt;*Reason: ...&lt;/nowiki&gt;

&lt;nowiki&gt;*Source (if applicable): ...&lt;/nowiki&gt;

&lt;nowiki&gt;~~~~&lt;/nowiki&gt;&lt;/code&gt;

----

== Redirect request: [[IsiNdebele]] ==
{{AfC-c|a}}
*Target of redirect: [[Isindebele]]

*Reason: Amaledere amakhulu, madoda.

*Source (if applicable): ...

[[Umsebenzisi:ThatEquatorialGuineaEditor (alt)|ThatEquatorialGuineaEditor (alt)]] ([[Umsebenzisi asiqongelane:ThatEquatorialGuineaEditor (alt)|talk]]) 07:46, 19 Nkwenkwezi 2026 (SAST)

:{{Done}}. Ngiyathokoza ngokusiza iWikiphidiya! [[Umsebenzisi:NgamangaXhosa|NgamangaXhosa]] ([[Umsebenzisi asiqongelane:NgamangaXhosa|talk]]) 07:48, 19 Nkwenkwezi 2026 (SAST)
{{AfC-c|b}}

== Redirect request: [[IsiNdebele seSewula]] ==
{{AfC-c|d}}
*Target of redirect: [[Isindebele]]

*Reason: Sebenzisa ibizo elifaneleko ;)

*Source (if applicable): ...

[[Umsebenzisi:ThatEquatorialGuineaEditor (alt)|ThatEquatorialGuineaEditor (alt)]] ([[Umsebenzisi asiqongelane:ThatEquatorialGuineaEditor (alt)|talk]]) 04:19, 20 Nkwenkwezi 2026 (SAST)

:{{Declined}}. Umtlolo lo uzokuthuthelwa esikhaleni esiceliweko msinyana. [[Umsebenzisi:NgamangaXhosa|NgamangaXhosa]] ([[Umsebenzisi asiqongelane:NgamangaXhosa|talk]]) 04:24, 20 Nkwenkwezi 2026 (SAST)
{{AfC-c|b}}</text>
      <sha1>noooxduxd158i9fjxw3htq9sfippmy6</sha1>
    </revision>
    <revision>
      <id>6648</id>
      <parentid>6636</parentid>
      <timestamp>2026-05-20T04:36:28Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6648</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1673" sha1="48rqo2ernjx923dbrszy52vyb5z8xsw" xml:space="preserve">Ikhasi leli liqukethe iimbawo '''zokuqondisa kabutjha''' okutjha okwenziwe ngendlela ye-[[Wikiphidiya:Athikili yokuDala|Athikili yokuDala]]. Nanyana yini engasi isibawo sokuqondisa kabutjha izokulahlwa ngokuzenzakalelayo nofana isuswe.

Yenza iimbawo ngokusebenzisa indlela le:

&lt;code&gt;&lt;nowiki&gt;== Redirect request: [[...]] ==&lt;/nowiki&gt;

&lt;nowiki&gt;*Target of redirect: [[...]]&lt;/nowiki&gt;

&lt;nowiki&gt;*Reason: ...&lt;/nowiki&gt;

&lt;nowiki&gt;*Source (if applicable): ...&lt;/nowiki&gt;

&lt;nowiki&gt;~~~~&lt;/nowiki&gt;&lt;/code&gt;

&lt;center&gt;'''Archives:'''&lt;/center&gt;
&lt;center&gt;[[Wikiphidiya:{{PAGENAME}}/Archive 1|1]]

----

== Redirect request: [[IsiNdebele]] ==
{{AfC-c|a}}
*Target of redirect: [[Isindebele]]

*Reason: Amaledere amakhulu, madoda.

*Source (if applicable): ...

[[Umsebenzisi:ThatEquatorialGuineaEditor (alt)|ThatEquatorialGuineaEditor (alt)]] ([[Umsebenzisi asiqongelane:ThatEquatorialGuineaEditor (alt)|talk]]) 07:46, 19 Nkwenkwezi 2026 (SAST)

:{{Done}}. Ngiyathokoza ngokusiza iWikiphidiya! [[Umsebenzisi:NgamangaXhosa|NgamangaXhosa]] ([[Umsebenzisi asiqongelane:NgamangaXhosa|talk]]) 07:48, 19 Nkwenkwezi 2026 (SAST)
{{AfC-c|b}}

== Redirect request: [[IsiNdebele seSewula]] ==
{{AfC-c|d}}
*Target of redirect: [[Isindebele]]

*Reason: Sebenzisa ibizo elifaneleko ;)

*Source (if applicable): ...

[[Umsebenzisi:ThatEquatorialGuineaEditor (alt)|ThatEquatorialGuineaEditor (alt)]] ([[Umsebenzisi asiqongelane:ThatEquatorialGuineaEditor (alt)|talk]]) 04:19, 20 Nkwenkwezi 2026 (SAST)

:{{Declined}}. Umtlolo lo uzokuthuthelwa esikhaleni esiceliweko msinyana. [[Umsebenzisi:NgamangaXhosa|NgamangaXhosa]] ([[Umsebenzisi asiqongelane:NgamangaXhosa|talk]]) 04:24, 20 Nkwenkwezi 2026 (SAST)
{{AfC-c|b}}</text>
      <sha1>48rqo2ernjx923dbrszy52vyb5z8xsw</sha1>
    </revision>
    <revision>
      <id>6649</id>
      <parentid>6648</parentid>
      <timestamp>2026-05-20T04:38:00Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6649</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="577" sha1="6401gp3yo5qb71z94solp6junnwgzo3" xml:space="preserve">Ikhasi leli liqukethe iimbawo '''zokuqondisa kabutjha''' okutjha okwenziwe ngendlela ye-[[Wikiphidiya:Athikili yokuDala|Athikili yokuDala]]. Nanyana yini engasi isibawo sokuqondisa kabutjha izokulahlwa ngokuzenzakalelayo nofana isuswe.

Yenza iimbawo ngokusebenzisa indlela le:

&lt;code&gt;&lt;nowiki&gt;== Redirect request: [[...]] ==&lt;/nowiki&gt;

&lt;nowiki&gt;*Target of redirect: [[...]]&lt;/nowiki&gt;

&lt;nowiki&gt;*Reason: ...&lt;/nowiki&gt;

&lt;nowiki&gt;*Source (if applicable): ...&lt;/nowiki&gt;

&lt;nowiki&gt;~~~~&lt;/nowiki&gt;&lt;/code&gt;

&lt;center&gt;'''Archives:'''&lt;/center&gt;
&lt;center&gt;[[Wikiphidiya:{{PAGENAME}}/Archive 1|1]]

----</text>
      <sha1>6401gp3yo5qb71z94solp6junnwgzo3</sha1>
    </revision>
    <revision>
      <id>6655</id>
      <parentid>6649</parentid>
      <timestamp>2026-05-20T04:41:35Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Undid revision [[Special:Diff/6649|6649]] by [[Special:Contributions/NgamangaXhosa|NgamangaXhosa]] ([[User talk:NgamangaXhosa|talk]])</comment>
      <origin>6655</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1673" sha1="48rqo2ernjx923dbrszy52vyb5z8xsw" xml:space="preserve">Ikhasi leli liqukethe iimbawo '''zokuqondisa kabutjha''' okutjha okwenziwe ngendlela ye-[[Wikiphidiya:Athikili yokuDala|Athikili yokuDala]]. Nanyana yini engasi isibawo sokuqondisa kabutjha izokulahlwa ngokuzenzakalelayo nofana isuswe.

Yenza iimbawo ngokusebenzisa indlela le:

&lt;code&gt;&lt;nowiki&gt;== Redirect request: [[...]] ==&lt;/nowiki&gt;

&lt;nowiki&gt;*Target of redirect: [[...]]&lt;/nowiki&gt;

&lt;nowiki&gt;*Reason: ...&lt;/nowiki&gt;

&lt;nowiki&gt;*Source (if applicable): ...&lt;/nowiki&gt;

&lt;nowiki&gt;~~~~&lt;/nowiki&gt;&lt;/code&gt;

&lt;center&gt;'''Archives:'''&lt;/center&gt;
&lt;center&gt;[[Wikiphidiya:{{PAGENAME}}/Archive 1|1]]

----

== Redirect request: [[IsiNdebele]] ==
{{AfC-c|a}}
*Target of redirect: [[Isindebele]]

*Reason: Amaledere amakhulu, madoda.

*Source (if applicable): ...

[[Umsebenzisi:ThatEquatorialGuineaEditor (alt)|ThatEquatorialGuineaEditor (alt)]] ([[Umsebenzisi asiqongelane:ThatEquatorialGuineaEditor (alt)|talk]]) 07:46, 19 Nkwenkwezi 2026 (SAST)

:{{Done}}. Ngiyathokoza ngokusiza iWikiphidiya! [[Umsebenzisi:NgamangaXhosa|NgamangaXhosa]] ([[Umsebenzisi asiqongelane:NgamangaXhosa|talk]]) 07:48, 19 Nkwenkwezi 2026 (SAST)
{{AfC-c|b}}

== Redirect request: [[IsiNdebele seSewula]] ==
{{AfC-c|d}}
*Target of redirect: [[Isindebele]]

*Reason: Sebenzisa ibizo elifaneleko ;)

*Source (if applicable): ...

[[Umsebenzisi:ThatEquatorialGuineaEditor (alt)|ThatEquatorialGuineaEditor (alt)]] ([[Umsebenzisi asiqongelane:ThatEquatorialGuineaEditor (alt)|talk]]) 04:19, 20 Nkwenkwezi 2026 (SAST)

:{{Declined}}. Umtlolo lo uzokuthuthelwa esikhaleni esiceliweko msinyana. [[Umsebenzisi:NgamangaXhosa|NgamangaXhosa]] ([[Umsebenzisi asiqongelane:NgamangaXhosa|talk]]) 04:24, 20 Nkwenkwezi 2026 (SAST)
{{AfC-c|b}}</text>
      <sha1>48rqo2ernjx923dbrszy52vyb5z8xsw</sha1>
    </revision>
    <revision>
      <id>6657</id>
      <parentid>6655</parentid>
      <timestamp>2026-05-20T04:42:06Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6657</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1590" sha1="noooxduxd158i9fjxw3htq9sfippmy6" xml:space="preserve">Ikhasi leli liqukethe iimbawo '''zokuqondisa kabutjha''' okutjha okwenziwe ngendlela ye-[[Wikiphidiya:Athikili yokuDala|Athikili yokuDala]]. Nanyana yini engasi isibawo sokuqondisa kabutjha izokulahlwa ngokuzenzakalelayo nofana isuswe.

Yenza iimbawo ngokusebenzisa indlela le:

&lt;code&gt;&lt;nowiki&gt;== Redirect request: [[...]] ==&lt;/nowiki&gt;

&lt;nowiki&gt;*Target of redirect: [[...]]&lt;/nowiki&gt;

&lt;nowiki&gt;*Reason: ...&lt;/nowiki&gt;

&lt;nowiki&gt;*Source (if applicable): ...&lt;/nowiki&gt;

&lt;nowiki&gt;~~~~&lt;/nowiki&gt;&lt;/code&gt;

----

== Redirect request: [[IsiNdebele]] ==
{{AfC-c|a}}
*Target of redirect: [[Isindebele]]

*Reason: Amaledere amakhulu, madoda.

*Source (if applicable): ...

[[Umsebenzisi:ThatEquatorialGuineaEditor (alt)|ThatEquatorialGuineaEditor (alt)]] ([[Umsebenzisi asiqongelane:ThatEquatorialGuineaEditor (alt)|talk]]) 07:46, 19 Nkwenkwezi 2026 (SAST)

:{{Done}}. Ngiyathokoza ngokusiza iWikiphidiya! [[Umsebenzisi:NgamangaXhosa|NgamangaXhosa]] ([[Umsebenzisi asiqongelane:NgamangaXhosa|talk]]) 07:48, 19 Nkwenkwezi 2026 (SAST)
{{AfC-c|b}}

== Redirect request: [[IsiNdebele seSewula]] ==
{{AfC-c|d}}
*Target of redirect: [[Isindebele]]

*Reason: Sebenzisa ibizo elifaneleko ;)

*Source (if applicable): ...

[[Umsebenzisi:ThatEquatorialGuineaEditor (alt)|ThatEquatorialGuineaEditor (alt)]] ([[Umsebenzisi asiqongelane:ThatEquatorialGuineaEditor (alt)|talk]]) 04:19, 20 Nkwenkwezi 2026 (SAST)

:{{Declined}}. Umtlolo lo uzokuthuthelwa esikhaleni esiceliweko msinyana. [[Umsebenzisi:NgamangaXhosa|NgamangaXhosa]] ([[Umsebenzisi asiqongelane:NgamangaXhosa|talk]]) 04:24, 20 Nkwenkwezi 2026 (SAST)
{{AfC-c|b}}</text>
      <sha1>noooxduxd158i9fjxw3htq9sfippmy6</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:ThatEquatorialGuineaEditor (alt)</title>
    <ns>2</ns>
    <id>1149</id>
    <revision>
      <id>6578</id>
      <timestamp>2026-05-19T05:43:49Z</timestamp>
      <contributor>
        <username>ThatEquatorialGuineaEditor (alt)</username>
        <id>1517</id>
      </contributor>
      <comment>Created page with &quot;{{#babel:es|nr-3}}  Habari.&quot;</comment>
      <origin>6578</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="27" sha1="cqt3syp4w23jo2fd9lfpuakugr7dc44" xml:space="preserve">{{#babel:es|nr-3}}

Habari.</text>
      <sha1>cqt3syp4w23jo2fd9lfpuakugr7dc44</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi asiqongelane:ThatEquatorialGuineaEditor (alt)</title>
    <ns>3</ns>
    <id>1150</id>
    <revision>
      <id>6580</id>
      <timestamp>2026-05-19T05:47:01Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>/* Une-imeyela! */ new section</comment>
      <origin>6580</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="154" sha1="lwfy1wymq1mbeq1qa3c81x0xhye0cvo" xml:space="preserve">== Une-imeyela! ==

{{ygm}} [[Umsebenzisi:NgamangaXhosa|NgamangaXhosa]] ([[Umsebenzisi asiqongelane:NgamangaXhosa|talk]]) 07:47, 19 Nkwenkwezi 2026 (SAST)</text>
      <sha1>lwfy1wymq1mbeq1qa3c81x0xhye0cvo</sha1>
    </revision>
  </page>
  <page>
    <title>IsiNdebele</title>
    <ns>0</ns>
    <id>1151</id>
    <redirect title="Isindebele" />
    <revision>
      <id>6583</id>
      <timestamp>2026-05-19T05:49:01Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Redirected page to [[Isindebele]]</comment>
      <origin>6583</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="24" sha1="syazeneobecpkgm25s34ks2kndd9cfb" xml:space="preserve">#REDIRECT [[Isindebele]]</text>
      <sha1>syazeneobecpkgm25s34ks2kndd9cfb</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi asiqongelane:NgamangaXhosa</title>
    <ns>3</ns>
    <id>1152</id>
    <revision>
      <id>6584</id>
      <timestamp>2026-05-19T05:51:28Z</timestamp>
      <contributor>
        <username>ThatEquatorialGuineaEditor (alt)</username>
        <id>1517</id>
      </contributor>
      <comment>/* Ngiyathokoza */ new section</comment>
      <origin>6584</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="274" sha1="2hsaktnwzr87714p9vp2sx62nt8wv90" xml:space="preserve">== Ngiyathokoza ==

{{Thank you}} ngokungisiza ukuhlela i-Wikipedia ngesiNdebele seSewuta. [[Umsebenzisi:ThatEquatorialGuineaEditor (alt)|ThatEquatorialGuineaEditor (alt)]] ([[Umsebenzisi asiqongelane:ThatEquatorialGuineaEditor (alt)|talk]]) 07:51, 19 Nkwenkwezi 2026 (SAST)</text>
      <sha1>2hsaktnwzr87714p9vp2sx62nt8wv90</sha1>
    </revision>
    <revision>
      <id>6585</id>
      <parentid>6584</parentid>
      <timestamp>2026-05-19T05:51:51Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>/* Ngiyathokoza */ Reply</comment>
      <origin>6585</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="422" sha1="r30h28sv62osvffd79j12c3s7dm3ol2" xml:space="preserve">== Ngiyathokoza ==

{{Thank you}} ngokungisiza ukuhlela i-Wikipedia ngesiNdebele seSewuta. [[Umsebenzisi:ThatEquatorialGuineaEditor (alt)|ThatEquatorialGuineaEditor (alt)]] ([[Umsebenzisi asiqongelane:ThatEquatorialGuineaEditor (alt)|talk]]) 07:51, 19 Nkwenkwezi 2026 (SAST)

:{{You're welcome}} [[Umsebenzisi:NgamangaXhosa|NgamangaXhosa]] ([[Umsebenzisi asiqongelane:NgamangaXhosa|talk]]) 07:51, 19 Nkwenkwezi 2026 (SAST)</text>
      <sha1>r30h28sv62osvffd79j12c3s7dm3ol2</sha1>
    </revision>
    <revision>
      <id>6586</id>
      <parentid>6585</parentid>
      <timestamp>2026-05-19T05:52:08Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6586</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="422" sha1="287ymmzvw4ak9hq921imj08l9woe7ud" xml:space="preserve">== Ngiyathokoza ==

{{Thank you}} ngokungisiza ukuhlela i-Wikipedia ngesiNdebele seSewuta. [[Umsebenzisi:ThatEquatorialGuineaEditor (alt)|ThatEquatorialGuineaEditor (alt)]] ([[Umsebenzisi asiqongelane:ThatEquatorialGuineaEditor (alt)|talk]]) 07:51, 19 Nkwenkwezi 2026 (SAST)

:{{You're welcome}} [[Umsebenzisi:NgamangaXhosa|NgamangaXhosa]] ([[Umsebenzisi asiqongelane:NgamangaXhosa|talk]]) 07:52, 19 Nkwenkwezi 2026 (SAST)</text>
      <sha1>287ymmzvw4ak9hq921imj08l9woe7ud</sha1>
    </revision>
    <revision>
      <id>6758</id>
      <parentid>6586</parentid>
      <timestamp>2026-08-01T04:23:55Z</timestamp>
      <contributor>
        <username>~2026-42453-34</username>
        <id>1664</id>
      </contributor>
      <origin>6758</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="450" sha1="gmxj6o0zov2ean7yflrre4o2wn9a1l1" xml:space="preserve">{{Not around|{{PAGENAME}}}}
== Ngiyathokoza ==

{{Thank you}} ngokungisiza ukuhlela i-Wikipedia ngesiNdebele seSewuta. [[Umsebenzisi:ThatEquatorialGuineaEditor (alt)|ThatEquatorialGuineaEditor (alt)]] ([[Umsebenzisi asiqongelane:ThatEquatorialGuineaEditor (alt)|talk]]) 07:51, 19 Nkwenkwezi 2026 (SAST)

:{{You're welcome}} [[Umsebenzisi:NgamangaXhosa|NgamangaXhosa]] ([[Umsebenzisi asiqongelane:NgamangaXhosa|talk]]) 07:52, 19 Nkwenkwezi 2026 (SAST)</text>
      <sha1>gmxj6o0zov2ean7yflrre4o2wn9a1l1</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi asiqongelane:MikitkoSynAlexeev</title>
    <ns>3</ns>
    <id>1153</id>
    <revision>
      <id>6596</id>
      <timestamp>2026-05-19T06:21:43Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;{{Not around|{{PAGENAME}}}}&quot;</comment>
      <origin>6596</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="27" sha1="43ncr18fghi0wiy07np8ue17ph7aec0" xml:space="preserve">{{Not around|{{PAGENAME}}}}</text>
      <sha1>43ncr18fghi0wiy07np8ue17ph7aec0</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Mbox</title>
    <ns>10</ns>
    <id>1154</id>
    <revision>
      <id>6598</id>
      <timestamp>2026-05-19T06:25:01Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;{{#invoke:Message box|mbox}}&lt;noinclude&gt; {{documentation}} &lt;!-- Add categories to the /doc subpage; interwikis go to Wikidata, thank you! --&gt; &lt;/noinclude&gt;&quot;</comment>
      <origin>6598</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="153" sha1="aqsrswx233se5jbjaza2b2hrk7pgx53" xml:space="preserve">{{#invoke:Message box|mbox}}&lt;noinclude&gt;
{{documentation}}
&lt;!-- Add categories to the /doc subpage; interwikis go to Wikidata, thank you! --&gt;
&lt;/noinclude&gt;</text>
      <sha1>aqsrswx233se5jbjaza2b2hrk7pgx53</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Message box/configuration</title>
    <ns>828</ns>
    <id>1155</id>
    <revision>
      <id>6599</id>
      <timestamp>2026-05-19T06:27:25Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;-------------------------------------------------------------------------------- --                          Message box configuration                         -- --                                                                            -- -- This module contains configuration data for [[Module:Message box]].        -- --------------------------------------------------------------------------------  return { 	ambox = { 		types = { 			speedy = { 				class = 'ambox-spee...&quot;</comment>
      <origin>6599</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="6642" sha1="p36hrbxjy99m7clj64lhlint2en3bo0" xml:space="preserve">--------------------------------------------------------------------------------
--                          Message box configuration                         --
--                                                                            --
-- This module contains configuration data for [[Module:Message box]].        --
--------------------------------------------------------------------------------

return {
	ambox = {
		types = {
			speedy = {
				class = 'ambox-speedy',
				image = 'Ambox warning pn.svg'
			},
			delete = {
				class = 'ambox-delete',
				image = 'Ambox warning pn.svg'
			},
			content = {
				class = 'ambox-content',
				image = 'Ambox important.svg'
			},
			style = {
				class = 'ambox-style',
				image = 'Edit-clear.svg'
			},
			move = {
				class = 'ambox-move',
				image = 'Merge-split-transwiki default.svg'
			},
			protection = {
				class = 'ambox-protection',
				image = 'Semi-protection-shackle-keyhole.svg'
			},
			notice = {
				class = 'ambox-notice',
				image = 'Information icon4.svg'
			}
		},
		default                     = 'notice',
		allowBlankParams            = {'talk', 'sect', 'date', 'issue', 'fix', 'subst', 'hidden'},
		allowSmall                  = true,
		smallParam                  = 'left',
		smallClass                  = 'mbox-small-left',
		substCheck                  = true,
		classes                     = {'metadata', 'ambox'},
		imageEmptyCell              = true,
		imageCheckBlank             = true,
		imageSmallSize              = '20x20px',
		imageCellDiv                = true,
		useCollapsibleTextFields    = true,
		imageRightNone              = true,
		sectionDefault              = 'article',
		allowMainspaceCategories    = true,
		templateCategory            = 'Article message templates',
	        templateCategoryRequireName = true,
		templateErrorCategory       = 'Article message templates with missing parameters',
		templateErrorParamsToCheck  = {'issue', 'fix', 'subst'},
		removalNotice               = '&lt;small&gt;[[Help:Maintenance template removal|Learn how and when to remove this message]]&lt;/small&gt;',
		templatestyles              = 'Module:Message box/ambox.css'
	},
	
	cmbox = {
		types = {
			speedy = {
				class = 'cmbox-speedy',
				image = 'Ambox warning pn.svg'
			},
			delete = {
				class = 'cmbox-delete',
				image = 'Ambox warning pn.svg'
			},
			content = {
				class = 'cmbox-content',
				image = 'Ambox important.svg'
			},
			style = {
				class = 'cmbox-style',
				image = 'Edit-clear.svg'
			},
			move = {
				class = 'cmbox-move',
				image = 'Merge-split-transwiki default.svg'
			},
			protection = {
				class = 'cmbox-protection',
				image = 'Semi-protection-shackle-keyhole.svg'
			},
			notice = {
				class = 'cmbox-notice',
				image = 'Information icon4.svg'
			}
		},
		default              = 'notice',
		showInvalidTypeError = true,
		classes              = {'cmbox'},
		imageEmptyCell       = true,
		templatestyles       = 'Module:Message box/cmbox.css',
		div_structure        = true,
	},
	
	fmbox = {
		types = {
			warning = {
				class = 'fmbox-warning',
				image = 'Ambox warning pn.svg'
			},
			editnotice = {
				class = 'fmbox-editnotice',
				image = 'Information icon4.svg'
			},
			system = {
				class = 'fmbox-system',
				image = 'Information icon4.svg'
			}
		},
		default              = 'system',
		showInvalidTypeError = true,
		classes              = {'fmbox'},
		imageEmptyCell       = false,
		imageRightNone       = false,
		templatestyles       = 'Module:Message box/fmbox.css',
		div_structure        = true,
	},
	
	imbox = {
		types = {
			speedy = {
				class = 'imbox-speedy',
				image = 'Ambox warning pn.svg'
			},
			delete = {
				class = 'imbox-delete',
				image = 'Ambox warning pn.svg'
			},
			content = {
				class = 'imbox-content',
				image = 'Ambox important.svg'
			},
			style = {
				class = 'imbox-style',
				image = 'Edit-clear.svg'
			},
			move = {
				class = 'imbox-move',
				image = 'Merge-split-transwiki default.svg'
			},
			protection = {
				class = 'imbox-protection',
				image = 'Semi-protection-shackle-keyhole.svg'
			},
			license = {
				class = 'imbox-license licensetpl',
				image = 'Imbox-license.svg'
			},
			[&quot;license-related&quot;] = {
				class = 'imbox-license',
				image = 'Imbox-license.svg'
			},
			featured = {
				class = 'imbox-featured',
				image = 'Cscr-featured.svg',
				imageNeedsLink = true
			},
			notice = {
				class = 'imbox-notice',
				image = 'Information icon4.svg'
			}
		},
		default              = 'notice',
		showInvalidTypeError = true,
		classes              = {'imbox'},
		imageEmptyCell       = true,
		below                = true,
		templateCategory     = 'File message boxes',
		templatestyles       = 'Module:Message box/imbox.css',
		div_structure        = true,
	},
	
	ombox = {
		types = {
			speedy = {
				class = 'ombox-speedy',
				image = 'Ambox warning pn.svg'
			},
			delete = {
				class = 'ombox-delete',
				image = 'Ambox warning pn.svg'
			},
			content = {
				class = 'ombox-content',
				image = 'Ambox important.svg'
			},
			style = {
				class = 'ombox-style',
				image = 'Edit-clear.svg'
			},
			move = {
				class = 'ombox-move',
				image = 'Merge-split-transwiki default.svg'
			},
			protection = {
				class = 'ombox-protection',
				image = 'Semi-protection-shackle-keyhole.svg'
			},
			notice = {
				class = 'ombox-notice',
				image = 'Information icon4.svg'
			}
		},
		default              = 'notice',
		showInvalidTypeError = true,
		classes              = {'ombox'},
		allowSmall           = true,
		imageEmptyCell       = true,
		imageRightNone       = true,
		templatestyles       = 'Module:Message box/ombox.css'
	},
	
	tmbox = {
		types = {
			speedy = {
				class = 'tmbox-speedy',
				image = 'Ambox warning pn.svg'
			},
			delete = {
				class = 'tmbox-delete',
				image = 'Ambox warning pn.svg'
			},
			content = {
				class = 'tmbox-content',
				image = 'Ambox important.svg'
			},
			style = {
				class = 'tmbox-style',
				image = 'Edit-clear.svg'
			},
			move = {
				class = 'tmbox-move',
				image = 'Merge-split-transwiki default.svg'
			},
			protection = {
				class = 'tmbox-protection',
				image = 'Semi-protection-shackle-keyhole.svg'
			},
			notice = {
				class = 'tmbox-notice',
				image = 'Information icon4.svg'
			}
		},
		default              = 'notice',
		showInvalidTypeError = true,
		classes              = {'tmbox'},
		allowSmall           = true,
		imageRightNone       = true,
		imageEmptyCell       = true,
		templateCategory     = 'Talk message boxes',
		templatestyles       = 'Module:Message box/tmbox.css'
	}
}</text>
      <sha1>p36hrbxjy99m7clj64lhlint2en3bo0</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Category handler/data</title>
    <ns>828</ns>
    <id>1156</id>
    <revision>
      <id>6600</id>
      <timestamp>2026-05-19T06:29:54Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;-- This module assembles data to be passed to [[Module:Category handler]] using -- mw.loadData. This includes the configuration data and whether the current -- page matches the title blacklist.  local data = require('Module:Category handler/config') local mShared = require('Module:Category handler/shared') local blacklist = require('Module:Category handler/blacklist') local title = mw.title.getCurrentTitle()  data.currentTitleMatchesBlacklist = mShared.matchesBlacklist(...&quot;</comment>
      <origin>6600</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="631" sha1="k26mwixuaeijisfddb0sxkg82iux8v4" xml:space="preserve">-- This module assembles data to be passed to [[Module:Category handler]] using
-- mw.loadData. This includes the configuration data and whether the current
-- page matches the title blacklist.

local data = require('Module:Category handler/config')
local mShared = require('Module:Category handler/shared')
local blacklist = require('Module:Category handler/blacklist')
local title = mw.title.getCurrentTitle()

data.currentTitleMatchesBlacklist = mShared.matchesBlacklist(
	title.prefixedText,
	blacklist
)

data.currentTitleNamespaceParameters = mShared.getNamespaceParameters(
	title,
	mShared.getParamMappings()
)

return data</text>
      <sha1>k26mwixuaeijisfddb0sxkg82iux8v4</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Category handler/config</title>
    <ns>828</ns>
    <id>1157</id>
    <revision>
      <id>6601</id>
      <timestamp>2026-05-19T06:31:08Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;-------------------------------------------------------------------------------- --            [[Module:Category handler]] configuration data                  -- --       Language-specific parameter names and values can be set here.        -- --       For blacklist config, see [[Module:Category handler/blacklist]].     -- --------------------------------------------------------------------------------  local cfg = {} -- Don't edit this line.  ----------------------------...&quot;</comment>
      <origin>6601</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="5755" sha1="6ga9hbq2pdwalsvx68i53dmbr421rq5" xml:space="preserve">--------------------------------------------------------------------------------
--            [[Module:Category handler]] configuration data                  --
--       Language-specific parameter names and values can be set here.        --
--       For blacklist config, see [[Module:Category handler/blacklist]].     --
--------------------------------------------------------------------------------

local cfg = {} -- Don't edit this line.

--------------------------------------------------------------------------------
--                       Start configuration data                             --
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
--                              Parameter names                               --
-- These configuration items specify custom parameter names.                  --
-- To add one extra name, you can use this format:                            --
--                                                                            --
-- foo = 'parameter name',                                                    --
--                                                                            --
-- To add multiple names, you can use this format:                            --
--                                                                            --
-- foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'},        --
--------------------------------------------------------------------------------

cfg.parameters = {
	
	-- The nocat and categories parameter suppress
	-- categorisation. They are used with Module:Yesno, and work as follows:
	--
	-- cfg.nocat:
	-- Result of yesno()                        Effect
	-- true                                     Categorisation is suppressed
	-- false                                    Categorisation is allowed, and
	--                                          the blacklist check is skipped
	-- nil                                      Categorisation is allowed
	--
	-- cfg.categories:
	-- Result of yesno()                        Effect
	-- true                                     Categorisation is allowed, and
	--                                          the blacklist check is skipped
	-- false                                    Categorisation is suppressed
	-- nil                                      Categorisation is allowed
	nocat = 'nocat',
	categories = 'categories',
	
	-- The parameter name for the legacy &quot;category2&quot; parameter. This skips the
	-- blacklist if set to the cfg.category2Yes value, and suppresses
	-- categorisation if present but equal to anything other than
	-- cfg.category2Yes or cfg.category2Negative.
	category2 = 'category2',
	
	-- cfg.subpage is the parameter name to specify how to behave on subpages.
	subpage = 'subpage',
	
	-- The parameter for data to return in all namespaces.
	all = 'all',
	
	-- The parameter name for data to return if no data is specified for the
	-- namespace that is detected.
	other = 'other',
	
	-- The parameter name used to specify a page other than the current page;
	-- used for testing and demonstration.
	demopage = 'page',
}

--------------------------------------------------------------------------------
--                              Parameter values                              --
-- These are set values that can be used with certain parameters. Only one    --
-- value can be specified, like this:                                         --
--                                                                            --
-- cfg.foo = 'value name'                                                     --                                               --
--------------------------------------------------------------------------------

-- The following settings are used with the cfg.category2 parameter. Setting
-- cfg.category2 to cfg.category2Yes skips the blacklist, and if cfg.category2
-- is present but equal to anything other than cfg.category2Yes or
-- cfg.category2Negative then it supresses cateogrisation.
cfg.category2Yes = 'yes'
cfg.category2Negative = '¬'

-- The following settings are used with the cfg.subpage parameter.
-- cfg.subpageNo is the value to specify to not categorise on subpages;
-- cfg.subpageOnly is the value to specify to only categorise on subpages.
cfg.subpageNo = 'no'
cfg.subpageOnly = 'only'

--------------------------------------------------------------------------------
--                           Default namespaces                               --
-- This is a table of namespaces to categorise by default. The keys are the   --
-- namespace numbers.                                                         --
--------------------------------------------------------------------------------

cfg.defaultNamespaces = {
	[  0] = true, -- main
	[  6] = true, -- file
	[ 12] = true, -- help
	[ 14] = true, -- category
	[100] = true, -- portal
	[108] = true, -- book
}

--------------------------------------------------------------------------------
--                                Wrappers                                    --
-- This is a wrapper template or a list of wrapper templates to be passed to  --
-- [[Module:Arguments]].                                                      --
--------------------------------------------------------------------------------

cfg.wrappers = 'Template:Category handler'

--------------------------------------------------------------------------------
--                           End configuration data                           --
--------------------------------------------------------------------------------

return cfg -- Don't edit this line.</text>
      <sha1>6ga9hbq2pdwalsvx68i53dmbr421rq5</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Category handler/shared</title>
    <ns>828</ns>
    <id>1158</id>
    <revision>
      <id>6602</id>
      <timestamp>2026-05-19T06:32:13Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;-- This module contains shared functions used by [[Module:Category handler]] -- and its submodules.  local p = {}  function p.matchesBlacklist(page, blacklist) 	for i, pattern in ipairs(blacklist) do 		local match = mw.ustring.match(page, pattern) 		if match then 			return true 		end 	end 	return false end  function p.getParamMappings(useLoadData) 	local dataPage = 'Module:Namespace detect/data' 	if useLoadData then 		return mw.loadData(dataPage).mappings 	else 		return...&quot;</comment>
      <origin>6602</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="888" sha1="omlsnhudxz6juptvtxz7ns97jutbzc5" xml:space="preserve">-- This module contains shared functions used by [[Module:Category handler]]
-- and its submodules.

local p = {}

function p.matchesBlacklist(page, blacklist)
	for i, pattern in ipairs(blacklist) do
		local match = mw.ustring.match(page, pattern)
		if match then
			return true
		end
	end
	return false
end

function p.getParamMappings(useLoadData)
	local dataPage = 'Module:Namespace detect/data'
	if useLoadData then
		return mw.loadData(dataPage).mappings
	else
		return require(dataPage).mappings
	end
end

function p.getNamespaceParameters(titleObj, mappings)
	-- We don't use title.nsText for the namespace name because it adds
	-- underscores.
	local mappingsKey
	if titleObj.isTalkPage then
		mappingsKey = 'talk'
	else
		mappingsKey = mw.site.namespaces[titleObj.namespace].name
	end
	mappingsKey = mw.ustring.lower(mappingsKey)
	return mappings[mappingsKey] or {}
end

return p</text>
      <sha1>omlsnhudxz6juptvtxz7ns97jutbzc5</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Category handler/blacklist</title>
    <ns>828</ns>
    <id>1159</id>
    <revision>
      <id>6603</id>
      <timestamp>2026-05-19T06:32:40Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;-- This module contains the blacklist used by [[Module:Category handler]]. -- Pages that match Lua patterns in this list will not be categorised unless -- categorisation is explicitly requested.  return { 	'^Main Page$', -- don't categorise the main page.  	-- Don't categorise the following pages or their subpages. 	-- &quot;%f[/\0]&quot; matches if the next character is &quot;/&quot; or the end of the string. 	'^Wikipedia:Cascade%-protected items%f[/\0]', 	'^User:UBX%f[/\0]', -- The userbo...&quot;</comment>
      <origin>6603</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="761" sha1="fsv1drcay6t25e91hzhqxtyp7pckbpx" xml:space="preserve">-- This module contains the blacklist used by [[Module:Category handler]].
-- Pages that match Lua patterns in this list will not be categorised unless
-- categorisation is explicitly requested.

return {
	'^Main Page$', -- don't categorise the main page.

	-- Don't categorise the following pages or their subpages.
	-- &quot;%f[/\0]&quot; matches if the next character is &quot;/&quot; or the end of the string.
	'^Wikipedia:Cascade%-protected items%f[/\0]',
	'^User:UBX%f[/\0]', -- The userbox &quot;template&quot; space.
	'^User talk:UBX%f[/\0]',

	-- Don't categorise subpages of these pages, but allow
	-- categorisation of the base page.
	'^Wikipedia:Template index/.*$',

	-- Don't categorise archives.
	'/[aA]rchive',
	&quot;^Wikipedia:Administrators' noticeboard/IncidentArchive%d+$&quot;,
}</text>
      <sha1>fsv1drcay6t25e91hzhqxtyp7pckbpx</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Namespace detect/data</title>
    <ns>828</ns>
    <id>1160</id>
    <revision>
      <id>6604</id>
      <timestamp>2026-05-19T06:33:13Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;-------------------------------------------------------------------------------- --                          Namespace detect data                             -- -- This module holds data for [[Module:Namespace detect]] to be loaded per    -- -- page, rather than per #invoke, for performance reasons.                    -- --------------------------------------------------------------------------------  local cfg = require('Module:Namespace detect/config')  local function...&quot;</comment>
      <origin>6604</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="2569" sha1="ojp6d3pc8mql5nufaqdg576c9so3479" xml:space="preserve">--------------------------------------------------------------------------------
--                          Namespace detect data                             --
-- This module holds data for [[Module:Namespace detect]] to be loaded per    --
-- page, rather than per #invoke, for performance reasons.                    --
--------------------------------------------------------------------------------

local cfg = require('Module:Namespace detect/config')

local function addKey(t, key, defaultKey)
	if key ~= defaultKey then
		t[#t + 1] = key
	end
end

-- Get a table of parameters to query for each default parameter name.
-- This allows wikis to customise parameter names in the cfg table while
-- ensuring that default parameter names will always work. The cfg table
-- values can be added as a string, or as an array of strings.

local defaultKeys = {
	'main',
	'talk',
	'other',
	'subjectns',
	'demospace',
	'demopage'
}

local argKeys = {}
for i, defaultKey in ipairs(defaultKeys) do
	argKeys[defaultKey] = {defaultKey}
end

for defaultKey, t in pairs(argKeys) do
	local cfgValue = cfg[defaultKey]
	local cfgValueType = type(cfgValue)
	if cfgValueType == 'string' then
		addKey(t, cfgValue, defaultKey)
	elseif cfgValueType == 'table' then
		for i, key in ipairs(cfgValue) do
			addKey(t, key, defaultKey)
		end
	end
	cfg[defaultKey] = nil -- Free the cfg value as we don't need it any more.
end

local function getParamMappings()
	--[[
	-- Returns a table of how parameter names map to namespace names. The keys
	-- are the actual namespace names, in lower case, and the values are the
	-- possible parameter names for that namespace, also in lower case. The
	-- table entries are structured like this:
	-- {
	--   [''] = {'main'},
	--   ['wikipedia'] = {'wikipedia', 'project', 'wp'},
	--   ...
	-- }
	--]]
	local mappings = {}
	local mainNsName = mw.site.subjectNamespaces[0].name
	mainNsName = mw.ustring.lower(mainNsName)
	mappings[mainNsName] = mw.clone(argKeys.main)
	mappings['talk'] = mw.clone(argKeys.talk)
	for nsid, ns in pairs(mw.site.subjectNamespaces) do
		if nsid ~= 0 then -- Exclude main namespace.
			local nsname = mw.ustring.lower(ns.name)
			local canonicalName = mw.ustring.lower(ns.canonicalName)
			mappings[nsname] = {nsname}
			if canonicalName ~= nsname then
				table.insert(mappings[nsname], canonicalName)
			end
			for _, alias in ipairs(ns.aliases) do
				table.insert(mappings[nsname], mw.ustring.lower(alias))
			end
		end
	end
	return mappings
end

return {
	argKeys = argKeys,
	cfg = cfg,
	mappings = getParamMappings()
}</text>
      <sha1>ojp6d3pc8mql5nufaqdg576c9so3479</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Namespace detect/config</title>
    <ns>828</ns>
    <id>1161</id>
    <revision>
      <id>6605</id>
      <timestamp>2026-05-19T06:33:40Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;-------------------------------------------------------------------------------- --                    Namespace detect configuration data                     -- --                                                                            -- -- This module stores configuration data for Module:Namespace detect. Here    -- -- you can localise the module to your wiki's language.                       -- --...&quot;</comment>
      <origin>6605</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="3545" sha1="1o6ozz56i8q0xgyl6xa41n2v7kelhli" xml:space="preserve">--------------------------------------------------------------------------------
--                    Namespace detect configuration data                     --
--                                                                            --
-- This module stores configuration data for Module:Namespace detect. Here    --
-- you can localise the module to your wiki's language.                       --
--                                                                            --
-- To activate a configuration item, you need to uncomment it. This means     --
-- that you need to remove the text &quot;-- &quot; at the start of the line.           --
--------------------------------------------------------------------------------

local cfg = {} -- Don't edit this line.

--------------------------------------------------------------------------------
--                              Parameter names                               --
-- These configuration items specify custom parameter names. Values added     --
-- here will work in addition to the default English parameter names.         --
-- To add one extra name, you can use this format:                            --
--                                                                            --
-- cfg.foo = 'parameter name'                                                 --
--                                                                            --
-- To add multiple names, you can use this format:                            --
--                                                                            --
-- cfg.foo = {'parameter name 1', 'parameter name 2', 'parameter name 3'}     --
--------------------------------------------------------------------------------

---- This parameter displays content for the main namespace:
-- cfg.main = 'main'

---- This parameter displays in talk namespaces:
-- cfg.talk = 'talk'

---- This parameter displays content for &quot;other&quot; namespaces (namespaces for which
---- parameters have not been specified):
-- cfg.other = 'other'

---- This parameter makes talk pages behave as though they are the corresponding
---- subject namespace. Note that this parameter is used with [[Module:Yesno]].
---- Edit that module to change the default values of &quot;yes&quot;, &quot;no&quot;, etc.
-- cfg.subjectns = 'subjectns'

---- This parameter sets a demonstration namespace:
-- cfg.demospace = 'demospace'

---- This parameter sets a specific page to compare:
cfg.demopage = 'page'

--------------------------------------------------------------------------------
--                           Table configuration                              --
-- These configuration items allow customisation of the &quot;table&quot; function,     --
-- used to generate a table of possible parameters in the module              --
-- documentation.                                                             --
--------------------------------------------------------------------------------

---- The header for the namespace column in the wikitable containing the list of
---- possible subject-space parameters.
-- cfg.wikitableNamespaceHeader = 'Namespace'

---- The header for the wikitable containing the list of possible subject-space
---- parameters.
-- cfg.wikitableAliasesHeader = 'Aliases'

--------------------------------------------------------------------------------
--                        End of configuration data                           --
--------------------------------------------------------------------------------

return cfg -- Don't edit this line.</text>
      <sha1>1o6ozz56i8q0xgyl6xa41n2v7kelhli</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Tmbox</title>
    <ns>10</ns>
    <id>1162</id>
    <revision>
      <id>6608</id>
      <timestamp>2026-05-19T06:37:59Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;{{#invoke:Message box|tmbox}}&lt;noinclude&gt; {{documentation}} &lt;!-- Categories go on the /doc subpage, and interwikis go on Wikidata. --&gt; &lt;/noinclude&gt;&quot;</comment>
      <origin>6608</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="146" sha1="jcav8pdjkvcwg8gc4m0b4gox7yjnxku" xml:space="preserve">{{#invoke:Message box|tmbox}}&lt;noinclude&gt;
{{documentation}}
&lt;!-- Categories go on the /doc subpage, and interwikis go on Wikidata. --&gt;
&lt;/noinclude&gt;</text>
      <sha1>jcav8pdjkvcwg8gc4m0b4gox7yjnxku</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Message box/tmbox.css</title>
    <ns>828</ns>
    <id>1163</id>
    <revision>
      <id>6610</id>
      <timestamp>2026-05-19T06:40:26Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;/* {{pp|small=y}} */ .tmbox { 	margin: 4px 0; 	border-collapse: collapse; 	border: 1px solid #c0c090;    /* Default &quot;notice&quot; gray-brown */ 	background-color: #f8eaba; 	box-sizing: border-box; }  /* For the &quot;small=yes&quot; option. */ .tmbox.mbox-small { 	font-size: 88%; 	line-height: 1.25em; }  .tmbox-speedy { 	border: 2px solid #b32424;    /* Red */ 	background-color: #fee7e6;    /* Pink */ }  .tmbox-delete { 	border: 2px solid #b32424;    /* Red */ }  .tmbox-content { 	bord...&quot;</comment>
      <origin>6610</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="2042" sha1="ffh2lypp0mcty5c7j53ntmwywlflceo" xml:space="preserve">/* {{pp|small=y}} */
.tmbox {
	margin: 4px 0;
	border-collapse: collapse;
	border: 1px solid #c0c090;    /* Default &quot;notice&quot; gray-brown */
	background-color: #f8eaba;
	box-sizing: border-box;
}

/* For the &quot;small=yes&quot; option. */
.tmbox.mbox-small {
	font-size: 88%;
	line-height: 1.25em;
}

.tmbox-speedy {
	border: 2px solid #b32424;    /* Red */
	background-color: #fee7e6;    /* Pink */
}

.tmbox-delete {
	border: 2px solid #b32424;    /* Red */
}

.tmbox-content {
	border: 2px solid #f28500;    /* Orange */
}

.tmbox-style {
	border: 2px solid #fc3;       /* Yellow */
}

.tmbox-move {
	border: 2px solid #9932cc;    /* Purple */
}

.tmbox .mbox-text {
	border: none;
	/* @noflip */
	padding: 0.25em 0.9em;
	width: 100%;
}

.tmbox .mbox-image {
	border: none;
	/* @noflip */
	padding: 2px 0 2px 0.9em;
	text-align: center;
}

.tmbox .mbox-imageright {
	border: none;
	/* @noflip */
	padding: 2px 0.9em 2px 0;
	text-align: center;
}

/* An empty narrow cell */
.tmbox .mbox-empty-cell {           
	border: none;
	padding: 0;
	width: 1px;
}

/* keep synced with each other type of message box as this isn't qualified */
.mbox-invalid-type {
	text-align: center;
}

@media (min-width: 720px) {
	.tmbox {
		margin: 4px 10%;
	}
	
	.tmbox.mbox-small {
		/* @noflip */
		clear: right;
		/* @noflip */
		float: right;
		/* @noflip */
		margin: 4px 0 4px 1em;
		width: 238px;
	}
}

@media screen {
    html.skin-theme-clientpref-night .tmbox {
		background-color: #2e2505;    /* Dark brown, same hue/saturation as light */
	}
	
	html.skin-theme-clientpref-night .tmbox-speedy {
		background-color: #310402;    /* Dark red, same hue/saturation as light */
	}
}

@media screen and (prefers-color-scheme: dark) {
	html.skin-theme-clientpref-os .tmbox {
		background-color: #2e2505; /* Dark brown, same hue/saturation as light */
	}
	
	html.skin-theme-clientpref-os .tmbox-speedy {
		background-color: #310402; /* Dark red, same hue/saturation as light */
	}
}

/** T367463 */
body.skin--responsive table.tmbox img {
	max-width: none !important;
}</text>
      <sha1>ffh2lypp0mcty5c7j53ntmwywlflceo</sha1>
    </revision>
    <revision>
      <id>6614</id>
      <parentid>6610</parentid>
      <timestamp>2026-05-19T06:46:25Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6614</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="2021" sha1="85ylhi9duvtn6hrmfoxd35tfl1431pb" xml:space="preserve">.tmbox {
	margin: 4px 0;
	border-collapse: collapse;
	border: 1px solid #c0c090;    /* Default &quot;notice&quot; gray-brown */
	background-color: #f8eaba;
	box-sizing: border-box;
}

/* For the &quot;small=yes&quot; option. */
.tmbox.mbox-small {
	font-size: 88%;
	line-height: 1.25em;
}

.tmbox-speedy {
	border: 2px solid #b32424;    /* Red */
	background-color: #fee7e6;    /* Pink */
}

.tmbox-delete {
	border: 2px solid #b32424;    /* Red */
}

.tmbox-content {
	border: 2px solid #f28500;    /* Orange */
}

.tmbox-style {
	border: 2px solid #fc3;       /* Yellow */
}

.tmbox-move {
	border: 2px solid #9932cc;    /* Purple */
}

.tmbox .mbox-text {
	border: none;
	/* @noflip */
	padding: 0.25em 0.9em;
	width: 100%;
}

.tmbox .mbox-image {
	border: none;
	/* @noflip */
	padding: 2px 0 2px 0.9em;
	text-align: center;
}

.tmbox .mbox-imageright {
	border: none;
	/* @noflip */
	padding: 2px 0.9em 2px 0;
	text-align: center;
}

/* An empty narrow cell */
.tmbox .mbox-empty-cell {           
	border: none;
	padding: 0;
	width: 1px;
}

/* keep synced with each other type of message box as this isn't qualified */
.mbox-invalid-type {
	text-align: center;
}

@media (min-width: 720px) {
	.tmbox {
		margin: 4px 10%;
	}
	
	.tmbox.mbox-small {
		/* @noflip */
		clear: right;
		/* @noflip */
		float: right;
		/* @noflip */
		margin: 4px 0 4px 1em;
		width: 238px;
	}
}

@media screen {
    html.skin-theme-clientpref-night .tmbox {
		background-color: #2e2505;    /* Dark brown, same hue/saturation as light */
	}
	
	html.skin-theme-clientpref-night .tmbox-speedy {
		background-color: #310402;    /* Dark red, same hue/saturation as light */
	}
}

@media screen and (prefers-color-scheme: dark) {
	html.skin-theme-clientpref-os .tmbox {
		background-color: #2e2505; /* Dark brown, same hue/saturation as light */
	}
	
	html.skin-theme-clientpref-os .tmbox-speedy {
		background-color: #310402; /* Dark red, same hue/saturation as light */
	}
}

/** T367463 */
body.skin--responsive table.tmbox img {
	max-width: none !important;
}</text>
      <sha1>85ylhi9duvtn6hrmfoxd35tfl1431pb</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Message box/ombox.css</title>
    <ns>828</ns>
    <id>1164</id>
    <revision>
      <id>6611</id>
      <timestamp>2026-05-19T06:41:10Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;/* {{pp|small=y}} */ .ombox { 	margin: 4px 0; 	border-collapse: collapse; 	border: 1px solid #a2a9b1;    /* Default &quot;notice&quot; gray */ 	background-color: var(--background-color-neutral-subtle, #f8f9fa); 	box-sizing: border-box;     color: var(--color-base, #202122); }  /* For the &quot;small=yes&quot; option. */ .ombox.mbox-small { 	font-size: 88%; 	line-height: 1.25em; }  .ombox-speedy { 	border: 2px solid #b32424;    /* Red */ 	background-color: #fee7e6;    /* Pink */ }  .ombox-de...&quot;</comment>
      <origin>6611</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="1923" sha1="s3kd4o8l90hza7k55c82cm0ltkd3xp2" xml:space="preserve">/* {{pp|small=y}} */
.ombox {
	margin: 4px 0;
	border-collapse: collapse;
	border: 1px solid #a2a9b1;    /* Default &quot;notice&quot; gray */
	background-color: var(--background-color-neutral-subtle, #f8f9fa);
	box-sizing: border-box;
    color: var(--color-base, #202122);
}

/* For the &quot;small=yes&quot; option. */
.ombox.mbox-small {
	font-size: 88%;
	line-height: 1.25em;
}

.ombox-speedy {
	border: 2px solid #b32424;    /* Red */
	background-color: #fee7e6;    /* Pink */
}

.ombox-delete {
	border: 2px solid #b32424;    /* Red */
}

.ombox-content {
	border: 1px solid #f28500;    /* Orange */
}

.ombox-style {
	border: 1px solid #fc3;       /* Yellow */
}

.ombox-move {
	border: 1px solid #9932cc;    /* Purple */
}

.ombox-protection {
	border: 2px solid #a2a9b1;    /* Gray-gold */
}

.ombox .mbox-text {
	border: none;
	/* @noflip */
	padding: 0.25em 0.9em;
	width: 100%;
}

.ombox .mbox-image {
	border: none;
	/* @noflip */
	padding: 2px 0 2px 0.9em;
	text-align: center;
}

.ombox .mbox-imageright {
	border: none;
	/* @noflip */
	padding: 2px 0.9em 2px 0;
	text-align: center;
}

/* An empty narrow cell */
.ombox .mbox-empty-cell {
	border: none;
	padding: 0;
	width: 1px;
}

/* keep synced with each other type of message box as this isn't qualified */
.mbox-invalid-type {
	text-align: center;
}

@media (min-width: 720px) {
	.ombox {
		margin: 4px 10%;
	}
	
	.ombox.mbox-small {
		/* @noflip */
		clear: right;
		/* @noflip */
		float: right;
		/* @noflip */
		margin: 4px 0 4px 1em;
		width: 238px;
	}
}

/** T367463 */
body.skin--responsive table.ombox img {
	max-width: none !important;
}

@media screen {
	html.skin-theme-clientpref-night .ombox-speedy {
		background-color: #310402;    /* Dark red, same hue/saturation as light */
	}
}

@media screen and (prefers-color-scheme: dark) {
	html.skin-theme-clientpref-os .ombox-speedy {
		background-color: #310402; /* Dark red, same hue/saturation as light */
	}
}</text>
      <sha1>s3kd4o8l90hza7k55c82cm0ltkd3xp2</sha1>
    </revision>
    <revision>
      <id>6612</id>
      <parentid>6611</parentid>
      <timestamp>2026-05-19T06:42:26Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6612</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="1902" sha1="j5hpz75a9bm4jwa16xb00sw1cl5djn7" xml:space="preserve">.ombox {
	margin: 4px 0;
	border-collapse: collapse;
	border: 1px solid #a2a9b1;    /* Default &quot;notice&quot; gray */
	background-color: var(--background-color-neutral-subtle, #f8f9fa);
	box-sizing: border-box;
    color: var(--color-base, #202122);
}

/* For the &quot;small=yes&quot; option. */
.ombox.mbox-small {
	font-size: 88%;
	line-height: 1.25em;
}

.ombox-speedy {
	border: 2px solid #b32424;    /* Red */
	background-color: #fee7e6;    /* Pink */
}

.ombox-delete {
	border: 2px solid #b32424;    /* Red */
}

.ombox-content {
	border: 1px solid #f28500;    /* Orange */
}

.ombox-style {
	border: 1px solid #fc3;       /* Yellow */
}

.ombox-move {
	border: 1px solid #9932cc;    /* Purple */
}

.ombox-protection {
	border: 2px solid #a2a9b1;    /* Gray-gold */
}

.ombox .mbox-text {
	border: none;
	/* @noflip */
	padding: 0.25em 0.9em;
	width: 100%;
}

.ombox .mbox-image {
	border: none;
	/* @noflip */
	padding: 2px 0 2px 0.9em;
	text-align: center;
}

.ombox .mbox-imageright {
	border: none;
	/* @noflip */
	padding: 2px 0.9em 2px 0;
	text-align: center;
}

/* An empty narrow cell */
.ombox .mbox-empty-cell {
	border: none;
	padding: 0;
	width: 1px;
}

/* keep synced with each other type of message box as this isn't qualified */
.mbox-invalid-type {
	text-align: center;
}

@media (min-width: 720px) {
	.ombox {
		margin: 4px 10%;
	}
	
	.ombox.mbox-small {
		/* @noflip */
		clear: right;
		/* @noflip */
		float: right;
		/* @noflip */
		margin: 4px 0 4px 1em;
		width: 238px;
	}
}

/** T367463 */
body.skin--responsive table.ombox img {
	max-width: none !important;
}

@media screen {
	html.skin-theme-clientpref-night .ombox-speedy {
		background-color: #310402;    /* Dark red, same hue/saturation as light */
	}
}

@media screen and (prefers-color-scheme: dark) {
	html.skin-theme-clientpref-os .ombox-speedy {
		background-color: #310402; /* Dark red, same hue/saturation as light */
	}
}</text>
      <sha1>j5hpz75a9bm4jwa16xb00sw1cl5djn7</sha1>
    </revision>
    <revision>
      <id>6613</id>
      <parentid>6612</parentid>
      <timestamp>2026-05-19T06:45:01Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6613</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="1831" sha1="5gv8lkpvzcasyypj8kwtvyoliam8iq0" xml:space="preserve">.ombox {
	margin: 4px 0;
	border-collapse: collapse;
	border: 1px solid #a2a9b1;    /* Default &quot;notice&quot; gray */
	background-color: var(--background-color-neutral-subtle, #f8f9fa);
	box-sizing: border-box;
    color: var(--color-base, #202122);
}

/* For the &quot;small=yes&quot; option. */
.ombox.mbox-small {
	font-size: 88%;
	line-height: 1.25em;
}

.ombox-speedy {
	border: 2px solid #b32424;    /* Red */
	background-color: #fee7e6;    /* Pink */
}

.ombox-delete {
	border: 2px solid #b32424;    /* Red */
}

.ombox-content {
	border: 1px solid #f28500;    /* Orange */
}

.ombox-style {
	border: 1px solid #fc3;       /* Yellow */
}

.ombox-move {
	border: 1px solid #9932cc;    /* Purple */
}

.ombox-protection {
	border: 2px solid #a2a9b1;    /* Gray-gold */
}

.ombox .mbox-text {
	border: none;
	/* @noflip */
	padding: 0.25em 0.9em;
	width: 100%;
}

.ombox .mbox-image {
	border: none;
	/* @noflip */
	padding: 2px 0 2px 0.9em;
	text-align: center;
}

.ombox .mbox-imageright {
	border: none;
	/* @noflip */
	padding: 2px 0.9em 2px 0;
	text-align: center;
}

/* An empty narrow cell */
.ombox .mbox-empty-cell {
	border: none;
	padding: 0;
	width: 1px;
}

.ombox .mbox-invalid-type {
	text-align: center;
}

@media (min-width: 720px) {
	.ombox {
		margin: 4px 10%;
	}
	
	.ombox.mbox-small {
		/* @noflip */
		clear: right;
		/* @noflip */
		float: right;
		/* @noflip */
		margin: 4px 0 4px 1em;
		width: 238px;
	}
}

/** T367463 */
body.skin--responsive table.ombox img {
	max-width: none !important;
}

@media screen {
	html.skin-theme-clientpref-night .ombox-speedy {
		background-color: #310402;    /* Dark red, same hue/saturation as light */
	}
}

@media screen and (prefers-color-scheme: dark) {
	html.skin-theme-clientpref-os .ombox-speedy {
		background-color: #310402; /* Dark red, same hue/saturation as light */
	}
}</text>
      <sha1>5gv8lkpvzcasyypj8kwtvyoliam8iq0</sha1>
    </revision>
    <revision>
      <id>6615</id>
      <parentid>6613</parentid>
      <timestamp>2026-05-19T06:47:30Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Undid revision [[Special:Diff/6613|6613]] by [[Special:Contributions/NgamangaXhosa|NgamangaXhosa]] ([[User talk:NgamangaXhosa|talk]])</comment>
      <origin>6615</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="1902" sha1="j5hpz75a9bm4jwa16xb00sw1cl5djn7" xml:space="preserve">.ombox {
	margin: 4px 0;
	border-collapse: collapse;
	border: 1px solid #a2a9b1;    /* Default &quot;notice&quot; gray */
	background-color: var(--background-color-neutral-subtle, #f8f9fa);
	box-sizing: border-box;
    color: var(--color-base, #202122);
}

/* For the &quot;small=yes&quot; option. */
.ombox.mbox-small {
	font-size: 88%;
	line-height: 1.25em;
}

.ombox-speedy {
	border: 2px solid #b32424;    /* Red */
	background-color: #fee7e6;    /* Pink */
}

.ombox-delete {
	border: 2px solid #b32424;    /* Red */
}

.ombox-content {
	border: 1px solid #f28500;    /* Orange */
}

.ombox-style {
	border: 1px solid #fc3;       /* Yellow */
}

.ombox-move {
	border: 1px solid #9932cc;    /* Purple */
}

.ombox-protection {
	border: 2px solid #a2a9b1;    /* Gray-gold */
}

.ombox .mbox-text {
	border: none;
	/* @noflip */
	padding: 0.25em 0.9em;
	width: 100%;
}

.ombox .mbox-image {
	border: none;
	/* @noflip */
	padding: 2px 0 2px 0.9em;
	text-align: center;
}

.ombox .mbox-imageright {
	border: none;
	/* @noflip */
	padding: 2px 0.9em 2px 0;
	text-align: center;
}

/* An empty narrow cell */
.ombox .mbox-empty-cell {
	border: none;
	padding: 0;
	width: 1px;
}

/* keep synced with each other type of message box as this isn't qualified */
.mbox-invalid-type {
	text-align: center;
}

@media (min-width: 720px) {
	.ombox {
		margin: 4px 10%;
	}
	
	.ombox.mbox-small {
		/* @noflip */
		clear: right;
		/* @noflip */
		float: right;
		/* @noflip */
		margin: 4px 0 4px 1em;
		width: 238px;
	}
}

/** T367463 */
body.skin--responsive table.ombox img {
	max-width: none !important;
}

@media screen {
	html.skin-theme-clientpref-night .ombox-speedy {
		background-color: #310402;    /* Dark red, same hue/saturation as light */
	}
}

@media screen and (prefers-color-scheme: dark) {
	html.skin-theme-clientpref-os .ombox-speedy {
		background-color: #310402; /* Dark red, same hue/saturation as light */
	}
}</text>
      <sha1>j5hpz75a9bm4jwa16xb00sw1cl5djn7</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Umbox</title>
    <ns>10</ns>
    <id>1165</id>
    <revision>
      <id>6616</id>
      <timestamp>2026-05-19T06:57:53Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;{{ safesubst:&lt;noinclude/&gt;ifsubst||&lt;templatestyles src=&quot;Template:Umbox/styles.css&quot; /&gt;}}&lt;!-- --&gt;&lt;div class=&quot;umbox {{{{{|safesubst:}}}#if:{{{class|}}}|{{{class|}}}|}}&quot; style=&quot;{{ safesubst:&lt;noinclude/&gt;ifsubst|background-color: var(--background-color-content-added, #a3d3ff); border: var(--border-color-progressive, #36c) 1px solid; margin: 2em 0 1em; padding: 0.5em 1em; font-weight: bold; overflow: auto; vertical-align: middle;}} {{{{{|safesubst:}}}#if:{{{style|}}}|{{{style|}}...&quot;</comment>
      <origin>6616</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="790" sha1="sc9gr4m0e4jkg0i69cxsbzpt4rl3hl6" xml:space="preserve">{{ safesubst:&lt;noinclude/&gt;ifsubst||&lt;templatestyles src=&quot;Template:Umbox/styles.css&quot; /&gt;}}&lt;!--
--&gt;&lt;div class=&quot;umbox {{{{{|safesubst:}}}#if:{{{class|}}}|{{{class|}}}|}}&quot; style=&quot;{{ safesubst:&lt;noinclude/&gt;ifsubst|background-color: var(--background-color-content-added, #a3d3ff); border: var(--border-color-progressive, #36c) 1px solid; margin: 2em 0 1em; padding: 0.5em 1em; font-weight: bold; overflow: auto; vertical-align: middle;}} {{{{{|safesubst:}}}#if:{{{style|}}}|{{{style|}}}|}}&quot;&gt;&lt;noinclude&gt;&lt;!--

// Image

--&gt;&lt;/noinclude&gt;{{{{{|safesubst:}}}#if:{{{image|}}}|[[File:{{{image}}}|left|{{{image-size|40px}}}|link={{{imagelink|}}}]]}}&lt;noinclude&gt;&lt;!--

// Text

--&gt;&lt;/noinclude&gt;{{{text|}}}&lt;/div&gt;&lt;noinclude&gt;

{{Documentation}}
&lt;!-- PLEASE ADD CATEGORIES TO THE /doc SUBPAGE, THANKS --&gt;
&lt;/noinclude&gt;</text>
      <sha1>sc9gr4m0e4jkg0i69cxsbzpt4rl3hl6</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Ifsubst</title>
    <ns>10</ns>
    <id>1166</id>
    <revision>
      <id>6617</id>
      <timestamp>2026-05-19T06:58:18Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;{{ safesubst:&lt;noinclude/&gt;#if:{{{demo|}}} |{{ safesubst:&lt;noinclude/&gt;#ifeq:{{{demo}}} |no  |{{{no|{{{2|}}}}}}  |{{{yes|{{{1|}}}}}} }} |{{ safesubst:&lt;noinclude/&gt;#ifeq:{{ safesubst:&lt;noinclude/&gt;NAMESPACE}}|{{NAMESPACE}}  |{{{no|{{{2|}}}}}}  |{{{yes|{{{1|}}}}}} }}}}&lt;noinclude&gt; {{Documentation}} &lt;/noinclude&gt;&quot;</comment>
      <origin>6617</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="302" sha1="6n9xrkgwrhqddknwc59l4tya8074m0o" xml:space="preserve">{{ safesubst:&lt;noinclude/&gt;#if:{{{demo|}}}
|{{ safesubst:&lt;noinclude/&gt;#ifeq:{{{demo}}} |no
 |{{{no|{{{2|}}}}}}
 |{{{yes|{{{1|}}}}}}
}}
|{{ safesubst:&lt;noinclude/&gt;#ifeq:{{ safesubst:&lt;noinclude/&gt;NAMESPACE}}|{{NAMESPACE}}
 |{{{no|{{{2|}}}}}}
 |{{{yes|{{{1|}}}}}}
}}}}&lt;noinclude&gt;
{{Documentation}}
&lt;/noinclude&gt;</text>
      <sha1>6n9xrkgwrhqddknwc59l4tya8074m0o</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Umbox/styles.css</title>
    <ns>10</ns>
    <id>1167</id>
    <revision>
      <id>6618</id>
      <timestamp>2026-05-19T06:59:11Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;.umbox { 	background-color: var(--background-color-content-added, #a3d3ff); 	border: 1px solid var(--border-color-progressive, #36c); 	padding: 0.5em 1em; 	margin: 2em 0 1em; 	font-weight: bold; 	overflow: auto; 	vertical-align: middle; }&quot;</comment>
      <origin>6618</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="238" sha1="8l5tcscdaytbdr01322sa6xslrrmmv2" xml:space="preserve">.umbox {
	background-color: var(--background-color-content-added, #a3d3ff);
	border: 1px solid var(--border-color-progressive, #36c);
	padding: 0.5em 1em;
	margin: 2em 0 1em;
	font-weight: bold;
	overflow: auto;
	vertical-align: middle;
}</text>
      <sha1>8l5tcscdaytbdr01322sa6xslrrmmv2</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:You've got mail/doc</title>
    <ns>10</ns>
    <id>1168</id>
    <revision>
      <id>6619</id>
      <timestamp>2026-05-19T07:01:14Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;{{umbox |image={{SAFESUBST:&lt;noinclude /&gt;#if:{{{tweet|}}}||Mail-message-new.svg}} |text=&lt;big&gt;'''Lotjha. Sibawa uhlole i-imeyili yakho; une-imeyela!'''&lt;/big&gt; Kungathatha imizuzu embalwa kusukela ngesikhathi i-imeyili ithunyelwa bona ivele ebhokisini lakho lokungenayo. Ungasusa isaziso lesi nanyana kunini ngokususa umhlahlandlelasakhiwo esithi {{tl|You've got mail}} nofana {{tl|ygm}}. }} &lt;noinclude&gt;{{documentation}}&lt;!-- PLEASE ADD CATEGORIES AND INTERWIKIS TO THE /doc SUB-P...&quot;</comment>
      <origin>6619</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="502" sha1="2im7346slc39an2u5602zl432b6s54f" xml:space="preserve">{{umbox
|image={{SAFESUBST:&lt;noinclude /&gt;#if:{{{tweet|}}}||Mail-message-new.svg}}
|text=&lt;big&gt;'''Lotjha. Sibawa uhlole i-imeyili yakho; une-imeyela!'''&lt;/big&gt; Kungathatha imizuzu embalwa kusukela ngesikhathi i-imeyili ithunyelwa bona ivele ebhokisini lakho lokungenayo. Ungasusa isaziso lesi nanyana kunini ngokususa umhlahlandlelasakhiwo esithi {{tl|You've got mail}} nofana {{tl|ygm}}.
}}
&lt;noinclude&gt;{{documentation}}&lt;!-- PLEASE ADD CATEGORIES AND INTERWIKIS TO THE /doc SUB-PAGE, THANKS --&gt;&lt;/noinclude&gt;</text>
      <sha1>2im7346slc39an2u5602zl432b6s54f</sha1>
    </revision>
  </page>
  <page>
    <title>Charles I of England</title>
    <ns>0</ns>
    <id>1169</id>
    <redirect title="Charles II of England" />
    <revision>
      <id>6624</id>
      <timestamp>2026-05-19T07:48:42Z</timestamp>
      <contributor>
        <username>Kwamikagami</username>
        <id>1412</id>
      </contributor>
      <comment>Kwamikagami moved page [[Charles I of England]] to [[Charles II of England]]: wrong topic</comment>
      <origin>6624</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="35" sha1="4sb0xfn9wry2ewg45b5e93i5fwj8int" xml:space="preserve">#REDIRECT [[Charles II of England]]</text>
      <sha1>4sb0xfn9wry2ewg45b5e93i5fwj8int</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi asiqongelane:Артем Загребельный</title>
    <ns>3</ns>
    <id>1170</id>
    <revision>
      <id>6626</id>
      <timestamp>2026-05-19T12:26:48Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;{{Not around}}&quot;</comment>
      <origin>6626</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="14" sha1="nhmxey8t2nsr7vh81fp6rh6187z5679" xml:space="preserve">{{Not around}}</text>
      <sha1>nhmxey8t2nsr7vh81fp6rh6187z5679</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi asiqongelane:Azaniya</title>
    <ns>3</ns>
    <id>1171</id>
    <revision>
      <id>6627</id>
      <timestamp>2026-05-19T12:27:56Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;{{Not around}}&quot;</comment>
      <origin>6627</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="14" sha1="nhmxey8t2nsr7vh81fp6rh6187z5679" xml:space="preserve">{{Not around}}</text>
      <sha1>nhmxey8t2nsr7vh81fp6rh6187z5679</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi asiqongelane:Enthusiastic Lady</title>
    <ns>3</ns>
    <id>1172</id>
    <revision>
      <id>6628</id>
      <timestamp>2026-05-19T12:29:46Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;{{Not around}}&quot;</comment>
      <origin>6628</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="14" sha1="nhmxey8t2nsr7vh81fp6rh6187z5679" xml:space="preserve">{{Not around}}</text>
      <sha1>nhmxey8t2nsr7vh81fp6rh6187z5679</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:AfC-c</title>
    <ns>10</ns>
    <id>1173</id>
    <revision>
      <id>6629</id>
      <timestamp>2026-05-19T13:45:17Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;{{#switch:{{lc:{{{1}}}}} | bottom | b        = {{#ifeq:{{ROOTPAGENAME}}|Files for upload|&lt;/div&gt;}}&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;''This is an archived discussion. &lt;span style=&quot;color:(--color-error, red);&quot;&gt;'''Please do not modify it.'''&lt;/span&gt; Subsequent comments should be made in a new section.''&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt; | #default = &lt;table class=&quot;mw-collapsible mw-collapsed mw-archivedtalk&quot; style=&quot;width: 100%; border: 0; margin-top: 0.2em; text-align: left;&quot;&gt; &lt;tr...&quot;</comment>
      <origin>6629</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3102" sha1="fj2go623fyyxls3lhdk68yyeh9djyws" xml:space="preserve">{{#switch:{{lc:{{{1}}}}}
| bottom
| b        = {{#ifeq:{{ROOTPAGENAME}}|Files for upload|&lt;/div&gt;}}&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;''This is an archived discussion. &lt;span style=&quot;color:(--color-error, red);&quot;&gt;'''Please do not modify it.'''&lt;/span&gt; Subsequent comments should be made in a new section.''&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
| #default = &lt;table class=&quot;mw-collapsible mw-collapsed mw-archivedtalk&quot; style=&quot;width: 100%; border: 0; margin-top: 0.2em; text-align: left;&quot;&gt;
&lt;tr&gt;{{#switch: {{lc:{{{1}}}}}
  | withdrawn
  | w = &lt;th style=&quot;background-color: var(--background-color-notice-subtle, #b8b8b8); color: inherit; text-align: center;&quot;&gt; [[File:Pictogram voting comment.svg|14px|alt=|link=]] This request has been withdrawn
  | partially-accepted
  | p = &lt;th style=&quot;background-color: var(--background-color-warning-subtle, #fff17e); color: inherit; text-align: center;&quot;&gt; [[File:Symbol confirmed.svg|14px|alt=|link=]][[File:Symbol oppose vote.svg|14px|alt=|link=]] This request has been partially accepted
  | unsuccessful
  | us = &lt;th style=&quot;background-color: var(--background-color-error-subtle, #bf8f8f); color: inherit; text-align: center;&quot;&gt; [[File:Symbol delete vote darkened.svg|14px|alt=|link=]] This request was unsuccessful
  | declined
  | d = &lt;th style=&quot;background-color: var(--background-color-error-subtle, #ffcece); color: inherit; text-align: center;&quot;&gt;[[File:Symbol oppose vote.svg|14px|alt=|link=]] This request has been declined
  | mass-accepted
  | ma = &lt;th style=&quot;background-color: var(--background-color-success-subtle, #68ff68); color: inherit; text-align: center;&quot;&gt;[[File:Symbol support vote.svg|14px|alt=|link=]][[File:Symbol support vote.svg|14px|alt=|link=]] These requests have been mass-moderated and accepted, unless otherwise marked
  | mass-declined
  | m
  | md = &lt;th style=&quot;background-color: var(--background-color-error-subtle, #ff9999); color: inherit; text-align: center;&quot;&gt;[[File:Symbol oppose vote.svg|14px|alt=|link=]][[File:Symbol oppose vote.svg|14px|alt=|link=]] These requests have been mass-moderated and declined, unless otherwise marked
  | succeeded
  | s = &lt;th style=&quot;background-color: var(--background-color-success-subtle, #90c090); color: inherit; text-align: center;&quot;&gt;[[File:Symbol confirmed.svg|14px|alt=|link=]] This request has succeeded
  | response
  | r = &lt;th style=&quot;background-color: var(--background-color-error-subtle, #ffcece); color: inherit; text-align: center;&quot;&gt;[[File:Image-Symbol wait old.svg|14px|alt=|link=]] This request has been closed because there was no response
  | accepted
  | a
  | #default = &lt;th style=&quot;background-color: var(--background-color-success-subtle, #a0ffa0); color: inherit; text-align: center;&quot;&gt;[[File:Symbol support vote.svg|14px|alt=|link=]] This request has been accepted
 }}. &lt;span style=&quot;color: var(--color-error, red);&quot;&gt;Please do not modify {{#switch:{{lc:{{{1}}}}}|ma|md=them|it}}.&lt;/span&gt;&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border: solid 1px; padding: 8px; background-color: var(--background-color-neutral, #e0e0e0); color: var(--color-base, #202122)&quot;&gt;
}}&lt;noinclude&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>fj2go623fyyxls3lhdk68yyeh9djyws</sha1>
    </revision>
    <revision>
      <id>6631</id>
      <parentid>6629</parentid>
      <timestamp>2026-05-19T13:48:50Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6631</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3100" sha1="f3z8bazw4hpvxcsi6log5o66ded44m6" xml:space="preserve">{{#switch:{{lc:{{{1}}}}}
| bottom
| b        = {{#ifeq:{{ROOTPAGENAME}}|Files for upload|&lt;/div&gt;}}&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;''Le yingcoco ebulungelweko. &lt;span style=&quot;color:(--color-error, red);&quot;&gt;'''Sibawa ungayitjhugululi.'''&lt;/span&gt; Ukuphawula okutjha kufanele kwenziwe esigabeni esitjha.''&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
| #default = &lt;table class=&quot;mw-collapsible mw-collapsed mw-archivedtalk&quot; style=&quot;width: 100%; border: 0; margin-top: 0.2em; text-align: left;&quot;&gt;
&lt;tr&gt;{{#switch: {{lc:{{{1}}}}}
  | withdrawn
  | w = &lt;th style=&quot;background-color: var(--background-color-notice-subtle, #b8b8b8); color: inherit; text-align: center;&quot;&gt; [[File:Pictogram voting comment.svg|14px|alt=|link=]] This request has been withdrawn
  | partially-accepted
  | p = &lt;th style=&quot;background-color: var(--background-color-warning-subtle, #fff17e); color: inherit; text-align: center;&quot;&gt; [[File:Symbol confirmed.svg|14px|alt=|link=]][[File:Symbol oppose vote.svg|14px|alt=|link=]] This request has been partially accepted
  | unsuccessful
  | us = &lt;th style=&quot;background-color: var(--background-color-error-subtle, #bf8f8f); color: inherit; text-align: center;&quot;&gt; [[File:Symbol delete vote darkened.svg|14px|alt=|link=]] This request was unsuccessful
  | declined
  | d = &lt;th style=&quot;background-color: var(--background-color-error-subtle, #ffcece); color: inherit; text-align: center;&quot;&gt;[[File:Symbol oppose vote.svg|14px|alt=|link=]] This request has been declined
  | mass-accepted
  | ma = &lt;th style=&quot;background-color: var(--background-color-success-subtle, #68ff68); color: inherit; text-align: center;&quot;&gt;[[File:Symbol support vote.svg|14px|alt=|link=]][[File:Symbol support vote.svg|14px|alt=|link=]] These requests have been mass-moderated and accepted, unless otherwise marked
  | mass-declined
  | m
  | md = &lt;th style=&quot;background-color: var(--background-color-error-subtle, #ff9999); color: inherit; text-align: center;&quot;&gt;[[File:Symbol oppose vote.svg|14px|alt=|link=]][[File:Symbol oppose vote.svg|14px|alt=|link=]] These requests have been mass-moderated and declined, unless otherwise marked
  | succeeded
  | s = &lt;th style=&quot;background-color: var(--background-color-success-subtle, #90c090); color: inherit; text-align: center;&quot;&gt;[[File:Symbol confirmed.svg|14px|alt=|link=]] This request has succeeded
  | response
  | r = &lt;th style=&quot;background-color: var(--background-color-error-subtle, #ffcece); color: inherit; text-align: center;&quot;&gt;[[File:Image-Symbol wait old.svg|14px|alt=|link=]] This request has been closed because there was no response
  | accepted
  | a
  | #default = &lt;th style=&quot;background-color: var(--background-color-success-subtle, #a0ffa0); color: inherit; text-align: center;&quot;&gt;[[File:Symbol support vote.svg|14px|alt=|link=]] This request has been accepted
 }}. &lt;span style=&quot;color: var(--color-error, red);&quot;&gt;Please do not modify {{#switch:{{lc:{{{1}}}}}|ma|md=them|it}}.&lt;/span&gt;&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border: solid 1px; padding: 8px; background-color: var(--background-color-neutral, #e0e0e0); color: var(--color-base, #202122)&quot;&gt;
}}&lt;noinclude&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>f3z8bazw4hpvxcsi6log5o66ded44m6</sha1>
    </revision>
    <revision>
      <id>6632</id>
      <parentid>6631</parentid>
      <timestamp>2026-05-19T14:02:40Z</timestamp>
      <contributor>
        <username>SetswanaPula</username>
        <id>1520</id>
      </contributor>
      <origin>6632</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3081" sha1="endle19ldb9xddpmogiy5ldg0xbi72i" xml:space="preserve">{{#switch:{{lc:{{{1}}}}}
| bottom
| b        = {{#ifeq:{{ROOTPAGENAME}}|Files for upload|&lt;/div&gt;}}&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;''Le yingcoco ebulungelweko. &lt;span style=&quot;color:(--color-error, red);&quot;&gt;'''Sibawa ungayitjhugululi.'''&lt;/span&gt; Ukuphawula okutjha kufanele kwenziwe esigabeni esitjha.''&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
| #default = &lt;table class=&quot;mw-collapsible mw-collapsed mw-archivedtalk&quot; style=&quot;width: 100%; border: 0; margin-top: 0.2em; text-align: left;&quot;&gt;
&lt;tr&gt;{{#switch: {{lc:{{{1}}}}}
  | withdrawn
  | w = &lt;th style=&quot;background-color: var(--background-color-notice-subtle, #b8b8b8); color: inherit; text-align: center;&quot;&gt; [[File:Pictogram voting comment.svg|14px|alt=|link=]] This request has been withdrawn
  | partially-accepted
  | p = &lt;th style=&quot;background-color: var(--background-color-warning-subtle, #fff17e); color: inherit; text-align: center;&quot;&gt; [[File:Symbol confirmed.svg|14px|alt=|link=]][[File:Symbol oppose vote.svg|14px|alt=|link=]] This request has been partially accepted
  | unsuccessful
  | us = &lt;th style=&quot;background-color: var(--background-color-error-subtle, #bf8f8f); color: inherit; text-align: center;&quot;&gt; [[File:Symbol delete vote darkened.svg|14px|alt=|link=]] This request was unsuccessful
  | declined
  | d = &lt;th style=&quot;background-color: var(--background-color-error-subtle, #ffcece); color: inherit; text-align: center;&quot;&gt;[[File:Symbol oppose vote.svg|14px|alt=|link=]] Isibawo lesi saliwa
  | mass-accepted
  | ma = &lt;th style=&quot;background-color: var(--background-color-success-subtle, #68ff68); color: inherit; text-align: center;&quot;&gt;[[File:Symbol support vote.svg|14px|alt=|link=]][[File:Symbol support vote.svg|14px|alt=|link=]] These requests have been mass-moderated and accepted, unless otherwise marked
  | mass-declined
  | m
  | md = &lt;th style=&quot;background-color: var(--background-color-error-subtle, #ff9999); color: inherit; text-align: center;&quot;&gt;[[File:Symbol oppose vote.svg|14px|alt=|link=]][[File:Symbol oppose vote.svg|14px|alt=|link=]] These requests have been mass-moderated and declined, unless otherwise marked
  | succeeded
  | s = &lt;th style=&quot;background-color: var(--background-color-success-subtle, #90c090); color: inherit; text-align: center;&quot;&gt;[[File:Symbol confirmed.svg|14px|alt=|link=]] This request has succeeded
  | response
  | r = &lt;th style=&quot;background-color: var(--background-color-error-subtle, #ffcece); color: inherit; text-align: center;&quot;&gt;[[File:Image-Symbol wait old.svg|14px|alt=|link=]] This request has been closed because there was no response
  | accepted
  | a
  | #default = &lt;th style=&quot;background-color: var(--background-color-success-subtle, #a0ffa0); color: inherit; text-align: center;&quot;&gt;[[File:Symbol support vote.svg|14px|alt=|link=]] Isibawo lesi samukelwe
 }}. &lt;span style=&quot;color: var(--color-error, red);&quot;&gt;Please do not modify {{#switch:{{lc:{{{1}}}}}|ma|md=them|it}}.&lt;/span&gt;&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border: solid 1px; padding: 8px; background-color: var(--background-color-neutral, #e0e0e0); color: var(--color-base, #202122)&quot;&gt;
}}&lt;noinclude&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>endle19ldb9xddpmogiy5ldg0xbi72i</sha1>
    </revision>
    <revision>
      <id>6633</id>
      <parentid>6632</parentid>
      <timestamp>2026-05-19T14:03:25Z</timestamp>
      <contributor>
        <username>SetswanaPula</username>
        <id>1520</id>
      </contributor>
      <origin>6633</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3044" sha1="fo79ui9j0uxhf9b6roi0w78zji85h1g" xml:space="preserve">{{#switch:{{lc:{{{1}}}}}
| bottom
| b        = {{#ifeq:{{ROOTPAGENAME}}|Files for upload|&lt;/div&gt;}}&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;''Le yingcoco ebulungelweko. &lt;span style=&quot;color:(--color-error, red);&quot;&gt;'''Sibawa ungayitjhugululi.'''&lt;/span&gt; Ukuphawula okutjha kufanele kwenziwe esigabeni esitjha.''&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
| #default = &lt;table class=&quot;mw-collapsible mw-collapsed mw-archivedtalk&quot; style=&quot;width: 100%; border: 0; margin-top: 0.2em; text-align: left;&quot;&gt;
&lt;tr&gt;{{#switch: {{lc:{{{1}}}}}
  | withdrawn
  | w = &lt;th style=&quot;background-color: var(--background-color-notice-subtle, #b8b8b8); color: inherit; text-align: center;&quot;&gt; [[File:Pictogram voting comment.svg|14px|alt=|link=]] This request has been withdrawn
  | partially-accepted
  | p = &lt;th style=&quot;background-color: var(--background-color-warning-subtle, #fff17e); color: inherit; text-align: center;&quot;&gt; [[File:Symbol confirmed.svg|14px|alt=|link=]][[File:Symbol oppose vote.svg|14px|alt=|link=]] This request has been partially accepted
  | unsuccessful
  | us = &lt;th style=&quot;background-color: var(--background-color-error-subtle, #bf8f8f); color: inherit; text-align: center;&quot;&gt; [[File:Symbol delete vote darkened.svg|14px|alt=|link=]] This request was unsuccessful
  | declined
  | d = &lt;th style=&quot;background-color: var(--background-color-error-subtle, #ffcece); color: inherit; text-align: center;&quot;&gt;[[File:Symbol oppose vote.svg|14px|alt=|link=]] Isibawo lesi saliwa
  | mass-accepted
  | ma = &lt;th style=&quot;background-color: var(--background-color-success-subtle, #68ff68); color: inherit; text-align: center;&quot;&gt;[[File:Symbol support vote.svg|14px|alt=|link=]][[File:Symbol support vote.svg|14px|alt=|link=]] These requests have been mass-moderated and accepted, unless otherwise marked
  | mass-declined
  | m
  | md = &lt;th style=&quot;background-color: var(--background-color-error-subtle, #ff9999); color: inherit; text-align: center;&quot;&gt;[[File:Symbol oppose vote.svg|14px|alt=|link=]][[File:Symbol oppose vote.svg|14px|alt=|link=]] These requests have been mass-moderated and declined, unless otherwise marked
  | succeeded
  | s = &lt;th style=&quot;background-color: var(--background-color-success-subtle, #90c090); color: inherit; text-align: center;&quot;&gt;[[File:Symbol confirmed.svg|14px|alt=|link=]] This request has succeeded
  | response
  | r = &lt;th style=&quot;background-color: var(--background-color-error-subtle, #ffcece); color: inherit; text-align: center;&quot;&gt;[[File:Image-Symbol wait old.svg|14px|alt=|link=]] This request has been closed because there was no response
  | accepted
  | a
  | #default = &lt;th style=&quot;background-color: var(--background-color-success-subtle, #a0ffa0); color: inherit; text-align: center;&quot;&gt;[[File:Symbol support vote.svg|14px|alt=|link=]] Isibawo lesi samukelwe
 }}. &lt;span style=&quot;color: var(--color-error, red);&quot;&gt; Sibawa ungayitjhugululi.&lt;/span&gt;&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border: solid 1px; padding: 8px; background-color: var(--background-color-neutral, #e0e0e0); color: var(--color-base, #202122)&quot;&gt;
}}&lt;noinclude&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>fo79ui9j0uxhf9b6roi0w78zji85h1g</sha1>
    </revision>
    <revision>
      <id>6638</id>
      <parentid>6633</parentid>
      <timestamp>2026-05-20T02:32:12Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6638</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3048" sha1="3mynbjduq9r6tdciudta38tgri8xrrb" xml:space="preserve">{{#switch:{{lc:{{{1}}}}}
| bottom
| b        = {{#ifeq:{{ROOTPAGENAME}}|Files for upload|&lt;/div&gt;}}&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;''Le yingcoco ebulungelweko. &lt;span style=&quot;color:(--color-error, red);&quot;&gt;'''Sibawa ungayitjhugululi.'''&lt;/span&gt; Ukuphawula okutjha kufanele kwenziwe esigabeni esitjha.''&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
| #default = &lt;table class=&quot;mw-collapsible mw-collapsed mw-archivedtalk&quot; style=&quot;width: 100%; border: 0; margin-top: 0.2em; text-align: left;&quot;&gt;
&lt;tr&gt;{{#switch: {{lc:{{{1}}}}}
  | withdrawn
  | w = &lt;th style=&quot;background-color: var(--background-color-notice-subtle, #b8b8b8); color: inherit; text-align: center;&quot;&gt; [[File:Pictogram voting comment.svg|14px|alt=|link=]] This request has been withdrawn
  | partially-accepted
  | p = &lt;th style=&quot;background-color: var(--background-color-warning-subtle, #fff17e); color: inherit; text-align: center;&quot;&gt; [[File:Symbol confirmed.svg|14px|alt=|link=]][[File:Symbol oppose vote.svg|14px|alt=|link=]] This request has been partially accepted
  | unsuccessful
  | us = &lt;th style=&quot;background-color: var(--background-color-error-subtle, #bf8f8f); color: inherit; text-align: center;&quot;&gt; [[File:Symbol delete vote darkened.svg|14px|alt=|link=]] This request was unsuccessful
  | declined
  | d = &lt;th style=&quot;background-color: var(--background-color-error-subtle, #ffcece); color: inherit; text-align: center;&quot;&gt;[[File:Symbol oppose vote.svg|14px|alt=|link=]] Isibawo lesi akukenziwa
  | mass-accepted
  | ma = &lt;th style=&quot;background-color: var(--background-color-success-subtle, #68ff68); color: inherit; text-align: center;&quot;&gt;[[File:Symbol support vote.svg|14px|alt=|link=]][[File:Symbol support vote.svg|14px|alt=|link=]] These requests have been mass-moderated and accepted, unless otherwise marked
  | mass-declined
  | m
  | md = &lt;th style=&quot;background-color: var(--background-color-error-subtle, #ff9999); color: inherit; text-align: center;&quot;&gt;[[File:Symbol oppose vote.svg|14px|alt=|link=]][[File:Symbol oppose vote.svg|14px|alt=|link=]] These requests have been mass-moderated and declined, unless otherwise marked
  | succeeded
  | s = &lt;th style=&quot;background-color: var(--background-color-success-subtle, #90c090); color: inherit; text-align: center;&quot;&gt;[[File:Symbol confirmed.svg|14px|alt=|link=]] This request has succeeded
  | response
  | r = &lt;th style=&quot;background-color: var(--background-color-error-subtle, #ffcece); color: inherit; text-align: center;&quot;&gt;[[File:Image-Symbol wait old.svg|14px|alt=|link=]] This request has been closed because there was no response
  | accepted
  | a
  | #default = &lt;th style=&quot;background-color: var(--background-color-success-subtle, #a0ffa0); color: inherit; text-align: center;&quot;&gt;[[File:Symbol support vote.svg|14px|alt=|link=]] Isibawo lesi samukelwe
 }}. &lt;span style=&quot;color: var(--color-error, red);&quot;&gt; Sibawa ungayitjhugululi.&lt;/span&gt;&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border: solid 1px; padding: 8px; background-color: var(--background-color-neutral, #e0e0e0); color: var(--color-base, #202122)&quot;&gt;
}}&lt;noinclude&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>3mynbjduq9r6tdciudta38tgri8xrrb</sha1>
    </revision>
    <revision>
      <id>6639</id>
      <parentid>6638</parentid>
      <timestamp>2026-05-20T02:35:06Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Undid revision [[Special:Diff/6638|6638]] by [[Special:Contributions/NgamangaXhosa|NgamangaXhosa]] ([[User talk:NgamangaXhosa|talk]])</comment>
      <origin>6639</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="3044" sha1="fo79ui9j0uxhf9b6roi0w78zji85h1g" xml:space="preserve">{{#switch:{{lc:{{{1}}}}}
| bottom
| b        = {{#ifeq:{{ROOTPAGENAME}}|Files for upload|&lt;/div&gt;}}&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;''Le yingcoco ebulungelweko. &lt;span style=&quot;color:(--color-error, red);&quot;&gt;'''Sibawa ungayitjhugululi.'''&lt;/span&gt; Ukuphawula okutjha kufanele kwenziwe esigabeni esitjha.''&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
| #default = &lt;table class=&quot;mw-collapsible mw-collapsed mw-archivedtalk&quot; style=&quot;width: 100%; border: 0; margin-top: 0.2em; text-align: left;&quot;&gt;
&lt;tr&gt;{{#switch: {{lc:{{{1}}}}}
  | withdrawn
  | w = &lt;th style=&quot;background-color: var(--background-color-notice-subtle, #b8b8b8); color: inherit; text-align: center;&quot;&gt; [[File:Pictogram voting comment.svg|14px|alt=|link=]] This request has been withdrawn
  | partially-accepted
  | p = &lt;th style=&quot;background-color: var(--background-color-warning-subtle, #fff17e); color: inherit; text-align: center;&quot;&gt; [[File:Symbol confirmed.svg|14px|alt=|link=]][[File:Symbol oppose vote.svg|14px|alt=|link=]] This request has been partially accepted
  | unsuccessful
  | us = &lt;th style=&quot;background-color: var(--background-color-error-subtle, #bf8f8f); color: inherit; text-align: center;&quot;&gt; [[File:Symbol delete vote darkened.svg|14px|alt=|link=]] This request was unsuccessful
  | declined
  | d = &lt;th style=&quot;background-color: var(--background-color-error-subtle, #ffcece); color: inherit; text-align: center;&quot;&gt;[[File:Symbol oppose vote.svg|14px|alt=|link=]] Isibawo lesi saliwa
  | mass-accepted
  | ma = &lt;th style=&quot;background-color: var(--background-color-success-subtle, #68ff68); color: inherit; text-align: center;&quot;&gt;[[File:Symbol support vote.svg|14px|alt=|link=]][[File:Symbol support vote.svg|14px|alt=|link=]] These requests have been mass-moderated and accepted, unless otherwise marked
  | mass-declined
  | m
  | md = &lt;th style=&quot;background-color: var(--background-color-error-subtle, #ff9999); color: inherit; text-align: center;&quot;&gt;[[File:Symbol oppose vote.svg|14px|alt=|link=]][[File:Symbol oppose vote.svg|14px|alt=|link=]] These requests have been mass-moderated and declined, unless otherwise marked
  | succeeded
  | s = &lt;th style=&quot;background-color: var(--background-color-success-subtle, #90c090); color: inherit; text-align: center;&quot;&gt;[[File:Symbol confirmed.svg|14px|alt=|link=]] This request has succeeded
  | response
  | r = &lt;th style=&quot;background-color: var(--background-color-error-subtle, #ffcece); color: inherit; text-align: center;&quot;&gt;[[File:Image-Symbol wait old.svg|14px|alt=|link=]] This request has been closed because there was no response
  | accepted
  | a
  | #default = &lt;th style=&quot;background-color: var(--background-color-success-subtle, #a0ffa0); color: inherit; text-align: center;&quot;&gt;[[File:Symbol support vote.svg|14px|alt=|link=]] Isibawo lesi samukelwe
 }}. &lt;span style=&quot;color: var(--color-error, red);&quot;&gt; Sibawa ungayitjhugululi.&lt;/span&gt;&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style=&quot;border: solid 1px; padding: 8px; background-color: var(--background-color-neutral, #e0e0e0); color: var(--color-base, #202122)&quot;&gt;
}}&lt;noinclude&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>fo79ui9j0uxhf9b6roi0w78zji85h1g</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi asiqongelane:2A04:4A43:88CF:F206:657C:7611:54FA:DF05</title>
    <ns>3</ns>
    <id>1174</id>
    <revision>
      <id>6640</id>
      <timestamp>2026-05-20T02:37:05Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;== Ngibawa ungamotjhisi iWikipedia ==  Nawuragela phambili nokwenza njalo, ungavinjelwa mlawuli. Zoke iintjhuguluko zakho: {{Declined}} kunye {{N/A icon}}. -- ~~~~&quot;</comment>
      <origin>6640</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="285" sha1="edx8p0wrlm459chmur9l6spsegy7eap" xml:space="preserve">== Ngibawa ungamotjhisi iWikipedia ==

Nawuragela phambili nokwenza njalo, ungavinjelwa mlawuli. Zoke iintjhuguluko zakho: {{Declined}} kunye {{N/A icon}}. -- [[Umsebenzisi:NgamangaXhosa|NgamangaXhosa]] ([[Umsebenzisi asiqongelane:NgamangaXhosa|talk]]) 04:37, 20 Nkwenkwezi 2026 (SAST)</text>
      <sha1>edx8p0wrlm459chmur9l6spsegy7eap</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi asiqongelane:Codename Noreste</title>
    <ns>3</ns>
    <id>1175</id>
    <revision>
      <id>6641</id>
      <timestamp>2026-05-20T02:38:06Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;{{Not around}}&quot;</comment>
      <origin>6641</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="14" sha1="nhmxey8t2nsr7vh81fp6rh6187z5679" xml:space="preserve">{{Not around}}</text>
      <sha1>nhmxey8t2nsr7vh81fp6rh6187z5679</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Archive request</title>
    <ns>10</ns>
    <id>1176</id>
    <revision>
      <id>6642</id>
      <timestamp>2026-05-20T04:20:42Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;{{Tmbox  |type  = notice  |style = {{SAFESUBST:&lt;noinclude /&gt;#ifexpr:{{{pagesize|{{SAFESUBST:&lt;noinclude /&gt;PAGESIZE:{{SAFESUBST:&lt;noinclude /&gt;FULLPAGENAME}}|R}}}}} &gt;  524288|background-color: #FDD}}  |image = [[File:Historical.svg|25px|link=|alt=]]  |imageright = [[File:Filing cabinet icon.svg|35px|alt=icon]]  |text  = Asiqongelane liya ngokuya '''lide'''. Cabanga ngokugcina iingcoco ezingasebenziko.{{SAFESUBST:&lt;noinclude /&gt;#if:{{{date|}}}|&lt;i style=&quot;font-size: smaller;&quot;&gt; Re...&quot;</comment>
      <origin>6642</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="799" sha1="f1qdc2crqd9ibvjet8w650pz8cryidc" xml:space="preserve">{{Tmbox
 |type  = notice
 |style = {{SAFESUBST:&lt;noinclude /&gt;#ifexpr:{{{pagesize|{{SAFESUBST:&lt;noinclude /&gt;PAGESIZE:{{SAFESUBST:&lt;noinclude /&gt;FULLPAGENAME}}|R}}}}} &gt;  524288|background-color: #FDD}}
 |image = [[File:Historical.svg|25px|link=|alt=]]
 |imageright = [[File:Filing cabinet icon.svg|35px|alt=icon]]
 |text  = Asiqongelane liya ngokuya '''lide'''. Cabanga ngokugcina iingcoco ezingasebenziko.{{SAFESUBST:&lt;noinclude /&gt;#if:{{{date|}}}|&lt;i style=&quot;font-size: smaller;&quot;&gt; Requested; {{{date}}}.&lt;/i&gt;}}
}}&lt;includeonly&gt;{{#ifeq:{{Yesno|{{{cat|yes}}}}}|yes|{{User talk other||{{talk other|[[Category:Archive requests|{{#expr:(1000-({{{pagesize|{{SAFESUBST:&lt;noinclude /&gt;PAGESIZE:{{SAFESUBST:&lt;noinclude /&gt;FULLPAGENAME}}|R}}}}}/1024))round0}}]]}}}}}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{Documentation}}
&lt;/noinclude&gt;</text>
      <sha1>f1qdc2crqd9ibvjet8w650pz8cryidc</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Archive</title>
    <ns>828</ns>
    <id>1177</id>
    <revision>
      <id>6643</id>
      <timestamp>2026-05-20T04:23:14Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;------------------------------------------------------------------------------- --                       Automatic archive navigator -- -- This module produces a talk archive banner, together with an automatically- -- generated list of navigation links to other archives of the talk page in -- question. It implements {{Archive}}. -------------------------------------------------------------------------------  local yesno = require('Module:Yesno')  ------------------------...&quot;</comment>
      <origin>6643</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="15036" sha1="giscie0tlv3d0yas5kiuygtkpuhyt3x" xml:space="preserve">-------------------------------------------------------------------------------
--                       Automatic archive navigator
--
-- This module produces a talk archive banner, together with an automatically-
-- generated list of navigation links to other archives of the talk page in
-- question. It implements {{Archive}}.
-------------------------------------------------------------------------------

local yesno = require('Module:Yesno')

-------------------------------------------------------------------------------
-- Helper functions
-------------------------------------------------------------------------------

local function makeWikilink(page, display)
	if display then
		return string.format('[[%s|%s]]', page, display)
	else
		return string.format('[[%s]]', page)
	end
end

local function escapePattern(s)
	-- Escape punctuation in a string so it can be used in a Lua pattern.
	s = s:gsub('%p', '%%%0')
	return s
end

local function makeTable(width)
	local archiveTable = mw.html.create('table')
	archiveTable
		:css({
			['max-width'] = width,
			['margin'] = '0 auto 0.5em',
			['text-align'] = 'center'
		})
		-- Set width so that the table doesn't spill out on narrower skins
		-- or when zooming in. It has to be defined multiple times because 
		-- &quot;stretch&quot; is experimental.
		:cssText('width:100%;width:-moz-available;width:-webkit-fill-available;width:stretch')
	return archiveTable
end

-- Check to see if the page is likely an annual archive. No talk pages exist 
-- before 2001. Some pages have the next year created in advance.
local function isYearlyArchive(num)
    local currentYear = tonumber(os.date(&quot;%Y&quot;))
    return num and num &gt;= 2001 and num &lt;= currentYear + 1 -- possible years
end
local function detectArchiveFormat(title, args)
	-- Check if next/previous are set. Some archives swap between annual and 
	-- sequential archives at some point and will need to accept whatever an
	-- editor says the next/previous link should be for these kind of weird 
	-- or unsual orders.
    if args and (args.prev or args.next) then
        return nil, nil, nil
    end
    
    -- Check if &quot;/Archive 2&quot; exists to prevent false positives on noticeboards
    local archiveBase = title.baseText
    local archive2Title = mw.title.new(archiveBase .. &quot;/Archive 2&quot;)
    if archive2Title and archive2Title.exists then
        return nil, nil, nil -- Exit early for sequential archives
    end

    -- How is the year formatted?
    local patterns = {
        {pattern = &quot;^(.-)/Archive (%d+)$&quot;, prefix = nil}, -- &quot;Talk:Base page/Archive YYYY&quot;
        -- &quot;nil&quot; triggers the default. There is some kind of quirk with how
        -- the module give spaces that Template:Yearly archive list cannot
        -- read with either a space or the HTML space entity
        {pattern = &quot;^(.-)/Archive(%d+)$&quot;, prefix = &quot;/Archive&quot;}, -- &quot;Talk:Base page/ArchiveYYYY&quot;
        {pattern = &quot;^(.-)/Archive/(%d+)$&quot;, prefix = &quot;/Archive/&quot;}, -- &quot;Talk:Base page/Archive/YYYY&quot;
        {pattern = &quot;^(.-)/Archives/(%d+)$&quot;, prefix = &quot;/Archives/&quot;}, -- &quot;Talk:Base page/Archives/YYYY&quot;
        {pattern = &quot;^(.-)/(%d+)$&quot;, prefix = &quot;/&quot;} -- &quot;Talk:Base page/YYYY&quot;
    }

    for _, p in ipairs(patterns) do
        local basePage, archiveNum = title.prefixedText:match(p.pattern)
        archiveNum = tonumber(archiveNum)
        if basePage and isYearlyArchive(archiveNum) then
            return basePage, true, p.prefix
        end
    end
    return nil, nil, nil
end



-------------------------------------------------------------------------------
-- Navigator class
-------------------------------------------------------------------------------

local Navigator = {}
Navigator.__index = Navigator

function Navigator.new(args, cfg, currentTitle)
	local obj = setmetatable({}, Navigator)
	
	-- Set inputs
	obj.args = args
	obj.cfg = cfg
	obj.currentTitle = currentTitle

	-- Archive prefix
	-- Decode HTML entities so users can enter things like &quot;Archive&amp;#32;&quot; from
	-- wikitext.
	obj.archivePrefix = obj.args.prefix or obj:message('archive-prefix')
	obj.archivePrefix = mw.text.decode(obj.archivePrefix)

	-- Current archive number
	do
		local pattern = string.format(
			'^%s([1-9][0-9]*)$',
			escapePattern(obj.archivePrefix)
		)
		obj.currentArchiveNum = obj.currentTitle.subpageText:match(pattern)
		obj.currentArchiveNum = tonumber(obj.currentArchiveNum)
	end
	
	-- Highest archive number
	obj.highestArchiveNum = require('Module:Highest archive number')._main(
		 obj.currentTitle.nsText ..
		 	':' .. 
			obj.currentTitle.baseText .. 
			'/' .. 
			obj.archivePrefix,
		obj.currentArchiveNum
	)

	return obj
end

function Navigator:message(key, ...)
	local msg = self.cfg[key]
	if select('#', ...) &gt; 0 then
		return mw.message.newRawMessage(msg, ...):plain()
	else
		return msg
	end
end

function Navigator:getNamespacePreposition()
	-- Most talk archives are about a subject. Some will be &quot;with&quot; an editor
	-- or &quot;on&quot; a noticeboard.
	-- Function to get the namespace preposition
		
	-- Namespace number where transcluded
	local namespaceNumber = mw.title.getCurrentTitle().namespace
	-- Preposition from table to make it easy for wikis to translate or ignore
	local namespacePrepositionTable = self.cfg['namespace-prepositions']

	-- Default preposition if not exception from above
    return namespacePrepositionTable[namespaceNumber] or self.cfg[&quot;preposition-default&quot;]
end

function Navigator:makeBlurb()
	local args = self.args
	local current = self.currentTitle
	local ret
	
	-- Skip if user provides their own blurb.
	if args.text then
		ret = args.text
	else
		-- Set parent talk page.
		local parentTalkPage = current.basePageTitle
		local talkPageTitle
		local pageUnderDiscussion
		
		-- If the parent talk page exists (and it's not the root talk page)
		-- we should link to it in both the &quot;main talk page&quot; and 
		-- &quot;discussions about&quot; parts of the blurb. 
		if args.prefix or (parentTalkPage.exists and parentTalkPage.isRedirect == false and current.baseText ~= current.rootText) then
			talkPageTitle = parentTalkPage.fullText
			pageUnderDiscussion = talkPageTitle
		-- If it doesn't, set &quot;main talk page&quot; to the root talk page
		-- and &quot;discussions about&quot; to the root subject.
		else
			talkPageTitle = current.nsText .. ':' .. parentTalkPage.rootText
			-- Set page under discussion.
			pageUnderDiscussion = current.subjectNsText .. ':' .. current.rootText
			
			-- Prepend colon for non-mainspace pages.
			if current.subjectNsText ~= '' then
				pageUnderDiscussion = ':' .. pageUnderDiscussion 
			end
		end
		
		-- Check current namespace for blurb.
		local namespace = 'main'
		if current.isTalkPage == true then
			namespace = 'talk'
		end
		
		-- What kind of blurb to use in the message box?
		local function getBlurbKey(args)
    		if args.type == 'index' then
    			-- For manually-indexed archives only
        		return 'blurb-index', args.type
        	elseif args.type == 'annual' then
			-- Grab the year of the current archive.
				return 'blurb-annual', mw.getCurrentFrame():expandTemplate {
					title = 'Title year', args = { page = current.fullText }
				}
    		elseif args.period then
        		return 'blurb-period', args.period
    		else
        		return 'blurb-noperiod', ''
    		end
		end

		-- Generate a blurb from Module:Archive/config
		local blurbKey, argValue = getBlurbKey(args)
		local namespacePreposition = self:getNamespacePreposition()
		ret = self:message(blurbKey, talkPageTitle, pageUnderDiscussion, argValue, namespace, namespacePreposition)

	end
	return ret
end

function Navigator:makeMessageBox()
	local args = self.args
	local image
	if args.image then
		image = args.image
	else
		local icon = args.icon or self:message('default-icon')
		image = string.format(
			'[[File:%s|%s|alt=|link=]]',
			icon,
			self:message('image-size')
		)
	end

	-- Hardcode tmbox style on the template's page.
	-- PS: Needs to be changed if the template is renamed!
	local mainTemplatePage = ''
	if self.currentTitle.fullText == 'Template:Archive' then
		mainTemplatePage = 'talk'
	end
	
	local mbox = require('Module:Message box').main('mbox', {
		demospace = args.demospace or mainTemplatePage,
		image = image,
		imageright = args.imageright,
		style = args.style or '',
		textstyle = args.textstyle or 'text-align:center',
		text = self:makeBlurb(),
	})

	return mbox
end

function Navigator:getArchiveNums()
	-- Returns an array of the archive numbers to format.
	local noLinks = tonumber(self.args.links) or self:message('default-link-count')
	noLinks = math.floor(noLinks)
	-- If |noredlinks is &quot;yes&quot;, true or absent, don't allow red links. If it is 
	-- 'no' or false, allow red links.
	local allowRedLinks = yesno(self.args.noredlinks) == false
	
	local current = self.currentArchiveNum
	local highest = self.highestArchiveNum

	if not current or not highest or noLinks &lt; 1 then
		return {}
	elseif noLinks == 1 then
		return {current}
	end

	local function getNum(i, current)
		-- Gets an archive number given i, the position in the array away from
		-- the current archive, and the current archive number. The first two
		-- offsets are consecutive; the third offset is rounded up to the
		-- nearest 5; and the fourth and subsequent offsets are rounded up to
		-- the nearest 10. The offsets are calculated in such a way that archive
		-- numbers will not be duplicated.
		if -2 &lt;= i and i &lt;= 2 then
			return current + i
		elseif -3 &lt;= i and i &lt;= 3 then
			return current + 2 - (current + 2) % 5 + (i / 3) * 5
		elseif 4 &lt;= i then
			return current + 7 - (current + 7) % 10 + (i - 3) * 10
		else
			return current + 2 - (current + 2) % 10 + (i + 3) * 10
		end
	end

	local nums = {}

	-- Archive nums lower than the current page.
	for i = -1, -math.floor((noLinks - 1) / 2), -1 do
		local num = getNum(i, current)
		if num &lt;= 1 then
			table.insert(nums, 1, 1)
			break
		else
			table.insert(nums, 1, num)
		end
	end

	-- Current page.
	if nums[#nums] &lt; current then
		table.insert(nums, current)
	end

	-- Higher archive nums.
	for i = 1, math.ceil((noLinks - 1) / 2) do
		local num = getNum(i, current)
		if num &lt;= highest then
			table.insert(nums, num)
		elseif allowRedLinks and (i &lt;= 2 or i &lt;= 3 and num == nums[#nums] + 1) then
			-- Only insert one red link, and only if it is consecutive.
			table.insert(nums, highest + 1)
			break
		elseif nums[#nums] &lt; highest then
			-- Insert the highest archive number if it isn't already there.
			table.insert(nums, highest)
			break
		else
			break
		end
	end

	return nums
end

function Navigator:makeArchiveLinksWikitable()
	local args = self.args
	local lang = mw.language.getContentLanguage()
	local nums = self:getArchiveNums()
	local noLinks = #nums
	
	-- Skip number processing if |prev and |next are defined.
	if args.prev or args.next then
		local archives = {}
		if args.prev then archives[#archives + 1] = mw.title.new(args.prev) end
		archives[#archives + 1] = self.currentTitle
		if args.next then archives[#archives + 1] = mw.title.new(args.next) end
		
		local table = makeTable('30em')
		for _, title in ipairs(archives) do
			if tostring(title) == self.currentTitle.prefixedText then
				table:tag(&quot;td&quot;):wikitext(string.format(
					'&lt;span style=&quot;font-size:115%%;&quot;&gt;%s&lt;/span&gt;',
					makeWikilink(title.fullText, title.subpageText)
				))
			else
				table:tag(&quot;td&quot;):wikitext(
					makeWikilink(title.fullText, title.subpageText)
				)
			end
		end
		return tostring(table)
	end
	if noLinks &lt; 1 then
		return ''
	end

	-- Make the table of links.
	local links = {}
	local isCompact = noLinks &gt; 7
	local currentIndex
	for i, num in ipairs(nums) do
		local subpage = self.archivePrefix .. tostring(num)
		local display
		if isCompact then
			display = tostring(num)
		else
			display = self:message('archive-link-display', num)
		end
		local link = makeWikilink('../' .. subpage, display)
		if num == self.currentArchiveNum then
			link = string.format('&lt;span style=&quot;font-size:115%%;&quot;&gt;%s&lt;/span&gt;', link)
			currentIndex = i
		end
		table.insert(links, link)
	end

	-- Add the arrows.
	-- We must do the forwards arrow first as we are adding elements to the
	-- links table. If we did the backwards arrow first the index for the
	-- current archive would be wrong.
	currentIndex = currentIndex or math.ceil(#links / 2)
	for i = currentIndex + 1, #links do
		if nums[i] - nums[i - 1] &gt; 1 then
			table.insert(links, i, lang:getArrow('forwards'))
			break
		end
	end
	for i = currentIndex - 1, 1, -1 do
		if nums[i + 1] - nums[i] &gt; 1 then
			table.insert(links, i + 1, lang:getArrow('backwards'))
			break
		end
	end

	-- Output the wikitable.
	local width
	if noLinks &lt;= 3 then
		width = string.format('%dem', noLinks * 10)
	elseif noLinks &lt;= 7 then
		width = string.format('%dem', (noLinks + 3) * 5)
	else
		width = '37em'
	end
	local table = makeTable(width)
	for _, s in ipairs(links) do
		table:tag(&quot;td&quot;):wikitext(s)
	end
	
	return tostring(table)
end

function Navigator:__tostring()
	local args = self.args
	local boxComponents
	
-- Is |omit filled? If not, make the whole box.
	if args.omit == nil then

-- Check for annual archives
	local currentTitle = self.currentTitle
	local yearlyBase, isYearly, yearlyPattern = detectArchiveFormat(currentTitle, args)

	if isYearly then
    	-- Use a yearly archive format
    	local linksYearlyListSeparator = &quot;&amp;#32;&quot; -- Space separator
    	local linksYearlyList = mw.getCurrentFrame():expandTemplate {
    	    title = 'Yearly archive list',
        	args = { 
        		root = yearlyBase, 
        		sep = linksYearlyListSeparator,
        		prefix = yearlyPattern
        	}
    	}
    	boxComponents = self:makeMessageBox() .. '\n' ..
        '&lt;div style=&quot;font-size:115%; width:100%; word-spacing:1em; text-align:center;&quot;&gt;' .. linksYearlyList .. '&lt;/div&gt;'
	else
    	-- Default numbered archive format
    	boxComponents = self:makeMessageBox() .. '\n' .. self:makeArchiveLinksWikitable()
	end	-- We're omitting the banner, so we should only make the links table.
	elseif args.omit == 'banner' then 
		boxComponents = self:makeArchiveLinksWikitable()
	-- We're omitting the archives, so we should only make the banner.
    elseif args.omit == 'archives' then
        boxComponents = self:makeMessageBox()
	end

	-- Allow for demo pages to be edited freely. 
	if not args.demospace then
		boxComponents = boxComponents .. ' __NONEWSECTIONLINK__ __NOEDITSECTION__ __ARCHIVEDTALK__'
	end

	return boxComponents
end

-------------------------------------------------------------------------------
-- Exports
-------------------------------------------------------------------------------

local p = {}

function p._exportClasses()
	return {
		Navigator = Navigator
	}
end

function p._aan(args, cfg, currentTitle)
	cfg = cfg or mw.loadData('Module:Archive/config')
	currentTitle = currentTitle or mw.title.getCurrentTitle()
	local aan = Navigator.new(args, cfg, currentTitle)
	return tostring(aan)
end

function p.aan(frame)
	local args = require('Module:Arguments').getArgs(frame, {
		wrappers = 'Template:Archive',
	})
	return p._aan(args)
end

return p</text>
      <sha1>giscie0tlv3d0yas5kiuygtkpuhyt3x</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Archive/config</title>
    <ns>828</ns>
    <id>1178</id>
    <revision>
      <id>6644</id>
      <timestamp>2026-05-20T04:24:54Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;-------------------------------------------------------------------------------- --             Configuration for Module:Automatic archive navigator -- -- This module contains configuration data for -- [[Module:Automatic archive navigator]]. It can be used to easily translate the -- module for use on other wikis, as well as changing settings like the default -- archive prefix and the default link count. --------------------------------------------------------------------...&quot;</comment>
      <origin>6644</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="4105" sha1="rx1cmanyjwz4ps0436v6syuydeni7ym" xml:space="preserve">--------------------------------------------------------------------------------
--             Configuration for Module:Automatic archive navigator
--
-- This module contains configuration data for
-- [[Module:Automatic archive navigator]]. It can be used to easily translate the
-- module for use on other wikis, as well as changing settings like the default
-- archive prefix and the default link count.
--------------------------------------------------------------------------------

return {

--------------------------------------------------------------------------------
-- Blurb
--------------------------------------------------------------------------------

-- The blurbs to use for the archive banner. If the &quot;period&quot; argument is
-- specified, the &quot;blurb-period&quot; message is used; otherwise the &quot;blurb-noperiod&quot;
-- message is used.
-- $1 - the full page name of the current talk page (assumed to be the base
--      page of the archive pages.
-- $2 - the page under discussion (i.e. &quot;Space&quot; for &quot;Talk:Space/Archive 1&quot;)
-- $3 - the value of the &quot;period&quot; argument.
-- $4 - the namespace of the current page.
-- $5 - this preposition changes depending on the namespace &quot;about&quot; by default
--      or &quot;with&quot; for user talk pages
['blurb-period'] = &quot;This is an '''[[Help:Archiving a talk page|archive]]''' &quot; ..
	&quot;of past discussions $5 [[$2]], '''for the period $3'''.&lt;br /&gt;'''Do not edit the &quot; ..
	&quot;contents of this page.''' If you wish to start a new discussion or &quot; ..
	&quot;revive an old one, please do so on the [[$1|current $4 page]].&quot;,
['blurb-index'] = &quot;This is an index of '''[[Help:Archiving a talk page|archived]]''' &quot; ..
	&quot;past discussions $5 [[$2]]. '''Do not edit the contents of this page.''' If &quot; ..
	&quot;you wish to start a new discussion or revive an old one, please do so &quot; ..
	&quot;on the [[$1|current $4 page]].&quot;,
['blurb-annual'] = &quot;'''Do not edit this page.''' This is the &quot; .. 
	&quot;[[Help:Archiving_a_talk_page|archive]] of past discussions $5 [[$2]], &quot; .. 
	&quot;for the year $3. (Please direct any additional comments to the &quot; ..
	&quot;[[$1|current $4 page]]) See the annual archives listed below:&quot;,
['blurb-noperiod'] = &quot;This is an '''[[Help:Archiving a talk page|archive]]''' &quot; ..
	&quot;of past discussions $5 [[$2]]. '''Do not edit the contents of this page.''' If &quot; ..
	&quot;you wish to start a new discussion or revive an old one, please do so &quot; ..
	&quot;on the [[$1|current $4 page]].&quot;,
	
--------------------------------------------------------------------------------
-- Prepositions
--------------------------------------------------------------------------------
-- Used in blurbs above. These change depending on namespace.
-- Depending on the blurb format in other languages, these can be translated
-- or ignored.
['namespace-prepositions'] = {
        [2] = &quot;with&quot;,    -- User
        [3] = &quot;with&quot;,    -- User talk
        [4] = &quot;on&quot;,      -- Wikipedia
        [12] = &quot;on&quot;,     -- Help
    },
['preposition-default'] = &quot;about&quot;,


--------------------------------------------------------------------------------
-- Image
--------------------------------------------------------------------------------

-- The default icon for the archive banner.
['default-icon'] = 'Replacement filing cabinet.svg',

-- The image size, unless a custom image is specified with the &quot;image&quot;
-- parameter.
['image-size'] = '40x40px',

--------------------------------------------------------------------------------
-- Archive links
--------------------------------------------------------------------------------

-- The default prefix for archive pages on this wiki. This is the subpage text
-- minus the archive number itself. So if the full page name of a typical
-- archive was &quot;Talk:France/Archive 12&quot;, the prefix would be &quot;Archive &quot;. This
-- message is used to detect whether the current page is an archive page.
['archive-prefix'] = 'Archive ',

-- The display value to use for long archive links. These are used if seven or
-- less links are output.
-- $1 - The archive number.
['archive-link-display'] = 'Archive&amp;nbsp;$1',

-- The default number of archive links to output.
['default-link-count'] = 7

}</text>
      <sha1>rx1cmanyjwz4ps0436v6syuydeni7ym</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Highest archive number</title>
    <ns>828</ns>
    <id>1179</id>
    <revision>
      <id>6645</id>
      <timestamp>2026-05-20T04:25:24Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;-- This module finds the highest existing archive number for a set of talk -- archive pages.  local expSearch = require('Module:Exponential search') local p = {}  local function raiseStartNumberError(start) 	error(string.format( 		'Invalid start number &quot;%s&quot; supplied to [[Module:Highest archive number]] (must be an integer)', 		tostring(start) 	), 3) end  local function pageExists(page) 	local success, exists = pcall(function() 		return mw.title.new(page).exists 	end) 	re...&quot;</comment>
      <origin>6645</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="1772" sha1="h3czqly5m6n03xkq0oyziwlta1lovvd" xml:space="preserve">-- This module finds the highest existing archive number for a set of talk
-- archive pages.

local expSearch = require('Module:Exponential search')
local p = {}

local function raiseStartNumberError(start)
	error(string.format(
		'Invalid start number &quot;%s&quot; supplied to [[Module:Highest archive number]] (must be an integer)',
		tostring(start)
	), 3)
end

local function pageExists(page)
	local success, exists = pcall(function()
		return mw.title.new(page).exists
	end)
	return success and exists
end

function p._main(prefix, start)
	-- Check our inputs
	if type(prefix) ~= 'string' or not prefix:find('%S') then
		error('No prefix supplied to [[Module:Highest archive number]]', 2)
	end
	if start ~= nil and (type(start) ~= &quot;number&quot; or math.floor(start) ~= start) then
		raiseStartNumberError(start)
	end
	start = start or 1
	
	-- Do an exponential search for the highest archive number
	local result = expSearch(function (i)
		local archiveNumber = i + start - 1
		local page = prefix .. tostring(archiveNumber)
		return pageExists(page)
	end, 10)
	
	if result == nil then
		-- We didn't find any archives for our prefix + start number
		return nil
	else
		-- We found the highest archive, but the number is always 1-based, so
		-- adjust it for our start number
		return result + start - 1
	end
end

function p.main(frame)
	local args = require('Module:Arguments').getArgs(frame, {
		trim = false,
		removeBlanks = false,
		wrappers = 'Template:Highest archive number'
	})
	local prefix = args[1]
	
	-- Get the start archive number, if specified.
	local start = args.start
	if start == &quot;&quot; then
		start = nil
	elseif start then
		start = tonumber(start)
		if not start then
			raiseStartNumberError(args.start)
		end
	end

	return p._main(prefix, start)
end

return p</text>
      <sha1>h3czqly5m6n03xkq0oyziwlta1lovvd</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Exponential search</title>
    <ns>828</ns>
    <id>1180</id>
    <revision>
      <id>6646</id>
      <timestamp>2026-05-20T04:27:00Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;-- This module provides a generic exponential search algorithm. require[[strict]]  local checkType = require('libraryUtil').checkType local floor = math.floor  local function midPoint(lower, upper) 	return floor(lower + (upper - lower) / 2) end  local function search(testFunc, i, lower, upper) 	if testFunc(i) then 		if i + 1 == upper then 			return i 		end 		lower = i 		if upper then 			i = midPoint(lower, upper) 		else 			i = i * 2 		end 		return search(testFunc, i, low...&quot;</comment>
      <origin>6646</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="1092" sha1="jqqi8l27tb73lglksbukg2g3bzt3fmv" xml:space="preserve">-- This module provides a generic exponential search algorithm.
require[[strict]]

local checkType = require('libraryUtil').checkType
local floor = math.floor

local function midPoint(lower, upper)
	return floor(lower + (upper - lower) / 2)
end

local function search(testFunc, i, lower, upper)
	if testFunc(i) then
		if i + 1 == upper then
			return i
		end
		lower = i
		if upper then
			i = midPoint(lower, upper)
		else
			i = i * 2
		end
		return search(testFunc, i, lower, upper)
	else
		upper = i
		i = midPoint(lower, upper)
		return search(testFunc, i, lower, upper)
	end
end

return function (testFunc, init)
	checkType('Exponential search', 1, testFunc, 'function')
	checkType('Exponential search', 2, init, 'number', true)
	if init and (init &lt; 1 or init ~= floor(init) or init == math.huge) then
		error(string.format(
			&quot;invalid init value '%s' detected in argument #2 to &quot; ..
			&quot;'Exponential search' (init value must be a positive integer)&quot;,
			tostring(init)
		), 2)
	end
	init = init or 2
	if not testFunc(1) then
		return nil
	end
	return search(testFunc, init, 1, nil)
end</text>
      <sha1>jqqi8l27tb73lglksbukg2g3bzt3fmv</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Archive</title>
    <ns>10</ns>
    <id>1181</id>
    <revision>
      <id>6647</id>
      <timestamp>2026-05-20T04:27:29Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;{{#invoke:Archive|aan|start={{{start|}}}}}&lt;includeonly&gt;{{#ifeq:{{{Redirect category|}}}|no||{{#if:{{is redirect|{{FULLBASEPAGENAME}}|talk=yes}}{{is redirect|{{#invoke:String|replace|{{FULLPAGENAME}}|/Archive.*||plain=false}}|talk=yes}} |[[Category:Archive pages whose parent page is a redirect]] |}}}}{{editnotice EXPECTUNUSEDTEMPLATE}}&lt;/includeonly&gt;&lt;noinclude&gt; {{documentation}} &lt;!-- Categories go on the /doc subpage and interwikis go on Wikidata. --&gt; &lt;/noinclude&gt;&quot;</comment>
      <origin>6647</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="466" sha1="359u08irmpwlhmvq3vq1m67ltg9qkum" xml:space="preserve">{{#invoke:Archive|aan|start={{{start|}}}}}&lt;includeonly&gt;{{#ifeq:{{{Redirect category|}}}|no||{{#if:{{is redirect|{{FULLBASEPAGENAME}}|talk=yes}}{{is redirect|{{#invoke:String|replace|{{FULLPAGENAME}}|/Archive.*||plain=false}}|talk=yes}} |[[Category:Archive pages whose parent page is a redirect]] |}}}}{{editnotice EXPECTUNUSEDTEMPLATE}}&lt;/includeonly&gt;&lt;noinclude&gt;
{{documentation}}
&lt;!-- Categories go on the /doc subpage and interwikis go on Wikidata. --&gt;
&lt;/noinclude&gt;</text>
      <sha1>359u08irmpwlhmvq3vq1m67ltg9qkum</sha1>
    </revision>
  </page>
  <page>
    <title>Wikiphidiya:Iimbawo zokuqondisa kabutjha/Archive 1</title>
    <ns>4</ns>
    <id>1182</id>
    <revision>
      <id>6650</id>
      <timestamp>2026-05-20T04:38:18Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;{{Archive}}  ----  == Redirect request: [[IsiNdebele]] == {{AfC-c|a}} *Target of redirect: [[Isindebele]]  *Reason: Amaledere amakhulu, madoda.  *Source (if applicable): ...  [[Umsebenzisi:ThatEquatorialGuineaEditor (alt)|ThatEquatorialGuineaEditor (alt)]] ([[Umsebenzisi asiqongelane:ThatEquatorialGuineaEditor (alt)|talk]]) 07:46, 19 Nkwenkwezi 2026 (SAST)  :{{Done}}. Ngiyathokoza ngokusiza iWikiphidiya! [[Umsebenzisi:NgamangaXhosa|NgamangaXhosa]] (Umsebenzisi asiqonge...&quot;</comment>
      <origin>6650</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1113" sha1="90csmvinkhlp181v0kqtpxoyo9jflga" xml:space="preserve">{{Archive}}

----

== Redirect request: [[IsiNdebele]] ==
{{AfC-c|a}}
*Target of redirect: [[Isindebele]]

*Reason: Amaledere amakhulu, madoda.

*Source (if applicable): ...

[[Umsebenzisi:ThatEquatorialGuineaEditor (alt)|ThatEquatorialGuineaEditor (alt)]] ([[Umsebenzisi asiqongelane:ThatEquatorialGuineaEditor (alt)|talk]]) 07:46, 19 Nkwenkwezi 2026 (SAST)

:{{Done}}. Ngiyathokoza ngokusiza iWikiphidiya! [[Umsebenzisi:NgamangaXhosa|NgamangaXhosa]] ([[Umsebenzisi asiqongelane:NgamangaXhosa|talk]]) 07:48, 19 Nkwenkwezi 2026 (SAST)
{{AfC-c|b}}

== Redirect request: [[IsiNdebele seSewula]] ==
{{AfC-c|d}}
*Target of redirect: [[Isindebele]]

*Reason: Sebenzisa ibizo elifaneleko ;)

*Source (if applicable): ...

[[Umsebenzisi:ThatEquatorialGuineaEditor (alt)|ThatEquatorialGuineaEditor (alt)]] ([[Umsebenzisi asiqongelane:ThatEquatorialGuineaEditor (alt)|talk]]) 04:19, 20 Nkwenkwezi 2026 (SAST)

:{{Declined}}. Umtlolo lo uzokuthuthelwa esikhaleni esiceliweko msinyana. [[Umsebenzisi:NgamangaXhosa|NgamangaXhosa]] ([[Umsebenzisi asiqongelane:NgamangaXhosa|talk]]) 04:24, 20 Nkwenkwezi 2026 (SAST)
{{AfC-c|b}}</text>
      <sha1>90csmvinkhlp181v0kqtpxoyo9jflga</sha1>
    </revision>
    <revision>
      <id>6651</id>
      <parentid>6650</parentid>
      <timestamp>2026-05-20T04:38:30Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6651</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1107" sha1="5cvrx4tzcvjvuhp0fh4mgxtre5p520g" xml:space="preserve">{{Archive}}

== Redirect request: [[IsiNdebele]] ==
{{AfC-c|a}}
*Target of redirect: [[Isindebele]]

*Reason: Amaledere amakhulu, madoda.

*Source (if applicable): ...

[[Umsebenzisi:ThatEquatorialGuineaEditor (alt)|ThatEquatorialGuineaEditor (alt)]] ([[Umsebenzisi asiqongelane:ThatEquatorialGuineaEditor (alt)|talk]]) 07:46, 19 Nkwenkwezi 2026 (SAST)

:{{Done}}. Ngiyathokoza ngokusiza iWikiphidiya! [[Umsebenzisi:NgamangaXhosa|NgamangaXhosa]] ([[Umsebenzisi asiqongelane:NgamangaXhosa|talk]]) 07:48, 19 Nkwenkwezi 2026 (SAST)
{{AfC-c|b}}

== Redirect request: [[IsiNdebele seSewula]] ==
{{AfC-c|d}}
*Target of redirect: [[Isindebele]]

*Reason: Sebenzisa ibizo elifaneleko ;)

*Source (if applicable): ...

[[Umsebenzisi:ThatEquatorialGuineaEditor (alt)|ThatEquatorialGuineaEditor (alt)]] ([[Umsebenzisi asiqongelane:ThatEquatorialGuineaEditor (alt)|talk]]) 04:19, 20 Nkwenkwezi 2026 (SAST)

:{{Declined}}. Umtlolo lo uzokuthuthelwa esikhaleni esiceliweko msinyana. [[Umsebenzisi:NgamangaXhosa|NgamangaXhosa]] ([[Umsebenzisi asiqongelane:NgamangaXhosa|talk]]) 04:24, 20 Nkwenkwezi 2026 (SAST)
{{AfC-c|b}}</text>
      <sha1>5cvrx4tzcvjvuhp0fh4mgxtre5p520g</sha1>
    </revision>
    <revision>
      <id>6653</id>
      <parentid>6651</parentid>
      <timestamp>2026-05-20T04:40:46Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6653</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1115" sha1="quv2t4aql32iu3jete8wxc794qn6m0l" xml:space="preserve">{{Archive}}
__TOC__

== Redirect request: [[IsiNdebele]] ==
{{AfC-c|a}}
*Target of redirect: [[Isindebele]]

*Reason: Amaledere amakhulu, madoda.

*Source (if applicable): ...

[[Umsebenzisi:ThatEquatorialGuineaEditor (alt)|ThatEquatorialGuineaEditor (alt)]] ([[Umsebenzisi asiqongelane:ThatEquatorialGuineaEditor (alt)|talk]]) 07:46, 19 Nkwenkwezi 2026 (SAST)

:{{Done}}. Ngiyathokoza ngokusiza iWikiphidiya! [[Umsebenzisi:NgamangaXhosa|NgamangaXhosa]] ([[Umsebenzisi asiqongelane:NgamangaXhosa|talk]]) 07:48, 19 Nkwenkwezi 2026 (SAST)
{{AfC-c|b}}

== Redirect request: [[IsiNdebele seSewula]] ==
{{AfC-c|d}}
*Target of redirect: [[Isindebele]]

*Reason: Sebenzisa ibizo elifaneleko ;)

*Source (if applicable): ...

[[Umsebenzisi:ThatEquatorialGuineaEditor (alt)|ThatEquatorialGuineaEditor (alt)]] ([[Umsebenzisi asiqongelane:ThatEquatorialGuineaEditor (alt)|talk]]) 04:19, 20 Nkwenkwezi 2026 (SAST)

:{{Declined}}. Umtlolo lo uzokuthuthelwa esikhaleni esiceliweko msinyana. [[Umsebenzisi:NgamangaXhosa|NgamangaXhosa]] ([[Umsebenzisi asiqongelane:NgamangaXhosa|talk]]) 04:24, 20 Nkwenkwezi 2026 (SAST)
{{AfC-c|b}}</text>
      <sha1>quv2t4aql32iu3jete8wxc794qn6m0l</sha1>
    </revision>
    <revision>
      <id>6654</id>
      <parentid>6653</parentid>
      <timestamp>2026-05-20T04:41:03Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <origin>6654</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1107" sha1="5cvrx4tzcvjvuhp0fh4mgxtre5p520g" xml:space="preserve">{{Archive}}

== Redirect request: [[IsiNdebele]] ==
{{AfC-c|a}}
*Target of redirect: [[Isindebele]]

*Reason: Amaledere amakhulu, madoda.

*Source (if applicable): ...

[[Umsebenzisi:ThatEquatorialGuineaEditor (alt)|ThatEquatorialGuineaEditor (alt)]] ([[Umsebenzisi asiqongelane:ThatEquatorialGuineaEditor (alt)|talk]]) 07:46, 19 Nkwenkwezi 2026 (SAST)

:{{Done}}. Ngiyathokoza ngokusiza iWikiphidiya! [[Umsebenzisi:NgamangaXhosa|NgamangaXhosa]] ([[Umsebenzisi asiqongelane:NgamangaXhosa|talk]]) 07:48, 19 Nkwenkwezi 2026 (SAST)
{{AfC-c|b}}

== Redirect request: [[IsiNdebele seSewula]] ==
{{AfC-c|d}}
*Target of redirect: [[Isindebele]]

*Reason: Sebenzisa ibizo elifaneleko ;)

*Source (if applicable): ...

[[Umsebenzisi:ThatEquatorialGuineaEditor (alt)|ThatEquatorialGuineaEditor (alt)]] ([[Umsebenzisi asiqongelane:ThatEquatorialGuineaEditor (alt)|talk]]) 04:19, 20 Nkwenkwezi 2026 (SAST)

:{{Declined}}. Umtlolo lo uzokuthuthelwa esikhaleni esiceliweko msinyana. [[Umsebenzisi:NgamangaXhosa|NgamangaXhosa]] ([[Umsebenzisi asiqongelane:NgamangaXhosa|talk]]) 04:24, 20 Nkwenkwezi 2026 (SAST)
{{AfC-c|b}}</text>
      <sha1>5cvrx4tzcvjvuhp0fh4mgxtre5p520g</sha1>
    </revision>
    <revision>
      <id>6656</id>
      <parentid>6654</parentid>
      <timestamp>2026-05-20T04:41:47Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Replaced content with &quot;{{Archive}}&quot;</comment>
      <origin>6656</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="11" sha1="rzh0eq4u5qq9tl9dk2ht86m4wc67fa4" xml:space="preserve">{{Archive}}</text>
      <sha1>rzh0eq4u5qq9tl9dk2ht86m4wc67fa4</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Editnotice EXPECTUNUSEDTEMPLATE</title>
    <ns>10</ns>
    <id>1183</id>
    <revision>
      <id>6652</id>
      <timestamp>2026-05-20T04:39:05Z</timestamp>
      <contributor>
        <username>NgamangaXhosa</username>
        <id>1515</id>
      </contributor>
      <comment>Created page with &quot;{{#ifeq:Template:Editnotices|{{FULLROOTPAGENAME}}|__EXPECTUNUSEDTEMPLATE__}}&lt;noinclude&gt;{{documentation}}&lt;/noinclude&gt;&quot;</comment>
      <origin>6652</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="116" sha1="1zwqf3zeqxnh21v7kbtjaygvxm2lqko" xml:space="preserve">{{#ifeq:Template:Editnotices|{{FULLROOTPAGENAME}}|__EXPECTUNUSEDTEMPLATE__}}&lt;noinclude&gt;{{documentation}}&lt;/noinclude&gt;</text>
      <sha1>1zwqf3zeqxnh21v7kbtjaygvxm2lqko</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:配合比全额更好（说说而已）</title>
    <ns>2</ns>
    <id>1184</id>
    <revision>
      <id>6661</id>
      <timestamp>2026-05-24T02:39:12Z</timestamp>
      <contributor>
        <username>配合比全额更好（说说而已）</username>
        <id>1535</id>
      </contributor>
      <comment>Created page with &quot;Lotjha!Ngi 配合比全额更好（说说而已）.&quot;</comment>
      <origin>6661</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="51" sha1="qbjpowgonvbfa2hzhwyb63qykk4l01p" xml:space="preserve">Lotjha!Ngi 配合比全额更好（说说而已）.</text>
      <sha1>qbjpowgonvbfa2hzhwyb63qykk4l01p</sha1>
    </revision>
  </page>
  <page>
    <title>Impophoma</title>
    <ns>0</ns>
    <id>1185</id>
    <revision>
      <id>6662</id>
      <timestamp>2026-05-27T09:32:53Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1340284932|Waterfall]]&quot;</comment>
      <origin>6662</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2486" sha1="byo3bmhpqro1kqat9hhuuorp3eyna83" xml:space="preserve">
[[Isimumathi:Cascada_Dynjandi,_Vestfirðir,_Islandia,_2014-08-14,_DD_136-138_HDR.JPG|thumb|i-Dynjandi impophoma ese Westfjords iceland.]]
'''Impophoma''' yindawo emlanjeni nofana emilanjeni lapho amanzi ageleza khona asuka phezulu ehlela phasi. Impophoma zenzeka lapho amanzi ancibilikako awela phezu komphetho weqhwa elifana netafula nofana itjhelfu yeqhwa .&lt;ref&gt;{{Cite web|date=2026-03-18|title=waterfall|url=https://dictionary.cambridge.org/dictionary/english/waterfall|access-date=2026-03-23|website=dictionary.cambridge.org|language=en}}&lt;/ref&gt; Iimpophoma zibubemka ngeendlela ezinengi, kodwana indlela ejayelekileko kukuthi umlambo ugeleza phezu kwesendlalelo esiphezulu selitje elijamelanako ngaphambi kobana uwele edwaleni elithambileko, eliguguleka msinyana, okurholela ekutheni  okuphezulu. Iimpophoma zifundwe ngomthelela wazo enlwaneni nentjalweni  eziphila kizo neziseduze kwazo.

Abantu bebanobudlelwano obukhethekileko nobuqakathekileko neempophoma kusukela elikadeni, bebakhamba amabanga bayozibona, bazihlola begodu bazithiya amabizo. Zingaveza iinqabo eziqinileko ekukhambeni ngemilanjeni. Emasikweni amanengi Impophoma zithathwa njengendawo ezibalulekileko zekolo. Sukela kwangeminyaka yekhulu le-18, zithole ukutjhejwa okukhulu njengeendawo zokuvakatjhela, imithombo yamandla wamanzi, begodu — khulukhulu kusukela phakathi nekhulu leminyaka ye-20 — njengeendaba zokurhubhulula.

== Ihlathululo namagama ==
Impophoma ngokuvamileko ihlathululwa njendawo emlanjeni lapho amanzi ageleza khona phezu kwethonsi eliphezulu eliseduze nofana elijame tsi. Ngomnyaka ka-2000 uMabin waveza bonyana &quot;Ibanga elivundlileko hlangana neendawo zomlomo kanye nedamu lokutjhinga akukafaneli libe ngaphezu kwama-25% wobude bempophoma.&quot; Kunemihlobo ehlukileko neendlela zokuhlukanisa iimpophoma. Ezinye izazi zifake ukugijima kwamanzi njengesigaba.  Khuyini eyakha impophoma iyaragela phambili nokuphikisana. &lt;ref&gt;{{Cite web|title=Waterfall|url=https://education.nationalgeographic.org/resource/waterfall|access-date=2026-03-23|website=education.nationalgeographic.org|language=en}}&lt;/ref&gt;
&lt;ref&gt;{{Cite web|title=Waterfall|url=https://education.nationalgeographic.org/resource/waterfall|access-date=2026-03-23|website=education.nationalgeographic.org|language=en}}&lt;/ref&gt;&lt;ref&gt;{{Cite web|date=2026-03-18|title=waterfall|url=https://dictionary.cambridge.org/dictionary/english/waterfall|access-date=2026-03-23|website=dictionary.cambridge.org|language=en}}&lt;/ref&gt;{{Reflist}}

== Iinkomba ==</text>
      <sha1>byo3bmhpqro1kqat9hhuuorp3eyna83</sha1>
    </revision>
    <revision>
      <id>6739</id>
      <parentid>6662</parentid>
      <timestamp>2026-07-07T19:41:20Z</timestamp>
      <contributor>
        <username>VamuhleOmuhle</username>
        <id>1385</id>
      </contributor>
      <comment>/* Iinkomba */</comment>
      <origin>6739</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2488" sha1="tq6bku6b6bxpi5o3k4653ncfntpo39k" xml:space="preserve">
[[Isimumathi:Cascada_Dynjandi,_Vestfirðir,_Islandia,_2014-08-14,_DD_136-138_HDR.JPG|thumb|i-Dynjandi impophoma ese Westfjords iceland.]]
'''Impophoma''' yindawo emlanjeni nofana emilanjeni lapho amanzi ageleza khona asuka phezulu ehlela phasi. Impophoma zenzeka lapho amanzi ancibilikako awela phezu komphetho weqhwa elifana netafula nofana itjhelfu yeqhwa .&lt;ref&gt;{{Cite web|date=2026-03-18|title=waterfall|url=https://dictionary.cambridge.org/dictionary/english/waterfall|access-date=2026-03-23|website=dictionary.cambridge.org|language=en}}&lt;/ref&gt; Iimpophoma zibubemka ngeendlela ezinengi, kodwana indlela ejayelekileko kukuthi umlambo ugeleza phezu kwesendlalelo esiphezulu selitje elijamelanako ngaphambi kobana uwele edwaleni elithambileko, eliguguleka msinyana, okurholela ekutheni  okuphezulu. Iimpophoma zifundwe ngomthelela wazo enlwaneni nentjalweni  eziphila kizo neziseduze kwazo.

Abantu bebanobudlelwano obukhethekileko nobuqakathekileko neempophoma kusukela elikadeni, bebakhamba amabanga bayozibona, bazihlola begodu bazithiya amabizo. Zingaveza iinqabo eziqinileko ekukhambeni ngemilanjeni. Emasikweni amanengi Impophoma zithathwa njengendawo ezibalulekileko zekolo. Sukela kwangeminyaka yekhulu le-18, zithole ukutjhejwa okukhulu njengeendawo zokuvakatjhela, imithombo yamandla wamanzi, begodu — khulukhulu kusukela phakathi nekhulu leminyaka ye-20 — njengeendaba zokurhubhulula.

== Ihlathululo namagama ==
Impophoma ngokuvamileko ihlathululwa njendawo emlanjeni lapho amanzi ageleza khona phezu kwethonsi eliphezulu eliseduze nofana elijame tsi. Ngomnyaka ka-2000 uMabin waveza bonyana &quot;Ibanga elivundlileko hlangana neendawo zomlomo kanye nedamu lokutjhinga akukafaneli libe ngaphezu kwama-25% wobude bempophoma.&quot; Kunemihlobo ehlukileko neendlela zokuhlukanisa iimpophoma. Ezinye izazi zifake ukugijima kwamanzi njengesigaba.  Khuyini eyakha impophoma iyaragela phambili nokuphikisana. &lt;ref&gt;{{Cite web|title=Waterfall|url=https://education.nationalgeographic.org/resource/waterfall|access-date=2026-03-23|website=education.nationalgeographic.org|language=en}}&lt;/ref&gt;
&lt;ref&gt;{{Cite web|title=Waterfall|url=https://education.nationalgeographic.org/resource/waterfall|access-date=2026-03-23|website=education.nationalgeographic.org|language=en}}&lt;/ref&gt;&lt;ref&gt;{{Cite web|date=2026-03-18|title=waterfall|url=https://dictionary.cambridge.org/dictionary/english/waterfall|access-date=2026-03-23|website=dictionary.cambridge.org|language=en}}&lt;/ref&gt;

== Imithombo ==
{{Reflist}}</text>
      <sha1>tq6bku6b6bxpi5o3k4653ncfntpo39k</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Infobox park</title>
    <ns>10</ns>
    <id>1186</id>
    <revision>
      <id>6669</id>
      <timestamp>2026-06-07T15:11:48Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>Opened</comment>
      <origin>6669</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7358" sha1="khu1j3y32l41rzuhj5v9dxf58qo7e7u" xml:space="preserve">{{infobox
| bodyclass      = vcard
| child          = {{#if:{{{child|}}}{{{embed|}}}|yes}}

| title          = {{#if:{{{child|}}}{{{embed|}}}|{{{title|}}}}}
| aboveclass     = fn org
| abovestyle     = background-color: #abdb75; color:inherit; line-height: 140%;
| above          = {{if empty|{{{name|}}}|{{PAGENAMEBASE}} }}

| subheaderstyle = font-size: 110%
| subheader      = {{{other_name|}}}
| subheader2     = {{#if:{{{native_name|}}}|{{#if:{{{native_name_lang|}}}|&lt;span class=&quot;nickname&quot; lang=&quot;{{{native_name_lang}}}&quot;&gt;}}{{{native_name}}}{{#if:{{{native_name_lang|}}}|&lt;/span&gt;}}}}

| image1          = {{#invoke:InfoboxImage|InfoboxImage|image={{{logo|}}}|size={{{logo_size|}}}|upright={{{logo_upright|}}}|alt={{{logo_alt|}}}}}
| caption1        = {{{logo_caption|}}}

| image2          = {{#invoke:InfoboxImage|InfoboxImage|image={{{image|}}}|size={{#switch:{{{image_size|}}}
                     | frameless = frameless
                     | upright = frameless
                     | {{{image_size|}}}
                     }}|upright={{#ifeq:{{{image_size|}}}|upright|0.75|{{{upright|}}}
                     }}|sizedefault=250px|maxsize=325px|alt={{{image_alt|}}} }}
| caption2        = {{{image_caption|}}}

| image3         = {{#if:{{{map|}}}
           | {{Location map|{{{map}}}
                     | border = infobox | float = center
                     | alt = {{{map_alt|}}}
                     | width = {{{map_size|}}}
                     | default_width = 250
                     | max_width = 272
                     | caption = {{{map_caption|}}}
                     | relief = {{{relief|}}}
                     | label = {{{map_label|}}}
                     | position = {{{map_label_position|}}}
                     | mark = {{{mark|}}}
                     | marksize = {{{mark_width|}}}
                     | coordinates = {{{coordinates|}}} }}
           | {{#invoke:InfoboxImage|InfoboxImage|image={{{map_image|}}}|size={{{map_size|}}}|sizedefault=250px|maxsize=272px|alt={{{map_alt|}}}}}
           }}
| caption3 = {{#if:{{{map|}}} || {{{map_caption|}}} }}

| image4     = {{#invoke:Infobox mapframe
  | autoWithCaption
  | onByDefault = {{#if:{{{map|}}}{{{map_image|}}}{{{child|}}}{{{embed|}}}|no|yes}}
  | mapframe-marker = park
  | mapframe-marker-color = #abdb75
  | mapframe-frame-width = 250
  | mapframe-wikidata = yes
  | mapframe-caption = Interactive map of {{if empty|{{{name|}}}|{{PAGENAMEBASE}}}}
}}

| rowclass2  = category
| label2     = Type
| data2      = {{{type|}}}

| label3     = Motto
| data3      = {{{motto|}}}

| rowclass4  = label
| label4     = Location
| data4      = {{{location|}}}

| label5     = Nearest&amp;nbsp;city
| data5      = {{{nearest_city|}}}

| label6     = Nearest&amp;nbsp;town
| data6      = {{{nearest_town|}}}

| label7     = [[Ordnance Survey National Grid|OS grid]]
| data7      = {{#if:{{{grid_ref_UK|}}}|{{gbm4ibx|{{{grid_ref_UK|}}}|name={{if empty|{{{name|}}}|{{PAGENAMEBASE}}}} }}{{{grid_ref_UK_note|}}}}}

| label8     = [[Irish grid reference system|OSI/OSNI grid]]
| data8      = {{#if:{{{grid_ref_Ireland|}}}|{{iem4ibx|{{{grid_ref_Ireland|}}}|name={{if empty|{{{name|}}}|{{PAGENAMEBASE}}}} }}{{{grid_ref_Ireland_note|}}}}}

| label9     = Coordinates
| data9      = {{#if:{{{coordinates|}}}|{{#invoke:Coordinates|coordinsert|{{{coordinates|}}}|type:landmark}}{{{coords_ref|}}}}}

| rowclass10 = note
| label10    = Area
| data10     = {{{area|}}}

| label11    = Elevation
| data11     = {{{elevation|}}}

| label12    = Authorized
| data12     = {{{authorized|}}}

| label13    = Created
| data13     = {{{created|}}}

| label14    = Established
| data14     = {{{established|}}}

| label15    = Designated
| data15     = {{{designated|}}}

| label16    = {{#if:{{{opening|}}}|Opening|Opened}}
| data16     = {{if empty|{{{opening|}}}|{{{opened|}}}}}

| label17    = Closed
| data17     = {{{closed|}}}

| label18    = Founder
| data18     = {{{founder|}}}

| label19    = Designer
| data19     = {{{designer|}}}

| label20    = Etymology
| data20     = {{{etymology|}}}

| label21    = Owner
| data21     = {{{owner|}}}

| label22    = Administrator
| data22     = {{{administrator|}}}

| label23    = Manager
| data23     = {{{manager|}}}

| label24    = Operator
| data24     = {{{operator|}}}

| label25    = Visitors
| data25     = {{#if:{{{visitation_num|}}}|{{{visitation_num|}}}&lt;!--
                   --&gt;{{#if:{{{visitation_year|}}}|{{sp}}(in&amp;nbsp;{{{visitation_year|}}})}}{{{visitation_ref|}}}}}

| label26    = Open
| data26     = {{{open|}}}

| rowclass27 = category
| label27    = Status
| data27     = {{{status|}}}

| label28    = Awards
| data28     = {{{awards|}}}

| label29    = Camp sites
| data29     = {{{camp_sites|}}}

| label30    = Hiking trails
| data30     = {{{hiking_trails|}}}

| label31    = Paths
| data31     = {{{paths|}}}

| label32    = Terrain
| data32     = {{{terrain|}}}

| label33    = Habitats
| data33     = {{{habitat|}}}

| label34    = Water
| data34     = {{{water|}}}

| label35    = Vegetation
| data35     = {{{vegetation|}}}

| label36    = Plants
| data36     = {{{plants|}}}

| label37    = Species
| data37     = {{{species|}}}

| label38    = Collections
| data38     = {{{collections|}}}

| label39    = Designation
| data39     = {{{designation|}}}

| label40    = Threatened&amp;nbsp;by
| data40     = {{{disturbance|}}}

| label41    = Budget
| data41     = {{{budget|}}}

| label42    = Parking
| data42     = {{{parking|}}}

| label43    = {{longitem|Public transit}}
| data43     = {{{public_transit|}}}

| label44    = {{{free_label|}}}
| class44    = note
| data44     = {{{free_data|}}}

| label45    = Facilities
| data45     = {{{facilities|}}}

| label46    = Other information
| data46     = {{{other_info|}}}

| label47    = Website
| data47     = {{{website|}}}

| data48     = {{{embedded|}}}
| data49     = {{{module|}}}

}}{{#invoke:Check for unknown parameters|check|unknown={{main other|[[Category:Pages using infobox park with unknown parameters|_VALUE_{{PAGENAME}}]]}}|preview=Page using [[Template:Infobox park]] with unknown parameter &quot;_VALUE_&quot;|ignoreblank=y|mapframe_args=y| administrator | area | authorized | awards | budget | camp_sites | child | closed | collections | coordinates | coords_ref | created | designated | designation | designer | disturbance | elevation | embed | embedded | established | etymology | facilities | founder | free_data | free_label | grid_ref_Ireland | grid_ref_Ireland_note | grid_ref_UK | grid_ref_UK_note | habitat | hiking_trails | image | image_alt | image_caption | image_size | location | logo | logo_alt | logo_caption | logo_size | logo_upright | manager | map | map_alt | map_caption | map_image | map_label | map_label_position | map_size | mark | mark_width | module | motto | name | native_name | native_name_lang | nearest_city | nearest_town | open | opened | opening | operator | other_info | other_name | owner | parking | paths | plants | public_transit | relief | species | status | terrain | title | type | upright | vegetation | visitation_num | visitation_ref | visitation_year | water | website }}{{#invoke:Check for conflicting parameters|check
| template = [[Template:Infobox park]]
| cat = {{main other|Category:Pages using infobox park with conflicting parameters}}
| opening; opened 
}}&lt;noinclude&gt;
{{documentation}}
&lt;/noinclude&gt;</text>
      <sha1>khu1j3y32l41rzuhj5v9dxf58qo7e7u</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Multiple image</title>
    <ns>10</ns>
    <id>1187</id>
    <revision>
      <id>6673</id>
      <timestamp>2026-06-07T15:26:39Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>Added module</comment>
      <origin>6673</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="33" sha1="mhbfjolvpdsccetk1h3jn96slzgx5vc" xml:space="preserve">{{#invoke:Multiple image|render}}</text>
      <sha1>mhbfjolvpdsccetk1h3jn96slzgx5vc</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Multiple image</title>
    <ns>828</ns>
    <id>1188</id>
    <revision>
      <id>6674</id>
      <timestamp>2026-06-07T15:31:07Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>Let’s try</comment>
      <origin>6674</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="10712" sha1="87jm8kwseugqlivazd2az7lublu53wp" xml:space="preserve">-- implements [[template:multiple image]]
local p = {}

local autoscaledimages
local nonautoscaledimages

local function isnotempty(s)
	return s and s:match( '^%s*(.-)%s*$' ) ~= ''
end

local function removepx(s)
	return tostring(s or ''):match('^(.*)[Pp][Xx]%s*$') or s
end

local function getdimensions(s, w, h)
	if tonumber(w) and tonumber(h) then
		nonautoscaledimages = true
		return tonumber(w), tonumber(h)
	end
	local file = s and mw.title.new('File:' .. mw.uri.decode(mw.ustring.gsub(s,'%|.*$',''), 'WIKI'))
	file = file and file.file or {width = 0, height = 0}
	w = tonumber(file.width) or 0
	h = tonumber(file.height) or 0
	autoscaledimages = true
	return w, h
end

local function renderImageCell(image, width, height, link, alt, thumbtime, caption, class, textalign, istyle, border, tcolor)
	local root = mw.html.create('')
	local altstr = ''
	local classstr = class and ('|class=' .. class) or ''
	local linkstr = link and ('|link=' .. link) or ''
	local widthstr = '|' .. tostring(width) .. 'px'
	local thumbtimestr = ''
	if isnotempty( alt ) then
		altstr = '|alt=' .. alt
	end
	if widthstr == '|-nanpx' then
		widthstr = ''
	end
	if isnotempty( thumbtime ) then
		thumbtimestr = '|thumbtime=' .. thumbtime
	end

	local imagediv = root:tag('div')
	imagediv:addClass((border ~= 'infobox') and 'thumbimage' or nil)
	imagediv:cssText(istyle)
	if( height ) then
		imagediv:css('height', tostring(height) .. 'px')
		imagediv:css('overflow', 'hidden')
	end
	imagediv:wikitext('[[file:' .. image .. classstr .. widthstr .. linkstr .. altstr .. thumbtimestr .. ']]')
	if isnotempty(caption) then
		local captiondiv = root:tag('div')
		captiondiv:addClass((border ~= 'infobox') and 'thumbcaption' or nil)
		if isnotempty(textalign) then
			captiondiv:addClass('text-align-' .. textalign)
        end
		if( tcolor ~= '' ) then
			captiondiv:css('color', tcolor)
		end
		captiondiv:wikitext(caption)
	end
	return tostring(root)
end

local function getWidth(w1, w2)
	local w
	if isnotempty(w1) then
		w = tonumber(w1)
	elseif isnotempty(w2) then
		w = tonumber(w2)
	end
	return w or 200
end

local function getPerRow(pstr, ic)
	-- split string into array using any non-digit as a dilimiter
	local pr = mw.text.split(pstr or '', '[^%d][^%d]*')
	-- if split failed, assume a single row
	if (#pr &lt; 1) then
		pr = {tostring(ic)}
	end
	-- convert the array of strings to an array of numbers,
	-- adding any implied/missing numbers at the end of the array
	local r = 1
	local thisrow = tonumber(pr[1] or ic) or ic
	local prownum = {}
	while( ic &gt; 0 ) do
		prownum[r] = thisrow
		ic = ic - thisrow
		r = r + 1
		-- use the previous if the next is missing and
		-- make sure we don't overstep the number of images
		thisrow = math.min(tonumber(pr[r] or thisrow) or ic, ic)
	end
	return prownum
end

local function renderMultipleImages(frame)
	local pargs = frame:getParent().args
	local args = frame.args
	local width = removepx(pargs['width'] or '')
	local dir = pargs['direction'] or ''
	local border = pargs['border'] or args['border'] or ''
	local align = pargs['align'] or args['align'] or (border == 'infobox' and 'center' or '')
	local capalign = pargs['caption_align'] or args['caption_align'] or ''
	local totalwidth = removepx(pargs['total_width'] or args['total_width'] or '')
	local imgstyle = pargs['image_style'] or args['image_style']
	local header = pargs['header'] or pargs['title'] or ''
	local footer = pargs['footer'] or ''
	local imagegap = tonumber(pargs['image_gap'] or '1') or 1
	local perrow = nil
	local thumbclass = {
		[&quot;left&quot;] = 'floatleft',
		[&quot;none&quot;] = 'tnone',
		[&quot;center&quot;] = 'tnone',
		[&quot;centre&quot;] = 'tnone',
		[&quot;right&quot;] = 'floatright'
		}

	-- find all the nonempty images
	local imagenumbers = {}
	local imagecount = 0
	for k, v in pairs( pargs ) do
		local i = tonumber(tostring(k):match( '^%s*image([%d]+)%s*$' ) or '0')
		if( i &gt; 0 and isnotempty(v) ) then
			table.insert( imagenumbers, i)
			imagecount = imagecount + 1
		end
	end

	-- sort the imagenumbers
	table.sort(imagenumbers)

	-- create an array with the number of images per row
	perrow = getPerRow(dir == 'vertical' and '1' or pargs['perrow'], imagecount)

	-- compute the number of rows
	local rowcount = #perrow

	-- store the image widths and compute row widths and maximum row width
	local heights = {}
	local widths = {}
	local widthmax = 0
	local widthsum = {}
	local k = 0
	for r=1,rowcount do
		widthsum[r] = 0
		for c=1,perrow[r] do
			k = k + 1
			if( k &lt;= imagecount ) then
				local i = imagenumbers[k]
				if( isnotempty(totalwidth) ) then
					widths[k], heights[k] = getdimensions(pargs['image' .. i], pargs['width' .. i], pargs['height' .. i])
				else
					widths[k] = getWidth(width, pargs['width' .. i])
				end
				widthsum[r] = widthsum[r] + widths[k]
			end
		end
		widthmax = math.max(widthmax, widthsum[r])
	end

	-- make sure the gap is non-negative
	if imagegap &lt; 0 then imagegap = 0 end

	-- if total_width has been specified, rescale the image widths
	if( isnotempty(totalwidth) ) then
		totalwidth = tonumber(totalwidth)
		widthmax = 0
		local k = 0
		for r=1,rowcount do
			local koffset = k
			local tw = totalwidth - (3 + imagegap) * (perrow[r] - 1) - 12
			local ar = {}
			local arsum = 0
			for j=1,perrow[r] do
				k = k + 1
				if( k&lt;= imagecount ) then
					local i = imagenumbers[k]
					local h = heights[k] or 0
					if (h &gt; 0) then
						ar[j] = widths[k]/h
						heights[k] = h
					else
						ar[j] = widths[k]/100
					end
					arsum = arsum + ar[j]
				end
			end
			local ht = tw/arsum
			local ws = 0
			k = koffset
			for j=1,perrow[r] do
				k = k + 1
				if( k&lt;= imagecount ) then
					local i = imagenumbers[k]
					widths[k] = math.floor(ar[j]*ht + 0.5)
					ws = ws + widths[k]
					if heights[k] then
						heights[k] = math.floor(ht)
					end
				end
			end
			widthsum[r] = ws
			widthmax = math.max(widthmax, widthsum[r])
		end
	end

	-- start building the array of images, if there are images
	if( imagecount &gt; 0 ) then
		-- compute width of outer div
		local bodywidth = 0
		for r=1,rowcount do
			if( widthmax == widthsum[r] ) then
				bodywidth = widthmax + (3 + imagegap) * (perrow[r] - 1) + 12
			end
		end
		-- The body has a min-width of 100, which needs to be taken into account on specific widths
		bodywidth = math.max( 100, bodywidth - 8);

		local tc = pargs['color'] or pargs['text_color'] or ''
		local bg = pargs['bg_color'] or pargs['background_color'] or pargs['background color'] or ''
		-- create the array of images
		local root = mw.html.create('div')
		root:addClass('thumb')
		root:addClass('tmulti')
		-- root:addClass('tmulti-sandbox')
		root:addClass(thumbclass[align] or 'floatright')

		if( align == 'center' or align == 'centre' ) then
			root:addClass('center')
		end
		if( tc ~= '' ) then
			root:css('color', tc)
		end

		local div = root:tag('div')
		div:addClass((border ~= 'infobox') and 'thumbinner multiimageinner' or 'multiimageinner')
		div:css('width', tostring(bodywidth) .. 'px')
			:css('max-width', tostring(bodywidth) .. 'px')
		if( bg ~= '' ) then
			div:css('background-color', bg)
        end
		if( tc ~= '' ) then
			div:css('color', tc)
		end
		if( border == 'infobox' or border == 'none') then
			div:css('border', 'none')
		end
		-- add the header
		if( isnotempty(header) ) then
			div:tag('div')
				:addClass('trow')
				:tag('div')
					:addClass('theader')
					:css('text-align', pargs['header_align'])
					:css('background-color', 
						(pargs['header_background'] ~= '') and pargs['header_background'] or nil)
					:wikitext(header)
		end
		-- loop through the images
		local k = 0
		for r=1,rowcount do
			local rowdiv = div:tag('div'):addClass('trow');
			for j=1,perrow[r] do
				k = k + 1
				if( k &lt;= imagecount ) then
					local imagediv = rowdiv:tag('div')
					imagediv:addClass('tsingle')
					if bg ~= '' then
						imagediv:css('background-color', bg);
					end
					if imagegap &gt; 1 and k &lt; imagecount then
						if dir == 'vertical' then
							imagediv:css('margin-bottom', tostring(imagegap) .. 'px')	
						elseif j &lt; perrow[r] then
							imagediv:css('margin-right', tostring(imagegap) .. 'px')
						end
					end
					local i = imagenumbers[k]
					local img = pargs['image' .. i]
					local w = widths[k]
					imagediv:css('width', tostring(2 + w) .. 'px')
						:css('max-width', tostring(2 + w) .. 'px')
					imagediv:wikitext(renderImageCell(img, w, heights[k],
						pargs['link' .. i], pargs['alt' .. i],
						pargs['thumbtime' .. i], pargs['caption' .. i], pargs['class' .. i], capalign, imgstyle, border, tc))
				end
			end
		end
		-- add the footer
		if( isnotempty(footer) ) then
			local falign = string.lower(pargs['footer_align'] or args['footer_align'] or '')
			falign = (falign == 'centre') and 'center' or falign
			div:tag('div')
				:addClass('trow')
				:css('display', (falign ~= '') and 'flow-root' or 'flex')
				:tag('div')
					:addClass((border ~= 'infobox') and 'thumbcaption' or nil)
					:css('text-align', (falign ~= '') and falign or nil)
					:css('background-color', 
						(pargs['footer_background'] ~= '') and pargs['footer_background'] or nil)
                    :css('color', (tc ~= '') and tc or nil)
					:wikitext(footer)
		end
		return tostring(root)
	end
	return ''
end

function p.render( frame )
	autoscaledimages = false
	nonautoscaledimages = false

	local check = require('Module:Check for unknown parameters')._check
	local tracking = check({
		['unknown'] = frame:expandTemplate{
			title = 'main other',
			args = {'[[Category:Pages using multiple image with unknown parameters|_VALUE_ ]]'}
		},
		['preview'] = 'Page using [[Template:Multiple image]] with unknown parameter &quot;_VALUE_&quot;',
		['ignoreblank'] = 'y',
		regexp1 = 'image%d+',
		regexp2 = 'width%d+',
		regexp3 = 'height%d+',
		regexp4 = 'class%d+',
		regexp5 = 'alt%d+',
		regexp6 = 'link%d+',
		regexp7 = 'thumbtime%d+',
		regexp8 = 'caption%d+',
		'align', 'direction', 'header_background', 
		'header_align', 'header', 'width', 'total_width', 
		'caption_align', 'footer_background', 'footer_align', 'footer', 
		'perrow', 'title', 'image_gap', 'border', 'image_style', 
        'color', 'text_color',
		'bg_color', 'background_color', 'background color'
	}, frame:getParent().args)
	
	return frame:extensionTag {name = 'templatestyles', args = {src = 'Multiple image/styles.css', wrapper = &quot;.tmulti&quot;}}
		.. renderMultipleImages( frame )
		.. (autoscaledimages and '[[Category:Pages using multiple image with auto scaled images]]' or '')
		.. (nonautoscaledimages and '[[Category:Pages using multiple image with manual scaled images]]' or '')
		.. tracking
end

p[''] = function( frame ) return p.render( frame:newChild{title = frame:getTitle()} ) end

return p</text>
      <sha1>87jm8kwseugqlivazd2az7lublu53wp</sha1>
    </revision>
  </page>
  <page>
    <title>Module:Check for unknown parameters</title>
    <ns>828</ns>
    <id>1189</id>
    <revision>
      <id>6675</id>
      <timestamp>2026-06-07T15:35:36Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>Created page with &quot;-- This module may be used to compare the arguments passed to the parent -- with a list of arguments, returning a specified result if an argument is -- not on the list  require ('strict');  local p = {}  local mapframe_params = { 	'coord', 	'coordinates', 	'id', 	'qid', 	'mapframe', 	'mapframe-area_km2', 	'mapframe-area_mi2', 	'mapframe-caption', 	'mapframe-coord', 	'mapframe-coordinates', 	'mapframe-custom', 	'mapframe-frame-coord', 	'mapframe-frame-coordinates', 	'mapf...&quot;</comment>
      <origin>6675</origin>
      <model>Scribunto</model>
      <format>text/plain</format>
      <text bytes="4561" sha1="mf5u017ry3j5wcsi9ctzrqfash3oih5" xml:space="preserve">-- This module may be used to compare the arguments passed to the parent
-- with a list of arguments, returning a specified result if an argument is
-- not on the list

require ('strict');

local p = {}

local mapframe_params = {
	'coord',
	'coordinates',
	'id',
	'qid',
	'mapframe',
	'mapframe-area_km2',
	'mapframe-area_mi2',
	'mapframe-caption',
	'mapframe-coord',
	'mapframe-coordinates',
	'mapframe-custom',
	'mapframe-frame-coord',
	'mapframe-frame-coordinates',
	'mapframe-frame-height',
	'mapframe-frame-width',
	'mapframe-geomask',
	'mapframe-geomask-fill',
	'mapframe-geomask-fill-opacity',
	'mapframe-geomask-stroke-color',
	'mapframe-geomask-stroke-colour',
	'mapframe-geomask-stroke-width',
	'mapframe-height',
	'mapframe-id',
	'mapframe-length_km',
	'mapframe-length_mi',
	'mapframe-line',
	'mapframe-line-stroke-color',
	'mapframe-line-stroke-colour',
	'mapframe-marker',
	'mapframe-marker-color',
	'mapframe-marker-colour',
	'mapframe-point',
	'mapframe-population',
	'mapframe-shape',
	'mapframe-shape-fill',
	'mapframe-shape-fill-opacity',
	'mapframe-shape-stroke-color',
	'mapframe-shape-stroke-colour',
	'mapframe-stroke-color',
	'mapframe-stroke-colour',
	'mapframe-stroke-width',
	'mapframe-switcher',
	'mapframe-type',
	'mapframe-width',
	'mapframe-wikidata',
	'mapframe-zoom'
}

local function trim(s)
	return s:match('^%s*(.-)%s*$')
end

local function isnotempty(s)
	return s and s:match('%S')
end

local function clean(text)
	-- Return text cleaned for display and truncated if too long.
	-- Strip markers are replaced with dummy text representing the original wikitext.
	local pos, truncated
	local function truncate(text)
		if truncated then
			return ''
		end
		if mw.ustring.len(text) &gt; 25 then
			truncated = true
			text = mw.ustring.sub(text, 1, 25) .. '...'
		end
		return mw.text.nowiki(text)
	end
	local parts = {}
	for before, tag, remainder in text:gmatch('([^\127]*)\127[^\127]*%-(%l+)%-[^\127]*\127()') do
		pos = remainder
		table.insert(parts, truncate(before) .. '&amp;lt;' .. tag .. '&amp;gt;...&amp;lt;/' .. tag .. '&amp;gt;')
	end
	table.insert(parts, truncate(text:sub(pos or 1)))
	return table.concat(parts)
end

function p._check(args, pargs)
	if type(args) ~= &quot;table&quot; or type(pargs) ~= &quot;table&quot; then
		-- TODO: error handling
		return
	end

	-- create the list of known args, regular expressions, and the return string
	local knownargs = {}
	
	if isnotempty(args['mapframe_args']) then
		for _, v in ipairs(mapframe_params) do
    		knownargs[v] = 1
		end
	end
	
	local regexps = {}
	for k, v in pairs(args) do
		if type(k) == 'number' then
			v = trim(v)
			knownargs[v] = 1
		elseif k:find('^regexp[1-9][0-9]*$') then
			table.insert(regexps, '^' .. v .. '$')
		end
	end
	
	-- loop over the parent args, and make sure they are on the list
	local ignoreblank = isnotempty(args['ignoreblank'])
	local showblankpos = isnotempty(args['showblankpositional'])
	local values = {}
	for k, v in pairs(pargs) do
		if type(k) == 'string' and knownargs[k] == nil then
			local knownflag = false
			for _, regexp in ipairs(regexps) do
				if mw.ustring.match(k, regexp) then
					knownflag = true
					break
				end
			end
			if not knownflag and ( not ignoreblank or isnotempty(v) )  then
				table.insert(values, clean(k))
			end
		elseif type(k) == 'number' and knownargs[tostring(k)] == nil then
			local knownflag = false
			for _, regexp in ipairs(regexps) do
				if mw.ustring.match(tostring(k), regexp) then
					knownflag = true
					break
				end
			end
			if not knownflag and ( showblankpos or isnotempty(v) ) then
				table.insert(values, k .. ' = ' .. clean(v))
			end
		end
	end

	-- add results to the output tables
	local res = {}
	if #values &gt; 0 then
		local unknown_text = args['unknown'] or 'Found _VALUE_, '

		if mw.getCurrentFrame():preprocess( &quot;{{REVISIONID}}&quot; ) == &quot;&quot; then
			local preview_text = args['preview']
			if isnotempty(preview_text) then
				preview_text = require('Module:If preview')._warning({preview_text})
			elseif preview_text == nil then
				preview_text = unknown_text
			end
			unknown_text = preview_text
		end
		for _, v in pairs(values) do
			-- Fix odd bug for | = which gets stripped to the empty string and
			-- breaks category links
			if v == '' then v = ' ' end

			-- avoid error with v = 'example%2' (&quot;invalid capture index&quot;)
			local r = unknown_text:gsub('_VALUE_', {_VALUE_ = v})
			table.insert(res, r)
		end
	end

	return table.concat(res)
end

function p.check(frame)
	local args = frame.args
	local pargs = frame:getParent().args
	return p._check(args, pargs)
end

return p</text>
      <sha1>mf5u017ry3j5wcsi9ctzrqfash3oih5</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Main other</title>
    <ns>10</ns>
    <id>1190</id>
    <revision>
      <id>6676</id>
      <timestamp>2026-06-07T15:38:25Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>Phew</comment>
      <origin>6676</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="478" sha1="9qaali5a3s60e5op8c0mnzbf3if9hmf" xml:space="preserve">{{safesubst:&lt;noinclude/&gt;#switch:
  &lt;noinclude&gt;&lt;!-- If no or empty &quot;demospace&quot; parameter then detect namespace --&gt;&lt;/noinclude&gt;
  {{safesubst:&lt;noinclude/&gt;#if:{{{demospace|}}} 
  | {{safesubst:&lt;noinclude/&gt;lc: {{{demospace}}} }}    &lt;noinclude&gt;&lt;!-- Use lower case &quot;demospace&quot; --&gt;&lt;/noinclude&gt;
  | {{safesubst:&lt;noinclude/&gt;#ifeq:{{safesubst:&lt;noinclude/&gt;NAMESPACE}}|{{safesubst:&lt;noinclude/&gt;ns:0}}
    | main
    | other
    }} 
  }}
| main     = {{{1|}}}
| other
| #default = {{{2|}}}
}}</text>
      <sha1>9qaali5a3s60e5op8c0mnzbf3if9hmf</sha1>
    </revision>
  </page>
  <page>
    <title>Asiqongelane:I-Mkhombo Nature Reserve</title>
    <ns>1</ns>
    <id>1191</id>
    <revision>
      <id>6678</id>
      <timestamp>2026-06-07T15:40:45Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>/* Tried to add an image template */ new section</comment>
      <origin>6678</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="485" sha1="ntzu2ttcrj8ninu2wd8vddek711m8iu" xml:space="preserve">== Tried to add an image template ==

{{multiple image
| border = infobox
| perrow = 1/2/2/1
| total_width = 290
| align = center
| caption_align = center
|image1 = 3-banded plover last weekend at Mkhombo Dam (36902155813).jpg
| caption1 = 
| image2             = 
| caption2           = 
|image3 = 
| caption3 = 
| image4          = 
| caption4          = 
}} [[Umsebenzisi:Derek J Moore|Derek J Moore]] ([[Umsebenzisi asiqongelane:Derek J Moore|talk]]) 17:40, 7 Nhlangula 2026 (SAST)</text>
      <sha1>ntzu2ttcrj8ninu2wd8vddek711m8iu</sha1>
    </revision>
  </page>
  <page>
    <title>Inyathelo</title>
    <ns>0</ns>
    <id>1192</id>
    <revision>
      <id>6684</id>
      <timestamp>2026-06-11T08:39:18Z</timestamp>
      <contributor>
        <username>MissHadassah</username>
        <id>1561</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1358620163|Shoe]]&quot;</comment>
      <origin>6684</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="227" sha1="5tlodga4sdzhy234j4w7dxx5bbdhkj9" xml:space="preserve">
'''Inyathelo''' indro yezinyathelo evamise ukutholakala ngababili ehloselwe ukuvikela nokududuza unyawo lomundru, kanengi yenziwe ngendlela yokuthi enye yenzelwe ukulingana nenyawo lesinxele kuthi enye yenzelwe inyawo lesidla.</text>
      <sha1>5tlodga4sdzhy234j4w7dxx5bbdhkj9</sha1>
    </revision>
    <revision>
      <id>6693</id>
      <parentid>6684</parentid>
      <timestamp>2026-06-12T07:39:04Z</timestamp>
      <contributor>
        <username>MissHadassah</username>
        <id>1561</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1358620163|Shoe]]&quot;</comment>
      <origin>6693</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="226" sha1="rq44dtnlcw1w48ttdfaldqq2geg9omm" xml:space="preserve">
'''Inyathelo''' yinto yamanyathelo evamise ukutholakala ngababili ehloselwe ukuvikela nokududuza unyawo lomuntu, kanengi yenziwe ngendlela yokuthi enye yenzelwe ukulingana nenyawo lesinxele kuthi enye yenzelwe inyawo lesidla.</text>
      <sha1>rq44dtnlcw1w48ttdfaldqq2geg9omm</sha1>
    </revision>
  </page>
  <page>
    <title>Vetkoek</title>
    <ns>0</ns>
    <id>1193</id>
    <revision>
      <id>6685</id>
      <timestamp>2026-06-11T10:59:58Z</timestamp>
      <contributor>
        <username>MissHadassah</username>
        <id>1561</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1342402681|Vetkoek]]&quot;</comment>
      <origin>6685</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="389" sha1="j71xj58amhraqu73369m24pufjwh1sm" xml:space="preserve">
'''Vetkoek''' ( /ˈ f ɛ t k ʊ k /,  ) vambane amatjhatjhatjha yisinkwa sesindru [[Isewula Afrika|seSewula Afrika]] esithosiweko . Ifana nekhekhe le-Caribbean Johnny, i ''-oliebol'' ye-Dutch, kanye nama ''-sopaipillas'' we-Mexico.  Yaziwa nangebizo lesiXhosa, lesiZulu, nelesiSetswana ''igwinya'' (ubunengi ''amagwinya'' ) kanye ''nelegwinya'' (ubunengi ''bemagwinya'' ) ngokulandrelana.</text>
      <sha1>j71xj58amhraqu73369m24pufjwh1sm</sha1>
    </revision>
  </page>
  <page>
    <title>Umrazana</title>
    <ns>0</ns>
    <id>1194</id>
    <revision>
      <id>6706</id>
      <timestamp>2026-06-12T09:51:19Z</timestamp>
      <contributor>
        <username>MissHadassah</username>
        <id>1561</id>
      </contributor>
      <comment>I defined a term in the Ndebele language</comment>
      <origin>6706</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="240" sha1="rsm7uv5l8pxwuj93qch3h9elgs6ser2" xml:space="preserve">* '''Umntrazana''' namkha ''umntazana'' [[umntwana]] wentombazana esitjhabeni sakwaNdebele&lt;ref&gt;[https://www.britannica.com/topic/Ndebele-South-African-people Ndebele | Language, Culture, History | Britannica]&lt;/ref&gt; [[Umtjhado|ongakatjhadi]]</text>
      <sha1>rsm7uv5l8pxwuj93qch3h9elgs6ser2</sha1>
    </revision>
    <revision>
      <id>6770</id>
      <parentid>6706</parentid>
      <timestamp>2026-08-14T10:15:58Z</timestamp>
      <contributor>
        <username>Nkosazanamasanabo</username>
        <id>1687</id>
      </contributor>
      <comment>Umntazana is the orthographic form, while umrazana reflects the phonetic pronunciation</comment>
      <origin>6770</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="220" sha1="goxh0jyzsi9zl0qpp5oaf2r6um8nsi7" xml:space="preserve">* '''Umntazana:'''  [[umntwana|mntwana]] osikazi esitjhabeni samaNdebele&lt;ref&gt;[https://www.britannica.com/topic/Ndebele-South-African-people Ndebele | Language, Culture, History | Britannica]&lt;/ref&gt; [[Umtjhado|ongakendi.]]</text>
      <sha1>goxh0jyzsi9zl0qpp5oaf2r6um8nsi7</sha1>
    </revision>
    <revision>
      <id>6798</id>
      <parentid>6770</parentid>
      <timestamp>2026-08-20T09:37:45Z</timestamp>
      <contributor>
        <username>Andries Solly Skhosana</username>
        <id>1624</id>
      </contributor>
      <comment>I have changed &quot;osikazi&quot; to &quot;omsikazi.&quot; The concord was not right in this sentence.</comment>
      <origin>6798</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="221" sha1="edp604lzh9ms9871c1xk4fago7k9335" xml:space="preserve">* '''Umntazana:'''  [[umntwana|mntwana]] omsikazi esitjhabeni samaNdebele&lt;ref&gt;[https://www.britannica.com/topic/Ndebele-South-African-people Ndebele | Language, Culture, History | Britannica]&lt;/ref&gt; [[Umtjhado|ongakendi.]]</text>
      <sha1>edp604lzh9ms9871c1xk4fago7k9335</sha1>
    </revision>
  </page>
  <page>
    <title>Portal:Amalimi</title>
    <ns>0</ns>
    <id>1195</id>
    <revision>
      <id>6708</id>
      <timestamp>2026-06-12T10:31:57Z</timestamp>
      <contributor>
        <username>MissHadassah</username>
        <id>1561</id>
      </contributor>
      <comment>I defined a term</comment>
      <origin>6708</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1326" sha1="k4wxl5xknjuukuj86qfknagboenv38z" xml:space="preserve">== '''Amalimi&lt;ref&gt;[https://dictionary.cambridge.org/dictionary/english/language LANGUAGE | English meaning - Cambridge Dictionary]&lt;/ref&gt;'''  lihlelo lokhulumisana elisetjenziswa lilizwe elithilko nofana umphakathi. Lilimi lihlelo elihlelekileko lokukhulumisana elisetjenziswa abantu ukudlulisa ihlathululo imicabango, nemizwa. Iqukethe amagama akhulunywako, umtlolo otlolwe phasi, nofana amatshwayo wesandla, alawula yimithetho yegrama nesilulumagama. ==
[[Isimumathi:SAPS language.png|thumb|isithombe sezibalo zeenlimi]]
''[[I-Afrika|eSewulu Afrika]]''  sineenlimi eili-12 ezisemthethweni&lt;ref&gt;[https://www.studycountry.com/wiki/what-are-the-12-official-languages-of-south-africa What are the 12 official languages of South Africa?]&lt;/ref&gt; ezisetjenziswako zokukhuthaza ukufaka woke umuntu emasikweni namalimi:

* i-Sepedi
* i-Sesotho
* i-Setswana 
* i-siSwati
* i-Tshivenda 
* i-Xitsonga 
* i-Afrikaans
* isiNgisi
* isiXhosa
* isiZulu 
* isiNdebele 
* kanye nelimi lezandla leSewula Afrika (SASL) 

Ukufunda&lt;ref&gt;[https://www.discover-the-world.com/study-trips/blog/why-learning-languages-is-important/ 10 Reasons Why Learning Languages Is Important for Everyone]&lt;/ref&gt; amalimi kuthuthukisa ukuzwisisa amasiko, amakghono wokucabanga, ukukhula komuntu mathupha nokwenza kube likghono eliqakathekileko enarheni yethu ehlanganeko.</text>
      <sha1>k4wxl5xknjuukuj86qfknagboenv38z</sha1>
    </revision>
  </page>
  <page>
    <title>Umakoti</title>
    <ns>0</ns>
    <id>1196</id>
    <revision>
      <id>6709</id>
      <timestamp>2026-06-12T10:47:55Z</timestamp>
      <contributor>
        <username>MissHadassah</username>
        <id>1561</id>
      </contributor>
      <comment>I defined a term</comment>
      <origin>6709</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="507" sha1="0ym604dmt17twt9j1i31d93ja1edm06" xml:space="preserve">[[Isimumathi:Ndebele Village Woman blowing in a horn.jpg|thumb|abafazi bamandebele ]]
'''uMalukuzana''' ngumfazi otjhadileko, begodu [[Umtjhado|otjhadileko]]&lt;ref&gt;[https://universvoyage.com/en/ndebele-of-engagement-and-ritual-nuptials/ Ndebele: ritual engagement and wedding - Univers Voyage]&lt;/ref&gt;&lt;ref&gt;[https://ibiene.com/culture/the-wedding-ceremony-of-the-ndebele/ The wedding ceremony of the Ndebele…. – Ibiene Magazine]&lt;/ref&gt; ngokuya ''ngesiko''  [[Umtjhado wesiNdebele isimanje|othjade ngesimanje]]</text>
      <sha1>0ym604dmt17twt9j1i31d93ja1edm06</sha1>
    </revision>
  </page>
  <page>
    <title>Umgodi</title>
    <ns>0</ns>
    <id>1197</id>
    <revision>
      <id>6710</id>
      <timestamp>2026-06-13T10:44:01Z</timestamp>
      <contributor>
        <username>Nozi2026</username>
        <id>1567</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1336386737|Borehole]]&quot;</comment>
      <origin>6710</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7822" sha1="0oegb82noo65bcry2q7r4i0q50t6r9x" xml:space="preserve">
[[Isimumathi:Borewell_digging.jpg|thumb|Ukwemba umgodi womgodi namkha umthombo wetjhubhu]]
[[Isimumathi:Borewell_digging.ogv|thumb| Ukumba umgodi]]
[[Isimumathi:Drilling_boreholes_for_clean_water_(9084603915).jpg|thumb|Owesifazana owe-Uganda uqoqa amanzi emgodini kanye nepompi yezandla enamathiselwe]]
[[Isimumathi:Borehole_01.jpg|thumb|Umthombo obhojiweko e-Ghana; umgodi awubonakali]]
'''Umgodi'''  omncane obhojwe phansi, kungaba ngokuthe nqo nofana ngokuvundlileko. Umgodi ungakhiwa ngenhloso ezinengi ezihlukahlukeneyo, kugoqela okufaka lokokukhipha amanzi ( umthombo wamanzi obhojiweko nomthombo wetjhubhu ), ezinye izinto  (ezifana ne -petroleum ), nofana lamagesi (njengegesi yemvelo ). Kungaba yingxenye yophenyo lwe-geotechnical, ukuhlolwa kwendawo yebhoduluko, ukuhlolwa kwamaminerali, ukulinganisa amazinga womtjhiso, njengomgodi wokulinga wokufaka amapayipi nofana lezisetshenziswayo ezingaphasi kwehlabathi, ukufakwa kwe-geothermal, nofana ukubulungwa ngaphasi kwehlabathi kwezinto ezingafunekiyo.

== Ukuqakatheka ==
[[Isimumathi:AlburyBoreHole.jpg|right|thumb|Umgodi wemithombo yamanzi eya e- chalk aquifer ngaphasi kwe- North Downs, e-England e -Albury]]
Omanjinela nabacebisi bezebhoduluko basebenzisa ibizo elithi ''umgodi'' ukuhlathulula ngokuhlanganyela yonke imihlobo ehlukileyo yemigodi ebhojiweko njengengcenye yophenyo lwe-geotechnical nofana ukuhlolwa kwendawo yezebhoduluko (okubizwa ngokuthi yi-Phase II ESA). Lokhu kufaka  imigodi ethuthukisiweko ukubuthelela amasampula wehlabathi, amasampula amanzi kumbe amadwala, ukuthuthukisa imitjhini yokuthatha amasampula ''endaweni'', nofana ukufaka imithombo yokutjheja nofana ama-piezometers . Amasampula abuthelelwe emigodini avamise ukuhlolwa elabhorethari ukuthola ubujamo bawo, nofana ukuhlola amazinga wamakhemikhali ahlukahlukeneko nofana izinto ezisilaphazako.

Ngokuvamileko, umgodi osetshenziswa njengomthombo wamanzi uqedwa ngokufaka ipayipi ejame ngqo (ikheyisi) nesikrini somthombo ukuvikela umgodi bona ungabhidli. Lokhu godu kusiza ukukhandela ukusilaphazeka kwephasi bona kungangeni emgodini begodu kuvikela nanyana ngiyiphi ipompo efakiweko bona ingadosi isihlabathi nenhlabathi. Imithombo yamafutha negesi yemvelo yenziwa ngendlela efanayo, nanyana ivamise ukuba yinkimbinkimbi.

Njengombana kuvezwe ngokunabileko ku- proxy (isimo sezulu), ukulinganisa amazinga womtjhiso we-borehole emlandweni wokujula okuhlukileko kunga &quot; guqulwa &quot; (ifomula yeembalo yokurarulula i-ikhweshini ye-matrix) ukusiza ukulinganisa amazinga womtjhiso wendawo yomlando.

Amaqoqo wemigodi emincani enendlela zokutshiswa ezenziwe ngepayipi yeplastiki ye-PEX ingasetshenziselwa ukugcina ukutshisa kumbe amakhaza hlangana neenkhathi eziphikisanako ngaphakathi kwamatje wemvelo. Indlela le ibizwa ngokuthi kugcinwa kwamandla womtjhiso ngesikhathi sonyaka . Iindaba ezingasetshenziselwa iqhinga leli zisukela ematjeni ukuya edwaleni. Kungaba nama-borehole ambalwa ukuya kwamakhulu amanengi, begodu ngokwenza, ukujula kwawo kusuka ku 50 to 300 metres (150 to 1,000 ft) .  

== Umlando ==
Ukubhoboza umgodi kunomlando omude. Okungenani ngobukhosi be-Han dynasty (202&amp;nbsp;BC&amp;nbsp;– 220&amp;nbsp;AD), amaTjhayina asebenzisa ukubhora umgodi ojulileko malungana nokumba namanye amaphrojekthi. Isazi se-sinology nesazi-mlando se-Britain u-Michael Loewe uthi indawo zokubhoboza zingafikelela emamitheni 600 metres (2,000 ft) .  U-KS Tom uchaza ikambiso yokubhora: &quot;Indlela yamaTjhayina yokubhora ngokujulileko yenziwa lithimba lamadoda ebeligxuma phezulu begodu liphume emgogodleni ukobana lithinte isiqephu sokubhora ngesikhathi ithuluzi lokubhora lijikeleziswa zinyathi nenkomo.&quot;  Le bekuyindlela efanako esetshenziselwa ukukhipha i-petroleum e -California ngeminyaka yabo-1860 (okutjho &quot;ukumkhahlela phansi&quot;). &lt;ref name=&quot;tom 1989 103&quot; /&gt;  I-Western Han dynasty bronze foundry eyatholwa e-Xinglong, e-Hebei gade inemigodi yemayini eseduze eyafikelela ekujuleni kwamamitha 100 metres (330 ft) eneendawo ezivulekileko zemayini; amashafthi namagumbi bekaphelele ngefreyimu yamapulangwe, amaladi namathulusi wensimbi.   Ngekhulu lokuthoma leminyaka BC, abasebenzi bezandla be-China ababhora ngensimbi kanye nababhora bebakghona ukubhora imigodi efika 1,500 metres (4,900 ft) ukutjhinga.    Ngekhulu leminyaka elitshumi lanye AD, amaTjhayina bekakwazi ukubhora imigodi efika 900 metres (3,000 ft) ngokujula. Ukubhora imigodi bekuthatha isikhathi eside begodu kuthatha isikhathi eside. Njengombana ukujula kwemigodi bekuhlukahluka, ukubhoboza umthombo munye bekungathatha iminyaka elitshumi.  Kwaze kwaba ngekhulu leminyaka ye-19 lapho i-Europe neTjingalanga zizokuthola begodu zincintisane nethekhnoloji yokubhora imigodi ye-China yakade. &lt;ref name=&quot;Conner 2005 175&quot; /&gt; &lt;ref name=&quot;Hobson 2004 215&quot; /&gt;

Kwaphela iminyaka eminengi, umgodi omude kakhulu ephasini bekuyi- Kola Superdeep Borehole e-Russia. Kusukela ngomnyaka ka-2011 bekube nguRhoboyi wee-2012 irekhodi belibanjwe li- 12,345-metre (40,502 ft) ubude i-Sakhalin-I Odoptu OP-11 Kuhlekuhle, eduze nelwandle lesihlengele se-Russia i-Sakhalin .  Umthombo we -Chayvo Z-44 ofinyeleleka khulu wathatha isikhundla somgodi omude khulu ephasini mhlazi-27 kuRhoboyi wee-2012. Ukujula okulinganisiweyo kwe-Z-44 kungamamitha 12,376 metres (40,604 ft) . Kodwana, imithombo ye-ERD ayijulile ukudlula i-Kola Borehole, ngebanga lokufuduka okukhulu okuvundlileyo. NgoJulayi 2023, i-China yaqala ukubhora imigodi etjhingako, enye e- Sichuan Basin kulindeleke bona ifinyelele 10,520 metres (34,510 ft) phasi begodu enye ise- Tarim Basin ngokujula okuhleliweko 11,100 metres (36,400 ft) .  

== Indlela yokusebenza ==
&lt;templatestyles src=&quot;Module:Hatnote/styles.css&quot;&gt;&lt;/templatestyles&gt; 
Ababholi bangacwilisa umgodi basebenzisa i -drill rig nofana i-rig esetshenziswa ngesandla. Imitshini namathekhnikhi wokuthuthukisa umgodi ayahluka kakhulu ngokuya ngomenzi, ubujamo bezesayensi, kanye nehloso ehlosiweko. Ukubhora elwandle amayunithi antantako nofana amaplatifomu asekelwa phansi kwelwandle asetshenziselwa ukubhora.
[[Isimumathi:Borehole-Manual-Digging-Process-2050-Paris.jpg|thumb|Abantu ababili abagebha umgodi bemba umgodi ngezandla]]
lkakhulu emazweni asathuthuka imigodi eminengi isagejwa ngezandla. Ukwemba kuqala ngomsebenzi wezandla kusetshenziswa amathulusi asisekelo afana namafosholo, amapiki, kanye nama-crowbar. Abasebenzi bemba ihlabathi ngesendlalelo ngesendlalelo, kanengi basebenzisa ukunyakaza okuyindilinga ukwenza umgodi omiswe kuhle. Ikambiso le ibuthakathaka begodu itlhoga, ifuna ukusebenzisana kwesiqhema nokusebenzisana. Ukukhandela bona amabhoda angawi begodu nokuqinisekisa ikhwalithi yamanzi, umgodi ufakwe izinto ezifana nezitina, amatshe, nofana amasongo wekhonkrithi. Ukuqiniswa lokhu kugcina ubuqotho besakhiwo somgodi begodu kusiza ukukhandela ukusilaphazeka. Ipulatifomu yekhonkrithi nofana ilebhu ingafakwa phansi ukukhandela bona inkunkuma ingangeni emanzini. Ingaphezulu lomgodi livalwe ukuwuvikela ekungcolisweni nokusilaphazeka. 

== Qala godu ==

* I-Askam Borehole e-Pennsylvania
* Umsiki wekheyisi
* Ukulahlwa kwemigodi etjhingako
* Isivuli somgodi
* Ukulahlwa komgodi ovundlileko
* I-Kola Superdeep Borehole
* Iphrofayili yokuzamazama komhlaba

== Iinkomba ==
&lt;templatestyles src=&quot;Reflist/styles.css&quot; /&gt;

== Amalinki wangaphandle ==
&lt;templatestyles src=&quot;Module:Side box/styles.css&quot;&gt;&lt;/templatestyles&gt;&lt;templatestyles src=&quot;Sister project/styles.css&quot;&gt;&lt;/templatestyles&gt; 

https://webapps.usgs.gov/nibi/&lt;templatestyles src=&quot;Module:Side box/styles.css&quot;&gt;&lt;/templatestyles&gt;&lt;templatestyles src=&quot;Sister project/styles.css&quot;&gt;&lt;/templatestyles&gt;

* [https://web.archive.org/web/20200920064331/https://www.geologieportal.ch/en/themes/fundamentals-of-geology/boreholes.html Imigodi: I-Swiss Geological Survey]
{{Geotechnical engineering|state=collapsed}}{{Man-made and man-related Subterranea}}</text>
      <sha1>0oegb82noo65bcry2q7r4i0q50t6r9x</sha1>
    </revision>
    <revision>
      <id>6711</id>
      <parentid>6710</parentid>
      <timestamp>2026-06-13T11:17:20Z</timestamp>
      <contributor>
        <username>Nozi2026</username>
        <id>1567</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1336386737|Borehole]]&quot;</comment>
      <origin>6711</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7825" sha1="qqeadayexvku0rl8zudwo2ancxymu3t" xml:space="preserve">
[[Isimumathi:Borewell_digging.jpg|thumb|Ukwemba umgodi womgodi namkha umthombo wetjhubhu]]
[[Isimumathi:Borewell_digging.ogv|thumb| Ukumba umgodi]]
[[Isimumathi:Drilling_boreholes_for_clean_water_(9084603915).jpg|thumb|Owesifazana owe-Uganda uqoqa amanzi emgodini kanye nepompi yezandla enamathiselwe]]
[[Isimumathi:Borehole_01.jpg|thumb|Umthombo obhojiweko e-Ghana; umgodi awubonakali]]
'''Umgodi'''  omncane obhojwe phansi, kungaba ngokuthe nqo nofana ngokuvundlileko. Umgodi ungakhiwa ngenhloso ezinengi ezihlukahlukeneyo, kugoqela okufaka lokokukhipha amanzi ( umthombo wamanzi obhojiweko nomthombo wetjhubhu ), ezinye izinto  (ezifana ne -petroleum ), nofana lamagesi (njengegesi yemvelo ). Kungaba yingxenye yophenyo lwe-geotechnical, ukuhlolwa kwendawo yebhoduluko, ukuhlolwa kwamaminerali, ukulinganisa amazinga womtjhiso, njengomgodi wokulinga wokufaka amapayipi nofana lezisetshenziswayo ezingaphasi kwehlabathi, ukufakwa kwe-geothermal, nofana ukubulungwa ngaphasi kwehlabathi kwezinto ezingafunekiyo.

== Ukuqakatheka ==
[[Isimumathi:AlburyBoreHole.jpg|right|thumb|Umgodi wemithombo yamanzi eya e- chalk aquifer ngaphasi kwe- North Downs, e-England e -Albury]]
Omanjinela nabacebisi bezebhoduluko basebenzisa ibizo elithi ''umgodi'' ukuhlathulula ngokuhlanganyela yonke imihlobo ehlukileyo yemigodi ebhojiweko njengengcenye yophenyo lwe-geotechnical nofana ukuhlolwa kwendawo yezebhoduluko (okubizwa ngokuthi yi-Phase II ESA). Lokhu kufaka  imigodi ethuthukisiweko ukubuthelela amasampula wehlabathi, amasampula amanzi kumbe amadwala, ukuthuthukisa imitjhini yokuthatha amasampula ''endaweni'', nofana ukufaka imithombo yokutjheja nofana ama-piezometers . Amasampula abuthelelwe emigodini avamise ukuhlolwa elabhorethari ukuthola ubujamo bawo, nofana ukuhlola amazinga wamakhemikhali ahlukahlukeneko nofana izinto ezisilaphazako.

Ngokuvamileko, umgodi osetshenziswa njengomthombo wamanzi uqedwa ngokufaka ipayipi ejame ngqo (ikheyisi) nesikrini somthombo ukuvikela umgodi bona ungabhidli. Lokhu godu kusiza ukukhandela ukusilaphazeka kwephasi bona kungangeni emgodini begodu kuvikela nanyana ngiyiphi ipompo efakiweko bona ingadosi isihlabathi nenhlabathi. Imithombo yamafutha negesi yemvelo yenziwa ngendlela efanayo, nanyana ivamise ukuba yinkimbinkimbi.

Njengombana kuvezwe ngokunabileko ku- proxy (isimo sezulu), ukulinganisa amazinga womtjhiso we-borehole emlandweni wokujula okuhlukileko kunga &quot; guqulwa &quot; (ifomula yeembalo yokurarulula i-ikhweshini ye-matrix) ukusiza ukulinganisa amazinga womtjhiso wendawo yomlando.

Amaqoqo wemigodi emincani enendlela zokutshiswa ezenziwe ngepayipi yeplastiki ye-PEX ingasetshenziselwa ukugcina ukutshisa kumbe amakhaza hlangana neenkhathi eziphikisanako ngaphakathi kwamatje wemvelo. Indlela le ibizwa ngokuthi kugcinwa kwamandla womtjhiso ngesikhathi sonyaka . Iindaba ezingasetshenziselwa iqhinga leli zisukela ematjeni ukuya edwaleni. Kungaba nama-borehole ambalwa ukuya kwamakhulu amanengi, begodu ngokwenza, ukujula kwawo kusuka ku 50 to 300 metres (150 to 1,000 ft) .  

== Umlando ==
Ukubhoboza umgodi kunomlando omude. Okungenani ngobukhosi be-Han dynasty (202&amp;nbsp;BC&amp;nbsp;– 220&amp;nbsp;AD), amaTjhayina asebenzisa ukubhora umgodi ojulileko malungana nokumba namanye amaphrojekthi. Isazi se-sinology nesazi-mlando se-Britain u-Michael Loewe uthi indawo zokubhoboza zingafikelela emamitheni 600 metres (2,000 ft) .  U-KS Tom uchaza ikambiso yokubhora: &quot;Indlela yamaTjhayina yokubhora ngokujulileko yenziwa lithimba lamadoda ebeligxuma phezulu begodu liphume emgogodleni ukobana lithinte isiqephu sokubhora ngesikhathi ithuluzi lokubhora lijikeleziswa zinyathi nenkomo.&quot;  Le bekuyindlela efanako esetshenziselwa ukukhipha i-petroleum e -California ngeminyaka yabo-1860 (okutjho &quot;ukumkhahlela phansi&quot;). &lt;ref name=&quot;tom 1989 103&quot; /&gt;  I-Western Han dynasty bronze foundry eyatholwa e-Xinglong, e-Hebei gade inemigodi yemayini eseduze eyafikelela ekujuleni kwamamitha 100 metres (330 ft) eneendawo ezivulekileko zemayini; amashafthi namagumbi bekaphelele ngefreyimu yamapulangwe, amaladi namathulusi wensimbi.   Ngekhulu lokuthoma leminyaka BC, abasebenzi bezandla be-China ababhora ngensimbi kanye nababhora bebakghona ukubhora imigodi efika 1,500 metres (4,900 ft) ukutjhinga.    Ngekhulu leminyaka elitshumi lanye AD, amaTjhayina bekakwazi ukubhora imigodi efika 900 metres (3,000 ft) ngokujula. Ukubhora imigodi bekuthatha isikhathi eside begodu kuthatha isikhathi eside. Njengombana ukujula kwemigodi bekuhlukahluka, ukubhoboza umthombo munye bekungathatha iminyaka elitshumi.  Kwaze kwaba ngekhulu leminyaka ye-19 lapho i-Europe neTjingalanga zizokuthola begodu zincintisane nethekhnoloji yokubhora imigodi ye-China yakade. &lt;ref name=&quot;Conner 2005 175&quot; /&gt; &lt;ref name=&quot;Hobson 2004 215&quot; /&gt;

Kwaphela iminyaka eminengi, umgodi omude kakhulu ephasini bekuyi- Kola Superdeep Borehole e-Russia. Kusukela ngomnyaka ka-2011 bekube nguRhoboyi wee-2012 irekhodi belibanjwe li- 12,345-metre (40,502 ft) ubude i-Sakhalin-I Odoptu OP-11 Kuhlekuhle, eduze nelwandle lesihlengele se-Russia i-Sakhalin .  Umthombo we -Chayvo Z-44 ofinyeleleka khulu wathatha isikhundla somgodi omude khulu ephasini mhlazi-27 kuRhoboyi wee-2012. Ukujula okulinganisiweyo kwe-Z-44 kungamamitha 12,376 metres (40,604 ft) . Kodwana, imithombo ye-ERD ayijulile ukudlula i-Kola Borehole, ngebanga lokufuduka okukhulu okuvundlileyo. NgoJulayi 2023, i-China yaqala ukubhora imigodi etjhingako, enye e- Sichuan Basin kulindeleke bona ifinyelele 10,520 metres (34,510 ft) phasi begodu enye ise- Tarim Basin ngokujula okuhleliweko 11,100 metres (36,400 ft) .  

== Indlela yokusebenza ==
&lt;templatestyles src=&quot;Module:Hatnote/styles.css&quot;&gt;&lt;/templatestyles&gt; 
Ababholi bangacwilisa umgodi basebenzisa i -drill rig nofana i-rig esetshenziswa ngesandla. Imitshini namathekhnikhi wokuthuthukisa umgodi ayahluka kakhulu ngokuya ngomenzi, ubujamo bezesayensi, kanye nehloso ehlosiweko. Ukubhora elwandle amayunithi antantako nofana amaplatifomu asekelwa phansi kwelwandle asetshenziselwa ukubhora.
[[Isimumathi:Borehole-Manual-Digging-Process-2050-Paris.jpg|thumb|Abantu ababili abagebha umgodi bemba umgodi ngezandla]]
lkakhulu emazweni asathuthuka imigodi eminengi isagejwa ngezandla. Ukwemba kuqala ngomsebenzi wezandla kusetshenziswa amathulusi asisekelo afana namafosholo, amapiki, kanye nama-crowbar. Abasebenzi bemba ihlabathi ngesendlalelo ngesendlalelo, kanengi basebenzisa ukunyakaza okuyindilinga ukwenza umgodi omiswe kuhle. Ikambiso le ibuthakathaka begodu itlhoga, ifuna ukusebenzisana kwesiqhema nokusebenzisana. Ukukhandela bona amabhoda angawi begodu nokuqinisekisa ikhwalithi yamanzi, umgodi ufakwe izinto ezifana nezitina, amatshe, nofana amasongo wekhonkrithi. Ukuqiniswa lokhu kugcina ubuqotho besakhiwo somgodi begodu kusiza ukukhandela ukusilaphazeka. Ipulatifomu yekhonkrithi nofana ilebhu ingafakwa phansi ukukhandela bona inkunkuma ingangeni emanzini. Ingaphezulu lomgodi livalwe ukuwuvikela ekungcolisweni nokusilaphazeka. 

== Qala godu ==

* I-Askam Borehole e-Pennsylvania
* Umsiki wekheyisi
* Ukulahlwa kwemigodi etjhingako
* Isivuli somgodi
* Ukulahlwa komgodi ovundlileko
* I-Kola Superdeep Borehole
* Iphrofayili yokuzamazama komhlaba

== Iinkomba ==
&lt;templatestyles src=&quot;Reflist/styles.css&quot; /&gt;

#

== Amalinki wangaphandle ==
&lt;templatestyles src=&quot;Module:Side box/styles.css&quot;&gt;&lt;/templatestyles&gt;&lt;templatestyles src=&quot;Sister project/styles.css&quot;&gt;&lt;/templatestyles&gt; 

https://webapps.usgs.gov/nibi/&lt;templatestyles src=&quot;Module:Side box/styles.css&quot;&gt;&lt;/templatestyles&gt;&lt;templatestyles src=&quot;Sister project/styles.css&quot;&gt;&lt;/templatestyles&gt;

* [https://web.archive.org/web/20200920064331/https://www.geologieportal.ch/en/themes/fundamentals-of-geology/boreholes.html Imigodi: I-Swiss Geological Survey]
{{Geotechnical engineering|state=collapsed}}{{Man-made and man-related Subterranea}}</text>
      <sha1>qqeadayexvku0rl8zudwo2ancxymu3t</sha1>
    </revision>
    <revision>
      <id>6712</id>
      <parentid>6711</parentid>
      <timestamp>2026-06-13T11:29:27Z</timestamp>
      <contributor>
        <username>Nozi2026</username>
        <id>1567</id>
      </contributor>
      <minor />
      <comment>Umthombo wolwazi#AWC2026</comment>
      <origin>6712</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8093" sha1="3jx6y9nbote1jud8jxzqplvj4qx9eqf" xml:space="preserve">
[[Isimumathi:Borewell_digging.jpg|thumb|Ukwemba umgodi womgodi namkha umthombo wetjhubhu]]
[[Isimumathi:Borewell_digging.ogv|thumb| Ukumba umgodi]]
[[Isimumathi:Drilling_boreholes_for_clean_water_(9084603915).jpg|thumb|Owesifazana owe-Uganda uqoqa amanzi emgodini kanye nepompi yezandla enamathiselwe]]
[[Isimumathi:Borehole_01.jpg|thumb|Umthombo obhojiweko e-Ghana; umgodi awubonakali]]
'''Umgodi'''  omncane obhojwe phansi, kungaba ngokuthe nqo nofana ngokuvundlileko. Umgodi ungakhiwa ngenhloso ezinengi ezihlukahlukeneyo, kugoqela okufaka lokokukhipha amanzi ( umthombo wamanzi obhojiweko nomthombo wetjhubhu ), ezinye izinto  (ezifana ne -petroleum ), nofana lamagesi (njengegesi yemvelo ). Kungaba yingxenye yophenyo lwe-geotechnical, ukuhlolwa kwendawo yebhoduluko, ukuhlolwa kwamaminerali, ukulinganisa amazinga womtjhiso, njengomgodi wokulinga wokufaka amapayipi nofana lezisetshenziswayo ezingaphasi kwehlabathi, ukufakwa kwe-geothermal, nofana ukubulungwa ngaphasi kwehlabathi kwezinto ezingafunekiyo.

== Ukuqakatheka ==
[[Isimumathi:AlburyBoreHole.jpg|right|thumb|Umgodi wemithombo yamanzi eya e- chalk aquifer ngaphasi kwe- North Downs, e-England e -Albury]]
Omanjinela nabacebisi bezebhoduluko basebenzisa ibizo elithi ''umgodi'' ukuhlathulula ngokuhlanganyela yonke imihlobo ehlukileyo yemigodi ebhojiweko njengengcenye yophenyo lwe-geotechnical nofana ukuhlolwa kwendawo yezebhoduluko (okubizwa ngokuthi yi-Phase II ESA). Lokhu kufaka  imigodi ethuthukisiweko ukubuthelela amasampula wehlabathi, amasampula amanzi kumbe amadwala, ukuthuthukisa imitjhini yokuthatha amasampula ''endaweni'', nofana ukufaka imithombo yokutjheja nofana ama-piezometers . Amasampula abuthelelwe emigodini avamise ukuhlolwa elabhorethari ukuthola ubujamo bawo, nofana ukuhlola amazinga wamakhemikhali ahlukahlukeneko nofana izinto ezisilaphazako.

Ngokuvamileko, umgodi osetshenziswa njengomthombo wamanzi uqedwa ngokufaka ipayipi ejame ngqo (ikheyisi) nesikrini somthombo ukuvikela umgodi bona ungabhidli. Lokhu godu kusiza ukukhandela ukusilaphazeka kwephasi bona kungangeni emgodini begodu kuvikela nanyana ngiyiphi ipompo efakiweko bona ingadosi isihlabathi nenhlabathi. Imithombo yamafutha negesi yemvelo yenziwa ngendlela efanayo, nanyana ivamise ukuba yinkimbinkimbi.

Njengombana kuvezwe ngokunabileko ku- proxy (isimo sezulu), ukulinganisa amazinga womtjhiso we-borehole emlandweni wokujula okuhlukileko kunga &quot; guqulwa &quot; (ifomula yeembalo yokurarulula i-ikhweshini ye-matrix) ukusiza ukulinganisa amazinga womtjhiso wendawo yomlando.

Amaqoqo wemigodi emincani enendlela zokutshiswa ezenziwe ngepayipi yeplastiki ye-PEX ingasetshenziselwa ukugcina ukutshisa kumbe amakhaza hlangana neenkhathi eziphikisanako ngaphakathi kwamatje wemvelo. Indlela le ibizwa ngokuthi kugcinwa kwamandla womtjhiso ngesikhathi sonyaka . Iindaba ezingasetshenziselwa iqhinga leli zisukela ematjeni ukuya edwaleni. Kungaba nama-borehole ambalwa ukuya kwamakhulu amanengi, begodu ngokwenza, ukujula kwawo kusuka ku 50 to 300 metres (150 to 1,000 ft) .&lt;ref&gt;Hellström G. (2008). Large-Scale Applications of Ground-Source Heat Pumps in Sweden. IEA HP Annex 29 Workshop, Zurich, May 19, 2008.&lt;/ref&gt;  

== Umlando ==
Ukubhoboza umgodi kunomlando omude. Okungenani ngobukhosi be-Han dynasty (202&amp;nbsp;BC&amp;nbsp;– 220&amp;nbsp;AD), amaTjhayina asebenzisa ukubhora umgodi ojulileko malungana nokumba namanye amaphrojekthi. Isazi se-sinology nesazi-mlando se-Britain u-Michael Loewe uthi indawo zokubhoboza zingafikelela emamitheni 600 metres (2,000 ft) .&lt;ref&gt;Loewe (1968), 194&lt;/ref&gt;  U-KS Tom uchaza ikambiso yokubhora: &quot;Indlela yamaTjhayina yokubhora ngokujulileko yenziwa lithimba lamadoda ebeligxuma phezulu begodu liphume emgogodleni ukobana lithinte isiqephu sokubhora ngesikhathi ithuluzi lokubhora lijikeleziswa zinyathi nenkomo.&quot;  Le bekuyindlela efanako esetshenziselwa ukukhipha i-petroleum e -California ngeminyaka yabo-1860 (okutjho &quot;ukumkhahlela phansi&quot;).   I-Western Han dynasty bronze foundry eyatholwa e-Xinglong, e-Hebei gade inemigodi yemayini eseduze eyafikelela ekujuleni kwamamitha 100 metres (330 ft) eneendawo ezivulekileko zemayini; amashafthi namagumbi bekaphelele ngefreyimu yamapulangwe, amaladi namathulusi wensimbi.   Ngekhulu lokuthoma leminyaka BC, abasebenzi bezandla be-China ababhora ngensimbi kanye nababhora bebakghona ukubhora imigodi efika 1,500 metres (4,900 ft) ukutjhinga.    Ngekhulu leminyaka elitshumi lanye AD, amaTjhayina bekakwazi ukubhora imigodi efika 900 metres (3,000 ft) ngokujula. Ukubhora imigodi bekuthatha isikhathi eside begodu kuthatha isikhathi eside. Njengombana ukujula kwemigodi bekuhlukahluka, ukubhoboza umthombo munye bekungathatha iminyaka elitshumi.  Kwaze kwaba ngekhulu leminyaka ye-19 lapho i-Europe neTjingalanga zizokuthola begodu zincintisane nethekhnoloji yokubhora imigodi ye-China yakade.  

Kwaphela iminyaka eminengi, umgodi omude kakhulu ephasini bekuyi- Kola Superdeep Borehole e-Russia. Kusukela ngomnyaka ka-2011 bekube nguRhoboyi wee-2012 irekhodi belibanjwe li- 12,345-metre (40,502 ft) ubude i-Sakhalin-I Odoptu OP-11 Kuhlekuhle, eduze nelwandle lesihlengele se-Russia i-Sakhalin .  Umthombo we -Chayvo Z-44 ofinyeleleka khulu wathatha isikhundla somgodi omude khulu ephasini mhlazi-27 kuRhoboyi wee-2012. Ukujula okulinganisiweyo kwe-Z-44 kungamamitha 12,376 metres (40,604 ft) . Kodwana, imithombo ye-ERD ayijulile ukudlula i-Kola Borehole, ngebanga lokufuduka okukhulu okuvundlileyo. NgoJulayi 2023, i-China yaqala ukubhora imigodi etjhingako, enye e- Sichuan Basin kulindeleke bona ifinyelele 10,520 metres (34,510 ft) phasi begodu enye ise- Tarim Basin ngokujula okuhleliweko 11,100 metres (36,400 ft) .&lt;ref&gt;Hellström G. (2008). Large-Scale Applications of Ground-Source Heat Pumps in Sweden. IEA HP Annex 29 Workshop, Zurich, May 19, 2008.&lt;/ref&gt;&lt;ref&gt;Stiles, Lynn (June 1998). &quot;Underground thermal energy storage in the US&quot;. ''IEA Heat Pump Centre Newsletter''. '''16''' (2): 22–23.&lt;/ref&gt;  

== Indlela yokusebenza ==
 Ababholi bangacwilisa umgodi basebenzisa i -drill rig nofana i-rig esetshenziswa ngesandla. Imitshini namathekhnikhi wokuthuthukisa umgodi ayahluka kakhulu ngokuya ngomenzi, ubujamo bezesayensi, kanye nehloso ehlosiweko. Ukubhora elwandle amayunithi antantako nofana amaplatifomu asekelwa phansi kwelwandle asetshenziselwa ukubhora.
[[Isimumathi:Borehole-Manual-Digging-Process-2050-Paris.jpg|thumb|Abantu ababili abagebha umgodi bemba umgodi ngezandla]]
lkakhulu emazweni asathuthuka imigodi eminengi isagejwa ngezandla. Ukwemba kuqala ngomsebenzi wezandla kusetshenziswa amathulusi asisekelo afana namafosholo, amapiki, kanye nama-crowbar. Abasebenzi bemba ihlabathi ngesendlalelo ngesendlalelo, kanengi basebenzisa ukunyakaza okuyindilinga ukwenza umgodi omiswe kuhle. Ikambiso le ibuthakathaka begodu itlhoga, ifuna ukusebenzisana kwesiqhema nokusebenzisana. Ukukhandela bona amabhoda angawi begodu nokuqinisekisa ikhwalithi yamanzi, umgodi ufakwe izinto ezifana nezitina, amatshe, nofana amasongo wekhonkrithi. Ukuqiniswa lokhu kugcina ubuqotho besakhiwo somgodi begodu kusiza ukukhandela ukusilaphazeka. Ipulatifomu yekhonkrithi nofana ilebhu ingafakwa phansi ukukhandela bona inkunkuma ingangeni emanzini. Ingaphezulu lomgodi livalwe ukuwuvikela ekungcolisweni nokusilaphazeka. 

== Qala godu ==

* I-Askam Borehole e-Pennsylvania
* Umsiki wekheyisi
* Ukulahlwa kwemigodi etjhingako
* Isivuli somgodi
* Ukulahlwa komgodi ovundlileko
* I-Kola Superdeep Borehole
* Iphrofayili yokuzamazama komhlaba

== Umthombo wolwazi ==

== Amalinki wangaphandle ==
&lt;templatestyles src=&quot;Module:Side box/styles.css&quot;&gt;&lt;/templatestyles&gt;&lt;templatestyles src=&quot;Sister project/styles.css&quot;&gt;&lt;/templatestyles&gt; 

https://webapps.usgs.gov/nibi/&lt;templatestyles src=&quot;Module:Side box/styles.css&quot;&gt;&lt;/templatestyles&gt;&lt;templatestyles src=&quot;Sister project/styles.css&quot;&gt;&lt;/templatestyles&gt;

* [https://web.archive.org/web/20200920064331/https://www.geologieportal.ch/en/themes/fundamentals-of-geology/boreholes.html Imigodi: I-Swiss Geological Survey]
{{Geotechnical engineering|state=collapsed}}{{Man-made and man-related Subterranea}}</text>
      <sha1>3jx6y9nbote1jud8jxzqplvj4qx9eqf</sha1>
    </revision>
    <revision>
      <id>6713</id>
      <parentid>6712</parentid>
      <timestamp>2026-06-13T11:30:22Z</timestamp>
      <contributor>
        <username>Nozi2026</username>
        <id>1567</id>
      </contributor>
      <minor />
      <origin>6713</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8237" sha1="5gst1tozdv0n0o1it7nvdbuvrf3j4qy" xml:space="preserve">
[[Isimumathi:Borewell_digging.jpg|thumb|Ukwemba umgodi womgodi namkha umthombo wetjhubhu]]
[[Isimumathi:Borewell_digging.ogv|thumb| Ukumba umgodi]]
[[Isimumathi:Drilling_boreholes_for_clean_water_(9084603915).jpg|thumb|Owesifazana owe-Uganda uqoqa amanzi emgodini kanye nepompi yezandla enamathiselwe]]
[[Isimumathi:Borehole_01.jpg|thumb|Umthombo obhojiweko e-Ghana; umgodi awubonakali]]
'''Umgodi'''  omncane obhojwe phansi, kungaba ngokuthe nqo nofana ngokuvundlileko. Umgodi ungakhiwa ngenhloso ezinengi ezihlukahlukeneyo, kugoqela okufaka lokokukhipha amanzi ( umthombo wamanzi obhojiweko nomthombo wetjhubhu ), ezinye izinto  (ezifana ne -petroleum ), nofana lamagesi (njengegesi yemvelo ). Kungaba yingxenye yophenyo lwe-geotechnical, ukuhlolwa kwendawo yebhoduluko, ukuhlolwa kwamaminerali, ukulinganisa amazinga womtjhiso, njengomgodi wokulinga wokufaka amapayipi nofana lezisetshenziswayo ezingaphasi kwehlabathi, ukufakwa kwe-geothermal, nofana ukubulungwa ngaphasi kwehlabathi kwezinto ezingafunekiyo.

== Ukuqakatheka ==
[[Isimumathi:AlburyBoreHole.jpg|right|thumb|Umgodi wemithombo yamanzi eya e- chalk aquifer ngaphasi kwe- North Downs, e-England e -Albury]]
Omanjinela nabacebisi bezebhoduluko basebenzisa ibizo elithi ''umgodi'' ukuhlathulula ngokuhlanganyela yonke imihlobo ehlukileyo yemigodi ebhojiweko njengengcenye yophenyo lwe-geotechnical nofana ukuhlolwa kwendawo yezebhoduluko (okubizwa ngokuthi yi-Phase II ESA). Lokhu kufaka  imigodi ethuthukisiweko ukubuthelela amasampula wehlabathi, amasampula amanzi kumbe amadwala, ukuthuthukisa imitjhini yokuthatha amasampula ''endaweni'', nofana ukufaka imithombo yokutjheja nofana ama-piezometers . Amasampula abuthelelwe emigodini avamise ukuhlolwa elabhorethari ukuthola ubujamo bawo, nofana ukuhlola amazinga wamakhemikhali ahlukahlukeneko nofana izinto ezisilaphazako.

Ngokuvamileko, umgodi osetshenziswa njengomthombo wamanzi uqedwa ngokufaka ipayipi ejame ngqo (ikheyisi) nesikrini somthombo ukuvikela umgodi bona ungabhidli. Lokhu godu kusiza ukukhandela ukusilaphazeka kwephasi bona kungangeni emgodini begodu kuvikela nanyana ngiyiphi ipompo efakiweko bona ingadosi isihlabathi nenhlabathi. Imithombo yamafutha negesi yemvelo yenziwa ngendlela efanayo, nanyana ivamise ukuba yinkimbinkimbi.

Njengombana kuvezwe ngokunabileko ku- proxy (isimo sezulu), ukulinganisa amazinga womtjhiso we-borehole emlandweni wokujula okuhlukileko kunga &quot; guqulwa &quot; (ifomula yeembalo yokurarulula i-ikhweshini ye-matrix) ukusiza ukulinganisa amazinga womtjhiso wendawo yomlando.

Amaqoqo wemigodi emincani enendlela zokutshiswa ezenziwe ngepayipi yeplastiki ye-PEX ingasetshenziselwa ukugcina ukutshisa kumbe amakhaza hlangana neenkhathi eziphikisanako ngaphakathi kwamatje wemvelo. Indlela le ibizwa ngokuthi kugcinwa kwamandla womtjhiso ngesikhathi sonyaka . Iindaba ezingasetshenziselwa iqhinga leli zisukela ematjeni ukuya edwaleni. Kungaba nama-borehole ambalwa ukuya kwamakhulu amanengi, begodu ngokwenza, ukujula kwawo kusuka ku 50 to 300 metres (150 to 1,000 ft) .&lt;ref&gt;Hellström G. (2008). Large-Scale Applications of Ground-Source Heat Pumps in Sweden. IEA HP Annex 29 Workshop, Zurich, May 19, 2008.&lt;/ref&gt;&lt;ref&gt;Stiles, Lynn (June 1998). &quot;Underground thermal energy storage in the US&quot;. ''IEA Heat Pump Centre Newsletter''. '''16''' (2): 22–23.&lt;/ref&gt;  

== Umlando ==
Ukubhoboza umgodi kunomlando omude. Okungenani ngobukhosi be-Han dynasty (202&amp;nbsp;BC&amp;nbsp;– 220&amp;nbsp;AD), amaTjhayina asebenzisa ukubhora umgodi ojulileko malungana nokumba namanye amaphrojekthi. Isazi se-sinology nesazi-mlando se-Britain u-Michael Loewe uthi indawo zokubhoboza zingafikelela emamitheni 600 metres (2,000 ft) .&lt;ref&gt;Loewe (1968), 194&lt;/ref&gt;  U-KS Tom uchaza ikambiso yokubhora: &quot;Indlela yamaTjhayina yokubhora ngokujulileko yenziwa lithimba lamadoda ebeligxuma phezulu begodu liphume emgogodleni ukobana lithinte isiqephu sokubhora ngesikhathi ithuluzi lokubhora lijikeleziswa zinyathi nenkomo.&quot;  Le bekuyindlela efanako esetshenziselwa ukukhipha i-petroleum e -California ngeminyaka yabo-1860 (okutjho &quot;ukumkhahlela phansi&quot;).   I-Western Han dynasty bronze foundry eyatholwa e-Xinglong, e-Hebei gade inemigodi yemayini eseduze eyafikelela ekujuleni kwamamitha 100 metres (330 ft) eneendawo ezivulekileko zemayini; amashafthi namagumbi bekaphelele ngefreyimu yamapulangwe, amaladi namathulusi wensimbi.   Ngekhulu lokuthoma leminyaka BC, abasebenzi bezandla be-China ababhora ngensimbi kanye nababhora bebakghona ukubhora imigodi efika 1,500 metres (4,900 ft) ukutjhinga.    Ngekhulu leminyaka elitshumi lanye AD, amaTjhayina bekakwazi ukubhora imigodi efika 900 metres (3,000 ft) ngokujula. Ukubhora imigodi bekuthatha isikhathi eside begodu kuthatha isikhathi eside. Njengombana ukujula kwemigodi bekuhlukahluka, ukubhoboza umthombo munye bekungathatha iminyaka elitshumi.  Kwaze kwaba ngekhulu leminyaka ye-19 lapho i-Europe neTjingalanga zizokuthola begodu zincintisane nethekhnoloji yokubhora imigodi ye-China yakade.  

Kwaphela iminyaka eminengi, umgodi omude kakhulu ephasini bekuyi- Kola Superdeep Borehole e-Russia. Kusukela ngomnyaka ka-2011 bekube nguRhoboyi wee-2012 irekhodi belibanjwe li- 12,345-metre (40,502 ft) ubude i-Sakhalin-I Odoptu OP-11 Kuhlekuhle, eduze nelwandle lesihlengele se-Russia i-Sakhalin .  Umthombo we -Chayvo Z-44 ofinyeleleka khulu wathatha isikhundla somgodi omude khulu ephasini mhlazi-27 kuRhoboyi wee-2012. Ukujula okulinganisiweyo kwe-Z-44 kungamamitha 12,376 metres (40,604 ft) . Kodwana, imithombo ye-ERD ayijulile ukudlula i-Kola Borehole, ngebanga lokufuduka okukhulu okuvundlileyo. NgoJulayi 2023, i-China yaqala ukubhora imigodi etjhingako, enye e- Sichuan Basin kulindeleke bona ifinyelele 10,520 metres (34,510 ft) phasi begodu enye ise- Tarim Basin ngokujula okuhleliweko 11,100 metres (36,400 ft) .&lt;ref&gt;Hellström G. (2008). Large-Scale Applications of Ground-Source Heat Pumps in Sweden. IEA HP Annex 29 Workshop, Zurich, May 19, 2008.&lt;/ref&gt;&lt;ref&gt;Stiles, Lynn (June 1998). &quot;Underground thermal energy storage in the US&quot;. ''IEA Heat Pump Centre Newsletter''. '''16''' (2): 22–23.&lt;/ref&gt;  

== Indlela yokusebenza ==
 Ababholi bangacwilisa umgodi basebenzisa i -drill rig nofana i-rig esetshenziswa ngesandla. Imitshini namathekhnikhi wokuthuthukisa umgodi ayahluka kakhulu ngokuya ngomenzi, ubujamo bezesayensi, kanye nehloso ehlosiweko. Ukubhora elwandle amayunithi antantako nofana amaplatifomu asekelwa phansi kwelwandle asetshenziselwa ukubhora.
[[Isimumathi:Borehole-Manual-Digging-Process-2050-Paris.jpg|thumb|Abantu ababili abagebha umgodi bemba umgodi ngezandla]]
lkakhulu emazweni asathuthuka imigodi eminengi isagejwa ngezandla. Ukwemba kuqala ngomsebenzi wezandla kusetshenziswa amathulusi asisekelo afana namafosholo, amapiki, kanye nama-crowbar. Abasebenzi bemba ihlabathi ngesendlalelo ngesendlalelo, kanengi basebenzisa ukunyakaza okuyindilinga ukwenza umgodi omiswe kuhle. Ikambiso le ibuthakathaka begodu itlhoga, ifuna ukusebenzisana kwesiqhema nokusebenzisana. Ukukhandela bona amabhoda angawi begodu nokuqinisekisa ikhwalithi yamanzi, umgodi ufakwe izinto ezifana nezitina, amatshe, nofana amasongo wekhonkrithi. Ukuqiniswa lokhu kugcina ubuqotho besakhiwo somgodi begodu kusiza ukukhandela ukusilaphazeka. Ipulatifomu yekhonkrithi nofana ilebhu ingafakwa phansi ukukhandela bona inkunkuma ingangeni emanzini. Ingaphezulu lomgodi livalwe ukuwuvikela ekungcolisweni nokusilaphazeka. 

== Qala godu ==

* I-Askam Borehole e-Pennsylvania
* Umsiki wekheyisi
* Ukulahlwa kwemigodi etjhingako
* Isivuli somgodi
* Ukulahlwa komgodi ovundlileko
* I-Kola Superdeep Borehole
* Iphrofayili yokuzamazama komhlaba

== Umthombo wolwazi ==

== Amalinki wangaphandle ==
&lt;templatestyles src=&quot;Module:Side box/styles.css&quot;&gt;&lt;/templatestyles&gt;&lt;templatestyles src=&quot;Sister project/styles.css&quot;&gt;&lt;/templatestyles&gt; 

https://webapps.usgs.gov/nibi/&lt;templatestyles src=&quot;Module:Side box/styles.css&quot;&gt;&lt;/templatestyles&gt;&lt;templatestyles src=&quot;Sister project/styles.css&quot;&gt;&lt;/templatestyles&gt;

* [https://web.archive.org/web/20200920064331/https://www.geologieportal.ch/en/themes/fundamentals-of-geology/boreholes.html Imigodi: I-Swiss Geological Survey]
{{Geotechnical engineering|state=collapsed}}{{Man-made and man-related Subterranea}}</text>
      <sha1>5gst1tozdv0n0o1it7nvdbuvrf3j4qy</sha1>
    </revision>
    <revision>
      <id>6714</id>
      <parentid>6713</parentid>
      <timestamp>2026-06-13T12:02:07Z</timestamp>
      <contributor>
        <username>Nozi2026</username>
        <id>1567</id>
      </contributor>
      <minor />
      <origin>6714</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7427" sha1="9ffef10xfbu6earfejd871j0cqz1lo5" xml:space="preserve">
[[Isimumathi:Borewell_digging.jpg|thumb|Ukwemba umgodi womgodi namkha umthombo wetjhubhu]]
[[Isimumathi:Borewell_digging.ogv|thumb| Ukumba umgodi]]
[[Isimumathi:Drilling_boreholes_for_clean_water_(9084603915).jpg|thumb|Owesifazana owe-Uganda uqoqa amanzi emgodini kanye nepompi yezandla enamathiselwe]]
[[Isimumathi:Borehole_01.jpg|thumb|Umthombo obhojiweko e-Ghana; umgodi awubonakali]]
'''Umgodi'''  omncane obhojwe phansi, kungaba ngokuthe nqo nofana ngokuvundlileko. Umgodi ungakhiwa ngenhloso ezinengi ezihlukahlukeneyo, kugoqela okufaka lokokukhipha amanzi ( umthombo wamanzi obhojiweko nomthombo wetjhubhu ), ezinye izinto  (ezifana ne -petroleum ), nofana lamagesi (njengegesi yemvelo ). Kungaba yingxenye yophenyo lwe-geotechnical, ukuhlolwa kwendawo yebhoduluko, ukuhlolwa kwamaminerali, ukulinganisa amazinga womtjhiso, njengomgodi wokulinga wokufaka amapayipi nofana lezisetshenziswayo ezingaphasi kwehlabathi, ukufakwa kwe-geothermal, nofana ukubulungwa ngaphasi kwehlabathi kwezinto ezingafunekiyo.

== Ukuqakatheka ==
[[Isimumathi:AlburyBoreHole.jpg|right|thumb|Umgodi wemithombo yamanzi eya e- chalk aquifer ngaphasi kwe- North Downs, e-England e -Albury]]
Omanjinela nabacebisi bezebhoduluko basebenzisa ibizo elithi ''umgodi'' ukuhlathulula ngokuhlanganyela yonke imihlobo ehlukileyo yemigodi ebhojiweko njengengcenye yophenyo lwe-geotechnical nofana ukuhlolwa kwendawo yezebhoduluko (okubizwa ngokuthi yi-Phase II ESA). Lokhu kufaka  imigodi ethuthukisiweko ukubuthelela amasampula wehlabathi, amasampula amanzi kumbe amadwala, ukuthuthukisa imitjhini yokuthatha amasampula ''endaweni'', nofana ukufaka imithombo yokutjheja nofana ama-piezometers . Amasampula abuthelelwe emigodini avamise ukuhlolwa elabhorethari ukuthola ubujamo bawo, nofana ukuhlola amazinga wamakhemikhali ahlukahlukeneko nofana izinto ezisilaphazako.

Ngokuvamileko, umgodi osetshenziswa njengomthombo wamanzi uqedwa ngokufaka ipayipi ejame ngqo (ikheyisi) nesikrini somthombo ukuvikela umgodi bona ungabhidli. Lokhu godu kusiza ukukhandela ukusilaphazeka kwephasi bona kungangeni emgodini begodu kuvikela nanyana ngiyiphi ipompo efakiweko bona ingadosi isihlabathi nenhlabathi. Imithombo yamafutha negesi yemvelo yenziwa ngendlela efanayo, nanyana ivamise ukuba yinkimbinkimbi.

Njengombana kuvezwe ngokunabileko ku- proxy (isimo sezulu), ukulinganisa amazinga womtjhiso we-borehole emlandweni wokujula okuhlukileko kunga &quot; guqulwa &quot; (ifomula yeembalo yokurarulula i-ikhweshini ye-matrix) ukusiza ukulinganisa amazinga womtjhiso wendawo yomlando.

Amaqoqo wemigodi emincani enendlela zokutshiswa ezenziwe ngepayipi yeplastiki ye-PEX ingasetshenziselwa ukugcina ukutshisa kumbe amakhaza hlangana neenkhathi eziphikisanako ngaphakathi kwamatje wemvelo. Indlela le ibizwa ngokuthi kugcinwa kwamandla womtjhiso ngesikhathi sonyaka . Iindaba ezingasetshenziselwa iqhinga leli zisukela ematjeni ukuya edwaleni. Kungaba nama-borehole ambalwa ukuya kwamakhulu amanengi, begodu ngokwenza, ukujula kwawo kusuka ku 50 to 300 metres (150 to 1,000 ft) .&lt;ref&gt;Hellström G. (2008). Large-Scale Applications of Ground-Source Heat Pumps in Sweden. IEA HP Annex 29 Workshop, Zurich, May 19, 2008.&lt;/ref&gt;&lt;ref&gt;Stiles, Lynn (June 1998). &quot;Underground thermal energy storage in the US&quot;. ''IEA Heat Pump Centre Newsletter''. '''16''' (2): 22–23.&lt;/ref&gt;  

== Umlando ==
Ukubhoboza umgodi kunomlando omude. Okungenani ngobukhosi be-Han dynasty (202&amp;nbsp;BC&amp;nbsp;– 220&amp;nbsp;AD), amaTjhayina asebenzisa ukubhora umgodi ojulileko malungana nokumba namanye amaphrojekthi. Isazi se-sinology nesazi-mlando se-Britain u-Michael Loewe uthi indawo zokubhoboza zingafikelela emamitheni 600 metres (2,000 ft) .&lt;ref&gt;Loewe (1968), 194&lt;/ref&gt;  U-KS Tom uchaza ikambiso yokubhora: &quot;Indlela yamaTjhayina yokubhora ngokujulileko yenziwa lithimba lamadoda ebeligxuma phezulu begodu liphume emgogodleni ukobana lithinte isiqephu sokubhora ngesikhathi ithuluzi lokubhora lijikeleziswa zinyathi nenkomo.&lt;ref name=&quot;:0&quot;&gt;Tom (1989), 103&lt;/ref&gt; Le bekuyindlela efanako esetshenziselwa ukukhipha i-petroleum e -California ngeminyaka yabo-1860 (okutjho &quot;ukumkhahlela phansi&quot;).&lt;ref name=&quot;:0&quot; /&gt;   I-Western Han dynasty bronze foundry eyatholwa e-Xinglong, e-Hebei gade inemigodi yemayini eseduze eyafikelela ekujuleni kwamamitha 100 metres (330 ft) eneendawo ezivulekileko zemayini; amashafthi namagumbi bekaphelele ngefreyimu yamapulangwe, amaladi namathulusi wensimbi.   Ngekhulu lokuthoma leminyaka BC, abasebenzi bezandla be-China ababhora ngensimbi kanye nababhora bebakghona ukubhora imigodi efika 1,500 metres (4,900 ft) ukutjhinga.    Ngekhulu leminyaka elitshumi lanye AD, amaTjhayina bekakwazi ukubhora imigodi efika 900 metres (3,000 ft) ngokujula. Ukubhora imigodi bekuthatha isikhathi eside begodu kuthatha isikhathi eside. Njengombana ukujula kwemigodi bekuhlukahluka, ukubhoboza umthombo munye bekungathatha iminyaka elitshumi.  Kwaze kwaba ngekhulu leminyaka ye-19 lapho i-Europe neTjingalanga zizokuthola begodu zincintisane nethekhnoloji yokubhora imigodi ye-China yakade.  

Kwaphela iminyaka eminengi, umgodi omude kakhulu ephasini bekuyi- Kola Superdeep Borehole e-Russia. Kusukela ngomnyaka ka-2011 bekube nguRhoboyi wee-2012 irekhodi belibanjwe li- 12,345-metre (40,502 ft) ubude i-Sakhalin-I Odoptu OP-11 Kuhlekuhle, eduze nelwandle lesihlengele se-Russia i-Sakhalin .  Umthombo we -Chayvo Z-44 ofinyeleleka khulu wathatha isikhundla somgodi omude khulu ephasini mhlazi-27 kuRhoboyi wee-2012. Ukujula okulinganisiweyo kwe-Z-44 kungamamitha 12,376 metres (40,604 ft) . Kodwana, imithombo ye-ERD ayijulile ukudlula i-Kola Borehole, ngebanga lokufuduka okukhulu okuvundlileyo. NgoJulayi 2023, i-China yaqala ukubhora imigodi etjhingako, enye e- Sichuan Basin kulindeleke bona ifinyelele 10,520 metres (34,510 ft) phasi begodu enye ise- Tarim Basin ngokujula okuhleliweko 11,100 metres (36,400 ft) .  

== Indlela yokusebenza ==
 Ababholi bangacwilisa umgodi basebenzisa i -drill rig nofana i-rig esetshenziswa ngesandla. Imitshini namathekhnikhi wokuthuthukisa umgodi ayahluka kakhulu ngokuya ngomenzi, ubujamo bezesayensi, kanye nehloso ehlosiweko. Ukubhora elwandle amayunithi antantako nofana amaplatifomu asekelwa phansi kwelwandle asetshenziselwa ukubhora.
[[Isimumathi:Borehole-Manual-Digging-Process-2050-Paris.jpg|thumb|Abantu ababili abagebha umgodi bemba umgodi ngezandla]]
lkakhulu emazweni asathuthuka imigodi eminengi isagejwa ngezandla. Ukwemba kuqala ngomsebenzi wezandla kusetshenziswa amathulusi asisekelo afana namafosholo, amapiki, kanye nama-crowbar. Abasebenzi bemba ihlabathi ngesendlalelo ngesendlalelo, kanengi basebenzisa ukunyakaza okuyindilinga ukwenza umgodi omiswe kuhle. Ikambiso le ibuthakathaka begodu itlhoga, ifuna ukusebenzisana kwesiqhema nokusebenzisana. Ukukhandela bona amabhoda angawi begodu nokuqinisekisa ikhwalithi yamanzi, umgodi ufakwe izinto ezifana nezitina, amatshe, nofana amasongo wekhonkrithi. Ukuqiniswa lokhu kugcina ubuqotho besakhiwo somgodi begodu kusiza ukukhandela ukusilaphazeka. Ipulatifomu yekhonkrithi nofana ilebhu ingafakwa phansi ukukhandela bona inkunkuma ingangeni emanzini. Ingaphezulu lomgodi livalwe ukuwuvikela ekungcolisweni nokusilaphazeka. 

== Qala godu ==

* I-Askam Borehole e-Pennsylvania
* Umsiki wekheyisi
* Ukulahlwa kwemigodi etjhingako
* Isivuli somgodi
* Ukulahlwa komgodi ovundlileko
* I-Kola Superdeep Borehole
* Iphrofayili yokuzamazama komhlaba

== Umthombo wolwazi ==</text>
      <sha1>9ffef10xfbu6earfejd871j0cqz1lo5</sha1>
    </revision>
    <revision>
      <id>6715</id>
      <parentid>6714</parentid>
      <timestamp>2026-06-13T12:04:10Z</timestamp>
      <contributor>
        <username>Nozi2026</username>
        <id>1567</id>
      </contributor>
      <minor />
      <origin>6715</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7578" sha1="l36j0g345auoq0eooq57w21fu9ao8xi" xml:space="preserve">
[[Isimumathi:Borewell_digging.jpg|thumb|Ukwemba umgodi womgodi namkha umthombo wetjhubhu]]
[[Isimumathi:Borewell_digging.ogv|thumb| Ukumba umgodi]]
[[Isimumathi:Drilling_boreholes_for_clean_water_(9084603915).jpg|thumb|Owesifazana owe-Uganda uqoqa amanzi emgodini kanye nepompi yezandla enamathiselwe]]
[[Isimumathi:Borehole_01.jpg|thumb|Umthombo obhojiweko e-Ghana; umgodi awubonakali]]
'''Umgodi'''  omncane obhojwe phansi, kungaba ngokuthe nqo nofana ngokuvundlileko. Umgodi ungakhiwa ngenhloso ezinengi ezihlukahlukeneyo, kugoqela okufaka lokokukhipha amanzi ( umthombo wamanzi obhojiweko nomthombo wetjhubhu ), ezinye izinto  (ezifana ne -petroleum ), nofana lamagesi (njengegesi yemvelo ). Kungaba yingxenye yophenyo lwe-geotechnical, ukuhlolwa kwendawo yebhoduluko, ukuhlolwa kwamaminerali, ukulinganisa amazinga womtjhiso, njengomgodi wokulinga wokufaka amapayipi nofana lezisetshenziswayo ezingaphasi kwehlabathi, ukufakwa kwe-geothermal, nofana ukubulungwa ngaphasi kwehlabathi kwezinto ezingafunekiyo.

== Ukuqakatheka ==
[[Isimumathi:AlburyBoreHole.jpg|right|thumb|Umgodi wemithombo yamanzi eya e- chalk aquifer ngaphasi kwe- North Downs, e-England e -Albury]]
Omanjinela nabacebisi bezebhoduluko basebenzisa ibizo elithi ''umgodi'' ukuhlathulula ngokuhlanganyela yonke imihlobo ehlukileyo yemigodi ebhojiweko njengengcenye yophenyo lwe-geotechnical nofana ukuhlolwa kwendawo yezebhoduluko (okubizwa ngokuthi yi-Phase II ESA). Lokhu kufaka  imigodi ethuthukisiweko ukubuthelela amasampula wehlabathi, amasampula amanzi kumbe amadwala, ukuthuthukisa imitjhini yokuthatha amasampula ''endaweni'', nofana ukufaka imithombo yokutjheja nofana ama-piezometers . Amasampula abuthelelwe emigodini avamise ukuhlolwa elabhorethari ukuthola ubujamo bawo, nofana ukuhlola amazinga wamakhemikhali ahlukahlukeneko nofana izinto ezisilaphazako.

Ngokuvamileko, umgodi osetshenziswa njengomthombo wamanzi uqedwa ngokufaka ipayipi ejame ngqo (ikheyisi) nesikrini somthombo ukuvikela umgodi bona ungabhidli. Lokhu godu kusiza ukukhandela ukusilaphazeka kwephasi bona kungangeni emgodini begodu kuvikela nanyana ngiyiphi ipompo efakiweko bona ingadosi isihlabathi nenhlabathi. Imithombo yamafutha negesi yemvelo yenziwa ngendlela efanayo, nanyana ivamise ukuba yinkimbinkimbi.

Njengombana kuvezwe ngokunabileko ku- proxy (isimo sezulu), ukulinganisa amazinga womtjhiso we-borehole emlandweni wokujula okuhlukileko kunga &quot; guqulwa &quot; (ifomula yeembalo yokurarulula i-ikhweshini ye-matrix) ukusiza ukulinganisa amazinga womtjhiso wendawo yomlando.

Amaqoqo wemigodi emincani enendlela zokutshiswa ezenziwe ngepayipi yeplastiki ye-PEX ingasetshenziselwa ukugcina ukutshisa kumbe amakhaza hlangana neenkhathi eziphikisanako ngaphakathi kwamatje wemvelo. Indlela le ibizwa ngokuthi kugcinwa kwamandla womtjhiso ngesikhathi sonyaka . Iindaba ezingasetshenziselwa iqhinga leli zisukela ematjeni ukuya edwaleni. Kungaba nama-borehole ambalwa ukuya kwamakhulu amanengi, begodu ngokwenza, ukujula kwawo kusuka ku 50 to 300 metres (150 to 1,000 ft) .&lt;ref&gt;Hellström G. (2008). Large-Scale Applications of Ground-Source Heat Pumps in Sweden. IEA HP Annex 29 Workshop, Zurich, May 19, 2008.&lt;/ref&gt;&lt;ref&gt;Stiles, Lynn (June 1998). &quot;Underground thermal energy storage in the US&quot;. ''IEA Heat Pump Centre Newsletter''. '''16''' (2): 22–23.&lt;/ref&gt;  

== Umlando&lt;ref&gt;Hobson, John M. (2004). ''The Eastern Origins of Western Civilisation''. Cambridge University Press. p. 215. ISBN &lt;bdi&gt;978-0521547246&lt;/bdi&gt;.&lt;/ref&gt; ==
Ukubhoboza umgodi kunomlando omude. Okungenani ngobukhosi be-Han dynasty (202&amp;nbsp;BC&amp;nbsp;– 220&amp;nbsp;AD), amaTjhayina asebenzisa ukubhora umgodi ojulileko malungana nokumba namanye amaphrojekthi. Isazi se-sinology nesazi-mlando se-Britain u-Michael Loewe uthi indawo zokubhoboza zingafikelela emamitheni 600 metres (2,000 ft) .&lt;ref&gt;Loewe (1968), 194&lt;/ref&gt;  U-KS Tom uchaza ikambiso yokubhora: &quot;Indlela yamaTjhayina yokubhora ngokujulileko yenziwa lithimba lamadoda ebeligxuma phezulu begodu liphume emgogodleni ukobana lithinte isiqephu sokubhora ngesikhathi ithuluzi lokubhora lijikeleziswa zinyathi nenkomo.&lt;ref name=&quot;:0&quot;&gt;Tom (1989), 103&lt;/ref&gt; Le bekuyindlela efanako esetshenziselwa ukukhipha i-petroleum e -California ngeminyaka yabo-1860 (okutjho &quot;ukumkhahlela phansi&quot;).&lt;ref name=&quot;:0&quot; /&gt;   I-Western Han dynasty bronze foundry eyatholwa e-Xinglong, e-Hebei gade inemigodi yemayini eseduze eyafikelela ekujuleni kwamamitha 100 metres (330 ft) eneendawo ezivulekileko zemayini; amashafthi namagumbi bekaphelele ngefreyimu yamapulangwe, amaladi namathulusi wensimbi.   Ngekhulu lokuthoma leminyaka BC, abasebenzi bezandla be-China ababhora ngensimbi kanye nababhora bebakghona ukubhora imigodi efika 1,500 metres (4,900 ft) ukutjhinga.    Ngekhulu leminyaka elitshumi lanye AD, amaTjhayina bekakwazi ukubhora imigodi efika 900 metres (3,000 ft) ngokujula. Ukubhora imigodi bekuthatha isikhathi eside begodu kuthatha isikhathi eside. Njengombana ukujula kwemigodi bekuhlukahluka, ukubhoboza umthombo munye bekungathatha iminyaka elitshumi.  Kwaze kwaba ngekhulu leminyaka ye-19 lapho i-Europe neTjingalanga zizokuthola begodu zincintisane nethekhnoloji yokubhora imigodi ye-China yakade.  

Kwaphela iminyaka eminengi, umgodi omude kakhulu ephasini bekuyi- Kola Superdeep Borehole e-Russia. Kusukela ngomnyaka ka-2011 bekube nguRhoboyi wee-2012 irekhodi belibanjwe li- 12,345-metre (40,502 ft) ubude i-Sakhalin-I Odoptu OP-11 Kuhlekuhle, eduze nelwandle lesihlengele se-Russia i-Sakhalin .  Umthombo we -Chayvo Z-44 ofinyeleleka khulu wathatha isikhundla somgodi omude khulu ephasini mhlazi-27 kuRhoboyi wee-2012. Ukujula okulinganisiweyo kwe-Z-44 kungamamitha 12,376 metres (40,604 ft) . Kodwana, imithombo ye-ERD ayijulile ukudlula i-Kola Borehole, ngebanga lokufuduka okukhulu okuvundlileyo. NgoJulayi 2023, i-China yaqala ukubhora imigodi etjhingako, enye e- Sichuan Basin kulindeleke bona ifinyelele 10,520 metres (34,510 ft) phasi begodu enye ise- Tarim Basin ngokujula okuhleliweko 11,100 metres (36,400 ft) .  

== Indlela yokusebenza ==
 Ababholi bangacwilisa umgodi basebenzisa i -drill rig nofana i-rig esetshenziswa ngesandla. Imitshini namathekhnikhi wokuthuthukisa umgodi ayahluka kakhulu ngokuya ngomenzi, ubujamo bezesayensi, kanye nehloso ehlosiweko. Ukubhora elwandle amayunithi antantako nofana amaplatifomu asekelwa phansi kwelwandle asetshenziselwa ukubhora.
[[Isimumathi:Borehole-Manual-Digging-Process-2050-Paris.jpg|thumb|Abantu ababili abagebha umgodi bemba umgodi ngezandla]]
lkakhulu emazweni asathuthuka imigodi eminengi isagejwa ngezandla. Ukwemba kuqala ngomsebenzi wezandla kusetshenziswa amathulusi asisekelo afana namafosholo, amapiki, kanye nama-crowbar. Abasebenzi bemba ihlabathi ngesendlalelo ngesendlalelo, kanengi basebenzisa ukunyakaza okuyindilinga ukwenza umgodi omiswe kuhle. Ikambiso le ibuthakathaka begodu itlhoga, ifuna ukusebenzisana kwesiqhema nokusebenzisana. Ukukhandela bona amabhoda angawi begodu nokuqinisekisa ikhwalithi yamanzi, umgodi ufakwe izinto ezifana nezitina, amatshe, nofana amasongo wekhonkrithi. Ukuqiniswa lokhu kugcina ubuqotho besakhiwo somgodi begodu kusiza ukukhandela ukusilaphazeka. Ipulatifomu yekhonkrithi nofana ilebhu ingafakwa phansi ukukhandela bona inkunkuma ingangeni emanzini. Ingaphezulu lomgodi livalwe ukuwuvikela ekungcolisweni nokusilaphazeka. 

== Qala godu ==

* I-Askam Borehole e-Pennsylvania
* Umsiki wekheyisi
* Ukulahlwa kwemigodi etjhingako
* Isivuli somgodi
* Ukulahlwa komgodi ovundlileko
* I-Kola Superdeep Borehole
* Iphrofayili yokuzamazama komhlaba

== Umthombo wolwazi ==</text>
      <sha1>l36j0g345auoq0eooq57w21fu9ao8xi</sha1>
    </revision>
    <revision>
      <id>6716</id>
      <parentid>6715</parentid>
      <timestamp>2026-06-13T12:06:53Z</timestamp>
      <contributor>
        <username>Nozi2026</username>
        <id>1567</id>
      </contributor>
      <minor />
      <origin>6716</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7607" sha1="0tduwdj9fzu12cfdndb90hdrzj11cxu" xml:space="preserve">
[[Isimumathi:Borewell_digging.jpg|thumb|Ukwemba umgodi womgodi namkha umthombo wetjhubhu]]
[[Isimumathi:Borewell_digging.ogv|thumb| Ukumba umgodi]]
[[Isimumathi:Drilling_boreholes_for_clean_water_(9084603915).jpg|thumb|Owesifazana owe-Uganda uqoqa amanzi emgodini kanye nepompi yezandla enamathiselwe]]
[[Isimumathi:Borehole_01.jpg|thumb|Umthombo obhojiweko e-Ghana; umgodi awubonakali]]
'''Umgodi'''  omncane obhojwe phansi, kungaba ngokuthe nqo nofana ngokuvundlileko. Umgodi ungakhiwa ngenhloso ezinengi ezihlukahlukeneyo, kugoqela okufaka lokokukhipha amanzi ( umthombo wamanzi obhojiweko nomthombo wetjhubhu ), ezinye izinto  (ezifana ne -petroleum ), nofana lamagesi (njengegesi yemvelo ). Kungaba yingxenye yophenyo lwe-geotechnical, ukuhlolwa kwendawo yebhoduluko, ukuhlolwa kwamaminerali, ukulinganisa amazinga womtjhiso, njengomgodi wokulinga wokufaka amapayipi nofana lezisetshenziswayo ezingaphasi kwehlabathi, ukufakwa kwe-geothermal, nofana ukubulungwa ngaphasi kwehlabathi kwezinto ezingafunekiyo.

== Ukuqakatheka ==
[[Isimumathi:AlburyBoreHole.jpg|right|thumb|Umgodi wemithombo yamanzi eya e- chalk aquifer ngaphasi kwe- North Downs, e-England e -Albury]]
Omanjinela nabacebisi bezebhoduluko basebenzisa ibizo elithi ''umgodi'' ukuhlathulula ngokuhlanganyela yonke imihlobo ehlukileyo yemigodi ebhojiweko njengengcenye yophenyo lwe-geotechnical nofana ukuhlolwa kwendawo yezebhoduluko (okubizwa ngokuthi yi-Phase II ESA). Lokhu kufaka  imigodi ethuthukisiweko ukubuthelela amasampula wehlabathi, amasampula amanzi kumbe amadwala, ukuthuthukisa imitjhini yokuthatha amasampula ''endaweni'', nofana ukufaka imithombo yokutjheja nofana ama-piezometers . Amasampula abuthelelwe emigodini avamise ukuhlolwa elabhorethari ukuthola ubujamo bawo, nofana ukuhlola amazinga wamakhemikhali ahlukahlukeneko nofana izinto ezisilaphazako.

Ngokuvamileko, umgodi osetshenziswa njengomthombo wamanzi uqedwa ngokufaka ipayipi ejame ngqo (ikheyisi) nesikrini somthombo ukuvikela umgodi bona ungabhidli. Lokhu godu kusiza ukukhandela ukusilaphazeka kwephasi bona kungangeni emgodini begodu kuvikela nanyana ngiyiphi ipompo efakiweko bona ingadosi isihlabathi nenhlabathi. Imithombo yamafutha negesi yemvelo yenziwa ngendlela efanayo, nanyana ivamise ukuba yinkimbinkimbi.

Njengombana kuvezwe ngokunabileko ku- proxy (isimo sezulu), ukulinganisa amazinga womtjhiso we-borehole emlandweni wokujula okuhlukileko kunga &quot; guqulwa &quot; (ifomula yeembalo yokurarulula i-ikhweshini ye-matrix) ukusiza ukulinganisa amazinga womtjhiso wendawo yomlando.

Amaqoqo wemigodi emincani enendlela zokutshiswa ezenziwe ngepayipi yeplastiki ye-PEX ingasetshenziselwa ukugcina ukutshisa kumbe amakhaza hlangana neenkhathi eziphikisanako ngaphakathi kwamatje wemvelo. Indlela le ibizwa ngokuthi kugcinwa kwamandla womtjhiso ngesikhathi sonyaka . Iindaba ezingasetshenziselwa iqhinga leli zisukela ematjeni ukuya edwaleni. Kungaba nama-borehole ambalwa ukuya kwamakhulu amanengi, begodu ngokwenza, ukujula kwawo kusuka ku 50 to 300 metres (150 to 1,000 ft) .&lt;ref&gt;Hellström G. (2008). Large-Scale Applications of Ground-Source Heat Pumps in Sweden. IEA HP Annex 29 Workshop, Zurich, May 19, 2008.&lt;/ref&gt;&lt;ref&gt;Stiles, Lynn (June 1998). &quot;Underground thermal energy storage in the US&quot;. ''IEA Heat Pump Centre Newsletter''. '''16''' (2): 22–23.&lt;/ref&gt;  

== Umlando&lt;ref&gt;Hobson, John M. (2004). ''The Eastern Origins of Western Civilisation''. Cambridge University Press. p. 215. ISBN &lt;bdi&gt;978-0521547246&lt;/bdi&gt;.&lt;/ref&gt; ==
Ukubhoboza umgodi kunomlando omude. Okungenani ngobukhosi be-Han dynasty (202&amp;nbsp;BC&amp;nbsp;– 220&amp;nbsp;AD), amaTjhayina asebenzisa ukubhora umgodi ojulileko malungana nokumba namanye amaphrojekthi. Isazi se-sinology nesazi-mlando se-Britain u-Michael Loewe uthi indawo zokubhoboza zingafikelela emamitheni 600 metres (2,000 ft) .&lt;ref&gt;Loewe (1968), 194&lt;/ref&gt;  U-KS Tom uchaza ikambiso yokubhora: &quot;Indlela yamaTjhayina yokubhora ngokujulileko yenziwa lithimba lamadoda ebeligxuma phezulu begodu liphume emgogodleni ukobana lithinte isiqephu sokubhora ngesikhathi ithuluzi lokubhora lijikeleziswa zinyathi nenkomo.&lt;ref name=&quot;:0&quot;&gt;Tom (1989), 103&lt;/ref&gt; Le bekuyindlela efanako esetshenziselwa ukukhipha i-petroleum e -California ngeminyaka yabo-1860 (okutjho &quot;ukumkhahlela phansi&quot;).&lt;ref name=&quot;:0&quot; /&gt;   I-Western Han dynasty bronze foundry eyatholwa e-Xinglong, e-Hebei gade inemigodi yemayini eseduze eyafikelela ekujuleni kwamamitha 100 metres (330 ft) eneendawo ezivulekileko zemayini; amashafthi namagumbi bekaphelele ngefreyimu yamapulangwe, amaladi namathulusi wensimbi.&lt;ref&gt;Loewe (1968), 191.&lt;/ref&gt;   Ngekhulu lokuthoma leminyaka BC, abasebenzi bezandla be-China ababhora ngensimbi kanye nababhora bebakghona ukubhora imigodi efika 1,500 metres (4,900 ft) ukutjhinga.    Ngekhulu leminyaka elitshumi lanye AD, amaTjhayina bekakwazi ukubhora imigodi efika 900 metres (3,000 ft) ngokujula. Ukubhora imigodi bekuthatha isikhathi eside begodu kuthatha isikhathi eside. Njengombana ukujula kwemigodi bekuhlukahluka, ukubhoboza umthombo munye bekungathatha iminyaka elitshumi.  Kwaze kwaba ngekhulu leminyaka ye-19 lapho i-Europe neTjingalanga zizokuthola begodu zincintisane nethekhnoloji yokubhora imigodi ye-China yakade.  

Kwaphela iminyaka eminengi, umgodi omude kakhulu ephasini bekuyi- Kola Superdeep Borehole e-Russia. Kusukela ngomnyaka ka-2011 bekube nguRhoboyi wee-2012 irekhodi belibanjwe li- 12,345-metre (40,502 ft) ubude i-Sakhalin-I Odoptu OP-11 Kuhlekuhle, eduze nelwandle lesihlengele se-Russia i-Sakhalin .  Umthombo we -Chayvo Z-44 ofinyeleleka khulu wathatha isikhundla somgodi omude khulu ephasini mhlazi-27 kuRhoboyi wee-2012. Ukujula okulinganisiweyo kwe-Z-44 kungamamitha 12,376 metres (40,604 ft) . Kodwana, imithombo ye-ERD ayijulile ukudlula i-Kola Borehole, ngebanga lokufuduka okukhulu okuvundlileyo. NgoJulayi 2023, i-China yaqala ukubhora imigodi etjhingako, enye e- Sichuan Basin kulindeleke bona ifinyelele 10,520 metres (34,510 ft) phasi begodu enye ise- Tarim Basin ngokujula okuhleliweko 11,100 metres (36,400 ft) .  

== Indlela yokusebenza ==
 Ababholi bangacwilisa umgodi basebenzisa i -drill rig nofana i-rig esetshenziswa ngesandla. Imitshini namathekhnikhi wokuthuthukisa umgodi ayahluka kakhulu ngokuya ngomenzi, ubujamo bezesayensi, kanye nehloso ehlosiweko. Ukubhora elwandle amayunithi antantako nofana amaplatifomu asekelwa phansi kwelwandle asetshenziselwa ukubhora.
[[Isimumathi:Borehole-Manual-Digging-Process-2050-Paris.jpg|thumb|Abantu ababili abagebha umgodi bemba umgodi ngezandla]]
lkakhulu emazweni asathuthuka imigodi eminengi isagejwa ngezandla. Ukwemba kuqala ngomsebenzi wezandla kusetshenziswa amathulusi asisekelo afana namafosholo, amapiki, kanye nama-crowbar. Abasebenzi bemba ihlabathi ngesendlalelo ngesendlalelo, kanengi basebenzisa ukunyakaza okuyindilinga ukwenza umgodi omiswe kuhle. Ikambiso le ibuthakathaka begodu itlhoga, ifuna ukusebenzisana kwesiqhema nokusebenzisana. Ukukhandela bona amabhoda angawi begodu nokuqinisekisa ikhwalithi yamanzi, umgodi ufakwe izinto ezifana nezitina, amatshe, nofana amasongo wekhonkrithi. Ukuqiniswa lokhu kugcina ubuqotho besakhiwo somgodi begodu kusiza ukukhandela ukusilaphazeka. Ipulatifomu yekhonkrithi nofana ilebhu ingafakwa phansi ukukhandela bona inkunkuma ingangeni emanzini. Ingaphezulu lomgodi livalwe ukuwuvikela ekungcolisweni nokusilaphazeka. 

== Qala godu ==

* I-Askam Borehole e-Pennsylvania
* Umsiki wekheyisi
* Ukulahlwa kwemigodi etjhingako
* Isivuli somgodi
* Ukulahlwa komgodi ovundlileko
* I-Kola Superdeep Borehole
* Iphrofayili yokuzamazama komhlaba

== Umthombo wolwazi ==</text>
      <sha1>0tduwdj9fzu12cfdndb90hdrzj11cxu</sha1>
    </revision>
    <revision>
      <id>6717</id>
      <parentid>6716</parentid>
      <timestamp>2026-06-13T12:08:03Z</timestamp>
      <contributor>
        <username>Nozi2026</username>
        <id>1567</id>
      </contributor>
      <minor />
      <origin>6717</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7635" sha1="eis6bg8pho87taucpfa92gt6yhex9b3" xml:space="preserve">
[[Isimumathi:Borewell_digging.jpg|thumb|Ukwemba umgodi womgodi namkha umthombo wetjhubhu]]
[[Isimumathi:Borewell_digging.ogv|thumb| Ukumba umgodi]]
[[Isimumathi:Drilling_boreholes_for_clean_water_(9084603915).jpg|thumb|Owesifazana owe-Uganda uqoqa amanzi emgodini kanye nepompi yezandla enamathiselwe]]
[[Isimumathi:Borehole_01.jpg|thumb|Umthombo obhojiweko e-Ghana; umgodi awubonakali]]
'''Umgodi'''  omncane obhojwe phansi, kungaba ngokuthe nqo nofana ngokuvundlileko. Umgodi ungakhiwa ngenhloso ezinengi ezihlukahlukeneyo, kugoqela okufaka lokokukhipha amanzi ( umthombo wamanzi obhojiweko nomthombo wetjhubhu ), ezinye izinto  (ezifana ne -petroleum ), nofana lamagesi (njengegesi yemvelo ). Kungaba yingxenye yophenyo lwe-geotechnical, ukuhlolwa kwendawo yebhoduluko, ukuhlolwa kwamaminerali, ukulinganisa amazinga womtjhiso, njengomgodi wokulinga wokufaka amapayipi nofana lezisetshenziswayo ezingaphasi kwehlabathi, ukufakwa kwe-geothermal, nofana ukubulungwa ngaphasi kwehlabathi kwezinto ezingafunekiyo.

== Ukuqakatheka ==
[[Isimumathi:AlburyBoreHole.jpg|right|thumb|Umgodi wemithombo yamanzi eya e- chalk aquifer ngaphasi kwe- North Downs, e-England e -Albury]]
Omanjinela nabacebisi bezebhoduluko basebenzisa ibizo elithi ''umgodi'' ukuhlathulula ngokuhlanganyela yonke imihlobo ehlukileyo yemigodi ebhojiweko njengengcenye yophenyo lwe-geotechnical nofana ukuhlolwa kwendawo yezebhoduluko (okubizwa ngokuthi yi-Phase II ESA). Lokhu kufaka  imigodi ethuthukisiweko ukubuthelela amasampula wehlabathi, amasampula amanzi kumbe amadwala, ukuthuthukisa imitjhini yokuthatha amasampula ''endaweni'', nofana ukufaka imithombo yokutjheja nofana ama-piezometers . Amasampula abuthelelwe emigodini avamise ukuhlolwa elabhorethari ukuthola ubujamo bawo, nofana ukuhlola amazinga wamakhemikhali ahlukahlukeneko nofana izinto ezisilaphazako.

Ngokuvamileko, umgodi osetshenziswa njengomthombo wamanzi uqedwa ngokufaka ipayipi ejame ngqo (ikheyisi) nesikrini somthombo ukuvikela umgodi bona ungabhidli. Lokhu godu kusiza ukukhandela ukusilaphazeka kwephasi bona kungangeni emgodini begodu kuvikela nanyana ngiyiphi ipompo efakiweko bona ingadosi isihlabathi nenhlabathi. Imithombo yamafutha negesi yemvelo yenziwa ngendlela efanayo, nanyana ivamise ukuba yinkimbinkimbi.

Njengombana kuvezwe ngokunabileko ku- proxy (isimo sezulu), ukulinganisa amazinga womtjhiso we-borehole emlandweni wokujula okuhlukileko kunga &quot; guqulwa &quot; (ifomula yeembalo yokurarulula i-ikhweshini ye-matrix) ukusiza ukulinganisa amazinga womtjhiso wendawo yomlando.

Amaqoqo wemigodi emincani enendlela zokutshiswa ezenziwe ngepayipi yeplastiki ye-PEX ingasetshenziselwa ukugcina ukutshisa kumbe amakhaza hlangana neenkhathi eziphikisanako ngaphakathi kwamatje wemvelo. Indlela le ibizwa ngokuthi kugcinwa kwamandla womtjhiso ngesikhathi sonyaka . Iindaba ezingasetshenziselwa iqhinga leli zisukela ematjeni ukuya edwaleni. Kungaba nama-borehole ambalwa ukuya kwamakhulu amanengi, begodu ngokwenza, ukujula kwawo kusuka ku 50 to 300 metres (150 to 1,000 ft) .&lt;ref&gt;Hellström G. (2008). Large-Scale Applications of Ground-Source Heat Pumps in Sweden. IEA HP Annex 29 Workshop, Zurich, May 19, 2008.&lt;/ref&gt;&lt;ref&gt;Stiles, Lynn (June 1998). &quot;Underground thermal energy storage in the US&quot;. ''IEA Heat Pump Centre Newsletter''. '''16''' (2): 22–23.&lt;/ref&gt;  

== Umlando&lt;ref&gt;Hobson, John M. (2004). ''The Eastern Origins of Western Civilisation''. Cambridge University Press. p. 215. ISBN &lt;bdi&gt;978-0521547246&lt;/bdi&gt;.&lt;/ref&gt; ==
Ukubhoboza umgodi kunomlando omude. Okungenani ngobukhosi be-Han dynasty (202&amp;nbsp;BC&amp;nbsp;– 220&amp;nbsp;AD), amaTjhayina asebenzisa ukubhora umgodi ojulileko malungana nokumba namanye amaphrojekthi. Isazi se-sinology nesazi-mlando se-Britain u-Michael Loewe uthi indawo zokubhoboza zingafikelela emamitheni 600 metres (2,000 ft) .&lt;ref&gt;Loewe (1968), 194&lt;/ref&gt;  U-KS Tom uchaza ikambiso yokubhora: &quot;Indlela yamaTjhayina yokubhora ngokujulileko yenziwa lithimba lamadoda ebeligxuma phezulu begodu liphume emgogodleni ukobana lithinte isiqephu sokubhora ngesikhathi ithuluzi lokubhora lijikeleziswa zinyathi nenkomo.&lt;ref name=&quot;:0&quot;&gt;Tom (1989), 103&lt;/ref&gt; Le bekuyindlela efanako esetshenziselwa ukukhipha i-petroleum e -California ngeminyaka yabo-1860 (okutjho &quot;ukumkhahlela phansi&quot;).&lt;ref name=&quot;:0&quot; /&gt;   I-Western Han dynasty bronze foundry eyatholwa e-Xinglong, e-Hebei gade inemigodi yemayini eseduze eyafikelela ekujuleni kwamamitha 100 metres (330 ft) eneendawo ezivulekileko zemayini; amashafthi namagumbi bekaphelele ngefreyimu yamapulangwe, amaladi namathulusi wensimbi.&lt;ref&gt;Loewe (1968), 191.&lt;/ref&gt; &lt;ref&gt;Wang (1982), 105.&lt;/ref&gt;  Ngekhulu lokuthoma leminyaka BC, abasebenzi bezandla be-China ababhora ngensimbi kanye nababhora bebakghona ukubhora imigodi efika 1,500 metres (4,900 ft) ukutjhinga.    Ngekhulu leminyaka elitshumi lanye AD, amaTjhayina bekakwazi ukubhora imigodi efika 900 metres (3,000 ft) ngokujula. Ukubhora imigodi bekuthatha isikhathi eside begodu kuthatha isikhathi eside. Njengombana ukujula kwemigodi bekuhlukahluka, ukubhoboza umthombo munye bekungathatha iminyaka elitshumi.  Kwaze kwaba ngekhulu leminyaka ye-19 lapho i-Europe neTjingalanga zizokuthola begodu zincintisane nethekhnoloji yokubhora imigodi ye-China yakade.  

Kwaphela iminyaka eminengi, umgodi omude kakhulu ephasini bekuyi- Kola Superdeep Borehole e-Russia. Kusukela ngomnyaka ka-2011 bekube nguRhoboyi wee-2012 irekhodi belibanjwe li- 12,345-metre (40,502 ft) ubude i-Sakhalin-I Odoptu OP-11 Kuhlekuhle, eduze nelwandle lesihlengele se-Russia i-Sakhalin .  Umthombo we -Chayvo Z-44 ofinyeleleka khulu wathatha isikhundla somgodi omude khulu ephasini mhlazi-27 kuRhoboyi wee-2012. Ukujula okulinganisiweyo kwe-Z-44 kungamamitha 12,376 metres (40,604 ft) . Kodwana, imithombo ye-ERD ayijulile ukudlula i-Kola Borehole, ngebanga lokufuduka okukhulu okuvundlileyo. NgoJulayi 2023, i-China yaqala ukubhora imigodi etjhingako, enye e- Sichuan Basin kulindeleke bona ifinyelele 10,520 metres (34,510 ft) phasi begodu enye ise- Tarim Basin ngokujula okuhleliweko 11,100 metres (36,400 ft) .  

== Indlela yokusebenza ==
 Ababholi bangacwilisa umgodi basebenzisa i -drill rig nofana i-rig esetshenziswa ngesandla. Imitshini namathekhnikhi wokuthuthukisa umgodi ayahluka kakhulu ngokuya ngomenzi, ubujamo bezesayensi, kanye nehloso ehlosiweko. Ukubhora elwandle amayunithi antantako nofana amaplatifomu asekelwa phansi kwelwandle asetshenziselwa ukubhora.
[[Isimumathi:Borehole-Manual-Digging-Process-2050-Paris.jpg|thumb|Abantu ababili abagebha umgodi bemba umgodi ngezandla]]
lkakhulu emazweni asathuthuka imigodi eminengi isagejwa ngezandla. Ukwemba kuqala ngomsebenzi wezandla kusetshenziswa amathulusi asisekelo afana namafosholo, amapiki, kanye nama-crowbar. Abasebenzi bemba ihlabathi ngesendlalelo ngesendlalelo, kanengi basebenzisa ukunyakaza okuyindilinga ukwenza umgodi omiswe kuhle. Ikambiso le ibuthakathaka begodu itlhoga, ifuna ukusebenzisana kwesiqhema nokusebenzisana. Ukukhandela bona amabhoda angawi begodu nokuqinisekisa ikhwalithi yamanzi, umgodi ufakwe izinto ezifana nezitina, amatshe, nofana amasongo wekhonkrithi. Ukuqiniswa lokhu kugcina ubuqotho besakhiwo somgodi begodu kusiza ukukhandela ukusilaphazeka. Ipulatifomu yekhonkrithi nofana ilebhu ingafakwa phansi ukukhandela bona inkunkuma ingangeni emanzini. Ingaphezulu lomgodi livalwe ukuwuvikela ekungcolisweni nokusilaphazeka. 

== Qala godu ==

* I-Askam Borehole e-Pennsylvania
* Umsiki wekheyisi
* Ukulahlwa kwemigodi etjhingako
* Isivuli somgodi
* Ukulahlwa komgodi ovundlileko
* I-Kola Superdeep Borehole
* Iphrofayili yokuzamazama komhlaba

== Umthombo wolwazi ==</text>
      <sha1>eis6bg8pho87taucpfa92gt6yhex9b3</sha1>
    </revision>
    <revision>
      <id>6718</id>
      <parentid>6717</parentid>
      <timestamp>2026-06-13T12:09:42Z</timestamp>
      <contributor>
        <username>Nozi2026</username>
        <id>1567</id>
      </contributor>
      <minor />
      <origin>6718</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7484" sha1="h9wodwxd6dayni36phwsuabrpld7yyh" xml:space="preserve">
[[Isimumathi:Borewell_digging.jpg|thumb|Ukwemba umgodi womgodi namkha umthombo wetjhubhu]]
[[Isimumathi:Borewell_digging.ogv|thumb| Ukumba umgodi]]
[[Isimumathi:Drilling_boreholes_for_clean_water_(9084603915).jpg|thumb|Owesifazana owe-Uganda uqoqa amanzi emgodini kanye nepompi yezandla enamathiselwe]]
[[Isimumathi:Borehole_01.jpg|thumb|Umthombo obhojiweko e-Ghana; umgodi awubonakali]]
'''Umgodi'''  omncane obhojwe phansi, kungaba ngokuthe nqo nofana ngokuvundlileko. Umgodi ungakhiwa ngenhloso ezinengi ezihlukahlukeneyo, kugoqela okufaka lokokukhipha amanzi ( umthombo wamanzi obhojiweko nomthombo wetjhubhu ), ezinye izinto  (ezifana ne -petroleum ), nofana lamagesi (njengegesi yemvelo ). Kungaba yingxenye yophenyo lwe-geotechnical, ukuhlolwa kwendawo yebhoduluko, ukuhlolwa kwamaminerali, ukulinganisa amazinga womtjhiso, njengomgodi wokulinga wokufaka amapayipi nofana lezisetshenziswayo ezingaphasi kwehlabathi, ukufakwa kwe-geothermal, nofana ukubulungwa ngaphasi kwehlabathi kwezinto ezingafunekiyo.

== Ukuqakatheka ==
[[Isimumathi:AlburyBoreHole.jpg|right|thumb|Umgodi wemithombo yamanzi eya e- chalk aquifer ngaphasi kwe- North Downs, e-England e -Albury]]
Omanjinela nabacebisi bezebhoduluko basebenzisa ibizo elithi ''umgodi'' ukuhlathulula ngokuhlanganyela yonke imihlobo ehlukileyo yemigodi ebhojiweko njengengcenye yophenyo lwe-geotechnical nofana ukuhlolwa kwendawo yezebhoduluko (okubizwa ngokuthi yi-Phase II ESA). Lokhu kufaka  imigodi ethuthukisiweko ukubuthelela amasampula wehlabathi, amasampula amanzi kumbe amadwala, ukuthuthukisa imitjhini yokuthatha amasampula ''endaweni'', nofana ukufaka imithombo yokutjheja nofana ama-piezometers . Amasampula abuthelelwe emigodini avamise ukuhlolwa elabhorethari ukuthola ubujamo bawo, nofana ukuhlola amazinga wamakhemikhali ahlukahlukeneko nofana izinto ezisilaphazako.

Ngokuvamileko, umgodi osetshenziswa njengomthombo wamanzi uqedwa ngokufaka ipayipi ejame ngqo (ikheyisi) nesikrini somthombo ukuvikela umgodi bona ungabhidli. Lokhu godu kusiza ukukhandela ukusilaphazeka kwephasi bona kungangeni emgodini begodu kuvikela nanyana ngiyiphi ipompo efakiweko bona ingadosi isihlabathi nenhlabathi. Imithombo yamafutha negesi yemvelo yenziwa ngendlela efanayo, nanyana ivamise ukuba yinkimbinkimbi.

Njengombana kuvezwe ngokunabileko ku- proxy (isimo sezulu), ukulinganisa amazinga womtjhiso we-borehole emlandweni wokujula okuhlukileko kunga &quot; guqulwa &quot; (ifomula yeembalo yokurarulula i-ikhweshini ye-matrix) ukusiza ukulinganisa amazinga womtjhiso wendawo yomlando.

Amaqoqo wemigodi emincani enendlela zokutshiswa ezenziwe ngepayipi yeplastiki ye-PEX ingasetshenziselwa ukugcina ukutshisa kumbe amakhaza hlangana neenkhathi eziphikisanako ngaphakathi kwamatje wemvelo. Indlela le ibizwa ngokuthi kugcinwa kwamandla womtjhiso ngesikhathi sonyaka . Iindaba ezingasetshenziselwa iqhinga leli zisukela ematjeni ukuya edwaleni. Kungaba nama-borehole ambalwa ukuya kwamakhulu amanengi, begodu ngokwenza, ukujula kwawo kusuka ku 50 to 300 metres (150 to 1,000 ft) .&lt;ref&gt;Hellström G. (2008). Large-Scale Applications of Ground-Source Heat Pumps in Sweden. IEA HP Annex 29 Workshop, Zurich, May 19, 2008.&lt;/ref&gt;&lt;ref&gt;Stiles, Lynn (June 1998). &quot;Underground thermal energy storage in the US&quot;. ''IEA Heat Pump Centre Newsletter''. '''16''' (2): 22–23.&lt;/ref&gt;  

== Umlando ==
Ukubhoboza umgodi kunomlando omude. Okungenani ngobukhosi be-Han dynasty (202&amp;nbsp;BC&amp;nbsp;– 220&amp;nbsp;AD), amaTjhayina asebenzisa ukubhora umgodi ojulileko malungana nokumba namanye amaphrojekthi. Isazi se-sinology nesazi-mlando se-Britain u-Michael Loewe uthi indawo zokubhoboza zingafikelela emamitheni 600 metres (2,000 ft) .&lt;ref&gt;Loewe (1968), 194&lt;/ref&gt;  U-KS Tom uchaza ikambiso yokubhora: &quot;Indlela yamaTjhayina yokubhora ngokujulileko yenziwa lithimba lamadoda ebeligxuma phezulu begodu liphume emgogodleni ukobana lithinte isiqephu sokubhora ngesikhathi ithuluzi lokubhora lijikeleziswa zinyathi nenkomo.&lt;ref name=&quot;:0&quot;&gt;Tom (1989), 103&lt;/ref&gt; Le bekuyindlela efanako esetshenziselwa ukukhipha i-petroleum e -California ngeminyaka yabo-1860 (okutjho &quot;ukumkhahlela phansi&quot;).&lt;ref name=&quot;:0&quot; /&gt;   I-Western Han dynasty bronze foundry eyatholwa e-Xinglong, e-Hebei gade inemigodi yemayini eseduze eyafikelela ekujuleni kwamamitha 100 metres (330 ft) eneendawo ezivulekileko zemayini; amashafthi namagumbi bekaphelele ngefreyimu yamapulangwe, amaladi namathulusi wensimbi.&lt;ref&gt;Loewe (1968), 191.&lt;/ref&gt; &lt;ref&gt;Wang (1982), 105.&lt;/ref&gt;  Ngekhulu lokuthoma leminyaka BC, abasebenzi bezandla be-China ababhora ngensimbi kanye nababhora bebakghona ukubhora imigodi efika 1,500 metres (4,900 ft) ukutjhinga.    Ngekhulu leminyaka elitshumi lanye AD, amaTjhayina bekakwazi ukubhora imigodi efika 900 metres (3,000 ft) ngokujula. Ukubhora imigodi bekuthatha isikhathi eside begodu kuthatha isikhathi eside. Njengombana ukujula kwemigodi bekuhlukahluka, ukubhoboza umthombo munye bekungathatha iminyaka elitshumi.  Kwaze kwaba ngekhulu leminyaka ye-19 lapho i-Europe neTjingalanga zizokuthola begodu zincintisane nethekhnoloji yokubhora imigodi ye-China yakade.  

Kwaphela iminyaka eminengi, umgodi omude kakhulu ephasini bekuyi- Kola Superdeep Borehole e-Russia. Kusukela ngomnyaka ka-2011 bekube nguRhoboyi wee-2012 irekhodi belibanjwe li- 12,345-metre (40,502 ft) ubude i-Sakhalin-I Odoptu OP-11 Kuhlekuhle, eduze nelwandle lesihlengele se-Russia i-Sakhalin .  Umthombo we -Chayvo Z-44 ofinyeleleka khulu wathatha isikhundla somgodi omude khulu ephasini mhlazi-27 kuRhoboyi wee-2012. Ukujula okulinganisiweyo kwe-Z-44 kungamamitha 12,376 metres (40,604 ft) . Kodwana, imithombo ye-ERD ayijulile ukudlula i-Kola Borehole, ngebanga lokufuduka okukhulu okuvundlileyo. NgoJulayi 2023, i-China yaqala ukubhora imigodi etjhingako, enye e- Sichuan Basin kulindeleke bona ifinyelele 10,520 metres (34,510 ft) phasi begodu enye ise- Tarim Basin ngokujula okuhleliweko 11,100 metres (36,400 ft) .  

== Indlela yokusebenza ==
 Ababholi bangacwilisa umgodi basebenzisa i -drill rig nofana i-rig esetshenziswa ngesandla. Imitshini namathekhnikhi wokuthuthukisa umgodi ayahluka kakhulu ngokuya ngomenzi, ubujamo bezesayensi, kanye nehloso ehlosiweko. Ukubhora elwandle amayunithi antantako nofana amaplatifomu asekelwa phansi kwelwandle asetshenziselwa ukubhora.
[[Isimumathi:Borehole-Manual-Digging-Process-2050-Paris.jpg|thumb|Abantu ababili abagebha umgodi bemba umgodi ngezandla]]
lkakhulu emazweni asathuthuka imigodi eminengi isagejwa ngezandla. Ukwemba kuqala ngomsebenzi wezandla kusetshenziswa amathulusi asisekelo afana namafosholo, amapiki, kanye nama-crowbar. Abasebenzi bemba ihlabathi ngesendlalelo ngesendlalelo, kanengi basebenzisa ukunyakaza okuyindilinga ukwenza umgodi omiswe kuhle. Ikambiso le ibuthakathaka begodu itlhoga, ifuna ukusebenzisana kwesiqhema nokusebenzisana. Ukukhandela bona amabhoda angawi begodu nokuqinisekisa ikhwalithi yamanzi, umgodi ufakwe izinto ezifana nezitina, amatshe, nofana amasongo wekhonkrithi. Ukuqiniswa lokhu kugcina ubuqotho besakhiwo somgodi begodu kusiza ukukhandela ukusilaphazeka. Ipulatifomu yekhonkrithi nofana ilebhu ingafakwa phansi ukukhandela bona inkunkuma ingangeni emanzini. Ingaphezulu lomgodi livalwe ukuwuvikela ekungcolisweni nokusilaphazeka. 

== Qala godu ==

* I-Askam Borehole e-Pennsylvania
* Umsiki wekheyisi
* Ukulahlwa kwemigodi etjhingako
* Isivuli somgodi
* Ukulahlwa komgodi ovundlileko
* I-Kola Superdeep Borehole
* Iphrofayili yokuzamazama komhlaba

== Umthombo wolwazi ==</text>
      <sha1>h9wodwxd6dayni36phwsuabrpld7yyh</sha1>
    </revision>
    <revision>
      <id>6719</id>
      <parentid>6718</parentid>
      <timestamp>2026-06-13T12:10:42Z</timestamp>
      <contributor>
        <username>Nozi2026</username>
        <id>1567</id>
      </contributor>
      <minor />
      <origin>6719</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7676" sha1="6504pzyypai82ybc6uiakysgdl907o6" xml:space="preserve">
[[Isimumathi:Borewell_digging.jpg|thumb|Ukwemba umgodi womgodi namkha umthombo wetjhubhu]]
[[Isimumathi:Borewell_digging.ogv|thumb| Ukumba umgodi]]
[[Isimumathi:Drilling_boreholes_for_clean_water_(9084603915).jpg|thumb|Owesifazana owe-Uganda uqoqa amanzi emgodini kanye nepompi yezandla enamathiselwe]]
[[Isimumathi:Borehole_01.jpg|thumb|Umthombo obhojiweko e-Ghana; umgodi awubonakali]]
'''Umgodi'''  omncane obhojwe phansi, kungaba ngokuthe nqo nofana ngokuvundlileko. Umgodi ungakhiwa ngenhloso ezinengi ezihlukahlukeneyo, kugoqela okufaka lokokukhipha amanzi ( umthombo wamanzi obhojiweko nomthombo wetjhubhu ), ezinye izinto  (ezifana ne -petroleum ), nofana lamagesi (njengegesi yemvelo ). Kungaba yingxenye yophenyo lwe-geotechnical, ukuhlolwa kwendawo yebhoduluko, ukuhlolwa kwamaminerali, ukulinganisa amazinga womtjhiso, njengomgodi wokulinga wokufaka amapayipi nofana lezisetshenziswayo ezingaphasi kwehlabathi, ukufakwa kwe-geothermal, nofana ukubulungwa ngaphasi kwehlabathi kwezinto ezingafunekiyo.

== Ukuqakatheka ==
[[Isimumathi:AlburyBoreHole.jpg|right|thumb|Umgodi wemithombo yamanzi eya e- chalk aquifer ngaphasi kwe- North Downs, e-England e -Albury]]
Omanjinela nabacebisi bezebhoduluko basebenzisa ibizo elithi ''umgodi'' ukuhlathulula ngokuhlanganyela yonke imihlobo ehlukileyo yemigodi ebhojiweko njengengcenye yophenyo lwe-geotechnical nofana ukuhlolwa kwendawo yezebhoduluko (okubizwa ngokuthi yi-Phase II ESA). Lokhu kufaka  imigodi ethuthukisiweko ukubuthelela amasampula wehlabathi, amasampula amanzi kumbe amadwala, ukuthuthukisa imitjhini yokuthatha amasampula ''endaweni'', nofana ukufaka imithombo yokutjheja nofana ama-piezometers . Amasampula abuthelelwe emigodini avamise ukuhlolwa elabhorethari ukuthola ubujamo bawo, nofana ukuhlola amazinga wamakhemikhali ahlukahlukeneko nofana izinto ezisilaphazako.

Ngokuvamileko, umgodi osetshenziswa njengomthombo wamanzi uqedwa ngokufaka ipayipi ejame ngqo (ikheyisi) nesikrini somthombo ukuvikela umgodi bona ungabhidli. Lokhu godu kusiza ukukhandela ukusilaphazeka kwephasi bona kungangeni emgodini begodu kuvikela nanyana ngiyiphi ipompo efakiweko bona ingadosi isihlabathi nenhlabathi. Imithombo yamafutha negesi yemvelo yenziwa ngendlela efanayo, nanyana ivamise ukuba yinkimbinkimbi.

Njengombana kuvezwe ngokunabileko ku- proxy (isimo sezulu), ukulinganisa amazinga womtjhiso we-borehole emlandweni wokujula okuhlukileko kunga &quot; guqulwa &quot; (ifomula yeembalo yokurarulula i-ikhweshini ye-matrix) ukusiza ukulinganisa amazinga womtjhiso wendawo yomlando.

Amaqoqo wemigodi emincani enendlela zokutshiswa ezenziwe ngepayipi yeplastiki ye-PEX ingasetshenziselwa ukugcina ukutshisa kumbe amakhaza hlangana neenkhathi eziphikisanako ngaphakathi kwamatje wemvelo. Indlela le ibizwa ngokuthi kugcinwa kwamandla womtjhiso ngesikhathi sonyaka . Iindaba ezingasetshenziselwa iqhinga leli zisukela ematjeni ukuya edwaleni. Kungaba nama-borehole ambalwa ukuya kwamakhulu amanengi, begodu ngokwenza, ukujula kwawo kusuka ku 50 to 300 metres (150 to 1,000 ft) .&lt;ref&gt;Hellström G. (2008). Large-Scale Applications of Ground-Source Heat Pumps in Sweden. IEA HP Annex 29 Workshop, Zurich, May 19, 2008.&lt;/ref&gt;&lt;ref&gt;Stiles, Lynn (June 1998). &quot;Underground thermal energy storage in the US&quot;. ''IEA Heat Pump Centre Newsletter''. '''16''' (2): 22–23.&lt;/ref&gt;  

== Umlando ==
Ukubhoboza umgodi kunomlando omude. Okungenani ngobukhosi be-Han dynasty (202&amp;nbsp;BC&amp;nbsp;– 220&amp;nbsp;AD), amaTjhayina asebenzisa ukubhora umgodi ojulileko malungana nokumba namanye amaphrojekthi. Isazi se-sinology nesazi-mlando se-Britain u-Michael Loewe uthi indawo zokubhoboza zingafikelela emamitheni 600 metres (2,000 ft) .&lt;ref&gt;Loewe (1968), 194&lt;/ref&gt;  U-KS Tom uchaza ikambiso yokubhora: &quot;Indlela yamaTjhayina yokubhora ngokujulileko yenziwa lithimba lamadoda ebeligxuma phezulu begodu liphume emgogodleni ukobana lithinte isiqephu sokubhora ngesikhathi ithuluzi lokubhora lijikeleziswa zinyathi nenkomo.&lt;ref name=&quot;:0&quot;&gt;Tom (1989), 103&lt;/ref&gt; Le bekuyindlela efanako esetshenziselwa ukukhipha i-petroleum e -California ngeminyaka yabo-1860 (okutjho &quot;ukumkhahlela phansi&quot;).&lt;ref name=&quot;:0&quot; /&gt;   I-Western Han dynasty bronze foundry eyatholwa e-Xinglong, e-Hebei gade inemigodi yemayini eseduze eyafikelela ekujuleni kwamamitha 100 metres (330 ft) eneendawo ezivulekileko zemayini; amashafthi namagumbi bekaphelele ngefreyimu yamapulangwe, amaladi namathulusi wensimbi.&lt;ref&gt;Loewe (1968), 191.&lt;/ref&gt; &lt;ref&gt;Wang (1982), 105.&lt;/ref&gt;  Ngekhulu lokuthoma leminyaka BC, abasebenzi bezandla be-China ababhora ngensimbi kanye nababhora bebakghona ukubhora imigodi efika 1,500 metres (4,900 ft) ukutjhinga. &lt;ref&gt;Hossain, M. E.; Abdullah Al-Majed, Abdulaziz (2015). ''Fundamentals of Sustainable Drilling Engineering''. Wiley-Scrivener (published March 2, 2015). ISBN &lt;bdi&gt;978-0470878170&lt;/bdi&gt;.&lt;/ref&gt;   Ngekhulu leminyaka elitshumi lanye AD, amaTjhayina bekakwazi ukubhora imigodi efika 900 metres (3,000 ft) ngokujula. Ukubhora imigodi bekuthatha isikhathi eside begodu kuthatha isikhathi eside. Njengombana ukujula kwemigodi bekuhlukahluka, ukubhoboza umthombo munye bekungathatha iminyaka elitshumi.  Kwaze kwaba ngekhulu leminyaka ye-19 lapho i-Europe neTjingalanga zizokuthola begodu zincintisane nethekhnoloji yokubhora imigodi ye-China yakade.  

Kwaphela iminyaka eminengi, umgodi omude kakhulu ephasini bekuyi- Kola Superdeep Borehole e-Russia. Kusukela ngomnyaka ka-2011 bekube nguRhoboyi wee-2012 irekhodi belibanjwe li- 12,345-metre (40,502 ft) ubude i-Sakhalin-I Odoptu OP-11 Kuhlekuhle, eduze nelwandle lesihlengele se-Russia i-Sakhalin .  Umthombo we -Chayvo Z-44 ofinyeleleka khulu wathatha isikhundla somgodi omude khulu ephasini mhlazi-27 kuRhoboyi wee-2012. Ukujula okulinganisiweyo kwe-Z-44 kungamamitha 12,376 metres (40,604 ft) . Kodwana, imithombo ye-ERD ayijulile ukudlula i-Kola Borehole, ngebanga lokufuduka okukhulu okuvundlileyo. NgoJulayi 2023, i-China yaqala ukubhora imigodi etjhingako, enye e- Sichuan Basin kulindeleke bona ifinyelele 10,520 metres (34,510 ft) phasi begodu enye ise- Tarim Basin ngokujula okuhleliweko 11,100 metres (36,400 ft) .  

== Indlela yokusebenza ==
 Ababholi bangacwilisa umgodi basebenzisa i -drill rig nofana i-rig esetshenziswa ngesandla. Imitshini namathekhnikhi wokuthuthukisa umgodi ayahluka kakhulu ngokuya ngomenzi, ubujamo bezesayensi, kanye nehloso ehlosiweko. Ukubhora elwandle amayunithi antantako nofana amaplatifomu asekelwa phansi kwelwandle asetshenziselwa ukubhora.
[[Isimumathi:Borehole-Manual-Digging-Process-2050-Paris.jpg|thumb|Abantu ababili abagebha umgodi bemba umgodi ngezandla]]
lkakhulu emazweni asathuthuka imigodi eminengi isagejwa ngezandla. Ukwemba kuqala ngomsebenzi wezandla kusetshenziswa amathulusi asisekelo afana namafosholo, amapiki, kanye nama-crowbar. Abasebenzi bemba ihlabathi ngesendlalelo ngesendlalelo, kanengi basebenzisa ukunyakaza okuyindilinga ukwenza umgodi omiswe kuhle. Ikambiso le ibuthakathaka begodu itlhoga, ifuna ukusebenzisana kwesiqhema nokusebenzisana. Ukukhandela bona amabhoda angawi begodu nokuqinisekisa ikhwalithi yamanzi, umgodi ufakwe izinto ezifana nezitina, amatshe, nofana amasongo wekhonkrithi. Ukuqiniswa lokhu kugcina ubuqotho besakhiwo somgodi begodu kusiza ukukhandela ukusilaphazeka. Ipulatifomu yekhonkrithi nofana ilebhu ingafakwa phansi ukukhandela bona inkunkuma ingangeni emanzini. Ingaphezulu lomgodi livalwe ukuwuvikela ekungcolisweni nokusilaphazeka. 

== Qala godu ==

* I-Askam Borehole e-Pennsylvania
* Umsiki wekheyisi
* Ukulahlwa kwemigodi etjhingako
* Isivuli somgodi
* Ukulahlwa komgodi ovundlileko
* I-Kola Superdeep Borehole
* Iphrofayili yokuzamazama komhlaba

== Umthombo wolwazi ==</text>
      <sha1>6504pzyypai82ybc6uiakysgdl907o6</sha1>
    </revision>
    <revision>
      <id>6720</id>
      <parentid>6719</parentid>
      <timestamp>2026-06-13T12:13:35Z</timestamp>
      <contributor>
        <username>Nozi2026</username>
        <id>1567</id>
      </contributor>
      <minor />
      <origin>6720</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7809" sha1="94l22hd8lxhdlszucg6uu3ejk28hah5" xml:space="preserve">
[[Isimumathi:Borewell_digging.jpg|thumb|Ukwemba umgodi womgodi namkha umthombo wetjhubhu]]
[[Isimumathi:Borewell_digging.ogv|thumb| Ukumba umgodi]]
[[Isimumathi:Drilling_boreholes_for_clean_water_(9084603915).jpg|thumb|Owesifazana owe-Uganda uqoqa amanzi emgodini kanye nepompi yezandla enamathiselwe]]
[[Isimumathi:Borehole_01.jpg|thumb|Umthombo obhojiweko e-Ghana; umgodi awubonakali]]
'''Umgodi'''  omncane obhojwe phansi, kungaba ngokuthe nqo nofana ngokuvundlileko. Umgodi ungakhiwa ngenhloso ezinengi ezihlukahlukeneyo, kugoqela okufaka lokokukhipha amanzi ( umthombo wamanzi obhojiweko nomthombo wetjhubhu ), ezinye izinto  (ezifana ne -petroleum ), nofana lamagesi (njengegesi yemvelo ). Kungaba yingxenye yophenyo lwe-geotechnical, ukuhlolwa kwendawo yebhoduluko, ukuhlolwa kwamaminerali, ukulinganisa amazinga womtjhiso, njengomgodi wokulinga wokufaka amapayipi nofana lezisetshenziswayo ezingaphasi kwehlabathi, ukufakwa kwe-geothermal, nofana ukubulungwa ngaphasi kwehlabathi kwezinto ezingafunekiyo.

== Ukuqakatheka ==
[[Isimumathi:AlburyBoreHole.jpg|right|thumb|Umgodi wemithombo yamanzi eya e- chalk aquifer ngaphasi kwe- North Downs, e-England e -Albury]]
Omanjinela nabacebisi bezebhoduluko basebenzisa ibizo elithi ''umgodi'' ukuhlathulula ngokuhlanganyela yonke imihlobo ehlukileyo yemigodi ebhojiweko njengengcenye yophenyo lwe-geotechnical nofana ukuhlolwa kwendawo yezebhoduluko (okubizwa ngokuthi yi-Phase II ESA). Lokhu kufaka  imigodi ethuthukisiweko ukubuthelela amasampula wehlabathi, amasampula amanzi kumbe amadwala, ukuthuthukisa imitjhini yokuthatha amasampula ''endaweni'', nofana ukufaka imithombo yokutjheja nofana ama-piezometers . Amasampula abuthelelwe emigodini avamise ukuhlolwa elabhorethari ukuthola ubujamo bawo, nofana ukuhlola amazinga wamakhemikhali ahlukahlukeneko nofana izinto ezisilaphazako.

Ngokuvamileko, umgodi osetshenziswa njengomthombo wamanzi uqedwa ngokufaka ipayipi ejame ngqo (ikheyisi) nesikrini somthombo ukuvikela umgodi bona ungabhidli. Lokhu godu kusiza ukukhandela ukusilaphazeka kwephasi bona kungangeni emgodini begodu kuvikela nanyana ngiyiphi ipompo efakiweko bona ingadosi isihlabathi nenhlabathi. Imithombo yamafutha negesi yemvelo yenziwa ngendlela efanayo, nanyana ivamise ukuba yinkimbinkimbi.

Njengombana kuvezwe ngokunabileko ku- proxy (isimo sezulu), ukulinganisa amazinga womtjhiso we-borehole emlandweni wokujula okuhlukileko kunga &quot; guqulwa &quot; (ifomula yeembalo yokurarulula i-ikhweshini ye-matrix) ukusiza ukulinganisa amazinga womtjhiso wendawo yomlando.

Amaqoqo wemigodi emincani enendlela zokutshiswa ezenziwe ngepayipi yeplastiki ye-PEX ingasetshenziselwa ukugcina ukutshisa kumbe amakhaza hlangana neenkhathi eziphikisanako ngaphakathi kwamatje wemvelo. Indlela le ibizwa ngokuthi kugcinwa kwamandla womtjhiso ngesikhathi sonyaka . Iindaba ezingasetshenziselwa iqhinga leli zisukela ematjeni ukuya edwaleni. Kungaba nama-borehole ambalwa ukuya kwamakhulu amanengi, begodu ngokwenza, ukujula kwawo kusuka ku 50 to 300 metres (150 to 1,000 ft) .&lt;ref&gt;Hellström G. (2008). Large-Scale Applications of Ground-Source Heat Pumps in Sweden. IEA HP Annex 29 Workshop, Zurich, May 19, 2008.&lt;/ref&gt;&lt;ref&gt;Stiles, Lynn (June 1998). &quot;Underground thermal energy storage in the US&quot;. ''IEA Heat Pump Centre Newsletter''. '''16''' (2): 22–23.&lt;/ref&gt;  

== Umlando ==
Ukubhoboza umgodi kunomlando omude. Okungenani ngobukhosi be-Han dynasty (202&amp;nbsp;BC&amp;nbsp;– 220&amp;nbsp;AD), amaTjhayina asebenzisa ukubhora umgodi ojulileko malungana nokumba namanye amaphrojekthi. Isazi se-sinology nesazi-mlando se-Britain u-Michael Loewe uthi indawo zokubhoboza zingafikelela emamitheni 600 metres (2,000 ft) .&lt;ref&gt;Loewe (1968), 194&lt;/ref&gt;  U-KS Tom uchaza ikambiso yokubhora: &quot;Indlela yamaTjhayina yokubhora ngokujulileko yenziwa lithimba lamadoda ebeligxuma phezulu begodu liphume emgogodleni ukobana lithinte isiqephu sokubhora ngesikhathi ithuluzi lokubhora lijikeleziswa zinyathi nenkomo.&lt;ref name=&quot;:0&quot;&gt;Tom (1989), 103&lt;/ref&gt; Le bekuyindlela efanako esetshenziselwa ukukhipha i-petroleum e -California ngeminyaka yabo-1860 (okutjho &quot;ukumkhahlela phansi&quot;). &lt;ref&gt;Hobson, John M. (2004). ''The Eastern Origins of Western Civilisation''. Cambridge University Press. p. 215. ISBN &lt;bdi&gt;978-0521547246&lt;/bdi&gt;.&lt;/ref&gt; I-Western Han dynasty bronze foundry eyatholwa e-Xinglong, e-Hebei gade inemigodi yemayini eseduze eyafikelela ekujuleni kwamamitha 100 metres (330 ft) eneendawo ezivulekileko zemayini; amashafthi namagumbi bekaphelele ngefreyimu yamapulangwe, amaladi namathulusi wensimbi.&lt;ref&gt;Loewe (1968), 191.&lt;/ref&gt; &lt;ref&gt;Wang (1982), 105.&lt;/ref&gt;  Ngekhulu lokuthoma leminyaka BC, abasebenzi bezandla be-China ababhora ngensimbi kanye nababhora bebakghona ukubhora imigodi efika 1,500 metres (4,900 ft) ukutjhinga. &lt;ref&gt;Hossain, M. E.; Abdullah Al-Majed, Abdulaziz (2015). ''Fundamentals of Sustainable Drilling Engineering''. Wiley-Scrivener (published March 2, 2015). ISBN &lt;bdi&gt;978-0470878170&lt;/bdi&gt;.&lt;/ref&gt;   Ngekhulu leminyaka elitshumi lanye AD, amaTjhayina bekakwazi ukubhora imigodi efika 900 metres (3,000 ft) ngokujula. Ukubhora imigodi bekuthatha isikhathi eside begodu kuthatha isikhathi eside. Njengombana ukujula kwemigodi bekuhlukahluka, ukubhoboza umthombo munye bekungathatha iminyaka elitshumi.  Kwaze kwaba ngekhulu leminyaka ye-19 lapho i-Europe neTjingalanga zizokuthola begodu zincintisane nethekhnoloji yokubhora imigodi ye-China yakade.  

Kwaphela iminyaka eminengi, umgodi omude kakhulu ephasini bekuyi- Kola Superdeep Borehole e-Russia. Kusukela ngomnyaka ka-2011 bekube nguRhoboyi wee-2012 irekhodi belibanjwe li- 12,345-metre (40,502 ft) ubude i-Sakhalin-I Odoptu OP-11 Kuhlekuhle, eduze nelwandle lesihlengele se-Russia i-Sakhalin .  Umthombo we -Chayvo Z-44 ofinyeleleka khulu wathatha isikhundla somgodi omude khulu ephasini mhlazi-27 kuRhoboyi wee-2012. Ukujula okulinganisiweyo kwe-Z-44 kungamamitha 12,376 metres (40,604 ft) . Kodwana, imithombo ye-ERD ayijulile ukudlula i-Kola Borehole, ngebanga lokufuduka okukhulu okuvundlileyo. NgoJulayi 2023, i-China yaqala ukubhora imigodi etjhingako, enye e- Sichuan Basin kulindeleke bona ifinyelele 10,520 metres (34,510 ft) phasi begodu enye ise- Tarim Basin ngokujula okuhleliweko 11,100 metres (36,400 ft) .  

== Indlela yokusebenza ==
 Ababholi bangacwilisa umgodi basebenzisa i -drill rig nofana i-rig esetshenziswa ngesandla. Imitshini namathekhnikhi wokuthuthukisa umgodi ayahluka kakhulu ngokuya ngomenzi, ubujamo bezesayensi, kanye nehloso ehlosiweko. Ukubhora elwandle amayunithi antantako nofana amaplatifomu asekelwa phansi kwelwandle asetshenziselwa ukubhora.
[[Isimumathi:Borehole-Manual-Digging-Process-2050-Paris.jpg|thumb|Abantu ababili abagebha umgodi bemba umgodi ngezandla]]
lkakhulu emazweni asathuthuka imigodi eminengi isagejwa ngezandla. Ukwemba kuqala ngomsebenzi wezandla kusetshenziswa amathulusi asisekelo afana namafosholo, amapiki, kanye nama-crowbar. Abasebenzi bemba ihlabathi ngesendlalelo ngesendlalelo, kanengi basebenzisa ukunyakaza okuyindilinga ukwenza umgodi omiswe kuhle. Ikambiso le ibuthakathaka begodu itlhoga, ifuna ukusebenzisana kwesiqhema nokusebenzisana. Ukukhandela bona amabhoda angawi begodu nokuqinisekisa ikhwalithi yamanzi, umgodi ufakwe izinto ezifana nezitina, amatshe, nofana amasongo wekhonkrithi. Ukuqiniswa lokhu kugcina ubuqotho besakhiwo somgodi begodu kusiza ukukhandela ukusilaphazeka. Ipulatifomu yekhonkrithi nofana ilebhu ingafakwa phansi ukukhandela bona inkunkuma ingangeni emanzini. Ingaphezulu lomgodi livalwe ukuwuvikela ekungcolisweni nokusilaphazeka. 

== Qala godu ==

* I-Askam Borehole e-Pennsylvania
* Umsiki wekheyisi
* Ukulahlwa kwemigodi etjhingako
* Isivuli somgodi
* Ukulahlwa komgodi ovundlileko
* I-Kola Superdeep Borehole
* Iphrofayili yokuzamazama komhlaba

== Umthombo wolwazi ==</text>
      <sha1>94l22hd8lxhdlszucg6uu3ejk28hah5</sha1>
    </revision>
    <revision>
      <id>6721</id>
      <parentid>6720</parentid>
      <timestamp>2026-06-13T12:17:51Z</timestamp>
      <contributor>
        <username>Nozi2026</username>
        <id>1567</id>
      </contributor>
      <minor />
      <origin>6721</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7939" sha1="40rjxajlb04xtdwxneyaf4jcebqt72a" xml:space="preserve">
[[Isimumathi:Borewell_digging.jpg|thumb|Ukwemba umgodi womgodi namkha umthombo wetjhubhu]]
[[Isimumathi:Borewell_digging.ogv|thumb| Ukumba umgodi]]
[[Isimumathi:Drilling_boreholes_for_clean_water_(9084603915).jpg|thumb|Owesifazana owe-Uganda uqoqa amanzi emgodini kanye nepompi yezandla enamathiselwe]]
[[Isimumathi:Borehole_01.jpg|thumb|Umthombo obhojiweko e-Ghana; umgodi awubonakali]]
'''Umgodi'''  omncane obhojwe phansi, kungaba ngokuthe nqo nofana ngokuvundlileko. Umgodi ungakhiwa ngenhloso ezinengi ezihlukahlukeneyo, kugoqela okufaka lokokukhipha amanzi ( umthombo wamanzi obhojiweko nomthombo wetjhubhu ), ezinye izinto  (ezifana ne -petroleum ), nofana lamagesi (njengegesi yemvelo ). Kungaba yingxenye yophenyo lwe-geotechnical, ukuhlolwa kwendawo yebhoduluko, ukuhlolwa kwamaminerali, ukulinganisa amazinga womtjhiso, njengomgodi wokulinga wokufaka amapayipi nofana lezisetshenziswayo ezingaphasi kwehlabathi, ukufakwa kwe-geothermal, nofana ukubulungwa ngaphasi kwehlabathi kwezinto ezingafunekiyo.

== Ukuqakatheka ==
[[Isimumathi:AlburyBoreHole.jpg|right|thumb|Umgodi wemithombo yamanzi eya e- chalk aquifer ngaphasi kwe- North Downs, e-England e -Albury]]
Omanjinela nabacebisi bezebhoduluko basebenzisa ibizo elithi ''umgodi'' ukuhlathulula ngokuhlanganyela yonke imihlobo ehlukileyo yemigodi ebhojiweko njengengcenye yophenyo lwe-geotechnical nofana ukuhlolwa kwendawo yezebhoduluko (okubizwa ngokuthi yi-Phase II ESA). Lokhu kufaka  imigodi ethuthukisiweko ukubuthelela amasampula wehlabathi, amasampula amanzi kumbe amadwala, ukuthuthukisa imitjhini yokuthatha amasampula ''endaweni'', nofana ukufaka imithombo yokutjheja nofana ama-piezometers . Amasampula abuthelelwe emigodini avamise ukuhlolwa elabhorethari ukuthola ubujamo bawo, nofana ukuhlola amazinga wamakhemikhali ahlukahlukeneko nofana izinto ezisilaphazako.

Ngokuvamileko, umgodi osetshenziswa njengomthombo wamanzi uqedwa ngokufaka ipayipi ejame ngqo (ikheyisi) nesikrini somthombo ukuvikela umgodi bona ungabhidli. Lokhu godu kusiza ukukhandela ukusilaphazeka kwephasi bona kungangeni emgodini begodu kuvikela nanyana ngiyiphi ipompo efakiweko bona ingadosi isihlabathi nenhlabathi. Imithombo yamafutha negesi yemvelo yenziwa ngendlela efanayo, nanyana ivamise ukuba yinkimbinkimbi.

Njengombana kuvezwe ngokunabileko ku- proxy (isimo sezulu), ukulinganisa amazinga womtjhiso we-borehole emlandweni wokujula okuhlukileko kunga &quot; guqulwa &quot; (ifomula yeembalo yokurarulula i-ikhweshini ye-matrix) ukusiza ukulinganisa amazinga womtjhiso wendawo yomlando.

Amaqoqo wemigodi emincani enendlela zokutshiswa ezenziwe ngepayipi yeplastiki ye-PEX ingasetshenziselwa ukugcina ukutshisa kumbe amakhaza hlangana neenkhathi eziphikisanako ngaphakathi kwamatje wemvelo. Indlela le ibizwa ngokuthi kugcinwa kwamandla womtjhiso ngesikhathi sonyaka . Iindaba ezingasetshenziselwa iqhinga leli zisukela ematjeni ukuya edwaleni. Kungaba nama-borehole ambalwa ukuya kwamakhulu amanengi, begodu ngokwenza, ukujula kwawo kusuka ku 50 to 300 metres (150 to 1,000 ft) .&lt;ref&gt;Hellström G. (2008). Large-Scale Applications of Ground-Source Heat Pumps in Sweden. IEA HP Annex 29 Workshop, Zurich, May 19, 2008.&lt;/ref&gt;&lt;ref&gt;Stiles, Lynn (June 1998). &quot;Underground thermal energy storage in the US&quot;. ''IEA Heat Pump Centre Newsletter''. '''16''' (2): 22–23.&lt;/ref&gt;  

== Umlando ==
Ukubhoboza umgodi kunomlando omude. Okungenani ngobukhosi be-Han dynasty (202&amp;nbsp;BC&amp;nbsp;– 220&amp;nbsp;AD), amaTjhayina asebenzisa ukubhora umgodi ojulileko malungana nokumba namanye amaphrojekthi. Isazi se-sinology nesazi-mlando se-Britain u-Michael Loewe uthi indawo zokubhoboza zingafikelela emamitheni 600 metres (2,000 ft) .&lt;ref&gt;Loewe (1968), 194&lt;/ref&gt;  U-KS Tom uchaza ikambiso yokubhora: &quot;Indlela yamaTjhayina yokubhora ngokujulileko yenziwa lithimba lamadoda ebeligxuma phezulu begodu liphume emgogodleni ukobana lithinte isiqephu sokubhora ngesikhathi ithuluzi lokubhora lijikeleziswa zinyathi nenkomo.&lt;ref name=&quot;:0&quot;&gt;Tom (1989), 103&lt;/ref&gt; Le bekuyindlela efanako esetshenziselwa ukukhipha i-petroleum e -California ngeminyaka yabo-1860 (okutjho &quot;ukumkhahlela phansi&quot;). &lt;ref&gt;Hobson, John M. (2004). ''The Eastern Origins of Western Civilisation''. Cambridge University Press. p. 215. ISBN &lt;bdi&gt;978-0521547246&lt;/bdi&gt;.&lt;/ref&gt; I-Western Han dynasty bronze foundry eyatholwa e-Xinglong, e-Hebei gade inemigodi yemayini eseduze eyafikelela ekujuleni kwamamitha 100 metres (330 ft) eneendawo ezivulekileko zemayini; amashafthi namagumbi bekaphelele ngefreyimu yamapulangwe, amaladi namathulusi wensimbi.&lt;ref&gt;Loewe (1968), 191.&lt;/ref&gt; &lt;ref&gt;Wang (1982), 105.&lt;/ref&gt;  Ngekhulu lokuthoma leminyaka BC, abasebenzi bezandla be-China ababhora ngensimbi kanye nababhora bebakghona ukubhora imigodi efika 1,500 metres (4,900 ft) ukutjhinga. &lt;ref&gt;Hossain, M. E.; Abdullah Al-Majed, Abdulaziz (2015). ''Fundamentals of Sustainable Drilling Engineering''. Wiley-Scrivener (published March 2, 2015). ISBN &lt;bdi&gt;978-0470878170&lt;/bdi&gt;.&lt;/ref&gt;  &lt;ref&gt;Rezende, Lisa (2007). ''Chronology of Science''. Checkmark Books (published April 1, 2007). pp. 40. ISBN 978-0816071197&lt;/ref&gt; Ngekhulu leminyaka elitshumi lanye AD, amaTjhayina bekakwazi ukubhora imigodi efika 900 metres (3,000 ft) ngokujula. Ukubhora imigodi bekuthatha isikhathi eside begodu kuthatha isikhathi eside. Njengombana ukujula kwemigodi bekuhlukahluka, ukubhoboza umthombo munye bekungathatha iminyaka elitshumi.  Kwaze kwaba ngekhulu leminyaka ye-19 lapho i-Europe neTjingalanga zizokuthola begodu zincintisane nethekhnoloji yokubhora imigodi ye-China yakade.  

Kwaphela iminyaka eminengi, umgodi omude kakhulu ephasini bekuyi- Kola Superdeep Borehole e-Russia. Kusukela ngomnyaka ka-2011 bekube nguRhoboyi wee-2012 irekhodi belibanjwe li- 12,345-metre (40,502 ft) ubude i-Sakhalin-I Odoptu OP-11 Kuhlekuhle, eduze nelwandle lesihlengele se-Russia i-Sakhalin .  Umthombo we -Chayvo Z-44 ofinyeleleka khulu wathatha isikhundla somgodi omude khulu ephasini mhlazi-27 kuRhoboyi wee-2012. Ukujula okulinganisiweyo kwe-Z-44 kungamamitha 12,376 metres (40,604 ft) . Kodwana, imithombo ye-ERD ayijulile ukudlula i-Kola Borehole, ngebanga lokufuduka okukhulu okuvundlileyo. NgoJulayi 2023, i-China yaqala ukubhora imigodi etjhingako, enye e- Sichuan Basin kulindeleke bona ifinyelele 10,520 metres (34,510 ft) phasi begodu enye ise- Tarim Basin ngokujula okuhleliweko 11,100 metres (36,400 ft) .  

== Indlela yokusebenza ==
 Ababholi bangacwilisa umgodi basebenzisa i -drill rig nofana i-rig esetshenziswa ngesandla. Imitshini namathekhnikhi wokuthuthukisa umgodi ayahluka kakhulu ngokuya ngomenzi, ubujamo bezesayensi, kanye nehloso ehlosiweko. Ukubhora elwandle amayunithi antantako nofana amaplatifomu asekelwa phansi kwelwandle asetshenziselwa ukubhora.
[[Isimumathi:Borehole-Manual-Digging-Process-2050-Paris.jpg|thumb|Abantu ababili abagebha umgodi bemba umgodi ngezandla]]
lkakhulu emazweni asathuthuka imigodi eminengi isagejwa ngezandla. Ukwemba kuqala ngomsebenzi wezandla kusetshenziswa amathulusi asisekelo afana namafosholo, amapiki, kanye nama-crowbar. Abasebenzi bemba ihlabathi ngesendlalelo ngesendlalelo, kanengi basebenzisa ukunyakaza okuyindilinga ukwenza umgodi omiswe kuhle. Ikambiso le ibuthakathaka begodu itlhoga, ifuna ukusebenzisana kwesiqhema nokusebenzisana. Ukukhandela bona amabhoda angawi begodu nokuqinisekisa ikhwalithi yamanzi, umgodi ufakwe izinto ezifana nezitina, amatshe, nofana amasongo wekhonkrithi. Ukuqiniswa lokhu kugcina ubuqotho besakhiwo somgodi begodu kusiza ukukhandela ukusilaphazeka. Ipulatifomu yekhonkrithi nofana ilebhu ingafakwa phansi ukukhandela bona inkunkuma ingangeni emanzini. Ingaphezulu lomgodi livalwe ukuwuvikela ekungcolisweni nokusilaphazeka. 

== Qala godu ==

* I-Askam Borehole e-Pennsylvania
* Umsiki wekheyisi
* Ukulahlwa kwemigodi etjhingako
* Isivuli somgodi
* Ukulahlwa komgodi ovundlileko
* I-Kola Superdeep Borehole
* Iphrofayili yokuzamazama komhlaba

== Umthombo wolwazi ==</text>
      <sha1>40rjxajlb04xtdwxneyaf4jcebqt72a</sha1>
    </revision>
    <revision>
      <id>6722</id>
      <parentid>6721</parentid>
      <timestamp>2026-06-13T12:20:26Z</timestamp>
      <contributor>
        <username>Nozi2026</username>
        <id>1567</id>
      </contributor>
      <minor />
      <origin>6722</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8133" sha1="0lpgr9v8vwccoz10kz4sqwg5817sthi" xml:space="preserve">
[[Isimumathi:Borewell_digging.jpg|thumb|Ukwemba umgodi womgodi namkha umthombo wetjhubhu]]
[[Isimumathi:Borewell_digging.ogv|thumb| Ukumba umgodi]]
[[Isimumathi:Drilling_boreholes_for_clean_water_(9084603915).jpg|thumb|Owesifazana owe-Uganda uqoqa amanzi emgodini kanye nepompi yezandla enamathiselwe]]
[[Isimumathi:Borehole_01.jpg|thumb|Umthombo obhojiweko e-Ghana; umgodi awubonakali]]
'''Umgodi'''  omncane obhojwe phansi, kungaba ngokuthe nqo nofana ngokuvundlileko. Umgodi ungakhiwa ngenhloso ezinengi ezihlukahlukeneyo, kugoqela okufaka lokokukhipha amanzi ( umthombo wamanzi obhojiweko nomthombo wetjhubhu ), ezinye izinto  (ezifana ne -petroleum ), nofana lamagesi (njengegesi yemvelo ). Kungaba yingxenye yophenyo lwe-geotechnical, ukuhlolwa kwendawo yebhoduluko, ukuhlolwa kwamaminerali, ukulinganisa amazinga womtjhiso, njengomgodi wokulinga wokufaka amapayipi nofana lezisetshenziswayo ezingaphasi kwehlabathi, ukufakwa kwe-geothermal, nofana ukubulungwa ngaphasi kwehlabathi kwezinto ezingafunekiyo.

== Ukuqakatheka ==
[[Isimumathi:AlburyBoreHole.jpg|right|thumb|Umgodi wemithombo yamanzi eya e- chalk aquifer ngaphasi kwe- North Downs, e-England e -Albury]]
Omanjinela nabacebisi bezebhoduluko basebenzisa ibizo elithi ''umgodi'' ukuhlathulula ngokuhlanganyela yonke imihlobo ehlukileyo yemigodi ebhojiweko njengengcenye yophenyo lwe-geotechnical nofana ukuhlolwa kwendawo yezebhoduluko (okubizwa ngokuthi yi-Phase II ESA). Lokhu kufaka  imigodi ethuthukisiweko ukubuthelela amasampula wehlabathi, amasampula amanzi kumbe amadwala, ukuthuthukisa imitjhini yokuthatha amasampula ''endaweni'', nofana ukufaka imithombo yokutjheja nofana ama-piezometers . Amasampula abuthelelwe emigodini avamise ukuhlolwa elabhorethari ukuthola ubujamo bawo, nofana ukuhlola amazinga wamakhemikhali ahlukahlukeneko nofana izinto ezisilaphazako.

Ngokuvamileko, umgodi osetshenziswa njengomthombo wamanzi uqedwa ngokufaka ipayipi ejame ngqo (ikheyisi) nesikrini somthombo ukuvikela umgodi bona ungabhidli. Lokhu godu kusiza ukukhandela ukusilaphazeka kwephasi bona kungangeni emgodini begodu kuvikela nanyana ngiyiphi ipompo efakiweko bona ingadosi isihlabathi nenhlabathi. Imithombo yamafutha negesi yemvelo yenziwa ngendlela efanayo, nanyana ivamise ukuba yinkimbinkimbi.

Njengombana kuvezwe ngokunabileko ku- proxy (isimo sezulu), ukulinganisa amazinga womtjhiso we-borehole emlandweni wokujula okuhlukileko kunga &quot; guqulwa &quot; (ifomula yeembalo yokurarulula i-ikhweshini ye-matrix) ukusiza ukulinganisa amazinga womtjhiso wendawo yomlando.

Amaqoqo wemigodi emincani enendlela zokutshiswa ezenziwe ngepayipi yeplastiki ye-PEX ingasetshenziselwa ukugcina ukutshisa kumbe amakhaza hlangana neenkhathi eziphikisanako ngaphakathi kwamatje wemvelo. Indlela le ibizwa ngokuthi kugcinwa kwamandla womtjhiso ngesikhathi sonyaka . Iindaba ezingasetshenziselwa iqhinga leli zisukela ematjeni ukuya edwaleni. Kungaba nama-borehole ambalwa ukuya kwamakhulu amanengi, begodu ngokwenza, ukujula kwawo kusuka ku 50 to 300 metres (150 to 1,000 ft) .&lt;ref&gt;Hellström G. (2008). Large-Scale Applications of Ground-Source Heat Pumps in Sweden. IEA HP Annex 29 Workshop, Zurich, May 19, 2008.&lt;/ref&gt;&lt;ref&gt;Stiles, Lynn (June 1998). &quot;Underground thermal energy storage in the US&quot;. ''IEA Heat Pump Centre Newsletter''. '''16''' (2): 22–23.&lt;/ref&gt;  

== Umlando ==
Ukubhoboza umgodi kunomlando omude. Okungenani ngobukhosi be-Han dynasty (202&amp;nbsp;BC&amp;nbsp;– 220&amp;nbsp;AD), amaTjhayina asebenzisa ukubhora umgodi ojulileko malungana nokumba namanye amaphrojekthi. Isazi se-sinology nesazi-mlando se-Britain u-Michael Loewe uthi indawo zokubhoboza zingafikelela emamitheni 6&lt;ref&gt;Conner, Clifford D. (2005). ''A People's History of Science: Miners, Midwives, and Low Mechanicks''. Nation Books. pp. 175. ISBN &lt;bdi&gt;978-1560257486&lt;/bdi&gt;.&lt;/ref&gt;00 metres (2,000 ft) .&lt;ref name=&quot;:1&quot;&gt;Loewe (1968), 194&lt;/ref&gt;  U-KS Tom uchaza ikambiso yokubhora: &quot;Indlela yamaTjhayina yokubhora ngokujulileko yenziwa lithimba lamadoda ebeligxuma phezulu begodu liphume emgogodleni ukobana lithinte isiqephu sokubhora ngesikhathi ithuluzi lokubhora lijikeleziswa zinyathi nenkomo.&lt;ref name=&quot;:0&quot;&gt;Tom (1989), 103&lt;/ref&gt; Le bekuyindlela efanako esetshenziselwa ukukhipha i-petroleum e -California ngeminyaka yabo-1860 (okutjho &quot;ukumkhahlela phansi&quot;). &lt;ref&gt;Hobson, John M. (2004). ''The Eastern Origins of Western Civilisation''. Cambridge University Press. p. 215. ISBN &lt;bdi&gt;978-0521547246&lt;/bdi&gt;.&lt;/ref&gt; I-Western Han dynasty bronze foundry eyatholwa e-Xinglong, e-Hebei gade inemigodi yemayini eseduze eyafikelela ekujuleni kwamamitha 100 metres (330 ft) eneendawo ezivulekileko zemayini; amashafthi namagumbi bekaphelele ngefreyimu yamapulangwe, amaladi namathulusi wensimbi.&lt;ref&gt;Loewe (1968), 191.&lt;/ref&gt; &lt;ref&gt;Wang (1982), 105.&lt;/ref&gt;  Ngekhulu lokuthoma leminyaka BC, abasebenzi bezandla be-China ababhora ngensimbi kanye nababhora bebakghona ukubhora imigodi efika 1,500 metres (4,900 ft) ukutjhinga. &lt;ref&gt;Hossain, M. E.; Abdullah Al-Majed, Abdulaziz (2015). ''Fundamentals of Sustainable Drilling Engineering''. Wiley-Scrivener (published March 2, 2015). ISBN &lt;bdi&gt;978-0470878170&lt;/bdi&gt;.&lt;/ref&gt;  &lt;ref&gt;Rezende, Lisa (2007). ''Chronology of Science''. Checkmark Books (published April 1, 2007). pp. 40. ISBN 978-0816071197&lt;/ref&gt;  Ngekhulu leminyaka elitshumi lanye AD, amaTjhayina bekakwazi ukubhora imigodi efika 900 metres (3,000 ft) ngokujula. Ukubhora imigodi bekuthatha isikhathi eside begodu kuthatha isikhathi eside. Njengombana ukujula kwemigodi bekuhlukahluka, ukubhoboza umthombo munye bekungathatha iminyaka elitshumi.&lt;ref name=&quot;:1&quot; /&gt;  Kwaze kwaba ngekhulu leminyaka ye-19 lapho i-Europe neTjingalanga zizokuthola begodu zincintisane nethekhnoloji yokubhora imigodi ye-China yakade.  

Kwaphela iminyaka eminengi, umgodi omude kakhulu ephasini bekuyi- Kola Superdeep Borehole e-Russia. Kusukela ngomnyaka ka-2011 bekube nguRhoboyi wee-2012 irekhodi belibanjwe li- 12,345-metre (40,502 ft) ubude i-Sakhalin-I Odoptu OP-11 Kuhlekuhle, eduze nelwandle lesihlengele se-Russia i-Sakhalin .  Umthombo we -Chayvo Z-44 ofinyeleleka khulu wathatha isikhundla somgodi omude khulu ephasini mhlazi-27 kuRhoboyi wee-2012. Ukujula okulinganisiweyo kwe-Z-44 kungamamitha 12,376 metres (40,604 ft) . Kodwana, imithombo ye-ERD ayijulile ukudlula i-Kola Borehole, ngebanga lokufuduka okukhulu okuvundlileyo. NgoJulayi 2023, i-China yaqala ukubhora imigodi etjhingako, enye e- Sichuan Basin kulindeleke bona ifinyelele 10,520 metres (34,510 ft) phasi begodu enye ise- Tarim Basin ngokujula okuhleliweko 11,100 metres (36,400 ft) .  

== Indlela yokusebenza ==
 Ababholi bangacwilisa umgodi basebenzisa i -drill rig nofana i-rig esetshenziswa ngesandla. Imitshini namathekhnikhi wokuthuthukisa umgodi ayahluka kakhulu ngokuya ngomenzi, ubujamo bezesayensi, kanye nehloso ehlosiweko. Ukubhora elwandle amayunithi antantako nofana amaplatifomu asekelwa phansi kwelwandle asetshenziselwa ukubhora.
[[Isimumathi:Borehole-Manual-Digging-Process-2050-Paris.jpg|thumb|Abantu ababili abagebha umgodi bemba umgodi ngezandla]]
lkakhulu emazweni asathuthuka imigodi eminengi isagejwa ngezandla. Ukwemba kuqala ngomsebenzi wezandla kusetshenziswa amathulusi asisekelo afana namafosholo, amapiki, kanye nama-crowbar. Abasebenzi bemba ihlabathi ngesendlalelo ngesendlalelo, kanengi basebenzisa ukunyakaza okuyindilinga ukwenza umgodi omiswe kuhle. Ikambiso le ibuthakathaka begodu itlhoga, ifuna ukusebenzisana kwesiqhema nokusebenzisana. Ukukhandela bona amabhoda angawi begodu nokuqinisekisa ikhwalithi yamanzi, umgodi ufakwe izinto ezifana nezitina, amatshe, nofana amasongo wekhonkrithi. Ukuqiniswa lokhu kugcina ubuqotho besakhiwo somgodi begodu kusiza ukukhandela ukusilaphazeka. Ipulatifomu yekhonkrithi nofana ilebhu ingafakwa phansi ukukhandela bona inkunkuma ingangeni emanzini. Ingaphezulu lomgodi livalwe ukuwuvikela ekungcolisweni nokusilaphazeka. 

== Qala godu ==

* I-Askam Borehole e-Pennsylvania
* Umsiki wekheyisi
* Ukulahlwa kwemigodi etjhingako
* Isivuli somgodi
* Ukulahlwa komgodi ovundlileko
* I-Kola Superdeep Borehole
* Iphrofayili yokuzamazama komhlaba

== Umthombo wolwazi ==</text>
      <sha1>0lpgr9v8vwccoz10kz4sqwg5817sthi</sha1>
    </revision>
    <revision>
      <id>6723</id>
      <parentid>6722</parentid>
      <timestamp>2026-06-13T12:22:10Z</timestamp>
      <contributor>
        <username>Nozi2026</username>
        <id>1567</id>
      </contributor>
      <minor />
      <origin>6723</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8160" sha1="ggvws867y21gaakqqlpnge1rl38ori9" xml:space="preserve">
[[Isimumathi:Borewell_digging.jpg|thumb|Ukwemba umgodi womgodi namkha umthombo wetjhubhu]]
[[Isimumathi:Borewell_digging.ogv|thumb| Ukumba umgodi]]
[[Isimumathi:Drilling_boreholes_for_clean_water_(9084603915).jpg|thumb|Owesifazana owe-Uganda uqoqa amanzi emgodini kanye nepompi yezandla enamathiselwe]]
[[Isimumathi:Borehole_01.jpg|thumb|Umthombo obhojiweko e-Ghana; umgodi awubonakali]]
'''Umgodi'''  omncane obhojwe phansi, kungaba ngokuthe nqo nofana ngokuvundlileko. Umgodi ungakhiwa ngenhloso ezinengi ezihlukahlukeneyo, kugoqela okufaka lokokukhipha amanzi ( umthombo wamanzi obhojiweko nomthombo wetjhubhu ), ezinye izinto  (ezifana ne -petroleum ), nofana lamagesi (njengegesi yemvelo ). Kungaba yingxenye yophenyo lwe-geotechnical, ukuhlolwa kwendawo yebhoduluko, ukuhlolwa kwamaminerali, ukulinganisa amazinga womtjhiso, njengomgodi wokulinga wokufaka amapayipi nofana lezisetshenziswayo ezingaphasi kwehlabathi, ukufakwa kwe-geothermal, nofana ukubulungwa ngaphasi kwehlabathi kwezinto ezingafunekiyo.

== Ukuqakatheka ==
[[Isimumathi:AlburyBoreHole.jpg|right|thumb|Umgodi wemithombo yamanzi eya e- chalk aquifer ngaphasi kwe- North Downs, e-England e -Albury]]
Omanjinela nabacebisi bezebhoduluko basebenzisa ibizo elithi ''umgodi'' ukuhlathulula ngokuhlanganyela yonke imihlobo ehlukileyo yemigodi ebhojiweko njengengcenye yophenyo lwe-geotechnical nofana ukuhlolwa kwendawo yezebhoduluko (okubizwa ngokuthi yi-Phase II ESA). Lokhu kufaka  imigodi ethuthukisiweko ukubuthelela amasampula wehlabathi, amasampula amanzi kumbe amadwala, ukuthuthukisa imitjhini yokuthatha amasampula ''endaweni'', nofana ukufaka imithombo yokutjheja nofana ama-piezometers . Amasampula abuthelelwe emigodini avamise ukuhlolwa elabhorethari ukuthola ubujamo bawo, nofana ukuhlola amazinga wamakhemikhali ahlukahlukeneko nofana izinto ezisilaphazako.

Ngokuvamileko, umgodi osetshenziswa njengomthombo wamanzi uqedwa ngokufaka ipayipi ejame ngqo (ikheyisi) nesikrini somthombo ukuvikela umgodi bona ungabhidli. Lokhu godu kusiza ukukhandela ukusilaphazeka kwephasi bona kungangeni emgodini begodu kuvikela nanyana ngiyiphi ipompo efakiweko bona ingadosi isihlabathi nenhlabathi. Imithombo yamafutha negesi yemvelo yenziwa ngendlela efanayo, nanyana ivamise ukuba yinkimbinkimbi.

Njengombana kuvezwe ngokunabileko ku- proxy (isimo sezulu), ukulinganisa amazinga womtjhiso we-borehole emlandweni wokujula okuhlukileko kunga &quot; guqulwa &quot; (ifomula yeembalo yokurarulula i-ikhweshini ye-matrix) ukusiza ukulinganisa amazinga womtjhiso wendawo yomlando.

Amaqoqo wemigodi emincani enendlela zokutshiswa ezenziwe ngepayipi yeplastiki ye-PEX ingasetshenziselwa ukugcina ukutshisa kumbe amakhaza hlangana neenkhathi eziphikisanako ngaphakathi kwamatje wemvelo. Indlela le ibizwa ngokuthi kugcinwa kwamandla womtjhiso ngesikhathi sonyaka . Iindaba ezingasetshenziselwa iqhinga leli zisukela ematjeni ukuya edwaleni. Kungaba nama-borehole ambalwa ukuya kwamakhulu amanengi, begodu ngokwenza, ukujula kwawo kusuka ku 50 to 300 metres (150 to 1,000 ft) .&lt;ref&gt;Hellström G. (2008). Large-Scale Applications of Ground-Source Heat Pumps in Sweden. IEA HP Annex 29 Workshop, Zurich, May 19, 2008.&lt;/ref&gt;&lt;ref&gt;Stiles, Lynn (June 1998). &quot;Underground thermal energy storage in the US&quot;. ''IEA Heat Pump Centre Newsletter''. '''16''' (2): 22–23.&lt;/ref&gt;  

== Umlando ==
Ukubhoboza umgodi kunomlando omude. Okungenani ngobukhosi be-Han dynasty (202&amp;nbsp;BC&amp;nbsp;– 220&amp;nbsp;AD), amaTjhayina asebenzisa ukubhora umgodi ojulileko malungana nokumba namanye amaphrojekthi. Isazi se-sinology nesazi-mlando se-Britain u-Michael Loewe uthi indawo zokubhoboza zingafikelela emamitheni 6&lt;ref&gt;Conner, Clifford D. (2005). ''A People's History of Science: Miners, Midwives, and Low Mechanicks''. Nation Books. pp. 175. ISBN &lt;bdi&gt;978-1560257486&lt;/bdi&gt;.&lt;/ref&gt;00 metres (2,000 ft) .&lt;ref name=&quot;:1&quot;&gt;Loewe (1968), 194&lt;/ref&gt;  U-KS Tom uchaza ikambiso yokubhora: &quot;Indlela yamaTjhayina yokubhora ngokujulileko yenziwa lithimba lamadoda ebeligxuma phezulu begodu liphume emgogodleni ukobana lithinte isiqephu sokubhora ngesikhathi ithuluzi lokubhora lijikeleziswa zinyathi nenkomo.&lt;ref name=&quot;:0&quot;&gt;Tom (1989), 103&lt;/ref&gt; Le bekuyindlela efanako esetshenziselwa ukukhipha i-petroleum e -California ngeminyaka yabo-1860 (okutjho &quot;ukumkhahlela phansi&quot;). &lt;ref&gt;Hobson, John M. (2004). ''The Eastern Origins of Western Civilisation''. Cambridge University Press. p. 215. ISBN &lt;bdi&gt;978-0521547246&lt;/bdi&gt;.&lt;/ref&gt; I-Western Han dynasty bronze foundry eyatholwa e-Xinglong, e-Hebei gade inemigodi yemayini eseduze eyafikelela ekujuleni kwamamitha 100 metres (330 ft) eneendawo ezivulekileko zemayini; amashafthi namagumbi bekaphelele ngefreyimu yamapulangwe, amaladi namathulusi wensimbi.&lt;ref&gt;Loewe (1968), 191.&lt;/ref&gt; &lt;ref&gt;Wang (1982), 105.&lt;/ref&gt;  Ngekhulu lokuthoma leminyaka BC, abasebenzi bezandla be-China ababhora ngensimbi kanye nababhora bebakghona ukubhora imigodi efika 1,500 metres (4,900 ft) ukutjhinga. &lt;ref&gt;Hossain, M. E.; Abdullah Al-Majed, Abdulaziz (2015). ''Fundamentals of Sustainable Drilling Engineering''. Wiley-Scrivener (published March 2, 2015). ISBN &lt;bdi&gt;978-0470878170&lt;/bdi&gt;.&lt;/ref&gt;  &lt;ref name=&quot;:2&quot;&gt;Rezende, Lisa (2007). ''Chronology of Science''. Checkmark Books (published April 1, 2007). pp. 40. ISBN 978-0816071197&lt;/ref&gt;  Ngekhulu leminyaka elitshumi lanye AD, amaTjhayina bekakwazi ukubhora imigodi efika 900 metres (3,000 ft) ngokujula. Ukubhora imigodi bekuthatha isikhathi eside begodu kuthatha isikhathi eside. Njengombana ukujula kwemigodi bekuhlukahluka, ukubhoboza umthombo munye bekungathatha iminyaka elitshumi.&lt;ref name=&quot;:1&quot; /&gt;  Kwaze kwaba ngekhulu leminyaka ye-19 lapho i-Europe neTjingalanga zizokuthola begodu zincintisane nethekhnoloji yokubhora imigodi ye-China yakade.&lt;ref name=&quot;:2&quot; /&gt;  

Kwaphela iminyaka eminengi, umgodi omude kakhulu ephasini bekuyi- Kola Superdeep Borehole e-Russia. Kusukela ngomnyaka ka-2011 bekube nguRhoboyi wee-2012 irekhodi belibanjwe li- 12,345-metre (40,502 ft) ubude i-Sakhalin-I Odoptu OP-11 Kuhlekuhle, eduze nelwandle lesihlengele se-Russia i-Sakhalin .  Umthombo we -Chayvo Z-44 ofinyeleleka khulu wathatha isikhundla somgodi omude khulu ephasini mhlazi-27 kuRhoboyi wee-2012. Ukujula okulinganisiweyo kwe-Z-44 kungamamitha 12,376 metres (40,604 ft) . Kodwana, imithombo ye-ERD ayijulile ukudlula i-Kola Borehole, ngebanga lokufuduka okukhulu okuvundlileyo. NgoJulayi 2023, i-China yaqala ukubhora imigodi etjhingako, enye e- Sichuan Basin kulindeleke bona ifinyelele 10,520 metres (34,510 ft) phasi begodu enye ise- Tarim Basin ngokujula okuhleliweko 11,100 metres (36,400 ft) .  

== Indlela yokusebenza ==
 Ababholi bangacwilisa umgodi basebenzisa i -drill rig nofana i-rig esetshenziswa ngesandla. Imitshini namathekhnikhi wokuthuthukisa umgodi ayahluka kakhulu ngokuya ngomenzi, ubujamo bezesayensi, kanye nehloso ehlosiweko. Ukubhora elwandle amayunithi antantako nofana amaplatifomu asekelwa phansi kwelwandle asetshenziselwa ukubhora.
[[Isimumathi:Borehole-Manual-Digging-Process-2050-Paris.jpg|thumb|Abantu ababili abagebha umgodi bemba umgodi ngezandla]]
lkakhulu emazweni asathuthuka imigodi eminengi isagejwa ngezandla. Ukwemba kuqala ngomsebenzi wezandla kusetshenziswa amathulusi asisekelo afana namafosholo, amapiki, kanye nama-crowbar. Abasebenzi bemba ihlabathi ngesendlalelo ngesendlalelo, kanengi basebenzisa ukunyakaza okuyindilinga ukwenza umgodi omiswe kuhle. Ikambiso le ibuthakathaka begodu itlhoga, ifuna ukusebenzisana kwesiqhema nokusebenzisana. Ukukhandela bona amabhoda angawi begodu nokuqinisekisa ikhwalithi yamanzi, umgodi ufakwe izinto ezifana nezitina, amatshe, nofana amasongo wekhonkrithi. Ukuqiniswa lokhu kugcina ubuqotho besakhiwo somgodi begodu kusiza ukukhandela ukusilaphazeka. Ipulatifomu yekhonkrithi nofana ilebhu ingafakwa phansi ukukhandela bona inkunkuma ingangeni emanzini. Ingaphezulu lomgodi livalwe ukuwuvikela ekungcolisweni nokusilaphazeka. 

== Qala godu ==

* I-Askam Borehole e-Pennsylvania
* Umsiki wekheyisi
* Ukulahlwa kwemigodi etjhingako
* Isivuli somgodi
* Ukulahlwa komgodi ovundlileko
* I-Kola Superdeep Borehole
* Iphrofayili yokuzamazama komhlaba

== Umthombo wolwazi ==</text>
      <sha1>ggvws867y21gaakqqlpnge1rl38ori9</sha1>
    </revision>
    <revision>
      <id>6724</id>
      <parentid>6723</parentid>
      <timestamp>2026-06-13T12:22:59Z</timestamp>
      <contributor>
        <username>Nozi2026</username>
        <id>1567</id>
      </contributor>
      <minor />
      <origin>6724</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8178" sha1="68b1y2nw1dgspjnnw1gyypkqjxc1701" xml:space="preserve">
[[Isimumathi:Borewell_digging.jpg|thumb|Ukwemba umgodi womgodi namkha umthombo wetjhubhu]]
[[Isimumathi:Borewell_digging.ogv|thumb| Ukumba umgodi]]
[[Isimumathi:Drilling_boreholes_for_clean_water_(9084603915).jpg|thumb|Owesifazana owe-Uganda uqoqa amanzi emgodini kanye nepompi yezandla enamathiselwe]]
[[Isimumathi:Borehole_01.jpg|thumb|Umthombo obhojiweko e-Ghana; umgodi awubonakali]]
'''Umgodi'''  omncane obhojwe phansi, kungaba ngokuthe nqo nofana ngokuvundlileko. Umgodi ungakhiwa ngenhloso ezinengi ezihlukahlukeneyo, kugoqela okufaka lokokukhipha amanzi ( umthombo wamanzi obhojiweko nomthombo wetjhubhu ), ezinye izinto  (ezifana ne -petroleum ), nofana lamagesi (njengegesi yemvelo ). Kungaba yingxenye yophenyo lwe-geotechnical, ukuhlolwa kwendawo yebhoduluko, ukuhlolwa kwamaminerali, ukulinganisa amazinga womtjhiso, njengomgodi wokulinga wokufaka amapayipi nofana lezisetshenziswayo ezingaphasi kwehlabathi, ukufakwa kwe-geothermal, nofana ukubulungwa ngaphasi kwehlabathi kwezinto ezingafunekiyo.

== Ukuqakatheka ==
[[Isimumathi:AlburyBoreHole.jpg|right|thumb|Umgodi wemithombo yamanzi eya e- chalk aquifer ngaphasi kwe- North Downs, e-England e -Albury]]
Omanjinela nabacebisi bezebhoduluko basebenzisa ibizo elithi ''umgodi'' ukuhlathulula ngokuhlanganyela yonke imihlobo ehlukileyo yemigodi ebhojiweko njengengcenye yophenyo lwe-geotechnical nofana ukuhlolwa kwendawo yezebhoduluko (okubizwa ngokuthi yi-Phase II ESA). Lokhu kufaka  imigodi ethuthukisiweko ukubuthelela amasampula wehlabathi, amasampula amanzi kumbe amadwala, ukuthuthukisa imitjhini yokuthatha amasampula ''endaweni'', nofana ukufaka imithombo yokutjheja nofana ama-piezometers . Amasampula abuthelelwe emigodini avamise ukuhlolwa elabhorethari ukuthola ubujamo bawo, nofana ukuhlola amazinga wamakhemikhali ahlukahlukeneko nofana izinto ezisilaphazako.

Ngokuvamileko, umgodi osetshenziswa njengomthombo wamanzi uqedwa ngokufaka ipayipi ejame ngqo (ikheyisi) nesikrini somthombo ukuvikela umgodi bona ungabhidli. Lokhu godu kusiza ukukhandela ukusilaphazeka kwephasi bona kungangeni emgodini begodu kuvikela nanyana ngiyiphi ipompo efakiweko bona ingadosi isihlabathi nenhlabathi. Imithombo yamafutha negesi yemvelo yenziwa ngendlela efanayo, nanyana ivamise ukuba yinkimbinkimbi.

Njengombana kuvezwe ngokunabileko ku- proxy (isimo sezulu), ukulinganisa amazinga womtjhiso we-borehole emlandweni wokujula okuhlukileko kunga &quot; guqulwa &quot; (ifomula yeembalo yokurarulula i-ikhweshini ye-matrix) ukusiza ukulinganisa amazinga womtjhiso wendawo yomlando.

Amaqoqo wemigodi emincani enendlela zokutshiswa ezenziwe ngepayipi yeplastiki ye-PEX ingasetshenziselwa ukugcina ukutshisa kumbe amakhaza hlangana neenkhathi eziphikisanako ngaphakathi kwamatje wemvelo. Indlela le ibizwa ngokuthi kugcinwa kwamandla womtjhiso ngesikhathi sonyaka . Iindaba ezingasetshenziselwa iqhinga leli zisukela ematjeni ukuya edwaleni. Kungaba nama-borehole ambalwa ukuya kwamakhulu amanengi, begodu ngokwenza, ukujula kwawo kusuka ku 50 to 300 metres (150 to 1,000 ft) .&lt;ref&gt;Hellström G. (2008). Large-Scale Applications of Ground-Source Heat Pumps in Sweden. IEA HP Annex 29 Workshop, Zurich, May 19, 2008.&lt;/ref&gt;&lt;ref&gt;Stiles, Lynn (June 1998). &quot;Underground thermal energy storage in the US&quot;. ''IEA Heat Pump Centre Newsletter''. '''16''' (2): 22–23.&lt;/ref&gt;  

== Umlando ==
Ukubhoboza umgodi kunomlando omude. Okungenani ngobukhosi be-Han dynasty (202&amp;nbsp;BC&amp;nbsp;– 220&amp;nbsp;AD), amaTjhayina asebenzisa ukubhora umgodi ojulileko malungana nokumba namanye amaphrojekthi. Isazi se-sinology nesazi-mlando se-Britain u-Michael Loewe uthi indawo zokubhoboza zingafikelela emamitheni 6&lt;ref&gt;Conner, Clifford D. (2005). ''A People's History of Science: Miners, Midwives, and Low Mechanicks''. Nation Books. pp. 175. ISBN &lt;bdi&gt;978-1560257486&lt;/bdi&gt;.&lt;/ref&gt;00 metres (2,000 ft) .&lt;ref name=&quot;:1&quot;&gt;Loewe (1968), 194&lt;/ref&gt;  U-KS Tom uchaza ikambiso yokubhora: &quot;Indlela yamaTjhayina yokubhora ngokujulileko yenziwa lithimba lamadoda ebeligxuma phezulu begodu liphume emgogodleni ukobana lithinte isiqephu sokubhora ngesikhathi ithuluzi lokubhora lijikeleziswa zinyathi nenkomo.&lt;ref name=&quot;:0&quot;&gt;Tom (1989), 103&lt;/ref&gt; Le bekuyindlela efanako esetshenziselwa ukukhipha i-petroleum e -California ngeminyaka yabo-1860 (okutjho &quot;ukumkhahlela phansi&quot;). &lt;ref&gt;Hobson, John M. (2004). ''The Eastern Origins of Western Civilisation''. Cambridge University Press. p. 215. ISBN &lt;bdi&gt;978-0521547246&lt;/bdi&gt;.&lt;/ref&gt; I-Western Han dynasty bronze foundry eyatholwa e-Xinglong, e-Hebei gade inemigodi yemayini eseduze eyafikelela ekujuleni kwamamitha 100 metres (330 ft) eneendawo ezivulekileko zemayini; amashafthi namagumbi bekaphelele ngefreyimu yamapulangwe, amaladi namathulusi wensimbi.&lt;ref&gt;Loewe (1968), 191.&lt;/ref&gt; &lt;ref&gt;Wang (1982), 105.&lt;/ref&gt;  Ngekhulu lokuthoma leminyaka BC, abasebenzi bezandla be-China ababhora ngensimbi kanye nababhora bebakghona ukubhora imigodi efika 1,500 metres (4,900 ft) ukutjhinga. &lt;ref&gt;Hossain, M. E.; Abdullah Al-Majed, Abdulaziz (2015). ''Fundamentals of Sustainable Drilling Engineering''. Wiley-Scrivener (published March 2, 2015). ISBN &lt;bdi&gt;978-0470878170&lt;/bdi&gt;.&lt;/ref&gt;  &lt;ref name=&quot;:2&quot;&gt;Rezende, Lisa (2007). ''Chronology of Science''. Checkmark Books (published April 1, 2007). pp. 40. ISBN 978-0816071197&lt;/ref&gt;  Ngekhulu leminyaka elitshumi lanye AD, amaTjhayina bekakwazi ukubhora imigodi efika 900 metres (3,000 ft) ngokujula. Ukubhora imigodi bekuthatha isikhathi eside begodu kuthatha isikhathi eside. Njengombana ukujula kwemigodi bekuhlukahluka, ukubhoboza umthombo munye bekungathatha iminyaka elitshumi.&lt;ref name=&quot;:1&quot; /&gt;  Kwaze kwaba ngekhulu leminyaka ye-19 lapho i-Europe neTjingalanga zizokuthola begodu zincintisane nethekhnoloji yokubhora imigodi ye-China yakade.&lt;ref name=&quot;:2&quot; /&gt; &lt;ref name=&quot;:0&quot; /&gt;  

Kwaphela iminyaka eminengi, umgodi omude kakhulu ephasini bekuyi- Kola Superdeep Borehole e-Russia. Kusukela ngomnyaka ka-2011 bekube nguRhoboyi wee-2012 irekhodi belibanjwe li- 12,345-metre (40,502 ft) ubude i-Sakhalin-I Odoptu OP-11 Kuhlekuhle, eduze nelwandle lesihlengele se-Russia i-Sakhalin .  Umthombo we -Chayvo Z-44 ofinyeleleka khulu wathatha isikhundla somgodi omude khulu ephasini mhlazi-27 kuRhoboyi wee-2012. Ukujula okulinganisiweyo kwe-Z-44 kungamamitha 12,376 metres (40,604 ft) . Kodwana, imithombo ye-ERD ayijulile ukudlula i-Kola Borehole, ngebanga lokufuduka okukhulu okuvundlileyo. NgoJulayi 2023, i-China yaqala ukubhora imigodi etjhingako, enye e- Sichuan Basin kulindeleke bona ifinyelele 10,520 metres (34,510 ft) phasi begodu enye ise- Tarim Basin ngokujula okuhleliweko 11,100 metres (36,400 ft) .  

== Indlela yokusebenza ==
 Ababholi bangacwilisa umgodi basebenzisa i -drill rig nofana i-rig esetshenziswa ngesandla. Imitshini namathekhnikhi wokuthuthukisa umgodi ayahluka kakhulu ngokuya ngomenzi, ubujamo bezesayensi, kanye nehloso ehlosiweko. Ukubhora elwandle amayunithi antantako nofana amaplatifomu asekelwa phansi kwelwandle asetshenziselwa ukubhora.
[[Isimumathi:Borehole-Manual-Digging-Process-2050-Paris.jpg|thumb|Abantu ababili abagebha umgodi bemba umgodi ngezandla]]
lkakhulu emazweni asathuthuka imigodi eminengi isagejwa ngezandla. Ukwemba kuqala ngomsebenzi wezandla kusetshenziswa amathulusi asisekelo afana namafosholo, amapiki, kanye nama-crowbar. Abasebenzi bemba ihlabathi ngesendlalelo ngesendlalelo, kanengi basebenzisa ukunyakaza okuyindilinga ukwenza umgodi omiswe kuhle. Ikambiso le ibuthakathaka begodu itlhoga, ifuna ukusebenzisana kwesiqhema nokusebenzisana. Ukukhandela bona amabhoda angawi begodu nokuqinisekisa ikhwalithi yamanzi, umgodi ufakwe izinto ezifana nezitina, amatshe, nofana amasongo wekhonkrithi. Ukuqiniswa lokhu kugcina ubuqotho besakhiwo somgodi begodu kusiza ukukhandela ukusilaphazeka. Ipulatifomu yekhonkrithi nofana ilebhu ingafakwa phansi ukukhandela bona inkunkuma ingangeni emanzini. Ingaphezulu lomgodi livalwe ukuwuvikela ekungcolisweni nokusilaphazeka. 

== Qala godu ==

* I-Askam Borehole e-Pennsylvania
* Umsiki wekheyisi
* Ukulahlwa kwemigodi etjhingako
* Isivuli somgodi
* Ukulahlwa komgodi ovundlileko
* I-Kola Superdeep Borehole
* Iphrofayili yokuzamazama komhlaba

== Umthombo wolwazi ==</text>
      <sha1>68b1y2nw1dgspjnnw1gyypkqjxc1701</sha1>
    </revision>
    <revision>
      <id>6725</id>
      <parentid>6724</parentid>
      <timestamp>2026-06-13T12:25:43Z</timestamp>
      <contributor>
        <username>Nozi2026</username>
        <id>1567</id>
      </contributor>
      <minor />
      <origin>6725</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8176" sha1="0wspbi9vr24z0tbodecglklo01yi2jk" xml:space="preserve">
[[Isimumathi:Borewell_digging.jpg|thumb|Ukwemba umgodi womgodi namkha umthombo wetjhubhu]]
[[Isimumathi:Borewell_digging.ogv|thumb| Ukumba umgodi]]
[[Isimumathi:Drilling_boreholes_for_clean_water_(9084603915).jpg|thumb|Owesifazana owe-Uganda uqoqa amanzi emgodini kanye nepompi yezandla enamathiselwe]]
[[Isimumathi:Borehole_01.jpg|thumb|Umthombo obhojiweko e-Ghana; umgodi awubonakali]]
'''Umgodi'''  omncane obhojwe phansi, kungaba ngokuthe nqo nofana ngokuvundlileko. Umgodi ungakhiwa ngenhloso ezinengi ezihlukahlukeneyo, kugoqela okufaka lokokukhipha amanzi ( umthombo wamanzi obhojiweko nomthombo wetjhubhu ), ezinye izinto  (ezifana ne -petroleum ), nofana lamagesi (njengegesi yemvelo ). Kungaba yingxenye yophenyo lwe-geotechnical, ukuhlolwa kwendawo yebhoduluko, ukuhlolwa kwamaminerali, ukulinganisa amazinga womtjhiso, njengomgodi wokulinga wokufaka amapayipi nofana lezisetshenziswayo ezingaphasi kwehlabathi, ukufakwa kwe-geothermal, nofana ukubulungwa ngaphasi kwehlabathi kwezinto ezingafunekiyo.

== Ukuqakatheka ==
[[Isimumathi:AlburyBoreHole.jpg|right|thumb|Umgodi wemithombo yamanzi eya e- chalk aquifer ngaphasi kwe- North Downs, e-England e -Albury]]
Omanjinela nabacebisi bezebhoduluko basebenzisa ibizo elithi ''umgodi'' ukuhlathulula ngokuhlanganyela yonke imihlobo ehlukileyo yemigodi ebhojiweko njengengcenye yophenyo lwe-geotechnical nofana ukuhlolwa kwendawo yezebhoduluko (okubizwa ngokuthi yi-Phase II ESA). Lokhu kufaka  imigodi ethuthukisiweko ukubuthelela amasampula wehlabathi, amasampula amanzi kumbe amadwala, ukuthuthukisa imitjhini yokuthatha amasampula ''endaweni'', nofana ukufaka imithombo yokutjheja nofana ama-piezometers . Amasampula abuthelelwe emigodini avamise ukuhlolwa elabhorethari ukuthola ubujamo bawo, nofana ukuhlola amazinga wamakhemikhali ahlukahlukeneko nofana izinto ezisilaphazako.

Ngokuvamileko, umgodi osetshenziswa njengomthombo wamanzi uqedwa ngokufaka ipayipi ejame ngqo (ikheyisi) nesikrini somthombo ukuvikela umgodi bona ungabhidli. Lokhu godu kusiza ukukhandela ukusilaphazeka kwephasi bona kungangeni emgodini begodu kuvikela nanyana ngiyiphi ipompo efakiweko bona ingadosi isihlabathi nenhlabathi. Imithombo yamafutha negesi yemvelo yenziwa ngendlela efanayo, nanyana ivamise ukuba yinkimbinkimbi.

Njengombana kuvezwe ngokunabileko ku- proxy (isimo sezulu), ukulinganisa amazinga womtjhiso we-borehole emlandweni wokujula okuhlukileko kunga &quot; guqulwa &quot; (ifomula yeembalo yokurarulula i-ikhweshini ye-matrix) ukusiza ukulinganisa amazinga womtjhiso wendawo yomlando.

Amaqoqo wemigodi emincani enendlela zokutshiswa ezenziwe ngepayipi yeplastiki ye-PEX ingasetshenziselwa ukugcina ukutshisa kumbe amakhaza hlangana neenkhathi eziphikisanako ngaphakathi kwamatje wemvelo. Indlela le ibizwa ngokuthi kugcinwa kwamandla womtjhiso ngesikhathi sonyaka . Iindaba ezingasetshenziselwa iqhinga leli zisukela ematjeni ukuya edwaleni. Kungaba nama-borehole ambalwa ukuya kwamakhulu amanengi, begodu ngokwenza, ukujula kwawo kusuka ku 50 to 300 metres (150 to 1,000 ft) .&lt;ref&gt;Hellström G. (2008). Large-Scale Applications of Ground-Source Heat Pumps in Sweden. IEA HP Annex 29 Workshop, Zurich, May 19, 2008.&lt;/ref&gt;&lt;ref&gt;Stiles, Lynn (June 1998). &quot;Underground thermal energy storage in the US&quot;. ''IEA Heat Pump Centre Newsletter''. '''16''' (2): 22–23.&lt;/ref&gt;  

== Umlando ==
Ukubhoboza umgodi kunomlando omude. Okungenani ngobukhosi be-Han dynasty (202&amp;nbsp;BC&amp;nbsp;– 220&amp;nbsp;AD), amaTjhayina asebenzisa ukubhora umgodi ojulileko malungana nokumba namanye amaphrojekthi. Isazi se-sinology nesazi-mlando se-Britain u-Michael Loewe uthi indawo zokubhoboza zingafikelela emamitheni 6&lt;ref&gt;Conner, Clifford D. (2005). ''A People's History of Science: Miners, Midwives, and Low Mechanicks''. Nation Books. pp. 175. ISBN &lt;bdi&gt;978-1560257486&lt;/bdi&gt;.&lt;/ref&gt;00 metres (2,000 ft) .&lt;ref name=&quot;:1&quot;&gt;Loewe (1968), 194&lt;/ref&gt;  U-KS Tom uchaza ikambiso yokubhora: &quot;Indlela yamaTjhayina yokubhora ngokujulileko yenziwa lithimba lamadoda ebeligxuma phezulu begodu liphume emgogodleni ukobana lithinte isiqephu sokubhora ngesikhathi ithuluzi lokubhora lijikeleziswa zinyathi nenkomo.&lt;ref name=&quot;:0&quot;&gt;Tom (1989), 103&lt;/ref&gt; Le bekuyindlela efanako esetshenziselwa ukukhipha i-petroleum e -California ngeminyaka yabo-1860 (okutjho &quot;ukumkhahlela phansi&quot;). &lt;ref&gt;Hobson, John M. (2004). ''The Eastern Origins of Western Civilisation''. Cambridge University Press. p. 215. ISBN &lt;bdi&gt;978-0521547246&lt;/bdi&gt;.&lt;/ref&gt; I-Western Han dynasty bronze foundry eyatholwa e-Xinglong, e-Hebei gade inemigodi yemayini eseduze eyafikelela ekujuleni kwamamitha 100 metres (330 ft) eneendawo ezivulekileko zemayini; amashafthi namagumbi bekaphelele ngefreyimu yamapulangwe, amaladi namathulusi wensimbi.&lt;ref&gt;Loewe (1968), 191.&lt;/ref&gt; &lt;ref&gt;Wang (1982), 105.&lt;/ref&gt;  Ngekhulu lokuthoma leminyaka BC, abasebenzi bezandla be-China ababhora ngensimbi kanye nababhora bebakghona ukubhora imigodi efika 1,500 metres (4,900 ft) ukutjhinga. &lt;ref&gt;Hossain, M. E.; Abdullah Al-Majed, Abdulaziz (2015). ''Fundamentals of Sustainable Drilling Engineering''. Wiley-Scrivener (published March 2, 2015). ISBN &lt;bdi&gt;978-0470878170&lt;/bdi&gt;.&lt;/ref&gt;  &lt;ref name=&quot;:2&quot;&gt;Rezende, Lisa (2007). ''Chronology of Science''. Checkmark Books (published April 1, 2007). pp. 40. ISBN 978-0816071197&lt;/ref&gt;  Ngekhulu leminyaka elitshumi lanye AD, amaTjhayina bekakwazi ukubhora imigodi efika 900 metres (3,000 ft) ngokujula. Ukubhora imigodi bekuthatha isikhathi eside begodu kuthatha isikhathi eside. Njengombana ukujula kwemigodi bekuhlukahluka, ukubhoboza umthombo munye bekungathatha iminyaka elitshumi.&lt;ref name=&quot;:1&quot; /&gt;  Kwaze kwaba ngekhulu leminyaka ye-19 lapho i-Europe neTjingalanga zizokuthola begodu zincintisane nethekhnoloji yokubhora imigodi ye-China yakade.&lt;ref name=&quot;:2&quot; /&gt; &lt;ref name=&quot;:0&quot; /&gt;  

Kwaphela iminyaka eminengi, umgodi omude kakhulu ephasini bekuyi- Kola Superdeep Borehole e-Russia. Kusukela ngomnyaka ka-2011 bekube nguRhoboyi wee-2012 irekhodi belibanjwe li- 12,345-metre (40,502 ft) ubude i-Sakhalin-I Odoptu OP- Kuhlekuhle, eduze nelwandle lesihlengele se-Russia i-Sakhalin .  Umthombo we -Chayvo Z-44 ofinyeleleka khulu wathatha isikhundla somgodi omude khulu ephasini mhlazi-27 kuRhoboyi wee-2012. Ukujula okulinganisiweyo kwe-Z-44 kungamamitha 12,376 metres (40,604 ft) . Kodwana, imithombo ye-ERD ayijulile ukudlula i-Kola Borehole, ngebanga lokufuduka okukhulu okuvundlileyo. NgoJulayi 2023, i-China yaqala ukubhora imigodi etjhingako, enye e- Sichuan Basin kulindeleke bona ifinyelele 10,520 metres (34,510 ft) phasi begodu enye ise- Tarim Basin ngokujula okuhleliweko 11,100 metres (36,400 ft) .  

== Indlela yokusebenza ==
 Ababholi bangacwilisa umgodi basebenzisa i -drill rig nofana i-rig esetshenziswa ngesandla. Imitshini namathekhnikhi wokuthuthukisa umgodi ayahluka kakhulu ngokuya ngomenzi, ubujamo bezesayensi, kanye nehloso ehlosiweko. Ukubhora elwandle amayunithi antantako nofana amaplatifomu asekelwa phansi kwelwandle asetshenziselwa ukubhora.
[[Isimumathi:Borehole-Manual-Digging-Process-2050-Paris.jpg|thumb|Abantu ababili abagebha umgodi bemba umgodi ngezandla]]
lkakhulu emazweni asathuthuka imigodi eminengi isagejwa ngezandla. Ukwemba kuqala ngomsebenzi wezandla kusetshenziswa amathulusi asisekelo afana namafosholo, amapiki, kanye nama-crowbar. Abasebenzi bemba ihlabathi ngesendlalelo ngesendlalelo, kanengi basebenzisa ukunyakaza okuyindilinga ukwenza umgodi omiswe kuhle. Ikambiso le ibuthakathaka begodu itlhoga, ifuna ukusebenzisana kwesiqhema nokusebenzisana. Ukukhandela bona amabhoda angawi begodu nokuqinisekisa ikhwalithi yamanzi, umgodi ufakwe izinto ezifana nezitina, amatshe, nofana amasongo wekhonkrithi. Ukuqiniswa lokhu kugcina ubuqotho besakhiwo somgodi begodu kusiza ukukhandela ukusilaphazeka. Ipulatifomu yekhonkrithi nofana ilebhu ingafakwa phansi ukukhandela bona inkunkuma ingangeni emanzini. Ingaphezulu lomgodi livalwe ukuwuvikela ekungcolisweni nokusilaphazeka. 

== Qala godu ==

* I-Askam Borehole e-Pennsylvania
* Umsiki wekheyisi
* Ukulahlwa kwemigodi etjhingako
* Isivuli somgodi
* Ukulahlwa komgodi ovundlileko
* I-Kola Superdeep Borehole
* Iphrofayili yokuzamazama komhlaba

== Umthombo wolwazi ==</text>
      <sha1>0wspbi9vr24z0tbodecglklo01yi2jk</sha1>
    </revision>
    <revision>
      <id>6726</id>
      <parentid>6725</parentid>
      <timestamp>2026-06-13T12:28:52Z</timestamp>
      <contributor>
        <username>Nozi2026</username>
        <id>1567</id>
      </contributor>
      <minor />
      <origin>6726</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="8290" sha1="9on5u0pdtrns3ptel90i0cajchq92pz" xml:space="preserve">
[[Isimumathi:Borewell_digging.jpg|thumb|Ukwemba umgodi womgodi namkha umthombo wetjhubhu]]
[[Isimumathi:Borewell_digging.ogv|thumb| Ukumba umgodi]]
[[Isimumathi:Drilling_boreholes_for_clean_water_(9084603915).jpg|thumb|Owesifazana owe-Uganda uqoqa amanzi emgodini kanye nepompi yezandla enamathiselwe]]
[[Isimumathi:Borehole_01.jpg|thumb|Umthombo obhojiweko e-Ghana; umgodi awubonakali]]
'''Umgodi'''  omncane obhojwe phansi, kungaba ngokuthe nqo nofana ngokuvundlileko. Umgodi ungakhiwa ngenhloso ezinengi ezihlukahlukeneyo, kugoqela okufaka lokokukhipha amanzi ( umthombo wamanzi obhojiweko nomthombo wetjhubhu ), ezinye izinto  (ezifana ne -petroleum ), nofana lamagesi (njengegesi yemvelo ). Kungaba yingxenye yophenyo lwe-geotechnical, ukuhlolwa kwendawo yebhoduluko, ukuhlolwa kwamaminerali, ukulinganisa amazinga womtjhiso, njengomgodi wokulinga wokufaka amapayipi nofana lezisetshenziswayo ezingaphasi kwehlabathi, ukufakwa kwe-geothermal, nofana ukubulungwa ngaphasi kwehlabathi kwezinto ezingafunekiyo.

== Ukuqakatheka ==
[[Isimumathi:AlburyBoreHole.jpg|right|thumb|Umgodi wemithombo yamanzi eya e- chalk aquifer ngaphasi kwe- North Downs, e-England e -Albury]]
Omanjinela nabacebisi bezebhoduluko basebenzisa ibizo elithi ''umgodi'' ukuhlathulula ngokuhlanganyela yonke imihlobo ehlukileyo yemigodi ebhojiweko njengengcenye yophenyo lwe-geotechnical nofana ukuhlolwa kwendawo yezebhoduluko (okubizwa ngokuthi yi-Phase II ESA). Lokhu kufaka  imigodi ethuthukisiweko ukubuthelela amasampula wehlabathi, amasampula amanzi kumbe amadwala, ukuthuthukisa imitjhini yokuthatha amasampula ''endaweni'', nofana ukufaka imithombo yokutjheja nofana ama-piezometers . Amasampula abuthelelwe emigodini avamise ukuhlolwa elabhorethari ukuthola ubujamo bawo, nofana ukuhlola amazinga wamakhemikhali ahlukahlukeneko nofana izinto ezisilaphazako.

Ngokuvamileko, umgodi osetshenziswa njengomthombo wamanzi uqedwa ngokufaka ipayipi ejame ngqo (ikheyisi) nesikrini somthombo ukuvikela umgodi bona ungabhidli. Lokhu godu kusiza ukukhandela ukusilaphazeka kwephasi bona kungangeni emgodini begodu kuvikela nanyana ngiyiphi ipompo efakiweko bona ingadosi isihlabathi nenhlabathi. Imithombo yamafutha negesi yemvelo yenziwa ngendlela efanayo, nanyana ivamise ukuba yinkimbinkimbi.

Njengombana kuvezwe ngokunabileko ku- proxy (isimo sezulu), ukulinganisa amazinga womtjhiso we-borehole emlandweni wokujula okuhlukileko kunga &quot; guqulwa &quot; (ifomula yeembalo yokurarulula i-ikhweshini ye-matrix) ukusiza ukulinganisa amazinga womtjhiso wendawo yomlando.

Amaqoqo wemigodi emincani enendlela zokutshiswa ezenziwe ngepayipi yeplastiki ye-PEX ingasetshenziselwa ukugcina ukutshisa kumbe amakhaza hlangana neenkhathi eziphikisanako ngaphakathi kwamatje wemvelo. Indlela le ibizwa ngokuthi kugcinwa kwamandla womtjhiso ngesikhathi sonyaka . Iindaba ezingasetshenziselwa iqhinga leli zisukela ematjeni ukuya edwaleni. Kungaba nama-borehole ambalwa ukuya kwamakhulu amanengi, begodu ngokwenza, ukujula kwawo kusuka ku 50 to 300 metres (150 to 1,000 ft) .&lt;ref&gt;Hellström G. (2008). Large-Scale Applications of Ground-Source Heat Pumps in Sweden. IEA HP Annex 29 Workshop, Zurich, May 19, 2008.&lt;/ref&gt;&lt;ref&gt;Stiles, Lynn (June 1998). &quot;Underground thermal energy storage in the US&quot;. ''IEA Heat Pump Centre Newsletter''. '''16''' (2): 22–23.&lt;/ref&gt;  

== Umlando ==
Ukubhoboza umgodi kunomlando omude. Okungenani ngobukhosi be-Han dynasty (202&amp;nbsp;BC&amp;nbsp;– 220&amp;nbsp;AD), amaTjhayina asebenzisa ukubhora umgodi ojulileko malungana nokumba namanye amaphrojekthi. Isazi se-sinology nesazi-mlando se-Britain u-Michael Loewe uthi indawo zokubhoboza zingafikelela emamitheni 6&lt;ref&gt;Conner, Clifford D. (2005). ''A People's History of Science: Miners, Midwives, and Low Mechanicks''. Nation Books. pp. 175. ISBN &lt;bdi&gt;978-1560257486&lt;/bdi&gt;.&lt;/ref&gt;00 metres (2,000 ft) .&lt;ref name=&quot;:1&quot;&gt;Loewe (1968), 194&lt;/ref&gt;  U-KS Tom uchaza ikambiso yokubhora: &quot;Indlela yamaTjhayina yokubhora ngokujulileko yenziwa lithimba lamadoda ebeligxuma phezulu begodu liphume emgogodleni ukobana lithinte isiqephu sokubhora ngesikhathi ithuluzi lokubhora lijikeleziswa zinyathi nenkomo.&lt;ref name=&quot;:0&quot;&gt;Tom (1989), 103&lt;/ref&gt; Le bekuyindlela efanako esetshenziselwa ukukhipha i-petroleum e -California ngeminyaka yabo-1860 (okutjho &quot;ukumkhahlela phansi&quot;). &lt;ref&gt;Hobson, John M. (2004). ''The Eastern Origins of Western Civilisation''. Cambridge University Press. p. 215. ISBN &lt;bdi&gt;978-0521547246&lt;/bdi&gt;.&lt;/ref&gt; I-Western Han dynasty bronze foundry eyatholwa e-Xinglong, e-Hebei gade inemigodi yemayini eseduze eyafikelela ekujuleni kwamamitha 100 metres (330 ft) eneendawo ezivulekileko zemayini; amashafthi namagumbi bekaphelele ngefreyimu yamapulangwe, amaladi namathulusi wensimbi.&lt;ref&gt;Loewe (1968), 191.&lt;/ref&gt; &lt;ref&gt;Wang (1982), 105.&lt;/ref&gt;  Ngekhulu lokuthoma leminyaka BC, abasebenzi bezandla be-China ababhora ngensimbi kanye nababhora bebakghona ukubhora imigodi efika 1,500 metres (4,900 ft) ukutjhinga. &lt;ref&gt;Hossain, M. E.; Abdullah Al-Majed, Abdulaziz (2015). ''Fundamentals of Sustainable Drilling Engineering''. Wiley-Scrivener (published March 2, 2015). ISBN &lt;bdi&gt;978-0470878170&lt;/bdi&gt;.&lt;/ref&gt;  &lt;ref name=&quot;:2&quot;&gt;Rezende, Lisa (2007). ''Chronology of Science''. Checkmark Books (published April 1, 2007). pp. 40. ISBN 978-0816071197&lt;/ref&gt;  Ngekhulu leminyaka elitshumi lanye AD, amaTjhayina bekakwazi ukubhora imigodi efika 900 metres (3,000 ft) ngokujula. Ukubhora imigodi bekuthatha isikhathi eside begodu kuthatha isikhathi eside. Njengombana ukujula kwemigodi bekuhlukahluka, ukubhoboza umthombo munye bekungathatha iminyaka elitshumi.&lt;ref name=&quot;:1&quot; /&gt;  Kwaze kwaba ngekhulu leminyaka ye-19 lapho i-Europe neTjingalanga zizokuthola begodu zincintisane nethekhnoloji yokubhora imigodi ye-China yakade.&lt;ref name=&quot;:2&quot; /&gt; &lt;ref name=&quot;:0&quot; /&gt;  

Kwaphela iminyaka eminengi, umgodi omude kakhulu ephasini bekuyi- Kola Superdeep Borehole e-Russia. Kusukela ngomnyaka ka-2011 bekube nguRhoboyi wee-2012 irekhodi belibanjwe li- 12,345-metre (40,502 ft) ubude i-Sakhalin-I Odoptu OP&lt;ref&gt;Sakhalin-1 Project Drills World's Longest Extended-Reach Well Archived 2011-01-31 at the Wayback Machine&lt;/ref&gt; Kuhlekuhle, eduze nelwandle lesihlengele se-Russia i-Sakhalin .  Umthombo we -Chayvo Z-44 ofinyeleleka khulu wathatha isikhundla somgodi omude khulu ephasini mhlazi-27 kuRhoboyi wee-2012. Ukujula okulinganisiweyo kwe-Z-44 kungamamitha 12,376 metres (40,604 ft) . Kodwana, imithombo ye-ERD ayijulile ukudlula i-Kola Borehole, ngebanga lokufuduka okukhulu okuvundlileyo. NgoJulayi 2023, i-China yaqala ukubhora imigodi etjhingako, enye e- Sichuan Basin kulindeleke bona ifinyelele 10,520 metres (34,510 ft) phasi begodu enye ise- Tarim Basin ngokujula okuhleliweko 11,100 metres (36,400 ft) .  

== Indlela yokusebenza ==
 Ababholi bangacwilisa umgodi basebenzisa i -drill rig nofana i-rig esetshenziswa ngesandla. Imitshini namathekhnikhi wokuthuthukisa umgodi ayahluka kakhulu ngokuya ngomenzi, ubujamo bezesayensi, kanye nehloso ehlosiweko. Ukubhora elwandle amayunithi antantako nofana amaplatifomu asekelwa phansi kwelwandle asetshenziselwa ukubhora.
[[Isimumathi:Borehole-Manual-Digging-Process-2050-Paris.jpg|thumb|Abantu ababili abagebha umgodi bemba umgodi ngezandla]]
lkakhulu emazweni asathuthuka imigodi eminengi isagejwa ngezandla. Ukwemba kuqala ngomsebenzi wezandla kusetshenziswa amathulusi asisekelo afana namafosholo, amapiki, kanye nama-crowbar. Abasebenzi bemba ihlabathi ngesendlalelo ngesendlalelo, kanengi basebenzisa ukunyakaza okuyindilinga ukwenza umgodi omiswe kuhle. Ikambiso le ibuthakathaka begodu itlhoga, ifuna ukusebenzisana kwesiqhema nokusebenzisana. Ukukhandela bona amabhoda angawi begodu nokuqinisekisa ikhwalithi yamanzi, umgodi ufakwe izinto ezifana nezitina, amatshe, nofana amasongo wekhonkrithi. Ukuqiniswa lokhu kugcina ubuqotho besakhiwo somgodi begodu kusiza ukukhandela ukusilaphazeka. Ipulatifomu yekhonkrithi nofana ilebhu ingafakwa phansi ukukhandela bona inkunkuma ingangeni emanzini. Ingaphezulu lomgodi livalwe ukuwuvikela ekungcolisweni nokusilaphazeka. 

== Qala godu ==

* I-Askam Borehole e-Pennsylvania
* Umsiki wekheyisi
* Ukulahlwa kwemigodi etjhingako
* Isivuli somgodi
* Ukulahlwa komgodi ovundlileko
* I-Kola Superdeep Borehole
* Iphrofayili yokuzamazama komhlaba

== Umthombo wolwazi ==</text>
      <sha1>9on5u0pdtrns3ptel90i0cajchq92pz</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Multiple image/styles.css</title>
    <ns>10</ns>
    <id>1198</id>
    <revision>
      <id>6727</id>
      <timestamp>2026-06-15T09:07:09Z</timestamp>
      <contributor>
        <username>Derek J Moore</username>
        <id>148</id>
      </contributor>
      <comment>added style sheet</comment>
      <origin>6727</origin>
      <model>sanitized-css</model>
      <format>text/css</format>
      <text bytes="2044" sha1="lf0p4p3o604razcb6ed3kk5mm9lba0y" xml:space="preserve">/* {{pp-template}} */
/* this is a block */
.multiimageinner {
	display: flex;
	flex-direction: column;
}

.trow {
	display: flex;
	flex-direction: row;
	clear: left;
	flex-wrap: wrap;
	width: 100%;
	box-sizing: border-box;
}

/* this is a cell */
.tsingle {
	margin: 1px;
	float: left;
}

.theader {
	clear: both;
	font-weight: bold;
	text-align: center;
	align-self: center;
	background-color: transparent;
	width: 100%;
}

.thumbcaption {
	background-color: transparent;
}

.text-align-left {
	text-align: left;
}

.text-align-right {
	text-align: right;
}

.text-align-center {
	text-align: center;
}

@media all and ( max-width: 720px ) {
	.thumbinner {
		/* not !important usage can be removed when these are no longer inline styles
		inside Template:Multiple image and media query using min-width is introduced */
		width: 100% !important;
		box-sizing: border-box;
		max-width: none !important;
		align-items: center;
	}
	.trow {
		justify-content: center;
	}
	.tsingle {
		/* not !important usage can be removed when these are no longer inline styles
		inside Template:Multiple image and media query using min-width is introduced */
	    float: none !important;
	    max-width: 100% !important;
	    box-sizing: border-box;
	    text-align: center;
	}
	.tsingle .thumbcaption {
		text-align: left;
	}
	.trow &gt; .thumbcaption {
		text-align: center;
	}
}

@media screen {
	.multiimageinner .thumbimage {
		background-color: inherit;
	}
	html.skin-theme-clientpref-night
		.multiimageinner
		.thumbimage:not([style*=&quot;background-color&quot;])
		span:not(.skin-invert-image):not(.skin-invert):not(.bg-transparent)
		img,
	html.skin-theme-clientpref-day
		.multiimageinner
		.thumbimage:not([style*=&quot;background-color&quot;])
		span:not(.bg-transparent)
		img
	{
		background-color: white;
	}
}

@media screen and (prefers-color-scheme: dark) {
	html.skin-theme-clientpref-os
		.multiimageinner
		.thumbimage:not([style*=&quot;background-color&quot;])
		span:not(.skin-invert-image):not(.skin-invert):not(.bg-transparent)
		img
	{
		background-color: white;
	}
}</text>
      <sha1>lf0p4p3o604razcb6ed3kk5mm9lba0y</sha1>
    </revision>
  </page>
  <page>
    <title>Amanzi</title>
    <ns>0</ns>
    <id>1199</id>
    <revision>
      <id>6729</id>
      <timestamp>2026-06-18T11:54:11Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''Amanzi''' kuyinto eselwako enganambitheki  ngendlela esingatjho bonyana izwakala njani. Amanzi akanawo umbala,  nofana iphunga, begodu lokha nakamanengi khulu angabonakala ahlaza kwesibhakabhaka.&lt;ref&gt;https://www.merriam-webster.com/dictionary/water&lt;/ref&gt; Amanzi adlala indima eqakathekileko emaphilweni wabantu ngombana umunut angeze aphila ngaphandle kwabo begodu izinto ezinengi sizenza ngawo amanzi.    Amanzi akghona ukuvela  ngendlela ezinengi ukuya ngokuthi abekwe n...&quot;</comment>
      <origin>6729</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="929" sha1="t9wgtg8efyf9ijp7lnpqv3px2ywmqfn" xml:space="preserve">'''Amanzi''' kuyinto eselwako enganambitheki  ngendlela esingatjho bonyana izwakala njani. Amanzi akanawo umbala,  nofana iphunga, begodu lokha nakamanengi khulu angabonakala ahlaza kwesibhakabhaka.&lt;ref&gt;https://www.merriam-webster.com/dictionary/water&lt;/ref&gt; Amanzi adlala indima eqakathekileko emaphilweni wabantu ngombana umunut angeze aphila ngaphandle kwabo begodu izinto ezinengi sizenza ngawo amanzi.  

Amanzi akghona ukuvela  ngendlela ezinengi ukuya ngokuthi abekwe ngaphasi kwabuphi ubujamo obufana namazinga wokutjhisa, ukuhlanganiswa nezinto nokunye. njengokuthi alirhwaba lokha nakabekwe lapho kumakhaza khona khulu. Godu akghona ukuthi avele abe mummoya lokha nakabekwe lapho kunamzinga wokutjhisa aphezulu. Amanzi akghona ukuthi asiphe iindawo ezinengi zemvelo ezifana nemifula, ilwandle, impophoma nokhunye. Amanzi akghona ukuthi anise izulu ngokuthi asuke aphasi njenge mtjhiso bese aphole abuye phasi njengezulu.</text>
      <sha1>t9wgtg8efyf9ijp7lnpqv3px2ywmqfn</sha1>
    </revision>
    <revision>
      <id>6730</id>
      <parentid>6729</parentid>
      <timestamp>2026-06-18T11:56:53Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6730</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="945" sha1="ncuai1hvy6lwxklp4q45p3w115efitw" xml:space="preserve">'''Amanzi''' kuyinto eselwako enganambitheki  ngendlela esingatjho bonyana izwakala njani. Amanzi akanawo umbala,  nofana iphunga, begodu lokha nakamanengi khulu angabonakala ahlaza kwesibhakabhaka.&lt;ref&gt;https://www.merriam-webster.com/dictionary/water&lt;/ref&gt; Amanzi adlala indima eqakathekileko emaphilweni wabantu ngombana umuntu angeze aphila ngaphandle kwawo begodu izinto ezinengi sizenza ngawo amanzi.  

Amanzi akghona ukuvela  ngendlela ezinengi ukuya ngokuthi abekwe ngaphasi kwabuphi ubujamo obufana namazinga wokutjhisa, ukuhlanganiswa nezinto nokunye. njengokuthi alirhwaba lokha nakabekwe lapho kumakhaza khona khulu. Godu akghona ukuthi avele abe mummoya lokha nakabekwe lapho kunamzinga wokutjhisa aphezulu. Amanzi akghona ukuthi asiphe iindawo ezinengi zemvelo ezifana nemifula, ilwandle, impophoma nokhunye. Amanzi akghona ukuthi anise izulu ngokuthi asuke aphasi njenge mtjhiso bese aphole abuye phasi njengezulu.

== Iinkomba ==</text>
      <sha1>ncuai1hvy6lwxklp4q45p3w115efitw</sha1>
    </revision>
    <revision>
      <id>6731</id>
      <parentid>6730</parentid>
      <timestamp>2026-06-18T11:59:11Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6731</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1012" sha1="03jixdmc9sdfwijovulxc82ivguo67i" xml:space="preserve">[[Isimumathi:Fresh water fountain.jpg|thumb|Ipompi ephuma amanzi]]
'''Amanzi''' kuyinto eselwako enganambitheki  ngendlela esingatjho bonyana izwakala njani. Amanzi akanawo umbala,  nofana iphunga, begodu lokha nakamanengi khulu angabonakala ahlaza kwesibhakabhaka.&lt;ref&gt;https://www.merriam-webster.com/dictionary/water&lt;/ref&gt; Amanzi adlala indima eqakathekileko emaphilweni wabantu ngombana umuntu angeze aphila ngaphandle kwawo begodu izinto ezinengi sizenza ngawo amanzi.  

Amanzi akghona ukuvela  ngendlela ezinengi ukuya ngokuthi abekwe ngaphasi kwabuphi ubujamo obufana namazinga wokutjhisa, ukuhlanganiswa nezinto nokunye. njengokuthi alirhwaba lokha nakabekwe lapho kumakhaza khona khulu. Godu akghona ukuthi avele abe mummoya lokha nakabekwe lapho kunamzinga wokutjhisa aphezulu. Amanzi akghona ukuthi asiphe iindawo ezinengi zemvelo ezifana nemifula, ilwandle, impophoma nokhunye. Amanzi akghona ukuthi anise izulu ngokuthi asuke aphasi njenge mtjhiso bese aphole abuye phasi njengezulu.

== Iinkomba ==</text>
      <sha1>03jixdmc9sdfwijovulxc82ivguo67i</sha1>
    </revision>
    <revision>
      <id>6732</id>
      <parentid>6731</parentid>
      <timestamp>2026-06-18T12:01:42Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6732</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1140" sha1="jk0h3pzlt93womjnx06qzz5kl62e23d" xml:space="preserve">[[Isimumathi:Fresh water fountain.jpg|thumb|Ipompi ephuma amanzi]]
'''Amanzi''' kuyinto eselwako enganambitheki  ngendlela esingatjho bonyana izwakala njani. Amanzi akanawo umbala,  nofana iphunga, begodu lokha nakamanengi khulu angabonakala ahlaza kwesibhakabhaka.&lt;ref&gt;https://www.merriam-webster.com/dictionary/water&lt;/ref&gt; Amanzi adlala indima eqakathekileko emaphilweni wabantu ngombana umuntu angeze aphila ngaphandle kwawo begodu izinto ezinengi sizenza ngawo amanzi.  

Amanzi akghona ukuvela  ngendlela ezinengi ukuya ngokuthi abekwe ngaphasi kwabuphi ubujamo obufana namazinga wokutjhisa, ukuhlanganiswa nezinto nokunye. njengokuthi alirhwaba lokha nakabekwe lapho kumakhaza khona khulu. Godu akghona ukuthi avele abe mummoya lokha nakabekwe lapho kunamzinga wokutjhisa aphezulu. Amanzi akghona ukuthi asiphe iindawo ezinengi zemvelo ezifana nemifula, ilwandle, impophoma nokhunye. Amanzi akghona ukuthi anise izulu ngokuthi asuke aphasi njenge mtjhiso bese aphole abuye phasi njengezulu.

== Iinkomba ==
[[category: Amanzi]]
[[Category: umlambo]]
[[Category:Imvelo]]
[[Category: ukuqakatheka kwamanzi]]
[[Category: ukusela amanzi]]</text>
      <sha1>jk0h3pzlt93womjnx06qzz5kl62e23d</sha1>
    </revision>
  </page>
  <page>
    <title>Ukuvuma</title>
    <ns>0</ns>
    <id>1200</id>
    <revision>
      <id>6733</id>
      <timestamp>2026-06-18T12:28:42Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <comment>Created page with &quot;'''Ukuvuma''' kukwenza itjhada ngomvumo ngephimbo lakho.&lt;ref&gt;Sundberg, J., 2018. The singing voice. ''The Oxford handbook of voice perception'', pp.117-142.&lt;/ref&gt; Usebenzisa umoya ovela emaphatjhini wakho, ukuvuthela okuvela emagodini wephimbo lakho, nokubunjwa okuvela emlonyeni wakho, ilimi, iindebe, nepumulo ukwenza iphitjhi, igido, namagama. Ngokungafani nokukhuluma, ukuvuma kulula itjhada begodu ilihlebe libe mvumo nesikhathi somvumo. Ibhayiloji ngemva kwayo Ibhoksi...&quot;</comment>
      <origin>6733</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="724" sha1="t16ulva7cnk5xj9nbcw0cv4x0swyc05" xml:space="preserve">'''Ukuvuma''' kukwenza itjhada ngomvumo ngephimbo lakho.&lt;ref&gt;Sundberg, J., 2018. The singing voice. ''The Oxford handbook of voice perception'', pp.117-142.&lt;/ref&gt; Usebenzisa umoya ovela emaphatjhini wakho, ukuvuthela okuvela emagodini wephimbo lakho, nokubunjwa okuvela emlonyeni wakho, ilimi, iindebe, nepumulo ukwenza iphitjhi, igido, namagama. Ngokungafani nokukhuluma, ukuvuma kulula itjhada begodu ilihlebe libe mvumo nesikhathi somvumo. Ibhayiloji ngemva kwayo Ibhoksi lakho lephimbo, i-larynx, linemikhakha emibili yemisipha ebizwa ngokuthi ma-vocal folds. Nawukhipha umoya, umoya uyadlula kizo. Zivuleka begodu zivale iinkhathi ezili-100 ukuya kweli-1000 ngomzuzwana. Ukuvuthela lokho lokho kwenza amagagasi womdumo.</text>
      <sha1>t16ulva7cnk5xj9nbcw0cv4x0swyc05</sha1>
    </revision>
    <revision>
      <id>6734</id>
      <parentid>6733</parentid>
      <timestamp>2026-06-18T12:29:31Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6734</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="740" sha1="pi1px54d1q75r3w8sys7112hnco9cng" xml:space="preserve">'''Ukuvuma''' kukwenza itjhada ngomvumo ngephimbo lakho.&lt;ref&gt;Sundberg, J., 2018. The singing voice. ''The Oxford handbook of voice perception'', pp.117-142.&lt;/ref&gt; Usebenzisa umoya ovela emaphatjhini wakho, ukuvuthela okuvela emagodini wephimbo lakho, nokubunjwa okuvela emlonyeni wakho, ilimu, iindebe, nepumulo ukwenza iphitjhi, igido, namagama. Ngokungafani nokukhuluma, ukuvuma kulula itjhada begodu ilihlebe libe mvumo nesikhathi somvumo. Ibhayiloji ngemva kwayo Ibhoksi lakho lephimbo, i-larynx, linemikhakha emibili yemisipha ebizwa ngokuthi ma-vocal folds. Nawukhipha umoya, umoya uyadlula kizo. Zivuleka begodu zivale iinkhathi ezili-100 ukuya kweli-1000 ngomzuzwana. Ukuvuthela lokho lokho kwenza amagagasi womdumo.

== Iinkomba ==</text>
      <sha1>pi1px54d1q75r3w8sys7112hnco9cng</sha1>
    </revision>
    <revision>
      <id>6735</id>
      <parentid>6734</parentid>
      <timestamp>2026-06-18T12:35:59Z</timestamp>
      <contributor>
        <username>Nqobile69</username>
        <id>190</id>
      </contributor>
      <minor />
      <origin>6735</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="828" sha1="mlj5km7e4h4mumow0r2g8qfoudjlko3" xml:space="preserve">[[Isimumathi:A musical instrument, Dhol.jpg|thumb|Isigubhu sokwenza umvumo ube mnandi]]
'''Ukuvuma''' kukwenza itjhada lomvumo ngephimbo lakho.&lt;ref&gt;Sundberg, J., 2018. The singing voice. ''The Oxford handbook of voice perception'', pp.117-142.&lt;/ref&gt; Usebenzisa umoya ovela emaphatjhini wakho, ukuvuthela okuvela emagodini wephimbo lakho, nokubunjwa okuvela emlonyeni wakho, ilimu, iindebe, nepumulo ukwenza iphitjhi, igido, namagama. Ngokungafani nokukhuluma, ukuvuma kulula itjhada begodu ilihlebe libe mvumo nesikhathi somvumo. Ibhayiloji ngemva kwayo: Ibhoksi lakho lephimbo, i-larynx, linemikhakha emibili yemisipha ebizwa ngokuthi ma-vocal folds. Nawukhipha umoya, umoya uyadlula kizo. Zivuleka begodu zivale iinkhathi ezili-100 ukuya kweli-1000 ngomzuzwana. Ukuvuthela lokho lokho kwenza amagagasi womdumo.

== Iinkomba ==</text>
      <sha1>mlj5km7e4h4mumow0r2g8qfoudjlko3</sha1>
    </revision>
  </page>
  <page>
    <title>Jacinta Ngobese-Zuma</title>
    <ns>0</ns>
    <id>1202</id>
    <revision>
      <id>6737</id>
      <timestamp>2026-07-07T11:13:16Z</timestamp>
      <contributor>
        <username>Bobbyshabangu</username>
        <id>66</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:zu:Special:Redirect/revision/125587|Jacinta Ngobese-Zuma]]&quot;</comment>
      <origin>6737</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4837" sha1="dn3bc7y34p0j00p1rjxny2o7tpvwypn" xml:space="preserve">'''U-Jacinta Zinhle Ngobese-Zuma''' (wabelethwa mhlazi-6 kuNtaka 1986) mlweli weSewula Afrika, umrhatjhi onqobe imiklomelo, nomenzi wamafilimu . Nguye umsunguli nomdosiphambili wehlangano yokulwisana nokufuduka okungekho emthethweni ''[[March and March|ngoNtaka noNtaka]]'', ebiza bona urhulumende aqinise imithetho yakhe yokufuduka. Ukulwisana kwakhe kumenze waba mdumo welizwe, abanye basekela umkhankaso wakhe, bathi ulwela inarha nokubusa komthetho, lokha abanye bawugxeka ngokuthi uzonda abafokazi.  

== Umlando wakhe ==
U-Zinhle wabelethwa mhlazi-6 kuNtaka 1986 e-Mashu, lapho akhulela khona, esifundazweni se-KwaZulu-Natal, eSewula Afrika. U-Zinhle wakhuliswa ngugogo wakhe njengombana ababelethi bakhe bahlukana nakasesemutjha, begodu uyise kwatlhogeka bona abaleke endaweni leyo ngebanga lodlakela lwepolotiki. Waphumelela nge-Bachelor of Science ku-Supply Chain Management [[Iyunivesithi ye-KwaZulu-Natal|e-University of KwaZulu-Natal]] .

== Ukurhatjha ==
U-MaNgobese wathoma umsebenzi wakhe emkhakheni wokurhatjha ngokusebenzela iintetjhini ezinengi ze-KwaZulu-Natal - i-Vibe 94.7 FM, i-Inanda FM, ne-Gagasi FM - ngaphambi kobana ajoyine i-Vuma FM ye-Durban. Esitetjhini, bekabamba umdlalo wemini obizwa ngokuthi ''&quot;I-Cruise with Jacinta Ngobese&quot;'', lapho bekahlala akhuluma khona ngeendaba zehlalakuhle, zomthetho, nezezwe. Wasebenza esiteshini kusukela ngo-2019 ukuya ku-2025. Ngesikhathi sakhe njengomsakazi, wathola imiklomelo eminengi yebubulo eqakathekisa igalelo lakhe njengomsakazi, njenge-MTN Broadcasting Award ngokukhiqiza i -Gagasi FM .  


Ngowezi-2023 waqonywa ukuba ayohlanganyela ohlelweni Lobuholi Bezivakashi Zamazwe Omhlaba loMnyango Wombuso waseMelika, lapho ayemele izingcwepheshi zezinsizakuxhumana zaseNingizimu Afrika.&lt;ref&gt;{{cite news|title=Durban media personality chosen for prestigious programme in the US|work=Daily News|publisher=Independent Media|date=1 September 2023|url=https://iol.co.za/dailynews/news/2023-09-01-durban-media-personality-chosen-for-prestigious-programme-in-the-us/}}&lt;/ref&gt; Isivumelwano sokusebenza ayenaso neVuma FM saqedwa ngowezi-2025, ngenxa yokuzibadakanya kwakhe nemibhikisho emelene nabafika ngokungemthetho ezweni. &lt;ref&gt;https://sundaytribune.co.za/news/2025-08-27-presenter-takes-legal-action-against-vuma-fm-over-termination-of-contract/&lt;/ref&gt; Wasola iqembu [[:zu:African_National_Congress|likaKhongolose]] KwaZulu-Natali ngokuba nesandla ekungavuselelweni kwesivumelwano sakhe neVuma FM.&lt;ref&gt;{{cite web|last1=Ntanzi|first1=Hope|title=Jacinta Ngobese-Zuma fights back: Legal action against ANC KZN's 'misleading claims'|url=https://iol.co.za/news/south-africa/2025-07-24-jacinta-ngobese-zuma-fights-back-legal-action-against-anc-kzns-misleading-claims/|website=iol.co.za|access-date=1 July 2026}}&lt;/ref&gt;  Wasungula [[:zu:Isifayelo|isifayelo]] (''podcast'') sakhe esibizwa ''zoom in with jacinta zuma'' (Ukulwilwiza noJacinta Zuma) esitholakala kuYoutube.

== Ukulwela amalungelo ==
I-MaNgobese yaba yindaba edumileko ngemva kokusungula ''[[March and March|u-March no-March]]'', umhlangano wabantu abasezingeni eliphasi okhuthaza ukuqiniswa nokugandeleleka kwemithetho yokufuduka eSewula Afrika. Umkhankaso lo sele uhlele imitjhagalo nemikhankaso eminengi eemfundeni zelizwe. 


UMaNgobese usekuvezile ukuthi umbutho wakhe uqondiswe kwabokufika abangenazo izimvume zokuba lapha nasekuphoqelelweni kwemithetho elawula ukungena kwabo lapha, hhayi kubantu bangaphandle jikelele. Uyakuphika ukuthi inhlangano yakhe [[:zu:Ukucwaswa_kwezifiki_eNingizimu_Afrika|icwasa izifikamthwalo]].&lt;ref&gt;{{cite news|title=Who is Jacinta Ngobese-Zuma? The woman behind March and March|work=The Post|publisher=Independent Media|date=4 June 2026|url=https://iol.co.za/thepost/news/2026-06-04-who-is-jacinta-ngobese-zuma-the-woman-behind-the-march-and-march-movement/}}&lt;/ref&gt;

== Isithunzi somphakathi ==
Ikulumo nekulumo kaMaNgobese ''[[March and March|noMatjhi noNtaka]]'' sele ivuse ipikiswano ekulu emphakathini. Abasekeli bathi yena nomkhankaso wakhe baveza ukutshwenyeka okuqakathekileko malungana nokufuduka okungekho emthethweni, ubulelesi, nokugandelelwa kwemithetho yokufuduka . Ezinye iinhlangano ezilwela amalungelo wobuntu, iinhlangano zepolotiki, namaqembu womphakathi ahlaba umkhosi lo, athi ukukhuluma kwawo kubandlulula begodu kuzonda abantu ababuya eenarheni zangaphandle. 

Abezindaba bachazisa uMaNgobese-Zuma njengosaziwayo waseNingizimu Afrika oyisishoshovu esibadidayo senqubomgono yabokufika ngowezi-2026.&lt;ref&gt;{{cite news|title=Who is Jacinta Ngobese-Zuma? The woman behind March and March|work=The Post|publisher=Independent Media|date=4 June 2026|url=https://iol.co.za/thepost/news/2026-06-04-who-is-jacinta-ngobese-zuma-the-woman-behind-the-march-and-march-movement/}}&lt;/ref&gt;

== Iinkomba ==

[[Mkhakha:Sopolitiki]]
[[Mkhakha:Sewula Afrika]]
[[Mkhakha:Isishoshovi]]</text>
      <sha1>dn3bc7y34p0j00p1rjxny2o7tpvwypn</sha1>
    </revision>
  </page>
  <page>
    <title>March and March</title>
    <ns>0</ns>
    <id>1203</id>
    <revision>
      <id>6741</id>
      <timestamp>2026-07-11T11:53:53Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <comment>Cited a person</comment>
      <origin>6741</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="7649" sha1="2b1n1t98oae1jdhrtl1tkxhgilaq6vu" xml:space="preserve">I-'''[https://marchandmarch.org.za/ March and March]'''&lt;ref&gt;{{Cite web |title=March &amp; March - Citizen Advocacy for Immigration Reform |url=https://marchandmarch.org.za/ |access-date=2026-07-11 |website=marchandmarch.org.za}}&lt;/ref&gt; ekuyihlangano yeSewula Afrika elwisana namaphandle ahlala kileli ilizwe ngaphandle kokuba namaphepha afaneleko, okutjho bona ukuhlala kwabo akukho em'thethweni. Amaphandle la kubalwa hlangana nabantu be-Zimbabwe, Malawi, Nigeria, Pakistan namanye amazwe. &lt;ref&gt;{{Cite web |last=Pawson |first=Nick |date=2025-12-08 |title=Which countries are responsible for the MOST illegal crossings into SA? |url=https://www.thesouthafrican.com/news/which-countries-are-responsible-for-the-most-illegal-crossings-into-sa/ |access-date=2026-07-11 |website=The South African |language=en-ZA}}&lt;/ref&gt; Isibalo samaphandle la sibalwa lapha eengidini ezintathu. &lt;ref&gt;{{Cite web |last=Mkwananzi |first=Masabata |date=2152-01-22 |title=South Africa cracks down on illegal immigrants – over 3 million undocumented reside here |url=https://thestar.co.za/ |access-date=2026-07-11 |website=The Star |language=en}}&lt;/ref&gt; Kanti-ke umphathi wehlangano ye-March and March ukosikazi Jacinta Zuma&lt;ref&gt;{{Cite web |last=Albert |date=2026-06-14 |title=Jacinta Ngobese-Zuma Biography: Age, Education, Career, Husband, Tribe, Activism, and Net Worth |url=https://litefacts.com.ng/jacinta-ngobese-zuma-biography/ |access-date=2026-07-11 |language=en-US}}&lt;/ref&gt; owaziwa khulu ngo-Jacinta Zinhle MaNgobese Zuma uthi amaphandle la amraro omkhulu ezweneli ngombana iintjhijilo zabantu beSewula Afrika ezifaka hlangana nokungasebenzi kwelutjha kubangwa ngibo. &lt;ref&gt;{{Cite web |last=Selane |first=Enkosi |date=2025-11-12 |title=Illegal immigrants partly to blame for South Africans' unemployment, committee hears |url=https://www.citizen.co.za/news/south-africa/illegal-immigrants-partly-to-blame-for-south-africans-unemployment-committee-hears/ |access-date=2026-07-11 |website=The Citizen |language=en}}&lt;/ref&gt; Isibalo sabantu abangasebenziko eSewula Afrika singaphezulu kwamaphesende ama-30.&lt;ref&gt;{{Cite web |last=Dludla |first=Siphelele |date=2241-10-26 |title=SA’s unemployment rate jumps to 32.7 percent as 345,000 jobs are lost |url=https://dailynews.co.za/business-report/2026-05-12-sas-unemployment-rate-jumps-to-327-as-345000-jobs-are-lost/ |access-date=2026-07-11 |website=Daily News |language=en}}&lt;/ref&gt;

U-Jacinta Zuma ekulwisaneni kwakhe nomraro lo wakhipha isitatimende esitjela umbuso bona ulungiselele ukusiza amaphandle bona akhambe eSewula Afrika kungakafiki ilanga elithize lamhlazana amalanga ama-30 kuMgwengweni kiwo wona umnyaka lo. Lo umlayezo wawungatjeli uRhulumende kwaphela kodwana bewutjela nawo amaphandle bona alungise akhambe, begodu lo umlayezo bekubika ebantwini beSewula Afrika bona ngelangelo ilizwe liyavalwa - ''national shut down,'' lapho kuyokuba nomguruguru (toy-toy) ozabe udoswa phambili ngiyo ihlangano le bese abantu beSewula Afrika balandele ngemva.&lt;ref&gt;{{Cite web |date=2026-07-08 |title=South African Anti-Illegal Immigration Activist Jacinta Ngobese-Zuma Warns Of Potential National Shutdown - PrimeTime News |url=https://primetimenews.co.za/south-african-anti-illegal-immigration-activist-jacinta-ngobese-zuma-warns-of-potential-national-shutdown/ |access-date=2026-07-11 |language=en-US}}&lt;/ref&gt; U-Jacinta wabawa nabantu bona bangaphangi iintolo zamaphandle begodu bangabalimazi, bangabulali begodu bangabagijimisi, watjho bona bazokutoyitoya ngaphandle kokona nokuhlukumeza amaphandle. &lt;ref&gt;{{Cite web |last=Majadibodu |first=Simon |date=2009-12-29 |title=Jacinta Ngobese-Zuma calls for non-violent June 30 shutdown against illegal immigration |url=https://thestar.co.za/thepost/news/2026-06-12-jacinta-ngobese-zuma-calls-for-non-violent-june-30-shutdown-against-illegal-immigration/ |access-date=2026-07-11 |website=The Star |language=en}}&lt;/ref&gt; UMongameli weSewula Afrika u-[[:en:Cyril_Ramaphosa|Cyril Ramaphosa]] waphendula mayelana nalokhu begodu wathi akunamuntu onelungelo lokufuna amaphepha wamaphandle ngombana umsebenzi loyo ngewabantu bomthetho begodu lokhu okukwenziwa yihlangano kumsebenzi womthetho, bewayelelisa abantu bona bangazibandakanyi ekuhlukumezeni amaphandle.&lt;ref&gt;{{Cite web |last=Juma |first=Ali Bahati |date=2026-06-25 |title='Might of the law:' Ramaphosa issues stern warning as 30 June nears |url=https://currentaffairsza.com/2026/06/25/might-of-the-law-ramaphosa-issues-stern-warning-as-30-june-nears/ |access-date=2026-07-11 |website=Current Affairs ZA |language=en-GB}}&lt;/ref&gt; Akhange aphethe ngalokho, uMongameli wathi uzokukhipha amasotja bekafake nemali engenge-600 yeengidi zamaranda ukuze kuvikelwe amaphandle. &lt;ref&gt;{{Cite web |last=Jack |first=Sipho |date=2040-02-16 |title=South Africans outraged over R600 million expenditure for protest security amidst immigration crisis |url=https://dailynews.co.za/news/2026-06-23-south-africans-outraged-over-r600-million-expenditure-for-protest-security-amidst-immigration-crisis/ |access-date=2026-07-11 |website=Daily News |language=en}}&lt;/ref&gt;

Ngelanga elabekwako u-Jacinta nehlangano yakhe bakhipha iintatimende eenkundlleni zokuthintana ukubikela abantu bona kuragelwa phambili ngehlelo. Abantu baphuma ngobunengi bagcwele eendleleni kanti ke nomkhandlu wamateksi i-[https://santaco.org/ SANTACO] kwakhulunywa nawo, kwathiwa angekhe amateksi ahlale angasebenzi ngaphezuku kwalokho ngiwo amateksi azabe athutha abantu abasa lapho kuhlanganwa khona. &lt;ref&gt;{{Cite web |last=Scott |first=Caslian |date=2026-06-29 |title='Santaco has never opposed a peaceful protest': Taxi council clarifies 30 June march stance |url=https://www.citizen.co.za/news/santaco-has-never-opposed-a-peaceful-protest-taxi-council-clarifies-30-june-march-stance/ |access-date=2026-07-11 |website=The Citizen |language=en}}&lt;/ref&gt; Kwathi lokha ngemva kwamadina u-Jacinta nakazokuthokoza ukuphumelela kwe-march and march, wathokoza iinhlanganazo ezimesekileko bewatjho bona njengombana uMongameli wenarha akhipha imalikazi engaka yokuzokuqinisekisa ukuphepha kwamaphandle kufanele akhiphe enye iveke neveke ngombana ukusukela lokho iveke neveke ngeLesine kuzokuba nomguruguru othi awakhambe amaphandle. &lt;ref&gt;{{Cite web |last=Mdaka |first=Zintle |date=2026-07-01 |title='We are marching every Thursday': Ngobese-Zuma announces weekly protests |url=https://www.bona.co.za/entertainment/we-are-marching-every-thursday-jacinta-ngobese-zuma-announces-weekly-protests/ |access-date=2026-07-11 |website=Bona Magazine |language=en-US}}&lt;/ref&gt;

Kikho koke lokhu kunabanye abantu beSewula Afrika abangavumelani nehlangano le, abanye babo baphi amaphandle wamambala makhuwa bese abanye babo bathi kusihluku ukuqotha abantu ngalendla - lokhu akusibo ubuntu. &lt;ref&gt;{{Cite web |last=Ngobese-Zuma |first=Jacinta |date=2102-05-16 |title=One year of March and March: Why South Africans refuse to be strangers in their own country |url=https://capeargus.co.za/sunday-tribune/opinion/2026-03-22-one-year-of-march-and-march-why-south-africans-refuse-to-be-strangers-in-their-own-country/ |access-date=2026-07-11 |website=Cape Argus |language=en}}&lt;/ref&gt; Okhunye kukuthi bakhona abayithabelako nebayisekelako ihlangano le begodu sekunabanye abantu abakhulumileko eenkundleni zokuthintana bona sele bathole imisebenzi begodu bathokoza yona ihlangano le.&lt;ref&gt;{{Cite web |last=Masasi |first=Rutendo |date=2026-07-02 |title=South African Man Thanks March and March Movement for New Job Amid High Unemployment Rates - Briefly.co.za |url=https://briefly.co.za/people/245501-man-march-march-job-tiktok-video/ |access-date=2026-07-11 |website=briefly.co.za |language=en}}&lt;/ref&gt;

=== IMITHOMBO ===</text>
      <sha1>2b1n1t98oae1jdhrtl1tkxhgilaq6vu</sha1>
    </revision>
  </page>
  <page>
    <title>France</title>
    <ns>0</ns>
    <id>1204</id>
    <revision>
      <id>6749</id>
      <timestamp>2026-07-27T07:39:34Z</timestamp>
      <contributor>
        <username>Zelbura</username>
        <id>1657</id>
      </contributor>
      <comment>I-France</comment>
      <origin>6749</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="57" sha1="mj5pp1qwitrr6k053ku3rad6yfvphcm" xml:space="preserve">'''I-France'''

[[File:Flag of France.svg||320px|thumb|]]</text>
      <sha1>mj5pp1qwitrr6k053ku3rad6yfvphcm</sha1>
    </revision>
    <revision>
      <id>6750</id>
      <parentid>6749</parentid>
      <timestamp>2026-07-27T07:41:14Z</timestamp>
      <contributor>
        <username>Zelbura</username>
        <id>1657</id>
      </contributor>
      <comment>/* */ Paris</comment>
      <origin>6750</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="117" sha1="ciefc0f7ftrfl7vz0ohdbtnuhsyt3yh" xml:space="preserve">'''I-France''' ilizwe elitholakala eYurophu. Inhlokodolobha yalo yi-Paris.

[[File:Flag of France.svg||320px|thumb|]]</text>
      <sha1>ciefc0f7ftrfl7vz0ohdbtnuhsyt3yh</sha1>
    </revision>
    <revision>
      <id>6751</id>
      <parentid>6750</parentid>
      <timestamp>2026-07-27T07:45:37Z</timestamp>
      <contributor>
        <username>Zelbura</username>
        <id>1657</id>
      </contributor>
      <comment>/* */ I-Etymology</comment>
      <origin>6751</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="207" sha1="krbx5ichutfoyy1u9wqv3daqv8003m2" xml:space="preserve">'''I-France''' ilizwe elitholakala eYurophu. Inhlokodolobha yalo yi-Paris.

[[File:Flag of France.svg||320px|thumb|]]

[[File:France (orthographic projection).svg|thumb|]]


== I-Etymology ==

== Iinkomba ==</text>
      <sha1>krbx5ichutfoyy1u9wqv3daqv8003m2</sha1>
    </revision>
    <revision>
      <id>6752</id>
      <parentid>6751</parentid>
      <timestamp>2026-07-27T07:46:58Z</timestamp>
      <contributor>
        <username>Zelbura</username>
        <id>1657</id>
      </contributor>
      <comment>/* I-Etymology */ Igama elithi France lisuselwa egameni lesiLatini elithi Francia, elitjho “ilizwe lamaFranks”. AmaFranks bekulibandla labantu bamaJalimane abahlala eNtshonalanga Yurophu ngesikhathi samaRoma. Igama elithi France lasetjenziswa ukutjho indawo eyayibuswa ngamaFranks, begodu ngokukhamba kwesikhathi laba ligama lelizwe leFrance lanamhlanje</comment>
      <origin>6752</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="549" sha1="9ir9mv68yu0sk5yg7zsl08p7g4e5icq" xml:space="preserve">'''I-France''' ilizwe elitholakala eYurophu. Inhlokodolobha yalo yi-Paris.

[[File:Flag of France.svg||320px|thumb|]]

[[File:France (orthographic projection).svg|thumb|]]


== I-Etymology ==

Igama elithi France lisuselwa egameni lesiLatini elithi Francia, elitjho “ilizwe lamaFranks”. AmaFranks bekulibandla labantu bamaJalimane abahlala eNtshonalanga Yurophu ngesikhathi samaRoma. Igama elithi France lasetjenziswa ukutjho indawo eyayibuswa ngamaFranks, begodu ngokukhamba kwesikhathi laba ligama lelizwe leFrance lanamhlanje.

== Iinkomba ==</text>
      <sha1>9ir9mv68yu0sk5yg7zsl08p7g4e5icq</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi asiqongelane:Jacques Ballieu</title>
    <ns>3</ns>
    <id>1205</id>
    <revision>
      <id>6753</id>
      <timestamp>2026-07-27T08:31:08Z</timestamp>
      <contributor>
        <username>Jacques Ballieu</username>
        <id>1658</id>
      </contributor>
      <comment>Created page with &quot;Hello! --~~~~&quot;</comment>
      <origin>6753</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="140" sha1="czgqb2yb4tcmjox9plmsalv7wma1usy" xml:space="preserve">Hello! --[[Umsebenzisi:Jacques Ballieu|Jacques Ballieu]] ([[Umsebenzisi asiqongelane:Jacques Ballieu|talk]]) 10:30, 27 Ntulikazi 2026 (SAST)</text>
      <sha1>czgqb2yb4tcmjox9plmsalv7wma1usy</sha1>
    </revision>
  </page>
  <page>
    <title>I-Belgium</title>
    <ns>0</ns>
    <id>1206</id>
    <revision>
      <id>6754</id>
      <timestamp>2026-07-27T08:36:44Z</timestamp>
      <contributor>
        <username>Jacques Ballieu</username>
        <id>1658</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:fr:Special:Redirect/revision/237598618|Belgique]]&quot;</comment>
      <origin>6754</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="541" sha1="llo91ogbw8u90rcdwio90h8y2ov1hu1" xml:space="preserve">'''I-Belgium''', ngendlela ede '''uMbuso we-Belgium''' &lt;ref group=&quot;alpha&quot;&gt;En néerlandais : ''{{Lang|nl|texte=Koninkrijk België}}'' ; en allemand : ''{{Lang|de|texte=Königreich Belgien}}''.&lt;/ref&gt;, lilizwe elise -Western Europe, elinomngcele we [[France|-France]], i- Netherlands, i-Germany, i-Luxembourg kanye ne- North Sea. 

Ngokwepolotiki, ngumbuso womthethosisekelo wefederali onehlelo lephalamende. Ikomkhulu layo yi -Brussels Amanye amadorobha amakhulu yi -Antwerp, i-Ghent, i-Charleroi, i-Liège, i-Bruges, i-Namur kanye ne -Leuven.</text>
      <sha1>llo91ogbw8u90rcdwio90h8y2ov1hu1</sha1>
    </revision>
    <revision>
      <id>6755</id>
      <parentid>6754</parentid>
      <timestamp>2026-07-27T08:40:35Z</timestamp>
      <contributor>
        <username>Jacques Ballieu</username>
        <id>1658</id>
      </contributor>
      <origin>6755</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="398" sha1="3tuu1lekbervskypnp0p0ckarr78vnt" xml:space="preserve">'''I-Belgium''', ngendlela ede '''uMbuso we-Belgium''', lilizwe elise -Western Europe, elinomngcele we [[France|i-France]], i-Netherlands, i-Germany, i-Luxembourg kanye ne- North Sea. 

Ngokwepolotiki, ngumbuso womthethosisekelo wefederali onehlelo lephalamende. Ikomkhulu layo y i-Brussels Amanye amadorobha amakhulu y i-Antwerp, i-Ghent, i-Charleroi, i-Liège, i-Bruges, i-Namur kanye ne -Leuven.</text>
      <sha1>3tuu1lekbervskypnp0p0ckarr78vnt</sha1>
    </revision>
  </page>
  <page>
    <title>Umhlahlandlelasakhiwo:Cite web/doc</title>
    <ns>10</ns>
    <id>1207</id>
    <revision>
      <id>6757</id>
      <timestamp>2026-07-31T20:11:34Z</timestamp>
      <contributor>
        <username>Thuvack</username>
        <id>106</id>
      </contributor>
      <comment>Added template documentation page with template data</comment>
      <origin>6757</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="29803" sha1="rpi5u29nrbr5ddl79ycolb3mlsw3hti" xml:space="preserve">&lt;templatedata&gt;
{
	&quot;description&quot;: &quot;Formats a citation to a website using the provided information such as URL and title. Used only for sources that are not correctly described by the specific citation templates for books, journals, news sources, etc.&quot;,
	&quot;params&quot;: {
		&quot;url&quot;: {
			&quot;label&quot;: &quot;URL&quot;,
			&quot;description&quot;: &quot;The URL of the online location where the text of the publication can be found. Requires schemes of the type \&quot;http://...\&quot; or maybe even the protocol relative scheme \&quot;//...\&quot;&quot;,
			&quot;type&quot;: &quot;string&quot;,
			&quot;aliases&quot;: [
				&quot;URL&quot;
			],
			&quot;required&quot;: true,
			&quot;example&quot;: &quot;https://www.metacritic.com//...&quot;
		},
		&quot;title&quot;: {
			&quot;label&quot;: &quot;Title&quot;,
			&quot;description&quot;: &quot;The title of the source page on the website; will display with quotation marks added. Usually found at the top of your web browser. Not the name of the website.&quot;,
			&quot;type&quot;: &quot;string&quot;,
			&quot;required&quot;: true
		},
		&quot;date&quot;: {
			&quot;label&quot;: &quot;Source date&quot;,
			&quot;description&quot;: &quot;Full date when the source was published; if unknown, use accessdate instead; do not wikilink&quot;,
			&quot;type&quot;: &quot;date&quot;,
			&quot;suggested&quot;: true
		},
		&quot;accessdate&quot;: {
			&quot;label&quot;: &quot;URL access date&quot;,
			&quot;description&quot;: &quot;The full date when the original URL was accessed; do not wikilink&quot;,
			&quot;type&quot;: &quot;date&quot;,
			&quot;suggested&quot;: true
		},
		&quot;website&quot;: {
			&quot;label&quot;: &quot;Name of the website&quot;,
			&quot;description&quot;: &quot;Title (name) of the website (or its short URL if no plain-language title is discernible); may be wikilinked; will display in italics. Having both 'publisher' and 'website' is redundant in many cases.&quot;,
			&quot;type&quot;: &quot;string&quot;,
			&quot;aliases&quot;: [
				&quot;work&quot;
			],
			&quot;suggested&quot;: true,
			&quot;example&quot;: &quot;Rotten Tomatoes&quot;
		},
		&quot;publisher&quot;: {
			&quot;label&quot;: &quot;Publisher&quot;,
			&quot;description&quot;: &quot;Name of the publisher; may be wikilinked. Having both 'publisher' and 'website' (a.k.a. 'work') is redundant in many cases.&quot;,
			&quot;type&quot;: &quot;string&quot;,
			&quot;example&quot;: &quot;\&quot;CBS Interactive\&quot;, which owns \&quot;Metacritic.com\&quot;&quot;
		},
		&quot;last&quot;: {
			&quot;label&quot;: &quot;Last name&quot;,
			&quot;description&quot;: &quot;The surname of the author; don't wikilink, use 'authorlink'; can suffix with a numeral to add additional authors&quot;,
			&quot;aliases&quot;: [
				&quot;last1&quot;,
				&quot;author&quot;,
				&quot;author1&quot;,
				&quot;author1-last&quot;,
				&quot;author-last&quot;,
				&quot;surname1&quot;,
				&quot;author-last1&quot;,
				&quot;subject1&quot;,
				&quot;surname&quot;,
				&quot;author-last&quot;,
				&quot;subject&quot;
			],
			&quot;type&quot;: &quot;line&quot;,
			&quot;suggested&quot;: true
		},
		&quot;first&quot;: {
			&quot;label&quot;: &quot;First name&quot;,
			&quot;description&quot;: &quot;Given or first name, middle names, or initials of the author; don't wikilink, use 'authorlink'; can suffix with a numeral to add additional authors&quot;,
			&quot;aliases&quot;: [
				&quot;given&quot;,
				&quot;author-first&quot;,
				&quot;first1&quot;,
				&quot;given1&quot;,
				&quot;author-first1&quot;,
				&quot;author1-first&quot;
			],
			&quot;type&quot;: &quot;line&quot;,
			&quot;suggested&quot;: true
		},
		&quot;authorlink&quot;: {
			&quot;label&quot;: &quot;Author link&quot;,
			&quot;description&quot;: &quot;Title of existing Wikipedia article about the author; can suffix with a numeral to add additional authors&quot;,
			&quot;type&quot;: &quot;wiki-page-name&quot;,
			&quot;aliases&quot;: [
				&quot;author-link&quot;,
				&quot;subjectlink&quot;,
				&quot;subject-link&quot;,
				&quot;authorlink1&quot;,
				&quot;author-link1&quot;,
				&quot;author1-link&quot;,
				&quot;subjectlink1&quot;,
				&quot;author1link&quot;,
				&quot;subject-link1&quot;,
				&quot;subject1-link&quot;,
				&quot;subject1link&quot;
			]
		},
		&quot;last2&quot;: {
			&quot;label&quot;: &quot;Last name 2&quot;,
			&quot;description&quot;: &quot;The surname of the second author; don't wikilink, use 'authorlink2'.&quot;,
			&quot;type&quot;: &quot;line&quot;,
			&quot;aliases&quot;: [
				&quot;author2&quot;
			]
		},
		&quot;first2&quot;: {
			&quot;label&quot;: &quot;First name 2&quot;,
			&quot;type&quot;: &quot;line&quot;,
			&quot;description&quot;: &quot;Given or first name, middle names, or initials of the second author; don't wikilink.&quot;
		},
		&quot;authorlink2&quot;: {
			&quot;label&quot;: &quot;Author link 2&quot;,
			&quot;description&quot;: &quot;Title of existing Wikipedia article about the second author.&quot;,
			&quot;type&quot;: &quot;wiki-page-name&quot;,
			&quot;aliases&quot;: [
				&quot;author2-link&quot;
			]
		},
		&quot;others&quot;: {
			&quot;label&quot;: &quot;Others&quot;,
			&quot;description&quot;: &quot;Used to record other (non-author) contributions to the work, such as 'Illustrated by John Smith' or 'Translated by John Smith'. Only one ''others'' parameter is allowed: e.g., 'Illustrated by Jane Doe; Translated by John Smith'&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;year&quot;: {
			&quot;label&quot;: &quot;Year of publication&quot;,
			&quot;description&quot;: &quot;Year of the source being referenced; deprecated in favor of 'date', except for the special case of ISO dates with CITEREF in CS2 or Harvard citations&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;orig-year&quot;: {
			&quot;label&quot;: &quot;Original year&quot;,
			&quot;description&quot;: &quot;Original year of publication; provide specifics&quot;,
			&quot;type&quot;: &quot;string&quot;,
			&quot;aliases&quot;: [
				&quot;origyear&quot;
			]
		},
		&quot;editor-last&quot;: {
			&quot;label&quot;: &quot;Editor last name&quot;,
			&quot;description&quot;: &quot;The surname of the editor; don't wikilink, use 'editor-link'; can suffix with a numeral to add additional editors.&quot;,
			&quot;type&quot;: &quot;line&quot;,
			&quot;aliases&quot;: [
				&quot;editor1-last&quot;,
				&quot;editor&quot;,
				&quot;editors&quot;
			]
		},
		&quot;editor-first&quot;: {
			&quot;label&quot;: &quot;Editor first name&quot;,
			&quot;description&quot;: &quot;Given or first name, middle names, or initials of the editor; don't wikilink, use 'editor-link'; can suffix with a numeral to add additional editors; alias of 'editor1-first'&quot;,
			&quot;type&quot;: &quot;line&quot;,
			&quot;aliases&quot;: [
				&quot;editor1-first&quot;
			]
		},
		&quot;editor-link&quot;: {
			&quot;label&quot;: &quot;Editor link&quot;,
			&quot;description&quot;: &quot;Title of existing Wikipedia article about the editor; can suffix with a numeral to add additional editors&quot;,
			&quot;aliases&quot;: [
				&quot;editor1-link&quot;
			],
			&quot;type&quot;: &quot;wiki-page-name&quot;
		},
		&quot;series&quot;: {
			&quot;label&quot;: &quot;Series identifier&quot;,
			&quot;description&quot;: &quot;Series identifier when the source is part of a series, such as a book series or a journal&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;location&quot;: {
			&quot;label&quot;: &quot;Location of publication&quot;,
			&quot;description&quot;: &quot;Geographical place of publication; usually not wikilinked; omit when the publication name includes place; alias of 'place'&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;publication-place&quot;: {
			&quot;label&quot;: &quot;Place of publication&quot;,
			&quot;description&quot;: &quot;Publication place shows after title; if 'place' or 'location' are also given, they are displayed before the title prefixed with 'written at'&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;publication-date&quot;: {
			&quot;label&quot;: &quot;Publication date&quot;,
			&quot;description&quot;: &quot;Date of publication when different from the date the work was written; do not wikilink&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;page&quot;: {
			&quot;label&quot;: &quot;Page&quot;,
			&quot;description&quot;: &quot;Page in the source that supports the content; displays after 'p.'&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;pages&quot;: {
			&quot;label&quot;: &quot;Pages&quot;,
			&quot;description&quot;: &quot;Pages in the source that support the content (not an indication of the number of pages in the source); displays after 'pp.'&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;nopp&quot;: {
			&quot;label&quot;: &quot;No pp&quot;,
			&quot;description&quot;: &quot;Set to 'y' to suppress the 'p.' or 'pp.' display with 'page' or 'pages' when inappropriate (such as 'Front cover')&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;at&quot;: {
			&quot;label&quot;: &quot;At&quot;,
			&quot;description&quot;: &quot;May be used instead of 'page' or 'pages' where a page number is inappropriate or insufficient&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;language&quot;: {
			&quot;label&quot;: &quot;Language&quot;,
			&quot;description&quot;: &quot;The language in which the source is written, if not English; use the full language name or one of the standard MediaWiki language codes; do not use icons or templates; separate multiple languages with commas (with no 'and' before the last one)&quot;,
			&quot;type&quot;: &quot;string&quot;,
			&quot;aliases&quot;: [
				&quot;lang&quot;
			],
			&quot;example&quot;: &quot;de, fr, es&quot;
		},
		&quot;script-title&quot;: {
			&quot;label&quot;: &quot;Script title&quot;,
			&quot;description&quot;: &quot;For titles in languages that do not use a Latin-based alphabet (Arabic, Chinese, Cyrillic, Greek, Hebrew, Japanese, Korean, Vietnamese, etc). Prefix with two-character ISO639-1 language code followed by a colon. For Japanese use: |script-title=ja:...&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;trans-title&quot;: {
			&quot;label&quot;: &quot;Translated title&quot;,
			&quot;description&quot;: &quot;An English language title, if the source cited is in a foreign language; 'language' is recommended&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;type&quot;: {
			&quot;label&quot;: &quot;Type&quot;,
			&quot;description&quot;: &quot;Additional information about the media type of the source; format in sentence case&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;format&quot;: {
			&quot;label&quot;: &quot;Format&quot;,
			&quot;description&quot;: &quot;Format of the work referred to by 'url'; examples: PDF, DOC, XLS; do not specify HTML&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;arxiv&quot;: {
			&quot;label&quot;: &quot;arXiv identifier&quot;,
			&quot;description&quot;: &quot;An identifier for arXive electronic preprints of scientific papers&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;asin&quot;: {
			&quot;label&quot;: &quot;ASIN&quot;,
			&quot;description&quot;: &quot;Amazon Standard Identification Number; 10 characters&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;asin-tld&quot;: {
			&quot;label&quot;: &quot;ASIN TLD&quot;,
			&quot;description&quot;: &quot;ASIN top-level domain for Amazon sites other than the US&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;bibcode&quot;: {
			&quot;label&quot;: &quot;Bibcode&quot;,
			&quot;description&quot;: &quot;Bibliographic Reference Code (REFCODE); 19 characters&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;biorxiv&quot;: {
			&quot;label&quot;: &quot;biorXiv&quot;,
			&quot;description&quot;: &quot;biorXiv identifier; 6 digits&quot;,
			&quot;type&quot;: &quot;line&quot;
		},
		&quot;citeseerx&quot;: {
			&quot;label&quot;: &quot;CiteSeerX&quot;,
			&quot;description&quot;: &quot;CiteSeerX identifier; found after the 'doi=' query parameter&quot;,
			&quot;type&quot;: &quot;line&quot;
		},
		&quot;doi&quot;: {
			&quot;label&quot;: &quot;DOI&quot;,
			&quot;description&quot;: &quot;Digital Object Identifier; begins with '10.'&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;doi-broken-date&quot;: {
			&quot;label&quot;: &quot;DOI broken date&quot;,
			&quot;description&quot;: &quot;The date that the DOI was determined to be broken&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;isbn&quot;: {
			&quot;label&quot;: &quot;ISBN&quot;,
			&quot;description&quot;: &quot;International Standard Book Number; use the 13-digit ISBN where possible&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;issn&quot;: {
			&quot;label&quot;: &quot;ISSN&quot;,
			&quot;description&quot;: &quot;International Standard Serial Number; 8 characters; may be split into two groups of four using a hyphen&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;jfm&quot;: {
			&quot;label&quot;: &quot;jfm code&quot;,
			&quot;description&quot;: &quot;Jahrbuch über die Fortschritte der Mathematik classification code&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;jstor&quot;: {
			&quot;label&quot;: &quot;JSTOR&quot;,
			&quot;description&quot;: &quot;JSTOR identifier&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;lccn&quot;: {
			&quot;label&quot;: &quot;LCCN&quot;,
			&quot;description&quot;: &quot;Library of Congress Control Number&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;mr&quot;: {
			&quot;label&quot;: &quot;MR&quot;,
			&quot;description&quot;: &quot;Mathematical Reviews identifier&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;oclc&quot;: {
			&quot;label&quot;: &quot;OCLC&quot;,
			&quot;description&quot;: &quot;Online Computer Library Center number&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;ol&quot;: {
			&quot;label&quot;: &quot;OL&quot;,
			&quot;description&quot;: &quot;Open Library identifier&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;osti&quot;: {
			&quot;label&quot;: &quot;OSTI&quot;,
			&quot;description&quot;: &quot;Office of Scientific and Technical Information identifier&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;pmc&quot;: {
			&quot;label&quot;: &quot;PMC&quot;,
			&quot;description&quot;: &quot;PubMed Center article number&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;pmid&quot;: {
			&quot;label&quot;: &quot;PMID&quot;,
			&quot;description&quot;: &quot;PubMed Unique Identifier&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;rfc&quot;: {
			&quot;label&quot;: &quot;RFC&quot;,
			&quot;description&quot;: &quot;Request for Comments number&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;ssrn&quot;: {
			&quot;label&quot;: &quot;SSRN&quot;,
			&quot;description&quot;: &quot;Social Science Research Network&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;zbl&quot;: {
			&quot;label&quot;: &quot;Zbl&quot;,
			&quot;description&quot;: &quot;Zentralblatt MATH journal identifier&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;id&quot;: {
			&quot;label&quot;: &quot;id&quot;,
			&quot;description&quot;: &quot;A unique identifier used where none of the specialized ones are applicable&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;archive-url&quot;: {
			&quot;label&quot;: &quot;Archive URL&quot;,
			&quot;aliases&quot;: [
				&quot;archiveurl&quot;
			],
			&quot;description&quot;: &quot;The URL of an archived copy of a web page, if or in case the URL becomes unavailable; requires 'archive-date'&quot;,
			&quot;type&quot;: &quot;string&quot;,
			&quot;suggested&quot;: true
		},
		&quot;archive-date&quot;: {
			&quot;label&quot;: &quot;Archive date&quot;,
			&quot;aliases&quot;: [
				&quot;archivedate&quot;
			],
			&quot;description&quot;: &quot;Date when the original URL was archived; do not wikilink&quot;,
			&quot;type&quot;: &quot;date&quot;,
			&quot;suggested&quot;: true
		},
		&quot;archive-format&quot;: {
			&quot;label&quot;: &quot;Archive format&quot;,
			&quot;description&quot;: &quot;Format of the archived copy; examples: PDF, DOC, XLS; do not specify HTML&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;quote&quot;: {
			&quot;label&quot;: &quot;Quote&quot;,
			&quot;description&quot;: &quot;Relevant text quoted from the source; displays last, enclosed in quotes; must include terminating punctuation&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;ref&quot;: {
			&quot;label&quot;: &quot;Ref&quot;,
			&quot;description&quot;: &quot;An anchor identifier; can be made the target of wikilinks to full references; special value 'harv' generates an anchor suitable for the harv template&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;separator&quot;: {
			&quot;label&quot;: &quot;Separator&quot;,
			&quot;description&quot;: &quot;The punctuation used to separate lists of authors, editors, etc.; a space must be encoded as &amp;#32; do not use an asterisk, colon, or hash mark&quot;,
			&quot;type&quot;: &quot;string&quot;,
			&quot;default&quot;: &quot;.&quot;
		},
		&quot;postscript&quot;: {
			&quot;label&quot;: &quot;Postscript&quot;,
			&quot;description&quot;: &quot;The closing punctuation for the citation; ignored if 'quote' is defined&quot;,
			&quot;type&quot;: &quot;string&quot;,
			&quot;default&quot;: &quot;.&quot;
		},
		&quot;layurl&quot;: {
			&quot;label&quot;: &quot;Lay URL&quot;,
			&quot;description&quot;: &quot;URL link to a non-technical summary or review of the source; alias of 'laysummary'&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;laysource&quot;: {
			&quot;label&quot;: &quot;Lay source&quot;,
			&quot;description&quot;: &quot;Name of the source of the laysummary; displays in italics, preceded by an en dash&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;laydate&quot;: {
			&quot;label&quot;: &quot;Lay date&quot;,
			&quot;description&quot;: &quot;Date of the summary; displays in parentheses&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;author-mask&quot;: {
			&quot;label&quot;: &quot;Author mask&quot;,
			&quot;description&quot;: &quot;Replaces the name of the first author with em dashes or text; set to a numeric value 'n' to set the dash 'n' em spaces wide; set to a text value to display the text without a trailing author separator; for example, 'with' instead&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;last3&quot;: {
			&quot;label&quot;: &quot;Last name 3&quot;,
			&quot;description&quot;: &quot;The surname of the third author; don't wikilink, use 'authorlink3'.&quot;,
			&quot;type&quot;: &quot;line&quot;,
			&quot;aliases&quot;: [
				&quot;author3&quot;
			]
		},
		&quot;first3&quot;: {
			&quot;label&quot;: &quot;First name 3&quot;,
			&quot;type&quot;: &quot;line&quot;,
			&quot;description&quot;: &quot;Given or first name, middle names, or initials of the third author; don't wikilink.&quot;
		},
		&quot;authorlink3&quot;: {
			&quot;label&quot;: &quot;Author link 3&quot;,
			&quot;description&quot;: &quot;Title of existing Wikipedia article about the third author.&quot;,
			&quot;type&quot;: &quot;wiki-page-name&quot;,
			&quot;aliases&quot;: [
				&quot;author3-link&quot;
			]
		},
		&quot;last4&quot;: {
			&quot;label&quot;: &quot;Last name 4&quot;,
			&quot;description&quot;: &quot;The surname of the fourth author; don't wikilink, use 'authorlink4'.&quot;,
			&quot;type&quot;: &quot;line&quot;,
			&quot;aliases&quot;: [
				&quot;author4&quot;
			]
		},
		&quot;first4&quot;: {
			&quot;label&quot;: &quot;First name 4&quot;,
			&quot;type&quot;: &quot;line&quot;,
			&quot;description&quot;: &quot;Given or first name, middle names, or initials of the fourth author; don't wikilink.&quot;
		},
		&quot;authorlink4&quot;: {
			&quot;label&quot;: &quot;Author link 4&quot;,
			&quot;description&quot;: &quot;Title of existing Wikipedia article about the fourth author.&quot;,
			&quot;type&quot;: &quot;wiki-page-name&quot;,
			&quot;aliases&quot;: [
				&quot;author4-link&quot;
			]
		},
		&quot;last5&quot;: {
			&quot;label&quot;: &quot;Last name 5&quot;,
			&quot;description&quot;: &quot;The surname of the fifth author; don't wikilink, use 'authorlink5'.&quot;,
			&quot;type&quot;: &quot;line&quot;,
			&quot;aliases&quot;: [
				&quot;author5&quot;
			]
		},
		&quot;first5&quot;: {
			&quot;label&quot;: &quot;First name 5&quot;,
			&quot;type&quot;: &quot;line&quot;,
			&quot;description&quot;: &quot;Given or first name, middle names, or initials of the fifth author; don't wikilink.&quot;
		},
		&quot;authorlink5&quot;: {
			&quot;label&quot;: &quot;Author link 5&quot;,
			&quot;description&quot;: &quot;Title of existing Wikipedia article about the fifth author.&quot;,
			&quot;type&quot;: &quot;wiki-page-name&quot;,
			&quot;aliases&quot;: [
				&quot;author5-link&quot;
			]
		},
		&quot;last6&quot;: {
			&quot;label&quot;: &quot;Last name 6&quot;,
			&quot;description&quot;: &quot;The surname of the sixth author; don't wikilink, use 'authorlink6'.&quot;,
			&quot;type&quot;: &quot;line&quot;,
			&quot;aliases&quot;: [
				&quot;author6&quot;
			]
		},
		&quot;first6&quot;: {
			&quot;label&quot;: &quot;First name 6&quot;,
			&quot;description&quot;: &quot;Given or first name, middle names, or initials of the sixth author; don't wikilink.&quot;,
			&quot;type&quot;: &quot;line&quot;
		},
		&quot;authorlink6&quot;: {
			&quot;label&quot;: &quot;Author link 6&quot;,
			&quot;description&quot;: &quot;Title of existing Wikipedia article about the sixth author.&quot;,
			&quot;type&quot;: &quot;wiki-page-name&quot;,
			&quot;aliases&quot;: [
				&quot;author6-link&quot;
			]
		},
		&quot;last7&quot;: {
			&quot;label&quot;: &quot;Last name 7&quot;,
			&quot;description&quot;: &quot;The surname of the seventh author; don't wikilink, use 'authorlink7'.&quot;,
			&quot;type&quot;: &quot;line&quot;,
			&quot;aliases&quot;: [
				&quot;author7&quot;
			]
		},
		&quot;first7&quot;: {
			&quot;label&quot;: &quot;First name 7&quot;,
			&quot;type&quot;: &quot;line&quot;,
			&quot;description&quot;: &quot;Given or first name, middle names, or initials of the seventh author; don't wikilink.&quot;
		},
		&quot;authorlink7&quot;: {
			&quot;label&quot;: &quot;Author link 7&quot;,
			&quot;description&quot;: &quot;Title of existing Wikipedia article about the seventh author.&quot;,
			&quot;type&quot;: &quot;wiki-page-name&quot;,
			&quot;aliases&quot;: [
				&quot;author7-link&quot;
			]
		},
		&quot;last8&quot;: {
			&quot;label&quot;: &quot;Last name 8&quot;,
			&quot;description&quot;: &quot;The surname of the eighth author; don't wikilink, use 'authorlink8'.&quot;,
			&quot;type&quot;: &quot;line&quot;,
			&quot;aliases&quot;: [
				&quot;author8&quot;
			]
		},
		&quot;first8&quot;: {
			&quot;label&quot;: &quot;First name 8&quot;,
			&quot;type&quot;: &quot;line&quot;,
			&quot;description&quot;: &quot;Given or first name, middle names, or initials of the eighth author; don't wikilink.&quot;
		},
		&quot;authorlink8&quot;: {
			&quot;label&quot;: &quot;Author link 8&quot;,
			&quot;description&quot;: &quot;Title of existing Wikipedia article about the eighth author.&quot;,
			&quot;type&quot;: &quot;wiki-page-name&quot;,
			&quot;aliases&quot;: [
				&quot;author8-link&quot;
			]
		},
		&quot;last9&quot;: {
			&quot;label&quot;: &quot;Last name 9&quot;,
			&quot;description&quot;: &quot;The surname of the ninth author; don't wikilink, use 'authorlink9'. If nine authors are defined, then only eight will show and 'et al.' will show in place of the last author.&quot;,
			&quot;type&quot;: &quot;line&quot;,
			&quot;aliases&quot;: [
				&quot;author9&quot;
			]
		},
		&quot;first9&quot;: {
			&quot;label&quot;: &quot;First name 9&quot;,
			&quot;type&quot;: &quot;line&quot;,
			&quot;description&quot;: &quot;Given or first name, middle names, or initials of the ninth author; don't wikilink.&quot;
		},
		&quot;authorlink9&quot;: {
			&quot;label&quot;: &quot;Author link 9&quot;,
			&quot;description&quot;: &quot;Title of existing Wikipedia article about the ninth author.&quot;,
			&quot;type&quot;: &quot;wiki-page-name&quot;,
			&quot;aliases&quot;: [
				&quot;author9-link&quot;
			]
		},
		&quot;author-name-separator&quot;: {
			&quot;label&quot;: &quot;Author name separator&quot;,
			&quot;description&quot;: &quot;Changes the separator between last and first names; defaults to a comma and space; a space must be encoded as &amp;#32; do not use an asterisk, colon, or hash mark&quot;,
			&quot;type&quot;: &quot;string&quot;,
			&quot;default&quot;: &quot;, &quot;
		},
		&quot;author-separator&quot;: {
			&quot;label&quot;: &quot;Author separator&quot;,
			&quot;description&quot;: &quot;Changes the separator between authors; defaults to a semicolon and space; a space must be encoded as &amp;#32; do not use an asterisk, colon, or hash mark&quot;,
			&quot;type&quot;: &quot;string&quot;,
			&quot;default&quot;: &quot;; &quot;
		},
		&quot;display-authors&quot;: {
			&quot;label&quot;: &quot;Display authors&quot;,
			&quot;description&quot;: &quot;Number of authors to display before 'et al.' is used. By default, all authors are displayed. Examples: |display-authors=2 will display only the first two authors in a citation followed by et al. |display-authors=etal displays all authors in the list followed by et al.&quot;,
			&quot;type&quot;: &quot;string&quot;,
			&quot;aliases&quot;: [
				&quot;displayauthors&quot;
			]
		},
		&quot;last-author-amp&quot;: {
			&quot;label&quot;: &quot;Last author ampersand&quot;,
			&quot;description&quot;: &quot;When set to any value, changes the separator between the last two names of the author list to 'space ampersand space'&quot;,
			&quot;type&quot;: &quot;string&quot;,
			&quot;aliases&quot;: [
				&quot;lastauthoramp&quot;
			]
		},
		&quot;editor2-last&quot;: {
			&quot;label&quot;: &quot;Editor last name 2&quot;,
			&quot;description&quot;: &quot;The surname of the second editor; don't wikilink, use 'editor2-link'.&quot;,
			&quot;aliases&quot;: [
				&quot;editor2&quot;
			],
			&quot;type&quot;: &quot;line&quot;
		},
		&quot;editor2-first&quot;: {
			&quot;label&quot;: &quot;Editor first name 2&quot;,
			&quot;description&quot;: &quot;Given or first name, middle names, or initials of the second editor; don't wikilink.&quot;,
			&quot;type&quot;: &quot;line&quot;
		},
		&quot;editor3-last&quot;: {
			&quot;label&quot;: &quot;Editor last name 3&quot;,
			&quot;description&quot;: &quot;The surname of the third editor; don't wikilink, use 'editor3-link'.&quot;,
			&quot;aliases&quot;: [
				&quot;editor3&quot;
			],
			&quot;type&quot;: &quot;line&quot;
		},
		&quot;editor3-first&quot;: {
			&quot;label&quot;: &quot;Editor first name 3&quot;,
			&quot;description&quot;: &quot;Given or first name, middle names, or initials of the third editor; don't wikilink.&quot;,
			&quot;type&quot;: &quot;line&quot;
		},
		&quot;editor4-last&quot;: {
			&quot;label&quot;: &quot;Editor last name 4&quot;,
			&quot;description&quot;: &quot;The surname of the fourth editor; don't wikilink, use 'editor4-link'.&quot;,
			&quot;aliases&quot;: [
				&quot;editor4&quot;
			],
			&quot;type&quot;: &quot;line&quot;
		},
		&quot;editor4-first&quot;: {
			&quot;label&quot;: &quot;Editor first name 4&quot;,
			&quot;description&quot;: &quot;Given or first name, middle names, or initials of the fourth editor; don't wikilink.&quot;,
			&quot;type&quot;: &quot;line&quot;
		},
		&quot;editor5-last&quot;: {
			&quot;label&quot;: &quot;Editor last name 5&quot;,
			&quot;description&quot;: &quot;The surname of the fifth editor; don't wikilink, use 'editor5-link'.&quot;,
			&quot;aliases&quot;: [
				&quot;editor5&quot;
			],
			&quot;type&quot;: &quot;line&quot;
		},
		&quot;editor5-first&quot;: {
			&quot;label&quot;: &quot;Editor first name 5&quot;,
			&quot;description&quot;: &quot;Given or first name, middle names, or initials of the fifth editor; don't wikilink.&quot;,
			&quot;type&quot;: &quot;line&quot;
		},
		&quot;editor6-last&quot;: {
			&quot;label&quot;: &quot;Editor last name 6&quot;,
			&quot;description&quot;: &quot;The surname of the sixth editor; don't wikilink, use 'editor6-link'.&quot;,
			&quot;aliases&quot;: [
				&quot;editor6&quot;
			],
			&quot;type&quot;: &quot;line&quot;
		},
		&quot;editor6-first&quot;: {
			&quot;label&quot;: &quot;Editor first name 6&quot;,
			&quot;description&quot;: &quot;Given or first name, middle names, or initials of the sixth editor; don't wikilink.&quot;,
			&quot;type&quot;: &quot;line&quot;
		},
		&quot;editor7-last&quot;: {
			&quot;label&quot;: &quot;Editor last name 7&quot;,
			&quot;description&quot;: &quot;The surname of the seventh editor; don't wikilink, use 'editor7-link'.&quot;,
			&quot;aliases&quot;: [
				&quot;editor7&quot;
			],
			&quot;type&quot;: &quot;line&quot;
		},
		&quot;editor7-first&quot;: {
			&quot;label&quot;: &quot;Editor first name 7&quot;,
			&quot;description&quot;: &quot;Given or first name, middle names, or initials of the seventh editor; don't wikilink.&quot;,
			&quot;type&quot;: &quot;line&quot;
		},
		&quot;editor8-last&quot;: {
			&quot;label&quot;: &quot;Editor last name 8&quot;,
			&quot;description&quot;: &quot;The surname of the eighth editor; don't wikilink, use 'editor8-link'.&quot;,
			&quot;aliases&quot;: [
				&quot;editor8&quot;
			],
			&quot;type&quot;: &quot;line&quot;
		},
		&quot;editor8-first&quot;: {
			&quot;label&quot;: &quot;Editor first name 8&quot;,
			&quot;description&quot;: &quot;Given or first name, middle names, or initials of the eighth editor; don't wikilink.&quot;,
			&quot;type&quot;: &quot;line&quot;
		},
		&quot;editor9-last&quot;: {
			&quot;label&quot;: &quot;Editor last name 9&quot;,
			&quot;description&quot;: &quot;The surname of the ninth editor; don't wikilink, use 'editor9-link'.&quot;,
			&quot;aliases&quot;: [
				&quot;editor9&quot;
			],
			&quot;type&quot;: &quot;line&quot;
		},
		&quot;editor9-first&quot;: {
			&quot;label&quot;: &quot;Editor first name 9&quot;,
			&quot;description&quot;: &quot;Given or first name, middle names, or initials of the ninth editor; don't wikilink.&quot;,
			&quot;type&quot;: &quot;line&quot;
		},
		&quot;editor2-link&quot;: {
			&quot;label&quot;: &quot;Editor link 2&quot;,
			&quot;description&quot;: &quot;Title of existing Wikipedia article about the second editor.&quot;,
			&quot;type&quot;: &quot;wiki-page-name&quot;,
			&quot;aliases&quot;: [
				&quot;editor2link&quot;,
				&quot;editorlink2&quot;
			]
		},
		&quot;editor3-link&quot;: {
			&quot;label&quot;: &quot;Editor link 3&quot;,
			&quot;description&quot;: &quot;Title of existing Wikipedia article about the third editor.&quot;,
			&quot;type&quot;: &quot;wiki-page-name&quot;,
			&quot;aliases&quot;: [
				&quot;editor3link&quot;,
				&quot;editorlink3&quot;
			]
		},
		&quot;editor4-link&quot;: {
			&quot;label&quot;: &quot;Editor link 4&quot;,
			&quot;description&quot;: &quot;Title of existing Wikipedia article about the fourth editor.&quot;,
			&quot;type&quot;: &quot;wiki-page-name&quot;,
			&quot;aliases&quot;: [
				&quot;editor4link&quot;,
				&quot;editorlink4&quot;
			]
		},
		&quot;editor5-link&quot;: {
			&quot;label&quot;: &quot;Editor link 5&quot;,
			&quot;description&quot;: &quot;Title of existing Wikipedia article about the fifth editor.&quot;,
			&quot;type&quot;: &quot;wiki-page-name&quot;,
			&quot;aliases&quot;: [
				&quot;editor5link&quot;,
				&quot;editorlink5&quot;
			]
		},
		&quot;editor6-link&quot;: {
			&quot;label&quot;: &quot;Editor link 6&quot;,
			&quot;description&quot;: &quot;Title of existing Wikipedia article about the sixth editor.&quot;,
			&quot;type&quot;: &quot;wiki-page-name&quot;,
			&quot;aliases&quot;: [
				&quot;editor6link&quot;,
				&quot;editorlink6&quot;
			]
		},
		&quot;editor7-link&quot;: {
			&quot;label&quot;: &quot;Editor link 7&quot;,
			&quot;description&quot;: &quot;Title of existing Wikipedia article about the seventh editor.&quot;,
			&quot;type&quot;: &quot;wiki-page-name&quot;,
			&quot;aliases&quot;: [
				&quot;editor7link&quot;,
				&quot;editorlink7&quot;
			]
		},
		&quot;editor8-link&quot;: {
			&quot;label&quot;: &quot;Editor link 8&quot;,
			&quot;description&quot;: &quot;Title of existing Wikipedia article about the eighth editor.&quot;,
			&quot;type&quot;: &quot;wiki-page-name&quot;,
			&quot;aliases&quot;: [
				&quot;editor8link&quot;,
				&quot;editorlink8&quot;
			]
		},
		&quot;editor9-link&quot;: {
			&quot;label&quot;: &quot;Editor link 9&quot;,
			&quot;description&quot;: &quot;Title of existing Wikipedia article about the ninth editor.&quot;,
			&quot;type&quot;: &quot;wiki-page-name&quot;,
			&quot;aliases&quot;: [
				&quot;editor9link&quot;,
				&quot;editorlink9&quot;
			]
		},
		&quot;subscription&quot;: {
			&quot;label&quot;: &quot;Subscription required&quot;,
			&quot;description&quot;: &quot;Use 'url-access' instead&quot;,
			&quot;type&quot;: &quot;string&quot;,
			&quot;deprecated&quot;: true
		},
		&quot;registration&quot;: {
			&quot;label&quot;: &quot;Registration required&quot;,
			&quot;description&quot;: &quot;Use 'url-access' instead&quot;,
			&quot;type&quot;: &quot;string&quot;,
			&quot;deprecated&quot;: true
		},
		&quot;edition&quot;: {
			&quot;label&quot;: &quot;Edition&quot;,
			&quot;type&quot;: &quot;string&quot;,
			&quot;description&quot;: &quot;Specify the edition or revision of the source, when applicable. For example: '2nd' or '5.1'. What you supply here is suffixed by ' ed.'&quot;
		},
		&quot;url-access&quot;: {
			&quot;label&quot;: &quot;URL access level&quot;,
			&quot;description&quot;: &quot;Classification of the access restrictions on the URL ('registration', 'subscription' or 'limited')&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;bibcode-access&quot;: {
			&quot;label&quot;: &quot;Bibcode access level&quot;,
			&quot;description&quot;: &quot;If the full text is available from ADS via this Bibcode, type 'free'.&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;doi-access&quot;: {
			&quot;label&quot;: &quot;DOI access level&quot;,
			&quot;description&quot;: &quot;If the full text is free to read via the DOI, type 'free'.&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;hdl-access&quot;: {
			&quot;label&quot;: &quot;HDL access level&quot;,
			&quot;description&quot;: &quot;If the full text is free to read via the HDL, type 'free'.&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;jstor-access&quot;: {
			&quot;label&quot;: &quot;Jstor access level&quot;,
			&quot;description&quot;: &quot;If the full text is free to read on Jstor, type 'free'.&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;ol-access&quot;: {
			&quot;label&quot;: &quot;OpenLibrary access level&quot;,
			&quot;description&quot;: &quot;If the full text is free to read on OpenLibrary, type 'free'.&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;osti-access&quot;: {
			&quot;label&quot;: &quot;OSTI access level&quot;,
			&quot;description&quot;: &quot;If the full text is free to read on OSTI, type 'free'.&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;authors&quot;: {
			&quot;label&quot;: &quot;Authors list&quot;,
			&quot;description&quot;: &quot;List of authors as a free form list. Use of this parameter is discouraged, \&quot;lastn\&quot; to \&quot;firstn\&quot; are preferable. Warning: do not use if last or any of its aliases are used.&quot;,
			&quot;type&quot;: &quot;string&quot;,
			&quot;aliases&quot;: [
				&quot;people&quot;,
				&quot;host&quot;,
				&quot;credits&quot;
			]
		},
		&quot;via&quot;: {
			&quot;label&quot;: &quot;Published via&quot;,
			&quot;description&quot;: &quot;Name of the entity hosting the original copy of the work, if different from the publisher. This entity is committed not to alter the work. GitHub, SourceForge, CodePlex, YouTube, Vimeo, Dailymotion and Netflix are examples of service dedicated to acting on behalf of the publisher, but Archive.org, Wikimedia Commons and grc.com have done this on certain occasions.&quot;,
			&quot;example&quot;: &quot;\&quot;GitHub\&quot;, which hosts \&quot;Visual Studio Code\&quot; on behalf of \&quot;Microsoft\&quot;&quot;,
			&quot;type&quot;: &quot;string&quot;
		},
		&quot;url-status&quot;: {
			&quot;label&quot;: &quot;URL status&quot;,
			&quot;description&quot;: &quot;If set to 'live', the title display is adjusted; useful for when the URL is archived preemptively but still live. Set to \&quot;dead\&quot; or 'usurped' for broken links. Entering 'unfit' or 'usurped' makes the original link not appear at all.&quot;,
			&quot;example&quot;: &quot;'dead' or 'live'&quot;,
			&quot;type&quot;: &quot;string&quot;,
			&quot;default&quot;: &quot;'dead' if an Archive URL is entered&quot;,
			&quot;autovalue&quot;: &quot;live&quot;,
			&quot;suggested&quot;: true
		}
	},
	&quot;maps&quot;: {
		&quot;citoid&quot;: {
			&quot;title&quot;: &quot;title&quot;,
			&quot;url&quot;: &quot;url&quot;,
			&quot;subject&quot;: &quot;title&quot;,
			&quot;publicationTitle&quot;: &quot;website&quot;,
			&quot;blogTitle&quot;: &quot;website&quot;,
			&quot;forumTitle&quot;: &quot;website&quot;,
			&quot;seriesTitle&quot;: &quot;website&quot;,
			&quot;websiteTitle&quot;: &quot;website&quot;,
			&quot;publisher&quot;: &quot;publisher&quot;,
			&quot;date&quot;: &quot;date&quot;,
			&quot;PMCID&quot;: &quot;pmc&quot;,
			&quot;PMID&quot;: &quot;pmid&quot;,
			&quot;oclc&quot;: &quot;oclc&quot;,
			&quot;pages&quot;: &quot;pages&quot;,
			&quot;series&quot;: &quot;series&quot;,
			&quot;accessDate&quot;: &quot;accessdate&quot;,
			&quot;DOI&quot;: &quot;doi&quot;,
			&quot;language&quot;: &quot;language&quot;,
			&quot;contributor&quot;: &quot;others&quot;,
			&quot;author&quot;: [
				[
					&quot;first&quot;,
					&quot;last&quot;
				],
				[
					&quot;first2&quot;,
					&quot;last2&quot;
				],
				[
					&quot;first3&quot;,
					&quot;last3&quot;
				],
				[
					&quot;first4&quot;,
					&quot;last4&quot;
				],
				[
					&quot;first5&quot;,
					&quot;last5&quot;
				],
				[
					&quot;first6&quot;,
					&quot;last6&quot;
				],
				[
					&quot;first7&quot;,
					&quot;last7&quot;
				],
				[
					&quot;first8&quot;,
					&quot;last8&quot;
				],
				[
					&quot;first9&quot;,
					&quot;last9&quot;
				]
			],
			&quot;editor&quot;: [
				[
					&quot;editor-first&quot;,
					&quot;editor-last&quot;
				],
				[
					&quot;editor2-first&quot;,
					&quot;editor2-last&quot;
				],
				[
					&quot;editor3-first&quot;,
					&quot;editor3-last&quot;
				],
				[
					&quot;editor4-first&quot;,
					&quot;editor4-last&quot;
				],
				[
					&quot;editor5-first&quot;,
					&quot;editor5-last&quot;
				],
				[
					&quot;editor6-first&quot;,
					&quot;editor6-last&quot;
				],
				[
					&quot;editor7-first&quot;,
					&quot;editor7-last&quot;
				],
				[
					&quot;editor8-first&quot;,
					&quot;editor8-last&quot;
				],
				[
					&quot;editor9-first&quot;,
					&quot;editor9-last&quot;
				]
			]
		}
	},
	&quot;paramOrder&quot;: [
		&quot;last&quot;,
		&quot;first&quot;,
		&quot;authorlink&quot;,
		&quot;last2&quot;,
		&quot;first2&quot;,
		&quot;authorlink2&quot;,
		&quot;last3&quot;,
		&quot;first3&quot;,
		&quot;authorlink3&quot;,
		&quot;last4&quot;,
		&quot;first4&quot;,
		&quot;authorlink4&quot;,
		&quot;last5&quot;,
		&quot;first5&quot;,
		&quot;authorlink5&quot;,
		&quot;last6&quot;,
		&quot;first6&quot;,
		&quot;authorlink6&quot;,
		&quot;last7&quot;,
		&quot;first7&quot;,
		&quot;authorlink7&quot;,
		&quot;last8&quot;,
		&quot;first8&quot;,
		&quot;authorlink8&quot;,
		&quot;last9&quot;,
		&quot;first9&quot;,
		&quot;authorlink9&quot;,
		&quot;authors&quot;,
		&quot;author-mask&quot;,
		&quot;author-name-separator&quot;,
		&quot;author-separator&quot;,
		&quot;display-authors&quot;,
		&quot;last-author-amp&quot;,
		&quot;date&quot;,
		&quot;year&quot;,
		&quot;orig-year&quot;,
		&quot;editor-last&quot;,
		&quot;editor-first&quot;,
		&quot;editor-link&quot;,
		&quot;editor2-last&quot;,
		&quot;editor2-first&quot;,
		&quot;editor2-link&quot;,
		&quot;editor3-last&quot;,
		&quot;editor3-first&quot;,
		&quot;editor3-link&quot;,
		&quot;editor4-last&quot;,
		&quot;editor4-first&quot;,
		&quot;editor4-link&quot;,
		&quot;editor5-last&quot;,
		&quot;editor5-first&quot;,
		&quot;editor5-link&quot;,
		&quot;editor6-last&quot;,
		&quot;editor6-first&quot;,
		&quot;editor6-link&quot;,
		&quot;editor7-last&quot;,
		&quot;editor7-first&quot;,
		&quot;editor7-link&quot;,
		&quot;editor8-last&quot;,
		&quot;editor8-first&quot;,
		&quot;editor8-link&quot;,
		&quot;editor9-last&quot;,
		&quot;editor9-first&quot;,
		&quot;editor9-link&quot;,
		&quot;others&quot;,
		&quot;title&quot;,
		&quot;script-title&quot;,
		&quot;trans-title&quot;,
		&quot;url&quot;,
		&quot;url-access&quot;,
		&quot;url-status&quot;,
		&quot;archive-url&quot;,
		&quot;archive-date&quot;,
		&quot;archive-format&quot;,
		&quot;accessdate&quot;,
		&quot;website&quot;,
		&quot;series&quot;,
		&quot;publisher&quot;,
		&quot;location&quot;,
		&quot;page&quot;,
		&quot;pages&quot;,
		&quot;at&quot;,
		&quot;language&quot;,
		&quot;type&quot;,
		&quot;format&quot;,
		&quot;publication-place&quot;,
		&quot;publication-date&quot;,
		&quot;via&quot;,
		&quot;nopp&quot;,
		&quot;arxiv&quot;,
		&quot;asin&quot;,
		&quot;asin-tld&quot;,
		&quot;bibcode&quot;,
		&quot;biorxiv&quot;,
		&quot;citeseerx&quot;,
		&quot;doi&quot;,
		&quot;doi-broken-date&quot;,
		&quot;isbn&quot;,
		&quot;issn&quot;,
		&quot;jfm&quot;,
		&quot;jstor&quot;,
		&quot;lccn&quot;,
		&quot;mr&quot;,
		&quot;oclc&quot;,
		&quot;ol&quot;,
		&quot;osti&quot;,
		&quot;pmc&quot;,
		&quot;pmid&quot;,
		&quot;rfc&quot;,
		&quot;ssrn&quot;,
		&quot;zbl&quot;,
		&quot;id&quot;,
		&quot;quote&quot;,
		&quot;ref&quot;,
		&quot;postscript&quot;,
		&quot;subscription&quot;,
		&quot;registration&quot;,
		&quot;separator&quot;,
		&quot;layurl&quot;,
		&quot;laysource&quot;,
		&quot;laydate&quot;,
		&quot;edition&quot;,
		&quot;bibcode-access&quot;,
		&quot;doi-access&quot;,
		&quot;hdl-access&quot;,
		&quot;jstor-access&quot;,
		&quot;ol-access&quot;,
		&quot;osti-access&quot;
	],
	&quot;format&quot;: &quot;inline&quot;
}
&lt;/templatedata&gt;</text>
      <sha1>rpi5u29nrbr5ddl79ycolb3mlsw3hti</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi asiqongelane:Revi C.</title>
    <ns>3</ns>
    <id>1208</id>
    <revision>
      <id>6759</id>
      <timestamp>2026-08-01T23:14:05Z</timestamp>
      <contributor>
        <username>Pathoschild</username>
        <id>130</id>
      </contributor>
      <comment>global user pages ([[m:Synchbot|requested by Revi C.]])</comment>
      <origin>6759</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1120" sha1="esxe13mcstpjlux1bt2hqwxr2v8t8mn" xml:space="preserve">__NOINDEX__&lt;div class=&quot;mw-content-ltr&quot; lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;[[File:Revi logo (pink).png|thumb|center|&lt;span style=&quot;color:red&quot;&gt;PLEASE DO NOT LEAVE MESSAGE HERE!&lt;/span&gt;]]

''' &lt;span style=&quot;color:red&quot;&gt; BEFORE YOU BLOCK MY ACCOUNT: IF MY EDIT SUMMARY INCLUDE PREFIX &lt;/span&gt;''(Script)''&lt;span style=&quot;color:red&quot;&gt;, DON'T BLOCK ME, JUST TELL ME TO SLOW DOWN AT COMMONS' TALK PAGE. IT IS AN AUTOMATED SCRIPT BEING USED ON COMMONS TO MOVE FILES.&lt;/span&gt;

Instead, please leave your message following site:
&lt;br /&gt;
[[File:Wikidata-logo-en.svg|45px|link=d:User talk:Revi C.]] [[d:User talk:Revi C.]] for Wikidata (Interwiki links) stuff &lt;!--(I am {{int:Group-sysop}} there)--&gt;
&lt;br /&gt;
[[File:Commons-logo.svg|45px|link=commons:User talk:Revi C.]] [[commons:User talk:Revi C.]] for renaming stuff or [[User:CommonsDelinker|CommonsDelinker]] action (I am {{int:Group-sysop}} there)
&lt;br /&gt;
[[File:Wikimedia Community Logo optimized.svg|45px|link=m:User talk:Revi C.]] [[meta:User talk:Revi C.]] for other stuff (User right notification, revert message, etc...)

Messages left on this page may be reverted or moved without any response.&lt;/div&gt;</text>
      <sha1>esxe13mcstpjlux1bt2hqwxr2v8t8mn</sha1>
    </revision>
    <revision>
      <id>6761</id>
      <parentid>6759</parentid>
      <timestamp>2026-08-02T14:25:59Z</timestamp>
      <contributor>
        <username>Pathoschild</username>
        <id>130</id>
      </contributor>
      <comment>global user pages ([[m:Synchbot|requested by Revi C.]])</comment>
      <origin>6761</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1122" sha1="5b8qtz4dnjnrhc9ts3mku14m3gujbq8" xml:space="preserve">__NOINDEX__&lt;div class=&quot;mw-content-ltr&quot; lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;[[File:Revi logo (pink).png|thumb|center|&lt;span style=&quot;color:red&quot;&gt;PLEASE DO NOT LEAVE MESSAGE HERE!&lt;/span&gt;]]

'''&lt;span style=&quot;color:red&quot;&gt; BEFORE YOU BLOCK MY ACCOUNT: IF MY EDIT SUMMARY INCLUDE PREFIX &lt;/span&gt;''(Script)''&lt;span style=&quot;color:red&quot;&gt;, DON'T BLOCK ME, JUST TELL ME TO SLOW DOWN AT COMMONS' TALK PAGE. IT IS AN AUTOMATED SCRIPT BEING USED ON COMMONS TO MOVE FILES.&lt;/span&gt;'''

Instead, please leave your message following site:
&lt;br /&gt;
[[File:Wikidata-logo-en.svg|45px|link=d:User talk:Revi C.]] [[d:User talk:Revi C.]] for Wikidata (Interwiki links) stuff &lt;!--(I am {{int:Group-sysop}} there)--&gt;
&lt;br /&gt;
[[File:Commons-logo.svg|45px|link=commons:User talk:Revi C.]] [[commons:User talk:Revi C.]] for renaming stuff or [[User:CommonsDelinker|CommonsDelinker]] action (I am {{int:Group-sysop}} there)
&lt;br /&gt;
[[File:Wikimedia Community Logo optimized.svg|45px|link=m:User talk:Revi C.]] [[meta:User talk:Revi C.]] for other stuff (User right notification, revert message, etc...)

Messages left on this page may be reverted or moved without any response.&lt;/div&gt;</text>
      <sha1>5b8qtz4dnjnrhc9ts3mku14m3gujbq8</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:Revi C.</title>
    <ns>2</ns>
    <id>1209</id>
    <revision>
      <id>6760</id>
      <timestamp>2026-08-01T23:54:52Z</timestamp>
      <contributor>
        <username>Pathoschild</username>
        <id>130</id>
      </contributor>
      <comment>global user pages ([[m:Synchbot|requested by Revi C.]])</comment>
      <origin>6760</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="728" sha1="kmhilvb55ib8ocgjmkmtd06hpatdlbt" xml:space="preserve">__NOINDEX__&lt;div class=&quot;mw-content-ltr&quot; lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;{{#babel:ko|en-3|nr-0}} [[File:Revi wikimedia image.jpg|thumb|center|middle|If you are here to talk about CommonsDelinker removing a deleted image, please [[:c:User talk:Revi C.|go here]].]]
Hello! I am [[:m:User:Revi C.|revi]]. I edit to [[m:SWMT|revert vandals]], do Wikidata stuff&lt;!--(I am a Wikidata Admin! &lt;small&gt;([{{fullurl:wikidata:Special:ListUsers/Revi C.|limit=1}} Verify])&lt;/small&gt;)--&gt;, or do [[:c:COM:FR|Commons Filemoving stuff]] (I am Commons Admin too! &lt;small&gt;([{{fullurl:c:Special:ListUsers/Revi C.|limit=1}} Verify])&lt;/small&gt;). Come to [[:m:User:Revi C.|my Meta userpage]] or [[:c:User:Revi C.|my Commons userpage]] for more information. Thank you.&lt;/div&gt;</text>
      <sha1>kmhilvb55ib8ocgjmkmtd06hpatdlbt</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi:-revi</title>
    <ns>2</ns>
    <id>1210</id>
    <redirect title="Umsebenzisi:Revi C." />
    <revision>
      <id>6762</id>
      <timestamp>2026-08-02T15:02:48Z</timestamp>
      <contributor>
        <username>Pathoschild</username>
        <id>130</id>
      </contributor>
      <comment>global user pages ([[m:Synchbot|requested by Revi C.]])</comment>
      <origin>6762</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="26" sha1="88g0cv17whfgb1wkeh281mptujwtlut" xml:space="preserve">#REDIRECT [[User:Revi C.]]</text>
      <sha1>88g0cv17whfgb1wkeh281mptujwtlut</sha1>
    </revision>
  </page>
  <page>
    <title>Umsebenzisi asiqongelane:-revi</title>
    <ns>3</ns>
    <id>1211</id>
    <redirect title="Umsebenzisi asiqongelane:Revi C." />
    <revision>
      <id>6763</id>
      <timestamp>2026-08-02T15:39:05Z</timestamp>
      <contributor>
        <username>Pathoschild</username>
        <id>130</id>
      </contributor>
      <comment>global user pages ([[m:Synchbot|requested by Revi C.]])</comment>
      <origin>6763</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="31" sha1="o9z79lcc9a9pfmqmrod5w3eyk4q9i0o" xml:space="preserve">#REDIRECT [[User talk:Revi C.]]</text>
      <sha1>o9z79lcc9a9pfmqmrod5w3eyk4q9i0o</sha1>
    </revision>
  </page>
  <page>
    <title>Ukutjhejwa kwe-AI</title>
    <ns>0</ns>
    <id>1213</id>
    <revision>
      <id>6768</id>
      <timestamp>2026-08-09T03:04:51Z</timestamp>
      <contributor>
        <username>Ndebalo</username>
        <id>1679</id>
      </contributor>
      <comment>Created page with &quot;[[File:Ai observability diagram.png|thumb|upright=1.5|I-telemetry ibuthelelwa emalayini amathathu wesistimu ye-AI (ingqalasizinda, imodeli, kanye nomphumela) begodu ihlanganiswe ngesendlalelo sokubonwa.]] '''Ukutjhejwa kwe-AI''' mkhuba wokubuthelela nokuhlaziya i-telemetry, idatha efana namalogi, amamethrikhi, kanye nemikhondo ihlelo elirekhoda ngokuzenzakalelako njengombana lisebenza, ukusuka eenhlelweni zobuhlakani bokwakha ezisetjenziswe ekukhiqizeni, ukwenzela bona k...&quot;</comment>
      <origin>6768</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1521" sha1="047vfffy8ug42t2zooll5bp4hy9brul" xml:space="preserve">[[File:Ai observability diagram.png|thumb|upright=1.5|I-telemetry ibuthelelwa emalayini amathathu wesistimu ye-AI (ingqalasizinda, imodeli, kanye nomphumela) begodu ihlanganiswe ngesendlalelo sokubonwa.]]
'''Ukutjhejwa kwe-AI''' mkhuba wokubuthelela nokuhlaziya i-telemetry, idatha efana namalogi, amamethrikhi, kanye nemikhondo ihlelo elirekhoda ngokuzenzakalelako njengombana lisebenza, ukusuka eenhlelweni zobuhlakani bokwakha ezisetjenziswe ekukhiqizeni, ukwenzela bona kuzwisiswe bona ziziphatha njani nokuthi zisebenza kuhle kangangani malungana nokunemba, iindleko, nokuphepha. Isebenzisa umqondo wokuqaphela, ovela ethiyori yokulawula nobunjiniyela behlelo, emahlelweni asekelwe kumamodeli wokufunda ngomtjhini, begodu khulukhulu kumamodeli welimi elikhulu (ama-LLM) nama-ejenti azijameleko. Ethiyori yokulawula, ukubonwa kulinganiso lokuthi ubujamo bangaphakathi besistimu bungatholwa kuhle kangangani ukusuka emiphumeleni yangaphandle.

Ukutjhejwa kwe-AI kuvamise ukuhlukaniswa nokutjheja okujayelekileko. Lapho ukutjheja kuthembele emamethrikhini ahlelwe ngaphambilini, imikhawulo, kanye neziyeleliso ukutjengisa bona umraro wenzeke, ukutjheja kuhlose ukunikela ngomongo owaneleko ukuzwisisa bona kubayini wenzeke. Umehluko lo uqakathekile eenhlelweni ze-AI khulukhulu, ngombana irherho lingabonakala liphilile ngeenlinganiso ezijayelekileko zesakhiwo, ezifana nokulibaziseka nofana izinga lephutha, ngesikhathi lisakhiqiza iimpendulo ezingakalungi, ezingakaqakatheki, nofana ezingaphephileko.

[[Category:AI]]</text>
      <sha1>047vfffy8ug42t2zooll5bp4hy9brul</sha1>
    </revision>
  </page>
  <page>
    <title>Mkhakha:Redirects connected to a Wikidata item</title>
    <ns>14</ns>
    <id>1214</id>
    <revision>
      <id>6774</id>
      <timestamp>2026-08-14T11:18:04Z</timestamp>
      <contributor>
        <username>PK2</username>
        <id>303</id>
      </contributor>
      <comment>Created blank page</comment>
      <origin>6774</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="0" sha1="phoiac9h4m842xq45sp7s6u21eteeq1" />
      <sha1>phoiac9h4m842xq45sp7s6u21eteeq1</sha1>
    </revision>
  </page>
  <page>
    <title>IKwekwezi FM</title>
    <ns>0</ns>
    <id>1215</id>
    <revision>
      <id>6777</id>
      <timestamp>2026-08-14T13:25:20Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <comment>Created page with &quot;[http://listen.ikwekwezifm.co.za/listenikwekwezifm/ IKwekwezi FM]mrhatjho wokuthoma wokurhatjha ngelimii lesiNdebele eSewula Afrika eyayazizwa nge Radio Ndebele.Yasungulwa ngomnyaka we-1983 kuSihlabantangana mhla amalanga amathathu.Yathonywa endaweni ye-Transvaal Region Studios on Minnar Street in Pretoria.Yathoma ukuduma khulu ngo mdlalo womoya obizwa &quot;Osemsamo Limphosa Emnyango.&lt;nowiki&gt;''&lt;/nowiki&gt;Eyatlolwa nguSkosana.Yahlala iminyaka&quot;</comment>
      <origin>6777</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="439" sha1="e78vt7zoqehua5ttk74hvr2z3sxkhny" xml:space="preserve">[http://listen.ikwekwezifm.co.za/listenikwekwezifm/ IKwekwezi FM]mrhatjho wokuthoma wokurhatjha ngelimii lesiNdebele eSewula Afrika eyayazizwa nge Radio Ndebele.Yasungulwa ngomnyaka we-1983 kuSihlabantangana mhla amalanga amathathu.Yathonywa endaweni ye-Transvaal Region Studios on Minnar Street in Pretoria.Yathoma ukuduma khulu ngo mdlalo womoya obizwa &quot;Osemsamo Limphosa Emnyango.&lt;nowiki&gt;''&lt;/nowiki&gt;Eyatlolwa nguSkosana.Yahlala iminyaka</text>
      <sha1>e78vt7zoqehua5ttk74hvr2z3sxkhny</sha1>
    </revision>
  </page>
  <page>
    <title>Elias Mokwana</title>
    <ns>0</ns>
    <id>1216</id>
    <revision>
      <id>6778</id>
      <timestamp>2026-08-14T13:33:15Z</timestamp>
      <contributor>
        <username>SandisiweMahlangu</username>
        <id>1620</id>
      </contributor>
      <comment>Created page with &quot;'''U-Elias Mokwana''' [https://e-s-tunis.com/ Taraji] imemezele bona, umdlali we[[:en:South_Africa|Sewula Afrika]] utlikitle isivumelwano sokudlalela isiqhema sabo iminyaka emithathu. Umdlali oneminyaka ema-25 uzibandakanya nesiqhema se-Esperence Sportive de Tuinis ubuya esiqhemeni esidlala e Sewula Afrika i-[https://sekhukhuneunitedfc.co.za/ Sekhukhune]. UMokwana udlale imidlalo emine negondelo elilodwa nesiqhema senarha i-Bafana Bafana.&lt;ref&gt;Mosaique Fm (''2024/08/01) E...&quot;</comment>
      <origin>6778</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="719" sha1="bqckt1p22mj2ply4lck6lhsjuaniw5w" xml:space="preserve">'''U-Elias Mokwana''' [https://e-s-tunis.com/ Taraji] imemezele bona, umdlali we[[:en:South_Africa|Sewula Afrika]] utlikitle isivumelwano sokudlalela isiqhema sabo iminyaka emithathu. Umdlali oneminyaka ema-25 uzibandakanya nesiqhema se-Esperence Sportive de Tuinis ubuya esiqhemeni esidlala e Sewula Afrika i-[https://sekhukhuneunitedfc.co.za/ Sekhukhune]. UMokwana udlale imidlalo emine negondelo elilodwa nesiqhema senarha i-Bafana Bafana.&lt;ref&gt;Mosaique Fm (''2024/08/01) Elias Mokwana signs for three seasons with EST.'' Retrieved at:[https://www.mosaiquefm.net/fr/mercato/1297931/elias-mokwana-s-engage-pour-trois-saisons-avec-l-est Elias Mokwana signs a three-year contract with EST | FM Mosaic]. 14/08/2026.&lt;/ref&gt;</text>
      <sha1>bqckt1p22mj2ply4lck6lhsjuaniw5w</sha1>
    </revision>
  </page>
  <page>
    <title>IKosikazi USekhothali Seeiso</title>
    <ns>0</ns>
    <id>1217</id>
    <revision>
      <id>6779</id>
      <timestamp>2026-08-14T13:34:40Z</timestamp>
      <contributor>
        <username>Emily Ndala</username>
        <id>1688</id>
      </contributor>
      <comment>Created page with &quot;'''IKosikazi YeNgwenyama Yombuso WamaNdebele.'''  '''U[https://www.bing.com/search?pglt=297&amp;q=Sekhothali+Seeiso&amp;cvid=caa1a2de849c4587b48eafa5b7d04079&amp;gs_lcrp=EgRlZGdlKgYIABBFGDkyBggAEEUYOTIGCAEQABhAMgYIAhAAGEDSAQkyNDYyOWowajeoAgCwAgA&amp;FORM=ANNTA1&amp;PC=HCTS&amp;source=chrome.ob Sekhothali]''' [https://www.bing.com/search?pglt=297&amp;q=Sekhothali+Seeiso&amp;cvid=caa1a2de849c4587b48eafa5b7d04079&amp;gs_lcrp=EgRlZGdlKgYIABBFGDkyBggAEEUYOTIGCAEQABhAMgYIAhAAGEDSAQkyNDYyOWowajeoAgCwAgA&amp;FORM=ANNT...&quot;</comment>
      <origin>6779</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1167" sha1="hf5p24u6is7p890coju6078fbfnc723" xml:space="preserve">'''IKosikazi YeNgwenyama Yombuso WamaNdebele.'''

'''U[https://www.bing.com/search?pglt=297&amp;q=Sekhothali+Seeiso&amp;cvid=caa1a2de849c4587b48eafa5b7d04079&amp;gs_lcrp=EgRlZGdlKgYIABBFGDkyBggAEEUYOTIGCAEQABhAMgYIAhAAGEDSAQkyNDYyOWowajeoAgCwAgA&amp;FORM=ANNTA1&amp;PC=HCTS&amp;source=chrome.ob Sekhothali]''' [https://www.bing.com/search?pglt=297&amp;q=Sekhothali+Seeiso&amp;cvid=caa1a2de849c4587b48eafa5b7d04079&amp;gs_lcrp=EgRlZGdlKgYIABBFGDkyBggAEEUYOTIGCAEQABhAMgYIAhAAGEDSAQkyNDYyOWowajeoAgCwAgA&amp;FORM=ANNTA1&amp;PC=HCTS&amp;source=chrome.ob Seeiso], oyiKosikazi yeNgwenyama Yombuso WamaNdebele,mumuntu ovelele emkhakheni wobulungiswa bobulili, uburholi babantu abatjha, kanye noburholi bendabuko. Unerhuluphelo lokulwela abafazi eendabeni ezimayelana namalungelo wezepilo, zomseme kanye nokubeletha. Ubenomthelela omkhulu ekulwisaneni neendaba zokutjhadiswa kwabantwana nokutlhorisana ngokobulili. Umsebenzi wakhe wokujamela amalungelo la usekelwa yikolelo yokobana amasiko kufanele atlhogomele, ahloniphe begodu avulele abantwana, abantu abatjha kanye nabomma amathuba .&lt;ref&gt;Sekhothali Seeiso (2026) retrieved from :[https://sekhothaliseeiso.com/ HRH Sekhothali Seeiso | Biography]. 14 August 2026.&lt;/ref&gt;</text>
      <sha1>hf5p24u6is7p890coju6078fbfnc723</sha1>
    </revision>
    <revision>
      <id>6785</id>
      <parentid>6779</parentid>
      <timestamp>2026-08-15T07:48:06Z</timestamp>
      <contributor>
        <username>Emily Ndala</username>
        <id>1688</id>
      </contributor>
      <minor />
      <origin>6785</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="2047" sha1="gvxdy21i1dqhmh1aztab8kpfy06yaga" xml:space="preserve">'''IKosikazi YeNgwenyama Yombuso WamaNdebele.'''

'''U[https://www.bing.com/search?pglt=297&amp;q=Sekhothali+Seeiso&amp;cvid=caa1a2de849c4587b48eafa5b7d04079&amp;gs_lcrp=EgRlZGdlKgYIABBFGDkyBggAEEUYOTIGCAEQABhAMgYIAhAAGEDSAQkyNDYyOWowajeoAgCwAgA&amp;FORM=ANNTA1&amp;PC=HCTS&amp;source=chrome.ob Sekhothali]''' [https://www.bing.com/search?pglt=297&amp;q=Sekhothali+Seeiso&amp;cvid=caa1a2de849c4587b48eafa5b7d04079&amp;gs_lcrp=EgRlZGdlKgYIABBFGDkyBggAEEUYOTIGCAEQABhAMgYIAhAAGEDSAQkyNDYyOWowajeoAgCwAgA&amp;FORM=ANNTA1&amp;PC=HCTS&amp;source=chrome.ob Seeiso], oyiKosikazi yeNgwenyama Yombuso WamaNdebele, mumuntu ovelele emkhakheni wobulungiswa bobulili, uburholi babantu abatjha, kanye noburholi bendabuko. Unerhuluphelo lokulwela abafazi eendabeni ezimayelana namalungelo wezepilo, zomseme kanye nokubeletha. Ubenomthelela omkhulu ekulwisaneni neendaba zokutjhadiswa kwabantwana nokutlhorisana ngokobulili. Umsebenzi wakhe wokujamela amalungelo la usekelwa yikolelo yokobana amasiko kufanele atlhogomele, ahloniphe begodu avulele abantwana, abantu abatjha kanye nabomma amathuba.

Ungomunye wabahlangana namahlelo neminyanya ehlukahlukeneko eqakathekileko, kanye namahlelo woburholi bomphakathi. Lokho ukwenza ngehloso yokwakha isithunzi, ukufumana amathuba nokwenza isiqiniseko sokobana ifundo yinto ejayelekileko kiwo woke umuntu.&lt;ref&gt;Sekhothali Seeiso (2026) retrieved from :[https://sekhothaliseeiso.com/ HRH Sekhothali Seeiso | Biography]. 14 August 2026.&lt;/ref&gt;

USekhothali Seeiso ulilunga le-United Nations Women Africa,&lt;ref&gt;United Nations Women Africa,&lt;/ref&gt; lapho asebenza khona ekuqedeni ukutjhadiswa kwabanatwana kanye ne-FMG. Ubuyelela abe mjameli wamalungelo wezepilo nezomseme i-HealthSexual Reproductive Rights.&lt;ref&gt;&lt;nowiki&gt;https://www.bing.com/ck/a?!&amp;&amp;p=a78a26543f6a3ec778dcb5c6be545c780b2fb0f5be1a6a0d9336b157ef27483eJmltdHM9MTc4Njc1MjAwMA&amp;ptn=3&amp;ver=2&amp;hsh=4&amp;fclid=37f02764-6a65-6373-2c7c-342f6b4662f2&amp;psq=Sexual+Reproductive+Health+and+Rights&amp;u=a1aHR0cHM6Ly93d3cud2hvLmludC9oZWFsdGgtdG9waWNzL3NleHVhbC1hbmQtcmVwcm9kdWN0aXZlLWhlYWx0aC1hbmQtcmlnaHRz&lt;/nowiki&gt;&lt;/ref&gt;&lt;references /&gt;</text>
      <sha1>gvxdy21i1dqhmh1aztab8kpfy06yaga</sha1>
    </revision>
    <revision>
      <id>6795</id>
      <parentid>6785</parentid>
      <timestamp>2026-08-19T10:44:28Z</timestamp>
      <contributor>
        <username>Emily Ndala</username>
        <id>1688</id>
      </contributor>
      <comment>I removed a link reference that is not wanted.</comment>
      <origin>6795</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1694" sha1="2xss8452mfws75vcy44sysrtv4itqqj" xml:space="preserve">'''IKosikazi YeNgwenyama Yombuso WamaNdebele.'''

'''U[https://www.bing.com/search?pglt=297&amp;q=Sekhothali+Seeiso&amp;cvid=caa1a2de849c4587b48eafa5b7d04079&amp;gs_lcrp=EgRlZGdlKgYIABBFGDkyBggAEEUYOTIGCAEQABhAMgYIAhAAGEDSAQkyNDYyOWowajeoAgCwAgA&amp;FORM=ANNTA1&amp;PC=HCTS&amp;source=chrome.ob Sekhothali]''' [https://www.bing.com/search?pglt=297&amp;q=Sekhothali+Seeiso&amp;cvid=caa1a2de849c4587b48eafa5b7d04079&amp;gs_lcrp=EgRlZGdlKgYIABBFGDkyBggAEEUYOTIGCAEQABhAMgYIAhAAGEDSAQkyNDYyOWowajeoAgCwAgA&amp;FORM=ANNTA1&amp;PC=HCTS&amp;source=chrome.ob Seeiso], oyiKosikazi yeNgwenyama Yombuso WamaNdebele, mumuntu ovelele emkhakheni wobulungiswa bobulili, uburholi babantu abatjha, kanye noburholi bendabuko. Unerhuluphelo lokulwela abafazi eendabeni ezimayelana namalungelo wezepilo, zomseme kanye nokubeletha. Ubenomthelela omkhulu ekulwisaneni neendaba zokutjhadiswa kwabantwana nokutlhorisana ngokobulili. Umsebenzi wakhe wokujamela amalungelo la usekelwa yikolelo yokobana amasiko kufanele atlhogomele, ahloniphe begodu avulele abantwana, abantu abatjha kanye nabomma amathuba.

Ungomunye wabahlangana namahlelo neminyanya ehlukahlukeneko eqakathekileko, kanye namahlelo woburholi bomphakathi. Lokho ukwenza ngehloso yokwakha isithunzi, ukufumana amathuba nokwenza isiqiniseko sokobana ifundo yinto ejayelekileko kiwo woke umuntu.&lt;ref&gt;Sekhothali Seeiso (2026) retrieved from :[https://sekhothaliseeiso.com/ HRH Sekhothali Seeiso | Biography]. 14 August 2026.&lt;/ref&gt;

USekhothali Seeiso ulilunga le-United Nations Women Africa,&lt;ref&gt;United Nations Women Africa,&lt;/ref&gt; lapho asebenza khona ekuqedeni ukutjhadiswa kwabanatwana kanye ne-FMG. Ubuyelela abe mjameli wamalungelo wezepilo nezomseme i-HealthSexual Reproductive Rights.&lt;references /&gt;</text>
      <sha1>2xss8452mfws75vcy44sysrtv4itqqj</sha1>
    </revision>
    <revision>
      <id>6796</id>
      <parentid>6795</parentid>
      <timestamp>2026-08-19T10:58:35Z</timestamp>
      <contributor>
        <username>Emily Ndala</username>
        <id>1688</id>
      </contributor>
      <comment>I added an image.</comment>
      <origin>6796</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1748" sha1="jju2j6q6g00697u710dzqdzxap3lhq1" xml:space="preserve">[[Isimumathi:Sekhothali.jpg|thumb|Sekhothali Seeiso]]
'''IKosikazi YeNgwenyama Yombuso WamaNdebele.'''

'''U[https://www.bing.com/search?pglt=297&amp;q=Sekhothali+Seeiso&amp;cvid=caa1a2de849c4587b48eafa5b7d04079&amp;gs_lcrp=EgRlZGdlKgYIABBFGDkyBggAEEUYOTIGCAEQABhAMgYIAhAAGEDSAQkyNDYyOWowajeoAgCwAgA&amp;FORM=ANNTA1&amp;PC=HCTS&amp;source=chrome.ob Sekhothali]''' [https://www.bing.com/search?pglt=297&amp;q=Sekhothali+Seeiso&amp;cvid=caa1a2de849c4587b48eafa5b7d04079&amp;gs_lcrp=EgRlZGdlKgYIABBFGDkyBggAEEUYOTIGCAEQABhAMgYIAhAAGEDSAQkyNDYyOWowajeoAgCwAgA&amp;FORM=ANNTA1&amp;PC=HCTS&amp;source=chrome.ob Seeiso], oyiKosikazi yeNgwenyama Yombuso WamaNdebele, mumuntu ovelele emkhakheni wobulungiswa bobulili, uburholi babantu abatjha, kanye noburholi bendabuko. Unerhuluphelo lokulwela abafazi eendabeni ezimayelana namalungelo wezepilo, zomseme kanye nokubeletha. Ubenomthelela omkhulu ekulwisaneni neendaba zokutjhadiswa kwabantwana nokutlhorisana ngokobulili. Umsebenzi wakhe wokujamela amalungelo la usekelwa yikolelo yokobana amasiko kufanele atlhogomele, ahloniphe begodu avulele abantwana, abantu abatjha kanye nabomma amathuba.

Ungomunye wabahlangana namahlelo neminyanya ehlukahlukeneko eqakathekileko, kanye namahlelo woburholi bomphakathi. Lokho ukwenza ngehloso yokwakha isithunzi, ukufumana amathuba nokwenza isiqiniseko sokobana ifundo yinto ejayelekileko kiwo woke umuntu.&lt;ref&gt;Sekhothali Seeiso (2026) retrieved from :[https://sekhothaliseeiso.com/ HRH Sekhothali Seeiso | Biography]. 14 August 2026.&lt;/ref&gt;

USekhothali Seeiso ulilunga le-United Nations Women Africa,&lt;ref&gt;United Nations Women Africa,&lt;/ref&gt; lapho asebenza khona ekuqedeni ukutjhadiswa kwabanatwana kanye ne-FMG. Ubuyelela abe mjameli wamalungelo wezepilo nezomseme i-HealthSexual Reproductive Rights.&lt;references /&gt;</text>
      <sha1>jju2j6q6g00697u710dzqdzxap3lhq1</sha1>
    </revision>
  </page>
  <page>
    <title>U-Joe Sibanyoni</title>
    <ns>0</ns>
    <id>1218</id>
    <revision>
      <id>6780</id>
      <timestamp>2026-08-14T19:45:15Z</timestamp>
      <contributor>
        <username>Onica359</username>
        <id>1686</id>
      </contributor>
      <comment>Created page with &quot;'''U-Joe Sibanyoni''' [[Joe Sibanyoni]],unikelwe isaziso esaziwa ngokobana yi-Rule 10.6 Notice,esimbawa bona ayokuphendula imibuzo emayelana namacala asarhujululwa yiKometjheni iMadlanga.Umjameli kaSibanyoni uqinisekisile kobana usitholile isaziso,kodwana akhange avume ukukhuluma ngaso. Imibuzo alindeleke bona ayiphendule le imayelana neenqhema zeenlelesi ezinamarhwebo angasi semthethweni.Yeke-ke,iKometjheni isaraga ngerhubhululo ngeenqhemezi namapholisa ezikhamba nawo....&quot;</comment>
      <origin>6780</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="591" sha1="psbibahgxb6iz6i7ijqs8c0zsh1e4aq" xml:space="preserve">'''U-Joe Sibanyoni''' [[Joe Sibanyoni]],unikelwe isaziso esaziwa ngokobana yi-Rule 10.6 Notice,esimbawa bona ayokuphendula imibuzo emayelana namacala asarhujululwa yiKometjheni iMadlanga.Umjameli kaSibanyoni uqinisekisile kobana usitholile isaziso,kodwana akhange avume ukukhuluma ngaso. Imibuzo alindeleke bona ayiphendule le imayelana neenqhema zeenlelesi ezinamarhwebo angasi semthethweni.Yeke-ke,iKometjheni isaraga ngerhubhululo ngeenqhemezi namapholisa ezikhamba nawo. Sele kunabafakazi abafuna ukufakana ngemsitheleni ngendaba kaSibanyoni. https://www.sabcnews.com/sabcnews/1151649-2/</text>
      <sha1>psbibahgxb6iz6i7ijqs8c0zsh1e4aq</sha1>
    </revision>
  </page>
  <page>
    <title>I-R573</title>
    <ns>0</ns>
    <id>1219</id>
    <revision>
      <id>6781</id>
      <timestamp>2026-08-15T07:27:09Z</timestamp>
      <contributor>
        <username>Bongz007</username>
        <id>1689</id>
      </contributor>
      <comment>Citations</comment>
      <origin>6781</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="637" sha1="qisuj4nvl1ur2gus86yflk36frxfqum" xml:space="preserve">I-R573 (INDLELA YEMLOTO)

'''Indlela''' I'''-'''R573 eyaziwa khulu ngokuthi yindlela yeMloto ithoma ngepumalanga yedorobha lePitori &lt;ref&gt;https://en.wikipedia.org/wiki/Pretoria&lt;/ref&gt;idlule hlanu kwendawo eziningi kwaNdebele &lt;ref&gt;https://en.wikipedia.org/wiki/KwaNdebele&lt;/ref&gt;iyokuphelela ngedorobheni leMarble Hall&lt;ref&gt;https://en.wikipedia.org/wiki/R573_(South_Africa)&lt;/ref&gt;&lt;ref&gt;https://en.wikipedia.org/wiki/Marble_Hall&lt;/ref&gt;. Indlela le yaziwa ngezingozı zendlela eziningi khulu ngokukuya ngembalobalo nayimadaniswa nezinye iindlela.&lt;ref&gt;https://www.cartrack.co.za/blog/the-most-dangerous-roads-in-the-world-and-how-to-avoid-them&lt;/ref&gt;</text>
      <sha1>qisuj4nvl1ur2gus86yflk36frxfqum</sha1>
    </revision>
    <revision>
      <id>6787</id>
      <parentid>6781</parentid>
      <timestamp>2026-08-15T08:00:10Z</timestamp>
      <contributor>
        <username>Bongz007</username>
        <id>1689</id>
      </contributor>
      <comment>Spelling</comment>
      <origin>6787</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="643" sha1="nb4jvgzf0vlcxuci1uiwdbbs7lywl9x" xml:space="preserve">'''I-R573 (INDLELA YEMLOTO)'''

'''Indlela''' I'''-'''R573 eyaziwa khulu ngokuthi yindlela yeMloto ithoma ngepumalanga yedorobha lePitori &lt;ref&gt;https://en.wikipedia.org/wiki/Pretoria&lt;/ref&gt;idlule hlanu kwezindawo ezinengi kwaNdebele &lt;ref&gt;https://en.wikipedia.org/wiki/KwaNdebele&lt;/ref&gt;iyokuphelela ngedorobheni leMarble Hall&lt;ref&gt;https://en.wikipedia.org/wiki/R573_(South_Africa)&lt;/ref&gt;&lt;ref&gt;https://en.wikipedia.org/wiki/Marble_Hall&lt;/ref&gt;. Indlela le yaziwa ngezingozı zendlela eziningi khulu ngokuya ngembalobalo nayimadaniswa nezinye iindlela.&lt;ref&gt;https://www.cartrack.co.za/blog/the-most-dangerous-roads-in-the-world-and-how-to-avoid-them&lt;/ref&gt;</text>
      <sha1>nb4jvgzf0vlcxuci1uiwdbbs7lywl9x</sha1>
    </revision>
    <revision>
      <id>6793</id>
      <parentid>6787</parentid>
      <timestamp>2026-08-15T11:02:36Z</timestamp>
      <contributor>
        <username>Bongz007</username>
        <id>1689</id>
      </contributor>
      <comment>Picture</comment>
      <origin>6793</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="750" sha1="5yvwwhshk90x2kif3gbu34icmqfm6u5" xml:space="preserve">[[Isimumathi:KwaMhlanga, R573-R568-kruising, Mpumalanga.jpg|thumb|R573 Moloto Road (KwaMhlanga Crossing)]]
'''I-R573 (INDLELA YEMLOTO)'''

'''Indlela''' I'''-'''R573 eyaziwa khulu ngokuthi yindlela yeMloto ithoma ngepumalanga yedorobha lePitori &lt;ref&gt;https://en.wikipedia.org/wiki/Pretoria&lt;/ref&gt;idlule hlanu kwezindawo ezinengi kwaNdebele &lt;ref&gt;https://en.wikipedia.org/wiki/KwaNdebele&lt;/ref&gt;iyokuphelela ngedorobheni leMarble Hall&lt;ref&gt;https://en.wikipedia.org/wiki/R573_(South_Africa)&lt;/ref&gt;&lt;ref&gt;https://en.wikipedia.org/wiki/Marble_Hall&lt;/ref&gt;. Indlela le yaziwa ngezingozı zendlela eziningi khulu ngokuya ngembalobalo nayimadaniswa nezinye iindlela.&lt;ref&gt;https://www.cartrack.co.za/blog/the-most-dangerous-roads-in-the-world-and-how-to-avoid-them&lt;/ref&gt;</text>
      <sha1>5yvwwhshk90x2kif3gbu34icmqfm6u5</sha1>
    </revision>
  </page>
  <page>
    <title>INgwenyama uMahlangu</title>
    <ns>0</ns>
    <id>1220</id>
    <revision>
      <id>6782</id>
      <timestamp>2026-08-15T07:31:39Z</timestamp>
      <contributor>
        <username>Ngcobile7</username>
        <id>1691</id>
      </contributor>
      <comment>I made a profile of King Mahlangu who ruled amaNdzundza in the 1700s</comment>
      <origin>6782</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1347" sha1="kgv1ptuvrl3nbs5fz82u0lrdo8dhvkm" xml:space="preserve">INgwenyama uMahlangu kaBongwe wabusela kwaMaza [[:en:Belfast,_Mpumalanga|eBelfast]], ngemva kokubanjelwa &lt;ref name=&quot;:0&quot;&gt;Makhosini Mahlangu, IGugu lamaNdzundza. 2024. https://www.academia.edu/121981629/BRIEF_HISTORY_OF_THE_NDEBELE_NDZUNDZA_NATION?email_work_card=title. 15/08/2026&lt;/ref&gt;

ngu Sindeni kaMrhetjha. uSindeni wabusa uMahlangu bekangakaphethi isiko lokuya &lt;ref name=&quot;:0&quot; /&gt;

ngengomeni. UMahlangu wabona ukuthi ubukhosi buzokuginywa yindlu kaSindeni, 

wabalekela engomeni yabesuthu ukuthi aqede isiko akghone ukubusa ubukhosi 

bukayise. Ngikho imbongi nayibongelela uMahlangu ithi “Yingwe yakonomazumani, 

ngeyazuma imini nobusuku, ingazumi nyamazana yayizum’ ubuntu”, lokhu kuveza 

isikhathi uMahlangu afuna ingoma yabesuthu, ibuyelele imbongi ithi “NguSnghalela 

kube [[SeSotho|Sotho]] abanye banghalela ebukhobongweni”, okuveza bona wanghalela 

engomeni yabeSotho. 

Uthe nakabuya engomeni uMahlangu, waya ngesigodlweni kuSindeni, wathi 

“bamkhulu sengikhulile, sengiyakghona ukujamela ubukhosi bukababa”. uSindeni 

khange abhale nobukhosi, bamnikeza ubuNgwenyama bakhe uMahlangu, &lt;ref name=&quot;:0&quot; /&gt;

owayesele abizwa ngoSnghalela. Kwathoma lapho ukuthi isitjhaba samaNdzundza &lt;ref name=&quot;:0&quot; /&gt;

siwisele ingoma nabeSotho

INgwenyama uMahlangu ibeletha naba abalandelako:

* Marhotjha
* Mgwezana
* Dzela
* Bungela</text>
      <sha1>kgv1ptuvrl3nbs5fz82u0lrdo8dhvkm</sha1>
    </revision>
    <revision>
      <id>6786</id>
      <parentid>6782</parentid>
      <timestamp>2026-08-15T07:59:09Z</timestamp>
      <contributor>
        <username>Ngcobile7</username>
        <id>1691</id>
      </contributor>
      <minor />
      <comment>Added to the kids of the King</comment>
      <origin>6786</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="1364" sha1="g8ozkydn5g612hra3i3uuatph9fdf2c" xml:space="preserve">'''INgwenyama uMahlangu''' kaBongwe wabusela kwaMaza [[:en:Belfast,_Mpumalanga|eBelfast]], ngemva kokubanjelwa &lt;ref name=&quot;:0&quot;&gt;Makhosini Mahlangu, IGugu lamaNdzundza. 2024. https://www.academia.edu/121981629/BRIEF_HISTORY_OF_THE_NDEBELE_NDZUNDZA_NATION?email_work_card=title. 15/08/2026&lt;/ref&gt;

ngu Sindeni kaMrhetjha. uSindeni wabusa uMahlangu bekangakaphethi isiko lokuya &lt;ref name=&quot;:0&quot; /&gt;

ngengomeni. UMahlangu wabona ukuthi ubukhosi buzokuginywa yindlu kaSindeni, 

wabalekela engomeni yabesuthu ukuthi aqede isiko akghone ukubusa ubukhosi 

bukayise. Ngikho imbongi nayibongelela uMahlangu ithi “Yingwe yakonomazumani, 

ngeyazuma imini nobusuku, ingazumi nyamazana yayizum’ ubuntu”, lokhu kuveza 

isikhathi uMahlangu afuna ingoma yabesuthu, ibuyelele imbongi ithi “NguSnghalela 

kube [[SeSotho|Sotho]] abanye banghalela ebukhobongweni”, okuveza bona wanghalela 

engomeni yabeSotho. 

Uthe nakabuya engomeni uMahlangu, waya ngesigodlweni kuSindeni, wathi 

“bamkhulu sengikhulile, sengiyakghona ukujamela ubukhosi bukababa”. uSindeni 

khange abhale nobukhosi, bamnikeza ubuNgwenyama bakhe uMahlangu, &lt;ref name=&quot;:0&quot; /&gt;

owayesele abizwa ngoSnghalela. Kwathoma lapho ukuthi isitjhaba samaNdzundza &lt;ref name=&quot;:0&quot; /&gt;

siwisele ingoma nabeSotho

INgwenyama uMahlangu ibeletha naba abalandelako:

* Marhotjha
* Mgwezana
* Dzela
* Bungela
* Phaswana</text>
      <sha1>g8ozkydn5g612hra3i3uuatph9fdf2c</sha1>
    </revision>
  </page>
  <page>
    <title>Ukuhlukumezeka Kwabobaba</title>
    <ns>0</ns>
    <id>1221</id>
    <revision>
      <id>6783</id>
      <timestamp>2026-08-15T07:36:42Z</timestamp>
      <contributor>
        <username>Andries Solly Skhosana</username>
        <id>1624</id>
      </contributor>
      <comment>Kumayelana nokuhlukumezeka kwabobaba eSewula Afrika.</comment>
      <origin>6783</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="349" sha1="36mqf1z85c38xur2oe49bkafbihjiu7" xml:space="preserve">'''Ukuhlukunyezwa kwabobaba''' [[:en:South_Africa|e-Afrika]] zombelele kubandakanya ukuhlukunyezwa ngokwengqondo kanye nangokwenyama, okufakahlangana ukuthidlhwa nokuphudlhelwa. Kanengi-ke abongazimbi kuba bobaba abatjhadileko nabasebudlelwaneni nabantu bengubo.&lt;ref&gt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Domestic_violence_against_men&lt;/nowiki&gt;&lt;/ref&gt;</text>
      <sha1>36mqf1z85c38xur2oe49bkafbihjiu7</sha1>
    </revision>
    <revision>
      <id>6794</id>
      <parentid>6783</parentid>
      <timestamp>2026-08-15T11:06:16Z</timestamp>
      <contributor>
        <username>Lungile M. Mabhena</username>
        <id>585</id>
      </contributor>
      <minor />
      <comment>I have just inserted the image.</comment>
      <origin>6794</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="433" sha1="gfzgrmwl4mpltssk6k0w4xhnrrqt0rq" xml:space="preserve">[[Isimumathi:Abu Ghraib prison abuse.jpg|thumb|426x426px|Ukuhlukumezeka Kwabobaba]]
'''Ukuhlukunyezwa kwabobaba''' [[:en:South_Africa|e-Afrika]] zombelele kubandakanya ukuhlukunyezwa ngokwengqondo kanye nangokwenyama, okufakahlangana ukuthidlhwa nokuphudlhelwa. Kanengi-ke abongazimbi kuba bobaba abatjhadileko nabasebudlelwaneni nabantu bengubo.&lt;ref&gt;&lt;nowiki&gt;https://en.wikipedia.org/wiki/Domestic_violence_against_men&lt;/nowiki&gt;&lt;/ref&gt;</text>
      <sha1>gfzgrmwl4mpltssk6k0w4xhnrrqt0rq</sha1>
    </revision>
  </page>
  <page>
    <title>Maphotla</title>
    <ns>0</ns>
    <id>1222</id>
    <revision>
      <id>6784</id>
      <timestamp>2026-08-15T07:47:47Z</timestamp>
      <contributor>
        <username>Mondli Sandile</username>
        <id>1690</id>
      </contributor>
      <comment>New Article</comment>
      <origin>6784</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="840" sha1="dgutksgxp11giycsnwemghjdsmbf6g6" xml:space="preserve">kuyindawo ehle, ekarisako lapha uthi nawufuna umoya opholileko wemvelo uzakufumana ihlathi elizele ngotjani obuhlaza khulu. IMaphotla Idume khulu kezinye iindawo ngezinto ezinengi. IMaphotla itholakala ngesifundeni sange Mpumalanga, ngakuMasipalada wange dr.js Moroka begudu kuyindawo ethulileko. Isintu sisahlonitjhwa lapha, kezinye iindawo nabalila ngesiko labo elithunyazweko, ngakilena indawo khona baziledlhele ngombana isiko lisaziwa njengento ekulu.&lt;ref&gt;&lt;nowiki&gt;https://share.google/T7d0BFuyXML0PHodM.15August2026&lt;/nowiki&gt;&lt;/ref&gt;

Indawo le izele ngeenkutani ezisaphilako nezingasekho. UMawaza Kabini owaziwa ngo Bhoro Matjhini emdlaweni azitlolele wona, ungomunye weenkuni zalindawo lena. UMawaza Kabini lo ungusomahlaya begodu umrhatjhi kwa-Kwekwezi FM.&lt;ref&gt;&lt;nowiki&gt;https://share.google/xfEMY87xgkQKpsZbp.15August2026&lt;/nowiki&gt;&lt;/ref&gt;</text>
      <sha1>dgutksgxp11giycsnwemghjdsmbf6g6</sha1>
    </revision>
  </page>
  <page>
    <title>Imali kufanele yehle</title>
    <ns>0</ns>
    <id>1223</id>
    <revision>
      <id>6788</id>
      <timestamp>2026-08-15T10:00:00Z</timestamp>
      <contributor>
        <username>SandisiweMahlangu</username>
        <id>1620</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1361103016|FeesMustFall]]&quot;</comment>
      <origin>6788</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="4559" sha1="hpv96gwh1gzjb6nc7o6u9ukmmawoj8a" xml:space="preserve">
 

Nanyana umnqopho umguruguru lo bewudzimelele ekukhuphukeni kweembadelo, kunezinto ezinengi ezakha isizinda semibhikisho evela ekutlhogekeni kwemali yabafundi abatlhagako ukobana baye eyunivesithi, imali ephezulu engenako yabaphathi beyunivesithi,  ukwehla kwamambala kwemali karhulumende yefundo ephakemeko,  ukutlhogeka kokutjhuguluka kwezehlalakuhle, ukuya eendabeni ezibalulekileko zomnotho nezomnotho. 

Umsekeli we-Chancellor weYunivesithi ye-Witwatersrand u-Adam Habib ulinganisele bona nangabe urhulumende anganikela nge-R80&amp;nbsp;amabhiliyoni ngonyaka &quot;okuzokubhadela imali yokufunda yawo woke umfundi kiwo woke amayunivesithi enarheni le.&quot;  ISewula Afrika isebenzisa i-0.75% ye-GDP yayo emfundweni ephakemeko engaphasi kwesilinganiso se-Afrika nofana sephasi loke. 

Iinhlangano zathonywa begodu zadoselwa phambili mdosiphambili we-SRC weYunivesithi ye-Witwatersrand yango-2015, u-Shaeera Kalla. &lt;sup class=&quot;noprint Inline-Template Template-Fact&quot; style=&quot;white-space:nowrap;&quot;&gt;&amp;#x5B; ''&lt;nowiki&gt;&lt;span title=&quot;This claim needs references to reliable sources. (August 2021)&quot;&gt;citation needed&lt;/span&gt;&lt;/nowiki&gt;'' &amp;#x5D;&lt;/sup&gt; Mhla amalanga amabili kuNobayeni u-Kalla waya emhlanganweni wakhe wokugcina womkhandlu njengomengameli we-SRC, uphelekezelwa ngumongameli okhethiweko we-SRC, u-Nompendulo Mkhatshwa. 

== Isikhathi saka-2015 ==

=== 12-19 kuSewula ===
Abafundi beYunivesithi ye-Witwatersrand bathoma ukutjhagala mhlana ali-14 kuNobayeni 2015 ukuphendula isimemezelo seyunivesithi sokuthi iindleko zizokukhuphulwa nge-10.5%.  Lokhu kwadosela ekutheni abafundi nabanye abasebenzi bavale iyunivesithi, mhla amalanga ali-17 kuSewula, kwabangela bona iyunivesithi ivume ukujamisa ukukhutjhulwela kwemali begodu ikhulumisane ngakho godu begodu ingafuni ukuthathelwa amagadango wokujezisa abafundi ababandakanyekako namkha amalunga wabasebenzi. 

Ngo Sondo mhla amalanga ali-18 kuSewula imilayezo yathoma ukujikajika ku-Facebook malungana nokuvalwa okupheleleko kwekhampasi ye-Rhodes University.

=== 19 KuSewula ===
NgoMvulo mhla ali-19 kuNobayeni iinkulumo ezitjha hlangana nabafundi neyunivesithi besele zithomile.  Ngelanga elifanako lokutjhagala efanako yasabalala eYunivesithi yeKapa neYunivesithi ye-Rhodes.  Ngelanga elifanako abaphathi beYunivesithi yeKapa -ebegade bamemezele ukukhutjhulwa kwemali nge-10.3% ngeveke eyadlulako- bafaka isibawo begodu bathola isivumelwano ekhotho ukukhandela ukutjhikiyela eyunivesithi. Abafundi bathoma ukuvimba ukungena kweenkoloyi ngokubeka amatje, imigqomu yeenzibi, neenhlalo eendleleni eya ekhampasini. 

Abafundi baragela phambili ukudosa abantu be -Rhodes Must Fall bahlala esakhiweni sokuphatha seyunivesithi.  Amapholisa wezokutjhagala abizwa bona akhuphe ngamandla abatjhagali begodu abafundi abangaphezu kweminyaka ema-25 babotjhwa ebusuku khulu. Kubikwa bona abafundi abangaphezu kwenkulungwana babuthana esitetjhini samapholisa se-Rondebosch begodu bajama ngaphandle ubusuku boke bafuna ukutjhatjhululwa kwabafundi. 

EYunivesithi ye-Rhodes abafundi kuthiwa bathoma ukuzivalela bona bangene eyunivesithi begodu bakhandela abanye bona bangangeni ekhempasini. Abafundi beYunivesithi ye-Pitoli kubikwa bona bathome amahlelo wokuvala amakhempasi amathathu weyunivesithi leyo ngoLosithathu mhla amalanga-21 kuSewula. 

=== 20 KuSewula ===
[[Isimumathi:Second_day_of_the_FeesMustFall_protests_at_the_University_of_Cape_Town_04.JPG|thumb| Abafundi beYunivesithi ye-Cape Town batjhagala baya esitetjhini samapholisa sendawo ngoLosibili mhla  amalanga ali-20 kuNobayeni 2015 ukuyokufuna ukutjhaphululwa kwabanye abafundi ababotjhwe ebusuku bangaphambilini.]]
NgeLesibili mhla amalanga ali-20 kuNobayeni abafundi babuthana eYunivesithi ye-Cape Town begodu batjhinga esitetjhini samapholisa sendawo ukuyokufuna bona abafundi ebebaboshwe ebusuku bangaphambilini batjhaphululwe. Abafundi be -Cape Peninsula University of Technology bathoma ukutjhagala begodu bavala ikhampasi. E- Fort Hare University abafundi nabo bathoma ukutjhagala nokuvala ikhampasi. Bala ukurhatjheka nofana ukutlola iinhlahlubo bekwaba kulapho abaphathi beyunivesithi baqalana nokutshwenyeka ngokukhuphulwa kwemali kanye neendaba zekohlakalo.  Abafundi beYunivesithi ye-Stellenbosch banikeze imemorandamu yeenlilo kibaphathi beyunivesithi baveza iinghonghoyilo zabo ngesikhathi abafundi beYunivesithi ye-Rhodes baragela phambili nokutjhagala kwabo.  E-Yunivesithi ye-Witwatersrand abafundi bala isivumelwano esiphakanyiswe yiyunivesithi soku ukunyuselwa kwemali ku-6% begodu esikhundleni salokho bafuna bona kungabi nokukhuphulwa kwemali.</text>
      <sha1>hpv96gwh1gzjb6nc7o6u9ukmmawoj8a</sha1>
    </revision>
  </page>
  <page>
    <title>Ekangala</title>
    <ns>0</ns>
    <id>1224</id>
    <revision>
      <id>6789</id>
      <timestamp>2026-08-15T10:01:08Z</timestamp>
      <contributor>
        <username>Bongz007</username>
        <id>1689</id>
      </contributor>
      <comment>Created by translating the page &quot;[[:en:Special:Redirect/revision/1171390177|Ekangala]]&quot;</comment>
      <origin>6789</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="169" sha1="mep9kcneicpslyldm7v9hjrmo21lpn0" xml:space="preserve">

'''I-Ekangala''' lilokishi elikhulu eliwela ngaphasi kweDorobha le-Tshwane esifundazweni se -Gauteng [[Isewula Afrika|eSewula Afrika]] . Iseduze nomngcele we Pumalanga</text>
      <sha1>mep9kcneicpslyldm7v9hjrmo21lpn0</sha1>
    </revision>
  </page>
  <page>
    <title>Bucs Mthombeni</title>
    <ns>0</ns>
    <id>1225</id>
    <revision>
      <id>6790</id>
      <timestamp>2026-08-15T10:48:13Z</timestamp>
      <contributor>
        <username>SandisiweMahlangu</username>
        <id>1620</id>
      </contributor>
      <comment>Created page with &quot;'''U-Bucs''' Mthombeni umubanduli wesiqhema i-Casric stars uthome ukubandula isiqhema mhla amalanga ali 10 KuNobayeni ngonyaka u 2024.&lt;ref&gt;{{Cite web |title=Bucs Mthombeni - Manager profile |url=https://www.transfermarkt.com/bucs-mthombeni/profil/trainer/115700 |access-date=2026-08-15 |website=www.transfermarkt.com |language=en}}&lt;/ref&gt;  ===== Imithombo Yelwazi =====&quot;</comment>
      <origin>6790</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="368" sha1="a7wugfrpzjm6y540r6ikgrryrcgsybj" xml:space="preserve">'''U-Bucs''' Mthombeni umubanduli wesiqhema i-Casric stars uthome ukubandula isiqhema mhla amalanga ali 10 KuNobayeni ngonyaka u 2024.&lt;ref&gt;{{Cite web |title=Bucs Mthombeni - Manager profile |url=https://www.transfermarkt.com/bucs-mthombeni/profil/trainer/115700 |access-date=2026-08-15 |website=www.transfermarkt.com |language=en}}&lt;/ref&gt;

===== Imithombo Yelwazi =====</text>
      <sha1>a7wugfrpzjm6y540r6ikgrryrcgsybj</sha1>
    </revision>
  </page>
  <page>
    <title>UBULELESI NGEENKOLWENI</title>
    <ns>0</ns>
    <id>1226</id>
    <revision>
      <id>6791</id>
      <timestamp>2026-08-15T10:48:32Z</timestamp>
      <contributor>
        <username>Naledi Mahlangu</username>
        <id>1617</id>
      </contributor>
      <comment>Created page with &quot;'UmNyango wezeFundo''' ukutlhogomele khulu ukubaluleka kwabafundi,abotitjhere kanye nomphakathi eenkolweni.&lt;ref&gt;Department of Education&lt;/ref&gt; https://www.education.gov.za/  ==== Imithombo yelwazi. ====&quot;</comment>
      <origin>6791</origin>
      <model>wikitext</model>
      <format>text/x-wiki</format>
      <text bytes="201" sha1="ae74e75qphq5ridqlb3d4v6it77vl7m" xml:space="preserve">'UmNyango wezeFundo''' ukutlhogomele khulu ukubaluleka kwabafundi,abotitjhere kanye nomphakathi eenkolweni.&lt;ref&gt;Department of Education&lt;/ref&gt;
https://www.education.gov.za/

==== Imithombo yelwazi. ====</text>
      <sha1>ae74e75qphq5ridqlb3d4v6it77vl7m</sha1>
    </revision>
  </page>
</mediawiki>